summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/accessibility/AccessibleControlShape.cxx923
-rw-r--r--svx/source/accessibility/AccessibleEmptyEditSource.cxx359
-rw-r--r--svx/source/accessibility/AccessibleEmptyEditSource.hxx102
-rw-r--r--svx/source/accessibility/AccessibleFrameSelector.cxx732
-rw-r--r--svx/source/accessibility/AccessibleGraphicShape.cxx215
-rw-r--r--svx/source/accessibility/AccessibleOLEShape.cxx234
-rw-r--r--svx/source/accessibility/AccessibleShape.cxx1241
-rw-r--r--svx/source/accessibility/AccessibleShapeInfo.cxx87
-rw-r--r--svx/source/accessibility/AccessibleShapeTreeInfo.cxx226
-rw-r--r--svx/source/accessibility/AccessibleTextEventQueue.cxx114
-rw-r--r--svx/source/accessibility/AccessibleTextEventQueue.hxx106
-rw-r--r--svx/source/accessibility/AccessibleTextHelper.cxx2080
-rw-r--r--svx/source/accessibility/ChildrenManager.cxx180
-rw-r--r--svx/source/accessibility/ChildrenManagerImpl.cxx1098
-rw-r--r--svx/source/accessibility/ChildrenManagerImpl.hxx579
-rw-r--r--svx/source/accessibility/DGColorNameLookUp.cxx151
-rw-r--r--svx/source/accessibility/DescriptionGenerator.cxx485
-rw-r--r--svx/source/accessibility/GraphCtlAccessibleContext.cxx1027
-rw-r--r--svx/source/accessibility/ShapeTypeHandler.cxx341
-rw-r--r--svx/source/accessibility/SvxShapeTypes.cxx210
-rw-r--r--svx/source/accessibility/accessibility.src262
-rw-r--r--svx/source/accessibility/charmapacc.cxx893
-rwxr-xr-xsvx/source/accessibility/makefile.mk68
-rw-r--r--svx/source/accessibility/svxrectctaccessiblecontext.cxx1208
-rw-r--r--svx/source/core/coreservices.cxx186
-rw-r--r--svx/source/core/makefile.mk47
-rw-r--r--svx/source/customshapes/EnhancedCustomShape2d.cxx2187
-rw-r--r--svx/source/customshapes/EnhancedCustomShape2d.hxx223
-rw-r--r--svx/source/customshapes/EnhancedCustomShape3d.cxx755
-rw-r--r--svx/source/customshapes/EnhancedCustomShape3d.hxx80
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeEngine.cxx472
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeEngine.hxx127
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFontWork.cxx909
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFontWork.hxx47
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx1214
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeGeometry.cxx8276
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeGeometry.hxx104
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeHandle.cxx96
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeHandle.hxx72
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx324
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeTypeNames.hxx42
-rw-r--r--svx/source/customshapes/makefile.mk71
-rw-r--r--svx/source/customshapes/tbxcustomshapes.cxx204
-rw-r--r--svx/source/dialog/SpellDialogChildWindow.cxx122
-rw-r--r--svx/source/dialog/_bmpmask.cxx1244
-rw-r--r--svx/source/dialog/_contdlg.cxx1161
-rw-r--r--svx/source/dialog/bmpmask.hrc62
-rw-r--r--svx/source/dialog/bmpmask.src358
-rw-r--r--svx/source/dialog/charmap.cxx896
-rw-r--r--svx/source/dialog/checklbx.cxx279
-rw-r--r--svx/source/dialog/connctrl.cxx389
-rw-r--r--svx/source/dialog/contdlg.hrc87
-rw-r--r--svx/source/dialog/contdlg.src288
-rw-r--r--svx/source/dialog/contimp.hxx127
-rw-r--r--svx/source/dialog/contwnd.cxx361
-rw-r--r--svx/source/dialog/contwnd.hxx92
-rw-r--r--svx/source/dialog/ctredlin.cxx1533
-rw-r--r--svx/source/dialog/ctredlin.hrc70
-rw-r--r--svx/source/dialog/ctredlin.src365
-rw-r--r--svx/source/dialog/databaseregistrationui.cxx65
-rw-r--r--svx/source/dialog/dialcontrol.cxx574
-rw-r--r--svx/source/dialog/dialmgr.cxx57
-rw-r--r--svx/source/dialog/dlgctl3d.cxx1326
-rw-r--r--svx/source/dialog/dlgctrl.cxx2288
-rw-r--r--svx/source/dialog/dlgctrl.src34
-rw-r--r--svx/source/dialog/dlgutil.cxx91
-rw-r--r--svx/source/dialog/docrecovery.cxx2182
-rw-r--r--svx/source/dialog/docrecovery.hrc292
-rw-r--r--svx/source/dialog/docrecovery.src635
-rw-r--r--svx/source/dialog/fntctrl.cxx852
-rw-r--r--svx/source/dialog/fontlb.cxx191
-rw-r--r--svx/source/dialog/fontwork.cxx1286
-rw-r--r--svx/source/dialog/fontwork.hrc67
-rw-r--r--svx/source/dialog/fontwork.src555
-rw-r--r--svx/source/dialog/framelink.cxx1436
-rw-r--r--svx/source/dialog/framelinkarray.cxx1249
-rw-r--r--svx/source/dialog/frmdirlbox.cxx129
-rw-r--r--svx/source/dialog/frmsel.cxx1228
-rw-r--r--svx/source/dialog/frmsel.src70
-rw-r--r--svx/source/dialog/graphctl.cxx961
-rw-r--r--svx/source/dialog/grfflt.cxx347
-rw-r--r--svx/source/dialog/hdft.cxx983
-rw-r--r--svx/source/dialog/hdft.hrc52
-rw-r--r--svx/source/dialog/hdft.src365
-rw-r--r--svx/source/dialog/hyperdlg.cxx108
-rw-r--r--svx/source/dialog/hyprdlg.hxx145
-rw-r--r--svx/source/dialog/hyprlink.cxx1001
-rw-r--r--svx/source/dialog/hyprlink.hrc58
-rw-r--r--svx/source/dialog/hyprlink.hxx45
-rw-r--r--svx/source/dialog/hyprlink.src167
-rw-r--r--svx/source/dialog/imapdlg.cxx1052
-rw-r--r--svx/source/dialog/imapdlg.hrc106
-rw-r--r--svx/source/dialog/imapdlg.src365
-rw-r--r--svx/source/dialog/imapimp.hxx59
-rw-r--r--svx/source/dialog/imapwnd.cxx1072
-rw-r--r--svx/source/dialog/imapwnd.hxx228
-rw-r--r--svx/source/dialog/langbox.cxx528
-rw-r--r--svx/source/dialog/langbox.src49
-rw-r--r--svx/source/dialog/language.src66
-rw-r--r--svx/source/dialog/linkwarn.cxx150
-rw-r--r--svx/source/dialog/linkwarn.hrc60
-rw-r--r--svx/source/dialog/linkwarn.src85
-rw-r--r--svx/source/dialog/makefile.mk156
-rw-r--r--svx/source/dialog/measctrl.cxx201
-rw-r--r--svx/source/dialog/optgrid.cxx421
-rw-r--r--svx/source/dialog/optgrid.hrc71
-rw-r--r--svx/source/dialog/optgrid.src353
-rw-r--r--svx/source/dialog/orienthelper.cxx206
-rw-r--r--svx/source/dialog/pagectrl.cxx424
-rw-r--r--svx/source/dialog/paraprev.cxx240
-rw-r--r--svx/source/dialog/passwd.cxx136
-rw-r--r--svx/source/dialog/passwd.hrc51
-rw-r--r--svx/source/dialog/passwd.src153
-rw-r--r--svx/source/dialog/pfiledlg.cxx288
-rw-r--r--svx/source/dialog/prtqry.cxx62
-rw-r--r--svx/source/dialog/prtqry.src74
-rw-r--r--svx/source/dialog/relfld.cxx148
-rw-r--r--svx/source/dialog/rlrcitem.cxx168
-rw-r--r--svx/source/dialog/rlrcitem.hxx53
-rw-r--r--svx/source/dialog/rubydialog.cxx990
-rw-r--r--svx/source/dialog/rubydialog.hrc53
-rw-r--r--svx/source/dialog/rubydialog.src207
-rw-r--r--svx/source/dialog/ruler.hrc38
-rw-r--r--svx/source/dialog/ruler.src149
-rw-r--r--svx/source/dialog/rulritem.cxx745
-rw-r--r--svx/source/dialog/sdstring.src1291
-rw-r--r--svx/source/dialog/sendreportgen.cxx56
-rw-r--r--svx/source/dialog/sendreportunx.cxx275
-rw-r--r--svx/source/dialog/sendreportw32.cxx264
-rw-r--r--svx/source/dialog/simptabl.cxx580
-rw-r--r--svx/source/dialog/srchctrl.cxx92
-rw-r--r--svx/source/dialog/srchctrl.hxx53
-rw-r--r--svx/source/dialog/srchdlg.cxx2581
-rw-r--r--svx/source/dialog/srchdlg.hrc93
-rw-r--r--svx/source/dialog/srchdlg.src411
-rw-r--r--svx/source/dialog/stddlg.cxx67
-rw-r--r--svx/source/dialog/strarray.cxx101
-rw-r--r--svx/source/dialog/svxbmpnumvalueset.cxx571
-rw-r--r--svx/source/dialog/svxbmpnumvalueset.src127
-rw-r--r--svx/source/dialog/svxdlg.cxx43
-rw-r--r--svx/source/dialog/svxgrahicitem.cxx53
-rw-r--r--svx/source/dialog/svxruler.cxx3961
-rw-r--r--svx/source/dialog/swframeexample.cxx739
-rw-r--r--svx/source/dialog/swframeposstrings.cxx79
-rw-r--r--svx/source/dialog/swframeposstrings.src245
-rw-r--r--svx/source/dialog/txencbox.cxx256
-rw-r--r--svx/source/dialog/txenctab.cxx78
-rw-r--r--svx/source/dialog/txenctab.src122
-rwxr-xr-xsvx/source/dialog/ucsubset.src511
-rw-r--r--svx/source/dialog/wrapfield.cxx63
-rw-r--r--svx/source/engine3d/camera3d.cxx395
-rw-r--r--svx/source/engine3d/cube3d.cxx202
-rw-r--r--svx/source/engine3d/deflt3d.cxx84
-rw-r--r--svx/source/engine3d/dragmt3d.cxx792
-rw-r--r--svx/source/engine3d/e3dsceneupdater.cxx133
-rw-r--r--svx/source/engine3d/e3dundo.cxx182
-rw-r--r--svx/source/engine3d/extrud3d.cxx267
-rw-r--r--svx/source/engine3d/float3d.cxx3335
-rw-r--r--svx/source/engine3d/float3d.src1420
-rw-r--r--svx/source/engine3d/helperhittest3d.cxx298
-rw-r--r--svx/source/engine3d/helperminimaldepth3d.cxx215
-rw-r--r--svx/source/engine3d/helperminimaldepth3d.hxx63
-rw-r--r--svx/source/engine3d/lathe3d.cxx280
-rw-r--r--svx/source/engine3d/makefile.mk76
-rw-r--r--svx/source/engine3d/obj3d.cxx1283
-rw-r--r--svx/source/engine3d/objfac3d.cxx112
-rw-r--r--svx/source/engine3d/polygn3d.cxx364
-rw-r--r--svx/source/engine3d/polysc3d.cxx77
-rw-r--r--svx/source/engine3d/scene3d.cxx887
-rw-r--r--svx/source/engine3d/sphere3d.cxx229
-rw-r--r--svx/source/engine3d/string3d.src116
-rw-r--r--svx/source/engine3d/svx3ditems.cxx550
-rw-r--r--svx/source/engine3d/view3d.cxx1930
-rw-r--r--svx/source/engine3d/view3d1.cxx232
-rw-r--r--svx/source/engine3d/viewpt3d2.cxx397
-rw-r--r--svx/source/fmcomp/dbaexchange.cxx730
-rw-r--r--svx/source/fmcomp/dbaobjectex.cxx185
-rw-r--r--svx/source/fmcomp/fmgridcl.cxx2146
-rw-r--r--svx/source/fmcomp/fmgridif.cxx2968
-rw-r--r--svx/source/fmcomp/gridcell.cxx4842
-rw-r--r--svx/source/fmcomp/gridcols.cxx116
-rw-r--r--svx/source/fmcomp/gridctrl.cxx3888
-rw-r--r--svx/source/fmcomp/gridctrl.src257
-rw-r--r--svx/source/fmcomp/makefile.mk63
-rw-r--r--svx/source/fmcomp/trace.cxx127
-rw-r--r--svx/source/fmcomp/xmlexchg.cxx95
-rw-r--r--svx/source/form/ParseContext.cxx252
-rw-r--r--svx/source/form/dataaccessdescriptor.cxx569
-rw-r--r--svx/source/form/databaselocationinput.cxx317
-rw-r--r--svx/source/form/datalistener.cxx100
-rw-r--r--svx/source/form/datanavi.cxx3735
-rw-r--r--svx/source/form/datanavi.src1160
-rw-r--r--svx/source/form/dbcharsethelper.cxx61
-rw-r--r--svx/source/form/dbtoolsclient.cxx368
-rw-r--r--svx/source/form/delayedevent.cxx71
-rw-r--r--svx/source/form/filtnav.cxx2088
-rw-r--r--svx/source/form/filtnav.src87
-rw-r--r--svx/source/form/fmPropBrw.cxx727
-rw-r--r--svx/source/form/fmcontrolbordermanager.cxx443
-rw-r--r--svx/source/form/fmcontrollayout.cxx331
-rw-r--r--svx/source/form/fmdmod.cxx134
-rw-r--r--svx/source/form/fmdocumentclassification.cxx214
-rw-r--r--svx/source/form/fmdpage.cxx148
-rw-r--r--svx/source/form/fmexch.cxx443
-rw-r--r--svx/source/form/fmexpl.cxx698
-rw-r--r--svx/source/form/fmexpl.src378
-rw-r--r--svx/source/form/fmitems.cxx71
-rw-r--r--svx/source/form/fmmodel.cxx372
-rw-r--r--svx/source/form/fmobj.cxx739
-rw-r--r--svx/source/form/fmobjfac.cxx266
-rw-r--r--svx/source/form/fmpage.cxx274
-rw-r--r--svx/source/form/fmpgeimp.cxx742
-rw-r--r--svx/source/form/fmscriptingenv.cxx580
-rw-r--r--svx/source/form/fmservs.cxx109
-rw-r--r--svx/source/form/fmshell.cxx1513
-rw-r--r--svx/source/form/fmshimp.cxx4342
-rw-r--r--svx/source/form/fmsrccfg.cxx366
-rw-r--r--svx/source/form/fmsrcimp.cxx1300
-rw-r--r--svx/source/form/fmstring.src491
-rw-r--r--svx/source/form/fmtextcontroldialogs.cxx122
-rw-r--r--svx/source/form/fmtextcontrolfeature.cxx133
-rw-r--r--svx/source/form/fmtextcontrolshell.cxx1401
-rw-r--r--svx/source/form/fmtools.cxx498
-rw-r--r--svx/source/form/fmundo.cxx1350
-rw-r--r--svx/source/form/fmview.cxx628
-rw-r--r--svx/source/form/fmvwimp.cxx1961
-rw-r--r--svx/source/form/formcontrolfactory.cxx736
-rw-r--r--svx/source/form/formcontroller.cxx4320
-rw-r--r--svx/source/form/formcontrolling.cxx608
-rw-r--r--svx/source/form/formdispatchinterceptor.cxx217
-rw-r--r--svx/source/form/formfeaturedispatcher.cxx244
-rw-r--r--svx/source/form/formshell.src227
-rw-r--r--svx/source/form/formtoolbars.cxx117
-rw-r--r--svx/source/form/legacyformcontroller.cxx228
-rw-r--r--svx/source/form/makefile.mk123
-rw-r--r--svx/source/form/navigatortree.cxx2324
-rw-r--r--svx/source/form/navigatortreemodel.cxx1128
-rw-r--r--svx/source/form/sdbdatacolumn.cxx290
-rw-r--r--svx/source/form/sqlparserclient.cxx64
-rw-r--r--svx/source/form/stringlistresource.cxx74
-rw-r--r--svx/source/form/tabwin.cxx470
-rw-r--r--svx/source/form/tbxform.cxx473
-rw-r--r--svx/source/form/typeconversionclient.cxx60
-rw-r--r--svx/source/form/typemap.cxx63
-rw-r--r--svx/source/form/xfm_addcondition.cxx193
-rw-r--r--svx/source/gallery2/codec.cxx176
-rw-r--r--svx/source/gallery2/codec.hxx54
-rw-r--r--svx/source/gallery2/galbrws.cxx288
-rw-r--r--svx/source/gallery2/galbrws1.cxx716
-rw-r--r--svx/source/gallery2/galbrws1.hxx138
-rw-r--r--svx/source/gallery2/galbrws2.cxx1255
-rw-r--r--svx/source/gallery2/galctrl.cxx726
-rw-r--r--svx/source/gallery2/galexpl.cxx518
-rw-r--r--svx/source/gallery2/gallery.src493
-rw-r--r--svx/source/gallery2/gallery1.cxx925
-rw-r--r--svx/source/gallery2/gallerydrawmodel.hxx46
-rw-r--r--svx/source/gallery2/galmisc.cxx672
-rw-r--r--svx/source/gallery2/galobj.cxx610
-rw-r--r--svx/source/gallery2/galtheme.cxx1601
-rw-r--r--svx/source/gallery2/galtheme.src1031
-rw-r--r--svx/source/gallery2/makefile.mk65
-rw-r--r--svx/source/gengal/gengal.cxx321
-rw-r--r--svx/source/gengal/gengal.sh101
-rw-r--r--svx/source/gengal/gengalrc.in12
-rw-r--r--svx/source/gengal/makefile.mk85
-rw-r--r--svx/source/inc/AccessibleFrameSelector.hxx151
-rw-r--r--svx/source/inc/DGColorNameLookUp.hxx102
-rw-r--r--svx/source/inc/GraphCtlAccessibleContext.hxx279
-rw-r--r--svx/source/inc/charmapacc.hxx278
-rw-r--r--svx/source/inc/clonelist.hxx60
-rw-r--r--svx/source/inc/datalistener.hxx81
-rw-r--r--svx/source/inc/datanavi.hrc180
-rw-r--r--svx/source/inc/datanavi.hxx603
-rw-r--r--svx/source/inc/delayedevent.hxx90
-rw-r--r--svx/source/inc/docrecovery.hxx972
-rw-r--r--svx/source/inc/filtnav.hxx374
-rw-r--r--svx/source/inc/fmPropBrw.hxx127
-rw-r--r--svx/source/inc/fmcontrolbordermanager.hxx271
-rw-r--r--svx/source/inc/fmcontrollayout.hxx93
-rw-r--r--svx/source/inc/fmdocumentclassification.hxx89
-rw-r--r--svx/source/inc/fmexch.hxx285
-rw-r--r--svx/source/inc/fmexpl.hrc40
-rw-r--r--svx/source/inc/fmexpl.hxx614
-rw-r--r--svx/source/inc/fmgroup.hxx118
-rw-r--r--svx/source/inc/fmhlpids.hrc36
-rw-r--r--svx/source/inc/fmitems.hxx74
-rw-r--r--svx/source/inc/fmobj.hxx136
-rw-r--r--svx/source/inc/fmpgeimp.hxx172
-rw-r--r--svx/source/inc/fmprop.hrc179
-rw-r--r--svx/source/inc/fmresids.hrc264
-rw-r--r--svx/source/inc/fmscriptingenv.hxx101
-rw-r--r--svx/source/inc/fmservs.hxx92
-rw-r--r--svx/source/inc/fmshimp.hxx608
-rw-r--r--svx/source/inc/fmslotinvalidator.hxx57
-rw-r--r--svx/source/inc/fmsrccfg.hxx158
-rw-r--r--svx/source/inc/fmsrcimp.hxx411
-rw-r--r--svx/source/inc/fmtextcontroldialogs.hxx72
-rw-r--r--svx/source/inc/fmtextcontrolfeature.hxx107
-rw-r--r--svx/source/inc/fmtextcontrolshell.hxx226
-rw-r--r--svx/source/inc/fmundo.hxx232
-rw-r--r--svx/source/inc/fmurl.hxx63
-rw-r--r--svx/source/inc/fmvwimp.hxx317
-rw-r--r--svx/source/inc/formcontrolfactory.hxx122
-rw-r--r--svx/source/inc/formcontroller.hxx594
-rw-r--r--svx/source/inc/formcontrolling.hxx311
-rw-r--r--svx/source/inc/formdispatchinterceptor.hxx122
-rw-r--r--svx/source/inc/formfeaturedispatcher.hxx160
-rw-r--r--svx/source/inc/formtoolbars.hxx92
-rw-r--r--svx/source/inc/frmsel.hrc38
-rw-r--r--svx/source/inc/frmselimpl.hxx307
-rw-r--r--svx/source/inc/gridcell.hxx1158
-rw-r--r--svx/source/inc/gridcols.hxx64
-rw-r--r--svx/source/inc/linectrl.hrc28
-rw-r--r--svx/source/inc/recoveryui.hxx158
-rw-r--r--svx/source/inc/sdbdatacolumn.hxx143
-rw-r--r--svx/source/inc/sqlparserclient.hxx81
-rw-r--r--svx/source/inc/stringlistresource.hxx89
-rw-r--r--svx/source/inc/svdoimp.hxx105
-rw-r--r--svx/source/inc/svdoutlinercache.hxx56
-rw-r--r--svx/source/inc/svxrectctaccessiblecontext.hxx566
-rw-r--r--svx/source/inc/tabwin.hxx143
-rw-r--r--svx/source/inc/tbxform.hxx166
-rw-r--r--svx/source/inc/trace.hxx71
-rw-r--r--svx/source/inc/treevisitor.hxx112
-rw-r--r--svx/source/inc/typeconversionclient.hxx95
-rw-r--r--svx/source/inc/unogalthemeprovider.hxx103
-rw-r--r--svx/source/inc/unopolyhelper.hxx57
-rw-r--r--svx/source/inc/xfm_addcondition.hxx94
-rw-r--r--svx/source/inc/xmlxtexp.hxx72
-rw-r--r--svx/source/inc/xmlxtimp.hxx66
-rw-r--r--svx/source/intro/intro_tmpl.hrc1327
-rw-r--r--svx/source/intro/iso.src224
-rw-r--r--svx/source/intro/makefile.mk66
-rw-r--r--svx/source/intro/ooo.src212
-rw-r--r--svx/source/items/SmartTagItem.cxx118
-rw-r--r--svx/source/items/algitem.cxx438
-rw-r--r--svx/source/items/chrtitem.cxx538
-rw-r--r--svx/source/items/clipfmtitem.cxx182
-rw-r--r--svx/source/items/customshapeitem.cxx388
-rw-r--r--svx/source/items/drawitem.cxx560
-rw-r--r--svx/source/items/e3ditem.cxx173
-rw-r--r--svx/source/items/grfitem.cxx199
-rw-r--r--svx/source/items/hlnkitem.cxx424
-rw-r--r--svx/source/items/makefile.mk85
-rw-r--r--svx/source/items/numfmtsh.cxx1868
-rw-r--r--svx/source/items/numinf.cxx252
-rw-r--r--svx/source/items/ofaitem.cxx94
-rw-r--r--svx/source/items/pageitem.cxx340
-rw-r--r--svx/source/items/postattr.cxx194
-rw-r--r--svx/source/items/rotmodit.cxx174
-rw-r--r--svx/source/items/svxempty.cxx42
-rw-r--r--svx/source/items/svxerr.cxx56
-rw-r--r--svx/source/items/svxerr.src174
-rw-r--r--svx/source/items/svxitems.src353
-rw-r--r--svx/source/items/viewlayoutitem.cxx213
-rw-r--r--svx/source/items/zoomitem.cxx232
-rw-r--r--svx/source/items/zoomslideritem.cxx282
-rw-r--r--svx/source/mnuctrls/SmartTagCtl.cxx223
-rw-r--r--svx/source/mnuctrls/clipboardctl.cxx165
-rw-r--r--svx/source/mnuctrls/fntctl.cxx184
-rw-r--r--svx/source/mnuctrls/fntszctl.cxx213
-rw-r--r--svx/source/mnuctrls/makefile.mk71
-rw-r--r--svx/source/mnuctrls/mnuctrls.src81
-rw-r--r--svx/source/sdr/animation/animationstate.cxx151
-rw-r--r--svx/source/sdr/animation/makefile.mk46
-rw-r--r--svx/source/sdr/animation/objectanimator.cxx55
-rw-r--r--svx/source/sdr/animation/scheduler.cxx318
-rw-r--r--svx/source/sdr/attribute/makefile.mk50
-rw-r--r--svx/source/sdr/attribute/sdrfilltextattribute.cxx95
-rw-r--r--svx/source/sdr/attribute/sdrformtextattribute.cxx426
-rw-r--r--svx/source/sdr/attribute/sdrformtextoutlineattribute.cxx188
-rw-r--r--svx/source/sdr/attribute/sdrlinefillshadowtextattribute.cxx98
-rw-r--r--svx/source/sdr/attribute/sdrlineshadowtextattribute.cxx96
-rw-r--r--svx/source/sdr/attribute/sdrshadowtextattribute.cxx88
-rw-r--r--svx/source/sdr/attribute/sdrtextattribute.cxx476
-rw-r--r--svx/source/sdr/contact/displayinfo.cxx113
-rw-r--r--svx/source/sdr/contact/makefile.mk92
-rw-r--r--svx/source/sdr/contact/objectcontact.cxx325
-rw-r--r--svx/source/sdr/contact/objectcontactofobjlistpainter.cxx210
-rw-r--r--svx/source/sdr/contact/objectcontactofpageview.cxx488
-rw-r--r--svx/source/sdr/contact/objectcontacttools.cxx107
-rw-r--r--svx/source/sdr/contact/sdrmediawindow.cxx196
-rw-r--r--svx/source/sdr/contact/sdrmediawindow.hxx71
-rw-r--r--svx/source/sdr/contact/viewcontact.cxx332
-rw-r--r--svx/source/sdr/contact/viewcontactofe3d.cxx230
-rw-r--r--svx/source/sdr/contact/viewcontactofe3dcube.cxx108
-rw-r--r--svx/source/sdr/contact/viewcontactofe3dextrude.cxx103
-rw-r--r--svx/source/sdr/contact/viewcontactofe3dlathe.cxx118
-rw-r--r--svx/source/sdr/contact/viewcontactofe3dpolygon.cxx189
-rw-r--r--svx/source/sdr/contact/viewcontactofe3dscene.cxx481
-rw-r--r--svx/source/sdr/contact/viewcontactofe3dsphere.cxx101
-rw-r--r--svx/source/sdr/contact/viewcontactofgraphic.cxx466
-rw-r--r--svx/source/sdr/contact/viewcontactofgroup.cxx106
-rw-r--r--svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx129
-rw-r--r--svx/source/sdr/contact/viewcontactofpageobj.cxx108
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx182
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrcircobj.cxx120
-rw-r--r--svx/source/sdr/contact/viewcontactofsdredgeobj.cxx82
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrmeasureobj.cxx146
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx187
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrobj.cxx197
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx244
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrole2obj.cxx133
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrpage.cxx696
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrpathobj.cxx148
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrrectobj.cxx107
-rw-r--r--svx/source/sdr/contact/viewcontactoftextobj.cxx54
-rw-r--r--svx/source/sdr/contact/viewcontactofunocontrol.cxx184
-rw-r--r--svx/source/sdr/contact/viewcontactofvirtobj.cxx119
-rw-r--r--svx/source/sdr/contact/viewobjectcontact.cxx441
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofe3d.cxx104
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx151
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofgraphic.cxx330
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofgroup.cxx118
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx156
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofpageobj.cxx355
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofsdrmediaobj.cxx179
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx155
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx246
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx726
-rw-r--r--svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx1927
-rw-r--r--svx/source/sdr/contact/viewobjectcontactredirector.cxx63
-rw-r--r--svx/source/sdr/event/eventhandler.cxx165
-rw-r--r--svx/source/sdr/event/makefile.mk44
-rw-r--r--svx/source/sdr/overlay/makefile.mk59
-rw-r--r--svx/source/sdr/overlay/overlayanimatedbitmapex.cxx220
-rw-r--r--svx/source/sdr/overlay/overlaybitmapex.cxx116
-rw-r--r--svx/source/sdr/overlay/overlaycrosshair.cxx87
-rw-r--r--svx/source/sdr/overlay/overlayhatchrect.cxx97
-rw-r--r--svx/source/sdr/overlay/overlayhelpline.cxx96
-rw-r--r--svx/source/sdr/overlay/overlayline.cxx110
-rw-r--r--svx/source/sdr/overlay/overlaymanager.cxx396
-rw-r--r--svx/source/sdr/overlay/overlaymanagerbuffered.cxx541
-rw-r--r--svx/source/sdr/overlay/overlayobject.cxx219
-rw-r--r--svx/source/sdr/overlay/overlayobjectcell.cxx114
-rw-r--r--svx/source/sdr/overlay/overlayobjectlist.cxx187
-rw-r--r--svx/source/sdr/overlay/overlaypolypolygon.cxx102
-rw-r--r--svx/source/sdr/overlay/overlayprimitive2dsequenceobject.cxx64
-rw-r--r--svx/source/sdr/overlay/overlayrollingrectangle.cxx153
-rw-r--r--svx/source/sdr/overlay/overlayselection.cxx240
-rw-r--r--svx/source/sdr/overlay/overlaytools.cxx496
-rw-r--r--svx/source/sdr/overlay/overlaytriangle.cxx109
-rw-r--r--svx/source/sdr/primitive2d/makefile.mk57
-rw-r--r--svx/source/sdr/primitive2d/primitivefactory2d.cxx135
-rw-r--r--svx/source/sdr/primitive2d/sdrattributecreator.cxx1031
-rw-r--r--svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx180
-rw-r--r--svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx127
-rw-r--r--svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx133
-rw-r--r--svx/source/sdr/primitive2d/sdrdecompositiontools.cxx494
-rw-r--r--svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx281
-rw-r--r--svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx180
-rw-r--r--svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx513
-rw-r--r--svx/source/sdr/primitive2d/sdrole2primitive2d.cxx193
-rw-r--r--svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx204
-rw-r--r--svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx150
-rw-r--r--svx/source/sdr/primitive2d/sdrprimitivetools.cxx179
-rw-r--r--svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx165
-rw-r--r--svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx549
-rw-r--r--svx/source/sdr/primitive3d/makefile.mk42
-rw-r--r--svx/source/sdr/primitive3d/sdrattributecreator3d.cxx161
-rw-r--r--svx/source/sdr/properties/attributeproperties.cxx631
-rw-r--r--svx/source/sdr/properties/captionproperties.cxx123
-rw-r--r--svx/source/sdr/properties/circleproperties.cxx160
-rw-r--r--svx/source/sdr/properties/connectorproperties.cxx110
-rw-r--r--svx/source/sdr/properties/customshapeproperties.cxx242
-rw-r--r--svx/source/sdr/properties/defaultproperties.cxx240
-rw-r--r--svx/source/sdr/properties/e3dcompoundproperties.cxx168
-rw-r--r--svx/source/sdr/properties/e3dextrudeproperties.cxx93
-rw-r--r--svx/source/sdr/properties/e3dlatheproperties.cxx103
-rw-r--r--svx/source/sdr/properties/e3dproperties.cxx109
-rw-r--r--svx/source/sdr/properties/e3dsceneproperties.cxx337
-rw-r--r--svx/source/sdr/properties/e3dsphereproperties.cxx88
-rw-r--r--svx/source/sdr/properties/emptyproperties.cxx156
-rw-r--r--svx/source/sdr/properties/graphicproperties.cxx146
-rw-r--r--svx/source/sdr/properties/groupproperties.cxx301
-rw-r--r--svx/source/sdr/properties/itemsettools.cxx149
-rw-r--r--svx/source/sdr/properties/makefile.mk65
-rw-r--r--svx/source/sdr/properties/measureproperties.cxx144
-rw-r--r--svx/source/sdr/properties/oleproperties.cxx83
-rw-r--r--svx/source/sdr/properties/pageproperties.cxx104
-rw-r--r--svx/source/sdr/properties/properties.cxx192
-rw-r--r--svx/source/sdr/properties/rectangleproperties.cxx87
-rw-r--r--svx/source/sdr/properties/textproperties.cxx641
-rw-r--r--svx/source/smarttags/SmartTagMgr.cxx554
-rw-r--r--svx/source/smarttags/makefile.mk48
-rw-r--r--svx/source/src/app.hrc447
-rw-r--r--svx/source/src/app.src86
-rw-r--r--svx/source/src/hidgen.hrc33
-rw-r--r--svx/source/src/makefile.mk57
-rw-r--r--svx/source/stbctrls/insctrl.cxx132
-rw-r--r--svx/source/stbctrls/makefile.mk75
-rw-r--r--svx/source/stbctrls/modctrl.cxx157
-rw-r--r--svx/source/stbctrls/pszctrl.cxx436
-rw-r--r--svx/source/stbctrls/selctrl.cxx154
-rw-r--r--svx/source/stbctrls/stbctrls.h57
-rw-r--r--svx/source/stbctrls/stbctrls.src353
-rw-r--r--svx/source/stbctrls/xmlsecctrl.cxx191
-rw-r--r--svx/source/stbctrls/zoomctrl.cxx220
-rw-r--r--svx/source/stbctrls/zoomsliderctrl.cxx447
-rw-r--r--svx/source/svdraw/ActionDescriptionProvider.cxx85
-rw-r--r--svx/source/svdraw/clonelist.cxx137
-rw-r--r--svx/source/svdraw/gradtrns.cxx541
-rw-r--r--svx/source/svdraw/gradtrns.hxx66
-rw-r--r--svx/source/svdraw/impgrfll.cxx258
-rw-r--r--svx/source/svdraw/makefile.mk124
-rw-r--r--svx/source/svdraw/polypolygoneditor.cxx193
-rw-r--r--svx/source/svdraw/sdrcomment.cxx101
-rw-r--r--svx/source/svdraw/sdrhittesthelper.cxx176
-rw-r--r--svx/source/svdraw/sdrmasterpagedescriptor.cxx145
-rw-r--r--svx/source/svdraw/sdrpagewindow.cxx467
-rw-r--r--svx/source/svdraw/sdrpaintwindow.cxx315
-rw-r--r--svx/source/svdraw/selectioncontroller.cxx117
-rw-r--r--svx/source/svdraw/svdattr.cxx2432
-rw-r--r--svx/source/svdraw/svdcrtv.cxx966
-rw-r--r--svx/source/svdraw/svddrag.cxx155
-rw-r--r--svx/source/svdraw/svddrgm1.hxx280
-rw-r--r--svx/source/svdraw/svddrgmt.cxx3655
-rw-r--r--svx/source/svdraw/svddrgv.cxx1009
-rw-r--r--svx/source/svdraw/svdedtv.cxx1088
-rw-r--r--svx/source/svdraw/svdedtv1.cxx1772
-rw-r--r--svx/source/svdraw/svdedtv2.cxx2141
-rw-r--r--svx/source/svdraw/svdedxv.cxx2146
-rw-r--r--svx/source/svdraw/svdetc.cxx1121
-rw-r--r--svx/source/svdraw/svdfmtf.cxx1031
-rw-r--r--svx/source/svdraw/svdfmtf.hxx169
-rw-r--r--svx/source/svdraw/svdglev.cxx424
-rw-r--r--svx/source/svdraw/svdglue.cxx453
-rw-r--r--svx/source/svdraw/svdhdl.cxx2420
-rw-r--r--svx/source/svdraw/svdhlpln.cxx152
-rw-r--r--svx/source/svdraw/svdibrow.cxx1301
-rw-r--r--svx/source/svdraw/svditer.cxx113
-rw-r--r--svx/source/svdraw/svditext.hxx39
-rw-r--r--svx/source/svdraw/svdlayer.cxx460
-rw-r--r--svx/source/svdraw/svdmark.cxx1043
-rw-r--r--svx/source/svdraw/svdmodel.cxx2257
-rw-r--r--svx/source/svdraw/svdmrkv.cxx2179
-rw-r--r--svx/source/svdraw/svdmrkv1.cxx726
-rw-r--r--svx/source/svdraw/svdoashp.cxx3507
-rw-r--r--svx/source/svdraw/svdoattr.cxx182
-rw-r--r--svx/source/svdraw/svdobj.cxx3313
-rw-r--r--svx/source/svdraw/svdocapt.cxx854
-rw-r--r--svx/source/svdraw/svdocirc.cxx1174
-rw-r--r--svx/source/svdraw/svdoedge.cxx2497
-rw-r--r--svx/source/svdraw/svdograf.cxx1285
-rw-r--r--svx/source/svdraw/svdogrp.cxx804
-rw-r--r--svx/source/svdraw/svdomeas.cxx1497
-rw-r--r--svx/source/svdraw/svdomedia.cxx288
-rw-r--r--svx/source/svdraw/svdoole2.cxx2245
-rw-r--r--svx/source/svdraw/svdopage.cxx198
-rw-r--r--svx/source/svdraw/svdopath.cxx3121
-rw-r--r--svx/source/svdraw/svdorect.cxx623
-rw-r--r--svx/source/svdraw/svdotext.cxx2215
-rw-r--r--svx/source/svdraw/svdotextdecomposition.cxx1397
-rw-r--r--svx/source/svdraw/svdotextpathdecomposition.cxx827
-rw-r--r--svx/source/svdraw/svdotxat.cxx464
-rw-r--r--svx/source/svdraw/svdotxdr.cxx287
-rw-r--r--svx/source/svdraw/svdotxed.cxx357
-rw-r--r--svx/source/svdraw/svdotxfl.cxx60
-rw-r--r--svx/source/svdraw/svdotxln.cxx352
-rw-r--r--svx/source/svdraw/svdotxtr.cxx552
-rw-r--r--svx/source/svdraw/svdouno.cxx668
-rw-r--r--svx/source/svdraw/svdoutl.cxx135
-rw-r--r--svx/source/svdraw/svdoutlinercache.cxx117
-rw-r--r--svx/source/svdraw/svdovirt.cxx662
-rw-r--r--svx/source/svdraw/svdpage.cxx2035
-rw-r--r--svx/source/svdraw/svdpagv.cxx1125
-rw-r--r--svx/source/svdraw/svdpntv.cxx1543
-rw-r--r--svx/source/svdraw/svdpoev.cxx748
-rw-r--r--svx/source/svdraw/svdsnpv.cxx733
-rw-r--r--svx/source/svdraw/svdstr.src2935
-rw-r--r--svx/source/svdraw/svdtext.cxx227
-rw-r--r--svx/source/svdraw/svdtrans.cxx1276
-rw-r--r--svx/source/svdraw/svdundo.cxx1874
-rw-r--r--svx/source/svdraw/svdview.cxx1608
-rw-r--r--svx/source/svdraw/svdviter.cxx353
-rw-r--r--svx/source/svdraw/svdxcgv.cxx897
-rw-r--r--svx/source/table/accessiblecell.cxx587
-rw-r--r--svx/source/table/accessiblecell.hxx152
-rw-r--r--svx/source/table/accessibletableshape.cxx726
-rw-r--r--svx/source/table/cell.cxx1811
-rw-r--r--svx/source/table/cell.hxx247
-rw-r--r--svx/source/table/cellcursor.cxx593
-rw-r--r--svx/source/table/cellcursor.hxx86
-rw-r--r--svx/source/table/celleditsource.cxx1058
-rw-r--r--svx/source/table/celleditsource.hxx92
-rw-r--r--svx/source/table/cellrange.cxx135
-rw-r--r--svx/source/table/cellrange.hxx75
-rw-r--r--svx/source/table/celltypes.hxx111
-rw-r--r--svx/source/table/makefile.mk80
-rw-r--r--svx/source/table/propertyset.cxx262
-rw-r--r--svx/source/table/propertyset.hxx112
-rw-r--r--svx/source/table/svdotable.cxx2823
-rw-r--r--svx/source/table/table.src34
-rw-r--r--svx/source/table/tablecolumn.cxx308
-rw-r--r--svx/source/table/tablecolumn.hxx91
-rw-r--r--svx/source/table/tablecolumns.cxx144
-rw-r--r--svx/source/table/tablecolumns.hxx74
-rw-r--r--svx/source/table/tablecontroller.cxx2621
-rw-r--r--svx/source/table/tablecontroller.hxx172
-rw-r--r--svx/source/table/tabledesign.cxx810
-rw-r--r--svx/source/table/tablehandles.cxx317
-rw-r--r--svx/source/table/tablehandles.hxx99
-rw-r--r--svx/source/table/tablelayouter.cxx1303
-rw-r--r--svx/source/table/tablelayouter.hxx181
-rw-r--r--svx/source/table/tablemodel.cxx1260
-rw-r--r--svx/source/table/tablemodel.hxx228
-rw-r--r--svx/source/table/tablerow.cxx384
-rw-r--r--svx/source/table/tablerow.hxx95
-rw-r--r--svx/source/table/tablerows.cxx139
-rw-r--r--svx/source/table/tablerows.hxx74
-rw-r--r--svx/source/table/tablertfexporter.cxx285
-rw-r--r--svx/source/table/tablertfimporter.cxx449
-rw-r--r--svx/source/table/tableundo.cxx562
-rw-r--r--svx/source/table/tableundo.hxx262
-rw-r--r--svx/source/table/viewcontactoftableobj.cxx743
-rw-r--r--svx/source/table/viewcontactoftableobj.hxx75
-rw-r--r--svx/source/tbxctrls/colorwindow.hxx51
-rw-r--r--svx/source/tbxctrls/colrctrl.cxx664
-rw-r--r--svx/source/tbxctrls/colrctrl.src83
-rw-r--r--svx/source/tbxctrls/extrusioncontrols.cxx1051
-rw-r--r--svx/source/tbxctrls/extrusioncontrols.hrc120
-rw-r--r--svx/source/tbxctrls/extrusioncontrols.hxx262
-rw-r--r--svx/source/tbxctrls/extrusioncontrols.src796
-rw-r--r--svx/source/tbxctrls/fillctrl.cxx848
-rw-r--r--svx/source/tbxctrls/fontworkgallery.cxx821
-rw-r--r--svx/source/tbxctrls/fontworkgallery.src323
-rw-r--r--svx/source/tbxctrls/formatpaintbrushctrl.cxx123
-rw-r--r--svx/source/tbxctrls/grafctrl.cxx1290
-rw-r--r--svx/source/tbxctrls/grafctrl.hrc28
-rw-r--r--svx/source/tbxctrls/grafctrl.src192
-rw-r--r--svx/source/tbxctrls/itemwin.cxx828
-rw-r--r--svx/source/tbxctrls/layctrl.cxx850
-rw-r--r--svx/source/tbxctrls/lboxctrl.cxx349
-rw-r--r--svx/source/tbxctrls/lboxctrl.hrc30
-rw-r--r--svx/source/tbxctrls/lboxctrl.src69
-rw-r--r--svx/source/tbxctrls/linectrl.cxx785
-rw-r--r--svx/source/tbxctrls/linectrl.src34
-rw-r--r--svx/source/tbxctrls/makefile.mk84
-rw-r--r--svx/source/tbxctrls/subtoolboxcontrol.cxx87
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx2887
-rw-r--r--svx/source/tbxctrls/tbcontrl.src189
-rw-r--r--svx/source/tbxctrls/tbunocontroller.cxx432
-rw-r--r--svx/source/tbxctrls/tbunosearchcontrollers.cxx876
-rw-r--r--svx/source/tbxctrls/tbunosearchcontrollers.src33
-rw-r--r--svx/source/tbxctrls/tbxalign.cxx142
-rw-r--r--svx/source/tbxctrls/tbxcolor.cxx120
-rw-r--r--svx/source/tbxctrls/tbxcolorupdate.cxx211
-rw-r--r--svx/source/tbxctrls/tbxdraw.hrc31
-rw-r--r--svx/source/tbxctrls/tbxdraw.src265
-rw-r--r--svx/source/tbxctrls/tbxdrctl.cxx122
-rw-r--r--svx/source/tbxctrls/verttexttbxctrl.cxx125
-rw-r--r--svx/source/toolbars/extrusionbar.cxx1373
-rw-r--r--svx/source/toolbars/extrusionbar.src115
-rw-r--r--svx/source/toolbars/fontworkbar.cxx642
-rw-r--r--svx/source/toolbars/fontworkbar.src87
-rw-r--r--svx/source/toolbars/makefile.mk56
-rw-r--r--svx/source/unodialogs/inc/buttongroup.hrc65
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx894
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hrc53
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hxx202
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.src184
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_direction_ids.hrc34
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_direction_tmpl.hrc51
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx288
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.hxx146
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.cxx202
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.hrc44
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.hxx91
-rw-r--r--svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.src117
-rw-r--r--svx/source/unodialogs/textconversiondlgs/makefile.mk90
-rw-r--r--svx/source/unodialogs/textconversiondlgs/resid.cxx55
-rw-r--r--svx/source/unodialogs/textconversiondlgs/resid.hxx53
-rw-r--r--svx/source/unodialogs/textconversiondlgs/resids.hrc33
-rw-r--r--svx/source/unodialogs/textconversiondlgs/services.cxx73
-rw-r--r--svx/source/unodraw/UnoGraphicExporter.cxx1285
-rw-r--r--svx/source/unodraw/UnoGraphicExporter.hxx43
-rw-r--r--svx/source/unodraw/UnoNameItemTable.cxx343
-rw-r--r--svx/source/unodraw/UnoNameItemTable.hxx94
-rw-r--r--svx/source/unodraw/UnoNamespaceMap.cxx315
-rw-r--r--svx/source/unodraw/XPropertyTable.cxx745
-rw-r--r--svx/source/unodraw/gluepts.cxx549
-rw-r--r--svx/source/unodraw/makefile.mk83
-rw-r--r--svx/source/unodraw/recoveryui.cxx402
-rw-r--r--svx/source/unodraw/shapeimpl.hxx131
-rw-r--r--svx/source/unodraw/shapepropertynotifier.cxx210
-rw-r--r--svx/source/unodraw/tableshape.cxx196
-rw-r--r--svx/source/unodraw/unobtabl.cxx124
-rw-r--r--svx/source/unodraw/unoctabl.cxx450
-rw-r--r--svx/source/unodraw/unodraw.src42
-rw-r--r--svx/source/unodraw/unodtabl.cxx110
-rw-r--r--svx/source/unodraw/unogtabl.cxx109
-rw-r--r--svx/source/unodraw/unohtabl.cxx107
-rw-r--r--svx/source/unodraw/unomlstr.cxx74
-rw-r--r--svx/source/unodraw/unomod.cxx757
-rw-r--r--svx/source/unodraw/unomtabl.cxx483
-rw-r--r--svx/source/unodraw/unopage.cxx1009
-rw-r--r--svx/source/unodraw/unopool.cxx431
-rw-r--r--svx/source/unodraw/unoprov.cxx1457
-rw-r--r--svx/source/unodraw/unoshap2.cxx2147
-rw-r--r--svx/source/unodraw/unoshap3.cxx1212
-rw-r--r--svx/source/unodraw/unoshap4.cxx996
-rw-r--r--svx/source/unodraw/unoshape.cxx4649
-rw-r--r--svx/source/unodraw/unoshcol.cxx261
-rw-r--r--svx/source/unodraw/unoshtxt.cxx1151
-rw-r--r--svx/source/unodraw/unottabl.cxx109
-rwxr-xr-xsvx/source/unogallery/makefile.mk48
-rw-r--r--svx/source/unogallery/unogalitem.cxx484
-rw-r--r--svx/source/unogallery/unogalitem.hxx127
-rw-r--r--svx/source/unogallery/unogaltheme.cxx469
-rw-r--r--svx/source/unogallery/unogaltheme.hxx113
-rw-r--r--svx/source/unogallery/unogalthemeprovider.cxx317
-rw-r--r--svx/source/xml/makefile.mk49
-rw-r--r--svx/source/xml/xmleohlp.cxx817
-rw-r--r--svx/source/xml/xmlexport.cxx286
-rw-r--r--svx/source/xml/xmlgrhlp.cxx1155
-rw-r--r--svx/source/xml/xmlxtexp.cxx495
-rw-r--r--svx/source/xml/xmlxtimp.cxx488
-rw-r--r--svx/source/xoutdev/_xoutbmp.cxx771
-rw-r--r--svx/source/xoutdev/_xpoly.cxx2135
-rw-r--r--svx/source/xoutdev/makefile.mk59
-rw-r--r--svx/source/xoutdev/xattr.cxx5780
-rw-r--r--svx/source/xoutdev/xattr2.cxx1714
-rw-r--r--svx/source/xoutdev/xattrbmp.cxx897
-rw-r--r--svx/source/xoutdev/xexch.cxx203
-rw-r--r--svx/source/xoutdev/xpool.cxx238
-rw-r--r--svx/source/xoutdev/xtabbtmp.cxx297
-rw-r--r--svx/source/xoutdev/xtabcolr.cxx551
-rw-r--r--svx/source/xoutdev/xtabdash.cxx381
-rw-r--r--svx/source/xoutdev/xtabgrdt.cxx375
-rw-r--r--svx/source/xoutdev/xtabhtch.cxx377
-rw-r--r--svx/source/xoutdev/xtable.cxx513
-rw-r--r--svx/source/xoutdev/xtablend.cxx396
732 files changed, 367417 insertions, 0 deletions
diff --git a/svx/source/accessibility/AccessibleControlShape.cxx b/svx/source/accessibility/AccessibleControlShape.cxx
new file mode 100644
index 000000000000..0d1aed702afa
--- /dev/null
+++ b/svx/source/accessibility/AccessibleControlShape.cxx
@@ -0,0 +1,923 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/AccessibleControlShape.hxx>
+#include <svx/AccessibleShapeInfo.hxx>
+#include "DescriptionGenerator.hxx"
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/reflection/XProxyFactory.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <comphelper/processfactory.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <svx/svdouno.hxx>
+#include "unoapi.hxx"
+#include <svx/ShapeTypeHandler.hxx>
+#include <svx/SvxShapeTypes.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <comphelper/accessiblewrapper.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpagv.hxx>
+#include "svdstr.hrc"
+#include <algorithm>
+
+using namespace ::comphelper;
+using namespace ::accessibility;
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::reflection;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::container;
+
+//--------------------------------------------------------------------
+namespace
+{
+ //................................................................
+ const ::rtl::OUString& lcl_getNamePropertyName( )
+ {
+ static ::rtl::OUString s_sNamePropertyName( RTL_CONSTASCII_USTRINGPARAM( "Name" ) );
+ return s_sNamePropertyName;
+ }
+ //................................................................
+ const ::rtl::OUString& lcl_getDescPropertyName( )
+ {
+ static ::rtl::OUString s_sDescPropertyDesc( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) );
+ return s_sDescPropertyDesc;
+ }
+ //................................................................
+ const ::rtl::OUString& lcl_getLabelPropertyName( )
+ {
+ static ::rtl::OUString s_sLabelPropertyLabel( RTL_CONSTASCII_USTRINGPARAM( "Label" ) );
+ return s_sLabelPropertyLabel;
+ }
+ //................................................................
+ // return the property which should be used as AccessibleName
+ const ::rtl::OUString& lcl_getPreferredAccNameProperty( const Reference< XPropertySetInfo >& _rxPSI )
+ {
+ if ( _rxPSI.is() && _rxPSI->hasPropertyByName( lcl_getLabelPropertyName() ) )
+ return lcl_getLabelPropertyName();
+ else
+ return lcl_getNamePropertyName();
+ }
+
+ //................................................................
+ // determines whether or not a state which belongs to the inner context needs to be forwarded to the "composed"
+ // context
+ sal_Bool isComposedState( const sal_Int16 _nState )
+ {
+ return ( ( AccessibleStateType::INVALID != _nState )
+ && ( AccessibleStateType::DEFUNC != _nState )
+ && ( AccessibleStateType::ICONIFIED != _nState )
+ && ( AccessibleStateType::RESIZABLE != _nState )
+ && ( AccessibleStateType::SELECTABLE != _nState )
+ && ( AccessibleStateType::SHOWING != _nState )
+ && ( AccessibleStateType::MANAGES_DESCENDANTS != _nState )
+ && ( AccessibleStateType::VISIBLE != _nState )
+ );
+ }
+
+ //................................................................
+ /** determines whether the given control is in alive mode
+ */
+ inline sal_Bool isAliveMode( const Reference< XControl >& _rxControl )
+ {
+ OSL_PRECOND( _rxControl.is(), "AccessibleControlShape::isAliveMode: invalid control" );
+ return _rxControl.is() && !_rxControl->isDesignMode();
+ }
+}
+
+//=============================================================================
+//= AccessibleControlShape
+//=============================================================================
+
+//-----------------------------------------------------------------------------
+AccessibleControlShape::AccessibleControlShape (
+ const AccessibleShapeInfo& rShapeInfo,
+ const AccessibleShapeTreeInfo& rShapeTreeInfo)
+ : AccessibleShape (rShapeInfo, rShapeTreeInfo)
+ , m_bListeningForName( sal_False )
+ , m_bListeningForDesc( sal_False )
+ , m_bMultiplexingStates( sal_False )
+ , m_bDisposeNativeContext( sal_False )
+ , m_bWaitingForControl( sal_False )
+{
+ m_pChildManager = new OWrappedAccessibleChildrenManager( getProcessServiceFactory() );
+ m_pChildManager->acquire();
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ m_pChildManager->setOwningAccessible( this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+//-----------------------------------------------------------------------------
+AccessibleControlShape::~AccessibleControlShape (void)
+{
+ m_pChildManager->release();
+ m_pChildManager = NULL;
+
+ if ( m_xControlContextProxy.is() )
+ m_xControlContextProxy->setDelegator( NULL );
+ m_xControlContextProxy.clear();
+ m_xControlContextTypeAccess.clear();
+ m_xControlContextComponent.clear();
+ // this should remove the _only_ three "real" reference (means not delegated to
+ // ourself) to this proxy, and thus delete it
+}
+
+//-----------------------------------------------------------------------------
+SdrObject* AccessibleControlShape::getSdrObject() const
+{
+ return GetSdrObjectFromXShape (mxShape);
+}
+
+namespace {
+ Reference< XContainer > lcl_getControlContainer( const Window* _pWin, const SdrView* _pView )
+ {
+ Reference< XContainer > xReturn;
+ DBG_ASSERT( _pView, "lcl_getControlContainer: invalid view!" );
+ if ( _pView && _pView->GetSdrPageView())
+ {
+ xReturn = xReturn.query( _pView->GetSdrPageView()->GetControlContainer( *_pWin ) );
+ }
+ return xReturn;
+ }
+}
+
+//-----------------------------------------------------------------------------
+void AccessibleControlShape::Init()
+{
+ AccessibleShape::Init();
+
+ OSL_ENSURE( !m_xControlContextProxy.is(), "AccessibleControlShape::Init: already initialized!" );
+ try
+ {
+ // What we need to do here is merge the functionality of the AccessibleContext of our UNO control
+ // with our own AccessibleContext-related functionality.
+ //
+ // The problem is that we do not know the interfaces our "inner" context supports - this may be any
+ // XAccessibleXXX interface (or even any other) which makes sense for it.
+ //
+ // In theory, we could implement all possible interfaces ourself, and re-route all functionality to
+ // the inner context (except those we implement ourself, like XAccessibleComponent). But this is in no
+ // way future-proof - as soon as an inner context appears which implements an additional interface,
+ // we would need to adjust our implementation to support this new interface, too. Bad idea.
+ //
+ // The usual solution for such a problem is aggregation. Aggregation means using UNO's own meachnisms
+ // for merging an inner with an outer component, and get a component which behaves as it is exactly one.
+ // This is what XAggregation is for. Unfortunately, aggregation requires _exact_ control over the ref count
+ // of the inner object, which we do not have at all.
+ // Bad, too.
+ //
+ // But there is a solution: com.sun.star.reflection.ProxyFactory. This service is able to create a proxy
+ // for any component, which supports _exactly_ the same interfaces as the component. In addition, it can
+ // be aggregated, as by definition the proxy's ref count is exactly 1 when returned from the factory.
+ // Sounds better. Though this yields the problem of slightly degraded performance, it's the only solution
+ // I'm aware of at the moment .....
+ //
+ // 98750 - 30.04.2002 - fs@openoffice.org
+ //
+
+ // get the control which belongs to our model (relative to our view)
+ const Window* pViewWindow = maShapeTreeInfo.GetWindow();
+ SdrUnoObj* pUnoObjectImpl = PTR_CAST( SdrUnoObj, getSdrObject() );
+ SdrView* pView = maShapeTreeInfo.GetSdrView();
+ OSL_ENSURE( pView && pViewWindow && pUnoObjectImpl, "AccessibleControlShape::Init: no view, or no view window, no SdrUnoObj!" );
+
+ if ( pView && pViewWindow && pUnoObjectImpl )
+ {
+ // .................................................................
+ // get the context of the control - it will be our "inner" context
+ m_xUnoControl = pUnoObjectImpl->GetUnoControl( *pView, *pViewWindow );
+
+ if ( !m_xUnoControl.is() )
+ {
+ // the control has not yet been created. Though speaking strictly, it is a bug that
+ // our instance here is created without an existing control (because an AccessibleControlShape
+ // is a representation of a view object, and can only live if the view it should represent
+ // is complete, which implies a living control), it's by far the easiest and most riskless way
+ // to fix this here in this class.
+ // Okay, we will add as listener to the control container where we expect our control to appear.
+ OSL_ENSURE( !m_bWaitingForControl, "AccessibleControlShape::Init: already waiting for the control!" );
+
+ Reference< XContainer > xControlContainer = lcl_getControlContainer( pViewWindow, maShapeTreeInfo.GetSdrView() );
+ OSL_ENSURE( xControlContainer.is(), "AccessibleControlShape::Init: unable to find my ControlContainer!" );
+ if ( xControlContainer.is() )
+ {
+ xControlContainer->addContainerListener( this );
+ m_bWaitingForControl = sal_True;
+ }
+ }
+ else
+ {
+ Reference< XModeChangeBroadcaster > xControlModes( m_xUnoControl, UNO_QUERY );
+ Reference< XAccessible > xControlAccessible( xControlModes, UNO_QUERY );
+ Reference< XAccessibleContext > xNativeControlContext;
+ if ( xControlAccessible.is() )
+ xNativeControlContext = xControlAccessible->getAccessibleContext();
+ OSL_ENSURE( xNativeControlContext.is(), "AccessibleControlShape::Init: no AccessibleContext for the control!" );
+ m_aControlContext = WeakReference< XAccessibleContext >( xNativeControlContext );
+
+ // .................................................................
+ // add as listener to the context - we want to multiplex some states
+ if ( isAliveMode( m_xUnoControl ) && xNativeControlContext.is() )
+ { // (but only in alive mode)
+ startStateMultiplexing( );
+ }
+
+ // now that we have all information about our control, do some adjustments
+ adjustAccessibleRole();
+ initializeComposedState();
+
+ // some initialization for our child manager, which is used in alive mode only
+ if ( isAliveMode( m_xUnoControl ) )
+ {
+ Reference< XAccessibleStateSet > xStates( getAccessibleStateSet( ) );
+ OSL_ENSURE( xStates.is(), "AccessibleControlShape::AccessibleControlShape: no inner state set!" );
+ m_pChildManager->setTransientChildren( !xStates.is() || xStates->contains( AccessibleStateType::MANAGES_DESCENDANTS ) );
+ }
+
+ // .................................................................
+ // finally, aggregate a proxy for the control context
+ // first a factory for the proxy
+ Reference< XProxyFactory > xFactory;
+ xFactory = xFactory.query( createProcessComponent( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.reflection.ProxyFactory" ) ) ) );
+ OSL_ENSURE( xFactory.is(), "AccessibleControlShape::Init: could not create a proxy factory!" );
+ // then the proxy itself
+ if ( xFactory.is() && xNativeControlContext.is() )
+ {
+ m_xControlContextProxy = xFactory->createProxy( xNativeControlContext );
+ OSL_VERIFY( xNativeControlContext->queryInterface( ::getCppuType( &m_xControlContextTypeAccess ) ) >>= m_xControlContextTypeAccess );
+ OSL_VERIFY( xNativeControlContext->queryInterface( ::getCppuType( &m_xControlContextComponent ) ) >>= m_xControlContextComponent );
+
+ // aggregate the proxy
+ osl_incrementInterlockedCount( &m_refCount );
+ if ( m_xControlContextProxy.is() )
+ {
+ // At this point in time, the proxy has a ref count of exactly one - in m_xControlContextProxy.
+ // Remember to _not_ reset this member unles the delegator of the proxy has been reset, too!
+ m_xControlContextProxy->setDelegator( *this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+
+ m_bDisposeNativeContext = sal_True;
+
+ // Finally, we need to add ourself as mode listener to the control. In case the mode switches,
+ // we need to dispose ourself.
+ xControlModes->addModeChangeListener( this );
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "AccessibleControlShape::Init: could not \"aggregate\" the controls XAccessibleContext!" );
+ }
+}
+
+//-----------------------------------------------------------------------------
+Reference< XAccessibleContext > SAL_CALL AccessibleControlShape::getAccessibleContext(void) throw (RuntimeException)
+{
+ return AccessibleShape::getAccessibleContext ();
+}
+
+
+//-----------------------------------------------------------------------------
+void SAL_CALL AccessibleControlShape::grabFocus(void) throw (RuntimeException)
+{
+ if ( !m_xUnoControl.is() || !isAliveMode( m_xUnoControl ) )
+ {
+ // in design mode, we simply forward the request to the base class
+ AccessibleShape::grabFocus();
+ }
+ else
+ {
+ Reference< XWindow > xWindow( m_xUnoControl, UNO_QUERY );
+ OSL_ENSURE( xWindow.is(), "AccessibleControlShape::grabFocus: invalid control!" );
+ if ( xWindow.is() )
+ xWindow->setFocus();
+ }
+}
+
+//-----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL AccessibleControlShape::getImplementationName(void) throw (RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.accessibility.AccessibleControlShape" ) );
+}
+
+//-----------------------------------------------------------------------------
+::rtl::OUString AccessibleControlShape::CreateAccessibleBaseName(void) throw (RuntimeException)
+{
+ ::rtl::OUString sName;
+
+ ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
+ switch (nShapeType)
+ {
+ case DRAWING_CONTROL:
+ sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("ControlShape"));
+ break;
+ default:
+ sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleControlShape"));
+ Reference< XShapeDescriptor > xDescriptor (mxShape, UNO_QUERY);
+ if (xDescriptor.is())
+ sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
+ + xDescriptor->getShapeType();
+ }
+
+ return sName;
+}
+
+
+
+
+//--------------------------------------------------------------------
+::rtl::OUString
+ AccessibleControlShape::CreateAccessibleDescription (void)
+ throw (RuntimeException)
+{
+ DescriptionGenerator aDG (mxShape);
+ ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
+ switch (nShapeType)
+ {
+ case DRAWING_CONTROL:
+ {
+ // check if we can obtain the "Desc" property from the model
+ ::rtl::OUString sDesc( getControlModelStringProperty( lcl_getDescPropertyName() ) );
+ if ( !sDesc.getLength() )
+ { // no -> use the default
+ aDG.Initialize (STR_ObjNameSingulUno);
+ aDG.AddProperty (::rtl::OUString::createFromAscii ("ControlBackground"),
+ DescriptionGenerator::COLOR,
+ ::rtl::OUString());
+ aDG.AddProperty (::rtl::OUString::createFromAscii ("ControlBorder"),
+ DescriptionGenerator::INTEGER,
+ ::rtl::OUString());
+ }
+ // ensure that we are listening to the Name property
+ m_bListeningForDesc = ensureListeningState( m_bListeningForDesc, sal_True, lcl_getDescPropertyName() );
+ }
+ break;
+
+ default:
+ aDG.Initialize (::rtl::OUString::createFromAscii (
+ "Unknown accessible control shape"));
+ Reference< XShapeDescriptor > xDescriptor (mxShape, UNO_QUERY);
+ if (xDescriptor.is())
+ {
+ aDG.AppendString (::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("service name=")));
+ aDG.AppendString (xDescriptor->getShapeType());
+ }
+ }
+
+ return aDG();
+}
+
+//--------------------------------------------------------------------
+IMPLEMENT_FORWARD_REFCOUNT( AccessibleControlShape, AccessibleShape )
+IMPLEMENT_GET_IMPLEMENTATION_ID( AccessibleControlShape )
+
+//--------------------------------------------------------------------
+void SAL_CALL AccessibleControlShape::propertyChange( const PropertyChangeEvent& _rEvent ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( maMutex );
+
+ // check if it is the name or the description
+ if ( _rEvent.PropertyName.equals( lcl_getNamePropertyName() )
+ || _rEvent.PropertyName.equals( lcl_getLabelPropertyName( ) )
+ )
+ {
+ SetAccessibleName(
+ CreateAccessibleName(),
+ AccessibleContextBase::AutomaticallyCreated);
+ }
+ else if ( _rEvent.PropertyName.equals( lcl_getDescPropertyName() ) )
+ {
+ SetAccessibleDescription(
+ CreateAccessibleDescription(),
+ AccessibleContextBase::AutomaticallyCreated);
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else
+ {
+ OSL_ENSURE( sal_False, "AccessibleControlShape::propertyChange: where did this come from?" );
+ }
+#endif
+}
+
+//--------------------------------------------------------------------
+Any SAL_CALL AccessibleControlShape::queryInterface( const Type& _rType ) throw (RuntimeException)
+{
+ Any aReturn = AccessibleShape::queryInterface( _rType );
+ if ( !aReturn.hasValue() )
+ {
+ aReturn = AccessibleControlShape_Base::queryInterface( _rType );
+ if ( !aReturn.hasValue() && m_xControlContextProxy.is() )
+ aReturn = m_xControlContextProxy->queryAggregation( _rType );
+ }
+ return aReturn;
+}
+
+//--------------------------------------------------------------------
+Sequence< Type > SAL_CALL AccessibleControlShape::getTypes() throw (RuntimeException)
+{
+ Sequence< Type > aShapeTypes = AccessibleShape::getTypes();
+ Sequence< Type > aOwnTypes = AccessibleControlShape_Base::getTypes();
+
+ Sequence< Type > aAggregateTypes;
+ if ( m_xControlContextTypeAccess.is() )
+ aAggregateTypes = m_xControlContextTypeAccess->getTypes();
+
+ Sequence< Type > aAllTypes = concatSequences( aShapeTypes, aOwnTypes, aAggregateTypes );
+
+ // remove duplicates
+ Type* pBegin = aAllTypes.getArray();
+ Type* pEnd = pBegin + aAllTypes.getLength();
+ while ( pBegin != pEnd )
+ {
+ Type aThisRoundType = *pBegin;
+ if ( ++pBegin != pEnd )
+ {
+ pEnd = ::std::remove( pBegin, pEnd, aThisRoundType );
+ // now all types between begin and (the old) end which equal aThisRoundType
+ // are moved behind the new end
+ }
+ }
+ aAllTypes.realloc( pEnd - aAllTypes.getArray() );
+
+ return aAllTypes;
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL AccessibleControlShape::notifyEvent( const AccessibleEventObject& _rEvent ) throw (RuntimeException)
+{
+ if ( AccessibleEventId::STATE_CHANGED == _rEvent.EventId )
+ {
+ // multiplex this change
+ sal_Int16 nLostState( 0 ), nGainedState( 0 );
+ _rEvent.OldValue >>= nLostState;
+ _rEvent.NewValue >>= nGainedState;
+
+ // don't multiplex states which the inner context is not resposible for
+ if ( isComposedState( nLostState ) )
+ AccessibleShape::ResetState( nLostState );
+
+ if ( isComposedState( nGainedState ) )
+ AccessibleShape::SetState( nGainedState );
+ }
+ else
+ {
+ AccessibleEventObject aTranslatedEvent( _rEvent );
+
+ {
+ ::osl::MutexGuard aGuard( maMutex );
+
+ // let the child manager translate the event
+ aTranslatedEvent.Source = *this;
+ m_pChildManager->translateAccessibleEvent( _rEvent, aTranslatedEvent );
+
+ // see if any of these notifications affect our child manager
+ m_pChildManager->handleChildNotification( _rEvent );
+ }
+
+ FireEvent( aTranslatedEvent );
+ }
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL AccessibleControlShape::modeChanged( const ModeChangeEvent& _rSource ) throw (RuntimeException)
+{
+ // did it come from our inner context (the real one, not it's proxy!)?
+ OSL_TRACE ("AccessibleControlShape::modeChanged");
+ Reference< XControl > xSource( _rSource.Source, UNO_QUERY ); // for faster compare
+ if ( xSource.get() == m_xUnoControl.get() )
+ {
+ // If our "pseudo-aggregated" inner context does not live anymore,
+ // we don't want to live, too. This is accomplished by asking our
+ // parent to replace this object with a new one. Disposing this
+ // object and sending notifications about the replacement are in
+ // the responsibility of our parent.
+ OSL_VERIFY( mpParent->ReplaceChild ( this, mxShape, mnIndex, maShapeTreeInfo ) );
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else
+ OSL_ENSURE( sal_False, "AccessibleControlShape::modeChanged: where did this come from?" );
+#endif
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL AccessibleControlShape::disposing (const EventObject& _rSource) throw (RuntimeException)
+{
+ AccessibleShape::disposing( _rSource );
+}
+
+//--------------------------------------------------------------------
+sal_Bool AccessibleControlShape::ensureListeningState(
+ const sal_Bool _bCurrentlyListening, const sal_Bool _bNeedNewListening,
+ const ::rtl::OUString& _rPropertyName )
+{
+ if ( ( _bCurrentlyListening == _bNeedNewListening ) || !ensureControlModelAccess() )
+ // nothing to do
+ return _bCurrentlyListening;
+
+ try
+ {
+ if ( !m_xModelPropsMeta.is() || m_xModelPropsMeta->hasPropertyByName( _rPropertyName ) )
+ {
+ // add or revoke as listener
+ if ( _bNeedNewListening )
+ m_xControlModel->addPropertyChangeListener( _rPropertyName, static_cast< XPropertyChangeListener* >( this ) );
+ else
+ m_xControlModel->removePropertyChangeListener( _rPropertyName, static_cast< XPropertyChangeListener* >( this ) );
+ }
+ else
+ OSL_ENSURE( sal_False, "AccessibleControlShape::ensureListeningState: this property does not exist at this model!" );
+ }
+ catch( const Exception& e )
+ {
+ (void)e; // make compiler happy
+ OSL_ENSURE( sal_False, "AccessibleControlShape::ensureListeningState: could not change the listening state!" );
+ }
+
+ return _bNeedNewListening;
+}
+
+//--------------------------------------------------------------------
+sal_Int32 SAL_CALL AccessibleControlShape::getAccessibleChildCount( ) throw(RuntimeException)
+{
+ if ( !m_xUnoControl.is() )
+ return 0;
+ else if ( !isAliveMode( m_xUnoControl ) )
+ // no special action required when in design mode
+ return AccessibleShape::getAccessibleChildCount( );
+ else
+ {
+ // in alive mode, we have the full control over our children - they are determined by the children
+ // of the context of our UNO control
+ Reference< XAccessibleContext > xControlContext( m_aControlContext );
+ OSL_ENSURE( xControlContext.is(), "AccessibleControlShape::getAccessibleChildCount: control context already dead! How this!" );
+ return xControlContext.is() ? xControlContext->getAccessibleChildCount() : 0;
+ }
+}
+
+//--------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL AccessibleControlShape::getAccessibleChild( sal_Int32 i ) throw(IndexOutOfBoundsException, RuntimeException)
+{
+ Reference< XAccessible > xChild;
+ if ( !m_xUnoControl.is() )
+ {
+ throw IndexOutOfBoundsException();
+ }
+ if ( !isAliveMode( m_xUnoControl ) )
+ {
+ // no special action required when in design mode - let the base class handle this
+ xChild = AccessibleShape::getAccessibleChild( i );
+ }
+ else
+ {
+ // in alive mode, we have the full control over our children - they are determined by the children
+ // of the context of our UNO control
+
+ Reference< XAccessibleContext > xControlContext( m_aControlContext );
+ OSL_ENSURE( xControlContext.is(), "AccessibleControlShape::getAccessibleChildCount: control context already dead! How this!" );
+ if ( xControlContext.is() )
+ {
+ Reference< XAccessible > xInnerChild( xControlContext->getAccessibleChild( i ) );
+ OSL_ENSURE( xInnerChild.is(), "AccessibleControlShape::getAccessibleChild: control context returned nonsense!" );
+ if ( xInnerChild.is() )
+ {
+ // we need to wrap this inner child into an own implementation
+ xChild = m_pChildManager->getAccessibleWrapperFor( xInnerChild );
+ }
+ }
+ }
+
+#if OSL_DEBUG_LEVEL > 0
+ sal_Int32 nChildIndex = -1;
+ Reference< XAccessibleContext > xContext;
+ if ( xChild.is() )
+ xContext = xChild->getAccessibleContext( );
+ if ( xContext.is() )
+ nChildIndex = xContext->getAccessibleIndexInParent( );
+ OSL_ENSURE( nChildIndex == i, "AccessibleControlShape::getAccessibleChild: index mismatch!" );
+#endif
+ return xChild;
+}
+
+//--------------------------------------------------------------------
+Reference< XAccessibleRelationSet > SAL_CALL AccessibleControlShape::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ // TODO
+ return AccessibleShape::getAccessibleRelationSet( );
+}
+
+//--------------------------------------------------------------------
+::rtl::OUString AccessibleControlShape::CreateAccessibleName (void) throw (RuntimeException)
+{
+ ensureControlModelAccess();
+
+ // check if we can obtain the "Name" resp. "Label" property from the model
+ const ::rtl::OUString& rAccNameProperty = lcl_getPreferredAccNameProperty( m_xModelPropsMeta );
+
+ ::rtl::OUString sName( getControlModelStringProperty( rAccNameProperty ) );
+ if ( !sName.getLength() )
+ { // no -> use the default
+ sName = AccessibleShape::CreateAccessibleName();
+ }
+
+ // now that somebody first asked us for our name, ensure that we are listening to name changes on the model
+ m_bListeningForName = ensureListeningState( m_bListeningForName, sal_True, lcl_getPreferredAccNameProperty( m_xModelPropsMeta ) );
+
+ return sName;
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL AccessibleControlShape::disposing (void)
+{
+ // ensure we're not listening
+ m_bListeningForName = ensureListeningState( m_bListeningForName, sal_False, lcl_getPreferredAccNameProperty( m_xModelPropsMeta ) );
+ m_bListeningForDesc = ensureListeningState( m_bListeningForDesc, sal_False, lcl_getDescPropertyName() );
+
+ if ( m_bMultiplexingStates )
+ stopStateMultiplexing( );
+
+ // dispose the child cache/map
+ m_pChildManager->dispose();
+
+ // release the model
+ m_xControlModel.clear();
+ m_xModelPropsMeta.clear();
+ m_aControlContext = WeakReference< XAccessibleContext >();
+
+ // stop listening at the control container (should never be necessary here, but who knows ....)
+ if ( m_bWaitingForControl )
+ {
+ OSL_ENSURE( sal_False, "AccessibleControlShape::disposing: this should never happen!" );
+ Reference< XContainer > xContainer = lcl_getControlContainer( maShapeTreeInfo.GetWindow(), maShapeTreeInfo.GetSdrView() );
+ if ( xContainer.is() )
+ {
+ m_bWaitingForControl = sal_False;
+ xContainer->removeContainerListener( this );
+ }
+ }
+
+ // forward the disposel to our inner context
+ if ( m_bDisposeNativeContext )
+ {
+ // don't listen for mode changes anymore
+ Reference< XModeChangeBroadcaster > xControlModes( m_xUnoControl, UNO_QUERY );
+ OSL_ENSURE( xControlModes.is(), "AccessibleControlShape::disposing: don't have an mode broadcaster anymore!" );
+ if ( xControlModes.is() )
+ xControlModes->removeModeChangeListener( this );
+
+ if ( m_xControlContextComponent.is() )
+ m_xControlContextComponent->dispose();
+ // do _not_ clear m_xControlContextProxy! This has to be done in the dtor for correct ref-count handling
+
+ // no need to dispose the proxy/inner context anymore
+ m_bDisposeNativeContext = sal_False;
+ }
+
+ m_xUnoControl.clear();
+
+ // let the base do it's stuff
+ AccessibleShape::disposing();
+}
+
+//--------------------------------------------------------------------
+sal_Bool AccessibleControlShape::ensureControlModelAccess() SAL_THROW(())
+{
+ if ( m_xControlModel.is() )
+ return sal_True;
+
+ try
+ {
+ Reference< XControlShape > xShape( mxShape, UNO_QUERY );
+ if ( xShape.is() )
+ m_xControlModel = m_xControlModel.query( xShape->getControl() );
+
+ if ( m_xControlModel.is() )
+ m_xModelPropsMeta = m_xControlModel->getPropertySetInfo();
+ }
+ catch( const Exception& e )
+ {
+ (void)e; // make compiler happy
+ OSL_ENSURE( sal_False, "AccessibleControlShape::ensureControlModelAccess: caught an exception!" );
+ }
+
+ return m_xControlModel.is();
+}
+
+//--------------------------------------------------------------------
+void AccessibleControlShape::startStateMultiplexing()
+{
+ OSL_PRECOND( !m_bMultiplexingStates, "AccessibleControlShape::startStateMultiplexing: already multiplexing!" );
+
+#if OSL_DEBUG_LEVEL > 0
+ // we should have a control, and it should be in alive mode
+ OSL_PRECOND( isAliveMode( m_xUnoControl ),
+ "AccessibleControlShape::startStateMultiplexing: should be done in alive mode only!" );
+#endif
+ // we should have the native context of the control
+ Reference< XAccessibleEventBroadcaster > xBroadcaster( m_aControlContext.get(), UNO_QUERY );
+ OSL_ENSURE( xBroadcaster.is(), "AccessibleControlShape::startStateMultiplexing: no AccessibleEventBroadcaster on the native context!" );
+
+ if ( xBroadcaster.is() )
+ {
+ xBroadcaster->addEventListener( this );
+ m_bMultiplexingStates = sal_True;
+ }
+}
+
+//--------------------------------------------------------------------
+void AccessibleControlShape::stopStateMultiplexing()
+{
+ OSL_PRECOND( m_bMultiplexingStates, "AccessibleControlShape::stopStateMultiplexing: not multiplexing!" );
+
+ // we should have the native context of the control
+ Reference< XAccessibleEventBroadcaster > xBroadcaster( m_aControlContext.get(), UNO_QUERY );
+ OSL_ENSURE( xBroadcaster.is(), "AccessibleControlShape::stopStateMultiplexing: no AccessibleEventBroadcaster on the native context!" );
+
+ if ( xBroadcaster.is() )
+ {
+ xBroadcaster->removeEventListener( this );
+ m_bMultiplexingStates = sal_False;
+ }
+}
+
+//--------------------------------------------------------------------
+::rtl::OUString AccessibleControlShape::getControlModelStringProperty( const ::rtl::OUString& _rPropertyName ) const SAL_THROW(())
+{
+ ::rtl::OUString sReturn;
+ try
+ {
+ if ( const_cast< AccessibleControlShape* >( this )->ensureControlModelAccess() )
+ {
+ if ( !m_xModelPropsMeta.is() || m_xModelPropsMeta->hasPropertyByName( _rPropertyName ) )
+ // ask only if a) the control does not have a PropertySetInfo object or b) it has, and the
+ // property in question is available
+ m_xControlModel->getPropertyValue( _rPropertyName ) >>= sReturn;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OAccessibleControlContext::getModelStringProperty: caught an exception!" );
+ }
+ return sReturn;
+}
+
+//--------------------------------------------------------------------
+void AccessibleControlShape::adjustAccessibleRole( )
+{
+ // if we're in design mode, we are a simple SHAPE, in alive mode, we use the role of our inner context
+ if ( !isAliveMode( m_xUnoControl ) )
+ return;
+
+ // we're in alive mode -> determine the role of the inner context
+ Reference< XAccessibleContext > xNativeContext( m_aControlContext );
+ OSL_PRECOND( xNativeContext.is(), "AccessibleControlShape::adjustAccessibleRole: no inner context!" );
+ if ( xNativeContext.is() )
+ SetAccessibleRole( xNativeContext->getAccessibleRole( ) );
+}
+
+#ifdef DBG_UTIL
+//--------------------------------------------------------------------
+sal_Bool AccessibleControlShape::SetState( sal_Int16 _nState )
+{
+ OSL_ENSURE( !isAliveMode( m_xUnoControl ) || !isComposedState( _nState ),
+ "AccessibleControlShape::SetState: a state which should be determined by the control context is set from outside!" );
+ return AccessibleShape::SetState( _nState );
+}
+#endif // DBG_UTIL
+
+//--------------------------------------------------------------------
+void AccessibleControlShape::initializeComposedState()
+{
+ if ( !isAliveMode( m_xUnoControl ) )
+ // no action necessary for design mode
+ return;
+
+ // get our own state set implementation
+ ::utl::AccessibleStateSetHelper* pComposedStates =
+ static_cast< ::utl::AccessibleStateSetHelper* >( mxStateSet.get() );
+ OSL_PRECOND( pComposedStates,
+ "AccessibleControlShape::initializeComposedState: no composed set!" );
+
+ // we need to reset some states of the composed set, because they either do not apply
+ // for controls in alive mode, or are in the responsibility of the UNO-control, anyway
+ pComposedStates->RemoveState( AccessibleStateType::ENABLED ); // this is controlled by the UNO-control
+ pComposedStates->RemoveState( AccessibleStateType::SENSITIVE ); // this is controlled by the UNO-control
+ pComposedStates->RemoveState( AccessibleStateType::FOCUSABLE ); // this is controlled by the UNO-control
+ pComposedStates->RemoveState( AccessibleStateType::SELECTABLE ); // this does not hold for an alive UNO-control
+#if OSL_DEBUG_LEVEL > 0
+ // now, only states which are not in the responsibility of the UNO control should be part of this state set
+ {
+ Sequence< sal_Int16 > aInitStates = pComposedStates->getStates();
+ for ( sal_Int32 i=0; i<aInitStates.getLength(); ++i )
+ OSL_ENSURE( !isComposedState( aInitStates.getConstArray()[i] ),
+ "AccessibleControlShape::initializeComposedState: invalid initial composed state (should be controlled by the UNO-control)!" );
+ }
+#endif
+
+ // get my inner context
+ Reference< XAccessibleContext > xInnerContext( m_aControlContext );
+ OSL_PRECOND( xInnerContext.is(), "AccessibleControlShape::initializeComposedState: no inner context!" );
+ if ( xInnerContext.is() )
+ {
+ // get all states of the inner context
+ Reference< XAccessibleStateSet > xInnerStates( xInnerContext->getAccessibleStateSet() );
+ OSL_ENSURE( xInnerStates.is(), "AccessibleControlShape::initializeComposedState: no inner states!" );
+ Sequence< sal_Int16 > aInnerStates;
+ if ( xInnerStates.is() )
+ aInnerStates = xInnerStates->getStates();
+
+ // look which one are to be propagated to the composed context
+ const sal_Int16* pStates = aInnerStates.getConstArray();
+ const sal_Int16* pStatesEnd = pStates + aInnerStates.getLength();
+ for ( ; pStates != pStatesEnd; ++pStates )
+ {
+ if ( isComposedState( *pStates ) && !pComposedStates->contains( *pStates ) )
+ {
+ pComposedStates->AddState( *pStates );
+ }
+ }
+ }
+}
+
+void SAL_CALL AccessibleControlShape::elementInserted( const ::com::sun::star::container::ContainerEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException)
+{
+ Reference< XContainer > xContainer( _rEvent.Source, UNO_QUERY );
+ Reference< XControl > xControl( _rEvent.Element, UNO_QUERY );
+
+ OSL_ENSURE( xContainer.is() && xControl.is(),
+ "AccessibleControlShape::elementInserted: invalid event description!" );
+
+ if ( !xControl.is() )
+ return;
+
+ ensureControlModelAccess();
+
+ Reference< XInterface > xNewNormalized( xControl->getModel(), UNO_QUERY );
+ Reference< XInterface > xMyModelNormalized( m_xControlModel, UNO_QUERY );
+ if ( xNewNormalized.get() && xMyModelNormalized.get() )
+ {
+ // now finally the control for the model we're responsible for has been inserted into the container
+ Reference< XInterface > xKeepAlive( *this );
+
+ // first, we're not interested in any more container events
+ if ( xContainer.is() )
+ {
+ xContainer->removeContainerListener( this );
+ m_bWaitingForControl = sal_False;
+ }
+
+ // second, we need to replace ourself with a new version, which now can be based on the
+ // control
+ OSL_VERIFY( mpParent->ReplaceChild ( this, mxShape, mnIndex, maShapeTreeInfo ) );
+ }
+}
+
+void SAL_CALL AccessibleControlShape::elementRemoved( const ::com::sun::star::container::ContainerEvent& ) throw (::com::sun::star::uno::RuntimeException)
+{
+ // not interested in
+}
+
+void SAL_CALL AccessibleControlShape::elementReplaced( const ::com::sun::star::container::ContainerEvent& ) throw (::com::sun::star::uno::RuntimeException)
+{
+ // not interested in
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleEmptyEditSource.cxx b/svx/source/accessibility/AccessibleEmptyEditSource.cxx
new file mode 100644
index 000000000000..cb1e23c6a5e8
--- /dev/null
+++ b/svx/source/accessibility/AccessibleEmptyEditSource.cxx
@@ -0,0 +1,359 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+//------------------------------------------------------------------------
+//
+// Global header
+//
+//------------------------------------------------------------------------
+#include <svl/itemset.hxx>
+#include <editeng/editdata.hxx>
+#include <editeng/outliner.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpool.hxx>
+
+//------------------------------------------------------------------------
+//
+// Project-local header
+//
+//------------------------------------------------------------------------
+
+#include "AccessibleEmptyEditSource.hxx"
+#include <svx/unoshtxt.hxx>
+
+namespace accessibility
+{
+
+ /** This class simply wraps a SvxTextEditSource, forwarding all
+ methods except the GetBroadcaster() call
+ */
+ class AccessibleProxyEditSource_Impl : public SvxEditSource
+ {
+ public:
+ /** Construct AccessibleEmptyEditSource_Impl
+
+ @param rBrdCast
+
+ Proxy broadcaster to allow seamless flipping of edit source implementations. ProxyEditSource and EmptyEditSource
+ */
+ AccessibleProxyEditSource_Impl( SdrObject& rObj,
+ SdrView& rView,
+ const Window& rViewWindow );
+ ~AccessibleProxyEditSource_Impl();
+
+ // from the SvxEditSource interface
+ SvxTextForwarder* GetTextForwarder();
+ SvxViewForwarder* GetViewForwarder();
+ SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate = sal_False );
+
+ SvxEditSource* Clone() const;
+
+ void UpdateData();
+
+ SfxBroadcaster& GetBroadcaster() const;
+
+ private:
+ SvxTextEditSource maEditSource;
+
+ };
+
+ /** Dummy class, faking exactly one empty paragraph for EditEngine accessibility
+ */
+ class AccessibleEmptyEditSource_Impl : public SvxEditSource, public SvxViewForwarder, public SvxTextForwarder, public SfxBroadcaster
+ {
+ public:
+
+ AccessibleEmptyEditSource_Impl() {}
+ ~AccessibleEmptyEditSource_Impl() {}
+
+ // from the SfxListener interface
+ void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ // SvxEditSource
+ SvxTextForwarder* GetTextForwarder() { return this; }
+ SvxViewForwarder* GetViewForwarder() { return this; }
+ SvxEditSource* Clone() const { return NULL; }
+ void UpdateData() {}
+ SfxBroadcaster& GetBroadcaster() const { return *(const_cast<AccessibleEmptyEditSource_Impl*>(this)); }
+
+ // SvxTextForwarder
+ USHORT GetParagraphCount() const { return 1; }
+ USHORT GetTextLen( USHORT /*nParagraph*/ ) const { return 0; }
+ String GetText( const ESelection& /*rSel*/ ) const { return String(); }
+ SfxItemSet GetAttribs( const ESelection& /*rSel*/, BOOL /*bOnlyHardAttrib*/ = 0 ) const
+ {
+ // AW: Very dangerous: The former implementation used a SfxItemPool created on the
+ // fly which of course was deleted again ASAP. Thus, the returned SfxItemSet was using
+ // a deleted Pool by design.
+ return SfxItemSet(SdrObject::GetGlobalDrawObjectItemPool());
+ }
+ SfxItemSet GetParaAttribs( USHORT /*nPara*/ ) const { return GetAttribs(ESelection()); }
+ void SetParaAttribs( USHORT /*nPara*/, const SfxItemSet& /*rSet*/ ) {}
+ void RemoveAttribs( const ESelection& /*rSelection*/, sal_Bool /*bRemoveParaAttribs*/, sal_uInt16 /*nWhich*/ ){}
+ void GetPortions( USHORT /*nPara*/, SvUShorts& /*rList*/ ) const {}
+
+ USHORT GetItemState( const ESelection& /*rSel*/, USHORT /*nWhich*/ ) const { return 0; }
+ USHORT GetItemState( USHORT /*nPara*/, USHORT /*nWhich*/ ) const { return 0; }
+
+ SfxItemPool* GetPool() const { return NULL; }
+
+ void QuickInsertText( const String& /*rText*/, const ESelection& /*rSel*/ ) {}
+ void QuickInsertField( const SvxFieldItem& /*rFld*/, const ESelection& /*rSel*/ ) {}
+ void QuickSetAttribs( const SfxItemSet& /*rSet*/, const ESelection& /*rSel*/ ) {}
+ void QuickInsertLineBreak( const ESelection& /*rSel*/ ) {}
+
+ const SfxItemSet * GetEmptyItemSetPtr() { return 0; }
+
+ void AppendParagraph() {}
+ xub_StrLen AppendTextPortion( USHORT /*nPara*/, const String & /*rText*/, const SfxItemSet & /*rSet*/ ) { return 0; }
+
+ //XTextCopy
+ void CopyText(const SvxTextForwarder& ){}
+
+ XubString CalcFieldValue( const SvxFieldItem& /*rField*/, USHORT /*nPara*/, USHORT /*nPos*/, Color*& /*rpTxtColor*/, Color*& /*rpFldColor*/ )
+ {
+ return XubString();
+ }
+ void FieldClicked( const SvxFieldItem&, USHORT, xub_StrLen ) {;}
+
+ BOOL IsValid() const { return sal_True; }
+
+ void SetNotifyHdl( const Link& ) {}
+ LanguageType GetLanguage( USHORT, USHORT ) const { return LANGUAGE_DONTKNOW; }
+ USHORT GetFieldCount( USHORT ) const { return 0; }
+ EFieldInfo GetFieldInfo( USHORT, USHORT ) const { return EFieldInfo(); }
+ EBulletInfo GetBulletInfo( USHORT ) const { return EBulletInfo(); }
+ Rectangle GetCharBounds( USHORT, USHORT ) const { return Rectangle(); }
+ Rectangle GetParaBounds( USHORT ) const { return Rectangle(); }
+ MapMode GetMapMode() const { return MapMode(); }
+ OutputDevice* GetRefDevice() const { return NULL; }
+ sal_Bool GetIndexAtPoint( const Point&, USHORT&, USHORT& ) const { return sal_False; }
+ sal_Bool GetWordIndices( USHORT, USHORT, USHORT&, USHORT& ) const { return sal_False; }
+ sal_Bool GetAttributeRun( USHORT&, USHORT&, USHORT, USHORT ) const { return sal_False; }
+ USHORT GetLineCount( USHORT nPara ) const { return nPara == 0 ? 1 : 0; }
+ USHORT GetLineLen( USHORT, USHORT ) const { return 0; }
+ void GetLineBoundaries( /*out*/USHORT & rStart, /*out*/USHORT & rEnd, USHORT /*nParagraph*/, USHORT /*nLine*/ ) const { rStart = rEnd = 0; }
+ USHORT GetLineNumberAtIndex( USHORT /*nPara*/, USHORT /*nIndex*/ ) const { return 0; }
+
+ // the following two methods would, strictly speaking, require
+ // a switch to a real EditSource, too. Fortunately, the
+ // AccessibleEditableTextPara implementation currently always
+ // calls GetEditViewForwarder(true) before doing
+ // changes. Thus, we rely on this behabviour here (problem
+ // when that changes: via accessibility API, it would no
+ // longer be possible to enter text in previously empty
+ // shapes).
+ sal_Bool Delete( const ESelection& ) { return sal_False; }
+ sal_Bool InsertText( const String&, const ESelection& ) { return sal_False; }
+ sal_Bool QuickFormatDoc( BOOL ) { return sal_True; }
+ sal_Int16 GetDepth( USHORT ) const { return -1; }
+ sal_Bool SetDepth( USHORT, sal_Int16 ) { return sal_True; }
+
+ Rectangle GetVisArea() const { return Rectangle(); }
+ Point LogicToPixel( const Point& rPoint, const MapMode& /*rMapMode*/ ) const { return rPoint; }
+ Point PixelToLogic( const Point& rPoint, const MapMode& /*rMapMode*/ ) const { return rPoint; }
+
+ };
+
+ // -------------------------------------------------------------------------
+ // Implementing AccessibleProxyEditSource_Impl
+ // -------------------------------------------------------------------------
+
+ AccessibleProxyEditSource_Impl::AccessibleProxyEditSource_Impl( SdrObject& rObj,
+ SdrView& rView,
+ const Window& rViewWindow ) :
+ maEditSource( rObj, 0, rView, rViewWindow )
+ {
+ }
+
+ AccessibleProxyEditSource_Impl::~AccessibleProxyEditSource_Impl()
+ {
+ }
+
+ SvxTextForwarder* AccessibleProxyEditSource_Impl::GetTextForwarder()
+ {
+ return maEditSource.GetTextForwarder();
+ }
+
+ SvxViewForwarder* AccessibleProxyEditSource_Impl::GetViewForwarder()
+ {
+ return maEditSource.GetViewForwarder();
+ }
+
+ SvxEditViewForwarder* AccessibleProxyEditSource_Impl::GetEditViewForwarder( sal_Bool bCreate )
+ {
+ return maEditSource.GetEditViewForwarder( bCreate );
+ }
+
+ SvxEditSource* AccessibleProxyEditSource_Impl::Clone() const
+ {
+ return maEditSource.Clone();
+ }
+
+ void AccessibleProxyEditSource_Impl::UpdateData()
+ {
+ maEditSource.UpdateData();
+ }
+
+ SfxBroadcaster& AccessibleProxyEditSource_Impl::GetBroadcaster() const
+ {
+ return maEditSource.GetBroadcaster();
+ }
+
+
+ // -------------------------------------------------------------------------
+ // Implementing AccessibleEmptyEditSource
+ // -------------------------------------------------------------------------
+
+ AccessibleEmptyEditSource::AccessibleEmptyEditSource( SdrObject& rObj,
+ SdrView& rView,
+ const Window& rViewWindow ) :
+ mpEditSource( new AccessibleEmptyEditSource_Impl() ),
+ mrObj(rObj),
+ mrView(rView),
+ mrViewWindow(rViewWindow),
+ mbEditSourceEmpty( true )
+ {
+ if( mrObj.GetModel() )
+ StartListening( *mrObj.GetModel() );
+ }
+
+ AccessibleEmptyEditSource::~AccessibleEmptyEditSource()
+ {
+ if( !mbEditSourceEmpty )
+ {
+ // deregister as listener
+ if( mpEditSource.get() )
+ EndListening( mpEditSource->GetBroadcaster() );
+ }
+ else
+ {
+ if( mrObj.GetModel() )
+ EndListening( *mrObj.GetModel() );
+ }
+ }
+
+ SvxTextForwarder* AccessibleEmptyEditSource::GetTextForwarder()
+ {
+ if( !mpEditSource.get() )
+ return NULL;
+
+ return mpEditSource->GetTextForwarder();
+ }
+
+ SvxViewForwarder* AccessibleEmptyEditSource::GetViewForwarder()
+ {
+ if( !mpEditSource.get() )
+ return NULL;
+
+ return mpEditSource->GetViewForwarder();
+ }
+
+ void AccessibleEmptyEditSource::Switch2ProxyEditSource()
+ {
+ // deregister EmptyEditSource model listener
+ if( mrObj.GetModel() )
+ EndListening( *mrObj.GetModel() );
+
+ ::std::auto_ptr< SvxEditSource > pProxySource( new AccessibleProxyEditSource_Impl(mrObj, mrView, mrViewWindow) );
+ ::std::auto_ptr< SvxEditSource > tmp = mpEditSource;
+ mpEditSource = pProxySource;
+ pProxySource = tmp;
+
+ // register as listener
+ StartListening( mpEditSource->GetBroadcaster() );
+
+ // we've irrevocably a full EditSource now.
+ mbEditSourceEmpty = false;
+ }
+
+ SvxEditViewForwarder* AccessibleEmptyEditSource::GetEditViewForwarder( sal_Bool bCreate )
+ {
+ if( !mpEditSource.get() )
+ return NULL;
+
+ // switch edit source, if not yet done
+ if( mbEditSourceEmpty && bCreate )
+ Switch2ProxyEditSource();
+
+ return mpEditSource->GetEditViewForwarder( bCreate );
+ }
+
+ SvxEditSource* AccessibleEmptyEditSource::Clone() const
+ {
+ if( !mpEditSource.get() )
+ return NULL;
+
+ return mpEditSource->Clone();
+ }
+
+ void AccessibleEmptyEditSource::UpdateData()
+ {
+ if( mpEditSource.get() )
+ mpEditSource->UpdateData();
+ }
+
+ SfxBroadcaster& AccessibleEmptyEditSource::GetBroadcaster() const
+ {
+ return *(const_cast<AccessibleEmptyEditSource*>(this));
+ }
+
+ void AccessibleEmptyEditSource::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+ {
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+
+ if( pSdrHint && pSdrHint->GetKind() == HINT_BEGEDIT &&
+ &mrObj == pSdrHint->GetObject() && mpEditSource.get() )
+ {
+ // switch edit source, if not yet done. This is necessary
+ // to become a full-fledged EditSource the first time a
+ // user start entering text in a previously empty object.
+ if( mbEditSourceEmpty )
+ Switch2ProxyEditSource();
+ }
+ else if (pSdrHint && pSdrHint->GetObject()!=NULL)
+ {
+ // When the SdrObject just got a para outliner object then
+ // switch the edit source.
+ if (pSdrHint->GetObject()->GetOutlinerParaObject() != NULL)
+ Switch2ProxyEditSource();
+ }
+
+ // forward messages
+ Broadcast( rHint );
+ }
+
+} // end of namespace accessibility
+
+//------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleEmptyEditSource.hxx b/svx/source/accessibility/AccessibleEmptyEditSource.hxx
new file mode 100644
index 000000000000..b2d6765847d9
--- /dev/null
+++ b/svx/source/accessibility/AccessibleEmptyEditSource.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_ACCESSIBLEEMPTYEDITSOURCE_HXX
+#define _SVX_ACCESSIBLEEMPTYEDITSOURCE_HXX
+
+#include <svl/brdcst.hxx>
+#include <svl/lstner.hxx>
+
+#include <memory>
+#include <editeng/unoedsrc.hxx>
+
+class SdrObject;
+class SdrView;
+class Window;
+
+namespace accessibility
+{
+ /** Proxy edit source for shapes without text
+
+ Extracted from old SvxDummyEditSource
+ */
+ class AccessibleEmptyEditSource : public SvxEditSource, public SfxListener, public SfxBroadcaster
+ {
+ public:
+ /** Create proxy edit source for shapes without text
+
+ Since the views don't broadcast their dying, make sure that
+ this object gets destroyed if the view becomes invalid
+
+ The window is necessary, since our views can display on multiple windows
+
+ Make sure you only create such an object if the shape _really_
+ does not contain text.
+ */
+ AccessibleEmptyEditSource( SdrObject& rObj, SdrView& rView, const Window& rViewWindow );
+ ~AccessibleEmptyEditSource();
+
+ // from the SvxEditSource interface
+ SvxTextForwarder* GetTextForwarder();
+ SvxViewForwarder* GetViewForwarder();
+
+ SvxEditSource* Clone() const;
+
+ // this method internally switches from empty to proxy mode,
+ // creating an SvxTextEditSource for the functionality.
+ SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate = sal_False );
+
+ void UpdateData();
+ SfxBroadcaster& GetBroadcaster() const;
+
+ // from the SfxListener interface
+ void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ private:
+ void Switch2ProxyEditSource();
+
+ /** Pointer to edit source implementation. This is switched on
+ a GetEditViewForwarder( true ) call, to actually create a
+ SvxTextEditSource.
+
+ @dyn
+ */
+ std::auto_ptr< SvxEditSource > mpEditSource;
+
+ SdrObject& mrObj;
+ SdrView& mrView;
+ const Window& mrViewWindow;
+
+ bool mbEditSourceEmpty;
+ };
+
+} // namespace accessibility
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleFrameSelector.cxx b/svx/source/accessibility/AccessibleFrameSelector.cxx
new file mode 100644
index 000000000000..d4c168275fb0
--- /dev/null
+++ b/svx/source/accessibility/AccessibleFrameSelector.cxx
@@ -0,0 +1,732 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "AccessibleFrameSelector.hxx"
+#include <com/sun/star/awt/KeyEvent.hpp>
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <com/sun/star/awt/Key.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/awt/FocusChangeReason.hpp>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/frmsel.hxx>
+#include <svx/dialmgr.hxx>
+#include "editeng/unolingu.hxx"
+
+#include <svx/dialogs.hrc>
+#include "frmsel.hrc"
+
+#ifndef MNEMONIC_CHAR
+#define MNEMONIC_CHAR ((sal_Unicode)'~')
+#endif
+
+namespace svx {
+namespace a11y {
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::XInterface;
+using ::com::sun::star::lang::Locale;
+using ::com::sun::star::lang::EventObject;
+using ::com::sun::star::beans::XPropertyChangeListener;
+using ::com::sun::star::awt::XFocusListener;
+
+using namespace ::com::sun::star::accessibility;
+
+namespace AwtKey = ::com::sun::star::awt::Key;
+namespace AwtKeyModifier = ::com::sun::star::awt::KeyModifier;
+namespace AwtFocusChangeReason = ::com::sun::star::awt::FocusChangeReason;
+
+typedef ::com::sun::star::awt::Point AwtPoint;
+typedef ::com::sun::star::awt::Size AwtSize;
+typedef ::com::sun::star::awt::Rectangle AwtRectangle;
+typedef ::com::sun::star::awt::KeyEvent AwtKeyEvent;
+typedef ::com::sun::star::awt::FocusEvent AwtFocusEvent;
+
+// ============================================================================
+
+AccFrameSelector::AccFrameSelector( FrameSelector& rFrameSel, FrameBorderType eBorder ) :
+ Resource( SVX_RES( RID_SVXSTR_BORDER_CONTROL ) ),
+ mpFrameSel( &rFrameSel ),
+ meBorder( eBorder ),
+ maFocusListeners( maFocusMutex ),
+ maPropertyListeners( maPropertyMutex ),
+ maNames( SVX_RES( ARR_TEXTS ) ),
+ maDescriptions( SVX_RES(ARR_DESCRIPTIONS ) ),
+ mnClientId( 0 )
+{
+ FreeResource();
+
+ if ( mpFrameSel )
+ {
+ mpFrameSel->AddEventListener( LINK( this, AccFrameSelector, WindowEventListener ) );
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+AccFrameSelector::~AccFrameSelector()
+{
+ if ( mpFrameSel )
+ {
+ mpFrameSel->RemoveEventListener( LINK( this, AccFrameSelector, WindowEventListener ) );
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+Reference< XAccessibleContext > AccFrameSelector::getAccessibleContext( )
+ throw (RuntimeException)
+{
+ return this;
+}
+
+// ----------------------------------------------------------------------------
+
+sal_Int32 AccFrameSelector::getAccessibleChildCount( ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ return (meBorder == FRAMEBORDER_NONE) ? mpFrameSel->GetEnabledBorderCount() : 0;
+}
+
+// ----------------------------------------------------------------------------
+
+Reference< XAccessible > AccFrameSelector::getAccessibleChild( sal_Int32 i )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ Reference< XAccessible > xRet;
+ if( meBorder == FRAMEBORDER_NONE )
+ xRet = mpFrameSel->GetChildAccessible( i );
+ if( !xRet.is() )
+ throw RuntimeException();
+ return xRet;
+}
+
+// ----------------------------------------------------------------------------
+
+Reference< XAccessible > AccFrameSelector::getAccessibleParent( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ Reference< XAccessible > xRet;
+ if(meBorder == FRAMEBORDER_NONE)
+ xRet = mpFrameSel->GetParent()->GetAccessible( sal_True );
+ else
+ xRet = mpFrameSel->CreateAccessible();
+ return xRet;
+}
+
+// ----------------------------------------------------------------------------
+
+sal_Int32 AccFrameSelector::getAccessibleIndexInParent( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+
+ sal_Int32 nIdx = 0;
+ if( meBorder == FRAMEBORDER_NONE )
+ {
+ Window* pTabPage = mpFrameSel->GetParent();
+ sal_Int32 nChildren = pTabPage->GetChildCount();
+ for( nIdx = 0; nIdx < nChildren; ++nIdx )
+ if( pTabPage->GetChild( static_cast< USHORT >( nIdx ) ) == mpFrameSel )
+ break;
+ }
+ else
+ nIdx = mpFrameSel->GetEnabledBorderIndex( meBorder );
+
+ if( nIdx < 0 )
+ throw RuntimeException();
+ return nIdx;
+}
+
+// ----------------------------------------------------------------------------
+
+sal_Int16 AccFrameSelector::getAccessibleRole( ) throw (RuntimeException)
+{
+ return AccessibleRole::OPTION_PANE;
+}
+
+// ----------------------------------------------------------------------------
+
+OUString AccFrameSelector::getAccessibleDescription( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ return maDescriptions.GetString(meBorder);
+}
+
+// ----------------------------------------------------------------------------
+
+OUString AccFrameSelector::getAccessibleName( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ return maNames.GetString(meBorder);
+}
+
+// ----------------------------------------------------------------------------
+
+Reference< XAccessibleRelationSet > AccFrameSelector::getAccessibleRelationSet( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ utl::AccessibleRelationSetHelper* pHelper;
+ Reference< XAccessibleRelationSet > xRet = pHelper = new utl::AccessibleRelationSetHelper;
+ if(meBorder == FRAMEBORDER_NONE)
+ {
+ //add the label relation
+ Window* pPrev = mpFrameSel->GetWindow( WINDOW_PREV );
+ if(pPrev && WINDOW_FIXEDTEXT == pPrev->GetType())
+ {
+ AccessibleRelation aLabelRelation;
+ aLabelRelation.RelationType = AccessibleRelationType::LABELED_BY;
+ aLabelRelation.TargetSet.realloc(1);
+ aLabelRelation.TargetSet.getArray()[0] = pPrev->GetAccessible();
+ pHelper->AddRelation(aLabelRelation);
+ }
+ }
+ return xRet;
+}
+
+// ----------------------------------------------------------------------------
+
+Reference< XAccessibleStateSet > AccFrameSelector::getAccessibleStateSet( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
+ Reference< XAccessibleStateSet > xRet = pStateSetHelper;
+
+ if(!mpFrameSel)
+ pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ const sal_Int16 aStandardStates[] =
+ {
+ AccessibleStateType::EDITABLE,
+ AccessibleStateType::FOCUSABLE,
+ AccessibleStateType::MULTI_SELECTABLE,
+ AccessibleStateType::SELECTABLE,
+ AccessibleStateType::SHOWING,
+ AccessibleStateType::VISIBLE,
+ AccessibleStateType::OPAQUE,
+ 0};
+ sal_Int16 nState = 0;
+ while(aStandardStates[nState])
+ {
+ pStateSetHelper->AddState(aStandardStates[nState++]);
+ }
+ if(mpFrameSel->IsEnabled())
+ {
+ pStateSetHelper->AddState(AccessibleStateType::ENABLED);
+ pStateSetHelper->AddState(AccessibleStateType::SENSITIVE);
+ }
+
+ sal_Bool bIsParent = meBorder == FRAMEBORDER_NONE;
+ if(mpFrameSel->HasFocus() &&
+ (bIsParent || mpFrameSel->IsBorderSelected(meBorder)))
+ {
+ pStateSetHelper->AddState(AccessibleStateType::ACTIVE);
+ pStateSetHelper->AddState(AccessibleStateType::FOCUSED);
+ pStateSetHelper->AddState(AccessibleStateType::SELECTED);
+ }
+ }
+ return xRet;
+}
+
+// ----------------------------------------------------------------------------
+
+Locale AccFrameSelector::getLocale( )
+ throw (IllegalAccessibleComponentStateException, RuntimeException)
+{
+ Locale aRet;
+ SvxLanguageToLocale( aRet, Application::GetSettings().GetUILanguage() );
+ return aRet;
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::addPropertyChangeListener(
+ const Reference< XPropertyChangeListener >& xListener )
+ throw (RuntimeException)
+{
+ maPropertyListeners.addInterface( xListener );
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::removePropertyChangeListener( const Reference< XPropertyChangeListener >& xListener )
+ throw (RuntimeException)
+{
+ maPropertyListeners.removeInterface( xListener );
+}
+
+// ----------------------------------------------------------------------------
+
+sal_Bool AccFrameSelector::containsPoint( const AwtPoint& aPt )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ //aPt is relative to the frame selector
+ return mpFrameSel->ContainsClickPoint( Point( aPt.X, aPt.Y ) );
+}
+
+// ----------------------------------------------------------------------------
+
+Reference< XAccessible > AccFrameSelector::getAccessibleAtPoint(
+ const AwtPoint& aPt )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ //aPt is relative to the frame selector
+ return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
+}
+
+AwtRectangle AccFrameSelector::getBounds( ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ Size aSz;
+ Point aPos;
+ switch(meBorder)
+ {
+ case FRAMEBORDER_NONE:
+ aSz = mpFrameSel->GetSizePixel();
+ aPos = mpFrameSel->GetPosPixel();
+ break;
+ default:
+ const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
+ aPos = aSpot.TopLeft();
+ aSz = aSpot.GetSize();
+ }
+ AwtRectangle aRet;
+ aRet.X = aPos.X();
+ aRet.Y = aPos.Y();
+ aRet.Width = aSz.Width();
+ aRet.Height = aSz.Height();
+ return aRet;
+}
+
+// ----------------------------------------------------------------------------
+
+AwtPoint AccFrameSelector::getLocation( ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ Point aPos;
+ switch(meBorder)
+ {
+ case FRAMEBORDER_NONE:
+ aPos = mpFrameSel->GetPosPixel();
+ break;
+ default:
+ const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
+ aPos = aSpot.TopLeft();
+ }
+ AwtPoint aRet(aPos.X(), aPos.Y());
+ return aRet;
+}
+
+// ----------------------------------------------------------------------------
+
+AwtPoint AccFrameSelector::getLocationOnScreen( ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ Point aPos;
+ switch(meBorder)
+ {
+ case FRAMEBORDER_NONE:
+ aPos = mpFrameSel->GetPosPixel();
+ break;
+ default:
+ const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
+ aPos = aSpot.TopLeft();
+ }
+ aPos = mpFrameSel->OutputToAbsoluteScreenPixel( aPos );
+ AwtPoint aRet(aPos.X(), aPos.Y());
+ return aRet;
+}
+
+// ----------------------------------------------------------------------------
+
+AwtSize AccFrameSelector::getSize( ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ Size aSz;
+ switch(meBorder)
+ {
+ case FRAMEBORDER_NONE:
+ aSz = mpFrameSel->GetSizePixel();
+ break;
+ default:
+ const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
+ aSz = aSpot.GetSize();
+ }
+ AwtSize aRet(aSz.Width(), aSz.Height());
+ return aRet;
+}
+
+// ----------------------------------------------------------------------------
+
+sal_Bool AccFrameSelector::isShowing( ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ return sal_True;
+}
+
+// ----------------------------------------------------------------------------
+
+sal_Bool AccFrameSelector::isVisible( ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ return sal_True;
+}
+
+// ----------------------------------------------------------------------------
+
+sal_Bool AccFrameSelector::isFocusTraversable( ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ return sal_True;
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::addFocusListener( const Reference< XFocusListener >& xListener ) throw (RuntimeException)
+{
+ maFocusListeners.addInterface( xListener );
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::removeFocusListener( const Reference< XFocusListener >& xListener ) throw (RuntimeException)
+{
+ maFocusListeners.removeInterface( xListener );
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::grabFocus( ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsValid();
+ mpFrameSel->GrabFocus();
+}
+
+// ----------------------------------------------------------------------------
+
+Any AccFrameSelector::getAccessibleKeyBinding( ) throw (RuntimeException)
+{
+ Any aRet;
+ SolarMutexGuard aGuard;
+ IsValid();
+ utl::AccessibleRelationSetHelper* pHelper;
+ Reference< XAccessibleRelationSet > xRet = pHelper = new utl::AccessibleRelationSetHelper;
+ if(meBorder == FRAMEBORDER_NONE)
+ {
+ Window* pPrev = mpFrameSel->GetWindow( WINDOW_PREV );
+ if(pPrev && WINDOW_FIXEDTEXT == pPrev->GetType())
+ {
+ String sText = pPrev->GetText();
+ xub_StrLen nFound = sText.Search( MNEMONIC_CHAR );
+ if(STRING_NOTFOUND != nFound && ++nFound < sText.Len())
+ {
+ sText.ToUpperAscii();
+ sal_Unicode cChar = sText.GetChar(nFound);
+ AwtKeyEvent aEvent;
+
+ aEvent.KeyCode = 0;
+ aEvent.KeyChar = cChar;
+ aEvent.KeyFunc = 0;
+ if(cChar >= 'A' && cChar <= 'Z')
+ {
+ aEvent.KeyCode = AwtKey::A + cChar - 'A';
+ }
+ aEvent.Modifiers = AwtKeyModifier::MOD2;
+ aRet <<= aEvent;
+ }
+ }
+ }
+ return aRet;
+}
+
+// ----------------------------------------------------------------------------
+
+sal_Int32 AccFrameSelector::getForeground( )
+ throw (RuntimeException)
+{
+ Any aRet;
+ SolarMutexGuard aGuard;
+ IsValid();
+ return mpFrameSel->GetControlForeground().GetColor();
+}
+
+// ----------------------------------------------------------------------------
+
+sal_Int32 AccFrameSelector::getBackground( )
+ throw (RuntimeException)
+{
+ Any aRet;
+ SolarMutexGuard aGuard;
+ IsValid();
+ return mpFrameSel->GetControlBackground().GetColor();
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( xListener.is() )
+ {
+ if ( !mnClientId )
+ {
+ mnClientId = ::comphelper::AccessibleEventNotifier::registerClient();
+ }
+ ::comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( xListener.is() && mnClientId != 0 &&
+ ::comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ) == 0 )
+ {
+ // no listeners anymore
+ // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+ // and at least to us not firing any events anymore, in case somebody calls
+ // NotifyAccessibleEvent, again
+ ::comphelper::AccessibleEventNotifier::TClientId nId( mnClientId );
+ mnClientId = 0;
+ ::comphelper::AccessibleEventNotifier::revokeClient( nId );
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+OUString AccFrameSelector::getImplementationName( ) throw (RuntimeException)
+{
+ return OUString::createFromAscii("AccFrameSelector");
+}
+
+// ----------------------------------------------------------------------------
+
+const sal_Char sAccessible[] = "Accessible";
+const sal_Char sAccessibleContext[] = "AccessibleContext";
+const sal_Char sAccessibleComponent[] = "AccessibleComponent";
+
+sal_Bool AccFrameSelector::supportsService( const OUString& rServiceName )
+ throw (RuntimeException)
+{
+ return rServiceName.equalsAsciiL( sAccessible , sizeof(sAccessible )-1 ) ||
+ rServiceName.equalsAsciiL( sAccessibleContext , sizeof(sAccessibleContext )-1 ) ||
+ rServiceName.equalsAsciiL( sAccessibleComponent, sizeof(sAccessibleComponent)-1 );
+}
+
+// ----------------------------------------------------------------------------
+
+Sequence< OUString > AccFrameSelector::getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ Sequence< OUString > aRet(3);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessible ) );
+ pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleContext ) );
+ pArray[2] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleComponent) );
+ return aRet;
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::IsValid() throw (RuntimeException)
+{
+ if(!mpFrameSel)
+ throw RuntimeException();
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::NotifyFocusListeners(sal_Bool bGetFocus)
+{
+ SolarMutexGuard aGuard;
+ AwtFocusEvent aEvent;
+ aEvent.FocusFlags = 0;
+ if(bGetFocus)
+ {
+ USHORT nFocusFlags = mpFrameSel->GetGetFocusFlags();
+ if(nFocusFlags&GETFOCUS_TAB)
+ aEvent.FocusFlags |= AwtFocusChangeReason::TAB;
+ if(nFocusFlags&GETFOCUS_CURSOR)
+ aEvent.FocusFlags |= AwtFocusChangeReason::CURSOR;
+ if(nFocusFlags&GETFOCUS_MNEMONIC)
+ aEvent.FocusFlags |= AwtFocusChangeReason::MNEMONIC;
+ if(nFocusFlags&GETFOCUS_FORWARD)
+ aEvent.FocusFlags |= AwtFocusChangeReason::FORWARD;
+ if(nFocusFlags&GETFOCUS_BACKWARD)
+ aEvent.FocusFlags |= AwtFocusChangeReason::BACKWARD;
+ if(nFocusFlags&GETFOCUS_AROUND)
+ aEvent.FocusFlags |= AwtFocusChangeReason::AROUND;
+ if(nFocusFlags&GETFOCUS_UNIQUEMNEMONIC)
+ aEvent.FocusFlags |= AwtFocusChangeReason::UNIQUEMNEMONIC;
+ // if(nFocusFlags&GETFOCUS_INIT)
+ // aEvent.FocusFlags |= AwtFocusChangeReason::
+ }
+// else
+ //how can I find the current focus window?
+// aEvent.NextFocus = ;
+ aEvent.Temporary = sal_False;
+
+ Reference < XAccessibleContext > xThis( this );
+ aEvent.Source = xThis;
+
+ ::cppu::OInterfaceIteratorHelper aIter( maFocusListeners );
+ while( aIter.hasMoreElements() )
+ {
+ Reference < XFocusListener > xListener( aIter.next(), UNO_QUERY );
+ if(bGetFocus)
+ xListener->focusGained( aEvent );
+ else
+ xListener->focusLost( aEvent );
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+IMPL_LINK( AccFrameSelector, WindowEventListener, VclSimpleEvent*, pEvent )
+{
+ VclWindowEvent* pWinEvent = dynamic_cast< VclWindowEvent* >( pEvent );
+ DBG_ASSERT( pWinEvent, "AccFrameSelector::WindowEventListener - unknown window event" );
+ if ( pWinEvent )
+ {
+ Window* pWindow = pWinEvent->GetWindow();
+ DBG_ASSERT( pWindow, "AccFrameSelector::WindowEventListener: no window!" );
+ if ( !pWindow->IsAccessibilityEventsSuppressed() || ( pWinEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
+ {
+ ProcessWindowEvent( *pWinEvent );
+ }
+ }
+
+ return 0;
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_WINDOW_GETFOCUS:
+ {
+ if ( meBorder == FRAMEBORDER_NONE )
+ {
+ Any aOldValue, aNewValue;
+ aNewValue <<= AccessibleStateType::FOCUSED;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ }
+ break;
+ case VCLEVENT_WINDOW_LOSEFOCUS:
+ {
+ if ( meBorder == FRAMEBORDER_NONE )
+ {
+ Any aOldValue, aNewValue;
+ aOldValue <<= AccessibleStateType::FOCUSED;
+ NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ }
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::NotifyAccessibleEvent( const sal_Int16 _nEventId,
+ const Any& _rOldValue, const Any& _rNewValue )
+{
+ if ( mnClientId )
+ {
+ Reference< XInterface > xSource( *this );
+ AccessibleEventObject aEvent( xSource, _nEventId, _rNewValue, _rOldValue );
+ ::comphelper::AccessibleEventNotifier::addEvent( mnClientId, aEvent );
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+void AccFrameSelector::Invalidate()
+{
+ mpFrameSel = 0;
+ EventObject aEvent;
+ Reference < XAccessibleContext > xThis( this );
+ aEvent.Source = xThis;
+ maFocusListeners.disposeAndClear( aEvent );
+ maPropertyListeners.disposeAndClear( aEvent );
+}
+
+// ============================================================================
+
+} // namespace a11y
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleGraphicShape.cxx b/svx/source/accessibility/AccessibleGraphicShape.cxx
new file mode 100644
index 000000000000..a3cfcbf1d9a0
--- /dev/null
+++ b/svx/source/accessibility/AccessibleGraphicShape.cxx
@@ -0,0 +1,215 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+
+#include <svx/AccessibleGraphicShape.hxx>
+
+#include <svx/ShapeTypeHandler.hxx>
+#include <svx/SvxShapeTypes.hxx>
+
+using namespace ::accessibility;
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+AccessibleGraphicShape::AccessibleGraphicShape (
+ const AccessibleShapeInfo& rShapeInfo,
+ const AccessibleShapeTreeInfo& rShapeTreeInfo)
+ : AccessibleShape (rShapeInfo, rShapeTreeInfo)
+{
+}
+
+
+
+
+AccessibleGraphicShape::~AccessibleGraphicShape (void)
+{
+}
+
+
+
+
+//===== XAccessibleImage ====================================================
+
+::rtl::OUString SAL_CALL AccessibleGraphicShape::getAccessibleImageDescription (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return AccessibleShape::getAccessibleDescription ();
+}
+
+
+
+
+sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageHeight (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return AccessibleShape::getSize().Height;
+}
+
+
+
+
+sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageWidth (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return AccessibleShape::getSize().Width;
+}
+
+
+
+
+//===== XInterface ==========================================================
+
+com::sun::star::uno::Any SAL_CALL
+ AccessibleGraphicShape::queryInterface (const com::sun::star::uno::Type & rType)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Any aReturn = AccessibleShape::queryInterface (rType);
+ if ( ! aReturn.hasValue())
+ aReturn = ::cppu::queryInterface (rType,
+ static_cast<XAccessibleImage*>(this));
+ return aReturn;
+}
+
+
+
+void SAL_CALL
+ AccessibleGraphicShape::acquire (void)
+ throw ()
+{
+ AccessibleShape::acquire ();
+}
+
+
+
+void SAL_CALL
+ AccessibleGraphicShape::release (void)
+ throw ()
+{
+ AccessibleShape::release ();
+}
+
+
+
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString SAL_CALL
+ AccessibleGraphicShape::getImplementationName (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("AccessibleGraphicShape"));
+}
+
+
+
+
+::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
+ AccessibleGraphicShape::getSupportedServiceNames (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+ // Get list of supported service names from base class...
+ uno::Sequence<OUString> aServiceNames =
+ AccessibleShape::getSupportedServiceNames();
+ sal_Int32 nCount (aServiceNames.getLength());
+
+ // ...and add additional names.
+ aServiceNames.realloc (nCount + 1);
+ static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.drawing.AccessibleGraphicShape"));
+ aServiceNames[nCount] = sAdditionalServiceName;
+
+ return aServiceNames;
+}
+
+
+
+
+//===== XTypeProvider ===================================================
+
+uno::Sequence<uno::Type> SAL_CALL
+ AccessibleGraphicShape::getTypes (void)
+ throw (uno::RuntimeException)
+{
+ // Get list of types from the context base implementation...
+ uno::Sequence<uno::Type> aTypeList (AccessibleShape::getTypes());
+ // ...and add the additional type for the component.
+ long nTypeCount = aTypeList.getLength();
+ aTypeList.realloc (nTypeCount + 1);
+ const uno::Type aImageType =
+ ::getCppuType((const uno::Reference<XAccessibleImage>*)0);
+ aTypeList[nTypeCount] = aImageType;
+
+ return aTypeList;
+}
+
+
+
+
+/// Create the base name of this object, i.e. the name without appended number.
+::rtl::OUString
+ AccessibleGraphicShape::CreateAccessibleBaseName (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString sName;
+
+ ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
+ switch (nShapeType)
+ {
+ case DRAWING_GRAPHIC_OBJECT:
+ sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("GraphicObjectShape"));
+ break;
+
+ default:
+ sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleGraphicShape"));
+ uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
+ if (xDescriptor.is())
+ sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
+ + xDescriptor->getShapeType();
+ }
+
+ return sName;
+}
+
+
+
+::rtl::OUString
+ AccessibleGraphicShape::CreateAccessibleDescription (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return CreateAccessibleName ();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleOLEShape.cxx b/svx/source/accessibility/AccessibleOLEShape.cxx
new file mode 100644
index 000000000000..764d4d8bfadd
--- /dev/null
+++ b/svx/source/accessibility/AccessibleOLEShape.cxx
@@ -0,0 +1,234 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+
+#include <svx/AccessibleOLEShape.hxx>
+
+#include <svx/ShapeTypeHandler.hxx>
+#include <svx/SvxShapeTypes.hxx>
+
+using namespace accessibility;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+AccessibleOLEShape::AccessibleOLEShape (
+ const AccessibleShapeInfo& rShapeInfo,
+ const AccessibleShapeTreeInfo& rShapeTreeInfo)
+ : AccessibleShape (rShapeInfo, rShapeTreeInfo)
+{
+}
+
+
+
+
+AccessibleOLEShape::~AccessibleOLEShape (void)
+{
+}
+
+
+
+
+//===== XAccessibleAction ===================================================
+
+sal_Int32 SAL_CALL AccessibleOLEShape::getAccessibleActionCount (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return 0;
+}
+
+
+
+
+sal_Bool SAL_CALL AccessibleOLEShape::doAccessibleAction (sal_Int32 /*nIndex*/)
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ throw lang::IndexOutOfBoundsException();
+}
+
+
+
+
+::rtl::OUString SAL_CALL AccessibleOLEShape::getAccessibleActionDescription (sal_Int32 /*nIndex*/)
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ throw lang::IndexOutOfBoundsException();
+}
+
+
+
+
+Reference<XAccessibleKeyBinding> SAL_CALL AccessibleOLEShape::getAccessibleActionKeyBinding (sal_Int32 /*nIndex*/)
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ throw lang::IndexOutOfBoundsException();
+}
+
+
+
+
+//===== XInterface ==========================================================
+
+com::sun::star::uno::Any SAL_CALL
+ AccessibleOLEShape::queryInterface (const com::sun::star::uno::Type & rType)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Any aReturn = AccessibleShape::queryInterface (rType);
+ if ( ! aReturn.hasValue())
+ aReturn = ::cppu::queryInterface (rType,
+ static_cast<XAccessibleAction*>(this));
+ return aReturn;
+}
+
+
+
+void SAL_CALL
+ AccessibleOLEShape::acquire (void)
+ throw ()
+{
+ AccessibleShape::acquire ();
+}
+
+
+
+void SAL_CALL
+ AccessibleOLEShape::release (void)
+ throw ()
+{
+ AccessibleShape::release ();
+}
+
+
+
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString SAL_CALL
+ AccessibleOLEShape::getImplementationName (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleOLEShape"));
+}
+
+
+
+
+::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
+ AccessibleOLEShape::getSupportedServiceNames (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed();
+ // Get list of supported service names from base class...
+ uno::Sequence< ::rtl::OUString > aServiceNames =
+ AccessibleShape::getSupportedServiceNames();
+ sal_Int32 nCount (aServiceNames.getLength());
+
+ // ...and add additional names.
+ aServiceNames.realloc (nCount + 1);
+ static const ::rtl::OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.drawing.AccessibleOLEShape"));
+ aServiceNames[nCount] = sAdditionalServiceName;
+
+ return aServiceNames;
+}
+
+
+
+
+//===== XTypeProvider ===================================================
+
+uno::Sequence<uno::Type> SAL_CALL
+ AccessibleOLEShape::getTypes (void)
+ throw (uno::RuntimeException)
+{
+ // Get list of types from the context base implementation...
+ uno::Sequence<uno::Type> aTypeList (AccessibleShape::getTypes());
+ // ...and add the additional type for the component.
+ long nTypeCount = aTypeList.getLength();
+ aTypeList.realloc (nTypeCount + 1);
+ const uno::Type aActionType =
+ ::getCppuType((const uno::Reference<XAccessibleAction>*)0);
+ aTypeList[nTypeCount] = aActionType;
+
+ return aTypeList;
+}
+
+
+
+
+/// Set this object's name if is different to the current name.
+::rtl::OUString
+ AccessibleOLEShape::CreateAccessibleBaseName (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString sName;
+
+ ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
+ switch (nShapeType)
+ {
+ case DRAWING_APPLET:
+ sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("AppletOLEShape"));
+ break;
+ case DRAWING_FRAME:
+ sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("FrameOLEShape"));
+ break;
+ case DRAWING_OLE:
+ sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("OLEShape"));
+ break;
+ case DRAWING_PLUGIN:
+ sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("PluginOLEShape"));
+ break;
+
+ default:
+ sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleOLEShape"));
+ uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
+ if (xDescriptor.is())
+ sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
+ + xDescriptor->getShapeType();
+ }
+
+ return sName;
+}
+
+
+
+::rtl::OUString
+ AccessibleOLEShape::CreateAccessibleDescription (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return CreateAccessibleName ();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleShape.cxx b/svx/source/accessibility/AccessibleShape.cxx
new file mode 100644
index 000000000000..61dde0820ea3
--- /dev/null
+++ b/svx/source/accessibility/AccessibleShape.cxx
@@ -0,0 +1,1241 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/AccessibleShape.hxx>
+#include "DescriptionGenerator.hxx"
+#include <svx/AccessibleShapeInfo.hxx>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <rtl/uuid.h>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/drawing/XShapeDescriptor.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <editeng/outlobj.hxx>
+#include <rtl/ref.hxx>
+#include <editeng/unoedsrc.hxx>
+#include <svx/unoshtxt.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdmodel.hxx>
+#include "unoapi.hxx"
+#include <com/sun/star/uno/Exception.hpp>
+#include <svx/ShapeTypeHandler.hxx>
+#include <svx/SvxShapeTypes.hxx>
+
+#include "accessibility.hrc"
+#include "svdstr.hrc"
+#include <svx/dialmgr.hxx>
+#include <vcl/svapp.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <svx/svdview.hxx>
+#include "AccessibleEmptyEditSource.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+using ::com::sun::star::uno::Reference;
+using ::rtl::OUString;
+
+namespace accessibility {
+
+namespace {
+
+OUString GetOptionalProperty (
+ const Reference<beans::XPropertySet>& rxSet,
+ const OUString& rsPropertyName)
+{
+ OUString sValue;
+
+ if (rxSet.is())
+ {
+ const Reference<beans::XPropertySetInfo> xInfo (rxSet->getPropertySetInfo());
+ if ( ! xInfo.is() || xInfo->hasPropertyByName(rsPropertyName))
+ {
+ try
+ {
+ rxSet->getPropertyValue(rsPropertyName) >>= sValue;
+ }
+ catch (beans::UnknownPropertyException&)
+ {
+ // This exception should only be thrown when the property
+ // does not exits (of course) and the XPropertySetInfo is
+ // not available.
+ }
+ }
+ }
+ return sValue;
+}
+
+} // end of anonymous namespace
+
+
+
+
+//===== internal ============================================================
+
+AccessibleShape::AccessibleShape (
+ const AccessibleShapeInfo& rShapeInfo,
+ const AccessibleShapeTreeInfo& rShapeTreeInfo)
+ : AccessibleContextBase (rShapeInfo.mxParent,AccessibleRole::LIST_ITEM),
+ mpChildrenManager(NULL),
+ mxShape (rShapeInfo.mxShape),
+ maShapeTreeInfo (rShapeTreeInfo),
+ mnIndex (rShapeInfo.mnIndex),
+ m_nIndexInParent(-1),
+ mpText (NULL),
+ mpParent (rShapeInfo.mpChildrenManager)
+{
+ m_pShape = GetSdrObjectFromXShape(mxShape);
+ UpdateNameAndDescription();
+}
+
+
+
+
+AccessibleShape::~AccessibleShape (void)
+{
+ if (mpChildrenManager != NULL)
+ delete mpChildrenManager;
+ if (mpText != NULL)
+ delete mpText;
+ OSL_TRACE ("~AccessibleShape");
+
+ // Unregistering from the various broadcasters should be unnecessary
+ // since this destructor would not have been called if one of the
+ // broadcasters would still hold a strong reference to this object.
+}
+
+
+
+
+void AccessibleShape::Init (void)
+{
+ // Update the OPAQUE and SELECTED shape.
+ UpdateStates ();
+
+ // Create a children manager when this shape has children of its own.
+ Reference<drawing::XShapes> xShapes (mxShape, uno::UNO_QUERY);
+ if (xShapes.is() && xShapes->getCount() > 0)
+ mpChildrenManager = new ChildrenManager (
+ this, xShapes, maShapeTreeInfo, *this);
+ if (mpChildrenManager != NULL)
+ mpChildrenManager->Update();
+
+ // Register at model as document::XEventListener.
+ if (maShapeTreeInfo.GetModelBroadcaster().is())
+ maShapeTreeInfo.GetModelBroadcaster()->addEventListener (
+ static_cast<document::XEventListener*>(this));
+
+ // Beware! Here we leave the paths of the UNO API and descend into the
+ // depths of the core. Necessary for makeing the edit engine
+ // accessible.
+ Reference<text::XText> xText (mxShape, uno::UNO_QUERY);
+ if (xText.is())
+ {
+ SdrView* pView = maShapeTreeInfo.GetSdrView ();
+ const Window* pWindow = maShapeTreeInfo.GetWindow ();
+ if (pView != NULL && pWindow != NULL && mxShape.is())
+ {
+ // #107948# Determine whether shape text is empty
+ SdrObject* pSdrObject = GetSdrObjectFromXShape(mxShape);
+ if( pSdrObject )
+ {
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, pSdrObject );
+ OutlinerParaObject* pOutlinerParaObject = NULL;
+
+ if( pTextObj )
+ pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
+
+ bool bOwnParaObj = pOutlinerParaObject != NULL;
+
+ if( !pOutlinerParaObject && pSdrObject )
+ pOutlinerParaObject = pSdrObject->GetOutlinerParaObject();
+
+ // create AccessibleTextHelper to handle this shape's text
+ if( !pOutlinerParaObject )
+ {
+ // empty text -> use proxy edit source to delay creation of EditEngine
+ ::std::auto_ptr<SvxEditSource> pEditSource( new AccessibleEmptyEditSource ( *pSdrObject, *pView, *pWindow) );
+ mpText = new AccessibleTextHelper( pEditSource );
+ }
+ else
+ {
+ // non-empty text -> use full-fledged edit source right away
+ ::std::auto_ptr<SvxEditSource> pEditSource( new SvxTextEditSource ( *pSdrObject, 0, *pView, *pWindow) );
+ mpText = new AccessibleTextHelper( pEditSource );
+ }
+
+ if( bOwnParaObj )
+ delete pOutlinerParaObject;
+
+ mpText->SetEventSource(this);
+ }
+ }
+ }
+}
+
+
+
+
+void AccessibleShape::UpdateStates (void)
+{
+ ::utl::AccessibleStateSetHelper* pStateSet =
+ static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
+ if (pStateSet == NULL)
+ return;
+
+ // Set the opaque state for certain shape types when their fill style is
+ // solid.
+ bool bShapeIsOpaque = false;
+ switch (ShapeTypeHandler::Instance().GetTypeId (mxShape))
+ {
+ case DRAWING_PAGE:
+ case DRAWING_RECTANGLE:
+ case DRAWING_TEXT:
+ {
+ uno::Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
+ if (xSet.is())
+ {
+ try
+ {
+ drawing::FillStyle aFillStyle;
+ bShapeIsOpaque = ( xSet->getPropertyValue (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FillStyle"))) >>= aFillStyle)
+ && aFillStyle == drawing::FillStyle_SOLID;
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException&)
+ {
+ // Ignore.
+ }
+ }
+ }
+ }
+ if (bShapeIsOpaque)
+ pStateSet->AddState (AccessibleStateType::OPAQUE);
+ else
+ pStateSet->RemoveState (AccessibleStateType::OPAQUE);
+
+ // Set the selected state.
+ bool bShapeIsSelected = false;
+ // XXX fix_me this has to be done with an extra interface later on
+ if ( m_pShape && maShapeTreeInfo.GetSdrView() )
+ {
+ bShapeIsSelected = maShapeTreeInfo.GetSdrView()->IsObjMarked(m_pShape) == TRUE;
+ }
+
+ if (bShapeIsSelected)
+ pStateSet->AddState (AccessibleStateType::SELECTED);
+ else
+ pStateSet->RemoveState (AccessibleStateType::SELECTED);
+}
+
+
+
+
+bool AccessibleShape::operator== (const AccessibleShape& rShape)
+{
+ return this==&rShape;
+}
+
+
+
+
+sal_Bool AccessibleShape::SetState (sal_Int16 aState)
+{
+ sal_Bool bStateHasChanged = sal_False;
+
+ if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
+ {
+ // Offer FOCUSED state to edit engine and detect whether the state
+ // changes.
+ sal_Bool bIsFocused = mpText->HaveFocus ();
+ mpText->SetFocus (sal_True);
+ bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
+ }
+ else
+ bStateHasChanged = AccessibleContextBase::SetState (aState);
+
+ return bStateHasChanged;
+}
+
+
+
+
+sal_Bool AccessibleShape::ResetState (sal_Int16 aState)
+{
+ sal_Bool bStateHasChanged = sal_False;
+
+ if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
+ {
+ // Try to remove FOCUSED state from the edit engine and detect
+ // whether the state changes.
+ sal_Bool bIsFocused = mpText->HaveFocus ();
+ mpText->SetFocus (sal_False);
+ bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
+ }
+ else
+ bStateHasChanged = AccessibleContextBase::ResetState (aState);
+
+ return bStateHasChanged;
+}
+
+
+
+
+sal_Bool AccessibleShape::GetState (sal_Int16 aState)
+{
+ if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
+ {
+ // Just delegate the call to the edit engine. The state is not
+ // merged into the state set.
+ return mpText->HaveFocus();
+ }
+ else
+ return AccessibleContextBase::GetState (aState);
+}
+
+
+
+
+//===== XAccessibleContext ==================================================
+
+/** The children of this shape come from two sources: The children from
+ group or scene shapes and the paragraphs of text.
+*/
+sal_Int32 SAL_CALL
+ AccessibleShape::getAccessibleChildCount ()
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+ sal_Int32 nChildCount = 0;
+
+ // Add the number of shapes that are children of this shape.
+ if (mpChildrenManager != NULL)
+ nChildCount += mpChildrenManager->GetChildCount ();
+ // Add the number text paragraphs.
+ if (mpText != NULL)
+ nChildCount += mpText->GetChildCount ();
+
+ return nChildCount;
+}
+
+
+
+
+/** Forward the request to the shape. Return the requested shape or throw
+ an exception for a wrong index.
+*/
+uno::Reference<XAccessible> SAL_CALL
+ AccessibleShape::getAccessibleChild (sal_Int32 nIndex)
+ throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+
+ uno::Reference<XAccessible> xChild;
+
+ // Depending on the index decide whether to delegate this call to the
+ // children manager or the edit engine.
+ if ((mpChildrenManager != NULL)
+ && (nIndex < mpChildrenManager->GetChildCount()))
+ {
+ xChild = mpChildrenManager->GetChild (nIndex);
+ }
+ else if (mpText != NULL)
+ {
+ sal_Int32 nI = nIndex;
+ if (mpChildrenManager != NULL)
+ nI -= mpChildrenManager->GetChildCount();
+ xChild = mpText->GetChild (nI);
+ }
+ else
+ throw lang::IndexOutOfBoundsException (
+ ::rtl::OUString::createFromAscii ("shape has no child with index ")
+ + rtl::OUString::valueOf(nIndex),
+ static_cast<uno::XWeak*>(this));
+
+ return xChild;
+}
+
+
+
+
+/** Return a copy of the state set.
+ Possible states are:
+ ENABLED
+ SHOWING
+ VISIBLE
+*/
+uno::Reference<XAccessibleStateSet> SAL_CALL
+ AccessibleShape::getAccessibleStateSet (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+ Reference<XAccessibleStateSet> xStateSet;
+
+ if (rBHelper.bDisposed || mpText == NULL)
+ // Return a minimal state set that only contains the DEFUNC state.
+ xStateSet = AccessibleContextBase::getAccessibleStateSet ();
+ else
+ {
+ ::utl::AccessibleStateSetHelper* pStateSet =
+ static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
+
+ if (pStateSet != NULL)
+ {
+ // Merge current FOCUSED state from edit engine.
+ if (mpText != NULL)
+ {
+ if (mpText->HaveFocus())
+ pStateSet->AddState (AccessibleStateType::FOCUSED);
+ else
+ pStateSet->RemoveState (AccessibleStateType::FOCUSED);
+ }
+
+ // Create a copy of the state set that may be modified by the
+ // caller without affecting the current state set.
+ xStateSet = Reference<XAccessibleStateSet>(
+ new ::utl::AccessibleStateSetHelper (*pStateSet));
+ }
+ }
+
+ return xStateSet;
+}
+
+
+
+
+//===== XAccessibleComponent ================================================
+
+/** The implementation below is at the moment straightforward. It iterates
+ over all children (and thereby instances all children which have not
+ been already instatiated) until a child covering the specifed point is
+ found.
+ This leaves room for improvement. For instance, first iterate only over
+ the already instantiated children and only if no match is found
+ instantiate the remaining ones.
+*/
+uno::Reference<XAccessible > SAL_CALL
+ AccessibleShape::getAccessibleAtPoint (
+ const awt::Point& aPoint)
+ throw (uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ sal_Int32 nChildCount = getAccessibleChildCount ();
+ for (sal_Int32 i=0; i<nChildCount; ++i)
+ {
+ Reference<XAccessible> xChild (getAccessibleChild (i));
+ if (xChild.is())
+ {
+ Reference<XAccessibleComponent> xChildComponent (
+ xChild->getAccessibleContext(), uno::UNO_QUERY);
+ if (xChildComponent.is())
+ {
+ awt::Rectangle aBBox (xChildComponent->getBounds());
+ if ( (aPoint.X >= aBBox.X)
+ && (aPoint.Y >= aBBox.Y)
+ && (aPoint.X < aBBox.X+aBBox.Width)
+ && (aPoint.Y < aBBox.Y+aBBox.Height) )
+ return xChild;
+ }
+ }
+ }
+
+ // Have not found a child under the given point. Returning empty
+ // reference to indicate this.
+ return uno::Reference<XAccessible>();
+}
+
+
+
+
+awt::Rectangle SAL_CALL AccessibleShape::getBounds (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard (maMutex);
+
+ ThrowIfDisposed ();
+ awt::Rectangle aBoundingBox;
+ if ( mxShape.is() )
+ {
+
+ static const OUString sBoundRectName (
+ RTL_CONSTASCII_USTRINGPARAM("BoundRect"));
+ static const OUString sAnchorPositionName (
+ RTL_CONSTASCII_USTRINGPARAM("AnchorPosition"));
+
+ // Get the shape's bounding box in internal coordinates (in 100th of
+ // mm). Use the property BoundRect. Only if that is not supported ask
+ // the shape for its position and size directly.
+ Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
+ Reference<beans::XPropertySetInfo> xSetInfo;
+ bool bFoundBoundRect = false;
+ if (xSet.is())
+ {
+ xSetInfo = xSet->getPropertySetInfo ();
+ if (xSetInfo.is())
+ {
+ if (xSetInfo->hasPropertyByName (sBoundRectName))
+ {
+ try
+ {
+ uno::Any aValue = xSet->getPropertyValue (sBoundRectName);
+ aValue >>= aBoundingBox;
+ bFoundBoundRect = true;
+ }
+ catch (beans::UnknownPropertyException e)
+ {
+ // Handled below (bFoundBoundRect stays false).
+ }
+ }
+ else
+ OSL_TRACE (" no property BoundRect");
+ }
+ }
+
+ // Fallback when there is no BoundRect Property.
+ if ( ! bFoundBoundRect )
+ {
+ awt::Point aPosition (mxShape->getPosition());
+ awt::Size aSize (mxShape->getSize());
+ aBoundingBox = awt::Rectangle (
+ aPosition.X, aPosition.Y,
+ aSize.Width, aSize.Height);
+
+ // While BoundRects have absolute positions, the position returned
+ // by XPosition::getPosition is relative. Get the anchor position
+ // (usually not (0,0) for Writer shapes).
+ if (xSetInfo.is())
+ {
+ if (xSetInfo->hasPropertyByName (sAnchorPositionName))
+ {
+ uno::Any aPos = xSet->getPropertyValue (sAnchorPositionName);
+ awt::Point aAnchorPosition;
+ aPos >>= aAnchorPosition;
+ aBoundingBox.X += aAnchorPosition.X;
+ aBoundingBox.Y += aAnchorPosition.Y;
+ }
+ }
+ }
+
+ // Transform coordinates from internal to pixel.
+ if (maShapeTreeInfo.GetViewForwarder() == NULL)
+ throw uno::RuntimeException (::rtl::OUString (
+ RTL_CONSTASCII_USTRINGPARAM(
+ "AccessibleShape has no valid view forwarder")),
+ static_cast<uno::XWeak*>(this));
+ ::Size aPixelSize = maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
+ ::Size (aBoundingBox.Width, aBoundingBox.Height));
+ ::Point aPixelPosition = maShapeTreeInfo.GetViewForwarder()->LogicToPixel (
+ ::Point (aBoundingBox.X, aBoundingBox.Y));
+
+ // Clip the shape's bounding box with the bounding box of its parent.
+ Reference<XAccessibleComponent> xParentComponent (
+ getAccessibleParent(), uno::UNO_QUERY);
+ if (xParentComponent.is())
+ {
+ // Make the coordinates relative to the parent.
+ awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
+ int x = aPixelPosition.getX() - aParentLocation.X;
+ int y = aPixelPosition.getY() - aParentLocation.Y;
+
+ /* // The following block is a workarround for bug #99889# (property
+ // BoundRect returnes coordinates relative to document window
+ // instead of absolute coordinates for shapes in Writer). Has to
+ // be removed as soon as bug is fixed.
+
+ // Use a non-null anchor position as flag that the shape is in a
+ // Writer document.
+ if (xSetInfo.is())
+ if (xSetInfo->hasPropertyByName (sAnchorPositionName))
+ {
+ uno::Any aPos = xSet->getPropertyValue (sAnchorPositionName);
+ awt::Point aAnchorPosition;
+ aPos >>= aAnchorPosition;
+ if (aAnchorPosition.X > 0)
+ {
+ x = aPixelPosition.getX();
+ y = aPixelPosition.getY();
+ }
+ }
+ // End of workarround.
+ */
+ // Clip with parent (with coordinates relative to itself).
+ ::Rectangle aBBox (
+ x, y, x + aPixelSize.getWidth(), y + aPixelSize.getHeight());
+ awt::Size aParentSize (xParentComponent->getSize());
+ ::Rectangle aParentBBox (0,0, aParentSize.Width, aParentSize.Height);
+ aBBox = aBBox.GetIntersection (aParentBBox);
+ aBoundingBox = awt::Rectangle (
+ aBBox.getX(),
+ aBBox.getY(),
+ aBBox.getWidth(),
+ aBBox.getHeight());
+ }
+ else
+ {
+ OSL_TRACE ("parent does not support component");
+ aBoundingBox = awt::Rectangle (
+ aPixelPosition.getX(), aPixelPosition.getY(),
+ aPixelSize.getWidth(), aPixelSize.getHeight());
+ }
+ }
+
+ return aBoundingBox;
+}
+
+
+
+
+awt::Point SAL_CALL AccessibleShape::getLocation (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+ awt::Rectangle aBoundingBox (getBounds());
+ return awt::Point (aBoundingBox.X, aBoundingBox.Y);
+}
+
+
+
+
+awt::Point SAL_CALL AccessibleShape::getLocationOnScreen (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+
+ // Get relative position...
+ awt::Point aLocation (getLocation ());
+
+ // ... and add absolute position of the parent.
+ uno::Reference<XAccessibleComponent> xParentComponent (
+ getAccessibleParent(), uno::UNO_QUERY);
+ if (xParentComponent.is())
+ {
+ awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
+ aLocation.X += aParentLocation.X;
+ aLocation.Y += aParentLocation.Y;
+ }
+ else
+ OSL_TRACE ("getLocation: parent does not support XAccessibleComponent");
+ return aLocation;
+}
+
+
+
+
+awt::Size SAL_CALL AccessibleShape::getSize (void)
+ throw (uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+ awt::Rectangle aBoundingBox (getBounds());
+ return awt::Size (aBoundingBox.Width, aBoundingBox.Height);
+}
+
+
+
+
+sal_Int32 SAL_CALL AccessibleShape::getForeground (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+ sal_Int32 nColor (0x0ffffffL);
+
+ try
+ {
+ uno::Reference<beans::XPropertySet> aSet (mxShape, uno::UNO_QUERY);
+ if (aSet.is())
+ {
+ uno::Any aColor;
+ aColor = aSet->getPropertyValue (OUString::createFromAscii ("LineColor"));
+ aColor >>= nColor;
+ }
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException)
+ {
+ // Ignore exception and return default color.
+ }
+ return nColor;
+}
+
+
+
+
+sal_Int32 SAL_CALL AccessibleShape::getBackground (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+ sal_Int32 nColor (0L);
+
+ try
+ {
+ uno::Reference<beans::XPropertySet> aSet (mxShape, uno::UNO_QUERY);
+ if (aSet.is())
+ {
+ uno::Any aColor;
+ aColor = aSet->getPropertyValue (OUString::createFromAscii ("FillColor"));
+ aColor >>= nColor;
+ }
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException)
+ {
+ // Ignore exception and return default color.
+ }
+ return nColor;
+}
+
+
+
+
+//===== XAccessibleEventBroadcaster =========================================
+
+void SAL_CALL AccessibleShape::addEventListener (
+ const Reference<XAccessibleEventListener >& rxListener)
+ throw (uno::RuntimeException)
+{
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ {
+ uno::Reference<uno::XInterface> xThis (
+ (lang::XComponent *)this, uno::UNO_QUERY);
+ rxListener->disposing (lang::EventObject (xThis));
+ }
+ else
+ {
+ AccessibleContextBase::addEventListener (rxListener);
+ if (mpText != NULL)
+ mpText->AddEventListener (rxListener);
+ }
+}
+
+
+
+
+void SAL_CALL AccessibleShape::removeEventListener (
+ const Reference<XAccessibleEventListener >& rxListener)
+ throw (uno::RuntimeException)
+{
+ AccessibleContextBase::removeEventListener (rxListener);
+ if (mpText != NULL)
+ mpText->RemoveEventListener (rxListener);
+}
+
+
+
+
+//===== XInterface ==========================================================
+
+com::sun::star::uno::Any SAL_CALL
+ AccessibleShape::queryInterface (const com::sun::star::uno::Type & rType)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Any aReturn = AccessibleContextBase::queryInterface (rType);
+ if ( ! aReturn.hasValue())
+ aReturn = ::cppu::queryInterface (rType,
+ static_cast<XAccessibleComponent*>(this),
+ static_cast<XAccessibleExtendedComponent*>(this),
+ static_cast<lang::XEventListener*>(this),
+ static_cast<document::XEventListener*>(this),
+ static_cast<lang::XUnoTunnel*>(this)
+ );
+ return aReturn;
+}
+
+
+
+
+void SAL_CALL
+ AccessibleShape::acquire (void)
+ throw ()
+{
+ AccessibleContextBase::acquire ();
+}
+
+
+
+
+void SAL_CALL
+ AccessibleShape::release (void)
+ throw ()
+{
+ AccessibleContextBase::release ();
+}
+
+
+
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString SAL_CALL
+ AccessibleShape::getImplementationName (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleShape"));
+}
+
+
+
+
+uno::Sequence<OUString> SAL_CALL
+ AccessibleShape::getSupportedServiceNames (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+ // Get list of supported service names from base class...
+ uno::Sequence<OUString> aServiceNames =
+ AccessibleContextBase::getSupportedServiceNames();
+ sal_Int32 nCount (aServiceNames.getLength());
+
+ // ...and add additional names.
+ aServiceNames.realloc (nCount + 1);
+ static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.drawing.AccessibleShape"));
+ aServiceNames[nCount] = sAdditionalServiceName;
+
+ return aServiceNames;
+}
+
+
+
+
+
+//===== XTypeProvider ===================================================
+
+uno::Sequence<uno::Type> SAL_CALL
+ AccessibleShape::getTypes (void)
+ throw (uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+ // Get list of types from the context base implementation, ...
+ uno::Sequence<uno::Type> aTypeList (AccessibleContextBase::getTypes());
+ // ... get list of types from component base implementation, ...
+ uno::Sequence<uno::Type> aComponentTypeList (AccessibleComponentBase::getTypes());
+ // ... define local types, ...
+ const uno::Type aLangEventListenerType =
+ ::getCppuType((const uno::Reference<lang::XEventListener>*)0);
+ const uno::Type aDocumentEventListenerType =
+ ::getCppuType((const uno::Reference<document::XEventListener>*)0);
+ const uno::Type aUnoTunnelType =
+ ::getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
+ // const uno::Type aStateSetType =
+ // ::getCppuType((const uno::Reference<XAccessibleStateSet>*)0);
+
+ // ... and merge them all into one list.
+ sal_Int32 nTypeCount (aTypeList.getLength()),
+ nComponentTypeCount (aComponentTypeList.getLength());
+ int i;
+
+ aTypeList.realloc (nTypeCount + nComponentTypeCount + 3);
+
+ for (i=0; i<nComponentTypeCount; i++)
+ aTypeList[nTypeCount + i] = aComponentTypeList[i];
+
+ aTypeList[nTypeCount + i++ ] = aLangEventListenerType;
+ aTypeList[nTypeCount + i++ ] = aDocumentEventListenerType;
+ aTypeList[nTypeCount + i ] = aUnoTunnelType;
+
+ return aTypeList;
+}
+
+
+
+
+//===== lang::XEventListener ================================================
+
+/** Disposing calls are accepted only from the model: Just reset the
+ reference to the model in the shape tree info. Otherwise this object
+ remains functional.
+*/
+void SAL_CALL
+ AccessibleShape::disposing (const lang::EventObject& aEvent)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard (maMutex);
+
+ try
+ {
+ if (aEvent.Source == maShapeTreeInfo.GetModelBroadcaster())
+ {
+ // Remove reference to model broadcaster to allow it to pass
+ // away.
+ maShapeTreeInfo.SetModelBroadcaster(NULL);
+ }
+
+ }
+ catch (uno::RuntimeException e)
+ {
+ OSL_TRACE ("caught exception while disposing");
+ }
+}
+
+
+
+
+//===== document::XEventListener ============================================
+
+void SAL_CALL
+ AccessibleShape::notifyEvent (const document::EventObject& rEventObject)
+ throw (uno::RuntimeException)
+{
+ static const OUString sShapeModified (
+ RTL_CONSTASCII_USTRINGPARAM("ShapeModified"));
+
+ // First check if the event is for us.
+ uno::Reference<drawing::XShape> xShape (
+ rEventObject.Source, uno::UNO_QUERY);
+ if ( xShape.get() == mxShape.get() )
+ {
+ if (rEventObject.EventName.equals (sShapeModified))
+ {
+ // Some property of a shape has been modified. Send an event
+ // that indicates a change of the visible data to all listeners.
+ CommitChange (
+ AccessibleEventId::VISIBLE_DATA_CHANGED,
+ uno::Any(),
+ uno::Any());
+
+ // Name and Description may have changed. Update the local
+ // values accordingly.
+ UpdateNameAndDescription();
+ }
+ }
+}
+
+
+
+
+//===== lang::XUnoTunnel ================================================
+
+const uno::Sequence< sal_Int8 >&
+ AccessibleShape::getUnoTunnelImplementationId()
+ throw()
+{
+ static uno::Sequence< sal_Int8 >* pSeq = 0;
+
+ if( !pSeq )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*) aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+
+ return( *pSeq );
+}
+
+//------------------------------------------------------------------------------
+AccessibleShape*
+ AccessibleShape::getImplementation( const uno::Reference< uno::XInterface >& rxIFace )
+ throw()
+{
+ uno::Reference< lang::XUnoTunnel > xTunnel( rxIFace, uno::UNO_QUERY );
+ AccessibleShape* pReturn = NULL;
+
+ if( xTunnel.is() )
+ pReturn = reinterpret_cast< AccessibleShape* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) );
+
+ return( pReturn );
+}
+
+//------------------------------------------------------------------------------
+sal_Int64 SAL_CALL
+ AccessibleShape::getSomething( const uno::Sequence< sal_Int8 >& rIdentifier )
+ throw(uno::RuntimeException)
+{
+ sal_Int64 nReturn( 0 );
+
+ if( ( rIdentifier.getLength() == 16 ) && ( 0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), rIdentifier.getConstArray(), 16 ) ) )
+ nReturn = reinterpret_cast< sal_Int64 >( this );
+
+ return( nReturn );
+}
+
+//===== IAccessibleViewForwarderListener ====================================
+
+void AccessibleShape::ViewForwarderChanged (ChangeType aChangeType,
+ const IAccessibleViewForwarder* pViewForwarder)
+{
+ // Inform all listeners that the graphical representation (i.e. size
+ // and/or position) of the shape has changed.
+ CommitChange (AccessibleEventId::VISIBLE_DATA_CHANGED,
+ uno::Any(),
+ uno::Any());
+
+ // Tell children manager of the modified view forwarder.
+ if (mpChildrenManager != NULL)
+ mpChildrenManager->ViewForwarderChanged (aChangeType, pViewForwarder);
+
+ // update our children that our screen position might have changed
+ if( mpText )
+ mpText->UpdateChildren();
+}
+
+
+
+
+//===== protected internal ==================================================
+/// Set this object's name if is different to the current name.
+::rtl::OUString
+ AccessibleShape::CreateAccessibleBaseName (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return ShapeTypeHandler::CreateAccessibleBaseName( mxShape );
+}
+
+
+::rtl::OUString
+ AccessibleShape::CreateAccessibleName (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ OUString sName (CreateAccessibleBaseName());
+
+ // Append the shape's index to the name to disambiguate between shapes
+ // of the same type. If such an index where not given to the
+ // constructor then use the z-order instead. If even that does not exist
+ // we throw an exception.
+ long nIndex = mnIndex;
+ if (nIndex == -1)
+ {
+ try
+ {
+ uno::Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY);
+ if (xSet.is())
+ {
+ uno::Any aZOrder (xSet->getPropertyValue (::rtl::OUString::createFromAscii ("ZOrder")));
+ aZOrder >>= nIndex;
+
+ // Add one to be not zero based.
+ nIndex += 1;
+ }
+ }
+ catch (beans::UnknownPropertyException)
+ {
+ // We throw our own exception that is a bit more informative.
+ throw uno::RuntimeException (::rtl::OUString (
+ RTL_CONSTASCII_USTRINGPARAM("AccessibleShape has invalid index and no ZOrder property")),
+ static_cast<uno::XWeak*>(this));
+ }
+
+ }
+
+ // Put a space between name and index because of Gnopernicus othewise
+ // spells the name.
+ sName += OUString (RTL_CONSTASCII_USTRINGPARAM(" ")) + OUString::valueOf (nIndex);
+
+ return sName;
+}
+
+
+
+
+::rtl::OUString
+ AccessibleShape::CreateAccessibleDescription (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ DescriptionGenerator aDG (mxShape);
+ aDG.Initialize (CreateAccessibleBaseName());
+ switch (ShapeTypeHandler::Instance().GetTypeId (mxShape))
+ {
+ case DRAWING_3D_CUBE:
+ case DRAWING_3D_EXTRUDE:
+ case DRAWING_3D_LATHE:
+ case DRAWING_3D_SPHERE:
+ aDG.Add3DProperties ();
+ break;
+
+ case DRAWING_3D_SCENE:
+ case DRAWING_GROUP:
+ case DRAWING_PAGE:
+ // No further information is appended.
+ break;
+
+ case DRAWING_CAPTION:
+ case DRAWING_CLOSED_BEZIER:
+ case DRAWING_CLOSED_FREEHAND:
+ case DRAWING_ELLIPSE:
+ case DRAWING_POLY_POLYGON:
+ case DRAWING_POLY_POLYGON_PATH:
+ case DRAWING_RECTANGLE:
+ aDG.AddLineProperties ();
+ aDG.AddFillProperties ();
+ break;
+
+ case DRAWING_CONNECTOR:
+ case DRAWING_LINE:
+ case DRAWING_MEASURE:
+ case DRAWING_OPEN_BEZIER:
+ case DRAWING_OPEN_FREEHAND:
+ case DRAWING_POLY_LINE:
+ case DRAWING_POLY_LINE_PATH:
+ aDG.AddLineProperties ();
+ break;
+
+ case DRAWING_CONTROL:
+ aDG.AddProperty (OUString::createFromAscii ("ControlBackground"),
+ DescriptionGenerator::COLOR,
+ OUString());
+ aDG.AddProperty (OUString::createFromAscii ("ControlBorder"),
+ DescriptionGenerator::INTEGER,
+ OUString());
+ break;
+
+ case DRAWING_TEXT:
+ aDG.AddTextProperties ();
+ break;
+
+ default:
+ aDG.Initialize (::rtl::OUString (
+ RTL_CONSTASCII_USTRINGPARAM("Unknown accessible shape")));
+ uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
+ if (xDescriptor.is())
+ {
+ aDG.AppendString (::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("service name=")));
+ aDG.AppendString (xDescriptor->getShapeType());
+ }
+ }
+
+ return aDG();
+}
+
+
+
+
+uno::Reference< drawing::XShape > AccessibleShape::GetXShape()
+{
+ return( mxShape );
+}
+
+
+
+// protected
+void AccessibleShape::disposing (void)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard (maMutex);
+
+ // Make sure to send an event that this object looses the focus in the
+ // case that it has the focus.
+ ::utl::AccessibleStateSetHelper* pStateSet =
+ static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
+ if (pStateSet != NULL)
+ pStateSet->RemoveState (AccessibleStateType::FOCUSED);
+
+ // Unregister from broadcasters.
+ Reference<lang::XComponent> xComponent (mxShape, uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->removeEventListener (this);
+
+ // Unregister from model.
+ if (maShapeTreeInfo.GetModelBroadcaster().is())
+ maShapeTreeInfo.GetModelBroadcaster()->removeEventListener (
+ static_cast<document::XEventListener*>(this));
+
+ // Release the child containers.
+ if (mpChildrenManager != NULL)
+ {
+ delete mpChildrenManager;
+ mpChildrenManager = NULL;
+ }
+ if (mpText != NULL)
+ {
+ mpText->Dispose();
+ delete mpText;
+ mpText = NULL;
+ }
+
+ // Cleanup. Remove references to objects to allow them to be
+ // destroyed.
+ mxShape = NULL;
+ maShapeTreeInfo = AccessibleShapeTreeInfo();
+
+ // Call base classes.
+ AccessibleContextBase::dispose ();
+}
+
+sal_Int32 SAL_CALL
+ AccessibleShape::getAccessibleIndexInParent (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+ // Use a simple but slow solution for now. Optimize later.
+
+ sal_Int32 nIndex = m_nIndexInParent;
+ if ( -1 == nIndex )
+ nIndex = AccessibleContextBase::getAccessibleIndexInParent();
+ return nIndex;
+}
+
+
+
+
+void AccessibleShape::UpdateNameAndDescription (void)
+{
+ // Ignore missing title, name, or description. There are fallbacks for
+ // them.
+ try
+ {
+ Reference<beans::XPropertySet> xSet (mxShape, uno::UNO_QUERY_THROW);
+ OUString sString;
+
+ // Get the accessible name.
+ sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Title")));
+ if (sString.getLength() > 0)
+ {
+ SetAccessibleName(sString, AccessibleContextBase::FromShape);
+ }
+ else
+ {
+ sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Name")));
+ if (sString.getLength() > 0)
+ SetAccessibleName(sString, AccessibleContextBase::FromShape);
+ }
+
+ // Get the accessible description.
+ sString = GetOptionalProperty(xSet, OUString(RTL_CONSTASCII_USTRINGPARAM("Description")));
+ if (sString.getLength() > 0)
+ SetAccessibleDescription(sString, AccessibleContextBase::FromShape);
+ }
+ catch (uno::RuntimeException&)
+ {
+ }
+}
+
+
+
+
+} // end of namespace accessibility
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleShapeInfo.cxx b/svx/source/accessibility/AccessibleShapeInfo.cxx
new file mode 100644
index 000000000000..756a02f145dd
--- /dev/null
+++ b/svx/source/accessibility/AccessibleShapeInfo.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+
+#include <svx/AccessibleShapeInfo.hxx>
+
+
+namespace accessibility {
+
+AccessibleShapeInfo::AccessibleShapeInfo (
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape>& rxShape,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ IAccessibleParent* pChildrenManager,
+ sal_Int32 nIndex)
+ : mxShape (rxShape),
+ mxParent (rxParent),
+ mpChildrenManager (pChildrenManager),
+ mnIndex (nIndex)
+{
+ // empty.
+}
+
+
+
+
+AccessibleShapeInfo::AccessibleShapeInfo (
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape>& rxShape,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ sal_Int32 nIndex)
+ : mxShape (rxShape),
+ mxParent (rxParent),
+ mpChildrenManager (NULL),
+ mnIndex (nIndex)
+{
+ // empty.
+}
+
+AccessibleShapeInfo::AccessibleShapeInfo (const AccessibleShapeInfo &rOther)
+ : mxShape (rOther.mxShape),
+ mxParent (rOther.mxParent),
+ mpChildrenManager (rOther.mpChildrenManager),
+ mnIndex (rOther.mnIndex)
+{
+ // empty.
+}
+
+
+AccessibleShapeInfo::~AccessibleShapeInfo (void)
+{
+ // empty.
+}
+
+} // end of namespace accessibility.
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleShapeTreeInfo.cxx b/svx/source/accessibility/AccessibleShapeTreeInfo.cxx
new file mode 100644
index 000000000000..879f7ed637b4
--- /dev/null
+++ b/svx/source/accessibility/AccessibleShapeTreeInfo.cxx
@@ -0,0 +1,226 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/AccessibleShapeTreeInfo.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+using ::com::sun::star::uno::Reference;
+
+namespace accessibility {
+
+AccessibleShapeTreeInfo::AccessibleShapeTreeInfo (
+ const Reference<XAccessibleComponent>& rxDocumentWindow,
+ const Reference<document::XEventBroadcaster>& rxModelBroadcaster)
+ : mxDocumentWindow (rxDocumentWindow),
+ mxModelBroadcaster (rxModelBroadcaster),
+ mpView (NULL),
+ mpWindow (NULL),
+ mpViewForwarder (NULL)
+{
+ // Empty.
+}
+
+
+
+
+AccessibleShapeTreeInfo::AccessibleShapeTreeInfo (void)
+ : mpView (NULL),
+ mpWindow (NULL),
+ mpViewForwarder (NULL)
+{
+ // Empty.
+}
+
+
+
+
+AccessibleShapeTreeInfo::AccessibleShapeTreeInfo (const AccessibleShapeTreeInfo& rInfo)
+ : mxDocumentWindow (rInfo.mxDocumentWindow),
+ mxModelBroadcaster (rInfo.mxModelBroadcaster),
+ mpView (rInfo.mpView),
+ mxController (rInfo.mxController),
+ mpWindow (rInfo.mpWindow),
+ mpViewForwarder (rInfo.mpViewForwarder)
+{
+ // Empty.
+}
+
+
+
+
+AccessibleShapeTreeInfo& AccessibleShapeTreeInfo::operator= (const AccessibleShapeTreeInfo& rInfo)
+{
+ if ( this != &rInfo )
+ {
+ mxDocumentWindow = rInfo.mxDocumentWindow;
+ mxModelBroadcaster = rInfo.mxModelBroadcaster;
+ mpView = rInfo.mpView;
+ mxController = rInfo.mxController,
+ mpWindow = rInfo.mpWindow;
+ mpViewForwarder = rInfo.mpViewForwarder;
+ }
+ return *this;
+}
+
+
+
+
+AccessibleShapeTreeInfo::~AccessibleShapeTreeInfo (void)
+{
+ //empty
+}
+
+
+
+
+void AccessibleShapeTreeInfo::SetDocumentWindow (
+ const Reference<XAccessibleComponent>& rxDocumentWindow)
+{
+ if (mxDocumentWindow != rxDocumentWindow)
+ mxDocumentWindow = rxDocumentWindow;
+}
+
+
+
+
+uno::Reference<XAccessibleComponent>
+ AccessibleShapeTreeInfo::GetDocumentWindow (void) const
+{
+ return mxDocumentWindow;
+}
+
+
+
+
+void AccessibleShapeTreeInfo::SetControllerBroadcaster (
+ const uno::Reference<document::XEventBroadcaster>& rxControllerBroadcaster)
+{
+ mxModelBroadcaster = rxControllerBroadcaster;
+}
+
+
+
+
+uno::Reference<document::XEventBroadcaster>
+ AccessibleShapeTreeInfo::GetControllerBroadcaster (void) const
+{
+ return mxModelBroadcaster;
+}
+
+
+
+
+void AccessibleShapeTreeInfo::SetModelBroadcaster (
+ const Reference<document::XEventBroadcaster>& rxModelBroadcaster)
+{
+ mxModelBroadcaster = rxModelBroadcaster;
+}
+
+
+
+
+Reference<document::XEventBroadcaster>
+ AccessibleShapeTreeInfo::GetModelBroadcaster (void) const
+{
+ return mxModelBroadcaster;
+}
+
+
+
+
+void AccessibleShapeTreeInfo::SetSdrView (SdrView* pView)
+{
+ mpView = pView;
+}
+
+
+
+
+SdrView* AccessibleShapeTreeInfo::GetSdrView (void) const
+{
+ return mpView;
+}
+
+
+
+
+void AccessibleShapeTreeInfo::SetController (
+ const Reference<frame::XController>& rxController)
+{
+ mxController = rxController;
+}
+
+
+
+
+Reference<frame::XController>
+ AccessibleShapeTreeInfo::GetController (void) const
+{
+ return mxController;
+}
+
+
+
+
+void AccessibleShapeTreeInfo::SetWindow (Window* pWindow)
+{
+ mpWindow = pWindow;
+}
+
+
+
+
+Window* AccessibleShapeTreeInfo::GetWindow (void) const
+{
+ return mpWindow;
+}
+
+
+
+
+void AccessibleShapeTreeInfo::SetViewForwarder (const IAccessibleViewForwarder* pViewForwarder)
+{
+ mpViewForwarder = pViewForwarder;
+}
+
+
+
+
+const IAccessibleViewForwarder* AccessibleShapeTreeInfo::GetViewForwarder (void) const
+{
+ return mpViewForwarder;
+}
+
+
+} // end of namespace accessibility
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleTextEventQueue.cxx b/svx/source/accessibility/AccessibleTextEventQueue.cxx
new file mode 100644
index 000000000000..894c8d004a6a
--- /dev/null
+++ b/svx/source/accessibility/AccessibleTextEventQueue.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "AccessibleTextEventQueue.hxx"
+#include <svx/unoshape.hxx>
+#include "editeng/unolingu.hxx"
+#include <editeng/unotext.hxx>
+
+#include "editeng/unoedhlp.hxx"
+#include "editeng/unopracc.hxx"
+#include <svx/svdmodel.hxx>
+#include <svx/svdpntv.hxx>
+#include <editeng/editdata.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editview.hxx>
+
+namespace accessibility
+{
+ //------------------------------------------------------------------------
+ //
+ // EventQueue implementation
+ //
+ //------------------------------------------------------------------------
+
+ AccessibleTextEventQueue::AccessibleTextEventQueue()
+ {
+ }
+
+ AccessibleTextEventQueue::~AccessibleTextEventQueue()
+ {
+ Clear();
+ }
+
+ void AccessibleTextEventQueue::Append( const SfxHint& rHint )
+ {
+ maEventQueue.push_back( new SfxHint( rHint ) );
+ }
+
+ void AccessibleTextEventQueue::Append( const SdrHint& rHint )
+ {
+ maEventQueue.push_back( new SdrHint( rHint ) );
+ }
+
+ void AccessibleTextEventQueue::Append( const SfxSimpleHint& rHint )
+ {
+ maEventQueue.push_back( new SfxSimpleHint( rHint ) );
+ }
+
+ void AccessibleTextEventQueue::Append( const TextHint& rHint )
+ {
+ maEventQueue.push_back( new TextHint( rHint ) );
+ }
+
+ void AccessibleTextEventQueue::Append( const SvxViewHint& rHint )
+ {
+ maEventQueue.push_back( new SvxViewHint( rHint ) );
+ }
+
+ void AccessibleTextEventQueue::Append( const SvxEditSourceHint& rHint )
+ {
+ maEventQueue.push_back( new SvxEditSourceHint( rHint ) );
+ }
+
+ ::std::auto_ptr< SfxHint > AccessibleTextEventQueue::PopFront()
+ {
+ ::std::auto_ptr< SfxHint > aRes( *(maEventQueue.begin()) );
+ maEventQueue.pop_front();
+ return aRes;
+ }
+
+ bool AccessibleTextEventQueue::IsEmpty() const
+ {
+ return maEventQueue.empty();
+ }
+
+ void AccessibleTextEventQueue::Clear()
+ {
+ // clear queue
+ while( !IsEmpty() )
+ PopFront();
+ }
+
+} // end of namespace accessibility
+
+//------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleTextEventQueue.hxx b/svx/source/accessibility/AccessibleTextEventQueue.hxx
new file mode 100644
index 000000000000..3fab23b06329
--- /dev/null
+++ b/svx/source/accessibility/AccessibleTextEventQueue.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TEXT_CHANGED_QUEUE_HXX
+#define _SVX_TEXT_CHANGED_QUEUE_HXX
+
+#include <memory>
+#include <list>
+#include <algorithm>
+#include <tools/solar.h>
+#include <tools/rtti.hxx>
+
+class SfxHint;
+class SdrHint;
+class SfxSimpleHint;
+class TextHint;
+class SvxViewHint;
+class SvxEditSourceHint;
+
+namespace accessibility
+{
+ /** This class handles the notification events for the
+ AccessibleTextHelper class.
+
+ For various reasons, we cannot process EditEngine events as
+ they arrive, but have to queue and handle them in a batch.
+ */
+ class AccessibleTextEventQueue
+ {
+ public:
+ typedef ::std::list< SfxHint* > EventQueue;
+
+ AccessibleTextEventQueue();
+ ~AccessibleTextEventQueue();
+
+ /// Append event to end of queue
+ void Append( const SfxHint& rHint );
+ /// Append event to end of queue
+ void Append( const SdrHint& rHint );
+ /// Append event to end of queue
+ void Append( const SfxSimpleHint& rHint );
+ /// Append event to end of queue
+ void Append( const TextHint& rHint );
+ /// Append event to end of queue
+ void Append( const SvxViewHint& rHint );
+ /// Append event to end of queue
+ void Append( const SvxEditSourceHint& rHint );
+
+ /** Pop first queue element
+
+ return first queue element, ownership transfers to caller
+ */
+ ::std::auto_ptr< SfxHint > PopFront();
+
+ /** Apply functor to every queue member
+
+ @param rFunctor
+ Functor to apply. Functor receives queue element as
+ parameter: void func( const SfxHint* );
+ */
+ template < typename Functor > void ForEach( Functor& rFunctor ) const
+ {
+ // #109864# Make sure results are put back into rFunctor
+ rFunctor = ::std::for_each( maEventQueue.begin(), maEventQueue.end(), rFunctor );
+ }
+
+ /// Query whether queue is empty
+ bool IsEmpty() const;
+
+ /// Clear event queue
+ void Clear();
+
+ private:
+ EventQueue maEventQueue;
+ };
+
+} // end of namespace accessibility
+
+#endif /* _SVX_TEXT_CHANGED_QUEUE_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx
new file mode 100644
index 000000000000..95d1e61fa85d
--- /dev/null
+++ b/svx/source/accessibility/AccessibleTextHelper.cxx
@@ -0,0 +1,2080 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+//------------------------------------------------------------------------
+//
+// Global header
+//
+//------------------------------------------------------------------------
+
+#include <limits.h>
+#include <memory>
+#include <algorithm>
+#include <deque>
+#include <osl/mutex.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <cppuhelper/weakref.hxx>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <comphelper/accessibleeventnotifier.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <vcl/unohelp.hxx>
+#include <vcl/svapp.hxx>
+
+//------------------------------------------------------------------------
+//
+// Project-local header
+//
+//------------------------------------------------------------------------
+#include "AccessibleTextEventQueue.hxx"
+#include <svx/AccessibleTextHelper.hxx>
+#include <svx/unoshape.hxx>
+#include "editeng/unolingu.hxx"
+#include <editeng/unotext.hxx>
+
+#include "editeng/unoedhlp.hxx"
+#include "editeng/unopracc.hxx"
+#include "editeng/AccessibleParaManager.hxx"
+#include "editeng/AccessibleEditableTextPara.hxx"
+#include <svx/svdmodel.hxx>
+#include <svx/svdpntv.hxx>
+#include <editeng/editdata.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editview.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+namespace accessibility
+{
+
+//------------------------------------------------------------------------
+//
+// AccessibleTextHelper_Impl declaration
+//
+//------------------------------------------------------------------------
+
+ DBG_NAME( AccessibleTextHelper_Impl )
+
+ template < typename first_type, typename second_type >
+ ::std::pair< first_type, second_type > makeSortedPair( first_type first,
+ second_type second )
+ {
+ if( first > second )
+ return ::std::make_pair( second, first );
+ else
+ return ::std::make_pair( first, second );
+ }
+
+ class AccessibleTextHelper_Impl : public SfxListener
+ {
+
+ public:
+ typedef ::std::vector< sal_Int16 > VectorOfStates;
+
+ // receive pointer to our frontend class and view window
+ AccessibleTextHelper_Impl();
+ ~AccessibleTextHelper_Impl();
+
+ // XAccessibleContext child handling methods
+ sal_Int32 SAL_CALL getAccessibleChildCount() SAL_THROW((uno::RuntimeException));
+ uno::Reference< XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException));
+
+ // XAccessibleEventBroadcaster child related methods
+ void SAL_CALL addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) SAL_THROW((uno::RuntimeException));
+ void SAL_CALL removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) SAL_THROW((uno::RuntimeException));
+
+ // XAccessibleComponent child related methods
+ uno::Reference< XAccessible > SAL_CALL getAccessibleAtPoint( const awt::Point& aPoint ) SAL_THROW((uno::RuntimeException));
+
+ SvxEditSourceAdapter& GetEditSource() const SAL_THROW((uno::RuntimeException));
+ void SetEditSource( ::std::auto_ptr< SvxEditSource > pEditSource ) SAL_THROW((uno::RuntimeException));
+
+ void SetEventSource( const uno::Reference< XAccessible >& rInterface )
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+ mxFrontEnd = rInterface;
+ }
+ uno::Reference< XAccessible > GetEventSource() const
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+ return mxFrontEnd;
+ }
+
+ void SetOffset( const Point& );
+ Point GetOffset() const
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+ ::osl::MutexGuard aGuard( maMutex ); Point aPoint( maOffset );
+ return aPoint;
+ }
+
+ void SetStartIndex( sal_Int32 nOffset );
+ sal_Int32 GetStartIndex() const
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+ // Strictly correct only with locked solar mutex, // but
+ // here we rely on the fact that sal_Int32 access is
+ // atomic
+ return mnStartIndex;
+ }
+
+ void SetAdditionalChildStates( const VectorOfStates& rChildStates );
+ const VectorOfStates& GetAdditionalChildStates() const;
+
+ sal_Bool IsSelected() const;
+
+ void Dispose();
+
+ // do NOT hold object mutex when calling this! Danger of deadlock
+ void FireEvent( const sal_Int16 nEventId, const uno::Any& rNewValue = uno::Any(), const uno::Any& rOldValue = uno::Any() ) const;
+ void FireEvent( const AccessibleEventObject& rEvent ) const;
+
+ void SetFocus( sal_Bool bHaveFocus ) SAL_THROW((::com::sun::star::uno::RuntimeException));
+ sal_Bool HaveFocus() SAL_THROW((::com::sun::star::uno::RuntimeException));
+ void SetChildFocus( sal_Int32 nChild, sal_Bool bHaveFocus ) SAL_THROW((::com::sun::star::uno::RuntimeException));
+ void SetShapeFocus( sal_Bool bHaveFocus ) SAL_THROW((::com::sun::star::uno::RuntimeException));
+ void ChangeChildFocus( sal_Int32 nNewChild ) SAL_THROW((::com::sun::star::uno::RuntimeException));
+
+#ifdef DBG_UTIL
+ void CheckInvariants() const;
+#endif
+
+ // checks all children for visibility, throws away invisible ones
+ void UpdateVisibleChildren( bool bBroadcastEvents=true );
+
+ // check all children for changes in positíon and size
+ void UpdateBoundRect();
+
+ // calls SetSelection on the forwarder and updates maLastSelection
+ // cache.
+ void UpdateSelection();
+
+ private:
+
+ // Process event queue
+ void ProcessQueue();
+
+ // syntactic sugar for FireEvent
+ void GotPropertyEvent( const uno::Any& rNewValue, const sal_Int16 nEventId ) const { FireEvent( nEventId, rNewValue ); }
+ void LostPropertyEvent( const uno::Any& rOldValue, const sal_Int16 nEventId ) const { FireEvent( nEventId, uno::Any(), rOldValue ); }
+
+ // shutdown usage of current edit source on myself and the children.
+ void ShutdownEditSource() SAL_THROW((uno::RuntimeException));
+
+ void ParagraphsMoved( sal_Int32 nFirst, sal_Int32 nMiddle, sal_Int32 nLast );
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ int getNotifierClientId() const { return mnNotifierClientId; }
+
+ // lock solar mutex before
+ SvxTextForwarder& GetTextForwarder() const SAL_THROW((uno::RuntimeException));
+ // lock solar mutex before
+ SvxViewForwarder& GetViewForwarder() const SAL_THROW((uno::RuntimeException));
+ // lock solar mutex before
+ SvxEditViewForwarder& GetEditViewForwarder( sal_Bool bCreate = sal_False ) const SAL_THROW((uno::RuntimeException));
+
+ // are we in edit mode?
+ sal_Bool IsActive() const SAL_THROW((uno::RuntimeException));
+
+ // our frontend class (the one implementing the actual
+ // interface). That's not necessarily the one containing the impl
+ // pointer!
+ uno::Reference< XAccessible > mxFrontEnd;
+
+ // a wrapper for the text forwarders (guarded by solar mutex)
+ mutable SvxEditSourceAdapter maEditSource;
+
+ // store last selection (to correctly report selection changes, guarded by solar mutex)
+ ESelection maLastSelection;
+
+ // cache range of visible children (guarded by solar mutex)
+ sal_Int32 mnFirstVisibleChild;
+ sal_Int32 mnLastVisibleChild;
+
+ // offset to add to all our children (unguarded, relying on
+ // the fact that sal_Int32 access is atomic)
+ sal_Int32 mnStartIndex;
+
+ // the object handling our children (guarded by solar mutex)
+ ::accessibility::AccessibleParaManager maParaManager;
+
+ // number of not-yet-closed event frames (BEGIN/END sequences) (guarded by solar mutex)
+ sal_Int32 maEventOpenFrames;
+
+ // Queued events from Notify() (guarded by solar mutex)
+ AccessibleTextEventQueue maEventQueue;
+
+ // spin lock to prevent notify in notify (guarded by solar mutex)
+ sal_Bool mbInNotify;
+
+ // whether the object or it's children has the focus set (guarded by solar mutex)
+ sal_Bool mbGroupHasFocus;
+
+ // whether we (this object) has the focus set (guarded by solar mutex)
+ sal_Bool mbThisHasFocus;
+
+ mutable ::osl::Mutex maMutex;
+
+ /// our current offset to the containing shape/cell (guarded by maMutex)
+ Point maOffset;
+
+ /// client Id from AccessibleEventNotifier
+ int mnNotifierClientId;
+ };
+
+ //------------------------------------------------------------------------
+ //
+ // AccessibleTextHelper_Impl implementation
+ //
+ //------------------------------------------------------------------------
+
+ AccessibleTextHelper_Impl::AccessibleTextHelper_Impl() :
+ mxFrontEnd( NULL ),
+ maLastSelection( EE_PARA_NOT_FOUND,EE_PARA_NOT_FOUND,EE_PARA_NOT_FOUND,EE_PARA_NOT_FOUND ),
+ mnFirstVisibleChild( -1 ),
+ mnLastVisibleChild( -2 ),
+ mnStartIndex( 0 ),
+ maEventOpenFrames( 0 ),
+ mbInNotify( sal_False ),
+ mbGroupHasFocus( sal_False ),
+ mbThisHasFocus( sal_False ),
+ maOffset(0,0),
+ // well, that's strictly exception safe, though not really
+ // robust. We rely on the fact that this member is constructed
+ // last, and that the constructor body is empty, thus no
+ // chance for exceptions once the Id is fetched. Nevertheless,
+ // normally should employ RAII here...
+ mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient())
+ {
+ DBG_CTOR( AccessibleTextHelper_Impl, NULL );
+
+#ifdef DBG_UTIL
+ OSL_TRACE( "AccessibleTextHelper_Impl received ID: %d", mnNotifierClientId );
+#endif
+ }
+
+ AccessibleTextHelper_Impl::~AccessibleTextHelper_Impl()
+ {
+ DBG_DTOR( AccessibleTextHelper_Impl, NULL );
+
+ SolarMutexGuard aGuard;
+
+ try
+ {
+ // call Dispose here, too, since we've some resources not
+ // automatically freed otherwise
+ Dispose();
+ }
+ catch( const uno::Exception& ) {}
+ }
+
+ SvxTextForwarder& AccessibleTextHelper_Impl::GetTextForwarder() const SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ if( !maEditSource.IsValid() )
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown edit source")), mxFrontEnd);
+
+ SvxTextForwarder* pTextForwarder = maEditSource.GetTextForwarder();
+
+ if( !pTextForwarder )
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch text forwarder, model might be dead")), mxFrontEnd);
+
+ if( pTextForwarder->IsValid() )
+ return *pTextForwarder;
+ else
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text forwarder is invalid, model might be dead")), mxFrontEnd);
+ }
+
+ SvxViewForwarder& AccessibleTextHelper_Impl::GetViewForwarder() const SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ if( !maEditSource.IsValid() )
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown edit source")), mxFrontEnd);
+
+ SvxViewForwarder* pViewForwarder = maEditSource.GetViewForwarder();
+
+ if( !pViewForwarder )
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, model might be dead")), mxFrontEnd);
+
+ if( pViewForwarder->IsValid() )
+ return *pViewForwarder;
+ else
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, model might be dead")), mxFrontEnd);
+ }
+
+ SvxEditViewForwarder& AccessibleTextHelper_Impl::GetEditViewForwarder( sal_Bool bCreate ) const SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ if( !maEditSource.IsValid() )
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown edit source")), mxFrontEnd);
+
+ SvxEditViewForwarder* pViewForwarder = maEditSource.GetEditViewForwarder( bCreate );
+
+ if( !pViewForwarder )
+ {
+ if( bCreate )
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch edit view forwarder, model might be dead")), mxFrontEnd);
+ else
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No edit view forwarder, object not in edit mode")), mxFrontEnd);
+ }
+
+ if( pViewForwarder->IsValid() )
+ return *pViewForwarder;
+ else
+ {
+ if( bCreate )
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, model might be dead")), mxFrontEnd);
+ else
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object not in edit mode")), mxFrontEnd);
+ }
+ }
+
+ SvxEditSourceAdapter& AccessibleTextHelper_Impl::GetEditSource() const SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ if( maEditSource.IsValid() )
+ return maEditSource;
+ else
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleTextHelper_Impl::GetEditSource: no edit source")), mxFrontEnd );
+ }
+
+ sal_Bool AccessibleTextHelper_Impl::IsSelected() const
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ sal_Bool bRet = sal_False;
+
+ try
+ {
+ ESelection aSelection;
+ bRet = GetEditViewForwarder().GetSelection( aSelection );
+ }
+ catch( const uno::Exception& ) {}
+
+ return bRet;
+ }
+
+ // functor for sending child events (no stand-alone function, they are maybe not inlined)
+ class AccessibleTextHelper_OffsetChildIndex : public ::std::unary_function< ::accessibility::AccessibleEditableTextPara&, void >
+ {
+ public:
+ AccessibleTextHelper_OffsetChildIndex( sal_Int32 nDifference ) : mnDifference(nDifference) {}
+ void operator()( ::accessibility::AccessibleEditableTextPara& rPara )
+ {
+ rPara.SetIndexInParent( rPara.GetIndexInParent() + mnDifference );
+ }
+
+ private:
+ const sal_Int32 mnDifference;
+ };
+
+ void AccessibleTextHelper_Impl::SetStartIndex( sal_Int32 nOffset )
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ sal_Int32 nOldOffset( mnStartIndex );
+
+ mnStartIndex = nOffset;
+
+ if( nOldOffset != nOffset )
+ {
+ // update children
+ AccessibleTextHelper_OffsetChildIndex aFunctor( nOffset - nOldOffset );
+
+ ::std::for_each( maParaManager.begin(), maParaManager.end(),
+ AccessibleParaManager::WeakChildAdapter< AccessibleTextHelper_OffsetChildIndex > (aFunctor) );
+ }
+ }
+
+ void AccessibleTextHelper_Impl::SetAdditionalChildStates( const VectorOfStates& rChildStates )
+ {
+ maParaManager.SetAdditionalChildStates( rChildStates );
+ }
+
+ const AccessibleTextHelper_Impl::VectorOfStates& AccessibleTextHelper_Impl::GetAdditionalChildStates() const
+ {
+ return maParaManager.GetAdditionalChildStates();
+ }
+
+ void AccessibleTextHelper_Impl::SetChildFocus( sal_Int32 nChild, sal_Bool bHaveFocus ) SAL_THROW((::com::sun::star::uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ if( bHaveFocus )
+ {
+ if( mbThisHasFocus )
+ SetShapeFocus( sal_False );
+
+ maParaManager.SetFocus( nChild );
+
+ // we just received the focus, also send caret event then
+ UpdateSelection();
+
+ DBG_TRACE1("AccessibleTextHelper_Impl::SetChildFocus(): Paragraph %d received focus", nChild );
+ }
+ else
+ {
+ maParaManager.SetFocus( -1 );
+
+ DBG_TRACE1("AccessibleTextHelper_Impl::SetChildFocus(): Paragraph %d lost focus", nChild );
+
+ if( mbGroupHasFocus )
+ SetShapeFocus( sal_True );
+ }
+ }
+
+ void AccessibleTextHelper_Impl::ChangeChildFocus( sal_Int32 nNewChild ) SAL_THROW((::com::sun::star::uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ if( mbThisHasFocus )
+ SetShapeFocus( sal_False );
+
+ mbGroupHasFocus = sal_True;
+ maParaManager.SetFocus( nNewChild );
+
+ DBG_TRACE1("AccessibleTextHelper_Impl::ChangeChildFocus(): Paragraph %d received focus", nNewChild );
+ }
+
+ void AccessibleTextHelper_Impl::SetShapeFocus( sal_Bool bHaveFocus ) SAL_THROW((::com::sun::star::uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ sal_Bool bOldFocus( mbThisHasFocus );
+
+ mbThisHasFocus = bHaveFocus;
+
+ if( bOldFocus != bHaveFocus )
+ {
+ if( bHaveFocus )
+ {
+ GotPropertyEvent( uno::makeAny(AccessibleStateType::FOCUSED), AccessibleEventId::STATE_CHANGED );
+ DBG_TRACE("AccessibleTextHelper_Impl::SetShapeFocus(): Parent object received focus" );
+ }
+ else
+ {
+ LostPropertyEvent( uno::makeAny(AccessibleStateType::FOCUSED), AccessibleEventId::STATE_CHANGED );
+ DBG_TRACE("AccessibleTextHelper_Impl::SetShapeFocus(): Parent object lost focus" );
+ }
+ }
+ }
+
+ void AccessibleTextHelper_Impl::SetFocus( sal_Bool bHaveFocus ) SAL_THROW((::com::sun::star::uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ sal_Bool bOldFocus( mbGroupHasFocus );
+
+ mbGroupHasFocus = bHaveFocus;
+
+ if( IsActive() )
+ {
+ try
+ {
+ // find the one with the cursor and get/set focus accordingly
+ ESelection aSelection;
+ if( GetEditViewForwarder().GetSelection( aSelection ) )
+ SetChildFocus( aSelection.nEndPara, bHaveFocus );
+ }
+ catch( const uno::Exception& ) {}
+ }
+ else if( bOldFocus != bHaveFocus )
+ {
+ SetShapeFocus( bHaveFocus );
+ }
+
+ DBG_TRACE2("AccessibleTextHelper_Impl::SetFocus: focus changed, Object %d, state: %s", this, bHaveFocus ? "focused" : "not focused");
+ }
+
+ sal_Bool AccessibleTextHelper_Impl::HaveFocus() SAL_THROW((::com::sun::star::uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ // No locking of solar mutex here, since we rely on the fact
+ // that sal_Bool access is atomic
+ return mbThisHasFocus;
+ }
+
+ sal_Bool AccessibleTextHelper_Impl::IsActive() const SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ try
+ {
+ SvxEditSource& rEditSource = GetEditSource();
+ SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder();
+
+ if( !pViewForwarder )
+ return sal_False;
+
+ if( pViewForwarder->IsValid() )
+ return sal_True;
+ else
+ return sal_False;
+ }
+ catch( const uno::RuntimeException& )
+ {
+ return sal_False;
+ }
+ }
+
+ void AccessibleTextHelper_Impl::UpdateSelection()
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ try
+ {
+ ESelection aSelection;
+ if( GetEditViewForwarder().GetSelection( aSelection ) )
+ {
+ if( !maLastSelection.IsEqual( aSelection ) &&
+ aSelection.nEndPara < maParaManager.GetNum() )
+ {
+ // #103998# Not that important, changed from assertion to trace
+ if( mbThisHasFocus )
+ {
+ DBG_TRACE("AccessibleTextHelper_Impl::UpdateSelection(): Parent has focus!");
+ }
+
+ USHORT nMaxValidParaIndex( static_cast< USHORT >( GetTextForwarder().GetParagraphCount() ) - 1 );
+
+ // notify all affected paragraphs (TODO: may be suboptimal,
+ // since some paragraphs might stay selected)
+ if( maLastSelection.nStartPara != EE_PARA_NOT_FOUND )
+ {
+ // Did the caret move from one paragraph to another?
+ // #100530# no caret events if not focused.
+ if( mbGroupHasFocus &&
+ maLastSelection.nEndPara != aSelection.nEndPara )
+ {
+ if( maLastSelection.nEndPara < maParaManager.GetNum() )
+ {
+ maParaManager.FireEvent( ::std::min( maLastSelection.nEndPara, nMaxValidParaIndex ),
+ ::std::min( maLastSelection.nEndPara, nMaxValidParaIndex )+1,
+ AccessibleEventId::CARET_CHANGED,
+ uno::makeAny(static_cast<sal_Int32>(-1)),
+ uno::makeAny(static_cast<sal_Int32>(maLastSelection.nEndPos)) );
+ }
+
+ ChangeChildFocus( aSelection.nEndPara );
+
+ DBG_TRACE3("AccessibleTextHelper_Impl::UpdateSelection(): focus changed, Object: %d, Paragraph: %d, Last paragraph: %d",
+ this, aSelection.nEndPara, maLastSelection.nEndPara);
+ }
+ }
+
+ // #100530# no caret events if not focused.
+ if( mbGroupHasFocus )
+ {
+ uno::Any aOldCursor;
+
+ // #i13705# The old cursor can only contain valid
+ // values if it's the same paragraph!
+ if( maLastSelection.nStartPara != EE_PARA_NOT_FOUND &&
+ maLastSelection.nEndPara == aSelection.nEndPara )
+ {
+ aOldCursor <<= static_cast<sal_Int32>(maLastSelection.nEndPos);
+ }
+ else
+ {
+ aOldCursor <<= static_cast<sal_Int32>(-1);
+ }
+
+ maParaManager.FireEvent( aSelection.nEndPara,
+ aSelection.nEndPara+1,
+ AccessibleEventId::CARET_CHANGED,
+ uno::makeAny(static_cast<sal_Int32>(aSelection.nEndPos)),
+ aOldCursor );
+ }
+
+ DBG_TRACE5("AccessibleTextHelper_Impl::UpdateSelection(): caret changed, Object: %d, New pos: %d, Old pos: %d, New para: %d, Old para: %d",
+ this, aSelection.nEndPos, maLastSelection.nEndPos, aSelection.nEndPara, maLastSelection.nEndPara);
+
+ // #108947# Sort new range before calling FireEvent
+ ::std::pair< xub_StrLen, xub_StrLen > sortedSelection(
+ makeSortedPair(::std::min( aSelection.nStartPara, nMaxValidParaIndex ),
+ ::std::min( aSelection.nEndPara, nMaxValidParaIndex ) ) );
+
+ // #108947# Sort last range before calling FireEvent
+ ::std::pair< xub_StrLen, xub_StrLen > sortedLastSelection(
+ makeSortedPair(::std::min( maLastSelection.nStartPara, nMaxValidParaIndex ),
+ ::std::min( maLastSelection.nEndPara, nMaxValidParaIndex ) ) );
+
+ // --> OD 2005-12-15 #i27299#
+ // event TEXT_SELECTION_CHANGED has to be submitted.
+ const sal_Int16 nTextSelChgEventId =
+ AccessibleEventId::TEXT_SELECTION_CHANGED;
+ // <--
+ // #107037# notify selection change
+ if( maLastSelection.nStartPara == EE_PARA_NOT_FOUND )
+ {
+ // last selection is undefined
+ // --> OD 2005-12-15 #i27299# - use method <ESelection::HasRange()>
+ if ( aSelection.HasRange() )
+ // <--
+ {
+ // selection was undefined, now is on
+ maParaManager.FireEvent( sortedSelection.first,
+ sortedSelection.second+1,
+ nTextSelChgEventId );
+ }
+ }
+ else
+ {
+ // last selection is valid
+ // --> OD 2005-12-15 #i27299# - use method <ESelection::HasRange()>
+ if ( maLastSelection.HasRange() &&
+ !aSelection.HasRange() )
+ // <--
+ {
+ // selection was on, now is empty
+ maParaManager.FireEvent( sortedLastSelection.first,
+ sortedLastSelection.second+1,
+ nTextSelChgEventId );
+ }
+ // --> OD 2005-12-15 #i27299# - use method <ESelection::HasRange()>
+ else if( !maLastSelection.HasRange() &&
+ aSelection.HasRange() )
+ // <--
+ {
+ // selection was empty, now is on
+ maParaManager.FireEvent( sortedSelection.first,
+ sortedSelection.second+1,
+ nTextSelChgEventId );
+ }
+ // --> OD 2005-12-15 #i27299#
+ // - no event TEXT_SELECTION_CHANGED event, if new and
+ // last selection are empty.
+ else if ( maLastSelection.HasRange() &&
+ aSelection.HasRange() )
+ // <--
+ {
+ // --> OD 2005-12-16 #i27299#
+ // - send event TEXT_SELECTION_CHANGED for difference
+ // between last and new selection.
+// // selection was on, now is different: take union of ranges
+// maParaManager.FireEvent( ::std::min(sortedSelection.first,
+// sortedLastSelection.second),
+// ::std::max(sortedSelection.first,
+// sortedLastSelection.second)+1,
+// nTextSelChgEventId );
+ // use sorted last and new selection
+ ESelection aTmpLastSel( maLastSelection );
+ aTmpLastSel.Adjust();
+ ESelection aTmpSel( aSelection );
+ aTmpSel.Adjust();
+ // first submit event for new and changed selection
+ sal_uInt32 nPara = aTmpSel.nStartPara;
+ for ( ; nPara <= aTmpSel.nEndPara; ++nPara )
+ {
+ if ( nPara < aTmpLastSel.nStartPara ||
+ nPara > aTmpLastSel.nEndPara )
+ {
+ // new selection on paragraph <nPara>
+ maParaManager.FireEvent( nPara,
+ nTextSelChgEventId );
+ }
+ else
+ {
+ // check for changed selection on paragraph <nPara>
+ const xub_StrLen nParaStartPos =
+ nPara == aTmpSel.nStartPara
+ ? aTmpSel.nStartPos : 0;
+ const xub_StrLen nParaEndPos =
+ nPara == aTmpSel.nEndPara
+ ? aTmpSel.nEndPos : STRING_LEN;
+ const xub_StrLen nLastParaStartPos =
+ nPara == aTmpLastSel.nStartPara
+ ? aTmpLastSel.nStartPos : 0;
+ const xub_StrLen nLastParaEndPos =
+ nPara == aTmpLastSel.nEndPara
+ ? aTmpLastSel.nEndPos : STRING_LEN;
+ if ( nParaStartPos != nLastParaStartPos ||
+ nParaEndPos != nLastParaEndPos )
+ {
+ maParaManager.FireEvent(
+ nPara, nTextSelChgEventId );
+ }
+ }
+ }
+ // second submit event for 'old' selections
+ nPara = aTmpLastSel.nStartPara;
+ for ( ; nPara <= aTmpLastSel.nEndPara; ++nPara )
+ {
+ if ( nPara < aTmpSel.nStartPara ||
+ nPara > aTmpSel.nEndPara )
+ {
+ maParaManager.FireEvent( nPara,
+ nTextSelChgEventId );
+ }
+ }
+ }
+ }
+
+ maLastSelection = aSelection;
+ }
+ }
+ }
+ // no selection? no update actions
+ catch( const uno::RuntimeException& ) {}
+ }
+
+ void AccessibleTextHelper_Impl::ShutdownEditSource() SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ // This should only be called with solar mutex locked, i.e. from the main office thread
+
+ // This here is somewhat clumsy: As soon as our children have
+ // a NULL EditSource (maParaManager.SetEditSource()), they
+ // enter the disposed state and cannot be reanimated. Thus, it
+ // is unavoidable and a hard requirement to let go and create
+ // from scratch each and every child.
+
+ // invalidate children
+ maParaManager.Dispose();
+ maParaManager.SetNum(0);
+
+ // lost all children
+ if( mxFrontEnd.is() )
+ FireEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN);
+
+ // quit listen on stale edit source
+ if( maEditSource.IsValid() )
+ EndListening( maEditSource.GetBroadcaster() );
+
+ maEditSource.SetEditSource( ::std::auto_ptr< SvxEditSource >(NULL) );
+ }
+
+ void AccessibleTextHelper_Impl::SetEditSource( ::std::auto_ptr< SvxEditSource > pEditSource ) SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ // This should only be called with solar mutex locked, i.e. from the main office thread
+
+ // shutdown old edit source
+ ShutdownEditSource();
+
+ // set new edit source
+ maEditSource.SetEditSource( pEditSource );
+
+ // init child vector to the current child count
+ if( maEditSource.IsValid() )
+ {
+ maParaManager.SetNum( GetTextForwarder().GetParagraphCount() );
+
+ // listen on new edit source
+ StartListening( maEditSource.GetBroadcaster() );
+
+ UpdateVisibleChildren();
+ }
+ }
+
+ void AccessibleTextHelper_Impl::SetOffset( const Point& rPoint )
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ // guard against non-atomic access to maOffset data structure
+ {
+ ::osl::MutexGuard aGuard( maMutex );
+ maOffset = rPoint;
+ }
+
+ maParaManager.SetEEOffset( rPoint );
+
+ // in all cases, check visibility afterwards.
+ UpdateVisibleChildren();
+ UpdateBoundRect();
+ }
+
+ void AccessibleTextHelper_Impl::UpdateVisibleChildren( bool bBroadcastEvents )
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ try
+ {
+ SvxTextForwarder& rCacheTF = GetTextForwarder();
+ SvxViewForwarder& rCacheVF = GetViewForwarder();
+
+ Rectangle aViewArea = rCacheVF.GetVisArea();
+
+ if( IsActive() )
+ {
+ // maybe the edit view scrolls, adapt aViewArea
+ Rectangle aEditViewArea = GetEditViewForwarder().GetVisArea();
+ aViewArea += aEditViewArea.TopLeft();
+
+ // now determine intersection
+ aViewArea.Intersection( aEditViewArea );
+ }
+
+ Rectangle aTmpBB, aParaBB;
+ sal_Bool bFirstChild = sal_True;
+ sal_Int32 nCurrPara;
+ sal_Int32 nParas=rCacheTF.GetParagraphCount();
+
+ mnFirstVisibleChild = -1;
+ mnLastVisibleChild = -2;
+
+ for( nCurrPara=0; nCurrPara<nParas; ++nCurrPara )
+ {
+ DBG_ASSERT(nCurrPara >= 0 && nCurrPara <= USHRT_MAX,
+ "AccessibleTextHelper_Impl::UpdateVisibleChildren: index value overflow");
+
+ aTmpBB = rCacheTF.GetParaBounds( static_cast< USHORT >( nCurrPara ) );
+
+ // convert to screen coordinates
+ aParaBB = ::accessibility::AccessibleEditableTextPara::LogicToPixel( aTmpBB, rCacheTF.GetMapMode(), rCacheVF );
+
+ if( aParaBB.IsOver( aViewArea ) )
+ {
+ // at least partially visible
+ if( bFirstChild )
+ {
+ bFirstChild = sal_False;
+ mnFirstVisibleChild = nCurrPara;
+ }
+
+ mnLastVisibleChild = nCurrPara;
+
+ // child not yet created?
+ ::accessibility::AccessibleParaManager::WeakChild aChild( maParaManager.GetChild(nCurrPara) );
+ if( aChild.second.Width == 0 &&
+ aChild.second.Height == 0 &&
+ mxFrontEnd.is() &&
+ bBroadcastEvents )
+ {
+ GotPropertyEvent( uno::makeAny( maParaManager.CreateChild( nCurrPara - mnFirstVisibleChild,
+ mxFrontEnd, GetEditSource(), nCurrPara ).first ),
+ AccessibleEventId::CHILD );
+ }
+ }
+ else
+ {
+ // not or no longer visible
+ if( maParaManager.IsReferencable( nCurrPara ) )
+ {
+ if( bBroadcastEvents )
+ LostPropertyEvent( uno::makeAny( maParaManager.GetChild( nCurrPara ).first.get().getRef() ),
+ AccessibleEventId::CHILD );
+
+ // clear reference
+ maParaManager.Release( nCurrPara );
+ }
+ }
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_ERROR("AccessibleTextHelper_Impl::UpdateVisibleChildren error while determining visible children");
+
+ // something failed - currently no children
+ mnFirstVisibleChild = -1;
+ mnLastVisibleChild = -2;
+ maParaManager.SetNum(0);
+
+ // lost all children
+ if( bBroadcastEvents )
+ FireEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN);
+ }
+ }
+
+ // functor for checking changes in paragraph bounding boxes (no stand-alone function, maybe not inlined)
+ class AccessibleTextHelper_UpdateChildBounds : public ::std::unary_function< const ::accessibility::AccessibleParaManager::WeakChild&,
+ ::accessibility::AccessibleParaManager::WeakChild >
+ {
+ public:
+ AccessibleTextHelper_UpdateChildBounds( AccessibleTextHelper_Impl& rImpl ) : mrImpl(rImpl) {}
+ ::accessibility::AccessibleParaManager::WeakChild operator()( const ::accessibility::AccessibleParaManager::WeakChild& rChild )
+ {
+ // retrieve hard reference from weak one
+ ::accessibility::AccessibleParaManager::WeakPara::HardRefType aHardRef( rChild.first.get() );
+
+ if( aHardRef.is() )
+ {
+ awt::Rectangle aNewRect = aHardRef->getBounds();
+ const awt::Rectangle& aOldRect = rChild.second;
+
+ if( aNewRect.X != aOldRect.X ||
+ aNewRect.Y != aOldRect.Y ||
+ aNewRect.Width != aOldRect.Width ||
+ aNewRect.Height != aOldRect.Height )
+ {
+ // visible data changed
+ aHardRef->FireEvent( AccessibleEventId::BOUNDRECT_CHANGED );
+
+ // update internal bounds
+ return ::accessibility::AccessibleParaManager::WeakChild( rChild.first, aNewRect );
+ }
+ }
+
+ // identity transform
+ return rChild;
+ }
+
+ private:
+ AccessibleTextHelper_Impl& mrImpl;
+ };
+
+ void AccessibleTextHelper_Impl::UpdateBoundRect()
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ // send BOUNDRECT_CHANGED to affected children
+ AccessibleTextHelper_UpdateChildBounds aFunctor( *this );
+ ::std::transform( maParaManager.begin(), maParaManager.end(), maParaManager.begin(), aFunctor );
+ }
+
+#ifdef DBG_UTIL
+ void AccessibleTextHelper_Impl::CheckInvariants() const
+ {
+ if( mnFirstVisibleChild >= 0 &&
+ mnFirstVisibleChild > mnLastVisibleChild )
+ {
+ DBG_ERROR( "AccessibleTextHelper: range invalid" );
+ }
+ }
+#endif
+
+ // functor for sending child events (no stand-alone function, they are maybe not inlined)
+ class AccessibleTextHelper_LostChildEvent : public ::std::unary_function< const ::accessibility::AccessibleParaManager::WeakChild&, void >
+ {
+ public:
+ AccessibleTextHelper_LostChildEvent( AccessibleTextHelper_Impl& rImpl ) : mrImpl(rImpl) {}
+ void operator()( const ::accessibility::AccessibleParaManager::WeakChild& rPara )
+ {
+ // retrieve hard reference from weak one
+ ::accessibility::AccessibleParaManager::WeakPara::HardRefType aHardRef( rPara.first.get() );
+
+ if( aHardRef.is() )
+ mrImpl.FireEvent(AccessibleEventId::CHILD, uno::Any(), uno::makeAny( aHardRef.getRef() ) );
+ }
+
+ private:
+ AccessibleTextHelper_Impl& mrImpl;
+ };
+
+ void AccessibleTextHelper_Impl::ParagraphsMoved( sal_Int32 nFirst, sal_Int32 nMiddle, sal_Int32 nLast )
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ const sal_Int32 nParas = GetTextForwarder().GetParagraphCount();
+
+ /* rotate paragraphs
+ * =================
+ *
+ * Three cases:
+ *
+ * 1.
+ * ... nParagraph ... nParam1 ... nParam2 ...
+ * |______________[xxxxxxxxxxx]
+ * becomes
+ * [xxxxxxxxxxx]|______________
+ *
+ * tail is 0
+ *
+ * 2.
+ * ... nParam1 ... nParagraph ... nParam2 ...
+ * [xxxxxxxxxxx|xxxxxxxxxxxxxx]____________
+ * becomes
+ * ____________[xxxxxxxxxxx|xxxxxxxxxxxxxx]
+ *
+ * tail is nParagraph - nParam1
+ *
+ * 3.
+ * ... nParam1 ... nParam2 ... nParagraph ...
+ * [xxxxxxxxxxx]___________|____________
+ * becomes
+ * ___________|____________[xxxxxxxxxxx]
+ *
+ * tail is nParam2 - nParam1
+ */
+
+ // sort nParagraph, nParam1 and nParam2 in ascending order, calc range
+ if( nMiddle < nFirst )
+ {
+ ::std::swap(nFirst, nMiddle);
+ }
+ else if( nMiddle < nLast )
+ {
+ nLast = nLast + nMiddle - nFirst;
+ }
+ else
+ {
+ ::std::swap(nMiddle, nLast);
+ nLast = nLast + nMiddle - nFirst;
+ }
+
+ if( nFirst < nParas && nMiddle < nParas && nLast < nParas )
+ {
+ // since we have no "paragraph index
+ // changed" event on UAA, remove
+ // [first,last] and insert again later (in
+ // UpdateVisibleChildren)
+
+ // maParaManager.Rotate( nFirst, nMiddle, nLast );
+
+ // send CHILD_EVENT to affected children
+ ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator begin = maParaManager.begin();
+ ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator end = begin;
+
+ ::std::advance( begin, nFirst );
+ ::std::advance( end, nLast+1 );
+
+ // TODO: maybe optimize here in the following way. If the
+ // number of removed children exceeds a certain threshold,
+ // use INVALIDATE_CHILDREN
+ AccessibleTextHelper_LostChildEvent aFunctor( *this );
+
+ ::std::for_each( begin, end, aFunctor );
+
+ maParaManager.Release(nFirst, nLast+1);
+ // should be no need for UpdateBoundRect, since all affected children are cleared.
+ }
+ }
+
+ // functor for sending child events (no stand-alone function, they are maybe not inlined)
+ class AccessibleTextHelper_ChildrenTextChanged : public ::std::unary_function< ::accessibility::AccessibleEditableTextPara&, void >
+ {
+ public:
+ void operator()( ::accessibility::AccessibleEditableTextPara& rPara )
+ {
+ rPara.TextChanged();
+ }
+ };
+
+ /** functor processing queue events
+
+ Reacts on TEXT_HINT_PARAINSERTED/REMOVED events and stores
+ their content
+ */
+ class AccessibleTextHelper_QueueFunctor : public ::std::unary_function< const SfxHint*, void >
+ {
+ public:
+ AccessibleTextHelper_QueueFunctor() :
+ mnParasChanged( 0 ),
+ mnParaIndex(-1),
+ mnHintId(-1)
+ {}
+ void operator()( const SfxHint* pEvent )
+ {
+ if( pEvent &&
+ mnParasChanged != -1 )
+ {
+ // determine hint type
+ const TextHint* pTextHint = PTR_CAST( TextHint, pEvent );
+ const SvxEditSourceHint* pEditSourceHint = PTR_CAST( SvxEditSourceHint, pEvent );
+
+ if( !pEditSourceHint && pTextHint &&
+ (pTextHint->GetId() == TEXT_HINT_PARAINSERTED ||
+ pTextHint->GetId() == TEXT_HINT_PARAREMOVED ) )
+ {
+ if( pTextHint->GetValue() == EE_PARA_ALL )
+ {
+ mnParasChanged = -1;
+ }
+ else
+ {
+ mnHintId = pTextHint->GetId();
+ mnParaIndex = pTextHint->GetValue();
+ ++mnParasChanged;
+ }
+ }
+ }
+ }
+
+ /** Query number of paragraphs changed during queue processing.
+
+ @return number of changed paragraphs, -1 for
+ "every paragraph changed"
+ */
+ int GetNumberOfParasChanged() { return mnParasChanged; }
+ /** Query index of last added/removed paragraph
+
+ @return index of lastly added paragraphs, -1 for none
+ added so far.
+ */
+ int GetParaIndex() { return mnParaIndex; }
+ /** Query hint id of last interesting event
+
+ @return hint id of last interesting event (REMOVED/INSERTED).
+ */
+ int GetHintId() { return mnHintId; }
+
+ private:
+ /** number of paragraphs changed during queue processing. -1 for
+ "every paragraph changed"
+ */
+ int mnParasChanged;
+ /// index of paragraph added/removed last
+ int mnParaIndex;
+ /// TextHint ID (removed/inserted) of last interesting event
+ int mnHintId;
+ };
+
+ void AccessibleTextHelper_Impl::ProcessQueue()
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ // inspect queue for paragraph insert/remove events. If there
+ // is exactly _one_ of those in the queue, and the number of
+ // paragraphs has changed by exactly one, use that event to
+ // determine a priori which paragraph was added/removed. This
+ // is necessary, since I must sync right here with the
+ // EditEngine state (number of paragraphs etc.), since I'm
+ // potentially sending listener events right away.
+ AccessibleTextHelper_QueueFunctor aFunctor;
+ maEventQueue.ForEach( aFunctor );
+
+ const sal_Int32 nNewParas( GetTextForwarder().GetParagraphCount() );
+ const sal_Int32 nCurrParas( maParaManager.GetNum() );
+
+ // whether every paragraph already is updated (no need to
+ // repeat that later on, e.g. for PARA_MOVED events)
+ bool bEverythingUpdated( false );
+
+ if( labs( nNewParas - nCurrParas ) == 1 &&
+ aFunctor.GetNumberOfParasChanged() == 1 )
+ {
+ // #103483# Exactly one paragraph added/removed. This is
+ // the normal case, optimize event handling here.
+
+ if( aFunctor.GetHintId() == TEXT_HINT_PARAINSERTED )
+ {
+ // update num of paras
+ maParaManager.SetNum( nNewParas );
+
+ // release everything from the insertion position until the end
+ maParaManager.Release(aFunctor.GetParaIndex(), nCurrParas);
+
+ // TODO: Clarify whether this behaviour _really_ saves
+ // anybody anything!
+ // update children, _don't_ broadcast
+ UpdateVisibleChildren( false );
+ UpdateBoundRect();
+
+ // send insert event
+ // #109864# Enforce creation of this paragraph
+ try
+ {
+ GotPropertyEvent( uno::makeAny( getAccessibleChild( aFunctor.GetParaIndex() -
+ mnFirstVisibleChild + GetStartIndex() ) ),
+ AccessibleEventId::CHILD );
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_ERROR("AccessibleTextHelper_Impl::ProcessQueue: could not create new paragraph");
+ }
+ }
+ else if( aFunctor.GetHintId() == TEXT_HINT_PARAREMOVED )
+ {
+ ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator begin = maParaManager.begin();
+ ::std::advance( begin, aFunctor.GetParaIndex() );
+ ::accessibility::AccessibleParaManager::VectorOfChildren::const_iterator end = begin;
+ ::std::advance( end, 1 );
+
+ // #i61812# remember para to be removed for later notification
+ // AFTER the new state is applied (that after the para got removed)
+ ::uno::Reference< XAccessible > xPara;
+ ::accessibility::AccessibleParaManager::WeakPara::HardRefType aHardRef( begin->first.get() );
+ if( aHardRef.is() )
+ xPara = ::uno::Reference< XAccessible >( aHardRef.getRef(), ::uno::UNO_QUERY );
+
+ // release everything from the remove position until the end
+ maParaManager.Release(aFunctor.GetParaIndex(), nCurrParas);
+
+ // update num of paras
+ maParaManager.SetNum( nNewParas );
+
+ // TODO: Clarify whether this behaviour _really_ saves
+ // anybody anything!
+ // update children, _don't_ broadcast
+ UpdateVisibleChildren( false );
+ UpdateBoundRect();
+
+ // #i61812# notification for removed para
+ if (xPara.is())
+ FireEvent(AccessibleEventId::CHILD, uno::Any(), uno::makeAny( xPara) );
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("AccessibleTextHelper_Impl::ProcessQueue() invalid hint id");
+#endif
+ }
+ else if( nNewParas != nCurrParas )
+ {
+ // release all paras
+ maParaManager.Release(0, nCurrParas);
+
+ // update num of paras
+ maParaManager.SetNum( nNewParas );
+
+ // #109864# create from scratch, don't broadcast
+ UpdateVisibleChildren( false );
+ UpdateBoundRect();
+
+ // number of paragraphs somehow changed - but we have no
+ // chance determining how. Thus, throw away everything and
+ // create from scratch.
+ // (child events should be broadcast after the changes are done...)
+ FireEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN);
+
+ // no need for further updates later on
+ bEverythingUpdated = true;
+ }
+
+ while( !maEventQueue.IsEmpty() )
+ {
+ ::std::auto_ptr< SfxHint > pHint( maEventQueue.PopFront() );
+ if( pHint.get() )
+ {
+ const SfxHint& rHint = *(pHint.get());
+
+ // determine hint type
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+ const SfxSimpleHint* pSimpleHint = PTR_CAST( SfxSimpleHint, &rHint );
+ const TextHint* pTextHint = PTR_CAST( TextHint, &rHint );
+ const SvxViewHint* pViewHint = PTR_CAST( SvxViewHint, &rHint );
+ const SvxEditSourceHint* pEditSourceHint = PTR_CAST( SvxEditSourceHint, &rHint );
+
+ try
+ {
+ const sal_Int32 nParas = GetTextForwarder().GetParagraphCount();
+
+ if( pEditSourceHint )
+ {
+ switch( pEditSourceHint->GetId() )
+ {
+ case EDITSOURCE_HINT_PARASMOVED:
+ {
+ DBG_ASSERT( pEditSourceHint->GetStartValue() < GetTextForwarder().GetParagraphCount() &&
+ pEditSourceHint->GetEndValue() < GetTextForwarder().GetParagraphCount(),
+ "AccessibleTextHelper_Impl::NotifyHdl: Invalid notification");
+
+ if( !bEverythingUpdated )
+ {
+ ParagraphsMoved(pEditSourceHint->GetStartValue(),
+ pEditSourceHint->GetValue(),
+ pEditSourceHint->GetEndValue());
+
+ // in all cases, check visibility afterwards.
+ UpdateVisibleChildren();
+ }
+ break;
+ }
+
+ case EDITSOURCE_HINT_SELECTIONCHANGED:
+ // notify listeners
+ try
+ {
+ UpdateSelection();
+ }
+ // maybe we're not in edit mode (this is not an error)
+ catch( const uno::Exception& ) {}
+ break;
+ }
+ }
+ else if( pTextHint )
+ {
+ switch( pTextHint->GetId() )
+ {
+ case TEXT_HINT_MODIFIED:
+ {
+ // notify listeners
+ sal_Int32 nPara( pTextHint->GetValue() );
+
+ // #108900# Delegate change event to children
+ AccessibleTextHelper_ChildrenTextChanged aNotifyChildrenFunctor;
+
+ if( nPara == static_cast<sal_Int32>(EE_PARA_ALL) )
+ {
+ // #108900# Call every child
+ ::std::for_each( maParaManager.begin(), maParaManager.end(),
+ AccessibleParaManager::WeakChildAdapter< AccessibleTextHelper_ChildrenTextChanged > (aNotifyChildrenFunctor) );
+ }
+ else
+ if( nPara < nParas )
+ {
+ // #108900# Call child at index nPara
+ ::std::for_each( maParaManager.begin()+nPara, maParaManager.begin()+nPara+1,
+ AccessibleParaManager::WeakChildAdapter< AccessibleTextHelper_ChildrenTextChanged > (aNotifyChildrenFunctor) );
+ }
+ break;
+ }
+
+ case TEXT_HINT_PARAINSERTED:
+ // already happened above
+ break;
+
+ case TEXT_HINT_PARAREMOVED:
+ // already happened above
+ break;
+
+ case TEXT_HINT_TEXTHEIGHTCHANGED:
+ // visibility changed, done below
+ break;
+
+ case TEXT_HINT_VIEWSCROLLED:
+ // visibility changed, done below
+ break;
+ }
+
+ // in all cases, check visibility afterwards.
+ UpdateVisibleChildren();
+ UpdateBoundRect();
+ }
+ else if( pViewHint )
+ {
+ switch( pViewHint->GetHintType() )
+ {
+ case SvxViewHint::SVX_HINT_VIEWCHANGED:
+ // just check visibility
+ UpdateVisibleChildren();
+ UpdateBoundRect();
+ break;
+ }
+ }
+ else if( pSdrHint )
+ {
+ switch( pSdrHint->GetKind() )
+ {
+ case HINT_BEGEDIT:
+ {
+ // change children state
+ maParaManager.SetActive();
+
+ // per definition, edit mode text has the focus
+ SetFocus( sal_True );
+ break;
+ }
+
+ case HINT_ENDEDIT:
+ {
+ // focused child now looses focus
+ ESelection aSelection;
+ if( GetEditViewForwarder().GetSelection( aSelection ) )
+ SetChildFocus( aSelection.nEndPara, sal_False );
+
+ // change children state
+ maParaManager.SetActive( sal_False );
+
+ maLastSelection = ESelection( EE_PARA_NOT_FOUND, EE_PARA_NOT_FOUND,
+ EE_PARA_NOT_FOUND, EE_PARA_NOT_FOUND);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ // it's VITAL to keep the SfxSimpleHint last! It's the base of some classes above!
+ else if( pSimpleHint )
+ {
+ switch( pSimpleHint->GetId() )
+ {
+ case SFX_HINT_DYING:
+ // edit source is dying under us, become defunc then
+ try
+ {
+ // make edit source inaccessible
+ // Note: cannot destroy it here, since we're called from there!
+ ShutdownEditSource();
+ }
+ catch( const uno::Exception& ) {}
+
+ break;
+ }
+ }
+ }
+ catch( const uno::Exception& )
+ {
+#ifdef DBG_UTIL
+ OSL_TRACE("AccessibleTextHelper_Impl::ProcessQueue: Unhandled exception.");
+#endif
+ }
+ }
+ }
+ }
+
+ void AccessibleTextHelper_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ // precondition: solar mutex locked
+ DBG_TESTSOLARMUTEX();
+
+ // precondition: not in a recursion
+ if( mbInNotify )
+ return;
+
+ mbInNotify = sal_True;
+
+ // determine hint type
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+ const SfxSimpleHint* pSimpleHint = PTR_CAST( SfxSimpleHint, &rHint );
+ const TextHint* pTextHint = PTR_CAST( TextHint, &rHint );
+ const SvxViewHint* pViewHint = PTR_CAST( SvxViewHint, &rHint );
+ const SvxEditSourceHint* pEditSourceHint = PTR_CAST( SvxEditSourceHint, &rHint );
+
+ try
+ {
+ // Process notification event
+ if( pEditSourceHint )
+ {
+ maEventQueue.Append( *pEditSourceHint );
+ // --> OD 2005-12-19 #i27299#
+ if( maEventOpenFrames == 0 )
+ ProcessQueue();
+ // <--
+ }
+ else if( pTextHint )
+ {
+ switch( pTextHint->GetId() )
+ {
+ case TEXT_HINT_BLOCKNOTIFICATION_END:
+ case TEXT_HINT_INPUT_END:
+ --maEventOpenFrames;
+
+ if( maEventOpenFrames == 0 )
+ {
+ // #103483#
+ /* All information should have arrived
+ * now, process queue. As stated in the
+ * above bug, we can often avoid throwing
+ * away all paragraphs by looking forward
+ * in the event queue (searching for
+ * PARAINSERT/REMOVE events). Furthermore,
+ * processing the event queue only at the
+ * end of an interaction cycle, ensures
+ * that the EditEngine state and the
+ * AccessibleText state are the same
+ * (well, mostly. If there are _multiple_
+ * interaction cycles in the EE queues, it
+ * can still happen that EE state is
+ * different. That's so to say broken by
+ * design with that delayed EE event
+ * concept).
+ */
+ ProcessQueue();
+ }
+ break;
+
+ case TEXT_HINT_BLOCKNOTIFICATION_START:
+ case TEXT_HINT_INPUT_START:
+ ++maEventOpenFrames;
+ // --> OD 2005-12-19 #i27299# - no FALLTROUGH
+ // reason: event will not be processes, thus appending
+ // the event isn't necessary.
+ break;
+ // <--
+ default:
+ maEventQueue.Append( *pTextHint );
+ // --> OD 2005-12-19 #i27299#
+ if( maEventOpenFrames == 0 )
+ ProcessQueue();
+ // <--
+ break;
+ }
+ }
+ else if( pViewHint )
+ {
+ maEventQueue.Append( *pViewHint );
+
+ // process visibility right away, if not within an
+ // open EE notification frame. Otherwise, event
+ // processing would be delayed until next EE
+ // notification sequence.
+ if( maEventOpenFrames == 0 )
+ ProcessQueue();
+ }
+ else if( pSdrHint )
+ {
+ maEventQueue.Append( *pSdrHint );
+
+ // process drawing layer events right away, if not
+ // within an open EE notification frame. Otherwise,
+ // event processing would be delayed until next EE
+ // notification sequence.
+ if( maEventOpenFrames == 0 )
+ ProcessQueue();
+ }
+ // it's VITAL to keep the SfxSimpleHint last! It's the base of some classes above!
+ else if( pSimpleHint )
+ {
+ // handle this event _at once_, because after that, objects are invalid
+ switch( pSimpleHint->GetId() )
+ {
+ case SFX_HINT_DYING:
+ // edit source is dying under us, become defunc then
+ maEventQueue.Clear();
+ try
+ {
+ // make edit source inaccessible
+ // Note: cannot destroy it here, since we're called from there!
+ ShutdownEditSource();
+ }
+ catch( const uno::Exception& ) {}
+
+ break;
+ }
+ }
+ }
+ catch( const uno::Exception& )
+ {
+#ifdef DBG_UTIL
+ OSL_TRACE("AccessibleTextHelper_Impl::Notify: Unhandled exception.");
+#endif
+ mbInNotify = sal_False;
+ }
+
+ mbInNotify = sal_False;
+ }
+
+ void AccessibleTextHelper_Impl::Dispose()
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ if( getNotifierClientId() != -1 )
+ {
+ try
+ {
+ // #106234# Unregister from EventNotifier
+ ::comphelper::AccessibleEventNotifier::revokeClient( getNotifierClientId() );
+#ifdef DBG_UTIL
+ OSL_TRACE( "AccessibleTextHelper_Impl disposed ID: %d", mnNotifierClientId );
+#endif
+ }
+ catch( const uno::Exception& ) {}
+
+ mnNotifierClientId = -1;
+ }
+
+ try
+ {
+ // dispose children
+ maParaManager.Dispose();
+ }
+ catch( const uno::Exception& ) {}
+
+ // quit listen on stale edit source
+ if( maEditSource.IsValid() )
+ EndListening( maEditSource.GetBroadcaster() );
+
+ // clear references
+ maEditSource.SetEditSource( ::std::auto_ptr< SvxEditSource >(NULL) );
+ mxFrontEnd = NULL;
+ }
+
+ void AccessibleTextHelper_Impl::FireEvent( const sal_Int16 nEventId, const uno::Any& rNewValue, const uno::Any& rOldValue ) const
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ // -- object locked --
+ ::osl::ClearableMutexGuard aGuard( maMutex );
+
+ AccessibleEventObject aEvent;
+
+ DBG_ASSERT(mxFrontEnd.is(), "AccessibleTextHelper::FireEvent: no event source set" );
+
+ if( mxFrontEnd.is() )
+ aEvent = AccessibleEventObject(mxFrontEnd->getAccessibleContext(), nEventId, rNewValue, rOldValue);
+ else
+ aEvent = AccessibleEventObject(uno::Reference< uno::XInterface >(), nEventId, rNewValue, rOldValue);
+
+ // no locking necessary, FireEvent internally copies listeners
+ // if someone removes/adds in between Further locking,
+ // actually, might lead to deadlocks, since we're calling out
+ // of this object
+ aGuard.clear();
+ // -- until here --
+
+ FireEvent(aEvent);
+ }
+
+ void AccessibleTextHelper_Impl::FireEvent( const AccessibleEventObject& rEvent ) const
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ // #102261# Call global queue for focus events
+ if( rEvent.EventId == AccessibleStateType::FOCUSED )
+ vcl::unohelper::NotifyAccessibleStateEventGlobally( rEvent );
+
+ // #106234# Delegate to EventNotifier
+ ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(),
+ rEvent );
+ }
+
+ // XAccessibleContext
+ sal_Int32 SAL_CALL AccessibleTextHelper_Impl::getAccessibleChildCount() SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ return mnLastVisibleChild - mnFirstVisibleChild + 1;
+ }
+
+ uno::Reference< XAccessible > SAL_CALL AccessibleTextHelper_Impl::getAccessibleChild( sal_Int32 i ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ i -= GetStartIndex();
+
+ if( 0 > i || i >= getAccessibleChildCount() ||
+ GetTextForwarder().GetParagraphCount() <= i )
+ {
+ throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid child index")), mxFrontEnd);
+ }
+
+ DBG_ASSERT(mxFrontEnd.is(), "AccessibleTextHelper_Impl::UpdateVisibleChildren: no frontend set");
+
+ if( mxFrontEnd.is() )
+ return maParaManager.CreateChild( i, mxFrontEnd, GetEditSource(), mnFirstVisibleChild + i ).first;
+ else
+ return NULL;
+ }
+
+ void SAL_CALL AccessibleTextHelper_Impl::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ if( getNotifierClientId() != -1 )
+ ::comphelper::AccessibleEventNotifier::addEventListener( getNotifierClientId(), xListener );
+ }
+
+ void SAL_CALL AccessibleTextHelper_Impl::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ if( getNotifierClientId() != -1 )
+ ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener );
+ }
+
+ uno::Reference< XAccessible > SAL_CALL AccessibleTextHelper_Impl::getAccessibleAtPoint( const awt::Point& _aPoint ) SAL_THROW((uno::RuntimeException))
+ {
+ DBG_CHKTHIS( AccessibleTextHelper_Impl, NULL );
+
+ // make given position relative
+ if( !mxFrontEnd.is() )
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleTextHelper_Impl::getAccessibleAt: frontend invalid")), mxFrontEnd );
+
+ uno::Reference< XAccessibleContext > xFrontEndContext = mxFrontEnd->getAccessibleContext();
+
+ if( !xFrontEndContext.is() )
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleTextHelper_Impl::getAccessibleAt: frontend invalid")), mxFrontEnd );
+
+ uno::Reference< XAccessibleComponent > xFrontEndComponent( xFrontEndContext, uno::UNO_QUERY );
+
+ if( !xFrontEndComponent.is() )
+ throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleTextHelper_Impl::getAccessibleAt: frontend is no XAccessibleComponent")),
+ mxFrontEnd );
+
+ // #103862# No longer need to make given position relative
+ Point aPoint( _aPoint.X, _aPoint.Y );
+
+ // respect EditEngine offset to surrounding shape/cell
+ aPoint -= GetOffset();
+
+ // convert to EditEngine coordinate system
+ SvxTextForwarder& rCacheTF = GetTextForwarder();
+ Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) );
+
+ // iterate over all visible children (including those not yet created)
+ sal_Int32 nChild;
+ for( nChild=mnFirstVisibleChild; nChild <= mnLastVisibleChild; ++nChild )
+ {
+ DBG_ASSERT(nChild >= 0 && nChild <= USHRT_MAX,
+ "AccessibleTextHelper_Impl::getAccessibleAt: index value overflow");
+
+ Rectangle aParaBounds( rCacheTF.GetParaBounds( static_cast< USHORT > (nChild) ) );
+
+ if( aParaBounds.IsInside( aLogPoint ) )
+ return getAccessibleChild( nChild - mnFirstVisibleChild + GetStartIndex() );
+ }
+
+ // found none
+ return NULL;
+ }
+
+ //------------------------------------------------------------------------
+ //
+ // AccessibleTextHelper implementation (simply forwards to impl)
+ //
+ //------------------------------------------------------------------------
+
+ AccessibleTextHelper::AccessibleTextHelper( ::std::auto_ptr< SvxEditSource > pEditSource ) :
+ mpImpl( new AccessibleTextHelper_Impl() )
+ {
+ SolarMutexGuard aGuard;
+
+ SetEditSource( pEditSource );
+ }
+
+ AccessibleTextHelper::~AccessibleTextHelper()
+ {
+ }
+
+ const SvxEditSource& AccessibleTextHelper::GetEditSource() const SAL_THROW((uno::RuntimeException))
+ {
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ const SvxEditSource& aEditSource = mpImpl->GetEditSource();
+
+ mpImpl->CheckInvariants();
+
+ return aEditSource;
+#else
+ return mpImpl->GetEditSource();
+#endif
+ }
+
+ void AccessibleTextHelper::SetEditSource( ::std::auto_ptr< SvxEditSource > pEditSource ) SAL_THROW((uno::RuntimeException))
+ {
+#ifdef DBG_UTIL
+ // precondition: solar mutex locked
+ DBG_TESTSOLARMUTEX();
+
+ mpImpl->CheckInvariants();
+#endif
+
+ mpImpl->SetEditSource( pEditSource );
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+ }
+
+ void AccessibleTextHelper::SetEventSource( const uno::Reference< XAccessible >& rInterface )
+ {
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+
+ mpImpl->SetEventSource( rInterface );
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+ }
+
+ uno::Reference< XAccessible > AccessibleTextHelper::GetEventSource() const
+ {
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ uno::Reference< XAccessible > xRet( mpImpl->GetEventSource() );
+
+ mpImpl->CheckInvariants();
+
+ return xRet;
+#else
+ return mpImpl->GetEventSource();
+#endif
+ }
+
+ void AccessibleTextHelper::SetFocus( sal_Bool bHaveFocus ) SAL_THROW((::com::sun::star::uno::RuntimeException))
+ {
+#ifdef DBG_UTIL
+ // precondition: solar mutex locked
+ DBG_TESTSOLARMUTEX();
+
+ mpImpl->CheckInvariants();
+#endif
+
+ mpImpl->SetFocus( bHaveFocus );
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+ }
+
+ sal_Bool AccessibleTextHelper::HaveFocus() SAL_THROW((::com::sun::star::uno::RuntimeException))
+ {
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ sal_Bool bRet( mpImpl->HaveFocus() );
+
+ mpImpl->CheckInvariants();
+
+ return bRet;
+#else
+ return mpImpl->HaveFocus();
+#endif
+ }
+
+ void AccessibleTextHelper::FireEvent( const sal_Int16 nEventId, const uno::Any& rNewValue, const uno::Any& rOldValue ) const
+ {
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+
+ mpImpl->FireEvent( nEventId, rNewValue, rOldValue );
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+ }
+
+ void AccessibleTextHelper::FireEvent( const AccessibleEventObject& rEvent ) const
+ {
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+
+ mpImpl->FireEvent( rEvent );
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+ }
+
+ void AccessibleTextHelper::SetOffset( const Point& rPoint )
+ {
+#ifdef DBG_UTIL
+ // precondition: solar mutex locked
+ DBG_TESTSOLARMUTEX();
+
+ mpImpl->CheckInvariants();
+#endif
+
+ mpImpl->SetOffset( rPoint );
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+ }
+
+ Point AccessibleTextHelper::GetOffset() const
+ {
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ Point aPoint( mpImpl->GetOffset() );
+
+ mpImpl->CheckInvariants();
+
+ return aPoint;
+#else
+ return mpImpl->GetOffset();
+#endif
+ }
+
+ void AccessibleTextHelper::SetStartIndex( sal_Int32 nOffset )
+ {
+#ifdef DBG_UTIL
+ // precondition: solar mutex locked
+ DBG_TESTSOLARMUTEX();
+
+ mpImpl->CheckInvariants();
+#endif
+
+ mpImpl->SetStartIndex( nOffset );
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+ }
+
+ sal_Int32 AccessibleTextHelper::GetStartIndex() const
+ {
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ sal_Int32 nOffset = mpImpl->GetStartIndex();
+
+ mpImpl->CheckInvariants();
+
+ return nOffset;
+#else
+ return mpImpl->GetStartIndex();
+#endif
+ }
+
+ void AccessibleTextHelper::SetAdditionalChildStates( const VectorOfStates& rChildStates )
+ {
+ mpImpl->SetAdditionalChildStates( rChildStates );
+ }
+
+ const AccessibleTextHelper::VectorOfStates& AccessibleTextHelper::GetAdditionalChildStates() const
+ {
+ return mpImpl->GetAdditionalChildStates();
+ }
+
+ void AccessibleTextHelper::UpdateChildren() SAL_THROW((::com::sun::star::uno::RuntimeException))
+ {
+#ifdef DBG_UTIL
+ // precondition: solar mutex locked
+ DBG_TESTSOLARMUTEX();
+
+ mpImpl->CheckInvariants();
+#endif
+
+ mpImpl->UpdateVisibleChildren();
+ mpImpl->UpdateBoundRect();
+
+ mpImpl->UpdateSelection();
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+ }
+
+ void AccessibleTextHelper::Dispose()
+ {
+ // As Dispose calls ShutdownEditSource, which in turn
+ // deregisters as listener on the edit source, have to lock
+ // here
+ SolarMutexGuard aGuard;
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+
+ mpImpl->Dispose();
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+#endif
+ }
+
+ sal_Bool AccessibleTextHelper::IsSelected() const
+ {
+ SolarMutexGuard aGuard;
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ sal_Bool aRet = mpImpl->IsSelected();
+
+ mpImpl->CheckInvariants();
+
+ return aRet;
+#else
+ return mpImpl->IsSelected();
+#endif
+ }
+
+ // XAccessibleContext
+ sal_Int32 AccessibleTextHelper::GetChildCount() SAL_THROW((uno::RuntimeException))
+ {
+ SolarMutexGuard aGuard;
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ sal_Int32 nRet = mpImpl->getAccessibleChildCount();
+
+ mpImpl->CheckInvariants();
+
+ return nRet;
+#else
+ return mpImpl->getAccessibleChildCount();
+#endif
+ }
+
+ uno::Reference< XAccessible > AccessibleTextHelper::GetChild( sal_Int32 i ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
+ {
+ SolarMutexGuard aGuard;
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ uno::Reference< XAccessible > xRet = mpImpl->getAccessibleChild( i );
+
+ mpImpl->CheckInvariants();
+
+ return xRet;
+#else
+ return mpImpl->getAccessibleChild( i );
+#endif
+ }
+
+ void AccessibleTextHelper::AddEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) SAL_THROW((uno::RuntimeException))
+ {
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ mpImpl->addEventListener( xListener );
+
+ mpImpl->CheckInvariants();
+#else
+ mpImpl->addEventListener( xListener );
+#endif
+ }
+
+ void AccessibleTextHelper::RemoveEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) SAL_THROW((uno::RuntimeException))
+ {
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ mpImpl->removeEventListener( xListener );
+
+ mpImpl->CheckInvariants();
+#else
+ mpImpl->removeEventListener( xListener );
+#endif
+ }
+
+ // XAccessibleComponent
+ uno::Reference< XAccessible > AccessibleTextHelper::GetAt( const awt::Point& aPoint ) SAL_THROW((uno::RuntimeException))
+ {
+ SolarMutexGuard aGuard;
+
+#ifdef DBG_UTIL
+ mpImpl->CheckInvariants();
+
+ uno::Reference< XAccessible > xChild = mpImpl->getAccessibleAtPoint( aPoint );
+
+ mpImpl->CheckInvariants();
+
+ return xChild;
+#else
+ return mpImpl->getAccessibleAtPoint( aPoint );
+#endif
+ }
+
+} // end of namespace accessibility
+
+//------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/ChildrenManager.cxx b/svx/source/accessibility/ChildrenManager.cxx
new file mode 100644
index 000000000000..9019ad46ecda
--- /dev/null
+++ b/svx/source/accessibility/ChildrenManager.cxx
@@ -0,0 +1,180 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/ChildrenManager.hxx>
+#include "ChildrenManagerImpl.hxx"
+#include <svx/AccessibleShape.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+using ::com::sun::star::uno::Reference;
+
+namespace accessibility {
+
+
+//===== AccessibleChildrenManager ===========================================
+
+ChildrenManager::ChildrenManager (
+ const ::com::sun::star::uno::Reference<XAccessible>& rxParent,
+ const ::com::sun::star::uno::Reference<drawing::XShapes>& rxShapeList,
+ const AccessibleShapeTreeInfo& rShapeTreeInfo,
+ AccessibleContextBase& rContext)
+ : mpImpl (NULL)
+{
+ mpImpl = new ChildrenManagerImpl (rxParent, rxShapeList, rShapeTreeInfo, rContext);
+ if (mpImpl != NULL)
+ mpImpl->Init ();
+ else
+ throw uno::RuntimeException(
+ ::rtl::OUString::createFromAscii(
+ "ChildrenManager::ChildrenManager can't create implementation object"), NULL);
+}
+
+
+
+
+ChildrenManager::~ChildrenManager (void)
+{
+ if (mpImpl != NULL)
+ mpImpl->dispose();
+
+ // emtpy
+ OSL_TRACE ("~ChildrenManager");
+}
+
+
+
+
+long ChildrenManager::GetChildCount (void) const throw ()
+{
+ OSL_ASSERT (mpImpl != NULL);
+ return mpImpl->GetChildCount();
+}
+
+
+
+
+::com::sun::star::uno::Reference<XAccessible> ChildrenManager::GetChild (long nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException)
+{
+ OSL_ASSERT (mpImpl != NULL);
+ return mpImpl->GetChild (nIndex);
+}
+
+
+
+
+void ChildrenManager::Update (bool bCreateNewObjectsOnDemand)
+{
+ OSL_ASSERT (mpImpl != NULL);
+ mpImpl->Update (bCreateNewObjectsOnDemand);
+}
+
+
+
+
+void ChildrenManager::SetShapeList (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes>& xShapeList)
+{
+ OSL_ASSERT (mpImpl != NULL);
+ mpImpl->SetShapeList (xShapeList);
+}
+
+
+
+
+void ChildrenManager::AddAccessibleShape (std::auto_ptr<AccessibleShape> pShape)
+{
+ OSL_ASSERT (mpImpl != NULL);
+ mpImpl->AddAccessibleShape (pShape);
+}
+
+
+
+
+void ChildrenManager::ClearAccessibleShapeList (void)
+{
+ OSL_ASSERT (mpImpl != NULL);
+ mpImpl->ClearAccessibleShapeList ();
+}
+
+
+
+
+void ChildrenManager::SetInfo (AccessibleShapeTreeInfo& rShapeTreeInfo)
+{
+ OSL_ASSERT (mpImpl != NULL);
+ mpImpl->SetInfo (rShapeTreeInfo);
+}
+
+
+
+
+void ChildrenManager::UpdateSelection (void)
+{
+ OSL_ASSERT (mpImpl != NULL);
+ mpImpl->UpdateSelection ();
+}
+
+
+
+
+bool ChildrenManager::HasFocus (void)
+{
+ OSL_ASSERT (mpImpl != NULL);
+ return mpImpl->HasFocus ();
+}
+
+
+
+
+void ChildrenManager::RemoveFocus (void)
+{
+ OSL_ASSERT (mpImpl != NULL);
+ mpImpl->RemoveFocus ();
+}
+
+
+
+
+//===== IAccessibleViewForwarderListener ====================================
+void ChildrenManager::ViewForwarderChanged (ChangeType aChangeType,
+ const IAccessibleViewForwarder* pViewForwarder)
+{
+ OSL_ASSERT (mpImpl != NULL);
+ mpImpl->ViewForwarderChanged (aChangeType, pViewForwarder);
+}
+
+
+
+} // end of namespace accessibility
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/ChildrenManagerImpl.cxx b/svx/source/accessibility/ChildrenManagerImpl.cxx
new file mode 100644
index 000000000000..32dfa318b30f
--- /dev/null
+++ b/svx/source/accessibility/ChildrenManagerImpl.cxx
@@ -0,0 +1,1098 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "ChildrenManagerImpl.hxx"
+#include <svx/ShapeTypeHandler.hxx>
+#include <svx/AccessibleShapeInfo.hxx>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <comphelper/uno3.hxx>
+#include <com/sun/star/container/XChild.hpp>
+
+#include <rtl/ustring.hxx>
+#include <tools/debug.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+using ::com::sun::star::uno::Reference;
+
+
+namespace accessibility {
+
+namespace
+{
+void adjustIndexInParentOfShapes(ChildDescriptorListType& _rList)
+{
+ ChildDescriptorListType::iterator aEnd = _rList.end();
+ sal_Int32 i=0;
+ for ( ChildDescriptorListType::iterator aIter = _rList.begin(); aIter != aEnd; ++aIter,++i)
+ aIter->setIndexAtAccessibleShape(i);
+}
+}
+
+//===== AccessibleChildrenManager ===========================================
+
+ChildrenManagerImpl::ChildrenManagerImpl (
+ const uno::Reference<XAccessible>& rxParent,
+ const uno::Reference<drawing::XShapes>& rxShapeList,
+ const AccessibleShapeTreeInfo& rShapeTreeInfo,
+ AccessibleContextBase& rContext)
+ : ::cppu::WeakComponentImplHelper2<
+ ::com::sun::star::document::XEventListener,
+ ::com::sun::star::view::XSelectionChangeListener>(maMutex),
+ mxShapeList (rxShapeList),
+ mxParent (rxParent),
+ maShapeTreeInfo (rShapeTreeInfo),
+ mrContext (rContext),
+ mnNewNameIndex(1),
+ mpFocusedShape(NULL)
+{
+}
+
+
+
+
+ChildrenManagerImpl::~ChildrenManagerImpl (void)
+{
+ DBG_ASSERT (rBHelper.bDisposed || rBHelper.bInDispose,
+ "~AccessibleDrawDocumentView: object has not been disposed");
+}
+
+
+
+
+void ChildrenManagerImpl::Init (void)
+{
+ // Register as view::XSelectionChangeListener.
+ Reference<frame::XController> xController(maShapeTreeInfo.GetController());
+ Reference<view::XSelectionSupplier> xSelectionSupplier (
+ xController, uno::UNO_QUERY);
+ if (xSelectionSupplier.is())
+ {
+ xController->addEventListener(
+ static_cast<document::XEventListener*>(this));
+
+ xSelectionSupplier->addSelectionChangeListener (
+ static_cast<view::XSelectionChangeListener*>(this));
+ }
+
+ // Register at model as document::XEventListener.
+ if (maShapeTreeInfo.GetModelBroadcaster().is())
+ maShapeTreeInfo.GetModelBroadcaster()->addEventListener (
+ static_cast<document::XEventListener*>(this));
+}
+
+
+
+
+long ChildrenManagerImpl::GetChildCount (void) const throw ()
+{
+ return maVisibleChildren.size();
+}
+
+
+
+
+/** Return the requested accessible child object. Create it if it is not
+ yet in the cache.
+*/
+uno::Reference<XAccessible>
+ ChildrenManagerImpl::GetChild (long nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException)
+{
+ // Check wether the given index is valid.
+ if (nIndex < 0 || (unsigned long)nIndex >= maVisibleChildren.size())
+ throw lang::IndexOutOfBoundsException (
+ ::rtl::OUString::createFromAscii(
+ "no accessible child with index ") + nIndex,
+ mxParent);
+
+ return GetChild (maVisibleChildren[nIndex],nIndex);
+}
+
+
+
+
+/** Return the requested accessible child object. Create it if it is not
+ yet in the cache.
+*/
+uno::Reference<XAccessible>
+ ChildrenManagerImpl::GetChild (ChildDescriptor& rChildDescriptor,sal_Int32 _nIndex)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ if ( ! rChildDescriptor.mxAccessibleShape.is())
+ {
+ ::osl::MutexGuard aGuard (maMutex);
+ // Make sure that the requested accessible object has not been
+ // created while locking the global mutex.
+ if ( ! rChildDescriptor.mxAccessibleShape.is())
+ {
+ AccessibleShapeInfo aShapeInfo(
+ rChildDescriptor.mxShape,
+ mxParent,
+ this,
+ mnNewNameIndex++);
+ // Create accessible object that corresponds to the descriptor's
+ // shape.
+ AccessibleShape* pShape =
+ ShapeTypeHandler::Instance().CreateAccessibleObject (
+ aShapeInfo,
+ maShapeTreeInfo);
+ rChildDescriptor.mxAccessibleShape = uno::Reference<XAccessible> (
+ static_cast<uno::XWeak*>(pShape),
+ uno::UNO_QUERY);
+ // Now that there is a reference to the new accessible shape we
+ // can safely call its Init() method.
+ if ( pShape != NULL )
+ {
+ pShape->Init();
+ pShape->setIndexInParent(_nIndex);
+ }
+ }
+ }
+
+ return rChildDescriptor.mxAccessibleShape;
+}
+
+
+
+
+uno::Reference<XAccessible>
+ ChildrenManagerImpl::GetChild (const uno::Reference<drawing::XShape>& xShape)
+ throw (uno::RuntimeException)
+{
+ ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end();
+ for (I = maVisibleChildren.begin(); I != aEnd; ++I)
+ {
+ if ( I->mxShape.get() == xShape.get() )
+ return I->mxAccessibleShape;
+ }
+ return uno::Reference<XAccessible> ();
+}
+
+
+
+
+/** Find all shapes among the specified shapes that lie fully or partially
+ inside the visible area. Put those shapes into the cleared cache. The
+ corresponding accessible objects will be created on demand.
+
+ At the moment, first all accessible objects are removed from the cache
+ and the appropriate listeners are informed of this. Next, the list is
+ created again. This should be optimized in the future to not remove and
+ create objects that will be in the list before and after the update
+ method.
+*/
+void ChildrenManagerImpl::Update (bool bCreateNewObjectsOnDemand)
+{
+ if (maShapeTreeInfo.GetViewForwarder() == NULL)
+ return;
+ Rectangle aVisibleArea = maShapeTreeInfo.GetViewForwarder()->GetVisibleArea();
+
+ // 1. Create a local list of visible shapes.
+ ChildDescriptorListType aChildList;
+ CreateListOfVisibleShapes (aChildList);
+
+ // 2. Merge the information that is already known about the visible
+ // shapes from the current list into the new list.
+ MergeAccessibilityInformation (aChildList);
+
+ // 3. Replace the current list of visible shapes with the new one. Do
+ // the same with the visible area.
+ {
+ ::osl::MutexGuard aGuard (maMutex);
+ adjustIndexInParentOfShapes(aChildList);
+
+ // Use swap to copy the contents of the new list in constant time.
+ maVisibleChildren.swap (aChildList);
+
+ // aChildList now contains all the old children, while maVisibleChildren
+ // contains all the current children
+
+ // 4. Find all shapes in the old list that are not in the current list,
+ // send appropriate events and remove the accessible shape.
+ //
+ // Do this *after* we have set our new list of children, because
+ // removing a child may cause
+ //
+ // ChildDescriptor::disposeAccessibleObject -->
+ // AccessibleContextBase::CommitChange -->
+ // AtkListener::notifyEvent ->
+ // AtkListener::handleChildRemoved ->
+ // AtkListener::updateChildList
+ // AccessibleDrawDocumentView::getAccessibleChildCount ->
+ // ChildrenManagerImpl::GetChildCount ->
+ // maVisibleChildren.size()
+ //
+ // to be fired, and so the operations will take place on
+ // the list we are trying to replace
+ //
+ RemoveNonVisibleChildren (maVisibleChildren, aChildList);
+
+ aChildList.clear();
+
+ maVisibleArea = aVisibleArea;
+ }
+
+ // 5. If the visible area has changed then send events that signal a
+ // change of their bounding boxes for all shapes that are members of
+ // both the current and the new list of visible shapes.
+ if (maVisibleArea != aVisibleArea)
+ SendVisibleAreaEvents (maVisibleChildren);
+
+ // 6. If children have to be created immediately and not on demand then
+ // create the missing accessible objects now.
+ if ( ! bCreateNewObjectsOnDemand)
+ CreateAccessibilityObjects (maVisibleChildren);
+}
+
+
+
+
+void ChildrenManagerImpl::CreateListOfVisibleShapes (
+ ChildDescriptorListType& raDescriptorList)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ OSL_ASSERT (maShapeTreeInfo.GetViewForwarder() != NULL);
+
+ Rectangle aVisibleArea = maShapeTreeInfo.GetViewForwarder()->GetVisibleArea();
+
+ // Add the visible shapes for wich the accessible objects already exist.
+ AccessibleShapeList::iterator I,aEnd = maAccessibleShapes.end();
+ for (I=maAccessibleShapes.begin(); I != aEnd; ++I)
+ {
+ if (I->is())
+ {
+ uno::Reference<XAccessibleComponent> xComponent (
+ (*I)->getAccessibleContext(), uno::UNO_QUERY);
+ if (xComponent.is())
+ {
+ // The bounding box of the object already is clipped to the
+ // visible area. The object is therefore visible if the
+ // bounding box has non-zero extensions.
+ awt::Rectangle aPixelBBox (xComponent->getBounds());
+ if ((aPixelBBox.Width > 0) && (aPixelBBox.Height > 0))
+ raDescriptorList.push_back (ChildDescriptor (*I));
+ }
+ }
+ }
+
+ // Add the visible shapes for which only the XShapes exist.
+ uno::Reference<container::XIndexAccess> xShapeAccess (mxShapeList, uno::UNO_QUERY);
+ if (xShapeAccess.is())
+ {
+ sal_Int32 nShapeCount = xShapeAccess->getCount();
+ raDescriptorList.reserve( nShapeCount );
+ awt::Point aPos;
+ awt::Size aSize;
+ Rectangle aBoundingBox;
+ uno::Reference<drawing::XShape> xShape;
+ for (sal_Int32 i=0; i<nShapeCount; ++i)
+ {
+ xShapeAccess->getByIndex(i) >>= xShape;
+ aPos = xShape->getPosition();
+ aSize = xShape->getSize();
+
+ aBoundingBox.nLeft = aPos.X;
+ aBoundingBox.nTop = aPos.Y;
+ aBoundingBox.nRight = aPos.X + aSize.Width;
+ aBoundingBox.nBottom = aPos.Y + aSize.Height;
+
+ // Insert shape if it is visible, i.e. its bounding box overlaps
+ // the visible area.
+ if ( aBoundingBox.IsOver (aVisibleArea) )
+ raDescriptorList.push_back (ChildDescriptor (xShape));
+ }
+ }
+}
+
+
+
+
+void ChildrenManagerImpl::RemoveNonVisibleChildren (
+ const ChildDescriptorListType& rNewChildList,
+ ChildDescriptorListType& rOldChildList)
+{
+ // Iterate over list of formerly visible children and remove those that
+ // are not visible anymore, i.e. member of the new list of visible
+ // children.
+ ChildDescriptorListType::iterator I, aEnd = rOldChildList.end();
+ for (I=rOldChildList.begin(); I != aEnd; ++I)
+ {
+ if (::std::find(rNewChildList.begin(), rNewChildList.end(), *I) == rNewChildList.end())
+ {
+ // The child is disposed when there is a UNO shape from which
+ // the accessible shape can be created when the shape becomes
+ // visible again. When there is no such UNO shape then simply
+ // reset the descriptor but keep the accessibility object.
+ if (I->mxShape.is())
+ {
+ UnregisterAsDisposeListener (I->mxShape);
+ I->disposeAccessibleObject (mrContext);
+ }
+ else
+ {
+ AccessibleShape* pAccessibleShape = I->GetAccessibleShape();
+ pAccessibleShape->ResetState (AccessibleStateType::VISIBLE);
+ I->mxAccessibleShape = NULL;
+ }
+ }
+ }
+}
+
+
+
+
+void ChildrenManagerImpl::MergeAccessibilityInformation (
+ ChildDescriptorListType& raNewChildList)
+{
+ ChildDescriptorListType::iterator aOldChildDescriptor;
+ ChildDescriptorListType::iterator I, aEnd = raNewChildList.end();
+ for (I=raNewChildList.begin(); I != aEnd; ++I)
+ {
+ aOldChildDescriptor = ::std::find (maVisibleChildren.begin(), maVisibleChildren.end(), *I);
+
+ // Copy accessible shape if that exists in the old descriptor.
+ bool bRegistrationIsNecessary = true;
+ if (aOldChildDescriptor != maVisibleChildren.end())
+ if (aOldChildDescriptor->mxAccessibleShape.is())
+ {
+ I->mxAccessibleShape = aOldChildDescriptor->mxAccessibleShape;
+ I->mbCreateEventPending = false;
+ bRegistrationIsNecessary = false;
+ }
+ if (bRegistrationIsNecessary)
+ RegisterAsDisposeListener (I->mxShape);
+ }
+}
+
+
+
+
+void ChildrenManagerImpl::SendVisibleAreaEvents (
+ ChildDescriptorListType& raNewChildList)
+{
+ ChildDescriptorListType::iterator I,aEnd = raNewChildList.end();
+ for (I=raNewChildList.begin(); I != aEnd; ++I)
+ {
+ // Tell shape of changed visible area. To do this, fake a
+ // change of the view forwarder. (Actually we usually get here
+ // as a result of a change of the view forwarder).
+ AccessibleShape* pShape = I->GetAccessibleShape ();
+ if (pShape != NULL)
+ pShape->ViewForwarderChanged (
+ IAccessibleViewForwarderListener::VISIBLE_AREA,
+ maShapeTreeInfo.GetViewForwarder());
+ }
+}
+
+
+
+
+void ChildrenManagerImpl::CreateAccessibilityObjects (
+ ChildDescriptorListType& raNewChildList)
+{
+ ChildDescriptorListType::iterator I, aEnd = raNewChildList.end();
+ sal_Int32 nPos = 0;
+ for ( I = raNewChildList.begin(); I != aEnd; ++I,++nPos)
+ {
+ // Create the associated accessible object when the flag says so and
+ // it does not yet exist.
+ if ( ! I->mxAccessibleShape.is() )
+ GetChild (*I,nPos);
+ if (I->mxAccessibleShape.is() && I->mbCreateEventPending)
+ {
+ I->mbCreateEventPending = false;
+ mrContext.CommitChange (
+ AccessibleEventId::CHILD,
+ uno::makeAny(I->mxAccessibleShape),
+ uno::Any());
+ }
+ }
+}
+
+
+
+
+void ChildrenManagerImpl::AddShape (const Reference<drawing::XShape>& rxShape)
+{
+ if (rxShape.is())
+ {
+ ::osl::ClearableMutexGuard aGuard (maMutex);
+
+ // Test visibility of the shape.
+ Rectangle aVisibleArea = maShapeTreeInfo.GetViewForwarder()->GetVisibleArea();
+ awt::Point aPos = rxShape->getPosition();
+ awt::Size aSize = rxShape->getSize();
+
+ Rectangle aBoundingBox (
+ aPos.X,
+ aPos.Y,
+ aPos.X + aSize.Width,
+ aPos.Y + aSize.Height);
+
+ // Add the shape only when it belongs to the list of shapes stored
+ // in mxShapeList (which is either a page or a group shape).
+ Reference<container::XChild> xChild (rxShape, uno::UNO_QUERY);
+ if (xChild.is())
+ {
+ Reference<drawing::XShapes> xParent (xChild->getParent(), uno::UNO_QUERY);
+ if (xParent == mxShapeList)
+ if (aBoundingBox.IsOver (aVisibleArea))
+ {
+ // Add shape to list of visible shapes.
+ maVisibleChildren.push_back (ChildDescriptor (rxShape));
+
+ // Create accessibility object.
+ ChildDescriptor& rDescriptor = maVisibleChildren.back();
+ GetChild (rDescriptor, maVisibleChildren.size()-1);
+
+ // Inform listeners about new child.
+ uno::Any aNewShape;
+ aNewShape <<= rDescriptor.mxAccessibleShape;
+ aGuard.clear();
+ mrContext.CommitChange (
+ AccessibleEventId::CHILD,
+ aNewShape,
+ uno::Any());
+ RegisterAsDisposeListener (rDescriptor.mxShape);
+ }
+ }
+ }
+}
+
+
+
+
+void ChildrenManagerImpl::RemoveShape (const Reference<drawing::XShape>& rxShape)
+{
+ if (rxShape.is())
+ {
+ ::osl::ClearableMutexGuard aGuard (maMutex);
+
+ // Search shape in list of visible children.
+ ChildDescriptorListType::iterator I (
+ ::std::find (maVisibleChildren.begin(), maVisibleChildren.end(),
+ ChildDescriptor (rxShape)));
+ if (I != maVisibleChildren.end())
+ {
+ // Remove descriptor from that list.
+ Reference<XAccessible> xAccessibleShape (I->mxAccessibleShape);
+
+ UnregisterAsDisposeListener (I->mxShape);
+ // Dispose the accessible object.
+ I->disposeAccessibleObject (mrContext);
+
+ // Now we can safely remove the child descriptor and thus
+ // invalidate the iterator.
+ maVisibleChildren.erase (I);
+
+ adjustIndexInParentOfShapes(maVisibleChildren);
+ }
+ }
+}
+
+
+
+
+void ChildrenManagerImpl::SetShapeList (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes>& xShapeList)
+{
+ mxShapeList = xShapeList;
+}
+
+
+
+
+void ChildrenManagerImpl::AddAccessibleShape (std::auto_ptr<AccessibleShape> pShape)
+{
+ if (pShape.get() != NULL)
+ maAccessibleShapes.push_back (pShape.release());
+}
+
+
+
+
+void ChildrenManagerImpl::ClearAccessibleShapeList (void)
+{
+ // Copy the list of (visible) shapes to local lists and clear the
+ // originals.
+ ChildDescriptorListType aLocalVisibleChildren;
+ aLocalVisibleChildren.swap(maVisibleChildren);
+ AccessibleShapeList aLocalAccessibleShapes;
+ aLocalAccessibleShapes.swap(maAccessibleShapes);
+
+ // Tell the listeners that all children are gone.
+ mrContext.CommitChange (
+ AccessibleEventId::INVALIDATE_ALL_CHILDREN,
+ uno::Any(),
+ uno::Any());
+
+ // There are no accessible shapes left so the index assigned to new
+ // accessible shapes can be reset.
+ mnNewNameIndex = 1;
+
+ // Now the objects in the local lists can be safely disposed without
+ // having problems with callers that want to update their child lists.
+
+ // Clear the list of visible accessible objects. Objects not created on
+ // demand for XShapes are treated below.
+ ChildDescriptorListType::iterator I,aEnd = aLocalVisibleChildren.end();
+ for (I=aLocalVisibleChildren.begin(); I != aEnd; ++I)
+ if ( I->mxAccessibleShape.is() && I->mxShape.is() )
+ {
+ ::comphelper::disposeComponent(I->mxAccessibleShape);
+ I->mxAccessibleShape = NULL;
+ }
+
+ // Dispose all objects in the accessible shape list.
+ AccessibleShapeList::iterator J,aEnd2 = aLocalAccessibleShapes.end();
+ for (J=aLocalAccessibleShapes.begin(); J != aEnd2; ++J)
+ if (J->is())
+ {
+ // Dispose the object.
+ ::comphelper::disposeComponent(*J);
+ *J = NULL;
+ }
+}
+
+
+
+
+/** If the broadcasters change at which this object is registered then
+ unregister at old and register at new broadcasters.
+*/
+void ChildrenManagerImpl::SetInfo (const AccessibleShapeTreeInfo& rShapeTreeInfo)
+{
+ // Remember the current broadcasters and exchange the shape tree info.
+ Reference<document::XEventBroadcaster> xCurrentBroadcaster;
+ Reference<frame::XController> xCurrentController;
+ Reference<view::XSelectionSupplier> xCurrentSelectionSupplier;
+ {
+ ::osl::MutexGuard aGuard (maMutex);
+ xCurrentBroadcaster = maShapeTreeInfo.GetModelBroadcaster();
+ xCurrentController = maShapeTreeInfo.GetController();
+ xCurrentSelectionSupplier = Reference<view::XSelectionSupplier> (
+ xCurrentController, uno::UNO_QUERY);
+ maShapeTreeInfo = rShapeTreeInfo;
+ }
+
+ // Move registration to new model.
+ if (maShapeTreeInfo.GetModelBroadcaster() != xCurrentBroadcaster)
+ {
+ // Register at new broadcaster.
+ if (maShapeTreeInfo.GetModelBroadcaster().is())
+ maShapeTreeInfo.GetModelBroadcaster()->addEventListener (
+ static_cast<document::XEventListener*>(this));
+
+ // Unregister at old broadcaster.
+ if (xCurrentBroadcaster.is())
+ xCurrentBroadcaster->removeEventListener (
+ static_cast<document::XEventListener*>(this));
+ }
+
+ // Move registration to new selection supplier.
+ Reference<frame::XController> xNewController(maShapeTreeInfo.GetController());
+ Reference<view::XSelectionSupplier> xNewSelectionSupplier (
+ xNewController, uno::UNO_QUERY);
+ if (xNewSelectionSupplier != xCurrentSelectionSupplier)
+ {
+ // Register at new broadcaster.
+ if (xNewSelectionSupplier.is())
+ {
+ xNewController->addEventListener(
+ static_cast<document::XEventListener*>(this));
+
+ xNewSelectionSupplier->addSelectionChangeListener (
+ static_cast<view::XSelectionChangeListener*>(this));
+ }
+
+ // Unregister at old broadcaster.
+ if (xCurrentSelectionSupplier.is())
+ {
+ xCurrentSelectionSupplier->removeSelectionChangeListener (
+ static_cast<view::XSelectionChangeListener*>(this));
+
+ xCurrentController->removeEventListener(
+ static_cast<document::XEventListener*>(this));
+ }
+ }
+}
+
+
+
+
+//===== lang::XEventListener ================================================
+
+void SAL_CALL
+ ChildrenManagerImpl::disposing (const lang::EventObject& rEventObject)
+ throw (uno::RuntimeException)
+{
+ if (rEventObject.Source == maShapeTreeInfo.GetModelBroadcaster()
+ || rEventObject.Source == maShapeTreeInfo.GetController())
+ {
+ impl_dispose();
+ }
+
+ // Handle disposing UNO shapes.
+ else
+ {
+ Reference<drawing::XShape> xShape (rEventObject.Source, uno::UNO_QUERY);
+
+ // Find the descriptor for the given shape.
+ ChildDescriptorListType::iterator I (
+ ::std::find (maVisibleChildren.begin(), maVisibleChildren.end(),
+ ChildDescriptor (xShape)));
+ if (I != maVisibleChildren.end())
+ {
+ // Clear the descriptor.
+ I->disposeAccessibleObject (mrContext);
+ I->mxShape = NULL;
+ }
+ }
+}
+
+
+
+
+//===== document::XEventListener ============================================
+
+/** Listen for new and removed shapes.
+*/
+void SAL_CALL
+ ChildrenManagerImpl::notifyEvent (
+ const document::EventObject& rEventObject)
+ throw (uno::RuntimeException)
+{
+ static const ::rtl::OUString sShapeInserted (
+ RTL_CONSTASCII_USTRINGPARAM("ShapeInserted"));
+ static const ::rtl::OUString sShapeRemoved (
+ RTL_CONSTASCII_USTRINGPARAM("ShapeRemoved"));
+
+
+ if (rEventObject.EventName.equals (sShapeInserted))
+ AddShape (Reference<drawing::XShape>(rEventObject.Source, uno::UNO_QUERY));
+ else if (rEventObject.EventName.equals (sShapeRemoved))
+ RemoveShape (Reference<drawing::XShape>(rEventObject.Source, uno::UNO_QUERY));
+ // else ignore unknown event.
+}
+
+
+
+
+//===== view::XSelectionChangeListener ======================================
+
+void SAL_CALL
+ ChildrenManagerImpl::selectionChanged (const lang::EventObject& /*rEvent*/)
+ throw (uno::RuntimeException)
+{
+ UpdateSelection ();
+}
+
+
+
+
+void ChildrenManagerImpl::impl_dispose (void)
+{
+ Reference<frame::XController> xController(maShapeTreeInfo.GetController());
+ // Remove from broadcasters.
+ try
+ {
+ Reference<view::XSelectionSupplier> xSelectionSupplier (
+ xController, uno::UNO_QUERY);
+ if (xSelectionSupplier.is())
+ {
+ xSelectionSupplier->removeSelectionChangeListener (
+ static_cast<view::XSelectionChangeListener*>(this));
+ }
+ }
+ catch( uno::RuntimeException&)
+ {}
+
+ try
+ {
+ if (xController.is())
+ xController->removeEventListener(
+ static_cast<document::XEventListener*>(this));
+ }
+ catch( uno::RuntimeException&)
+ {}
+
+ maShapeTreeInfo.SetController (NULL);
+
+ try
+ {
+ // Remove from broadcaster.
+ if (maShapeTreeInfo.GetModelBroadcaster().is())
+ maShapeTreeInfo.GetModelBroadcaster()->removeEventListener (
+ static_cast<document::XEventListener*>(this));
+ maShapeTreeInfo.SetModelBroadcaster (NULL);
+ }
+ catch( uno::RuntimeException& )
+ {}
+
+ ClearAccessibleShapeList ();
+ SetShapeList (NULL);
+}
+
+
+
+void SAL_CALL ChildrenManagerImpl::disposing (void)
+{
+ impl_dispose();
+}
+
+
+
+
+// This method is experimental. Use with care.
+long int ChildrenManagerImpl::GetChildIndex (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& xChild) const
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+ sal_Int32 nCount = maVisibleChildren.size();
+ for (sal_Int32 i=0; i < nCount; ++i)
+ {
+ // Is this equality comparison valid?
+ if (maVisibleChildren[i].mxAccessibleShape == xChild)
+ return i;
+ }
+
+ return -1;
+}
+
+
+
+
+//===== IAccessibleViewForwarderListener ====================================
+
+void ChildrenManagerImpl::ViewForwarderChanged (ChangeType aChangeType,
+ const IAccessibleViewForwarder* pViewForwarder)
+{
+ if (aChangeType == IAccessibleViewForwarderListener::VISIBLE_AREA)
+ Update (false);
+ else
+ {
+ ::osl::MutexGuard aGuard (maMutex);
+ ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end();
+ for (I=maVisibleChildren.begin(); I != aEnd; ++I)
+ {
+ AccessibleShape* pShape = I->GetAccessibleShape();
+ if (pShape != NULL)
+ pShape->ViewForwarderChanged (aChangeType, pViewForwarder);
+ }
+ }
+}
+
+
+
+
+//===== IAccessibleParent ===================================================
+
+sal_Bool ChildrenManagerImpl::ReplaceChild (
+ AccessibleShape* pCurrentChild,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
+ const long _nIndex,
+ const AccessibleShapeTreeInfo& _rShapeTreeInfo)
+ throw (uno::RuntimeException)
+{
+ AccessibleShapeInfo aShapeInfo( _rxShape, pCurrentChild->getAccessibleParent(), this, _nIndex );
+ // create the new child
+ AccessibleShape* pNewChild = ShapeTypeHandler::Instance().CreateAccessibleObject (
+ aShapeInfo,
+ _rShapeTreeInfo
+ );
+ Reference< XAccessible > xNewChild( pNewChild ); // keep this alive (do this before calling Init!)
+ if ( pNewChild )
+ pNewChild->Init();
+
+ sal_Bool bResult = sal_False;
+
+ // Iterate over the visible children. If one of them has an already
+ // created accessible object that matches pCurrentChild then replace
+ // it. Otherwise the child to replace is either not in the list or has
+ // not ye been created (and is therefore not in the list, too) and a
+ // replacement is not necessary.
+ ChildDescriptorListType::iterator I,aEnd = maVisibleChildren.end();
+ for (I=maVisibleChildren.begin(); I != aEnd; ++I)
+ {
+ if (I->GetAccessibleShape() == pCurrentChild)
+ {
+ // Dispose the current child and send an event about its deletion.
+ pCurrentChild->dispose();
+ mrContext.CommitChange (
+ AccessibleEventId::CHILD,
+ uno::Any(),
+ uno::makeAny (I->mxAccessibleShape));
+
+ // Replace with replacement and send an event about existance
+ // of the new child.
+ I->mxAccessibleShape = pNewChild;
+ mrContext.CommitChange (
+ AccessibleEventId::CHILD,
+ uno::makeAny (I->mxAccessibleShape),
+ uno::Any());
+ bResult = sal_True;
+ break;
+ }
+ }
+
+ // When not found among the visible children we have to search the list
+ // of accessible shapes. This is not yet implemented.
+
+ return bResult;
+}
+
+
+
+
+/** Update the <const>SELECTED</const> and the <const>FOCUSED</const> state
+ of all visible children. Maybe this should be changed to all children.
+
+ Iterate over all descriptors of visible accessible shapes and look them
+ up in the selection.
+
+ If there is no valid controller then all shapes are deselected and
+ unfocused. If the controller's frame is not active then all shapes are
+ unfocused.
+*/
+void ChildrenManagerImpl::UpdateSelection (void)
+{
+ Reference<frame::XController> xController(maShapeTreeInfo.GetController());
+ Reference<view::XSelectionSupplier> xSelectionSupplier (
+ xController, uno::UNO_QUERY);
+
+ // Try to cast the selection both to a multi selection and to a single
+ // selection.
+ Reference<container::XIndexAccess> xSelectedShapeAccess;
+ Reference<drawing::XShape> xSelectedShape;
+ if (xSelectionSupplier.is())
+ {
+ xSelectedShapeAccess = Reference<container::XIndexAccess> (
+ xSelectionSupplier->getSelection(), uno::UNO_QUERY);
+ xSelectedShape = Reference<drawing::XShape> (
+ xSelectionSupplier->getSelection(), uno::UNO_QUERY);
+ }
+
+ // Remember the current and new focused shape.
+ AccessibleShape* pCurrentlyFocusedShape = NULL;
+ AccessibleShape* pNewFocusedShape = NULL;
+
+ ChildDescriptorListType::iterator I, aEnd = maVisibleChildren.end();
+ for (I=maVisibleChildren.begin(); I != aEnd; ++I)
+ {
+ AccessibleShape* pAccessibleShape = I->GetAccessibleShape();
+ if (I->mxAccessibleShape.is() && I->mxShape.is() && pAccessibleShape!=NULL)
+ {
+ bool bShapeIsSelected = false;
+
+ // Look up the shape in the (single or multi-) selection.
+ if (xSelectedShape.is())
+ {
+ if (I->mxShape == xSelectedShape)
+ {
+ bShapeIsSelected = true;
+ pNewFocusedShape = pAccessibleShape;
+ }
+ }
+ else if (xSelectedShapeAccess.is())
+ {
+ sal_Int32 nCount=xSelectedShapeAccess->getCount();
+ for (sal_Int32 i=0; i<nCount&&!bShapeIsSelected; i++)
+ if (xSelectedShapeAccess->getByIndex(i) == I->mxShape)
+ {
+ bShapeIsSelected = true;
+ // In a multi-selection no shape has the focus.
+ if (nCount == 1)
+ pNewFocusedShape = pAccessibleShape;
+ }
+ }
+
+ // Set or reset the SELECTED state.
+ if (bShapeIsSelected)
+ pAccessibleShape->SetState (AccessibleStateType::SELECTED);
+ else
+ pAccessibleShape->ResetState (AccessibleStateType::SELECTED);
+
+ // Does the shape have the current selection?
+ if (pAccessibleShape->GetState (AccessibleStateType::FOCUSED))
+ pCurrentlyFocusedShape = pAccessibleShape;
+ }
+ }
+
+ // Check if the frame we are in is currently active. If not then make
+ // sure to not send a FOCUSED state change.
+ if (xController.is())
+ {
+ Reference<frame::XFrame> xFrame (xController->getFrame());
+ if (xFrame.is())
+ if ( ! xFrame->isActive())
+ pNewFocusedShape = NULL;
+ }
+
+ // Move focus from current to newly focused shape.
+ if (pCurrentlyFocusedShape != pNewFocusedShape)
+ {
+ if (pCurrentlyFocusedShape != NULL)
+ pCurrentlyFocusedShape->ResetState (AccessibleStateType::FOCUSED);
+ if (pNewFocusedShape != NULL)
+ pNewFocusedShape->SetState (AccessibleStateType::FOCUSED);
+ }
+
+ // Remember whether there is a shape that now has the focus.
+ mpFocusedShape = pNewFocusedShape;
+}
+
+
+
+
+bool ChildrenManagerImpl::HasFocus (void)
+{
+ return mpFocusedShape != NULL;
+}
+
+
+
+
+void ChildrenManagerImpl::RemoveFocus (void)
+{
+ if (mpFocusedShape != NULL)
+ {
+ mpFocusedShape->ResetState (AccessibleStateType::FOCUSED);
+ mpFocusedShape = NULL;
+ }
+}
+
+
+
+void ChildrenManagerImpl::RegisterAsDisposeListener (
+ const Reference<drawing::XShape>& xShape)
+{
+ Reference<lang::XComponent> xComponent (xShape, uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->addEventListener (
+ static_cast<document::XEventListener*>(this));
+}
+
+
+
+
+void ChildrenManagerImpl::UnregisterAsDisposeListener (
+ const Reference<drawing::XShape>& xShape)
+{
+ Reference<lang::XComponent> xComponent (xShape, uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->removeEventListener (
+ static_cast<document::XEventListener*>(this));
+}
+
+
+
+
+//===== AccessibleChildDescriptor ===========================================
+
+ChildDescriptor::ChildDescriptor (const Reference<drawing::XShape>& xShape)
+ : mxShape (xShape),
+ mxAccessibleShape (NULL),
+ mbCreateEventPending (true)
+{
+ // Empty.
+}
+
+
+
+
+ChildDescriptor::ChildDescriptor (const Reference<XAccessible>& rxAccessibleShape)
+ : mxShape (NULL),
+ mxAccessibleShape (rxAccessibleShape),
+ mbCreateEventPending (true)
+{
+ // Make sure that the accessible object has the <const>VISIBLE</const>
+ // state set.
+ AccessibleShape* pAccessibleShape = GetAccessibleShape();
+ pAccessibleShape->SetState (AccessibleStateType::VISIBLE);
+}
+
+
+
+
+ChildDescriptor::~ChildDescriptor (void)
+{
+}
+
+
+
+
+AccessibleShape* ChildDescriptor::GetAccessibleShape (void) const
+{
+ return static_cast<AccessibleShape*> (mxAccessibleShape.get());
+}
+// -----------------------------------------------------------------------------
+void ChildDescriptor::setIndexAtAccessibleShape(sal_Int32 _nIndex)
+{
+ AccessibleShape* pShape = GetAccessibleShape();
+ if ( pShape )
+ pShape->setIndexInParent(_nIndex);
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+void ChildDescriptor::disposeAccessibleObject (AccessibleContextBase& rParent)
+{
+ if (mxAccessibleShape.is())
+ {
+ // Send event that the shape has been removed.
+ uno::Any aOldValue;
+ aOldValue <<= mxAccessibleShape;
+ rParent.CommitChange (
+ AccessibleEventId::CHILD,
+ uno::Any(),
+ aOldValue);
+
+ // Dispose and remove the object.
+ Reference<lang::XComponent> xComponent (mxAccessibleShape, uno::UNO_QUERY);
+ if (xComponent.is())
+ xComponent->dispose ();
+
+ mxAccessibleShape = NULL;
+ }
+}
+
+
+} // end of namespace accessibility
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/ChildrenManagerImpl.hxx b/svx/source/accessibility/ChildrenManagerImpl.hxx
new file mode 100644
index 000000000000..c863721f2153
--- /dev/null
+++ b/svx/source/accessibility/ChildrenManagerImpl.hxx
@@ -0,0 +1,579 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_ACCESSIBILITY_CHILDREN_MANAGER_IMPL_HXX
+
+#include <svx/IAccessibleViewForwarderListener.hxx>
+#include <svx/IAccessibleParent.hxx>
+#include <svx/AccessibleShapeTreeInfo.hxx>
+#include <editeng/AccessibleContextBase.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <osl/mutex.hxx>
+#include <vector>
+#include <memory>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+
+using namespace ::com::sun::star;
+
+namespace accessibility {
+
+class AccessibleShape;
+
+class ChildDescriptor; // See below for declaration.
+typedef ::std::vector<ChildDescriptor> ChildDescriptorListType;
+
+// Re-using MutexOwner class defined in AccessibleContextBase.hxx
+
+/** This class contains the actual implementation of the children manager.
+
+ <p>It maintains a set of visible accessible shapes in
+ <member>maVisibleChildren</member>. The objects in this list stem from
+ two sources. The first is a list of UNO shapes like the list of shapes
+ in a draw page. A reference to this list is held in
+ <member>maShapeList</member>. Accessible objects for these shapes are
+ created on demand. The list can be replaced by calls to the
+ <member>SetShapeList</member> method. The second source is a list of
+ already accessible objects. It can be modified by calls to the
+ <member>AddAccessibleShape</member> and
+ <member>ClearAccessibleShapeList</member> methods.</p>
+
+ <p>Each call of the <member>Update</member> method leads to a
+ re-calculation of the visible shapes which then can be queried with the
+ <member>GetChildCount</member> and <member>GetChild</member> methods.
+ Events are send informing all listeners about the removed shapes which are
+ not visible anymore and about the added shapes.</p>
+
+ <p> The visible area which is used to determine the visibility of the
+ shapes is taken from the view forwarder. Thus, to signal a change of
+ the visible area call <member>ViewForwarderChanged</member>.</p>
+
+ <p>The children manager adds itself as disposing() listener at every UNO
+ shape it creates an accessible object for so that when the UNO shape
+ passes away it can dispose() the associated accessible object.</p>
+
+ @see ChildrenManager
+*/
+class ChildrenManagerImpl
+ : public MutexOwner,
+ public cppu::WeakComponentImplHelper2<
+ ::com::sun::star::document::XEventListener,
+ ::com::sun::star::view::XSelectionChangeListener>,
+ public IAccessibleViewForwarderListener,
+ public IAccessibleParent
+{
+public:
+ /** Create a children manager, which manages the children of the given
+ parent. The parent is used for creating accessible objects. The
+ list of shapes for which to create those objects is not derived from
+ the parent and has to be provided seperately by calling one of the
+ update methods.
+ @param rxParent
+ The parent of the accessible objects which will be created
+ on demand at some point of time in the future.
+ @param rxShapeList
+ List of UNO shapes to manage.
+ @param rShapeTreeInfo
+ Bundel of information passed down the shape tree.
+ @param rContext
+ An accessible context object that is called for fireing events
+ for new and deleted children, i.e. that holds a list of
+ listeners to be informed.
+ */
+ ChildrenManagerImpl (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes>& rxShapeList,
+ const AccessibleShapeTreeInfo& rShapeTreeInfo,
+ AccessibleContextBase& rContext);
+
+ /** If there still are managed children these are disposed and
+ released.
+ */
+ ~ChildrenManagerImpl (void);
+
+ /** Do that part of the initialization that you can not or should not do
+ in the constructor like registering at broadcasters.
+ */
+ void Init (void);
+
+ /** Return the number of currently visible accessible children.
+ @return
+ If there are no children a 0 is returned.
+ */
+ long GetChildCount (void) const throw ();
+
+ /** Return the requested accessible child or throw and
+ IndexOutOfBoundsException if the given index is invalid.
+ @param nIndex
+ Index of the requested child. Call getChildCount for obtaining
+ the number of children.
+ @return
+ In case of a valid index this method returns a reference to the
+ requested accessible child. This reference is empty if it has
+ not been possible to create the accessible object of the
+ corresponding shape.
+ @raises
+ Throws an IndexOutOfBoundsException if the index is not valid.
+ */
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>
+ GetChild (long nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /** Return the requested accessible child.
+ @param aChildDescriptor
+ This object contains references to the original shape and its
+ associated accessible object.
+ @param _nIndex
+ The index which will be used in getAccessibleIndexInParent of the accessible shape.
+ @return
+ Returns a reference to the requested accessible child. This
+ reference is empty if it has not been possible to create the
+ accessible object of the corresponding shape.
+ */
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>
+ GetChild (ChildDescriptor& aChildDescriptor,sal_Int32 _nIndex)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Return the requested accessible child given a shape. This method
+ searches the list of descriptors for the one that holds the
+ association of the given shape to the requested accessible object
+ and returns that. If no such descriptor is found that is
+ interpreted so that the specified shape is not visible at the moment.
+ @param xShape
+ The shape for which to return the associated accessible object.
+ @return
+ Returns a reference to the requested accessible child. The
+ reference is empty if there is no shape descriptor that
+ associates the shape with an accessible object.
+ */
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>
+ GetChild (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape>& xShape)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Update the child manager. Take care of a modified set of children
+ and modified visible area. This method can optimize the update
+ process with respect seperate updates of a modified children list
+ and visible area.
+ @param bCreateNewObjectsOnDemand
+ If </true> then accessible objects associated with the visible
+ shapes are created only when asked for. No event is sent on
+ creation. If </false> then the accessible objects are created
+ before this method returns and events are sent to inform the
+ listeners of the new object.
+ */
+ void Update (bool bCreateNewObjectsOnDemand = true);
+
+ /** Set the list of UNO shapes to the given list. This removes the old
+ list and does not add to it. The list of accessible shapes that is
+ build up by calls to <member>AddAccessibleShape</member> is not
+ modified. Neither is the list of visible children. Accessible
+ objects are created on demand.
+ @param xShapeList
+ The list of UNO shapes that replaces the old list.
+ */
+ void SetShapeList (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes>& xShapeList);
+
+ /** Add a accessible shape. This does not modify the list of UNO shapes
+ or the list of visible shapes. Accessible shapes are, at the
+ moment, not tested against the visible area but are always appended
+ to the list of visible children.
+ @param pShape
+ The new shape that is added to the list of accessible shapes.
+ */
+ void AddAccessibleShape (std::auto_ptr<AccessibleShape> pShape);
+
+ /** Clear the lists of accessible shapes and that of visible accessible
+ shapes. The list of UNO shapes is not modified.
+ */
+ void ClearAccessibleShapeList (void);
+
+ /** Set a new event shape tree info. Call this method to inform the
+ children manager of a change of the info bundle.
+ @param rShapeTreeInfo
+ The new info that replaces the current one.
+ */
+ void SetInfo (const AccessibleShapeTreeInfo& rShapeTreeInfo);
+
+ /** Update the SELECTED and FOCUSED states of all visible children
+ according to the given selection. This includes setting
+ <em>and</em> resetting the states.
+ */
+ void UpdateSelection (void);
+
+ /** Return whether one of the shapes managed by this object has
+ currently the focus.
+ @return
+ Returns <true/> when there is a shape that has the focus and
+ <false/> when there is no such shape.
+ */
+ bool HasFocus (void);
+
+ /** When there is a shape that currently has the focus,
+ i.e. <member>HasFocus()</member> returns <true/> then remove the
+ focus from that shape. Otherwise nothing changes.
+ */
+ void RemoveFocus (void);
+
+ //===== lang::XEventListener ============================================
+
+ virtual void SAL_CALL
+ disposing (const ::com::sun::star::lang::EventObject& rEventObject)
+ throw (::com::sun::star::uno::RuntimeException);
+
+
+ //===== document::XEventListener ========================================
+
+ virtual void SAL_CALL
+ notifyEvent (const ::com::sun::star::document::EventObject& rEventObject)
+ throw (::com::sun::star::uno::RuntimeException);
+
+
+ //===== view::XSelectionChangeListener ==================================
+
+ virtual void SAL_CALL
+ selectionChanged (const ::com::sun::star::lang::EventObject& rEvent)
+ throw (::com::sun::star::uno::RuntimeException);
+
+
+ //===== IAccessibleViewForwarderListener ================================
+
+ /** Informs this children manager and its children about a change of one
+ (or more) aspect of the view forwarder.
+ @param aChangeType
+ A change type of <const>VISIBLE_AREA</const> leads to a call to
+ the <member>Update</memeber> which creates accessible objects of
+ new shapes immediately. Other change types are passed to the
+ visible accessible children without calling
+ <member>Update</memeber>.
+ @param pViewForwarder
+ The modified view forwarder. Use this one from now on.
+ */
+ virtual void ViewForwarderChanged (ChangeType aChangeType,
+ const IAccessibleViewForwarder* pViewForwarder);
+
+ //===== IAccessibleParent ===============================================
+
+ /** Replace the specified child with a replacement.
+ @param pCurrentChild
+ This child is to be replaced.
+ @param pReplacement
+ The replacement for the current child.
+ @return
+ The returned value indicates wether the replacement has been
+ finished successfully.
+ */
+ virtual sal_Bool ReplaceChild (
+ AccessibleShape* pCurrentChild,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
+ const long _nIndex,
+ const AccessibleShapeTreeInfo& _rShapeTreeInfo
+ ) throw (::com::sun::star::uno::RuntimeException);
+
+
+protected:
+ /** This list holds the descriptors of all currently visible shapes and
+ associated accessible object.
+
+ <p>With the descriptors it maintains a mapping of shapes to
+ accessible objects. It acts as a cache in that accessible objects
+ are only created on demand and released with every update (where the
+ latter may be optimized by the update methods).<p>
+
+ <p>The list is realized as a vector because it remains unchanged
+ between updates (i.e. complete rebuilds of the list) and allows a
+ fast (constant time) access to its elements for given indices.</p>
+ */
+ ChildDescriptorListType maVisibleChildren;
+
+ /** The original list of UNO shapes. The visible shapes are inserted
+ into the list of visible children
+ <member>maVisibleChildren</member>.
+ */
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes> mxShapeList;
+
+ /** This list of additional accessible shapes that can or shall not be
+ created by the shape factory.
+ */
+ typedef std::vector< ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible> > AccessibleShapeList;
+ AccessibleShapeList maAccessibleShapes;
+
+ /** Rectangle that describes the visible area in which a shape has to lie
+ at least partly, to be accessible through this class. Used to
+ detect changes of the visible area after changes of the view forwarder.
+ */
+ Rectangle maVisibleArea;
+
+ /** The parent of the shapes. It is used for creating accessible
+ objects for given shapes.
+ */
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible> mxParent;
+
+ /** Bundel of information passed down the shape tree.
+ */
+ AccessibleShapeTreeInfo maShapeTreeInfo;
+
+ /** Reference to an accessible context object that is used to inform its
+ listeners of new and remved children.
+ */
+ AccessibleContextBase& mrContext;
+
+ /** This method is called from the component helper base class while
+ disposing.
+ */
+ virtual void SAL_CALL disposing (void);
+
+ /** Experimental: Get the index of the specified accessible object with
+ respect to the list of children maintained by this object.
+
+ @return
+ Return the index of the given child or -1 to indicate that the
+ child is unknown.
+ */
+ long GetChildIndex (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& xChild) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+ void impl_dispose (void);
+
+private:
+ /** Names of new accessible objects are disambiguated with this index.
+ It gets increased every time a new object is created and (at the
+ moment) never reset.
+ */
+ sal_Int32 mnNewNameIndex;
+
+ // Don't use the copy constructor or the assignment operator. They are
+ // not implemented (and are not intended to be).
+ ChildrenManagerImpl (const ChildrenManagerImpl&);
+ ChildrenManagerImpl& operator= (const ChildrenManagerImpl&);
+
+ /** This member points to the currently focused shape. It is NULL when
+ there is no focused shape.
+ */
+ AccessibleShape* mpFocusedShape;
+
+ /** Three helper functions for the <member>Update</member> method.
+ */
+
+ /** Create a list of visible shapes from the list of UNO shapes
+ <member>maShapeList</member> and the list of accessible objects.
+ @param raChildList
+ For every visible shape from the two sources mentioned above one
+ descriptor is added to this list.
+ */
+ void CreateListOfVisibleShapes (ChildDescriptorListType& raChildList);
+
+ /** From the old list of (former) visible shapes remove those that
+ are not member of the new list. Send appropriate events for every
+ such shape.
+ @param raNewChildList
+ The new list of visible children against which the old one
+ is compared.
+ @param raOldChildList
+ The old list of visible children against which the new one
+ is compared.
+ */
+ void RemoveNonVisibleChildren (
+ const ChildDescriptorListType& raNewChildList,
+ ChildDescriptorListType& raOldChildList);
+
+ /** Merge the information that is already known about the visible shapes
+ from the current list into the new list.
+ @param raChildList
+ Information is merged from the current list of visible children
+ to this list.
+ */
+ void MergeAccessibilityInformation (ChildDescriptorListType& raChildList);
+
+ /** If the visible area has changed then send events that signal a
+ change of their bounding boxes for all shapes that are members of
+ both the current and the new list of visible shapes.
+ @param raChildList
+ Events are sent to all entries of this list that already contain
+ an accessible object.
+ */
+ void SendVisibleAreaEvents (ChildDescriptorListType& raChildList);
+
+ /** If children have to be created immediately and not on demand the
+ create the missing accessible objects now.
+ @param raDescriptorList
+ Create an accessible object for every member of this list where
+ that obejct does not already exist.
+ */
+ void CreateAccessibilityObjects (ChildDescriptorListType& raChildList);
+
+ /** Add a single shape. Update all relevant data structures
+ accordingly. Use this method instead of <member>Update()</member>
+ when only a single shape has been added.
+ */
+ void AddShape (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape>& xShape);
+
+ /** Remove a single shape. Update all relevant data structures
+ accordingly. Use this method instead of <member>Update()</member>
+ when only a single shape has been removed.
+ */
+ void RemoveShape (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape>& xShape);
+
+ /** Add the children manager as dispose listener at the given shape so
+ that the associated accessible object can be disposed when the shape
+ is disposed.
+ @param xShape
+ Register at this shape as dispose listener.
+ */
+ void RegisterAsDisposeListener (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape>& xShape);
+
+ /** Remove the children manager as dispose listener at the given shape
+ @param xShape
+ Unregister at this shape as dispose listener.
+ */
+ void UnregisterAsDisposeListener (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape>& xShape);
+};
+
+
+
+
+/** A child descriptor holds a reference to a UNO shape and the
+ corresponding accessible object. There are two use cases:
+ <ol><li>The accessible object is only created on demand and is then
+ initially empty.</li>
+ <li>There is no UNO shape. The accessible object is given as argument
+ to the constructor.</li>
+ </ol>
+ In both cases the child descriptor assumes ownership over the accessible
+ object.
+*/
+class ChildDescriptor
+{
+public:
+ /** Reference to a (partially) visible shape.
+ */
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape> mxShape;
+
+ /** The corresponding accessible object. This reference is initially
+ empty and only replaced by a reference to a new object when that is
+ requested from the outside.
+ */
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible> mxAccessibleShape;
+
+ /** Return a pointer to the implementation object of the accessible
+ shape of this descriptor.
+ @return
+ The result is NULL if either the UNO reference to the accessible
+ shape is empty or it can not be transformed into a pointer to
+ the desired class.
+ */
+ AccessibleShape* GetAccessibleShape (void) const;
+
+ /** set the index _nIndex at the accessible shape
+ @param _nIndex
+ The new index in parent.
+ */
+ void setIndexAtAccessibleShape(sal_Int32 _nIndex);
+
+ /** This flag is set during the visibility calculation and indicates
+ that at one time in this process an event is sent that informs the
+ listners of the creation of a new accessible object. This flags is
+ not reset afterwards. Don't use it unless you know exactly what you
+ are doing.
+ */
+ bool mbCreateEventPending;
+
+ /** Create a new descriptor for the specified shape with empty reference
+ to accessible object.
+ */
+ explicit ChildDescriptor (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShape>& xShape);
+
+ /** Create a new descriptor for the specified shape with empty reference
+ to the original shape.
+ */
+ explicit ChildDescriptor (const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxAccessibleShape);
+
+ ~ChildDescriptor (void);
+
+ /** Dispose the accessible object of this descriptor. If that object
+ does not exist then do nothing.
+ @param rParent
+ The parent of the accessible object to dispose. A child event
+ is sent in its name.
+ */
+ void disposeAccessibleObject (AccessibleContextBase& rParent);
+
+ /** Compare two child descriptors. Take into account that a child
+ descriptor may be based on a UNO shape or, already, on an accessible
+ shape.
+ */
+ inline bool operator == (const ChildDescriptor& aDescriptor) const
+ {
+ return (
+ this == &aDescriptor ||
+ (
+ (mxShape.get() == aDescriptor.mxShape.get() ) &&
+ (mxShape.is() || mxAccessibleShape.get() == aDescriptor.mxAccessibleShape.get())
+ )
+ );
+ }
+
+ /** The ordering defined by this operator is only used in order to be able
+ to put child descriptors in some STL containers. The ordering itself is
+ not so important, its 'features' are not used.
+ */
+ inline bool operator < (const ChildDescriptor& aDescriptor) const
+ {
+ return (mxShape.get() < aDescriptor.mxShape.get());
+ }
+
+};
+
+
+
+} // end of namespace accessibility
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/DGColorNameLookUp.cxx b/svx/source/accessibility/DGColorNameLookUp.cxx
new file mode 100644
index 000000000000..cafe0d6a4a1b
--- /dev/null
+++ b/svx/source/accessibility/DGColorNameLookUp.cxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "DGColorNameLookUp.hxx"
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+
+namespace accessibility {
+
+// Initialize the class instance with NULL. A true instance is created only
+// when the static <member>Instance</member> is called for the first time.
+DGColorNameLookUp* DGColorNameLookUp::mpInstance = NULL;
+
+DGColorNameLookUp& DGColorNameLookUp::Instance (void)
+{
+ // Using double check pattern to make sure that exactly one instance of
+ // the shape type handler is instantiated.
+ if (mpInstance == NULL)
+ {
+ SolarMutexGuard aGuard;
+ if (mpInstance == NULL)
+ {
+ // Create the single instance of the color name look up.
+ mpInstance = new DGColorNameLookUp();
+ }
+ }
+
+ return *mpInstance;
+}
+
+
+
+
+OUString DGColorNameLookUp::LookUpColor (long int nColor) const
+{
+ OUString sColorName;
+ tColorValueToNameMap::const_iterator I;
+ I = maColorValueToNameMap.find (nColor);
+ if (I != maColorValueToNameMap.end())
+ // Found the color value. Return the associated name.
+ sColorName = I->second;
+ else
+ {
+ // Did not find the given color. Append its rgb tuple to the
+ // description.
+ ::rtl::OUStringBuffer sNameBuffer;
+ sNameBuffer.append (sal_Unicode('#'));
+ sNameBuffer.append (nColor, 16);
+ sColorName = sNameBuffer.makeStringAndClear();
+ }
+ return sColorName;
+}
+
+
+
+
+DGColorNameLookUp::DGColorNameLookUp (void)
+{
+ uno::Sequence<OUString> aNames;
+ uno::Reference<container::XNameAccess> xNA;
+
+ try
+ {
+ // Create color table in which to look up the given color.
+ uno::Reference<container::XNameContainer> xColorTable (
+ ::comphelper::getProcessServiceFactory()->createInstance(
+ OUString::createFromAscii("com.sun.star.drawing.ColorTable")),
+ uno::UNO_QUERY);
+
+ // Get list of color names in order to iterate over the color table.
+ xNA = uno::Reference<container::XNameAccess>(xColorTable, uno::UNO_QUERY);
+ if (xNA.is())
+ {
+ // Look the solar mutex here as workarround for missing lock in
+ // called function.
+ SolarMutexGuard aGuard;
+ aNames = xNA->getElementNames();
+ }
+ }
+ catch (uno::RuntimeException e)
+ {
+ // When an excpetion occured then whe have an empty name sequence
+ // and the loop below is not entered.
+ }
+
+ // Fill the map to convert from numerical color values to names.
+ if (xNA.is())
+ for (long int i=0; i<aNames.getLength(); i++)
+ {
+ // Get the numerical value for the i-th color name.
+ try
+ {
+ uno::Any aColor (xNA->getByName (aNames[i]));
+ long nColor = 0;
+ aColor >>= nColor;
+ maColorValueToNameMap[nColor] = aNames[i];
+ }
+ catch (uno::RuntimeException e)
+ {
+ // Ignore the exception: the color who lead to the excpetion
+ // is not included into the map.
+ }
+ }
+}
+
+
+
+
+DGColorNameLookUp::~DGColorNameLookUp (void)
+{
+ maColorValueToNameMap.clear();
+}
+
+} // end of namespace accessibility
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/DescriptionGenerator.cxx b/svx/source/accessibility/DescriptionGenerator.cxx
new file mode 100644
index 000000000000..999b155ee1c5
--- /dev/null
+++ b/svx/source/accessibility/DescriptionGenerator.cxx
@@ -0,0 +1,485 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "DescriptionGenerator.hxx"
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/drawing/XShapeDescriptor.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/style/XStyle.hpp>
+#include <comphelper/processfactory.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#include <com/sun/star/uno/Exception.hpp>
+
+// Includes for string resources.
+#include "accessibility.hrc"
+#include "svdstr.hrc"
+#include <svx/dialmgr.hxx>
+#include <tools/string.hxx>
+
+#include <svx/xdef.hxx>
+#include "unoapi.hxx"
+#include "accessibility.hrc"
+#include "DGColorNameLookUp.hxx"
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+
+void SvxUnogetInternalNameForItem( const sal_Int16 nWhich, const rtl::OUString& rApiName, String& rInternalName ) throw();
+
+namespace accessibility {
+
+
+DescriptionGenerator::DescriptionGenerator (
+ const uno::Reference<drawing::XShape>& xShape)
+ : mxShape (xShape),
+ mxSet (mxShape, uno::UNO_QUERY),
+ mbIsFirstProperty (true)
+{
+}
+
+
+
+
+DescriptionGenerator::~DescriptionGenerator (void)
+{
+}
+
+
+
+
+void DescriptionGenerator::Initialize (sal_Int32 nResourceId)
+{
+ // Get the string from the resource for the specified id.
+ OUString sPrefix;
+ {
+ SolarMutexGuard aGuard;
+ sPrefix = OUString (SVX_RESSTR (nResourceId));
+ }
+
+ // Forward the call with the resulting string.
+ Initialize (sPrefix);
+}
+
+
+
+
+void DescriptionGenerator::Initialize (::rtl::OUString sPrefix)
+{
+ msDescription = sPrefix;
+ if (mxSet.is())
+ {
+ {
+ SolarMutexGuard aGuard;
+
+ msDescription.append (sal_Unicode (' '));
+ msDescription.append (OUString (SVX_RESSTR(RID_SVXSTR_A11Y_WITH)));
+ msDescription.append (sal_Unicode (' '));
+
+ msDescription.append (OUString (SVX_RESSTR (RID_SVXSTR_A11Y_STYLE)));
+ msDescription.append (sal_Unicode ('='));
+ }
+
+ try
+ {
+ if (mxSet.is())
+ {
+ uno::Any aValue = mxSet->getPropertyValue (OUString::createFromAscii ("Style"));
+ uno::Reference<container::XNamed> xStyle (aValue, uno::UNO_QUERY);
+ if (xStyle.is())
+ msDescription.append (xStyle->getName());
+ }
+ else
+ msDescription.append (
+ OUString::createFromAscii("<no style>"));
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException)
+ {
+ msDescription.append (
+ OUString::createFromAscii("<unknown>"));
+ }
+ }
+}
+
+
+
+
+::rtl::OUString DescriptionGenerator::operator() (void)
+{
+ msDescription.append (sal_Unicode ('.'));
+ return msDescription.makeStringAndClear();
+}
+
+
+
+
+void DescriptionGenerator::AddProperty (
+ const OUString& sPropertyName,
+ PropertyType aType,
+ const sal_Int32 nLocalizedNameId,
+ long nWhichId)
+{
+ OUString sLocalizedName;
+ {
+ SolarMutexGuard aGuard;
+ sLocalizedName = SVX_RESSTR (nLocalizedNameId);
+ }
+ AddProperty (sPropertyName, aType, sLocalizedName, nWhichId);
+}
+
+
+
+
+void DescriptionGenerator::AddProperty (const OUString& sPropertyName,
+ PropertyType aType, const OUString& sLocalizedName, long nWhichId)
+{
+ uno::Reference<beans::XPropertyState> xState (mxShape, uno::UNO_QUERY);
+ if (xState.is()
+ && xState->getPropertyState(sPropertyName)!=beans::PropertyState_DEFAULT_VALUE)
+ if (mxSet.is())
+ {
+ // Append a seperator from previous Properties.
+ if ( ! mbIsFirstProperty)
+ msDescription.append (sal_Unicode (','));
+ else
+ {
+ SolarMutexGuard aGuard;
+
+ msDescription.append (sal_Unicode (' '));
+ msDescription.append (OUString (SVX_RESSTR(RID_SVXSTR_A11Y_AND)));
+ msDescription.append (sal_Unicode (' '));
+ mbIsFirstProperty = false;
+ }
+
+ // Delegate to type specific property handling.
+ switch (aType)
+ {
+ case COLOR:
+ AddColor (sPropertyName, sLocalizedName);
+ break;
+ case INTEGER:
+ AddInteger (sPropertyName, sLocalizedName);
+ break;
+ case STRING:
+ AddString (sPropertyName, sLocalizedName, nWhichId);
+ break;
+ case FILL_STYLE:
+ AddFillStyle (sPropertyName, sLocalizedName);
+ break;
+ }
+ }
+}
+
+
+
+
+void DescriptionGenerator::AppendString (const ::rtl::OUString& sString)
+{
+ msDescription.append (sString);
+}
+
+
+
+
+void DescriptionGenerator::AddLineProperties (void)
+{
+ AddProperty (OUString::createFromAscii ("LineColor"),
+ DescriptionGenerator::COLOR,
+ SIP_XA_LINECOLOR);
+ AddProperty (OUString::createFromAscii ("LineDashName"),
+ DescriptionGenerator::STRING,
+ SIP_XA_LINEDASH,
+ XATTR_LINEDASH);
+ AddProperty (OUString::createFromAscii ("LineWidth"),
+ DescriptionGenerator::INTEGER,
+ SIP_XA_LINEWIDTH);
+}
+
+
+
+
+/** The fill style is described by the property "FillStyle". Depending on
+ its value a hatch-, gradient-, or bitmap name is appended.
+*/
+void DescriptionGenerator::AddFillProperties (void)
+{
+ AddProperty (OUString::createFromAscii ("FillStyle"),
+ DescriptionGenerator::FILL_STYLE,
+ SIP_XA_FILLSTYLE);
+}
+
+
+
+
+void DescriptionGenerator::Add3DProperties (void)
+{
+ AddProperty (OUString::createFromAscii ("D3DMaterialColor"),
+ DescriptionGenerator::COLOR,
+ RID_SVXSTR_A11Y_3D_MATERIAL_COLOR);
+ AddLineProperties ();
+ AddFillProperties ();
+}
+
+
+
+
+void DescriptionGenerator::AddTextProperties (void)
+{
+ AddProperty (OUString::createFromAscii ("CharColor"),
+ DescriptionGenerator::COLOR);
+ AddFillProperties ();
+}
+
+
+
+
+/** Search for the given color in the global color table. If found append
+ its name to the description. Otherwise append its RGB tuple.
+*/
+void DescriptionGenerator::AddColor (const OUString& sPropertyName,
+ const OUString& sLocalizedName)
+{
+ msDescription.append (sLocalizedName);
+ msDescription.append (sal_Unicode('='));
+
+ try
+ {
+
+ long nValue(0);
+ if (mxSet.is())
+ {
+ uno::Any aValue = mxSet->getPropertyValue (sPropertyName);
+ aValue >>= nValue;
+ }
+
+ msDescription.append (DGColorNameLookUp::Instance().LookUpColor (nValue));
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException)
+ {
+ msDescription.append (
+ OUString::createFromAscii("<unknown>"));
+ }
+}
+
+
+
+
+void DescriptionGenerator::AddUnknown (const OUString& /*sPropertyName*/,
+ const OUString& sLocalizedName)
+{
+ // uno::Any aValue = mxSet->getPropertyValue (sPropertyName);
+ msDescription.append (sLocalizedName);
+}
+
+
+
+
+void DescriptionGenerator::AddInteger (const OUString& sPropertyName,
+ const OUString& sLocalizedName)
+{
+ msDescription.append (sLocalizedName);
+ msDescription.append (sal_Unicode('='));
+
+ try
+ {
+ if (mxSet.is())
+ {
+ uno::Any aValue = mxSet->getPropertyValue (sPropertyName);
+ long nValue = 0;
+ aValue >>= nValue;
+ msDescription.append (nValue);
+ }
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException)
+ {
+ msDescription.append (
+ OUString::createFromAscii("<unknown>"));
+ }
+}
+
+
+
+
+void DescriptionGenerator::AddString (const OUString& sPropertyName,
+ const OUString& sLocalizedName, long nWhichId)
+{
+ msDescription.append (sLocalizedName);
+ msDescription.append (sal_Unicode('='));
+
+ try
+ {
+ if (mxSet.is())
+ {
+ uno::Any aValue = mxSet->getPropertyValue (sPropertyName);
+ OUString sValue;
+ aValue >>= sValue;
+
+ if (nWhichId >= 0)
+ {
+ SolarMutexGuard aGuard;
+ String sLocalizedValue;
+ SvxUnogetInternalNameForItem (sal::static_int_cast<sal_Int16>(nWhichId),
+ sValue, sLocalizedValue);
+ msDescription.append (sLocalizedValue);
+ }
+ else
+ msDescription.append (sValue);
+ }
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException)
+ {
+ msDescription.append (
+ OUString::createFromAscii("<unknown>"));
+ }
+}
+
+
+
+
+void DescriptionGenerator::AddFillStyle (const OUString& sPropertyName,
+ const OUString& sLocalizedName)
+{
+ msDescription.append (sLocalizedName);
+ msDescription.append (sal_Unicode('='));
+
+ try
+ {
+ if (mxSet.is())
+ {
+ uno::Any aValue = mxSet->getPropertyValue (sPropertyName);
+ drawing::FillStyle aFillStyle;
+ aValue >>= aFillStyle;
+
+ // Get the fill style name from the resource.
+ OUString sFillStyleName;
+ {
+ SolarMutexGuard aGuard;
+ switch (aFillStyle)
+ {
+ case drawing::FillStyle_NONE:
+ sFillStyleName = SVX_RESSTR(RID_SVXSTR_A11Y_FILLSTYLE_NONE);
+ break;
+ case drawing::FillStyle_SOLID:
+ sFillStyleName = SVX_RESSTR(RID_SVXSTR_A11Y_FILLSTYLE_SOLID);
+ break;
+ case drawing::FillStyle_GRADIENT:
+ sFillStyleName = SVX_RESSTR(RID_SVXSTR_A11Y_FILLSTYLE_GRADIENT);
+ break;
+ case drawing::FillStyle_HATCH:
+ sFillStyleName = SVX_RESSTR(RID_SVXSTR_A11Y_FILLSTYLE_HATCH);
+ break;
+ case drawing::FillStyle_BITMAP:
+ sFillStyleName = SVX_RESSTR(RID_SVXSTR_A11Y_FILLSTYLE_BITMAP);
+ break;
+ case drawing::FillStyle_MAKE_FIXED_SIZE:
+ break;
+ }
+ }
+ msDescription.append (sFillStyleName);
+
+ // Append the appropriate properties.
+ switch (aFillStyle)
+ {
+ case drawing::FillStyle_NONE:
+ break;
+ case drawing::FillStyle_SOLID:
+ AddProperty (OUString::createFromAscii ("FillColor"),
+ COLOR,
+ SIP_XA_FILLCOLOR);
+ break;
+ case drawing::FillStyle_GRADIENT:
+ AddProperty (OUString::createFromAscii ("FillGradientName"),
+ STRING,
+ SIP_XA_FILLGRADIENT,
+ XATTR_FILLGRADIENT);
+ break;
+ case drawing::FillStyle_HATCH:
+ AddProperty (OUString::createFromAscii ("FillColor"),
+ COLOR,
+ SIP_XA_FILLCOLOR);
+ AddProperty (OUString::createFromAscii ("FillHatchName"),
+ STRING,
+ SIP_XA_FILLHATCH,
+ XATTR_FILLHATCH);
+ break;
+ case drawing::FillStyle_BITMAP:
+ AddProperty (OUString::createFromAscii ("FillBitmapName"),
+ STRING,
+ SIP_XA_FILLBITMAP,
+ XATTR_FILLBITMAP);
+ break;
+ case drawing::FillStyle_MAKE_FIXED_SIZE:
+ break;
+ }
+ }
+ }
+ catch (::com::sun::star::beans::UnknownPropertyException)
+ {
+ msDescription.append (
+ OUString::createFromAscii("<unknown>"));
+ }
+}
+
+
+
+
+void DescriptionGenerator::AddPropertyNames (void)
+{
+ if (mxSet.is())
+ {
+ uno::Reference<beans::XPropertySetInfo> xInfo (mxSet->getPropertySetInfo());
+ if (xInfo.is())
+ {
+ uno::Sequence<beans::Property> aPropertyList (xInfo->getProperties ());
+ for (int i=0; i<aPropertyList.getLength(); i++)
+ {
+ msDescription.append (aPropertyList[i].Name);
+ msDescription.append (sal_Unicode(','));
+ }
+ }
+ }
+}
+
+
+} // end of namespace accessibility
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/GraphCtlAccessibleContext.cxx b/svx/source/accessibility/GraphCtlAccessibleContext.cxx
new file mode 100644
index 000000000000..8abc8322e7d4
--- /dev/null
+++ b/svx/source/accessibility/GraphCtlAccessibleContext.cxx
@@ -0,0 +1,1027 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/uuid.h>
+#include <tools/debug.hxx>
+#include <tools/gen.hxx>
+#include <svl/smplhint.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <svtools/colorcfg.hxx>
+#include <comphelper/accessibleeventnotifier.hxx>
+#include <sdrpaintwindow.hxx>
+
+//===== local includes ========================================================
+#include <svx/ShapeTypeHandler.hxx>
+#include <svx/AccessibleShapeInfo.hxx>
+#include "GraphCtlAccessibleContext.hxx"
+#include <svx/graphctl.hxx>
+#include <svx/dialogs.hrc>
+#include "accessibility.hrc"
+#include <svx/svdpage.hxx>
+#include <svx/unomod.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/sdrhittesthelper.hxx>
+
+//===== namespaces ===========================================================
+
+using namespace ::cppu;
+using namespace ::osl;
+using ::rtl::OUString;
+using namespace ::accessibility;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::accessibility;
+
+using rtl::OUString;
+
+//===== internal ============================================================
+
+/** initialize this component and set default values */
+SvxGraphCtrlAccessibleContext::SvxGraphCtrlAccessibleContext(
+ const Reference< XAccessible >& rxParent,
+ GraphCtrl& rRepr,
+ const OUString* pName,
+ const OUString* pDesc ) :
+
+ SvxGraphCtrlAccessibleContext_Base( m_aMutex ),
+ mxParent( rxParent ),
+ mpControl( &rRepr ),
+ mpModel (NULL),
+ mpPage (NULL),
+ mpView (NULL),
+ mnClientId( 0 ),
+ mbDisposed( sal_False )
+{
+ if (mpControl != NULL)
+ {
+ mpModel = mpControl->GetSdrModel();
+ if (mpModel != NULL)
+ mpPage = (SdrPage*)mpModel->GetPage( 0 );
+ mpView = mpControl->GetSdrView();
+
+ if( mpModel == NULL || mpPage == NULL || mpView == NULL )
+ {
+ mbDisposed = true;
+ // Set all the pointers to NULL just in case they are used as
+ // a disposed flag.
+ mpModel = NULL;
+ mpPage = NULL;
+ mpView = NULL;
+ }
+ }
+
+ if( pName )
+ {
+ msName = *pName;
+ }
+ else
+ {
+ ::SolarMutexGuard aSolarGuard;
+ msName = SVX_RESSTR( RID_SVXSTR_GRAPHCTRL_ACC_NAME );
+ }
+
+ if( pDesc )
+ {
+ msDescription = *pDesc;
+ }
+ else
+ {
+ ::SolarMutexGuard aSolarGuard;
+ msDescription = SVX_RESSTR( RID_SVXSTR_GRAPHCTRL_ACC_DESCRIPTION );
+ }
+
+ maTreeInfo.SetSdrView( mpView );
+ maTreeInfo.SetWindow( mpControl );
+ maTreeInfo.SetViewForwarder( const_cast<SvxGraphCtrlAccessibleContext*>(this) );
+}
+
+//-----------------------------------------------------------------------------
+
+/** on destruction, this component is disposed and all dispose listeners
+ are called, except if this component was already disposed */
+SvxGraphCtrlAccessibleContext::~SvxGraphCtrlAccessibleContext()
+{
+ disposing();
+}
+
+//-----------------------------------------------------------------------------
+
+/** returns the XAccessible interface for a given SdrObject.
+ Multiple calls for the same SdrObject return the same XAccessible.
+*/
+Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessible( const SdrObject* pObj )
+{
+ Reference<XAccessible> xAccessibleShape;
+
+ if( pObj )
+ {
+ // see if we already created an XAccessible for the given SdrObject
+ ShapesMapType::iterator iter = mxShapes.find( pObj );
+
+ if( iter != mxShapes.end() )
+ {
+ // if we already have one, return it
+ xAccessibleShape = (*iter).second;
+ }
+ else
+ {
+ // create a new one and remember in our internal map
+ Reference< XShape > xShape( Reference< XShape >::query( (const_cast<SdrObject*>(pObj))->getUnoShape() ) );
+
+ AccessibleShapeInfo aShapeInfo (xShape,mxParent);
+ // Create accessible object that corresponds to the descriptor's shape.
+ AccessibleShape* pAcc = ShapeTypeHandler::Instance().CreateAccessibleObject(
+ aShapeInfo, maTreeInfo);
+ xAccessibleShape = pAcc;
+ if (pAcc != NULL)
+ {
+ pAcc->acquire();
+ // Now that we acquired the new accessible shape we can
+ // safely call its Init() method.
+ pAcc->Init ();
+ }
+ mxShapes[pObj] = pAcc;
+
+ // Create event and inform listeners of the object creation.
+ CommitChange( AccessibleEventId::CHILD, makeAny( xAccessibleShape ), makeAny( Reference<XAccessible>() ) );
+ }
+ }
+
+ return xAccessibleShape;
+}
+
+//===== XAccessible =========================================================
+
+Reference< XAccessibleContext > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleContext( void ) throw( RuntimeException )
+{
+ return this;
+}
+
+//===== XAccessibleComponent ================================================
+
+sal_Bool SAL_CALL SvxGraphCtrlAccessibleContext::containsPoint( const awt::Point& rPoint ) throw( RuntimeException )
+{
+ // no guard -> done in getSize()
+ awt::Size aSize (getSize());
+ return (rPoint.X >= 0)
+ && (rPoint.X < aSize.Width)
+ && (rPoint.Y >= 0)
+ && (rPoint.Y < aSize.Height);
+}
+
+//-----------------------------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleAtPoint( const awt::Point& rPoint ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XAccessible > xAccessible;
+
+ if( mpControl )
+ {
+ Point aPnt( rPoint.X, rPoint.Y );
+ mpControl->PixelToLogic( aPnt );
+
+ SdrObject* pObj = 0;
+
+ if(mpView && mpView->GetSdrPageView())
+ {
+ pObj = SdrObjListPrimitiveHit(*mpPage, aPnt, 1, *mpView->GetSdrPageView(), 0, false);
+ }
+
+ if( pObj )
+ xAccessible = getAccessible( pObj );
+ }
+ else
+ {
+ throw DisposedException();
+ }
+
+ return xAccessible;
+}
+
+//-----------------------------------------------------------------------------
+
+awt::Rectangle SAL_CALL SvxGraphCtrlAccessibleContext::getBounds() throw( RuntimeException )
+{
+ // no guard -> done in GetBoundingBox()
+ Rectangle aCoreBounds( GetBoundingBox() );
+ awt::Rectangle aBounds;
+ aBounds.X = aCoreBounds.getX();
+ aBounds.Y = aCoreBounds.getY();
+ aBounds.Width = aCoreBounds.getWidth();
+ aBounds.Height = aCoreBounds.getHeight();
+ return aBounds;
+}
+
+//-----------------------------------------------------------------------------
+
+awt::Point SAL_CALL SvxGraphCtrlAccessibleContext::getLocation() throw( RuntimeException )
+{
+ // no guard -> done in GetBoundingBox()
+ Rectangle aRect( GetBoundingBox() );
+ return awt::Point( aRect.getX(), aRect.getY() );
+}
+
+//-----------------------------------------------------------------------------
+
+awt::Point SAL_CALL SvxGraphCtrlAccessibleContext::getLocationOnScreen() throw( RuntimeException )
+{
+ // no guard -> done in GetBoundingBoxOnScreen()
+ Rectangle aRect( GetBoundingBoxOnScreen() );
+ return awt::Point( aRect.getX(), aRect.getY() );
+}
+
+//-----------------------------------------------------------------------------
+
+awt::Size SAL_CALL SvxGraphCtrlAccessibleContext::getSize() throw( RuntimeException )
+{
+ // no guard -> done in GetBoundingBox()
+ Rectangle aRect( GetBoundingBox() );
+ return awt::Size( aRect.getWidth(), aRect.getHeight() );
+}
+
+
+//===== XAccessibleContext ==================================================
+
+sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleChildCount( void ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( NULL == mpPage )
+ throw DisposedException();
+
+ return mpPage->GetObjCount();
+}
+
+//-----------------------------------------------------------------------------
+
+/** returns the SdrObject at index nIndex from the model of this graph */
+SdrObject* SvxGraphCtrlAccessibleContext::getSdrObject( sal_Int32 nIndex )
+ throw( RuntimeException, lang::IndexOutOfBoundsException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( NULL == mpPage )
+ throw DisposedException();
+
+ if( (nIndex < 0) || ( static_cast<sal_uInt32>(nIndex) >= mpPage->GetObjCount() ) )
+ throw lang::IndexOutOfBoundsException();
+
+ return mpPage->GetObj( nIndex );
+}
+
+//-----------------------------------------------------------------------------
+
+/** sends an AccessibleEventObject to all added XAccessibleEventListeners */
+void SvxGraphCtrlAccessibleContext::CommitChange (
+ sal_Int16 nEventId,
+ const uno::Any& rNewValue,
+ const uno::Any& rOldValue)
+{
+ AccessibleEventObject aEvent (
+ static_cast<uno::XWeak*>(this),
+ nEventId,
+ rNewValue,
+ rOldValue);
+
+ FireEvent (aEvent);
+}
+
+/** sends an AccessibleEventObject to all added XAccessibleEventListeners */
+void SvxGraphCtrlAccessibleContext::FireEvent (const AccessibleEventObject& aEvent)
+{
+ if (mnClientId)
+ comphelper::AccessibleEventNotifier::addEvent( mnClientId, aEvent );
+}
+
+//-----------------------------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleChild( sal_Int32 nIndex )
+ throw( RuntimeException, lang::IndexOutOfBoundsException )
+{
+ ::SolarMutexGuard aGuard;
+
+ return getAccessible( getSdrObject( nIndex ) );
+}
+
+//-----------------------------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleParent( void ) throw( RuntimeException )
+{
+ return mxParent;
+}
+
+//-----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleIndexInParent( void ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+ // Use a simple but slow solution for now. Optimize later.
+
+ // Iterate over all the parent's children and search for this object.
+ if( mxParent.is() )
+ {
+ Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() );
+ if( xParentContext.is() )
+ {
+ sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
+ for( sal_Int32 i = 0 ; i < nChildCount ; ++i )
+ {
+ Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) );
+ if( xChild.is() )
+ {
+ Reference< XAccessibleContext > xChildContext = xChild->getAccessibleContext();
+ if( xChildContext == ( XAccessibleContext* ) this )
+ return i;
+ }
+ }
+ }
+ }
+
+ // Return -1 to indicate that this object's parent does not know about the
+ // object.
+ return -1;
+}
+
+//-----------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleRole( void ) throw( RuntimeException )
+{
+ return AccessibleRole::PANEL;
+}
+
+//-----------------------------------------------------------------------------
+
+OUString SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleDescription( void ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+ return msDescription;
+}
+
+//-----------------------------------------------------------------------------
+
+OUString SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleName( void ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+ return msName;
+}
+
+//-----------------------------------------------------------------------------
+
+/** Return empty reference to indicate that the relation set is not
+ supported.
+*/
+Reference< XAccessibleRelationSet > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleRelationSet( void ) throw( RuntimeException )
+{
+ return Reference< XAccessibleRelationSet >();
+}
+
+//-----------------------------------------------------------------------------
+
+Reference< XAccessibleStateSet > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleStateSet( void ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
+
+ if ( rBHelper.bDisposed || mbDisposed )
+ {
+ pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+ }
+ else
+ {
+ // pStateSetHelper->AddState( AccessibleStateType::ENABLED );
+ // pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
+ pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
+ if( mpControl->HasFocus() )
+ pStateSetHelper->AddState( AccessibleStateType::FOCUSED );
+ pStateSetHelper->AddState( AccessibleStateType::OPAQUE );
+ pStateSetHelper->AddState( AccessibleStateType::SHOWING );
+ pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
+ }
+
+ return pStateSetHelper;
+}
+
+//-----------------------------------------------------------------------------
+
+lang::Locale SAL_CALL SvxGraphCtrlAccessibleContext::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( mxParent.is() )
+ {
+ Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() );
+ if( xParentContext.is() )
+ return xParentContext->getLocale();
+ }
+
+ // No parent. Therefore throw exception to indicate this cluelessness.
+ throw IllegalAccessibleComponentStateException();
+}
+
+//===== XAccessibleEventListener ============================================
+
+void SAL_CALL SvxGraphCtrlAccessibleContext::addEventListener( const Reference< XAccessibleEventListener >& xListener )
+ throw( RuntimeException )
+{
+ if (xListener.is())
+ {
+ ::SolarMutexGuard aGuard;
+ if (!mnClientId)
+ mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
+ comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL SvxGraphCtrlAccessibleContext::removeEventListener( const Reference< XAccessibleEventListener >& xListener )
+ throw( RuntimeException )
+{
+ if (xListener.is())
+ {
+ ::SolarMutexGuard aGuard;
+
+ sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
+ if ( !nListenerCount )
+ {
+ // no listeners anymore
+ // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+ // and at least to us not firing any events anymore, in case somebody calls
+ // NotifyAccessibleEvent, again
+ comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
+ mnClientId = 0;
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL SvxGraphCtrlAccessibleContext::addFocusListener( const Reference< awt::XFocusListener >& xListener )
+ throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( xListener.is() )
+ {
+ Reference< ::com::sun::star::awt::XWindow > xWindow( VCLUnoHelper::GetInterface( mpControl ) );
+ if( xWindow.is() )
+ xWindow->addFocusListener( xListener );
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL SvxGraphCtrlAccessibleContext::removeFocusListener( const Reference< awt::XFocusListener >& xListener )
+ throw (RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( xListener.is() )
+ {
+ Reference< ::com::sun::star::awt::XWindow > xWindow = VCLUnoHelper::GetInterface( mpControl );
+ if( xWindow.is() )
+ xWindow->removeFocusListener( xListener );
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL SvxGraphCtrlAccessibleContext::grabFocus() throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( NULL == mpControl )
+ throw DisposedException();
+
+ mpControl->GrabFocus();
+}
+
+//-----------------------------------------------------------------------------
+
+Any SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleKeyBinding() throw( RuntimeException )
+{
+ // here is no implementation, because here are no KeyBindings for every object
+ return Any();
+}
+
+
+
+
+
+sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getForeground (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ svtools::ColorConfig aColorConfig;
+ UINT32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
+ return static_cast<sal_Int32>(nColor);
+}
+
+
+
+
+sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getBackground (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ UINT32 nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
+ return static_cast<sal_Int32>(nColor);
+}
+
+
+//===== XServiceInfo ========================================================
+
+OUString SAL_CALL SvxGraphCtrlAccessibleContext::getImplementationName( void ) throw( RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvxGraphCtrlAccessibleContext" ) );
+}
+
+//-----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL SvxGraphCtrlAccessibleContext::supportsService( const OUString& sServiceName ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+ // Iterate over all supported service names and return true if on of them
+ // matches the given name.
+ Sequence< OUString > aSupportedServices( getSupportedServiceNames() );
+ int nLenght = aSupportedServices.getLength();
+
+ for( int i = 0 ; i < nLenght ; ++i )
+ {
+ if( sServiceName == aSupportedServices[ i ] )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//-----------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL SvxGraphCtrlAccessibleContext::getSupportedServiceNames( void ) throw( RuntimeException )
+{
+ Sequence< OUString > aSNs( 3 );
+
+ aSNs[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.Accessible" ) );
+ aSNs[1] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) );
+ aSNs[2] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AccessibleGraphControl" ) );
+
+ return aSNs;
+}
+
+//===== XTypeProvider =======================================================
+
+Sequence<sal_Int8> SAL_CALL SvxGraphCtrlAccessibleContext::getImplementationId( void ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+ return getUniqueId();
+}
+
+//===== XServiceName ========================================================
+
+OUString SvxGraphCtrlAccessibleContext::getServiceName( void ) throw( RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) );
+}
+
+//===== XAccessibleSelection =============================================
+
+void SAL_CALL SvxGraphCtrlAccessibleContext::selectAccessibleChild( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( NULL == mpView )
+ throw DisposedException();
+
+ SdrObject* pObj = getSdrObject( nIndex );
+
+ if( pObj )
+ mpView->MarkObj( pObj, mpView->GetSdrPageView());
+}
+
+//-----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL SvxGraphCtrlAccessibleContext::isAccessibleChildSelected( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( NULL == mpView )
+ throw DisposedException();
+
+ return mpView->IsObjMarked( getSdrObject( nIndex ) );
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL SvxGraphCtrlAccessibleContext::clearAccessibleSelection() throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( NULL == mpView )
+ throw DisposedException();
+
+ mpView->UnmarkAllObj();
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL SvxGraphCtrlAccessibleContext::selectAllAccessibleChildren() throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( NULL == mpView )
+ throw DisposedException();
+
+ mpView->MarkAllObj();
+}
+
+//-----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getSelectedAccessibleChildCount() throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( NULL == mpView )
+ throw DisposedException();
+
+ const SdrMarkList& rList = mpView->GetMarkedObjectList();
+ return rList.GetMarkCount();
+}
+
+//-----------------------------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getSelectedAccessibleChild( sal_Int32 nIndex )
+ throw( lang::IndexOutOfBoundsException, RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ checkChildIndexOnSelection( nIndex );
+
+ Reference< XAccessible > xAccessible;
+
+ const SdrMarkList& rList = mpView->GetMarkedObjectList();
+ SdrObject* pObj = rList.GetMark(nIndex)->GetMarkedSdrObj();
+ if( pObj )
+ xAccessible = getAccessible( pObj );
+
+ return xAccessible;
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL SvxGraphCtrlAccessibleContext::deselectAccessibleChild( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ checkChildIndexOnSelection( nIndex );
+
+ if( mpView )
+ {
+ const SdrMarkList& rList = mpView->GetMarkedObjectList();
+
+ SdrObject* pObj = getSdrObject( nIndex );
+ if( pObj )
+ {
+ SdrMarkList aRefList( rList );
+
+ SdrPageView* pPV = mpView->GetSdrPageView();
+ mpView->UnmarkAllObj( pPV );
+
+ sal_uInt32 nCount = aRefList.GetMarkCount();
+ sal_uInt32 nMark;
+ for( nMark = 0; nMark < nCount; nMark++ )
+ {
+ if( aRefList.GetMark(nMark)->GetMarkedSdrObj() != pObj )
+ mpView->MarkObj( aRefList.GetMark(nMark)->GetMarkedSdrObj(), pPV );
+ }
+ }
+ }
+}
+
+//===== internals ========================================================
+
+void SvxGraphCtrlAccessibleContext::checkChildIndex( long nIndex ) throw( lang::IndexOutOfBoundsException )
+{
+ if( nIndex < 0 || nIndex >= getAccessibleChildCount() )
+ throw lang::IndexOutOfBoundsException();
+}
+
+//-----------------------------------------------------------------------------
+
+void SvxGraphCtrlAccessibleContext::checkChildIndexOnSelection( long nIndex ) throw( lang::IndexOutOfBoundsException )
+{
+ if( nIndex < 0 || nIndex >= getSelectedAccessibleChildCount() )
+ throw lang::IndexOutOfBoundsException();
+}
+
+//-----------------------------------------------------------------------------
+
+void SvxGraphCtrlAccessibleContext::setName( const OUString& rName )
+{
+ ::SolarMutexGuard aGuard;
+
+ msName = rName;
+}
+
+//-----------------------------------------------------------------------------
+
+void SvxGraphCtrlAccessibleContext::setDescription( const OUString& rDescr )
+{
+ ::SolarMutexGuard aGuard;
+
+ msDescription = rDescr;
+}
+
+
+
+
+/** Replace the model, page, and view pointers by the ones provided
+ (explicitly and implicitly).
+*/
+void SvxGraphCtrlAccessibleContext::setModelAndView (
+ SdrModel* pModel,
+ SdrView* pView)
+{
+ ::SolarMutexGuard aGuard;
+
+ mpModel = pModel;
+ if (mpModel != NULL)
+ mpPage = (SdrPage*)mpModel->GetPage( 0 );
+ mpView = pView;
+
+ if (mpModel == NULL || mpPage == NULL || mpView == NULL)
+ {
+ mbDisposed = true;
+
+ // Set all the pointers to NULL just in case they are used as
+ // a disposed flag.
+ mpModel = NULL;
+ mpPage = NULL;
+ mpView = NULL;
+ }
+
+ maTreeInfo.SetSdrView (mpView);
+}
+
+
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL SvxGraphCtrlAccessibleContext::disposing()
+{
+ ::SolarMutexGuard aGuard;
+
+ if( mbDisposed )
+ return;
+
+ mbDisposed = sal_True;
+
+ mpControl = NULL; // object dies with representation
+ mpView = NULL;
+ mpPage = NULL;
+
+ {
+ ShapesMapType::iterator I;
+
+ for (I=mxShapes.begin(); I!=mxShapes.end(); I++)
+ {
+ XAccessible* pAcc = (*I).second;
+ Reference< XComponent > xComp( pAcc, UNO_QUERY );
+ if( xComp.is() )
+ xComp->dispose();
+
+ (*I).second->release();
+ }
+
+ mxShapes.clear();
+ }
+
+ // Send a disposing to all listeners.
+ if ( mnClientId )
+ {
+ comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
+ mnClientId = 0;
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+Rectangle SvxGraphCtrlAccessibleContext::GetBoundingBoxOnScreen( void ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( NULL == mpControl )
+ throw DisposedException();
+
+ return Rectangle(
+ mpControl->GetAccessibleParentWindow()->OutputToAbsoluteScreenPixel(
+ mpControl->GetPosPixel() ),
+ mpControl->GetSizePixel() );
+}
+
+//-----------------------------------------------------------------------------
+
+/** Calculate the relative coordinates of the bounding box as difference
+ between the absolute coordinates of the bounding boxes of this control
+ and its parent in the accessibility tree.
+*/
+Rectangle SvxGraphCtrlAccessibleContext::GetBoundingBox( void ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ Rectangle aBounds ( 0, 0, 0, 0 );
+
+ Window* pWindow = mpControl;
+ if (pWindow != NULL)
+ {
+ aBounds = pWindow->GetWindowExtentsRelative (NULL);
+ Window* pParent = pWindow->GetAccessibleParentWindow();
+ if (pParent != NULL)
+ {
+ Rectangle aParentRect = pParent->GetWindowExtentsRelative (NULL);
+ aBounds -= aParentRect.TopLeft();
+ }
+ }
+ else
+ throw DisposedException();
+
+ return aBounds;
+}
+
+//-----------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SvxGraphCtrlAccessibleContext::getUniqueId( void )
+{
+ // no guard because it's private -> has to guarded when using it!
+ static OImplementationId* pId = 0;
+ if( !pId )
+ {
+ ::SolarMutexGuard aGuard;
+ if( !pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+//-----------------------------------------------------------------------------
+
+void SvxGraphCtrlAccessibleContext::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+
+ if( pSdrHint )
+ {
+ switch( pSdrHint->GetKind() )
+ {
+ case HINT_OBJCHG:
+ {
+ ShapesMapType::iterator iter = mxShapes.find( pSdrHint->GetObject() );
+
+ if( iter != mxShapes.end() )
+ {
+ // if we already have one, return it
+ AccessibleShape* pShape = (*iter).second;
+
+ if( NULL != pShape )
+ pShape->CommitChange( AccessibleEventId::VISIBLE_DATA_CHANGED, uno::Any(), uno::Any() );
+ }
+ }
+ break;
+
+ case HINT_OBJINSERTED:
+ CommitChange( AccessibleEventId::CHILD, makeAny( getAccessible( pSdrHint->GetObject() ) ) , uno::Any());
+ break;
+ case HINT_OBJREMOVED:
+ CommitChange( AccessibleEventId::CHILD, uno::Any(), makeAny( getAccessible( pSdrHint->GetObject() ) ) );
+ break;
+ case HINT_MODELCLEARED:
+ dispose();
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ const SfxSimpleHint* pSfxHint = PTR_CAST(SfxSimpleHint, &rHint );
+
+ // ist unser SdDrawDocument gerade gestorben?
+ if(pSfxHint && pSfxHint->GetId() == SFX_HINT_DYING)
+ {
+ dispose();
+ }
+ }
+}
+
+//===== IAccessibleViewforwarder ========================================
+
+sal_Bool SvxGraphCtrlAccessibleContext::IsValid (void) const
+{
+ return sal_True;
+}
+
+//-----------------------------------------------------------------------------
+
+Rectangle SvxGraphCtrlAccessibleContext::GetVisibleArea (void) const
+{
+ Rectangle aVisArea;
+
+ if( mpView && mpView->PaintWindowCount())
+ {
+ SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(0L);
+ aVisArea = pPaintWindow->GetVisibleArea();
+ }
+
+ return aVisArea;
+}
+
+//-----------------------------------------------------------------------------
+
+Point SvxGraphCtrlAccessibleContext::LogicToPixel (const Point& rPoint) const
+{
+ if( mpControl )
+ {
+ Rectangle aBBox(mpControl->GetWindowExtentsRelative(NULL));
+ return mpControl->LogicToPixel (rPoint) + aBBox.TopLeft();
+ }
+ else
+ {
+ return rPoint;
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+Size SvxGraphCtrlAccessibleContext::LogicToPixel (const Size& rSize) const
+{
+ if( mpControl )
+ return mpControl->LogicToPixel (rSize);
+ else
+ return rSize;
+}
+
+//-----------------------------------------------------------------------------
+
+Point SvxGraphCtrlAccessibleContext::PixelToLogic (const Point& rPoint) const
+{
+ if( mpControl )
+ return mpControl->PixelToLogic (rPoint);
+ else
+ return rPoint;
+}
+
+//-----------------------------------------------------------------------------
+
+Size SvxGraphCtrlAccessibleContext::PixelToLogic (const Size& rSize) const
+{
+ if( mpControl )
+ return mpControl->PixelToLogic (rSize);
+ else
+ return rSize;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/ShapeTypeHandler.cxx b/svx/source/accessibility/ShapeTypeHandler.cxx
new file mode 100644
index 000000000000..f26e55b1bf8a
--- /dev/null
+++ b/svx/source/accessibility/ShapeTypeHandler.cxx
@@ -0,0 +1,341 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/ShapeTypeHandler.hxx>
+#include <svx/SvxShapeTypes.hxx>
+#include <svx/AccessibleShapeInfo.hxx>
+#include <com/sun/star/drawing/XShapeDescriptor.hpp>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/dialmgr.hxx>
+#include "svdstr.hrc"
+
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+namespace accessibility {
+
+// Pointer to the shape type handler singleton.
+ShapeTypeHandler* ShapeTypeHandler::instance = NULL;
+
+
+// Create an empty reference to an accessible object.
+AccessibleShape*
+ CreateEmptyShapeReference (
+ const AccessibleShapeInfo& /*rShapeInfo*/,
+ const AccessibleShapeTreeInfo& /*rShapeTreeInfo*/,
+ ShapeTypeId /*nId*/)
+{
+ return NULL;
+}
+
+
+
+
+ShapeTypeHandler& ShapeTypeHandler::Instance (void)
+{
+ // Using double check pattern to make sure that exactly one instance of
+ // the shape type handler is instantiated.
+ if (instance == NULL)
+ {
+ SolarMutexGuard aGuard;
+ if (instance == NULL)
+ {
+ // Create the single instance of the shape type handler.
+ instance = new ShapeTypeHandler;
+
+ // Register the basic SVX shape types.
+ RegisterDrawShapeTypes ();
+ }
+ }
+
+ return *instance;
+}
+
+
+
+
+/** The given service name is first transformed into a slot id that
+ identifies the place of the type descriptor. From that descriptor the
+ shape type id is returned.
+*/
+ShapeTypeId ShapeTypeHandler::GetTypeId (const OUString& aServiceName) const
+{
+ tServiceNameToSlotId::iterator I (maServiceNameToSlotId.find (aServiceName));
+ if (I != maServiceNameToSlotId.end())
+ {
+ // long nSlotId = maServiceNameToSlotId[aServiceName];
+ return maShapeTypeDescriptorList[I->second].mnShapeTypeId;
+ }
+ else
+ return -1;
+}
+
+
+
+/** Extract the specified shape's service name and forward the request to
+ the appropriate method.
+*/
+ShapeTypeId ShapeTypeHandler::GetTypeId (const uno::Reference<drawing::XShape>& rxShape) const
+{
+ uno::Reference<drawing::XShapeDescriptor> xDescriptor (rxShape, uno::UNO_QUERY);
+ if (xDescriptor.is())
+ return GetTypeId (xDescriptor->getShapeType());
+ else
+ return -1;
+}
+
+
+
+
+const OUString& ShapeTypeHandler::GetServiceName (ShapeTypeId aTypeId) const
+{
+ return maShapeTypeDescriptorList[aTypeId].msServiceName;
+}
+
+
+
+
+/** This factory method determines the type descriptor for the type of the
+ given shape, then calls the descriptor's create function, and finally
+ initializes the new object.
+*/
+AccessibleShape*
+ ShapeTypeHandler::CreateAccessibleObject (
+ const AccessibleShapeInfo& rShapeInfo,
+ const AccessibleShapeTreeInfo& rShapeTreeInfo) const
+{
+ ShapeTypeId nSlotId (GetSlotId (rShapeInfo.mxShape));
+ AccessibleShape* pShape =
+ maShapeTypeDescriptorList[nSlotId].maCreateFunction (
+ rShapeInfo,
+ rShapeTreeInfo,
+ maShapeTypeDescriptorList[nSlotId].mnShapeTypeId);
+ return pShape;
+}
+
+
+
+
+/** Create the single instance of this class and initialize its list of
+ type descriptors with an entry of an unknown type.
+*/
+ShapeTypeHandler::ShapeTypeHandler (void)
+ : maShapeTypeDescriptorList (1)
+{
+ // Make sure that at least the UNKNOWN entry is present.
+ // Resize the list, if necessary, so that the new type can be inserted.
+ maShapeTypeDescriptorList[0].mnShapeTypeId = UNKNOWN_SHAPE_TYPE;
+ maShapeTypeDescriptorList[0].msServiceName =
+ OUString::createFromAscii ("UNKNOWN_SHAPE_TYPE");
+ maShapeTypeDescriptorList[0].maCreateFunction = CreateEmptyShapeReference;
+ maServiceNameToSlotId[maShapeTypeDescriptorList[0].msServiceName] = 0;
+}
+
+
+
+
+ShapeTypeHandler::~ShapeTypeHandler (void)
+{
+ // Because this class is a singleton and the only instance, whose
+ // destructor has just been called, is pointed to from instance,
+ // we reset the static variable instance, so that further calls to
+ // getInstance do not return an undefined object but create a new
+ // singleton.
+ instance = NULL;
+}
+
+
+
+
+bool ShapeTypeHandler::AddShapeTypeList (int nDescriptorCount,
+ ShapeTypeDescriptor aDescriptorList[])
+{
+ SolarMutexGuard aGuard;
+
+ // Determine first id of new type descriptor(s).
+ int nFirstId = maShapeTypeDescriptorList.size();
+
+ // Resize the list, if necessary, so that the types can be inserted.
+ maShapeTypeDescriptorList.resize (nFirstId + nDescriptorCount);
+
+ for (int i=0; i<nDescriptorCount; i++)
+ {
+ #if OSL_DEBUG_LEVEL > 0
+ ShapeTypeId nId (aDescriptorList[i].mnShapeTypeId);
+ (void)nId;
+ #endif
+
+ // Fill Type descriptor.
+ maShapeTypeDescriptorList[nFirstId+i].mnShapeTypeId = aDescriptorList[i].mnShapeTypeId;
+ maShapeTypeDescriptorList[nFirstId+i].msServiceName = aDescriptorList[i].msServiceName;
+ maShapeTypeDescriptorList[nFirstId+i].maCreateFunction = aDescriptorList[i].maCreateFunction;
+
+ // Update inverse mapping from service name to the descriptor's position.
+ maServiceNameToSlotId[aDescriptorList[i].msServiceName] = nFirstId+i;
+ }
+
+ return true;
+}
+
+
+
+
+#include <tools/string.hxx>
+long ShapeTypeHandler::GetSlotId (const OUString& aServiceName) const
+{
+ tServiceNameToSlotId::iterator I (maServiceNameToSlotId.find (aServiceName));
+ if (I != maServiceNameToSlotId.end())
+ return I->second;
+ else
+ return 0;
+}
+
+
+
+
+// Extract the given shape's service name and forward request to appropriate
+// method.
+long ShapeTypeHandler::GetSlotId (const uno::Reference<drawing::XShape>& rxShape) const
+{
+ uno::Reference<drawing::XShapeDescriptor> xDescriptor (rxShape, uno::UNO_QUERY);
+ if (xDescriptor.is())
+ return GetSlotId (xDescriptor->getShapeType());
+ else
+ return 0;
+}
+
+/// get the accessible base name for an object
+::rtl::OUString
+ ShapeTypeHandler::CreateAccessibleBaseName (const uno::Reference<drawing::XShape>& rxShape)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ sal_Int32 nResourceId;
+ OUString sName;
+
+ switch (ShapeTypeHandler::Instance().GetTypeId (rxShape))
+ {
+ // case DRAWING_3D_POLYGON: was removed in original code in
+ // AccessibleShape::CreateAccessibleBaseName. See issue 11190 for details.
+ // Id can be removed from SvxShapeTypes.hxx as well.
+ case DRAWING_3D_CUBE:
+ nResourceId = STR_ObjNameSingulCube3d;
+ break;
+ case DRAWING_3D_EXTRUDE:
+ nResourceId = STR_ObjNameSingulExtrude3d;
+ break;
+ case DRAWING_3D_LATHE:
+ nResourceId = STR_ObjNameSingulLathe3d;
+ break;
+ case DRAWING_3D_SCENE:
+ nResourceId = STR_ObjNameSingulScene3d;
+ break;
+ case DRAWING_3D_SPHERE:
+ nResourceId = STR_ObjNameSingulSphere3d;
+ break;
+ case DRAWING_CAPTION:
+ nResourceId = STR_ObjNameSingulCAPTION;
+ break;
+ case DRAWING_CLOSED_BEZIER:
+ nResourceId = STR_ObjNameSingulPATHFILL;
+ break;
+ case DRAWING_CLOSED_FREEHAND:
+ nResourceId = STR_ObjNameSingulFREEFILL;
+ break;
+ case DRAWING_CONNECTOR:
+ nResourceId = STR_ObjNameSingulEDGE;
+ break;
+ case DRAWING_CONTROL:
+ nResourceId = STR_ObjNameSingulUno;
+ break;
+ case DRAWING_ELLIPSE:
+ nResourceId = STR_ObjNameSingulCIRCE;
+ break;
+ case DRAWING_GROUP:
+ nResourceId = STR_ObjNameSingulGRUP;
+ break;
+ case DRAWING_LINE:
+ nResourceId = STR_ObjNameSingulLINE;
+ break;
+ case DRAWING_MEASURE:
+ nResourceId = STR_ObjNameSingulMEASURE;
+ break;
+ case DRAWING_OPEN_BEZIER:
+ nResourceId = STR_ObjNameSingulPATHLINE;
+ break;
+ case DRAWING_OPEN_FREEHAND:
+ nResourceId = STR_ObjNameSingulFREELINE;
+ break;
+ case DRAWING_PAGE:
+ nResourceId = STR_ObjNameSingulPAGE;
+ break;
+ case DRAWING_POLY_LINE:
+ nResourceId = STR_ObjNameSingulPLIN;
+ break;
+ case DRAWING_POLY_LINE_PATH:
+ nResourceId = STR_ObjNameSingulPLIN;
+ break;
+ case DRAWING_POLY_POLYGON:
+ nResourceId = STR_ObjNameSingulPOLY;
+ break;
+ case DRAWING_POLY_POLYGON_PATH:
+ nResourceId = STR_ObjNameSingulPOLY;
+ break;
+ case DRAWING_RECTANGLE:
+ nResourceId = STR_ObjNameSingulRECT;
+ break;
+ case DRAWING_TEXT:
+ nResourceId = STR_ObjNameSingulTEXT;
+ break;
+ default:
+ nResourceId = -1;
+ sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleShape"));
+ uno::Reference<drawing::XShapeDescriptor> xDescriptor (rxShape, uno::UNO_QUERY);
+ if (xDescriptor.is())
+ sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
+ + xDescriptor->getShapeType();
+ break;
+ }
+
+ if (nResourceId != -1)
+ {
+ SolarMutexGuard aGuard;
+ sName = OUString (SVX_RESSTR((unsigned short)nResourceId));
+ }
+
+ return sName;
+}
+
+} // end of namespace accessibility
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/SvxShapeTypes.cxx b/svx/source/accessibility/SvxShapeTypes.cxx
new file mode 100644
index 000000000000..d2f670529240
--- /dev/null
+++ b/svx/source/accessibility/SvxShapeTypes.cxx
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/SvxShapeTypes.hxx>
+#include <svx/AccessibleShape.hxx>
+#include <svx/AccessibleGraphicShape.hxx>
+#include <svx/AccessibleOLEShape.hxx>
+#include <svx/AccessibleControlShape.hxx>
+#include <svx/AccessibleTableShape.hxx>
+
+namespace accessibility {
+
+AccessibleShape* CreateSvxAccessibleShape (
+ const AccessibleShapeInfo& rShapeInfo,
+ const AccessibleShapeTreeInfo& rShapeTreeInfo,
+ ShapeTypeId nId)
+{
+ switch (nId)
+ {
+ case DRAWING_3D_CUBE:
+ case DRAWING_3D_EXTRUDE:
+ case DRAWING_3D_LATHE:
+ case DRAWING_3D_SCENE:
+ case DRAWING_3D_SPHERE:
+ case DRAWING_CAPTION:
+ case DRAWING_CLOSED_BEZIER:
+ case DRAWING_CLOSED_FREEHAND:
+ case DRAWING_CONNECTOR:
+ case DRAWING_ELLIPSE:
+ case DRAWING_GROUP:
+ case DRAWING_LINE:
+ case DRAWING_MEASURE:
+ case DRAWING_OPEN_BEZIER:
+ case DRAWING_OPEN_FREEHAND:
+ case DRAWING_PAGE:
+ case DRAWING_POLY_POLYGON:
+ case DRAWING_POLY_LINE:
+ case DRAWING_POLY_POLYGON_PATH:
+ case DRAWING_POLY_LINE_PATH:
+ case DRAWING_RECTANGLE:
+ case DRAWING_TEXT:
+ // --> OD 2004-11-29 #i37790# - default accessiblility shape for
+ // com::sun::star::drawing::CustomShape
+ case DRAWING_CUSTOM:
+ // <--
+ // --> OD 2008-05-19 #i85429# - default accessiblility shape for
+ // com::sun::star::drawing::MediaShape
+ case DRAWING_MEDIA:
+ // <--
+ return new AccessibleShape (rShapeInfo, rShapeTreeInfo);
+
+ case DRAWING_CONTROL:
+ return new AccessibleControlShape (rShapeInfo, rShapeTreeInfo);
+
+ case DRAWING_GRAPHIC_OBJECT:
+ return new AccessibleGraphicShape (rShapeInfo, rShapeTreeInfo);
+
+ case DRAWING_APPLET:
+ case DRAWING_FRAME:
+ case DRAWING_OLE:
+ case DRAWING_PLUGIN:
+ return new AccessibleOLEShape (rShapeInfo, rShapeTreeInfo);
+
+ case DRAWING_TABLE:
+ return new AccessibleTableShape( rShapeInfo, rShapeTreeInfo );
+
+ default:
+ return NULL;
+ }
+}
+
+
+
+ShapeTypeDescriptor aSvxShapeTypeList[] = {
+ ShapeTypeDescriptor (DRAWING_TEXT,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TextShape")),
+ CreateSvxAccessibleShape),
+ ShapeTypeDescriptor (DRAWING_RECTANGLE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.RectangleShape")),
+ CreateSvxAccessibleShape),
+ ShapeTypeDescriptor ( DRAWING_ELLIPSE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.EllipseShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_CONTROL,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ControlShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_CONNECTOR,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ConnectorShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_MEASURE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MeasureShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_LINE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.LineShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_POLY_POLYGON,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.PolyPolygonShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_POLY_LINE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.PolyLineShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_OPEN_BEZIER,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OpenBezierShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_CLOSED_BEZIER,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ClosedBezierShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_OPEN_FREEHAND,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OpenFreeHandShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_CLOSED_FREEHAND,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ClosedFreeHandShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_POLY_POLYGON_PATH,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.PolyPolygonPathShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_POLY_LINE_PATH,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.PolyLinePathShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_GRAPHIC_OBJECT,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GraphicObjectShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_GROUP,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GroupShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_OLE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_PAGE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.PageShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_CAPTION,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_FRAME,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.FrameShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_PLUGIN,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.PluginShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_APPLET,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.AppletShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_3D_SCENE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shape3DSceneObject")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_3D_CUBE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shape3DCubeObject")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_3D_SPHERE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shape3DSphereObject")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_3D_LATHE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shape3DLatheObject")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_3D_EXTRUDE,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shape3DExtrudeObject")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_CUSTOM,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CustomShape")),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_TABLE,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TableShape" ) ),
+ CreateSvxAccessibleShape ),
+ ShapeTypeDescriptor ( DRAWING_MEDIA,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MediaShape" ) ),
+ CreateSvxAccessibleShape ),
+
+};
+
+
+void RegisterDrawShapeTypes (void)
+{
+ // --> OD 2004-11-26 #i37790#
+ ShapeTypeHandler::Instance().AddShapeTypeList ( DRAWING_END, aSvxShapeTypeList);
+ // <--
+}
+
+
+} // end of namespace accessibility
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/accessibility.src b/svx/source/accessibility/accessibility.src
new file mode 100644
index 000000000000..0fd5579898f6
--- /dev/null
+++ b/svx/source/accessibility/accessibility.src
@@ -0,0 +1,262 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "accessibility.hrc"
+
+String RID_SVXSTR_A11Y_3D_MATERIAL_COLOR
+{
+ Text [ en-US ] = "3D material color" ;
+};
+String RID_SVXSTR_A11Y_TEXT_COLOR
+{
+ Text [ en-US ] = "Font color" ;
+};
+String RID_SVXSTR_A11Y_BACKGROUND_COLOR
+{
+ Text [ en-US ] = "Background color" ;
+};
+String RID_SVXSTR_A11Y_FILLSTYLE_NONE
+{
+ Text [ en-US ] = "None" ;
+};
+String RID_SVXSTR_A11Y_FILLSTYLE_SOLID
+{
+ Text [ en-US ] = "Solid" ;
+};
+String RID_SVXSTR_A11Y_FILLSTYLE_HATCH
+{
+ Text [ en-US ] = "With hatching" ;
+};
+String RID_SVXSTR_A11Y_FILLSTYLE_GRADIENT
+{
+ Text [ en-US ] = "Gradient" ;
+};
+String RID_SVXSTR_A11Y_FILLSTYLE_BITMAP
+{
+ Text [ en-US ] = "Bitmap" ;
+};
+String RID_SVXSTR_A11Y_WITH
+{
+ Text [ en-US ] = "with" ;
+};
+String RID_SVXSTR_A11Y_STYLE
+{
+ Text [ en-US ] = "Style" ;
+};
+String RID_SVXSTR_A11Y_AND
+{
+ Text [ en-US ] = "and" ;
+};
+
+
+// SvxRectCtl
+
+String RID_SVXSTR_RECTCTL_ACC_CORN_NAME
+{
+ Text [ en-US ] = "Corner control" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CORN_DESCR
+{
+ Text [ en-US ] = "Selection of a corner point." ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_ANGL_NAME
+{
+ Text [ en-US ] = "Angle control" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_ANGL_DESCR
+{
+ Text [ en-US ] = "Selection of a major angle." ;
+};
+
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_LT
+{
+ Text [ en-US ] = "Top left" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_MT
+{
+ Text [ en-US ] = "Top middle" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_RT
+{
+ Text [ en-US ] = "Top right" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_LM
+{
+ Text [ en-US ] = "Left center" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_MM
+{
+ Text [ en-US ] = "Center" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_RM
+{
+ Text [ en-US ] = "Right center" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_LB
+{
+ Text [ en-US ] = "Bottom left" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_MB
+{
+ Text [ en-US ] = "Bottom middle" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_RB
+{
+ Text [ en-US ] = "Bottom right" ;
+};
+
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_A000
+{
+ Text [ en-US ] = "0 degrees" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_A045
+{
+ Text [ en-US ] = "45 degrees" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_A090
+{
+ Text [ en-US ] = "90 degrees" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_A135
+{
+ Text [ en-US ] = "135 degrees" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_A180
+{
+ Text [ en-US ] = "180 degrees" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_A225
+{
+ Text [ en-US ] = "225 degrees" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_A270
+{
+ Text [ en-US ] = "270 degrees" ;
+};
+
+String RID_SVXSTR_RECTCTL_ACC_CHLD_A315
+{
+ Text [ en-US ] = "315 degrees" ;
+};
+
+// SvxGraphCtrlAccessibleContext
+String RID_SVXSTR_GRAPHCTRL_ACC_NAME
+{
+ Text [ en-US ] = "Contour control" ;
+};
+
+String RID_SVXSTR_GRAPHCTRL_ACC_DESCRIPTION
+{
+ Text [ en-US ] = "This is where you can edit the contour." ;
+};
+
+String RID_SVXSTR_CHARACTER_SELECTION
+{
+ Text [ en-US ] = "Special character selection";
+};
+
+String RID_SVXSTR_CHAR_SEL_DESC
+{
+ Text [ en-US ] = "Select special characters in this area.";
+};
+
+String RID_SVXSTR_CHARACTER_CODE
+{
+ // The space behind is a must.
+ Text [ en-US ] = "Character code ";
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/accessibility/charmapacc.cxx b/svx/source/accessibility/charmapacc.cxx
new file mode 100644
index 000000000000..f7581151583f
--- /dev/null
+++ b/svx/source/accessibility/charmapacc.cxx
@@ -0,0 +1,893 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define _SVX_CHARMAP_CXX_
+#include <unotools/accessiblestatesethelper.hxx>
+#include <vcl/svapp.hxx>
+#include <stdio.h>
+#include <svx/charmap.hxx>
+#include "charmapacc.hxx"
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <toolkit/helper/externallock.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <osl/interlck.h>
+#include <svx/dialmgr.hxx>
+#include "accessibility.hrc"
+#include <comphelper/types.hxx>
+
+namespace svx
+{
+ using namespace comphelper;
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::accessibility;
+
+// ----------------
+// - SvxShowCharSetVirtualAcc -
+// ----------------
+SvxShowCharSetVirtualAcc::SvxShowCharSetVirtualAcc( SvxShowCharSet* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock())
+,mpParent( pParent )
+,m_pTable(NULL)
+{
+ osl_incrementInterlockedCount(&m_refCount);
+ { // #b6211265 #
+ lateInit(this);
+ }
+ osl_decrementInterlockedCount(&m_refCount);
+}
+
+// -----------------------------------------------------------------------------
+
+SvxShowCharSetVirtualAcc::~SvxShowCharSetVirtualAcc()
+{
+ ensureDisposed();
+ delete getExternalLock();
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetVirtualAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetVirtualAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
+
+void SAL_CALL SvxShowCharSetVirtualAcc::fireEvent(
+ const sal_Int16 _nEventId,
+ const ::com::sun::star::uno::Any& _rOldValue,
+ const ::com::sun::star::uno::Any& _rNewValue
+ )
+{
+ if ( m_pTable )
+ m_pTable->fireEvent(_nEventId,_rOldValue,_rNewValue);
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChildCount( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ return ( mpParent->getScrollBar()->IsVisible() ) ? 2 : 1;
+}
+// -----------------------------------------------------------------------------
+uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleAtPoint( const awt::Point& aPoint )
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+
+ uno::Reference< accessibility::XAccessible > xRet;
+ const USHORT nItemId = sal::static_int_cast<USHORT>(mpParent->PixelToMapIndex( Point( aPoint.X, aPoint.Y ) ));
+
+ if( USHORT(-1) != nItemId )
+ {
+ if ( !m_pTable )
+ m_pTable = new SvxShowCharSetAcc(this);
+ xRet = m_pTable;
+ }
+ else if ( mpParent->getScrollBar()->IsVisible() )
+ {
+ const Point aOutPos( mpParent->getScrollBar()->GetPosPixel() );
+ const Size aScrollBar = mpParent->getScrollBar()->GetOutputSizePixel();
+ Rectangle aRect(aOutPos,aScrollBar);
+
+ if ( aRect.IsInside(VCLPoint(aPoint)) )
+ xRet = mpParent->getScrollBar()->GetAccessible();
+ }
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+uno::Any SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleKeyBinding()
+ throw (uno::RuntimeException)
+{
+ return uno::Any();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL SvxShowCharSetVirtualAcc::grabFocus()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ mpParent->GrabFocus();
+}
+
+
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ if ( mpParent->getScrollBar()->IsVisible() && i == 0 )
+ return mpParent->getScrollBar()->GetAccessible();
+ else if ( i == 1 )
+ {
+ if ( !m_xAcc.is() )
+ {
+ m_pTable = new SvxShowCharSetAcc(this);
+ m_xAcc = m_pTable;
+ }
+ }
+ else
+ throw IndexOutOfBoundsException();
+ return m_xAcc;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleParent( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ Window* pParent = mpParent->GetParent();
+ uno::Reference< accessibility::XAccessible > xRet;
+
+ if ( pParent )
+ xRet = pParent->GetAccessible();
+
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::awt::Rectangle SAL_CALL SvxShowCharSetVirtualAcc::implGetBounds( ) throw (RuntimeException)
+{
+ const Point aOutPos( mpParent->GetPosPixel() );
+ Size aOutSize( mpParent->GetOutputSizePixel() );
+ if ( mpParent->getScrollBar()->IsVisible() )
+ {
+ const Size aScrollBar = mpParent->getScrollBar()->GetOutputSizePixel();
+ aOutSize.Width() -= aScrollBar.Width();
+ aOutSize.Height() -= aScrollBar.Height();
+ }
+
+ awt::Rectangle aRet;
+
+ aRet.X = aOutPos.X();
+ aRet.Y = aOutPos.Y();
+ aRet.Width = aOutSize.Width();
+ aRet.Height = aOutSize.Height();
+
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+sal_Int16 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleRole( ) throw (RuntimeException)
+{
+ return accessibility::AccessibleRole::SCROLL_PANE;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleDescription( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleName( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC);
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessibleRelationSet > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ return Reference< XAccessibleRelationSet >();
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessibleStateSet > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleStateSet( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
+
+ if( mpParent )
+ {
+ // SELECTABLE
+ pStateSet->AddState( AccessibleStateType::FOCUSABLE );
+ if ( mpParent->HasFocus() )
+ pStateSet->AddState( AccessibleStateType::FOCUSED );
+ if ( mpParent->IsActive() )
+ pStateSet->AddState( AccessibleStateType::ACTIVE );
+ if ( mpParent->IsEnabled() )
+ {
+ pStateSet->AddState( AccessibleStateType::ENABLED );
+ pStateSet->AddState( AccessibleStateType::SENSITIVE );
+ }
+ if ( mpParent->IsReallyVisible() )
+ pStateSet->AddState( AccessibleStateType::VISIBLE );
+ }
+
+ return pStateSet;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL SvxShowCharSetVirtualAcc::disposing()
+{
+ OAccessibleContextHelper::disposing();
+ if ( m_pTable )
+ m_pTable->dispose();
+ m_pTable = NULL;
+}
+// -----------------------------------------------------------------------------
+// ----------------
+// - SvxShowCharSetItem -
+// ----------------
+
+SvxShowCharSetItem::SvxShowCharSetItem( SvxShowCharSet& rParent,SvxShowCharSetAcc* _pParent,USHORT _nPos ) :
+ mrParent( rParent )
+ ,mnId( _nPos )
+ ,m_pItem(NULL)
+ ,m_pParent(_pParent)
+{
+}
+// -----------------------------------------------------------------------
+
+SvxShowCharSetItem::~SvxShowCharSetItem()
+{
+ if ( m_xAcc.is() )
+ {
+ m_pItem->ParentDestroyed();
+ ClearAccessible();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SvxShowCharSetItem::GetAccessible()
+{
+ if( !m_xAcc.is() )
+ {
+ m_pItem = new SvxShowCharSetItemAcc( this );
+ m_xAcc = m_pItem;
+ }
+
+ return m_xAcc;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSetItem::ClearAccessible()
+{
+ if ( m_xAcc.is() )
+ {
+ m_pItem = NULL;
+ m_xAcc = NULL;
+ }
+}
+
+
+// ---------------
+// - SvxShowCharSetAcc -
+// ---------------
+
+SvxShowCharSetAcc::SvxShowCharSetAcc( SvxShowCharSetVirtualAcc* _pParent ) : OAccessibleSelectionHelper(new VCLExternalSolarLock())
+ ,m_pParent( _pParent )
+{
+ osl_incrementInterlockedCount(&m_refCount);
+ { // #b6211265 #
+ lateInit(this);
+ }
+ osl_decrementInterlockedCount(&m_refCount);
+}
+
+// -----------------------------------------------------------------------------
+
+SvxShowCharSetAcc::~SvxShowCharSetAcc()
+{
+ ensureDisposed();
+ delete getExternalLock();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL SvxShowCharSetAcc::disposing()
+{
+ OAccessibleSelectionHelper::disposing();
+ ::std::vector< Reference< XAccessible > >::iterator aIter = m_aChildren.begin();
+ ::std::vector< Reference< XAccessible > >::iterator aEnd = m_aChildren.end();
+ for (;aIter != aEnd ; ++aIter)
+ ::comphelper::disposeComponent(*aIter);
+
+ m_aChildren.clear();
+ m_pParent = NULL;
+}
+
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base )
+// -----------------------------------------------------------------------
+sal_Bool SvxShowCharSetAcc::implIsSelected( sal_Int32 nAccessibleChildIndex ) throw (RuntimeException)
+{
+ return m_pParent && m_pParent->getCharSetControl()->IsSelected(
+ sal::static_int_cast<USHORT>(nAccessibleChildIndex));
+}
+// -----------------------------------------------------------------------------
+ // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
+void SvxShowCharSetAcc::implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ if ( m_pParent )
+ {
+ if ( bSelect )
+ m_pParent->getCharSetControl()->SelectIndex(nAccessibleChildIndex,sal_True);
+ else
+ m_pParent->getCharSetControl()->DeSelect();
+ }
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::awt::Rectangle SAL_CALL SvxShowCharSetAcc::implGetBounds( ) throw (RuntimeException)
+{
+ const Point aOutPos( m_pParent->getCharSetControl()->GetPosPixel() );
+ Size aOutSize( m_pParent->getCharSetControl()->GetOutputSizePixel());
+ if ( m_pParent->getCharSetControl()->getScrollBar()->IsVisible() )
+ {
+ const Size aScrollBar = m_pParent->getCharSetControl()->getScrollBar()->GetOutputSizePixel();
+ aOutSize.Width() -= aScrollBar.Width();
+ aOutSize.Height() -= aScrollBar.Height();
+ }
+
+ awt::Rectangle aRet;
+
+ aRet.X = aOutPos.X();
+ aRet.Y = aOutPos.Y();
+ aRet.Width = aOutSize.Width();
+ aRet.Height = aOutSize.Height();
+
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleChildCount()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ return m_pParent->getCharSetControl()->getMaxCharCount();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleChild( sal_Int32 i )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ uno::Reference< accessibility::XAccessible > xRet;
+ SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( static_cast< USHORT >( i ) );
+
+ if( pItem )
+ {
+ pItem->m_pParent = this;
+ xRet = pItem->GetAccessible();
+ m_aChildren.push_back(xRet);
+ }
+ else
+ throw lang::IndexOutOfBoundsException();
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleParent()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ return m_pParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL SvxShowCharSetAcc::getAccessibleRole()
+ throw (uno::RuntimeException)
+{
+ return accessibility::AccessibleRole::TABLE;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleDescription()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION );
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleName()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC );
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL SvxShowCharSetAcc::getAccessibleRelationSet()
+ throw (uno::RuntimeException)
+{
+ return uno::Reference< accessibility::XAccessibleRelationSet >();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSetAcc::getAccessibleStateSet()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
+
+ if( m_pParent->getCharSetControl() )
+ {
+ // SELECTABLE
+ pStateSet->AddState( AccessibleStateType::FOCUSABLE );
+ if ( m_pParent->getCharSetControl()->HasFocus() )
+ pStateSet->AddState( AccessibleStateType::FOCUSED );
+ if ( m_pParent->getCharSetControl()->IsActive() )
+ pStateSet->AddState( AccessibleStateType::ACTIVE );
+ if ( m_pParent->getCharSetControl()->IsEnabled() )
+ {
+ pStateSet->AddState( AccessibleStateType::ENABLED );
+ pStateSet->AddState( AccessibleStateType::SENSITIVE );
+ }
+ if ( m_pParent->getCharSetControl()->IsReallyVisible() )
+ pStateSet->AddState( AccessibleStateType::VISIBLE );
+
+ pStateSet->AddState( AccessibleStateType::MANAGES_DESCENDANTS );
+ }
+
+ return pStateSet;
+}
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleAtPoint( const awt::Point& aPoint )
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+
+ uno::Reference< accessibility::XAccessible > xRet;
+ const USHORT nItemId = sal::static_int_cast<USHORT>(
+ m_pParent->getCharSetControl()->PixelToMapIndex( Point( aPoint.X, aPoint.Y ) ));
+
+ if( USHORT(-1) != nItemId )
+ {
+ SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( nItemId );
+ xRet = pItem->GetAccessible();
+ }
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SvxShowCharSetAcc::grabFocus()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ m_pParent->getCharSetControl()->GrabFocus();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Any SAL_CALL SvxShowCharSetAcc::getAccessibleKeyBinding()
+ throw (uno::RuntimeException)
+{
+ return uno::Any();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowCount( ) throw (RuntimeException)
+{
+ return ((getAccessibleChildCount()-1) / COLUMN_COUNT) + 1;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnCount( ) throw (RuntimeException)
+{
+ return COLUMN_COUNT;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleRowDescription( sal_Int32 /*nRow*/ ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleColumnDescription( sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return 1;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return 1;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessibleTable > SAL_CALL SvxShowCharSetAcc::getAccessibleRowHeaders( ) throw (RuntimeException)
+{
+ return Reference< XAccessibleTable >();
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessibleTable > SAL_CALL SvxShowCharSetAcc::getAccessibleColumnHeaders( ) throw (RuntimeException)
+{
+ return Reference< XAccessibleTable >();
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleRows( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ Sequence< sal_Int32 > aSel(1);
+ aSel[0] = m_pParent->getCharSetControl()->GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId());
+ return aSel;
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleColumns( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ Sequence< sal_Int32 > aSel(1);
+ aSel[0] = m_pParent->getCharSetControl()->GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId());
+ return aSel;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ return m_pParent->getCharSetControl()->GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId()) == nRow;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleColumnSelected( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ return m_pParent->getCharSetControl()->GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId()) == nColumn;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ ::svx::SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem(
+ sal::static_int_cast<USHORT>(getAccessibleIndex(nRow,nColumn) ));
+ if ( !pItem )
+ throw IndexOutOfBoundsException();
+ return pItem->GetAccessible();
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleCaption( ) throw (RuntimeException)
+{
+ return Reference< XAccessible >();
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleSummary( ) throw (RuntimeException)
+{
+ return Reference< XAccessible >();
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ return m_pParent->getCharSetControl()->GetSelectIndexId() == getAccessibleIndex(nRow,nColumn);
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return (nRow*COLUMN_COUNT) + nColumn;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRow( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ return m_pParent->getCharSetControl()->GetRowPos(sal::static_int_cast<USHORT>(nChildIndex));
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumn( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ return m_pParent->getCharSetControl()->GetColumnPos(sal::static_int_cast<USHORT>(nChildIndex));
+}
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+// ----------------
+// - SvxShowCharSetItemAcc -
+// ----------------
+
+SvxShowCharSetItemAcc::SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock())
+,mpParent( pParent )
+{
+ OSL_ENSURE(pParent,"NO parent supplied!");
+ osl_incrementInterlockedCount(&m_refCount);
+ { // #b6211265 #
+ lateInit(this);
+ }
+ osl_decrementInterlockedCount(&m_refCount);
+}
+
+// -----------------------------------------------------------------------------
+
+SvxShowCharSetItemAcc::~SvxShowCharSetItemAcc()
+{
+ ensureDisposed();
+ delete getExternalLock();
+}
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetItemAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetItemAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
+// -----------------------------------------------------------------------------
+
+void SvxShowCharSetItemAcc::ParentDestroyed()
+{
+ const ::osl::MutexGuard aGuard( GetMutex() );
+ mpParent = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL SvxShowCharSetItemAcc::getAccessibleChildCount()
+ throw (uno::RuntimeException)
+{
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleChild( sal_Int32 /*i*/ )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ throw lang::IndexOutOfBoundsException();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleParent()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ return mpParent->m_pParent;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL SvxShowCharSetItemAcc::getAccessibleRole()
+ throw (uno::RuntimeException)
+{
+ return accessibility::AccessibleRole::LABEL;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleDescription()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ String sDescription = SVX_RESSTR( RID_SVXSTR_CHARACTER_CODE );
+
+ sal_Unicode c = mpParent->maText.GetChar(0);
+ char buf[16] = "0x0000";
+ sal_Unicode c_Shifted = c;
+ for( int i = 0; i < 4; ++i )
+ {
+ char h = (char)(c_Shifted & 0x0F);
+ buf[5-i] = (h > 9) ? (h - 10 + 'A') : (h + '0');
+ c_Shifted >>= 4;
+ }
+ if( c < 256 )
+ snprintf( buf+6, 10, " (%d)", c );
+ sDescription.AppendAscii(buf);
+
+ return sDescription;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleName()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+ String aRet;
+
+ if( mpParent )
+ {
+ aRet = mpParent->maText;
+
+ if( !aRet.Len() )
+ aRet = getAccessibleDescription();
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL SvxShowCharSetItemAcc::getAccessibleRelationSet()
+ throw (uno::RuntimeException)
+{
+ return uno::Reference< accessibility::XAccessibleRelationSet >();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSetItemAcc::getAccessibleStateSet()
+ throw (uno::RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ ensureAlive();
+
+ ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
+
+ if( mpParent )
+ {
+ // SELECTABLE
+ pStateSet->AddState( accessibility::AccessibleStateType::SELECTABLE );
+ pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
+
+ // SELECTED
+ if( mpParent->mrParent.GetSelectIndexId() == mpParent->mnId )
+ {
+ pStateSet->AddState( accessibility::AccessibleStateType::SELECTED );
+ pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
+ }
+ if ( mpParent->mnId >= mpParent->mrParent.FirstInView() && mpParent->mnId <= mpParent->mrParent.LastInView() )
+ pStateSet->AddState( AccessibleStateType::VISIBLE );
+ pStateSet->AddState( AccessibleStateType::TRANSIENT );
+ }
+
+ return pStateSet;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL SvxShowCharSetItemAcc::grabFocus()
+ throw (uno::RuntimeException)
+{
+ // nothing to do
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Any SAL_CALL SvxShowCharSetItemAcc::getAccessibleKeyBinding()
+ throw (uno::RuntimeException)
+{
+ return uno::Any();
+}
+// -----------------------------------------------------------------------------
+awt::Rectangle SAL_CALL SvxShowCharSetItemAcc::implGetBounds( ) throw (RuntimeException)
+{
+ awt::Rectangle aRet;
+
+ if( mpParent )
+ {
+ Rectangle aRect( mpParent->maRect );
+ Point aOrigin;
+ Rectangle aParentRect( aOrigin, mpParent->mrParent.GetOutputSizePixel() );
+
+ aRect.Intersection( aParentRect );
+
+ aRet.X = aRect.Left();
+ aRet.Y = aRect.Top();
+ aRet.Width = aRect.GetWidth();
+ aRet.Height = aRect.GetHeight();
+ }
+
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleAtPoint( const awt::Point& /*aPoint*/ )
+ throw (uno::RuntimeException)
+{
+ return uno::Reference< accessibility::XAccessible >();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getForeground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ if ( mpParent )
+ {
+ if ( mpParent->IsControlForeground() )
+ nColor = mpParent->GetControlForeground().GetColor();
+ else
+ {
+ Font aFont;
+ if ( mpParent->IsControlFont() )
+ aFont = mpParent->GetControlFont();
+ else
+ aFont = mpParent->GetFont();
+ nColor = aFont.GetColor().GetColor();
+ }
+ }
+
+ return nColor;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ sal_Int32 nColor = 0;
+ if ( mpParent )
+ {
+ if ( mpParent->IsControlBackground() )
+ nColor = mpParent->GetControlBackground().GetColor();
+ else
+ nColor = mpParent->GetBackground().GetColor().GetColor();
+ }
+
+ return nColor;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetAcc::getForeground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+
+ sal_Int32 nColor = 0;
+ if ( m_pParent )
+ nColor = m_pParent->getForeground();
+ return nColor;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShowCharSetAcc::getBackground( ) throw (RuntimeException)
+{
+ OExternalLockGuard aGuard( this );
+ sal_Int32 nColor = 0;
+ if ( m_pParent )
+ nColor = m_pParent->getBackground();
+ return nColor;
+}
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+} // namespace svx
+// -----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/accessibility/makefile.mk b/svx/source/accessibility/makefile.mk
new file mode 100755
index 000000000000..9ac9cff08a1d
--- /dev/null
+++ b/svx/source/accessibility/makefile.mk
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+TARGET=accessibility
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/charmapacc.obj \
+ $(SLO)$/svxrectctaccessiblecontext.obj \
+ $(SLO)$/GraphCtlAccessibleContext.obj \
+ $(SLO)$/ChildrenManager.obj \
+ $(SLO)$/ChildrenManagerImpl.obj \
+ $(SLO)$/DescriptionGenerator.obj \
+ $(SLO)$/AccessibleShape.obj \
+ $(SLO)$/AccessibleGraphicShape.obj \
+ $(SLO)$/AccessibleOLEShape.obj \
+ $(SLO)$/AccessibleShapeInfo.obj \
+ $(SLO)$/AccessibleShapeTreeInfo.obj \
+ $(SLO)$/AccessibleTextHelper.obj \
+ $(SLO)$/AccessibleEmptyEditSource.obj \
+ $(SLO)$/AccessibleTextEventQueue.obj \
+ $(SLO)$/ShapeTypeHandler.obj \
+ $(SLO)$/SvxShapeTypes.obj \
+ $(SLO)$/AccessibleControlShape.obj \
+ $(SLO)$/DGColorNameLookUp.obj \
+ $(SLO)$/AccessibleFrameSelector.obj
+
+SRS2NAME = accessibility
+SRC2FILES = accessibility.src
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/accessibility/svxrectctaccessiblecontext.cxx b/svx/source/accessibility/svxrectctaccessiblecontext.cxx
new file mode 100644
index 000000000000..2b02a99cf4c5
--- /dev/null
+++ b/svx/source/accessibility/svxrectctaccessiblecontext.cxx
@@ -0,0 +1,1208 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+
+#include "svxrectctaccessiblecontext.hxx"
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/uuid.h>
+#include <tools/debug.hxx>
+#include <tools/gen.hxx>
+
+#include <svx/dialogs.hrc>
+#include "accessibility.hrc"
+#include <svx/dlgctrl.hxx>
+#include <svx/dialmgr.hxx>
+#include <comphelper/accessibleeventnotifier.hxx>
+
+
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+
+
+#define MAX_NUM_OF_CHILDS 9
+#define NOCHILDSELECTED -1
+
+
+DBG_NAME( SvxRectCtlAccessibleContext )
+
+
+//===== internal ============================================================
+
+namespace
+{
+ struct ChildIndexToPointData
+ {
+ short nResIdName;
+ short nResIdDescr;
+ RECT_POINT ePoint;
+ };
+}
+
+
+static const ChildIndexToPointData* IndexToPoint( long nIndex, sal_Bool bAngleControl )
+{
+ DBG_ASSERT( nIndex < ( bAngleControl? 8 : 9 ) && nIndex >= 0, "-IndexToPoint(): invalid child index! You have been warned..." );
+
+ // angles are counted reverse counter clock wise
+ static const ChildIndexToPointData pAngleData[] =
+ { // index
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_A000, RID_SVXSTR_RECTCTL_ACC_CHLD_A000, RP_RM }, // 0
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_A045, RID_SVXSTR_RECTCTL_ACC_CHLD_A045, RP_RT }, // 1
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_A090, RID_SVXSTR_RECTCTL_ACC_CHLD_A090, RP_MT }, // 2
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_A135, RID_SVXSTR_RECTCTL_ACC_CHLD_A135, RP_LT }, // 3
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_A180, RID_SVXSTR_RECTCTL_ACC_CHLD_A180, RP_LM }, // 4
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_A225, RID_SVXSTR_RECTCTL_ACC_CHLD_A225, RP_LB }, // 5
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_A270, RID_SVXSTR_RECTCTL_ACC_CHLD_A270, RP_MB }, // 6
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_A315, RID_SVXSTR_RECTCTL_ACC_CHLD_A315, RP_RB } // 7
+ };
+
+ // corners are counted from left to right and top to bottom
+ static const ChildIndexToPointData pCornerData[] =
+ { // index
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_LT, RID_SVXSTR_RECTCTL_ACC_CHLD_LT, RP_LT }, // 0
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_MT, RID_SVXSTR_RECTCTL_ACC_CHLD_MT, RP_MT }, // 1
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_RT, RID_SVXSTR_RECTCTL_ACC_CHLD_RT, RP_RT }, // 2
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_LM, RID_SVXSTR_RECTCTL_ACC_CHLD_LM, RP_LM }, // 3
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_MM, RID_SVXSTR_RECTCTL_ACC_CHLD_MM, RP_MM }, // 4
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_RM, RID_SVXSTR_RECTCTL_ACC_CHLD_RM, RP_RM }, // 5
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_LB, RID_SVXSTR_RECTCTL_ACC_CHLD_LB, RP_LB }, // 6
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_MB, RID_SVXSTR_RECTCTL_ACC_CHLD_MB, RP_MB }, // 7
+ { RID_SVXSTR_RECTCTL_ACC_CHLD_RB, RID_SVXSTR_RECTCTL_ACC_CHLD_RB, RP_RB } // 8
+ };
+
+ return ( bAngleControl? pAngleData : pCornerData ) + nIndex;
+}
+
+
+static long PointToIndex( RECT_POINT ePoint, sal_Bool bAngleControl )
+{
+ long nRet( (long) ePoint );
+ if( bAngleControl )
+ { // angle control
+ // angles are counted reverse counter clock wise
+ switch( ePoint )
+ {
+ case RP_LT: nRet = 3; break;
+ case RP_MT: nRet = 2; break;
+ case RP_RT: nRet = 1; break;
+ case RP_LM: nRet = 4; break;
+ case RP_MM: nRet = NOCHILDSELECTED; break;
+ case RP_RM: nRet = 0; break;
+ case RP_LB: nRet = 5; break;
+ case RP_MB: nRet = 6; break;
+ case RP_RB: nRet = 7; break;
+ }
+ }
+ else
+ { // corner control
+ // corners are counted from left to right and top to bottom
+ DBG_ASSERT( RP_LT == 0 && RP_MT == 1 && RP_RT == 2 && RP_LM == 3 && RP_MM == 4 && RP_RM == 5 &&
+ RP_LB == 6 && RP_MB == 7 && RP_RB == 8, "*PointToIndex(): unexpected enum value!" );
+
+ nRet = ( long ) ePoint;
+ }
+
+ return nRet;
+}
+
+
+SvxRectCtlAccessibleContext::SvxRectCtlAccessibleContext(
+ const Reference< XAccessible >& rxParent,
+ SvxRectCtl& rRepr,
+ const ::rtl::OUString* pName,
+ const ::rtl::OUString* pDesc ) :
+
+ SvxRectCtlAccessibleContext_Base( m_aMutex ),
+ mxParent( rxParent ),
+ mpRepr( &rRepr ),
+ mpChilds( NULL ),
+ mnClientId( 0 ),
+ mnSelectedChild( NOCHILDSELECTED ),
+ mbAngleMode( rRepr.GetNumOfChilds() == 8 )
+{
+ DBG_CTOR( SvxRectCtlAccessibleContext, NULL );
+
+ if( pName )
+ msName = *pName;
+ else
+ {
+ ::SolarMutexGuard aSolarGuard;
+ msName = SVX_RESSTR( mbAngleMode? RID_SVXSTR_RECTCTL_ACC_ANGL_NAME : RID_SVXSTR_RECTCTL_ACC_CORN_NAME );
+ }
+
+ if( pDesc )
+ msDescription = *pDesc;
+ else
+ {
+ ::SolarMutexGuard aSolarGuard;
+ msDescription = SVX_RESSTR( mbAngleMode? RID_SVXSTR_RECTCTL_ACC_ANGL_DESCR : RID_SVXSTR_RECTCTL_ACC_CORN_DESCR );
+ }
+
+ mpChilds = new SvxRectCtlChildAccessibleContext*[ MAX_NUM_OF_CHILDS ];
+
+ SvxRectCtlChildAccessibleContext** p = mpChilds;
+ for( int i = MAX_NUM_OF_CHILDS ; i ; --i, ++p )
+ *p = NULL;
+}
+
+
+SvxRectCtlAccessibleContext::~SvxRectCtlAccessibleContext()
+{
+ DBG_DTOR( SvxRectCtlAccessibleContext, NULL );
+
+ if( IsAlive() )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose(); // set mpRepr = NULL & release all childs
+ }
+}
+
+//===== XAccessible =========================================================
+
+Reference< XAccessibleContext > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleContext( void ) throw( RuntimeException )
+{
+ return this;
+}
+
+//===== XAccessibleComponent ================================================
+
+sal_Bool SAL_CALL SvxRectCtlAccessibleContext::containsPoint( const awt::Point& rPoint ) throw( RuntimeException )
+{
+ // no guard -> done in getBounds()
+// return GetBoundingBox().IsInside( VCLPoint( rPoint ) );
+ return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
+}
+
+Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleAtPoint( const awt::Point& rPoint ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ThrowExceptionIfNotAlive();
+
+ Reference< XAccessible > xRet;
+
+ long nChild = PointToIndex( mpRepr->GetApproxRPFromPixPt( rPoint ), mbAngleMode );
+
+ if( nChild != NOCHILDSELECTED )
+ xRet = getAccessibleChild( nChild );
+
+ return xRet;
+}
+
+awt::Rectangle SAL_CALL SvxRectCtlAccessibleContext::getBounds() throw( RuntimeException )
+{
+ // no guard -> done in GetBoundingBox()
+ return AWTRectangle( GetBoundingBox() );
+}
+
+awt::Point SAL_CALL SvxRectCtlAccessibleContext::getLocation() throw( RuntimeException )
+{
+ // no guard -> done in GetBoundingBox()
+ return AWTPoint( GetBoundingBox().TopLeft() );
+}
+
+awt::Point SAL_CALL SvxRectCtlAccessibleContext::getLocationOnScreen() throw( RuntimeException )
+{
+ // no guard -> done in GetBoundingBoxOnScreen()
+ return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
+}
+
+awt::Size SAL_CALL SvxRectCtlAccessibleContext::getSize() throw( RuntimeException )
+{
+ // no guard -> done in GetBoundingBox()
+ return AWTSize( GetBoundingBox().GetSize() );
+}
+
+sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isShowing() throw( RuntimeException )
+{
+ return sal_True;
+}
+
+sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isVisible() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ThrowExceptionIfNotAlive();
+
+ return mpRepr->IsVisible();
+}
+
+sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isFocusTraversable() throw( RuntimeException )
+{
+ return sal_True;
+}
+
+//===== XAccessibleContext ==================================================
+
+sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChildCount( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ThrowExceptionIfNotAlive();
+
+ return mpRepr->GetNumOfChilds();
+}
+
+Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleChild( sal_Int32 nIndex )
+ throw( RuntimeException, lang::IndexOutOfBoundsException )
+{
+ checkChildIndex( nIndex );
+
+ Reference< XAccessible > xChild = mpChilds[ nIndex ];
+ if( !xChild.is() )
+ {
+ ::SolarMutexGuard aSolarGuard;
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ThrowExceptionIfNotAlive();
+
+ xChild = mpChilds[ nIndex ];
+
+ if( !xChild.is() )
+ {
+ const ChildIndexToPointData* p = IndexToPoint( nIndex, mbAngleMode );
+ UniString tmp = SVX_RESSTR( p->nResIdName );
+ ::rtl::OUString aName( tmp );
+ tmp = SVX_RESSTR( p->nResIdDescr );
+ ::rtl::OUString aDescr( tmp );
+
+ Rectangle aFocusRect( mpRepr->CalculateFocusRectangle( p->ePoint ) );
+
+ Rectangle aBoundingBoxOnScreen( mpRepr->OutputToScreenPixel( aFocusRect.TopLeft() ), aFocusRect.GetSize() );
+
+ SvxRectCtlChildAccessibleContext* pChild = new SvxRectCtlChildAccessibleContext(
+ this, *mpRepr, aName, aDescr, aFocusRect, nIndex );
+ xChild = mpChilds[ nIndex ] = pChild;
+ pChild->acquire();
+
+ // set actual state
+ if( mnSelectedChild == nIndex )
+ pChild->setStateChecked( sal_True );
+ }
+ }
+
+ return xChild;
+}
+
+Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleParent( void ) throw( RuntimeException )
+{
+ return mxParent;
+}
+
+sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleIndexInParent( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ // Use a simple but slow solution for now. Optimize later.
+
+ // Iterate over all the parent's children and search for this object.
+ if( mxParent.is() )
+ {
+ Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() );
+ if( xParentContext.is() )
+ {
+ sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
+ for( sal_Int32 i = 0 ; i < nChildCount ; ++i )
+ {
+ Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) );
+ if( xChild.get() == ( XAccessible* ) this )
+ return i;
+ }
+ }
+ }
+
+ // Return -1 to indicate that this object's parent does not know about the
+ // object.
+ return -1;
+}
+
+sal_Int16 SAL_CALL SvxRectCtlAccessibleContext::getAccessibleRole( void ) throw( RuntimeException )
+{
+ return AccessibleRole::PANEL;
+}
+
+::rtl::OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleDescription( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return msDescription;
+}
+
+::rtl::OUString SAL_CALL SvxRectCtlAccessibleContext::getAccessibleName( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return msName;
+}
+
+/** Return empty reference to indicate that the relation set is not
+ supported.
+*/
+Reference< XAccessibleRelationSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleRelationSet( void ) throw( RuntimeException )
+{
+ return Reference< XAccessibleRelationSet >();
+}
+
+Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlAccessibleContext::getAccessibleStateSet( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
+
+ if( IsAlive() )
+ {
+ // pStateSetHelper->AddState( AccessibleStateType::ENABLED );
+ // pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
+ pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
+ if( mpRepr->HasFocus() )
+ pStateSetHelper->AddState( AccessibleStateType::FOCUSED );
+ pStateSetHelper->AddState( AccessibleStateType::OPAQUE );
+
+ if( isShowing() )
+ pStateSetHelper->AddState( AccessibleStateType::SHOWING );
+
+ if( isVisible() )
+ pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
+ }
+ else
+ pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+
+ return pStateSetHelper;
+}
+
+lang::Locale SAL_CALL SvxRectCtlAccessibleContext::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if( mxParent.is() )
+ {
+ Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() );
+ if( xParentContext.is() )
+ return xParentContext->getLocale();
+ }
+
+ // No parent. Therefore throw exception to indicate this cluelessness.
+ throw IllegalAccessibleComponentStateException();
+}
+
+void SAL_CALL SvxRectCtlAccessibleContext::addEventListener( const Reference< XAccessibleEventListener >& xListener )
+ throw( RuntimeException )
+{
+ if (xListener.is())
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (!mnClientId)
+ mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
+ comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
+ }
+}
+
+void SAL_CALL SvxRectCtlAccessibleContext::removeEventListener( const Reference< XAccessibleEventListener >& xListener )
+ throw( RuntimeException )
+{
+ if (xListener.is())
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
+ if ( !nListenerCount )
+ {
+ // no listeners anymore
+ // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+ // and at least to us not firing any events anymore, in case somebody calls
+ // NotifyAccessibleEvent, again
+ comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
+ mnClientId = 0;
+ }
+ }
+}
+
+void SAL_CALL SvxRectCtlAccessibleContext::addFocusListener( const Reference< awt::XFocusListener >& xListener )
+ throw( RuntimeException )
+{
+ if( xListener.is() )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ThrowExceptionIfNotAlive();
+
+ Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( mpRepr );
+ if( xWindow.is() )
+ xWindow->addFocusListener( xListener );
+ }
+}
+
+void SAL_CALL SvxRectCtlAccessibleContext::removeFocusListener( const Reference< awt::XFocusListener >& xListener )
+ throw (RuntimeException)
+{
+ if( xListener.is() )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ThrowExceptionIfNotAlive();
+
+ Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( mpRepr );
+ if( xWindow.is() )
+ xWindow->removeFocusListener( xListener );
+ }
+}
+
+void SAL_CALL SvxRectCtlAccessibleContext::grabFocus() throw( RuntimeException )
+{
+ ::SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ThrowExceptionIfNotAlive();
+
+ mpRepr->GrabFocus();
+}
+
+Any SAL_CALL SvxRectCtlAccessibleContext::getAccessibleKeyBinding() throw( RuntimeException )
+{
+ // here is no implementation, because here are no KeyBindings for every object
+ return Any();
+}
+
+sal_Int32 SvxRectCtlAccessibleContext::getForeground( )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ThrowExceptionIfNotAlive();
+
+ return mpRepr->GetControlForeground().GetColor();
+}
+sal_Int32 SvxRectCtlAccessibleContext::getBackground( )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ThrowExceptionIfNotAlive();
+
+ return mpRepr->GetControlBackground().GetColor();
+}
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString SAL_CALL SvxRectCtlAccessibleContext::getImplementationName( void ) throw( RuntimeException )
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvxRectCtlAccessibleContext" ) );
+}
+
+sal_Bool SAL_CALL SvxRectCtlAccessibleContext::supportsService( const ::rtl::OUString& sServiceName ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ // Iterate over all supported service names and return true if on of them
+ // matches the given name.
+ Sequence< ::rtl::OUString > aSupportedServices( getSupportedServiceNames() );
+ int nLength = aSupportedServices.getLength();
+ const ::rtl::OUString* pStr = aSupportedServices.getConstArray();
+
+ for( int i = nLength ; i ; --i, ++pStr )
+ {
+ if( sServiceName == *pStr )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+Sequence< ::rtl::OUString > SAL_CALL SvxRectCtlAccessibleContext::getSupportedServiceNames( void ) throw( RuntimeException )
+{
+ const ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) );
+ return Sequence< ::rtl::OUString >( &sServiceName, 1 );
+}
+
+//===== XTypeProvider =======================================================
+
+Sequence< sal_Int8 > SAL_CALL SvxRectCtlAccessibleContext::getImplementationId( void ) throw( RuntimeException )
+{
+ return getUniqueId();
+}
+
+//===== XAccessibleSelection =============================================
+
+void SAL_CALL SvxRectCtlAccessibleContext::selectAccessibleChild( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException )
+{
+ ::SolarMutexGuard aSolarGuard;
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ checkChildIndex( nIndex );
+
+ ThrowExceptionIfNotAlive();
+
+ const ChildIndexToPointData* pData = IndexToPoint( nIndex, mbAngleMode );
+
+ DBG_ASSERT( pData,
+ "SvxRectCtlAccessibleContext::selectAccessibleChild(): this is an impossible state! Or at least should be..." );
+
+ // this does all wich is needed, including the change of the child's state!
+ mpRepr->SetActualRP( pData->ePoint );
+}
+
+sal_Bool SAL_CALL SvxRectCtlAccessibleContext::isAccessibleChildSelected( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ checkChildIndex( nIndex );
+
+ return nIndex == mnSelectedChild;
+}
+
+void SAL_CALL SvxRectCtlAccessibleContext::clearAccessibleSelection() throw( RuntimeException )
+{
+ DBG_ASSERT( sal_False, "SvxRectCtlAccessibleContext::clearAccessibleSelection() is not possible!" );
+}
+
+void SAL_CALL SvxRectCtlAccessibleContext::selectAllAccessibleChildren() throw( RuntimeException )
+{
+ // guard in selectAccessibleChild()!
+
+ selectAccessibleChild( 0 ); // default per definition
+}
+
+sal_Int32 SAL_CALL SvxRectCtlAccessibleContext::getSelectedAccessibleChildCount() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return mnSelectedChild == NOCHILDSELECTED? 0 : 1;
+}
+
+Reference< XAccessible > SAL_CALL SvxRectCtlAccessibleContext::getSelectedAccessibleChild( sal_Int32 nIndex )
+ throw( lang::IndexOutOfBoundsException, RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ checkChildIndexOnSelection( nIndex );
+
+ return getAccessibleChild( mnSelectedChild );
+}
+
+void SAL_CALL SvxRectCtlAccessibleContext::deselectAccessibleChild( sal_Int32 /*nIndex*/ ) throw( lang::IndexOutOfBoundsException, RuntimeException )
+{
+ ::rtl::OUString aMessage( RTL_CONSTASCII_USTRINGPARAM( "deselectAccessibleChild is not possible in this context" ) );
+
+ DBG_ASSERT( sal_False, "SvxRectCtlAccessibleContext::deselectAccessibleChild() is not possible!" );
+
+ throw lang::IndexOutOfBoundsException( aMessage, *this ); // never possible
+}
+
+//===== internals ========================================================
+
+void SvxRectCtlAccessibleContext::checkChildIndex( long nIndex ) throw( lang::IndexOutOfBoundsException )
+{
+ if( nIndex < 0 || nIndex >= getAccessibleChildCount() )
+ throw lang::IndexOutOfBoundsException();
+}
+
+void SvxRectCtlAccessibleContext::checkChildIndexOnSelection( long nIndex ) throw( lang::IndexOutOfBoundsException )
+{
+ if( nIndex || mnSelectedChild == NOCHILDSELECTED )
+ // in our case only for the first (0) _selected_ child this is a valid request
+ throw lang::IndexOutOfBoundsException();
+}
+
+void SvxRectCtlAccessibleContext::selectChild( long nNew )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if( nNew != mnSelectedChild )
+ {
+ long nNumOfChilds = getAccessibleChildCount();
+ if( nNew < nNumOfChilds )
+ { // valid index
+ SvxRectCtlChildAccessibleContext* pChild;
+ if( mnSelectedChild != NOCHILDSELECTED )
+ { // deselect old selected child if one is selected
+ pChild = mpChilds[ mnSelectedChild ];
+ if( pChild )
+ pChild->setStateChecked( sal_False );
+ }
+
+ // select new child
+ mnSelectedChild = nNew;
+
+ if( nNew != NOCHILDSELECTED )
+ {
+ pChild = mpChilds[ nNew ];
+ if( pChild )
+ pChild->setStateChecked( sal_True );
+ }
+ }
+ else
+ mnSelectedChild = NOCHILDSELECTED;
+ }
+}
+
+void SvxRectCtlAccessibleContext::selectChild( RECT_POINT eButton )
+{
+ // no guard -> is done in next selectChild
+ selectChild( PointToIndex( eButton, mbAngleMode ) );
+}
+
+void SvxRectCtlAccessibleContext::setName( const ::rtl::OUString& rName )
+{
+ Any aPreVal, aPostVal;
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ aPreVal <<= msName;
+ aPostVal <<= rName;
+
+ msName = rName;
+ }
+
+ const Reference< XInterface > xSource( *this );
+ CommitChange( AccessibleEventObject( xSource, AccessibleEventId::NAME_CHANGED, aPreVal, aPostVal ) );
+}
+
+void SvxRectCtlAccessibleContext::setDescription( const ::rtl::OUString& rDescr )
+{
+ Any aPreVal, aPostVal;
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ aPreVal <<= msDescription;
+ aPostVal <<= rDescr;
+
+ msDescription = rDescr;
+ }
+
+ const Reference< XInterface > xSource( *this );
+ CommitChange( AccessibleEventObject( xSource, AccessibleEventId::DESCRIPTION_CHANGED, aPreVal, aPostVal ) );
+}
+
+void SvxRectCtlAccessibleContext::CommitChange( const AccessibleEventObject& rEvent )
+{
+ if (mnClientId)
+ comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent );
+}
+
+void SAL_CALL SvxRectCtlAccessibleContext::disposing()
+{
+ if( !rBHelper.bDisposed )
+ {
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ mpRepr = NULL; // object dies with representation
+
+ SvxRectCtlChildAccessibleContext** p = mpChilds;
+ for( int i = MAX_NUM_OF_CHILDS ; i ; --i, ++p )
+ {
+ SvxRectCtlChildAccessibleContext* pChild = *p;
+ if( pChild )
+ {
+ pChild->dispose();
+ pChild->release();
+ *p = NULL;
+ }
+ }
+
+ delete[] mpChilds;
+ mpChilds = NULL;
+ }
+
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // Send a disposing to all listeners.
+ if ( mnClientId )
+ {
+ comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
+ mnClientId = 0;
+ }
+
+ mxParent = Reference< XAccessible >();
+ }
+ }
+}
+
+Rectangle SvxRectCtlAccessibleContext::GetBoundingBoxOnScreen( void ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ThrowExceptionIfNotAlive();
+
+ return Rectangle( mpRepr->GetParent()->OutputToScreenPixel( mpRepr->GetPosPixel() ), mpRepr->GetSizePixel() );
+}
+
+Rectangle SvxRectCtlAccessibleContext::GetBoundingBox( void ) throw( RuntimeException )
+{
+ ::SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ThrowExceptionIfNotAlive();
+
+ return Rectangle( mpRepr->GetPosPixel(), mpRepr->GetSizePixel() );
+}
+
+Sequence< sal_Int8 > SvxRectCtlAccessibleContext::getUniqueId( void )
+{
+ static OImplementationId* pId = 0;
+ if( !pId )
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if( !pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+void SvxRectCtlAccessibleContext::ThrowExceptionIfNotAlive( void ) throw( lang::DisposedException )
+{
+ if( IsNotAlive() )
+ throw lang::DisposedException();
+}
+
+// -------------------------------------------------------------------------------------------------
+
+
+DBG_NAME( SvxRectCtlChildAccessibleContext )
+
+
+SvxRectCtlChildAccessibleContext::SvxRectCtlChildAccessibleContext(
+ const Reference<XAccessible>& rxParent,
+ const Window& rParentWindow,
+ const ::rtl::OUString& rName,
+ const ::rtl::OUString& rDescription,
+ const Rectangle& rBoundingBox,
+ long nIndexInParent ) :
+
+ SvxRectCtlChildAccessibleContext_Base( maMutex ),
+ msDescription( rDescription ),
+ msName( rName ),
+ mxParent(rxParent),
+ mpBoundingBox( new Rectangle( rBoundingBox ) ),
+ mrParentWindow( rParentWindow ),
+ mnClientId( 0 ),
+ mnIndexInParent( nIndexInParent ),
+ mbIsChecked( sal_False )
+{
+ DBG_CTOR( SvxRectCtlChildAccessibleContext, NULL );
+}
+
+
+SvxRectCtlChildAccessibleContext::~SvxRectCtlChildAccessibleContext()
+{
+ DBG_DTOR( SvxRectCtlChildAccessibleContext, NULL );
+
+ if( IsAlive() )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose(); // set mpRepr = NULL & release all childs
+ }
+}
+
+//===== XAccessible =========================================================
+
+Reference< XAccessibleContext> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleContext( void ) throw( RuntimeException )
+{
+ return this;
+}
+
+//===== XAccessibleComponent ================================================
+
+sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::containsPoint( const awt::Point& rPoint ) throw( RuntimeException )
+{
+ // no guard -> done in getBounds()
+// return GetBoundingBox().IsInside( VCLPoint( rPoint ) );
+ return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
+}
+
+Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleAtPoint( const awt::Point& /*rPoint*/ ) throw( RuntimeException )
+{
+ return Reference< XAccessible >();
+}
+
+awt::Rectangle SAL_CALL SvxRectCtlChildAccessibleContext::getBounds() throw( RuntimeException )
+{
+ // no guard -> done in getBoundingBox()
+ return AWTRectangle( GetBoundingBox() );
+}
+
+awt::Point SAL_CALL SvxRectCtlChildAccessibleContext::getLocation() throw( RuntimeException )
+{
+ // no guard -> done in getBoundingBox()
+ return AWTPoint( GetBoundingBox().TopLeft() );
+}
+
+awt::Point SAL_CALL SvxRectCtlChildAccessibleContext::getLocationOnScreen() throw( RuntimeException )
+{
+ // no guard -> done in getBoundingBoxOnScreen()
+ return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
+}
+
+awt::Size SAL_CALL SvxRectCtlChildAccessibleContext::getSize() throw( RuntimeException )
+{
+ // no guard -> done in getBoundingBox()
+ return AWTSize( GetBoundingBox().GetSize() );
+}
+
+sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::isShowing() throw( RuntimeException )
+{
+ return sal_True;
+}
+
+sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::isVisible() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( maMutex );
+
+ ThrowExceptionIfNotAlive();
+
+ return mxParent.is()? ( static_cast< SvxRectCtlAccessibleContext* >( mxParent.get() ) )->isVisible() : sal_False;
+}
+
+sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::isFocusTraversable() throw( RuntimeException )
+{
+ return sal_False;
+}
+
+void SAL_CALL SvxRectCtlChildAccessibleContext::addFocusListener( const Reference< awt::XFocusListener >& /*xListener*/ )
+ throw( RuntimeException )
+{
+ OSL_ENSURE( false, "SvxRectCtlChildAccessibleContext::addFocusListener: not implemented" );
+}
+
+void SAL_CALL SvxRectCtlChildAccessibleContext::removeFocusListener( const Reference< awt::XFocusListener >& /*xListener*/ )
+ throw (RuntimeException)
+{
+ OSL_ENSURE( false, "SvxRectCtlChildAccessibleContext::removeFocusListener: not implemented" );
+}
+
+void SAL_CALL SvxRectCtlChildAccessibleContext::grabFocus() throw( RuntimeException )
+{
+}
+
+Any SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleKeyBinding() throw( RuntimeException )
+{
+ // here is no implementation, because here are no KeyBindings for every object
+ return Any();
+}
+sal_Int32 SvxRectCtlChildAccessibleContext::getForeground( )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( maMutex );
+ ThrowExceptionIfNotAlive();
+ return mrParentWindow.GetControlForeground().GetColor();
+}
+sal_Int32 SvxRectCtlChildAccessibleContext::getBackground( )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( maMutex );
+
+ ThrowExceptionIfNotAlive();
+ return mrParentWindow.GetControlBackground().GetColor();
+}
+
+//===== XAccessibleContext ==================================================
+
+sal_Int32 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleChildCount( void ) throw( RuntimeException )
+{
+ return 0;
+}
+
+Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleChild( sal_Int32 /*nIndex*/ ) throw ( RuntimeException, lang::IndexOutOfBoundsException )
+{
+ throw lang::IndexOutOfBoundsException();
+}
+
+Reference< XAccessible > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleParent( void ) throw( RuntimeException )
+{
+ return mxParent;
+}
+
+sal_Int32 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleIndexInParent( void ) throw( RuntimeException )
+{
+ return mnIndexInParent;
+}
+
+sal_Int16 SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRole( void ) throw( RuntimeException )
+{
+ return AccessibleRole::RADIO_BUTTON;
+}
+
+::rtl::OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleDescription( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ return msDescription;
+}
+
+::rtl::OUString SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleName( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ return msName;
+}
+
+/** Return empty reference to indicate that the relation set is not
+ supported.
+*/
+Reference<XAccessibleRelationSet> SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleRelationSet( void ) throw( RuntimeException )
+{
+ return Reference< XAccessibleRelationSet >();
+}
+
+Reference< XAccessibleStateSet > SAL_CALL SvxRectCtlChildAccessibleContext::getAccessibleStateSet( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
+
+ if( IsAlive() )
+ {
+ if( mbIsChecked )
+ {
+ pStateSetHelper->AddState( AccessibleStateType::CHECKED );
+// pStateSetHelper->AddState( AccessibleStateType::SELECTED );
+ }
+
+ pStateSetHelper->AddState( AccessibleStateType::ENABLED );
+ pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
+ pStateSetHelper->AddState( AccessibleStateType::OPAQUE );
+ pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
+ pStateSetHelper->AddState( AccessibleStateType::SHOWING );
+ pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
+ }
+ else
+ pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+
+ return pStateSetHelper;
+}
+
+lang::Locale SAL_CALL SvxRectCtlChildAccessibleContext::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException )
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ if( mxParent.is() )
+ {
+ Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() );
+ if( xParentContext.is() )
+ return xParentContext->getLocale();
+ }
+
+ // No locale and no parent. Therefore throw exception to indicate this
+ // cluelessness.
+ throw IllegalAccessibleComponentStateException();
+}
+
+void SAL_CALL SvxRectCtlChildAccessibleContext::addEventListener( const Reference< XAccessibleEventListener >& xListener )
+ throw( RuntimeException )
+{
+ if (xListener.is())
+ {
+ ::osl::MutexGuard aGuard( maMutex );
+ if (!mnClientId)
+ mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
+ comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
+ }
+}
+
+
+
+
+void SAL_CALL SvxRectCtlChildAccessibleContext::removeEventListener( const Reference< XAccessibleEventListener >& xListener )
+ throw( RuntimeException )
+{
+ if (xListener.is())
+ {
+ ::osl::MutexGuard aGuard( maMutex );
+
+ sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
+ if ( !nListenerCount )
+ {
+ // no listeners anymore
+ // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+ // and at least to us not firing any events anymore, in case somebody calls
+ // NotifyAccessibleEvent, again
+ comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
+ mnClientId = 0;
+ }
+ }
+}
+
+//===== XAccessibleValue ================================================
+
+Any SAL_CALL SvxRectCtlChildAccessibleContext::getCurrentValue() throw( RuntimeException )
+{
+ ThrowExceptionIfNotAlive();
+
+ Any aRet;
+ aRet <<= ( mbIsChecked? 1.0 : 0.0 );
+ return aRet;
+}
+
+sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::setCurrentValue( const Any& /*aNumber*/ ) throw( RuntimeException )
+{
+ return sal_False;
+}
+
+Any SAL_CALL SvxRectCtlChildAccessibleContext::getMaximumValue() throw( RuntimeException )
+{
+ Any aRet;
+ aRet <<= 1.0;
+ return aRet;
+}
+
+Any SAL_CALL SvxRectCtlChildAccessibleContext::getMinimumValue() throw( RuntimeException )
+{
+ Any aRet;
+ aRet <<= 0.0;
+ return aRet;
+}
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString SAL_CALL SvxRectCtlChildAccessibleContext::getImplementationName( void ) throw( RuntimeException )
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvxRectCtlChildAccessibleContext" ) );
+}
+
+sal_Bool SAL_CALL SvxRectCtlChildAccessibleContext::supportsService( const ::rtl::OUString& sServiceName ) throw( RuntimeException )
+{
+ // Iterate over all supported service names and return true if on of them
+ // matches the given name.
+ ::osl::MutexGuard aGuard( maMutex );
+ Sequence< ::rtl::OUString > aSupportedServices ( getSupportedServiceNames() );
+ int nLength = aSupportedServices.getLength();
+ for( int i = 0 ; i < nLength; ++i )
+ {
+ if( sServiceName == aSupportedServices[ i ] )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+Sequence< ::rtl::OUString > SAL_CALL SvxRectCtlChildAccessibleContext::getSupportedServiceNames( void ) throw( RuntimeException )
+{
+ const ::rtl::OUString sServiceName (RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.accessibility.AccessibleContext"));
+ return Sequence< ::rtl::OUString >( &sServiceName, 1 );
+}
+
+//===== XTypeProvider =======================================================
+
+Sequence< sal_Int8 > SAL_CALL SvxRectCtlChildAccessibleContext::getImplementationId( void ) throw( RuntimeException )
+{
+ static OImplementationId* pId = 0;
+ if( !pId )
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex() );
+ if( !pId)
+ {
+ static OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+//===== internal ============================================================
+
+void SvxRectCtlChildAccessibleContext::CommitChange( const AccessibleEventObject& rEvent )
+{
+ if (mnClientId)
+ comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent );
+}
+
+void SAL_CALL SvxRectCtlChildAccessibleContext::disposing()
+{
+ if( !rBHelper.bDisposed )
+ {
+ ::osl::MutexGuard aGuard( maMutex );
+
+ // Send a disposing to all listeners.
+ if ( mnClientId )
+ {
+ comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
+ mnClientId = 0;
+ }
+
+ mxParent = Reference< XAccessible >();
+
+ delete mpBoundingBox;
+ }
+}
+
+void SvxRectCtlChildAccessibleContext::ThrowExceptionIfNotAlive( void ) throw( lang::DisposedException )
+{
+ if( IsNotAlive() )
+ throw lang::DisposedException();
+}
+
+Rectangle SvxRectCtlChildAccessibleContext::GetBoundingBoxOnScreen( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( maMutex );
+
+ // no ThrowExceptionIfNotAlive() because its done in GetBoundingBox()
+ Rectangle aRect( GetBoundingBox() );
+
+ return Rectangle( mrParentWindow.OutputToScreenPixel( aRect.TopLeft() ), aRect.GetSize() );
+}
+
+Rectangle SvxRectCtlChildAccessibleContext::GetBoundingBox( void ) throw( RuntimeException )
+{
+ // no guard neccessary, because no one changes mpBoundingBox after creating it
+ ThrowExceptionIfNotAlive();
+
+ return *mpBoundingBox;
+}
+
+void SvxRectCtlChildAccessibleContext::setStateChecked( sal_Bool bChecked )
+{
+ if( mbIsChecked != bChecked )
+ {
+ mbIsChecked = bChecked;
+
+ const Reference< XInterface > xSource( *this );
+
+ Any aOld;
+ Any aNew;
+ Any& rMod = bChecked? aNew : aOld;
+
+ rMod <<= AccessibleStateType::CHECKED;
+
+ CommitChange( AccessibleEventObject( xSource, AccessibleEventId::STATE_CHANGED, aNew, aOld ) );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/core/coreservices.cxx b/svx/source/core/coreservices.cxx
new file mode 100644
index 000000000000..c6073aea3947
--- /dev/null
+++ b/svx/source/core/coreservices.cxx
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+/** this file contains the uno service registrations for all services in the svxcore lib */
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svx.hxx"
+
+#include "sal/types.h"
+#include "osl/diagnose.h"
+#include "cppuhelper/factory.hxx"
+#include "uno/lbnames.h"
+
+using rtl::OUString;
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+
+namespace svx
+{
+extern OUString SAL_CALL ExtrusionDepthController_getImplementationName();
+extern Reference< XInterface > SAL_CALL ExtrusionDepthController_createInstance(const Reference< XMultiServiceFactory > &) throw( RuntimeException );
+extern Sequence< OUString > SAL_CALL ExtrusionDepthController_getSupportedServiceNames() throw( RuntimeException );
+
+extern OUString SAL_CALL ExtrusionDirectionControl_getImplementationName();
+extern Reference< XInterface > SAL_CALL ExtrusionDirectionControl_createInstance(const Reference< XMultiServiceFactory > &) throw( RuntimeException );
+extern Sequence< OUString > SAL_CALL ExtrusionDirectionControl_getSupportedServiceNames() throw( RuntimeException );
+
+extern OUString SAL_CALL ExtrusionLightingControl_getImplementationName();
+extern Reference< XInterface > SAL_CALL ExtrusionLightingControl_createInstance(const Reference< XMultiServiceFactory > &) throw( RuntimeException );
+extern Sequence< OUString > SAL_CALL ExtrusionLightingControl_getSupportedServiceNames() throw( RuntimeException );
+
+extern OUString SAL_CALL ExtrusionSurfaceControl_getImplementationName();
+extern Reference< XInterface > SAL_CALL ExtrusionSurfaceControl_createInstance(const Reference< XMultiServiceFactory > &) throw( RuntimeException );
+extern Sequence< OUString > SAL_CALL ExtrusionSurfaceControl_getSupportedServiceNames() throw( RuntimeException );
+
+extern OUString SAL_CALL FontWorkAlignmentControl_getImplementationName();
+extern Reference< XInterface > SAL_CALL FontWorkAlignmentControl_createInstance(const Reference< XMultiServiceFactory > &) throw( RuntimeException );
+extern Sequence< OUString > SAL_CALL FontWorkAlignmentControl_getSupportedServiceNames() throw( RuntimeException );
+
+extern OUString SAL_CALL FontWorkCharacterSpacingControl_getImplementationName();
+extern Reference< XInterface > SAL_CALL FontWorkCharacterSpacingControl_createInstance(const Reference< XMultiServiceFactory > &) throw( RuntimeException );
+extern Sequence< OUString > SAL_CALL FontWorkCharacterSpacingControl_getSupportedServiceNames() throw( RuntimeException );
+}
+
+extern "C"
+{
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment (
+ const sal_Char ** ppEnvTypeName, uno_Environment ** )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+static void writeInfo (
+ XRegistryKey * pRegistryKey,
+ const OUString& rImplementationName,
+ const Sequence< OUString >& rServices)
+{
+ Reference< XRegistryKey > xNewKey(
+ pRegistryKey->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + rImplementationName + OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) ) );
+
+ for( sal_Int32 i = 0; i < rServices.getLength(); i++ )
+ xNewKey->createKey( rServices.getConstArray()[i]);
+}
+
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo (
+ void * , void * pRegistryKey)
+{
+ if( pRegistryKey )
+ {
+ try
+ {
+ XRegistryKey *pKey = reinterpret_cast< XRegistryKey * >( pRegistryKey );
+
+ writeInfo( pKey, ::svx::ExtrusionDepthController_getImplementationName(),::svx::ExtrusionDepthController_getSupportedServiceNames() );
+ writeInfo( pKey, ::svx::ExtrusionDirectionControl_getImplementationName(),::svx::ExtrusionDirectionControl_getSupportedServiceNames() );
+ writeInfo( pKey, ::svx::ExtrusionLightingControl_getImplementationName(),::svx::ExtrusionLightingControl_getSupportedServiceNames() );
+ writeInfo( pKey, ::svx::ExtrusionSurfaceControl_getImplementationName(),::svx::ExtrusionSurfaceControl_getSupportedServiceNames() );
+ writeInfo( pKey, ::svx::FontWorkAlignmentControl_getImplementationName(),::svx::FontWorkAlignmentControl_getSupportedServiceNames() );
+ writeInfo( pKey, ::svx::FontWorkCharacterSpacingControl_getImplementationName(),::svx::FontWorkCharacterSpacingControl_getSupportedServiceNames() );
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+
+ return sal_True;
+}
+
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory (
+ const sal_Char * pImplName, void * pServiceManager, void * )
+{
+ void * pRet = 0;
+ if( pServiceManager )
+ {
+ Reference< XSingleServiceFactory > xFactory;
+
+ if( ::svx::ExtrusionDepthController_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ ::svx::ExtrusionDepthController_getImplementationName(),
+ ::svx::ExtrusionDepthController_createInstance,
+ ::svx::ExtrusionDepthController_getSupportedServiceNames() );
+ }
+ else if( ::svx::ExtrusionDirectionControl_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ ::svx::ExtrusionDirectionControl_getImplementationName(),
+ ::svx::ExtrusionDirectionControl_createInstance,
+ ::svx::ExtrusionDirectionControl_getSupportedServiceNames() );
+ }
+ else if( ::svx::ExtrusionLightingControl_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ ::svx::ExtrusionLightingControl_getImplementationName(),
+ ::svx::ExtrusionLightingControl_createInstance,
+ ::svx::ExtrusionLightingControl_getSupportedServiceNames() );
+ }
+ else if( ::svx::ExtrusionSurfaceControl_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ ::svx::ExtrusionSurfaceControl_getImplementationName(),
+ ::svx::ExtrusionSurfaceControl_createInstance,
+ ::svx::ExtrusionSurfaceControl_getSupportedServiceNames() );
+ }
+ else if( ::svx::FontWorkAlignmentControl_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ ::svx::FontWorkAlignmentControl_getImplementationName(),
+ ::svx::FontWorkAlignmentControl_createInstance,
+ ::svx::FontWorkAlignmentControl_getSupportedServiceNames() );
+ }
+ else if( ::svx::FontWorkCharacterSpacingControl_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ ::svx::FontWorkCharacterSpacingControl_getImplementationName(),
+ ::svx::FontWorkCharacterSpacingControl_createInstance,
+ ::svx::FontWorkCharacterSpacingControl_getSupportedServiceNames() );
+ } if( xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/core/makefile.mk b/svx/source/core/makefile.mk
new file mode 100644
index 000000000000..da874894bae6
--- /dev/null
+++ b/svx/source/core/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+TARGET=core
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/coreservices.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
new file mode 100644
index 000000000000..f67449b858c1
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -0,0 +1,2187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "EnhancedCustomShape2d.hxx"
+#include "EnhancedCustomShapeGeometry.hxx"
+#include "EnhancedCustomShapeTypeNames.hxx"
+#include <svx/svdoashp.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdocirc.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/sdasaitm.hxx>
+#include <svx/svdmodel.hxx>
+#include <rtl/crc.h>
+#include <rtl/math.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xlnstcit.hxx>
+#include <svx/xlnedcit.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xgrad.hxx>
+#include <svx/xbitmap.hxx>
+#include <svx/xhatch.hxx>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
+#include <boost/shared_ptr.hpp>
+#include <basegfx/numeric/ftools.hxx>
+#include <basegfx/color/bcolortools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+// #i76201#
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+#include <math.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::drawing::EnhancedCustomShapeSegmentCommand;
+
+void EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( EnhancedCustomShapeParameter& rParameter, const sal_Int32 nValue )
+{
+ sal_uInt32 nDat = (sal_uInt32)nValue;
+ sal_Int32 nNewValue = nValue;
+
+ // check if this is a special point
+ if ( ( nDat >> 16 ) == 0x8000 )
+ {
+ nNewValue = (sal_uInt16)nDat;
+ rParameter.Type = EnhancedCustomShapeParameterType::EQUATION;
+ }
+ else
+ rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
+ rParameter.Value <<= nNewValue;
+}
+
+rtl::OUString EnhancedCustomShape2d::GetEquation( const sal_uInt16 nFlags, sal_Int16 nP1, sal_Int16 nP2, sal_Int16 nP3 )
+{
+ rtl::OUString aEquation;
+ sal_Bool b1Special = ( nFlags & 0x2000 ) != 0;
+ sal_Bool b2Special = ( nFlags & 0x4000 ) != 0;
+ sal_Bool b3Special = ( nFlags & 0x8000 ) != 0;
+ switch( nFlags & 0xff )
+ {
+ case 0 :
+ case 14 :
+ {
+ sal_Int32 nOptimize = 0;
+ if ( nP1 )
+ nOptimize |= 1;
+ if ( nP2 )
+ nOptimize |= 2;
+ if ( b1Special )
+ nOptimize |= 4;
+ if ( b2Special )
+ nOptimize |= 8;
+ switch( nOptimize )
+ {
+ case 0 :
+ break;
+ case 1 :
+ case 4 :
+ case 5 :
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ break;
+ case 2 :
+ case 8 :
+ case 10:
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ break;
+ default :
+ {
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( (sal_Unicode)'+' );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ }
+ break;
+ }
+ if ( b3Special || nP3 )
+ {
+ aEquation += rtl::OUString( (sal_Unicode)'-' );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ }
+ }
+ break;
+ case 1 :
+ {
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ if ( b2Special || ( nP2 != 1 ) )
+ {
+ aEquation += rtl::OUString( (sal_Unicode)'*' );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ }
+ if ( b3Special || ( ( nP3 != 1 ) && ( nP3 != 0 ) ) )
+ {
+ aEquation += rtl::OUString( (sal_Unicode)'/' );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ }
+ }
+ break;
+ case 2 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")/2" ) );
+ }
+ break;
+ case 3 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "abs(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
+ }
+ break;
+ case 4 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "min(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
+ }
+ break;
+ case 5 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "max(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
+ }
+ break;
+ case 6 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "if(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( (sal_Unicode)',' );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( (sal_Unicode)',' );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( (sal_Unicode)')' );
+ }
+ break;
+ case 7 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "+" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( (sal_Unicode)')' );
+ }
+ break;
+ case 8 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "atan2(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")/(pi/180)" ) );
+ }
+ break;
+ case 9 :
+ {
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*sin(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))" ) );
+ }
+ break;
+ case 10 :
+ {
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*cos(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))" ) );
+ }
+ break;
+ case 11 :
+ {
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "cos(atan2(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
+ }
+ break;
+ case 12 :
+ {
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sin(atan2(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "," ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
+ }
+ break;
+ case 13 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
+ }
+ break;
+ case 15 :
+ {
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*sqrt(1-(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "))" ) );
+ }
+ break;
+ case 16 :
+ {
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*tan(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ")" ) );
+ }
+ break;
+ case 0x80 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "sqrt(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( (sal_Unicode)')' );
+ }
+ break;
+ case 0x81 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "(cos(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800)+sin(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800))+10800" ) );
+ }
+ break;
+ case 0x82 :
+ {
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-(sin(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP1, b1Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800)-cos(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP3, b3Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "*(pi/180))*(" ) );
+ EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( aEquation, nP2, b2Special );
+ aEquation += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "-10800))+10800" ) );
+ }
+ break;
+ }
+ return aEquation;
+}
+
+void EnhancedCustomShape2d::AppendEnhancedCustomShapeEquationParameter( rtl::OUString& rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue )
+{
+ if ( bIsSpecialValue )
+ {
+ if ( nPara & 0x400 )
+ {
+ rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "?" ) );
+ rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara & 0xff ) );
+ rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( " " ) );
+ }
+ else
+ {
+ switch( nPara )
+ {
+ case DFF_Prop_adjustValue :
+ case DFF_Prop_adjust2Value :
+ case DFF_Prop_adjust3Value :
+ case DFF_Prop_adjust4Value :
+ case DFF_Prop_adjust5Value :
+ case DFF_Prop_adjust6Value :
+ case DFF_Prop_adjust7Value :
+ case DFF_Prop_adjust8Value :
+ case DFF_Prop_adjust9Value :
+ case DFF_Prop_adjust10Value :
+ {
+ rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "$" ) );
+ rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara - DFF_Prop_adjustValue ) );
+ rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( " " ) );
+ }
+ break;
+ case DFF_Prop_geoLeft :
+ {
+ rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "left" ) );
+ }
+ break;
+ case DFF_Prop_geoTop :
+ {
+ rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "top" ) );
+ }
+ break;
+ case DFF_Prop_geoRight :
+ {
+ rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "right" ) );
+ }
+ break;
+ case DFF_Prop_geoBottom :
+ {
+ rParameter += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "bottom" ) );
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ rParameter += rtl::OUString::valueOf( (sal_Int32)( nPara ) );
+ }
+}
+
+void EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( EnhancedCustomShapeParameter& rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue, sal_Bool bHorz )
+{
+ sal_Int32 nValue = 0;
+ if ( bIsSpecialValue )
+ {
+ if ( ( nPara >= 0x100 ) && ( nPara <= 0x107 ) )
+ {
+ nValue = nPara & 0xff;
+ rParameter.Type = EnhancedCustomShapeParameterType::ADJUSTMENT;
+ }
+ else if ( ( nPara >= 3 ) && ( nPara <= 0x82 ) )
+ {
+ nValue = nPara - 3;
+ rParameter.Type = EnhancedCustomShapeParameterType::EQUATION;
+ }
+ else if ( nPara == 0 )
+ {
+ nValue = 0;
+ if ( bHorz )
+ rParameter.Type = EnhancedCustomShapeParameterType::LEFT;
+ else
+ rParameter.Type = EnhancedCustomShapeParameterType::TOP;
+ }
+ else if ( nPara == 1 )
+ {
+ nValue = 0;
+ if ( bHorz )
+ rParameter.Type = EnhancedCustomShapeParameterType::RIGHT;
+ else
+ rParameter.Type = EnhancedCustomShapeParameterType::BOTTOM;
+ }
+ else if ( nPara == 2 ) // means to be centered, but should not be
+ { // used in our implementation
+ nValue = 5600;
+ rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
+ }
+ else
+ {
+ nValue = nPara;
+ rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
+ }
+ }
+ else
+ {
+ nValue = nPara;
+ rParameter.Type = EnhancedCustomShapeParameterType::NORMAL;
+ }
+ rParameter.Value <<= nValue;
+}
+
+sal_Bool EnhancedCustomShape2d::ConvertSequenceToEnhancedCustomShape2dHandle(
+ const com::sun::star::beans::PropertyValues& rHandleProperties,
+ EnhancedCustomShape2d::Handle& rDestinationHandle )
+{
+ sal_Bool bRetValue = sal_False;
+ sal_uInt32 i, nProperties = rHandleProperties.getLength();
+ if ( nProperties )
+ {
+ rDestinationHandle.nFlags = 0;
+ for ( i = 0; i < nProperties; i++ )
+ {
+ const com::sun::star::beans::PropertyValue& rPropVal = rHandleProperties[ i ];
+
+ const rtl::OUString sPosition ( RTL_CONSTASCII_USTRINGPARAM( "Position" ) );
+ const rtl::OUString sMirroredX ( RTL_CONSTASCII_USTRINGPARAM( "MirroredX" ) );
+ const rtl::OUString sMirroredY ( RTL_CONSTASCII_USTRINGPARAM( "MirroredY" ) );
+ const rtl::OUString sSwitched ( RTL_CONSTASCII_USTRINGPARAM( "Switched" ) );
+ const rtl::OUString sPolar ( RTL_CONSTASCII_USTRINGPARAM( "Polar" ) );
+// const rtl::OUString sMap ( RTL_CONSTASCII_USTRINGPARAM( "Map" ) );
+ const rtl::OUString sRefX ( RTL_CONSTASCII_USTRINGPARAM( "RefX" ) );
+ const rtl::OUString sRefY ( RTL_CONSTASCII_USTRINGPARAM( "RefY" ) );
+ const rtl::OUString sRefAngle ( RTL_CONSTASCII_USTRINGPARAM( "RefAngle" ) );
+ const rtl::OUString sRefR ( RTL_CONSTASCII_USTRINGPARAM( "RefR" ) );
+ const rtl::OUString sRadiusRangeMinimum ( RTL_CONSTASCII_USTRINGPARAM( "RadiusRangeMinimum" ) );
+ const rtl::OUString sRadiusRangeMaximum ( RTL_CONSTASCII_USTRINGPARAM( "RadiusRangeMaximum" ) );
+ const rtl::OUString sRangeXMinimum ( RTL_CONSTASCII_USTRINGPARAM( "RangeXMinimum" ) );
+ const rtl::OUString sRangeXMaximum ( RTL_CONSTASCII_USTRINGPARAM( "RangeXMaximum" ) );
+ const rtl::OUString sRangeYMinimum ( RTL_CONSTASCII_USTRINGPARAM( "RangeYMinimum" ) );
+ const rtl::OUString sRangeYMaximum ( RTL_CONSTASCII_USTRINGPARAM( "RangeYMaximum" ) );
+
+ if ( rPropVal.Name.equals( sPosition ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.aPosition )
+ bRetValue = sal_True;
+ }
+ else if ( rPropVal.Name.equals( sMirroredX ) )
+ {
+ sal_Bool bMirroredX = sal_Bool();
+ if ( rPropVal.Value >>= bMirroredX )
+ {
+ if ( bMirroredX )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_X;
+ }
+ }
+ else if ( rPropVal.Name.equals( sMirroredY ) )
+ {
+ sal_Bool bMirroredY = sal_Bool();
+ if ( rPropVal.Value >>= bMirroredY )
+ {
+ if ( bMirroredY )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_MIRRORED_Y;
+ }
+ }
+ else if ( rPropVal.Name.equals( sSwitched ) )
+ {
+ sal_Bool bSwitched = sal_Bool();
+ if ( rPropVal.Value >>= bSwitched )
+ {
+ if ( bSwitched )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_SWITCHED;
+ }
+ }
+ else if ( rPropVal.Name.equals( sPolar ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.aPolar )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_POLAR;
+ }
+/* seems not to be used.
+ else if ( rPropVal.Name.equals( sMap ) )
+ {
+ com::sun::star::drawing::EnhancedCustomShapeParameterPair aMap;
+ if ( rPropVal.Value >>= aMap )
+ {
+ if ( GetValueForEnhancedCustomShapeHandleParameter( nXMap, aMap.First ) )
+ rDestinationHandle.Flags |= 0x800;
+ if ( GetValueForEnhancedCustomShapeHandleParameter( nYMap, aMap.Second ) )
+ rDestinationHandle.Flags |= 0x1000;
+ rDestinationHandle.Flags |= 0x10;
+ }
+ }
+*/
+ else if ( rPropVal.Name.equals( sRefX ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.nRefX )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_REFX;
+ }
+ else if ( rPropVal.Name.equals( sRefY ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.nRefY )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_REFY;
+ }
+ else if ( rPropVal.Name.equals( sRefAngle ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.nRefAngle )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_REFANGLE;
+ }
+ else if ( rPropVal.Name.equals( sRefR ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.nRefR )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_REFR;
+ }
+ else if ( rPropVal.Name.equals( sRadiusRangeMinimum ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMinimum )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MINIMUM;
+ }
+ else if ( rPropVal.Name.equals( sRadiusRangeMaximum ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.aRadiusRangeMaximum )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM;
+ }
+ else if ( rPropVal.Name.equals( sRangeXMinimum ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.aXRangeMinimum )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MINIMUM;
+ }
+ else if ( rPropVal.Name.equals( sRangeXMaximum ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.aXRangeMaximum )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_X_MAXIMUM;
+ }
+ else if ( rPropVal.Name.equals( sRangeYMinimum ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.aYRangeMinimum )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MINIMUM;
+ }
+ else if ( rPropVal.Name.equals( sRangeYMaximum ) )
+ {
+ if ( rPropVal.Value >>= rDestinationHandle.aYRangeMaximum )
+ rDestinationHandle.nFlags |= HANDLE_FLAGS_RANGE_Y_MAXIMUM;
+ }
+ }
+ }
+ return bRetValue;
+}
+
+const sal_Int32* EnhancedCustomShape2d::ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rGeometryItem )
+{
+ const sal_Int32* pDefData = NULL;
+ const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
+ if ( pDefCustomShape )
+ pDefData = pDefCustomShape->pDefData;
+
+ //////////////////////
+ // AdjustmentValues //
+ //////////////////////
+ const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
+ const Any* pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sAdjustmentValues );
+ if ( pAny )
+ *pAny >>= seqAdjustmentValues;
+
+ ///////////////
+ // Coordsize //
+ ///////////////
+ const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
+ const Any* pViewBox = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sViewBox );
+ com::sun::star::awt::Rectangle aViewBox;
+ if ( pViewBox && (*pViewBox >>= aViewBox ) )
+ {
+ nCoordLeft = aViewBox.X;
+ nCoordTop = aViewBox.Y;
+ nCoordWidth = labs( aViewBox.Width );
+ nCoordHeight= labs( aViewBox.Height);
+ }
+ const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
+
+ //////////////////////
+ // Path/Coordinates //
+ //////////////////////
+ const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
+ if ( pAny )
+ *pAny >>= seqCoordinates;
+
+ /////////////////////
+ // Path/GluePoints //
+ /////////////////////
+ const rtl::OUString sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sGluePoints );
+ if ( pAny )
+ *pAny >>= seqGluePoints;
+
+ ///////////////////
+ // Path/Segments //
+ ///////////////////
+ const rtl::OUString sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sSegments );
+ if ( pAny )
+ *pAny >>= seqSegments;
+
+ ///////////////////
+ // Path/StretchX //
+ ///////////////////
+ const rtl::OUString sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sStretchX );
+ if ( pAny )
+ {
+ sal_Int32 nStretchX = 0;
+ if ( *pAny >>= nStretchX )
+ nXRef = nStretchX;
+ }
+
+ ///////////////////
+ // Path/StretchY //
+ ///////////////////
+ const rtl::OUString sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sStretchY );
+ if ( pAny )
+ {
+ sal_Int32 nStretchY = 0;
+ if ( *pAny >>= nStretchY )
+ nYRef = nStretchY;
+ }
+
+ /////////////////////
+ // Path/TextFrames //
+ /////////////////////
+ const rtl::OUString sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sPath, sTextFrames );
+ if ( pAny )
+ *pAny >>= seqTextFrames;
+
+ ///////////////
+ // Equations //
+ ///////////////
+ const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sEquations );
+ if ( pAny )
+ *pAny >>= seqEquations;
+
+ /////////////
+ // Handles //
+ /////////////
+ const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( sHandles );
+ if ( pAny )
+ *pAny >>= seqHandles;
+
+ return pDefData;
+}
+
+EnhancedCustomShape2d::~EnhancedCustomShape2d()
+{
+}
+
+EnhancedCustomShape2d::EnhancedCustomShape2d( SdrObject* pAObj ) :
+ SfxItemSet ( pAObj->GetMergedItemSet() ),
+ pCustomShapeObj ( pAObj ),
+ eSpType ( mso_sptNil ),
+ nCoordLeft ( 0 ),
+ nCoordTop ( 0 ),
+ nCoordWidth ( 21600 ),
+ nCoordHeight ( 21600 ),
+ nXRef ( 0x80000000 ),
+ nYRef ( 0x80000000 ),
+ nFlags ( 0 ),
+ nColorData ( 0 ),
+ bTextFlow ( sal_False ),
+ bFilled ( ((const XFillStyleItem&)pAObj->GetMergedItem( XATTR_FILLSTYLE )).GetValue() != XFILL_NONE ),
+ bStroked ( ((const XLineStyleItem&)pAObj->GetMergedItem( XATTR_LINESTYLE )).GetValue() != XLINE_NONE ),
+ bFlipH ( sal_False ),
+ bFlipV ( sal_False )
+{
+ // bTextFlow needs to be set before clearing the TextDirection Item
+
+ ClearItem( SDRATTR_TEXTDIRECTION ); //SJ: vertical writing is not required, by removing this item no outliner is created
+
+ // #i105323# For 2D AtoShapes, the shadow attirbute does not need to be applied to any
+ // of the constucted helper SdrObjects. This would lead to problems since the shadow
+ // of one helper object would fall on one helper object behind it (e.g. with the
+ // eyes of the smiley shape). This is not wanted; instead a single shadow 'behind'
+ // the AutoShape visualisation is wanted. This is done with primitive functionailty
+ // now in SdrCustomShapePrimitive2D::create2DDecomposition, but only for 2D objects
+ // (see there and in EnhancedCustomShape3d::Create3DObject to read more).
+ // This exception may be removed later when AutoShapes will create primitives directly.
+ // So, currently remove the ShadowAttribute from the ItemSet to not apply it to any
+ // 2D helper shape.
+ ClearItem(SDRATTR_SHADOW);
+
+ Point aP( pCustomShapeObj->GetSnapRect().Center() );
+ Size aS( pCustomShapeObj->GetLogicRect().GetSize() );
+ aP.X() -= aS.Width() / 2;
+ aP.Y() -= aS.Height() / 2;
+ aLogicRect = Rectangle( aP, aS );
+
+ const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
+ const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
+ const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
+
+ rtl::OUString sShapeType;
+ SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)(const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ Any* pAny = rGeometryItem.GetPropertyValueByName( sType );
+ if ( pAny )
+ *pAny >>= sShapeType;
+ eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
+
+ pAny = rGeometryItem.GetPropertyValueByName( sMirroredX );
+ if ( pAny )
+ *pAny >>= bFlipH;
+ pAny = rGeometryItem.GetPropertyValueByName( sMirroredY );
+ if ( pAny )
+ *pAny >>= bFlipV;
+
+ if ( pCustomShapeObj->ISA( SdrObjCustomShape ) ) // should always be a SdrObjCustomShape, but you don't know
+ nRotateAngle = (sal_Int32)(((SdrObjCustomShape*)pCustomShapeObj)->GetObjectRotation() * 100.0);
+ else
+ nRotateAngle = pCustomShapeObj->GetRotateAngle();
+
+ /*const sal_Int32* pDefData =*/ ApplyShapeAttributes( rGeometryItem );
+ switch( eSpType )
+ {
+ case mso_sptCan : nColorData = 0x20400000; break;
+ case mso_sptCube : nColorData = 0x302e0000; break;
+ case mso_sptActionButtonBlank : nColorData = 0x502ce400; break;
+ case mso_sptActionButtonHome : nColorData = 0x702ce4ce; break;
+ case mso_sptActionButtonHelp : nColorData = 0x602ce4c0; break;
+ case mso_sptActionButtonInformation : nColorData = 0x702ce4c5; break;
+ case mso_sptActionButtonBackPrevious : nColorData = 0x602ce4c0; break;
+ case mso_sptActionButtonForwardNext : nColorData = 0x602ce4c0; break;
+ case mso_sptActionButtonBeginning : nColorData = 0x602ce4c0; break;
+ case mso_sptActionButtonEnd : nColorData = 0x602ce4c0; break;
+ case mso_sptActionButtonReturn : nColorData = 0x602ce4c0; break;
+ case mso_sptActionButtonDocument : nColorData = 0x702ce4ec; break;
+ case mso_sptActionButtonSound : nColorData = 0x602ce4c0; break;
+ case mso_sptActionButtonMovie : nColorData = 0x602ce4c0; break;
+ case mso_sptBevel : nColorData = 0x502ce400; break;
+ case mso_sptFoldedCorner : nColorData = 0x20e00000; break;
+ case mso_sptSmileyFace : nColorData = 0x20e00000; break;
+ case mso_sptNil :
+ {
+ if( sShapeType.getLength() > 4 &&
+ sShapeType.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "col-" )))
+ {
+ nColorData = sShapeType.copy( 4 ).toInt32( 16 );
+ }
+ }
+ break;
+ case mso_sptCurvedLeftArrow :
+ case mso_sptCurvedRightArrow :
+ case mso_sptCurvedUpArrow :
+ case mso_sptCurvedDownArrow : nColorData = 0x2d000000; break;
+ case mso_sptRibbon2 : nColorData = 0x30ee0000; break;
+ case mso_sptRibbon : nColorData = 0x30ee0000; break;
+
+ case mso_sptEllipseRibbon2 : nColorData = 0x30ee0000; break;
+ case mso_sptEllipseRibbon : nColorData = 0x30ee0000; break;
+
+ case mso_sptVerticalScroll : nColorData = 0x30ee0000; break;
+ case mso_sptHorizontalScroll : nColorData = 0x30ee0000; break;
+ default:
+ break;
+ }
+ fXScale = nCoordWidth == 0 ? 0.0 : (double)aLogicRect.GetWidth() / (double)nCoordWidth;
+ fYScale = nCoordHeight == 0 ? 0.0 : (double)aLogicRect.GetHeight() / (double)nCoordHeight;
+ if ( (sal_uInt32)nXRef != 0x80000000 && aLogicRect.GetHeight() )
+ {
+ fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight();
+ if ( fXRatio > 1 )
+ fXScale /= fXRatio;
+ else
+ fXRatio = 1.0;
+ }
+ else
+ fXRatio = 1.0;
+ if ( (sal_uInt32)nYRef != 0x80000000 && aLogicRect.GetWidth() )
+ {
+ fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth();
+ if ( fYRatio > 1 )
+ fYScale /= fYRatio;
+ else
+ fYRatio = 1.0;
+ }
+ else
+ fYRatio = 1.0;
+
+ sal_Int32 i, nLength = seqEquations.getLength();
+
+
+ if ( nLength )
+ {
+ vNodesSharedPtr.resize( nLength );
+ for ( i = 0; i < seqEquations.getLength(); i++ )
+ {
+ try
+ {
+ vNodesSharedPtr[ i ] = EnhancedCustomShape::FunctionParser::parseFunction( seqEquations[ i ], *this );
+ }
+ catch ( EnhancedCustomShape::ParseError& )
+ {
+ }
+ }
+ }
+}
+double EnhancedCustomShape2d::GetEnumFunc( const EnumFunc eFunc ) const
+{
+ double fRet = 0.0;
+ switch( eFunc )
+ {
+ case ENUM_FUNC_PI : fRet = F_PI; break;
+ case ENUM_FUNC_LEFT : fRet = 0.0; break;
+ case ENUM_FUNC_TOP : fRet = 0.0; break;
+ case ENUM_FUNC_RIGHT : fRet = (double)nCoordWidth * fXRatio; break;
+ case ENUM_FUNC_BOTTOM : fRet = (double)nCoordHeight * fYRatio; break;
+ case ENUM_FUNC_XSTRETCH : fRet = nXRef; break;
+ case ENUM_FUNC_YSTRETCH : fRet = nYRef; break;
+ case ENUM_FUNC_HASSTROKE : fRet = bStroked ? 1.0 : 0.0; break;
+ case ENUM_FUNC_HASFILL : fRet = bFilled ? 1.0 : 0.0; break;
+ case ENUM_FUNC_WIDTH : fRet = nCoordWidth; break;
+ case ENUM_FUNC_HEIGHT : fRet = nCoordHeight; break;
+ case ENUM_FUNC_LOGWIDTH : fRet = aLogicRect.GetWidth(); break;
+ case ENUM_FUNC_LOGHEIGHT : fRet = aLogicRect.GetHeight(); break;
+ }
+ return fRet;
+}
+double EnhancedCustomShape2d::GetAdjustValueAsDouble( const sal_Int32 nIndex ) const
+{
+ double fNumber = 0.0;
+ if ( nIndex < seqAdjustmentValues.getLength() )
+ {
+ if ( seqAdjustmentValues[ nIndex ].Value.getValueTypeClass() == TypeClass_DOUBLE )
+ seqAdjustmentValues[ nIndex ].Value >>= fNumber;
+ else
+ {
+ sal_Int32 nNumber = 0;
+ seqAdjustmentValues[ nIndex ].Value >>= nNumber;
+ fNumber = (double)nNumber;
+ }
+ }
+ return fNumber;
+}
+double EnhancedCustomShape2d::GetEquationValueAsDouble( const sal_Int32 nIndex ) const
+{
+ double fNumber = 0.0;
+ if ( nIndex < (sal_Int32)vNodesSharedPtr.size() )
+ {
+ if ( vNodesSharedPtr[ nIndex ].get() )
+ try
+ {
+ fNumber = (*vNodesSharedPtr[ nIndex ])();
+ if ( !rtl::math::isFinite( fNumber ) )
+ fNumber = 0.0;
+ }
+ catch ( ... )
+ {
+ /* sal_Bool bUps = sal_True; */
+ }
+ }
+ return fNumber;
+}
+sal_Int32 EnhancedCustomShape2d::GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault ) const
+{
+ sal_Int32 nNumber = nDefault;
+ if ( nIndex < seqAdjustmentValues.getLength() )
+ {
+ if ( seqAdjustmentValues[ nIndex ].Value.getValueTypeClass() == TypeClass_DOUBLE )
+ {
+ double fNumber = 0;
+ seqAdjustmentValues[ nIndex ].Value >>= fNumber;
+ nNumber = (sal_Int32)fNumber;
+ }
+ else
+ seqAdjustmentValues[ nIndex ].Value >>= nNumber;
+ }
+ return nNumber;
+}
+sal_Bool EnhancedCustomShape2d::SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex )
+{
+ sal_Bool bRetValue = sal_False;
+ if ( nIndex < seqAdjustmentValues.getLength() )
+ {
+ // updating our local adjustment sequence
+ seqAdjustmentValues[ nIndex ].Value <<= rValue;
+ seqAdjustmentValues[ nIndex ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
+ bRetValue = sal_True;
+ }
+ return bRetValue;
+}
+
+Point EnhancedCustomShape2d::GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair& rPair,
+ const sal_Bool bScale, const sal_Bool bReplaceGeoSize ) const
+{
+ Point aRetValue;
+ sal_Bool bExchange = ( nFlags & DFF_CUSTOMSHAPE_EXCH ) != 0; // x <-> y
+ sal_uInt32 nPass = 0;
+ do
+ {
+ sal_uInt32 nIndex = nPass;
+
+ if ( bExchange )
+ nIndex ^= 1;
+
+ double fVal;
+ const EnhancedCustomShapeParameter& rParameter = nIndex ? rPair.Second : rPair.First;
+ if ( nPass ) // height
+ {
+ GetParameter( fVal, rParameter, sal_False, bReplaceGeoSize );
+ fVal -= nCoordTop;
+ if ( bScale )
+ {
+ fVal *= fYScale;
+
+ if ( nFlags & DFF_CUSTOMSHAPE_FLIP_V )
+ fVal = aLogicRect.GetHeight() - fVal;
+ }
+ aRetValue.Y() = (sal_Int32)fVal;
+ }
+ else // width
+ {
+ GetParameter( fVal, rParameter, bReplaceGeoSize, sal_False );
+ fVal -= nCoordLeft;
+ if ( bScale )
+ {
+ fVal *= fXScale;
+
+ if ( nFlags & DFF_CUSTOMSHAPE_FLIP_H )
+ fVal = aLogicRect.GetWidth() - fVal;
+ }
+ aRetValue.X() = (sal_Int32)fVal;
+ }
+ }
+ while ( ++nPass < 2 );
+ return aRetValue;
+}
+
+sal_Bool EnhancedCustomShape2d::GetParameter( double& rRetValue, const EnhancedCustomShapeParameter& rParameter,
+ const sal_Bool bReplaceGeoWidth, const sal_Bool bReplaceGeoHeight ) const
+{
+ rRetValue = 0.0;
+ sal_Bool bRetValue = sal_False;
+ switch ( rParameter.Type )
+ {
+ case EnhancedCustomShapeParameterType::ADJUSTMENT :
+ {
+ sal_Int32 nAdjustmentIndex = 0;
+ if ( rParameter.Value >>= nAdjustmentIndex )
+ {
+ rRetValue = GetAdjustValueAsDouble( nAdjustmentIndex );
+ bRetValue = sal_True;
+ }
+ }
+ break;
+ case EnhancedCustomShapeParameterType::EQUATION :
+ {
+ sal_Int32 nEquationIndex = 0;
+ if ( rParameter.Value >>= nEquationIndex )
+ {
+ rRetValue = GetEquationValueAsDouble( nEquationIndex );
+ bRetValue = sal_True;
+ }
+ }
+ break;
+ case EnhancedCustomShapeParameterType::NORMAL :
+ {
+ if ( rParameter.Value.getValueTypeClass() == TypeClass_DOUBLE )
+ {
+ double fValue;
+ if ( rParameter.Value >>= fValue )
+ {
+ rRetValue = fValue;
+ bRetValue = sal_True;
+ }
+ }
+ else
+ {
+ sal_Int32 nValue = 0;
+ if ( rParameter.Value >>= nValue )
+ {
+ rRetValue = nValue;
+ bRetValue = sal_True;
+ if ( bReplaceGeoWidth && ( nValue == nCoordWidth ) )
+ rRetValue *= fXRatio;
+ else if ( bReplaceGeoHeight && ( nValue == nCoordHeight ) )
+ rRetValue *= fYRatio;
+ }
+ }
+ }
+ break;
+ case EnhancedCustomShapeParameterType::LEFT :
+ {
+ rRetValue = 0.0;
+ bRetValue = sal_True;
+ }
+ break;
+ case EnhancedCustomShapeParameterType::TOP :
+ {
+ rRetValue = 0.0;
+ bRetValue = sal_True;
+ }
+ break;
+ case EnhancedCustomShapeParameterType::RIGHT :
+ {
+ rRetValue = nCoordWidth;
+ bRetValue = sal_True;
+ }
+ break;
+ case EnhancedCustomShapeParameterType::BOTTOM :
+ {
+ rRetValue = nCoordHeight;
+ bRetValue = sal_True;
+ }
+ break;
+ }
+ return bRetValue;
+}
+
+// nLumDat 28-31 = number of luminance entries in nLumDat
+// nLumDat 27-24 = nLumDatEntry 0
+// nLumDat 23-20 = nLumDatEntry 1 ...
+// each 4bit entry is to be interpreted as a 10 percent signed luminance changing
+sal_Int32 EnhancedCustomShape2d::GetLuminanceChange( sal_uInt32 nIndex ) const
+{
+ const sal_uInt32 nCount = nColorData >> 28;
+ if ( !nCount )
+ return 0;
+
+ if ( nIndex >= nCount )
+ nIndex = nCount - 1;
+
+ const sal_Int32 nLumDat = nColorData << ( ( 1 + nIndex ) << 2 );
+ return ( nLumDat >> 28 ) * 10;
+}
+
+Color EnhancedCustomShape2d::GetColorData( const Color& rFillColor, sal_uInt32 nIndex ) const
+{
+ const sal_Int32 nLuminance = GetLuminanceChange(nIndex);
+ if( !nLuminance )
+ return rFillColor;
+
+ basegfx::BColor aHSVColor=
+ basegfx::tools::rgb2hsv(
+ basegfx::BColor(rFillColor.GetRed()/255.0,
+ rFillColor.GetGreen()/255.0,
+ rFillColor.GetBlue()/255.0));
+ if( nLuminance > 0 )
+ {
+ aHSVColor.setGreen(
+ aHSVColor.getGreen() * (1.0-nLuminance/100.0));
+ aHSVColor.setBlue(
+ nLuminance/100.0 +
+ (1.0-nLuminance/100.0)*aHSVColor.getBlue());
+ }
+ else if( nLuminance < 0 )
+ {
+ aHSVColor.setBlue(
+ (1.0+nLuminance/100.0)*aHSVColor.getBlue());
+ }
+
+ aHSVColor = basegfx::tools::hsv2rgb(aHSVColor);
+ return Color( (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getRed(),0.0,1.0) * 255.0 + 0.5 ),
+ (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getGreen(),0.0,1.0) * 255.0 + 0.5 ),
+ (sal_uInt8)static_cast< sal_Int32 >( basegfx::clamp(aHSVColor.getBlue(),0.0,1.0) * 255.0 + 0.5 ) );
+}
+
+Rectangle EnhancedCustomShape2d::GetTextRect() const
+{
+ sal_Int32 nIndex, nSize = seqTextFrames.getLength();
+ if ( !nSize )
+ return aLogicRect;
+ nIndex = 0;
+ if ( bTextFlow && ( nSize > 1 ) )
+ nIndex++;
+ Point aTopLeft( GetPoint( seqTextFrames[ nIndex ].TopLeft, sal_True, sal_True ) );
+ Point aBottomRight( GetPoint( seqTextFrames[ nIndex ].BottomRight, sal_True, sal_True ) );
+ if ( bFlipH )
+ {
+ aTopLeft.X() = aLogicRect.GetWidth() - aTopLeft.X();
+ aBottomRight.X() = aLogicRect.GetWidth() - aBottomRight.X();
+ }
+ if ( bFlipV )
+ {
+ aTopLeft.Y() = aLogicRect.GetHeight() - aTopLeft.Y();
+ aBottomRight.Y() = aLogicRect.GetHeight() - aBottomRight.Y();
+ }
+ Rectangle aRect( aTopLeft, aBottomRight );
+ aRect.Move( aLogicRect.Left(), aLogicRect.Top() );
+ aRect.Justify();
+ return aRect;
+}
+
+sal_uInt32 EnhancedCustomShape2d::GetHdlCount() const
+{
+ return seqHandles.getLength();
+}
+
+sal_Bool EnhancedCustomShape2d::GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const
+{
+ sal_Bool bRetValue = sal_False;
+ if ( nIndex < GetHdlCount() )
+ {
+ Handle aHandle;
+ if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) )
+ {
+ if ( aHandle.nFlags & HANDLE_FLAGS_POLAR )
+ {
+ Point aReferencePoint( GetPoint( aHandle.aPolar, sal_True, sal_False ) );
+
+ double fAngle;
+ double fRadius;
+ GetParameter( fRadius, aHandle.aPosition.First, sal_False, sal_False );
+ GetParameter( fAngle, aHandle.aPosition.Second, sal_False, sal_False );
+
+ double a = ( 360.0 - fAngle ) * F_PI180;
+ double dx = fRadius * fXScale;
+ double fX = dx * cos( a );
+ double fY =-dx * sin( a );
+ rReturnPosition =
+ Point(
+ Round( fX + aReferencePoint.X() ),
+ basegfx::fTools::equalZero(fXScale) ? aReferencePoint.Y() :
+ Round( ( fY * fYScale ) / fXScale + aReferencePoint.Y() ) );
+ }
+ else
+ {
+ if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED )
+ {
+ if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() )
+ {
+ com::sun::star::drawing::EnhancedCustomShapeParameter aFirst = aHandle.aPosition.First;
+ com::sun::star::drawing::EnhancedCustomShapeParameter aSecond = aHandle.aPosition.Second;
+ aHandle.aPosition.First = aSecond;
+ aHandle.aPosition.Second = aFirst;
+ }
+ }
+ rReturnPosition = GetPoint( aHandle.aPosition, sal_True, sal_False );
+ }
+ const GeoStat aGeoStat( ((SdrObjCustomShape*)pCustomShapeObj)->GetGeoStat() );
+ if ( aGeoStat.nShearWink )
+ {
+ double nTan = aGeoStat.nTan;
+ if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
+ nTan = -nTan;
+ ShearPoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan );
+ }
+ if ( nRotateAngle )
+ {
+ double a = nRotateAngle * F_PI18000;
+ RotatePoint( rReturnPosition, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) );
+ }
+ if ( bFlipH )
+ rReturnPosition.X() = aLogicRect.GetWidth() - rReturnPosition.X();
+ if ( bFlipV )
+ rReturnPosition.Y() = aLogicRect.GetHeight() - rReturnPosition.Y();
+ rReturnPosition.Move( aLogicRect.Left(), aLogicRect.Top() );
+ bRetValue = sal_True;
+ }
+ }
+ return bRetValue;
+}
+
+sal_Bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition )
+{
+ sal_Bool bRetValue = sal_False;
+ if ( nIndex < GetHdlCount() )
+ {
+ Handle aHandle;
+ if ( ConvertSequenceToEnhancedCustomShape2dHandle( seqHandles[ nIndex ], aHandle ) )
+ {
+ Point aP( rPosition.X, rPosition.Y );
+ // apply the negative object rotation to the controller position
+
+ aP.Move( -aLogicRect.Left(), -aLogicRect.Top() );
+ if ( bFlipH )
+ aP.X() = aLogicRect.GetWidth() - aP.X();
+ if ( bFlipV )
+ aP.Y() = aLogicRect.GetHeight() - aP.Y();
+ if ( nRotateAngle )
+ {
+ double a = -nRotateAngle * F_PI18000;
+ RotatePoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), sin( a ), cos( a ) );
+ }
+ const GeoStat aGeoStat( ((SdrObjCustomShape*)pCustomShapeObj)->GetGeoStat() );
+ if ( aGeoStat.nShearWink )
+ {
+ double nTan = -aGeoStat.nTan;
+ if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
+ nTan = -nTan;
+ ShearPoint( aP, Point( aLogicRect.GetWidth() / 2, aLogicRect.GetHeight() / 2 ), nTan );
+ }
+
+ double fPos1 = aP.X(); //( bFlipH ) ? aLogicRect.GetWidth() - aP.X() : aP.X();
+ double fPos2 = aP.Y(); //( bFlipV ) ? aLogicRect.GetHeight() -aP.Y() : aP.Y();
+ fPos1 /= fXScale;
+ fPos2 /= fYScale;
+
+ if ( aHandle.nFlags & HANDLE_FLAGS_SWITCHED )
+ {
+ if ( aLogicRect.GetHeight() > aLogicRect.GetWidth() )
+ {
+ double fX = fPos1;
+ double fY = fPos2;
+ fPos1 = fY;
+ fPos2 = fX;
+ }
+ }
+
+ sal_Int32 nFirstAdjustmentValue = -1, nSecondAdjustmentValue = -1;
+
+ if ( aHandle.aPosition.First.Type == EnhancedCustomShapeParameterType::ADJUSTMENT )
+ aHandle.aPosition.First.Value >>= nFirstAdjustmentValue;
+ if ( aHandle.aPosition.Second.Type == EnhancedCustomShapeParameterType::ADJUSTMENT )
+ aHandle.aPosition.Second.Value>>= nSecondAdjustmentValue;
+
+ if ( aHandle.nFlags & HANDLE_FLAGS_POLAR )
+ {
+ double fXRef, fYRef, fAngle;
+ GetParameter( fXRef, aHandle.aPolar.First, sal_False, sal_False );
+ GetParameter( fYRef, aHandle.aPolar.Second, sal_False, sal_False );
+ const double fDX = fPos1 - fXRef;
+ fAngle = -( atan2( -fPos2 + fYRef, ( ( fDX == 0.0L ) ? 0.000000001 : fDX ) ) / F_PI180 );
+ double fX = ( fPos1 - fXRef );
+ double fY = ( fPos2 - fYRef );
+ double fRadius = sqrt( fX * fX + fY * fY );
+ if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MINIMUM )
+ {
+ double fMin;
+ GetParameter( fMin, aHandle.aRadiusRangeMinimum, sal_False, sal_False );
+ if ( fRadius < fMin )
+ fRadius = fMin;
+ }
+ if ( aHandle.nFlags & HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM )
+ {
+ double fMax;
+ GetParameter( fMax, aHandle.aRadiusRangeMaximum, sal_False, sal_False );
+ if ( fRadius > fMax )
+ fRadius = fMax;
+ }
+ if ( nFirstAdjustmentValue >= 0 )
+ SetAdjustValueAsDouble( fRadius, nFirstAdjustmentValue );
+ if ( nSecondAdjustmentValue >= 0 )
+ SetAdjustValueAsDouble( fAngle, nSecondAdjustmentValue );
+ }
+ else
+ {
+ if ( aHandle.nFlags & HANDLE_FLAGS_REFX )
+ {
+ nFirstAdjustmentValue = aHandle.nRefX;
+ fPos1 *= 100000.0;
+ fPos1 /= nCoordWidth;
+ }
+ if ( aHandle.nFlags & HANDLE_FLAGS_REFY )
+ {
+ nSecondAdjustmentValue = aHandle.nRefY;
+ fPos2 *= 100000.0;
+ fPos2 /= nCoordHeight;
+ }
+ if ( nFirstAdjustmentValue >= 0 )
+ {
+ if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MINIMUM ) // check if horizontal handle needs to be within a range
+ {
+ double fXMin;
+ GetParameter( fXMin, aHandle.aXRangeMinimum, sal_False, sal_False );
+ if ( fPos1 < fXMin )
+ fPos1 = fXMin;
+ }
+ if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_X_MAXIMUM ) // check if horizontal handle needs to be within a range
+ {
+ double fXMax;
+ GetParameter( fXMax, aHandle.aXRangeMaximum, sal_False, sal_False );
+ if ( fPos1 > fXMax )
+ fPos1 = fXMax;
+ }
+ SetAdjustValueAsDouble( fPos1, nFirstAdjustmentValue );
+ }
+ if ( nSecondAdjustmentValue >= 0 )
+ {
+ if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MINIMUM ) // check if vertical handle needs to be within a range
+ {
+ double fYMin;
+ GetParameter( fYMin, aHandle.aYRangeMinimum, sal_False, sal_False );
+ if ( fPos2 < fYMin )
+ fPos2 = fYMin;
+ }
+ if ( aHandle.nFlags & HANDLE_FLAGS_RANGE_Y_MAXIMUM ) // check if vertical handle needs to be within a range
+ {
+ double fYMax;
+ GetParameter( fYMax, aHandle.aYRangeMaximum, sal_False, sal_False );
+ if ( fPos2 > fYMax )
+ fPos2 = fYMax;
+ }
+ SetAdjustValueAsDouble( fPos2, nSecondAdjustmentValue );
+ }
+ }
+ // and writing them back into the GeometryItem
+ SdrCustomShapeGeometryItem aGeometryItem((SdrCustomShapeGeometryItem&)
+ (const SdrCustomShapeGeometryItem&)pCustomShapeObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ));
+ const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
+ com::sun::star::beans::PropertyValue aPropVal;
+ aPropVal.Name = sAdjustmentValues;
+ aPropVal.Value <<= seqAdjustmentValues;
+ aGeometryItem.SetPropertyValue( aPropVal );
+ pCustomShapeObj->SetMergedItem( aGeometryItem );
+ bRetValue = sal_True;
+ }
+ }
+ return bRetValue;
+}
+
+void EnhancedCustomShape2d::SwapStartAndEndArrow( SdrObject* pObj ) //#108274
+{
+ XLineStartItem aLineStart;
+ aLineStart.SetLineStartValue(((XLineStartItem&)pObj->GetMergedItem( XATTR_LINEEND )).GetLineStartValue());
+ XLineStartWidthItem aLineStartWidth(((XLineStartWidthItem&)pObj->GetMergedItem( XATTR_LINEENDWIDTH )).GetValue());
+ XLineStartCenterItem aLineStartCenter(((XLineStartCenterItem&)pObj->GetMergedItem( XATTR_LINEENDCENTER )).GetValue());
+
+ XLineEndItem aLineEnd;
+ aLineEnd.SetLineEndValue(((XLineEndItem&)pObj->GetMergedItem( XATTR_LINESTART )).GetLineEndValue());
+ XLineEndWidthItem aLineEndWidth(((XLineEndWidthItem&)pObj->GetMergedItem( XATTR_LINESTARTWIDTH )).GetValue());
+ XLineEndCenterItem aLineEndCenter(((XLineEndCenterItem&)pObj->GetMergedItem( XATTR_LINESTARTCENTER )).GetValue());
+
+ pObj->SetMergedItem( aLineStart );
+ pObj->SetMergedItem( aLineStartWidth );
+ pObj->SetMergedItem( aLineStartCenter );
+ pObj->SetMergedItem( aLineEnd );
+ pObj->SetMergedItem( aLineEndWidth );
+ pObj->SetMergedItem( aLineEndCenter );
+}
+
+basegfx::B2DPolygon CreateArc( const Rectangle& rRect, const Point& rStart, const Point& rEnd, const sal_Bool bClockwise )
+{
+ Rectangle aRect( rRect );
+ Point aStart( rStart );
+ Point aEnd( rEnd );
+
+ sal_Int32 bSwapStartEndAngle = 0;
+
+ if ( aRect.Left() > aRect.Right() )
+ bSwapStartEndAngle ^= 0x01;
+ if ( aRect.Top() > aRect.Bottom() )
+ bSwapStartEndAngle ^= 0x11;
+ if ( bSwapStartEndAngle )
+ {
+ aRect.Justify();
+ if ( bSwapStartEndAngle & 1 )
+ {
+ Point aTmp( aStart );
+ aStart = aEnd;
+ aEnd = aTmp;
+ }
+ }
+
+ Polygon aTempPoly( aRect, aStart, aEnd, POLY_ARC );
+ basegfx::B2DPolygon aRetval;
+
+ if ( bClockwise )
+ {
+ for ( sal_uInt16 j = aTempPoly.GetSize(); j--; )
+ {
+ aRetval.append(basegfx::B2DPoint(aTempPoly[ j ].X(), aTempPoly[ j ].Y()));
+ }
+ }
+ else
+ {
+ for ( sal_uInt16 j = 0; j < aTempPoly.GetSize(); j++ )
+ {
+ aRetval.append(basegfx::B2DPoint(aTempPoly[ j ].X(), aTempPoly[ j ].Y()));
+ }
+ }
+
+ return aRetval;
+}
+
+void EnhancedCustomShape2d::CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
+ const sal_Bool bLineGeometryNeededOnly,
+ const sal_Bool bSortFilledObjectsToBack )
+{
+ sal_Bool bNoFill = sal_False;
+ sal_Bool bNoStroke = sal_False;
+
+ basegfx::B2DPolyPolygon aNewB2DPolyPolygon;
+ basegfx::B2DPolygon aNewB2DPolygon;
+
+ sal_Int32 nCoordSize = seqCoordinates.getLength();
+ sal_Int32 nSegInfoSize = seqSegments.getLength();
+ if ( !nSegInfoSize )
+ {
+ const EnhancedCustomShapeParameterPair* pTmp = seqCoordinates.getArray();
+
+ for ( sal_Int32 nPtNum(0L); nPtNum < nCoordSize; nPtNum++ )
+ {
+ const Point aTempPoint(GetPoint( *pTmp++, sal_True, sal_True ));
+ aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
+ }
+
+ aNewB2DPolygon.setClosed(true);
+ }
+ else
+ {
+ for ( ;rSegmentInd < nSegInfoSize; )
+ {
+ sal_Int16 nCommand = seqSegments[ rSegmentInd ].Command;
+ sal_Int16 nPntCount= seqSegments[ rSegmentInd++ ].Count;
+
+ switch ( nCommand )
+ {
+ case NOFILL :
+ bNoFill = sal_True;
+ break;
+ case NOSTROKE :
+ bNoStroke = sal_True;
+ break;
+ case MOVETO :
+ {
+ if(aNewB2DPolygon.count() > 1L)
+ {
+ // #i76201# Add conversion to closed polygon when first and last points are equal
+ basegfx::tools::checkClosed(aNewB2DPolygon);
+ aNewB2DPolyPolygon.append(aNewB2DPolygon);
+ }
+
+ aNewB2DPolygon.clear();
+
+ if ( rSrcPt < nCoordSize )
+ {
+ const Point aTempPoint(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
+ aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
+ }
+ }
+ break;
+ case ENDSUBPATH :
+ break;
+ case CLOSESUBPATH :
+ {
+ if(aNewB2DPolygon.count())
+ {
+ if(aNewB2DPolygon.count() > 1L)
+ {
+ aNewB2DPolygon.setClosed(true);
+ aNewB2DPolyPolygon.append(aNewB2DPolygon);
+ }
+
+ aNewB2DPolygon.clear();
+ }
+ }
+ break;
+ case CURVETO :
+ {
+ for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ )
+ {
+ const Point aControlA(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
+ const Point aControlB(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
+ const Point aEnd(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
+
+ DBG_ASSERT(aNewB2DPolygon.count(), "EnhancedCustomShape2d::CreateSubPath: Error in adding control point (!)");
+ aNewB2DPolygon.appendBezierSegment(
+ basegfx::B2DPoint(aControlA.X(), aControlA.Y()),
+ basegfx::B2DPoint(aControlB.X(), aControlB.Y()),
+ basegfx::B2DPoint(aEnd.X(), aEnd.Y()));
+ }
+ }
+ break;
+
+ case ANGLEELLIPSE :
+ {
+ if(aNewB2DPolygon.count() > 1L)
+ {
+ // #i76201# Add conversion to closed polygon when first and last points are equal
+ basegfx::tools::checkClosed(aNewB2DPolygon);
+ aNewB2DPolyPolygon.append(aNewB2DPolygon);
+ }
+
+ aNewB2DPolygon.clear();
+ }
+ case ANGLEELLIPSETO :
+ {
+ for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 2 ) < nCoordSize ); i++ )
+ {
+ // create a circle
+ Point _aCenter( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ) );
+ double fWidth, fHeight;
+ GetParameter( fWidth, seqCoordinates[ rSrcPt + 1 ].First, sal_True, sal_False );
+ GetParameter( fHeight, seqCoordinates[ rSrcPt + 1 ].Second, sal_False, sal_True );
+ fWidth *= fXScale;
+ fHeight*= fYScale;
+ Point aP( (sal_Int32)( _aCenter.X() - fWidth ), (sal_Int32)( _aCenter.Y() - fHeight ) );
+ Size aS( (sal_Int32)( fWidth * 2.0 ), (sal_Int32)( fHeight * 2.0 ) );
+ Rectangle aRect( aP, aS );
+ if ( aRect.GetWidth() && aRect.GetHeight() )
+ {
+ double fStartAngle, fEndAngle;
+ GetParameter( fStartAngle, seqCoordinates[ rSrcPt + 2 ].First, sal_False, sal_False );
+ GetParameter( fEndAngle , seqCoordinates[ rSrcPt + 2 ].Second, sal_False, sal_False );
+
+ if ( ((sal_Int32)fStartAngle % 360) != ((sal_Int32)fEndAngle % 360) )
+ {
+ if ( (sal_Int32)fStartAngle & 0x7fff0000 ) // SJ: if the angle was imported from our escher import, then the
+ fStartAngle /= 65536.0; // value is shifted by 16. TODO: already change the fixed float to a
+ if ( (sal_Int32)fEndAngle & 0x7fff0000 ) // double in the import filter
+ {
+ fEndAngle /= 65536.0;
+ fEndAngle = fEndAngle + fStartAngle;
+ if ( fEndAngle < 0 )
+ { // in the binary filter the endangle is the amount
+ double fTemp = fStartAngle;
+ fStartAngle = fEndAngle;
+ fEndAngle = fTemp;
+ }
+ }
+ double fCenterX = aRect.Center().X();
+ double fCenterY = aRect.Center().Y();
+ double fx1 = ( cos( fStartAngle * F_PI180 ) * 65536.0 * fXScale ) + fCenterX;
+ double fy1 = ( -sin( fStartAngle * F_PI180 ) * 65536.0 * fYScale ) + fCenterY;
+ double fx2 = ( cos( fEndAngle * F_PI180 ) * 65536.0 * fXScale ) + fCenterX;
+ double fy2 = ( -sin( fEndAngle * F_PI180 ) * 65536.0 * fYScale ) + fCenterY;
+ aNewB2DPolygon.append(CreateArc( aRect, Point( (sal_Int32)fx1, (sal_Int32)fy1 ), Point( (sal_Int32)fx2, (sal_Int32)fy2 ), sal_False));
+ }
+ else
+ { /* SJ: TODO: this block should be replaced sometimes, because the current point
+ is not set correct, it also does not use the correct moveto
+ point if ANGLEELLIPSETO was used, but the method CreateArc
+ is at the moment not able to draw full circles (if startangle is 0
+ and endangle 360 nothing is painted :-( */
+ sal_Int32 nXControl = (sal_Int32)((double)aRect.GetWidth() * 0.2835 );
+ sal_Int32 nYControl = (sal_Int32)((double)aRect.GetHeight() * 0.2835 );
+ Point aCenter( aRect.Center() );
+
+ // append start point
+ aNewB2DPolygon.append(basegfx::B2DPoint(aCenter.X(), aRect.Top()));
+
+ // append four bezier segments
+ aNewB2DPolygon.appendBezierSegment(
+ basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Top()),
+ basegfx::B2DPoint(aRect.Right(), aCenter.Y() - nYControl),
+ basegfx::B2DPoint(aRect.Right(), aCenter.Y()));
+
+ aNewB2DPolygon.appendBezierSegment(
+ basegfx::B2DPoint(aRect.Right(), aCenter.Y() + nYControl),
+ basegfx::B2DPoint(aCenter.X() + nXControl, aRect.Bottom()),
+ basegfx::B2DPoint(aCenter.X(), aRect.Bottom()));
+
+ aNewB2DPolygon.appendBezierSegment(
+ basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Bottom()),
+ basegfx::B2DPoint(aRect.Left(), aCenter.Y() + nYControl),
+ basegfx::B2DPoint(aRect.Left(), aCenter.Y()));
+
+ aNewB2DPolygon.appendBezierSegment(
+ basegfx::B2DPoint(aRect.Left(), aCenter.Y() - nYControl),
+ basegfx::B2DPoint(aCenter.X() - nXControl, aRect.Top()),
+ basegfx::B2DPoint(aCenter.X(), aRect.Top()));
+
+ // close, rescue last controlpoint, remove double last point
+ basegfx::tools::closeWithGeometryChange(aNewB2DPolygon);
+ }
+ }
+ rSrcPt += 3;
+ }
+ }
+ break;
+
+ case LINETO :
+ {
+ for ( sal_Int32 i(0L); ( i < nPntCount ) && ( rSrcPt < nCoordSize ); i++ )
+ {
+ const Point aTempPoint(GetPoint( seqCoordinates[ rSrcPt++ ], sal_True, sal_True ));
+ aNewB2DPolygon.append(basegfx::B2DPoint(aTempPoint.X(), aTempPoint.Y()));
+ }
+ }
+ break;
+
+ case ARC :
+ case CLOCKWISEARC :
+ {
+ if(aNewB2DPolygon.count() > 1L)
+ {
+ // #i76201# Add conversion to closed polygon when first and last points are equal
+ basegfx::tools::checkClosed(aNewB2DPolygon);
+ aNewB2DPolyPolygon.append(aNewB2DPolygon);
+ }
+
+ aNewB2DPolygon.clear();
+ }
+ case ARCTO :
+ case CLOCKWISEARCTO :
+ {
+ sal_Bool bClockwise = ( nCommand == CLOCKWISEARC ) || ( nCommand == CLOCKWISEARCTO );
+ sal_uInt32 nXor = bClockwise ? 3 : 2;
+ for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( ( rSrcPt + 3 ) < nCoordSize ); i++ )
+ {
+ Rectangle aRect( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ), GetPoint( seqCoordinates[ rSrcPt + 1 ], sal_True, sal_True ) );
+ if ( aRect.GetWidth() && aRect.GetHeight() )
+ {
+ Point aCenter( aRect.Center() );
+ Point aStart( GetPoint( seqCoordinates[ (sal_uInt16)( rSrcPt + nXor ) ], sal_True, sal_True ) );
+ Point aEnd( GetPoint( seqCoordinates[ (sal_uInt16)( rSrcPt + ( nXor ^ 1 ) ) ], sal_True, sal_True ) );
+ double fRatio = (double)aRect.GetHeight() / (double)aRect.GetWidth();
+ aStart.X() = (sal_Int32)( ( (double)( aStart.X() - aCenter.X() ) ) * fRatio ) + aCenter.X();
+ aStart.Y() = (sal_Int32)( ( (double)( aStart.Y() - aCenter.Y() ) ) ) + aCenter.Y();
+ aEnd.X() = (sal_Int32)( ( (double)( aEnd.X() - aCenter.X() ) ) * fRatio ) + aCenter.X();
+ aEnd.Y() = (sal_Int32)( ( (double)( aEnd.Y() - aCenter.Y() ) ) ) + aCenter.Y();
+ aNewB2DPolygon.append(CreateArc( aRect, aStart, aEnd, bClockwise));
+ }
+ rSrcPt += 4;
+ }
+ }
+ break;
+
+ case ELLIPTICALQUADRANTX :
+ case ELLIPTICALQUADRANTY :
+ {
+ bool bFirstDirection(true);
+ basegfx::B2DPoint aControlPointA;
+ basegfx::B2DPoint aControlPointB;
+
+ for ( sal_uInt16 i = 0; ( i < nPntCount ) && ( rSrcPt < nCoordSize ); i++ )
+ {
+ sal_uInt32 nModT = ( nCommand == ELLIPTICALQUADRANTX ) ? 1 : 0;
+ Point aCurrent( GetPoint( seqCoordinates[ rSrcPt ], sal_True, sal_True ) );
+
+ if ( rSrcPt ) // we need a previous point
+ {
+ Point aPrev( GetPoint( seqCoordinates[ rSrcPt - 1 ], sal_True, sal_True ) );
+ sal_Int32 nX, nY;
+ nX = aCurrent.X() - aPrev.X();
+ nY = aCurrent.Y() - aPrev.Y();
+ if ( ( nY ^ nX ) & 0x80000000 )
+ {
+ if ( !i )
+ bFirstDirection = true;
+ else if ( !bFirstDirection )
+ nModT ^= 1;
+ }
+ else
+ {
+ if ( !i )
+ bFirstDirection = false;
+ else if ( bFirstDirection )
+ nModT ^= 1;
+ }
+ if ( nModT ) // get the right corner
+ {
+ nX = aCurrent.X();
+ nY = aPrev.Y();
+ }
+ else
+ {
+ nX = aPrev.X();
+ nY = aCurrent.Y();
+ }
+ sal_Int32 nXVec = ( nX - aPrev.X() ) >> 1;
+ sal_Int32 nYVec = ( nY - aPrev.Y() ) >> 1;
+ Point aControl1( aPrev.X() + nXVec, aPrev.Y() + nYVec );
+
+ aControlPointA = basegfx::B2DPoint(aControl1.X(), aControl1.Y());
+
+ nXVec = ( nX - aCurrent.X() ) >> 1;
+ nYVec = ( nY - aCurrent.Y() ) >> 1;
+ Point aControl2( aCurrent.X() + nXVec, aCurrent.Y() + nYVec );
+
+ aControlPointB = basegfx::B2DPoint(aControl2.X(), aControl2.Y());
+
+ aNewB2DPolygon.appendBezierSegment(
+ aControlPointA,
+ aControlPointB,
+ basegfx::B2DPoint(aCurrent.X(), aCurrent.Y()));
+ }
+ else
+ {
+ aNewB2DPolygon.append(basegfx::B2DPoint(aCurrent.X(), aCurrent.Y()));
+ }
+
+ rSrcPt++;
+ }
+ }
+ break;
+
+#ifdef DBG_CUSTOMSHAPE
+ case UNKNOWN :
+ default :
+ {
+ ByteString aString( "CustomShapes::unknown PolyFlagValue :" );
+ aString.Append( ByteString::CreateFromInt32( nCommand ) );
+ DBG_ERROR( aString.GetBuffer() );
+ }
+ break;
+#endif
+ }
+ if ( nCommand == ENDSUBPATH )
+ break;
+ }
+ }
+ if ( rSegmentInd == nSegInfoSize )
+ rSegmentInd++;
+
+ if(aNewB2DPolygon.count() > 1L)
+ {
+ // #i76201# Add conversion to closed polygon when first and last points are equal
+ basegfx::tools::checkClosed(aNewB2DPolygon);
+ aNewB2DPolyPolygon.append(aNewB2DPolygon);
+ }
+
+ if(aNewB2DPolyPolygon.count())
+ {
+ if( !bLineGeometryNeededOnly )
+ {
+ // hack aNewB2DPolyPolygon to fill logic rect - this is
+ // needed to produce gradient fills that look like mso
+ aNewB2DPolygon.clear();
+ aNewB2DPolygon.append(basegfx::B2DPoint(0,0));
+ aNewB2DPolygon.setClosed(true);
+ aNewB2DPolyPolygon.append(aNewB2DPolygon);
+
+ aNewB2DPolygon.clear();
+ aNewB2DPolygon.append(basegfx::B2DPoint(aLogicRect.GetWidth(),
+ aLogicRect.GetHeight()));
+ aNewB2DPolygon.setClosed(true);
+ aNewB2DPolyPolygon.append(aNewB2DPolygon);
+ }
+
+ // #i37011#
+ bool bForceCreateTwoObjects(false);
+
+ if(!bSortFilledObjectsToBack && !aNewB2DPolyPolygon.isClosed() && !bNoStroke)
+ {
+ bForceCreateTwoObjects = true;
+ }
+
+ if(bLineGeometryNeededOnly)
+ {
+ bForceCreateTwoObjects = true;
+ bNoFill = true;
+ bNoStroke = false;
+ }
+
+ if(bForceCreateTwoObjects || bSortFilledObjectsToBack)
+ {
+ if(bFilled && !bNoFill)
+ {
+ basegfx::B2DPolyPolygon aClosedPolyPolygon(aNewB2DPolyPolygon);
+ aClosedPolyPolygon.setClosed(true);
+ SdrPathObj* pFill = new SdrPathObj(OBJ_POLY, aClosedPolyPolygon);
+ SfxItemSet aTempSet(*this);
+ aTempSet.Put(SdrShadowItem(sal_False));
+ aTempSet.Put(XLineStyleItem(XLINE_NONE));
+ pFill->SetMergedItemSet(aTempSet);
+ rObjectList.push_back(pFill);
+ }
+
+ if(!bNoStroke)
+ {
+ // there is no reason to use OBJ_PLIN here when the polygon is actually closed,
+ // the non-fill is defined by XFILL_NONE. Since SdrPathObj::ImpForceKind() needs
+ // to correct the polygon (here: open it) using the type, the last edge may get lost.
+ // Thus, use a type that fits the polygon
+ SdrPathObj* pStroke = new SdrPathObj(
+ aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
+ aNewB2DPolyPolygon);
+ SfxItemSet aTempSet(*this);
+ aTempSet.Put(SdrShadowItem(sal_False));
+ aTempSet.Put(XFillStyleItem(XFILL_NONE));
+ pStroke->SetMergedItemSet(aTempSet);
+ rObjectList.push_back(pStroke);
+ }
+ }
+ else
+ {
+ SdrPathObj* pObj = 0;
+ SfxItemSet aTempSet(*this);
+ aTempSet.Put(SdrShadowItem(sal_False));
+
+ if(bNoFill)
+ {
+ // see comment above about OBJ_PLIN
+ pObj = new SdrPathObj(
+ aNewB2DPolyPolygon.isClosed() ? OBJ_POLY : OBJ_PLIN,
+ aNewB2DPolyPolygon);
+ aTempSet.Put(XFillStyleItem(XFILL_NONE));
+ }
+ else
+ {
+ aNewB2DPolyPolygon.setClosed(true);
+ pObj = new SdrPathObj(OBJ_POLY, aNewB2DPolyPolygon);
+ }
+
+ if(bNoStroke)
+ {
+ aTempSet.Put(XLineStyleItem(XLINE_NONE));
+ }
+
+ if(pObj)
+ {
+ pObj->SetMergedItemSet(aTempSet);
+ rObjectList.push_back(pObj);
+ }
+ }
+ }
+}
+
+void CorrectCalloutArrows( MSO_SPT eSpType, sal_uInt32 nLineObjectCount, std::vector< SdrPathObj* >& vObjectList )
+{
+ sal_Bool bAccent = sal_False;
+ switch( eSpType )
+ {
+ case mso_sptCallout1 :
+ case mso_sptBorderCallout1 :
+ case mso_sptCallout90 :
+ case mso_sptBorderCallout90 :
+ default:
+ break;
+
+ case mso_sptAccentCallout1 :
+ case mso_sptAccentBorderCallout1 :
+ case mso_sptAccentCallout90 :
+ case mso_sptAccentBorderCallout90 :
+ {
+ sal_uInt32 i, nLine = 0;
+ for ( i = 0; i < vObjectList.size(); i++ )
+ {
+ SdrPathObj* pObj( vObjectList[ i ] );
+ if(pObj->IsLine())
+ {
+ nLine++;
+ if ( nLine == nLineObjectCount )
+ {
+ pObj->ClearMergedItem( XATTR_LINESTART );
+ pObj->ClearMergedItem( XATTR_LINEEND );
+ }
+ }
+ }
+ }
+ break;
+
+ // switch start & end
+ case mso_sptAccentCallout2 :
+ case mso_sptAccentBorderCallout2 :
+ bAccent = sal_True;
+ case mso_sptCallout2 :
+ case mso_sptBorderCallout2 :
+ {
+ sal_uInt32 i, nLine = 0;
+ for ( i = 0; i < vObjectList.size(); i++ )
+ {
+ SdrPathObj* pObj( vObjectList[ i ] );
+ if(pObj->IsLine())
+ {
+ nLine++;
+ if ( nLine == 1 )
+ pObj->ClearMergedItem( XATTR_LINEEND );
+ else if ( ( bAccent && ( nLine == nLineObjectCount - 1 ) ) || ( !bAccent && ( nLine == nLineObjectCount ) ) )
+ pObj->ClearMergedItem( XATTR_LINESTART );
+ else
+ {
+ pObj->ClearMergedItem( XATTR_LINESTART );
+ pObj->ClearMergedItem( XATTR_LINEEND );
+ }
+ }
+ }
+ }
+ break;
+
+ case mso_sptAccentCallout3 :
+ case mso_sptAccentBorderCallout3 :
+ bAccent = sal_False;
+ case mso_sptCallout3 :
+ case mso_sptBorderCallout3 :
+ {
+ sal_uInt32 i, nLine = 0;
+ for ( i = 0; i < vObjectList.size(); i++ )
+ {
+ SdrPathObj* pObj( vObjectList[ i ] );
+ if(pObj->IsLine())
+ {
+ if ( nLine )
+ {
+ pObj->ClearMergedItem( XATTR_LINESTART );
+ pObj->ClearMergedItem( XATTR_LINEEND );
+ }
+ else
+ EnhancedCustomShape2d::SwapStartAndEndArrow( pObj );
+
+ nLine++;
+ }
+ }
+ }
+ break;
+ }
+}
+
+void EnhancedCustomShape2d::AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
+ sal_uInt32& nColorIndex, sal_uInt32 nColorCount)
+{
+ if ( !rObj.IsLine() )
+ {
+ const XFillStyle eFillStyle = ((const XFillStyleItem&)rObj.GetMergedItem(XATTR_FILLSTYLE)).GetValue();
+ switch( eFillStyle )
+ {
+ default:
+ case XFILL_SOLID:
+ {
+ Color aFillColor;
+ if ( nColorCount )
+ {
+ aFillColor = GetColorData(
+ ((XFillColorItem&)rCustomShapeSet.Get( XATTR_FILLCOLOR )).GetColorValue(),
+ std::min(nColorIndex, nColorCount-1) );
+ rObj.SetMergedItem( XFillColorItem( String(), aFillColor ) );
+ }
+ break;
+ }
+ case XFILL_GRADIENT:
+ {
+ XGradient aXGradient(((const XFillGradientItem&)rObj.GetMergedItem(XATTR_FILLGRADIENT)).GetGradientValue());
+ if ( nColorCount )
+ {
+ aXGradient.SetStartColor(
+ GetColorData(
+ aXGradient.GetStartColor(),
+ std::min(nColorIndex, nColorCount-1) ));
+ aXGradient.SetEndColor(
+ GetColorData(
+ aXGradient.GetEndColor(),
+ std::min(nColorIndex, nColorCount-1) ));
+ }
+
+ rObj.SetMergedItem( XFillGradientItem( String(), aXGradient ) );
+ break;
+ }
+ case XFILL_HATCH:
+ {
+ XHatch aXHatch(((const XFillHatchItem&)rObj.GetMergedItem(XATTR_FILLHATCH)).GetHatchValue());
+ if ( nColorCount )
+ {
+ aXHatch.SetColor(
+ GetColorData(
+ aXHatch.GetColor(),
+ std::min(nColorIndex, nColorCount-1) ));
+ }
+
+ rObj.SetMergedItem( XFillHatchItem( String(), aXHatch ) );
+ break;
+ }
+ case XFILL_BITMAP:
+ {
+ Bitmap aBitmap(((const XFillBitmapItem&)rObj.GetMergedItem(XATTR_FILLBITMAP)).GetBitmapValue().GetBitmap());
+ if ( nColorCount )
+ {
+ aBitmap.Adjust(
+ static_cast< short > ( GetLuminanceChange(
+ std::min(nColorIndex, nColorCount-1))));
+ }
+
+ rObj.SetMergedItem( XFillBitmapItem( String(), aBitmap ) );
+ break;
+ }
+ }
+
+ if ( nColorIndex < nColorCount )
+ nColorIndex++;
+ }
+}
+
+SdrObject* EnhancedCustomShape2d::CreatePathObj( sal_Bool bLineGeometryNeededOnly )
+{
+ sal_Int32 nCoordSize = seqCoordinates.getLength();
+ if ( !nCoordSize )
+ return NULL;
+
+ sal_uInt16 nSrcPt = 0;
+ sal_uInt16 nSegmentInd = 0;
+
+ std::vector< SdrPathObj* > vObjectList;
+ sal_Bool bSortFilledObjectsToBack = SortFilledObjectsToBackByDefault( eSpType );
+
+ while( nSegmentInd <= seqSegments.getLength() )
+ {
+ CreateSubPath( nSrcPt, nSegmentInd, vObjectList, bLineGeometryNeededOnly, bSortFilledObjectsToBack );
+ }
+
+ SdrObject* pRet = NULL;
+ sal_uInt32 i;
+
+ if ( vObjectList.size() )
+ {
+ const SfxItemSet& rCustomShapeSet = pCustomShapeObj->GetMergedItemSet();
+ Color aFillColor;
+ sal_uInt32 nColorCount = nColorData >> 28;
+ sal_uInt32 nColorIndex = 0;
+
+ // #i37011# remove invisible objects
+ if(vObjectList.size())
+ {
+ std::vector< SdrPathObj* > vTempList;
+
+ for(i = 0L; i < vObjectList.size(); i++)
+ {
+ SdrPathObj* pObj(vObjectList[i]);
+ const XLineStyle eLineStyle = ((const XLineStyleItem&)pObj->GetMergedItem(XATTR_LINESTYLE)).GetValue();
+ const XFillStyle eFillStyle = ((const XFillStyleItem&)pObj->GetMergedItem(XATTR_FILLSTYLE)).GetValue();
+
+ //SJ: #i40600# if bLineGeometryNeededOnly is set linystyle does not matter
+ if( !bLineGeometryNeededOnly && ( XLINE_NONE == eLineStyle ) && ( XFILL_NONE == eFillStyle ) )
+ delete pObj;
+ else
+ vTempList.push_back(pObj);
+ }
+
+ vObjectList = vTempList;
+ }
+
+ if(1L == vObjectList.size())
+ {
+ // a single object, correct some values
+ AdaptObjColor(*vObjectList[0L],rCustomShapeSet,nColorIndex,nColorCount);
+ }
+ else
+ {
+ sal_Int32 nLineObjectCount = 0;
+ sal_Int32 nAreaObjectCount = 0;
+
+ // correct some values and collect content data
+ for ( i = 0; i < vObjectList.size(); i++ )
+ {
+ SdrPathObj* pObj( vObjectList[ i ] );
+
+ if(pObj->IsLine())
+ {
+ nLineObjectCount++;
+ }
+ else
+ {
+ nAreaObjectCount++;
+ AdaptObjColor(*pObj,rCustomShapeSet,nColorIndex,nColorCount);
+ }
+ }
+
+ // #i88870# correct line arrows for callouts
+ if ( nLineObjectCount )
+ CorrectCalloutArrows( eSpType, nLineObjectCount, vObjectList );
+
+ // sort objects so that filled ones are in front. Necessary
+ // for some strange objects
+ if ( bSortFilledObjectsToBack )
+ {
+ std::vector< SdrPathObj* > vTempList;
+
+ for ( i = 0; i < vObjectList.size(); i++ )
+ {
+ SdrPathObj* pObj( vObjectList[ i ] );
+
+ if ( !pObj->IsLine() )
+ {
+ vTempList.push_back(pObj);
+ }
+ }
+
+ for ( i = 0; i < vObjectList.size(); i++ )
+ {
+ SdrPathObj* pObj( vObjectList[ i ] );
+
+ if ( pObj->IsLine() )
+ {
+ vTempList.push_back(pObj);
+ }
+ }
+
+ vObjectList = vTempList;
+ }
+ }
+ }
+
+ // #i37011#
+ if(vObjectList.size())
+ {
+ // copy remaining objects to pRet
+ if(vObjectList.size() > 1L)
+ {
+ pRet = new SdrObjGroup;
+
+ for (i = 0L; i < vObjectList.size(); i++)
+ {
+ SdrObject* pObj(vObjectList[i]);
+ pRet->GetSubList()->NbcInsertObject(pObj);
+ }
+ }
+ else if(1L == vObjectList.size())
+ {
+ pRet = vObjectList[0L];
+ }
+
+ if(pRet)
+ {
+ // move to target position
+ Rectangle aCurRect(pRet->GetSnapRect());
+ aCurRect.Move(aLogicRect.Left(), aLogicRect.Top());
+ pRet->NbcSetSnapRect(aCurRect);
+ }
+ }
+
+ return pRet;
+}
+
+SdrObject* EnhancedCustomShape2d::CreateObject( sal_Bool bLineGeometryNeededOnly )
+{
+ SdrObject* pRet = NULL;
+
+ if ( eSpType == mso_sptRectangle )
+ {
+ pRet = new SdrRectObj( aLogicRect );
+// SJ: not setting model, so we save a lot of broadcasting and the model is not modified any longer
+// pRet->SetModel( pCustomShapeObj->GetModel() );
+ pRet->SetMergedItemSet( *this );
+ }
+ if ( !pRet )
+ pRet = CreatePathObj( bLineGeometryNeededOnly );
+
+ return pRet;
+}
+
+void EnhancedCustomShape2d::ApplyGluePoints( SdrObject* pObj )
+{
+ if ( pObj && seqGluePoints.getLength() )
+ {
+ sal_uInt32 i, nCount = seqGluePoints.getLength();
+ for ( i = 0; i < nCount; i++ )
+ {
+ SdrGluePoint aGluePoint;
+
+ aGluePoint.SetPos( GetPoint( seqGluePoints[ i ], sal_True, sal_True ) );
+ aGluePoint.SetPercent( sal_False );
+
+// const Point& rPoint = GetPoint( seqGluePoints[ i ], sal_True, sal_True );
+// double fXRel = rPoint.X();
+// double fYRel = rPoint.Y();
+// fXRel = aLogicRect.GetWidth() == 0 ? 0.0 : fXRel / aLogicRect.GetWidth() * 10000;
+// fYRel = aLogicRect.GetHeight() == 0 ? 0.0 : fYRel / aLogicRect.GetHeight() * 10000;
+// aGluePoint.SetPos( Point( (sal_Int32)fXRel, (sal_Int32)fYRel ) );
+// aGluePoint.SetPercent( sal_True );
+ aGluePoint.SetAlign( SDRVERTALIGN_TOP | SDRHORZALIGN_LEFT );
+ aGluePoint.SetEscDir( SDRESC_SMART );
+ SdrGluePointList* pList = pObj->ForceGluePointList();
+ if( pList )
+ /* sal_uInt16 nId = */ pList->Insert( aGluePoint );
+ }
+ }
+}
+
+SdrObject* EnhancedCustomShape2d::CreateLineGeometry()
+{
+ return CreateObject( sal_True );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.hxx b/svx/source/customshapes/EnhancedCustomShape2d.hxx
new file mode 100644
index 000000000000..568f53338510
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShape2d.hxx
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _ENHANCEDCUSTOMSHAPE2D_HXX
+#define _ENHANCEDCUSTOMSHAPE2D_HXX
+
+#include <svx/msdffdef.hxx>
+#include <svx/sdasitm.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/beans/PropertyValues.hpp>
+#include <com/sun/star/awt/Point.hpp>
+#include <svl/itemset.hxx>
+#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeParameter.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
+#include <svx/EnhancedCustomShapeFunctionParser.hxx>
+
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+#define DFF_CUSTOMSHAPE_FLIP_V 1
+#define DFF_CUSTOMSHAPE_FLIP_H 2
+#define DFF_CUSTOMSHAPE_EXCH 4
+
+class SdrModel;
+class SdrObject;
+class SfxItemSet;
+struct SvxMSDffVertPair;
+struct SvxMSDffCalculationData;
+struct SvxMSDffTextRectangles;
+class SvxMSDffAdjustmentHandle;
+
+#define HANDLE_FLAGS_MIRRORED_X 0x0001
+#define HANDLE_FLAGS_MIRRORED_Y 0x0002
+#define HANDLE_FLAGS_SWITCHED 0x0004
+#define HANDLE_FLAGS_POLAR 0x0008
+#define HANDLE_FLAGS_MAP 0x0010
+#define HANDLE_FLAGS_RANGE_X_MINIMUM 0x0020
+#define HANDLE_FLAGS_RANGE_X_MAXIMUM 0x0040
+#define HANDLE_FLAGS_RANGE_Y_MINIMUM 0x0080
+#define HANDLE_FLAGS_RANGE_Y_MAXIMUM 0x0100
+#define HANDLE_FLAGS_RADIUS_RANGE_MINIMUM 0x0200
+#define HANDLE_FLAGS_RADIUS_RANGE_MAXIMUM 0x0400
+#define HANDLE_FLAGS_REFX 0x0800
+#define HANDLE_FLAGS_REFY 0x1000
+#define HANDLE_FLAGS_REFANGLE 0x2000
+#define HANDLE_FLAGS_REFR 0x4000
+
+// MSDFF_HANDLE_FLAGS_RANGE_Y seems to be not defined in
+// escher, but we are using it internally in to differentiate
+// between X_RANGE and Y_RANGE
+
+class SdrPathObj;
+
+class EnhancedCustomShape2d : public SfxItemSet
+{
+ SdrObject* pCustomShapeObj;
+ MSO_SPT eSpType;
+
+ sal_Int32 nCoordLeft;
+ sal_Int32 nCoordTop;
+ sal_Int32 nCoordWidth;
+ sal_Int32 nCoordHeight;
+ Rectangle aLogicRect;
+
+ double fXScale;
+ double fYScale;
+ double fXRatio;
+ double fYRatio;
+
+ sal_Int32 nXRef;
+ sal_Int32 nYRef;
+ sal_uInt32 nFlags;
+ sal_uInt32 nColorData;
+
+ /*
+
+ */
+ com::sun::star::uno::Sequence< rtl::OUString > seqEquations;
+ std::vector< ::boost::shared_ptr< EnhancedCustomShape::ExpressionNode > > vNodesSharedPtr;
+
+
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments;
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates;
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames;
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints;
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues;
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles;
+
+ sal_Bool bTextFlow : 1;
+ sal_Bool bFilled : 1;
+ sal_Bool bStroked : 1;
+
+ sal_Bool bFlipH;
+ sal_Bool bFlipV;
+ sal_Int32 nRotateAngle;
+
+ sal_Bool SetAdjustValueAsDouble( const double& rValue, const sal_Int32 nIndex );
+ sal_Int32 GetLuminanceChange( sal_uInt32 nIndex ) const;
+ Color GetColorData( const Color& rFillColor, sal_uInt32 nIndex ) const;
+ void AdaptObjColor(SdrPathObj& rObj, const SfxItemSet& rCustomShapeSet,
+ sal_uInt32& nColorIndex, sal_uInt32 nColorCount);
+ sal_Bool GetParameter( double& rParameterReturnValue, const com::sun::star::drawing::EnhancedCustomShapeParameter&,
+ const sal_Bool bReplaceGeoWidth, const sal_Bool bReplaceGeoHeight ) const;
+ Point GetPoint( const com::sun::star::drawing::EnhancedCustomShapeParameterPair&,
+ const sal_Bool bScale = sal_True, const sal_Bool bReplaceGeoSize = sal_False ) const;
+
+ void CreateSubPath( sal_uInt16& rSrcPt, sal_uInt16& rSegmentInd, std::vector< SdrPathObj* >& rObjectList,
+ sal_Bool bLineGeometryNeededOnly, sal_Bool bSortFilledObjectsToBack );
+ SdrObject* CreatePathObj( sal_Bool bLineGeometryNeededOnly );
+ const sal_Int32* ApplyShapeAttributes( const SdrCustomShapeGeometryItem& rItem );
+
+ public :
+
+ struct Handle
+ {
+ sal_uInt32 nFlags;
+
+ sal_Bool bMirroredX;
+ sal_Bool bMirroredY;
+ sal_Bool bSwitched;
+
+ com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
+ com::sun::star::drawing::EnhancedCustomShapeParameterPair aPolar;
+
+ sal_Int32 nRefX;
+ sal_Int32 nRefY;
+ sal_Int32 nRefAngle;
+ sal_Int32 nRefR;
+
+ com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
+ com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
+ com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMinimum;
+ com::sun::star::drawing::EnhancedCustomShapeParameter aXRangeMaximum;
+ com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMinimum;
+ com::sun::star::drawing::EnhancedCustomShapeParameter aYRangeMaximum;
+
+ Handle() : bMirroredX ( sal_False ), bMirroredY ( sal_False ), bSwitched( sal_False ),
+ nRefX( -1 ), nRefY( -1 ), nRefAngle( -1 ), nRefR( -1 ) {};
+ };
+
+ sal_Bool IsFlipVert() { return bFlipV; };
+ sal_Bool IsFlipHorz() { return bFlipH; };
+ sal_Int32 GetRotateAngle() { return nRotateAngle; };
+
+ SVX_DLLPUBLIC SdrObject* CreateLineGeometry();
+ SVX_DLLPUBLIC SdrObject* CreateObject( sal_Bool bLineGeometryNeededOnly );
+ SVX_DLLPUBLIC void ApplyGluePoints( SdrObject* pObj );
+ SVX_DLLPUBLIC Rectangle GetTextRect() const;
+
+ SVX_DLLPUBLIC sal_uInt32 GetHdlCount() const;
+ SVX_DLLPUBLIC sal_Bool GetHandlePosition( const sal_uInt32 nIndex, Point& rReturnPosition ) const;
+ SVX_DLLPUBLIC sal_Bool SetHandleControllerPosition( const sal_uInt32 nIndex, const com::sun::star::awt::Point& rPosition );
+
+ SVX_DLLPUBLIC EnhancedCustomShape2d( SdrObject* pSdrObjCustomShape );
+ SVX_DLLPUBLIC ~EnhancedCustomShape2d();
+
+ enum EnumFunc
+ {
+ ENUM_FUNC_PI,
+ ENUM_FUNC_LEFT,
+ ENUM_FUNC_TOP,
+ ENUM_FUNC_RIGHT,
+ ENUM_FUNC_BOTTOM,
+ ENUM_FUNC_XSTRETCH,
+ ENUM_FUNC_YSTRETCH,
+ ENUM_FUNC_HASSTROKE,
+ ENUM_FUNC_HASFILL,
+ ENUM_FUNC_WIDTH,
+ ENUM_FUNC_HEIGHT,
+ ENUM_FUNC_LOGWIDTH,
+ ENUM_FUNC_LOGHEIGHT
+ };
+ double GetEnumFunc( const EnumFunc eVal ) const;
+
+ double GetAdjustValueAsDouble( const sal_Int32 nIndex ) const;
+ double GetEquationValueAsDouble( const sal_Int32 nIndex ) const;
+ sal_Int32 GetAdjustValueAsInteger( const sal_Int32 nIndex, const sal_Int32 nDefault = 0 ) const;
+
+ SVX_DLLPUBLIC static rtl::OUString GetEquation( const sal_uInt16 nFlags, sal_Int16 nPara1, sal_Int16 nPara2, sal_Int16 nPara3 );
+
+ static void AppendEnhancedCustomShapeEquationParameter( rtl::OUString& rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue );
+
+ static void SetEnhancedCustomShapeEquationParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
+ rParameter, const sal_Int16 nPara, const sal_Bool bIsSpecialValue );
+ SVX_DLLPUBLIC static void SetEnhancedCustomShapeParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
+ rParameter, const sal_Int32 nValue );
+ SVX_DLLPUBLIC static void SetEnhancedCustomShapeHandleParameter( com::sun::star::drawing::EnhancedCustomShapeParameter&
+ rParameter, const sal_Int32 nPara, const sal_Bool bIsSpecialValue, sal_Bool bHorz );
+ static sal_Bool ConvertSequenceToEnhancedCustomShape2dHandle( const com::sun::star::beans::PropertyValues& rHandleProperties,
+ EnhancedCustomShape2d::Handle& rDestinationHandle );
+ static void SwapStartAndEndArrow( SdrObject* pObj );
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.cxx b/svx/source/customshapes/EnhancedCustomShape3d.cxx
new file mode 100644
index 000000000000..6593e757455a
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShape3d.cxx
@@ -0,0 +1,755 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "EnhancedCustomShape3d.hxx"
+#include <svx/svdetc.hxx>
+#include <svx/svdmodel.hxx>
+#include <tools/poly.hxx>
+#include <svditer.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdoashp.hxx>
+#include <svl/poolitem.hxx>
+#include <svl/itemset.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xsflclit.hxx>
+#include <svx/xit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/polysc3d.hxx>
+#include <svx/svddef.hxx>
+#include <svx/svx3ditems.hxx>
+#include <svx/extrud3d.hxx>
+#include <svx/xflbmtit.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/sdasitm.hxx>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/drawing/Position3D.hpp>
+#include <com/sun/star/drawing/Direction3D.hpp>
+#include <com/sun/star/drawing/ShadeMode.hpp>
+#include <svx/sdr/properties/properties.hxx>
+#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/range/b2drange.hxx>
+
+#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
+
+void GetOrigin( SdrCustomShapeGeometryItem& rItem, double& rOriginX, double& rOriginY )
+{
+ ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aOriginParaPair;
+ const rtl::OUString sOrigin( RTL_CONSTASCII_USTRINGPARAM ( "Origin" ) );
+ Any* pAny = rItem.GetPropertyValueByName( sExtrusion, sOrigin );
+ if ( ! ( pAny && ( *pAny >>= aOriginParaPair ) && ( aOriginParaPair.First.Value >>= rOriginX ) && ( aOriginParaPair.Second.Value >>= rOriginY ) ) )
+ {
+ rOriginX = 0.50;
+ rOriginY =-0.50;
+ }
+}
+
+void GetRotateAngle( SdrCustomShapeGeometryItem& rItem, double& rAngleX, double& rAngleY )
+{
+ ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aRotateAngleParaPair;
+ const rtl::OUString sRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "RotateAngle" ) );
+ Any* pAny = rItem.GetPropertyValueByName( sExtrusion, sRotateAngle );
+ if ( ! ( pAny && ( *pAny >>= aRotateAngleParaPair ) && ( aRotateAngleParaPair.First.Value >>= rAngleX ) && ( aRotateAngleParaPair.Second.Value >>= rAngleY ) ) )
+ {
+ rAngleX = 0.0;
+ rAngleY = 0.0;
+ }
+ rAngleX *= F_PI180;
+ rAngleY *= F_PI180;
+}
+
+void GetSkew( SdrCustomShapeGeometryItem& rItem, double& rSkewAmount, double& rSkewAngle )
+{
+ ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aSkewParaPair;
+ const rtl::OUString sSkew( RTL_CONSTASCII_USTRINGPARAM ( "Skew" ) );
+ Any* pAny = rItem.GetPropertyValueByName( sExtrusion, sSkew );
+ if ( ! ( pAny && ( *pAny >>= aSkewParaPair ) && ( aSkewParaPair.First.Value >>= rSkewAmount ) && ( aSkewParaPair.Second.Value >>= rSkewAngle ) ) )
+ {
+ rSkewAmount = 50;
+ rSkewAngle = -135;
+ }
+ rSkewAngle *= F_PI180;
+}
+
+void GetExtrusionDepth( SdrCustomShapeGeometryItem& rItem, const double* pMap, double& rBackwardDepth, double& rForwardDepth )
+{
+ ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aDepthParaPair;
+ double fDepth = 0, fFraction = 0;
+ const rtl::OUString sDepth( RTL_CONSTASCII_USTRINGPARAM ( "Depth" ) );
+ Any* pAny = rItem.GetPropertyValueByName( sExtrusion, sDepth );
+ if ( pAny && ( *pAny >>= aDepthParaPair ) && ( aDepthParaPair.First.Value >>= fDepth ) && ( aDepthParaPair.Second.Value >>= fFraction ) )
+ {
+ rForwardDepth = fDepth * fFraction;
+ rBackwardDepth = fDepth - rForwardDepth;
+ }
+ else
+ {
+ rBackwardDepth = 1270;
+ rForwardDepth = 0;
+ }
+ if ( pMap )
+ {
+ double fMap = *pMap;
+ rBackwardDepth *= fMap;
+ rForwardDepth *= fMap;
+ }
+}
+
+double GetDouble( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName, double fDefault, const double* pMap )
+{
+ double fRetValue = fDefault;
+ Any* pAny = rItem.GetPropertyValueByName( sExtrusion, rPropertyName );
+ if ( pAny )
+ *pAny >>= fRetValue;
+ if ( pMap )
+ fRetValue *= *pMap;
+ return fRetValue;
+}
+
+drawing::ShadeMode GetShadeMode( SdrCustomShapeGeometryItem& rItem, const drawing::ShadeMode eDefault )
+{
+ drawing::ShadeMode eRet( eDefault );
+ const rtl::OUString sShadeMode( RTL_CONSTASCII_USTRINGPARAM ( "ShadeMode" ) );
+ Any* pAny = rItem.GetPropertyValueByName( sExtrusion, sShadeMode );
+ if ( pAny )
+ *pAny >>= eRet;
+ return eRet;
+}
+
+sal_Int32 GetInt32( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName, const sal_Int32 nDefault )
+{
+ sal_Int32 nRetValue = nDefault;
+ Any* pAny = rItem.GetPropertyValueByName( sExtrusion, rPropertyName );
+ if ( pAny )
+ *pAny >>= nRetValue;
+ return nRetValue;
+}
+
+sal_Bool GetBool( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName, const sal_Bool bDefault )
+{
+ sal_Bool bRetValue = bDefault;
+ const Any* pAny = rItem.GetPropertyValueByName( sExtrusion, rPropertyName );
+ if ( pAny )
+ *pAny >>= bRetValue;
+ return bRetValue;
+}
+
+awt::Point GetPoint( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName, const awt::Point& rDefault )
+{
+ awt::Point aRetValue( rDefault );
+ const Any* pAny = rItem.GetPropertyValueByName( sExtrusion, rPropertyName );
+ if ( pAny )
+ *pAny >>= aRetValue;
+ return aRetValue;
+}
+
+drawing::Position3D GetPosition3D( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName,
+ const drawing::Position3D& rDefault, const double* pMap )
+{
+ drawing::Position3D aRetValue( rDefault );
+ const Any* pAny = rItem.GetPropertyValueByName( sExtrusion, rPropertyName );
+ if ( pAny )
+ *pAny >>= aRetValue;
+ if ( pMap )
+ {
+ aRetValue.PositionX *= *pMap;
+ aRetValue.PositionY *= *pMap;
+ aRetValue.PositionZ *= *pMap;
+ }
+ return aRetValue;
+}
+
+drawing::Direction3D GetDirection3D( SdrCustomShapeGeometryItem& rItem, const rtl::OUString& rPropertyName, const drawing::Direction3D& rDefault )
+{
+ drawing::Direction3D aRetValue( rDefault );
+ const Any* pAny = rItem.GetPropertyValueByName( sExtrusion, rPropertyName );
+ if ( pAny )
+ *pAny >>= aRetValue;
+ return aRetValue;
+}
+
+EnhancedCustomShape3d::Transformation2D::Transformation2D( const SdrObject* pCustomShape, const Rectangle& /*rBoundRect*/, const double *pM )
+: aCenter( pCustomShape->GetSnapRect().Center() )
+, eProjectionMode( drawing::ProjectionMode_PARALLEL )
+, pMap( pM )
+{
+ SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ const rtl::OUString sProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
+ Any* pAny = rGeometryItem.GetPropertyValueByName( sExtrusion, sProjectionMode );
+ if ( pAny )
+ *pAny >>= eProjectionMode;
+
+ if ( eProjectionMode == drawing::ProjectionMode_PARALLEL )
+ GetSkew( rGeometryItem, fSkew, fSkewAngle );
+ else
+ {
+ fZScreen = 0.0;
+ GetOrigin( rGeometryItem, fOriginX, fOriginY );
+ fOriginX = fOriginX * pCustomShape->GetLogicRect().GetWidth();
+ fOriginY = fOriginY * pCustomShape->GetLogicRect().GetHeight();
+
+ const rtl::OUString sViewPoint( RTL_CONSTASCII_USTRINGPARAM ( "ViewPoint" ) );
+ drawing::Position3D aViewPointDefault( 3472, -3472, 25000 );
+ drawing::Position3D aViewPoint( GetPosition3D( rGeometryItem, sViewPoint, aViewPointDefault, pMap ) );
+ fViewPoint.setX(aViewPoint.PositionX);
+ fViewPoint.setY(aViewPoint.PositionY);
+ fViewPoint.setZ(-aViewPoint.PositionZ);
+ }
+}
+
+basegfx::B3DPolygon EnhancedCustomShape3d::Transformation2D::ApplySkewSettings( const basegfx::B3DPolygon& rPoly3D ) const
+{
+ basegfx::B3DPolygon aRetval;
+
+ sal_uInt32 j;
+ for ( j = 0L; j < rPoly3D.count(); j++ )
+ {
+ const basegfx::B3DPoint aPoint(rPoly3D.getB3DPoint(j));
+ double fDepth(-( aPoint.getZ() * fSkew ) / 100.0);
+ aRetval.append(basegfx::B3DPoint(
+ aPoint.getX() + (fDepth * cos( fSkewAngle )),
+ aPoint.getY() - (fDepth * sin( fSkewAngle )),
+ aPoint.getZ()));
+ }
+
+ return aRetval;
+}
+
+Point EnhancedCustomShape3d::Transformation2D::Transform2D( const basegfx::B3DPoint& rPoint3D ) const
+{
+ Point aPoint2D;
+ if ( eProjectionMode == drawing::ProjectionMode_PARALLEL )
+ {
+ aPoint2D.X() = (sal_Int32)rPoint3D.getX();
+ aPoint2D.Y() = (sal_Int32)rPoint3D.getY();
+ }
+ else
+ {
+ double fX = rPoint3D.getX() - fOriginX;
+ double fY = rPoint3D.getY() - fOriginY;
+ double f = ( fZScreen - fViewPoint.getZ() ) / ( rPoint3D.getZ() - fViewPoint.getZ() );
+ aPoint2D.X() = (sal_Int32)(( fX - fViewPoint.getX() ) * f + fViewPoint.getX() + fOriginX );
+ aPoint2D.Y() = (sal_Int32)(( fY - fViewPoint.getY() ) * f + fViewPoint.getY() + fOriginY );
+ }
+ aPoint2D.Move( aCenter.X(), aCenter.Y() );
+ return aPoint2D;
+}
+
+sal_Bool EnhancedCustomShape3d::Transformation2D::IsParallel() const
+{
+ return eProjectionMode == com::sun::star::drawing::ProjectionMode_PARALLEL;
+}
+
+SdrObject* EnhancedCustomShape3d::Create3DObject( const SdrObject* pShape2d, const SdrObject* pCustomShape )
+{
+ SdrObject* pRet = NULL;
+ SdrModel* pModel = pCustomShape->GetModel();
+ SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+
+ double fMap, *pMap = NULL;
+ if ( pModel )
+ {
+ fMap = 1.0;
+ Fraction aFraction( pModel->GetScaleFraction() );
+ if ( ( aFraction.GetNumerator() ) != 1 || ( aFraction.GetDenominator() != 1 ) )
+ {
+ fMap *= aFraction.GetNumerator();
+ fMap /= aFraction.GetDenominator();
+ pMap = &fMap;
+ }
+ if ( pModel->GetScaleUnit() != MAP_100TH_MM )
+ {
+ DBG_ASSERT( pModel->GetScaleUnit() == MAP_TWIP, "EnhancedCustomShape3d::Current MapMode is Unsupported" );
+ fMap *= 1440.0 / 2540.0;
+ pMap = &fMap;
+ }
+ }
+ if ( GetBool( rGeometryItem, sExtrusion, sal_False ) )
+ {
+ sal_Bool bIsMirroredX = ((SdrObjCustomShape*)pCustomShape)->IsMirroredX();
+ sal_Bool bIsMirroredY = ((SdrObjCustomShape*)pCustomShape)->IsMirroredY();
+ Rectangle aSnapRect( pCustomShape->GetLogicRect() );
+ long nObjectRotation = pCustomShape->GetRotateAngle();
+ if ( nObjectRotation )
+ {
+ double a = ( 36000 - nObjectRotation ) * nPi180;
+ long dx = aSnapRect.Right() - aSnapRect.Left();
+ long dy = aSnapRect.Bottom()- aSnapRect.Top();
+ Point aP( aSnapRect.TopLeft() );
+ RotatePoint( aP, pCustomShape->GetSnapRect().Center(), sin( a ), cos( a ) );
+ aSnapRect.Left() = aP.X();
+ aSnapRect.Top() = aP.Y();
+ aSnapRect.Right() = aSnapRect.Left() + dx;
+ aSnapRect.Bottom() = aSnapRect.Top() + dy;
+ }
+ Point aCenter( aSnapRect.Center() );
+
+ SfxItemSet aSet( pCustomShape->GetMergedItemSet() );
+
+ //SJ: vertical writing is not required, by removing this item no outliner is created
+ aSet.ClearItem( SDRATTR_TEXTDIRECTION );
+
+ // #i105323# For 3D AutoShapes, the shadow attribute has to be applied to each
+ // created visualisation helper model shape individually. The shadow itself
+ // will then be rendered from the 3D renderer correctly for the whole 3D scene
+ // (and thus behind all objects of which the visualisation may be built). So,
+ // dio NOT remove it from the ItemSet here.
+ // aSet.ClearItem(SDRATTR_SHADOW);
+
+ std::vector< E3dCompoundObject* > aPlaceholderObjectList;
+
+ double fExtrusionBackward, fExtrusionForward;
+ GetExtrusionDepth( rGeometryItem, pMap, fExtrusionBackward, fExtrusionForward );
+ double fDepth = fExtrusionBackward - fExtrusionForward;
+ if ( fDepth < 1.0 )
+ fDepth = 1.0;
+
+ drawing::ProjectionMode eProjectionMode( drawing::ProjectionMode_PARALLEL );
+ const rtl::OUString sProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
+ Any* pAny = rGeometryItem.GetPropertyValueByName( sExtrusion, sProjectionMode );
+ if ( pAny )
+ *pAny >>= eProjectionMode;
+ ProjectionType eProjectionType( eProjectionMode == drawing::ProjectionMode_PARALLEL ? PR_PARALLEL : PR_PERSPECTIVE );
+
+ // pShape2d Umwandeln in Szene mit 3D Objekt
+ E3dDefaultAttributes a3DDefaultAttr;
+ a3DDefaultAttr.SetDefaultLatheCharacterMode( TRUE );
+ a3DDefaultAttr.SetDefaultExtrudeCharacterMode( TRUE );
+
+ E3dScene* pScene = new E3dPolyScene( a3DDefaultAttr );
+
+ sal_Bool bSceneHasObjects ( sal_False );
+ sal_Bool bUseTwoFillStyles( sal_False );
+
+ drawing::ShadeMode eShadeMode( GetShadeMode( rGeometryItem, drawing::ShadeMode_FLAT ) );
+ const rtl::OUString sExtrusionColor( RTL_CONSTASCII_USTRINGPARAM ( "Color" ) );
+ sal_Bool bUseExtrusionColor = GetBool( rGeometryItem, sExtrusionColor, sal_False );
+
+ XFillStyle eFillStyle( ITEMVALUE( aSet, XATTR_FILLSTYLE, XFillStyleItem ) );
+ pScene->GetProperties().SetObjectItem( Svx3DShadeModeItem( 0 ) );
+ aSet.Put( Svx3DPercentDiagonalItem( 0 ) );
+ aSet.Put( Svx3DTextureModeItem( 1 ) );
+ aSet.Put( Svx3DNormalsKindItem( 1 ) );
+
+ if ( eShadeMode == drawing::ShadeMode_DRAFT )
+ {
+ aSet.Put( XLineStyleItem( XLINE_SOLID ) );
+ aSet.Put( XFillStyleItem ( XFILL_NONE ) );
+ aSet.Put( Svx3DDoubleSidedItem( TRUE ) );
+ }
+ else
+ {
+ aSet.Put( XLineStyleItem( XLINE_NONE ) );
+ if ( eFillStyle == XFILL_NONE )
+ aSet.Put( XFillStyleItem( XFILL_SOLID ) );
+ else if ( ( eFillStyle == XFILL_BITMAP ) || ( eFillStyle == XFILL_GRADIENT ) || bUseExtrusionColor )
+ bUseTwoFillStyles = sal_True;
+
+ // #116336#
+ // If shapes are mirrored once (mirroring two times correct geometry again)
+ // double-sided at the object and two-sided-lighting at the scene need to be set.
+ if((bIsMirroredX && !bIsMirroredY) || (!bIsMirroredX && bIsMirroredY))
+ {
+ aSet.Put( Svx3DDoubleSidedItem( sal_True ) );
+ pScene->GetProperties().SetObjectItem( Svx3DTwoSidedLightingItem( sal_True ) );
+ }
+ }
+
+ Rectangle aBoundRect2d;
+ SdrObjListIter aIter( *pShape2d, IM_DEEPWITHGROUPS );
+ while( aIter.IsMore() )
+ {
+ const SdrObject* pNext = aIter.Next();
+ sal_Bool bIsPlaceholderObject = (((XFillStyleItem&)pNext->GetMergedItem( XATTR_FILLSTYLE )).GetValue() == XFILL_NONE )
+ && (((XLineStyleItem&)pNext->GetMergedItem( XATTR_LINESTYLE )).GetValue() == XLINE_NONE );
+ basegfx::B2DPolyPolygon aPolyPoly;
+
+ if ( pNext->ISA( SdrPathObj ) )
+ {
+ aPolyPoly = ((SdrPathObj*)pNext)->GetPathPoly();
+
+ if(aPolyPoly.areControlPointsUsed())
+ {
+ aPolyPoly = basegfx::tools::adaptiveSubdivideByAngle(aPolyPoly);
+ }
+ }
+ else
+ {
+ SdrObject* pNewObj = pNext->ConvertToPolyObj( FALSE, FALSE );
+ SdrPathObj* pPath = PTR_CAST( SdrPathObj, pNewObj );
+ if ( pPath )
+ aPolyPoly = pPath->GetPathPoly();
+ SdrObject::Free( pNewObj );
+ }
+
+ if( aPolyPoly.count() )
+ {
+ const basegfx::B2DRange aTempRange(basegfx::tools::getRange(aPolyPoly));
+ const Rectangle aBoundRect(basegfx::fround(aTempRange.getMinX()), basegfx::fround(aTempRange.getMinY()), basegfx::fround(aTempRange.getMaxX()), basegfx::fround(aTempRange.getMaxY()));
+ aBoundRect2d.Union( aBoundRect );
+
+ E3dCompoundObject* p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, bUseTwoFillStyles ? 10 : fDepth );
+ p3DObj->NbcSetLayer( pShape2d->GetLayer() );
+ p3DObj->SetMergedItemSet( aSet );
+ if ( bIsPlaceholderObject )
+ aPlaceholderObjectList.push_back( p3DObj );
+ else if ( bUseTwoFillStyles )
+ {
+ Bitmap aFillBmp;
+ sal_Bool bFillBmpTile = ((XFillBmpTileItem&)p3DObj->GetMergedItem( XATTR_FILLBMP_TILE )).GetValue();
+ if ( bFillBmpTile )
+ {
+ const XFillBitmapItem& rBmpItm = (XFillBitmapItem&)p3DObj->GetMergedItem( XATTR_FILLBITMAP );
+ const XOBitmap& rXOBmp = rBmpItm.GetBitmapValue();
+ aFillBmp = rXOBmp.GetBitmap();
+ Size aLogicalSize = aFillBmp.GetPrefSize();
+ if ( aFillBmp.GetPrefMapMode() == MAP_PIXEL )
+ aLogicalSize = Application::GetDefaultDevice()->PixelToLogic( aLogicalSize, MAP_100TH_MM );
+ else
+ aLogicalSize = OutputDevice::LogicToLogic( aLogicalSize, aFillBmp.GetPrefMapMode(), MAP_100TH_MM );
+ aLogicalSize.Width() *= 5; ;// :-( nice scaling, look at engine3d/obj3d.cxx
+ aLogicalSize.Height() *= 5;
+ aFillBmp.SetPrefSize( aLogicalSize );
+ aFillBmp.SetPrefMapMode( MAP_100TH_MM );
+ p3DObj->SetMergedItem( XFillBitmapItem( String(), aFillBmp ) );
+ }
+ else
+ {
+ if ( aSnapRect != aBoundRect )
+ {
+ const XFillBitmapItem& rBmpItm = (XFillBitmapItem&)p3DObj->GetMergedItem( XATTR_FILLBITMAP );
+ const XOBitmap& rXOBmp = rBmpItm.GetBitmapValue();
+ aFillBmp = rXOBmp.GetBitmap();
+ Size aBmpSize( aFillBmp.GetSizePixel() );
+ double fXScale = (double)aBoundRect.GetWidth() / (double)aSnapRect.GetWidth();
+ double fYScale = (double)aBoundRect.GetHeight() / (double)aSnapRect.GetHeight();
+
+ Point aPt( (sal_Int32)( (double)( aBoundRect.Left() - aSnapRect.Left() )* (double)aBmpSize.Width() / (double)aSnapRect.GetWidth() ),
+ (sal_Int32)( (double)( aBoundRect.Top() - aSnapRect.Top() ) * (double)aBmpSize.Height() / (double)aSnapRect.GetHeight() ) );
+ Size aSize( (sal_Int32)( aBmpSize.Width() * fXScale ),
+ (sal_Int32)( aBmpSize.Height() * fYScale ) );
+ Rectangle aCropRect( aPt, aSize );
+ aFillBmp.Crop( aCropRect );
+ p3DObj->SetMergedItem( XFillBitmapItem( String(), aFillBmp ) );
+ }
+ }
+ pScene->Insert3DObj( p3DObj );
+ p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, fDepth );
+ p3DObj->NbcSetLayer( pShape2d->GetLayer() );
+ p3DObj->SetMergedItemSet( aSet );
+ if ( bUseExtrusionColor )
+ p3DObj->SetMergedItem( XFillColorItem( String(), ((XSecondaryFillColorItem&)pCustomShape->GetMergedItem( XATTR_SECONDARYFILLCOLOR )).GetColorValue() ) );
+ p3DObj->SetMergedItem( XFillStyleItem( XFILL_SOLID ) );
+ p3DObj->SetMergedItem( Svx3DCloseFrontItem( sal_False ) );
+ p3DObj->SetMergedItem( Svx3DCloseBackItem( sal_False ) );
+ pScene->Insert3DObj( p3DObj );
+ p3DObj = new E3dExtrudeObj( a3DDefaultAttr, aPolyPoly, 10 );
+ p3DObj->NbcSetLayer( pShape2d->GetLayer() );
+ p3DObj->SetMergedItemSet( aSet );
+
+ basegfx::B3DHomMatrix aFrontTransform( p3DObj->GetTransform() );
+ aFrontTransform.translate( 0.0, 0.0, fDepth );
+ p3DObj->NbcSetTransform( aFrontTransform );
+
+ if ( ( eFillStyle == XFILL_BITMAP ) && !aFillBmp.IsEmpty() )
+ p3DObj->SetMergedItem( XFillBitmapItem( String(), aFillBmp ) );
+ }
+ else if ( eFillStyle == XFILL_NONE )
+ {
+ XLineColorItem& rLineColor = (XLineColorItem&)p3DObj->GetMergedItem( XATTR_LINECOLOR );
+ p3DObj->SetMergedItem( XFillColorItem( String(), rLineColor.GetColorValue() ) );
+ p3DObj->SetMergedItem( Svx3DDoubleSidedItem( sal_True ) );
+ p3DObj->SetMergedItem( Svx3DCloseFrontItem( sal_False ) );
+ p3DObj->SetMergedItem( Svx3DCloseBackItem( sal_False ) );
+ }
+ pScene->Insert3DObj( p3DObj );
+ bSceneHasObjects = sal_True;
+ }
+ }
+
+ if ( bSceneHasObjects ) // is the SdrObject properly converted
+ {
+ // then we can change the return value
+ pRet = pScene;
+
+ // Kameraeinstellungen, Perspektive ...
+ Camera3D& rCamera = (Camera3D&)pScene->GetCamera();
+ const basegfx::B3DRange& rVolume = pScene->GetBoundVolume();
+ pScene->NbcSetSnapRect( aSnapRect );
+
+ // InitScene replacement
+ double fW = rVolume.getWidth();
+ double fH = rVolume.getHeight();
+
+ rCamera.SetAutoAdjustProjection( FALSE );
+ rCamera.SetViewWindow( -fW / 2, - fH / 2, fW, fH);
+ basegfx::B3DPoint aLookAt( 0.0, 0.0, 0.0 );
+ basegfx::B3DPoint aCamPos( 0.0, 0.0, 100.0 );
+ rCamera.SetDefaults( basegfx::B3DPoint( 0.0, 0.0, 100.0 ), aLookAt, 100.0 );
+ rCamera.SetPosAndLookAt( aCamPos, aLookAt );
+ rCamera.SetFocalLength( 1.0 );
+ rCamera.SetProjection( eProjectionType );
+ pScene->SetCamera( rCamera );
+ pScene->SetRectsDirty();
+
+ double fOriginX, fOriginY;
+ GetOrigin( rGeometryItem, fOriginX, fOriginY );
+ fOriginX = fOriginX * aSnapRect.GetWidth();
+ fOriginY = fOriginY * aSnapRect.GetHeight();
+
+ basegfx::B3DHomMatrix aNewTransform( pScene->GetTransform() );
+ aNewTransform.translate( -aCenter.X(), aCenter.Y(), -pScene->GetBoundVolume().getDepth() );
+
+ double fXRotate, fYRotate;
+ GetRotateAngle( rGeometryItem, fXRotate, fYRotate );
+ double fZRotate = ((SdrObjCustomShape*)pCustomShape)->GetObjectRotation() * F_PI180;
+ if ( fZRotate != 0.0 )
+ aNewTransform.rotate( 0.0, 0.0, fZRotate );
+ if ( bIsMirroredX )
+ aNewTransform.scale( -1.0, 1, 1 );
+ if ( bIsMirroredY )
+ aNewTransform.scale( 1, -1.0, 1 );
+ if( fYRotate != 0.0 )
+ aNewTransform.rotate( 0.0, -fYRotate, 0.0 );
+ if( fXRotate != 0.0 )
+ aNewTransform.rotate( -fXRotate, 0.0, 0.0 );
+ if ( eProjectionType == PR_PARALLEL )
+ {
+ double fSkew, fAlpha;
+ GetSkew( rGeometryItem, fSkew, fAlpha );
+ if ( fSkew != 0.0 )
+ {
+ double fInvTanBeta( fSkew / 100.0 );
+ if(fInvTanBeta)
+ {
+ aNewTransform.shearXY(
+ fInvTanBeta * cos(fAlpha),
+ fInvTanBeta * sin(fAlpha));
+ }
+ }
+ basegfx::B3DPoint _aLookAt( 0.0, 0.0, 0.0 );
+ basegfx::B3DPoint _aNewCamPos( 0.0, 0.0, 25000.0 );
+ rCamera.SetPosAndLookAt( _aNewCamPos, _aLookAt );
+ pScene->SetCamera( rCamera );
+ }
+ else
+ {
+ aNewTransform.translate( -fOriginX, fOriginY, 0.0 );
+ // now set correct camera position
+ const rtl::OUString sViewPoint( RTL_CONSTASCII_USTRINGPARAM ( "ViewPoint" ) );
+ drawing::Position3D aViewPointDefault( 3472, -3472, 25000 );
+ drawing::Position3D aViewPoint( GetPosition3D( rGeometryItem, sViewPoint, aViewPointDefault, pMap ) );
+ double fViewPointX = aViewPoint.PositionX;
+ double fViewPointY = aViewPoint.PositionY;
+ double fViewPointZ = aViewPoint.PositionZ;
+ basegfx::B3DPoint _aLookAt( fViewPointX, -fViewPointY, 0.0 );
+ basegfx::B3DPoint aNewCamPos( fViewPointX, -fViewPointY, fViewPointZ );
+ rCamera.SetPosAndLookAt( aNewCamPos, _aLookAt );
+ pScene->SetCamera( rCamera );
+ }
+
+ pScene->NbcSetTransform( aNewTransform );
+
+ ///////////
+ // light //
+ ///////////
+
+ const rtl::OUString sBrightness( RTL_CONSTASCII_USTRINGPARAM ( "Brightness" ) );
+ double fAmbientIntensity = GetDouble( rGeometryItem, sBrightness, 22178.0 / 655.36, NULL ) / 100.0;
+
+
+ const rtl::OUString sFirstLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightDirection" ) );
+ drawing::Direction3D aFirstLightDirectionDefault( 50000, 0, 10000 );
+ drawing::Direction3D aFirstLightDirection( GetDirection3D( rGeometryItem, sFirstLightDirection, aFirstLightDirectionDefault ) );
+ if ( aFirstLightDirection.DirectionZ == 0.0 )
+ aFirstLightDirection.DirectionZ = 1.0;
+
+ const rtl::OUString sFirstLightLevel( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightLevel" ) );
+ double fLightIntensity = GetDouble( rGeometryItem, sFirstLightLevel, 43712.0 / 655.36, NULL ) / 100.0;
+
+ const rtl::OUString sFirstLightHarsh( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightHarsh" ) );
+ /* sal_Bool bFirstLightHarsh = */ GetBool( rGeometryItem, sFirstLightHarsh, sal_False );
+
+ const rtl::OUString sSecondLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightDirection" ) );
+ drawing::Direction3D aSecondLightDirectionDefault( -50000, 0, 10000 );
+ drawing::Direction3D aSecondLightDirection( GetDirection3D( rGeometryItem, sSecondLightDirection, aSecondLightDirectionDefault ) );
+ if ( aSecondLightDirection.DirectionZ == 0.0 )
+ aSecondLightDirection.DirectionZ = -1;
+
+ const rtl::OUString sSecondLightLevel( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightLevel" ) );
+ double fLight2Intensity = GetDouble( rGeometryItem, sSecondLightLevel, 43712.0 / 655.36, NULL ) / 100.0;
+
+ const rtl::OUString sSecondLightHarsh( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightHarsh" ) );
+ const rtl::OUString sLightFace( RTL_CONSTASCII_USTRINGPARAM ( "LightFace" ) );
+ /* sal_Bool bLight2Harsh = */ GetBool( rGeometryItem, sSecondLightHarsh, sal_False );
+ /* sal_Bool bLightFace = */ GetBool( rGeometryItem, sLightFace, sal_False );
+
+ sal_uInt16 nAmbientColor = (sal_uInt16)( fAmbientIntensity * 255.0 );
+ if ( nAmbientColor > 255 )
+ nAmbientColor = 255;
+ Color aGlobalAmbientColor( (sal_uInt8)nAmbientColor, (sal_uInt8)nAmbientColor, (sal_uInt8)nAmbientColor );
+ pScene->GetProperties().SetObjectItem( Svx3DAmbientcolorItem( aGlobalAmbientColor ) );
+
+ sal_uInt8 nSpotLight1 = (sal_uInt8)( fLightIntensity * 255.0 );
+ basegfx::B3DVector aSpotLight1( aFirstLightDirection.DirectionX, - ( aFirstLightDirection.DirectionY ), -( aFirstLightDirection.DirectionZ ) );
+ aSpotLight1.normalize();
+ pScene->GetProperties().SetObjectItem( Svx3DLightOnOff1Item( sal_True ) );
+ Color aAmbientSpot1Color( nSpotLight1, nSpotLight1, nSpotLight1 );
+ pScene->GetProperties().SetObjectItem( Svx3DLightcolor1Item( aAmbientSpot1Color ) );
+ pScene->GetProperties().SetObjectItem( Svx3DLightDirection1Item( aSpotLight1 ) );
+
+ sal_uInt8 nSpotLight2 = (sal_uInt8)( fLight2Intensity * 255.0 );
+ basegfx::B3DVector aSpotLight2( aSecondLightDirection.DirectionX, -aSecondLightDirection.DirectionY, -aSecondLightDirection.DirectionZ );
+ aSpotLight2.normalize();
+ pScene->GetProperties().SetObjectItem( Svx3DLightOnOff2Item( sal_True ) );
+ Color aAmbientSpot2Color( nSpotLight2, nSpotLight2, nSpotLight2 );
+ pScene->GetProperties().SetObjectItem( Svx3DLightcolor2Item( aAmbientSpot2Color ) );
+ pScene->GetProperties().SetObjectItem( Svx3DLightDirection2Item( aSpotLight2 ) );
+
+ sal_uInt8 nSpotLight3 = 70;
+ basegfx::B3DVector aSpotLight3( 0.0, 0.0, 1.0 );
+ pScene->GetProperties().SetObjectItem( Svx3DLightOnOff3Item( sal_True ) );
+ Color aAmbientSpot3Color( nSpotLight3, nSpotLight3, nSpotLight3 );
+ pScene->GetProperties().SetObjectItem( Svx3DLightcolor3Item( aAmbientSpot3Color ) );
+ pScene->GetProperties().SetObjectItem( Svx3DLightDirection3Item( aSpotLight3 ) );
+
+ const rtl::OUString sSpecularity( RTL_CONSTASCII_USTRINGPARAM ( "Specularity" ) );
+ const rtl::OUString sDiffusion( RTL_CONSTASCII_USTRINGPARAM ( "Diffusion" ) );
+ const rtl::OUString sShininess( RTL_CONSTASCII_USTRINGPARAM ( "Shininess" ) );
+ const rtl::OUString sMetal( RTL_CONSTASCII_USTRINGPARAM ( "Metal" ) );
+ double fSpecular = GetDouble( rGeometryItem, sSpecularity, 0, NULL ) / 100;
+ sal_Bool bMetal = GetBool( rGeometryItem, sMetal, sal_False );
+
+ Color aSpecularCol( 225,225,225 );
+ if ( bMetal )
+ {
+ aSpecularCol = Color( 200, 200, 200 );
+ fSpecular += 0.15;
+ }
+ sal_Int32 nIntensity = (sal_Int32)fSpecular * 100;
+ if ( nIntensity > 100 )
+ nIntensity = 100;
+ else if ( nIntensity < 0 )
+ nIntensity = 0;
+ nIntensity = 100 - nIntensity;
+ pScene->GetProperties().SetObjectItem( Svx3DMaterialSpecularItem( aSpecularCol ) );
+ pScene->GetProperties().SetObjectItem( Svx3DMaterialSpecularIntensityItem( (sal_uInt16)nIntensity ) );
+
+ pScene->SetLogicRect( CalculateNewSnapRect( pCustomShape, aSnapRect, aBoundRect2d, pMap ) );
+
+ // removing placeholder objects
+ std::vector< E3dCompoundObject* >::iterator aObjectListIter( aPlaceholderObjectList.begin() );
+ while ( aObjectListIter != aPlaceholderObjectList.end() )
+ {
+ pScene->Remove3DObj( *aObjectListIter );
+ delete *aObjectListIter++;
+ }
+ }
+ else
+ delete pScene;
+ }
+ return pRet;
+}
+
+Rectangle EnhancedCustomShape3d::CalculateNewSnapRect( const SdrObject* pCustomShape, const Rectangle& rSnapRect, const Rectangle& rBoundRect, const double* pMap )
+{
+ SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ const Point aCenter( rSnapRect.Center() );
+ double fExtrusionBackward, fExtrusionForward;
+ GetExtrusionDepth( rGeometryItem, pMap, fExtrusionBackward, fExtrusionForward );
+ sal_uInt32 i;
+
+ // creating initial bound volume ( without rotation. skewing.and camera )
+ basegfx::B3DPolygon aBoundVolume;
+ const Polygon aPolygon( rBoundRect );
+
+ for ( i = 0L; i < 4L; i++ )
+ {
+ aBoundVolume.append(basegfx::B3DPoint(aPolygon[ (sal_uInt16)i ].X() - aCenter.X(), aPolygon[ (sal_uInt16)i ].Y() - aCenter.Y(), fExtrusionForward));
+ }
+
+ for ( i = 0L; i < 4L; i++ )
+ {
+ aBoundVolume.append(basegfx::B3DPoint(aPolygon[ (sal_uInt16)i ].X() - aCenter.X(), aPolygon[ (sal_uInt16)i ].Y() - aCenter.Y(), fExtrusionBackward));
+ }
+
+ const rtl::OUString sRotationCenter( RTL_CONSTASCII_USTRINGPARAM ( "RotationCenter" ) );
+ drawing::Direction3D aRotationCenterDefault( 0, 0, 0 ); // default seems to be wrong, a fractional size of shape has to be used!!
+ drawing::Direction3D aRotationCenter( GetDirection3D( rGeometryItem, sRotationCenter, aRotationCenterDefault ) );
+
+ // double XCenterInGUnits = rPropSet.GetPropertyValue( DFF_Prop_c3DRotationCenterX, 0 );
+ // double YCenterInGUnits = rPropSet.GetPropertyValue( DFF_Prop_c3DRotationCenterY, 0 );
+
+ // sal_Int32 nRotationXAxisInProz = rPropSet.GetPropertyValue( DFF_Prop_c3DRotationAxisX, 100 );
+ // sal_Int32 nRotationYAxisInProz = rPropSet.GetPropertyValue( DFF_Prop_c3DRotationAxisY, 0 );
+ // sal_Int32 nRotationZAxisInProz = rPropSet.GetPropertyValue( DFF_Prop_c3DRotationAxisZ, 0 );
+
+
+ double fXRotate, fYRotate;
+ GetRotateAngle( rGeometryItem, fXRotate, fYRotate );
+ double fZRotate = - ((SdrObjCustomShape*)pCustomShape)->GetObjectRotation() * F_PI180;
+
+ // rotating bound volume
+ basegfx::B3DHomMatrix aMatrix;
+ aMatrix.translate(-aRotationCenter.DirectionX, -aRotationCenter.DirectionY, -aRotationCenter.DirectionZ);
+ if ( fZRotate != 0.0 )
+ aMatrix.rotate( 0.0, 0.0, fZRotate );
+ if ( ((SdrObjCustomShape*)pCustomShape)->IsMirroredX() )
+ aMatrix.scale( -1.0, 1, 1 );
+ if ( ((SdrObjCustomShape*)pCustomShape)->IsMirroredY() )
+ aMatrix.scale( 1, -1.0, 1 );
+ if( fYRotate != 0.0 )
+ aMatrix.rotate( 0.0, fYRotate, 0.0 );
+ if( fXRotate != 0.0 )
+ aMatrix.rotate( -fXRotate, 0.0, 0.0 );
+ aMatrix.translate(aRotationCenter.DirectionX, aRotationCenter.DirectionY, aRotationCenter.DirectionZ);
+ aBoundVolume.transform(aMatrix);
+
+ Transformation2D aTransformation2D( pCustomShape, rSnapRect, pMap );
+ if ( aTransformation2D.IsParallel() )
+ aBoundVolume = aTransformation2D.ApplySkewSettings( aBoundVolume );
+
+ Polygon aTransformed( 8 );
+ for ( i = 0L; i < 8L; i++ )
+ aTransformed[ (sal_uInt16)i ] = aTransformation2D.Transform2D( aBoundVolume.getB3DPoint( i ) );
+
+ return aTransformed.GetBoundRect();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShape3d.hxx b/svx/source/customshapes/EnhancedCustomShape3d.hxx
new file mode 100644
index 000000000000..8007d9829b53
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShape3d.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _ENHANCEDCUSTOMSHAPE3D_HXX
+#define _ENHANCEDCUSTOMSHAPE3D_HXX
+
+#include <vector>
+#include <com/sun/star/drawing/ProjectionMode.hpp>
+#include <basegfx/point/b3dpoint.hxx>
+#include <basegfx/polygon/b3dpolygon.hxx>
+
+#include <tools/gen.hxx>
+
+class SdrObject;
+
+class EnhancedCustomShape3d
+{
+ class Transformation2D
+ {
+ Point aCenter;
+ com::sun::star::drawing::ProjectionMode eProjectionMode;
+
+ // parallel projection
+ double fSkewAngle;
+ double fSkew; // in percent
+
+ // perspective projection
+ double fZScreen;
+ basegfx::B3DPoint fViewPoint;
+ double fOriginX;
+ double fOriginY;
+
+ const double* pMap;
+
+ public :
+
+ Transformation2D( const SdrObject* pCustomShape, const Rectangle& rBoundRect, const double* pMap );
+
+ basegfx::B3DPolygon ApplySkewSettings( const basegfx::B3DPolygon& rPolygon3D ) const;
+ Point Transform2D( const basegfx::B3DPoint& rPoint ) const;
+ sal_Bool IsParallel() const;
+ };
+
+ friend class Transformation2D;
+
+ protected :
+ static Rectangle CalculateNewSnapRect( const SdrObject* pCustomShape, const Rectangle& rSnapRect, const Rectangle& rBoundRect, const double* pMap );
+
+ public :
+ static SdrObject* Create3DObject( const SdrObject* pShape2d, const SdrObject* pCustomShape );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.cxx b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
new file mode 100644
index 000000000000..96109855827e
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.cxx
@@ -0,0 +1,472 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "EnhancedCustomShapeEngine.hxx"
+#include "EnhancedCustomShape2d.hxx"
+#include "EnhancedCustomShape3d.hxx"
+#include "EnhancedCustomShapeFontWork.hxx"
+#include "EnhancedCustomShapeHandle.hxx"
+#include "EnhancedCustomShapeGeometry.hxx"
+#include <svx/unoshape.hxx>
+#include "svx/unopage.hxx"
+#include "unoapi.hxx"
+#include <svx/svdobj.hxx>
+#include <svx/svdoashp.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdorect.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/outliner.hxx>
+#include <svx/svdoutl.hxx>
+#include <svl/itemset.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdmodel.hxx>
+#include "svditer.hxx"
+#include "unopolyhelper.hxx"
+#include <uno/mapping.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <com/sun/star/document/XActionLockable.hpp>
+
+// ---------------------------
+// - EnhancedCustomShapeEngine -
+// ---------------------------
+
+rtl::OUString EnhancedCustomShapeEngine_getImplementationName()
+ throw( NMSP_UNO::RuntimeException )
+{
+ return B2UCONST( "com.sun.star.drawing.EnhancedCustomShapeEngine" );
+}
+sal_Bool SAL_CALL EnhancedCustomShapeEngine_supportsService( const rtl::OUString& ServiceName )
+ throw( NMSP_UNO::RuntimeException )
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.CustomShapeEngine" ) );
+}
+SEQ( rtl::OUString ) SAL_CALL EnhancedCustomShapeEngine_getSupportedServiceNames()
+ throw( NMSP_UNO::RuntimeException )
+{
+ SEQ( rtl::OUString ) aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = B2UCONST( "com.sun.star.drawing.CustomShapeEngine" );
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+EnhancedCustomShapeEngine::EnhancedCustomShapeEngine( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) :
+ mxFact ( rxMgr ),
+ mbForceGroupWithText ( sal_False )
+{
+}
+EnhancedCustomShapeEngine::~EnhancedCustomShapeEngine()
+{
+}
+
+// XInterface -----------------------------------------------------------------
+
+void SAL_CALL EnhancedCustomShapeEngine::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+void SAL_CALL EnhancedCustomShapeEngine::release() throw()
+{
+ OWeakObject::release();
+}
+
+// XInitialization ------------------------------------------------------------
+
+void SAL_CALL EnhancedCustomShapeEngine::initialize( const SEQ( NMSP_UNO::Any )& aArguments )
+ throw ( NMSP_UNO::Exception, NMSP_UNO::RuntimeException )
+{
+ sal_Int32 i;
+ SEQ( NMSP_BEANS::PropertyValue ) aParameter;
+ for ( i = 0; i < aArguments.getLength(); i++ )
+ {
+ if ( aArguments[ i ] >>= aParameter )
+ break;
+ }
+ for ( i = 0; i < aParameter.getLength(); i++ )
+ {
+ const NMSP_BEANS::PropertyValue& rProp = aParameter[ i ];
+ if ( rProp.Name.equalsAscii( "CustomShape" ) )
+ rProp.Value >>= mxShape;
+ else if ( rProp.Name.equalsAscii( "ForceGroupWithText" ) )
+ rProp.Value >>= mbForceGroupWithText;
+ }
+}
+
+// XServiceInfo ---------------------------------------------------------------
+
+rtl::OUString SAL_CALL EnhancedCustomShapeEngine::getImplementationName()
+ throw( NMSP_UNO::RuntimeException )
+{
+ return EnhancedCustomShapeEngine_getImplementationName();
+}
+sal_Bool SAL_CALL EnhancedCustomShapeEngine::supportsService( const rtl::OUString& rServiceName )
+ throw( NMSP_UNO::RuntimeException )
+{
+ return EnhancedCustomShapeEngine_supportsService( rServiceName );
+}
+SEQ( rtl::OUString ) SAL_CALL EnhancedCustomShapeEngine::getSupportedServiceNames()
+ throw ( NMSP_UNO::RuntimeException )
+{
+ return EnhancedCustomShapeEngine_getSupportedServiceNames();
+}
+
+// XCustomShapeEngine -----------------------------------------------------------
+
+SdrObject* EnhancedCustomShapeEngine::ImplForceGroupWithText( const SdrObjCustomShape* pCustoObj, SdrObject* pRenderedShape )
+{
+ bool bHasText = pCustoObj->HasText();
+ if ( pRenderedShape || bHasText )
+ {
+ // applying shadow
+ const SdrObject* pShadowGeometry = pCustoObj->GetSdrObjectShadowFromCustomShape();
+ if ( pShadowGeometry )
+ {
+ if ( pRenderedShape )
+ {
+ if ( !pRenderedShape->ISA( SdrObjGroup ) )
+ {
+ SdrObject* pTmp = pRenderedShape;
+ pRenderedShape = new SdrObjGroup();
+ ((SdrObjGroup*)pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
+ }
+ ((SdrObjGroup*)pRenderedShape)->GetSubList()->NbcInsertObject( pShadowGeometry->Clone(), 0 );
+ }
+ else
+ pRenderedShape = pShadowGeometry->Clone();
+ }
+
+ // apply text
+ if ( bHasText )
+ {
+ // #i37011# also create a text object and add at rPos + 1
+ SdrTextObj* pTextObj = (SdrTextObj*)SdrObjFactory::MakeNewObject(
+ pCustoObj->GetObjInventor(), OBJ_TEXT, 0L, pCustoObj->GetModel());
+
+ // Copy text content
+ OutlinerParaObject* pParaObj = pCustoObj->GetOutlinerParaObject();
+ if( pParaObj )
+ pTextObj->NbcSetOutlinerParaObject( new OutlinerParaObject(*pParaObj) );
+
+ // copy all attributes
+ SfxItemSet aTargetItemSet( pCustoObj->GetMergedItemSet() );
+
+ // clear fill and line style
+ aTargetItemSet.Put(XLineStyleItem(XLINE_NONE));
+ aTargetItemSet.Put(XFillStyleItem(XFILL_NONE));
+
+ // get the text bounds and set at text object
+ Rectangle aTextBounds = pCustoObj->GetSnapRect();
+ SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
+ if ( pSdrObjCustomShape )
+ {
+ EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ aTextBounds = aCustomShape2d.GetTextRect();
+ }
+ pTextObj->SetSnapRect( aTextBounds );
+
+ // if rotated, copy GeoStat, too.
+ const GeoStat& rSourceGeo = pCustoObj->GetGeoStat();
+ if ( rSourceGeo.nDrehWink )
+ {
+ pTextObj->NbcRotate(
+ pCustoObj->GetSnapRect().Center(), rSourceGeo.nDrehWink,
+ rSourceGeo.nSin, rSourceGeo.nCos);
+ }
+
+ // set modified ItemSet at text object
+ pTextObj->SetMergedItemSet(aTargetItemSet);
+
+ if ( pRenderedShape )
+ {
+ if ( !pRenderedShape->ISA( SdrObjGroup ) )
+ {
+ SdrObject* pTmp = pRenderedShape;
+ pRenderedShape = new SdrObjGroup();
+ ((SdrObjGroup*)pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
+ }
+ ((SdrObjGroup*)pRenderedShape)->GetSubList()->NbcInsertObject( pTextObj, LIST_APPEND );
+ }
+ else
+ pRenderedShape = pTextObj;
+ }
+
+ // force group
+ if ( pRenderedShape )
+ {
+ if ( !pRenderedShape->ISA( SdrObjGroup ) )
+ {
+ SdrObject* pTmp = pRenderedShape;
+ pRenderedShape = new SdrObjGroup();
+ ((SdrObjGroup*)pRenderedShape)->GetSubList()->NbcInsertObject( pTmp );
+ }
+ pRenderedShape->SetPage( pCustoObj->GetPage() );
+ pRenderedShape->SetModel( pCustoObj->GetModel() );
+ }
+ }
+ return pRenderedShape;
+}
+
+void SetTemporary( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape )
+{
+ if ( xShape.is() )
+ {
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+ if ( pShape )
+ pShape->TakeSdrObjectOwnership();
+/*
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::drawing::XShapes > xShapes( xShape, ::com::sun::star::uno::UNO_QUERY );
+ if ( xShapes.is() )
+ {
+ sal_Int32 i;
+ for ( i = 0; i < xShapes->getCount(); i++ )
+ {
+ ::com::sun::star::uno::Any aAny( xShapes->getByIndex( i ) );
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape;
+ if ( aAny >>= xShape )
+ SetTemporary( xShape );
+ }
+ }
+*/
+ }
+}
+
+REF( com::sun::star::drawing::XShape ) SAL_CALL EnhancedCustomShapeEngine::render()
+ throw ( NMSP_UNO::RuntimeException )
+{
+ REF( com::sun::star::drawing::XShape ) xShape;
+ SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
+ if ( pSdrObjCustomShape )
+ {
+ // retrieving the TextPath property to check if feature is enabled
+ SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)
+ pSdrObjCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ sal_Bool bTextPathOn = sal_False;
+ const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
+ com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sTextPath );
+ if ( pAny )
+ *pAny >>= bTextPathOn;
+
+ EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ sal_Int32 nRotateAngle = aCustomShape2d.GetRotateAngle();
+
+ sal_Bool bFlipV = aCustomShape2d.IsFlipVert();
+ sal_Bool bFlipH = aCustomShape2d.IsFlipHorz();
+ sal_Bool bLineGeometryNeededOnly = bTextPathOn;
+
+ SdrObject* pRenderedShape = aCustomShape2d.CreateObject( bLineGeometryNeededOnly );
+ if ( pRenderedShape )
+ {
+ if ( bTextPathOn )
+ {
+ SdrObject* pRenderedFontWork = EnhancedCustomShapeFontWork::CreateFontWork( pRenderedShape, pSdrObjCustomShape );
+ if ( pRenderedFontWork )
+ {
+ SdrObject::Free( pRenderedShape );
+ pRenderedShape = pRenderedFontWork;
+ }
+ }
+ SdrObject* pRenderedShape3d = EnhancedCustomShape3d::Create3DObject( pRenderedShape, pSdrObjCustomShape );
+ if ( pRenderedShape3d )
+ {
+ bFlipV = bFlipH = sal_False;
+ nRotateAngle = 0;
+ SdrObject::Free( pRenderedShape );
+ pRenderedShape = pRenderedShape3d;
+ }
+ Rectangle aRect( pSdrObjCustomShape->GetSnapRect() );
+
+ const GeoStat& rGeoStat = ((SdrObjCustomShape*)pSdrObjCustomShape)->GetGeoStat();
+ if ( rGeoStat.nShearWink )
+ {
+ long nShearWink = rGeoStat.nShearWink;
+ double nTan = rGeoStat.nTan;
+ if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
+ {
+ nShearWink = -nShearWink;
+ nTan = -nTan;
+ }
+ pRenderedShape->Shear( pSdrObjCustomShape->GetSnapRect().Center(), nShearWink, nTan, FALSE);
+ }
+ if( nRotateAngle )
+ {
+ double a = nRotateAngle * F_PI18000;
+ pRenderedShape->NbcRotate( pSdrObjCustomShape->GetSnapRect().Center(), nRotateAngle, sin( a ), cos( a ) );
+ }
+ if ( bFlipV )
+ {
+ Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
+ Point aRight( aLeft.X() + 1000, aLeft.Y() );
+ pRenderedShape->NbcMirror( aLeft, aRight );
+ }
+ if ( bFlipH )
+ {
+ Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
+ Point aBottom( aTop.X(), aTop.Y() + 1000 );
+ pRenderedShape->NbcMirror( aTop, aBottom );
+ }
+ pRenderedShape->NbcSetStyleSheet( pSdrObjCustomShape->GetStyleSheet(), sal_True );
+ pRenderedShape->RecalcSnapRect();
+ }
+
+ if ( mbForceGroupWithText )
+ pRenderedShape = ImplForceGroupWithText( (SdrObjCustomShape*)pSdrObjCustomShape, pRenderedShape );
+
+ if ( pRenderedShape )
+ {
+ aCustomShape2d.ApplyGluePoints( pRenderedShape );
+ xShape = SvxDrawPage::CreateShapeByTypeAndInventor( pRenderedShape->GetObjIdentifier(),
+ pRenderedShape->GetObjInventor(), pRenderedShape, NULL );
+ }
+ SetTemporary( xShape );
+ }
+ return xShape;
+}
+
+com::sun::star::awt::Rectangle SAL_CALL EnhancedCustomShapeEngine::getTextBounds()
+ throw ( NMSP_UNO::RuntimeException )
+{
+ com::sun::star::awt::Rectangle aTextRect;
+ SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
+ ::com::sun::star::uno::Reference< ::com::sun::star::document::XActionLockable > xLockable( mxShape, ::com::sun::star::uno::UNO_QUERY );
+ if ( pSdrObjCustomShape && pSdrObjCustomShape->GetModel() && xLockable.is() && !xLockable->isActionLocked() )
+ {
+ if ( pSdrObjCustomShape )
+ {
+ EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ Rectangle aRect( aCustomShape2d.GetTextRect() );
+ aTextRect.X = aRect.Left();
+ aTextRect.Y = aRect.Top();
+ aTextRect.Width = aRect.GetWidth();
+ aTextRect.Height = aRect.GetHeight();
+ }
+ }
+ return aTextRect;
+}
+
+com::sun::star::drawing::PolyPolygonBezierCoords SAL_CALL EnhancedCustomShapeEngine::getLineGeometry()
+ throw ( NMSP_UNO::RuntimeException )
+{
+ com::sun::star::drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords;
+ SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxShape ) );
+ if ( pSdrObjCustomShape )
+ {
+ EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ SdrObject* pObj = aCustomShape2d.CreateLineGeometry();
+ if ( pObj )
+ {
+ Rectangle aRect( pSdrObjCustomShape->GetSnapRect() );
+ sal_Bool bFlipV = aCustomShape2d.IsFlipVert();
+ sal_Bool bFlipH = aCustomShape2d.IsFlipHorz();
+
+ const GeoStat& rGeoStat = ((SdrObjCustomShape*)pSdrObjCustomShape)->GetGeoStat();
+ if ( rGeoStat.nShearWink )
+ {
+ long nShearWink = rGeoStat.nShearWink;
+ double nTan = rGeoStat.nTan;
+ if ((bFlipV&&!bFlipH )||(bFlipH&&!bFlipV))
+ {
+ nShearWink = -nShearWink;
+ nTan = -nTan;
+ }
+ pObj->Shear( aRect.Center(), nShearWink, nTan, FALSE);
+ }
+ sal_Int32 nRotateAngle = aCustomShape2d.GetRotateAngle();
+ if( nRotateAngle )
+ {
+ double a = nRotateAngle * F_PI18000;
+ pObj->NbcRotate( aRect.Center(), nRotateAngle, sin( a ), cos( a ) );
+ }
+ if ( bFlipH )
+ {
+ Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
+ Point aBottom( aTop.X(), aTop.Y() + 1000 );
+ pObj->NbcMirror( aTop, aBottom );
+ }
+ if ( bFlipV )
+ {
+ Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
+ Point aRight( aLeft.X() + 1000, aLeft.Y() );
+ pObj->NbcMirror( aLeft, aRight );
+ }
+
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ SdrObjListIter aIter( *pObj, IM_DEEPWITHGROUPS );
+
+ while ( aIter.IsMore() )
+ {
+ SdrObject* pNewObj = NULL;
+ basegfx::B2DPolyPolygon aPP;
+ const SdrObject* pNext = aIter.Next();
+
+ if ( pNext->ISA( SdrPathObj ) )
+ {
+ aPP = ((SdrPathObj*)pNext)->GetPathPoly();
+ }
+ else
+ {
+ pNewObj = pNext->ConvertToPolyObj( FALSE, FALSE );
+ SdrPathObj* pPath = PTR_CAST( SdrPathObj, pNewObj );
+ if ( pPath )
+ aPP = pPath->GetPathPoly();
+ }
+
+ if ( aPP.count() )
+ aPolyPolygon.append(aPP);
+
+ SdrObject::Free( pNewObj );
+ }
+ SdrObject::Free( pObj );
+ SvxConvertB2DPolyPolygonToPolyPolygonBezier( aPolyPolygon, aPolyPolygonBezierCoords );
+ }
+ }
+
+ return aPolyPolygonBezierCoords;
+}
+
+SEQ( REF( com::sun::star::drawing::XCustomShapeHandle ) ) SAL_CALL EnhancedCustomShapeEngine::getInteraction()
+ throw ( NMSP_UNO::RuntimeException )
+{
+ sal_uInt32 i, nHdlCount = 0;
+ SdrObject* pSdrObjCustomShape = GetSdrObjectFromXShape( mxShape );
+ if ( pSdrObjCustomShape )
+ {
+ EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ nHdlCount = aCustomShape2d.GetHdlCount();
+ }
+ SEQ( REF( com::sun::star::drawing::XCustomShapeHandle ) ) aSeq( nHdlCount );
+ for ( i = 0; i < nHdlCount; i++ )
+ aSeq[ i ] = new EnhancedCustomShapeHandle( mxShape, i );
+ return aSeq;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeEngine.hxx b/svx/source/customshapes/EnhancedCustomShapeEngine.hxx
new file mode 100644
index 000000000000..919f1a11f6fa
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeEngine.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _ENHANCED_CUSTOMSHAPE_ENGINE_HXX
+#define _ENHANCED_CUSTOMSHAPE_ENGINE_HXX
+
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <tools/stack.hxx>
+
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <cppuhelper/implbase3.hxx>
+#ifndef __com_sun_star_awt_Rectangle_hpp_
+#include <com/sun/star/awt/Rectangle.hpp>
+#endif
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/drawing/XCustomShapeEngine.hpp>
+
+// -----------------------------------------------------------------------------
+
+#define NMSP_IO com::sun::star::io
+#define NMSP_UNO com::sun::star::uno
+#define NMSP_BEANS com::sun::star::beans
+#define NMSP_LANG com::sun::star::lang
+#define NMSP_UTIL com::sun::star::util
+#define NMSP_SAX com::sun::star::xml::sax
+#define NMSP_LOGGING NMSP_UTIL::logging
+
+
+#define REF( _def_Obj ) NMSP_UNO::Reference< _def_Obj >
+#define SEQ( _def_Obj ) NMSP_UNO::Sequence< _def_Obj >
+#define B2UCONST( _def_pChar ) (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(_def_pChar )))
+
+// ---------------------------
+// - EnhancedCustomShapeEngine -
+// ---------------------------
+//
+
+class SdrObject;
+class SdrObjCustomShape;
+class EnhancedCustomShapeEngine : public cppu::WeakImplHelper3
+<
+ com::sun::star::lang::XInitialization,
+ com::sun::star::lang::XServiceInfo,
+ com::sun::star::drawing::XCustomShapeEngine
+>
+{
+ REF( NMSP_LANG::XMultiServiceFactory ) mxFact;
+ REF( com::sun::star::drawing::XShape ) mxShape;
+ sal_Bool mbForceGroupWithText;
+
+ SdrObject* ImplForceGroupWithText( const SdrObjCustomShape* pCustoObj, SdrObject* pRenderedShape );
+
+public:
+ EnhancedCustomShapeEngine( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr );
+ virtual ~EnhancedCustomShapeEngine();
+
+ // XInterface
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const SEQ( NMSP_UNO::Any )& aArguments )
+ throw ( NMSP_UNO::Exception, NMSP_UNO::RuntimeException );
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw ( NMSP_UNO::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& rServiceName )
+ throw ( NMSP_UNO::RuntimeException );
+ virtual SEQ( rtl::OUString ) SAL_CALL getSupportedServiceNames()
+ throw ( NMSP_UNO::RuntimeException );
+
+ // XCustomShapeEngine
+ virtual REF( com::sun::star::drawing::XShape ) SAL_CALL render()
+ throw ( NMSP_UNO::RuntimeException );
+ virtual com::sun::star::awt::Rectangle SAL_CALL getTextBounds()
+ throw ( NMSP_UNO::RuntimeException );
+ virtual com::sun::star::drawing::PolyPolygonBezierCoords SAL_CALL getLineGeometry()
+ throw ( NMSP_UNO::RuntimeException );
+ virtual SEQ( REF( com::sun::star::drawing::XCustomShapeHandle ) ) SAL_CALL getInteraction()
+ throw ( NMSP_UNO::RuntimeException );
+};
+
+rtl::OUString EnhancedCustomShapeEngine_getImplementationName()
+ throw ( NMSP_UNO::RuntimeException );
+sal_Bool SAL_CALL EnhancedCustomShapeEngine_supportsService( const rtl::OUString& rServiceName )
+ throw( NMSP_UNO::RuntimeException );
+SEQ( rtl::OUString ) SAL_CALL EnhancedCustomShapeEngine_getSupportedServiceNames()
+ throw( NMSP_UNO::RuntimeException );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
new file mode 100644
index 000000000000..dabe89d2ff42
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -0,0 +1,909 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "EnhancedCustomShapeFontWork.hxx"
+#include <tools/solar.h> // UINTXX
+#include <svx/svddef.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdopath.hxx>
+#include <vcl/metric.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/sdasitm.hxx>
+#include <svx/sdasaitm.hxx>
+#include <svx/sdtfsitm.hxx>
+#include <vcl/virdev.hxx>
+#include <svditer.hxx>
+#include <vcl/metric.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/charscaleitem.hxx>
+#include "EnhancedCustomShapeTypeNames.hxx"
+#include <svx/svdorect.hxx>
+#include <svx/svdoashp.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/editeng.hxx>
+#include <svx/svdmodel.hxx>
+#include <vector>
+#include <numeric>
+#include <algorithm>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/i18n/ScriptType.hdl>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/i18n/CharacterIteratorMode.hdl>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+typedef std::vector< std::vector< double > > PolyPolygonDistances;
+
+struct FWCharacterData // representing a single character
+{
+ std::vector< PolyPolygon > vOutlines;
+ Rectangle aBoundRect;
+};
+struct FWParagraphData // representing a single paragraph
+{
+ rtl::OUString aString;
+ std::vector< FWCharacterData > vCharacters;
+ Rectangle aBoundRect;
+ sal_Int16 nFrameDirection;
+};
+struct FWTextArea // representing multiple concluding paragraphs
+{
+ std::vector< FWParagraphData > vParagraphs;
+ Rectangle aBoundRect;
+};
+struct FWData // representing the whole text
+{
+ std::vector< FWTextArea > vTextAreas;
+ double fHorizontalTextScaling;
+ sal_uInt32 nMaxParagraphsPerTextArea;
+ sal_Int32 nSingleLineHeight;
+ sal_Bool bSingleLineMode;
+};
+
+
+sal_Bool InitializeFontWorkData( const SdrObject* pCustomShape, const sal_uInt16 nOutlinesCount2d, FWData& rFWData )
+{
+ sal_Bool bNoErr = sal_False;
+ sal_Bool bSingleLineMode = sal_False;
+ sal_uInt16 nTextAreaCount = nOutlinesCount2d;
+ if ( nOutlinesCount2d & 1 )
+ bSingleLineMode = sal_True;
+ else
+ nTextAreaCount >>= 1;
+
+ if ( nTextAreaCount )
+ {
+ rFWData.bSingleLineMode = bSingleLineMode;
+
+ // setting the strings
+ OutlinerParaObject* pParaObj = ((SdrObjCustomShape*)pCustomShape)->GetOutlinerParaObject();
+ if ( pParaObj )
+ {
+ const EditTextObject& rTextObj = pParaObj->GetTextObject();
+ sal_Int32 nParagraphsLeft = rTextObj.GetParagraphCount();
+
+ rFWData.nMaxParagraphsPerTextArea = ( ( nParagraphsLeft - 1 ) / nTextAreaCount ) + 1;
+ sal_Int16 j = 0;
+ while( nParagraphsLeft && nTextAreaCount )
+ {
+ FWTextArea aTextArea;
+ sal_Int32 i, nParagraphs = ( ( nParagraphsLeft - 1 ) / nTextAreaCount ) + 1;
+ for ( i = 0; i < nParagraphs; i++, j++ )
+ {
+ FWParagraphData aParagraphData;
+ aParagraphData.aString = rTextObj.GetText( j );
+
+ const SfxItemSet& rParaSet = rTextObj.GetParaAttribs( j ); // retrieving some paragraph attributes
+ aParagraphData.nFrameDirection = ((SvxFrameDirectionItem&)rParaSet.Get( EE_PARA_WRITINGDIR )).GetValue();
+ aTextArea.vParagraphs.push_back( aParagraphData );
+ }
+ rFWData.vTextAreas.push_back( aTextArea );
+ nParagraphsLeft -= nParagraphs;
+ nTextAreaCount--;
+ }
+ bNoErr = sal_True;
+ }
+ }
+ return bNoErr;
+}
+
+double GetLength( const Polygon& rPolygon )
+{
+ double fLength = 0;
+ if ( rPolygon.GetSize() > 1 )
+ {
+ sal_uInt16 nCount = rPolygon.GetSize();
+ while( --nCount )
+ fLength += ((Polygon&)rPolygon).CalcDistance( nCount, nCount - 1 );
+ }
+ return fLength;
+}
+
+
+/* CalculateHorizontalScalingFactor returns the horizontal scaling factor for
+the whole text object, so that each text will match its corresponding 2d Outline */
+void CalculateHorizontalScalingFactor( const SdrObject* pCustomShape,
+ FWData& rFWData, const PolyPolygon& rOutline2d )
+{
+ double fScalingFactor = 1.0;
+ sal_Bool bScalingFactorDefined = sal_False;
+
+ sal_uInt16 i = 0;
+ sal_Bool bSingleLineMode = sal_False;
+ sal_uInt16 nOutlinesCount2d = rOutline2d.Count();
+
+ Font aFont;
+ SvxFontItem& rFontItem = (SvxFontItem&)pCustomShape->GetMergedItem( EE_CHAR_FONTINFO );
+ aFont.SetHeight( pCustomShape->GetLogicRect().GetHeight() / rFWData.nMaxParagraphsPerTextArea );
+ aFont.SetAlign( ALIGN_TOP );
+ aFont.SetName( rFontItem.GetFamilyName() );
+ aFont.SetFamily( rFontItem.GetFamily() );
+ aFont.SetStyleName( rFontItem.GetStyleName() );
+ aFont.SetOrientation( 0 );
+ // initializing virtual device
+
+ VirtualDevice aVirDev( 1 );
+ aVirDev.SetMapMode( MAP_100TH_MM );
+ aVirDev.SetFont( aFont );
+
+ if ( nOutlinesCount2d & 1 )
+ bSingleLineMode = sal_True;
+
+ std::vector< FWTextArea >::iterator aTextAreaIter = rFWData.vTextAreas.begin();
+ std::vector< FWTextArea >::iterator aTextAreaIEnd = rFWData.vTextAreas.end();
+ while( aTextAreaIter != aTextAreaIEnd )
+ {
+ // calculating the width of the corresponding 2d text area
+ double fWidth = GetLength( rOutline2d.GetObject( i++ ) );
+ if ( !bSingleLineMode )
+ {
+ fWidth += GetLength( rOutline2d.GetObject( i++ ) );
+ fWidth /= 2.0;
+ }
+ std::vector< FWParagraphData >::const_iterator aParagraphIter( aTextAreaIter->vParagraphs.begin() );
+ std::vector< FWParagraphData >::const_iterator aParagraphIEnd( aTextAreaIter->vParagraphs.end() );
+ while( aParagraphIter != aParagraphIEnd )
+ {
+ double fTextWidth = aVirDev.GetTextWidth( aParagraphIter->aString );
+ if ( fTextWidth > 0.0 )
+ {
+ double fScale = fWidth / fTextWidth;
+ if ( !bScalingFactorDefined )
+ {
+ fScalingFactor = fScale;
+ bScalingFactorDefined = sal_True;
+ }
+ else
+ {
+ if ( fScale < fScalingFactor )
+ fScalingFactor = fScale;
+ }
+ }
+ aParagraphIter++;
+ }
+ aTextAreaIter++;
+ }
+ rFWData.fHorizontalTextScaling = fScalingFactor;
+}
+
+void GetTextAreaOutline( const FWData& rFWData, const SdrObject* pCustomShape, FWTextArea& rTextArea, sal_Bool bSameLetterHeights )
+{
+ sal_Bool bIsVertical = ((SdrObjCustomShape*)pCustomShape)->IsVerticalWriting();
+ sal_Int32 nVerticalOffset = rFWData.nMaxParagraphsPerTextArea > rTextArea.vParagraphs.size()
+ ? rFWData.nSingleLineHeight / 2 : 0;
+
+ std::vector< FWParagraphData >::iterator aParagraphIter( rTextArea.vParagraphs.begin() );
+ std::vector< FWParagraphData >::iterator aParagraphIEnd( rTextArea.vParagraphs.end() );
+ while( aParagraphIter != aParagraphIEnd )
+ {
+ const rtl::OUString& rText = aParagraphIter->aString;
+ if ( rText.getLength() )
+ {
+ // generating vcl/font
+ USHORT nScriptType = i18n::ScriptType::LATIN;
+ Reference< i18n::XBreakIterator > xBI( EnhancedCustomShapeFontWork::GetBreakIterator() );
+ if ( xBI.is() )
+ {
+ nScriptType = xBI->getScriptType( rText, 0 );
+ sal_uInt16 nChg = 0;
+ if( i18n::ScriptType::WEAK == nScriptType )
+ {
+ nChg = (xub_StrLen)xBI->endOfScript( rText, nChg, nScriptType );
+ if( nChg < rText.getLength() )
+ nScriptType = xBI->getScriptType( rText, nChg );
+ else
+ nScriptType = i18n::ScriptType::LATIN;
+ }
+ }
+ UINT16 nFntItm = EE_CHAR_FONTINFO;
+ if ( nScriptType == i18n::ScriptType::COMPLEX )
+ nFntItm = EE_CHAR_FONTINFO_CTL;
+ else if ( nScriptType == i18n::ScriptType::ASIAN )
+ nFntItm = EE_CHAR_FONTINFO_CJK;
+ SvxFontItem& rFontItem = (SvxFontItem&)pCustomShape->GetMergedItem( nFntItm );
+ Font aFont;
+ aFont.SetHeight( rFWData.nSingleLineHeight );
+ aFont.SetAlign( ALIGN_TOP );
+ // aFont.SetAlign( )
+
+ aFont.SetName( rFontItem.GetFamilyName() );
+ aFont.SetFamily( rFontItem.GetFamily() );
+ aFont.SetStyleName( rFontItem.GetStyleName() );
+ aFont.SetOrientation( 0 );
+
+ SvxPostureItem& rPostureItem = (SvxPostureItem&)pCustomShape->GetMergedItem( EE_CHAR_ITALIC );
+ aFont.SetItalic( rPostureItem.GetPosture() );
+
+ SvxWeightItem& rWeightItem = (SvxWeightItem&)pCustomShape->GetMergedItem( EE_CHAR_WEIGHT );
+ aFont.SetWeight( rWeightItem.GetWeight() );
+
+ // initializing virtual device
+ VirtualDevice aVirDev( 1 );
+ aVirDev.SetMapMode( MAP_100TH_MM );
+ aVirDev.SetFont( aFont );
+ aVirDev.EnableRTL( sal_True );
+ if ( aParagraphIter->nFrameDirection == FRMDIR_HORI_RIGHT_TOP )
+ aVirDev.SetLayoutMode( TEXT_LAYOUT_BIDI_RTL );
+
+ SvxCharScaleWidthItem& rCharScaleWidthItem = (SvxCharScaleWidthItem&)pCustomShape->GetMergedItem( EE_CHAR_FONTWIDTH );
+ sal_uInt16 nCharScaleWidth = rCharScaleWidthItem.GetValue();
+ sal_Int32* pDXArry = NULL;
+ sal_Int32 nWidth = 0;
+
+ // VERTICAL
+ if ( bIsVertical )
+ {
+ // vertical _> each single character needs to be rotated by 90
+ sal_Int32 i;
+ sal_Int32 nHeight = 0;
+ Rectangle aSingleCharacterUnion;
+ for ( i = 0; i < rText.getLength(); i++ )
+ {
+ FWCharacterData aCharacterData;
+ rtl::OUString aCharText( (sal_Unicode)rText[ i ] );
+ if ( aVirDev.GetTextOutlines( aCharacterData.vOutlines, aCharText, 0, 0, STRING_LEN, TRUE, nWidth, pDXArry ) )
+ {
+ sal_Int32 nTextWidth = aVirDev.GetTextWidth( aCharText, 0, STRING_LEN );
+ std::vector< PolyPolygon >::iterator aOutlineIter = aCharacterData.vOutlines.begin();
+ std::vector< PolyPolygon >::iterator aOutlineIEnd = aCharacterData.vOutlines.end();
+ if ( aOutlineIter == aOutlineIEnd )
+ {
+ nHeight += rFWData.nSingleLineHeight;
+ }
+ else
+ {
+ while ( aOutlineIter != aOutlineIEnd )
+ {
+ // rotating
+ aOutlineIter->Rotate( Point( nTextWidth / 2, rFWData.nSingleLineHeight / 2 ), 900 );
+ aCharacterData.aBoundRect.Union( aOutlineIter->GetBoundRect() );
+ aOutlineIter++;
+ }
+ aOutlineIter = aCharacterData.vOutlines.begin();
+ aOutlineIEnd = aCharacterData.vOutlines.end();
+ while ( aOutlineIter != aOutlineIEnd )
+ {
+ sal_Int32 nM = - aCharacterData.aBoundRect.Left() + nHeight;
+ aOutlineIter->Move( nM, 0 );
+ aCharacterData.aBoundRect.Move( nM, 0 );
+ aOutlineIter++;
+ }
+ nHeight += aCharacterData.aBoundRect.GetWidth() + ( rFWData.nSingleLineHeight / 5 );
+ aSingleCharacterUnion.Union( aCharacterData.aBoundRect );
+ }
+ }
+ aParagraphIter->vCharacters.push_back( aCharacterData );
+ }
+ std::vector< FWCharacterData >::iterator aCharacterIter( aParagraphIter->vCharacters.begin() );
+ std::vector< FWCharacterData >::iterator aCharacterIEnd( aParagraphIter->vCharacters.end() );
+ while ( aCharacterIter != aCharacterIEnd )
+ {
+ std::vector< PolyPolygon >::iterator aOutlineIter( aCharacterIter->vOutlines.begin() );
+ std::vector< PolyPolygon >::iterator aOutlineIEnd( aCharacterIter->vOutlines.end() );
+ while ( aOutlineIter != aOutlineIEnd )
+ {
+ aOutlineIter->Move( ( aSingleCharacterUnion.GetWidth() - aCharacterIter->aBoundRect.GetWidth() ) / 2, 0 );
+ aOutlineIter++;
+ }
+ aCharacterIter++;
+ }
+ }
+ else
+ {
+ if ( ( nCharScaleWidth != 100 ) && nCharScaleWidth )
+ { // applying character spacing
+ pDXArry = new sal_Int32[ rText.getLength() ];
+ aVirDev.GetTextArray( rText, pDXArry, 0, STRING_LEN );
+ FontMetric aFontMetric( aVirDev.GetFontMetric() );
+ aFont.SetWidth( (sal_Int32)( (double)aFontMetric.GetWidth() * ( (double)100 / (double)nCharScaleWidth ) ) );
+ aVirDev.SetFont( aFont );
+ }
+ FWCharacterData aCharacterData;
+ if ( aVirDev.GetTextOutlines( aCharacterData.vOutlines, rText, 0, 0, STRING_LEN, TRUE, nWidth, pDXArry ) )
+ {
+ aParagraphIter->vCharacters.push_back( aCharacterData );
+ }
+
+/* trying to retrieve each single character _> is not working well
+ sal_Int32 i;
+ for ( i = 0; i < rText.getLength(); i++ )
+ {
+ FWCharacterData aCharacterData;
+ if ( aVirDev.GetTextOutlines( aCharacterData.vOutlines, rText, 0, i, 1, TRUE, nWidth, pDXArry ) )
+ {
+ std::vector< PolyPolygon >::iterator aOutlineIter = aCharacterData.vOutlines.begin();
+ std::vector< PolyPolygon >::iterator aOutlineIEnd = aCharacterData.vOutlines.end();
+ while ( aOutlineIter != aOutlineIEnd )
+ {
+ aCharacterData.aBoundRect.Union( aOutlineIter->GetBoundRect() );
+ aOutlineIter++;
+ }
+ }
+ aParagraphIter->vCharacters.push_back( aCharacterData );
+ }
+*/
+ }
+ delete[] pDXArry;
+
+ // veritcal alignment
+ std::vector< FWCharacterData >::iterator aCharacterIter( aParagraphIter->vCharacters.begin() );
+ std::vector< FWCharacterData >::iterator aCharacterIEnd ( aParagraphIter->vCharacters.end() );
+ while ( aCharacterIter != aCharacterIEnd )
+ {
+ std::vector< PolyPolygon >::iterator aOutlineIter( aCharacterIter->vOutlines.begin() );
+ std::vector< PolyPolygon >::iterator aOutlineIEnd( aCharacterIter->vOutlines.end() );
+ while( aOutlineIter != aOutlineIEnd )
+ {
+
+ PolyPolygon& rPolyPoly = *aOutlineIter++;
+
+ if ( nVerticalOffset )
+ rPolyPoly.Move( 0, nVerticalOffset );
+
+ // retrieving the boundrect for the paragraph
+ Rectangle aBoundRect( rPolyPoly.GetBoundRect() );
+ aParagraphIter->aBoundRect.Union( aBoundRect );
+ }
+ aCharacterIter++;
+ }
+ }
+ // updating the boundrect for the text area by merging the current paragraph boundrect
+ if ( aParagraphIter->aBoundRect.IsEmpty() )
+ {
+ if ( rTextArea.aBoundRect.IsEmpty() )
+ rTextArea.aBoundRect = Rectangle( Point( 0, 0 ), Size( 1, rFWData.nSingleLineHeight ) );
+ else
+ rTextArea.aBoundRect.Bottom() += rFWData.nSingleLineHeight;
+ }
+ else
+ {
+ Rectangle& rParagraphBoundRect = aParagraphIter->aBoundRect;
+ rTextArea.aBoundRect.Union( rParagraphBoundRect );
+
+ if ( bSameLetterHeights )
+ {
+ std::vector< FWCharacterData >::iterator aCharacterIter( aParagraphIter->vCharacters.begin() );
+ std::vector< FWCharacterData >::iterator aCharacterIEnd( aParagraphIter->vCharacters.end() );
+ while ( aCharacterIter != aCharacterIEnd )
+ {
+ std::vector< PolyPolygon >::iterator aOutlineIter( aCharacterIter->vOutlines.begin() );
+ std::vector< PolyPolygon >::iterator aOutlineIEnd( aCharacterIter->vOutlines.end() );
+ while( aOutlineIter != aOutlineIEnd )
+ {
+ Rectangle aPolyPolyBoundRect( aOutlineIter->GetBoundRect() );
+ if ( aPolyPolyBoundRect.GetHeight() != rParagraphBoundRect.GetHeight() )
+ aOutlineIter->Scale( 1.0, (double)rParagraphBoundRect.GetHeight() / aPolyPolyBoundRect.GetHeight() );
+ aPolyPolyBoundRect = aOutlineIter->GetBoundRect();
+ sal_Int32 nMove = aPolyPolyBoundRect.Top() - rParagraphBoundRect.Top();
+ if ( nMove )
+ aOutlineIter->Move( 0, -nMove );
+ aOutlineIter++;
+ }
+ aCharacterIter++;
+ }
+ }
+ }
+ if ( bIsVertical )
+ nVerticalOffset -= rFWData.nSingleLineHeight;
+ else
+ nVerticalOffset += rFWData.nSingleLineHeight;
+ aParagraphIter++;
+ }
+}
+
+void GetFontWorkOutline( FWData& rFWData, const SdrObject* pCustomShape )
+{
+ SdrTextHorzAdjust eHorzAdjust( ((SdrTextHorzAdjustItem&)pCustomShape->GetMergedItem( SDRATTR_TEXT_HORZADJUST )).GetValue() );
+ SdrFitToSizeType eFTS( ((SdrTextFitToSizeTypeItem&)pCustomShape->GetMergedItem( SDRATTR_TEXT_FITTOSIZE )).GetValue() );
+
+ std::vector< FWTextArea >::iterator aTextAreaIter = rFWData.vTextAreas.begin();
+ std::vector< FWTextArea >::iterator aTextAreaIEnd = rFWData.vTextAreas.end();
+
+ rFWData.nSingleLineHeight = (sal_Int32)( ( (double)pCustomShape->GetLogicRect().GetHeight()
+ / rFWData.nMaxParagraphsPerTextArea ) * rFWData.fHorizontalTextScaling );
+
+ sal_Bool bSameLetterHeights = sal_False;
+ SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
+ const rtl::OUString sSameLetterHeights( RTL_CONSTASCII_USTRINGPARAM ( "SameLetterHeights" ) );
+ com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sSameLetterHeights );
+ if ( pAny )
+ *pAny >>= bSameLetterHeights;
+
+ while ( aTextAreaIter != aTextAreaIEnd )
+ {
+ GetTextAreaOutline( rFWData, pCustomShape, *aTextAreaIter, bSameLetterHeights );
+ if ( eFTS == SDRTEXTFIT_ALLLINES )
+ {
+ std::vector< FWParagraphData >::iterator aParagraphIter( aTextAreaIter->vParagraphs.begin() );
+ std::vector< FWParagraphData >::iterator aParagraphIEnd( aTextAreaIter->vParagraphs.end() );
+ while ( aParagraphIter != aParagraphIEnd )
+ {
+ sal_Int32 nParaWidth = aParagraphIter->aBoundRect.GetWidth();
+ if ( nParaWidth )
+ {
+ double fScale = (double)aTextAreaIter->aBoundRect.GetWidth() / nParaWidth;
+
+ std::vector< FWCharacterData >::iterator aCharacterIter( aParagraphIter->vCharacters.begin() );
+ std::vector< FWCharacterData >::iterator aCharacterIEnd( aParagraphIter->vCharacters.end() );
+ while ( aCharacterIter != aCharacterIEnd )
+ {
+ std::vector< PolyPolygon >::iterator aOutlineIter = aCharacterIter->vOutlines.begin();
+ std::vector< PolyPolygon >::iterator aOutlineIEnd = aCharacterIter->vOutlines.end();
+ while( aOutlineIter != aOutlineIEnd )
+ {
+ aOutlineIter->Scale( fScale, 1.0 );
+ aOutlineIter++;
+ }
+ aCharacterIter++;
+ }
+ }
+ aParagraphIter++;
+ }
+ }
+ else
+ {
+ switch( eHorzAdjust )
+ {
+ case SDRTEXTHORZADJUST_RIGHT :
+ case SDRTEXTHORZADJUST_CENTER:
+ {
+ std::vector< FWParagraphData >::iterator aParagraphIter( aTextAreaIter->vParagraphs.begin() );
+ std::vector< FWParagraphData >::iterator aParagraphIEnd( aTextAreaIter->vParagraphs.end() );
+ while ( aParagraphIter != aParagraphIEnd )
+ {
+ sal_Int32 nHorzDiff = 0;
+ if ( eHorzAdjust == SDRTEXTHORZADJUST_CENTER )
+ nHorzDiff = ( aTextAreaIter->aBoundRect.GetWidth() - aParagraphIter->aBoundRect.GetWidth() ) / 2;
+ else if ( eHorzAdjust == SDRTEXTHORZADJUST_RIGHT )
+ nHorzDiff = ( aTextAreaIter->aBoundRect.GetWidth() - aParagraphIter->aBoundRect.GetWidth() );
+ if ( nHorzDiff )
+ {
+ std::vector< FWCharacterData >::iterator aCharacterIter( aParagraphIter->vCharacters.begin() );
+ std::vector< FWCharacterData >::iterator aCharacterIEnd( aParagraphIter->vCharacters.end() );
+ while ( aCharacterIter != aCharacterIEnd )
+ {
+ std::vector< PolyPolygon >::iterator aOutlineIter = aCharacterIter->vOutlines.begin();
+ std::vector< PolyPolygon >::iterator aOutlineIEnd = aCharacterIter->vOutlines.end();
+ while( aOutlineIter != aOutlineIEnd )
+ {
+ aOutlineIter->Move( nHorzDiff, 0 );
+ aOutlineIter++;
+ }
+ aCharacterIter++;
+ }
+ }
+ aParagraphIter++;
+ }
+ }
+ break;
+ default:
+ case SDRTEXTHORZADJUST_BLOCK : break; // don't know
+ case SDRTEXTHORZADJUST_LEFT : break; // already left aligned -> nothing to do
+ }
+ }
+ aTextAreaIter++;
+ }
+}
+
+basegfx::B2DPolyPolygon GetOutlinesFromShape2d( const SdrObject* pShape2d )
+{
+ basegfx::B2DPolyPolygon aOutlines2d;
+
+ SdrObjListIter aObjListIter( *pShape2d, IM_DEEPWITHGROUPS );
+ while( aObjListIter.IsMore() )
+ {
+ SdrObject* pPartObj = aObjListIter.Next();
+ if ( pPartObj->ISA( SdrPathObj ) )
+ {
+ basegfx::B2DPolyPolygon aCandidate(((SdrPathObj*)pPartObj)->GetPathPoly());
+ if(aCandidate.areControlPointsUsed())
+ {
+ aCandidate = basegfx::tools::adaptiveSubdivideByAngle(aCandidate);
+ }
+ aOutlines2d.append(aCandidate);
+ }
+ }
+
+ return aOutlines2d;
+}
+
+void CalcDistances( const Polygon& rPoly, std::vector< double >& rDistances )
+{
+ sal_uInt16 i, nCount = rPoly.GetSize();
+ if ( nCount > 1 )
+ {
+ for ( i = 0; i < nCount; i++ )
+ {
+ double fDistance = i ? ((Polygon&)rPoly).CalcDistance( i, i - 1 ) : 0.0;
+ rDistances.push_back( fDistance );
+ }
+ std::partial_sum( rDistances.begin(), rDistances.end(), rDistances.begin() );
+ double fLength = rDistances[ rDistances.size() - 1 ];
+ if ( fLength > 0.0 )
+ {
+ std::vector< double >::iterator aIter = rDistances.begin();
+ std::vector< double >::iterator aEnd = rDistances.end();
+ while ( aIter != aEnd )
+ *aIter++ /= fLength;
+ }
+ }
+}
+
+void InsertMissingOutlinePoints( const Polygon& /*rOutlinePoly*/, const std::vector< double >& rDistances, const Rectangle& rTextAreaBoundRect, Polygon& rPoly )
+{
+ sal_uInt16 i = 0;
+ double fLastDistance = 0.0;
+ for ( i = 0; i < rPoly.GetSize(); i++ )
+ {
+ Point& rPoint = rPoly[ i ];
+ double fDistance = (double)( rPoint.X() - rTextAreaBoundRect.Left() ) / (double)rTextAreaBoundRect.GetWidth();
+ if ( i )
+ {
+ if ( fDistance > fLastDistance )
+ {
+ std::vector< double >::const_iterator aIter = std::upper_bound( rDistances.begin(), rDistances.end(), fLastDistance );
+ if ( aIter != rDistances.end() && ( *aIter > fLastDistance ) && ( *aIter < fDistance ) )
+ {
+ Point& rPt0 = rPoly[ i - 1 ];
+ sal_Int32 fX = rPoint.X() - rPt0.X();
+ sal_Int32 fY = rPoint.Y() - rPt0.Y();
+ double fd = ( 1.0 / ( fDistance - fLastDistance ) ) * ( *aIter - fLastDistance );
+ rPoly.Insert( i, Point( (sal_Int32)( rPt0.X() + fX * fd ), (sal_Int32)( rPt0.Y() + fY * fd ) ) );
+ fDistance = *aIter;
+ }
+ }
+ else if ( fDistance < fLastDistance )
+ {
+ std::vector< double >::const_iterator aIter = std::lower_bound( rDistances.begin(), rDistances.end(), fLastDistance );
+ if ( aIter-- != rDistances.begin() )
+ {
+ if ( ( *aIter > fDistance ) && ( *aIter < fLastDistance ) )
+ {
+ Point& rPt0 = rPoly[ i - 1 ];
+ sal_Int32 fX = rPoint.X() - rPt0.X();
+ sal_Int32 fY = rPoint.Y() - rPt0.Y();
+ double fd = ( 1.0 / ( fDistance - fLastDistance ) ) * ( *aIter - fLastDistance );
+ rPoly.Insert( i, Point( (sal_Int32)( rPt0.X() + fX * fd ), (sal_Int32)( rPt0.Y() + fY * fd ) ) );
+ fDistance = *aIter;
+ }
+ }
+ }
+ }
+ fLastDistance = fDistance;
+ }
+}
+
+void GetPoint( const Polygon& rPoly, const std::vector< double >& rDistances, const double& fX, double& fx1, double& fy1 )
+{
+ fy1 = fx1 = 0.0;
+ if ( rPoly.GetSize() > 1 )
+ {
+ std::vector< double >::const_iterator aIter = std::lower_bound( rDistances.begin(), rDistances.end(), fX );
+ sal_uInt16 nIdx = sal::static_int_cast<sal_uInt16>( std::distance( rDistances.begin(), aIter ) );
+ if ( aIter == rDistances.end() )
+ nIdx--;
+ const Point& rPt = rPoly[ nIdx ];
+ fx1 = rPt.X();
+ fy1 = rPt.Y();
+ if ( nIdx && ( aIter != rDistances.end() ) && ( *aIter != fX ) )
+ {
+ nIdx = sal::static_int_cast<sal_uInt16>( std::distance( rDistances.begin(), aIter ) );
+ double fDist0 = *( aIter - 1 );
+ double fd = ( 1.0 / ( *aIter - fDist0 ) ) * ( fX - fDist0 );
+ const Point& rPt2 = rPoly[ nIdx - 1 ];
+ double fWidth = rPt.X() - rPt2.X();
+ double fHeight= rPt.Y() - rPt2.Y();
+ fWidth *= fd;
+ fHeight*= fd;
+ fx1 = rPt2.X() + fWidth;
+ fy1 = rPt2.Y() + fHeight;
+ }
+ }
+}
+
+void FitTextOutlinesToShapeOutlines( const PolyPolygon& aOutlines2d, FWData& rFWData )
+{
+ std::vector< FWTextArea >::iterator aTextAreaIter = rFWData.vTextAreas.begin();
+ std::vector< FWTextArea >::iterator aTextAreaIEnd = rFWData.vTextAreas.end();
+
+ sal_uInt16 nOutline2dIdx = 0;
+ while( aTextAreaIter != aTextAreaIEnd )
+ {
+ Rectangle rTextAreaBoundRect = aTextAreaIter->aBoundRect;
+ sal_Int32 nLeft = rTextAreaBoundRect.Left();
+ sal_Int32 nTop = rTextAreaBoundRect.Top();
+ sal_Int32 nWidth = rTextAreaBoundRect.GetWidth();
+ sal_Int32 nHeight= rTextAreaBoundRect.GetHeight();
+ if ( rFWData.bSingleLineMode && nHeight && nWidth )
+ {
+ if ( nOutline2dIdx >= aOutlines2d.Count() )
+ break;
+ const Polygon& rOutlinePoly( aOutlines2d[ nOutline2dIdx++ ] );
+ const sal_uInt16 nPointCount = rOutlinePoly.GetSize();
+ if ( nPointCount > 1 )
+ {
+ std::vector< double > vDistances;
+ vDistances.reserve( nPointCount );
+ CalcDistances( rOutlinePoly, vDistances );
+ if ( vDistances.size() )
+ {
+ std::vector< FWParagraphData >::iterator aParagraphIter( aTextAreaIter->vParagraphs.begin() );
+ std::vector< FWParagraphData >::iterator aParagraphIEnd( aTextAreaIter->vParagraphs.end() );
+ while( aParagraphIter != aParagraphIEnd )
+ {
+ std::vector< FWCharacterData >::iterator aCharacterIter( aParagraphIter->vCharacters.begin() );
+ std::vector< FWCharacterData >::iterator aCharacterIEnd( aParagraphIter->vCharacters.end() );
+ while ( aCharacterIter != aCharacterIEnd )
+ {
+ std::vector< PolyPolygon >::iterator aOutlineIter = aCharacterIter->vOutlines.begin();
+ std::vector< PolyPolygon >::iterator aOutlineIEnd = aCharacterIter->vOutlines.end();
+ while( aOutlineIter != aOutlineIEnd )
+ {
+ PolyPolygon& rPolyPoly = *aOutlineIter;
+ Rectangle aBoundRect( rPolyPoly.GetBoundRect() );
+ double fx1 = aBoundRect.Left() - nLeft;
+ double fx2 = aBoundRect.Right() - nLeft;
+ double fy1, fy2;
+ double fM1 = fx1 / (double)nWidth;
+ double fM2 = fx2 / (double)nWidth;
+
+ GetPoint( rOutlinePoly, vDistances, fM1, fx1, fy1 );
+ GetPoint( rOutlinePoly, vDistances, fM2, fx2, fy2 );
+
+ double fvx = ( fy2 - fy1 );
+ double fvy = - ( fx2 - fx1 );
+ fx1 = fx1 + ( ( fx2 - fx1 ) * 0.5 );
+ fy1 = fy1 + ( ( fy2 - fy1 ) * 0.5 );
+
+ double fAngle = atan2( -fvx, -fvy );
+ double fL = hypot( fvx, fvy );
+ fvx = fvx / fL;
+ fvy = fvy / fL;
+ fL = (double)( aTextAreaIter->aBoundRect.GetHeight() / 2.0 + aTextAreaIter->aBoundRect.Top() ) - aParagraphIter->aBoundRect.Center().Y();
+ fvx *= fL;
+ fvy *= fL;
+ rPolyPoly.Rotate( Point( aBoundRect.Center().X(), aParagraphIter->aBoundRect.Center().Y() ), sin( fAngle ), cos( fAngle ) );
+ rPolyPoly.Move( (sal_Int32)( ( fx1 + fvx )- aBoundRect.Center().X() ), (sal_Int32)( ( fy1 + fvy ) - aParagraphIter->aBoundRect.Center().Y() ) );
+
+ aOutlineIter++;
+ }
+ aCharacterIter++;
+ }
+ aParagraphIter++;
+ }
+ }
+ }
+ }
+ else
+ {
+ if ( ( nOutline2dIdx + 1 ) >= aOutlines2d.Count() )
+ break;
+ const Polygon& rOutlinePoly( aOutlines2d[ nOutline2dIdx++ ] );
+ const Polygon& rOutlinePoly2( aOutlines2d[ nOutline2dIdx++ ] );
+ const sal_uInt16 nPointCount = rOutlinePoly.GetSize();
+ const sal_uInt16 nPointCount2 = rOutlinePoly2.GetSize();
+ if ( ( nPointCount > 1 ) && ( nPointCount2 > 1 ) )
+ {
+ std::vector< double > vDistances;
+ vDistances.reserve( nPointCount );
+ std::vector< double > vDistances2;
+ vDistances2.reserve( nPointCount2 );
+ CalcDistances( rOutlinePoly, vDistances );
+ CalcDistances( rOutlinePoly2, vDistances2 );
+ std::vector< FWParagraphData >::iterator aParagraphIter = aTextAreaIter->vParagraphs.begin();
+ std::vector< FWParagraphData >::iterator aParagraphIEnd = aTextAreaIter->vParagraphs.end();
+ while( aParagraphIter != aParagraphIEnd )
+ {
+ std::vector< FWCharacterData >::iterator aCharacterIter( aParagraphIter->vCharacters.begin() );
+ std::vector< FWCharacterData >::iterator aCharacterIEnd( aParagraphIter->vCharacters.end() );
+ while ( aCharacterIter != aCharacterIEnd )
+ {
+ std::vector< PolyPolygon >::iterator aOutlineIter = aCharacterIter->vOutlines.begin();
+ std::vector< PolyPolygon >::iterator aOutlineIEnd = aCharacterIter->vOutlines.end();
+ while( aOutlineIter != aOutlineIEnd )
+ {
+ PolyPolygon& rPolyPoly = *aOutlineIter;
+ sal_uInt16 i, nPolyCount = rPolyPoly.Count();
+ for ( i = 0; i < nPolyCount; i++ )
+ {
+ // #i35928#
+ basegfx::B2DPolygon aCandidate(rPolyPoly[ i ].getB2DPolygon());
+
+ if(aCandidate.areControlPointsUsed())
+ {
+ aCandidate = basegfx::tools::adaptiveSubdivideByAngle(aCandidate);
+ }
+
+ // create local polygon copy to work on
+ Polygon aLocalPoly(aCandidate);
+
+ InsertMissingOutlinePoints( rOutlinePoly, vDistances, rTextAreaBoundRect, aLocalPoly );
+ InsertMissingOutlinePoints( rOutlinePoly2, vDistances2, rTextAreaBoundRect, aLocalPoly );
+
+ sal_uInt16 j, _nPointCount = aLocalPoly.GetSize();
+ for ( j = 0; j < _nPointCount; j++ )
+ {
+ Point& rPoint = aLocalPoly[ j ];
+ rPoint.X() -= nLeft;
+ rPoint.Y() -= nTop;
+ double fX = (double)rPoint.X() / (double)nWidth;
+ double fY = (double)rPoint.Y() / (double)nHeight;
+
+ double fx1, fy1, fx2, fy2;
+ GetPoint( rOutlinePoly, vDistances, fX, fx1, fy1 );
+ GetPoint( rOutlinePoly2, vDistances2, fX, fx2, fy2 );
+ double fWidth = fx2 - fx1;
+ double fHeight= fy2 - fy1;
+ rPoint.X() = (sal_Int32)( fx1 + fWidth * fY );
+ rPoint.Y() = (sal_Int32)( fy1 + fHeight* fY );
+ }
+
+ // write back polygon
+ rPolyPoly[ i ] = aLocalPoly;
+ }
+ aOutlineIter++;
+ }
+ aCharacterIter++;
+ }
+ aParagraphIter++;
+ }
+ }
+ }
+ aTextAreaIter++;
+ }
+}
+
+SdrObject* CreateSdrObjectFromParagraphOutlines( const FWData& rFWData, const SdrObject* pCustomShape )
+{
+ SdrObject* pRet = NULL;
+ if ( rFWData.vTextAreas.size() )
+ {
+ pRet = new SdrObjGroup();
+// SJ: not setting model, so we save a lot of broadcasting and the model is not modified any longer
+// pRet->SetModel( pCustomShape->GetModel() );
+ std::vector< FWTextArea >::const_iterator aTextAreaIter = rFWData.vTextAreas.begin();
+ std::vector< FWTextArea >::const_iterator aTextAreaIEnd = rFWData.vTextAreas.end();
+ while ( aTextAreaIter != aTextAreaIEnd )
+ {
+ std::vector< FWParagraphData >::const_iterator aParagraphIter = aTextAreaIter->vParagraphs.begin();
+ std::vector< FWParagraphData >::const_iterator aParagraphIEnd = aTextAreaIter->vParagraphs.end();
+ while ( aParagraphIter != aParagraphIEnd )
+ {
+ std::vector< FWCharacterData >::const_iterator aCharacterIter( aParagraphIter->vCharacters.begin() );
+ std::vector< FWCharacterData >::const_iterator aCharacterIEnd( aParagraphIter->vCharacters.end() );
+ while ( aCharacterIter != aCharacterIEnd )
+ {
+ std::vector< PolyPolygon >::const_iterator aOutlineIter = aCharacterIter->vOutlines.begin();
+ std::vector< PolyPolygon >::const_iterator aOutlineIEnd = aCharacterIter->vOutlines.end();
+ while( aOutlineIter != aOutlineIEnd )
+ {
+ SdrObject* pPathObj = new SdrPathObj( OBJ_POLY, aOutlineIter->getB2DPolyPolygon() );
+ // SJ: not setting model, so we save a lot of broadcasting and the model is not modified any longer
+ // pPathObj->SetModel( pCustomShape->GetModel() );
+ ((SdrObjGroup*)pRet)->GetSubList()->NbcInsertObject( pPathObj );
+ aOutlineIter++;
+ }
+ aCharacterIter++;
+ }
+ aParagraphIter++;
+ }
+ aTextAreaIter++;
+ }
+
+ Point aP( pCustomShape->GetSnapRect().Center() );
+ Size aS( pCustomShape->GetLogicRect().GetSize() );
+ aP.X() -= aS.Width() / 2;
+ aP.Y() -= aS.Height() / 2;
+ Rectangle aLogicRect( aP, aS );
+
+ SfxItemSet aSet( pCustomShape->GetMergedItemSet() );
+ aSet.ClearItem( SDRATTR_TEXTDIRECTION ); //SJ: vertical writing is not required, by removing this item no outliner is created
+ aSet.Put(SdrShadowItem(sal_False)); // #i37011# NO shadow for FontWork geometry
+ pRet->SetMergedItemSet( aSet ); // * otherwise we would crash, because the outliner tries to create a Paraobject, but there is no model
+ }
+ return pRet;
+}
+
+::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > EnhancedCustomShapeFontWork::mxBreakIterator = 0;
+
+Reference < i18n::XBreakIterator > EnhancedCustomShapeFontWork::GetBreakIterator()
+{
+ if ( !mxBreakIterator.is() )
+ {
+ Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ Reference < XInterface > xI = xMSF->createInstance( rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) );
+ if ( xI.is() )
+ {
+ Any x = xI->queryInterface( ::getCppuType((const Reference< i18n::XBreakIterator >*)0) );
+ x >>= mxBreakIterator;
+ }
+ }
+ return mxBreakIterator;
+}
+
+SdrObject* EnhancedCustomShapeFontWork::CreateFontWork( const SdrObject* pShape2d, const SdrObject* pCustomShape )
+{
+ SdrObject* pRet = NULL;
+
+ Rectangle aLogicRect( pCustomShape->GetLogicRect() );
+ PolyPolygon aOutlines2d( GetOutlinesFromShape2d( pShape2d ) );
+ sal_uInt16 nOutlinesCount2d = aOutlines2d.Count();
+ if ( nOutlinesCount2d )
+ {
+ FWData aFWData;
+ if ( InitializeFontWorkData( pCustomShape, nOutlinesCount2d, aFWData ) )
+ {
+ /* retrieves the horizontal scaling factor that has to be used
+ to fit each paragraph text into its corresponding 2d outline */
+ CalculateHorizontalScalingFactor( pCustomShape, aFWData, aOutlines2d );
+
+ /* retrieving the Outlines for the each Paragraph. */
+
+ GetFontWorkOutline( aFWData, pCustomShape );
+
+ FitTextOutlinesToShapeOutlines( aOutlines2d, aFWData );
+
+ pRet = CreateSdrObjectFromParagraphOutlines( aFWData, pCustomShape );
+ }
+ }
+ return pRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx
new file mode 100644
index 000000000000..4b3a90e0dcc1
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _ENHANCEDCUSTOMSHAPEFONTWORK_HXX
+#define _ENHANCEDCUSTOMSHAPEFONTWORK_HXX
+
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+
+class SdrObject;
+class EnhancedCustomShapeFontWork
+{
+ static ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > mxBreakIterator;
+
+ public :
+
+ static com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > GetBreakIterator();
+ static SdrObject* CreateFontWork( const SdrObject* pShape2d, const SdrObject* pCustomShape );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx b/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx
new file mode 100644
index 000000000000..3f079e3dc672
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeFunctionParser.cxx
@@ -0,0 +1,1214 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "EnhancedCustomShape2d.hxx"
+#include <rtl/ustring.hxx>
+#include <tools/fract.hxx>
+
+// Makes parser a static resource,
+// we're synchronized externally.
+// But watch out, the parser might have
+// state not visible to this code!
+
+#define BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE
+#if defined(VERBOSE) && defined(DBG_UTIL)
+#include <typeinfo>
+#define BOOST_SPIRIT_DEBUG
+#endif
+#include <boost/spirit/include/classic_core.hpp>
+
+#if (OSL_DEBUG_LEVEL > 0)
+#include <iostream>
+#endif
+#include <functional>
+#include <algorithm>
+#include <stack>
+
+#include <math.h> // fabs, sqrt, sin, cos, tan, atan, atan2
+using namespace EnhancedCustomShape;
+using namespace com::sun::star;
+using namespace com::sun::star::drawing;
+
+void EnhancedCustomShape::FillEquationParameter( const EnhancedCustomShapeParameter& rSource, const sal_Int32 nDestPara, EnhancedCustomShapeEquation& rDest )
+{
+ sal_Int32 nValue = 0;
+ if ( rSource.Value.getValueTypeClass() == uno::TypeClass_DOUBLE )
+ {
+ double fValue;
+ if ( rSource.Value >>= fValue )
+ nValue = (sal_Int32)fValue;
+ }
+ else
+ rSource.Value >>= nValue;
+
+ switch( rSource.Type )
+ {
+ case com::sun::star::drawing::EnhancedCustomShapeParameterType::EQUATION :
+ {
+ if ( nValue & 0x40000000 )
+ {
+ nValue ^= 0x40000000;
+ rDest.nOperation |= 0x20000000 << nDestPara; // the bit is indicating that this value has to be adjusted later
+ }
+ nValue |= 0x400;
+ }
+ break;
+ case com::sun::star::drawing::EnhancedCustomShapeParameterType::ADJUSTMENT : nValue += DFF_Prop_adjustValue; break;
+ case com::sun::star::drawing::EnhancedCustomShapeParameterType::BOTTOM : nValue = DFF_Prop_geoBottom; break;
+ case com::sun::star::drawing::EnhancedCustomShapeParameterType::RIGHT : nValue = DFF_Prop_geoRight; break;
+ case com::sun::star::drawing::EnhancedCustomShapeParameterType::TOP : nValue = DFF_Prop_geoTop; break;
+ case com::sun::star::drawing::EnhancedCustomShapeParameterType::LEFT : nValue = DFF_Prop_geoLeft; break;
+ }
+ if ( rSource.Type != com::sun::star::drawing::EnhancedCustomShapeParameterType::NORMAL )
+ rDest.nOperation |= ( 0x2000 << nDestPara );
+ rDest.nPara[ nDestPara ] = nValue;
+}
+
+ExpressionNode::~ExpressionNode()
+{}
+
+namespace
+{
+
+//////////////////////
+//////////////////////
+// EXPRESSION NODES
+//////////////////////
+//////////////////////
+class ConstantValueExpression : public ExpressionNode
+{
+ double maValue;
+
+public:
+
+ ConstantValueExpression( double rValue ) :
+ maValue( rValue )
+ {
+ }
+ virtual double operator()() const
+ {
+ return maValue;
+ }
+ virtual bool isConstant() const
+ {
+ return true;
+ }
+ virtual ExpressionFunct getType() const
+ {
+ return FUNC_CONST;
+ }
+ virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* /* pOptionalArg */, sal_uInt32 /* nFlags */ )
+ {
+ EnhancedCustomShapeParameter aRet;
+ Fraction aFract( maValue );
+ if ( aFract.GetDenominator() == 1 )
+ {
+ aRet.Type = EnhancedCustomShapeParameterType::NORMAL;
+ aRet.Value <<= (sal_Int32)aFract.GetNumerator();
+ }
+ else
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation = 1;
+ aEquation.nPara[ 0 ] = 1;
+ aEquation.nPara[ 1 ] = (sal_Int16)aFract.GetNumerator();
+ aEquation.nPara[ 2 ] = (sal_Int16)aFract.GetDenominator();
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ return aRet;
+ }
+};
+
+class AdjustmentExpression : public ExpressionNode
+{
+ sal_Int32 mnIndex;
+ const EnhancedCustomShape2d& mrCustoShape;
+
+public:
+
+ AdjustmentExpression( const EnhancedCustomShape2d& rCustoShape, sal_Int32 nIndex )
+ : mnIndex ( nIndex )
+ , mrCustoShape( rCustoShape )
+
+ {
+ }
+ virtual double operator()() const
+ {
+ return mrCustoShape.GetAdjustValueAsDouble( mnIndex );
+ }
+ virtual bool isConstant() const
+ {
+ return false;
+ }
+ virtual ExpressionFunct getType() const
+ {
+ return ENUM_FUNC_ADJUSTMENT;
+ }
+ virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& /*rEquations*/, ExpressionNode* /*pOptionalArg*/, sal_uInt32 /*nFlags*/ )
+ {
+ EnhancedCustomShapeParameter aRet;
+ aRet.Type = EnhancedCustomShapeParameterType::ADJUSTMENT;
+ aRet.Value <<= mnIndex;
+ return aRet;
+ }
+};
+
+class EquationExpression : public ExpressionNode
+{
+ sal_Int32 mnIndex;
+ const EnhancedCustomShape2d& mrCustoShape;
+
+public:
+
+ EquationExpression( const EnhancedCustomShape2d& rCustoShape, sal_Int32 nIndex )
+ : mnIndex ( nIndex )
+ , mrCustoShape( rCustoShape )
+ {
+ }
+ virtual double operator()() const
+ {
+ return mrCustoShape.GetEquationValueAsDouble( mnIndex );
+ }
+ virtual bool isConstant() const
+ {
+ return false;
+ }
+ virtual ExpressionFunct getType() const
+ {
+ return ENUM_FUNC_EQUATION;
+ }
+ virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& /*rEquations*/, ExpressionNode* /*pOptionalArg*/, sal_uInt32 /*nFlags*/ )
+ {
+ EnhancedCustomShapeParameter aRet;
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= mnIndex | 0x40000000; // the bit is indicating that this equation needs to be adjusted later
+ return aRet;
+ }
+};
+
+class EnumValueExpression : public ExpressionNode
+{
+ const ExpressionFunct meFunct;
+ const EnhancedCustomShape2d& mrCustoShape;
+
+public:
+
+ EnumValueExpression( const EnhancedCustomShape2d& rCustoShape, const ExpressionFunct eFunct )
+ : meFunct ( eFunct )
+ , mrCustoShape ( rCustoShape )
+ {
+ }
+ static double getValue( const EnhancedCustomShape2d& rCustoShape, const ExpressionFunct eFunc )
+ {
+ EnhancedCustomShape2d::EnumFunc eF;
+ switch( eFunc )
+ {
+ case ENUM_FUNC_PI : eF = EnhancedCustomShape2d::ENUM_FUNC_PI; break;
+ case ENUM_FUNC_LEFT : eF = EnhancedCustomShape2d::ENUM_FUNC_LEFT; break;
+ case ENUM_FUNC_TOP : eF = EnhancedCustomShape2d::ENUM_FUNC_TOP; break;
+ case ENUM_FUNC_RIGHT : eF = EnhancedCustomShape2d::ENUM_FUNC_RIGHT; break;
+ case ENUM_FUNC_BOTTOM : eF = EnhancedCustomShape2d::ENUM_FUNC_BOTTOM; break;
+ case ENUM_FUNC_XSTRETCH : eF = EnhancedCustomShape2d::ENUM_FUNC_XSTRETCH; break;
+ case ENUM_FUNC_YSTRETCH : eF = EnhancedCustomShape2d::ENUM_FUNC_YSTRETCH; break;
+ case ENUM_FUNC_HASSTROKE : eF = EnhancedCustomShape2d::ENUM_FUNC_HASSTROKE; break;
+ case ENUM_FUNC_HASFILL : eF = EnhancedCustomShape2d::ENUM_FUNC_HASFILL; break;
+ case ENUM_FUNC_WIDTH : eF = EnhancedCustomShape2d::ENUM_FUNC_WIDTH; break;
+ case ENUM_FUNC_HEIGHT : eF = EnhancedCustomShape2d::ENUM_FUNC_HEIGHT; break;
+ case ENUM_FUNC_LOGWIDTH : eF = EnhancedCustomShape2d::ENUM_FUNC_LOGWIDTH; break;
+ case ENUM_FUNC_LOGHEIGHT : eF = EnhancedCustomShape2d::ENUM_FUNC_LOGHEIGHT; break;
+
+ default :
+ return 0.0;
+ }
+ return rCustoShape.GetEnumFunc( eF );
+ }
+ virtual double operator()() const
+ {
+ return getValue( mrCustoShape, meFunct );
+ }
+ virtual bool isConstant() const
+ {
+ return false;
+ }
+ virtual ExpressionFunct getType() const
+ {
+ return meFunct;
+ }
+ virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* /*pOptionalArg*/, sal_uInt32 nFlags )
+ {
+ EnhancedCustomShapeParameter aRet;
+
+ sal_Int32 nDummy = 1;
+ aRet.Value <<= nDummy;
+
+ switch( meFunct )
+ {
+ case ENUM_FUNC_WIDTH : // TODO: do not use this as constant value
+ case ENUM_FUNC_HEIGHT :
+ case ENUM_FUNC_LOGWIDTH :
+ case ENUM_FUNC_LOGHEIGHT :
+ case ENUM_FUNC_PI :
+ {
+ ConstantValueExpression aConstantValue( getValue( mrCustoShape, meFunct ) );
+ aRet = aConstantValue.fillNode( rEquations, NULL, nFlags );
+ }
+ break;
+ case ENUM_FUNC_LEFT : aRet.Type = EnhancedCustomShapeParameterType::LEFT; break;
+ case ENUM_FUNC_TOP : aRet.Type = EnhancedCustomShapeParameterType::TOP; break;
+ case ENUM_FUNC_RIGHT : aRet.Type = EnhancedCustomShapeParameterType::RIGHT; break;
+ case ENUM_FUNC_BOTTOM : aRet.Type = EnhancedCustomShapeParameterType::BOTTOM; break;
+
+ // not implemented so far
+ case ENUM_FUNC_XSTRETCH :
+ case ENUM_FUNC_YSTRETCH :
+ case ENUM_FUNC_HASSTROKE :
+ case ENUM_FUNC_HASFILL : aRet.Type = EnhancedCustomShapeParameterType::NORMAL; break;
+
+ default:
+ break;
+ }
+ return aRet;
+ }
+};
+
+/** ExpressionNode implementation for unary
+ function over one ExpressionNode
+ */
+class UnaryFunctionExpression : public ExpressionNode
+{
+ const ExpressionFunct meFunct;
+ ExpressionNodeSharedPtr mpArg;
+
+public:
+ UnaryFunctionExpression( const ExpressionFunct eFunct, const ExpressionNodeSharedPtr& rArg ) :
+ meFunct( eFunct ),
+ mpArg( rArg )
+ {
+ }
+ static double getValue( const ExpressionFunct eFunct, const ExpressionNodeSharedPtr& rArg )
+ {
+ double fRet = 0;
+ switch( eFunct )
+ {
+ case UNARY_FUNC_ABS : fRet = fabs( (*rArg)() ); break;
+ case UNARY_FUNC_SQRT: fRet = sqrt( (*rArg)() ); break;
+ case UNARY_FUNC_SIN : fRet = sin( (*rArg)() ); break;
+ case UNARY_FUNC_COS : fRet = cos( (*rArg)() ); break;
+ case UNARY_FUNC_TAN : fRet = tan( (*rArg)() ); break;
+ case UNARY_FUNC_ATAN: fRet = atan( (*rArg)() ); break;
+ case UNARY_FUNC_NEG : fRet = ::std::negate<double>()( (*rArg)() ); break;
+ default:
+ break;
+ }
+ return fRet;
+ }
+ virtual double operator()() const
+ {
+ return getValue( meFunct, mpArg );
+ }
+ virtual bool isConstant() const
+ {
+ return mpArg->isConstant();
+ }
+ virtual ExpressionFunct getType() const
+ {
+ return meFunct;
+ }
+ virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* pOptionalArg, sal_uInt32 nFlags )
+ {
+ EnhancedCustomShapeParameter aRet;
+ switch( meFunct )
+ {
+ case UNARY_FUNC_ABS :
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 3;
+ FillEquationParameter( mpArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ case UNARY_FUNC_SQRT:
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 13;
+ FillEquationParameter( mpArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ case UNARY_FUNC_SIN :
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 9;
+ if ( pOptionalArg )
+ FillEquationParameter( pOptionalArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ else
+ aEquation.nPara[ 0 ] = 1;
+
+ EnhancedCustomShapeParameter aSource( mpArg->fillNode( rEquations, NULL, nFlags | EXPRESSION_FLAG_SUMANGLE_MODE ) );
+ if ( aSource.Type == EnhancedCustomShapeParameterType::NORMAL )
+ { // sumangle needed :-(
+ EnhancedCustomShapeEquation _aEquation;
+ _aEquation.nOperation |= 0xe; // sumangle
+ FillEquationParameter( aSource, 1, _aEquation );
+ aSource.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aSource.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( _aEquation );
+ }
+ FillEquationParameter( aSource, 1, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ case UNARY_FUNC_COS :
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 10;
+ if ( pOptionalArg )
+ FillEquationParameter( pOptionalArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ else
+ aEquation.nPara[ 0 ] = 1;
+
+ EnhancedCustomShapeParameter aSource( mpArg->fillNode( rEquations, NULL, nFlags | EXPRESSION_FLAG_SUMANGLE_MODE ) );
+ if ( aSource.Type == EnhancedCustomShapeParameterType::NORMAL )
+ { // sumangle needed :-(
+ EnhancedCustomShapeEquation aTmpEquation;
+ aTmpEquation.nOperation |= 0xe; // sumangle
+ FillEquationParameter( aSource, 1, aTmpEquation );
+ aSource.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aSource.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aTmpEquation );
+ }
+ FillEquationParameter( aSource, 1, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ case UNARY_FUNC_TAN :
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 16;
+ if ( pOptionalArg )
+ FillEquationParameter( pOptionalArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ else
+ aEquation.nPara[ 0 ] = 1;
+
+ EnhancedCustomShapeParameter aSource( mpArg->fillNode( rEquations, NULL, nFlags | EXPRESSION_FLAG_SUMANGLE_MODE ) );
+ if ( aSource.Type == EnhancedCustomShapeParameterType::NORMAL )
+ { // sumangle needed :-(
+ EnhancedCustomShapeEquation aTmpEquation;
+ aTmpEquation.nOperation |= 0xe; // sumangle
+ FillEquationParameter( aSource, 1, aTmpEquation );
+ aSource.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aSource.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aTmpEquation );
+ }
+ FillEquationParameter( aSource, 1, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ case UNARY_FUNC_ATAN:
+ {
+// TODO:
+ aRet.Type = EnhancedCustomShapeParameterType::NORMAL;
+ }
+ break;
+ case UNARY_FUNC_NEG:
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 1;
+ aEquation.nPara[ 1 ] = -1;
+ aEquation.nPara[ 2 ] = 1;
+ FillEquationParameter( mpArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ default:
+ break;
+ }
+ return aRet;
+ }
+};
+
+/** ExpressionNode implementation for unary
+ function over two ExpressionNodes
+ */
+class BinaryFunctionExpression : public ExpressionNode
+{
+ const ExpressionFunct meFunct;
+ ExpressionNodeSharedPtr mpFirstArg;
+ ExpressionNodeSharedPtr mpSecondArg;
+
+public:
+
+ BinaryFunctionExpression( const ExpressionFunct eFunct, const ExpressionNodeSharedPtr& rFirstArg, const ExpressionNodeSharedPtr& rSecondArg ) :
+ meFunct( eFunct ),
+ mpFirstArg( rFirstArg ),
+ mpSecondArg( rSecondArg )
+ {
+ }
+ static double getValue( const ExpressionFunct eFunct, const ExpressionNodeSharedPtr& rFirstArg, const ExpressionNodeSharedPtr& rSecondArg )
+ {
+ double fRet = 0;
+ switch( eFunct )
+ {
+ case BINARY_FUNC_PLUS : fRet = (*rFirstArg)() + (*rSecondArg)(); break;
+ case BINARY_FUNC_MINUS: fRet = (*rFirstArg)() - (*rSecondArg)(); break;
+ case BINARY_FUNC_MUL : fRet = (*rFirstArg)() * (*rSecondArg)(); break;
+ case BINARY_FUNC_DIV : fRet = (*rFirstArg)() / (*rSecondArg)(); break;
+ case BINARY_FUNC_MIN : fRet = ::std::min( (*rFirstArg)(), (*rSecondArg)() ); break;
+ case BINARY_FUNC_MAX : fRet = ::std::max( (*rFirstArg)(), (*rSecondArg)() ); break;
+ case BINARY_FUNC_ATAN2: fRet = atan2( (*rFirstArg)(), (*rSecondArg)() ); break;
+ default:
+ break;
+ }
+ return fRet;
+ }
+ virtual double operator()() const
+ {
+ return getValue( meFunct, mpFirstArg, mpSecondArg );
+ }
+ virtual bool isConstant() const
+ {
+ return mpFirstArg->isConstant() && mpSecondArg->isConstant();
+ }
+ virtual ExpressionFunct getType() const
+ {
+ return meFunct;
+ }
+ virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* /*pOptionalArg*/, sal_uInt32 nFlags )
+ {
+ EnhancedCustomShapeParameter aRet;
+ switch( meFunct )
+ {
+ case BINARY_FUNC_PLUS :
+ {
+ if ( nFlags & EXPRESSION_FLAG_SUMANGLE_MODE )
+ {
+ if ( mpFirstArg->getType() == ENUM_FUNC_ADJUSTMENT )
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 0xe; // sumangle
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags ), 1, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ else if ( mpSecondArg->getType() == ENUM_FUNC_ADJUSTMENT )
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 0xe; // sumangle
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags ), 1, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ else
+ {
+ EnhancedCustomShapeEquation aSumangle1;
+ aSumangle1.nOperation |= 0xe; // sumangle
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags &~EXPRESSION_FLAG_SUMANGLE_MODE ), 1, aSumangle1 );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aSumangle1 );
+
+ EnhancedCustomShapeEquation aSumangle2;
+ aSumangle2.nOperation |= 0xe; // sumangle
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags &~EXPRESSION_FLAG_SUMANGLE_MODE ), 1, aSumangle2 );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aSumangle2 );
+
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 0;
+ aEquation.nPara[ 0 ] = ( rEquations.size() - 2 ) | 0x400;
+ aEquation.nPara[ 1 ] = ( rEquations.size() - 1 ) | 0x400;
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ }
+ else
+ {
+ sal_Bool bFirstIsEmpty = mpFirstArg->isConstant() && ( (*mpFirstArg)() == 0 );
+ sal_Bool bSecondIsEmpty = mpSecondArg->isConstant() && ( (*mpSecondArg)() == 0 );
+
+ if ( bFirstIsEmpty )
+ aRet = mpSecondArg->fillNode( rEquations, NULL, nFlags );
+ else if ( bSecondIsEmpty )
+ aRet = mpFirstArg->fillNode( rEquations, NULL, nFlags );
+ else
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 0;
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags ), 1, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ }
+ }
+ break;
+ case BINARY_FUNC_MINUS:
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 0;
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags ), 2, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ case BINARY_FUNC_MUL :
+ {
+ // in the dest. format the cos function is using integer as result :-(
+ // so we can't use the generic algorithm
+ if ( ( mpFirstArg->getType() == UNARY_FUNC_SIN ) || ( mpFirstArg->getType() == UNARY_FUNC_COS ) || ( mpFirstArg->getType() == UNARY_FUNC_TAN ) )
+ aRet = mpFirstArg->fillNode( rEquations, mpSecondArg.get(), nFlags );
+ else if ( ( mpSecondArg->getType() == UNARY_FUNC_SIN ) || ( mpSecondArg->getType() == UNARY_FUNC_COS ) || ( mpSecondArg->getType() == UNARY_FUNC_TAN ) )
+ aRet = mpSecondArg->fillNode( rEquations, mpFirstArg.get(), nFlags );
+ else
+ {
+ if ( mpFirstArg->isConstant() && (*mpFirstArg)() == 1 )
+ aRet = mpSecondArg->fillNode( rEquations, NULL, nFlags );
+ else if ( mpSecondArg->isConstant() && (*mpSecondArg)() == 1 )
+ aRet = mpFirstArg->fillNode( rEquations, NULL, nFlags );
+ else if ( ( mpFirstArg->getType() == BINARY_FUNC_DIV ) // don't care of (pi/180)
+ && ( ((BinaryFunctionExpression*)((BinaryFunctionExpression*)mpFirstArg.get())->mpFirstArg.get())->getType() == ENUM_FUNC_PI )
+ && ( ((BinaryFunctionExpression*)((BinaryFunctionExpression*)mpFirstArg.get())->mpSecondArg.get())->getType() == FUNC_CONST ) )
+ {
+ aRet = mpSecondArg->fillNode( rEquations, NULL, nFlags );
+ }
+ else if ( ( mpSecondArg->getType() == BINARY_FUNC_DIV ) // don't care of (pi/180)
+ && ( ((BinaryFunctionExpression*)((BinaryFunctionExpression*)mpSecondArg.get())->mpFirstArg.get())->getType() == ENUM_FUNC_PI )
+ && ( ((BinaryFunctionExpression*)((BinaryFunctionExpression*)mpSecondArg.get())->mpSecondArg.get())->getType() == FUNC_CONST ) )
+ {
+ aRet = mpFirstArg->fillNode( rEquations, NULL, nFlags );
+ }
+ else
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 1;
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags ), 1, aEquation );
+ aEquation.nPara[ 2 ] = 1;
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ }
+ }
+ break;
+ case BINARY_FUNC_DIV :
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 1;
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ aEquation.nPara[ 1 ] = 1;
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags ), 2, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ case BINARY_FUNC_MIN :
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 4;
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags ), 1, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ case BINARY_FUNC_MAX :
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 5;
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags ), 1, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ case BINARY_FUNC_ATAN2:
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 8;
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags ), 1, aEquation );
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ rEquations.push_back( aEquation );
+ }
+ break;
+ default:
+ break;
+ }
+ return aRet;
+ }
+};
+
+class IfExpression : public ExpressionNode
+{
+ ExpressionNodeSharedPtr mpFirstArg;
+ ExpressionNodeSharedPtr mpSecondArg;
+ ExpressionNodeSharedPtr mpThirdArg;
+
+public:
+
+ IfExpression( const ExpressionNodeSharedPtr& rFirstArg,
+ const ExpressionNodeSharedPtr& rSecondArg,
+ const ExpressionNodeSharedPtr& rThirdArg ) :
+ mpFirstArg( rFirstArg ),
+ mpSecondArg( rSecondArg ),
+ mpThirdArg( rThirdArg )
+ {
+ }
+ virtual bool isConstant() const
+ {
+ return
+ mpFirstArg->isConstant() &&
+ mpSecondArg->isConstant() &&
+ mpThirdArg->isConstant();
+ }
+ virtual double operator()() const
+ {
+ return (*mpFirstArg)() > 0 ? (*mpSecondArg)() : (*mpThirdArg)();
+ }
+ virtual ExpressionFunct getType() const
+ {
+ return TERNARY_FUNC_IF;
+ }
+ virtual EnhancedCustomShapeParameter fillNode( std::vector< EnhancedCustomShapeEquation >& rEquations, ExpressionNode* /*pOptionalArg*/, sal_uInt32 nFlags )
+ {
+ EnhancedCustomShapeParameter aRet;
+ aRet.Type = EnhancedCustomShapeParameterType::EQUATION;
+ aRet.Value <<= (sal_Int32)rEquations.size();
+ {
+ EnhancedCustomShapeEquation aEquation;
+ aEquation.nOperation |= 6;
+ FillEquationParameter( mpFirstArg->fillNode( rEquations, NULL, nFlags ), 0, aEquation );
+ FillEquationParameter( mpSecondArg->fillNode( rEquations, NULL, nFlags ), 1, aEquation );
+ FillEquationParameter( mpThirdArg->fillNode( rEquations, NULL, nFlags ), 2, aEquation );
+ rEquations.push_back( aEquation );
+ }
+ return aRet;
+ }
+};
+
+////////////////////////
+////////////////////////
+// FUNCTION PARSER
+////////////////////////
+////////////////////////
+
+typedef const sal_Char* StringIteratorT;
+
+struct ParserContext
+{
+ typedef ::std::stack< ExpressionNodeSharedPtr > OperandStack;
+
+ // stores a stack of not-yet-evaluated operands. This is used
+ // by the operators (i.e. '+', '*', 'sin' etc.) to pop their
+ // arguments from. If all arguments to an operator are constant,
+ // the operator pushes a precalculated result on the stack, and
+ // a composite ExpressionNode otherwise.
+ OperandStack maOperandStack;
+
+ const EnhancedCustomShape2d* mpCustoShape;
+
+};
+
+typedef ::boost::shared_ptr< ParserContext > ParserContextSharedPtr;
+
+/** Generate apriori constant value
+ */
+
+class ConstantFunctor
+{
+ const double mnValue;
+ ParserContextSharedPtr mpContext;
+
+public:
+
+ ConstantFunctor( double rValue, const ParserContextSharedPtr& rContext ) :
+ mnValue( rValue ),
+ mpContext( rContext )
+ {
+ }
+ void operator()( StringIteratorT /*rFirst*/, StringIteratorT /*rSecond*/ ) const
+ {
+ mpContext->maOperandStack.push( ExpressionNodeSharedPtr( new ConstantValueExpression( mnValue ) ) );
+ }
+};
+
+/** Generate parse-dependent-but-then-constant value
+ */
+class DoubleConstantFunctor
+{
+ ParserContextSharedPtr mpContext;
+
+public:
+ DoubleConstantFunctor( const ParserContextSharedPtr& rContext ) :
+ mpContext( rContext )
+ {
+ }
+ void operator()( double n ) const
+ {
+ mpContext->maOperandStack.push( ExpressionNodeSharedPtr( new ConstantValueExpression( n ) ) );
+ }
+};
+
+class EnumFunctor
+{
+ const ExpressionFunct meFunct;
+ double mnValue;
+ ParserContextSharedPtr mpContext;
+
+public:
+
+ EnumFunctor( const ExpressionFunct eFunct, const ParserContextSharedPtr& rContext )
+ : meFunct( eFunct )
+ , mnValue( 0 )
+ , mpContext( rContext )
+ {
+ }
+ void operator()( StringIteratorT rFirst, StringIteratorT rSecond ) const
+ {
+ /*double nVal = mnValue;*/
+ switch( meFunct )
+ {
+ case ENUM_FUNC_ADJUSTMENT :
+ {
+ rtl::OUString aVal( rFirst + 1, rSecond - rFirst, RTL_TEXTENCODING_UTF8 );
+ mpContext->maOperandStack.push( ExpressionNodeSharedPtr( new AdjustmentExpression( *mpContext->mpCustoShape, aVal.toInt32() ) ) );
+ }
+ break;
+ case ENUM_FUNC_EQUATION :
+ {
+ rtl::OUString aVal( rFirst + 1, rSecond - rFirst, RTL_TEXTENCODING_UTF8 );
+ mpContext->maOperandStack.push( ExpressionNodeSharedPtr( new EquationExpression( *mpContext->mpCustoShape, aVal.toInt32() ) ) );
+ }
+ break;
+ default:
+ mpContext->maOperandStack.push( ExpressionNodeSharedPtr( new EnumValueExpression( *mpContext->mpCustoShape, meFunct ) ) );
+ }
+ }
+};
+
+class UnaryFunctionFunctor
+{
+ const ExpressionFunct meFunct;
+ ParserContextSharedPtr mpContext;
+
+public :
+
+ UnaryFunctionFunctor( const ExpressionFunct eFunct, const ParserContextSharedPtr& rContext ) :
+ meFunct( eFunct ),
+ mpContext( rContext )
+ {
+ }
+ void operator()( StringIteratorT, StringIteratorT ) const
+ {
+ ParserContext::OperandStack& rNodeStack( mpContext->maOperandStack );
+
+ if( rNodeStack.size() < 1 )
+ throw ParseError( "Not enough arguments for unary operator" );
+
+ // retrieve arguments
+ ExpressionNodeSharedPtr pArg( rNodeStack.top() );
+ rNodeStack.pop();
+
+ if( pArg->isConstant() ) // check for constness
+ rNodeStack.push( ExpressionNodeSharedPtr( new ConstantValueExpression( UnaryFunctionExpression::getValue( meFunct, pArg ) ) ) );
+ else // push complex node, that calcs the value on demand
+ rNodeStack.push( ExpressionNodeSharedPtr( new UnaryFunctionExpression( meFunct, pArg ) ) );
+ }
+};
+
+/** Implements a binary function over two ExpressionNodes
+
+ @tpl Generator
+ Generator functor, to generate an ExpressionNode of
+ appropriate type
+
+ */
+class BinaryFunctionFunctor
+{
+ const ExpressionFunct meFunct;
+ ParserContextSharedPtr mpContext;
+
+public:
+
+ BinaryFunctionFunctor( const ExpressionFunct eFunct, const ParserContextSharedPtr& rContext ) :
+ meFunct( eFunct ),
+ mpContext( rContext )
+ {
+ }
+
+ void operator()( StringIteratorT, StringIteratorT ) const
+ {
+ ParserContext::OperandStack& rNodeStack( mpContext->maOperandStack );
+
+ if( rNodeStack.size() < 2 )
+ throw ParseError( "Not enough arguments for binary operator" );
+
+ // retrieve arguments
+ ExpressionNodeSharedPtr pSecondArg( rNodeStack.top() );
+ rNodeStack.pop();
+ ExpressionNodeSharedPtr pFirstArg( rNodeStack.top() );
+ rNodeStack.pop();
+
+ // create combined ExpressionNode
+ ExpressionNodeSharedPtr pNode = ExpressionNodeSharedPtr( new BinaryFunctionExpression( meFunct, pFirstArg, pSecondArg ) );
+ // check for constness
+ if( pFirstArg->isConstant() && pSecondArg->isConstant() ) // call the operator() at pNode, store result in constant value ExpressionNode.
+ rNodeStack.push( ExpressionNodeSharedPtr( new ConstantValueExpression( (*pNode)() ) ) );
+ else // push complex node, that calcs the value on demand
+ rNodeStack.push( pNode );
+ }
+};
+
+class IfFunctor
+{
+ ParserContextSharedPtr mpContext;
+
+public :
+
+ IfFunctor( const ParserContextSharedPtr& rContext ) :
+ mpContext( rContext )
+ {
+ }
+ void operator()( StringIteratorT, StringIteratorT ) const
+ {
+ ParserContext::OperandStack& rNodeStack( mpContext->maOperandStack );
+
+ if( rNodeStack.size() < 3 )
+ throw ParseError( "Not enough arguments for ternary operator" );
+
+ // retrieve arguments
+ ExpressionNodeSharedPtr pThirdArg( rNodeStack.top() );
+ rNodeStack.pop();
+ ExpressionNodeSharedPtr pSecondArg( rNodeStack.top() );
+ rNodeStack.pop();
+ ExpressionNodeSharedPtr pFirstArg( rNodeStack.top() );
+ rNodeStack.pop();
+
+ // create combined ExpressionNode
+ ExpressionNodeSharedPtr pNode( new IfExpression( pFirstArg, pSecondArg, pThirdArg ) );
+ // check for constness
+ if( pFirstArg->isConstant() && pSecondArg->isConstant() && pThirdArg->isConstant() )
+ rNodeStack.push( ExpressionNodeSharedPtr( new ConstantValueExpression( (*pNode)() ) ) ); // call the operator() at pNode, store result in constant value ExpressionNode.
+ else
+ rNodeStack.push( pNode ); // push complex node, that calcs the value on demand
+ }
+};
+
+// Workaround for MSVC compiler anomaly (stack trashing)
+//
+// The default ureal_parser_policies implementation of parse_exp
+// triggers a really weird error in MSVC7 (Version 13.00.9466), in
+// that the real_parser_impl::parse_main() call of parse_exp()
+// overwrites the frame pointer _on the stack_ (EBP of the calling
+// function gets overwritten while lying on the stack).
+//
+// For the time being, our parser thus can only read the 1.0E10
+// notation, not the 1.0e10 one.
+//
+// TODO(F1): Also handle the 1.0e10 case here.
+template< typename T > struct custom_real_parser_policies : public ::boost::spirit::ureal_parser_policies<T>
+{
+ template< typename ScannerT >
+ static typename ::boost::spirit::parser_result< ::boost::spirit::chlit<>, ScannerT >::type
+ parse_exp(ScannerT& scan)
+ {
+ // as_lower_d somehow breaks MSVC7
+ return ::boost::spirit::ch_p('E').parse(scan);
+ }
+};
+
+/* This class implements the following grammar (more or
+ less literally written down below, only slightly
+ obfuscated by the parser actions):
+
+ identifier = '$'|'pi'|'e'|'X'|'Y'|'Width'|'Height'
+
+ function = 'abs'|'sqrt'|'sin'|'cos'|'tan'|'atan'|'acos'|'asin'|'exp'|'log'
+
+ basic_expression =
+ number |
+ identifier |
+ function '(' additive_expression ')' |
+ '(' additive_expression ')'
+
+ unary_expression =
+ '-' basic_expression |
+ basic_expression
+
+ multiplicative_expression =
+ unary_expression ( ( '*' unary_expression )* |
+ ( '/' unary_expression )* )
+
+ additive_expression =
+ multiplicative_expression ( ( '+' multiplicative_expression )* |
+ ( '-' multiplicative_expression )* )
+
+ */
+
+class ExpressionGrammar : public ::boost::spirit::grammar< ExpressionGrammar >
+{
+public:
+ /** Create an arithmetic expression grammar
+
+ @param rParserContext
+ Contains context info for the parser
+ */
+ ExpressionGrammar( const ParserContextSharedPtr& rParserContext ) :
+ mpParserContext( rParserContext )
+ {
+ }
+
+ template< typename ScannerT > class definition
+ {
+ public:
+ // grammar definition
+ definition( const ExpressionGrammar& self )
+ {
+ using ::boost::spirit::str_p;
+ using ::boost::spirit::range_p;
+ using ::boost::spirit::lexeme_d;
+ using ::boost::spirit::real_parser;
+ using ::boost::spirit::chseq_p;
+
+ identifier =
+ str_p( "pi" )[ EnumFunctor(ENUM_FUNC_PI, self.getContext() ) ]
+ | str_p( "left" )[ EnumFunctor(ENUM_FUNC_LEFT, self.getContext() ) ]
+ | str_p( "top" )[ EnumFunctor(ENUM_FUNC_TOP, self.getContext() ) ]
+ | str_p( "right" )[ EnumFunctor(ENUM_FUNC_RIGHT, self.getContext() ) ]
+ | str_p( "bottom" )[ EnumFunctor(ENUM_FUNC_BOTTOM, self.getContext() ) ]
+ | str_p( "xstretch" )[ EnumFunctor(ENUM_FUNC_XSTRETCH, self.getContext() ) ]
+ | str_p( "ystretch" )[ EnumFunctor(ENUM_FUNC_YSTRETCH, self.getContext() ) ]
+ | str_p( "hasstroke" )[ EnumFunctor(ENUM_FUNC_HASSTROKE, self.getContext() ) ]
+ | str_p( "hasfill" )[ EnumFunctor(ENUM_FUNC_HASFILL, self.getContext() ) ]
+ | str_p( "width" )[ EnumFunctor(ENUM_FUNC_WIDTH, self.getContext() ) ]
+ | str_p( "height" )[ EnumFunctor(ENUM_FUNC_HEIGHT, self.getContext() ) ]
+ | str_p( "logwidth" )[ EnumFunctor(ENUM_FUNC_LOGWIDTH, self.getContext() ) ]
+ | str_p( "logheight" )[ EnumFunctor(ENUM_FUNC_LOGHEIGHT, self.getContext() ) ]
+ ;
+
+ unaryFunction =
+ (str_p( "abs" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_ABS, self.getContext()) ]
+ | (str_p( "sqrt" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_SQRT, self.getContext()) ]
+ | (str_p( "sin" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_SIN, self.getContext()) ]
+ | (str_p( "cos" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_COS, self.getContext()) ]
+ | (str_p( "tan" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_TAN, self.getContext()) ]
+ | (str_p( "atan" ) >> '(' >> additiveExpression >> ')' )[ UnaryFunctionFunctor( UNARY_FUNC_ATAN, self.getContext()) ]
+ ;
+
+ binaryFunction =
+ (str_p( "min" ) >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( BINARY_FUNC_MIN, self.getContext()) ]
+ | (str_p( "max" ) >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( BINARY_FUNC_MAX, self.getContext()) ]
+ | (str_p( "atan2") >> '(' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ BinaryFunctionFunctor( BINARY_FUNC_ATAN2,self.getContext()) ]
+ ;
+
+ ternaryFunction =
+ (str_p( "if" ) >> '(' >> additiveExpression >> ',' >> additiveExpression >> ',' >> additiveExpression >> ')' )[ IfFunctor( self.getContext() ) ]
+ ;
+
+ funcRef_decl =
+ lexeme_d[ +( range_p('a','z') | range_p('A','Z') | range_p('0','9') ) ];
+
+ functionReference =
+ (str_p( "?" ) >> funcRef_decl )[ EnumFunctor( ENUM_FUNC_EQUATION, self.getContext() ) ];
+
+ modRef_decl =
+ lexeme_d[ +( range_p('0','9') ) ];
+
+ modifierReference =
+ (str_p( "$" ) >> modRef_decl )[ EnumFunctor( ENUM_FUNC_ADJUSTMENT, self.getContext() ) ];
+
+ basicExpression =
+ real_parser<double, custom_real_parser_policies<double> >()[ DoubleConstantFunctor(self.getContext()) ]
+ | identifier
+ | functionReference
+ | modifierReference
+ | unaryFunction
+ | binaryFunction
+ | ternaryFunction
+ | '(' >> additiveExpression >> ')'
+ ;
+
+ unaryExpression =
+ ('-' >> basicExpression)[ UnaryFunctionFunctor( UNARY_FUNC_NEG, self.getContext()) ]
+ | basicExpression
+ ;
+
+ multiplicativeExpression =
+ unaryExpression
+ >> *( ('*' >> unaryExpression)[ BinaryFunctionFunctor( BINARY_FUNC_MUL, self.getContext()) ]
+ | ('/' >> unaryExpression)[ BinaryFunctionFunctor( BINARY_FUNC_DIV, self.getContext()) ]
+ )
+ ;
+
+ additiveExpression =
+ multiplicativeExpression
+ >> *( ('+' >> multiplicativeExpression)[ BinaryFunctionFunctor( BINARY_FUNC_PLUS, self.getContext()) ]
+ | ('-' >> multiplicativeExpression)[ BinaryFunctionFunctor( BINARY_FUNC_MINUS, self.getContext()) ]
+ )
+ ;
+
+ BOOST_SPIRIT_DEBUG_RULE(additiveExpression);
+ BOOST_SPIRIT_DEBUG_RULE(multiplicativeExpression);
+ BOOST_SPIRIT_DEBUG_RULE(unaryExpression);
+ BOOST_SPIRIT_DEBUG_RULE(basicExpression);
+ BOOST_SPIRIT_DEBUG_RULE(unaryFunction);
+ BOOST_SPIRIT_DEBUG_RULE(binaryFunction);
+ BOOST_SPIRIT_DEBUG_RULE(ternaryFunction);
+ BOOST_SPIRIT_DEBUG_RULE(identifier);
+ }
+
+ const ::boost::spirit::rule< ScannerT >& start() const
+ {
+ return additiveExpression;
+ }
+
+ private:
+ // the constituents of the Spirit arithmetic expression grammar.
+ // For the sake of readability, without 'ma' prefix.
+ ::boost::spirit::rule< ScannerT > additiveExpression;
+ ::boost::spirit::rule< ScannerT > multiplicativeExpression;
+ ::boost::spirit::rule< ScannerT > unaryExpression;
+ ::boost::spirit::rule< ScannerT > basicExpression;
+ ::boost::spirit::rule< ScannerT > unaryFunction;
+ ::boost::spirit::rule< ScannerT > binaryFunction;
+ ::boost::spirit::rule< ScannerT > ternaryFunction;
+ ::boost::spirit::rule< ScannerT > funcRef_decl;
+ ::boost::spirit::rule< ScannerT > functionReference;
+ ::boost::spirit::rule< ScannerT > modRef_decl;
+ ::boost::spirit::rule< ScannerT > modifierReference;
+ ::boost::spirit::rule< ScannerT > identifier;
+ };
+
+ const ParserContextSharedPtr& getContext() const
+ {
+ return mpParserContext;
+ }
+
+private:
+ ParserContextSharedPtr mpParserContext; // might get modified during parsing
+};
+
+#ifdef BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE
+const ParserContextSharedPtr& getParserContext()
+{
+ static ParserContextSharedPtr lcl_parserContext( new ParserContext() );
+
+ // clear node stack (since we reuse the static object, that's
+ // the whole point here)
+ while( !lcl_parserContext->maOperandStack.empty() )
+ lcl_parserContext->maOperandStack.pop();
+
+ return lcl_parserContext;
+}
+#endif
+
+}
+
+namespace EnhancedCustomShape {
+
+
+
+ExpressionNodeSharedPtr FunctionParser::parseFunction( const ::rtl::OUString& rFunction, const EnhancedCustomShape2d& rCustoShape )
+{
+ // TODO(Q1): Check if a combination of the RTL_UNICODETOTEXT_FLAGS_*
+ // gives better conversion robustness here (we might want to map space
+ // etc. to ASCII space here)
+ const ::rtl::OString& rAsciiFunction(
+ rtl::OUStringToOString( rFunction, RTL_TEXTENCODING_ASCII_US ) );
+
+ StringIteratorT aStart( rAsciiFunction.getStr() );
+ StringIteratorT aEnd( rAsciiFunction.getStr()+rAsciiFunction.getLength() );
+
+ ParserContextSharedPtr pContext;
+
+#ifdef BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE
+ // static parser context, because the actual
+ // Spirit parser is also a static object
+ pContext = getParserContext();
+#else
+ pContext.reset( new ParserContext() );
+#endif
+ pContext->mpCustoShape = &rCustoShape;
+
+ ExpressionGrammar aExpressionGrammer( pContext );
+ const ::boost::spirit::parse_info<StringIteratorT> aParseInfo(
+ ::boost::spirit::parse( aStart,
+ aEnd,
+ aExpressionGrammer >> ::boost::spirit::end_p,
+ ::boost::spirit::space_p ) );
+ OSL_DEBUG_ONLY(::std::cout.flush()); // needed to keep stdout and cout in sync
+
+
+
+ // input fully congested by the parser?
+ if( !aParseInfo.full )
+ throw ParseError( "EnhancedCustomShapeFunctionParser::parseFunction(): string not fully parseable" );
+
+ // parser's state stack now must contain exactly _one_ ExpressionNode,
+ // which represents our formula.
+ if( pContext->maOperandStack.size() != 1 )
+ throw ParseError( "EnhancedCustomShapeFunctionParser::parseFunction(): incomplete or empty expression" );
+
+
+ return pContext->maOperandStack.top();
+}
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx
new file mode 100644
index 000000000000..278246a30820
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx
@@ -0,0 +1,8276 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "EnhancedCustomShapeGeometry.hxx"
+#include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp>
+/*
+static const SvxMSDffVertPair Vert[] =
+{
+ { 0, 0, }
+};
+static const sal_uInt16 Segm[] =
+{
+ 0x4000,
+ 0x8000
+};
+static const SvxMSDffCalculationData Calc[] =
+{
+ { 0x0000, 0, 0, 0 }
+};
+static const sal_Int32 Default[] =
+{
+ 0
+};
+static const SvxMSDffTextRect TextRect[] =
+{
+ { { 0, 0 }, { 0, 0 } }
+};
+static const mso_CustomShape mso =
+{
+ (SvxMSDffVertPair*)mso_sptVert, sizeof( mso_sptVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptSegm, sizeof( mso_sptSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalc, sizeof( mso_sptCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault,
+ (SvxMSDffTextRectangles*)mso_sptTextRect, sizeof( mso_sptTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptVert, sizeof( mso_sptVert ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandles*)mso_sptHandles, sizeof( mso_sptHandles ) / sizeof( SvxMSDffHandles )
+};
+*/
+
+static const sal_Int32 mso_sptDefault0[] =
+{
+ 1, 0
+};
+static const sal_Int32 mso_sptDefault1400[] =
+{
+ 1, 1400
+};
+static const sal_Int32 mso_sptDefault1800[] =
+{
+ 1, 1800
+};
+static const sal_Int32 mso_sptDefault2500[] =
+{
+ 1, 2500
+};
+static const sal_Int32 mso_sptDefault2700[] =
+{
+ 1, 2700
+};
+static const sal_Int32 mso_sptDefault3600[] =
+{
+ 1, 3600
+};
+static const sal_Int32 mso_sptDefault3700[] =
+{
+ 1, 3700
+};
+static const sal_Int32 mso_sptDefault5400[] =
+{
+ 1, 5400
+};
+static const sal_Int32 mso_sptDefault7200[] =
+{
+ 1, 7200
+};
+static const sal_Int32 mso_sptDefault8100[] =
+{
+ 1, 8100
+};
+static const sal_Int32 mso_sptDefault9600[] =
+{
+ 1, 9600
+};
+static const sal_Int32 mso_sptDefault10800[] =
+{
+ 1, 10800
+};
+static const sal_Int32 mso_sptDefault12000[] =
+{
+ 1, 12000
+};
+static const sal_Int32 mso_sptDefault13500[] =
+{
+ 1, 13500
+};
+static const sal_Int32 mso_sptDefault16200[] =
+{
+ 1, 16200
+};
+static const sal_Int32 mso_sptDefault16200and5400[] =
+{
+ 2, 16200, 5400
+};
+
+static const SvxMSDffVertPair mso_sptArcVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 3 MSO_I, 1 MSO_I }, { 7 MSO_I, 5 MSO_I }, { 10800, 10800 },
+ { 0, 0 }, { 21600, 21600 }, { 3 MSO_I, 1 MSO_I }, { 7 MSO_I, 5 MSO_I }
+};
+static const sal_uInt16 mso_sptArcSegm[] =
+{
+ 0xa504, 0xab00, 0x0001, 0x6001, 0x8000,
+ 0xa504, 0xaa00, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptArcCalc[] =
+{
+ { 0x4009, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x2000, { 0x400, 10800, 0 } },
+ { 0x400a, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x2000, { 0x402, 10800, 0 } },
+ { 0x4009, { 10800, DFF_Prop_adjust2Value, 0 } },
+ { 0x2000, { 0x404, 10800, 0 } },
+ { 0x400a, { 10800, DFF_Prop_adjust2Value, 0 } },
+ { 0x2000, { 0x406, 10800, 0 } }
+};
+static const sal_Int32 mso_sptArcDefault[] =
+{
+ 2, 270, 0
+};
+static const SvxMSDffVertPair mso_sptStandardGluePoints[] =
+{
+ { 10800, 0 }, { 0, 10800 }, { 10800, 21600 }, { 21600, 10800 }
+};
+static const SvxMSDffHandle mso_sptArcHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_POLAR | MSDFF_HANDLE_FLAGS_RADIUS_RANGE,
+ 10800, 0x100, 10800, 10800, 10800, 10800, 0x80000000, 0x7fffffff },
+ { MSDFF_HANDLE_FLAGS_POLAR | MSDFF_HANDLE_FLAGS_RADIUS_RANGE,
+ 10800, 0x101, 10800, 10800, 10800, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoArc =
+{
+ (SvxMSDffVertPair*)mso_sptArcVert, sizeof( mso_sptArcVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptArcSegm, sizeof( mso_sptArcSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptArcCalc, sizeof( mso_sptArcCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptArcDefault,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptArcHandle, sizeof( mso_sptArcHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptTextSimpleVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 }, { 0, 0 }
+};
+static const mso_CustomShape msoTextSimple =
+{
+ (SvxMSDffVertPair*)mso_sptTextSimpleVert, sizeof( mso_sptTextSimpleVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptRectangleVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 }, { 0, 0 }
+};
+static const mso_CustomShape msoRectangle =
+{
+ (SvxMSDffVertPair*)mso_sptRectangleVert, sizeof( mso_sptRectangleVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptRoundRectangleVert[] = // adj value 0 -> 10800
+{
+ { 7 MSO_I, 0 }, { 0, 8 MSO_I }, { 0, 9 MSO_I }, { 7 MSO_I, 21600 },
+ { 10 MSO_I, 21600 }, { 21600, 9 MSO_I }, { 21600, 8 MSO_I }, { 10 MSO_I, 0 }
+};
+static const sal_uInt16 mso_sptRoundRectangleSegm[] =
+{
+ 0x4000, 0xa701, 0x0001, 0xa801, 0x0001, 0xa701, 0x0001, 0xa801, 0x6000, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptRoundRectangleCalc[] =
+{
+ { 0x000e, { 0, 45, 0 } },
+ { 0x6009, { DFF_Prop_adjustValue, 0x400, 0 } },
+ { 0x2001, { 0x401, 3163, 7636 } },
+ { 0x6000, { DFF_Prop_geoLeft, 0x402, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, 0x402, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x402 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x402 } },
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } }
+};
+static const SvxMSDffTextRectangles mso_sptRoundRectangleTextRect[] =
+{
+ { { 3 MSO_I, 4 MSO_I }, { 5 MSO_I, 6 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptRoundRectangleHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_SWITCHED,
+ 0x100, 0, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoRoundRectangle =
+{
+ (SvxMSDffVertPair*)mso_sptRoundRectangleVert, sizeof( mso_sptRoundRectangleVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptRoundRectangleSegm, sizeof( mso_sptRoundRectangleSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptRoundRectangleCalc, sizeof( mso_sptRoundRectangleCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault3600,
+ (SvxMSDffTextRectangles*)mso_sptRoundRectangleTextRect, sizeof( mso_sptRoundRectangleTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptRoundRectangleHandle, sizeof( mso_sptRoundRectangleHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptRightTriangleVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 0, 21600 }, { 0, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptRightTriangleTextRect[] =
+{
+ { { 1900, 12700 }, { 12700, 19700 } }
+};
+static const SvxMSDffVertPair mso_sptRightTriangleGluePoints[] =
+{
+ { 10800, 0 }, { 5400, 10800 }, { 0, 21600 }, { 10800, 21600 }, { 21600, 21600 }, { 16200, 10800 }
+};
+static const mso_CustomShape msoRightTriangle =
+{
+ (SvxMSDffVertPair*)mso_sptRightTriangleVert, sizeof( mso_sptRightTriangleVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptRightTriangleTextRect, sizeof( mso_sptRightTriangleTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptRightTriangleGluePoints, sizeof( mso_sptRightTriangleGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptEllipseVert[] =
+{
+ { 10800, 10800 }, { 10800, 10800 }, { 0, 360 }
+};
+static const sal_uInt16 mso_sptEllipseSegm[] =
+{
+ 0xa203, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptEllipseTextRect[] =
+{
+ { { 3163, 3163 }, { 18437, 18437 } }
+};
+static const SvxMSDffVertPair mso_sptEllipseGluePoints[] =
+{
+ { 10800, 0 }, { 3163, 3163 }, { 0, 10800 }, { 3163, 18437 }, { 10800, 21600 }, { 18437, 18437 }, { 21600, 10800 }, { 18437, 3163 }
+};
+static const mso_CustomShape msoEllipse =
+{
+ (SvxMSDffVertPair*)mso_sptEllipseVert, sizeof( mso_sptEllipseVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptEllipseSegm, sizeof( mso_sptEllipseSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptEllipseTextRect, sizeof( mso_sptEllipseTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptEllipseGluePoints, sizeof( mso_sptEllipseGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptParallelogramVert[] = // adjustment1 : 0 - 21600
+{
+ { 0 MSO_I, 0 }, { 21600, 0 }, { 1 MSO_I, 21600 }, { 0, 21600 }
+};
+static const sal_uInt16 mso_sptParallelogramSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptParallelogramCalc[] =
+{
+ { 0x4000, { 0, DFF_Prop_adjustValue, 0 } },
+ { 0x8000, { 0, 21600, DFF_Prop_adjustValue } },
+ { 0x2001, { DFF_Prop_adjustValue, 10, 24 } },
+ { 0x2000, { 0x0402, 1750, 0 } },
+ { 0x8000, { 21600, 0, 0x0403 } },
+ { 0x2001, { 0x400, 1, 2 } },
+ { 0x4000, { 10800, 0x405, 0 } },
+ { 0x2000, { 0x400, 0, 10800 } },
+ { 0x6006, { 0x407, 0x40d, 0 } },
+ { 0x8000, { 10800, 0, 0x405 } },
+ { 0x6006, { 0x407, 0x40c, 21600 } },
+ { 0x8000, { 21600, 0, 0x405 } },
+ { 0x8001, { 21600, 10800, 0x400 } },
+ { 0x8000, { 21600, 0, 0x40c } }
+};
+static const SvxMSDffTextRectangles mso_sptParallelogramTextRect[] =
+{
+ { { 3 MSO_I, 3 MSO_I }, { 4 MSO_I, 4 MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptParallelogramGluePoints[] =
+{
+ { 6 MSO_I, 0 }, { 10800, 8 MSO_I }, { 11 MSO_I, 10800 }, { 9 MSO_I, 21600 }, { 10800, 10 MSO_I }, { 5 MSO_I, 10800 }
+};
+static const SvxMSDffHandle mso_sptParallelogramHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0, 10800, 10800, 0, 21600, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoParallelogram =
+{
+ (SvxMSDffVertPair*)mso_sptParallelogramVert, sizeof( mso_sptParallelogramVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptParallelogramSegm, sizeof( mso_sptParallelogramSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptParallelogramCalc, sizeof( mso_sptParallelogramCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault5400,
+ (SvxMSDffTextRectangles*)mso_sptParallelogramTextRect, sizeof( mso_sptParallelogramTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptParallelogramGluePoints, sizeof( mso_sptParallelogramGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptParallelogramHandle, sizeof( mso_sptParallelogramHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptDiamondVert[] =
+{
+ { 10800, 0 }, { 21600, 10800 }, { 10800, 21600 }, { 0, 10800 }, { 10800, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptDiamondTextRect[] =
+{
+ { { 5400, 5400 }, { 16200, 16200 } }
+};
+static const mso_CustomShape msoDiamond =
+{
+ (SvxMSDffVertPair*)mso_sptDiamondVert, sizeof( mso_sptDiamondVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptDiamondTextRect, sizeof( mso_sptDiamondTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptTrapezoidVert[] = // adjustment1 : 0 - 10800
+{
+ { 0, 0 }, { 21600, 0 }, {0 MSO_I, 21600 }, { 1 MSO_I, 21600 }
+};
+static const sal_uInt16 mso_sptTrapezoidSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptTrapezoidCalc[] =
+{
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2001, { DFF_Prop_adjustValue, 10, 18 } },
+ { 0x2000, { 0x0402, 1750, 0 } },
+ { 0x8000, { 21600, 0, 0x403 } },
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } },
+ { 0x8000, { 21600, 0, 0x405 } }
+};
+static const SvxMSDffTextRectangles mso_sptTrapezoidTextRect[] =
+{
+ { { 3 MSO_I, 3 MSO_I }, { 4 MSO_I, 4 MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptTrapezoidGluePoints[] =
+{
+ { 6 MSO_I, 10800 }, { 10800, 21600 }, { 5 MSO_I, 10800 }, { 10800, 0 }
+};
+static const SvxMSDffHandle mso_sptTrapezoidHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 1, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoTrapezoid =
+{
+ (SvxMSDffVertPair*)mso_sptTrapezoidVert, sizeof( mso_sptTrapezoidVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTrapezoidSegm, sizeof( mso_sptTrapezoidSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTrapezoidCalc, sizeof( mso_sptTrapezoidCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault5400,
+ (SvxMSDffTextRectangles*)mso_sptTrapezoidTextRect, sizeof( mso_sptTrapezoidTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptTrapezoidGluePoints, sizeof( mso_sptTrapezoidGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptTrapezoidHandle, sizeof( mso_sptTrapezoidHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptOctagonVert[] = // adjustment1 : 0 - 10800
+{
+ { 0 MSO_I, 0 }, { 2 MSO_I, 0 }, { 21600, 1 MSO_I }, { 21600, 3 MSO_I },
+ { 2 MSO_I, 21600 }, { 0 MSO_I, 21600 }, { 0, 3 MSO_I }, { 0, 1 MSO_I }
+};
+static const sal_uInt16 mso_sptOctagonSegm[] =
+{
+ 0x4000, 0x0007, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptOctagonCalc[] =
+{
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } },
+ { 0x6000, { DFF_Prop_geoLeft, 0x404, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, 0x404, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x404 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x404 } }
+};
+static const sal_Int32 mso_sptOctagonDefault[] =
+{
+ 1, 5000
+};
+static const SvxMSDffTextRectangles mso_sptOctagonTextRect[] =
+{
+ { { 5 MSO_I, 6 MSO_I }, { 7 MSO_I, 8 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptOctagonHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoOctagon =
+{
+ (SvxMSDffVertPair*)mso_sptOctagonVert, sizeof( mso_sptOctagonVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptOctagonSegm, sizeof( mso_sptOctagonSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptOctagonCalc, sizeof( mso_sptOctagonCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptOctagonDefault,
+ (SvxMSDffTextRectangles*)mso_sptOctagonTextRect, sizeof( mso_sptOctagonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptOctagonHandle, sizeof( mso_sptOctagonHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptIsocelesTriangleVert[] = // adjustment1 : 0 - 21600
+{
+ { 0 MSO_I, 0 }, { 21600, 21600 }, { 0, 21600 }
+};
+static const sal_uInt16 mso_sptIsocelesTriangleSegm[] =
+{
+ 0x4000, 0x0002, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptIsocelesTriangleCalc[] =
+{
+ { 0x4000, { 0, DFF_Prop_adjustValue, 0 } },
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } },
+ { 0x2000, { 0x401, 10800, 0 } },
+ { 0x2001, { DFF_Prop_adjustValue, 2, 3 } },
+ { 0x2000, { 0x403, 7200, 0 } },
+ { 0x8000, { 21600, 0, 0x400 } },
+ { 0x2001, { 0x405, 1, 2 } },
+ { 0x8000, { 21600, 0, 0x406 } }
+};
+static const SvxMSDffTextRectangles mso_sptIsocelesTriangleTextRect[] =
+{
+ { { 1 MSO_I, 10800 }, { 2 MSO_I, 18000 } },
+ { { 3 MSO_I, 7200 }, { 4 MSO_I, 21600 } }
+};
+static const SvxMSDffVertPair mso_sptIsocelesTriangleGluePoints[] =
+{
+ { 10800, 0 }, { 1 MSO_I, 10800 }, { 0, 21600 }, { 10800, 21600 }, { 21600, 21600 }, { 7 MSO_I, 10800 }
+};
+static const SvxMSDffHandle mso_sptIsocelesTriangleHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0, 10800, 10800, 0, 21600, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoIsocelesTriangle =
+{
+ (SvxMSDffVertPair*)mso_sptIsocelesTriangleVert, sizeof( mso_sptIsocelesTriangleVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptIsocelesTriangleSegm, sizeof( mso_sptIsocelesTriangleSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptIsocelesTriangleCalc, sizeof( mso_sptIsocelesTriangleCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault10800,
+ (SvxMSDffTextRectangles*)mso_sptIsocelesTriangleTextRect, sizeof( mso_sptIsocelesTriangleTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptIsocelesTriangleGluePoints, sizeof( mso_sptIsocelesTriangleGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptIsocelesTriangleHandle, sizeof( mso_sptIsocelesTriangleHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptHexagonVert[] = // adjustment1 : 0 - 10800
+{
+ { 0 MSO_I, 0 }, { 1 MSO_I, 0 }, { 21600, 10800 }, { 1 MSO_I, 21600 },
+ { 0 MSO_I, 21600 }, { 0, 10800 }
+};
+static const sal_uInt16 mso_sptHexagonSegm[] =
+{
+ 0x4000, 0x0005, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptHexagonCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { DFF_Prop_adjustValue, 100, 234 } },
+ { 0x2000, { 0x402, 1700, 0 } },
+ { 0x8000, { 21600, 0, 0x403 } }
+};
+static const SvxMSDffTextRectangles mso_sptHexagonTextRect[] =
+{
+ { { 3 MSO_I, 3 MSO_I }, { 4 MSO_I, 4 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptHexagonHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoHexagon =
+{
+ (SvxMSDffVertPair*)mso_sptHexagonVert, sizeof( mso_sptHexagonVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptHexagonSegm, sizeof( mso_sptHexagonSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptHexagonCalc, sizeof( mso_sptHexagonCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault5400,
+ (SvxMSDffTextRectangles*)mso_sptHexagonTextRect, sizeof( mso_sptHexagonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptHexagonHandle, sizeof( mso_sptHexagonHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptPentagonVert[] =
+{
+ { 10800, 0 }, { 0, 8260 }, { 4230, 21600 }, { 17370, 21600 },
+ { 21600, 8260 }, { 10800, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptPentagonTextRect[] =
+{
+ { { 4230, 5080 }, { 17370, 21600 } }
+};
+static const SvxMSDffVertPair mso_sptPentagonGluePoints[] =
+{
+ { 10800, 0 }, { 0, 8260 }, { 4230, 21600 }, { 10800, 21600 },
+ { 17370, 21600 }, { 21600, 8260 }
+};
+static const mso_CustomShape msoPentagon =
+{
+ (SvxMSDffVertPair*)mso_sptPentagonVert, sizeof( mso_sptPentagonVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptPentagonTextRect, sizeof( mso_sptPentagonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptPentagonGluePoints, sizeof( mso_sptPentagonGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptPlusVert[] = // adjustment1 : 0 - 10800
+{
+ { 1 MSO_I, 0 }, { 2 MSO_I, 0 }, { 2 MSO_I, 1 MSO_I }, { 21600, 1 MSO_I },
+ { 21600, 3 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 2 MSO_I, 21600 }, { 1 MSO_I, 21600 },
+ { 1 MSO_I, 3 MSO_I }, { 0, 3 MSO_I }, { 0, 1 MSO_I }, { 1 MSO_I, 1 MSO_I }, { 1 MSO_I, 0 }
+};
+static const SvxMSDffCalculationData mso_sptPlusCalc[] =
+{
+ { 0x2001, { DFF_Prop_adjustValue, 10799, 10800 } },
+ { 0x2000, { 0x400, 0, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x400 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x400 } }
+};
+static const SvxMSDffTextRectangles mso_sptPlusTextRect[] =
+{
+ { { 1 MSO_I, 1 MSO_I }, { 2 MSO_I, 3 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptPlusHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_SWITCHED,
+ 0x100, 0, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoPlus =
+{
+ (SvxMSDffVertPair*)mso_sptPlusVert, sizeof( mso_sptPlusVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ (SvxMSDffCalculationData*)mso_sptPlusCalc, sizeof( mso_sptPlusCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault5400,
+ (SvxMSDffTextRectangles*)mso_sptPlusTextRect, sizeof( mso_sptPlusTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptPlusHandle, sizeof( mso_sptPlusHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptCanVert[] = // adjustment1 : 0 - 10800
+{
+ { 44, 0 },
+ { 20, 0 }, { 0, 2 MSO_I }, { 0, 0 MSO_I }, // ccp
+ { 0, 3 MSO_I }, // p
+ { 0, 4 MSO_I }, { 20, 21600 }, { 44, 21600 }, // ccp
+ { 68, 21600 }, { 88, 4 MSO_I }, { 88, 3 MSO_I }, // ccp
+ { 88, 0 MSO_I }, // p
+ { 88, 2 MSO_I }, { 68, 0 }, { 44, 0 }, // ccp
+ { 44, 0 }, // p
+ { 20, 0 }, { 0, 2 MSO_I }, { 0, 0 MSO_I }, // ccp
+ { 0, 5 MSO_I }, { 20, 6 MSO_I }, { 44, 6 MSO_I }, // ccp
+ { 68, 6 MSO_I },{ 88, 5 MSO_I }, { 88, 0 MSO_I }, // ccp
+ { 88, 2 MSO_I },{ 68, 0 }, { 44, 0 } // ccp
+};
+static const sal_uInt16 mso_sptCanSegm[] =
+{
+ 0x4000, 0x2001, 0x0001, 0x2002, 0x0001, 0x2001, 0x6001, 0x8000,
+ 0x4000, 0x2004, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCanCalc[] =
+{
+ { 0x2001, { DFF_Prop_adjustValue, 2, 4 } }, // 1/4
+ { 0x2001, { 0x0400, 6, 11 } },
+ { 0xa000, { 0x0400, 0, 0x0401 } },
+ { 0x8000, { 21600, 0, 0x0400 } },
+ { 0x6000, { 0x0403, 0x0401, 0 } },
+ { 0x6000, { 0x0400, 0x0401, 0 } },
+ { 0x2001, { DFF_Prop_adjustValue, 2, 2 } },
+ { 0x0000, { 44, 0, 0 } }
+};
+static const SvxMSDffTextRectangles mso_sptCanTextRect[] =
+{
+ { { 0, 6 MSO_I }, { 88, 3 MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptCanGluePoints[] =
+{
+ { 44, 6 MSO_I }, { 44, 0 }, { 0, 10800 }, { 44, 21600 }, { 88, 10800 }
+};
+static const SvxMSDffHandle mso_sptCanHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 7 + 3, 0x100, 44, 10800, 0x80000000, 0x7fffffff, 0, 10800 }
+};
+static const mso_CustomShape msoCan =
+{
+ (SvxMSDffVertPair*)mso_sptCanVert, sizeof( mso_sptCanVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCanSegm, sizeof( mso_sptCanSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCanCalc, sizeof( mso_sptCanCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault5400,
+ (SvxMSDffTextRectangles*)mso_sptCanTextRect, sizeof( mso_sptCanTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 88, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptCanGluePoints, sizeof( mso_sptCanGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptCanHandle, sizeof( mso_sptCanHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptArrowVert[] = // adjustment1: x 0 - 21600
+{ // adjustment2: y 0 - 10800
+ { 0, 0 MSO_I }, { 1 MSO_I, 0 MSO_I }, { 1 MSO_I, 0 }, { 21600, 10800 },
+ { 1 MSO_I, 21600 }, { 1 MSO_I, 2 MSO_I }, { 0, 2 MSO_I }
+};
+static const sal_uInt16 mso_sptArrowSegm[] =
+{
+ 0x4000, 0x0006, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptArrowCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjust2Value } },
+ { 0x8000, { 21600, 0, 0x401 } },
+ { 0x6001, { 0x403, 0x400, 10800 } },
+ { 0x6000, { 0x401, 0x404, 0 } },
+ { 0x6001, { 0x401, 0x400, 10800 } },
+ { 0xa000, { 0x401, 0, 0x406 } }
+};
+static const SvxMSDffTextRectangles mso_sptArrowTextRect[] =
+{
+ { { 0, 0 MSO_I }, { 5 MSO_I, 2 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0x101, 10800, 10800, 0, 21600, 0, 10800 }
+};
+static const mso_CustomShape msoArrow =
+{
+ (SvxMSDffVertPair*)mso_sptArrowVert, sizeof( mso_sptArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptArrowSegm, sizeof( mso_sptArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptArrowCalc, sizeof( mso_sptArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault16200and5400,
+ (SvxMSDffTextRectangles*)mso_sptArrowTextRect, sizeof( mso_sptArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptArrowHandle, sizeof( mso_sptArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptLeftArrowVert[] = // adjustment1: x 0 - 21600
+{ // adjustment2: y 0 - 10800
+ { 21600, 0 MSO_I }, { 1 MSO_I, 0 MSO_I }, { 1 MSO_I, 0 }, { 0, 10800 },
+ { 1 MSO_I, 21600 }, { 1 MSO_I, 2 MSO_I }, { 21600, 2 MSO_I }
+};
+static const sal_uInt16 mso_sptLeftArrowSegm[] =
+{
+ 0x4000, 0x0006, 0x6001, 0x8000
+};
+static const sal_Int32 mso_sptLeftArrowDefault[] =
+{
+ 2, 5400, 5400
+};
+static const SvxMSDffTextRectangles mso_sptLeftArrowTextRect[] =
+{
+ { { 7 MSO_I, 0 MSO_I }, { 21600, 2 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptLeftArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0x101, 10800, 10800, 0, 21600, 0, 10800 }
+};
+static const mso_CustomShape msoLeftArrow =
+{
+ (SvxMSDffVertPair*)mso_sptLeftArrowVert, sizeof( mso_sptLeftArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptLeftArrowSegm, sizeof( mso_sptLeftArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptArrowCalc, sizeof( mso_sptArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptLeftArrowDefault,
+ (SvxMSDffTextRectangles*)mso_sptLeftArrowTextRect, sizeof( mso_sptLeftArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptLeftArrowHandle, sizeof( mso_sptLeftArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptDownArrowVert[] = // adjustment1: x 0 - 21600
+{ // adjustment2: y 0 - 10800
+ { 0 MSO_I, 0 }, { 0 MSO_I, 1 MSO_I }, { 0, 1 MSO_I }, { 10800, 21600 },
+ { 21600, 1 MSO_I }, { 2 MSO_I, 1 MSO_I }, { 2 MSO_I, 0 }
+};
+static const sal_uInt16 mso_sptDownArrowSegm[] =
+{
+ 0x4000, 0x0006, 0x6001, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptDownArrowTextRect[] =
+{
+ { { 0 MSO_I, 0 }, { 2 MSO_I, 5 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptDownArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x101, 0x100, 10800, 10800, 0, 10800, 0, 21600 }
+};
+static const mso_CustomShape msoDownArrow =
+{
+ (SvxMSDffVertPair*)mso_sptDownArrowVert, sizeof( mso_sptDownArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptDownArrowSegm, sizeof( mso_sptDownArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptArrowCalc, sizeof( mso_sptArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault16200and5400,
+ (SvxMSDffTextRectangles*)mso_sptDownArrowTextRect, sizeof( mso_sptDownArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptDownArrowHandle, sizeof( mso_sptDownArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptUpArrowVert[] = // adjustment1: x 0 - 21600
+{ // adjustment2: y 0 - 10800
+ { 0 MSO_I, 21600 }, { 0 MSO_I, 1 MSO_I }, { 0, 1 MSO_I }, { 10800, 0 },
+ { 21600, 1 MSO_I }, { 2 MSO_I, 1 MSO_I }, { 2 MSO_I, 21600 }
+};
+static const sal_uInt16 mso_sptUpArrowSegm[] =
+{
+ 0x4000, 0x0006, 0x6001, 0x8000
+};
+static const sal_Int32 mso_sptUpArrowDefault[] =
+{
+ 2, 5400, 5400
+};
+static const SvxMSDffTextRectangles mso_sptUpArrowTextRect[] =
+{
+ { { 0 MSO_I, 7 MSO_I }, { 2 MSO_I, 21600 } }
+};
+static const SvxMSDffHandle mso_sptUpArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x101, 0x100, 10800, 10800, 0, 10800, 0, 21600 }
+};
+static const mso_CustomShape msoUpArrow =
+{
+ (SvxMSDffVertPair*)mso_sptUpArrowVert, sizeof( mso_sptUpArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptUpArrowSegm, sizeof( mso_sptUpArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptArrowCalc, sizeof( mso_sptArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptUpArrowDefault,
+ (SvxMSDffTextRectangles*)mso_sptUpArrowTextRect, sizeof( mso_sptUpArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptUpArrowHandle, sizeof( mso_sptUpArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptLeftRightArrowVert[] = // adjustment1: x 0 - 10800
+{ // adjustment2: y 0 - 10800
+ { 0, 10800 }, { 0 MSO_I, 0 }, { 0 MSO_I, 1 MSO_I }, { 2 MSO_I, 1 MSO_I },
+ { 2 MSO_I, 0 }, { 21600, 10800 }, { 2 MSO_I, 21600 }, { 2 MSO_I, 3 MSO_I },
+ { 0 MSO_I, 3 MSO_I }, { 0 MSO_I, 21600 }
+};
+static const sal_uInt16 mso_sptLeftRightArrowSegm[] =
+{
+ 0x4000, 0x0009, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptDoubleArrowCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjust2Value } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjust2Value } },
+ { 0x6001, { DFF_Prop_adjustValue, 0x404, 10800 } },
+ { 0x8000, { 21600, 0, 0x405 } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } },
+ { 0x6001, { DFF_Prop_adjust2Value, 0x407, 10800 } },
+ { 0x8000, { 21600, 0, 0x408 } }
+};
+static const sal_Int32 mso_sptLeftRightArrowDefault[] =
+{
+ 2, 4300, 5400
+};
+static const SvxMSDffTextRectangles mso_sptLeftRightArrowTextRect[] =
+{
+ { { 5 MSO_I, 1 MSO_I }, { 6 MSO_I, 3 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptLeftRightArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0x101, 10800, 10800, 0, 10800, 0, 10800 }
+};
+static const mso_CustomShape msoLeftRightArrow =
+{
+ (SvxMSDffVertPair*)mso_sptLeftRightArrowVert, sizeof( mso_sptLeftRightArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptLeftRightArrowSegm, sizeof( mso_sptLeftRightArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptDoubleArrowCalc, sizeof( mso_sptDoubleArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptLeftRightArrowDefault,
+ (SvxMSDffTextRectangles*)mso_sptLeftRightArrowTextRect, sizeof( mso_sptLeftRightArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptLeftRightArrowHandle, sizeof( mso_sptLeftRightArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptUpDownArrowVert[] = // adjustment1: x 0 - 10800
+{ // adjustment2: y 0 - 10800
+ { 0, 1 MSO_I }, { 10800, 0 }, { 21600, 1 MSO_I }, { 2 MSO_I, 1 MSO_I },
+ { 2 MSO_I, 3 MSO_I }, { 21600, 3 MSO_I }, { 10800, 21600 }, { 0, 3 MSO_I },
+ { 0 MSO_I, 3 MSO_I }, { 0 MSO_I, 1 MSO_I }
+};
+static const sal_uInt16 mso_sptUpDownArrowSegm[] =
+{
+ 0x4000, 0x0009, 0x6001, 0x8000
+};
+static const sal_Int32 mso_sptUpDownArrowDefault[] =
+{
+ 2, 5400, 4300
+};
+static const SvxMSDffTextRectangles mso_sptUpDownArrowTextRect[] =
+{
+ { { 0 MSO_I, 8 MSO_I }, { 2 MSO_I, 9 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptUpDownArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0x101, 10800, 10800, 0, 10800, 0, 10800 }
+};
+static const mso_CustomShape msoUpDownArrow =
+{
+ (SvxMSDffVertPair*)mso_sptUpDownArrowVert, sizeof( mso_sptUpDownArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptUpDownArrowSegm, sizeof( mso_sptUpDownArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptDoubleArrowCalc, sizeof( mso_sptDoubleArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptUpDownArrowDefault,
+ (SvxMSDffTextRectangles*)mso_sptUpDownArrowTextRect, sizeof( mso_sptUpDownArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptUpDownArrowHandle, sizeof( mso_sptUpDownArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptQuadArrowVert[] = // adjustment1: x 0 - 10800, adjustment2: x 0 - 10800
+{ // adjustment3: y 0 - 10800
+ { 0, 10800 }, { 0 MSO_I, 1 MSO_I }, { 0 MSO_I, 2 MSO_I }, { 2 MSO_I, 2 MSO_I },
+ { 2 MSO_I, 0 MSO_I }, { 1 MSO_I, 0 MSO_I }, { 10800, 0 }, { 3 MSO_I, 0 MSO_I },
+ { 4 MSO_I, 0 MSO_I }, { 4 MSO_I, 2 MSO_I }, { 5 MSO_I, 2 MSO_I }, { 5 MSO_I, 1 MSO_I },
+ { 21600, 10800 }, { 5 MSO_I, 3 MSO_I }, { 5 MSO_I, 4 MSO_I }, { 4 MSO_I, 4 MSO_I },
+ { 4 MSO_I, 5 MSO_I }, { 3 MSO_I, 5 MSO_I }, { 10800, 21600 }, { 1 MSO_I, 5 MSO_I },
+ { 2 MSO_I, 5 MSO_I }, { 2 MSO_I, 4 MSO_I }, { 0 MSO_I, 4 MSO_I }, { 0 MSO_I, 3 MSO_I }
+};
+static const sal_uInt16 mso_sptQuadArrowSegm[] =
+{
+ 0x4000, 0x0017, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptQuadArrowCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjust2Value } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjust3Value } }
+};
+static const sal_Int32 mso_sptQuadArrowDefault[] =
+{
+ 3, 6500, 8600, 4300
+};
+static const SvxMSDffTextRectangles mso_sptQuadArrowTextRect[] = // todo
+{
+ { { 0, 0 }, { 21600, 21600 } }
+};
+static const SvxMSDffHandle mso_sptQuadArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL,
+ 0x101, 0x102, 10800, 10800, 0x100, 10800, 0, 0x100 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x100, 0, 10800, 10800, 0x102, 0x101, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoQuadArrow =
+{
+ (SvxMSDffVertPair*)mso_sptQuadArrowVert, sizeof( mso_sptQuadArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptQuadArrowSegm, sizeof( mso_sptQuadArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptQuadArrowCalc, sizeof( mso_sptQuadArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptQuadArrowDefault,
+ (SvxMSDffTextRectangles*)mso_sptQuadArrowTextRect, sizeof( mso_sptQuadArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptQuadArrowHandle, sizeof( mso_sptQuadArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptLeftRightUpArrowVert[] = // adjustment1: x 0 - 10800, adjustment2: x 0 - 10800
+{ // adjustment3: y 0 - 21600
+ { 10800, 0 }, { 3 MSO_I, 2 MSO_I }, { 4 MSO_I, 2 MSO_I }, { 4 MSO_I, 1 MSO_I },
+ { 5 MSO_I, 1 MSO_I }, { 5 MSO_I, 0 MSO_I }, { 21600, 10800 }, { 5 MSO_I, 3 MSO_I },
+ { 5 MSO_I, 4 MSO_I }, { 2 MSO_I, 4 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 0, 10800 },
+ { 2 MSO_I, 0 MSO_I }, { 2 MSO_I, 1 MSO_I }, { 1 MSO_I, 1 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 0 MSO_I, 2 MSO_I }
+};
+static const sal_uInt16 mso_sptLeftRightUpArrowSegm[] =
+{
+ 0x4000, 0x0010, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptLeftRightUpArrowCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 0
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } }, // 1
+ { 0x6001, { 0x0403, DFF_Prop_adjust3Value, 21600 } }, // 2
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }, // 3
+ { 0x8000, { 21600, 0, DFF_Prop_adjust2Value } }, // 4
+ { 0x8000, { 21600, 0, 0x0402 } } // 5
+};
+static const sal_Int32 mso_sptLeftRightUpArrowDefault[] =
+{
+ 3, 6500, 8600, 6200
+};
+static const SvxMSDffTextRectangles mso_sptLeftRightUpArrowTextRect[] = // todo
+{
+ { { 0, 0 }, { 21600, 21600 } }
+};
+static const SvxMSDffHandle mso_sptLeftRightUpArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL,
+ 0x101, 0x102, 10800, 10800, 0x100, 10800, 0, 0x100 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x100, 0, 10800, 10800, 0x102, 0x101, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoLeftRightUpArrow =
+{
+ (SvxMSDffVertPair*)mso_sptLeftRightUpArrowVert, sizeof( mso_sptLeftRightUpArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptLeftRightUpArrowSegm, sizeof( mso_sptLeftRightUpArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptLeftRightUpArrowCalc, sizeof( mso_sptLeftRightUpArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptLeftRightUpArrowDefault,
+ (SvxMSDffTextRectangles*)mso_sptLeftRightUpArrowTextRect, sizeof( mso_sptLeftRightUpArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptLeftRightUpArrowHandle, sizeof( mso_sptLeftRightUpArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptBentArrowVert[] = // adjustment1 : x 12427 - 21600
+{ // adjustment2 : y 0 - 6079
+ { 0, 21600 }, { 0, 12160 }, { 12427, 1 MSO_I }, { 0 MSO_I, 1 MSO_I },
+ { 0 MSO_I, 0 }, { 21600, 6079 }, { 0 MSO_I, 12158 }, { 0 MSO_I, 2 MSO_I },
+ { 12427, 2 MSO_I }, { 4 MSO_I, 12160 }, { 4 MSO_I, 21600 }
+};
+static const sal_uInt16 mso_sptBentArrowSegm[] =
+{
+ 0x4000, 0x0001, 0xa801, 0x0006, 0xa701, 0x0001, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptBentArrowCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x8000, { 12158, 0, DFF_Prop_adjust2Value } },
+ { 0x8000, { 6079, 0, DFF_Prop_adjust2Value } },
+ { 0x2001, { 0x0403, 2, 1 } }
+};
+static const sal_Int32 mso_sptBentArrowDefault[] =
+{
+ 2, 15100, 2900
+};
+static const SvxMSDffTextRectangles mso_sptBentArrowTextRect[] = // todo
+{
+ { { 0, 0 }, { 21600, 21600 } }
+};
+static const SvxMSDffHandle mso_sptBentArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0x101, 10800, 10800, 12427, 21600, 0, 6079 }
+};
+static const mso_CustomShape msoBentArrow =
+{
+ (SvxMSDffVertPair*)mso_sptBentArrowVert, sizeof( mso_sptBentArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBentArrowSegm, sizeof( mso_sptBentArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBentArrowCalc, sizeof( mso_sptBentArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptBentArrowDefault,
+ (SvxMSDffTextRectangles*)mso_sptBentArrowTextRect, sizeof( mso_sptBentArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptBentArrowHandle, sizeof( mso_sptBentArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptUturnArrowVert[] =
+{
+ { 0, 21600 }, { 0, 8550 }, // pp
+ { 0, 3540 }, { 4370, 0 }, { 9270, 0 }, // ccp
+ { 13890, 0 }, { 18570, 3230 }, { 18600, 8300 }, // ccp
+ { 21600, 8300 }, { 15680, 14260 }, { 9700, 8300 }, { 12500, 8300 }, // pppp
+ { 12320, 6380 }, { 10870, 5850 }, { 9320, 5850 }, // ccp
+ { 7770, 5850 }, { 6040, 6410 }, { 6110, 8520 }, // ccp
+ { 6110, 21600 }
+};
+static const sal_uInt16 mso_sptUturnArrowSegm[] =
+{
+ 0x4000, 0x0001, 0x2002, 0x0004, 0x2002, 0x0001, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptUturnArrowTextRect[] =
+{
+ { { 0, 8280 }, { 6110, 21600 } }
+};
+static const mso_CustomShape msoUturnArrow =
+{
+ (SvxMSDffVertPair*)mso_sptUturnArrowVert, sizeof( mso_sptUturnArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptUturnArrowSegm, sizeof( mso_sptUturnArrowSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptUturnArrowTextRect, sizeof( mso_sptUturnArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptLeftUpArrowVert[] = // adjustment1 : x 0 - 21600, adjustment2 : x 0 - 21600
+{ // adjustment3 : y 0 - 21600
+ { 0, 5 MSO_I }, { 2 MSO_I, 0 MSO_I }, { 2 MSO_I, 7 MSO_I }, { 7 MSO_I, 7 MSO_I },
+ { 7 MSO_I, 2 MSO_I }, { 0 MSO_I, 2 MSO_I }, { 5 MSO_I, 0 }, { 21600, 2 MSO_I },
+ { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 1 MSO_I }, { 2 MSO_I, 1 MSO_I }, { 2 MSO_I, 21600 }
+};
+static const sal_uInt16 mso_sptLeftUpArrowSegm[] =
+{
+ 0x4000, 0x000b, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptLeftUpArrowCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 0
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } }, // 1
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } }, // 2
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }, // 3
+ { 0x2001, { 0x0403, 1, 2 } }, // 4
+ { 0x6000, { DFF_Prop_adjustValue, 0x0404, 0 } }, // 5
+ { 0x8000, { 21600, 0, DFF_Prop_adjust2Value } }, // 6
+ { 0x6000, { DFF_Prop_adjustValue, 0x0406, 0 } }, // 7
+ { 0x8000, { 21600, 0, 0x406 } }, // 8
+ { 0xa000, { 0x408, 0, 0x406 } } // 9
+};
+static const sal_Int32 mso_sptLeftUpArrowDefault[] =
+{
+ 3, 9340, 18500, 6200
+};
+static const SvxMSDffTextRectangles mso_sptLeftUpArrowTextRect[] =
+{
+ { { 2 MSO_I, 7 MSO_I }, { 1 MSO_I, 1 MSO_I } },
+ { { 7 MSO_I, 2 MSO_I }, { 1 MSO_I, 1 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptLeftUpArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL,
+ 0x101, 0x102, 10800, 10800, 3 + 5, 21600, 0, 0x100 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x100, 0, 10800, 10800, 0x102, 3 + 9, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoLeftUpArrow =
+{
+ (SvxMSDffVertPair*)mso_sptLeftUpArrowVert, sizeof( mso_sptLeftUpArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptLeftUpArrowSegm, sizeof( mso_sptLeftUpArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptLeftUpArrowCalc, sizeof( mso_sptLeftUpArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptLeftUpArrowDefault,
+ (SvxMSDffTextRectangles*)mso_sptLeftUpArrowTextRect, sizeof( mso_sptLeftUpArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptLeftUpArrowHandle, sizeof( mso_sptLeftUpArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptBentUpArrowVert[] = // adjustment1 : x 0 - 21600, adjustment2 : x 0 - 21600
+{ // adjustment3 : y 0 - 21600
+ { 0, 8 MSO_I }, { 7 MSO_I, 8 MSO_I }, { 7 MSO_I, 2 MSO_I }, { 0 MSO_I, 2 MSO_I },
+ { 5 MSO_I, 0 }, { 21600, 2 MSO_I }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 21600 },
+ { 0, 21600 }
+};
+static const sal_uInt16 mso_sptBentUpArrowSegm[] =
+{
+ 0x4000, 0x0008, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptBentUpArrowCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 0
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } }, // 1
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } }, // 2
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }, // 3
+ { 0x2001, { 0x0403, 1, 2 } }, // 4
+ { 0x6000, { DFF_Prop_adjustValue, 0x0404, 0 } }, // 5
+ { 0x8000, { 21600, 0, DFF_Prop_adjust2Value } }, // 6
+ { 0x6000, { DFF_Prop_adjustValue, 0x0406, 0 } }, // 7
+ { 0x6000, { 0x0407, 0x0406, 0 } }, // 8
+ { 0x8000, { 21600, 0, 0x406 } }, // 9
+ { 0xa000, { 0x409, 0, 0x406 } } // a
+};
+static const sal_Int32 mso_sptBentUpArrowDefault[] =
+{
+ 3, 9340, 18500, 7200
+};
+static const SvxMSDffTextRectangles mso_sptBentUpArrowTextRect[] =
+{
+ { { 2 MSO_I, 7 MSO_I }, { 1 MSO_I, 1 MSO_I } },
+ { { 7 MSO_I, 2 MSO_I }, { 1 MSO_I, 1 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptBentUpArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL,
+ 0x101, 0x102, 10800, 10800, 3 + 5, 21600, 0, 0x100 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x100, 0, 10800, 10800, 0x102, 3 + 10, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoBentUpArrow =
+{
+ (SvxMSDffVertPair*)mso_sptBentUpArrowVert, sizeof( mso_sptBentUpArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBentUpArrowSegm, sizeof( mso_sptBentUpArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBentUpArrowCalc, sizeof( mso_sptBentUpArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptBentUpArrowDefault,
+ (SvxMSDffTextRectangles*)mso_sptBentUpArrowTextRect, sizeof( mso_sptBentUpArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptBentUpArrowHandle, sizeof( mso_sptBentUpArrowHandle ) / sizeof( SvxMSDffHandle )
+};
+
+
+static const SvxMSDffVertPair mso_sptCurvedDownVert[] =
+{
+ { 0, 0 }, { 3 MSO_I, 21 MSO_I }, { 0, 21600 }, { 4 MSO_I, 0 },
+ { 0, 0 }, { 3 MSO_I, 21 MSO_I }, { 4 MSO_I, 0 }, { 17 MSO_I, 24 MSO_I },
+ { 15 MSO_I, 0 }, { 1 MSO_I, 21 MSO_I }, { 17 MSO_I, 24 MSO_I }, { 15 MSO_I, 21600 },
+ { 15 MSO_I, 0 }, { 1 MSO_I, 21 MSO_I }, { 7 MSO_I, 0 }, { 13 MSO_I, 2 MSO_I },
+ { 14 MSO_I, 2 MSO_I }, { 8 MSO_I, 21600 }, { 12 MSO_I, 2 MSO_I },
+ { 0, 0 }, { 3 MSO_I, 21 MSO_I }, { 11 MSO_I, 2 MSO_I }, { 17 MSO_I, 24 MSO_I },
+ { 0, 0 }, { 3 MSO_I, 21 MSO_I }, { 17 MSO_I, 24 MSO_I }, { 4 MSO_I, 0 }
+};
+static const sal_uInt16 mso_sptCurvedDownSegm[] =
+{
+ 0xa508,
+ 0xa304,
+ 0x6000,
+ 0x8000,
+ 0xa604,
+ 0x0003,
+ 0xa308,
+ 0x6000,
+ 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCurvedDownCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0xa000, { DFF_Prop_adjustValue, 21600, DFF_Prop_adjust2Value } },
+ { 0x2001, { 0x403, 1, 2 } },
+ { 0x6000, { DFF_Prop_adjust2Value, DFF_Prop_adjust2Value, 21600 } },
+ { 0xe000, { 0x405, DFF_Prop_adjust2Value, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x406, 1, 2 } },
+ { 0x4002, { 21600, DFF_Prop_adjustValue, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjust3Value } },
+ { 0xa00f, { 0x409, 21600, 0x404 } },
+ { 0x6000, { 0x404, 0x40a, 0 } },
+ { 0x6000, { 0x40b, DFF_Prop_adjust2Value, 21600 } },
+ { 0x6000, { 0x407, 0x40a, 0 } },
+ { 0xa000, { 0x40c, 21600, DFF_Prop_adjustValue } },
+ { 0xa000, { 0x405, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x40f, 1, 2 } },
+ { 0x6002, { 0x404, 0x407, 0 } },
+ { 0x6000, { DFF_Prop_adjustValue, DFF_Prop_adjust2Value, 21600 } },
+ { 0x2001, { 0x412, 1, 2 } },
+ { 0xa000, { 0x411, 0, 0x413 } },
+ { 0x0001, { 21600, 2, 1 } },
+ { 0xa000, { 0x411, 0, 0x404 } },
+ { 0x600f, { 0x416, 0x404, 21600 } },
+ { 0x8000, { 21600, 0, 0x417 } },
+ { 0x2000, { 0x408, 128, 0 } },
+ { 0x2001, { 0x405, 1, 2 } },
+ { 0x2000, { 0x405, 0, 128 } },
+ { 0xe000, { DFF_Prop_adjustValue, 0x411, 0x40c } },
+ { 0x600f, { 0x414, 0x404, 21600 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x41e, 1, 2 } },
+ { 0x0001, { 21600, 21600, 1 } },
+ { 0x6001, { 0x409, 0x409, 1 } },
+ { 0xa000, { 0x420, 0, 0x421 } },
+ { 0x200d, { 0x422, 0, 0 } },
+ { 0x2000, { 0x423, 21600, 0 } },
+ { 0x8001, { 21600, 21600, 0x424 } },
+ { 0x2000, { 0x425, 64, 0 } },
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } },
+ { 0x600f, { 0x41f, 0x427, 21600 } },
+ { 0x8000, { 21600, 0, 0x428 } },
+ { 0x2000, { 0x429, 64, 0 } },
+ { 0x2001, { 0x404, 1, 2 } },
+ { 0xa000, { DFF_Prop_adjust2Value, 0, 0x42b } },
+ { 0x0001, { 21600, 2195, 16384 } },
+ { 0x0001, { 21600, 14189, 16384 } }
+};
+static const sal_Int32 mso_sptCurvedDownDefault[] =
+{
+ 3, 12960, 19440, 14400
+};
+static const SvxMSDffTextRectangles mso_sptCurvedDownTextRect[] =
+{
+ { { 43 MSO_I, 45 MSO_I }, { 44 MSO_I, 46 MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptCurvedDownGluePoints[] =
+{
+ { 17 MSO_I, 0 }, { 16 MSO_I, 21600 }, { 12 MSO_I, 2 MSO_I }, { 8 MSO_I, 21600 }, { 14 MSO_I, 2 MSO_I }
+};
+static const SvxMSDffHandle mso_sptCurvedDownHandles[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x100, 21600, 10800, 10800, 3 + 0x26, 3 + 0x1b, 0, 10800 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL,
+ 0x101, 21600, 10800, 10800, 3 + 0x19, 21600, 0, 10800 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL,
+ 21600, 0x102, 10800, 10800, 3375, 21600, 3 + 0x2a, 21600 }
+};
+static const mso_CustomShape msoCurvedDownArrow =
+{
+ (SvxMSDffVertPair*)mso_sptCurvedDownVert, sizeof( mso_sptCurvedDownVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCurvedDownSegm, sizeof( mso_sptCurvedDownSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCurvedDownCalc, sizeof( mso_sptCurvedDownCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCurvedDownDefault,
+ (SvxMSDffTextRectangles*)mso_sptCurvedDownTextRect, sizeof( mso_sptCurvedDownTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptCurvedDownGluePoints, sizeof( mso_sptCurvedDownGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptCurvedDownHandles, sizeof( mso_sptCurvedDownHandles ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptCurvedUpVert[] =
+{
+ { 0, 22 MSO_I }, { 3 MSO_I, 21 MSO_I }, { 0, 0 }, { 4 MSO_I, 21 MSO_I },
+ { 14 MSO_I, 22 MSO_I }, { 1 MSO_I, 21 MSO_I }, { 7 MSO_I, 21 MSO_I }, { 12 MSO_I, 2 MSO_I },
+ { 13 MSO_I, 2 MSO_I }, { 8 MSO_I, 0 }, { 11 MSO_I, 2 MSO_I },
+ { 0, 22 MSO_I }, { 3 MSO_I, 21 MSO_I }, { 10 MSO_I, 2 MSO_I }, { 16 MSO_I, 24 MSO_I },
+ { 14 MSO_I, 22 MSO_I }, { 1 MSO_I, 21 MSO_I }, { 16 MSO_I, 24 MSO_I }, { 14 MSO_I, 0 },
+ { 14 MSO_I, 22 MSO_I }, { 1 MSO_I, 21 MSO_I }, { 7 MSO_I, 21 MSO_I }, { 16 MSO_I, 24 MSO_I }
+};
+static const sal_uInt16 mso_sptCurvedUpSegm[] =
+{
+ 0xa408,
+ 0x0003,
+ 0xa508,
+ 0x6000,
+ 0x8000,
+ 0xa604,
+ 0xaa00,
+ 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCurvedUpCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0xa000, { DFF_Prop_adjustValue, 21600, DFF_Prop_adjust2Value } },
+ { 0x2001, { 0x403, 1, 2 } },
+ { 0x6000, { DFF_Prop_adjust2Value, DFF_Prop_adjust2Value, 21600 } },
+ { 0xe000, { 0x405, DFF_Prop_adjust2Value, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x406, 1, 2 } },
+ { 0x4002, { 21600, DFF_Prop_adjustValue, 0 } },
+ { 0xa00f, { DFF_Prop_adjust3Value, 21600, 0x404 } },
+ { 0x6000, { 0x404, 0x409, 0 } },
+ { 0x6000, { 0x40a, DFF_Prop_adjust2Value, 21600 } },
+ { 0x6000, { 0x407, 0x409, 0 } },
+ { 0xa000, { 0x40b, 21600, DFF_Prop_adjustValue } },
+ { 0xa000, { 0x405, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x40e, 1, 2 } },
+ { 0x6002, { 0x404, 0x407, 0 } },
+ { 0x6000, { DFF_Prop_adjustValue, DFF_Prop_adjust2Value, 21600 } },
+ { 0x2001, { 0x411, 1, 2 } },
+ { 0xa000, { 0x410, 0, 0x412 } },
+ { 0x0000, { 21600, 0, 0 } },
+ { 0x0000, { 21600, 0, 0 } },
+ { 0x0000, { 0, 0, 21600 } },
+ { 0xa000, { 0x410, 0, 0x404 } },
+ { 0x600f, { 0x417, 0x404, 21600 } },
+ { 0x2000, { 0x408, 128, 0 } },
+ { 0x2001, { 0x405, 1, 2 } },
+ { 0x2000, { 0x405, 0, 128 } },
+ { 0xe000, { DFF_Prop_adjustValue, 0x410, 0x40b } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x41d, 1, 2 } },
+ { 0x0001, { 21600, 21600, 1 } },
+ { 0x6001, { DFF_Prop_adjust3Value, DFF_Prop_adjust3Value, 1 } },
+ { 0xa000, { 0x41f, 0, 0x420 } },
+ { 0x200d, { 0x421, 0, 0 } },
+ { 0x2000, { 0x422, 21600, 0 } },
+ { 0x8001, { 21600, 21600, 0x423 } },
+ { 0x2000, { 0x424, 64, 0 } },
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } },
+ { 0x600f, { 0x41e, 0x426, 21600 } },
+ { 0x2000, { 0x427, 0, 64 } },
+ { 0x2001, { 0x404, 1, 2 } },
+ { 0xa000, { DFF_Prop_adjust2Value, 0, 0x429 } },
+ { 0x0001, { 21600, 2195, 16384 } },
+ { 0x0001, { 21600, 14189, 16384 } }
+};
+static const sal_Int32 mso_sptCurvedUpDefault[] =
+{
+ 3, 12960, 19440, 7200
+};
+static const SvxMSDffTextRectangles mso_sptCurvedUpTextRect[] =
+{
+ { { 41 MSO_I, 43 MSO_I }, { 42 MSO_I, 44 MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptCurvedUpGluePoints[] =
+{
+ { 8 MSO_I, 0 }, { 11 MSO_I, 2 MSO_I }, { 15 MSO_I, 0 }, { 16 MSO_I, 21 MSO_I }, { 13 MSO_I, 2 MSO_I }
+};
+static const SvxMSDffHandle mso_sptCurvedUpHandles[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x100, 0, 10800, 10800, 3 + 37, 3 + 27, 0, 10800 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x101, 0, 10800, 10800, 3 + 25, 3 + 20, 0, 10800 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 21600, 0x102, 10800, 10800, 3375, 21600, 0, 3 + 40 }
+};
+static const mso_CustomShape msoCurvedUpArrow =
+{
+ (SvxMSDffVertPair*)mso_sptCurvedUpVert, sizeof( mso_sptCurvedUpVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCurvedUpSegm, sizeof( mso_sptCurvedUpSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCurvedUpCalc, sizeof( mso_sptCurvedUpCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCurvedUpDefault,
+ (SvxMSDffTextRectangles*)mso_sptCurvedUpTextRect, sizeof( mso_sptCurvedUpTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptCurvedUpGluePoints, sizeof( mso_sptCurvedUpGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptCurvedUpHandles, sizeof( mso_sptCurvedUpHandles ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptCurvedRightVert[] =
+{
+ { 0, 0 }, { 23 MSO_I, 3 MSO_I }, { 22 MSO_I, 0 }, { 0, 4 MSO_I }, { 0, 15 MSO_I }, { 23 MSO_I, 1 MSO_I }, { 0, 7 MSO_I }, { 2 MSO_I, 13 MSO_I },
+ { 2 MSO_I, 14 MSO_I }, { 22 MSO_I, 8 MSO_I }, { 2 MSO_I, 12 MSO_I },
+ { 0, 0 }, { 23 MSO_I, 3 MSO_I }, { 2 MSO_I, 11 MSO_I }, { 26 MSO_I, 17 MSO_I }, { 0, 15 MSO_I }, { 23 MSO_I, 1 MSO_I }, { 26 MSO_I, 17 MSO_I }, { 22 MSO_I, 15 MSO_I },
+ { 0, 0 }, { 23 MSO_I, 3 MSO_I }, { 0, 4 MSO_I }, { 26 MSO_I, 17 MSO_I }
+};
+static const sal_uInt16 mso_sptCurvedRightSegm[] =
+{
+ 0xa408,
+ 0x0003,
+ 0xa508,
+ 0x6000,
+ 0x8000,
+ 0xa404,
+ 0xaa00,
+ 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCurvedRightCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0xa000, { DFF_Prop_adjustValue, 21600, DFF_Prop_adjust2Value } },
+ { 0x2001, { 0x403, 1, 2 } },
+ { 0x6000, { DFF_Prop_adjust2Value, DFF_Prop_adjust2Value, 21600 } },
+ { 0xe000, { 0x405, DFF_Prop_adjust2Value, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x406, 1, 2 } },
+ { 0x4002, { 21600, DFF_Prop_adjustValue, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjust3Value } },
+ { 0xa00f, { 0x409, 21600, 0x404 } },
+ { 0x6000, { 0x404, 0x40a, 0 } },
+ { 0x6000, { 0x40b, DFF_Prop_adjust2Value, 21600 } },
+ { 0x6000, { 0x407, 0x40a, 0 } },
+ { 0xa000, { 0x40c, 21600, DFF_Prop_adjustValue } },
+ { 0xa000, { 0x405, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x40f, 1, 2 } },
+ { 0x6002, { 0x404, 0x407, 0 } },
+ { 0x6000, { DFF_Prop_adjustValue, DFF_Prop_adjust2Value, 21600 } },
+ { 0x2001, { 0x412, 1, 2 } },
+ { 0xa000, { 0x411, 0, 0x413 } },
+ { 0x0000, { 21600, 0, 0 } },
+ { 0x0000, { 21600, 0, 0 } },
+ { 0x0001, { 21600, 2, 1 } },
+ { 0xa000, { 0x411, 0, 0x404 } },
+ { 0x600f, { 0x418, 0x404, 21600 } },
+ { 0x8000, { 21600, 0, 0x419 } },
+ { 0x2000, { 0x408, 128, 0 } },
+ { 0x2001, { 0x405, 1, 2 } },
+ { 0x2000, { 0x405, 0, 128 } },
+ { 0xe000, { DFF_Prop_adjustValue, 0x411, 0x40c } },
+ { 0x600f, { 0x414, 0x404, 21600 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x420, 1, 2 } },
+ { 0x0001, { 21600, 21600, 1 } },
+ { 0x6001, { 0x409, 0x409, 1 } },
+ { 0xa000, { 0x422, 0, 0x423 } },
+ { 0x200d, { 0x424, 0, 0 } },
+ { 0x2000, { 0x425, 21600, 0 } },
+ { 0x8001, { 21600, 21600, 0x426 } },
+ { 0x2000, { 0x427, 64, 0 } },
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } },
+ { 0x600f, { 0x421, 0x429, 21600 } },
+ { 0x8000, { 21600, 0, 0x42a } },
+ { 0x2000, { 0x42b, 64, 0 } },
+ { 0x2001, { 0x404, 1, 2 } },
+ { 0xa000, { DFF_Prop_adjust2Value, 0, 0x42d } },
+ { 0x0001, { 21600, 2195, 16384 } },
+ { 0x0001, { 21600, 14189, 16384 } }
+};
+static const sal_Int32 mso_sptCurvedRightDefault[] =
+{
+ 3, 12960, 19440, 14400
+};
+static const SvxMSDffTextRectangles mso_sptCurvedRightTextRect[] =
+{
+ { { 47 MSO_I, 45 MSO_I }, { 48 MSO_I, 46 MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptCurvedRightGluePoints[] =
+{
+ { 0, 17 MSO_I }, { 2 MSO_I, 14 MSO_I }, { 22 MSO_I, 8 MSO_I }, { 2 MSO_I, 12 MSO_I }, { 22 MSO_I, 16 MSO_I }
+};
+static const SvxMSDffHandle mso_sptCurvedRightHandles[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 21600, 0x100, 10800, 10800, 0, 10800, 3 + 40, 3 + 29 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 21600, 0x101, 10800, 10800, 0, 10800, 3 + 27, 3 + 21 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x102, 21600, 10800, 10800, 3 + 44, 3 + 22, 3375, 21600 }
+};
+static const mso_CustomShape msoCurvedRightArrow =
+{
+ (SvxMSDffVertPair*)mso_sptCurvedRightVert, sizeof( mso_sptCurvedRightVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCurvedRightSegm, sizeof( mso_sptCurvedRightSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCurvedRightCalc, sizeof( mso_sptCurvedRightCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCurvedRightDefault,
+ (SvxMSDffTextRectangles*)mso_sptCurvedRightTextRect, sizeof( mso_sptCurvedRightTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptCurvedRightGluePoints, sizeof( mso_sptCurvedRightGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptCurvedRightHandles, sizeof( mso_sptCurvedRightHandles ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptCurvedLeftVert[] =
+{
+ { 22 MSO_I, 0 }, { 21 MSO_I, 3 MSO_I }, { 0, 0 }, { 21 MSO_I, 4 MSO_I }, { 22 MSO_I, 14 MSO_I }, { 21 MSO_I, 1 MSO_I }, { 21 MSO_I, 7 MSO_I }, { 2 MSO_I, 12 MSO_I },
+ { 2 MSO_I, 13 MSO_I }, { 0, 8 MSO_I }, { 2 MSO_I, 11 MSO_I },
+ { 22 MSO_I, 0 }, { 21 MSO_I, 3 MSO_I }, { 2 MSO_I, 10 MSO_I }, { 24 MSO_I, 16 MSO_I }, { 22 MSO_I, 14 MSO_I }, { 21 MSO_I, 1 MSO_I }, { 24 MSO_I, 16 MSO_I }, { 0, 14 MSO_I },
+ { 22 MSO_I, 14 MSO_I }, { 21 MSO_I, 1 MSO_I }, { 21 MSO_I, 7 MSO_I }, { 24 MSO_I, 16 MSO_I }
+};
+static const sal_uInt16 mso_sptCurvedLeftSegm[] =
+{
+ 0xa608,
+ 0x0003,
+ 0xa308,
+ 0x6000,
+ 0x8000,
+ 0xa404,
+ 0xaa00,
+ 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCurvedLeftCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0xa000, { DFF_Prop_adjustValue, 21600, DFF_Prop_adjust2Value } },
+ { 0x2001, { 0x403, 1, 2 } },
+ { 0x6000, { DFF_Prop_adjust2Value, DFF_Prop_adjust2Value, 21600 } },
+ { 0xe000, { 0x405, DFF_Prop_adjust2Value, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x406, 1, 2 } },
+ { 0x4002, { 21600, DFF_Prop_adjustValue, 0 } },
+ { 0xa00f, { DFF_Prop_adjust3Value, 21600, 0x404 } },
+ { 0x6000, { 0x404, 0x409, 0 } },
+ { 0x6000, { 0x40a, DFF_Prop_adjust2Value, 21600 } },
+ { 0x6000, { 0x407, 0x409, 0 } },
+ { 0xa000, { 0x40b, 21600, DFF_Prop_adjustValue } },
+ { 0xa000, { 0x405, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x40e, 1, 2 } },
+ { 0x6002, { 0x404, 0x407, 0 } },
+ { 0x6000, { DFF_Prop_adjustValue, DFF_Prop_adjust2Value, 21600 } },
+ { 0x2001, { 0x411, 1, 2 } },
+ { 0xa000, { 0x410, 0, 0x412 } },
+ { 0x0000, { 21600, 0, 0 } },
+ { 0x0000, { 21600, 0, 0 } },
+ { 0x0000, { 0, 0, 21600 } },
+ { 0xa000, { 0x410, 0, 0x404 } },
+ { 0x600f, { 0x417, 0x404, 21600 } },
+ { 0x2000, { 0x408, 128, 0 } },
+ { 0x2001, { 0x405, 1, 2 } },
+ { 0x2000, { 0x405, 0, 128 } },
+ { 0xe000, { DFF_Prop_adjustValue, 0x410, 0x40b } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x41d, 1, 2 } },
+ { 0x0001, { 21600, 21600, 1 } },
+ { 0x6001, { DFF_Prop_adjust3Value, DFF_Prop_adjust3Value, 1 } },
+ { 0xa000, { 0x41f, 0, 0x420 } },
+ { 0x200d, { 0x421, 0, 0 } },
+ { 0x2000, { 0x422, 21600, 0 } },
+ { 0x8001, { 21600, 21600, 0x423 } },
+ { 0x2000, { 0x424, 64, 0 } },
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } },
+ { 0x600f, { 0x41e, 0x426, 21600 } },
+ { 0x2000, { 0x427, 0, 64 } },
+ { 0x2001, { 0x404, 1, 2 } },
+ { 0xa000, { DFF_Prop_adjust2Value, 0, 0x429 } },
+ { 0x0001, { 21600, 2195, 16384 } },
+ { 0x0001, { 21600, 14189, 16384 } }
+};
+static const sal_Int32 mso_sptCurvedLeftDefault[] =
+{
+ 3, 12960, 19440, 7200
+};
+static const SvxMSDffTextRectangles mso_sptCurvedLeftTextRect[] =
+{
+ { { 43 MSO_I, 41 MSO_I }, { 44 MSO_I, 42 MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptCurvedLeftGluePoints[] =
+{
+ { 0, 15 MSO_I }, { 2 MSO_I, 11 MSO_I }, { 0, 8 MSO_I }, { 2 MSO_I, 13 MSO_I }, { 21 MSO_I, 16 MSO_I }
+};
+static const SvxMSDffHandle mso_sptCurvedLeftHandles[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0, 0x100, 10800, 10800, 0, 10800, 3 + 37, 3 + 27 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0, 0x101, 10800, 10800, 0, 10800, 3 + 25, 3 + 20 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x102, 21600, 10800, 10800, 0, 3 + 40, 3375, 21600 }
+};
+static const mso_CustomShape msoCurvedLeftArrow =
+{
+ (SvxMSDffVertPair*)mso_sptCurvedLeftVert, sizeof( mso_sptCurvedLeftVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCurvedLeftSegm, sizeof( mso_sptCurvedLeftSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCurvedLeftCalc, sizeof( mso_sptCurvedLeftCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCurvedLeftDefault,
+ (SvxMSDffTextRectangles*)mso_sptCurvedLeftTextRect, sizeof( mso_sptCurvedLeftTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptCurvedLeftGluePoints, sizeof( mso_sptCurvedLeftGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptCurvedLeftHandles, sizeof( mso_sptCurvedLeftHandles ) / sizeof( SvxMSDffHandle )
+};
+
+
+
+
+
+static const SvxMSDffVertPair mso_sptStripedRightArrowVert[] = // adjustment1 : x 3375 - 21600
+{ // adjustment2 : y 0 - 10800
+ { 3375, 0 MSO_I }, { 1 MSO_I, 0 MSO_I }, { 1 MSO_I, 0 }, { 21600, 10800 },
+ { 1 MSO_I, 21600 }, { 1 MSO_I, 2 MSO_I }, { 3375, 2 MSO_I }, { 0, 0 MSO_I },
+ { 675, 0 MSO_I }, { 675, 2 MSO_I }, { 0, 2 MSO_I }, { 1350, 0 MSO_I },
+ { 2700, 0 MSO_I }, { 2700, 2 MSO_I }, { 1350, 2 MSO_I }
+};
+static const sal_uInt16 mso_sptStripedRightArrowSegm[] =
+{
+ 0x4000, 0x0006, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptStripedRightArrowCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjust2Value } },
+ { 0x8000, { 21600, 0, 0x401 } },
+ { 0x6001, { 0x403, 0x400, 10800 } },
+ { 0x6000, { 0x401, 0x404, 0 } }
+};
+static const SvxMSDffTextRectangles mso_sptStripedRightArrowTextRect[] =
+{
+ { { 3375, 0 MSO_I }, { 5 MSO_I, 2 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptStripedRightArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0x101, 10800, 10800, 3375, 21600, 0, 10800 }
+};
+static const mso_CustomShape msoStripedRightArrow =
+{
+ (SvxMSDffVertPair*)mso_sptStripedRightArrowVert, sizeof( mso_sptStripedRightArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptStripedRightArrowSegm, sizeof( mso_sptStripedRightArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptStripedRightArrowCalc, sizeof( mso_sptStripedRightArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault16200and5400,
+ (SvxMSDffTextRectangles*)mso_sptStripedRightArrowTextRect, sizeof( mso_sptStripedRightArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptStripedRightArrowHandle, sizeof( mso_sptStripedRightArrowHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptNotchedRightArrowVert[] = // adjustment1 : x 0 - 21600 (default 16200)
+{ // adjustment2 : y 0 - 10800 (default 5400)
+ { 0, 1 MSO_I }, { 0 MSO_I, 1 MSO_I }, { 0 MSO_I, 0 }, { 21600, 10800 },
+ { 0 MSO_I, 21600 }, { 0 MSO_I, 2 MSO_I }, { 0, 2 MSO_I }, { 5 MSO_I, 10800 }, { 0, 1 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptNotchedRightArrowCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjust2Value } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjust2Value } },
+ { 0x6001, { 0x403, 0x404, 10800 } }
+};
+static const SvxMSDffTextRectangles mso_sptNotchedRightArrowTextRect[] = // todo
+{
+ { { 0, 0 }, { 21600, 21600 } }
+};
+static const SvxMSDffHandle mso_sptNotchedRightArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0x101, 10800, 10800, 0, 21600, 0, 10800 }
+};
+static const mso_CustomShape msoNotchedRightArrow =
+{
+ (SvxMSDffVertPair*)mso_sptNotchedRightArrowVert, sizeof( mso_sptNotchedRightArrowVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ (SvxMSDffCalculationData*)mso_sptNotchedRightArrowCalc, sizeof( mso_sptNotchedRightArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault16200and5400,
+ (SvxMSDffTextRectangles*)mso_sptNotchedRightArrowTextRect, sizeof( mso_sptNotchedRightArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptNotchedRightArrowHandle, sizeof( mso_sptNotchedRightArrowHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptHomePlateVert[] = // adjustment1 : x 0 - 21600
+{
+ { 0, 0 }, { 0 MSO_I, 0 }, { 21600, 10800 }, { 0 MSO_I, 21600 },
+ { 0, 21600 }
+};
+static const sal_uInt16 mso_sptHomePlateSegm[] =
+{
+ 0x4000, 0x0004, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptHomePlateCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }
+};
+static const sal_Int32 mso_sptHomePlateDefault[] =
+{
+ 1, 16200
+};
+static const SvxMSDffTextRectangles mso_sptHomePlateTextRect[] = // todo
+{
+ { { 0, 0 }, { 21600, 21600 } }
+};
+static const SvxMSDffHandle mso_sptHomePlateHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0, 10800, 10800, 0, 21600, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoHomePlate =
+{
+ (SvxMSDffVertPair*)mso_sptHomePlateVert, sizeof( mso_sptHomePlateVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptHomePlateSegm, sizeof( mso_sptHomePlateSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptHomePlateCalc, sizeof( mso_sptHomePlateCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptHomePlateDefault,
+ (SvxMSDffTextRectangles*)mso_sptHomePlateTextRect, sizeof( mso_sptHomePlateTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptHomePlateHandle, sizeof( mso_sptHomePlateHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptChevronVert[] = // adjustment1 : x 0 - 21600
+{
+ { 0, 0 }, { 0 MSO_I, 0 }, { 21600, 10800 }, { 0 MSO_I, 21600 },
+ { 0, 21600 }, { 1 MSO_I, 10800 }
+};
+static const sal_uInt16 mso_sptChevronSegm[] =
+{
+ 0x4000, 0x0005, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptChevronCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, 0x0400 } }
+};
+static const sal_Int32 mso_sptChevronDefault[] =
+{
+ 1, 16200
+};
+static const SvxMSDffTextRectangles mso_sptChevronTextRect[] = // todo
+{
+ { { 0, 0 }, { 21600, 21600 } }
+};
+static const SvxMSDffHandle mso_sptChevronHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0, 10800, 10800, 0, 21600, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoChevron =
+{
+ (SvxMSDffVertPair*)mso_sptChevronVert, sizeof( mso_sptChevronVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptChevronSegm, sizeof( mso_sptChevronSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptChevronCalc, sizeof( mso_sptChevronCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptChevronDefault,
+ (SvxMSDffTextRectangles*)mso_sptChevronTextRect, sizeof( mso_sptChevronTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptChevronHandle, sizeof( mso_sptChevronHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptRightArrowCalloutVert[] = // adjustment1 : x 0 - 21000
+{ // adjustment2 : y 0 - 10800
+ { 0, 0 }, { 0 MSO_I, 0 }, { 0 MSO_I, 3 MSO_I }, { 2 MSO_I, 3 MSO_I },
+ { 2 MSO_I, 1 MSO_I }, { 21600, 10800 }, { 2 MSO_I, 4 MSO_I }, { 2 MSO_I, 5 MSO_I },
+ { 0 MSO_I, 5 MSO_I }, { 0 MSO_I, 21600 }, { 0, 21600 }
+};
+static const sal_uInt16 mso_sptRightArrowCalloutSegm[] =
+{
+ 0x4000, 0x000a, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptRightArrowCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust4Value, 0, 0 } },
+ { 0x8000, { 21600, 0, 0x0401 } },
+ { 0x8000, { 21600, 0, 0x0403 } }
+};
+static const sal_Int32 mso_sptRightArrowCalloutDefault[] =
+{
+ 4, 14400, 5400, 18000, 8100
+};
+static const SvxMSDffTextRectangles mso_sptRightArrowCalloutTextRect[] =
+{
+ { { 0, 0 }, { 0 MSO_I, 21600 } }
+};
+static const SvxMSDffHandle mso_sptRightArrowCalloutHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x100, 0, 10800, 10800, 0, 0x102, 0x80000000, 0x7fffffff },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL,
+ 0x102, 0x103, 10800, 10800, 0x100, 21600, 0x101, 10800 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 1, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 0, 0x103 }
+};
+static const mso_CustomShape msoRightArrowCallout =
+{
+ (SvxMSDffVertPair*)mso_sptRightArrowCalloutVert, sizeof( mso_sptRightArrowCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptRightArrowCalloutSegm, sizeof( mso_sptRightArrowCalloutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptRightArrowCalloutCalc, sizeof( mso_sptRightArrowCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptRightArrowCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptRightArrowCalloutTextRect, sizeof( mso_sptRightArrowCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptRightArrowCalloutHandle, sizeof( mso_sptRightArrowCalloutHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptLeftArrowCalloutVert[] = // adjustment1 : x 0 - 21600, adjustment2 : y 0 - 10800
+{ // adjustment3 : x 0 - 21600, adjustment4 : y 0 - 10800
+ { 0 MSO_I, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0 MSO_I, 21600 },
+ { 0 MSO_I, 5 MSO_I }, { 2 MSO_I, 5 MSO_I }, { 2 MSO_I, 4 MSO_I }, { 0, 10800 },
+ { 2 MSO_I, 1 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 0 MSO_I, 3 MSO_I }
+};
+static const sal_uInt16 mso_sptLeftArrowCalloutSegm[] =
+{
+ 0x4000, 0x000a, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptLeftArrowCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust4Value, 0, 0 } },
+ { 0x8000, { 21600, 0, 0x0401 } },
+ { 0x8000, { 21600, 0, 0x0403 } }
+};
+static const sal_Int32 mso_sptLeftArrowCalloutDefault[] =
+{
+ 4, 7200, 5400, 3600, 8100
+};
+static const SvxMSDffTextRectangles mso_sptLeftArrowCalloutTextRect[] =
+{
+ { { 0 MSO_I, 0 }, { 21600, 21600 } }
+};
+static const SvxMSDffHandle mso_sptLeftArrowCalloutHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL,
+ 0x100, 0, 10800, 10800, 0x102, 21600, 0x80000000, 0x7fffffff },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL,
+ 0x102, 0x103, 10800, 10800, 0, 0x100, 0x101, 10800 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 0, 0x103 }
+};
+static const mso_CustomShape msoLeftArrowCallout =
+{
+ (SvxMSDffVertPair*)mso_sptLeftArrowCalloutVert, sizeof( mso_sptLeftArrowCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptLeftArrowCalloutSegm, sizeof( mso_sptLeftArrowCalloutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptLeftArrowCalloutCalc, sizeof( mso_sptLeftArrowCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptLeftArrowCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptLeftArrowCalloutTextRect, sizeof( mso_sptLeftArrowCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptLeftArrowCalloutHandle, sizeof( mso_sptLeftArrowCalloutHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptUpArrowCalloutVert[] =
+{
+ { 21600, 0 MSO_I }, { 21600, 21600 }, { 0, 21600 }, { 0, 0 MSO_I },
+ { 3 MSO_I, 0 MSO_I }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I }, { 10800, 0 },
+ { 4 MSO_I, 2 MSO_I }, { 5 MSO_I, 2 MSO_I }, { 5 MSO_I, 0 MSO_I }
+};
+static const sal_uInt16 mso_sptUpArrowCalloutSegm[] =
+{
+ 0x4000, 0x000a, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptUpArrowCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust4Value, 0, 0 } },
+ { 0x8000, { 21600, 0, 0x0401 } },
+ { 0x8000, { 21600, 0, 0x0403 } }
+};
+static const sal_Int32 mso_sptUpArrowCalloutDefault[] =
+{
+ 4, 7200, 5400, 3600, 8100
+};
+static const SvxMSDffTextRectangles mso_sptUpArrowCalloutTextRect[] =
+{
+ { { 0, 0 MSO_I }, { 21600, 21600 } }
+};
+static const SvxMSDffHandle mso_sptUpArrowCalloutHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0x102, 21600 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0x103, 0x102, 10800, 10800, 0x101, 10800, 0, 0x100 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x101, 0, 10800, 10800, 0, 0x103, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoUpArrowCallout =
+{
+ (SvxMSDffVertPair*)mso_sptUpArrowCalloutVert, sizeof( mso_sptUpArrowCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptUpArrowCalloutSegm, sizeof( mso_sptUpArrowCalloutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptUpArrowCalloutCalc, sizeof( mso_sptUpArrowCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptUpArrowCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptUpArrowCalloutTextRect, sizeof( mso_sptUpArrowCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptUpArrowCalloutHandle, sizeof( mso_sptUpArrowCalloutHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptDownArrowCalloutVert[] =
+{
+ { 0, 0 MSO_I }, { 0, 0 }, { 21600, 0 }, { 21600, 0 MSO_I },
+ { 5 MSO_I, 0 MSO_I }, { 5 MSO_I, 2 MSO_I }, { 4 MSO_I, 2 MSO_I }, { 10800, 21600 },
+ { 1 MSO_I, 2 MSO_I }, { 3 MSO_I, 2 MSO_I }, { 3 MSO_I, 0 MSO_I }
+};
+static const sal_uInt16 mso_sptDownArrowCalloutSegm[] =
+{
+ 0x4000, 0x000a, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptDownArrowCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust4Value, 0, 0 } },
+ { 0x8000, { 21600, 0, 0x0401 } },
+ { 0x8000, { 21600, 0, 0x0403 } }
+};
+static const sal_Int32 mso_sptDownArrowCalloutDefault[] =
+{
+ 4, 14400, 5400, 18000, 8100
+};
+static const SvxMSDffTextRectangles mso_sptDownArrowCalloutTextRect[] =
+{
+ { { 0, 0 }, { 21600, 0 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptDownArrowCalloutHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 0x102 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL,
+ 0x103, 0x102, 10800, 10800, 0x101, 10800, 0x100, 21600 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x101, 1, 10800, 10800, 0, 0x103, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoDownArrowCallout =
+{
+ (SvxMSDffVertPair*)mso_sptDownArrowCalloutVert, sizeof( mso_sptDownArrowCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptDownArrowCalloutSegm, sizeof( mso_sptDownArrowCalloutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptDownArrowCalloutCalc, sizeof( mso_sptDownArrowCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDownArrowCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptDownArrowCalloutTextRect, sizeof( mso_sptDownArrowCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptDownArrowCalloutHandle, sizeof( mso_sptDownArrowCalloutHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptLeftRightArrowCalloutVert[] =
+{
+ { 0 MSO_I, 0 }, { 4 MSO_I, 0 }, { 4 MSO_I, 3 MSO_I }, { 6 MSO_I, 3 MSO_I },
+ { 6 MSO_I, 1 MSO_I }, { 21600, 10800 }, { 6 MSO_I, 5 MSO_I }, { 6 MSO_I, 7 MSO_I },
+ { 4 MSO_I, 7 MSO_I }, { 4 MSO_I, 21600 }, { 0 MSO_I, 21600 }, { 0 MSO_I, 7 MSO_I },
+ { 2 MSO_I, 7 MSO_I }, { 2 MSO_I, 5 MSO_I }, { 0, 10800 }, { 2 MSO_I, 1 MSO_I },
+ { 2 MSO_I, 3 MSO_I }, { 0 MSO_I, 3 MSO_I }
+};
+static const sal_uInt16 mso_sptLeftRightArrowCalloutSegm[] =
+{
+ 0x4000, 0x0011, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptLeftRightArrowCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust4Value, 0, 0 } },
+ { 0x8000, { 21600, 0, 0x0400 } },
+ { 0x8000, { 21600, 0, 0x0401 } },
+ { 0x8000, { 21600, 0, 0x0402 } },
+ { 0x8000, { 21600, 0, 0x0403 } }
+};
+static const sal_Int32 mso_sptLeftRightArrowCalloutDefault[] =
+{
+ 4, 5400, 5500, 2700, 8100
+};
+static const SvxMSDffTextRectangles mso_sptLeftRightArrowCalloutTextRect[] =
+{
+ { { 0 MSO_I, 0 }, { 4 MSO_I, 21600 } }
+};
+static const SvxMSDffHandle mso_sptLeftRightArrowCalloutHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL,
+ 0x100, 0, 10800, 10800, 0x102, 10800, 0x80000000, 0x7fffffff },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL,
+ 0x102, 0x103, 10800, 10800, 0, 0x100, 0x101, 10800 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 0, 0x103 }
+};
+static const mso_CustomShape msoLeftRightArrowCallout =
+{
+ (SvxMSDffVertPair*)mso_sptLeftRightArrowCalloutVert, sizeof( mso_sptLeftRightArrowCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptLeftRightArrowCalloutSegm, sizeof( mso_sptLeftRightArrowCalloutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptLeftRightArrowCalloutCalc, sizeof( mso_sptLeftRightArrowCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptLeftRightArrowCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptLeftRightArrowCalloutTextRect, sizeof( mso_sptLeftRightArrowCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptLeftRightArrowCalloutHandle, sizeof( mso_sptLeftRightArrowCalloutHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptUpDownArrowCalloutVert[] =
+{
+ { 0, 0 MSO_I }, { 0, 4 MSO_I }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 6 MSO_I },
+ { 1 MSO_I, 6 MSO_I }, { 10800, 21600 }, { 5 MSO_I, 6 MSO_I }, { 7 MSO_I, 6 MSO_I },
+ { 7 MSO_I, 4 MSO_I }, { 21600, 4 MSO_I }, { 21600, 0 MSO_I }, { 7 MSO_I, 0 MSO_I },
+ { 7 MSO_I, 2 MSO_I }, { 5 MSO_I, 2 MSO_I }, { 10800, 0 }, { 1 MSO_I, 2 MSO_I },
+ { 3 MSO_I, 2 MSO_I }, { 3 MSO_I, 0 MSO_I }
+};
+static const sal_uInt16 mso_sptUpDownArrowCalloutSegm[] =
+{
+ 0x4000, 0x0011, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptUpDownArrowCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust4Value, 0, 0 } },
+ { 0x8000, { 21600, 0, 0x0400 } },
+ { 0x8000, { 21600, 0, 0x0401 } },
+ { 0x8000, { 21600, 0, 0x0402 } },
+ { 0x8000, { 21600, 0, 0x0403 } }
+};
+static const sal_Int32 mso_sptUpDownArrowCalloutDefault[] =
+{
+ 4, 5400, 5500, 2700, 8100
+};
+static const SvxMSDffTextRectangles mso_sptUpDownArrowCalloutTextRect[] =
+{
+ { { 0, 0 MSO_I }, { 21600, 4 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptUpDownArrowCalloutHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0x102, 10800 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0x103, 0x102, 10800, 10800, 0x101, 10800, 0, 0x100 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 0x101, 0, 10800, 10800, 0, 0x103, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoUpDownArrowCallout =
+{
+ (SvxMSDffVertPair*)mso_sptUpDownArrowCalloutVert, sizeof( mso_sptUpDownArrowCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptUpDownArrowCalloutSegm, sizeof( mso_sptUpDownArrowCalloutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptUpDownArrowCalloutCalc, sizeof( mso_sptUpDownArrowCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptUpDownArrowCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptUpDownArrowCalloutTextRect, sizeof( mso_sptUpDownArrowCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptUpDownArrowCalloutHandle, sizeof( mso_sptUpDownArrowCalloutHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptQuadArrowCalloutVert[] =
+{
+ { 0 MSO_I, 0 MSO_I }, { 3 MSO_I, 0 MSO_I }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 10800, 0 }, { 5 MSO_I, 2 MSO_I }, { 7 MSO_I, 2 MSO_I }, { 7 MSO_I, 0 MSO_I },
+ { 4 MSO_I, 0 MSO_I }, { 4 MSO_I, 3 MSO_I }, { 6 MSO_I, 3 MSO_I }, { 6 MSO_I, 1 MSO_I },
+ { 21600, 10800 }, { 6 MSO_I, 5 MSO_I }, { 6 MSO_I, 7 MSO_I }, { 4 MSO_I, 7 MSO_I },
+ { 4 MSO_I, 4 MSO_I }, { 7 MSO_I, 4 MSO_I }, { 7 MSO_I, 6 MSO_I }, { 5 MSO_I, 6 MSO_I },
+ { 10800, 21600 }, { 1 MSO_I, 6 MSO_I }, { 3 MSO_I, 6 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0 MSO_I, 4 MSO_I }, { 0 MSO_I, 7 MSO_I }, { 2 MSO_I, 7 MSO_I }, { 2 MSO_I, 5 MSO_I },
+ { 0, 10800 }, { 2 MSO_I, 1 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 0 MSO_I, 3 MSO_I }
+};
+static const sal_uInt16 mso_sptQuadArrowCalloutSegm[] =
+{
+ 0x4000, 0x001f, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptQuadArrowCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust4Value, 0, 0 } },
+ { 0x8000, { 21600, 0, 0x0400 } },
+ { 0x8000, { 21600, 0, 0x0401 } },
+ { 0x8000, { 21600, 0, 0x0402 } },
+ { 0x8000, { 21600, 0, 0x0403 } }
+};
+static const sal_Int32 mso_sptQuadArrowCalloutDefault[] =
+{
+ 4, 5400, 8100, 2700, 9400
+};
+static const SvxMSDffTextRectangles mso_sptQuadArrowCalloutTextRect[] =
+{
+ { { 0 MSO_I, 0 MSO_I }, { 4 MSO_I, 4 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptQuadArrowCalloutHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0x102, 0x101 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL,
+ 0x101, 0, 10800, 10800, 0x100, 10800, 0x80000000, 0x7fffffff },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0x103, 0x102, 10800, 10800, 0x101, 10800, 0, 0x100 }
+};
+static const mso_CustomShape msoQuadArrowCallout =
+{
+ (SvxMSDffVertPair*)mso_sptQuadArrowCalloutVert, sizeof( mso_sptQuadArrowCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptQuadArrowCalloutSegm, sizeof( mso_sptQuadArrowCalloutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptQuadArrowCalloutCalc, sizeof( mso_sptQuadArrowCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptQuadArrowCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptQuadArrowCalloutTextRect, sizeof( mso_sptQuadArrowCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptQuadArrowCalloutHandle, sizeof( mso_sptQuadArrowCalloutHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptCircularArrowVert[] =
+{
+ { 0x03 MSO_I, 0x03 MSO_I },
+ { 0x14 MSO_I, 0x14 MSO_I },
+ { 0x13 MSO_I, 0x12 MSO_I },
+ { 0x11 MSO_I, 0x10 MSO_I },
+ { 0, 0 }, { 21600, 21600 },
+ { 0x09 MSO_I, 0x08 MSO_I },
+ { 0x0B MSO_I, 0x0A MSO_I },
+ { 0x18 MSO_I, 0x17 MSO_I },
+ { 0x2F MSO_I, 0x2E MSO_I },
+ { 0x1D MSO_I, 0x1C MSO_I }
+};
+static const sal_uInt16 mso_sptCircularArrowSegm[] =
+{
+ 0xa404, 0xa504, 0x0003, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCircularArrowCalc[] =
+{
+ { 0x2000, { 0x0147, 0x0000, 0x0000 } },
+ { 0x2000, { 0x0148, 0x0000, 0x0000 } },
+ { 0x2000, { 0x0149, 0x0000, 0x0000 } },
+ { 0x4000, { 0x2A30, 0x0149, 0x0000 } },
+ { 0x4009, { 0x2A30, 0x0147, 0x0000 } },
+ { 0x400A, { 0x2A30, 0x0147, 0x0000 } },
+ { 0x4009, { 0x2A30, 0x0148, 0x0000 } },
+ { 0x400A, { 0x2A30, 0x0148, 0x0000 } },
+ { 0x2000, { 0x0404, 0x2A30, 0x0000 } },
+ { 0x2000, { 0x0405, 0x2A30, 0x0000 } },
+ { 0x2000, { 0x0406, 0x2A30, 0x0000 } },
+ { 0x2000, { 0x0407, 0x2A30, 0x0000 } },
+ { 0x6009, { 0x0403, 0x0147, 0x0000 } },
+ { 0x600A, { 0x0403, 0x0147, 0x0000 } },
+ { 0x6009, { 0x0403, 0x0148, 0x0000 } },
+ { 0x600A, { 0x0403, 0x0148, 0x0000 } },
+ { 0x2000, { 0x040C, 0x2A30, 0x0000 } },
+ { 0x2000, { 0x040D, 0x2A30, 0x0000 } },
+ { 0x2000, { 0x040E, 0x2A30, 0x0000 } },
+ { 0x2000, { 0x040F, 0x2A30, 0x0000 } },
+ { 0x8000, { 0x5460, 0x0000, 0x0403 } },
+ { 0x4009, { 0x34BC, 0x0148, 0x0000 } },
+ { 0x400A, { 0x34BC, 0x0148, 0x0000 } },
+ { 0x2000, { 0x0415, 0x2A30, 0x0000 } },
+ { 0x2000, { 0x0416, 0x2A30, 0x0000 } },
+ { 0x2000, { 0x0149, 0x0000, 0x0A8C } },
+ { 0x6009, { 0x0419, 0x0148, 0x0000 } },
+ { 0x600A, { 0x0419, 0x0148, 0x0000 } },
+ { 0x2000, { 0x041A, 0x2A30, 0x0000 } },
+ { 0x2000, { 0x041B, 0x2A30, 0x0000 } },
+ { 0xA000, { 0x041D, 0x0000, 0x0418 } },
+ { 0xA000, { 0x041D, 0x0000, 0x0418 } },
+ { 0x6001, { 0x041E, 0x041F, 0x0001 } },
+ { 0xA000, { 0x041C, 0x0000, 0x0417 } },
+ { 0xA000, { 0x041C, 0x0000, 0x0417 } },
+ { 0x6001, { 0x0421, 0x0422, 0x0001 } },
+ { 0x6000, { 0x0420, 0x0423, 0x0000 } },
+ { 0x200D, { 0x0424, 0x0000, 0x0000 } },
+ { 0x200E, { 0x0148, 0x002D, 0x0000 } },
+ { 0x6009, { 0x0425, 0x0426, 0x0000 } },
+ { 0x200E, { 0x0148, 0x002D, 0x0000 } },
+ { 0x600A, { 0x0425, 0x0428, 0x0000 } },
+ { 0x000E, { 0x0000, 0x002D, 0x0000 } },
+ { 0x6009, { 0x0427, 0x042A, 0x0000 } },
+ { 0x000E, { 0x0000, 0x002D, 0x0000 } },
+ { 0x6009, { 0x0429, 0x042C, 0x0000 } },
+ { 0x6000, { 0x041C, 0x042B, 0x0000 } },
+ { 0x6000, { 0x041D, 0x042D, 0x0000 } }
+};
+static const sal_Int32 mso_sptCircularArrowDefault[] =
+{
+ 3, 180, 0, 5500
+};
+static const SvxMSDffTextRectangles mso_sptCircularArrowTextRect[] = // todo
+{
+ { { 0, 0 }, { 21600, 21600 } }
+};
+static const SvxMSDffHandle mso_sptCircularArrowHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_POLAR | MSDFF_HANDLE_FLAGS_RADIUS_RANGE,
+ 10800, 0x100, 10800, 10800, 10800, 10800, 0xff4c0000, 0x00b40000 },
+ { MSDFF_HANDLE_FLAGS_POLAR | MSDFF_HANDLE_FLAGS_RADIUS_RANGE,
+ 0x102, 0x101, 10800, 10800, 0, 10800, 0xff4c0000, 0x00b40000 }
+};
+static const mso_CustomShape msoCircularArrow =
+{
+ (SvxMSDffVertPair*)mso_sptCircularArrowVert, sizeof( mso_sptCircularArrowVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCircularArrowSegm, sizeof( mso_sptCircularArrowSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCircularArrowCalc, sizeof( mso_sptCircularArrowCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCircularArrowDefault,
+ (SvxMSDffTextRectangles*)mso_sptCircularArrowTextRect, sizeof( mso_sptCircularArrowTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCircularArrowHandle, sizeof( mso_sptCircularArrowHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptCubeVert[] =
+{
+ { 0, 12 MSO_I }, { 0, 1 MSO_I }, { 2 MSO_I, 0 }, { 11 MSO_I, 0 }, { 11 MSO_I, 3 MSO_I }, { 4 MSO_I, 12 MSO_I },
+ { 0, 1 MSO_I }, { 2 MSO_I, 0 }, { 11 MSO_I, 0 }, { 4 MSO_I, 1 MSO_I },
+ { 4 MSO_I, 12 MSO_I }, { 4 MSO_I, 1 MSO_I }, { 11 MSO_I, 0 }, { 11 MSO_I, 3 MSO_I }
+};
+static const sal_uInt16 mso_sptCubeSegm[] =
+{
+ 0x4000, 0x0005, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCubeCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, 0x400, 0 } },
+ { 0x6000, { DFF_Prop_geoLeft, 0x400, 0 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x400 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x400 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x402 } }, // 5
+ { 0x2001, { 0x405, 1, 2 } }, // 6
+ { 0x6000, { 0x402, 0x406, 0 } }, // 7
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x401 } }, // 8
+ { 0x2001, { 0x408, 1, 2 } }, // 9
+ { 0x6000, { 0x401, 0x409, 0 } }, // 10
+ { 0x2000, { DFF_Prop_geoRight, 0, 0 } }, // 11
+ { 0x2000, { DFF_Prop_geoBottom, 0, 0 } } // 12
+};
+static const SvxMSDffTextRectangles mso_sptCubeTextRect[] =
+{
+ { { 0, 1 MSO_I }, { 4 MSO_I, 12 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptCubeHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_SWITCHED,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 21600 }
+};
+static const SvxMSDffVertPair mso_sptCubeGluePoints[] =
+{
+ { 7 MSO_I, 0 }, { 6 MSO_I, 1 MSO_I }, { 0, 10 MSO_I }, { 6 MSO_I, 21600 }, { 4 MSO_I, 10 MSO_I }, { 21600, 9 MSO_I }
+};
+static const mso_CustomShape msoCube =
+{
+ (SvxMSDffVertPair*)mso_sptCubeVert, sizeof( mso_sptCubeVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCubeSegm, sizeof( mso_sptCubeSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCubeCalc, sizeof( mso_sptCubeCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault5400,
+ (SvxMSDffTextRectangles*)mso_sptCubeTextRect, sizeof( mso_sptCubeTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ (SvxMSDffVertPair*)mso_sptCubeGluePoints, sizeof( mso_sptCubeGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptCubeHandle, sizeof( mso_sptCubeHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptBevelVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 1 MSO_I, 0 MSO_I }, { 0 MSO_I, 0 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 0 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 0 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 0 MSO_I, 0 MSO_I }, { 0 MSO_I, 2 MSO_I }
+};
+static const sal_uInt16 mso_sptBevelSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptBevelCalc[] =
+{
+ { 0x2001, { DFF_Prop_adjustValue, 21599, 21600 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x400 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x400 } }
+};
+
+static const SvxMSDffTextRectangles mso_sptBevelTextRect[] =
+{
+ { { 0 MSO_I, 0 MSO_I }, { 1 MSO_I, 2 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptBevelHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_SWITCHED,
+ 0x100, 0, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoBevel =
+{
+ (SvxMSDffVertPair*)mso_sptBevelVert, sizeof( mso_sptBevelVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBevelSegm, sizeof( mso_sptBevelSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBevelCalc, sizeof( mso_sptBevelCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault2700,
+ (SvxMSDffTextRectangles*)mso_sptBevelTextRect, sizeof( mso_sptBevelTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptBevelHandle, sizeof( mso_sptBevelHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptFoldedCornerVert[] = // adjustment1 : x 10800 - 21600
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 0 MSO_I }, { 0 MSO_I, 21600 },
+ { 0, 21600 }, { 0 MSO_I, 21600 }, { 3 MSO_I, 0 MSO_I }, { 8 MSO_I, 9 MSO_I },
+ { 10 MSO_I, 11 MSO_I }, { 21600, 0 MSO_I }
+};
+static const sal_uInt16 mso_sptFoldedCornerSegm[] =
+{
+ 0x4000, 0x0004, 0x6001, 0x8000,
+ 0x4000, 0x0001, 0x2001, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptFoldedCornerCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, 0x400 } },
+ { 0x2001, { 0x0401, 8000, 10800 } },
+ { 0x8000, { 21600, 0, 0x0402 } },
+ { 0x2001, { 0x0401, 1, 2 } },
+ { 0x2001, { 0x0401, 1, 4 } },
+ { 0x2001, { 0x0401, 1, 7 } },
+ { 0x2001, { 0x0401, 1, 16 } },
+ { 0x6000, { 0x0403, 0x405, 0 } },
+ { 0x6000, { 0x0400, 0x406, 0 } },
+ { 0x8000, { 21600, 0, 0x404 } },
+ { 0x6000, { 0x400, 0x407, 0 } }
+};
+static const sal_Int32 mso_sptFoldedCornerDefault[] =
+{
+ 1, 18900
+};
+static const SvxMSDffTextRectangles mso_sptFoldedCornerTextRect[] =
+{
+ { { 0, 0 }, { 21600, 11 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptFoldedCornerHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 1, 10800, 10800, 10800, 21600, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoFoldedCorner =
+{
+ (SvxMSDffVertPair*)mso_sptFoldedCornerVert, sizeof( mso_sptFoldedCornerVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFoldedCornerSegm, sizeof( mso_sptFoldedCornerSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptFoldedCornerCalc, sizeof( mso_sptFoldedCornerCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptFoldedCornerDefault,
+ (SvxMSDffTextRectangles*)mso_sptFoldedCornerTextRect, sizeof( mso_sptFoldedCornerTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptFoldedCornerHandle, sizeof( mso_sptFoldedCornerHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonBlankVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 1 MSO_I, 0 MSO_I }, { 0 MSO_I, 0 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 0 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 0 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 0 MSO_I, 0 MSO_I }, { 0 MSO_I, 2 MSO_I }
+};
+static const sal_uInt16 mso_sptActionButtonBlankSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptActionButtonBlankCalc[] =
+{
+ { 0x2001, { DFF_Prop_adjustValue, 21599, 21600 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x400 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x400 } }
+};
+static const SvxMSDffTextRectangles mso_sptActionButtonBlankTextRect[] =
+{
+ { { 0 MSO_I, 0 MSO_I }, { 1 MSO_I, 2 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptButtonHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_SWITCHED,
+ 0x100, 0, 10800, 10800, 0, 5400, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoActionButtonBlank =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonBlankVert, sizeof( mso_sptActionButtonBlankVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonBlankSegm, sizeof( mso_sptActionButtonBlankSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonBlankCalc, sizeof( mso_sptActionButtonBlankCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonBlankTextRect, sizeof( mso_sptActionButtonBlankTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffTextRectangles mso_sptActionButtonTextRect[] =
+{
+ { { 1 MSO_I, 2 MSO_I }, { 3 MSO_I, 4 MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptActionButtonHomeVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 4 MSO_I },
+
+ { 7 MSO_I, 0xa MSO_I }, { 0xc MSO_I, 0xe MSO_I }, { 0xc MSO_I, 0x10 MSO_I }, { 0x12 MSO_I, 0x10 MSO_I },
+ { 0x12 MSO_I, 0x14 MSO_I }, { 0x16 MSO_I, 8 MSO_I }, { 0x18 MSO_I, 8 MSO_I }, { 0x18 MSO_I, 0x1a MSO_I },
+ { 0x1c MSO_I, 0x1a MSO_I }, { 0x1c MSO_I, 8 MSO_I }, { 0x1e MSO_I, 8 MSO_I },
+
+ { 0xc MSO_I, 0xe MSO_I }, { 0xc MSO_I, 0x10 MSO_I }, { 0x12 MSO_I, 0x10 MSO_I },{ 0x12 MSO_I, 0x14 MSO_I },
+
+ { 0x20 MSO_I, 0x24 MSO_I }, { 0x22 MSO_I, 0x24 MSO_I }, { 0x22 MSO_I, 0x1a MSO_I }, { 0x18 MSO_I, 0x1a MSO_I },
+ { 0x18 MSO_I, 8 MSO_I }, { 0x1c MSO_I, 8 MSO_I }, { 0x1c MSO_I, 0x1a MSO_I }, { 0x20 MSO_I, 0x1a MSO_I }
+
+};
+static const sal_uInt16 mso_sptActionButtonHomeSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x000a, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0007, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptActionButtonHomeCalc[] = // adj value 0 - 5400
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x0405, 1, 10800 } }, // scaling 6
+ { 0x2001, { DFF_Prop_geoRight, 1, 2 } }, // lr center 7
+ { 0x2001, { DFF_Prop_geoBottom, 1, 2 } }, // ul center 8
+
+ { 0x4001, { -8000, 0x0406, 1 } }, // 9
+ { 0x6000, { 0x0409, 0x0408, 0 } }, // a
+ { 0x4001, { 2960, 0x0406, 1 } }, // b
+ { 0x6000, { 0x040b, 0x0407, 0 } }, // c
+ { 0x4001, { -5000, 0x0406, 1 } }, // d
+ { 0x6000, { 0x040d, 0x0408, 0 } }, // e
+ { 0x4001, { -7000, 0x0406, 1 } }, // f
+ { 0x6000, { 0x040f, 0x0408, 0 } }, // 10
+ { 0x4001, { 5000, 0x0406, 1 } }, // 11
+ { 0x6000, { 0x0411, 0x0407, 0 } }, // 12
+ { 0x4001, { -2960, 0x0406, 1 } }, // 13
+ { 0x6000, { 0x0413, 0x0408, 0 } }, // 14
+ { 0x4001, { 8000, 0x0406, 1 } }, // 15
+ { 0x6000, { 0x0415,0x0407, 0 } }, // 16
+ { 0x4001, { 6100, 0x0406, 1 } }, // 17
+ { 0x6000, { 0x0417,0x0407, 0 } }, // 18
+ { 0x4001, { 8260, 0x0406, 1 } }, // 19
+ { 0x6000, { 0x0419, 0x0408, 0 } }, // 1a
+ { 0x4001, { -6100, 0x0406, 1 } }, // 1b
+ { 0x6000, { 0x041b, 0x0407, 0 } }, // 1c
+ { 0x4001, { -8000, 0x0406, 1 } }, // 1d
+ { 0x6000, { 0x041d, 0x0407, 0 } }, // 1e
+ { 0x4001, { -1060, 0x0406, 1 } }, // 1f
+ { 0x6000, { 0x041f, 0x0407, 0 } }, // 20
+ { 0x4001, { 1060, 0x0406, 1 } }, // 21
+ { 0x6000, { 0x0421, 0x0407, 0 } }, // 22
+ { 0x4001, { 4020, 0x0406, 1 } }, // 23
+ { 0x6000, { 0x0423, 0x0408, 0 } } // 24
+
+};
+static const mso_CustomShape msoActionButtonHome =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonHomeVert, sizeof( mso_sptActionButtonHomeVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonHomeSegm, sizeof( mso_sptActionButtonHomeSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonHomeCalc, sizeof( mso_sptActionButtonHomeCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonHelpVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I,4 MSO_I },
+ { 7 MSO_I, 0xc MSO_I }, { 0xa MSO_I, 0x3e MSO_I }, { 7 MSO_I, 0x10 MSO_I }, { 0xe MSO_I, 0x3e MSO_I }, { 7 MSO_I, 0xc MSO_I },
+ { 0x12 MSO_I, 0x14 MSO_I }, { 0x12 MSO_I, 0x16 MSO_I }, // pp
+ { 0x12 MSO_I, 0x18 MSO_I }, { 0x1a MSO_I, 8 MSO_I }, { 0x1c MSO_I, 8 MSO_I }, // ccp
+ { 0x1e MSO_I, 8 MSO_I }, { 0x20 MSO_I, 0x22 MSO_I }, { 0x20 MSO_I, 0x24 MSO_I }, // ccp
+ { 0x20 MSO_I, 0x26 MSO_I }, { 0x28 MSO_I, 0x2a MSO_I }, { 7 MSO_I, 0x2a MSO_I }, // ccp
+ { 0x2c MSO_I, 0x2a MSO_I }, { 0x2e MSO_I, 0x26 MSO_I }, { 0x2e MSO_I, 0x24 MSO_I }, // ccp
+ { 0x30 MSO_I, 0x24 MSO_I }, { 0x30 MSO_I, 0x32 MSO_I }, { 0x34 MSO_I, 0x36 MSO_I }, // ccp
+ { 7 MSO_I, 0x36 MSO_I }, // p
+ { 0x12 MSO_I, 0x36 MSO_I }, { 0x1c MSO_I, 0x32 MSO_I }, { 0x1c MSO_I, 0x24 MSO_I }, // ccp
+ { 0x1c MSO_I, 0x38 MSO_I }, { 0x3a MSO_I, 0x3c MSO_I }, { 0x12 MSO_I, 0x3c MSO_I }, // ccp
+ { 7 MSO_I, 0x3c MSO_I }, { 0x34 MSO_I, 8 MSO_I }, { 0x34 MSO_I, 0x16 MSO_I }, // ccp
+ { 0x34 MSO_I, 0x14 MSO_I }
+};
+static const sal_uInt16 mso_sptActionButtonHelpSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0xa704, 0x6000, 0x8000,
+ 0x4000, 0x0001, 0x2004, 0x0001, 0x2004, 0x0001, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptActionButtonHelpCalc[] = // adj value 0 - 5400
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x0405, 1, 10800 } }, // scaling 6
+ { 0x2001, { DFF_Prop_geoRight, 1, 2 } }, // lr center 7
+ { 0x2001, { DFF_Prop_geoBottom, 1, 2 } }, // ul center 8
+
+ { 0x4001, { -1690, 0x0406, 1 } }, // 9
+ { 0x6000, { 0x0409, 0x0407, 0 } }, // a
+ { 0x4001, { 4600, 0x0406, 1 } }, // b
+ { 0x6000, { 0x040b, 0x0408, 0 } }, // c
+ { 0x4001, { 1690, 0x0406, 1 } }, // d
+ { 0x6000, { 0x040d, 0x0407, 0 } }, // e
+ { 0x4001, { 7980, 0x0406, 1 } }, // f
+ { 0x6000, { 0x040f, 0x0408, 0 } }, // 10
+ { 0x4001, { 1270, 0x0406, 1 } }, // 11
+ { 0x6000, { 0x0411, 0x0407, 0 } }, // 12
+ { 0x4001, { 4000, 0x0406, 1 } }, // 13
+ { 0x6000, { 0x0413, 0x0408, 0 } }, // 14
+ { 0x4001, { 1750, 0x0406, 1 } }, // 15
+ { 0x6000, { 0x0415, 0x0408, 0 } }, // 16
+ { 0x4001, { 800, 0x0406, 1 } }, // 17
+ { 0x6000, { 0x0417, 0x0408, 0 } }, // 18
+ { 0x4001, { 1650, 0x0406, 1 } }, // 19
+ { 0x6000, { 0x0419, 0x0407, 0 } }, // 1a
+ { 0x4001, { 2340, 0x0406, 1 } }, // 1b
+ { 0x6000, { 0x041b, 0x0407, 0 } }, // 1c
+ { 0x4001, { 3640, 0x0406, 1 } }, // 1d
+ { 0x6000, { 0x041d, 0x0407, 0 } }, // 1e
+ { 0x4001, { 4670, 0x0406, 1 } }, // 1f
+ { 0x6000, { 0x041f, 0x0407, 0 } }, // 20
+ { 0x4001, { -1570, 0x0406, 1 } }, // 21
+ { 0x6000, { 0x0421, 0x0408, 0 } }, // 22
+ { 0x4001, { -3390, 0x0406, 1 } }, // 23
+ { 0x6000, { 0x0423, 0x0408, 0 } }, // 24
+ { 0x4001, { -6050, 0x0406, 1 } }, // 25
+ { 0x6000, { 0x0425, 0x0408, 0 } }, // 26
+ { 0x4001, { 2540, 0x0406, 1 } }, // 27
+ { 0x6000, { 0x0427, 0x0407, 0 } }, // 28
+ { 0x4001, { -8050, 0x0406, 1 } }, // 29
+ { 0x6000, { 0x0429, 0x0408, 0 } }, // 2a
+ { 0x4001, { -2540, 0x0406, 1 } }, // 2b
+ { 0x6000, { 0x042b, 0x0407, 0 } }, // 2c
+ { 0x4001, { -4460, 0x0406, 1 } }, // 2d
+ { 0x6000, { 0x042d, 0x0407, 0 } }, // 2e
+ { 0x4001, { -2330, 0x0406, 1 } }, // 2f
+ { 0x6000, { 0x042f, 0x0407, 0 } }, // 30
+ { 0x4001, { -4700, 0x0406, 1 } }, // 31
+ { 0x6000, { 0x0431, 0x0408, 0 } }, // 32
+ { 0x4001, { -1270, 0x0406, 1 } }, // 33
+ { 0x6000, { 0x0433, 0x0407, 0 } }, // 34
+ { 0x4001, { -5720, 0x0406, 1 } }, // 35
+ { 0x6000, { 0x0435, 0x0408, 0 } }, // 36
+ { 0x4001, { -2540, 0x0406, 1 } }, // 37
+ { 0x6000, { 0x0437, 0x0408, 0 } }, // 38
+ { 0x4001, { 1800, 0x0406, 1 } }, // 39
+ { 0x6000, { 0x0439, 0x0407, 0 } }, // 3a
+ { 0x4001, { -1700, 0x0406, 1 } }, // 3b
+ { 0x6000, { 0x043b, 0x0408, 0 } }, // 3c
+ { 0x4001, { 6290, 0x0406, 1 } }, // 3d
+ { 0x6000, { 0x043d, 0x0408, 0 } } // 3e
+};
+static const mso_CustomShape msoActionButtonHelp =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonHelpVert, sizeof( mso_sptActionButtonHelpVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonHelpSegm, sizeof( mso_sptActionButtonHelpSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonHelpCalc, sizeof( mso_sptActionButtonHelpCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonInformationVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 4 MSO_I },
+ { 0x7 MSO_I, 0xc MSO_I }, { 0xa MSO_I, 0x8 MSO_I }, { 0x7 MSO_I, 0x10 MSO_I }, { 0xe MSO_I, 8 MSO_I }, { 0x7 MSO_I, 0xc MSO_I },
+ { 0x7 MSO_I, 0x14 MSO_I }, { 0x12 MSO_I, 0x2a MSO_I }, { 0x7 MSO_I, 0x18 MSO_I }, { 0x16 MSO_I, 0x2a MSO_I }, { 0x7 MSO_I, 0x14 MSO_I },
+ { 0x1a MSO_I, 0x1c MSO_I }, { 0x1e MSO_I, 0x1c MSO_I }, { 0x1e MSO_I, 0x20 MSO_I }, { 0x22 MSO_I, 0x20 MSO_I },
+ { 0x22 MSO_I, 0x24 MSO_I }, { 0x1a MSO_I, 0x24 MSO_I }, { 0x1a MSO_I, 0x20 MSO_I }, { 0x26 MSO_I, 0x20 MSO_I },
+ { 0x26 MSO_I, 0x28 MSO_I }, { 0x1a MSO_I, 0x28 MSO_I }
+};
+static const sal_uInt16 mso_sptActionButtonInformationSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0xa704, 0x6000, 0x8000,
+ 0x4000, 0xa704, 0x6000, 0x8000,
+ 0x4000, 0x0009, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptActionButtonInformationCalc[] = // adj value 0 - 5400
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x0405, 1, 10800 } }, // scaling 6
+ { 0x2001, { DFF_Prop_geoRight, 1, 2 } }, // lr center 7
+ { 0x2001, { DFF_Prop_geoBottom, 1, 2 } }, // ul center 8
+
+ { 0x4001, { -8050, 0x0406, 1 } }, // 9
+ { 0x6000, { 0x0409, 0x0407, 0 } }, // a
+ { 0x4001, { -8050, 0x0406, 1 } }, // b
+ { 0x6000, { 0x040b, 0x0408, 0 } }, // c
+ { 0x4001, { 8050, 0x0406, 1 } }, // d
+ { 0x6000, { 0x040d, 0x0407, 0 } }, // e
+ { 0x4001, { 8050, 0x0406, 1 } }, // f
+ { 0x6000, { 0x040f, 0x0408, 0 } }, // 10
+
+ { 0x4001, { -2060, 0x0406, 1 } }, // 11
+ { 0x6000, { 0x0411, 0x0407, 0 } }, // 12
+ { 0x4001, { -7620, 0x0406, 1 } }, // 13
+ { 0x6000, { 0x0413, 0x0408, 0 } }, // 14
+ { 0x4001, { 2060, 0x0406, 1 } }, // 15
+ { 0x6000, { 0x0415, 0x0407, 0 } }, // 16
+ { 0x4001, { -3500, 0x0406, 1 } }, // 17
+ { 0x6000, { 0x0417, 0x0408, 0 } }, // 18
+
+ { 0x4001, { -2960, 0x0406, 1 } }, // 19
+ { 0x6000, { 0x0419, 0x0407, 0 } }, // 1a
+ { 0x4001, { -2960, 0x0406, 1 } }, // 1b
+ { 0x6000, { 0x041b, 0x0408, 0 } }, // 1c
+ { 0x4001, { 1480, 0x0406, 1 } }, // 1d
+ { 0x6000, { 0x041d, 0x0407, 0 } }, // 1e
+ { 0x4001, { 5080, 0x0406, 1 } }, // 1f
+ { 0x6000, { 0x041f, 0x0408, 0 } }, // 20
+ { 0x4001, { 2960, 0x0406, 1 } }, // 21
+ { 0x6000, { 0x0421, 0x0407, 0 } }, // 22
+ { 0x4001, { 6140, 0x0406, 1 } }, // 23
+ { 0x6000, { 0x0423, 0x0408, 0 } }, // 24
+ { 0x4001, { -1480, 0x0406, 1 } }, // 25
+ { 0x6000, { 0x0425, 0x0407, 0 } }, // 26
+ { 0x4001, { -1920, 0x0406, 1 } }, // 27
+ { 0x6000, { 0x0427, 0x0408, 0 } }, // 28
+
+ { 0x4001, { -5560, 0x0406, 1 } }, // 29
+ { 0x6000, { 0x0429, 0x0408, 0 } }, // 2a
+
+};
+static const mso_CustomShape msoActionButtonInformation =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonInformationVert, sizeof( mso_sptActionButtonInformationVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonInformationSegm, sizeof( mso_sptActionButtonInformationSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonInformationCalc, sizeof( mso_sptActionButtonInformationCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonBackPreviousVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I,4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 4 MSO_I },
+
+ { 0xa MSO_I, 8 MSO_I }, { 0xe MSO_I, 0xc MSO_I }, { 0xe MSO_I, 0x10 MSO_I }
+};
+static const sal_uInt16 mso_sptActionButtonForwardBackSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0002, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptActionButtonForwardBackCalc[] = // adj value 0 - 5400
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x0405, 1, 10800 } }, // scaling 6
+ { 0x2001, { DFF_Prop_geoRight, 1, 2 } }, // lr center 7
+ { 0x2001, { DFF_Prop_geoBottom, 1, 2 } }, // ul center 8
+
+ { 0x4001, { -8050, 0x0406, 1 } }, // 9
+ { 0x6000, { 0x0409, 0x0407, 0 } }, // a
+ { 0x4001, { -8050, 0x0406, 1 } }, // b
+ { 0x6000, { 0x040b, 0x0408, 0 } }, // c
+ { 0x4001, { 8050, 0x0406, 1 } }, // d
+ { 0x6000, { 0x040d, 0x0407, 0 } }, // e
+ { 0x4001, { 8050, 0x0406, 1 } }, // f
+ { 0x6000, { 0x040f, 0x0408, 0 } } // 10
+};
+static const mso_CustomShape msoActionButtonBackPrevious =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonBackPreviousVert, sizeof( mso_sptActionButtonBackPreviousVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonForwardBackSegm, sizeof( mso_sptActionButtonForwardBackSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonForwardBackCalc, sizeof( mso_sptActionButtonForwardBackCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonForwardNextVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 4 MSO_I },
+
+ { 0xa MSO_I, 0xc MSO_I }, { 0xe MSO_I, 8 MSO_I }, { 0xa MSO_I, 0x10 MSO_I }
+};
+static const mso_CustomShape msoActionButtonForwardNext =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonForwardNextVert, sizeof( mso_sptActionButtonForwardNextVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonForwardBackSegm, sizeof( mso_sptActionButtonForwardBackSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonForwardBackCalc, sizeof( mso_sptActionButtonForwardBackCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonBeginningVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 4 MSO_I },
+
+ { 0xa MSO_I, 8 MSO_I }, { 0xe MSO_I, 0xc MSO_I }, { 0xe MSO_I, 0x10 MSO_I }, { 0x12 MSO_I, 0xc MSO_I },
+ { 0x14 MSO_I, 0xc MSO_I }, { 0x14 MSO_I, 0x10 MSO_I }, { 0x12 MSO_I, 0x10 MSO_I }
+};
+static const sal_uInt16 mso_sptActionButtonBeginningEndSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+
+ 0x4000, 0x0002, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptActionButtonBeginningEndCalc[] = // adj value 0 - 5400
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x0405, 1, 10800 } }, // scaling 6
+ { 0x2001, { DFF_Prop_geoRight, 1, 2 } }, // lr center 7
+ { 0x2001, { DFF_Prop_geoBottom, 1, 2 } }, // ul center 8
+
+ { 0x4001, { -4020, 0x0406, 1 } }, // 9
+ { 0x6000, { 0x0409, 0x0407, 0 } }, // a
+ { 0x4001, { -8050, 0x0406, 1 } }, // b
+ { 0x6000, { 0x040b, 0x0408, 0 } }, // c
+ { 0x4001, { 8050, 0x0406, 1 } }, // d
+ { 0x6000, { 0x040d, 0x0407, 0 } }, // e
+ { 0x4001, { 8050, 0x0406, 1 } }, // f
+ { 0x6000, { 0x040f, 0x0408, 0 } }, // 10
+
+ { 0x4001, { -8050, 0x0406, 1 } }, // 11
+ { 0x6000, { 0x0411, 0x0407, 0 } }, // 12
+ { 0x4001, { -6140, 0x0406, 1 } }, // 13
+ { 0x6000, { 0x0413, 0x0407, 0 } }, // 14
+
+
+ { 0x4001, { 4020, 0x0406, 1 } }, // 15
+ { 0x6000, { 0x0415, 0x0407, 0 } }, // 16
+ { 0x4001, { 6140, 0x0406, 1 } }, // 17
+ { 0x6000, { 0x0417, 0x0407, 0 } } // 18
+};
+static const mso_CustomShape msoActionButtonBeginning =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonBeginningVert, sizeof( mso_sptActionButtonBeginningVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonBeginningEndSegm, sizeof( mso_sptActionButtonBeginningEndSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonBeginningEndCalc, sizeof( mso_sptActionButtonBeginningEndCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonEndVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 4 MSO_I },
+
+ { 0x16 MSO_I, 8 MSO_I }, { 0x12 MSO_I, 0x10 MSO_I }, { 0x12 MSO_I, 0xc MSO_I },
+
+ { 0x18 MSO_I, 0xc MSO_I }, { 0x18 MSO_I, 0x10 MSO_I }, { 0xe MSO_I, 0x10 MSO_I }, { 0xe MSO_I, 0xc MSO_I }
+};
+static const mso_CustomShape msoActionButtonEnd =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonEndVert, sizeof( mso_sptActionButtonEndVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonBeginningEndSegm, sizeof( mso_sptActionButtonBeginningEndSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonBeginningEndCalc, sizeof( mso_sptActionButtonBeginningEndCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonReturnVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 4 MSO_I },
+
+ { 0xa MSO_I, 0xc MSO_I }, { 0xe MSO_I, 0xc MSO_I }, { 0xe MSO_I, 0x10 MSO_I }, // ppp
+ { 0xe MSO_I, 0x12 MSO_I }, { 0x14 MSO_I, 0x16 MSO_I }, { 0x18 MSO_I, 0x16 MSO_I }, // ccp
+ { 7 MSO_I, 0x16 MSO_I }, // p
+ { 0x1a MSO_I, 0x16 MSO_I }, { 0x1c MSO_I, 0x12 MSO_I }, { 0x1c MSO_I, 0x10 MSO_I }, // ccp
+ { 0x1c MSO_I, 0xc MSO_I }, { 7 MSO_I, 0xc MSO_I }, { 0x1e MSO_I, 0x20 MSO_I }, { 0x22 MSO_I, 0xc MSO_I },// pppp
+ { 0x24 MSO_I, 0xc MSO_I }, { 0x24 MSO_I, 0x10 MSO_I }, // pp
+ { 0x24 MSO_I, 0x26 MSO_I }, { 0x28 MSO_I, 0x2a MSO_I }, { 7 MSO_I, 0x2a MSO_I }, // ccp
+ { 0x18 MSO_I, 0x2a MSO_I }, // p
+ { 0x2c MSO_I, 0x2a MSO_I }, { 0xa MSO_I, 0x26 MSO_I }, { 0xa MSO_I, 0x10 MSO_I } // ccp
+};
+static const sal_uInt16 mso_sptActionButtonReturnSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0002, 0x2001, 0x0001, 0x2001, 0x0006,0x2001, 0x0001, 0x2001, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptActionButtonReturnCalc[] = // adj value 0 - 5400
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x0405, 1, 10800 } }, // scaling 6
+ { 0x2001, { DFF_Prop_geoRight, 1, 2 } }, // lr center 7
+ { 0x2001, { DFF_Prop_geoBottom, 1, 2 } }, // ul center 8
+
+ { 0x4001, { -8050, 0x0406, 1 } }, // 9
+ { 0x6000, { 0x0409, 0x0407, 0 } }, // a
+ { 0x4001, { -3800, 0x0406, 1 } }, // b
+ { 0x6000, { 0x040b, 0x0408, 0 } }, // c
+ { 0x4001, { -4020, 0x0406, 1 } }, // d
+ { 0x6000, { 0x040d, 0x0407, 0 } }, // e
+ { 0x4001, { 2330, 0x0406, 1 } }, // f
+ { 0x6000, { 0x040f, 0x0408, 0 } }, // 10
+ { 0x4001, { 3390, 0x0406, 1 } }, // 11
+ { 0x6000, { 0x0411, 0x0408, 0 } }, // 12
+ { 0x4001, { -3100, 0x0406, 1 } }, // 13
+ { 0x6000, { 0x0413, 0x0407, 0 } }, // 14
+ { 0x4001, { 4230, 0x0406, 1 } }, // 15
+ { 0x6000, { 0x0415, 0x0408, 0 } }, // 16
+ { 0x4001, { -1910, 0x0406, 1 } }, // 17
+ { 0x6000, { 0x0417, 0x0407, 0 } }, // 18
+ { 0x4001, { 1190, 0x0406, 1 } }, // 19
+ { 0x6000, { 0x0419, 0x0407, 0 } }, // 1a
+ { 0x4001, { 2110, 0x0406, 1 } }, // 1b
+ { 0x6000, { 0x041b, 0x0407, 0 } }, // 1c
+ { 0x4001, { 4030, 0x0406, 1 } }, // 1d
+ { 0x6000, { 0x041d, 0x0407, 0 } }, // 1e
+ { 0x4001, { -7830, 0x0406, 1 } }, // 1f
+ { 0x6000, { 0x041f, 0x0408, 0 } }, // 20
+ { 0x4001, { 8250, 0x0406, 1 } }, // 21
+ { 0x6000, { 0x0421, 0x0407, 0 } }, // 22
+ { 0x4001, { 6140, 0x0406, 1 } }, // 23
+ { 0x6000, { 0x0423, 0x0407, 0 } }, // 24
+ { 0x4001, { 5510, 0x0406, 1 } }, // 25
+ { 0x6000, { 0x0425, 0x0408, 0 } }, // 26
+ { 0x4001, { 3180, 0x0406, 1 } }, // 27
+ { 0x6000, { 0x0427, 0x0407, 0 } }, // 28
+ { 0x4001, { 8450, 0x0406, 1 } }, // 29
+ { 0x6000, { 0x0429, 0x0408, 0 } }, // 2a
+ { 0x4001, { -5090, 0x0406, 1 } }, // 2b
+ { 0x6000, { 0x042b, 0x0407, 0 } } // 2c
+};
+static const mso_CustomShape msoActionButtonReturn =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonReturnVert, sizeof( mso_sptActionButtonReturnVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonReturnSegm, sizeof( mso_sptActionButtonReturnSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonReturnCalc, sizeof( mso_sptActionButtonReturnCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonDocumentVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 4 MSO_I },
+
+ { 0xa MSO_I, 0xc MSO_I }, { 0xe MSO_I, 0xc MSO_I }, { 0x10 MSO_I, 0x12 MSO_I }, { 0x10 MSO_I, 0x14 MSO_I },
+ { 0xa MSO_I, 0x14 MSO_I }, { 0xe MSO_I, 0xc MSO_I }, { 0x10 MSO_I, 0x12 MSO_I }, { 0xe MSO_I, 0x12 MSO_I }
+};
+static const sal_uInt16 mso_sptActionButtonDocumentSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+
+ 0x4000, 0x0004, 0x6001, 0x8000,
+ 0x4000, 0x0002, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptActionButtonDocumentCalc[] = // adj value 0 - 5400
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x0405, 1, 10800 } }, // scaling 6
+ { 0x2001, { DFF_Prop_geoRight, 1, 2 } }, // lr center 7
+ { 0x2001, { DFF_Prop_geoBottom, 1, 2 } }, // ul center 8
+
+ { 0x4001, { -6350, 0x0406, 1 } }, // 9
+ { 0x6000, { 0x0409, 0x0407, 0 } }, // a
+ { 0x4001, { -7830, 0x0406, 1 } }, // b
+ { 0x6000, { 0x040b, 0x0408, 0 } }, // c
+ { 0x4001, { 1690, 0x0406, 1 } }, // d
+ { 0x6000, { 0x040d, 0x0407, 0 } }, // e
+ { 0x4001, { 6350, 0x0406, 1 } }, // f
+ { 0x6000, { 0x040f, 0x0407, 0 } }, // 10
+ { 0x4001, { -3810, 0x0406, 1 } }, // 11
+ { 0x6000, { 0x0411, 0x0408, 0 } }, // 12
+ { 0x4001, { 7830, 0x0406, 1 } }, // 13
+ { 0x6000, { 0x0413, 0x0408, 0 } } // 14
+};
+static const mso_CustomShape msoActionButtonDocument =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonDocumentVert, sizeof( mso_sptActionButtonDocumentVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonDocumentSegm, sizeof( mso_sptActionButtonDocumentSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonDocumentCalc, sizeof( mso_sptActionButtonDocumentCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonSoundVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 4 MSO_I },
+
+ { 0xa MSO_I, 0xc MSO_I }, { 0xe MSO_I, 0xc MSO_I }, { 0x10 MSO_I, 0x12 MSO_I }, { 0x10 MSO_I, 0x14 MSO_I },
+ { 0xe MSO_I, 0x16 MSO_I }, { 0xa MSO_I, 0x16 MSO_I }, { 0x18 MSO_I, 8 MSO_I }, { 0x1a MSO_I, 8 MSO_I },
+
+ { 0x18 MSO_I, 0xc MSO_I }, { 0x1a MSO_I, 0x1c MSO_I },
+
+ { 0x18 MSO_I, 0x16 MSO_I }, { 0x1a MSO_I, 0x1e MSO_I }
+};
+static const sal_uInt16 mso_sptActionButtonSoundSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+
+ 0x4000, 0x0005, 0x6001, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptActionButtonSoundCalc[] = // adj value 0 - 5400
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x0405, 1, 10800 } }, // scaling 6
+ { 0x2001, { DFF_Prop_geoRight, 1, 2 } }, // lr center 7
+ { 0x2001, { DFF_Prop_geoBottom, 1, 2 } }, // ul center 8
+
+ { 0x4001, { -8050, 0x0406, 1 } }, // 9
+ { 0x6000, { 0x0409, 0x0407, 0 } }, // a
+ { 0x4001, { -2750, 0x0406, 1 } }, // b
+ { 0x6000, { 0x040b, 0x0408, 0 } }, // c
+ { 0x4001, { -2960, 0x0406, 1 } }, // d
+ { 0x6000, { 0x040d, 0x0407, 0 } }, // e
+ { 0x4001, { 2120, 0x0406, 1 } }, // f
+ { 0x6000, { 0x040f, 0x0407, 0 } }, // 10
+ { 0x4001, { -8050, 0x0406, 1 } }, // 11
+ { 0x6000, { 0x0411, 0x0408, 0 } }, // 12
+ { 0x4001, { 8050, 0x0406, 1 } }, // 13
+ { 0x6000, { 0x0413, 0x0408, 0 } }, // 14
+ { 0x4001, { 2750, 0x0406, 1 } }, // 15
+ { 0x6000, { 0x0415, 0x0408, 0 } }, // 16
+ { 0x4001, { 4020, 0x0406, 1 } }, // 17
+ { 0x6000, { 0x0417, 0x0407, 0 } }, // 18
+ { 0x4001, { 8050, 0x0406, 1 } }, // 19
+ { 0x6000, { 0x0419, 0x0407, 0 } }, // 1a
+ { 0x4001, { -5930, 0x0406, 1 } }, // 1b
+ { 0x6000, { 0x041b, 0x0408, 0 } }, // 1c
+ { 0x4001, { 5930, 0x0406, 1 } }, // 1d
+ { 0x6000, { 0x041d, 0x0408, 0 } } // 1e
+};
+static const mso_CustomShape msoActionButtonSound =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonSoundVert, sizeof( mso_sptActionButtonSoundVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonSoundSegm, sizeof( mso_sptActionButtonSoundSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonSoundCalc, sizeof( mso_sptActionButtonSoundCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptActionButtonMovieVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 0 }, { 21600, 0 }, { 3 MSO_I, 2 MSO_I }, { 1 MSO_I, 2 MSO_I },
+ { 21600, 0 }, { 21600, 21600 }, { 3 MSO_I, 4 MSO_I }, { 3 MSO_I, 2 MSO_I },
+ { 21600, 21600 }, { 0, 21600 }, { 1 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 0, 21600 }, { 0, 0 }, { 1 MSO_I, 2 MSO_I }, { 1 MSO_I, 4 MSO_I },
+
+ { 0xa MSO_I, 0xc MSO_I }, { 0xe MSO_I, 0xc MSO_I }, { 0x10 MSO_I, 0x12 MSO_I }, { 0x14 MSO_I, 0x12 MSO_I },
+ { 0x16 MSO_I, 0x18 MSO_I }, { 0x16 MSO_I, 0x1a MSO_I }, { 0x1c MSO_I, 0x1a MSO_I }, { 0x1e MSO_I, 0x18 MSO_I },
+ { 0x20 MSO_I, 0x18 MSO_I }, { 0x20 MSO_I, 0x22 MSO_I }, { 0x1e MSO_I, 0x22 MSO_I }, { 0x1c MSO_I, 0x24 MSO_I },
+ { 0x16 MSO_I, 0x24 MSO_I }, { 0x16 MSO_I, 0x26 MSO_I }, { 0x2a MSO_I, 0x26 MSO_I }, { 0x2a MSO_I, 0x28 MSO_I },
+ { 0x10 MSO_I, 0x28 MSO_I }, { 0xe MSO_I, 0x2c MSO_I }, { 0xa MSO_I, 0x2c MSO_I }
+};
+static const sal_uInt16 mso_sptActionButtonMovieSegm[] =
+{
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0003, 0x6001, 0x8000,
+ 0x4000, 0x0012, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptActionButtonMovieCalc[] = // adj value 0 - 5400
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x0405, 1, 10800 } }, // scaling 6
+ { 0x2001, { DFF_Prop_geoRight, 1, 2 } }, // lr center 7
+ { 0x2001, { DFF_Prop_geoBottom, 1, 2 } }, // ul center 8
+
+ { 0x4001, { -8050, 0x0406, 1 } }, // 9
+ { 0x6000, { 0x0409, 0x0407, 0 } }, // a
+ { 0x4001, { -4020, 0x0406, 1 } }, // b
+ { 0x6000, { 0x040b, 0x0408, 0 } }, // c
+ { 0x4001, { -7000, 0x0406, 1 } }, // d
+ { 0x6000, { 0x040d, 0x0407, 0 } }, // e
+ { 0x4001, { -6560, 0x0406, 1 } }, // f
+ { 0x6000, { 0x040f, 0x0407, 0 } }, // 10
+ { 0x4001, { -3600, 0x0406, 1 } }, // 11
+ { 0x6000, { 0x0411, 0x0408, 0 } }, // 12
+ { 0x4001, { 4020, 0x0406, 1 } }, // 13
+ { 0x6000, { 0x0413, 0x0407, 0 } }, // 14
+ { 0x4001, { 4660, 0x0406, 1 } }, // 15
+ { 0x6000, { 0x0415, 0x0407, 0 } }, // 16
+ { 0x4001, { -2960, 0x0406, 1 } }, // 17
+ { 0x6000, { 0x0417, 0x0408, 0 } }, // 18
+ { 0x4001, { -2330, 0x0406, 1 } }, // 19
+ { 0x6000, { 0x0419, 0x0408, 0 } }, // 1a
+ { 0x4001, { 6780, 0x0406, 1 } }, // 1b
+ { 0x6000, { 0x041b, 0x0407, 0 } }, // 1c
+ { 0x4001, { 7200, 0x0406, 1 } }, // 1d
+ { 0x6000, { 0x041d, 0x0407, 0 } }, // 1e
+ { 0x4001, { 8050, 0x0406, 1 } }, // 1f
+ { 0x6000, { 0x041f, 0x0407, 0 } }, // 20
+ { 0x4001, { 2960, 0x0406, 1 } }, // 21
+ { 0x6000, { 0x0421, 0x0408, 0 } }, // 22
+ { 0x4001, { 2330, 0x0406, 1 } }, // 23
+ { 0x6000, { 0x0423, 0x0408, 0 } }, // 24
+ { 0x4001, { 3800, 0x0406, 1 } }, // 25
+ { 0x6000, { 0x0425, 0x0408, 0 } }, // 26
+ { 0x4001, { -1060, 0x0406, 1 } }, // 27
+ { 0x6000, { 0x0427, 0x0408, 0 } }, // 28
+ { 0x4001, { -6350, 0x0406, 1 } }, // 29
+ { 0x6000, { 0x0429, 0x0407, 0 } }, // 2a
+ { 0x4001, { -640, 0x0406, 1 } }, // 2b
+ { 0x6000, { 0x042b, 0x0408, 0 } } // 2c
+};
+static const mso_CustomShape msoActionButtonMovie =
+{
+ (SvxMSDffVertPair*)mso_sptActionButtonMovieVert, sizeof( mso_sptActionButtonMovieVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptActionButtonMovieSegm, sizeof( mso_sptActionButtonMovieSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptActionButtonMovieCalc, sizeof( mso_sptActionButtonMovieCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1400,
+ (SvxMSDffTextRectangles*)mso_sptActionButtonTextRect, sizeof( mso_sptActionButtonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptButtonHandle, sizeof( mso_sptButtonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptSmileyFaceVert[] = // adj value 15510 - 17520
+{
+ { 10800, 10800 }, { 10800, 10800 }, { 0, 360 },
+ { 7305, 7515 }, { 1165, 1165 }, { 0, 360 },
+ { 14295, 7515 }, { 1165, 1165 }, { 0, 360 },
+ { 4870, 1 MSO_I }, { 8680, 2 MSO_I }, { 12920, 2 MSO_I }, { 16730, 1 MSO_I }
+};
+static const sal_uInt16 mso_sptSmileyFaceSegm[] =
+{
+ 0xa203, 0x6000, 0x8000,
+ 0xa203, 0x6000, 0x8000,
+ 0xa203, 0x6000, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptSmileyFaceCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 15510 } },
+ { 0x8000, { 17520, 0, 0x400 } },
+ { 0x4000, { 15510, 0x400, 0 } }
+};
+
+static const SvxMSDffTextRectangles mso_sptSmileyFaceTextRect[] =
+{
+ { { 0, 1 MSO_I }, { 4 MSO_I, 21600 } }
+};
+static const sal_Int32 mso_sptSmileyFaceDefault[] =
+{
+ 1, 17520
+};
+static const SvxMSDffHandle mso_sptSmileyHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 15510, 17520 }
+};
+static const mso_CustomShape msoSmileyFace =
+{
+ (SvxMSDffVertPair*)mso_sptSmileyFaceVert, sizeof( mso_sptSmileyFaceVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptSmileyFaceSegm, sizeof( mso_sptSmileyFaceSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptSmileyFaceCalc, sizeof( mso_sptSmileyFaceCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptSmileyFaceDefault,
+ (SvxMSDffTextRectangles*)mso_sptEllipseTextRect, sizeof( mso_sptEllipseTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptEllipseGluePoints, sizeof( mso_sptEllipseGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptSmileyHandle, sizeof( mso_sptSmileyHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptDonutVert[] = // adj value 0 - 10800
+{
+ { 10800, 10800 }, { 10800, 10800 }, { 0, 360 },
+ { 10800, 10800 }, { 1 MSO_I, 1 MSO_I }, { 0, 360 }
+};
+static const sal_uInt16 mso_sptDonutSegm[] =
+{
+ 0xa203, 0x6000, 0xa203, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptDonutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } }
+};
+static const SvxMSDffHandle mso_sptDonutHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 10800, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoDonut =
+{
+ (SvxMSDffVertPair*)mso_sptDonutVert, sizeof( mso_sptDonutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptDonutSegm, sizeof( mso_sptDonutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptDonutCalc, sizeof( mso_sptDonutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault5400,
+ (SvxMSDffTextRectangles*)mso_sptEllipseTextRect, sizeof( mso_sptEllipseTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptEllipseGluePoints, sizeof( mso_sptEllipseGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptDonutHandle, sizeof( mso_sptDonutHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptNoSmokingVert[] = // adj value 0 - 7200
+{
+ { 10800, 10800 }, { 10800, 10800 }, { 0, 360 },
+ { 0 MSO_I, 0 MSO_I }, { 1 MSO_I, 1 MSO_I },
+ { 9 MSO_I, 0xa MSO_I }, { 0xb MSO_I, 0xc MSO_I }, { 0 MSO_I, 0 MSO_I }, { 1 MSO_I, 1 MSO_I },
+ { 0xd MSO_I, 0xe MSO_I }, { 0xf MSO_I, 0x10 MSO_I }
+};
+static const sal_uInt16 mso_sptNoSmokingSegm[] =
+{
+ 0xa203, 0x6000, 0xa404, 0x6000, 0xa404, 0x6000, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptNoSmokingCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 0
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }, // 1
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } }, // 2
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } }, // 3
+ { 0xa080, { 0x403, 0, 0x402 } }, // 4
+ { 0x8000, { 10800, 0, 0x403 } }, // 5 x1
+ { 0x4000, { 10800, 0x403, 0 } }, // 6 x2
+ { 0x8000, { 10800, 0, 0x404 } }, // 7 y1
+ { 0x4000, { 10800, 0x404, 0 } }, // 8 y2
+ { 0x6081, { 0x405, 0x407, 45 } }, // 9
+ { 0x6082, { 0x405, 0x407, 45 } }, // a
+ { 0x6081, { 0x405, 0x408, 45 } }, // b
+ { 0x6082, { 0x405, 0x408, 45 } }, // c
+ { 0x6081, { 0x406, 0x408, 45 } }, // d
+ { 0x6082, { 0x406, 0x408, 45 } }, // e
+ { 0x6081, { 0x406, 0x407, 45 } }, // f
+ { 0x6082, { 0x406, 0x407, 45 } } // 10
+};
+static const SvxMSDffHandle mso_sptNoSmokingHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 10800, 10800, 10800, 0, 7200, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoNoSmoking =
+{
+ (SvxMSDffVertPair*)mso_sptNoSmokingVert, sizeof( mso_sptNoSmokingVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptNoSmokingSegm, sizeof( mso_sptNoSmokingSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptNoSmokingCalc, sizeof( mso_sptNoSmokingCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault2700,
+ (SvxMSDffTextRectangles*)mso_sptEllipseTextRect, sizeof( mso_sptEllipseTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptEllipseGluePoints, sizeof( mso_sptEllipseGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptNoSmokingHandle, sizeof( mso_sptNoSmokingHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptBlockArcVert[] = // adj value 0 (degrees)
+{ // adj value 1: 0 -> 10800;
+ { 0, 0 }, { 21600, 21600 }, { 4 MSO_I, 3 MSO_I }, { 2 MSO_I, 3 MSO_I },
+ { 5 MSO_I, 5 MSO_I }, { 6 MSO_I, 6 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 4 MSO_I, 3 MSO_I }
+};
+static const sal_uInt16 mso_sptBlockArcSegm[] =
+{
+ 0xA404, 0xa504, 0x6001, 0x8000
+};
+static const sal_Int32 mso_sptBlockArcDefault[] =
+{
+ 2, 180, 5400
+};
+static const SvxMSDffCalculationData mso_sptBlockArcCalc[] =
+{
+ { 0x400a, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x4009, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x2000, { 0x400, 10800, 0 } },
+ { 0x2000, { 0x401, 10800, 0 } },
+ { 0x8000, { 21600, 0, 0x402 } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjust2Value } },
+ { 0x4000, { 10800, DFF_Prop_adjust2Value, 0 } },
+ { 0x600a, { 0x405, DFF_Prop_adjustValue, 0 } },
+ { 0x6009, { 0x405, DFF_Prop_adjustValue, 0 } }
+};
+static const SvxMSDffHandle mso_sptBlockArcHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_POLAR | MSDFF_HANDLE_FLAGS_RADIUS_RANGE,
+ 0x101, 0x100, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoBlockArc =
+{
+ (SvxMSDffVertPair*)mso_sptBlockArcVert, sizeof( mso_sptBlockArcVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBlockArcSegm, sizeof( mso_sptBlockArcSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBlockArcCalc, sizeof( mso_sptBlockArcCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptBlockArcDefault,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptBlockArcHandle, sizeof( mso_sptBlockArcHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+// aware : control points are always part of the bounding box
+static const SvxMSDffVertPair mso_sptHeartVert[] =
+{
+ { 10800, 21599 }, { 321, 6886 }, { 70, 6036 }, // ppp
+ { -9, 5766 }, { -1, 5474 }, { 2, 5192 }, // ccp
+ { 6, 4918 }, { 43, 4641 }, { 101, 4370 }, // ccp
+ { 159, 4103 }, { 245, 3837 }, { 353, 3582 }, // ccp
+ { 460, 3326 }, { 591, 3077 }, { 741, 2839 }, // ccp
+ { 892, 2598 }, { 1066, 2369 }, { 1253, 2155 }, // ccp
+ { 1443, 1938 }, { 1651, 1732 }, { 1874, 1543 }, // ccp
+ { 2097, 1351 }, { 2337, 1174 }, { 2587, 1014 }, // ccp
+ { 2839, 854 }, { 3106, 708 }, { 3380, 584 }, // ccp
+ { 3656, 459 }, { 3945, 350 }, { 4237, 264 }, // ccp
+ { 4533, 176 }, { 4838, 108 }, { 5144, 66 }, // ccp
+ { 5454, 22 }, { 5771, 1 }, { 6086, 3 }, // ccp
+ { 6407, 7 }, { 6731, 35 }, { 7048, 89 }, // ccp
+ { 7374, 144 }, { 7700, 226 }, { 8015, 335 }, // ccp
+ { 8344, 447 }, { 8667, 590 }, { 8972, 756 }, // ccp
+ { 9297, 932 }, { 9613, 1135 }, { 9907, 1363 }, // ccp
+ { 10224, 1609 }, { 10504, 1900 }, { 10802, 2169 }, // ccp
+ { 11697, 1363 }, // p
+ { 11971, 1116 }, { 12304, 934 }, { 12630, 756 }, // ccp
+ { 12935, 590 }, { 13528, 450 }, { 13589, 335 }, // ccp
+ { 13901, 226 }, { 14227, 144 }, { 14556, 89 }, // ccp
+ { 14872, 35 }, { 15195, 7 }, { 15517, 3 }, // ccp
+ { 15830, 0 }, { 16147, 22 }, { 16458, 66 }, // ccp
+ { 16764, 109 }, { 17068, 177 }, { 17365, 264 }, // ccp
+ { 17658, 349 }, { 17946, 458 }, { 18222, 584 }, // ccp
+ { 18496, 708 }, { 18762, 854 }, { 19015, 1014 }, // ccp
+ { 19264, 1172 }, { 19504, 1349 }, { 19730, 1543 }, // ccp
+ { 19950, 1731 }, { 20158, 1937 }, { 20350, 2155 }, // ccp
+ { 20536, 2369 }, { 20710, 2598 }, { 20861, 2839 }, // ccp
+ { 21010, 3074 }, { 21143, 3323 }, { 21251, 3582 }, // ccp
+ { 21357, 3835 }, { 21443, 4099 }, { 21502, 4370 }, // ccp
+ { 21561, 4639 }, { 21595, 4916 }, { 21600, 5192 }, // ccp
+ { 21606, 5474 }, { 21584, 5760 }, { 21532, 6036 }, // ccp
+ { 21478, 6326 }, { 21366, 6603 }, { 21282, 6887 }, // ccp
+ { 10802, 21602 } // p
+};
+static const sal_uInt16 mso_sptHeartSegm[] =
+{
+ 0x4000, 0x0002, 0x2010, 0x0001, 0x2010, 0x0001, 0x6001, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptHeartTextRect[] =
+{
+ { { 5080, 2540 }, { 16520, 13550 } }
+};
+static const SvxMSDffVertPair mso_sptHeartGluePoints[] =
+{
+ { 10800, 2180 }, { 3090, 10800 }, { 10800, 21600 }, { 18490, 10800 }
+};
+static const mso_CustomShape msoHeart =
+{
+ (SvxMSDffVertPair*)mso_sptHeartVert, sizeof( mso_sptHeartVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptHeartSegm, sizeof( mso_sptHeartSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptHeartTextRect, sizeof( mso_sptHeartTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21615, 21602,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptHeartGluePoints, sizeof( mso_sptHeartGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptLightningBoldVert[] =
+{
+ { 8458, 0 }, { 0, 3923 }, { 7564, 8416 }, { 4993, 9720 },
+ { 12197, 13904 }, { 9987, 14934 }, { 21600, 21600 }, { 14768, 12911 },
+ { 16558, 12016 }, { 11030, 6840 }, { 12831, 6120 }, { 8458, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptLightningBoldTextRect[] =
+{
+ { { 8680, 7410 }, { 13970, 14190 } }
+};
+static const SvxMSDffVertPair mso_sptLightningBoldGluePoints[] =
+{
+ { 8458, 0 }, { 0, 3923 }, { 4993, 9720 }, { 9987, 14934 }, { 21600, 21600 },
+ { 16558, 12016 }, { 12831, 6120 }
+};
+static const mso_CustomShape msoLightningBold =
+{
+ (SvxMSDffVertPair*)mso_sptLightningBoldVert, sizeof( mso_sptLightningBoldVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptLightningBoldTextRect, sizeof( mso_sptLightningBoldTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptLightningBoldGluePoints, sizeof( mso_sptLightningBoldGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptSunVert[] = // adj value 2700 -> 10125
+{
+ { 0, 10800 }, { 4 MSO_I, 8 MSO_I }, { 4 MSO_I, 9 MSO_I },
+ { 0x0a MSO_I, 0x0b MSO_I }, { 0x0c MSO_I, 0x0d MSO_I }, { 0x0e MSO_I, 0x0f MSO_I },
+ { 0x10 MSO_I, 0x11 MSO_I }, { 0x12 MSO_I, 0x13 MSO_I }, { 0x14 MSO_I, 0x15 MSO_I },
+ { 0x16 MSO_I, 0x17 MSO_I }, { 0x18 MSO_I, 0x19 MSO_I }, { 0x1a MSO_I, 0x1b MSO_I },
+ { 0x1c MSO_I, 0x1d MSO_I }, { 0x1e MSO_I, 0x1f MSO_I }, { 0x20 MSO_I, 0x21 MSO_I },
+ { 0x22 MSO_I, 0x23 MSO_I }, { 0x24 MSO_I, 0x25 MSO_I }, { 0x26 MSO_I, 0x27 MSO_I },
+ { 0x28 MSO_I, 0x29 MSO_I }, { 0x2a MSO_I, 0x2b MSO_I }, { 0x2c MSO_I, 0x2d MSO_I },
+ { 0x2e MSO_I, 0x2f MSO_I }, { 0x30 MSO_I, 0x31 MSO_I }, { 0x32 MSO_I, 0x33 MSO_I },
+ { 10800, 10800 }, { 0x36 MSO_I, 0x36 MSO_I }, { 0, 360 }
+};
+static const sal_uInt16 mso_sptSunSegm[] =
+{
+ 0x4000, 0x0002, 0x6001, 0x8000,
+ 0x4000, 0x0002, 0x6001, 0x8000,
+ 0x4000, 0x0002, 0x6001, 0x8000,
+ 0x4000, 0x0002, 0x6001, 0x8000,
+ 0x4000, 0x0002, 0x6001, 0x8000,
+ 0x4000, 0x0002, 0x6001, 0x8000,
+ 0x4000, 0x0002, 0x6001, 0x8000,
+ 0x4000, 0x0002, 0x6001, 0x8000,
+ 0xa203, 0x6000, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptSunCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x2000, { DFF_Prop_adjustValue, 0, 2700 } },
+ { 0x2001, { 0x402, 5080, 7425 } },
+ { 0x2000, { 0x403, 2540, 0 } },
+ { 0x8000, { 10125, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x405, 2120, 7425 } },
+ { 0x2000, { 0x406, 210, 0 } },
+ { 0x4000, { 10800, 0x407, 0 } }, // y1 (0x8)
+ { 0x8000, { 10800, 0, 0x407 } }, // y2 (0x9)
+ { 0x0081, { 0, 10800, 45 } }, // 0xa
+ { 0x0082, { 0, 10800, 45 } }, // 0xb
+ { 0x6081, { 0x404, 0x408, 45 } }, // 0xc
+ { 0x6082, { 0x404, 0x408, 45 } }, // 0xd
+ { 0x6081, { 0x404, 0x409, 45 } }, // 0xe
+ { 0x6082, { 0x404, 0x409, 45 } }, // 0xf
+ { 0x0081, { 0, 10800, 90 } }, // 0x10
+ { 0x0082, { 0, 10800, 90 } }, // 0x11
+ { 0x6081, { 0x404, 0x408, 90 } }, // 0x12
+ { 0x6082, { 0x404, 0x408, 90 } }, // 0x13
+ { 0x6081, { 0x404, 0x409, 90 } }, // 0x14
+ { 0x6082, { 0x404, 0x409, 90 } }, // 0x15
+ { 0x0081, { 0, 10800, 135 } }, // 0x16
+ { 0x0082, { 0, 10800, 135 } }, // 0x17
+ { 0x6081, { 0x404, 0x408, 135 } }, // 0x18
+ { 0x6082, { 0x404, 0x408, 135 } }, // 0x19
+ { 0x6081, { 0x404, 0x409, 135 } }, // 0x1a
+ { 0x6082, { 0x404, 0x409, 135 } }, // 0x1b
+ { 0x0081, { 0, 10800, 180 } }, // 0x1c
+ { 0x0082, { 0, 10800, 180 } }, // 0x1d
+ { 0x6081, { 0x404, 0x408, 180 } }, // 0x1e
+ { 0x6082, { 0x404, 0x408, 180 } }, // 0x1f
+ { 0x6081, { 0x404, 0x409, 180 } }, // 0x20
+ { 0x6082, { 0x404, 0x409, 180 } }, // 0x21
+ { 0x0081, { 0, 10800, 225 } }, // 0x22
+ { 0x0082, { 0, 10800, 225 } }, // 0x23
+ { 0x6081, { 0x404, 0x408, 225 } }, // 0x24
+ { 0x6082, { 0x404, 0x408, 225 } }, // 0x25
+ { 0x6081, { 0x404, 0x409, 225 } }, // 0x26
+ { 0x6082, { 0x404, 0x409, 225 } }, // 0x27
+ { 0x0081, { 0, 10800, 270 } }, // 0x28
+ { 0x0082, { 0, 10800, 270 } }, // 0x29
+ { 0x6081, { 0x404, 0x408, 270 } }, // 0x2a
+ { 0x6082, { 0x404, 0x408, 270 } }, // 0x2b
+ { 0x6081, { 0x404, 0x409, 270 } }, // 0x2c
+ { 0x6082, { 0x404, 0x409, 270 } }, // 0x2d
+ { 0x0081, { 0, 10800, 315 } }, // 0x2e
+ { 0x0082, { 0, 10800, 315 } }, // 0x2f
+ { 0x6081, { 0x404, 0x408, 315 } }, // 0x30
+ { 0x6082, { 0x404, 0x408, 315 } }, // 0x31
+ { 0x6081, { 0x404, 0x409, 315 } }, // 0x32
+ { 0x6082, { 0x404, 0x409, 315 } }, // 0x33
+ { 0x2081, { DFF_Prop_adjustValue, 10800, 45 } }, // 0x34 ( textbox )
+ { 0x2081, { DFF_Prop_adjustValue, 10800, 225 } }, // 0x35
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } }
+};
+static const SvxMSDffTextRectangles mso_sptSunTextRect[] =
+{
+ { { 0x34 MSO_I, 0x34 MSO_I }, { 0x35 MSO_I, 0x35 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptSunHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 10800, 10800, 10800, 2700, 10125, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoSun =
+{
+ (SvxMSDffVertPair*)mso_sptSunVert, sizeof( mso_sptSunVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptSunSegm, sizeof( mso_sptSunSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptSunCalc, sizeof( mso_sptSunCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault5400,
+ (SvxMSDffTextRectangles*)mso_sptSunTextRect, sizeof( mso_sptSunTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptSunHandle, sizeof( mso_sptSunHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptMoonVert[] = // adj value 0 -> 18900
+{
+ { 21600, 0 },
+ { 3 MSO_I, 4 MSO_I }, { 0 MSO_I, 5080 }, { 0 MSO_I, 10800 }, // ccp
+ { 0 MSO_I, 16520 }, { 3 MSO_I, 5 MSO_I }, { 21600, 21600 }, // ccp
+ { 9740, 21600 }, { 0, 16730 }, { 0, 10800 }, // ccp
+ { 0, 4870 }, { 9740, 0 }, { 21600, 0 } // ccp
+};
+static const sal_uInt16 mso_sptMoonSegm[] =
+{
+ 0x4000, 0x2004, 0x6000, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptMoonCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x401, 1, 2 } },
+ { 0x6000, { 0x402, DFF_Prop_adjustValue, 0 } },
+ { 0x2001, { DFF_Prop_adjustValue, 1794, 10000 } },
+ { 0x8000, { 21600, 0, 0x0404 } },
+ { 0x2001, { DFF_Prop_adjustValue, 400, 18900 } },
+ { 0x8081, { 0, 10800, 0x406 } },
+ { 0x8082, { 0, 10800, 0x406 } },
+ { 0x6000, { 0x407, 0x407, 0 } },
+ { 0x8000, { 21600, 0, 0x408 } }
+};
+static const SvxMSDffTextRectangles mso_sptMoonTextRect[] =
+{
+ { { 9 MSO_I, 8 MSO_I }, { 0 MSO_I, 0xa MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptMoonGluePoints[] =
+{
+ { 21600, 0 }, { 0, 10800 }, { 21600, 21600 }, { 0 MSO_I, 10800 }
+};
+static const SvxMSDffHandle mso_sptMoonHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 10800, 10800, 10800, 0, 18900, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoMoon =
+{
+ (SvxMSDffVertPair*)mso_sptMoonVert, sizeof( mso_sptMoonVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptMoonSegm, sizeof( mso_sptMoonSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptMoonCalc, sizeof( mso_sptMoonCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault10800,
+ (SvxMSDffTextRectangles*)mso_sptMoonTextRect, sizeof( mso_sptMoonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptMoonGluePoints, sizeof( mso_sptMoonGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptMoonHandle, sizeof( mso_sptMoonHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptBracketPairVert[] = // adj value 0 -> 10800
+{
+ { 0 MSO_I, 0 }, { 0, 1 MSO_I }, // left top alignment
+ { 0, 2 MSO_I }, { 0 MSO_I, 21600 }, // left bottom "
+ { 3 MSO_I, 21600 }, { 21600, 2 MSO_I }, // right bottom "
+ { 21600, 1 MSO_I }, { 3 MSO_I, 0 } // right top "
+};
+static const sal_uInt16 mso_sptBracketPairSegm[] =
+{
+ 0x4000, 0xa701, 0x0001, 0xa801, 0x8000,
+ 0x4000, 0xa701, 0x0001, 0xa801, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptBracketPairCalc[] =
+{
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0x2082, { DFF_Prop_adjustValue, 0, 45 } },
+ { 0x2000, { 0x404, 0, 10800 } },
+ { 0x8000, { 0, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { 0x406, 0, 0x405 } },
+ { 0xa000, { DFF_Prop_geoLeft, 0, 0x407 } },
+ { 0xa000, { DFF_Prop_geoTop, 0, 0x407 } },
+ { 0x6000, { DFF_Prop_geoRight, 0x407, 0 } },
+ { 0x6000, { DFF_Prop_geoBottom, 0x407, 0 } },
+ { 0xa000, { DFF_Prop_geoLeft, 0, 0x405 } },
+ { 0xa000, { DFF_Prop_geoTop, 0, 0x405 } },
+ { 0x6000, { DFF_Prop_geoRight, 0x405, 0 } },
+ { 0x6000, { DFF_Prop_geoBottom, 0x405, 0 } }
+};
+static const SvxMSDffTextRectangles mso_sptBracketPairTextRect[] =
+{
+ { { 8 MSO_I, 9 MSO_I }, { 0xa MSO_I, 0xb MSO_I } }
+};
+static const SvxMSDffHandle mso_sptBracketPairHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_SWITCHED,
+ 0x100, 0, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoBracketPair =
+{
+ (SvxMSDffVertPair*)mso_sptBracketPairVert, sizeof( mso_sptBracketPairVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBracketPairSegm, sizeof( mso_sptBracketPairSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBracketPairCalc, sizeof( mso_sptBracketPairCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault3700,
+ (SvxMSDffTextRectangles*)mso_sptBracketPairTextRect, sizeof( mso_sptBracketPairTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptBracketPairHandle, sizeof( mso_sptBracketPairHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const sal_uInt16 mso_sptPlaqueSegm[] =
+{
+ 0x4000, 0xa801, 0x0001, 0xa701, 0x0001, 0xa801, 0x0001, 0xa701, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptPlaqueTextRect[] =
+{
+ { { 0xc MSO_I, 0xd MSO_I }, { 0xe MSO_I, 0xf MSO_I } }
+};
+static const SvxMSDffHandle mso_sptPlaqueHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_SWITCHED,
+ 0x100, 0, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoPlaque =
+{
+ (SvxMSDffVertPair*)mso_sptBracketPairVert, sizeof( mso_sptBracketPairVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptPlaqueSegm, sizeof( mso_sptPlaqueSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBracketPairCalc, sizeof( mso_sptBracketPairCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault3600,
+ (SvxMSDffTextRectangles*)mso_sptPlaqueTextRect, sizeof( mso_sptPlaqueTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 10800,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptPlaqueHandle, sizeof( mso_sptPlaqueHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptBracePairVert[] = // adj value 0 -> 5400
+{
+ { 4 MSO_I, 0 }, { 0 MSO_I, 1 MSO_I }, { 0 MSO_I, 6 MSO_I }, { 0 ,10800 }, // left bracket
+ { 0 MSO_I, 7 MSO_I }, { 0 MSO_I, 2 MSO_I }, { 4 MSO_I, 21600 },
+ { 8 MSO_I, 21600 }, { 3 MSO_I, 2 MSO_I }, { 3 MSO_I, 7 MSO_I }, { 21600, 10800 }, // right bracket
+ { 3 MSO_I, 6 MSO_I }, { 3 MSO_I, 1 MSO_I }, { 8 MSO_I, 0 }
+};
+static const sal_uInt16 mso_sptBracePairSegm[] =
+{
+ 0x4000, 0xa701, 0x0001, 0xa801, 0xa701, 0x0001, 0xa801, 0x8000,
+ 0x4000, 0xa701, 0x0001, 0xa801, 0xa701, 0x0001, 0xa801, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptBracePairCalc[] =
+{
+ { 0x6000, { DFF_Prop_geoLeft, DFF_Prop_adjustValue, 0 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { DFF_Prop_geoRight, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x400, 2, 1 } }, // 4
+ { 0x2001, { DFF_Prop_adjustValue, 2, 1 } }, // 5
+ { 0x8000, { 10800, 0, DFF_Prop_adjustValue } }, // 6
+ { 0x8000, { 21600, 0, 0x406 } }, // 7
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x405 } }, // 8
+ { 0x2001, { DFF_Prop_adjustValue, 1, 3 } }, // 9
+ { 0x6000, { 0x409, DFF_Prop_adjustValue, 0 } }, // xa
+ { 0x6000, { DFF_Prop_geoLeft, 0x40a, 0 } }, // xb
+ { 0x6000, { DFF_Prop_geoTop, 0x409, 0 } }, // xc
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x40a } }, // xd
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x409 } } // xe
+};
+static const SvxMSDffTextRectangles mso_sptBracePairTextRect[] =
+{
+ { { 0xb MSO_I, 0xc MSO_I }, { 0xd MSO_I, 0xe MSO_I } }
+};
+static const SvxMSDffHandle mso_sptBracePairHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_SWITCHED,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 5400 }
+};
+static const mso_CustomShape msoBracePair =
+{
+ (SvxMSDffVertPair*)mso_sptBracePairVert, sizeof( mso_sptBracePairVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBracePairSegm, sizeof( mso_sptBracePairSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBracePairCalc, sizeof( mso_sptBracePairCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1800,
+ (SvxMSDffTextRectangles*)mso_sptBracePairTextRect, sizeof( mso_sptBracePairTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptBracePairHandle, sizeof( mso_sptBracePairHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffCalculationData mso_sptBracketCalc[] =
+{
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } },
+ { 0x6000, { DFF_Prop_geoTop, DFF_Prop_adjustValue, 0 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, DFF_Prop_adjustValue } },
+ { 0x6000, { DFF_Prop_geoTop, 0x400, 0 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x400 } }
+};
+static const sal_uInt16 mso_sptBracketSegm[] =
+{
+ 0x4000, 0x2001, 0x0001, 0x2001, 0x8000
+};
+static const SvxMSDffVertPair mso_sptLeftBracketVert[] = // adj value 0 -> 10800
+{
+ { 21600, 0 }, { 10800, 0 }, { 0, 3 MSO_I }, { 0, 1 MSO_I },
+ { 0, 2 MSO_I }, { 0, 4 MSO_I }, { 10800, 21600 }, { 21600, 21600 }
+};
+static const SvxMSDffTextRectangles mso_sptLeftBracketTextRect[] =
+{
+ { { 6350, 3 MSO_I }, { 21600, 4 MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptLeftBracketGluePoints[] =
+{
+ { 21600, 0 }, { 0, 10800 }, { 21600, 21600 }
+};
+static const SvxMSDffHandle mso_sptLeftBracketHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 10800 }
+};
+static const mso_CustomShape msoLeftBracket =
+{
+ (SvxMSDffVertPair*)mso_sptLeftBracketVert, sizeof( mso_sptLeftBracketVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBracketSegm, sizeof( mso_sptBracketSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBracketCalc, sizeof( mso_sptBracketCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1800,
+ (SvxMSDffTextRectangles*)mso_sptLeftBracketTextRect, sizeof( mso_sptLeftBracketTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptLeftBracketGluePoints, sizeof( mso_sptLeftBracketGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptLeftBracketHandle, sizeof( mso_sptLeftBracketHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+static const SvxMSDffVertPair mso_sptRightBracketVert[] = // adj value 0 -> 10800
+{
+ { 0, 0 }, { 10800, 0 }, { 21600, 3 MSO_I }, { 21600, 1 MSO_I },
+ { 21600, 2 MSO_I }, { 21600, 4 MSO_I }, { 10800, 21600 }, { 0, 21600 }
+};
+static const SvxMSDffTextRectangles mso_sptRightBracketTextRect[] =
+{
+ { { 0, 3 MSO_I }, { 15150, 4 MSO_I } }
+};
+static const SvxMSDffVertPair mso_sptRightBracketGluePoints[] =
+{
+ { 0, 0 }, { 0, 21600 }, { 21600, 10800 }
+};
+static const SvxMSDffHandle mso_sptRightBracketHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 1, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 10800 }
+};
+static const mso_CustomShape msoRightBracket =
+{
+ (SvxMSDffVertPair*)mso_sptRightBracketVert, sizeof( mso_sptRightBracketVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBracketSegm, sizeof( mso_sptBracketSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBracketCalc, sizeof( mso_sptBracketCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault1800,
+ (SvxMSDffTextRectangles*)mso_sptRightBracketTextRect, sizeof( mso_sptRightBracketTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptRightBracketGluePoints, sizeof( mso_sptRightBracketGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptRightBracketHandle, sizeof( mso_sptRightBracketHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffCalculationData mso_sptBraceCalc[] =
+{
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } },
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0xa000, { 0x404, 0, DFF_Prop_adjustValue } },
+ { 0xa000, { 0x404, 0, 0x400 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x6000, { 0x404, 0x400, 0 } },
+ { 0x6000, { 0x404, DFF_Prop_adjustValue, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x8000, { 21600, 0, 0x400 } },
+ { 0x2001, { DFF_Prop_adjustValue, 10000, 31953 } },
+ { 0x8000, { 21600, 0, 0x409 } }
+};
+static const sal_uInt16 mso_sptBraceSegm[] =
+{
+ 0x4000, 0x2001, 0x0001, 0x2002, 0x0001, 0x2001, 0x8000
+};
+static const sal_Int32 mso_sptBraceDefault[] =
+{
+ 2, 1800, 10800
+};
+static const SvxMSDffVertPair mso_sptLeftBraceVert[] =
+{
+ { 21600, 0 }, // p
+ { 16200, 0 }, { 10800, 0 MSO_I }, { 10800, 1 MSO_I }, // ccp
+ { 10800, 2 MSO_I }, // p
+ { 10800, 3 MSO_I }, { 5400, 4 MSO_I }, { 0, 4 MSO_I }, // ccp
+ { 5400, 4 MSO_I }, { 10800, 5 MSO_I }, { 10800, 6 MSO_I }, // ccp
+ { 10800, 7 MSO_I }, // p
+ { 10800, 8 MSO_I }, { 16200, 21600 }, { 21600, 21600 } // ccp
+};
+static const SvxMSDffTextRectangles mso_sptLeftBraceTextRect[] =
+{
+ { { 13800, 9 MSO_I }, { 21600, 10 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptLeftBraceHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 5400 },
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 0, 21600 }
+};
+static const mso_CustomShape msoLeftBrace = // adj value0 0 -> 5400
+{ // adj value1 0 -> 21600
+ (SvxMSDffVertPair*)mso_sptLeftBraceVert, sizeof( mso_sptLeftBraceVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBraceSegm, sizeof( mso_sptBraceSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBraceCalc, sizeof( mso_sptBraceCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptBraceDefault,
+ (SvxMSDffTextRectangles*)mso_sptLeftBraceTextRect, sizeof( mso_sptLeftBraceTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptLeftBracketGluePoints, sizeof( mso_sptLeftBracketGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptLeftBraceHandle, sizeof( mso_sptLeftBraceHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+static const SvxMSDffVertPair mso_sptRightBraceVert[] =
+{
+ { 0, 0 }, // p
+ { 5400, 0 }, { 10800, 0 MSO_I }, { 10800, 1 MSO_I }, // ccp
+ { 10800, 2 MSO_I }, // p
+ { 10800, 3 MSO_I }, { 16200, 4 MSO_I }, { 21600, 4 MSO_I }, // ccp
+ { 16200, 4 MSO_I }, { 10800, 5 MSO_I }, { 10800, 6 MSO_I }, // ccp
+ { 10800, 7 MSO_I }, // p
+ { 10800, 8 MSO_I }, { 5400, 21600 }, { 0, 21600 } // ccp
+};
+static const SvxMSDffTextRectangles mso_sptRightBraceTextRect[] =
+{
+ { { 0, 9 MSO_I }, { 7800, 10 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptRightBraceHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 5400 },
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 1, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 0, 21600 }
+};
+static const mso_CustomShape msoRightBrace = // adj value0 0 -> 5400
+{ // adj value1 0 -> 21600
+ (SvxMSDffVertPair*)mso_sptRightBraceVert, sizeof( mso_sptRightBraceVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBraceSegm, sizeof( mso_sptBraceSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBraceCalc, sizeof( mso_sptBraceCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptBraceDefault,
+ (SvxMSDffTextRectangles*)mso_sptRightBraceTextRect, sizeof( mso_sptRightBraceTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptRightBracketGluePoints, sizeof( mso_sptRightBracketGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptRightBraceHandle, sizeof( mso_sptRightBraceHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptIrregularSeal1Vert[] =
+{
+ { 10901, 5905 }, { 8458, 2399 }, { 7417, 6425 }, { 476, 2399 },
+ { 4732, 7722 }, { 106, 8718 }, { 3828, 11880 }, { 243, 14689 },
+ { 5772, 14041 }, { 4868, 17719 }, { 7819, 15730 }, { 8590, 21600 },
+ { 10637, 15038 }, { 13349, 19840 }, { 14125, 14561 }, { 18248, 18195 },
+ { 16938, 13044 }, { 21600, 13393 }, { 17710, 10579 }, { 21198, 8242 },
+ { 16806, 7417 }, { 18482, 4560 }, { 14257, 5429 }, { 14623, 106 }, { 10901, 5905 }
+};
+static const SvxMSDffTextRectangles mso_sptIrregularSeal1TextRect[] =
+{
+ { { 4680, 6570 }, { 16140, 13280 } }
+};
+static const SvxMSDffVertPair mso_sptIrregularSeal1GluePoints[] =
+{
+ { 14623, 106 }, { 106, 8718 }, { 8590, 21600 }, { 21600, 13393 }
+};
+static const mso_CustomShape msoIrregularSeal1 =
+{
+ (SvxMSDffVertPair*)mso_sptIrregularSeal1Vert, sizeof( mso_sptIrregularSeal1Vert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptIrregularSeal1TextRect, sizeof( mso_sptIrregularSeal1TextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptIrregularSeal1GluePoints, sizeof( mso_sptIrregularSeal1GluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptIrregularSeal2Vert[] =
+{
+ { 11464, 4340 }, { 9722, 1887 }, { 8548, 6383 }, { 4503, 3626 },
+ { 5373, 7816 }, { 1174, 8270 }, { 3934, 11592 }, { 0, 12875 },
+ { 3329, 15372 }, { 1283, 17824 }, { 4804, 18239 }, { 4918, 21600 },
+ { 7525, 18125 }, { 8698, 19712 }, { 9871, 17371 }, { 11614, 18844 },
+ { 12178, 15937 }, { 14943, 17371 }, { 14640, 14348 }, { 18878, 15632 },
+ { 16382, 12311 }, { 18270, 11292 }, { 16986, 9404 }, { 21600, 6646 },
+ { 16382, 6533 }, { 18005, 3172 }, { 14524, 5778 }, { 14789, 0 },
+ { 11464, 4340 }
+};
+static const SvxMSDffTextRectangles mso_sptIrregularSeal2TextRect[] =
+{
+ { { 5400, 6570 }, { 14160, 15290 } }
+};
+static const SvxMSDffVertPair mso_sptIrregularSeal2GluePoints[] =
+{
+ { 9722, 1887 }, { 0, 12875 }, { 11614, 18844 }, { 21600, 6646 }
+};
+static const mso_CustomShape msoIrregularSeal2 =
+{
+ (SvxMSDffVertPair*)mso_sptIrregularSeal2Vert, sizeof( mso_sptIrregularSeal2Vert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptIrregularSeal2TextRect, sizeof( mso_sptIrregularSeal2TextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptIrregularSeal2GluePoints, sizeof( mso_sptIrregularSeal2GluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptSeal4Vert[] = // adjustment1 : 0 - 10800
+{
+ { 0, 10800 }, { 4 MSO_I, 4 MSO_I }, { 10800, 0 }, { 3 MSO_I, 4 MSO_I },
+ { 21600, 10800 }, { 3 MSO_I, 3 MSO_I }, { 10800, 21600 }, { 4 MSO_I, 3 MSO_I },
+ { 0, 10800 }
+};
+static const SvxMSDffCalculationData mso_sptSeal4Calc[] =
+{
+ { 0x0000, { 7600, 0, 0 } },
+ { 0x6001, { 0x400, DFF_Prop_adjustValue, 10800 } },
+ { 0xa000, { 0x400, 0, 0x401 } },
+ { 0x4000, { 10800, 0x402, 0 } },
+ { 0x8000, { 10800, 0, 0x402 } }
+};
+static const SvxMSDffTextRectangles mso_sptSeal4TextRect[] =
+{
+ { { 4 MSO_I, 4 MSO_I }, { 3 MSO_I, 3 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptSealHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 10800, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoSeal4 =
+{
+ (SvxMSDffVertPair*)mso_sptSeal4Vert, sizeof( mso_sptSeal4Vert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ (SvxMSDffCalculationData*)mso_sptSeal4Calc, sizeof( mso_sptSeal4Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault8100,
+ (SvxMSDffTextRectangles*)mso_sptSeal4TextRect, sizeof( mso_sptSeal4TextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptSealHandle, sizeof( mso_sptSealHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptStarVert[] =
+{
+ { 10797, 0 }, { 8278, 8256 }, { 0, 8256 }, { 6722, 13405 },
+ { 4198, 21600 }, { 10797, 16580 }, { 17401, 21600 }, { 14878, 13405 },
+ { 21600, 8256 }, { 13321, 8256 }, { 10797, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptStarTextRect[] =
+{
+ { { 6722, 8256 }, { 14878, 15460 } }
+};
+static const mso_CustomShape msoStar =
+{
+ (SvxMSDffVertPair*)mso_sptStarVert, sizeof( mso_sptStarVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptStarTextRect, sizeof( mso_sptStarTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ NULL, 0 // handles
+};
+
+static const SvxMSDffCalculationData mso_sptSeal24Calc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 0x00
+ { 0x2081, { 0x400, 10800, 315 } }, // 0x01 ( textframe )
+ { 0x2082, { 0x400, 10800, 315 } }, // 0x02
+ { 0x2081, { 0x400, 10800, 135 } }, // 0x03
+ { 0x2082, { 0x400, 10800, 135 } }, // 0x04
+ { 0x0081, { 0, 10800, 0 } },
+ { 0x0082, { 0, 10800, 0 } },
+ { 0x2081, { 0x400, 10800, 7 } },
+ { 0x2082, { 0x400, 10800, 7 } },
+ { 0x0081, { 0, 10800, 15 } },
+ { 0x0082, { 0, 10800, 15 } },
+ { 0x2081, { 0x400, 10800, 22 } },
+ { 0x2082, { 0x400, 10800, 22 } },
+ { 0x0081, { 0, 10800, 30 } },
+ { 0x0082, { 0, 10800, 30 } },
+ { 0x2081, { 0x400, 10800, 37 } },
+ { 0x2082, { 0x400, 10800, 37 } },
+ { 0x0081, { 0, 10800, 45 } },
+ { 0x0082, { 0, 10800, 45 } },
+ { 0x2081, { 0x400, 10800, 52 } },
+ { 0x2082, { 0x400, 10800, 52 } },
+ { 0x0081, { 0, 10800, 60 } },
+ { 0x0082, { 0, 10800, 60 } },
+ { 0x2081, { 0x400, 10800, 67 } },
+ { 0x2082, { 0x400, 10800, 67 } },
+ { 0x0081, { 0, 10800, 75 } },
+ { 0x0082, { 0, 10800, 75 } },
+ { 0x2081, { 0x400, 10800, 82 } },
+ { 0x2082, { 0x400, 10800, 82 } },
+ { 0x0081, { 0, 10800, 90 } },
+ { 0x0082, { 0, 10800, 90 } },
+ { 0x2081, { 0x400, 10800, 97 } },
+ { 0x2082, { 0x400, 10800, 97 } },
+ { 0x0081, { 0, 10800, 105 } },
+ { 0x0082, { 0, 10800, 105 } },
+ { 0x2081, { 0x400, 10800, 112 } },
+ { 0x2082, { 0x400, 10800, 112 } },
+ { 0x0081, { 0, 10800, 120 } },
+ { 0x0082, { 0, 10800, 120 } },
+ { 0x2081, { 0x400, 10800, 127 } },
+ { 0x2082, { 0x400, 10800, 127 } },
+ { 0x0081, { 0, 10800, 135 } },
+ { 0x0082, { 0, 10800, 135 } },
+ { 0x2081, { 0x400, 10800, 142 } },
+ { 0x2082, { 0x400, 10800, 142 } },
+ { 0x0081, { 0, 10800, 150 } },
+ { 0x0082, { 0, 10800, 150 } },
+ { 0x2081, { 0x400, 10800, 157 } },
+ { 0x2082, { 0x400, 10800, 157 } },
+ { 0x0081, { 0, 10800, 165 } },
+ { 0x0082, { 0, 10800, 165 } },
+ { 0x2081, { 0x400, 10800, 172 } },
+ { 0x2082, { 0x400, 10800, 172 } },
+ { 0x0081, { 0, 10800, 180 } },
+ { 0x0082, { 0, 10800, 180 } },
+ { 0x2081, { 0x400, 10800, 187 } },
+ { 0x2082, { 0x400, 10800, 187 } },
+ { 0x0081, { 0, 10800, 195 } },
+ { 0x0082, { 0, 10800, 195 } },
+ { 0x2081, { 0x400, 10800, 202 } },
+ { 0x2082, { 0x400, 10800, 202 } },
+ { 0x0081, { 0, 10800, 210 } },
+ { 0x0082, { 0, 10800, 210 } },
+ { 0x2081, { 0x400, 10800, 217 } },
+ { 0x2082, { 0x400, 10800, 217 } },
+ { 0x0081, { 0, 10800, 225 } },
+ { 0x0082, { 0, 10800, 225 } },
+ { 0x2081, { 0x400, 10800, 232 } },
+ { 0x2082, { 0x400, 10800, 232 } },
+ { 0x0081, { 0, 10800, 240 } },
+ { 0x0082, { 0, 10800, 240 } },
+ { 0x2081, { 0x400, 10800, 247 } },
+ { 0x2082, { 0x400, 10800, 247 } },
+ { 0x0081, { 0, 10800, 255 } },
+ { 0x0082, { 0, 10800, 255 } },
+ { 0x2081, { 0x400, 10800, 262 } },
+ { 0x2082, { 0x400, 10800, 262 } },
+ { 0x0081, { 0, 10800, 270 } },
+ { 0x0082, { 0, 10800, 270 } },
+ { 0x2081, { 0x400, 10800, 277 } },
+ { 0x2082, { 0x400, 10800, 277 } },
+ { 0x0081, { 0, 10800, 285 } },
+ { 0x0082, { 0, 10800, 285 } },
+ { 0x2081, { 0x400, 10800, 292 } },
+ { 0x2082, { 0x400, 10800, 292 } },
+ { 0x0081, { 0, 10800, 300 } },
+ { 0x0082, { 0, 10800, 300 } },
+ { 0x2081, { 0x400, 10800, 307 } },
+ { 0x2082, { 0x400, 10800, 307 } },
+ { 0x0081, { 0, 10800, 315 } },
+ { 0x0082, { 0, 10800, 315 } },
+ { 0x2081, { 0x400, 10800, 322 } },
+ { 0x2082, { 0x400, 10800, 322 } },
+ { 0x0081, { 0, 10800, 330 } },
+ { 0x0082, { 0, 10800, 330 } },
+ { 0x2081, { 0x400, 10800, 337 } },
+ { 0x2082, { 0x400, 10800, 337 } },
+ { 0x0081, { 0, 10800, 345 } },
+ { 0x0082, { 0, 10800, 345 } },
+ { 0x2081, { 0x400, 10800, 352 } },
+ { 0x2082, { 0x400, 10800, 352 } }
+};
+static const SvxMSDffVertPair mso_sptSeal8Vert[] = // adj value 0 -> 10800
+{
+ { 5 MSO_I, 6 MSO_I }, { 11 MSO_I, 12 MSO_I }, { 17 MSO_I, 18 MSO_I }, { 23 MSO_I, 24 MSO_I },
+ { 29 MSO_I, 30 MSO_I }, { 35 MSO_I, 36 MSO_I }, { 41 MSO_I, 42 MSO_I }, { 47 MSO_I, 48 MSO_I },
+ { 53 MSO_I, 54 MSO_I }, { 59 MSO_I, 60 MSO_I }, { 65 MSO_I, 66 MSO_I }, { 71 MSO_I, 72 MSO_I },
+ { 77 MSO_I, 78 MSO_I }, { 83 MSO_I, 84 MSO_I }, { 89 MSO_I, 90 MSO_I }, { 95 MSO_I, 96 MSO_I },
+ { 5 MSO_I, 6 MSO_I }
+};
+static const SvxMSDffTextRectangles mso_sptSealTextRect[] =
+{
+ { { 1 MSO_I, 2 MSO_I }, { 3 MSO_I, 4 MSO_I } }
+};
+static const mso_CustomShape msoSeal8 =
+{
+ (SvxMSDffVertPair*)mso_sptSeal8Vert, sizeof( mso_sptSeal8Vert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ (SvxMSDffCalculationData*)mso_sptSeal24Calc, sizeof( mso_sptSeal24Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault2500,
+ (SvxMSDffTextRectangles*)mso_sptSealTextRect, sizeof( mso_sptSealTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptSealHandle, sizeof( mso_sptSealHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+static const SvxMSDffVertPair mso_sptSeal16Vert[] = // adj value 0 -> 10800
+{
+ { 0x05 MSO_I, 0x06 MSO_I }, { 0x07 MSO_I, 0x08 MSO_I }, { 0x09 MSO_I, 0x0a MSO_I }, { 0x0b MSO_I, 0x0c MSO_I },
+ { 0x0d MSO_I, 0x0e MSO_I }, { 0x0f MSO_I, 0x10 MSO_I }, { 0x11 MSO_I, 0x12 MSO_I }, { 0x13 MSO_I, 0x14 MSO_I },
+ { 0x15 MSO_I, 0x16 MSO_I }, { 0x17 MSO_I, 0x18 MSO_I }, { 0x19 MSO_I, 0x1a MSO_I }, { 0x1b MSO_I, 0x1c MSO_I },
+ { 0x1d MSO_I, 0x1e MSO_I }, { 0x1f MSO_I, 0x20 MSO_I }, { 0x21 MSO_I, 0x22 MSO_I }, { 0x23 MSO_I, 0x24 MSO_I },
+ { 0x25 MSO_I, 0x26 MSO_I }, { 0x27 MSO_I, 0x28 MSO_I }, { 0x29 MSO_I, 0x2a MSO_I }, { 0x2b MSO_I, 0x2c MSO_I },
+ { 0x2d MSO_I, 0x2e MSO_I }, { 0x2f MSO_I, 0x30 MSO_I }, { 0x31 MSO_I, 0x32 MSO_I }, { 0x33 MSO_I, 0x34 MSO_I },
+ { 0x35 MSO_I, 0x36 MSO_I }, { 0x37 MSO_I, 0x38 MSO_I }, { 0x39 MSO_I, 0x3a MSO_I }, { 0x3b MSO_I, 0x3c MSO_I },
+ { 0x3d MSO_I, 0x3e MSO_I }, { 0x3f MSO_I, 0x40 MSO_I }, { 0x41 MSO_I, 0x42 MSO_I }, { 0x43 MSO_I, 0x44 MSO_I },
+ { 0x05 MSO_I, 0x06 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptSeal16Calc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 0x00
+ { 0x2081, { 0x400, 10800, 315 } }, // 0x01 ( textframe )
+ { 0x2082, { 0x400, 10800, 315 } }, // 0x02
+ { 0x2081, { 0x400, 10800, 135 } }, // 0x03
+ { 0x2082, { 0x400, 10800, 135 } }, // 0x04
+ { 0x0081, { 0, 10800, 0 } },
+ { 0x0082, { 0, 10800, 0 } },
+ { 0x2081, { 0x400, 10800, 11 } },
+ { 0x2082, { 0x400, 10800, 11 } },
+ { 0x0081, { 0, 10800, 22 } },
+ { 0x0082, { 0, 10800, 22 } },
+ { 0x2081, { 0x400, 10800, 33 } },
+ { 0x2082, { 0x400, 10800, 33 } },
+ { 0x0081, { 0, 10800, 45 } },
+ { 0x0082, { 0, 10800, 45 } },
+ { 0x2081, { 0x400, 10800, 56 } },
+ { 0x2082, { 0x400, 10800, 56 } },
+ { 0x0081, { 0, 10800, 67 } },
+ { 0x0082, { 0, 10800, 67 } },
+ { 0x2081, { 0x400, 10800, 78 } },
+ { 0x2082, { 0x400, 10800, 78 } },
+ { 0x0081, { 0, 10800, 90 } },
+ { 0x0082, { 0, 10800, 90 } },
+ { 0x2081, { 0x400, 10800, 101 } },
+ { 0x2082, { 0x400, 10800, 101 } },
+ { 0x0081, { 0, 10800, 112 } },
+ { 0x0082, { 0, 10800, 112 } },
+ { 0x2081, { 0x400, 10800, 123 } },
+ { 0x2082, { 0x400, 10800, 123 } },
+ { 0x0081, { 0, 10800, 135 } },
+ { 0x0082, { 0, 10800, 135 } },
+ { 0x2081, { 0x400, 10800, 146 } },
+ { 0x2082, { 0x400, 10800, 146 } },
+ { 0x0081, { 0, 10800, 157 } },
+ { 0x0082, { 0, 10800, 157 } },
+ { 0x2081, { 0x400, 10800, 168 } },
+ { 0x2082, { 0x400, 10800, 168 } },
+ { 0x0081, { 0, 10800, 180 } },
+ { 0x0082, { 0, 10800, 180 } },
+ { 0x2081, { 0x400, 10800, 191 } },
+ { 0x2082, { 0x400, 10800, 191 } },
+ { 0x0081, { 0, 10800, 202 } },
+ { 0x0082, { 0, 10800, 202 } },
+ { 0x2081, { 0x400, 10800, 213 } },
+ { 0x2082, { 0x400, 10800, 213 } },
+ { 0x0081, { 0, 10800, 225 } },
+ { 0x0082, { 0, 10800, 225 } },
+ { 0x2081, { 0x400, 10800, 236 } },
+ { 0x2082, { 0x400, 10800, 236 } },
+ { 0x0081, { 0, 10800, 247 } },
+ { 0x0082, { 0, 10800, 247 } },
+ { 0x2081, { 0x400, 10800, 258 } },
+ { 0x2082, { 0x400, 10800, 258 } },
+ { 0x0081, { 0, 10800, 270 } },
+ { 0x0082, { 0, 10800, 270 } },
+ { 0x2081, { 0x400, 10800, 281 } },
+ { 0x2082, { 0x400, 10800, 281 } },
+ { 0x0081, { 0, 10800, 292 } },
+ { 0x0082, { 0, 10800, 292 } },
+ { 0x2081, { 0x400, 10800, 303 } },
+ { 0x2082, { 0x400, 10800, 303 } },
+ { 0x0081, { 0, 10800, 315 } },
+ { 0x0082, { 0, 10800, 315 } },
+ { 0x2081, { 0x400, 10800, 326 } },
+ { 0x2082, { 0x400, 10800, 326 } },
+ { 0x0081, { 0, 10800, 337 } },
+ { 0x0082, { 0, 10800, 337 } },
+ { 0x2081, { 0x400, 10800, 348 } },
+ { 0x2082, { 0x400, 10800, 348 } }
+};
+static const mso_CustomShape msoSeal16 =
+{
+ (SvxMSDffVertPair*)mso_sptSeal16Vert, sizeof( mso_sptSeal16Vert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ (SvxMSDffCalculationData*)mso_sptSeal16Calc, sizeof( mso_sptSeal16Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault2500,
+ (SvxMSDffTextRectangles*)mso_sptSealTextRect, sizeof( mso_sptSealTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptSealHandle, sizeof( mso_sptSealHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+static const SvxMSDffVertPair mso_sptSeal24Vert[] =
+{
+ { 0x05 MSO_I, 0x06 MSO_I }, { 0x07 MSO_I, 0x08 MSO_I }, { 0x09 MSO_I, 0x0a MSO_I }, { 0x0b MSO_I, 0x0c MSO_I },
+ { 0x0d MSO_I, 0x0e MSO_I }, { 0x0f MSO_I, 0x10 MSO_I }, { 0x11 MSO_I, 0x12 MSO_I }, { 0x13 MSO_I, 0x14 MSO_I },
+ { 0x15 MSO_I, 0x16 MSO_I }, { 0x17 MSO_I, 0x18 MSO_I }, { 0x19 MSO_I, 0x1a MSO_I }, { 0x1b MSO_I, 0x1c MSO_I },
+ { 0x1d MSO_I, 0x1e MSO_I }, { 0x1f MSO_I, 0x20 MSO_I }, { 0x21 MSO_I, 0x22 MSO_I }, { 0x23 MSO_I, 0x24 MSO_I },
+ { 0x25 MSO_I, 0x26 MSO_I }, { 0x27 MSO_I, 0x28 MSO_I }, { 0x29 MSO_I, 0x2a MSO_I }, { 0x2b MSO_I, 0x2c MSO_I },
+ { 0x2d MSO_I, 0x2e MSO_I }, { 0x2f MSO_I, 0x30 MSO_I }, { 0x31 MSO_I, 0x32 MSO_I }, { 0x33 MSO_I, 0x34 MSO_I },
+ { 0x35 MSO_I, 0x36 MSO_I }, { 0x37 MSO_I, 0x38 MSO_I }, { 0x39 MSO_I, 0x3a MSO_I }, { 0x3b MSO_I, 0x3c MSO_I },
+ { 0x3d MSO_I, 0x3e MSO_I }, { 0x3f MSO_I, 0x40 MSO_I }, { 0x41 MSO_I, 0x42 MSO_I }, { 0x43 MSO_I, 0x44 MSO_I },
+ { 0x45 MSO_I, 0x46 MSO_I }, { 0x47 MSO_I, 0x48 MSO_I }, { 0x49 MSO_I, 0x4a MSO_I }, { 0x4b MSO_I, 0x4c MSO_I },
+ { 0x4d MSO_I, 0x4e MSO_I }, { 0x4f MSO_I, 0x50 MSO_I }, { 0x51 MSO_I, 0x52 MSO_I }, { 0x53 MSO_I, 0x54 MSO_I },
+ { 0x55 MSO_I, 0x56 MSO_I }, { 0x57 MSO_I, 0x58 MSO_I }, { 0x59 MSO_I, 0x5a MSO_I }, { 0x5b MSO_I, 0x5c MSO_I },
+ { 0x5d MSO_I, 0x5e MSO_I }, { 0x5f MSO_I, 0x60 MSO_I }, { 0x61 MSO_I, 0x62 MSO_I }, { 0x63 MSO_I, 0x64 MSO_I },
+ { 0x05 MSO_I, 0x06 MSO_I }
+};
+static const mso_CustomShape msoSeal24 =
+{
+ (SvxMSDffVertPair*)mso_sptSeal24Vert, sizeof( mso_sptSeal24Vert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ (SvxMSDffCalculationData*)mso_sptSeal24Calc, sizeof( mso_sptSeal24Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault2500,
+ (SvxMSDffTextRectangles*)mso_sptSealTextRect, sizeof( mso_sptSealTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptSealHandle, sizeof( mso_sptSealHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+static const SvxMSDffCalculationData mso_sptSeal32Calc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 0x00
+ { 0x2081, { 0x400, 10800, 315 } }, // 0x01 ( textframe )
+ { 0x2082, { 0x400, 10800, 315 } }, // 0x02
+ { 0x2081, { 0x400, 10800, 135 } }, // 0x03
+ { 0x2082, { 0x400, 10800, 135 } }, // 0x04
+ { 0x0081, { 0, 10800, 0 } },
+ { 0x0082, { 0, 10800, 0 } },
+ { 0x2081, { 0x400, 10800, 5 } },
+ { 0x2082, { 0x400, 10800, 5 } },
+ { 0x0081, { 0, 10800, 11 } },
+ { 0x0082, { 0, 10800, 11 } },
+ { 0x2081, { 0x400, 10800, 16 } },
+ { 0x2082, { 0x400, 10800, 16 } },
+ { 0x0081, { 0, 10800, 22 } },
+ { 0x0082, { 0, 10800, 22 } },
+ { 0x2081, { 0x400, 10800, 28 } },
+ { 0x2082, { 0x400, 10800, 28 } },
+ { 0x0081, { 0, 10800, 33 } },
+ { 0x0082, { 0, 10800, 33 } },
+ { 0x2081, { 0x400, 10800, 39 } },
+ { 0x2082, { 0x400, 10800, 39 } },
+ { 0x0081, { 0, 10800, 45 } },
+ { 0x0082, { 0, 10800, 45 } },
+ { 0x2081, { 0x400, 10800, 50 } },
+ { 0x2082, { 0x400, 10800, 50 } },
+ { 0x0081, { 0, 10800, 56 } },
+ { 0x0082, { 0, 10800, 56 } },
+ { 0x2081, { 0x400, 10800, 61 } },
+ { 0x2082, { 0x400, 10800, 61 } },
+ { 0x0081, { 0, 10800, 67 } },
+ { 0x0082, { 0, 10800, 67 } },
+ { 0x2081, { 0x400, 10800, 73 } },
+ { 0x2082, { 0x400, 10800, 73 } },
+ { 0x0081, { 0, 10800, 78 } },
+ { 0x0082, { 0, 10800, 78 } },
+ { 0x2081, { 0x400, 10800, 84 } },
+ { 0x2082, { 0x400, 10800, 84 } },
+ { 0x0081, { 0, 10800, 90 } },
+ { 0x0082, { 0, 10800, 90 } },
+ { 0x2081, { 0x400, 10800, 95 } },
+ { 0x2082, { 0x400, 10800, 95 } },
+ { 0x0081, { 0, 10800, 101 } },
+ { 0x0082, { 0, 10800, 101 } },
+ { 0x2081, { 0x400, 10800, 106 } },
+ { 0x2082, { 0x400, 10800, 106 } },
+ { 0x0081, { 0, 10800, 112 } },
+ { 0x0082, { 0, 10800, 112 } },
+ { 0x2081, { 0x400, 10800, 118 } },
+ { 0x2082, { 0x400, 10800, 118 } },
+ { 0x0081, { 0, 10800, 123 } },
+ { 0x0082, { 0, 10800, 123 } },
+ { 0x2081, { 0x400, 10800, 129 } },
+ { 0x2082, { 0x400, 10800, 129 } },
+ { 0x0081, { 0, 10800, 135 } },
+ { 0x0082, { 0, 10800, 135 } },
+ { 0x2081, { 0x400, 10800, 140 } },
+ { 0x2082, { 0x400, 10800, 140 } },
+ { 0x0081, { 0, 10800, 146 } },
+ { 0x0082, { 0, 10800, 146 } },
+ { 0x2081, { 0x400, 10800, 151 } },
+ { 0x2082, { 0x400, 10800, 151 } },
+ { 0x0081, { 0, 10800, 157 } },
+ { 0x0082, { 0, 10800, 157 } },
+ { 0x2081, { 0x400, 10800, 163 } },
+ { 0x2082, { 0x400, 10800, 163 } },
+ { 0x0081, { 0, 10800, 168 } },
+ { 0x0082, { 0, 10800, 168 } },
+ { 0x2081, { 0x400, 10800, 174 } },
+ { 0x2082, { 0x400, 10800, 174 } },
+ { 0x0081, { 0, 10800, 180 } },
+ { 0x0082, { 0, 10800, 180 } },
+ { 0x2081, { 0x400, 10800, 185 } },
+ { 0x2082, { 0x400, 10800, 185 } },
+ { 0x0081, { 0, 10800, 191 } },
+ { 0x0082, { 0, 10800, 191 } },
+ { 0x2081, { 0x400, 10800, 196 } },
+ { 0x2082, { 0x400, 10800, 196 } },
+ { 0x0081, { 0, 10800, 202 } },
+ { 0x0082, { 0, 10800, 202 } },
+ { 0x2081, { 0x400, 10800, 208 } },
+ { 0x2082, { 0x400, 10800, 208 } },
+ { 0x0081, { 0, 10800, 213 } },
+ { 0x0082, { 0, 10800, 213 } },
+ { 0x2081, { 0x400, 10800, 219 } },
+ { 0x2082, { 0x400, 10800, 219 } },
+ { 0x0081, { 0, 10800, 225 } },
+ { 0x0082, { 0, 10800, 225 } },
+ { 0x2081, { 0x400, 10800, 230 } },
+ { 0x2082, { 0x400, 10800, 230 } },
+ { 0x0081, { 0, 10800, 236 } },
+ { 0x0082, { 0, 10800, 236 } },
+ { 0x2081, { 0x400, 10800, 241 } },
+ { 0x2082, { 0x400, 10800, 241 } },
+ { 0x0081, { 0, 10800, 247 } },
+ { 0x0082, { 0, 10800, 247 } },
+ { 0x2081, { 0x400, 10800, 253 } },
+ { 0x2082, { 0x400, 10800, 253 } },
+ { 0x0081, { 0, 10800, 258 } },
+ { 0x0082, { 0, 10800, 258 } },
+ { 0x2081, { 0x400, 10800, 264 } },
+ { 0x2082, { 0x400, 10800, 264 } },
+ { 0x0081, { 0, 10800, 270 } },
+ { 0x0082, { 0, 10800, 270 } },
+ { 0x2081, { 0x400, 10800, 275 } },
+ { 0x2082, { 0x400, 10800, 275 } },
+ { 0x0081, { 0, 10800, 281 } },
+ { 0x0082, { 0, 10800, 281 } },
+ { 0x2081, { 0x400, 10800, 286 } },
+ { 0x2082, { 0x400, 10800, 286 } },
+ { 0x0081, { 0, 10800, 292 } },
+ { 0x0082, { 0, 10800, 292 } },
+ { 0x2081, { 0x400, 10800, 298 } },
+ { 0x2082, { 0x400, 10800, 298 } },
+ { 0x0081, { 0, 10800, 303 } },
+ { 0x0082, { 0, 10800, 303 } },
+ { 0x2081, { 0x400, 10800, 309 } },
+ { 0x2082, { 0x400, 10800, 309 } },
+ { 0x0081, { 0, 10800, 315 } },
+ { 0x0082, { 0, 10800, 315 } },
+ { 0x2081, { 0x400, 10800, 320 } },
+ { 0x2082, { 0x400, 10800, 320 } },
+ { 0x0081, { 0, 10800, 326 } },
+ { 0x0082, { 0, 10800, 326 } },
+ { 0x2081, { 0x400, 10800, 331 } },
+ { 0x2082, { 0x400, 10800, 331 } },
+ { 0x0081, { 0, 10800, 337 } },
+ { 0x0082, { 0, 10800, 337 } },
+ { 0x2081, { 0x400, 10800, 343 } },
+ { 0x2082, { 0x400, 10800, 343 } },
+ { 0x0081, { 0, 10800, 348 } },
+ { 0x0082, { 0, 10800, 348 } },
+ { 0x2081, { 0x400, 10800, 354 } },
+ { 0x2082, { 0x400, 10800, 354 } }
+};
+static const SvxMSDffVertPair mso_sptSeal32Vert[] =
+{
+ { 0x05 MSO_I, 0x06 MSO_I }, { 0x07 MSO_I, 0x08 MSO_I }, { 0x09 MSO_I, 0x0a MSO_I }, { 0x0b MSO_I, 0x0c MSO_I },
+ { 0x0d MSO_I, 0x0e MSO_I }, { 0x0f MSO_I, 0x10 MSO_I }, { 0x11 MSO_I, 0x12 MSO_I }, { 0x13 MSO_I, 0x14 MSO_I },
+ { 0x15 MSO_I, 0x16 MSO_I }, { 0x17 MSO_I, 0x18 MSO_I }, { 0x19 MSO_I, 0x1a MSO_I }, { 0x1b MSO_I, 0x1c MSO_I },
+ { 0x1d MSO_I, 0x1e MSO_I }, { 0x1f MSO_I, 0x20 MSO_I }, { 0x21 MSO_I, 0x22 MSO_I }, { 0x23 MSO_I, 0x24 MSO_I },
+ { 0x25 MSO_I, 0x26 MSO_I }, { 0x27 MSO_I, 0x28 MSO_I }, { 0x29 MSO_I, 0x2a MSO_I }, { 0x2b MSO_I, 0x2c MSO_I },
+ { 0x2d MSO_I, 0x2e MSO_I }, { 0x2f MSO_I, 0x30 MSO_I }, { 0x31 MSO_I, 0x32 MSO_I }, { 0x33 MSO_I, 0x34 MSO_I },
+ { 0x35 MSO_I, 0x36 MSO_I }, { 0x37 MSO_I, 0x38 MSO_I }, { 0x39 MSO_I, 0x3a MSO_I }, { 0x3b MSO_I, 0x3c MSO_I },
+ { 0x3d MSO_I, 0x3e MSO_I }, { 0x3f MSO_I, 0x40 MSO_I }, { 0x41 MSO_I, 0x42 MSO_I }, { 0x43 MSO_I, 0x44 MSO_I },
+ { 0x45 MSO_I, 0x46 MSO_I }, { 0x47 MSO_I, 0x48 MSO_I }, { 0x49 MSO_I, 0x4a MSO_I }, { 0x4b MSO_I, 0x4c MSO_I },
+ { 0x4d MSO_I, 0x4e MSO_I }, { 0x4f MSO_I, 0x50 MSO_I }, { 0x51 MSO_I, 0x52 MSO_I }, { 0x53 MSO_I, 0x54 MSO_I },
+ { 0x55 MSO_I, 0x56 MSO_I }, { 0x57 MSO_I, 0x58 MSO_I }, { 0x59 MSO_I, 0x5a MSO_I }, { 0x5b MSO_I, 0x5c MSO_I },
+ { 0x5d MSO_I, 0x5e MSO_I }, { 0x5f MSO_I, 0x60 MSO_I }, { 0x61 MSO_I, 0x62 MSO_I }, { 0x63 MSO_I, 0x64 MSO_I },
+ { 0x65 MSO_I, 0x66 MSO_I }, { 0x67 MSO_I, 0x68 MSO_I }, { 0x69 MSO_I, 0x6a MSO_I }, { 0x6b MSO_I, 0x6c MSO_I },
+ { 0x6d MSO_I, 0x6e MSO_I }, { 0x6f MSO_I, 0x70 MSO_I }, { 0x71 MSO_I, 0x72 MSO_I }, { 0x73 MSO_I, 0x74 MSO_I },
+ { 0x75 MSO_I, 0x76 MSO_I }, { 0x77 MSO_I, 0x78 MSO_I }, { 0x79 MSO_I, 0x7a MSO_I }, { 0x7b MSO_I, 0x7c MSO_I },
+ { 0x7d MSO_I, 0x7e MSO_I }, { 0x7f MSO_I, 0x80 MSO_I }, { 0x81 MSO_I, 0x82 MSO_I }, { 0x83 MSO_I, 0x84 MSO_I },
+ { 0x05 MSO_I, 0x06 MSO_I }
+};
+static const mso_CustomShape msoSeal32 =
+{
+ (SvxMSDffVertPair*)mso_sptSeal32Vert, sizeof( mso_sptSeal32Vert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ (SvxMSDffCalculationData*)mso_sptSeal32Calc, sizeof( mso_sptSeal32Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault2500,
+ (SvxMSDffTextRectangles*)mso_sptSealTextRect, sizeof( mso_sptSealTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptSealHandle, sizeof( mso_sptSealHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptRibbon2Vert[] = // adjustment1 : x 2700 - 8100 def 5400
+{ // adjustment2 : y 14400 - 21600 def 18900
+ { 12 MSO_I, 1 MSO_I }, { 12 MSO_I, 13 MSO_I }, // pp
+ { 12 MSO_I, 14 MSO_I }, { 15 MSO_I, 21600 }, { 16 MSO_I, 21600 }, // ccp
+ { 0, 21600 }, { 2750, 7 MSO_I }, { 0, 2 MSO_I }, { 0 MSO_I, 2 MSO_I }, // pppp
+ { 0 MSO_I, 4 MSO_I }, // p
+ { 0 MSO_I, 5 MSO_I }, { 10 MSO_I, 0 }, { 11 MSO_I, 0 }, // ccp
+ { 17 MSO_I, 0 }, // p
+ { 18 MSO_I, 0 }, { 19 MSO_I, 5 MSO_I }, { 19 MSO_I, 4 MSO_I }, // ccp
+ { 19 MSO_I, 2 MSO_I }, { 21600, 2 MSO_I }, { 18850, 7 MSO_I }, { 21600, 21600 }, // pppp
+ { 20 MSO_I, 21600 }, // p
+ { 21 MSO_I, 21600 }, { 22 MSO_I, 14 MSO_I }, { 22 MSO_I, 13 MSO_I }, // ccp
+ { 22 MSO_I, 1 MSO_I }, { 12 MSO_I, 1 MSO_I }, { 12 MSO_I, 13 MSO_I }, // ppp
+ { 12 MSO_I, 23 MSO_I }, { 15 MSO_I, 24 MSO_I }, { 16 MSO_I, 24 MSO_I }, // ccp
+ { 11 MSO_I, 24 MSO_I }, // p
+ { 10 MSO_I, 24 MSO_I }, { 0 MSO_I, 26 MSO_I }, { 0 MSO_I, 25 MSO_I }, // ccp
+ { 0 MSO_I, 27 MSO_I }, { 10 MSO_I, 1 MSO_I }, { 11 MSO_I, 1 MSO_I }, // ccp
+
+ { 22 MSO_I, 1 MSO_I }, { 22 MSO_I, 13 MSO_I }, // pp
+ { 22 MSO_I, 23 MSO_I }, { 21 MSO_I, 24 MSO_I }, { 20 MSO_I, 24 MSO_I }, // ccp
+ { 17 MSO_I, 24 MSO_I }, // p
+ { 18 MSO_I, 24 MSO_I }, { 19 MSO_I, 26 MSO_I }, { 19 MSO_I, 25 MSO_I }, // ccp
+ { 19 MSO_I, 27 MSO_I }, { 18 MSO_I, 1 MSO_I }, { 17 MSO_I, 1 MSO_I }, // ccp
+
+ { 0 MSO_I, 25 MSO_I }, { 0 MSO_I, 2 MSO_I }, // pp
+
+ { 19 MSO_I, 25 MSO_I }, { 19 MSO_I, 2 MSO_I } // pp
+};
+static const sal_uInt16 mso_sptRibbon2Segm[] =
+{
+ 0x4000, 0x0001, 0x2001, 0x0005, 0x2001, 0x0001, 0x2001, 0x0005, 0x2001, 0x0001, 0x6001, 0x8000,
+ 0x4000, 0x0001, 0x2001, 0x0001, 0x2002, 0x6001, 0x8000,
+ 0x4000, 0x0001, 0x2001, 0x0001, 0x2002, 0x6001, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptRibbon2Calc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 00
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } }, // 01
+ { 0x8000, { 21600, 0, 0x401 } }, // 02
+ { 0x2001, { 0x402, 1, 2 } }, // 03
+ { 0x2001, { 0x403, 1, 2 } }, // 04
+ { 0x2001, { 0x404, 1, 2 } }, // 05
+ { 0x2001, { 0x401, 1, 2 } }, // 06
+ { 0x8000, { 21600, 0, 0x406 } }, // 07
+ { 0x0000, { 420, 0, 0 } }, // 08
+ { 0x2001, { 0x408, 2, 1 } }, // 09
+ { 0x6000, { 0x400, 0x408, 0 } }, // 10
+ { 0x6000, { 0x400, 0x409, 0 } }, // 11
+ { 0x2000, { 0x400, 2700, 0 } }, // 12
+ { 0x8000, { 21600, 0, 0x404 } }, // 13
+ { 0x8000, { 21600, 0, 0x405 } }, // 14
+ { 0xa000, { 0x40c, 0, 0x408 } }, // 15
+ { 0xa000, { 0x40c, 0, 0x409 } }, // 16
+
+ { 0x8000, { 21600, 0, 0x40b } }, // 17
+ { 0x8000, { 21600, 0, 0x40a } }, // 18
+ { 0x8000, { 21600, 0, 0x400 } }, // 19
+ { 0x8000, { 21600, 0, 0x410 } }, // 20
+ { 0x8000, { 21600, 0, 0x40f } }, // 21
+ { 0x8000, { 21600, 0, 0x40c } }, // 22
+
+ { 0xa000, { 0x40d, 0, 0x405 } }, // 23
+ { 0x6000, { 0x401, 0x403, 0 } }, // 24
+ { 0x6000, { 0x401, 0x404, 0 } }, // 25
+ { 0x6000, { 0x419, 0x405, 0 } }, // 26
+ { 0xa000, { 0x419, 0, 0x405 } } // 27
+};
+static const sal_Int32 mso_sptRibbon2Default[] =
+{
+ 2, 5400, 18900
+};
+static const SvxMSDffTextRectangles mso_sptRibbon2TextRect[] =
+{
+ { { 0 MSO_I, 0 }, { 19 MSO_I, 1 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptRibbon2Handle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0, 10800, 10800, 2700, 8100, 0x80000000, 0x7fffffff },
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 14400, 21600 }
+};
+static const mso_CustomShape msoRibbon2 =
+{
+ (SvxMSDffVertPair*)mso_sptRibbon2Vert, sizeof( mso_sptRibbon2Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptRibbon2Segm, sizeof( mso_sptRibbon2Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptRibbon2Calc, sizeof( mso_sptRibbon2Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptRibbon2Default,
+ (SvxMSDffTextRectangles*)mso_sptRibbon2TextRect, sizeof( mso_sptRibbon2TextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptRibbon2Handle, sizeof( mso_sptRibbon2Handle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptRibbonVert[] =
+{
+ { 0, 0 }, { 3 MSO_I, 0 },
+ { 4 MSO_I, 11 MSO_I }, { 4 MSO_I, 10 MSO_I }, { 5 MSO_I, 10 MSO_I }, { 5 MSO_I, 11 MSO_I },
+ { 6 MSO_I, 0 }, { 21600, 0 }, { 18 MSO_I, 14 MSO_I }, { 21600, 15 MSO_I }, { 9 MSO_I, 15 MSO_I }, { 9 MSO_I, 16 MSO_I }, { 8 MSO_I, 21600 }, { 1 MSO_I, 21600 },
+ { 0 MSO_I, 16 MSO_I }, { 0 MSO_I, 15 MSO_I }, { 0, 15 MSO_I }, { 2700, 14 MSO_I },
+
+ { 4 MSO_I, 11 MSO_I },
+ { 3 MSO_I, 12 MSO_I }, { 1 MSO_I, 12 MSO_I },
+ { 0 MSO_I, 13 MSO_I }, { 1 MSO_I, 10 MSO_I }, { 4 MSO_I, 10 MSO_I },
+ { 5 MSO_I, 11 MSO_I },
+ { 6 MSO_I, 12 MSO_I }, { 8 MSO_I, 12 MSO_I },
+ { 9 MSO_I, 13 MSO_I }, { 8 MSO_I, 10 MSO_I }, { 5 MSO_I, 10 MSO_I },
+ { 0 MSO_I, 13 MSO_I },
+ { 0 MSO_I, 15 MSO_I },
+ { 9 MSO_I, 13 MSO_I },
+ { 9 MSO_I, 15 MSO_I }
+};
+static const sal_uInt16 mso_sptRibbonSegm[] =
+{
+ 0x4000, 0x0001, 0xa701, 0x0003, 0xa801, 0x0005, 0xa801, 0x0001, 0xa701, 0x0003, 0x6000, 0x8000,
+ 0x4000, 0xaa00, 0xa801, 0x0001, 0xa702, 0x0001, 0x8000,
+ 0x4000, 0xaa00, 0xa801, 0x0001, 0xa702, 0x0001, 0x8000,
+ 0x4000, 0xaa00, 0x0001, 0x8000,
+ 0x4000, 0xaa00, 0x0001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptRibbonCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 00
+ { 0x2000, { 0x400, 675, 0 } }, // 01
+ { 0x2000, { 0x401, 675, 0 } }, // 02
+ { 0x2000, { 0x402, 675, 0 } }, // 03
+ { 0x2000, { 0x403, 675, 0 } }, // 04
+ { 0x8000, { 21600, 0, 0x404 } }, // 05
+ { 0x8000, { 21600, 0, 0x403 } }, // 06
+ { 0x8000, { 21600, 0, 0x402 } }, // 07
+ { 0x8000, { 21600, 0, 0x401 } }, // 08
+ { 0x8000, { 21600, 0, 0x400 } }, // 09
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } }, // 10
+ { 0x2001, { 0x40a, 1, 4 } }, // 11
+ { 0x2001, { 0x40b, 2, 1 } }, // 12
+ { 0x2001, { 0x40b, 3, 1 } }, // 13
+ { 0x8000, { 10800, 0, 0x40c } }, // 14
+ { 0x8000, { 21600, 0, 0x40a } }, // 15
+ { 0x8000, { 21600, 0, 0x40b } }, // 16
+ { 0x0001, { 21600, 1, 2 } }, // 17
+ { 0x0000, { 21600, 0, 2700 } }, // 18
+ { 0x2000, { 0x411, 0, 2700 } } // 19
+};
+static const sal_Int32 mso_sptRibbonDefault[] =
+{
+ 2, 5400, 2700
+};
+static const SvxMSDffTextRectangles mso_sptRibbonTextRect[] =
+{
+ { { 0 MSO_I, 10 MSO_I }, { 9 MSO_I, 21600 } }
+};
+static const SvxMSDffVertPair mso_sptRibbonGluePoints[] =
+{
+ { 17 MSO_I, 10 MSO_I }, { 2700, 14 MSO_I }, { 17 MSO_I, 21600 }, { 18 MSO_I, 14 MSO_I }
+};
+static const SvxMSDffHandle mso_sptRibbonHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0, 10800, 10800, 2700, 8100, 0x80000000, 0x7fffffff },
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 0, 7200 }
+};
+static const mso_CustomShape msoRibbon =
+{
+ (SvxMSDffVertPair*)mso_sptRibbonVert, sizeof( mso_sptRibbonVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptRibbonSegm, sizeof( mso_sptRibbonSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptRibbonCalc, sizeof( mso_sptRibbonCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptRibbonDefault,
+ (SvxMSDffTextRectangles*)mso_sptRibbonTextRect, sizeof( mso_sptRibbonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptRibbonGluePoints, sizeof( mso_sptRibbonGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptRibbonHandle, sizeof( mso_sptRibbonHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptVerticalScrollVert[] = // adjustment1 : 0 - 5400
+{
+ { 1 MSO_I, 21600 }, { 0, 11 MSO_I }, { 1 MSO_I, 12 MSO_I }, { 0 MSO_I, 12 MSO_I },
+ { 0 MSO_I, 1 MSO_I }, { 4 MSO_I, 0 }, { 2 MSO_I, 0 }, { 21600, 1 MSO_I },
+ { 2 MSO_I, 0 MSO_I }, { 3 MSO_I, 0 MSO_I }, { 3 MSO_I, 11 MSO_I }, { 5 MSO_I, 21600 },
+
+ { 6 MSO_I, 1 MSO_I }, { 4 MSO_I, 0 MSO_I }, { 8 MSO_I, 9 MSO_I }, { 4 MSO_I, 1 MSO_I },
+
+ { 0 MSO_I, 11 MSO_I }, { 1 MSO_I, 21600 }, { 0, 11 MSO_I }, { 1 MSO_I, 12 MSO_I },
+ { 9 MSO_I, 10 MSO_I }, { 1 MSO_I, 11 MSO_I },
+
+ { 4 MSO_I, 0 }, { 6 MSO_I, 1 MSO_I },
+
+ { 0 MSO_I, 12 MSO_I }, { 0 MSO_I, 11 MSO_I },
+
+ { 4 MSO_I, 0 MSO_I },
+ { 2 MSO_I, 0 MSO_I }
+};
+static const sal_uInt16 mso_sptVerticalScrollSegm[] =
+{
+ 0x4000, 0xa702, 0x0002, 0xa801, 0x0001, 0xa702, 0x0002, 0xa801, 0x6001, 0x8000,
+ 0x4000, 0xa801, 0xa702, 0x6000, 0x8000,
+ 0x4000, 0xa803, 0xa702, 0x6001, 0x8000,
+ 0x4000, 0xa701, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptScrollCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2001, { 0x400, 1, 2 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x401 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x400 } },
+ { 0x6000, { 0x400, 0x401, 0 } },
+ { 0xa000, { DFF_Prop_geoRight, 0, 0x404 } },
+ { 0x2001, { 0x400, 2, 1 } },
+ { 0x2001, { 0x401, 1, 2 } },
+ { 0x6000, { 0x400, 0x407, 0 } },
+ { 0x6000, { 0x401, 0x407, 0 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x409 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x401 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x400 } },
+ { 0xa000, { DFF_Prop_geoBottom, 0, 0x404 } }
+};
+static const SvxMSDffTextRectangles mso_sptScrollTextRect[] =
+{
+ { { 0 MSO_I, 0 MSO_I }, { 3 MSO_I, 12 MSO_I } }
+};
+static const SvxMSDffHandle mso_sptVerticalScrollHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 5400 }
+};
+static const mso_CustomShape msoVerticalScroll =
+{
+ (SvxMSDffVertPair*)mso_sptVerticalScrollVert, sizeof( mso_sptVerticalScrollVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptVerticalScrollSegm, sizeof( mso_sptVerticalScrollSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptScrollCalc, sizeof( mso_sptScrollCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault2700,
+ (SvxMSDffTextRectangles*)mso_sptScrollTextRect, sizeof( mso_sptScrollTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 11000, 10800,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptVerticalScrollHandle, sizeof( mso_sptVerticalScrollHandle ) / sizeof( SvxMSDffHandle )
+};
+static const SvxMSDffVertPair mso_sptHorizontalScrollVert[] = // adjustment1 : 0 - 5400
+{
+ { 0, 4 MSO_I }, { 1 MSO_I, 0 MSO_I }, { 3 MSO_I, 0 MSO_I }, { 3 MSO_I, 1 MSO_I },
+ { 2 MSO_I, 0 }, { 21600, 1 MSO_I }, { 21600, 13 MSO_I }, { 2 MSO_I, 12 MSO_I },
+ { 0 MSO_I, 12 MSO_I }, { 0 MSO_I, 11 MSO_I }, { 1 MSO_I, 21600 }, { 0, 11 MSO_I },
+
+ { 1 MSO_I, 4 MSO_I }, { 9 MSO_I, 8 MSO_I }, { 0 MSO_I, 4 MSO_I }, { 1 MSO_I, 6 MSO_I },
+
+ { 2 MSO_I, 1 MSO_I }, { 3 MSO_I, 9 MSO_I }, { 3 MSO_I, 1 MSO_I }, { 2 MSO_I, 0 },
+ { 21600, 1 MSO_I }, { 2 MSO_I, 0 MSO_I },
+
+ { 1 MSO_I, 6 MSO_I },
+ { 0, 4 MSO_I },
+
+ { 2 MSO_I, 0 MSO_I },
+ { 3 MSO_I, 0 MSO_I },
+
+ { 0 MSO_I, 4 MSO_I },
+ { 0 MSO_I, 11 MSO_I }
+};
+static const sal_uInt16 mso_sptHorizontalScrollSegm[] =
+{
+ 0x4000, 0xa801, 0x0002, 0xa802, 0x0001, 0xa801, 0x0002, 0xa802, 0x6001, 0x8000,
+ 0x4000, 0xa803, 0x6000, 0x8000,
+ 0x4000, 0xa803, 0xa702, 0x6000, 0x8000,
+ 0x4000, 0xa701, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffHandle mso_sptHorizontalScrollHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0, 10800, 10800, 0, 5400, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoHorizontalScroll =
+{
+ (SvxMSDffVertPair*)mso_sptHorizontalScrollVert, sizeof( mso_sptHorizontalScrollVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptHorizontalScrollSegm, sizeof( mso_sptHorizontalScrollSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptScrollCalc, sizeof( mso_sptScrollCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault2700,
+ (SvxMSDffTextRectangles*)mso_sptScrollTextRect, sizeof( mso_sptScrollTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 10800, 11000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptHorizontalScrollHandle, sizeof( mso_sptHorizontalScrollHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartProcessVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 }, { 0, 0 }
+};
+static const mso_CustomShape msoFlowChartProcess =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartProcessVert, sizeof( mso_sptFlowChartProcessVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartAlternateProcessVert[] =
+{
+ { 0, 2 MSO_I }, { 0 MSO_I, 0 }, { 1 MSO_I, 0 }, { 21600, 2 MSO_I },
+ { 21600, 3 MSO_I }, { 1 MSO_I, 21600 }, { 0 MSO_I, 21600 }, { 0, 3 MSO_I }
+};
+static const sal_uInt16 mso_sptFlowChartAlternateProcessSegm[] =
+{
+ 0x4000, 0xa801, 0x0001, 0xa701, 0x0001, 0xa801, 0x0001, 0xa701, 0x6000, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptFlowChartAlternateProcessCalc[] =
+{
+ { 0x2000, { DFF_Prop_geoLeft, 2540, 0 } },
+ { 0x2000, { DFF_Prop_geoRight, 0, 2540 } },
+ { 0x2000, { DFF_Prop_geoTop, 2540, 0 } },
+ { 0x2000, { DFF_Prop_geoBottom, 0, 2540 } },
+ { 0x2000, { DFF_Prop_geoLeft, 800, 0 } },
+ { 0x2000, { DFF_Prop_geoRight, 0, 800 } },
+ { 0x2000, { DFF_Prop_geoTop, 800, 0 } },
+ { 0x2000, { DFF_Prop_geoBottom,0, 800 } }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartAlternateProcessTextRect[] =
+{
+ { { 4 MSO_I, 6 MSO_I }, { 5 MSO_I, 7 MSO_I } }
+};
+static const mso_CustomShape msoFlowChartAlternateProcess =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartAlternateProcessVert, sizeof( mso_sptFlowChartAlternateProcessVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartAlternateProcessSegm, sizeof( mso_sptFlowChartAlternateProcessSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptFlowChartAlternateProcessCalc, sizeof( mso_sptFlowChartAlternateProcessCalc ) / sizeof( SvxMSDffCalculationData ),
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartAlternateProcessTextRect, sizeof( mso_sptFlowChartAlternateProcessTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartDecisionVert[] =
+{
+ { 0, 10800 }, { 10800, 0 }, { 21600, 10800 }, { 10800, 21600 }, { 0, 10800 }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartDecisionTextRect[] =
+{
+ { { 5400, 5400 }, { 16200, 16200 } }
+};
+static const mso_CustomShape msoFlowChartDecision =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartDecisionVert, sizeof( mso_sptFlowChartDecisionVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartDecisionTextRect, sizeof( mso_sptFlowChartDecisionTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartInputOutputVert[] =
+{
+ { 4230, 0 }, { 21600, 0 }, { 17370, 21600 }, { 0, 21600 }, { 4230, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartInputOutputTextRect[] =
+{
+ { { 4230, 0 }, { 17370, 21600 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartInputOutputGluePoints[] =
+{
+ { 12960, 0 }, { 10800, 0 }, { 2160, 10800 }, { 8600, 21600 }, { 10800, 21600 }, { 19400, 10800 }
+};
+static const mso_CustomShape msoFlowChartInputOutput =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartInputOutputVert, sizeof( mso_sptFlowChartInputOutputVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartInputOutputTextRect, sizeof( mso_sptFlowChartInputOutputTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartInputOutputGluePoints, sizeof( mso_sptFlowChartInputOutputGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartPredefinedProcessVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+
+ { 2540, 0 }, { 2540, 21600 },
+
+ { 21600 - 2540, 0 }, { 21600 - 2540, 21600 }
+};
+static const sal_uInt16 mso_sptFlowChartPredefinedProcessSegm[] =
+{
+ 0x4000, 0x0003, 0x6000, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartPredefinedProcessTextRect[] =
+{
+ { { 2540, 0 }, { 21600 - 2540, 21600 } }
+};
+static const mso_CustomShape msoFlowChartPredefinedProcess =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartPredefinedProcessVert, sizeof( mso_sptFlowChartPredefinedProcessVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartPredefinedProcessSegm, sizeof( mso_sptFlowChartPredefinedProcessSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartPredefinedProcessTextRect, sizeof( mso_sptFlowChartPredefinedProcessTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartInternalStorageVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+
+ { 4230, 0 }, { 4230, 21600 },
+
+ { 0, 4230 }, { 21600, 4230 }
+};
+static const sal_uInt16 mso_sptFlowChartInternalStorageSegm[] =
+{
+ 0x4000, 0x0003, 0x6000, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartInternalStorageTextRect[] =
+{
+ { { 4230, 4230 }, { 21600, 21600 } }
+};
+static const mso_CustomShape msoFlowChartInternalStorage =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartInternalStorageVert, sizeof( mso_sptFlowChartInternalStorageVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartInternalStorageSegm, sizeof( mso_sptFlowChartInternalStorageSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartInternalStorageTextRect, sizeof( mso_sptFlowChartInternalStorageTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartDocumentVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 17360 },
+ { 13050, 17220 }, { 13340, 20770 }, { 5620, 21600 }, // ccp
+ { 2860, 21100 }, { 1850, 20700 }, { 0, 20120 } // ccp
+};
+static const sal_uInt16 mso_sptFlowChartDocumentSegm[] =
+{
+ 0x4000, 0x0002, 0x2002, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartDocumentTextRect[] =
+{
+ { { 0, 0 }, { 21600, 17360 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartDocumentGluePoints[] =
+{
+ { 10800, 0 }, { 0, 10800 }, { 10800, 20320 }, { 21600, 10800 }
+};
+static const mso_CustomShape msoFlowChartDocument =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartDocumentVert, sizeof( mso_sptFlowChartDocumentVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartDocumentSegm, sizeof( mso_sptFlowChartDocumentSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartDocumentTextRect, sizeof( mso_sptFlowChartDocumentTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartDocumentGluePoints, sizeof( mso_sptFlowChartDocumentGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartMultidocumentVert[] =
+{
+ { 0, 3600 }, { 1500, 3600 }, { 1500, 1800 }, { 3000, 1800 },
+ { 3000, 0 }, { 21600, 0 }, { 21600, 14409 }, { 21600 - 1500, 14409 },
+ { 21600 - 1500, 14409 + 1800 }, { 21600 - 3000, 14409 + 1800 }, { 21600 - 3000, 14409 + 3600 },
+ { 11610, 14293 + 3600 }, { 11472, 17239 + 3600 }, { 4833, 17928 + 3600 }, // ccp
+ { 2450, 17513 + 3600 }, { 1591, 17181 + 3600 }, { 0, 16700 + 3600 }, // ccp
+
+ { 1500, 3600 }, { 21600 - 3000, 3600 }, { 21600 - 3000, 14409 + 1800 },
+
+ { 3000, 1800 }, { 21600 - 1500, 1800 }, { 21600 - 1500, 14409 }
+};
+static const sal_uInt16 mso_sptFlowChartMultidocumentSegm[] =
+{
+ 0x4000, 0x000a, 0x2002, 0x6000, 0x8000,
+ 0x4000, 0xaa00, 0x0002, 0x8000, // NO FILL
+ 0x4000, 0xaa00, 0x0002, 0x8000 // NO FILL
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartMultidocumentTextRect[] =
+{
+ { { 0, 3600 }, { 21600 - 3000, 14409 + 3600 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartMultidocumentGluePoints[] =
+{
+ { 10800, 0 }, { 0, 10800 }, { 10800, 19890 }, { 21600, 10800 }
+};
+static const mso_CustomShape msoFlowChartMultidocument =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartMultidocumentVert, sizeof( mso_sptFlowChartMultidocumentVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartMultidocumentSegm, sizeof( mso_sptFlowChartMultidocumentSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartMultidocumentTextRect, sizeof( mso_sptFlowChartMultidocumentTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartMultidocumentGluePoints, sizeof( mso_sptFlowChartMultidocumentGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartTerminatorVert[] =
+{
+ { 3470, 21600 }, { 0, 10800 }, { 3470, 0 }, { 18130, 0 },
+ { 21600, 10800 }, { 18130, 21600 }
+};
+static const sal_uInt16 mso_sptFlowChartTerminatorSegm[] =
+{
+ 0x4000, 0xa702, 0x0001, 0xa702, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartTerminatorTextRect[] =
+{
+ { { 1060, 3180 }, { 20540, 18420 } }
+};
+static const mso_CustomShape msoFlowChartTerminator =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartTerminatorVert, sizeof( mso_sptFlowChartTerminatorVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartTerminatorSegm, sizeof( mso_sptFlowChartTerminatorSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartTerminatorTextRect, sizeof( mso_sptFlowChartTerminatorTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartPreparationVert[] =
+{
+ { 4350, 0 }, { 17250, 0 }, { 21600, 10800 }, { 17250, 21600 },
+ { 4350, 21600 }, { 0, 10800 }, { 4350, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartPreparationTextRect[] =
+{
+ { { 4350, 0 }, { 17250, 21600 } }
+};
+static const mso_CustomShape msoFlowChartPreparation =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartPreparationVert, sizeof( mso_sptFlowChartPreparationVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartPreparationTextRect, sizeof( mso_sptFlowChartPreparationTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartManualInputVert[] =
+{
+ { 0, 4300 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 }, { 0, 4300 }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartManualInputTextRect[] =
+{
+ { { 0, 4300 }, { 21600, 21600 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartManualInputGluePoints[] =
+{
+ { 10800, 2150 }, { 0, 10800 }, { 10800, 19890 }, { 21600, 10800 }
+};
+static const mso_CustomShape msoFlowChartManualInput =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartManualInputVert, sizeof( mso_sptFlowChartManualInputVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartManualInputTextRect, sizeof( mso_sptFlowChartManualInputTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartManualInputGluePoints, sizeof( mso_sptFlowChartManualInputGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartManualOperationVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 17250, 21600 }, { 4350, 21600 }, { 0, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartManualOperationTextRect[] =
+{
+ { { 4350, 0 }, { 17250, 21600 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartManualOperationGluePoints[] =
+{
+ { 10800, 0 }, { 2160, 10800 }, { 10800, 21600 }, { 19440, 10800 }
+};
+static const mso_CustomShape msoFlowChartManualOperation =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartManualOperationVert, sizeof( mso_sptFlowChartManualOperationVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartManualOperationTextRect, sizeof( mso_sptFlowChartManualOperationTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartManualOperationGluePoints, sizeof( mso_sptFlowChartManualOperationGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartConnectorVert[] =
+{
+ { 10800, 10800 }, { 10800, 10800 }, { 0, 360 }
+};
+static const sal_uInt16 mso_sptFlowChartConnectorSegm[] =
+{
+ 0xa203, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartConnectorTextRect[] =
+{
+ { { 3180, 3180 }, { 18420, 18420 } }
+};
+static const mso_CustomShape msoFlowChartConnector =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartConnectorVert, sizeof( mso_sptFlowChartConnectorVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartConnectorSegm, sizeof( mso_sptFlowChartConnectorSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartConnectorTextRect, sizeof( mso_sptFlowChartConnectorTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptEllipseGluePoints, sizeof( mso_sptEllipseGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartOffpageConnectorVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 17150 }, { 10800, 21600 },
+ { 0, 17150 }, { 0, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartOffpageConnectorTextRect[] =
+{
+ { { 0, 0 }, { 21600, 17150 } }
+};
+static const mso_CustomShape msoFlowChartOffpageConnector =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartOffpageConnectorVert, sizeof( mso_sptFlowChartOffpageConnectorVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartOffpageConnectorTextRect, sizeof( mso_sptFlowChartOffpageConnectorTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartPunchedCardVert[] =
+{
+ { 4300, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 },
+ { 0, 4300 }, { 4300, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartPunchedCardTextRect[] =
+{
+ { { 0, 4300 }, { 21600, 21600 } }
+};
+static const mso_CustomShape msoFlowChartPunchedCard =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartPunchedCardVert, sizeof( mso_sptFlowChartPunchedCardVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartPunchedCardTextRect, sizeof( mso_sptFlowChartPunchedCardTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartPunchedTapeVert[] =
+{
+ { 0, 2230 }, // p
+ { 820, 3990 }, { 3410, 3980 }, { 5370, 4360 }, // ccp
+ { 7430, 4030 }, { 10110, 3890 }, { 10690, 2270 }, // ccp
+ { 11440, 300 }, { 14200, 160 }, { 16150, 0 }, // ccp
+ { 18670, 170 }, { 20690, 390 }, { 21600, 2230 }, // ccp
+ { 21600, 19420 }, // p
+ { 20640, 17510 }, { 18320, 17490 }, { 16140, 17240 }, // ccp
+ { 14710, 17370 }, { 11310, 17510 }, { 10770, 19430 }, // ccp
+ { 10150, 21150 }, { 7380, 21290 }, { 5290, 21600 }, // ccp
+ { 3220, 21250 }, { 610, 21130 }, { 0, 19420 } // ccp
+};
+static const sal_uInt16 mso_sptFlowChartPunchedTapeSegm[] =
+{
+ 0x4000, 0x2004, 0x0001, 0x2004, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartPunchedTapeTextRect[] =
+{
+ { { 0, 4360 }, { 21600, 17240 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartPunchedTapeGluePoints[] =
+{
+ { 10800, 2020 }, { 0, 10800 }, { 10800, 19320 }, { 21600, 10800 }
+};
+static const mso_CustomShape msoFlowChartPunchedTape =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartPunchedTapeVert, sizeof( mso_sptFlowChartPunchedTapeVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartPunchedTapeSegm, sizeof( mso_sptFlowChartPunchedTapeSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartPunchedTapeTextRect, sizeof( mso_sptFlowChartPunchedTapeTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartPunchedTapeGluePoints, sizeof( mso_sptFlowChartPunchedTapeGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartSummingJunctionVert[] =
+{
+ { 10800, 10800 }, { 10800, 10800 }, { 0, 360 },
+
+ { 3100, 3100 },
+ { 18500, 18500 },
+
+ { 3100, 18500 },
+ { 18500, 3100 }
+};
+static const sal_uInt16 mso_sptFlowChartSummingJunctionSegm[] =
+{
+ 0xa203, 0x6000, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartSummingJunctionTextRect[] =
+{
+ { { 3100, 3100 }, { 18500, 18500 } }
+};
+static const mso_CustomShape msoFlowChartSummingJunction =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartSummingJunctionVert, sizeof( mso_sptFlowChartSummingJunctionVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartSummingJunctionSegm, sizeof( mso_sptFlowChartSummingJunctionSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartSummingJunctionTextRect, sizeof( mso_sptFlowChartSummingJunctionTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptEllipseGluePoints, sizeof( mso_sptEllipseGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartOrVert[] =
+{
+ { 10800, 10800 }, { 10800, 10800 }, { 0, 360 },
+
+ { 0, 10800 }, { 21600, 10800 },
+
+ { 10800, 0 }, { 10800, 21600 }
+};
+static const sal_uInt16 mso_sptFlowChartOrSegm[] =
+{
+ 0xa203, 0x6000, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartOrTextRect[] =
+{
+ { { 3100, 3100 }, { 18500, 18500 } }
+};
+static const mso_CustomShape msoFlowChartOr =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartOrVert, sizeof( mso_sptFlowChartOrVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartOrSegm, sizeof( mso_sptFlowChartOrSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartOrTextRect, sizeof( mso_sptFlowChartOrTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptEllipseGluePoints, sizeof( mso_sptEllipseGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartCollateVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 0, 21600 }, { 21600, 0 }, { 0, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartCollateTextRect[] =
+{
+ { { 5400, 5400 }, { 16200, 16200 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartCollateGluePoints[] =
+{
+ { 10800, 0 }, { 10800, 10800 }, { 10800, 21600 }
+};
+static const mso_CustomShape msoFlowChartCollate =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartCollateVert, sizeof( mso_sptFlowChartCollateVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartCollateTextRect, sizeof( mso_sptFlowChartCollateTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartCollateGluePoints, sizeof( mso_sptFlowChartCollateGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartSortVert[] =
+{
+ { 0, 10800 }, { 10800, 0 }, { 21600, 10800 }, { 10800, 21600 },
+
+ { 0, 10800 }, { 21600, 10800 }
+};
+static const sal_uInt16 mso_sptFlowChartSortSegm[] =
+{
+ 0x4000, 0x0003, 0x6000, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartSortTextRect[] =
+{
+ { { 5400, 5400 }, { 16200, 16200 } }
+};
+static const mso_CustomShape msoFlowChartSort =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartSortVert, sizeof( mso_sptFlowChartSortVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartSortSegm, sizeof( mso_sptFlowChartSortSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartSortTextRect, sizeof( mso_sptFlowChartSortTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartExtractVert[] =
+{
+ { 10800, 0 }, { 21600, 21600 }, { 0, 21600 }, { 10800, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartExtractTextRect[] =
+{
+ { { 5400, 10800 }, { 16200, 21600 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartExtractGluePoints[] =
+{
+ { 10800, 0 }, { 5400, 10800 }, { 10800, 21600 }, { 16200, 10800 }
+};
+static const mso_CustomShape msoFlowChartExtract =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartExtractVert, sizeof( mso_sptFlowChartExtractVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartExtractTextRect, sizeof( mso_sptFlowChartExtractTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartExtractGluePoints, sizeof( mso_sptFlowChartExtractGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartMergeVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 10800, 21600 }, { 0, 0 }
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartMergeTextRect[] =
+{
+ { { 5400, 0 }, { 16200, 10800 } }
+};
+static const mso_CustomShape msoFlowChartMerge =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartMergeVert, sizeof( mso_sptFlowChartMergeVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartMergeTextRect, sizeof( mso_sptFlowChartMergeTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartExtractGluePoints, sizeof( mso_sptFlowChartExtractGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartOnlineStorageVert[] =
+{
+ { 3600, 21600 }, { 0, 10800 }, { 3600, 0 }, { 21600, 0 },
+ { 18000, 10800 }, { 21600, 21600 }
+};
+static const sal_uInt16 mso_sptFlowChartOnlineStorageSegm[] =
+{
+ 0x4000, 0xa702, 0x0001, 0xa702, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartOnlineStorageTextRect[] =
+{
+ { { 3600, 0 }, { 18000, 21600 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartOnlineStorageGluePoints[] =
+{
+ { 10800, 0 }, { 0, 10800 }, { 10800, 21600 }, { 18000, 10800 }
+};
+static const mso_CustomShape msoFlowChartOnlineStorage =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartOnlineStorageVert, sizeof( mso_sptFlowChartOnlineStorageVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartOnlineStorageSegm, sizeof( mso_sptFlowChartOnlineStorageSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartOnlineStorageTextRect, sizeof( mso_sptFlowChartOnlineStorageTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartOnlineStorageGluePoints, sizeof( mso_sptFlowChartOnlineStorageGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartDelayVert[] =
+{
+ { 10800, 0 }, { 21600, 10800 }, { 10800, 21600 }, { 0, 21600 },
+ { 0, 0 }
+};
+static const sal_uInt16 mso_sptFlowChartDelaySegm[] =
+{
+ 0x4000, 0xa702, 0x0002, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartDelayTextRect[] =
+{
+ { { 0, 3100 }, { 18500, 18500 } }
+};
+static const mso_CustomShape msoFlowChartDelay =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartDelayVert, sizeof( mso_sptFlowChartDelayVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartDelaySegm, sizeof( mso_sptFlowChartDelaySegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartDelayTextRect, sizeof( mso_sptFlowChartDelayTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartMagneticTapeVert[] =
+{
+ { 20980, 18150 }, { 20980, 21600 }, { 10670, 21600 },
+ { 4770, 21540 }, { 0, 16720 }, { 0, 10800 }, // ccp
+ { 0, 4840 }, { 4840, 0 }, { 10800, 0 }, // ccp
+ { 16740, 0 }, { 21600, 4840 }, { 21600, 10800 }, // ccp
+ { 21600, 13520 }, { 20550, 16160 }, { 18670, 18170 } // ccp
+};
+static const sal_uInt16 mso_sptFlowChartMagneticTapeSegm[] =
+{
+ 0x4000, 0x0002, 0x2004, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartMagneticTapeTextRect[] =
+{
+ { { 3100, 3100 }, { 18500, 18500 } }
+};
+static const mso_CustomShape msoFlowChartMagneticTape =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartMagneticTapeVert, sizeof( mso_sptFlowChartMagneticTapeVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartMagneticTapeSegm, sizeof( mso_sptFlowChartMagneticTapeSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartMagneticTapeTextRect, sizeof( mso_sptFlowChartMagneticTapeTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartMagneticDiskVert[] =
+{
+ { 0, 3400 }, { 10800, 0 }, { 21600, 3400 }, { 21600, 18200 },
+ { 10800, 21600 }, { 0, 18200 },
+
+ { 0, 3400 }, { 10800, 6800 }, { 21600, 3400 }
+};
+static const sal_uInt16 mso_sptFlowChartMagneticDiskSegm[] =
+{
+ 0x4000, 0xa802, 0x0001, 0xa802, 0x6000, 0x8000,
+ 0x4000, 0xa802, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartMagneticDiskTextRect[] =
+{
+ { { 0, 6800 }, { 21600, 18200 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartMagneticDiskGluePoints[] =
+{
+ { 10800, 6800 }, { 10800, 0 }, { 0, 10800 }, { 10800, 21600 }, { 21600, 10800 }
+};
+static const mso_CustomShape msoFlowChartMagneticDisk =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartMagneticDiskVert, sizeof( mso_sptFlowChartMagneticDiskVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartMagneticDiskSegm, sizeof( mso_sptFlowChartMagneticDiskSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartMagneticDiskTextRect, sizeof( mso_sptFlowChartMagneticDiskTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartMagneticDiskGluePoints, sizeof( mso_sptFlowChartMagneticDiskGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartMagneticDrumVert[] =
+{
+ { 18200, 0 }, { 21600, 10800 }, { 18200, 21600 }, { 3400, 21600 },
+ { 0, 10800 }, { 3400, 0 },
+
+ { 18200, 0 }, { 14800, 10800 }, { 18200, 21600 }
+};
+static const sal_uInt16 mso_sptFlowChartMagneticDrumSegm[] =
+{
+ 0x4000, 0xa702, 0x0001, 0xa702, 0x6000, 0x8000,
+ 0x4000, 0xa702, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartMagneticDrumTextRect[] =
+{
+ { { 3400, 0 }, { 14800, 21600 } }
+};
+static const SvxMSDffVertPair mso_sptFlowChartMagneticDrumGluePoints[] =
+{
+ { 10800, 0 }, { 0, 10800 }, { 10800, 21600 }, { 14800, 10800 }, { 21600, 10800 }
+};
+static const mso_CustomShape msoFlowChartMagneticDrum =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartMagneticDrumVert, sizeof( mso_sptFlowChartMagneticDrumVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartMagneticDrumSegm, sizeof( mso_sptFlowChartMagneticDrumSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartMagneticDrumTextRect, sizeof( mso_sptFlowChartMagneticDrumTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptFlowChartMagneticDrumGluePoints, sizeof( mso_sptFlowChartMagneticDrumGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptFlowChartDisplayVert[] =
+{
+ { 3600, 0 }, { 17800, 0 }, { 21600, 10800 }, { 17800, 21600 },
+ { 3600, 21600 }, { 0, 10800 }
+};
+static const sal_uInt16 mso_sptFlowChartDisplaySegm[] =
+{
+ 0x4000, 0x0001, 0xa702, 0x0002, 0x6000, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFlowChartDisplayTextRect[] =
+{
+ { { 3600, 0 }, { 17800, 21600 } }
+};
+static const mso_CustomShape msoFlowChartDisplay =
+{
+ (SvxMSDffVertPair*)mso_sptFlowChartDisplayVert, sizeof( mso_sptFlowChartDisplayVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFlowChartDisplaySegm, sizeof( mso_sptFlowChartDisplaySegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFlowChartDisplayTextRect, sizeof( mso_sptFlowChartDisplayTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptStandardGluePoints, sizeof( mso_sptStandardGluePoints ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0 // handles
+};
+
+static const SvxMSDffVertPair mso_sptWedgeRectCalloutVert[] =
+{
+ { 0, 0 },
+ { 0, 3590 }, { 2 MSO_I, 3 MSO_I }, { 0, 8970 },
+ { 0, 12630 },{ 4 MSO_I, 5 MSO_I }, { 0, 18010 },
+ { 0, 21600 },
+ { 3590, 21600 }, { 6 MSO_I, 7 MSO_I }, { 8970, 21600 },
+ { 12630, 21600 }, { 8 MSO_I, 9 MSO_I }, { 18010, 21600 },
+ { 21600, 21600 },
+ { 21600, 18010 }, { 10 MSO_I, 11 MSO_I }, { 21600, 12630 },
+ { 21600, 8970 }, { 12 MSO_I, 13 MSO_I }, { 21600, 3590 },
+ { 21600, 0 },
+ { 18010, 0 }, { 14 MSO_I, 15 MSO_I }, { 12630, 0 },
+ { 8970, 0 }, { 16 MSO_I, 17 MSO_I }, { 3590, 0 },
+ { 0, 0 }
+};
+static const SvxMSDffCalculationData mso_sptWedgeRectCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 10800 } }, //0x400
+ { 0x2000, { DFF_Prop_adjust2Value, 0,10800 } },
+ { 0x6006, { 0x412, DFF_Prop_adjustValue, 0 } }, //0x402
+ { 0x6006, { 0x412, DFF_Prop_adjust2Value, 6280 } },
+ { 0x6006, { 0x417, DFF_Prop_adjustValue, 0 } }, //0x404
+ { 0x6006, { 0x417, DFF_Prop_adjust2Value, 15320 } },
+ { 0x6006, { 0x41a, DFF_Prop_adjustValue, 6280 } }, //0x406
+ { 0x6006, { 0x41a, DFF_Prop_adjust2Value, 21600 } },
+ { 0x6006, { 0x41d, DFF_Prop_adjustValue, 15320 } }, //0x408
+ { 0x6006, { 0x41d, DFF_Prop_adjust2Value, 21600 } },
+ { 0x6006, { 0x420, DFF_Prop_adjustValue, 21600 } }, //0x40a
+ { 0x6006, { 0x420, DFF_Prop_adjust2Value, 15320 } },
+ { 0x6006, { 0x422, DFF_Prop_adjustValue, 21600 } }, //0x40c
+ { 0x6006, { 0x422, DFF_Prop_adjust2Value, 6280 } },
+ { 0x6006, { 0x424, DFF_Prop_adjustValue, 15320 } }, //0x40e
+ { 0x6006, { 0x424, DFF_Prop_adjust2Value, 0 } },
+ { 0x6006, { 0x426, DFF_Prop_adjustValue, 6280 } }, //0x410
+ { 0x6006, { 0x426, DFF_Prop_adjust2Value, 0 } },
+ { 0xa006, { DFF_Prop_adjustValue, -1, 0x413 } }, //0x412
+ { 0xa006, { 0x401, -1, 0x416 } },
+ { 0x2003, { 0x400, 0, 0 } }, //0x414
+ { 0x2003, { 0x401, 0, 0 } },
+ { 0xa000, { 0x414, 0, 0x415 } }, //0x416
+ { 0xa006, { DFF_Prop_adjustValue, -1, 0x418 } },
+ { 0x6006, { 0x401, 0x416, -1 } }, //0x418
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 21600 } },
+ { 0x6006, { 0x419, 0x41b, -1 } }, //0x41a
+ { 0xa006, { 0x400, -1, 0x41c } },
+ { 0xa000, { 0x415, 0, 0x414 } }, //0x41c
+ { 0x6006, { 0x419, 0x41e, -1 } },
+ { 0x6006, { 0x400, 0x41c, -1 } }, //0x41e
+ { 0x2000, { DFF_Prop_adjustValue, 0, 21600 } },
+ { 0x6006, { 0x41f, 0x421, -1 } }, //0x420
+ { 0x6006, { 0x401, 0x416, -1 } },
+ { 0x6006, { 0x41f, 0x423, -1 } }, //0x422
+ { 0xa006, { 0x401, -1, 0x416 } },
+ { 0xa006, { DFF_Prop_adjust2Value, -1, 0x425 } }, //0x424
+ { 0x6006, { 0x400, 0x41c, -1 } },
+ { 0xa006, { DFF_Prop_adjust2Value, -1, 0x427 } }, //0x426
+ { 0xa006, { 0x400, -1, 0x41c } },
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, //0x428
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } }
+};
+static const sal_Int32 mso_sptWedgeRectCalloutDefault[] =
+{
+ 2, 1400, 25920
+};
+static const SvxMSDffTextRectangles mso_sptWedgeRectCalloutTextRect[] =
+{
+ { { 0, 0 }, { 21600, 21600 } }
+};
+static const SvxMSDffVertPair mso_sptWedgeRectCalloutGluePoints[] =
+{
+ { 10800, 0 }, { 0, 10800 }, { 10800, 21600 }, { 21600, 10800 }, { 40 MSO_I, 41 MSO_I }
+};
+static const SvxMSDffHandle mso_sptCalloutHandle[] =
+{
+ {
+ 0,
+ 0x100, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff
+ }
+};
+static const mso_CustomShape msoWedgeRectCallout =
+{
+ (SvxMSDffVertPair*)mso_sptWedgeRectCalloutVert, sizeof( mso_sptWedgeRectCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ NULL, 0,
+ (SvxMSDffCalculationData*)mso_sptWedgeRectCalloutCalc, sizeof( mso_sptWedgeRectCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptWedgeRectCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptWedgeRectCalloutTextRect, sizeof( mso_sptWedgeRectCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptWedgeRectCalloutGluePoints, sizeof( mso_sptWedgeRectCalloutGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptCalloutHandle, sizeof( mso_sptCalloutHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+static const SvxMSDffVertPair mso_sptWedgeRRectCalloutVert[] =
+{
+ { 3590, 0 },
+ { 0, 3590 },
+ { 2 MSO_I, 3 MSO_I }, { 0, 8970 },
+ { 0, 12630 },{ 4 MSO_I, 5 MSO_I }, { 0, 18010 },
+ { 3590, 21600 },
+ { 6 MSO_I, 7 MSO_I }, { 8970, 21600 },
+ { 12630, 21600 }, { 8 MSO_I, 9 MSO_I }, { 18010, 21600 },
+ { 21600, 18010 },
+ { 10 MSO_I, 11 MSO_I }, { 21600, 12630 },
+ { 21600, 8970 }, { 12 MSO_I, 13 MSO_I }, { 21600, 3590 },
+ { 18010, 0 },
+ { 14 MSO_I, 15 MSO_I }, { 12630, 0 },
+ { 8970, 0 }, { 16 MSO_I, 17 MSO_I }
+};
+static const sal_uInt16 mso_sptWedgeRRectCalloutSegm[] =
+{
+ 0x4000, 0xa701, 0x0005, 0xa801, 0x0005, 0xa701, 0x0005, 0xa801, 0x0004, 0x6001, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptWedgeRRectCalloutTextRect[] =
+{
+ { { 800, 800 }, { 20800, 20800 } }
+};
+static const mso_CustomShape msoWedgeRRectCallout =
+{
+ (SvxMSDffVertPair*)mso_sptWedgeRRectCalloutVert, sizeof( mso_sptWedgeRRectCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptWedgeRRectCalloutSegm, sizeof( mso_sptWedgeRRectCalloutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptWedgeRectCalloutCalc, sizeof( mso_sptWedgeRectCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptWedgeRectCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptWedgeRRectCalloutTextRect, sizeof( mso_sptWedgeRRectCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle, sizeof( mso_sptCalloutHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+static const SvxMSDffVertPair mso_sptBalloonVert[] =
+{
+ { 3590, 0 },
+ { 0, 3590 },
+ { 0, 14460 },
+ { 3590, 18050 },
+ { 40 MSO_I, 21600 }, { 5420, 18050 },
+ { 18010, 18050 },
+ { 21600, 14460 },
+ { 21600, 3590 },
+ { 18010, 0 }
+};
+static const sal_uInt16 mso_sptBalloonSegm[] =
+{
+ 0x4000, 0xa701, 0x0001, 0xa801, 0x0003, 0xa701, 0x0001, 0xa801, 0x6001, 0x8000
+};
+static const SvxMSDffHandle mso_sptBalloonHandle[] =
+{
+ {
+ MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 1, 10800, 10800, 0, 8990, 0x80000000, 0x7fffffff
+ }
+};
+static const SvxMSDffTextRectangles mso_sptBalloonTextRect[] =
+{
+ { { 800, 800 }, { 20800, 17250 } }
+};
+static const mso_CustomShape msoBalloon =
+{
+ (SvxMSDffVertPair*)mso_sptBalloonVert, sizeof( mso_sptBalloonVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBalloonSegm, sizeof( mso_sptBalloonSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptWedgeRectCalloutCalc, sizeof( mso_sptWedgeRectCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptWedgeRectCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptBalloonTextRect, sizeof( mso_sptBalloonTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptBalloonHandle, sizeof( mso_sptBalloonHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+static const SvxMSDffVertPair mso_sptWedgeEllipseCalloutVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 0x16 MSO_I, 0x17 MSO_I }, { 0x12 MSO_I, 0x13 MSO_I }, { 0xe MSO_I, 0xf MSO_I }
+};
+static const sal_uInt16 mso_sptWedgeEllipseCalloutSegm[] =
+{
+ 0xa504, 0x0001, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptWedgeEllipseCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 10800 } }, // 00 rad x
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 10800 } }, // 01 rad y
+ { 0x6001, { 0x400, 0x400, 1 } }, // 02 rad x^2
+ { 0x6001, { 0x401, 0x401, 1 } }, // 03 rad y^2
+ { 0x6000, { 0x402, 0x403, 0 } }, // 04
+ { 0x200d, { 0x404, 0, 0 } }, // 05
+ { 0x2000, { 0x405, 0, 10800 } }, // 06 > 0 ? spur needs to be drawn : 10800
+ { 0x6008, { 0x400, 0x401, 0 } }, // 07 atan2 -> angle
+ { 0x2000, { 0x407, 0, 10 } }, // 08
+ { 0x2000, { 0x407, 10, 0 } }, // 09
+ { 0x400a, { 10800, 0x407, 0 } }, // 0a
+ { 0x4009, { 10800, 0x407, 0 } }, // 0b
+ { 0x2000, { 0x40a, 10800, 0 } }, // 0c
+ { 0x2000, { 0x40b, 10800, 0 } }, // 0d
+ { 0xe006, { 0x406, DFF_Prop_adjustValue, 0x40c } }, // 0e
+ { 0xe006, { 0x406, DFF_Prop_adjust2Value, 0x40d } },// 0f
+ { 0x400a, { 10800, 0x408, 0 } }, // 10
+ { 0x4009, { 10800, 0x408, 0 } }, // 11
+ { 0x2000, { 0x410, 10800, 0 } }, // 12
+ { 0x2000, { 0x411, 10800, 0 } }, // 13
+ { 0x400a, { 10800, 0x409, 0 } }, // 14
+ { 0x4009, { 10800, 0x409, 0 } }, // 15
+ { 0x2000, { 0x414, 10800, 0 } }, // 16
+ { 0x2000, { 0x415, 10800, 0 } } // 17
+};
+static const sal_Int32 mso_sptWedgeEllipseCalloutDefault[] =
+{
+ 2, 1350, 25920
+};
+static const SvxMSDffVertPair mso_sptWedgeEllipseCalloutGluePoints[] =
+{
+ { 10800, 0 }, { 3160, 3160 }, { 0, 10800 }, { 3160, 18440 }, { 10800, 21600 }, { 18440, 18440 }, { 21600, 10800 }, { 18440, 3160 }, { 0xe MSO_I, 0xf MSO_I }
+};
+static const SvxMSDffTextRectangles mso_sptWedgeEllipseCalloutTextRect[] =
+{
+ { { 3200, 3200 }, { 18400, 18400 } }
+};
+static const mso_CustomShape msoWedgeEllipseCallout =
+{
+ (SvxMSDffVertPair*)mso_sptWedgeEllipseCalloutVert, sizeof( mso_sptWedgeEllipseCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptWedgeEllipseCalloutSegm, sizeof( mso_sptWedgeEllipseCalloutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptWedgeEllipseCalloutCalc, sizeof( mso_sptWedgeEllipseCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptWedgeEllipseCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptWedgeEllipseCalloutTextRect, sizeof( mso_sptWedgeEllipseCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptWedgeEllipseCalloutGluePoints, sizeof( mso_sptWedgeEllipseCalloutGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptCalloutHandle, sizeof( mso_sptCalloutHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptCloudCalloutVert[] =
+{
+ { 1930,7160 }, // p
+ { 1530,4490 }, { 3400,1970 }, { 5270,1970 }, // ccp
+ { 5860,1950 }, { 6470,2210 }, { 6970,2600 }, // ccp
+ { 7450,1390 }, { 8340,650 }, { 9340,650 }, // ccp
+ { 10004,690 }, { 10710,1050 }, { 11210,1700 }, // ccp
+ { 11570,630 }, { 12330,0 }, { 13150,0 }, // ccp
+ { 13840,0 }, { 14470,460 }, { 14870,1160 }, // ccp
+ { 15330,440 }, { 16020,0 }, { 16740,0 }, // ccp
+ { 17910,0 }, { 18900,1130 }, { 19110,2710 }, // ccp
+ { 20240,3150 }, { 21060,4580 }, { 21060,6220 }, // ccp
+ { 21060,6720 }, { 21000,7200 }, { 20830,7660 }, // ccp
+ { 21310,8460 }, { 21600,9450 }, { 21600,10460 }, // ccp
+ { 21600,12750 }, { 20310,14680 }, { 18650,15010 }, // ccp
+ { 18650,17200 }, { 17370,18920 }, { 15770,18920 }, // ccp
+ { 15220,18920 }, { 14700,18710 }, { 14240,18310 }, // ccp
+ { 13820,20240 }, { 12490,21600 }, { 11000,21600 }, // ccp
+ { 9890,21600 }, { 8840,20790 }, { 8210,19510 }, // ccp
+ { 7620,20000 }, { 7930,20290 }, { 6240,20290 }, // ccp
+ { 4850,20290 }, { 3570,19280 }, { 2900,17640 }, // ccp
+ { 1300,17600 }, { 480,16300 }, { 480,14660 }, // ccp
+ { 480,13900 }, { 690,13210 }, { 1070,12640 }, // ccp
+ { 380,12160 }, { 0,11210 }, { 0,10120 }, // ccp
+ { 0,8590 }, { 840,7330 }, { 1930,7160 }, // ccp
+
+ { 1930, 7160 }, { 1950, 7410 }, { 2040, 7690 }, { 2090, 7920 }, // pccp
+ { 6970, 2600 }, { 7200, 2790 }, { 7480, 3050 }, { 7670, 3310 }, // pccp
+ { 11210, 1700 }, { 11130, 1910 }, { 11080, 2160 }, { 11030, 2400 }, // pccp
+ { 14870, 1160 }, { 14720, 1400 }, { 14640, 1720 }, { 14540, 2010 }, // pccp
+ { 19110, 2710 }, { 19130, 2890 }, { 19230, 3290 }, { 19190, 3380 }, // pccp
+ { 20830, 7660 }, { 20660, 8170 }, { 20430, 8620 }, { 20110, 8990 }, // pccp
+ { 18660, 15010 }, { 18740, 14200 }, { 18280, 12200 }, { 17000, 11450 }, // pccp
+ { 14240, 18310 }, { 14320, 17980 }, { 14350, 17680 }, { 14370, 17360 }, // pccp
+ { 8220, 19510 }, { 8060, 19250 }, { 7960, 18950 }, { 7860, 18640 }, // pccp
+ { 2900, 17640 }, { 3090, 17600 }, { 3280, 17540 }, { 3460, 17450 }, // pccp
+ { 1070, 12640 }, { 1400, 12900 }, { 1780, 13130 }, { 2330, 13040 }, // pccp
+
+ { 0x11 MSO_I, 0x12 MSO_I }, { 1800, 1800 }, { 0, 360 }, // circ1
+ { 0x13 MSO_I, 0x14 MSO_I }, { 1200, 1200 }, { 0, 360 }, // circ2
+ { 0xd MSO_I, 0xe MSO_I }, { 700, 700 }, { 0, 360 } // circ3
+};
+static const sal_uInt16 mso_sptCloudCalloutSegm[] =
+{
+ 0x4000, 0x2016, 0x6001, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0x4000, 0x2001, 0xaa00, 0x8000,
+ 0xa203, 0x6001, 0x8000,
+ 0xa203, 0x6001, 0x8000,
+ 0xa203, 0x6001, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCloudCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 10800 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 10800 } },
+ { 0x6008, { 0x400, 0x401, 0 } },
+ { 0x400a, { 10800, 0x402, 0 } }, // 3
+ { 0x4009, { 10800, 0x402, 0 } }, // 4
+ { 0x2000, { 0x403, 10800, 0 } }, // 5
+ { 0x2000, { 0x404, 10800, 0 } }, // 6
+ { 0xa000, { DFF_Prop_adjustValue, 0, 0x405 } }, // 7
+ { 0xa000, { DFF_Prop_adjust2Value,0, 0x406 } }, // 8
+ { 0x2001, { 0x407, 1, 3 } }, // 9
+ { 0x2001, { 0x408, 1, 3 } }, // 0xa
+ { 0x2001, { 0x407, 2, 3 } }, // 0xb
+ { 0x2001, { 0x408, 2, 3 } }, // 0xc
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 0xd
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } }, // 0xe
+ { 0x2001, { 0x403, 1, 10800 / 900 } }, // 0xf taking half x distance of the radius from the first bobble
+ { 0x2001, { 0x404, 1, 10800 / 900 } }, // 0x10
+ { 0xe000, { 0x409, 0x405, 0x40f } }, // 0x11
+ { 0xe000, { 0x40a, 0x406, 0x410 } }, // 0x12
+ { 0x6000, { 0x40b, 0x405, 0 } }, // 0x13
+ { 0x6000, { 0x40c, 0x406, 0 } } // 0x14
+};
+static const sal_Int32 mso_sptCloudCalloutDefault[] =
+{
+ 2, 1350, 25920
+};
+static const SvxMSDffTextRectangles mso_sptCloudCalloutTextRect[] =
+{
+ { { 3000, 3320 }, { 17110, 17330 } }
+};
+static const mso_CustomShape msoCloudCallout =
+{
+ (SvxMSDffVertPair*)mso_sptCloudCalloutVert, sizeof( mso_sptCloudCalloutVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCloudCalloutSegm, sizeof( mso_sptCloudCalloutSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCloudCalloutCalc, sizeof( mso_sptCloudCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCloudCalloutDefault,
+ (SvxMSDffTextRectangles*)mso_sptCloudCalloutTextRect, sizeof( mso_sptCloudCalloutTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle, sizeof( mso_sptCalloutHandle ) / sizeof( SvxMSDffHandle ) // handles
+};
+
+static const SvxMSDffVertPair mso_sptWaveVert[] = // adjustment1 : 0 - 4460
+{ // adjustment2 : 8640 - 12960
+ { 7 MSO_I, 0 MSO_I }, { 15 MSO_I, 9 MSO_I }, { 16 MSO_I, 10 MSO_I }, { 12 MSO_I, 0 MSO_I },
+ { 24 MSO_I, 1 MSO_I }, { 25 MSO_I, 26 MSO_I }, { 27 MSO_I, 28 MSO_I }, { 29 MSO_I, 1 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptWaveCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, //400 (vert.adj)
+ { 0x8000, { 21600, 0, 0x400 } }, //401
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },//402 (horz.adj)
+ { 0x2000, { 0x402, 0, 10800 } }, //403 -2160 -> 2160 (horz.adj)
+ { 0x2001, { 0x403, 2, 1 } }, //404 -4320 -> 4320 (horz.adj)
+ { 0x2003, { 0x404, 0, 0 } }, //405 abs( 0x404 ) (horz.adj)
+ { 0x8000, { 4320, 0, 0x405 } }, //406
+ { 0xa006, { 0x403, 0, 0x405 } }, //407
+ { 0x4001, { 15800, 0x400, 4460 } }, //408 0 -> 15800 (vert.adj)
+ { 0xa000, { 0x400, 0, 0x408 } }, //409
+ { 0x6000, { 0x400, 0x408, 0 } }, //40a
+ { 0x8000, { 21600, 0, 0x404 } }, //40b
+ { 0x6006, { 0x403, 0x40b, 21600 } }, //40c
+ { 0xa000, { 0x40c, 0, 0x407 } }, //40d width between p0 and p1
+ { 0x2001, { 0x405, 1, 2 } }, //40e
+ { 0xa000, { 0x407, 7200, 0x40e } }, //40f
+ { 0x6000, { 0x40c, 0x40e, 7200 } }, //410
+ { 0x2001, { 0x40d, 1, 2 } }, //411 1/2 width
+ { 0x6000, { 0x407, 0x411, 0 } }, //412 top center glue xpos
+ { 0x8000, { 21600, 0, 0x412 } }, //413 bottom center glue xpos
+ { 0x2001, { 0x405, 1, 2 } }, //414 left glue x pos
+ { 0x8000, { 21600, 0, 0x414 } }, //415 right glue x pos
+ { 0x2001, { 0x400, 2, 1 } }, //416 y1 (textbox)
+ { 0x8000, { 21600, 0, 0x416 } }, //417 y2 (textbox)
+
+ { 0x8000, { 21600, 0, 0x407 } }, //418 p2
+
+ { 0x8000, { 21600, 0, 0x40f } }, //419 c
+ { 0x6000, { 0x401, 0x408, 0 } }, //41a
+
+ { 0x8000, { 21600, 0, 0x410 } }, //41b c
+ { 0xa000, { 0x401, 0, 0x408 } }, //41c
+
+ { 0x8000, { 21600, 0, 0x40c } } //41d p3
+};
+static const SvxMSDffVertPair mso_sptWaveGluePoints[] =
+{
+ { 0x12 MSO_I, 0 MSO_I }, { 0x14 MSO_I, 10800 }, { 0x13 MSO_I, 1 MSO_I }, { 0x15 MSO_I, 10800 }
+};
+static const sal_uInt16 mso_sptWaveSegm[] =
+{
+ 0x4000, 0x2001, 0x0001, 0x2001, 0x6000, 0x8000
+};
+static const SvxMSDffHandle mso_sptWaveHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 4460 },
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x101, 21600, 10800, 10800, 8640, 12960, 0x80000000, 0x7fffffff }
+};
+static const sal_Int32 mso_sptWaveDefault[] =
+{
+ 2, 1400, 10800
+};
+static const SvxMSDffTextRectangles mso_sptWaveTextRect[] =
+{
+ { { 5 MSO_I, 22 MSO_I }, { 11 MSO_I, 23 MSO_I } }
+};
+static const mso_CustomShape msoWave =
+{
+ (SvxMSDffVertPair*)mso_sptWaveVert, sizeof( mso_sptWaveVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptWaveSegm, sizeof( mso_sptWaveSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptWaveCalc, sizeof( mso_sptWaveCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptWaveDefault,
+ (SvxMSDffTextRectangles*)mso_sptWaveTextRect, sizeof( mso_sptWaveTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptWaveGluePoints, sizeof( mso_sptWaveGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptWaveHandle, sizeof( mso_sptWaveHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptDoubleWaveVert[] = // adjustment1 : 0 - 2230
+{ // adjustment2 : 8640 - 12960
+ { 7 MSO_I, 0 MSO_I }, { 15 MSO_I, 9 MSO_I }, { 0x1e MSO_I, 10 MSO_I }, { 0x12 MSO_I, 0 MSO_I }, { 0x1f MSO_I, 9 MSO_I }, { 16 MSO_I, 10 MSO_I }, { 12 MSO_I, 0 MSO_I },
+ { 24 MSO_I, 1 MSO_I }, { 25 MSO_I, 26 MSO_I }, { 0x21 MSO_I, 28 MSO_I }, { 0x13 MSO_I, 1 MSO_I }, { 0x20 MSO_I, 26 MSO_I }, { 27 MSO_I, 28 MSO_I }, { 29 MSO_I, 1 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptDoubleWaveCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, //400 (vert.adj)
+ { 0x8000, { 21600, 0, 0x400 } }, //401
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },//402 (horz.adj)
+ { 0x2000, { 0x402, 0, 10800 } }, //403 -2160 -> 2160 (horz.adj)
+ { 0x2001, { 0x403, 2, 1 } }, //404 -4320 -> 4320 (horz.adj)
+ { 0x2003, { 0x404, 0, 0 } }, //405 abs( 0x404 ) (horz.adj)
+ { 0x8000, { 4320, 0, 0x405 } }, //406 -> not used
+ { 0xa006, { 0x403, 0, 0x405 } }, //407
+ { 0x4001, { 7900, 0x400, 2230 } }, //408 0 -> 7900 (vert.adj)
+ { 0xa000, { 0x400, 0, 0x408 } }, //409
+ { 0x6000, { 0x400, 0x408, 0 } }, //40a
+ { 0x8000, { 21600, 0, 0x404 } }, //40b
+ { 0x6006, { 0x403, 0x40b, 21600 } }, //40c
+ { 0xa000, { 0x40c, 0, 0x407 } }, //40d width between p0 and p1
+ { 0x2001, { 0x405, 1, 2 } }, //40e
+ { 0xa000, { 0x407, 3600, 0x40e } }, //40f
+ { 0x6000, { 0x40c, 0x40e, 3600 } }, //410
+ { 0x2001, { 0x40d, 1, 2 } }, //411 1/2 width
+ { 0x6000, { 0x407, 0x411, 0 } }, //412 top center glue xpos
+ { 0x8000, { 21600, 0, 0x412 } }, //413 bottom center glue xpos
+ { 0x2001, { 0x405, 1, 2 } }, //414 left glue x pos
+ { 0x8000, { 21600, 0, 0x414 } }, //415 right glue x pos
+ { 0x2001, { 0x400, 2, 1 } }, //416 y1 (textbox)
+ { 0x8000, { 21600, 0, 0x416 } }, //417 y2 (textbox)
+
+ { 0x8000, { 21600, 0, 0x407 } }, //418 p2
+
+ { 0x8000, { 21600, 0, 0x40f } }, //419 c
+ { 0x6000, { 0x401, 0x408, 0 } }, //41a
+
+ { 0x8000, { 21600, 0, 0x410 } }, //41b c
+ { 0xa000, { 0x401, 0, 0x408 } }, //41c
+
+ { 0x8000, { 21600, 0, 0x40c } }, //41d p3
+ { 0xa000, { 0x412, 0, 0x40e } }, //41e
+ { 0x6000, { 0x412, 0x40e, 0 } }, //41f
+ { 0xa000, { 0x413, 0, 0x40e } }, //420
+ { 0x6000, { 0x413, 0x40e, 0 } } //421
+};
+static const SvxMSDffVertPair mso_sptDoubleWaveGluePoints[] =
+{
+ { 0x12 MSO_I, 0 MSO_I }, { 0x14 MSO_I, 10800 }, { 0x13 MSO_I, 1 MSO_I }, { 0x15 MSO_I, 10800 }
+};
+static const sal_uInt16 mso_sptDoubleWaveSegm[] =
+{
+ 0x4000, 0x2002, 0x0001, 0x2002, 0x6000, 0x8000
+};
+static const SvxMSDffHandle mso_sptDoubleWaveHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 2230 },
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x101, 21600, 10800, 10800, 8640, 12960, 0x80000000, 0x7fffffff }
+};
+static const sal_Int32 mso_sptDoubleWaveDefault[] =
+{
+ 2, 1400, 10800
+};
+static const SvxMSDffTextRectangles mso_sptDoubleWaveTextRect[] =
+{
+ { { 5 MSO_I, 22 MSO_I }, { 11 MSO_I, 23 MSO_I } }
+};
+static const mso_CustomShape msoDoubleWave =
+{
+ (SvxMSDffVertPair*)mso_sptDoubleWaveVert, sizeof( mso_sptDoubleWaveVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptDoubleWaveSegm, sizeof( mso_sptDoubleWaveSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptDoubleWaveCalc, sizeof( mso_sptDoubleWaveCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDoubleWaveDefault,
+ (SvxMSDffTextRectangles*)mso_sptDoubleWaveTextRect, sizeof( mso_sptDoubleWaveTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptDoubleWaveGluePoints, sizeof( mso_sptDoubleWaveGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptDoubleWaveHandle, sizeof( mso_sptDoubleWaveHandle ) / sizeof( SvxMSDffHandle )
+};
+
+// for each shapetype a bit of 1 is indicating that the shape is NOT filled by default
+static const sal_uInt16 mso_DefaultFillingTable[] =
+{
+ 0x0000, 0x0018, 0x01ff, 0x0000, 0x0c00, 0x01e0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000
+};
+sal_Bool IsCustomShapeFilledByDefault( MSO_SPT eSpType )
+{
+ sal_Bool bIsFilledByDefault = sal_True;
+ sal_uInt32 i = (sal_uInt32)eSpType;
+ if ( i < 0x100 )
+ bIsFilledByDefault = ( mso_DefaultFillingTable[ i >> 4 ] & ( 1 << ( i & 0xf ) ) ) == 0;
+ return bIsFilledByDefault;
+}
+sal_Int16 GetCustomShapeConnectionTypeDefault( MSO_SPT eSpType )
+{
+ sal_Int16 nGluePointType = com::sun::star::drawing::EnhancedCustomShapeGluePointType::SEGMENTS;
+ const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
+ if ( pDefCustomShape && pDefCustomShape->nGluePoints )
+ nGluePointType = com::sun::star::drawing::EnhancedCustomShapeGluePointType::CUSTOM;
+ else
+ {
+ switch( eSpType )
+ {
+ case mso_sptRectangle :
+ case mso_sptRoundRectangle :
+ case mso_sptPictureFrame :
+ case mso_sptFlowChartProcess :
+ case mso_sptFlowChartPredefinedProcess :
+ case mso_sptFlowChartInternalStorage :
+ case mso_sptTextPlainText :
+ case mso_sptTextBox :
+ case mso_sptVerticalScroll :
+ case mso_sptHorizontalScroll :
+ nGluePointType = com::sun::star::drawing::EnhancedCustomShapeGluePointType::RECT;
+ default: break;
+ }
+ }
+ return nGluePointType;
+}
+
+// for each shapetype a bit of 1 is indicating that the shape is NOT stroked by default
+// #i28269#
+static const sal_uInt16 mso_DefaultStrokingTable[] =
+{
+ 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0800, 0x0000, 0x0000, 0x0000, // #i28269# Added shape 75 (mso_sptPictureFrame)
+ 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000
+};
+// #i28269#
+sal_Bool IsCustomShapeStrokedByDefault( MSO_SPT eSpType )
+{
+ sal_Bool bIsStrokedByDefault = sal_True;
+ sal_uInt32 i = (sal_uInt32)eSpType;
+ if ( i < 0x100 )
+ bIsStrokedByDefault = ( mso_DefaultStrokingTable[ i >> 4 ] & ( 1 << ( i & 0xf ) ) ) == 0;
+ return bIsStrokedByDefault;
+}
+
+static const sal_uInt16 msoSortFilledObjectsToBackTable[] =
+{
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0010, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
+};
+sal_Bool SortFilledObjectsToBackByDefault( MSO_SPT eSpType )
+{
+ sal_Bool bSortFilledObjectsToBackByDefault = sal_True;
+ sal_uInt32 i = (sal_uInt32)eSpType;
+ if ( i < 0x100 )
+ bSortFilledObjectsToBackByDefault = ( msoSortFilledObjectsToBackTable[ i >> 4 ] & ( 1 << ( i & 0xf ) ) ) != 0;
+ return bSortFilledObjectsToBackByDefault;
+}
+
+static const SvxMSDffVertPair mso_sptFontWorkVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 0, 21600 }, { 21600, 21600 }
+};
+static const sal_uInt16 mso_sptFontWorkSegm[] =
+{
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffTextRectangles mso_sptFontWorkTextRect[] =
+{
+ { { 0, 0 }, { 21600, 21600 } }
+};
+static const mso_CustomShape msoFontWork =
+{
+ (SvxMSDffVertPair*)mso_sptFontWorkVert, sizeof( mso_sptFontWorkVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptFontWorkSegm, sizeof( mso_sptFontWorkSegm ) >> 1,
+ NULL, 0,
+ NULL,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ NULL, 0 // Handles
+};
+
+static const SvxMSDffVertPair mso_sptTextPlainTextVert[] =
+{
+ { 3 MSO_I, 0 }, { 5 MSO_I, 0 }, { 6 MSO_I, 21600 }, { 7 MSO_I, 21600 }
+};
+static const SvxMSDffCalculationData mso_sptTextPlainTextCalc[] = // adjustment1 : 6629 - 14971
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 10800 } },
+ { 0x2001, { 0x400, 2, 1 } },
+ { 0x2003, { 0x401, 0, 0 } },
+ { 0xa006, { 0x401, 0, 0x402 } }, // x1(3)
+ { 0x8000, { 21600, 0, 0x402 } },
+ { 0x6006, { 0x401, 0x404, 21600 } }, // x2(5)
+ { 0x6006, { 0x401, 0x402, 0 } }, // x2
+ { 0xa006, { 0x401, 21600, 0x404 } } // x3(7)
+};
+static const sal_uInt16 mso_sptTextPlainTextSegm[] =
+{
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextPlainTextHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 21600, 10800, 10800, 6629, 14971, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoTextPlainText =
+{
+ (SvxMSDffVertPair*)mso_sptTextPlainTextVert, sizeof( mso_sptTextPlainTextVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextPlainTextSegm, sizeof( mso_sptTextPlainTextSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextPlainTextCalc, sizeof( mso_sptTextPlainTextCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault10800,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextPlainTextHandle, sizeof( mso_sptTextPlainTextHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextStopVert[] =
+{
+ { 0, 0 MSO_I }, { 7200, 0 }, { 14400, 0 }, { 21600, 0 MSO_I },
+ { 0, 1 MSO_I }, { 7200, 21600 }, { 14400, 21600 }, { 21600, 1 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextStopCalc[] = // adjustment1 : 3080 - 10800
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }
+};
+static const sal_uInt16 mso_sptTextStopSegm[] =
+{
+ 0x4000, 0x0003, 0x8000,
+ 0x4000, 0x0003, 0x8000
+};
+static const sal_Int32 mso_sptTextStopDefault[] =
+{
+ 1, 2700
+};
+static const SvxMSDffHandle mso_sptTextStopHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 3080, 10800 }
+};
+static const mso_CustomShape msoTextStop =
+{
+ (SvxMSDffVertPair*)mso_sptTextStopVert, sizeof( mso_sptTextStopVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextStopSegm, sizeof( mso_sptTextStopSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextStopCalc, sizeof( mso_sptTextStopCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextStopDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextStopHandle, sizeof( mso_sptTextStopHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextTriangleVert[] =
+{
+ { 0, 0 MSO_I }, { 10800, 0 }, { 21600, 0 MSO_I }, { 0, 21600 }, { 21600, 21600 }
+};
+static const SvxMSDffCalculationData mso_sptTextTriangleCalc[] = // adjustment1 : 6629 - 14971
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }
+};
+static const sal_uInt16 mso_sptTextTriangleSegm[] =
+{
+ 0x4000, 0x0002, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextTriangleHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 21600 }
+};
+static const mso_CustomShape msoTextTriangle =
+{
+ (SvxMSDffVertPair*)mso_sptTextTriangleVert, sizeof( mso_sptTextTriangleVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextTriangleSegm, sizeof( mso_sptTextTriangleSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextTriangleCalc, sizeof( mso_sptTextTriangleCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault10800,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextTriangleHandle, sizeof( mso_sptTextTriangleHandle ) / sizeof( SvxMSDffHandle )
+};
+static const SvxMSDffVertPair mso_sptTextTriangleInvertedVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 0, 0 MSO_I }, { 10800, 21600 }, { 21600, 0 MSO_I }
+};
+static const sal_uInt16 mso_sptTextTriangleInvertedSegm[] =
+{
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0002, 0x8000
+};
+static const mso_CustomShape msoTextTriangleInverted =
+{
+ (SvxMSDffVertPair*)mso_sptTextTriangleInvertedVert, sizeof( mso_sptTextTriangleInvertedVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextTriangleInvertedSegm, sizeof( mso_sptTextTriangleInvertedSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextTriangleCalc, sizeof( mso_sptTextTriangleCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault10800,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextTriangleHandle, sizeof( mso_sptTextTriangleHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextChevronVert[] =
+{
+ { 0, 0 MSO_I }, { 10800, 0 }, { 21600, 0 MSO_I }, { 0, 21600 }, { 10800, 1 MSO_I }, { 21600, 21600 }
+};
+static const SvxMSDffCalculationData mso_sptTextChevronCalc[] = // adjustment1 : 6629 - 14971
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }
+};
+static const sal_uInt16 mso_sptTextChevronSegm[] =
+{
+ 0x4000, 0x0002, 0x8000,
+ 0x4000, 0x0002, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextChevronHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 10800 }
+};
+static const mso_CustomShape msoTextChevron =
+{
+ (SvxMSDffVertPair*)mso_sptTextChevronVert, sizeof( mso_sptTextChevronVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextChevronSegm, sizeof( mso_sptTextChevronSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextChevronCalc, sizeof( mso_sptTextChevronCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault5400,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextChevronHandle, sizeof( mso_sptTextChevronHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextChevronInvertedVert[] =
+{
+ { 0, 0 }, { 10800, 1 MSO_I }, { 21600, 0 }, { 0, 0 MSO_I }, { 10800, 21600 }, { 21600, 0 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextChevronInvertedCalc[] = // adjustment1 : 6629 - 14971
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }
+};
+static const sal_uInt16 mso_sptTextChevronInvertedSegm[] =
+{
+ 0x4000, 0x0002, 0x8000,
+ 0x4000, 0x0002, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextChevronInvertedHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 10800, 21600 }
+};
+static const mso_CustomShape msoTextChevronInverted =
+{
+ (SvxMSDffVertPair*)mso_sptTextChevronInvertedVert, sizeof( mso_sptTextChevronInvertedVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextChevronInvertedSegm, sizeof( mso_sptTextChevronInvertedSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextChevronInvertedCalc, sizeof( mso_sptTextChevronInvertedCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault16200,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextChevronInvertedHandle, sizeof( mso_sptTextChevronInvertedHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextRingOutsideVert[] =
+{
+ { 10800, 0 MSO_I }, { 10800, 0 MSO_I }, { 180, 359 },
+ { 10800, 1 MSO_I }, { 10800, 0 MSO_I }, { 180, 359 }
+};
+static const SvxMSDffCalculationData mso_sptTextRingOutsideCalc[] = // adjustment1 : 6629 - 14971
+{
+ { 0x2001, { DFF_Prop_adjustValue, 1, 2 } },
+ { 0x8000, { 21600, 0, 0x400 } }
+};
+static const sal_uInt16 mso_sptTextRingOutsideSegm[] =
+{
+ 0xA203, 0x8000,
+ 0xA203, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextRingOutsideHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 10800, 21600 }
+};
+static const mso_CustomShape msoTextRingOutside =
+{
+ (SvxMSDffVertPair*)mso_sptTextRingOutsideVert, sizeof( mso_sptTextRingOutsideVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextRingOutsideSegm, sizeof( mso_sptTextRingOutsideSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextRingOutsideCalc, sizeof( mso_sptTextRingOutsideCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault16200,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextRingOutsideHandle, sizeof( mso_sptTextRingOutsideHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextFadeRightVert[] =
+{
+ { 0, 0 }, { 21600, 0 MSO_I }, { 0, 21600 }, { 21600, 1 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextFadeCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }
+};
+static const sal_uInt16 mso_sptTextFadeSegm[] =
+{
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextFadeRightHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 21600, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 10800 }
+};
+static const mso_CustomShape msoTextFadeRight =
+{
+ (SvxMSDffVertPair*)mso_sptTextFadeRightVert, sizeof( mso_sptTextFadeRightVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextFadeSegm, sizeof( mso_sptTextFadeSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextFadeCalc, sizeof( mso_sptTextFadeCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault7200,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextFadeRightHandle, sizeof( mso_sptTextFadeRightHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextFadeLeftVert[] =
+{
+ { 0, 0 MSO_I }, { 21600, 0 }, { 0, 1 MSO_I }, { 21600, 21600 }
+};
+static const SvxMSDffHandle mso_sptTextFadeLeftHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 10800 }
+};
+static const mso_CustomShape msoTextFadeLeft =
+{
+ (SvxMSDffVertPair*)mso_sptTextFadeLeftVert, sizeof( mso_sptTextFadeLeftVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextFadeSegm, sizeof( mso_sptTextFadeSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextFadeCalc, sizeof( mso_sptTextFadeCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault7200,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextFadeLeftHandle, sizeof( mso_sptTextFadeLeftHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextFadeUpVert[] =
+{
+ { 0 MSO_I, 0 }, { 1 MSO_I, 0 }, { 0, 21600 }, { 21600, 21600 }
+};
+static const SvxMSDffHandle mso_sptTextFadeUpHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 0, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoTextFadeUp =
+{
+ (SvxMSDffVertPair*)mso_sptTextFadeUpVert, sizeof( mso_sptTextFadeUpVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextFadeSegm, sizeof( mso_sptTextFadeSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextFadeCalc, sizeof( mso_sptTextFadeCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault7200,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextFadeUpHandle, sizeof( mso_sptTextFadeUpHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextFadeDownVert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 0 MSO_I, 21600 }, { 1 MSO_I, 21600 }
+};
+static const SvxMSDffHandle mso_sptTextFadeDownHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 21600, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoTextFadeDown =
+{
+ (SvxMSDffVertPair*)mso_sptTextFadeDownVert, sizeof( mso_sptTextFadeDownVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextFadeSegm, sizeof( mso_sptTextFadeSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextFadeCalc, sizeof( mso_sptTextFadeCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault7200,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextFadeDownHandle, sizeof( mso_sptTextFadeDownHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextSlantUpVert[] =
+{
+ { 0, 0 MSO_I }, { 21600, 0 }, { 0, 21600 }, { 21600, 1 MSO_I }
+};
+static const SvxMSDffHandle mso_sptTextSlantUpHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 15400 }
+};
+static const mso_CustomShape msoTextSlantUp =
+{
+ (SvxMSDffVertPair*)mso_sptTextSlantUpVert, sizeof( mso_sptTextSlantUpVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextFadeSegm, sizeof( mso_sptTextFadeSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextFadeCalc, sizeof( mso_sptTextFadeCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault12000,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextSlantUpHandle, sizeof( mso_sptTextSlantUpHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextSlantDownVert[] =
+{
+ { 0, 0 }, { 21600, 1 MSO_I }, { 0, 0 MSO_I }, { 21600, 21600 }
+};
+static const SvxMSDffHandle mso_sptTextSlantDownHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 6200, 21600 }
+};
+static const mso_CustomShape msoTextSlantDown =
+{
+ (SvxMSDffVertPair*)mso_sptTextSlantDownVert, sizeof( mso_sptTextSlantDownVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextFadeSegm, sizeof( mso_sptTextFadeSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextFadeCalc, sizeof( mso_sptTextFadeCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault12000,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextSlantDownHandle, sizeof( mso_sptTextSlantDownHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextCascadeUpVert[] =
+{
+ { 0, 2 MSO_I }, { 21600, 0 }, { 0, 21600 }, { 21600, 0 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextCascadeCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } },
+ { 0x2001, { 0x401, 1, 4 } }
+};
+static const SvxMSDffHandle mso_sptTextCascadeUpHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 21600, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 6200, 21600 }
+};
+static const mso_CustomShape msoTextCascadeUp =
+{
+ (SvxMSDffVertPair*)mso_sptTextCascadeUpVert, sizeof( mso_sptTextCascadeUpVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextFadeSegm, sizeof( mso_sptTextFadeSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextCascadeCalc, sizeof( mso_sptTextCascadeCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault9600,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextCascadeUpHandle, sizeof( mso_sptTextCascadeUpHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextCascadeDownVert[] =
+{
+ { 0, 0 }, { 21600, 2 MSO_I }, { 0, 0 MSO_I }, { 21600, 21600 }
+};
+static const SvxMSDffHandle mso_sptTextCascadeDownHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 6200, 21600 }
+};
+static const mso_CustomShape msoTextCascadeDown =
+{
+ (SvxMSDffVertPair*)mso_sptTextCascadeDownVert, sizeof( mso_sptTextCascadeDownVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextFadeSegm, sizeof( mso_sptTextFadeSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextCascadeCalc, sizeof( mso_sptTextCascadeCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault9600,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextCascadeDownHandle, sizeof( mso_sptTextCascadeDownHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextArchUpCurveVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 2 MSO_I, 3 MSO_I }, { 4 MSO_I, 3 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextArchCurveCalc[] =
+{
+ { 0x400a, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x4009, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x2000, { 0x400, 10800, 0 } },
+ { 0x2000, { 0x401, 10800, 0 } },
+ { 0x8000, { 21600, 0, 0x402 } }
+};
+static const sal_uInt16 mso_sptTextArchUpCurveSegm[] =
+{
+ 0xA504, 0x8000 // clockwíse arc
+};
+static const SvxMSDffHandle mso_sptTextArchUpCurveHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_POLAR,
+ 10800, 0x100, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const sal_Int32 mso_sptTextArchUpCurveDefault[] =
+{
+ 1, 180
+};
+static const mso_CustomShape msoTextArchUpCurve =
+{
+ (SvxMSDffVertPair*)mso_sptTextArchUpCurveVert, sizeof( mso_sptTextArchUpCurveVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextArchUpCurveSegm, sizeof( mso_sptTextArchUpCurveSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextArchCurveCalc, sizeof( mso_sptTextArchCurveCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextArchUpCurveDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextArchUpCurveHandle, sizeof( mso_sptTextArchUpCurveHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextArchDownCurveVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 4 MSO_I, 3 MSO_I }, { 2 MSO_I, 3 MSO_I }
+};
+static const sal_uInt16 mso_sptTextArchDownCurveSegm[] =
+{
+ 0xA304, 0x8000 // counter clockwise arc to
+};
+static const SvxMSDffHandle mso_sptTextArchDownCurveHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_POLAR,
+ 10800, 0x100, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const sal_Int32 mso_sptTextArchDownCurveDefault[] =
+{
+ 1, 0
+};
+static const mso_CustomShape msoTextArchDownCurve =
+{
+ (SvxMSDffVertPair*)mso_sptTextArchDownCurveVert, sizeof( mso_sptTextArchDownCurveVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextArchDownCurveSegm, sizeof( mso_sptTextArchDownCurveSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextArchCurveCalc, sizeof( mso_sptTextArchCurveCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextArchDownCurveDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextArchDownCurveHandle, sizeof( mso_sptTextArchDownCurveHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextCircleCurveVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 2 MSO_I, 3 MSO_I }, { 2 MSO_I, 4 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextCircleCurveCalc[] =
+{
+ { 0x400a, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x4009, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x2000, { 0x400, 10800, 0 } },
+ { 0x2000, { 0x401, 10800, 0 } },
+ { 0x8000, { 21600, 0, 0x403 } }
+};
+static const sal_uInt16 mso_sptTextCircleCurveSegm[] =
+{
+ 0xA504, 0x8000 // clockwise arc to
+};
+static const SvxMSDffHandle mso_sptTextCircleCurveHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_POLAR,
+ 10800, 0x100, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const sal_Int32 mso_sptTextCircleCurveDefault[] =
+{
+ 1, -179
+};
+static const mso_CustomShape msoTextCircleCurve =
+{
+ (SvxMSDffVertPair*)mso_sptTextCircleCurveVert, sizeof( mso_sptTextCircleCurveVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextCircleCurveSegm, sizeof( mso_sptTextCircleCurveSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextCircleCurveCalc, sizeof( mso_sptTextCircleCurveCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextCircleCurveDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextCircleCurveHandle, sizeof( mso_sptTextCircleCurveHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextButtonCurveVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 2 MSO_I, 3 MSO_I }, { 4 MSO_I, 3 MSO_I },
+ { 0, 10800 }, { 21600, 10800 },
+ { 0, 0 }, { 21600, 21600 }, { 2 MSO_I, 5 MSO_I }, { 4 MSO_I, 5 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextButtonCurveCalc[] =
+{
+ { 0x400a, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x4009, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x2000, { 0x400, 10800, 0 } },
+ { 0x2000, { 0x401, 10800, 0 } },
+ { 0x8000, { 21600, 0, 0x402 } },
+ { 0x8000, { 21600, 0, 0x403 } }
+};
+static const sal_uInt16 mso_sptTextButtonCurveSegm[] =
+{
+ 0xA504, 0x8000, // clockwise arc
+ 0x4000, 0x0001, 0x8000,
+ 0xA304, 0x8000 // counter clockwise
+};
+static const SvxMSDffHandle mso_sptTextButtonCurveHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_POLAR,
+ 10800, 0x100, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const sal_Int32 mso_sptTextButtonCurveDefault[] =
+{
+ 1, 180
+};
+static const mso_CustomShape msoTextButtonCurve =
+{
+ (SvxMSDffVertPair*)mso_sptTextButtonCurveVert, sizeof( mso_sptTextButtonCurveVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextButtonCurveSegm, sizeof( mso_sptTextButtonCurveSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextButtonCurveCalc, sizeof( mso_sptTextButtonCurveCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextButtonCurveDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextButtonCurveHandle, sizeof( mso_sptTextButtonCurveHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextArchUpPourVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 2 MSO_I, 3 MSO_I }, { 4 MSO_I, 3 MSO_I },
+ { 5 MSO_I, 5 MSO_I }, { 11 MSO_I, 11 MSO_I }, { 8 MSO_I, 9 MSO_I }, { 0xa MSO_I, 9 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextArchPourCalc[] =
+{
+ { 0x400a, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x4009, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x2000, { 0x400, 10800, 0 } },
+ { 0x2000, { 0x401, 10800, 0 } },
+ { 0x8000, { 21600, 0, 0x402 } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjust2Value } },
+ { 0x600a, { 0x405, DFF_Prop_adjustValue, 0 } }, // 6
+ { 0x6009, { 0x405, DFF_Prop_adjustValue, 0 } },
+ { 0x2000, { 0x406, 10800, 0 } }, // 8
+ { 0x2000, { 0x407, 10800, 0 } },
+ { 0x8000, { 21600, 0, 0x408 } }, // 10
+ { 0x8000, { 21600, 0, 0x405 } }
+};
+static const sal_uInt16 mso_sptTextArchUpPourSegm[] =
+{
+ 0xA504, 0x8000, 0xA504, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextArchPourHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_POLAR | MSDFF_HANDLE_FLAGS_RADIUS_RANGE,
+ 0x101, 0x100, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const sal_Int32 mso_sptTextArchUpPourDefault[] =
+{
+ 2, 180, 5400
+};
+static const mso_CustomShape msoTextArchUpPour =
+{
+ (SvxMSDffVertPair*)mso_sptTextArchUpPourVert, sizeof( mso_sptTextArchUpPourVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextArchUpPourSegm, sizeof( mso_sptTextArchUpPourSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextArchPourCalc, sizeof( mso_sptTextArchPourCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextArchUpPourDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextArchPourHandle, sizeof( mso_sptTextArchPourHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextArchDownPourVert[] =
+{
+ { 5 MSO_I, 5 MSO_I }, { 11 MSO_I, 11 MSO_I }, { 0xa MSO_I, 9 MSO_I }, { 8 MSO_I, 9 MSO_I },
+ { 0, 0 }, { 21600, 21600 }, { 4 MSO_I, 3 MSO_I }, { 2 MSO_I, 3 MSO_I }
+};
+static const sal_uInt16 mso_sptTextArchDownPourSegm[] =
+{
+ 0xA304, 0x8000, 0xA304, 0x8000
+};
+static const sal_Int32 mso_sptTextArchDownPourDefault[] =
+{
+ 2, 0, 5400
+};
+static const mso_CustomShape msoTextArchDownPour =
+{
+ (SvxMSDffVertPair*)mso_sptTextArchDownPourVert, sizeof( mso_sptTextArchDownPourVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextArchDownPourSegm, sizeof( mso_sptTextArchDownPourSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextArchPourCalc, sizeof( mso_sptTextArchPourCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextArchDownPourDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextArchPourHandle, sizeof( mso_sptTextArchPourHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextCirclePourVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 2 MSO_I, 3 MSO_I }, { 2 MSO_I, 4 MSO_I },
+ { 5 MSO_I, 5 MSO_I }, { 11 MSO_I, 11 MSO_I }, { 8 MSO_I, 9 MSO_I }, { 8 MSO_I, 0xa MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextCirclePourCalc[] =
+{
+ { 0x400a, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x4009, { 10800, DFF_Prop_adjustValue, 0 } },
+ { 0x2000, { 0x400, 10800, 0 } },
+ { 0x2000, { 0x401, 10800, 0 } },
+ { 0x8000, { 21600, 0, 0x403 } },
+ { 0x8000, { 10800, 0, DFF_Prop_adjust2Value } },
+ { 0x600a, { 0x405, DFF_Prop_adjustValue, 0 } }, // 6
+ { 0x6009, { 0x405, DFF_Prop_adjustValue, 0 } },
+ { 0x2000, { 0x406, 10800, 0 } }, // 8
+ { 0x2000, { 0x407, 10800, 0 } },
+ { 0x8000, { 21600, 0, 0x409 } }, // 10
+ { 0x8000, { 21600, 0, 0x405 } },
+ { 0x000, { 21600, 0, 0 } }
+};
+static const sal_uInt16 mso_sptTextCirclePourSegm[] =
+{
+ 0xA504, 0x8000, 0xA504, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextCirclePourHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_POLAR | MSDFF_HANDLE_FLAGS_RADIUS_RANGE,
+ 0x101, 0x100, 10800, 10800, 0, 10800, 0x80000000, 0x7fffffff }
+};
+static const sal_Int32 mso_sptTextCirclePourDefault[] =
+{
+ 2, -179, 5400
+};
+static const mso_CustomShape msoTextCirclePour =
+{
+ (SvxMSDffVertPair*)mso_sptTextCirclePourVert, sizeof( mso_sptTextCirclePourVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextCirclePourSegm, sizeof( mso_sptTextCirclePourSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextCirclePourCalc, sizeof( mso_sptTextCirclePourCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextCirclePourDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextCirclePourHandle, sizeof( mso_sptTextCirclePourHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextButtonPourVert[] =
+{
+ { 0, 0 }, { 21600, 21600 }, { 2 MSO_I, 3 MSO_I }, { 4 MSO_I, 3 MSO_I },
+ { 6 MSO_I, 6 MSO_I }, { 7 MSO_I, 7 MSO_I }, { 10 MSO_I, 11 MSO_I }, { 12 MSO_I, 11 MSO_I },
+ { 0x16 MSO_I, 16 MSO_I }, { 0x15 MSO_I, 16 MSO_I },
+ { 0x16 MSO_I, 15 MSO_I }, { 0x15 MSO_I, 15 MSO_I },
+ { 6 MSO_I, 6 MSO_I }, { 7 MSO_I, 7 MSO_I }, { 10 MSO_I, 13 MSO_I }, { 12 MSO_I, 13 MSO_I },
+ { 0, 0 }, { 21600, 21600 }, { 2 MSO_I, 5 MSO_I }, { 4 MSO_I, 5 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextButtonPourCalc[] =
+{
+ { 0x400a, { 10800, DFF_Prop_adjustValue, 0 } }, // 0x00
+ { 0x4009, { 10800, DFF_Prop_adjustValue, 0 } }, // 0x01
+ { 0x2000, { 0x400, 10800, 0 } }, // 0x02
+ { 0x2000, { 0x401, 10800, 0 } }, // 0x03
+ { 0x8000, { 21600, 0, 0x402 } }, // 0x04
+ { 0x8000, { 21600, 0, 0x403 } }, // 0x05
+
+ { 0x8000, { 10800, 0, DFF_Prop_adjust2Value } }, // 0x06
+ { 0x8000, { 21600, 0, 0x406 } }, // 0x07
+
+ { 0x600a, { DFF_Prop_adjust2Value, DFF_Prop_adjustValue, 0 } }, // 0x08
+ { 0x6009, { DFF_Prop_adjust2Value, DFF_Prop_adjustValue, 0 } }, // 0x09
+ { 0x2000, { 0x408, 10800, 0 } }, // 0x0a
+ { 0x2000, { 0x409, 10800, 0 } }, // 0x0b
+ { 0x8000, { 21600, 0, 0x40a } }, // 0x0c
+ { 0x8000, { 21600, 0, 0x40b } }, // 0x0d
+ { 0x2001, { 0x406, 1, 2 } }, // 0x0e
+ { 0x4000, { 10800, 0x40e, 0 } }, // 0x0f
+ { 0x8000, { 10800, 0, 0x40e } }, // 0x10
+ { 0x6001, { 0x40e, 0x40e, 1 } }, // 0x11
+ { 0x6001, { DFF_Prop_adjust2Value, DFF_Prop_adjust2Value, 1 } }, // 0x12
+ { 0xA000, { 0x412, 0, 0x411 } }, // 0x13
+ { 0x200d, { 0x413, 0, 0 } }, // 0x14
+ { 0x4000, { 10800, 0x414, 0 } }, // 0x15
+ { 0x8000, { 10800, 0, 0x414 } } // 0x16
+};
+static const sal_uInt16 mso_sptTextButtonPourSegm[] =
+{
+ 0xA504, 0x8000, // clockwise arc
+ 0xA504, 0x8000, // clockwise arc
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0xA304, 0x8000, // counter clockwise
+ 0xA304, 0x8000 // counter clockwise
+};
+static const SvxMSDffHandle mso_sptTextButtonPourHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_POLAR | MSDFF_HANDLE_FLAGS_RADIUS_RANGE,
+ 0x101, 0x100, 10800, 10800, 4320, 10800, 0x80000000, 0x7fffffff }
+};
+static const sal_Int32 mso_sptTextButtonPourDefault[] =
+{
+ 2, 180, 5400
+};
+static const mso_CustomShape msoTextButtonPour =
+{
+ (SvxMSDffVertPair*)mso_sptTextButtonPourVert, sizeof( mso_sptTextButtonPourVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextButtonPourSegm, sizeof( mso_sptTextButtonPourSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextButtonPourCalc, sizeof( mso_sptTextButtonPourCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextButtonPourDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextButtonPourHandle, sizeof( mso_sptTextButtonPourHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextCurveUpVert[] =
+{
+ { 0, 0 MSO_I }, { 4900, 1 MSO_I /*12170->0 14250 ->0*/ }, { 11640, 2 MSO_I /*12170->0 12800 ->0*/ }, { 21600, 0 },
+ { 0, 4 MSO_I /*12170->0 17220 ->21600*/ }, { 3700, 21600 }, { 8500, 21600 }, { 10100, 21600 }, { 14110, 21600 }, { 15910, 21600 }, { 21600, 4 MSO_I /*12170->0 17220 ->21600*/ }
+};
+static const SvxMSDffCalculationData mso_sptTextCurveUpCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 400
+ { 0x4001, { 14250, 0x400, 12170 } }, // 401
+ { 0x4001, { 12800, 0x400, 12170 } }, // 402
+ { 0x4001, { 6380, 0x400, 12170 } }, // 403
+ { 0x8000, { 21600, 0, 0x403 } } // 404
+};
+static const sal_uInt16 mso_sptTextCurveUpSegm[] =
+{
+ 0x4000, 0x2001, 0x8000,
+ 0x4000, 0x2002, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextCurveUpHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 12170 }
+};
+static const sal_Int32 mso_sptTextCurveUpDefault[] =
+{
+ 1, 9900
+};
+static const mso_CustomShape msoTextCurveUp =
+{
+ (SvxMSDffVertPair*)mso_sptTextCurveUpVert, sizeof( mso_sptTextCurveUpVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextCurveUpSegm, sizeof( mso_sptTextCurveUpSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextCurveUpCalc, sizeof( mso_sptTextCurveUpCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextCurveUpDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextCurveUpHandle, sizeof( mso_sptTextCurveUpHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextCurveDownVert[] =
+{
+// { 0, 0 MSO_I }, { 4900, 1 MSO_I /*12170->0 14250 ->0*/ }, { 11640, 2 MSO_I /*12170->0 12800 ->0*/ }, { 21600, 0 },
+ { 0, 0 }, { 9960, 2 MSO_I }, { 16700, 1 MSO_I }, { 21600, 0 MSO_I },
+
+// { 0, 4 MSO_I /*12170->0 17220 ->21600*/ }, { 3700, 21600 }, { 8500, 21600 }, { 10100, 21600 }, { 14110, 21600 }, { 15910, 21600 }, { 21600, 4 MSO_I /*12170->0 17220 ->21600*/ }
+ { 0, 4 MSO_I }, { 5690, 21600 }, { 7490, 21600 }, { 11500, 21600 }, { 13100, 21600 }, { 17900, 21600 }, { 21600, 4 MSO_I }
+};
+static const SvxMSDffHandle mso_sptTextCurveDownHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 21600, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 12170 }
+};
+static const mso_CustomShape msoTextCurveDown =
+{
+ (SvxMSDffVertPair*)mso_sptTextCurveDownVert, sizeof( mso_sptTextCurveDownVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextCurveUpSegm, sizeof( mso_sptTextCurveUpSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextCurveUpCalc, sizeof( mso_sptTextCurveUpCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextCurveUpDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextCurveDownHandle, sizeof( mso_sptTextCurveDownHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextCanUpVert[] =
+{
+ { 0, 1 MSO_I }, { 900, 0 }, { 7100, 0 }, { 10800, 0 }, { 14500, 0 }, { 20700, 0 }, { 21600, 1 MSO_I },
+ { 0, 21600 }, { 900, 4 MSO_I }, { 7100, 0 MSO_I }, { 10800, 0 MSO_I }, { 14500, 0 MSO_I }, { 20700, 4 MSO_I }, { 21600, 21600 }
+};
+static const SvxMSDffCalculationData mso_sptTextCanUpCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 400
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }, // 401
+ { 0x2000, { DFF_Prop_adjustValue, 0, 14400 } }, // 402
+ { 0x4001, { 5470, 0x402, 7200 } }, // 403
+ { 0x4000, { 16130, 0x403, 0 } } // 404
+};
+static const sal_uInt16 mso_sptTextCanUpSegm[] =
+{
+ 0x4000, 0x2002, 0x8000,
+ 0x4000, 0x2002, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextCanUpHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 14400, 21600 }
+};
+static const sal_Int32 mso_sptTextCanUpDefault[] =
+{
+ 1, 18500
+};
+static const mso_CustomShape msoTextCanUp =
+{
+ (SvxMSDffVertPair*)mso_sptTextCanUpVert, sizeof( mso_sptTextCanUpVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextCanUpSegm, sizeof( mso_sptTextCanUpSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextCanUpCalc, sizeof( mso_sptTextCanUpCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextCanUpDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextCanUpHandle, sizeof( mso_sptTextCanUpHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextCanDownVert[] =
+{
+ { 0, 0 }, { 900, 2 MSO_I }, { 7100, 0 MSO_I }, { 10800, 0 MSO_I }, { 14500, 0 MSO_I }, { 20700, 2 MSO_I }, { 21600, 0 },
+ { 0, 1 MSO_I }, { 900, 21600 }, { 7100, 21600 }, { 10800, 21600 }, { 14500, 21600 }, { 20700, 21600 }, { 21600, 1 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextCanDownCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 400
+ { 0x8000, { 21600, 0, DFF_Prop_adjustValue } }, // 401
+ { 0x4001, { 5470, 0x400, 7200 } } // 402
+};
+static const SvxMSDffHandle mso_sptTextCanDownHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 7200 }
+};
+static const sal_Int32 mso_sptTextCanDownDefault[] =
+{
+ 1, 3100
+};
+static const mso_CustomShape msoTextCanDown =
+{
+ (SvxMSDffVertPair*)mso_sptTextCanDownVert, sizeof( mso_sptTextCanDownVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextCanUpSegm, sizeof( mso_sptTextCanUpSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextCanDownCalc, sizeof( mso_sptTextCanDownCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextCanDownDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextCanDownHandle, sizeof( mso_sptTextCanDownHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextInflateVert[] =
+{
+ { 0, 0 MSO_I }, { 4100, 1 MSO_I }, { 7300, 0 }, { 10800, 0 }, { 14300, 0 }, { 17500, 1 MSO_I }, { 21600, 0 MSO_I },
+ { 0, 2 MSO_I }, { 4100, 3 MSO_I }, { 7300, 21600 }, { 10800, 21600 }, { 14300, 21600 }, { 17500, 3 MSO_I }, { 21600, 2 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextInflateCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 400
+ { 0x4001, { 1530, 0x400, 4650 } }, // 401
+ { 0x8000, { 21600, 0, 0x400 } }, // 402
+ { 0x8000, { 21600, 0, 0x401 } } // 403
+};
+static const SvxMSDffHandle mso_sptTextInflateHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 4650 }
+};
+static const sal_Int32 mso_sptTextInflateDefault[] =
+{
+ 1, 2950
+};
+static const mso_CustomShape msoTextInflate =
+{
+ (SvxMSDffVertPair*)mso_sptTextInflateVert, sizeof( mso_sptTextInflateVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextCanUpSegm, sizeof( mso_sptTextCanUpSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextInflateCalc, sizeof( mso_sptTextInflateCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextInflateDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextInflateHandle, sizeof( mso_sptTextInflateHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextDeflateVert[] =
+{
+ { 0, 0 }, { 3500, 1 MSO_I }, { 7100, 0 MSO_I }, { 10800, 0 MSO_I }, { 14500, 0 MSO_I }, { 18100, 1 MSO_I }, { 21600, 0 },
+ { 0, 21600 }, { 3500, 3 MSO_I }, { 7100, 2 MSO_I }, { 10800, 2 MSO_I }, { 14500, 2 MSO_I }, { 18100, 3 MSO_I }, { 21600, 21600 }
+};
+static const SvxMSDffCalculationData mso_sptTextDeflateCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 400
+ { 0x2001, { 0x400, 5320, 7100 } }, // 401
+ { 0x8000, { 21600, 0, 0x400 } }, // 402
+ { 0x8000, { 21600, 0, 0x401 } } // 403
+};
+static const SvxMSDffHandle mso_sptTextDeflateHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 8100 }
+};
+static const mso_CustomShape msoTextDeflate =
+{
+ (SvxMSDffVertPair*)mso_sptTextDeflateVert, sizeof( mso_sptTextDeflateVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextCanUpSegm, sizeof( mso_sptTextCanUpSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextDeflateCalc, sizeof( mso_sptTextDeflateCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDefault8100,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextDeflateHandle, sizeof( mso_sptTextDeflateHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextInflateBottomVert[] =
+{
+ { 0, 0 }, { 21600, 0 },
+ { 0, 0 MSO_I }, { 3500, 3 MSO_I }, { 7300, 21600 }, { 10800, 21600 }, { 14300, 21600 }, { 18100, 3 MSO_I }, { 21600, 0 MSO_I }
+};
+static const SvxMSDffCalculationData mso_sptTextInflateBottomCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 400
+ { 0x2000, { 0x400, 0, 11150 } }, // 401 0->10450
+ { 0x2001, { 0x401, 3900, 10450 } }, // 402
+ { 0x2000, { 0x402, 17700, 0 } } // 403
+};
+static const sal_uInt16 mso_sptTextInflateBottomSegm[] =
+{
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x2002, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextInflateBottomHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 11150, 21600 }
+};
+static const sal_Int32 mso_sptTextInflateBottomDefault[] =
+{
+ 1, 14700
+};
+static const mso_CustomShape msoTextInflateBottom =
+{
+ (SvxMSDffVertPair*)mso_sptTextInflateBottomVert, sizeof( mso_sptTextInflateBottomVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextInflateBottomSegm, sizeof( mso_sptTextInflateBottomSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextInflateBottomCalc, sizeof( mso_sptTextInflateBottomCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextInflateBottomDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextInflateBottomHandle, sizeof( mso_sptTextInflateBottomHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextDeflateBottomVert[] =
+{
+ { 0, 0 }, { 21600, 0 },
+ { 0, 21600 }, { 2900, 3 MSO_I }, { 7200, 0 MSO_I }, { 10800, 0 MSO_I }, { 14400, 0 MSO_I }, { 18700, 3 MSO_I }, { 21600, 21600 }
+};
+static const SvxMSDffCalculationData mso_sptTextDeflateBottomCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 400
+ { 0x2000, { 0x400, 0, 1350 } }, // 401 0->20250
+ { 0x2001, { 0x401, 12070, 20250 } }, // 402
+ { 0x2000, { 0x402, 9530, 0 } } // 403
+};
+static const sal_uInt16 mso_sptTextDeflateBottomSegm[] =
+{
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x2002, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextDeflateBottomHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 1350, 21600 }
+};
+static const sal_Int32 mso_sptTextDeflateBottomDefault[] =
+{
+ 1, 11500
+};
+static const mso_CustomShape msoTextDeflateBottom =
+{
+ (SvxMSDffVertPair*)mso_sptTextDeflateBottomVert, sizeof( mso_sptTextDeflateBottomVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextDeflateBottomSegm, sizeof( mso_sptTextDeflateBottomSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextDeflateBottomCalc, sizeof( mso_sptTextDeflateBottomCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextDeflateBottomDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextDeflateBottomHandle, sizeof( mso_sptTextDeflateBottomHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextInflateTopVert[] =
+{
+ { 0, 0 MSO_I }, { 3500, 1 MSO_I }, { 7300, 0 }, { 10800, 0 }, { 14300, 0 }, { 18100, 1 MSO_I }, { 21600, 0 MSO_I },
+ { 0, 21600 }, { 21600, 21600 }
+};
+static const SvxMSDffCalculationData mso_sptTextInflateTopCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 400
+ { 0x2001, { 0x400, 3900, 10450 } } // 401
+};
+static const sal_uInt16 mso_sptTextInflateTopSegm[] =
+{
+ 0x4000, 0x2002, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextInflateTopHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 10450 }
+};
+static const sal_Int32 mso_sptTextInflateTopDefault[] =
+{
+ 1, 6900
+};
+static const mso_CustomShape msoTextInflateTop =
+{
+ (SvxMSDffVertPair*)mso_sptTextInflateTopVert, sizeof( mso_sptTextInflateTopVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextInflateTopSegm, sizeof( mso_sptTextInflateTopSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextInflateTopCalc, sizeof( mso_sptTextInflateTopCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextInflateTopDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextInflateTopHandle, sizeof( mso_sptTextInflateTopHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextDeflateTopVert[] =
+{
+ { 0, 0 }, { 2900, 1 MSO_I }, { 7200, 0 MSO_I }, { 10800, 0 MSO_I }, { 14400, 0 MSO_I }, { 18700, 1 MSO_I }, { 21600, 0 },
+ { 0, 21600 }, { 21600, 21600 }
+};
+static const SvxMSDffCalculationData mso_sptTextDeflateTopCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 400
+ { 0x2001, { 0x400, 12070, 20250 } } // 402
+};
+static const sal_uInt16 mso_sptTextDeflateTopSegm[] =
+{
+ 0x4000, 0x2002, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextDeflateTopHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 0, 20250 }
+};
+static const sal_Int32 mso_sptTextDeflateTopDefault[] =
+{
+ 1, 10100
+};
+static const mso_CustomShape msoTextDeflateTop =
+{
+ (SvxMSDffVertPair*)mso_sptTextDeflateTopVert, sizeof( mso_sptTextDeflateTopVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextDeflateTopSegm, sizeof( mso_sptTextDeflateTopSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextDeflateTopCalc, sizeof( mso_sptTextDeflateTopCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextDeflateTopDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextDeflateTopHandle, sizeof( mso_sptTextDeflateTopHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextDeflateInflateVert[] =
+{
+ { 0, 0 }, { 21600, 0 },
+ { 0, 10100 }, { 3300, 3 MSO_I }, { 7100, 5 MSO_I }, { 10800, 5 MSO_I }, { 14500, 5 MSO_I }, { 18300, 3 MSO_I }, { 21600, 10100 },
+ { 0, 11500 }, { 3300, 4 MSO_I }, { 7100, 6 MSO_I }, { 10800, 6 MSO_I }, { 14500, 6 MSO_I }, { 18300, 4 MSO_I }, { 21600, 11500 },
+ { 0, 21600 }, { 21600, 21600 }
+};
+static const SvxMSDffCalculationData mso_sptTextDeflateInflateCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }, // 400
+ { 0x8000, { 10800, 0, 0x400 } }, // 401
+ { 0x2001, { 0x401, 5770, 9500 } }, // 402
+ { 0x8000, { 10100, 0, 0x402 } }, // 403
+ { 0x8000, { 11500, 0, 0x402 } }, // 404
+ { 0x2000, { 0x400, 0, 700 } }, // 405
+ { 0x2000, { 0x400, 700, 0 } } // 406
+};
+static const sal_uInt16 mso_sptTextDeflateInflateSegm[] =
+{
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x2002, 0x8000,
+ 0x4000, 0x2002, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextDeflateInflateHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 1300, 20300 }
+};
+static const sal_Int32 mso_sptTextDeflateInflateDefault[] =
+{
+ 1, 6500
+};
+static const mso_CustomShape msoTextDeflateInflate =
+{
+ (SvxMSDffVertPair*)mso_sptTextDeflateInflateVert, sizeof( mso_sptTextDeflateInflateVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextDeflateInflateSegm, sizeof( mso_sptTextDeflateInflateSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextDeflateInflateCalc, sizeof( mso_sptTextDeflateInflateCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextDeflateInflateDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextDeflateInflateHandle, sizeof( mso_sptTextDeflateInflateHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextDeflateInflateDeflateVert[] =
+{
+ { 0, 0 }, { 21600, 0 },
+ { 0, 6600 }, { 3600, 3 MSO_I }, { 7250, 4 MSO_I }, { 10800, 4 MSO_I }, { 14350, 4 MSO_I }, { 18000, 3 MSO_I }, { 21600, 6600 },
+ { 0, 7500 }, { 3600, 5 MSO_I }, { 7250, 6 MSO_I }, { 10800, 6 MSO_I }, { 14350, 6 MSO_I }, { 18000, 5 MSO_I }, { 21600, 7500 },
+ { 0, 14100 }, { 3600, 9 MSO_I }, { 7250, 10 MSO_I }, { 10800, 10 MSO_I }, { 14350, 10 MSO_I }, { 18000, 9 MSO_I }, { 21600, 14100 },
+ { 0, 15000 }, { 3600, 7 MSO_I }, { 7250, 8 MSO_I }, { 10800, 8 MSO_I }, { 14350, 8 MSO_I }, { 18000, 7 MSO_I }, { 21600, 15000 },
+ { 0, 21600 }, { 21600, 21600 }
+};
+static const SvxMSDffCalculationData mso_sptTextDeflateInflateDeflateCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 850 } }, // 400
+ { 0x2001, { 0x400, 6120, 8700 } },
+ { 0x2000, { 0x401, 0, 4280 } },
+ { 0x4000, { 6600, 0x402, 0 } },
+ { 0x2000, { DFF_Prop_adjustValue, 0, 450 } }, // 404
+ { 0x2000, { 0x403, 900, 0 } }, // 405
+ { 0x2000, { 0x404, 900, 0 } }, // 406
+ { 0x8000, { 21600, 0, 0x403 } }, // 407
+ { 0x8000, { 21600, 0, 0x404 } }, // 408
+ { 0x8000, { 21600, 0, 0x405 } }, // 409
+ { 0x8000, { 21600, 0, 0x406 } } // 410
+};
+static const sal_uInt16 mso_sptTextDeflateInflateDeflateSegm[] =
+{
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x2002, 0x8000,
+ 0x4000, 0x2002, 0x8000,
+ 0x4000, 0x2002, 0x8000,
+ 0x4000, 0x2002, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffHandle mso_sptTextDeflateInflateDeflateHandle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 10800, 0x100, 10800, 10800, 0x80000000, 0x7fffffff, 850, 9550 }
+};
+static const sal_Int32 mso_sptTextDeflateInflateDeflateDefault[] =
+{
+ 1, 6050
+};
+static const mso_CustomShape msoTextDeflateInflateDeflate =
+{
+ (SvxMSDffVertPair*)mso_sptTextDeflateInflateDeflateVert, sizeof( mso_sptTextDeflateInflateDeflateVert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextDeflateInflateDeflateSegm, sizeof( mso_sptTextDeflateInflateDeflateSegm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptTextDeflateInflateDeflateCalc, sizeof( mso_sptTextDeflateInflateDeflateCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptTextDeflateInflateDeflateDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptTextDeflateInflateDeflateHandle, sizeof( mso_sptTextDeflateInflateDeflateHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextWave1Vert[] = // adjustment1 : 0 - 4459
+{ // adjustment2 : 8640 - 12960
+ { 7 MSO_I, 0 MSO_I }, { 15 MSO_I, 9 MSO_I }, { 16 MSO_I, 10 MSO_I }, { 12 MSO_I, 0 MSO_I },
+ { 29 MSO_I, 1 MSO_I }, { 27 MSO_I, 28 MSO_I }, { 25 MSO_I, 26 MSO_I }, { 24 MSO_I, 1 MSO_I }
+};
+static const sal_uInt16 mso_sptTextWave1Segm[] =
+{
+ 0x4000, 0x2001, 0x8000,
+ 0x4000, 0x2001, 0x8000
+};
+static const mso_CustomShape msoTextWave1 =
+{
+ (SvxMSDffVertPair*)mso_sptTextWave1Vert, sizeof( mso_sptTextWave1Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextWave1Segm, sizeof( mso_sptTextWave1Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptWaveCalc, sizeof( mso_sptWaveCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptWaveDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptWaveGluePoints, sizeof( mso_sptWaveGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptWaveHandle, sizeof( mso_sptWaveHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextWave2Vert[] = // adjustment1 : 0 - 4459
+{ // adjustment2 : 8640 - 12960
+ { 7 MSO_I, 0 MSO_I }, { 15 MSO_I, 10 MSO_I }, { 16 MSO_I, 9 MSO_I }, { 12 MSO_I, 0 MSO_I },
+ { 29 MSO_I, 1 MSO_I }, { 27 MSO_I, 26 MSO_I }, { 25 MSO_I, 28 MSO_I }, { 24 MSO_I, 1 MSO_I }
+};
+static const mso_CustomShape msoTextWave2 =
+{
+ (SvxMSDffVertPair*)mso_sptTextWave2Vert, sizeof( mso_sptTextWave2Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextWave1Segm, sizeof( mso_sptTextWave1Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptWaveCalc, sizeof( mso_sptWaveCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptWaveDefault,
+ (SvxMSDffTextRectangles*)mso_sptFontWorkTextRect, sizeof( mso_sptFontWorkTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptWaveGluePoints, sizeof( mso_sptWaveGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptWaveHandle, sizeof( mso_sptWaveHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextWave3Vert[] = // adjustment1 : 0 - 2230
+{ // adjustment2 : 8640 - 12960
+ { 7 MSO_I, 0 MSO_I }, { 15 MSO_I, 9 MSO_I }, { 0x1e MSO_I, 10 MSO_I }, { 0x12 MSO_I, 0 MSO_I }, { 0x1f MSO_I, 9 MSO_I }, { 16 MSO_I, 10 MSO_I }, { 12 MSO_I, 0 MSO_I },
+ { 29 MSO_I, 1 MSO_I }, { 27 MSO_I, 28 MSO_I }, { 0x20 MSO_I, 26 MSO_I }, { 0x13 MSO_I, 1 MSO_I }, { 0x21 MSO_I, 28 MSO_I }, { 25 MSO_I, 26 MSO_I }, { 24 MSO_I, 1 MSO_I }
+};
+static const sal_uInt16 mso_sptTextWave3Segm[] =
+{
+ 0x4000, 0x2002, 0x8000,
+ 0x4000, 0x2002, 0x8000
+};
+static const mso_CustomShape msoTextWave3 =
+{
+ (SvxMSDffVertPair*)mso_sptTextWave3Vert, sizeof( mso_sptTextWave3Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextWave3Segm, sizeof( mso_sptTextWave3Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptDoubleWaveCalc, sizeof( mso_sptDoubleWaveCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDoubleWaveDefault,
+ (SvxMSDffTextRectangles*)mso_sptDoubleWaveTextRect, sizeof( mso_sptDoubleWaveTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptDoubleWaveGluePoints, sizeof( mso_sptDoubleWaveGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptDoubleWaveHandle, sizeof( mso_sptDoubleWaveHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptTextWave4Vert[] = // adjustment1 : 0 - 2230
+{ // adjustment2 : 8640 - 12960
+ { 7 MSO_I, 0 MSO_I }, { 15 MSO_I, 10 MSO_I }, { 0x1e MSO_I, 9 MSO_I }, { 0x12 MSO_I, 0 MSO_I }, { 0x1f MSO_I, 10 MSO_I }, { 16 MSO_I, 9 MSO_I }, { 12 MSO_I, 0 MSO_I },
+ { 29 MSO_I, 1 MSO_I }, { 27 MSO_I, 26 MSO_I }, { 0x20 MSO_I, 28 MSO_I }, { 0x13 MSO_I, 1 MSO_I }, { 0x21 MSO_I, 26 MSO_I }, { 25 MSO_I, 28 MSO_I }, { 24 MSO_I, 1 MSO_I }
+};
+static const mso_CustomShape msoTextWave4 =
+{
+ (SvxMSDffVertPair*)mso_sptTextWave4Vert, sizeof( mso_sptTextWave4Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptTextWave3Segm, sizeof( mso_sptTextWave3Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptDoubleWaveCalc, sizeof( mso_sptDoubleWaveCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptDoubleWaveDefault,
+ (SvxMSDffTextRectangles*)mso_sptDoubleWaveTextRect, sizeof( mso_sptDoubleWaveTextRect ) / sizeof( SvxMSDffTextRectangles ),
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ (SvxMSDffVertPair*)mso_sptDoubleWaveGluePoints, sizeof( mso_sptDoubleWaveGluePoints ) / sizeof( SvxMSDffVertPair ),
+ (SvxMSDffHandle*)mso_sptDoubleWaveHandle, sizeof( mso_sptDoubleWaveHandle ) / sizeof( SvxMSDffHandle )
+};
+
+static const sal_Int32 mso_sptCalloutDefault1[] =
+{
+ 4, -1800, 24500, -1800, 4000
+};
+static const sal_Int32 mso_sptCalloutDefault2[] =
+{
+ 4, -8300, 24500, -1800, 4000
+};
+static const sal_Int32 mso_sptCalloutDefault3[] =
+{
+ 6, -10000, 24500, -3600, 4000, -1800, 4000
+};
+static const sal_Int32 mso_sptCalloutDefault4[] =
+{
+ 8, 23400, 24500, 25200, 21600, 25200, 4000, 23400, 4000
+};
+static const SvxMSDffVertPair mso_sptCalloutVert1[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 }, { 0 MSO_I, 1 MSO_I }, { 2 MSO_I, 3 MSO_I }
+};
+static const SvxMSDffHandle mso_sptCalloutHandle1[] =
+{
+ { 0,
+ 0x100, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff },
+ { 0,
+ 0x102, 0x103, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff }
+};
+static const sal_uInt16 mso_sptCalloutSegm1a[] =
+{
+ 0x4000, 0x0003, 0x6000, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const sal_uInt16 mso_sptCalloutSegm1b[] =
+{
+ 0x4000, 0xab00, 0x0003, 0x6000, 0x8000, // NO STROKE
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffVertPair mso_sptCallout1Vert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 }, { 0 MSO_I, 1 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 2 MSO_I, 0 }, { 2 MSO_I, 21600 }
+};
+static const sal_uInt16 mso_sptCallout1Segm1a[] =
+{
+ 0x4000, 0x0003, 0x6000, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const sal_uInt16 mso_sptCallout1Segm1b[] =
+{
+ 0x4000, 0xab00, 0x0003, 0x6000, 0x8000, // NO STROKE
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffVertPair mso_sptCallout2Verta[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 }, { 0 MSO_I, 1 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 4 MSO_I, 5 MSO_I }
+};
+static const SvxMSDffVertPair mso_sptCallout2Vertb[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 }, { 0 MSO_I, 1 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 4 MSO_I, 5 MSO_I }, { 4 MSO_I, 0 }, { 4 MSO_I, 21600 }
+};
+static const SvxMSDffHandle mso_sptCalloutHandle2[] =
+{
+ { 0,
+ 0x100, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff },
+ { 0,
+ 0x102, 0x103, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff },
+ { 0,
+ 0x104, 0x105, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff }
+};
+static const sal_uInt16 mso_sptCallout2Segm1a[] =
+{
+ 0x4000, 0x0003, 0x6000, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const sal_uInt16 mso_sptCallout2Segm1b[] =
+{
+ 0x4000, 0xab00, 0x0003, 0x6000, 0x8000, // NO STROKE
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const sal_uInt16 mso_sptCallout2Segm1c[] =
+{
+ 0x4000, 0x0003, 0x6000, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const sal_uInt16 mso_sptCallout2Segm1d[] =
+{
+ 0x4000, 0xab00, 0x0003, 0x6000, 0x8000, // NO STROKE
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000,
+ 0x4000, 0x0001, 0x8000
+};
+static const SvxMSDffVertPair mso_sptCallout3Verta[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 }, { 6 MSO_I, 7 MSO_I }, { 4 MSO_I, 5 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 0 MSO_I, 1 MSO_I }
+};
+static const SvxMSDffVertPair mso_sptCallout3Vertb[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }, { 0, 21600 }, { 6 MSO_I, 7 MSO_I }, { 4 MSO_I, 5 MSO_I }, { 2 MSO_I, 3 MSO_I }, { 0 MSO_I, 1 MSO_I }, { 6 MSO_I, 0 }, { 6 MSO_I, 21600 }
+};
+static const SvxMSDffHandle mso_sptCalloutHandle3[] =
+{
+ { 0,
+ 0x100, 0x101, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff },
+ { 0,
+ 0x102, 0x103, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff },
+ { 0,
+ 0x104, 0x105, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff },
+ { 0,
+ 0x106, 0x107, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff }
+};
+static const sal_uInt16 mso_sptCallout3Segm1a[] =
+{
+ 0x4000, 0x0003, 0x6000, 0x8000,
+ 0x4000, 0xaa00, 0x0003, 0x8000 // NO_FILL
+};
+static const sal_uInt16 mso_sptCallout3Segm1b[] =
+{
+ 0x4000, 0xab00, 0x0003, 0x6000, 0x8000, // NO STROKE
+ 0x4000, 0xaa00, 0x0003, 0x8000 // NO FILL
+};
+static const sal_uInt16 mso_sptCallout3Segm1c[] =
+{
+ 0x4000, 0x0003, 0x6000, 0x8000,
+ 0x4000, 0xaa00, 0x0003, 0x8000, // NO FILL
+ 0x4000, 0x0001, 0x8000
+};
+static const sal_uInt16 mso_sptCallout3Segm1d[] =
+{
+ 0x4000, 0xab00, 0x0003, 0x6000, 0x8000, // NO STROKE
+ 0x4000, 0xaa00, 0x0003, 0x8000, // NO FILL
+ 0x4000, 0x0001, 0x8000
+};
+
+static const SvxMSDffCalculationData mso_sptCalloutCalc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust4Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust5Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust6Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust7Value, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust8Value, 0, 0 } }
+};
+
+static const mso_CustomShape msoCallout90 =
+{
+ (SvxMSDffVertPair*)mso_sptCalloutVert1, sizeof( mso_sptCalloutVert1 ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCalloutSegm1b, sizeof( mso_sptCalloutSegm1b ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault1,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle1, sizeof( mso_sptCalloutHandle1 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoCallout1 =
+{
+ (SvxMSDffVertPair*)mso_sptCalloutVert1, sizeof( mso_sptCalloutVert1 ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCalloutSegm1b, sizeof( mso_sptCalloutSegm1b ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault2,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle1, sizeof( mso_sptCalloutHandle1 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoCallout2 =
+{
+ (SvxMSDffVertPair*)mso_sptCallout2Verta, sizeof( mso_sptCallout2Verta ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCallout2Segm1b, sizeof( mso_sptCallout2Segm1b ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault3,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle2, sizeof( mso_sptCalloutHandle2 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoCallout3 =
+{
+ (SvxMSDffVertPair*)mso_sptCallout3Verta, sizeof( mso_sptCallout3Verta ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCallout3Segm1b, sizeof( mso_sptCallout3Segm1b ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault4,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle3, sizeof( mso_sptCalloutHandle3 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoAccentCallout90 =
+{
+ (SvxMSDffVertPair*)mso_sptCalloutVert1, sizeof( mso_sptCalloutVert1 ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCalloutSegm1b, sizeof( mso_sptCalloutSegm1b ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault1,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle1, sizeof( mso_sptCalloutHandle1 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoAccentCallout1 =
+{
+ (SvxMSDffVertPair*)mso_sptCallout1Vert, sizeof( mso_sptCallout1Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCallout1Segm1b, sizeof( mso_sptCallout1Segm1b ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault2,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle1, sizeof( mso_sptCalloutHandle1 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoAccentCallout2 =
+{
+ (SvxMSDffVertPair*)mso_sptCallout2Vertb, sizeof( mso_sptCallout2Vertb ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCallout2Segm1d, sizeof( mso_sptCallout2Segm1d ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault3,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle2, sizeof( mso_sptCalloutHandle2 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoAccentCallout3 =
+{
+ (SvxMSDffVertPair*)mso_sptCallout3Vertb, sizeof( mso_sptCallout3Vertb ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCallout3Segm1d, sizeof( mso_sptCallout3Segm1d ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault4,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle3, sizeof( mso_sptCalloutHandle3 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoBorderCallout90 =
+{
+ (SvxMSDffVertPair*)mso_sptCalloutVert1, sizeof( mso_sptCalloutVert1 ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCalloutSegm1a, sizeof( mso_sptCalloutSegm1a ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault1,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle1, sizeof( mso_sptCalloutHandle1 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoBorderCallout1 =
+{
+ (SvxMSDffVertPair*)mso_sptCalloutVert1, sizeof( mso_sptCalloutVert1 ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCalloutSegm1a, sizeof( mso_sptCalloutSegm1a ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault2,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle1, sizeof( mso_sptCalloutHandle1 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoBorderCallout2 =
+{
+ (SvxMSDffVertPair*)mso_sptCallout2Verta, sizeof( mso_sptCallout2Verta ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCallout2Segm1a, sizeof( mso_sptCallout2Segm1a ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault3,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle2, sizeof( mso_sptCalloutHandle2 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoBorderCallout3 =
+{
+ (SvxMSDffVertPair*)mso_sptCallout3Verta, sizeof( mso_sptCallout3Verta ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCallout3Segm1a, sizeof( mso_sptCallout3Segm1a ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault4,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle3, sizeof( mso_sptCalloutHandle3 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoAccentBorderCallout90 =
+{
+ (SvxMSDffVertPair*)mso_sptCalloutVert1, sizeof( mso_sptCalloutVert1 ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCalloutSegm1a, sizeof( mso_sptCalloutSegm1a ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault1,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle1, sizeof( mso_sptCalloutHandle1 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoAccentBorderCallout1 =
+{
+ (SvxMSDffVertPair*)mso_sptCallout1Vert, sizeof( mso_sptCallout1Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCallout1Segm1a, sizeof( mso_sptCallout1Segm1a ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault2,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle1, sizeof( mso_sptCalloutHandle1 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoAccentBorderCallout2 =
+{
+ (SvxMSDffVertPair*)mso_sptCallout2Vertb, sizeof( mso_sptCallout2Vertb ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCallout2Segm1c, sizeof( mso_sptCallout2Segm1c ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault3,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle2, sizeof( mso_sptCalloutHandle2 ) / sizeof( SvxMSDffHandle )
+};
+static const mso_CustomShape msoAccentBorderCallout3 =
+{
+ (SvxMSDffVertPair*)mso_sptCallout3Vertb, sizeof( mso_sptCallout3Vertb ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCallout3Segm1c, sizeof( mso_sptCallout3Segm1c ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCalloutCalc, sizeof( mso_sptCalloutCalc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCalloutDefault4,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCalloutHandle3, sizeof( mso_sptCalloutHandle3 ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptStraightConnector1Vert[] =
+{
+ { 0, 0 }, { 21600, 21600 }
+};
+static const sal_uInt16 mso_sptStraightConnector1Segm[] =
+{
+ 0x4000, 0x0001, 0x8000
+};
+static const mso_CustomShape msoStraightConnector1 =
+{
+ (SvxMSDffVertPair*)mso_sptStraightConnector1Vert, sizeof( mso_sptStraightConnector1Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptStraightConnector1Segm, sizeof( mso_sptStraightConnector1Segm ) >> 1,
+ (SvxMSDffCalculationData*)NULL, 0,
+ (sal_Int32*)NULL,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)NULL, 0
+};
+
+static const SvxMSDffVertPair mso_sptBentConnector2Vert[] =
+{
+ { 0, 0 }, { 21600, 0 }, { 21600, 21600 }
+};
+static const sal_uInt16 mso_sptBentConnector2Segm[] =
+{
+ 0x4000, 0x0002, 0x8000
+};
+static const mso_CustomShape msoBentConnector2 =
+{
+ (SvxMSDffVertPair*)mso_sptBentConnector2Vert, sizeof( mso_sptBentConnector2Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBentConnector2Segm, sizeof( mso_sptBentConnector2Segm ) >> 1,
+ (SvxMSDffCalculationData*)NULL, 0,
+ (sal_Int32*)NULL,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)NULL, 0
+};
+
+static const SvxMSDffVertPair mso_sptBentConnector3Vert[] =
+{
+ { 0, 0 }, { 0 MSO_I, 0 }, { 0 MSO_I, 21600 }, { 21600, 21600 }
+};
+static const sal_uInt16 mso_sptBentConnector3Segm[] =
+{
+ 0x4000, 0x0003, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptBentConnector3Calc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } }
+};
+static const sal_Int32 mso_sptBentConnector3Default[] =
+{
+ 1, 10800
+};
+static const SvxMSDffHandle mso_sptBentConnector3Handle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 10800, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoBentConnector3 =
+{
+ (SvxMSDffVertPair*)mso_sptBentConnector3Vert, sizeof( mso_sptBentConnector3Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBentConnector3Segm, sizeof( mso_sptBentConnector3Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBentConnector3Calc, sizeof( mso_sptBentConnector3Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptBentConnector3Default,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptBentConnector3Handle, sizeof( mso_sptBentConnector3Handle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptBentConnector4Vert[] =
+{
+ { 0, 0 }, { 0 MSO_I, 0 }, { 0 MSO_I, 1 MSO_I }, { 21600, 1 MSO_I }, { 21600, 21600 }
+};
+static const sal_uInt16 mso_sptBentConnector4Segm[] =
+{
+ 0x4000, 0x0004, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptBentConnector4Calc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2000, { 0x400, 21600, 0 } },
+ { 0x2001, { 0x402, 1, 2 } },
+ { 0x2001, { 0x401, 1, 2 } }
+};
+static const sal_Int32 mso_sptBentConnector4Default[] =
+{
+ 2, 10800, 10800
+};
+static const SvxMSDffHandle mso_sptBentConnector4Handle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0x100, 4 + 3, 10800, 10800, 0x80000000, 0x7fffffff, 4 + 3, 4 + 3 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 3 + 3, 0x101, 10800, 10800, 3 + 3, 3 + 3, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoBentConnector4 =
+{
+ (SvxMSDffVertPair*)mso_sptBentConnector4Vert, sizeof( mso_sptBentConnector4Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBentConnector4Segm, sizeof( mso_sptBentConnector4Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBentConnector4Calc, sizeof( mso_sptBentConnector4Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptBentConnector4Default,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptBentConnector4Handle, sizeof( mso_sptBentConnector4Handle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptBentConnector5Vert[] =
+{
+ { 0, 0 }, { 0 MSO_I, 0 }, { 0 MSO_I, 4 MSO_I }, { 1 MSO_I, 4 MSO_I }, { 1 MSO_I, 21600 }, { 21600, 21600 }
+};
+static const sal_uInt16 mso_sptBentConnector5Segm[] =
+{
+ 0x4000, 0x0005, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptBentConnector5Calc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x6000, { 0x400, 0x401, 0 } },
+ { 0x2001, { 0x402, 1, 2 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2001, { 0x404, 1, 2 } },
+ { 0x4000, { 21600, 0x404, 0 } },
+ { 0x2001, { 0x406, 1, 2 } }
+};
+static const sal_Int32 mso_sptBentConnector5Default[] =
+{
+ 3, 10800, 10800, 10800
+};
+static const SvxMSDffHandle mso_sptBentConnector5Handle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0x100, 5 + 3, 10800, 10800, 0x80000000, 0x7fffffff, 5 + 3, 5 + 3 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 3 + 3, 0x101, 10800, 10800, 3 + 3, 3 + 3, 0x80000000, 0x7fffffff },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0x102, 7 + 3, 10800, 10800, 0x80000000, 0x7fffffff, 7 + 3, 7 + 3 }
+};
+static const mso_CustomShape msoBentConnector5 =
+{
+ (SvxMSDffVertPair*)mso_sptBentConnector5Vert, sizeof( mso_sptBentConnector5Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptBentConnector5Segm, sizeof( mso_sptBentConnector5Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptBentConnector5Calc, sizeof( mso_sptBentConnector5Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptBentConnector5Default,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptBentConnector5Handle, sizeof( mso_sptBentConnector5Handle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptCurvedConnector2Vert[] =
+{
+ { 0, 0 }, { 10800, 0 }, { 21600, 10800 }, { 21600, 21600 }
+};
+static const sal_uInt16 mso_sptCurvedConnector2Segm[] =
+{
+ 0x4000, 0x2001, 0x8000
+};
+static const mso_CustomShape msoCurvedConnector2 =
+{
+ (SvxMSDffVertPair*)mso_sptCurvedConnector2Vert, sizeof( mso_sptCurvedConnector2Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCurvedConnector2Segm, sizeof( mso_sptCurvedConnector2Segm ) >> 1,
+ (SvxMSDffCalculationData*)NULL, 0,
+ (sal_Int32*)NULL,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)NULL, 0
+};
+
+static const SvxMSDffVertPair mso_sptCurvedConnector3Vert[] =
+{
+ { 0, 0 }, { 1 MSO_I, 0 }, { 0 MSO_I, 5400 }, { 0 MSO_I, 10800 }, { 0 MSO_I, 16200 }, { 3 MSO_I, 21600 }, { 21600, 21600 }
+};
+static const sal_uInt16 mso_sptCurvedConnector3Segm[] =
+{
+ 0x4000, 0x2002, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCurvedConnector3Calc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2001, { 0x400, 1, 2 } },
+ { 0x2000, { 0x400, 21600, 0 } },
+ { 0x2001, { 0x402, 1, 2 } }
+};
+static const sal_Int32 mso_sptCurvedConnector3Default[] =
+{
+ 1, 10800
+};
+static const SvxMSDffHandle mso_sptCurvedConnector3Handle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE,
+ 0x100, 10800, 10800, 10800, 0x80000000, 0x7fffffff, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoCurvedConnector3 =
+{
+ (SvxMSDffVertPair*)mso_sptCurvedConnector3Vert, sizeof( mso_sptCurvedConnector3Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCurvedConnector3Segm, sizeof( mso_sptCurvedConnector3Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCurvedConnector3Calc, sizeof( mso_sptCurvedConnector3Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCurvedConnector3Default,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCurvedConnector3Handle, sizeof( mso_sptCurvedConnector3Handle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptCurvedConnector4Vert[] =
+{
+ { 0, 0 }, { 1 MSO_I, 0 }, { 0 MSO_I, 10 MSO_I }, { 0 MSO_I, 9 MSO_I },
+ { 0 MSO_I, 12 MSO_I }, { 5 MSO_I, 8 MSO_I }, { 3 MSO_I, 8 MSO_I },
+ { 7 MSO_I, 8 MSO_I }, { 21600, 14 MSO_I }, { 21600, 21600 }
+
+};
+static const sal_uInt16 mso_sptCurvedConnector4Segm[] =
+{
+ 0x4000, 0x2003, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCurvedConnector4Calc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2001, { 0x400, 1, 2 } },
+ { 0x4000, { 21600, 0x400, 0 } },
+ { 0x2001, { 0x402, 1, 2 } },
+ { 0x6000, { 0x400, 0x403, 0 } },
+ { 0x2001, { 0x404, 1, 2 } },
+ { 0x2000, { 0x403, 21600, 0 } },
+ { 0x2001, { 0x406, 1, 2 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x2001, { DFF_Prop_adjust2Value, 1, 2 } },
+ { 0x2001, { DFF_Prop_adjust2Value, 1, 4 } },
+ { 0x6000, { 0x408, 0x409, 0 } },
+ { 0x2001, { 0x40b, 1, 2 } },
+ { 0x2000, { 0x408, 21600, 0 } },
+ { 0x2001, { 0x40d, 1, 2 } }
+};
+static const sal_Int32 mso_sptCurvedConnector4Default[] =
+{
+ 2, 10800, 10800
+};
+static const SvxMSDffHandle mso_sptCurvedConnector4Handle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0x100, 9 + 3, 10800, 10800, 0x80000000, 0x7fffffff, 9 + 3, 9 + 3 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 3 + 3, 0x101, 10800, 10800, 3 + 3, 3 + 3, 0x80000000, 0x7fffffff }
+};
+static const mso_CustomShape msoCurvedConnector4 =
+{
+ (SvxMSDffVertPair*)mso_sptCurvedConnector4Vert, sizeof( mso_sptCurvedConnector4Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCurvedConnector4Segm, sizeof( mso_sptCurvedConnector4Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCurvedConnector4Calc, sizeof( mso_sptCurvedConnector4Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCurvedConnector4Default,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCurvedConnector4Handle, sizeof( mso_sptCurvedConnector4Handle ) / sizeof( SvxMSDffHandle )
+};
+
+static const SvxMSDffVertPair mso_sptCurvedConnector5Vert[] =
+{
+ { 0, 0 },
+ { 21 MSO_I, 0 }, { 0 MSO_I, 12 MSO_I }, { 0 MSO_I, 11 MSO_I },
+ { 0 MSO_I, 14 MSO_I }, { 6 MSO_I, 4 MSO_I }, { 3 MSO_I, 4 MSO_I },
+ { 8 MSO_I, 4 MSO_I }, { 1 MSO_I, 18 MSO_I }, { 1 MSO_I, 16 MSO_I },
+ { 1 MSO_I, 20 MSO_I }, { 10 MSO_I, 21600 }, { 21600, 21600 }
+};
+static const sal_uInt16 mso_sptCurvedConnector5Segm[] =
+{
+ 0x4000, 0x2004, 0x8000
+};
+static const SvxMSDffCalculationData mso_sptCurvedConnector5Calc[] =
+{
+ { 0x2000, { DFF_Prop_adjustValue, 0, 0 } },
+ { 0x2000, { DFF_Prop_adjust3Value, 0, 0 } },
+ { 0x6000, { 0x400, 0x401, 0 } },
+ { 0x2001, { 0x402, 1, 2 } },
+ { 0x2000, { DFF_Prop_adjust2Value, 0, 0 } },
+ { 0x6000, { 0x400, 0x403, 0 } },
+ { 0x2001, { 0x405, 1, 2 } },
+ { 0x6000, { 0x401, 0x403, 0 } },
+ { 0x2001, { 0x407, 1, 2 } },
+ { 0x2000, { 0x401, 21600, 0 } },
+ { 0x2001, { 0x409, 1, 2 } },
+ { 0x2001, { 0x404, 1, 2 } },
+ { 0x2001, { 0x40b, 1, 2 } },
+ { 0x6000, { 0x404, 0x40b, 0 } },
+ { 0x2001, { 0x40d, 1, 2 } },
+ { 0x2000, { 0x404, 21600, 0 } },
+ { 0x2001, { 0x40f, 1, 2 } },
+ { 0x6000, { 0x404, 0x410, 0 } },
+ { 0x2001, { 0x411, 1, 2 } },
+ { 0x2000, { 0x410, 21600, 0 } },
+ { 0x2001, { 0x413, 1, 2 } },
+ { 0x2001, { 0x400, 1, 2 } }
+};
+static const sal_Int32 mso_sptCurvedConnector5Default[] =
+{
+ 3, 10800, 10800, 10800
+};
+static const SvxMSDffHandle mso_sptCurvedConnector5Handle[] =
+{
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0x100, 11 + 3, 10800, 10800, 0x80000000, 0x7fffffff, 11 + 3, 11 + 3 },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL,
+ 3 + 3, 0x101, 10800, 10800, 3 + 3, 3 + 3, 0x80000000, 0x7fffffff },
+ { MSDFF_HANDLE_FLAGS_RANGE | MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL | MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL,
+ 0x102, 16 + 3, 10800, 10800, 0x80000000, 0x7fffffff, 16 + 3, 16 + 3 }
+};
+static const mso_CustomShape msoCurvedConnector5 =
+{
+ (SvxMSDffVertPair*)mso_sptCurvedConnector5Vert, sizeof( mso_sptCurvedConnector5Vert ) / sizeof( SvxMSDffVertPair ),
+ (sal_uInt16*)mso_sptCurvedConnector5Segm, sizeof( mso_sptCurvedConnector5Segm ) >> 1,
+ (SvxMSDffCalculationData*)mso_sptCurvedConnector5Calc, sizeof( mso_sptCurvedConnector5Calc ) / sizeof( SvxMSDffCalculationData ),
+ (sal_Int32*)mso_sptCurvedConnector5Default,
+ NULL, 0,
+ 21600, 21600,
+ 0x80000000, 0x80000000,
+ NULL, 0,
+ (SvxMSDffHandle*)mso_sptCurvedConnector5Handle, sizeof( mso_sptCurvedConnector5Handle ) / sizeof( SvxMSDffHandle )
+};
+
+const mso_CustomShape* GetCustomShapeContent( MSO_SPT eSpType )
+{
+ const mso_CustomShape* pCustomShape = NULL;
+ switch( eSpType )
+ {
+ case mso_sptArc : pCustomShape = &msoArc; break;
+ case mso_sptRectangle : pCustomShape = &msoRectangle; break;
+ case mso_sptParallelogram : pCustomShape = &msoParallelogram; break;
+ case mso_sptTrapezoid : pCustomShape = &msoTrapezoid; break;
+ case mso_sptDiamond : pCustomShape = &msoDiamond; break;
+ case mso_sptRoundRectangle : pCustomShape = &msoRoundRectangle; break;
+ case mso_sptOctagon : pCustomShape = &msoOctagon; break;
+ case mso_sptIsocelesTriangle : pCustomShape = &msoIsocelesTriangle; break;
+ case mso_sptRightTriangle : pCustomShape = &msoRightTriangle; break;
+ case mso_sptEllipse : pCustomShape = &msoEllipse; break;
+ case mso_sptHexagon : pCustomShape = &msoHexagon; break;
+ case mso_sptPlus : pCustomShape = &msoPlus; break;
+ case mso_sptPentagon : pCustomShape = &msoPentagon; break;
+ case mso_sptCan : pCustomShape = &msoCan; break;
+ case mso_sptCube : pCustomShape = &msoCube; break;
+ case mso_sptBalloon : pCustomShape = &msoBalloon; break;
+ case mso_sptActionButtonBlank : pCustomShape = &msoActionButtonBlank; break;
+ case mso_sptActionButtonHome : pCustomShape = &msoActionButtonHome; break;
+ case mso_sptActionButtonHelp : pCustomShape = &msoActionButtonHelp; break;
+ case mso_sptActionButtonInformation : pCustomShape = &msoActionButtonInformation; break;
+ case mso_sptActionButtonBackPrevious : pCustomShape = &msoActionButtonBackPrevious; break;
+ case mso_sptActionButtonForwardNext : pCustomShape = &msoActionButtonForwardNext; break;
+ case mso_sptActionButtonBeginning : pCustomShape = &msoActionButtonBeginning; break;
+ case mso_sptActionButtonEnd : pCustomShape = &msoActionButtonEnd; break;
+ case mso_sptActionButtonReturn : pCustomShape = &msoActionButtonReturn; break;
+ case mso_sptActionButtonDocument : pCustomShape = &msoActionButtonDocument; break;
+ case mso_sptActionButtonSound : pCustomShape = &msoActionButtonSound; break;
+ case mso_sptActionButtonMovie : pCustomShape = &msoActionButtonMovie; break;
+ case mso_sptBevel : pCustomShape = &msoBevel; break;
+ case mso_sptFoldedCorner : pCustomShape = &msoFoldedCorner; break;
+ case mso_sptSmileyFace : pCustomShape = &msoSmileyFace; break;
+ case mso_sptDonut : pCustomShape = &msoDonut; break;
+ case mso_sptNoSmoking : pCustomShape = &msoNoSmoking; break;
+ case mso_sptBlockArc : pCustomShape = &msoBlockArc; break;
+ case mso_sptHeart : pCustomShape = &msoHeart; break;
+ case mso_sptLightningBolt : pCustomShape = &msoLightningBold; break;
+ case mso_sptSun : pCustomShape = &msoSun; break;
+ case mso_sptMoon : pCustomShape = &msoMoon; break;
+ case mso_sptBracketPair : pCustomShape = &msoBracketPair; break;
+ case mso_sptBracePair : pCustomShape = &msoBracePair; break;
+ case mso_sptPlaque : pCustomShape = &msoPlaque; break;
+ case mso_sptLeftBracket : pCustomShape = &msoLeftBracket; break;
+ case mso_sptRightBracket : pCustomShape = &msoRightBracket; break;
+ case mso_sptLeftBrace : pCustomShape = &msoLeftBrace; break;
+ case mso_sptRightBrace : pCustomShape = &msoRightBrace; break;
+ case mso_sptArrow : pCustomShape = &msoArrow; break;
+ case mso_sptUpArrow : pCustomShape = &msoUpArrow; break;
+ case mso_sptDownArrow : pCustomShape = &msoDownArrow; break;
+ case mso_sptLeftArrow : pCustomShape = &msoLeftArrow; break;
+ case mso_sptLeftRightArrow : pCustomShape = &msoLeftRightArrow; break;
+ case mso_sptUpDownArrow : pCustomShape = &msoUpDownArrow; break;
+ case mso_sptQuadArrow : pCustomShape = &msoQuadArrow; break;
+ case mso_sptLeftRightUpArrow : pCustomShape = &msoLeftRightUpArrow; break;
+ case mso_sptBentArrow : pCustomShape = &msoBentArrow; break;
+ case mso_sptUturnArrow : pCustomShape = &msoUturnArrow; break;
+ case mso_sptLeftUpArrow : pCustomShape = &msoLeftUpArrow; break;
+ case mso_sptBentUpArrow : pCustomShape = &msoBentUpArrow; break;
+ case mso_sptCurvedRightArrow : pCustomShape = &msoCurvedRightArrow; break;
+ case mso_sptCurvedLeftArrow : pCustomShape = &msoCurvedLeftArrow; break;
+ case mso_sptCurvedUpArrow : pCustomShape = &msoCurvedUpArrow; break;
+ case mso_sptCurvedDownArrow : pCustomShape = &msoCurvedDownArrow; break;
+ case mso_sptStripedRightArrow : pCustomShape = &msoStripedRightArrow; break;
+ case mso_sptNotchedRightArrow : pCustomShape = &msoNotchedRightArrow; break;
+ case mso_sptHomePlate : pCustomShape = &msoHomePlate; break;
+ case mso_sptChevron : pCustomShape = &msoChevron; break;
+ case mso_sptRightArrowCallout : pCustomShape = &msoRightArrowCallout; break;
+ case mso_sptLeftArrowCallout : pCustomShape = &msoLeftArrowCallout; break;
+ case mso_sptUpArrowCallout : pCustomShape = &msoUpArrowCallout; break;
+ case mso_sptDownArrowCallout : pCustomShape = &msoDownArrowCallout; break;
+ case mso_sptLeftRightArrowCallout : pCustomShape = &msoLeftRightArrowCallout; break;
+ case mso_sptUpDownArrowCallout : pCustomShape = &msoUpDownArrowCallout; break;
+ case mso_sptQuadArrowCallout : pCustomShape = &msoQuadArrowCallout; break;
+ case mso_sptCircularArrow : pCustomShape = &msoCircularArrow; break;
+ case mso_sptIrregularSeal1 : pCustomShape = &msoIrregularSeal1; break;
+ case mso_sptIrregularSeal2 : pCustomShape = &msoIrregularSeal2; break;
+ case mso_sptSeal4 : pCustomShape = &msoSeal4; break;
+ case mso_sptStar : pCustomShape = &msoStar; break;
+ case mso_sptSeal8 : pCustomShape = &msoSeal8; break;
+ case mso_sptSeal :
+ case mso_sptSeal16 : pCustomShape = &msoSeal16; break;
+ case mso_sptSeal24 : pCustomShape = &msoSeal24; break;
+ case mso_sptSeal32 : pCustomShape = &msoSeal32; break;
+ case mso_sptRibbon2 : pCustomShape = &msoRibbon2; break;
+ case mso_sptRibbon : pCustomShape = &msoRibbon; break;
+ case mso_sptEllipseRibbon2 : pCustomShape = &msoRibbon2; break; // SJ: TODO
+ case mso_sptEllipseRibbon : pCustomShape = &msoRibbon; break; // SJ: TODO
+ case mso_sptVerticalScroll : pCustomShape = &msoVerticalScroll; break;
+ case mso_sptHorizontalScroll : pCustomShape = &msoHorizontalScroll; break;
+ case mso_sptFlowChartProcess : pCustomShape = &msoFlowChartProcess; break;
+ case mso_sptFlowChartAlternateProcess : pCustomShape = &msoFlowChartAlternateProcess; break;
+ case mso_sptFlowChartDecision : pCustomShape = &msoFlowChartDecision; break;
+ case mso_sptFlowChartInputOutput : pCustomShape = &msoFlowChartInputOutput; break;
+ case mso_sptFlowChartPredefinedProcess :pCustomShape = &msoFlowChartPredefinedProcess; break;
+ case mso_sptFlowChartInternalStorage : pCustomShape = &msoFlowChartInternalStorage; break;
+ case mso_sptFlowChartDocument : pCustomShape = &msoFlowChartDocument; break;
+ case mso_sptFlowChartMultidocument : pCustomShape = &msoFlowChartMultidocument; break;
+ case mso_sptFlowChartTerminator : pCustomShape = &msoFlowChartTerminator; break;
+ case mso_sptFlowChartPreparation : pCustomShape = &msoFlowChartPreparation; break;
+ case mso_sptFlowChartManualInput : pCustomShape = &msoFlowChartManualInput; break;
+ case mso_sptFlowChartManualOperation : pCustomShape = &msoFlowChartManualOperation; break;
+ case mso_sptFlowChartConnector : pCustomShape = &msoFlowChartConnector; break;
+ case mso_sptFlowChartOffpageConnector : pCustomShape = &msoFlowChartOffpageConnector; break;
+ case mso_sptFlowChartPunchedCard : pCustomShape = &msoFlowChartPunchedCard; break;
+ case mso_sptFlowChartPunchedTape : pCustomShape = &msoFlowChartPunchedTape; break;
+ case mso_sptFlowChartSummingJunction : pCustomShape = &msoFlowChartSummingJunction; break;
+ case mso_sptFlowChartOr : pCustomShape = &msoFlowChartOr; break;
+ case mso_sptFlowChartCollate : pCustomShape = &msoFlowChartCollate; break;
+ case mso_sptFlowChartSort : pCustomShape = &msoFlowChartSort; break;
+ case mso_sptFlowChartExtract : pCustomShape = &msoFlowChartExtract; break;
+ case mso_sptFlowChartMerge : pCustomShape = &msoFlowChartMerge; break;
+ case mso_sptFlowChartOnlineStorage : pCustomShape = &msoFlowChartOnlineStorage; break;
+ case mso_sptFlowChartDelay : pCustomShape = &msoFlowChartDelay; break;
+ case mso_sptFlowChartMagneticTape : pCustomShape = &msoFlowChartMagneticTape; break;
+ case mso_sptFlowChartMagneticDisk : pCustomShape = &msoFlowChartMagneticDisk; break;
+ case mso_sptFlowChartMagneticDrum : pCustomShape = &msoFlowChartMagneticDrum; break;
+ case mso_sptFlowChartDisplay : pCustomShape = &msoFlowChartDisplay; break;
+ case mso_sptWedgeRectCallout : pCustomShape = &msoWedgeRectCallout; break;
+ case mso_sptWedgeRRectCallout : pCustomShape = &msoWedgeRRectCallout; break;
+ case mso_sptWedgeEllipseCallout : pCustomShape = &msoWedgeEllipseCallout; break;
+ case mso_sptCloudCallout : pCustomShape = &msoCloudCallout; break;
+ case mso_sptWave : pCustomShape = &msoWave; break;
+ case mso_sptDoubleWave : pCustomShape = &msoDoubleWave; break;
+
+ // callout
+ case mso_sptCallout1 : pCustomShape = &msoCallout1; break;
+ case mso_sptCallout2 : pCustomShape = &msoCallout2; break;
+ case mso_sptCallout3 : pCustomShape = &msoCallout3; break;
+ case mso_sptAccentCallout1 : pCustomShape = &msoAccentCallout1; break;
+ case mso_sptAccentCallout2 : pCustomShape = &msoAccentCallout2; break;
+ case mso_sptAccentCallout3 : pCustomShape = &msoAccentCallout3; break;
+ case mso_sptBorderCallout1 : pCustomShape = &msoBorderCallout1; break;
+ case mso_sptBorderCallout2 : pCustomShape = &msoBorderCallout2; break;
+ case mso_sptBorderCallout3 : pCustomShape = &msoBorderCallout3; break;
+ case mso_sptAccentBorderCallout1 : pCustomShape = &msoAccentBorderCallout1; break;
+ case mso_sptAccentBorderCallout2 : pCustomShape = &msoAccentBorderCallout2; break;
+ case mso_sptAccentBorderCallout3 : pCustomShape = &msoAccentBorderCallout3; break;
+ case mso_sptCallout90 : pCustomShape = &msoCallout90; break;
+ case mso_sptAccentCallout90 : pCustomShape = &msoAccentCallout90; break;
+ case mso_sptBorderCallout90 : pCustomShape = &msoBorderCallout90; break;
+ case mso_sptAccentBorderCallout90 : pCustomShape = &msoAccentBorderCallout90; break;
+
+ // connectors
+ case mso_sptStraightConnector1 : pCustomShape = &msoStraightConnector1; break;
+ case mso_sptBentConnector2 : pCustomShape = &msoBentConnector2; break;
+ case mso_sptBentConnector3 : pCustomShape = &msoBentConnector3; break;
+ case mso_sptBentConnector4 : pCustomShape = &msoBentConnector4; break;
+ case mso_sptBentConnector5 : pCustomShape = &msoBentConnector5; break;
+ case mso_sptCurvedConnector2 : pCustomShape = &msoCurvedConnector2; break;
+ case mso_sptCurvedConnector3 : pCustomShape = &msoCurvedConnector3; break;
+ case mso_sptCurvedConnector4 : pCustomShape = &msoCurvedConnector4; break;
+ case mso_sptCurvedConnector5 : pCustomShape = &msoCurvedConnector5; break;
+
+ // Dont know, simply mapping to TextSimple
+ case mso_sptTextOnRing :
+ case mso_sptTextOnCurve :
+ case mso_sptTextRing :
+ case mso_sptTextWave :
+ case mso_sptTextCurve :
+ case mso_sptTextHexagon :
+ case mso_sptTextOctagon :
+ case mso_sptTextBox : pCustomShape = &msoTextSimple; break;
+
+ // FontWork
+ case mso_sptTextSimple :
+ case mso_sptTextPlainText : pCustomShape = &msoTextPlainText; break;
+ case mso_sptTextStop : pCustomShape = &msoTextStop; break;
+ case mso_sptTextTriangle : pCustomShape = &msoTextTriangle; break;
+ case mso_sptTextTriangleInverted : pCustomShape = &msoTextTriangleInverted; break;
+ case mso_sptTextChevron : pCustomShape = &msoTextChevron; break;
+ case mso_sptTextChevronInverted : pCustomShape = &msoTextChevronInverted; break;
+ case mso_sptTextRingInside : pCustomShape = &msoTextRingOutside; break; // SJ: TODO->the orientation of the ellipse needs to be changed
+ case mso_sptTextRingOutside : pCustomShape = &msoTextRingOutside; break;
+ case mso_sptTextFadeRight : pCustomShape = &msoTextFadeRight; break;
+ case mso_sptTextFadeLeft : pCustomShape = &msoTextFadeLeft; break;
+ case mso_sptTextFadeUp : pCustomShape = &msoTextFadeUp; break;
+ case mso_sptTextFadeDown : pCustomShape = &msoTextFadeDown; break;
+ case mso_sptTextSlantUp : pCustomShape = &msoTextSlantUp; break;
+ case mso_sptTextSlantDown : pCustomShape = &msoTextSlantDown; break;
+ case mso_sptTextCascadeUp : pCustomShape = &msoTextCascadeUp; break;
+ case mso_sptTextCascadeDown : pCustomShape = &msoTextCascadeDown; break;
+ case mso_sptTextArchUpCurve : pCustomShape = &msoTextArchUpCurve; break;
+ case mso_sptTextArchDownCurve : pCustomShape = &msoTextArchDownCurve; break;
+ case mso_sptTextCircleCurve : pCustomShape = &msoTextCircleCurve; break;
+ case mso_sptTextButtonCurve : pCustomShape = &msoTextButtonCurve; break;
+ case mso_sptTextArchUpPour : pCustomShape = &msoTextArchUpPour; break;
+ case mso_sptTextArchDownPour : pCustomShape = &msoTextArchDownPour; break;
+ case mso_sptTextCirclePour : pCustomShape = &msoTextCirclePour; break;
+ case mso_sptTextButtonPour : pCustomShape = &msoTextButtonPour; break;
+ case mso_sptTextCurveUp : pCustomShape = &msoTextCurveUp; break;
+ case mso_sptTextCurveDown : pCustomShape = &msoTextCurveDown; break;
+ case mso_sptTextCanUp : pCustomShape = &msoTextCanUp; break;
+ case mso_sptTextCanDown : pCustomShape = &msoTextCanDown; break;
+ case mso_sptTextInflate : pCustomShape = &msoTextInflate; break;
+ case mso_sptTextDeflate : pCustomShape = &msoTextDeflate; break;
+ case mso_sptTextInflateBottom : pCustomShape = &msoTextInflateBottom; break;
+ case mso_sptTextDeflateBottom : pCustomShape = &msoTextDeflateBottom; break;
+ case mso_sptTextInflateTop : pCustomShape = &msoTextInflateTop; break;
+ case mso_sptTextDeflateTop : pCustomShape = &msoTextDeflateTop; break;
+ case mso_sptTextDeflateInflate : pCustomShape = &msoTextDeflateInflate; break;
+ case mso_sptTextDeflateInflateDeflate : pCustomShape = &msoTextDeflateInflateDeflate; break;
+ case mso_sptTextWave1 : pCustomShape = &msoTextWave1; break;
+ case mso_sptTextWave2 : pCustomShape = &msoTextWave2; break;
+ case mso_sptTextWave3 : pCustomShape = &msoTextWave3; break;
+ case mso_sptTextWave4 : pCustomShape = &msoTextWave4; break;
+ default :
+ break;
+ }
+ return pCustomShape;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeGeometry.hxx b/svx/source/customshapes/EnhancedCustomShapeGeometry.hxx
new file mode 100644
index 000000000000..4c16eb1bf7f5
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeGeometry.hxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _ENHANCEDCUSTOMSHAPEGEOMETRY_HXX
+#define _ENHANCEDCUSTOMSHAPEGEOMETRY_HXX
+
+#include <sal/types.h>
+#include <svx/msdffdef.hxx>
+
+struct SvxMSDffVertPair
+{
+ sal_Int32 nValA;
+ sal_Int32 nValB;
+};
+struct SvxMSDffCalculationData
+{
+ sal_uInt16 nFlags;
+ sal_Int16 nVal[ 3 ];
+};
+struct SvxMSDffTextRectangles
+{
+ SvxMSDffVertPair nPairA;
+ SvxMSDffVertPair nPairB;
+};
+
+#define MSDFF_HANDLE_FLAGS_MIRRORED_X 0x0001
+#define MSDFF_HANDLE_FLAGS_MIRRORED_Y 0x0002
+#define MSDFF_HANDLE_FLAGS_SWITCHED 0x0004
+#define MSDFF_HANDLE_FLAGS_POLAR 0x0008
+#define MSDFF_HANDLE_FLAGS_MAP 0x0010
+#define MSDFF_HANDLE_FLAGS_RANGE 0x0020
+#define MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL 0x0080
+#define MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL 0x0100
+#define MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL 0x0200
+#define MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL 0x0400
+#define MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL 0x0800
+#define MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL 0x1000
+#define MSDFF_HANDLE_FLAGS_RADIUS_RANGE 0x2000
+
+struct SvxMSDffHandle
+{
+ sal_uInt32 nFlags;
+ sal_Int32 nPositionX, nPositionY, nCenterX, nCenterY, nRangeXMin, nRangeXMax, nRangeYMin, nRangeYMax;
+};
+struct mso_CustomShape
+{
+ SvxMSDffVertPair* pVertices;
+ sal_uInt32 nVertices;
+ sal_uInt16* pElements;
+ sal_uInt32 nElements;
+ SvxMSDffCalculationData* pCalculation;
+ sal_uInt32 nCalculation;
+ sal_Int32* pDefData;
+ SvxMSDffTextRectangles* pTextRect;
+ sal_uInt32 nTextRect;
+ sal_Int32 nCoordWidth;
+ sal_Int32 nCoordHeight;
+ sal_Int32 nXRef;
+ sal_Int32 nYRef;
+ SvxMSDffVertPair* pGluePoints;
+ sal_uInt32 nGluePoints;
+ SvxMSDffHandle* pHandles;
+ sal_uInt32 nHandles;
+};
+
+#define MSO_I | (sal_Int32)0x80000000
+
+sal_Bool SortFilledObjectsToBackByDefault( MSO_SPT eSpType );
+SVX_DLLPUBLIC sal_Bool IsCustomShapeFilledByDefault( MSO_SPT eSpType );
+SVX_DLLPUBLIC sal_Int16 GetCustomShapeConnectionTypeDefault( MSO_SPT eSpType );
+
+// #i28269#
+SVX_DLLPUBLIC sal_Bool IsCustomShapeStrokedByDefault( MSO_SPT eSpType );
+
+SVX_DLLPUBLIC const mso_CustomShape* GetCustomShapeContent( MSO_SPT eSpType );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeHandle.cxx b/svx/source/customshapes/EnhancedCustomShapeHandle.cxx
new file mode 100644
index 000000000000..6b2f8699b7cd
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeHandle.cxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "EnhancedCustomShapeHandle.hxx"
+#include "EnhancedCustomShape2d.hxx"
+#include "unoapi.hxx"
+
+// -----------------------------------------------------------------------------
+
+EnhancedCustomShapeHandle::EnhancedCustomShapeHandle( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xCustomShape, sal_uInt32 nIndex ) :
+ mnIndex ( nIndex ),
+ mxCustomShape ( xCustomShape )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+EnhancedCustomShapeHandle::~EnhancedCustomShapeHandle()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL EnhancedCustomShapeHandle::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL EnhancedCustomShapeHandle::release() throw()
+{
+ OWeakObject::release();
+}
+
+// XCustomShapeHandle
+com::sun::star::awt::Point SAL_CALL EnhancedCustomShapeHandle::getPosition()
+ throw ( com::sun::star::uno::RuntimeException )
+{
+ SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxCustomShape ) );
+ if ( !pSdrObjCustomShape )
+ throw com::sun::star::uno::RuntimeException();
+
+ Point aPosition;
+ EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ if ( !aCustomShape2d.GetHandlePosition( mnIndex, aPosition ) )
+ throw com::sun::star::uno::RuntimeException();
+ return com::sun::star::awt::Point( aPosition.X(), aPosition.Y() );
+}
+
+void SAL_CALL EnhancedCustomShapeHandle::setControllerPosition( const com::sun::star::awt::Point& aPnt )
+ throw ( com::sun::star::uno::RuntimeException )
+{
+ SdrObject* pSdrObjCustomShape( GetSdrObjectFromXShape( mxCustomShape ) );
+ if ( !pSdrObjCustomShape )
+ throw com::sun::star::uno::RuntimeException();
+
+ EnhancedCustomShape2d aCustomShape2d( pSdrObjCustomShape );
+ if ( !aCustomShape2d.SetHandleControllerPosition( mnIndex, aPnt ) )
+ throw com::sun::star::uno::RuntimeException();
+}
+
+// XInitialization
+void SAL_CALL EnhancedCustomShapeHandle::initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& /* aArguments */ )
+ throw ( com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException )
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeHandle.hxx b/svx/source/customshapes/EnhancedCustomShapeHandle.hxx
new file mode 100644
index 000000000000..68ac2bc78401
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeHandle.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _ENHANCED_CUSTOMSHAPE_HANDLE_HXX
+#define _ENHANCED_CUSTOMSHAPE_HANDLE_HXX
+
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/XCustomShapeHandle.hpp>
+#include <com/sun/star/awt/Point.hpp>
+#include <cppuhelper/weakref.hxx>
+
+class EnhancedCustomShapeHandle : public cppu::WeakImplHelper2
+<
+ com::sun::star::drawing::XCustomShapeHandle,
+ com::sun::star::lang::XInitialization
+>
+{
+ sal_uInt32 mnIndex;
+ com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxCustomShape;
+
+public:
+
+ EnhancedCustomShapeHandle( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xCustomShape, sal_uInt32 nIndex );
+ virtual ~EnhancedCustomShapeHandle();
+
+ // XInterface
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XCustomShapeHandle
+ virtual com::sun::star::awt::Point SAL_CALL getPosition()
+ throw ( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL setControllerPosition( const com::sun::star::awt::Point& )
+ throw ( com::sun::star::uno::RuntimeException );
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& aArguments )
+ throw ( com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx b/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx
new file mode 100644
index 000000000000..9b266dcecde0
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx
@@ -0,0 +1,324 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "EnhancedCustomShapeTypeNames.hxx"
+#include <osl/mutex.hxx>
+#include <hash_map>
+
+struct TCheck
+{
+ bool operator()( const char* s1, const char* s2 ) const
+ {
+ return strcmp( s1, s2 ) == 0;
+ }
+};
+typedef std::hash_map< const char*, MSO_SPT, std::hash<const char*>, TCheck> TypeNameHashMap;
+static TypeNameHashMap* pHashMap = NULL;
+static ::osl::Mutex& getHashMapMutex()
+{
+ static osl::Mutex s_aHashMapProtection;
+ return s_aHashMapProtection;
+}
+
+struct NameTypeTable
+{
+ const char* pS;
+ MSO_SPT pE;
+};
+static const NameTypeTable pNameTypeTableArray[] =
+{
+ { "non-primitive", mso_sptMin },
+ { "rectangle", mso_sptRectangle },
+ { "round-rectangle", mso_sptRoundRectangle },
+ { "ellipse", mso_sptEllipse },
+ { "diamond", mso_sptDiamond },
+ { "isosceles-triangle", mso_sptIsocelesTriangle },
+ { "right-triangle", mso_sptRightTriangle },
+ { "parallelogram", mso_sptParallelogram },
+ { "trapezoid", mso_sptTrapezoid },
+ { "hexagon", mso_sptHexagon },
+ { "octagon", mso_sptOctagon },
+ { "cross", mso_sptPlus },
+ { "star5", mso_sptStar },
+ { "right-arrow", mso_sptArrow },
+ { "mso-spt14", mso_sptThickArrow },
+ { "pentagon-right", mso_sptHomePlate },
+ { "cube", mso_sptCube },
+ { "mso-spt17", mso_sptBalloon },
+ { "mso-spt18", mso_sptSeal },
+ { "mso-spt19", mso_sptArc },
+ { "mso-spt20", mso_sptLine },
+ { "mso-spt21", mso_sptPlaque },
+ { "can", mso_sptCan },
+ { "ring", mso_sptDonut },
+ { "mso-spt24", mso_sptTextSimple },
+ { "mso-spt25", mso_sptTextOctagon },
+ { "mso-spt26", mso_sptTextHexagon },
+ { "mso-spt27", mso_sptTextCurve },
+ { "mso-spt28", mso_sptTextWave },
+ { "mso-spt29", mso_sptTextRing },
+ { "mso-spt30", mso_sptTextOnCurve },
+ { "mso-spt31", mso_sptTextOnRing },
+ { "mso-spt32", mso_sptStraightConnector1 },
+ { "mso-spt33", mso_sptBentConnector2 },
+ { "mso-spt34", mso_sptBentConnector3 },
+ { "mso-spt35", mso_sptBentConnector4 },
+ { "mso-spt36", mso_sptBentConnector5 },
+ { "mso-spt37", mso_sptCurvedConnector2 },
+ { "mso-spt38", mso_sptCurvedConnector3 },
+ { "mso-spt39", mso_sptCurvedConnector4 },
+ { "mso-spt40", mso_sptCurvedConnector5 },
+ { "mso-spt41", mso_sptCallout1 },
+ { "mso-spt42", mso_sptCallout2 },
+ { "mso-spt43", mso_sptCallout3 },
+ { "mso-spt44", mso_sptAccentCallout1 },
+ { "mso-spt45", mso_sptAccentCallout2 },
+ { "mso-spt46", mso_sptAccentCallout3 },
+ { "line-callout-1", mso_sptBorderCallout1 },
+ { "line-callout-2", mso_sptBorderCallout2 },
+ { "mso-spt49", mso_sptBorderCallout3 },
+ { "mso-spt50", mso_sptAccentBorderCallout1 },
+ { "mso-spt51", mso_sptAccentBorderCallout2 },
+ { "mso-spt52", mso_sptAccentBorderCallout3 },
+ { "mso-spt53", mso_sptRibbon },
+ { "mso-spt54", mso_sptRibbon2 },
+ { "chevron", mso_sptChevron },
+ { "pentagon", mso_sptPentagon },
+ { "forbidden", mso_sptNoSmoking },
+ { "star8", mso_sptSeal8 },
+ { "mso-spt59", mso_sptSeal16 },
+ { "mso-spt60", mso_sptSeal32 },
+ { "rectangular-callout", mso_sptWedgeRectCallout },
+ { "round-rectangular-callout", mso_sptWedgeRRectCallout },
+ { "round-callout", mso_sptWedgeEllipseCallout },
+ { "mso-spt64", mso_sptWave },
+ { "paper", mso_sptFoldedCorner },
+ { "left-arrow", mso_sptLeftArrow },
+ { "down-arrow", mso_sptDownArrow },
+ { "up-arrow", mso_sptUpArrow },
+ { "left-right-arrow", mso_sptLeftRightArrow },
+ { "up-down-arrow", mso_sptUpDownArrow },
+ { "mso-spt71", mso_sptIrregularSeal1 },
+ { "bang", mso_sptIrregularSeal2 },
+ { "lightning", mso_sptLightningBolt },
+ { "heart", mso_sptHeart },
+ { "mso-spt75", mso_sptPictureFrame },
+ { "quad-arrow", mso_sptQuadArrow },
+ { "left-arrow-callout", mso_sptLeftArrowCallout },
+ { "right-arrow-callout", mso_sptRightArrowCallout },
+ { "up-arrow-callout", mso_sptUpArrowCallout },
+ { "down-arrow-callout", mso_sptDownArrowCallout },
+ { "left-right-arrow-callout", mso_sptLeftRightArrowCallout },
+ { "up-down-arrow-callout", mso_sptUpDownArrowCallout },
+ { "quad-arrow-callout", mso_sptQuadArrowCallout },
+ { "quad-bevel", mso_sptBevel },
+ { "left-bracket", mso_sptLeftBracket },
+ { "right-bracket", mso_sptRightBracket },
+ { "left-brace", mso_sptLeftBrace },
+ { "right-brace", mso_sptRightBrace },
+ { "mso-spt89", mso_sptLeftUpArrow },
+ { "mso-spt90", mso_sptBentUpArrow },
+ { "mso-spt91", mso_sptBentArrow },
+ { "star24", mso_sptSeal24 },
+ { "striped-right-arrow", mso_sptStripedRightArrow },
+ { "notched-right-arrow", mso_sptNotchedRightArrow },
+ { "block-arc", mso_sptBlockArc },
+ { "smiley", mso_sptSmileyFace },
+ { "vertical-scroll", mso_sptVerticalScroll },
+ { "horizontal-scroll", mso_sptHorizontalScroll },
+ { "circular-arrow", mso_sptCircularArrow },
+ { "mso-spt100", mso_sptNotchedCircularArrow },
+ { "mso-spt101", mso_sptUturnArrow },
+ { "mso-spt102", mso_sptCurvedRightArrow },
+ { "mso-spt103", mso_sptCurvedLeftArrow },
+ { "mso-spt104", mso_sptCurvedUpArrow },
+ { "mso-spt105", mso_sptCurvedDownArrow },
+ { "cloud-callout", mso_sptCloudCallout },
+ { "mso-spt107", mso_sptEllipseRibbon },
+ { "mso-spt108", mso_sptEllipseRibbon2 },
+ { "flowchart-process", mso_sptFlowChartProcess },
+ { "flowchart-decision", mso_sptFlowChartDecision },
+ { "flowchart-data", mso_sptFlowChartInputOutput },
+ { "flowchart-predefined-process", mso_sptFlowChartPredefinedProcess },
+ { "flowchart-internal-storage", mso_sptFlowChartInternalStorage },
+ { "flowchart-document", mso_sptFlowChartDocument },
+ { "flowchart-multidocument", mso_sptFlowChartMultidocument },
+ { "flowchart-terminator", mso_sptFlowChartTerminator },
+ { "flowchart-preparation", mso_sptFlowChartPreparation },
+ { "flowchart-manual-input", mso_sptFlowChartManualInput },
+ { "flowchart-manual-operation", mso_sptFlowChartManualOperation },
+ { "flowchart-connector", mso_sptFlowChartConnector },
+ { "flowchart-card", mso_sptFlowChartPunchedCard },
+ { "flowchart-punched-tape", mso_sptFlowChartPunchedTape },
+ { "flowchart-summing-junction", mso_sptFlowChartSummingJunction },
+ { "flowchart-or", mso_sptFlowChartOr },
+ { "flowchart-collate", mso_sptFlowChartCollate },
+ { "flowchart-sort", mso_sptFlowChartSort },
+ { "flowchart-extract", mso_sptFlowChartExtract },
+ { "flowchart-merge", mso_sptFlowChartMerge },
+ { "mso-spt129", mso_sptFlowChartOfflineStorage },
+ { "flowchart-stored-data", mso_sptFlowChartOnlineStorage },
+ { "flowchart-sequential-access", mso_sptFlowChartMagneticTape },
+ { "flowchart-magnetic-disk", mso_sptFlowChartMagneticDisk },
+ { "flowchart-direct-access-storage", mso_sptFlowChartMagneticDrum },
+ { "flowchart-display", mso_sptFlowChartDisplay },
+ { "flowchart-delay", mso_sptFlowChartDelay },
+ { "fontwork-plain-text", mso_sptTextPlainText },
+ { "fontwork-stop", mso_sptTextStop },
+ { "fontwork-triangle-up", mso_sptTextTriangle },
+ { "fontwork-triangle-down", mso_sptTextTriangleInverted },
+ { "fontwork-chevron-up", mso_sptTextChevron },
+ { "fontwork-chevron-down", mso_sptTextChevronInverted },
+ { "mso-spt142", mso_sptTextRingInside },
+ { "mso-spt143", mso_sptTextRingOutside },
+ { "fontwork-arch-up-curve", mso_sptTextArchUpCurve },
+ { "fontwork-arch-down-curve", mso_sptTextArchDownCurve },
+ { "fontwork-circle-curve", mso_sptTextCircleCurve },
+ { "fontwork-open-circle-curve", mso_sptTextButtonCurve },
+ { "fontwork-arch-up-pour", mso_sptTextArchUpPour },
+ { "fontwork-arch-down-pour", mso_sptTextArchDownPour },
+ { "fontwork-circle-pour", mso_sptTextCirclePour },
+ { "fontwork-open-circle-pour", mso_sptTextButtonPour },
+ { "fontwork-curve-up", mso_sptTextCurveUp },
+ { "fontwork-curve-down", mso_sptTextCurveDown },
+ { "fontwork-fade-up-and-right", mso_sptTextCascadeUp },
+ { "fontwork-fade-up-and-left", mso_sptTextCascadeDown },
+ { "fontwork-wave", mso_sptTextWave1 },
+ { "mso-spt157", mso_sptTextWave2 },
+ { "mso-spt158", mso_sptTextWave3 },
+ { "mso-spt159", mso_sptTextWave4 },
+ { "fontwork-inflate", mso_sptTextInflate },
+ { "mso-spt161", mso_sptTextDeflate },
+ { "mso-spt162", mso_sptTextInflateBottom },
+ { "mso-spt163", mso_sptTextDeflateBottom },
+ { "mso-spt164", mso_sptTextInflateTop },
+ { "mso-spt165", mso_sptTextDeflateTop },
+ { "mso-spt166", mso_sptTextDeflateInflate },
+ { "mso-spt167", mso_sptTextDeflateInflateDeflate },
+ { "fontwork-fade-right", mso_sptTextFadeRight },
+ { "fontwork-fade-left", mso_sptTextFadeLeft },
+ { "fontwork-fade-up", mso_sptTextFadeUp },
+ { "fontwork-fade-down", mso_sptTextFadeDown },
+ { "fontwork-slant-up", mso_sptTextSlantUp },
+ { "fontwork-slant-down", mso_sptTextSlantDown },
+ { "mso-spt174", mso_sptTextCanUp },
+ { "mso-spt175", mso_sptTextCanDown },
+ { "flowchart-alternate-process", mso_sptFlowChartAlternateProcess },
+ { "flowchart-off-page-connector", mso_sptFlowChartOffpageConnector },
+ { "mso-spt178", mso_sptCallout90 },
+ { "mso-spt179", mso_sptAccentCallout90 },
+ { "mso-spt180", mso_sptBorderCallout90 },
+ { "line-callout-3", mso_sptAccentBorderCallout90 },
+ { "mso-spt182", mso_sptLeftRightUpArrow },
+ { "sun", mso_sptSun },
+ { "moon", mso_sptMoon },
+ { "bracket-pair", mso_sptBracketPair },
+ { "brace-pair", mso_sptBracePair },
+ { "star4", mso_sptSeal4 },
+ { "mso-spt188", mso_sptDoubleWave },
+ { "mso-spt189", mso_sptActionButtonBlank },
+ { "mso-spt190", mso_sptActionButtonHome },
+ { "mso-spt191", mso_sptActionButtonHelp },
+ { "mso-spt192", mso_sptActionButtonInformation },
+ { "mso-spt193", mso_sptActionButtonForwardNext },
+ { "mso-spt194", mso_sptActionButtonBackPrevious },
+ { "mso-spt195", mso_sptActionButtonEnd },
+ { "mso-spt196", mso_sptActionButtonBeginning },
+ { "mso-spt197", mso_sptActionButtonReturn },
+ { "mso-spt198", mso_sptActionButtonDocument },
+ { "mso-spt199", mso_sptActionButtonSound },
+ { "mso-spt200", mso_sptActionButtonMovie },
+ { "mso-spt201", mso_sptHostControl },
+ { "mso-spt202", mso_sptTextBox }
+};
+
+ // gallery: quadrat
+ // gallery: round-quadrat
+ // gallery: circle
+ // gallery: circle-pie
+ // gallery: frame
+ // gallery: flower
+ // gallery: cloud
+ // gallery: puzzle
+ // gallery: octagon-bevel
+ // gallery: diamond-bevel
+ // gallery: up-right-arrow
+ // gallery: up-right-down-arrow
+ // gallery: corner-right-arrow
+ // gallery: split-arrow
+ // gallery: up-right-arrow-callout
+ // gallery: split-round-arrow
+ // gallery: s-sharped-arrow
+ // Gallery: star6
+ // Gallery: star12
+ // Gallery: concave-star6
+ // Gallery: signet
+ // Gallery: doorplate
+ // gallery: fontwork-arch-left-curve
+ // gallery: fontwork-arch-right-curve
+ // gallery: fontwork-arch-left-pour
+ // gallery: fontwork-arch-right-pour
+
+MSO_SPT EnhancedCustomShapeTypeNames::Get( const rtl::OUString& rShapeType )
+{
+ if ( !pHashMap )
+ { // init hash map
+ ::osl::MutexGuard aGuard( getHashMapMutex() );
+ if ( !pHashMap )
+ {
+ TypeNameHashMap* pH = new TypeNameHashMap;
+ const NameTypeTable* pPtr = pNameTypeTableArray;
+ const NameTypeTable* pEnd = pPtr + ( sizeof( pNameTypeTableArray ) / sizeof( NameTypeTable ) );
+ for ( ; pPtr < pEnd; pPtr++ )
+ (*pH)[ pPtr->pS ] = pPtr->pE;
+ pHashMap = pH;
+ }
+ }
+ MSO_SPT eRetValue = mso_sptNil;
+ int i, nLen = rShapeType.getLength();
+ char* pBuf = new char[ nLen + 1 ];
+ for ( i = 0; i < nLen; i++ )
+ pBuf[ i ] = (char)rShapeType[ i ];
+ pBuf[ i ] = 0;
+ TypeNameHashMap::iterator aHashIter( pHashMap->find( pBuf ) );
+ delete[] pBuf;
+ if ( aHashIter != pHashMap->end() )
+ eRetValue = (*aHashIter).second;
+ return eRetValue;
+}
+
+rtl::OUString EnhancedCustomShapeTypeNames::Get( const MSO_SPT eShapeType )
+{
+ return eShapeType <= mso_sptTextBox
+ ? rtl::OUString::createFromAscii( pNameTypeTableArray[ eShapeType ].pS )
+ : rtl::OUString();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/EnhancedCustomShapeTypeNames.hxx b/svx/source/customshapes/EnhancedCustomShapeTypeNames.hxx
new file mode 100644
index 000000000000..4432c7a8a117
--- /dev/null
+++ b/svx/source/customshapes/EnhancedCustomShapeTypeNames.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _ENHANCED_CUSTOMSHAPE_TYPE_NAMES_HXX
+#define _ENHANCED_CUSTOMSHAPE_TYPE_NAMES_HXX
+#include <svx/msdffdef.hxx>
+#include <rtl/ustring.hxx>
+
+namespace EnhancedCustomShapeTypeNames
+{
+ SVX_DLLPUBLIC MSO_SPT Get( const rtl::OUString& );
+ SVX_DLLPUBLIC rtl::OUString Get( const MSO_SPT );
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/customshapes/makefile.mk b/svx/source/customshapes/makefile.mk
new file mode 100644
index 000000000000..3feca8f25007
--- /dev/null
+++ b/svx/source/customshapes/makefile.mk
@@ -0,0 +1,71 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=svx
+TARGET=customshapes
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Types -------------------------------------
+
+# Disable optimization for SunCC SPARC and MACOSX (funny loops
+# when parsing e.g. "x+width/2"),
+# also http://gcc.gnu.org/PR22392
+.IF ("$(OS)$(CPU)"=="SOLARISS" && "$(COM)"!="GCC") || "$(OS)"=="MACOSX" || ("$(OS)"=="LINUX" && "$(CPU)"=="P")
+NOOPTFILES= $(SLO)$/EnhancedCustomShapeFunctionParser.obj
+.ENDIF
+
+ENVCFLAGS += -DBOOST_SPIRIT_USE_OLD_NAMESPACE
+
+# --- Files -------------------------------------
+
+LIB1TARGET= $(SLB)$/$(TARGET)-core.lib
+LIB1OBJFILES= \
+ $(SLO)$/EnhancedCustomShapeTypeNames.obj \
+ $(SLO)$/EnhancedCustomShapeGeometry.obj \
+ $(SLO)$/EnhancedCustomShape2d.obj \
+ $(SLO)$/EnhancedCustomShapeFunctionParser.obj
+
+LIB2TARGET= $(SLB)$/$(TARGET).lib
+LIB2OBJFILES= \
+ $(SLO)$/EnhancedCustomShapeEngine.obj \
+ $(SLO)$/EnhancedCustomShape3d.obj \
+ $(SLO)$/EnhancedCustomShapeFontWork.obj \
+ $(SLO)$/EnhancedCustomShapeHandle.obj \
+ $(SLO)$/tbxcustomshapes.obj
+
+SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/svx/source/customshapes/tbxcustomshapes.cxx b/svx/source/customshapes/tbxcustomshapes.cxx
new file mode 100644
index 000000000000..36854b15017c
--- /dev/null
+++ b/svx/source/customshapes/tbxcustomshapes.cxx
@@ -0,0 +1,204 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+
+#include <svx/svxids.hrc>
+#include <tools/shl.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/toolbox.hxx>
+#include <osl/mutex.hxx>
+
+#include <sfx2/imagemgr.hxx>
+#include <vcl/svapp.hxx>
+#include "tbxcustomshapes.hxx"
+
+SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlCustomShapes, SfxBoolItem);
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SvxTbxCtlCustomShapes::SvxTbxCtlCustomShapes( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ m_aSubTbxResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" ) )
+{
+ switch( nSlotId )
+ {
+ default :
+ {
+ DBG_ASSERT( false, "SvxTbxCtlCustomShapes: unknown slot executed. ?" );
+ }
+ case SID_DRAWTBX_CS_BASIC :
+ {
+ m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BasicShapes.diamond" ) );
+ m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "basicshapes" ) );
+ }
+ break;
+
+ case SID_DRAWTBX_CS_SYMBOL :
+ {
+ m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SymbolShapes.smiley" ) );
+ m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "symbolshapes" ) );
+ }
+ break;
+
+ case SID_DRAWTBX_CS_ARROW :
+ {
+ m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ArrowShapes.left-right-arrow" ) );
+ m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "arrowshapes" ) );
+ }
+ break;
+ case SID_DRAWTBX_CS_FLOWCHART :
+ {
+ m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FlowChartShapes.flowchart-internal-storage" ) );
+ m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "flowchartshapes" ) );
+ }
+ break;
+ case SID_DRAWTBX_CS_CALLOUT :
+ {
+ m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CalloutShapes.round-rectangular-callout" ) );
+ m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "calloutshapes" ) );
+ }
+ break;
+ case SID_DRAWTBX_CS_STAR :
+ {
+ m_aCommand = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StarShapes.star5" ) );
+ m_aSubTbName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "starshapes" ) );
+ }
+ break;
+ }
+ m_aSubTbxResName += m_aSubTbName;
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+}
+
+/*************************************************************************
+|*
+|* Benachrichtigung, wenn sich der Applikationsstatus geaendert hat
+|*
+\************************************************************************/
+
+void SvxTbxCtlCustomShapes::StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ SfxToolBoxControl::StateChanged( nSID, eState, pState );
+}
+
+/*************************************************************************
+|*
+|* Wenn man ein PopupWindow erzeugen will
+|*
+\************************************************************************/
+
+SfxPopupWindowType SvxTbxCtlCustomShapes::GetPopupWindowType() const
+{
+ return( m_aCommand.getLength() == 0 ? SFX_POPUPWINDOW_ONCLICK : SFX_POPUPWINDOW_ONTIMEOUT);
+}
+
+/*************************************************************************
+|*
+|* Hier wird das Fenster erzeugt
+|* Lage der Toolbox mit GetToolBox() abfragbar
+|* rItemRect sind die Screen-Koordinaten
+|*
+\************************************************************************/
+
+SfxPopupWindow* SvxTbxCtlCustomShapes::CreatePopupWindow()
+{
+ createAndPositionSubToolBar( m_aSubTbxResName );
+ return NULL;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxTbxCtlCustomShapes::Select( BOOL /*bMod1*/ )
+{
+ if ( m_aCommand.getLength() > 0 )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aParamSeq( 0 );
+ Dispatch( m_aCommand, aParamSeq );
+ }
+}
+
+
+::sal_Bool SAL_CALL SvxTbxCtlCustomShapes::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException)
+{
+ // We control a sub-toolbar therefor, we have to return true.
+ return sal_True;
+}
+
+::rtl::OUString SAL_CALL SvxTbxCtlCustomShapes::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException)
+{
+ // Provide the controlled sub-toolbar name, so we are notified whenever
+ // this toolbar executes a function.
+ return m_aSubTbName;
+}
+
+void SAL_CALL SvxTbxCtlCustomShapes::functionSelected( const ::rtl::OUString& rCommand ) throw (::com::sun::star::uno::RuntimeException)
+{
+ // remind the new command
+ m_aCommand = rCommand;
+ // Our sub-toolbar wants to execute a function.
+ // We have to change the image of our toolbar button to reflect the new function.
+ SolarMutexGuard aGuard;
+ if ( !m_bDisposed )
+ {
+ if ( m_aCommand.getLength() > 0 )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
+ Image aImage = GetImage( xFrame, m_aCommand, hasBigImages(), isHighContrast() );
+ if ( !!aImage )
+ GetToolBox().SetItemImage( GetId(), aImage );
+ }
+ }
+}
+
+void SAL_CALL SvxTbxCtlCustomShapes::updateImage( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ // We should update the button image of our parent (toolbar).
+ // Use the stored command to set the correct current image.
+ SolarMutexGuard aGuard;
+ if ( m_aCommand.getLength() > 0 )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
+ Image aImage = GetImage( xFrame, m_aCommand, hasBigImages(), isHighContrast() );
+ if ( !!aImage )
+ GetToolBox().SetItemImage( GetId(), aImage );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/SpellDialogChildWindow.cxx b/svx/source/dialog/SpellDialogChildWindow.cxx
new file mode 100644
index 000000000000..cd87a911f75c
--- /dev/null
+++ b/svx/source/dialog/SpellDialogChildWindow.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/SpellDialogChildWindow.hxx>
+
+#include <svx/svxdlg.hxx>
+
+namespace svx {
+
+/*-------------------------------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SpellDialogChildWindow::SpellDialogChildWindow (
+ Window* _pParent,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* /*pInfo*/)
+ : SfxChildWindow (_pParent, nId)
+
+{
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "SvxAbstractDialogFactory::Create() failed");
+ m_pAbstractSpellDialog = pFact->CreateSvxSpellDialog(_pParent,
+ pBindings,
+ this );
+ pWindow = m_pAbstractSpellDialog->GetWindow();
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+ SetHideNotDelete (TRUE);
+}
+/*-------------------------------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SpellDialogChildWindow::~SpellDialogChildWindow (void)
+{
+}
+/*-------------------------------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SfxBindings& SpellDialogChildWindow::GetBindings (void) const
+{
+ OSL_ASSERT (m_pAbstractSpellDialog != NULL);
+ return m_pAbstractSpellDialog->GetBindings();
+}
+/*-------------------------------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SpellDialogChildWindow::InvalidateSpellDialog()
+{
+ OSL_ASSERT (m_pAbstractSpellDialog != NULL);
+ if(m_pAbstractSpellDialog)
+ m_pAbstractSpellDialog->Invalidate();
+}
+/*-------------------------------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SpellDialogChildWindow::HasAutoCorrection()
+{
+ return false;
+}
+/*-------------------------------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SpellDialogChildWindow::AddAutoCorrection(
+ const String& /*rOld*/,
+ const String& /*rNew*/,
+ LanguageType /*eLanguage*/)
+{
+ DBG_ERROR("AutoCorrection should have been overloaded - if available");
+}
+/*-- 16.06.2008 10:11:57---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SpellDialogChildWindow::HasGrammarChecking()
+{
+ return false;
+}
+/*-- 18.06.2008 12:26:35---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+bool SpellDialogChildWindow::IsGrammarChecking()
+{
+ DBG_ERROR("Grammar checking should have been overloaded - if available");
+ return false;
+}
+/*-- 18.06.2008 12:26:35---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void SpellDialogChildWindow::SetGrammarChecking(bool )
+{
+ DBG_ERROR("Grammar checking should have been overloaded - if available");
+}
+} // end of namespace ::svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx
new file mode 100644
index 000000000000..40c00320ec47
--- /dev/null
+++ b/svx/source/dialog/_bmpmask.cxx
@@ -0,0 +1,1244 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <vcl/wrkwin.hxx>
+#include <tools/shl.hxx>
+#include <vcl/metaact.hxx>
+#include <svtools/valueset.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svtools/colrdlg.hxx>
+
+#define BMPMASK_PRIVATE
+
+#include <svx/dialmgr.hxx>
+#include <svx/bmpmask.hxx>
+#include <svx/dialogs.hrc>
+#include <bmpmask.hrc>
+#include <svx/svxids.hrc>
+
+//-------------------------------------------------------------------------
+
+#define BMP_RESID(nId) ResId(nId, DIALOG_MGR())
+#define TRANSP_STRING "Transparent"
+#define TRANSP_COL (Color( 252, 252, 252 ))
+#define OWN_CALLMODE SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD
+
+//-------------------------------------------------------------------------
+
+#define TEST_COLS() \
+{ \
+ nR = aCol.GetRed(); nG = aCol.GetGreen(); nB = aCol.GetBlue(); \
+ for( i = 0; i < nCount; i++ ) \
+ { \
+ if ( ( pMinR[i] <= nR ) && ( pMaxR[i] >= nR ) && \
+ ( pMinG[i] <= nG ) && ( pMaxG[i] >= nG ) && \
+ ( pMinB[i] <= nB ) && ( pMaxB[i] >= nB ) ) \
+ { \
+ aCol = pDstCols[i]; bReplace = TRUE; break; \
+ } \
+ } \
+}
+
+// -------------------------------------------------------------------------
+
+SFX_IMPL_DOCKINGWINDOW( SvxBmpMaskChildWindow, SID_BMPMASK )
+
+// -------------------------------------------------------------------------
+
+class ColorWindow : public Control
+{
+ Color aColor;
+
+
+public:
+
+ ColorWindow( Window* pParent, WinBits nWinStyle ) :
+ Control( pParent, nWinStyle ),
+ aColor( COL_WHITE ) {};
+
+ ColorWindow( Window* pParent, const ResId& rId ) :
+ Control( pParent, rId ),
+ aColor( COL_WHITE ) {};
+
+ void SetColor( const Color& rColor )
+ {
+ aColor = rColor;
+ Invalidate();
+ }
+
+ virtual void Paint( const Rectangle& rRect );
+};
+
+//-------------------------------------------------------------------------
+
+class MaskSet : public ValueSet
+{
+ SvxBmpMask* pSvxBmpMask;
+
+
+public:
+ MaskSet( SvxBmpMask* pParent, WinBits nWinStyle );
+ MaskSet( SvxBmpMask* pParent, const ResId& rId );
+
+ virtual void Select();
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void GetFocus();
+
+ void onEditColor();
+};
+
+//-------------------------------------------------------------------------
+
+MaskSet::MaskSet( SvxBmpMask* pParent, WinBits nWinStyle ) :
+ ValueSet ( pParent, nWinStyle ),
+ pSvxBmpMask ( pParent )
+{
+}
+
+//-------------------------------------------------------------------------
+
+MaskSet::MaskSet( SvxBmpMask* pParent, const ResId& rId ) :
+ ValueSet ( pParent, rId ),
+ pSvxBmpMask ( pParent )
+{
+}
+
+//-------------------------------------------------------------------------
+
+void MaskSet::Select()
+{
+ ValueSet::Select();
+
+ pSvxBmpMask->onSelect( this );
+}
+
+void MaskSet::GetFocus()
+{
+ SelectItem( 1 );
+ pSvxBmpMask->onSelect( this );
+}
+
+void MaskSet::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyCode aCode = rKEvt.GetKeyCode();
+
+ // if the key has a modifier we don't care
+ if( aCode.GetModifier() )
+ {
+ ValueSet::KeyInput( rKEvt );
+ }
+ else
+ {
+ // check for keys that interests us
+ switch ( aCode.GetCode() )
+ {
+ case KEY_SPACE:
+ onEditColor();
+ break;
+ default:
+ ValueSet::KeyInput( rKEvt );
+ }
+
+ }
+}
+
+void MaskSet::onEditColor()
+{
+ SvColorDialog* pColorDlg = new SvColorDialog( GetParent() );
+
+ pColorDlg->SetColor(GetItemColor(1));
+
+ if( pColorDlg->Execute() )
+ SetItemColor( 1, pColorDlg->GetColor() );
+
+ delete pColorDlg;
+}
+
+//-------------------------------------------------------------------------
+
+class MaskData
+{
+ SvxBmpMask* pMask;
+ BOOL bIsReady;
+ BOOL bExecState;
+ SfxBindings& rBindings;
+
+public:
+ MaskData( SvxBmpMask* pBmpMask, SfxBindings& rBind );
+
+ BOOL IsCbxReady() const { return bIsReady; }
+ void SetExecState( BOOL bState ) { bExecState = bState; }
+ BOOL IsExecReady() const { return bExecState; }
+
+ DECL_LINK( PipetteHdl, ToolBox* pTbx );
+ DECL_LINK( CbxHdl, CheckBox* pCbx );
+ DECL_LINK( CbxTransHdl, CheckBox* pCbx );
+ DECL_LINK( FocusLbHdl, ColorLB* pLb );
+ DECL_LINK( ExecHdl, PushButton* pBtn );
+};
+
+//-------------------------------------------------------------------------
+
+MaskData::MaskData( SvxBmpMask* pBmpMask, SfxBindings& rBind ) :
+
+ pMask ( pBmpMask ),
+ bIsReady ( FALSE ),
+ bExecState ( FALSE ),
+ rBindings ( rBind )
+
+{
+}
+
+//-------------------------------------------------------------------------
+
+IMPL_LINK( MaskData, PipetteHdl, ToolBox*, pTbx )
+{
+ SfxBoolItem aBItem( SID_BMPMASK_PIPETTE,
+ pTbx->IsItemChecked( TBI_PIPETTE ) );
+
+ rBindings.GetDispatcher()->Execute( SID_BMPMASK_PIPETTE, OWN_CALLMODE, &aBItem, 0L );
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+
+IMPL_LINK( MaskData, CbxHdl, CheckBox*, pCbx )
+{
+ bIsReady = pMask->aCbx1.IsChecked() || pMask->aCbx2.IsChecked() ||
+ pMask->aCbx3.IsChecked() || pMask->aCbx4.IsChecked();
+
+ if ( bIsReady && IsExecReady() )
+ pMask->aBtnExec.Enable();
+ else
+ pMask->aBtnExec.Disable();
+
+ // Wenn eine Checkbox gecheckt wurde, wird die Pipette enabled
+ if ( pCbx->IsChecked() )
+ {
+ MaskSet* pSet = NULL;
+
+ if ( pCbx == &( pMask->aCbx1 ) )
+ pSet = pMask->pQSet1;
+ else if ( pCbx == &( pMask->aCbx2 ) )
+ pSet = pMask->pQSet2;
+ else if ( pCbx == &( pMask->aCbx3 ) )
+ pSet = pMask->pQSet3;
+ else // if ( pCbx == &( pMask->aCbx4 ) )
+ pSet = pMask->pQSet4;
+
+ pSet->SelectItem( 1 );
+ pSet->Select();
+
+ pMask->aTbxPipette.CheckItem( TBI_PIPETTE, TRUE );
+ PipetteHdl( &( pMask->aTbxPipette ) );
+ }
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+
+IMPL_LINK( MaskData, CbxTransHdl, CheckBox*, pCbx )
+{
+ bIsReady = pCbx->IsChecked();
+ if ( bIsReady )
+ {
+ pMask->pQSet1->Disable();
+ pMask->pQSet2->Disable();
+ pMask->pQSet3->Disable();
+ pMask->pQSet4->Disable();
+ pMask->pCtlPipette->Disable();
+ pMask->aCbx1.Disable();
+ pMask->aSp1.Disable();
+ pMask->aCbx2.Disable();
+ pMask->aSp2.Disable();
+ pMask->aCbx3.Disable();
+ pMask->aSp3.Disable();
+ pMask->aCbx4.Disable();
+ pMask->aSp4.Disable();
+ pMask->aTbxPipette.Disable();
+
+ pMask->aLbColor1.Disable();
+ pMask->aLbColor2.Disable();
+ pMask->aLbColor3.Disable();
+ pMask->aLbColor4.Disable();
+ pMask->aLbColorTrans.Enable();
+ }
+ else
+ {
+ pMask->pQSet1->Enable();
+ pMask->pQSet2->Enable();
+ pMask->pQSet3->Enable();
+ pMask->pQSet4->Enable();
+ pMask->pCtlPipette->Enable();
+ pMask->aCbx1.Enable();
+ pMask->aSp1.Enable();
+ pMask->aCbx2.Enable();
+ pMask->aSp2.Enable();
+ pMask->aCbx3.Enable();
+ pMask->aSp3.Enable();
+ pMask->aCbx4.Enable();
+ pMask->aSp4.Enable();
+ pMask->aTbxPipette.Enable();
+
+ pMask->aLbColor1.Enable();
+ pMask->aLbColor2.Enable();
+ pMask->aLbColor3.Enable();
+ pMask->aLbColor4.Enable();
+ pMask->aLbColorTrans.Disable();
+
+ bIsReady = pMask->aCbx1.IsChecked() || pMask->aCbx2.IsChecked() ||
+ pMask->aCbx3.IsChecked() || pMask->aCbx4.IsChecked();
+ }
+
+ if ( bIsReady && IsExecReady() )
+ pMask->aBtnExec.Enable();
+ else
+ pMask->aBtnExec.Disable();
+
+ return 0L;
+}
+
+//-------------------------------------------------------------------------
+
+IMPL_LINK( MaskData, FocusLbHdl, ColorLB*, pLb )
+{
+ pMask->pQSet1->SelectItem( pLb == &( pMask->aLbColor1 ) ? 1 : 0 );
+ pMask->pQSet2->SelectItem( pLb == &( pMask->aLbColor2 ) ? 1 : 0 );
+ pMask->pQSet3->SelectItem( pLb == &( pMask->aLbColor3 ) ? 1 : 0 );
+ pMask->pQSet4->SelectItem( pLb == &( pMask->aLbColor4 ) ? 1 : 0 );
+
+ return 0;
+}
+
+//-------------------------------------------------------------------------
+
+IMPL_LINK( MaskData, ExecHdl, PushButton*, EMPTYARG )
+{
+ SfxBoolItem aBItem( SID_BMPMASK_EXEC, TRUE );
+ rBindings.GetDispatcher()->Execute( SID_BMPMASK_EXEC, OWN_CALLMODE, &aBItem, 0L );
+
+ return 0L;
+}
+
+//-------------------------------------------------------------------------
+
+void ColorWindow::Paint( const Rectangle &/*Rect*/ )
+{
+ const Color& rOldLineColor = GetLineColor();
+ const Color& rOldFillColor = GetFillColor();
+
+ SetLineColor( aColor );
+ SetFillColor( aColor );
+
+ DrawRect( Rectangle( Point(), GetSizePixel() ) );
+
+ SetLineColor( rOldLineColor );
+ SetFillColor( rOldFillColor );
+}
+
+//-------------------------------------------------------------------------
+
+SvxBmpMaskSelectItem::SvxBmpMaskSelectItem( USHORT nId_, SvxBmpMask& rMask,
+ SfxBindings& rBindings ) :
+ SfxControllerItem ( nId_, rBindings ),
+ rBmpMask ( rMask)
+{
+}
+
+//-------------------------------------------------------------------------
+
+void SvxBmpMaskSelectItem::StateChanged( USHORT nSID, SfxItemState /*eState*/,
+ const SfxPoolItem* pItem )
+{
+ if ( ( nSID == SID_BMPMASK_EXEC ) && pItem )
+ {
+ const SfxBoolItem* pStateItem = PTR_CAST( SfxBoolItem, pItem );
+
+ DBG_ASSERT( pStateItem || pItem == 0, "SfxBoolItem erwartet");
+
+ rBmpMask.SetExecState( pStateItem->GetValue() );
+ }
+}
+
+//-------------------------------------------------------------------------
+
+SvxBmpMaskChildWindow::SvxBmpMaskChildWindow( Window* pParent_, USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( pParent_, nId )
+{
+ pWindow = new SvxBmpMask( pBindings, this, pParent_,
+ BMP_RESID( RID_SVXDLG_BMPMASK ) );
+ SvxBmpMask* pDlg = (SvxBmpMask*) pWindow;
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+
+ pDlg->Initialize( pInfo );
+}
+
+//-------------------------------------------------------------------------
+
+SvxBmpMask::SvxBmpMask( SfxBindings *pBindinx,
+ SfxChildWindow *pCW,
+ Window* pParent,
+ const ResId& rResId ) :
+ SfxDockingWindow ( pBindinx, pCW, pParent, rResId ),
+ aTbxPipette ( this, BMP_RESID( TBX_PIPETTE ) ),
+ pCtlPipette ( new ColorWindow( this, BMP_RESID( WND_PIPETTE ) ) ),
+ aBtnExec ( this, BMP_RESID( BTN_EXEC ) ),
+ aGrpQ ( this, BMP_RESID( GRP_Q ) ),
+
+ aCbx1 ( this, BMP_RESID( CBX_1 ) ),
+ pQSet1 ( new MaskSet( this, BMP_RESID( QCOL_1 ) ) ),
+ aSp1 ( this, BMP_RESID( SP_1 ) ),
+ aLbColor1 ( this, BMP_RESID ( LB_1 ) ),
+
+ aCbx2 ( this, BMP_RESID( CBX_2 ) ),
+ pQSet2 ( new MaskSet( this, BMP_RESID( QCOL_2 ) ) ),
+ aSp2 ( this, BMP_RESID( SP_2 ) ),
+ aLbColor2 ( this, BMP_RESID ( LB_2 ) ),
+
+ aCbx3 ( this, BMP_RESID( CBX_3 ) ),
+ pQSet3 ( new MaskSet( this, BMP_RESID( QCOL_3 ) ) ),
+ aSp3 ( this, BMP_RESID( SP_3 ) ),
+ aLbColor3 ( this, BMP_RESID ( LB_3 ) ),
+
+ aCbx4 ( this, BMP_RESID( CBX_4 ) ),
+ pQSet4 ( new MaskSet( this, BMP_RESID( QCOL_4 ) ) ),
+ aSp4 ( this, BMP_RESID( SP_4 ) ),
+ aLbColor4 ( this, BMP_RESID ( LB_4 ) ),
+
+ pData ( new MaskData( this, *pBindinx ) ),
+ aCbxTrans ( this, BMP_RESID( CBX_TRANS ) ),
+ aLbColorTrans ( this, BMP_RESID ( LB_TRANS ) ),
+ aFt1 ( this, BMP_RESID ( FT_1 ) ),
+ aFt2 ( this, BMP_RESID ( FT_2 ) ),
+ aFt3 ( this, BMP_RESID ( FT_3 ) ),
+ pColTab ( NULL ),
+ aPipetteColor ( COL_WHITE ),
+ aSelItem ( SID_BMPMASK_EXEC, *this, *pBindinx ),
+ maImgPipette ( BMP_RESID ( IMG_PIPETTE ) ),
+ maImgPipetteH ( BMP_RESID ( IMG_PIPETTE_H ) )
+{
+ FreeResource();
+
+ ApplyStyle();
+
+ aTbxPipette.SetSizePixel( aTbxPipette.CalcWindowSizePixel() );
+ aTbxPipette.SetSelectHdl( LINK( pData, MaskData, PipetteHdl ) );
+ aBtnExec.SetClickHdl( LINK( pData, MaskData, ExecHdl ) );
+
+ aCbx1.SetClickHdl( LINK( pData, MaskData, CbxHdl ) );
+ aCbx2.SetClickHdl( LINK( pData, MaskData, CbxHdl ) );
+ aCbx3.SetClickHdl( LINK( pData, MaskData, CbxHdl ) );
+ aCbx4.SetClickHdl( LINK( pData, MaskData, CbxHdl ) );
+ aCbxTrans.SetClickHdl( LINK( pData, MaskData, CbxTransHdl ) );
+
+ SetAccessibleNames ();
+
+ aLbColor1.SetGetFocusHdl( LINK( pData, MaskData, FocusLbHdl ) );
+ aLbColor2.SetGetFocusHdl( LINK( pData, MaskData, FocusLbHdl ) );
+ aLbColor3.SetGetFocusHdl( LINK( pData, MaskData, FocusLbHdl ) );
+ aLbColor4.SetGetFocusHdl( LINK( pData, MaskData, FocusLbHdl ) );
+ aLbColorTrans.Disable();
+
+ aSp1.SetValue( 10 );
+ aSp2.SetValue( 10 );
+ aSp3.SetValue( 10 );
+ aSp4.SetValue( 10 );
+
+ pQSet1->SetStyle( pQSet1->GetStyle() | WB_DOUBLEBORDER | WB_ITEMBORDER );
+ pQSet1->SetColCount( 1 );
+ pQSet1->SetLineCount( 1 );
+// pQSet1->SetExtraSpacing( 1 );
+ pQSet1->InsertItem( 1, aPipetteColor );
+ pQSet1->SelectItem( 1 );
+
+ pQSet2->SetStyle( pQSet2->GetStyle() | WB_DOUBLEBORDER | WB_ITEMBORDER );
+ pQSet2->SetColCount( 1 );
+ pQSet2->SetLineCount( 1 );
+// pQSet2->SetExtraSpacing( 1 );
+ pQSet2->InsertItem( 1, aPipetteColor );
+ pQSet2->SelectItem( 0 );
+
+ pQSet3->SetStyle( pQSet3->GetStyle() | WB_DOUBLEBORDER | WB_ITEMBORDER );
+ pQSet3->SetColCount( 1 );
+ pQSet3->SetLineCount( 1 );
+// pQSet3->SetExtraSpacing( 1 );
+ pQSet3->InsertItem( 1, aPipetteColor );
+ pQSet3->SelectItem( 0 );
+
+ pQSet4->SetStyle( pQSet4->GetStyle() | WB_DOUBLEBORDER | WB_ITEMBORDER );
+ pQSet4->SetColCount( 1 );
+ pQSet4->SetLineCount( 1 );
+// pQSet4->SetExtraSpacing( 1 );
+ pQSet4->InsertItem( 1, aPipetteColor );
+ pQSet4->SelectItem( 0 );
+
+ pQSet1->Show();
+ pQSet2->Show();
+ pQSet3->Show();
+ pQSet4->Show();
+}
+
+//-------------------------------------------------------------------------
+
+SvxBmpMask::~SvxBmpMask()
+{
+ delete pQSet1;
+ delete pQSet2;
+ delete pQSet3;
+ delete pQSet4;
+ delete pCtlPipette;
+ delete pData;
+}
+
+//-------------------------------------------------------------------------
+
+/** is called by a MaskSet when it is selected */
+void SvxBmpMask::onSelect( MaskSet* pSet )
+{
+ // automaticaly set focus to the corresponding listbox
+/*
+ if( pSet == pQSet1 )
+ aLbColor1.GrabFocus();
+ else if( pSet == pQSet2 )
+ aLbColor2.GrabFocus();
+ else if( pSet == pQSet2 )
+ aLbColor3.GrabFocus();
+ else if( pSet == pQSet2 )
+ aLbColor4.GrabFocus();
+*/
+
+ // now deselect all other value sets
+ if( pSet != pQSet1 )
+ pQSet1->SelectItem( 0 );
+
+ if( pSet != pQSet2 )
+ pQSet2->SelectItem( 0 );
+
+ if( pSet != pQSet3 )
+ pQSet3->SelectItem( 0 );
+
+ if( pSet != pQSet4 )
+ pQSet4->SelectItem( 0 );
+}
+
+//-------------------------------------------------------------------------
+
+BOOL SvxBmpMask::Close()
+{
+ SfxBoolItem aItem2( SID_BMPMASK_PIPETTE, FALSE );
+ GetBindings().GetDispatcher()->Execute( SID_BMPMASK_PIPETTE, OWN_CALLMODE, &aItem2, 0L );
+
+ return SfxDockingWindow::Close();
+}
+
+//-------------------------------------------------------------------------
+
+BOOL SvxBmpMask::NeedsColorTable() const
+{
+ return ( aLbColor1.GetEntryCount() == 0 );
+}
+
+//-------------------------------------------------------------------------
+
+void SvxBmpMask::SetColorTable( const XColorTable* pTable )
+{
+ if ( pTable && ( pTable != pColTab ) )
+ {
+ const String aTransp( BMP_RESID( RID_SVXDLG_BMPMASK_STR_TRANSP ) );
+
+ pColTab = pTable;
+
+ aLbColorTrans.Fill( pColTab );
+ aLbColorTrans.SelectEntryPos( 0 );
+
+ aLbColor1.Fill( pColTab );
+ aLbColor1.InsertEntry( TRANSP_COL, aTransp, 0 );
+ aLbColor1.SelectEntryPos( 0 );
+
+ aLbColor2.Fill( pColTab );
+ aLbColor2.InsertEntry( TRANSP_COL, aTransp, 0 );
+ aLbColor2.SelectEntryPos( 0 );
+
+ aLbColor3.Fill( pColTab );
+ aLbColor3.InsertEntry( TRANSP_COL, aTransp, 0 );
+ aLbColor3.SelectEntryPos( 0 );
+
+ aLbColor4.Fill( pColTab );
+ aLbColor4.InsertEntry( TRANSP_COL, aTransp, 0 );
+ aLbColor4.SelectEntryPos( 0 );
+ }
+}
+
+//-------------------------------------------------------------------------
+
+void SvxBmpMask::SetColor( const Color& rColor )
+{
+ aPipetteColor = rColor;
+ pCtlPipette->SetColor( aPipetteColor );
+}
+
+//-------------------------------------------------------------------------
+
+void SvxBmpMask::PipetteClicked()
+{
+ if( pQSet1->GetSelectItemId() == 1 )
+ {
+ aCbx1.Check( TRUE );
+ pData->CbxHdl( &aCbx1 );
+ pQSet1->SetItemColor( 1, aPipetteColor );
+ }
+ else if( pQSet2->GetSelectItemId() == 1 )
+ {
+ aCbx2.Check( TRUE );
+ pData->CbxHdl( &aCbx2 );
+ pQSet2->SetItemColor( 1, aPipetteColor );
+ }
+ else if( pQSet3->GetSelectItemId() == 1 )
+ {
+ aCbx3.Check( TRUE );
+ pData->CbxHdl( &aCbx3 );
+ pQSet3->SetItemColor( 1, aPipetteColor );
+ }
+ else if( pQSet4->GetSelectItemId() == 1 )
+ {
+ aCbx4.Check( TRUE );
+ pData->CbxHdl( &aCbx4 );
+ pQSet4->SetItemColor( 1, aPipetteColor );
+ }
+
+ aTbxPipette.CheckItem( TBI_PIPETTE, FALSE );
+ pData->PipetteHdl( &aTbxPipette );
+}
+
+//-------------------------------------------------------------------------
+
+void SvxBmpMask::SetExecState( BOOL bEnable )
+{
+ pData->SetExecState( bEnable );
+
+ if ( pData->IsExecReady() && pData->IsCbxReady() )
+ aBtnExec.Enable();
+ else
+ aBtnExec.Disable();
+}
+
+//-------------------------------------------------------------------------
+
+USHORT SvxBmpMask::InitColorArrays( Color* pSrcCols, Color* pDstCols, ULONG* pTols )
+{
+ USHORT nCount = 0;
+
+ if ( aCbx1.IsChecked() )
+ {
+ pSrcCols[nCount] = pQSet1->GetItemColor( 1 );
+ pDstCols[nCount] = aLbColor1.GetSelectEntryColor();
+ pTols[nCount++] = static_cast<ULONG>(aSp1.GetValue());
+ }
+
+ if ( aCbx2.IsChecked() )
+ {
+ pSrcCols[nCount] = pQSet2->GetItemColor( 1 );
+ pDstCols[nCount] = aLbColor2.GetSelectEntryColor();
+ pTols[nCount++] = static_cast<ULONG>(aSp2.GetValue());
+ }
+
+ if ( aCbx3.IsChecked() )
+ {
+ pSrcCols[nCount] = pQSet3->GetItemColor( 1 );
+ pDstCols[nCount] = aLbColor3.GetSelectEntryColor();
+ pTols[nCount++] = static_cast<ULONG>(aSp3.GetValue());
+ }
+
+ if ( aCbx4.IsChecked() )
+ {
+ pSrcCols[nCount] = pQSet4->GetItemColor( 1 );
+ pDstCols[nCount] = aLbColor4.GetSelectEntryColor();
+ pTols[nCount++] = static_cast<ULONG>(aSp4.GetValue());
+ }
+
+ return nCount;
+}
+
+//-------------------------------------------------------------------------
+
+Bitmap SvxBmpMask::ImpMask( const Bitmap& rBitmap )
+{
+ Bitmap aBitmap( rBitmap );
+ Color pSrcCols[4];
+ Color pDstCols[4];
+ ULONG pTols[4];
+ const USHORT nCount = InitColorArrays( pSrcCols, pDstCols, pTols );
+
+ EnterWait();
+ aBitmap.Replace( pSrcCols, pDstCols, nCount, pTols );
+ LeaveWait();
+
+ return aBitmap;
+}
+
+//-------------------------------------------------------------------------
+
+BitmapEx SvxBmpMask::ImpMask( const BitmapEx& rBitmapEx )
+{
+ return BitmapEx( ImpMask( rBitmapEx.GetBitmap() ), rBitmapEx.GetMask() );
+}
+
+//-------------------------------------------------------------------------
+
+BitmapEx SvxBmpMask::ImpMaskTransparent( const BitmapEx& rBitmapEx, const Color& rColor, const long nTol )
+{
+ EnterWait();
+
+ BitmapEx aBmpEx;
+ Bitmap aMask( rBitmapEx.GetBitmap().CreateMask( rColor, nTol ) );
+
+ if( rBitmapEx.IsTransparent() )
+ aMask.CombineSimple( rBitmapEx.GetMask(), BMP_COMBINE_OR );
+
+ aBmpEx = BitmapEx( rBitmapEx.GetBitmap(), aMask );
+ LeaveWait();
+
+ return aBmpEx;
+}
+
+//-------------------------------------------------------------------------
+
+Animation SvxBmpMask::ImpMask( const Animation& rAnimation )
+{
+ Animation aAnimation( rAnimation );
+ Color pSrcCols[4];
+ Color pDstCols[4];
+ ULONG pTols[4];
+ InitColorArrays( pSrcCols, pDstCols, pTols );
+ USHORT nAnimationCount = aAnimation.Count();
+
+ for( USHORT i = 0; i < nAnimationCount; i++ )
+ {
+ AnimationBitmap aAnimBmp( aAnimation.Get( i ) );
+ aAnimBmp.aBmpEx = Mask( aAnimBmp.aBmpEx ).GetBitmapEx();
+ aAnimation.Replace( aAnimBmp, i );
+ }
+
+ return aAnimation;
+}
+
+//-------------------------------------------------------------------------
+
+GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf )
+{
+ GDIMetaFile aMtf;
+ Color pSrcCols[4];
+ Color pDstCols[4];
+ ULONG pTols[4];
+ USHORT nCount = InitColorArrays( pSrcCols, pDstCols, pTols );
+ BOOL pTrans[4];
+
+ // Falls keine Farben ausgewaehlt, kopieren wir nur das Mtf
+ if( !nCount )
+ aMtf = rMtf;
+ else
+ {
+ Color aCol;
+ long nVal;
+ long nTol;
+ long nR;
+ long nG;
+ long nB;
+ long* pMinR = new long[nCount];
+ long* pMaxR = new long[nCount];
+ long* pMinG = new long[nCount];
+ long* pMaxG = new long[nCount];
+ long* pMinB = new long[nCount];
+ long* pMaxB = new long[nCount];
+ USHORT i;
+ BOOL bReplace;
+
+ aMtf.SetPrefSize( rMtf.GetPrefSize() );
+ aMtf.SetPrefMapMode( rMtf.GetPrefMapMode() );
+
+ // Farbvergleichsarrays vorbereiten
+ for( i = 0; i < nCount; i++ )
+ {
+ nTol = ( pTols[i] * 255L ) / 100L;
+
+ nVal = ( (long) pSrcCols[i].GetRed() );
+ pMinR[i] = Max( nVal - nTol, 0L );
+ pMaxR[i] = Min( nVal + nTol, 255L );
+
+ nVal = ( (long) pSrcCols[i].GetGreen() );
+ pMinG[i] = Max( nVal - nTol, 0L );
+ pMaxG[i] = Min( nVal + nTol, 255L );
+
+ nVal = ( (long) pSrcCols[i].GetBlue() );
+ pMinB[i] = Max( nVal - nTol, 0L );
+ pMaxB[i] = Min( nVal + nTol, 255L );
+
+ pTrans[ i ] = ( pDstCols[ i ] == TRANSP_COL );
+ }
+
+ // Actions untersuchen und Farben ggf. ersetzen
+ for( ULONG nAct = 0UL, nActCount = rMtf.GetActionCount(); nAct < nActCount; nAct++ )
+ {
+ MetaAction* pAction = rMtf.GetAction( nAct );
+
+ bReplace = FALSE;
+
+ switch( pAction->GetType() )
+ {
+ case( META_PIXEL_ACTION ):
+ {
+ MetaPixelAction* pAct = (MetaPixelAction*) pAction;
+
+ aCol = pAct->GetColor();
+ TEST_COLS();
+
+ if( bReplace )
+ pAct = new MetaPixelAction( pAct->GetPoint(), aCol );
+ else
+ pAct->Duplicate();
+
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_LINECOLOR_ACTION ):
+ {
+ MetaLineColorAction* pAct = (MetaLineColorAction*) pAction;
+
+ aCol = pAct->GetColor();
+ TEST_COLS();
+
+ if( bReplace )
+ pAct = new MetaLineColorAction( aCol, !pTrans[ i ] );
+ else
+ pAct->Duplicate();
+
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_FILLCOLOR_ACTION ):
+ {
+ MetaFillColorAction* pAct = (MetaFillColorAction*) pAction;
+
+ aCol = pAct->GetColor();
+ TEST_COLS();
+
+ if( bReplace )
+ pAct = new MetaFillColorAction( aCol, !pTrans[ i ] );
+ else
+ pAct->Duplicate();
+
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_TEXTCOLOR_ACTION ):
+ {
+ MetaTextColorAction* pAct = (MetaTextColorAction*) pAction;
+
+ aCol = pAct->GetColor();
+ TEST_COLS();
+
+ if( bReplace )
+ pAct = new MetaTextColorAction( aCol );
+ else
+ pAct->Duplicate();
+
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_TEXTFILLCOLOR_ACTION ):
+ {
+ MetaTextFillColorAction* pAct = (MetaTextFillColorAction*) pAction;
+
+ aCol = pAct->GetColor();
+ TEST_COLS();
+
+ if( bReplace )
+ pAct = new MetaTextFillColorAction( aCol, !pTrans[ i ] );
+ else
+ pAct->Duplicate();
+
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_FONT_ACTION ):
+ {
+ MetaFontAction* pAct = (MetaFontAction*) pAction;
+ Font aFont( pAct->GetFont() );
+
+ aCol = aFont.GetColor();
+ TEST_COLS();
+
+ if( bReplace )
+ {
+ aFont.SetColor( aCol );
+ pAct = new MetaFontAction( aFont );
+ }
+ else
+ pAct->Duplicate();
+
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_WALLPAPER_ACTION ):
+ {
+ MetaWallpaperAction* pAct = (MetaWallpaperAction*) pAction;
+ Wallpaper aWall( pAct->GetWallpaper() );
+
+ aCol = aWall.GetColor();
+ TEST_COLS();
+
+ if( bReplace )
+ {
+ aWall.SetColor( aCol );
+ pAct = new MetaWallpaperAction( pAct->GetRect(), aWall );
+ }
+ else
+ pAct->Duplicate();
+
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_BMP_ACTION ):
+ {
+ MetaBmpAction* pAct = (MetaBmpAction*) pAction;
+ const Bitmap aBmp( Mask( pAct->GetBitmap() ).GetBitmap() );
+
+ pAct = new MetaBmpAction( pAct->GetPoint(), aBmp );
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_BMPSCALE_ACTION ):
+ {
+ MetaBmpScaleAction* pAct = (MetaBmpScaleAction*) pAction;
+ const Bitmap aBmp( Mask( pAct->GetBitmap() ).GetBitmap() );
+
+ pAct = new MetaBmpScaleAction( pAct->GetPoint(), pAct->GetSize(), aBmp );
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_BMPSCALEPART_ACTION ):
+ {
+ MetaBmpScalePartAction* pAct = (MetaBmpScalePartAction*) pAction;
+ const Bitmap aBmp( Mask( pAct->GetBitmap() ).GetBitmap() );
+
+ pAct = new MetaBmpScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(),
+ pAct->GetSrcPoint(), pAct->GetSrcSize(), aBmp );
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_BMPEX_ACTION ):
+ {
+ MetaBmpExAction* pAct = (MetaBmpExAction*) pAction;
+ const BitmapEx aBmpEx( Mask( pAct->GetBitmapEx() ).GetBitmapEx() );
+
+ pAct = new MetaBmpExAction( pAct->GetPoint(), aBmpEx );
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_BMPEXSCALE_ACTION ):
+ {
+ MetaBmpExScaleAction* pAct = (MetaBmpExScaleAction*) pAction;
+ const BitmapEx aBmpEx( Mask( pAct->GetBitmapEx() ).GetBitmapEx() );
+
+ pAct = new MetaBmpExScaleAction( pAct->GetPoint(), pAct->GetSize(), aBmpEx );
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ case( META_BMPEXSCALEPART_ACTION ):
+ {
+ MetaBmpExScalePartAction* pAct = (MetaBmpExScalePartAction*) pAction;
+ const BitmapEx aBmpEx( Mask( pAct->GetBitmapEx() ).GetBitmapEx() );
+
+ pAct = new MetaBmpExScalePartAction( pAct->GetDestPoint(), pAct->GetDestSize(),
+ pAct->GetSrcPoint(), pAct->GetSrcSize(), aBmpEx );
+ aMtf.AddAction( pAct );
+ }
+ break;
+
+ default:
+ {
+ pAction->Duplicate();
+ aMtf.AddAction( pAction );
+ }
+ break;
+ }
+ }
+
+ delete[] pMinR;
+ delete[] pMaxR;
+ delete[] pMinG;
+ delete[] pMaxG;
+ delete[] pMinB;
+ delete[] pMaxB;
+ }
+
+ LeaveWait();
+
+ return aMtf;
+}
+
+//-------------------------------------------------------------------------
+
+BitmapEx SvxBmpMask::ImpReplaceTransparency( const BitmapEx& rBmpEx, const Color& rColor )
+{
+ if( rBmpEx.IsTransparent() )
+ {
+ Bitmap aBmp( rBmpEx.GetBitmap() );
+ aBmp.Replace( rBmpEx.GetMask(), rColor );
+ return aBmp;
+ }
+ else
+ return rBmpEx;
+}
+
+//-------------------------------------------------------------------------
+
+Animation SvxBmpMask::ImpReplaceTransparency( const Animation& rAnim, const Color& rColor )
+{
+ Animation aAnimation( rAnim );
+ USHORT nAnimationCount = aAnimation.Count();
+
+ for( USHORT i = 0; i < nAnimationCount; i++ )
+ {
+ AnimationBitmap aAnimBmp( aAnimation.Get( i ) );
+ aAnimBmp.aBmpEx = ImpReplaceTransparency( aAnimBmp.aBmpEx, rColor );
+ aAnimation.Replace( aAnimBmp, i );
+ }
+
+ return aAnimation;
+}
+
+//-------------------------------------------------------------------------
+
+GDIMetaFile SvxBmpMask::ImpReplaceTransparency( const GDIMetaFile& rMtf, const Color& rColor )
+{
+ VirtualDevice aVDev;
+ GDIMetaFile aMtf;
+ const MapMode& rPrefMap = rMtf.GetPrefMapMode();
+ const Size& rPrefSize = rMtf.GetPrefSize();
+ const ULONG nActionCount = rMtf.GetActionCount();
+
+ aVDev.EnableOutput( FALSE );
+ aMtf.Record( &aVDev );
+ aMtf.SetPrefSize( rPrefSize );
+ aMtf.SetPrefMapMode( rPrefMap );
+ aVDev.SetLineColor( rColor );
+ aVDev.SetFillColor( rColor );
+
+ // Actions nacheinander abspielen; zuerst
+ // den gesamten Bereich auf die Ersatzfarbe setzen
+ aVDev.DrawRect( Rectangle( rPrefMap.GetOrigin(), rPrefSize ) );
+ for ( ULONG i = 0; i < nActionCount; i++ )
+ {
+ MetaAction* pAct = rMtf.GetAction( i );
+
+ pAct->Duplicate();
+ aMtf.AddAction( pAct );
+ }
+
+ aMtf.Stop();
+ aMtf.WindStart();
+
+ return aMtf;
+}
+
+//-------------------------------------------------------------------------
+
+Graphic SvxBmpMask::Mask( const Graphic& rGraphic )
+{
+ Graphic aGraphic( rGraphic );
+ const Color aReplColor( aLbColorTrans.GetSelectEntryColor() );
+
+ switch( rGraphic.GetType() )
+ {
+ case( GRAPHIC_BITMAP ):
+ {
+ if( rGraphic.IsAnimated() )
+ {
+ // Transparenz ersetzen?
+ if ( aCbxTrans.IsChecked() )
+ aGraphic = ImpReplaceTransparency( rGraphic.GetAnimation(), aReplColor );
+ else
+ aGraphic = ImpMask( rGraphic.GetAnimation() );
+ }
+ else
+ {
+ // Transparenz ersetzen?
+ if( aCbxTrans.IsChecked() )
+ {
+ if( aGraphic.IsTransparent() )
+ {
+ BitmapEx aBmpEx( ImpReplaceTransparency( aGraphic.GetBitmapEx(), aReplColor ) );
+ const Size aSize( aBmpEx.GetSizePixel() );
+
+ if( aSize.Width() && aSize.Height() )
+ aGraphic = aBmpEx;
+ }
+ }
+ else
+ {
+ Color pSrcCols[4];
+ Color pDstCols[4];
+ ULONG pTols[4];
+ USHORT nCount = InitColorArrays( pSrcCols, pDstCols, pTols );
+
+ if( nCount )
+ {
+ // erstmal alle Transparent-Farben setzen
+ for( USHORT i = 0; i < nCount; i++ )
+ {
+ // Haben wir eine Transparenzfarbe?
+ if( pDstCols[i] == TRANSP_COL )
+ {
+ BitmapEx aBmpEx( ImpMaskTransparent( aGraphic.GetBitmapEx(),
+ pSrcCols[ i ], pTols[ i ] ) );
+ const Size aSize( aBmpEx.GetSizePixel() );
+
+ if( aSize.Width() && aSize.Height() )
+ aGraphic = aBmpEx;
+ }
+ }
+
+ // jetzt noch einmal mit den normalen Farben ersetzen
+ Bitmap aBitmap( ImpMask( aGraphic.GetBitmap() ) );
+ Size aSize( aBitmap.GetSizePixel() );
+
+ if ( aSize.Width() && aSize.Height() )
+ {
+ if ( aGraphic.IsTransparent() )
+ aGraphic = Graphic( BitmapEx( aBitmap, aGraphic.GetBitmapEx().GetMask() ) );
+ else
+ aGraphic = aBitmap;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case( GRAPHIC_GDIMETAFILE ):
+ {
+ GDIMetaFile aMtf( aGraphic.GetGDIMetaFile() );
+
+ // Transparenz ersetzen?
+ if( aCbxTrans.IsChecked() )
+ aMtf = ImpReplaceTransparency( aMtf, aReplColor );
+ else
+ aMtf = ImpMask( aMtf );
+
+ Size aSize( aMtf.GetPrefSize() );
+ if ( aSize.Width() && aSize.Height() )
+ aGraphic = Graphic( aMtf );
+ else
+ aGraphic = rGraphic;
+ }
+ break;
+
+ default:
+ aGraphic = rGraphic;
+ break;
+ }
+
+ if( aGraphic != rGraphic )
+ {
+ aGraphic.SetPrefSize( rGraphic.GetPrefSize() );
+ aGraphic.SetPrefMapMode( rGraphic.GetPrefMapMode() );
+ }
+
+ return aGraphic;
+}
+
+//-------------------------------------------------------------------------
+
+BOOL SvxBmpMask::IsEyedropping() const
+{
+ return aTbxPipette.IsItemChecked( TBI_PIPETTE );
+}
+
+void SvxBmpMask::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ SfxDockingWindow::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ ApplyStyle();
+}
+
+void SvxBmpMask::ApplyStyle()
+{
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ aTbxPipette.SetItemImage( TBI_PIPETTE, bHighContrast ? maImgPipetteH : maImgPipette );
+}
+
+
+/** Set an accessible name for the source color check boxes. Without this
+ the lengthy description is read.
+*/
+void SvxBmpMask::SetAccessibleNames (void)
+{
+ String sSourceColor (BMP_RESID( RID_SVXDLG_BMPMASK_STR_SOURCECOLOR));
+ String sSourceColorN;
+
+ sSourceColorN = sSourceColor;
+ sSourceColorN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 1"));
+ aCbx1.SetAccessibleName (sSourceColorN);
+
+ sSourceColorN = sSourceColor;
+ sSourceColorN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 2"));
+ aCbx2.SetAccessibleName (sSourceColorN);
+
+ sSourceColorN = sSourceColor;
+ sSourceColorN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 3"));
+ aCbx3.SetAccessibleName (sSourceColorN);
+
+ sSourceColorN = sSourceColor;
+ sSourceColorN.AppendAscii (RTL_CONSTASCII_STRINGPARAM (" 4"));
+ aCbx4.SetAccessibleName (sSourceColorN);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/_contdlg.cxx b/svx/source/dialog/_contdlg.cxx
new file mode 100644
index 000000000000..3d4fecd285e7
--- /dev/null
+++ b/svx/source/dialog/_contdlg.cxx
@@ -0,0 +1,1161 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <vcl/wrkwin.hxx>
+#include <sot/factory.hxx>
+#include <tools/shl.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include <vcl/msgbox.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svtools/miscopt.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#define _SDR_NOITEMS
+#define _SDR_NOTOUCH
+#define _SDR_NOTRANSFORM
+#define _SDR_NOOBJECTS
+#define _SDR_NOVIEWMARKER
+#define _SDR_NODRAGMETHODS
+#define _SDR_NOUNDO
+#define _SDR_NOXOUTDEV
+#define _XOUTBMP_STATICS_ONLY
+
+#include <svx/dialmgr.hxx>
+#include "xoutbmp.hxx"
+#include <svx/dialogs.hrc>
+#include <svx/svxids.hrc>
+#include <svx/contdlg.hxx>
+#include "contimp.hxx"
+#include "contdlg.hrc"
+#include "contwnd.hxx"
+#include <svx/svdtrans.hxx>
+#include <svx/svdopath.hxx>
+#include "dlgutil.hxx"
+#include <vcl/svapp.hxx>
+
+/******************************************************************************/
+
+inline String GetUnitString( long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep )
+{
+ String aVal = UniString::CreateFromInt64( MetricField::ConvertValue( nVal_100, 2, MAP_100TH_MM, eFieldUnit ) );
+
+ while( aVal.Len() < 3 )
+ aVal.Insert( sal_Unicode('0'), 0 );
+
+ aVal.Insert( cSep, aVal.Len() - 2 );
+ aVal += sal_Unicode(' ');
+ aVal += SdrFormatter::GetUnitStr( eFieldUnit );
+
+ return aVal;
+}
+
+
+/******************************************************************************/
+
+
+SFX_IMPL_FLOATINGWINDOW( SvxContourDlgChildWindow, SID_CONTOUR_DLG );
+
+
+/******************************************************************************/
+
+
+/*************************************************************************
+|*
+|* ControllerItem
+|*
+\************************************************************************/
+
+SvxContourDlgItem::SvxContourDlgItem( USHORT _nId, SvxSuperContourDlg& rContourDlg, SfxBindings& rBindings ) :
+ SfxControllerItem ( _nId, rBindings ),
+ rDlg ( rContourDlg )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxContourDlgItem::StateChanged( USHORT nSID, SfxItemState /*eState*/, const SfxPoolItem* pItem )
+{
+ if ( pItem && ( SID_CONTOUR_EXEC == nSID ) )
+ {
+ const SfxBoolItem* pStateItem = PTR_CAST( SfxBoolItem, pItem );
+
+ DBG_ASSERT( pStateItem || pItem == 0, "SfxBoolItem erwartet");
+
+ rDlg.SetExecState( !pStateItem->GetValue() );
+ }
+}
+
+
+/******************************************************************************/
+
+
+/*************************************************************************
+|*
+|* Contour-Float
+|*
+\************************************************************************/
+
+SvxContourDlgChildWindow::SvxContourDlgChildWindow( Window* _pParent, USHORT nId,
+ SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( _pParent, nId )
+{
+ SvxSuperContourDlg* pDlg = new SvxSuperContourDlg( pBindings, this, _pParent, CONT_RESID( RID_SVXDLG_CONTOUR ) );
+ pWindow = pDlg;
+
+ if ( pInfo->nFlags & SFX_CHILDWIN_ZOOMIN )
+ pDlg->RollUp();
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+
+ pDlg->Initialize( pInfo );
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxContourDlgChildWindow::UpdateContourDlg( const Graphic& rGraphic, BOOL bGraphicLinked,
+ const PolyPolygon* pPolyPoly, void* pEditingObj )
+{
+ if ( SfxViewFrame::Current() &&
+ SfxViewFrame::Current()->HasChildWindow( SvxContourDlgChildWindow::GetChildWindowId() ) )
+ SVXCONTOURDLG()->Update( rGraphic, bGraphicLinked, pPolyPoly, pEditingObj );
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SvxContourDlg::SvxContourDlg( SfxBindings* _pBindings, SfxChildWindow* pCW,
+ Window* _pParent, const ResId& rResId ) :
+
+ SfxFloatingWindow ( _pBindings, pCW, _pParent, rResId )
+
+{
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SvxContourDlg::~SvxContourDlg()
+{
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+PolyPolygon SvxContourDlg::CreateAutoContour( const Graphic& rGraphic,
+ const Rectangle* pRect,
+ const ULONG nFlags )
+{
+ Bitmap aBmp;
+ ULONG nContourFlags = XOUTBMP_CONTOUR_HORZ;
+
+ if ( rGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+ if( rGraphic.IsAnimated() )
+ {
+ VirtualDevice aVDev;
+ MapMode aTransMap;
+ PolyPolygon aAnimPolyPoly;
+ const Animation aAnim( rGraphic.GetAnimation() );
+ const Size& rSizePix = aAnim.GetDisplaySizePixel();
+ const USHORT nCount = aAnim.Count();
+
+ if ( aVDev.SetOutputSizePixel( rSizePix ) )
+ {
+ aVDev.SetLineColor( Color( COL_BLACK ) );
+ aVDev.SetFillColor( Color( COL_BLACK ) );
+
+ for( USHORT i = 0; i < nCount; i++ )
+ {
+ const AnimationBitmap& rStepBmp = aAnim.Get( i );
+
+ // Polygonausgabe an die richtige Stelle schieben;
+ // dies ist der Offset des Teilbildes innerhalb
+ // der Gesamtanimation
+ aTransMap.SetOrigin( Point( rStepBmp.aPosPix.X(), rStepBmp.aPosPix.Y() ) );
+ aVDev.SetMapMode( aTransMap );
+ aVDev.DrawPolyPolygon( CreateAutoContour( rStepBmp.aBmpEx, pRect, nFlags ) );
+ }
+
+ aTransMap.SetOrigin( Point() );
+ aVDev.SetMapMode( aTransMap );
+ aBmp = aVDev.GetBitmap( Point(), rSizePix );
+ aBmp.Convert( BMP_CONVERSION_1BIT_THRESHOLD );
+ }
+ }
+ else if( rGraphic.IsTransparent() )
+ aBmp = rGraphic.GetBitmapEx().GetMask();
+ else
+ {
+ aBmp = rGraphic.GetBitmap();
+ nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT;
+ }
+ }
+ else if( rGraphic.GetType() != GRAPHIC_NONE )
+ {
+ const Graphic aTmpGrf( rGraphic.GetGDIMetaFile().GetMonochromeMtf( Color( COL_BLACK ) ) );
+ VirtualDevice aVDev;
+ Size aSizePix( aVDev.LogicToPixel( aTmpGrf.GetPrefSize(), aTmpGrf.GetPrefMapMode() ) );
+
+ if( aSizePix.Width() && aSizePix.Height() && ( aSizePix.Width() > 512 || aSizePix.Height() > 512 ) )
+ {
+ double fWH = (double) aSizePix.Width() / aSizePix.Height();
+
+ if( fWH <= 1.0 )
+ aSizePix.Width() = FRound( ( aSizePix.Height() = 512 ) * fWH );
+ else
+ aSizePix.Height() = FRound( ( aSizePix.Width() = 512 ) / fWH );
+ }
+
+ if( aVDev.SetOutputSizePixel( aSizePix ) )
+ {
+ const Point aPt;
+ aTmpGrf.Draw( &aVDev, aPt, aSizePix );
+ aBmp = aVDev.GetBitmap( aPt, aSizePix );
+ }
+
+ nContourFlags |= XOUTBMP_CONTOUR_EDGEDETECT;
+ }
+
+ aBmp.SetPrefSize( rGraphic.GetPrefSize() );
+ aBmp.SetPrefMapMode( rGraphic.GetPrefMapMode() );
+
+ return PolyPolygon( XOutBitmap::GetCountour( aBmp, nContourFlags, 128, pRect ) );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxContourDlg::ScaleContour( PolyPolygon& rContour, const Graphic& rGraphic,
+ const MapUnit eUnit, const Size& rDisplaySize )
+{
+ DBG_ASSERT( rGraphic.GetType() != GRAPHIC_NONE, "Graphic is not valid!" );
+
+ OutputDevice* pOutDev = Application::GetDefaultDevice();
+ const MapMode aDispMap( eUnit );
+ const MapMode aGrfMap( rGraphic.GetPrefMapMode() );
+ const Size aGrfSize( rGraphic.GetPrefSize() );
+ double fScaleX;
+ double fScaleY;
+ Size aOrgSize;
+ Point aNewPoint;
+ BOOL bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
+
+ if ( bPixelMap )
+ aOrgSize = pOutDev->PixelToLogic( aGrfSize, aDispMap );
+ else
+ aOrgSize = pOutDev->LogicToLogic( aGrfSize, aGrfMap, aDispMap );
+
+ if ( aOrgSize.Width() && aOrgSize.Height() )
+ {
+ fScaleX = (double) rDisplaySize.Width() / aOrgSize.Width();
+ fScaleY = (double) rDisplaySize.Height() / aOrgSize.Height();
+
+ for ( USHORT j = 0, nPolyCount = rContour.Count(); j < nPolyCount; j++ )
+ {
+ Polygon& rPoly = rContour[ j ];
+
+ for ( USHORT i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
+ {
+ if ( bPixelMap )
+ aNewPoint = pOutDev->PixelToLogic( rPoly[ i ], aDispMap );
+ else
+ aNewPoint = pOutDev->LogicToLogic( rPoly[ i ], aGrfMap, aDispMap );
+
+ rPoly[ i ] = Point( FRound( aNewPoint.X() * fScaleX ), FRound( aNewPoint.Y() * fScaleY ) );
+ }
+ }
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Durchschleifen an SuperClass; keine virt. Methoden, um
+|* bei IF-Aenderungen nicht inkompatibel zu werden
+|*
+\************************************************************************/
+
+void SvxContourDlg::SetExecState( BOOL bEnable )
+{
+ pSuperClass->SetExecState( bEnable );
+}
+
+void SvxContourDlg::SetGraphic( const Graphic& rGraphic )
+{
+ pSuperClass->SetGraphic( rGraphic );
+}
+
+void SvxContourDlg::SetGraphicLinked( BOOL bGraphicLinked )
+{
+ pSuperClass->SetGraphicLinked( bGraphicLinked );
+}
+
+const Graphic& SvxContourDlg::GetGraphic() const
+{
+ return pSuperClass->GetGraphic();
+}
+
+BOOL SvxContourDlg::IsGraphicChanged() const
+{
+ return pSuperClass->IsGraphicChanged();
+}
+
+void SvxContourDlg::SetPolyPolygon( const PolyPolygon& rPolyPoly )
+{
+ pSuperClass->SetPolyPolygon( rPolyPoly );
+}
+
+PolyPolygon SvxContourDlg::GetPolyPolygon()
+{
+ return pSuperClass->GetPolyPolygon( TRUE );
+}
+
+void SvxContourDlg::SetEditingObject( void* pObj )
+{
+ pSuperClass->SetEditingObject( pObj );
+}
+
+const void* SvxContourDlg::GetEditingObject() const
+{
+ return pSuperClass->GetEditingObject();
+}
+
+void SvxContourDlg::Update( const Graphic& rGraphic, BOOL bGraphicLinked,
+ const PolyPolygon* pPolyPoly, void* pEditingObj )
+{
+ pSuperClass->UpdateGraphic( rGraphic, bGraphicLinked, pPolyPoly, pEditingObj );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SvxSuperContourDlg::SvxSuperContourDlg( SfxBindings *_pBindings, SfxChildWindow *pCW,
+ Window* _pParent, const ResId& rResId ) :
+ SvxContourDlg ( _pBindings, pCW, _pParent, rResId ),
+ pCheckObj ( NULL ),
+ aContourItem ( SID_CONTOUR_EXEC, *this, *_pBindings ),
+ aTbx1 ( this, ResId( TBX1, *rResId.GetResMgr() ) ),
+ aMtfTolerance ( this, ResId( MTF_TOLERANCE, *rResId.GetResMgr() ) ),
+ aContourWnd ( this, ResId( CTL_CONTOUR, *rResId.GetResMgr() ) ),
+ aStbStatus ( this, WB_BORDER | WB_3DLOOK | WB_LEFT ),
+ nGrfChanged ( 0UL ),
+ bExecState ( FALSE ),
+ bGraphicLinked ( FALSE ),
+ maImageList ( SVX_RES( CD_IMAPDLG ) ),
+ maImageListH ( SVX_RES( CDH_IMAPDLG ) )
+{
+ ApplyImageList();
+
+ FreeResource();
+
+ SvxContourDlg::SetSuperClass( *this );
+
+ aContourWnd.SetMousePosLink( LINK( this, SvxSuperContourDlg, MousePosHdl ) );
+ aContourWnd.SetGraphSizeLink( LINK( this, SvxSuperContourDlg, GraphSizeHdl ) );
+ aContourWnd.SetUpdateLink( LINK( this, SvxSuperContourDlg, StateHdl ) );
+ aContourWnd.SetPipetteHdl( LINK( this, SvxSuperContourDlg, PipetteHdl ) );
+ aContourWnd.SetPipetteClickHdl( LINK( this, SvxSuperContourDlg, PipetteClickHdl ) );
+ aContourWnd.SetWorkplaceClickHdl( LINK( this, SvxSuperContourDlg, WorkplaceClickHdl ) );
+
+ const Size aTbxSize( aTbx1.CalcWindowSizePixel() );
+ Point aPos( aTbx1.GetPosPixel() );
+ SvtMiscOptions aMiscOptions;
+
+ aMiscOptions.AddListenerLink( LINK( this, SvxSuperContourDlg, MiscHdl ) );
+
+ aTbx1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
+ aTbx1.SetSizePixel( aTbxSize );
+ aTbx1.SetSelectHdl( LINK( this, SvxSuperContourDlg, Tbx1ClickHdl ) );
+
+ aPos.X() += aTbxSize.Width() + LogicToPixel( Size( 3, 0 ), MapMode( MAP_APPFONT ) ).Width();
+ aMtfTolerance.SetPosPixel( aPos );
+ aMtfTolerance.SetValue( 10L );
+
+ SetMinOutputSizePixel( aLastSize = GetOutputSizePixel() );
+
+ aStbStatus.InsertItem( 1, 130, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
+ aStbStatus.InsertItem( 2, 10 + GetTextWidth( String::CreateFromAscii( " 9999,99 cm / 9999,99 cm " ) ), SIB_CENTER | SIB_IN );
+ aStbStatus.InsertItem( 3, 10 + GetTextWidth( String::CreateFromAscii( " 9999,99 cm x 9999,99 cm " ) ), SIB_CENTER | SIB_IN );
+ aStbStatus.InsertItem( 4, 20, SIB_CENTER | SIB_IN );
+
+ Resize();
+
+ aUpdateTimer.SetTimeout( 100 );
+ aUpdateTimer.SetTimeoutHdl( LINK( this, SvxSuperContourDlg, UpdateHdl ) );
+
+ aCreateTimer.SetTimeout( 50 );
+ aCreateTimer.SetTimeoutHdl( LINK( this, SvxSuperContourDlg, CreateHdl ) );
+}
+
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+\************************************************************************/
+
+SvxSuperContourDlg::~SvxSuperContourDlg()
+{
+}
+
+
+/*************************************************************************
+|*
+|* Resize-Methode
+|*
+\************************************************************************/
+
+void SvxSuperContourDlg::Resize()
+{
+ SfxFloatingWindow::Resize();
+
+ Size aMinSize( GetMinOutputSizePixel() );
+ Size aNewSize( GetOutputSizePixel() );
+
+ if ( aNewSize.Height() >= aMinSize.Height() )
+ {
+ Size _aSize( aStbStatus.GetSizePixel() );
+ Point aPoint( 0, aNewSize.Height() - _aSize.Height() );
+
+ // StatusBar positionieren
+ aStbStatus.SetPosSizePixel( aPoint, Size( aNewSize.Width(), _aSize.Height() ) );
+ aStbStatus.Show();
+
+ // EditWindow positionieren
+ _aSize.Width() = aNewSize.Width() - 18;
+ _aSize.Height() = aPoint.Y() - aContourWnd.GetPosPixel().Y() - 6;
+ aContourWnd.SetSizePixel( _aSize );
+
+ aLastSize = aNewSize;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Close-Methode
+|*
+\************************************************************************/
+
+BOOL SvxSuperContourDlg::Close()
+{
+ BOOL bRet = TRUE;
+
+ if ( aTbx1.IsItemEnabled( TBI_APPLY ) )
+ {
+ QueryBox aQBox( this, WB_YES_NO_CANCEL | WB_DEF_YES,
+ String( CONT_RESID( STR_CONTOURDLG_MODIFY ) ) );
+ const long nRet = aQBox.Execute();
+
+ if ( nRet == RET_YES )
+ {
+ SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, TRUE );
+ GetBindings().GetDispatcher()->Execute(
+ SID_CONTOUR_EXEC, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
+ }
+ else if ( nRet == RET_CANCEL )
+ bRet = FALSE;
+ }
+
+ return( bRet ? SfxFloatingWindow::Close() : FALSE );
+}
+
+
+/*************************************************************************
+|*
+|* Enabled oder disabled alle Controls
+|*
+\************************************************************************/
+
+void SvxSuperContourDlg::SetExecState( BOOL bEnable )
+{
+ bExecState = bEnable;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxSuperContourDlg::SetGraphic( const Graphic& rGraphic )
+{
+ aUndoGraphic = aRedoGraphic = Graphic();
+ aGraphic = rGraphic;
+ nGrfChanged = 0UL;
+ aContourWnd.SetGraphic( aGraphic );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxSuperContourDlg::SetPolyPolygon( const PolyPolygon& rPolyPoly )
+{
+ DBG_ASSERT( aContourWnd.GetGraphic().GetType() != GRAPHIC_NONE, "Graphic must've been set first!" );
+
+ PolyPolygon aPolyPoly( rPolyPoly );
+ const MapMode aMap100( MAP_100TH_MM );
+ const MapMode aGrfMap( aGraphic.GetPrefMapMode() );
+ OutputDevice* pOutDev = Application::GetDefaultDevice();
+ BOOL bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
+
+ for ( USHORT j = 0, nPolyCount = aPolyPoly.Count(); j < nPolyCount; j++ )
+ {
+ Polygon& rPoly = aPolyPoly[ j ];
+
+ for ( USHORT i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
+ {
+ Point& rPt = rPoly[ i ];
+
+ if ( !bPixelMap )
+ rPt = pOutDev->LogicToPixel( rPt, aGrfMap );
+
+ rPt = pOutDev->PixelToLogic( rPt, aMap100 );
+ }
+ }
+
+ aContourWnd.SetPolyPolygon( aPolyPoly );
+ aContourWnd.GetSdrModel()->SetChanged( sal_True );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+PolyPolygon SvxSuperContourDlg::GetPolyPolygon( BOOL bRescaleToGraphic )
+{
+ PolyPolygon aRetPolyPoly( aContourWnd.GetPolyPolygon() );
+
+ if ( bRescaleToGraphic )
+ {
+ const MapMode aMap100( MAP_100TH_MM );
+ const MapMode aGrfMap( aGraphic.GetPrefMapMode() );
+ OutputDevice* pOutDev = Application::GetDefaultDevice();
+ BOOL bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
+
+ for ( USHORT j = 0, nPolyCount = aRetPolyPoly.Count(); j < nPolyCount; j++ )
+ {
+ Polygon& rPoly = aRetPolyPoly[ j ];
+
+ for ( USHORT i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
+ {
+ Point& rPt = rPoly[ i ];
+
+ rPt = pOutDev->LogicToPixel( rPt, aMap100 );
+
+ if ( !bPixelMap )
+ rPt = pOutDev->PixelToLogic( rPt, aGrfMap );
+ }
+ }
+ }
+
+ return aRetPolyPoly;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxSuperContourDlg::UpdateGraphic( const Graphic& rGraphic, BOOL _bGraphicLinked,
+ const PolyPolygon* pPolyPoly, void* pEditingObj )
+{
+ aUpdateGraphic = rGraphic;
+ bUpdateGraphicLinked = _bGraphicLinked;
+ pUpdateEditingObject = pEditingObj;
+
+ if ( pPolyPoly )
+ aUpdatePolyPoly = *pPolyPoly;
+ else
+ aUpdatePolyPoly = PolyPolygon();
+
+ aUpdateTimer.Start();
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL SvxSuperContourDlg::IsUndoPossible() const
+{
+ return aUndoGraphic.GetType() != GRAPHIC_NONE;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL SvxSuperContourDlg::IsRedoPossible() const
+{
+ return aRedoGraphic.GetType() != GRAPHIC_NONE;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxSuperContourDlg::DoAutoCreate()
+{
+ aCreateTimer.Start();
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxSuperContourDlg::ReducePoints( const long nTol )
+{
+ PolyPolygon aPolyPoly( GetPolyPolygon( FALSE ) );
+
+ if ( aPolyPoly.Count() )
+ {
+ const MapMode aMapMode( MAP_100TH_MM );
+ const long nTol2 = nTol * nTol;
+ Polygon& rPoly = aPolyPoly[ 0 ];
+ OutputDevice* pOutDev = Application::GetDefaultDevice();
+ Point aPtPix;
+ const USHORT nSize = rPoly.GetSize();
+ USHORT nCounter = 0;
+
+ if ( nSize )
+ aPtPix = pOutDev->LogicToPixel( rPoly[ 0 ], aMapMode );
+
+ for( USHORT i = 1; i < nSize; i++ )
+ {
+ const Point& rNewPt = rPoly[ i ];
+ const Point aNewPtPix( pOutDev->LogicToPixel( rNewPt, aMapMode ) );
+
+ const long nDistX = aNewPtPix.X() - aPtPix.X();
+ const long nDistY = aNewPtPix.Y() - aPtPix.Y();
+
+ if( ( nDistX * nDistX + nDistY * nDistY ) >= nTol2 )
+ {
+ rPoly[ ++nCounter ] = rNewPt;
+ aPtPix = aNewPtPix;
+ }
+ }
+
+ rPoly.SetSize( nCounter );
+ aContourWnd.SetPolyPolygon( aPolyPoly );
+ aContourWnd.GetSdrModel()->SetChanged( sal_True );
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Click-Hdl fuer ToolBox
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxSuperContourDlg, Tbx1ClickHdl, ToolBox*, pTbx )
+{
+ USHORT nNewItemId = pTbx->GetCurItemId();
+
+ switch( pTbx->GetCurItemId() )
+ {
+ case( TBI_APPLY ):
+ {
+ SfxBoolItem aBoolItem( SID_CONTOUR_EXEC, TRUE );
+ GetBindings().GetDispatcher()->Execute(
+ SID_CONTOUR_EXEC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
+ }
+ break;
+
+ case( TBI_WORKPLACE ):
+ {
+ if ( aTbx1.IsItemChecked( TBI_WORKPLACE ) )
+ {
+ QueryBox aQBox( this, WB_YES_NO | WB_DEF_NO, String( CONT_RESID( STR_CONTOURDLG_WORKPLACE ) ) );
+
+ if ( !aContourWnd.IsContourChanged() || ( aQBox.Execute() == RET_YES ) )
+ aContourWnd.SetWorkplaceMode( TRUE );
+ else
+ aTbx1.CheckItem( TBI_WORKPLACE, FALSE );
+ }
+ else
+ aContourWnd.SetWorkplaceMode( FALSE );
+ }
+ break;
+
+ case( TBI_SELECT ):
+ {
+ pTbx->CheckItem( nNewItemId, TRUE );
+ aContourWnd.SetEditMode( TRUE );
+ }
+ break;
+
+ case( TBI_RECT ):
+ {
+ pTbx->CheckItem( nNewItemId, TRUE );
+ aContourWnd.SetObjKind( OBJ_RECT );
+ }
+ break;
+
+ case( TBI_CIRCLE ):
+ {
+ pTbx->CheckItem( nNewItemId, TRUE );
+ aContourWnd.SetObjKind( OBJ_CIRC );
+
+ }
+ break;
+
+ case( TBI_POLY ):
+ {
+ pTbx->CheckItem( nNewItemId, TRUE );
+ aContourWnd.SetObjKind( OBJ_POLY );
+ }
+ break;
+
+ case( TBI_FREEPOLY ):
+ {
+ pTbx->CheckItem( nNewItemId, TRUE );
+ aContourWnd.SetObjKind( OBJ_FREEFILL );
+ }
+ break;
+
+ case( TBI_POLYEDIT ):
+ aContourWnd.SetPolyEditMode( pTbx->IsItemChecked( TBI_POLYEDIT ) ? SID_BEZIER_MOVE : 0 );
+ break;
+
+ case( TBI_POLYMOVE ):
+ aContourWnd.SetPolyEditMode( SID_BEZIER_MOVE );
+ break;
+
+ case( TBI_POLYINSERT ):
+ aContourWnd.SetPolyEditMode( SID_BEZIER_INSERT );
+ break;
+
+ case( TBI_POLYDELETE ):
+ aContourWnd.GetSdrView()->DeleteMarkedPoints();
+ break;
+
+ case( TBI_UNDO ):
+ {
+ nGrfChanged = nGrfChanged ? nGrfChanged - 1 : 0UL;
+ aRedoGraphic = aGraphic;
+ aGraphic = aUndoGraphic;
+ aUndoGraphic = Graphic();
+ aContourWnd.SetGraphic( aGraphic, FALSE );
+ }
+ break;
+
+ case( TBI_REDO ):
+ {
+ nGrfChanged++;
+ aUndoGraphic = aGraphic;
+ aGraphic = aRedoGraphic;
+ aRedoGraphic = Graphic();
+ aContourWnd.SetGraphic( aGraphic, FALSE );
+ }
+ break;
+
+ case( TBI_AUTOCONTOUR ):
+ aCreateTimer.Start();
+ break;
+
+ case( TBI_PIPETTE ):
+ {
+ BOOL bPipette = aTbx1.IsItemChecked( TBI_PIPETTE );
+
+ if ( !bPipette )
+ aStbStatus.Invalidate();
+ else if ( bGraphicLinked )
+ {
+ QueryBox aQBox( this, WB_YES_NO | WB_DEF_YES, String( CONT_RESID( STR_CONTOURDLG_LINKED ) ) );
+
+ if ( aQBox.Execute() != RET_YES )
+ {
+ aTbx1.CheckItem( TBI_PIPETTE, bPipette = FALSE );
+ aStbStatus.Invalidate();
+ }
+ }
+
+ aContourWnd.SetPipetteMode( bPipette );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return 0L;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxSuperContourDlg, MousePosHdl, ContourWindow*, pWnd )
+{
+ String aStr;
+ const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
+ const Point& rMousePos = pWnd->GetMousePos();
+ LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
+ const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
+
+ aStr.Assign( GetUnitString( rMousePos.X(), eFieldUnit, cSep ) );
+ aStr.Append( String::CreateFromAscii( " / " ) );
+ aStr.Append( GetUnitString( rMousePos.Y(), eFieldUnit, cSep ) );
+
+ aStbStatus.SetItemText( 2, aStr );
+
+ return 0L;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxSuperContourDlg, GraphSizeHdl, ContourWindow*, pWnd )
+{
+ String aStr;
+ const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
+ const Size& rSize = pWnd->GetGraphicSize();
+ LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
+ const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
+
+ aStr.Assign( GetUnitString( rSize.Width(), eFieldUnit, cSep ) );
+ aStr.Append( String::CreateFromAscii( " x " ) );
+ aStr.Append( GetUnitString( rSize.Height(), eFieldUnit, cSep ) );
+
+ aStbStatus.SetItemText( 3, aStr );
+
+ return 0L;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxSuperContourDlg, UpdateHdl, Timer*, EMPTYARG )
+{
+ aUpdateTimer.Stop();
+
+ if ( pUpdateEditingObject != pCheckObj )
+ {
+ if( !GetEditingObject() )
+ aContourWnd.GrabFocus();
+
+ SetGraphic( aUpdateGraphic );
+ SetPolyPolygon( aUpdatePolyPoly );
+ SetEditingObject( pUpdateEditingObject );
+ bGraphicLinked = bUpdateGraphicLinked;
+
+ aUpdateGraphic = Graphic();
+ aUpdatePolyPoly = PolyPolygon();
+ bUpdateGraphicLinked = FALSE;
+
+ aContourWnd.GetSdrModel()->SetChanged( sal_False );
+ }
+
+ GetBindings().Invalidate( SID_CONTOUR_EXEC );
+
+ return 0L;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxSuperContourDlg, CreateHdl, Timer*, EMPTYARG )
+{
+ aCreateTimer.Stop();
+
+ const Rectangle aWorkRect = aContourWnd.LogicToPixel( aContourWnd.GetWorkRect(), MapMode( MAP_100TH_MM ) );
+ const Graphic& rGraphic = aContourWnd.GetGraphic();
+ const BOOL bValid = aWorkRect.Left() != aWorkRect.Right() && aWorkRect.Top() != aWorkRect.Bottom();
+
+ EnterWait();
+ SetPolyPolygon( CreateAutoContour( rGraphic, bValid ? &aWorkRect : NULL ) );
+ LeaveWait();
+
+ return 0L;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxSuperContourDlg, StateHdl, ContourWindow*, pWnd )
+{
+ const SdrObject* pObj = pWnd->GetSelectedSdrObject();
+ const SdrView* pView = pWnd->GetSdrView();
+ const BOOL bPolyEdit = ( pObj != NULL ) && pObj->ISA( SdrPathObj );
+ const BOOL bDrawEnabled = !( bPolyEdit && aTbx1.IsItemChecked( TBI_POLYEDIT ) );
+ const BOOL bPipette = aTbx1.IsItemChecked( TBI_PIPETTE );
+ const BOOL bWorkplace = aTbx1.IsItemChecked( TBI_WORKPLACE );
+ const BOOL bDontHide = !( bPipette || bWorkplace );
+ const BOOL bBitmap = pWnd->GetGraphic().GetType() == GRAPHIC_BITMAP;
+
+ aTbx1.EnableItem( TBI_APPLY, bDontHide && bExecState && pWnd->IsChanged() );
+
+ aTbx1.EnableItem( TBI_WORKPLACE, !bPipette && bDrawEnabled );
+
+ aTbx1.EnableItem( TBI_SELECT, bDontHide && bDrawEnabled );
+ aTbx1.EnableItem( TBI_RECT, bDontHide && bDrawEnabled );
+ aTbx1.EnableItem( TBI_CIRCLE, bDontHide && bDrawEnabled );
+ aTbx1.EnableItem( TBI_POLY, bDontHide && bDrawEnabled );
+ aTbx1.EnableItem( TBI_FREEPOLY, bDontHide && bDrawEnabled );
+
+ aTbx1.EnableItem( TBI_POLYEDIT, bDontHide && bPolyEdit );
+ aTbx1.EnableItem( TBI_POLYMOVE, bDontHide && !bDrawEnabled );
+ aTbx1.EnableItem( TBI_POLYINSERT, bDontHide && !bDrawEnabled );
+ aTbx1.EnableItem( TBI_POLYDELETE, bDontHide && !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() );
+
+ aTbx1.EnableItem( TBI_AUTOCONTOUR, bDontHide && bDrawEnabled );
+ aTbx1.EnableItem( TBI_PIPETTE, !bWorkplace && bDrawEnabled && bBitmap );
+
+ aTbx1.EnableItem( TBI_UNDO, bDontHide && IsUndoPossible() );
+ aTbx1.EnableItem( TBI_REDO, bDontHide && IsRedoPossible() );
+
+ if ( bPolyEdit )
+ {
+ USHORT nId = 0;
+
+ switch( pWnd->GetPolyEditMode() )
+ {
+ case( SID_BEZIER_MOVE ): nId = TBI_POLYMOVE; break;
+ case( SID_BEZIER_INSERT ): nId = TBI_POLYINSERT; break;
+
+ default:
+ break;
+ }
+
+ aTbx1.CheckItem( nId, TRUE );
+ }
+ else
+ {
+ aTbx1.CheckItem( TBI_POLYEDIT, FALSE );
+ aTbx1.CheckItem( TBI_POLYMOVE, TRUE );
+ aTbx1.CheckItem( TBI_POLYINSERT, FALSE );
+ pWnd->SetPolyEditMode( 0 );
+ }
+
+ return 0L;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxSuperContourDlg, PipetteHdl, ContourWindow*, pWnd )
+{
+ const Color& rOldLineColor = aStbStatus.GetLineColor();
+ const Color& rOldFillColor = aStbStatus.GetFillColor();
+
+ Rectangle aRect( aStbStatus.GetItemRect( 4 ) );
+ const Color& rColor = pWnd->GetPipetteColor();
+
+ aStbStatus.SetLineColor( rColor );
+ aStbStatus.SetFillColor( rColor );
+
+ aRect.Left() += 4;
+ aRect.Top() += 4;
+ aRect.Right() -= 4;
+ aRect.Bottom() -= 4;
+
+ aStbStatus.DrawRect( aRect );
+
+ aStbStatus.SetLineColor( rOldLineColor );
+ aStbStatus.SetFillColor( rOldFillColor );
+
+ return 0L;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxSuperContourDlg, PipetteClickHdl, ContourWindow*, pWnd )
+{
+ if ( pWnd->IsClickValid() )
+ {
+ Bitmap aMask;
+ const Color& rColor = pWnd->GetPipetteColor();
+
+ EnterWait();
+
+ if( aGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+ Bitmap aBmp( aGraphic.GetBitmap() );
+ const long nTol = static_cast<long>(aMtfTolerance.GetValue() * 255L / 100L);
+
+ aMask = aBmp.CreateMask( rColor, nTol );
+
+ if( aGraphic.IsTransparent() )
+ aMask.CombineSimple( aGraphic.GetBitmapEx().GetMask(), BMP_COMBINE_OR );
+
+ if( !!aMask )
+ {
+ QueryBox aQBox( this, WB_YES_NO | WB_DEF_YES, String( CONT_RESID( STR_CONTOURDLG_NEWPIPETTE ) ) );
+ BOOL bNewContour;
+
+ aRedoGraphic = Graphic();
+ aUndoGraphic = aGraphic;
+ aGraphic = Graphic( BitmapEx( aBmp, aMask ) );
+ nGrfChanged++;
+
+ bNewContour = ( aQBox.Execute() == RET_YES );
+ pWnd->SetGraphic( aGraphic, bNewContour );
+
+ if( bNewContour )
+ aCreateTimer.Start();
+ }
+ }
+
+ LeaveWait();
+ }
+
+ aTbx1.CheckItem( TBI_PIPETTE, FALSE );
+ pWnd->SetPipetteMode( FALSE );
+ aStbStatus.Invalidate();
+
+ return 0L;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxSuperContourDlg, WorkplaceClickHdl, ContourWindow*, pWnd )
+{
+ aTbx1.CheckItem( TBI_WORKPLACE, FALSE );
+ aTbx1.CheckItem( TBI_SELECT, TRUE );
+ pWnd->SetWorkplaceMode( FALSE );
+
+ return 0L;
+}
+
+void SvxSuperContourDlg::ApplyImageList()
+{
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ ImageList& rImgLst = bHighContrast ? maImageListH : maImageList;
+
+ aTbx1.SetImageList( rImgLst );
+}
+
+void SvxSuperContourDlg::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ SfxFloatingWindow::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ ApplyImageList();
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxSuperContourDlg, MiscHdl, void*, EMPTYARG )
+{
+ SvtMiscOptions aMiscOptions;
+ aTbx1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
+
+ return 0L;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/bmpmask.hrc b/svx/source/dialog/bmpmask.hrc
new file mode 100644
index 000000000000..79c9b60d3ada
--- /dev/null
+++ b/svx/source/dialog/bmpmask.hrc
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#define RID_SVXDLG_BMPMASK (RID_SVX_BMPMASK_START)
+#define RID_SVXDLG_BMPMASK_STR_TRANSP (RID_SVX_BMPMASK_START + 1)
+#define RID_SVXDLG_BMPMASK_STR_SOURCECOLOR (RID_SVX_BMPMASK_START + 2)
+
+#define GRP_Q 1
+#define CTR_PIPETTE 1
+#define CBX_1 1
+#define CBX_2 4
+#define CBX_3 3
+#define CBX_4 2
+#define CBX_TRANS 5
+#define QCOL_1 2
+#define QCOL_2 5
+#define QCOL_3 4
+#define QCOL_4 3
+#define SP_1 2
+#define SP_2 4
+#define SP_3 1
+#define SP_4 3
+#define GRP_D 2
+#define TBX_PIPETTE 1
+#define TBI_PIPETTE 1
+#define WND_PIPETTE 10
+#define BTN_EXEC 1
+#define LB_1 1
+#define LB_2 2
+#define LB_3 3
+#define LB_4 4
+#define LB_TRANS 5
+#define FT_1 1
+#define FT_2 2
+#define FT_3 3
+#define IMG_PIPETTE 11
+#define IMG_PIPETTE_H 12
+
+
diff --git a/svx/source/dialog/bmpmask.src b/svx/source/dialog/bmpmask.src
new file mode 100644
index 000000000000..4b93fe924c5c
--- /dev/null
+++ b/svx/source/dialog/bmpmask.src
@@ -0,0 +1,358 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include <svx/svxids.hrc>
+#include <svx/dialogs.hrc>
+#include "bmpmask.hrc"
+#include "helpid.hrc"
+
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+
+
+ // RID_SVXDLG_BMPMASK ----------------------------------------------------
+DockingWindow RID_SVXDLG_BMPMASK
+{
+ HelpId = SID_BMPMASK ;
+ OutputSize = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 163 , 126 ) ;
+ Sizeable = FALSE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ Dockable = TRUE ;
+ EnableResizing = TRUE ;
+ FixedLine GRP_Q
+ {
+ Pos = MAP_APPFONT ( 6 , 26 ) ;
+ Size = MAP_APPFONT ( 151 , 8 ) ;
+ Text [ en-US ] = "Colors" ;
+ };
+ FixedText FT_1
+ {
+ Pos = MAP_APPFONT ( 12 , 37 ) ;
+ Size = MAP_APPFONT ( 44 , 8 ) ;
+ Text [ en-US ] = "Source color" ;
+ };
+ FixedText FT_2
+ {
+ Pos = MAP_APPFONT ( 58 , 37 ) ;
+ Size = MAP_APPFONT ( 34 , 8 ) ;
+ Text [ en-US ] = "Tolerance" ;
+ };
+ FixedText FT_3
+ {
+ Pos = MAP_APPFONT ( 93 , 37 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "Replace with..." ;
+ };
+
+ // line 1
+
+ CheckBox CBX_1
+ {
+ Pos = MAP_APPFONT ( 12 , 50 ) ;
+ Size = MAP_APPFONT ( 10 , 10 ) ;
+ TabStop = TRUE ;
+ };
+ Control QCOL_1
+ {
+ HelpId = HID_BMPMASK_CTL_QCOL_1 ;
+ Pos = MAP_APPFONT ( 24 , 48 ) ;
+ Size = MAP_APPFONT ( 24 , 12 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ };
+ MetricField SP_1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 48 ) ;
+ Size = MAP_APPFONT ( 29 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 99 ;
+ Last = 99 ;
+ SpinSize = 1 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = "%" ;
+ };
+ ListBox LB_1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 93 , 48 ) ;
+ Size = MAP_APPFONT ( 64 , 75 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+
+ // line 2
+
+ CheckBox CBX_2
+ {
+ Pos = MAP_APPFONT ( 12 , 65 ) ;
+ Size = MAP_APPFONT ( 10 , 10 ) ;
+ TabStop = TRUE ;
+ };
+ Control QCOL_2
+ {
+ HelpId = HID_BMPMASK_CTL_QCOL_1 ;
+ Pos = MAP_APPFONT ( 24 , 63 ) ;
+ Size = MAP_APPFONT ( 24 , 12 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ };
+ MetricField SP_2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 63 ) ;
+ Size = MAP_APPFONT ( 29 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 99 ;
+ Last = 99 ;
+ SpinSize = 1 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = "%" ;
+ };
+ ListBox LB_2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 93 , 63 ) ;
+ Size = MAP_APPFONT ( 64 , 75 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+
+ // line 3
+
+ CheckBox CBX_3
+ {
+ Pos = MAP_APPFONT ( 12 , 80 ) ;
+ Size = MAP_APPFONT ( 10 , 10 ) ;
+ TabStop = TRUE ;
+ };
+ Control QCOL_3
+ {
+ HelpId = HID_BMPMASK_CTL_QCOL_1 ;
+ Pos = MAP_APPFONT ( 24 , 78 ) ;
+ Size = MAP_APPFONT ( 24 , 12 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ };
+ MetricField SP_3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58, 78 ) ;
+ Size = MAP_APPFONT ( 29 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 99 ;
+ Last = 99 ;
+ SpinSize = 1 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = "%" ;
+ };
+ ListBox LB_3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 93 , 78 ) ;
+ Size = MAP_APPFONT ( 64 , 75 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+
+ // Line 4
+
+ CheckBox CBX_4
+ {
+ Pos = MAP_APPFONT ( 12 , 95 ) ;
+ Size = MAP_APPFONT ( 10 , 10 ) ;
+ TabStop = TRUE ;
+ };
+ Control QCOL_4
+ {
+ HelpId = HID_BMPMASK_CTL_QCOL_1 ;
+ Pos = MAP_APPFONT ( 24 , 93 ) ;
+ Size = MAP_APPFONT ( 24 , 12 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ };
+ MetricField SP_4
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 93 ) ;
+ Size = MAP_APPFONT ( 29 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 99 ;
+ Last = 99 ;
+ SpinSize = 1 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = "%" ;
+ };
+ ListBox LB_4
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 93 , 93 ) ;
+ Size = MAP_APPFONT ( 64 , 75 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+
+ CheckBox CBX_TRANS
+ {
+ Pos = MAP_APPFONT ( 12 , 110 ) ;
+ Size = MAP_APPFONT ( 71 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Tr~ansparency" ;
+ };
+
+ PushButton BTN_EXEC
+ {
+ Pos = MAP_APPFONT ( 93 , 6 ) ;
+ Size = MAP_APPFONT ( 64 , 14 ) ;
+ Text [ en-US ] = "~Replace" ;
+ };
+
+ ListBox LB_TRANS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 93 , 108 ) ;
+ Size = MAP_APPFONT ( 64 , 75 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ ToolBox TBX_PIPETTE
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 7 ) ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ Identifier = TBI_PIPETTE ;
+ HelpId = HID_BMPMASK_TBI_PIPETTE ;
+ ItemImage = Image
+ {
+ ImageBitmap = Bitmap { File = "sc10350.bmp" ; };
+ MASKCOLOR
+ };
+ Text [ en-US ] = "Eyedropper" ;
+ };
+ };
+ };
+ Control WND_PIPETTE
+ {
+ HelpId = HID_BMPMASK_CTL_PIPETTE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 22 , 6 ) ;
+ Size = MAP_APPFONT ( 43 , 14 ) ;
+ };
+ Text [ en-US ] = "Eyedropper" ;
+
+ Image IMG_PIPETTE
+ {
+ ImageBitmap = Bitmap { File = "sc10350.bmp" ; };
+ MASKCOLOR
+ };
+
+ Image IMG_PIPETTE_H
+ {
+ ImageBitmap = Bitmap { File = "sc10350_h.bmp" ; };
+ MASKCOLOR
+ };
+};
+
+String RID_SVXDLG_BMPMASK_STR_TRANSP
+{
+ Text [ en-US ] = "Transparent";
+};
+
+String RID_SVXDLG_BMPMASK_STR_SOURCECOLOR
+{
+ // This string is used by the eyedropper dialog to denote a color in an image
+ // that will be replaced by another color.
+ Text [ en-US ] = "Source Color";
+};
+
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx
new file mode 100644
index 000000000000..69370001a0ee
--- /dev/null
+++ b/svx/source/dialog/charmap.cxx
@@ -0,0 +1,896 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <stdio.h>
+
+#define _SVX_CHARMAP_CXX_
+#include <vcl/svapp.hxx>
+#include <svtools/colorcfg.hxx>
+
+#include <rtl/textenc.h>
+#include <svx/ucsubset.hxx>
+
+#include <svx/dialogs.hrc>
+
+#include <svx/charmap.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/svxdlg.hxx>
+
+#include "charmapacc.hxx"
+#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <comphelper/types.hxx>
+#include <svl/itemset.hxx>
+
+#include "rtl/ustrbuf.hxx"
+
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+
+// -----------------------------------------------------------------------
+sal_uInt32& SvxShowCharSet::getSelectedChar()
+{
+ static sal_uInt32 cSelectedChar = ' '; // keeps selected character over app livetime
+ return cSelectedChar;
+}
+
+// class SvxShowCharSet ==================================================
+
+#define SBWIDTH 16
+
+SvxShowCharSet::SvxShowCharSet( Window* pParent, const ResId& rResId ) :
+ Control( pParent, rResId )
+ ,m_pAccessible(NULL)
+ ,aVscrollSB( this, WB_VERT)
+{
+ nSelectedIndex = -1; // TODO: move into init list when it is no longer static
+
+ aOrigSize = GetOutputSizePixel();
+ aOrigPos = GetPosPixel();
+
+ SetStyle( GetStyle() | WB_CLIPCHILDREN );
+ aVscrollSB.SetScrollHdl( LINK( this, SvxShowCharSet, VscrollHdl ) );
+ aVscrollSB.EnableDrag( TRUE );
+ // other settings like aVscroll depend on selected font => see SetFont
+
+ bDrag = FALSE;
+ InitSettings( TRUE, TRUE );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::GetFocus()
+{
+ Control::GetFocus();
+ SelectIndex( nSelectedIndex, TRUE );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::LoseFocus()
+{
+ Control::LoseFocus();
+ SelectIndex( nSelectedIndex, FALSE );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::StateChanged( StateChangedType nType )
+{
+ if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
+ InitSettings( TRUE, FALSE );
+ else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
+ InitSettings( FALSE, TRUE );
+
+ Control::StateChanged( nType );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS )
+ && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ InitSettings( TRUE, TRUE );
+ else
+ Control::DataChanged( rDCEvt );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( rMEvt.IsLeft() )
+ {
+ if ( rMEvt.GetClicks() == 1 )
+ {
+ GrabFocus();
+ bDrag = TRUE;
+ CaptureMouse();
+
+ int nIndex = PixelToMapIndex( rMEvt.GetPosPixel() );
+ SelectIndex( nIndex );
+ }
+
+ if ( !(rMEvt.GetClicks() % 2) )
+ aDoubleClkHdl.Call( this );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if ( bDrag && rMEvt.IsLeft() )
+ {
+ // released mouse over character map
+ if ( Rectangle(Point(), GetOutputSize()).IsInside(rMEvt.GetPosPixel()))
+ aSelectHdl.Call( this );
+ ReleaseMouse();
+ bDrag = FALSE;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::MouseMove( const MouseEvent& rMEvt )
+{
+ if ( rMEvt.IsLeft() && bDrag )
+ {
+ Point aPos = rMEvt.GetPosPixel();
+ Size aSize = GetSizePixel();
+
+ if ( aPos.X() < 0 )
+ aPos.X() = 0;
+ else if ( aPos.X() > aSize.Width()-5 )
+ aPos.X() = aSize.Width()-5;
+ if ( aPos.Y() < 0 )
+ aPos.Y() = 0;
+ else if ( aPos.Y() > aSize.Height()-5 )
+ aPos.Y() = aSize.Height()-5;
+
+ int nIndex = PixelToMapIndex( aPos );
+ SelectIndex( nIndex );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::Command( const CommandEvent& rCEvt )
+{
+ if( !HandleScrollCommand( rCEvt, 0, &aVscrollSB ) )
+ Control::Command( rCEvt );
+}
+
+// -----------------------------------------------------------------------------
+
+USHORT SvxShowCharSet::GetRowPos(USHORT _nPos) const
+{
+ return _nPos / COLUMN_COUNT ;
+}
+
+// -----------------------------------------------------------------------------
+
+USHORT SvxShowCharSet::GetColumnPos(USHORT _nPos) const
+{
+ return _nPos % COLUMN_COUNT ;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxShowCharSet::FirstInView( void ) const
+{
+ int nIndex = 0;
+ if( aVscrollSB.IsVisible() )
+ nIndex += aVscrollSB.GetThumbPos() * COLUMN_COUNT;
+ return nIndex;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxShowCharSet::LastInView( void ) const
+{
+ ULONG nIndex = FirstInView();
+ nIndex += ROW_COUNT * COLUMN_COUNT - 1;
+ ULONG nCompare = sal::static_int_cast<ULONG>( maFontCharMap.GetCharCount() - 1 );
+ if( nIndex > nCompare )
+ nIndex = nCompare;
+ return nIndex;
+}
+
+// -----------------------------------------------------------------------
+
+inline Point SvxShowCharSet::MapIndexToPixel( int nIndex ) const
+{
+ const int nBase = FirstInView();
+ int x = ((nIndex - nBase) % COLUMN_COUNT) * nX;
+ int y = ((nIndex - nBase) / COLUMN_COUNT) * nY;
+ return Point( x, y );
+}
+// -----------------------------------------------------------------------------
+
+int SvxShowCharSet::PixelToMapIndex( const Point& point) const
+{
+ int nBase = FirstInView();
+ return (nBase + (point.X()/nX) + (point.Y()/nY) * COLUMN_COUNT);
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyCode aCode = rKEvt.GetKeyCode();
+
+ if( aCode.GetModifier() )
+ {
+ Control::KeyInput( rKEvt );
+ return;
+ }
+
+ int tmpSelected = nSelectedIndex;
+
+ switch ( aCode.GetCode() )
+ {
+ case KEY_SPACE:
+ aSelectHdl.Call( this );
+ break;
+ case KEY_LEFT:
+ --tmpSelected;
+ break;
+ case KEY_RIGHT:
+ ++tmpSelected;
+ break;
+ case KEY_UP:
+ tmpSelected -= COLUMN_COUNT;
+ break;
+ case KEY_DOWN:
+ tmpSelected += COLUMN_COUNT;
+ break;
+ case KEY_PAGEUP:
+ tmpSelected -= ROW_COUNT * COLUMN_COUNT;
+ break;
+ case KEY_PAGEDOWN:
+ tmpSelected += ROW_COUNT * COLUMN_COUNT;
+ break;
+ case KEY_HOME:
+ tmpSelected = 0;
+ break;
+ case KEY_END:
+ tmpSelected = maFontCharMap.GetCharCount() - 1;
+ break;
+ case KEY_TAB: // some fonts have a character at these unicode control codes
+ case KEY_ESCAPE:
+ case KEY_RETURN:
+ Control::KeyInput( rKEvt );
+ tmpSelected = - 1; // mark as invalid
+ break;
+ default:
+ {
+ sal_UCS4 cChar = rKEvt.GetCharCode();
+ sal_UCS4 cNext = maFontCharMap.GetNextChar( cChar - 1 );
+ tmpSelected = maFontCharMap.GetIndexFromChar( cNext );
+ if( tmpSelected < 0 || (cChar != cNext) )
+ {
+ Control::KeyInput( rKEvt );
+ tmpSelected = - 1; // mark as invalid
+ }
+ }
+ }
+
+ if ( tmpSelected >= 0 )
+ {
+ SelectIndex( tmpSelected, TRUE );
+ aPreSelectHdl.Call( this );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::Paint( const Rectangle& )
+{
+ DrawChars_Impl( FirstInView(), LastInView() );
+}
+// -----------------------------------------------------------------------------
+void SvxShowCharSet::DeSelect()
+{
+ DrawChars_Impl(nSelectedIndex,nSelectedIndex);
+}
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::DrawChars_Impl( int n1, int n2 )
+{
+ if( n1 > LastInView() || n2 < FirstInView() )
+ return;
+
+ Size aOutputSize = GetOutputSizePixel();
+ if( aVscrollSB.IsVisible() )
+ aOutputSize.setWidth( aOutputSize.Width() - SBWIDTH );
+
+ int i;
+ for ( i = 1; i < COLUMN_COUNT; ++i )
+ DrawLine( Point( nX * i, 0 ), Point( nX * i, aOutputSize.Height() ) );
+ for ( i = 1; i < ROW_COUNT; ++i )
+ DrawLine( Point( 0, nY * i ), Point( aOutputSize.Width(), nY * i ) );
+
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ const Color aWindowTextColor( rStyleSettings.GetFieldTextColor() );
+ Color aHighlightColor( rStyleSettings.GetHighlightColor() );
+ Color aHighlightTextColor( rStyleSettings.GetHighlightTextColor() );
+ Color aFaceColor( rStyleSettings.GetFaceColor() );
+ Color aLightColor( rStyleSettings.GetLightColor() );
+ Color aShadowColor( rStyleSettings.GetShadowColor() );
+
+ int nTextHeight = GetTextHeight();
+ Rectangle aBoundRect;
+ for( i = n1; i <= n2; ++i )
+ {
+ Point pix = MapIndexToPixel( i );
+ int x = pix.X();
+ int y = pix.Y();
+
+ rtl::OUStringBuffer buf;
+ buf.appendUtf32( maFontCharMap.GetCharFromIndex( i ) );
+ String aCharStr(buf.makeStringAndClear());
+ int nTextWidth = GetTextWidth(aCharStr);
+ int tx = x + (nX - nTextWidth + 1) / 2;
+ int ty = y + (nY - nTextHeight + 1) / 2;
+ Point aPointTxTy( tx, ty );
+
+ // adjust position before it gets out of bounds
+ if( GetTextBoundRect( aBoundRect, aCharStr ) && !aBoundRect.IsEmpty() )
+ {
+ // zero advance width => use ink width to center glyph
+ if( !nTextWidth )
+ {
+ aPointTxTy.X() = x - aBoundRect.Left()
+ + (nX - aBoundRect.GetWidth() + 1) / 2;
+ }
+
+ aBoundRect += aPointTxTy;
+
+ // shift back vertically if needed
+ int nYLDelta = aBoundRect.Top() - y;
+ int nYHDelta = (y + nY) - aBoundRect.Bottom();
+ if( nYLDelta <= 0 )
+ aPointTxTy.Y() -= nYLDelta - 1;
+ else if( nYHDelta <= 0 )
+ aPointTxTy.Y() += nYHDelta - 1;
+
+ // shift back horizontally if needed
+ int nXLDelta = aBoundRect.Left() - x;
+ int nXHDelta = (x + nX) - aBoundRect.Right();
+ if( nXLDelta <= 0 )
+ aPointTxTy.X() -= nXLDelta - 1;
+ else if( nXHDelta <= 0 )
+ aPointTxTy.X() += nXHDelta - 1;
+ }
+
+ Color aTextCol = GetTextColor();
+ if ( i != nSelectedIndex )
+ {
+ SetTextColor( aWindowTextColor );
+ DrawText( aPointTxTy, aCharStr );
+ }
+ else
+ {
+ Color aLineCol = GetLineColor();
+ Color aFillCol = GetFillColor();
+ SetLineColor();
+ Point aPointUL( x + 1, y + 1 );
+ if( HasFocus() )
+ {
+ SetFillColor( aHighlightColor );
+ DrawRect( Rectangle( aPointUL, Size(nX-1,nY-1) ) );
+
+ SetTextColor( aHighlightTextColor );
+ DrawText( aPointTxTy, aCharStr );
+ }
+ else
+ {
+ SetFillColor( aFaceColor );
+ DrawRect( Rectangle( aPointUL, Size( nX-1, nY-1) ) );
+
+ SetLineColor( aLightColor );
+ DrawLine( aPointUL, Point( x+nX-1, y+1) );
+ DrawLine( aPointUL, Point( x+1, y+nY-1) );
+
+ SetLineColor( aShadowColor );
+ DrawLine( Point( x+1, y+nY-1), Point( x+nX-1, y+nY-1) );
+ DrawLine( Point( x+nX-1, y+nY-1), Point( x+nX-1, y+1) );
+
+ DrawText( aPointTxTy, aCharStr );
+ }
+ SetLineColor( aLineCol );
+ SetFillColor( aFillCol );
+ }
+ SetTextColor( aTextCol );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::InitSettings( BOOL bForeground, BOOL bBackground )
+{
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ if ( bForeground )
+ {
+ Color aTextColor( rStyleSettings.GetDialogTextColor() );
+
+ if ( IsControlForeground() )
+ aTextColor = GetControlForeground();
+ SetTextColor( aTextColor );
+ }
+
+ if ( bBackground )
+ {
+ if ( IsControlBackground() )
+ SetBackground( GetControlBackground() );
+ else
+ SetBackground( rStyleSettings.GetWindowColor() );
+ }
+
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+sal_UCS4 SvxShowCharSet::GetSelectCharacter() const
+{
+ if( nSelectedIndex >= 0 )
+ getSelectedChar() = maFontCharMap.GetCharFromIndex( nSelectedIndex );
+ return getSelectedChar();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::SetFont( const Font& rFont )
+{
+ // save last selected unicode
+ if( nSelectedIndex >= 0 )
+ getSelectedChar() = maFontCharMap.GetCharFromIndex( nSelectedIndex );
+
+ Font aFont = rFont;
+ aFont.SetWeight( WEIGHT_LIGHT );
+ aFont.SetAlign( ALIGN_TOP );
+ int nFontHeight = (aOrigSize.Height() - 5) * 2 / (3 * ROW_COUNT);
+ aFont.SetSize( PixelToLogic( Size( 0, nFontHeight ) ) );
+ aFont.SetTransparent( TRUE );
+ Control::SetFont( aFont );
+ GetFontCharMap( maFontCharMap );
+
+ // hide scrollbar when there is nothing to scroll
+ BOOL bNeedVscroll = (maFontCharMap.GetCharCount() > ROW_COUNT*COLUMN_COUNT);
+
+ nX = (aOrigSize.Width() - (bNeedVscroll ? SBWIDTH : 0)) / COLUMN_COUNT;
+ nY = aOrigSize.Height() / ROW_COUNT;
+
+ if( bNeedVscroll)
+ {
+ aVscrollSB.SetPosSizePixel( nX * COLUMN_COUNT, 0, SBWIDTH, nY * ROW_COUNT );
+ aVscrollSB.SetRangeMin( 0 );
+ int nLastRow = (maFontCharMap.GetCharCount() - 1 + COLUMN_COUNT) / COLUMN_COUNT;
+ aVscrollSB.SetRangeMax( nLastRow );
+ aVscrollSB.SetPageSize( ROW_COUNT-1 );
+ aVscrollSB.SetVisibleSize( ROW_COUNT );
+ }
+
+ // restore last selected unicode
+ int nMapIndex = maFontCharMap.GetIndexFromChar( getSelectedChar() );
+ SelectIndex( nMapIndex );
+
+ // rearrange CharSet element in sync with nX- and nY-multiples
+ Size aNewSize( nX * COLUMN_COUNT + (bNeedVscroll ? SBWIDTH : 0), nY * ROW_COUNT );
+ Point aNewPos = aOrigPos + Point( (aOrigSize.Width() - aNewSize.Width()) / 2, 0 );
+ SetPosPixel( aNewPos );
+ SetOutputSizePixel( aNewSize );
+
+ aVscrollSB.Show( bNeedVscroll );
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::SelectIndex( int nNewIndex, BOOL bFocus )
+{
+ if( nNewIndex < 0 )
+ {
+ // need to scroll see closest unicode
+ sal_uInt32 cPrev = maFontCharMap.GetPrevChar( getSelectedChar() );
+ int nMapIndex = maFontCharMap.GetIndexFromChar( cPrev );
+ int nNewPos = nMapIndex / COLUMN_COUNT;
+ aVscrollSB.SetThumbPos( nNewPos );
+ nSelectedIndex = bFocus ? nMapIndex+1 : -1;
+ Invalidate();
+ Update();
+ }
+ else if( nNewIndex < FirstInView() )
+ {
+ // need to scroll up to see selected item
+ int nOldPos = aVscrollSB.GetThumbPos();
+ int nDelta = (FirstInView() - nNewIndex + COLUMN_COUNT-1) / COLUMN_COUNT;
+ aVscrollSB.SetThumbPos( nOldPos - nDelta );
+ nSelectedIndex = nNewIndex;
+ Invalidate();
+ if( nDelta )
+ Update();
+ }
+ else if( nNewIndex > LastInView() )
+ {
+ // need to scroll down to see selected item
+ int nOldPos = aVscrollSB.GetThumbPos();
+ int nDelta = (nNewIndex - LastInView() + COLUMN_COUNT) / COLUMN_COUNT;
+ aVscrollSB.SetThumbPos( nOldPos + nDelta );
+ if( nNewIndex < maFontCharMap.GetCharCount() )
+ {
+ nSelectedIndex = nNewIndex;
+ Invalidate();
+ }
+ if( nOldPos != aVscrollSB.GetThumbPos() )
+ {
+ Invalidate();
+ Update();
+ }
+ }
+ else
+ {
+ // remove highlighted view
+ Color aLineCol = GetLineColor();
+ Color aFillCol = GetFillColor();
+ SetLineColor();
+ SetFillColor( GetBackground().GetColor() );
+
+ Point aOldPixel = MapIndexToPixel( nSelectedIndex );
+ aOldPixel.Move( +1, +1);
+ DrawRect( Rectangle( aOldPixel, Size( nX-1, nY-1 ) ) );
+ SetLineColor( aLineCol );
+ SetFillColor( aFillCol );
+
+ int nOldIndex = nSelectedIndex;
+ nSelectedIndex = nNewIndex;
+ DrawChars_Impl( nOldIndex, nOldIndex );
+ DrawChars_Impl( nNewIndex, nNewIndex );
+ }
+
+ if( nSelectedIndex >= 0 )
+ {
+ getSelectedChar() = maFontCharMap.GetCharFromIndex( nSelectedIndex );
+ if( m_pAccessible )
+ {
+ ::svx::SvxShowCharSetItem* pItem = ImplGetItem(nSelectedIndex);
+ m_pAccessible->fireEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), makeAny(pItem->GetAccessible()) ); // this call asures that m_pItem is set
+
+ OSL_ENSURE(pItem->m_pItem,"No accessible created!");
+ Any aOldAny, aNewAny;
+ aNewAny <<= AccessibleStateType::FOCUSED;
+ pItem->m_pItem->fireEvent( AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny );
+
+ aNewAny <<= AccessibleStateType::SELECTED;
+ pItem->m_pItem->fireEvent( AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny );
+ }
+ }
+
+
+ aHighHdl.Call( this );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxShowCharSet::SelectCharacter( sal_UCS4 cNew, BOOL bFocus )
+{
+ // get next available char of current font
+ sal_UCS4 cNext = maFontCharMap.GetNextChar( cNew - 1 );
+
+ int nMapIndex = maFontCharMap.GetIndexFromChar( cNext );
+ SelectIndex( nMapIndex, bFocus );
+ if( !bFocus )
+ {
+ // move selected item to top row if not in focus
+ aVscrollSB.SetThumbPos( nMapIndex / COLUMN_COUNT );
+ Invalidate();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxShowCharSet, VscrollHdl, ScrollBar *, EMPTYARG )
+{
+ if( nSelectedIndex < FirstInView() )
+ {
+ SelectIndex( FirstInView() + (nSelectedIndex % COLUMN_COUNT) );
+ }
+ else if( nSelectedIndex > LastInView() )
+ {
+ if( m_pAccessible )
+ {
+ ::com::sun::star::uno::Any aOldAny, aNewAny;
+ int nLast = LastInView();
+ for ( ; nLast != nSelectedIndex; ++nLast)
+ {
+ aOldAny <<= ImplGetItem(nLast)->GetAccessible();
+ m_pAccessible ->fireEvent( AccessibleEventId::CHILD, aOldAny, aNewAny );
+ }
+ }
+ SelectIndex( (LastInView() - COLUMN_COUNT + 1) + (nSelectedIndex % COLUMN_COUNT) );
+ }
+
+ Invalidate();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SvxShowCharSet::~SvxShowCharSet()
+{
+ if ( m_pAccessible )
+ ReleaseAccessible();
+}
+// -----------------------------------------------------------------------------
+void SvxShowCharSet::ReleaseAccessible()
+{
+ m_aItems.clear();
+ m_pAccessible = NULL;
+ m_xAccessible = NULL;
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< XAccessible > SvxShowCharSet::CreateAccessible()
+{
+ OSL_ENSURE(!m_pAccessible,"Accessible already created!");
+ m_pAccessible = new ::svx::SvxShowCharSetVirtualAcc(this);
+ m_xAccessible = m_pAccessible;
+ return m_xAccessible;
+}
+// -----------------------------------------------------------------------------
+::svx::SvxShowCharSetItem* SvxShowCharSet::ImplGetItem( int _nPos )
+{
+ ItemsMap::iterator aFind = m_aItems.find(_nPos);
+ if ( aFind == m_aItems.end() )
+ {
+ OSL_ENSURE(m_pAccessible,"Who wants to create a child of my table without a parent?");
+ aFind = m_aItems.insert(ItemsMap::value_type(_nPos,new ::svx::SvxShowCharSetItem(*this,m_pAccessible->getTable(),sal::static_int_cast< USHORT >(_nPos)))).first;
+ rtl::OUStringBuffer buf;
+ buf.appendUtf32( maFontCharMap.GetCharFromIndex( _nPos ) );
+ aFind->second->maText = buf.makeStringAndClear();
+ Point pix = MapIndexToPixel( _nPos );
+ aFind->second->maRect = Rectangle( Point( pix.X() + 1, pix.Y() + 1 ), Size(nX-1,nY-1) );
+ }
+
+ return aFind->second;
+}
+// -----------------------------------------------------------------------------
+void SvxShowCharSet::ImplFireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue )
+{
+ if( m_pAccessible )
+ m_pAccessible->fireEvent( nEventId, rOldValue, rNewValue );
+}
+// -----------------------------------------------------------------------------
+ScrollBar* SvxShowCharSet::getScrollBar()
+{
+ return &aVscrollSB;
+}
+// -----------------------------------------------------------------------
+sal_Int32 SvxShowCharSet::getMaxCharCount() const
+{
+ return maFontCharMap.GetCharCount();
+}
+
+
+// class SubsetMap =======================================================
+// TODO: should be moved into Font Attributes stuff
+// we let it mature here though because it is currently the only use
+
+SubsetMap::SubsetMap( const FontCharMap* pFontCharMap )
+: Resource( SVX_RES(RID_SUBSETMAP) )
+{
+ InitList();
+ ApplyCharMap( pFontCharMap );
+ FreeResource();
+}
+
+const Subset* SubsetMap::GetNextSubset( bool bFirst ) const
+{
+ if( bFirst )
+ maSubsetIterator = maSubsets.begin();
+ if( maSubsetIterator == maSubsets.end() )
+ return NULL;
+ const Subset* s = &*(maSubsetIterator++);
+ return s;
+}
+
+const Subset* SubsetMap::GetSubsetByUnicode( sal_UCS4 cChar ) const
+{
+ // TODO: is it worth to avoid a linear search?
+ for( const Subset* s = GetNextSubset( true ); s; s = GetNextSubset( false ) )
+ if( (s->GetRangeMin() <= cChar) && (cChar <= s->GetRangeMax()) )
+ return s;
+ return NULL;
+}
+
+inline Subset::Subset( sal_UCS4 nMin, sal_UCS4 nMax, int resId)
+: mnRangeMin(nMin), mnRangeMax(nMax), maRangeName( SVX_RES(resId) )
+{}
+
+void SubsetMap::InitList()
+{
+ static SubsetList aAllSubsets;
+ static bool bInit = true;
+ if( bInit )
+ {
+ bInit = false;
+
+ // TODO: eventually merge or split unicode subranges
+ // a "native writer" should decide for his subsets
+ aAllSubsets.push_back( Subset( 0x0020, 0x007F, RID_SUBSETSTR_BASIC_LATIN ) );
+ aAllSubsets.push_back( Subset( 0x0080, 0x00FF, RID_SUBSETSTR_LATIN_1 ) );
+ aAllSubsets.push_back( Subset( 0x0100, 0x017F, RID_SUBSETSTR_LATIN_EXTENDED_A ) );
+ aAllSubsets.push_back( Subset( 0x0180, 0x024F, RID_SUBSETSTR_LATIN_EXTENDED_B ) );
+ aAllSubsets.push_back( Subset( 0x0250, 0x02AF, RID_SUBSETSTR_IPA_EXTENSIONS ) );
+ aAllSubsets.push_back( Subset( 0x02B0, 0x02FF, RID_SUBSETSTR_SPACING_MODIFIERS ) );
+ aAllSubsets.push_back( Subset( 0x0300, 0x036F, RID_SUBSETSTR_COMB_DIACRITICAL ) );
+ aAllSubsets.push_back( Subset( 0x0370, 0x03FF, RID_SUBSETSTR_BASIC_GREEK ) );
+ // aAllSubsets.push_back( Subset( 0x03D0, 0x03F3, RID_SUBSETSTR_GREEK_SYMS_COPTIC ) );
+ aAllSubsets.push_back( Subset( 0x0400, 0x04FF, RID_SUBSETSTR_CYRILLIC ) );
+ aAllSubsets.push_back( Subset( 0x0530, 0x058F, RID_SUBSETSTR_ARMENIAN ) );
+ aAllSubsets.push_back( Subset( 0x0590, 0x05FF, RID_SUBSETSTR_BASIC_HEBREW ) );
+ // aAllSubsets.push_back( Subset( 0x0591, 0x05C4, RID_SUBSETSTR_HEBREW_EXTENDED ) );
+ aAllSubsets.push_back( Subset( 0x0600, 0x065F, RID_SUBSETSTR_BASIC_ARABIC ) );
+ aAllSubsets.push_back( Subset( 0x0660, 0x06FF, RID_SUBSETSTR_ARABIC_EXTENDED ) );
+ aAllSubsets.push_back( Subset( 0x0700, 0x074F, RID_SUBSETSTR_SYRIAC ) );
+ aAllSubsets.push_back( Subset( 0x0780, 0x07BF, RID_SUBSETSTR_THAANA ) );
+ aAllSubsets.push_back( Subset( 0x0900, 0x097F, RID_SUBSETSTR_DEVANAGARI ) );
+ aAllSubsets.push_back( Subset( 0x0980, 0x09FF, RID_SUBSETSTR_BENGALI ) );
+ aAllSubsets.push_back( Subset( 0x0A00, 0x0A7F, RID_SUBSETSTR_GURMUKHI ) );
+ aAllSubsets.push_back( Subset( 0x0A80, 0x0AFF, RID_SUBSETSTR_GUJARATI ) );
+ aAllSubsets.push_back( Subset( 0x0B00, 0x0B7F, RID_SUBSETSTR_ORIYA ) );
+ aAllSubsets.push_back( Subset( 0x0B80, 0x0BFF, RID_SUBSETSTR_TAMIL ) );
+ aAllSubsets.push_back( Subset( 0x0C00, 0x0C7F, RID_SUBSETSTR_TELUGU ) );
+ aAllSubsets.push_back( Subset( 0x0C80, 0x0CFF, RID_SUBSETSTR_KANNADA ) );
+ aAllSubsets.push_back( Subset( 0x0D00, 0x0D7F, RID_SUBSETSTR_MALAYALAM ) );
+ aAllSubsets.push_back( Subset( 0x0D80, 0x0DFF, RID_SUBSETSTR_SINHALA ) );
+ aAllSubsets.push_back( Subset( 0x0E00, 0x0E7F, RID_SUBSETSTR_THAI ) );
+ aAllSubsets.push_back( Subset( 0x0E80, 0x0EFF, RID_SUBSETSTR_LAO ) );
+ aAllSubsets.push_back( Subset( 0x0F00, 0x0FBF, RID_SUBSETSTR_TIBETAN ) );
+ aAllSubsets.push_back( Subset( 0x1000, 0x109F, RID_SUBSETSTR_MYANMAR ) );
+ aAllSubsets.push_back( Subset( 0x10A0, 0x10FF, RID_SUBSETSTR_BASIC_GEORGIAN ) );
+ // aAllSubsets.push_back( Subset( 0x10A0, 0x10C5, RID_SUBSETSTR_GEORGIAN_EXTENDED ) );
+ aAllSubsets.push_back( Subset( 0x1100, 0x11FF, RID_SUBSETSTR_HANGUL_JAMO ) );
+ aAllSubsets.push_back( Subset( 0x1200, 0x137F, RID_SUBSETSTR_ETHIOPIC ) );
+ aAllSubsets.push_back( Subset( 0x13A0, 0x13FF, RID_SUBSETSTR_CHEROKEE ) );
+ aAllSubsets.push_back( Subset( 0x1400, 0x167F, RID_SUBSETSTR_CANADIAN_ABORIGINAL ) );
+ aAllSubsets.push_back( Subset( 0x1680, 0x169F, RID_SUBSETSTR_OGHAM ) );
+ aAllSubsets.push_back( Subset( 0x16A0, 0x16F0, RID_SUBSETSTR_RUNIC ) );
+ aAllSubsets.push_back( Subset( 0x1700, 0x171F, RID_SUBSETSTR_TAGALOG ) );
+ aAllSubsets.push_back( Subset( 0x1720, 0x173F, RID_SUBSETSTR_HANUNOO ) );
+ aAllSubsets.push_back( Subset( 0x1740, 0x175F, RID_SUBSETSTR_BUHID ) );
+ aAllSubsets.push_back( Subset( 0x1760, 0x177F, RID_SUBSETSTR_TAGBANWA ) );
+ aAllSubsets.push_back( Subset( 0x1780, 0x17FF, RID_SUBSETSTR_KHMER ) );
+ aAllSubsets.push_back( Subset( 0x1800, 0x18AF, RID_SUBSETSTR_MONGOLIAN ) );
+ aAllSubsets.push_back( Subset( 0x1E00, 0x1EFF, RID_SUBSETSTR_LATIN_EXTENDED_ADDS ) );
+ aAllSubsets.push_back( Subset( 0x1F00, 0x1FFF, RID_SUBSETSTR_GREEK_EXTENDED ) );
+
+ aAllSubsets.push_back( Subset( 0x2000, 0x206F, RID_SUBSETSTR_GENERAL_PUNCTUATION ) );
+ aAllSubsets.push_back( Subset( 0x2070, 0x209F, RID_SUBSETSTR_SUB_SUPER_SCRIPTS ) );
+ aAllSubsets.push_back( Subset( 0x20A0, 0x20CF, RID_SUBSETSTR_CURRENCY_SYMBOLS ) );
+ aAllSubsets.push_back( Subset( 0x20D0, 0x20FF, RID_SUBSETSTR_COMB_DIACRITIC_SYMS ) );
+ aAllSubsets.push_back( Subset( 0x2100, 0x214F, RID_SUBSETSTR_LETTERLIKE_SYMBOLS ) );
+ aAllSubsets.push_back( Subset( 0x2150, 0x218F, RID_SUBSETSTR_NUMBER_FORMS ) );
+ aAllSubsets.push_back( Subset( 0x2190, 0x21FF, RID_SUBSETSTR_ARROWS ) );
+ aAllSubsets.push_back( Subset( 0x2200, 0x22FF, RID_SUBSETSTR_MATH_OPERATORS ) );
+ aAllSubsets.push_back( Subset( 0x2300, 0x23FF, RID_SUBSETSTR_MISC_TECHNICAL ) );
+ aAllSubsets.push_back( Subset( 0x2400, 0x243F, RID_SUBSETSTR_CONTROL_PICTURES ) );
+ aAllSubsets.push_back( Subset( 0x2440, 0x245F, RID_SUBSETSTR_OPTICAL_CHAR_REC ) );
+ aAllSubsets.push_back( Subset( 0x2460, 0x24FF, RID_SUBSETSTR_ENCLOSED_ALPHANUM ) );
+ aAllSubsets.push_back( Subset( 0x2500, 0x257F, RID_SUBSETSTR_BOX_DRAWING ) );
+ aAllSubsets.push_back( Subset( 0x2580, 0x259F, RID_SUBSETSTR_BLOCK_ELEMENTS ) );
+ aAllSubsets.push_back( Subset( 0x25A0, 0x25FF, RID_SUBSETSTR_GEOMETRIC_SHAPES ) );
+ aAllSubsets.push_back( Subset( 0x2600, 0x26FF, RID_SUBSETSTR_MISC_DINGBATS ) );
+ aAllSubsets.push_back( Subset( 0x2700, 0x27BF, RID_SUBSETSTR_DINGBATS ) );
+
+ aAllSubsets.push_back( Subset( 0x27C0, 0x27FF, RID_SUBSETSTR_MISC_MATH_SYMS_A ) );
+ aAllSubsets.push_back( Subset( 0x27F0, 0x27FF, RID_SUBSETSTR_SUPPL_ARROWS_A ) );
+ aAllSubsets.push_back( Subset( 0x2800, 0x28FF, RID_SUBSETSTR_BRAILLE_PATTERNS ) );
+ aAllSubsets.push_back( Subset( 0x2900, 0x297F, RID_SUBSETSTR_SUPPL_ARROWS_B ) );
+ aAllSubsets.push_back( Subset( 0x2980, 0x29FF, RID_SUBSETSTR_MISC_MATH_SYMS_B ) );
+ aAllSubsets.push_back( Subset( 0x2E80, 0x2EFF, RID_SUBSETSTR_CJK_RADICAL_SUPPL ) );
+ aAllSubsets.push_back( Subset( 0x2F00, 0x2FDF, RID_SUBSETSTR_KANXI_RADICALS ) );
+ aAllSubsets.push_back( Subset( 0x2FF0, 0x2FFF, RID_SUBSETSTR_IDEO_DESC_CHARS ) );
+
+ aAllSubsets.push_back( Subset( 0x3000, 0x303F, RID_SUBSETSTR_CJK_SYMS_PUNCTUATION ) );
+ aAllSubsets.push_back( Subset( 0x3040, 0x309F, RID_SUBSETSTR_HIRAGANA ) );
+ aAllSubsets.push_back( Subset( 0x30A0, 0x30FF, RID_SUBSETSTR_KATAKANA ) );
+ aAllSubsets.push_back( Subset( 0x3100, 0x312F, RID_SUBSETSTR_BOPOMOFO ) );
+ aAllSubsets.push_back( Subset( 0x3130, 0x318F, RID_SUBSETSTR_HANGUL_COMPAT_JAMO ) );
+ aAllSubsets.push_back( Subset( 0x3190, 0x319F, RID_SUBSETSTR_KANBUN ) );
+ aAllSubsets.push_back( Subset( 0x31A0, 0x31BF, RID_SUBSETSTR_BOPOMOFO_EXTENDED ) );
+ aAllSubsets.push_back( Subset( 0x31C0, 0x31FF, RID_SUBSETSTR_KATAKANA_PHONETIC ) );
+ aAllSubsets.push_back( Subset( 0x3200, 0x32FF, RID_SUBSETSTR_ENCLOSED_CJK_LETTERS ) );
+ aAllSubsets.push_back( Subset( 0x3300, 0x33FF, RID_SUBSETSTR_CJK_COMPATIBILITY ) );
+
+ aAllSubsets.push_back( Subset( 0x3400, 0x4DFF, RID_SUBSETSTR_CJK_EXT_A_UNIFIED_IDGRAPH ) );
+ aAllSubsets.push_back( Subset( 0x4E00, 0x9FA5, RID_SUBSETSTR_CJK_UNIFIED_IDGRAPH ) );
+ aAllSubsets.push_back( Subset( 0xA000, 0xA4CF, RID_SUBSETSTR_YI ) );
+ aAllSubsets.push_back( Subset( 0xAC00, 0xB097, RID_SUBSETSTR_HANGUL_GA ) );
+ aAllSubsets.push_back( Subset( 0xB098, 0xB2E3, RID_SUBSETSTR_HANGUL_NA ) );
+ aAllSubsets.push_back( Subset( 0xB2E4, 0xB77B, RID_SUBSETSTR_HANGUL_DA ) );
+ aAllSubsets.push_back( Subset( 0xB77C, 0xB9C7, RID_SUBSETSTR_HANGUL_RA ) );
+ aAllSubsets.push_back( Subset( 0xB9C8, 0xBC13, RID_SUBSETSTR_HANGUL_MA ) );
+ aAllSubsets.push_back( Subset( 0xBC14, 0xC0AB, RID_SUBSETSTR_HANGUL_BA ) );
+ aAllSubsets.push_back( Subset( 0xC0AC, 0xC543, RID_SUBSETSTR_HANGUL_SA ) );
+ aAllSubsets.push_back( Subset( 0xC544, 0xC78F, RID_SUBSETSTR_HANGUL_AH ) );
+ aAllSubsets.push_back( Subset( 0xC790, 0xCC27, RID_SUBSETSTR_HANGUL_JA ) );
+ aAllSubsets.push_back( Subset( 0xCC28, 0xCE73, RID_SUBSETSTR_HANGUL_CHA ) );
+ aAllSubsets.push_back( Subset( 0xCE74, 0xD0BF, RID_SUBSETSTR_HANGUL_KA ) );
+ aAllSubsets.push_back( Subset( 0xD0C0, 0xD30B, RID_SUBSETSTR_HANGUL_TA ) );
+ aAllSubsets.push_back( Subset( 0xD30C, 0xD557, RID_SUBSETSTR_HANGUL_PA ) );
+ aAllSubsets.push_back( Subset( 0xD558, 0xD7A3, RID_SUBSETSTR_HANGUL_HA ) );
+ // aAllSubsets.push_back( Subset( 0xAC00, 0xD7AF, RID_SUBSETSTR_HANGUL ) );
+
+ // aAllSubsets.push_back( Subset( 0xD800, 0xDFFF, RID_SUBSETSTR_SURROGATE ) );
+ aAllSubsets.push_back( Subset( 0xE000, 0xF8FF, RID_SUBSETSTR_PRIVATE_USE_AREA ) );
+ aAllSubsets.push_back( Subset( 0xF900, 0xFAFF, RID_SUBSETSTR_CJK_COMPAT_IDGRAPHS ) );
+ aAllSubsets.push_back( Subset( 0xFB00, 0xFB4F, RID_SUBSETSTR_ALPHA_PRESENTATION ) );
+ aAllSubsets.push_back( Subset( 0xFB50, 0xFDFF, RID_SUBSETSTR_ARABIC_PRESENT_A ) );
+ aAllSubsets.push_back( Subset( 0xFE20, 0xFE2F, RID_SUBSETSTR_COMBINING_HALF_MARKS ) );
+ aAllSubsets.push_back( Subset( 0xFE30, 0xFE4F, RID_SUBSETSTR_CJK_COMPAT_FORMS ) );
+ aAllSubsets.push_back( Subset( 0xFE50, 0xFE6F, RID_SUBSETSTR_SMALL_FORM_VARIANTS ) );
+ aAllSubsets.push_back( Subset( 0xFE70, 0xFEFF, RID_SUBSETSTR_ARABIC_PRESENT_B ) );
+ aAllSubsets.push_back( Subset( 0xFF00, 0xFFEF, RID_SUBSETSTR_HALFW_FULLW_FORMS ) );
+ aAllSubsets.push_back( Subset( 0xFFF0, 0xFFFF, RID_SUBSETSTR_SPECIALS ) );
+ }
+
+ maSubsets = aAllSubsets;
+}
+
+void SubsetMap::ApplyCharMap( const FontCharMap* pFontCharMap )
+{
+ if( !pFontCharMap )
+ return;
+
+ // remove subsets that are not matched in any range
+ SubsetList::iterator it_next = maSubsets.begin();
+ while( it_next != maSubsets.end() )
+ {
+ SubsetList::iterator it = it_next++;
+ const Subset& rSubset = *it;
+ sal_uInt32 cMin = rSubset.GetRangeMin();
+ sal_uInt32 cMax = rSubset.GetRangeMax();
+
+ int nCount = pFontCharMap->CountCharsInRange( cMin, cMax );
+ if( nCount <= 0 )
+ maSubsets.erase( it );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/checklbx.cxx b/svx/source/dialog/checklbx.cxx
new file mode 100644
index 000000000000..296434abba8f
--- /dev/null
+++ b/svx/source/dialog/checklbx.cxx
@@ -0,0 +1,279 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/shl.hxx>
+
+#define _SVX_CHECKLBX_CXX
+
+#include <svx/checklbx.hxx>
+#include <svx/dialmgr.hxx>
+
+#include <svx/dialogs.hrc>
+
+// class SvxCheckListBox -------------------------------------------------
+
+SvxCheckListBox::SvxCheckListBox( Window* pParent, WinBits nWinStyle ) :
+
+ SvTreeListBox( pParent, nWinStyle )
+
+{
+ Init_Impl();
+}
+
+// -----------------------------------------------------------------------
+
+SvxCheckListBox::SvxCheckListBox( Window* pParent, const ResId& rResId ) :
+
+ SvTreeListBox( pParent, rResId )
+
+{
+ Init_Impl();
+}
+
+// -----------------------------------------------------------------------
+
+SvxCheckListBox::SvxCheckListBox( Window* pParent, const ResId& rResId,
+ const Image& rNormalStaticImage,
+ const Image& /*TODO#i72485# rHighContrastStaticImage*/ ) :
+
+ SvTreeListBox( pParent, rResId )
+
+{
+ Init_Impl();
+ pCheckButton->aBmps[SV_BMP_STATICIMAGE] = rNormalStaticImage;
+}
+
+// -----------------------------------------------------------------------
+
+SvxCheckListBox::~SvxCheckListBox()
+{
+ delete pCheckButton;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxCheckListBox::Init_Impl()
+{
+ pCheckButton = new SvLBoxButtonData( this );
+ EnableCheckButton( pCheckButton );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxCheckListBox::InsertEntry( const String& rStr, USHORT nPos,
+ void* pUserData,
+ SvLBoxButtonKind eButtonKind )
+{
+ SvTreeListBox::InsertEntry( rStr, NULL, FALSE, nPos, pUserData,
+ eButtonKind );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxCheckListBox::RemoveEntry( USHORT nPos )
+{
+ if ( nPos < GetEntryCount() )
+ SvTreeListBox::GetModel()->Remove( GetEntry( nPos ) );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxCheckListBox::SelectEntryPos( USHORT nPos, BOOL bSelect )
+{
+ if ( nPos < GetEntryCount() )
+ Select( GetEntry( nPos ), bSelect );
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SvxCheckListBox::GetSelectEntryPos() const
+{
+ SvLBoxEntry* pEntry = GetCurEntry();
+
+ if ( pEntry )
+ return (USHORT)GetModel()->GetAbsPos( pEntry );
+ return LISTBOX_ENTRY_NOTFOUND;
+}
+
+// -----------------------------------------------------------------------
+
+String SvxCheckListBox::GetText( USHORT nPos ) const
+{
+ SvLBoxEntry* pEntry = GetEntry( nPos );
+
+ if ( pEntry )
+ return GetEntryText( pEntry );
+ return String();
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SvxCheckListBox::GetCheckedEntryCount() const
+{
+ USHORT nCheckCount = 0;
+ USHORT nCount = (USHORT)GetEntryCount();
+
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ if ( IsChecked( i ) )
+ nCheckCount++;
+ }
+ return nCheckCount;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxCheckListBox::CheckEntryPos( USHORT nPos, BOOL bCheck )
+{
+ if ( nPos < GetEntryCount() )
+ SetCheckButtonState(
+ GetEntry( nPos ), bCheck ? SvButtonState( SV_BUTTON_CHECKED ) :
+ SvButtonState( SV_BUTTON_UNCHECKED ) );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SvxCheckListBox::IsChecked( USHORT nPos ) const
+{
+ if ( nPos < GetEntryCount() )
+ return (GetCheckButtonState( GetEntry( nPos ) ) == SV_BUTTON_CHECKED);
+ else
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+void* SvxCheckListBox::SetEntryData ( USHORT nPos, void* pNewData )
+{
+ void* pOld = NULL;
+
+ if ( nPos < GetEntryCount() )
+ {
+ pOld = GetEntry( nPos )->GetUserData();
+ GetEntry( nPos )->SetUserData( pNewData );
+ }
+ return pOld;
+}
+
+// -----------------------------------------------------------------------
+
+void* SvxCheckListBox::GetEntryData( USHORT nPos ) const
+{
+ if ( nPos < GetEntryCount() )
+ return GetEntry( nPos )->GetUserData();
+ else
+ return NULL;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxCheckListBox::ToggleCheckButton( SvLBoxEntry* pEntry )
+{
+ if ( pEntry )
+ {
+ if ( !IsSelected( pEntry ) )
+ Select( pEntry );
+ else
+ CheckEntryPos( GetSelectEntryPos(), !IsChecked( GetSelectEntryPos() ) );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxCheckListBox::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( rMEvt.IsLeft() )
+ {
+ const Point aPnt = rMEvt.GetPosPixel();
+ SvLBoxEntry* pEntry = GetEntry( aPnt );
+
+ if ( pEntry )
+ {
+ BOOL bCheck = ( GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED );
+ SvLBoxItem* pItem = GetItem( pEntry, aPnt.X() );
+
+ if ( pItem && pItem->IsA() == SV_ITEM_ID_LBOXBUTTON )
+ {
+ SvTreeListBox::MouseButtonDown( rMEvt );
+ Select( pEntry, TRUE );
+ return;
+ }
+ else
+ {
+ ToggleCheckButton( pEntry );
+ SvTreeListBox::MouseButtonDown( rMEvt );
+
+ // check if the entry below the mouse changed during the base method call. This is possible if,
+ // for instance, a handler invoked by the base class tampers with the list entries.
+ const SvLBoxEntry* pNewEntry = GetEntry( aPnt );
+ if ( pNewEntry != pEntry )
+ return;
+
+ if ( bCheck != ( GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED ) )
+ CheckButtonHdl();
+ return;
+ }
+ }
+ }
+ SvTreeListBox::MouseButtonDown( rMEvt );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxCheckListBox::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKey = rKEvt.GetKeyCode();
+
+ if ( rKey.GetCode() == KEY_RETURN || rKey.GetCode() == KEY_SPACE )
+ {
+ SvLBoxEntry* pEntry = GetCurEntry();
+
+ if ( pEntry )
+ {
+ BOOL bCheck = ( GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED );
+ ToggleCheckButton( pEntry );
+ if ( bCheck != ( GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED ) )
+ CheckButtonHdl();
+ }
+ }
+ else if ( GetEntryCount() )
+ SvTreeListBox::KeyInput( rKEvt );
+}
+
+// -----------------------------------------------------------------------
+
+SvLBoxEntry* SvxCheckListBox::InsertEntry( const XubString& rText, SvLBoxEntry* pParent, BOOL bChildsOnDemand, ULONG nPos, void* pUserData, SvLBoxButtonKind eButtonKind )
+{
+ return SvTreeListBox::InsertEntry( rText, pParent, bChildsOnDemand, nPos, pUserData, eButtonKind );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/connctrl.cxx b/svx/source/dialog/connctrl.cxx
new file mode 100644
index 000000000000..986e73af24d8
--- /dev/null
+++ b/svx/source/dialog/connctrl.cxx
@@ -0,0 +1,389 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <svx/svdoedge.hxx>
+#include <svx/svdattrx.hxx>
+#include <svx/svdmark.hxx>
+#include <svx/svdview.hxx>
+
+#include <svx/svdpage.hxx> // SdrObjList
+
+#include "connctrl.hxx"
+#include <svx/dialmgr.hxx>
+#include "dlgutil.hxx"
+
+// #110094#
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+
+// #110094#
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <vcl/svapp.hxx>
+
+/*************************************************************************
+|*
+|* Ctor SvxXConnectionPreview
+|*
+*************************************************************************/
+
+SvxXConnectionPreview::SvxXConnectionPreview( Window* pParent, const ResId& rResId,
+ const SfxItemSet& rInAttrs ) :
+ Control ( pParent, rResId ),
+ rAttrs ( rInAttrs ),
+ pEdgeObj( NULL ),
+ pObjList( NULL ),
+ pView ( NULL )
+{
+ SetMapMode( MAP_100TH_MM );
+ SetStyles();
+}
+
+/*************************************************************************
+|*
+|* Dtor SvxXConnectionPreview
+|*
+*************************************************************************/
+
+SvxXConnectionPreview::~SvxXConnectionPreview()
+{
+ delete pObjList;
+}
+
+/*************************************************************************
+|*
+|* Dtor SvxXConnectionPreview
+|*
+*************************************************************************/
+
+void SvxXConnectionPreview::Construct()
+{
+ DBG_ASSERT( pView, "Keine gueltige View Uebergeben!" );
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ ULONG nMarkCount = rMarkList.GetMarkCount();
+
+ if( nMarkCount >= 1 )
+ {
+ BOOL bFound = FALSE;
+ const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+
+ for( USHORT i = 0; i < nMarkCount && !bFound; i++ )
+ {
+ pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
+ UINT32 nInv = pObj->GetObjInventor();
+ UINT16 nId = pObj->GetObjIdentifier();
+ if( nInv == SdrInventor && nId == OBJ_EDGE )
+ {
+ bFound = TRUE;
+ SdrEdgeObj* pTmpEdgeObj = (SdrEdgeObj*) pObj;
+ pEdgeObj = (SdrEdgeObj*) pTmpEdgeObj->Clone();
+
+ SdrObjConnection& rConn1 = (SdrObjConnection&)pEdgeObj->GetConnection( TRUE );
+ SdrObjConnection& rConn2 = (SdrObjConnection&)pEdgeObj->GetConnection( FALSE );
+
+ rConn1 = pTmpEdgeObj->GetConnection( TRUE );
+ rConn2 = pTmpEdgeObj->GetConnection( FALSE );
+
+ SdrObject* pTmpObj1 = pTmpEdgeObj->GetConnectedNode( TRUE );
+ SdrObject* pTmpObj2 = pTmpEdgeObj->GetConnectedNode( FALSE );
+
+ // #110094#
+ // potential memory leak here (!). Create SdrObjList only when there is
+ // not yet one.
+ if(!pObjList)
+ {
+ pObjList = new SdrObjList( pView->GetModel(), NULL );
+ }
+
+ if( pTmpObj1 )
+ {
+ SdrObject* pObj1 = pTmpObj1->Clone();
+ pObjList->InsertObject( pObj1 );
+ pEdgeObj->ConnectToNode( TRUE, pObj1 );
+ }
+ if( pTmpObj2 )
+ {
+ SdrObject* pObj2 = pTmpObj2->Clone();
+ pObjList->InsertObject( pObj2 );
+ pEdgeObj->ConnectToNode( FALSE, pObj2 );
+ }
+ pObjList->InsertObject( pEdgeObj );
+ }
+ }
+ }
+
+ if( !pEdgeObj )
+ pEdgeObj = new SdrEdgeObj();
+
+ // Groesse anpassen
+ if( pObjList )
+ {
+ OutputDevice* pOD = pView->GetFirstOutputDevice(); // GetWin( 0 );
+ Rectangle aRect = pObjList->GetAllObjBoundRect();
+
+ MapMode aMapMode = GetMapMode();
+ aMapMode.SetMapUnit( pOD->GetMapMode().GetMapUnit() );
+ SetMapMode( aMapMode );
+
+ MapMode aDisplayMap( aMapMode );
+ Point aNewPos;
+ Size aNewSize;
+ const Size aWinSize = PixelToLogic( GetOutputSizePixel(), aDisplayMap );
+ const long nWidth = aWinSize.Width();
+ const long nHeight = aWinSize.Height();
+ double fRectWH = (double) aRect.GetWidth() / aRect.GetHeight();
+ double fWinWH = (double) nWidth / nHeight;
+
+ // Bitmap an Thumbgroesse anpassen (hier nicht!)
+ if ( fRectWH < fWinWH)
+ {
+ aNewSize.Width() = (long) ( (double) nHeight * fRectWH );
+ aNewSize.Height()= nHeight;
+ }
+ else
+ {
+ aNewSize.Width() = nWidth;
+ aNewSize.Height()= (long) ( (double) nWidth / fRectWH );
+ }
+
+ Fraction aFrac1( aWinSize.Width(), aRect.GetWidth() );
+ Fraction aFrac2( aWinSize.Height(), aRect.GetHeight() );
+ Fraction aMinFrac( aFrac1 <= aFrac2 ? aFrac1 : aFrac2 );
+
+ // MapMode umsetzen
+ aDisplayMap.SetScaleX( aMinFrac );
+ aDisplayMap.SetScaleY( aMinFrac );
+
+ // Zentrierung
+ aNewPos.X() = ( nWidth - aNewSize.Width() ) >> 1;
+ aNewPos.Y() = ( nHeight - aNewSize.Height() ) >> 1;
+
+ aDisplayMap.SetOrigin( LogicToLogic( aNewPos, aMapMode, aDisplayMap ) );
+ SetMapMode( aDisplayMap );
+
+ // Ursprung
+ aNewPos = aDisplayMap.GetOrigin();
+ aNewPos -= Point( aRect.TopLeft().X(), aRect.TopLeft().Y() );
+ aDisplayMap.SetOrigin( aNewPos );
+ SetMapMode( aDisplayMap );
+
+
+ Point aPos;
+ MouseEvent aMEvt( aPos, 1, 0, MOUSE_RIGHT );
+ MouseButtonDown( aMEvt );
+ /*
+ Point aPt( -aRect.TopLeft().X(), -aRect.TopLeft().Y() );
+ aMapMode.SetOrigin( aPt );
+
+ // Skalierung
+ Size aSize = GetOutputSize();
+ Fraction aFrac1( aSize.Width(), aRect.GetWidth() );
+ Fraction aFrac2( aSize.Height(), aRect.GetHeight() );
+ Fraction aMaxFrac( aFrac1 > aFrac2 ? aFrac1 : aFrac2 );
+ Fraction aMinFrac( aFrac1 <= aFrac2 ? aFrac1 : aFrac2 );
+ BOOL bChange = (BOOL) ( (double)aMinFrac > 1.0 );
+ aMapMode.SetScaleX( aMinFrac );
+ aMapMode.SetScaleY( aMinFrac );
+
+ // zentrieren
+ long nXXL = aSize.Width() > aRect.GetWidth() ? aSize.Width() : aRect.GetWidth();
+ long nXS = aSize.Width() <= aRect.GetWidth() ? aSize.Width() : aRect.GetWidth();
+ if( bChange )
+ {
+ long nTmp = nXXL; nXXL = nXS; nXS = nTmp;
+ }
+ long nX = (long) ( (double)aMinFrac * (double)nXXL );
+ nX = (long) ( (double)labs( nXS - nX ) / (double)aMinFrac / 2.0 );
+
+ long nYXL = aSize.Height() > aRect.GetHeight() ? aSize.Height() : aRect.GetHeight();
+ long nYS = aSize.Height() <= aRect.GetHeight() ? aSize.Height() : aRect.GetHeight();
+ if( bChange )
+ {
+ long nTmp = nXXL; nXXL = nXS; nXS = nTmp;
+ }
+ long nY = (long) ( (double)aMinFrac * (double)nYXL );
+ nY = (long) ( (double)labs( nYS - nY ) / (double)aMinFrac / 2.0 );
+
+ aPt += Point( nX, nY );
+ aMapMode.SetOrigin( aPt );
+
+ SetMapMode( aMapMode );
+ */
+ }
+}
+
+/*************************************************************************
+|*
+|* SvxXConnectionPreview: Paint()
+|*
+*************************************************************************/
+
+void SvxXConnectionPreview::Paint( const Rectangle& )
+{
+ if( pObjList )
+ {
+ // #110094#
+ // This will not work anymore. To not start at Adam and Eve, i will
+ // ATM not try to change all this stuff to really using an own model
+ // and a view. I will just try to provide a mechanism to paint such
+ // objects without own model and without a page/view with the new
+ // mechanism.
+
+ // New stuff: Use a ObjectContactOfObjListPainter.
+ sdr::contact::SdrObjectVector aObjectVector;
+
+ for(sal_uInt32 a(0L); a < pObjList->GetObjCount(); a++)
+ {
+ SdrObject* pObject = pObjList->GetObj(a);
+ DBG_ASSERT(pObject,
+ "SvxXConnectionPreview::Paint: Corrupt ObjectList (!)");
+ aObjectVector.push_back(pObject);
+ }
+
+ sdr::contact::ObjectContactOfObjListPainter aPainter(*this, aObjectVector, 0);
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ // do processing
+ aPainter.ProcessDisplay(aDisplayInfo);
+ }
+}
+
+/*************************************************************************
+|*
+|* SvxXConnectionPreview: SetAttributes()
+|*
+*************************************************************************/
+
+void SvxXConnectionPreview::SetAttributes( const SfxItemSet& rInAttrs )
+{
+ //pEdgeObj->SetItemSetAndBroadcast(rInAttrs);
+ pEdgeObj->SetMergedItemSetAndBroadcast(rInAttrs);
+
+ Invalidate();
+}
+
+/*************************************************************************
+|*
+|* Ermittelt die Anzahl der Linienversaetze anhand des Preview-Objektes
+|*
+*************************************************************************/
+
+USHORT SvxXConnectionPreview::GetLineDeltaAnz()
+{
+ const SfxItemSet& rSet = pEdgeObj->GetMergedItemSet();
+ sal_uInt16 nCount(0);
+
+ if(SFX_ITEM_DONTCARE != rSet.GetItemState(SDRATTR_EDGELINEDELTAANZ))
+ nCount = ((const SdrEdgeLineDeltaAnzItem&)rSet.Get(SDRATTR_EDGELINEDELTAANZ)).GetValue();
+
+ return nCount;
+}
+
+/*************************************************************************
+|*
+|* SvxXConnectionPreview: MouseButtonDown()
+|*
+*************************************************************************/
+
+void SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ BOOL bZoomIn = rMEvt.IsLeft() && !rMEvt.IsShift();
+ BOOL bZoomOut = rMEvt.IsRight() || rMEvt.IsShift();
+ BOOL bCtrl = rMEvt.IsMod1();
+
+ if( bZoomIn || bZoomOut )
+ {
+ MapMode aMapMode = GetMapMode();
+ Fraction aXFrac = aMapMode.GetScaleX();
+ Fraction aYFrac = aMapMode.GetScaleY();
+ Fraction* pMultFrac;
+
+ if( bZoomIn )
+ {
+ if( bCtrl )
+ pMultFrac = new Fraction( 3, 2 );
+ else
+ pMultFrac = new Fraction( 11, 10 );
+ }
+ else
+ {
+ if( bCtrl )
+ pMultFrac = new Fraction( 2, 3 );
+ else
+ pMultFrac = new Fraction( 10, 11 );
+ }
+
+ aXFrac *= *pMultFrac;
+ aYFrac *= *pMultFrac;
+ if( (double)aXFrac > 0.001 && (double)aXFrac < 1000.0 &&
+ (double)aYFrac > 0.001 && (double)aYFrac < 1000.0 )
+ {
+ aMapMode.SetScaleX( aXFrac );
+ aMapMode.SetScaleY( aYFrac );
+ SetMapMode( aMapMode );
+
+ Size aOutSize( GetOutputSize() );
+
+ Point aPt( aMapMode.GetOrigin() );
+ long nX = (long)( ( (double)aOutSize.Width() - ( (double)aOutSize.Width() * (double)*pMultFrac ) ) / 2.0 + 0.5 );
+ long nY = (long)( ( (double)aOutSize.Height() - ( (double)aOutSize.Height() * (double)*pMultFrac ) ) / 2.0 + 0.5 );
+ aPt.X() += nX;
+ aPt.Y() += nY;
+
+ aMapMode.SetOrigin( aPt );
+ SetMapMode( aMapMode );
+
+ Invalidate();
+ }
+ delete pMultFrac;
+ }
+}
+
+void SvxXConnectionPreview::SetStyles()
+{
+ const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
+ SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
+ SetBackground( Wallpaper( Color( rStyles.GetFieldColor() ) ) );
+}
+
+void SvxXConnectionPreview::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Control::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ SetStyles();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/contdlg.hrc b/svx/source/dialog/contdlg.hrc
new file mode 100644
index 000000000000..bf3bc84267a3
--- /dev/null
+++ b/svx/source/dialog/contdlg.hrc
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <svx/dialogs.hrc>
+
+
+// ImapDlg-Dialoge
+#define RID_SVX_CONTOURDLG_START RID_SVX_CONTOUR_START
+
+
+/******************************************************************************/
+
+
+#define RID_SVXDLG_CONTOUR (RID_SVX_CONTOURDLG_START)
+
+#define TBX1 1
+#define TBI_APPLY 1
+
+#define TBI_WORKPLACE 2
+
+#define TBI_SELECT 5
+#define TBI_RECT 6
+#define TBI_CIRCLE 7
+#define TBI_POLY 8
+#define TBI_FREEPOLY 9
+
+#define TBI_POLYEDIT 15
+#define TBI_POLYMOVE 16
+#define TBI_POLYINSERT 17
+#define TBI_POLYDELETE 18
+
+#define TBI_UNDO 20
+#define TBI_REDO 21
+
+#define TBI_AUTOCONTOUR 25
+#define TBI_PIPETTE 26
+
+#define MTF_TOLERANCE 1
+
+#define CTL_CONTOUR 1
+
+#define STB_STATUS 1
+
+#define CD_IMAPDLG 1300
+#define CDH_IMAPDLG 1301
+
+
+/******************************************************************************/
+
+#define STR_CONTOURDLG_MODIFY (RID_SVX_CONTOURDLG_START + 2)
+#define STR_CONTOURDLG_NEWPIPETTE (RID_SVX_CONTOURDLG_START + 3)
+#define STR_CONTOURDLG_WORKPLACE (RID_SVX_CONTOURDLG_START + 4)
+#define STR_CONTOURDLG_LINKED (RID_SVX_CONTOURDLG_START + 5)
+
+/******************************************************************************/
+
+
+/******************************************************************************/
+
+
+/******************************************************************************/
+
+
+/******************************************************************************/
diff --git a/svx/source/dialog/contdlg.src b/svx/source/dialog/contdlg.src
new file mode 100644
index 000000000000..df5805daa669
--- /dev/null
+++ b/svx/source/dialog/contdlg.src
@@ -0,0 +1,288 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include "helpid.hrc"
+#include "contdlg.hrc"
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; } ;
+
+ // RID_SVXDLG_CONTOUR ----------------------------------------------------
+FloatingWindow RID_SVXDLG_CONTOUR
+{
+ OutputSize = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 270 , 213 ) ;
+ Text [ en-US ] = "Contour Editor" ;
+ Sizeable = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ ToolBox TBX1
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ HelpId = HID_CONTDLG_TOOLBOX ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = TBI_APPLY ;
+ HelpId = HID_CONTDLG_APPLY ;
+ Text [ en-US ] = "Apply" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_WORKPLACE ;
+ HelpId = HID_CONTDLG_WORKPLACE ;
+ Text [ en-US ] = "Workspace" ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_SELECT ;
+ HelpId = HID_CONTDLG_SELECT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ Text [ en-US ] = "Select" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_RECT ;
+ HelpId = HID_CONTDLG_RECT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ Text [ en-US ] = "Rectangle" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_CIRCLE ;
+ HelpId = HID_CONTDLG_CIRCLE ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ Text [ en-US ] = "Ellipse" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_POLY ;
+ HelpId = HID_CONTDLG_POLY ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ Text [ en-US ] = "Polygon" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_POLYEDIT ;
+ HelpId = HID_CONTDLG_POLYEDIT ;
+ Text [ en-US ] = "Edit Points" ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_POLYMOVE ;
+ HelpId = HID_CONTDLG_POLYMOVE ;
+ Text [ en-US ] = "Move Points" ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_POLYINSERT ;
+ HelpId = HID_CONTDLG_POLYINSERT ;
+ Text [ en-US ] = "Insert Points" ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_POLYDELETE ;
+ HelpId = HID_CONTDLG_POLYDELETE ;
+ Text [ en-US ] = "Delete Points" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_AUTOCONTOUR ;
+ HelpId = HID_CONTDLG_AUTOCONTOUR ;
+ Text [ en-US ] = "AutoContour" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_UNDO ;
+ HelpId = HID_CONTDLG_UNDO ;
+
+ Text [ en-US ] = "Undo " ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_REDO ;
+ HelpId = HID_CONTDLG_REDO ;
+
+
+ Text [ en-US ] = "Redo " ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_PIPETTE ;
+ HelpId = HID_CONTDLG_PIPETTE ;
+ Text [ en-US ] = "Eyedropper" ;
+ AutoCheck = TRUE ;
+ };
+ };
+ };
+ MetricField MTF_TOLERANCE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 28 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 99 ;
+ Last = 99 ;
+ SpinSize = 1 ;
+ Unit = FUNIT_CUSTOM ;
+ QuickHelpText [ en-US ] = "Color Tolerance" ;
+ CustomUnitText [ en-US ] = "%" ;
+ };
+ Control CTL_CONTOUR
+ {
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 24 ) ;
+ HelpId = HID_CONTDLG_GRAPHWND ;
+ };
+
+#define CONTOURDLG_IDLIST \
+ IdList = \
+ { \
+ TBI_APPLY ; \
+ TBI_WORKPLACE ; \
+ TBI_SELECT ; \
+ TBI_RECT ; \
+ TBI_CIRCLE ; \
+ TBI_POLY ; \
+ TBI_POLYEDIT ; \
+ TBI_POLYMOVE ; \
+ TBI_POLYINSERT ; \
+ TBI_POLYDELETE ; \
+ TBI_AUTOCONTOUR ; \
+ TBI_UNDO ; \
+ TBI_REDO ; \
+ TBI_PIPETTE ; \
+ }; \
+ IdCount = { 14 ; };
+
+ ImageList CD_IMAPDLG
+ {
+ Prefix = "cd";
+ MASKCOLOR
+ CONTOURDLG_IDLIST
+ };
+ ImageList CDH_IMAPDLG
+ {
+ Prefix = "cdh";
+ MASKCOLOR
+ CONTOURDLG_IDLIST
+ };
+};
+/******************************************************************************/
+String STR_CONTOURDLG_MODIFY
+{
+ Text [ en-US ] = "The contour has been modified.\nDo you want to save the changes?" ;
+};
+String STR_CONTOURDLG_NEWPIPETTE
+{
+ Text [ en-US ] = "Do you want to create a new contour?" ;
+};
+String STR_CONTOURDLG_WORKPLACE
+{
+ Text [ en-US ] = "Setting a new workspace will\ncause the contour to be deleted.\nAre you sure you want to continue?" ;
+};
+String STR_CONTOURDLG_LINKED
+{
+ Text [ en-US ] = "This graphic object is linked to the document. Do you want to unlink the graphics in order to edit it?" ;
+};
+/******************************************************************************/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/contimp.hxx b/svx/source/dialog/contimp.hxx
new file mode 100644
index 000000000000..5824d6fc7ffe
--- /dev/null
+++ b/svx/source/dialog/contimp.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _CONTIMP_HXX_
+#define _CONTIMP_HXX_
+
+#include <svx/contdlg.hxx>
+#include "contwnd.hxx"
+#include <vcl/toolbox.hxx>
+#include <vcl/status.hxx>
+
+#define CONT_RESID(nId) ResId( nId, DIALOG_MGR() )
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+class SvxSuperContourDlg : public SvxContourDlg
+{
+ using SvxContourDlg::GetPolyPolygon;
+
+ Graphic aGraphic;
+ Graphic aUndoGraphic;
+ Graphic aRedoGraphic;
+ Graphic aUpdateGraphic;
+ PolyPolygon aUpdatePolyPoly;
+ Timer aUpdateTimer;
+ Timer aCreateTimer;
+ Size aLastSize;
+ void* pUpdateEditingObject;
+ void* pCheckObj;
+ SvxContourDlgItem aContourItem;
+ ToolBox aTbx1;
+ MetricField aMtfTolerance;
+ ContourWindow aContourWnd;
+ StatusBar aStbStatus;
+ ULONG nGrfChanged;
+ BOOL bExecState;
+ BOOL bPipetteMode;
+ BOOL bWorkplaceMode;
+ BOOL bUpdateGraphicLinked;
+ BOOL bGraphicLinked;
+ ImageList maImageList;
+ ImageList maImageListH;
+
+ virtual void Resize();
+ virtual BOOL Close();
+
+ void DoAutoCreate();
+ void ReducePoints( const long nTol = 8 );
+
+ DECL_LINK( Tbx1ClickHdl, ToolBox* );
+ DECL_LINK( MousePosHdl, ContourWindow* );
+ DECL_LINK( GraphSizeHdl, ContourWindow* );
+ DECL_LINK( UpdateHdl, Timer* );
+ DECL_LINK( CreateHdl, Timer* );
+ DECL_LINK( StateHdl, ContourWindow* );
+ DECL_LINK( PipetteHdl, ContourWindow* );
+ DECL_LINK( PipetteClickHdl, ContourWindow* );
+ DECL_LINK( WorkplaceClickHdl, ContourWindow* );
+ DECL_LINK( MiscHdl, void* );
+
+public:
+
+ SvxSuperContourDlg( SfxBindings *pBindings, SfxChildWindow *pCW,
+ Window* pParent, const ResId& rResId );
+ ~SvxSuperContourDlg();
+
+ void SetExecState( BOOL bEnable );
+
+ void SetGraphic( const Graphic& rGraphic );
+ void SetGraphicLinked( BOOL bLinked ) { bGraphicLinked = bLinked; }
+ const Graphic& GetGraphic() const { return aGraphic; }
+ BOOL IsGraphicChanged() const { return nGrfChanged > 0UL; }
+
+ void SetPolyPolygon( const PolyPolygon& rPolyPoly );
+ PolyPolygon GetPolyPolygon( BOOL bRescaleToGraphic = TRUE );
+
+ void SetEditingObject( void* pObj ) { pCheckObj = pObj; }
+ const void* GetEditingObject() const { return pCheckObj; }
+
+ BOOL IsUndoPossible() const;
+ BOOL IsRedoPossible() const;
+
+ void UpdateGraphic( const Graphic& rGraphic, BOOL bGraphicLinked,
+ const PolyPolygon* pPolyPoly = NULL,
+ void* pEditingObj = NULL );
+
+ /** switches the toolbox images depending on the actuall high contrast display mode state */
+ void ApplyImageList();
+
+ /** virtual method from Window is used to detect change in high contrast display mode
+ to switch the toolbox images */
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+};
+
+
+#endif // _CONTIMP_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/contwnd.cxx b/svx/source/dialog/contwnd.cxx
new file mode 100644
index 000000000000..ed05b16915a8
--- /dev/null
+++ b/svx/source/dialog/contwnd.cxx
@@ -0,0 +1,361 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <xoutbmp.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/svxids.hrc>
+#include <contdlg.hrc>
+#include <contwnd.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/xfillit.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+
+// #i75482#
+#include "sdrpaintwindow.hxx"
+
+#define TRANSCOL Color( COL_WHITE )
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+ContourWindow::ContourWindow( Window* pParent, const ResId& rResId ) :
+ GraphCtrl ( pParent, rResId ),
+ aWorkRect ( 0, 0, 0, 0 ),
+ bPipetteMode ( FALSE ),
+ bWorkplaceMode ( FALSE ),
+ bClickValid ( FALSE )
+{
+ SetWinStyle( WB_SDRMODE );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+ContourWindow::~ContourWindow()
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void ContourWindow::SetPolyPolygon( const PolyPolygon& rPolyPoly )
+{
+ SdrPage* pPage = (SdrPage*) pModel->GetPage( 0 );
+ const USHORT nPolyCount = rPolyPoly.Count();
+
+ // zuerst alle Zeichenobjekte loeschen
+ aPolyPoly = rPolyPoly;
+
+ // #117412#
+ // To avoid to have destroyed objects which are still selected, it is necessary to deselect
+ // them first (!)
+ pView->UnmarkAllObj();
+
+ pPage->Clear();
+
+ for ( USHORT i = 0; i < nPolyCount; i++ )
+ {
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ aPolyPolygon.append(aPolyPoly[ i ].getB2DPolygon());
+ SdrPathObj* pPathObj = new SdrPathObj( OBJ_PATHFILL, aPolyPolygon );
+
+ if ( pPathObj )
+ {
+ SfxItemSet aSet( pModel->GetItemPool() );
+
+ aSet.Put( XFillStyleItem( XFILL_SOLID ) );
+ aSet.Put( XFillColorItem( String(), TRANSCOL ) );
+ aSet.Put( XFillTransparenceItem( 50 ) );
+
+ //pPathObj->SetItemSetAndBroadcast(aSet);
+ pPathObj->SetMergedItemSetAndBroadcast(aSet);
+
+ pPage->InsertObject( pPathObj );
+ }
+ }
+
+ if ( nPolyCount )
+ {
+ pView->MarkAll();
+ pView->CombineMarkedObjects( sal_False );
+ }
+
+ pModel->SetChanged( sal_False );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+const PolyPolygon& ContourWindow::GetPolyPolygon()
+{
+ if ( pModel->IsChanged() )
+ {
+ SdrPage* pPage = (SdrPage*) pModel->GetPage( 0 );
+
+ aPolyPoly = PolyPolygon();
+
+ if ( pPage && pPage->GetObjCount() )
+ {
+ SdrPathObj* pPathObj = (SdrPathObj*)pPage->GetObj(0L);
+ // Not sure if subdivision is needed for ContourWindow, but maybe it cannot handle
+ // curves at all. Keeping subdivision here for security
+ const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::tools::adaptiveSubdivideByAngle(pPathObj->GetPathPoly()));
+ aPolyPoly = PolyPolygon(aB2DPolyPolygon);
+ }
+
+ pModel->SetChanged( sal_False );
+ }
+
+ return aPolyPoly;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void ContourWindow::InitSdrModel()
+{
+ GraphCtrl::InitSdrModel();
+
+ SfxItemSet aSet( pModel->GetItemPool() );
+
+ aSet.Put( XFillColorItem( String(), TRANSCOL ) );
+ aSet.Put( XFillTransparenceItem( 50 ) );
+ pView->SetAttributes( aSet );
+ pView->SetFrameDragSingles( TRUE );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void ContourWindow::SdrObjCreated( const SdrObject& )
+{
+ pView->MarkAll();
+ pView->CombineMarkedObjects( sal_False );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL ContourWindow::IsContourChanged() const
+{
+ SdrPage* pPage = (SdrPage*) pModel->GetPage( 0 );
+ BOOL bRet = FALSE;
+
+ if ( pPage && pPage->GetObjCount() )
+ bRet = ( (SdrPathObj*) pPage->GetObj( 0 ) )->GetPathPoly().count() && pModel->IsChanged();
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void ContourWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( bWorkplaceMode )
+ {
+ const Point aLogPt( PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ SetPolyPolygon( PolyPolygon() );
+ aWorkRect = Rectangle( aLogPt, aLogPt );
+ Paint( Rectangle( Point(), GetGraphicSize() ) );
+ SetEditMode( TRUE );
+ }
+
+ if ( !bPipetteMode )
+ GraphCtrl::MouseButtonDown( rMEvt );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void ContourWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ bClickValid = FALSE;
+
+ if ( bPipetteMode )
+ {
+ const Point aLogPt( PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ aPipetteColor = GetPixel( aLogPt );
+ Control::MouseMove( rMEvt );
+
+ if ( aPipetteLink.IsSet() && Rectangle( Point(), GetGraphicSize() ).IsInside( aLogPt ) )
+ {
+ SetPointer( POINTER_REFHAND );
+ aPipetteLink.Call( this );
+ }
+ }
+ else
+ GraphCtrl::MouseMove( rMEvt );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void ContourWindow::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ Point aTmpPoint;
+ const Rectangle aGraphRect( aTmpPoint, GetGraphicSize() );
+ const Point aLogPt( PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ bClickValid = aGraphRect.IsInside( aLogPt );
+ ReleaseMouse();
+
+ if ( bPipetteMode )
+ {
+ Control::MouseButtonUp( rMEvt );
+
+ if ( aPipetteClickLink.IsSet() )
+ aPipetteClickLink.Call( this );
+ }
+ else if ( bWorkplaceMode )
+ {
+ GraphCtrl::MouseButtonUp( rMEvt );
+
+ aWorkRect.Right() = aLogPt.X();
+ aWorkRect.Bottom() = aLogPt.Y();
+ aWorkRect.Intersection( aGraphRect );
+ aWorkRect.Justify();
+
+ if ( aWorkRect.Left() != aWorkRect.Right() && aWorkRect.Top() != aWorkRect.Bottom() )
+ {
+ PolyPolygon _aPolyPoly( GetPolyPolygon() );
+
+ _aPolyPoly.Clip( aWorkRect );
+ SetPolyPolygon( _aPolyPoly );
+ pView->SetWorkArea( aWorkRect );
+ }
+ else
+ pView->SetWorkArea( aGraphRect );
+
+ Invalidate( aGraphRect );
+
+ if ( aWorkplaceClickLink.IsSet() )
+ aWorkplaceClickLink.Call( this );
+ }
+ else
+ GraphCtrl::MouseButtonUp( rMEvt );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void ContourWindow::Paint( const Rectangle& rRect )
+{
+ // #i75482#
+ // encapsulate the redraw using Begin/End and use the returned
+ // data to get the target output device (e.g. when pre-rendering)
+ SdrPaintWindow* pPaintWindow = pView->BeginCompleteRedraw(this);
+ OutputDevice& rTarget = pPaintWindow->GetTargetOutputDevice();
+
+ const Graphic& rGraphic = GetGraphic();
+ const Color& rOldLineColor = GetLineColor();
+ const Color& rOldFillColor = GetFillColor();
+
+ rTarget.SetLineColor( Color( COL_BLACK ) );
+ rTarget.SetFillColor( Color( COL_WHITE ) );
+
+ rTarget.DrawRect( Rectangle( Point(), GetGraphicSize() ) );
+
+ rTarget.SetLineColor( rOldLineColor );
+ rTarget.SetFillColor( rOldFillColor );
+
+ if ( rGraphic.GetType() != GRAPHIC_NONE )
+ rGraphic.Draw( &rTarget, Point(), GetGraphicSize() );
+
+ if ( aWorkRect.Left() != aWorkRect.Right() && aWorkRect.Top() != aWorkRect.Bottom() )
+ {
+ PolyPolygon _aPolyPoly( 2, 2 );
+ const Color aOldFillColor( GetFillColor() );
+
+ _aPolyPoly.Insert( Rectangle( Point(), GetGraphicSize() ) );
+ _aPolyPoly.Insert( aWorkRect );
+
+ rTarget.SetFillColor( COL_LIGHTRED );
+ rTarget.DrawTransparent( _aPolyPoly, 50 );
+ rTarget.SetFillColor( aOldFillColor );
+ }
+
+ // #i75482#
+ const Region aRepaintRegion(rRect);
+ pView->DoCompleteRedraw(*pPaintWindow, aRepaintRegion);
+ pView->EndCompleteRedraw(*pPaintWindow, true);
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/contwnd.hxx b/svx/source/dialog/contwnd.hxx
new file mode 100644
index 000000000000..51dbd51e98f3
--- /dev/null
+++ b/svx/source/dialog/contwnd.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _CONTWND_HXX
+#define _CONTWND_HXX
+
+#include <tools/poly.hxx>
+#include <svx/graphctl.hxx>
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+class ContourWindow : public GraphCtrl
+{
+ PolyPolygon aPolyPoly;
+ Color aPipetteColor;
+ Rectangle aWorkRect;
+ Link aPipetteLink;
+ Link aPipetteClickLink;
+ Link aWorkplaceClickLink;
+ BOOL bPipetteMode;
+ BOOL bWorkplaceMode;
+ BOOL bClickValid;
+
+protected:
+
+ virtual void MouseButtonDown(const MouseEvent& rMEvt);
+ virtual void MouseMove(const MouseEvent& rMEvt);
+ virtual void MouseButtonUp(const MouseEvent& rMEvt);
+ virtual void SdrObjCreated( const SdrObject& rObj );
+ virtual void InitSdrModel();
+ virtual void Paint( const Rectangle& rRect );
+
+ void CreatePolyPolygon();
+
+public:
+
+ ContourWindow( Window* pParent, const ResId& rResId );
+ ~ContourWindow();
+
+ void SetPolyPolygon( const PolyPolygon& rPolyPoly );
+ const PolyPolygon& GetPolyPolygon();
+
+ void SetPipetteMode( const BOOL bPipette ) { bPipetteMode = bPipette; }
+ BOOL IsPipetteMode() const { return bPipetteMode; }
+ const Color& GetPipetteColor() const { return aPipetteColor; }
+
+ BOOL IsClickValid() const { return bClickValid; }
+ BOOL IsContourChanged() const;
+
+ void SetWorkplaceMode( const BOOL bWorkplace ) { bWorkplaceMode = bWorkplace; }
+ BOOL IsWorkplaceMode() const { return bWorkplaceMode; }
+ const Rectangle& GetWorkRect() const { return aWorkRect; }
+
+ void SetPipetteHdl( const Link& rLink ) { aPipetteLink = rLink; }
+ void SetPipetteClickHdl( const Link& rLink ) { aPipetteClickLink = rLink; }
+
+ void SetWorkplaceClickHdl( const Link& rLink ) { aWorkplaceClickLink = rLink; }
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/ctredlin.cxx b/svx/source/dialog/ctredlin.cxx
new file mode 100644
index 000000000000..47c9c10c0e07
--- /dev/null
+++ b/svx/source/dialog/ctredlin.cxx
@@ -0,0 +1,1533 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// System - Includes ---------------------------------------------------------
+#include <vcl/svapp.hxx>
+#include <tools/shl.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/module.hxx>
+#include <svtools/txtcmp.hxx>
+#include <unotools/charclass.hxx>
+// INCLUDE -------------------------------------------------------------------
+#include <editeng/unolingu.hxx>
+#include <svx/dialmgr.hxx>
+#include "ctredlin.hrc"
+#include <svx/ctredlin.hxx>
+#include "helpid.hrc"
+
+//============================================================================
+// Local Defines and Function
+//----------------------------------------------------------------------------
+
+inline void EnableDisable( Window& rWin, BOOL bEnable )
+{
+ if (bEnable)
+ rWin.Enable();
+ else
+ rWin.Disable();
+}
+
+static long nStaticTabs[]=
+{
+ 5,10,65,120,170,220
+};
+
+#define MIN_DISTANCE 6
+#define WRITER_AUTHOR 1
+#define WRITER_DATE 2
+#define CALC_AUTHOR 2
+#define CALC_DATE 3
+
+RedlinData::RedlinData()
+{
+ bDisabled=FALSE;
+ pData=NULL;
+}
+RedlinData::~RedlinData()
+{
+}
+
+//============================================================================
+// class SvxRedlinEntry (Eintraege fuer Liste)
+//----------------------------------------------------------------------------
+
+SvxRedlinEntry::SvxRedlinEntry()
+ :SvLBoxEntry()
+{
+}
+
+SvxRedlinEntry::~SvxRedlinEntry()
+{
+ RedlinData* pRedDat=(RedlinData*) GetUserData();
+ if(pRedDat!=NULL)
+ {
+ delete pRedDat;
+ }
+}
+
+/*************************************************************************
+#* Funktionen der in den SvxRedlinTable eingefuegten Items
+#************************************************************************/
+
+DBG_NAME(SvLBoxColorString);
+
+/*************************************************************************
+#* Member: SvLBoxColorString Datum:23.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvLBoxColorString
+#*
+#* Funktion: Konstruktor der Klasse SvLBoxColorString
+#*
+#* Input: Box- Entry,Flags, Text fuer Anzeige, Schrift
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+SvLBoxColorString::SvLBoxColorString( SvLBoxEntry*pEntry,USHORT nFlags,const XubString& rStr,
+ const Color& rCol)
+
+: SvLBoxString( pEntry, nFlags, rStr )
+{
+ DBG_CTOR(SvLBoxColorString,0);
+ aPrivColor=rCol;
+ SetText( pEntry, rStr );
+}
+
+/*************************************************************************
+#* Member: SvLBoxColorString Datum:23.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvLBoxColorString
+#*
+#* Funktion: Default Konstruktor der Klasse SvLBoxColorString
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+SvLBoxColorString::SvLBoxColorString()
+: SvLBoxString()
+{
+ DBG_CTOR(SvLBoxColorString,0);
+}
+
+/*************************************************************************
+#* Member: ~SvLBoxColorString Datum:23.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvLBoxColorString
+#*
+#* Funktion: Destruktor der Klasse SvLBoxColorString
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+SvLBoxColorString::~SvLBoxColorString()
+{
+ DBG_DTOR(SvLBoxColorString,0);
+}
+
+
+/*************************************************************************
+#* Member: SvLBoxColorString Datum:23.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvLBoxColorString
+#*
+#* Funktion: Erzeugt einen neuen SvLBoxColorString
+#*
+#* Input: ---
+#*
+#* Output: SvLBoxColorString
+#*
+#************************************************************************/
+
+SvLBoxItem* SvLBoxColorString::Create() const
+{
+ DBG_CHKTHIS(SvLBoxColorString,0);
+ return new SvLBoxColorString;
+}
+
+
+
+/*************************************************************************
+#* Member: SvLBoxColorString Datum:23.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvLBoxColorString
+#*
+#* Funktion: Zeichenroutine des SvLBoxColorString. Gezeichnet wird
+#* der entsprechende Text mit der eingestellten Farbe
+#* im Ausgabe- Device.
+#*
+#* Input: Position, Ausgabe- Device, Flag fuer Selection,
+#* Zeiger auf den Eintrag
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void SvLBoxColorString::Paint( const Point& rPos, SvLBox& rDev,
+ USHORT nFlags, SvLBoxEntry* pEntry )
+{
+ Color aColor=rDev.GetTextColor();
+ Color a2Color=aColor;
+ if(!(nFlags & SVLISTENTRYFLAG_SELECTED))
+ {
+ rDev.SetTextColor(aPrivColor);
+ }
+ SvLBoxString::Paint(rPos,rDev,nFlags,pEntry );
+ rDev.SetTextColor(a2Color);
+}
+
+//============================================================================
+// class SvxRedlinTable
+//----------------------------------------------------------------------------
+
+SvxRedlinTable::SvxRedlinTable( Window* pParent,WinBits nBits ):
+ SvxSimpleTable(pParent,nBits )
+{
+ bAuthor=FALSE;
+ bDate=FALSE;
+ bIsCalc=FALSE;
+ bComment=FALSE;
+ nDatePos=WRITER_DATE;
+ pCommentSearcher=NULL;
+ SetNodeDefaultImages();
+}
+
+SvxRedlinTable::SvxRedlinTable( Window* pParent,const ResId& rResId):
+ SvxSimpleTable(pParent,rResId)
+{
+ bAuthor=FALSE;
+ bDate=FALSE;
+ bIsCalc=FALSE;
+ bComment=FALSE;
+ nDatePos=WRITER_DATE;
+ pCommentSearcher=NULL;
+ SetNodeDefaultImages();
+}
+
+SvxRedlinTable::~SvxRedlinTable()
+{
+ if(pCommentSearcher!=NULL)
+ delete pCommentSearcher;
+}
+
+StringCompare SvxRedlinTable::ColCompare(SvLBoxEntry* pLeft,SvLBoxEntry* pRight)
+{
+ StringCompare eCompare=COMPARE_EQUAL;
+
+ if(aColCompareLink.IsSet())
+ {
+ SvSortData aRedlinCompare;
+ aRedlinCompare.pLeft=pLeft;
+ aRedlinCompare.pRight=pRight;
+ eCompare=(StringCompare) aColCompareLink.Call(&aRedlinCompare);
+ }
+ else
+ {
+ if(nDatePos==GetSortedCol())
+ {
+ RedlinData *pLeftData=(RedlinData *)(pLeft->GetUserData());
+ RedlinData *pRightData=(RedlinData *)(pRight->GetUserData());
+
+ if(pLeftData!=NULL && pRightData!=NULL)
+ {
+ if(pLeftData->aDateTime < pRightData->aDateTime)
+ {
+ eCompare=COMPARE_LESS;
+ }
+ else if(pLeftData->aDateTime > pRightData->aDateTime)
+ {
+ eCompare=COMPARE_GREATER;
+ }
+ }
+ else
+ eCompare=SvxSimpleTable::ColCompare(pLeft,pRight);
+ }
+ else
+ {
+ eCompare=SvxSimpleTable::ColCompare(pLeft,pRight);
+ }
+
+ }
+
+ return eCompare;
+}
+void SvxRedlinTable::SetCalcView(BOOL bFlag)
+{
+ bIsCalc=bFlag;
+ if(bFlag)
+ {
+ nDatePos=CALC_DATE;
+ }
+ else
+ {
+ nDatePos=WRITER_DATE;
+ }
+}
+
+
+void SvxRedlinTable::UpdateFilterTest()
+{
+ Date aDateMax;
+ USHORT nYEAR=aDateMax.GetYear()+100;
+ aDateMax.SetYear(nYEAR);
+ Date aDateMin(1,1,1989);
+ Time aTMin(0);
+ Time aTMax(23,59,59);
+
+
+ DateTime aDTMin(aDateMin);
+ DateTime aDTMax(aDateMax);
+
+ switch(nDaTiMode)
+ {
+ case FLT_DATE_BEFORE:
+ aDaTiFilterFirst=aDTMin;
+ aDaTiFilterLast=aDaTiFirst;
+ break;
+ case FLT_DATE_SAVE:
+ case FLT_DATE_SINCE:
+ aDaTiFilterFirst=aDaTiFirst;
+ aDaTiFilterLast=aDTMax;
+ break;
+ case FLT_DATE_EQUAL:
+ aDaTiFilterFirst=aDaTiFirst;
+ aDaTiFilterLast=aDaTiFirst;
+ aDaTiFilterFirst.SetTime(aTMin.GetTime());
+ aDaTiFilterLast.SetTime(aTMax.GetTime());
+ break;
+ case FLT_DATE_NOTEQUAL:
+ aDaTiFilterFirst=aDaTiFirst;
+ aDaTiFilterLast=aDaTiFirst;
+ aDaTiFilterFirst.SetTime(aTMin.GetTime());
+ aDaTiFilterLast.SetTime(aTMax.GetTime());
+ break;
+ case FLT_DATE_BETWEEN:
+ aDaTiFilterFirst=aDaTiFirst;
+ aDaTiFilterLast=aDaTiLast;
+ break;
+ }
+}
+
+
+void SvxRedlinTable::SetFilterDate(BOOL bFlag)
+{
+ bDate=bFlag;
+}
+
+void SvxRedlinTable::SetDateTimeMode(USHORT nMode)
+{
+ nDaTiMode=nMode;
+}
+
+void SvxRedlinTable::SetFirstDate(const Date& aDate)
+{
+ aDaTiFirst.SetDate(aDate.GetDate());
+}
+
+void SvxRedlinTable::SetLastDate(const Date& aDate)
+{
+ aDaTiLast.SetDate(aDate.GetDate());
+}
+
+void SvxRedlinTable::SetFirstTime(const Time& aTime)
+{
+ aDaTiFirst.SetTime(aTime.GetTime());
+}
+
+void SvxRedlinTable::SetLastTime(const Time& aTime)
+{
+ aDaTiLast.SetTime(aTime.GetTime());
+}
+
+void SvxRedlinTable::SetFilterAuthor(BOOL bFlag)
+{
+ bAuthor=bFlag;
+}
+
+void SvxRedlinTable::SetAuthor(const String &aString)
+{
+ aAuthor=aString;
+}
+
+void SvxRedlinTable::SetFilterComment(BOOL bFlag)
+{
+ bComment=bFlag;
+}
+
+void SvxRedlinTable::SetCommentParams( const utl::SearchParam* pSearchPara )
+{
+ if(pSearchPara!=NULL)
+ {
+ if(pCommentSearcher!=NULL) delete pCommentSearcher;
+
+ pCommentSearcher=new utl::TextSearch(*pSearchPara, LANGUAGE_SYSTEM );
+ }
+}
+
+BOOL SvxRedlinTable::IsValidWriterEntry(const String& rString,RedlinData *pUserData)
+{
+ BOOL nTheFlag=TRUE;
+ String aString=rString.GetToken(WRITER_AUTHOR,'\t');
+ if(pUserData==NULL)
+ {
+ if(bAuthor)
+ {
+ if(aAuthor.CompareTo(aString)==COMPARE_EQUAL)
+ nTheFlag=TRUE;
+ else
+ nTheFlag=FALSE;
+ }
+ }
+ else
+ {
+ DateTime aDateTime=pUserData->aDateTime;
+ nTheFlag=IsValidEntry(&aString,&aDateTime);
+ }
+ return nTheFlag;
+}
+
+BOOL SvxRedlinTable::IsValidCalcEntry(const String& rString,RedlinData *pUserData)
+{
+ BOOL nTheFlag=TRUE;
+ String aString=rString.GetToken(CALC_AUTHOR,'\t');
+ if(pUserData==NULL)
+ {
+ if(bAuthor)
+ {
+ if(aAuthor.CompareTo(aString)==COMPARE_EQUAL)
+ nTheFlag=TRUE;
+ else
+ nTheFlag=FALSE;
+ }
+ }
+ else
+ {
+ DateTime aDateTime=pUserData->aDateTime;
+ nTheFlag=IsValidEntry(&aString,&aDateTime);
+ }
+ return nTheFlag;
+}
+
+BOOL SvxRedlinTable::IsValidEntry(const String* pAuthorStr,
+ const DateTime *pDateTime,const String* pCommentStr)
+{
+ bool nTheFlag=true;
+ if(bAuthor)
+ {
+ nTheFlag = aAuthor.CompareTo(*pAuthorStr)==COMPARE_EQUAL;
+ }
+ if(bDate && nTheFlag)
+ {
+ if(nDaTiMode!=FLT_DATE_NOTEQUAL)
+ {
+ nTheFlag=pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast);
+ }
+ else
+ {
+ nTheFlag=!(pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast));
+ }
+ }
+ if(bComment && nTheFlag)
+ {
+ xub_StrLen nStartPos = 0;
+ xub_StrLen nEndPos = pCommentStr->Len();
+
+ nTheFlag=pCommentSearcher->SearchFrwrd( *pCommentStr, &nStartPos, &nEndPos);
+ }
+ return nTheFlag;
+}
+
+BOOL SvxRedlinTable::IsValidEntry(const String* pAuthorStr,const DateTime *pDateTime)
+{
+ BOOL nTheFlag=TRUE;
+ if(bAuthor)
+ {
+ if(aAuthor.CompareTo(*pAuthorStr)==COMPARE_EQUAL)
+ nTheFlag=TRUE;
+ else
+ nTheFlag=FALSE;
+ }
+ if(bDate && nTheFlag)
+ {
+ if(nDaTiMode!=FLT_DATE_NOTEQUAL)
+ {
+ nTheFlag=pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast);
+ }
+ else
+ {
+ nTheFlag=!(pDateTime->IsBetween(aDaTiFilterFirst,aDaTiFilterLast));
+ }
+ }
+ return nTheFlag;
+}
+
+BOOL SvxRedlinTable::IsValidComment(const String* pCommentStr)
+{
+ bool nTheFlag=true;
+
+ if(bComment)
+ {
+ xub_StrLen nStartPos = 0;
+ xub_StrLen nEndPos = pCommentStr->Len();
+
+ nTheFlag=pCommentSearcher->SearchFrwrd( *pCommentStr, &nStartPos, &nEndPos);
+ }
+ return nTheFlag;
+}
+
+SvLBoxEntry* SvxRedlinTable::InsertEntry(const String& rStr,RedlinData *pUserData,
+ SvLBoxEntry* pParent,ULONG nPos)
+{
+ aEntryColor=GetTextColor();
+ if(pUserData!=NULL)
+ {
+ if(pUserData->bDisabled)
+ aEntryColor=Color(COL_GRAY);
+ }
+
+ XubString aStr= rStr;
+
+ XubString aFirstStr( aStr );
+ xub_StrLen nEnd = aFirstStr.Search( sal_Unicode( '\t' ) );
+ if( nEnd != STRING_NOTFOUND )
+ {
+ aFirstStr.Erase( nEnd );
+ aCurEntry = aStr;
+ aCurEntry.Erase( 0, ++nEnd );
+ }
+ else
+ aCurEntry.Erase();
+
+ return SvTreeListBox::InsertEntry( aFirstStr, pParent, FALSE, nPos, pUserData );
+
+}
+
+SvLBoxEntry* SvxRedlinTable::InsertEntry(const String& rStr,RedlinData *pUserData,const Color& aColor,
+ SvLBoxEntry* pParent,ULONG nPos)
+{
+ aEntryColor=aColor;
+
+ XubString aStr= rStr;
+
+ XubString aFirstStr( aStr );
+ xub_StrLen nEnd = aFirstStr.Search( sal_Unicode ( '\t' ) );
+ if( nEnd != STRING_NOTFOUND )
+ {
+ aFirstStr.Erase( nEnd );
+ aCurEntry = aStr;
+ aCurEntry.Erase( 0, ++nEnd );
+ }
+ else
+ aCurEntry.Erase();
+
+ return SvTreeListBox::InsertEntry( aFirstStr, pParent, FALSE, nPos, pUserData );
+}
+
+SvLBoxEntry* SvxRedlinTable::CreateEntry() const
+{
+ return new SvxRedlinEntry;
+}
+
+void SvxRedlinTable::InitEntry( SvLBoxEntry* pEntry, const XubString& rStr,
+ const Image& rColl, const Image& rExp, SvLBoxButtonKind eButtonKind )
+{
+ SvLBoxButton* pButton;
+ SvLBoxString* pString;
+ SvLBoxContextBmp* pContextBmp;
+
+ if( nTreeFlags & TREEFLAG_CHKBTN )
+ {
+ pButton= new SvLBoxButton( pEntry,eButtonKind,0,pCheckButtonData );
+ pEntry->AddItem( pButton );
+ }
+
+ pContextBmp= new SvLBoxContextBmp( pEntry,0, rColl,rExp,
+ SVLISTENTRYFLAG_EXPANDED);
+ pEntry->AddItem( pContextBmp );
+
+ pString = new SvLBoxColorString( pEntry, 0, rStr ,aEntryColor);
+ pEntry->AddItem( pString );
+
+ XubString aToken;
+
+ xub_Unicode* pCurToken = (xub_Unicode*)aCurEntry.GetBuffer();
+ USHORT nCurTokenLen;
+ xub_Unicode* pNextToken = (xub_Unicode*)GetToken( pCurToken, nCurTokenLen );
+ USHORT nCount = TabCount(); nCount--;
+
+ for( USHORT nToken = 0; nToken < nCount; nToken++ )
+ {
+ if( pCurToken && nCurTokenLen )
+ // aToken.Assign( pCurToken, nCurTokenLen );
+ aToken = XubString( pCurToken, nCurTokenLen );
+ else
+ aToken.Erase();
+
+ SvLBoxColorString* pStr = new SvLBoxColorString( pEntry, 0, aToken ,aEntryColor);
+ pEntry->AddItem( pStr );
+
+ pCurToken = pNextToken;
+ if( pCurToken )
+ pNextToken = (xub_Unicode*)GetToken( pCurToken, nCurTokenLen );
+ else
+ nCurTokenLen = 0;
+ }
+}
+
+
+
+
+//============================================================================
+// class SvxTPView
+//----------------------------------------------------------------------------
+
+SvxTPView::SvxTPView( Window * pParent)
+ : TabPage( pParent, SVX_RES(SID_REDLIN_VIEW_PAGE)),
+ aViewData ( this, SVX_RES( DG_VIEW) ),
+ PbAccept ( this, SVX_RES(PB_ACCEPT ) ),
+ PbReject ( this, SVX_RES(PB_REJECT ) ),
+ PbAcceptAll ( this, SVX_RES(PB_ACCEPTALL ) ),
+ PbRejectAll ( this, SVX_RES(PB_REJECTALL ) ),
+ PbUndo ( this, SVX_RES(PB_UNDO ) ),
+ aTitle1 ( SVX_RES( STR_TITLE1 ) ), // lokale Resource
+ aTitle2 ( SVX_RES( STR_TITLE2 ) ),
+ aTitle3 ( SVX_RES( STR_TITLE3 ) ),
+ aTitle4 ( SVX_RES( STR_TITLE4 ) ),
+ aTitle5 ( SVX_RES( STR_TITLE5 ) ),
+ aStrMyName ( SVX_RES( STR_VIEW) )
+{
+ FreeResource();
+
+ aViewData.SetHelpId(HID_REDLINING_VIEW_DG_VIEW_TABLE);
+ aViewData.SetHeaderBarHelpId(HID_REDLINING_VIEW_DG_VIEW_HEADER);
+
+ aMinSize=GetSizePixel();
+
+ Link aLink=LINK( this, SvxTPView, PbClickHdl);
+
+ PbAccept.SetClickHdl(aLink);
+ PbAcceptAll.SetClickHdl(aLink);
+ PbReject.SetClickHdl(aLink);
+ PbRejectAll.SetClickHdl(aLink);
+ PbUndo.SetClickHdl(aLink);
+
+ nDistance=PbAccept.GetSizePixel().Height()+2*MIN_DISTANCE;
+ aViewData.SetTabs(nStaticTabs);
+}
+
+String SvxTPView::GetMyName() const
+{
+ return aStrMyName;
+}
+
+void SvxTPView::Resize()
+{
+ Size aSize=GetOutputSizePixel();
+ Point aPos=aViewData.GetPosPixel();
+ aSize.Height()-=aPos.Y()+nDistance;
+ aSize.Width()-=2*aPos.X();
+
+ long newY=aPos.Y()+aSize.Height()+MIN_DISTANCE;
+ aPos=PbAccept.GetPosPixel();
+ aPos.Y()=newY;
+ PbAccept.SetPosPixel(aPos);
+ aPos=PbAcceptAll.GetPosPixel();
+ aPos.Y()=newY;
+ PbAcceptAll.SetPosPixel(aPos);
+ aPos=PbReject.GetPosPixel();
+ aPos.Y()=newY;
+ PbReject.SetPosPixel(aPos);
+ aPos=PbRejectAll.GetPosPixel();
+ aPos.Y()=newY;
+ PbRejectAll.SetPosPixel(aPos);
+
+ if(PbUndo.IsVisible())
+ {
+ aPos=PbUndo.GetPosPixel();
+ aPos.Y()=newY;
+ PbUndo.SetPosPixel(aPos);
+ }
+ aViewData.SetSizePixel(aSize);
+}
+
+void SvxTPView::InsertWriterHeader()
+{
+ String aStrTab(sal_Unicode('\t'));
+ String aString(aTitle1);
+ aString+=aStrTab;
+ aString+=aTitle3;
+ aString+=aStrTab;
+ aString+=aTitle4;
+ aString+=aStrTab;
+ aString+=aTitle5;
+ aViewData.ClearHeader();
+ aViewData.InsertHeaderEntry(aString);
+}
+
+void SvxTPView::InsertCalcHeader()
+{
+ String aStrTab(sal_Unicode('\t'));
+ String aString(aTitle1);
+ aString+=aStrTab;
+ aString+=aTitle2;
+ aString+=aStrTab;
+ aString+=aTitle3;
+ aString+=aStrTab;
+ aString+=aTitle4;
+ aString+=aStrTab;
+ aString+=aTitle5;
+ aViewData.ClearHeader();
+ aViewData.InsertHeaderEntry(aString);
+}
+
+void SvxTPView::EnableAccept(BOOL nFlag)
+{
+ PbAccept.Enable(nFlag);
+}
+
+void SvxTPView::EnableAcceptAll(BOOL nFlag)
+{
+ PbAcceptAll.Enable(nFlag);
+}
+
+void SvxTPView::EnableReject(BOOL nFlag)
+{
+ PbReject.Enable(nFlag);
+}
+
+void SvxTPView::EnableRejectAll(BOOL nFlag)
+{
+ PbRejectAll.Enable(nFlag);
+}
+
+void SvxTPView::ShowUndo(BOOL nFlag)
+{
+ PbUndo.Show(nFlag);
+}
+
+void SvxTPView::EnableUndo(BOOL nFlag)
+{
+ PbUndo.Enable(nFlag);
+}
+
+Size SvxTPView::GetMinSizePixel()
+{
+ Size aSize=aMinSize;
+ if(PbUndo.IsVisible())
+ {
+ ULONG nSize=PbUndo.GetSizePixel().Width()
+ +PbUndo.GetPosPixel().X()
+ +PbAccept.GetPosPixel().X();
+
+ aSize.Width()=nSize;
+ }
+
+ return aSize;
+}
+
+
+SvxRedlinTable* SvxTPView::GetTableControl()
+{
+ return &aViewData;
+}
+
+IMPL_LINK( SvxTPView, PbClickHdl, PushButton*, pPushB )
+{
+ if(pPushB==&PbAccept)
+ {
+ AcceptClickLk.Call(this);
+ }
+ else if(pPushB==&PbAcceptAll)
+ {
+ AcceptAllClickLk.Call(this);
+ }
+ else if(pPushB==&PbReject)
+ {
+ RejectClickLk.Call(this);
+ }
+ else if(pPushB==&PbRejectAll)
+ {
+ RejectAllClickLk.Call(this);
+ }
+ else if(pPushB==&PbUndo)
+ {
+ UndoClickLk.Call(this);
+ }
+
+ return 0;
+}
+
+
+
+
+//============================================================================
+// class SvxTPFilter
+//----------------------------------------------------------------------------
+
+SvxTPFilter::SvxTPFilter( Window * pParent)
+ : TabPage( pParent, SVX_RES(SID_REDLIN_FILTER_PAGE)),
+ pRedlinTable(NULL),
+ aCbDate ( this, SVX_RES( CB_DATE ) ),
+ aLbDate ( this, SVX_RES( LB_DATE ) ),
+ aDfDate ( this, SVX_RES( DF_DATE ) ),
+ aTfDate ( this, SVX_RES( TF_DATE ) ),
+ aIbClock ( this, SVX_RES( IB_CLOCK ) ),
+ aFtDate2 ( this, SVX_RES( FT_DATE2 ) ),
+ aDfDate2 ( this, SVX_RES( DF_DATE2 ) ),
+ aTfDate2 ( this, SVX_RES( TF_DATE2 ) ),
+ aIbClock2 ( this, SVX_RES( IB_CLOCK2) ),
+ aCbAuthor ( this, SVX_RES( CB_AUTOR ) ),
+ aLbAuthor ( this, SVX_RES( LB_AUTOR ) ),
+ aCbRange ( this, SVX_RES( CB_RANGE ) ),
+ aEdRange ( this, SVX_RES( ED_RANGE ) ),
+ aBtnRange ( this, SVX_RES( BTN_REF ) ),
+ aLbAction ( this, SVX_RES( LB_ACTION ) ),
+ aCbComment ( this, SVX_RES( CB_COMMENT) ),
+ aEdComment ( this, SVX_RES( ED_COMMENT) ),
+ aActionStr ( SVX_RES( STR_ACTION) ),
+ aStrMyName ( SVX_RES( STR_FILTER) ),
+ bModified (FALSE)
+{
+ Image aImgTimeHC( SVX_RES( IMG_TIME_H ) );
+ FreeResource();
+
+ aIbClock.SetModeImage( aImgTimeHC, BMP_COLOR_HIGHCONTRAST );
+ aIbClock2.SetModeImage( aImgTimeHC, BMP_COLOR_HIGHCONTRAST );
+
+ aDfDate.SetShowDateCentury( TRUE );
+ aDfDate2.SetShowDateCentury( TRUE );
+
+ aRangeStr=aCbRange.GetText();
+ aLbDate.SelectEntryPos(0);
+ aLbDate.SetSelectHdl( LINK( this, SvxTPFilter, SelDateHdl ) );
+ aIbClock.SetClickHdl( LINK( this, SvxTPFilter, TimeHdl) );
+ aIbClock2.SetClickHdl( LINK( this, SvxTPFilter,TimeHdl) );
+ aBtnRange.SetClickHdl( LINK( this, SvxTPFilter, RefHandle));
+
+ Link aLink=LINK( this, SvxTPFilter, RowEnableHdl) ;
+ aCbDate.SetClickHdl(aLink);
+ aCbAuthor.SetClickHdl(aLink);
+ aCbRange.SetClickHdl(aLink);
+ aCbComment.SetClickHdl(aLink);
+
+ Link a2Link=LINK( this, SvxTPFilter, ModifyDate);
+ aDfDate.SetModifyHdl(a2Link);
+ aTfDate.SetModifyHdl(a2Link);
+ aDfDate2.SetModifyHdl(a2Link);
+ aTfDate2.SetModifyHdl(a2Link);
+
+ Link a3Link=LINK( this, SvxTPFilter, ModifyHdl);
+ aEdRange.SetModifyHdl(a3Link);
+ aEdComment.SetModifyHdl(a3Link);
+ aLbAction.SetSelectHdl(a3Link);
+ aLbAuthor.SetSelectHdl(a3Link);
+
+ RowEnableHdl(&aCbDate);
+ RowEnableHdl(&aCbAuthor);
+ RowEnableHdl(&aCbRange);
+ RowEnableHdl(&aCbComment);
+
+ Date aDate;
+ Time aTime;
+ aDfDate.SetDate(aDate);
+ aTfDate.SetTime(aTime);
+ aDfDate2.SetDate(aDate);
+ aTfDate2.SetTime(aTime);
+ HideRange();
+ ShowAction();
+ bModified=FALSE;
+}
+
+void SvxTPFilter::SetRedlinTable(SvxRedlinTable* pTable)
+{
+ pRedlinTable=pTable;
+}
+
+String SvxTPFilter::GetMyName() const
+{
+ return aStrMyName;
+}
+
+void SvxTPFilter::DisableRange(BOOL bFlag)
+{
+ if(bFlag)
+ {
+ aCbRange.Disable();
+ aEdRange.Disable();
+ aBtnRange.Disable();
+ }
+ else
+ {
+ aCbRange.Enable();
+ aEdRange.Enable();
+ aBtnRange.Enable();
+ }
+}
+
+void SvxTPFilter::ShowDateFields(USHORT nKind)
+{
+ String aEmpty;
+ switch(nKind)
+ {
+ case FLT_DATE_BEFORE:
+ EnableDateLine1(TRUE);
+ EnableDateLine2(FALSE);
+ break;
+ case FLT_DATE_SINCE:
+ EnableDateLine1(TRUE);
+ EnableDateLine2(FALSE);
+ break;
+ case FLT_DATE_EQUAL:
+ EnableDateLine1(TRUE);
+ aTfDate.Disable();
+ aTfDate.SetText(aEmpty);
+ EnableDateLine2(FALSE);
+ break;
+ case FLT_DATE_NOTEQUAL:
+ EnableDateLine1(TRUE);
+ aTfDate.Disable();
+ aTfDate.SetText(aEmpty);
+ EnableDateLine2(FALSE);
+ break;
+ case FLT_DATE_BETWEEN:
+ EnableDateLine1(TRUE);
+ EnableDateLine2(TRUE);
+ break;
+ case FLT_DATE_SAVE:
+ EnableDateLine1(FALSE);
+ EnableDateLine2(FALSE);
+ break;
+ }
+}
+
+void SvxTPFilter::EnableDateLine1(BOOL bFlag)
+{
+ if(bFlag && aCbDate.IsChecked())
+ {
+ aDfDate.Enable();
+ aTfDate.Enable();
+ aIbClock.Enable();
+ }
+ else
+ {
+ aDfDate.Disable();
+ aTfDate.Disable();
+ aIbClock.Disable();
+ }
+}
+void SvxTPFilter::EnableDateLine2(BOOL bFlag)
+{
+ String aEmpty;
+ if(bFlag && aCbDate.IsChecked())
+ {
+ aFtDate2.Enable();
+ aDfDate2.Enable();
+ aTfDate2.Enable();
+ aIbClock2.Enable();
+ }
+ else
+ {
+ aFtDate2.Disable();
+ aDfDate2.Disable();
+ aDfDate2.SetText(aEmpty);
+ aTfDate2.Disable();
+ aTfDate2.SetText(aEmpty);
+ aIbClock2.Disable();
+ }
+}
+
+Date SvxTPFilter::GetFirstDate() const
+{
+ return aDfDate.GetDate();
+}
+
+void SvxTPFilter::SetFirstDate(const Date &aDate)
+{
+ aDfDate.SetDate(aDate);
+}
+
+Time SvxTPFilter::GetFirstTime() const
+{
+ return aTfDate.GetTime();
+}
+
+void SvxTPFilter::SetFirstTime(const Time &aTime)
+{
+ aTfDate.SetTime(aTime);
+}
+
+
+Date SvxTPFilter::GetLastDate() const
+{
+ return aDfDate2.GetDate();
+}
+
+void SvxTPFilter::SetLastDate(const Date &aDate)
+{
+ aDfDate2.SetDate(aDate);
+}
+
+Time SvxTPFilter::GetLastTime() const
+{
+ return aTfDate2.GetTime();
+}
+
+void SvxTPFilter::SetLastTime(const Time &aTime)
+{
+ aTfDate2.SetTime(aTime);
+}
+
+void SvxTPFilter::SetDateMode(USHORT nMode)
+{
+ aLbDate.SelectEntryPos(nMode);
+ SelDateHdl(&aLbDate);
+}
+
+USHORT SvxTPFilter::GetDateMode()
+{
+ return (USHORT) aLbDate.GetSelectEntryPos();
+}
+void SvxTPFilter::ClearAuthors()
+{
+ aLbAuthor.Clear();
+}
+
+void SvxTPFilter::InsertAuthor( const String& rString, USHORT nPos)
+{
+ aLbAuthor.InsertEntry(rString,nPos);
+}
+
+String SvxTPFilter::GetSelectedAuthor() const
+{
+ return aLbAuthor.GetSelectEntry();
+}
+
+USHORT SvxTPFilter::GetSelectedAuthorPos()
+{
+ return (USHORT) aLbAuthor.GetSelectEntryPos();
+}
+
+void SvxTPFilter::SelectedAuthorPos(USHORT nPos)
+{
+ aLbAuthor.SelectEntryPos(nPos);
+}
+
+USHORT SvxTPFilter::SelectAuthor(const String& aString)
+{
+ aLbAuthor.SelectEntry(aString);
+ return aLbAuthor.GetSelectEntryPos();
+}
+
+void SvxTPFilter::SetRange(const String& rString)
+{
+ aEdRange.SetText(rString);
+}
+
+String SvxTPFilter::GetRange() const
+{
+ return aEdRange.GetText();
+}
+
+void SvxTPFilter::SetFocusToRange()
+{
+ aEdRange.GrabFocus();
+}
+
+void SvxTPFilter::HideRange(BOOL bHide)
+{
+ if(bHide)
+ {
+ aCbRange.Hide();
+ aEdRange.Hide();
+ aBtnRange.Hide();
+ }
+ else
+ {
+ ShowAction(FALSE);
+ aCbRange.SetText(aRangeStr);
+ aCbRange.Show();
+ aEdRange.Show();
+ aBtnRange.Show();
+ }
+}
+
+void SvxTPFilter::HideClocks(BOOL bHide)
+{
+ if(bHide)
+ {
+ aIbClock. Hide();
+ aIbClock2.Hide();
+ }
+ else
+ {
+ aIbClock. Show();
+ aIbClock2.Show();
+ }
+}
+
+void SvxTPFilter::SetComment(const String &rComment)
+{
+ aEdComment.SetText(rComment);
+}
+String SvxTPFilter::GetComment()const
+{
+ return aEdComment.GetText();
+}
+
+BOOL SvxTPFilter::IsDate()
+{
+ return aCbDate.IsChecked();
+}
+
+BOOL SvxTPFilter::IsAuthor()
+{
+ return aCbAuthor.IsChecked();
+}
+
+BOOL SvxTPFilter::IsRange()
+{
+ return aCbRange.IsChecked();
+}
+BOOL SvxTPFilter::IsAction()
+{
+ return aCbRange.IsChecked();
+}
+
+BOOL SvxTPFilter::IsComment()
+{
+ return aCbComment.IsChecked();
+}
+
+void SvxTPFilter::CheckDate(BOOL bFlag)
+{
+ aCbDate.Check(bFlag);
+ RowEnableHdl(&aCbDate);
+ bModified=FALSE;
+}
+
+void SvxTPFilter::CheckAuthor(BOOL bFlag)
+{
+ aCbAuthor.Check(bFlag);
+ RowEnableHdl(&aCbAuthor);
+ bModified=FALSE;
+}
+
+void SvxTPFilter::CheckRange(BOOL bFlag)
+{
+ aCbRange.Check(bFlag);
+ RowEnableHdl(&aCbRange);
+ bModified=FALSE;
+}
+
+void SvxTPFilter::CheckAction(BOOL bFlag)
+{
+ aCbRange.Check(bFlag);
+ RowEnableHdl(&aCbRange);
+ bModified=FALSE;
+}
+
+void SvxTPFilter::CheckComment(BOOL bFlag)
+{
+ aCbComment.Check(bFlag);
+ RowEnableHdl(&aCbComment);
+ bModified=FALSE;
+}
+
+void SvxTPFilter::ShowAction(BOOL bShow)
+{
+ if(!bShow)
+ {
+ aCbRange.Hide();
+ aLbAction.Hide();
+ aCbRange.SetHelpId(HID_REDLINING_FILTER_CB_RANGE);
+ }
+ else
+ {
+ HideRange();
+ aCbRange.SetText(aActionStr);
+ aCbRange.SetHelpId(HID_REDLINING_FILTER_CB_ACTION);
+ aCbRange.Show();
+ aLbAction.Show();
+
+ }
+}
+
+ListBox* SvxTPFilter::GetLbAction()
+{
+ return &aLbAction;
+}
+
+IMPL_LINK( SvxTPFilter, SelDateHdl, ListBox*, pLb )
+{
+ ShowDateFields((USHORT)aLbDate.GetSelectEntryPos());
+ ModifyHdl(pLb);
+ return 0;
+}
+
+IMPL_LINK( SvxTPFilter, RowEnableHdl, CheckBox*, pCB )
+{
+ if(pCB==&aCbDate)
+ {
+ aLbDate.Enable(aCbDate.IsChecked());
+ aLbDate.Invalidate();
+ EnableDateLine1(FALSE);
+ EnableDateLine2(FALSE);
+ if(aCbDate.IsChecked()) SelDateHdl(&aLbDate);
+ }
+ else if(pCB==&aCbAuthor)
+ {
+ aLbAuthor.Enable(aCbAuthor.IsChecked());
+ aLbAuthor.Invalidate();
+ }
+ else if(pCB==&aCbRange)
+ {
+ aLbAction.Enable(aCbRange.IsChecked());
+ aLbAction.Invalidate();
+ aEdRange.Enable(aCbRange.IsChecked());
+ aBtnRange.Enable(aCbRange.IsChecked());
+ }
+ else if(pCB==&aCbComment)
+ {
+ aEdComment.Enable(aCbComment.IsChecked());
+ aEdComment.Invalidate();
+ }
+
+ ModifyHdl(pCB);
+ return 0;
+}
+
+IMPL_LINK( SvxTPFilter, TimeHdl, ImageButton*,pIB )
+{
+ Date aDate;
+ Time aTime;
+ if(pIB==&aIbClock)
+ {
+ aDfDate.SetDate(aDate);
+ aTfDate.SetTime(aTime);
+ }
+ else if(pIB==&aIbClock2)
+ {
+ aDfDate2.SetDate(aDate);
+ aTfDate2.SetTime(aTime);
+ }
+ ModifyHdl(&aDfDate);
+ return 0;
+}
+
+IMPL_LINK( SvxTPFilter, ModifyHdl, void*, pCtr)
+{
+ if(pCtr!=NULL)
+ {
+ if(pCtr==&aCbDate || pCtr==&aLbDate ||
+ pCtr==&aDfDate || pCtr==&aTfDate ||
+ pCtr==&aIbClock || pCtr==&aFtDate2||
+ pCtr==&aDfDate2 || pCtr==&aTfDate2||
+ pCtr==&aIbClock2)
+ {
+ aModifyDateLink.Call(this);
+ }
+ else if(pCtr==&aCbAuthor || pCtr==&aLbAuthor)
+ {
+ aModifyAuthorLink.Call(this);
+ }
+ else if(pCtr==&aCbRange || pCtr==&aEdRange ||
+ pCtr==&aBtnRange )
+ {
+ aModifyRefLink.Call(this);
+ }
+ else if(pCtr==&aCbComment || pCtr==&aEdComment)
+ {
+ aModifyComLink.Call(this);
+ }
+
+ bModified=TRUE;
+ aModifyLink.Call(this);
+ }
+ return 0;
+}
+
+void SvxTPFilter::DeactivatePage()
+{
+ if(bModified)
+ {
+ if(pRedlinTable!=NULL)
+ {
+ pRedlinTable->SetFilterDate(IsDate());
+ pRedlinTable->SetDateTimeMode(GetDateMode());
+ pRedlinTable->SetFirstDate(aDfDate.GetDate());
+ pRedlinTable->SetLastDate(aDfDate2.GetDate());
+ pRedlinTable->SetFirstTime(aTfDate.GetTime());
+ pRedlinTable->SetLastTime(aTfDate2.GetTime());
+ pRedlinTable->SetFilterAuthor(IsAuthor());
+ pRedlinTable->SetAuthor(GetSelectedAuthor());
+
+ pRedlinTable->SetFilterComment(IsComment());
+
+ utl::SearchParam aSearchParam( aEdComment.GetText(),
+ utl::SearchParam::SRCH_REGEXP,FALSE,FALSE,FALSE );
+
+ pRedlinTable->SetCommentParams(&aSearchParam);
+
+ pRedlinTable->UpdateFilterTest();
+ }
+
+ aReadyLink.Call(this);
+ }
+ bModified=FALSE;
+ TabPage::DeactivatePage();
+}
+
+void SvxTPFilter::Enable( bool bEnable, bool bChild)
+{
+ TabPage::Enable(bEnable,bChild);
+ if(aCbDate.IsEnabled())
+ {
+ RowEnableHdl(&aCbDate);
+ RowEnableHdl(&aCbAuthor);
+ RowEnableHdl(&aCbRange);
+ RowEnableHdl(&aCbComment);
+ }
+}
+void SvxTPFilter::Disable( bool bChild)
+{
+ Enable( false, bChild );
+}
+
+IMPL_LINK( SvxTPFilter, ModifyDate, void*,pTF)
+{
+
+ Date aDate;
+ Time aTime(0);
+ if(&aDfDate==pTF)
+ {
+ if(aDfDate.GetText().Len()==0)
+ aDfDate.SetDate(aDate);
+
+ if(pRedlinTable!=NULL)
+ pRedlinTable->SetFirstDate(aDfDate.GetDate());
+ }
+ else if(&aDfDate2==pTF)
+ {
+ if(aDfDate2.GetText().Len()==0)
+ aDfDate2.SetDate(aDate);
+
+ if(pRedlinTable!=NULL)
+ pRedlinTable->SetLastDate(aDfDate2.GetDate());
+ }
+ else if(&aTfDate==pTF)
+ {
+ if(aTfDate.GetText().Len()==0)
+ aTfDate.SetTime(aTime);
+
+ if(pRedlinTable!=NULL)
+ pRedlinTable->SetFirstTime(aTfDate.GetTime());
+ }
+ else if(&aTfDate2==pTF)
+ {
+ if(aTfDate2.GetText().Len()==0)
+ aTfDate2.SetTime(aTime);
+
+ if(pRedlinTable!=NULL)
+ pRedlinTable->SetLastTime(aTfDate2.GetTime());
+
+ }
+ ModifyHdl(&aDfDate);
+ return 0;
+}
+
+IMPL_LINK( SvxTPFilter, RefHandle, PushButton*, pRef )
+{
+ if(pRef!=NULL)
+ {
+ aRefLink.Call(this);
+ }
+ return 0;
+}
+
+static Size gDiffSize;
+//============================================================================
+// class SvxAcceptChgCtr
+//----------------------------------------------------------------------------
+
+SvxAcceptChgCtr::SvxAcceptChgCtr( Window* pParent, WinBits nWinStyle)
+ : Control(pParent,nWinStyle |WB_DIALOGCONTROL),
+ aTCAccept(this,WB_TABSTOP |WB_DIALOGCONTROL)
+{
+ pTPFilter=new SvxTPFilter(&aTCAccept);
+ pTPView=new SvxTPView(&aTCAccept);
+ aMinSize=pTPView->GetMinSizePixel();
+
+ aTCAccept.InsertPage( TP_VIEW, pTPView->GetMyName());
+ aTCAccept.InsertPage( TP_FILTER, pTPFilter->GetMyName());
+ aTCAccept.SetTabPage( TP_VIEW, pTPView);
+ aTCAccept.SetTabPage( TP_FILTER, pTPFilter);
+ aTCAccept.SetHelpId(HID_REDLINING_TABCONTROL);
+
+ aTCAccept.SetTabPageSizePixel(aMinSize);
+ Size aSize=aTCAccept.GetSizePixel();
+
+ gDiffSize.Height()=aSize.Height()-aMinSize.Height();
+ gDiffSize.Width()=aSize.Width()-aMinSize.Width();
+
+
+ pTPFilter->SetRedlinTable(GetViewTable());
+
+ aTCAccept.Show();
+ ShowViewPage();
+}
+
+SvxAcceptChgCtr::SvxAcceptChgCtr( Window* pParent, const ResId& rResId )
+ : Control(pParent,rResId ),
+ aTCAccept(this,WB_TABSTOP |WB_DIALOGCONTROL)
+{
+ pTPFilter=new SvxTPFilter(&aTCAccept);
+ pTPView=new SvxTPView(&aTCAccept);
+ aMinSize=pTPView->GetMinSizePixel();
+
+ aTCAccept.InsertPage( TP_VIEW, pTPView->GetMyName());
+ aTCAccept.InsertPage( TP_FILTER, pTPFilter->GetMyName());
+ aTCAccept.SetTabPage( TP_VIEW, pTPView);
+ aTCAccept.SetTabPage( TP_FILTER, pTPFilter);
+ aTCAccept.SetHelpId(HID_REDLINING_TABCONTROL);
+
+ aTCAccept.SetTabPageSizePixel(aMinSize);
+ Size aSize=aTCAccept.GetSizePixel();
+
+ gDiffSize.Height()=aSize.Height()-aMinSize.Height();
+ gDiffSize.Width()=aSize.Width()-aMinSize.Width();
+
+
+ pTPFilter->SetRedlinTable(GetViewTable());
+ WinBits nWinStyle=GetStyle()|WB_DIALOGCONTROL;
+ SetStyle(nWinStyle);
+
+ aTCAccept.Show();
+ ShowViewPage();
+ Resize();
+}
+
+SvxAcceptChgCtr::~SvxAcceptChgCtr()
+{
+ delete pTPView;
+ delete pTPFilter;
+}
+
+void SvxAcceptChgCtr::Resize()
+{
+ aMinSize=pTPView->GetMinSizePixel();
+ Size aSize=GetOutputSizePixel();
+ BOOL bFlag=FALSE;
+
+ if(aMinSize.Height()>aSize.Height())
+ {
+ aSize.Height()=aMinSize.Height();
+ bFlag=TRUE;
+ }
+ if(aMinSize.Width()>aSize.Width())
+ {
+ aSize.Width()=aMinSize.Width();
+ bFlag=TRUE;
+ }
+
+ if(bFlag)
+ {
+ SetOutputSizePixel(aSize);
+ aMinSizeLink.Call(this);
+ }
+
+ aSize.Height()-=2;
+ aSize.Width()-=2;
+ aTCAccept.SetSizePixel(aSize);
+}
+
+Size SvxAcceptChgCtr::GetMinSizePixel() const
+{
+ Size aSize=pTPView->GetMinSizePixel();
+ aSize.Height()+=gDiffSize.Height();
+ aSize.Width()+=gDiffSize.Width();
+ return aSize;
+}
+
+void SvxAcceptChgCtr::ShowFilterPage()
+{
+ aTCAccept.SetCurPageId(TP_FILTER);
+}
+
+void SvxAcceptChgCtr::ShowViewPage()
+{
+ aTCAccept.SetCurPageId(TP_VIEW);
+}
+
+BOOL SvxAcceptChgCtr::IsFilterPageVisible()
+{
+ return (aTCAccept.GetCurPageId()==TP_FILTER);
+}
+
+BOOL SvxAcceptChgCtr::IsViewPageVisible()
+{
+ return (aTCAccept.GetCurPageId()==TP_VIEW);
+}
+
+SvxTPFilter* SvxAcceptChgCtr::GetFilterPage()
+{
+ return pTPFilter;
+}
+
+SvxTPView* SvxAcceptChgCtr::GetViewPage()
+{
+ return pTPView;
+}
+
+SvxRedlinTable* SvxAcceptChgCtr::GetViewTable()
+{
+ if(pTPView!=NULL)
+ {
+ return pTPView->GetTableControl();
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/ctredlin.hrc b/svx/source/dialog/ctredlin.hrc
new file mode 100644
index 000000000000..cba699d8394b
--- /dev/null
+++ b/svx/source/dialog/ctredlin.hrc
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/svxids.hrc> // ->SID_REDLIN_FILTER_PAGE
+ // ->SID_REDLIN_VIEW_PAGE
+
+#define TP_FILTER 11
+#define TP_VIEW 12
+
+#define LB_DATE 1
+#define DF_DATE 2
+#define TF_DATE 3
+#define LB_AUTOR 4
+#define ED_RANGE 5
+#define IB_CLOCK 6
+#define BTN_REF 7
+#define CB_DATE 8
+#define CB_AUTOR 9
+#define CB_RANGE 10
+#define FT_DATE2 12
+#define DF_DATE2 13
+#define TF_DATE2 14
+#define IB_CLOCK2 15
+#define STR_FILTER 16
+#define STR_ACTION 17
+#define LB_ACTION 18
+#define CB_COMMENT 19
+#define ED_COMMENT 20
+#define IMG_TIME_H 30
+
+#define HG_VIEW 1
+#define DG_VIEW 2
+#define PB_ACCEPT 3
+#define PB_ACCEPTALL 4
+#define PB_REJECT 5
+#define PB_REJECTALL 6
+#define PB_UNDO 7
+#define STR_VIEW 8
+
+#define STR_TITLE1 1
+#define STR_TITLE2 2
+#define STR_TITLE3 3
+#define STR_TITLE4 4
+#define STR_TITLE5 5
+//
+
diff --git a/svx/source/dialog/ctredlin.src b/svx/source/dialog/ctredlin.src
new file mode 100644
index 000000000000..3ca9f104801a
--- /dev/null
+++ b/svx/source/dialog/ctredlin.src
@@ -0,0 +1,365 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "ctredlin.hrc"
+#include "helpid.hrc"
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; } ;
+
+TabPage SID_REDLIN_FILTER_PAGE
+{
+ String STR_FILTER
+ {
+ Text [ en-US ] = "Filter" ;
+ };
+ HelpId = HID_REDLINING_FILTER_PAGE ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 261 , 86 ) ;
+ Hide = TRUE ;
+ CheckBox CB_DATE
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ TabStop = TRUE ;
+ HelpId = HID_REDLINING_FILTER_CB_DATE ;
+ Text [ en-US ] = "~Date" ;
+ };
+ ListBox LB_DATE
+ {
+ HelpId = HID_REDLINING_FILTER_LB_DATE ;
+ Border = TRUE ;
+ Disable = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 6 ) ;
+ Size = MAP_APPFONT ( 78 , 99 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "earlier than" ; Default ; > ;
+ < "since" ; Default ; > ;
+ < "equal to " ; Default ; > ;
+ < "not equal to" ; Default ; > ;
+ < "between" ; Default ; > ;
+ < "since saving" ; Default ; > ;
+ };
+ };
+ DateField DF_DATE
+ {
+ HelpId = HID_REDLINING_FILTER_DF_DATE ;
+ Disable = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 144 , 6 ) ;
+ Size = MAP_APPFONT ( 57 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = Date
+ {
+ Year = 1985 ;
+ Month = 12 ;
+ Day = 31 ;
+ };
+ Maximum = Date
+ {
+ Year = 2050 ;
+ Month = 12 ;
+ Day = 31 ;
+ };
+ };
+ TimeField TF_DATE
+ {
+ HelpId = HID_REDLINING_FILTER_TF_DATE ;
+ Disable = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 203 , 6 ) ;
+ Size = MAP_APPFONT ( 35 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ };
+ ImageButton IB_CLOCK
+ {
+ HelpId = HID_REDLINING_FILTER_IB_CLOCK ;
+ Disable = TRUE ;
+ Pos = MAP_APPFONT ( 240 , 5 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "time.bmp" ; };
+ MASKCOLOR
+ };
+ QuickHelpText [ en-US ] = "Set Date/Time" ;
+ };
+ FixedText FT_DATE2
+ {
+ Pos = MAP_APPFONT ( 60 , 24 ) ;
+ Size = MAP_APPFONT ( 78 , 8 ) ;
+ Right = TRUE ;
+ Disable = TRUE ;
+ Text [ en-US ] = "and" ;
+ };
+ DateField DF_DATE2
+ {
+ HelpId = HID_REDLINING_FILTER_DF_DATE2 ;
+ Border = TRUE ;
+ Disable = TRUE ;
+ Pos = MAP_APPFONT ( 144 , 22 ) ;
+ Size = MAP_APPFONT ( 57 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = Date
+ {
+ Year = 1985 ;
+ Month = 12 ;
+ Day = 31 ;
+ };
+ Maximum = Date
+ {
+ Year = 2050 ;
+ Month = 12 ;
+ Day = 31 ;
+ };
+ };
+ TimeField TF_DATE2
+ {
+ HelpId = HID_REDLINING_FILTER_TF_DATE2 ;
+ Border = TRUE ;
+ Disable = TRUE ;
+ Pos = MAP_APPFONT ( 203 , 22 ) ;
+ Size = MAP_APPFONT ( 35 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ };
+ ImageButton IB_CLOCK2
+ {
+ HelpId = HID_REDLINING_FILTER_IB_CLOCK2 ;
+ Disable = TRUE ;
+ Pos = MAP_APPFONT ( 240 , 21 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "time.bmp" ; };
+ MASKCOLOR
+ };
+ QuickHelpText [ en-US ] = "Set Date/Time" ;
+ };
+ CheckBox CB_AUTOR
+ {
+ HelpId = HID_REDLINING_FILTER_CB_AUTOR ;
+ Pos = MAP_APPFONT ( 6 , 40 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Author" ;
+ };
+ ListBox LB_AUTOR
+ {
+ HelpId = HID_REDLINING_FILTER_LB_AUTOR ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 38 ) ;
+ Size = MAP_APPFONT ( 178 , 100 ) ;
+ TabStop = TRUE ;
+ Disable = TRUE ;
+ DropDown = TRUE ;
+ };
+ CheckBox CB_RANGE
+ {
+ HelpId = HID_REDLINING_FILTER_CB_RANGE ;
+ Pos = MAP_APPFONT ( 6 , 56 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Range" ;
+ };
+ Edit ED_RANGE
+ {
+ HelpId = HID_REDLINING_FILTER_ED_RANGE ;
+ Disable = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 54 ) ;
+ Size = MAP_APPFONT ( 178 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_ACTION
+ {
+ Text [ en-US ] = "A~ction" ;
+ };
+ ListBox LB_ACTION
+ {
+ HelpId = HID_REDLINING_FILTER_LB_ACTION ;
+ Border = TRUE ;
+ Hide = TRUE ;
+ Disable = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 54 ) ;
+ Size = MAP_APPFONT ( 178 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ PushButton BTN_REF
+ {
+ HelpId = HID_REDLINING_FILTER_BTN_REF ;
+ Pos = MAP_APPFONT ( 240 , 54 ) ;
+ Size = MAP_APPFONT ( 12 , 12 ) ;
+ Disable = TRUE ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Set Reference" ;
+ Text [ en-US ] = "..." ;
+ };
+ CheckBox CB_COMMENT
+ {
+ HelpId = HID_REDLINING_FILTER_CB_COMMENT ;
+ Pos = MAP_APPFONT ( 6 , 72 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Comment";
+ };
+ Edit ED_COMMENT
+ {
+ HelpId = HID_REDLINING_FILTER_ED_COMMENT ;
+ Disable = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 60 , 70 ) ;
+ Size = MAP_APPFONT ( 178 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ Image IMG_TIME_H
+ {
+ ImageBitmap = Bitmap { File = "time_h.bmp" ; };
+ MASKCOLOR
+ };
+};
+TabPage SID_REDLIN_VIEW_PAGE
+{
+ HelpId = HID_REDLINING_VIEW_PAGE ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 126 ) ;
+ Hide = TRUE ;
+ String STR_VIEW
+ {
+ Text [ en-US ] = "List" ;
+ };
+ Control DG_VIEW
+ {
+ HelpId = HID_REDLINING_VIEW_DG_VIEW ;
+ Pos = MAP_APPFONT ( 3 , 1 ) ;
+ Size = MAP_APPFONT ( 221 , 65 ) ;
+ Border = TRUE ;
+ };
+ PushButton PB_ACCEPT
+ {
+ HelpId = HID_REDLINING_VIEW_PB_ACCEPT ;
+ Pos = MAP_APPFONT ( 3 , 69 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~Accept" ;
+ };
+ PushButton PB_REJECT
+ {
+ HelpId = HID_REDLINING_VIEW_PB_REJECT ;
+ Pos = MAP_APPFONT ( 69 , 69 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~Reject" ;
+ };
+ PushButton PB_ACCEPTALL
+ {
+ HelpId = HID_REDLINING_VIEW_PB_ACCEPTALL ;
+ Pos = MAP_APPFONT ( 141 , 69 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "A~ccept All" ;
+ };
+ PushButton PB_REJECTALL
+ {
+ HelpId = HID_REDLINING_VIEW_PB_REJECTALL ;
+ Pos = MAP_APPFONT ( 207 , 69 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "R~eject All" ;
+ };
+
+ PushButton PB_UNDO
+ {
+ HelpId = HID_REDLINING_VIEW_PB_UNDO ;
+ Hide = TRUE;
+ Pos = MAP_APPFONT ( 279 , 69 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "Undo";
+ };
+ String STR_TITLE1
+ {
+ Text [ en-US ] = "Action" ;
+ };
+ String STR_TITLE2
+ {
+ Text [ en-US ] = "Position" ;
+ };
+ String STR_TITLE3
+ {
+ Text [ en-US ] = "Author" ;
+ };
+ String STR_TITLE4
+ {
+ Text [ en-US ] = "Date" ;
+ };
+ String STR_TITLE5
+ {
+ Text [ en-US ] = "Comment" ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/databaseregistrationui.cxx b/svx/source/dialog/databaseregistrationui.cxx
new file mode 100644
index 000000000000..ce496d42726f
--- /dev/null
+++ b/svx/source/dialog/databaseregistrationui.cxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// === includes (declaration) ============================================
+#include "databaseregistrationui.hxx"
+
+// === includes (project) ================================================
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+
+// === includes (global) =================================================
+#include <sfx2/app.hxx>
+#include <svl/itemset.hxx>
+#include <vcl/msgbox.hxx>
+
+
+namespace svx
+{
+ USHORT administrateDatabaseRegistration( Window* _parentWindow )
+ {
+ USHORT nResult = RET_CANCEL;
+
+ SfxItemSet aRegistrationItems( SFX_APP()->GetPool(), SID_SB_DB_REGISTER, SID_SB_DB_REGISTER, 0 );
+
+ SvxAbstractDialogFactory* pDialogFactory = SvxAbstractDialogFactory::Create();
+ ::std::auto_ptr< SfxAbstractDialog > pDialog;
+ if ( pDialogFactory )
+ pDialog.reset( pDialogFactory->CreateSfxDialog( _parentWindow, aRegistrationItems, NULL, RID_SFXPAGE_DBREGISTER ) );
+ if ( pDialog.get() )
+ nResult = pDialog->Execute();
+
+ return nResult;
+ }
+
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/dialcontrol.cxx b/svx/source/dialog/dialcontrol.cxx
new file mode 100644
index 000000000000..d5d5d5cfd994
--- /dev/null
+++ b/svx/source/dialog/dialcontrol.cxx
@@ -0,0 +1,574 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "dialcontrol.hxx"
+
+#include <math.h>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/field.hxx>
+#include <svtools/colorcfg.hxx>
+
+namespace svx {
+
+// ============================================================================
+
+const long DIAL_OUTER_WIDTH = 8;
+
+// ============================================================================
+
+class DialControlBmp : public VirtualDevice
+{
+public:
+ explicit DialControlBmp( Window& rParent );
+
+ void InitBitmap( const Size& rSize, const Font& rFont );
+ void CopyBackground( const DialControlBmp& rSrc );
+ void DrawBackground( const Size& rSize, bool bEnabled );
+ void DrawElements( const String& rText, sal_Int32 nAngle );
+
+private:
+ const Color& GetBackgroundColor() const;
+ const Color& GetTextColor() const;
+ const Color& GetScaleLineColor() const;
+ const Color& GetButtonLineColor() const;
+ const Color& GetButtonFillColor( bool bMain ) const;
+
+ void Init( const Size& rSize );
+ void DrawBackground();
+
+ Window& mrParent;
+ Rectangle maRect;
+ long mnCenterX;
+ long mnCenterY;
+ bool mbEnabled;
+};
+
+// ----------------------------------------------------------------------------
+
+DialControlBmp::DialControlBmp( Window& rParent ) :
+ VirtualDevice( rParent, 0, 0 ),
+ mrParent( rParent ),
+ mbEnabled( true )
+{
+ EnableRTL( FALSE );
+}
+
+void DialControlBmp::InitBitmap( const Size& rSize, const Font& rFont )
+{
+ Init( rSize );
+ SetFont( rFont );
+}
+
+void DialControlBmp::CopyBackground( const DialControlBmp& rSrc )
+{
+ Init( rSrc.maRect.GetSize() );
+ mbEnabled = rSrc.mbEnabled;
+ Point aPos;
+ DrawBitmapEx( aPos, rSrc.GetBitmapEx( aPos, maRect.GetSize() ) );
+}
+
+void DialControlBmp::DrawBackground( const Size& rSize, bool bEnabled )
+{
+ Init( rSize );
+ mbEnabled = bEnabled;
+ DrawBackground();
+}
+
+void DialControlBmp::DrawElements( const String& rText, sal_Int32 nAngle )
+{
+ // *** rotated text ***
+
+ Font aFont( GetFont() );
+ aFont.SetColor( GetTextColor() );
+ aFont.SetOrientation( static_cast< short >( (nAngle + 5) / 10 ) ); // Font uses 1/10 degrees
+ aFont.SetWeight( WEIGHT_BOLD );
+ SetFont( aFont );
+
+ double fAngle = nAngle * F_PI180 / 100.0;
+ double fSin = sin( fAngle );
+ double fCos = cos( fAngle );
+ double fWidth = GetTextWidth( rText ) / 2.0;
+ double fHeight = GetTextHeight() / 2.0;
+ long nX = static_cast< long >( mnCenterX - fWidth * fCos - fHeight * fSin );
+ long nY = static_cast< long >( mnCenterY + fWidth * fSin - fHeight * fCos );
+ Rectangle aRect( nX, nY, 2 * mnCenterX - nX, 2 * mnCenterY - nY );
+ DrawText( aRect, rText, mbEnabled ? 0 : TEXT_DRAW_DISABLE );
+
+ // *** drag button ***
+
+ bool bMain = (nAngle % 4500) != 0;
+ SetLineColor( GetButtonLineColor() );
+ SetFillColor( GetButtonFillColor( bMain ) );
+
+ nX = mnCenterX - static_cast< long >( (DIAL_OUTER_WIDTH / 2 - mnCenterX) * fCos );
+ nY = mnCenterY - static_cast< long >( (mnCenterY - DIAL_OUTER_WIDTH / 2) * fSin );
+ long nSize = bMain ? (DIAL_OUTER_WIDTH / 4) : (DIAL_OUTER_WIDTH / 2 - 1);
+ DrawEllipse( Rectangle( nX - nSize, nY - nSize, nX + nSize, nY + nSize ) );
+}
+
+// private --------------------------------------------------------------------
+
+const Color& DialControlBmp::GetBackgroundColor() const
+{
+ return GetSettings().GetStyleSettings().GetDialogColor();
+}
+
+const Color& DialControlBmp::GetTextColor() const
+{
+ return GetSettings().GetStyleSettings().GetLabelTextColor();
+}
+
+const Color& DialControlBmp::GetScaleLineColor() const
+{
+ const StyleSettings& rSett = GetSettings().GetStyleSettings();
+ return mbEnabled ? rSett.GetButtonTextColor() : rSett.GetDisableColor();
+}
+
+const Color& DialControlBmp::GetButtonLineColor() const
+{
+ const StyleSettings& rSett = GetSettings().GetStyleSettings();
+ return mbEnabled ? rSett.GetButtonTextColor() : rSett.GetDisableColor();
+}
+
+const Color& DialControlBmp::GetButtonFillColor( bool bMain ) const
+{
+ const StyleSettings& rSett = GetSettings().GetStyleSettings();
+ return mbEnabled ? (bMain ? rSett.GetMenuColor() : rSett.GetHighlightColor()) : rSett.GetDisableColor();
+}
+
+void DialControlBmp::Init( const Size& rSize )
+{
+ SetSettings( mrParent.GetSettings() );
+ maRect.SetPos( Point( 0, 0 ) );
+ maRect.SetSize( rSize );
+ mnCenterX = rSize.Width() / 2;
+ mnCenterY = rSize.Height() / 2;
+ SetOutputSize( rSize );
+ SetBackground();
+}
+
+void DialControlBmp::DrawBackground()
+{
+ // *** background with 3D effect ***
+
+ SetLineColor();
+ SetFillColor();
+ Erase();
+
+ EnableRTL( TRUE ); // #107807# draw 3D effect in correct direction
+
+ sal_uInt8 nDiff = mbEnabled ? 0x18 : 0x10;
+ Color aColor;
+
+ aColor = GetBackgroundColor();
+ SetFillColor( aColor );
+ DrawPie( maRect, maRect.TopRight(), maRect.TopCenter() );
+ DrawPie( maRect, maRect.BottomLeft(), maRect.BottomCenter() );
+
+ aColor.DecreaseLuminance( nDiff );
+ SetFillColor( aColor );
+ DrawPie( maRect, maRect.BottomCenter(), maRect.TopRight() );
+
+ aColor.DecreaseLuminance( nDiff );
+ SetFillColor( aColor );
+ DrawPie( maRect, maRect.BottomRight(), maRect.RightCenter() );
+
+ aColor = GetBackgroundColor();
+ aColor.IncreaseLuminance( nDiff );
+ SetFillColor( aColor );
+ DrawPie( maRect, maRect.TopCenter(), maRect.BottomLeft() );
+
+ aColor.IncreaseLuminance( nDiff );
+ SetFillColor( aColor );
+ DrawPie( maRect, maRect.TopLeft(), maRect.LeftCenter() );
+
+ EnableRTL( FALSE );
+
+ // *** calibration ***
+
+ Point aStartPos( mnCenterX, mnCenterY );
+ Color aFullColor( GetScaleLineColor() );
+ Color aLightColor( GetBackgroundColor() );
+ aLightColor.Merge( aFullColor, 128 );
+
+ for( int nAngle = 0; nAngle < 360; nAngle += 15 )
+ {
+ SetLineColor( (nAngle % 45) ? aLightColor : aFullColor );
+ double fAngle = nAngle * F_PI180;
+ long nX = static_cast< long >( -mnCenterX * cos( fAngle ) );
+ long nY = static_cast< long >( mnCenterY * sin( fAngle ) );
+ DrawLine( aStartPos, Point( mnCenterX - nX, mnCenterY - nY ) );
+ }
+
+ // *** clear inner area ***
+
+ SetLineColor();
+ SetFillColor( GetBackgroundColor() );
+ DrawEllipse( Rectangle( maRect.Left() + DIAL_OUTER_WIDTH, maRect.Top() + DIAL_OUTER_WIDTH,
+ maRect.Right() - DIAL_OUTER_WIDTH, maRect.Bottom() - DIAL_OUTER_WIDTH ) );
+}
+
+// ============================================================================
+
+struct DialControl_Impl
+{
+ DialControlBmp maBmpEnabled;
+ DialControlBmp maBmpDisabled;
+ DialControlBmp maBmpBuffered;
+ Link maModifyHdl;
+ NumericField* mpLinkField;
+ Size maWinSize;
+ Font maWinFont;
+ sal_Int32 mnAngle;
+ sal_Int32 mnOldAngle;
+ long mnCenterX;
+ long mnCenterY;
+ bool mbNoRot;
+
+ explicit DialControl_Impl( Window& rParent );
+ void Init( const Size& rWinSize, const Font& rWinFont );
+};
+
+// ----------------------------------------------------------------------------
+
+DialControl_Impl::DialControl_Impl( Window& rParent ) :
+ maBmpEnabled( rParent ),
+ maBmpDisabled( rParent ),
+ maBmpBuffered( rParent ),
+ mpLinkField( 0 ),
+ mnAngle( 0 ),
+ mbNoRot( false )
+{
+}
+
+void DialControl_Impl::Init( const Size& rWinSize, const Font& rWinFont )
+{
+ // "(x - 1) | 1" creates odd value <= x, to have a well-defined center pixel position
+ maWinSize = Size( (rWinSize.Width() - 1) | 1, (rWinSize.Height() - 1) | 1 );
+ maWinFont = rWinFont;
+
+ mnCenterX = maWinSize.Width() / 2;
+ mnCenterY = maWinSize.Height() / 2;
+ maWinFont.SetTransparent( TRUE );
+
+ maBmpEnabled.DrawBackground( maWinSize, true );
+ maBmpDisabled.DrawBackground( maWinSize, false );
+ maBmpBuffered.InitBitmap( maWinSize, maWinFont );
+}
+
+// ============================================================================
+
+DialControl::DialControl( Window* pParent, const Size& rSize, const Font& rFont, WinBits nWinStyle ) :
+ Control( pParent, nWinStyle ),
+ mpImpl( new DialControl_Impl( *this ) )
+{
+ Init( rSize, rFont );
+}
+
+DialControl::DialControl( Window* pParent, const Size& rSize, WinBits nWinStyle ) :
+ Control( pParent, nWinStyle ),
+ mpImpl( new DialControl_Impl( *this ) )
+{
+ if( pParent )
+ Init( rSize, pParent->GetFont() );
+ else
+ Init( rSize );
+}
+
+DialControl::DialControl( Window* pParent, const ResId& rResId ) :
+ Control( pParent, rResId ),
+ mpImpl( new DialControl_Impl( *this ) )
+{
+ Init( GetOutputSizePixel() );
+}
+
+DialControl::~DialControl()
+{
+}
+
+void DialControl::Paint( const Rectangle& )
+{
+ Point aPos;
+ DrawBitmapEx( aPos, mpImpl->maBmpBuffered.GetBitmapEx( aPos, mpImpl->maWinSize ) );
+}
+
+void DialControl::StateChanged( StateChangedType nStateChange )
+{
+ if( nStateChange == STATE_CHANGE_ENABLE )
+ InvalidateControl();
+
+ // update the linked edit field
+ if( mpImpl->mpLinkField )
+ {
+ NumericField& rField = *mpImpl->mpLinkField;
+ switch( nStateChange )
+ {
+ case STATE_CHANGE_VISIBLE: rField.Show( IsVisible() ); break;
+ case STATE_CHANGE_ENABLE: rField.Enable( IsEnabled() ); break;
+ }
+ }
+
+ Control::StateChanged( nStateChange );
+}
+
+void DialControl::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ Init( mpImpl->maWinSize, mpImpl->maWinFont );
+ InvalidateControl();
+ }
+ Control::DataChanged( rDCEvt );
+}
+
+void DialControl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if( rMEvt.IsLeft() )
+ {
+ GrabFocus();
+ CaptureMouse();
+ mpImpl->mnOldAngle = mpImpl->mnAngle;
+ HandleMouseEvent( rMEvt.GetPosPixel(), true );
+ }
+ Control::MouseButtonDown( rMEvt );
+}
+
+void DialControl::MouseMove( const MouseEvent& rMEvt )
+{
+ if( IsMouseCaptured() && rMEvt.IsLeft() )
+ HandleMouseEvent( rMEvt.GetPosPixel(), false );
+ Control::MouseMove(rMEvt );
+}
+
+void DialControl::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if( IsMouseCaptured() )
+ {
+ ReleaseMouse();
+ if( mpImpl->mpLinkField )
+ mpImpl->mpLinkField->GrabFocus();
+ }
+ Control::MouseButtonUp( rMEvt );
+}
+
+void DialControl::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKCode = rKEvt.GetKeyCode();
+ if( !rKCode.GetModifier() && (rKCode.GetCode() == KEY_ESCAPE) )
+ HandleEscapeEvent();
+ else
+ Control::KeyInput( rKEvt );
+}
+
+void DialControl::LoseFocus()
+{
+ // release captured mouse
+ HandleEscapeEvent();
+ Control::LoseFocus();
+}
+
+bool DialControl::HasRotation() const
+{
+ return !mpImpl->mbNoRot;
+}
+
+void DialControl::SetNoRotation()
+{
+ if( !mpImpl->mbNoRot )
+ {
+ mpImpl->mbNoRot = true;
+ InvalidateControl();
+ if( mpImpl->mpLinkField )
+ mpImpl->mpLinkField->SetText( String() );
+ }
+}
+
+sal_Int32 DialControl::GetRotation() const
+{
+ return mpImpl->mnAngle;
+}
+
+void DialControl::SetRotation( sal_Int32 nAngle )
+{
+ ImplSetRotation( nAngle, false );
+}
+
+void DialControl::SetLinkedField( NumericField* pField )
+{
+ // remove modify handler from old linked field
+ ImplSetFieldLink( Link() );
+ // remember the new linked field
+ mpImpl->mpLinkField = pField;
+ // set modify handler at new linked field
+ ImplSetFieldLink( LINK( this, DialControl, LinkedFieldModifyHdl ) );
+}
+
+NumericField* DialControl::GetLinkedField() const
+{
+ return mpImpl->mpLinkField;
+}
+
+void DialControl::SetModifyHdl( const Link& rLink )
+{
+ mpImpl->maModifyHdl = rLink;
+}
+
+const Link& DialControl::GetModifyHdl() const
+{
+ return mpImpl->maModifyHdl;
+}
+
+// private --------------------------------------------------------------------
+
+void DialControl::Init( const Size& rWinSize, const Font& rWinFont )
+{
+ mpImpl->Init( rWinSize, rWinFont );
+ EnableRTL( FALSE ); // #107807# don't mirror mouse handling
+ SetOutputSizePixel( mpImpl->maWinSize );
+ SetBackground();
+}
+
+void DialControl::Init( const Size& rWinSize )
+{
+ Font aFont( OutputDevice::GetDefaultFont(
+ DEFAULTFONT_UI_SANS, Application::GetSettings().GetUILanguage(), DEFAULTFONT_FLAGS_ONLYONE ) );
+ Init( rWinSize, aFont );
+}
+
+void DialControl::InvalidateControl()
+{
+ mpImpl->maBmpBuffered.CopyBackground( IsEnabled() ? mpImpl->maBmpEnabled : mpImpl->maBmpDisabled );
+ if( !mpImpl->mbNoRot )
+ mpImpl->maBmpBuffered.DrawElements( GetText(), mpImpl->mnAngle );
+ Invalidate();
+}
+
+void DialControl::ImplSetRotation( sal_Int32 nAngle, bool bBroadcast )
+{
+ bool bOldSel = mpImpl->mbNoRot;
+ mpImpl->mbNoRot = false;
+
+ while( nAngle < 0 ) nAngle += 36000;
+ nAngle = (((nAngle + 50) / 100) * 100) % 36000;
+ if( !bOldSel || (mpImpl->mnAngle != nAngle) )
+ {
+ mpImpl->mnAngle = nAngle;
+ InvalidateControl();
+ if( mpImpl->mpLinkField )
+ mpImpl->mpLinkField->SetValue( static_cast< long >( GetRotation() / 100 ) );
+ if( bBroadcast )
+ mpImpl->maModifyHdl.Call( this );
+ }
+}
+
+void DialControl::ImplSetFieldLink( const Link& rLink )
+{
+ if( mpImpl->mpLinkField )
+ {
+ NumericField& rField = *mpImpl->mpLinkField;
+ rField.SetModifyHdl( rLink );
+ rField.SetUpHdl( rLink );
+ rField.SetDownHdl( rLink );
+ rField.SetFirstHdl( rLink );
+ rField.SetLastHdl( rLink );
+ rField.SetLoseFocusHdl( rLink );
+ }
+}
+
+void DialControl::HandleMouseEvent( const Point& rPos, bool bInitial )
+{
+ long nX = rPos.X() - mpImpl->mnCenterX;
+ long nY = mpImpl->mnCenterY - rPos.Y();
+ double fH = sqrt( static_cast< double >( nX ) * nX + static_cast< double >( nY ) * nY );
+ if( fH != 0.0 )
+ {
+ double fAngle = acos( nX / fH );
+ sal_Int32 nAngle = static_cast< sal_Int32 >( fAngle / F_PI180 * 100.0 );
+ if( nY < 0 )
+ nAngle = 36000 - nAngle;
+ if( bInitial ) // round to entire 15 degrees
+ nAngle = ((nAngle + 750) / 1500) * 1500;
+ ImplSetRotation( nAngle, true );
+ }
+}
+
+void DialControl::HandleEscapeEvent()
+{
+ if( IsMouseCaptured() )
+ {
+ ReleaseMouse();
+ ImplSetRotation( mpImpl->mnOldAngle, true );
+ if( mpImpl->mpLinkField )
+ mpImpl->mpLinkField->GrabFocus();
+ }
+}
+
+IMPL_LINK( DialControl, LinkedFieldModifyHdl, NumericField*, pField )
+{
+ if( pField )
+ ImplSetRotation( static_cast< sal_Int32 >( pField->GetValue() * 100 ), false );
+ return 0;
+}
+
+// ============================================================================
+
+DialControlWrapper::DialControlWrapper( DialControl& rDial ) :
+ SingleControlWrapperType( rDial )
+{
+}
+
+bool DialControlWrapper::IsControlDontKnow() const
+{
+ return !GetControl().HasRotation();
+}
+
+void DialControlWrapper::SetControlDontKnow( bool bSet )
+{
+ if( bSet )
+ GetControl().SetNoRotation();
+}
+
+sal_Int32 DialControlWrapper::GetControlValue() const
+{
+ return GetControl().GetRotation();
+}
+
+void DialControlWrapper::SetControlValue( sal_Int32 nValue )
+{
+ GetControl().SetRotation( nValue );
+}
+
+// ============================================================================
+
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/dialmgr.cxx b/svx/source/dialog/dialmgr.cxx
new file mode 100644
index 000000000000..b2d0ba368adf
--- /dev/null
+++ b/svx/source/dialog/dialmgr.cxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+//#ifdef SVX_DLLIMPLEMENTATION
+//#undef SVX_DLLIMPLEMENTATION
+//#endif
+
+// include ---------------------------------------------------------------
+
+#include <svx/dialmgr.hxx>
+#include <tools/rc.hxx>
+#include <svl/solar.hrc>
+#include <vcl/svapp.hxx>
+
+static ResMgr* pResMgr=0;
+
+// struct DialogsResMgr --------------------------------------------------
+ResMgr* DialogsResMgr::GetResMgr()
+{
+ if ( !pResMgr )
+ {
+ ByteString aName( "svx" );
+ pResMgr = ResMgr::CreateResMgr( aName.GetBuffer(), Application::GetSettings().GetUILocale() );
+ }
+
+ return pResMgr;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/dlgctl3d.cxx b/svx/source/dialog/dlgctl3d.cxx
new file mode 100644
index 000000000000..a23c311fc263
--- /dev/null
+++ b/svx/source/dialog/dlgctl3d.cxx
@@ -0,0 +1,1326 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/dlgctl3d.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/view3d.hxx>
+#include <svx/fmmodel.hxx>
+#include <svl/itempool.hxx>
+#include <svx/fmpage.hxx>
+#include <svx/polysc3d.hxx>
+#include <svx/sphere3d.hxx>
+#include <svx/cube3d.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/helperhittest3d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/polygn3d.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlnwtit.hxx>
+#include "helpid.hrc"
+#include <algorithm>
+
+//////////////////////////////////////////////////////////////////////////////
+
+Svx3DPreviewControl::Svx3DPreviewControl(Window* pParent, const ResId& rResId)
+: Control(pParent, rResId),
+ mpModel(0),
+ mpFmPage(0),
+ mp3DView(0),
+ mpScene(0),
+ mp3DObj(0),
+ mnObjectType(PREVIEW_OBJECTTYPE_SPHERE)
+{
+ Construct();
+
+ // do not paint background self, DrawingLayer paints this buffered and as page
+ SetControlBackground();
+ SetBackground();
+}
+
+Svx3DPreviewControl::Svx3DPreviewControl(Window* pParent, WinBits nStyle)
+: Control(pParent, nStyle),
+ mpModel(0),
+ mpFmPage(0),
+ mp3DView(0),
+ mpScene(0),
+ mp3DObj(0),
+ mnObjectType(PREVIEW_OBJECTTYPE_SPHERE)
+{
+ Construct();
+
+ // do not paint background self, DrawingLayer paints this buffered and as page
+ SetControlBackground();
+ SetBackground();
+}
+
+Svx3DPreviewControl::~Svx3DPreviewControl()
+{
+ delete mp3DView;
+ delete mpModel;
+}
+
+void Svx3DPreviewControl::Construct()
+{
+ // Do never mirror the preview window. This explicitly includes right
+ // to left writing environments.
+ EnableRTL (FALSE);
+ SetMapMode( MAP_100TH_MM );
+
+ // Model
+ mpModel = new FmFormModel();
+ mpModel->GetItemPool().FreezeIdRanges();
+
+ // Page
+ mpFmPage = new FmFormPage( *mpModel, NULL );
+ mpModel->InsertPage( mpFmPage, 0 );
+
+ // 3D View
+ mp3DView = new E3dView( mpModel, this );
+ mp3DView->SetBufferedOutputAllowed(true);
+ mp3DView->SetBufferedOverlayAllowed(true);
+
+ // 3D Scene
+ mpScene = new E3dPolyScene(mp3DView->Get3DDefaultAttributes());
+
+ // initially create object
+ SetObjectType(PREVIEW_OBJECTTYPE_SPHERE);
+
+ // camera and perspective
+ Camera3D& rCamera = (Camera3D&) mpScene->GetCamera();
+ const basegfx::B3DRange& rVolume = mpScene->GetBoundVolume();
+ double fW = rVolume.getWidth();
+ double fH = rVolume.getHeight();
+ double fCamZ = rVolume.getMaxZ() + ((fW + fH) / 2.0);
+
+ rCamera.SetAutoAdjustProjection(FALSE);
+ rCamera.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
+ basegfx::B3DPoint aLookAt;
+ double fDefaultCamPosZ = mp3DView->GetDefaultCamPosZ();
+ basegfx::B3DPoint aCamPos(0.0, 0.0, fCamZ < fDefaultCamPosZ ? fDefaultCamPosZ : fCamZ);
+ rCamera.SetPosAndLookAt(aCamPos, aLookAt);
+ double fDefaultCamFocal = mp3DView->GetDefaultCamFocal();
+ rCamera.SetFocalLength(fDefaultCamFocal);
+ rCamera.SetDefaults(basegfx::B3DPoint(0.0, 0.0, fDefaultCamPosZ), aLookAt, fDefaultCamFocal);
+
+ mpScene->SetCamera( rCamera );
+ mpFmPage->InsertObject( mpScene );
+
+ basegfx::B3DHomMatrix aRotation;
+ aRotation.rotate(DEG2RAD( 25 ), 0.0, 0.0);
+ aRotation.rotate(0.0, DEG2RAD( 40 ), 0.0);
+ mpScene->SetTransform(aRotation * mpScene->GetTransform());
+
+ // invalidate SnapRects of objects
+ mpScene->SetRectsDirty();
+
+ SfxItemSet aSet( mpModel->GetItemPool(),
+ XATTR_LINESTYLE, XATTR_LINESTYLE,
+ XATTR_FILL_FIRST, XATTR_FILLBITMAP,
+ 0, 0 );
+ aSet.Put( XLineStyleItem( XLINE_NONE ) );
+ aSet.Put( XFillStyleItem( XFILL_SOLID ) );
+ aSet.Put( XFillColorItem( String(), Color( COL_WHITE ) ) );
+
+ mpScene->SetMergedItemSet(aSet);
+
+ // PageView
+ SdrPageView* pPageView = mp3DView->ShowSdrPage( mpFmPage );
+ mp3DView->hideMarkHandles();
+
+ // mark scene
+ mp3DView->MarkObj( mpScene, pPageView );
+}
+
+void Svx3DPreviewControl::Resize()
+{
+ // size of page
+ Size aSize( GetSizePixel() );
+ aSize = PixelToLogic( aSize );
+ mpFmPage->SetSize( aSize );
+
+ // set size
+ Size aObjSize( aSize.Width()*5/6, aSize.Height()*5/6 );
+ Point aObjPoint( (aSize.Width() - aObjSize.Width()) / 2,
+ (aSize.Height() - aObjSize.Height()) / 2);
+ Rectangle aRect( aObjPoint, aObjSize);
+ mpScene->SetSnapRect( aRect );
+}
+
+void Svx3DPreviewControl::Paint(const Rectangle& rRect)
+{
+ mp3DView->CompleteRedraw(this, Region(rRect));
+}
+
+void Svx3DPreviewControl::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ Control::MouseButtonDown(rMEvt);
+
+ if( rMEvt.IsShift() && rMEvt.IsMod1() )
+ {
+ if(PREVIEW_OBJECTTYPE_SPHERE == GetObjectType())
+ {
+ SetObjectType(PREVIEW_OBJECTTYPE_CUBE);
+ }
+ else
+ {
+ SetObjectType(PREVIEW_OBJECTTYPE_SPHERE);
+ }
+ }
+}
+
+void Svx3DPreviewControl::SetObjectType(sal_uInt16 nType)
+{
+ if( mnObjectType != nType || !mp3DObj)
+ {
+ SfxItemSet aSet(mpModel->GetItemPool(), SDRATTR_START, SDRATTR_END, 0, 0);
+ mnObjectType = nType;
+
+ if( mp3DObj )
+ {
+ aSet.Put(mp3DObj->GetMergedItemSet());
+ mpScene->Remove3DObj( mp3DObj );
+ delete mp3DObj;
+ mp3DObj = NULL;
+ }
+
+ switch( nType )
+ {
+ case PREVIEW_OBJECTTYPE_SPHERE:
+ {
+ mp3DObj = new E3dSphereObj(
+ mp3DView->Get3DDefaultAttributes(),
+ basegfx::B3DPoint( 0, 0, 0 ),
+ basegfx::B3DVector( 5000, 5000, 5000 ));
+ }
+ break;
+
+ case PREVIEW_OBJECTTYPE_CUBE:
+ {
+ mp3DObj = new E3dCubeObj(
+ mp3DView->Get3DDefaultAttributes(),
+ basegfx::B3DPoint( -2500, -2500, -2500 ),
+ basegfx::B3DVector( 5000, 5000, 5000 ));
+ }
+ break;
+ }
+
+ mpScene->Insert3DObj( mp3DObj );
+ mp3DObj->SetMergedItemSet(aSet);
+
+ Resize();
+ }
+}
+
+SfxItemSet Svx3DPreviewControl::Get3DAttributes() const
+{
+ return mp3DObj->GetMergedItemSet();
+}
+
+void Svx3DPreviewControl::Set3DAttributes( const SfxItemSet& rAttr )
+{
+ mp3DObj->SetMergedItemSet(rAttr, true);
+ Resize();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+#define RADIUS_LAMP_PREVIEW_SIZE (4500.0)
+#define RADIUS_LAMP_SMALL (600.0)
+#define RADIUS_LAMP_BIG (1000.0)
+#define NO_LIGHT_SELECTED (0xffffffff)
+#define MAX_NUMBER_LIGHTS (8)
+
+Svx3DLightControl::Svx3DLightControl(Window* pParent, const ResId& rResId)
+: Svx3DPreviewControl(pParent, rResId),
+ maUserInteractiveChangeCallback(),
+ maUserSelectionChangeCallback(),
+ maChangeCallback(),
+ maSelectionChangeCallback(),
+ maSelectedLight(NO_LIGHT_SELECTED),
+ mpExpansionObject(0),
+ mpLampBottomObject(0),
+ mpLampShaftObject(0),
+ maLightObjects(MAX_NUMBER_LIGHTS, (E3dObject*)0),
+ mfRotateX(-20.0),
+ mfRotateY(45.0),
+ mfRotateZ(0.0),
+ maActionStartPoint(),
+ mnInteractionStartDistance(5 * 5 * 2),
+ mfSaveActionStartHor(0.0),
+ mfSaveActionStartVer(0.0),
+ mfSaveActionStartRotZ(0.0),
+ mbMouseMoved(false),
+ mbGeometrySelected(false)
+{
+ Construct2();
+}
+
+Svx3DLightControl::Svx3DLightControl(Window* pParent, WinBits nStyle)
+: Svx3DPreviewControl(pParent, nStyle),
+ maUserInteractiveChangeCallback(),
+ maUserSelectionChangeCallback(),
+ maChangeCallback(),
+ maSelectionChangeCallback(),
+ maSelectedLight(NO_LIGHT_SELECTED),
+ mpExpansionObject(0),
+ mpLampBottomObject(0),
+ mpLampShaftObject(0),
+ maLightObjects(MAX_NUMBER_LIGHTS, (E3dObject*)0),
+ mfRotateX(-20.0),
+ mfRotateY(45.0),
+ mfRotateZ(0.0),
+ maActionStartPoint(),
+ mnInteractionStartDistance(5 * 5 * 2),
+ mfSaveActionStartHor(0.0),
+ mfSaveActionStartVer(0.0),
+ mfSaveActionStartRotZ(0.0),
+ mbMouseMoved(false),
+ mbGeometrySelected(false)
+{
+ Construct2();
+}
+
+Svx3DLightControl::~Svx3DLightControl()
+{
+ // SdrObjects like mpExpansionObject and mpLampBottomObject/mpLampShaftObject get deleted
+ // with deletion of the DrawingLayer and model
+}
+
+void Svx3DLightControl::Construct2()
+{
+ {
+ // hide all page stuff, use control background (normally gray)
+ const Color aDialogColor(Application::GetSettings().GetStyleSettings().GetDialogColor());
+ mp3DView->SetPageVisible(false);
+ mp3DView->SetApplicationBackgroundColor(aDialogColor);
+ mp3DView->SetApplicationDocumentColor(aDialogColor);
+ }
+
+ {
+ // create invisible expansion object
+ const double fMaxExpansion(RADIUS_LAMP_BIG + RADIUS_LAMP_PREVIEW_SIZE);
+ mpExpansionObject = new E3dCubeObj(
+ mp3DView->Get3DDefaultAttributes(),
+ basegfx::B3DPoint(-fMaxExpansion, -fMaxExpansion, -fMaxExpansion),
+ basegfx::B3DVector(2.0 * fMaxExpansion, 2.0 * fMaxExpansion, 2.0 * fMaxExpansion));
+ mpScene->Insert3DObj( mpExpansionObject );
+ SfxItemSet aSet(mpModel->GetItemPool());
+ aSet.Put( XLineStyleItem( XLINE_NONE ) );
+ aSet.Put( XFillStyleItem( XFILL_NONE ) );
+ mpExpansionObject->SetMergedItemSet(aSet);
+ }
+
+ {
+ // create lamp control object (Yellow lined object)
+ // base circle
+ const basegfx::B2DPolygon a2DCircle(basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0.0, 0.0), RADIUS_LAMP_PREVIEW_SIZE));
+ basegfx::B3DPolygon a3DCircle(basegfx::tools::createB3DPolygonFromB2DPolygon(a2DCircle));
+ basegfx::B3DHomMatrix aTransform;
+
+ aTransform.rotate(F_PI2, 0.0, 0.0);
+ aTransform.translate(0.0, -RADIUS_LAMP_PREVIEW_SIZE, 0.0);
+ a3DCircle.transform(aTransform);
+
+ // create object for it
+ mpLampBottomObject = new E3dPolygonObj(
+ mp3DView->Get3DDefaultAttributes(),
+ basegfx::B3DPolyPolygon(a3DCircle),
+ true);
+ mpScene->Insert3DObj( mpLampBottomObject );
+
+ // half circle with stand
+ basegfx::B2DPolygon a2DHalfCircle;
+ a2DHalfCircle.append(basegfx::B2DPoint(RADIUS_LAMP_PREVIEW_SIZE, 0.0));
+ a2DHalfCircle.append(basegfx::B2DPoint(RADIUS_LAMP_PREVIEW_SIZE, -RADIUS_LAMP_PREVIEW_SIZE));
+ a2DHalfCircle.append(basegfx::tools::createPolygonFromEllipseSegment(
+ basegfx::B2DPoint(0.0, 0.0), RADIUS_LAMP_PREVIEW_SIZE, RADIUS_LAMP_PREVIEW_SIZE, F_2PI - F_PI2, F_PI2));
+ basegfx::B3DPolygon a3DHalfCircle(basegfx::tools::createB3DPolygonFromB2DPolygon(a2DHalfCircle));
+
+ // create object for it
+ mpLampShaftObject = new E3dPolygonObj(
+ mp3DView->Get3DDefaultAttributes(),
+ basegfx::B3DPolyPolygon(a3DHalfCircle),
+ true);
+ mpScene->Insert3DObj( mpLampShaftObject );
+
+ // initially invisible
+ SfxItemSet aSet(mpModel->GetItemPool());
+ aSet.Put( XLineStyleItem( XLINE_NONE ) );
+ aSet.Put( XFillStyleItem( XFILL_NONE ) );
+
+ mpLampBottomObject->SetMergedItemSet(aSet);
+ mpLampShaftObject->SetMergedItemSet(aSet);
+ }
+
+ {
+ // change camera settings
+ Camera3D& rCamera = (Camera3D&) mpScene->GetCamera();
+ const basegfx::B3DRange& rVolume = mpScene->GetBoundVolume();
+ double fW = rVolume.getWidth();
+ double fH = rVolume.getHeight();
+ double fCamZ = rVolume.getMaxZ() + ((fW + fH) / 2.0);
+
+ rCamera.SetAutoAdjustProjection(FALSE);
+ rCamera.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
+ basegfx::B3DPoint aLookAt;
+ double fDefaultCamPosZ = mp3DView->GetDefaultCamPosZ();
+ basegfx::B3DPoint aCamPos(0.0, 0.0, fCamZ < fDefaultCamPosZ ? fDefaultCamPosZ : fCamZ);
+ rCamera.SetPosAndLookAt(aCamPos, aLookAt);
+ double fDefaultCamFocal = mp3DView->GetDefaultCamFocal();
+ rCamera.SetFocalLength(fDefaultCamFocal);
+ rCamera.SetDefaults(basegfx::B3DPoint(0.0, 0.0, fDefaultCamPosZ), aLookAt, fDefaultCamFocal);
+
+ mpScene->SetCamera( rCamera );
+
+ basegfx::B3DHomMatrix aNeutral;
+ mpScene->SetTransform(aNeutral);
+ }
+
+ // invalidate SnapRects of objects
+ mpScene->SetRectsDirty();
+}
+
+void Svx3DLightControl::ConstructLightObjects()
+{
+ for(sal_uInt32 a(0); a < MAX_NUMBER_LIGHTS; a++)
+ {
+ // get rid of evtl. existing light object
+ if(maLightObjects[a])
+ {
+ mpScene->Remove3DObj(maLightObjects[a]);
+ delete maLightObjects[a];
+ maLightObjects[a] = 0;
+ }
+
+ if(GetLightOnOff(a))
+ {
+ const bool bIsSelectedLight(a == maSelectedLight);
+ basegfx::B3DVector aDirection(GetLightDirection(a));
+ aDirection.normalize();
+ aDirection *= RADIUS_LAMP_PREVIEW_SIZE;
+
+ const double fLampSize(bIsSelectedLight ? RADIUS_LAMP_BIG : RADIUS_LAMP_SMALL);
+ E3dObject* pNewLight = new E3dSphereObj(
+ mp3DView->Get3DDefaultAttributes(),
+ basegfx::B3DPoint( 0, 0, 0 ),
+ basegfx::B3DVector( fLampSize, fLampSize, fLampSize));
+ mpScene->Insert3DObj(pNewLight);
+
+ basegfx::B3DHomMatrix aTransform;
+ aTransform.translate(aDirection.getX(), aDirection.getY(), aDirection.getZ());
+ pNewLight->SetTransform(aTransform);
+
+ SfxItemSet aSet(mpModel->GetItemPool());
+ aSet.Put( XLineStyleItem( XLINE_NONE ) );
+ aSet.Put( XFillStyleItem( XFILL_SOLID ) );
+ aSet.Put( XFillColorItem(String(), GetLightColor(a)));
+ pNewLight->SetMergedItemSet(aSet);
+
+ maLightObjects[a] = pNewLight;
+ }
+ }
+}
+
+void Svx3DLightControl::AdaptToSelectedLight()
+{
+ if(NO_LIGHT_SELECTED == maSelectedLight)
+ {
+ // make mpLampBottomObject/mpLampShaftObject invisible
+ SfxItemSet aSet(mpModel->GetItemPool());
+ aSet.Put( XLineStyleItem( XLINE_NONE ) );
+ aSet.Put( XFillStyleItem( XFILL_NONE ) );
+ mpLampBottomObject->SetMergedItemSet(aSet);
+ mpLampShaftObject->SetMergedItemSet(aSet);
+ }
+ else
+ {
+ basegfx::B3DVector aDirection(GetLightDirection(maSelectedLight));
+ aDirection.normalize();
+
+ // make mpLampBottomObject/mpLampShaftObject visible (yellow hairline)
+ SfxItemSet aSet(mpModel->GetItemPool());
+ aSet.Put( XLineStyleItem( XLINE_SOLID ) );
+ aSet.Put( XLineColorItem(String(), COL_YELLOW));
+ aSet.Put( XLineWidthItem(0));
+ aSet.Put( XFillStyleItem( XFILL_NONE ) );
+ mpLampBottomObject->SetMergedItemSet(aSet);
+ mpLampShaftObject->SetMergedItemSet(aSet);
+
+ // adapt transformation of mpLampShaftObject
+ basegfx::B3DHomMatrix aTransform;
+ double fRotateY(0.0);
+
+ if(!basegfx::fTools::equalZero(aDirection.getZ()) || !basegfx::fTools::equalZero(aDirection.getX()))
+ {
+ fRotateY = atan2(-aDirection.getZ(), aDirection.getX());
+ }
+
+ aTransform.rotate(0.0, fRotateY, 0.0);
+ mpLampShaftObject->SetTransform(aTransform);
+
+ // adapt transformation of selected light
+ E3dObject* pSelectedLight = maLightObjects[sal_Int32(maSelectedLight)];
+
+ if(pSelectedLight)
+ {
+ aTransform.identity();
+ aTransform.translate(
+ aDirection.getX() * RADIUS_LAMP_PREVIEW_SIZE,
+ aDirection.getY() * RADIUS_LAMP_PREVIEW_SIZE,
+ aDirection.getZ() * RADIUS_LAMP_PREVIEW_SIZE);
+ pSelectedLight->SetTransform(aTransform);
+ }
+ }
+}
+
+void Svx3DLightControl::TrySelection(Point aPosPixel)
+{
+ if(mpScene)
+ {
+ const Point aPosLogic(PixelToLogic(aPosPixel));
+ const basegfx::B2DPoint aPoint(aPosLogic.X(), aPosLogic.Y());
+ std::vector< const E3dCompoundObject* > aResult;
+ getAllHit3DObjectsSortedFrontToBack(aPoint, *mpScene, aResult);
+
+ if(aResult.size())
+ {
+ // exclude expansion object which will be part of
+ // the hits. It's invisible, but for HitTest, it's included
+ const E3dCompoundObject* pResult = 0;
+
+ for(sal_uInt32 b(0); !pResult && b < aResult.size(); b++)
+ {
+ if(aResult[b] && aResult[b] != mpExpansionObject)
+ {
+ pResult = aResult[b];
+ }
+ }
+
+ if(pResult == mp3DObj)
+ {
+ if(!mbGeometrySelected)
+ {
+ mbGeometrySelected = true;
+ maSelectedLight = NO_LIGHT_SELECTED;
+ ConstructLightObjects();
+ AdaptToSelectedLight();
+ Invalidate();
+
+ if(maSelectionChangeCallback.IsSet())
+ {
+ maSelectionChangeCallback.Call(this);
+ }
+ }
+ }
+ else
+ {
+ sal_uInt32 aNewSelectedLight(NO_LIGHT_SELECTED);
+
+ for(sal_uInt32 a(0); a < MAX_NUMBER_LIGHTS; a++)
+ {
+ if(maLightObjects[a] && maLightObjects[a] == pResult)
+ {
+ aNewSelectedLight = a;
+ }
+ }
+
+ if(aNewSelectedLight != maSelectedLight)
+ {
+ SelectLight(aNewSelectedLight);
+
+ if(maSelectionChangeCallback.IsSet())
+ {
+ maSelectionChangeCallback.Call(this);
+ }
+ }
+ }
+ }
+ }
+}
+
+void Svx3DLightControl::Paint(const Rectangle& rRect)
+{
+ Svx3DPreviewControl::Paint(rRect);
+}
+
+void Svx3DLightControl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ bool bCallParent(true);
+
+ // switch state
+ if(rMEvt.IsLeft())
+ {
+ if(IsSelectionValid() || mbGeometrySelected)
+ {
+ mbMouseMoved = false;
+ bCallParent = false;
+ maActionStartPoint = rMEvt.GetPosPixel();
+ StartTracking();
+ }
+ else
+ {
+ // Einfacher Click ohne viel Bewegen, versuche eine
+ // Selektion
+ TrySelection(rMEvt.GetPosPixel());
+ bCallParent = false;
+ }
+ }
+
+ // call parent
+ if(bCallParent)
+ {
+ Svx3DPreviewControl::MouseButtonDown(rMEvt);
+ }
+}
+
+void Svx3DLightControl::Tracking( const TrackingEvent& rTEvt )
+{
+ if(rTEvt.IsTrackingEnded())
+ {
+ if(rTEvt.IsTrackingCanceled())
+ {
+ if(mbMouseMoved)
+ {
+ // interrupt tracking
+ mbMouseMoved = false;
+
+ if(mbGeometrySelected)
+ {
+ SetRotation(mfSaveActionStartVer, mfSaveActionStartHor, mfSaveActionStartRotZ);
+ }
+ else
+ {
+ SetPosition(mfSaveActionStartHor, mfSaveActionStartVer);
+ }
+
+ if(maChangeCallback.IsSet())
+ {
+ maChangeCallback.Call(this);
+ }
+ }
+ }
+ else
+ {
+ const MouseEvent& rMEvt = rTEvt.GetMouseEvent();
+
+ if(mbMouseMoved)
+ {
+ // was change dinteractively
+ }
+ else
+ {
+ // simple click without much movement, try selection
+ TrySelection(rMEvt.GetPosPixel());
+ }
+ }
+ }
+ else
+ {
+ const MouseEvent& rMEvt = rTEvt.GetMouseEvent();
+ Point aDeltaPos = rMEvt.GetPosPixel() - maActionStartPoint;
+
+ if(!mbMouseMoved)
+ {
+ if(sal_Int32(aDeltaPos.X() * aDeltaPos.X() + aDeltaPos.Y() * aDeltaPos.Y()) > mnInteractionStartDistance)
+ {
+ if(mbGeometrySelected)
+ {
+ GetRotation(mfSaveActionStartVer, mfSaveActionStartHor, mfSaveActionStartRotZ);
+ }
+ else
+ {
+ // intercation start, save values
+ GetPosition(mfSaveActionStartHor, mfSaveActionStartVer);
+ }
+
+ mbMouseMoved = true;
+ }
+ }
+
+ if(mbMouseMoved)
+ {
+ if(mbGeometrySelected)
+ {
+ double fNewRotX = mfSaveActionStartVer - ((double)aDeltaPos.Y() * F_PI180);
+ double fNewRotY = mfSaveActionStartHor + ((double)aDeltaPos.X() * F_PI180);
+
+ // cut horizontal
+ while(fNewRotY < 0.0)
+ {
+ fNewRotY += F_2PI;
+ }
+
+ while(fNewRotY >= F_2PI)
+ {
+ fNewRotY -= F_2PI;
+ }
+
+ // cut vertical
+ if(fNewRotX < -F_PI2)
+ {
+ fNewRotX = -F_PI2;
+ }
+
+ if(fNewRotX > F_PI2)
+ {
+ fNewRotX = F_PI2;
+ }
+
+ SetRotation(fNewRotX, fNewRotY, mfSaveActionStartRotZ);
+
+ if(maChangeCallback.IsSet())
+ {
+ maChangeCallback.Call(this);
+ }
+ }
+ else
+ {
+ // interaction in progress
+ double fNewPosHor = mfSaveActionStartHor + ((double)aDeltaPos.X());
+ double fNewPosVer = mfSaveActionStartVer - ((double)aDeltaPos.Y());
+
+ // cut horizontal
+ while(fNewPosHor < 0.0)
+ {
+ fNewPosHor += 360.0;
+ }
+
+ while(fNewPosHor >= 360.0)
+ {
+ fNewPosHor -= 360.0;
+ }
+
+ // cut vertical
+ if(fNewPosVer < -90.0)
+ {
+ fNewPosVer = -90.0;
+ }
+
+ if(fNewPosVer > 90.0)
+ {
+ fNewPosVer = 90.0;
+ }
+
+ SetPosition(fNewPosHor, fNewPosVer);
+
+ if(maChangeCallback.IsSet())
+ {
+ maChangeCallback.Call(this);
+ }
+ }
+ }
+ }
+}
+
+void Svx3DLightControl::Resize()
+{
+ // set size of page
+ const Size aSize(PixelToLogic(GetSizePixel()));
+ mpFmPage->SetSize(aSize);
+
+ // set position and size of scene
+ mpScene->SetSnapRect(Rectangle(Point(0, 0), aSize));
+}
+
+void Svx3DLightControl::SetObjectType(sal_uInt16 nType)
+{
+ // call parent
+ Svx3DPreviewControl::SetObjectType(nType);
+
+ // apply object rotation
+ if(mp3DObj)
+ {
+ basegfx::B3DHomMatrix aObjectRotation;
+ aObjectRotation.rotate(mfRotateX, mfRotateY, mfRotateZ);
+ mp3DObj->SetTransform(aObjectRotation);
+ }
+}
+
+bool Svx3DLightControl::IsSelectionValid()
+{
+ if((NO_LIGHT_SELECTED != maSelectedLight) && (GetLightOnOff(maSelectedLight)))
+ {
+ return true;
+ }
+
+ return false;
+}
+
+void Svx3DLightControl::GetPosition(double& rHor, double& rVer)
+{
+ if(IsSelectionValid())
+ {
+ basegfx::B3DVector aDirection(GetLightDirection(maSelectedLight));
+ aDirection.normalize();
+ rHor = atan2(-aDirection.getX(), -aDirection.getZ()) + F_PI; // 0..2PI
+ rVer = atan2(aDirection.getY(), aDirection.getXZLength()); // -PI2..PI2
+ rHor /= F_PI180; // 0..360.0
+ rVer /= F_PI180; // -90.0..90.0
+ }
+ if(IsGeometrySelected())
+ {
+ rHor = mfRotateY / F_PI180; // 0..360.0
+ rVer = mfRotateX / F_PI180; // -90.0..90.0
+ }
+}
+
+void Svx3DLightControl::SetPosition(double fHor, double fVer)
+{
+ if(IsSelectionValid())
+ {
+ // set selected light's direction
+ fHor = (fHor * F_PI180) - F_PI; // -PI..PI
+ fVer *= F_PI180; // -PI2..PI2
+ basegfx::B3DVector aDirection(cos(fVer) * -sin(fHor), sin(fVer), cos(fVer) * -cos(fHor));
+ aDirection.normalize();
+
+ if(!aDirection.equal(GetLightDirection(maSelectedLight)))
+ {
+ // set changed light direction at SdrScene
+ SfxItemSet aSet(mpModel->GetItemPool());
+
+ switch(maSelectedLight)
+ {
+ case 0: aSet.Put(Svx3DLightDirection1Item(aDirection)); break;
+ case 1: aSet.Put(Svx3DLightDirection2Item(aDirection)); break;
+ case 2: aSet.Put(Svx3DLightDirection3Item(aDirection)); break;
+ case 3: aSet.Put(Svx3DLightDirection4Item(aDirection)); break;
+ case 4: aSet.Put(Svx3DLightDirection5Item(aDirection)); break;
+ case 5: aSet.Put(Svx3DLightDirection6Item(aDirection)); break;
+ case 6: aSet.Put(Svx3DLightDirection7Item(aDirection)); break;
+ default:
+ case 7: aSet.Put(Svx3DLightDirection8Item(aDirection)); break;
+ }
+
+ mpScene->SetMergedItemSet(aSet);
+
+ // correct 3D light's and LampFrame's geometries
+ AdaptToSelectedLight();
+ Invalidate();
+ }
+ }
+ if(IsGeometrySelected())
+ {
+ if(mfRotateX != fVer || mfRotateY != fHor)
+ {
+ mfRotateX = fVer * F_PI180;
+ mfRotateY = fHor * F_PI180;
+
+ if(mp3DObj)
+ {
+ basegfx::B3DHomMatrix aObjectRotation;
+ aObjectRotation.rotate(mfRotateX, mfRotateY, mfRotateZ);
+ mp3DObj->SetTransform(aObjectRotation);
+
+ Invalidate();
+ }
+ }
+ }
+}
+
+void Svx3DLightControl::SetRotation(double fRotX, double fRotY, double fRotZ)
+{
+ if(IsGeometrySelected())
+ {
+ if(fRotX != mfRotateX || fRotY != mfRotateY || fRotZ != mfRotateZ)
+ {
+ mfRotateX = fRotX;
+ mfRotateY = fRotY;
+ mfRotateZ = fRotZ;
+
+ if(mp3DObj)
+ {
+ basegfx::B3DHomMatrix aObjectRotation;
+ aObjectRotation.rotate(mfRotateX, mfRotateY, mfRotateZ);
+ mp3DObj->SetTransform(aObjectRotation);
+
+ Invalidate();
+ }
+ }
+ }
+}
+
+void Svx3DLightControl::GetRotation(double& rRotX, double& rRotY, double& rRotZ)
+{
+ rRotX = mfRotateX;
+ rRotY = mfRotateY;
+ rRotZ = mfRotateZ;
+}
+
+void Svx3DLightControl::Set3DAttributes( const SfxItemSet& rAttr )
+{
+ // call parent
+ Svx3DPreviewControl::Set3DAttributes(rAttr);
+
+ if(maSelectedLight != NO_LIGHT_SELECTED && !GetLightOnOff(maSelectedLight))
+ {
+ // selected light is no more active, select new one
+ maSelectedLight = NO_LIGHT_SELECTED;
+ }
+
+ // local updates
+ ConstructLightObjects();
+ AdaptToSelectedLight();
+ Invalidate();
+}
+
+void Svx3DLightControl::SelectLight(sal_uInt32 nLightNumber)
+{
+ if(nLightNumber > 7)
+ {
+ nLightNumber = NO_LIGHT_SELECTED;
+ }
+
+ if(NO_LIGHT_SELECTED != nLightNumber)
+ {
+ if(!GetLightOnOff(nLightNumber))
+ {
+ nLightNumber = NO_LIGHT_SELECTED;
+ }
+ }
+
+ if(nLightNumber != maSelectedLight)
+ {
+ maSelectedLight = nLightNumber;
+ mbGeometrySelected = false;
+ ConstructLightObjects();
+ AdaptToSelectedLight();
+ Invalidate();
+ }
+}
+
+bool Svx3DLightControl::GetLightOnOff(sal_uInt32 nNum) const
+{
+ if(nNum <= 7)
+ {
+ const SfxItemSet aLightItemSet(Get3DAttributes());
+
+ switch(nNum)
+ {
+ case 0 : return ((const Svx3DLightOnOff1Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue();
+ case 1 : return ((const Svx3DLightOnOff2Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue();
+ case 2 : return ((const Svx3DLightOnOff3Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue();
+ case 3 : return ((const Svx3DLightOnOff4Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue();
+ case 4 : return ((const Svx3DLightOnOff5Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue();
+ case 5 : return ((const Svx3DLightOnOff6Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue();
+ case 6 : return ((const Svx3DLightOnOff7Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue();
+ case 7 : return ((const Svx3DLightOnOff8Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue();
+ }
+ }
+
+ return false;
+}
+
+Color Svx3DLightControl::GetLightColor(sal_uInt32 nNum) const
+{
+ if(nNum <= 7)
+ {
+ const SfxItemSet aLightItemSet(Get3DAttributes());
+
+ switch(nNum)
+ {
+ case 0 : return ((const Svx3DLightcolor1Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue();
+ case 1 : return ((const Svx3DLightcolor2Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue();
+ case 2 : return ((const Svx3DLightcolor3Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue();
+ case 3 : return ((const Svx3DLightcolor4Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue();
+ case 4 : return ((const Svx3DLightcolor5Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue();
+ case 5 : return ((const Svx3DLightcolor6Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue();
+ case 6 : return ((const Svx3DLightcolor7Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue();
+ case 7 : return ((const Svx3DLightcolor8Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue();
+ }
+ }
+
+ return Color(COL_BLACK);
+}
+
+basegfx::B3DVector Svx3DLightControl::GetLightDirection(sal_uInt32 nNum) const
+{
+ if(nNum <= 7)
+ {
+ const SfxItemSet aLightItemSet(Get3DAttributes());
+
+ switch(nNum)
+ {
+ case 0 : return ((const Svx3DLightDirection1Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue();
+ case 1 : return ((const Svx3DLightDirection2Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue();
+ case 2 : return ((const Svx3DLightDirection3Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue();
+ case 3 : return ((const Svx3DLightDirection4Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue();
+ case 4 : return ((const Svx3DLightDirection5Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue();
+ case 5 : return ((const Svx3DLightDirection6Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue();
+ case 6 : return ((const Svx3DLightDirection7Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue();
+ case 7 : return ((const Svx3DLightDirection8Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue();
+ }
+ }
+
+ return basegfx::B3DVector();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+SvxLightCtl3D::SvxLightCtl3D( Window* pParent, const ResId& rResId)
+: Control(pParent, rResId),
+ maLightControl(this, 0),
+ maHorScroller(this, WB_HORZ | WB_DRAG),
+ maVerScroller(this, WB_VERT | WB_DRAG),
+ maSwitcher(this, 0)
+{
+ // init members
+ Init();
+}
+
+SvxLightCtl3D::SvxLightCtl3D( Window* pParent, WinBits nStyle )
+: Control(pParent, nStyle),
+ maLightControl(this, 0),
+ maHorScroller(this, WB_HORZ | WB_DRAG),
+ maVerScroller(this, WB_VERT | WB_DRAG),
+ maSwitcher(this, 0)
+{
+ // init members
+ Init();
+}
+
+void SvxLightCtl3D::Init()
+{
+ // #i58240# set HelpIDs for scrollbars and switcher
+ maHorScroller.SetHelpId(HID_CTRL3D_HSCROLL);
+ maVerScroller.SetHelpId(HID_CTRL3D_VSCROLL);
+ maSwitcher.SetHelpId(HID_CTRL3D_SWITCHER);
+
+ // Light preview
+ maLightControl.Show();
+ maLightControl.SetChangeCallback( LINK(this, SvxLightCtl3D, InternalInteractiveChange) );
+ maLightControl.SetSelectionChangeCallback( LINK(this, SvxLightCtl3D, InternalSelectionChange) );
+
+ // Horiz Scrollbar
+ maHorScroller.Show();
+ maHorScroller.SetRange(Range(0, 36000));
+ maHorScroller.SetLineSize(100);
+ maHorScroller.SetPageSize(1000);
+ maHorScroller.SetScrollHdl( LINK(this, SvxLightCtl3D, ScrollBarMove) );
+
+ // Vert Scrollbar
+ maVerScroller.Show();
+ maVerScroller.SetRange(Range(0, 18000));
+ maVerScroller.SetLineSize(100);
+ maVerScroller.SetPageSize(1000);
+ maVerScroller.SetScrollHdl( LINK(this, SvxLightCtl3D, ScrollBarMove) );
+
+ // Switch Button
+ maSwitcher.Show();
+ maSwitcher.SetClickHdl( LINK(this, SvxLightCtl3D, ButtonPress) );
+
+ // check selection
+ CheckSelection();
+
+ // new layout
+ NewLayout();
+}
+
+SvxLightCtl3D::~SvxLightCtl3D()
+{
+}
+
+void SvxLightCtl3D::Resize()
+{
+ // call parent
+ Control::Resize();
+
+ // new layout
+ NewLayout();
+}
+
+void SvxLightCtl3D::NewLayout()
+{
+ // Layout members
+ const Size aSize(GetOutputSizePixel());
+ const sal_Int32 nScrollSize(maHorScroller.GetSizePixel().Height());
+
+ // Preview control
+ Point aPoint(0, 0);
+ Size aDestSize(aSize.Width() - nScrollSize, aSize.Height() - nScrollSize);
+ maLightControl.SetPosSizePixel(aPoint, aDestSize);
+
+ // hor scrollbar
+ aPoint.Y() = aSize.Height() - nScrollSize;
+ aDestSize.Height() = nScrollSize;
+ maHorScroller.SetPosSizePixel(aPoint, aDestSize);
+
+ // vert scrollbar
+ aPoint.X() = aSize.Width() - nScrollSize;
+ aPoint.Y() = 0;
+ aDestSize.Width() = nScrollSize;
+ aDestSize.Height() = aSize.Height() - nScrollSize;
+ maVerScroller.SetPosSizePixel(aPoint, aDestSize);
+
+ // button
+ aPoint.Y() = aSize.Height() - nScrollSize;
+ aDestSize.Height() = nScrollSize;
+ maSwitcher.SetPosSizePixel(aPoint, aDestSize);
+}
+
+void SvxLightCtl3D::CheckSelection()
+{
+ const bool bSelectionValid(maLightControl.IsSelectionValid() || maLightControl.IsGeometrySelected());
+ maHorScroller.Enable(bSelectionValid);
+ maVerScroller.Enable(bSelectionValid);
+
+ if(bSelectionValid)
+ {
+ double fHor, fVer;
+ maLightControl.GetPosition(fHor, fVer);
+ maHorScroller.SetThumbPos( INT32(fHor * 100.0) );
+ maVerScroller.SetThumbPos( 18000 - INT32((fVer + 90.0) * 100.0) );
+ }
+}
+
+void SvxLightCtl3D::move( double fDeltaHor, double fDeltaVer )
+{
+ double fHor, fVer;
+
+ maLightControl.GetPosition(fHor, fVer);
+ fHor += fDeltaHor;
+ fVer += fDeltaVer;
+
+ if( fVer > 90.0 )
+ return;
+
+ if ( fVer < -90.0 )
+ return;
+
+ maLightControl.SetPosition(fHor, fVer);
+ maHorScroller.SetThumbPos( INT32(fHor * 100.0) );
+ maVerScroller.SetThumbPos( 18000 - INT32((fVer + 90.0) * 100.0) );
+
+ if(maUserInteractiveChangeCallback.IsSet())
+ {
+ maUserInteractiveChangeCallback.Call(this);
+ }
+}
+
+void SvxLightCtl3D::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode aCode(rKEvt.GetKeyCode());
+
+ if( aCode.GetModifier() )
+ {
+ Control::KeyInput( rKEvt );
+ return;
+ }
+
+ switch ( aCode.GetCode() )
+ {
+ case KEY_SPACE:
+ {
+ break;
+ }
+ case KEY_LEFT:
+ {
+ move( -4.0, 0.0 ); // #i58242# changed move direction in X
+ break;
+ }
+ case KEY_RIGHT:
+ {
+ move( 4.0, 0.0 ); // #i58242# changed move direction in X
+ break;
+ }
+ case KEY_UP:
+ {
+ move( 0.0, 4.0 );
+ break;
+ }
+ case KEY_DOWN:
+ {
+ move( 0.0, -4.0 );
+ break;
+ }
+ case KEY_PAGEUP:
+ {
+ sal_Int32 nLight(maLightControl.GetSelectedLight() - 1);
+
+ while((nLight >= 0) && !maLightControl.GetLightOnOff(nLight))
+ {
+ nLight--;
+ }
+
+ if(nLight < 0)
+ {
+ nLight = 7;
+
+ while((nLight >= 0) && !maLightControl.GetLightOnOff(nLight))
+ {
+ nLight--;
+ }
+ }
+
+ if(nLight >= 0)
+ {
+ maLightControl.SelectLight(nLight);
+ CheckSelection();
+
+ if(maUserSelectionChangeCallback.IsSet())
+ {
+ maUserSelectionChangeCallback.Call(this);
+ }
+ }
+
+ break;
+ }
+ case KEY_PAGEDOWN:
+ {
+ sal_Int32 nLight(maLightControl.GetSelectedLight() - 1);
+
+ while(nLight <= 7 && !maLightControl.GetLightOnOff(nLight))
+ {
+ nLight++;
+ }
+
+ if(nLight > 7)
+ {
+ nLight = 0;
+
+ while(nLight <= 7 && !maLightControl.GetLightOnOff(nLight))
+ {
+ nLight++;
+ }
+ }
+
+ if(nLight <= 7)
+ {
+ maLightControl.SelectLight(nLight);
+ CheckSelection();
+
+ if(maUserSelectionChangeCallback.IsSet())
+ {
+ maUserSelectionChangeCallback.Call(this);
+ }
+ }
+
+ break;
+ }
+ default:
+ {
+ Control::KeyInput( rKEvt );
+ break;
+ }
+ }
+}
+
+void SvxLightCtl3D::GetFocus()
+{
+ Control::GetFocus();
+
+ if(HasFocus() && IsEnabled())
+ {
+ CheckSelection();
+
+ Size aFocusSize = maLightControl.GetOutputSizePixel();
+
+ aFocusSize.Width() -= 4;
+ aFocusSize.Height() -= 4;
+
+ Rectangle aFocusRect( Point( 2, 2 ), aFocusSize );
+
+ aFocusRect = maLightControl.PixelToLogic( aFocusRect );
+
+ maLightControl.ShowFocus( aFocusRect );
+ }
+}
+
+void SvxLightCtl3D::LoseFocus()
+{
+ Control::LoseFocus();
+
+ maLightControl.HideFocus();
+}
+
+IMPL_LINK( SvxLightCtl3D, ScrollBarMove, void*, EMPTYARG)
+{
+ const sal_Int32 nHor(maHorScroller.GetThumbPos());
+ const sal_Int32 nVer(maVerScroller.GetThumbPos());
+
+ maLightControl.SetPosition(
+ ((double)nHor) / 100.0,
+ ((double)((18000 - nVer) - 9000)) / 100.0);
+
+ if(maUserInteractiveChangeCallback.IsSet())
+ {
+ maUserInteractiveChangeCallback.Call(this);
+ }
+
+ return 0;
+}
+
+IMPL_LINK( SvxLightCtl3D, ButtonPress, void*, EMPTYARG)
+{
+ if(PREVIEW_OBJECTTYPE_SPHERE == GetSvx3DLightControl().GetObjectType())
+ {
+ GetSvx3DLightControl().SetObjectType(PREVIEW_OBJECTTYPE_CUBE);
+ }
+ else
+ {
+ GetSvx3DLightControl().SetObjectType(PREVIEW_OBJECTTYPE_SPHERE);
+ }
+
+ return 0;
+}
+
+IMPL_LINK( SvxLightCtl3D, InternalInteractiveChange, void*, EMPTYARG)
+{
+ double fHor, fVer;
+
+ maLightControl.GetPosition(fHor, fVer);
+ maHorScroller.SetThumbPos( INT32(fHor * 100.0) );
+ maVerScroller.SetThumbPos( 18000 - INT32((fVer + 90.0) * 100.0) );
+
+ if(maUserInteractiveChangeCallback.IsSet())
+ {
+ maUserInteractiveChangeCallback.Call(this);
+ }
+
+ return 0;
+}
+
+IMPL_LINK( SvxLightCtl3D, InternalSelectionChange, void*, EMPTYARG)
+{
+ CheckSelection();
+
+ if(maUserSelectionChangeCallback.IsSet())
+ {
+ maUserSelectionChangeCallback.Call(this);
+ }
+
+ return 0;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
new file mode 100644
index 000000000000..6efc91d3c691
--- /dev/null
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -0,0 +1,2288 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/shl.hxx>
+#include <vcl/svapp.hxx>
+
+#include <svx/xtable.hxx>
+#include <svx/xpool.hxx>
+
+#include <svx/dialogs.hrc>
+#include "accessibility.hrc"
+#include <svx/dlgctrl.hxx>
+#include <svx/dialmgr.hxx>
+#include <tools/poly.hxx>
+#include <vcl/region.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/hatch.hxx>
+#include <svtools/colorcfg.hxx>
+
+#include "svxrectctaccessiblecontext.hxx"
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <svx/svdorect.hxx>
+
+#include <svx/svdmodel.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include "linectrl.hrc"
+
+#define OUTPUT_DRAWMODE_COLOR (DRAWMODE_DEFAULT)
+#define OUTPUT_DRAWMODE_CONTRAST (DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT)
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::accessibility;
+
+
+/*************************************************************************
+|*
+|* Control zur Darstellung und Auswahl der Eckpunkte (und Mittelpunkt)
+|* eines Objekts
+|*
+\************************************************************************/
+
+Bitmap& SvxRectCtl::GetRectBitmap( void )
+{
+ if( !pBitmap )
+ InitRectBitmap();
+
+ return *pBitmap;
+}
+
+SvxRectCtl::SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt,
+ USHORT nBorder, USHORT nCircle, CTL_STYLE eStyle ) :
+
+ Control( pParent, rResId ),
+
+ pAccContext ( NULL ),
+ nBorderWidth( nBorder ),
+ nRadius ( nCircle),
+ eDefRP ( eRpt ),
+ eCS ( eStyle ),
+ pBitmap ( NULL ),
+ m_nState ( 0 ),
+ mbCompleteDisable(sal_False)
+{
+ SetMapMode( MAP_100TH_MM );
+ Resize_Impl();
+}
+
+// -----------------------------------------------------------------------
+
+SvxRectCtl::~SvxRectCtl()
+{
+ delete pBitmap;
+
+ if( pAccContext )
+ pAccContext->release();
+}
+
+// -----------------------------------------------------------------------
+void SvxRectCtl::Resize()
+{
+ Resize_Impl();
+ Control::Resize();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxRectCtl::Resize_Impl()
+{
+ aSize = GetOutputSize();
+
+ switch( eCS )
+ {
+ case CS_RECT:
+ case CS_ANGLE:
+ case CS_SHADOW:
+ aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth );
+ aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
+ aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth );
+
+ aPtLM = Point( 0 + nBorderWidth, aSize.Height() / 2 );
+ aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
+ aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 );
+
+ aPtLB = Point( 0 + nBorderWidth, aSize.Height() - nBorderWidth );
+ aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth );
+ aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth );
+ break;
+
+ case CS_LINE:
+ aPtLT = Point( 0 + 3 * nBorderWidth, 0 + nBorderWidth );
+ aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth );
+ aPtRT = Point( aSize.Width() - 3 * nBorderWidth, 0 + nBorderWidth );
+
+ aPtLM = Point( 0 + 3 * nBorderWidth, aSize.Height() / 2 );
+ aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 );
+ aPtRM = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() / 2 );
+
+ aPtLB = Point( 0 + 3 * nBorderWidth, aSize.Height() - nBorderWidth );
+ aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth );
+ aPtRB = Point( aSize.Width() - 3 * nBorderWidth, aSize.Height() - nBorderWidth );
+ break;
+ }
+ Reset();
+ InitSettings( TRUE, TRUE );
+}
+// -----------------------------------------------------------------------
+
+void SvxRectCtl::InitRectBitmap( void )
+{
+ if( pBitmap )
+ delete pBitmap;
+
+ const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
+ svtools::ColorConfig aColorConfig;
+
+ pBitmap = new Bitmap( SVX_RES( RID_SVXCTRL_RECTBTNS ) );
+
+ // set bitmap-colors
+ Color aColorAry1[7];
+ Color aColorAry2[7];
+ aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray
+ aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow
+ aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF ); // white
+ aColorAry1[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray
+ aColorAry1[4] = Color( 0x00, 0x00, 0x00 ); // black
+ aColorAry1[5] = Color( 0x00, 0xFF, 0x00 ); // green
+ aColorAry1[6] = Color( 0x00, 0x00, 0xFF ); // blue
+ aColorAry2[0] = rStyles.GetDialogColor(); // background
+ aColorAry2[1] = rStyles.GetWindowColor();
+ aColorAry2[2] = rStyles.GetLightColor();
+ aColorAry2[3] = rStyles.GetShadowColor();
+ aColorAry2[4] = rStyles.GetDarkShadowColor();
+ aColorAry2[5] = Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
+ aColorAry2[6] = rStyles.GetDialogColor();
+
+#ifdef DBG_UTIL
+ static BOOL bModify = FALSE;
+ BOOL& rModify = bModify;
+ if( rModify )
+ {
+ static int n = 0;
+ static UINT8 r = 0xFF;
+ static UINT8 g = 0x00;
+ static UINT8 b = 0xFF;
+ int& rn = n;
+ UINT8& rr = r;
+ UINT8& rg = g;
+ UINT8& rb = b;
+ aColorAry2[ rn ] = Color( rr, rg, rb );
+ }
+#endif
+
+ pBitmap->Replace( aColorAry1, aColorAry2, 7, NULL );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxRectCtl::InitSettings( BOOL bForeground, BOOL bBackground )
+{
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ if( bForeground )
+ {
+ svtools::ColorConfig aColorConfig;
+ Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
+
+ if ( IsControlForeground() )
+ aTextColor = GetControlForeground();
+ SetTextColor( aTextColor );
+ }
+
+ if( bBackground )
+ {
+ if ( IsControlBackground() )
+ SetBackground( GetControlBackground() );
+ else
+ SetBackground( rStyleSettings.GetWindowColor() );
+ }
+
+ delete pBitmap;
+ pBitmap = NULL; // forces new creating of bitmap
+
+ Invalidate();
+}
+
+/*************************************************************************
+|*
+|* Das angeklickte Rechteck (3 x 3) wird ermittelt und der Parent (Dialog)
+|* wird benachrichtigt, dass der Punkt geaendert wurde
+|*
+\************************************************************************/
+
+void SvxRectCtl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
+ if(!IsCompletelyDisabled())
+ {
+ Point aPtLast = aPtNew;
+
+ aPtNew = GetApproxLogPtFromPixPt( rMEvt.GetPosPixel() );
+
+ if( aPtNew == aPtMM && ( eCS == CS_SHADOW || eCS == CS_ANGLE ) )
+ {
+ aPtNew = aPtLast;
+ }
+ else
+ {
+ Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ),
+ aPtLast + Point( nRadius, nRadius ) ) );
+ Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ),
+ aPtNew + Point( nRadius, nRadius ) ) );
+ eRP = GetRPFromPoint( aPtNew );
+
+ SetActualRP( eRP );
+
+ if( WINDOW_TABPAGE == GetParent()->GetType() )
+ ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxRectCtl::KeyInput( const KeyEvent& rKeyEvt )
+{
+ // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
+ if(!IsCompletelyDisabled())
+ {
+ RECT_POINT eNewRP = eRP;
+ BOOL bUseMM = (eCS != CS_SHADOW) && (eCS != CS_ANGLE);
+
+ switch( rKeyEvt.GetKeyCode().GetCode() )
+ {
+ case KEY_DOWN:
+ {
+ if( !(m_nState & CS_NOVERT) )
+ switch( eNewRP )
+ {
+ case RP_LT: eNewRP = RP_LM; break;
+ case RP_MT: eNewRP = bUseMM ? RP_MM : RP_MB; break;
+ case RP_RT: eNewRP = RP_RM; break;
+ case RP_LM: eNewRP = RP_LB; break;
+ case RP_MM: eNewRP = RP_MB; break;
+ case RP_RM: eNewRP = RP_RB; break;
+ default: ; //prevent warning
+ }
+ }
+ break;
+ case KEY_UP:
+ {
+ if( !(m_nState & CS_NOVERT) )
+ switch( eNewRP )
+ {
+ case RP_LM: eNewRP = RP_LT; break;
+ case RP_MM: eNewRP = RP_MT; break;
+ case RP_RM: eNewRP = RP_RT; break;
+ case RP_LB: eNewRP = RP_LM; break;
+ case RP_MB: eNewRP = bUseMM ? RP_MM : RP_MT; break;
+ case RP_RB: eNewRP = RP_RM; break;
+ default: ; //prevent warning
+ }
+ }
+ break;
+ case KEY_LEFT:
+ {
+ if( !(m_nState & CS_NOHORZ) )
+ switch( eNewRP )
+ {
+ case RP_MT: eNewRP = RP_LT; break;
+ case RP_RT: eNewRP = RP_MT; break;
+ case RP_MM: eNewRP = RP_LM; break;
+ case RP_RM: eNewRP = bUseMM ? RP_MM : RP_LM; break;
+ case RP_MB: eNewRP = RP_LB; break;
+ case RP_RB: eNewRP = RP_MB; break;
+ default: ; //prevent warning
+ }
+ }
+ break;
+ case KEY_RIGHT:
+ {
+ if( !(m_nState & CS_NOHORZ) )
+ switch( eNewRP )
+ {
+ case RP_LT: eNewRP = RP_MT; break;
+ case RP_MT: eNewRP = RP_RT; break;
+ case RP_LM: eNewRP = bUseMM ? RP_MM : RP_RM; break;
+ case RP_MM: eNewRP = RP_RM; break;
+ case RP_LB: eNewRP = RP_MB; break;
+ case RP_MB: eNewRP = RP_RB; break;
+ default: ; //prevent warning
+ }
+ }
+ break;
+ default:
+ Control::KeyInput( rKeyEvt );
+ return;
+ }
+ if( eNewRP != eRP )
+ {
+ SetActualRP( eNewRP );
+
+ if( WINDOW_TABPAGE == GetParent()->GetType() )
+ ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
+
+ SetFocusRect();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxRectCtl::StateChanged( StateChangedType nType )
+{
+ if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
+ InitSettings( TRUE, FALSE );
+ else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
+ InitSettings( FALSE, TRUE );
+
+ Window::StateChanged( nType );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxRectCtl::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ InitSettings( TRUE, TRUE );
+ else
+ Window::DataChanged( rDCEvt );
+}
+
+/*************************************************************************
+|*
+|* Zeichnet das Control (Rechteck mit 9 Kreisen)
+|*
+\************************************************************************/
+
+void SvxRectCtl::Paint( const Rectangle& )
+{
+ Point aPtDiff( PixelToLogic( Point( 1, 1 ) ) );
+
+ const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
+
+ SetLineColor( rStyles.GetDialogColor() );
+ SetFillColor( rStyles.GetDialogColor() );
+ DrawRect( Rectangle( Point(0,0), GetOutputSize() ) );
+
+ if( IsEnabled() )
+ SetLineColor( rStyles.GetLabelTextColor() );
+ else
+ SetLineColor( rStyles.GetShadowColor() );
+
+ SetFillColor();
+
+ switch( eCS )
+ {
+
+ case CS_RECT:
+ case CS_SHADOW:
+ if( !IsEnabled() )
+ {
+ Color aOldCol = GetLineColor();
+ SetLineColor( rStyles.GetLightColor() );
+ DrawRect( Rectangle( aPtLT + aPtDiff, aPtRB + aPtDiff ) );
+ SetLineColor( aOldCol );
+ }
+ DrawRect( Rectangle( aPtLT, aPtRB ) );
+ break;
+
+ case CS_LINE:
+ if( !IsEnabled() )
+ {
+ Color aOldCol = GetLineColor();
+ SetLineColor( rStyles.GetLightColor() );
+ DrawLine( aPtLM - Point( 2 * nBorderWidth, 0) + aPtDiff,
+ aPtRM + Point( 2 * nBorderWidth, 0 ) + aPtDiff );
+ SetLineColor( aOldCol );
+ }
+ DrawLine( aPtLM - Point( 2 * nBorderWidth, 0),
+ aPtRM + Point( 2 * nBorderWidth, 0 ) );
+ break;
+
+ case CS_ANGLE:
+ if( !IsEnabled() )
+ {
+ Color aOldCol = GetLineColor();
+ SetLineColor( rStyles.GetLightColor() );
+ DrawLine( aPtLT + aPtDiff, aPtRB + aPtDiff );
+ DrawLine( aPtLB + aPtDiff, aPtRT + aPtDiff );
+ DrawLine( aPtLM + aPtDiff, aPtRM + aPtDiff );
+ DrawLine( aPtMT + aPtDiff, aPtMB + aPtDiff );
+ SetLineColor( aOldCol );
+ }
+ DrawLine( aPtLT, aPtRB );
+ DrawLine( aPtLB, aPtRT );
+ DrawLine( aPtLM, aPtRM );
+ DrawLine( aPtMT, aPtMB );
+ break;
+
+ default:
+ break;
+ }
+ SetFillColor( GetBackground().GetColor() );
+
+ Size aBtnSize( 11, 11 );
+ Size aDstBtnSize( PixelToLogic( aBtnSize ) );
+ Point aToCenter( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
+ Point aBtnPnt1( IsEnabled()?0:22,0 );
+ Point aBtnPnt2( 11,0 );
+ Point aBtnPnt3( 22,0 );
+
+ BOOL bNoHorz = (m_nState & CS_NOHORZ) != 0;
+ BOOL bNoVert = (m_nState & CS_NOVERT) != 0;
+
+ Bitmap& rBitmap = GetRectBitmap();
+
+ // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
+ if(IsCompletelyDisabled())
+ {
+ DrawBitmap( aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
+ DrawBitmap( aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
+ DrawBitmap( aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
+ DrawBitmap( aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
+ if( eCS == CS_RECT || eCS == CS_LINE )
+ DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
+ DrawBitmap( aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
+ DrawBitmap( aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
+ DrawBitmap( aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
+ DrawBitmap( aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap );
+ }
+ else
+ {
+ DrawBitmap( aPtLT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
+ DrawBitmap( aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
+ DrawBitmap( aPtRT - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
+
+ DrawBitmap( aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
+
+ // Mittelpunkt bei Rechteck und Linie
+ if( eCS == CS_RECT || eCS == CS_LINE )
+ DrawBitmap( aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap );
+
+ DrawBitmap( aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
+
+ DrawBitmap( aPtLB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
+ DrawBitmap( aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
+ DrawBitmap( aPtRB - aToCenter, aDstBtnSize, (bNoHorz | bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap );
+ }
+
+ // draw active button, avoid center pos for angle
+ // #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
+ if(!IsCompletelyDisabled())
+ {
+ if( IsEnabled() && (eCS != CS_ANGLE || aPtNew != aPtMM) )
+ {
+ Point aCenterPt( aPtNew );
+ aCenterPt -= aToCenter;
+
+ DrawBitmap( aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Konvertiert RECT_POINT in Point
+|*
+\************************************************************************/
+
+Point SvxRectCtl::GetPointFromRP( RECT_POINT _eRP) const
+{
+ switch( _eRP )
+ {
+ case RP_LT: return aPtLT;
+ case RP_MT: return aPtMT;
+ case RP_RT: return aPtRT;
+ case RP_LM: return aPtLM;
+ case RP_MM: return aPtMM;
+ case RP_RM: return aPtRM;
+ case RP_LB: return aPtLB;
+ case RP_MB: return aPtMB;
+ case RP_RB: return aPtRB;
+ }
+ return( aPtMM ); // default
+}
+
+
+void SvxRectCtl::SetFocusRect( const Rectangle* pRect )
+{
+ HideFocus();
+
+ if( pRect )
+ ShowFocus( *pRect );
+ else
+ ShowFocus( CalculateFocusRectangle() );
+}
+
+Point SvxRectCtl::SetActualRPWithoutInvalidate( RECT_POINT eNewRP )
+{
+ Point aPtLast = aPtNew;
+ aPtNew = GetPointFromRP( eNewRP );
+
+ if( (m_nState & CS_NOHORZ) != 0 )
+ aPtNew.X() = aPtMM.X();
+
+ if( (m_nState & CS_NOVERT) != 0 )
+ aPtNew.Y() = aPtMM.Y();
+
+ eNewRP = GetRPFromPoint( aPtNew );
+
+ eDefRP = eNewRP;
+ eRP = eNewRP;
+
+ return aPtLast;
+}
+
+void SvxRectCtl::GetFocus()
+{
+ SetFocusRect();
+}
+
+
+void SvxRectCtl::LoseFocus()
+{
+ HideFocus();
+}
+
+
+Point SvxRectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const
+{
+ Point aPt = PixelToLogic( rPt );
+ long x;
+ long y;
+
+ if( ( m_nState & CS_NOHORZ ) == 0 )
+ {
+ if( aPt.X() < aSize.Width() / 3 )
+ x = aPtLT.X();
+ else if( aPt.X() < aSize.Width() * 2 / 3 )
+ x = aPtMM.X();
+ else
+ x = aPtRB.X();
+ }
+ else
+ x = aPtMM.X();
+
+ if( ( m_nState & CS_NOVERT ) == 0 )
+ {
+ if( aPt.Y() < aSize.Height() / 3 )
+ y = aPtLT.Y();
+ else if( aPt.Y() < aSize.Height() * 2 / 3 )
+ y = aPtMM.Y();
+ else
+ y = aPtRB.Y();
+ }
+ else
+ y = aPtMM.Y();
+
+ return Point( x, y );
+}
+
+
+/*************************************************************************
+|*
+|* Konvertiert Point in RECT_POINT
+|*
+\************************************************************************/
+
+RECT_POINT SvxRectCtl::GetRPFromPoint( Point aPt ) const
+{
+ if ( aPt == aPtLT) return RP_LT;
+ else if( aPt == aPtMT) return RP_MT;
+ else if( aPt == aPtRT) return RP_RT;
+ else if( aPt == aPtLM) return RP_LM;
+ else if( aPt == aPtRM) return RP_RM;
+ else if( aPt == aPtLB) return RP_LB;
+ else if( aPt == aPtMB) return RP_MB;
+ else if( aPt == aPtRB) return RP_RB;
+
+ else
+ return RP_MM; // default
+}
+
+/*************************************************************************
+|*
+|* Bewirkt den Ursprungszustand des Controls
+|*
+\************************************************************************/
+
+void SvxRectCtl::Reset()
+{
+ aPtNew = GetPointFromRP( eDefRP );
+ eRP = eDefRP;
+ Invalidate();
+}
+
+/*************************************************************************
+|*
+|* Gibt den aktuell ausgewaehlten RECT_POINT zur�ck
+|*
+\************************************************************************/
+
+RECT_POINT SvxRectCtl::GetActualRP() const
+{
+ return( eRP );
+}
+
+/*************************************************************************
+|*
+|* Gibt den aktuell ausgewaehlten RECT_POINT zur�ck
+|*
+\************************************************************************/
+
+void SvxRectCtl::SetActualRP( RECT_POINT eNewRP )
+{
+ Point aPtLast( SetActualRPWithoutInvalidate( eNewRP ) );
+
+ Invalidate( Rectangle( aPtLast - Point( nRadius, nRadius ), aPtLast + Point( nRadius, nRadius ) ) );
+ Invalidate( Rectangle( aPtNew - Point( nRadius, nRadius ), aPtNew + Point( nRadius, nRadius ) ) );
+
+ // notify accessibility object about change
+ if( pAccContext )
+ pAccContext->selectChild( eNewRP );
+}
+
+void SvxRectCtl::SetState( CTL_STATE nState )
+{
+ m_nState = nState;
+
+ Point aPtLast( GetPointFromRP( eRP ) );
+ Point _aPtNew( aPtLast );
+
+ if( (m_nState & CS_NOHORZ) != 0 )
+ _aPtNew.X() = aPtMM.X();
+
+ if( (m_nState & CS_NOVERT) != 0 )
+ _aPtNew.Y() = aPtMM.Y();
+
+ eRP = GetRPFromPoint( _aPtNew );
+ Invalidate();
+
+ if( WINDOW_TABPAGE == GetParent()->GetType() )
+ ( (SvxTabPage*) GetParent() )->PointChanged( this, eRP );
+}
+
+UINT8 SvxRectCtl::GetNumOfChilds( void ) const
+{
+ return ( eCS == CS_ANGLE )? 8 : 9;
+}
+
+Rectangle SvxRectCtl::CalculateFocusRectangle( void ) const
+{
+ Size aDstBtnSize( PixelToLogic( Size( 15, 15 ) ) );
+ return Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
+}
+
+Rectangle SvxRectCtl::CalculateFocusRectangle( RECT_POINT eRectPoint ) const
+{
+ Rectangle aRet;
+ RECT_POINT eOldRectPoint = GetActualRP();
+
+ if( eOldRectPoint == eRectPoint )
+ aRet = CalculateFocusRectangle();
+ else
+ {
+ SvxRectCtl* pThis = const_cast< SvxRectCtl* >( this );
+
+ pThis->SetActualRPWithoutInvalidate( eRectPoint ); // no invalidation because it's only temporary!
+ aRet = CalculateFocusRectangle();
+
+ pThis->SetActualRPWithoutInvalidate( eOldRectPoint ); // no invalidation because nothing has changed!
+ }
+
+ return aRet;
+}
+
+Reference< XAccessible > SvxRectCtl::CreateAccessible()
+{
+ Window* pParent = GetAccessibleParentWindow();
+
+ DBG_ASSERT( pParent, "-SvxRectCtl::CreateAccessible(): No Parent!" );
+
+ Reference< XAccessible > xAccParent = pParent->GetAccessible();
+ if( xAccParent.is() )
+ {
+ pAccContext = new SvxRectCtlAccessibleContext( xAccParent, *this );
+ pAccContext->acquire();
+
+ SetActualRP( GetActualRP() );
+
+ return pAccContext;
+ }
+ else
+ return Reference< XAccessible >();
+}
+
+RECT_POINT SvxRectCtl::GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& r ) const
+{
+ return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
+}
+
+// #103516# CompletelyDisabled() added to have a disabled state for SvxRectCtl
+void SvxRectCtl::DoCompletelyDisable(sal_Bool bNew)
+{
+ mbCompleteDisable = bNew;
+ Invalidate();
+}
+
+/*************************************************************************
+|*
+|* Konstruktor ohne Size-Parameter
+|*
+\************************************************************************/
+
+SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId ) :
+
+ SvxRectCtl( pParent, rResId ),
+
+ aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
+{
+ aFontSize = Size( 250, 400 );
+ Initialize();
+}
+
+/*************************************************************************
+|*
+|* Konstruktor mit Size-Parameter
+|*
+\************************************************************************/
+
+SvxAngleCtl::SvxAngleCtl( Window* pParent, const ResId& rResId, Size _aSize ) :
+
+ SvxRectCtl( pParent, rResId ),
+
+ aFont( Application::GetSettings().GetStyleSettings().GetAppFont() )
+{
+ aFontSize = _aSize;
+ Initialize();
+}
+
+/*************************************************************************
+|*
+|* Initialisierung
+|*
+\************************************************************************/
+
+void SvxAngleCtl::Initialize()
+{
+ bPositive = TRUE;
+
+ // aFont.SetName( "Helvetica" );
+ aFont.SetSize( aFontSize );
+ aFont.SetWeight( WEIGHT_NORMAL );
+ aFont.SetTransparent( FALSE );
+
+ SetFont( aFont );
+}
+
+/*************************************************************************
+|*
+|* Zeichnet das (Mini-)Koordinatensystem
+|*
+\************************************************************************/
+
+void SvxAngleCtl::Paint( const Rectangle& )
+{
+ SetLineColor( Color( COL_BLACK ) ); // PEN_DOT ???
+ DrawLine( aPtLT - Point( 0, 0), aPtRB + Point( 0, 0 ) );
+ DrawLine( aPtLB - Point( 0, 0), aPtRT + Point( 0, 0 ) );
+
+ SetLineColor( Color( COL_BLACK ) );
+ DrawLine( aPtLM - Point( 0, 0), aPtRM + Point( 0, 0 ) );
+ DrawLine( aPtMT - Point( 0, 0), aPtMB + Point( 0, 0 ) );
+
+ Point aDiff(aFontSize.Width() / 2, aFontSize.Height() / 2);
+
+ DrawText( aPtLT - aDiff, UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "135" ) ) );
+ DrawText( aPtLM - aDiff, UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "180" ) ) );
+
+ if ( bPositive )
+ DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "225" ) ) );
+ else
+ DrawText( aPtLB - aDiff, UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "-135" ) ) );
+
+ aDiff.X() = aFontSize.Width();
+ DrawText( aPtMT - aDiff, UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "90" ) ) );
+ DrawText( aPtRT - aDiff, UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "45" ) ) );
+ aDiff.X() = aDiff .X() * 3 / 2;
+
+ if ( bPositive )
+ DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "270" ) ) );
+ else
+ DrawText( aPtMB - aDiff, UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "-90" ) ) );
+
+ DrawText( aPtRM - Point( 0, aDiff.Y() ), UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "0" ) ) );
+ aDiff.X() = aFontSize.Width() * 2;
+
+ if ( bPositive )
+ DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "315" ) ) );
+ else
+ DrawText( aPtRB - aDiff, UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "-45" ) ) );
+}
+
+/*************************************************************************
+|*
+|* Control zum Editieren von Bitmaps
+|*
+\************************************************************************/
+
+SvxPixelCtl::SvxPixelCtl( Window* pParent, const ResId& rResId, USHORT nNumber ) :
+ Control ( pParent, rResId ),
+ nLines ( nNumber ),
+ bPaintable ( TRUE )
+{
+ // SetMapMode( MAP_100TH_MM );
+ aRectSize = GetOutputSize();
+
+ SetPixelColor( Color( COL_BLACK ) );
+ SetBackgroundColor( Color( COL_WHITE ) );
+ SetLineColor( Application::GetSettings().GetStyleSettings().GetShadowColor() );
+
+ nSquares = nLines * nLines;
+ pPixel = new USHORT[ nSquares ];
+ rtl_zeroMemory(pPixel, nSquares * sizeof(USHORT));
+}
+
+/*************************************************************************
+|*
+|* Destruktor dealociert dyn. Array
+|*
+\************************************************************************/
+
+SvxPixelCtl::~SvxPixelCtl( )
+{
+ delete []pPixel;
+}
+
+/*************************************************************************
+|*
+|* Wechselt die Vordergrund- ,bzw. Hintergrundfarbe
+|*
+\************************************************************************/
+
+void SvxPixelCtl::ChangePixel( USHORT nPixel )
+{
+ if( *( pPixel + nPixel) == 0 )
+ *( pPixel + nPixel) = 1; // koennte erweitert werden auf mehrere Farben
+ else
+ *( pPixel + nPixel) = 0;
+}
+
+/*************************************************************************
+|*
+|* Das angeklickte Rechteck wird ermittelt um die Farbe zu wechseln
+|*
+\************************************************************************/
+
+void SvxPixelCtl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Point aPt = PixelToLogic( rMEvt.GetPosPixel() );
+ Point aPtTl, aPtBr;
+ USHORT nX, nY;
+
+ nX = (USHORT) ( aPt.X() * nLines / aRectSize.Width() );
+ nY = (USHORT) ( aPt.Y() * nLines / aRectSize.Height() );
+
+ ChangePixel( nX + nY * nLines );
+
+ aPtTl.X() = aRectSize.Width() * nX / nLines + 1;
+ aPtBr.X() = aRectSize.Width() * (nX + 1) / nLines - 1;
+ aPtTl.Y() = aRectSize.Height() * nY / nLines + 1;
+ aPtBr.Y() = aRectSize.Height() * (nY + 1) / nLines - 1;
+
+ Invalidate( Rectangle( aPtTl, aPtBr ) );
+
+ if( WINDOW_TABPAGE == GetParent()->GetType() )
+ ( (SvxTabPage*) GetParent() )->PointChanged( this, RP_MM ); // RectPoint ist dummy
+}
+
+/*************************************************************************
+|*
+|* Zeichnet das Control (Rechteck mit 9 Kreisen)
+|*
+\************************************************************************/
+
+void SvxPixelCtl::Paint( const Rectangle& )
+{
+ USHORT i, j, nTmp;
+ Point aPtTl, aPtBr;
+
+ if( bPaintable )
+ {
+ // Linien Zeichnen
+ Control::SetLineColor( aLineColor );
+ for( i = 1; i < nLines; i++)
+ {
+ // horizontal
+ nTmp = (USHORT) ( aRectSize.Height() * i / nLines );
+ DrawLine( Point( 0, nTmp ), Point( aRectSize.Width(), nTmp ) );
+ // vertikal
+ nTmp = (USHORT) ( aRectSize.Width() * i / nLines );
+ DrawLine( Point( nTmp, 0 ), Point( nTmp, aRectSize.Height() ) );
+ }
+
+ // Rechtecke (Quadrate) zeichnen
+ Control::SetLineColor();
+ USHORT nLastPixel = *pPixel ? 0 : 1;
+
+ for( i = 0; i < nLines; i++)
+ {
+ aPtTl.Y() = aRectSize.Height() * i / nLines + 1;
+ aPtBr.Y() = aRectSize.Height() * (i + 1) / nLines - 1;
+
+ for( j = 0; j < nLines; j++)
+ {
+ aPtTl.X() = aRectSize.Width() * j / nLines + 1;
+ aPtBr.X() = aRectSize.Width() * (j + 1) / nLines - 1;
+
+ if ( *( pPixel + i * nLines + j ) != nLastPixel )
+ {
+ nLastPixel = *( pPixel + i * nLines + j );
+ // Farbe wechseln: 0 -> Hintergrundfarbe
+ SetFillColor( nLastPixel ? aPixelColor : aBackgroundColor );
+ }
+ DrawRect( Rectangle( aPtTl, aPtBr ) );
+ }
+ }
+ } // bPaintable
+ else
+ {
+ SetBackground( Wallpaper( Color( COL_LIGHTGRAY ) ) );
+ Control::SetLineColor( Color( COL_LIGHTRED ) );
+ DrawLine( Point( 0, 0 ), Point( aRectSize.Width(), aRectSize.Height() ) );
+ DrawLine( Point( 0, aRectSize.Height() ), Point( aRectSize.Width(), 0 ) );
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxPixelCtl::SetXBitmap( const XOBitmap& rXBmp )
+{
+ if( rXBmp.GetBitmapType() == XBITMAP_8X8 )
+ {
+ aPixelColor = rXBmp.GetPixelColor();
+ aBackgroundColor = rXBmp.GetBackgroundColor();
+
+ USHORT* pArray = rXBmp.GetPixelArray();
+
+ for( USHORT i = 0; i < nSquares; i++ )
+ *( pPixel + i ) = *( pArray + i );
+ }
+}
+
+/*************************************************************************
+|*
+|* Gibt ein bestimmtes Pixel zurueck
+|*
+\************************************************************************/
+
+USHORT SvxPixelCtl::GetBitmapPixel( const USHORT nPixel )
+{
+ return( *( pPixel + nPixel ) );
+}
+
+/*************************************************************************
+|*
+|* Bewirkt den Ursprungszustand des Controls
+|*
+\************************************************************************/
+
+void SvxPixelCtl::Reset()
+{
+ // clear pixel area
+ rtl_zeroMemory(pPixel, nSquares * sizeof(USHORT));
+ Invalidate();
+}
+
+/*************************************************************************
+|*
+|* Ctor: BitmapCtl fuer SvxPixelCtl
+|*
+\************************************************************************/
+
+SvxBitmapCtl::SvxBitmapCtl( Window* /*pParent*/, const Size& rSize )
+{
+ aSize = rSize;
+ // aVD.SetOutputSizePixel( aSize );
+}
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+\************************************************************************/
+
+SvxBitmapCtl::~SvxBitmapCtl()
+{
+}
+
+/*************************************************************************
+|*
+|* BitmapCtl: Gibt die Bitmap zurueck
+|*
+\************************************************************************/
+
+XOBitmap SvxBitmapCtl::GetXBitmap()
+{
+ XOBitmap aXOBitmap( pBmpArray, aPixelColor, aBackgroundColor );
+
+ return( aXOBitmap );
+}
+
+/*************************************************************************
+|*
+|* Fuellt die Listbox mit Farben und Strings
+|*
+\************************************************************************/
+
+void ColorLB::Fill( const XColorTable* pColorTab )
+{
+ long nCount = pColorTab->Count();
+ XColorEntry* pEntry;
+ SetUpdateMode( FALSE );
+
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pColorTab->GetColor( i );
+ InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+ }
+ SetUpdateMode( TRUE );
+}
+
+/************************************************************************/
+
+void ColorLB::Append( XColorEntry* pEntry, Bitmap* )
+{
+ InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+}
+
+/************************************************************************/
+
+void ColorLB::Modify( XColorEntry* pEntry, USHORT nPos, Bitmap* )
+{
+ RemoveEntry( nPos );
+ InsertEntry( pEntry->GetColor(), pEntry->GetName(), nPos );
+}
+
+/*************************************************************************
+|*
+|* Fuellt die Listbox mit Farben und Strings
+|*
+\************************************************************************/
+
+void FillAttrLB::Fill( const XColorTable* pColorTab )
+{
+ long nCount = pColorTab->Count();
+ XColorEntry* pEntry;
+ SetUpdateMode( FALSE );
+
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pColorTab->GetColor( i );
+ InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+ }
+ SetUpdateMode( TRUE );
+}
+
+/*************************************************************************
+|*
+|* Fuellt die Listbox (vorlaeufig) mit Strings
+|*
+\************************************************************************/
+
+HatchingLB::HatchingLB( Window* pParent, ResId Id, BOOL bUserDraw /*= TRUE*/ )
+: ListBox( pParent, Id ),
+ mpList ( NULL ),
+ mbUserDraw( bUserDraw )
+{
+ EnableUserDraw( mbUserDraw );
+}
+
+HatchingLB::HatchingLB( Window* pParent, WinBits aWB, BOOL bUserDraw /*= TRUE*/ )
+: ListBox( pParent, aWB ),
+ mpList ( NULL ),
+ mbUserDraw( bUserDraw )
+{
+ EnableUserDraw( mbUserDraw );
+}
+
+void HatchingLB::Fill( const XHatchList* pList )
+{
+ mpList = (XHatchList*)pList;
+ XHatchEntry* pEntry;
+ long nCount = pList->Count();
+
+ SetUpdateMode( FALSE );
+
+ if( mbUserDraw )
+ {
+ for( long i = 0; i < nCount; i++ )
+ InsertEntry( pList->GetHatch( i )->GetName() );
+ }
+ else
+ {
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pList->GetHatch( i );
+ Bitmap* pBitmap = pList->GetBitmap( i );
+ if( pBitmap )
+ InsertEntry( pEntry->GetName(), *pBitmap );
+ else
+ InsertEntry( pEntry->GetName() );
+ }
+ }
+
+ SetUpdateMode( TRUE );
+}
+
+void HatchingLB::UserDraw( const UserDrawEvent& rUDEvt )
+{
+ if( mpList != NULL )
+ {
+ // Draw gradient with borderrectangle
+ const Rectangle& rDrawRect = rUDEvt.GetRect();
+ Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
+
+ sal_Int32 nId = rUDEvt.GetItemId();
+ if( nId >= 0 && nId <= mpList->Count() )
+ {
+ OutputDevice* pDevice = rUDEvt.GetDevice();
+
+ ULONG nOldDrawMode = pDevice->GetDrawMode();
+ pDevice->SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
+
+ XHatch& rXHatch = mpList->GetHatch( rUDEvt.GetItemId() )->GetHatch();
+ MapMode aMode( MAP_100TH_MM );
+ Hatch aHatch( (HatchStyle) rXHatch.GetHatchStyle(),
+ rXHatch.GetColor(),
+ rUDEvt.GetDevice()->LogicToPixel( Point( rXHatch.GetDistance(), 0 ), aMode ).X(),
+ (sal_uInt16)rXHatch.GetAngle() );
+ const Polygon aPolygon( aRect );
+ const PolyPolygon aPolypoly( aPolygon );
+ pDevice->DrawHatch( aPolypoly, aHatch );
+
+ pDevice->SetLineColor( COL_BLACK );
+ pDevice->SetFillColor();
+ pDevice->DrawRect( aRect );
+
+ pDevice->SetDrawMode( nOldDrawMode );
+
+ // Draw name
+ pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetHatch( rUDEvt.GetItemId() )->GetName() );
+ }
+ }
+}
+
+/************************************************************************/
+
+void HatchingLB::Append( XHatchEntry* pEntry, Bitmap* pBmp )
+{
+ if( pBmp )
+ InsertEntry( pEntry->GetName(), *pBmp );
+ else
+ InsertEntry( pEntry->GetName() );
+}
+
+/************************************************************************/
+
+void HatchingLB::Modify( XHatchEntry* pEntry, USHORT nPos, Bitmap* pBmp )
+{
+ RemoveEntry( nPos );
+
+ if( pBmp )
+ InsertEntry( pEntry->GetName(), *pBmp, nPos );
+ else
+ InsertEntry( pEntry->GetName(), nPos );
+}
+
+/************************************************************************/
+
+void HatchingLB::SelectEntryByList( const XHatchList* pList, const String& rStr,
+ const XHatch& rHatch, USHORT nDist )
+{
+ long nCount = pList->Count();
+ XHatchEntry* pEntry;
+ BOOL bFound = FALSE;
+ String aStr;
+
+ long i;
+ for( i = 0; i < nCount && !bFound; i++ )
+ {
+ pEntry = pList->GetHatch( i );
+
+ aStr = pEntry->GetName();
+
+ if( rStr == aStr && rHatch == pEntry->GetHatch() )
+ bFound = TRUE;
+ }
+ if( bFound )
+ SelectEntryPos( (USHORT) ( i - 1 + nDist ) );
+}
+
+/*************************************************************************
+|*
+|* Fuellt die Listbox (vorlaeufig) mit Strings
+|*
+\************************************************************************/
+
+void FillAttrLB::Fill( const XHatchList* pList )
+{
+ long nCount = pList->Count();
+ XHatchEntry* pEntry;
+ ListBox::SetUpdateMode( FALSE );
+
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pList->GetHatch( i );
+ Bitmap* pBitmap = pList->GetBitmap( i );
+ if( pBitmap )
+ ListBox::InsertEntry( pEntry->GetName(), *pBitmap );
+ else
+ InsertEntry( pEntry->GetName() );
+ }
+ ListBox::SetUpdateMode( TRUE );
+}
+
+/*************************************************************************
+|*
+|* Fuellt die Listbox (vorlaeufig) mit Strings
+|*
+\************************************************************************/
+
+GradientLB::GradientLB( Window* pParent, ResId Id, BOOL bUserDraw /*= TRUE*/ )
+: ListBox( pParent, Id ),
+ mpList(NULL),
+ mbUserDraw( bUserDraw )
+{
+ EnableUserDraw( mbUserDraw);
+}
+
+GradientLB::GradientLB( Window* pParent, WinBits aWB, BOOL bUserDraw /*= TRUE*/ )
+: ListBox( pParent, aWB ),
+ mpList(NULL),
+ mbUserDraw( bUserDraw )
+{
+ EnableUserDraw( mbUserDraw );
+}
+
+void GradientLB::Fill( const XGradientList* pList )
+{
+ mpList = (XGradientList*)pList;
+ XGradientEntry* pEntry;
+ long nCount = pList->Count();
+
+ SetUpdateMode( FALSE );
+
+ if( mbUserDraw )
+ {
+ for( long i = 0; i < nCount; i++ )
+ InsertEntry( pList->GetGradient( i )->GetName() );
+ }
+ else
+ {
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pList->GetGradient( i );
+ Bitmap* pBitmap = pList->GetBitmap( i );
+ if( pBitmap )
+ InsertEntry( pEntry->GetName(), *pBitmap );
+ else
+ InsertEntry( pEntry->GetName() );
+ }
+ }
+
+ SetUpdateMode( TRUE );
+}
+
+void GradientLB::UserDraw( const UserDrawEvent& rUDEvt )
+{
+ if( mpList != NULL )
+ {
+ // Draw gradient with borderrectangle
+ const Rectangle& rDrawRect = rUDEvt.GetRect();
+ Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
+
+ sal_Int32 nId = rUDEvt.GetItemId();
+ if( nId >= 0 && nId <= mpList->Count() )
+ {
+ OutputDevice* pDevice = rUDEvt.GetDevice();
+
+ XGradient& rXGrad = mpList->GetGradient( rUDEvt.GetItemId() )->GetGradient();
+ Gradient aGradient( (GradientStyle) rXGrad.GetGradientStyle(), rXGrad.GetStartColor(), rXGrad.GetEndColor() );
+ aGradient.SetAngle( (USHORT)rXGrad.GetAngle() );
+ aGradient.SetBorder( rXGrad.GetBorder() );
+ aGradient.SetOfsX( rXGrad.GetXOffset() );
+ aGradient.SetOfsY( rXGrad.GetYOffset() );
+ aGradient.SetStartIntensity( rXGrad.GetStartIntens() );
+ aGradient.SetEndIntensity( rXGrad.GetEndIntens() );
+ aGradient.SetSteps( 255 );
+
+ // #i76307# always paint the preview in LTR, because this is what the document does
+ Window* pWin = dynamic_cast<Window*>(pDevice);
+ if( pWin && pWin->IsRTLEnabled() && Application::GetSettings().GetLayoutRTL())
+ {
+ long nWidth = pDevice->GetOutputSize().Width();
+
+ pWin->EnableRTL( FALSE );
+
+ Rectangle aMirrorRect( Point( nWidth - aRect.Left() - aRect.GetWidth(), aRect.Top() ),
+ aRect.GetSize() );
+
+ pDevice->DrawGradient( aMirrorRect, aGradient );
+
+ pWin->EnableRTL( TRUE );
+ }
+ else
+ pDevice->DrawGradient( aRect, aGradient );
+
+ pDevice->SetLineColor( COL_BLACK );
+ pDevice->SetFillColor();
+ pDevice->DrawRect( aRect );
+
+ // Draw name
+ pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetGradient( rUDEvt.GetItemId() )->GetName() );
+ }
+ }
+}
+
+/************************************************************************/
+
+void GradientLB::Append( XGradientEntry* pEntry, Bitmap* pBmp )
+{
+ if( pBmp )
+ InsertEntry( pEntry->GetName(), *pBmp );
+ else
+ InsertEntry( pEntry->GetName() );
+}
+
+/************************************************************************/
+
+void GradientLB::Modify( XGradientEntry* pEntry, USHORT nPos, Bitmap* pBmp )
+{
+ RemoveEntry( nPos );
+
+ if( pBmp )
+ InsertEntry( pEntry->GetName(), *pBmp, nPos );
+ else
+ InsertEntry( pEntry->GetName(), nPos );
+}
+
+/************************************************************************/
+
+void GradientLB::SelectEntryByList( const XGradientList* pList, const String& rStr,
+ const XGradient& rGradient, USHORT nDist )
+{
+ long nCount = pList->Count();
+ XGradientEntry* pEntry;
+ BOOL bFound = FALSE;
+ String aStr;
+
+ long i;
+ for( i = 0; i < nCount && !bFound; i++ )
+ {
+ pEntry = pList->GetGradient( i );
+
+ aStr = pEntry->GetName();
+
+ if( rStr == aStr && rGradient == pEntry->GetGradient() )
+ bFound = TRUE;
+ }
+ if( bFound )
+ SelectEntryPos( (USHORT) ( i - 1 + nDist ) );
+}
+
+/*************************************************************************
+|*
+|* Fuellt die Listbox (vorlaeufig) mit Strings
+|*
+\************************************************************************/
+
+void FillAttrLB::Fill( const XGradientList* pList )
+{
+ long nCount = pList->Count();
+ XGradientEntry* pEntry;
+ ListBox::SetUpdateMode( FALSE );
+
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pList->GetGradient( i );
+ Bitmap* pBitmap = pList->GetBitmap( i );
+ if( pBitmap )
+ ListBox::InsertEntry( pEntry->GetName(), *pBitmap );
+ else
+ InsertEntry( pEntry->GetName() );
+ }
+ ListBox::SetUpdateMode( TRUE );
+}
+
+/*************************************************************************
+|*
+|* Konstruktor von BitmapLB
+|*
+\************************************************************************/
+
+BitmapLB::BitmapLB( Window* pParent, ResId Id, BOOL bUserDraw /*= TRUE*/ )
+: ListBox( pParent, Id ),
+ mpList( NULL ),
+ mbUserDraw( bUserDraw )
+{
+ aVD.SetOutputSizePixel( Size( 32, 16 ) );
+ EnableUserDraw( mbUserDraw );
+}
+
+/************************************************************************/
+
+void BitmapLB::SetVirtualDevice()
+{
+ if( aBitmap.GetSizePixel().Width() > 8 ||
+ aBitmap.GetSizePixel().Height() > 8 )
+ {
+ aVD.DrawBitmap( Point( 0, 0 ), Size( 32, 16 ), aBitmap );
+ }
+ else
+ {
+ aVD.DrawBitmap( Point( 0, 0 ), aBitmap );
+ aVD.DrawBitmap( Point( 8, 0 ), aBitmap );
+ aVD.DrawBitmap( Point( 16, 0 ), aBitmap );
+ aVD.DrawBitmap( Point( 24, 0 ), aBitmap );
+ aVD.DrawBitmap( Point( 0, 8 ), aBitmap );
+ aVD.DrawBitmap( Point( 8, 8 ), aBitmap );
+ aVD.DrawBitmap( Point( 16, 8 ), aBitmap );
+ aVD.DrawBitmap( Point( 24, 8 ), aBitmap );
+ }
+}
+
+/************************************************************************/
+
+void BitmapLB::Fill( const XBitmapList* pList )
+{
+ mpList = (XBitmapList*)pList;
+ XBitmapEntry* pEntry;
+ long nCount = pList->Count();
+
+ SetUpdateMode( FALSE );
+
+ if( mbUserDraw )
+ {
+ for( long i = 0; i < nCount; i++ )
+ InsertEntry( pList->GetBitmap( i )->GetName() );
+ }
+ else
+ {
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pList->GetBitmap( i );
+ aBitmap = pEntry->GetXBitmap().GetBitmap();
+
+ SetVirtualDevice();
+
+ InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
+ }
+ }
+
+ SetUpdateMode( TRUE );
+}
+
+void BitmapLB::UserDraw( const UserDrawEvent& rUDEvt )
+{
+ if( mpList != NULL )
+ {
+ // Draw bitmap
+ const Rectangle& rDrawRect = rUDEvt.GetRect();
+ Rectangle aRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nLeft+33, rDrawRect.nBottom-1 );
+
+ sal_Int32 nId = rUDEvt.GetItemId();
+ if( nId >= 0 && nId <= mpList->Count() )
+ {
+ Rectangle aClipRect( rDrawRect.nLeft+1, rDrawRect.nTop+1, rDrawRect.nRight-1, rDrawRect.nBottom-1 );
+
+ OutputDevice* pDevice = rUDEvt.GetDevice();
+ pDevice->SetClipRegion( Region( aClipRect ) );
+
+ aBitmap = mpList->GetBitmap( nId )->GetXBitmap().GetBitmap();
+
+ long nPosBaseX = aRect.nLeft;
+ long nPosBaseY = aRect.nTop;
+
+ if( aBitmap.GetSizePixel().Width() > 8 ||
+ aBitmap.GetSizePixel().Height() > 8 )
+ {
+ pDevice->DrawBitmap( Point( nPosBaseX, nPosBaseY ), Size( 32, 16 ), aBitmap );
+ }
+ else
+ {
+ pDevice->DrawBitmap( Point( nPosBaseX+ 0, nPosBaseY+0 ), aBitmap );
+ pDevice->DrawBitmap( Point( nPosBaseX+ 8, nPosBaseY+0 ), aBitmap );
+ pDevice->DrawBitmap( Point( nPosBaseX+16, nPosBaseY+0 ), aBitmap );
+ pDevice->DrawBitmap( Point( nPosBaseX+24, nPosBaseY+0 ), aBitmap );
+ pDevice->DrawBitmap( Point( nPosBaseX+ 0, nPosBaseY+8 ), aBitmap );
+ pDevice->DrawBitmap( Point( nPosBaseX+ 8, nPosBaseY+8 ), aBitmap );
+ pDevice->DrawBitmap( Point( nPosBaseX+16, nPosBaseY+8 ), aBitmap );
+ pDevice->DrawBitmap( Point( nPosBaseX+24, nPosBaseY+8 ), aBitmap );
+ }
+
+ pDevice->SetClipRegion();
+
+ // Draw name
+ pDevice->DrawText( Point( aRect.nRight+7, aRect.nTop-1 ), mpList->GetBitmap( nId )->GetName() );
+ }
+ }
+}
+
+/************************************************************************/
+
+void BitmapLB::Append( XBitmapEntry* pEntry, Bitmap* pBmp )
+{
+ if( pBmp )
+ {
+ aBitmap = pEntry->GetXBitmap().GetBitmap();
+ SetVirtualDevice();
+ InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
+ }
+ else
+ InsertEntry( pEntry->GetName() );
+}
+
+/************************************************************************/
+
+void BitmapLB::Modify( XBitmapEntry* pEntry, USHORT nPos, Bitmap* pBmp )
+{
+ RemoveEntry( nPos );
+
+ if( pBmp )
+ {
+ aBitmap = pEntry->GetXBitmap().GetBitmap();
+ SetVirtualDevice();
+
+ InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ), nPos );
+ }
+ else
+ InsertEntry( pEntry->GetName() );
+}
+
+/************************************************************************/
+
+void BitmapLB::SelectEntryByList( const XBitmapList* pList, const String& rStr,
+ const Bitmap& )
+{
+ long nCount = pList->Count();
+ XBitmapEntry* pEntry;
+ BOOL bFound = FALSE;
+
+ long i;
+ for( i = 0; i < nCount && !bFound; i++ )
+ {
+ pEntry = pList->GetBitmap( i );
+
+ String aStr = pEntry->GetName();
+ // Bitmap aBmp = pEntry->GetBitmap();
+
+ if( rStr == aStr )
+ {
+ bFound = TRUE;
+ }
+ }
+ if( bFound )
+ SelectEntryPos( (USHORT) ( i - 1 ) );
+}
+
+/*************************************************************************
+|*
+|* Konstruktor von FillAttrLB
+|*
+\************************************************************************/
+
+FillAttrLB::FillAttrLB( Window* pParent, ResId Id ) :
+ ColorListBox( pParent, Id )
+{
+ aVD.SetOutputSizePixel( Size( 32, 16 ) );
+}
+
+/************************************************************************/
+
+FillAttrLB::FillAttrLB( Window* pParent, WinBits aWB ) :
+ ColorListBox( pParent, aWB )
+{
+ aVD.SetOutputSizePixel( Size( 32, 16 ) );
+}
+
+/************************************************************************/
+
+void FillAttrLB::SetVirtualDevice()
+{
+ if( aBitmap.GetSizePixel().Width() > 8 ||
+ aBitmap.GetSizePixel().Height() > 8 )
+ {
+ aVD.DrawBitmap( Point( 0, 0 ), Size( 32, 16 ), aBitmap );
+ }
+ else
+ {
+ aVD.DrawBitmap( Point( 0, 0 ), aBitmap );
+ aVD.DrawBitmap( Point( 8, 0 ), aBitmap );
+ aVD.DrawBitmap( Point( 16, 0 ), aBitmap );
+ aVD.DrawBitmap( Point( 24, 0 ), aBitmap );
+ aVD.DrawBitmap( Point( 0, 8 ), aBitmap );
+ aVD.DrawBitmap( Point( 8, 8 ), aBitmap );
+ aVD.DrawBitmap( Point( 16, 8 ), aBitmap );
+ aVD.DrawBitmap( Point( 24, 8 ), aBitmap );
+ }
+}
+
+/************************************************************************/
+
+void FillAttrLB::Fill( const XBitmapList* pList )
+{
+ long nCount = pList->Count();
+ XBitmapEntry* pEntry;
+ ListBox::SetUpdateMode( FALSE );
+
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pList->GetBitmap( i );
+ aBitmap = pEntry->GetXBitmap().GetBitmap();
+
+ SetVirtualDevice();
+
+ ListBox::InsertEntry( pEntry->GetName(), aVD.GetBitmap( Point( 0, 2 ), Size( 32, 12 ) ) );
+ }
+ ListBox::SetUpdateMode( TRUE );
+}
+
+/************************************************************************/
+
+void FillAttrLB::SelectEntryByList( const XBitmapList* pList, const String& rStr,
+ const Bitmap& /*rBmp*/)
+{
+ long nCount = pList->Count();
+ XBitmapEntry* pEntry;
+ BOOL bFound = FALSE;
+
+ long i;
+ for( i = 0; i < nCount && !bFound; i++ )
+ {
+ pEntry = pList->GetBitmap( i );
+
+ String aStr = pEntry->GetName();
+ // Bitmap aBmp = pEntry->GetBitmap();
+
+ if( rStr == aStr )
+ {
+ bFound = TRUE;
+ }
+ /*
+ if( rStr == aStr && rBmp == aBmp )
+ bFound = TRUE; */
+ }
+ if( bFound )
+ SelectEntryPos( (USHORT) ( i - 1 ) );
+}
+
+/*************************************************************************
+|*
+|* Fuellt die Listbox (vorlaeufig) mit Strings
+|*
+\************************************************************************/
+
+void FillTypeLB::Fill()
+{
+ SetUpdateMode( FALSE );
+ InsertEntry( String( SVX_RES( RID_SVXSTR_INVISIBLE ) ) );
+ InsertEntry( String( SVX_RES( RID_SVXSTR_COLOR ) ) );
+ InsertEntry( String( SVX_RES( RID_SVXSTR_GRADIENT ) ) );
+ InsertEntry( String( SVX_RES( RID_SVXSTR_HATCH ) ) );
+ InsertEntry( String( SVX_RES( RID_SVXSTR_BITMAP ) ) );
+ SetUpdateMode( TRUE );
+}
+
+/*************************************************************************
+|*
+|* Fuellt die Listbox (vorlaeufig) mit Strings
+|*
+\************************************************************************/
+
+void LineLB::Fill( const XDashList* pList )
+{
+ long nCount = pList->Count();
+ XDashEntry* pEntry;
+ SetUpdateMode( FALSE );
+
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pList->GetDash( i );
+ Bitmap* pBitmap = const_cast<XDashList*>(pList)->CreateBitmapForUI( i );
+ if( pBitmap )
+ {
+ InsertEntry( pEntry->GetName(), *pBitmap );
+ delete pBitmap;
+ }
+ else
+ InsertEntry( pEntry->GetName() );
+ }
+ SetUpdateMode( TRUE );
+}
+
+void LineLB::FillStyles()
+{
+ ResMgr& rMgr = DIALOG_MGR();
+
+ // Linienstile
+ Clear();
+ InsertEntry( String( ResId( RID_SVXSTR_INVISIBLE, rMgr ) ) );
+
+ const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
+ Bitmap aBitmap ( SVX_RES ( RID_SVXCTRL_LINECTRL ) );
+ Color aSourceColors[2];
+ Color aDestColors[2];
+
+ aSourceColors[0] = Color( COL_WHITE );
+ aSourceColors[1] = Color( COL_BLACK );
+
+ aDestColors[0] = rStyles.GetFieldColor();
+ aDestColors[1] = rStyles.GetFieldTextColor();
+
+ aBitmap.Replace ( aSourceColors, aDestColors, 2 );
+ Image aSolidLine ( aBitmap );
+ InsertEntry( String( ResId( RID_SVXSTR_SOLID, rMgr ) ), aSolidLine );
+}
+
+/************************************************************************/
+
+void LineLB::Append( XDashEntry* pEntry, Bitmap* pBmp )
+{
+ if( pBmp )
+ InsertEntry( pEntry->GetName(), *pBmp );
+ else
+ InsertEntry( pEntry->GetName() );
+}
+
+/************************************************************************/
+
+void LineLB::Modify( XDashEntry* pEntry, USHORT nPos, Bitmap* pBmp )
+{
+ RemoveEntry( nPos );
+
+ if( pBmp )
+ InsertEntry( pEntry->GetName(), *pBmp, nPos );
+ else
+ InsertEntry( pEntry->GetName(), nPos );
+}
+
+/************************************************************************/
+
+void LineLB::SelectEntryByList( const XDashList* pList, const String& rStr,
+ const XDash& rDash, USHORT nDist )
+{
+ long nCount = pList->Count();
+ XDashEntry* pEntry;
+ BOOL bFound = FALSE;
+ String aStr;
+ XDash aDash;
+
+ long i;
+ for( i = 0; i < nCount && !bFound; i++ )
+ {
+ pEntry = pList->GetDash( i );
+
+ aStr = pEntry->GetName();
+ aDash = pEntry->GetDash();
+
+ if( rStr == aStr && rDash == aDash )
+ bFound = TRUE;
+ }
+ if( bFound )
+ SelectEntryPos( (USHORT) ( i - 1 + nDist ) );
+}
+
+/*************************************************************************
+|*
+|* Fuellt die Listbox (vorlaeufig) mit Strings
+|*
+\************************************************************************/
+
+void LineEndLB::Fill( const XLineEndList* pList, BOOL bStart )
+{
+ long nCount = pList->Count();
+ XLineEndEntry* pEntry;
+ VirtualDevice aVD;
+ SetUpdateMode( FALSE );
+
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pList->GetLineEnd( i );
+ Bitmap* pBitmap = const_cast<XLineEndList*>(pList)->CreateBitmapForUI( i );
+ if( pBitmap )
+ {
+ Size aBmpSize( pBitmap->GetSizePixel() );
+ aVD.SetOutputSizePixel( aBmpSize, FALSE );
+ aVD.DrawBitmap( Point(), *pBitmap );
+ InsertEntry( pEntry->GetName(),
+ aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
+ Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
+
+ delete pBitmap;
+ }
+ else
+ InsertEntry( pEntry->GetName() );
+ }
+ SetUpdateMode( TRUE );
+}
+
+/************************************************************************/
+
+void LineEndLB::Append( XLineEndEntry* pEntry, Bitmap* pBmp,
+ BOOL bStart )
+{
+ if( pBmp )
+ {
+ VirtualDevice aVD;
+ Size aBmpSize( pBmp->GetSizePixel() );
+
+ aVD.SetOutputSizePixel( aBmpSize, FALSE );
+ aVD.DrawBitmap( Point(), *pBmp );
+ InsertEntry( pEntry->GetName(),
+ aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
+ Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ) );
+ }
+ else
+ InsertEntry( pEntry->GetName() );
+}
+
+/************************************************************************/
+
+void LineEndLB::Modify( XLineEndEntry* pEntry, USHORT nPos, Bitmap* pBmp,
+ BOOL bStart )
+{
+ RemoveEntry( nPos );
+
+ if( pBmp )
+ {
+ VirtualDevice aVD;
+ Size aBmpSize( pBmp->GetSizePixel() );
+
+ aVD.SetOutputSizePixel( aBmpSize, FALSE );
+ aVD.DrawBitmap( Point(), *pBmp );
+ InsertEntry( pEntry->GetName(),
+ aVD.GetBitmap( bStart ? Point() : Point( aBmpSize.Width() / 2, 0 ),
+ Size( aBmpSize.Width() / 2, aBmpSize.Height() ) ), nPos );
+ }
+ else
+ InsertEntry( pEntry->GetName(), nPos );
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void SvxPreviewBase::InitSettings(bool bForeground, bool bBackground)
+{
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ if(bForeground)
+ {
+ svtools::ColorConfig aColorConfig;
+ Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
+
+ if(IsControlForeground())
+ {
+ aTextColor = GetControlForeground();
+ }
+
+ getBufferDevice().SetTextColor(aTextColor);
+ }
+
+ if(bBackground)
+ {
+ if(IsControlBackground())
+ {
+ getBufferDevice().SetBackground(GetControlBackground());
+ }
+ else
+ {
+ getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
+ }
+ }
+
+ // do not paint background self, it gets painted buffered
+ SetControlBackground();
+ SetBackground();
+
+ Invalidate();
+}
+
+SvxPreviewBase::SvxPreviewBase( Window* pParent, const ResId& rResId )
+: Control( pParent, rResId ),
+ mpModel( new SdrModel() ),
+ mpBufferDevice( new VirtualDevice(*this) )
+{
+ // Draw the control's border as a flat thin black line.
+ SetBorderStyle(WINDOW_BORDER_MONO);
+ SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
+ SetMapMode(MAP_100TH_MM);
+
+ // init model
+ mpModel->GetItemPool().FreezeIdRanges();
+}
+
+SvxPreviewBase::~SvxPreviewBase()
+{
+ delete mpModel;
+ delete mpBufferDevice;
+}
+
+void SvxPreviewBase::LocalPrePaint()
+{
+ // init BufferDevice
+ if(mpBufferDevice->GetOutputSizePixel() != GetOutputSizePixel())
+ {
+ mpBufferDevice->SetDrawMode(GetDrawMode());
+ mpBufferDevice->SetSettings(GetSettings());
+ mpBufferDevice->SetAntialiasing(GetAntialiasing());
+ mpBufferDevice->SetOutputSizePixel(GetOutputSizePixel());
+ mpBufferDevice->SetMapMode(GetMapMode());
+ }
+
+ mpBufferDevice->Erase();
+}
+
+void SvxPreviewBase::LocalPostPaint()
+{
+ // copy to front (in pixel mode)
+ const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
+ const bool bWasEnabledDst(IsMapModeEnabled());
+ const Point aEmptyPoint;
+
+ mpBufferDevice->EnableMapMode(false);
+ EnableMapMode(false);
+
+ DrawOutDev(
+ aEmptyPoint, GetOutputSizePixel(),
+ aEmptyPoint, GetOutputSizePixel(),
+ *mpBufferDevice);
+
+ mpBufferDevice->EnableMapMode(bWasEnabledSrc);
+ EnableMapMode(bWasEnabledDst);
+}
+
+void SvxPreviewBase::StateChanged(StateChangedType nType)
+{
+ Control::StateChanged(nType);
+
+ if(STATE_CHANGE_CONTROLFOREGROUND == nType)
+ {
+ InitSettings(true, false);
+ }
+ else if(STATE_CHANGE_CONTROLBACKGROUND == nType)
+ {
+ InitSettings(false, true);
+ }
+}
+
+void SvxPreviewBase::DataChanged(const DataChangedEvent& rDCEvt)
+{
+ SetDrawMode(GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR);
+
+ if((DATACHANGED_SETTINGS == rDCEvt.GetType()) && (rDCEvt.GetFlags() & SETTINGS_STYLE))
+ {
+ InitSettings(true, true);
+ }
+ else
+ {
+ Control::DataChanged(rDCEvt);
+ }
+}
+
+/*************************************************************************
+|*
+|* SvxXLinePreview::SvxXLinePreview()
+|*
+*************************************************************************/
+
+SvxXLinePreview::SvxXLinePreview( Window* pParent, const ResId& rResId )
+: SvxPreviewBase( pParent, rResId ),
+ mpLineObjA( 0L ),
+ mpLineObjB( 0L ),
+ mpLineObjC( 0L ),
+ mpGraphic( 0L ),
+ mbWithSymbol( sal_False )
+{
+ const Size aOutputSize(GetOutputSize());
+ InitSettings( TRUE, TRUE );
+
+ const sal_Int32 nDistance(500L);
+ const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
+
+ // create DrawObectA
+ const sal_Int32 aYPosA(aOutputSize.Height() / 2);
+ const basegfx::B2DPoint aPointA1( nDistance, aYPosA);
+ const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
+ basegfx::B2DPolygon aPolygonA;
+ aPolygonA.append(aPointA1);
+ aPolygonA.append(aPointA2);
+ mpLineObjA = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygonA));
+ mpLineObjA->SetModel(&getModel());
+
+ // create DrawObectB
+ const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
+ const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
+ const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance, aYPosB1);
+ const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
+ const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
+ basegfx::B2DPolygon aPolygonB;
+ aPolygonB.append(aPointB1);
+ aPolygonB.append(aPointB2);
+ aPolygonB.append(aPointB3);
+ mpLineObjB = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonB));
+ mpLineObjB->SetModel(&getModel());
+
+ // create DrawObectC
+ const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance, aYPosB1);
+ const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
+ const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
+ basegfx::B2DPolygon aPolygonC;
+ aPolygonC.append(aPointC1);
+ aPolygonC.append(aPointC2);
+ aPolygonC.append(aPointC3);
+ mpLineObjC = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aPolygonC));
+ mpLineObjC->SetModel(&getModel());
+}
+
+SvxXLinePreview::~SvxXLinePreview()
+{
+ SdrObject::Free( mpLineObjA );
+ SdrObject::Free( mpLineObjB );
+ SdrObject::Free( mpLineObjC );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxXLinePreview::SetSymbol(Graphic* p,const Size& s)
+{
+ mpGraphic = p;
+ maSymbolSize = s;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxXLinePreview::ResizeSymbol(const Size& s)
+{
+ if ( s != maSymbolSize )
+ {
+ maSymbolSize = s;
+ Invalidate();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxXLinePreview::SetLineAttributes(const SfxItemSet& rItemSet)
+{
+ // Set ItemSet at objects
+ mpLineObjA->SetMergedItemSet(rItemSet);
+
+ // At line joints, do not use arrows
+ SfxItemSet aTempSet(rItemSet);
+ aTempSet.ClearItem(XATTR_LINESTART);
+ aTempSet.ClearItem(XATTR_LINEEND);
+
+ mpLineObjB->SetMergedItemSet(aTempSet);
+ mpLineObjC->SetMergedItemSet(aTempSet);
+}
+
+// -----------------------------------------------------------------------
+
+void SvxXLinePreview::Paint( const Rectangle& )
+{
+ LocalPrePaint();
+
+ // paint objects to buffer device
+ sdr::contact::SdrObjectVector aObjectVector;
+ aObjectVector.push_back(mpLineObjA);
+ aObjectVector.push_back(mpLineObjB);
+ aObjectVector.push_back(mpLineObjC);
+
+ sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ // do processing
+ aPainter.ProcessDisplay(aDisplayInfo);
+
+ if ( mbWithSymbol && mpGraphic )
+ {
+ const Size aOutputSize(GetOutputSize());
+ Point aPos = Point( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
+ aPos.X() -= maSymbolSize.Width() / 2;
+ aPos.Y() -= maSymbolSize.Height() / 2;
+ mpGraphic->Draw( &getBufferDevice(), aPos, maSymbolSize );
+ }
+
+ LocalPostPaint();
+}
+
+/*************************************************************************
+|*
+|* SvxXRectPreview::SvxXRectPreview()
+|*
+*************************************************************************/
+
+SvxXRectPreview::SvxXRectPreview( Window* pParent, const ResId& rResId )
+: SvxPreviewBase( pParent, rResId ),
+ mpRectangleObject(0)
+{
+ InitSettings(true, true);
+
+ // create RectangleObject
+ const Rectangle aObjectSize(Point(), GetOutputSize());
+ mpRectangleObject = new SdrRectObj(aObjectSize);
+ mpRectangleObject->SetModel(&getModel());
+}
+
+SvxXRectPreview::~SvxXRectPreview()
+{
+ SdrObject::Free(mpRectangleObject);
+}
+
+void SvxXRectPreview::SetAttributes(const SfxItemSet& rItemSet)
+{
+ mpRectangleObject->SetMergedItemSet(rItemSet, true);
+ mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
+}
+
+void SvxXRectPreview::Paint( const Rectangle& )
+{
+ LocalPrePaint();
+
+ sdr::contact::SdrObjectVector aObjectVector;
+
+ aObjectVector.push_back(mpRectangleObject);
+
+ sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ aPainter.ProcessDisplay(aDisplayInfo);
+
+ LocalPostPaint();
+}
+
+/*************************************************************************
+|*
+|* SvxXShadowPreview::SvxXShadowPreview()
+|*
+*************************************************************************/
+
+SvxXShadowPreview::SvxXShadowPreview( Window* pParent, const ResId& rResId )
+: SvxPreviewBase( pParent, rResId ),
+ mpRectangleObject(0),
+ mpRectangleShadow(0)
+{
+ InitSettings(true, true);
+
+ // prepare size
+ Size aSize = GetOutputSize();
+ aSize.Width() = aSize.Width() / 3;
+ aSize.Height() = aSize.Height() / 3;
+
+ // create RectangleObject
+ const Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
+ mpRectangleObject = new SdrRectObj(aObjectSize);
+ mpRectangleObject->SetModel(&getModel());
+
+ // create ShadowObject
+ const Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
+ mpRectangleShadow = new SdrRectObj(aShadowSize);
+ mpRectangleShadow->SetModel(&getModel());
+}
+
+SvxXShadowPreview::~SvxXShadowPreview()
+{
+ SdrObject::Free(mpRectangleObject);
+ SdrObject::Free(mpRectangleShadow);
+}
+
+void SvxXShadowPreview::SetRectangleAttributes(const SfxItemSet& rItemSet)
+{
+ mpRectangleObject->SetMergedItemSet(rItemSet, true);
+ mpRectangleObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
+}
+
+void SvxXShadowPreview::SetShadowAttributes(const SfxItemSet& rItemSet)
+{
+ mpRectangleShadow->SetMergedItemSet(rItemSet, true);
+ mpRectangleShadow->SetMergedItem(XLineStyleItem(XLINE_NONE));
+}
+
+void SvxXShadowPreview::SetShadowPosition(const Point& rPos)
+{
+ Rectangle aObjectPosition(mpRectangleObject->GetSnapRect());
+ aObjectPosition.Move(rPos.X(), rPos.Y());
+ mpRectangleShadow->SetSnapRect(aObjectPosition);
+}
+
+void SvxXShadowPreview::Paint( const Rectangle& )
+{
+ LocalPrePaint();
+
+ sdr::contact::SdrObjectVector aObjectVector;
+
+ aObjectVector.push_back(mpRectangleShadow);
+ aObjectVector.push_back(mpRectangleObject);
+
+ sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, 0);
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ aPainter.ProcessDisplay(aDisplayInfo);
+
+ LocalPostPaint();
+}
+
+// -----------------------------------------------------------------------
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/dlgctrl.src b/svx/source/dialog/dlgctrl.src
new file mode 100644
index 000000000000..e5bd607efdf4
--- /dev/null
+++ b/svx/source/dialog/dlgctrl.src
@@ -0,0 +1,34 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+
+Bitmap RID_SVXCTRL_RECTBTNS
+{
+ File = "rectbtns.bmp" ;
+};
+
diff --git a/svx/source/dialog/dlgutil.cxx b/svx/source/dialog/dlgutil.cxx
new file mode 100644
index 000000000000..02f182940904
--- /dev/null
+++ b/svx/source/dialog/dlgutil.cxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include "dlgutil.hxx"
+#include <svl/itemset.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/module.hxx>
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objsh.hxx>
+
+// -----------------------------------------------------------------------
+
+FieldUnit GetModuleFieldUnit( const SfxItemSet& rSet )
+{
+ FieldUnit eUnit = FUNIT_INCH;
+ const SfxPoolItem* pItem = NULL;
+ if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC, FALSE, &pItem ) )
+ eUnit = (FieldUnit)( (const SfxUInt16Item*)pItem )->GetValue();
+ else
+ {
+ DBG_ERROR("Using fallback for field unit - field unit should be provided in ItemSet");
+ return SfxModule::GetCurrentFieldUnit();
+ }
+
+ return eUnit;
+}
+
+BOOL GetApplyCharUnit( const SfxItemSet& rSet )
+{
+ BOOL bUseCharUnit = FALSE;
+ const SfxPoolItem* pItem = NULL;
+ if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_APPLYCHARUNIT, FALSE, &pItem ) )
+ bUseCharUnit = (BOOL)( (const SfxBoolItem*)pItem )->GetValue();
+ else
+ {
+ // FIXME - this might be wrong, cf. the DEV300 changes in GetModuleFieldUnit()
+ SfxViewFrame* pFrame = SfxViewFrame::Current();
+ SfxObjectShell* pSh = NULL;
+ if ( pFrame )
+ pSh = pFrame->GetObjectShell();
+ if ( pSh ) // #93209# the object shell is not always available during reload
+ {
+ SfxModule* pModule = pSh->GetModule();
+ if ( pModule )
+ {
+ pItem = pModule->GetItem( SID_ATTR_APPLYCHARUNIT );
+ if ( pItem )
+ bUseCharUnit = (BOOL)( (SfxBoolItem*)pItem )->GetValue();
+ }
+ else
+ {
+ DBG_ERRORFILE( "GetApplyCharUnit(): no module found" );
+ }
+ }
+ }
+ return bUseCharUnit;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
new file mode 100644
index 000000000000..67de10233fd4
--- /dev/null
+++ b/svx/source/dialog/docrecovery.cxx
@@ -0,0 +1,2182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include "docrecovery.hxx"
+#include "docrecovery.hrc"
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/configurationhelper.hxx>
+#include <svtools/imagemgr.hxx>
+#include <svtools/xtextedt.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <vcl/scrbar.hxx>
+
+#include <toolkit/unohlp.hxx>
+
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/ui/dialogs/XFolderPicker.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <osl/file.hxx>
+#include <osl/security.hxx>
+#include <rtl/bootstrap.hxx>
+#include <unotools/pathoptions.hxx>
+#include <unotools/localfilehelper.hxx>
+
+#define RET_BACK 100
+
+//===============================================
+// namespace
+namespace svx{
+ namespace DocRecovery{
+
+namespace css = ::com::sun::star;
+
+using namespace ::rtl;
+using namespace ::osl;
+
+//===============================================
+TabDialog4Recovery::TabDialog4Recovery(Window* pParent)
+ : TabDialog (pParent, SVX_RES( RID_SVX_TABDLG_DOCRECOVERY ))
+ , m_pActualPage(m_lTabPages.begin() )
+{
+}
+
+//===============================================
+TabDialog4Recovery::~TabDialog4Recovery()
+{
+ m_lTabPages.clear();
+}
+
+//===============================================
+void TabDialog4Recovery::addTabPage(IExtendedTabPage* pPage)
+{
+ if (pPage)
+ m_lTabPages.push_back(pPage);
+}
+
+//===============================================
+short TabDialog4Recovery::Execute()
+{
+ ::SolarMutexGuard aLock;
+
+ Show();
+ m_pActualPage = m_lTabPages.begin();
+ while(sal_True)
+ {
+ IExtendedTabPage* pPage = *m_pActualPage;
+ SetViewWindow(pPage);
+ pPage->Show();
+ pPage->setDefButton();
+ short nRet = pPage->execute();
+ pPage->Hide();
+
+ switch(nRet)
+ {
+ case DLG_RET_OK :
+ {
+ ++m_pActualPage;
+ if (m_pActualPage == m_lTabPages.end())
+ return nRet;
+ }
+ break;
+
+ case DLG_RET_BACK :
+ {
+ if (m_pActualPage != m_lTabPages.begin())
+ --m_pActualPage;
+ }
+ break;
+
+ case DLG_RET_UNKNOWN :
+ case DLG_RET_CANCEL :
+ case DLG_RET_OK_AUTOLUNCH :
+ return nRet;
+ }
+ }
+}
+
+//===============================================
+RecoveryCore::RecoveryCore(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
+ sal_Bool bUsedForSaving)
+ : m_xSMGR ( xSMGR )
+ , m_pListener ( 0 )
+ , m_bListenForSaving(bUsedForSaving)
+{
+ impl_startListening();
+}
+
+//===============================================
+RecoveryCore::~RecoveryCore()
+{
+ impl_stopListening();
+}
+
+//===============================================
+css::uno::Reference< css::lang::XMultiServiceFactory > RecoveryCore::getSMGR()
+{
+ return m_xSMGR;
+}
+
+//===============================================
+TURLList* RecoveryCore::getURLListAccess()
+{
+ return &m_lURLs;
+}
+
+//===============================================
+sal_Bool RecoveryCore::existsBrokenTempEntries()
+{
+ TURLList::const_iterator pIt;
+ for ( pIt = m_lURLs.begin();
+ pIt != m_lURLs.end() ;
+ ++pIt )
+ {
+ const TURLInfo& rInfo = *pIt;
+ if (RecoveryCore::isBrokenTempEntry(rInfo))
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//===============================================
+sal_Bool RecoveryCore::existsNonRecoveredEntries()
+{
+ TURLList::const_iterator pIt;
+ for ( pIt = m_lURLs.begin();
+ pIt != m_lURLs.end() ;
+ ++pIt )
+ {
+ const TURLInfo& rInfo = *pIt;
+ if (rInfo.RecoveryState == E_NOT_RECOVERED_YET)
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//===============================================
+sal_Bool RecoveryCore::isBrokenTempEntry(const TURLInfo& rInfo)
+{
+ if (!rInfo.TempURL.getLength())
+ return sal_False;
+
+ // Note: If the original files was recovery ... but a temp file
+ // exists ... an error inside the temp file exists!
+ if (
+ !(rInfo.RecoveryState == E_RECOVERY_FAILED ) &&
+ !(rInfo.RecoveryState == E_ORIGINAL_DOCUMENT_RECOVERED)
+ )
+ return sal_False;
+
+ return sal_True;
+}
+
+//===============================================
+void RecoveryCore::saveBrokenTempEntries(const ::rtl::OUString& sPath)
+{
+ if (!sPath.getLength())
+ return;
+
+ if (!m_xRealCore.is())
+ return;
+
+ // prepare all needed parameters for the following dispatch() request.
+ css::util::URL aCopyURL = impl_getParsedURL(RECOVERY_CMD_DO_ENTRY_BACKUP);
+ css::uno::Sequence< css::beans::PropertyValue > lCopyArgs(3);
+ lCopyArgs[0].Name = PROP_DISPATCHASYNCHRON;
+ lCopyArgs[0].Value <<= sal_False;
+ lCopyArgs[1].Name = PROP_SAVEPATH;
+ lCopyArgs[1].Value <<= sPath;
+ lCopyArgs[2].Name = PROP_ENTRYID;
+ // lCopyArgs[2].Value will be changed during next loop ...
+
+ // work on a copied list only ...
+ // Reason: We will get notifications from the core for every
+ // changed or removed element. And that will change our m_lURLs list.
+ // That's not a good idea, if we use a stl iterator inbetween .-)
+ TURLList lURLs = m_lURLs;
+ TURLList::const_iterator pIt;
+ for ( pIt = lURLs.begin();
+ pIt != lURLs.end() ;
+ ++pIt )
+ {
+ const TURLInfo& rInfo = *pIt;
+ if (!RecoveryCore::isBrokenTempEntry(rInfo))
+ continue;
+
+ lCopyArgs[2].Value <<= rInfo.ID;
+ m_xRealCore->dispatch(aCopyURL, lCopyArgs);
+ }
+}
+
+//===============================================
+void RecoveryCore::saveAllTempEntries(const ::rtl::OUString& sPath)
+{
+ if (!sPath.getLength())
+ return;
+
+ if (!m_xRealCore.is())
+ return;
+
+ // prepare all needed parameters for the following dispatch() request.
+ css::util::URL aCopyURL = impl_getParsedURL(RECOVERY_CMD_DO_ENTRY_BACKUP);
+ css::uno::Sequence< css::beans::PropertyValue > lCopyArgs(3);
+ lCopyArgs[0].Name = PROP_DISPATCHASYNCHRON;
+ lCopyArgs[0].Value <<= sal_False;
+ lCopyArgs[1].Name = PROP_SAVEPATH;
+ lCopyArgs[1].Value <<= sPath;
+ lCopyArgs[2].Name = PROP_ENTRYID;
+ // lCopyArgs[2].Value will be changed during next loop ...
+
+ // work on a copied list only ...
+ // Reason: We will get notifications from the core for every
+ // changed or removed element. And that will change our m_lURLs list.
+ // That's not a good idea, if we use a stl iterator inbetween .-)
+ TURLList lURLs = m_lURLs;
+ TURLList::const_iterator pIt;
+ for ( pIt = lURLs.begin();
+ pIt != lURLs.end() ;
+ ++pIt )
+ {
+ const TURLInfo& rInfo = *pIt;
+ if (!rInfo.TempURL.getLength())
+ continue;
+
+ lCopyArgs[2].Value <<= rInfo.ID;
+ m_xRealCore->dispatch(aCopyURL, lCopyArgs);
+ }
+}
+
+//===============================================
+void RecoveryCore::forgetBrokenTempEntries()
+{
+ if (!m_xRealCore.is())
+ return;
+
+ css::util::URL aRemoveURL = impl_getParsedURL(RECOVERY_CMD_DO_ENTRY_CLEANUP);
+ css::uno::Sequence< css::beans::PropertyValue > lRemoveArgs(2);
+ lRemoveArgs[0].Name = PROP_DISPATCHASYNCHRON;
+ lRemoveArgs[0].Value <<= sal_False;
+ lRemoveArgs[1].Name = PROP_ENTRYID;
+ // lRemoveArgs[1].Value will be changed during next loop ...
+
+ // work on a copied list only ...
+ // Reason: We will get notifications from the core for every
+ // changed or removed element. And that will change our m_lURLs list.
+ // That's not a good idea, if we use a stl iterator inbetween .-)
+ TURLList lURLs = m_lURLs;
+ TURLList::const_iterator pIt;
+ for ( pIt = lURLs.begin();
+ pIt != lURLs.end() ;
+ ++pIt )
+ {
+ const TURLInfo& rInfo = *pIt;
+ if (!RecoveryCore::isBrokenTempEntry(rInfo))
+ continue;
+
+ lRemoveArgs[1].Value <<= rInfo.ID;
+ m_xRealCore->dispatch(aRemoveURL, lRemoveArgs);
+ }
+}
+
+//===============================================
+void RecoveryCore::forgetAllRecoveryEntries()
+{
+ if (!m_xRealCore.is())
+ return;
+
+ css::util::URL aRemoveURL = impl_getParsedURL(RECOVERY_CMD_DO_ENTRY_CLEANUP);
+ css::uno::Sequence< css::beans::PropertyValue > lRemoveArgs(2);
+ lRemoveArgs[0].Name = PROP_DISPATCHASYNCHRON;
+ lRemoveArgs[0].Value <<= sal_False;
+ lRemoveArgs[1].Name = PROP_ENTRYID;
+ // lRemoveArgs[1].Value will be changed during next loop ...
+
+ // work on a copied list only ...
+ // Reason: We will get notifications from the core for every
+ // changed or removed element. And that will change our m_lURLs list.
+ // That's not a good idea, if we use a stl iterator inbetween .-)
+ TURLList lURLs = m_lURLs;
+ TURLList::const_iterator pIt;
+ for ( pIt = lURLs.begin();
+ pIt != lURLs.end() ;
+ ++pIt )
+ {
+ const TURLInfo& rInfo = *pIt;
+ lRemoveArgs[1].Value <<= rInfo.ID;
+ m_xRealCore->dispatch(aRemoveURL, lRemoveArgs);
+ }
+}
+
+//===============================================
+void RecoveryCore::forgetBrokenRecoveryEntries()
+{
+ if (!m_xRealCore.is())
+ return;
+
+ css::util::URL aRemoveURL = impl_getParsedURL(RECOVERY_CMD_DO_ENTRY_CLEANUP);
+ css::uno::Sequence< css::beans::PropertyValue > lRemoveArgs(2);
+ lRemoveArgs[0].Name = PROP_DISPATCHASYNCHRON;
+ lRemoveArgs[0].Value <<= sal_False;
+ lRemoveArgs[1].Name = PROP_ENTRYID;
+ // lRemoveArgs[1].Value will be changed during next loop ...
+
+ // work on a copied list only ...
+ // Reason: We will get notifications from the core for every
+ // changed or removed element. And that will change our m_lURLs list.
+ // That's not a good idea, if we use a stl iterator inbetween .-)
+ TURLList lURLs = m_lURLs;
+ TURLList::const_iterator pIt;
+ for ( pIt = lURLs.begin();
+ pIt != lURLs.end() ;
+ ++pIt )
+ {
+ const TURLInfo& rInfo = *pIt;
+ if (!RecoveryCore::isBrokenTempEntry(rInfo))
+ continue;
+
+ lRemoveArgs[1].Value <<= rInfo.ID;
+ m_xRealCore->dispatch(aRemoveURL, lRemoveArgs);
+ }
+}
+
+//===============================================
+void RecoveryCore::setProgressHandler(const css::uno::Reference< css::task::XStatusIndicator >& xProgress)
+{
+ m_xProgress = xProgress;
+}
+
+//===============================================
+void RecoveryCore::setUpdateListener(IRecoveryUpdateListener* pListener)
+{
+ m_pListener = pListener;
+}
+
+//===============================================
+void RecoveryCore::doEmergencySavePrepare()
+{
+ if (!m_xRealCore.is())
+ return;
+
+ css::util::URL aURL = impl_getParsedURL(RECOVERY_CMD_DO_PREPARE_EMERGENCY_SAVE);
+
+ css::uno::Sequence< css::beans::PropertyValue > lArgs(1);
+ lArgs[0].Name = PROP_DISPATCHASYNCHRON;
+ lArgs[0].Value <<= sal_False;
+
+ m_xRealCore->dispatch(aURL, lArgs);
+}
+
+//===============================================
+void RecoveryCore::doEmergencySave()
+{
+ if (!m_xRealCore.is())
+ return;
+
+ css::util::URL aURL = impl_getParsedURL(RECOVERY_CMD_DO_EMERGENCY_SAVE);
+
+ css::uno::Sequence< css::beans::PropertyValue > lArgs(2);
+ lArgs[0].Name = PROP_STATUSINDICATOR;
+ lArgs[0].Value <<= m_xProgress;
+ lArgs[1].Name = PROP_DISPATCHASYNCHRON;
+ lArgs[1].Value <<= sal_True;
+
+ m_xRealCore->dispatch(aURL, lArgs);
+}
+
+//===============================================
+void RecoveryCore::doRecovery()
+{
+ if (!m_xRealCore.is())
+ return;
+
+ css::util::URL aURL = impl_getParsedURL(RECOVERY_CMD_DO_RECOVERY);
+
+ css::uno::Sequence< css::beans::PropertyValue > lArgs(2);
+ lArgs[0].Name = PROP_STATUSINDICATOR;
+ lArgs[0].Value <<= m_xProgress;
+ lArgs[1].Name = PROP_DISPATCHASYNCHRON;
+ lArgs[1].Value <<= sal_True;
+
+ m_xRealCore->dispatch(aURL, lArgs);
+}
+
+//===============================================
+ERecoveryState RecoveryCore::mapDocState2RecoverState(sal_Int32 eDocState)
+{
+ // ???
+ ERecoveryState eRecState = E_NOT_RECOVERED_YET;
+
+ /* Attention:
+ Some of the following states can occure at the
+ same time. So we have to check for the "worst case" first!
+
+ DAMAGED -> INCOMPLETE -> HANDLED
+ */
+
+ // running ...
+ if (
+ ((eDocState & E_TRY_LOAD_BACKUP ) == E_TRY_LOAD_BACKUP ) ||
+ ((eDocState & E_TRY_LOAD_ORIGINAL) == E_TRY_LOAD_ORIGINAL)
+ )
+ eRecState = E_RECOVERY_IS_IN_PROGRESS;
+ // red
+ else
+ if ((eDocState & E_DAMAGED) == E_DAMAGED)
+ eRecState = E_RECOVERY_FAILED;
+ // yellow
+ else
+ if ((eDocState & E_INCOMPLETE) == E_INCOMPLETE)
+ eRecState = E_ORIGINAL_DOCUMENT_RECOVERED;
+ // green
+ else
+ if ((eDocState & E_SUCCEDED) == E_SUCCEDED)
+ eRecState = E_SUCCESSFULLY_RECOVERED;
+
+ return eRecState;
+}
+
+//===============================================
+void SAL_CALL RecoveryCore::statusChanged(const css::frame::FeatureStateEvent& aEvent)
+ throw(css::uno::RuntimeException)
+{
+ // a) special notification about start/stop async dispatch!
+ // FeatureDescriptor = "start" || "stop"
+ if (aEvent.FeatureDescriptor.equals(RECOVERY_OPERATIONSTATE_START))
+ {
+ if (m_pListener)
+ m_pListener->start();
+ return;
+ }
+
+ if (aEvent.FeatureDescriptor.equals(RECOVERY_OPERATIONSTATE_STOP))
+ {
+ if (m_pListener)
+ m_pListener->end();
+ return;
+ }
+
+ // b) normal notification about changed items
+ // FeatureDescriptor = "Update"
+ // State = Lits of informations [seq< NamedValue >]
+ if (! aEvent.FeatureDescriptor.equals(RECOVERY_OPERATIONSTATE_UPDATE))
+ return;
+
+ ::comphelper::SequenceAsHashMap lInfo(aEvent.State);
+ TURLInfo aNew;
+
+ aNew.ID = lInfo.getUnpackedValueOrDefault(STATEPROP_ID , (sal_Int32)0 );
+ aNew.DocState = lInfo.getUnpackedValueOrDefault(STATEPROP_STATE , (sal_Int32)0 );
+ aNew.OrgURL = lInfo.getUnpackedValueOrDefault(STATEPROP_ORGURL , ::rtl::OUString());
+ aNew.TempURL = lInfo.getUnpackedValueOrDefault(STATEPROP_TEMPURL , ::rtl::OUString());
+ aNew.FactoryURL = lInfo.getUnpackedValueOrDefault(STATEPROP_FACTORYURL , ::rtl::OUString());
+ aNew.TemplateURL = lInfo.getUnpackedValueOrDefault(STATEPROP_TEMPLATEURL, ::rtl::OUString());
+ aNew.DisplayName = lInfo.getUnpackedValueOrDefault(STATEPROP_TITLE , ::rtl::OUString());
+ aNew.Module = lInfo.getUnpackedValueOrDefault(STATEPROP_MODULE , ::rtl::OUString());
+
+ // search for already existing items and update her nState value ...
+ TURLList::iterator pIt;
+ for ( pIt = m_lURLs.begin();
+ pIt != m_lURLs.end() ;
+ ++pIt )
+ {
+ TURLInfo& aOld = *pIt;
+ if (aOld.ID == aNew.ID)
+ {
+ // change existing
+ aOld.DocState = aNew.DocState;
+ aOld.RecoveryState = RecoveryCore::mapDocState2RecoverState(aOld.DocState);
+ if (m_pListener)
+ {
+ m_pListener->updateItems();
+ m_pListener->stepNext(&aOld);
+ }
+ return;
+ }
+ }
+
+ // append as new one
+ // TODO think about mmatching Module name to a corresponding icon
+ String sURL = aNew.OrgURL;
+ if (!sURL.Len())
+ sURL = aNew.FactoryURL;
+ if (!sURL.Len())
+ sURL = aNew.TempURL;
+ if (!sURL.Len())
+ sURL = aNew.TemplateURL;
+ INetURLObject aURL(sURL);
+ aNew.StandardImage = SvFileInformationManager::GetFileImage(aURL, false, false);
+ aNew.HCImage = SvFileInformationManager::GetFileImage(aURL, false, true );
+
+ /* set the right UI state for this item to NOT_RECOVERED_YET ... because nDocState shows the state of
+ the last emergency save operation before and is interessting for the used recovery core service only ...
+ for now! But if there is a further notification for this item (see lines above!) we must
+ map the doc state to an UI state. */
+ aNew.RecoveryState = E_NOT_RECOVERED_YET;
+
+ // patch DisplayName! Because the document title contain more then the file name ...
+ sal_Int32 i = aNew.DisplayName.indexOf(::rtl::OUString::createFromAscii(" - "));
+ if (i > 0)
+ aNew.DisplayName = aNew.DisplayName.copy(0, i);
+
+ m_lURLs.push_back(aNew);
+
+ if (m_pListener)
+ m_pListener->updateItems();
+}
+
+//===============================================
+void SAL_CALL RecoveryCore::disposing(const css::lang::EventObject& /*aEvent*/)
+ throw(css::uno::RuntimeException)
+{
+ m_xRealCore.clear();
+}
+
+//===============================================
+void RecoveryCore::impl_startListening()
+{
+ // listening already initialized ?
+ if (m_xRealCore.is())
+ return;
+ m_xRealCore = css::uno::Reference< css::frame::XDispatch >(m_xSMGR->createInstance(SERVICENAME_RECOVERYCORE), css::uno::UNO_QUERY_THROW);
+
+ css::util::URL aURL;
+ if (m_bListenForSaving)
+ aURL.Complete = RECOVERY_CMD_DO_EMERGENCY_SAVE;
+ else
+ aURL.Complete = RECOVERY_CMD_DO_RECOVERY;
+ css::uno::Reference< css::util::XURLTransformer > xParser(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY_THROW);
+ xParser->parseStrict(aURL);
+
+ /* Note: addStatusListener() call us synchronous back ... so we
+ will get the complete list of currently open documents! */
+ m_xRealCore->addStatusListener(static_cast< css::frame::XStatusListener* >(this), aURL);
+}
+
+//===============================================
+void RecoveryCore::impl_stopListening()
+{
+ // Ignore it, if this instance doesnt listen currently
+ if (!m_xRealCore.is())
+ return;
+
+ css::util::URL aURL;
+ if (m_bListenForSaving)
+ aURL.Complete = RECOVERY_CMD_DO_EMERGENCY_SAVE;
+ else
+ aURL.Complete = RECOVERY_CMD_DO_RECOVERY;
+ css::uno::Reference< css::util::XURLTransformer > xParser(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY_THROW);
+ xParser->parseStrict(aURL);
+
+ m_xRealCore->removeStatusListener(static_cast< css::frame::XStatusListener* >(this), aURL);
+ m_xRealCore.clear();
+}
+
+//===============================================
+css::util::URL RecoveryCore::impl_getParsedURL(const ::rtl::OUString& sURL)
+{
+ css::util::URL aURL;
+ aURL.Complete = sURL;
+
+ css::uno::Reference< css::util::XURLTransformer > xParser(m_xSMGR->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY_THROW);
+ xParser->parseStrict(aURL);
+
+ return aURL;
+}
+
+//===============================================
+PluginProgressWindow::PluginProgressWindow( Window* pParent ,
+ const css::uno::Reference< css::lang::XComponent >& xProgress)
+ : Window (pParent )
+ , m_xProgress(xProgress)
+{
+ Show();
+ Size aParentSize = pParent->GetSizePixel();
+ // align the progressbar to its parent
+ SetPosSizePixel( -9, 0, aParentSize.Width() + 15, aParentSize.Height() - 4 );
+}
+
+//===============================================
+PluginProgressWindow::~PluginProgressWindow()
+{
+ if (m_xProgress.is())
+ m_xProgress->dispose();
+}
+
+//===============================================
+PluginProgress::PluginProgress( Window* pParent,
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR )
+{
+ m_pPlugProgressWindow = new PluginProgressWindow(pParent, static_cast< css::lang::XComponent* >(this));
+ css::uno::Reference< css::awt::XWindow > xProgressWindow = VCLUnoHelper::GetInterface(m_pPlugProgressWindow);
+ m_xProgressFactory = css::uno::Reference< css::task::XStatusIndicatorFactory >(xSMGR->createInstance(SERVICENAME_PROGRESSFACTORY), css::uno::UNO_QUERY_THROW);
+ css::uno::Reference< css::lang::XInitialization > xInit(m_xProgressFactory, css::uno::UNO_QUERY_THROW);
+
+ css::uno::Sequence< css::uno::Any > lArgs(2);
+ css::beans::NamedValue aProp;
+ aProp.Name = PROP_PARENTWINDOW;
+ aProp.Value <<= xProgressWindow;
+ lArgs[0] <<= aProp;
+ aProp.Name = PROP_ALLOWPARENTSHOW;
+ aProp.Value <<= sal_True;
+ lArgs[1] <<= aProp;
+
+ xInit->initialize(lArgs);
+
+ m_xProgress = m_xProgressFactory->createStatusIndicator();
+}
+
+//===============================================
+PluginProgress::~PluginProgress()
+{
+}
+
+//===============================================
+Window* PluginProgress::getPlugWindow()
+{
+ return m_pPlugProgressWindow;
+}
+
+//===============================================
+void SAL_CALL PluginProgress::dispose()
+ throw(css::uno::RuntimeException)
+{
+ // m_pPluginProgressWindow was deleted ...
+ // So the internal pointer of this progress
+ // weill be dead!
+ m_xProgress.clear();
+}
+
+//===============================================
+void SAL_CALL PluginProgress::addEventListener(const css::uno::Reference< css::lang::XEventListener >& )
+ throw(css::uno::RuntimeException)
+{
+}
+
+//===============================================
+void SAL_CALL PluginProgress::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& )
+ throw(css::uno::RuntimeException)
+{
+}
+
+//===============================================
+void SAL_CALL PluginProgress::start(const ::rtl::OUString&,
+ sal_Int32 nRange)
+ throw(css::uno::RuntimeException)
+{
+ if (m_xProgress.is())
+ m_xProgress->start(::rtl::OUString(), nRange);
+}
+
+//===============================================
+void SAL_CALL PluginProgress::end()
+ throw(css::uno::RuntimeException)
+{
+ if (m_xProgress.is())
+ m_xProgress->end();
+}
+
+//===============================================
+void SAL_CALL PluginProgress::setText(const ::rtl::OUString& sText)
+ throw(css::uno::RuntimeException)
+{
+ if (m_xProgress.is())
+ m_xProgress->setText(sText);
+}
+
+//===============================================
+void SAL_CALL PluginProgress::setValue(sal_Int32 nValue)
+ throw(css::uno::RuntimeException)
+{
+ if (m_xProgress.is())
+ m_xProgress->setValue(nValue);
+}
+
+//===============================================
+void SAL_CALL PluginProgress::reset()
+ throw(css::uno::RuntimeException)
+{
+ if (m_xProgress.is())
+ m_xProgress->reset();
+}
+
+//===============================================
+SaveDialog::SaveDialog(Window* pParent,
+ RecoveryCore* pCore )
+ : IExtendedTabPage( pParent, SVX_RES( RID_SVXPAGE_DOCRECOVERY_SAVE ) )
+ , m_aTitleWin ( this , SVX_RES ( WIN_SAVE_TITLE ) )
+ , m_aTitleFT ( this , SVX_RES ( FT_SAVE_TITLE ) )
+ , m_aTitleFL ( this , SVX_RES ( FL_SAVE_TITLE ) )
+ , m_aDescrFT ( this , SVX_RES ( FT_SAVE_DESCR ) )
+ , m_aFileListFT ( this , SVX_RES ( FT_SAVE_FILELIST ) )
+ , m_aFileListLB ( this , SVX_RES ( LB_SAVE_FILELIST ) )
+ , m_aBottomFL ( this , SVX_RES ( FL_SAVE_BOTTOM ) )
+ , m_aOkBtn ( this , SVX_RES ( BT_SAVE_OK ) )
+ , m_pCore ( pCore )
+{
+ FreeResource();
+
+ // Prepare the office for the following crash save step.
+ // E.g. hide all open widows so the user cant influence our
+ // operation .-)
+ m_pCore->doEmergencySavePrepare();
+
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ Wallpaper aBackground(rStyleSettings.GetWindowColor());
+ m_aTitleWin.SetBackground(aBackground);
+ m_aTitleFT.SetBackground (aBackground);
+
+ Font aFont(m_aTitleFT.GetFont());
+ aFont.SetWeight(WEIGHT_BOLD);
+ m_aTitleFT.SetFont(aFont);
+
+ m_aOkBtn.SetClickHdl( LINK( this, SaveDialog, OKButtonHdl ) );
+// m_aFileListLB.EnableInput( sal_False );
+ m_aFileListLB.SetControlBackground( rStyleSettings.GetDialogColor() );
+
+ // fill listbox with current open documents
+ m_aFileListLB.Clear();
+
+ TURLList* pURLs = m_pCore->getURLListAccess();
+ TURLList::const_iterator pIt;
+
+ for ( pIt = pURLs->begin();
+ pIt != pURLs->end() ;
+ ++pIt )
+ {
+ const TURLInfo& rInfo = *pIt;
+ m_aFileListLB.InsertEntry( rInfo.DisplayName, rInfo.StandardImage );
+ }
+}
+
+//===============================================
+SaveDialog::~SaveDialog()
+{
+}
+
+//===============================================
+IMPL_LINK( SaveDialog, OKButtonHdl, void*, EMPTYARG )
+{
+ m_nResult = DLG_RET_OK;
+ return 0;
+}
+
+//===============================================
+short SaveDialog::execute()
+{
+ ::SolarMutexGuard aLock;
+
+ // wait for user input "OK"
+ m_nResult = DLG_RET_UNKNOWN;
+ while(m_nResult == DLG_RET_UNKNOWN)
+ Application::Yield();
+
+ // start crash-save with progress
+ if (m_nResult == DLG_RET_OK)
+ {
+ SaveProgressDialog* pProgress = new SaveProgressDialog(this, m_pCore);
+ m_nResult = pProgress->Execute();
+ delete pProgress;
+ }
+ // if "CANCEL" => return "CANCEL"
+ // if "OK" => "AUTOLUNCH" always !
+ if (m_nResult == DLG_RET_OK)
+ m_nResult = DLG_RET_OK_AUTOLUNCH;
+
+ return m_nResult;
+}
+
+//===============================================
+void SaveDialog::setDefButton()
+{
+ m_aOkBtn.GrabFocus();
+}
+
+//===============================================
+SaveProgressDialog::SaveProgressDialog(Window* pParent,
+ RecoveryCore* pCore )
+ : ModalDialog ( pParent , SVX_RES( RID_SVX_MDLG_DOCRECOVERY_PROGR ) )
+ , m_aHintFT ( this , SVX_RES ( FT_SAVEPROGR_HINT ) )
+ , m_aProgrFT ( this , SVX_RES ( FT_SAVEPROGR_PROGR ) )
+ , m_aProgrParent( this , SVX_RES ( WIN_SAVEPROGR_PROGR ) )
+ , m_pCore ( pCore )
+{
+ FreeResource();
+ PluginProgress* pProgress = new PluginProgress( &m_aProgrParent, pCore->getSMGR() );
+ m_xProgress = css::uno::Reference< css::task::XStatusIndicator >(static_cast< css::task::XStatusIndicator* >(pProgress), css::uno::UNO_QUERY_THROW);
+// m_aProgrBaseTxt = m_aProgrFT.GetText();
+}
+
+//===============================================
+SaveProgressDialog::~SaveProgressDialog()
+{
+}
+
+//===============================================
+short SaveProgressDialog::Execute()
+{
+ ::SolarMutexGuard aLock;
+
+ m_pCore->setProgressHandler(m_xProgress);
+ m_pCore->setUpdateListener(this);
+ m_pCore->doEmergencySave();
+ short nRet = ModalDialog::Execute();
+ m_pCore->setUpdateListener(0);
+ return nRet;
+}
+
+//===============================================
+void SaveProgressDialog::updateItems()
+{
+}
+
+//===============================================
+void SaveProgressDialog::stepNext(TURLInfo* )
+{
+ /* TODO
+
+ wenn die m_pCore noch ein Member m_nCurrentItem haette
+ koennte man dort erkennen, wer gerade drann war, wer demnaechst
+ dran ist ... Diese Info kann man dann in unserem Progress FixText anzeigen ...
+ */
+}
+
+//===============================================
+void SaveProgressDialog::start()
+{
+}
+
+//===============================================
+void SaveProgressDialog::end()
+{
+ EndDialog(DLG_RET_OK);
+}
+
+//===============================================
+RecovDocListEntry::RecovDocListEntry( SvLBoxEntry* pEntry,
+ USHORT nFlags,
+ const String& sText )
+ : SvLBoxString( pEntry, nFlags, sText )
+{
+}
+
+//===============================================
+void RecovDocListEntry::Paint(const Point& aPos ,
+ SvLBox& aDevice,
+ USHORT /*nFlags */,
+ SvLBoxEntry* pEntry )
+{
+ const Image* pImg = 0;
+ const String* pTxt = 0;
+ RecovDocList* pList = static_cast< RecovDocList* >(&aDevice);
+
+ BOOL bHC = aDevice.GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ TURLInfo* pInfo = (TURLInfo*)pEntry->GetUserData();
+ switch(pInfo->RecoveryState)
+ {
+ case E_SUCCESSFULLY_RECOVERED :
+ {
+ pImg = &pList->m_aGreenCheckImg;
+ if (bHC)
+ pImg = &pList->m_aGreenCheckImgHC;
+ pTxt = &pList->m_aSuccessRecovStr;
+ }
+ break;
+
+ case E_ORIGINAL_DOCUMENT_RECOVERED : // TODO must be renamed into ORIGINAL DOCUMENT recovered! Because its marked as yellow
+ {
+ pImg = &pList->m_aYellowCheckImg;
+ if (bHC)
+ pImg = &pList->m_aYellowCheckImgHC;
+ pTxt = &pList->m_aOrigDocRecovStr;
+ }
+ break;
+
+ case E_RECOVERY_FAILED :
+ {
+ pImg = &pList->m_aRedCrossImg;
+ if (bHC)
+ pImg = &pList->m_aRedCrossImgHC;
+ pTxt = &pList->m_aRecovFailedStr;
+ }
+ break;
+
+ case E_RECOVERY_IS_IN_PROGRESS :
+ {
+ pImg = 0;
+ pTxt = &pList->m_aRecovInProgrStr;
+ }
+ break;
+
+ case E_NOT_RECOVERED_YET :
+ {
+ pImg = 0;
+ pTxt = &pList->m_aNotRecovYetStr;
+ }
+ break;
+ }
+
+ if (pImg)
+ aDevice.DrawImage(aPos, *pImg);
+
+ if (pTxt)
+ {
+ ::rtl::OUString sT1(*pTxt);
+
+ Point aPnt(aPos);
+ aPnt.X() += pList->m_aGreenCheckImg.GetSizePixel().Width();
+ aPnt.X() += 10;
+ aDevice.DrawText(aPnt, *pTxt);
+ }
+}
+//===============================================
+RecovDocList::RecovDocList( Window* pParent,
+ const ResId& rResId )
+ : SvxSimpleTable ( pParent, rResId )
+ , m_aGreenCheckImg ( ResId(IMG_GREENCHECK,*rResId.GetResMgr() ) )
+ , m_aYellowCheckImg ( ResId(IMG_YELLOWCHECK,*rResId.GetResMgr() ) )
+ , m_aRedCrossImg ( ResId(IMG_REDCROSS,*rResId.GetResMgr() ) )
+ , m_aGreenCheckImgHC ( ResId(IMG_GREENCHECK_HC,*rResId.GetResMgr() ) )
+ , m_aYellowCheckImgHC ( ResId(IMG_YELLOWCHECK_HC,*rResId.GetResMgr() ) )
+ , m_aRedCrossImgHC ( ResId(IMG_REDCROSS_HC,*rResId.GetResMgr() ) )
+ , m_aSuccessRecovStr ( ResId(STR_SUCCESSRECOV,*rResId.GetResMgr() ) )
+ , m_aOrigDocRecovStr ( ResId(STR_ORIGDOCRECOV,*rResId.GetResMgr() ) )
+ , m_aRecovFailedStr ( ResId(STR_RECOVFAILED,*rResId.GetResMgr() ) )
+ , m_aRecovInProgrStr ( ResId(STR_RECOVINPROGR,*rResId.GetResMgr() ) )
+ , m_aNotRecovYetStr ( ResId(STR_NOTRECOVYET,*rResId.GetResMgr() ) )
+{
+ //SetEntryHeight( short( maGreenCheckImg.GetSizePixel().Height() ) );
+}
+
+//===============================================
+RecovDocList::~RecovDocList()
+{
+}
+
+//===============================================
+void RecovDocList::InitEntry( SvLBoxEntry* pEntry ,
+ const XubString& sText ,
+ const Image& aImage1,
+ const Image& aImage2,
+ SvLBoxButtonKind eButtonKind)
+{
+ SvTabListBox::InitEntry(pEntry, sText, aImage1, aImage2, eButtonKind);
+ DBG_ASSERT( TabCount() == 2, "*RecovDocList::InitEntry(): structure missmatch" );
+
+ SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem(2);
+ RecovDocListEntry* p = new RecovDocListEntry(pEntry, 0, pCol->GetText());
+ pEntry->ReplaceItem(p, 2);
+}
+
+//===============================================
+short impl_askUserForWizardCancel(Window* pParent, sal_Int16 nRes)
+{
+ QueryBox aQuery(pParent, SVX_RES(nRes));
+ if (aQuery.Execute() == RET_YES)
+ return DLG_RET_OK;
+ else
+ return DLG_RET_CANCEL;
+}
+
+//===============================================
+RecoveryDialog::RecoveryDialog(Window* pParent,
+ RecoveryCore* pCore )
+ : IExtendedTabPage( pParent , SVX_RES( RID_SVXPAGE_DOCRECOVERY_RECOVER ) )
+ , m_aTitleWin ( this , SVX_RES ( WIN_RECOV_TITLE ) )
+ , m_aTitleFT ( this , SVX_RES ( FT_RECOV_TITLE ) )
+ , m_aTitleFL ( this , SVX_RES ( FL_RECOV_TITLE ) )
+ , m_aDescrFT ( this , SVX_RES ( FT_RECOV_DESCR ) )
+ , m_aProgressFT ( this , SVX_RES ( FT_RECOV_PROGR ) )
+ , m_aProgrParent ( this , SVX_RES ( WIN_RECOV_PROGR ) )
+ , m_aFileListFT ( this , SVX_RES ( FT_RECOV_FILELIST ) )
+ , m_aFileListLB ( this , SVX_RES ( LB_RECOV_FILELIST ) )
+ , m_aBottomFL ( this , SVX_RES ( FL_RECOV_BOTTOM ) )
+ , m_aNextBtn ( this , SVX_RES ( BTN_RECOV_NEXT ) )
+ , m_aCancelBtn ( this , SVX_RES ( BTN_RECOV_CANCEL ) )
+ , m_aNextStr ( SVX_RES ( STR_RECOVERY_NEXT ) )
+ , m_aTitleRecoveryInProgress( SVX_RES ( STR_RECOVERY_INPROGRESS ) )
+ , m_aTitleRecoveryReport( SVX_RES ( STR_RECOVERY_REPORT ) )
+ , m_aRecoveryOnlyFinish ( SVX_RES ( STR_RECOVERYONLY_FINISH ) )
+ , m_aRecoveryOnlyFinishDescr( SVX_RES ( STR_RECOVERYONLY_FINISH_DESCR ) )
+ , m_pDefButton ( NULL )
+ , m_pCore ( pCore )
+ , m_eRecoveryState (RecoveryDialog::E_RECOVERY_PREPARED)
+ , m_bWaitForUser (sal_False)
+ , m_bWaitForCore (sal_False)
+ , m_bUserDecideNext (sal_False)
+ , m_bWasRecoveryStarted (sal_False)
+ , m_bRecoveryOnly (sal_False)
+{
+ static long nTabs[] = { 2, 0, 40*RECOV_CONTROLWIDTH/100 };
+ m_aFileListLB.SetTabs( &nTabs[0] );
+ m_aFileListLB.InsertHeaderEntry( String( SVX_RES( STR_HEADERBAR ) ) );
+
+ FreeResource();
+
+ ::rtl::OUString CFG_PACKAGE_RECOVERY( RTL_CONSTASCII_USTRINGPARAM ( "org.openoffice.Office.Recovery/" ));
+ ::rtl::OUString CFG_PATH_CRASHREPORTER( RTL_CONSTASCII_USTRINGPARAM( "CrashReporter" ));
+ ::rtl::OUString CFG_ENTRY_ENABLED( RTL_CONSTASCII_USTRINGPARAM ( "Enabled" ));
+
+ sal_Bool bCrashRepEnabled( sal_True );
+ css::uno::Any aVal = ::comphelper::ConfigurationHelper::readDirectKey(
+ pCore->getSMGR(),
+ CFG_PACKAGE_RECOVERY,
+ CFG_PATH_CRASHREPORTER,
+ CFG_ENTRY_ENABLED,
+ ::comphelper::ConfigurationHelper::E_READONLY);
+ aVal >>= bCrashRepEnabled;
+ m_bRecoveryOnly = !bCrashRepEnabled;
+
+ PluginProgress* pProgress = new PluginProgress( &m_aProgrParent, pCore->getSMGR() );
+ m_xProgress = css::uno::Reference< css::task::XStatusIndicator >(static_cast< css::task::XStatusIndicator* >(pProgress), css::uno::UNO_QUERY_THROW);
+
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ Wallpaper aBackground( rStyleSettings.GetWindowColor() );
+ m_aTitleWin.SetBackground(aBackground);
+ m_aTitleFT.SetBackground (aBackground);
+
+ Font aFont(m_aTitleFT.GetFont());
+ aFont.SetWeight(WEIGHT_BOLD);
+ m_aTitleFT.SetFont(aFont);
+
+ m_aFileListLB.SetBackground( rStyleSettings.GetDialogColor() );
+
+ m_aNextBtn.Enable(TRUE);
+ m_aNextBtn.SetClickHdl( LINK( this, RecoveryDialog, NextButtonHdl ) );
+ m_aCancelBtn.SetClickHdl( LINK( this, RecoveryDialog, CancelButtonHdl ) );
+
+ // fill list box first time
+ TURLList* pURLList = m_pCore->getURLListAccess();
+ TURLList::const_iterator pIt;
+ for ( pIt = pURLList->begin();
+ pIt != pURLList->end() ;
+ ++pIt )
+ {
+ const TURLInfo& rInfo = *pIt;
+
+ String sName( rInfo.DisplayName );
+ sName += '\t';
+ sName += impl_getStatusString( rInfo );
+ SvLBoxEntry* pEntry = m_aFileListLB.InsertEntry(sName, rInfo.StandardImage, rInfo.StandardImage);
+ pEntry->SetUserData((void*)&rInfo);
+ m_aFileListLB.SetExpandedEntryBmp (pEntry, rInfo.HCImage, BMP_COLOR_HIGHCONTRAST);
+ m_aFileListLB.SetCollapsedEntryBmp(pEntry, rInfo.HCImage, BMP_COLOR_HIGHCONTRAST);
+ }
+
+ // mark first item
+ SvLBoxEntry* pFirst = m_aFileListLB.First();
+ if (pFirst)
+ m_aFileListLB.SetCursor(pFirst, sal_True);
+}
+
+//===============================================
+RecoveryDialog::~RecoveryDialog()
+{
+}
+
+//===============================================
+short RecoveryDialog::execute()
+{
+ ::SolarMutexGuard aSolarLock;
+
+ switch(m_eRecoveryState)
+ {
+ case RecoveryDialog::E_RECOVERY_PREPARED :
+ {
+ // Dialog was started first time ...
+ // wait for user decision ("start" or "cancel" recovery)
+ // This decision will be made inside the NextBtn handler.
+ m_aNextBtn.Enable(TRUE);
+ m_aCancelBtn.Enable(TRUE);
+ m_bWaitForUser = sal_True;
+ while(m_bWaitForUser)
+ Application::Yield();
+ if (m_bUserDecideNext)
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_IN_PROGRESS;
+ else
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_CANCELED;
+ return execute();
+ }
+
+ case RecoveryDialog::E_RECOVERY_IN_PROGRESS :
+ {
+ // user decided to start recovery ...
+ m_bWasRecoveryStarted = sal_True;
+ // do it asynchronous (to allow repaints)
+ // and wait for this asynchronous operation.
+ m_aDescrFT.SetText( m_aTitleRecoveryInProgress );
+ m_aNextBtn.Enable(FALSE);
+ m_aCancelBtn.Enable(FALSE);
+ m_pCore->setProgressHandler(m_xProgress);
+ m_pCore->setUpdateListener(this);
+ m_pCore->doRecovery();
+
+ m_bWaitForCore = sal_True;
+ while(m_bWaitForCore)
+ Application::Yield();
+
+ m_pCore->setUpdateListener(0);
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_CORE_DONE;
+ return execute();
+ }
+
+ case RecoveryDialog::E_RECOVERY_CORE_DONE :
+ {
+ // the core finished it's task.
+ // let the user decide the next step.
+ if ( m_bRecoveryOnly )
+ {
+ m_aDescrFT.SetText(m_aRecoveryOnlyFinishDescr);
+ m_aNextBtn.SetText(m_aRecoveryOnlyFinish);
+ m_aNextBtn.Enable(TRUE);
+ m_aCancelBtn.Enable(FALSE);
+ }
+ else
+ {
+ m_aDescrFT.SetText(m_aTitleRecoveryReport);
+ m_aNextBtn.SetText(m_aNextStr);
+ m_aNextBtn.Enable(TRUE);
+ m_aCancelBtn.Enable(TRUE);
+ }
+
+ m_bWaitForUser = sal_True;
+ while(m_bWaitForUser)
+ Application::Yield();
+
+ if (m_bUserDecideNext)
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_DONE;
+ else
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_CANCELED;
+ return execute();
+ }
+
+ case RecoveryDialog::E_RECOVERY_DONE :
+ {
+ // All documents was reovered.
+ // User decided to step to the "next" wizard page.
+ // Do it ... but check first, if there exist some
+ // failed recovery documents. They must be saved to
+ // a user selected directrory.
+ short nRet = DLG_RET_UNKNOWN;
+ BrokenRecoveryDialog* pBrokenRecoveryDialog = new BrokenRecoveryDialog(this, m_pCore, !m_bWasRecoveryStarted);
+ String sSaveDir = pBrokenRecoveryDialog->getSaveDirURL(); // get the default dir
+ if (pBrokenRecoveryDialog->isExecutionNeeded())
+ {
+ nRet = pBrokenRecoveryDialog->Execute();
+ sSaveDir = pBrokenRecoveryDialog->getSaveDirURL();
+ }
+ delete pBrokenRecoveryDialog;
+
+ switch(nRet)
+ {
+ // no broken temp files exists
+ // step to the next wizard page
+ case DLG_RET_UNKNOWN :
+ {
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_HANDLED;
+ return DLG_RET_OK;
+ }
+
+ // user decided to save the broken temp files
+ // do and forget it
+ // step to the next wizard page
+ case DLG_RET_OK :
+ {
+ m_pCore->saveBrokenTempEntries(sSaveDir);
+ m_pCore->forgetBrokenTempEntries();
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_HANDLED;
+ return DLG_RET_OK;
+ }
+
+ // user decided to ignore broken temp files.
+ // Ask it again ... may be this decision was wrong.
+ // Results:
+ // IGNORE => remove broken temp files
+ // => step to the next wizard page
+ // CANCEL => step back to the recovery page
+ case DLG_RET_CANCEL :
+ {
+ // TODO ask user ...
+ m_pCore->forgetBrokenTempEntries();
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_HANDLED;
+ return DLG_RET_OK;
+ }
+ }
+
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_HANDLED;
+ return DLG_RET_OK;
+ }
+
+ case RecoveryDialog::E_RECOVERY_CANCELED :
+ {
+ // "YES" => break recovery
+ // But there exist different states, where "cancel" can be called.
+ // Handle it different.
+ if (m_bWasRecoveryStarted)
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_CANCELED_AFTERWARDS;
+ else
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_CANCELED_BEFORE;
+ return execute();
+ }
+
+ case RecoveryDialog::E_RECOVERY_CANCELED_BEFORE :
+ case RecoveryDialog::E_RECOVERY_CANCELED_AFTERWARDS :
+ {
+ // We have to check if there exists some temp. files.
+ // They should be saved to a user defined location.
+ // If no temp files exists or user decided to ignore it ...
+ // we have to remove all recovery/session data anyway!
+ short nRet = DLG_RET_UNKNOWN;
+ BrokenRecoveryDialog* pBrokenRecoveryDialog = new BrokenRecoveryDialog(this, m_pCore, !m_bWasRecoveryStarted);
+ String sSaveDir = pBrokenRecoveryDialog->getSaveDirURL(); // get the default save location
+
+ // dialog itself checks if there is a need to copy files for this mode.
+ // It uses the information m_bWasRecoveryStarted doing so.
+ if (pBrokenRecoveryDialog->isExecutionNeeded())
+ {
+ nRet = pBrokenRecoveryDialog->Execute();
+ sSaveDir = pBrokenRecoveryDialog->getSaveDirURL();
+ }
+ delete pBrokenRecoveryDialog;
+
+ // Possible states:
+ // a) nRet == DLG_RET_UNKNOWN
+ // dialog was not shown ...
+ // because there exists no temp file for copy.
+ // => remove all recovery data
+ // b) nRet == DLG_RET_OK
+ // dialog was shown ...
+ // user decided to save temp files
+ // => save all OR broken temp files (depends from the time, where cancel was called)
+ // => remove all recovery data
+ // c) nRet == DLG_RET_CANCEL
+ // dialog was shown ...
+ // user decided to ignore temp files
+ // => remove all recovery data
+ // => a)/c) are the same ... b) has one additional operation
+
+ // b)
+ if (nRet == DLG_RET_OK)
+ {
+ if (m_bWasRecoveryStarted)
+ m_pCore->saveBrokenTempEntries(sSaveDir);
+ else
+ m_pCore->saveAllTempEntries(sSaveDir);
+ }
+
+ // a,b,c)
+ if (m_bWasRecoveryStarted)
+ m_pCore->forgetBrokenRecoveryEntries();
+ else
+ m_pCore->forgetAllRecoveryEntries();
+ m_eRecoveryState = RecoveryDialog::E_RECOVERY_HANDLED;
+
+ // THERE IS NO WAY BACK. see impl_askUserForWizardCancel()!
+ return DLG_RET_CANCEL;
+ }
+
+ case RecoveryDialog::E_RECOVERY_HANDLED :
+ {
+ m_bWaitForUser = sal_True;
+ while(m_bWaitForUser)
+ Application::Yield();
+
+ // TODO: show BrokenRecoveryDialog again, ift he user
+ // doesnt accepted it last time.
+
+ if (m_bUserDecideNext)
+ return DLG_RET_OK;
+ else
+ return DLG_RET_CANCEL;
+ }
+ }
+
+ // should never be reached .-)
+ DBG_ERROR("Should never be reached!");
+ return DLG_RET_OK;
+}
+
+//===============================================
+void RecoveryDialog::setDefButton()
+{
+ if ( m_aNextBtn.IsEnabled() )
+ m_aNextBtn.GrabFocus();
+ else
+ m_pDefButton = &m_aNextBtn;
+}
+
+//===============================================
+void RecoveryDialog::start()
+{
+}
+
+//===============================================
+void RecoveryDialog::updateItems()
+{
+ ULONG c = m_aFileListLB.GetEntryCount();
+ ULONG i = 0;
+ for ( i=0; i<c; ++i )
+ {
+ SvLBoxEntry* pEntry = m_aFileListLB.GetEntry(i);
+ if ( !pEntry )
+ continue;
+
+ TURLInfo* pInfo = (TURLInfo*)pEntry->GetUserData();
+ if ( !pInfo )
+ continue;
+
+ String sStatus = impl_getStatusString( *pInfo );
+ if ( sStatus.Len() > 0 )
+ m_aFileListLB.SetEntryText( sStatus, pEntry, 1 );
+ }
+
+ m_aFileListLB.Invalidate();
+ m_aFileListLB.Update();
+}
+
+//===============================================
+void RecoveryDialog::stepNext(TURLInfo* pItem)
+{
+ ULONG c = m_aFileListLB.GetEntryCount();
+ ULONG i = 0;
+ for (i=0; i<c; ++i)
+ {
+ SvLBoxEntry* pEntry = m_aFileListLB.GetEntry(i);
+ if (!pEntry)
+ continue;
+
+ TURLInfo* pInfo = (TURLInfo*)pEntry->GetUserData();
+ if (pInfo->ID != pItem->ID)
+ continue;
+
+ m_aFileListLB.SetCursor(pEntry, sal_True);
+ m_aFileListLB.MakeVisible(pEntry);
+ m_aFileListLB.Invalidate();
+ m_aFileListLB.Update();
+ break;
+ }
+}
+
+//===============================================
+void RecoveryDialog::end()
+{
+ if ( m_pDefButton )
+ {
+ m_pDefButton->GrabFocus();
+ m_pDefButton = NULL;
+ }
+ m_bWaitForCore = sal_False;
+}
+
+//===============================================
+IMPL_LINK( RecoveryDialog, NextButtonHdl, void*, EMPTYARG )
+{
+ m_bUserDecideNext = sal_True;
+ m_bWaitForUser = sal_False;
+ return 0;
+}
+
+//===============================================
+IMPL_LINK( RecoveryDialog, CancelButtonHdl, void*, EMPTYARG )
+{
+ if (m_eRecoveryState == RecoveryDialog::E_RECOVERY_PREPARED)
+ {
+ if (impl_askUserForWizardCancel(this, RID_SVXQB_EXIT_RECOVERY) == DLG_RET_CANCEL)
+ return 0;
+ }
+ m_bUserDecideNext = sal_False;
+ m_bWaitForUser = sal_False;
+ return 0;
+}
+
+//===============================================
+void RecoveryDialog::impl_refreshDocList()
+{
+}
+
+//===============================================
+String RecoveryDialog::impl_getStatusString( const TURLInfo& rInfo ) const
+{
+ String sStatus;
+ switch ( rInfo.RecoveryState )
+ {
+ case E_SUCCESSFULLY_RECOVERED :
+ sStatus = m_aFileListLB.m_aSuccessRecovStr;
+ break;
+ case E_ORIGINAL_DOCUMENT_RECOVERED :
+ sStatus = m_aFileListLB.m_aOrigDocRecovStr;
+ break;
+ case E_RECOVERY_FAILED :
+ sStatus = m_aFileListLB.m_aRecovFailedStr;
+ break;
+ case E_RECOVERY_IS_IN_PROGRESS :
+ sStatus = m_aFileListLB.m_aRecovInProgrStr;
+ break;
+ case E_NOT_RECOVERED_YET :
+ sStatus = m_aFileListLB.m_aNotRecovYetStr;
+ break;
+ default:
+ break;
+ }
+ return sStatus;
+}
+
+//===============================================
+BrokenRecoveryDialog::BrokenRecoveryDialog(Window* pParent ,
+ RecoveryCore* pCore ,
+ sal_Bool bBeforeRecovery)
+ : ModalDialog ( pParent, SVX_RES( RID_SVX_MDLG_DOCRECOVERY_BROKEN ) )
+ , m_aDescrFT ( this , SVX_RES( FT_BROKEN_DESCR ) )
+ , m_aFileListFT ( this , SVX_RES( FT_BROKEN_FILELIST ) )
+ , m_aFileListLB ( this , SVX_RES( LB_BROKEN_FILELIST ) )
+ , m_aSaveDirFT ( this , SVX_RES( FT_BROKEN_SAVEDIR ) )
+ , m_aSaveDirED ( this , SVX_RES( ED_BROKEN_SAVEDIR ) )
+ , m_aSaveDirBtn ( this , SVX_RES( BTN_BROKEN_SAVEDIR ) )
+ , m_aBottomFL ( this , SVX_RES( FL_BROKEN_BOTTOM ) )
+ , m_aOkBtn ( this , SVX_RES( BTN_BROKEN_OK ) )
+ , m_aCancelBtn ( this , SVX_RES( BTN_BROKEN_CANCEL ) )
+ , m_pCore ( pCore )
+ , m_bBeforeRecovery (bBeforeRecovery)
+ , m_bExecutionNeeded(sal_False)
+{
+ FreeResource();
+
+ m_aSaveDirBtn.SetClickHdl( LINK( this, BrokenRecoveryDialog, SaveButtonHdl ) );
+ m_aOkBtn.SetClickHdl( LINK( this, BrokenRecoveryDialog, OkButtonHdl ) );
+ m_aCancelBtn.SetClickHdl( LINK( this, BrokenRecoveryDialog, CancelButtonHdl ) );
+
+ m_sSavePath = SvtPathOptions().GetWorkPath();
+ INetURLObject aObj( m_sSavePath );
+ String sPath;
+ ::utl::LocalFileHelper::ConvertURLToSystemPath( aObj.GetMainURL( INetURLObject::NO_DECODE ), sPath );
+ m_aSaveDirED.SetText( sPath );
+
+ impl_refresh();
+}
+
+//===============================================
+BrokenRecoveryDialog::~BrokenRecoveryDialog()
+{
+}
+
+//===============================================
+void BrokenRecoveryDialog::impl_refresh()
+{
+ m_bExecutionNeeded = sal_False;
+ TURLList* pURLList = m_pCore->getURLListAccess();
+ TURLList::const_iterator pIt;
+ for ( pIt = pURLList->begin();
+ pIt != pURLList->end() ;
+ ++pIt )
+ {
+ const TURLInfo& rInfo = *pIt;
+
+ if (m_bBeforeRecovery)
+ {
+ // "Cancel" before recovery ->
+ // search for any temp files!
+ if (!rInfo.TempURL.getLength())
+ continue;
+ }
+ else
+ {
+ // "Cancel" after recovery ->
+ // search for broken temp files
+ if (!RecoveryCore::isBrokenTempEntry(rInfo))
+ continue;
+ }
+
+ m_bExecutionNeeded = sal_True;
+
+ USHORT nPos = m_aFileListLB.InsertEntry(rInfo.DisplayName, rInfo.StandardImage );
+ m_aFileListLB.SetEntryData( nPos, (void*)&rInfo );
+ }
+ m_sSavePath = ::rtl::OUString();
+ m_aOkBtn.GrabFocus();
+}
+
+//===============================================
+sal_Bool BrokenRecoveryDialog::isExecutionNeeded()
+{
+ return m_bExecutionNeeded;
+}
+
+//===============================================
+::rtl::OUString BrokenRecoveryDialog::getSaveDirURL()
+{
+ return m_sSavePath;
+}
+
+//===============================================
+IMPL_LINK( BrokenRecoveryDialog, OkButtonHdl, void*, EMPTYARG )
+{
+ String sPhysicalPath = m_aSaveDirED.GetText().EraseLeadingChars().EraseTrailingChars();
+ String sURL;
+ ::utl::LocalFileHelper::ConvertPhysicalNameToURL( sPhysicalPath, sURL );
+ m_sSavePath = sURL;
+ while (!m_sSavePath.getLength())
+ impl_askForSavePath();
+
+ EndDialog(DLG_RET_OK);
+ return 0;
+}
+
+//===============================================
+IMPL_LINK( BrokenRecoveryDialog, CancelButtonHdl, void*, EMPTYARG )
+{
+ EndDialog(DLG_RET_CANCEL);
+ return 0;
+}
+
+//===============================================
+IMPL_LINK( BrokenRecoveryDialog, SaveButtonHdl, void*, EMPTYARG )
+{
+ impl_askForSavePath();
+ return 0;
+}
+
+//===============================================
+void BrokenRecoveryDialog::impl_askForSavePath()
+{
+ css::uno::Reference< css::ui::dialogs::XFolderPicker > xFolderPicker(
+ m_pCore->getSMGR()->createInstance(SERVICENAME_FOLDERPICKER), css::uno::UNO_QUERY_THROW);
+// svt::SetDialogHelpId( xFolderPicker, HID_OPTIONS_PATHS_SELECTFOLDER );
+
+ INetURLObject aURL(m_sSavePath, INET_PROT_FILE);
+ xFolderPicker->setDisplayDirectory(aURL.GetMainURL(INetURLObject::NO_DECODE));
+ short nRet = xFolderPicker->execute();
+ if (nRet == css::ui::dialogs::ExecutableDialogResults::OK)
+ {
+ m_sSavePath = xFolderPicker->getDirectory();
+ String sPath;
+ ::utl::LocalFileHelper::ConvertURLToSystemPath( m_sSavePath, sPath );
+ m_aSaveDirED.SetText( sPath );
+ }
+}
+
+//===============================================
+ ///////////////////////////////////////////////////////////////////////
+ // Error Report Welcome Dialog
+ ///////////////////////////////////////////////////////////////////////
+
+ ErrorRepWelcomeDialog::ErrorRepWelcomeDialog( Window* _pParent, sal_Bool _bAllowBack )
+ :IExtendedTabPage ( _pParent, SVX_RES( RID_SVXPAGE_ERR_REP_WELCOME ) )
+ ,maTitleWin ( this, SVX_RES( WIN_RECOV_TITLE ) )
+ ,maTitleFT ( this, SVX_RES( FT_RECOV_TITLE ) )
+ ,maTitleFL ( this, SVX_RES( FL_RECOV_TITLE ) )
+ ,maDescrFT ( this, SVX_RES( FT_RECOV_DESCR ) )
+ ,maBottomFL ( this, SVX_RES( FL_RECOV_BOTTOM ) )
+ ,maPrevBtn ( this, SVX_RES( BTN_RECOV_PREV ) )
+ ,maNextBtn ( this, SVX_RES( BTN_RECOV_NEXT ) )
+ ,maCancelBtn ( this, SVX_RES( BTN_RECOV_CANCEL ) )
+ {
+ FreeResource();
+
+ Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() );
+ maTitleWin.SetBackground( aBack );
+ maTitleFT.SetBackground( aBack );
+
+ Font aFnt( maTitleFT.GetFont() );
+ aFnt.SetWeight( WEIGHT_BOLD );
+ maTitleFT.SetFont( aFnt );
+
+ maPrevBtn.SetClickHdl( LINK( this, ErrorRepWelcomeDialog, PrevBtnHdl ) );
+ maPrevBtn.Enable( _bAllowBack );
+
+ maNextBtn.SetClickHdl( LINK( this, ErrorRepWelcomeDialog, NextBtnHdl ) );
+ maNextBtn.Enable( sal_True );
+
+ maCancelBtn.SetClickHdl( LINK( this, ErrorRepWelcomeDialog, CancelBtnHdl ) );
+ maCancelBtn.Enable( sal_True );
+ }
+
+ ErrorRepWelcomeDialog::~ErrorRepWelcomeDialog()
+ {
+ }
+
+ IMPL_LINK( ErrorRepWelcomeDialog, PrevBtnHdl, void*, EMPTYARG )
+ {
+ m_nResult = DLG_RET_BACK;
+ return 0;
+ }
+
+ IMPL_LINK( ErrorRepWelcomeDialog, NextBtnHdl, void*, EMPTYARG )
+ {
+ m_nResult = DLG_RET_OK;
+ return 0;
+ }
+
+ IMPL_LINK( ErrorRepWelcomeDialog, CancelBtnHdl, void*, EMPTYARG )
+ {
+ m_nResult = DLG_RET_CANCEL;
+ return 0;
+ }
+
+ short ErrorRepWelcomeDialog::execute()
+ {
+ ::SolarMutexGuard aLock;
+ Show();
+ m_nResult = DLG_RET_UNKNOWN;
+ while(m_nResult == DLG_RET_UNKNOWN)
+ Application::Yield();
+ return m_nResult;
+ }
+
+ void ErrorRepWelcomeDialog::setDefButton()
+ {
+ maNextBtn.GrabFocus();
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // Error Report Send Dialog and its MultiLineEdit
+ ///////////////////////////////////////////////////////////////////////
+
+ ErrorDescriptionEdit::ErrorDescriptionEdit( Window* pParent, const ResId& rResId ) :
+
+ MultiLineEdit( pParent, rResId )
+
+ {
+ SetModifyHdl( LINK( this, ErrorDescriptionEdit, ModifyHdl ) );
+ if ( GetVScrollBar() )
+ GetVScrollBar()->Hide();
+ }
+
+ ErrorDescriptionEdit::~ErrorDescriptionEdit()
+ {
+ }
+
+ IMPL_LINK( ErrorDescriptionEdit, ModifyHdl, void*, EMPTYARG )
+ {
+ if ( !GetVScrollBar() )
+ return 0;
+
+ ExtTextEngine* pTextEngine = GetTextEngine();
+ DBG_ASSERT( pTextEngine, "no text engine" );
+
+ ULONG i, nParaCount = pTextEngine->GetParagraphCount();
+ USHORT nLineCount = 0;
+
+ for ( i = 0; i < nParaCount; ++i )
+ nLineCount = nLineCount + pTextEngine->GetLineCount(i);
+
+ USHORT nVisCols = 0, nVisLines = 0;
+ GetMaxVisColumnsAndLines( nVisCols, nVisLines );
+ GetVScrollBar()->Show( nLineCount > nVisLines );
+
+ return 0;
+ }
+
+ ErrorRepSendDialog::ErrorRepSendDialog( Window* _pParent )
+ :IExtendedTabPage ( _pParent, SVX_RES( RID_SVXPAGE_ERR_REP_SEND ) )
+ ,maTitleWin ( this, SVX_RES( WIN_RECOV_TITLE ) )
+ ,maTitleFT ( this, SVX_RES( FT_RECOV_TITLE ) )
+ ,maTitleFL ( this, SVX_RES( FL_RECOV_TITLE ) )
+ ,maDescrFT ( this, SVX_RES( FT_RECOV_DESCR ) )
+
+ ,maDocTypeFT ( this, SVX_RES( FT_ERRSEND_DOCTYPE ) )
+ ,maDocTypeED ( this, SVX_RES( ED_ERRSEND_DOCTYPE ) )
+ ,maUsingFT ( this, SVX_RES( FT_ERRSEND_USING ) )
+ ,maUsingML ( this, SVX_RES( ML_ERRSEND_USING ) )
+ ,maShowRepBtn ( this, SVX_RES( BTN_ERRSEND_SHOWREP ) )
+ ,maOptBtn ( this, SVX_RES( BTN_ERRSEND_OPT ) )
+ ,maContactCB ( this, SVX_RES( CB_ERRSEND_CONTACT ) )
+ ,maEMailAddrFT ( this, SVX_RES( FT_ERRSEND_EMAILADDR ) )
+ ,maEMailAddrED ( this, SVX_RES( ED_ERRSEND_EMAILADDR ) )
+
+ ,maBottomFL ( this, SVX_RES( FL_RECOV_BOTTOM ) )
+ ,maPrevBtn ( this, SVX_RES( BTN_RECOV_PREV ) )
+ ,maNextBtn ( this, SVX_RES( BTN_RECOV_NEXT ) )
+ ,maCancelBtn ( this, SVX_RES( BTN_RECOV_CANCEL ) )
+ {
+ FreeResource();
+
+ initControls();
+
+ Wallpaper aBack( GetSettings().GetStyleSettings().GetWindowColor() );
+ maTitleWin.SetBackground( aBack );
+ maTitleFT.SetBackground( aBack );
+
+ Font aFnt( maTitleFT.GetFont() );
+ aFnt.SetWeight( WEIGHT_BOLD );
+ maTitleFT.SetFont( aFnt );
+
+ maShowRepBtn.SetClickHdl( LINK( this, ErrorRepSendDialog, ShowRepBtnHdl ) );
+ maOptBtn.SetClickHdl( LINK( this, ErrorRepSendDialog, OptBtnHdl ) );
+ maContactCB.SetClickHdl( LINK( this, ErrorRepSendDialog, ContactCBHdl ) );
+ maPrevBtn.SetClickHdl( LINK( this, ErrorRepSendDialog, PrevBtnHdl ) );
+ maNextBtn.SetClickHdl( LINK( this, ErrorRepSendDialog, SendBtnHdl ) );
+ maCancelBtn.SetClickHdl( LINK( this, ErrorRepSendDialog, CancelBtnHdl ) );
+
+ ReadParams();
+
+ /*
+ maDocTypeED.SetText( maParams.maSubject );
+ maUsingML.SetText( maParams.maBody );
+ maContactCB.Check( maParams.mbAllowContact );
+ maEMailAddrED.SetText( maParams.maReturnAddress );
+ */
+ ContactCBHdl( 0 );
+ }
+
+ ErrorRepSendDialog::~ErrorRepSendDialog()
+ {
+ }
+
+ short ErrorRepSendDialog::execute()
+ {
+ ::SolarMutexGuard aLock;
+ Show();
+ m_nResult = DLG_RET_UNKNOWN;
+ while(m_nResult == DLG_RET_UNKNOWN)
+ Application::Yield();
+ return m_nResult;
+ }
+
+ void ErrorRepSendDialog::setDefButton()
+ {
+ // set first focus
+ maDocTypeED.GrabFocus();
+ }
+
+ IMPL_LINK( ErrorRepSendDialog, PrevBtnHdl, void*, EMPTYARG )
+ {
+ m_nResult = DLG_RET_BACK;
+ return 0;
+ }
+
+ IMPL_LINK( ErrorRepSendDialog, CancelBtnHdl, void*, EMPTYARG )
+ {
+ m_nResult = DLG_RET_CANCEL;
+ return 0;
+ }
+
+ IMPL_LINK( ErrorRepSendDialog, SendBtnHdl, void*, EMPTYARG )
+ {
+
+ SaveParams();
+ SendReport();
+
+ m_nResult = DLG_RET_OK;
+ return 0;
+ }
+
+ IMPL_LINK( ErrorRepSendDialog, ShowRepBtnHdl, void*, EMPTYARG )
+ {
+ ErrorRepPreviewDialog aDlg( this );
+ aDlg.Execute();
+ return 0;
+ }
+
+ IMPL_LINK( ErrorRepSendDialog, OptBtnHdl, void*, EMPTYARG )
+ {
+ ErrorRepOptionsDialog aDlg( this, maParams );
+ aDlg.Execute();
+ return 0;
+ }
+
+ IMPL_LINK( ErrorRepSendDialog, ContactCBHdl, void*, EMPTYARG )
+ {
+ bool bCheck = maContactCB.IsChecked();
+ maEMailAddrFT.Enable( bCheck );
+ maEMailAddrED.Enable( bCheck );
+ return 0;
+ }
+
+ void ErrorRepSendDialog::initControls()
+ {
+ // if the text is too short for two lines, insert a newline
+ String sText = maDocTypeFT.GetText();
+ if ( maDocTypeFT.GetCtrlTextWidth( sText ) <= maDocTypeFT.GetSizePixel().Width() )
+ {
+ sText.Insert( '\n', 0 );
+ maDocTypeFT.SetText( sText );
+ }
+
+ // if the button text is too wide, then broaden the button
+ sText = maShowRepBtn.GetText();
+ long nTxtW = maShowRepBtn.GetCtrlTextWidth( sText );
+ long nBtnW = maShowRepBtn.GetSizePixel().Width();
+ if ( nTxtW >= nBtnW )
+ {
+ const long nMinDelta = 10;
+ long nDelta = Max( nTxtW - nBtnW, nMinDelta );
+ sal_uInt32 i = 0;
+ Window* pWins[] =
+ {
+ &maShowRepBtn, &maOptBtn,
+ &maDescrFT, &maDocTypeFT, &maDocTypeED, &maUsingFT,
+ &maUsingML, &maContactCB, &maEMailAddrFT, &maEMailAddrED
+ };
+ // the first two buttons need a new size (wider) and position (more left)
+ Window** pCurrent = pWins;
+ const sal_uInt32 nBtnCount = 2;
+ for ( ; i < nBtnCount; ++i, ++pCurrent )
+ {
+ Size aNewSize = (*pCurrent)->GetSizePixel();
+ aNewSize.Width() += nDelta;
+ (*pCurrent)->SetSizePixel( aNewSize );
+ Point aNewPos = (*pCurrent)->GetPosPixel();
+ aNewPos.X() -= nDelta;
+ (*pCurrent)->SetPosPixel( aNewPos );
+ }
+
+ // loop through all the other windows and adjust their size
+ for ( ; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent )
+ {
+ Size aSize = (*pCurrent)->GetSizePixel();
+ aSize.Width() -= nDelta;
+ (*pCurrent)->SetSizePixel( aSize );
+ }
+ }
+ }
+
+ String ErrorRepSendDialog::GetDocType( void ) const
+ {
+ return maDocTypeED.GetText();
+ }
+
+ String ErrorRepSendDialog::GetUsing( void ) const
+ {
+ return maUsingML.GetText();
+ }
+
+ bool ErrorRepSendDialog::IsContactAllowed( void ) const
+ {
+ return maContactCB.IsChecked();
+ }
+
+ String ErrorRepSendDialog::GetEMailAddress( void ) const
+ {
+ return maEMailAddrED.GetText();
+ }
+
+
+ ///////////////////////////////////////////////////////////////////////
+ // Error Report Options Dialog
+ ///////////////////////////////////////////////////////////////////////
+
+ ErrorRepOptionsDialog::ErrorRepOptionsDialog( Window* _pParent, ErrorRepParams& _rParams )
+ :ModalDialog ( _pParent, SVX_RES( RID_SVX_MDLG_ERR_REP_OPTIONS ) )
+ ,maProxyFL( this, SVX_RES( FL_ERROPT_PROXY ) )
+ ,maSystemBtn( this, SVX_RES( BTN_ERROPT_SYSTEM ) )
+ ,maDirectBtn( this, SVX_RES( BTN_ERROPT_DIRECT ) )
+ ,maManualBtn( this, SVX_RES( BTN_ERROPT_MANUAL ) )
+ ,maProxyServerFT( this, SVX_RES( FT_ERROPT_PROXYSERVER ) )
+ ,maProxyServerEd( this, SVX_RES( ED_ERROPT_PROXYSERVER ) )
+ ,maProxyPortFT( this, SVX_RES( FT_ERROPT_PROXYPORT ) )
+ ,maProxyPortEd( this, SVX_RES( ED_ERROPT_PROXYPORT ) )
+ ,maDescriptionFT( this, SVX_RES( FT_ERROPT_DESCRIPTION ) )
+ ,maButtonsFL( this, SVX_RES( FL_ERROPT_BUTTONS ) )
+ ,maOKBtn( this, SVX_RES( BTN_ERROPT_OK ) )
+ ,maCancelBtn( this, SVX_RES( BTN_ERROPT_CANCEL ) )
+ ,mrParams( _rParams )
+ {
+ FreeResource();
+
+ maManualBtn.SetToggleHdl( LINK( this, ErrorRepOptionsDialog, ManualBtnHdl ) );
+ maCancelBtn.SetClickHdl( LINK( this, ErrorRepOptionsDialog, CancelBtnHdl ) );
+ maOKBtn.SetClickHdl( LINK( this, ErrorRepOptionsDialog, OKBtnHdl ) );
+
+ maProxyServerEd.SetText( mrParams.maHTTPProxyServer );
+ maProxyPortEd.SetText( mrParams.maHTTPProxyPort );
+
+#ifndef WNT
+ // no "Use system settings" button on non windows systems
+ // so hide this button
+ maSystemBtn.Hide();
+ long nDelta = maDirectBtn.GetPosPixel().Y() - maSystemBtn.GetPosPixel().Y();
+ // and loop through all these controls and adjust their position
+ Window* pWins[] =
+ {
+ &maDirectBtn, &maManualBtn, &maProxyServerFT,
+ &maProxyServerEd, &maProxyPortFT, &maProxyPortEd, &maDescriptionFT
+ };
+ Window** pCurrent = pWins;
+ for ( sal_uInt32 i = 0; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent )
+ {
+ Point aPos = (*pCurrent)->GetPosPixel();
+ aPos.Y() -= nDelta;
+ (*pCurrent)->SetPosPixel( aPos );
+ }
+#endif
+
+
+ switch ( mrParams.miHTTPConnectionType )
+ {
+ default:
+#ifdef WNT
+ case 0:
+ maSystemBtn.Check( TRUE );
+ break;
+#endif
+ case 1:
+ maDirectBtn.Check( TRUE );
+ break;
+ case 2:
+ maManualBtn.Check( TRUE );
+ break;
+ }
+
+ ManualBtnHdl( 0 );
+ }
+
+ ErrorRepOptionsDialog::~ErrorRepOptionsDialog()
+ {
+ }
+
+ IMPL_LINK( ErrorRepOptionsDialog, ManualBtnHdl, void*, EMPTYARG )
+ {
+ bool bCheck = maManualBtn.IsChecked();
+ maProxyServerFT.Enable( bCheck );
+ maProxyServerEd.Enable( bCheck );
+ maProxyPortFT.Enable( bCheck );
+ maProxyPortEd.Enable( bCheck );
+ return 0;
+ }
+
+ IMPL_LINK( ErrorRepOptionsDialog, OKBtnHdl, void*, EMPTYARG )
+ {
+ if ( maManualBtn.IsChecked() )
+ mrParams.miHTTPConnectionType = 2;
+ else if ( maDirectBtn.IsChecked() )
+ mrParams.miHTTPConnectionType = 1;
+ else if ( maSystemBtn.IsChecked() )
+ mrParams.miHTTPConnectionType = 0;
+
+ mrParams.maHTTPProxyServer = maProxyServerEd.GetText();
+ mrParams.maHTTPProxyPort = maProxyPortEd.GetText();
+
+ EndDialog(DLG_RET_OK);
+ return 0;
+ }
+
+ IMPL_LINK( ErrorRepOptionsDialog, CancelBtnHdl, void*, EMPTYARG )
+ {
+ EndDialog(DLG_RET_CANCEL);
+ return 0;
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // Error Report Edit (MultiLineEdit with fixed font)
+ ///////////////////////////////////////////////////////////////////////
+
+ ErrorRepEdit::ErrorRepEdit( Window* pParent, const ResId& rResId ) :
+ ExtMultiLineEdit( pParent, rResId )
+ {
+ // fixed font for error report
+ Color aColor = GetTextColor();
+
+ Font aFont = OutputDevice::GetDefaultFont(
+ DEFAULTFONT_FIXED, LANGUAGE_SYSTEM, DEFAULTFONT_FLAGS_ONLYONE );
+
+ // Set font color because the default font color is transparent !!!
+ aFont.SetColor( aColor );
+
+ GetTextEngine()->SetFont( aFont );
+
+ // no blinking cursor and a little left margin
+ EnableCursor( FALSE );
+ SetLeftMargin( 4 );
+ }
+
+ ErrorRepEdit::~ErrorRepEdit()
+ {
+ }
+
+ ///////////////////////////////////////////////////////////////////////
+ // Error Report Preview Dialog
+ ///////////////////////////////////////////////////////////////////////
+
+
+ static ::rtl::OUString GetCrashConfigDir()
+ {
+
+#if defined(WNT) || defined(OS2)
+ OUString ustrValue = OUString::createFromAscii("${$BRAND_BASE_DIR/program/bootstrap.ini:UserInstallation}");
+#elif defined( MACOSX )
+ OUString ustrValue = OUString::createFromAscii("~");
+#else
+ OUString ustrValue = OUString::createFromAscii("$SYSUSERCONFIG");
+#endif
+ Bootstrap::expandMacros( ustrValue );
+
+#if defined(WNT) || defined(OS2)
+ ustrValue += OUString::createFromAscii("/user/crashdata");
+#endif
+ return ustrValue;
+ }
+
+#if defined(WNT) || defined(OS2)
+#define CHKFILE "crashdat.chk"
+#define STKFILE "crashdat.stk"
+#define PRVFILE "crashdat.prv"
+#else
+#define CHKFILE ".crash_report_checksum"
+#define STKFILE ".crash_report_frames"
+#define PRVFILE ".crash_report_preview"
+#endif
+
+// static ::rtl::OUString GetChecksumURL()
+// {
+// ::rtl::OUString aURL = GetCrashConfigDir();
+
+// aURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+// aURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CHKFILE ) );
+
+// return aURL;
+// }
+
+// static ::rtl::OUString GetStackURL()
+// {
+// ::rtl::OUString aURL = GetCrashConfigDir();
+
+// aURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+// aURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STKFILE ) );
+
+// return aURL;
+// }
+
+ static ::rtl::OUString GetPreviewURL()
+ {
+ ::rtl::OUString aURL = GetCrashConfigDir();
+
+ aURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ aURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRVFILE ) );
+
+ return aURL;
+ }
+
+ static String LoadCrashFile( const ::rtl::OUString &rURL )
+ {
+ String aFileContent;
+ ::osl::File aFile( rURL );
+
+ printf( "Loading %s:", OString( rURL.getStr(), rURL.getLength(), osl_getThreadTextEncoding() ).getStr() );
+ if ( ::osl::FileBase::E_None == aFile.open( OpenFlag_Read ) )
+ {
+ ::rtl::OString aContent;
+ ::osl::FileBase::RC result;
+ sal_uInt64 aBytesRead;
+
+ do
+ {
+ sal_Char aBuffer[256];
+
+ result = aFile.read( aBuffer, sizeof(aBuffer), aBytesRead );
+
+ if ( ::osl::FileBase::E_None == result )
+ {
+ ::rtl::OString aTemp( aBuffer, static_cast< xub_StrLen >( aBytesRead ) );
+ aContent += aTemp;
+ }
+ } while ( ::osl::FileBase::E_None == result && aBytesRead );
+
+ ::rtl::OUString ustrContent( aContent.getStr(), aContent.getLength(), RTL_TEXTENCODING_UTF8 );
+ aFileContent = ustrContent;
+
+ aFile.close();
+
+ printf( "SUCCEEDED\n" );
+ }
+ else
+ printf( "FAILED\n" );
+
+ return aFileContent;
+ }
+
+
+
+ ErrorRepPreviewDialog::ErrorRepPreviewDialog( Window* _pParent )
+ :ModalDialog ( _pParent, SVX_RES( RID_SVX_MDLG_ERR_REP_PREVIEW ) )
+ ,maContentML( this, SVX_RES( ML_ERRPREVIEW_CONTENT ) )
+ ,maOKBtn( this, SVX_RES( BTN_ERRPREVIEW_OK ) )
+
+ {
+ FreeResource();
+
+ mnMinHeight = ( maContentML.GetSizePixel().Height() / 2 );
+
+ String aPreview = LoadCrashFile( GetPreviewURL() );
+ ErrorRepSendDialog *pMainDlg = (ErrorRepSendDialog *)_pParent;
+
+ String aSeperator = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "\r\n\r\n================\r\n\r\n" ) );
+
+ String aContent = pMainDlg->GetDocType();
+ if ( aContent.Len() > 0 )
+ aContent += aSeperator;
+ aContent += pMainDlg->GetUsing();
+ if ( aContent.Len() > 0 )
+ aContent += aSeperator;
+ aContent += aPreview;
+
+ maContentML.SetText( aContent );
+ }
+
+ ErrorRepPreviewDialog::~ErrorRepPreviewDialog()
+ {
+ }
+
+ void ErrorRepPreviewDialog::Resize()
+ {
+ Size a3Sz = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
+ Size aWinSz = GetSizePixel();
+ Size aBtnSz = maOKBtn.GetSizePixel();
+ Point aEditPnt = maContentML.GetPosPixel();
+
+ long nNewHeight = Max( aWinSz.Height() - aEditPnt.Y() - 3 * a3Sz.Height() - aBtnSz.Height(), mnMinHeight );
+ long nNewWidth = aWinSz.Width() - 4 * a3Sz.Width();
+
+ Size aNewSize( nNewWidth, nNewHeight );
+ maContentML.SetSizePixel( aNewSize );
+ Point aNewPoint( Max( aEditPnt.X() + aNewSize.Width() - aBtnSz.Width(), aEditPnt.X() ),
+ aEditPnt.Y() + aNewSize.Height() + a3Sz.Height() );
+ maOKBtn.SetPosPixel( aNewPoint );
+ }
+ } // namespace DocRecovery
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/docrecovery.hrc b/svx/source/dialog/docrecovery.hrc
new file mode 100644
index 000000000000..851321bc6ad1
--- /dev/null
+++ b/svx/source/dialog/docrecovery.hrc
@@ -0,0 +1,292 @@
+/*************************************************************************
+ *
+ * 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 _SVX_DOCRECOVERY_HRC
+#define _SVX_DOCRECOVERY_HRC
+
+#include <svtools/controldims.hrc>
+
+// general
+
+#define PROGR_HEIGHT (RSC_CD_PUSHBUTTON_HEIGHT)
+
+// TabDialog
+#define TABDLG_WIDTH 290
+#define TABDLG_HEIGHT 278
+
+// TabPage CrashSave
+
+#define WIN_SAVE_TITLE 1
+#define FT_SAVE_TITLE 2
+#define FL_SAVE_TITLE 3
+#define FT_SAVE_DESCR 4
+#define FT_SAVE_FILELIST 5
+#define LB_SAVE_FILELIST 6
+#define CB_SAVE_LAUNCHAUTO 7
+#define FL_SAVE_BOTTOM 8
+#define BT_SAVE_OK 9
+
+
+#define SAVE_WIDTH 290
+#define SAVE_HEIGHT 278
+#define SAVE_TITLEWINHEIGHT 36
+#define SAVE_DESCRHEIGHT 48
+#define SAVE_COL0 (RSC_SP_DLG_INNERBORDER_LEFT)
+#define SAVE_COL2 (SAVE_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT)
+#define SAVE_COL1 (SAVE_COL2-RSC_CD_PUSHBUTTON_WIDTH)
+#define SAVE_ROW0 ((SAVE_TITLEWINHEIGHT-RSC_CD_FIXEDTEXT_HEIGHT)/2)
+#define SAVE_ROW1 (SAVE_TITLEWINHEIGHT)
+#define SAVE_ROW2 (SAVE_ROW1+RSC_SP_CTRL_Y)
+#define SAVE_ROW3 (SAVE_ROW2+3*RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_DESC_Y)
+#define SAVE_ROW4 (SAVE_ROW3+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_DESC_Y)
+#define SAVE_ROW9 (SAVE_HEIGHT-RSC_SP_DLG_INNERBORDER_BOTTOM)
+#define SAVE_ROW8 (SAVE_ROW9-RSC_CD_PUSHBUTTON_HEIGHT)
+#define SAVE_ROW7 (SAVE_ROW8-RSC_SP_CTRL_GROUP_Y-RSC_CD_FIXEDLINE_HEIGHT)
+#define SAVE_ROW6 (SAVE_ROW7-RSC_SP_CTRL_GROUP_Y-RSC_CD_CHECKBOX_HEIGHT)
+#define SAVE_ROW5 (SAVE_ROW6-RSC_SP_CTRL_Y)
+#define SAVE_FILELISTHEIGHT (SAVE_ROW5-SAVE_ROW4)
+#define SAVE_CONTROLWIDTH (SAVE_COL2-SAVE_COL0)
+
+// Save Progress Dialog
+
+#define FT_SAVEPROGR_HINT 1
+#define FT_SAVEPROGR_PROGR 2
+#define WIN_SAVEPROGR_PROGR 3
+
+#define SAVEPROGR_WIDTH 240
+#define SAVEPROGR_COL0 (RSC_SP_DLG_INNERBORDER_LEFT)
+#define SAVEPROGR_COL1 (SAVEPROGR_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT)
+#define SAVEPROGR_ROW0 (RSC_SP_DLG_INNERBORDER_TOP)
+#define SAVEPROGR_ROW1 (SAVEPROGR_ROW0+2*RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_Y)
+#define SAVEPROGR_ROW2 (SAVEPROGR_ROW1+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_DESC_Y)
+#define SAVEPROGR_ROW3 (SAVEPROGR_ROW2+PROGR_HEIGHT)
+#define SAVEPROGR_CONTROLWIDTH (SAVEPROGR_COL1-SAVEPROGR_COL0)
+#define SAVEPROGR_HEIGHT (SAVEPROGR_ROW3+RSC_SP_DLG_INNERBORDER_BOTTOM)
+
+// TabPage Recovery
+
+#define WIN_RECOV_TITLE 1
+#define FT_RECOV_TITLE 2
+#define FL_RECOV_TITLE 3
+#define FT_RECOV_DESCR 4
+#define FT_RECOV_PROGR 5
+#define WIN_RECOV_PROGR 6
+#define FT_RECOV_FILELIST 7
+#define LB_RECOV_FILELIST 8
+#define FL_RECOV_BOTTOM 9
+#define BTN_RECOV_PREV 10
+#define BTN_RECOV_NEXT 11
+#define BTN_RECOV_CANCEL 12
+#define STR_HEADERBAR 13
+#define IMG_GREENCHECK 14
+#define IMG_YELLOWCHECK 15
+#define IMG_REDCROSS 16
+#define IMG_GREENCHECK_HC 17
+#define IMG_YELLOWCHECK_HC 18
+#define IMG_REDCROSS_HC 19
+#define STR_SUCCESSRECOV 20
+#define STR_ORIGDOCRECOV 21
+#define STR_RECOVFAILED 22
+#define STR_RECOVINPROGR 23
+#define STR_NOTRECOVYET 24
+#define STR_RECOVERY_NEXT 25
+#define STR_RECOVERY_INPROGRESS 26
+#define STR_RECOVERY_REPORT 27
+#define STR_RECOVERYONLY_FINISH_DESCR 28
+#define STR_RECOVERYONLY_FINISH 29
+
+#define RECOV_WIDTH SAVE_WIDTH
+#define RECOV_HEIGHT SAVE_HEIGHT
+#define RECOV_TITLEWINHEIGHT SAVE_TITLEWINHEIGHT
+#define RECOV_DESCRHEIGHT 6*RSC_CD_FIXEDTEXT_HEIGHT
+#define RECOV_COL1 (RSC_SP_DLG_INNERBORDER_LEFT)
+#define RECOV_COL2 40
+#define RECOV_COL3 (RECOV_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT)
+#define RECOV_COL_A (RECOV_COL1)
+#define RECOV_COL_B (COL_1+RSC_CD_PUSHBUTTON_WIDTH)
+#define RECOV_COL_G (RECOV_COL3)
+#define RECOV_COL_F (RECOV_COL_G-RSC_CD_PUSHBUTTON_WIDTH)
+#define RECOV_COL_E (RECOV_COL_F-RSC_SP_CTRL_X)
+#define RECOV_COL_D (RECOV_COL_E-RSC_CD_PUSHBUTTON_WIDTH)
+#define RECOV_COL_C (RECOV_COL_D-RSC_CD_PUSHBUTTON_WIDTH)
+#define RECOV_ROW0 ((RECOV_TITLEWINHEIGHT-RSC_CD_FIXEDTEXT_HEIGHT)/2)
+#define RECOV_ROW1 (RECOV_TITLEWINHEIGHT)
+#define RECOV_ROW2 (RECOV_ROW1+RSC_SP_CTRL_Y)
+#define RECOV_ROW3 (RECOV_ROW2+RECOV_DESCRHEIGHT+RSC_SP_CTRL_DESC_Y)
+#define RECOV_ROW4 (RECOV_ROW3+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_DESC_Y)
+#define RECOV_ROW5 (RECOV_ROW4+PROGR_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define RECOV_ROW6 (RECOV_ROW5+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_DESC_Y)
+#define RECOV_ROW10 (RECOV_HEIGHT-RSC_SP_DLG_INNERBORDER_BOTTOM)
+#define RECOV_ROW9 (RECOV_ROW10-RSC_CD_PUSHBUTTON_HEIGHT)
+#define RECOV_ROW8 (RECOV_ROW9-RSC_SP_CTRL_GROUP_Y-RSC_CD_FIXEDLINE_HEIGHT)
+#define RECOV_ROW7 (RECOV_ROW8-RSC_SP_CTRL_GROUP_Y)
+#define RECOV_FILELISTHEIGHT (RECOV_ROW7-RECOV_ROW6)
+#define RECOV_CONTROLWIDTH (SAVE_COL2-SAVE_COL0)
+
+// TabPage Broken Recovery
+
+#define FT_BROKEN_DESCR 1
+#define FT_BROKEN_FILELIST 2
+#define LB_BROKEN_FILELIST 3
+#define FT_BROKEN_SAVEDIR 4
+#define ED_BROKEN_SAVEDIR 5
+#define BTN_BROKEN_SAVEDIR 6
+#define FL_BROKEN_BOTTOM 7
+#define BTN_BROKEN_OK 8
+#define BTN_BROKEN_CANCEL 9
+
+#define BROKEN_WIDTH 210
+#define BROKEN_HEIGHT 160
+#define BROKEN_COL0 (RSC_SP_DLG_INNERBORDER_LEFT)
+#define BROKEN_COL4 (BROKEN_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT)
+#define BROKEN_COL3 (BROKEN_COL4-RSC_CD_PUSHBUTTON_WIDTH)
+#define BROKEN_COL2 (BROKEN_COL3-RSC_SP_CTRL_GROUP_X)
+#define BROKEN_COL1 (BROKEN_COL2-RSC_CD_PUSHBUTTON_WIDTH)
+
+#define BROKEN_ROW0 (RSC_SP_DLG_INNERBORDER_TOP)
+#define BROKEN_ROW1 (BROKEN_ROW0+5*RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define BROKEN_ROW2 (BROKEN_ROW1+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define BROKEN_ROW8 (BROKEN_HEIGHT-RSC_SP_DLG_INNERBORDER_BOTTOM)
+#define BROKEN_ROW7 (BROKEN_ROW8-RSC_CD_PUSHBUTTON_HEIGHT)
+#define BROKEN_ROW6 (BROKEN_ROW7-RSC_SP_FLGR_INNERBORDER_BOTTOM-RSC_CD_FIXEDLINE_HEIGHT)
+#define BROKEN_ROW5 (BROKEN_ROW6-RSC_SP_FLGR_INNERBORDER_TOP-RSC_CD_PUSHBUTTON_HEIGHT)
+#define BROKEN_ROW4 (BROKEN_ROW5-RSC_SP_CTRL_GROUP_Y-RSC_CD_FIXEDTEXT_HEIGHT)
+#define BROKEN_ROW3 (BROKEN_ROW4-RSC_SP_CTRL_GROUP_Y)
+
+#define BROKEN_CONTROLWIDTH (BROKEN_COL4-BROKEN_COL0)
+
+// TabPage Error Report Welcome
+// most defines equal to TabPage Recovery
+
+#define RECOV_DESCR_HEIGHT (RECOV_ROW7-RECOV_ROW2)
+
+// TabPage Error Report Send
+// borrow basic metrics from TabPage Recovery
+
+#define FT_ERRSEND_DOCTYPE 20
+#define ED_ERRSEND_DOCTYPE 21
+#define FT_ERRSEND_USING 22
+#define ML_ERRSEND_USING 23
+#define BTN_ERRSEND_SHOWREP 24
+#define BTN_ERRSEND_OPT 25
+#define CB_ERRSEND_CONTACT 26
+#define FT_ERRSEND_EMAILADDR 27
+#define ED_ERRSEND_EMAILADDR 28
+
+#define ERRSEND_WIDTH (RECOV_WIDTH)
+#define ERRSEND_HEIGHT (RECOV_HEIGHT)
+#define ERRSEND_TITLEWINHEIGHT SAVE_TITLEWINHEIGHT
+
+#define ERRSEND_COL0 (RSC_SP_DLG_INNERBORDER_LEFT)
+#define ERRSEND_COL1 (ERRSEND_COL0+RSC_SP_CHK_TEXTINDENT)
+
+#define ERRSEND_COL4 (ERRSEND_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT)
+#define ERRSEND_COL3 (ERRSEND_COL4-RSC_CD_PUSHBUTTON_WIDTH)
+#define ERRSEND_COL2 (ERRSEND_COL3-RSC_SP_CTRL_X)
+
+#define ERRSEND_COL6 (ERRSEND_COL3-RSC_SP_CTRL_GROUP_X-RSC_CD_PUSHBUTTON_WIDTH)
+#define ERRSEND_COL5 (ERRSEND_COL6-RSC_SP_CTRL_X-RSC_CD_PUSHBUTTON_WIDTH)
+
+#define ERRSEND_CONTROLWIDTH1 (ERRSEND_COL4-ERRSEND_COL0)
+#define ERRSEND_CONTROLWIDTH2 (ERRSEND_COL2-ERRSEND_COL0)
+#define ERRSEND_CONTROLWIDTH3 (ERRSEND_COL2-ERRSEND_COL1)
+
+#define ERRSEND_ROW0 ((ERRSEND_TITLEWINHEIGHT-RSC_CD_FIXEDTEXT_HEIGHT)/2)
+#define ERRSEND_ROW1 (ERRSEND_TITLEWINHEIGHT)
+#define ERRSEND_ROW2 (ERRSEND_ROW1+RSC_SP_CTRL_Y)
+#define ERRSEND_ROW3 (ERRSEND_ROW2+3*RSC_CD_FIXEDTEXT_HEIGHT)
+#define ERRSEND_ROW4 (ERRSEND_ROW3+RSC_SP_CTRL_GROUP_Y)
+#define ERRSEND_ROW5 (ERRSEND_ROW4+2*RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define ERRSEND_ROW6 (ERRSEND_ROW5+RSC_CD_TEXTBOX_HEIGHT)
+#define ERRSEND_ROW7 (ERRSEND_ROW6+RSC_SP_CTRL_Y)
+#define ERRSEND_ROW8 (ERRSEND_ROW7+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define ERRSEND_ROW9 (ERRSEND_ROW8+RSC_CD_PUSHBUTTON_HEIGHT)
+#define ERRSEND_ROW10 (ERRSEND_ROW9+RSC_SP_CTRL_GROUP_Y)
+#define ERRSEND_ROW11 (ERRSEND_ROW10+RSC_CD_PUSHBUTTON_HEIGHT)
+
+#define ERRSEND_ROW16 (ERRSEND_HEIGHT-RSC_SP_DLG_INNERBORDER_RIGHT-RSC_CD_PUSHBUTTON_HEIGHT)
+#define ERRSEND_ROW15 (ERRSEND_ROW16-RSC_SP_CTRL_GROUP_Y-RSC_CD_FIXEDLINE_HEIGHT)
+#define ERRSEND_ROW14 (ERRSEND_ROW15-RSC_SP_CTRL_GROUP_Y-RSC_CD_TEXTBOX_HEIGHT)
+#define ERRSEND_ROW13 (ERRSEND_ROW14-RSC_SP_CTRL_GROUP_Y-RSC_CD_FIXEDTEXT_HEIGHT)
+#define ERRSEND_ROW12 (ERRSEND_ROW13-RSC_SP_CTRL_GROUP_Y-RSC_CD_CHECKBOX_HEIGHT)
+
+// Error Report Options Dialog
+
+#define ERROPT_WIDTH 220
+#define ERROPT_HEIGHT 180
+
+#define FL_ERROPT_PROXY 1
+#define BTN_ERROPT_SYSTEM 2
+#define BTN_ERROPT_DIRECT 3
+#define BTN_ERROPT_MANUAL 4
+#define FT_ERROPT_PROXYSERVER 5
+#define ED_ERROPT_PROXYSERVER 6
+#define FT_ERROPT_PROXYPORT 7
+#define ED_ERROPT_PROXYPORT 8
+#define FT_ERROPT_DESCRIPTION 9
+#define FL_ERROPT_BUTTONS 10
+#define BTN_ERROPT_OK 11
+#define BTN_ERROPT_CANCEL 12
+
+#define ERROPT_COLA (RSC_SP_DLG_INNERBORDER_LEFT)
+#define ERROPT_COLB (ERROPT_COLA + RSC_SP_CTRL_X)
+#define ERROPT_COLC (ERROPT_COLB + RSC_SP_CHK_TEXTINDENT)
+
+#define ERROPT_COLF (ERROPT_WIDTH - RSC_SP_DLG_INNERBORDER_RIGHT)
+#define ERROPT_COLE (ERROPT_COLF - RSC_CD_PUSHBUTTON_WIDTH)
+#define ERROPT_COLD (ERROPT_COLE - RSC_SP_CTRL_DESC_X - RSC_CD_PUSHBUTTON_WIDTH)
+
+#define ERROPT_ROW0 (RSC_SP_DLG_INNERBORDER_TOP)
+#define ERROPT_ROW1 (ERROPT_ROW0 + RSC_CD_FIXEDLINE_HEIGHT + RSC_SP_CTRL_Y)
+#define ERROPT_ROW2 (ERROPT_ROW1 + RSC_CD_RADIOBUTTON_HEIGHT + RSC_SP_CTRL_GROUP_Y)
+#define ERROPT_ROW3 (ERROPT_ROW2 + RSC_CD_RADIOBUTTON_HEIGHT + RSC_SP_CTRL_GROUP_Y)
+#define ERROPT_ROW4 (ERROPT_ROW3 + RSC_CD_RADIOBUTTON_HEIGHT + RSC_SP_CTRL_GROUP_Y)
+#define ERROPT_ROW5 (ERROPT_ROW4 + RSC_CD_FIXEDTEXT_HEIGHT + RSC_SP_CTRL_DESC_Y)
+#define ERROPT_ROW6 (ERROPT_ROW5 + RSC_CD_TEXTBOX_HEIGHT + RSC_SP_CTRL_Y)
+
+#define ERROPT_ROW9 (ERROPT_HEIGHT - RSC_SP_DLG_INNERBORDER_BOTTOM - RSC_CD_PUSHBUTTON_HEIGHT)
+#define ERROPT_ROW8 (ERROPT_ROW9 - RSC_SP_CTRL_DESC_Y - RSC_CD_FIXEDLINE_HEIGHT)
+#define ERROPT_ROW7 (ERROPT_ROW8 - RSC_SP_CTRL_DESC_Y)
+
+#define ERROPT_SERVER_WIDTH 150
+#define ERROPT_PORT_WIDTH (ERROPT_COLF-ERROPT_COLC-RSC_SP_CTRL_GROUP_X-ERROPT_SERVER_WIDTH)
+
+// Error Report Preview Dialog
+
+#define ERRPREVIEW_WIDTH 300
+#define ERRPREVIEW_HEIGHT 200
+
+#define ML_ERRPREVIEW_CONTENT 1
+#define BTN_ERRPREVIEW_OK 2
+#define ERRPREVIEW_COLA (RSC_SP_DLG_INNERBORDER_LEFT)
+#define ERRPREVIEW_COLB (ERRPREVIEW_WIDTH - RSC_SP_DLG_INNERBORDER_RIGHT - RSC_CD_PUSHBUTTON_WIDTH)
+#define ERRPREVIEW_COLC (ERRPREVIEW_WIDTH - RSC_SP_DLG_INNERBORDER_RIGHT)
+#define ERRPREVIEW_ROW0 (RSC_SP_DLG_INNERBORDER_TOP)
+#define ERRPREVIEW_ROW1 (ERRPREVIEW_ROW2 - RSC_SP_CTRL_Y)
+#define ERRPREVIEW_ROW2 (ERRPREVIEW_HEIGHT - RSC_SP_DLG_INNERBORDER_BOTTOM - RSC_CD_PUSHBUTTON_HEIGHT)
+
+#endif
diff --git a/svx/source/dialog/docrecovery.src b/svx/source/dialog/docrecovery.src
new file mode 100644
index 000000000000..32c356003128
--- /dev/null
+++ b/svx/source/dialog/docrecovery.src
@@ -0,0 +1,635 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+#include "helpid.hrc"
+
+#include "docrecovery.hrc"
+
+TabDialog RID_SVX_TABDLG_DOCRECOVERY
+{
+ Size = MAP_APPFONT( TABDLG_WIDTH, TABDLG_HEIGHT );
+ HelpId = HID_SVX_TABDLG_DOCRECOVERY;
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Moveable = TRUE;
+ Closeable = FALSE;
+ Text = "%PRODUCTNAME %PRODUCTVERSION";
+};
+
+TabPage RID_SVXPAGE_DOCRECOVERY_SAVE
+{
+ Size = MAP_APPFONT( SAVE_WIDTH, SAVE_HEIGHT );
+ HelpId = HID_SVX_TP_DOCRECOVERY_SAVE;
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Hide = TRUE;
+ Window WIN_SAVE_TITLE
+ {
+ Pos = MAP_APPFONT( 0 , 0 );
+ Size = MAP_APPFONT( SAVE_WIDTH, SAVE_ROW1 );
+ };
+ FixedText FT_SAVE_TITLE
+ {
+ Pos = MAP_APPFONT( SAVE_COL0 , SAVE_ROW0 );
+ Size = MAP_APPFONT( SAVE_CONTROLWIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "%PRODUCTNAME Document Recovery";
+ };
+ FixedLine FL_SAVE_TITLE
+ {
+ Pos = MAP_APPFONT( 0 , SAVE_ROW1 );
+ Size = MAP_APPFONT( SAVE_WIDTH, 2 );
+ };
+ FixedText FT_SAVE_DESCR
+ {
+ Pos = MAP_APPFONT( SAVE_COL0 , SAVE_ROW2 );
+ Size = MAP_APPFONT( SAVE_CONTROLWIDTH, (SAVE_ROW3-SAVE_ROW2-RSC_SP_CTRL_DESC_Y) );
+ WordBreak = TRUE;
+ Text[ en-US ] = "Due to an unexpected error, %PRODUCTNAME crashed. All the files you were working on will now be saved. The next time %PRODUCTNAME is launched, your files will be recovered automatically.";
+ };
+ FixedText FT_SAVE_FILELIST
+ {
+ Pos = MAP_APPFONT( SAVE_COL0 , SAVE_ROW3 );
+ Size = MAP_APPFONT( SAVE_CONTROLWIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "The following files will be recovered:";
+ };
+ ListBox LB_SAVE_FILELIST
+ {
+ Pos = MAP_APPFONT( SAVE_COL0 , SAVE_ROW4 );
+ Size = MAP_APPFONT( SAVE_CONTROLWIDTH, SAVE_FILELISTHEIGHT );
+ Border = TRUE;
+ TabStop = TRUE;
+ };
+ FixedLine FL_SAVE_BOTTOM
+ {
+ Pos = MAP_APPFONT( 0 , SAVE_ROW7 );
+ Size = MAP_APPFONT( SAVE_WIDTH, RSC_CD_FIXEDLINE_HEIGHT );
+ };
+ OKButton BT_SAVE_OK
+ {
+ Pos = MAP_APPFONT( SAVE_COL1 , SAVE_ROW8 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ DefButton = TRUE;
+ };
+};
+
+ModalDialog RID_SVX_MDLG_DOCRECOVERY_PROGR
+{
+ Size = MAP_APPFONT( SAVEPROGR_WIDTH, SAVEPROGR_HEIGHT );
+ HelpId = HID_SVX_MDLG_DOCRECOVERY_PROGR;
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Moveable = TRUE;
+ Closeable = FALSE;
+ Text = "%PRODUCTNAME %PRODUCTVERSION";
+
+ FixedText FT_SAVEPROGR_HINT
+ {
+ Pos = MAP_APPFONT( SAVEPROGR_COL0, SAVEPROGR_ROW0 );
+ Size = MAP_APPFONT( SAVEPROGR_CONTROLWIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "Documents are being saved.";
+ };
+ FixedText FT_SAVEPROGR_PROGR
+ {
+ Pos = MAP_APPFONT( SAVEPROGR_COL0, SAVEPROGR_ROW1 );
+ Size = MAP_APPFONT( SAVEPROGR_CONTROLWIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "Progress of saving: ";
+ };
+ Window WIN_SAVEPROGR_PROGR
+ {
+ Pos = MAP_APPFONT( SAVEPROGR_COL0, SAVEPROGR_ROW2 );
+ Size = MAP_APPFONT( SAVEPROGR_CONTROLWIDTH, PROGR_HEIGHT );
+ Border = TRUE;
+ };
+};
+
+TabPage RID_SVXPAGE_DOCRECOVERY_RECOVER
+{
+ Size = MAP_APPFONT( RECOV_WIDTH, RECOV_HEIGHT );
+ HelpId = HID_SVX_TP_DOCRECOVERY_RECOVER;
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Hide = TRUE;
+ Window WIN_RECOV_TITLE
+ {
+ Pos = MAP_APPFONT( 0 , 0 );
+ Size = MAP_APPFONT( RECOV_WIDTH, RECOV_TITLEWINHEIGHT );
+ };
+ FixedText FT_RECOV_TITLE
+ {
+ Pos = MAP_APPFONT( RECOV_COL1, RECOV_ROW0 );
+ Size = MAP_APPFONT( RECOV_CONTROLWIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "%PRODUCTNAME Document Recovery";
+ };
+ FixedLine FL_RECOV_TITLE
+ {
+ Pos = MAP_APPFONT( 0 , RECOV_TITLEWINHEIGHT );
+ Size = MAP_APPFONT( RECOV_WIDTH, 2 );
+ };
+ FixedText FT_RECOV_DESCR
+ {
+ Pos = MAP_APPFONT( RECOV_COL1, RECOV_ROW2 );
+ Size = MAP_APPFONT( RECOV_CONTROLWIDTH, RECOV_DESCRHEIGHT );
+ WordBreak = TRUE;
+ Text[ en-US ] = "Press 'Start Recovery' to start the recovery process of the documents listed below.\n\nThe 'Status' column shows whether the document could be recovered.";
+ };
+ FixedText FT_RECOV_PROGR
+ {
+ Pos = MAP_APPFONT( RECOV_COL1, RECOV_ROW3 );
+ Size = MAP_APPFONT( RECOV_CONTROLWIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "Recovering document:";
+ };
+ Window WIN_RECOV_PROGR
+ {
+ Pos = MAP_APPFONT( RECOV_COL1, RECOV_ROW4 );
+ Size = MAP_APPFONT( RECOV_CONTROLWIDTH, PROGR_HEIGHT );
+ Border = TRUE;
+ };
+ FixedText FT_RECOV_FILELIST
+ {
+ Pos = MAP_APPFONT( RECOV_COL1, RECOV_ROW5 );
+ Size = MAP_APPFONT( RECOV_CONTROLWIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "Status of recovered documents:";
+ };
+ String STR_HEADERBAR
+ {
+ Text[ en-US ] = "Document Name\tStatus";
+ };
+ Control LB_RECOV_FILELIST
+ {
+ Pos = MAP_APPFONT( RECOV_COL1, RECOV_ROW6 );
+ Size = MAP_APPFONT( RECOV_CONTROLWIDTH, RECOV_FILELISTHEIGHT );
+ Border = TRUE;
+ SVLook = TRUE;
+ };
+ FixedLine FL_RECOV_BOTTOM
+ {
+ Pos = MAP_APPFONT( 0 , RECOV_ROW8 );
+ Size = MAP_APPFONT( RECOV_WIDTH, RSC_CD_FIXEDLINE_HEIGHT );
+ };
+ PushButton BTN_RECOV_NEXT
+ {
+ Pos = MAP_APPFONT( RECOV_COL_C, RECOV_ROW9 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH*2, RSC_CD_PUSHBUTTON_HEIGHT );
+ Text[ en-US ] = "~Start Recovery >";
+ DefButton = TRUE;
+ };
+ String STR_RECOVERY_NEXT
+ {
+ Text[ en-US ] = "~Next >";
+ };
+ CancelButton BTN_RECOV_CANCEL
+ {
+ Pos = MAP_APPFONT( RECOV_COL_F, RECOV_ROW9 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ };
+ Image IMG_GREENCHECK
+ {
+ ImageBitmap = Bitmap { File = "nu01.png"; };
+ };
+ Image IMG_GREENCHECK_HC
+ {
+ ImageBitmap = Bitmap { File = "nuh01.png"; };
+ };
+ Image IMG_YELLOWCHECK
+ {
+ ImageBitmap = Bitmap { File = "nu04.png"; };
+ };
+ Image IMG_YELLOWCHECK_HC
+ {
+ ImageBitmap = Bitmap { File = "nuh04.png"; };
+ };
+ Image IMG_REDCROSS
+ {
+ ImageBitmap = Bitmap { File = "nu02.png"; };
+ };
+ Image IMG_REDCROSS_HC
+ {
+ ImageBitmap = Bitmap { File = "nuh02.png"; };
+ };
+ String STR_SUCCESSRECOV
+ {
+ Text[ en-US ] = "Successfully recovered";
+ };
+ String STR_ORIGDOCRECOV
+ {
+ Text[ en-US ] = "Original document recovered";
+ };
+ String STR_RECOVFAILED
+ {
+ Text[ en-US ] = "Recovery failed";
+ };
+ String STR_RECOVINPROGR
+ {
+ Text[ en-US ] = "Recovery in progress";
+ };
+ String STR_NOTRECOVYET
+ {
+ Text[ en-US ] = "Not recovered yet";
+ };
+ String STR_RECOVERY_INPROGRESS
+ {
+ Text[ en-US ] = "%PRODUCTNAME %PRODUCTVERSION will start to recover your documents. Depending on the size of the documents this process can take some time." ;
+ };
+ String STR_RECOVERY_REPORT
+ {
+ Text[ en-US ] = "A report of the crash was created to help us identify the reason why %PRODUCTNAME crashed. Click 'Next' to get to the Error Report Tool or press 'Cancel' to skip this step." ;
+ };
+ String STR_RECOVERYONLY_FINISH_DESCR
+ {
+ Text[ en-US ] = "Recovery of your documents was finished.\nClick 'Finish' to see your documents.";
+ };
+ String STR_RECOVERYONLY_FINISH
+ {
+ Text[ en-US ] = "~Finish";
+ };
+};
+
+QueryBox RID_SVXQB_EXIT_RECOVERY
+{
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_YES ;
+ Message [ en-US ] = "Are you sure you want to cancel the %PRODUCTNAME document recovery?";
+};
+
+ModalDialog RID_SVX_MDLG_DOCRECOVERY_BROKEN
+{
+ Size = MAP_APPFONT( BROKEN_WIDTH, BROKEN_HEIGHT );
+ HelpId = HID_SVX_MDLG_DOCRECOVERY_BROKEN;
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Moveable = TRUE;
+ Text = "%PRODUCTNAME %PRODUCTVERSION";
+
+ FixedText FT_BROKEN_DESCR
+ {
+ Pos = MAP_APPFONT( BROKEN_COL0, BROKEN_ROW0 );
+ Size = MAP_APPFONT( BROKEN_CONTROLWIDTH, (5*RSC_CD_FIXEDTEXT_HEIGHT) );
+ WordBreak = TRUE;
+ Text[ en-US ] = "The automatic recovery process was interrupted.\n\nThe documents listed below will be saved in the folder noted below if you click 'Save'. Click 'Cancel' to close the wizard without saving the documents.";
+ };
+ FixedText FT_BROKEN_FILELIST
+ {
+ Pos = MAP_APPFONT( BROKEN_COL0, BROKEN_ROW1 );
+ Size = MAP_APPFONT( BROKEN_CONTROLWIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "Documents";
+ };
+ ListBox LB_BROKEN_FILELIST
+ {
+ Pos = MAP_APPFONT( BROKEN_COL0, BROKEN_ROW2 );
+ Size = MAP_APPFONT( BROKEN_CONTROLWIDTH, (BROKEN_ROW3-BROKEN_ROW2) );
+ Border = TRUE;
+ TabStop = TRUE;
+ };
+ FixedText FT_BROKEN_SAVEDIR
+ {
+ Pos = MAP_APPFONT( BROKEN_COL0, BROKEN_ROW4 + 1 ); // see ED_BROKEN_SAVEDIR
+ Size = MAP_APPFONT( BROKEN_CONTROLWIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "~Save to";
+ };
+ Edit ED_BROKEN_SAVEDIR
+ {
+ Pos = MAP_APPFONT( BROKEN_COL0, BROKEN_ROW5 + 1 ); // center to pushbutton
+ Size = MAP_APPFONT( BROKEN_COL2 - BROKEN_COL0, RSC_CD_TEXTBOX_HEIGHT );
+ Border = TRUE;
+ };
+ PushButton BTN_BROKEN_SAVEDIR
+ {
+ Pos = MAP_APPFONT( BROKEN_COL3, BROKEN_ROW5 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ Text [ en-US ] = "Chan~ge...";
+ };
+ FixedLine FL_BROKEN_BOTTOM
+ {
+ Pos = MAP_APPFONT( 0 , BROKEN_ROW6 );
+ Size = MAP_APPFONT( BROKEN_WIDTH, RSC_CD_FIXEDLINE_HEIGHT );
+ };
+ OKButton BTN_BROKEN_OK
+ {
+ Pos = MAP_APPFONT( BROKEN_COL1, BROKEN_ROW7 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ DefButton = TRUE;
+ Text [ en-US ] = "~Save";
+ };
+ CancelButton BTN_BROKEN_CANCEL
+ {
+ Pos = MAP_APPFONT( BROKEN_COL3, BROKEN_ROW7 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ };
+};
+
+TabPage RID_SVXPAGE_ERR_REP_WELCOME
+{
+ Size = MAP_APPFONT( RECOV_WIDTH, RECOV_HEIGHT );
+ HelpId = HID_SVX_TP_ERR_REP_WELCOME;
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Hide = TRUE;
+ Window WIN_RECOV_TITLE
+ {
+ Pos = MAP_APPFONT( 0 , 0 );
+ Size = MAP_APPFONT( RECOV_WIDTH, RECOV_TITLEWINHEIGHT );
+ };
+ FixedText FT_RECOV_TITLE
+ {
+ Pos = MAP_APPFONT( RECOV_COL1, RECOV_ROW0 );
+ Size = MAP_APPFONT( RECOV_CONTROLWIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "Welcome to the %PRODUCTNAME %PRODUCTVERSION Error Report";
+ };
+ FixedLine FL_RECOV_TITLE
+ {
+ Pos = MAP_APPFONT( 0 , RECOV_TITLEWINHEIGHT );
+ Size = MAP_APPFONT( RECOV_WIDTH, 2 );
+ };
+ FixedText FT_RECOV_DESCR
+ {
+ Pos = MAP_APPFONT( RECOV_COL1, RECOV_ROW2 );
+ Size = MAP_APPFONT( RECOV_CONTROLWIDTH, (RECOV_ROW7-RECOV_ROW2-RSC_SP_CTRL_Y) );
+ WordBreak = TRUE;
+ Text[ en-US ] = "This error report tool gathers information about how %PRODUCTNAME is working and sends it to Oracle to help improve future versions.\n\nIt's easy - just send the report without any further effort on your part by clicking 'Send' in the next dialog, or you can briefly describe how the error occurred and then click 'Send'. If you want to see the report, click the 'Show Report' button. No data will be sent if you click 'Do Not Send'.\n\nCustomer Privacy\nThe information gathered is limited to data concerning the state of %PRODUCTNAME %PRODUCTVERSION when the error occurred. Other information about passwords or document contents is not collected.\n\nThe information will only be used to improve the quality of %PRODUCTNAME and will not be shared with third parties.\nFor more information on Oracle's privacy policy, visit\nwww.oracle.com/html/services-privacy-policy.html";
+ };
+ FixedLine FL_RECOV_BOTTOM
+ {
+ Pos = MAP_APPFONT( 0 , RECOV_ROW8 );
+ Size = MAP_APPFONT( RECOV_WIDTH, RSC_CD_FIXEDLINE_HEIGHT );
+ };
+ PushButton BTN_RECOV_PREV
+ {
+ Pos = MAP_APPFONT( RECOV_COL_C, RECOV_ROW9 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ Text[ en-US ] = "< ~Back";
+ };
+ OKButton BTN_RECOV_NEXT
+ {
+ Pos = MAP_APPFONT( RECOV_COL_D, RECOV_ROW9 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ Text[ en-US ] = "~Next >";
+ DefButton = TRUE;
+ };
+ CancelButton BTN_RECOV_CANCEL
+ {
+ Pos = MAP_APPFONT( RECOV_COL_F, RECOV_ROW9 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ };
+};
+
+TabPage RID_SVXPAGE_ERR_REP_SEND
+{
+ Size = MAP_APPFONT( ERRSEND_WIDTH, ERRSEND_HEIGHT );
+ HelpId = HID_SVX_TP_ERR_REP_SEND;
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Hide = TRUE;
+ Window WIN_RECOV_TITLE
+ {
+ Pos = MAP_APPFONT( 0 , 0 );
+ Size = MAP_APPFONT( ERRSEND_WIDTH, RECOV_TITLEWINHEIGHT );
+ };
+ FixedText FT_RECOV_TITLE
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL0, ERRSEND_ROW0 );
+ Size = MAP_APPFONT( ERRSEND_CONTROLWIDTH1, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "Sending the Error Report";
+ };
+ FixedLine FL_RECOV_TITLE
+ {
+ Pos = MAP_APPFONT( 0 , RECOV_TITLEWINHEIGHT );
+ Size = MAP_APPFONT( RECOV_WIDTH, 2 );
+ };
+ FixedText FT_RECOV_DESCR
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL0, ERRSEND_ROW2 );
+ Size = MAP_APPFONT( ERRSEND_CONTROLWIDTH2, (ERRSEND_ROW3-ERRSEND_ROW2) );
+ WordBreak = TRUE;
+ Text[ en-US ] = "In the spaces below, you can enter a title for your error report and describe the action you were trying to carry out when the error occurred. Then click 'Send'.";
+ };
+
+ FixedText FT_ERRSEND_DOCTYPE
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL0, ERRSEND_ROW4 );
+ Size = MAP_APPFONT( ERRSEND_CONTROLWIDTH2, 2*RSC_CD_FIXEDTEXT_HEIGHT );
+ WordBreak = TRUE;
+ Text[ en-US ] = "~Which type of document (e.g. presentation) were you using when the error occurred?";
+ };
+ Edit ED_ERRSEND_DOCTYPE
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL0, ERRSEND_ROW5 );
+ Size = MAP_APPFONT( ERRSEND_CONTROLWIDTH2, RSC_CD_TEXTBOX_HEIGHT );
+ Border = TRUE;
+ };
+ FixedText FT_ERRSEND_USING
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL0, ERRSEND_ROW7 );
+ Size = MAP_APPFONT( ERRSEND_CONTROLWIDTH2, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "~How were you using %PRODUCTNAME when the error occurred? (optional)";
+ };
+ MultiLineEdit ML_ERRSEND_USING
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL0, ERRSEND_ROW8 );
+ Size = MAP_APPFONT( ERRSEND_CONTROLWIDTH2, (ERRSEND_ROW12-ERRSEND_ROW8-RSC_SP_CTRL_Y) );
+ VScroll = TRUE;
+ IgnoreTab = TRUE;
+ Border = TRUE;
+ };
+ PushButton BTN_ERRSEND_SHOWREP
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL3, ERRSEND_ROW8 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ Text[ en-US ] = "Show ~Report";
+ };
+ PushButton BTN_ERRSEND_OPT
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL3, ERRSEND_ROW10 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ Text[ en-US ] = "~Options...";
+ };
+ CheckBox CB_ERRSEND_CONTACT
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL0, ERRSEND_ROW12 );
+ Size = MAP_APPFONT( ERRSEND_CONTROLWIDTH2, RSC_CD_CHECKBOX_HEIGHT );
+ Check = FALSE;
+ Text[ en-US ] = "~I allow Oracle to contact me regarding this report.";
+ };
+ FixedText FT_ERRSEND_EMAILADDR
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL1, ERRSEND_ROW13 );
+ Size = MAP_APPFONT( ERRSEND_CONTROLWIDTH3, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "~Please enter your e-mail address";
+ };
+ Edit ED_ERRSEND_EMAILADDR
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL1, ERRSEND_ROW14 );
+ Size = MAP_APPFONT( ERRSEND_CONTROLWIDTH3, RSC_CD_TEXTBOX_HEIGHT );
+ Border = TRUE;
+ };
+ FixedLine FL_RECOV_BOTTOM
+ {
+ Pos = MAP_APPFONT( 0 , ERRSEND_ROW15 );
+ Size = MAP_APPFONT( ERRSEND_WIDTH, RSC_CD_FIXEDLINE_HEIGHT );
+ };
+ PushButton BTN_RECOV_PREV
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL5, ERRSEND_ROW16 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ Text[ en-US ] = "< ~Back";
+ };
+ OKButton BTN_RECOV_NEXT
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL6, ERRSEND_ROW16 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ Text[ en-US ] = "S~end";
+ DefButton = TRUE;
+ };
+ CancelButton BTN_RECOV_CANCEL
+ {
+ Pos = MAP_APPFONT( ERRSEND_COL3, ERRSEND_ROW16 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ Text[ en-US ] = "Do ~Not Send";
+ };
+};
+
+ModalDialog RID_SVX_MDLG_ERR_REP_OPTIONS
+{
+ Size = MAP_APPFONT( ERROPT_WIDTH, ERROPT_HEIGHT );
+ HelpId = HID_SVX_MDLG_ERR_REP_OPTIONS;
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Moveable = TRUE;
+ Text[ en-US ] = "Options";
+
+ FixedLine FL_ERROPT_PROXY
+ {
+ Pos = MAP_APPFONT( ERROPT_COLA, ERROPT_ROW0 );
+ Size = MAP_APPFONT( ERROPT_COLF - ERROPT_COLA, RSC_CD_FIXEDLINE_HEIGHT );
+ Text[ en-US ] = "Proxy settings";
+ };
+
+ RadioButton BTN_ERROPT_SYSTEM
+ {
+ Pos = MAP_APPFONT( ERROPT_COLB, ERROPT_ROW1 );
+ Size = MAP_APPFONT( ERROPT_COLF - ERROPT_COLB, RSC_CD_RADIOBUTTON_HEIGHT );
+ Text[ en-US ] = "Use ~system settings";
+ };
+
+ RadioButton BTN_ERROPT_DIRECT
+ {
+ Pos = MAP_APPFONT( ERROPT_COLB, ERROPT_ROW2 );
+ Size = MAP_APPFONT( ERROPT_COLF - ERROPT_COLB, RSC_CD_RADIOBUTTON_HEIGHT );
+ Text[ en-US ] = "Use ~direct connection to the Internet";
+ };
+
+ RadioButton BTN_ERROPT_MANUAL
+ {
+ Pos = MAP_APPFONT( ERROPT_COLB, ERROPT_ROW3 );
+ Size = MAP_APPFONT( ERROPT_COLF - ERROPT_COLB, RSC_CD_RADIOBUTTON_HEIGHT );
+ Text[ en-US ] = "Use ~manual settings";
+ };
+
+ FixedText FT_ERROPT_PROXYSERVER
+ {
+ Pos = MAP_APPFONT( ERROPT_COLC, ERROPT_ROW4 );
+ Size = MAP_APPFONT( ERROPT_SERVER_WIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "HT~TP Proxy";
+ };
+
+ Edit ED_ERROPT_PROXYSERVER
+ {
+ Pos = MAP_APPFONT( ERROPT_COLC, ERROPT_ROW5 );
+ Size = MAP_APPFONT( ERROPT_SERVER_WIDTH, RSC_CD_TEXTBOX_HEIGHT );
+ Border = TRUE;
+ };
+
+ FixedText FT_ERROPT_PROXYPORT
+ {
+ Pos = MAP_APPFONT( ERROPT_COLC + ERROPT_SERVER_WIDTH + RSC_SP_CTRL_GROUP_X, ERROPT_ROW4 );
+ Size = MAP_APPFONT( ERROPT_PORT_WIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
+ Text[ en-US ] = "~Port";
+ };
+
+ Edit ED_ERROPT_PROXYPORT
+ {
+ Pos = MAP_APPFONT( ERROPT_COLC + ERROPT_SERVER_WIDTH + RSC_SP_CTRL_GROUP_X, ERROPT_ROW5 );
+ Size = MAP_APPFONT( ERROPT_PORT_WIDTH, RSC_CD_TEXTBOX_HEIGHT );
+ Border = TRUE;
+ };
+
+ FixedText FT_ERROPT_DESCRIPTION
+ {
+ Pos = MAP_APPFONT( ERROPT_COLB, ERROPT_ROW6 );
+ Size = MAP_APPFONT( ERROPT_COLF - ERROPT_COLB, ERROPT_ROW7 - ERROPT_ROW6 );
+ WordBreak = TRUE;
+ Text[ en-US ] = "The %PRODUCTNAME Error Report tool needs to be connected to the Internet to be able to send error reports.\nCompanies often use proxy servers in conjunction with a firewall to protect the network.\nIf this applies to your situation, you have to specify the address and port for the server.";
+ };
+
+ FixedLine FL_ERROPT_BUTTONS
+ {
+ Pos = MAP_APPFONT( 0, ERROPT_ROW8 );
+ Size = MAP_APPFONT( ERROPT_WIDTH, RSC_CD_FIXEDLINE_HEIGHT );
+ };
+
+ OKButton BTN_ERROPT_OK
+ {
+ Pos = MAP_APPFONT( ERROPT_COLD, ERROPT_ROW9 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ DefButton = TRUE;
+ };
+
+ CancelButton BTN_ERROPT_CANCEL
+ {
+ Pos = MAP_APPFONT( ERROPT_COLE, ERROPT_ROW9 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ };
+};
+
+
+ModalDialog RID_SVX_MDLG_ERR_REP_PREVIEW
+{
+ Size = MAP_APPFONT( ERRPREVIEW_WIDTH, ERRPREVIEW_HEIGHT );
+ HelpId = HID_SVX_MDLG_ERR_REP_PREVIEW;
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Moveable = TRUE;
+ Sizeable = TRUE;
+ Text[ en-US ] = "Error Report";
+
+ MultiLineEdit ML_ERRPREVIEW_CONTENT
+ {
+ Pos = MAP_APPFONT( ERRPREVIEW_COLA, ERRPREVIEW_ROW0 );
+ Size = MAP_APPFONT( ERRPREVIEW_COLC - ERRPREVIEW_COLA, ERRPREVIEW_ROW1 - ERRPREVIEW_ROW0 );
+ VScroll = TRUE;
+ HScroll = TRUE;
+ ReadOnly = TRUE;
+ Border = TRUE;
+ };
+
+ OKButton BTN_ERRPREVIEW_OK
+ {
+ Pos = MAP_APPFONT( ERRPREVIEW_COLB, ERRPREVIEW_ROW2 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ DefButton = TRUE;
+ };
+}; \ No newline at end of file
diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx
new file mode 100644
index 000000000000..369e0c7cf33b
--- /dev/null
+++ b/svx/source/dialog/fntctrl.cxx
@@ -0,0 +1,852 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <sfx2/viewsh.hxx> // SfxViewShell
+#include <sfx2/printer.hxx> // Printer
+#include <vcl/metric.hxx>
+#include <vcl/svapp.hxx>
+#include <unicode/uchar.h>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/i18n/ScriptType.hdl>
+
+#ifndef _SVSTDARR_HXX
+#define _SVSTDARR_USHORTS
+#define _SVSTDARR_ULONGS
+#define _SVSTDARR_XUB_STRLEN
+#include <svl/svstdarr.hxx>
+#endif
+#include <svtools/colorcfg.hxx>
+
+#include <svx/fntctrl.hxx>
+#include <svx/dialogs.hrc>
+#define TEXT_WIDTH 20
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using ::com::sun::star::i18n::XBreakIterator;
+
+// -----------------------------------------------------------------------
+// small helper functions to set fonts
+// -----------------------------------------------------------------------
+namespace
+{
+ void scaleFontWidth(Font& _rFont,const OutputDevice& rOutDev,long& _n100PercentFont)
+ {
+ _rFont.SetWidth( 0 );
+ _n100PercentFont = rOutDev.GetFontMetric( _rFont ).GetWidth();
+ }
+ // -----------------------------------------------------------------------
+ void initFont(Font& _rFont)
+ {
+ _rFont.SetTransparent(TRUE);
+ _rFont.SetAlign(ALIGN_BASELINE);
+ }
+ // -----------------------------------------------------------------------
+ void setFontSize(Font& _rFont)
+ {
+ Size aSize( _rFont.GetSize() );
+ aSize.Height() = ( aSize.Height() * 3 ) / 5;
+ aSize.Width() = ( aSize.Width() * 3 ) / 5;
+ _rFont.SetSize( aSize );
+ }
+ // -----------------------------------------------------------------------
+ void calcFontHeightAnyAscent(OutputDevice* _pWin,Font& _rFont,long& _nHeight,long& _nAscent)
+ {
+ if ( !_nHeight )
+ {
+ _pWin->SetFont( _rFont );
+ FontMetric aMetric( _pWin->GetFontMetric() );
+ _nHeight = aMetric.GetLineHeight();
+ _nAscent = aMetric.GetAscent();
+ }
+ }
+ // -----------------------------------------------------------------------
+ void setFont( const SvxFont& rNewFont, SvxFont& rImplFont )
+ {
+ rImplFont = rNewFont;
+ rImplFont.SetTransparent( TRUE );
+ rImplFont.SetAlign( ALIGN_BASELINE );
+ }
+
+}
+// -----------------------------------------------------------------------
+
+
+// class FontPrevWin_Impl -----------------------------------------------
+
+class FontPrevWin_Impl
+{
+ friend class SvxFontPrevWindow;
+
+ SvxFont aFont;
+ Printer* pPrinter;
+ BOOL bDelPrinter;
+
+ Reference < XBreakIterator > xBreak;
+ SvULongs aTextWidth;
+ SvXub_StrLens aScriptChg;
+ SvUShorts aScriptType;
+ SvxFont aCJKFont;
+ SvxFont aCTLFont;
+ String aText;
+ String aScriptText;
+ Color* pColor;
+ Color* pBackColor;
+ long nAscent;
+ sal_Unicode cStartBracket;
+ sal_Unicode cEndBracket;
+
+ long n100PercentFontWidth; // initial -1 -> not set yet
+ long n100PercentFontWidthCJK;
+ long n100PercentFontWidthCTL;
+ UINT16 nFontWidthScale;
+
+ BOOL bSelection : 1,
+ bGetSelection : 1,
+ bUseResText : 1,
+ bTwoLines : 1,
+ bIsCJKUI : 1,
+ bIsCTLUI : 1,
+ bUseFontNameAsText : 1,
+ bTextInited : 1;
+
+ void _CheckScript();
+public:
+ inline FontPrevWin_Impl() :
+ pPrinter( NULL ), bDelPrinter( FALSE ),
+ pColor( NULL ), pBackColor( 0 ),
+ cStartBracket( 0 ), cEndBracket( 0 ), nFontWidthScale( 100 ),
+ bSelection( FALSE ), bGetSelection( FALSE ), bUseResText( FALSE ),
+ bTwoLines( FALSE ),
+ bIsCJKUI( FALSE ), bIsCTLUI( FALSE ),
+ bUseFontNameAsText( FALSE ), bTextInited( FALSE )
+ {
+ Invalidate100PercentFontWidth();
+ }
+
+ inline ~FontPrevWin_Impl()
+ {
+ delete pColor;
+ delete pBackColor;
+ if( bDelPrinter )
+ delete pPrinter;
+ }
+
+ void CheckScript();
+ Size CalcTextSize( OutputDevice* pWin, OutputDevice* pPrt, SvxFont &rFont );
+ void DrawPrev( OutputDevice* pWin, Printer* pPrt, Point &rPt, SvxFont &rFont );
+
+ BOOL SetFontWidthScale( UINT16 nScaleInPercent );
+ inline void Invalidate100PercentFontWidth();
+ inline BOOL Is100PercentFontWidthValid() const;
+ void ScaleFontWidth( const OutputDevice& rOutDev );
+ // scales rNonCJKFont and aCJKFont depending on nFontWidthScale and
+ // sets the 100%-Font-Widths
+};
+
+void FontPrevWin_Impl::CheckScript()
+{
+ if( aText != aScriptText )
+ _CheckScript();
+}
+
+inline void FontPrevWin_Impl::Invalidate100PercentFontWidth()
+{
+ n100PercentFontWidth = n100PercentFontWidthCJK = n100PercentFontWidthCTL = -1;
+}
+
+inline BOOL FontPrevWin_Impl::Is100PercentFontWidthValid() const
+{
+ DBG_ASSERT( ( n100PercentFontWidth == -1 && n100PercentFontWidthCJK == -1 ) ||
+ ( n100PercentFontWidth != -1 && n100PercentFontWidthCJK != -1 ) ||
+ ( n100PercentFontWidth == -1 && n100PercentFontWidthCTL == -1 ) ||
+ ( n100PercentFontWidth != -1 && n100PercentFontWidthCTL != -1 ),
+ "*FontPrevWin_Impl::Is100PercentFontWidthValid(): 100PercentFontWidth's not synchronous" );
+ return n100PercentFontWidth != -1;
+}
+
+// class FontPrevWin_Impl -----------------------------------------------
+
+/*-----------------19.7.2001 08:44------------------
+ * void FontPrevWin_Impl::_CheckScript()
+ * evalutates the scripttypes of the actual string.
+ * Afterwards the positions of script change are notified in aScriptChg,
+ * the scripttypes in aScriptType.
+ * The aTextWidth array will be filled with zero.
+ * --------------------------------------------------*/
+
+void FontPrevWin_Impl::_CheckScript()
+{
+ aScriptText = aText;
+ USHORT nCnt = aScriptChg.Count();
+ if( nCnt )
+ {
+ aScriptChg.Remove( 0, nCnt );
+ aScriptType.Remove( 0, nCnt );
+ aTextWidth.Remove( 0, nCnt );
+ nCnt = 0;
+ }
+ if( !xBreak.is() )
+ {
+ Reference< XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ xBreak = Reference< XBreakIterator >(xMSF->createInstance(
+ ::rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) ),UNO_QUERY);
+ }
+ if( xBreak.is() )
+ {
+ USHORT nScript = xBreak->getScriptType( aText, 0 );
+ USHORT nChg = 0;
+ if( com::sun::star::i18n::ScriptType::WEAK == nScript )
+ {
+ nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript );
+ if( nChg < aText.Len() )
+ nScript = xBreak->getScriptType( aText, nChg );
+ else
+ nScript = com::sun::star::i18n::ScriptType::LATIN;
+ }
+
+ do
+ {
+ nChg = (xub_StrLen)xBreak->endOfScript( aText, nChg, nScript );
+ if (nChg < aText.Len() && nChg > 0 &&
+ (com::sun::star::i18n::ScriptType::WEAK ==
+ xBreak->getScriptType(aText, nChg - 1)))
+ {
+ int8_t nType = u_charType(aText.GetChar(nChg) );
+ if (nType == U_NON_SPACING_MARK || nType == U_ENCLOSING_MARK ||
+ nType == U_COMBINING_SPACING_MARK )
+ {
+ aScriptChg.Insert( nChg - 1, nCnt );
+ }
+ else
+ {
+ aScriptChg.Insert( nChg, nCnt );
+ }
+ }
+ else
+ {
+ aScriptChg.Insert( nChg, nCnt );
+ }
+ aScriptType.Insert( nScript, nCnt );
+ aTextWidth.Insert( ULONG(0), nCnt++ );
+
+ if( nChg < aText.Len() )
+ nScript = xBreak->getScriptType( aText, nChg );
+ else
+ break;
+ } while( TRUE );
+ }
+}
+
+/*-----------------19.7.2001 08:48------------------
+ * Size FontPrevWin_Impl::CalcTextSize(..)
+ * fills the aTextWidth array with the text width of every part
+ * of the actual string without a script change inside.
+ * For Latin parts the given rFont will be used,
+ * for Asian parts the aCJKFont.
+ * The returned size contains the whole string.
+ * The member nAscent is calculated to the maximal ascent of all used fonts.
+ * --------------------------------------------------*/
+
+Size FontPrevWin_Impl::CalcTextSize( OutputDevice* pWin, OutputDevice* _pPrinter,
+ SvxFont &rFont )
+{
+ USHORT nScript;
+ USHORT nIdx = 0;
+ xub_StrLen nStart = 0;
+ xub_StrLen nEnd;
+ USHORT nCnt = aScriptChg.Count();
+ if( nCnt )
+ {
+ nEnd = aScriptChg[ nIdx ];
+ nScript = aScriptType[ nIdx ];
+ }
+ else
+ {
+ nEnd = aText.Len();
+ nScript = com::sun::star::i18n::ScriptType::LATIN;
+ }
+ long nTxtWidth = 0;
+ long nCJKHeight = 0;
+ long nCTLHeight = 0;
+ long nHeight = 0;
+ nAscent = 0;
+ long nCJKAscent = 0;
+ long nCTLAscent = 0;
+ do
+ {
+ SvxFont& rFnt = (nScript==com::sun::star::i18n::ScriptType::ASIAN) ? aCJKFont : ((nScript==com::sun::star::i18n::ScriptType::COMPLEX) ? aCTLFont : rFont);
+ ULONG nWidth = rFnt.GetTxtSize( _pPrinter, aText, nStart, nEnd-nStart ).
+ Width();
+ aTextWidth[ nIdx++ ] = nWidth;
+ nTxtWidth += nWidth;
+ switch(nScript)
+ {
+ case com::sun::star::i18n::ScriptType::ASIAN:
+ calcFontHeightAnyAscent(pWin,aCJKFont,nCJKHeight,nCJKAscent);
+ break;
+ case com::sun::star::i18n::ScriptType::COMPLEX:
+ calcFontHeightAnyAscent(pWin,aCTLFont,nCTLHeight,nCTLAscent);
+ break;
+ default:
+ calcFontHeightAnyAscent(pWin,rFont,nHeight,nAscent);
+ }
+
+ if( nEnd < aText.Len() && nIdx < nCnt )
+ {
+ nStart = nEnd;
+ nEnd = aScriptChg[ nIdx ];
+ nScript = aScriptType[ nIdx ];
+ }
+ else
+ break;
+ }
+ while( TRUE );
+ nHeight -= nAscent;
+ nCJKHeight -= nCJKAscent;
+ nCTLHeight -= nCTLAscent;
+ if( nHeight < nCJKHeight )
+ nHeight = nCJKHeight;
+ if( nAscent < nCJKAscent )
+ nAscent = nCJKAscent;
+ if( nHeight < nCTLHeight )
+ nHeight = nCTLHeight;
+ if( nAscent < nCTLAscent )
+ nAscent = nCTLAscent;
+ nHeight += nAscent;
+
+ Size aTxtSize( nTxtWidth, nHeight );
+ return aTxtSize;
+}
+
+/*-----------------19.7.2001 08:54------------------
+ * void FontPrevWin_Impl::DrawPrev(..)
+ * calls SvxFont::DrawPrev(..) for every part of the string without a script
+ * change inside, for Asian parts the aCJKFont will be used, otherwise the
+ * given rFont.
+ * --------------------------------------------------*/
+
+void FontPrevWin_Impl::DrawPrev( OutputDevice* pWin, Printer* _pPrinter,
+ Point &rPt, SvxFont &rFont )
+{
+ Font aOldFont = _pPrinter->GetFont();
+ USHORT nScript;
+ USHORT nIdx = 0;
+ xub_StrLen nStart = 0;
+ xub_StrLen nEnd;
+ USHORT nCnt = aScriptChg.Count();
+ if( nCnt )
+ {
+ nEnd = aScriptChg[ nIdx ];
+ nScript = aScriptType[ nIdx ];
+ }
+ else
+ {
+ nEnd = aText.Len();
+ nScript = com::sun::star::i18n::ScriptType::LATIN;
+ }
+ do
+ {
+ SvxFont& rFnt = (nScript==com::sun::star::i18n::ScriptType::ASIAN) ? aCJKFont : ((nScript==com::sun::star::i18n::ScriptType::COMPLEX) ? aCTLFont : rFont);
+ _pPrinter->SetFont( rFnt );
+
+ rFnt.DrawPrev( pWin, _pPrinter, rPt, aText, nStart, nEnd - nStart );
+
+ rPt.X() += aTextWidth[ nIdx++ ];
+ if( nEnd < aText.Len() && nIdx < nCnt )
+ {
+ nStart = nEnd;
+ nEnd = aScriptChg[ nIdx ];
+ nScript = aScriptType[ nIdx ];
+ }
+ else
+ break;
+ }
+ while( TRUE );
+ _pPrinter->SetFont( aOldFont );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL FontPrevWin_Impl::SetFontWidthScale( UINT16 nScale )
+{
+ if( nFontWidthScale != nScale )
+ {
+ nFontWidthScale = nScale;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+// -----------------------------------------------------------------------
+
+void FontPrevWin_Impl::ScaleFontWidth( const OutputDevice& rOutDev )
+{
+ if( !Is100PercentFontWidthValid() )
+ {
+ scaleFontWidth(aFont,rOutDev,n100PercentFontWidth);
+ scaleFontWidth(aCJKFont,rOutDev,n100PercentFontWidthCJK);
+ scaleFontWidth(aCTLFont,rOutDev,n100PercentFontWidthCTL);
+ }
+
+ aFont.SetWidth( n100PercentFontWidth * nFontWidthScale / 100 );
+ aCJKFont.SetWidth( n100PercentFontWidthCJK * nFontWidthScale / 100 );
+ aCTLFont.SetWidth( n100PercentFontWidthCTL * nFontWidthScale / 100 );
+}
+
+// class SvxFontPrevWindow -----------------------------------------------
+
+void SvxFontPrevWindow::InitSettings( BOOL bForeground, BOOL bBackground )
+{
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ if ( bForeground )
+ {
+ svtools::ColorConfig aColorConfig;
+ Color aTextColor( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
+
+ if ( IsControlForeground() )
+ aTextColor = GetControlForeground();
+ SetTextColor( aTextColor );
+ }
+
+ if ( bBackground )
+ {
+ if ( IsControlBackground() )
+ SetBackground( GetControlBackground() );
+ else
+ SetBackground( rStyleSettings.GetWindowColor() );
+ }
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+SvxFontPrevWindow::SvxFontPrevWindow( Window* pParent, const ResId& rId ) :
+
+ Window ( pParent, rId )
+{
+ pImpl = new FontPrevWin_Impl;
+ SfxViewShell* pSh = SfxViewShell::Current();
+
+ if ( pSh )
+ pImpl->pPrinter = pSh->GetPrinter();
+
+ if ( !pImpl->pPrinter )
+ {
+ pImpl->pPrinter = new Printer;
+ pImpl->bDelPrinter = TRUE;
+ }
+ SetMapMode( MapMode( MAP_TWIP ) );
+ initFont(pImpl->aFont);
+ initFont(pImpl->aCJKFont);
+ initFont(pImpl->aCTLFont);
+ InitSettings( TRUE, TRUE );
+ SetBorderStyle( WINDOW_BORDER_MONO );
+
+ LanguageType eLanguage = Application::GetSettings().GetUILanguage();
+ switch( eLanguage )
+ {
+ case LANGUAGE_CHINESE:
+ case LANGUAGE_JAPANESE:
+ case LANGUAGE_KOREAN:
+ case LANGUAGE_KOREAN_JOHAB:
+ case LANGUAGE_CHINESE_SIMPLIFIED:
+ case LANGUAGE_CHINESE_HONGKONG:
+ case LANGUAGE_CHINESE_SINGAPORE:
+ case LANGUAGE_CHINESE_MACAU:
+ case LANGUAGE_CHINESE_TRADITIONAL:
+ pImpl->bIsCJKUI = sal_True;
+ break;
+ // TODO: CTL Locale
+ // pImpl->bIsCTLUI = sal_True;
+ // break;
+ default:
+ pImpl->bIsCJKUI = pImpl->bIsCTLUI = sal_False;
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SvxFontPrevWindow::~SvxFontPrevWindow()
+{
+ delete pImpl;
+}
+
+// -----------------------------------------------------------------------
+SvxFont& SvxFontPrevWindow::GetCTLFont()
+{
+ return pImpl->aCTLFont;
+}
+
+// -----------------------------------------------------------------------
+
+SvxFont& SvxFontPrevWindow::GetCJKFont()
+{
+ return pImpl->aCJKFont;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::StateChanged( StateChangedType nType )
+{
+ if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
+ InitSettings( TRUE, FALSE );
+ else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
+ InitSettings( FALSE, TRUE );
+
+ Window::StateChanged( nType );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ InitSettings( TRUE, TRUE );
+ else
+ Window::DataChanged( rDCEvt );
+}
+
+SvxFont& SvxFontPrevWindow::GetFont()
+{
+ pImpl->Invalidate100PercentFontWidth(); // because the user might change the size
+ return pImpl->aFont;
+}
+
+const SvxFont& SvxFontPrevWindow::GetFont() const
+{
+ return pImpl->aFont;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetPreviewText( const ::rtl::OUString& rString )
+{
+ pImpl->aText = rString;
+ pImpl->bTextInited = TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetFontNameAsPreviewText()
+{
+ pImpl->bUseFontNameAsText = TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetFont( const SvxFont& rOutFont )
+{
+ setFont( rOutFont, pImpl->aFont );
+
+ pImpl->Invalidate100PercentFontWidth();
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetFont( const SvxFont& rNormalOutFont, const SvxFont& rCJKOutFont, const SvxFont& rCTLFont )
+{
+ setFont( rNormalOutFont, pImpl->aFont );
+ setFont( rCJKOutFont, pImpl->aCJKFont );
+ setFont( rCTLFont, pImpl->aCTLFont );
+
+
+ pImpl->Invalidate100PercentFontWidth();
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetCJKFont( const SvxFont &rCJKOutFont )
+{
+ setFont( rCJKOutFont, pImpl->aCJKFont );
+
+ pImpl->Invalidate100PercentFontWidth();
+ Invalidate();
+}
+// -----------------------------------------------------------------------------
+void SvxFontPrevWindow::SetCTLFont( const SvxFont &rCTLOutFont )
+{
+ setFont( rCTLOutFont, pImpl->aCTLFont );
+
+ pImpl->Invalidate100PercentFontWidth();
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetColor(const Color &rColor)
+{
+ delete pImpl->pColor;
+ pImpl->pColor = new Color( rColor );
+ Invalidate();
+}
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::ResetColor()
+{
+ delete pImpl->pColor;
+ pImpl->pColor = 0;
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetBackColor(const Color &rColor)
+{
+ delete pImpl->pBackColor;
+ pImpl->pBackColor = new Color( rColor );
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::UseResourceText( BOOL bUse )
+{
+ pImpl->bUseResText = bUse;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::Paint( const Rectangle& )
+{
+ Printer* pPrinter = pImpl->pPrinter;
+ SvxFont& rFont = pImpl->aFont;
+ SvxFont& rCJKFont = pImpl->aCJKFont;
+ // TODO: SvxFont& rCTLFont = pImpl->aCTLFont;
+
+ if ( pImpl->bUseResText )
+ pImpl->aText = GetText();
+ else if ( !pImpl->bSelection && !pImpl->bTextInited )
+ {
+ SfxViewShell* pSh = SfxViewShell::Current();
+
+ if ( pSh && !pImpl->bGetSelection && !pImpl->bUseFontNameAsText )
+ {
+ pImpl->aText = pSh->GetSelectionText();
+ pImpl->bGetSelection = TRUE;
+ pImpl->bSelection = pImpl->aText.Len() != 0;
+
+ }
+
+ if ( !pImpl->bSelection || pImpl->bUseFontNameAsText )
+ {
+ pImpl->aText = rFont.GetName();
+ if( pImpl->bIsCJKUI )
+ pImpl->aText += rCJKFont.GetName();
+ //TODO bIsCTLUI
+ }
+
+ if ( !pImpl->aText.Len() )
+ pImpl->aText = GetText();
+
+ // remove line feeds and carriage returns from string
+ bool bNotEmpty = false;
+ for ( xub_StrLen i = 0; i < pImpl->aText.Len(); ++i )
+ {
+ if ( 0xa == pImpl->aText.GetChar( i ) ||
+ 0xd == pImpl->aText.GetChar( i ) )
+ pImpl->aText.SetChar( i, ' ' );
+ else
+ bNotEmpty = true;
+ }
+ if ( !bNotEmpty )
+ pImpl->aText = GetText();
+
+ if ( pImpl->aText.Len() > (TEXT_WIDTH-1) )
+ pImpl->aText.Erase( pImpl->aText.Search( sal_Unicode( ' ' ), TEXT_WIDTH ) );
+ }
+
+ // calculate text width scaling
+ pImpl->ScaleFontWidth( *this/*, rFont*/ );
+
+ pImpl->CheckScript();
+ Size aTxtSize = pImpl->CalcTextSize( this, pPrinter, rFont );
+
+ const Size aLogSize( GetOutputSize() );
+
+ long nX = aLogSize.Width() / 2 - aTxtSize.Width() / 2;
+ long nY = aLogSize.Height() / 2 - aTxtSize.Height() / 2;
+
+ if ( nY + pImpl->nAscent > aLogSize.Height() )
+ nY = aLogSize.Height() - pImpl->nAscent;
+
+ if ( pImpl->pBackColor )
+ {
+ Rectangle aRect( Point( 0, 0 ), aLogSize );
+ Color aLineCol = GetLineColor();
+ Color aFillCol = GetFillColor();
+ SetLineColor();
+ SetFillColor( *pImpl->pBackColor );
+ DrawRect( aRect );
+ SetLineColor( aLineCol );
+ SetFillColor( aFillCol );
+ }
+ if ( pImpl->pColor )
+ {
+ Rectangle aRect( Point( nX, nY ), aTxtSize );
+ Color aLineCol = GetLineColor();
+ Color aFillCol = GetFillColor();
+ SetLineColor();
+ SetFillColor( *pImpl->pColor );
+ DrawRect( aRect );
+ SetLineColor( aLineCol );
+ SetFillColor( aFillCol );
+ }
+
+ long nStdAscent = pImpl->nAscent;
+ nY += nStdAscent;
+
+ if(pImpl->bTwoLines)
+ {
+ SvxFont aSmallFont( rFont );
+ Size aOldSize = pImpl->aCJKFont.GetSize();
+ setFontSize(aSmallFont);
+ setFontSize(pImpl->aCJKFont);
+
+ long nStartBracketWidth = 0;
+ long nEndBracketWidth = 0;
+ long nTextWidth = 0;
+ if(pImpl->cStartBracket)
+ {
+ String sBracket(pImpl->cStartBracket);
+ nStartBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width();
+ }
+ if(pImpl->cEndBracket)
+ {
+ String sBracket(pImpl->cEndBracket);
+ nEndBracketWidth = rFont.GetTxtSize( pPrinter, sBracket ).Width();
+ }
+ nTextWidth = pImpl->CalcTextSize( this, pPrinter, aSmallFont ).Width();
+ long nResultWidth = nStartBracketWidth;
+ nResultWidth += nEndBracketWidth;
+ nResultWidth += nTextWidth;
+
+ long _nX = (aLogSize.Width() - nResultWidth) / 2;
+ DrawLine( Point( 0, nY ), Point( _nX, nY ) );
+ DrawLine( Point( _nX + nResultWidth, nY ), Point( aLogSize.Width(), nY ) );
+
+ long nSmallAscent = pImpl->nAscent;
+ long nOffset = (nStdAscent - nSmallAscent ) / 2;
+
+ if(pImpl->cStartBracket)
+ {
+ String sBracket(pImpl->cStartBracket);
+ rFont.DrawPrev( this, pPrinter, Point( _nX, nY - nOffset - 4), sBracket );
+ _nX += nStartBracketWidth;
+ }
+
+ Point aTmpPoint1( _nX, nY - nSmallAscent - 2 );
+ Point aTmpPoint2( _nX, nY );
+ pImpl->DrawPrev( this, pPrinter, aTmpPoint1, aSmallFont );
+ pImpl->DrawPrev( this, pPrinter, aTmpPoint2, aSmallFont );
+
+ _nX += nTextWidth;
+ if(pImpl->cEndBracket)
+ {
+ Point aTmpPoint( _nX + 1, nY - nOffset - 4);
+ String sBracket(pImpl->cEndBracket);
+ rFont.DrawPrev( this, pPrinter, aTmpPoint, sBracket );
+ }
+ pImpl->aCJKFont.SetSize( aOldSize );
+ }
+ else
+ {
+ Color aLineCol = GetLineColor();
+
+ SetLineColor( rFont.GetColor() );
+ DrawLine( Point( 0, nY ), Point( nX, nY ) );
+ DrawLine( Point( nX + aTxtSize.Width(), nY ), Point( aLogSize.Width(), nY ) );
+
+ SetLineColor( aLineCol );
+
+ Point aTmpPoint( nX, nY );
+ pImpl->DrawPrev( this, pPrinter, aTmpPoint, rFont );
+ }
+}
+/* -----------------------------04.12.00 16:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL SvxFontPrevWindow::IsTwoLines() const
+{
+ return pImpl->bTwoLines;
+}
+/* -----------------------------04.12.00 16:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxFontPrevWindow::SetTwoLines(BOOL bSet)
+{
+ pImpl->bTwoLines = bSet;}
+
+/* -----------------------------04.12.00 16:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxFontPrevWindow::SetBrackets(sal_Unicode cStart, sal_Unicode cEnd)
+{
+ pImpl->cStartBracket = cStart;
+ pImpl->cEndBracket = cEnd;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::SetFontWidthScale( UINT16 n )
+{
+ if( pImpl->SetFontWidthScale( n ) )
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontPrevWindow::AutoCorrectFontColor( void )
+{
+ Color aFontColor( GetTextColor() );
+
+ if( COL_AUTO == pImpl->aFont.GetColor().GetColor() )
+ pImpl->aFont.SetColor( aFontColor );
+
+ if( COL_AUTO == pImpl->aCJKFont.GetColor().GetColor() )
+ pImpl->aCJKFont.SetColor( aFontColor );
+
+ if( COL_AUTO == pImpl->aCTLFont.GetColor().GetColor() )
+ pImpl->aCTLFont.SetColor( aFontColor );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/fontlb.cxx b/svx/source/dialog/fontlb.cxx
new file mode 100644
index 000000000000..d2223baa47d8
--- /dev/null
+++ b/svx/source/dialog/fontlb.cxx
@@ -0,0 +1,191 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "fontlb.hxx"
+#include <vcl/svapp.hxx>
+
+// ============================================================================
+
+DBG_NAME( SvLBoxFontString );
+
+SvLBoxFontString::SvLBoxFontString() :
+ SvLBoxString()
+{
+ DBG_CTOR( SvLBoxFontString, 0 );
+}
+
+SvLBoxFontString::SvLBoxFontString(
+ SvLBoxEntry* pEntry, sal_uInt16 nFlags, const XubString& rString,
+ const Font& rFont, const Color* pColor ) :
+ SvLBoxString( pEntry, nFlags, rString ),
+ maFont( rFont ),
+ mbUseColor( pColor != NULL )
+{
+ DBG_CTOR( SvLBoxFontString, 0 );
+ SetText( pEntry, rString );
+ if( pColor )
+ maFont.SetColor( *pColor );
+}
+
+SvLBoxFontString::~SvLBoxFontString()
+{
+ DBG_DTOR( SvLBoxFontString, 0 );
+}
+
+
+SvLBoxItem* SvLBoxFontString::Create() const
+{
+ DBG_CHKTHIS( SvLBoxFontString, 0 );
+ return new SvLBoxFontString;
+}
+
+void SvLBoxFontString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry )
+{
+ DBG_CHKTHIS( SvLBoxFontString, 0 );
+ Font aOldFont( rDev.GetFont() );
+ Font aNewFont( maFont );
+ bool bSel = (nFlags & SVLISTENTRYFLAG_SELECTED) != 0;
+// if( !mbUseColor ) // selection gets font color, if available
+ if( !mbUseColor || bSel ) // selection always gets highlight color
+ {
+ const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
+ aNewFont.SetColor( bSel ? rSett.GetHighlightTextColor() : rSett.GetFieldTextColor() );
+ }
+
+ rDev.SetFont( aNewFont );
+ SvLBoxString::Paint( rPos, rDev, nFlags, pEntry );
+ rDev.SetFont( aOldFont );
+}
+
+void SvLBoxFontString::InitViewData( SvLBox* pView, SvLBoxEntry* pEntry, SvViewDataItem* pViewData )
+{
+ DBG_CHKTHIS( SvLBoxFontString, 0 );
+ Font aOldFont( pView->GetFont() );
+ pView->SetFont( maFont );
+ SvLBoxString::InitViewData( pView, pEntry, pViewData);
+ pView->SetFont( aOldFont );
+}
+
+
+// ============================================================================
+
+SvxFontListBox::SvxFontListBox( Window* pParent, const ResId& rResId ) :
+ SvTabListBox( pParent, rResId ),
+ maStdFont( GetFont() ),
+ mbUseFont( false )
+{
+ maStdFont.SetTransparent( TRUE );
+ maEntryFont = maStdFont;
+}
+
+void SvxFontListBox::InsertFontEntry( const String& rString, const Font& rFont, const Color* pColor )
+{
+ mbUseFont = true; // InitEntry() will use maEntryFont
+ maEntryFont = rFont; // font to use in InitEntry() over InsertEntry()
+ mpEntryColor = pColor; // color to use in InitEntry() over InsertEntry()
+ InsertEntry( rString );
+ mbUseFont = false;
+}
+
+void SvxFontListBox::SelectEntryPos( sal_uInt16 nPos, bool bSelect )
+{
+ SvLBoxEntry* pEntry = GetEntry( nPos );
+ if( pEntry )
+ {
+ Select( pEntry, bSelect );
+ ShowEntry( pEntry );
+ }
+}
+
+void SvxFontListBox::SetNoSelection()
+{
+ SelectAll( FALSE, TRUE );
+}
+
+ULONG SvxFontListBox::GetSelectEntryPos() const
+{
+ SvLBoxEntry* pSvLBoxEntry = FirstSelected();
+ return pSvLBoxEntry ? GetModel()->GetAbsPos( pSvLBoxEntry ) : LIST_APPEND;
+}
+
+XubString SvxFontListBox::GetSelectEntry() const
+{
+ return GetEntryText( GetSelectEntryPos() );
+}
+
+void SvxFontListBox::InitEntry(
+ SvLBoxEntry* pEntry, const XubString& rEntryText,
+ const Image& rCollImg, const Image& rExpImg,
+ SvLBoxButtonKind eButtonKind )
+{
+ if( mbUseFont )
+ {
+ if( nTreeFlags & TREEFLAG_CHKBTN )
+ pEntry->AddItem( new SvLBoxButton( pEntry, eButtonKind, 0,
+ pCheckButtonData ) );
+ pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, rCollImg, rExpImg, SVLISTENTRYFLAG_EXPANDED ) );
+ pEntry->AddItem( new SvLBoxFontString( pEntry, 0, rEntryText, maEntryFont, mpEntryColor ) );
+ }
+ else
+ SvTreeListBox::InitEntry( pEntry, rEntryText, rCollImg, rExpImg,
+ eButtonKind );
+}
+
+#if ENABLE_LAYOUT
+
+namespace layout
+{
+
+SvxFontListBox::~SvxFontListBox ()
+{
+}
+
+sal_uInt16 SvxFontListBox::InsertFontEntry (String const& entry, Font const&, Color const*)
+{
+ return InsertEntry (entry);
+}
+
+SvxFontListBox::SvxFontListBox( Context* pParent, const char* pFile)
+: ListBox( pParent, pFile )
+{
+}
+
+/*IMPL_IMPL (SvxFontListBox, ListBox);
+IMPL_CONSTRUCTORS (SvxFontListBox, ListBox, "svxfontlistbox");
+IMPL_GET_IMPL (SvxFontListBox);
+IMPL_GET_WINDOW (SvxFontListBox);*/
+
+};
+
+#endif
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/fontwork.cxx b/svx/source/dialog/fontwork.cxx
new file mode 100644
index 000000000000..e29b1a27ac45
--- /dev/null
+++ b/svx/source/dialog/fontwork.cxx
@@ -0,0 +1,1286 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <sfx2/module.hxx>
+#include <sfx2/dispatch.hxx>
+#include <tools/shl.hxx>
+
+#define _SVX_FONTWORK_CXX
+#include <svx/svdobj.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdocirc.hxx>
+#include <svx/xtextit.hxx>
+
+#include <svx/dialmgr.hxx>
+#include "dlgutil.hxx"
+
+#include <svx/dialogs.hrc>
+#include "fontwork.hrc"
+#include <svx/fontwork.hxx>
+#include <editeng/outlobj.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+
+SFX_IMPL_DOCKINGWINDOW( SvxFontWorkChildWindow, SID_FONTWORK );
+
+/*************************************************************************
+|*
+|* ControllerItem fuer Fontwork
+|*
+\************************************************************************/
+
+SvxFontWorkControllerItem::SvxFontWorkControllerItem
+(
+ USHORT _nId,
+ SvxFontWorkDialog& rDlg,
+ SfxBindings& rBindings
+) :
+
+ SfxControllerItem( _nId, rBindings ),
+
+ rFontWorkDlg( rDlg )
+{
+}
+
+/*************************************************************************
+|*
+|* StateChanged-Methode fuer FontWork-Items
+|*
+\************************************************************************/
+
+void SvxFontWorkControllerItem::StateChanged( USHORT /*nSID*/, SfxItemState /*eState*/,
+ const SfxPoolItem* pItem )
+{
+ switch ( GetId() )
+ {
+ case SID_FORMTEXT_STYLE:
+ {
+ const XFormTextStyleItem* pStateItem =
+ PTR_CAST(XFormTextStyleItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextStyleItem erwartet");
+ rFontWorkDlg.SetStyle_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_ADJUST:
+ {
+ const XFormTextAdjustItem* pStateItem =
+ PTR_CAST(XFormTextAdjustItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextAdjustItem erwartet");
+ rFontWorkDlg.SetAdjust_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_DISTANCE:
+ {
+ const XFormTextDistanceItem* pStateItem =
+ PTR_CAST(XFormTextDistanceItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextDistanceItem erwartet");
+ rFontWorkDlg.SetDistance_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_START:
+ {
+ const XFormTextStartItem* pStateItem =
+ PTR_CAST(XFormTextStartItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextStartItem erwartet");
+ rFontWorkDlg.SetStart_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_MIRROR:
+ {
+ const XFormTextMirrorItem* pStateItem =
+ PTR_CAST(XFormTextMirrorItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextMirrorItem erwartet");
+ rFontWorkDlg.SetMirror_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_STDFORM:
+ {
+ const XFormTextStdFormItem* pStateItem =
+ PTR_CAST(XFormTextStdFormItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextStdFormItem erwartet");
+ rFontWorkDlg.SetStdForm_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_HIDEFORM:
+ {
+ const XFormTextHideFormItem* pStateItem =
+ PTR_CAST(XFormTextHideFormItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextHideFormItem erwartet");
+ rFontWorkDlg.SetShowForm_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_OUTLINE:
+ {
+ const XFormTextOutlineItem* pStateItem =
+ PTR_CAST(XFormTextOutlineItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextOutlineItem erwartet");
+ rFontWorkDlg.SetOutline_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_SHADOW:
+ {
+ const XFormTextShadowItem* pStateItem =
+ PTR_CAST(XFormTextShadowItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowItem erwartet");
+ rFontWorkDlg.SetShadow_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_SHDWCOLOR:
+ {
+ const XFormTextShadowColorItem* pStateItem =
+ PTR_CAST(XFormTextShadowColorItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowColorItem erwartet");
+ rFontWorkDlg.SetShadowColor_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_SHDWXVAL:
+ {
+ const XFormTextShadowXValItem* pStateItem =
+ PTR_CAST(XFormTextShadowXValItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowXValItem erwartet");
+ rFontWorkDlg.SetShadowXVal_Impl(pStateItem);
+ break;
+ }
+ case SID_FORMTEXT_SHDWYVAL:
+ {
+ const XFormTextShadowYValItem* pStateItem =
+ PTR_CAST(XFormTextShadowYValItem, pItem);
+ DBG_ASSERT(pStateItem || pItem == 0, "XFormTextShadowYValItem erwartet");
+ rFontWorkDlg.SetShadowYVal_Impl(pStateItem);
+ break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Ableitung vom SfxChildWindow als "Behaelter" fuer Fontwork-Dialog
+|*
+\************************************************************************/
+
+SvxFontWorkChildWindow::SvxFontWorkChildWindow
+(
+ Window* _pParent,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo
+) :
+
+ SfxChildWindow( _pParent, nId )
+
+{
+ pWindow = new SvxFontWorkDialog( pBindings, this, _pParent,
+ SVX_RES( RID_SVXDLG_FONTWORK ) );
+ SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*) pWindow;
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+
+ pDlg->Initialize( pInfo );
+}
+
+/*************************************************************************
+|*
+|* Floating Window zur Attributierung von Texteffekten
+|*
+\************************************************************************/
+
+SvxFontWorkDialog::SvxFontWorkDialog( SfxBindings *pBindinx,
+ SfxChildWindow *pCW,
+ Window* _pParent,
+ const ResId& rResId ) :
+ SfxDockingWindow( pBindinx, pCW, _pParent, rResId ),
+
+ aFormSet (this, ResId(VS_FORMS,*rResId.GetResMgr())),
+
+ aTbxStyle (this, ResId(TBX_STYLE,*rResId.GetResMgr())),
+ aTbxAdjust (this, ResId(TBX_ADJUST,*rResId.GetResMgr())),
+
+ aFbDistance (this, ResId(FB_DISTANCE,*rResId.GetResMgr())),
+ aMtrFldDistance (this, ResId(MTR_FLD_DISTANCE,*rResId.GetResMgr())),
+ aFbTextStart (this, ResId(FB_TEXTSTART,*rResId.GetResMgr())),
+ aMtrFldTextStart(this, ResId(MTR_FLD_TEXTSTART,*rResId.GetResMgr())),
+
+ aTbxShadow (this, ResId(TBX_SHADOW,*rResId.GetResMgr())),
+
+ aFbShadowX (this, ResId(FB_SHADOW_X,*rResId.GetResMgr())),
+ aMtrFldShadowX (this, ResId(MTR_FLD_SHADOW_X,*rResId.GetResMgr())),
+ aFbShadowY (this, ResId(FB_SHADOW_Y,*rResId.GetResMgr())),
+ aMtrFldShadowY (this, ResId(MTR_FLD_SHADOW_Y,*rResId.GetResMgr())),
+
+ aShadowColorLB (this, ResId(CLB_SHADOW_COLOR,*rResId.GetResMgr())),
+ rBindings (*pBindinx),
+
+ nLastStyleTbxId(0),
+ nLastAdjustTbxId(0),
+ nLastShadowTbxId(0),
+ nSaveShadowX (0),
+ nSaveShadowY (0),
+ nSaveShadowAngle(450),
+ nSaveShadowSize (100),
+
+ maImageList (ResId(IL_FONTWORK,*rResId.GetResMgr())),
+ maImageListH (ResId(ILH_FONTWORK,*rResId.GetResMgr())),
+
+ pColorTable (NULL)
+{
+ FreeResource();
+
+ ApplyImageList();
+
+ pCtrlItems[0] = new SvxFontWorkControllerItem(SID_FORMTEXT_STYLE, *this, rBindings);
+ pCtrlItems[1] = new SvxFontWorkControllerItem(SID_FORMTEXT_ADJUST, *this, rBindings);
+ pCtrlItems[2] = new SvxFontWorkControllerItem(SID_FORMTEXT_DISTANCE, *this, rBindings);
+ pCtrlItems[3] = new SvxFontWorkControllerItem(SID_FORMTEXT_START, *this, rBindings);
+ pCtrlItems[4] = new SvxFontWorkControllerItem(SID_FORMTEXT_MIRROR, *this, rBindings);
+ pCtrlItems[5] = new SvxFontWorkControllerItem(SID_FORMTEXT_STDFORM, *this, rBindings);
+ pCtrlItems[6] = new SvxFontWorkControllerItem(SID_FORMTEXT_HIDEFORM, *this, rBindings);
+ pCtrlItems[7] = new SvxFontWorkControllerItem(SID_FORMTEXT_OUTLINE, *this, rBindings);
+ pCtrlItems[8] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHADOW, *this, rBindings);
+ pCtrlItems[9] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWCOLOR, *this, rBindings);
+ pCtrlItems[10] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWXVAL, *this, rBindings);
+ pCtrlItems[11] = new SvxFontWorkControllerItem(SID_FORMTEXT_SHDWYVAL, *this, rBindings);
+
+ WinBits aNewStyle = ( aFormSet.GetStyle() | WB_VSCROLL | WB_ITEMBORDER | WB_DOUBLEBORDER );
+ aFormSet.SetStyle( aNewStyle );
+
+ Size aSize = aTbxStyle.CalcWindowSizePixel();
+ aTbxStyle.SetSizePixel(aSize);
+ aTbxStyle.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectStyleHdl_Impl) );
+
+ aTbxAdjust.SetSizePixel(aSize);
+ aTbxAdjust.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectAdjustHdl_Impl) );
+
+ aTbxShadow.SetSizePixel(aSize);
+ aTbxShadow.SetSelectHdl( LINK(this, SvxFontWorkDialog, SelectShadowHdl_Impl) );
+
+// aFbShadowX.SetBitmap(Bitmap(FW_RESID(RID_SVXBMP_SHADOW_XDIST)));
+// aFbShadowY.SetBitmap(Bitmap(FW_RESID(RID_SVXBMP_SHADOW_YDIST)));
+
+ Link aLink = LINK(this, SvxFontWorkDialog, ModifyInputHdl_Impl);
+ aMtrFldDistance.SetModifyHdl( aLink );
+ aMtrFldTextStart.SetModifyHdl( aLink );
+ aMtrFldShadowX.SetModifyHdl( aLink );
+ aMtrFldShadowY.SetModifyHdl( aLink );
+
+ // System-Metrik setzen
+ const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
+ SetFieldUnit( aMtrFldDistance, eDlgUnit, TRUE );
+ SetFieldUnit( aMtrFldTextStart, eDlgUnit, TRUE );
+ SetFieldUnit( aMtrFldShadowX, eDlgUnit, TRUE );
+ SetFieldUnit( aMtrFldShadowY, eDlgUnit, TRUE );
+ if( eDlgUnit == FUNIT_MM )
+ {
+ aMtrFldDistance.SetSpinSize( 50 );
+ aMtrFldTextStart.SetSpinSize( 50 );
+ aMtrFldShadowX.SetSpinSize( 50 );
+ aMtrFldShadowY.SetSpinSize( 50 );
+ }
+ else
+ {
+ aMtrFldDistance.SetSpinSize( 10 );
+ aMtrFldTextStart.SetSpinSize( 10 );
+ aMtrFldShadowX.SetSpinSize( 10 );
+ aMtrFldShadowY.SetSpinSize( 10 );
+ }
+
+ aShadowColorLB.SetSelectHdl( LINK(this, SvxFontWorkDialog, ColorSelectHdl_Impl) );
+
+ aInputTimer.SetTimeout(500);
+ aInputTimer.SetTimeoutHdl(LINK(this, SvxFontWorkDialog, InputTimoutHdl_Impl));
+
+ aFormSet.SetSelectHdl( LINK(this, SvxFontWorkDialog, FormSelectHdl_Impl) );
+ aFormSet.SetColCount(4);
+ aFormSet.SetLineCount(2);
+
+ Bitmap aBmp(SVX_RES(RID_SVXBMP_FONTWORK_FORM1));
+ aSize.Height() = aFormSet.CalcWindowSizePixel(aBmp.GetSizePixel()).Height() + 2;
+ aFormSet.SetSizePixel(aSize);
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+SvxFontWorkDialog::~SvxFontWorkDialog()
+{
+ for (USHORT i = 0; i < CONTROLLER_COUNT; i++)
+ DELETEZ(pCtrlItems[i]);
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::Zoom()
+{
+ SfxDockingWindow::Roll();
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SfxChildAlignment SvxFontWorkDialog::CheckAlignment( SfxChildAlignment eActAlign,
+ SfxChildAlignment eAlign )
+{
+ SfxChildAlignment eAlignment;
+
+ switch ( eAlign )
+ {
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_LOWESTTOP:
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_HIGHESTBOTTOM:
+ {
+ eAlignment = eActAlign;
+ }
+ break;
+
+ case SFX_ALIGN_LEFT:
+ case SFX_ALIGN_RIGHT:
+ case SFX_ALIGN_FIRSTLEFT:
+ case SFX_ALIGN_LASTLEFT:
+ case SFX_ALIGN_FIRSTRIGHT:
+ case SFX_ALIGN_LASTRIGHT:
+ {
+ eAlignment = eAlign;
+ }
+ break;
+
+ default:
+ {
+ eAlignment = eAlign;
+ }
+ break;
+ }
+
+ return eAlignment;
+}
+
+
+/*************************************************************************
+|*
+|* Style-Buttons setzen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetStyle_Impl(const XFormTextStyleItem* pItem)
+{
+ if ( pItem )
+ {
+ USHORT nId = TBI_STYLE_OFF;
+
+ switch ( pItem->GetValue() )
+ {
+ case XFT_ROTATE : nId = TBI_STYLE_ROTATE; break;
+ case XFT_UPRIGHT: nId = TBI_STYLE_UPRIGHT; break;
+ case XFT_SLANTX : nId = TBI_STYLE_SLANTX; break;
+ case XFT_SLANTY : nId = TBI_STYLE_SLANTY; break;
+ default: ;//prevent warning
+ }
+ aTbxStyle.Enable();
+
+ // Make sure that there is allways exactly one checked toolbox item.
+ if ( pItem->GetValue() == XFT_NONE )
+ {
+ aTbxStyle.CheckItem(TBI_STYLE_ROTATE, FALSE);
+ aTbxStyle.CheckItem(TBI_STYLE_UPRIGHT, FALSE);
+ aTbxStyle.CheckItem(TBI_STYLE_SLANTX, FALSE);
+ aTbxStyle.CheckItem(TBI_STYLE_SLANTY, FALSE);
+
+ aTbxStyle.CheckItem(TBI_STYLE_OFF, TRUE);
+ }
+ else
+ {
+ aTbxStyle.CheckItem(TBI_STYLE_OFF, FALSE);
+ aTbxStyle.CheckItem(nId);
+ }
+
+ nLastStyleTbxId = nId;
+ }
+ else
+ aTbxStyle.Disable();
+}
+
+/*************************************************************************
+|*
+|* Adjust-Buttons setzen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetAdjust_Impl(const XFormTextAdjustItem* pItem)
+{
+ if ( pItem )
+ {
+ USHORT nId;
+
+ aTbxAdjust.Enable();
+ aMtrFldDistance.Enable();
+
+ if ( pItem->GetValue() == XFT_LEFT || pItem->GetValue() == XFT_RIGHT )
+ {
+ if ( pItem->GetValue() == XFT_LEFT ) nId = TBI_ADJUST_LEFT;
+ else nId = TBI_ADJUST_RIGHT;
+ aMtrFldTextStart.Enable();
+ }
+ else
+ {
+ if ( pItem->GetValue() == XFT_CENTER ) nId = TBI_ADJUST_CENTER;
+ else nId = TBI_ADJUST_AUTOSIZE;
+ aMtrFldTextStart.Disable();
+ }
+
+ if ( !aTbxAdjust.IsItemChecked(nId) )
+ {
+ aTbxAdjust.CheckItem(nId);
+ }
+ nLastAdjustTbxId = nId;
+ }
+ else
+ {
+ aTbxAdjust.Disable();
+ aMtrFldTextStart.Disable();
+ aMtrFldDistance.Disable();
+ }
+}
+
+/*************************************************************************
+|*
+|* Abstand-Wert in Editfeld eintragen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetDistance_Impl(const XFormTextDistanceItem* pItem)
+{
+ // #104596# Use HasChildPathFocus() instead of HasFocus() at SpinFields
+ if ( pItem && !aMtrFldDistance.HasChildPathFocus() )
+ {
+ SetMetricValue( aMtrFldDistance, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
+ }
+}
+
+/*************************************************************************
+|*
+|* Einzug-Wert in Editfeld eintragen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetStart_Impl(const XFormTextStartItem* pItem)
+{
+ // #104596# Use HasChildPathFocus() instead of HasFocus() at SpinFields
+ if ( pItem && !aMtrFldTextStart.HasChildPathFocus() )
+ {
+ SetMetricValue( aMtrFldTextStart, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
+ }
+}
+
+/*************************************************************************
+|*
+|* Button fuer Umkehrung der Textrichtung setzen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetMirror_Impl(const XFormTextMirrorItem* pItem)
+{
+ if ( pItem )
+ aTbxAdjust.CheckItem(TBI_ADJUST_MIRROR, pItem->GetValue());
+}
+
+/*************************************************************************
+|*
+|* Standardform im ValueSet anzeigen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetStdForm_Impl(const XFormTextStdFormItem* pItem)
+{
+ if ( pItem )
+ {
+ aFormSet.Enable();
+ aFormSet.SetNoSelection();
+
+ if ( pItem->GetValue() != XFTFORM_NONE )
+ aFormSet.SelectItem(
+ sal::static_int_cast< USHORT >(pItem->GetValue()));
+ }
+ else
+ aFormSet.Disable();
+}
+
+/*************************************************************************
+|*
+|* Button fuer Konturanzeige setzen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetShowForm_Impl(const XFormTextHideFormItem* pItem)
+{
+ if ( pItem )
+ aTbxShadow.CheckItem(TBI_SHOWFORM, !pItem->GetValue());
+}
+
+/*************************************************************************
+|*
+|* Button fuer Zeichenumrandung setzen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetOutline_Impl(const XFormTextOutlineItem* pItem)
+{
+ if ( pItem )
+ aTbxShadow.CheckItem(TBI_OUTLINE, pItem->GetValue());
+}
+
+/*************************************************************************
+|*
+|* Shadow-Buttons setzen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetShadow_Impl(const XFormTextShadowItem* pItem,
+ BOOL bRestoreValues)
+{
+ if ( pItem )
+ {
+ USHORT nId;
+
+ aTbxShadow.Enable();
+
+ if ( pItem->GetValue() == XFTSHADOW_NONE )
+ {
+ nId = TBI_SHADOW_OFF;
+ aFbShadowX.Hide();
+ aFbShadowY.Hide();
+ aMtrFldShadowX.Disable();
+ aMtrFldShadowY.Disable();
+ aShadowColorLB.Disable();
+ }
+ else
+ {
+ aFbShadowX.Show();
+ aFbShadowY.Show();
+ aMtrFldShadowX.Enable();
+ aMtrFldShadowY.Enable();
+ aShadowColorLB.Enable();
+
+ if ( pItem->GetValue() == XFTSHADOW_NORMAL )
+ {
+ nId = TBI_SHADOW_NORMAL;
+ const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
+
+// aFbShadowX.SetBitmap( Bitmap( ResId(RID_SVXBMP_SHADOW_XDIST, _pMgr ) ) );
+ //aMtrFldShadowX.SetUnit(FUNIT_MM);
+ aMtrFldShadowX.SetUnit( eDlgUnit );
+ aMtrFldShadowX.SetDecimalDigits(2);
+ aMtrFldShadowX.SetMin(LONG_MIN);
+ aMtrFldShadowX.SetMax(LONG_MAX);
+ if( eDlgUnit == FUNIT_MM )
+ aMtrFldShadowX.SetSpinSize( 50 );
+ else
+ aMtrFldShadowX.SetSpinSize( 10 );
+
+// aFbShadowY.SetBitmap( Bitmap( ResId( RID_SVXBMP_SHADOW_YDIST, _pMgr ) ) );
+ //aMtrFldShadowY.SetUnit(FUNIT_MM);
+ aMtrFldShadowY.SetUnit( eDlgUnit );
+ aMtrFldShadowY.SetDecimalDigits(2);
+ aMtrFldShadowY.SetMin(LONG_MIN);
+ aMtrFldShadowY.SetMax(LONG_MAX);
+ if( eDlgUnit == FUNIT_MM )
+ aMtrFldShadowY.SetSpinSize( 50 );
+ else
+ aMtrFldShadowY.SetSpinSize( 10 );
+
+ if ( bRestoreValues )
+ {
+ SetMetricValue( aMtrFldShadowX, nSaveShadowX, SFX_MAPUNIT_100TH_MM );
+ SetMetricValue( aMtrFldShadowY, nSaveShadowY, SFX_MAPUNIT_100TH_MM );
+
+ XFormTextShadowXValItem aXItem( nSaveShadowX );
+ XFormTextShadowYValItem aYItem( nSaveShadowY );
+
+ GetBindings().GetDispatcher()->Execute(
+ SID_FORMTEXT_SHDWXVAL, SFX_CALLMODE_RECORD, &aXItem, &aYItem, 0L );
+ }
+ }
+ else
+ {
+ nId = TBI_SHADOW_SLANT;
+
+// aFbShadowX.SetBitmap( Bitmap( ResId( RID_SVXBMP_SHADOW_ANGLE, _pMgr ) ) );
+ aMtrFldShadowX.SetUnit(FUNIT_CUSTOM);
+ aMtrFldShadowX.SetDecimalDigits(1);
+ aMtrFldShadowX.SetMin(-1800);
+ aMtrFldShadowX.SetMax( 1800);
+ aMtrFldShadowX.SetSpinSize(10);
+
+// aFbShadowY.SetBitmap( Bitmap( ResId( RID_SVXBMP_SHADOW_SIZE, _pMgr ) ) );
+ aMtrFldShadowY.SetUnit(FUNIT_CUSTOM);
+ aMtrFldShadowY.SetDecimalDigits(0);
+ aMtrFldShadowY.SetMin(-999);
+ aMtrFldShadowY.SetMax( 999);
+ aMtrFldShadowY.SetSpinSize(10);
+
+ if ( bRestoreValues )
+ {
+ aMtrFldShadowX.SetValue(nSaveShadowAngle);
+ aMtrFldShadowY.SetValue(nSaveShadowSize);
+ XFormTextShadowXValItem aXItem(nSaveShadowAngle);
+ XFormTextShadowYValItem aYItem(nSaveShadowSize);
+ GetBindings().GetDispatcher()->Execute(
+ SID_FORMTEXT_SHDWXVAL, SFX_CALLMODE_RECORD, &aXItem, &aYItem, 0L );
+ }
+ }
+ }
+
+ if ( !aTbxShadow.IsItemChecked(nId) )
+ {
+ aTbxShadow.CheckItem(nId);
+ }
+ nLastShadowTbxId = nId;
+
+ ApplyImageList();
+ }
+ else
+ {
+ aTbxShadow.Disable();
+ aMtrFldShadowX.Disable();
+ aMtrFldShadowY.Disable();
+ aShadowColorLB.Disable();
+ }
+}
+
+/*************************************************************************
+|*
+|* Schattenfarbe in Listbox eintragen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetShadowColor_Impl(const XFormTextShadowColorItem* pItem)
+{
+ if ( pItem )
+ aShadowColorLB.SelectEntry(pItem->GetColorValue());
+}
+
+/*************************************************************************
+|*
+|* X-Wert fuer Schatten in Editfeld eintragen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetShadowXVal_Impl(const XFormTextShadowXValItem* pItem)
+{
+ // #104596# Use HasChildPathFocus() instead of HasFocus() at SpinFields
+ if ( pItem && !aMtrFldShadowX.HasChildPathFocus() )
+ {
+ // #i19251#
+ // INT32 nValue = pItem->GetValue();
+
+ // #i19251#
+ // The two involved fields/items are used double and contain/give different
+ // values regarding to the access method. Thus, here we need to separate the access
+ // methos regarding to the kind of value accessed.
+ if(aTbxShadow.IsItemChecked(TBI_SHADOW_SLANT))
+ {
+ // #i19251#
+ // There is no value correction necessary at all, i think this
+ // was only tried to be done without understanding that the two
+ // involved fields/items are used double and contain/give different
+ // values regarding to the access method.
+ // nValue = nValue - ( int( float( nValue ) / 360.0 ) * 360 );
+ aMtrFldShadowX.SetValue(pItem->GetValue());
+ }
+ else
+ {
+ SetMetricValue( aMtrFldShadowX, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Y-Wert fuer Schatten in Editfeld eintragen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetShadowYVal_Impl(const XFormTextShadowYValItem* pItem)
+{
+ // #104596# Use HasChildPathFocus() instead of HasFocus() at SpinFields
+ if ( pItem && !aMtrFldShadowY.HasChildPathFocus() )
+ {
+ // #i19251#
+ // The two involved fields/items are used double and contain/give different
+ // values regarding to the access method. Thus, here we need to separate the access
+ // methos regarding to the kind of value accessed.
+ if(aTbxShadow.IsItemChecked(TBI_SHADOW_SLANT))
+ {
+ aMtrFldShadowY.SetValue(pItem->GetValue());
+ }
+ else
+ {
+ SetMetricValue( aMtrFldShadowY, pItem->GetValue(), SFX_MAPUNIT_100TH_MM );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxFontWorkDialog, SelectStyleHdl_Impl, void *, EMPTYARG )
+{
+ USHORT nId = aTbxStyle.GetCurItemId();
+
+ // Execute this block when a different toolbox item has been clicked or
+ // when the off item has been clicked. The later is necessary to
+ // override the toolbox behaviour of unchecking the item after second
+ // click on it: One of the items has to be checked at all times (when
+ // enabled that is.)
+ if (nId == TBI_STYLE_OFF || nId != nLastStyleTbxId )
+ {
+ XFormTextStyle eStyle = XFT_NONE;
+
+ switch ( nId )
+ {
+ case TBI_STYLE_ROTATE : eStyle = XFT_ROTATE; break;
+ case TBI_STYLE_UPRIGHT : eStyle = XFT_UPRIGHT; break;
+ case TBI_STYLE_SLANTX : eStyle = XFT_SLANTX; break;
+ case TBI_STYLE_SLANTY : eStyle = XFT_SLANTY; break;
+ }
+ XFormTextStyleItem aItem( eStyle );
+ GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_STYLE, SFX_CALLMODE_RECORD, &aItem, 0L );
+ SetStyle_Impl( &aItem );
+ nLastStyleTbxId = nId;
+ }
+ return 0;
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxFontWorkDialog, SelectAdjustHdl_Impl, void *, EMPTYARG )
+{
+ USHORT nId = aTbxAdjust.GetCurItemId();
+
+ if ( nId == TBI_ADJUST_MIRROR )
+ {
+ XFormTextMirrorItem aItem(aTbxAdjust.IsItemChecked(nId));
+ GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_MIRROR, SFX_CALLMODE_SLOT, &aItem, 0L );
+ }
+ else if ( nId != nLastAdjustTbxId )
+ {
+ XFormTextAdjust eAdjust = XFT_AUTOSIZE;
+
+ switch ( nId )
+ {
+ case TBI_ADJUST_LEFT : eAdjust = XFT_LEFT; break;
+ case TBI_ADJUST_CENTER : eAdjust = XFT_CENTER; break;
+ case TBI_ADJUST_RIGHT : eAdjust = XFT_RIGHT; break;
+ }
+ XFormTextAdjustItem aItem(eAdjust);
+ GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_ADJUST, SFX_CALLMODE_RECORD, &aItem, 0L );
+ SetAdjust_Impl(&aItem);
+ nLastAdjustTbxId = nId;
+ }
+ return 0;
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxFontWorkDialog, SelectShadowHdl_Impl, void *, EMPTYARG )
+{
+ USHORT nId = aTbxShadow.GetCurItemId();
+
+ if ( nId == TBI_SHOWFORM )
+ {
+ XFormTextHideFormItem aItem(!aTbxShadow.IsItemChecked(nId));
+ GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_HIDEFORM, SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+ else if ( nId == TBI_OUTLINE )
+ {
+ XFormTextOutlineItem aItem(aTbxShadow.IsItemChecked(nId));
+ GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_OUTLINE, SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+ else if ( nId != nLastShadowTbxId )
+ {
+ XFormTextShadow eShadow = XFTSHADOW_NONE;
+
+ if ( nLastShadowTbxId == TBI_SHADOW_NORMAL )
+ {
+ nSaveShadowX = GetCoreValue( aMtrFldShadowX, SFX_MAPUNIT_100TH_MM );
+ nSaveShadowY = GetCoreValue( aMtrFldShadowY, SFX_MAPUNIT_100TH_MM );
+ }
+ else if ( nLastShadowTbxId == TBI_SHADOW_SLANT )
+ {
+ nSaveShadowAngle = static_cast<long>(aMtrFldShadowX.GetValue());
+ nSaveShadowSize = static_cast<long>(aMtrFldShadowY.GetValue());
+ }
+ nLastShadowTbxId = nId;
+
+ if ( nId == TBI_SHADOW_NORMAL ) eShadow = XFTSHADOW_NORMAL;
+ else if ( nId == TBI_SHADOW_SLANT ) eShadow = XFTSHADOW_SLANT;
+
+ XFormTextShadowItem aItem(eShadow);
+ GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_SHADOW, SFX_CALLMODE_RECORD, &aItem, 0L );
+ SetShadow_Impl(&aItem, TRUE);
+ }
+ return 0;
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+IMPL_LINK_INLINE_START( SvxFontWorkDialog, ModifyInputHdl_Impl, void *, EMPTYARG )
+{
+ aInputTimer.Start();
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvxFontWorkDialog, ModifyInputHdl_Impl, void *, EMPTYARG )
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxFontWorkDialog, InputTimoutHdl_Impl, void *, EMPTYARG )
+{
+ // System-Metrik evtl. neu setzen
+ // Dieses sollte mal als Listener passieren, ist aber aus
+ // inkompatibilitaetsgruenden z.Z. nicht moeglich
+ const FieldUnit eDlgUnit = rBindings.GetDispatcher()->GetModule()->GetFieldUnit();
+ if( eDlgUnit != aMtrFldDistance.GetUnit() )
+ {
+ SetFieldUnit( aMtrFldDistance, eDlgUnit, TRUE );
+ SetFieldUnit( aMtrFldTextStart, eDlgUnit, TRUE );
+ aMtrFldDistance.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
+ aMtrFldTextStart.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
+ }
+ if( eDlgUnit != aMtrFldShadowX.GetUnit() &&
+ aTbxShadow.IsItemChecked( TBI_SHADOW_NORMAL ) )
+ {
+ SetFieldUnit( aMtrFldShadowX, eDlgUnit, TRUE );
+ SetFieldUnit( aMtrFldShadowY, eDlgUnit, TRUE );
+ aMtrFldShadowX.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
+ aMtrFldShadowY.SetSpinSize( eDlgUnit == FUNIT_MM ? 50 : 10 );
+ }
+
+ long nValue = GetCoreValue( aMtrFldDistance, SFX_MAPUNIT_100TH_MM );
+ XFormTextDistanceItem aDistItem( nValue );
+ nValue = GetCoreValue( aMtrFldTextStart, SFX_MAPUNIT_100TH_MM );
+ XFormTextStartItem aStartItem( nValue );
+
+ sal_Int32 nValueX(0L);
+ sal_Int32 nValueY(0L);
+
+ // #i19251#
+ // The two involved fields/items are used double and contain/give different
+ // values regarding to the access method. Thus, here we need to separate the access
+ // methos regarding to the kind of value accessed.
+ if(nLastShadowTbxId == TBI_SHADOW_NORMAL)
+ {
+ nValueX = GetCoreValue( aMtrFldShadowX, SFX_MAPUNIT_100TH_MM );
+ nValueY = GetCoreValue( aMtrFldShadowY, SFX_MAPUNIT_100TH_MM );
+ }
+ else if(nLastShadowTbxId == TBI_SHADOW_SLANT)
+ {
+ nValueX = static_cast<long>(aMtrFldShadowX.GetValue());
+ nValueY = static_cast<long>(aMtrFldShadowY.GetValue());
+ }
+
+ XFormTextShadowXValItem aShadowXItem( nValueX );
+ XFormTextShadowYValItem aShadowYItem( nValueY );
+
+ // Slot-ID ist egal, die Exec-Methode wertet das gesamte ItemSet aus
+ GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_DISTANCE, SFX_CALLMODE_RECORD, &aDistItem,
+ &aStartItem, &aShadowXItem, &aShadowYItem, 0L );
+ return 0;
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxFontWorkDialog, FormSelectHdl_Impl, void *, EMPTYARG )
+{
+ XFormTextStdFormItem aItem;
+
+ if ( aFormSet.IsNoSelection() )
+ aItem.SetValue(XFTFORM_NONE);
+ else
+ aItem.SetValue(aFormSet.GetSelectItemId());
+ GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_STDFORM, SFX_CALLMODE_RECORD, &aItem, 0L );
+ aFormSet.SetNoSelection();
+ return 0;
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxFontWorkDialog, ColorSelectHdl_Impl, void *, EMPTYARG )
+{
+// Changed by obo. Linux-Compiler can't parse commented lines
+ XFormTextShadowColorItem aItem( (const String &) String(),
+ (const Color &) aShadowColorLB.GetSelectEntryColor() );
+// XFormTextShadowColorItem aItem( String(),
+// aShadowColorLB.GetSelectEntryColor() );
+ GetBindings().GetDispatcher()->Execute( SID_FORMTEXT_SHDWCOLOR, SFX_CALLMODE_RECORD, &aItem, 0L );
+ return 0;
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetColorTable(const XColorTable* pTable)
+{
+ if ( pTable && pTable != pColorTable )
+ {
+ pColorTable = pTable;
+ aShadowColorLB.Clear();
+ aShadowColorLB.Fill(pColorTable);
+ }
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::SetActive(BOOL /*bActivate*/)
+{
+}
+
+/*************************************************************************
+|*
+|* Standard-FontWork-Objekt erzeugen
+|*
+\************************************************************************/
+
+void SvxFontWorkDialog::CreateStdFormObj(SdrView& rView, SdrPageView& rPV,
+ const SfxItemSet& rAttr,
+ SdrObject& rOldObj,
+ XFormTextStdForm eForm)
+{
+ SfxItemSet aAttr(*rAttr.GetPool(), XATTR_FORMTXTSTYLE,
+ XATTR_FORMTXTHIDEFORM);
+ SdrObject* pNewObj = NULL;
+ Rectangle aRect;
+ XFormTextAdjust eAdjust = XFT_AUTOSIZE;
+
+//-/ rOldObj.TakeAttributes(aAttr, TRUE, FALSE);
+ aAttr.Put(rOldObj.GetMergedItemSet());
+
+ const XFormTextStdFormItem& rOldForm = (const XFormTextStdFormItem&)
+ aAttr.Get(XATTR_FORMTXTSTDFORM);
+
+ aRect = rOldObj.GetSnapRect();
+
+ if ( !rOldObj.ISA(SdrPathObj) )
+ {
+ Point aPos = aRect.TopLeft();
+ aRect = rOldObj.GetLogicRect();
+ aRect.SetPos(aPos);
+ }
+
+ aAttr.Put(rAttr);
+
+ if ( rOldForm.GetValue() == XFTFORM_NONE )
+ {
+ long nW = aRect.GetWidth();
+ aRect.SetSize(Size(nW, nW));
+ aAttr.Put(XFormTextStyleItem(XFT_ROTATE));
+ }
+
+ Point aCenter = aRect.Center();
+
+ switch ( eForm )
+ {
+ case XFTFORM_TOPCIRC:
+ case XFTFORM_BOTCIRC:
+ case XFTFORM_LFTCIRC:
+ case XFTFORM_RGTCIRC:
+ case XFTFORM_TOPARC:
+ case XFTFORM_BOTARC:
+ case XFTFORM_LFTARC:
+ case XFTFORM_RGTARC:
+ {
+ long nBeg, nEnd;
+
+ switch ( eForm )
+ {
+ default: ; //prevent warning
+ case XFTFORM_TOPCIRC:
+ nBeg = 0;
+ nEnd = 18000;
+ break;
+ case XFTFORM_BOTCIRC:
+ nBeg = 18000;
+ nEnd = 36000;
+ break;
+ case XFTFORM_LFTCIRC:
+ nBeg = 9000;
+ nEnd = 27000;
+ break;
+ case XFTFORM_RGTCIRC:
+ nBeg = 27000;
+ nEnd = 9000;
+ break;
+ case XFTFORM_TOPARC:
+ nBeg = 4500;
+ nEnd = 13500;
+ break;
+ case XFTFORM_BOTARC:
+ nBeg = 22500;
+ nEnd = 31500;
+ break;
+ case XFTFORM_LFTARC:
+ nBeg = 13500;
+ nEnd = 22500;
+ break;
+ case XFTFORM_RGTARC:
+ nBeg = 31500;
+ nEnd = 4500;
+ break;
+ }
+ pNewObj = new SdrCircObj(OBJ_CARC, aRect, nBeg, nEnd);
+ break;
+ }
+ case XFTFORM_BUTTON1:
+ {
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ basegfx::B2DPolygon aLine;
+ long nR = aRect.GetWidth() / 2;
+ basegfx::B2DPolygon aTopArc(XPolygon(aCenter, -nR, nR, 50, 1750, FALSE).getB2DPolygon());
+ basegfx::B2DPolygon aBottomArc(XPolygon(aCenter, -nR, nR, 1850, 3550, FALSE).getB2DPolygon());
+
+ // Polygone schliessen
+ aTopArc.setClosed(true);
+ aBottomArc.setClosed(true);
+ aPolyPolygon.append(aTopArc);
+
+ aLine.append(aBottomArc.getB2DPoint(aBottomArc.count() - 1L));
+ aLine.append(aBottomArc.getB2DPoint(0L));
+ aLine.setClosed(true);
+
+ aPolyPolygon.append(aLine);
+ aPolyPolygon.append(aBottomArc);
+
+ pNewObj = new SdrPathObj(OBJ_PATHFILL, aPolyPolygon);
+ eAdjust = XFT_CENTER;
+ break;
+ }
+ case XFTFORM_BUTTON2:
+ case XFTFORM_BUTTON3:
+ case XFTFORM_BUTTON4:
+ {
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ basegfx::B2DPolygon aLine;
+ long nR = aRect.GetWidth() / 2;
+ long nWDiff = nR / 5;
+ long nHDiff;
+
+ if ( eForm == XFTFORM_BUTTON4 )
+ {
+ basegfx::B2DPolygon aNewArc(XPolygon(aCenter, -nR, nR, 950, 2650, FALSE).getB2DPolygon());
+ aNewArc.setClosed(true);
+ aPolyPolygon.append(aNewArc);
+ eAdjust = XFT_CENTER;
+ }
+ else
+ {
+ basegfx::B2DPolygon aNewArc(XPolygon(aCenter, -nR, nR, 2700, 2700).getB2DPolygon());
+ aPolyPolygon.append(aNewArc);
+ }
+
+ if ( eForm == XFTFORM_BUTTON3 )
+ nHDiff = -aRect.GetHeight() / 10;
+ else
+ nHDiff = aRect.GetHeight() / 20;
+
+ aLine.append(basegfx::B2DPoint(aRect.Left() + nWDiff, aRect.Center().Y() + nHDiff));
+ aLine.append(basegfx::B2DPoint(aRect.Right() - nWDiff, aRect.Center().Y() + nHDiff));
+ aLine.setClosed(true);
+ aPolyPolygon.append(aLine);
+
+ if ( eForm == XFTFORM_BUTTON4 )
+ {
+ basegfx::B2DPolygon aNewArc(XPolygon(aCenter, -nR, nR, 2750, 850, FALSE).getB2DPolygon());
+ aNewArc.setClosed(true);
+ aPolyPolygon.append(aNewArc);
+ }
+
+ if ( eForm == XFTFORM_BUTTON3 )
+ {
+ nHDiff += nHDiff;
+ aLine.setB2DPoint(0L, basegfx::B2DPoint(aLine.getB2DPoint(0L).getX(), aLine.getB2DPoint(0L).getY() - nHDiff));
+ aLine.setB2DPoint(1L, basegfx::B2DPoint(aLine.getB2DPoint(1L).getX(), aLine.getB2DPoint(1L).getY() - nHDiff));
+ aPolyPolygon.append(aLine);
+ }
+
+ pNewObj = new SdrPathObj(OBJ_PATHFILL, aPolyPolygon);
+ break;
+ }
+ default: ; //prevent warning
+ }
+ if ( pNewObj )
+ {
+ // #78478# due to DLs changes in Outliner the object needs
+ // a model to get an outliner for later calls to
+ // pNewObj->SetOutlinerParaObject(pPara) (see below).
+ pNewObj->SetModel(rOldObj.GetModel());
+
+ Size aSize;
+ Rectangle aSnap = pNewObj->GetSnapRect();
+
+ aSize.Width() = aRect.Left() - aSnap.Left();
+ aSize.Height() = aRect.Top() - aSnap.Top();
+ pNewObj->NbcMove(aSize);
+
+ rView.BegUndo( SVX_RESSTR( RID_SVXSTR_FONTWORK_UNDOCREATE ) );
+ OutlinerParaObject* pPara = rOldObj.GetOutlinerParaObject();
+ BOOL bHide = TRUE;
+
+ if ( pPara != NULL )
+ {
+ pPara = new OutlinerParaObject(*pPara);
+ pNewObj->SetOutlinerParaObject(pPara);
+ }
+ else
+ bHide = FALSE;
+
+ rView.ReplaceObjectAtView(&rOldObj, rPV, pNewObj, TRUE);
+ pNewObj->SetLayer(rOldObj.GetLayer());
+ aAttr.Put(XFormTextHideFormItem(bHide));
+ aAttr.Put(XFormTextAdjustItem(eAdjust));
+
+ XFormTextShadow eShadow = XFTSHADOW_NONE;
+
+ if ( nLastShadowTbxId == TBI_SHADOW_NORMAL )
+ {
+ eShadow = XFTSHADOW_NORMAL;
+ aAttr.Put(XFormTextShadowXValItem(nSaveShadowX));
+ aAttr.Put(XFormTextShadowYValItem(nSaveShadowY));
+ }
+ else if ( nLastShadowTbxId == TBI_SHADOW_SLANT )
+ {
+ eShadow = XFTSHADOW_SLANT;
+ aAttr.Put(XFormTextShadowXValItem(nSaveShadowAngle));
+ aAttr.Put(XFormTextShadowYValItem(nSaveShadowSize));
+ }
+
+ aAttr.Put(XFormTextShadowItem(eShadow));
+
+ rView.SetAttributes(aAttr);
+ rView.EndUndo();
+ }
+}
+
+void SvxFontWorkDialog::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ ApplyImageList();
+
+ SfxDockingWindow::DataChanged( rDCEvt );
+}
+/* -----------------------------08.05.2002 14:28------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxFontWorkDialog::ApplyImageList()
+{
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ ResMgr* _pMgr = &DIALOG_MGR();
+
+ USHORT nBitmapResId = bHighContrast ? RID_SVXBMP_FONTWORK_FORM1_H : RID_SVXBMP_FONTWORK_FORM1;
+ USHORT nTextResId = RID_SVXSTR_FONTWORK_FORM1;
+
+ bool bInit = aFormSet.GetItemCount() == 0;
+
+ if( bInit )
+ {
+/*
+ Size aSize( aTbxStyle.CalcWindowSizePixel() );
+ Bitmap aBmp(ResId(RID_SVXBMP_FONTWORK_FORM1,_pMgr));
+ aSize.Height() = aFormSet.CalcWindowSizePixel(aBmp.GetSizePixel()).Height() + 2;
+ aFormSet.SetSizePixel(aSize);
+*/
+ }
+
+ USHORT i;
+ for( i = 1; i < 13; i++, nTextResId++, nBitmapResId++ )
+ {
+ if( bInit )
+ {
+ aFormSet.InsertItem( i, Bitmap(ResId(nBitmapResId,*_pMgr)),
+ String(ResId(nTextResId,*_pMgr)));
+ }
+ else
+ {
+ aFormSet.SetItemImage( i, Bitmap(ResId(nBitmapResId,*_pMgr)) );
+ }
+ }
+
+ ImageList& rImgLst = bHighContrast ? maImageListH : maImageList;
+
+ aTbxStyle.SetImageList( rImgLst );
+ aTbxAdjust.SetImageList( rImgLst );
+ aTbxShadow.SetImageList( rImgLst );
+
+ switch( nLastShadowTbxId )
+ {
+ case TBI_SHADOW_SLANT:
+ aFbShadowX.SetImage( rImgLst.GetImage( TBI_SHADOW_ANGLE ) );
+ aFbShadowY.SetImage( rImgLst.GetImage( TBI_SHADOW_SIZE ) );
+ break;
+// case TBI_SHADOW_NORMAL:
+ default:
+ aFbShadowX.SetImage( rImgLst.GetImage( TBI_SHADOW_XDIST ) );
+ aFbShadowY.SetImage( rImgLst.GetImage( TBI_SHADOW_YDIST ) );
+ break;
+ }
+
+ aFbDistance.SetImage( rImgLst.GetImage( TBI_DISTANCE ) );
+ aFbTextStart.SetImage( rImgLst.GetImage( TBI_TEXTSTART ) );
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/fontwork.hrc b/svx/source/dialog/fontwork.hrc
new file mode 100644
index 000000000000..a664dd3ce630
--- /dev/null
+++ b/svx/source/dialog/fontwork.hrc
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#define VS_FORMS 1
+#define TBX_STYLE 1
+#define TBX_ADJUST 2
+#define TBX_SHADOW 3
+
+#define FB_DISTANCE 1
+#define FB_TEXTSTART 2
+#define FB_SHADOW_X 3
+#define FB_SHADOW_Y 4
+#define MTR_FLD_DISTANCE 1
+#define MTR_FLD_TEXTSTART 2
+#define MTR_FLD_SHADOW_X 3
+#define MTR_FLD_SHADOW_Y 4
+#define CLB_SHADOW_COLOR 1
+
+#define IL_FONTWORK 1200
+#define ILH_FONTWORK 1201
+
+// the following ids are also used to identify the
+// bitmaps for the image list
+#define TBI_STYLE_OFF 1
+#define TBI_STYLE_ROTATE 2
+#define TBI_STYLE_UPRIGHT 3
+#define TBI_STYLE_SLANTX 4
+#define TBI_STYLE_SLANTY 5
+#define TBI_ADJUST_MIRROR 6
+#define TBI_ADJUST_LEFT 7
+#define TBI_ADJUST_CENTER 8
+#define TBI_ADJUST_RIGHT 9
+#define TBI_ADJUST_AUTOSIZE 10
+#define TBI_SHOWFORM 11
+#define TBI_OUTLINE 12
+#define TBI_SHADOW_OFF 13
+#define TBI_SHADOW_NORMAL 14
+#define TBI_SHADOW_SLANT 15
+#define TBI_SHADOW_XDIST 16
+#define TBI_SHADOW_YDIST 17
+#define TBI_SHADOW_ANGLE 18
+#define TBI_SHADOW_SIZE 19
+#define TBI_DISTANCE 20
+#define TBI_TEXTSTART 21
diff --git a/svx/source/dialog/fontwork.src b/svx/source/dialog/fontwork.src
new file mode 100644
index 000000000000..667ab90f968b
--- /dev/null
+++ b/svx/source/dialog/fontwork.src
@@ -0,0 +1,555 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include <svx/svxids.hrc>
+#include <svx/dialogs.hrc>
+#include "fontwork.hrc"
+#include "helpid.hrc"
+ // pragma ----------------------------------------------------------------
+
+ // RID_SVXDLG_FONTWORK ---------------------------------------------------
+DockingWindow RID_SVXDLG_FONTWORK
+{
+ HelpId = SID_FONTWORK ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 89 , 193 ) ;
+ Text [ en-US ] = "Fontwork" ;
+ Moveable = TRUE ;
+ Zoomable = TRUE ;
+ Closeable = TRUE ;
+ Dockable = TRUE ;
+ EnableResizing = TRUE ;
+ Control VS_FORMS
+ {
+ HelpId = HID_FONTWORK_CTL_FORMS ;
+ Pos = MAP_APPFONT ( 6 , 4 ) ;
+ Size = MAP_APPFONT ( 71 , 30 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ };
+ ToolBox TBX_STYLE
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 41 ) ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ Identifier = TBI_STYLE_OFF ;
+ HelpId = HID_FONTWORK_TBI_STYLE_OFF ;
+ Text [ en-US ] = "Off" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_STYLE_ROTATE ;
+ HelpId = HID_FONTWORK_TBI_STYLE_ROTATE ;
+ Text [ en-US ] = "Rotate" ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_STYLE_UPRIGHT ;
+ HelpId = HID_FONTWORK_TBI_STYLE_UPRIGHT ;
+ Text [ en-US ] = "Upright" ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_STYLE_SLANTX ;
+ HelpId = HID_FONTWORK_TBI_STYLE_SLANTX ;
+ Text [ en-US ] = "Slant Horizontal" ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_STYLE_SLANTY ;
+ HelpId = HID_FONTWORK_TBI_STYLE_SLANTY ;
+ Text [ en-US ] = "Slant Vertical" ;
+ };
+ };
+ };
+ ToolBox TBX_ADJUST
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 63 ) ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ Checkable = TRUE ;
+ Identifier = TBI_ADJUST_MIRROR ;
+ HelpId = HID_FONTWORK_TBI_ADJUST_MIRROR ;
+ Text [ en-US ] = "Orientation" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_ADJUST_LEFT ;
+ HelpId = HID_FONTWORK_TBI_ADJUST_LEFT ;
+ Text [ en-US ] = "Align Left" ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_ADJUST_CENTER ;
+ HelpId = HID_FONTWORK_TBI_ADJUST_CENTER ;
+ Text [ en-US ] = "Center" ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_ADJUST_RIGHT ;
+ HelpId = HID_FONTWORK_TBI_ADJUST_RIGHT ;
+ Text [ en-US ] = "Align Right" ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_ADJUST_AUTOSIZE ;
+ HelpId = HID_FONTWORK_TBI_ADJUST_AUTOSIZE ;
+ Text [ en-US ] = "AutoSize Text" ;
+ };
+ };
+ };
+ FixedImage FB_DISTANCE
+ {
+ Pos = MAP_APPFONT ( 10 , 84 ) ;
+ Size = MAP_APPFONT ( 14 , 15 ) ;
+ };
+ MetricField MTR_FLD_DISTANCE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 29 , 85 ) ;
+ Size = MAP_APPFONT ( 48 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = -5000000 ;
+ Maximum = 5000000 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ First = -5000000 ;
+ Last = 5000000 ;
+ SpinSize = 50 ;
+ QuickHelpText [ en-US ] = "Distance" ;
+
+ };
+ FixedImage FB_TEXTSTART
+ {
+ Pos = MAP_APPFONT ( 10 , 99 ) ;
+ Size = MAP_APPFONT ( 14 , 15 ) ;
+ };
+ MetricField MTR_FLD_TEXTSTART
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 29 , 100 ) ;
+ Size = MAP_APPFONT ( 48 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 5000000 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ Last = 5000000 ;
+ SpinSize = 50 ;
+ QuickHelpText [ en-US ] = "Indent" ;
+ };
+ ToolBox TBX_SHADOW
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 122 ) ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ Checkable = TRUE ;
+ Identifier = TBI_SHOWFORM ;
+ HelpId = HID_FONTWORK_TBI_SHOWFORM ;
+ Text [ en-US ] = "Contour" ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ Checkable = TRUE ;
+ Identifier = TBI_OUTLINE ;
+ HelpId = HID_FONTWORK_TBI_OUTLINE ;
+ Text [ en-US ] = "Text Contour" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_SHADOW_OFF ;
+ HelpId = HID_FONTWORK_TBI_SHADOW_OFF ;
+ Text [ en-US ] = "No Shadow" ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_SHADOW_NORMAL ;
+ HelpId = HID_FONTWORK_TBI_SHADOW_NORMAL ;
+ Text [ en-US ] = "Vertical" ;
+ };
+ ToolBoxItem
+ {
+ AutoCheck = TRUE ;
+ RadioCheck = TRUE ;
+ Identifier = TBI_SHADOW_SLANT ;
+ HelpId = HID_FONTWORK_TBI_SHADOW_SLANT ;
+ Text [ en-US ] = "Slant" ;
+ };
+ };
+ };
+ FixedImage FB_SHADOW_X
+ {
+ Pos = MAP_APPFONT ( 10 , 143 ) ;
+ Size = MAP_APPFONT ( 14 , 15 ) ;
+ };
+ MetricField MTR_FLD_SHADOW_X
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 29 , 144 ) ;
+ Size = MAP_APPFONT ( 48 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = -5000000 ;
+ Maximum = 5000000 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ CustomUnitText [ en-US ] = " degrees" ;
+ First = -5000000 ;
+ Last = 5000000 ;
+ SpinSize = 50 ;
+ QuickHelpText [ en-US ] = "Distance X" ;
+ };
+ FixedImage FB_SHADOW_Y
+ {
+ Pos = MAP_APPFONT ( 10 , 158 ) ;
+ Size = MAP_APPFONT ( 14 , 15 ) ;
+ };
+ MetricField MTR_FLD_SHADOW_Y
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 29 , 159 ) ;
+ Size = MAP_APPFONT ( 48 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 5000000 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ Last = 5000000 ;
+ SpinSize = 50 ;
+ QuickHelpText [ en-US ] = "Distance Y" ;
+ CustomUnitText [ en-US ] = "%" ;
+ };
+ ListBox CLB_SHADOW_COLOR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 174 ) ;
+ Size = MAP_APPFONT ( 71 , 60 ) ;
+ DropDown = TRUE ;
+ QuickHelpText [ en-US ] = "Shadow Color" ;
+ Text = "-";
+ };
+
+#define FONTWORK_IDLIST \
+ IdList = \
+ { \
+ TBI_STYLE_OFF ; \
+ TBI_STYLE_ROTATE ; \
+ TBI_STYLE_UPRIGHT ; \
+ TBI_STYLE_SLANTX ; \
+ TBI_STYLE_SLANTY ; \
+ TBI_ADJUST_MIRROR ; \
+ TBI_ADJUST_LEFT ; \
+ TBI_ADJUST_CENTER ; \
+ TBI_ADJUST_RIGHT ; \
+ TBI_ADJUST_AUTOSIZE ; \
+ TBI_SHOWFORM ; \
+ TBI_OUTLINE ; \
+ TBI_SHADOW_OFF ; \
+ TBI_SHADOW_NORMAL ; \
+ TBI_SHADOW_SLANT ; \
+ TBI_SHADOW_XDIST ; \
+ TBI_SHADOW_YDIST ; \
+ TBI_SHADOW_ANGLE ; \
+ TBI_SHADOW_SIZE ; \
+ TBI_DISTANCE ; \
+ TBI_TEXTSTART ; \
+ }; \
+ IdCount = { 21 ; };
+
+ #define IMAGE_STDBTN_COLOR Color { Red = 0xff00; Green = 0x0000; Blue = 0xff00; }
+
+ ImageList IL_FONTWORK
+ {
+ Prefix = "fw";
+ MaskColor = IMAGE_STDBTN_COLOR ;
+ FONTWORK_IDLIST
+ };
+ ImageList ILH_FONTWORK
+ {
+ Prefix = "fwh";
+ MaskColor = IMAGE_STDBTN_COLOR ;
+ FONTWORK_IDLIST
+ };
+};
+ // Bitmaps ---------------------------------------------------------------
+Bitmap RID_SVXBMP_FONTWORK_FORM1
+{
+ File = "fwthcirc.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM2
+{
+ File = "fwbhcirc.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM3
+{
+ File = "fwlhcirc.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM4
+{
+ File = "fwrhcirc.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM5
+{
+ File = "fwtoparc.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM6
+{
+ File = "fwbotarc.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM7
+{
+ File = "fwlftarc.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM8
+{
+ File = "fwrgtarc.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM9
+{
+ File = "fwbuttn1.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM10
+{
+ File = "fwbuttn2.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM11
+{
+ File = "fwbuttn3.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM12
+{
+ File = "fwbuttn4.bmp" ;
+};
+
+Bitmap RID_SVXBMP_FONTWORK_FORM1_H
+{
+ File = "fwthcirc_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM2_H
+{
+ File = "fwbhcirc_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM3_H
+{
+ File = "fwlhcirc_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM4_H
+{
+ File = "fwrhcirc_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM5_H
+{
+ File = "fwtoparc_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM6_H
+{
+ File = "fwbotarc_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM7_H
+{
+ File = "fwlftarc_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM8_H
+{
+ File = "fwrgtarc_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM9_H
+{
+ File = "fwbuttn1_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM10_H
+{
+ File = "fwbuttn2_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM11_H
+{
+ File = "fwbuttn3_h.bmp" ;
+};
+Bitmap RID_SVXBMP_FONTWORK_FORM12_H
+{
+ File = "fwbuttn4_h.bmp" ;
+};
+
+ // Strings ---------------------------------------------------------------
+String RID_SVXSTR_FONTWORK_FORM1
+{
+ Text [ en-US ] = "Upper Semicircle" ;
+};
+String RID_SVXSTR_FONTWORK_FORM2
+{
+ Text [ en-US ] = "Lower Semicircle" ;
+};
+String RID_SVXSTR_FONTWORK_FORM3
+{
+ Text [ en-US ] = "Left Semicircle" ;
+};
+String RID_SVXSTR_FONTWORK_FORM4
+{
+ Text [ en-US ] = "Right Semicircle" ;
+};
+String RID_SVXSTR_FONTWORK_FORM5
+{
+ Text [ en-US ] = "Upper Arc" ;
+};
+String RID_SVXSTR_FONTWORK_FORM6
+{
+ Text [ en-US ] = "Lower Arc" ;
+};
+String RID_SVXSTR_FONTWORK_FORM7
+{
+ Text [ en-US ] = "Left Arc" ;
+};
+String RID_SVXSTR_FONTWORK_FORM8
+{
+ Text [ en-US ] = "Right Arc" ;
+};
+String RID_SVXSTR_FONTWORK_FORM9
+{
+ Text [ en-US ] = "Open Circle" ;
+};
+String RID_SVXSTR_FONTWORK_FORM10
+{
+ Text [ en-US ] = "Closed Circle" ;
+};
+String RID_SVXSTR_FONTWORK_FORM11
+{
+ Text [ en-US ] = "Closed Circle II" ;
+};
+String RID_SVXSTR_FONTWORK_FORM12
+{
+ Text [ en-US ] = "Open Circle Vertical" ;
+};
+String RID_SVXSTR_FONTWORK_UNDOCREATE
+{
+ Text [ en-US ] = "Create Fontwork object" ;
+};
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/framelink.cxx b/svx/source/dialog/framelink.cxx
new file mode 100644
index 000000000000..6074b40ba220
--- /dev/null
+++ b/svx/source/dialog/framelink.cxx
@@ -0,0 +1,1436 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/framelink.hxx>
+
+#include <math.h>
+#include <vcl/outdev.hxx>
+#include <editeng/borderline.hxx>
+#include <svtools/borderhelper.hxx>
+
+// ----------------------------------------------------------------------------
+
+/** Define to select the drawing mode of thin dotted lines.
+
+ 0 = Draw lines using an own implementation (recommended). Draws always
+ little dots in an appropriate distance.
+ 1 = Draw dotted lines using vcl/LineInfo. Results in dashed lines instead
+ of dotted lines, which may look ugly for diagonal lines.
+ */
+#define SVX_FRAME_USE_LINEINFO 0
+
+// ----------------------------------------------------------------------------
+
+#if SVX_FRAME_USE_LINEINFO
+#include <vcl/lineinfo.hxx>
+#else
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#endif
+
+namespace svx {
+namespace frame {
+
+// ============================================================================
+// ============================================================================
+
+namespace {
+
+typedef std::vector< Point > PointVec;
+
+// ----------------------------------------------------------------------------
+// Link result structs for horizontal and vertical lines and borders.
+
+/** Result struct used by the horizontal/vertical frame link functions.
+
+ This struct is used to return coordinate offsets for one end of a single
+ line in a frame border, i.e. the left end of the primary line of a
+ horizontal frame border.
+
+ 1) Usage for horizontal lines
+
+ If this struct is returned by the lclLinkHorFrameBorder() function, each
+ member refers to the X coordinate of one edge of a single line end in a
+ horizontal frame border. They specify an offset to modify this coordinate
+ when the line is painted. The values in this struct may change a
+ rectangular line shape into a line with slanted left or right border, which
+ is used to connect the line with diagonal lines.
+
+ Usage for a left line end: Usage for a right line end:
+ mnOffs1 mnOffs1
+ <-------> <------->
+ +-------------------------------+
+ | the original horizontal line |
+ +-------------------------------+
+ <-------> <------->
+ mnOffs2 mnOffs2
+
+ 2) Usage for vertical lines
+
+ If this struct is returned by the lclLinkVerFrameBorder() function, each
+ member refers to the Y coordinate of one edge of a single line end in a
+ vertical frame border. They specify an offset to modify this coordinate
+ when the line is painted. The values in this struct may change a
+ rectangular line shape into a line with slanted top or bottom border, which
+ is used to connect the line with diagonal lines.
+
+ Usage for a top line end: mnOffs1 ^ ^ mnOffs2
+ | +-------+ |
+ v | | v
+ | |
+ | |
+ the original vertical line ---> | |
+ | |
+ | |
+ ^ | | ^
+ | +-------+ |
+ Usage for a bottom line end: mnOffs1 v v mnOffs2
+ */
+struct LineEndResult
+{
+ long mnOffs1; /// Offset for top or left edge, dependent of context.
+ long mnOffs2; /// Offset for bottom or right edge, dependent of context
+
+ inline explicit LineEndResult() : mnOffs1( 0 ), mnOffs2( 0 ) {}
+
+ inline void Swap() { std::swap( mnOffs1, mnOffs2 ); }
+ inline void Negate() { mnOffs1 = -mnOffs1; mnOffs2 = -mnOffs2; }
+};
+
+/** Result struct used by the horizontal/vertical frame link functions.
+
+ This struct contains the linking results for one end of a frame border,
+ including both the primary and secondary line ends.
+ */
+struct BorderEndResult
+{
+ LineEndResult maPrim; /// Result for primary line.
+ LineEndResult maSecn; /// Result for secondary line.
+
+ inline void Negate() { maPrim.Negate(); maSecn.Negate(); }
+};
+
+/** Result struct used by the horizontal/vertical frame link functions.
+
+ This struct contains the linking results for both frame border ends, and
+ therefore for the complete frame border.
+ */
+struct BorderResult
+{
+ BorderEndResult maBeg; /// Result for begin of border line (left or top end).
+ BorderEndResult maEnd; /// Result for end of border line (right or bottom end).
+};
+
+// ----------------------------------------------------------------------------
+// Link result structs for diagonal lines and borders.
+
+/** Result struct used by the diagonal frame link functions.
+
+ This struct contains the linking results for one line of a diagonal frame
+ border.
+ */
+struct DiagLineResult
+{
+ long mnLClip; /// Offset for left border of clipping rectangle.
+ long mnRClip; /// Offset for right border of clipping rectangle.
+ long mnTClip; /// Offset for top border of clipping rectangle.
+ long mnBClip; /// Offset for bottom border of clipping rectangle.
+
+ inline explicit DiagLineResult() : mnLClip( 0 ), mnRClip( 0 ), mnTClip( 0 ), mnBClip( 0 ) {}
+};
+
+/** Result struct used by the diagonal frame link functions.
+
+ This struct contains the linking results for one diagonal frame border.
+ */
+struct DiagBorderResult
+{
+ DiagLineResult maPrim; /// Result for primary line.
+ DiagLineResult maSecn; /// Result for secondary line.
+};
+
+/** Result struct used by the diagonal frame link functions.
+
+ This struct contains the linking results for both diagonal frame borders.
+ */
+struct DiagBordersResult
+{
+ DiagBorderResult maTLBR; /// Result for top-left to bottom-right frame border.
+ DiagBorderResult maBLTR; /// Result for bottom-left to top-right frame border.
+};
+
+// ----------------------------------------------------------------------------
+
+/** A helper struct containing two points of a line.
+ */
+struct LinePoints
+{
+ Point maBeg; /// Start position of the line.
+ Point maEnd; /// End position of the line.
+
+ explicit LinePoints( const Point& rBeg, const Point& rEnd ) :
+ maBeg( rBeg ), maEnd( rEnd ) {}
+ explicit LinePoints( const Rectangle& rRect, bool bTLBR ) :
+ maBeg( bTLBR ? rRect.TopLeft() : rRect.TopRight() ),
+ maEnd( bTLBR ? rRect.BottomRight() : rRect.BottomLeft() ) {}
+};
+
+// ============================================================================
+
+/** Rounds and casts a double value to a long value. */
+inline long lclD2L( double fValue )
+{
+ return static_cast< long >( (fValue < 0.0) ? (fValue - 0.5) : (fValue + 0.5) );
+}
+
+/** Converts a width in twips to a width in another map unit (specified by fScale). */
+sal_uInt16 lclScaleValue( long nValue, double fScale, sal_uInt16 nMaxWidth )
+{
+ // convert any width except 0 to at least 1 unit
+ // #i61324# 1 twip must scale to 1/100mm
+ return nValue ? static_cast< sal_uInt16 >( std::min< long >( std::max(
+ static_cast< long >( nValue * fScale ), 1L ), nMaxWidth ) ) : 0;
+}
+
+// ----------------------------------------------------------------------------
+// Line width offset calculation.
+
+/** Returns the start offset of the single/primary line across the frame border.
+
+ All following lclGet*Beg() and lclGet*End() functions return sub units to
+ increase the computational accuracy, where 256 sub units are equal to
+ 1 map unit of the used OutputDevice.
+
+ The following pictures show the upper end of a vertical frame border and
+ illustrates the return values of all following lclGet*Beg() and lclGet*End()
+ functions. The first picture shows a single frame border, the second picture
+ shows a double frame border.
+
+ The functions regard the reference point handling mode of the passed border
+ style.
+ REFMODE_CENTERED:
+ All returned offsets are relative to the middle position of the frame
+ border (offsets left of the middle are returned negative, offsets right
+ of the middle are returned positive).
+ REFMODE_BEGIN:
+ All returned offsets are relative to the begin of the frame border
+ (lclGetBeg() always returns 0).
+ REFMODE_END:
+ All returned offsets are relative to the end of the frame border
+ (lclGetEnd() always returns 0).
+
+ |<- lclGetEnd()
+ |<- lclGetBeforeBeg() |<- lclGetPrimEnd()
+ | |
+ ||<- lclGetBeg() ||<- lclGetBehindEnd()
+ || ||
+ |#################################|
+ direction of | #################################
+ the frame | #################################
+ border is | #################################
+ vertical | #################################
+ v #################################
+ |
+ |<- middle of the frame border
+
+
+ lclGetDistEnd() ->||<- lclGetSecnBeg()
+ ||
+ lclGetBeg() ->| lclGetDistBeg() ->| || |<- lclGetEnd()
+ | | || |
+ lclGetBeforeBeg()->|| lclGetPrimEnd() ->|| || ||<- lclGetBehindEnd()
+ || || || ||
+ |######################| |#############|
+ direction of | ###################### #############
+ the frame | ###################### #############
+ border is | ###################### #############
+ vertical | ###################### | #############
+ v ###################### | #############
+ primary line | secondary line
+ |
+ |<- middle of the frame border
+
+ @return
+ The start offset of the single/primary line relative to the reference
+ position of the frame border (sub units; 0 for invisible or one pixel
+ wide single frame styles).
+ */
+long lclGetBeg( const Style& rBorder )
+{
+ long nPos = 0;
+ switch( rBorder.GetRefMode() )
+ {
+ case REFMODE_CENTERED: if( rBorder.Prim() ) nPos = -128 * (rBorder.GetWidth() - 1); break;
+ case REFMODE_END: if( rBorder.Prim() ) nPos = -256 * (rBorder.GetWidth() - 1); break;
+ case REFMODE_BEGIN: break;
+ }
+ return nPos;
+}
+
+/** Returns the end offset of the single/secondary line across the frame border.
+ @descr See description of lclGetBeg() for an illustration.
+ @return The end offset of the single/secondary line relative to the
+ reference position of the frame border (sub units; 0 for invisible or one
+ pixel wide single frame styles). */
+long lclGetEnd( const Style& rBorder )
+{
+ long nPos = 0;
+ switch( rBorder.GetRefMode() )
+ {
+ case REFMODE_CENTERED: if( rBorder.Prim() ) nPos = 128 * (rBorder.GetWidth() - 1); break;
+ case REFMODE_BEGIN: if( rBorder.Prim() ) nPos = 256 * (rBorder.GetWidth() - 1); break;
+ case REFMODE_END: break;
+ }
+ return nPos;
+}
+
+/** Returns the end offset of the primary line across the frame border.
+ @descr See description of lclGetBeg() for an illustration.
+ @return The end offset of the primary line relative to the reference
+ position of the frame border (sub units; the end of the primary line in a
+ double frame style, otherwise the same as lclGetEnd()). */
+inline long lclGetPrimEnd( const Style& rBorder )
+{ return rBorder.Prim() ? (lclGetBeg( rBorder ) + 256 * (rBorder.Prim() - 1)) : 0; }
+
+/** Returns the start offset of the secondary line across the frame border.
+ @descr See description of lclGetBeg() for an illustration.
+ @return The start offset of the secondary line relative to the reference
+ position of the frame border (sub units; 0 for single/invisible border
+ styles). */
+inline long lclGetSecnBeg( const Style& rBorder )
+{ return rBorder.Secn() ? (lclGetEnd( rBorder ) - 256 * (rBorder.Secn() - 1)) : 0; }
+
+/** Returns the start offset of the distance space across the frame border.
+ @descr See description of lclGetBeg() for an illustration.
+ @return The start offset of the distance space relative to the reference
+ position of the frame border (sub units; 0 for single/invisible border
+ styles). */
+inline long lclGetDistBeg( const Style& rBorder )
+{ return rBorder.Secn() ? (lclGetBeg( rBorder ) + 256 * rBorder.Prim()) : 0; }
+
+/** Returns the end offset of the distance space across the frame border.
+ @descr See description of lclGetBeg() for an illustration.
+ @return The end offset of the distance space relative to the reference
+ position of the frame border (sub units; 0 for single/invisible border
+ styles). */
+inline long lclGetDistEnd( const Style& rBorder )
+{ return rBorder.Secn() ? (lclGetEnd( rBorder ) - 256 * rBorder.Secn()) : 0; }
+
+/** Returns the offset before start of single/primary line across the frame border.
+ @descr See description of lclGetBeg() for an illustration.
+ @return The offset directly before start of single/primary line relative
+ to the reference position of the frame border (sub units; a value one less
+ than lclGetBeg() for visible frame styles, or 0 for invisible frame style). */
+inline long lclGetBeforeBeg( const Style& rBorder )
+{ return rBorder.Prim() ? (lclGetBeg( rBorder ) - 256) : 0; }
+
+/** Returns the offset behind end of single/secondary line across the frame border.
+ @descr See description of lclGetBeg() for an illustration.
+ @return The offset directly behind end of single/secondary line relative
+ to the reference position of the frame border (sub units; a value one
+ greater than lclGetEnd() for visible frame styles, or 0 for invisible frame
+ style). */
+inline long lclGetBehindEnd( const Style& rBorder )
+{ return rBorder.Prim() ? (lclGetEnd( rBorder ) + 256) : 0; }
+
+// ============================================================================
+// Linking functions
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// Linking of single horizontal line ends.
+
+/** Calculates X offsets for the left end of a single horizontal frame border.
+
+ See DrawHorFrameBorder() function for a description of all parameters.
+
+ @param rResult
+ (out-param) The contained values (sub units) specify offsets for the
+ X coordinates of the left line end.
+ */
+void lclLinkLeftEnd_Single(
+ LineEndResult& rResult, const Style& rBorder,
+ const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& rLFromBR )
+{
+ // both vertical and diagonal frame borders are double
+ if( rLFromT.Secn() && rLFromB.Secn() && rLFromTR.Secn() && rLFromBR.Secn() )
+ {
+ // take left position of upper and lower secondary start
+ rResult.mnOffs1 = GetBLDiagOffset( lclGetBeg( rBorder ), lclGetSecnBeg( rLFromTR ), rLFromTR.GetAngle() );
+ rResult.mnOffs2 = GetTLDiagOffset( lclGetEnd( rBorder ), lclGetSecnBeg( rLFromBR ), rLFromBR.GetAngle() );
+ }
+ else
+ {
+ // both vertical frame borders are double
+ if( rLFromT.Secn() && rLFromB.Secn() )
+ rResult.mnOffs1 = (!rLFromTR.Secn() && !rLFromBR.Secn() && (rLFromT.GetWidth() == rLFromB.GetWidth())) ?
+ // don't overdraw vertical borders with equal width
+ lclGetBehindEnd( rLFromT ) :
+ // take leftmost start of both secondary lines (#46488#)
+ std::min( lclGetSecnBeg( rLFromT ), lclGetSecnBeg( rLFromB ) );
+
+ // single border with equal width coming from left
+ else if( !rLFromL.Secn() && (rLFromL.Prim() == rBorder.Prim()) )
+ // draw to connection point
+ rResult.mnOffs1 = 0;
+
+ // single border coming from left
+ else if( !rLFromL.Secn() && rLFromL.Prim() )
+ {
+ if( rLFromL.Prim() == rBorder.Prim() )
+ // draw to reference position, if from left has equal width
+ rResult.mnOffs1 = 0;
+ else
+ rResult.mnOffs1 = (rLFromL < rBorder) ?
+ // take leftmost start of both frame borders, if from left is thinner
+ std::min( lclGetBeg( rLFromT ), lclGetBeg( rLFromB ) ) :
+ // do not overdraw vertical, if from left is thicker
+ std::max( lclGetBehindEnd( rLFromT ), lclGetBehindEnd( rLFromB ) );
+ }
+
+ // no border coming from left
+ else if( !rLFromL.Prim() )
+ // don't overdraw vertical borders with equal width
+ rResult.mnOffs1 = (rLFromT.GetWidth() == rLFromB.GetWidth()) ?
+ lclGetBehindEnd( rLFromT ) :
+ std::min( lclGetBeg( rLFromT ), lclGetBeg( rLFromB ) );
+
+ // double frame border coming from left and from top
+ else if( rLFromT.Secn() )
+ // do not overdraw the vertical double frame border
+ rResult.mnOffs1 = lclGetBehindEnd( rLFromT );
+
+ // double frame border coming from left and from bottom
+ else if( rLFromB.Secn() )
+ // do not overdraw the vertical double frame border
+ rResult.mnOffs1 = lclGetBehindEnd( rLFromB );
+
+ // double frame border coming from left, both vertical frame borders are single or off
+ else
+ // draw from leftmost start of both frame borders, if from left is not thicker
+ rResult.mnOffs1 = (rLFromL <= rBorder) ?
+ std::min( lclGetBeg( rLFromT ), lclGetBeg( rLFromB ) ) :
+ std::max( lclGetBehindEnd( rLFromT ), lclGetBehindEnd( rLFromB ) );
+
+ // bottom-left point is equal to top-left point (results in rectangle)
+ rResult.mnOffs2 = rResult.mnOffs1;
+ }
+}
+
+/** Calculates X offsets for the left end of a primary horizontal line.
+
+ See DrawHorFrameBorder() function for a description of all parameters.
+
+ @param rResult
+ (out-param) The contained values (sub units) specify offsets for the
+ X coordinates of the left end of the primary line.
+ */
+void lclLinkLeftEnd_Prim(
+ LineEndResult& rResult, const Style& rBorder,
+ const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& /*rLFromBR*/ )
+{
+ // double diagonal frame border coming from top right
+ if( rLFromTR.Secn() )
+ {
+ // draw from where secondary diagonal line meets the own primary
+ rResult.mnOffs1 = GetBLDiagOffset( lclGetBeg( rBorder ), lclGetSecnBeg( rLFromTR ), rLFromTR.GetAngle() );
+ rResult.mnOffs2 = GetBLDiagOffset( lclGetPrimEnd( rBorder ), lclGetSecnBeg( rLFromTR ), rLFromTR.GetAngle() );
+ }
+
+ // no or single diagonal frame border - ignore it
+ else
+ {
+ // double frame border coming from top
+ if( rLFromT.Secn() )
+ // draw from left edge of secondary vertical
+ rResult.mnOffs1 = lclGetSecnBeg( rLFromT );
+
+ // double frame border coming from left (from top is not double)
+ else if( rLFromL.Secn() )
+ // do not overdraw single frame border coming from top
+ rResult.mnOffs1 = (rLFromL.GetWidth() == rBorder.GetWidth()) ?
+ 0 : lclGetBehindEnd( rLFromT );
+
+ // double frame border coming from bottom (from top and from left are not double)
+ else if( rLFromB.Secn() )
+ // draw from left edge of primary vertical from bottom
+ rResult.mnOffs1 = lclGetBeg( rLFromB );
+
+ // no other frame border is double
+ else
+ // do not overdraw vertical frame borders
+ rResult.mnOffs1 = std::max( lclGetBehindEnd( rLFromT ), lclGetBehindEnd( rLFromB ) );
+
+ // bottom-left point is equal to top-left point (results in rectangle)
+ rResult.mnOffs2 = rResult.mnOffs1;
+ }
+}
+
+/** Calculates X offsets for the left end of a secondary horizontal line.
+
+ See DrawHorFrameBorder() function for a description of all parameters.
+
+ @param rResult
+ (out-param) The contained values (sub units) specify offsets for the
+ X coordinates of the left end of the secondary line.
+ */
+void lclLinkLeftEnd_Secn(
+ LineEndResult& rResult, const Style& rBorder,
+ const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& rLFromBR )
+{
+ /* Recycle lclLinkLeftEnd_Prim() function with mirrored horizontal borders. */
+ lclLinkLeftEnd_Prim( rResult, rBorder.Mirror(), rLFromBR, rLFromB, rLFromL.Mirror(), rLFromT, rLFromTR );
+ rResult.Swap();
+}
+
+// ----------------------------------------------------------------------------
+// Linking of horizontal frame border ends.
+
+/** Calculates X offsets for the left end of a horizontal frame border.
+
+ This function can be used for single and double frame borders.
+ See DrawHorFrameBorder() function for a description of all parameters.
+
+ @param rResult
+ (out-param) The contained values (sub units) specify offsets for the
+ X coordinates of the left end of the line(s) in the frame border.
+ */
+void lclLinkLeftEnd(
+ BorderEndResult& rResult, const Style& rBorder,
+ const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& rLFromBR )
+{
+ if( rBorder.Secn() )
+ {
+ // current frame border is double
+ lclLinkLeftEnd_Prim( rResult.maPrim, rBorder, rLFromTR, rLFromT, rLFromL, rLFromB, rLFromBR );
+ lclLinkLeftEnd_Secn( rResult.maSecn, rBorder, rLFromTR, rLFromT, rLFromL, rLFromB, rLFromBR );
+ }
+ else if( rBorder.Prim() )
+ {
+ // current frame border is single
+ lclLinkLeftEnd_Single( rResult.maPrim, rBorder, rLFromTR, rLFromT, rLFromL, rLFromB, rLFromBR );
+ }
+ else
+ {
+ DBG_ERRORFILE( "lclLinkLeftEnd - called for invisible frame style" );
+ }
+}
+
+/** Calculates X offsets for the right end of a horizontal frame border.
+
+ This function can be used for single and double frame borders.
+ See DrawHorFrameBorder() function for a description of all parameters.
+
+ @param rResult
+ (out-param) The contained values (sub units) specify offsets for the
+ X coordinates of the right end of the line(s) in the frame border.
+ */
+void lclLinkRightEnd(
+ BorderEndResult& rResult, const Style& rBorder,
+ const DiagStyle& rRFromTL, const Style& rRFromT, const Style& rRFromR, const Style& rRFromB, const DiagStyle& rRFromBL )
+{
+ /* Recycle lclLinkLeftEnd() function with mirrored vertical borders. */
+ lclLinkLeftEnd( rResult, rBorder, rRFromTL.Mirror(), rRFromT.Mirror(), rRFromR, rRFromB.Mirror(), rRFromBL.Mirror() );
+ rResult.Negate();
+}
+
+// ----------------------------------------------------------------------------
+// Linking of horizontal and vertical frame borders.
+
+/** Calculates X offsets for all line ends of a horizontal frame border.
+
+ This function can be used for single and double frame borders.
+ See DrawHorFrameBorder() function for a description of all parameters.
+
+ @param rResult
+ (out-param) The contained values (sub units) specify offsets for the
+ X coordinates of both ends of the line(s) in the frame border. To get
+ the actual X coordinates to draw the lines, these offsets have to be
+ added to the X coordinates of the reference points of the frame border
+ (the offsets may be negative).
+ */
+void lclLinkHorFrameBorder(
+ BorderResult& rResult, const Style& rBorder,
+ const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& rLFromBR,
+ const DiagStyle& rRFromTL, const Style& rRFromT, const Style& rRFromR, const Style& rRFromB, const DiagStyle& rRFromBL )
+{
+ lclLinkLeftEnd( rResult.maBeg, rBorder, rLFromTR, rLFromT, rLFromL, rLFromB, rLFromBR );
+ lclLinkRightEnd( rResult.maEnd, rBorder, rRFromTL, rRFromT, rRFromR, rRFromB, rRFromBL );
+}
+
+/** Calculates Y offsets for all line ends of a vertical frame border.
+
+ This function can be used for single and double frame borders.
+ See DrawVerFrameBorder() function for a description of all parameters.
+
+ @param rResult
+ (out-param) The contained values (sub units) specify offsets for the
+ Y coordinates of both ends of the line(s) in the frame border. To get
+ the actual Y coordinates to draw the lines, these offsets have to be
+ added to the Y coordinates of the reference points of the frame border
+ (the offsets may be negative).
+ */
+void lclLinkVerFrameBorder(
+ BorderResult& rResult, const Style& rBorder,
+ const DiagStyle& rTFromBL, const Style& rTFromL, const Style& rTFromT, const Style& rTFromR, const DiagStyle& rTFromBR,
+ const DiagStyle& rBFromTL, const Style& rBFromL, const Style& rBFromB, const Style& rBFromR, const DiagStyle& rBFromTR )
+{
+ /* Recycle lclLinkHorFrameBorder() function with correct parameters. The
+ frame border is virtually mirrored at the top-left to bottom-right
+ diagonal. rTFromBR and rBFromTL are mirrored to process their primary
+ and secondary lines correctly. */
+ lclLinkHorFrameBorder( rResult, rBorder,
+ rTFromBL, rTFromL, rTFromT, rTFromR, rTFromBR.Mirror(),
+ rBFromTL.Mirror(), rBFromL, rBFromB, rBFromR, rBFromTR );
+}
+
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// Linking of diagonal frame borders.
+
+/** Calculates clipping offsets for a top-left to bottom-right frame border.
+
+ This function can be used for single and double frame borders.
+ See DrawDiagFrameBorders() function for a description of all parameters.
+
+ @param rResult
+ (out-param) The contained values (sub units) specify offsets for all
+ borders of the reference rectangle containing the diagonal frame border.
+ */
+void lclLinkTLBRFrameBorder(
+ DiagBorderResult& rResult, const Style& rBorder,
+ const Style& rTLFromB, const Style& rTLFromR, const Style& rBRFromT, const Style& rBRFromL )
+{
+ bool bIsDbl = rBorder.Secn() != 0;
+
+ rResult.maPrim.mnLClip = lclGetBehindEnd( rTLFromB );
+ rResult.maPrim.mnRClip = (bIsDbl && rBRFromT.Secn()) ? lclGetEnd( rBRFromT ) : lclGetBeforeBeg( rBRFromT );
+ rResult.maPrim.mnTClip = (bIsDbl && rTLFromR.Secn()) ? lclGetBeg( rTLFromR ) : lclGetBehindEnd( rTLFromR );
+ rResult.maPrim.mnBClip = lclGetBeforeBeg( rBRFromL );
+
+ if( bIsDbl )
+ {
+ rResult.maSecn.mnLClip = rTLFromB.Secn() ? lclGetBeg( rTLFromB ) : lclGetBehindEnd( rTLFromB );
+ rResult.maSecn.mnRClip = lclGetBeforeBeg( rBRFromT );
+ rResult.maSecn.mnTClip = lclGetBehindEnd( rTLFromR );
+ rResult.maSecn.mnBClip = rBRFromL.Secn() ? lclGetEnd( rBRFromL ) : lclGetBeforeBeg( rBRFromL );
+ }
+}
+
+/** Calculates clipping offsets for a bottom-left to top-right frame border.
+
+ This function can be used for single and double frame borders.
+ See DrawDiagFrameBorders() function for a description of all parameters.
+
+ @param rResult
+ (out-param) The contained values (sub units) specify offsets for all
+ borders of the reference rectangle containing the diagonal frame border.
+ */
+void lclLinkBLTRFrameBorder(
+ DiagBorderResult& rResult, const Style& rBorder,
+ const Style& rBLFromT, const Style& rBLFromR, const Style& rTRFromB, const Style& rTRFromL )
+{
+ bool bIsDbl = rBorder.Secn() != 0;
+
+ rResult.maPrim.mnLClip = lclGetBehindEnd( rBLFromT );
+ rResult.maPrim.mnRClip = (bIsDbl && rTRFromB.Secn()) ? lclGetEnd( rTRFromB ) : lclGetBeforeBeg( rTRFromB );
+ rResult.maPrim.mnTClip = lclGetBehindEnd( rTRFromL );
+ rResult.maPrim.mnBClip = (bIsDbl && rBLFromR.Secn()) ? lclGetEnd( rBLFromR ) : lclGetBeforeBeg( rBLFromR );
+
+ if( bIsDbl )
+ {
+ rResult.maSecn.mnLClip = rBLFromT.Secn() ? lclGetBeg( rBLFromT ) : lclGetBehindEnd( rBLFromT );
+ rResult.maSecn.mnRClip = lclGetBeforeBeg( rTRFromB );
+ rResult.maSecn.mnTClip = rTRFromL.Secn() ? lclGetBeg( rTRFromL ) : lclGetBehindEnd( rTRFromL );
+ rResult.maSecn.mnBClip = lclGetBeforeBeg( rBLFromR );
+ }
+}
+
+/** Calculates clipping offsets for both diagonal frame borders.
+
+ This function can be used for single and double frame borders.
+ See DrawDiagFrameBorders() function for a description of all parameters.
+
+ @param rResult
+ (out-param) The contained values (sub units) specify offsets for all
+ borders of the reference rectangle containing the diagonal frame
+ borders.
+ */
+void lclLinkDiagFrameBorders(
+ DiagBordersResult& rResult, const Style& rTLBR, const Style& rBLTR,
+ const Style& rTLFromB, const Style& rTLFromR, const Style& rBRFromT, const Style& rBRFromL,
+ const Style& rBLFromT, const Style& rBLFromR, const Style& rTRFromB, const Style& rTRFromL )
+{
+ lclLinkTLBRFrameBorder( rResult.maTLBR, rTLBR, rTLFromB, rTLFromR, rBRFromT, rBRFromL );
+ lclLinkBLTRFrameBorder( rResult.maBLTR, rBLTR, rBLFromT, rBLFromR, rTRFromB, rTRFromL );
+}
+
+// ============================================================================
+// Drawing functions
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// Simple helper functions
+
+/** Converts sub units to OutputDevice map units. */
+inline long lclToMapUnit( long nSubUnits )
+{
+ return ((nSubUnits < 0) ? (nSubUnits - 127) : (nSubUnits + 128)) / 256;
+}
+
+/** Converts a point in sub units to an OutputDevice point. */
+inline Point lclToMapUnit( long nSubXPos, long nSubYPos )
+{
+ return Point( lclToMapUnit( nSubXPos ), lclToMapUnit( nSubYPos ) );
+}
+
+/** Returns a polygon constructed from a vector of points. */
+inline Polygon lclCreatePolygon( const PointVec& rPoints )
+{
+ return Polygon( static_cast< USHORT >( rPoints.size() ), &rPoints[ 0 ] );
+}
+
+/** Returns a polygon constructed from the four passed points. */
+Polygon lclCreatePolygon( const Point& rP1, const Point& rP2, const Point& rP3, const Point& rP4 )
+{
+ PointVec aPoints;
+ aPoints.reserve( 2 );
+ aPoints.push_back( rP1 );
+ aPoints.push_back( rP2 );
+ aPoints.push_back( rP3 );
+ aPoints.push_back( rP4 );
+ return lclCreatePolygon( aPoints );
+}
+
+/** Returns a polygon constructed from the five passed points. */
+Polygon lclCreatePolygon( const Point& rP1, const Point& rP2, const Point& rP3, const Point& rP4, const Point& rP5 )
+{
+ PointVec aPoints;
+ aPoints.reserve( 5 );
+ aPoints.push_back( rP1 );
+ aPoints.push_back( rP2 );
+ aPoints.push_back( rP3 );
+ aPoints.push_back( rP4 );
+ aPoints.push_back( rP5 );
+ return lclCreatePolygon( aPoints );
+}
+
+/** Sets the color of the passed frame style to the output device.
+
+ Sets the line color and fill color in the output device.
+
+ @param rDev
+ The output device the color has to be set to. The old colors are pushed
+ onto the device's stack and can be restored with a call to
+ OutputDevice::Pop(). Please take care about the correct calling order
+ of Pop() if this function is used with other functions pushing
+ something onto the stack.
+ @param rStyle
+ The border style that contains the line color to be set to the device.
+ */
+void lclSetColorToOutDev( OutputDevice& rDev, const Style& rStyle, const Color* pForceColor )
+{
+ rDev.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
+ rDev.SetLineColor( pForceColor ? *pForceColor : rStyle.GetColor() );
+ rDev.SetFillColor( pForceColor ? *pForceColor : rStyle.GetColor() );
+}
+
+// ----------------------------------------------------------------------------
+// ============================================================================
+// Drawing of horizontal frame borders.
+
+/** Draws a horizontal thin or thick line into the passed output device.
+
+ The X coordinates of the edges of the line are adjusted according to the
+ passed LineEndResult structs. A one pixel wide line can be drawn dotted.
+ */
+void lclDrawHorLine(
+ OutputDevice& rDev,
+ const Point& rLPos, const LineEndResult& rLRes,
+ const Point& rRPos, const LineEndResult& rRRes,
+ long nTOffs, long nBOffs, SvxBorderStyle nDashing )
+{
+ LinePoints aTPoints( rLPos + lclToMapUnit( rLRes.mnOffs1, nTOffs ), rRPos + lclToMapUnit( rRRes.mnOffs1, nTOffs ) );
+ LinePoints aBPoints( rLPos + lclToMapUnit( rLRes.mnOffs2, nBOffs ), rRPos + lclToMapUnit( rRRes.mnOffs2, nBOffs ) );
+
+ sal_uInt32 nWidth = lclToMapUnit( abs( nTOffs ) ) + lclToMapUnit( abs( nBOffs ) );
+ if ( ( nTOffs >= 0 && nBOffs >= 0 ) || ( nTOffs <= 0 && nBOffs <= 0 ) )
+ nWidth = abs( lclToMapUnit( nTOffs ) - lclToMapUnit( nBOffs ) ) + 1;
+ Point rLMid = ( aTPoints.maBeg + aBPoints.maBeg ) / 2;
+ Point rRMid = ( aTPoints.maEnd + aBPoints.maEnd ) / 2;
+
+ ::svtools::DrawLine( rDev, rLMid, rRMid, nWidth, nDashing );
+}
+
+/** Draws a horizontal frame border into the passed output device.
+
+ @param rLPos
+ The top-left or bottom-left reference point of the diagonal frame border.
+ @param rRPos
+ The top-right or bottom-right reference point of the diagonal frame border.
+ @param rBorder
+ The frame style used to draw the border.
+ @param rResult
+ The X coordinates of the edges of all lines of the frame border are
+ adjusted according to the offsets contained here.
+ */
+void lclDrawHorFrameBorder(
+ OutputDevice& rDev, const Point& rLPos, const Point& rRPos,
+ const Style& rBorder, const BorderResult& rResult, const Color* pForceColor )
+{
+ DBG_ASSERT( rBorder.Prim(), "svx::frame::lclDrawHorFrameBorder - line not visible" );
+ DBG_ASSERT( rLPos.X() <= rRPos.X(), "svx::frame::lclDrawHorFrameBorder - wrong order of line ends" );
+ DBG_ASSERT( rLPos.Y() == rRPos.Y(), "svx::frame::lclDrawHorFrameBorder - line not horizontal" );
+ if( rLPos.X() <= rRPos.X() )
+ {
+ lclSetColorToOutDev( rDev, rBorder, pForceColor );
+ lclDrawHorLine( rDev, rLPos, rResult.maBeg.maPrim, rRPos, rResult.maEnd.maPrim,
+ lclGetBeg( rBorder ), lclGetPrimEnd( rBorder ), rBorder.Dashing() );
+ if( rBorder.Secn() )
+ lclDrawHorLine( rDev, rLPos, rResult.maBeg.maSecn, rRPos, rResult.maEnd.maSecn,
+ lclGetSecnBeg( rBorder ), lclGetEnd( rBorder ), rBorder.Dashing() );
+ rDev.Pop(); // colors
+ }
+}
+
+// ----------------------------------------------------------------------------
+// Drawing of vertical frame borders.
+
+/** Draws a vertical thin or thick line into the passed output device.
+
+ The Y coordinates of the edges of the line are adjusted according to the
+ passed LineEndResult structs. A one pixel wide line can be drawn dotted.
+ */
+void lclDrawVerLine(
+ OutputDevice& rDev,
+ const Point& rTPos, const LineEndResult& rTRes,
+ const Point& rBPos, const LineEndResult& rBRes,
+ long nLOffs, long nROffs, SvxBorderStyle nDashing )
+{
+ LinePoints aLPoints( rTPos + lclToMapUnit( nLOffs, rTRes.mnOffs1 ), rBPos + lclToMapUnit( nLOffs, rBRes.mnOffs1 ) );
+ LinePoints aRPoints( rTPos + lclToMapUnit( nROffs, rTRes.mnOffs2 ), rBPos + lclToMapUnit( nROffs, rBRes.mnOffs2 ) );
+
+ sal_uInt32 nWidth = lclToMapUnit( abs( nLOffs ) ) + lclToMapUnit( abs( nROffs ) );
+ if ( ( nLOffs >= 0 && nROffs >= 0 ) || ( nLOffs <= 0 && nROffs <= 0 ) )
+ nWidth = abs( lclToMapUnit( nLOffs ) - lclToMapUnit( nROffs ) ) + 1;
+ Point rTMid = ( aLPoints.maBeg + aRPoints.maBeg ) / 2;
+ Point rBMid = ( aLPoints.maEnd + aRPoints.maEnd ) / 2;
+
+ ::svtools::DrawLine( rDev, rTMid, rBMid, nWidth, nDashing );
+}
+
+/** Draws a vertical frame border into the passed output device.
+
+ @param rTPos
+ The top-left or top-right reference point of the diagonal frame border.
+ @param rBPos
+ The bottom-left or bottom-right reference point of the diagonal frame border.
+ @param rBorder
+ The frame style used to draw the border.
+ @param rResult
+ The Y coordinates of the edges of all lines of the frame border are
+ adjusted according to the offsets contained here.
+ */
+void lclDrawVerFrameBorder(
+ OutputDevice& rDev, const Point& rTPos, const Point& rBPos,
+ const Style& rBorder, const BorderResult& rResult, const Color* pForceColor )
+{
+ DBG_ASSERT( rBorder.Prim(), "svx::frame::lclDrawVerFrameBorder - line not visible" );
+ DBG_ASSERT( rTPos.Y() <= rBPos.Y(), "svx::frame::lclDrawVerFrameBorder - wrong order of line ends" );
+ DBG_ASSERT( rTPos.X() == rBPos.X(), "svx::frame::lclDrawVerFrameBorder - line not vertical" );
+ if( rTPos.Y() <= rBPos.Y() )
+ {
+ lclSetColorToOutDev( rDev, rBorder, pForceColor );
+ lclDrawVerLine( rDev, rTPos, rResult.maBeg.maPrim, rBPos, rResult.maEnd.maPrim,
+ lclGetBeg( rBorder ), lclGetPrimEnd( rBorder ), rBorder.Dashing() );
+ if( rBorder.Secn() )
+ lclDrawVerLine( rDev, rTPos, rResult.maBeg.maSecn, rBPos, rResult.maEnd.maSecn,
+ lclGetSecnBeg( rBorder ), lclGetEnd( rBorder ), rBorder.Dashing() );
+ rDev.Pop(); // colors
+ }
+}
+
+// ============================================================================
+// Drawing of diagonal frame borders, incudes clipping functions.
+
+/** Returns the drawing coordinates for a diagonal thin line.
+
+ This function can be used for top-left to bottom-right and for bottom-left
+ to top-right lines.
+
+ @param rRect
+ The reference rectangle of the diagonal frame border.
+ @param bTLBR
+ true = top-left to bottom-right; false = bottom-left to top-right.
+ @param nDiagOffs
+ Width offset (sub units) across the diagonal frame border.
+ @return
+ A struct containg start and end position of the diagonal line.
+ */
+LinePoints lclGetDiagLineEnds( const Rectangle& rRect, bool bTLBR, long nDiagOffs )
+{
+ LinePoints aPoints( rRect, bTLBR );
+ bool bVert = rRect.GetWidth() < rRect.GetHeight();
+ double fAngle = bVert ? GetVerDiagAngle( rRect ) : GetHorDiagAngle( rRect );
+ // vertical top-left to bottom-right borders are handled mirrored
+ if( bVert && bTLBR )
+ nDiagOffs = -nDiagOffs;
+ long nTOffs = bTLBR ? GetTLDiagOffset( 0, nDiagOffs, fAngle ) : GetTRDiagOffset( 0, nDiagOffs, fAngle );
+ long nBOffs = bTLBR ? GetBRDiagOffset( 0, nDiagOffs, fAngle ) : GetBLDiagOffset( 0, nDiagOffs, fAngle );
+ // vertical bottom-left to top-right borders are handled with exchanged end points
+ if( bVert && !bTLBR )
+ std::swap( nTOffs, nBOffs );
+ (bVert ? aPoints.maBeg.Y() : aPoints.maBeg.X()) += lclToMapUnit( nTOffs );
+ (bVert ? aPoints.maEnd.Y() : aPoints.maEnd.X()) += lclToMapUnit( nBOffs );
+ return aPoints;
+}
+
+// ----------------------------------------------------------------------------
+// Clipping functions for diagonal frame borders.
+
+/** Limits the clipping region to the inner area of a rectange.
+
+ Takes the values from the passed DiagLineResult struct into account. They
+ may specify to not clip one or more borders of a rectangle.
+
+ @param rDev
+ The output device with the clipping region to be modified. The old
+ clipping region is pushed onto the device's stack and can be restored
+ with a call to OutputDevice::Pop(). Please take care about the correct
+ calling order of Pop() if this function is used with other functions
+ pushing something onto the stack.
+ @param rRect
+ The reference rectangle of the diagonal frame borders.
+ @param rResult
+ The result struct containing modifies for each border of the reference
+ rectangle.
+ */
+void lclPushDiagClipRect( OutputDevice& rDev, const Rectangle& rRect, const DiagLineResult& rResult )
+{
+ // PixelToLogic() regards internal offset of the output device
+ Rectangle aClipRect( rRect );
+ aClipRect.Left() += lclToMapUnit( rResult.mnLClip );
+ aClipRect.Top() += lclToMapUnit( rResult.mnTClip );
+ aClipRect.Right() += lclToMapUnit( rResult.mnRClip );
+ aClipRect.Bottom() += lclToMapUnit( rResult.mnBClip );
+ // output device would adjust the rectangle -> invalidate it before
+ if( (aClipRect.GetWidth() < 1) ||(aClipRect.GetHeight() < 1) )
+ aClipRect.SetEmpty();
+
+ rDev.Push( PUSH_CLIPREGION );
+ rDev.IntersectClipRegion( aClipRect );
+}
+
+/** Excludes inner area of a crossing double frame border from clipping region.
+
+ This function is used to modify the clipping region so that it excludes the
+ inner free area of a double diagonal frame border. This makes it possible
+ to draw a diagonal frame border in one step without taking care of the
+ crossing double frame border.
+
+ @param rDev
+ The output device with the clipping region to be modified. The old
+ clipping region is pushed onto the device's stack and can be restored
+ with a call to OutputDevice::Pop(). Please take care about the correct
+ calling order of Pop() if this function is used with other functions
+ pushing something onto the stack.
+ @param rRect
+ The reference rectangle of the diagonal frame borders.
+ @param bTLBR
+ The orientation of the processed frame border (not the orientation of
+ the crossing frame border).
+ @param bCrossStyle
+ The style of the crossing frame border. Must be a double frame style.
+ */
+void lclPushCrossingClipRegion( OutputDevice& rDev, const Rectangle& rRect, bool bTLBR, const Style& rCrossStyle )
+{
+ DBG_ASSERT( rCrossStyle.Secn(), "lclGetCrossingClipRegion - use only for double styles" );
+ LinePoints aLPoints( lclGetDiagLineEnds( rRect, !bTLBR, lclGetPrimEnd( rCrossStyle ) ) );
+ LinePoints aRPoints( lclGetDiagLineEnds( rRect, !bTLBR, lclGetSecnBeg( rCrossStyle ) ) );
+
+ Region aClipReg;
+ if( bTLBR )
+ {
+ aClipReg = lclCreatePolygon(
+ aLPoints.maBeg, aLPoints.maEnd, rRect.BottomRight(), rRect.BottomLeft(), rRect.TopLeft() );
+ aClipReg.Union( lclCreatePolygon(
+ aRPoints.maBeg, aRPoints.maEnd, rRect.BottomRight(), rRect.TopRight(), rRect.TopLeft() ) );
+ }
+ else
+ {
+ aClipReg = lclCreatePolygon(
+ aLPoints.maBeg, aLPoints.maEnd, rRect.BottomLeft(), rRect.TopLeft(), rRect.TopRight() );
+ aClipReg.Union( lclCreatePolygon(
+ aRPoints.maBeg, aRPoints.maEnd, rRect.BottomLeft(), rRect.BottomRight(), rRect.TopRight() ) );
+ }
+
+ rDev.Push( PUSH_CLIPREGION );
+ rDev.IntersectClipRegion( aClipReg );
+}
+
+// ----------------------------------------------------------------------------
+// Drawing functions for diagonal frame borders.
+
+/** Draws a diagonal thin or thick line into the passed output device.
+
+ The clipping region of the output device is modified according to the
+ passed DiagLineResult struct. A one pixel wide line can be drawn dotted.
+ */
+void lclDrawDiagLine(
+ OutputDevice& rDev, const Rectangle& rRect, bool bTLBR,
+ const DiagLineResult& rResult, long nDiagOffs1, long nDiagOffs2, SvxBorderStyle nDashing )
+{
+ lclPushDiagClipRect( rDev, rRect, rResult );
+ LinePoints aLPoints( lclGetDiagLineEnds( rRect, bTLBR, nDiagOffs1 ) );
+ LinePoints aL2Points( lclGetDiagLineEnds( rRect, bTLBR, nDiagOffs2 ) );
+ Point aSMid( ( aLPoints.maBeg + aL2Points.maBeg ) / 2 );
+ Point aEMid( ( aLPoints.maEnd + aL2Points.maEnd ) / 2 );
+
+ sal_uInt32 nWidth = lclToMapUnit( abs( nDiagOffs1 ) ) + lclToMapUnit( abs( nDiagOffs2 ) );
+ if ( ( nDiagOffs1 <= 0 && nDiagOffs2 <= 0 ) || ( nDiagOffs1 >=0 && nDiagOffs2 >=0 ) )
+ nWidth = lclToMapUnit( abs( nDiagOffs1 - nDiagOffs2 ) );
+
+ svtools::DrawLine( rDev, aSMid, aEMid, nWidth, nDashing );
+ rDev.Pop(); // clipping region
+}
+
+/** Draws a diagonal frame border into the passed output device.
+
+ The lines of the frame border are drawn interrupted, if the style of the
+ crossing frame border is double.
+
+ @param rRect
+ The reference rectangle of the diagonal frame border.
+ @param bTLBR
+ The orientation of the diagonal frame border.
+ @param rBorder
+ The frame style used to draw the border.
+ @param rResult
+ Offsets (sub units) to modify the clipping region of the output device.
+ @param rCrossStyle
+ Style of the crossing diagonal frame border.
+ */
+void lclDrawDiagFrameBorder(
+ OutputDevice& rDev, const Rectangle& rRect, bool bTLBR,
+ const Style& rBorder, const DiagBorderResult& rResult, const Style& rCrossStyle,
+ const Color* pForceColor, bool bDiagDblClip )
+{
+ DBG_ASSERT( rBorder.Prim(), "svx::frame::lclDrawDiagFrameBorder - line not visible" );
+
+ bool bClip = bDiagDblClip && rCrossStyle.Secn();
+ if( bClip )
+ lclPushCrossingClipRegion( rDev, rRect, bTLBR, rCrossStyle );
+
+ lclSetColorToOutDev( rDev, rBorder, pForceColor );
+ lclDrawDiagLine( rDev, rRect, bTLBR, rResult.maPrim, lclGetBeg( rBorder ), lclGetPrimEnd( rBorder ), rBorder.Dashing() );
+ if( rBorder.Secn() )
+ lclDrawDiagLine( rDev, rRect, bTLBR, rResult.maSecn, lclGetSecnBeg( rBorder ), lclGetEnd( rBorder ), rBorder.Dashing() );
+ rDev.Pop(); // colors
+
+ if( bClip )
+ rDev.Pop(); // clipping region
+}
+
+/** Draws both diagonal frame borders into the passed output device.
+
+ The lines of each frame border is drawn interrupted, if the style of the
+ other crossing frame border is double.
+
+ @param rRect
+ The reference rectangle of the diagonal frame borders.
+ @param rTLBR
+ The frame style of the top-left to bottom-right frame border.
+ @param rBLTR
+ The frame style of the bottom-left to top-right frame border.
+ @param rResult
+ Offsets (sub units) to modify the clipping region of the output device.
+ */
+void lclDrawDiagFrameBorders(
+ OutputDevice& rDev, const Rectangle& rRect,
+ const Style& rTLBR, const Style& rBLTR, const DiagBordersResult& rResult,
+ const Color* pForceColor, bool bDiagDblClip )
+{
+ DBG_ASSERT( (rRect.GetWidth() > 1) && (rRect.GetHeight() > 1), "svx::frame::lclDrawDiagFrameBorders - rectangle too small" );
+ if( (rRect.GetWidth() > 1) && (rRect.GetHeight() > 1) )
+ {
+ bool bDrawTLBR = rTLBR.Prim() != 0;
+ bool bDrawBLTR = rBLTR.Prim() != 0;
+ bool bFirstDrawBLTR = rTLBR.Secn() != 0;
+
+ if( bDrawBLTR && bFirstDrawBLTR )
+ lclDrawDiagFrameBorder( rDev, rRect, false, rBLTR, rResult.maBLTR, rTLBR, pForceColor, bDiagDblClip );
+ if( bDrawTLBR )
+ lclDrawDiagFrameBorder( rDev, rRect, true, rTLBR, rResult.maTLBR, rBLTR, pForceColor, bDiagDblClip );
+ if( bDrawBLTR && !bFirstDrawBLTR )
+ lclDrawDiagFrameBorder( rDev, rRect, false, rBLTR, rResult.maBLTR, rTLBR, pForceColor, bDiagDblClip );
+ }
+}
+
+// ============================================================================
+
+} // namespace
+
+// ============================================================================
+// Classes
+// ============================================================================
+
+#define SCALEVALUE( value ) lclScaleValue( value, fScale, nMaxWidth )
+
+void Style::Clear()
+{
+ Set( Color(), 0, 0, 0 );
+}
+
+void Style::Set( sal_uInt16 nP, sal_uInt16 nD, sal_uInt16 nS )
+{
+ /* nP nD nS -> mnPrim mnDist mnSecn
+ --------------------------------------
+ any any 0 nP 0 0
+ 0 any >0 nS 0 0
+ >0 0 >0 nP 0 0
+ >0 >0 >0 nP nD nS
+ */
+ mnPrim = nP ? nP : nS;
+ mnDist = (nP && nS) ? nD : 0;
+ mnSecn = (nP && nD) ? nS : 0;
+}
+
+void Style::Set( const Color& rColor, sal_uInt16 nP, sal_uInt16 nD, sal_uInt16 nS )
+{
+ maColor = rColor;
+ Set( nP, nD, nS );
+}
+
+void Style::Set( const SvxBorderLine& rBorder, double fScale, sal_uInt16 nMaxWidth )
+{
+ maColor = rBorder.GetColor();
+
+ USHORT nPrim = rBorder.GetOutWidth();
+ USHORT nDist = rBorder.GetDistance();
+ USHORT nSecn = rBorder.GetInWidth();
+
+ if( !nSecn ) // no or single frame border
+ {
+ Set( SCALEVALUE( nPrim ), 0, 0 );
+ mnDashing = rBorder.GetStyle();
+ }
+ else
+ {
+ Set( SCALEVALUE( nPrim ), SCALEVALUE( nDist ), SCALEVALUE( nSecn ) );
+ mnDashing = SOLID;
+ // Enlarge the style if distance is too small due to rounding losses.
+ sal_uInt16 nPixWidth = SCALEVALUE( nPrim + nDist + nSecn );
+ if( nPixWidth > GetWidth() )
+ mnDist = nPixWidth - mnPrim - mnSecn;
+ // Shrink the style if it is too thick for the control.
+ while( GetWidth() > nMaxWidth )
+ {
+ // First decrease space between lines.
+ if( mnDist )
+ --mnDist;
+ // Still too thick? Decrease the line widths.
+ if( GetWidth() > nMaxWidth )
+ {
+ if( mnPrim && (mnPrim == mnSecn) )
+ {
+ // Both lines equal - decrease both to keep symmetry.
+ --mnPrim;
+ --mnSecn;
+ }
+ else
+ {
+ // Decrease each line for itself
+ if( mnPrim )
+ --mnPrim;
+ if( (GetWidth() > nMaxWidth) && mnSecn )
+ --mnSecn;
+ }
+ }
+ }
+ }
+}
+
+void Style::Set( const SvxBorderLine* pBorder, double fScale, sal_uInt16 nMaxWidth )
+{
+ if( pBorder )
+ Set( *pBorder, fScale, nMaxWidth );
+ else
+ {
+ Clear();
+ mnDashing = SOLID;
+ }
+}
+
+Style& Style::ScaleSelf( double fScale, sal_uInt16 nMaxWidth )
+{
+ Set( SCALEVALUE( mnPrim ), SCALEVALUE( mnDist ), SCALEVALUE( mnSecn ) );
+ return *this;
+}
+
+Style Style::Scale( double fScale, sal_uInt16 nMaxWidth ) const
+{
+ return Style( *this ).ScaleSelf( fScale, nMaxWidth );
+}
+
+Style& Style::MirrorSelf()
+{
+ if( mnSecn )
+ std::swap( mnPrim, mnSecn );
+ if( meRefMode != REFMODE_CENTERED )
+ meRefMode = (meRefMode == REFMODE_BEGIN) ? REFMODE_END : REFMODE_BEGIN;
+ return *this;
+}
+
+Style Style::Mirror() const
+{
+ return Style( *this ).MirrorSelf();
+}
+
+bool operator==( const Style& rL, const Style& rR )
+{
+ return (rL.Prim() == rR.Prim()) && (rL.Dist() == rR.Dist()) && (rL.Secn() == rR.Secn()) &&
+ (rL.GetColor() == rR.GetColor()) && (rL.GetRefMode() == rR.GetRefMode()) &&
+ (rL.Dashing() == rR.Dashing());
+}
+
+bool operator<( const Style& rL, const Style& rR )
+{
+ // different total widths -> rL<rR, if rL is thinner
+ sal_uInt16 nLW = rL.GetWidth();
+ sal_uInt16 nRW = rR.GetWidth();
+ if( nLW != nRW ) return nLW < nRW;
+
+ // one line double, the other single -> rL<rR, if rL is single
+ if( (rL.Secn() == 0) != (rR.Secn() == 0) ) return rL.Secn() == 0;
+
+ // both lines double with different distances -> rL<rR, if distance of rL greater
+ if( (rL.Secn() && rR.Secn()) && (rL.Dist() != rR.Dist()) ) return rL.Dist() > rR.Dist();
+
+ // both lines single and 1 unit thick, only one is dotted -> rL<rR, if rL is dotted
+ if( (nLW == 1) && (rL.Dashing() != rR.Dashing()) ) return rL.Dashing();
+
+ // seem to be equal
+ return false;
+}
+
+#undef SCALEVALUE
+
+// ============================================================================
+// Various helper functions
+// ============================================================================
+
+double GetHorDiagAngle( long nWidth, long nHeight )
+{
+ return atan2( static_cast< double >( Abs( nHeight ) ), static_cast< double >( Abs( nWidth ) ) );
+}
+
+// ============================================================================
+
+long GetTLDiagOffset( long nVerOffs, long nDiagOffs, double fAngle )
+{
+ return lclD2L( nVerOffs / tan( fAngle ) + nDiagOffs / sin( fAngle ) );
+}
+
+long GetBLDiagOffset( long nVerOffs, long nDiagOffs, double fAngle )
+{
+ return lclD2L( -nVerOffs / tan( fAngle ) + nDiagOffs / sin( fAngle ) );
+}
+
+long GetBRDiagOffset( long nVerOffs, long nDiagOffs, double fAngle )
+{
+ return -lclD2L( -nVerOffs / tan( fAngle ) - nDiagOffs / sin( fAngle ) );
+}
+
+long GetTRDiagOffset( long nVerOffs, long nDiagOffs, double fAngle )
+{
+ return -lclD2L( nVerOffs / tan( fAngle ) - nDiagOffs / sin( fAngle ) );
+}
+
+// ============================================================================
+
+bool CheckFrameBorderConnectable( const Style& rLBorder, const Style& rRBorder,
+ const Style& rTFromTL, const Style& rTFromT, const Style& rTFromTR,
+ const Style& rBFromBL, const Style& rBFromB, const Style& rBFromBR )
+{
+ return // returns 1 AND (2a OR 2b)
+ // 1) only, if both frame borders are equal
+ (rLBorder == rRBorder)
+ &&
+ (
+ (
+ // 2a) if the borders are not double, at least one of the vertical must not be double
+ !rLBorder.Secn() && (!rTFromT.Secn() || !rBFromB.Secn())
+ )
+ ||
+ (
+ // 2b) if the borders are double, all other borders must not be double
+ rLBorder.Secn() &&
+ !rTFromTL.Secn() && !rTFromT.Secn() && !rTFromTR.Secn() &&
+ !rBFromBL.Secn() && !rBFromB.Secn() && !rBFromBR.Secn()
+ )
+ );
+}
+
+// ============================================================================
+// Drawing functions
+// ============================================================================
+
+void DrawHorFrameBorder( OutputDevice& rDev,
+ const Point& rLPos, const Point& rRPos, const Style& rBorder,
+ const DiagStyle& rLFromTR, const Style& rLFromT, const Style& rLFromL, const Style& rLFromB, const DiagStyle& rLFromBR,
+ const DiagStyle& rRFromTL, const Style& rRFromT, const Style& rRFromR, const Style& rRFromB, const DiagStyle& rRFromBL,
+ const Color* pForceColor )
+{
+ if( rBorder.Prim() )
+ {
+ BorderResult aResult;
+ lclLinkHorFrameBorder( aResult, rBorder,
+ rLFromTR, rLFromT, rLFromL, rLFromB, rLFromBR,
+ rRFromTL, rRFromT, rRFromR, rRFromB, rRFromBL );
+ lclDrawHorFrameBorder( rDev, rLPos, rRPos, rBorder, aResult, pForceColor );
+ }
+}
+
+void DrawHorFrameBorder( OutputDevice& rDev,
+ const Point& rLPos, const Point& rRPos, const Style& rBorder,
+ const Style& rLFromT, const Style& rLFromL, const Style& rLFromB,
+ const Style& rRFromT, const Style& rRFromR, const Style& rRFromB,
+ const Color* pForceColor )
+{
+ /* Recycle complex version of the DrawHorFrameBorder() function with empty diagonals. */
+ const DiagStyle aNoStyle;
+ DrawHorFrameBorder(
+ rDev, rLPos, rRPos, rBorder,
+ aNoStyle, rLFromT, rLFromL, rLFromB, aNoStyle,
+ aNoStyle, rRFromT, rRFromR, rRFromB, aNoStyle,
+ pForceColor );
+}
+
+void DrawHorFrameBorder( OutputDevice& rDev,
+ const Point& rLPos, const Point& rRPos, const Style& rBorder, const Color* pForceColor )
+{
+ if( rBorder.Prim() )
+ lclDrawHorFrameBorder( rDev, rLPos, rRPos, rBorder, BorderResult(), pForceColor );
+}
+
+// ----------------------------------------------------------------------------
+
+void DrawVerFrameBorder( OutputDevice& rDev,
+ const Point& rTPos, const Point& rBPos, const Style& rBorder,
+ const DiagStyle& rTFromBL, const Style& rTFromL, const Style& rTFromT, const Style& rTFromR, const DiagStyle& rTFromBR,
+ const DiagStyle& rBFromTL, const Style& rBFromL, const Style& rBFromB, const Style& rBFromR, const DiagStyle& rBFromTR,
+ const Color* pForceColor )
+{
+ if( rBorder.Prim() )
+ {
+ BorderResult aResult;
+ lclLinkVerFrameBorder( aResult, rBorder,
+ rTFromBL, rTFromL, rTFromT, rTFromR, rTFromBR,
+ rBFromTL, rBFromL, rBFromB, rBFromR, rBFromTR );
+ lclDrawVerFrameBorder( rDev, rTPos, rBPos, rBorder, aResult, pForceColor );
+ }
+}
+
+void DrawVerFrameBorder( OutputDevice& rDev,
+ const Point& rTPos, const Point& rBPos, const Style& rBorder,
+ const Style& rTFromL, const Style& rTFromT, const Style& rTFromR,
+ const Style& rBFromL, const Style& rBFromB, const Style& rBFromR,
+ const Color* pForceColor )
+{
+ /* Recycle complex version of the DrawVerFrameBorder() function with empty diagonals. */
+ const DiagStyle aNoStyle;
+ DrawVerFrameBorder(
+ rDev, rTPos, rBPos, rBorder,
+ aNoStyle, rTFromL, rTFromT, rTFromR, aNoStyle,
+ aNoStyle, rBFromL, rBFromB, rBFromR, aNoStyle,
+ pForceColor );
+}
+
+void DrawVerFrameBorder( OutputDevice& rDev,
+ const Point& rTPos, const Point& rBPos, const Style& rBorder, const Color* pForceColor )
+{
+ if( rBorder.Prim() )
+ lclDrawVerFrameBorder( rDev, rTPos, rBPos, rBorder, BorderResult(), pForceColor );
+}
+
+// ----------------------------------------------------------------------------
+
+void DrawVerFrameBorderSlanted( OutputDevice& rDev,
+ const Point& rTPos, const Point& rBPos, const Style& rBorder, const Color* pForceColor )
+{
+ DBG_ASSERT( rTPos.Y() < rBPos.Y(), "svx::frame::DrawVerFrameBorderSlanted - wrong order of line ends" );
+ if( rBorder.Prim() && (rTPos.Y() < rBPos.Y()) )
+ {
+ if( rTPos.X() == rBPos.X() )
+ {
+ DrawVerFrameBorder( rDev, rTPos, rBPos, rBorder, pForceColor );
+ }
+ else
+ {
+ const LineEndResult aRes;
+
+ Style aScaled( rBorder );
+ aScaled.ScaleSelf( 1.0 / cos( GetVerDiagAngle( rTPos, rBPos ) ) );
+
+ lclSetColorToOutDev( rDev, aScaled, pForceColor );
+ lclDrawVerLine( rDev, rTPos, aRes, rBPos, aRes,
+ lclGetBeg( aScaled ), lclGetPrimEnd( aScaled ), aScaled.Dashing() );
+ if( aScaled.Secn() )
+ lclDrawVerLine( rDev, rTPos, aRes, rBPos, aRes,
+ lclGetSecnBeg( aScaled ), lclGetEnd( aScaled ), aScaled.Dashing() );
+ rDev.Pop(); // colors
+ }
+ }
+}
+
+// ============================================================================
+
+void DrawDiagFrameBorders(
+ OutputDevice& rDev, const Rectangle& rRect, const Style& rTLBR, const Style& rBLTR,
+ const Style& rTLFromB, const Style& rTLFromR, const Style& rBRFromT, const Style& rBRFromL,
+ const Style& rBLFromT, const Style& rBLFromR, const Style& rTRFromB, const Style& rTRFromL,
+ const Color* pForceColor, bool bDiagDblClip )
+{
+ if( rTLBR.Prim() || rBLTR.Prim() )
+ {
+ DiagBordersResult aResult;
+ lclLinkDiagFrameBorders( aResult, rTLBR, rBLTR,
+ rTLFromB, rTLFromR, rBRFromT, rBRFromL, rBLFromT, rBLFromR, rTRFromB, rTRFromL );
+ lclDrawDiagFrameBorders( rDev, rRect, rTLBR, rBLTR, aResult, pForceColor, bDiagDblClip );
+ }
+}
+
+// ============================================================================
+
+} // namespace frame
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/framelinkarray.cxx b/svx/source/dialog/framelinkarray.cxx
new file mode 100644
index 000000000000..e778abca89b4
--- /dev/null
+++ b/svx/source/dialog/framelinkarray.cxx
@@ -0,0 +1,1249 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/framelinkarray.hxx>
+
+#include <math.h>
+#include <vector>
+#include <algorithm>
+#include <vcl/outdev.hxx>
+
+namespace svx {
+namespace frame {
+
+// ============================================================================
+
+
+Cell::Cell() :
+ mnAddLeft( 0 ),
+ mnAddRight( 0 ),
+ mnAddTop( 0 ),
+ mnAddBottom( 0 ),
+ mbMergeOrig( false ),
+ mbOverlapX( false ),
+ mbOverlapY( false )
+{
+}
+
+void Cell::MirrorSelfX( bool bMirrorStyles, bool bSwapDiag )
+{
+ std::swap( maLeft, maRight );
+ std::swap( mnAddLeft, mnAddRight );
+ if( bMirrorStyles )
+ {
+ maLeft.MirrorSelf();
+ maRight.MirrorSelf();
+ }
+ if( bSwapDiag )
+ {
+ std::swap( maTLBR, maBLTR );
+ if( bMirrorStyles )
+ {
+ maTLBR.MirrorSelf();
+ maBLTR.MirrorSelf();
+ }
+ }
+}
+
+void Cell::MirrorSelfY( bool bMirrorStyles, bool bSwapDiag )
+{
+ std::swap( maTop, maBottom );
+ std::swap( mnAddTop, mnAddBottom );
+ if( bMirrorStyles )
+ {
+ maTop.MirrorSelf();
+ maBottom.MirrorSelf();
+ }
+ if( bSwapDiag )
+ std::swap( maTLBR, maBLTR );
+ /* Do not mirror diagonal styles, because they are oriented vertical.
+ Therefore swapping the styles is sufficient for correct behaviour. */
+}
+
+// ----------------------------------------------------------------------------
+
+
+void lclRecalcCoordVec( LongVec& rCoords, const LongVec& rSizes )
+{
+ DBG_ASSERT( rCoords.size() == rSizes.size() + 1, "lclRecalcCoordVec - inconsistent vectors" );
+ LongVec::iterator aCIt = rCoords.begin();
+ LongVec::const_iterator aSIt = rSizes.begin(), aSEnd = rSizes.end();
+ for( ; aSIt != aSEnd; ++aCIt, ++aSIt )
+ *(aCIt + 1) = *aCIt + *aSIt;
+}
+
+void lclSetMergedRange( CellVec& rCells, size_t nWidth, size_t nFirstCol, size_t nFirstRow, size_t nLastCol, size_t nLastRow )
+{
+ for( size_t nCol = nFirstCol; nCol <= nLastCol; ++nCol )
+ {
+ for( size_t nRow = nFirstRow; nRow <= nLastRow; ++nRow )
+ {
+ Cell& rCell = rCells[ nRow * nWidth + nCol ];
+ rCell.mbMergeOrig = false;
+ rCell.mbOverlapX = nCol > nFirstCol;
+ rCell.mbOverlapY = nRow > nFirstRow;
+ }
+ }
+ rCells[ nFirstRow * nWidth + nFirstCol ].mbMergeOrig = true;
+}
+
+// ----------------------------------------------------------------------------
+
+static const Style OBJ_STYLE_NONE;
+static const Cell OBJ_CELL_NONE;
+
+const bool DIAG_DBL_CLIP_DEFAULT = false;
+
+// ============================================================================
+
+ArrayImpl::ArrayImpl( size_t nWidth, size_t nHeight, bool bDiagDblClip ) :
+ mnWidth( nWidth ),
+ mnHeight( nHeight ),
+ mnFirstClipCol( 0 ),
+ mnFirstClipRow( 0 ),
+ mnLastClipCol( nWidth - 1 ),
+ mnLastClipRow( nHeight - 1 ),
+ mbXCoordsDirty( false ),
+ mbYCoordsDirty( false ),
+ mbDiagDblClip( bDiagDblClip )
+{
+ // default-construct all vectors
+ maCells.resize( mnWidth * mnHeight );
+ maWidths.resize( mnWidth, 0L );
+ maHeights.resize( mnHeight, 0L );
+ maXCoords.resize( mnWidth + 1, 0L );
+ maYCoords.resize( mnHeight + 1, 0L );
+}
+
+const Cell& ArrayImpl::GetCell( size_t nCol, size_t nRow ) const
+{
+ return IsValidPos( nCol, nRow ) ? maCells[ GetIndex( nCol, nRow ) ] : OBJ_CELL_NONE;
+}
+
+Cell& ArrayImpl::GetCellAcc( size_t nCol, size_t nRow )
+{
+ static Cell aDummy;
+ return IsValidPos( nCol, nRow ) ? maCells[ GetIndex( nCol, nRow ) ] : aDummy;
+}
+
+size_t ArrayImpl::GetMergedFirstCol( size_t nCol, size_t nRow ) const
+{
+ size_t nFirstCol = nCol;
+ while( (nFirstCol > 0) && GetCell( nFirstCol, nRow ).mbOverlapX ) --nFirstCol;
+ return nFirstCol;
+}
+
+size_t ArrayImpl::GetMergedFirstRow( size_t nCol, size_t nRow ) const
+{
+ size_t nFirstRow = nRow;
+ while( (nFirstRow > 0) && GetCell( nCol, nFirstRow ).mbOverlapY ) --nFirstRow;
+ return nFirstRow;
+}
+
+size_t ArrayImpl::GetMergedLastCol( size_t nCol, size_t nRow ) const
+{
+ size_t nLastCol = nCol + 1;
+ while( (nLastCol < mnWidth) && GetCell( nLastCol, nRow ).mbOverlapX ) ++nLastCol;
+ return nLastCol - 1;
+}
+
+size_t ArrayImpl::GetMergedLastRow( size_t nCol, size_t nRow ) const
+{
+ size_t nLastRow = nRow + 1;
+ while( (nLastRow < mnHeight) && GetCell( nCol, nLastRow ).mbOverlapY ) ++nLastRow;
+ return nLastRow - 1;
+}
+
+const Cell& ArrayImpl::GetMergedOriginCell( size_t nCol, size_t nRow ) const
+{
+ return GetCell( GetMergedFirstCol( nCol, nRow ), GetMergedFirstRow( nCol, nRow ) );
+}
+
+Cell& ArrayImpl::GetMergedOriginCellAcc( size_t nCol, size_t nRow )
+{
+ return GetCellAcc( GetMergedFirstCol( nCol, nRow ), GetMergedFirstRow( nCol, nRow ) );
+}
+
+bool ArrayImpl::IsMergedOverlappedLeft( size_t nCol, size_t nRow ) const
+{
+ const Cell& rCell = GetCell( nCol, nRow );
+ return rCell.mbOverlapX || (rCell.mnAddLeft > 0);
+}
+
+bool ArrayImpl::IsMergedOverlappedRight( size_t nCol, size_t nRow ) const
+{
+ return GetCell( nCol + 1, nRow ).mbOverlapX || (GetCell( nCol, nRow ).mnAddRight > 0);
+}
+
+bool ArrayImpl::IsMergedOverlappedTop( size_t nCol, size_t nRow ) const
+{
+ const Cell& rCell = GetCell( nCol, nRow );
+ return rCell.mbOverlapY || (rCell.mnAddTop > 0);
+}
+
+bool ArrayImpl::IsMergedOverlappedBottom( size_t nCol, size_t nRow ) const
+{
+ return GetCell( nCol, nRow + 1 ).mbOverlapY || (GetCell( nCol, nRow ).mnAddBottom > 0);
+}
+
+bool ArrayImpl::IsColInClipRange( size_t nCol ) const
+{
+ return (mnFirstClipCol <= nCol) && (nCol <= mnLastClipCol);
+}
+
+bool ArrayImpl::IsRowInClipRange( size_t nRow ) const
+{
+ return (mnFirstClipRow <= nRow) && (nRow <= mnLastClipRow);
+}
+
+bool ArrayImpl::IsInClipRange( size_t nCol, size_t nRow ) const
+{
+ return IsColInClipRange( nCol ) && IsRowInClipRange( nRow );
+}
+
+long ArrayImpl::GetColPosition( size_t nCol ) const
+{
+ if( mbXCoordsDirty )
+ {
+ lclRecalcCoordVec( maXCoords, maWidths );
+ mbXCoordsDirty = false;
+ }
+ return maXCoords[ nCol ];
+}
+
+long ArrayImpl::GetRowPosition( size_t nRow ) const
+{
+ if( mbYCoordsDirty )
+ {
+ lclRecalcCoordVec( maYCoords, maHeights );
+ mbYCoordsDirty = false;
+ }
+ return maYCoords[ nRow ];
+}
+
+long ArrayImpl::GetColWidth( size_t nFirstCol, size_t nLastCol ) const
+{
+ return GetColPosition( nLastCol + 1 ) - GetColPosition( nFirstCol );
+}
+
+long ArrayImpl::GetRowHeight( size_t nFirstRow, size_t nLastRow ) const
+{
+ return GetRowPosition( nLastRow + 1 ) - GetRowPosition( nFirstRow );
+}
+
+double ArrayImpl::GetHorDiagAngle( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ double fAngle = 0.0;
+ if( IsValidPos( nCol, nRow ) )
+ {
+ if( bSimple || !GetCell( nCol, nRow ).IsMerged() )
+ {
+ fAngle = frame::GetHorDiagAngle( maWidths[ nCol ] + 1, maHeights[ nRow ] + 1 );
+ }
+ else
+ {
+ // return correct angle for each cell in the merged range
+ size_t nFirstCol = GetMergedFirstCol( nCol, nRow );
+ size_t nFirstRow = GetMergedFirstRow( nCol, nRow );
+ const Cell& rCell = GetCell( nFirstCol, nFirstRow );
+ long nWidth = GetColWidth( nFirstCol, GetMergedLastCol( nCol, nRow ) ) + rCell.mnAddLeft + rCell.mnAddRight;
+ long nHeight = GetRowHeight( nFirstRow, GetMergedLastRow( nCol, nRow ) ) + rCell.mnAddTop + rCell.mnAddBottom;
+ fAngle = frame::GetHorDiagAngle( nWidth + 1, nHeight + 1 );
+ }
+ }
+ return fAngle;
+}
+
+double ArrayImpl::GetVerDiagAngle( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ double fAngle = GetHorDiagAngle( nCol, nRow, bSimple );
+ return (fAngle > 0.0) ? (F_PI2 - fAngle) : 0.0;
+}
+
+// ============================================================================
+
+class MergedCellIterator
+{
+public:
+ explicit MergedCellIterator( const Array& rArray, size_t nCol, size_t nRow );
+
+ inline bool Is() const { return (mnCol <= mnLastCol) && (mnRow <= mnLastRow); }
+ inline size_t Col() const { return mnCol; }
+ inline size_t Row() const { return mnRow; }
+
+ MergedCellIterator& operator++();
+
+private:
+ size_t mnFirstCol;
+ size_t mnFirstRow;
+ size_t mnLastCol;
+ size_t mnLastRow;
+ size_t mnCol;
+ size_t mnRow;
+};
+
+// ----------------------------------------------------------------------------
+
+MergedCellIterator::MergedCellIterator( const Array& rArray, size_t nCol, size_t nRow )
+{
+ DBG_ASSERT( rArray.IsMerged( nCol, nRow ), "svx::frame::MergedCellIterator::MergedCellIterator - not in merged range" );
+ rArray.GetMergedRange( mnFirstCol, mnFirstRow, mnLastCol, mnLastRow, nCol, nRow );
+ mnCol = mnFirstCol;
+ mnRow = mnFirstRow;
+}
+
+MergedCellIterator& MergedCellIterator::operator++()
+{
+ DBG_ASSERT( Is(), "svx::frame::MergedCellIterator::operator++() - already invalid" );
+ if( ++mnCol > mnLastCol )
+ {
+ mnCol = mnFirstCol;
+ ++mnRow;
+ }
+ return *this;
+}
+
+// ============================================================================
+
+#define DBG_FRAME_ERROR( funcname, error ) DBG_ERRORFILE( "svx::frame::Array::" funcname " - " error )
+#define DBG_FRAME_CHECK( cond, funcname, error ) DBG_ASSERT( cond, "svx::frame::Array::" funcname " - " error )
+#define DBG_FRAME_CHECK_COL( col, funcname ) DBG_FRAME_CHECK( (col) < GetColCount(), funcname, "invalid column index" )
+#define DBG_FRAME_CHECK_ROW( row, funcname ) DBG_FRAME_CHECK( (row) < GetRowCount(), funcname, "invalid row index" )
+#define DBG_FRAME_CHECK_COLROW( col, row, funcname ) DBG_FRAME_CHECK( ((col) < GetColCount()) && ((row) < GetRowCount()), funcname, "invalid cell index" )
+#define DBG_FRAME_CHECK_INDEX( index, funcname ) DBG_FRAME_CHECK( (index) < GetCellCount(), funcname, "invalid cell index" )
+#define DBG_FRAME_CHECK_COL_1( col, funcname ) DBG_FRAME_CHECK( (col) <= GetColCount(), funcname, "invalid column index" )
+#define DBG_FRAME_CHECK_ROW_1( row, funcname ) DBG_FRAME_CHECK( (row) <= GetRowCount(), funcname, "invalid row index" )
+
+// ----------------------------------------------------------------------------
+
+#define CELL( col, row ) mxImpl->GetCell( col, row )
+#define CELLACC( col, row ) mxImpl->GetCellAcc( col, row )
+#define ORIGCELL( col, row ) mxImpl->GetMergedOriginCell( col, row )
+#define ORIGCELLACC( col, row ) mxImpl->GetMergedOriginCellAcc( col, row )
+
+// ----------------------------------------------------------------------------
+
+Array::Array()
+{
+ Initialize( 0, 0 );
+}
+
+Array::Array( size_t nWidth, size_t nHeight )
+{
+ Initialize( nWidth, nHeight );
+}
+
+Array::~Array()
+{
+}
+
+// array size and column/row indexes ------------------------------------------
+
+void Array::Initialize( size_t nWidth, size_t nHeight )
+{
+ bool bDiagDblClip = mxImpl.get() ? mxImpl->mbDiagDblClip : DIAG_DBL_CLIP_DEFAULT;
+ mxImpl.reset( new ArrayImpl( nWidth, nHeight, bDiagDblClip ) );
+}
+
+void Array::Clear()
+{
+ Initialize( mxImpl->mnWidth, mxImpl->mnHeight );
+}
+
+size_t Array::GetColCount() const
+{
+ return mxImpl->mnWidth;
+}
+
+size_t Array::GetRowCount() const
+{
+ return mxImpl->mnHeight;
+}
+
+size_t Array::GetCellCount() const
+{
+ return mxImpl->maCells.size();
+}
+
+size_t Array::GetColFromIndex( size_t nCellIndex ) const
+{
+ DBG_FRAME_CHECK_INDEX( nCellIndex, "GetColFromIndex" );
+ return mxImpl->mnWidth ? (nCellIndex % mxImpl->mnWidth) : 0;
+}
+
+size_t Array::GetRowFromIndex( size_t nCellIndex ) const
+{
+ DBG_FRAME_CHECK_INDEX( nCellIndex, "GetRowFromIndex" );
+ return mxImpl->mnWidth ? (nCellIndex / mxImpl->mnWidth) : 0;
+}
+
+size_t Array::GetCellIndex( size_t nCol, size_t nRow, bool bRTL ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "GetCellIndex" );
+ if (bRTL)
+ nCol = mxImpl->GetMirrorCol(nCol);
+ return mxImpl->GetIndex( nCol, nRow );
+}
+
+// cell border styles ---------------------------------------------------------
+
+void Array::SetCellStyleLeft( size_t nCol, size_t nRow, const Style& rStyle )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetCellStyleLeft" );
+ CELLACC( nCol, nRow ).maLeft = rStyle;
+}
+
+void Array::SetCellStyleRight( size_t nCol, size_t nRow, const Style& rStyle )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetCellStyleRight" );
+ CELLACC( nCol, nRow ).maRight = rStyle;
+}
+
+void Array::SetCellStyleTop( size_t nCol, size_t nRow, const Style& rStyle )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetCellStyleTop" );
+ CELLACC( nCol, nRow ).maTop = rStyle;
+}
+
+void Array::SetCellStyleBottom( size_t nCol, size_t nRow, const Style& rStyle )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetCellStyleBottom" );
+ CELLACC( nCol, nRow ).maBottom = rStyle;
+}
+
+void Array::SetCellStyleTLBR( size_t nCol, size_t nRow, const Style& rStyle )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetCellStyleTLBR" );
+ CELLACC( nCol, nRow ).maTLBR = rStyle;
+}
+
+void Array::SetCellStyleBLTR( size_t nCol, size_t nRow, const Style& rStyle )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetCellStyleBLTR" );
+ CELLACC( nCol, nRow ).maBLTR = rStyle;
+}
+
+void Array::SetCellStyleDiag( size_t nCol, size_t nRow, const Style& rTLBR, const Style& rBLTR )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetCellStyleDiag" );
+ Cell& rCell = CELLACC( nCol, nRow );
+ rCell.maTLBR = rTLBR;
+ rCell.maBLTR = rBLTR;
+}
+
+void Array::SetColumnStyleLeft( size_t nCol, const Style& rStyle )
+{
+ DBG_FRAME_CHECK_COL( nCol, "SetColumnStyleLeft" );
+ for( size_t nRow = 0; nRow < mxImpl->mnHeight; ++nRow )
+ SetCellStyleLeft( nCol, nRow, rStyle );
+}
+
+void Array::SetColumnStyleRight( size_t nCol, const Style& rStyle )
+{
+ DBG_FRAME_CHECK_COL( nCol, "SetColumnStyleRight" );
+ for( size_t nRow = 0; nRow < mxImpl->mnHeight; ++nRow )
+ SetCellStyleRight( nCol, nRow, rStyle );
+}
+
+void Array::SetRowStyleTop( size_t nRow, const Style& rStyle )
+{
+ DBG_FRAME_CHECK_ROW( nRow, "SetRowStyleTop" );
+ for( size_t nCol = 0; nCol < mxImpl->mnWidth; ++nCol )
+ SetCellStyleTop( nCol, nRow, rStyle );
+}
+
+void Array::SetRowStyleBottom( size_t nRow, const Style& rStyle )
+{
+ DBG_FRAME_CHECK_ROW( nRow, "SetRowStyleBottom" );
+ for( size_t nCol = 0; nCol < mxImpl->mnWidth; ++nCol )
+ SetCellStyleBottom( nCol, nRow, rStyle );
+}
+
+const Style& Array::GetCellStyleLeft( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ // simple: always return own left style
+ if( bSimple )
+ return CELL( nCol, nRow ).maLeft;
+ // outside clipping rows or overlapped in merged cells: invisible
+ if( !mxImpl->IsRowInClipRange( nRow ) || mxImpl->IsMergedOverlappedLeft( nCol, nRow ) )
+ return OBJ_STYLE_NONE;
+ // left clipping border: always own left style
+ if( nCol == mxImpl->mnFirstClipCol )
+ return ORIGCELL( nCol, nRow ).maLeft;
+ // right clipping border: always right style of left neighbor cell
+ if( nCol == mxImpl->mnLastClipCol + 1 )
+ return ORIGCELL( nCol - 1, nRow ).maRight;
+ // outside clipping columns: invisible
+ if( !mxImpl->IsColInClipRange( nCol ) )
+ return OBJ_STYLE_NONE;
+ // inside clipping range: maximum of own left style and right style of left neighbor cell
+ return std::max( ORIGCELL( nCol, nRow ).maLeft, ORIGCELL( nCol - 1, nRow ).maRight );
+}
+
+const Style& Array::GetCellStyleRight( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ // simple: always return own right style
+ if( bSimple )
+ return CELL( nCol, nRow ).maRight;
+ // outside clipping rows or overlapped in merged cells: invisible
+ if( !mxImpl->IsRowInClipRange( nRow ) || mxImpl->IsMergedOverlappedRight( nCol, nRow ) )
+ return OBJ_STYLE_NONE;
+ // left clipping border: always left style of right neighbor cell
+ if( nCol + 1 == mxImpl->mnFirstClipCol )
+ return ORIGCELL( nCol + 1, nRow ).maLeft;
+ // right clipping border: always own right style
+ if( nCol == mxImpl->mnLastClipCol )
+ return ORIGCELL( nCol, nRow ).maRight;
+ // outside clipping columns: invisible
+ if( !mxImpl->IsColInClipRange( nCol ) )
+ return OBJ_STYLE_NONE;
+ // inside clipping range: maximum of own right style and left style of right neighbor cell
+ return std::max( ORIGCELL( nCol, nRow ).maRight, ORIGCELL( nCol + 1, nRow ).maLeft );
+}
+
+const Style& Array::GetCellStyleTop( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ // simple: always return own top style
+ if( bSimple )
+ return CELL( nCol, nRow ).maTop;
+ // outside clipping columns or overlapped in merged cells: invisible
+ if( !mxImpl->IsColInClipRange( nCol ) || mxImpl->IsMergedOverlappedTop( nCol, nRow ) )
+ return OBJ_STYLE_NONE;
+ // top clipping border: always own top style
+ if( nRow == mxImpl->mnFirstClipRow )
+ return ORIGCELL( nCol, nRow ).maTop;
+ // bottom clipping border: always bottom style of top neighbor cell
+ if( nRow == mxImpl->mnLastClipRow + 1 )
+ return ORIGCELL( nCol, nRow - 1 ).maBottom;
+ // outside clipping rows: invisible
+ if( !mxImpl->IsRowInClipRange( nRow ) )
+ return OBJ_STYLE_NONE;
+ // inside clipping range: maximum of own top style and bottom style of top neighbor cell
+ return std::max( ORIGCELL( nCol, nRow ).maTop, ORIGCELL( nCol, nRow - 1 ).maBottom );
+}
+
+const Style& Array::GetCellStyleBottom( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ // simple: always return own bottom style
+ if( bSimple )
+ return CELL( nCol, nRow ).maBottom;
+ // outside clipping columns or overlapped in merged cells: invisible
+ if( !mxImpl->IsColInClipRange( nCol ) || mxImpl->IsMergedOverlappedBottom( nCol, nRow ) )
+ return OBJ_STYLE_NONE;
+ // top clipping border: always top style of bottom neighbor cell
+ if( nRow + 1 == mxImpl->mnFirstClipRow )
+ return ORIGCELL( nCol, nRow + 1 ).maTop;
+ // bottom clipping border: always own bottom style
+ if( nRow == mxImpl->mnLastClipRow )
+ return ORIGCELL( nCol, nRow ).maBottom;
+ // outside clipping rows: invisible
+ if( !mxImpl->IsRowInClipRange( nRow ) )
+ return OBJ_STYLE_NONE;
+ // inside clipping range: maximum of own bottom style and top style of bottom neighbor cell
+ return std::max( ORIGCELL( nCol, nRow ).maBottom, ORIGCELL( nCol, nRow + 1 ).maTop );
+}
+
+const Style& Array::GetCellStyleTLBR( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ return bSimple ? CELL( nCol, nRow ).maTLBR :
+ (mxImpl->IsInClipRange( nCol, nRow ) ? ORIGCELL( nCol, nRow ).maTLBR : OBJ_STYLE_NONE);
+}
+
+const Style& Array::GetCellStyleBLTR( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ return bSimple ? CELL( nCol, nRow ).maBLTR :
+ (mxImpl->IsInClipRange( nCol, nRow ) ? ORIGCELL( nCol, nRow ).maBLTR : OBJ_STYLE_NONE);
+}
+
+const Style& Array::GetCellStyleTL( size_t nCol, size_t nRow ) const
+{
+ // not in clipping range: always invisible
+ if( !mxImpl->IsInClipRange( nCol, nRow ) )
+ return OBJ_STYLE_NONE;
+ // return style only for top-left cell
+ size_t nFirstCol = mxImpl->GetMergedFirstCol( nCol, nRow );
+ size_t nFirstRow = mxImpl->GetMergedFirstRow( nCol, nRow );
+ return ((nCol == nFirstCol) && (nRow == nFirstRow)) ?
+ CELL( nFirstCol, nFirstRow ).maTLBR : OBJ_STYLE_NONE;
+}
+
+const Style& Array::GetCellStyleBR( size_t nCol, size_t nRow ) const
+{
+ // not in clipping range: always invisible
+ if( !mxImpl->IsInClipRange( nCol, nRow ) )
+ return OBJ_STYLE_NONE;
+ // return style only for bottom-right cell
+ size_t nLastCol = mxImpl->GetMergedLastCol( nCol, nRow );
+ size_t nLastRow = mxImpl->GetMergedLastRow( nCol, nRow );
+ return ((nCol == nLastCol) && (nRow == nLastRow)) ?
+ CELL( mxImpl->GetMergedFirstCol( nCol, nRow ), mxImpl->GetMergedFirstRow( nCol, nRow ) ).maTLBR : OBJ_STYLE_NONE;
+}
+
+const Style& Array::GetCellStyleBL( size_t nCol, size_t nRow ) const
+{
+ // not in clipping range: always invisible
+ if( !mxImpl->IsInClipRange( nCol, nRow ) )
+ return OBJ_STYLE_NONE;
+ // return style only for bottom-left cell
+ size_t nFirstCol = mxImpl->GetMergedFirstCol( nCol, nRow );
+ size_t nLastRow = mxImpl->GetMergedLastRow( nCol, nRow );
+ return ((nCol == nFirstCol) && (nRow == nLastRow)) ?
+ CELL( nFirstCol, mxImpl->GetMergedFirstRow( nCol, nRow ) ).maBLTR : OBJ_STYLE_NONE;
+}
+
+const Style& Array::GetCellStyleTR( size_t nCol, size_t nRow ) const
+{
+ // not in clipping range: always invisible
+ if( !mxImpl->IsInClipRange( nCol, nRow ) )
+ return OBJ_STYLE_NONE;
+ // return style only for top-right cell
+ size_t nFirstRow = mxImpl->GetMergedFirstRow( nCol, nRow );
+ size_t nLastCol = mxImpl->GetMergedLastCol( nCol, nRow );
+ return ((nCol == nLastCol) && (nRow == nFirstRow)) ?
+ CELL( mxImpl->GetMergedFirstCol( nCol, nRow ), nFirstRow ).maBLTR : OBJ_STYLE_NONE;
+}
+
+// cell merging ---------------------------------------------------------------
+
+void Array::SetMergedRange( size_t nFirstCol, size_t nFirstRow, size_t nLastCol, size_t nLastRow )
+{
+ DBG_FRAME_CHECK_COLROW( nFirstCol, nFirstRow, "SetMergedRange" );
+ DBG_FRAME_CHECK_COLROW( nLastCol, nLastRow, "SetMergedRange" );
+#if OSL_DEBUG_LEVEL >= 2
+ {
+ bool bFound = false;
+ for( size_t nCurrCol = nFirstCol; !bFound && (nCurrCol <= nLastCol); ++nCurrCol )
+ for( size_t nCurrRow = nFirstRow; !bFound && (nCurrRow <= nLastRow); ++nCurrRow )
+ bFound = CELL( nCurrCol, nCurrRow ).IsMerged();
+ DBG_FRAME_CHECK( !bFound, "SetMergedRange", "overlapping merged ranges" );
+ }
+#endif
+ if( mxImpl->IsValidPos( nFirstCol, nFirstRow ) && mxImpl->IsValidPos( nLastCol, nLastRow ) )
+ lclSetMergedRange( mxImpl->maCells, mxImpl->mnWidth, nFirstCol, nFirstRow, nLastCol, nLastRow );
+}
+
+void Array::RemoveMergedRange( size_t nCol, size_t nRow )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "RemoveMergedRange" );
+ for( MergedCellIterator aIt( *this, nCol, nRow ); aIt.Is(); ++aIt )
+ {
+ Cell& rCell = CELLACC( aIt.Col(), aIt.Row() );
+ rCell.mbMergeOrig = rCell.mbOverlapX = rCell.mbOverlapY = false;
+ rCell.mnAddLeft = rCell.mnAddRight = rCell.mnAddTop = rCell.mnAddBottom = 0;
+ }
+}
+
+void Array::SetAddMergedLeftSize( size_t nCol, size_t nRow, long nAddSize )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetAddMergedLeftSize" );
+ DBG_FRAME_CHECK( mxImpl->GetMergedFirstCol( nCol, nRow ) == 0, "SetAddMergedLeftSize", "additional border inside array" );
+ for( MergedCellIterator aIt( *this, nCol, nRow ); aIt.Is(); ++aIt )
+ CELLACC( aIt.Col(), aIt.Row() ).mnAddLeft = nAddSize;
+}
+
+void Array::SetAddMergedRightSize( size_t nCol, size_t nRow, long nAddSize )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetAddMergedRightSize" );
+ DBG_FRAME_CHECK( mxImpl->GetMergedLastCol( nCol, nRow ) + 1 == mxImpl->mnWidth, "SetAddMergedRightSize", "additional border inside array" );
+ for( MergedCellIterator aIt( *this, nCol, nRow ); aIt.Is(); ++aIt )
+ CELLACC( aIt.Col(), aIt.Row() ).mnAddRight = nAddSize;
+}
+
+void Array::SetAddMergedTopSize( size_t nCol, size_t nRow, long nAddSize )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetAddMergedTopSize" );
+ DBG_FRAME_CHECK( mxImpl->GetMergedFirstRow( nCol, nRow ) == 0, "SetAddMergedTopSize", "additional border inside array" );
+ for( MergedCellIterator aIt( *this, nCol, nRow ); aIt.Is(); ++aIt )
+ CELLACC( aIt.Col(), aIt.Row() ).mnAddTop = nAddSize;
+}
+
+void Array::SetAddMergedBottomSize( size_t nCol, size_t nRow, long nAddSize )
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "SetAddMergedBottomSize" );
+ DBG_FRAME_CHECK( mxImpl->GetMergedLastRow( nCol, nRow ) + 1 == mxImpl->mnHeight, "SetAddMergedBottomSize", "additional border inside array" );
+ for( MergedCellIterator aIt( *this, nCol, nRow ); aIt.Is(); ++aIt )
+ CELLACC( aIt.Col(), aIt.Row() ).mnAddBottom = nAddSize;
+}
+
+bool Array::IsMerged( size_t nCol, size_t nRow ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "IsMerged" );
+ return CELL( nCol, nRow ).IsMerged();
+}
+
+bool Array::IsMergedOrigin( size_t nCol, size_t nRow ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "IsMergedOrigin" );
+ return CELL( nCol, nRow ).mbMergeOrig;
+}
+
+bool Array::IsMergedOverlapped( size_t nCol, size_t nRow ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "IsMergedOverlapped" );
+ return CELL( nCol, nRow ).IsOverlapped();
+}
+
+bool Array::IsMergedOverlappedLeft( size_t nCol, size_t nRow ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "IsMergedOverlappedLeft" );
+ return mxImpl->IsMergedOverlappedLeft( nCol, nRow );
+}
+
+bool Array::IsMergedOverlappedRight( size_t nCol, size_t nRow ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "IsMergedOverlappedRight" );
+ return mxImpl->IsMergedOverlappedRight( nCol, nRow );
+}
+
+bool Array::IsMergedOverlappedTop( size_t nCol, size_t nRow ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "IsMergedOverlappedTop" );
+ return mxImpl->IsMergedOverlappedTop( nCol, nRow );
+}
+
+bool Array::IsMergedOverlappedBottom( size_t nCol, size_t nRow ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "IsMergedOverlappedBottom" );
+ return mxImpl->IsMergedOverlappedBottom( nCol, nRow );
+}
+
+void Array::GetMergedOrigin( size_t& rnFirstCol, size_t& rnFirstRow, size_t nCol, size_t nRow ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "GetMergedOrigin" );
+ rnFirstCol = mxImpl->GetMergedFirstCol( nCol, nRow );
+ rnFirstRow = mxImpl->GetMergedFirstRow( nCol, nRow );
+}
+
+void Array::GetMergedSize( size_t& rnWidth, size_t& rnHeight, size_t nCol, size_t nRow ) const
+{
+ size_t nFirstCol, nFirstRow, nLastCol, nLastRow;
+ GetMergedRange( nFirstCol, nFirstRow, nLastCol, nLastRow, nCol, nRow );
+ rnWidth = nLastCol - nFirstCol + 1;
+ rnHeight = nLastRow - nFirstRow + 1;
+}
+
+void Array::GetMergedRange( size_t& rnFirstCol, size_t& rnFirstRow,
+ size_t& rnLastCol, size_t& rnLastRow, size_t nCol, size_t nRow ) const
+{
+ GetMergedOrigin( rnFirstCol, rnFirstRow, nCol, nRow );
+ rnLastCol = mxImpl->GetMergedLastCol( nCol, nRow );
+ rnLastRow = mxImpl->GetMergedLastRow( nCol, nRow );
+}
+
+// clipping -------------------------------------------------------------------
+
+void Array::SetClipRange( size_t nFirstCol, size_t nFirstRow, size_t nLastCol, size_t nLastRow )
+{
+ DBG_FRAME_CHECK_COLROW( nFirstCol, nFirstRow, "SetClipRange" );
+ DBG_FRAME_CHECK_COLROW( nLastCol, nLastRow, "SetClipRange" );
+ mxImpl->mnFirstClipCol = nFirstCol;
+ mxImpl->mnFirstClipRow = nFirstRow;
+ mxImpl->mnLastClipCol = nLastCol;
+ mxImpl->mnLastClipRow = nLastRow;
+}
+
+void Array::RemoveClipRange()
+{
+ if( !mxImpl->maCells.empty() )
+ SetClipRange( 0, 0, mxImpl->mnWidth - 1, mxImpl->mnHeight - 1 );
+}
+
+bool Array::IsInClipRange( size_t nCol, size_t nRow ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "IsInClipRange" );
+ return mxImpl->IsInClipRange( nCol, nRow );
+}
+
+Rectangle Array::GetClipRangeRectangle() const
+{
+ return Rectangle(
+ mxImpl->GetColPosition( mxImpl->mnFirstClipCol ),
+ mxImpl->GetRowPosition( mxImpl->mnFirstClipRow ),
+ mxImpl->GetColPosition( mxImpl->mnLastClipCol + 1 ),
+ mxImpl->GetRowPosition( mxImpl->mnLastClipRow + 1 ) );
+}
+
+// cell coordinates -----------------------------------------------------------
+
+void Array::SetXOffset( long nXOffset )
+{
+ mxImpl->maXCoords[ 0 ] = nXOffset;
+ mxImpl->mbXCoordsDirty = true;
+}
+
+void Array::SetYOffset( long nYOffset )
+{
+ mxImpl->maYCoords[ 0 ] = nYOffset;
+ mxImpl->mbYCoordsDirty = true;
+}
+
+void Array::SetColWidth( size_t nCol, long nWidth )
+{
+ DBG_FRAME_CHECK_COL( nCol, "SetColWidth" );
+ mxImpl->maWidths[ nCol ] = nWidth;
+ mxImpl->mbXCoordsDirty = true;
+}
+
+void Array::SetRowHeight( size_t nRow, long nHeight )
+{
+ DBG_FRAME_CHECK_ROW( nRow, "SetRowHeight" );
+ mxImpl->maHeights[ nRow ] = nHeight;
+ mxImpl->mbYCoordsDirty = true;
+}
+
+void Array::SetAllColWidths( long nWidth )
+{
+ std::fill( mxImpl->maWidths.begin(), mxImpl->maWidths.end(), nWidth );
+ mxImpl->mbXCoordsDirty = true;
+}
+
+void Array::SetAllRowHeights( long nHeight )
+{
+ std::fill( mxImpl->maHeights.begin(), mxImpl->maHeights.end(), nHeight );
+ mxImpl->mbYCoordsDirty = true;
+}
+
+long Array::GetColPosition( size_t nCol ) const
+{
+ DBG_FRAME_CHECK_COL_1( nCol, "GetColPosition" );
+ return mxImpl->GetColPosition( nCol );
+}
+
+long Array::GetRowPosition( size_t nRow ) const
+{
+ DBG_FRAME_CHECK_ROW_1( nRow, "GetRowPosition" );
+ return mxImpl->GetRowPosition( nRow );
+}
+
+long Array::GetColWidth( size_t nCol ) const
+{
+ DBG_FRAME_CHECK_COL( nCol, "GetColWidth" );
+ return mxImpl->maWidths[ nCol ];
+}
+
+long Array::GetColWidth( size_t nFirstCol, size_t nLastCol ) const
+{
+ DBG_FRAME_CHECK_COL( nFirstCol, "GetColWidth" );
+ DBG_FRAME_CHECK_COL( nLastCol, "GetColWidth" );
+ return GetColPosition( nLastCol + 1 ) - GetColPosition( nFirstCol );
+}
+
+long Array::GetRowHeight( size_t nRow ) const
+{
+ DBG_FRAME_CHECK_ROW( nRow, "GetRowHeight" );
+ return mxImpl->maHeights[ nRow ];
+}
+
+long Array::GetRowHeight( size_t nFirstRow, size_t nLastRow ) const
+{
+ DBG_FRAME_CHECK_ROW( nFirstRow, "GetRowHeight" );
+ DBG_FRAME_CHECK_ROW( nLastRow, "GetRowHeight" );
+ return GetRowPosition( nLastRow + 1 ) - GetRowPosition( nFirstRow );
+}
+
+long Array::GetWidth() const
+{
+ return GetColPosition( mxImpl->mnWidth ) - GetColPosition( 0 );
+}
+
+long Array::GetHeight() const
+{
+ return GetRowPosition( mxImpl->mnHeight ) - GetRowPosition( 0 );
+}
+
+Point Array::GetCellPosition( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ size_t nFirstCol = bSimple ? nCol : mxImpl->GetMergedFirstCol( nCol, nRow );
+ size_t nFirstRow = bSimple ? nRow : mxImpl->GetMergedFirstRow( nCol, nRow );
+ return Point( GetColPosition( nFirstCol ), GetRowPosition( nFirstRow ) );
+}
+
+Size Array::GetCellSize( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ size_t nFirstCol = bSimple ? nCol : mxImpl->GetMergedFirstCol( nCol, nRow );
+ size_t nFirstRow = bSimple ? nRow : mxImpl->GetMergedFirstRow( nCol, nRow );
+ size_t nLastCol = bSimple ? nCol : mxImpl->GetMergedLastCol( nCol, nRow );
+ size_t nLastRow = bSimple ? nRow : mxImpl->GetMergedLastRow( nCol, nRow );
+ return Size( GetColWidth( nFirstCol, nLastCol ) + 1, GetRowHeight( nFirstRow, nLastRow ) + 1 );
+}
+
+Rectangle Array::GetCellRect( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ Rectangle aRect( GetCellPosition( nCol, nRow, bSimple ), GetCellSize( nCol, nRow, bSimple ) );
+
+ // adjust rectangle for partly visible merged cells
+ const Cell& rCell = CELL( nCol, nRow );
+ if( !bSimple && rCell.IsMerged() )
+ {
+ aRect.Left() -= rCell.mnAddLeft;
+ aRect.Right() += rCell.mnAddRight;
+ aRect.Top() -= rCell.mnAddTop;
+ aRect.Bottom() += rCell.mnAddBottom;
+ }
+ return aRect;
+}
+
+// diagonal frame borders -----------------------------------------------------
+
+double Array::GetHorDiagAngle( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "GetHorDiagAngle" );
+ return mxImpl->GetHorDiagAngle( nCol, nRow, bSimple );
+}
+
+double Array::GetVerDiagAngle( size_t nCol, size_t nRow, bool bSimple ) const
+{
+ DBG_FRAME_CHECK_COLROW( nCol, nRow, "GetVerDiagAngle" );
+ return mxImpl->GetVerDiagAngle( nCol, nRow, bSimple );
+}
+
+void Array::SetUseDiagDoubleClipping( bool bSet )
+{
+ mxImpl->mbDiagDblClip = bSet;
+}
+
+bool Array::GetUseDiagDoubleClipping() const
+{
+ return mxImpl->mbDiagDblClip;
+}
+
+// mirroring ------------------------------------------------------------------
+
+void Array::MirrorSelfX( bool bMirrorStyles, bool bSwapDiag )
+{
+ CellVec aNewCells;
+ aNewCells.reserve( GetCellCount() );
+
+ size_t nCol, nRow;
+ for( nRow = 0; nRow < mxImpl->mnHeight; ++nRow )
+ {
+ for( nCol = 0; nCol < mxImpl->mnWidth; ++nCol )
+ {
+ aNewCells.push_back( CELL( mxImpl->GetMirrorCol( nCol ), nRow ) );
+ aNewCells.back().MirrorSelfX( bMirrorStyles, bSwapDiag );
+ }
+ }
+ for( nRow = 0; nRow < mxImpl->mnHeight; ++nRow )
+ {
+ for( nCol = 0; nCol < mxImpl->mnWidth; ++nCol )
+ {
+ if( CELL( nCol, nRow ).mbMergeOrig )
+ {
+ size_t nLastCol = mxImpl->GetMergedLastCol( nCol, nRow );
+ size_t nLastRow = mxImpl->GetMergedLastRow( nCol, nRow );
+ lclSetMergedRange( aNewCells, mxImpl->mnWidth,
+ mxImpl->GetMirrorCol( nLastCol ), nRow,
+ mxImpl->GetMirrorCol( nCol ), nLastRow );
+ }
+ }
+ }
+ mxImpl->maCells.swap( aNewCells );
+
+ std::reverse( mxImpl->maWidths.begin(), mxImpl->maWidths.end() );
+ mxImpl->mbXCoordsDirty = true;
+}
+
+void Array::MirrorSelfY( bool bMirrorStyles, bool bSwapDiag )
+{
+ CellVec aNewCells;
+ aNewCells.reserve( GetCellCount() );
+
+ size_t nCol, nRow;
+ for( nRow = 0; nRow < mxImpl->mnHeight; ++nRow )
+ {
+ for( nCol = 0; nCol < mxImpl->mnWidth; ++nCol )
+ {
+ aNewCells.push_back( CELL( nCol, mxImpl->GetMirrorRow( nRow ) ) );
+ aNewCells.back().MirrorSelfY( bMirrorStyles, bSwapDiag );
+ }
+ }
+ for( nRow = 0; nRow < mxImpl->mnHeight; ++nRow )
+ {
+ for( nCol = 0; nCol < mxImpl->mnWidth; ++nCol )
+ {
+ if( CELL( nCol, nRow ).mbMergeOrig )
+ {
+ size_t nLastCol = mxImpl->GetMergedLastCol( nCol, nRow );
+ size_t nLastRow = mxImpl->GetMergedLastRow( nCol, nRow );
+ lclSetMergedRange( aNewCells, mxImpl->mnWidth,
+ nCol, mxImpl->GetMirrorRow( nLastRow ),
+ nLastCol, mxImpl->GetMirrorRow( nRow ) );
+ }
+ }
+ }
+ mxImpl->maCells.swap( aNewCells );
+
+ std::reverse( mxImpl->maHeights.begin(), mxImpl->maHeights.end() );
+ mxImpl->mbYCoordsDirty = true;
+}
+
+// drawing --------------------------------------------------------------------
+
+void Array::DrawCell( OutputDevice& rDev, size_t nCol, size_t nRow, const Color* pForceColor ) const
+{
+ DrawRange( rDev, nCol, nRow, nCol, nRow, pForceColor );
+}
+
+void Array::DrawRange( OutputDevice& rDev,
+ size_t nFirstCol, size_t nFirstRow, size_t nLastCol, size_t nLastRow,
+ const Color* pForceColor ) const
+{
+ DBG_FRAME_CHECK_COLROW( nFirstCol, nFirstRow, "DrawRange" );
+ DBG_FRAME_CHECK_COLROW( nLastCol, nLastRow, "DrawRange" );
+
+ size_t nCol, nRow;
+
+ // *** diagonal frame borders ***
+
+ // set clipping region to clip partly visible merged cells
+ rDev.Push( PUSH_CLIPREGION );
+ rDev.IntersectClipRegion( GetClipRangeRectangle() );
+ for( nRow = nFirstRow; nRow <= nLastRow; ++nRow )
+ {
+ for( nCol = nFirstCol; nCol <= nLastCol; ++nCol )
+ {
+ const Cell& rCell = CELL( nCol, nRow );
+ bool bOverlapX = rCell.mbOverlapX;
+ bool bOverlapY = rCell.mbOverlapY;
+ bool bFirstCol = nCol == nFirstCol;
+ bool bFirstRow = nRow == nFirstRow;
+ if( (!bOverlapX && !bOverlapY) || (bFirstCol && bFirstRow) ||
+ (!bOverlapY && bFirstCol) || (!bOverlapX && bFirstRow) )
+ {
+ Rectangle aRect( GetCellRect( nCol, nRow ) );
+ if( (aRect.GetWidth() > 1) && (aRect.GetHeight() > 1) )
+ {
+ size_t _nFirstCol = mxImpl->GetMergedFirstCol( nCol, nRow );
+ size_t _nFirstRow = mxImpl->GetMergedFirstRow( nCol, nRow );
+ size_t _nLastCol = mxImpl->GetMergedLastCol( nCol, nRow );
+ size_t _nLastRow = mxImpl->GetMergedLastRow( nCol, nRow );
+
+ DrawDiagFrameBorders( rDev, aRect,
+ GetCellStyleTLBR( _nFirstCol, _nFirstRow, true ), GetCellStyleBLTR( _nFirstCol, _nFirstRow, true ),
+ GetCellStyleLeft( _nFirstCol, _nFirstRow ), GetCellStyleTop( _nFirstCol, _nFirstRow ),
+ GetCellStyleRight( _nLastCol, _nLastRow ), GetCellStyleBottom( _nLastCol, _nLastRow ),
+ GetCellStyleLeft( _nFirstCol, _nLastRow ), GetCellStyleBottom( _nFirstCol, _nLastRow ),
+ GetCellStyleRight( _nLastCol, _nFirstRow ), GetCellStyleTop( _nLastCol, _nFirstRow ),
+ pForceColor, mxImpl->mbDiagDblClip );
+ }
+ }
+ }
+ }
+ rDev.Pop(); // clip region
+
+ // *** horizontal frame borders ***
+
+ for( nRow = nFirstRow; nRow <= nLastRow + 1; ++nRow )
+ {
+ double fAngle = mxImpl->GetHorDiagAngle( nFirstCol, nRow );
+ double fTAngle = mxImpl->GetHorDiagAngle( nFirstCol, nRow - 1 );
+
+ // *Start*** variables store the data of the left end of the cached frame border
+ Point aStartPos( mxImpl->GetColPosition( nFirstCol ), mxImpl->GetRowPosition( nRow ) );
+ const Style* pStart = &GetCellStyleTop( nFirstCol, nRow );
+ DiagStyle aStartLFromTR( GetCellStyleBL( nFirstCol, nRow - 1 ), fTAngle );
+ const Style* pStartLFromT = &GetCellStyleLeft( nFirstCol, nRow - 1 );
+ const Style* pStartLFromL = &GetCellStyleTop( nFirstCol - 1, nRow );
+ const Style* pStartLFromB = &GetCellStyleLeft( nFirstCol, nRow );
+ DiagStyle aStartLFromBR( GetCellStyleTL( nFirstCol, nRow ), fAngle );
+
+ // *End*** variables store the data of the right end of the cached frame border
+ DiagStyle aEndRFromTL( GetCellStyleBR( nFirstCol, nRow - 1 ), fTAngle );
+ const Style* pEndRFromT = &GetCellStyleRight( nFirstCol, nRow - 1 );
+ const Style* pEndRFromR = &GetCellStyleTop( nFirstCol + 1, nRow );
+ const Style* pEndRFromB = &GetCellStyleRight( nFirstCol, nRow );
+ DiagStyle aEndRFromBL( GetCellStyleTR( nFirstCol, nRow ), fAngle );
+
+ for( nCol = nFirstCol + 1; nCol <= nLastCol; ++nCol )
+ {
+ fAngle = mxImpl->GetHorDiagAngle( nCol, nRow );
+ fTAngle = mxImpl->GetHorDiagAngle( nCol, nRow - 1 );
+
+ const Style& rCurr = *pEndRFromR;
+
+ DiagStyle aLFromTR( GetCellStyleBL( nCol, nRow - 1 ), fTAngle );
+ const Style& rLFromT = *pEndRFromT;
+ const Style& rLFromL = *pStart;
+ const Style& rLFromB = *pEndRFromB;
+ DiagStyle aLFromBR( GetCellStyleTL( nCol, nRow ), fAngle );
+
+ DiagStyle aRFromTL( GetCellStyleBR( nCol, nRow - 1 ), fTAngle );
+ const Style& rRFromT = GetCellStyleRight( nCol, nRow - 1 );
+ const Style& rRFromR = GetCellStyleTop( nCol + 1, nRow );
+ const Style& rRFromB = GetCellStyleRight( nCol, nRow );
+ DiagStyle aRFromBL( GetCellStyleTR( nCol, nRow ), fAngle );
+
+ // check if current frame border can be connected to cached frame border
+ if( !CheckFrameBorderConnectable( *pStart, rCurr,
+ aEndRFromTL, rLFromT, aLFromTR, aEndRFromBL, rLFromB, aLFromBR ) )
+ {
+ // draw previous frame border
+ Point aEndPos( mxImpl->GetColPosition( nCol ), aStartPos.Y() );
+ if( pStart->Prim() && (aStartPos.X() <= aEndPos.X()) )
+ DrawHorFrameBorder( rDev, aStartPos, aEndPos, *pStart,
+ aStartLFromTR, *pStartLFromT, *pStartLFromL, *pStartLFromB, aStartLFromBR,
+ aEndRFromTL, *pEndRFromT, *pEndRFromR, *pEndRFromB, aEndRFromBL, pForceColor );
+
+ // re-init "*Start***" variables
+ aStartPos = aEndPos;
+ pStart = &rCurr;
+ aStartLFromTR = aLFromTR;
+ pStartLFromT = &rLFromT;
+ pStartLFromL = &rLFromL;
+ pStartLFromB = &rLFromB;
+ aStartLFromBR = aLFromBR;
+ }
+
+ // store current styles in "*End***" variables
+ aEndRFromTL = aRFromTL;
+ pEndRFromT = &rRFromT;
+ pEndRFromR = &rRFromR;
+ pEndRFromB = &rRFromB;
+ aEndRFromBL = aRFromBL;
+ }
+
+ // draw last frame border
+ Point aEndPos( mxImpl->GetColPosition( nCol ), aStartPos.Y() );
+ if( pStart->Prim() && (aStartPos.X() <= aEndPos.X()) )
+ DrawHorFrameBorder( rDev, aStartPos, aEndPos, *pStart,
+ aStartLFromTR, *pStartLFromT, *pStartLFromL, *pStartLFromB, aStartLFromBR,
+ aEndRFromTL, *pEndRFromT, *pEndRFromR, *pEndRFromB, aEndRFromBL, pForceColor );
+ }
+
+ // *** vertical frame borders ***
+
+ for( nCol = nFirstCol; nCol <= nLastCol + 1; ++nCol )
+ {
+ double fAngle = mxImpl->GetVerDiagAngle( nCol, nFirstRow );
+ double fLAngle = mxImpl->GetVerDiagAngle( nCol - 1, nFirstRow );
+
+ // *Start*** variables store the data of the top end of the cached frame border
+ Point aStartPos( mxImpl->GetColPosition( nCol ), mxImpl->GetRowPosition( nFirstRow ) );
+ const Style* pStart = &GetCellStyleLeft( nCol, nFirstRow );
+ DiagStyle aStartTFromBL( GetCellStyleTR( nCol - 1, nFirstRow ), fLAngle );
+ const Style* pStartTFromL = &GetCellStyleTop( nCol - 1, nFirstRow );
+ const Style* pStartTFromT = &GetCellStyleLeft( nCol, nFirstRow - 1 );
+ const Style* pStartTFromR = &GetCellStyleTop( nCol, nFirstRow );
+ DiagStyle aStartTFromBR( GetCellStyleTL( nCol, nFirstRow ), fAngle );
+
+ // *End*** variables store the data of the bottom end of the cached frame border
+ DiagStyle aEndBFromTL( GetCellStyleBR( nCol - 1, nFirstRow ), fLAngle );
+ const Style* pEndBFromL = &GetCellStyleBottom( nCol - 1, nFirstRow );
+ const Style* pEndBFromB = &GetCellStyleLeft( nCol, nFirstRow + 1 );
+ const Style* pEndBFromR = &GetCellStyleBottom( nCol, nFirstRow );
+ DiagStyle aEndBFromTR( GetCellStyleBL( nCol, nFirstRow ), fAngle );
+
+ for( nRow = nFirstRow + 1; nRow <= nLastRow; ++nRow )
+ {
+ fAngle = mxImpl->GetVerDiagAngle( nCol, nRow );
+ fLAngle = mxImpl->GetVerDiagAngle( nCol - 1, nRow );
+
+ const Style& rCurr = *pEndBFromB;
+
+ DiagStyle aTFromBL( GetCellStyleTR( nCol - 1, nRow ), fLAngle );
+ const Style& rTFromL = *pEndBFromL;
+ const Style& rTFromT = *pStart;
+ const Style& rTFromR = *pEndBFromR;
+ DiagStyle aTFromBR( GetCellStyleTL( nCol, nRow ), fAngle );
+
+ DiagStyle aBFromTL( GetCellStyleBR( nCol - 1, nRow ), fLAngle );
+ const Style& rBFromL = GetCellStyleBottom( nCol - 1, nRow );
+ const Style& rBFromB = GetCellStyleLeft( nCol, nRow + 1 );
+ const Style& rBFromR = GetCellStyleBottom( nCol, nRow );
+ DiagStyle aBFromTR( GetCellStyleBL( nCol, nRow ), fAngle );
+
+ // check if current frame border can be connected to cached frame border
+ if( !CheckFrameBorderConnectable( *pStart, rCurr,
+ aEndBFromTL, rTFromL, aTFromBL, aEndBFromTR, rTFromR, aTFromBR ) )
+ {
+ // draw previous frame border
+ Point aEndPos( aStartPos.X(), mxImpl->GetRowPosition( nRow ) );
+ if( pStart->Prim() && (aStartPos.Y() <= aEndPos.Y()) )
+ DrawVerFrameBorder( rDev, aStartPos, aEndPos, *pStart,
+ aStartTFromBL, *pStartTFromL, *pStartTFromT, *pStartTFromR, aStartTFromBR,
+ aEndBFromTL, *pEndBFromL, *pEndBFromB, *pEndBFromR, aEndBFromTR, pForceColor );
+
+ // re-init "*Start***" variables
+ aStartPos = aEndPos;
+ pStart = &rCurr;
+ aStartTFromBL = aTFromBL;
+ pStartTFromL = &rTFromL;
+ pStartTFromT = &rTFromT;
+ pStartTFromR = &rTFromR;
+ aStartTFromBR = aTFromBR;
+ }
+
+ // store current styles in "*End***" variables
+ aEndBFromTL = aBFromTL;
+ pEndBFromL = &rBFromL;
+ pEndBFromB = &rBFromB;
+ pEndBFromR = &rBFromR;
+ aEndBFromTR = aBFromTR;
+ }
+
+ // draw last frame border
+ Point aEndPos( aStartPos.X(), mxImpl->GetRowPosition( nRow ) );
+ if( pStart->Prim() && (aStartPos.Y() <= aEndPos.Y()) )
+ DrawVerFrameBorder( rDev, aStartPos, aEndPos, *pStart,
+ aStartTFromBL, *pStartTFromL, *pStartTFromT, *pStartTFromR, aStartTFromBR,
+ aEndBFromTL, *pEndBFromL, *pEndBFromB, *pEndBFromR, aEndBFromTR, pForceColor );
+ }
+}
+
+void Array::DrawArray( OutputDevice& rDev, const Color* pForceColor ) const
+{
+ if( mxImpl->mnWidth && mxImpl->mnHeight )
+ DrawRange( rDev, 0, 0, mxImpl->mnWidth - 1, mxImpl->mnHeight - 1, pForceColor );
+}
+
+// ----------------------------------------------------------------------------
+
+#undef ORIGCELLACC
+#undef ORIGCELL
+#undef CELLACC
+#undef CELL
+
+// ----------------------------------------------------------------------------
+
+#undef DBG_FRAME_CHECK_ROW_1
+#undef DBG_FRAME_CHECK_COL_1
+#undef DBG_FRAME_CHECK_INDEX
+#undef DBG_FRAME_CHECK_COLROW
+#undef DBG_FRAME_CHECK_ROW
+#undef DBG_FRAME_CHECK_COL
+#undef DBG_FRAME_CHECK
+#undef DBG_FRAME_ERROR
+
+// ============================================================================
+
+} // namespace frame
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/frmdirlbox.cxx b/svx/source/dialog/frmdirlbox.cxx
new file mode 100644
index 000000000000..03b1eec8a2cc
--- /dev/null
+++ b/svx/source/dialog/frmdirlbox.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/frmdirlbox.hxx>
+
+namespace svx {
+
+// ============================================================================
+
+namespace {
+
+inline void* lclEnumToVoid( SvxFrameDirection eDirection )
+{
+ return reinterpret_cast< void* >( static_cast< sal_uInt32 >( eDirection ) );
+}
+
+inline SvxFrameDirection lclVoidToEnum( void* pDirection )
+{
+ return static_cast< SvxFrameDirection >( reinterpret_cast< sal_IntPtr >( pDirection ) );
+}
+
+} // namespace
+
+// ============================================================================
+
+FrameDirectionListBox::FrameDirectionListBox( Window* pParent, WinBits nStyle ) :
+ ListBox( pParent, nStyle )
+{
+}
+
+FrameDirectionListBox::FrameDirectionListBox( Window* pParent, const ResId& rResId ) :
+ ListBox( pParent, rResId )
+{
+}
+
+FrameDirectionListBox::~FrameDirectionListBox()
+{
+}
+
+void FrameDirectionListBox::InsertEntryValue( const String& rString, SvxFrameDirection eDirection, sal_uInt16 nPos )
+{
+ sal_uInt16 nRealPos = InsertEntry( rString, nPos );
+ SetEntryData( nRealPos, lclEnumToVoid( eDirection ) );
+}
+
+void FrameDirectionListBox::RemoveEntryValue( SvxFrameDirection eDirection )
+{
+ sal_uInt16 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
+ if( nPos != LISTBOX_ENTRY_NOTFOUND )
+ RemoveEntry( nPos );
+}
+
+void FrameDirectionListBox::SelectEntryValue( SvxFrameDirection eDirection )
+{
+ sal_uInt16 nPos = GetEntryPos( lclEnumToVoid( eDirection ) );
+ if( nPos == LISTBOX_ENTRY_NOTFOUND )
+ SetNoSelection();
+ else
+ SelectEntryPos( nPos );
+}
+
+SvxFrameDirection FrameDirectionListBox::GetSelectEntryValue() const
+{
+ sal_uInt16 nPos = GetSelectEntryPos();
+ if( nPos == LISTBOX_ENTRY_NOTFOUND )
+ return static_cast< SvxFrameDirection >( 0xFFFF );
+ return lclVoidToEnum( GetEntryData( nPos ) );
+}
+
+// ============================================================================
+
+FrameDirListBoxWrapper::FrameDirListBoxWrapper( FrameDirListBox& rListBox ) :
+ SingleControlWrapperType( rListBox )
+{
+}
+
+bool FrameDirListBoxWrapper::IsControlDontKnow() const
+{
+ return GetControl().GetSelectEntryCount() == 0;
+}
+
+void FrameDirListBoxWrapper::SetControlDontKnow( bool bSet )
+{
+ if( bSet )
+ GetControl().SetNoSelection();
+}
+
+SvxFrameDirection FrameDirListBoxWrapper::GetControlValue() const
+{
+ return GetControl().GetSelectEntryValue();
+}
+
+void FrameDirListBoxWrapper::SetControlValue( SvxFrameDirection eValue )
+{
+ GetControl().SelectEntryValue( eValue );
+}
+
+// ============================================================================
+
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/frmsel.cxx b/svx/source/dialog/frmsel.cxx
new file mode 100644
index 000000000000..867ef9a593c6
--- /dev/null
+++ b/svx/source/dialog/frmsel.cxx
@@ -0,0 +1,1228 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/frmsel.hxx>
+
+#include <algorithm>
+#include <math.h>
+#include "frmselimpl.hxx"
+#include "AccessibleFrameSelector.hxx"
+#include <svx/dialmgr.hxx>
+
+#include <svx/dialogs.hrc>
+#include "frmsel.hrc"
+
+#include <tools/rcid.h>
+
+namespace svx {
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::accessibility::XAccessible;
+
+// ============================================================================
+// global functions from framebordertype.hxx
+
+FrameBorderType GetFrameBorderTypeFromIndex( size_t nIndex )
+{
+ DBG_ASSERT( nIndex < (size_t)FRAMEBORDERTYPE_COUNT,
+ "svx::GetFrameBorderTypeFromIndex - invalid index" );
+ return static_cast< FrameBorderType >( nIndex + 1 );
+}
+
+size_t GetIndexFromFrameBorderType( FrameBorderType eBorder )
+{
+ DBG_ASSERT( eBorder != FRAMEBORDER_NONE,
+ "svx::GetIndexFromFrameBorderType - invalid frame border type" );
+ return static_cast< size_t >( eBorder ) - 1;
+}
+
+// ============================================================================
+
+namespace {
+
+/** Space between outer control border and any graphical element of the control. */
+const long FRAMESEL_GEOM_OUTER = 2;
+
+/** Space between arrows and usable inner area. */
+const long FRAMESEL_GEOM_INNER = 3;
+
+/** Maximum width to draw a frame border style. */
+const long FRAMESEL_GEOM_WIDTH = 9;
+
+/** Additional margin for click area of outer lines. */
+const long FRAMESEL_GEOM_ADD_CLICK_OUTER = 5;
+
+/** Additional margin for click area of inner lines. */
+const long FRAMESEL_GEOM_ADD_CLICK_INNER = 2;
+
+// ----------------------------------------------------------------------------
+
+static const frame::Style OBJ_FRAMESTYLE_DONTCARE( 3, 0, 0 );
+static const FrameBorder OBJ_FRAMEBORDER_NONE( FRAMEBORDER_NONE );
+
+// ----------------------------------------------------------------------------
+
+/** Returns the corresponding flag for a frame border. */
+FrameSelFlags lclGetFlagFromType( FrameBorderType eBorder )
+{
+ switch( eBorder )
+ {
+ case FRAMEBORDER_LEFT: return FRAMESEL_LEFT;
+ case FRAMEBORDER_RIGHT: return FRAMESEL_RIGHT;
+ case FRAMEBORDER_TOP: return FRAMESEL_TOP;
+ case FRAMEBORDER_BOTTOM: return FRAMESEL_BOTTOM;
+ case FRAMEBORDER_HOR: return FRAMESEL_INNER_HOR;
+ case FRAMEBORDER_VER: return FRAMESEL_INNER_VER;
+ case FRAMEBORDER_TLBR: return FRAMESEL_DIAG_TLBR;
+ case FRAMEBORDER_BLTR: return FRAMESEL_DIAG_BLTR;
+ case FRAMEBORDER_NONE : break;
+ }
+ return FRAMESEL_NONE;
+}
+
+/** Converts an SvxBorderLine line width (in twips) to a pixel line width. */
+inline sal_uInt16 lclGetPixel( USHORT nWidth )
+{
+ // convert all core styles expect 0 to a visible UI style (at least 1 pixel), map 1pt to 1pixel
+ return nWidth ? std::min< sal_uInt16 >( std::max< sal_uInt16 >( (nWidth + 5) / 20, 1 ), FRAMESEL_GEOM_WIDTH ) : 0;
+}
+
+/** Merges the rSource polypolygon into the rDest polypolygon. */
+inline void lclPolyPolyUnion( PolyPolygon& rDest, const PolyPolygon& rSource )
+{
+ const PolyPolygon aTmp( rDest );
+ aTmp.GetUnion( rSource, rDest );
+}
+
+} // namespace
+
+// ============================================================================
+// FrameBorder
+// ============================================================================
+
+FrameBorder::FrameBorder( FrameBorderType eType ) :
+ meType( eType ),
+ meState( FRAMESTATE_HIDE ),
+ meKeyLeft( FRAMEBORDER_NONE ),
+ meKeyRight( FRAMEBORDER_NONE ),
+ meKeyTop( FRAMEBORDER_NONE ),
+ meKeyBottom( FRAMEBORDER_NONE ),
+ mbEnabled( false ),
+ mbSelected( false )
+{
+}
+
+void FrameBorder::Enable( FrameSelFlags nFlags )
+{
+ mbEnabled = (nFlags & lclGetFlagFromType( meType )) != 0;
+ if( !mbEnabled )
+ SetState( FRAMESTATE_HIDE );
+}
+
+void FrameBorder::SetCoreStyle( const SvxBorderLine* pStyle )
+{
+ if( pStyle )
+ maCoreStyle = *pStyle;
+ else
+ maCoreStyle = SvxBorderLine();
+
+ // from twips to points
+ maUIStyle.Set( maCoreStyle, 0.05, FRAMESEL_GEOM_WIDTH );
+ meState = maUIStyle.Prim() ? FRAMESTATE_SHOW : FRAMESTATE_HIDE;
+}
+
+void FrameBorder::SetState( FrameBorderState eState )
+{
+ meState = eState;
+ switch( meState )
+ {
+ case FRAMESTATE_SHOW:
+ DBG_ERRORFILE( "svx::FrameBorder::SetState - use SetCoreStyle to make border visible" );
+ break;
+ case FRAMESTATE_HIDE:
+ maCoreStyle = SvxBorderLine();
+ maUIStyle.Clear();
+ break;
+ case FRAMESTATE_DONTCARE:
+ maCoreStyle = SvxBorderLine();
+ maUIStyle = OBJ_FRAMESTYLE_DONTCARE;
+ break;
+ }
+}
+
+void FrameBorder::AddFocusPolygon( const Polygon& rFocus )
+{
+ lclPolyPolyUnion( maFocusArea, rFocus );
+}
+
+void FrameBorder::MergeFocusToPolyPolygon( PolyPolygon& rPPoly ) const
+{
+ lclPolyPolyUnion( rPPoly, maFocusArea );
+}
+
+void FrameBorder::AddClickRect( const Rectangle& rRect )
+{
+ lclPolyPolyUnion( maClickArea, Polygon( rRect ) );
+}
+
+bool FrameBorder::ContainsClickPoint( const Point& rPos ) const
+{
+ return Region( maClickArea ).IsInside( rPos );
+}
+
+void FrameBorder::MergeClickAreaToPolyPolygon( PolyPolygon& rPPoly ) const
+{
+ lclPolyPolyUnion( rPPoly, maClickArea );
+}
+
+Rectangle FrameBorder::GetClickBoundRect() const
+{
+ return maClickArea.GetBoundRect();
+}
+
+void FrameBorder::SetKeyboardNeighbors(
+ FrameBorderType eLeft, FrameBorderType eRight, FrameBorderType eTop, FrameBorderType eBottom )
+{
+ meKeyLeft = eLeft;
+ meKeyRight = eRight;
+ meKeyTop = eTop;
+ meKeyBottom = eBottom;
+}
+
+FrameBorderType FrameBorder::GetKeyboardNeighbor( USHORT nKeyCode ) const
+{
+ FrameBorderType eBorder = FRAMEBORDER_NONE;
+ switch( nKeyCode )
+ {
+ case KEY_LEFT: eBorder = meKeyLeft; break;
+ case KEY_RIGHT: eBorder = meKeyRight; break;
+ case KEY_UP: eBorder = meKeyTop; break;
+ case KEY_DOWN: eBorder = meKeyBottom; break;
+ default: DBG_ERRORFILE( "svx::FrameBorder::GetKeyboardNeighbor - unknown key code" );
+ }
+ return eBorder;
+}
+
+// ============================================================================
+// FrameSelectorImpl
+// ============================================================================
+
+FrameSelectorImpl::FrameSelectorImpl( FrameSelector& rFrameSel ) :
+ Resource( SVX_RES( RID_SVXSTR_BORDER_CONTROL ) ),
+ mrFrameSel( rFrameSel ),
+ maILArrows( 16 ),
+ maLeft( FRAMEBORDER_LEFT ),
+ maRight( FRAMEBORDER_RIGHT ),
+ maTop( FRAMEBORDER_TOP ),
+ maBottom( FRAMEBORDER_BOTTOM ),
+ maHor( FRAMEBORDER_HOR ),
+ maVer( FRAMEBORDER_VER ),
+ maTLBR( FRAMEBORDER_TLBR ),
+ maBLTR( FRAMEBORDER_BLTR ),
+ mnFlags( FRAMESEL_OUTER ),
+ mbHor( false ),
+ mbVer( false ),
+ mbTLBR( false ),
+ mbBLTR( false ),
+ mbFullRepaint( true ),
+ mbAutoSelect( true ),
+ mbClicked( false ),
+ mbHCMode( false ),
+ mpAccess( 0 ),
+ maChildVec( 8, static_cast< a11y::AccFrameSelector* >( 0 ) ),
+ mxChildVec( 8 )
+{
+ FreeResource();
+
+ maAllBorders.resize( FRAMEBORDERTYPE_COUNT, 0 );
+ maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_LEFT ) ] = &maLeft;
+ maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_RIGHT ) ] = &maRight;
+ maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_TOP ) ] = &maTop;
+ maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_BOTTOM ) ] = &maBottom;
+ maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_HOR ) ] = &maHor;
+ maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_VER ) ] = &maVer;
+ maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_TLBR ) ] = &maTLBR;
+ maAllBorders[ GetIndexFromFrameBorderType( FRAMEBORDER_BLTR ) ] = &maBLTR;
+#if OSL_DEBUG_LEVEL >= 2
+ {
+ bool bOk = true;
+ for( FrameBorderCIter aIt( maAllBorders ); bOk && aIt.Is(); bOk = (*aIt != 0), ++aIt );
+ DBG_ASSERT( bOk, "svx::FrameSelectorImpl::FrameSelectorImpl - missing entry in maAllBorders" );
+ }
+#endif
+ // left neighbor right neighbor upper neighbor lower neighbor
+ maLeft.SetKeyboardNeighbors( FRAMEBORDER_NONE, FRAMEBORDER_TLBR, FRAMEBORDER_TOP, FRAMEBORDER_BOTTOM );
+ maRight.SetKeyboardNeighbors( FRAMEBORDER_BLTR, FRAMEBORDER_NONE, FRAMEBORDER_TOP, FRAMEBORDER_BOTTOM );
+ maTop.SetKeyboardNeighbors( FRAMEBORDER_LEFT, FRAMEBORDER_RIGHT, FRAMEBORDER_NONE, FRAMEBORDER_TLBR );
+ maBottom.SetKeyboardNeighbors( FRAMEBORDER_LEFT, FRAMEBORDER_RIGHT, FRAMEBORDER_BLTR, FRAMEBORDER_NONE );
+ maHor.SetKeyboardNeighbors( FRAMEBORDER_LEFT, FRAMEBORDER_RIGHT, FRAMEBORDER_TLBR, FRAMEBORDER_BLTR );
+ maVer.SetKeyboardNeighbors( FRAMEBORDER_TLBR, FRAMEBORDER_BLTR, FRAMEBORDER_TOP, FRAMEBORDER_BOTTOM );
+ maTLBR.SetKeyboardNeighbors( FRAMEBORDER_LEFT, FRAMEBORDER_VER, FRAMEBORDER_TOP, FRAMEBORDER_HOR );
+ maBLTR.SetKeyboardNeighbors( FRAMEBORDER_VER, FRAMEBORDER_RIGHT, FRAMEBORDER_HOR, FRAMEBORDER_BOTTOM );
+}
+
+FrameSelectorImpl::~FrameSelectorImpl()
+{
+ if( mpAccess )
+ mpAccess->Invalidate();
+ for( AccessibleImplVec::iterator aIt = maChildVec.begin(), aEnd = maChildVec.end(); aIt != aEnd; ++aIt )
+ if( *aIt )
+ (*aIt)->Invalidate();
+}
+
+// initialization -------------------------------------------------------------
+
+void FrameSelectorImpl::Initialize( FrameSelFlags nFlags )
+{
+ mnFlags = nFlags;
+
+ maEnabBorders.clear();
+ for( FrameBorderIter aIt( maAllBorders ); aIt.Is(); ++aIt )
+ {
+ (*aIt)->Enable( mnFlags );
+ if( (*aIt)->IsEnabled() )
+ maEnabBorders.push_back( *aIt );
+ }
+ mbHor = maHor.IsEnabled();
+ mbVer = maVer.IsEnabled();
+ mbTLBR = maTLBR.IsEnabled();
+ mbBLTR = maBLTR.IsEnabled();
+
+ InitVirtualDevice();
+}
+
+void FrameSelectorImpl::InitColors()
+{
+ const StyleSettings& rSett = mrFrameSel.GetSettings().GetStyleSettings();
+ maBackCol = rSett.GetFieldColor();
+ mbHCMode = rSett.GetHighContrastMode();
+ maArrowCol = rSett.GetFieldTextColor();
+ maMarkCol.operator=( maBackCol ).Merge( maArrowCol, mbHCMode ? 0x80 : 0xC0 );
+ maHCLineCol = rSett.GetLabelTextColor();
+}
+
+void FrameSelectorImpl::InitArrowImageList()
+{
+ /* Build the arrow images bitmap with current colors. */
+ Color pColorAry1[3];
+ Color pColorAry2[3];
+ pColorAry1[0] = Color( 0, 0, 0 );
+ pColorAry2[0] = maArrowCol; // black -> arrow color
+ pColorAry1[1] = Color( 0, 255, 0 );
+ pColorAry2[1] = maMarkCol; // green -> marker color
+ pColorAry1[2] = Color( 255, 0, 255 );
+ pColorAry2[2] = maBackCol; // magenta -> background
+
+ GetRes( SVX_RES( RID_SVXSTR_BORDER_CONTROL ).SetRT( RSC_RESOURCE ) );
+ maILArrows.InsertFromHorizontalBitmap(
+ SVX_RES( BMP_FRMSEL_ARROWS ), 16, NULL, pColorAry1, pColorAry2, 3);
+ FreeResource();
+ DBG_ASSERT( maILArrows.GetImageSize().Height() == maILArrows.GetImageSize().Width(),
+ "svx::FrameSelectorImpl::InitArrowImageList - images are not squarish" );
+ mnArrowSize = maILArrows.GetImageSize().Height();
+}
+
+void FrameSelectorImpl::InitGlobalGeometry()
+{
+ Size aCtrlSize( mrFrameSel.CalcOutputSize( mrFrameSel.GetSizePixel() ) );
+ /* nMinSize is the lower of width and height (control will always be squarish).
+ FRAMESEL_GEOM_OUTER is the minimal distance between inner control border
+ and any element. */
+ long nMinSize = Min( aCtrlSize.Width(), aCtrlSize.Height() ) - 2 * FRAMESEL_GEOM_OUTER;
+ /* nFixedSize is the size all existing elements need in one direction:
+ the diag. arrow, space betw. arrow and frame border, outer frame border,
+ inner frame border, other outer frame border, space betw. frame border
+ and arrow, the other arrow. */
+ long nFixedSize = 2 * mnArrowSize + 2 * FRAMESEL_GEOM_INNER + 3 * FRAMESEL_GEOM_WIDTH;
+ /* nBetwBordersSize contains the size between an outer and inner frame border (made odd). */
+ long nBetwBordersSize = (((nMinSize - nFixedSize) / 2) - 1) | 1;
+
+ /* The final size of the usable area. */
+ mnCtrlSize = 2 * nBetwBordersSize + nFixedSize;
+ maVirDev.SetOutputSizePixel( Size( mnCtrlSize, mnCtrlSize ) );
+
+ /* Center the virtual device in the control. */
+ maVirDevPos = Point( (aCtrlSize.Width() - mnCtrlSize) / 2, (aCtrlSize.Height() - mnCtrlSize) / 2 );
+}
+
+void FrameSelectorImpl::InitBorderGeometry()
+{
+ size_t nCol, nCols, nRow, nRows;
+
+ // Global border geometry values ------------------------------------------
+
+ /* mnLine* is the middle point inside a frame border (i.e. mnLine1 is mid X inside left border). */
+ mnLine1 = mnArrowSize + FRAMESEL_GEOM_INNER + FRAMESEL_GEOM_WIDTH / 2;
+ mnLine2 = mnCtrlSize / 2;
+ mnLine3 = 2 * mnLine2 - mnLine1;
+
+ // Frame helper array -----------------------------------------------------
+
+ maArray.Initialize( mbVer ? 2 : 1, mbHor ? 2 : 1 );
+ maArray.SetUseDiagDoubleClipping( true );
+
+ maArray.SetXOffset( mnLine1 );
+ maArray.SetAllColWidths( (mbVer ? mnLine2 : mnLine3) - mnLine1 );
+
+ maArray.SetYOffset( mnLine1 );
+ maArray.SetAllRowHeights( (mbHor ? mnLine2 : mnLine3) - mnLine1 );
+
+ Rectangle aTLRect( maArray.GetCellRect( 0, 0 ) );
+
+ // Focus polygons ---------------------------------------------------------
+
+ /* Width for focus rectangles from center of frame borders. */
+ mnFocusOffs = FRAMESEL_GEOM_WIDTH / 2 + 1;
+
+ maLeft.AddFocusPolygon( Rectangle( mnLine1 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine1 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
+ maVer.AddFocusPolygon( Rectangle( mnLine2 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine2 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
+ maRight.AddFocusPolygon( Rectangle( mnLine3 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
+ maTop.AddFocusPolygon( Rectangle( mnLine1 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine1 + mnFocusOffs ) );
+ maHor.AddFocusPolygon( Rectangle( mnLine1 - mnFocusOffs, mnLine2 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine2 + mnFocusOffs ) );
+ maBottom.AddFocusPolygon( Rectangle( mnLine1 - mnFocusOffs, mnLine3 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
+
+ for( nCol = 0, nCols = maArray.GetColCount(); nCol < nCols; ++nCol )
+ {
+ for( nRow = 0, nRows = maArray.GetRowCount(); nRow < nRows; ++nRow )
+ {
+ Rectangle aRect( maArray.GetCellRect( nCol, nRow ) );
+ long nDiagFocusOffsX = frame::GetTLDiagOffset( -mnFocusOffs, mnFocusOffs, maArray.GetHorDiagAngle( nCol, nRow ) );
+ long nDiagFocusOffsY = frame::GetTLDiagOffset( -mnFocusOffs, mnFocusOffs, maArray.GetVerDiagAngle( nCol, nRow ) );
+
+ std::vector< Point > aFocusVec;
+ aFocusVec.push_back( Point( aRect.Left() - mnFocusOffs, aRect.Top() + nDiagFocusOffsY ) );
+ aFocusVec.push_back( Point( aRect.Left() - mnFocusOffs, aRect.Top() - mnFocusOffs ) );
+ aFocusVec.push_back( Point( aRect.Left() + nDiagFocusOffsX, aRect.Top() - mnFocusOffs ) );
+ aFocusVec.push_back( Point( aRect.Right() + mnFocusOffs, aRect.Bottom() - nDiagFocusOffsY ) );
+ aFocusVec.push_back( Point( aRect.Right() + mnFocusOffs, aRect.Bottom() + mnFocusOffs ) );
+ aFocusVec.push_back( Point( aRect.Right() - nDiagFocusOffsX, aRect.Bottom() + mnFocusOffs ) );
+ maTLBR.AddFocusPolygon( Polygon( static_cast< USHORT >( aFocusVec.size() ), &aFocusVec[ 0 ] ) );
+
+ aFocusVec.clear();
+ aFocusVec.push_back( Point( aRect.Right() + mnFocusOffs, aRect.Top() + nDiagFocusOffsY ) );
+ aFocusVec.push_back( Point( aRect.Right() + mnFocusOffs, aRect.Top() - mnFocusOffs ) );
+ aFocusVec.push_back( Point( aRect.Right() - nDiagFocusOffsX, aRect.Top() - mnFocusOffs ) );
+ aFocusVec.push_back( Point( aRect.Left() - mnFocusOffs, aRect.Bottom() - nDiagFocusOffsY ) );
+ aFocusVec.push_back( Point( aRect.Left() - mnFocusOffs, aRect.Bottom() + mnFocusOffs ) );
+ aFocusVec.push_back( Point( aRect.Left() + nDiagFocusOffsX, aRect.Bottom() + mnFocusOffs ) );
+ maBLTR.AddFocusPolygon( Polygon( static_cast< USHORT >( aFocusVec.size() ), &aFocusVec[ 0 ] ) );
+ }
+ }
+
+ // Click areas ------------------------------------------------------------
+
+ for( FrameBorderIter aIt( maAllBorders ); aIt.Is(); ++aIt )
+ (*aIt)->ClearClickArea();
+
+ /* Additional space for click area: is added to the space available to draw
+ the frame borders. For instance left frame border:
+ - To left, top, and bottom always big additional space (outer area).
+ - To right: Dependent on existence of inner vertical frame border
+ (if enabled, use less space).
+ */
+ long nClO = FRAMESEL_GEOM_WIDTH / 2 + FRAMESEL_GEOM_ADD_CLICK_OUTER;
+ long nClI = (mbTLBR && mbBLTR) ? (FRAMESEL_GEOM_WIDTH / 2 + FRAMESEL_GEOM_ADD_CLICK_INNER) : nClO;
+ long nClH = mbHor ? nClI : nClO; // additional space dependent of horizontal inner border
+ long nClV = mbVer ? nClI : nClO; // additional space dependent of vertical inner border
+
+ maLeft.AddClickRect( Rectangle( mnLine1 - nClO, mnLine1 - nClO, mnLine1 + nClV, mnLine3 + nClO ) );
+ maVer.AddClickRect( Rectangle( mnLine2 - nClI, mnLine1 - nClO, mnLine2 + nClI, mnLine3 + nClO ) );
+ maRight.AddClickRect( Rectangle( mnLine3 - nClV, mnLine1 - nClO, mnLine3 + nClO, mnLine3 + nClO ) );
+ maTop.AddClickRect( Rectangle( mnLine1 - nClO, mnLine1 - nClO, mnLine3 + nClO, mnLine1 + nClH ) );
+ maHor.AddClickRect( Rectangle( mnLine1 - nClO, mnLine2 - nClI, mnLine3 + nClO, mnLine2 + nClI ) );
+ maBottom.AddClickRect( Rectangle( mnLine1 - nClO, mnLine3 - nClH, mnLine3 + nClO, mnLine3 + nClO ) );
+
+ /* Diagonal frame borders use the remaining space between outer and inner frame borders. */
+ if( mbTLBR || mbBLTR )
+ {
+ for( nCol = 0, nCols = maArray.GetColCount(); nCol < nCols; ++nCol )
+ {
+ for( nRow = 0, nRows = maArray.GetRowCount(); nRow < nRows; ++nRow )
+ {
+ // the usable area between horizonal/vertical frame borders of current quadrant
+ Rectangle aRect( maArray.GetCellRect( nCol, nRow ) );
+ aRect.Left() += nClV + 1;
+ aRect.Right() -= nClV + 1;
+ aRect.Top() += nClH + 1;
+ aRect.Bottom() -= nClH + 1;
+
+ /* Both diagonal frame borders enabled. */
+ if( mbTLBR && mbBLTR )
+ {
+ // single areas
+ Point aMid( aRect.Center() );
+ maTLBR.AddClickRect( Rectangle( aRect.TopLeft(), aMid ) );
+ maTLBR.AddClickRect( Rectangle( aMid + Point( 1, 1 ), aRect.BottomRight() ) );
+ maBLTR.AddClickRect( Rectangle( aRect.Left(), aMid.Y() + 1, aMid.X(), aRect.Bottom() ) );
+ maBLTR.AddClickRect( Rectangle( aMid.X() + 1, aRect.Top(), aRect.Right(), aMid.Y() ) );
+ // centered rectangle for both frame borders
+ Rectangle aMidRect( aRect.TopLeft(), Size( aRect.GetWidth() / 3, aRect.GetHeight() / 3 ) );
+ aMidRect.Move( (aRect.GetWidth() - aMidRect.GetWidth()) / 2, (aRect.GetHeight() - aMidRect.GetHeight()) / 2 );
+ maTLBR.AddClickRect( aMidRect );
+ maBLTR.AddClickRect( aMidRect );
+ }
+ /* One of the diagonal frame borders enabled - use entire rectangle. */
+ else if( mbTLBR && !mbBLTR ) // top-left to bottom-right only
+ maTLBR.AddClickRect( aRect );
+ else if( !mbTLBR && mbBLTR ) // bottom-left to top-right only
+ maBLTR.AddClickRect( aRect );
+ }
+ }
+ }
+}
+
+void FrameSelectorImpl::InitVirtualDevice()
+{
+ // initialize resources
+ InitColors();
+ InitArrowImageList();
+
+ // initialize geometry
+ InitGlobalGeometry();
+ InitBorderGeometry();
+
+ // correct background around the used area
+ mrFrameSel.SetBackground( Wallpaper( maBackCol ) );
+ DoInvalidate( true );
+}
+
+// frame border access --------------------------------------------------------
+
+const FrameBorder& FrameSelectorImpl::GetBorder( FrameBorderType eBorder ) const
+{
+ size_t nIndex = GetIndexFromFrameBorderType( eBorder );
+ if( nIndex < maAllBorders.size() )
+ return *maAllBorders[ nIndex ];
+ DBG_ERRORFILE( "svx::FrameSelectorImpl::GetBorder - unknown border type" );
+ return maTop;
+}
+
+FrameBorder& FrameSelectorImpl::GetBorderAccess( FrameBorderType eBorder )
+{
+ return const_cast< FrameBorder& >( GetBorder( eBorder ) );
+}
+
+// drawing --------------------------------------------------------------------
+
+void FrameSelectorImpl::DrawBackground()
+{
+ // clear the area
+ maVirDev.SetLineColor();
+ maVirDev.SetFillColor( maBackCol );
+ maVirDev.DrawRect( Rectangle( Point( 0, 0 ), maVirDev.GetOutputSizePixel() ) );
+
+ // draw the inner gray (or whatever color) rectangle
+ maVirDev.SetLineColor();
+ maVirDev.SetFillColor( maMarkCol );
+ maVirDev.DrawRect( Rectangle(
+ mnLine1 - mnFocusOffs, mnLine1 - mnFocusOffs, mnLine3 + mnFocusOffs, mnLine3 + mnFocusOffs ) );
+
+ // draw the white space for enabled frame borders
+ PolyPolygon aPPoly;
+ for( FrameBorderCIter aIt( maEnabBorders ); aIt.Is(); ++aIt )
+ (*aIt)->MergeFocusToPolyPolygon( aPPoly );
+ aPPoly.Optimize( POLY_OPTIMIZE_CLOSE );
+ maVirDev.SetLineColor( maBackCol );
+ maVirDev.SetFillColor( maBackCol );
+ maVirDev.DrawPolyPolygon( aPPoly );
+}
+
+void FrameSelectorImpl::DrawArrows( const FrameBorder& rBorder )
+{
+ DBG_ASSERT( rBorder.IsEnabled(), "svx::FrameSelectorImpl::DrawArrows - access to disabled border" );
+
+ long nLinePos = 0;
+ switch( rBorder.GetType() )
+ {
+ case FRAMEBORDER_LEFT:
+ case FRAMEBORDER_TOP: nLinePos = mnLine1; break;
+ case FRAMEBORDER_VER:
+ case FRAMEBORDER_HOR: nLinePos = mnLine2; break;
+ case FRAMEBORDER_RIGHT:
+ case FRAMEBORDER_BOTTOM: nLinePos = mnLine3; break;
+ default: ; //prevent warning
+ }
+ nLinePos -= mnArrowSize / 2;
+
+ long nTLPos = 0;
+ long nBRPos = mnCtrlSize - mnArrowSize;
+ Point aPos1, aPos2;
+ USHORT nImgId1 = 0, nImgId2 = 0;
+ switch( rBorder.GetType() )
+ {
+ case FRAMEBORDER_LEFT:
+ case FRAMEBORDER_RIGHT:
+ case FRAMEBORDER_VER:
+ aPos1 = Point( nLinePos, nTLPos ); nImgId1 = 1;
+ aPos2 = Point( nLinePos, nBRPos ); nImgId2 = 2;
+ break;
+
+ case FRAMEBORDER_TOP:
+ case FRAMEBORDER_BOTTOM:
+ case FRAMEBORDER_HOR:
+ aPos1 = Point( nTLPos, nLinePos ); nImgId1 = 3;
+ aPos2 = Point( nBRPos, nLinePos ); nImgId2 = 4;
+ break;
+
+ case FRAMEBORDER_TLBR:
+ aPos1 = Point( nTLPos, nTLPos ); nImgId1 = 5;
+ aPos2 = Point( nBRPos, nBRPos ); nImgId2 = 6;
+ break;
+ case FRAMEBORDER_BLTR:
+ aPos1 = Point( nTLPos, nBRPos ); nImgId1 = 7;
+ aPos2 = Point( nBRPos, nTLPos ); nImgId2 = 8;
+ break;
+ default: ; //prevent warning
+ }
+
+ // Arrow or marker? Do not draw arrows into disabled control.
+ USHORT nSelectAdd = (mrFrameSel.IsEnabled() && rBorder.IsSelected()) ? 0 : 8;
+ maVirDev.DrawImage( aPos1, maILArrows.GetImage( nImgId1 + nSelectAdd ) );
+ maVirDev.DrawImage( aPos2, maILArrows.GetImage( nImgId2 + nSelectAdd ) );
+}
+
+void FrameSelectorImpl::DrawAllArrows()
+{
+ for( FrameBorderCIter aIt( maEnabBorders ); aIt.Is(); ++aIt )
+ DrawArrows( **aIt );
+}
+
+Color FrameSelectorImpl::GetDrawLineColor( const Color& rColor ) const
+{
+ Color aColor( mbHCMode ? maHCLineCol : rColor );
+ if( aColor == maBackCol )
+ aColor.Invert();
+ return aColor;
+}
+
+void FrameSelectorImpl::DrawAllFrameBorders()
+{
+ // Translate core colors to current UI colors (regards current background and HC mode).
+ for( FrameBorderIter aIt( maEnabBorders ); aIt.Is(); ++aIt )
+ {
+ Color aCoreColor = ((*aIt)->GetState() == FRAMESTATE_DONTCARE) ? maMarkCol : (*aIt)->GetCoreStyle().GetColor();
+ (*aIt)->SetUIColor( GetDrawLineColor( aCoreColor ) );
+ }
+
+ // Copy all frame border styles to the helper array
+ maArray.SetColumnStyleLeft( 0, maLeft.GetUIStyle() );
+ if( mbVer ) maArray.SetColumnStyleLeft( 1, maVer.GetUIStyle() );
+
+ // Invert the style for the right line
+ const frame::Style rRightStyle = maRight.GetUIStyle( );
+ frame::Style rInvertedRight( rRightStyle.GetColor(),
+ rRightStyle.Secn(), rRightStyle.Dist(), rRightStyle.Prim( ),
+ rRightStyle.Dashing( ) );
+ maArray.SetColumnStyleRight( mbVer ? 1 : 0, rInvertedRight );
+
+ maArray.SetRowStyleTop( 0, maTop.GetUIStyle() );
+ if( mbHor )
+ {
+ // Invert the style for the hor line to match the real borders
+ const frame::Style rHorStyle = maHor.GetUIStyle();
+ frame::Style rInvertedHor( rHorStyle.GetColor(),
+ rHorStyle.Secn(), rHorStyle.Dist(), rHorStyle.Prim( ),
+ rHorStyle.Dashing() );
+ maArray.SetRowStyleTop( 1, rInvertedHor );
+ }
+
+ // Invert the style for the bottom line
+ const frame::Style rBottomStyle = maBottom.GetUIStyle( );
+ frame::Style rInvertedBottom( rBottomStyle.GetColor(),
+ rBottomStyle.Secn(), rBottomStyle.Dist(), rBottomStyle.Prim( ),
+ rBottomStyle.Dashing() );
+ maArray.SetRowStyleBottom( mbHor ? 1 : 0, rInvertedBottom );
+
+ for( size_t nCol = 0; nCol < maArray.GetColCount(); ++nCol )
+ for( size_t nRow = 0; nRow < maArray.GetRowCount(); ++nRow )
+ maArray.SetCellStyleDiag( nCol, nRow, maTLBR.GetUIStyle(), maBLTR.GetUIStyle() );
+
+ // Let the helper array draw itself
+ maArray.DrawArray( maVirDev );
+}
+
+void FrameSelectorImpl::DrawVirtualDevice()
+{
+ DrawBackground();
+ DrawAllArrows();
+ DrawAllFrameBorders();
+ mbFullRepaint = false;
+}
+
+void FrameSelectorImpl::CopyVirDevToControl()
+{
+ if( mbFullRepaint )
+ DrawVirtualDevice();
+ mrFrameSel.DrawBitmap( maVirDevPos, maVirDev.GetBitmap( Point( 0, 0 ), maVirDev.GetOutputSizePixel() ) );
+}
+
+void FrameSelectorImpl::DrawAllTrackingRects()
+{
+ PolyPolygon aPPoly;
+ if( mrFrameSel.IsAnyBorderSelected() )
+ {
+ for( SelFrameBorderCIter aIt( maEnabBorders ); aIt.Is(); ++aIt )
+ (*aIt)->MergeFocusToPolyPolygon( aPPoly );
+ aPPoly.Move( maVirDevPos.X(), maVirDevPos.Y() );
+ }
+ else
+ // no frame border selected -> draw tracking rectangle around entire control
+ aPPoly.Insert( Polygon( Rectangle( maVirDevPos, maVirDev.GetOutputSizePixel() ) ) );
+
+ aPPoly.Optimize( POLY_OPTIMIZE_CLOSE );
+ for( USHORT nIdx = 0, nCount = aPPoly.Count(); nIdx < nCount; ++nIdx )
+ mrFrameSel.InvertTracking( aPPoly.GetObject( nIdx ), SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+}
+
+Point FrameSelectorImpl::GetDevPosFromMousePos( const Point& rMousePos ) const
+{
+ return rMousePos - maVirDevPos;
+}
+
+void FrameSelectorImpl::DoInvalidate( bool bFullRepaint )
+{
+ mbFullRepaint |= bFullRepaint;
+ mrFrameSel.Invalidate( INVALIDATE_NOERASE );
+}
+
+// frame border state and style -----------------------------------------------
+
+void FrameSelectorImpl::SetBorderState( FrameBorder& rBorder, FrameBorderState eState )
+{
+ DBG_ASSERT( rBorder.IsEnabled(), "svx::FrameSelectorImpl::SetBorderState - access to disabled border" );
+ if( eState == FRAMESTATE_SHOW )
+ SetBorderCoreStyle( rBorder, &maCurrStyle );
+ else
+ rBorder.SetState( eState );
+ DoInvalidate( true );
+}
+
+void FrameSelectorImpl::SetBorderCoreStyle( FrameBorder& rBorder, const SvxBorderLine* pStyle )
+{
+ DBG_ASSERT( rBorder.IsEnabled(), "svx::FrameSelectorImpl::SetBorderCoreStyle - access to disabled border" );
+ rBorder.SetCoreStyle( pStyle );
+ DoInvalidate( true );
+}
+
+void FrameSelectorImpl::ToggleBorderState( FrameBorder& rBorder )
+{
+ bool bDontCare = mrFrameSel.SupportsDontCareState();
+ switch( rBorder.GetState() )
+ {
+ // same order as tristate check box: visible -> don't care -> hidden
+ case FRAMESTATE_SHOW:
+ SetBorderState( rBorder, bDontCare ? FRAMESTATE_DONTCARE : FRAMESTATE_HIDE );
+ break;
+ case FRAMESTATE_HIDE:
+ SetBorderState( rBorder, FRAMESTATE_SHOW );
+ break;
+ case FRAMESTATE_DONTCARE:
+ SetBorderState( rBorder, FRAMESTATE_HIDE );
+ break;
+ }
+}
+
+// frame border selection -----------------------------------------------------
+
+void FrameSelectorImpl::SelectBorder( FrameBorder& rBorder, bool bSelect )
+{
+ DBG_ASSERT( rBorder.IsEnabled(), "svx::FrameSelectorImpl::SelectBorder - access to disabled border" );
+ rBorder.Select( bSelect );
+ DrawArrows( rBorder );
+ DoInvalidate( false );
+ maSelectHdl.Call( this );
+}
+
+void FrameSelectorImpl::SilentGrabFocus()
+{
+ bool bOldAuto = mbAutoSelect;
+ mbAutoSelect = false;
+ mrFrameSel.GrabFocus();
+ mbAutoSelect = bOldAuto;
+}
+
+bool FrameSelectorImpl::SelectedBordersEqual() const
+{
+ bool bEqual = true;
+ SelFrameBorderCIter aIt( maEnabBorders );
+ if( aIt.Is() )
+ {
+ const SvxBorderLine& rFirstStyle = (*aIt)->GetCoreStyle();
+ for( ++aIt; bEqual && aIt.Is(); ++aIt )
+ bEqual = ((*aIt)->GetCoreStyle() == rFirstStyle);
+ }
+ return bEqual;
+}
+
+// ============================================================================
+// FrameSelector
+// ============================================================================
+
+FrameSelector::FrameSelector( Window* pParent, const ResId& rResId ) :
+ Control( pParent, rResId )
+{
+ // not in c'tor init list (avoid warning about usage of *this)
+ mxImpl.reset( new FrameSelectorImpl( *this ) );
+ EnableRTL( false ); // #107808# don't mirror the mouse handling
+}
+
+FrameSelector::~FrameSelector()
+{
+}
+
+void FrameSelector::Initialize( FrameSelFlags nFlags )
+{
+ mxImpl->Initialize( nFlags );
+ Show();
+}
+
+// enabled frame borders ------------------------------------------------------
+
+bool FrameSelector::IsBorderEnabled( FrameBorderType eBorder ) const
+{
+ return mxImpl->GetBorder( eBorder ).IsEnabled();
+}
+
+sal_Int32 FrameSelector::GetEnabledBorderCount() const
+{
+ return static_cast< sal_Int32 >( mxImpl->maEnabBorders.size() );
+}
+
+FrameBorderType FrameSelector::GetEnabledBorderType( sal_Int32 nIndex ) const
+{
+ FrameBorderType eBorder = FRAMEBORDER_NONE;
+ if( nIndex >= 0 )
+ {
+ size_t nVecIdx = static_cast< size_t >( nIndex );
+ if( nVecIdx < mxImpl->maEnabBorders.size() )
+ eBorder = mxImpl->maEnabBorders[ nVecIdx ]->GetType();
+ }
+ return eBorder;
+}
+
+sal_Int32 FrameSelector::GetEnabledBorderIndex( FrameBorderType eBorder ) const
+{
+ sal_Int32 nIndex = 0;
+ for( FrameBorderCIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt, ++nIndex )
+ if( (*aIt)->GetType() == eBorder )
+ return nIndex;
+ return -1;
+}
+
+// frame border state and style -----------------------------------------------
+
+bool FrameSelector::SupportsDontCareState() const
+{
+ return (mxImpl->mnFlags & FRAMESEL_DONTCARE) != 0;
+}
+
+FrameBorderState FrameSelector::GetFrameBorderState( FrameBorderType eBorder ) const
+{
+ return mxImpl->GetBorder( eBorder ).GetState();
+}
+
+const SvxBorderLine* FrameSelector::GetFrameBorderStyle( FrameBorderType eBorder ) const
+{
+ const SvxBorderLine& rStyle = mxImpl->GetBorder( eBorder ).GetCoreStyle();
+ // rest of the world uses null pointer for invisible frame border
+ return rStyle.GetOutWidth() ? &rStyle : 0;
+}
+
+void FrameSelector::ShowBorder( FrameBorderType eBorder, const SvxBorderLine* pStyle )
+{
+ mxImpl->SetBorderCoreStyle( mxImpl->GetBorderAccess( eBorder ), pStyle );
+}
+
+void FrameSelector::SetBorderDontCare( FrameBorderType eBorder )
+{
+ mxImpl->SetBorderState( mxImpl->GetBorderAccess( eBorder ), FRAMESTATE_DONTCARE );
+}
+
+bool FrameSelector::IsAnyBorderVisible() const
+{
+ bool bIsSet = false;
+ for( FrameBorderCIter aIt( mxImpl->maEnabBorders ); !bIsSet && aIt.Is(); ++aIt )
+ bIsSet = ((*aIt)->GetState() == FRAMESTATE_SHOW);
+ return bIsSet;
+}
+
+void FrameSelector::HideAllBorders()
+{
+ for( FrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
+ mxImpl->SetBorderState( **aIt, FRAMESTATE_HIDE );
+}
+
+bool FrameSelector::GetVisibleWidth( USHORT& rnPrim, USHORT& rnDist, USHORT& rnSecn,
+ SvxBorderStyle& rnStyle ) const
+{
+ VisFrameBorderCIter aIt( mxImpl->maEnabBorders );
+ if( !aIt.Is() )
+ return false;
+
+ const SvxBorderLine& rStyle = (*aIt)->GetCoreStyle();
+ bool bFound = true;
+ for( ++aIt; bFound && aIt.Is(); ++aIt )
+ bFound =
+ (rStyle.GetOutWidth() == (*aIt)->GetCoreStyle().GetOutWidth()) &&
+ (rStyle.GetDistance() == (*aIt)->GetCoreStyle().GetDistance()) &&
+ (rStyle.GetInWidth() == (*aIt)->GetCoreStyle().GetInWidth()) &&
+ (rStyle.GetStyle() == (*aIt)->GetCoreStyle().GetStyle());
+
+ if( bFound )
+ {
+ rnPrim = rStyle.GetOutWidth();
+ rnDist = rStyle.GetDistance();
+ rnSecn = rStyle.GetInWidth();
+ rnStyle = rStyle.GetStyle();
+ }
+ return bFound;
+}
+
+bool FrameSelector::GetVisibleColor( Color& rColor ) const
+{
+ VisFrameBorderCIter aIt( mxImpl->maEnabBorders );
+ if( !aIt.Is() )
+ return false;
+
+ const SvxBorderLine& rStyle = (*aIt)->GetCoreStyle();
+ bool bFound = true;
+ for( ++aIt; bFound && aIt.Is(); ++aIt )
+ bFound = (rStyle.GetColor() == (*aIt)->GetCoreStyle().GetColor());
+
+ if( bFound )
+ rColor = rStyle.GetColor();
+ return bFound;
+}
+
+// frame border selection -----------------------------------------------------
+
+const Link& FrameSelector::GetSelectHdl() const
+{
+ return mxImpl->maSelectHdl;
+}
+
+void FrameSelector::SetSelectHdl( const Link& rHdl )
+{
+ mxImpl->maSelectHdl = rHdl;
+}
+
+bool FrameSelector::IsBorderSelected( FrameBorderType eBorder ) const
+{
+ return mxImpl->GetBorder( eBorder ).IsSelected();
+}
+
+void FrameSelector::SelectBorder( FrameBorderType eBorder, bool bSelect )
+{
+ mxImpl->SelectBorder( mxImpl->GetBorderAccess( eBorder ), bSelect );
+}
+
+bool FrameSelector::IsAnyBorderSelected() const
+{
+ // Construct an iterator for selected borders. If it is valid, there is a selected border.
+ return SelFrameBorderCIter( mxImpl->maEnabBorders ).Is();
+}
+
+void FrameSelector::SelectAllBorders( bool bSelect )
+{
+ for( FrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
+ mxImpl->SelectBorder( **aIt, bSelect );
+}
+
+void FrameSelector::SelectAllVisibleBorders( bool bSelect )
+{
+ for( VisFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
+ mxImpl->SelectBorder( **aIt, bSelect );
+}
+
+void FrameSelector::SetStyleToSelection( USHORT nPrim, USHORT nDist, USHORT nSecn,
+ SvxBorderStyle nStyle )
+{
+ mxImpl->maCurrStyle.SetOutWidth( nPrim );
+ mxImpl->maCurrStyle.SetDistance( nDist );
+ mxImpl->maCurrStyle.SetInWidth( nSecn );
+ mxImpl->maCurrStyle.SetStyle( nStyle );
+ for( SelFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
+ mxImpl->SetBorderState( **aIt, FRAMESTATE_SHOW );
+}
+
+void FrameSelector::SetColorToSelection( const Color& rColor )
+{
+ mxImpl->maCurrStyle.SetColor( rColor );
+ for( SelFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
+ mxImpl->SetBorderState( **aIt, FRAMESTATE_SHOW );
+}
+
+// accessibility --------------------------------------------------------------
+
+Reference< XAccessible > FrameSelector::CreateAccessible()
+{
+ if( !mxImpl->mxAccess.is() )
+ mxImpl->mxAccess = mxImpl->mpAccess =
+ new a11y::AccFrameSelector( *this, FRAMEBORDER_NONE );
+ return mxImpl->mxAccess;
+}
+
+Reference< XAccessible > FrameSelector::GetChildAccessible( FrameBorderType eBorder )
+{
+ Reference< XAccessible > xRet;
+ size_t nVecIdx = static_cast< size_t >( eBorder );
+ if( IsBorderEnabled( eBorder ) && (1 <= nVecIdx) && (nVecIdx <= mxImpl->maChildVec.size()) )
+ {
+ --nVecIdx;
+ if( !mxImpl->maChildVec[ nVecIdx ] )
+ mxImpl->mxChildVec[ nVecIdx ] = mxImpl->maChildVec[ nVecIdx ] =
+ new a11y::AccFrameSelector( *this, eBorder );
+ xRet = mxImpl->mxChildVec[ nVecIdx ];
+ }
+ return xRet;
+}
+
+Reference< XAccessible > FrameSelector::GetChildAccessible( sal_Int32 nIndex )
+{
+ return GetChildAccessible( GetEnabledBorderType( nIndex ) );
+}
+
+Reference< XAccessible > FrameSelector::GetChildAccessible( const Point& rPos )
+{
+ Reference< XAccessible > xRet;
+ for( FrameBorderCIter aIt( mxImpl->maEnabBorders ); !xRet.is() && aIt.Is(); ++aIt )
+ if( (*aIt)->ContainsClickPoint( rPos ) )
+ xRet = GetChildAccessible( (*aIt)->GetType() );
+ return xRet;
+}
+
+bool FrameSelector::ContainsClickPoint( const Point& rPos ) const
+{
+ bool bContains = false;
+ for( FrameBorderCIter aIt( mxImpl->maEnabBorders ); !bContains && aIt.Is(); ++aIt )
+ bContains = (*aIt)->ContainsClickPoint( rPos );
+ return bContains;
+}
+
+Rectangle FrameSelector::GetClickBoundRect( FrameBorderType eBorder ) const
+{
+ Rectangle aRect;
+ const FrameBorder& rBorder = mxImpl->GetBorder( eBorder );
+ if( rBorder.IsEnabled() )
+ aRect = rBorder.GetClickBoundRect();
+ return aRect;
+}
+
+// virtual functions from base class ------------------------------------------
+
+void FrameSelector::Paint( const Rectangle& )
+{
+ mxImpl->CopyVirDevToControl();
+ if( HasFocus() )
+ mxImpl->DrawAllTrackingRects();
+}
+
+void FrameSelector::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ /* Mouse handling:
+ * Click on an unselected frame border:
+ Set current style/color, make frame border visible, deselect all
+ other frame borders.
+ * Click on a selected frame border:
+ Toggle state of the frame border (visible -> don't care -> hidden),
+ deselect all other frame borders.
+ * SHIFT+Click or CTRL+Click on an unselected frame border:
+ Extend selection, set current style/color to all selected frame
+ borders independent of the state/style/color of the borders.
+ * SHIFT+Click or CTRL+Click on a selected frame border:
+ If all frame borders have same style/color, toggle state of all
+ borders (see above), otherwise set current style/color to all
+ borders.
+ * Click on unused area: Do not modify selection and selected frame
+ borders.
+ */
+
+ // #107394# do not auto-select a frame border
+ mxImpl->SilentGrabFocus();
+
+ if( rMEvt.IsLeft() )
+ {
+ Point aPos( mxImpl->GetDevPosFromMousePos( rMEvt.GetPosPixel() ) );
+ FrameBorderPtrVec aDeselectBorders;
+
+ bool bAnyClicked = false; // Any frame border clicked?
+ bool bNewSelected = false; // Any unselected frame border selected?
+
+ /* If frame borders are set to "don't care" and the control does not
+ support this state, hide them on first mouse click.
+ DR 2004-01-30: Why are the borders set to "don't care" then?!? */
+ bool bHideDontCare = !mxImpl->mbClicked && !SupportsDontCareState();
+
+ for( FrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
+ {
+ if( (*aIt)->ContainsClickPoint( aPos ) )
+ {
+ // frame border is clicked
+ bAnyClicked = true;
+ if( !(*aIt)->IsSelected() )
+ {
+ bNewSelected = true;
+ mxImpl->SelectBorder( **aIt, true );
+ }
+ }
+ else
+ {
+ // hide a "don't care" frame border only if it is not clicked
+ if( bHideDontCare && ((*aIt)->GetState() == FRAMESTATE_DONTCARE) )
+ mxImpl->SetBorderState( **aIt, FRAMESTATE_HIDE );
+
+ // deselect frame borders not clicked (if SHIFT or CTRL are not pressed)
+ if( !rMEvt.IsShift() && !rMEvt.IsMod1() )
+ aDeselectBorders.push_back( *aIt );
+ }
+ }
+
+ if( bAnyClicked )
+ {
+ // any valid frame border clicked? -> deselect other frame borders
+ for( FrameBorderIter aIt( aDeselectBorders ); aIt.Is(); ++aIt )
+ mxImpl->SelectBorder( **aIt, false );
+
+ if( bNewSelected || !mxImpl->SelectedBordersEqual() )
+ {
+ // new frame border selected, selection extended, or selected borders different? -> show
+ for( SelFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
+ // SetBorderState() sets current style and color to the frame border
+ mxImpl->SetBorderState( **aIt, FRAMESTATE_SHOW );
+ }
+ else
+ {
+ // all selected frame borders are equal -> toggle state
+ for( SelFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
+ mxImpl->ToggleBorderState( **aIt );
+ }
+ }
+ }
+}
+
+void FrameSelector::KeyInput( const KeyEvent& rKEvt )
+{
+ bool bHandled = false;
+ KeyCode aKeyCode = rKEvt.GetKeyCode();
+ if( !aKeyCode.GetModifier() )
+ {
+ USHORT nCode = aKeyCode.GetCode();
+ switch( nCode )
+ {
+ case KEY_SPACE:
+ {
+ for( SelFrameBorderIter aIt( mxImpl->maEnabBorders ); aIt.Is(); ++aIt )
+ mxImpl->ToggleBorderState( **aIt );
+ bHandled = true;
+ }
+ break;
+
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ {
+ if( !mxImpl->maEnabBorders.empty() )
+ {
+ // start from first selected frame border
+ SelFrameBorderCIter aIt( mxImpl->maEnabBorders );
+ FrameBorderType eBorder = aIt.Is() ? (*aIt)->GetType() : mxImpl->maEnabBorders.front()->GetType();
+
+ // search for next enabled frame border
+ do
+ {
+ eBorder = mxImpl->GetBorder( eBorder ).GetKeyboardNeighbor( nCode );
+ }
+ while( (eBorder != FRAMEBORDER_NONE) && !IsBorderEnabled( eBorder ) );
+
+ // select the frame border
+ if( eBorder != FRAMEBORDER_NONE )
+ {
+ DeselectAllBorders();
+ SelectBorder( eBorder );
+ }
+ }
+ }
+ break;
+ }
+ }
+ if( !bHandled )
+ Window::KeyInput(rKEvt);
+}
+
+void FrameSelector::GetFocus()
+{
+ // auto-selection of a frame border, if focus reaches control, and nothing is selected
+ if( mxImpl->mbAutoSelect && !IsAnyBorderSelected() && !mxImpl->maEnabBorders.empty() )
+ mxImpl->SelectBorder( *mxImpl->maEnabBorders.front(), true );
+
+ mxImpl->DoInvalidate( false );
+ if( mxImpl->mxAccess.is() )
+ mxImpl->mpAccess->NotifyFocusListeners( sal_True );
+ Control::GetFocus();
+}
+
+void FrameSelector::LoseFocus()
+{
+ mxImpl->DoInvalidate( false );
+ if( mxImpl->mxAccess.is() )
+ mxImpl->mpAccess->NotifyFocusListeners( sal_False );
+ Control::LoseFocus();
+}
+
+void FrameSelector::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Control::DataChanged( rDCEvt );
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ mxImpl->InitVirtualDevice();
+}
+
+// ============================================================================
+
+template< typename Cont, typename Iter, typename Pred >
+FrameBorderIterBase< Cont, Iter, Pred >::FrameBorderIterBase( container_type& rCont ) :
+ maIt( rCont.begin() ),
+ maEnd( rCont.end() )
+{
+ while( Is() && !maPred( *maIt ) ) ++maIt;
+}
+
+template< typename Cont, typename Iter, typename Pred >
+FrameBorderIterBase< Cont, Iter, Pred >& FrameBorderIterBase< Cont, Iter, Pred >::operator++()
+{
+ do { ++maIt; } while( Is() && !maPred( *maIt ) );
+ return *this;
+}
+
+// ============================================================================
+
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/frmsel.src b/svx/source/dialog/frmsel.src
new file mode 100644
index 000000000000..4f85f5eff9eb
--- /dev/null
+++ b/svx/source/dialog/frmsel.src
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * 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 _SVX_DIALOGS_HRC
+#include <svx/dialogs.hrc>
+#endif
+#ifndef SVX_FRMSEL_HRC
+#include "frmsel.hrc"
+#endif
+
+Resource RID_SVXSTR_BORDER_CONTROL
+{
+ StringArray ARR_TEXTS
+ {
+ ItemList [ en-US ] =
+ {
+ < "Border setting" ; 0; > ;
+ < "Left border line" ; 1; > ;
+ < "Right border line" ; 2; > ;
+ < "Top border line" ; 3; > ;
+ < "Bottom border line" ; 4; > ;
+ < "Horizontal border line" ; 5; > ;
+ < "Vertical border line" ; 6; > ;
+ < "Diagonal border line from top left to bottom right" ; 7; > ;
+ < "Diagonal border line from bottom left to top right" ; 8; > ;
+ };
+ };
+ StringArray ARR_DESCRIPTIONS
+ {
+ ItemList [ en-US ] =
+ {
+ < "Border setting" ; 0; > ;
+ < "Left border line" ; 1; > ;
+ < "Right border line" ; 2; > ;
+ < "Top border line" ; 3; > ;
+ < "Bottom border line" ; 4; > ;
+ < "Horizontal border line" ; 5; > ;
+ < "Vertical border line" ; 6; > ;
+ < "Diagonal border line from top left to bottom right" ; 7; > ;
+ < "Diagonal border line from bottom left to top right" ; 8; > ;
+ };
+ };
+
+ Bitmap BMP_FRMSEL_ARROWS { File = "frmsel.bmp"; };
+};
+
diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx
new file mode 100644
index 000000000000..c970269d67bd
--- /dev/null
+++ b/svx/source/dialog/graphctl.cxx
@@ -0,0 +1,961 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svl/itempool.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/wrkwin.hxx>
+#include <unotools/syslocale.hxx>
+#include <rtl/math.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+
+#include <svx/graphctl.hxx>
+#include "GraphCtlAccessibleContext.hxx"
+#include "xoutbmp.hxx"
+#include <svx/svxids.hrc>
+#include <svx/svdpage.hxx>
+
+// #i72889#
+#include "sdrpaintwindow.hxx"
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrlUserCall::Changed( const SdrObject& rObj, SdrUserCallType eType, const Rectangle& /*rOldBoundRect*/ )
+{
+ switch( eType )
+ {
+ case( SDRUSERCALL_MOVEONLY ):
+ case( SDRUSERCALL_RESIZE ):
+ rWin.SdrObjChanged( rObj );
+ break;
+
+ case( SDRUSERCALL_INSERTED ):
+ rWin.SdrObjCreated( rObj );
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+GraphCtrl::GraphCtrl( Window* pParent, const WinBits nWinBits ) :
+ Control ( pParent, nWinBits ),
+ aMap100 ( MAP_100TH_MM ),
+ eObjKind ( OBJ_NONE ),
+ nPolyEdit ( 0 ),
+ bEditMode ( FALSE ),
+ bSdrMode ( FALSE ),
+ mpAccContext ( NULL ),
+ pModel ( NULL ),
+ pView ( NULL )
+{
+ pUserCall = new GraphCtrlUserCall( *this );
+ aUpdateTimer.SetTimeout( 200 );
+ aUpdateTimer.SetTimeoutHdl( LINK( this, GraphCtrl, UpdateHdl ) );
+ aUpdateTimer.Start();
+
+ SetWinStyle( nWinBits );
+
+ EnableRTL( FALSE );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+GraphCtrl::GraphCtrl( Window* pParent, const ResId& rResId ) :
+ Control ( pParent, rResId ),
+ aMap100 ( MAP_100TH_MM ),
+ nWinStyle ( 0 ),
+ eObjKind ( OBJ_NONE ),
+ nPolyEdit ( 0 ),
+ bEditMode ( FALSE ),
+ bSdrMode ( FALSE ),
+ bAnim ( FALSE ),
+ mpAccContext ( NULL ),
+ pModel ( NULL ),
+ pView ( NULL )
+{
+ pUserCall = new GraphCtrlUserCall( *this );
+ aUpdateTimer.SetTimeout( 500 );
+ aUpdateTimer.SetTimeoutHdl( LINK( this, GraphCtrl, UpdateHdl ) );
+ aUpdateTimer.Start();
+ EnableRTL( FALSE );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+GraphCtrl::~GraphCtrl()
+{
+ if( mpAccContext )
+ {
+ mpAccContext->disposing();
+ mpAccContext->release();
+ }
+ delete pView;
+ delete pModel;
+ delete pUserCall;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::SetWinStyle( WinBits nWinBits )
+{
+ nWinStyle = nWinBits;
+ bAnim = ( nWinStyle & WB_ANIMATION ) == WB_ANIMATION;
+ bSdrMode = ( nWinStyle & WB_SDRMODE ) == WB_SDRMODE;
+
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ SetBackground( Wallpaper( rStyleSettings.GetWindowColor() ) );
+ SetMapMode( aMap100 );
+
+ delete pView;
+ pView = NULL;
+
+ delete pModel;
+ pModel = NULL;
+
+ if ( bSdrMode )
+ InitSdrModel();
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::InitSdrModel()
+{
+ SolarMutexGuard aGuard;
+
+ SdrPage* pPage;
+
+ // alten Kram zerstoeren
+ delete pView;
+ delete pModel;
+
+ // Model anlegen
+ pModel = new SdrModel;
+ pModel->GetItemPool().FreezeIdRanges();
+ pModel->SetScaleUnit( aMap100.GetMapUnit() );
+ pModel->SetScaleFraction( Fraction( 1, 1 ) );
+ pModel->SetDefaultFontHeight( 500 );
+
+ pPage = new SdrPage( *pModel );
+
+ pPage->SetSize( aGraphSize );
+ pPage->SetBorder( 0, 0, 0, 0 );
+ pModel->InsertPage( pPage );
+ pModel->SetChanged( sal_False );
+
+ // View anlegen
+ pView = new GraphCtrlView( pModel, this );
+ pView->SetWorkArea( Rectangle( Point(), aGraphSize ) );
+ pView->EnableExtendedMouseEventDispatcher( TRUE );
+ pView->ShowSdrPage(pView->GetModel()->GetPage(0));
+// pView->ShowSdrPage(pView->GetModel()->GetPage(0));
+ pView->SetFrameDragSingles( TRUE );
+ pView->SetMarkedPointsSmooth( SDRPATHSMOOTH_SYMMETRIC );
+ pView->SetEditMode( TRUE );
+
+ // #i72889# set neeeded flags
+ pView->SetPagePaintingAllowed(false);
+ pView->SetBufferedOutputAllowed(true);
+ pView->SetBufferedOverlayAllowed(true);
+
+ // Tell the accessibility object about the changes.
+ if (mpAccContext != NULL)
+ mpAccContext->setModelAndView (pModel, pView);
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::SetGraphic( const Graphic& rGraphic, BOOL bNewModel )
+{
+ // Bitmaps dithern wir ggf. fuer die Anzeige
+ if ( !bAnim && ( rGraphic.GetType() == GRAPHIC_BITMAP ) )
+ {
+ if ( rGraphic.IsTransparent() )
+ {
+ Bitmap aBmp( rGraphic.GetBitmap() );
+
+ DitherBitmap( aBmp );
+ aGraphic = Graphic( BitmapEx( aBmp, rGraphic.GetBitmapEx().GetMask() ) );
+ }
+ else
+ {
+ Bitmap aBmp( rGraphic.GetBitmap() );
+ DitherBitmap( aBmp );
+ aGraphic = aBmp;
+ }
+ }
+ else
+ aGraphic = rGraphic;
+
+ if ( aGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
+ aGraphSize = Application::GetDefaultDevice()->PixelToLogic( aGraphic.GetPrefSize(), aMap100 );
+ else
+ aGraphSize = OutputDevice::LogicToLogic( aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), aMap100 );
+
+ if ( bSdrMode && bNewModel )
+ InitSdrModel();
+
+ if ( aGraphSizeLink.IsSet() )
+ aGraphSizeLink.Call( this );
+
+ Resize();
+ Invalidate();
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::Resize()
+{
+ Control::Resize();
+
+ if ( aGraphSize.Width() && aGraphSize.Height() )
+ {
+ MapMode aDisplayMap( aMap100 );
+ Point aNewPos;
+ Size aNewSize;
+ const Size aWinSize = PixelToLogic( GetOutputSizePixel(), aDisplayMap );
+ const long nWidth = aWinSize.Width();
+ const long nHeight = aWinSize.Height();
+ double fGrfWH = (double) aGraphSize.Width() / aGraphSize.Height();
+ double fWinWH = (double) nWidth / nHeight;
+
+ // Bitmap an Thumbgroesse anpassen
+ if ( fGrfWH < fWinWH)
+ {
+ aNewSize.Width() = (long) ( (double) nHeight * fGrfWH );
+ aNewSize.Height()= nHeight;
+ }
+ else
+ {
+ aNewSize.Width() = nWidth;
+ aNewSize.Height()= (long) ( (double) nWidth / fGrfWH );
+ }
+
+ aNewPos.X() = ( nWidth - aNewSize.Width() ) >> 1;
+ aNewPos.Y() = ( nHeight - aNewSize.Height() ) >> 1;
+
+ // MapMode fuer Engine umsetzen
+ aDisplayMap.SetScaleX( Fraction( aNewSize.Width(), aGraphSize.Width() ) );
+ aDisplayMap.SetScaleY( Fraction( aNewSize.Height(), aGraphSize.Height() ) );
+
+ aDisplayMap.SetOrigin( LogicToLogic( aNewPos, aMap100, aDisplayMap ) );
+ SetMapMode( aDisplayMap );
+ }
+
+ Invalidate();
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::Paint( const Rectangle& rRect )
+{
+ // #i72889# used splitted repaint to be able to paint an own background
+ // even to the buffered view
+ const bool bGraphicValid(GRAPHIC_NONE != aGraphic.GetType());
+
+ if(bSdrMode)
+ {
+ SdrPaintWindow* pPaintWindow = pView->BeginCompleteRedraw(this);
+
+ if(bGraphicValid)
+ {
+ OutputDevice& rTarget = pPaintWindow->GetTargetOutputDevice();
+
+ rTarget.SetBackground(GetBackground());
+ rTarget.Erase();
+
+ aGraphic.Draw(&rTarget, Point(), aGraphSize);
+ }
+
+ const Region aRepaintRegion(rRect);
+ pView->DoCompleteRedraw(*pPaintWindow, aRepaintRegion);
+ pView->EndCompleteRedraw(*pPaintWindow, true);
+ }
+ else
+ {
+ // #i73381# in non-SdrMode, paint to local directly
+ if(bGraphicValid)
+ {
+ aGraphic.Draw(this, Point(), aGraphSize);
+ }
+ }
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::SdrObjChanged( const SdrObject& )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::SdrObjCreated( const SdrObject& )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::MarkListHasChanged()
+{
+ if ( aMarkObjLink.IsSet() )
+ aMarkObjLink.Call( this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyCode aCode( rKEvt.GetKeyCode() );
+ BOOL bProc = FALSE;
+
+ switch ( aCode.GetCode() )
+ {
+ case KEY_DELETE:
+ case KEY_BACKSPACE:
+ {
+ if ( bSdrMode )
+ {
+ pView->DeleteMarked();
+ bProc = TRUE;
+ if( !pView->AreObjectsMarked() )
+ ((Dialog*)GetParent())->GrabFocusToFirstControl();
+ }
+ }
+ break;
+
+ case KEY_ESCAPE:
+ {
+ if ( bSdrMode )
+ {
+ if ( pView->IsAction() )
+ {
+ pView->BrkAction();
+ }
+ else if ( pView->AreObjectsMarked() )
+ {
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if(pHdl)
+ {
+ ((SdrHdlList&)rHdlList).ResetFocusHdl();
+ }
+ else
+ {
+ ((Dialog*)GetParent())->GrabFocusToFirstControl();
+ }
+ }
+ else
+ {
+ ((Dialog*)GetParent())->GrabFocusToFirstControl();
+ }
+ bProc = TRUE;
+ }
+ }
+ break;
+
+ case KEY_F11:
+ case KEY_TAB:
+ {
+ if( bSdrMode )
+ {
+ if( !aCode.IsMod1() && !aCode.IsMod2() )
+ {
+ bool bForward = !aCode.IsShift();
+ // select next object
+ if ( ! pView->MarkNextObj( bForward ))
+ {
+ // At first or last object. Cycle to the other end
+ // of the list.
+ pView->UnmarkAllObj();
+ pView->MarkNextObj (bForward);
+ }
+ bProc = TRUE;
+ }
+ else if(aCode.IsMod1())
+ {
+ // select next handle
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ sal_Bool bForward(!aCode.IsShift());
+
+ ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
+
+ bProc = true;
+ }
+ }
+ }
+ break;
+
+ case KEY_END:
+ {
+
+ if ( aCode.IsMod1() )
+ {
+ // #97016# mark last object
+ pView->UnmarkAllObj();
+ pView->MarkNextObj(FALSE);
+
+ bProc = true;
+ }
+ }
+ break;
+
+ case KEY_HOME:
+ {
+ if ( aCode.IsMod1() )
+ {
+ pView->UnmarkAllObj();
+ pView->MarkNextObj(TRUE);
+
+ bProc = true;
+ }
+ }
+ break;
+
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ {
+ long nX = 0;
+ long nY = 0;
+
+ if (aCode.GetCode() == KEY_UP)
+ {
+ // Scroll nach oben
+ nX = 0;
+ nY =-1;
+ }
+ else if (aCode.GetCode() == KEY_DOWN)
+ {
+ // Scroll nach unten
+ nX = 0;
+ nY = 1;
+ }
+ else if (aCode.GetCode() == KEY_LEFT)
+ {
+ // Scroll nach links
+ nX =-1;
+ nY = 0;
+ }
+ else if (aCode.GetCode() == KEY_RIGHT)
+ {
+ // Scroll nach rechts
+ nX = 1;
+ nY = 0;
+ }
+
+ if (pView->AreObjectsMarked() && !aCode.IsMod1() )
+ {
+ if(aCode.IsMod2())
+ {
+ // #97016# move in 1 pixel distance
+ Size aLogicSizeOnePixel = PixelToLogic(Size(1,1));
+ nX *= aLogicSizeOnePixel.Width();
+ nY *= aLogicSizeOnePixel.Height();
+ }
+ else
+ {
+ // old, fixed move distance
+ nX *= 100;
+ nY *= 100;
+ }
+
+ // #97016# II
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if(0L == pHdl)
+ {
+ // #90129# restrict movement to WorkArea
+ const Rectangle& rWorkArea = pView->GetWorkArea();
+
+ if(!rWorkArea.IsEmpty())
+ {
+ Rectangle aMarkRect(pView->GetMarkedObjRect());
+ aMarkRect.Move(nX, nY);
+
+ if(!aMarkRect.IsInside(rWorkArea))
+ {
+ if(aMarkRect.Left() < rWorkArea.Left())
+ {
+ nX += rWorkArea.Left() - aMarkRect.Left();
+ }
+
+ if(aMarkRect.Right() > rWorkArea.Right())
+ {
+ nX -= aMarkRect.Right() - rWorkArea.Right();
+ }
+
+ if(aMarkRect.Top() < rWorkArea.Top())
+ {
+ nY += rWorkArea.Top() - aMarkRect.Top();
+ }
+
+ if(aMarkRect.Bottom() > rWorkArea.Bottom())
+ {
+ nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
+ }
+ }
+ }
+
+ // no handle selected
+ if(0 != nX || 0 != nY)
+ {
+ pView->MoveAllMarked(Size(nX, nY));
+ }
+ }
+ else
+ {
+ // move handle with index nHandleIndex
+ if(pHdl && (nX || nY))
+ {
+ // now move the Handle (nX, nY)
+ Point aStartPoint(pHdl->GetPos());
+ Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
+ const SdrDragStat& rDragStat = pView->GetDragStat();
+
+ // start dragging
+ pView->BegDragObj(aStartPoint, 0, pHdl, 0);
+
+ if(pView->IsDragObj())
+ {
+ bool bWasNoSnap = rDragStat.IsNoSnap();
+ BOOL bWasSnapEnabled = pView->IsSnapEnabled();
+
+ // switch snapping off
+ if(!bWasNoSnap)
+ ((SdrDragStat&)rDragStat).SetNoSnap(TRUE);
+ if(bWasSnapEnabled)
+ pView->SetSnapEnabled(FALSE);
+
+ pView->MovAction(aEndPoint);
+ pView->EndDragObj();
+
+ // restore snap
+ if(!bWasNoSnap)
+ ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
+ if(bWasSnapEnabled)
+ pView->SetSnapEnabled(bWasSnapEnabled);
+ }
+ }
+ }
+
+ bProc = true;
+ }
+ }
+ break;
+
+ case KEY_SPACE:
+ {
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if(pHdl)
+ {
+ if(pHdl->GetKind() == HDL_POLY)
+ {
+ // rescue ID of point with focus
+ sal_uInt32 nPol(pHdl->GetPolyNum());
+ sal_uInt32 nPnt(pHdl->GetPointNum());
+
+ if(pView->IsPointMarked(*pHdl))
+ {
+ if(rKEvt.GetKeyCode().IsShift())
+ {
+ pView->UnmarkPoint(*pHdl);
+ }
+ }
+ else
+ {
+ if(!rKEvt.GetKeyCode().IsShift())
+ {
+ pView->UnmarkAllPoints();
+ }
+
+ pView->MarkPoint(*pHdl);
+ }
+
+ if(0L == rHdlList.GetFocusHdl())
+ {
+ // restore point with focus
+ SdrHdl* pNewOne = 0L;
+
+ for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
+ {
+ SdrHdl* pAct = rHdlList.GetHdl(a);
+
+ if(pAct
+ && pAct->GetKind() == HDL_POLY
+ && pAct->GetPolyNum() == nPol
+ && pAct->GetPointNum() == nPnt)
+ {
+ pNewOne = pAct;
+ }
+ }
+
+ if(pNewOne)
+ {
+ ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
+ }
+ }
+
+ bProc = TRUE;
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if ( !bProc )
+ Control::KeyInput( rKEvt );
+ else
+ ReleaseMouse();
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( bSdrMode && ( rMEvt.GetClicks() < 2 ) )
+ {
+ const Point aLogPt( PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ if ( !Rectangle( Point(), aGraphSize ).IsInside( aLogPt ) && !pView->IsEditMode() )
+ Control::MouseButtonDown( rMEvt );
+ else
+ {
+ // Focus anziehen fuer Key-Inputs
+ GrabFocus();
+
+ if ( nPolyEdit )
+ {
+ SdrViewEvent aVEvt;
+ SdrHitKind eHit = pView->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
+
+ if ( nPolyEdit == SID_BEZIER_INSERT && eHit == SDRHIT_MARKEDOBJECT )
+ pView->BegInsObjPoint( aLogPt, rMEvt.IsMod1());
+ else
+ pView->MouseButtonDown( rMEvt, this );
+ }
+ else
+ pView->MouseButtonDown( rMEvt, this );
+ }
+
+ SdrObject* pCreateObj = pView->GetCreateObj();
+
+ // Wir wollen das Inserten mitbekommen
+ if ( pCreateObj && !pCreateObj->GetUserCall() )
+ pCreateObj->SetUserCall( pUserCall );
+
+ SetPointer( pView->GetPreferedPointer( aLogPt, this ) );
+ }
+ else
+ Control::MouseButtonDown( rMEvt );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::MouseMove(const MouseEvent& rMEvt)
+{
+ const Point aLogPos( PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ if ( bSdrMode )
+ {
+ pView->MouseMove( rMEvt, this );
+
+ if( ( SID_BEZIER_INSERT == nPolyEdit ) &&
+ !pView->PickHandle( aLogPos ) &&
+ !pView->IsInsObjPoint() )
+ {
+ SetPointer( POINTER_CROSS );
+ }
+ else
+ SetPointer( pView->GetPreferedPointer( aLogPos, this ) );
+ }
+ else
+ Control::MouseButtonUp( rMEvt );
+
+ if ( aMousePosLink.IsSet() )
+ {
+ if ( Rectangle( Point(), aGraphSize ).IsInside( aLogPos ) )
+ aMousePos = aLogPos;
+ else
+ aMousePos = Point();
+
+ aMousePosLink.Call( this );
+ }
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ if ( bSdrMode )
+ {
+ if ( pView->IsInsObjPoint() )
+ pView->EndInsObjPoint( SDRCREATE_FORCEEND );
+ else
+ pView->MouseButtonUp( rMEvt, this );
+
+ ReleaseMouse();
+ SetPointer( pView->GetPreferedPointer( PixelToLogic( rMEvt.GetPosPixel() ), this ) );
+ }
+ else
+ Control::MouseButtonUp( rMEvt );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SdrObject* GraphCtrl::GetSelectedSdrObject() const
+{
+ SdrObject* pSdrObj = NULL;
+
+ if ( bSdrMode )
+ {
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+
+ if ( rMarkList.GetMarkCount() == 1 )
+ pSdrObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ }
+
+ return pSdrObj;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::SetEditMode( const BOOL _bEditMode )
+{
+ if ( bSdrMode )
+ {
+ bEditMode = _bEditMode;
+ pView->SetEditMode( bEditMode );
+ eObjKind = OBJ_NONE;
+ pView->SetCurrentObj( sal::static_int_cast< UINT16 >( eObjKind ) );
+ }
+ else
+ bEditMode = FALSE;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::SetPolyEditMode( const USHORT _nPolyEdit )
+{
+ if ( bSdrMode && ( _nPolyEdit != nPolyEdit ) )
+ {
+ nPolyEdit = _nPolyEdit;
+ pView->SetFrameDragSingles( nPolyEdit == 0 );
+ }
+ else
+ nPolyEdit = 0;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void GraphCtrl::SetObjKind( const SdrObjKind _eObjKind )
+{
+ if ( bSdrMode )
+ {
+ bEditMode = FALSE;
+ pView->SetEditMode( bEditMode );
+ eObjKind = _eObjKind;
+ pView->SetCurrentObj( sal::static_int_cast< UINT16 >( eObjKind ) );
+ }
+ else
+ eObjKind = OBJ_NONE;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+String GraphCtrl::GetStringFromDouble( const double& rDouble )
+{
+ sal_Unicode cSep =
+ SvtSysLocale().GetLocaleData().getNumDecimalSep().GetChar(0);
+ String aStr( ::rtl::math::doubleToUString( rDouble,
+ rtl_math_StringFormat_F, 2, cSep ));
+ return aStr;
+}
+
+
+/*************************************************************************
+www|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( GraphCtrl, UpdateHdl, Timer*, pTimer )
+{
+ if ( aUpdateLink.IsSet() )
+ aUpdateLink.Call( this );
+
+ pTimer->Start();
+
+ return 0L;
+}
+
+
+::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GraphCtrl::CreateAccessible()
+{
+ if( mpAccContext == NULL )
+ {
+ Window* pParent = GetParent();
+
+ DBG_ASSERT( pParent, "-GraphCtrl::CreateAccessible(): No Parent!" );
+
+ if( pParent )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccParent( pParent->GetAccessible() );
+
+ // #103856# Disable accessibility if no model/view data available
+ if( pView &&
+ pModel &&
+ xAccParent.is() )
+ {
+ mpAccContext = new SvxGraphCtrlAccessibleContext( xAccParent, *this );
+ mpAccContext->acquire();
+ }
+ }
+ }
+
+ return mpAccContext;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/grfflt.cxx b/svx/source/dialog/grfflt.cxx
new file mode 100644
index 000000000000..94206e158480
--- /dev/null
+++ b/svx/source/dialog/grfflt.cxx
@@ -0,0 +1,347 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/shl.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+
+#include <svx/dialmgr.hxx>
+#include <svx/grfflt.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/svxdlg.hxx>
+
+// --------------------
+// - SvxGraphicFilter -
+// --------------------
+
+ULONG SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObject& rFilterObject )
+{
+ const Graphic& rGraphic = rFilterObject.GetGraphic();
+ ULONG nRet = SVX_GRAPHICFILTER_UNSUPPORTED_GRAPHICTYPE;
+
+ if( rGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+ SfxViewFrame* pViewFrame = SfxViewFrame::Current();
+ SfxObjectShell* pShell = pViewFrame ? pViewFrame->GetObjectShell() : NULL;
+ Window* pWindow = ( pViewFrame && pViewFrame->GetViewShell() ) ? pViewFrame->GetViewShell()->GetWindow() : NULL;
+ Graphic aGraphic;
+
+ switch( rReq.GetSlot() )
+ {
+ case( SID_GRFFILTER_INVERT ):
+ {
+ if( pShell )
+ pShell->SetWaitCursor( TRUE );
+
+ if( rGraphic.IsAnimated() )
+ {
+ Animation aAnimation( rGraphic.GetAnimation() );
+
+ if( aAnimation.Invert() )
+ aGraphic = aAnimation;
+ }
+ else
+ {
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+
+ if( aBmpEx.Invert() )
+ aGraphic = aBmpEx;
+ }
+
+ if( pShell )
+ pShell->SetWaitCursor( FALSE );
+ }
+ break;
+
+ case( SID_GRFFILTER_SMOOTH ):
+ {
+ if( pShell )
+ pShell->SetWaitCursor( TRUE );
+
+ if( rGraphic.IsAnimated() )
+ {
+ Animation aAnimation( rGraphic.GetAnimation() );
+
+ if( aAnimation.Filter( BMP_FILTER_SMOOTH ) )
+ aGraphic = aAnimation;
+ }
+ else
+ {
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+
+ if( aBmpEx.Filter( BMP_FILTER_SMOOTH ) )
+ aGraphic = aBmpEx;
+ }
+
+ if( pShell )
+ pShell->SetWaitCursor( FALSE );
+ }
+ break;
+
+ case( SID_GRFFILTER_SHARPEN ):
+ {
+ if( pShell )
+ pShell->SetWaitCursor( TRUE );
+
+ if( rGraphic.IsAnimated() )
+ {
+ Animation aAnimation( rGraphic.GetAnimation() );
+
+ if( aAnimation.Filter( BMP_FILTER_SHARPEN ) )
+ aGraphic = aAnimation;
+ }
+ else
+ {
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+
+ if( aBmpEx.Filter( BMP_FILTER_SHARPEN ) )
+ aGraphic = aBmpEx;
+ }
+
+ if( pShell )
+ pShell->SetWaitCursor( FALSE );
+ }
+ break;
+
+ case( SID_GRFFILTER_REMOVENOISE ):
+ {
+ if( pShell )
+ pShell->SetWaitCursor( TRUE );
+
+ if( rGraphic.IsAnimated() )
+ {
+ Animation aAnimation( rGraphic.GetAnimation() );
+
+ if( aAnimation.Filter( BMP_FILTER_REMOVENOISE ) )
+ aGraphic = aAnimation;
+ }
+ else
+ {
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+
+ if( aBmpEx.Filter( BMP_FILTER_REMOVENOISE ) )
+ aGraphic = aBmpEx;
+ }
+
+ if( pShell )
+ pShell->SetWaitCursor( FALSE );
+ }
+ break;
+
+ case( SID_GRFFILTER_SOBEL ):
+ {
+ if( pShell )
+ pShell->SetWaitCursor( TRUE );
+
+ if( rGraphic.IsAnimated() )
+ {
+ Animation aAnimation( rGraphic.GetAnimation() );
+
+ if( aAnimation.Filter( BMP_FILTER_SOBEL_GREY ) )
+ aGraphic = aAnimation;
+ }
+ else
+ {
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+
+ if( aBmpEx.Filter( BMP_FILTER_SOBEL_GREY ) )
+ aGraphic = aBmpEx;
+ }
+
+ if( pShell )
+ pShell->SetWaitCursor( FALSE );
+ }
+ break;
+
+ case( SID_GRFFILTER_MOSAIC ):
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterMosaic( pWindow, rGraphic, 4, 4, FALSE, RID_SVX_GRFFILTER_DLG_MOSAIC);
+ DBG_ASSERT(aDlg, "Dialogdiet fail!");
+ if( aDlg->Execute() == RET_OK )
+ aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
+ delete aDlg;
+ }
+ }
+ break;
+
+ case( SID_GRFFILTER_EMBOSS ):
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterEmboss( pWindow, rGraphic, RP_MM, RID_SVX_GRFFILTER_DLG_EMBOSS );
+ DBG_ASSERT(aDlg, "Dialogdiet fail!");
+ if( aDlg->Execute() == RET_OK )
+ aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
+ delete aDlg;
+ }
+ }
+ break;
+
+ case( SID_GRFFILTER_POSTER ):
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPosterSepia( pWindow, rGraphic, 16, RID_SVX_GRFFILTER_DLG_POSTER );
+ DBG_ASSERT(aDlg, "Dialogdiet fail!");
+ if( aDlg->Execute() == RET_OK )
+ aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
+ delete aDlg;
+ }
+ }
+ break;
+
+ case( SID_GRFFILTER_POPART ):
+ {
+ if( pShell )
+ pShell->SetWaitCursor( TRUE );
+
+ if( rGraphic.IsAnimated() )
+ {
+ Animation aAnimation( rGraphic.GetAnimation() );
+
+ if( aAnimation.Filter( BMP_FILTER_POPART ) )
+ aGraphic = aAnimation;
+ }
+ else
+ {
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+
+ if( aBmpEx.Filter( BMP_FILTER_POPART ) )
+ aGraphic = aBmpEx;
+ }
+
+ if( pShell )
+ pShell->SetWaitCursor( FALSE );
+ }
+ break;
+
+ case( SID_GRFFILTER_SEPIA ):
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPosterSepia( pWindow, rGraphic, 10, RID_SVX_GRFFILTER_DLG_SEPIA );
+ DBG_ASSERT(aDlg, "Dialogdiet fail!");
+ if( aDlg->Execute() == RET_OK )
+ aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
+ delete aDlg;
+ }
+ }
+ break;
+
+ case( SID_GRFFILTER_SOLARIZE ):
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSolarize( pWindow, rGraphic, 128, FALSE, RID_SVX_GRFFILTER_DLG_SOLARIZE );
+ DBG_ASSERT(aDlg, "Dialogdiet fail!");
+ if( aDlg->Execute() == RET_OK )
+ aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
+ delete aDlg;
+ }
+ }
+ break;
+
+ case SID_GRFFILTER :
+ {
+ // do nothing; no error
+ nRet = SVX_GRAPHICFILTER_ERRCODE_NONE;
+ break;
+ }
+
+ default:
+ {
+ DBG_ERROR( "SvxGraphicFilter: selected filter slot not yet implemented" );
+ nRet = SVX_GRAPHICFILTER_UNSUPPORTED_SLOT;
+ }
+ break;
+ }
+
+ if( aGraphic.GetType() != GRAPHIC_NONE )
+ {
+ rFilterObject.SetGraphic( aGraphic );
+ nRet = SVX_GRAPHICFILTER_ERRCODE_NONE;
+ }
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SvxGraphicFilter::DisableGraphicFilterSlots( SfxItemSet& rSet )
+{
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER ) )
+ rSet.DisableItem( SID_GRFFILTER );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_INVERT ) )
+ rSet.DisableItem( SID_GRFFILTER_INVERT );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SMOOTH ) )
+ rSet.DisableItem( SID_GRFFILTER_SMOOTH );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SHARPEN ) )
+ rSet.DisableItem( SID_GRFFILTER_SHARPEN );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_REMOVENOISE ) )
+ rSet.DisableItem( SID_GRFFILTER_REMOVENOISE );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SOBEL ) )
+ rSet.DisableItem( SID_GRFFILTER_SOBEL );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_MOSAIC ) )
+ rSet.DisableItem( SID_GRFFILTER_MOSAIC );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_EMBOSS ) )
+ rSet.DisableItem( SID_GRFFILTER_EMBOSS );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_POSTER ) )
+ rSet.DisableItem( SID_GRFFILTER_POSTER );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_POPART ) )
+ rSet.DisableItem( SID_GRFFILTER_POPART );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SEPIA ) )
+ rSet.DisableItem( SID_GRFFILTER_SEPIA );
+
+ if( SFX_ITEM_AVAILABLE <= rSet.GetItemState( SID_GRFFILTER_SOLARIZE ) )
+ rSet.DisableItem( SID_GRFFILTER_SOLARIZE );
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx
new file mode 100644
index 000000000000..eb78aa66c554
--- /dev/null
+++ b/svx/source/dialog/hdft.cxx
@@ -0,0 +1,983 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/shl.hxx>
+#include <svl/itemiter.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/module.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/graph.hxx>
+
+#include <sfx2/sfxsids.hrc>
+#include <svx/svxids.hrc>
+#include <svx/dialogs.hrc>
+#include "hdft.hrc"
+#include <svl/intitem.hxx>
+
+#define _SVX_HDFT_CXX
+
+#include <svx/hdft.hxx>
+#include <svx/pageitem.hxx>
+
+#include "dlgutil.hxx"
+#include <svx/dialmgr.hxx>
+#include "htmlmode.hxx"
+
+#include <editeng/brshitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/boxitem.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+// static ----------------------------------------------------------------
+
+// --> OD 2004-06-18 #i19922#
+//static const long MINBODY = 284; // 0,5cm in twips aufgerundet
+static const long MINBODY = 56; // 1mm in twips rounded
+
+// default distance to Header or footer
+static const long DEF_DIST_WRITER = 500; // 5mm (Writer)
+static const long DEF_DIST_CALC = 250; // 2,5mm (Calc)
+
+static USHORT pRanges[] =
+{
+ SID_ATTR_BRUSH, SID_ATTR_BRUSH,
+ SID_ATTR_BORDER_OUTER, SID_ATTR_BORDER_OUTER,
+ SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
+ SID_ATTR_BORDER_SHADOW, SID_ATTR_BORDER_SHADOW,
+ SID_ATTR_LRSPACE, SID_ATTR_LRSPACE,
+ SID_ATTR_ULSPACE, SID_ATTR_ULSPACE,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ SID_ATTR_PAGE_HEADERSET, SID_ATTR_PAGE_HEADERSET,
+ SID_ATTR_PAGE_FOOTERSET, SID_ATTR_PAGE_FOOTERSET,
+ SID_ATTR_PAGE_ON, SID_ATTR_PAGE_ON,
+ SID_ATTR_PAGE_DYNAMIC, SID_ATTR_PAGE_DYNAMIC,
+ SID_ATTR_PAGE_SHARED, SID_ATTR_PAGE_SHARED,
+ SID_ATTR_HDFT_DYNAMIC_SPACING, SID_ATTR_HDFT_DYNAMIC_SPACING,
+ 0
+};
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+// gibt den Bereich der Which-Werte zurueck
+
+
+USHORT* SvxHeaderPage::GetRanges()
+{
+ return pRanges;
+}
+
+//------------------------------------------------------------------------
+
+SfxTabPage* SvxHeaderPage::Create( Window* pParent, const SfxItemSet& rSet )
+{
+ return new SvxHeaderPage( pParent, rSet );
+}
+
+//------------------------------------------------------------------------
+
+USHORT* SvxFooterPage::GetRanges()
+{
+ return pRanges;
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* SvxFooterPage::Create( Window* pParent, const SfxItemSet& rSet )
+{
+ return new SvxFooterPage( pParent, rSet );
+}
+
+// -----------------------------------------------------------------------
+
+SvxHeaderPage::SvxHeaderPage( Window* pParent, const SfxItemSet& rAttr ) :
+
+ SvxHFPage( pParent, RID_SVXPAGE_HEADER, rAttr, SID_ATTR_PAGE_HEADERSET )
+
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxFooterPage::SvxFooterPage( Window* pParent, const SfxItemSet& rAttr ) :
+
+ SvxHFPage( pParent, RID_SVXPAGE_FOOTER, rAttr, SID_ATTR_PAGE_FOOTERSET )
+
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxHFPage::SvxHFPage( Window* pParent, USHORT nResId, const SfxItemSet& rAttr, USHORT nSetId ) :
+
+ SfxTabPage( pParent, SVX_RES( nResId ), rAttr ),
+
+ aTurnOnBox ( this, SVX_RES( CB_TURNON ) ),
+ aCntSharedBox ( this, SVX_RES( CB_SHARED ) ),
+ aLMLbl ( this, SVX_RES( FT_LMARGIN ) ),
+ aLMEdit ( this, SVX_RES( ED_LMARGIN ) ),
+ aRMLbl ( this, SVX_RES( FT_RMARGIN ) ),
+ aRMEdit ( this, SVX_RES( ED_RMARGIN ) ),
+ aDistFT ( this, SVX_RES( FT_DIST ) ),
+ aDistEdit ( this, SVX_RES( ED_DIST ) ),
+ aDynSpacingCB ( this, SVX_RES( CB_DYNSPACING ) ),
+ aHeightFT ( this, SVX_RES( FT_HEIGHT ) ),
+ aHeightEdit ( this, SVX_RES( ED_HEIGHT ) ),
+ aHeightDynBtn ( this, SVX_RES( CB_HEIGHT_DYN ) ),
+ aFrm ( this, SVX_RES( FL_FRAME ) ),
+ aBspWin ( this, SVX_RES( WN_BSP ) ),
+ aBackgroundBtn ( this, SVX_RES( BTN_EXTRAS ) ),
+
+ nId ( nSetId ),
+ pBBSet ( NULL ),
+ bDisableQueryBox ( FALSE ),
+ bEnableBackgroundSelector ( TRUE )
+
+{
+ InitHandler();
+ aBspWin.EnableRTL( FALSE );
+
+ // diese Page braucht ExchangeSupport
+ SetExchangeSupport();
+
+ FreeResource();
+
+ // Metrik einstellen
+ FieldUnit eFUnit = GetModuleFieldUnit( rAttr );
+ SetFieldUnit( aDistEdit, eFUnit );
+ SetFieldUnit( aHeightEdit, eFUnit );
+ SetFieldUnit( aLMEdit, eFUnit );
+ SetFieldUnit( aRMEdit, eFUnit );
+}
+
+// -----------------------------------------------------------------------
+
+SvxHFPage::~SvxHFPage()
+{
+ delete pBBSet;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SvxHFPage::FillItemSet( SfxItemSet& rSet )
+{
+ const USHORT nWSize = GetWhich( SID_ATTR_PAGE_SIZE );
+ const USHORT nWLRSpace = GetWhich( SID_ATTR_LRSPACE );
+ const USHORT nWULSpace = GetWhich( SID_ATTR_ULSPACE );
+ const USHORT nWOn = GetWhich( SID_ATTR_PAGE_ON );
+ const USHORT nWDynamic = GetWhich( SID_ATTR_PAGE_DYNAMIC );
+ const USHORT nWDynSpacing = GetWhich( SID_ATTR_HDFT_DYNAMIC_SPACING );
+ const USHORT nWShared = GetWhich( SID_ATTR_PAGE_SHARED );
+ const USHORT nWBrush = GetWhich( SID_ATTR_BRUSH );
+ const USHORT nWBox = GetWhich( SID_ATTR_BORDER_OUTER );
+ const USHORT nWBoxInfo = GetWhich( SID_ATTR_BORDER_INNER );
+ const USHORT nWShadow = GetWhich( SID_ATTR_BORDER_SHADOW );
+ const USHORT aWhichTab[] = { nWSize, nWSize,
+ nWLRSpace, nWLRSpace,
+ nWULSpace, nWULSpace,
+ nWOn, nWOn,
+ nWDynamic, nWDynamic,
+ nWShared, nWShared,
+ nWBrush, nWBrush,
+ nWBoxInfo, nWBoxInfo,
+ nWBox, nWBox,
+ nWShadow, nWShadow,
+ nWDynSpacing, nWDynSpacing,
+ 0 };
+ const SfxItemSet& rOldSet = GetItemSet();
+ SfxItemPool* pPool = rOldSet.GetPool();
+ DBG_ASSERT( pPool, "no pool :-(" );
+ SfxMapUnit eUnit = pPool->GetMetric( nWSize );
+ SfxItemSet aSet ( *pPool, aWhichTab );
+
+ //--------------------------------------------------------------------
+
+ aSet.Put( SfxBoolItem( nWOn, aTurnOnBox.IsChecked() ) );
+ aSet.Put( SfxBoolItem( nWDynamic, aHeightDynBtn.IsChecked() ) );
+ aSet.Put( SfxBoolItem( nWShared, aCntSharedBox.IsChecked() ) );
+ if(aDynSpacingCB.IsVisible() && SFX_WHICH_MAX > nWDynSpacing)
+ {
+ SfxBoolItem* pBoolItem = (SfxBoolItem*)pPool->GetDefaultItem(nWDynSpacing).Clone();
+ pBoolItem->SetValue(aDynSpacingCB.IsChecked());
+ aSet.Put(*pBoolItem);
+ delete pBoolItem;
+ }
+
+ // Groesse
+ SvxSizeItem aSizeItem( (const SvxSizeItem&)rOldSet.Get( nWSize ) );
+ Size aSize( aSizeItem.GetSize() );
+ long nDist = GetCoreValue( aDistEdit, eUnit );
+ long nH = GetCoreValue( aHeightEdit, eUnit );
+
+ // fixe Hoehe?
+// if ( !aHeightDynBtn.IsChecked() )
+ nH += nDist; // dann Abstand dazu addieren
+ aSize.Height() = nH;
+ aSizeItem.SetSize( aSize );
+ aSet.Put( aSizeItem );
+
+ // Raender
+ SvxLRSpaceItem aLR( nWLRSpace );
+ aLR.SetLeft( (USHORT)GetCoreValue( aLMEdit, eUnit ) );
+ aLR.SetRight( (USHORT)GetCoreValue( aRMEdit, eUnit ) );
+ aSet.Put( aLR );
+
+ SvxULSpaceItem aUL( nWULSpace );
+ if ( nId == SID_ATTR_PAGE_HEADERSET )
+ aUL.SetLower( (USHORT)nDist );
+ else
+ aUL.SetUpper( (USHORT)nDist );
+ aSet.Put( aUL );
+
+ // Hintergrund und Umrandung?
+ if ( pBBSet )
+ aSet.Put( *pBBSet );
+ else
+ {
+ const SfxItemSet* _pSet;
+ const SfxPoolItem* pItem;
+
+ if ( SFX_ITEM_SET ==
+ GetItemSet().GetItemState( GetWhich( nId ), FALSE, &pItem ) )
+ {
+ _pSet = &( (SvxSetItem*)pItem )->GetItemSet();
+
+ if ( _pSet->GetItemState( nWBrush ) == SFX_ITEM_SET )
+ aSet.Put( (const SvxBrushItem&)_pSet->Get( nWBrush ) );
+ if ( _pSet->GetItemState( nWBoxInfo ) == SFX_ITEM_SET )
+ aSet.Put( (const SvxBoxInfoItem&)_pSet->Get( nWBoxInfo ) );
+ if ( _pSet->GetItemState( nWBox ) == SFX_ITEM_SET )
+ aSet.Put( (const SvxBoxItem&)_pSet->Get( nWBox ) );
+ if ( _pSet->GetItemState( nWShadow ) == SFX_ITEM_SET )
+ aSet.Put( (const SvxShadowItem&)_pSet->Get( nWShadow ) );
+ }
+ }
+
+ // Das SetItem wegschreiben
+ SvxSetItem aSetItem( GetWhich( nId ), aSet );
+ rSet.Put( aSetItem );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+void SvxHFPage::Reset( const SfxItemSet& rSet )
+{
+ ActivatePage( rSet );
+ ResetBackground_Impl( rSet );
+
+ SfxItemPool* pPool = GetItemSet().GetPool();
+ DBG_ASSERT( pPool, "Wo ist der Pool" );
+ SfxMapUnit eUnit = pPool->GetMetric( GetWhich( SID_ATTR_PAGE_SIZE ) );
+
+ // Kopf-/Fusszeilen-Attribute auswerten
+ //
+ const SvxSetItem* pSetItem = 0;
+
+ if ( SFX_ITEM_SET == rSet.GetItemState( GetWhich(nId), FALSE,
+ (const SfxPoolItem**)&pSetItem ) )
+ {
+ const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
+ const SfxBoolItem& rHeaderOn =
+ (const SfxBoolItem&)rHeaderSet.Get(GetWhich(SID_ATTR_PAGE_ON));
+
+ aTurnOnBox.Check(rHeaderOn.GetValue());
+
+ if ( rHeaderOn.GetValue() )
+ {
+ const SfxBoolItem& rDynamic =
+ (const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_DYNAMIC ) );
+ const SfxBoolItem& rShared =
+ (const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SHARED ) );
+ const SvxSizeItem& rSize =
+ (const SvxSizeItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
+ const SvxULSpaceItem& rUL =
+ (const SvxULSpaceItem&)rHeaderSet.Get( GetWhich( SID_ATTR_ULSPACE ) );
+ const SvxLRSpaceItem& rLR =
+ (const SvxLRSpaceItem&)rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
+ if(aDynSpacingCB.IsVisible())
+ {
+ const SfxBoolItem& rDynSpacing =
+ (const SfxBoolItem&)rHeaderSet.Get(GetWhich(SID_ATTR_HDFT_DYNAMIC_SPACING));
+ aDynSpacingCB.Check(rDynSpacing.GetValue());
+ }
+
+
+ if ( nId == SID_ATTR_PAGE_HEADERSET )
+ { // Kopfzeile
+ SetMetricValue( aDistEdit, rUL.GetLower(), eUnit );
+ SetMetricValue( aHeightEdit, rSize.GetSize().Height() - rUL.GetLower(), eUnit );
+ }
+ else
+ { // Fusszeile
+ SetMetricValue( aDistEdit, rUL.GetUpper(), eUnit );
+ SetMetricValue( aHeightEdit, rSize.GetSize().Height() - rUL.GetUpper(), eUnit );
+ }
+
+ aHeightDynBtn.Check(rDynamic.GetValue());
+ SetMetricValue( aLMEdit, rLR.GetLeft(), eUnit );
+ SetMetricValue( aRMEdit, rLR.GetRight(), eUnit );
+ aCntSharedBox.Check(rShared.GetValue());
+ }
+ else
+ pSetItem = 0;
+ }
+ else
+ {
+ // defaults for distance and height
+ long nDefaultDist = DEF_DIST_WRITER;
+ const SfxPoolItem* pExt1 = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
+ const SfxPoolItem* pExt2 = GetItem( rSet, SID_ATTR_PAGE_EXT2 );
+
+ if ( pExt1 && pExt1->ISA(SfxBoolItem) && pExt2 && pExt2->ISA(SfxBoolItem) )
+ nDefaultDist = DEF_DIST_CALC;
+
+ SetMetricValue( aDistEdit, nDefaultDist, SFX_MAPUNIT_100TH_MM );
+ SetMetricValue( aHeightEdit, 500, SFX_MAPUNIT_100TH_MM );
+ }
+
+ if ( !pSetItem )
+ {
+ aTurnOnBox.Check( FALSE );
+ aHeightDynBtn.Check( TRUE );
+ aCntSharedBox.Check( TRUE );
+ }
+
+ TurnOnHdl(0);
+
+ aTurnOnBox.SaveValue();
+ aDistEdit.SaveValue();
+ aHeightEdit.SaveValue();
+ aHeightDynBtn.SaveValue();
+ aLMEdit.SaveValue();
+ aRMEdit.SaveValue();
+ aCntSharedBox.SaveValue();
+ RangeHdl( 0 );
+
+ USHORT nHtmlMode = 0;
+ const SfxPoolItem* pItem = 0;
+ SfxObjectShell* pShell;
+ if(SFX_ITEM_SET == rSet.GetItemState(SID_HTML_MODE, FALSE, &pItem) ||
+ ( 0 != (pShell = SfxObjectShell::Current()) &&
+ 0 != (pItem = pShell->GetItem(SID_HTML_MODE))))
+ {
+ nHtmlMode = ((SfxUInt16Item*)pItem)->GetValue();
+ if(nHtmlMode && HTMLMODE_ON)
+ {
+ aCntSharedBox.Hide();
+ aBackgroundBtn.Hide();
+ }
+ }
+
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Handler initialisieren
+ --------------------------------------------------------------------*/
+
+void SvxHFPage::InitHandler()
+{
+ aTurnOnBox.SetClickHdl(LINK(this, SvxHFPage, TurnOnHdl));
+ aDistEdit.SetModifyHdl(LINK(this, SvxHFPage, DistModify));
+ aDistEdit.SetLoseFocusHdl(LINK(this, SvxHFPage, RangeHdl));
+
+ aHeightEdit.SetModifyHdl(LINK(this, SvxHFPage, HeightModify));
+ aHeightEdit.SetLoseFocusHdl(LINK(this,SvxHFPage,RangeHdl));
+
+ aLMEdit.SetModifyHdl(LINK(this, SvxHFPage, BorderModify));
+ aLMEdit.SetLoseFocusHdl(LINK(this, SvxHFPage, RangeHdl));
+ aRMEdit.SetModifyHdl(LINK(this, SvxHFPage, BorderModify));
+ aRMEdit.SetLoseFocusHdl(LINK(this, SvxHFPage, RangeHdl));
+ aBackgroundBtn.SetClickHdl(LINK(this,SvxHFPage, BackgroundHdl));
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Ein/aus
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SvxHFPage, TurnOnHdl, CheckBox *, pBox )
+{
+ if ( aTurnOnBox.IsChecked() )
+ {
+ aDistFT.Enable();
+ aDistEdit.Enable();
+ aDynSpacingCB.Enable();
+ aHeightFT.Enable();
+ aHeightEdit.Enable();
+ aHeightDynBtn.Enable();
+ aLMLbl.Enable();
+ aLMEdit.Enable();
+ aRMLbl.Enable();
+ aRMEdit.Enable();
+
+ USHORT nUsage = aBspWin.GetUsage();
+
+ if( nUsage == SVX_PAGE_RIGHT || nUsage == SVX_PAGE_LEFT )
+ aCntSharedBox.Disable();
+ else
+ aCntSharedBox.Enable();
+ aBackgroundBtn.Enable();
+ }
+ else
+ {
+ BOOL bDelete = TRUE;
+
+ if ( !bDisableQueryBox && pBox && aTurnOnBox.GetSavedValue() == TRUE )
+ bDelete = ( QueryBox( this, SVX_RES( RID_SVXQBX_DELETE_HEADFOOT ) ).Execute() == RET_YES );
+
+ if ( bDelete )
+ {
+ aDistFT.Disable();
+ aDistEdit.Disable();
+ aDynSpacingCB.Enable(FALSE);
+ aHeightFT.Disable();
+ aHeightEdit.Disable();
+ aHeightDynBtn.Disable();
+
+ aLMLbl.Disable();
+ aLMEdit.Disable();
+ aRMLbl.Disable();
+ aRMEdit.Disable();
+
+ aCntSharedBox.Disable();
+ aBackgroundBtn.Disable();
+ }
+ else
+ aTurnOnBox.Check();
+ }
+ UpdateExample();
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Abstand im Bsp Modifizieren
+ --------------------------------------------------------------------*/
+
+IMPL_LINK_INLINE_START( SvxHFPage, DistModify, MetricField *, EMPTYARG )
+{
+ UpdateExample();
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvxHFPage, DistModify, MetricField *, EMPTYARG )
+
+IMPL_LINK_INLINE_START( SvxHFPage, HeightModify, MetricField *, EMPTYARG )
+{
+ UpdateExample();
+
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvxHFPage, HeightModify, MetricField *, EMPTYARG )
+
+/*--------------------------------------------------------------------
+ Beschreibung: Raender einstellen
+ --------------------------------------------------------------------*/
+
+IMPL_LINK_INLINE_START( SvxHFPage, BorderModify, MetricField *, EMPTYARG )
+{
+ UpdateExample();
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvxHFPage, BorderModify, MetricField *, EMPTYARG )
+
+/*--------------------------------------------------------------------
+ Beschreibung: Hintergrund
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SvxHFPage, BackgroundHdl, Button *, EMPTYARG )
+{
+ if ( !pBBSet )
+ {
+ // nur die n"otigen Items f"uer Umrandung und Hintergrund benutzen
+ USHORT nBrush = GetWhich( SID_ATTR_BRUSH );
+ USHORT nOuter = GetWhich( SID_ATTR_BORDER_OUTER );
+ USHORT nInner = GetWhich( SID_ATTR_BORDER_INNER, sal_False );
+ USHORT nShadow = GetWhich( SID_ATTR_BORDER_SHADOW );
+
+ // einen leeren Set erzeugenc
+ pBBSet = new SfxItemSet( *GetItemSet().GetPool(), nBrush, nBrush,
+ nOuter, nOuter, nInner, nInner,
+ nShadow, nShadow, 0 );
+ const SfxPoolItem* pItem;
+
+ if ( SFX_ITEM_SET ==
+ GetItemSet().GetItemState( GetWhich( nId ), FALSE, &pItem ) )
+ // wenn es schon einen gesetzen Set gibt, dann diesen benutzen
+ pBBSet->Put( ( (SvxSetItem*)pItem)->GetItemSet() );
+
+ if ( SFX_ITEM_SET ==
+ GetItemSet().GetItemState( nInner, FALSE, &pItem ) )
+ // das gesetze InfoItem wird immer ben"otigt
+ pBBSet->Put( *pItem );
+ }
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ SfxAbstractTabDialog* pDlg = pFact->CreateSvxBorderBackgroundDlg( this, *pBBSet, bEnableBackgroundSelector );
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ if ( pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet() )
+ {
+ SfxItemIter aIter( *pDlg->GetOutputItemSet() );
+ const SfxPoolItem* pItem = aIter.FirstItem();
+
+ while ( pItem )
+ {
+ if ( !IsInvalidItem( pItem ) )
+ pBBSet->Put( *pItem );
+ pItem = aIter.NextItem();
+ }
+
+ //----------------------------------------------------------------
+
+ USHORT nWhich = GetWhich( SID_ATTR_BRUSH );
+
+ if ( pBBSet->GetItemState( nWhich ) == SFX_ITEM_SET )
+ {
+ const SvxBrushItem& rItem = (const SvxBrushItem&)pBBSet->Get( nWhich );
+ if ( nId == SID_ATTR_PAGE_HEADERSET )
+ aBspWin.SetHdColor( rItem.GetColor() );
+ else
+ aBspWin.SetFtColor( rItem.GetColor() );
+ }
+
+ //----------------------------------------------------------------
+
+ nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
+
+ if ( pBBSet->GetItemState( nWhich ) == SFX_ITEM_SET )
+ {
+ const SvxBoxItem& rItem = (const SvxBoxItem&)pBBSet->Get( nWhich );
+
+ if ( nId == SID_ATTR_PAGE_HEADERSET )
+ aBspWin.SetHdBorder( rItem );
+ else
+ aBspWin.SetFtBorder( rItem );
+ }
+
+ UpdateExample();
+ }
+ delete pDlg;
+ }
+ return 0;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Bsp
+ --------------------------------------------------------------------*/
+
+void SvxHFPage::UpdateExample()
+{
+ if ( nId == SID_ATTR_PAGE_HEADERSET )
+ {
+ aBspWin.SetHeader( aTurnOnBox.IsChecked() );
+ aBspWin.SetHdHeight( GetCoreValue( aHeightEdit, SFX_MAPUNIT_TWIP ) );
+ aBspWin.SetHdDist( GetCoreValue( aDistEdit, SFX_MAPUNIT_TWIP ) );
+ aBspWin.SetHdLeft( GetCoreValue( aLMEdit, SFX_MAPUNIT_TWIP ) );
+ aBspWin.SetHdRight( GetCoreValue( aRMEdit, SFX_MAPUNIT_TWIP ) );
+ }
+ else
+ {
+ aBspWin.SetFooter( aTurnOnBox.IsChecked() );
+ aBspWin.SetFtHeight( GetCoreValue( aHeightEdit, SFX_MAPUNIT_TWIP ) );
+ aBspWin.SetFtDist( GetCoreValue( aDistEdit, SFX_MAPUNIT_TWIP ) );
+ aBspWin.SetFtLeft( GetCoreValue( aLMEdit, SFX_MAPUNIT_TWIP ) );
+ aBspWin.SetFtRight( GetCoreValue( aRMEdit, SFX_MAPUNIT_TWIP ) );
+ }
+ aBspWin.Invalidate();
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Hintergrund im Beispiel setzen
+ --------------------------------------------------------------------*/
+
+void SvxHFPage::ResetBackground_Impl( const SfxItemSet& rSet )
+{
+ USHORT nWhich = GetWhich( SID_ATTR_PAGE_HEADERSET );
+
+ if ( rSet.GetItemState( nWhich, FALSE ) == SFX_ITEM_SET )
+ {
+ const SvxSetItem& rSetItem =
+ (const SvxSetItem&)rSet.Get( nWhich, FALSE );
+ const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
+ const SfxBoolItem& rOn =
+ (const SfxBoolItem&)rTmpSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
+
+ if ( rOn.GetValue() )
+ {
+ nWhich = GetWhich( SID_ATTR_BRUSH );
+
+ if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
+ {
+ const SvxBrushItem& rItem = (const SvxBrushItem&)rTmpSet.Get( nWhich );
+ aBspWin.SetHdColor( rItem.GetColor() );
+ }
+ nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
+
+ if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
+ {
+ const SvxBoxItem& rItem =
+ (const SvxBoxItem&)rTmpSet.Get( nWhich );
+ aBspWin.SetHdBorder( rItem );
+ }
+ }
+ }
+
+ nWhich = GetWhich( SID_ATTR_PAGE_FOOTERSET );
+
+ if ( rSet.GetItemState( nWhich, FALSE ) == SFX_ITEM_SET )
+ {
+ const SvxSetItem& rSetItem =
+ (const SvxSetItem&)rSet.Get( nWhich, FALSE );
+ const SfxItemSet& rTmpSet = rSetItem.GetItemSet();
+ const SfxBoolItem& rOn =
+ (const SfxBoolItem&)rTmpSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
+
+ if ( rOn.GetValue() )
+ {
+ nWhich = GetWhich( SID_ATTR_BRUSH );
+
+ if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
+ {
+ const SvxBrushItem& rItem = (const SvxBrushItem&)rTmpSet.Get( nWhich );
+ aBspWin.SetFtColor( rItem.GetColor() );
+ }
+ nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
+
+ if ( rTmpSet.GetItemState( nWhich ) == SFX_ITEM_SET )
+ {
+ const SvxBoxItem& rItem =
+ (const SvxBoxItem&)rTmpSet.Get( nWhich );
+ aBspWin.SetFtBorder( rItem );
+ }
+ }
+ }
+ nWhich = GetWhich( SID_ATTR_BRUSH );
+
+ if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
+ {
+ const SvxBrushItem& rItem = (const SvxBrushItem&)rSet.Get( nWhich );
+ aBspWin.SetColor( rItem.GetColor() );
+ const Graphic* pGrf = rItem.GetGraphic();
+
+ if ( pGrf )
+ {
+ Bitmap aBitmap = pGrf->GetBitmap();
+ aBspWin.SetBitmap( &aBitmap );
+ }
+ else
+ aBspWin.SetBitmap( NULL );
+ }
+ nWhich = GetWhich( SID_ATTR_BORDER_OUTER );
+
+ if ( rSet.GetItemState( nWhich ) >= SFX_ITEM_AVAILABLE )
+ {
+ const SvxBoxItem& rItem = (const SvxBoxItem&)rSet.Get( nWhich );
+ aBspWin.SetBorder( rItem );
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SvxHFPage::ActivatePage( const SfxItemSet& rSet )
+{
+ const SfxPoolItem* pItem = GetItem( rSet, SID_ATTR_LRSPACE );
+
+ if ( pItem )
+ {
+ // linken und rechten Rand einstellen
+ const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&)*pItem;
+
+ aBspWin.SetLeft( rLRSpace.GetLeft() );
+ aBspWin.SetRight( rLRSpace.GetRight() );
+ }
+ else
+ {
+ aBspWin.SetLeft( 0 );
+ aBspWin.SetRight( 0 );
+ }
+
+ pItem = GetItem( rSet, SID_ATTR_ULSPACE );
+
+ if ( pItem )
+ {
+ // oberen und unteren Rand einstellen
+ const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)*pItem;
+
+ aBspWin.SetTop( rULSpace.GetUpper() );
+ aBspWin.SetBottom( rULSpace.GetLower() );
+ }
+ else
+ {
+ aBspWin.SetTop( 0 );
+ aBspWin.SetBottom( 0 );
+ }
+
+ USHORT nUsage = SVX_PAGE_ALL;
+ pItem = GetItem( rSet, SID_ATTR_PAGE );
+
+ if ( pItem )
+ nUsage = ( (const SvxPageItem*)pItem )->GetPageUsage();
+
+ aBspWin.SetUsage( nUsage );
+
+ if ( SVX_PAGE_RIGHT == nUsage || SVX_PAGE_LEFT == nUsage )
+ aCntSharedBox.Disable();
+ else
+ aCntSharedBox.Enable();
+ pItem = GetItem( rSet, SID_ATTR_PAGE_SIZE );
+
+ if ( pItem )
+ {
+ // Orientation und Size aus dem PageItem
+ const SvxSizeItem& rSize = (const SvxSizeItem&)*pItem;
+ // die Groesse ist ggf. schon geswappt (Querformat)
+ aBspWin.SetSize( rSize.GetSize() );
+ }
+
+ // Kopfzeilen-Attribute auswerten
+ const SvxSetItem* pSetItem = 0;
+
+ if ( SFX_ITEM_SET == rSet.GetItemState( GetWhich( SID_ATTR_PAGE_HEADERSET ),
+ FALSE,
+ (const SfxPoolItem**)&pSetItem ) )
+ {
+ const SfxItemSet& rHeaderSet = pSetItem->GetItemSet();
+ const SfxBoolItem& rHeaderOn =
+ (const SfxBoolItem&)rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
+
+ if ( rHeaderOn.GetValue() )
+ {
+ const SvxSizeItem& rSize = (const SvxSizeItem&)
+ rHeaderSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
+ const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)
+ rHeaderSet.Get( GetWhich(SID_ATTR_ULSPACE ) );
+ const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)
+ rHeaderSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
+ long nDist = rUL.GetLower();
+
+ aBspWin.SetHdHeight( rSize.GetSize().Height() - nDist );
+ aBspWin.SetHdDist( nDist );
+ aBspWin.SetHdLeft( rLR.GetLeft() );
+ aBspWin.SetHdRight( rLR.GetRight() );
+ aBspWin.SetHeader( TRUE );
+ }
+ else
+ pSetItem = 0;
+ }
+
+ if ( !pSetItem )
+ {
+ aBspWin.SetHeader( FALSE );
+
+ if ( SID_ATTR_PAGE_HEADERSET == nId )
+ aCntSharedBox.Disable();
+ }
+ pSetItem = 0;
+
+ if ( SFX_ITEM_SET == rSet.GetItemState( GetWhich( SID_ATTR_PAGE_FOOTERSET ),
+ FALSE,
+ (const SfxPoolItem**)&pSetItem ) )
+ {
+ const SfxItemSet& rFooterSet = pSetItem->GetItemSet();
+ const SfxBoolItem& rFooterOn =
+ (const SfxBoolItem&)rFooterSet.Get( GetWhich( SID_ATTR_PAGE_ON ) );
+
+ if ( rFooterOn.GetValue() )
+ {
+ const SvxSizeItem& rSize = (const SvxSizeItem&)
+ rFooterSet.Get( GetWhich( SID_ATTR_PAGE_SIZE ) );
+ const SvxULSpaceItem& rUL = (const SvxULSpaceItem&)
+ rFooterSet.Get( GetWhich( SID_ATTR_ULSPACE ) );
+ const SvxLRSpaceItem& rLR = (const SvxLRSpaceItem&)
+ rFooterSet.Get( GetWhich( SID_ATTR_LRSPACE ) );
+ long nDist = rUL.GetUpper();
+
+ aBspWin.SetFtHeight( rSize.GetSize().Height() - nDist );
+ aBspWin.SetFtDist( nDist );
+ aBspWin.SetFtLeft( rLR.GetLeft() );
+ aBspWin.SetFtRight( rLR.GetRight() );
+ aBspWin.SetFooter( TRUE );
+ }
+ else
+ pSetItem = 0;
+ }
+
+ if ( !pSetItem )
+ {
+ aBspWin.SetFooter( FALSE );
+
+ if ( SID_ATTR_PAGE_FOOTERSET == nId )
+ aCntSharedBox.Disable();
+ }
+
+ pItem = GetItem( rSet, SID_ATTR_PAGE_EXT1 );
+
+ if ( pItem && pItem->ISA(SfxBoolItem) )
+ {
+ aBspWin.SetTable( TRUE );
+ aBspWin.SetHorz( ( (SfxBoolItem*)pItem )->GetValue() );
+ }
+
+ pItem = GetItem( rSet, SID_ATTR_PAGE_EXT2 );
+
+ if ( pItem && pItem->ISA(SfxBoolItem) )
+ {
+ aBspWin.SetTable( TRUE );
+ aBspWin.SetVert( ( (SfxBoolItem*)pItem )->GetValue() );
+ }
+ ResetBackground_Impl( rSet );
+ RangeHdl( 0 );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+int SvxHFPage::DeactivatePage( SfxItemSet* _pSet )
+{
+ if ( _pSet )
+ FillItemSet( *_pSet );
+ return LEAVE_PAGE;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Berech
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SvxHFPage, RangeHdl, Edit *, EMPTYARG )
+{
+ long nHHeight = aBspWin.GetHdHeight();
+ long nHDist = aBspWin.GetHdDist();
+
+ long nFHeight = aBspWin.GetFtHeight();
+ long nFDist = aBspWin.GetFtDist();
+
+ long nHeight = Max( (long)MINBODY,
+ static_cast<long>(aHeightEdit.Denormalize( aHeightEdit.GetValue( FUNIT_TWIP ) ) ) );
+ long nDist = aTurnOnBox.IsChecked() ?
+ static_cast<long>(aDistEdit.Denormalize( aDistEdit.GetValue( FUNIT_TWIP ) )) : 0;
+
+ long nMin;
+ long nMax;
+
+ if ( nId == SID_ATTR_PAGE_HEADERSET )
+ {
+ nHHeight = nHeight;
+ nHDist = nDist;
+ }
+ else
+ {
+ nFHeight = nHeight;
+ nFDist = nDist;
+ }
+
+ // Aktuelle Werte der Seitenraender
+ long nBT = aBspWin.GetTop();
+ long nBB = aBspWin.GetBottom();
+ long nBL = aBspWin.GetLeft();
+ long nBR = aBspWin.GetRight();
+
+ long nH = aBspWin.GetSize().Height();
+ long nW = aBspWin.GetSize().Width();
+
+ // Grenzen
+ if ( nId == SID_ATTR_PAGE_HEADERSET )
+ {
+ // Header
+ nMin = ( nH - nBB - nBT ) / 5; // 20%
+ nMax = Max( nH - nMin - nHDist - nFDist - nFHeight - nBB - nBT,
+ nMin );
+ aHeightEdit.SetMax( aHeightEdit.Normalize( nMax ), FUNIT_TWIP );
+ nMin = ( nH - nBB - nBT ) / 5; // 20%
+ nDist = Max( nH - nMin - nHHeight - nFDist - nFHeight - nBB - nBT,
+ long(0) );
+ aDistEdit.SetMax( aDistEdit.Normalize( nDist ), FUNIT_TWIP );
+ }
+ else
+ {
+ // Footer
+ nMin = ( nH - nBT - nBB ) / 5; // 20%
+ nMax = Max( nH - nMin - nFDist - nHDist - nHHeight - nBT - nBB,
+ nMin );
+ aHeightEdit.SetMax( aHeightEdit.Normalize( nMax ), FUNIT_TWIP );
+ nMin = ( nH - nBT - nBB ) / 5; // 20%
+ nDist = Max( nH - nMin - nFHeight - nHDist - nHHeight - nBT - nBB,
+ long(0) );
+ aDistEdit.SetMax( aDistEdit.Normalize( nDist ), FUNIT_TWIP );
+ }
+
+ // Einzuege beschraenken
+ nMax = nW - nBL - nBR -
+ static_cast<long>(aRMEdit.Denormalize( aRMEdit.GetValue( FUNIT_TWIP ) )) - MINBODY;
+ aLMEdit.SetMax( aLMEdit.Normalize( nMax ), FUNIT_TWIP );
+
+ nMax = nW - nBL - nBR -
+ static_cast<long>(aLMEdit.Denormalize( aLMEdit.GetValue( FUNIT_TWIP ) )) - MINBODY;
+ aRMEdit.SetMax( aLMEdit.Normalize( nMax ), FUNIT_TWIP );
+ return 0;
+}
+/* -----------------------------26.08.2002 12:49------------------------------
+
+ ---------------------------------------------------------------------------*/
+void lcl_Move(Window& rWin, sal_Int32 nDiff)
+{
+ Point aPos(rWin.GetPosPixel());
+ aPos.Y() -= nDiff;
+ rWin.SetPosPixel(aPos);
+}
+void SvxHFPage::EnableDynamicSpacing()
+{
+ aDynSpacingCB.Show();
+ //move all following controls
+ Window* aMoveWindows[] =
+ {
+ &aHeightFT,
+ &aHeightEdit,
+ &aHeightDynBtn,
+ &aBackgroundBtn,
+ 0
+ };
+ sal_Int32 nOffset = aTurnOnBox.GetPosPixel().Y() - aCntSharedBox.GetPosPixel().Y();
+ sal_Int32 nIdx = 0;
+ while(aMoveWindows[nIdx])
+ lcl_Move(*aMoveWindows[nIdx++], nOffset);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/hdft.hrc b/svx/source/dialog/hdft.hrc
new file mode 100644
index 000000000000..fe221189fc12
--- /dev/null
+++ b/svx/source/dialog/hdft.hrc
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * 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 _SVX_HDFT_HRC
+#define _SVX_HDFT_HRC
+
+// defines ---------------------------------------------------------------
+
+#define CB_TURNON 10
+#define FT_DIST 11
+#define ED_DIST 12
+#define FT_HEIGHT 13
+#define ED_HEIGHT 14
+#define CB_HEIGHT_DYN 15
+#define FT_LMARGIN 16
+#define ED_LMARGIN 17
+#define FT_RMARGIN 18
+#define ED_RMARGIN 19
+#define CB_SHARED 20
+#define FL_FRAME 21
+#define CB_DYNSPACING 22
+
+#define WN_BSP 30
+
+#define BTN_EXTRAS 40
+
+
+#endif
+
diff --git a/svx/source/dialog/hdft.src b/svx/source/dialog/hdft.src
new file mode 100644
index 000000000000..adb89ce3bf9f
--- /dev/null
+++ b/svx/source/dialog/hdft.src
@@ -0,0 +1,365 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include "helpid.hrc"
+#include <svx/dialogs.hrc>
+#include "hdft.hrc"
+ // pragma ----------------------------------------------------------------
+
+#define _TEXT_FT_LMARGIN \
+ Text [ en-US ] = "~Left margin" ; \
+
+#define _TEXT_FT_RMARGIN \
+ Text [ en-US ] = "R~ight margin" ; \
+
+
+ // RID_SVXPAGE_HEADER ----------------------------------------------------
+TabPage RID_SVXPAGE_HEADER
+{
+ HelpId = HID_FORMAT_HEADER ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Header" ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ CheckBox CB_TURNON
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
+ Text [ en-US ] = "Hea~der on" ;
+ };
+ CheckBox CB_SHARED
+ {
+ Pos = MAP_APPFONT ( 12 , 30 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
+ Text [ en-US ] = "Same ~content left/right" ;
+ };
+ FixedText FT_LMARGIN
+ {
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 102 , 8 ) ;
+ _TEXT_FT_LMARGIN
+ Left = TRUE ;
+ };
+ MetricField ED_LMARGIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 46 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 9999 ;
+ Minimum = 0 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ Last = 9999 ;
+ SpinSize = 10 ;
+ };
+ FixedText FT_RMARGIN
+ {
+ Pos = MAP_APPFONT ( 12 , 64 ) ;
+ Size = MAP_APPFONT ( 102 , 8 ) ;
+ _TEXT_FT_RMARGIN
+ Left = TRUE ;
+ };
+ MetricField ED_RMARGIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 62 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ Maximum = 9999 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ Last = 9999 ;
+ SpinSize = 10 ;
+ };
+
+ FixedText FT_DIST
+ {
+ Pos = MAP_APPFONT ( 12 , 82 ) ;
+ Size = MAP_APPFONT ( 102 , 8 ) ;
+ Text [ en-US ] = "~Spacing" ;
+ };
+ MetricField ED_DIST
+ {
+ Disable = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 80 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 9999 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ Last = 9999 ;
+ SpinSize = 10 ;
+ };
+ CheckBox CB_DYNSPACING
+ {
+ Pos = MAP_APPFONT ( 12 , 96 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
+ Hide = TRUE;
+ Text [ en-US ] = "Use d~ynamic spacing" ;
+ };
+ FixedText FT_HEIGHT
+ {
+ Pos = MAP_APPFONT ( 12 , 98 ) ;
+ Size = MAP_APPFONT ( 102 , 8 ) ;
+ Text [ en-US ] = "~Height" ;
+ };
+ MetricField ED_HEIGHT
+ {
+ Disable = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 96 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 10 ;
+ Maximum = 9999 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ First = 50 ;
+ Last = 9999 ;
+ SpinSize = 10 ;
+ };
+ CheckBox CB_HEIGHT_DYN
+ {
+ Pos = MAP_APPFONT ( 12 , 112 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
+ Text [ en-US ] = "~AutoFit height" ;
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 164 , 8 ) ;
+ Text [ en-US ] = "Header" ;
+ };
+ Window WN_BSP
+ {
+ Pos = MAP_APPFONT ( 176 , 6 ) ;
+ Size = MAP_APPFONT ( 75 , 46 ) ;
+ };
+ PushButton BTN_EXTRAS
+ {
+ Pos = MAP_APPFONT ( 12 , 130 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~More..." ;
+ };
+};
+ // RID_SVXPAGE_FOOTER ----------------------------------------------------
+TabPage RID_SVXPAGE_FOOTER
+{
+ HelpId = HID_FORMAT_FOOTER ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Footer" ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ CheckBox CB_TURNON
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
+ Text [ en-US ] = "~Footer on" ;
+ };
+ CheckBox CB_SHARED
+ {
+ Pos = MAP_APPFONT ( 12 , 30 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
+ Text [ en-US ] = "Same ~content left/right" ;
+ };
+ FixedText FT_LMARGIN
+ {
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 102 , 8 ) ;
+ Left = TRUE ;
+ _TEXT_FT_LMARGIN
+ };
+ MetricField ED_LMARGIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 46 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ Maximum = 9999 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ Last = 9999 ;
+ SpinSize = 10 ;
+ };
+ FixedText FT_RMARGIN
+ {
+ Pos = MAP_APPFONT ( 12 , 64 ) ;
+ Size = MAP_APPFONT ( 102 , 8 ) ;
+ _TEXT_FT_RMARGIN
+ Left = TRUE ;
+ };
+ MetricField ED_RMARGIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 62 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ Maximum = 9999 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ Last = 9999 ;
+ SpinSize = 10 ;
+ };
+ FixedText FT_DIST
+ {
+ Pos = MAP_APPFONT ( 12 , 82 ) ;
+ Size = MAP_APPFONT ( 102 , 8 ) ;
+ Text [ en-US ] = "~Spacing" ;
+ };
+ MetricField ED_DIST
+ {
+ Disable = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 80 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 9999 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ Last = 9999 ;
+ SpinSize = 10 ;
+ };
+ CheckBox CB_DYNSPACING
+ {
+ Pos = MAP_APPFONT ( 12 , 96 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
+ Hide = TRUE;
+ Text [ en-US ] = "Use d~ynamic spacing" ;
+ };
+ FixedText FT_HEIGHT
+ {
+ Pos = MAP_APPFONT ( 12 , 98 ) ;
+ Size = MAP_APPFONT ( 102 , 8 ) ;
+ Disable = TRUE ;
+ Text [ en-US ] = "~Height" ;
+ };
+ MetricField ED_HEIGHT
+ {
+ Disable = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 96 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 10 ;
+ Maximum = 9999 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ First = 50 ;
+ Last = 9999 ;
+ SpinSize = 10 ;
+ };
+ CheckBox CB_HEIGHT_DYN
+ {
+ Pos = MAP_APPFONT ( 12 , 112 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
+ Text [ en-US ] = "~AutoFit height" ;
+ };
+
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 164 , 8 ) ;
+ Text [ en-US ] = "Footer" ;
+ };
+ Window WN_BSP
+ {
+ Pos = MAP_APPFONT ( 176 , 6 ) ;
+ Size = MAP_APPFONT ( 75 , 46 ) ;
+ };
+ PushButton BTN_EXTRAS
+ {
+ Pos = MAP_APPFONT ( 12 , 130 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~More..." ;
+ };
+};
+QueryBox RID_SVXQBX_DELETE_HEADFOOT
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_NO ;
+ Message [ en-US ] = "Removing headers or footers deletes the contents.\nDo you want to delete this text?" ;
+};
+
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/hyperdlg.cxx b/svx/source/dialog/hyperdlg.cxx
new file mode 100644
index 000000000000..e21927f0b943
--- /dev/null
+++ b/svx/source/dialog/hyperdlg.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <vcl/settings.hxx>
+#include <unotools/viewoptions.hxx>
+#include "hyperdlg.hxx"
+#include <svx/svxdlg.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/sfxsids.hrc>
+
+//########################################################################
+//# #
+//# Childwindow-Wrapper-Class #
+//# #
+//########################################################################
+
+SFX_IMPL_CHILDWINDOW(SvxHlinkDlgWrapper, SID_HYPERLINK_DIALOG)
+
+// -----------------------------------------------------------------------
+
+struct MyStruct
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
+ SfxChildWinFactory* pFact;
+ sal_Bool bHideNotDelete;
+ sal_Bool bVisible;
+ sal_Bool bHideAtToggle;
+ SfxModule* pContextModule;
+ SfxWorkWindow* pWorkWin;
+};
+
+SvxHlinkDlgWrapper::SvxHlinkDlgWrapper( Window* _pParent, USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( _pParent, nId ),
+
+ mpDlg( NULL )
+
+{
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");
+ mpDlg = pFact->CreateSvxHpLinkDlg( _pParent, pBindings, SID_HYPERLINK_DIALOG );
+ DBG_ASSERT(mpDlg, "Dialogdiet fail!");
+ pWindow = mpDlg->GetWindow();
+ ((MyStruct*)pImp)->bVisible = FALSE;
+
+ Window* pTopWindow = 0;
+ if ( pInfo->aSize.Width() != 0 && pInfo->aSize.Height() != 0 &&
+ (0 != (pTopWindow = SFX_APP()->GetTopWindow())))
+ {
+ Size aParentSize( pTopWindow->GetSizePixel() );
+ Size aDlgSize ( GetSizePixel () );
+
+ if( aParentSize.Width() < pInfo->aPos.X() )
+ pInfo->aPos.setX( aParentSize.Width()-aDlgSize.Width() < long(0.1*aParentSize.Width()) ?
+ long(0.1*aParentSize.Width()) : aParentSize.Width()-aDlgSize.Width() );
+ if( aParentSize.Height() < pInfo->aPos. Y() )
+ pInfo->aPos.setY( aParentSize.Height()-aDlgSize.Height() < long(0.1*aParentSize.Height()) ?
+ long(0.1*aParentSize.Height()) : aParentSize.Height()-aDlgSize.Height() );
+
+ pWindow->SetPosPixel( pInfo->aPos );
+ }
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+
+ SetHideNotDelete( TRUE );
+}
+
+SfxChildWinInfo SvxHlinkDlgWrapper::GetInfo() const
+{
+ return SfxChildWindow::GetInfo();
+}
+
+sal_Bool SvxHlinkDlgWrapper::QueryClose()
+{
+ return mpDlg ? mpDlg->QueryClose() : sal_True;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/hyprdlg.hxx b/svx/source/dialog/hyprdlg.hxx
new file mode 100644
index 000000000000..732d5b3009f3
--- /dev/null
+++ b/svx/source/dialog/hyprdlg.hxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_DLG_HYPERDLG_HXX
+#define _SVX_DLG_HYPERDLG_HXX
+
+#include <vcl/combobox.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/menu.hxx>
+#include <svtools/stdctrl.hxx>
+#include <sfx2/ctrlitem.hxx>
+#include <svl/srchcfg.hxx>
+#include <sfx2/tbxctrl.hxx>
+
+class SvxHyperlinkDlg;
+class SfxViewFrame;
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+class HyperCombo : public ComboBox
+{
+ SvxHyperlinkDlg *pDlg;
+ long nMaxWidth;
+ long nMinWidth;
+ long nRatio;
+
+ virtual long Notify( NotifyEvent& rNEvt );
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+public:
+ HyperCombo( SvxHyperlinkDlg* pDialog, const ResId& rResId );
+
+ inline void SetRatio( long nR ) { nRatio = nR; }
+ inline long GetRatio() { return nRatio; }
+ long CalcResizeWidth( long nW );
+ inline long GetResizeWidth() { return (nMaxWidth - nMinWidth); }
+ void DoResize( long nW );
+};
+
+class HyperFixedText : public FixedInfo
+{
+ SvxHyperlinkDlg *pDlg;
+
+public:
+ HyperFixedText( SvxHyperlinkDlg* pDialog, const ResId& rResId );
+
+};
+
+/*--------------------------------------------------------------------
+ Beschreibung: Dialog zum Einfgen/Žndern eines Hyperlink
+ --------------------------------------------------------------------*/
+
+class SvxHyperlinkDlg : public ToolBox, public SfxControllerItem
+{
+ friend class HyperCombo;
+ friend class HyperFixedText;
+ using ToolBox::StateChanged;
+
+private:
+ SfxStatusForwarder aForwarder;
+ SfxStatusForwarder aHyperlinkDlgForward;
+ HyperCombo aNameCB;
+ HyperFixedText aUrlFT;
+ HyperCombo aUrlCB;
+
+ SvxSearchConfig aSearchConfig;
+
+ String sAddress;
+ String sExplorer;
+ String sOldName;
+ String sSearchTitle;
+ PopupMenu aLinkPopup;
+ PopupMenu *pTargetMenu;
+ BOOL bNoDoc;
+ BOOL bSend;
+ BOOL bHasOldName;
+ long nMaxWidth;
+ long nMinWidth;
+ long nMaxHeight;
+ BOOL bHtmlMode;
+
+ SfxImageManager* mpManager;
+
+ virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ // DockingWindow
+ virtual void Resize();
+ virtual void Resizing(Size& rSize);
+
+ // Drag&Drop
+ BOOL GetDragData(USHORT nItem, ULONG nDDFormatId, String& rBuffer);
+
+ DECL_LINK(TBClickHdl, ToolBox *);
+ DECL_LINK(TBSelectHdl, ToolBox *);
+ DECL_LINK(DropdownClick, ToolBox * );
+ DECL_LINK(LinkPopupSelectHdl, Menu *);
+ DECL_LINK(SearchPopupSelectHdl, Menu *);
+ DECL_LINK(ComboSelectHdl, ComboBox *);
+ DECL_LINK(ComboModifyHdl, ComboBox *);
+ DECL_LINK(BookmarkFoundHdl, String *);
+
+ void OpenDoc( const String& rURL, SfxViewFrame* pViewFrame );
+ void EnableLink();
+ void SendToApp(USHORT nType);
+ void AddToHistory(const String& rName, const String& rURL);
+ void TargetMenu(const String& rSelEntry, BOOL bExecute);
+ String GetSelTarget();
+
+ void SetImages();
+public:
+ SvxHyperlinkDlg(SfxBindings *pBindings, Window* pWindow);
+ ~SvxHyperlinkDlg();
+};
+
+
+#endif // _SVX_DLG_HYPERDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/hyprlink.cxx b/svx/source/dialog/hyprlink.cxx
new file mode 100644
index 000000000000..b1d799f76d80
--- /dev/null
+++ b/svx/source/dialog/hyprlink.cxx
@@ -0,0 +1,1001 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/urlobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/configitem.hxx>
+#include <unotools/cmdoptions.hxx>
+#include <svtools/inetimg.hxx>
+#include <svl/urlbmk.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/imgmgr.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/urihelper.hxx>
+#include <sfx2/objsh.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include "hlnkitem.hxx"
+#include <svx/dialogs.hrc>
+#include "hyprlink.hrc"
+#include <svx/dialmgr.hxx>
+#include "hyprlink.hxx"
+#include "hyprdlg.hxx"
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+// -----------------------------------------------------------------------
+
+class SearchDefaultConfigItem_Impl : public ::utl::ConfigItem
+{
+ OUString sDefaultEngine;
+public:
+ SearchDefaultConfigItem_Impl();
+ ~SearchDefaultConfigItem_Impl();
+
+ const OUString& GetDefaultSearchEngine(){ return sDefaultEngine;}
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+ virtual void Commit();
+};
+
+/*-- 11.11.2003 14:20:59---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SearchDefaultConfigItem_Impl::SearchDefaultConfigItem_Impl() :
+ ConfigItem(OUString::createFromAscii("Inet/DefaultSearchEngine"))
+{
+ uno::Sequence<OUString> aNames(1);
+ aNames.getArray()[0] = OUString::createFromAscii("Name");
+ uno::Sequence< uno::Any > aValues = GetProperties(aNames);
+ aValues.getConstArray()[0] >>= sDefaultEngine;
+}
+/*-- 11.11.2003 14:21:00---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SearchDefaultConfigItem_Impl::~SearchDefaultConfigItem_Impl()
+{
+}
+
+void SearchDefaultConfigItem_Impl::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& )
+{
+}
+
+void SearchDefaultConfigItem_Impl::Commit()
+{
+}
+
+/*************************************************************************
+|*
+|* Dialog zum Einf"ugen/"Andern eines Hyperlink
+|*
+\************************************************************************/
+
+SvxHyperlinkDlg::SvxHyperlinkDlg( SfxBindings *_pBindings, Window* pParent) :
+
+ ToolBox ( pParent, SVX_RES( RID_SVXDLG_HYPERLINK ) ),
+ SfxControllerItem ( SID_HYPERLINK_SETLINK, *_pBindings ),
+
+ aForwarder ( SID_HYPERLINK_GETLINK, *this ),
+ aHyperlinkDlgForward( SID_HYPERLINK_DIALOG , *this),
+
+ aNameCB ( this, SVX_RES( CB_NAME ) ),
+ aUrlFT ( this, SVX_RES( FT_URL ) ),
+ aUrlCB ( this, SVX_RES( CB_URL ) ),
+ aSearchConfig (sal_True),
+ sAddress ( SVX_RES( STR_ADDRESS ) ),
+ sExplorer ( SVX_RES( STR_EXPLORER ) ),
+ sSearchTitle ( SVX_RES( STR_BOOKMARK_SEARCH ) ),
+ aLinkPopup ( SVX_RES( RID_SVXMN_HYPERLINK ) ),
+ pTargetMenu ( NULL ),
+
+ bNoDoc ( TRUE ),
+ bSend ( FALSE ),
+ bHasOldName ( FALSE ),
+ bHtmlMode ( FALSE )
+
+{
+ FreeResource();
+
+ mpManager = SfxImageManager::GetImageManager( 0 );
+ mpManager->RegisterToolBox( this );
+
+ SetImages();
+
+ // save initial size
+ nMaxWidth = GetSizePixel().Width();
+ nMaxHeight = GetSizePixel().Height();
+
+
+ InsertSeparator( 0 );
+ InsertWindow( CB_URL, &aUrlCB, 0, 0 );
+ // we need an item text for accessibility
+ String sItemText = aUrlCB.GetText();
+ if ( sItemText.Len() == 0 )
+ sItemText = aUrlCB.GetQuickHelpText();
+ if ( sItemText.Len() > 0 )
+ {
+ SetItemText( CB_URL, sItemText );
+ sItemText.Erase();
+ }
+ InsertWindow( FT_URL, &aUrlFT, 0, 0 );
+ InsertSeparator( 0 );
+ InsertWindow( CB_NAME, &aNameCB, 0, 0 );
+ sItemText = aNameCB.GetText();
+ if ( sItemText.Len() == 0 )
+ sItemText = aNameCB.GetQuickHelpText();
+ if ( sItemText.Len() > 0 )
+ SetItemText( CB_NAME, sItemText );
+
+ SetSizePixel(CalcWindowSizePixel()); // Groesse initialisieren
+
+ nMaxHeight = GetSizePixel().Height(); // Hoehe nochmal merken, da sie veraendert wurde
+ // SetSizePixel ruft Resize-Handler!
+
+ Show();
+ Resize();
+
+ long nUrlWidth = aUrlCB.GetResizeWidth();
+ long nNameWidth = aNameCB.GetResizeWidth();
+ long nSum = nUrlWidth + nNameWidth;
+
+ aUrlCB.SetRatio((nUrlWidth * 100L) / nSum);
+ aNameCB.SetRatio((nNameWidth * 100L) / nSum);
+
+ SetClickHdl( LINK( this, SvxHyperlinkDlg, TBClickHdl ) );
+ SetSelectHdl( LINK( this, SvxHyperlinkDlg, TBSelectHdl ) );
+ SetDropdownClickHdl( LINK( this, SvxHyperlinkDlg, DropdownClick ) );
+
+ SetItemBits( BTN_TARGET, GetItemBits( BTN_TARGET ) | TIB_DROPDOWNONLY );
+ SetItemBits( BTN_INET_SEARCH, GetItemBits( BTN_INET_SEARCH ) | TIB_DROPDOWN );
+ SetItemBits( BTN_INET_SEARCH, GetItemBits( BTN_TARGET ) | TIB_DROPDOWNONLY );
+
+ aLinkPopup.SetSelectHdl(LINK(this, SvxHyperlinkDlg, LinkPopupSelectHdl));
+
+ Link aLk = LINK(this, SvxHyperlinkDlg, ComboSelectHdl);
+ aNameCB.SetSelectHdl(aLk);
+ aUrlCB.SetSelectHdl(aLk);
+
+ aLk = LINK(this, SvxHyperlinkDlg, ComboModifyHdl);
+ aNameCB.SetModifyHdl(aLk);
+ aUrlCB.SetModifyHdl(aLk);
+
+ // Accessibility: Set the quick help text as accessible name for the
+ // drop down lists.
+ aNameCB.SetAccessibleName (aNameCB.GetQuickHelpText());
+ aUrlCB.SetAccessibleName (aUrlCB.GetQuickHelpText());
+
+ // Hide button according to config item.
+ SvtCommandOptions aCmdOpts;
+ if ( aCmdOpts.Lookup( SvtCommandOptions::CMDOPTION_DISABLED,
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "InternetSearch" ) ) ) )
+ HideItem( BTN_INET_SEARCH );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+SvxHyperlinkDlg::~SvxHyperlinkDlg()
+{
+ SfxImageManager::GetImageManager( 0 )->ReleaseToolBox(this);
+
+ if (pTargetMenu != NULL)
+ delete pTargetMenu;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Leiste so resizen, dass die Comboboxen automatisch mit
+ verkleinert werden
+ --------------------------------------------------------------------*/
+
+void SvxHyperlinkDlg::Resize()
+{
+ long nWidth = GetSizePixel().Width();
+
+ ToolBox::Resize();
+
+ if (nWidth) // nWidth ist manchmal 0
+ {
+ long nDeltaW = nMaxWidth - nWidth + aUrlCB.LogicToPixel(Size(3, 1)).Width() + 1;
+
+ long nNewUrlWidth = aUrlCB.CalcResizeWidth(nDeltaW);
+ long nNewNameWidth = aNameCB.CalcResizeWidth(nDeltaW);
+
+ if (nNewUrlWidth && nNewNameWidth) // Flackern reduzieren
+ {
+ SetUpdateMode(FALSE);
+
+ // Comboboxen resizen
+ aUrlCB.DoResize(nNewUrlWidth);
+ aNameCB.DoResize(nNewNameWidth);
+ RecalcItems(); // Alle Elemente neu anordnen
+
+ SetUpdateMode(TRUE);
+ }
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SvxHyperlinkDlg::Resizing(Size& rSize)
+{
+ if (rSize.Height() > nMaxHeight)
+ rSize.Height() = nMaxHeight;
+
+ if (rSize.Width() > nMaxWidth)
+ rSize.Width() = nMaxWidth;
+
+ ToolBox::Resizing(rSize);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Im Dokument selektierten Hyperlink in Leiste anzeigen
+ --------------------------------------------------------------------*/
+
+void SvxHyperlinkDlg::StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ if ( nSID == SID_HYPERLINK_DIALOG )
+ {
+ if( eState != SFX_ITEM_DISABLED)
+ {
+ EnableItem( BTN_OPENDIALOG, TRUE );
+
+ BOOL bItem = FALSE;
+ if ( pState && eState == SFX_ITEM_AVAILABLE )
+ bItem = ((SfxBoolItem*)pState)->GetValue();
+ SetItemState ( BTN_OPENDIALOG, bItem ? STATE_CHECK : STATE_NOCHECK );
+ }
+ else
+ {
+ SetItemState ( BTN_OPENDIALOG, STATE_NOCHECK );
+ EnableItem( BTN_OPENDIALOG, FALSE );
+ }
+ }
+
+ if (nSID == SID_HYPERLINK_SETLINK)
+ {
+ if (eState == SFX_ITEM_DISABLED)
+ bNoDoc = TRUE;
+ else
+ bNoDoc = FALSE;
+ EnableItem(BTN_TARGET, !bNoDoc);
+ EnableLink();
+ }
+
+ if (nSID == SID_HYPERLINK_GETLINK)
+ {
+ if (eState == SFX_ITEM_AVAILABLE)
+ {
+ const SvxHyperlinkItem& rHLnkItem = *((const SvxHyperlinkItem*)pState);
+
+ USHORT nNamePos = aNameCB.GetEntryPos(aNameCB.GetText());
+ USHORT nUrlPos = aUrlCB.GetEntryPos(aUrlCB.GetText());
+ USHORT nNotFound = COMBOBOX_ENTRY_NOTFOUND;
+
+ if (!bHasOldName &&
+ (nNamePos == nNotFound || nUrlPos == nNotFound))
+ {
+ sOldName = aNameCB.GetText();
+ bHasOldName = TRUE;
+ }
+ if (rHLnkItem.GetName().Len())
+ {
+ aNameCB.SetText(rHLnkItem.GetName());
+ ComboModifyHdl(&aNameCB);
+ }
+ if (rHLnkItem.GetURL().Len() || rHLnkItem.GetName().Len())
+ {
+ String sUrl = INetURLObject(rHLnkItem.GetURL()).GetURLNoPass();
+ aUrlCB.SetText(sUrl);
+ }
+ else if (aUrlCB.GetEntryCount())
+ { // Letzten Eintrag wieder selektieren
+ aNameCB.SetText(aNameCB.GetEntry(0));
+ aUrlCB.SetText(aUrlCB.GetEntry(0));
+ }
+
+ TargetMenu(rHLnkItem.GetTargetFrame(), FALSE);
+ bHtmlMode = (rHLnkItem.GetInsertMode() & HLINK_HTMLMODE) != 0;
+ }
+ else
+ return;
+
+ ComboModifyHdl(&aUrlCB);
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SvxHyperlinkDlg, TBClickHdl, ToolBox *, pBox )
+{
+ switch (pBox->GetCurItemId())
+ {
+ case BTN_LINK:
+ {
+ if (!bSend) // Link ins Dokument einfuegen
+ SendToApp(HLINK_DEFAULT);
+ }
+ break;
+
+ case BTN_OPENDIALOG:
+ {
+ GetBindings().GetDispatcher()->Execute( SID_HYPERLINK_DIALOG );
+ }
+ break;
+ }
+
+ return TRUE;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SvxHyperlinkDlg, TBSelectHdl, ToolBox *, pBox )
+{
+ switch (pBox->GetCurItemId())
+ {
+ // Link als Bookmark im Explorer eintragen
+ // Soll erst im Loslassen der Maus gerufen werden, daher im Select-Hdl
+ case BTN_INSERT_BOOKMARK:
+ {
+ String sName = aNameCB.GetText();
+ if ( !sName.Len() )
+ sName = aUrlCB.GetText();
+
+ String aBase = GetBindings().GetDispatcher()->GetFrame()->GetObjectShell()->GetMedium()->GetBaseURL();
+ SfxStringItem aName( SID_BOOKMARK_TITLE, sName );
+ SfxStringItem aURL( SID_BOOKMARK_URL,
+ URIHelper::SmartRel2Abs( INetURLObject(aBase), aUrlCB.GetText(), URIHelper::GetMaybeFileHdl(), true, false,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_UNAMBIGUOUS ) );
+ GetBindings().GetDispatcher()->Execute(
+ SID_CREATELINK, SFX_CALLMODE_ASYNCHRON, &aName, &aURL, 0L );
+ }
+ break;
+ }
+
+ return TRUE;
+}
+
+IMPL_LINK( SvxHyperlinkDlg, DropdownClick, ToolBox *, pBox )
+{
+ switch (pBox->GetCurItemId())
+ {
+ case BTN_LINK:
+ {
+ // Link-Popup anstossen
+ EndSelection(); // Vor dem Execute, damit Popup den Focus bekommt
+ aLinkPopup.EnableItem(MN_BUTTON, !bHtmlMode);
+ aLinkPopup.Execute( this, GetItemRect( BTN_LINK ), FLOATWIN_POPUPMODE_DOWN );
+ }
+ break;
+
+ case BTN_INET_SEARCH:
+ {
+ // Search-Engines per Popup auswaehlen
+ PopupMenu *pMenu = new PopupMenu;
+ pMenu->SetSelectHdl(LINK(this, SvxHyperlinkDlg, SearchPopupSelectHdl));
+ SearchDefaultConfigItem_Impl aDefaultEngine;
+ String sDefault(aDefaultEngine.GetDefaultSearchEngine());
+ sDefault.ToLowerAscii();
+ const bool bHasDefault = sDefault.Len() > 0;
+
+ sal_uInt16 nCount = aSearchConfig.Count();
+ String sFound;
+ for (USHORT i = 0; i < nCount; i++)
+ {
+ const SvxSearchEngineData& rData = aSearchConfig.GetData(i);
+ //check if it's the configured default search engine
+ String sTest(rData.sEngineName);
+ sTest.ToLowerAscii();
+ bool bIsDefaultEngine = bHasDefault && STRING_NOTFOUND != sTest.Search( sDefault );
+ //then put it at the top
+ if(i && bIsDefaultEngine)
+ {
+ pMenu->InsertItem( i + 1, rData.sEngineName, 0, 0);
+ pMenu->InsertSeparator(1);
+ }
+ else
+ {
+ if (i)
+ pMenu->InsertSeparator();
+ pMenu->InsertItem( i + 1, rData.sEngineName);
+ }
+ }
+ pBox->SetItemDown(BTN_INET_SEARCH, TRUE, TRUE);
+ pMenu->Execute( this, GetItemRect( BTN_INET_SEARCH ), FLOATWIN_POPUPMODE_DOWN );
+ pBox->SetItemDown(BTN_INET_SEARCH, FALSE, TRUE);
+ EndSelection();
+ delete pMenu;
+ }
+ break;
+
+ case BTN_TARGET:
+ {
+ // Target Frame einstellen
+ TargetMenu(GetSelTarget(), TRUE);
+ EndSelection();
+ }
+ break;
+ }
+
+ return TRUE;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SvxHyperlinkDlg::TargetMenu(const String& rSelEntry, BOOL bExecute)
+{
+ if (pTargetMenu && !bExecute)
+ {
+ for (USHORT i = 1; i <= pTargetMenu->GetItemCount(); i++)
+ {
+ if (pTargetMenu->GetItemText(i) == rSelEntry)
+ {
+ pTargetMenu->CheckItem(i);
+ return;
+ }
+ }
+ }
+
+ SfxViewFrame* pVwFrm = SfxViewFrame::Current();
+
+ if (pVwFrm) // Alle moeglichen Target Frames zusammensammeln und anzeigen
+ {
+ TargetList aList;
+ pVwFrm->GetTopFrame().GetTargetList(aList);
+
+ USHORT nCount = (USHORT)aList.Count();
+ if( nCount )
+ {
+ BOOL bChecked = FALSE;
+
+ if (pTargetMenu != NULL)
+ delete pTargetMenu;
+
+ pTargetMenu = new PopupMenu;
+ pTargetMenu->SetMenuFlags( pTargetMenu->GetMenuFlags() |
+ MENU_FLAG_NOAUTOMNEMONICS );
+ USHORT i;
+ for ( i = 0; i < nCount; i++ )
+ {
+ String sEntry(*aList.GetObject(i));
+ pTargetMenu->InsertItem(i + 1, sEntry, MIB_RADIOCHECK|MIB_AUTOCHECK);
+
+ if (sEntry == rSelEntry)
+ {
+ pTargetMenu->CheckItem(i + 1);
+ bChecked = TRUE;
+ }
+ }
+ for ( i = nCount; i; i-- )
+ delete aList.GetObject( i - 1 );
+
+ if (!bChecked)
+ pTargetMenu->CheckItem(1);
+
+ if (bExecute)
+ {
+ USHORT nEntry = pTargetMenu->Execute(
+ this, GetItemRect( BTN_TARGET ), FLOATWIN_POPUPMODE_DOWN );
+ if ( nEntry )
+ pTargetMenu->CheckItem( nEntry );
+ }
+ }
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SvxHyperlinkDlg, LinkPopupSelectHdl, Menu *, pMenu )
+{
+ switch (pMenu->GetCurItemId())
+ {
+ case MN_FIELD: // URL als Hyperlink ins Dok einfuegen
+ SendToApp(HLINK_FIELD);
+ break;
+ case MN_BUTTON: // URL als Button ins Dok einfuegen
+ SendToApp(HLINK_BUTTON);
+ break;
+ }
+
+ return TRUE;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SvxHyperlinkDlg, SearchPopupSelectHdl, Menu *, pMenu )
+{
+ const SvxSearchEngineData& rData = aSearchConfig.GetData(pMenu->GetCurItemId() - 1);
+ String sText(aNameCB.GetText());
+ sText.EraseLeadingChars().EraseTrailingChars();
+
+ rtl::OUString sPrefix;
+ rtl::OUString sSuffix;
+ rtl::OUString sSeparator;
+ sal_Int32 nCaseMatch;
+ sal_Unicode cToken = 0;
+
+ if (sText.Search(' ') != STRING_NOTFOUND)
+ {
+ sPrefix = rData.sExactPrefix;
+ sSuffix = rData.sExactSuffix;
+ sSeparator = rData.sExactSeparator;
+ nCaseMatch = rData.nExactCaseMatch;
+ cToken = ' ';
+ }
+ else if (sText.Search('+') != STRING_NOTFOUND)
+ {
+ sPrefix = rData.sAndPrefix;
+ sSuffix = rData.sAndSuffix;
+ sSeparator = rData.sAndSeparator;
+ nCaseMatch = rData.nAndCaseMatch;
+ cToken = '+';
+ }
+ else if (sText.Search(',') != STRING_NOTFOUND)
+ {
+ sPrefix = rData.sOrPrefix;
+ sSuffix = rData.sOrSuffix;
+ sSeparator = rData.sOrSeparator;
+ nCaseMatch = rData.nOrCaseMatch;
+ cToken = ',';
+ }
+ else
+ {
+ sPrefix = rData.sExactPrefix;
+ sSuffix = rData.sExactSuffix;
+ nCaseMatch = rData.nExactCaseMatch;
+ cToken = 0;
+ }
+
+ String sURL = sPrefix;
+ xub_StrLen nTok;
+
+ if(1 == nCaseMatch)
+ sText.ToUpperAscii();
+ else if(2 == nCaseMatch)
+ sText.ToLowerAscii();
+
+ if ((nTok = sText.GetTokenCount(cToken)) > 1)
+ {
+ for (USHORT i = 0; i < nTok; i++)
+ {
+ sURL += sText.GetToken(i, cToken);
+ if(i < nTok -1)
+ sURL += (String)sSeparator;
+ }
+ sURL += (String)sSuffix;
+ }
+ else
+ {
+ sURL += sText;
+ sURL += (String)sSuffix;
+ }
+ sURL.EraseAllChars(); // remove all spaces
+ SfxViewFrame* pViewFrame = SfxViewFrame::Current();
+ if ( pViewFrame )
+ pViewFrame = pViewFrame->GetTopViewFrame();
+ OpenDoc( sURL, pViewFrame );
+
+ return TRUE;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SvxHyperlinkDlg, BookmarkFoundHdl, String *, pUrl )
+{
+ if (pUrl && pUrl->Len())
+ {
+ aUrlCB.SetText(*pUrl);
+ ComboModifyHdl(&aUrlCB);
+ }
+
+ return TRUE;
+}
+/*--------------------------------------------------------------------
+ Beschreibung: Link-Button enablen/disablen
+ --------------------------------------------------------------------*/
+
+void SvxHyperlinkDlg::EnableLink()
+{
+ BOOL bEnable = aUrlCB.GetText().Len() != 0;
+
+ EnableItem(BTN_LINK, (!bNoDoc) & bEnable);
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: URL im Dokument einfuegen
+ --------------------------------------------------------------------*/
+
+void SvxHyperlinkDlg::SendToApp(USHORT nType)
+{
+ BOOL bIsFile = FALSE;
+ bSend = TRUE;
+ String sURL( aUrlCB.GetText() );
+
+ if ( !sURL.Len() )
+ return;
+
+ String aBase = GetBindings().GetDispatcher()->GetFrame()->GetObjectShell()->GetMedium()->GetBaseURL();
+ INetURLObject aObj( URIHelper::SmartRel2Abs( INetURLObject(aBase), sURL, URIHelper::GetMaybeFileHdl(), true, false,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_UNAMBIGUOUS ) );
+ sURL = aObj.GetMainURL( INetURLObject::NO_DECODE );
+ if ( aObj.GetProtocol() == INET_PROT_FILE )
+ bIsFile = TRUE;
+
+ if ( bIsFile )
+ {
+ EnterWait();
+ SfxMedium aMedium( sURL, STREAM_STD_READ, TRUE );
+ if ( aMedium.Exists( FALSE ) == FALSE )
+ {
+ LeaveWait();
+ QueryBox aBox( this, SVX_RES( RID_SVXQB_DONTEXIST ) );
+ if ( aBox.Execute() == RET_NO )
+ return;
+ }
+ else
+ LeaveWait();
+ }
+
+ SvxHyperlinkItem aItem( SID_HYPERLINK_SETLINK );
+
+ if (aNameCB.GetText().Len())
+ aItem.SetName( aNameCB.GetText() );
+ else
+ aItem.SetName( sURL );
+
+ sOldName = aNameCB.GetText();
+
+ aItem.SetURL(sURL);
+ aItem.SetInsertMode( (SvxLinkInsertMode)nType );
+ aItem.SetTargetFrame( GetSelTarget() );
+
+ GetBindings().GetDispatcher()->Execute(
+ SID_HYPERLINK_SETLINK, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+
+ AddToHistory( aNameCB.GetText(), sURL );
+
+ if ( sURL != aUrlCB.GetText() )
+ aUrlCB.SetText( sURL );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Selektierten Target Frame Eintrag im Popup ermitteln
+ --------------------------------------------------------------------*/
+
+String SvxHyperlinkDlg::GetSelTarget()
+{
+ String sTarget;
+
+ if (pTargetMenu != NULL)
+ {
+ for (USHORT i = 1; i <= pTargetMenu->GetItemCount(); i++)
+ {
+ if (pTargetMenu->IsItemChecked(i))
+ {
+ sTarget = pTargetMenu->GetItemText(i);
+ break;
+ }
+ }
+ }
+
+ return sTarget;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: URL in History der Leiste aufnehmen
+ --------------------------------------------------------------------*/
+
+void SvxHyperlinkDlg::AddToHistory(const String& rName, const String& rURL)
+{
+ String sName(rName);
+
+ if (bHasOldName && sOldName.Len())
+ {
+ sName = sOldName;
+ bHasOldName = FALSE;
+ }
+
+ if (!sName.Len())
+ sName = rURL;
+
+ if (rURL.Len())
+ {
+ USHORT nNamePos = aNameCB.GetEntryPos(sName);
+ USHORT nUrlPos = aUrlCB.GetEntryPos(rURL);
+ USHORT nPos = COMBOBOX_ENTRY_NOTFOUND;
+
+ if (nNamePos != COMBOBOX_ENTRY_NOTFOUND)
+ nPos = nNamePos;
+ else
+ nPos = nUrlPos;
+
+ // Alten Eintrag durch neuen Eintrag ersetzen
+ if (nPos != COMBOBOX_ENTRY_NOTFOUND)
+ {
+ aNameCB.RemoveEntry(nPos);
+ aUrlCB.RemoveEntry(nPos);
+ aNameCB.SetText(rName);
+ aUrlCB.SetText(rURL);
+ }
+
+ aNameCB.InsertEntry(sName, 0);
+ aUrlCB.InsertEntry(rURL, 0);
+ }
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Bookmark und Search-Button enablen/disablen
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SvxHyperlinkDlg, ComboSelectHdl, ComboBox *, pCombo )
+{
+ USHORT nPos = pCombo->GetEntryPos(pCombo->GetText());
+
+ if (nPos != COMBOBOX_ENTRY_NOTFOUND)
+ {
+ aNameCB.SetText(aNameCB.GetEntry(nPos));
+ aUrlCB.SetText(aUrlCB.GetEntry(nPos));
+
+ EnableLink();
+ EnableItem(BTN_INSERT_BOOKMARK, TRUE);
+ EnableItem(BTN_INET_SEARCH, TRUE);
+ }
+ return TRUE;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+IMPL_LINK( SvxHyperlinkDlg, ComboModifyHdl, ComboBox *, pCombo )
+{
+ BOOL bEnable = TRUE;
+
+ if (!pCombo->GetText().Len())
+ bEnable = FALSE;
+
+ if (pCombo == &aNameCB)
+ {
+ if (IsItemEnabled(BTN_INET_SEARCH) != bEnable)
+ EnableItem(BTN_INET_SEARCH, bEnable);
+ }
+
+ EnableLink();
+
+ if (aUrlCB.GetText().Len())
+ bEnable = TRUE;
+ else
+ bEnable = FALSE;
+
+ if (IsItemEnabled(BTN_INSERT_BOOKMARK) != bEnable)
+ EnableItem(BTN_INSERT_BOOKMARK, bEnable);
+
+ return TRUE;
+}
+
+// --------------------------------------------------------------------
+
+void SvxHyperlinkDlg::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ ToolBox::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE))
+ SetImages();
+}
+
+// --------------------------------------------------------------------
+
+void SvxHyperlinkDlg::SetImages()
+{
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ SetItemImage( BTN_LINK, mpManager->GetImage( BTN_LINK, bHighContrast ) );
+ SetItemImage( BTN_INSERT_BOOKMARK, mpManager->GetImage( BTN_INSERT_BOOKMARK, bHighContrast ) );
+ SetItemImage( BTN_INET_SEARCH, mpManager->GetImage( BTN_INET_SEARCH, bHighContrast ) );
+ SetItemImage( BTN_TARGET, mpManager->GetImage( BTN_TARGET, bHighContrast ) );
+ SetItemImage( BTN_OPENDIALOG, mpManager->GetImage( BTN_OPENDIALOG, bHighContrast ) );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Comboboxen
+ --------------------------------------------------------------------*/
+
+HyperCombo::HyperCombo( SvxHyperlinkDlg* pDialog, const ResId& rResId ) :
+ ComboBox( (Window *)pDialog, rResId )
+{
+ pDlg = pDialog;
+
+ nMaxWidth = GetSizePixel().Width();
+ if (this == &pDlg->aUrlCB)
+ nMinWidth = GetTextWidth(String::CreateFromAscii("http://www.stardiv.dewww"));
+ else
+ nMinWidth = GetTextWidth(String::CreateFromAscii("StarDivision GmbHwww"));
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Comboboxen KeyInput
+ --------------------------------------------------------------------*/
+
+long HyperCombo::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = 0;
+ static BOOL bLocked = FALSE;
+
+ if (bLocked) // Keine weiteren RETURNs annehmen (nicht Reentrant!)
+ return nHandled;
+
+ bLocked = TRUE;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ const KeyCode aKeyCode = pKEvt->GetKeyCode();
+
+ if (aKeyCode.GetCode() == KEY_RETURN)
+ {
+ pDlg->SendToApp(HLINK_DEFAULT);
+ nHandled = 1;
+ }
+ }
+ if (this == &pDlg->aNameCB)
+ pDlg->sOldName = GetText();
+
+ if (!nHandled)
+ nHandled = ComboBox::Notify( rNEvt );
+
+ bLocked = FALSE;
+
+ return nHandled;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Drag&Drop vor dem Combo-Edit abfangen und weiterleiten
+ --------------------------------------------------------------------*/
+
+long HyperCombo::PreNotify( NotifyEvent& rNEvt )
+{
+ long nHandled = 0;
+
+ nHandled = ComboBox::PreNotify( rNEvt );
+
+ return nHandled;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+long HyperCombo::CalcResizeWidth( long nW )
+{
+ long nNewWidth = Max(nMaxWidth - nW * GetRatio() / 100L, nMinWidth);
+
+ if (nNewWidth > nMaxWidth)
+ nNewWidth = nMaxWidth;
+
+ if (nNewWidth != GetSizePixel().Width())
+ return nNewWidth;
+ else
+ return 0; // Kein Resize notwendig
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void HyperCombo::DoResize( long nNewWidth )
+{
+ SetSizePixel(Size(nNewWidth, GetSizePixel().Height()));
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: FixedText
+ --------------------------------------------------------------------*/
+
+HyperFixedText::HyperFixedText( SvxHyperlinkDlg* pDialog, const ResId& rResId ) :
+ FixedInfo( (Window *)pDialog, rResId )
+{
+ pDlg = pDialog;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Webseite der Search-Engine mit Suchergebnissen anzeigen
+ --------------------------------------------------------------------*/
+void SvxHyperlinkDlg::OpenDoc( const String& rURL, SfxViewFrame* pViewFrame )
+{
+ SfxStringItem aName( SID_FILE_NAME, rURL );
+ SfxStringItem aReferer( SID_REFERER, String::CreateFromAscii("private:user") );
+ SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, TRUE );
+ SfxBoolItem aSilent( SID_SILENT, TRUE );
+ SfxBoolItem aReadOnly( SID_DOC_READONLY, TRUE );
+ SfxBoolItem aExternal( SID_BROWSE, TRUE );
+ SfxDispatcher* pDisp = SfxViewFrame::Current() ? SfxViewFrame::Current()->GetDispatcher() : NULL;
+
+ if ( pViewFrame )
+ {
+ SfxFrameItem aView( SID_DOCFRAME, pViewFrame ? &pViewFrame->GetFrame() : NULL );
+ if ( pDisp )
+ pDisp->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aName, &aView, &aNewView, &aSilent, &aReadOnly, &aReferer, &aExternal, 0L );
+ }
+ else if ( pDisp )
+ pDisp->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aName, &aNewView, &aSilent, &aReadOnly, &aReferer, 0L );
+}
+// class SvxHyperlinkDialogWrapper ------------------------------------------
+
+SFX_IMPL_CHILDWINDOW(SvxHyperlinkDlgWrapper, SID_HYPERLINK_INSERT)
+
+/*--------------------------------------------------------------------
+ Beschreibung: Wrapper fuer Hyperlinkleiste
+ --------------------------------------------------------------------*/
+
+SvxHyperlinkDlgWrapper::SvxHyperlinkDlgWrapper( Window* _pParent, USHORT nId,
+ SfxBindings* _pBindings, SfxChildWinInfo* /*pInfo*/ ) :
+
+ SfxChildWindow( _pParent, nId )
+
+{
+ pWindow = new SvxHyperlinkDlg( _pBindings, _pParent );
+ eChildAlignment = SFX_ALIGN_TOP;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+SfxChildWinInfo SvxHyperlinkDlgWrapper::GetInfo() const
+{
+ SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
+ return aInfo;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/hyprlink.hrc b/svx/source/dialog/hyprlink.hrc
new file mode 100644
index 000000000000..87f7c9f893a3
--- /dev/null
+++ b/svx/source/dialog/hyprlink.hrc
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * 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 _SVX_HYPERLINK_HRC
+#define _SVX_HYPERLINK_HRC
+
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+
+#ifndef _SFXSIDS_HRC
+#include <sfx2/sfxsids.hrc>
+#endif
+
+// defines ------------------------------------------------------------------
+
+#define CB_NAME 1
+#define FT_URL 2
+#define CB_URL 3
+#define BTN_LINK SID_HLINKBAR_LINK
+#define BTN_INSERT_BOOKMARK SID_HLINKBAR_BOOKMARK
+#define BTN_INET_SEARCH SID_HLINKBAR_SEARCH
+#define TB 7
+#define MN_FIELD 8
+#define MN_BUTTON 9
+#define BTN_TARGET SID_HLINKBAR_TARGET
+#define STR_ADDRESS 11
+#define STR_EXPLORER 12
+#define STR_BOOKMARK_SEARCH 13
+
+#define BTN_OPENDIALOG SID_HYPERLINK_DIALOG
+
+
+#endif
+
diff --git a/svx/source/dialog/hyprlink.hxx b/svx/source/dialog/hyprlink.hxx
new file mode 100644
index 000000000000..b37c2cf2b241
--- /dev/null
+++ b/svx/source/dialog/hyprlink.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_DLG_HYPERLINK_HXX
+#define _SVX_DLG_HYPERLINK_HXX
+
+#include <sfx2/childwin.hxx>
+#include "svx/svxdllapi.h"
+
+// class SvxHyperlinkDialogWrapper ---------------------------------------
+class SVX_DLLPUBLIC SvxHyperlinkDlgWrapper : public SfxChildWindow
+{
+public:
+ SvxHyperlinkDlgWrapper( Window*pParent, USHORT nId,
+ SfxBindings* pBindings, SfxChildWinInfo* pInfo );
+ SFX_DECL_CHILDWINDOW(SvxHyperlinkDlgWrapper);
+};
+#endif // _SVX_DLG_HYPERLINK_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/hyprlink.src b/svx/source/dialog/hyprlink.src
new file mode 100644
index 000000000000..75d67753407e
--- /dev/null
+++ b/svx/source/dialog/hyprlink.src
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ------------------------------------------------------------------
+#include <svx/dialogs.hrc>
+#include "hyprlink.hrc"
+#include "helpid.hrc"
+#include <svx/svxids.hrc>
+
+ // pragma -------------------------------------------------------------------
+
+ // RID_SVXDLG_HYPERLINK ------------------------------------------------------
+ToolBox RID_SVXDLG_HYPERLINK
+{
+ OutputSize = TRUE ;
+ Hide = TRUE;
+
+ // Dockable = TRUE ;
+ // Closeable = TRUE ;
+ // Moveable = TRUE ;
+ // Sizeable = TRUE ;
+ // EnableResizing = TRUE ;
+
+ SVLook = TRUE ;
+ Border = TRUE ;
+ Size = MAP_APPFONT ( 410 , 17 ) ;
+ Scroll = TRUE ;
+ HelpID = HID_OFA_HYPERLINK_DLG ;
+
+ Text [ en-US ] = "Insert Hyperlink" ;
+
+ ComboBox CB_NAME
+ {
+ HelpID = HID_OFA_HYPERLINK_NAME ;
+ Pos = MAP_APPFONT ( 2 , 3 ) ;
+ Size = MAP_APPFONT ( 100 , 60 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoSize = TRUE ;
+ AutoHScroll = TRUE ;
+ DDExtraWidth = TRUE ;
+ QuickHelpText [ en-US ] = "URL Name" ;
+ };
+ FixedText FT_URL
+ {
+ HelpID = HID_OFA_HYPERLINK_URL_TXT ;
+ Pos = MAP_APPFONT ( 105 , 5 ) ;
+ Size = MAP_APPFONT ( 16 , 10 ) ;
+ Text [ en-US ] = "URL:" ;
+ };
+ ComboBox CB_URL
+ {
+ HelpID = HID_OFA_HYPERLINK_URL ;
+ Pos = MAP_APPFONT ( 121 , 3 ) ;
+ Size = MAP_APPFONT ( 204 , 60 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoSize = TRUE ;
+ AutoHScroll = TRUE ;
+ DDExtraWidth = TRUE ;
+ QuickHelpText [ en-US ] = "Internet URLs" ;
+ };
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ HelpID = HID_OFA_HYPERLINK_TARGET ;
+ Identifier = BTN_TARGET ;
+ DropDown = TRUE ;
+ Text [ en-US ] = "Target Frame" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ HelpID = SID_HYPERLINK_SETLINK ;
+ Identifier = BTN_LINK ;
+ Disable = TRUE ;
+ DropDown = TRUE ;
+ Text [ en-US ] = "Hyperlink" ;
+ };
+ ToolBoxItem
+ {
+ HelpID = SID_CREATELINK ;
+ Identifier = BTN_INSERT_BOOKMARK ;
+ Disable = TRUE ;
+ Hide = TRUE;
+ Text [ en-US ] = "Link" ;
+ };
+ ToolBoxItem
+ {
+ HelpID = HID_OFA_HYPERLINK_SEARCH ;
+ Identifier = BTN_INET_SEARCH ;
+ Disable = TRUE ;
+ DropDown = TRUE ;
+ Text [ en-US ] = "Find" ;
+ };
+ };
+ String STR_ADDRESS
+ {
+ Text [ en-US ] = "Address Book" ;
+ };
+ String STR_EXPLORER
+ {
+ Text [ en-US ] = "Bookmark folder" ;
+ };
+ String STR_BOOKMARK_SEARCH
+ {
+ Text [ en-US ] = "Search in bookmarks";
+ };
+};
+ // PopupMenu -------------------------------------------------------------
+Menu RID_SVXMN_HYPERLINK
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_FIELD ;
+ Text [ en-US ] = "As Text" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_BUTTON ;
+ Text [ en-US ] = "As Button" ;
+ };
+ };
+};
+QueryBox RID_SVXQB_DONTEXIST
+{
+ BUTTONS = WB_YES_NO ;
+ DEFBUTTON = WB_DEF_YES ;
+ Message [ en-US ] = "This URL does not exist.\nInsert anyway?" ;
+};
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/imapdlg.cxx b/svx/source/dialog/imapdlg.cxx
new file mode 100644
index 000000000000..43a2735d148a
--- /dev/null
+++ b/svx/source/dialog/imapdlg.cxx
@@ -0,0 +1,1052 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define _SDR_NOITEMS
+#define _SDR_NOTOUCH
+#define _SDR_NOTRANSFORM
+#define _SDR_NOOBJECTS
+#define _SDR_NOVIEWMARKER
+#define _SDR_NODRAGMETHODS
+#define _SDR_NOUNDO
+#define _SDR_NOXOUTDEV
+
+#include <stdlib.h>
+#include <tools/shl.hxx>
+#include <tools/errinf.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/group.hxx>
+#include <vcl/lstbox.hxx>
+#include <svl/eitem.hxx>
+#include <unotools/pathoptions.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/module.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <svl/urihelper.hxx>
+#include <svtools/miscopt.hxx>
+#include <svtools/ehdl.hxx>
+#include <svtools/sfxecode.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/docfile.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#define _IMAPDLG_PRIVATE
+#include "imapdlg.hxx"
+
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/svxids.hrc>
+#include "imapdlg.hrc"
+#include "imapwnd.hxx"
+#include "imapimp.hxx"
+#include "dlgutil.hxx"
+#include <svx/svdtrans.hxx>
+#include <svx/svdopath.hxx>
+#include <vcl/svapp.hxx>
+
+#define SELF_TARGET "_self"
+#define IMAP_ALL_FILTER "<Alle>"
+#define IMAP_CERN_FILTER "MAP - CERN"
+#define IMAP_NCSA_FILTER "MAP - NCSA"
+#define IMAP_BINARY_FILTER "SIP - StarView ImageMap"
+#define IMAP_ALL_TYPE "*.*"
+#define IMAP_BINARY_TYPE "*.sip"
+#define IMAP_CERN_TYPE "*.map"
+#define IMAP_NCSA_TYPE "*.map"
+#define IMAP_BINARY_EXT "sip"
+#define IMAP_CERN_EXT "map"
+#define IMAP_NCSA_EXT "map"
+
+/******************************************************************************/
+
+SFX_IMPL_MODELESSDIALOG( SvxIMapDlgChildWindow, SID_IMAP );
+
+/******************************************************************************/
+
+inline String GetUnitString( long nVal_100, FieldUnit eFieldUnit, sal_Unicode cSep )
+{
+ String aVal = UniString::CreateFromInt64( MetricField::ConvertValue( nVal_100, 2, MAP_100TH_MM, eFieldUnit ) );
+
+ while( aVal.Len() < 3 )
+ aVal.Insert( sal_Unicode('0'), 0 );
+
+ aVal.Insert( cSep, aVal.Len() - 2 );
+ aVal += sal_Unicode(' ');
+ aVal += SdrFormatter::GetUnitStr( eFieldUnit );
+
+ return aVal;
+}
+
+/*************************************************************************
+|*
+|* ControllerItem
+|*
+\************************************************************************/
+
+SvxIMapDlgItem::SvxIMapDlgItem( USHORT _nId, SvxIMapDlg& rIMapDlg, SfxBindings& rBindings ) :
+ SfxControllerItem ( _nId, rBindings ),
+ rIMap ( rIMapDlg )
+{
+}
+
+/*************************************************************************
+|*
+|* StateChanged-Methode
+|*
+\************************************************************************/
+
+void SvxIMapDlgItem::StateChanged( USHORT nSID, SfxItemState /*eState*/,
+ const SfxPoolItem* pItem )
+{
+ if ( ( nSID == SID_IMAP_EXEC ) && pItem )
+ {
+ const SfxBoolItem* pStateItem = PTR_CAST( SfxBoolItem, pItem );
+
+ DBG_ASSERT( pStateItem || pItem == 0, "SfxBoolItem erwartet");
+
+ // Float ggf. disablen
+ rIMap.SetExecState( !pStateItem->GetValue() );
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SvxIMapDlgChildWindow::SvxIMapDlgChildWindow( Window* _pParent, USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( _pParent, nId )
+{
+ pWindow = new SvxIMapDlg( pBindings, this, _pParent, SVX_RES( RID_SVXDLG_IMAP ) );
+ SvxIMapDlg* pDlg = (SvxIMapDlg*) pWindow;
+
+ if ( pInfo->nFlags & SFX_CHILDWIN_ZOOMIN )
+ pDlg->RollUp();
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+
+ pDlg->Initialize( pInfo );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxIMapDlgChildWindow::UpdateIMapDlg( const Graphic& rGraphic, const ImageMap* pImageMap,
+ const TargetList* pTargetList, void* pEditingObj )
+{
+ if ( SfxViewFrame::Current() &&
+ SfxViewFrame::Current()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
+ SVXIMAPDLG()->Update( rGraphic, pImageMap, pTargetList, pEditingObj );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SvxIMapDlg::SvxIMapDlg( SfxBindings *_pBindings, SfxChildWindow *pCW,
+ Window* _pParent, const ResId& rResId ) :
+ SfxModelessDialog ( _pBindings, pCW, _pParent, rResId ),
+
+ aTbxIMapDlg1 ( this, SVX_RES( TBX_IMAPDLG1 ) ),
+ aFtURL ( this, SVX_RES( FT_URL ) ),
+ maURLBox ( this, SVX_RES( CBB_URL ) ),
+ aFtText ( this, SVX_RES( FT_TEXT ) ),
+ aEdtText ( this, SVX_RES( EDT_TEXT ) ),
+ maFtTarget ( this, SVX_RES( RID_SVXCTL_FT_TARGET ) ),
+ maCbbTarget ( this, SVX_RES( RID_SVXCTL_CBB_TARGET ) ),
+ aStbStatus ( this, WB_BORDER | WB_3DLOOK | WB_LEFT ),
+ maImageList ( SVX_RES( IL_IMAPDLG ) ),
+ maImageListH ( SVX_RES( ILH_IMAPDLG ) ),
+ pCheckObj ( NULL ),
+ aIMapItem ( SID_IMAP_EXEC, *this, *_pBindings )
+{
+ pIMapWnd = new IMapWindow( this, SVX_RES( RID_SVXCTL_IMAP ), _pBindings->GetActiveFrame() );
+
+ ApplyImageList();
+
+ FreeResource();
+
+ pOwnData = new IMapOwnData( this );
+
+ pIMapWnd->SetInfoLink( LINK( this, SvxIMapDlg, InfoHdl ) );
+ pIMapWnd->SetMousePosLink( LINK( this, SvxIMapDlg, MousePosHdl ) );
+ pIMapWnd->SetGraphSizeLink( LINK( this, SvxIMapDlg, GraphSizeHdl ) );
+ pIMapWnd->SetUpdateLink( LINK( this, SvxIMapDlg, StateHdl ) );
+
+ maURLBox.SetModifyHdl( LINK( this, SvxIMapDlg, URLModifyHdl ) );
+ maURLBox.SetSelectHdl( LINK( this, SvxIMapDlg, URLModifyHdl ) );
+ maURLBox.SetLoseFocusHdl( LINK( this, SvxIMapDlg, URLLoseFocusHdl ) );
+ aEdtText.SetModifyHdl( LINK( this, SvxIMapDlg, URLModifyHdl ) );
+ maCbbTarget.SetLoseFocusHdl( LINK( this, SvxIMapDlg, URLLoseFocusHdl ) );
+
+ SvtMiscOptions aMiscOptions;
+ aMiscOptions.AddListenerLink( LINK( this, SvxIMapDlg, MiscHdl ) );
+
+ aTbxIMapDlg1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
+ aTbxIMapDlg1.SetSizePixel( aTbxIMapDlg1.CalcWindowSizePixel() );
+ aTbxIMapDlg1.SetSelectHdl( LINK( this, SvxIMapDlg, TbxClickHdl ) );
+ aTbxIMapDlg1.CheckItem( TBI_SELECT, TRUE );
+ TbxClickHdl( &aTbxIMapDlg1 );
+
+ SetMinOutputSizePixel( aLastSize = GetOutputSizePixel() );
+
+ aStbStatus.InsertItem( 1, 130, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
+ aStbStatus.InsertItem( 2, 10 + GetTextWidth( DEFINE_CONST_UNICODE( " 9999,99 cm / 9999,99 cm ") ), SIB_CENTER | SIB_IN );
+ aStbStatus.InsertItem( 3, 10 + GetTextWidth( DEFINE_CONST_UNICODE( " 9999,99 cm x 9999,99 cm ") ), SIB_CENTER | SIB_IN );
+
+ aFtURL.Disable();
+ maURLBox.Disable();
+ aFtText.Disable();
+ aEdtText.Disable();
+ maFtTarget.Disable();
+ maCbbTarget.Disable();
+ pOwnData->bExecState = FALSE;
+
+ Resize();
+
+ pOwnData->aTimer.SetTimeout( 100 );
+ pOwnData->aTimer.SetTimeoutHdl( LINK( this, SvxIMapDlg, UpdateHdl ) );
+
+ aTbxIMapDlg1.EnableItem( TBI_ACTIVE, FALSE );
+ aTbxIMapDlg1.EnableItem( TBI_MACRO, FALSE );
+ aTbxIMapDlg1.EnableItem( TBI_PROPERTY, FALSE );
+}
+
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+\************************************************************************/
+
+SvxIMapDlg::~SvxIMapDlg()
+{
+ // URL-Liste loeschen
+ delete pIMapWnd;
+ delete pOwnData;
+}
+
+
+/*************************************************************************
+|*
+|* Resize-Methode
+|*
+\************************************************************************/
+
+void SvxIMapDlg::Resize()
+{
+ SfxModelessDialog::Resize();
+
+ Size aMinSize( GetMinOutputSizePixel() );
+ Size aNewSize( GetOutputSizePixel() );
+
+ if ( aNewSize.Height() >= aMinSize.Height() )
+ {
+ Size _aSize( aStbStatus.GetSizePixel() );
+ Point aPoint( 0, aNewSize.Height() - _aSize.Height() );
+
+ // StatusBar positionieren
+ aStbStatus.SetPosSizePixel( aPoint, Size( aNewSize.Width(), _aSize.Height() ) );
+ aStbStatus.Show();
+
+ // EditWindow positionieren
+ _aSize.Width() = aNewSize.Width() - 18;
+ _aSize.Height() = aPoint.Y() - pIMapWnd->GetPosPixel().Y() - 6;
+ pIMapWnd->SetSizePixel( _aSize );
+
+ aLastSize = aNewSize;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Close-Methode
+|*
+\************************************************************************/
+
+BOOL SvxIMapDlg::Close()
+{
+ BOOL bRet = TRUE;
+
+ if ( aTbxIMapDlg1.IsItemEnabled( TBI_APPLY ) )
+ {
+ QueryBox aQBox( this, WB_YES_NO_CANCEL | WB_DEF_YES,
+ String( SVX_RES( STR_IMAPDLG_MODIFY ) ) );
+ const long nRet = aQBox.Execute();
+
+ if( nRet == RET_YES )
+ {
+ SfxBoolItem aBoolItem( SID_IMAP_EXEC, TRUE );
+ GetBindings().GetDispatcher()->Execute(
+ SID_IMAP_EXEC, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
+ }
+ else if( nRet == RET_CANCEL )
+ bRet = FALSE;
+ }
+ else if( pIMapWnd->IsChanged() )
+ {
+ QueryBox aQBox( this, WB_YES_NO_CANCEL | WB_DEF_YES,
+ String( SVX_RES( STR_IMAPDLG_SAVE ) ) );
+ const long nRet = aQBox.Execute();
+
+ if( nRet == RET_YES )
+ bRet = DoSave();
+ else if( nRet == RET_CANCEL )
+ bRet = FALSE;
+ }
+
+ return( bRet ? SfxModelessDialog::Close() : FALSE );
+}
+
+
+/*************************************************************************
+|*
+|* Enabled oder disabled alle Controls
+|*
+\************************************************************************/
+
+void SvxIMapDlg::SetExecState( BOOL bEnable )
+{
+ pOwnData->bExecState = bEnable;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxIMapDlg::SetGraphic( const Graphic& rGraphic )
+{
+ pIMapWnd->SetGraphic( rGraphic );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxIMapDlg::SetImageMap( const ImageMap& rImageMap )
+{
+ pIMapWnd->SetImageMap( rImageMap );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+const ImageMap& SvxIMapDlg::GetImageMap() const
+{
+ return pIMapWnd->GetImageMap();
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxIMapDlg::SetTargetList( const TargetList& rTargetList )
+{
+ TargetList aNewList( rTargetList );
+
+ pIMapWnd->SetTargetList( aNewList );
+
+ maCbbTarget.Clear();
+
+ for( String* pStr = aNewList.First(); pStr; pStr = aNewList.Next() )
+ maCbbTarget.InsertEntry( *pStr );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+const TargetList& SvxIMapDlg::GetTargetList() const
+{
+ return pIMapWnd->GetTargetList();
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxIMapDlg::Update( const Graphic& rGraphic, const ImageMap* pImageMap,
+ const TargetList* pTargetList, void* pEditingObj )
+{
+ pOwnData->aUpdateGraphic = rGraphic;
+
+ if ( pImageMap )
+ pOwnData->aUpdateImageMap = *pImageMap;
+ else
+ pOwnData->aUpdateImageMap.ClearImageMap();
+
+ pOwnData->pUpdateEditingObject = pEditingObj;
+
+ // UpdateTargetList loeschen, da diese Methode
+ // vor dem Zuschlagen des Update-Timers noch
+ // mehrmals gerufen werden kann( #46540 )
+ for( String* pStr = pOwnData->aUpdateTargetList.First(); pStr; pStr = pOwnData->aUpdateTargetList.Next() )
+ delete pStr;
+ pOwnData->aUpdateTargetList.Clear();
+
+ // TargetListe muss kopiert werden, da sie im
+ // Besitz des Aufrufers ist und von ihm nach diesem
+ // Aufruf sofort geloescht werden kann;
+ // die kopierte Liste wird im Handler wieder geloescht
+ if( pTargetList )
+ {
+ TargetList aTargetList( *pTargetList );
+
+ for( String* pStr = aTargetList.First(); pStr; pStr = aTargetList.Next() )
+ pOwnData->aUpdateTargetList.Insert( new String( *pStr ) );
+ }
+
+ pOwnData->aTimer.Start();
+}
+
+
+void SvxIMapDlg::KeyInput( const KeyEvent& rKEvt )
+{
+ SfxModelessDialog::KeyInput( rKEvt );
+}
+
+/*************************************************************************
+|*
+|* Click-Hdl fuer ToolBox
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxIMapDlg, TbxClickHdl, ToolBox*, pTbx )
+{
+ USHORT nNewItemId = pTbx->GetCurItemId();
+
+ switch( pTbx->GetCurItemId() )
+ {
+ case( TBI_APPLY ):
+ {
+ URLLoseFocusHdl( NULL );
+ SfxBoolItem aBoolItem( SID_IMAP_EXEC, TRUE );
+ GetBindings().GetDispatcher()->Execute(
+ SID_IMAP_EXEC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aBoolItem, 0L );
+ }
+ break;
+
+ case( TBI_OPEN ):
+ DoOpen();
+ break;
+
+ case( TBI_SAVEAS ):
+ DoSave();
+ break;
+
+ case( TBI_SELECT ):
+ {
+ pTbx->CheckItem( nNewItemId, TRUE );
+ pIMapWnd->SetEditMode( TRUE );
+ if( pTbx->IsKeyEvent() )
+ {
+ if((pTbx->GetKeyModifier() & KEY_MOD1) != 0)
+ pIMapWnd->SelectFirstObject();
+ else
+ pIMapWnd->GrabFocus();
+ }
+ }
+ break;
+
+ case( TBI_RECT ):
+ {
+ pTbx->CheckItem( nNewItemId, TRUE );
+ pIMapWnd->SetObjKind( OBJ_RECT );
+ if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
+ {
+ pIMapWnd->CreateDefaultObject();
+ pIMapWnd->GrabFocus();
+ }
+ }
+ break;
+
+ case( TBI_CIRCLE ):
+ {
+ pTbx->CheckItem( nNewItemId, TRUE );
+ pIMapWnd->SetObjKind( OBJ_CIRC );
+ if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
+ {
+ pIMapWnd->CreateDefaultObject();
+ pIMapWnd->GrabFocus();
+ }
+ }
+ break;
+
+ case( TBI_POLY ):
+ {
+ pTbx->CheckItem( nNewItemId, TRUE );
+ pIMapWnd->SetObjKind( OBJ_POLY );
+ if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
+ {
+ pIMapWnd->CreateDefaultObject();
+ pIMapWnd->GrabFocus();
+ }
+ }
+ break;
+
+ case( TBI_FREEPOLY ):
+ {
+ pTbx->CheckItem( nNewItemId, TRUE );
+ pIMapWnd->SetObjKind( OBJ_FREEFILL );
+ if( pTbx->IsKeyEvent() && ((pTbx->GetKeyModifier() & KEY_MOD1) != 0) )
+ {
+ pIMapWnd->CreateDefaultObject();
+ pIMapWnd->GrabFocus();
+ }
+ }
+ break;
+
+ case( TBI_ACTIVE ):
+ {
+ URLLoseFocusHdl( NULL );
+ BOOL bNewState = !pTbx->IsItemChecked( TBI_ACTIVE );
+ pTbx->CheckItem( TBI_ACTIVE, bNewState );
+ pIMapWnd->SetCurrentObjState( !bNewState );
+ }
+ break;
+
+ case( TBI_MACRO ):
+ pIMapWnd->DoMacroAssign();
+ break;
+
+ case( TBI_PROPERTY ):
+ pIMapWnd->DoPropertyDialog();
+ break;
+
+ case( TBI_POLYEDIT ):
+ pIMapWnd->SetPolyEditMode( pTbx->IsItemChecked( TBI_POLYEDIT ) ? SID_BEZIER_MOVE : 0 );
+ if( pTbx->IsKeyEvent() && pTbx->IsItemChecked( TBI_POLYEDIT ) )
+ pIMapWnd->StartPolyEdit();
+ break;
+
+ case( TBI_POLYMOVE ):
+ pIMapWnd->SetPolyEditMode( SID_BEZIER_MOVE );
+ break;
+
+ case( TBI_POLYINSERT ):
+ pIMapWnd->SetPolyEditMode( SID_BEZIER_INSERT );
+ break;
+
+ case( TBI_POLYDELETE ):
+ pIMapWnd->GetSdrView()->DeleteMarkedPoints();
+ break;
+
+ case( TBI_UNDO ):
+ {
+ URLLoseFocusHdl( NULL );
+ pIMapWnd->GetSdrModel()->Undo();
+ }
+ break;
+
+ case( TBI_REDO ):
+ {
+ URLLoseFocusHdl( NULL );
+ pIMapWnd->GetSdrModel()->Redo();
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void SvxIMapDlg::DoOpen()
+{
+ ::sfx2::FileDialogHelper aDlg(
+ com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
+
+ ImageMap aLoadIMap;
+ const String aFilter( DEFINE_CONST_UNICODE( IMAP_ALL_FILTER ) );
+
+ aDlg.AddFilter( aFilter, DEFINE_CONST_UNICODE( IMAP_ALL_TYPE ) );
+ aDlg.AddFilter( DEFINE_CONST_UNICODE( IMAP_CERN_FILTER ), DEFINE_CONST_UNICODE( IMAP_CERN_TYPE ) );
+ aDlg.AddFilter( DEFINE_CONST_UNICODE( IMAP_NCSA_FILTER ), DEFINE_CONST_UNICODE( IMAP_NCSA_TYPE ) );
+ aDlg.AddFilter( DEFINE_CONST_UNICODE( IMAP_BINARY_FILTER ), DEFINE_CONST_UNICODE( IMAP_BINARY_TYPE ) );
+
+ aDlg.SetCurrentFilter( aFilter );
+ aDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
+
+ if( aDlg.Execute() == ERRCODE_NONE )
+ {
+ INetURLObject aURL( aDlg.GetPath() );
+ DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+ if( pIStm )
+ {
+ aLoadIMap.Read( *pIStm, IMAP_FORMAT_DETECT, String() );
+
+ if( pIStm->GetError() )
+ {
+ SfxErrorContext eEC(ERRCODE_SFX_GENERAL,this);
+ ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
+ }
+ else
+ pIMapWnd->SetImageMap( aLoadIMap );
+
+ delete pIStm;
+ }
+
+ pIMapWnd->Invalidate();
+ }
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL SvxIMapDlg::DoSave()
+{
+ ::sfx2::FileDialogHelper aDlg(
+ com::sun::star::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE, 0 );
+
+ const String aBinFilter( DEFINE_CONST_UNICODE( IMAP_BINARY_FILTER ) );
+ const String aCERNFilter( DEFINE_CONST_UNICODE( IMAP_CERN_FILTER ) );
+ const String aNCSAFilter( DEFINE_CONST_UNICODE( IMAP_NCSA_FILTER ) );
+ SdrModel* pModel = pIMapWnd->GetSdrModel();
+ const sal_Bool bChanged = pModel->IsChanged();
+ BOOL bRet = false;
+
+ aDlg.AddFilter( aCERNFilter, DEFINE_CONST_UNICODE( IMAP_CERN_TYPE ) );
+ aDlg.AddFilter( aNCSAFilter, DEFINE_CONST_UNICODE( IMAP_NCSA_TYPE ) );
+ aDlg.AddFilter( aBinFilter, DEFINE_CONST_UNICODE( IMAP_BINARY_TYPE ) );
+
+ aDlg.SetCurrentFilter( aCERNFilter );
+ aDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
+
+ if( aDlg.Execute() == ERRCODE_NONE )
+ {
+ const String aFilter( aDlg.GetCurrentFilter() );
+ String aExt;
+ ULONG nFormat;
+
+ if ( aFilter == aBinFilter )
+ {
+ nFormat = IMAP_FORMAT_BIN;
+ aExt = DEFINE_CONST_UNICODE( IMAP_BINARY_EXT );
+ }
+ else if ( aFilter == aCERNFilter )
+ {
+ nFormat = IMAP_FORMAT_CERN;
+ aExt = DEFINE_CONST_UNICODE( IMAP_CERN_EXT );
+ }
+ else if ( aFilter == aNCSAFilter )
+ {
+ nFormat = IMAP_FORMAT_NCSA;
+ aExt = DEFINE_CONST_UNICODE( IMAP_NCSA_EXT );
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ INetURLObject aURL( aDlg.GetPath() );
+
+ if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
+ {
+ DBG_ERROR( "invalid URL" );
+ }
+ else
+ {
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( aExt );
+
+ SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
+ if( pOStm )
+ {
+ pIMapWnd->GetImageMap().Write( *pOStm, nFormat, String() );
+
+ if( pOStm->GetError() )
+ ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
+
+ delete pOStm;
+ pModel->SetChanged( bChanged );
+ bRet = TRUE;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxIMapDlg, InfoHdl, IMapWindow*, pWnd )
+{
+ String aStr;
+ const NotifyInfo& rInfo = pWnd->GetInfo();
+
+ if ( rInfo.bNewObj )
+ {
+ if( rInfo.aMarkURL.Len() && ( maURLBox.GetEntryPos( rInfo.aMarkURL ) == LISTBOX_ENTRY_NOTFOUND ) )
+ maURLBox.InsertEntry( rInfo.aMarkURL );
+
+ maURLBox.SetText( rInfo.aMarkURL );
+ aEdtText.SetText( rInfo.aMarkAltText );
+
+ if ( !rInfo.aMarkTarget.Len() )
+ maCbbTarget.SetText( DEFINE_CONST_UNICODE( SELF_TARGET ) );
+ else
+ maCbbTarget.SetText( rInfo.aMarkTarget );
+ }
+
+ if ( !rInfo.bOneMarked )
+ {
+ aTbxIMapDlg1.CheckItem( TBI_ACTIVE, FALSE );
+ aTbxIMapDlg1.EnableItem( TBI_ACTIVE, FALSE );
+ aTbxIMapDlg1.EnableItem( TBI_MACRO, FALSE );
+ aTbxIMapDlg1.EnableItem( TBI_PROPERTY, FALSE );
+ aStbStatus.SetItemText( 1, aStr );
+
+ aFtURL.Disable();
+ maURLBox.Disable();
+ aFtText.Disable();
+ aEdtText.Disable();
+ maFtTarget.Disable();
+ maCbbTarget.Disable();
+
+ maURLBox.SetText( String() );
+ aEdtText.SetText( String() );
+ }
+ else
+ {
+ aTbxIMapDlg1.EnableItem( TBI_ACTIVE, TRUE );
+ aTbxIMapDlg1.CheckItem( TBI_ACTIVE, !rInfo.bActivated );
+ aTbxIMapDlg1.EnableItem( TBI_MACRO, TRUE );
+ aTbxIMapDlg1.EnableItem( TBI_PROPERTY, TRUE );
+
+ aFtURL.Enable();
+ maURLBox.Enable();
+ aFtText.Enable();
+ aEdtText.Enable();
+ maFtTarget.Enable();
+ maCbbTarget.Enable();
+
+ aStbStatus.SetItemText( 1, rInfo.aMarkURL );
+
+ if ( maURLBox.GetText() != rInfo.aMarkURL )
+ maURLBox.SetText( rInfo.aMarkURL );
+
+ if ( aEdtText.GetText() != rInfo.aMarkAltText )
+ aEdtText.SetText( rInfo.aMarkAltText );
+
+ if ( !rInfo.aMarkTarget.Len() )
+ maCbbTarget.SetText( DEFINE_CONST_UNICODE( SELF_TARGET ) );
+ else
+ maCbbTarget.SetText( rInfo.aMarkTarget );
+ }
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxIMapDlg, MousePosHdl, IMapWindow*, pWnd )
+{
+ String aStr;
+ const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
+ const Point& rMousePos = pWnd->GetMousePos();
+ LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
+ const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
+
+ aStr.Assign( GetUnitString( rMousePos.X(), eFieldUnit, cSep ) );
+ aStr.Append( DEFINE_CONST_UNICODE( " / " ) );
+ aStr.Append( GetUnitString( rMousePos.Y(), eFieldUnit, cSep ) );
+
+ aStbStatus.SetItemText( 2, aStr );
+
+ return 0L;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxIMapDlg, GraphSizeHdl, IMapWindow*, pWnd )
+{
+ String aStr;
+ const FieldUnit eFieldUnit = GetBindings().GetDispatcher()->GetModule()->GetFieldUnit();
+ const Size& rSize = pWnd->GetGraphicSize();
+ LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
+ const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
+
+ aStr.Assign( GetUnitString( rSize.Width(), eFieldUnit, cSep ) );
+ aStr.Append( DEFINE_CONST_UNICODE( " x " ) );
+ aStr.Append( GetUnitString( rSize.Height(), eFieldUnit, cSep ) );
+
+ aStbStatus.SetItemText( 3, aStr );
+
+ return 0L;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxIMapDlg, URLModifyHdl, void*, EMPTYARG )
+{
+ NotifyInfo aNewInfo;
+
+ aNewInfo.aMarkURL = maURLBox.GetText();
+ aNewInfo.aMarkAltText = aEdtText.GetText();
+ aNewInfo.aMarkTarget = maCbbTarget.GetText();
+
+ pIMapWnd->ReplaceActualIMapInfo( aNewInfo );
+
+ return 0;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxIMapDlg, URLLoseFocusHdl, void*, EMPTYARG )
+{
+ NotifyInfo aNewInfo;
+ const String aURLText( maURLBox.GetText() );
+ const String aTargetText( maCbbTarget.GetText() );
+
+ if ( aURLText.Len() )
+ {
+ String aBase = GetBindings().GetDispatcher()->GetFrame()->GetObjectShell()->GetMedium()->GetBaseURL();
+ aNewInfo.aMarkURL = ::URIHelper::SmartRel2Abs( INetURLObject(aBase), aURLText, URIHelper::GetMaybeFileHdl(), true, false,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_UNAMBIGUOUS );
+ }
+ else
+ aNewInfo.aMarkURL = aURLText;
+
+ aNewInfo.aMarkAltText = aEdtText.GetText();
+
+ if ( !aTargetText.Len() )
+ aNewInfo.aMarkTarget = DEFINE_CONST_UNICODE( SELF_TARGET );
+ else
+ aNewInfo.aMarkTarget = aTargetText;
+
+ pIMapWnd->ReplaceActualIMapInfo( aNewInfo );
+
+ return 0;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxIMapDlg, UpdateHdl, Timer*, EMPTYARG )
+{
+ pOwnData->aTimer.Stop();
+
+ if ( pOwnData->pUpdateEditingObject != pCheckObj )
+ {
+ if ( pIMapWnd->IsChanged() &&
+ ( QueryBox( this, WB_YES_NO | WB_DEF_YES,
+ String( SVX_RES( STR_IMAPDLG_SAVE ) ) ).Execute() == RET_YES ) )
+ {
+ DoSave();
+ }
+
+ SetGraphic( pOwnData->aUpdateGraphic );
+ SetImageMap( pOwnData->aUpdateImageMap );
+ SetTargetList( pOwnData->aUpdateTargetList );
+ SetEditingObject( pOwnData->pUpdateEditingObject );
+
+ // Nach Wechsel => default Selektion
+ aTbxIMapDlg1.CheckItem( TBI_SELECT, TRUE );
+ pIMapWnd->SetEditMode( TRUE );
+ }
+
+ // die in der Update-Methode kopierte Liste wieder loeschen
+ for( String* pStr = pOwnData->aUpdateTargetList.First(); pStr; pStr = pOwnData->aUpdateTargetList.Next() )
+ delete pStr;
+
+ pOwnData->aUpdateTargetList.Clear();
+
+ GetBindings().Invalidate( SID_IMAP_EXEC );
+
+ return 0L;
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxIMapDlg, StateHdl, IMapWindow*, pWnd )
+{
+ const SdrObject* pObj = pWnd->GetSelectedSdrObject();
+ const SdrModel* pModel = pWnd->GetSdrModel();
+ const SdrView* pView = pWnd->GetSdrView();
+ const BOOL bPolyEdit = ( pObj != NULL ) && pObj->ISA( SdrPathObj );
+ const BOOL bDrawEnabled = !( bPolyEdit && aTbxIMapDlg1.IsItemChecked( TBI_POLYEDIT ) );
+
+ aTbxIMapDlg1.EnableItem( TBI_APPLY, pOwnData->bExecState && pWnd->IsChanged() );
+
+ aTbxIMapDlg1.EnableItem( TBI_SELECT, bDrawEnabled );
+ aTbxIMapDlg1.EnableItem( TBI_RECT, bDrawEnabled );
+ aTbxIMapDlg1.EnableItem( TBI_CIRCLE, bDrawEnabled );
+ aTbxIMapDlg1.EnableItem( TBI_POLY, bDrawEnabled );
+ aTbxIMapDlg1.EnableItem( TBI_FREEPOLY, bDrawEnabled );
+
+ // BezierEditor-Stati
+ aTbxIMapDlg1.EnableItem( TBI_POLYEDIT, bPolyEdit );
+ aTbxIMapDlg1.EnableItem( TBI_POLYMOVE, !bDrawEnabled );
+ aTbxIMapDlg1.EnableItem( TBI_POLYINSERT, !bDrawEnabled );
+ aTbxIMapDlg1.EnableItem( TBI_POLYDELETE, !bDrawEnabled && pView->IsDeleteMarkedPointsPossible() );
+
+ // Undo/Redo
+ aTbxIMapDlg1.EnableItem( TBI_UNDO, pModel->GetUndoActionCount() > 0 );
+ aTbxIMapDlg1.EnableItem( TBI_REDO, pModel->GetRedoActionCount() > 0 );
+
+ if ( bPolyEdit )
+ {
+ USHORT nId = 0;
+
+ switch( pWnd->GetPolyEditMode() )
+ {
+ case( SID_BEZIER_MOVE ): nId = TBI_POLYMOVE; break;
+ case( SID_BEZIER_INSERT ): nId = TBI_POLYINSERT; break;
+
+ default:
+ break;
+ }
+
+ aTbxIMapDlg1.CheckItem( nId, TRUE );
+ }
+ else
+ {
+ aTbxIMapDlg1.CheckItem( TBI_POLYEDIT, FALSE );
+ aTbxIMapDlg1.CheckItem( TBI_POLYMOVE, TRUE );
+ aTbxIMapDlg1.CheckItem( TBI_POLYINSERT, FALSE );
+ pWnd->SetPolyEditMode( 0 );
+ }
+
+ return 0L;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxIMapDlg, MiscHdl, void*, EMPTYARG )
+{
+ SvtMiscOptions aMiscOptions;
+ aTbxIMapDlg1.SetOutStyle( aMiscOptions.GetToolboxStyle() );
+
+ return 0L;
+}
+
+void SvxIMapDlg::ApplyImageList()
+{
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ ImageList& rImgLst = bHighContrast ? maImageListH : maImageList;
+
+ aTbxIMapDlg1.SetImageList( rImgLst );
+}
+
+void SvxIMapDlg::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ SfxModelessDialog::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ ApplyImageList();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/imapdlg.hrc b/svx/source/dialog/imapdlg.hrc
new file mode 100644
index 000000000000..5247836d25eb
--- /dev/null
+++ b/svx/source/dialog/imapdlg.hrc
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <svx/dialogs.hrc>
+
+
+// ImapDlg-Dialoge
+#define RID_SVX_IMAPDLG_START RID_SVX_IMAP_START
+
+
+/******************************************************************************/
+
+
+#define RID_SVXDLG_IMAP (RID_SVX_IMAPDLG_START)
+#define RID_SVXCTL_IMAP (RID_SVX_IMAPDLG_START + 7)
+
+#define TBX_IMAPDLG1 1
+#define TBI_APPLY 1
+#define TBI_OPEN 2
+#define TBI_SAVEAS 3
+
+#define TBI_SELECT 4
+#define TBI_RECT 5
+#define TBI_CIRCLE 6
+#define TBI_POLY 7
+#define TBI_FREEPOLY 8
+
+#define TBI_ACTIVE 16
+#define TBI_COLOR 17
+#define TBI_MACRO 18
+#define TBI_PROPERTY 19
+
+#define TBI_POLYEDIT 30
+#define TBI_POLYMOVE 31
+#define TBI_POLYINSERT 32
+#define TBI_POLYDELETE 33
+
+#define TBI_UNDO 40
+#define TBI_REDO 41
+
+#define FT_URL 1
+#define FT_TEXT 2
+#define FT_TARG 3
+#define CBB_URL 1
+#define EDT_TEXT 1
+#define LB_TARG 1
+
+#define STB_STATUS 1
+
+#define IL_IMAPDLG 1024
+#define ILH_IMAPDLG 1025
+
+/******************************************************************************/
+
+
+#define RID_SVXMN_IMAP (RID_SVX_IMAPDLG_START + 1)
+
+#define MN_URL 1
+#define MN_POSITION 2
+#define MN_FRAME_TO_TOP 3
+#define MN_MOREFRONT 4
+#define MN_MOREBACK 5
+#define MN_FRAME_TO_BOTTOM 6
+#define MN_MARK_ALL 7
+#define MN_DELETE1 8
+#define MN_ACTIVATE 9
+#define MN_MACRO 10
+
+/******************************************************************************/
+
+
+#define RID_SVXCTL_FT_TARGET (RID_SVX_IMAPDLG_START + 3)
+#define RID_SVXCTL_CBB_TARGET (RID_SVX_IMAPDLG_START + 4)
+
+
+/******************************************************************************/
+
+
+#define STR_IMAPDLG_SAVE (RID_SVX_IMAPDLG_START + 5)
+#define STR_IMAPDLG_MODIFY (RID_SVX_IMAPDLG_START + 6)
+
+
+/******************************************************************************/
diff --git a/svx/source/dialog/imapdlg.src b/svx/source/dialog/imapdlg.src
new file mode 100644
index 000000000000..6c4facd2f00f
--- /dev/null
+++ b/svx/source/dialog/imapdlg.src
@@ -0,0 +1,365 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include "helpid.hrc"
+#include "imapdlg.hrc"
+ // pragma ----------------------------------------------------------------
+
+ // RID_SVXDLG_IMAP ----------------------------------------------------
+ModelessDialog RID_SVXDLG_IMAP
+{
+ OutputSize = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 270 , 213 ) ;
+ Sizeable = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ ToolBox TBX_IMAPDLG1
+ {
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ HelpId = HID_IMAPDLG_TOOLBOX ;
+
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = TBI_APPLY ;
+ HelpId = HID_IMAPDLG_APPLY ;
+ Text [ en-US ] = "Apply" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_OPEN ;
+ HelpId = HID_IMAPDLG_OPEN ;
+ Text [ en-US ] = "Open..." ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_SAVEAS ;
+ HelpId = HID_IMAPDLG_SAVEAS ;
+
+ Text [ en-US ] = "Save..." ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_SELECT ;
+ HelpId = HID_IMAPDLG_SELECT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ Text [ en-US ] = "Select" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_RECT ;
+ HelpId = HID_IMAPDLG_RECT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ Text [ en-US ] = "Rectangle" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_CIRCLE ;
+ HelpId = HID_IMAPDLG_CIRCLE ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ Text [ en-US ] = "Ellipse" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_POLY ;
+ HelpId = HID_IMAPDLG_POLY ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ Text [ en-US ] = "Polygon" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_FREEPOLY ;
+ HelpId = HID_IMAPDLG_FREEPOLY ;
+ Text [ en-US ] = "Freeform Polygon" ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_POLYEDIT ;
+ HelpId = HID_IMAPDLG_POLYEDIT ;
+ Text [ en-US ] = "Edit Points" ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_POLYMOVE ;
+ HelpId = HID_IMAPDLG_POLYMOVE ;
+ Text [ en-US ] = "Move Points" ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_POLYINSERT ;
+ HelpId = HID_IMAPDLG_POLYINSERT ;
+ Text [ en-US ] = "Insert Points" ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_POLYDELETE ;
+ HelpId = HID_IMAPDLG_POLYDELETE ;
+ Text [ en-US ] = "Delete Points" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_UNDO ;
+ HelpId = HID_IMAPDLG_UNDO ;
+ Text [ en-US ] = "Undo " ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_REDO ;
+ HelpId = HID_IMAPDLG_REDO ;
+ Text [ en-US ] = "Redo" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_ACTIVE ;
+ HelpId = HID_IMAPDLG_ACTIVE ;
+ Text [ en-US ] = "Active" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_MACRO ;
+ HelpId = HID_IMAPDLG_MACRO ;
+ Text [ en-US ] = "Macro..." ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_PROPERTY ;
+ HelpId = HID_IMAPDLG_PROPERTY ;
+ Text [ en-US ] = "Properties..." ;
+ };
+ };
+ };
+
+ FixedText FT_URL
+ {
+ Pos = MAP_APPFONT ( 6 , 25 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ Text [ en-US ] = "Address:" ;
+ };
+ ComboBox CBB_URL
+ {
+ Pos = MAP_APPFONT ( 39 , 23 ) ;
+ Size = MAP_APPFONT ( 225 , 69 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoSize = TRUE ;
+ AutoHScroll = TRUE ;
+ };
+ FixedText FT_TEXT
+ {
+ Pos = MAP_APPFONT ( 6 , 43 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ Text [ en-US ] = "Text:" ;
+ };
+ Edit EDT_TEXT
+ {
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 39 , 41 ) ;
+ Size = MAP_APPFONT ( 143 , 12 ) ;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ };
+ Text [ en-US ] = "ImageMap Editor" ;
+
+ FixedText RID_SVXCTL_FT_TARGET
+ {
+ Pos = MAP_APPFONT ( 188 , 43 ) ;
+ Size = MAP_APPFONT ( 22 , 12 ) ;
+ Text [ en-US ] = "Frame:" ;
+ };
+ // nur temporaer
+ ComboBox RID_SVXCTL_CBB_TARGET
+ {
+ Border = TRUE ;
+ Sort = TRUE ;
+ Pos = MAP_APPFONT ( 213 , 41 ) ;
+ Size = MAP_APPFONT ( 51 , 50 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ HScroll = TRUE ;
+ };
+
+
+#define IMAPDLG_IDLIST \
+ IdList = \
+ { \
+ TBI_APPLY ; \
+ TBI_OPEN ; \
+ TBI_SAVEAS ; \
+ TBI_SELECT ; \
+ TBI_RECT ; \
+ TBI_CIRCLE ; \
+ TBI_POLY ; \
+ TBI_FREEPOLY ; \
+ TBI_POLYEDIT ; \
+ TBI_POLYMOVE ; \
+ TBI_POLYINSERT ; \
+ TBI_POLYDELETE ; \
+ TBI_UNDO ; \
+ TBI_REDO ; \
+ TBI_ACTIVE ; \
+ TBI_MACRO ; \
+ TBI_PROPERTY ; \
+ }; \
+ IdCount = { 17 ; };
+
+ ImageList IL_IMAPDLG
+ {
+ Prefix = "id";
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; } ;
+ IMAPDLG_IDLIST
+ };
+ ImageList ILH_IMAPDLG
+ {
+ Prefix = "idh";
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; } ;
+ IMAPDLG_IDLIST
+ };
+};
+Control RID_SVXCTL_IMAP
+{
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 56 ) ;
+ HelpId = HID_IMAPDLG_GRAPHWND ;
+};
+
+/******************************************************************************/
+Menu RID_SVXMN_IMAP
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_URL ;
+ Text [ en-US ] = "Description..." ;
+ };
+ MenuItem
+ {
+ Identifier = MN_MACRO ;
+ Text [ en-US ] = "~Macro..." ;
+ };
+ MenuItem
+ {
+ Identifier = MN_ACTIVATE ;
+ Text [ en-US ] = "Active" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_POSITION ;
+ Text [ en-US ] = "Arrange" ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_FRAME_TO_TOP ;
+ Text [ en-US ] = "Bring to Front" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_MOREFRONT ;
+ Text [ en-US ] = "Bring ~Forward" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_MOREBACK ;
+ Text [ en-US ] = "Send Back~ward" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_FRAME_TO_BOTTOM ;
+ Text [ en-US ] = "~Send to Back" ;
+ };
+ };
+ };
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_MARK_ALL ;
+ Text [ en-US ] = "Select ~All" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_DELETE1 ;
+ Text [ en-US ] = "~Delete" ;
+ };
+ };
+};
+
+/******************************************************************************/
+
+String STR_IMAPDLG_SAVE
+{
+ Text [ en-US ] = "The ImageMap has been modified.\nDo you want to save the changes?";
+};
+
+String STR_IMAPDLG_MODIFY
+{
+ Text [ en-US ] = "The ImageMap has been modified.\nDo you want to save the changes?" ;
+};
diff --git a/svx/source/dialog/imapimp.hxx b/svx/source/dialog/imapimp.hxx
new file mode 100644
index 000000000000..4887298e3568
--- /dev/null
+++ b/svx/source/dialog/imapimp.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _IMAPIMP_HXX_
+#define _IMAPIMP_HXX_
+
+// ---------------
+// - IMapOwnData -
+// ---------------
+
+class IMapOwnData
+{
+private:
+
+ SvxIMapDlg* pIMap;
+
+public:
+
+ Timer aTimer;
+ Timer aTbxTimer;
+ Graphic aUpdateGraphic;
+ ImageMap aUpdateImageMap;
+ TargetList aUpdateTargetList;
+ void* pUpdateEditingObject;
+ BOOL bExecState;
+
+ IMapOwnData( SvxIMapDlg* pIMapDlg ) : pIMap ( pIMapDlg ) {}
+};
+
+
+#endif // _IMAPIMP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx
new file mode 100644
index 000000000000..5e417a61b67d
--- /dev/null
+++ b/svx/source/dialog/imapwnd.cxx
@@ -0,0 +1,1072 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/urlobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/help.hxx>
+#include <sfx2/sfxsids.hrc> // SID_ATTR_MACROITEM
+#define _ANIMATION
+#include <svtools/imaprect.hxx>
+#include <svtools/imapcirc.hxx>
+#include <svtools/imappoly.hxx>
+#include <svl/urlbmk.hxx>
+
+#include <xoutbmp.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/svxids.hrc>
+#include <imapdlg.hrc>
+#include <imapwnd.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdorect.hxx>
+#include <svx/svdocirc.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/svdpagv.hxx>
+#include <svl/urihelper.hxx>
+#include <svx/xfillit.hxx>
+#include <svx/xlineit.hxx>
+#include <sfx2/evntconf.hxx>
+
+#include <sot/formats.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+using ::com::sun::star::frame::XFrame;
+using ::com::sun::star::uno::Reference;
+
+#define TRANSCOL Color( COL_WHITE )
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMapWindow::IMapWindow( Window* pParent, const ResId& rResId, const Reference< XFrame >& rxDocumentFrame ) :
+ GraphCtrl( pParent, rResId ),
+ DropTargetHelper( this ),
+ mxDocumentFrame( rxDocumentFrame )
+{
+ SetWinStyle( WB_SDRMODE );
+
+ pItemInfo = new SfxItemInfo[ 1 ];
+ memset( pItemInfo, 0, sizeof( SfxItemInfo ) );
+ pIMapPool = new SfxItemPool( String::CreateFromAscii( "IMapItemPool" ),
+ SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, pItemInfo );
+ pIMapPool->FreezeIdRanges();
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMapWindow::~IMapWindow()
+{
+ // Liste loeschen
+ for( String* pStr = aTargetList.First(); pStr; pStr = aTargetList.Next() )
+ delete pStr;
+
+ SfxItemPool::Free(pIMapPool);
+ delete[] pItemInfo;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::SetImageMap( const ImageMap& rImageMap )
+{
+ ReplaceImageMap( rImageMap, FALSE );
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::ReplaceImageMap( const ImageMap& rImageMap, BOOL /*bScaleToGraphic*/ )
+{
+ SdrPage* pPage = 0;
+ aIMap = rImageMap;
+
+ if(GetSdrModel())
+ {
+ // try to access page
+ pPage = GetSdrModel()->GetPage(0L);
+ }
+
+ if(pPage)
+ {
+ // clear all draw objects
+ pPage->Clear();
+ }
+
+ if(GetSdrView())
+ {
+ // #i63762# reset selection at view
+ GetSdrView()->UnmarkAllObj();
+ }
+
+ // create new drawing objects
+ const USHORT nCount(rImageMap.GetIMapObjectCount());
+
+ for ( USHORT i(nCount); i > 0; i-- )
+ {
+ SdrObject* pNewObj = CreateObj( rImageMap.GetIMapObject( i - 1 ) );
+
+ if ( pNewObj )
+ {
+ pPage->InsertObject( pNewObj );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+BOOL IMapWindow::ReplaceActualIMapInfo( const NotifyInfo& rNewInfo )
+{
+ const SdrObject* pSdrObj = GetSelectedSdrObject();
+ IMapObject* pIMapObj;
+ BOOL bRet = FALSE;
+
+ if ( pSdrObj && ( ( pIMapObj = GetIMapObj( pSdrObj ) ) != NULL ) )
+ {
+ pIMapObj->SetURL( rNewInfo.aMarkURL );
+ pIMapObj->SetAltText( rNewInfo.aMarkAltText );
+ pIMapObj->SetTarget( rNewInfo.aMarkTarget );
+ pModel->SetChanged( sal_True );
+ UpdateInfo( FALSE );
+
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+const ImageMap& IMapWindow::GetImageMap()
+{
+ if ( pModel->IsChanged() )
+ {
+ SdrPage* pPage = (SdrPage*) pModel->GetPage( 0 );
+
+ if ( pPage )
+ {
+ const long nCount = pPage->GetObjCount();
+
+ aIMap.ClearImageMap();
+
+ for ( long i = nCount - 1; i > -1; i-- )
+ aIMap.InsertIMapObject( *( ( (IMapUserData*) pPage->GetObj( i )->GetUserData( 0 ) )->GetObject() ) );
+ }
+
+ pModel->SetChanged( sal_False );
+ }
+
+ return aIMap;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::SetTargetList( TargetList& rTargetList )
+{
+ String* pStr;
+
+ // alte Liste loeschen
+ for( pStr = aTargetList.First(); pStr; pStr = aTargetList.Next() )
+ delete pStr;
+
+ aTargetList.Clear();
+
+ // mit uebergebener Liste fuellen
+ for( pStr = rTargetList.First(); pStr; pStr = rTargetList.Next() )
+ aTargetList.Insert( new String( *pStr ) );
+
+ pModel->SetChanged( sal_False );
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SdrObject* IMapWindow::CreateObj( const IMapObject* pIMapObj )
+{
+ Point aPoint;
+ Rectangle aClipRect( aPoint, GetGraphicSize() );
+ SdrObject* pSdrObj = NULL;
+ IMapObjectPtr pCloneIMapObj;
+
+ switch( pIMapObj->GetType() )
+ {
+ case( IMAP_OBJ_RECTANGLE ):
+ {
+ IMapRectangleObject* pIMapRectObj = (IMapRectangleObject*) pIMapObj;
+ Rectangle aDrawRect( pIMapRectObj->GetRectangle( FALSE ) );
+
+ // auf Zeichenflaeche clippen
+ aDrawRect.Intersection( aClipRect );
+
+ pSdrObj = (SdrObject*) new SdrRectObj( aDrawRect );
+ pCloneIMapObj.reset((IMapObject*) new IMapRectangleObject( *pIMapRectObj ));
+ }
+ break;
+
+ case( IMAP_OBJ_CIRCLE ):
+ {
+ IMapCircleObject* pIMapCircleObj = (IMapCircleObject*) pIMapObj;
+ const Point aCenter( pIMapCircleObj->GetCenter( FALSE ) );
+ const long nRadius = pIMapCircleObj->GetRadius( FALSE );
+ const Point aOffset( nRadius, nRadius );
+ Rectangle aCircle( aCenter - aOffset, aCenter + aOffset );
+
+ // auf Zeichenflaeche begrenzen
+ aCircle.Intersection( aClipRect );
+
+ pSdrObj = (SdrObject*) new SdrCircObj( OBJ_CIRC, aCircle, 0, 36000 );
+ pCloneIMapObj.reset((IMapObject*) new IMapCircleObject( *pIMapCircleObj ));
+ }
+ break;
+
+ case( IMAP_OBJ_POLYGON ):
+ {
+ IMapPolygonObject* pIMapPolyObj = (IMapPolygonObject*) pIMapObj;
+
+ // Falls wir eigentlich eine Ellipse sind,
+ // erzeugen wir auch wieder eine Ellipse
+ if ( pIMapPolyObj->HasExtraEllipse() )
+ {
+ Rectangle aDrawRect( pIMapPolyObj->GetExtraEllipse() );
+
+ // auf Zeichenflaeche clippen
+ aDrawRect.Intersection( aClipRect );
+
+ pSdrObj = (SdrObject*) new SdrCircObj( OBJ_CIRC, aDrawRect, 0, 36000 );
+ }
+ else
+ {
+ const Polygon& rPoly = pIMapPolyObj->GetPolygon( FALSE );
+ Polygon aDrawPoly( rPoly );
+
+ // auf Zeichenflaeche clippen
+ aDrawPoly.Clip( aClipRect );
+
+ basegfx::B2DPolygon aPolygon;
+ aPolygon.append(aDrawPoly.getB2DPolygon());
+ pSdrObj = (SdrObject*)new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aPolygon));
+ }
+
+ pCloneIMapObj.reset((IMapObject*) new IMapPolygonObject( *pIMapPolyObj ));
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if ( pSdrObj )
+ {
+ SfxItemSet aSet( pModel->GetItemPool() );
+
+ aSet.Put( XFillStyleItem( XFILL_SOLID ) );
+ aSet.Put( XFillColorItem( String(), TRANSCOL ) );
+
+ if ( !pIMapObj->IsActive() )
+ {
+ aSet.Put( XFillTransparenceItem( 100 ) );
+ aSet.Put( XLineColorItem( String(), Color( COL_RED ) ) );
+ }
+ else
+ {
+ aSet.Put( XFillTransparenceItem( 50 ) );
+ aSet.Put( XLineColorItem( String(), Color( COL_BLACK ) ) );
+ }
+
+ //pSdrObj->SetItemSetAndBroadcast(aSet);
+ pSdrObj->SetMergedItemSetAndBroadcast(aSet);
+
+ pSdrObj->InsertUserData( new IMapUserData( pCloneIMapObj ) );
+ pSdrObj->SetUserCall( GetSdrUserCall() );
+ }
+
+ return pSdrObj;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::InitSdrModel()
+{
+ GraphCtrl::InitSdrModel();
+
+ SfxItemSet aSet( pModel->GetItemPool() );
+
+ aSet.Put( XFillColorItem( String(), TRANSCOL ) );
+ aSet.Put( XFillTransparenceItem( 50 ) );
+ pView->SetAttributes( aSet );
+ pView->SetFrameDragSingles( TRUE );
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::SdrObjCreated( const SdrObject& rObj )
+{
+ switch( rObj.GetObjIdentifier() )
+ {
+ case( OBJ_RECT ):
+ {
+ SdrRectObj* pRectObj = (SdrRectObj*) &rObj;
+ IMapRectangleObject* pObj = new IMapRectangleObject( pRectObj->GetLogicRect(),
+ String(), String(), String(), String(), String(), TRUE, FALSE );
+
+ pRectObj->InsertUserData( new IMapUserData( IMapObjectPtr(pObj) ) );
+ }
+ break;
+
+ case( OBJ_CIRC ):
+ {
+ SdrCircObj* pCircObj = (SdrCircObj*) &rObj;
+ SdrPathObj* pPathObj = (SdrPathObj*) pCircObj->ConvertToPolyObj( FALSE, FALSE );
+ Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0L));
+ delete pPathObj;
+
+ IMapPolygonObject* pObj = new IMapPolygonObject( Polygon(aPoly), String(), String(), String(), String(), String(), TRUE, FALSE );
+ pObj->SetExtraEllipse( aPoly.GetBoundRect() );
+ pCircObj->InsertUserData( new IMapUserData( IMapObjectPtr(pObj) ) );
+ }
+ break;
+
+ case( OBJ_POLY ):
+ case( OBJ_FREEFILL ):
+ case( OBJ_PATHPOLY ):
+ case( OBJ_PATHFILL ):
+ {
+ SdrPathObj* pPathObj = (SdrPathObj*) &rObj;
+ const basegfx::B2DPolyPolygon& rXPolyPoly = pPathObj->GetPathPoly();
+
+ if ( rXPolyPoly.count() )
+ {
+ Polygon aPoly(rXPolyPoly.getB2DPolygon(0L));
+ IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, String(), String(), String(), String(), String(), TRUE, FALSE );
+ pPathObj->InsertUserData( new IMapUserData( IMapObjectPtr(pObj) ) );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::SdrObjChanged( const SdrObject& rObj )
+{
+ IMapUserData* pUserData = (IMapUserData*) rObj.GetUserData( 0 );
+
+ if ( pUserData )
+ {
+ String aURL;
+ String aAltText;
+ String aDesc;
+ String aTarget;
+ IMapObjectPtr pIMapObj = pUserData->GetObject();
+ BOOL bActive = TRUE;
+
+ if ( pIMapObj.get() )
+ {
+ aURL = pIMapObj->GetURL();
+ aAltText = pIMapObj->GetAltText();
+ aDesc = pIMapObj->GetDesc();
+ aTarget = pIMapObj->GetTarget();
+ bActive = pIMapObj->IsActive();
+ }
+
+ switch( rObj.GetObjIdentifier() )
+ {
+ case( OBJ_RECT ):
+ {
+ pUserData->ReplaceObject( IMapObjectPtr(new IMapRectangleObject( ( (const SdrRectObj&) rObj ).GetLogicRect(),
+ aURL, aAltText, aDesc, aTarget, String(), bActive, FALSE ) ) );
+ }
+ break;
+
+ case( OBJ_CIRC ):
+ {
+ const SdrCircObj& rCircObj = (const SdrCircObj&) rObj;
+ SdrPathObj* pPathObj = (SdrPathObj*) rCircObj.ConvertToPolyObj( FALSE, FALSE );
+ Polygon aPoly(pPathObj->GetPathPoly().getB2DPolygon(0L));
+
+ IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, String(), bActive, FALSE );
+ pObj->SetExtraEllipse( aPoly.GetBoundRect() );
+
+ // wurde von uns nur temporaer angelegt
+ delete pPathObj;
+ pUserData->ReplaceObject( IMapObjectPtr(pObj) );
+ }
+ break;
+
+ case( OBJ_POLY ):
+ case( OBJ_FREEFILL ):
+ case( OBJ_PATHPOLY ):
+ case( OBJ_PATHFILL ):
+ {
+ const SdrPathObj& rPathObj = (const SdrPathObj&) rObj;
+ const basegfx::B2DPolyPolygon& rXPolyPoly = rPathObj.GetPathPoly();
+
+ if ( rXPolyPoly.count() )
+ {
+ Polygon aPoly(rPathObj.GetPathPoly().getB2DPolygon(0L));
+ IMapPolygonObject* pObj = new IMapPolygonObject( aPoly, aURL, aAltText, aDesc, aTarget, String(), bActive, FALSE );
+ pUserData->ReplaceObject( IMapObjectPtr(pObj) );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ GraphCtrl::MouseButtonUp( rMEvt );
+ UpdateInfo( TRUE );
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::MarkListHasChanged()
+{
+ GraphCtrl::MarkListHasChanged();
+ UpdateInfo( FALSE );
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SdrObject* IMapWindow::GetHitSdrObj( const Point& rPosPixel ) const
+{
+ SdrObject* pObj = NULL;
+ Point aPt = PixelToLogic( rPosPixel );
+
+ if ( Rectangle( Point(), GetGraphicSize() ).IsInside( aPt ) )
+ {
+ SdrPage* pPage = (SdrPage*) pModel->GetPage( 0 );
+ ULONG nCount;
+
+ if ( pPage && ( ( nCount = pPage->GetObjCount() ) > 0 ) )
+ {
+ for ( long i = nCount - 1; i >= 0; i-- )
+ {
+ SdrObject* pTestObj = pPage->GetObj( i );
+ IMapObject* pIMapObj = GetIMapObj( pTestObj );
+
+ if ( pIMapObj && pIMapObj->IsHit( aPt ) )
+ {
+ pObj = pTestObj;
+ break;
+ }
+ }
+ }
+ }
+
+ return pObj;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMapObject* IMapWindow::GetIMapObj( const SdrObject* pSdrObj ) const
+{
+ IMapObject* pIMapObj = NULL;
+
+ if ( pSdrObj )
+ {
+ IMapUserData* pUserData = (IMapUserData*) pSdrObj->GetUserData( 0 );
+
+ if ( pUserData )
+ pIMapObj = pUserData->GetObject().get();
+ }
+
+ return pIMapObj;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+SdrObject* IMapWindow::GetSdrObj( const IMapObject* pIMapObj ) const
+{
+ SdrObject* pSdrObj = NULL;
+ SdrPage* pPage = (SdrPage*) pModel->GetPage( 0 );
+ ULONG nCount;
+
+ if ( pPage && ( ( nCount = pPage->GetObjCount() ) > 0 ) )
+ {
+ for ( ULONG i = 0; i < nCount; i++ )
+ {
+ SdrObject* pTestObj = pPage->GetObj( i );
+
+ if ( pIMapObj == GetIMapObj( pTestObj ) )
+ {
+ pSdrObj = pTestObj;
+ break;
+ }
+ }
+ }
+
+ return pSdrObj;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::Command(const CommandEvent& rCEvt)
+{
+ Region aRegion;
+
+ if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
+ {
+ PopupMenu aMenu( SVX_RES( RID_SVXMN_IMAP ) );
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ ULONG nMarked = rMarkList.GetMarkCount();
+
+ aMenu.EnableItem( MN_URL, FALSE );
+ aMenu.EnableItem( MN_ACTIVATE, FALSE );
+ aMenu.EnableItem( MN_MACRO, FALSE );
+ aMenu.EnableItem( MN_MARK_ALL, pModel->GetPage( 0 )->GetObjCount() != pView->GetMarkedObjectCount() );
+
+ if ( !nMarked )
+ {
+ aMenu.EnableItem( MN_POSITION, FALSE );
+ aMenu.EnableItem( MN_FRAME_TO_TOP, FALSE );
+ aMenu.EnableItem( MN_MOREFRONT, FALSE );
+ aMenu.EnableItem( MN_MOREBACK, FALSE );
+ aMenu.EnableItem( MN_FRAME_TO_BOTTOM, FALSE );
+ aMenu.EnableItem( MN_DELETE1, FALSE );
+ }
+ else
+ {
+ if ( nMarked == 1 )
+ {
+ SdrObject* pSdrObj = GetSelectedSdrObject();
+
+ aMenu.EnableItem( MN_URL, TRUE );
+ aMenu.EnableItem( MN_ACTIVATE, TRUE );
+ aMenu.EnableItem( MN_MACRO, TRUE );
+ aMenu.CheckItem( MN_ACTIVATE, GetIMapObj( pSdrObj )->IsActive() );
+ }
+
+ aMenu.EnableItem( MN_POSITION, TRUE );
+ aMenu.EnableItem( MN_FRAME_TO_TOP, TRUE );
+ aMenu.EnableItem( MN_MOREFRONT, TRUE );
+ aMenu.EnableItem( MN_MOREBACK, TRUE );
+ aMenu.EnableItem( MN_FRAME_TO_BOTTOM, TRUE );
+ aMenu.EnableItem( MN_DELETE1, TRUE );
+ }
+
+ aMenu.SetSelectHdl( LINK( this, IMapWindow, MenuSelectHdl ) );
+ aMenu.Execute( this, rCEvt.GetMousePosPixel() );
+ }
+ else
+ Window::Command(rCEvt);
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+sal_Int8 IMapWindow::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ return( ( GetHitSdrObj( rEvt.maPosPixel ) != NULL ) ? rEvt.mnAction : DND_ACTION_NONE );
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+sal_Int8 IMapWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) )
+ {
+ const String aString;
+ INetBookmark aBookMark( aString, aString );
+ SdrObject* pSdrObj = GetHitSdrObj( rEvt.maPosPixel );
+
+ if( pSdrObj && TransferableDataHelper( rEvt.maDropEvent.Transferable ).GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aBookMark ) )
+ {
+ IMapObject* pIMapObj = GetIMapObj( pSdrObj );
+
+ pIMapObj->SetURL( aBookMark.GetURL() );
+ pIMapObj->SetAltText( aBookMark.GetDescription() );
+ pModel->SetChanged( sal_True );
+ pView->UnmarkAll();
+ pView->MarkObj( pSdrObj, pView->GetSdrPageView() );
+ UpdateInfo( TRUE );
+ nRet = rEvt.mnAction;
+ }
+ }
+
+ return nRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::RequestHelp( const HelpEvent& rHEvt )
+{
+ SdrObject* pSdrObj = NULL;
+ SdrPageView* pPageView = NULL;
+ Point aPos = PixelToLogic( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
+
+ if ( Help::IsBalloonHelpEnabled() || Help::IsQuickHelpEnabled() )
+ {
+ if ( pView->PickObj( aPos, pView->getHitTolLog(), pSdrObj, pPageView ) )
+ {
+ const IMapObject* pIMapObj = GetIMapObj( pSdrObj );
+ String aStr;
+
+ if ( pIMapObj && ( aStr = pIMapObj->GetURL() ).Len() )
+ {
+ String aDescr( pIMapObj->GetAltText() );
+ Rectangle aLogicPix( LogicToPixel( Rectangle( Point(), GetGraphicSize() ) ) );
+ Rectangle aScreenRect( OutputToScreenPixel( aLogicPix.TopLeft() ),
+ OutputToScreenPixel( aLogicPix.BottomRight() ) );
+
+ if ( Help::IsBalloonHelpEnabled() )
+ Help::ShowBalloon( this, rHEvt.GetMousePosPixel(), aScreenRect, aStr );
+ else if ( Help::IsQuickHelpEnabled() )
+ Help::ShowQuickHelp( this, aScreenRect, aStr );
+ }
+ }
+ else
+ Window::RequestHelp( rHEvt );
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::SetCurrentObjState( BOOL bActive )
+{
+ SdrObject* pObj = GetSelectedSdrObject();
+
+ if ( pObj )
+ {
+ SfxItemSet aSet( pModel->GetItemPool() );
+
+ GetIMapObj( pObj )->SetActive( bActive );
+
+ aSet.Put( XFillColorItem( String(), TRANSCOL ) );
+
+ if ( !bActive )
+ {
+ aSet.Put( XFillTransparenceItem( 100 ) );
+ aSet.Put( XLineColorItem( String(), Color( COL_RED ) ) );
+ }
+ else
+ {
+ aSet.Put( XFillTransparenceItem( 50 ) );
+ aSet.Put( XLineColorItem( String(), Color( COL_BLACK ) ) );
+ }
+
+ pView->SetAttributes( aSet, FALSE );
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::UpdateInfo( BOOL bNewObj )
+{
+ if ( aInfoLink.IsSet() )
+ {
+ const SdrObject* pSdrObj = GetSelectedSdrObject();
+ const IMapObject* pIMapObj = pSdrObj ? GetIMapObj( pSdrObj ) : NULL;
+
+ aInfo.bNewObj = bNewObj;
+
+ if ( pIMapObj )
+ {
+ aInfo.bOneMarked = TRUE;
+ aInfo.aMarkURL = pIMapObj->GetURL();
+ aInfo.aMarkAltText = pIMapObj->GetAltText();
+ aInfo.aMarkTarget = pIMapObj->GetTarget();
+ aInfo.bActivated = pIMapObj->IsActive();
+ aInfoLink.Call( this );
+ }
+ else
+ {
+ aInfo.aMarkURL = aInfo.aMarkAltText = aInfo.aMarkTarget = String();
+ aInfo.bOneMarked = FALSE;
+ aInfo.bActivated = FALSE;
+ }
+
+ aInfoLink.Call( this );
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::DoMacroAssign()
+{
+ SdrObject* pSdrObj = GetSelectedSdrObject();
+
+ if ( pSdrObj )
+ {
+ SfxItemSet aSet( *pIMapPool, SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );
+
+ SfxEventNamesItem aNamesItem(SID_EVENTCONFIG);
+ aNamesItem.AddEvent( String::CreateFromAscii( "MouseOver" ), String(), SFX_EVENT_MOUSEOVER_OBJECT );
+ aNamesItem.AddEvent( String::CreateFromAscii( "MouseOut" ), String(), SFX_EVENT_MOUSEOUT_OBJECT );
+ aSet.Put( aNamesItem );
+
+ SvxMacroItem aMacroItem(SID_ATTR_MACROITEM);
+ IMapObject* pIMapObj = GetIMapObj( pSdrObj );
+ aMacroItem.SetMacroTable( pIMapObj->GetMacroTable() );
+ aSet.Put( aMacroItem, SID_ATTR_MACROITEM );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( this, aSet, mxDocumentFrame, SID_EVENTCONFIG );
+
+ if ( pMacroDlg && pMacroDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet();
+ pIMapObj->SetMacroTable( ((const SvxMacroItem& )pOutSet->Get( SID_ATTR_MACROITEM )).GetMacroTable() );
+ pModel->SetChanged( sal_True );
+ UpdateInfo( FALSE );
+ }
+
+ delete pMacroDlg;
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void IMapWindow::DoPropertyDialog()
+{
+ SdrObject* pSdrObj = GetSelectedSdrObject();
+
+ if ( pSdrObj )
+ {
+ IMapObject* pIMapObj = GetIMapObj( pSdrObj );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractURLDlg* aDlg = pFact->CreateURLDialog( this, pIMapObj->GetURL(), pIMapObj->GetAltText(), pIMapObj->GetDesc(),
+ pIMapObj->GetTarget(), pIMapObj->GetName(), aTargetList );
+ DBG_ASSERT(aDlg, "Dialogdiet fail!");
+ if ( aDlg->Execute() == RET_OK )
+ {
+ const String aURLText( aDlg->GetURL() );
+
+ if ( aURLText.Len() )
+ {
+ INetURLObject aObj( aURLText, INET_PROT_FILE );
+ DBG_ASSERT( aObj.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL" );
+ pIMapObj->SetURL( aObj.GetMainURL( INetURLObject::NO_DECODE ) );
+ }
+ else
+ pIMapObj->SetURL( aURLText );
+
+ pIMapObj->SetAltText( aDlg->GetAltText() );
+ pIMapObj->SetDesc( aDlg->GetDesc() );
+ pIMapObj->SetTarget( aDlg->GetTarget() );
+ pIMapObj->SetName( aDlg->GetName() );
+ pModel->SetChanged( sal_True );
+ UpdateInfo( TRUE );
+ }
+ delete aDlg;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_LINK( IMapWindow, MenuSelectHdl, Menu*, pMenu )
+{
+ if (pMenu)
+ {
+ USHORT nId = pMenu->GetCurItemId();
+
+ switch(nId)
+ {
+ case( MN_URL ):
+ DoPropertyDialog();
+ break;
+
+ case( MN_MACRO ):
+ DoMacroAssign();
+ break;
+
+ case( MN_ACTIVATE ):
+ {
+ const BOOL bNewState = !pMenu->IsItemChecked( MN_ACTIVATE );
+
+ pMenu->CheckItem( MN_ACTIVATE, bNewState );
+ SetCurrentObjState( bNewState );
+ UpdateInfo( FALSE );
+ }
+
+ case( MN_FRAME_TO_TOP ):
+ pView->PutMarkedToTop();
+ break;
+
+ case( MN_MOREFRONT ):
+ pView->MovMarkedToTop();
+ break;
+
+ case( MN_MOREBACK ):
+ pView->MovMarkedToBtm();
+ break;
+
+ case( MN_FRAME_TO_BOTTOM ):
+ pView->PutMarkedToBtm();
+ break;
+
+ case( MN_MARK_ALL ):
+ pView->MarkAll();
+ break;
+
+ case( MN_DELETE1 ):
+ pView->DeleteMarked();
+
+ default :
+ break;
+ }
+ }
+
+ return 0;
+}
+
+void IMapWindow::CreateDefaultObject()
+{
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ // calc position and size
+ Point aPagePos(0, 0); // = pPageView->GetOffset();
+ Size aPageSize = pPageView->GetPage()->GetSize();
+ sal_uInt32 nDefaultObjectSizeWidth = aPageSize.Width() / 4;
+ sal_uInt32 nDefaultObjectSizeHeight = aPageSize.Height() / 4;
+ aPagePos.X() += (aPageSize.Width() / 2) - (nDefaultObjectSizeWidth / 2);
+ aPagePos.Y() += (aPageSize.Height() / 2) - (nDefaultObjectSizeHeight / 2);
+ Rectangle aNewObjectRectangle(aPagePos, Size(nDefaultObjectSizeWidth, nDefaultObjectSizeHeight));
+
+ SdrObject* pObj = SdrObjFactory::MakeNewObject( pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), 0L, pModel);
+ pObj->SetLogicRect(aNewObjectRectangle);
+
+ switch( pObj->GetObjIdentifier() )
+ {
+ case OBJ_POLY:
+ case OBJ_PATHPOLY:
+ {
+ basegfx::B2DPolygon aInnerPoly;
+ aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.BottomLeft().X(), aNewObjectRectangle.BottomLeft().Y()));
+ aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.TopLeft().X(), aNewObjectRectangle.TopLeft().Y()));
+ aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.TopCenter().X(), aNewObjectRectangle.TopCenter().Y()));
+ aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.Center().X(), aNewObjectRectangle.Center().Y()));
+ aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.RightCenter().X(), aNewObjectRectangle.RightCenter().Y()));
+ aInnerPoly.append(basegfx::B2DPoint(aNewObjectRectangle.BottomRight().X(), aNewObjectRectangle.BottomRight().Y()));
+ aInnerPoly.setClosed(true);
+ ((SdrPathObj*)pObj)->SetPathPoly(basegfx::B2DPolyPolygon(aInnerPoly));
+ break;
+ }
+ case OBJ_FREEFILL:
+ case OBJ_PATHFILL:
+ {
+ sal_Int32 nWdt(aNewObjectRectangle.GetWidth() / 2);
+ sal_Int32 nHgt(aNewObjectRectangle.GetHeight() / 2);
+ basegfx::B2DPolygon aInnerPoly(XPolygon(aNewObjectRectangle.Center(), nWdt, nHgt).getB2DPolygon());
+ ((SdrPathObj*)pObj)->SetPathPoly(basegfx::B2DPolyPolygon(aInnerPoly));
+ break;
+ }
+
+ }
+
+ pView->InsertObjectAtView(pObj, *pPageView);
+ SdrObjCreated( *pObj );
+ SetCurrentObjState( true );
+ pView->MarkObj( pObj, pPageView );
+ }
+}
+
+void IMapWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyCode aCode = rKEvt.GetKeyCode();
+
+/*
+ switch(aCode.GetCode())
+ {
+ case KEY_ESCAPE:
+ {
+ if ( pView->IsAction() )
+ {
+ pView->BrkAction();
+ return;
+ }
+ else if ( pView->AreObjectsMarked() )
+ {
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if(pHdl)
+ {
+ ((SdrHdlList&)rHdlList).ResetFocusHdl();
+ }
+ else
+ {
+ pView->UnmarkAllObj();
+ ((Dialog*)GetParent())->GrabFocusToFirstControl();
+ }
+
+ return;
+ }
+ }
+ break;
+
+ }
+*/
+ GraphCtrl::KeyInput( rKEvt );
+}
+
+void IMapWindow::SelectFirstObject()
+{
+ SdrPage* pPage = (SdrPage*) pModel->GetPage( 0 );
+ if( pPage->GetObjCount() != 0 )
+ {
+ GrabFocus();
+ pView->UnmarkAllObj();
+ pView->MarkNextObj(TRUE);
+ }
+}
+
+void IMapWindow::StartPolyEdit()
+{
+ GrabFocus();
+
+ if( !pView->AreObjectsMarked() )
+ pView->MarkNextObj(TRUE);
+
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if(!pHdl)
+ {
+ ((SdrHdlList&)rHdlList).TravelFocusHdl(true);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/imapwnd.hxx b/svx/source/dialog/imapwnd.hxx
new file mode 100644
index 000000000000..971e93af7263
--- /dev/null
+++ b/svx/source/dialog/imapwnd.hxx
@@ -0,0 +1,228 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _IMAPWND_HXX
+#define _IMAPWND_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/menu.hxx>
+#include <svl/itempool.hxx>
+#include <svtools/imapobj.hxx>
+#include <svtools/transfer.hxx>
+#include <svtools/imap.hxx>
+#include <sfx2/frame.hxx>
+#include <svx/graphctl.hxx>
+
+#include <com/sun/star/frame/XFrame.hpp>
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+struct NotifyInfo
+{
+ String aMarkURL;
+ String aMarkAltText;
+ String aMarkTarget;
+ BOOL bNewObj;
+ BOOL bOneMarked;
+ BOOL bActivated;
+};
+
+
+struct NotifyPosSize
+{
+ Size aPictureSize;
+ Point aMousePos;
+ BOOL bPictureSize;
+ BOOL bMousePos;
+};
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+#define SVD_IMAP_USERDATA 0x0001
+
+const UINT32 IMapInventor = UINT32('I') * 0x00000001+
+ UINT32('M') * 0x00000100+
+ UINT32('A') * 0x00010000+
+ UINT32('P') * 0x01000000;
+
+
+typedef boost::shared_ptr< IMapObject > IMapObjectPtr;
+
+class IMapUserData : public SdrObjUserData
+{
+ // #i98386# use boost::shared_ptr here due to cloning possibilities
+ IMapObjectPtr mpObj;
+
+public:
+
+ IMapUserData() :
+ SdrObjUserData ( IMapInventor, SVD_IMAP_USERDATA, 0 ),
+ mpObj ( ) {}
+
+ IMapUserData( const IMapObjectPtr& rIMapObj ) :
+ SdrObjUserData ( IMapInventor, SVD_IMAP_USERDATA, 0 ),
+ mpObj ( rIMapObj ) {}
+
+ IMapUserData( const IMapUserData& rIMapUserData ) :
+ SdrObjUserData ( IMapInventor, SVD_IMAP_USERDATA, 0 ),
+ mpObj ( rIMapUserData.mpObj ) {}
+
+ ~IMapUserData() { }
+
+ virtual SdrObjUserData* Clone( SdrObject * ) const { return new IMapUserData( *this ); }
+
+ void SetObject( const IMapObjectPtr& rIMapObj ) { mpObj = rIMapObj; }
+ const IMapObjectPtr GetObject() const { return mpObj; }
+ void ReplaceObject( const IMapObjectPtr& pNewIMapObject ) { mpObj = pNewIMapObject; }
+};
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+/* move to cui //CHINA001
+class URLDlg : public ModalDialog
+{
+ FixedLine aFlURL;
+ FixedText aFtURL1;
+ Edit aEdtURL;
+ FixedText aFtURLDescription;
+ Edit aEdtURLDescription;
+ FixedText aFtTarget;
+ ComboBox aCbbTargets;
+ FixedText aFtName;
+ Edit aEdtName;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+
+public:
+
+ URLDlg( Window* pWindow,
+ const String& rURL, const String& rDescription,
+ const String& rTarget, const String& rName,
+ TargetList& rTargetList );
+
+ String GetURL() const { return aEdtURL.GetText(); }
+ String GetDescription() const { return aEdtURLDescription.GetText(); }
+ String GetTarget() const { return aCbbTargets.GetText(); }
+ String GetName() const { return aEdtName.GetText(); }
+};
+*/
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+class IMapWindow : public GraphCtrl, public DropTargetHelper
+{
+ NotifyInfo aInfo;
+ ImageMap aIMap;
+ TargetList aTargetList;
+ Link aInfoLink;
+ SfxItemPool* pIMapPool;
+ SfxItemInfo* pItemInfo;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
+ mxDocumentFrame;
+
+ DECL_LINK( MenuSelectHdl, Menu* );
+ DECL_LINK( MouseTimerHdl, Timer* );
+
+protected:
+
+ // GraphCtrl
+ virtual void MouseButtonUp(const MouseEvent& rMEvt);
+ virtual void Command(const CommandEvent& rCEvt);
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+ virtual void SdrObjCreated( const SdrObject& rObj );
+ virtual void SdrObjChanged( const SdrObject& rObj );
+ virtual void MarkListHasChanged();
+ virtual void InitSdrModel();
+
+ // DropTargetHelper
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+ void CreateImageMap();
+ void ReplaceImageMap( const ImageMap& rNewImageMap, BOOL bScaleToGraphic );
+
+ void ClearTargetList();
+
+ SdrObject* CreateObj( const IMapObject* pIMapObj );
+ IMapObject* GetIMapObj( const SdrObject* pSdrObj ) const;
+ SdrObject* GetSdrObj( const IMapObject* pIMapObj ) const;
+ SdrObject* GetHitSdrObj( const Point& rPosPixel ) const;
+
+ void UpdateInfo( BOOL bNewObj );
+
+public:
+
+ IMapWindow( Window* pParent, const ResId& rResId, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxDocumentFrame );
+ ~IMapWindow();
+
+ BOOL ReplaceActualIMapInfo( const NotifyInfo& rNewInfo );
+
+ void SetImageMap( const ImageMap& rImageMap );
+ const ImageMap& GetImageMap();
+
+ void SetCurrentObjState( BOOL bActive );
+ void DoMacroAssign();
+ void DoPropertyDialog();
+
+ void SetInfoLink( const Link& rLink ) { aInfoLink = rLink; }
+ const Link& GetInfoLink() const { return aInfoLink; }
+
+ void SetTargetList( TargetList& rTargetList );
+ const TargetList& GetTargetList() const { return aTargetList; }
+
+ const NotifyInfo& GetInfo() const { return aInfo; }
+
+ void CreateDefaultObject();
+ void SelectFirstObject();
+ void StartPolyEdit();
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/langbox.cxx b/svx/source/dialog/langbox.cxx
new file mode 100644
index 000000000000..35aa62c3a531
--- /dev/null
+++ b/svx/source/dialog/langbox.cxx
@@ -0,0 +1,528 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <com/sun/star/linguistic2/XLinguServiceManager.hdl>
+#include <com/sun/star/linguistic2/XAvailableLocales.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <linguistic/misc.hxx>
+#include <rtl/ustring.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <tools/urlobj.hxx>
+#include <svtools/langtab.hxx>
+#include <tools/shl.hxx>
+#include <i18npool/mslangid.hxx>
+#include <i18npool/lang.h>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/unolingu.hxx>
+#include <svx/langbox.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::linguistic2;
+using namespace ::com::sun::star::uno;
+
+// -----------------------------------------------------------------------
+
+String GetDicInfoStr( const String& rName, const USHORT nLang, BOOL bNeg )
+{
+ INetURLObject aURLObj;
+ aURLObj.SetSmartProtocol( INET_PROT_FILE );
+ aURLObj.SetSmartURL( rName, INetURLObject::ENCODE_ALL );
+ String aTmp( aURLObj.GetBase() );
+ aTmp += sal_Unicode( ' ' );
+
+ if ( bNeg )
+ {
+ sal_Char const sTmp[] = " (-) ";
+ aTmp.AppendAscii( sTmp );
+ }
+
+ if ( LANGUAGE_NONE == nLang )
+ aTmp += String( ResId( RID_SVXSTR_LANGUAGE_ALL, DIALOG_MGR() ) );
+ else
+ {
+ aTmp += sal_Unicode( '[' );
+ aTmp += SvtLanguageTable::GetLanguageString( (LanguageType)nLang );
+ aTmp += sal_Unicode( ']' );
+ }
+
+ return aTmp;
+}
+
+//========================================================================
+// misc local helper functions
+//========================================================================
+
+static Sequence< INT16 > lcl_LocaleSeqToLangSeq( Sequence< Locale > &rSeq )
+{
+ const Locale *pLocale = rSeq.getConstArray();
+ INT32 nCount = rSeq.getLength();
+
+ Sequence< INT16 > aLangs( nCount );
+ INT16 *pLang = aLangs.getArray();
+ for (INT32 i = 0; i < nCount; ++i)
+ {
+ pLang[i] = SvxLocaleToLanguage( pLocale[i] );
+
+ }
+
+ return aLangs;
+}
+
+
+static BOOL lcl_SeqHasLang( const Sequence< INT16 > & rLangSeq, INT16 nLang )
+{
+ INT32 i = -1;
+ INT32 nLen = rLangSeq.getLength();
+ if (nLen)
+ {
+ const INT16 *pLang = rLangSeq.getConstArray();
+ for (i = 0; i < nLen; ++i)
+ {
+ if (nLang == pLang[i])
+ break;
+ }
+ }
+ return i >= 0 && i < nLen;
+}
+
+//========================================================================
+// class SvxLanguageBox
+//========================================================================
+
+USHORT TypeToPos_Impl( LanguageType eType, const ListBox& rLb )
+{
+ USHORT nPos = LISTBOX_ENTRY_NOTFOUND;
+ USHORT nCount = rLb.GetEntryCount();
+
+ for ( USHORT i=0; nPos == LISTBOX_ENTRY_NOTFOUND && i<nCount; i++ )
+ if ( eType == LanguageType((ULONG)rLb.GetEntryData(i)) )
+ nPos = i;
+
+ return nPos;
+}
+
+//-----------------------------------------------------------------------
+SvxLanguageBox::SvxLanguageBox( Window* pParent, WinBits nWinStyle, BOOL bCheck ) :
+ ListBox( pParent, nWinStyle ),
+ m_pSpellUsedLang( NULL ),
+ m_bWithCheckmark( bCheck )
+{
+ Init();
+}
+//------------------------------------------------------------------------
+SvxLanguageBox::SvxLanguageBox( Window* pParent, const ResId& rResId, BOOL bCheck ) :
+ ListBox( pParent, rResId ),
+ m_pSpellUsedLang( NULL ),
+ m_bWithCheckmark( bCheck )
+{
+ Init();
+}
+//------------------------------------------------------------------------
+void SvxLanguageBox::Init()
+{
+ m_pLangTable = new SvtLanguageTable;
+ m_aNotCheckedImage = Image( SVX_RES( RID_SVXIMG_NOTCHECKED ) );
+ m_aCheckedImage = Image( SVX_RES( RID_SVXIMG_CHECKED ) );
+ m_aCheckedImageHC = Image( SVX_RES( RID_SVXIMG_CHECKED_H ) );
+ m_aAllString = String( SVX_RESSTR( RID_SVXSTR_LANGUAGE_ALL ) );
+ m_nLangList = LANG_LIST_EMPTY;
+ m_bHasLangNone = FALSE;
+ m_bLangNoneIsLangAll = FALSE;
+
+ // display entries sorted
+ SetStyle( GetStyle() | WB_SORT );
+
+ if ( m_bWithCheckmark )
+ {
+ SvtLanguageTable aLangTable;
+ sal_uInt32 nCount = aLangTable.GetEntryCount();
+ for ( sal_uInt32 i = 0; i < nCount; i++ )
+ {
+ LanguageType nLangType = aLangTable.GetTypeAtIndex( i );
+
+ BOOL bInsert = TRUE;
+ if ((LANGUAGE_DONTKNOW == nLangType) ||
+ (LANGUAGE_SYSTEM == nLangType) ||
+ (LANGUAGE_USER1 <= nLangType && nLangType <= LANGUAGE_USER9))
+ {
+ bInsert = FALSE;
+ }
+
+ if ( bInsert )
+ InsertLanguage( nLangType );
+ }
+ m_nLangList = LANG_LIST_ALL;
+ }
+}
+//------------------------------------------------------------------------
+
+SvxLanguageBox::~SvxLanguageBox()
+{
+ delete m_pSpellUsedLang;
+ delete m_pLangTable;
+}
+
+//------------------------------------------------------------------------
+
+USHORT SvxLanguageBox::ImplInsertImgEntry( const String& rEntry, USHORT nPos, bool bChecked )
+{
+ USHORT nRet = 0;
+ if( !bChecked )
+ nRet = InsertEntry( rEntry, m_aNotCheckedImage, nPos );
+ else if( GetSettings().GetStyleSettings().GetHighContrastMode() )
+ nRet = InsertEntry( rEntry, m_aCheckedImageHC, nPos );
+ else
+ nRet = InsertEntry( rEntry, m_aCheckedImage, nPos );
+ return nRet;
+}
+
+//------------------------------------------------------------------------
+
+void SvxLanguageBox::SetLanguageList( INT16 nLangList,
+ BOOL bHasLangNone, BOOL bLangNoneIsLangAll, BOOL bCheckSpellAvail )
+{
+ Clear();
+
+ m_nLangList = nLangList;
+ m_bHasLangNone = bHasLangNone;
+ m_bLangNoneIsLangAll = bLangNoneIsLangAll;
+ m_bWithCheckmark = bCheckSpellAvail;
+
+ if ( LANG_LIST_EMPTY != nLangList )
+ {
+ Sequence< INT16 > aSpellAvailLang;
+ Sequence< INT16 > aHyphAvailLang;
+ Sequence< INT16 > aThesAvailLang;
+ Sequence< INT16 > aSpellUsedLang;
+ Sequence< INT16 > aHyphUsedLang;
+ Sequence< INT16 > aThesUsedLang;
+ Reference< XAvailableLocales > xAvail( LinguMgr::GetLngSvcMgr(), UNO_QUERY );
+ if (xAvail.is())
+ {
+ Sequence< Locale > aTmp;
+
+ if (LANG_LIST_SPELL_AVAIL & nLangList)
+ {
+ aTmp = xAvail->getAvailableLocales( A2OU( SN_SPELLCHECKER ) );
+ aSpellAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
+ }
+ if (LANG_LIST_HYPH_AVAIL & nLangList)
+ {
+ aTmp = xAvail->getAvailableLocales( A2OU( SN_HYPHENATOR ) );
+ aHyphAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
+ }
+ if (LANG_LIST_THES_AVAIL & nLangList)
+ {
+ aTmp = xAvail->getAvailableLocales( A2OU( SN_THESAURUS ) );
+ aThesAvailLang = lcl_LocaleSeqToLangSeq( aTmp );
+ }
+ }
+ if (LANG_LIST_SPELL_USED & nLangList)
+ {
+ Reference< XSpellChecker1 > xTmp1( SvxGetSpellChecker(), UNO_QUERY );
+ if (xTmp1.is())
+ aSpellUsedLang = xTmp1->getLanguages();
+ }
+ if (LANG_LIST_HYPH_USED & nLangList)
+ {
+ Reference< XHyphenator > xTmp( SvxGetHyphenator() );
+ if (xTmp.is()) {
+ Sequence < Locale > aLocaleSequence( xTmp->getLocales() );
+ aHyphUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
+ }
+ }
+ if (LANG_LIST_THES_USED & nLangList)
+ {
+ Reference< XThesaurus > xTmp( SvxGetThesaurus() );
+ if (xTmp.is()) {
+ Sequence < Locale > aLocaleSequence( xTmp->getLocales() );
+ aThesUsedLang = lcl_LocaleSeqToLangSeq( aLocaleSequence );
+ }
+ }
+
+ SvtLanguageTable aLangTable;
+ ::com::sun::star::uno::Sequence< sal_uInt16 > xKnown;
+ const sal_uInt16* pKnown;
+ sal_uInt32 nCount;
+ if ( nLangList & LANG_LIST_ONLY_KNOWN )
+ {
+ xKnown = LocaleDataWrapper::getInstalledLanguageTypes();
+ pKnown = xKnown.getConstArray();
+ nCount = xKnown.getLength();
+ }
+ else
+ {
+ nCount = aLangTable.GetEntryCount();
+ pKnown = NULL;
+ }
+ for ( sal_uInt32 i = 0; i < nCount; i++ )
+ {
+ LanguageType nLangType;
+ if ( nLangList & LANG_LIST_ONLY_KNOWN )
+ nLangType = pKnown[i];
+ else
+ nLangType = aLangTable.GetTypeAtIndex( i );
+ if ( nLangType != LANGUAGE_DONTKNOW &&
+ nLangType != LANGUAGE_SYSTEM &&
+ nLangType != LANGUAGE_NONE &&
+ (nLangType < LANGUAGE_USER1 || nLangType > LANGUAGE_USER9) &&
+ (MsLangId::getSubLanguage( nLangType) != 0 ||
+ (nLangList & LANG_LIST_ALSO_PRIMARY_ONLY)) &&
+ ((nLangList & LANG_LIST_ALL) != 0 ||
+ ((nLangList & LANG_LIST_WESTERN) != 0 &&
+ (SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) ==
+ SCRIPTTYPE_LATIN)) ||
+ ((nLangList & LANG_LIST_CTL) != 0 &&
+ (SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) ==
+ SCRIPTTYPE_COMPLEX)) ||
+ ((nLangList & LANG_LIST_CJK) != 0 &&
+ (SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType) ==
+ SCRIPTTYPE_ASIAN)) ||
+ ((nLangList & LANG_LIST_FBD_CHARS) != 0 &&
+ MsLangId::hasForbiddenCharacters(nLangType)) ||
+ ((nLangList & LANG_LIST_SPELL_AVAIL) != 0 &&
+ lcl_SeqHasLang(aSpellAvailLang, nLangType)) ||
+ ((nLangList & LANG_LIST_HYPH_AVAIL) != 0 &&
+ lcl_SeqHasLang(aHyphAvailLang, nLangType)) ||
+ ((nLangList & LANG_LIST_THES_AVAIL) != 0 &&
+ lcl_SeqHasLang(aThesAvailLang, nLangType)) ||
+ ((nLangList & LANG_LIST_SPELL_USED) != 0 &&
+ lcl_SeqHasLang(aSpellUsedLang, nLangType)) ||
+ ((nLangList & LANG_LIST_HYPH_USED) != 0 &&
+ lcl_SeqHasLang(aHyphUsedLang, nLangType)) ||
+ ((nLangList & LANG_LIST_THES_USED) != 0 &&
+ lcl_SeqHasLang(aThesUsedLang, nLangType))) )
+ InsertLanguage( nLangType );
+ }
+
+ if (bHasLangNone)
+ InsertLanguage( LANGUAGE_NONE );
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT SvxLanguageBox::InsertLanguage( const LanguageType nLangType, USHORT nPos )
+{
+ return ImplInsertLanguage( nLangType, nPos, ::com::sun::star::i18n::ScriptType::WEAK );
+}
+
+//------------------------------------------------------------------------
+
+USHORT SvxLanguageBox::ImplInsertLanguage( const LanguageType nLangType, USHORT nPos, sal_Int16 nType )
+{
+ LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType);
+ // For obsolete and to be replaced languages check whether an entry of the
+ // replacement already exists and if so don't add an entry with identical
+ // string as would be returned by SvtLanguageTable::GetString().
+ if (nLang != nLangType)
+ {
+ USHORT nAt = TypeToPos_Impl( nLang, *this );
+ if ( nAt != LISTBOX_ENTRY_NOTFOUND )
+ return nAt;
+ }
+
+ String aStrEntry = m_pLangTable->GetString( nLang );
+ if (LANGUAGE_NONE == nLang && m_bHasLangNone && m_bLangNoneIsLangAll)
+ aStrEntry = m_aAllString;
+
+ LanguageType nRealLang = nLang;
+ if (nRealLang == LANGUAGE_SYSTEM)
+ {
+ nRealLang = MsLangId::resolveSystemLanguageByScriptType(nRealLang, nType);
+ aStrEntry.AppendAscii(" - ");
+ aStrEntry.Append(m_pLangTable->GetString( nRealLang ));
+ }
+
+ aStrEntry = ApplyLreOrRleEmbedding( aStrEntry );
+
+ USHORT nAt = 0;
+ if ( m_bWithCheckmark )
+ {
+ sal_Bool bFound = sal_False;
+
+ if (!m_pSpellUsedLang)
+ {
+ Reference< XSpellChecker1 > xSpell( SvxGetSpellChecker(), UNO_QUERY );
+ if ( xSpell.is() )
+ m_pSpellUsedLang = new Sequence< INT16 >( xSpell->getLanguages() );
+ }
+ bFound = m_pSpellUsedLang ?
+ lcl_SeqHasLang( *m_pSpellUsedLang, nRealLang ) : FALSE;
+
+ nAt = ImplInsertImgEntry( aStrEntry, nPos, bFound );
+ }
+ else
+ nAt = InsertEntry( aStrEntry, nPos );
+
+ SetEntryData( nAt, (void*)(ULONG)nLangType );
+ return nAt;
+}
+
+//------------------------------------------------------------------------
+
+USHORT SvxLanguageBox::InsertDefaultLanguage( sal_Int16 nType, USHORT nPos )
+{
+ return ImplInsertLanguage( LANGUAGE_SYSTEM, nPos, nType );
+}
+
+//------------------------------------------------------------------------
+
+USHORT SvxLanguageBox::InsertLanguage( const LanguageType nLangType,
+ BOOL bCheckEntry, USHORT nPos )
+{
+ LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( nLangType);
+ // For obsolete and to be replaced languages check whether an entry of the
+ // replacement already exists and if so don't add an entry with identical
+ // string as would be returned by SvtLanguageTable::GetString().
+ if (nLang != nLangType)
+ {
+ USHORT nAt = TypeToPos_Impl( nLang, *this );
+ if ( nAt != LISTBOX_ENTRY_NOTFOUND )
+ return nAt;
+ }
+
+ String aStrEntry = m_pLangTable->GetString( nLang );
+ if (LANGUAGE_NONE == nLang && m_bHasLangNone && m_bLangNoneIsLangAll)
+ aStrEntry = m_aAllString;
+
+ USHORT nAt = ImplInsertImgEntry( aStrEntry, nPos, bCheckEntry );
+ SetEntryData( nAt, (void*)(ULONG)nLang );
+
+ return nAt;
+}
+
+//------------------------------------------------------------------------
+
+void SvxLanguageBox::RemoveLanguage( const LanguageType eLangType )
+{
+ USHORT nAt = TypeToPos_Impl( eLangType, *this );
+
+ if ( nAt != LISTBOX_ENTRY_NOTFOUND )
+ RemoveEntry( nAt );
+}
+
+//------------------------------------------------------------------------
+
+LanguageType SvxLanguageBox::GetSelectLanguage() const
+{
+ USHORT nPos = GetSelectEntryPos();
+
+ if ( nPos != LISTBOX_ENTRY_NOTFOUND )
+ return LanguageType( (ULONG)GetEntryData(nPos) );
+ else
+ return LanguageType( LANGUAGE_DONTKNOW );
+}
+
+//------------------------------------------------------------------------
+
+void SvxLanguageBox::SelectLanguage( const LanguageType eLangType, BOOL bSelect )
+{
+ // If the core uses a LangID of an imported MS document and wants to select
+ // a language that is replaced, we need to select the replacement instead.
+ LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( eLangType);
+
+ USHORT nAt = TypeToPos_Impl( nLang, *this );
+
+ if ( nAt != LISTBOX_ENTRY_NOTFOUND )
+ SelectEntryPos( nAt, bSelect );
+}
+
+//------------------------------------------------------------------------
+
+BOOL SvxLanguageBox::IsLanguageSelected( const LanguageType eLangType ) const
+{
+ // Same here, work on the replacement if applicable.
+ LanguageType nLang = MsLangId::getReplacementForObsoleteLanguage( eLangType);
+
+ USHORT nAt = TypeToPos_Impl( nLang, *this );
+
+ if ( nAt != LISTBOX_ENTRY_NOTFOUND )
+ return IsEntryPosSelected( nAt );
+ else
+ return FALSE;
+}
+
+#if ENABLE_LAYOUT
+
+namespace layout
+{
+
+SvxLanguageBox::~SvxLanguageBox ()
+{
+}
+
+SvxLanguageBox::SvxLanguageBox( Context* pParent, const char* pFile, BOOL bCheck )
+: ListBox ( pParent, pFile, bCheck )
+{
+}
+
+void SvxLanguageBox::SetLanguageList( sal_Int16/*list*/, bool/*hasLangNone*/, bool /*langNoneIsLangAll*/, bool /*checkSpellAvail*/)
+{
+}
+
+sal_uInt16 SvxLanguageBox::InsertLanguage( const LanguageType/*type*/, sal_uInt16/*pos*/)
+{
+ return 0;
+}
+sal_uInt16 SvxLanguageBox::InsertLanguage( const LanguageType/*type*/, bool/*checkEntry*/, sal_uInt16 /*pos*/)
+{
+ return 0;
+}
+void SvxLanguageBox::RemoveLanguage( const LanguageType/*type*/)
+{
+}
+void SvxLanguageBox::SelectLanguage( const LanguageType/*type*/, bool/*select*/)
+{
+}
+LanguageType SvxLanguageBox::GetSelectLanguage() const
+{
+ return 0;
+}
+bool SvxLanguageBox::IsLanguageSelected( const LanguageType/*type*/) const
+{
+ return true;
+}
+
+/*IMPL_IMPL (SvxLanguageBox, ListBox);
+IMPL_CONSTRUCTORS ( SvxLanguageBox, ListBox, "svxlanguagebox" );
+IMPL_GET_IMPL( SvxLanguageBox );
+IMPL_GET_WINDOW (SvxLanguageBox);*/
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/langbox.src b/svx/source/dialog/langbox.src
new file mode 100644
index 000000000000..8bd1987d2d94
--- /dev/null
+++ b/svx/source/dialog/langbox.src
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// include ---------------------------------------------------------------
+
+#include <svx/dialogs.hrc>
+
+Image RID_SVXIMG_NOTCHECKED
+{
+ ImageBitmap = Bitmap { File = "notcheck.bmp" ; } ;
+ MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+};
+Image RID_SVXIMG_CHECKED
+{
+ ImageBitmap = Bitmap { File = "lngcheck.bmp" ; } ;
+ MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+};
+Image RID_SVXIMG_CHECKED_H
+{
+ ImageBitmap = Bitmap { File = "lngcheck_h.bmp" ; } ;
+ MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+};
+
+// ********************************************************************** EOF
+
diff --git a/svx/source/dialog/language.src b/svx/source/dialog/language.src
new file mode 100644
index 000000000000..9cd239996e68
--- /dev/null
+++ b/svx/source/dialog/language.src
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+ // include ---------------------------------------------------------------
+#include <svx/dialogs.hrc>
+ // pragma ----------------------------------------------------------------
+
+ // Language-Strings ------------------------------------------------------
+
+String RID_SVXSTR_LANGUAGE_ALL
+{
+ Text [ en-US ] = "[All]" ;
+};
+
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/linkwarn.cxx b/svx/source/dialog/linkwarn.cxx
new file mode 100644
index 000000000000..d69ddda72b7c
--- /dev/null
+++ b/svx/source/dialog/linkwarn.cxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * Copyright 2010 Novell, Inc.
+ *
+ * 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_svx.hxx"
+
+#include "linkwarn.hrc"
+#include "svx/linkwarn.hxx"
+#include "svx/dialogs.hrc"
+#include "svx/dialmgr.hxx"
+#include <vcl/msgbox.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <svtools/miscopt.hxx>
+
+SvxLinkWarningDialog::SvxLinkWarningDialog( Window* pParent, const String& _rFileName ) :
+ SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_LINK_WARNING ) ),
+ m_aQueryImage ( this, SVX_RES( FI_QUERY ) ),
+ m_aInfoText ( this, SVX_RES( FT_INFOTEXT ) ),
+ m_aLinkGraphicBtn ( this, SVX_RES( PB_OK ) ),
+ m_aEmbedGraphicBtn ( this, SVX_RES( PB_NO ) ),
+ m_aOptionLine ( this, SVX_RES( FL_OPTION ) ),
+ m_aWarningOnBox ( this, SVX_RES( CB_WARNING_OFF ) )
+{
+ FreeResource();
+
+ // set questionmark image
+ m_aQueryImage.SetImage( QueryBox::GetStandardImage() );
+
+ // replace filename
+ String sInfoText = m_aInfoText.GetText();
+ sInfoText.SearchAndReplaceAll(
+ UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "%FILENAME" ) ), _rFileName );
+ m_aInfoText.SetText( sInfoText );
+
+ // load state of "warning on" checkbox from misc options
+ SvtMiscOptions aMiscOpt;
+ m_aWarningOnBox.Check( aMiscOpt.ShowLinkWarningDialog() == sal_True );
+ if( aMiscOpt.IsShowLinkWarningDialogReadOnly() )
+ m_aWarningOnBox.Disable();
+
+ // set focus to Cancel button
+ m_aEmbedGraphicBtn.GrabFocus();
+
+ // calculate and set the size of the dialog and its controls
+ InitSize();
+}
+
+// -----------------------------------------------------------------------
+
+SvxLinkWarningDialog::~SvxLinkWarningDialog()
+{
+ // save value of "warning off" checkbox, if necessary
+ SvtMiscOptions aMiscOpt;
+ sal_Bool bChecked = m_aWarningOnBox.IsChecked();
+ if ( aMiscOpt.ShowLinkWarningDialog() != bChecked )
+ aMiscOpt.SetShowLinkWarningDialog( bChecked );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLinkWarningDialog::InitSize()
+{
+ // text of checkbox to wide -> add new line
+ long nTxtW = m_aWarningOnBox.GetCtrlTextWidth( m_aWarningOnBox.GetText() ) + IMPL_EXTRA_BUTTON_WIDTH;
+ long nCtrlW = m_aWarningOnBox.GetSizePixel().Width();
+ if ( nTxtW >= nCtrlW )
+ {
+ long nTextHeight = m_aWarningOnBox.GetTextHeight();
+ Size aNewSize = m_aWarningOnBox.GetSizePixel();
+ aNewSize.Height() += nTextHeight;
+ m_aWarningOnBox.SetSizePixel( aNewSize );
+ aNewSize = GetSizePixel();
+ aNewSize.Height() += nTextHeight;
+ SetSizePixel( aNewSize );
+ }
+
+ // align the size of the information text control (FixedText) to its content
+ Size aMinSize = m_aInfoText.CalcMinimumSize( m_aInfoText.GetSizePixel().Width() );
+ long nTxtH = aMinSize.Height();
+ long nCtrlH = m_aInfoText.GetSizePixel().Height();
+ long nDelta = ( nCtrlH - nTxtH );
+ Size aNewSize = m_aInfoText.GetSizePixel();
+ aNewSize.Height() -= nDelta;
+ m_aInfoText.SetSizePixel( aNewSize );
+
+ // new position for the succeeding windows
+ Window* pWins[] =
+ {
+ &m_aLinkGraphicBtn, &m_aEmbedGraphicBtn, &m_aOptionLine, &m_aWarningOnBox
+ };
+ Window** pCurrent = pWins;
+ for ( sal_uInt32 i = 0; i < sizeof(pWins) / sizeof(*pWins); ++i, ++pCurrent )
+ {
+ Point aNewPos = (*pCurrent)->GetPosPixel();
+ aNewPos.Y() -= nDelta;
+ (*pCurrent)->SetPosPixel( aNewPos );
+ }
+
+ // new size of the dialog
+ aNewSize = GetSizePixel();
+ aNewSize.Height() -= nDelta;
+ SetSizePixel( aNewSize );
+
+ // recalculate the size and position of the buttons
+ nTxtW = m_aLinkGraphicBtn.GetCtrlTextWidth( m_aLinkGraphicBtn.GetText() );
+ long nTemp = m_aEmbedGraphicBtn.GetCtrlTextWidth( m_aEmbedGraphicBtn.GetText() );
+ if ( nTemp > nTxtW )
+ nTxtW = nTemp;
+ nTxtW += IMPL_EXTRA_BUTTON_WIDTH;
+ Size a3Size = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
+ Point aPos = m_aLinkGraphicBtn.GetPosPixel();
+ aPos.X() = ( aNewSize.Width() - (2*nTxtW) - a3Size.Width() ) / 2;
+ long nDefX = m_aWarningOnBox.GetPosPixel().X();
+ if ( nDefX < aPos.X() )
+ aPos.X() = nDefX;
+ aNewSize = m_aLinkGraphicBtn.GetSizePixel();
+ aNewSize.Width() = nTxtW;
+ m_aLinkGraphicBtn.SetPosSizePixel( aPos, aNewSize );
+ aPos.X() += nTxtW + a3Size.Width();
+ m_aEmbedGraphicBtn.SetPosSizePixel( aPos, aNewSize );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/linkwarn.hrc b/svx/source/dialog/linkwarn.hrc
new file mode 100644
index 000000000000..d01dc88d8e30
--- /dev/null
+++ b/svx/source/dialog/linkwarn.hrc
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * Copyright 2010 Novell, Inc.
+ *
+ * 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 _SVX_LINKWARN_HRC
+#define _SVX_LINKWARN_HRC
+
+#include <svtools/controldims.hrc>
+
+// dialog ids
+#define FI_QUERY 10
+#define FT_INFOTEXT 11
+#define PB_OK 12
+#define PB_NO 13
+#define FL_OPTION 15
+#define CB_WARNING_OFF 16
+
+// --------- general metrics ---------
+
+#define SYMBOL_EDGE 20
+#define DIALOG_WIDTH 220
+#define INFO_TEXT_LINES 11
+
+#define AW_COL_1 (RSC_SP_DLG_INNERBORDER_LEFT)
+#define AW_COL_2 (AW_COL_1+SYMBOL_EDGE+RSC_SP_CTRL_DESC_X)
+#define AW_COL_3 (AW_COL_2+RSC_CD_PUSHBUTTON_WIDTH+RSC_SP_CTRL_DESC_X)
+#define AW_COL_4 (DIALOG_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT-RSC_CD_PUSHBUTTON_WIDTH)
+
+#define AW_ROW_1 (RSC_SP_DLG_INNERBORDER_TOP)
+#define AW_ROW_2 (AW_ROW_1+INFO_TEXT_LINES*RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_Y)
+#define AW_ROW_3 (AW_ROW_2+RSC_CD_PUSHBUTTON_HEIGHT+RSC_SP_CTRL_DESC_Y)
+#define AW_ROW_4 (AW_ROW_3+RSC_CD_FIXEDLINE_HEIGHT+RSC_SP_CTRL_DESC_Y)
+
+#define DIALOG_HEIGHT (AW_ROW_4+RSC_CD_CHECKBOX_HEIGHT+RSC_SP_DLG_INNERBORDER_BOTTOM)
+
+#endif
diff --git a/svx/source/dialog/linkwarn.src b/svx/source/dialog/linkwarn.src
new file mode 100644
index 000000000000..100b53cb6e33
--- /dev/null
+++ b/svx/source/dialog/linkwarn.src
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * Copyright 2010 Novell, Inc.
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "linkwarn.hrc"
+#include "svx/dialogs.hrc"
+#include "helpid.hrc"
+
+ModalDialog RID_SVXDLG_LINK_WARNING
+{
+ Size = MAP_APPFONT( DIALOG_WIDTH, DIALOG_HEIGHT );
+ OutputSize = TRUE;
+ Closeable = FALSE;
+ Moveable = TRUE;
+ SVLook = TRUE;
+
+ Text = "%PRODUCTNAME %PRODUCTVERSION %PRODUCTEXTENSION";
+
+ FixedImage FI_QUERY
+ {
+ Pos = MAP_APPFONT( AW_COL_1, AW_ROW_1 );
+ Size = MAP_APPFONT( SYMBOL_EDGE, SYMBOL_EDGE );
+ };
+ FixedText FT_INFOTEXT
+ {
+ Pos = MAP_APPFONT( AW_COL_2, AW_ROW_1 );
+ Size = MAP_APPFONT( DIALOG_WIDTH-AW_COL_2-RSC_SP_DLG_INNERBORDER_RIGHT, INFO_TEXT_LINES*RSC_CD_FIXEDTEXT_HEIGHT );
+ NoLabel = TRUE;
+ Wordbreak = TRUE;
+ Text [ en-US ] = "The file %FILENAME will not be stored along with your document, but only referenced as a link. This is dangerous if you move and/or rename the files. Do you want to embed the graphic instead?";
+ Text [ de-DE ] = "Die Datei %FILENAME wird nicht zusammen mit dem Dokument gespeichert, sondern nur als Verweis referenziert. Dies kann zu Problemen führen, wenn die Dateien verschoben und/oder umbenannt werden. Möchten Sie stattdessen die Grafik als eingebettetes Objekt einfügen?";
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT( AW_COL_2, AW_ROW_2 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ DefButton = TRUE ;
+ Text [ en-US ] = "~Keep Link";
+ Text [ de-DE ] = "~Als Verweis einfügen";
+ };
+ CancelButton PB_NO
+ {
+ Pos = MAP_APPFONT( AW_COL_3, AW_ROW_2 );
+ Size = MAP_APPFONT( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+ Text [ en-US ] = "~Embed Graphic";
+ Text [ de-DE ] = "~Eingebettet einfügen";
+ };
+ FixedLine FL_OPTION
+ {
+ Pos = MAP_APPFONT( 0, AW_ROW_3 );
+ Size = MAP_APPFONT( DIALOG_WIDTH, RSC_CD_FIXEDLINE_HEIGHT );
+ };
+ CheckBox CB_WARNING_OFF
+ {
+ Pos = MAP_APPFONT( AW_COL_2, AW_ROW_4 );
+ Size = MAP_APPFONT( DIALOG_WIDTH-AW_COL_2-RSC_SP_DLG_INNERBORDER_RIGHT, RSC_CD_CHECKBOX_HEIGHT );
+ WordBreak = TRUE ;
+ Text [ en-US ] = "~Ask when linking a graphic";
+ Text [ de-DE ] = "~Nachfragen falls Grafik als Verweis eingefügt wird";
+ };
+};
diff --git a/svx/source/dialog/makefile.mk b/svx/source/dialog/makefile.mk
new file mode 100644
index 000000000000..3805de953c57
--- /dev/null
+++ b/svx/source/dialog/makefile.mk
@@ -0,0 +1,156 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+PRJ=..$/..
+PRJNAME=svx
+TARGET=dialogs
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+#
+.IF "$(GUI)"=="WNT"
+CFLAGS+= -DUNICODE -D_UNICODE
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=dialogs
+SRC1FILES = \
+ bmpmask.src \
+ contdlg.src \
+ ctredlin.src \
+ dlgctrl.src \
+ docrecovery.src \
+ fontwork.src \
+ frmsel.src \
+ hdft.src \
+ hyprlink.src \
+ imapdlg.src \
+ langbox.src \
+ language.src \
+ linkwarn.src \
+ passwd.src \
+ prtqry.src \
+ rubydialog.src\
+ ruler.src \
+ srchdlg.src \
+ svxbmpnumvalueset.src \
+ swframeposstrings.src \
+ txenctab.src \
+ ucsubset.src \
+ optgrid.src
+
+SRS2NAME=drawdlgs
+SRC2FILES = \
+ sdstring.src
+
+LIB1TARGET=$(SLB)$/$(TARGET)-core.lib
+
+LIB1OBJFILES= \
+ $(SLO)$/checklbx.obj \
+ $(SLO)$/dialmgr.obj\
+ $(SLO)$/dlgutil.obj \
+ $(SLO)$/framelink.obj\
+ $(SLO)$/langbox.obj \
+ $(SLO)$/simptabl.obj \
+ $(SLO)$/svxdlg.obj \
+ $(SLO)$/stddlg.obj \
+
+LIB2TARGET=$(SLB)$/$(TARGET).lib
+
+LIB2OBJFILES= \
+ $(SLO)$/charmap.obj \
+ $(SLO)$/connctrl.obj \
+ $(SLO)$/contwnd.obj \
+ $(SLO)$/ctredlin.obj \
+ $(SLO)$/databaseregistrationui.obj \
+ $(SLO)$/dialcontrol.obj \
+ $(SLO)$/dlgctl3d.obj \
+ $(SLO)$/dlgctrl.obj \
+ $(SLO)$/docrecovery.obj \
+ $(SLO)$/fntctrl.obj \
+ $(SLO)$/fontlb.obj \
+ $(SLO)$/fontwork.obj \
+ $(SLO)$/framelinkarray.obj \
+ $(SLO)$/frmdirlbox.obj \
+ $(SLO)$/frmsel.obj \
+ $(SLO)$/graphctl.obj \
+ $(SLO)$/grfflt.obj \
+ $(SLO)$/hdft.obj \
+ $(SLO)$/hyperdlg.obj \
+ $(SLO)$/hyprlink.obj \
+ $(SLO)$/imapdlg.obj \
+ $(SLO)$/imapwnd.obj \
+ $(SLO)$/linkwarn.obj \
+ $(SLO)$/measctrl.obj \
+ $(SLO)$/orienthelper.obj \
+ $(SLO)$/pagectrl.obj \
+ $(SLO)$/paraprev.obj \
+ $(SLO)$/passwd.obj \
+ $(SLO)$/pfiledlg.obj \
+ $(SLO)$/prtqry.obj \
+ $(SLO)$/relfld.obj \
+ $(SLO)$/rlrcitem.obj \
+ $(SLO)$/rubydialog.obj \
+ $(SLO)$/rulritem.obj \
+ $(SLO)$/SpellDialogChildWindow.obj \
+ $(SLO)$/srchctrl.obj \
+ $(SLO)$/srchdlg.obj \
+ $(SLO)$/strarray.obj \
+ $(SLO)$/svxbmpnumvalueset.obj\
+ $(SLO)$/svxgrahicitem.obj \
+ $(SLO)$/svxruler.obj \
+ $(SLO)$/swframeexample.obj \
+ $(SLO)$/swframeposstrings.obj \
+ $(SLO)$/txencbox.obj \
+ $(SLO)$/txenctab.obj \
+ $(SLO)$/wrapfield.obj \
+ $(SLO)$/_bmpmask.obj \
+ $(SLO)$/_contdlg.obj \
+ $(SLO)$/optgrid.obj
+
+
+.IF "$(GUI)"=="UNX"
+LIB2OBJFILES += $(SLO)$/sendreportunx.obj
+.ELSE
+.IF "$(GUI)"=="WNT"
+LIB2OBJFILES += $(SLO)$/sendreportw32.obj
+.ELSE
+LIB2OBJFILES += $(SLO)$/sendreportgen.obj
+.ENDIF
+.ENDIF
+
+SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES)
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx
new file mode 100644
index 000000000000..1ff587ac0b53
--- /dev/null
+++ b/svx/source/dialog/measctrl.cxx
@@ -0,0 +1,201 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <svx/svdomeas.hxx>
+#include <svx/svdmodel.hxx>
+
+#include "measctrl.hxx"
+#include <svx/dialmgr.hxx>
+#include "dlgutil.hxx"
+
+/*************************************************************************
+|*
+|* Ctor SvxXMeasurePreview
+|*
+*************************************************************************/
+
+SvxXMeasurePreview::SvxXMeasurePreview
+(
+ Window* pParent,
+ const ResId& rResId,
+ const SfxItemSet& rInAttrs
+) :
+
+ Control ( pParent, rResId ),
+ rAttrs ( rInAttrs )
+
+{
+ SetMapMode( MAP_100TH_MM );
+
+ Size aSize = GetOutputSize();
+
+ // Massstab: 1:2
+ MapMode aMapMode = GetMapMode();
+ aMapMode.SetScaleX( Fraction( 1, 2 ) );
+ aMapMode.SetScaleY( Fraction( 1, 2 ) );
+ SetMapMode( aMapMode );
+
+ aSize = GetOutputSize();
+ Rectangle aRect = Rectangle( Point(), aSize );
+ Point aPt1 = Point( aSize.Width() / 5, (long) ( aSize.Height() / 2 ) );
+ Point aPt2 = Point( aSize.Width() * 4 / 5, (long) ( aSize.Height() / 2 ) );
+
+ pMeasureObj = new SdrMeasureObj( aPt1, aPt2 );
+ pModel = new SdrModel();
+ pMeasureObj->SetModel( pModel );
+
+ //pMeasureObj->SetItemSetAndBroadcast(rInAttrs);
+ pMeasureObj->SetMergedItemSetAndBroadcast(rInAttrs);
+
+ SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
+
+ Invalidate();
+}
+
+/*************************************************************************
+|*
+|* Dtor SvxXMeasurePreview
+|*
+*************************************************************************/
+
+SvxXMeasurePreview::~SvxXMeasurePreview()
+{
+ // #111111#
+ // No one is deleting the MeasureObj? This is not only an error but also
+ // a memory leak (!). Main problem is that this object is still listening to
+ // a StyleSheet of the model which was set. Thus, if You want to keep the obnject,
+ // set the modfel to 0L, if object is not needed (seems to be the case here),
+ // delete it.
+ delete pMeasureObj;
+
+ delete pModel;
+}
+
+/*************************************************************************
+|*
+|* SvxXMeasurePreview: Paint()
+|*
+*************************************************************************/
+
+void SvxXMeasurePreview::Paint( const Rectangle& )
+{
+ pMeasureObj->SingleObjectPainter(*this); // #110094#-17
+}
+
+/*************************************************************************
+|*
+|* SvxXMeasurePreview: SetAttributes()
+|*
+*************************************************************************/
+
+void SvxXMeasurePreview::SetAttributes( const SfxItemSet& rInAttrs )
+{
+ //pMeasureObj->SetItemSetAndBroadcast(rInAttrs);
+ pMeasureObj->SetMergedItemSetAndBroadcast(rInAttrs);
+
+ Invalidate();
+}
+
+/*************************************************************************
+|*
+|* SvxXMeasurePreview: SetAttributes()
+|*
+*************************************************************************/
+
+void SvxXMeasurePreview::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ BOOL bZoomIn = rMEvt.IsLeft() && !rMEvt.IsShift();
+ BOOL bZoomOut = rMEvt.IsRight() || rMEvt.IsShift();
+ BOOL bCtrl = rMEvt.IsMod1();
+
+ if( bZoomIn || bZoomOut )
+ {
+ MapMode aMapMode = GetMapMode();
+ Fraction aXFrac = aMapMode.GetScaleX();
+ Fraction aYFrac = aMapMode.GetScaleY();
+ Fraction* pMultFrac;
+
+ if( bZoomIn )
+ {
+ if( bCtrl )
+ pMultFrac = new Fraction( 3, 2 );
+ else
+ pMultFrac = new Fraction( 11, 10 );
+ }
+ else
+ {
+ if( bCtrl )
+ pMultFrac = new Fraction( 2, 3 );
+ else
+ pMultFrac = new Fraction( 10, 11 );
+ }
+
+ aXFrac *= *pMultFrac;
+ aYFrac *= *pMultFrac;
+ if( (double)aXFrac > 0.001 && (double)aXFrac < 1000.0 &&
+ (double)aYFrac > 0.001 && (double)aYFrac < 1000.0 )
+ {
+ aMapMode.SetScaleX( aXFrac );
+ aMapMode.SetScaleY( aYFrac );
+ SetMapMode( aMapMode );
+
+ Size aOutSize( GetOutputSize() );
+
+ Point aPt( aMapMode.GetOrigin() );
+ long nX = (long)( ( (double)aOutSize.Width() - ( (double)aOutSize.Width() * (double)*pMultFrac ) ) / 2.0 + 0.5 );
+ long nY = (long)( ( (double)aOutSize.Height() - ( (double)aOutSize.Height() * (double)*pMultFrac ) ) / 2.0 + 0.5 );
+ aPt.X() += nX;
+ aPt.Y() += nY;
+
+ aMapMode.SetOrigin( aPt );
+ SetMapMode( aMapMode );
+
+ Invalidate();
+ }
+ delete pMultFrac;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxXMeasurePreview::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Control::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ SetDrawMode( GetSettings().GetStyleSettings().GetHighContrastMode() ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/optgrid.cxx b/svx/source/dialog/optgrid.cxx
new file mode 100644
index 000000000000..eaf495d28c72
--- /dev/null
+++ b/svx/source/dialog/optgrid.cxx
@@ -0,0 +1,421 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/shl.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/module.hxx>
+#include <svl/intitem.hxx>
+
+#define _SVX_OPTGRID_CXX
+
+#include <svx/svxids.hrc>
+#include <svx/dialmgr.hxx>
+#include "optgrid.hxx"
+#include <svx/dialogs.hrc>
+#include "optgrid.hrc"
+#include "dlgutil.hxx"
+
+/* -----------------18.08.98 17:41-------------------
+ * local functions
+ * --------------------------------------------------*/
+void lcl_GetMinMax(MetricField& rField, long& nFirst, long& nLast, long& nMin, long& nMax)
+{
+ nFirst = static_cast<long>(rField.Denormalize( rField.GetFirst( FUNIT_TWIP ) ));
+ nLast = static_cast<long>(rField.Denormalize( rField.GetLast( FUNIT_TWIP ) ));
+ nMin = static_cast<long>(rField.Denormalize( rField.GetMin( FUNIT_TWIP ) ));
+ nMax = static_cast<long>(rField.Denormalize( rField.GetMax( FUNIT_TWIP ) ));
+}
+
+void lcl_SetMinMax(MetricField& rField, long nFirst, long nLast, long nMin, long nMax)
+{
+ rField.SetFirst( rField.Normalize( nFirst ), FUNIT_TWIP );
+ rField.SetLast( rField.Normalize( nLast ), FUNIT_TWIP );
+ rField.SetMin( rField.Normalize( nMin ), FUNIT_TWIP );
+ rField.SetMax( rField.Normalize( nMax ), FUNIT_TWIP );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Rastereinstellungen Ctor
+ --------------------------------------------------------------------*/
+
+SvxOptionsGrid::SvxOptionsGrid() :
+ nFldDrawX ( 100 ),
+ nFldDivisionX ( 0 ),
+ nFldDrawY ( 100 ),
+ nFldDivisionY ( 0 ),
+ nFldSnapX ( 100 ),
+ nFldSnapY ( 100 ),
+ bUseGridsnap ( 0 ),
+ bSynchronize ( 1 ),
+ bGridVisible ( 0 ),
+ bEqualGrid ( 1 )
+{
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Rastereinstellungen Dtor
+ --------------------------------------------------------------------*/
+
+SvxOptionsGrid::~SvxOptionsGrid()
+{
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Item fuer Rastereinstellungen
+ --------------------------------------------------------------------*/
+
+SvxGridItem::SvxGridItem( const SvxGridItem& rItem )
+: SvxOptionsGrid()
+, SfxPoolItem(rItem)
+{
+ bUseGridsnap = rItem.bUseGridsnap ;
+ bSynchronize = rItem.bSynchronize ;
+ bGridVisible = rItem.bGridVisible ;
+ bEqualGrid = rItem.bEqualGrid ;
+ nFldDrawX = rItem.nFldDrawX ;
+ nFldDivisionX= rItem.nFldDivisionX;
+ nFldDrawY = rItem.nFldDrawY ;
+ nFldDivisionY= rItem.nFldDivisionY;
+ nFldSnapX = rItem.nFldSnapX ;
+ nFldSnapY = rItem.nFldSnapY ;
+
+};
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+SfxPoolItem* SvxGridItem::Clone( SfxItemPool* ) const
+{
+ return new SvxGridItem( *this );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+int SvxGridItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unterschiedliche Typen" );
+
+ const SvxGridItem& rItem = (const SvxGridItem&) rAttr;
+
+ return ( bUseGridsnap == rItem.bUseGridsnap &&
+ bSynchronize == rItem.bSynchronize &&
+ bGridVisible == rItem.bGridVisible &&
+ bEqualGrid == rItem.bEqualGrid &&
+ nFldDrawX == rItem.nFldDrawX &&
+ nFldDivisionX== rItem.nFldDivisionX&&
+ nFldDrawY == rItem.nFldDrawY &&
+ nFldDivisionY== rItem.nFldDivisionY&&
+ nFldSnapX == rItem.nFldSnapX &&
+ nFldSnapY == rItem.nFldSnapY );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+SfxItemPresentation SvxGridItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ String& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = String::CreateFromAscii("SvxGridItem");
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+/*----------------- OS 23.02.95 -----------------------
+ TabPage Rastereinstellungen
+-------------------------------------------------------*/
+
+SvxGridTabPage::SvxGridTabPage( Window* pParent, const SfxItemSet& rCoreSet) :
+
+ SfxTabPage( pParent, SVX_RES( RID_SVXPAGE_GRID ), rCoreSet ),
+
+ aCbxUseGridsnap ( this, SVX_RES( CBX_USE_GRIDSNAP ) ),
+ aCbxGridVisible ( this, SVX_RES( CBX_GRID_VISIBLE ) ),
+
+ aFlResolution ( this, SVX_RES( FL_RESOLUTION ) ),
+ aFtDrawX ( this, SVX_RES( FT_DRAW_X ) ),
+ aMtrFldDrawX ( this, SVX_RES( MTR_FLD_DRAW_X ) ),
+ aFtDrawY ( this, SVX_RES( FT_DRAW_Y ) ),
+ aMtrFldDrawY ( this, SVX_RES( MTR_FLD_DRAW_Y ) ),
+
+ aFlDivision ( this, SVX_RES( FL_DIVISION ) ),
+ aFtDivisionX( this, SVX_RES( FT_DIVISION_X) ),
+ aNumFldDivisionX( this, SVX_RES( NUM_FLD_DIVISION_X ) ),
+ aDivisionPointX( this, SVX_RES( FT_HORZ_POINTS) ),
+
+ aFtDivisionY( this, SVX_RES( FT_DIVISION_Y) ),
+ aNumFldDivisionY( this, SVX_RES( NUM_FLD_DIVISION_Y ) ),
+ aDivisionPointY( this, SVX_RES( FT_VERT_POINTS) ),
+
+ aCbxSynchronize ( this, SVX_RES( CBX_SYNCHRONIZE ) ),
+ aGrpDrawGrid ( this, SVX_RES( GRP_DRAWGRID ) ),
+
+ aGrpSnap ( this, SVX_RES( GRP_SNAP ) ),
+ aCbxSnapHelplines ( this, SVX_RES( CBX_SNAP_HELPLINES ) ),
+ aCbxSnapBorder ( this, SVX_RES( CBX_SNAP_BORDER ) ),
+ aCbxSnapFrame ( this, SVX_RES( CBX_SNAP_FRAME ) ),
+ aCbxSnapPoints ( this, SVX_RES( CBX_SNAP_POINTS ) ),
+ aFtSnapArea ( this, SVX_RES( FT_SNAP_AREA ) ),
+ aMtrFldSnapArea ( this, SVX_RES( MTR_FLD_SNAP_AREA ) ),
+
+ aSeparatorFL ( this, SVX_RES( FL_SEPARATOR ) ),
+
+ aGrpOrtho ( this, SVX_RES( GRP_ORTHO ) ),
+ aCbxOrtho ( this, SVX_RES( CBX_ORTHO ) ),
+ aCbxBigOrtho ( this, SVX_RES( CBX_BIGORTHO ) ),
+ aCbxRotate ( this, SVX_RES( CBX_ROTATE ) ),
+ aMtrFldAngle ( this, SVX_RES( MTR_FLD_ANGLE ) ),
+ aFtBezAngle ( this, SVX_RES( FT_BEZ_ANGLE ) ),
+ aMtrFldBezAngle ( this, SVX_RES( MTR_FLD_BEZ_ANGLE ) ),
+
+ bAttrModified( FALSE )
+{
+ // diese Page braucht ExchangeSupport
+ SetExchangeSupport();
+
+ FreeResource();
+
+ aDivisionPointY.SetText(aDivisionPointX.GetText());
+ // Metrik einstellen
+ FieldUnit eFUnit = GetModuleFieldUnit( rCoreSet );
+ long nFirst, nLast, nMin, nMax;
+
+ lcl_GetMinMax(aMtrFldDrawX, nFirst, nLast, nMin, nMax);
+ SetFieldUnit( aMtrFldDrawX, eFUnit, TRUE );
+ lcl_SetMinMax(aMtrFldDrawX, nFirst, nLast, nMin, nMax);
+
+ lcl_GetMinMax(aMtrFldDrawY, nFirst, nLast, nMin, nMax);
+ SetFieldUnit( aMtrFldDrawY, eFUnit, TRUE );
+ lcl_SetMinMax(aMtrFldDrawY, nFirst, nLast, nMin, nMax);
+
+
+ aCbxRotate.SetClickHdl( LINK( this, SvxGridTabPage, ClickRotateHdl_Impl ) );
+ Link aLink = LINK( this, SvxGridTabPage, ChangeGridsnapHdl_Impl );
+ aCbxUseGridsnap.SetClickHdl( aLink );
+ aCbxSynchronize.SetClickHdl( aLink );
+ aCbxGridVisible.SetClickHdl( aLink );
+ aMtrFldDrawX.SetModifyHdl(
+ LINK( this, SvxGridTabPage, ChangeDrawHdl_Impl ) );
+ aMtrFldDrawY.SetModifyHdl(
+ LINK( this, SvxGridTabPage, ChangeDrawHdl_Impl ) );
+ aNumFldDivisionX.SetModifyHdl(
+ LINK( this, SvxGridTabPage, ChangeDivisionHdl_Impl ) );
+ aNumFldDivisionY.SetModifyHdl(
+ LINK( this, SvxGridTabPage, ChangeDivisionHdl_Impl ) );
+}
+
+//------------------------------------------------------------------------
+
+SfxTabPage* SvxGridTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
+{
+ return ( new SvxGridTabPage( pParent, rAttrSet ) );
+}
+
+//------------------------------------------------------------------------
+
+BOOL SvxGridTabPage::FillItemSet( SfxItemSet& rCoreSet )
+{
+ if ( bAttrModified )
+ {
+ SvxGridItem aGridItem( SID_ATTR_GRID_OPTIONS );
+
+ aGridItem.bUseGridsnap = aCbxUseGridsnap.IsChecked();
+ aGridItem.bSynchronize = aCbxSynchronize.IsChecked();
+ aGridItem.bGridVisible = aCbxGridVisible.IsChecked();
+
+ SfxMapUnit eUnit =
+ rCoreSet.GetPool()->GetMetric( GetWhich( SID_ATTR_GRID_OPTIONS ) );
+ long nX =GetCoreValue( aMtrFldDrawX, eUnit );
+ long nY = GetCoreValue( aMtrFldDrawY, eUnit );
+
+ aGridItem.nFldDrawX = (UINT32) nX;
+ aGridItem.nFldDrawY = (UINT32) nY;
+ aGridItem.nFldDivisionX = static_cast<long>(aNumFldDivisionX.GetValue());
+ aGridItem.nFldDivisionY = static_cast<long>(aNumFldDivisionY.GetValue());
+
+ rCoreSet.Put( aGridItem );
+ }
+ return bAttrModified;
+}
+
+//------------------------------------------------------------------------
+
+void SvxGridTabPage::Reset( const SfxItemSet& rSet )
+{
+ const SfxPoolItem* pAttr = 0;
+
+ if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS , FALSE,
+ (const SfxPoolItem**)&pAttr ))
+ {
+ const SvxGridItem* pGridAttr = (SvxGridItem*)pAttr;
+ aCbxUseGridsnap.Check( pGridAttr->bUseGridsnap == 1 );
+ aCbxSynchronize.Check( pGridAttr->bSynchronize == 1 );
+ aCbxGridVisible.Check( pGridAttr->bGridVisible == 1 );
+
+ SfxMapUnit eUnit =
+ rSet.GetPool()->GetMetric( GetWhich( SID_ATTR_GRID_OPTIONS ) );
+ SetMetricValue( aMtrFldDrawX , pGridAttr->nFldDrawX, eUnit );
+ SetMetricValue( aMtrFldDrawY , pGridAttr->nFldDrawY, eUnit );
+
+// UINT32 nFineX = pGridAttr->nFldDivisionX;
+// UINT32 nFineY = pGridAttr->nFldDivisionY;
+// aNumFldDivisionX.SetValue( nFineX ? (pGridAttr->nFldDrawX / nFineX - 1) : 0 );
+// aNumFldDivisionY.SetValue( nFineY ? (pGridAttr->nFldDrawY / nFineY - 1) : 0 );
+ aNumFldDivisionX.SetValue( pGridAttr->nFldDivisionX );
+ aNumFldDivisionY.SetValue( pGridAttr->nFldDivisionY );
+ }
+
+ ChangeGridsnapHdl_Impl( &aCbxUseGridsnap );
+ bAttrModified = FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxGridTabPage::ActivatePage( const SfxItemSet& rSet )
+{
+ const SfxPoolItem* pAttr = NULL;
+ if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_GRID_OPTIONS , FALSE,
+ (const SfxPoolItem**)&pAttr ))
+ {
+ const SvxGridItem* pGridAttr = (SvxGridItem*) pAttr;
+ aCbxUseGridsnap.Check( pGridAttr->bUseGridsnap == 1 );
+
+ ChangeGridsnapHdl_Impl( &aCbxUseGridsnap );
+ }
+
+ // Metrik ggfs. aendern (da TabPage im Dialog liegt,
+ // wo die Metrik eingestellt werden kann
+ //USHORT nWhich = GetWhich( SID_ATTR_METRIC );
+ //if( rSet.GetItemState( GetWhich( SID_ATTR_METRIC ) ) >= SFX_ITEM_AVAILABLE )
+ if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC , FALSE,
+ (const SfxPoolItem**)&pAttr ))
+ {
+ const SfxUInt16Item* pItem = (SfxUInt16Item*) pAttr;
+
+ FieldUnit eFUnit = (FieldUnit)(long)pItem->GetValue();
+
+ if( eFUnit != aMtrFldDrawX.GetUnit() )
+ {
+ // Metriken einstellen
+ long nFirst, nLast, nMin, nMax;
+ long nVal = static_cast<long>(aMtrFldDrawX.Denormalize( aMtrFldDrawX.GetValue( FUNIT_TWIP ) ));
+
+ lcl_GetMinMax(aMtrFldDrawX, nFirst, nLast, nMin, nMax);
+ SetFieldUnit( aMtrFldDrawX, eFUnit, TRUE );
+ lcl_SetMinMax(aMtrFldDrawX, nFirst, nLast, nMin, nMax);
+
+ aMtrFldDrawX.SetValue( aMtrFldDrawX.Normalize( nVal ), FUNIT_TWIP );
+
+ nVal = static_cast<long>(aMtrFldDrawY.Denormalize( aMtrFldDrawY.GetValue( FUNIT_TWIP ) ));
+ lcl_GetMinMax(aMtrFldDrawY, nFirst, nLast, nMin, nMax);
+ SetFieldUnit( aMtrFldDrawY, eFUnit, TRUE );
+ lcl_SetMinMax(aMtrFldDrawY, nFirst, nLast, nMin, nMax);
+ aMtrFldDrawY.SetValue( aMtrFldDrawY.Normalize( nVal ), FUNIT_TWIP );
+
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+int SvxGridTabPage::DeactivatePage( SfxItemSet* _pSet )
+{
+ if ( _pSet )
+ FillItemSet( *_pSet );
+ return( LEAVE_PAGE );
+}
+//------------------------------------------------------------------------
+IMPL_LINK( SvxGridTabPage, ChangeDrawHdl_Impl, MetricField *, pField )
+{
+ bAttrModified = TRUE;
+ if( aCbxSynchronize.IsChecked() )
+ {
+ if(pField == &aMtrFldDrawX)
+ aMtrFldDrawY.SetValue( aMtrFldDrawX.GetValue() );
+ else
+ aMtrFldDrawX.SetValue( aMtrFldDrawY.GetValue() );
+ }
+ return 0;
+}
+//------------------------------------------------------------------------
+
+IMPL_LINK( SvxGridTabPage, ClickRotateHdl_Impl, void *, EMPTYARG )
+{
+ if( aCbxRotate.IsChecked() )
+ aMtrFldAngle.Enable();
+ else
+ aMtrFldAngle.Disable();
+
+ return( 0L );
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( SvxGridTabPage, ChangeDivisionHdl_Impl, NumericField *, pField )
+{
+ bAttrModified = TRUE;
+ if( aCbxSynchronize.IsChecked() )
+ {
+ if(&aNumFldDivisionX == pField)
+ aNumFldDivisionY.SetValue( aNumFldDivisionX.GetValue() );
+ else
+ aNumFldDivisionX.SetValue( aNumFldDivisionY.GetValue() );
+ }
+ return 0;
+}
+//------------------------------------------------------------------------
+
+IMPL_LINK( SvxGridTabPage, ChangeGridsnapHdl_Impl, void *, EMPTYARG )
+{
+ bAttrModified = TRUE;
+ return 0;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/optgrid.hrc b/svx/source/dialog/optgrid.hrc
new file mode 100644
index 000000000000..f010dbb6a649
--- /dev/null
+++ b/svx/source/dialog/optgrid.hrc
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * 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 _SVX_OPTGRID_HRC
+#define _SVX_OPTGRID_HRC
+
+//Grid-Page
+#define MTR_FLD_GRID 1
+#define GRP_DRAWGRID 2
+#define GRP_SNAPGRID 3
+#define CBX_USE_GRIDSNAP 4
+#define CBX_SYNCHRONIZE 5
+#define CBX_EQUAL_GRID 6
+#define CBX_SNAPGRID 7
+#define CBX_GRID_VISIBLE 8
+#define MTR_FLD_DRAW_Y 9
+#define MTR_FLD_SNAP_X 10
+#define MTR_FLD_SNAP_Y 11
+#define MTR_FLD_DRAW_X 12
+#define NUM_FLD_DIVISION_X 13
+#define NUM_FLD_DIVISION_Y 14
+#define FT_SNAP_X 15
+#define FT_SNAP_Y 16
+#define FT_DRAW_X 17
+#define FT_DRAW_Y 18
+#define FL_RESOLUTION 19
+#define FL_DIVISION 20
+#define FT_VERT_POINTS 21
+#define FT_HORZ_POINTS 22
+#define FT_DIVISION_Y 23
+#define FT_DIVISION_X 24
+#define CBX_SNAP_HELPLINES 25
+#define CBX_SNAP_BORDER 26
+#define CBX_SNAP_FRAME 27
+#define CBX_SNAP_POINTS 28
+#define FT_SNAP_AREA 29
+#define MTR_FLD_SNAP_AREA 30
+#define GRP_SNAP 31
+#define CBX_ORTHO 32
+#define CBX_BIGORTHO 33
+#define CBX_ROTATE 34
+#define MTR_FLD_ANGLE 35
+#define FT_BEZ_ANGLE 36
+#define MTR_FLD_BEZ_ANGLE 37
+#define GRP_ORTHO 38
+#define FL_SEPARATOR 39
+
+#endif
diff --git a/svx/source/dialog/optgrid.src b/svx/source/dialog/optgrid.src
new file mode 100644
index 000000000000..e427ddfd08e4
--- /dev/null
+++ b/svx/source/dialog/optgrid.src
@@ -0,0 +1,353 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include <sfx2/sfx.hrc>
+#include "helpid.hrc"
+#include <svx/dialogs.hrc>
+#include "optgrid.hrc"
+ // pragma ----------------------------------------------------------------
+
+TabPage RID_SVXPAGE_GRID
+{
+ HelpId = HID_OPTIONS_GRID ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ FixedLine GRP_DRAWGRID
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Grid" ;
+ };
+ CheckBox CBX_USE_GRIDSNAP
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 204 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Sn~ap to grid" ;
+ };
+ CheckBox CBX_GRID_VISIBLE
+ {
+ Pos = MAP_APPFONT ( 12 , 27 ) ;
+ Size = MAP_APPFONT ( 204 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "V~isible grid" ;
+ };
+ FixedLine FL_RESOLUTION
+ {
+ Pos = MAP_APPFONT ( 6 , 45 ) ;
+ Size = MAP_APPFONT ( 120 , 8 ) ;
+ Text [ en-US ] = "Resolution" ;
+ };
+ FixedText FT_DRAW_X
+ {
+ Pos = MAP_APPFONT ( 12 , 56 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "H~orizontal";
+ };
+ FixedText FT_DRAW_Y
+ {
+ Pos = MAP_APPFONT ( 12 , 71 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "~Vertical";
+ };
+ MetricField MTR_FLD_DRAW_X
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 75 , 54 ) ;
+ Size = MAP_APPFONT ( 45 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 10 ;
+ First = 10 ;
+ Maximum = 10000 ;
+ Last = 10000 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ SpinSize = 50 ;
+ };
+ MetricField MTR_FLD_DRAW_Y
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 75 , 69 ) ;
+ Size = MAP_APPFONT ( 45 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 10 ;
+ First = 10 ;
+ Maximum = 10000 ;
+ Last = 10000 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ SpinSize = 50 ;
+ };
+ FixedLine FL_DIVISION
+ {
+ Pos = MAP_APPFONT ( 130 , 45 ) ;
+ Size = MAP_APPFONT ( 124 , 8 ) ;
+ Text [ en-US ] = "Subdivision" ;
+ };
+ FixedText FT_DIVISION_X
+ {
+ Pos = MAP_APPFONT ( 136 , 56 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Horizont~al";
+ };
+ FixedText FT_DIVISION_Y
+ {
+ Pos = MAP_APPFONT ( 136 , 71 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "V~ertical";
+ };
+ NumericField NUM_FLD_DIVISION_X
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 195 , 54 ) ;
+ Size = MAP_APPFONT ( 25 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 99 ;
+ Last = 99 ;
+ StrictFormat = TRUE ;
+ SpinSize = 1 ;
+ };
+ FixedText FT_HORZ_POINTS
+ {
+ Pos = MAP_APPFONT ( 223 , 56 ) ;
+ Size = MAP_APPFONT ( 29 , 8 ) ;
+ Text [ en-US ] = "point(s)" ;
+ };
+ NumericField NUM_FLD_DIVISION_Y
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 195 , 69 ) ;
+ Size = MAP_APPFONT ( 25 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 99 ;
+ Last = 99 ;
+ StrictFormat = TRUE ;
+ SpinSize = 1 ;
+ };
+ FixedText FT_VERT_POINTS
+ {
+ Pos = MAP_APPFONT ( 223 , 71 ) ;
+ Size = MAP_APPFONT ( 29 , 8 ) ;
+
+ };
+ CheckBox CBX_SYNCHRONIZE
+ {
+ Pos = MAP_APPFONT ( 12 , 84 ) ;
+ Size = MAP_APPFONT ( 127 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Synchronize a~xes" ;
+ };
+ FixedLine GRP_SNAP
+ {
+ Pos = MAP_APPFONT ( 6 , 100 ) ;
+ Size = MAP_APPFONT ( 120 , 8 ) ;
+ Hide = TRUE;
+ Text [ en-US ] = "Snap" ;
+ };
+
+ CheckBox CBX_SNAP_HELPLINES
+ {
+ Pos = MAP_APPFONT ( 12 , 111 ) ;
+ Size = MAP_APPFONT ( 106 , 10 ) ;
+ Hide = TRUE;
+ TabStop = TRUE ;
+ Text [ en-US ] = "To snap lines" ;
+ };
+ CheckBox CBX_SNAP_BORDER
+ {
+ Hide = TRUE;
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 125 ) ;
+ Size = MAP_APPFONT ( 106 , 10 ) ;
+ Text [ en-US ] = "To the ~page margins" ;
+ };
+ CheckBox CBX_SNAP_FRAME
+ {
+ Pos = MAP_APPFONT ( 12 , 139 ) ;
+ Size = MAP_APPFONT ( 106 , 10 ) ;
+ Hide = TRUE;
+ TabStop = TRUE ;
+ Text [ en-US ] = "To object ~frame" ;
+ };
+ CheckBox CBX_SNAP_POINTS
+ {
+ Pos = MAP_APPFONT ( 12 , 153 ) ;
+ Size = MAP_APPFONT ( 106 , 10 ) ;
+ Hide = TRUE;
+ TabStop = TRUE ;
+ Text [ en-US ] = "To obje~ct points" ;
+ };
+ FixedText FT_SNAP_AREA
+ {
+ Pos = MAP_APPFONT ( 12 , 169 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ Hide = TRUE;
+ Text [ en-US ] = "~Snap range" ;
+ };
+ MetricField MTR_FLD_SNAP_AREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 83 , 167 ) ;
+ Size = MAP_APPFONT ( 35 , 12 ) ;
+ Hide = TRUE;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 1 ;
+ Maximum = 50 ;
+ StrictFormat = TRUE ;
+ Unit = FUNIT_CUSTOM ;
+ First = 1 ;
+ Last = 999 ;
+ CustomUnitText [ en-US ] = " Pixels" ;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 127 , 111 ) ;
+ Size = MAP_APPFONT ( 4 , 68 ) ;
+ Hide = TRUE;
+ Vert = TRUE;
+ };
+ FixedLine GRP_ORTHO
+ {
+ Pos = MAP_APPFONT ( 130 , 100 ) ;
+ Size = MAP_APPFONT ( 124 , 8 ) ;
+ Hide = TRUE;
+ Text [ en-US ] = "Snap position" ;
+ };
+ CheckBox CBX_ORTHO
+ {
+ Pos = MAP_APPFONT ( 136 , 111 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Hide = TRUE;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~When creating or moving objects" ;
+ };
+ CheckBox CBX_BIGORTHO
+ {
+ Pos = MAP_APPFONT ( 136 , 125 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Hide = TRUE;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Extend edges" ;
+ };
+ CheckBox CBX_ROTATE
+ {
+ Pos = MAP_APPFONT ( 136 , 139 ) ;
+ // 136, 111
+ Size = MAP_APPFONT ( 55 , 10 ) ;
+ Hide = TRUE;
+ TabStop = TRUE ;
+ Text [ en-US ] = "When ro~tating" ;
+ };
+ MetricField MTR_FLD_ANGLE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 194 , 137 ) ;
+ // 190, 111
+ Size = MAP_APPFONT ( 54 , 12 ) ;
+ Hide = TRUE;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 18000 ;
+ Last = 18000 ;
+ DecimalDigits = 2 ;
+ StrictFormat = TRUE ;
+ Unit = FUNIT_CUSTOM ;
+ SpinSize = 500 ;
+ CustomUnitText [ en-US ] = " degrees" ;
+ };
+ FixedText FT_BEZ_ANGLE
+ {
+ Pos = MAP_APPFONT ( 136 , 156 ) ;
+ Size = MAP_APPFONT ( 55 , 10 ) ;
+ Hide = TRUE;
+ Text [ en-US ] = "Point reducti~on" ;
+ };
+ MetricField MTR_FLD_BEZ_ANGLE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 194 , 154 ) ;
+ Size = MAP_APPFONT ( 54 , 12 ) ;
+ Hide = TRUE;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 9000 ;
+ Last = 9000 ;
+ DecimalDigits = 2 ;
+ StrictFormat = TRUE ;
+ Unit = FUNIT_CUSTOM ;
+ SpinSize = 500 ;
+ CustomUnitText [ en-US ] = " degrees" ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/orienthelper.cxx b/svx/source/dialog/orienthelper.cxx
new file mode 100644
index 000000000000..713ca089ba0b
--- /dev/null
+++ b/svx/source/dialog/orienthelper.cxx
@@ -0,0 +1,206 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "orienthelper.hxx"
+
+#include <vector>
+#include <utility>
+
+#include <vcl/button.hxx>
+#include "dialcontrol.hxx"
+
+namespace svx {
+
+// ============================================================================
+
+struct OrientationHelper_Impl
+{
+ typedef std::pair< Window*, TriState > WindowPair;
+ typedef std::vector< WindowPair > WindowVec;
+
+ DialControl& mrCtrlDial;
+ CheckBox& mrCbStacked;
+ WindowVec maWinVec;
+ bool mbEnabled;
+ bool mbVisible;
+
+ explicit OrientationHelper_Impl( DialControl& rCtrlDial, CheckBox& rCbStacked );
+
+ void AddDependentWindow( Window& rWindow, TriState eDisableIfStacked );
+
+ void EnableDependentWindows();
+ void EnableWindow( Window& rWindow, TriState eDisableIfStacked );
+
+ void ShowDependentWindows();
+
+ DECL_LINK( ClickHdl, void* );
+};
+
+// ----------------------------------------------------------------------------
+
+OrientationHelper_Impl::OrientationHelper_Impl( DialControl& rCtrlDial, CheckBox& rCbStacked ) :
+ mrCtrlDial( rCtrlDial ),
+ mrCbStacked( rCbStacked ),
+ mbEnabled( rCtrlDial.IsEnabled() ),
+ mbVisible( rCtrlDial.IsVisible() )
+{
+ maWinVec.push_back( WindowPair( &mrCtrlDial, STATE_CHECK ) );
+ maWinVec.push_back( WindowPair( &mrCbStacked, STATE_DONTKNOW ) );
+ mrCbStacked.SetClickHdl( LINK( this, OrientationHelper_Impl, ClickHdl ) );
+}
+
+void OrientationHelper_Impl::AddDependentWindow( Window& rWindow, TriState eDisableIfStacked )
+{
+ maWinVec.push_back( std::make_pair( &rWindow, eDisableIfStacked ) );
+ EnableWindow( rWindow, eDisableIfStacked );
+}
+
+void OrientationHelper_Impl::EnableDependentWindows()
+{
+ for( WindowVec::iterator aIt = maWinVec.begin(), aEnd = maWinVec.end(); aIt != aEnd; ++aIt )
+ EnableWindow( *aIt->first, aIt->second );
+}
+
+void OrientationHelper_Impl::EnableWindow( Window& rWindow, TriState eDisableIfStacked )
+{
+ bool bDisableOnStacked = false;
+ switch( eDisableIfStacked )
+ {
+ // STATE_CHECK: Disable window, if stacked text is turned on or "don't know".
+ case STATE_CHECK: bDisableOnStacked = (mrCbStacked.GetState() != STATE_NOCHECK); break;
+ // STATE_NOCHECK: Disable window, if stacked text is turned off or "don't know".
+ case STATE_NOCHECK: bDisableOnStacked = (mrCbStacked.GetState() != STATE_CHECK); break;
+ default: ;//prevent warning
+ }
+ rWindow.Enable( mbEnabled && !bDisableOnStacked );
+}
+
+void OrientationHelper_Impl::ShowDependentWindows()
+{
+ for( WindowVec::iterator aIt = maWinVec.begin(), aEnd = maWinVec.end(); aIt != aEnd; ++aIt )
+ aIt->first->Show( mbVisible );
+}
+
+IMPL_LINK( OrientationHelper_Impl, ClickHdl, void*, EMPTYARG )
+{
+ EnableDependentWindows();
+ return 0L;
+}
+
+// ============================================================================
+
+OrientationHelper::OrientationHelper( DialControl& rCtrlDial, CheckBox& rCbStacked ) :
+ mpImpl( new OrientationHelper_Impl( rCtrlDial, rCbStacked ) )
+{
+ mpImpl->EnableDependentWindows();
+ mpImpl->ShowDependentWindows();
+}
+
+OrientationHelper::OrientationHelper( DialControl& rCtrlDial, NumericField& rNfRotation, CheckBox& rCbStacked ) :
+ mpImpl( new OrientationHelper_Impl( rCtrlDial, rCbStacked ) )
+{
+ rCtrlDial.SetLinkedField( &rNfRotation );
+ mpImpl->EnableDependentWindows();
+ mpImpl->ShowDependentWindows();
+}
+
+OrientationHelper::~OrientationHelper()
+{
+}
+
+void OrientationHelper::AddDependentWindow( Window& rWindow, TriState eDisableIfStacked )
+{
+ mpImpl->AddDependentWindow( rWindow, eDisableIfStacked );
+}
+
+void OrientationHelper::Enable( bool bEnable )
+{
+ mpImpl->mbEnabled = bEnable;
+ mpImpl->EnableDependentWindows();
+}
+
+void OrientationHelper::Show( bool bShow )
+{
+ mpImpl->mbVisible = bShow;
+ mpImpl->ShowDependentWindows();
+}
+
+void OrientationHelper::SetStackedState( TriState eState )
+{
+ if( eState != GetStackedState() )
+ {
+ mpImpl->mrCbStacked.SetState( eState );
+ mpImpl->EnableDependentWindows();
+ }
+}
+
+TriState OrientationHelper::GetStackedState() const
+{
+ return mpImpl->mrCbStacked.GetState();
+}
+
+void OrientationHelper::EnableStackedTriState( bool bEnable )
+{
+ mpImpl->mrCbStacked.EnableTriState( bEnable );
+}
+
+// ============================================================================
+
+OrientStackedWrapper::OrientStackedWrapper( OrientationHelper& rOrientHlp ) :
+ SingleControlWrapperType( rOrientHlp )
+{
+}
+
+bool OrientStackedWrapper::IsControlDontKnow() const
+{
+ return GetControl().GetStackedState() == STATE_DONTKNOW;
+}
+
+void OrientStackedWrapper::SetControlDontKnow( bool bSet )
+{
+ GetControl().EnableStackedTriState( bSet );
+ GetControl().SetStackedState( bSet ? STATE_DONTKNOW : STATE_NOCHECK );
+}
+
+bool OrientStackedWrapper::GetControlValue() const
+{
+ return GetControl().GetStackedState() == STATE_CHECK;
+}
+
+void OrientStackedWrapper::SetControlValue( bool bValue )
+{
+ GetControl().SetStackedState( bValue ? STATE_CHECK : STATE_NOCHECK );
+}
+
+// ============================================================================
+
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/pagectrl.cxx b/svx/source/dialog/pagectrl.cxx
new file mode 100644
index 000000000000..74bb6be227de
--- /dev/null
+++ b/svx/source/dialog/pagectrl.cxx
@@ -0,0 +1,424 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+
+#include <vcl/bitmap.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <svx/pageitem.hxx>
+#include <svx/pagectrl.hxx>
+#include <editeng/boxitem.hxx>
+
+#include <algorithm>
+
+// struct PageWindow_Impl ------------------------------------------------
+
+struct PageWindow_Impl
+{
+ SvxBoxItem* pBorder;
+ Bitmap aBitmap;
+ bool bBitmap;
+ sal_Bool bResetBackground;
+ sal_Bool bFrameDirection;
+ sal_Int32 nFrameDirection;
+
+
+ PageWindow_Impl() :
+ pBorder(0),
+ bBitmap(FALSE),
+ bResetBackground(sal_False),
+ bFrameDirection(sal_False),
+ nFrameDirection(0) {}
+
+ void EnableFrameDirection(sal_Bool bEnable){bFrameDirection = bEnable;}
+ void SetFrameDirection(sal_Int32 nDirection){nFrameDirection = nDirection;}
+
+};
+
+// STATIC DATA -----------------------------------------------------------
+
+#define CELL_WIDTH 1600L
+#define CELL_HEIGHT 800L
+
+// class SvxPageWindow ---------------------------------------------------
+
+SvxPageWindow::SvxPageWindow( Window* pParent, const ResId& rId ) :
+
+ Window( pParent, rId ),
+
+ nTop ( 0 ),
+ nBottom ( 0 ),
+ nLeft ( 0 ),
+ nRight ( 0 ),
+ aColor ( COL_TRANSPARENT ),
+ nHdLeft ( 0 ),
+ nHdRight ( 0 ),
+ nHdDist ( 0 ),
+ nHdHeight ( 0 ),
+ aHdColor ( COL_TRANSPARENT ),
+ pHdBorder ( 0 ),
+ nFtLeft ( 0 ),
+ nFtRight ( 0 ),
+ nFtDist ( 0 ),
+ nFtHeight ( 0 ),
+ aFtColor ( COL_TRANSPARENT ),
+ pFtBorder ( 0 ),
+ bFooter ( FALSE ),
+ bHeader ( FALSE ),
+ bTable ( FALSE ),
+ bHorz ( FALSE ),
+ bVert ( FALSE ),
+ eUsage ( SVX_PAGE_ALL )
+
+{
+ pImpl = new PageWindow_Impl;
+
+ // defaultmaessing in Twips rechnen
+ SetMapMode( MapMode( MAP_TWIP ) );
+ aWinSize = GetOutputSizePixel();
+ aWinSize.Height() -= 4;
+ aWinSize.Width() -= 4;
+
+ aWinSize = PixelToLogic( aWinSize );
+ SetBackground();
+}
+
+// -----------------------------------------------------------------------
+
+SvxPageWindow::~SvxPageWindow()
+{
+ delete pImpl;
+ delete pHdBorder;
+ delete pFtBorder;
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT SvxPageWindow::Paint( const Rectangle& )
+{
+ Fraction aXScale( aWinSize.Width(), std::max( (long) (aSize.Width() * 2 + aSize.Width() / 8), 1L ) );
+ Fraction aYScale( aWinSize.Height(), std::max( aSize.Height(), 1L ) );
+ MapMode aMapMode( GetMapMode() );
+
+ if ( aYScale < aXScale )
+ {
+ aMapMode.SetScaleX( aYScale );
+ aMapMode.SetScaleY( aYScale );
+ }
+ else
+ {
+ aMapMode.SetScaleX( aXScale );
+ aMapMode.SetScaleY( aXScale );
+ }
+ SetMapMode( aMapMode );
+ Size aSz( PixelToLogic( GetSizePixel() ) );
+ long nYPos = ( aSz.Height() - aSize.Height() ) / 2;
+
+ if ( eUsage == SVX_PAGE_ALL )
+ {
+ // alle Seiten gleich -> eine Seite malen
+ if ( aSize.Width() > aSize.Height() )
+ {
+ // Querformat in gleicher Gr"osse zeichnen
+ Fraction aX = aMapMode.GetScaleX();
+ Fraction aY = aMapMode.GetScaleY();
+ Fraction a2( 1.5 );
+ aX *= a2;
+ aY *= a2;
+ aMapMode.SetScaleX( aX );
+ aMapMode.SetScaleY( aY );
+ SetMapMode( aMapMode );
+ aSz = PixelToLogic( GetSizePixel() );
+ nYPos = ( aSz.Height() - aSize.Height() ) / 2;
+ long nXPos = ( aSz.Width() - aSize.Width() ) / 2;
+ DrawPage( Point( nXPos, nYPos ), TRUE, TRUE );
+ }
+ else
+ // Hochformat
+ DrawPage( Point( ( aSz.Width() - aSize.Width() ) / 2, nYPos ), TRUE, TRUE );
+ }
+ else
+ {
+ // Linke und rechte Seite unterschiedlich -> ggf. zwei Seiten malen
+ DrawPage( Point( 0, nYPos ), FALSE, (BOOL)( eUsage & SVX_PAGE_LEFT ) );
+ DrawPage( Point( aSize.Width() + aSize.Width() / 8, nYPos ), TRUE,
+ (BOOL)( eUsage & SVX_PAGE_RIGHT ) );
+ }
+}
+
+// -----------------------------------------------------------------------
+void SvxPageWindow::DrawPage( const Point& rOrg, const BOOL bSecond, const BOOL bEnabled )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ const Color& rFieldColor = rStyleSettings.GetFieldColor();
+ const Color& rFieldTextColor = rStyleSettings.GetFieldTextColor();
+ const Color& rDisableColor = rStyleSettings.GetDisableColor();
+ const Color& rDlgColor = rStyleSettings.GetDialogColor();
+
+ // background
+ if(!bSecond || pImpl->bResetBackground)
+ {
+ SetLineColor( Color(COL_TRANSPARENT) );
+ SetFillColor( rDlgColor );
+ Size winSize(GetOutputSize());
+ DrawRect( Rectangle( Point(0,0), winSize ) );
+
+ if ( pImpl->bResetBackground )
+ pImpl->bResetBackground = sal_False;
+ }
+ SetLineColor( rFieldTextColor );
+ // Schatten
+ Size aTempSize = aSize;
+ // Seite
+ if ( !bEnabled )
+ {
+ SetFillColor( rDisableColor );
+ DrawRect( Rectangle( rOrg, aTempSize ) );
+ return;
+ }
+ SetFillColor( rFieldColor );
+ DrawRect( Rectangle( rOrg, aTempSize ) );
+
+ // Border Top Bottom Left Right
+ Point aBegin( rOrg );
+ Point aEnd( rOrg );
+
+ long nL = nLeft;
+ long nR = nRight;
+
+ if ( eUsage == SVX_PAGE_MIRROR && !bSecond )
+ {
+ // f"ur gespiegelt drehen
+ nL = nRight;
+ nR = nLeft;
+ }
+
+ Rectangle aRect;
+
+ aRect.Left() = rOrg.X() + nL;
+ aRect.Right() = rOrg.X() + aTempSize.Width() - nR;
+ aRect.Top() = rOrg.Y() + nTop;
+ aRect.Bottom()= rOrg.Y() + aTempSize.Height() - nBottom;
+
+ Rectangle aHdRect( aRect );
+ Rectangle aFtRect( aRect );
+
+ if ( bHeader )
+ {
+ // ggf. Header anzeigen
+ aHdRect.Left() += nHdLeft;
+ aHdRect.Right() -= nHdRight;
+ aHdRect.Bottom() = aRect.Top() + nHdHeight;
+ aRect.Top() += nHdHeight + nHdDist;
+ SetFillColor( aHdColor );
+ DrawRect( aHdRect );
+ }
+
+ if ( bFooter )
+ {
+ // ggf. Footer anzeigen
+ aFtRect.Left() += nFtLeft;
+ aFtRect.Right() -= nFtRight;
+ aFtRect.Top() = aRect.Bottom() - nFtHeight;
+ aRect.Bottom() -= nFtHeight + nFtDist;
+ SetFillColor( aFtColor );
+ DrawRect( aFtRect );
+ }
+
+ // Body malen
+ SetFillColor( aColor );
+ if ( pImpl->bBitmap )
+ {
+ DrawRect( aRect );
+ Point aBmpPnt = aRect.TopLeft();
+ Size aBmpSiz = aRect.GetSize();
+ long nDeltaX = aBmpSiz.Width() / 15;
+ long nDeltaY = aBmpSiz.Height() / 15;
+ aBmpPnt.X() += nDeltaX;
+ aBmpPnt.Y() += nDeltaY;
+ aBmpSiz.Width() -= nDeltaX * 2;
+ aBmpSiz.Height() -= nDeltaY * 2;
+ DrawBitmap( aBmpPnt, aBmpSiz, pImpl->aBitmap );
+ }
+ else
+ DrawRect( aRect );
+
+ if(pImpl->bFrameDirection && !bTable)
+ {
+ //pImpl->nFrameDirection
+ Point aPos;
+ Font aFont(GetFont());
+ const Size aSaveSize = aFont.GetSize();
+ Size aDrawSize( 0, aRect.GetHeight() / 6);
+ aFont.SetSize(aDrawSize);
+ SetFont(aFont);
+ String sText(String::CreateFromAscii("ABC"));
+ Point aMove(1, GetTextHeight());
+ sal_Unicode cArrow = 0x2193;
+ long nAWidth = GetTextWidth(String(sText.GetChar(0)));
+ switch(pImpl->nFrameDirection)
+ {
+ case FRMDIR_HORI_LEFT_TOP:
+ aPos = aRect.TopLeft();
+ aPos.X() += PixelToLogic(Point(1,1)).X();
+ aMove.Y() = 0;
+ cArrow = 0x2192;
+ break;
+ case FRMDIR_HORI_RIGHT_TOP:
+ aPos = aRect.TopRight();
+ aPos.X() -= nAWidth;
+ aMove.Y() = 0;
+ aMove.X() *= -1;
+ cArrow = 0x2190;
+ break;
+ case FRMDIR_VERT_TOP_LEFT:
+ aPos = aRect.TopLeft();
+ aPos.X() += PixelToLogic(Point(1,1)).X();
+ aMove.X() = 0;
+ break;
+ case FRMDIR_VERT_TOP_RIGHT:
+ aPos = aRect.TopRight();
+ aPos.X() -= nAWidth;
+ aMove.X() = 0;
+ break;
+ }
+ sText.Append(cArrow);
+ for(USHORT i = 0; i < sText.Len(); i++)
+ {
+ String sDraw(sText.GetChar(i));
+ long nHDiff = 0;
+ long nCharWidth = GetTextWidth(sDraw);
+ BOOL bHorizontal = 0 == aMove.Y();
+ if(!bHorizontal)
+ {
+ nHDiff = (nAWidth - nCharWidth)/2;
+ aPos.X() += nHDiff;
+ }
+ DrawText(aPos, sDraw);
+ if(bHorizontal)
+ {
+ aPos.X() += aMove.X() < 0 ? - nCharWidth : nCharWidth;
+ }
+ else
+ {
+ aPos.X() -= nHDiff;
+ aPos.Y() += aMove.Y();
+ }
+ }
+ aFont.SetSize(aSaveSize);
+ SetFont(aFont);
+
+ }
+ if ( bTable )
+ {
+ // Tabelle malen, ggf. zentrieren
+ SetLineColor( Color(COL_LIGHTGRAY) );
+
+ long nW = aRect.GetWidth(), nH = aRect.GetHeight();
+ long nTW = CELL_WIDTH * 3, nTH = CELL_HEIGHT * 3;
+ long _nLeft = bHorz ? aRect.Left() + ((nW - nTW) / 2) : aRect.Left();
+ long _nTop = bVert ? aRect.Top() + ((nH - nTH) / 2) : aRect.Top();
+ Rectangle aCellRect( Point( _nLeft, _nTop ), Size( CELL_WIDTH, CELL_HEIGHT ) );
+
+ for ( USHORT i = 0; i < 3; ++i )
+ {
+ aCellRect.Left() = _nLeft;
+ aCellRect.Right() = _nLeft + CELL_WIDTH;
+ if ( i > 0 )
+ aCellRect.Move( 0, CELL_HEIGHT );
+
+ for ( USHORT j = 0; j < 3; ++j )
+ {
+ if ( j > 0 )
+ aCellRect.Move( CELL_WIDTH, 0 );
+ DrawRect( aCellRect );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxPageWindow::SetBorder( const SvxBoxItem& rNew )
+{
+ delete pImpl->pBorder;
+ pImpl->pBorder = new SvxBoxItem( rNew );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxPageWindow::SetBitmap( Bitmap* pBmp )
+{
+ if ( pBmp )
+ {
+ pImpl->aBitmap = *pBmp;
+ pImpl->bBitmap = TRUE;
+ }
+ else
+ pImpl->bBitmap = FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxPageWindow::SetHdBorder( const SvxBoxItem& rNew )
+{
+ delete pHdBorder;
+ pHdBorder = new SvxBoxItem( rNew );
+}
+// -----------------------------------------------------------------------
+
+void SvxPageWindow::SetFtBorder( const SvxBoxItem& rNew )
+{
+ delete pFtBorder;
+ pFtBorder = new SvxBoxItem( rNew );
+}
+/* -----------------------------13.06.2002 16:16------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxPageWindow::EnableFrameDirection(sal_Bool bEnable)
+{
+ pImpl->EnableFrameDirection(bEnable);
+}
+/* -----------------------------13.06.2002 16:16------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxPageWindow::SetFrameDirection(sal_Int32 nFrameDirection)
+{
+ pImpl->SetFrameDirection(nFrameDirection);
+}
+
+void SvxPageWindow::ResetBackground()
+{
+ pImpl->bResetBackground = sal_True;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/paraprev.cxx b/svx/source/dialog/paraprev.cxx
new file mode 100644
index 000000000000..9d24138834f5
--- /dev/null
+++ b/svx/source/dialog/paraprev.cxx
@@ -0,0 +1,240 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <svx/paraprev.hxx>
+
+// STATIC DATA -----------------------------------------------------------
+
+#define FOUR_POINTS 80
+
+// class SvxParaPrevWindow -----------------------------------------------
+
+SvxParaPrevWindow::SvxParaPrevWindow( Window* pParent, const ResId& rId ) :
+
+ Window( pParent, rId ),
+
+ nLeftMargin ( 0 ),
+ nRightMargin ( 0 ),
+ nFirstLineOfst ( 0 ),
+ nUpper ( 0 ),
+ nLower ( 0 ),
+ eAdjust ( SVX_ADJUST_LEFT ),
+ eLastLine ( SVX_ADJUST_LEFT ),
+ eLine ( SVX_PREV_LINESPACE_1 ),
+ nLineVal ( 0 )
+
+{
+ // defaultmaessing in Twips rechnen
+ SetMapMode( MapMode( MAP_TWIP ) );
+ aWinSize = GetOutputSizePixel();
+ aWinSize = PixelToLogic( aWinSize );
+ Size aTmp(1, 1);
+ aTmp = PixelToLogic(aTmp);
+ aWinSize.Width() -= aTmp.Width() /2;
+ aWinSize.Height() -= aTmp.Height() /2;
+
+ aSize = Size( 11905, 16837 );
+
+ SetBorderStyle( WINDOW_BORDER_MONO );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxParaPrevWindow::Paint( const Rectangle& )
+{
+ DrawParagraph( TRUE );
+}
+
+// -----------------------------------------------------------------------
+
+#define DEF_MARGIN 120
+
+void SvxParaPrevWindow::DrawParagraph( BOOL bAll )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ const Color& rWinColor = rStyleSettings.GetWindowColor();
+ Color aGrayColor(COL_LIGHTGRAY);
+
+ SetFillColor( Color( rWinColor ) );
+ if( bAll )
+ DrawRect( Rectangle( Point(), aWinSize ) );
+
+ SetLineColor();
+
+ long nH = aWinSize.Height() / 19;
+ Size aLineSiz( aWinSize.Width() - DEF_MARGIN, nH ),
+ aSiz = aLineSiz;
+ Point aPnt;
+ aPnt.X() = DEF_MARGIN / 2;
+ SetFillColor( aGrayColor );
+
+ for ( USHORT i = 0; i < 9; ++i )
+ {
+ if ( 3 == i )
+ {
+ SetFillColor( Color( COL_GRAY ) );
+ long nTop = nUpper * aLineSiz.Height() / aSize.Height();
+ aPnt.Y() += nTop * 2;
+ }
+
+ if ( 6 == i )
+ SetFillColor( aGrayColor );
+
+ if ( 3 <= i && 6 > i )
+ {
+ long nLeft = nLeftMargin * aLineSiz.Width() / aSize.Width();
+ long nFirst = nFirstLineOfst * aLineSiz.Width() / aSize.Width();
+ long nTmp = nLeft + nFirst;
+
+ if ( 3 == i )
+ {
+ aPnt.X() += nTmp;
+ aSiz.Width() -= nTmp;
+ }
+ else
+ {
+ aPnt.X() += nLeft;
+ aSiz.Width() -= nLeft;
+ }
+ long nRight = nRightMargin * aLineSiz.Width() / aSize.Width();
+ aSiz.Width() -= nRight;
+ }
+
+ if ( 4 == i || 5 == i || 6 == i )
+ {
+ switch ( eLine )
+ {
+ case SVX_PREV_LINESPACE_1: break;
+ case SVX_PREV_LINESPACE_15: aPnt.Y() += nH / 2; break;
+ case SVX_PREV_LINESPACE_2: aPnt.Y() += nH; break;
+
+ case SVX_PREV_LINESPACE_PROP:
+ case SVX_PREV_LINESPACE_MIN:
+ case SVX_PREV_LINESPACE_DURCH: break;
+ }
+ }
+
+ aPnt.Y() += nH;
+
+ if ( (3 <= i) && (5 >= i) )
+ {
+ long nLW;
+ switch( i )
+ {
+ default:
+ case 3: nLW = aLineSiz.Width() * 8 / 10; break;
+ case 4: nLW = aLineSiz.Width() * 9 / 10; break;
+ case 5: nLW = aLineSiz.Width() / 2; break;
+ }
+
+ if ( nLW > aSiz.Width() )
+ nLW = aSiz.Width();
+
+ switch ( eAdjust )
+ {
+ case SVX_ADJUST_LEFT:
+ break;
+ case SVX_ADJUST_RIGHT:
+ aPnt.X() += ( aSiz.Width() - nLW );
+ break;
+ case SVX_ADJUST_CENTER:
+ aPnt.X() += ( aSiz.Width() - nLW ) / 2;
+ break;
+ default: ; //prevent warning
+ }
+ if( SVX_ADJUST_BLOCK == eAdjust )
+ {
+ if( 5 == i )
+ {
+ switch( eLastLine )
+ {
+ case SVX_ADJUST_LEFT:
+ break;
+ case SVX_ADJUST_RIGHT:
+ aPnt.X() += ( aSiz.Width() - nLW );
+ break;
+ case SVX_ADJUST_CENTER:
+ aPnt.X() += ( aSiz.Width() - nLW ) / 2;
+ break;
+ case SVX_ADJUST_BLOCK:
+ nLW = aSiz.Width();
+ break;
+ default: ; //prevent warning
+ }
+ }
+ else
+ nLW = aSiz.Width();
+ }
+ aSiz.Width() = nLW;
+ }
+
+ Rectangle aRect( aPnt, aSiz );
+
+ if ( Lines[i] != aRect || bAll )
+ {
+ if ( !bAll )
+ {
+ Color aFillCol = GetFillColor();
+ SetFillColor( rWinColor );
+ DrawRect( Lines[i] );
+ SetFillColor( aFillCol );
+ }
+ DrawRect( aRect );
+ Lines[i] = aRect;
+ }
+
+ if ( 5 == i )
+ {
+ long nBottom = nLower * aLineSiz.Height() / aSize.Height();
+ aPnt.Y() += nBottom * 2;
+ }
+
+ aPnt.Y() += nH;
+ // wieder zuruecksetzen, fuer jede Linie neu berechnen
+ aPnt.X() = DEF_MARGIN / 2;
+ aSiz = aLineSiz;
+ }
+}
+
+#undef DEF_MARGIN
+
+// -----------------------------------------------------------------------
+
+void SvxParaPrevWindow::OutputSizeChanged()
+{
+ aWinSize = GetOutputSizePixel();
+ aWinSize = PixelToLogic( aWinSize );
+ Invalidate();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/passwd.cxx b/svx/source/dialog/passwd.cxx
new file mode 100644
index 000000000000..eae5fbb23142
--- /dev/null
+++ b/svx/source/dialog/passwd.cxx
@@ -0,0 +1,136 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/shl.hxx>
+#include <vcl/msgbox.hxx>
+
+#define _SVX_PASSWD_CXX
+
+#include "passwd.hxx"
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include "passwd.hrc"
+
+// class SvxPasswordDialog -----------------------------------------------
+
+IMPL_LINK( SvxPasswordDialog, ButtonHdl, OKButton *, EMPTYARG )
+{
+ BOOL bOK = TRUE;
+ short nRet = RET_OK;
+ String aEmpty;
+
+ if ( aNewPasswdED.GetText() != aRepeatPasswdED.GetText() )
+ {
+ ErrorBox( this, WB_OK, aRepeatPasswdErrStr ).Execute();
+ aNewPasswdED.SetText( aEmpty );
+ aRepeatPasswdED.SetText( aEmpty );
+ aNewPasswdED.GrabFocus();
+ bOK = FALSE;
+ }
+
+ if ( bOK && aCheckPasswordHdl.IsSet() && !aCheckPasswordHdl.Call( this ) )
+ {
+ ErrorBox( this, WB_OK, aOldPasswdErrStr ).Execute();
+ aOldPasswdED.SetText( aEmpty );
+ aOldPasswdED.GrabFocus();
+ bOK = FALSE;
+ }
+
+ if ( bOK )
+ EndDialog( nRet );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxPasswordDialog, EditModifyHdl, Edit *, EMPTYARG )
+{
+ if ( !bEmpty )
+ {
+ String aPasswd = aRepeatPasswdED.GetText();
+ aPasswd.EraseLeadingChars().EraseTrailingChars();
+
+ if ( !aPasswd.Len() && aOKBtn.IsEnabled() )
+ aOKBtn.Disable();
+ else if ( aPasswd.Len() && !aOKBtn.IsEnabled() )
+ aOKBtn.Enable();
+ }
+ else if ( !aOKBtn.IsEnabled() )
+ aOKBtn.Enable();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SvxPasswordDialog::SvxPasswordDialog( Window* pParent, BOOL bAllowEmptyPasswords, BOOL bDisableOldPassword ) :
+ SfxModalDialog( pParent, SVX_RES( RID_SVXDLG_PASSWORD ) ),
+ aOldFL ( this, SVX_RES( FL_OLD_PASSWD ) ),
+ aOldPasswdFT ( this, SVX_RES( FT_OLD_PASSWD ) ),
+ aOldPasswdED ( this, SVX_RES( ED_OLD_PASSWD ) ),
+ aNewFL ( this, SVX_RES( FL_NEW_PASSWD ) ),
+ aNewPasswdFT ( this, SVX_RES( FT_NEW_PASSWD ) ),
+ aNewPasswdED ( this, SVX_RES( ED_NEW_PASSWD ) ),
+ aRepeatPasswdFT ( this, SVX_RES( FT_REPEAT_PASSWD ) ),
+ aRepeatPasswdED ( this, SVX_RES( ED_REPEAT_PASSWD ) ),
+ aOKBtn ( this, SVX_RES( BTN_PASSWD_OK ) ),
+ aEscBtn ( this, SVX_RES( BTN_PASSWD_ESC ) ),
+ aHelpBtn ( this, SVX_RES( BTN_PASSWD_HELP ) ),
+ aOldPasswdErrStr ( SVX_RES( STR_ERR_OLD_PASSWD ) ),
+ aRepeatPasswdErrStr ( SVX_RES( STR_ERR_REPEAT_PASSWD ) ),
+ bEmpty ( bAllowEmptyPasswords )
+{
+ FreeResource();
+
+ aOKBtn.SetClickHdl( LINK( this, SvxPasswordDialog, ButtonHdl ) );
+ aRepeatPasswdED.SetModifyHdl( LINK( this, SvxPasswordDialog, EditModifyHdl ) );
+ EditModifyHdl( 0 );
+
+ if ( bDisableOldPassword )
+ {
+ aOldFL.Disable();
+ aOldPasswdFT.Disable();
+ aOldPasswdED.Disable();
+ aNewPasswdED.GrabFocus();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SvxPasswordDialog::~SvxPasswordDialog()
+{
+}
+
+// -----------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/passwd.hrc b/svx/source/dialog/passwd.hrc
new file mode 100644
index 000000000000..f840be4c9af6
--- /dev/null
+++ b/svx/source/dialog/passwd.hrc
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * 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 _SVX_PASSWD_HRC
+#define _SVX_PASSWD_HRC
+
+// defines ------------------------------------------------------------------
+
+#define FT_OLD_PASSWD 10
+#define ED_OLD_PASSWD 11
+#define FL_OLD_PASSWD 12
+
+#define FT_NEW_PASSWD 20
+#define ED_NEW_PASSWD 21
+#define FT_REPEAT_PASSWD 22
+#define ED_REPEAT_PASSWD 23
+#define FL_NEW_PASSWD 24
+
+#define BTN_PASSWD_OK 30
+#define BTN_PASSWD_ESC 31
+#define BTN_PASSWD_HELP 32
+
+#define STR_ERR_OLD_PASSWD 40
+#define STR_ERR_REPEAT_PASSWD 41
+
+
+#endif
+
diff --git a/svx/source/dialog/passwd.src b/svx/source/dialog/passwd.src
new file mode 100644
index 000000000000..587150bc852a
--- /dev/null
+++ b/svx/source/dialog/passwd.src
@@ -0,0 +1,153 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include <svx/dialogs.hrc>
+#include "helpid.hrc"
+#include "passwd.hrc"
+ // pragma ----------------------------------------------------------------
+
+ // RID_SVXDLG_PASSWORD ---------------------------------------------------
+ModalDialog RID_SVXDLG_PASSWORD
+{
+ HelpId = HID_PASSWORD ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 210 , 77 ) ;
+ Moveable = TRUE ;
+ FixedText FT_OLD_PASSWD
+ {
+ Pos = MAP_APPFONT ( 12 , 16 ) ;
+ Size = MAP_APPFONT ( 57 , 8 ) ;
+ Text [ en-US ] = "~Password" ;
+ };
+ Edit ED_OLD_PASSWD
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 71 , 14 ) ;
+ Size = MAP_APPFONT ( 71 , 12 ) ;
+ PassWord = TRUE ;
+ };
+ FixedLine FL_OLD_PASSWD
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 142 , 8 ) ;
+ Text [ en-US ] = "Old password" ;
+ };
+ FixedText FT_NEW_PASSWD
+ {
+ Pos = MAP_APPFONT ( 12 , 45 ) ;
+ Size = MAP_APPFONT ( 57 , 8 ) ;
+ Text [ en-US ] = "Pa~ssword" ;
+ };
+ Edit ED_NEW_PASSWD
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 71 , 43 ) ;
+ Size = MAP_APPFONT ( 71 , 12 ) ;
+ PassWord = TRUE ;
+ };
+ FixedText FT_REPEAT_PASSWD
+ {
+ Pos = MAP_APPFONT ( 12 , 61 ) ;
+ Size = MAP_APPFONT ( 57 , 8 ) ;
+ Text [ en-US ] = "Confi~rm";
+ };
+ Edit ED_REPEAT_PASSWD
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 71 , 59 ) ;
+ Size = MAP_APPFONT ( 71 , 12 ) ;
+ PassWord = TRUE ;
+ };
+ FixedLine FL_NEW_PASSWD
+ {
+ Pos = MAP_APPFONT ( 6 , 32 ) ;
+ Size = MAP_APPFONT ( 142 , 8 ) ;
+ Text [ en-US ] = "New password" ;
+ };
+ OKButton BTN_PASSWD_OK
+ {
+ Pos = MAP_APPFONT ( 154 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ Disable = TRUE ;
+ };
+ CancelButton BTN_PASSWD_ESC
+ {
+ Pos = MAP_APPFONT ( 154 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_PASSWD_HELP
+ {
+ Pos = MAP_APPFONT ( 154 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String STR_ERR_OLD_PASSWD
+ {
+ Text [ en-US ] = "Invalid password" ;
+ };
+ String STR_ERR_REPEAT_PASSWD
+ {
+ Text [ en-US ] = "Passwords do not match" ;
+ };
+ Text [ en-US ] = "Change Password" ;
+};
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/pfiledlg.cxx b/svx/source/dialog/pfiledlg.cxx
new file mode 100644
index 000000000000..768d110eaa03
--- /dev/null
+++ b/svx/source/dialog/pfiledlg.cxx
@@ -0,0 +1,288 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <sfx2/docfile.hxx>
+#include <com/sun/star/plugin/PluginDescription.hpp>
+#include <com/sun/star/plugin/XPluginManager.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+#include "pfiledlg.hxx"
+#include <svx/dialogs.hrc>
+
+#include <svx/dialmgr.hxx>
+#include <list>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+sal_Char __READONLY_DATA sAudio[] = "audio";
+sal_Char __READONLY_DATA sVideo[] = "video";
+
+/*************************************************************************
+|*
+|* Filedialog to insert Plugin-Fileformats
+|*
+\************************************************************************/
+
+ErrCode SvxPluginFileDlg::Execute()
+{
+ return maFileDlg.Execute();
+}
+
+String SvxPluginFileDlg::GetPath() const
+{
+ return maFileDlg.GetPath();
+}
+
+SvxPluginFileDlg::SvxPluginFileDlg (Window *, sal_uInt16 nKind ) :
+ maFileDlg(SFXWB_INSERT)
+{
+ // set title of the dialogwindow
+ switch (nKind)
+ {
+ case SID_INSERT_SOUND :
+ {
+ maFileDlg.SetTitle(SVX_RESSTR(STR_INSERT_SOUND_TITLE));
+ }
+ break;
+ case SID_INSERT_VIDEO :
+ {
+ maFileDlg.SetTitle(SVX_RESSTR(STR_INSERT_VIDEO_TITLE));
+ }
+ break;
+ }
+
+ // fill the filterlist of the filedialog with data of installed plugins
+ uno::Reference< lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+
+ if( xMgr.is() )
+ {
+ uno::Reference< plugin::XPluginManager > rPluginManager( xMgr->createInstance(
+ OUString::createFromAscii( "com.sun.star.plugin.PluginManager" ) ), uno::UNO_QUERY );
+ if ( rPluginManager.is() )
+ {
+ const uno::Sequence<plugin::PluginDescription > aSeq( rPluginManager->getPluginDescriptions() );
+ const plugin::PluginDescription* pDescription = aSeq.getConstArray();
+ sal_Int32 nAnzahlPlugins = rPluginManager->getPluginDescriptions().getLength();
+
+ std::list< String > aPlugNames;
+ std::list< String > aPlugExtensions;
+ std::list< String >::iterator j;
+ std::list< String >::iterator k;
+ std::list< String >::const_iterator end;
+
+ for ( int i = 0; i < nAnzahlPlugins; i++ )
+ {
+ String aStrPlugMIMEType( pDescription[i].Mimetype );
+ String aStrPlugName( pDescription[i].Description );
+ String aStrPlugExtension( pDescription[i].Extension );
+
+ aStrPlugMIMEType.ToLowerAscii();
+ aStrPlugExtension.ToLowerAscii();
+
+ if ( ( nKind == SID_INSERT_SOUND && aStrPlugMIMEType.SearchAscii ( sAudio ) == 0 ) ||
+ ( nKind == SID_INSERT_VIDEO && aStrPlugMIMEType.SearchAscii ( sVideo ) == 0 ) )
+ {
+ // extension already in the filterlist of the filedlg ?
+ sal_Bool bAlreadyExist = sal_False;
+ for ( j = aPlugExtensions.begin(), end = aPlugExtensions.end(); j != end && !bAlreadyExist; ++j )
+ {
+ bAlreadyExist = (j->Search( aStrPlugExtension ) != STRING_NOTFOUND );
+ }
+
+ if ( !bAlreadyExist )
+ {
+ // filterdescription already there?
+ // (then append the new extension to the existing filter)
+ int nfound = -1;
+ for ( j = aPlugNames.begin(),
+ k = aPlugExtensions.begin(),
+ end = aPlugNames.end();
+ j != end && nfound != 0; )
+ {
+ if ( ( nfound = j->Search( aStrPlugName ) ) == 0 )
+ {
+ if ( aStrPlugExtension.Len() > 0 )
+ aStrPlugExtension.Insert( sal_Unicode( ';' ) );
+ aStrPlugExtension.Insert( *k );
+
+ // remove old entry, increment (iterators are invalid thereafter, thus the postincrement)
+ aPlugNames.erase(j++); aPlugExtensions.erase(k++);
+
+ // update end iterator (which may be invalid, too!)
+ end = aPlugNames.end();
+ }
+ else
+ {
+ // next element
+ ++j; ++k;
+ }
+ }
+
+ // build filterdescription
+ aStrPlugName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) );
+ aStrPlugName.Append( aStrPlugExtension );
+ aStrPlugName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) );
+
+ // use a own description for the video-formate avi, mov and mpeg
+ // the descriptions of these MIME-types are not very meaningful
+ const sal_Char sAVI[] = "*.avi";
+ const sal_Char sMOV[] = "*.mov";
+ const sal_Char sMPG[] = "*.mpg";
+ const sal_Char sMPE[] = "*.mpe";
+ const sal_Char sMPEG[] = "*.mpeg";
+
+ if ( aStrPlugExtension.EqualsIgnoreCaseAscii( sAVI ) )
+ aStrPlugName = SVX_RESSTR( STR_INSERT_VIDEO_EXTFILTER_AVI );
+ else if ( aStrPlugExtension.EqualsIgnoreCaseAscii( sMOV ) )
+ aStrPlugName = SVX_RESSTR( STR_INSERT_VIDEO_EXTFILTER_MOV );
+ else if ( aStrPlugExtension.SearchAscii( sMPG ) != STRING_NOTFOUND ||
+ aStrPlugExtension.SearchAscii( sMPE ) != STRING_NOTFOUND ||
+ aStrPlugExtension.SearchAscii( sMPEG ) != STRING_NOTFOUND )
+ aStrPlugName = SVX_RESSTR(STR_INSERT_VIDEO_EXTFILTER_MPEG);
+
+ aPlugNames.push_back( aStrPlugName );
+ aPlugExtensions.push_back( aStrPlugExtension );
+ }
+ }
+ }
+
+ // add filter to dialog
+ for ( j = aPlugNames.begin(),
+ k = aPlugExtensions.begin(),
+ end = aPlugNames.end();
+ j != end; ++j, ++k )
+ {
+ maFileDlg.AddFilter( *j, *k );
+ }
+ }
+ }
+
+ // add the All-Filter
+ String aAllFilter( ResId( STR_EXTFILTER_ALL, DIALOG_MGR() ) );
+ maFileDlg.AddFilter( aAllFilter, UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "*.*" ) ) );
+
+ // and activate him
+ maFileDlg.SetCurrentFilter( aAllFilter );
+}
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+\************************************************************************/
+
+SvxPluginFileDlg::~SvxPluginFileDlg()
+{
+}
+
+/*************************************************************************
+|*
+|* Plugins available for the the MIME-Typ in nKind
+|* (whith nKind = SID_INSERT_SOUND for MIME-Type audio
+|* SID_INSERT_VIDEO for MIME-Type video
+|*
+\************************************************************************/
+
+#define PFDLG_CHECKED_SOUND 0x0001
+#define PFDLG_CHECKED_VIDEO 0x0002
+#define PFDLG_FOUND_SOUND 0x0004
+#define PFDLG_FOUND_VIDEO 0x0008
+
+bool SvxPluginFileDlg::IsAvailable (sal_uInt16 nKind)
+{
+ static sal_uInt16 nCheck = 0;
+
+ if ( nKind == SID_INSERT_SOUND && ( nCheck & PFDLG_CHECKED_SOUND ) )
+ return (nCheck & PFDLG_FOUND_SOUND) != 0;
+ if ( nKind == SID_INSERT_VIDEO && ( nCheck & PFDLG_CHECKED_VIDEO ) )
+ return (nCheck & PFDLG_FOUND_VIDEO) != 0;
+
+ bool bFound = false;
+ uno::Reference< lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+
+ if( xMgr.is() )
+ {
+ uno::Reference< plugin::XPluginManager > rPluginManager = uno::Reference< plugin::XPluginManager > ( xMgr->createInstance( OUString::createFromAscii( "com.sun.star.plugin.PluginManager" ) ), uno::UNO_QUERY );
+ if( rPluginManager.is() )
+ {
+ const uno::Sequence<plugin::PluginDescription > aSeq( rPluginManager->getPluginDescriptions() );
+ const plugin::PluginDescription* pDescription = aSeq.getConstArray();
+ sal_Int32 nAnzahlPlugins = rPluginManager->getPluginDescriptions().getLength();
+
+ for ( sal_uInt16 i = 0; i < nAnzahlPlugins && !bFound; ++i )
+ {
+ String aStrPlugMIMEType( pDescription[i].Mimetype );
+ switch (nKind)
+ {
+ case SID_INSERT_SOUND :
+ {
+ nCheck |= PFDLG_CHECKED_SOUND;
+
+ if( aStrPlugMIMEType.SearchAscii( sAudio ) == 0 )
+ {
+ bFound = true;
+ nCheck |= PFDLG_FOUND_SOUND;
+ }
+ }
+ break;
+ case SID_INSERT_VIDEO :
+ {
+ nCheck |= PFDLG_CHECKED_VIDEO;
+
+ if (aStrPlugMIMEType.SearchAscii( sVideo ) == 0)
+ {
+ bFound = true;
+ nCheck |= PFDLG_FOUND_VIDEO;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ return bFound;
+}
+
+void SvxPluginFileDlg::SetDialogHelpId( const sal_Int32 _nHelpId )
+{
+ maFileDlg.SetDialogHelpId( _nHelpId );
+}
+
+void SvxPluginFileDlg::SetContext( sfx2::FileDialogHelper::Context _eNewContext )
+{
+ maFileDlg.SetContext( _eNewContext );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/prtqry.cxx b/svx/source/dialog/prtqry.cxx
new file mode 100644
index 000000000000..a2336cb40fd1
--- /dev/null
+++ b/svx/source/dialog/prtqry.cxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/dialogs.hrc>
+#include <prtqry.hxx>
+#include <svx/dialmgr.hxx>
+#include <tools/shl.hxx>
+
+/* -----------------------------01.02.00 13:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SvxPrtQryBox::SvxPrtQryBox(Window* pParent) :
+ MessBox(pParent, 0,
+ String(SVX_RES(RID_SVXSTR_QRY_PRINT_TITLE)),
+ String(SVX_RES(RID_SVXSTR_QRY_PRINT_MSG)))
+{
+ SetImage( QueryBox::GetStandardImage() );
+
+ AddButton(String(SVX_RES(RID_SVXSTR_QRY_PRINT_SELECTION)), RET_OK,
+ BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_OKBUTTON | BUTTONDIALOG_FOCUSBUTTON);
+
+ AddButton(String(SVX_RES(RID_SVXSTR_QRY_PRINT_ALL)), 2, 0);
+ AddButton(BUTTON_CANCEL, RET_CANCEL, BUTTONDIALOG_CANCELBUTTON);
+ SetButtonHelpText( RET_OK, String() );
+}
+/* -----------------------------01.02.00 13:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SvxPrtQryBox::~SvxPrtQryBox()
+{
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/prtqry.src b/svx/source/dialog/prtqry.src
new file mode 100644
index 000000000000..3f8c04cea918
--- /dev/null
+++ b/svx/source/dialog/prtqry.src
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+
+
+String RID_SVXSTR_QRY_PRINT_TITLE
+{
+ Text [ en-US ] = "Printing selection";
+};
+String RID_SVXSTR_QRY_PRINT_MSG
+{
+ Text [ en-US ] = "Do you want to print the selection or the entire document?";
+};
+String RID_SVXSTR_QRY_PRINT_ALL
+{
+ Text [ en-US ] = "~All";
+};
+String RID_SVXSTR_QRY_PRINT_SELECTION
+{
+ Text [ en-US ] = "~Selection";
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/relfld.cxx b/svx/source/dialog/relfld.cxx
new file mode 100644
index 000000000000..9c2c15306b87
--- /dev/null
+++ b/svx/source/dialog/relfld.cxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <tools/ref.hxx>
+#include "relfld.hxx"
+
+// -----------------------------------------------------------------------
+
+SvxRelativeField::SvxRelativeField( Window* pParent, WinBits nWinSize ) :
+ MetricField( pParent, nWinSize )
+{
+ bNegativeEnabled = FALSE;
+ bRelativeMode = FALSE;
+ bRelative = FALSE;
+
+ SetDecimalDigits( 2 );
+ SetMin( 0 );
+ SetMax( 9999 );
+}
+
+// -----------------------------------------------------------------------
+
+SvxRelativeField::SvxRelativeField( Window* pParent, const ResId& rResId ) :
+ MetricField( pParent, rResId )
+{
+ bNegativeEnabled = FALSE;
+ bRelativeMode = FALSE;
+ bRelative = FALSE;
+
+ SetDecimalDigits( 2 );
+ SetMin( 0 );
+ SetMax( 9999 );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxRelativeField::Modify()
+{
+ MetricField::Modify();
+
+ if ( bRelativeMode )
+ {
+ String aStr = GetText();
+ BOOL bNewMode = bRelative;
+
+ if ( bRelative )
+ {
+ const sal_Unicode* pStr = aStr.GetBuffer();
+
+ while ( *pStr )
+ {
+ if( ( ( *pStr < sal_Unicode( '0' ) ) || ( *pStr > sal_Unicode( '9' ) ) ) &&
+ ( *pStr != sal_Unicode( '%' ) ) )
+ {
+ bNewMode = FALSE;
+ break;
+ }
+ pStr++;
+ }
+ }
+ else
+ {
+ xub_StrLen nPos = aStr.Search( sal_Unicode( '%' ) );
+
+ if ( nPos != STRING_NOTFOUND )
+ bNewMode = TRUE;
+ }
+
+ if ( bNewMode != bRelative )
+ SetRelative( bNewMode );
+
+ MetricField::Modify();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxRelativeField::EnableRelativeMode( USHORT nMin,
+ USHORT nMax, USHORT nStep )
+{
+ bRelativeMode = TRUE;
+ nRelMin = nMin;
+ nRelMax = nMax;
+ nRelStep = nStep;
+ SetUnit( FUNIT_CM );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxRelativeField::SetRelative( BOOL bNewRelative )
+{
+ Selection aSelection = GetSelection();
+ String aStr = GetText();
+
+ if ( bNewRelative )
+ {
+ bRelative = TRUE;
+ SetDecimalDigits( 0 );
+ SetMin( nRelMin );
+ SetMax( nRelMax );
+ SetCustomUnitText( String( sal_Unicode( '%' ) ) );
+ SetUnit( FUNIT_CUSTOM );
+ }
+ else
+ {
+ bRelative = FALSE;
+ SetDecimalDigits( 2 );
+ SetMin( bNegativeEnabled ? -9999 : 0 );
+ SetMax( 9999 );
+ SetUnit( FUNIT_CM );
+ }
+
+ SetText( aStr );
+ SetSelection( aSelection );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/rlrcitem.cxx b/svx/source/dialog/rlrcitem.cxx
new file mode 100644
index 000000000000..c988f8c4f786
--- /dev/null
+++ b/svx/source/dialog/rlrcitem.cxx
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+#include <svl/rectitem.hxx>
+
+
+
+
+
+
+#include <svx/dialogs.hrc>
+
+#include <svx/ruler.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/tstpitem.hxx>
+#include "editeng/protitem.hxx"
+#include "rlrcitem.hxx"
+#include "rulritem.hxx"
+#include <svl/eitem.hxx>
+
+// class SvxRulerItem ----------------------------------------------------
+
+SvxRulerItem::SvxRulerItem(USHORT _nId, SvxRuler &rRul, SfxBindings &rBindings)
+: SfxControllerItem(_nId, rBindings),
+ rRuler(rRul)
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxRulerItem::StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState)
+{
+ // SFX_ITEM_DONTCARE => pState == -1 => PTR_CAST buff
+ if ( eState != SFX_ITEM_AVAILABLE )
+ pState = 0;
+
+ switch(nSID)
+ {
+ // Linker / rechter Seitenrand
+ case SID_RULER_LR_MIN_MAX:
+ {
+ const SfxRectangleItem *pItem = PTR_CAST(SfxRectangleItem, pState);
+ rRuler.UpdateFrameMinMax(pItem);
+ break;
+ }
+ case SID_ATTR_LONG_LRSPACE:
+ {
+ const SvxLongLRSpaceItem *pItem = PTR_CAST(SvxLongLRSpaceItem, pState);
+ DBG_ASSERT(pState? 0 != pItem: TRUE, "SvxLRSpaceItem erwartet");
+ rRuler.UpdateFrame(pItem);
+ break;
+ }
+ case SID_ATTR_LONG_ULSPACE:
+ {
+ const SvxLongULSpaceItem *pItem = PTR_CAST(SvxLongULSpaceItem, pState);
+ DBG_ASSERT(pState? 0 != pItem: TRUE, "SvxULSpaceItem erwartet");
+ rRuler.UpdateFrame(pItem);
+ break;
+ }
+ case SID_ATTR_TABSTOP_VERTICAL:
+ case SID_ATTR_TABSTOP:
+ {
+ const SvxTabStopItem *pItem = PTR_CAST(SvxTabStopItem, pState);
+ DBG_ASSERT(pState? 0 != pItem: TRUE, "SvxTabStopItem erwartet");
+ rRuler.Update(pItem);
+ break;
+ }
+ case SID_ATTR_PARA_LRSPACE_VERTICAL:
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ const SvxLRSpaceItem *pItem = PTR_CAST(SvxLRSpaceItem, pState);
+ DBG_ASSERT(pState? 0 != pItem: TRUE, "SvxLRSpaceItem erwartet");
+ rRuler.UpdatePara(pItem);
+ break;
+ }
+ case SID_RULER_BORDERS_VERTICAL:
+ case SID_RULER_BORDERS:
+ case SID_RULER_ROWS:
+ case SID_RULER_ROWS_VERTICAL:
+ {
+ const SvxColumnItem *pItem = PTR_CAST(SvxColumnItem, pState);
+ DBG_ASSERT(pState? 0 != pItem: TRUE, "SvxColumnItem erwartet");
+#ifdef DBG_UTIL
+ if(pItem)
+ {
+ if(pItem->IsConsistent())
+ rRuler.Update(pItem, nSID);
+ else
+ DBG_ERROR("Spaltenitem corrupted");
+ }
+ else
+ rRuler.Update(pItem, nSID);
+#else
+ rRuler.Update(pItem, nSID);
+#endif
+ break;
+ }
+ case SID_RULER_PAGE_POS:
+ { // Position Seite, Seitenbreite
+ const SvxPagePosSizeItem *pItem = PTR_CAST(SvxPagePosSizeItem, pState);
+ DBG_ASSERT(pState? 0 != pItem: TRUE, "SvxPagePosSizeItem erwartet");
+ rRuler.Update(pItem);
+ break;
+ }
+ case SID_RULER_OBJECT:
+ { // Object-Selektion
+ const SvxObjectItem *pItem = PTR_CAST(SvxObjectItem, pState);
+ DBG_ASSERT(pState? 0 != pItem: TRUE, "SvxObjectItem erwartet");
+ rRuler.Update(pItem);
+ break;
+ }
+ case SID_RULER_PROTECT:
+ {
+ const SvxProtectItem *pItem = PTR_CAST(SvxProtectItem, pState);
+ DBG_ASSERT(pState? 0 != pItem: TRUE, "SvxProtectItem erwartet");
+ rRuler.Update(pItem);
+ break;
+ }
+ case SID_RULER_BORDER_DISTANCE:
+ {
+ const SvxLRSpaceItem *pItem = PTR_CAST(SvxLRSpaceItem, pState);
+ DBG_ASSERT(pState? 0 != pItem: TRUE, "SvxLRSpaceItem erwartet");
+ rRuler.UpdateParaBorder(pItem);
+ }
+ break;
+ case SID_RULER_TEXT_RIGHT_TO_LEFT :
+ {
+ const SfxBoolItem *pItem = PTR_CAST(SfxBoolItem, pState);
+ DBG_ASSERT(pState? 0 != pItem: TRUE, "SfxBoolItem erwartet");
+ rRuler.UpdateTextRTL(pItem);
+ }
+ break;
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/rlrcitem.hxx b/svx/source/dialog/rlrcitem.hxx
new file mode 100644
index 000000000000..7c643c4f733d
--- /dev/null
+++ b/svx/source/dialog/rlrcitem.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_RLRCITEM_HXX
+#define _SVX_RLRCITEM_HXX
+
+#include <sfx2/ctrlitem.hxx>
+
+class SvxRuler;
+
+// class SvxRulerItem ----------------------------------------------------
+
+class SvxRulerItem : public SfxControllerItem
+{
+private:
+ SvxRuler& rRuler;
+
+protected:
+ virtual void StateChanged( USHORT,
+ SfxItemState, const SfxPoolItem* pState );
+
+public:
+ SvxRulerItem( USHORT nId, SvxRuler&, SfxBindings& );
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/rubydialog.cxx b/svx/source/dialog/rubydialog.cxx
new file mode 100644
index 000000000000..d2f251b636d7
--- /dev/null
+++ b/svx/source/dialog/rubydialog.cxx
@@ -0,0 +1,990 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <rubydialog.hxx>
+#include <tools/shl.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include <rubydialog.hrc>
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/eitem.hxx>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/text/XRubySelection.hpp>
+#include <com/sun/star/beans/PropertyValues.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/text/RubyAdjust.hpp>
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <svtools/colorcfg.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::text;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::style;
+using namespace com::sun::star::text;
+using namespace com::sun::star::view;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
+using rtl::OUString;
+
+#define C2U(cChar) rtl::OUString::createFromAscii(cChar)
+
+SFX_IMPL_CHILDWINDOW( SvxRubyChildWindow, SID_RUBY_DIALOG );
+
+static const sal_Char cRubyBaseText[] = "RubyBaseText";
+static const sal_Char cRubyText[] = "RubyText";
+static const sal_Char cCharacterStyles[] = "CharacterStyles";
+static const sal_Char cRubyAdjust[] = "RubyAdjust";
+static const sal_Char cRubyIsAbove[] = "RubyIsAbove";
+static const sal_Char cDisplayName[] = "DisplayName";
+static const sal_Char cRubyCharStyleName[] = "RubyCharStyleName";
+static const sal_Char cRubies[] = "Rubies";
+/* -----------------------------09.01.01 17:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SvxRubyChildWindow::SvxRubyChildWindow( Window* _pParent, USHORT nId,
+ SfxBindings* pBindings, SfxChildWinInfo* pInfo) :
+ SfxChildWindow(_pParent, nId)
+{
+ pWindow = new SvxRubyDialog( pBindings, this, _pParent, SVX_RES( RID_SVXDLG_RUBY ) );
+ SvxRubyDialog* pDlg = (SvxRubyDialog*) pWindow;
+
+ if ( pInfo->nFlags & SFX_CHILDWIN_ZOOMIN )
+ pDlg->RollUp();
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+
+ pDlg->Initialize( pInfo );
+}
+/* -----------------------------10.01.01 13:53--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SfxChildWinInfo SvxRubyChildWindow::GetInfo() const
+{
+ return SfxChildWindow::GetInfo();
+}
+/* -----------------------------09.01.01 17:17--------------------------------
+
+ ---------------------------------------------------------------------------*/
+class SvxRubyData_Impl : public cppu::WeakImplHelper1
+ < ::com::sun::star::view::XSelectionChangeListener >
+{
+ Reference<XModel> xModel;
+ Reference<XRubySelection> xSelection;
+ Sequence<PropertyValues> aRubyValues;
+ Reference<XController> xController;
+ sal_Bool bHasSelectionChanged;
+ public:
+ SvxRubyData_Impl();
+ ~SvxRubyData_Impl();
+
+ void SetController(Reference<XController> xCtrl);
+ Reference<XModel> GetModel()
+ {
+ if(!xController.is())
+ xModel = 0;
+ else
+ xModel = xController->getModel();
+ return xModel;
+ }
+ sal_Bool HasSelectionChanged() const{return bHasSelectionChanged;}
+ Reference<XRubySelection> GetRubySelection()
+ {
+ xSelection = Reference<XRubySelection>(xController, UNO_QUERY);
+ return xSelection;
+ }
+ void UpdateRubyValues(sal_Bool bAutoUpdate)
+ {
+ if(!xSelection.is())
+ aRubyValues.realloc(0);
+ else
+ aRubyValues = xSelection->getRubyList(bAutoUpdate);
+ bHasSelectionChanged = sal_False;
+ }
+ Sequence<PropertyValues>& GetRubyValues() {return aRubyValues;}
+ void AssertOneEntry();
+
+ virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent ) throw (RuntimeException);
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (RuntimeException);
+
+};
+//-----------------------------------------------------------------------------
+SvxRubyData_Impl::SvxRubyData_Impl() :
+ bHasSelectionChanged(sal_False)
+{
+}
+//-----------------------------------------------------------------------------
+SvxRubyData_Impl::~SvxRubyData_Impl()
+{
+}
+//-----------------------------------------------------------------------------
+void SvxRubyData_Impl::SetController(Reference<XController> xCtrl)
+{
+ if(xCtrl.get() != xController.get())
+ {
+ try
+ {
+ Reference<XSelectionSupplier> xSelSupp(xController, UNO_QUERY);
+ if(xSelSupp.is())
+ xSelSupp->removeSelectionChangeListener(this);
+
+ bHasSelectionChanged = sal_True;
+ xController = xCtrl;
+ xSelSupp = Reference<XSelectionSupplier>(xController, UNO_QUERY);
+ if(xSelSupp.is())
+ xSelSupp->addSelectionChangeListener(this);
+ }
+ catch(Exception&)
+ {}
+ }
+}
+//-----------------------------------------------------------------------------
+void SvxRubyData_Impl::selectionChanged( const EventObject& ) throw (RuntimeException)
+{
+ bHasSelectionChanged = sal_True;
+}
+//-----------------------------------------------------------------------------
+void SvxRubyData_Impl::disposing( const EventObject&) throw (RuntimeException)
+{
+ try
+ {
+ Reference<XSelectionSupplier> xSelSupp(xController, UNO_QUERY);
+ if(xSelSupp.is())
+ xSelSupp->removeSelectionChangeListener(this);
+ }
+ catch(Exception&)
+ {}
+ xController = 0;
+}
+//-----------------------------------------------------------------------------
+void SvxRubyData_Impl::AssertOneEntry()
+{
+ //create one entry
+ if(!aRubyValues.getLength())
+ {
+ aRubyValues.realloc(1);
+ Sequence<PropertyValue>& rValues = aRubyValues.getArray()[0];
+ rValues.realloc(5);
+ PropertyValue* pValues = rValues.getArray();
+ pValues[0].Name = C2U(cRubyBaseText);
+ pValues[1].Name = C2U(cRubyText);
+ pValues[2].Name = C2U(cRubyAdjust);
+ pValues[3].Name = C2U(cRubyIsAbove);
+ pValues[4].Name = C2U(cRubyCharStyleName);
+ }
+}
+/* ---------------------------------------------------------------------------
+
+ ---------------------------------------------------------------------------*/
+SvxRubyDialog::SvxRubyDialog( SfxBindings *pBind, SfxChildWindow *pCW,
+ Window* _pParent, const ResId& rResId ) :
+ SfxModelessDialog( pBind, pCW, _pParent, rResId ),
+ aLeftFT(this, ResId(FT_LEFT,*rResId.GetResMgr() )),
+ aLeft1ED(this, ResId(ED_LEFT_1,*rResId.GetResMgr() )),
+ aRightFT(this, ResId(FT_RIGHT,*rResId.GetResMgr() )),
+ aRight1ED(this, ResId(ED_RIGHT_1,*rResId.GetResMgr() )),
+ aLeft2ED(this, ResId(ED_LEFT_2,*rResId.GetResMgr() )),
+ aRight2ED(this, ResId(ED_RIGHT_2,*rResId.GetResMgr() )),
+ aLeft3ED(this, ResId(ED_LEFT_3,*rResId.GetResMgr() )),
+ aRight3ED(this, ResId(ED_RIGHT_3,*rResId.GetResMgr() )),
+ aLeft4ED(this, ResId(ED_LEFT_4,*rResId.GetResMgr() )),
+ aRight4ED(this, ResId(ED_RIGHT_4,*rResId.GetResMgr() )),
+ aScrollSB(this, ResId(SB_SCROLL,*rResId.GetResMgr() )),
+ aAutoDetectionCB(this, ResId(CB_AUTO_DETECT,*rResId.GetResMgr() )),
+ aAdjustFT(this, ResId(FT_ADJUST,*rResId.GetResMgr() )),
+ aAdjustLB(this, ResId(LB_ADJUST,*rResId.GetResMgr() )),
+ aPositionFT(this, ResId(FT_POSITION,*rResId.GetResMgr() )),
+ aPositionLB(this, ResId(LB_POSITION,*rResId.GetResMgr() )),
+ aCharStyleFT(this, ResId(FT_CHAR_STYLE,*rResId.GetResMgr() )),
+ aCharStyleLB(this, ResId(LB_CHAR_STYLE,*rResId.GetResMgr() )),
+ aStylistPB(this, ResId(PB_STYLIST,*rResId.GetResMgr() )),
+ aPreviewFT(this, ResId(FT_PREVIEW,*rResId.GetResMgr() )),
+ aPreviewWin(*this, ResId(WIN_PREVIEW,*rResId.GetResMgr() )),
+ aApplyPB(this, ResId(PB_APPLY,*rResId.GetResMgr() )),
+ aClosePB(this, ResId(PB_CLOSE,*rResId.GetResMgr() )),
+ aHelpPB(this, ResId(PB_HELP,*rResId.GetResMgr() )),
+ nLastPos(0),
+ nCurrentEdit(0),
+ bModified(FALSE),
+ pBindings(pBind)
+{
+ xImpl = pImpl = new SvxRubyData_Impl;
+ FreeResource();
+ //#85638# automatic detection not yet available
+ aAutoDetectionCB.Hide();
+ aEditArr[0] = &aLeft1ED; aEditArr[1] = &aRight1ED;
+ aEditArr[2] = &aLeft2ED; aEditArr[3] = &aRight2ED;
+ aEditArr[4] = &aLeft3ED; aEditArr[5] = &aRight3ED;
+ aEditArr[6] = &aLeft4ED; aEditArr[7] = &aRight4ED;
+
+ aApplyPB.SetClickHdl(LINK(this, SvxRubyDialog, ApplyHdl_Impl));
+ aClosePB.SetClickHdl(LINK(this, SvxRubyDialog, CloseHdl_Impl));
+ aStylistPB.SetClickHdl(LINK(this, SvxRubyDialog, StylistHdl_Impl));
+ aAutoDetectionCB.SetClickHdl(LINK(this, SvxRubyDialog, AutomaticHdl_Impl));
+ aAdjustLB.SetSelectHdl(LINK(this, SvxRubyDialog, AdjustHdl_Impl));
+ aPositionLB.SetSelectHdl(LINK(this, SvxRubyDialog, PositionHdl_Impl));
+ aCharStyleLB.SetSelectHdl(LINK(this, SvxRubyDialog, CharStyleHdl_Impl));
+
+ Link aScrLk(LINK(this, SvxRubyDialog, ScrollHdl_Impl));
+ aScrollSB.SetScrollHdl( aScrLk );
+ aScrollSB.SetEndScrollHdl( aScrLk );
+
+ Link aEditLk(LINK(this, SvxRubyDialog, EditModifyHdl_Impl));
+ Link aScrollLk(LINK(this, SvxRubyDialog, EditScrollHdl_Impl));
+ Link aJumpLk(LINK(this, SvxRubyDialog, EditJumpHdl_Impl));
+ for(USHORT i = 0; i < 8; i++)
+ {
+ aEditArr[i]->SetModifyHdl(aEditLk);
+ aEditArr[i]->SetJumpHdl(aJumpLk);
+ if(!i || 7 == i)
+ aEditArr[i]->SetScrollHdl(aScrollLk);
+ }
+
+ UpdateColors();
+}
+/* -----------------------------09.01.01 17:17--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SvxRubyDialog::~SvxRubyDialog()
+{
+ ClearCharStyleList();
+ EventObject aEvent;
+ xImpl->disposing(aEvent);
+}
+/* -----------------------------01.02.01 10:29--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxRubyDialog::ClearCharStyleList()
+{
+ for(USHORT i = 0; i < aCharStyleLB.GetEntryCount(); i++)
+ {
+ void* pData = aCharStyleLB.GetEntryData(i);
+ delete (OUString*)pData;
+ }
+ aCharStyleLB.Clear();
+}
+/* -----------------------------09.01.01 17:17--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BOOL SvxRubyDialog::Close()
+{
+ pBindings->GetDispatcher()->Execute( SID_RUBY_DIALOG,
+ SFX_CALLMODE_ASYNCHRON |
+ SFX_CALLMODE_RECORD);
+ return TRUE;
+}
+/* -----------------------------29.01.01 15:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxRubyDialog::Activate()
+{
+ SfxModelessDialog::Activate();
+ SfxPoolItem* pState = 0;
+ SfxItemState eState = pBindings->QueryState( SID_STYLE_DESIGNER, pState );
+ sal_Bool bEnable = (eState < SFX_ITEM_AVAILABLE) || !pState || !((SfxBoolItem*)pState)->GetValue();
+ aStylistPB.Enable(bEnable);
+ //get selection from current view frame
+ SfxViewFrame* pCurFrm = SfxViewFrame::Current();
+ Reference< XController > xCtrl = pCurFrm->GetFrame().GetController();
+ pImpl->SetController(xCtrl);
+ if(pImpl->HasSelectionChanged())
+ {
+
+ Reference< XRubySelection > xRubySel = pImpl->GetRubySelection();
+ pImpl->UpdateRubyValues(aAutoDetectionCB.IsChecked());
+ EnableControls(xRubySel.is());
+ if(xRubySel.is())
+ {
+ Reference< XModel > xModel = pImpl->GetModel();
+ const String sCharStyleSelect = aCharStyleLB.GetSelectEntry();
+ ClearCharStyleList();
+ Reference<XStyleFamiliesSupplier> xSupplier(xModel, UNO_QUERY);
+ if(xSupplier.is())
+ {
+ try
+ {
+ Reference<XNameAccess> xFam = xSupplier->getStyleFamilies();
+ Any aChar = xFam->getByName(C2U(cCharacterStyles));
+ Reference<XNameContainer> xChar;
+ aChar >>= xChar;
+ Reference<XIndexAccess> xCharIdx(xChar, UNO_QUERY);
+ if(xCharIdx.is())
+ {
+ OUString sUIName(C2U(cDisplayName));
+ for(sal_Int32 nStyle = 0; nStyle < xCharIdx->getCount(); nStyle++)
+ {
+ Any aStyle = xCharIdx->getByIndex(nStyle);
+ Reference<XStyle> xStyle;
+ aStyle >>= xStyle;
+ Reference<XPropertySet> xPrSet(xStyle, UNO_QUERY);
+ OUString sName, sCoreName;
+ if(xPrSet.is())
+ {
+ Reference<XPropertySetInfo> xInfo = xPrSet->getPropertySetInfo();
+ if(xInfo->hasPropertyByName(sUIName))
+ {
+ Any aName = xPrSet->getPropertyValue(sUIName);
+ aName >>= sName;
+ }
+ }
+ Reference<XNamed> xNamed(xStyle, UNO_QUERY);
+ if(xNamed.is())
+ {
+ sCoreName = xNamed->getName();
+ if(!sName.getLength())
+ sName = sCoreName;
+ }
+ if(sName.getLength())
+ {
+ USHORT nPos = aCharStyleLB.InsertEntry(sName);
+ aCharStyleLB.SetEntryData( nPos, new OUString(sCoreName) );
+
+ }
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("exception in style access");
+ }
+ if(sCharStyleSelect.Len())
+ aCharStyleLB.SelectEntry(sCharStyleSelect);
+ }
+ aCharStyleLB.Enable(xSupplier.is());
+ aCharStyleFT.Enable(xSupplier.is());
+ }
+ Update();
+ aPreviewWin.Invalidate();
+ }
+}
+/* -----------------------------29.01.01 15:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxRubyDialog::Deactivate()
+{
+ SfxModelessDialog::Deactivate();
+}
+/* -----------------------------30.01.01 15:35--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxRubyDialog::SetText(sal_Int32 nPos, Edit& rLeft, Edit& rRight)
+{
+ OUString sLeft, sRight;
+ const Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
+ BOOL bEnable = aRubyValues.getLength() > nPos;
+ if(bEnable)
+ {
+ const Sequence<PropertyValue> aProps = aRubyValues.getConstArray()[nPos];
+ const PropertyValue* pProps = aProps.getConstArray();
+ for(sal_Int32 nProp = 0; nProp < aProps.getLength(); nProp++)
+ {
+ if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyBaseText)))
+ pProps[nProp].Value >>= sLeft;
+ else if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyText)))
+ pProps[nProp].Value >>= sRight;
+ }
+ }
+ else if(!nPos)
+ bEnable = TRUE;
+ rLeft.Enable(bEnable);
+ rRight.Enable(bEnable);
+ rLeft.SetText(sLeft);
+ rRight.SetText(sRight);
+ rLeft.SaveValue();
+ rRight.SaveValue();
+}
+//-----------------------------------------------------------------------------
+void SvxRubyDialog::GetText()
+{
+ long nTempLastPos = GetLastPos();
+ for(int i = 0; i < 8; i+=2)
+ {
+ if(aEditArr[i]->IsEnabled() &&
+ (aEditArr[i]->GetText() != aEditArr[i]->GetSavedValue() ||
+ aEditArr[i + 1]->GetText() != aEditArr[i + 1]->GetSavedValue()))
+ {
+ Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
+ DBG_ASSERT(aRubyValues.getLength() > (i / 2 + nTempLastPos), "wrong index" );
+ SetModified(TRUE);
+ Sequence<PropertyValue> &rProps = aRubyValues.getArray()[i / 2 + nTempLastPos];
+ PropertyValue* pProps = rProps.getArray();
+ for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
+ {
+ if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyBaseText)))
+ pProps[nProp].Value <<= OUString(aEditArr[i]->GetText());
+ else if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyText)))
+ pProps[nProp].Value <<= OUString(aEditArr[i + 1]->GetText());
+ }
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+void SvxRubyDialog::Update()
+{
+ const Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
+ sal_Int32 nLen = aRubyValues.getLength();
+ aScrollSB.Enable(nLen > 4);
+ aScrollSB.SetRange( Range(0, nLen > 4 ? nLen - 4 : 0));
+ aScrollSB.SetThumbPos(0);
+ SetLastPos(0);
+ SetModified(FALSE);
+
+ sal_Int16 nAdjust = -1;
+ sal_Int16 nPosition = -1;
+ OUString sCharStyleName, sTmp;
+ sal_Bool bCharStyleEqual = sal_True;
+ for(sal_Int32 nRuby = 0; nRuby < nLen; nRuby++)
+ {
+ const Sequence<PropertyValue> &rProps = aRubyValues.getConstArray()[nRuby];
+ const PropertyValue* pProps = rProps.getConstArray();
+ for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
+ {
+ if(nAdjust > -2 &&
+ pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyAdjust)))
+ {
+ sal_Int16 nTmp = sal_Int16();
+ pProps[nProp].Value >>= nTmp;
+ if(!nRuby)
+ nAdjust = nTmp;
+ else if(nAdjust != nTmp)
+ nAdjust = -2;
+ }
+ if(nPosition > -2 &&
+ pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyIsAbove)))
+ {
+ sal_Bool bTmp = *(sal_Bool*)pProps[nProp].Value.getValue();
+ if(!nRuby)
+ nPosition = bTmp ? 0 : 1;
+ else if( (!nPosition && !bTmp) || (nPosition == 1 && bTmp) )
+ nPosition = -2;
+ }
+ if(bCharStyleEqual &&
+ pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyCharStyleName)))
+ {
+ pProps[nProp].Value >>= sTmp;
+ if(!nRuby)
+ sCharStyleName = sTmp;
+ else if(sCharStyleName != sTmp)
+ bCharStyleEqual = sal_False;
+ }
+ }
+ }
+ if(!nLen)
+ {
+ //enable selection if the ruby list is empty
+ nAdjust = 0;
+ nPosition = 0;
+ }
+ if(nAdjust > -1)
+ aAdjustLB.SelectEntryPos(nAdjust);
+ else
+ aAdjustLB.SetNoSelection();
+ if(nPosition > -1)
+ aPositionLB.SelectEntryPos(nPosition ? 1 : 0);
+ if(!nLen || (bCharStyleEqual && !sCharStyleName.getLength()))
+ sCharStyleName = C2U(cRubies);
+ if(sCharStyleName.getLength())
+ {
+ for(USHORT i = 0; i < aCharStyleLB.GetEntryCount(); i++)
+ {
+ const OUString* pCoreName = (const OUString*)aCharStyleLB.GetEntryData(i);
+ if(pCoreName && sCharStyleName == *pCoreName)
+ {
+ aCharStyleLB.SelectEntryPos(i);
+ break;
+ }
+ }
+ }
+ else
+ aCharStyleLB.SetNoSelection();
+
+ ScrollHdl_Impl(&aScrollSB);
+}
+/* -----------------------------16.02.01 14:01--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxRubyDialog::GetCurrentText(String& rBase, String& rRuby)
+{
+ rBase = aEditArr[nCurrentEdit * 2]->GetText();
+ rRuby = aEditArr[nCurrentEdit * 2 + 1]->GetText();
+}
+/* -----------------------------31.01.01 14:09--------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, ScrollHdl_Impl, ScrollBar*, pScroll)
+{
+ long nPos = pScroll->GetThumbPos();
+ if(GetLastPos() != nPos)
+ {
+ GetText();
+ }
+ SetText(nPos++, aLeft1ED, aRight1ED);
+ SetText(nPos++, aLeft2ED, aRight2ED);
+ SetText(nPos++, aLeft3ED, aRight3ED);
+ SetText(nPos, aLeft4ED, aRight4ED);
+ SetLastPos(nPos - 3);
+ aPreviewWin.Invalidate();
+ return 0;
+}
+/* -----------------------------30.01.01 14:48--------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, ApplyHdl_Impl, PushButton*, EMPTYARG)
+{
+ const Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
+ if(!aRubyValues.getLength())
+ {
+ AssertOneEntry();
+ PositionHdl_Impl(&aPositionLB);
+ AdjustHdl_Impl(&aAdjustLB);
+ CharStyleHdl_Impl(&aCharStyleLB);
+ }
+ GetText();
+ //reset all edit fields - SaveValue is called
+ ScrollHdl_Impl(&aScrollSB);
+
+ Reference<XRubySelection> xSelection = pImpl->GetRubySelection();
+ if(IsModified() && xSelection.is())
+ {
+ try
+ {
+ xSelection->setRubyList(aRubyValues, aAutoDetectionCB.IsChecked());
+ }
+ catch(Exception& )
+ {
+ DBG_ERROR("Exception caught");
+ }
+ }
+ return 0;
+}
+/* -----------------------------29.01.01 09:38--------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, CloseHdl_Impl, PushButton*, EMPTYARG)
+{
+ Close();
+ return 0;
+}
+/* -----------------------------29.01.01 15:10--------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, StylistHdl_Impl, PushButton*, EMPTYARG)
+{
+ SfxPoolItem* pState = 0;
+ SfxItemState eState = pBindings->QueryState( SID_STYLE_DESIGNER, pState );
+ if(eState <= SFX_ITEM_SET || !pState || !((SfxBoolItem*)pState)->GetValue())
+ {
+ pBindings->GetDispatcher()->Execute( SID_STYLE_DESIGNER,
+ SFX_CALLMODE_ASYNCHRON |
+ SFX_CALLMODE_RECORD);
+ }
+ return 0;
+}
+/* -----------------------------30.01.01 15:32--------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, AutomaticHdl_Impl, CheckBox*, pBox)
+{
+ pImpl->UpdateRubyValues(pBox->IsChecked());
+ Update();
+ return 0;
+}
+/* -----------------------------31.01.01 16:37--------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, AdjustHdl_Impl, ListBox*, pBox)
+{
+ AssertOneEntry();
+ sal_Int16 nAdjust = pBox->GetSelectEntryPos();
+ Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
+ for(sal_Int32 nRuby = 0; nRuby < aRubyValues.getLength(); nRuby++)
+ {
+ Sequence<PropertyValue> &rProps = aRubyValues.getArray()[nRuby];
+ PropertyValue* pProps = rProps.getArray();
+ for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
+ {
+ if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyAdjust)))
+ pProps[nProp].Value <<= nAdjust;
+ }
+ SetModified(TRUE);
+ }
+ aPreviewWin.Invalidate();
+ return 0;
+}
+/* -----------------------------01.06.01 10:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, PositionHdl_Impl, ListBox*, pBox)
+{
+ AssertOneEntry();
+ sal_Bool bAbove = !pBox->GetSelectEntryPos();
+ const Type& rType = ::getBooleanCppuType();
+ Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
+ for(sal_Int32 nRuby = 0; nRuby < aRubyValues.getLength(); nRuby++)
+ {
+ Sequence<PropertyValue> &rProps = aRubyValues.getArray()[nRuby];
+ PropertyValue* pProps = rProps.getArray();
+ for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
+ {
+ if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyIsAbove)))
+ pProps[nProp].Value.setValue(&bAbove, rType);
+ }
+ SetModified(TRUE);
+ }
+ aPreviewWin.Invalidate();
+ return 0;
+}
+/* -----------------------------01.02.01 10:06--------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, CharStyleHdl_Impl, ListBox*, EMPTYARG )
+{
+ AssertOneEntry();
+ OUString sStyleName;
+ if(LISTBOX_ENTRY_NOTFOUND != aCharStyleLB.GetSelectEntryPos())
+ sStyleName = *(OUString*) aCharStyleLB.GetEntryData(aCharStyleLB.GetSelectEntryPos());
+ Sequence<PropertyValues>& aRubyValues = pImpl->GetRubyValues();
+ for(sal_Int32 nRuby = 0; nRuby < aRubyValues.getLength(); nRuby++)
+ {
+ Sequence<PropertyValue> &rProps = aRubyValues.getArray()[nRuby];
+ PropertyValue* pProps = rProps.getArray();
+ for(sal_Int32 nProp = 0; nProp < rProps.getLength(); nProp++)
+ {
+ if(pProps[nProp].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cRubyCharStyleName)))
+ {
+ pProps[nProp].Value <<= sStyleName;
+ }
+ }
+ SetModified(TRUE);
+ }
+ return 0;
+}
+/* -----------------------------16.02.01 08:35--------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, EditModifyHdl_Impl, Edit*, pEdit)
+{
+ for(USHORT i = 0; i < 8; i++)
+ {
+ if(pEdit == aEditArr[i])
+ {
+ nCurrentEdit = i / 2;
+ break;
+ }
+ }
+ aPreviewWin.Invalidate();
+ return 0;
+}
+/* -----------------------------17.07.01 09:11--------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, EditScrollHdl_Impl, sal_Int32*, pParam)
+{
+ long nRet = 0;
+ if(aScrollSB.IsEnabled())
+ {
+ //scroll forward
+ if(*pParam > 0 && (aEditArr[7]->HasFocus() || aEditArr[6]->HasFocus() ))
+ {
+ if(aScrollSB.GetRangeMax() > aScrollSB.GetThumbPos())
+ {
+ aScrollSB.SetThumbPos(aScrollSB.GetThumbPos() + 1);
+ aEditArr[6]->GrabFocus();
+ nRet = 1;
+ }
+ }
+ //scroll backward
+ else if(aScrollSB.GetThumbPos() && (aEditArr[0]->HasFocus()||aEditArr[1]->HasFocus()) )
+ {
+ aScrollSB.SetThumbPos(aScrollSB.GetThumbPos() - 1);
+ aEditArr[1]->GrabFocus();
+ nRet = 1;
+ }
+ if(nRet)
+ ScrollHdl_Impl(&aScrollSB);
+ }
+ return nRet;
+}
+/* -----------------------------20.07.2001 15:18------------------------------
+
+ ---------------------------------------------------------------------------*/
+IMPL_LINK(SvxRubyDialog, EditJumpHdl_Impl, sal_Int32*, pParam)
+{
+ USHORT nIndex = USHRT_MAX;
+ for(USHORT i = 0; i < 8; i++)
+ {
+ if(aEditArr[i]->HasFocus())
+ nIndex = i;
+ }
+ if(nIndex < 8)
+ {
+ if(*pParam > 0)
+ {
+ if(nIndex < 6)
+ aEditArr[nIndex + 2]->GrabFocus();
+ else if( EditScrollHdl_Impl(pParam))
+ aEditArr[nIndex]->GrabFocus();
+ }
+ else
+ {
+ if(nIndex > 1)
+ aEditArr[nIndex - 2]->GrabFocus();
+ else if( EditScrollHdl_Impl(pParam))
+ aEditArr[nIndex]->GrabFocus();
+ }
+ }
+ return 0;
+};
+/* -----------------------------19.06.01 11:33--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxRubyDialog::AssertOneEntry()
+{
+ pImpl->AssertOneEntry();
+}
+
+// ----------------------------------------------------------------------------
+
+void SvxRubyDialog::UpdateColors( void )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ svtools::ColorConfig aColorConfig;
+
+ Font aFnt( aPreviewWin.GetFont() );
+
+ Color aNewTextCol( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
+ Color aNewFillCol( rStyleSettings.GetWindowColor() );
+
+ if( aNewFillCol != aFnt.GetFillColor() || aNewTextCol != aFnt.GetColor() )
+ {
+ aFnt.SetFillColor( aNewFillCol );
+ aFnt.SetColor( aNewTextCol );
+ aPreviewWin.SetFont( aFnt );
+
+ aPreviewWin.Invalidate();
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+void SvxRubyDialog::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ SfxModelessDialog::DataChanged( rDCEvt );
+
+ if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ UpdateColors();
+}
+
+/* -----------------------------29.01.01 15:44--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void lcl_MoveBox(long nOffset, Edit& rLeft, Edit& rRight)
+{
+ Size aLeftSz(rLeft.GetSizePixel());
+ Point aRightPos(rRight.GetPosPixel());
+ Size aRightSz(rRight.GetSizePixel());
+ aLeftSz.Width() += nOffset;
+ aRightSz.Width() -= nOffset;
+ aRightPos.X() += nOffset;
+ rLeft.SetSizePixel(aLeftSz);
+ rRight.SetPosSizePixel(aRightPos, aRightSz);
+
+}
+/* -----------------------------16.02.01 08:09--------------------------------
+
+ ---------------------------------------------------------------------------*/
+RubyPreview::RubyPreview(SvxRubyDialog& rParent, const ResId& rResId) :
+ Window(&rParent, rResId),
+ rParentDlg(rParent)
+{
+ SetMapMode(MAP_TWIP);
+ Size aWinSize = GetOutputSize();
+
+ Font aFont = GetFont();
+ aFont.SetHeight(aWinSize.Height() / 4);
+ SetFont(aFont);
+
+ SetBorderStyle( WINDOW_BORDER_MONO );
+}
+/* -----------------------------29.01.01 14:05--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void RubyPreview::Paint( const Rectangle& /* rRect */ )
+{
+ Font aRubyFont = GetFont();
+ Font aSaveFont(aRubyFont);
+ aRubyFont.SetHeight(aRubyFont.GetHeight() * 70 / 100);
+
+ Size aWinSize = GetOutputSize();
+ Rectangle aRect(Point(0, 0), aWinSize);
+ SetLineColor();
+ SetFillColor( aSaveFont.GetFillColor() );
+ DrawRect(aRect);
+
+ String sBaseText, sRubyText;
+ rParentDlg.GetCurrentText(sBaseText, sRubyText);
+
+ long nTextHeight = GetTextHeight();
+ long nBaseWidth = GetTextWidth(sBaseText);
+ SetFont(aRubyFont);
+ long nRubyWidth = GetTextWidth(sRubyText);
+ SetFont(aSaveFont);
+
+ USHORT nAdjust = rParentDlg.aAdjustLB.GetSelectEntryPos();
+ //use center if no adjustment is available
+ if(nAdjust > 4)
+ nAdjust = 1;
+
+ //which part is stretched ?
+ sal_Bool bRubyStretch = nBaseWidth >= nRubyWidth;
+
+ long nCenter = aWinSize.Width() / 2;
+ long nLeftStart = nCenter - (bRubyStretch ? (nBaseWidth / 2) : (nRubyWidth / 2));
+ long nRightEnd = nCenter + (bRubyStretch ? (nBaseWidth / 2) : (nRubyWidth / 2));
+
+ long nYRuby = aWinSize.Height() / 4 - nTextHeight / 2;
+ long nYBase = aWinSize.Height() * 3 / 4 - nTextHeight / 2;
+
+ //use above also if no selection is set
+ BOOL bAbove = rParentDlg.aPositionLB.GetSelectEntryPos() != 1;
+ if(!bAbove)
+ {
+ long nTmp = nYRuby;
+ nYRuby = nYBase;
+ nYBase = nTmp;
+ }
+ long nYOutput, nOutTextWidth;
+ String sOutputText;
+
+
+ if(bRubyStretch)
+ {
+ DrawText( Point( nLeftStart , nYBase), sBaseText );
+ nYOutput = nYRuby;
+ sOutputText = sRubyText;
+ nOutTextWidth = nRubyWidth;
+ SetFont(aRubyFont);
+ }
+ else
+ {
+ SetFont(aRubyFont);
+ DrawText( Point( nLeftStart , nYRuby), sRubyText );
+ nYOutput = nYBase;
+ sOutputText = sBaseText;
+ nOutTextWidth = nBaseWidth;
+ SetFont(aSaveFont);
+ }
+
+ switch(nAdjust)
+ {
+ case RubyAdjust_LEFT:
+ DrawText( Point( nLeftStart , nYOutput), sOutputText );
+ break;
+ case RubyAdjust_RIGHT:
+ DrawText( Point( nRightEnd - nOutTextWidth, nYOutput), sOutputText );
+ break;
+ case RubyAdjust_INDENT_BLOCK:
+ {
+ long nCharWidth = GetTextWidth(String::CreateFromAscii("X"));
+ if(nOutTextWidth < (nRightEnd - nLeftStart - nCharWidth))
+ {
+ nCharWidth /= 2;
+ nLeftStart += nCharWidth;
+ nRightEnd -= nCharWidth;
+ }
+ }
+ // no break!
+ case RubyAdjust_BLOCK:
+ if(sOutputText.Len() > 1)
+ {
+ xub_StrLen nCount = sOutputText.Len();
+ long nSpace = ((nRightEnd - nLeftStart) - GetTextWidth(sOutputText)) / (nCount - 1);
+ for(xub_StrLen i = 0; i < nCount; i++)
+ {
+ sal_Unicode cChar = sOutputText.GetChar(i);
+ DrawText( Point( nLeftStart , nYOutput), cChar);
+ long nCharWidth = GetTextWidth(cChar);
+ nLeftStart += nCharWidth + nSpace;
+ }
+ break;
+ }
+ //no break;
+ case RubyAdjust_CENTER:
+ DrawText( Point( nCenter - nOutTextWidth / 2 , nYOutput), sOutputText );
+ break;
+ }
+ SetFont(aSaveFont);
+}
+/* -----------------------------16.02.01 15:12--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void RubyEdit::GetFocus()
+{
+ GetModifyHdl().Call(this);
+ Edit::GetFocus();
+}
+/* -----------------------------17.07.01 09:00--------------------------------
+
+ ---------------------------------------------------------------------------*/
+long RubyEdit::PreNotify( NotifyEvent& rNEvt )
+{
+ long nHandled = 0;
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ const KeyCode& rKeyCode = pKEvt->GetKeyCode();
+ USHORT nMod = rKeyCode.GetModifier();
+ USHORT nCode = rKeyCode.GetCode();
+ if( nCode == KEY_TAB && (!nMod || KEY_SHIFT == nMod))
+ {
+ sal_Int32 nParam = KEY_SHIFT == nMod ? -1 : 1;
+ if(aScrollHdl.IsSet() && aScrollHdl.Call(&nParam))
+ nHandled = 1;
+ }
+ else if(KEY_UP == nCode || KEY_DOWN == nCode)
+ {
+ sal_Int32 nParam = KEY_UP == nCode ? -1 : 1;
+ aJumpHdl.Call(&nParam);
+ }
+ }
+ if(!nHandled)
+ nHandled = Edit::PreNotify(rNEvt);
+ return nHandled;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/rubydialog.hrc b/svx/source/dialog/rubydialog.hrc
new file mode 100644
index 000000000000..76839aeb8580
--- /dev/null
+++ b/svx/source/dialog/rubydialog.hrc
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#define CB_AUTO_DETECT 1
+#define FT_CHAR_STYLE 2
+#define LB_CHAR_STYLE 3
+#define PB_STYLIST 4
+#define FT_PREVIEW 5
+#define WIN_PREVIEW 6
+#define PB_APPLY 7
+#define PB_CLOSE 8
+#define PB_HELP 9
+#define ED_LEFT_1 10
+#define ED_LEFT_2 11
+#define ED_LEFT_3 12
+#define ED_LEFT_4 13
+#define ED_RIGHT_1 14
+#define ED_RIGHT_2 15
+#define ED_RIGHT_3 16
+#define ED_RIGHT_4 17
+#define HB_HEADER 18
+#define SB_SCROLL 19
+#define FT_LEFT 20
+#define FT_RIGHT 21
+#define FT_ADJUST 22
+#define LB_ADJUST 23
+#define FT_POSITION 24
+#define LB_POSITION 25
+
diff --git a/svx/source/dialog/rubydialog.src b/svx/source/dialog/rubydialog.src
new file mode 100644
index 000000000000..b1537c1fa71c
--- /dev/null
+++ b/svx/source/dialog/rubydialog.src
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <rubydialog.hrc>
+#include "helpid.hrc"
+#include <svx/dialogs.hrc>
+
+ModelessDialog RID_SVXDLG_RUBY
+{
+ OutputSize = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ HelpId = HID_RUBY_DIALOG;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 227 , 195 ) ;
+ Text [ en-US ] = "Asian Phonetic Guide" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ CheckBox CB_AUTO_DETECT
+ {
+ Pos = MAP_APPFONT ( 6, 6 ) ;
+ Size = MAP_APPFONT ( 186 , 12 ) ;
+ Text [ en-US ] = "Automatic detection";
+ };
+ FixedText FT_LEFT
+ {
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 80 , 8 ) ;
+ Text [ en-US ] = "Base text";
+ };
+ FixedText FT_RIGHT
+ {
+ Pos = MAP_APPFONT ( 109 , 17 ) ;
+ Size = MAP_APPFONT ( 80 , 8 ) ;
+ Text [ en-US ] = "Ruby text";
+ };
+ Edit ED_LEFT_1
+ {
+ Pos = MAP_APPFONT ( 6 , 30 ) ;
+ Size = MAP_APPFONT ( 102 , 12 ) ;
+ Hide = False;
+ Border = TRUE;
+ };
+ Edit ED_RIGHT_1
+ {
+ Pos = MAP_APPFONT ( 109 , 30 ) ;
+ Size = MAP_APPFONT ( 102 , 12 ) ;
+ Border = TRUE;
+ };
+ Edit ED_LEFT_2
+ {
+ Pos = MAP_APPFONT ( 6 , 42) ;
+ Size = MAP_APPFONT ( 102 , 12 ) ;
+ Border = TRUE;
+ };
+ Edit ED_RIGHT_2
+ {
+ Pos = MAP_APPFONT ( 109 , 42 ) ;
+ Size = MAP_APPFONT ( 102 , 12 ) ;
+ Border = TRUE;
+ };
+ Edit ED_LEFT_3
+ {
+ Pos = MAP_APPFONT ( 6 , 54 ) ;
+ Size = MAP_APPFONT ( 102 , 12 ) ;
+ Border = TRUE;
+ };
+ Edit ED_RIGHT_3
+ {
+ Pos = MAP_APPFONT ( 109 , 54 ) ;
+ Size = MAP_APPFONT ( 102 , 12 ) ;
+ Border = TRUE;
+ };
+ Edit ED_LEFT_4
+ {
+ Pos = MAP_APPFONT ( 6 , 66 ) ;
+ Size = MAP_APPFONT ( 102 , 12 ) ;
+ Border = TRUE;
+ };
+ Edit ED_RIGHT_4
+ {
+ Pos = MAP_APPFONT ( 109 , 66 ) ;
+ Size = MAP_APPFONT ( 102 , 12 ) ;
+ Border = TRUE;
+ };
+ ScrollBar SB_SCROLL
+ {
+ Pos = MAP_APPFONT ( 213 , 30 ) ;
+ Size = MAP_APPFONT ( 8 , 48 ) ;
+ VScroll = TRUE ;
+ Drag = TRUE ;
+ };
+ FixedText FT_ADJUST
+ {
+ Pos = MAP_APPFONT ( 6 , 82 ) ;
+ Size = MAP_APPFONT ( 35 , 8 ) ;
+ Text [ en-US ] = "Alignment";
+ };
+ ListBox LB_ADJUST
+ {
+ Pos = MAP_APPFONT ( 6 , 93) ;
+ Size = MAP_APPFONT ( 35 , 60 ) ;
+ DropDown = TRUE;
+ Border = TRUE;
+ StringList [ en-US ] =
+ {
+ "Left" ;
+ "Center" ;
+ "Right" ;
+ "0 1 0" ;
+ "1 2 1" ;
+ };
+ };
+ FixedText FT_POSITION
+ {
+ Pos = MAP_APPFONT ( 43 , 82 ) ;
+ Size = MAP_APPFONT ( 35 , 8 ) ;
+ Text [ en-US ] = "Position";
+ };
+ ListBox LB_POSITION
+ {
+ Pos = MAP_APPFONT ( 43 , 93) ;
+ Size = MAP_APPFONT ( 35 , 60 ) ;
+ DropDown = TRUE;
+ Border = TRUE;
+ StringList [ en-US ] =
+ {
+ "Top" ;
+ "Bottom" ;
+ };
+ };
+ FixedText FT_CHAR_STYLE
+ {
+ Pos = MAP_APPFONT ( 80 , 82 ) ;
+ Size = MAP_APPFONT ( 141 , 8 ) ;
+ Text [ en-US ] = "Character Style for ruby text";
+ };
+ ListBox LB_CHAR_STYLE
+ {
+ Pos = MAP_APPFONT ( 80 , 93) ;
+ Size = MAP_APPFONT ( 89 , 60 ) ;
+ DropDown = TRUE;
+ Border = TRUE;
+ Sort = TRUE;
+ };
+ PushButton PB_STYLIST
+ {
+ Pos = MAP_APPFONT ( 171 , 92 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "Styles";
+ };
+ FixedText FT_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 6, 110 ) ;
+ Size = MAP_APPFONT ( 195 , 8 ) ;
+ Text [ en-US ] = "Preview:";
+ };
+ Window WIN_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 6 , 121 ) ;
+ Size = MAP_APPFONT ( 215 , 50 ) ;
+ Border = TRUE ;
+ };
+ OKButton PB_APPLY
+ {
+ DefButton = TRUE;
+ Pos = MAP_APPFONT ( 65 , 175 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Apply";
+ };
+ PushButton PB_CLOSE
+ {
+ Pos = MAP_APPFONT ( 118, 175 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Close";
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 171 , 175 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
diff --git a/svx/source/dialog/ruler.hrc b/svx/source/dialog/ruler.hrc
new file mode 100644
index 000000000000..101130bbb7b3
--- /dev/null
+++ b/svx/source/dialog/ruler.hrc
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+//!! Abhaegigkeit zu sv.hxx
+#define ID_MM 1
+#define ID_CM 2
+#define ID_M 3
+#define ID_KM 4
+#define ID_INCH 8
+#define ID_FOOT 9
+#define ID_MILE 10
+#define ID_POINT 6
+#define ID_PICA 7
+#define ID_CHAR 11
+#define ID_LINE 12
diff --git a/svx/source/dialog/ruler.src b/svx/source/dialog/ruler.src
new file mode 100644
index 000000000000..b30ca44b5ee7
--- /dev/null
+++ b/svx/source/dialog/ruler.src
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <svx/dialogs.hrc>
+#include "ruler.hrc"
+
+Menu RID_SVXMN_RULER
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = ID_MM ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Millimeter" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_CM ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Centimeter" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_M ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Meter" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_KM ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Kilometer" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_INCH ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Inch" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_FOOT ;
+ Checkable = TRUE ;
+ /* ### ACHTUNG: Neuer Text in Resource? Fuß : Fu˜ */
+ /* ### ACHTUNG: Neuer Text in Resource? Fuß : Fu˜ */
+ Text [ en-US ] = "Foot" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_MILE ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Miles" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_POINT ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Point" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_PICA ;
+ Checkable = TRUE ;
+ Text [ en-US ] = "Pica" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_CHAR ;
+ Checkable = TRUE ;
+ Text[ en-US ] = "Char" ;
+ };
+ MenuItem
+ {
+ Identifier = ID_LINE ;
+ Checkable = TRUE ;
+ Text[ en-US ] = "Line" ;
+ };
+ };
+};
+String RID_SVXSTR_RULER_TAB_LEFT
+{
+ Text [ en-US ] = "Left" ;
+};
+String RID_SVXSTR_RULER_TAB_RIGHT
+{
+ Text [ en-US ] = "Right" ;
+};
+String RID_SVXSTR_RULER_TAB_DECIMAL
+{
+ Text [ en-US ] = "Decimal" ;
+};
+String RID_SVXSTR_RULER_TAB_CENTER
+{
+ Text [ en-US ] = "Center" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/rulritem.cxx b/svx/source/dialog/rulritem.cxx
new file mode 100644
index 000000000000..e1dbcbbb2ee8
--- /dev/null
+++ b/svx/source/dialog/rulritem.cxx
@@ -0,0 +1,745 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/string.hxx>
+
+#include <svx/dialogs.hrc>
+#include "rulritem.hxx"
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/frame/status/LeftRightMargin.hpp>
+#include <com/sun/star/frame/status/UpperLowerMargin.hpp>
+
+//------------------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SvxPagePosSizeItem, SfxPoolItem);
+TYPEINIT1_AUTOFACTORY(SvxLongLRSpaceItem, SfxPoolItem);
+TYPEINIT1_AUTOFACTORY(SvxLongULSpaceItem, SfxPoolItem);
+TYPEINIT1(SvxColumnItem, SfxPoolItem);
+TYPEINIT1(SvxObjectItem, SfxPoolItem);
+
+//------------------------------------------------------------------------
+
+int SvxLongLRSpaceItem::operator==( const SfxPoolItem& rCmp) const
+{
+ return SfxPoolItem::operator==(rCmp) &&
+ lLeft==((const SvxLongLRSpaceItem &)rCmp).lLeft &&
+ lRight==((const SvxLongLRSpaceItem &)rCmp).lRight;
+}
+
+
+//------------------------------------------------------------------------
+
+String SvxLongLRSpaceItem::GetValueText() const
+{
+ return String();
+}
+
+#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
+#define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
+
+bool SvxLongLRSpaceItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ sal_Int32 nVal;
+ switch( nMemberId )
+ {
+ case 0:
+ {
+ ::com::sun::star::frame::status::LeftRightMargin aLeftRightMargin;
+ aLeftRightMargin.Left = bConvert ? TWIP_TO_MM100( lLeft ) : lLeft;
+ aLeftRightMargin.Right = bConvert ? TWIP_TO_MM100( lRight ) : lRight;
+ rVal <<= aLeftRightMargin;
+ return TRUE;
+ }
+
+ case MID_LEFT: nVal = lLeft; break;
+ case MID_RIGHT: nVal = lRight; break;
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ if ( bConvert )
+ nVal = TWIP_TO_MM100( nVal );
+
+ rVal <<= nVal;
+ return true;
+}
+
+// -----------------------------------------------------------------------
+bool SvxLongLRSpaceItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ sal_Int32 nVal = 0;
+ if ( nMemberId == 0 )
+ {
+ ::com::sun::star::frame::status::LeftRightMargin aLeftRightMargin;
+ if ( rVal >>= aLeftRightMargin )
+ {
+ lLeft = bConvert ? MM100_TO_TWIP( aLeftRightMargin.Left ) : aLeftRightMargin.Left;
+ lRight = bConvert ? MM100_TO_TWIP( aLeftRightMargin.Right ) : aLeftRightMargin.Right;
+ return true;
+ }
+ }
+ else if ( rVal >>= nVal )
+ {
+ if ( bConvert )
+ nVal = MM100_TO_TWIP( nVal );
+
+ switch( nMemberId )
+ {
+ case MID_LEFT: lLeft = nVal; break;
+ case MID_RIGHT: lRight = nVal; break;
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxLongLRSpaceItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ String& /*rText*/, const IntlWrapper *
+) const
+{
+
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxLongLRSpaceItem::Clone(SfxItemPool *) const
+{
+ return new SvxLongLRSpaceItem(*this);
+}
+
+//------------------------------------------------------------------------
+
+SvxLongLRSpaceItem::SvxLongLRSpaceItem(long lL, long lR, USHORT nId)
+ : SfxPoolItem(nId),
+ lLeft(lL),
+ lRight(lR)
+{}
+
+//------------------------------------------------------------------------
+
+SvxLongLRSpaceItem::SvxLongLRSpaceItem() :
+ SfxPoolItem( 0 ),
+ lLeft( 0 ),
+ lRight( 0 )
+{}
+
+//------------------------------------------------------------------------
+
+SvxLongLRSpaceItem::SvxLongLRSpaceItem(const SvxLongLRSpaceItem &rCpy)
+ : SfxPoolItem(rCpy),
+ lLeft(rCpy.lLeft),
+ lRight(rCpy.lRight)
+ {}
+
+//------------------------------------------------------------------------
+
+int SvxLongULSpaceItem::operator==( const SfxPoolItem& rCmp) const
+{
+ return SfxPoolItem::operator==(rCmp) &&
+ lLeft==((const SvxLongULSpaceItem &)rCmp).lLeft &&
+ lRight==((const SvxLongULSpaceItem &)rCmp).lRight;
+}
+
+
+//------------------------------------------------------------------------
+
+String SvxLongULSpaceItem::GetValueText() const
+{
+ return String();
+}
+
+bool SvxLongULSpaceItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ sal_Int32 nVal;
+ switch( nMemberId )
+ {
+ case 0:
+ {
+ ::com::sun::star::frame::status::UpperLowerMargin aUpperLowerMargin;
+ aUpperLowerMargin.Upper = bConvert ? TWIP_TO_MM100( lLeft ) : lLeft;
+ aUpperLowerMargin.Lower = bConvert ? TWIP_TO_MM100( lRight ) : lRight;
+ rVal <<= aUpperLowerMargin;
+ return true;
+ }
+
+ case MID_UPPER: nVal = lLeft; break;
+ case MID_LOWER: nVal = lRight; break;
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ if ( bConvert )
+ nVal = TWIP_TO_MM100( nVal );
+
+ rVal <<= nVal;
+ return true;
+}
+
+// -----------------------------------------------------------------------
+bool SvxLongULSpaceItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ sal_Int32 nVal = 0;
+ if ( nMemberId == 0 )
+ {
+ ::com::sun::star::frame::status::UpperLowerMargin aUpperLowerMargin;
+ if ( rVal >>= aUpperLowerMargin )
+ {
+ lLeft = bConvert ? MM100_TO_TWIP( aUpperLowerMargin.Upper ) : aUpperLowerMargin.Upper;
+ lRight = bConvert ? MM100_TO_TWIP( aUpperLowerMargin.Lower ) : aUpperLowerMargin.Lower;
+ return true;
+ }
+ }
+ else if ( rVal >>= nVal )
+ {
+ if ( bConvert )
+ nVal = MM100_TO_TWIP( nVal );
+
+ switch( nMemberId )
+ {
+ case MID_UPPER: lLeft = nVal; break;
+ case MID_LOWER: lRight = nVal; break;
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxLongULSpaceItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ String& /*rText*/, const IntlWrapper *
+) const
+{
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxLongULSpaceItem::Clone(SfxItemPool *) const
+{
+ return new SvxLongULSpaceItem(*this);
+}
+
+//------------------------------------------------------------------------
+
+SvxLongULSpaceItem::SvxLongULSpaceItem(long lL, long lR, USHORT nId)
+ : SfxPoolItem(nId),
+ lLeft(lL),
+ lRight(lR)
+{}
+
+//------------------------------------------------------------------------
+
+SvxLongULSpaceItem::SvxLongULSpaceItem(const SvxLongULSpaceItem &rCpy)
+ : SfxPoolItem(rCpy),
+ lLeft(rCpy.lLeft),
+ lRight(rCpy.lRight)
+ {}
+
+//------------------------------------------------------------------------
+
+SvxLongULSpaceItem::SvxLongULSpaceItem() :
+ SfxPoolItem( 0 ),
+ lLeft( 0 ),
+ lRight( 0 )
+{}
+
+//------------------------------------------------------------------------
+
+int SvxPagePosSizeItem::operator==( const SfxPoolItem& rCmp) const
+{
+ return SfxPoolItem::operator==(rCmp) &&
+ aPos == ((const SvxPagePosSizeItem &)rCmp).aPos &&
+ lWidth == ((const SvxPagePosSizeItem &)rCmp).lWidth &&
+ lHeight == ((const SvxPagePosSizeItem &)rCmp).lHeight;
+}
+
+bool SvxPagePosSizeItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+ nMemberId &= ~CONVERT_TWIPS;
+
+ sal_Int32 nVal;
+ switch ( nMemberId )
+ {
+ case 0 :
+ {
+ com::sun::star::awt::Rectangle aPagePosSize;
+ aPagePosSize.X = aPos.X();
+ aPagePosSize.Y = aPos.Y();
+ aPagePosSize.Width = lWidth;
+ aPagePosSize.Height = lHeight;
+ rVal <<= aPagePosSize;
+ return true;
+ }
+
+ case MID_X: nVal = aPos.X(); break;
+ case MID_Y: nVal = aPos.Y(); break;
+ case MID_WIDTH: nVal = lWidth; break;
+ case MID_HEIGHT: nVal = lHeight; break;
+
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ rVal <<= nVal;
+ return true;
+}
+
+bool SvxPagePosSizeItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+ nMemberId &= ~CONVERT_TWIPS;
+
+ sal_Int32 nVal = 0;
+ if ( nMemberId == 0 )
+ {
+ com::sun::star::awt::Rectangle aPagePosSize;
+ if ( rVal >>= aPagePosSize )
+ {
+ aPos.X() = aPagePosSize.X;
+ aPos.Y() = aPagePosSize.Y;
+ lWidth = aPagePosSize.Width;
+ lHeight = aPagePosSize.Height;
+ return sal_True;
+ }
+ else
+ return sal_False;
+ }
+ else if ( rVal >>= nVal )
+ {
+ switch ( nMemberId )
+ {
+ case MID_X: aPos.X() = nVal; break;
+ case MID_Y: aPos.Y() = nVal; break;
+ case MID_WIDTH: lWidth = nVal; break;
+ case MID_HEIGHT: lHeight = nVal; break;
+
+ default: DBG_ERROR("Wrong MemberId!"); return sal_False;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+//------------------------------------------------------------------------
+
+String SvxPagePosSizeItem::GetValueText() const
+{
+ return String();
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxPagePosSizeItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ String& /*rText*/, const IntlWrapper *
+) const
+{
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxPagePosSizeItem::Clone(SfxItemPool *) const
+{
+ return new SvxPagePosSizeItem(*this);
+}
+
+//------------------------------------------------------------------------
+
+SvxPagePosSizeItem::SvxPagePosSizeItem(const Point &rP, long lW, long lH)
+ : SfxPoolItem(SID_RULER_PAGE_POS),
+ aPos(rP),
+ lWidth(lW),
+ lHeight(lH)
+{}
+
+//------------------------------------------------------------------------
+
+SvxPagePosSizeItem::SvxPagePosSizeItem(const SvxPagePosSizeItem &rCpy)
+ : SfxPoolItem(rCpy),
+ aPos(rCpy.aPos),
+ lWidth(rCpy.lWidth),
+ lHeight(rCpy.lHeight)
+ {}
+
+//------------------------------------------------------------------------
+
+SvxPagePosSizeItem::SvxPagePosSizeItem()
+ : SfxPoolItem( 0 ),
+ aPos( 0, 0 ),
+ lWidth( 0 ),
+ lHeight( 0 )
+{}
+
+//------------------------------------------------------------------------
+
+void SvxColumnItem::DeleteAndDestroyColumns()
+{
+ for( USHORT i = aColumns.Count(); i>0; )
+ {
+ SvxColumnDescription *pTmp = (SvxColumnDescription *)aColumns[--i];
+ aColumns.Remove( i );
+ delete pTmp;
+ }
+}
+
+//------------------------------------------------------------------------
+
+int SvxColumnItem::operator==(const SfxPoolItem& rCmp) const
+{
+ if(!SfxPoolItem::operator==(rCmp) ||
+ nActColumn != ((const SvxColumnItem&)rCmp).nActColumn ||
+ nLeft != ((const SvxColumnItem&)rCmp).nLeft ||
+ nRight != ((const SvxColumnItem&)rCmp).nRight ||
+ bTable != ((const SvxColumnItem&)rCmp).bTable ||
+ Count() != ((const SvxColumnItem&)rCmp).Count())
+ return FALSE;
+
+ const USHORT nCount = ((const SvxColumnItem&)rCmp).Count();
+ for(USHORT i = 0; i < nCount;++i) {
+#if OSL_DEBUG_LEVEL > 1
+ SvxColumnDescription *p1, *p2;
+ p1 = (SvxColumnDescription *)aColumns[i];
+ p2 = (SvxColumnDescription *)((const SvxColumnItem&)rCmp).aColumns[i];
+#endif
+ if( (*this)[i] != ((const SvxColumnItem&)rCmp)[i] )
+ return FALSE;
+ }
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+String SvxColumnItem::GetValueText() const
+{
+ return String();
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxColumnItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ String& /*rText*/, const IntlWrapper *
+) const
+{
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxColumnItem::Clone( SfxItemPool * ) const
+{
+ return new SvxColumnItem(*this);
+}
+
+//------------------------------------------------------------------------
+
+SvxColumnItem::SvxColumnItem( USHORT nAct ) :
+
+ SfxPoolItem( SID_RULER_BORDERS ),
+
+ nLeft ( 0 ),
+ nRight ( 0 ),
+ nActColumn ( nAct ),
+ bTable ( FALSE ),
+ bOrtho (TRUE )
+
+{
+}
+
+//------------------------------------------------------------------------
+
+SvxColumnItem::SvxColumnItem( USHORT nActCol, USHORT left, USHORT right ) :
+
+ SfxPoolItem( SID_RULER_BORDERS ),
+
+ nLeft ( left ),
+ nRight ( right ),
+ nActColumn ( nActCol ),
+ bTable ( TRUE ),
+ bOrtho ( TRUE )
+{
+}
+
+//------------------------------------------------------------------------
+
+SvxColumnItem::SvxColumnItem( const SvxColumnItem& rCopy ) :
+
+ SfxPoolItem( rCopy ),
+
+ aColumns ( (BYTE)rCopy.Count() ),
+ nLeft ( rCopy.nLeft ),
+ nRight ( rCopy.nRight ),
+ nActColumn( rCopy.nActColumn ),
+ bTable ( rCopy.bTable ),
+ bOrtho ( rCopy.bOrtho )
+
+{
+ const USHORT nCount = rCopy.Count();
+
+ for ( USHORT i = 0; i < nCount; ++i )
+ Append( rCopy[i] );
+}
+
+//------------------------------------------------------------------------
+
+SvxColumnItem::~SvxColumnItem()
+{
+ DeleteAndDestroyColumns();
+}
+
+//------------------------------------------------------------------------
+
+const SvxColumnItem &SvxColumnItem::operator=(const SvxColumnItem &rCopy)
+{
+ nLeft = rCopy.nLeft;
+ nRight = rCopy.nRight;
+ bTable = rCopy.bTable;
+ nActColumn = rCopy.nActColumn;
+ DeleteAndDestroyColumns();
+ const USHORT nCount = rCopy.Count();
+ for(USHORT i = 0; i < nCount;++i)
+ Insert(rCopy[i], i);
+ return *this;
+}
+
+//------------------------------------------------------------------------
+
+BOOL SvxColumnItem::CalcOrtho() const
+{
+ const USHORT nCount = Count();
+ DBG_ASSERT(nCount >= 2, "keine Spalten");
+ if(nCount < 2)
+ return FALSE;
+
+ long nColWidth = (*this)[0].GetWidth();
+ for(USHORT i = 1; i < nCount; ++i) {
+ if( (*this)[i].GetWidth() != nColWidth)
+ return FALSE;
+ }
+ //!! Breite Trenner
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+long SvxColumnItem::GetVisibleRight() const
+{
+ USHORT nIdx = 0;
+
+ for ( USHORT i = 0; i < nActColumn; ++i )
+ {
+ if ( (*this)[i].bVisible )
+ ++nIdx;
+ }
+ return (*this)[nIdx].nEnd;
+}
+
+bool SvxColumnItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case MID_COLUMNARRAY:
+ {
+ return false;
+ }
+ case MID_RIGHT: rVal <<= nRight; break;
+ case MID_LEFT: rVal <<= nLeft; break;
+ case MID_ORTHO: rVal <<= (sal_Bool) bOrtho; break;
+ case MID_ACTUAL: rVal <<= (sal_Int32) nActColumn; break;
+ case MID_TABLE: rVal <<= (sal_Bool) bTable; break;
+ default: DBG_ERROR("Wrong MemberId!"); return sal_False;
+ }
+
+ return true;
+}
+
+bool SvxColumnItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ sal_Int32 nVal = 0;
+ switch ( nMemberId )
+ {
+ case MID_COLUMNARRAY:
+ {
+ return false;
+ }
+ case MID_RIGHT: rVal >>= nRight; break;
+ case MID_LEFT: rVal >>= nLeft; break;
+ case MID_ORTHO: rVal >>= nVal; bOrtho = (BOOL) nVal; break;
+ case MID_ACTUAL: rVal >>= nVal; nActColumn = (USHORT) nVal; break;
+ case MID_TABLE: rVal >>= nVal; bTable = (BOOL) nVal; break;
+ default: DBG_ERROR("Wrong MemberId!"); return sal_False;
+ }
+
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+int SvxObjectItem::operator==( const SfxPoolItem& rCmp ) const
+{
+ return SfxPoolItem::operator==(rCmp) &&
+ nStartX == ((const SvxObjectItem&)rCmp).nStartX &&
+ nEndX == ((const SvxObjectItem&)rCmp).nEndX &&
+ nStartY == ((const SvxObjectItem&)rCmp).nStartY &&
+ nEndY == ((const SvxObjectItem&)rCmp).nEndY &&
+ bLimits == ((const SvxObjectItem&)rCmp).bLimits;
+}
+
+//------------------------------------------------------------------------
+
+String SvxObjectItem::GetValueText() const
+{
+ return String();
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxObjectItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ String& /*rText*/, const IntlWrapper *
+) const
+{
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxObjectItem::Clone(SfxItemPool *) const
+{
+ return new SvxObjectItem(*this);
+}
+
+//------------------------------------------------------------------------
+
+SvxObjectItem::SvxObjectItem( long nSX, long nEX,
+ long nSY, long nEY, BOOL limits ) :
+
+ SfxPoolItem( SID_RULER_OBJECT ),
+
+ nStartX ( nSX ),
+ nEndX ( nEX ),
+ nStartY ( nSY ),
+ nEndY ( nEY ),
+ bLimits ( limits )
+
+{
+}
+
+//------------------------------------------------------------------------
+
+SvxObjectItem::SvxObjectItem( const SvxObjectItem& rCopy ) :
+
+ SfxPoolItem( rCopy ),
+
+ nStartX ( rCopy.nStartX ),
+ nEndX ( rCopy.nEndX ),
+ nStartY ( rCopy.nStartY ),
+ nEndY ( rCopy.nEndY ),
+ bLimits ( rCopy.bLimits )
+
+{
+}
+
+bool SvxObjectItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case MID_START_X : rVal <<= nStartX; break;
+ case MID_START_Y : rVal <<= nStartY; break;
+ case MID_END_X : rVal <<= nEndX; break;
+ case MID_END_Y : rVal <<= nEndY; break;
+ case MID_LIMIT : rVal <<= bLimits; break;
+ default:
+ DBG_ERROR( "Wrong MemberId" );
+ return sal_False;
+ }
+
+ return true;
+}
+
+bool SvxObjectItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ BOOL bRet = false;
+ switch ( nMemberId )
+ {
+ case MID_START_X : bRet = (rVal >>= nStartX); break;
+ case MID_START_Y : bRet = (rVal >>= nStartY); break;
+ case MID_END_X : bRet = (rVal >>= nEndX); break;
+ case MID_END_Y : bRet = (rVal >>= nEndY); break;
+ case MID_LIMIT : bRet = (rVal >>= bLimits); break;
+ default: DBG_ERROR( "Wrong MemberId" );
+ }
+
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/sdstring.src b/svx/source/dialog/sdstring.src
new file mode 100644
index 000000000000..4a5be0d59ac9
--- /dev/null
+++ b/svx/source/dialog/sdstring.src
@@ -0,0 +1,1291 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ------------------------------------------------------------------
+#include <svx/dialogs.hrc>
+ // pragma -------------------------------------------------------------------
+
+ // Strings fuer die Draw-Dialoge --------------------------------------------
+String RID_SVXSTR_SOLID
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Durchgängig : Durchgõngig */
+ /* ### ACHTUNG: Neuer Text in Resource? Durchgängig : Durchgõngig */
+ Text [ en-US ] = "Continuous" ;
+};
+String RID_SVXSTR_GRADIENT
+{
+ Text [ en-US ] = "Gradient" ;
+};
+String RID_SVXSTR_BITMAP
+{
+ Text [ en-US ] = "Bitmap" ;
+};
+String RID_SVXSTR_LINESTYLE
+{
+ Text [ en-US ] = "Line Style" ;
+};
+String RID_SVXSTR_INVISIBLE
+{
+ Text [ en-US ] = "Invisible" ;
+};
+String RID_SVXSTR_COLOR
+{
+ Text [ en-US ] = "Color" ;
+};
+String RID_SVXSTR_HATCH
+{
+ Text [ en-US ] = "Hatching" ;
+};
+String RID_SVXSTR_LINEEND
+{
+ Text [ en-US ] = "Arrowheads" ;
+};
+
+String RID_SVXSTR_CLOSE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Schließen : Schlie˜en */
+ /* ### ACHTUNG: Neuer Text in Resource? Schließen : Schlie˜en */
+ Text [ en-US ] = "Close" ;
+};
+String RID_SVXSTR_BLACK
+{
+ Text [ en-US ] = "Black" ;
+};
+String RID_SVXSTR_BLUE
+{
+ Text [ en-US ] = "Blue" ;
+};
+String RID_SVXSTR_GREEN
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Grün : Gr³n */
+ /* ### ACHTUNG: Neuer Text in Resource? Grün : Gr³n */
+ Text [ en-US ] = "Green" ;
+};
+String RID_SVXSTR_CYAN
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Türkis : T³rkis */
+ /* ### ACHTUNG: Neuer Text in Resource? Türkis : T³rkis */
+ Text [ en-US ] = "Turquoise" ;
+};
+String RID_SVXSTR_RED
+{
+ Text [ en-US ] = "Red" ;
+};
+String RID_SVXSTR_MAGENTA
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Magenta : Violett */
+ Text [ en-US ] = "Magenta" ;
+};
+String RID_SVXSTR_BROWN
+{
+ Text [ en-US ] = "Brown" ;
+};
+String RID_SVXSTR_GREY
+{
+ Text [ en-US ] = "Gray" ;
+};
+String RID_SVXSTR_LIGHTGREY
+{
+ Text [ en-US ] = "Light gray" ;
+};
+String RID_SVXSTR_LIGHTBLUE
+{
+ Text [ en-US ] = "Light blue" ;
+};
+String RID_SVXSTR_LIGHTGREEN
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Hellgrün : Hellgr³n */
+ /* ### ACHTUNG: Neuer Text in Resource? Hellgrün : Hellgr³n */
+ Text [ en-US ] = "Light green" ;
+};
+String RID_SVXSTR_LIGHTCYAN
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Helltürkis : Hellt³rkis */
+ /* ### ACHTUNG: Neuer Text in Resource? Helltürkis : Hellt³rkis */
+ Text [ en-US ] = "Light cyan" ;
+};
+String RID_SVXSTR_LIGHTRED
+{
+ Text [ en-US ] = "Light red" ;
+};
+String RID_SVXSTR_LIGHTMAGENTA
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Hellmagenta : Hellviolett */
+ Text [ en-US ] = "Light magenta" ;
+};
+String RID_SVXSTR_YELLOW
+{
+ Text [ en-US ] = "Yellow" ;
+};
+String RID_SVXSTR_WHITE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Weiß : Wei˜ */
+ /* ### ACHTUNG: Neuer Text in Resource? Weiß : Wei˜ */
+ Text [ en-US ] = "White" ;
+};
+String RID_SVXSTR_BLUEGREY
+{
+ Text [ en-US ] = "Blue gray" ;
+};
+String RID_SVXSTR_ORANGE
+{
+ Text [ en-US ] = "Orange" ;
+};
+String RID_SVXSTR_ARROW
+{
+ Text [ en-US ] = "Arrow" ;
+};
+String RID_SVXSTR_SQUARE
+{
+ Text [ en-US ] = "Square" ;
+};
+String RID_SVXSTR_CIRCLE
+{
+ Text [ en-US ] = "Circle" ;
+};
+String RID_SVXSTR_NONE
+{
+ Text [ en-US ] = "- none -" ;
+};
+String RID_SVXSTR_TRANSPARENCE
+{
+ Text [ en-US ] = "Transparency" ;
+};
+String RID_SVXSTR_CENTERED
+{
+ Text [ en-US ] = "Centered" ;
+};
+String RID_SVXSTR_NOTCENTERED
+{
+ Text [ en-US ] = "Not centered" ;
+};
+String RID_SVXSTR_GRAFMODE_STANDARD
+{
+ Text [ en-US ] = "Default";
+};
+String RID_SVXSTR_GRAFMODE_GREYS
+{
+ Text [ en-US ] = "Grayscale";
+};
+String RID_SVXSTR_GRAFMODE_MONO
+{
+ Text [ en-US ] = "Black/White";
+};
+String RID_SVXSTR_GRAFMODE_WATERMARK
+{
+ Text [ en-US ] = "Watermark";
+};
+String STR_INSERT_VIDEO_EXTFILTER_IVF
+{
+ Text [ en-US ] = "Intel Indeo Video (*.ivf)" ;
+};
+
+String STR_INSERT_VIDEO_EXTFILTER_AVI
+{
+ Text [ en-US ] = "Video for Windows (*.avi)" ;
+};
+
+String STR_INSERT_VIDEO_EXTFILTER_MOV
+{
+ Text [ en-US ] = "QuickTime Movie (*.mov)" ;
+};
+
+String STR_INSERT_VIDEO_EXTFILTER_MPEG
+{
+ Text [ en-US ] = "MPEG - Motion Pictures Experts Group (*.mpe;*.mpeg;*.mpg)" ;
+};
+
+String STR_EXTFILTER_ALL
+{
+ Text [ en-US ] = "<All>" ;
+};
+
+String STR_INSERT_SOUND_TITLE
+{
+ Text [ en-US ] = "Insert sound" ;
+};
+
+String STR_INSERT_VIDEO_TITLE
+{
+ Text [ en-US ] = "Insert video" ;
+};
+
+
+// BM: some additional standard colors
+
+String RID_SVXSTR_VIOLET
+{
+ Text [ en-US ] = "Violet";
+};
+
+String RID_SVXSTR_BORDEAUX
+{
+ Text [ en-US ] = "Bordeaux";
+};
+
+String RID_SVXSTR_PALE_YELLOW
+{
+ Text [ en-US ] = "Pale yellow";
+};
+
+String RID_SVXSTR_PALE_GREEN
+{
+ Text [ en-US ] = "Pale green";
+};
+
+String RID_SVXSTR_DKVIOLET
+{
+ Text [ en-US ] = "Dark violet";
+};
+
+String RID_SVXSTR_SALMON
+{
+ Text [ en-US ] = "Salmon";
+};
+
+String RID_SVXSTR_SEABLUE
+{
+ Text [ en-US ] = "Sea blue";
+};
+
+String RID_SVXSTR_COLOR_SUN
+{
+ // attention: this is the color string for the Sun Microsystems specific colors !!!
+ Text [ en-US ] = "Sun" ;
+};
+
+String RID_SVXSTR_COLOR_CHART
+{
+ Text [ en-US ] = "Chart" ;
+};
+
+String RID_SVXSTR_TBLAFMT_3D
+{
+ Text [ en-US ] = "3D";
+};
+String RID_SVXSTR_TBLAFMT_BLACK1
+{
+ Text [ en-US ] = "Black 1";
+};
+String RID_SVXSTR_TBLAFMT_BLACK2
+{
+ Text [ en-US ] = "Black 2";
+};
+String RID_SVXSTR_TBLAFMT_BLUE
+{
+ Text [ en-US ] = "Blue";
+};
+String RID_SVXSTR_TBLAFMT_BROWN
+{
+ Text [ en-US ] = "Brown";
+};
+String RID_SVXSTR_TBLAFMT_CURRENCY
+{
+ Text [ en-US ] = "Currency";
+};
+String RID_SVXSTR_TBLAFMT_CURRENCY_3D
+{
+ Text [ en-US ] = "Currency 3D";
+};
+String RID_SVXSTR_TBLAFMT_CURRENCY_GRAY
+{
+ Text [ en-US ] = "Currency Gray";
+};
+String RID_SVXSTR_TBLAFMT_CURRENCY_LAVENDER
+{
+ Text [ en-US ] = "Currency Lavender";
+};
+String RID_SVXSTR_TBLAFMT_CURRENCY_TURQUOISE
+{
+ Text [ en-US ] = "Currency Turquoise";
+};
+String RID_SVXSTR_TBLAFMT_GRAY
+{
+ Text [ en-US ] = "Gray";
+};
+String RID_SVXSTR_TBLAFMT_GREEN
+{
+ Text [ en-US ] = "Green";
+};
+String RID_SVXSTR_TBLAFMT_LAVENDER
+{
+ Text [ en-US ] = "Lavender";
+};
+String RID_SVXSTR_TBLAFMT_RED
+{
+ Text [ en-US ] = "Red";
+};
+String RID_SVXSTR_TBLAFMT_TURQUOISE
+{
+ Text [ en-US ] = "Turquoise";
+};
+String RID_SVXSTR_TBLAFMT_YELLOW
+{
+ Text [ en-US ] = "Yellow";
+};
+
+String RID_SVXSTR_LINEJOINT_MIDDLE
+{
+ Text [ en-US ] = "Line joint averaged";
+};
+String RID_SVXSTR_LINEJOINT_BEVEL
+{
+ Text [ en-US ] = "Line joint bevel";
+};
+String RID_SVXSTR_LINEJOINT_MITER
+{
+ Text [ en-US ] = "Line joint miter";
+};
+String RID_SVXSTR_LINEJOINT_ROUND
+{
+ Text [ en-US ] = "Line joint round";
+};
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Reference-strings for standardcolor-table
+//
+
+/* nicht uebersetzen */
+String RID_SVXSTR_BLACK_DEF
+{
+ Text = "Black" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BLUE_DEF
+{
+ Text = "Blue" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GREEN_DEF
+{
+ Text = "Green" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_CYAN_DEF
+{
+ Text = "Turquoise" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_RED_DEF
+{
+ Text = "Red" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_MAGENTA_DEF
+{
+ Text = "Magenta" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BROWN_DEF
+{
+ Text = "Brown" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GREY_DEF
+{
+ Text = "Gray" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LIGHTGREY_DEF
+{
+ Text = "Light gray" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LIGHTBLUE_DEF
+{
+ Text = "Light blue" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LIGHTGREEN_DEF
+{
+ Text = "Light green" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LIGHTCYAN_DEF
+{
+ Text = "Light cyan" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LIGHTRED_DEF
+{
+ Text = "Light red" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LIGHTMAGENTA_DEF
+{
+ Text = "Light magenta" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_YELLOW_DEF
+{
+ Text = "Yellow" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_WHITE_DEF
+{
+ Text = "White" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BLUEGREY_DEF
+{
+ Text = "Blue gray" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_ORANGE_DEF
+{
+ Text = "Orange" ;
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_VIOLET_DEF
+{
+ Text = "Violet";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BORDEAUX_DEF
+{
+ Text = "Bordeaux";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_PALE_YELLOW_DEF
+{
+ Text = "Pale yellow";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_PALE_GREEN_DEF
+{
+ Text = "Pale green";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DKVIOLET_DEF
+{
+ Text = "Dark violet";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_SALMON_DEF
+{
+ Text = "Salmon";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_SEABLUE_DEF
+{
+ Text = "Sea blue";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_COLOR_SUN_DEF
+{
+ // attention: this is the color string for the Sun Microsystems specific colors !!!
+ Text = "Sun";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_COLOR_CHART_DEF
+{
+ Text = "Chart";
+};
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Reference-strings for standard-gradient-table
+//
+
+/* nicht uebersetzen */
+String RID_SVXSTR_GRDT0_DEF
+{
+ Text = "Gradient";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GRDT1_DEF
+{
+ Text = "Linear blue/white";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GRDT2_DEF
+{
+ Text = "Linear magenta/green";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GRDT3_DEF
+{
+ Text = "Linear yellow/brown";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GRDT4_DEF
+{
+ Text = "Radial green/black";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GRDT5_DEF
+{
+ Text = "Radial red/yellow";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GRDT6_DEF
+{
+ Text = "Rectangular red/white";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GRDT7_DEF
+{
+ Text = "Square yellow/white";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GRDT8_DEF
+{
+ Text = "Ellipsoid blue grey/light blue";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_GRDT9_DEF
+{
+ Text = "Axial light red/white";
+};
+
+String RID_SVXSTR_GRDT0
+{
+ Text [ en-US ] = "Gradient";
+};
+String RID_SVXSTR_GRDT1
+{
+ Text [ en-US ] = "Linear blue/white";
+};
+String RID_SVXSTR_GRDT2
+{
+ Text [ en-US ] = "Linear magenta/green";
+};
+String RID_SVXSTR_GRDT3
+{
+ Text [ en-US ] = "Linear yellow/brown";
+};
+String RID_SVXSTR_GRDT4
+{
+ Text [ en-US ] = "Radial green/black";
+};
+String RID_SVXSTR_GRDT5
+{
+ Text [ en-US ] = "Radial red/yellow";
+};
+String RID_SVXSTR_GRDT6
+{
+ Text [ en-US ] = "Rectangular red/white";
+};
+String RID_SVXSTR_GRDT7
+{
+ Text [ en-US ] = "Square yellow/white";
+};
+String RID_SVXSTR_GRDT8
+{
+ Text [ en-US ] = "Ellipsoid blue gray/light blue";
+};
+String RID_SVXSTR_GRDT9
+{
+ Text [ en-US ] = "Axial light red/white";
+};
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Reference-strings for standard-hatch-table
+//
+
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH0_DEF
+{
+ Text = "Black 45 Degrees Wide";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH1_DEF
+{
+ Text = "Black 45 Degrees";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH2_DEF
+{
+ Text = "Black -45 Degrees";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH3_DEF
+{
+ Text = "Black 90 Degrees";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH4_DEF
+{
+ Text = "Red Crossed 45 Degrees";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH5_DEF
+{
+ Text = "Red Crossed 0 Degrees";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH6_DEF
+{
+ Text = "Blue Crossed 45 Degrees";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH7_DEF
+{
+ Text = "Blue Crossed 0 Degrees";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH8_DEF
+{
+ Text = "Blue Triple 90 Degrees";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH9_DEF
+{
+ Text = "Black 0 Degrees";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_HATCH10_DEF
+{
+ Text = "Hatch";
+};
+
+String RID_SVXSTR_HATCH0
+{
+ Text [ en-US ] = "Black 45 degrees wide";
+};
+String RID_SVXSTR_HATCH1
+{
+ Text [ en-US ] = "Black 45 degrees";
+};
+String RID_SVXSTR_HATCH2
+{
+ Text [ en-US ] = "Black -45 degrees";
+};
+String RID_SVXSTR_HATCH3
+{
+ Text [ en-US ] = "Black 90 degrees";
+};
+String RID_SVXSTR_HATCH4
+{
+ Text [ en-US ] = "Red crossed 45 degrees";
+};
+String RID_SVXSTR_HATCH5
+{
+ Text [ en-US ] = "Red crossed 0 degrees";
+};
+String RID_SVXSTR_HATCH6
+{
+ Text [ en-US ] = "Blue crossed 45 degrees";
+};
+String RID_SVXSTR_HATCH7
+{
+ Text [ en-US ] = "Blue crossed 0 degrees";
+};
+String RID_SVXSTR_HATCH8
+{
+ Text [ en-US ] = "Blue triple 90 degrees";
+};
+String RID_SVXSTR_HATCH9
+{
+ Text [ en-US ] = "Black 0 degrees";
+};
+String RID_SVXSTR_HATCH10
+{
+ Text [ en-US ] = "Hatching" ;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Reference-strings for standard-bitmap-table
+//
+
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP0_DEF
+{
+ Text = "Empty";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP1_DEF
+{
+ Text = "Sky";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP2_DEF
+{
+ Text = "Aqua";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP3_DEF
+{
+ Text = "Coarse";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP4_DEF
+{
+ Text = "Space Metal";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP5_DEF
+{
+ Text = "Space";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP6_DEF
+{
+ Text = "Metal";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP7_DEF
+{
+ Text = "Wet";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP8_DEF
+{
+ Text = "Marble";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP9_DEF
+{
+ Text = "Linen";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP10_DEF
+{
+ Text = "Stone";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP11_DEF
+{
+ Text = "Pebbles";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP12_DEF
+{
+ Text = "Wall";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP13_DEF
+{
+ Text = "Red Wall";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP14_DEF
+{
+ Text = "Pattern";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP15_DEF
+{
+ Text = "Leaves";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP16_DEF
+{
+ Text = "Lawn Artificial";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP17_DEF
+{
+ Text = "Daisy";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP18_DEF
+{
+ Text = "Orange";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP19_DEF
+{
+ Text = "Fiery";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP20_DEF
+{
+ Text = "Roses";
+};
+
+/* nicht uebersetzen */
+String RID_SVXSTR_BMP21_DEF
+{
+ Text = "Bitmape";
+};
+
+String RID_SVXSTR_BMP0
+{
+ Text [ en-US ] = "Blank";
+};
+String RID_SVXSTR_BMP1
+{
+ Text [ en-US ] = "Sky";
+};
+String RID_SVXSTR_BMP2
+{
+ Text [ en-US ] = "Water";
+};
+String RID_SVXSTR_BMP3
+{
+ Text [ en-US ] = "Coarse grained";
+};
+String RID_SVXSTR_BMP4
+{
+ Text [ en-US ] = "Mercury";
+};
+String RID_SVXSTR_BMP5
+{
+ Text [ en-US ] = "Space";
+};
+String RID_SVXSTR_BMP6
+{
+ Text [ en-US ] = "Metal";
+};
+String RID_SVXSTR_BMP7
+{
+ Text [ en-US ] = "Droplets";
+};
+String RID_SVXSTR_BMP8
+{
+ Text [ en-US ] = "Marble";
+};
+String RID_SVXSTR_BMP9
+{
+ Text [ en-US ] = "Linen";
+};
+String RID_SVXSTR_BMP10
+{
+ Text [ en-US ] = "Stone";
+};
+String RID_SVXSTR_BMP11
+{
+ Text [ en-US ] = "Gravel";
+};
+String RID_SVXSTR_BMP12
+{
+ Text [ en-US ] = "Wall";
+};
+String RID_SVXSTR_BMP13
+{
+ Text [ en-US ] = "Brownstone";
+};
+String RID_SVXSTR_BMP14
+{
+ Text [ en-US ] = "Netting";
+};
+String RID_SVXSTR_BMP15
+{
+ Text [ en-US ] = "Leaves";
+};
+String RID_SVXSTR_BMP16
+{
+ Text [ en-US ] = "Artificial Turf";
+};
+String RID_SVXSTR_BMP17
+{
+ Text [ en-US ] = "Daisy";
+};
+String RID_SVXSTR_BMP18
+{
+ Text [ en-US ] = "Orange";
+};
+String RID_SVXSTR_BMP19
+{
+ Text [ en-US ] = "Fiery";
+};
+String RID_SVXSTR_BMP20
+{
+ Text [ en-US ] = "Roses";
+};
+
+String RID_SVXSTR_BMP21
+{
+ Text [ en-US ] = "Bitmap";
+};
+///////////////////////////////////////////////////////////////////////////////
+//
+// Reference-strings for standard-dash-table
+//
+
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH0_DEF
+{
+ Text = "Ultrafine Dashed";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH1_DEF
+{
+ Text = "Fine Dashed";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH2_DEF
+{
+ Text = "Ultrafine 2 Dots 3 Dashes";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH3_DEF
+{
+ Text = "Fine Dotted";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH4_DEF
+{
+ Text = "Line with Fine Dots";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH5_DEF
+{
+ Text = "Fine Dashed (var)";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH6_DEF
+{
+ Text = "3 Dashes 3 Dots (var)";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH7_DEF
+{
+ Text = "Ultrafine Dotted (var)";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH8_DEF
+{
+ Text = "Line Style 9";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH9_DEF
+{
+ Text = "2 Dots 1 Dash";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH10_DEF
+{
+ Text = "Dashed (var)";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_DASH11_DEF
+{
+ Text = "Dash";
+};
+
+String RID_SVXSTR_DASH0
+{
+ Text [ en-US ] = "Ultrafine dashed";
+};
+String RID_SVXSTR_DASH1
+{
+ Text [ en-US ] = "Fine dashed";
+};
+String RID_SVXSTR_DASH2
+{
+ Text [ en-US ] = "Ultrafine 2 dots 3 dashes";
+};
+String RID_SVXSTR_DASH3
+{
+ Text [ en-US ] = "Fine dotted";
+};
+String RID_SVXSTR_DASH4
+{
+ Text [ en-US ] = "Line with fine dots";
+};
+String RID_SVXSTR_DASH5
+{
+ Text [ en-US ] = "Fine dashed (variable)";
+};
+String RID_SVXSTR_DASH6
+{
+ Text [ en-US ] = "3 dashes 3 dots (variable)";
+};
+String RID_SVXSTR_DASH7
+{
+ Text [ en-US ] = "Ultrafine dotted (variable)";
+};
+String RID_SVXSTR_DASH8
+{
+ Text [ en-US ] = "Line style 9";
+};
+String RID_SVXSTR_DASH9
+{
+ Text [ en-US ] = "2 dots 1 dash";
+};
+String RID_SVXSTR_DASH10
+{
+ Text [ en-US ] = "Dashed (variable)";
+};
+String RID_SVXSTR_DASH11
+{
+ Text [ en-US ] = "Dashed";
+};
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Reference-strings for standard-line-end-table
+//
+
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND0_DEF
+{
+ Text = "Arrow concave";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND1_DEF
+{
+ Text = "Square 45";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND2_DEF
+{
+ Text = "Small Arrow";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND3_DEF
+{
+ Text = "Dimension Lines";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND4_DEF
+{
+ Text = "Double Arrow";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND5_DEF
+{
+ Text = "Rounded short Arrow";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND6_DEF
+{
+ Text = "Symmetric Arrow";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND7_DEF
+{
+ Text = "Line Arrow";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND8_DEF
+{
+ Text = "Rounded large Arrow";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND9_DEF
+{
+ Text = "Circle";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND10_DEF
+{
+ Text = "Square";
+};
+/* nicht uebersetzen */
+String RID_SVXSTR_LEND11_DEF
+{
+ Text = "Arrow";
+};
+
+String RID_SVXSTR_LEND0
+{
+ Text [ en-US ] = "Arrow concave";
+};
+String RID_SVXSTR_LEND1
+{
+ Text [ en-US ] = "Square 45";
+};
+String RID_SVXSTR_LEND2
+{
+ Text [ en-US ] = "Small arrow";
+};
+String RID_SVXSTR_LEND3
+{
+ Text [ en-US ] = "Dimension lines";
+};
+String RID_SVXSTR_LEND4
+{
+ Text [ en-US ] = "Double Arrow";
+};
+String RID_SVXSTR_LEND5
+{
+ Text [ en-US ] = "Rounded short arrow";
+};
+String RID_SVXSTR_LEND6
+{
+ Text [ en-US ] = "Symmetric arrow";
+};
+String RID_SVXSTR_LEND7
+{
+ Text [ en-US ] = "Line arrow";
+};
+String RID_SVXSTR_LEND8
+{
+ Text [ en-US ] = "Rounded large arrow";
+};
+String RID_SVXSTR_LEND9
+{
+ Text [ en-US ] = "Circle";
+};
+String RID_SVXSTR_LEND10
+{
+ Text [ en-US ] = "Square";
+};
+String RID_SVXSTR_LEND11
+{
+ Text [ en-US ] = "Arrow";
+};
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Reference-strings for standard transparence gradients
+//
+
+/* nicht uebersetzen */
+String RID_SVXSTR_TRASNGR0_DEF
+{
+ Text = "Transparency";
+};
+
+String RID_SVXSTR_TRASNGR0
+{
+ Text [ en-US ] = "Transparency";
+};
+
+ // ********************************************************************** EOF
+
+ // RID_SVXSTR_FIELDUNIT_TABLE --------------------------------------------
+
+StringArray RID_SVXSTR_FIELDUNIT_TABLE
+{
+ ItemList [ en-US ] =
+ {
+ < "Millimeter" ; FUNIT_MM ; > ;
+ < "Centimeter" ; FUNIT_CM ; > ;
+ < "Meter" ; FUNIT_M ; > ;
+ < "Kilometer" ; FUNIT_KM ; > ;
+ < "Inch" ; FUNIT_INCH ; > ;
+ < "Foot" ; FUNIT_FOOT ; > ;
+ < "Miles" ; FUNIT_MILE ; > ;
+ < "Pica" ; FUNIT_PICA ; > ;
+ < "Point" ; FUNIT_POINT ; > ;
+ < "Char" ; FUNIT_CHAR ; > ;
+ < "Line" ; FUNIT_LINE ; > ;
+ };
+ };
+
+// unbekannte Zeichenfarbe
+String RID_SVXSTR_COLOR_USER
+{
+ Text [ en-US ] = "User" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/dialog/sendreportgen.cxx b/svx/source/dialog/sendreportgen.cxx
new file mode 100644
index 000000000000..75c8d9eb9eaf
--- /dev/null
+++ b/svx/source/dialog/sendreportgen.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "docrecovery.hxx"
+
+namespace svx{
+ namespace DocRecovery{
+
+ bool ErrorRepSendDialog::ReadParams()
+ {
+ return false;
+ }
+
+ bool ErrorRepSendDialog::SaveParams()
+ {
+ return false;
+ }
+
+ bool ErrorRepSendDialog::SendReport()
+ {
+ return false;
+ }
+
+
+ } // namespace DocRecovery
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/sendreportunx.cxx b/svx/source/dialog/sendreportunx.cxx
new file mode 100644
index 000000000000..2362cc3bea2f
--- /dev/null
+++ b/svx/source/dialog/sendreportunx.cxx
@@ -0,0 +1,275 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "docrecovery.hxx"
+#include "osl/file.hxx"
+#include "rtl/bootstrap.hxx"
+#include "rtl/strbuf.hxx"
+#include "tools/appendunixshellword.hxx"
+#include <string>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <pwd.h>
+
+#define RCFILE ".crash_reportrc"
+
+using namespace ::std;
+
+static const char *get_home_dir()
+{
+ struct passwd *ppwd = getpwuid( getuid() );
+
+ return ppwd ? (ppwd->pw_dir ? ppwd->pw_dir : "/") : "/";
+}
+
+static bool read_line( FILE *fp, string& rLine )
+{
+ char szBuffer[1024];
+ bool bSuccess = false;
+ bool bEOL = false;
+ string line;
+
+
+ while ( !bEOL && fgets( szBuffer, sizeof(szBuffer), fp ) )
+ {
+ int len = strlen(szBuffer);
+
+ bSuccess = true;
+
+ while ( len && szBuffer[len - 1] == '\n' )
+ {
+ szBuffer[--len] = 0;
+ bEOL = true;
+ }
+
+ line.append( szBuffer );
+ }
+
+ rLine = line;
+ return bSuccess;
+}
+
+static string trim_string( const string& rString )
+{
+ string temp = rString;
+
+ while ( temp.length() && (temp[0] == ' ' || temp[0] == '\t') )
+ temp.erase( 0, 1 );
+
+ string::size_type len = temp.length();
+
+ while ( len && (temp[len-1] == ' ' || temp[len-1] == '\t') )
+ {
+ temp.erase( len - 1, 1 );
+ len = temp.length();
+ }
+
+ return temp;
+}
+
+static string get_profile_string( const char *pFileName, const char *pSectionName, const char *pKeyName, const char *pDefault = NULL )
+{
+ FILE *fp = fopen( pFileName, "r" );
+ string retValue = pDefault ? pDefault : "";
+
+ if ( fp )
+ {
+ string line;
+ string section;
+
+ while ( read_line( fp, line ) )
+ {
+ line = trim_string( line );
+
+ if ( line.length() && line[0] == '[' )
+ {
+ line.erase( 0, 1 );
+ string::size_type end = line.find( ']', 0 );
+
+ if ( string::npos != end )
+ section = trim_string( line.substr( 0, end ) );
+ }
+ else
+ {
+
+ string::size_type iEqualSign = line.find( '=', 0 );
+
+ if ( iEqualSign != string::npos )
+ {
+ string keyname = line.substr( 0, iEqualSign );
+ keyname = trim_string( keyname );
+
+ string value = line.substr( iEqualSign + 1, string::npos );
+ value = trim_string( value );
+
+ if (
+ 0 == strcasecmp( section.c_str(), pSectionName ) &&
+ 0 == strcasecmp( keyname.c_str(), pKeyName )
+ )
+ {
+ retValue = value;
+ break;
+ }
+ }
+ }
+ }
+
+ fclose( fp );
+ }
+
+ return retValue;
+}
+
+static bool get_profile_bool( const char *pFileName, const char *pSectionName, const char *pKeyName )
+{
+ string str = get_profile_string( pFileName, pSectionName, pKeyName );
+
+ if ( !strcasecmp( str.c_str(), "true" ) )
+ return true;
+ return false;
+}
+
+static String get_profile_String( const char *pFileName, const char *pSectionName, const char *pKeyName, const char * = NULL )
+{
+ string str = get_profile_string( pFileName, pSectionName, pKeyName );
+ String result( str.c_str(), RTL_TEXTENCODING_UTF8 );
+
+ return result;
+}
+
+namespace svx{
+ namespace DocRecovery{
+
+ bool ErrorRepSendDialog::ReadParams()
+ {
+ string sRCFile = get_home_dir();
+
+ sRCFile += "/";
+ sRCFile += string(RCFILE);
+
+ maEMailAddrED.SetText( get_profile_String( sRCFile.c_str(), "Options", "ReturnAddress" ) );
+ maParams.maHTTPProxyServer = get_profile_String( sRCFile.c_str(), "Options", "ProxyServer" );
+ maParams.maHTTPProxyPort = get_profile_String( sRCFile.c_str(), "Options", "ProxyPort" );
+ maParams.miHTTPConnectionType = get_profile_bool( sRCFile.c_str(), "Options", "UseProxy" ) ? 2 : 1;
+ maContactCB.Check( get_profile_bool( sRCFile.c_str(), "Options", "AllowContact" ) );
+
+ return true;
+ }
+
+ bool ErrorRepSendDialog::SaveParams()
+ {
+ bool success = false;
+ string sRCFile = get_home_dir();
+
+ sRCFile += "/";
+ sRCFile += string(RCFILE);
+
+ FILE *fp = fopen( sRCFile.c_str(), "w" );
+
+ if ( fp )
+ {
+ fprintf( fp, "[Options]\n" );
+ fprintf( fp, "UseProxy=%s\n", 2 == maParams.miHTTPConnectionType ? "true" : "false" );
+ fprintf( fp, "ProxyServer=%s\n", ByteString( maParams.maHTTPProxyServer, RTL_TEXTENCODING_UTF8 ).GetBuffer() );
+ fprintf( fp, "ProxyPort=%s\n", ByteString( maParams.maHTTPProxyPort, RTL_TEXTENCODING_UTF8 ).GetBuffer() );
+ fprintf( fp, "ReturnAddress=%s\n", ByteString( GetEMailAddress(), RTL_TEXTENCODING_UTF8 ).GetBuffer() );
+ fprintf( fp, "AllowContact=%s\n", IsContactAllowed() ? "true" : "false" );
+ fclose( fp );
+ }
+
+ return success;
+ }
+
+ bool ErrorRepSendDialog::SendReport()
+ {
+ ByteString strSubject( GetDocType(), RTL_TEXTENCODING_UTF8 );
+
+#if defined( LINUX ) || defined (MACOSX )
+ setenv( "ERRORREPORT_SUBJECT", strSubject.GetBuffer(), 1 );
+#else
+ static ::rtl::OString strEnvSubject = "ERRORREPORT_SUBJECT";
+ strEnvSubject += "=";
+ strEnvSubject += strSubject.GetBuffer();
+ putenv( (char *)strEnvSubject.getStr() );
+#endif
+
+ char szBodyFile[L_tmpnam] = "";
+ FILE *fp = fopen( tmpnam( szBodyFile ), "w" );
+
+ if ( fp )
+ {
+ ByteString strUTF8( GetUsing(), RTL_TEXTENCODING_UTF8 );
+
+ fwrite( strUTF8.GetBuffer(), 1, strUTF8.Len(), fp );
+ fclose( fp );
+#if defined( LINUX ) || defined (MACOSX)
+ setenv( "ERRORREPORT_BODYFILE", szBodyFile, 1 );
+#else
+ static ::rtl::OString strEnvBodyFile = "ERRORREPORT_BODYFILE";
+ strEnvBodyFile += "=";
+ strEnvBodyFile += szBodyFile;
+ putenv( (char *)strEnvBodyFile.getStr() );
+#endif
+ }
+
+ int ret = -1;
+ rtl::OUString path1(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "$BRAND_BASE_DIR/program/crashrep"));
+ rtl::Bootstrap::expandMacros(path1);
+ rtl::OString path2;
+ if ((osl::FileBase::getSystemPathFromFileURL(path1, path1) ==
+ osl::FileBase::E_None) &&
+ path1.convertToString(
+ &path2, osl_getThreadTextEncoding(),
+ (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
+ {
+ rtl::OStringBuffer cmd;
+ tools::appendUnixShellWord(&cmd, path2);
+ cmd.append(RTL_CONSTASCII_STRINGPARAM(" -debug -load -send -noui"));
+ ret = system(cmd.getStr());
+ }
+
+ if ( szBodyFile[0] )
+ {
+ unlink( szBodyFile );
+ }
+
+ return -1 != ret;
+ }
+
+
+ } // namespace DocRecovery
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/sendreportw32.cxx b/svx/source/dialog/sendreportw32.cxx
new file mode 100644
index 000000000000..b50dc0c0caee
--- /dev/null
+++ b/svx/source/dialog/sendreportw32.cxx
@@ -0,0 +1,264 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define UNICODE
+#define _UNICODE
+
+#include <tools/svwin.h>
+
+#define WIN32_LEAN_AND_MEAN
+#include <tchar.h>
+#include <stdio.h>
+#include <systools/win32/uwinapi.h>
+#include <sal/macros.h>
+
+// need to undef min and max macros from MS headers here to make
+// the std::min and std::max from stl visible again
+#ifdef min
+#undef min
+#endif
+#ifdef max
+#undef max
+#endif
+
+#include "docrecovery.hxx"
+
+//***************************************************************************
+
+static LONG RegReadValue( HKEY hBaseKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, LPVOID lpData, DWORD cbData )
+{
+ HKEY hKey = NULL;
+ LONG lResult;
+
+ lResult = RegOpenKeyEx( hBaseKey, lpSubKey, 0, KEY_QUERY_VALUE, &hKey );
+
+ if ( ERROR_SUCCESS == lResult )
+ {
+ lResult = RegQueryValueEx( hKey, lpValueName, NULL, NULL, (LPBYTE)lpData, &cbData );
+ RegCloseKey( hKey );
+ }
+
+ return lResult;
+}
+
+//***************************************************************************
+
+static LONG RegWriteValue( HKEY hBaseKey, LPCTSTR lpSubKey, LPCTSTR lpValueName, DWORD dwType, LPCVOID lpData, DWORD cbData )
+{
+ HKEY hKey = NULL;
+ LONG lResult;
+
+ lResult = RegCreateKeyEx( hBaseKey, lpSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL );
+
+ if ( ERROR_SUCCESS == lResult )
+ {
+ lResult = RegSetValueEx( hKey, lpValueName, NULL, dwType, (CONST BYTE *)lpData, cbData );
+ RegCloseKey( hKey );
+ }
+
+ return lResult;
+}
+
+//***************************************************************************
+
+namespace svx{
+ namespace DocRecovery{
+
+ bool ErrorRepSendDialog::ReadParams()
+ {
+ _TCHAR szBuffer[2048];
+
+ if ( ERROR_SUCCESS == RegReadValue(
+ HKEY_CURRENT_USER,
+ TEXT("SOFTWARE\\OpenOffice.org\\CrashReport"),
+ TEXT("HTTPProxyServer"),
+ szBuffer,
+ sizeof(szBuffer) ) )
+ maParams.maHTTPProxyServer = (sal_Unicode *)szBuffer;
+
+ DWORD dwProxyPort;
+ if ( ERROR_SUCCESS == RegReadValue(
+ HKEY_CURRENT_USER,
+ TEXT("SOFTWARE\\OpenOffice.org\\CrashReport"),
+ TEXT("HTTPProxyPort"),
+ &dwProxyPort,
+ sizeof(dwProxyPort) ) )
+ {
+ _stprintf( szBuffer, _T("%d"), dwProxyPort );
+ maParams.maHTTPProxyPort = (sal_Unicode *)szBuffer;
+ }
+
+ if ( ERROR_SUCCESS == RegReadValue(
+ HKEY_CURRENT_USER,
+ TEXT("SOFTWARE\\OpenOffice.org\\CrashReport"),
+ TEXT("ReturnAddress"),
+ szBuffer,
+ sizeof(szBuffer) ) )
+ maEMailAddrED.SetText( (sal_Unicode *)szBuffer );
+
+ DWORD fAllowContact = FALSE;
+ RegReadValue(
+ HKEY_CURRENT_USER,
+ TEXT("SOFTWARE\\OpenOffice.org\\CrashReport"),
+ TEXT("AllowContact"),
+ &fAllowContact,
+ sizeof(fAllowContact) );
+ maContactCB.Check( (BOOL)fAllowContact );
+
+ DWORD uInternetConnection = 0;
+ RegReadValue(
+ HKEY_CURRENT_USER,
+ TEXT("SOFTWARE\\OpenOffice.org\\CrashReport"),
+ TEXT("HTTPConnection"),
+ &uInternetConnection,
+ sizeof(uInternetConnection) );
+ maParams.miHTTPConnectionType = uInternetConnection;
+
+ return true;
+ }
+
+ bool ErrorRepSendDialog::SaveParams()
+ {
+ const _TCHAR *lpHTTPProxyServer = reinterpret_cast<LPCTSTR>(maParams.maHTTPProxyServer.GetBuffer());
+ RegWriteValue(
+ HKEY_CURRENT_USER,
+ TEXT("SOFTWARE\\OpenOffice.org\\CrashReport"),
+ TEXT("HTTPProxyServer"), REG_SZ,
+ lpHTTPProxyServer,
+ sizeof(TCHAR) * (_tcslen(lpHTTPProxyServer) + 1) );
+
+ _TCHAR* endptr = NULL;
+ DWORD dwProxyPort = _tcstoul( reinterpret_cast<LPCTSTR>(maParams.maHTTPProxyPort.GetBuffer()), &endptr, 10 );
+
+ RegWriteValue(
+ HKEY_CURRENT_USER,
+ TEXT("SOFTWARE\\OpenOffice.org\\CrashReport"),
+ TEXT("HTTPProxyPort"), REG_DWORD,
+ &dwProxyPort,
+ sizeof(DWORD) );
+
+ DWORD fAllowContact = IsContactAllowed();
+ RegWriteValue(
+ HKEY_CURRENT_USER,
+ TEXT("SOFTWARE\\OpenOffice.org\\CrashReport"),
+ TEXT("AllowContact"), REG_DWORD,
+ &fAllowContact,
+ sizeof(DWORD) );
+
+
+ DWORD uInternetConnection = maParams.miHTTPConnectionType;
+
+ RegWriteValue(
+ HKEY_CURRENT_USER,
+ TEXT("SOFTWARE\\OpenOffice.org\\CrashReport"),
+ TEXT("HTTPConnection"), REG_DWORD,
+ &uInternetConnection,
+ sizeof(DWORD) );
+
+ const _TCHAR *lpEmail = reinterpret_cast<LPCTSTR>(GetEMailAddress().GetBuffer());
+ RegWriteValue(
+ HKEY_CURRENT_USER,
+ TEXT("SOFTWARE\\OpenOffice.org\\CrashReport"),
+ TEXT("ReturnAddress"), REG_SZ,
+ lpEmail,
+ sizeof(TCHAR) * (_tcslen(lpEmail) + 1) );
+
+ return true;
+ }
+
+ bool ErrorRepSendDialog::SendReport()
+ {
+ TCHAR szTempPath[MAX_PATH];
+ TCHAR szFileName[MAX_PATH];
+
+ GetTempPath( SAL_N_ELEMENTS(szTempPath), szTempPath );
+ GetTempFileName( szTempPath, TEXT("DSC"), 0, szFileName );
+
+ FILE *fp = _tfopen( szFileName, _T("wb") );
+
+ if ( fp )
+ {
+ ByteString strUTF8( GetUsing(), RTL_TEXTENCODING_UTF8 );
+
+ fwrite( strUTF8.GetBuffer(), 1, strUTF8.Len(), fp );
+ fclose( fp );
+ }
+
+ SetEnvironmentVariable( TEXT("ERRORREPORT_SUBJECT"), reinterpret_cast<LPCTSTR>(GetDocType().GetBuffer()) );
+ SetEnvironmentVariable( TEXT("ERRORREPORT_BODYFILE"), szFileName );
+
+ _TCHAR szBuffer[1024];
+ TCHAR szPath[MAX_PATH];
+ LPTSTR lpFilePart;
+ PROCESS_INFORMATION ProcessInfo;
+ STARTUPINFO StartupInfo;
+
+ if ( SearchPath( NULL, TEXT("crashrep.exe"), NULL, MAX_PATH, szPath, &lpFilePart ) )
+ {
+ ZeroMemory( &StartupInfo, sizeof(StartupInfo) );
+ StartupInfo.cb = sizeof(StartupInfo.cb);
+
+ sntprintf( szBuffer, SAL_N_ELEMENTS(szBuffer),
+ _T("%s -noui -load -send"),
+ szPath );
+
+ if (
+ CreateProcess(
+ NULL,
+ szBuffer,
+ NULL,
+ NULL,
+ FALSE,
+ 0,
+ NULL, NULL, &StartupInfo, &ProcessInfo )
+ )
+ {
+ DWORD dwExitCode;
+
+ WaitForSingleObject( ProcessInfo.hProcess, INFINITE );
+ if ( GetExitCodeProcess( ProcessInfo.hProcess, &dwExitCode ) && 0 == dwExitCode )
+ return true;
+
+ }
+ }
+
+ DeleteFile( szFileName );
+
+
+ return false;
+ }
+
+
+ } // namespace DocRecovery
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/simptabl.cxx b/svx/source/dialog/simptabl.cxx
new file mode 100644
index 000000000000..d1b37a9a5bc5
--- /dev/null
+++ b/svx/source/dialog/simptabl.cxx
@@ -0,0 +1,580 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// INCLUDE -------------------------------------------------------------------
+
+#include <svx/simptabl.hxx>
+#include <vcl/svapp.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <unotools/intlwrapper.hxx>
+
+// SvxSimpTblContainer ------------------------------------------------------
+
+SvxSimpTblContainer::SvxSimpTblContainer( Window* pParent, WinBits nWinStyle):
+ Control(pParent,nWinStyle)
+{
+ //Do Nothing;
+}
+
+SvxSimpTblContainer::SvxSimpTblContainer( Window* pParent, const ResId& rResId):
+ Control(pParent,rResId)
+{
+ //Do Nothing;
+}
+
+long SvxSimpTblContainer::PreNotify( NotifyEvent& rNEvt )
+{
+ long nResult = TRUE;
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyCode& aKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
+ USHORT nKey = aKeyCode.GetCode();
+ if ( nKey == KEY_TAB )
+ GetParent()->Notify( rNEvt );
+ else if ( m_pTable->IsFocusOnCellEnabled() && ( nKey == KEY_LEFT || nKey == KEY_RIGHT ) )
+ return 0;
+ else
+ nResult = Control::PreNotify( rNEvt );
+ }
+ else
+ nResult = Control::PreNotify( rNEvt );
+
+ return nResult;
+}
+
+
+// SvxSimpleTable ------------------------------------------------------------
+
+SvxSimpleTable::SvxSimpleTable( Window* pParent,WinBits nBits ):
+ SvHeaderTabListBox(pParent,WB_CLIPCHILDREN | WB_HSCROLL | WB_TABSTOP),
+ aPrivContainer(pParent,nBits|WB_DIALOGCONTROL),
+ aHeaderBar(pParent,WB_BUTTONSTYLE | WB_BORDER | WB_TABSTOP),
+ nHeaderItemId(1),
+ bResizeFlag(FALSE),
+ bPaintFlag(TRUE)
+{
+ bSortDirection=TRUE;
+ nSortCol=0xFFFF;
+ nOldPos=0;
+
+ SetParent(&aPrivContainer);
+ aHeaderBar.SetParent(&aPrivContainer);
+ aPrivContainer.SetTable( this );
+
+ aHeaderBar.SetStartDragHdl(LINK( this, SvxSimpleTable, StartDragHdl));
+ aHeaderBar.SetDragHdl(LINK( this, SvxSimpleTable, DragHdl));
+ aHeaderBar.SetEndDragHdl(LINK( this, SvxSimpleTable, EndDragHdl));
+ aHeaderBar.SetSelectHdl(LINK( this, SvxSimpleTable, HeaderBarClick));
+ aHeaderBar.SetDoubleClickHdl(LINK( this, SvxSimpleTable, HeaderBarDblClick));
+
+ EnableCellFocus();
+ DisableTransientChildren();
+ InitHeaderBar( &aHeaderBar );
+
+ aHeaderBar.Show();
+ SvHeaderTabListBox::Show();
+}
+
+
+SvxSimpleTable::SvxSimpleTable( Window* pParent,const ResId& rResId):
+ SvHeaderTabListBox(pParent,WB_CLIPCHILDREN | WB_HSCROLL | WB_TABSTOP),
+ aPrivContainer(pParent,rResId),
+ aHeaderBar(pParent,WB_BUTTONSTYLE | WB_BORDER | WB_TABSTOP),
+ nHeaderItemId(1),
+ bResizeFlag(TRUE),
+ bPaintFlag(TRUE)
+{
+
+ bSortDirection=TRUE;
+ nOldPos=0;
+ nSortCol=0xFFFF;
+
+ pMyParentWin=pParent;
+ SetParent(&aPrivContainer);
+ aHeaderBar.SetParent(&aPrivContainer);
+ aPrivContainer.SetTable( this );
+
+ WinBits nBits=aPrivContainer.GetStyle()|WB_DIALOGCONTROL;
+ aPrivContainer.SetStyle(nBits);
+
+ aHeaderBar.SetStartDragHdl(LINK( this, SvxSimpleTable, StartDragHdl));
+ aHeaderBar.SetDragHdl(LINK( this, SvxSimpleTable, DragHdl));
+ aHeaderBar.SetEndDragHdl(LINK( this, SvxSimpleTable, EndDragHdl));
+ aHeaderBar.SetSelectHdl(LINK( this, SvxSimpleTable, HeaderBarClick));
+ aHeaderBar.SetDoubleClickHdl(LINK( this, SvxSimpleTable, HeaderBarDblClick));
+
+ Size theWinSize=aPrivContainer.GetOutputSizePixel();
+ Size HbSize=aHeaderBar.GetSizePixel();
+
+ HbSize.Width()=theWinSize.Width();
+ theWinSize.Height()-=HbSize.Height();
+ Point thePos(0,0);
+
+ aHeaderBar.SetPosPixel(thePos);
+ aHeaderBar.SetSizePixel(HbSize);
+
+ thePos.Y()+=HbSize.Height();
+ SvHeaderTabListBox::SetPosPixel(thePos);
+ SvHeaderTabListBox::SetSizePixel(theWinSize);
+
+ EnableCellFocus();
+ DisableTransientChildren();
+ InitHeaderBar( &aHeaderBar );
+
+ aHeaderBar.Show();
+ SetWindowBits(WB_CLIPCHILDREN | WB_HSCROLL);
+ SvHeaderTabListBox::Show();
+}
+
+SvxSimpleTable::~SvxSimpleTable()
+{
+ SetParent(pMyParentWin);
+ aPrivContainer.SetParent(this);
+ aHeaderBar.SetParent(this);
+}
+
+
+void SvxSimpleTable::UpdateViewSize()
+{
+ Size theWinSize=aPrivContainer.GetOutputSizePixel();
+ Size HbSize=aHeaderBar.GetSizePixel();
+
+ HbSize.Width()=theWinSize.Width();
+ theWinSize.Height()-=HbSize.Height();
+ Point thePos(0,0);
+
+ aHeaderBar.SetPosPixel(thePos);
+ aHeaderBar.SetSizePixel(HbSize);
+
+ thePos.Y()+=HbSize.Height();
+ SvHeaderTabListBox::SetPosPixel(thePos);
+ SvHeaderTabListBox::SetSizePixel(theWinSize);
+ Invalidate();
+}
+
+void SvxSimpleTable::NotifyScrolled()
+{
+ long nOffset=-GetXOffset();
+ if(nOldPos!=nOffset)
+ {
+ aHeaderBar.SetOffset(nOffset);
+ aHeaderBar.Invalidate();
+ aHeaderBar.Update();
+ nOldPos=nOffset;
+ }
+ SvHeaderTabListBox::NotifyScrolled();
+}
+
+void SvxSimpleTable::SetTabs()
+{
+ SvHeaderTabListBox::SetTabs();
+
+ USHORT nPrivTabCount = TabCount();
+ if ( nPrivTabCount )
+ {
+ if ( nPrivTabCount > aHeaderBar.GetItemCount() )
+ nPrivTabCount = aHeaderBar.GetItemCount();
+
+ USHORT i, nNewSize = static_cast< USHORT >( GetTab(0) ), nPos = 0;
+ for ( i = 1; i < nPrivTabCount; ++i )
+ {
+ nNewSize = static_cast< USHORT >( GetTab(i) ) - nPos;
+ aHeaderBar.SetItemSize( i, nNewSize );
+ nPos = (USHORT)GetTab(i);
+ }
+
+ aHeaderBar.SetItemSize( i, HEADERBAR_FULLSIZE ); // because no tab for last entry
+ }
+}
+
+void SvxSimpleTable::SetTabs( long* pTabs, MapUnit eMapUnit)
+{
+ SvHeaderTabListBox::SetTabs(pTabs,eMapUnit);
+}
+
+void SvxSimpleTable::Paint( const Rectangle& rRect )
+{
+ SvHeaderTabListBox::Paint(rRect );
+
+ USHORT nPrivTabCount = TabCount();
+ USHORT nPos = 0;
+ USHORT nNewSize = ( nPrivTabCount > 0 ) ? (USHORT)GetTab(0) : 0;
+
+ long nOffset=-GetXOffset();
+ nOldPos=nOffset;
+
+ aHeaderBar.SetOffset(nOffset);
+ aHeaderBar.Invalidate();
+
+ if(nPrivTabCount && bPaintFlag)
+ {
+ if(nPrivTabCount>aHeaderBar.GetItemCount())
+ nPrivTabCount=aHeaderBar.GetItemCount();
+
+ for(USHORT i=1;i<nPrivTabCount;i++)
+ {
+ nNewSize = static_cast< USHORT >( GetTab(i) ) - nPos;
+ aHeaderBar.SetItemSize( i, nNewSize );
+ nPos= static_cast< USHORT >( GetTab(i) );
+ }
+ }
+ bPaintFlag=TRUE;
+}
+void SvxSimpleTable::InsertHeaderEntry(const XubString& rText,USHORT nCol,
+ HeaderBarItemBits nBits)
+{
+ xub_StrLen nEnd = rText.Search( sal_Unicode( '\t' ) );
+ if( nEnd == STRING_NOTFOUND )
+ {
+ aHeaderBar.InsertItem(nHeaderItemId++, rText, 0, nBits, nCol);
+ }
+ else
+ {
+ xub_StrLen nCount = rText.GetTokenCount( sal_Unicode( '\t' ) );
+
+ for( xub_StrLen i=0; i<nCount; i++ )
+ {
+ String aString=rText.GetToken(i, sal_Unicode( '\t' ) );
+ aHeaderBar.InsertItem(nHeaderItemId++, aString, 0, nBits, nCol);
+ }
+ }
+ SetTabs();
+}
+
+void SvxSimpleTable::ClearAll()
+{
+ aHeaderBar.Clear();
+ Clear();
+}
+void SvxSimpleTable::ClearHeader()
+{
+ aHeaderBar.Clear();
+}
+
+void SvxSimpleTable::ShowTable()
+{
+ aPrivContainer.Show();
+}
+
+void SvxSimpleTable::HideTable()
+{
+ aPrivContainer.Hide();
+}
+
+BOOL SvxSimpleTable::IsVisible() const
+{
+ return aPrivContainer.IsVisible();
+}
+
+void SvxSimpleTable::EnableTable()
+{
+ aPrivContainer.Enable();
+}
+
+void SvxSimpleTable::DisableTable()
+{
+ aPrivContainer.Disable();
+}
+
+BOOL SvxSimpleTable::IsEnabled() const
+{
+ return aPrivContainer.IsEnabled();
+}
+
+void SvxSimpleTable::TableToTop()
+{
+ aPrivContainer.ToTop();
+}
+
+void SvxSimpleTable::SetPosPixel( const Point& rNewPos )
+{
+ aPrivContainer.SetPosPixel(rNewPos);
+}
+
+Point SvxSimpleTable::GetPosPixel() const
+{
+ return aPrivContainer.GetPosPixel();
+}
+
+void SvxSimpleTable::SetPosSizePixel( const Point& rNewPos, Size& rNewSize )
+{
+ aPrivContainer.SetPosPixel(rNewPos);
+ aPrivContainer.SetSizePixel(rNewSize);
+}
+
+void SvxSimpleTable::SetPosSize( const Point& rNewPos, const Size& rNewSize )
+{
+ aPrivContainer.SetPosPixel(rNewPos);
+ SvHeaderTabListBox::SetPosSizePixel(rNewPos,rNewSize);
+}
+
+Size SvxSimpleTable::GetSizePixel() const
+{
+ return aPrivContainer.GetSizePixel();
+}
+
+Size SvxSimpleTable::GetOutputSizePixel() const
+{
+ return aPrivContainer.GetOutputSizePixel();
+}
+
+void SvxSimpleTable::SetSizePixel(const Size& rNewSize )
+{
+ aPrivContainer.SetSizePixel(rNewSize);
+ UpdateViewSize();
+}
+
+void SvxSimpleTable::SetOutputSizePixel(const Size& rNewSize )
+{
+ aPrivContainer.SetOutputSizePixel(rNewSize);
+ UpdateViewSize();
+}
+
+USHORT SvxSimpleTable::GetSelectedCol()
+{
+ return (aHeaderBar.GetCurItemId()-1);
+}
+
+void SvxSimpleTable::SortByCol(USHORT nCol,BOOL bDir)
+{
+ bSortDirection=bDir;
+ if(nSortCol!=0xFFFF)
+ aHeaderBar.SetItemBits(nSortCol+1,HIB_STDSTYLE);
+
+ if (nCol != 0xFFFF)
+ {
+ if(bDir)
+ {
+ aHeaderBar.SetItemBits( nCol+1, HIB_STDSTYLE | HIB_DOWNARROW);
+ GetModel()->SetSortMode(SortAscending);
+ }
+ else
+ {
+ aHeaderBar.SetItemBits( nCol+1, HIB_STDSTYLE | HIB_UPARROW);
+ GetModel()->SetSortMode(SortDescending);
+ }
+ nSortCol=nCol;
+ GetModel()->SetCompareHdl( LINK( this, SvxSimpleTable, CompareHdl));
+ GetModel()->Resort();
+ }
+ else
+ GetModel()->SetSortMode(SortNone);
+ nSortCol=nCol;
+}
+
+void SvxSimpleTable::HBarClick()
+{
+ USHORT nId=aHeaderBar.GetCurItemId();
+
+ if (aHeaderBar.GetItemBits(nId) & HIB_CLICKABLE)
+ {
+ if(nId==nSortCol+1)
+ {
+ SortByCol(nId-1,!bSortDirection);
+ }
+ else
+ {
+ SortByCol(nId-1,bSortDirection);
+ }
+
+ aHeaderBarClickLink.Call(this);
+ }
+}
+
+void SvxSimpleTable::HBarDblClick()
+{
+ aHeaderBarDblClickLink.Call(this);
+}
+
+void SvxSimpleTable::HBarStartDrag()
+{
+ if(!aHeaderBar.IsItemMode())
+ {
+ Rectangle aSizeRect(Point(0,0),
+ SvHeaderTabListBox::GetOutputSizePixel());
+ aSizeRect.Left()=-GetXOffset()+aHeaderBar.GetDragPos();
+ aSizeRect.Right()=-GetXOffset()+aHeaderBar.GetDragPos();
+ ShowTracking( aSizeRect, SHOWTRACK_SPLIT );
+ }
+}
+void SvxSimpleTable::HBarDrag()
+{
+ HideTracking();
+ if(!aHeaderBar.IsItemMode())
+ {
+ Rectangle aSizeRect(Point(0,0),
+ SvHeaderTabListBox::GetOutputSizePixel());
+ aSizeRect.Left()=-GetXOffset()+aHeaderBar.GetDragPos();
+ aSizeRect.Right()=-GetXOffset()+aHeaderBar.GetDragPos();
+ ShowTracking( aSizeRect, SHOWTRACK_SPLIT );
+ }
+}
+void SvxSimpleTable::HBarEndDrag()
+{
+ HideTracking();
+ USHORT nPrivTabCount=TabCount();
+ USHORT nPos=0;
+ USHORT nNewSize=0;
+
+ if(nPrivTabCount)
+ {
+ if(nPrivTabCount>aHeaderBar.GetItemCount())
+ nPrivTabCount=aHeaderBar.GetItemCount();
+
+ //for(USHORT i=1;i<=nPrivTabCount;i++)
+ for(USHORT i=1;i<nPrivTabCount;i++)
+ {
+ nNewSize = static_cast< USHORT >( aHeaderBar.GetItemSize(i) ) + nPos;
+ SetTab( i, nNewSize, MAP_PIXEL );
+ nPos = nNewSize;
+ }
+ }
+ bPaintFlag=FALSE;
+ Invalidate();
+ Update();
+}
+
+CommandEvent SvxSimpleTable::GetCommandEvent() const
+{
+ return aCEvt;
+}
+
+void SvxSimpleTable::Command( const CommandEvent& rCEvt )
+{
+ aCEvt=rCEvt;
+ aCommandLink.Call(this);
+ SvHeaderTabListBox::Command(rCEvt);
+}
+
+IMPL_LINK( SvxSimpleTable, StartDragHdl, HeaderBar*, pCtr)
+{
+ if(pCtr==&aHeaderBar)
+ {
+ HBarStartDrag();
+ }
+ return 0;
+}
+
+IMPL_LINK( SvxSimpleTable, DragHdl, HeaderBar*, pCtr)
+{
+ if(pCtr==&aHeaderBar)
+ {
+ HBarDrag();
+ }
+ return 0;
+}
+
+IMPL_LINK( SvxSimpleTable, EndDragHdl, HeaderBar*, pCtr)
+{
+ if(pCtr==&aHeaderBar)
+ {
+ HBarEndDrag();
+ }
+ return 0;
+}
+
+IMPL_LINK( SvxSimpleTable, HeaderBarClick, HeaderBar*, pCtr)
+{
+ if(pCtr==&aHeaderBar)
+ {
+ HBarClick();
+ }
+ return 0;
+}
+
+IMPL_LINK( SvxSimpleTable, HeaderBarDblClick, HeaderBar*, pCtr)
+{
+ if(pCtr==&aHeaderBar)
+ {
+ HBarDblClick();
+ }
+ return 0;
+}
+
+SvLBoxItem* SvxSimpleTable::GetEntryAtPos( SvLBoxEntry* pEntry, USHORT nPos ) const
+{
+ DBG_ASSERT(pEntry,"GetEntryText:Invalid Entry");
+ SvLBoxItem* pItem = NULL;
+
+ if( pEntry )
+ {
+ USHORT nCount = pEntry->ItemCount();
+
+ nPos++;
+
+ if( nTreeFlags & TREEFLAG_CHKBTN ) nPos++;
+
+ if( nPos < nCount )
+ {
+ pItem = pEntry->GetItem( nPos);
+ }
+ }
+ return pItem;
+}
+
+StringCompare SvxSimpleTable::ColCompare(SvLBoxEntry* pLeft,SvLBoxEntry* pRight)
+{
+ StringCompare eCompare=COMPARE_EQUAL;
+
+ SvLBoxItem* pLeftItem = GetEntryAtPos( pLeft, nSortCol);
+ SvLBoxItem* pRightItem = GetEntryAtPos( pRight, nSortCol);
+
+
+ if(pLeftItem != NULL && pRightItem != NULL)
+ {
+ USHORT nLeftKind=pLeftItem->IsA();
+ USHORT nRightKind=pRightItem->IsA();
+
+ if(nRightKind == SV_ITEM_ID_LBOXSTRING &&
+ nLeftKind == SV_ITEM_ID_LBOXSTRING )
+ {
+ IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
+ const CollatorWrapper* pCollator = aIntlWrapper.getCaseCollator();
+
+ eCompare=(StringCompare)pCollator->compareString( ((SvLBoxString*)pLeftItem)->GetText(),
+ ((SvLBoxString*)pRightItem)->GetText());
+
+ if(eCompare==COMPARE_EQUAL) eCompare=COMPARE_LESS;
+ }
+ }
+ return eCompare;
+}
+
+IMPL_LINK( SvxSimpleTable, CompareHdl, SvSortData*, pData)
+{
+ SvLBoxEntry* pLeft = (SvLBoxEntry*)(pData->pLeft );
+ SvLBoxEntry* pRight = (SvLBoxEntry*)(pData->pRight );
+ return (long) ColCompare(pLeft,pRight);
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/srchctrl.cxx b/svx/source/dialog/srchctrl.cxx
new file mode 100644
index 000000000000..6e215781e1de
--- /dev/null
+++ b/svx/source/dialog/srchctrl.cxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/pstm.hxx>
+#include <svl/intitem.hxx>
+#include <sfx2/objsh.hxx>
+
+#include <svx/svxids.hrc>
+
+#define _SVX_SRCHDLG_CXX // damit private-Methoden vom SrchDlg bekannt sind
+
+
+
+#include "srchctrl.hxx"
+#include "srchdlg.hxx"
+#include <svl/srchitem.hxx>
+
+// class SvxSearchFamilyControllerItem -----------------------------------
+
+SvxSearchController::SvxSearchController
+(
+ USHORT _nId,
+ SfxBindings& rBind,
+ SvxSearchDialog& rDlg
+) :
+ SfxControllerItem( _nId, rBind ),
+
+ rSrchDlg( rDlg )
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchController::StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ if ( SFX_ITEM_AVAILABLE == eState )
+ {
+ if ( SID_STYLE_FAMILY1 <= nSID && nSID <= SID_STYLE_FAMILY4 )
+ {
+ SfxObjectShell* pShell = SfxObjectShell::Current();
+
+ if ( pShell && pShell->GetStyleSheetPool() )
+ rSrchDlg.TemplatesChanged_Impl( *pShell->GetStyleSheetPool() );
+ }
+ else if ( SID_SEARCH_OPTIONS == nSID )
+ {
+ DBG_ASSERT( pState->ISA(SfxUInt16Item), "wrong item type" );
+ USHORT nFlags = (USHORT)( (SfxUInt16Item*)pState )->GetValue();
+ rSrchDlg.EnableControls_Impl( nFlags );
+ }
+ else if ( SID_SEARCH_ITEM == nSID )
+ {
+ DBG_ASSERT( pState->ISA(SvxSearchItem), "wrong item type" );
+ rSrchDlg.SetItem_Impl( (const SvxSearchItem*)pState );
+ }
+ }
+ else if ( SID_SEARCH_OPTIONS == nSID || SID_SEARCH_ITEM == nSID )
+ rSrchDlg.EnableControls_Impl( 0 );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/srchctrl.hxx b/svx/source/dialog/srchctrl.hxx
new file mode 100644
index 000000000000..3547c3ea8b8c
--- /dev/null
+++ b/svx/source/dialog/srchctrl.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_SRCHCTRL_HXX
+#define _SVX_SRCHCTRL_HXX
+
+// include ---------------------------------------------------------------
+
+
+#include <sfx2/ctrlitem.hxx>
+// class SvxSearchFamilyController ---------------------------------------
+
+class SvxSearchDialog;
+
+class SvxSearchController : public SfxControllerItem
+{
+ SvxSearchDialog& rSrchDlg;
+
+protected:
+ virtual void StateChanged( USHORT, SfxItemState, const SfxPoolItem* pState );
+
+public:
+ SvxSearchController( USHORT nId, SfxBindings& rBnd, SvxSearchDialog& rDlg );
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
new file mode 100644
index 000000000000..96f202f7ea9e
--- /dev/null
+++ b/svx/source/dialog/srchdlg.cxx
@@ -0,0 +1,2581 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+#include <vcl/wrkwin.hxx>
+#include <vcl/morebtn.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/slstitm.hxx>
+#include <svl/itemiter.hxx>
+#include <svl/style.hxx>
+#include <unotools/searchopt.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/module.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <svl/cjkoptions.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <comphelper/processfactory.hxx>
+#include <svl/itempool.hxx>
+#include <svl/intitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <toolkit/unohlp.hxx>
+
+#define _SVX_SRCHDLG_CXX
+#include "srchdlg.hxx"
+
+#include <svx/dialogs.hrc>
+#include <svx/svxitems.hrc>
+#include "srchdlg.hrc"
+
+
+#define ITEMID_SETITEM 0
+
+#include <svl/srchitem.hxx>
+#include <svx/pageitem.hxx>
+#include "srchctrl.hxx"
+#include <svx/dialmgr.hxx>
+#include "dlgutil.hxx"
+#include <editeng/brshitem.hxx>
+#include <tools/resary.hxx>
+#include <svx/svxdlg.hxx>
+
+#include <sfx2/layout-pre.hxx>
+
+using namespace com::sun::star::i18n;
+using namespace com::sun::star;
+using namespace comphelper;
+
+// -----------------------------------------------------------------------
+
+#define REMEMBER_SIZE 10
+
+#define MODIFY_SEARCH 0x00000001
+#define MODIFY_REPLACE 0x00000002
+#define MODIFY_WORD 0x00000004
+#define MODIFY_EXACT 0x00000008
+#define MODIFY_BACKWARDS 0x00000010
+#define MODIFY_SELECTION 0x00000020
+#define MODIFY_REGEXP 0x00000040
+#define MODIFY_LAYOUT 0x00000080
+#define MODIFY_SIMILARITY 0x00000100
+#define MODIFY_FORMULAS 0x00000200
+#define MODIFY_VALUES 0x00000400
+#define MODIFY_CALC_NOTES 0x00000800
+#define MODIFY_ROWS 0x00001000
+#define MODIFY_COLUMNS 0x00002000
+#define MODIFY_ALLTABLES 0x00004000
+#define MODIFY_NOTES 0x00008000
+
+SV_IMPL_VARARR(SrchAttrItemList, SearchAttrItem);
+
+//#define NotifyApp( nId )
+// rBindings.ExecuteSynchron( nId, (const SfxPoolItem**)&pSearchItem, 0L )
+
+#define GetCheckBoxValue( rBox ) \
+ rBox.IsEnabled() ? rBox.IsChecked() : FALSE
+
+#if ENABLE_LAYOUT
+#undef SVX_RES
+#define SVX_RES(x) #x
+#endif /* ENABLE_LAYOUT */
+
+struct SearchDlg_Impl
+{
+ FixedText aSearchFormats;
+ FixedText aReplaceFormats;
+
+ BOOL bMultiLineEdit : 1,
+ bSaveToModule : 1,
+ bFocusOnSearch : 1,
+ bDeltaCalculated : 1;
+ USHORT* pRanges;
+ Timer aSelectionTimer;
+
+ uno::Reference< frame::XDispatch > xCommand1Dispatch;
+ uno::Reference< frame::XDispatch > xCommand2Dispatch;
+ util::URL aCommand1URL;
+ util::URL aCommand2URL;
+
+#if ENABLE_LAYOUT
+ SearchDlg_Impl( layout::Context* pParent ) :
+#else /* !ENABLE_LAYOUT */
+ SearchDlg_Impl( Window* pParent ) :
+#endif /* !ENABLE_LAYOUT */
+ aSearchFormats ( pParent, SVX_RES( FT_SEARCH_FORMATS ) ),
+ aReplaceFormats ( pParent, SVX_RES( FT_REPLACE_FORMATS ) ),
+ bMultiLineEdit ( FALSE ),
+ bSaveToModule ( TRUE ),
+ bFocusOnSearch ( TRUE ),
+ bDeltaCalculated( FALSE ),
+ pRanges ( NULL )
+ {
+ aCommand1URL.Complete = aCommand1URL.Main = rtl::OUString::createFromAscii("vnd.sun.search:SearchViaComponent1");
+ aCommand1URL.Protocol = rtl::OUString::createFromAscii("vnd.sun.search:");
+ aCommand1URL.Path = rtl::OUString::createFromAscii("SearchViaComponent1");
+ aCommand2URL.Complete = aCommand2URL.Main = rtl::OUString::createFromAscii("vnd.sun.search:SearchViaComponent2");
+ aCommand2URL.Protocol = rtl::OUString::createFromAscii("vnd.sun.search:");
+ aCommand2URL.Path = rtl::OUString::createFromAscii("SearchViaComponent2");
+ }
+ ~SearchDlg_Impl() { delete[] pRanges; }
+};
+
+// -----------------------------------------------------------------------
+
+void ListToStrArr_Impl( USHORT nId, SvStringsDtor& rStrLst, ComboBox& rCBox )
+{
+ SfxStringListItem* pSrchItem =
+ (SfxStringListItem*)SFX_APP()->GetItem( nId );
+ List* pLst = pSrchItem ? pSrchItem->GetList() : 0;
+
+ if ( pLst )
+ for ( USHORT i = 0; i < pLst->Count(); ++i )
+ {
+ String* pTmp = new String( *(String*)( pLst->GetObject(i) ) );
+ rStrLst.Insert( pTmp, rStrLst.Count() );
+ rCBox.InsertEntry( *pTmp );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void StrArrToList_Impl( USHORT nId, const SvStringsDtor& rStrLst )
+{
+ DBG_ASSERT( rStrLst.Count(), "vorher abpruefen!!" );
+ List aLst;
+
+ for ( USHORT i = 0; i < rStrLst.Count(); ++i )
+ aLst.Insert( rStrLst[ i ], LIST_APPEND );
+
+ SFX_APP()->PutItem( SfxStringListItem( nId, &aLst ) );
+}
+
+// class SearchAttrItemList ----------------------------------------------
+
+SearchAttrItemList::SearchAttrItemList( const SearchAttrItemList& rList ) :
+
+ SrchAttrItemList( (BYTE)rList.Count() )
+
+{
+ SrchAttrItemList::Insert( &rList, 0 );
+ SearchAttrItem* _pData = (SearchAttrItem*)GetData();
+
+ for ( USHORT i = Count(); i; --i, ++_pData )
+ if ( !IsInvalidItem( _pData->pItem ) )
+ _pData->pItem = _pData->pItem->Clone();
+}
+
+// -----------------------------------------------------------------------
+
+SearchAttrItemList::~SearchAttrItemList()
+{
+ Clear();
+}
+
+// -----------------------------------------------------------------------
+
+void SearchAttrItemList::Put( const SfxItemSet& rSet )
+{
+ if ( !rSet.Count() )
+ return;
+
+ SfxItemPool* pPool = rSet.GetPool();
+ SfxItemIter aIter( rSet );
+ SearchAttrItem aItem;
+ const SfxPoolItem* pItem = aIter.GetCurItem();
+ USHORT nWhich;
+
+ while ( TRUE )
+ {
+ // nur testen, ob vorhanden ist ?
+ if( IsInvalidItem( pItem ) )
+ {
+ nWhich = rSet.GetWhichByPos( aIter.GetCurPos() );
+ aItem.pItem = (SfxPoolItem*)pItem;
+ }
+ else
+ {
+ nWhich = pItem->Which();
+ aItem.pItem = pItem->Clone();
+ }
+
+ aItem.nSlot = pPool->GetSlotId( nWhich );
+ Insert( aItem );
+
+ if ( aIter.IsAtEnd() )
+ break;
+ pItem = aIter.NextItem();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemSet& SearchAttrItemList::Get( SfxItemSet& rSet )
+{
+ SfxItemPool* pPool = rSet.GetPool();
+ SearchAttrItem* _pData = (SearchAttrItem*)GetData();
+
+ for ( USHORT i = Count(); i; --i, ++_pData )
+ if ( IsInvalidItem( _pData->pItem ) )
+ rSet.InvalidateItem( pPool->GetWhich( _pData->nSlot ) );
+ else
+ rSet.Put( *_pData->pItem );
+ return rSet;
+}
+
+// -----------------------------------------------------------------------
+
+void SearchAttrItemList::Clear()
+{
+ SearchAttrItem* _pData = (SearchAttrItem*)GetData();
+
+ for ( USHORT i = Count(); i; --i, ++_pData )
+ if ( !IsInvalidItem( _pData->pItem ) )
+ delete _pData->pItem;
+ SrchAttrItemList::Remove( 0, Count() );
+}
+
+// -----------------------------------------------------------------------
+
+// l"oscht die Pointer auf die Items
+void SearchAttrItemList::Remove( USHORT nPos, USHORT nLen )
+{
+ if ( nPos + nLen > Count() )
+ nLen = Count() - nPos;
+ SearchAttrItem* _pData = (SearchAttrItem*)GetData() + nPos;
+
+ for ( USHORT n = nLen; n; --n, ++_pData )
+ if ( !IsInvalidItem( _pData->pItem ) )
+ delete _pData->pItem;
+
+ SrchAttrItemList::Remove( nPos, nLen );
+}
+
+#if ENABLE_LAYOUT
+#undef SfxModelessDialog
+#define SfxModelessDialog(bindings, child, parent, id) SfxDialog (parent, "find-and-replace.xml", id, bindings, child)
+#define SVX_RES_PLAIN(x) ResId (x, DIALOG_MGR ())
+#define THIS_SVX_RES(x) this, #x
+#else /* !ENABLE_LAYOUT */
+#define SVX_RES_PLAIN SVX_RES
+#define THIS_SVX_RES SVX_RES
+#endif /* !ENABLE_LAYOUT */
+
+#undef INI_LIST
+#define INI_LIST() \
+ aSearchText ( this, SVX_RES( FT_SEARCH ) ), \
+ aSearchLB ( this, SVX_RES( ED_SEARCH ) ), \
+ aSearchTmplLB ( this, SVX_RES( LB_SEARCH ) ), \
+ aSearchAttrText ( this, SVX_RES( FT_SEARCH_ATTR ) ), \
+ aReplaceText ( this, SVX_RES( FT_REPLACE ) ), \
+ aReplaceLB ( this, SVX_RES( ED_REPLACE ) ), \
+ aReplaceTmplLB ( this, SVX_RES( LB_REPLACE ) ), \
+ aReplaceAttrText( this, SVX_RES( FT_REPLACE_ATTR ) ), \
+ aSearchBtn ( this, SVX_RES( BTN_SEARCH ) ), \
+ aSearchAllBtn ( this, SVX_RES( BTN_SEARCH_ALL ) ), \
+ aSearchCmdLine ( this, SVX_RES( FL_SEARCH_COMMAND ) ), \
+ aReplaceBtn ( this, SVX_RES( BTN_REPLACE ) ), \
+ aReplaceAllBtn ( this, SVX_RES( BTN_REPLACE_ALL ) ), \
+ aSearchComponentFL( this, SVX_RES( FL_SEARCH_COMPONENT ) ), \
+ aSearchComponent1PB( this, SVX_RES( BTN_COMPONENT_1 ) ), \
+ aSearchComponent2PB( this, SVX_RES( BTN_COMPONENT_2 ) ), \
+ aMatchCaseCB ( this, SVX_RES( CB_MATCH_CASE ) ), \
+ aWordBtn ( this, SVX_RES( CB_WHOLE_WORDS ) ), \
+ aButtonsFL ( this, SVX_RES( FL_BUTTONS ) ), \
+ pMoreBtn ( new MoreButton( this, SVX_RES( BTN_MORE ) ) ), \
+ aHelpBtn ( this, SVX_RES( BTN_HELP ) ), \
+ aCloseBtn ( this, SVX_RES( BTN_CLOSE ) ), \
+ aOptionsFL ( this, SVX_RES( FL_OPTIONS ) ), \
+ aSelectionBtn ( this, SVX_RES( CB_SELECTIONS ) ), \
+ aBackwardsBtn ( this, SVX_RES( CB_BACKWARDS ) ), \
+ aRegExpBtn ( this, SVX_RES( CB_REGEXP ) ), \
+ aSimilarityBox ( this, SVX_RES( CB_SIMILARITY) ), \
+ aSimilarityBtn ( this, SVX_RES( PB_SIMILARITY) ), \
+ aLayoutBtn ( this, SVX_RES( CB_LAYOUTS ) ), \
+ aNotesBtn ( this, SVX_RES( CB_NOTES ) ), \
+ aJapMatchFullHalfWidthCB( this, SVX_RES( CB_JAP_MATCH_FULL_HALF_WIDTH ) ),\
+ aJapOptionsCB ( this, SVX_RES( CB_JAP_SOUNDS_LIKE ) ), \
+ aJapOptionsBtn ( this, SVX_RES( PB_JAP_OPTIONS ) ), \
+ aAttributeBtn ( this, SVX_RES( BTN_ATTRIBUTE ) ), \
+ aFormatBtn ( this, SVX_RES( BTN_FORMAT ) ), \
+ aNoFormatBtn ( this, SVX_RES( BTN_NOFORMAT ) ), \
+ aCalcFL ( this, SVX_RES( FL_CALC ) ), \
+ aCalcSearchInFT ( this, SVX_RES( FT_CALC_SEARCHIN ) ), \
+ aCalcSearchInLB ( this, SVX_RES( LB_CALC_SEARCHIN ) ), \
+ aCalcSearchDirFT( this, SVX_RES( FT_CALC_SEARCHDIR ) ), \
+ aRowsBtn ( this, SVX_RES( RB_CALC_ROWS ) ), \
+ aColumnsBtn ( this, SVX_RES( RB_CALC_COLUMNS ) ), \
+ aAllSheetsCB ( this, SVX_RES( CB_ALL_SHEETS ) ), \
+ rBindings ( rBind ), \
+ bWriter ( FALSE ), \
+ bSearch ( TRUE ), \
+ bFormat ( FALSE ), \
+ nOptions ( USHRT_MAX ), \
+ bSet ( FALSE ), \
+ bReadOnly ( FALSE ), \
+ bConstruct ( TRUE ), \
+ nModifyFlag ( 0 ), \
+ aCalcStr ( THIS_SVX_RES( STR_WORDCALC ) ), \
+ pImpl ( NULL ), \
+ pSearchList ( NULL ), \
+ pReplaceList ( new SearchAttrItemList ), \
+ pSearchItem ( NULL ), \
+ pSearchController ( NULL ), \
+ pOptionsController ( NULL ), \
+ pFamilyController ( NULL ), \
+ pSearchSetController ( NULL ), \
+ pReplaceSetController ( NULL ), \
+ nTransliterationFlags ( 0x00000000 )
+
+// class SvxSearchDialog -------------------------------------------------
+
+SvxSearchDialog::SvxSearchDialog( Window* pParent, SfxBindings& rBind ) :
+
+ SfxModelessDialog( &rBind, NULL, pParent, SVX_RES( RID_SVXDLG_SEARCH ) ),
+
+ INI_LIST()
+
+{
+ Construct_Impl();
+}
+
+// -----------------------------------------------------------------------
+
+SvxSearchDialog::SvxSearchDialog( Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind ) :
+
+ SfxModelessDialog( &rBind, pChildWin, pParent, SVX_RES( RID_SVXDLG_SEARCH ) ),
+
+ INI_LIST()
+
+{
+ Construct_Impl();
+}
+
+#undef INI_LIST
+#if ENABLE_LAYOUT
+#undef SVX_RES
+#define SVX_RES(x) ResId (x, DIALOG_MGR ())
+#endif
+
+// -----------------------------------------------------------------------
+
+SvxSearchDialog::~SvxSearchDialog()
+{
+ Hide();
+
+ rBindings.EnterRegistrations();
+ delete pSearchController;
+ delete pOptionsController;
+ delete pFamilyController;
+ delete pSearchSetController;
+ delete pReplaceSetController;
+ rBindings.LeaveRegistrations();
+
+ delete pSearchItem;
+ delete pImpl;
+ delete pSearchList;
+ delete pReplaceList;
+ delete pMoreBtn;
+}
+
+#if ENABLE_LAYOUT
+#undef Window
+#define Window layout::Window
+#endif /* ENABLE_LAYOUT */
+
+void lcl_MoveDown( Window& rWindow, sal_Int32 nOffset )
+{
+ Point aPos(rWindow.GetPosPixel());
+ aPos.Y() += nOffset;
+ rWindow.SetPosPixel(aPos);
+}
+
+void SvxSearchDialog::Construct_Impl()
+{
+#if ENABLE_LAYOUT
+ SetHelpId (SID_SEARCH_DLG);
+#endif /* ENABLE_LAYOUT */
+
+ // temporary to avoid incompatibility
+ pImpl = new SearchDlg_Impl( this );
+#if !ENABLE_LAYOUT
+ pImpl->aSelectionTimer.SetTimeout( 500 );
+ pImpl->aSelectionTimer.SetTimeoutHdl(
+ LINK( this, SvxSearchDialog, TimeoutHdl_Impl ) );
+#endif /* !ENABLE_LAYOUT */
+ EnableControls_Impl( 0 );
+
+ // alten Text des aWordBtn's merken
+ aCalcStr += sal_Unicode('#');
+ aCalcStr += aWordBtn.GetText();
+
+ aLayoutStr = SVX_RESSTR( RID_SVXSTR_SEARCH_STYLES );
+ aStylesStr = aLayoutBtn.GetText();
+
+ // gemerkte Such-Strings von der Applikation holen
+ ListToStrArr_Impl( SID_SEARCHDLG_SEARCHSTRINGS,
+ aSearchStrings, aSearchLB );
+ ListToStrArr_Impl( SID_SEARCHDLG_REPLACESTRINGS,
+ aReplaceStrings, aReplaceLB );
+
+ pMoreBtn->SetMoreText( String( SVX_RES( STR_MORE_BTN ) ) );
+ pMoreBtn->SetLessText( String( SVX_RES( STR_LESS_BTN ) ) );
+
+ FreeResource();
+ InitControls_Impl();
+
+ // Attribut-Sets nur einmal im Ctor() besorgen
+ const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
+ const SvxSetItem* pSrchSetItem =
+ (const SvxSetItem*) rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SFX_CALLMODE_SLOT, ppArgs );
+
+ if ( pSrchSetItem )
+ InitAttrList_Impl( &pSrchSetItem->GetItemSet(), 0 );
+
+ const SvxSetItem* pReplSetItem =
+ (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SFX_CALLMODE_SLOT, ppArgs );
+
+ if ( pReplSetItem )
+ InitAttrList_Impl( 0, &pReplSetItem->GetItemSet() );
+
+ // Controller erzeugen und gleich aktualisieren
+ rBindings.EnterRegistrations();
+ pSearchController =
+ new SvxSearchController( SID_SEARCH_ITEM, rBindings, *this );
+ pOptionsController =
+ new SvxSearchController( SID_SEARCH_OPTIONS, rBindings, *this );
+ rBindings.LeaveRegistrations();
+ rBindings.GetDispatcher()->Execute( FID_SEARCH_ON, SFX_CALLMODE_SLOT, ppArgs );
+ pImpl->aSelectionTimer.Start();
+
+
+ SvtCJKOptions aCJKOptions;
+ if(!aCJKOptions.IsJapaneseFindEnabled())
+ {
+ aJapOptionsCB.Check( FALSE );
+ aJapOptionsCB.Hide();
+ aJapOptionsBtn.Hide();
+ }
+ if(!aCJKOptions.IsCJKFontEnabled())
+ {
+ aJapMatchFullHalfWidthCB.Hide();
+ }
+ //component extension - show component search buttons if the commands
+ // vnd.sun.star::SearchViaComponent1 and 2 are supported
+ const uno::Reference< frame::XFrame >xFrame = rBindings.GetActiveFrame();
+ const uno::Reference< frame::XDispatchProvider > xDispatchProv(xFrame, uno::UNO_QUERY);
+ rtl::OUString sTarget = rtl::OUString::createFromAscii("_self");
+
+ bool bSearchComponent1 = false;
+ bool bSearchComponent2 = false;
+ if(xDispatchProv.is() &&
+ (pImpl->xCommand1Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand1URL, sTarget, 0)).is())
+ {
+ bSearchComponent1 = true;
+ }
+ if(xDispatchProv.is() &&
+ (pImpl->xCommand2Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand2URL, sTarget, 0)).is())
+ {
+ bSearchComponent2 = true;
+ }
+
+ if( bSearchComponent1 || bSearchComponent2 )
+ {
+ //get the labels of the FixedLine and the buttons
+ // "/org.openoffice.Office.Common/SearchOptions/ComponentSearchGroupLabel
+ // "/org.openoffice.Office.Common/SearchOptions/ComponentSearchCommandLabel1
+ // "/org.openoffice.Office.Common/SearchOptions/ComponentSearchCommandLabel2
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMgr = getProcessServiceFactory();
+ uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(xMgr->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider"))),
+ uno::UNO_QUERY);
+ uno::Sequence< uno::Any > aArgs(1);
+ ::rtl::OUString sPath(RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/SearchOptions/"));
+ aArgs[0] <<= sPath;
+
+ uno::Reference< uno::XInterface > xIFace = xConfigurationProvider->createInstanceWithArguments(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess")),
+ aArgs);
+ uno::Reference< container::XNameAccess> xDirectAccess(xIFace, uno::UNO_QUERY);
+ if(xDirectAccess.is())
+ {
+ ::rtl::OUString sTemp;
+ ::rtl::OUString sProperty(RTL_CONSTASCII_USTRINGPARAM( "ComponentSearchGroupLabel"));
+ uno::Any aRet = xDirectAccess->getByName(sProperty);
+ aRet >>= sTemp;
+ aSearchComponentFL.SetText( sTemp );
+ aRet = xDirectAccess->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ComponentSearchCommandLabel1")));
+ aRet >>= sTemp;
+ aSearchComponent1PB.SetText( sTemp );
+ aRet = xDirectAccess->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ComponentSearchCommandLabel2")));
+ aRet >>= sTemp;
+ aSearchComponent2PB.SetText( sTemp );
+ }
+ }
+ catch(uno::Exception&){}
+
+ if(aSearchComponent1PB.GetText().Len() && bSearchComponent1 )
+ {
+ aSearchComponentFL.Show();
+ aSearchComponent1PB.Show();
+ }
+ if( aSearchComponent2PB.GetText().Len() )
+ {
+ if(!aSearchComponent1PB.IsVisible())
+ {
+ aSearchComponent2PB.SetPosPixel(aSearchComponent1PB.GetPosPixel());
+ }
+ aSearchComponentFL.Show();
+ aSearchComponent2PB.Show();
+ }
+ if( aSearchComponentFL.IsVisible() && aSearchComponent1PB.IsVisible() )
+ {
+
+ //dialog must be resized
+ Size aDlgSize(GetSizePixel());
+ sal_Int32 nOffset = aSearchCmdLine.GetPosPixel().Y() - aSearchAllBtn.GetPosPixel().Y()
+ - aButtonsFL.GetPosPixel().Y() + aSearchComponent2PB.GetPosPixel().Y();
+
+ aDlgSize.Height() += nOffset;
+ Window* aWindows[] =
+ {
+ &aOptionsFL,
+ &aSelectionBtn,
+ &aBackwardsBtn,
+ &aRegExpBtn,
+ &aSimilarityBox,
+ &aSimilarityBtn,
+ &aLayoutBtn,
+ &aNotesBtn,
+ &aJapMatchFullHalfWidthCB,
+ &aJapOptionsCB,
+ &aJapOptionsBtn,
+ &aAttributeBtn,
+ &aFormatBtn,
+ &aNoFormatBtn,
+ &aCalcFL,
+ &aCalcSearchInFT,
+ &aCalcSearchInLB,
+ &aCalcSearchDirFT,
+ &aRowsBtn,
+ &aColumnsBtn,
+ &aAllSheetsCB,
+ &aButtonsFL,
+ &aHelpBtn,
+ &aCloseBtn,
+ pMoreBtn,
+ 0
+ };
+ sal_Int32 nWindow = 0;
+ do
+ {
+ lcl_MoveDown( *aWindows[nWindow], nOffset );
+ }
+ while(aWindows[++nWindow]);
+
+ SetSizePixel(aDlgSize);
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SvxSearchDialog::Close()
+{
+ // remember strings speichern
+ if ( aSearchStrings.Count() )
+ StrArrToList_Impl( SID_SEARCHDLG_SEARCHSTRINGS, aSearchStrings );
+
+ if ( aReplaceStrings.Count() )
+ StrArrToList_Impl( SID_SEARCHDLG_REPLACESTRINGS, aReplaceStrings );
+
+ // save settings to configuration
+ SvtSearchOptions aOpt;
+ aOpt.SetWholeWordsOnly ( aWordBtn .IsChecked() );
+ aOpt.SetBackwards ( aBackwardsBtn .IsChecked() );
+ aOpt.SetUseRegularExpression ( aRegExpBtn .IsChecked() );
+ //aOpt.SetMatchCase ( aMatchCaseCB .IsChecked() );
+ aOpt.SetSearchForStyles ( aLayoutBtn .IsChecked() );
+ aOpt.SetSimilaritySearch ( aSimilarityBox .IsChecked() );
+ //aOpt.SetMatchFullHalfWidthForms ( !aJapMatchFullHalfWidthCB.IsChecked() );
+ aOpt.SetUseAsianOptions ( aJapOptionsCB .IsChecked() );
+ aOpt.SetNotes ( aNotesBtn .IsChecked() );
+
+ const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
+ rBindings.GetDispatcher()->Execute( FID_SEARCH_OFF, SFX_CALLMODE_SLOT, ppArgs );
+ rBindings.Execute( SID_SEARCH_DLG );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+INT32 SvxSearchDialog::GetTransliterationFlags() const
+{
+ if (!aMatchCaseCB.IsChecked())
+ nTransliterationFlags |= TransliterationModules_IGNORE_CASE;
+ else
+ nTransliterationFlags &= ~TransliterationModules_IGNORE_CASE;
+ if ( !aJapMatchFullHalfWidthCB.IsChecked())
+ nTransliterationFlags |= TransliterationModules_IGNORE_WIDTH;
+ else
+ nTransliterationFlags &= ~TransliterationModules_IGNORE_WIDTH;
+ return nTransliterationFlags;
+}
+
+void SvxSearchDialog::SetSaveToModule(bool b)
+{
+ pImpl->bSaveToModule = b;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::ApplyTransliterationFlags_Impl( INT32 nSettings )
+{
+ nTransliterationFlags = nSettings;
+ BOOL bVal = 0 != (nSettings & TransliterationModules_IGNORE_CASE);
+ aMatchCaseCB .Check(!bVal );
+ bVal = 0 != (nSettings & TransliterationModules_IGNORE_WIDTH);
+ aJapMatchFullHalfWidthCB.Check( !bVal );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::Activate()
+{
+ // apply possible transliteration changes of the SvxSearchItem member
+ DBG_ASSERT( pSearchItem, "SearchItem missing" );
+ if (pSearchItem)
+ {
+ aMatchCaseCB .Check( pSearchItem->GetExact() );
+ aJapMatchFullHalfWidthCB.Check( !pSearchItem->IsMatchFullHalfWidthForms() );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::InitControls_Impl()
+{
+ // CaseSensitives AutoComplete
+ aSearchLB.EnableAutocomplete( TRUE, TRUE );
+ aSearchLB.Show();
+ aReplaceLB.EnableAutocomplete( TRUE, TRUE );
+ aReplaceLB.Show();
+
+ aFormatBtn.Disable();
+ aAttributeBtn.Disable();
+
+ aSearchLB.SetModifyHdl( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
+ aReplaceLB.SetModifyHdl( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
+
+ Link aLink = LINK( this, SvxSearchDialog, FocusHdl_Impl );
+ aSearchLB.SetGetFocusHdl( aLink );
+ pImpl->aSearchFormats.SetGetFocusHdl( aLink );
+
+ aReplaceLB.SetGetFocusHdl( aLink );
+ pImpl->aReplaceFormats.SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, SvxSearchDialog, LoseFocusHdl_Impl );
+ aSearchLB.SetLoseFocusHdl( aLink );
+ aReplaceLB.SetLoseFocusHdl( aLink );
+
+ aSearchTmplLB.SetLoseFocusHdl( aLink );
+ aReplaceTmplLB.SetLoseFocusHdl( aLink );
+
+ aLink = LINK( this, SvxSearchDialog, CommandHdl_Impl );
+ aSearchBtn.SetClickHdl( aLink );
+ aSearchAllBtn.SetClickHdl( aLink );
+ aReplaceBtn.SetClickHdl( aLink );
+ aReplaceAllBtn.SetClickHdl( aLink );
+ aCloseBtn.SetClickHdl( aLink );
+ aSimilarityBtn.SetClickHdl( aLink );
+ aJapOptionsBtn.SetClickHdl( aLink );
+ aSearchComponent1PB.SetClickHdl( aLink );
+ aSearchComponent2PB.SetClickHdl( aLink );
+
+ aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
+ aWordBtn.SetClickHdl( aLink );
+ aSelectionBtn.SetClickHdl( aLink );
+ aMatchCaseCB.SetClickHdl( aLink );
+ aRegExpBtn.SetClickHdl( aLink );
+ aBackwardsBtn.SetClickHdl( aLink );
+ aNotesBtn.SetClickHdl( aLink );
+ aSimilarityBox.SetClickHdl( aLink );
+ aJapOptionsCB.SetClickHdl( aLink );
+ aJapMatchFullHalfWidthCB.SetClickHdl( aLink );
+
+ aLayoutBtn.SetClickHdl( LINK( this, SvxSearchDialog, TemplateHdl_Impl ) );
+ aFormatBtn.SetClickHdl( LINK( this, SvxSearchDialog, FormatHdl_Impl ) );
+ aNoFormatBtn.SetClickHdl(
+ LINK( this, SvxSearchDialog, NoFormatHdl_Impl ) );
+ aAttributeBtn.SetClickHdl(
+ LINK( this, SvxSearchDialog, AttributeHdl_Impl ) );
+
+ // check if buttontext is to wide
+ long nTxtW = Max( pMoreBtn->GetCtrlTextWidth( pMoreBtn->GetMoreText() ),
+ pMoreBtn->GetCtrlTextWidth( pMoreBtn->GetLessText() ) );
+ nTxtW += ( pMoreBtn->GetTextHeight() * 2 ); // add image size + offset
+ long nBtnW = pMoreBtn->GetSizePixel().Width();
+ if ( nTxtW > nBtnW )
+ {
+ // broaden the button
+ const long nMinDelta = 10;
+ long nDelta = Max( nTxtW - nBtnW, nMinDelta );
+ Size aNewSize = pMoreBtn->GetSizePixel();
+ aNewSize.Width() += nDelta;
+ pMoreBtn->SetSizePixel( aNewSize );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::CalculateDelta_Impl()
+{
+ DBG_ASSERT( pSearchItem, "no search item" );
+
+ bool bDrawApp = false;
+ bool bCalcApp = false;
+ bool bWriterApp = false;
+ bool bImpressApp = false;
+ const uno::Reference< frame::XFrame > xFrame = rBindings.GetActiveFrame();
+ uno::Reference< frame::XModuleManager > xModuleManager(
+ ::comphelper::getProcessServiceFactory()->createInstance(
+ DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), uno::UNO_QUERY );
+ if ( xModuleManager.is() )
+ {
+ try
+ {
+ ::rtl::OUString aModuleIdentifier = xModuleManager->identify( xFrame );
+ bCalcApp = aModuleIdentifier.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" );
+ bDrawApp = aModuleIdentifier.equalsAscii( "com.sun.star.drawing.DrawingDocument" );
+ bImpressApp = aModuleIdentifier.equalsAscii( "com.sun.star.presentation.PresentationDocument" );
+ bWriterApp = aModuleIdentifier.equalsAscii( "com.sun.star.text.TextDocument" );
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+
+ if ( pImpl->bDeltaCalculated )
+ return;
+ else
+ pImpl->bDeltaCalculated = TRUE;
+
+ ULONG nDelta = 187, nOffset = 0;
+ SvtCJKOptions aCJKOptions;
+
+ pMoreBtn->AddWindow( &aOptionsFL );
+ if ( !bDrawApp )
+ pMoreBtn->AddWindow( &aLayoutBtn );
+ if ( bWriterApp )
+ pMoreBtn->AddWindow( &aNotesBtn );
+ else
+ {
+ aNotesBtn.Hide();
+ nOffset = !bDrawApp ? 13 : 0;
+ }
+ pMoreBtn->AddWindow( &aBackwardsBtn );
+ if ( !bDrawApp )
+ pMoreBtn->AddWindow( &aRegExpBtn );
+ pMoreBtn->AddWindow( &aSimilarityBox );
+ pMoreBtn->AddWindow( &aSimilarityBtn );
+ pMoreBtn->AddWindow( &aSelectionBtn );
+
+ if ( aCJKOptions.IsCJKFontEnabled() )
+ pMoreBtn->AddWindow( &aJapMatchFullHalfWidthCB );
+ else
+ nOffset += 13;
+ if ( aCJKOptions.IsJapaneseFindEnabled() )
+ {
+ pMoreBtn->AddWindow( &aJapOptionsCB );
+ pMoreBtn->AddWindow( &aJapOptionsBtn );
+ }
+ else
+ nOffset += 17;
+
+ if ( bWriter )
+ {
+ pMoreBtn->AddWindow( &aAttributeBtn );
+ pMoreBtn->AddWindow( &aFormatBtn );
+ pMoreBtn->AddWindow( &aNoFormatBtn );
+ }
+
+ if (bDrawApp || bImpressApp)
+ {
+ // "Find All" button is hidden--align "Find" vertically to the
+ // search listbox
+ Point aNewPt(aSearchBtn.GetPosPixel());
+ const Size aBtnSz(aSearchBtn.GetSizePixel());
+ const Size aLBSz(aSearchLB.GetSizePixel());
+ const int nOff((aLBSz.Height() - aBtnSz.Height()) / 2);
+ aNewPt.Y() = aSearchLB.GetPosPixel().Y() + nOff;
+ aSearchBtn.SetPosPixel(aNewPt);
+ }
+
+ if ( bDrawApp )
+ {
+ // Draw App: "Regular expressions" and "Search for Styles" check boxes are hidden
+ // so align the other buttons
+ const long nAppFontHeight = 13; // checkbox height + space between in APPFONT
+ long nH = LogicToPixel( Size( 0, nAppFontHeight ), MAP_APPFONT ).Height();
+
+ Point aNewPos = aSimilarityBox.GetPosPixel();
+ aNewPos.Y() -= nH;
+ aSimilarityBox.SetPosPixel( aNewPos );
+ aNewPos = aSimilarityBtn.GetPosPixel();
+ aNewPos.Y() -= nH;
+ aSimilarityBtn.SetPosPixel( aNewPos );
+ nH *= 3;
+ nOffset += ( 3 * nAppFontHeight );
+ if ( aCJKOptions.IsCJKFontEnabled() )
+ {
+ aNewPos = aJapMatchFullHalfWidthCB.GetPosPixel();
+ aNewPos.Y() -= nH;
+ aJapMatchFullHalfWidthCB.SetPosPixel( aNewPos );
+ }
+ if ( aCJKOptions.IsJapaneseFindEnabled() )
+ {
+ aNewPos = aJapOptionsCB.GetPosPixel();
+ aNewPos.Y() -= nH;
+ aJapOptionsCB.SetPosPixel( aNewPos );
+ aNewPos = aJapOptionsBtn.GetPosPixel();
+ aNewPos.Y() -= nH;
+ aJapOptionsBtn.SetPosPixel( aNewPos );
+ }
+ }
+
+ if ( bCalcApp || bImpressApp )
+ {
+ Window* pWins[] =
+ {
+ &aCalcFL, &aCalcSearchInFT, &aCalcSearchInLB, &aCalcSearchDirFT,
+ &aRowsBtn, &aColumnsBtn, &aAllSheetsCB, &aJapMatchFullHalfWidthCB,
+ &aJapOptionsCB, &aJapOptionsBtn
+ };
+ Window** pCurrent = pWins;
+ sal_uInt32 i = 0;
+ const sal_uInt32 nCalcCtrlCount = 7;
+ if ( nOffset > 0 )
+ {
+ long nH = LogicToPixel( Size( 0, nOffset ), MAP_APPFONT ).Height();
+ for ( i = 0; i < SAL_N_ELEMENTS( pWins ); ++i, ++pCurrent )
+ {
+ if ( ( bCalcApp && i < nCalcCtrlCount )
+ || ( i == nCalcCtrlCount && aCJKOptions.IsCJKFontEnabled() )
+ || ( i > nCalcCtrlCount && aCJKOptions.IsJapaneseFindEnabled() ) )
+ {
+ Point aNewPos = (*pCurrent)->GetPosPixel();
+ aNewPos.Y() -= nH;
+ (*pCurrent)->SetPosPixel( aNewPos );
+ }
+ }
+ }
+
+ if ( bCalcApp)
+ {
+ pCurrent = pWins;
+ for ( i = 0; i < nCalcCtrlCount; ++i, ++pCurrent )
+ pMoreBtn->AddWindow( *pCurrent );
+ }
+ else
+ nOffset += 64;
+ }
+ else
+ nOffset += 64;
+
+ pMoreBtn->SetDelta( nDelta - nOffset );
+ pMoreBtn->Show();
+ pMoreBtn->Enable();
+}
+
+#if ENABLE_LAYOUT
+#undef Window
+#define Window ::Window
+#endif /* ENABLE_LAYOUT */
+
+// -----------------------------------------------------------------------
+
+namespace {
+
+class ToggleSaveToModule
+{
+public:
+ ToggleSaveToModule(SvxSearchDialog& rDialog, bool bValue) :
+ mrDialog(rDialog), mbValue(bValue)
+ {
+ mrDialog.SetSaveToModule(mbValue);
+ }
+
+ ~ToggleSaveToModule()
+ {
+ mrDialog.SetSaveToModule(!mbValue);
+ }
+private:
+ SvxSearchDialog& mrDialog;
+ bool mbValue;
+};
+
+}
+
+void SvxSearchDialog::Init_Impl( int bSearchPattern )
+{
+ DBG_ASSERT( pSearchItem, "SearchItem == 0" );
+
+ // We don't want to save any intermediate state to the module while the
+ // dialog is being initialized.
+ ToggleSaveToModule aNoModuleSave(*this, false);
+
+ bWriter = ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_WRITER );
+
+ pImpl->bMultiLineEdit = FALSE;
+
+ if ( !pImpl->bMultiLineEdit )
+ {
+ pImpl->aSearchFormats.Hide();
+ aSearchAttrText.Show();
+ pImpl->aReplaceFormats.Hide();
+ aReplaceAttrText.Show();
+ }
+ else
+ {
+ String aText = aSearchAttrText.GetText();
+ aSearchAttrText.Hide();
+
+ if ( aText.Len() )
+ pImpl->aSearchFormats.SetText( aText );
+ pImpl->aSearchFormats.Show();
+ aText = aReplaceAttrText.GetText();
+ aReplaceAttrText.Hide();
+
+ if ( aText.Len() )
+ pImpl->aReplaceFormats.SetText( aText );
+ pImpl->aReplaceFormats.Show();
+ }
+
+ if ( ( nModifyFlag & MODIFY_WORD ) == 0 )
+ aWordBtn.Check( pSearchItem->GetWordOnly() );
+ if ( ( nModifyFlag & MODIFY_EXACT ) == 0 )
+ aMatchCaseCB.Check( pSearchItem->GetExact() );
+ if ( ( nModifyFlag & MODIFY_BACKWARDS ) == 0 )
+ aBackwardsBtn.Check( pSearchItem->GetBackward() );
+ if ( ( nModifyFlag & MODIFY_NOTES ) == 0 )
+ aNotesBtn.Check( pSearchItem->GetNotes() );
+ if ( ( nModifyFlag & MODIFY_SELECTION ) == 0 )
+ aSelectionBtn.Check( pSearchItem->GetSelection() );
+ if ( ( nModifyFlag & MODIFY_REGEXP ) == 0 )
+ aRegExpBtn.Check( pSearchItem->GetRegExp() );
+ if ( ( nModifyFlag & MODIFY_LAYOUT ) == 0 )
+ aLayoutBtn.Check( pSearchItem->GetPattern() );
+ if (aNotesBtn.IsChecked())
+ aLayoutBtn.Disable();
+ aSimilarityBox.Check( pSearchItem->IsLevenshtein() );
+ if( aJapOptionsCB.IsVisible() )
+ aJapOptionsCB.Check( pSearchItem->IsUseAsianOptions() );
+ ApplyTransliterationFlags_Impl( pSearchItem->GetTransliterationFlags() );
+
+ CalculateDelta_Impl();
+
+ bool bDraw = FALSE;
+ if ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC )
+ {
+ Link aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
+ aCalcSearchInLB.SetSelectHdl( aLink );
+ aRowsBtn.SetClickHdl( aLink );
+ aColumnsBtn.SetClickHdl( aLink );
+ aAllSheetsCB.SetClickHdl( aLink );
+
+ switch ( pSearchItem->GetCellType() )
+ {
+ case SVX_SEARCHIN_FORMULA:
+ if ( ( nModifyFlag & MODIFY_FORMULAS ) == 0 )
+ aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_FORMULA );
+ break;
+
+ case SVX_SEARCHIN_VALUE:
+ if ( ( nModifyFlag & MODIFY_VALUES ) == 0 )
+ aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_VALUE );
+ break;
+
+ case SVX_SEARCHIN_NOTE:
+ if ( ( nModifyFlag & MODIFY_CALC_NOTES ) == 0 )
+ aCalcSearchInLB.SelectEntryPos( SVX_SEARCHIN_NOTE );
+ break;
+ }
+ aWordBtn.SetText( aCalcStr.GetToken( 0, '#' ) );
+
+ if ( pSearchItem->GetRowDirection() &&
+ ( nModifyFlag & MODIFY_ROWS ) == 0 )
+ aRowsBtn.Check();
+ else if ( !pSearchItem->GetRowDirection() &&
+ ( nModifyFlag & MODIFY_COLUMNS ) == 0 )
+ aColumnsBtn.Check();
+
+ if ( ( nModifyFlag & MODIFY_ALLTABLES ) == 0 )
+ aAllSheetsCB.Check( pSearchItem->IsAllTables() );
+
+ // nur im Writer Suche nach Formatierung
+ aFormatBtn.Hide();
+ aNoFormatBtn.Hide();
+ aAttributeBtn.Hide();
+ }
+ else
+ {
+ aWordBtn.SetText( aCalcStr.GetToken( 1, '#' ) );
+
+ if ( pSearchItem->GetAppFlag() == SVX_SEARCHAPP_DRAW )
+ {
+ aSearchAllBtn.Hide();
+
+ aRegExpBtn.Hide();
+ aLayoutBtn.Hide();
+
+ // nur im Writer Suche nach Formatierung
+ aFormatBtn.Hide();
+ aNoFormatBtn.Hide();
+ aAttributeBtn.Hide();
+ bDraw = TRUE;
+ }
+ else
+ {
+ if ( !pSearchList )
+ {
+ // Attribut-Sets besorgen, wenn noch nicht geschehen
+ const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
+ const SvxSetItem* pSrchSetItem =
+ (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SFX_CALLMODE_SLOT, ppArgs );
+
+ if ( pSrchSetItem )
+ InitAttrList_Impl( &pSrchSetItem->GetItemSet(), 0 );
+
+ const SvxSetItem* pReplSetItem =
+ (const SvxSetItem*)rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SFX_CALLMODE_SLOT, ppArgs );
+
+ if ( pReplSetItem )
+ InitAttrList_Impl( 0, &pReplSetItem->GetItemSet() );
+ }
+/*
+ aFormatBtn.Show();
+ aNoFormatBtn.Show();
+ aAttributeBtn.Show();
+*/
+ }
+// pMoreBtn->SetState( FALSE );
+// pMoreBtn->Hide();
+ }
+
+ if ( 0 && !bDraw ) //!!!!!
+ {
+ aRegExpBtn.Show();
+ aLayoutBtn.Show();
+ }
+
+ // "Ahnlichkeitssuche?
+ if ( ( nModifyFlag & MODIFY_SIMILARITY ) == 0 )
+ aSimilarityBox.Check( pSearchItem->IsLevenshtein() );
+ bSet = TRUE;
+
+ FlagHdl_Impl( &aSimilarityBox );
+ FlagHdl_Impl( &aJapOptionsCB );
+
+ bool bDisableSearch = FALSE;
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+
+ if ( pViewShell )
+ {
+ BOOL bText = !bSearchPattern;
+
+ if ( pViewShell->HasSelection( bText ) )
+ EnableControl_Impl( &aSelectionBtn );
+ else
+ {
+ aSelectionBtn.Check( FALSE );
+ aSelectionBtn.Disable();
+ }
+ }
+
+ // Patternsuche und es wurden keine AttrSets "ubergeben
+ if ( bSearchPattern )
+ {
+ SfxObjectShell* pShell = SfxObjectShell::Current();
+
+ if ( pShell && pShell->GetStyleSheetPool() )
+ {
+ // Vorlagen beschaffen
+ aSearchTmplLB .Clear();
+ aReplaceTmplLB.Clear();
+ SfxStyleSheetBasePool* pStylePool = pShell->GetStyleSheetPool();
+ pStylePool->SetSearchMask( pSearchItem->GetFamily(),
+ SFXSTYLEBIT_ALL );
+ SfxStyleSheetBase* pBase = pStylePool->First();
+
+ while ( pBase )
+ {
+ if ( pBase->IsUsed() )
+ aSearchTmplLB.InsertEntry( pBase->GetName() );
+ aReplaceTmplLB.InsertEntry( pBase->GetName() );
+ pBase = pStylePool->Next();
+ }
+ aSearchTmplLB.SelectEntry( pSearchItem->GetSearchString() );
+ aReplaceTmplLB.SelectEntry( pSearchItem->GetReplaceString() );
+
+ }
+ aSearchTmplLB.Show();
+
+ if ( bConstruct )
+ // nur nach dem Erzeugen den Fokus grappen
+ aSearchTmplLB.GrabFocus();
+ aReplaceTmplLB.Show();
+ aSearchLB.Hide();
+ aReplaceLB.Hide();
+
+ aWordBtn.Disable();
+ aRegExpBtn.Disable();
+ aMatchCaseCB.Disable();
+
+ bDisableSearch = !aSearchTmplLB.GetEntryCount();
+ }
+ else
+ {
+ bool bSetSearch = ( ( nModifyFlag & MODIFY_SEARCH ) == 0 );
+ bool bSetReplace = ( ( nModifyFlag & MODIFY_REPLACE ) == 0 );
+
+ if ( pSearchItem->GetSearchString().Len() && bSetSearch )
+ aSearchLB.SetText( pSearchItem->GetSearchString() );
+ else if ( aSearchStrings.Count() )
+ {
+ bool bAttributes =
+ ( ( pSearchList && pSearchList->Count() ) ||
+ ( pReplaceList && pReplaceList->Count() ) );
+
+ if ( bSetSearch && !bAttributes )
+ aSearchLB.SetText( *aSearchStrings[ 0 ] );
+
+ String aReplaceTxt = pSearchItem->GetReplaceString();
+
+ if ( aReplaceStrings.Count() )
+ aReplaceTxt = *aReplaceStrings[ 0 ];
+
+ if ( bSetReplace && !bAttributes )
+ aReplaceLB.SetText( aReplaceTxt );
+ }
+ aSearchLB.Show();
+
+ if ( bConstruct )
+ // nur nach dem Erzeugen den Fokus grappen
+ aSearchLB.GrabFocus();
+ aReplaceLB.Show();
+ aSearchTmplLB.Hide();
+ aReplaceTmplLB.Hide();
+
+ EnableControl_Impl( &aRegExpBtn );
+ EnableControl_Impl( &aMatchCaseCB );
+
+ if ( aRegExpBtn.IsChecked() )
+ aWordBtn.Disable();
+ else
+ EnableControl_Impl( &aWordBtn );
+
+ String aSrchAttrTxt;
+
+ if ( pImpl->bMultiLineEdit )
+ aSrchAttrTxt = pImpl->aSearchFormats.GetText();
+ else
+ aSrchAttrTxt = aSearchAttrText.GetText();
+
+ bDisableSearch = !aSearchLB.GetText().Len() && !aSrchAttrTxt.Len();
+ }
+ FocusHdl_Impl( &aSearchLB );
+
+ if ( bDisableSearch )
+ {
+ aSearchBtn.Disable();
+ aSearchAllBtn.Disable();
+ aReplaceBtn.Disable();
+ aReplaceAllBtn.Disable();
+ aSearchComponentFL.Enable(sal_False);
+ aSearchComponent1PB.Enable(sal_False);
+ aSearchComponent2PB.Enable(sal_False);
+ }
+ else
+ {
+ EnableControl_Impl( &aSearchBtn );
+ EnableControl_Impl( &aReplaceBtn );
+ if (!bWriter || (bWriter && !aNotesBtn.IsChecked()))
+ {
+ EnableControl_Impl( &aSearchAllBtn );
+ EnableControl_Impl( &aReplaceAllBtn );
+ }
+ if (bWriter && pSearchItem->GetNotes())
+ {
+ aSearchAllBtn.Disable();
+ aReplaceAllBtn.Disable();
+ }
+ }
+
+ if ( ( !pImpl->bMultiLineEdit && aSearchAttrText.GetText().Len() ) ||
+ ( pImpl->bMultiLineEdit && pImpl->aSearchFormats.GetText().Len() ) )
+ EnableControl_Impl( &aNoFormatBtn );
+ else
+ aNoFormatBtn.Disable();
+
+ if ( !pSearchList )
+ {
+ aAttributeBtn.Disable();
+ aFormatBtn.Disable();
+ }
+
+ if ( aLayoutBtn.IsChecked() )
+ {
+ pImpl->bSaveToModule = FALSE;
+ TemplateHdl_Impl( &aLayoutBtn );
+ pImpl->bSaveToModule = TRUE;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::InitAttrList_Impl( const SfxItemSet* pSSet,
+ const SfxItemSet* pRSet )
+{
+ if ( !pSSet && !pRSet )
+ return;
+
+ if ( !pImpl->pRanges && pSSet )
+ {
+ sal_sSize nCnt = 0;
+ const USHORT* pPtr = pSSet->GetRanges();
+ const USHORT* pTmp = pPtr;
+
+ while( *pPtr )
+ {
+ nCnt += ( *(pPtr+1) - *pPtr ) + 1;
+ pPtr += 2;
+ }
+ nCnt = pPtr - pTmp + 1;
+ pImpl->pRanges = new USHORT[nCnt];
+ memcpy( pImpl->pRanges, pTmp, sizeof(USHORT) * nCnt );
+ }
+
+ // sorge daf"ur, das die Texte der Attribute richtig stehen
+ String aDesc;
+
+ if ( pSSet )
+ {
+ delete pSearchList;
+ pSearchList = new SearchAttrItemList;
+
+ if ( pSSet->Count() )
+ {
+ pSearchList->Put( *pSSet );
+
+ if ( !pImpl->bMultiLineEdit )
+ aSearchAttrText.SetText( BuildAttrText_Impl( aDesc, TRUE ) );
+ else
+ pImpl->aSearchFormats.SetText( BuildAttrText_Impl( aDesc, TRUE ) );
+
+ if ( aDesc.Len() )
+ bFormat |= TRUE;
+ }
+ }
+
+ if ( pRSet )
+ {
+ delete pReplaceList;
+ pReplaceList = new SearchAttrItemList;
+
+ if ( pRSet->Count() )
+ {
+ pReplaceList->Put( *pRSet );
+
+ if ( !pImpl->bMultiLineEdit )
+ aReplaceAttrText.SetText( BuildAttrText_Impl( aDesc, FALSE ) );
+ else
+ pImpl->aReplaceFormats.SetText( BuildAttrText_Impl( aDesc, FALSE ) );
+
+ if ( aDesc.Len() )
+ bFormat |= TRUE;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxSearchDialog, FlagHdl_Impl, Control *, pCtrl )
+{
+ if ( pCtrl && !bSet )
+ SetModifyFlag_Impl( pCtrl );
+ else
+ bSet = FALSE;
+
+ if ( pCtrl == &aSimilarityBox )
+ {
+ BOOL bIsChecked = aSimilarityBox.IsChecked();
+
+ if ( bIsChecked )
+ {
+ aSimilarityBtn.Enable();
+ aRegExpBtn.Check( FALSE );
+ aRegExpBtn.Disable();
+ EnableControl_Impl( &aWordBtn );
+
+ if ( aLayoutBtn.IsChecked() )
+ {
+ EnableControl_Impl( &aMatchCaseCB );
+ aLayoutBtn.Check( FALSE );
+ }
+ aRegExpBtn.Disable();
+ aLayoutBtn.Disable();
+ aFormatBtn.Disable();
+ aNoFormatBtn.Disable();
+ aAttributeBtn.Disable();
+ }
+ else
+ {
+ EnableControl_Impl( &aRegExpBtn );
+ if (!aNotesBtn.IsChecked())
+ EnableControl_Impl( &aLayoutBtn );
+ EnableControl_Impl( &aFormatBtn );
+ EnableControl_Impl( &aAttributeBtn );
+ aSimilarityBtn.Disable();
+ }
+ pSearchItem->SetLevenshtein( bIsChecked );
+ }
+ else
+ if ( pCtrl == &aNotesBtn)
+ {
+ if (aNotesBtn.IsChecked())
+ {
+ aLayoutBtn.Disable();
+ aSearchAllBtn.Disable();
+ aReplaceAllBtn.Disable();
+ }
+ else
+ {
+ EnableControl_Impl( &aLayoutBtn );
+ ModifyHdl_Impl( &aSearchLB );
+ }
+ }
+ else
+ {
+ if ( aLayoutBtn.IsChecked() && !bFormat )
+ {
+ aWordBtn.Check( FALSE );
+ aWordBtn.Disable();
+ aRegExpBtn.Check( FALSE );
+ aRegExpBtn.Disable();
+ aMatchCaseCB.Check( FALSE );
+ aMatchCaseCB.Disable();
+ aNotesBtn.Disable();
+
+ if ( aSearchTmplLB.GetEntryCount() )
+ {
+ EnableControl_Impl( &aSearchBtn );
+ EnableControl_Impl( &aSearchAllBtn );
+ EnableControl_Impl( &aReplaceBtn );
+ EnableControl_Impl( &aReplaceAllBtn );
+ }
+ }
+ else
+ {
+ EnableControl_Impl( &aRegExpBtn );
+ EnableControl_Impl( &aMatchCaseCB );
+ EnableControl_Impl( &aNotesBtn );
+
+ if ( aRegExpBtn.IsChecked() )
+ {
+ aWordBtn.Check( FALSE );
+ aWordBtn.Disable();
+ aSimilarityBox.Disable();
+ aSimilarityBtn.Disable();
+ }
+ else
+ {
+ EnableControl_Impl( &aWordBtn );
+ EnableControl_Impl( &aSimilarityBox );
+ }
+
+ // Such-String vorhanden? dann Buttons enablen
+ bSet = TRUE;
+ ModifyHdl_Impl( &aSearchLB );
+ }
+ }
+
+ if ( &aAllSheetsCB == pCtrl )
+ {
+ if ( aAllSheetsCB.IsChecked() )
+ aSearchAllBtn.Disable();
+ else
+ {
+ bSet = TRUE;
+ ModifyHdl_Impl( &aSearchLB );
+ }
+ }
+
+ if ( &aJapOptionsCB == pCtrl )
+ {
+ BOOL bEnableJapOpt = aJapOptionsCB.IsChecked();
+ aMatchCaseCB .Enable(!bEnableJapOpt );
+ aJapMatchFullHalfWidthCB.Enable(!bEnableJapOpt );
+ aJapOptionsBtn .Enable( bEnableJapOpt );
+ }
+
+ if ( pImpl->bSaveToModule )
+ SaveToModule_Impl();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxSearchDialog, CommandHdl_Impl, Button *, pBtn )
+{
+ bool bInclusive = ( aLayoutBtn.GetText() == aLayoutStr );
+
+ if ( ( pBtn == &aSearchBtn ) ||
+ ( pBtn == &aSearchAllBtn ) ||
+ ( pBtn == &aReplaceBtn ) ||
+ ( pBtn == &aReplaceAllBtn ) )
+ {
+ if ( aLayoutBtn.IsChecked() && !bInclusive )
+ {
+ pSearchItem->SetSearchString ( aSearchTmplLB.GetSelectEntry() );
+ pSearchItem->SetReplaceString( aReplaceTmplLB.GetSelectEntry() );
+ }
+ else
+ {
+ pSearchItem->SetSearchString ( aSearchLB.GetText() );
+ pSearchItem->SetReplaceString( aReplaceLB.GetText() );
+
+ if ( pBtn == &aReplaceBtn )
+ Remember_Impl( aReplaceLB.GetText(), FALSE );
+ else
+ {
+ Remember_Impl( aSearchLB.GetText(), TRUE );
+
+ if ( pBtn == &aReplaceAllBtn )
+ Remember_Impl( aReplaceLB.GetText(), FALSE );
+ }
+ }
+
+ pSearchItem->SetRegExp( FALSE );
+ pSearchItem->SetLevenshtein( FALSE );
+ if (GetCheckBoxValue( aRegExpBtn ))
+ pSearchItem->SetRegExp( TRUE );
+ else if (GetCheckBoxValue( aSimilarityBox ))
+ pSearchItem->SetLevenshtein( TRUE );
+
+ pSearchItem->SetWordOnly( GetCheckBoxValue( aWordBtn ) );
+ pSearchItem->SetBackward( GetCheckBoxValue( aBackwardsBtn ) );
+ pSearchItem->SetNotes( GetCheckBoxValue( aNotesBtn ) );
+ pSearchItem->SetPattern( GetCheckBoxValue( aLayoutBtn ) );
+ pSearchItem->SetSelection( GetCheckBoxValue( aSelectionBtn ) );
+
+ pSearchItem->SetUseAsianOptions( GetCheckBoxValue( aJapOptionsCB ) );
+ INT32 nFlags = GetTransliterationFlags();
+ if( !pSearchItem->IsUseAsianOptions())
+ nFlags &= (TransliterationModules_IGNORE_CASE |
+ TransliterationModules_IGNORE_WIDTH );
+ pSearchItem->SetTransliterationFlags( nFlags );
+
+ if ( !bWriter )
+ {
+ if ( aCalcSearchInLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
+ pSearchItem->SetCellType( aCalcSearchInLB.GetSelectEntryPos() );
+
+ pSearchItem->SetRowDirection( aRowsBtn.IsChecked() );
+ pSearchItem->SetAllTables( aAllSheetsCB.IsChecked() );
+ }
+
+ if ( pBtn == &aSearchBtn )
+ pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
+ else if ( pBtn == &aSearchAllBtn )
+ pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
+ else if ( pBtn == &aReplaceBtn )
+ pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE );
+ else if ( pBtn == &aReplaceAllBtn )
+ pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
+
+ // wenn nach Vorlagen gesucht wird, dann Format-Listen l"oschen
+ if ( !bFormat && pSearchItem->GetPattern() )
+ {
+ if ( pSearchList )
+ pSearchList->Clear();
+
+ if ( pReplaceList )
+ pReplaceList->Clear();
+ }
+ nModifyFlag = 0;
+ const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
+ rBindings.ExecuteSynchron( FID_SEARCH_NOW, ppArgs, 0L );
+ }
+ else if ( pBtn == &aCloseBtn )
+ {
+ if ( !aLayoutBtn.IsChecked() || bInclusive )
+ {
+ String aStr( aSearchLB.GetText() );
+
+ if ( aStr.Len() )
+ Remember_Impl( aStr, TRUE );
+ aStr = aReplaceLB.GetText();
+
+ if ( aStr.Len() )
+ Remember_Impl( aStr, FALSE );
+ }
+ SaveToModule_Impl();
+ Close();
+ }
+ else if ( pBtn == &aSimilarityBtn )
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractSvxSearchSimilarityDialog* pDlg = pFact->CreateSvxSearchSimilarityDialog( LAYOUT_THIS_WINDOW (this),
+ pSearchItem->IsLEVRelaxed(),
+ pSearchItem->GetLEVOther(),
+ pSearchItem->GetLEVShorter(),
+ pSearchItem->GetLEVLonger() );
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ if ( pDlg && pDlg->Execute() == RET_OK )
+ {
+ pSearchItem->SetLEVRelaxed( pDlg->IsRelaxed() );
+ pSearchItem->SetLEVOther( pDlg->GetOther() );
+ pSearchItem->SetLEVShorter( pDlg->GetShorter() );
+ pSearchItem->SetLEVLonger( pDlg->GetLonger() );
+ SaveToModule_Impl();
+ }
+ delete pDlg;
+ }
+ }
+ else if ( pBtn == &aJapOptionsBtn )
+ {
+ SfxItemSet aSet( SFX_APP()->GetPool() );
+ pSearchItem->SetTransliterationFlags( GetTransliterationFlags() );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractSvxJSearchOptionsDialog* aDlg = pFact->CreateSvxJSearchOptionsDialog( LAYOUT_THIS_WINDOW (this), aSet,
+ pSearchItem->GetTransliterationFlags() );
+ DBG_ASSERT(aDlg, "Dialogdiet fail!");
+ int nRet = aDlg->Execute();
+ if (RET_OK == nRet) //! true only if FillItemSet of SvxJSearchOptionsPage returns true
+ {
+ INT32 nFlags = aDlg->GetTransliterationFlags();
+ pSearchItem->SetTransliterationFlags( nFlags );
+ ApplyTransliterationFlags_Impl( nFlags );
+ }
+ delete aDlg;
+ }
+ }
+ else if(pBtn == &aSearchComponent1PB || pBtn == &aSearchComponent2PB )
+ {
+ uno::Sequence < beans::PropertyValue > aArgs(2);
+ beans::PropertyValue* pArgs = aArgs.getArray();
+ pArgs[0].Name = ::rtl::OUString::createFromAscii("SearchString");
+ pArgs[0].Value <<= ::rtl::OUString(aSearchLB.GetText());
+ pArgs[1].Name = ::rtl::OUString::createFromAscii("ParentWindow");
+ pArgs[1].Value <<= VCLUnoHelper::GetInterface( LAYOUT_THIS_WINDOW (this) );
+ if(pBtn == &aSearchComponent1PB)
+ {
+ if ( pImpl->xCommand1Dispatch.is() )
+ pImpl->xCommand1Dispatch->dispatch(pImpl->aCommand1URL, aArgs);
+ }
+ else
+ {
+ if ( pImpl->xCommand2Dispatch.is() )
+ pImpl->xCommand2Dispatch->dispatch(pImpl->aCommand2URL, aArgs);
+ }
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxSearchDialog, ModifyHdl_Impl, ComboBox *, pEd )
+{
+ if ( !bSet )
+ SetModifyFlag_Impl( pEd );
+ else
+ bSet = FALSE;
+
+ // Calc allows searching for empty cells.
+ bool bAllowEmptySearch = (pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC);
+
+ if ( pEd == &aSearchLB || pEd == &aReplaceLB )
+ {
+ xub_StrLen nSrchTxtLen = aSearchLB.GetText().Len();
+ xub_StrLen nReplTxtLen = 0;
+ if (bAllowEmptySearch)
+ nReplTxtLen = aReplaceLB.GetText().Len();
+ xub_StrLen nAttrTxtLen = 0;
+
+ if ( !pImpl->bMultiLineEdit )
+ nAttrTxtLen = aSearchAttrText.GetText().Len();
+ else
+ nAttrTxtLen = pImpl->aSearchFormats.GetText().Len();
+
+ if (nSrchTxtLen || nReplTxtLen || nAttrTxtLen)
+ {
+ EnableControl_Impl( &aSearchBtn );
+ EnableControl_Impl( &aReplaceBtn );
+ if (!bWriter || (bWriter && !aNotesBtn.IsChecked()))
+ {
+ EnableControl_Impl( &aSearchAllBtn );
+ EnableControl_Impl( &aReplaceAllBtn );
+ }
+ }
+ else
+ {
+ aSearchComponentFL.Enable(sal_False);
+ aSearchComponent1PB.Enable(sal_False);
+ aSearchComponent2PB.Enable(sal_False);
+ aSearchBtn.Disable();
+ aSearchAllBtn.Disable();
+ aReplaceBtn.Disable();
+ aReplaceAllBtn.Disable();
+ }
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxSearchDialog, TemplateHdl_Impl, Button *, EMPTYARG )
+{
+ if ( pImpl->bSaveToModule )
+ SaveToModule_Impl();
+
+ if ( bFormat )
+ return 0;
+ String sDesc;
+
+ if ( aLayoutBtn.IsChecked() )
+ {
+ if ( !pFamilyController )
+ {
+ USHORT nId = 0;
+
+ // Vorlagen-Controller enablen
+ switch ( pSearchItem->GetFamily() )
+ {
+ case SFX_STYLE_FAMILY_CHAR:
+ nId = SID_STYLE_FAMILY1; break;
+
+ case SFX_STYLE_FAMILY_PARA:
+ nId = SID_STYLE_FAMILY2; break;
+
+ case SFX_STYLE_FAMILY_FRAME:
+ nId = SID_STYLE_FAMILY3; break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ nId = SID_STYLE_FAMILY4; break;
+
+ case SFX_STYLE_FAMILY_ALL:
+ break;
+
+ default:
+ DBG_ERROR( "StyleSheetFamily wurde geaendert?" );
+ }
+
+ rBindings.EnterRegistrations();
+ pFamilyController =
+ new SvxSearchController( nId, rBindings, *this );
+ rBindings.LeaveRegistrations();
+ aSearchTmplLB.Clear();
+ aReplaceTmplLB.Clear();
+
+ aSearchTmplLB.Show();
+ aReplaceTmplLB.Show();
+ aSearchLB.Hide();
+ aReplaceLB.Hide();
+
+ if ( !pImpl->bMultiLineEdit )
+ {
+ aSearchAttrText.SetText( sDesc );
+ aReplaceAttrText.SetText( sDesc );
+ }
+ else
+ {
+ pImpl->aSearchFormats.SetText( sDesc );
+ pImpl->aReplaceFormats.SetText( sDesc );
+ }
+ }
+ aFormatBtn.Disable();
+ aNoFormatBtn.Disable();
+ aAttributeBtn.Disable();
+ aSimilarityBox.Disable();
+ aSimilarityBtn.Disable();
+ }
+ else
+ {
+ // Vorlagen-Controller disablen
+ rBindings.EnterRegistrations();
+ DELETEZ( pFamilyController );
+ rBindings.LeaveRegistrations();
+
+ aSearchLB.Show();
+ aReplaceLB.Show();
+ aSearchTmplLB.Hide();
+ aReplaceTmplLB.Hide();
+
+ if ( !pImpl->bMultiLineEdit )
+ {
+ aSearchAttrText.SetText( BuildAttrText_Impl( sDesc, TRUE ) );
+ aReplaceAttrText.SetText( BuildAttrText_Impl( sDesc, FALSE ) );
+ }
+ else
+ {
+ pImpl->aSearchFormats.SetText( BuildAttrText_Impl( sDesc, TRUE ) );
+ pImpl->aReplaceFormats.SetText( BuildAttrText_Impl( sDesc, FALSE ) );
+ }
+
+ EnableControl_Impl( &aFormatBtn );
+ EnableControl_Impl( &aAttributeBtn );
+ EnableControl_Impl( &aSimilarityBox );
+
+ FocusHdl_Impl( bSearch ? &aSearchLB : &aReplaceLB );
+ }
+ bSet = TRUE;
+ pImpl->bSaveToModule = FALSE;
+ FlagHdl_Impl( &aLayoutBtn );
+ pImpl->bSaveToModule = TRUE;
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::Remember_Impl( const String &rStr,BOOL _bSearch )
+{
+ if ( !rStr.Len() )
+ return;
+
+ SvStringsDtor* pArr = _bSearch ? &aSearchStrings : &aReplaceStrings;
+ ComboBox* pListBox = _bSearch ? &aSearchLB : &aReplaceLB;
+
+ // identische Strings ignorieren
+ for ( USHORT i = 0; i < pArr->Count(); ++i )
+ {
+ if ( COMPARE_EQUAL == (*pArr)[i]->CompareTo( rStr ) )
+ return;
+ }
+
+ // bei maximaler Belegung "altesten Eintrag l"oschen (ListBox und Array)
+ String* pInsStr;
+
+ if ( pArr->Count() >= REMEMBER_SIZE )
+ {
+ pInsStr = (*pArr)[REMEMBER_SIZE - 1];
+ pListBox->RemoveEntry( USHORT(REMEMBER_SIZE - 1) );
+ pArr->Remove( REMEMBER_SIZE - 1 );
+ *pInsStr = rStr;
+ }
+ else
+ pInsStr = new String( rStr );
+
+ pArr->Insert( pInsStr, 0 );
+ pListBox->InsertEntry( *pInsStr, 0 );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool )
+{
+// SetUpdateMode( FALSE );
+ String aOldSrch( aSearchTmplLB .GetSelectEntry() );
+ String aOldRepl( aReplaceTmplLB.GetSelectEntry() );
+ aSearchTmplLB .Clear();
+ aReplaceTmplLB.Clear();
+ rPool.SetSearchMask( pSearchItem->GetFamily(), SFXSTYLEBIT_ALL );
+ aSearchTmplLB.SetUpdateMode( FALSE );
+ aReplaceTmplLB.SetUpdateMode( FALSE );
+ SfxStyleSheetBase* pBase = rPool.First();
+
+ while ( pBase )
+ {
+ if ( pBase->IsUsed() )
+ aSearchTmplLB.InsertEntry( pBase->GetName() );
+ aReplaceTmplLB.InsertEntry( pBase->GetName() );
+ pBase = rPool.Next();
+ }
+ aSearchTmplLB.SetUpdateMode( TRUE );
+ aReplaceTmplLB.SetUpdateMode( TRUE );
+ aSearchTmplLB.SelectEntryPos(0);
+
+ if ( aOldSrch.Len() )
+ aSearchTmplLB .SelectEntry( aOldSrch );
+ aReplaceTmplLB.SelectEntryPos(0);
+
+ if ( aOldRepl.Len() )
+ aReplaceTmplLB.SelectEntry( aOldRepl );
+
+ if ( aSearchTmplLB.GetEntryCount() )
+ {
+ EnableControl_Impl( &aSearchBtn );
+ EnableControl_Impl( &aSearchAllBtn );
+ EnableControl_Impl( &aReplaceBtn );
+ EnableControl_Impl( &aReplaceAllBtn );
+ }
+// FlagHdl_Impl(0);
+// SetUpdateMode( TRUE );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::EnableControls_Impl( const USHORT nFlags )
+{
+ if ( nFlags == nOptions )
+ return;
+ else
+ nOptions = nFlags;
+
+ if ( !nOptions )
+ {
+ if ( IsVisible() )
+ {
+ Hide();
+ return;
+ }
+ }
+ else if ( !IsVisible() )
+ Show();
+ bool bNoSearch = true;
+
+ sal_Bool bEnableSearch = ( SEARCH_OPTIONS_SEARCH & nOptions ) != 0;
+ aSearchBtn.Enable(bEnableSearch);
+
+ if( bEnableSearch )
+ bNoSearch = false;
+
+
+ if ( ( SEARCH_OPTIONS_SEARCH_ALL & nOptions ) != 0 )
+ {
+ aSearchAllBtn.Enable();
+ bNoSearch = false;
+ }
+ else
+ aSearchAllBtn.Disable();
+ if ( ( SEARCH_OPTIONS_REPLACE & nOptions ) != 0 )
+ {
+ aReplaceBtn.Enable();
+ aReplaceText.Enable();
+ aReplaceLB.Enable();
+ aReplaceTmplLB.Enable();
+ bNoSearch = false;
+ }
+ else
+ {
+ aReplaceBtn.Disable();
+ aReplaceText.Disable();
+ aReplaceLB.Disable();
+ aReplaceTmplLB.Disable();
+ }
+ if ( ( SEARCH_OPTIONS_REPLACE_ALL & nOptions ) != 0 )
+ {
+ aReplaceAllBtn.Enable();
+ bNoSearch = false;
+ }
+ else
+ aReplaceAllBtn.Disable();
+ aSearchComponentFL.Enable(!bNoSearch);
+ aSearchComponent1PB.Enable(!bNoSearch);
+ aSearchComponent2PB.Enable(!bNoSearch);
+ aSearchBtn.Enable( !bNoSearch );
+ aSearchText.Enable( !bNoSearch );
+ aSearchLB.Enable( !bNoSearch );
+
+ if ( ( SEARCH_OPTIONS_WHOLE_WORDS & nOptions ) != 0 )
+ aWordBtn.Enable();
+ else
+ aWordBtn.Disable();
+ if ( ( SEARCH_OPTIONS_BACKWARDS & nOptions ) != 0 )
+ aBackwardsBtn.Enable();
+ else
+ aBackwardsBtn.Disable();
+ //!if ( ( SEARCH_OPTIONS_NOTES & nOptions ) != 0 )
+ aNotesBtn.Enable();
+ //!else
+ //! aNotesBtn.Disable();
+ if ( ( SEARCH_OPTIONS_REG_EXP & nOptions ) != 0 )
+ aRegExpBtn.Enable();
+ else
+ aRegExpBtn.Disable();
+ if ( ( SEARCH_OPTIONS_EXACT & nOptions ) != 0 )
+ aMatchCaseCB.Enable();
+ else
+ aMatchCaseCB.Disable();
+ if ( ( SEARCH_OPTIONS_SELECTION & nOptions ) != 0 )
+ aSelectionBtn.Enable();
+ else
+ aSelectionBtn.Disable();
+ if ( ( SEARCH_OPTIONS_FAMILIES & nOptions ) != 0 )
+ aLayoutBtn.Enable();
+ else
+ aLayoutBtn.Disable();
+ if ( ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
+ {
+ aAttributeBtn.Enable();
+ aFormatBtn.Enable();
+ aNoFormatBtn.Enable();
+ }
+ else
+ {
+ aAttributeBtn.Disable();
+ aFormatBtn.Disable();
+ aNoFormatBtn.Disable();
+ }
+/*
+ if ( ( SEARCH_OPTIONS_MORE & nOptions ) != 0 &&
+ pSearchItem && pSearchItem->GetAppFlag() == SVX_SEARCHAPP_CALC )
+ pMoreBtn->Enable();
+ else
+ {
+ pMoreBtn->SetState( FALSE );
+ pMoreBtn->Disable();
+ }
+*/
+ if ( ( SEARCH_OPTIONS_SIMILARITY & nOptions ) != 0 )
+ {
+ aSimilarityBox.Enable();
+ aSimilarityBtn.Enable();
+ }
+ else
+ {
+ aSimilarityBox.Disable();
+ aSimilarityBtn.Disable();
+ }
+
+ if ( pSearchItem )
+ Init_Impl( pSearchItem->GetPattern() &&
+ ( !pSearchList || !pSearchList->Count() ) );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::EnableControl_Impl( Control* pCtrl )
+{
+ if ( &aSearchBtn == pCtrl && ( SEARCH_OPTIONS_SEARCH & nOptions ) != 0 )
+ {
+ aSearchComponentFL.Enable();
+ aSearchComponent1PB.Enable();
+ aSearchComponent2PB.Enable();
+ aSearchBtn.Enable();
+ return;
+ }
+ if ( &aSearchAllBtn == pCtrl &&
+ ( SEARCH_OPTIONS_SEARCH_ALL & nOptions ) != 0 )
+ {
+ aSearchAllBtn.Enable( ( bWriter || !aAllSheetsCB.IsChecked() ) );
+ return;
+ }
+ if ( &aReplaceBtn == pCtrl && ( SEARCH_OPTIONS_REPLACE & nOptions ) != 0 )
+ {
+ aReplaceBtn.Enable();
+ return;
+ }
+ if ( &aReplaceAllBtn == pCtrl &&
+ ( SEARCH_OPTIONS_REPLACE_ALL & nOptions ) != 0 )
+ {
+ aReplaceAllBtn.Enable();
+ return;
+ }
+ if ( &aWordBtn == pCtrl && ( SEARCH_OPTIONS_WHOLE_WORDS & nOptions ) != 0 )
+ {
+ aWordBtn.Enable();
+ return;
+ }
+ if ( &aBackwardsBtn == pCtrl && ( SEARCH_OPTIONS_BACKWARDS & nOptions ) != 0 )
+ {
+ aBackwardsBtn.Enable();
+ return;
+ }
+ if ( &aNotesBtn == pCtrl /*! && ( SEARCH_OPTIONS_NOTES & nOptions ) != 0 */ )
+ {
+ aNotesBtn.Enable();
+ return;
+ }
+ if ( &aRegExpBtn == pCtrl && ( SEARCH_OPTIONS_REG_EXP & nOptions ) != 0
+ && !aSimilarityBox.IsChecked())
+ {
+ aRegExpBtn.Enable();
+ return;
+ }
+ if ( &aMatchCaseCB == pCtrl && ( SEARCH_OPTIONS_EXACT & nOptions ) != 0 )
+ {
+ if (!aJapOptionsCB.IsChecked())
+ aMatchCaseCB.Enable();
+ return;
+ }
+ if ( &aSelectionBtn == pCtrl && ( SEARCH_OPTIONS_SELECTION & nOptions ) != 0 )
+ {
+ aSelectionBtn.Enable();
+ return;
+ }
+ if ( &aLayoutBtn == pCtrl && ( SEARCH_OPTIONS_FAMILIES & nOptions ) != 0 )
+ {
+ aLayoutBtn.Enable();
+ return;
+ }
+ if ( &aAttributeBtn == pCtrl
+ && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0
+ && pSearchList )
+ {
+ aAttributeBtn.Enable( pImpl->bFocusOnSearch );
+ }
+ if ( &aFormatBtn == pCtrl && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
+ {
+ aFormatBtn.Enable();
+ return;
+ }
+ if ( &aNoFormatBtn == pCtrl && ( SEARCH_OPTIONS_FORMAT & nOptions ) != 0 )
+ {
+ aNoFormatBtn.Enable();
+ return;
+ }
+ if ( &aSimilarityBox == pCtrl &&
+ ( SEARCH_OPTIONS_SIMILARITY & nOptions ) != 0 )
+ {
+ aSimilarityBox.Enable();
+
+ if ( aSimilarityBox.IsChecked() )
+ aSimilarityBtn.Enable();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::SetItem_Impl( const SvxSearchItem* pItem )
+{
+ if ( pItem )
+ {
+ delete pSearchItem;
+ pSearchItem = (SvxSearchItem*)pItem->Clone();
+ Init_Impl( pSearchItem->GetPattern() &&
+ ( !pSearchList || !pSearchList->Count() ) );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxSearchDialog, FocusHdl_Impl, Control *, pCtrl )
+{
+ xub_StrLen nTxtLen;
+
+ if ( !pImpl->bMultiLineEdit )
+ nTxtLen = aSearchAttrText.GetText().Len();
+ else
+ nTxtLen = pImpl->aSearchFormats.GetText().Len();
+
+ if ( pCtrl == &aSearchLB || pCtrl == &pImpl->aSearchFormats )
+ {
+ if ( pCtrl->HasChildPathFocus() )
+ pImpl->bFocusOnSearch = TRUE;
+ pCtrl = &aSearchLB;
+ bSearch = TRUE;
+
+ if( nTxtLen )
+ EnableControl_Impl( &aNoFormatBtn );
+ else
+ aNoFormatBtn.Disable();
+ EnableControl_Impl( &aAttributeBtn );
+ }
+ else
+ {
+ pImpl->bFocusOnSearch = FALSE;
+ pCtrl = &aReplaceLB;
+ bSearch = FALSE;
+
+ if ( ( !pImpl->bMultiLineEdit && aReplaceAttrText.GetText().Len() ) ||
+ ( pImpl->bMultiLineEdit && pImpl->aReplaceFormats.GetText().Len() ) )
+ EnableControl_Impl( &aNoFormatBtn );
+ else
+ aNoFormatBtn.Disable();
+ aAttributeBtn.Disable();
+ }
+ bSet = TRUE;
+
+ aSearchLB.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
+
+ ModifyHdl_Impl( (ComboBox*)pCtrl );
+
+ aLayoutBtn.SetText( bFormat && nTxtLen ? aLayoutStr : aStylesStr );
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxSearchDialog, LoseFocusHdl_Impl, Control *, EMPTYARG )
+{
+ SaveToModule_Impl();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxSearchDialog, FormatHdl_Impl, Button *, EMPTYARG )
+{
+ SfxObjectShell* pSh = SfxObjectShell::Current();
+
+ DBG_ASSERT( pSh, "no DocShell" );
+
+ if ( !pSh || !pImpl->pRanges )
+ return 0;
+
+ sal_sSize nCnt = 0;
+ const USHORT* pPtr = pImpl->pRanges;
+ const USHORT* pTmp = pPtr;
+
+ while( *pTmp )
+ pTmp++;
+ nCnt = pTmp - pPtr + 7;
+ USHORT* pWhRanges = new USHORT[nCnt];
+ USHORT nPos = 0;
+
+ while( *pPtr )
+ {
+ pWhRanges[nPos++] = *pPtr++;
+ }
+
+ pWhRanges[nPos++] = SID_ATTR_PARA_MODEL;
+ pWhRanges[nPos++] = SID_ATTR_PARA_MODEL;
+
+ USHORT nBrushWhich = pSh->GetPool().GetWhich(SID_ATTR_BRUSH);
+ pWhRanges[nPos++] = nBrushWhich;
+ pWhRanges[nPos++] = nBrushWhich;
+ pWhRanges[nPos++] = SID_PARA_BACKGRND_DESTINATION;
+ pWhRanges[nPos++] = SID_PARA_BACKGRND_DESTINATION;
+ pWhRanges[nPos] = 0;
+ SfxItemPool& rPool = pSh->GetPool();
+ SfxItemSet aSet( rPool, pWhRanges );
+ String aTxt;
+
+ aSet.InvalidateAllItems();
+ aSet.Put(SvxBrushItem(nBrushWhich));
+ aSet.Put(SfxUInt16Item(SID_PARA_BACKGRND_DESTINATION, PARA_DEST_CHAR));
+
+ if ( bSearch )
+ {
+ aTxt = SVX_RESSTR( RID_SVXSTR_SEARCH );
+ pSearchList->Get( aSet );
+ }
+ else
+ {
+ aTxt = SVX_RESSTR( RID_SVXSTR_REPLACE );
+ pReplaceList->Get( aSet );
+ }
+ aSet.DisableItem(SID_ATTR_PARA_MODEL);
+ aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_PAGEBREAK));
+ aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_KEEP));
+
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ SfxAbstractTabDialog* pDlg = pFact->CreateTabItemDialog( LAYOUT_THIS_WINDOW (this), aSet, RID_SVXDLG_SEARCHFORMAT );
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ aTxt.Insert( pDlg->GetText(), 0 );
+ pDlg->SetText( aTxt );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ DBG_ASSERT( pDlg->GetOutputItemSet(), "invalid Output-Set" );
+ SfxItemSet aOutSet( *pDlg->GetOutputItemSet() );
+
+ SearchAttrItemList* pList = bSearch ? pSearchList : pReplaceList;
+
+ SearchAttrItem* pAItem;
+ const SfxPoolItem* pItem;
+ for( USHORT n = 0; n < pList->Count(); ++n )
+ if( !IsInvalidItem( (pAItem = &pList->GetObject(n))->pItem ) &&
+ SFX_ITEM_SET == aOutSet.GetItemState(
+ pAItem->pItem->Which(), FALSE, &pItem ) )
+ {
+ delete pAItem->pItem;
+ pAItem->pItem = pItem->Clone();
+ aOutSet.ClearItem( pAItem->pItem->Which() );
+ }
+
+ if( aOutSet.Count() )
+ pList->Put( aOutSet );
+
+ PaintAttrText_Impl(); // AttributText in GroupBox setzen
+ }
+ delete pDlg;
+ }
+ delete[] pWhRanges;
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxSearchDialog, NoFormatHdl_Impl, Button *, EMPTYARG )
+{
+ aLayoutBtn.SetText( aStylesStr );
+ bFormat = FALSE;
+ aLayoutBtn.Check( FALSE );
+
+ if ( bSearch )
+ {
+ if ( !pImpl->bMultiLineEdit )
+ aSearchAttrText.SetText( String() );
+ else
+ pImpl->aSearchFormats.SetText( String() );
+ pSearchList->Clear();
+ }
+ else
+ {
+ if ( !pImpl->bMultiLineEdit )
+ aReplaceAttrText.SetText( String() );
+ else
+ pImpl->aReplaceFormats.SetText( String() );
+ pReplaceList->Clear();
+ }
+ pImpl->bSaveToModule = FALSE;
+ TemplateHdl_Impl( &aLayoutBtn );
+ pImpl->bSaveToModule = TRUE;
+ aNoFormatBtn.Disable();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxSearchDialog, AttributeHdl_Impl, Button *, EMPTYARG )
+{
+ if ( !pSearchList || !pImpl->pRanges )
+ return 0;
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ VclAbstractDialog* pDlg = pFact->CreateSvxSearchAttributeDialog( LAYOUT_THIS_WINDOW (this), *pSearchList, pImpl->pRanges );
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ pDlg->Execute();
+ delete pDlg;
+ }
+ PaintAttrText_Impl();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxSearchDialog, TimeoutHdl_Impl, Timer *, pTimer )
+{
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+
+ if ( pViewShell )
+ {
+ if ( pViewShell->HasSelection( aSearchLB.IsVisible() ) )
+ EnableControl_Impl( &aSelectionBtn );
+ else
+ {
+ aSelectionBtn.Check( FALSE );
+ aSelectionBtn.Disable();
+ }
+ }
+
+ pTimer->Start();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::GetSearchItems( SfxItemSet& rSet )
+{
+ xub_StrLen nLen;
+
+ if ( !pImpl->bMultiLineEdit )
+ nLen = aSearchAttrText.GetText().Len();
+ else
+ nLen = pImpl->aSearchFormats.GetText().Len();
+
+ if ( nLen && pSearchList )
+ pSearchList->Get( rSet );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::GetReplaceItems( SfxItemSet& rSet )
+{
+ xub_StrLen nLen;
+
+ if ( !pImpl->bMultiLineEdit )
+ nLen = aReplaceAttrText.GetText().Len();
+ else
+ nLen = pImpl->aReplaceFormats.GetText().Len();
+
+ if ( nLen && pReplaceList )
+ pReplaceList->Get( rSet );
+}
+
+// -----------------------------------------------------------------------
+
+String& SvxSearchDialog::BuildAttrText_Impl( String& rStr,
+ BOOL bSrchFlag ) const
+{
+ if ( rStr.Len() )
+ rStr.Erase();
+
+ SfxObjectShell* pSh = SfxObjectShell::Current();
+ DBG_ASSERT( pSh, "no DocShell" );
+
+ if ( !pSh )
+ return rStr;
+
+ SfxItemPool& rPool = pSh->GetPool();
+ SearchAttrItemList* pList = bSrchFlag ? pSearchList : pReplaceList;
+
+ if ( !pList )
+ return rStr;
+
+ // Metrik abfragen
+ SfxMapUnit eMapUnit = SFX_MAPUNIT_CM;
+ FieldUnit eFieldUnit = pSh->GetModule()->GetFieldUnit();
+ switch ( eFieldUnit )
+ {
+ case FUNIT_MM: eMapUnit = SFX_MAPUNIT_MM; break;
+ case FUNIT_CM:
+ case FUNIT_M:
+ case FUNIT_KM: eMapUnit = SFX_MAPUNIT_CM; break;
+ case FUNIT_TWIP: eMapUnit = SFX_MAPUNIT_TWIP; break;
+ case FUNIT_POINT:
+ case FUNIT_PICA: eMapUnit = SFX_MAPUNIT_POINT; break;
+ case FUNIT_INCH:
+ case FUNIT_FOOT:
+ case FUNIT_MILE: eMapUnit = SFX_MAPUNIT_INCH; break;
+ case FUNIT_100TH_MM: eMapUnit = SFX_MAPUNIT_100TH_MM; break;
+ default: ;//prevent warning
+ }
+
+ ResStringArray aAttrNames( SVX_RES( RID_ATTR_NAMES ) );
+
+ for ( USHORT i = 0; i < pList->Count(); ++i )
+ {
+ const SearchAttrItem& rItem = pList->GetObject(i);
+
+ if ( rStr.Len() )
+ rStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ", " ) );
+
+ if ( !IsInvalidItem( rItem.pItem ) )
+ {
+ String aStr;
+ rPool.GetPresentation( *rItem.pItem,
+ SFX_ITEM_PRESENTATION_COMPLETE,
+ eMapUnit, aStr );
+ rStr += aStr;
+ }
+ else if ( rItem.nSlot == SID_ATTR_BRUSH_CHAR )
+ {
+ //Sonderbehandlung fuer Zeichenhintergrund
+ rStr += SVX_RESSTR( RID_SVXITEMS_BRUSH_CHAR );
+ }
+ else
+ {
+ sal_uInt32 nId = aAttrNames.FindIndex( rItem.nSlot );
+ if ( RESARRAY_INDEX_NOTFOUND != nId )
+ rStr += aAttrNames.GetString( nId );
+ }
+ }
+ return rStr;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::PaintAttrText_Impl()
+{
+ String aDesc;
+ BuildAttrText_Impl( aDesc, bSearch );
+
+ if ( !bFormat && aDesc.Len() )
+ bFormat = TRUE;
+
+ if ( bSearch )
+ {
+ if ( !pImpl->bMultiLineEdit )
+ aSearchAttrText.SetText( aDesc );
+ else
+ pImpl->aSearchFormats.SetText( aDesc );
+ FocusHdl_Impl( &aSearchLB );
+ }
+ else
+ {
+ if ( !pImpl->bMultiLineEdit )
+ aReplaceAttrText.SetText( aDesc );
+ else
+ pImpl->aReplaceFormats.SetText( aDesc );
+ FocusHdl_Impl( &aReplaceLB );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::SetModifyFlag_Impl( const Control* pCtrl )
+{
+ if ( &aSearchLB == (ComboBox*)pCtrl )
+ nModifyFlag |= MODIFY_SEARCH;
+ else if ( &aReplaceLB == (ComboBox*)pCtrl )
+ nModifyFlag |= MODIFY_REPLACE;
+ else if ( &aWordBtn == (CheckBox*)pCtrl )
+ nModifyFlag |= MODIFY_WORD;
+ else if ( &aMatchCaseCB == (CheckBox*)pCtrl )
+ nModifyFlag |= MODIFY_EXACT;
+ else if ( &aBackwardsBtn == (CheckBox*)pCtrl )
+ nModifyFlag |= MODIFY_BACKWARDS;
+ else if ( &aNotesBtn == (CheckBox*)pCtrl )
+ nModifyFlag |= MODIFY_NOTES;
+ else if ( &aSelectionBtn == (CheckBox*)pCtrl )
+ nModifyFlag |= MODIFY_SELECTION;
+ else if ( &aRegExpBtn == (CheckBox*)pCtrl )
+ nModifyFlag |= MODIFY_REGEXP;
+ else if ( &aLayoutBtn == (CheckBox*)pCtrl )
+ nModifyFlag |= MODIFY_LAYOUT;
+ else if ( &aSimilarityBox == (CheckBox*)pCtrl )
+ nModifyFlag |= MODIFY_SIMILARITY;
+ else if ( &aCalcSearchInLB == (ListBox*)pCtrl )
+ {
+ nModifyFlag |= MODIFY_FORMULAS;
+ nModifyFlag |= MODIFY_VALUES;
+ nModifyFlag |= MODIFY_CALC_NOTES;
+ }
+ else if ( &aRowsBtn == (RadioButton*)pCtrl )
+ nModifyFlag |= MODIFY_ROWS;
+ else if ( &aColumnsBtn == (RadioButton*)pCtrl )
+ nModifyFlag |= MODIFY_COLUMNS;
+ else if ( &aAllSheetsCB == (CheckBox*)pCtrl )
+ nModifyFlag |= MODIFY_ALLTABLES;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSearchDialog::SaveToModule_Impl()
+{
+ if ( !pSearchItem )
+ return;
+
+ if ( aLayoutBtn.IsChecked() )
+ {
+ pSearchItem->SetSearchString ( aSearchTmplLB.GetSelectEntry() );
+ pSearchItem->SetReplaceString( aReplaceTmplLB.GetSelectEntry() );
+ }
+ else
+ {
+ pSearchItem->SetSearchString ( aSearchLB.GetText() );
+ pSearchItem->SetReplaceString( aReplaceLB.GetText() );
+ Remember_Impl( aSearchLB.GetText(), TRUE );
+ }
+
+ pSearchItem->SetRegExp( FALSE );
+ pSearchItem->SetLevenshtein( FALSE );
+ if (GetCheckBoxValue( aRegExpBtn ))
+ pSearchItem->SetRegExp( TRUE );
+ else if (GetCheckBoxValue( aSimilarityBox ))
+ pSearchItem->SetLevenshtein( TRUE );
+
+ pSearchItem->SetWordOnly( GetCheckBoxValue( aWordBtn ) );
+ pSearchItem->SetBackward( GetCheckBoxValue( aBackwardsBtn ) );
+ pSearchItem->SetNotes( GetCheckBoxValue( aNotesBtn ) );
+ pSearchItem->SetPattern( GetCheckBoxValue( aLayoutBtn ) );
+ pSearchItem->SetSelection( GetCheckBoxValue( aSelectionBtn ) );
+
+ pSearchItem->SetUseAsianOptions( GetCheckBoxValue( aJapOptionsCB ) );
+ INT32 nFlags = GetTransliterationFlags();
+ if( !pSearchItem->IsUseAsianOptions())
+ nFlags &= (TransliterationModules_IGNORE_CASE |
+ TransliterationModules_IGNORE_WIDTH );
+ pSearchItem->SetTransliterationFlags( nFlags );
+
+ if ( !bWriter )
+ {
+ if ( aCalcSearchInLB.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND )
+ pSearchItem->SetCellType( aCalcSearchInLB.GetSelectEntryPos() );
+
+ pSearchItem->SetRowDirection( aRowsBtn.IsChecked() );
+ pSearchItem->SetAllTables( aAllSheetsCB.IsChecked() );
+ }
+
+ pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
+ nModifyFlag = 0;
+ const SfxPoolItem* ppArgs[] = { pSearchItem, 0 };
+ rBindings.GetDispatcher()->Execute( SID_SEARCH_ITEM, SFX_CALLMODE_SLOT, ppArgs );
+}
+
+// class SvxSearchDialogWrapper ------------------------------------------
+
+SFX_IMPL_CHILDWINDOW(SvxSearchDialogWrapper, SID_SEARCH_DLG);
+
+// -----------------------------------------------------------------------
+
+SvxSearchDialogWrapper::SvxSearchDialogWrapper( Window* _pParent, USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo )
+ : SfxChildWindow( _pParent, nId )
+ , dialog (new SvxSearchDialog (_pParent, this, *pBindings))
+{
+ pWindow = LAYOUT_THIS_WINDOW (dialog);
+ dialog->Initialize( pInfo );
+
+ pBindings->Update( SID_SEARCH_ITEM );
+ pBindings->Update( SID_SEARCH_OPTIONS );
+ pBindings->Update( SID_SEARCH_SEARCHSET );
+ pBindings->Update( SID_SEARCH_REPLACESET );
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+ dialog->bConstruct = FALSE;
+}
+
+SvxSearchDialogWrapper::~SvxSearchDialogWrapper ()
+{
+#if ENABLE_LAYOUT
+ delete dialog;
+ pWindow = 0;
+#endif /* ENABLE_LAYOUT */
+}
+
+SvxSearchDialog *SvxSearchDialogWrapper::getDialog ()
+{
+ return dialog;
+}
+
+// -----------------------------------------------------------------------
+
+SfxChildWinInfo SvxSearchDialogWrapper::GetInfo() const
+{
+ SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
+ aInfo.bVisible = sal_False;
+ return aInfo;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/srchdlg.hrc b/svx/source/dialog/srchdlg.hrc
new file mode 100644
index 000000000000..90ce20f46753
--- /dev/null
+++ b/svx/source/dialog/srchdlg.hrc
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * 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 _SVX_SRCHDLG_HRC
+#define _SVX_SRCHDLG_HRC
+
+// defines ------------------------------------------------------------------
+
+#define FT_SEARCH 10
+#define ED_SEARCH 11
+#define LB_SEARCH 12
+#define FT_SEARCH_ATTR 13
+#define FT_SEARCH_FORMATS 14
+#define FT_REPLACE 15
+#define ED_REPLACE 16
+#define LB_REPLACE 17
+#define FT_REPLACE_ATTR 18
+#define FT_REPLACE_FORMATS 19
+
+#define BTN_SEARCH 20
+#define BTN_SEARCH_ALL 21
+#define FL_SEARCH_COMMAND 22
+#define BTN_REPLACE 23
+#define BTN_REPLACE_ALL 24
+
+#define CB_MATCH_CASE 25
+#define CB_WHOLE_WORDS 26
+#define FL_SEARCH_COMPONENT 27
+#define BTN_COMPONENT_1 28
+#define BTN_COMPONENT_2 29
+
+#define FL_BUTTONS 30
+#define BTN_MORE 31
+#define BTN_HELP 32
+#define BTN_CLOSE 33
+
+#define FL_OPTIONS 40
+#define CB_SELECTIONS 41
+#define CB_BACKWARDS 42
+#define CB_REGEXP 43
+#define CB_SIMILARITY 44
+#define PB_SIMILARITY 45
+#define CB_LAYOUTS 46
+#define CB_JAP_MATCH_FULL_HALF_WIDTH 47
+#define CB_JAP_SOUNDS_LIKE 48
+#define PB_JAP_OPTIONS 49
+
+#define BTN_ATTRIBUTE 50
+#define BTN_FORMAT 51
+#define BTN_NOFORMAT 52
+
+#define FL_CALC 53
+#define FT_CALC_SEARCHIN 54
+#define LB_CALC_SEARCHIN 55
+#define FT_CALC_SEARCHDIR 56
+#define RB_CALC_ROWS 57
+#define RB_CALC_COLUMNS 58
+#define CB_ALL_SHEETS 59
+
+#define CB_NOTES 60
+
+#define IMG_MOREBTN_DOWN 100
+#define IMG_MOREBTN_UP 101
+
+#define STR_WORDCALC 100
+#define STR_MORE_BTN 101
+#define STR_LESS_BTN 102
+
+#endif // #ifndef _SVX_SRCHDLG_HRC
+
diff --git a/svx/source/dialog/srchdlg.src b/svx/source/dialog/srchdlg.src
new file mode 100644
index 000000000000..f00a6c809363
--- /dev/null
+++ b/svx/source/dialog/srchdlg.src
@@ -0,0 +1,411 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+ // include ---------------------------------------------------------------
+
+#include <svx/dialogs.hrc>
+#include "srchdlg.hrc"
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; } ;
+
+ // Strings ---------------------------------------------------------------
+
+String RID_SVXSTR_SEARCH_STYLES
+{
+ Text [ en-US ] = "Including Styles" ;
+};
+String RID_SVXSTR_SEARCH
+{
+ Text [ en-US ] = "(Search)" ;
+};
+String RID_SVXSTR_REPLACE
+{
+ Text [ en-US ] = "(Replace)" ;
+};
+
+ // RID_SVXDLG_SEARCH -----------------------------------------------------
+
+ModelessDialog RID_SVXDLG_SEARCH
+{
+ HelpId = SID_SEARCH_DLG ;
+ OutputSize = TRUE ;
+ Hide = TRUE ;
+ SvLook = TRUE ;
+ Size = MAP_APPFONT ( 200 , 155 ) ;
+ Text [ en-US ] = "Find & Replace" ;
+ Moveable = TRUE ;
+ FixedText FT_SEARCH
+ {
+ Pos = MAP_APPFONT ( 6 , 7 ) ;
+ Size = MAP_APPFONT ( 132 , 8 ) ;
+ Text [ en-US ] = "~Search for" ;
+ };
+ ComboBox ED_SEARCH
+ {
+ Pos = MAP_APPFONT ( 6 , 18 ) ;
+ Size = MAP_APPFONT ( 132 , 98 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_SEARCH
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 18 ) ;
+ Size = MAP_APPFONT ( 132 , 98 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Hide = TRUE ;
+ Sort = TRUE ;
+ };
+ FixedText FT_SEARCH_ATTR
+ {
+ Pos = MAP_APPFONT ( 9 , 35 ) ;
+ Size = MAP_APPFONT ( 129 , 16 ) ;
+ WordBreak = TRUE ;
+ Hide = TRUE ;
+ };
+ FixedText FT_SEARCH_FORMATS
+ {
+ Pos = MAP_APPFONT ( 9 , 35 ) ;
+ Size = MAP_APPFONT ( 129 , 16 ) ;
+ WordBreak = TRUE ;
+ Hide = TRUE ;
+ };
+ FixedText FT_REPLACE
+ {
+ Pos = MAP_APPFONT ( 6 , 54 ) ;
+ Size = MAP_APPFONT ( 132 , 8 ) ;
+ Text [ en-US ] = "Re~place with" ;
+ };
+ ComboBox ED_REPLACE
+ {
+ Pos = MAP_APPFONT ( 6 , 65 ) ;
+ Size = MAP_APPFONT ( 132 , 98 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_REPLACE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 65 ) ;
+ Size = MAP_APPFONT ( 132 , 98 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Hide = TRUE ;
+ Sort = TRUE ;
+ };
+ FixedText FT_REPLACE_ATTR
+ {
+ Pos = MAP_APPFONT ( 9 , 82 ) ;
+ Size = MAP_APPFONT ( 129 , 16 ) ;
+ WordBreak = TRUE ;
+ Hide = TRUE ;
+ };
+ FixedText FT_REPLACE_FORMATS
+ {
+ Pos = MAP_APPFONT ( 9 , 82 ) ;
+ Size = MAP_APPFONT ( 129 , 16 ) ;
+ WordBreak = TRUE ;
+ Hide = TRUE ;
+ };
+ PushButton BTN_SEARCH
+ {
+ Pos = MAP_APPFONT ( 144 , 9 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Find" ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ PushButton BTN_SEARCH_ALL
+ {
+ Pos = MAP_APPFONT ( 144 , 26 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "Find ~All" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_SEARCH_COMMAND
+ {
+ Pos = MAP_APPFONT ( 141 , 44 ) ;
+ Size = MAP_APPFONT ( 56 , 8 ) ;
+ };
+ PushButton BTN_REPLACE
+ {
+ Pos = MAP_APPFONT ( 144 , 56 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Replace" ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_REPLACE_ALL
+ {
+ Pos = MAP_APPFONT ( 144 , 73 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "Replace A~ll" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_SEARCH_COMPONENT
+ {
+ Pos = MAP_APPFONT ( 141 , 91 ) ;
+ Size = MAP_APPFONT ( 56 , 8 ) ;
+ Hide = TRUE;
+ };
+ PushButton BTN_COMPONENT_1
+ {
+ Pos = MAP_APPFONT ( 144 , 103 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE;
+ };
+ PushButton BTN_COMPONENT_2
+ {
+ Pos = MAP_APPFONT ( 144 , 120 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE;
+ };
+ CheckBox CB_MATCH_CASE
+ {
+ Pos = MAP_APPFONT ( 12 , 101 ) ;
+ Size = MAP_APPFONT ( 126 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Ma~tch case";
+ };
+ CheckBox CB_WHOLE_WORDS
+ {
+ Pos = MAP_APPFONT ( 12 , 114 ) ;
+ Size = MAP_APPFONT ( 126 , 10 ) ;
+ Text [ en-US ] = "Whole wor~ds only" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , 124 ) ;
+ Size = MAP_APPFONT ( 200 , 8 ) ;
+ };
+ MoreButton BTN_MORE
+ {
+ Pos = MAP_APPFONT ( 6 , 135 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 174 ;
+ State = FALSE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 88 , 135 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CLOSE
+ {
+ Pos = MAP_APPFONT ( 144 , 135 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Close" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 152 ) ;
+ Size = MAP_APPFONT ( 191 , 8 ) ;
+ Hide = TRUE ;
+ };
+ CheckBox CB_SELECTIONS
+ {
+ Pos = MAP_APPFONT ( 12 , 163 ) ;
+ Size = MAP_APPFONT ( 126 , 10 ) ;
+ Text [ en-US ] = "C~urrent selection only" ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ CheckBox CB_BACKWARDS
+ {
+ Pos = MAP_APPFONT ( 12 , 176 ) ;
+ Size = MAP_APPFONT ( 126 , 10 ) ;
+ Text [ en-US ] = "Bac~kwards" ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ CheckBox CB_REGEXP
+ {
+ Pos = MAP_APPFONT ( 12 , 189 ) ;
+ Size = MAP_APPFONT ( 126 , 10 ) ;
+ Text [ en-US ] = "Regular e~xpressions" ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ CheckBox CB_SIMILARITY
+ {
+ Pos = MAP_APPFONT ( 12 , 204 ) ;
+ Size = MAP_APPFONT ( 109 , 10 ) ;
+ Text [ en-US ] = "S~imilarity search" ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ PushButton PB_SIMILARITY
+ {
+ Pos = MAP_APPFONT ( 124 , 202 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Text = "~..." ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ CheckBox CB_LAYOUTS
+ {
+ Pos = MAP_APPFONT ( 12 , 219 ) ;
+ Size = MAP_APPFONT ( 126 , 10 ) ;
+ Text [ en-US ] = "Search for St~yles" ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ CheckBox CB_NOTES
+ {
+ Pos = MAP_APPFONT ( 12 , 232 ) ;
+ Size = MAP_APPFONT ( 126 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Notes";
+ };
+ CheckBox CB_JAP_MATCH_FULL_HALF_WIDTH
+ {
+ Pos = MAP_APPFONT ( 12 , 247 ) ;
+ Size = MAP_APPFONT ( 126 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Match character width";
+ Hide = TRUE ;
+ };
+ CheckBox CB_JAP_SOUNDS_LIKE
+ {
+ Pos = MAP_APPFONT ( 12 , 260 ) ;
+ Size = MAP_APPFONT ( 109 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Sounds like (Japanese)";
+ Hide = TRUE ;
+ };
+ PushButton PB_JAP_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 124 , 258 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Text = "..." ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ PushButton BTN_ATTRIBUTE
+ {
+ Pos = MAP_APPFONT ( 144 , 163 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "Attri~butes..." ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ PushButton BTN_FORMAT
+ {
+ Pos = MAP_APPFONT ( 144 , 180 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "For~mat..." ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ PushButton BTN_NOFORMAT
+ {
+ Pos = MAP_APPFONT ( 144 , 197 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~No Format" ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ FixedLine FL_CALC
+ {
+ Pos = MAP_APPFONT ( 6 , 272 ) ;
+ Size = MAP_APPFONT ( 191 , 8 ) ;
+ Hide = TRUE ;
+ };
+ FixedText FT_CALC_SEARCHIN
+ {
+ Pos = MAP_APPFONT ( 12 , 285 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Search i~n" ;
+ Hide = TRUE ;
+ };
+ ListBox LB_CALC_SEARCHIN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 75 , 283 ) ;
+ Size = MAP_APPFONT ( 63 , 48 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Hide = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Formulas" ; Default ; > ;
+ < "Values" ; Default ; > ;
+ < "Notes" ; Default ; > ;
+ };
+ };
+ FixedText FT_CALC_SEARCHDIR
+ {
+ Pos = MAP_APPFONT ( 12 , 300 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Search ~direction" ;
+ Hide = TRUE ;
+ };
+ RadioButton RB_CALC_ROWS
+ {
+ Pos = MAP_APPFONT ( 75 , 300 ) ;
+ Size = MAP_APPFONT ( 63 , 10 ) ;
+ Text [ en-US ] = "Ro~ws" ;
+ Hide = TRUE ;
+ };
+ RadioButton RB_CALC_COLUMNS
+ {
+ Pos = MAP_APPFONT ( 75 , 313 ) ;
+ Size = MAP_APPFONT ( 63 , 10 ) ;
+ Text [ en-US ] = "Colu~mns" ;
+ Hide = TRUE ;
+ };
+ CheckBox CB_ALL_SHEETS
+ {
+ Pos = MAP_APPFONT ( 12 , 326 ) ;
+ Size = MAP_APPFONT ( 126 , 10 ) ;
+ Text [ en-US ] = "Search in all sheets" ;
+ Hide = TRUE ;
+ };
+
+ String STR_WORDCALC
+ {
+ Text [ en-US ] = "~Entire cells" ;
+ };
+ String STR_MORE_BTN
+ {
+ Text [ en-US ] = "More ~Options" ;
+ };
+ String STR_LESS_BTN
+ {
+ Text [ en-US ] = "Fewer ~Options" ;
+ };
+};
+
+ // ********************************************************************** EOF
+
diff --git a/svx/source/dialog/stddlg.cxx b/svx/source/dialog/stddlg.cxx
new file mode 100644
index 000000000000..6021b232e2db
--- /dev/null
+++ b/svx/source/dialog/stddlg.cxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include <svx/stddlg.hxx>
+
+// STATIC DATA -----------------------------------------------------------
+
+
+// class SvxStandardDialog -----------------------------------------------
+
+short SvxStandardDialog::Execute()
+{
+ short nRet = ModalDialog::Execute();
+
+ if ( RET_OK == nRet )
+ Apply();
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+SvxStandardDialog::SvxStandardDialog( Window *pParent, const ResId &rResId ) :
+ SfxModalDialog( pParent, rResId )
+{
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT SvxStandardDialog::~SvxStandardDialog()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/strarray.cxx b/svx/source/dialog/strarray.cxx
new file mode 100644
index 000000000000..4ac073612103
--- /dev/null
+++ b/svx/source/dialog/strarray.cxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/shl.hxx>
+
+// include ---------------------------------------------------------------
+
+#include <svx/dialogs.hrc> // -> RID_SVXSTR_LANGUAGE_TABLE
+#include <svx/dialmgr.hxx>
+#include <svx/strarray.hxx>
+
+//------------------------------------------------------------------------
+
+SvxStringArray::SvxStringArray( sal_uInt32 nResId ) :
+
+ ResStringArray( SVX_RES( nResId ) )
+
+{
+}
+
+//------------------------------------------------------------------------
+
+SvxStringArray::SvxStringArray( const ResId& rResId ) :
+ ResStringArray( rResId )
+{
+}
+
+
+//------------------------------------------------------------------------
+
+SvxStringArray::~SvxStringArray()
+{
+}
+
+//------------------------------------------------------------------------
+
+const String& SvxStringArray::GetStringByPos( sal_uInt32 nPos ) const
+{
+ if ( RESARRAY_INDEX_NOTFOUND != nPos && nPos < Count() )
+ return ResStringArray::GetString( nPos );
+ else
+ return String::EmptyString();
+}
+
+//------------------------------------------------------------------------
+
+const String& SvxStringArray::GetStringByType( long nType ) const
+{
+ sal_uInt32 nPos = FindIndex( nType );
+
+ if ( RESARRAY_INDEX_NOTFOUND != nPos && nPos < Count() )
+ return ResStringArray::GetString( nPos );
+ else
+ return String::EmptyString();
+}
+
+//------------------------------------------------------------------------
+
+long SvxStringArray::GetValueByStr( const String& rStr ) const
+{
+ long nType = 0;
+ sal_uInt32 nCount = Count();
+
+ for ( sal_uInt32 i = 0; i < nCount; ++i )
+ if ( rStr == ResStringArray::GetString( i ) )
+ {
+ nType = GetValue( i );
+ break;
+ }
+ return nType;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/svxbmpnumvalueset.cxx b/svx/source/dialog/svxbmpnumvalueset.cxx
new file mode 100644
index 000000000000..8f0843575fc7
--- /dev/null
+++ b/svx/source/dialog/svxbmpnumvalueset.cxx
@@ -0,0 +1,571 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include <tools/shl.hxx>
+#include <i18npool/mslangid.hxx>
+#include <svtools/valueset.hxx>
+#include <svl/languageoptions.hxx>
+#include <helpid.hrc>
+#include <editeng/numitem.hxx>
+#include <svl/eitem.hxx>
+#include <vcl/svapp.hxx>
+#include <gallery.hxx>
+#include <svl/urihelper.hxx>
+#include <editeng/brshitem.hxx>
+#include <svl/intitem.hxx>
+#include <sfx2/objsh.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/msgbox.hxx>
+#include <editeng/flstitem.hxx>
+#include <dlgutil.hxx>
+#ifndef _XTABLE_HXX //autogen
+
+#include <svx/xtable.hxx>
+#endif
+#include <drawitem.hxx>
+#include <numvset.hxx>
+#include <htmlmode.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svtools/ctrltool.hxx>
+#include <editeng/unolingu.hxx>
+#include <com/sun/star/style/NumberingType.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/text/XDefaultNumberingProvider.hpp>
+#include <com/sun/star/text/XNumberingFormatter.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/text/XNumberingTypeInfo.hpp>
+
+#include <algorithm>
+#include <sfx2/opengrf.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::i18n;
+using namespace com::sun::star::text;
+using namespace com::sun::star::container;
+using namespace com::sun::star::style;
+using rtl::OUString;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+#define NUM_PAGETYPE_BULLET 0
+#define NUM_PAGETYPE_SINGLENUM 1
+#define NUM_PAGETYPE_NUM 2
+#define NUM_PAGETYPE_BMP 3
+#define PAGETYPE_USER_START 10
+
+#define SHOW_NUMBERING 0
+#define SHOW_BULLET 1
+#define SHOW_BITMAP 2
+
+#define MAX_BMP_WIDTH 16
+#define MAX_BMP_HEIGHT 16
+
+static const sal_Char cNumberingType[] = "NumberingType";
+static const sal_Char cValue[] = "Value";
+static const sal_Char cParentNumbering[] = "ParentNumbering";
+static const sal_Char cPrefix[] = "Prefix";
+static const sal_Char cSuffix[] = "Suffix";
+static const sal_Char cBulletChar[] = "BulletChar";
+static const sal_Char cBulletFontName[] = "BulletFontName";
+
+/* -----------------28.10.98 08:32-------------------
+ *
+ * --------------------------------------------------*/
+// Die Auswahl an Bullets aus den StarSymbol
+static const sal_Unicode aBulletTypes[] =
+{
+ 0x2022,
+ 0x25cf,
+ 0xe00c,
+ 0xe00a,
+ 0x2794,
+ 0x27a2,
+ 0x2717,
+ 0x2714
+};
+
+static Font& lcl_GetDefaultBulletFont()
+{
+ static BOOL bInit = 0;
+ static Font aDefBulletFont( UniString::CreateFromAscii(
+ RTL_CONSTASCII_STRINGPARAM( "StarSymbol" ) ),
+ String(), Size( 0, 14 ) );
+ if(!bInit)
+ {
+ aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
+ aDefBulletFont.SetFamily( FAMILY_DONTKNOW );
+ aDefBulletFont.SetPitch( PITCH_DONTKNOW );
+ aDefBulletFont.SetWeight( WEIGHT_DONTKNOW );
+ aDefBulletFont.SetTransparent( TRUE );
+ bInit = TRUE;
+ }
+ return aDefBulletFont;
+}
+
+static void lcl_PaintLevel(OutputDevice* pVDev, sal_Int16 nNumberingType,
+ const OUString& rBulletChar, const OUString& rText, const OUString& rFontName,
+ Point& rLeft, Font& rRuleFont, const Font& rTextFont)
+{
+
+ if(NumberingType::CHAR_SPECIAL == nNumberingType )
+ {
+ rRuleFont.SetStyleName(rFontName);
+ pVDev->SetFont(rRuleFont);
+ pVDev->DrawText(rLeft, rBulletChar);
+ rLeft.X() += pVDev->GetTextWidth(rBulletChar);
+ }
+ else
+ {
+ pVDev->SetFont(rTextFont);
+ pVDev->DrawText(rLeft, rText);
+ rLeft.X() += pVDev->GetTextWidth(rText);
+ }
+}
+void SvxNumValueSet::UserDraw( const UserDrawEvent& rUDEvt )
+{
+ static USHORT __READONLY_DATA aLinesArr[] =
+ {
+ 15, 10,
+ 20, 30,
+ 25, 50,
+ 30, 70,
+ 35, 90, // up to here line positions
+ 05, 10, // character positions
+ 10, 30,
+ 15, 50,
+ 20, 70,
+ 25, 90,
+ };
+
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ const Color aBackColor = rStyleSettings.GetFieldColor();
+ const Color aTextColor = rStyleSettings.GetFieldTextColor();
+
+ OutputDevice* pDev = rUDEvt.GetDevice();
+ Rectangle aRect = rUDEvt.GetRect();
+ USHORT nItemId = rUDEvt.GetItemId();
+ long nRectWidth = aRect.GetWidth();
+ long nRectHeight = aRect.GetHeight();
+ Size aRectSize(nRectWidth, aRect.GetHeight());
+ Point aBLPos = aRect.TopLeft();
+ Font aOldFont = pDev->GetFont();
+ Color aOldColor = pDev->GetLineColor();
+ pDev->SetLineColor(aTextColor);
+ Font aFont(OutputDevice::GetDefaultFont(
+ DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
+
+ Size aSize = aFont.GetSize();
+
+ Font aRuleFont( lcl_GetDefaultBulletFont() );
+ aSize.Height() = nRectHeight/6;
+ aRuleFont.SetSize(aSize);
+ aRuleFont.SetColor(aTextColor);
+ aRuleFont.SetFillColor(aBackColor);
+ if(nPageType == NUM_PAGETYPE_BULLET)
+ aFont = aRuleFont;
+ else if(nPageType == NUM_PAGETYPE_NUM)
+ {
+ aSize.Height() = nRectHeight/8;
+ }
+ aFont.SetColor(aTextColor);
+ aFont.SetFillColor(aBackColor);
+ aFont.SetSize( aSize );
+ pDev->SetFont(aFont);
+
+ if(!pVDev)
+ {
+ // Die Linien werden nur einmalig in das VirtualDevice gepainted
+ // nur die Gliederungspage bekommt es aktuell
+ pVDev = new VirtualDevice(*pDev);
+ pVDev->SetMapMode(pDev->GetMapMode());
+ pVDev->EnableRTL( IsRTLEnabled() );
+ pVDev->SetOutputSize( aRectSize );
+ aOrgRect = aRect;
+ pVDev->SetFillColor( aBackColor );
+ pVDev->DrawRect(aOrgRect);
+
+ if(aBackColor == aLineColor)
+ aLineColor.Invert();
+ pVDev->SetLineColor(aLineColor);
+ // Linien nur einmalig Zeichnen
+ if(nPageType != NUM_PAGETYPE_NUM)
+ {
+ Point aStart(aBLPos.X() + nRectWidth *25 / 100,0);
+ Point aEnd(aBLPos.X() + nRectWidth * 9 / 10,0);
+ for( USHORT i = 11; i < 100; i += 33)
+ {
+ aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * i / 100;
+ pVDev->DrawLine(aStart, aEnd);
+ aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * (i + 11) / 100;
+ pVDev->DrawLine(aStart, aEnd);
+ }
+ }
+ }
+ pDev->DrawOutDev( aRect.TopLeft(), aRectSize,
+ aOrgRect.TopLeft(), aRectSize,
+ *pVDev );
+ // jetzt kommt der Text
+ const OUString sValue(C2U(cValue));
+ if( NUM_PAGETYPE_SINGLENUM == nPageType ||
+ NUM_PAGETYPE_BULLET == nPageType )
+ {
+ Point aStart(aBLPos.X() + nRectWidth / 9,0);
+ for( USHORT i = 0; i < 3; i++ )
+ {
+ USHORT nY = 11 + i * 33;
+ aStart.Y() = aBLPos.Y() + nRectHeight * nY / 100;
+ String sText;
+ if(nPageType == NUM_PAGETYPE_BULLET)
+ {
+ sText = aBulletTypes[nItemId - 1];
+ aStart.Y() -= pDev->GetTextHeight()/2;
+ aStart.X() = aBLPos.X() + 5;
+ }
+ else
+ {
+ if(xFormatter.is() && aNumSettings.getLength() > nItemId - 1)
+ {
+ Sequence<PropertyValue> aLevel = aNumSettings.getConstArray()[nItemId - 1];
+ try
+ {
+ aLevel.realloc(aLevel.getLength() + 1);
+ PropertyValue& rValue = aLevel.getArray()[aLevel.getLength() - 1];
+ rValue.Name = sValue;
+ rValue.Value <<= (sal_Int32)(i + 1);
+ sText = xFormatter->makeNumberingString( aLevel, aLocale );
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("Exception in DefaultNumberingProvider::makeNumberingString");
+ }
+ }
+ // knapp neben dem linken Rand beginnen
+ aStart.X() = aBLPos.X() + 2;
+ aStart.Y() -= pDev->GetTextHeight()/2;
+ }
+ pDev->DrawText(aStart, sText);
+ }
+ }
+ else if(NUM_PAGETYPE_NUM == nPageType )
+ {
+ // Outline numbering has to be painted into the virtual device
+ // to get correct lines
+ // has to be made again
+ pVDev->DrawRect(aOrgRect);
+ long nStartX = aOrgRect.TopLeft().X();
+ long nStartY = aOrgRect.TopLeft().Y();
+
+ if(xFormatter.is() && aOutlineSettings.getLength() > nItemId - 1)
+ {
+ Reference<XIndexAccess> xLevel = aOutlineSettings.getArray()[nItemId - 1];
+ try
+ {
+ OUString sLevelTexts[5];
+ OUString sFontNames[5];
+ OUString sBulletChars[5];
+ sal_Int16 aNumberingTypes[5];
+ OUString sPrefixes[5];
+ OUString sSuffixes[5];
+ sal_Int16 aParentNumberings[5];
+
+ sal_Int32 nLevelCount = xLevel->getCount();
+ if(nLevelCount > 5)
+ nLevelCount = 5;
+ for( sal_Int32 i = 0; i < nLevelCount && i < 5; i++)
+ {
+ long nTop = nStartY + nRectHeight * (aLinesArr[2 * i + 11])/100 ;
+ Point aLeft(nStartX + nRectWidth * (aLinesArr[2 * i + 10])/ 100, nTop );
+
+ Any aLevelAny = xLevel->getByIndex(i);
+ Sequence<PropertyValue> aLevel;
+ aLevelAny >>= aLevel;
+ const PropertyValue* pValues = aLevel.getConstArray();
+ aNumberingTypes[i] = 0;
+ for(sal_Int32 nProperty = 0; nProperty < aLevel.getLength() - 1; nProperty++)
+ {
+ if(pValues[nProperty].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cNumberingType)))
+ pValues[nProperty].Value >>= aNumberingTypes[i];
+ else if(pValues[nProperty].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cBulletFontName)))
+ pValues[nProperty].Value >>= sFontNames[i];
+ else if(pValues[nProperty].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cBulletChar)))
+ pValues[nProperty].Value >>= sBulletChars[i];
+ else if(pValues[nProperty].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cPrefix)))
+ pValues[nProperty].Value >>= sPrefixes[i];
+ else if(pValues[nProperty].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cSuffix)))
+ pValues[nProperty].Value >>= sSuffixes[i];
+ else if(pValues[nProperty].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(cParentNumbering)))
+ pValues[nProperty].Value >>= aParentNumberings[i];
+ }
+ Sequence< PropertyValue > aProperties(2);
+ PropertyValue* pProperties = aProperties.getArray();
+ pProperties[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberingType"));
+ pProperties[0].Value <<= aNumberingTypes[i];
+ pProperties[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"));
+ pProperties[1].Value <<= (sal_Int32)1;
+ try
+ {
+ sLevelTexts[i] = xFormatter->makeNumberingString( aProperties, aLocale );
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("Exception in DefaultNumberingProvider::makeNumberingString");
+ }
+
+ aLeft.Y() -= (pDev->GetTextHeight()/2);
+ if(sPrefixes[i].getLength() &&
+ !sPrefixes[i].equalsAsciiL(" ", 1) &&
+ sPrefixes[i].getStr()[0] != 0)
+ {
+ pVDev->SetFont(aFont);
+ pVDev->DrawText(aLeft, sPrefixes[i]);
+ aLeft.X() += pDev->GetTextWidth(sPrefixes[i]);
+ }
+ if(aParentNumberings[i])
+ {
+ //insert old numberings here
+ sal_Int32 nStartLevel = std::min((sal_Int32)aParentNumberings[i], i);
+ for(sal_Int32 nParentLevel = i - nStartLevel; nParentLevel < i; nParentLevel++)
+ {
+ OUString sTmp(sLevelTexts[nParentLevel]);
+ sTmp += C2U(".");
+ lcl_PaintLevel(pVDev,
+ aNumberingTypes[nParentLevel],
+ sBulletChars[nParentLevel],
+ sTmp,
+ sFontNames[nParentLevel],
+ aLeft,
+ aRuleFont,
+ aFont);
+ }
+ }
+ lcl_PaintLevel(pVDev,
+ aNumberingTypes[i],
+ sBulletChars[i],
+ sLevelTexts[i],
+ sFontNames[i],
+ aLeft,
+ aRuleFont,
+ aFont);
+ if(sSuffixes[i].getLength()&&
+ !sSuffixes[i].equalsAsciiL(" ", 1) &&
+ sSuffixes[i].getStr()[0] != 0)
+ {
+ pVDev->SetFont(aFont);
+ pVDev->DrawText(aLeft, sSuffixes[i]);
+ aLeft.X() += pDev->GetTextWidth(sSuffixes[i]);
+ }
+
+ long nLineTop = nStartY + nRectHeight * aLinesArr[2 * i + 1]/100 ;
+ Point aLineLeft(aLeft.X() /*+ nStartX + nRectWidth * aLinesArr[2 * i]/ 100*/, nLineTop );
+ Point aLineRight(nStartX + nRectWidth * 90 /100, nLineTop );
+ pVDev->DrawLine(aLineLeft, aLineRight);
+ }
+
+ }
+#ifdef DBG_UTIL
+ catch(Exception&)
+ {
+ static sal_Bool bAssert = FALSE;
+ if(!bAssert)
+ {
+ DBG_ERROR("exception in ::UserDraw");
+ bAssert = sal_True;
+ }
+ }
+#else
+ catch(Exception&)
+ {
+ }
+#endif
+ }
+ pDev->DrawOutDev( aRect.TopLeft(), aRectSize,
+ aOrgRect.TopLeft(), aRectSize,
+ *pVDev );
+ }
+
+ pDev->SetFont(aOldFont);
+ pDev->SetLineColor(aOldColor);
+}
+
+/**************************************************************************/
+/* */
+/* */
+/**************************************************************************/
+
+SvxNumValueSet::SvxNumValueSet( Window* pParent, const ResId& rResId, USHORT nType ) :
+
+ ValueSet( pParent, rResId ),
+
+ aLineColor ( COL_LIGHTGRAY ),
+ nPageType ( nType ),
+ bHTMLMode ( FALSE ),
+ pVDev ( NULL )
+{
+ SetColCount( 4 );
+ SetLineCount( 2 );
+ SetStyle( GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER );
+ if(NUM_PAGETYPE_BULLET == nType)
+ {
+ for ( USHORT i = 0; i < 8; i++ )
+ {
+ InsertItem( i + 1, i );
+ SetItemText( i + 1, SVX_RESSTR( RID_SVXSTR_BULLET_DESCRIPTIONS + i ) );
+ }
+ }
+}
+
+/*-----------------08.02.97 12.38-------------------
+
+--------------------------------------------------*/
+
+ SvxNumValueSet::~SvxNumValueSet()
+{
+ delete pVDev;
+}
+/* -----------------------------30.01.01 16:24--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxNumValueSet::SetNumberingSettings(
+ const Sequence<Sequence<PropertyValue> >& aNum,
+ Reference<XNumberingFormatter>& xFormat,
+ const Locale& rLocale )
+{
+ aNumSettings = aNum;
+ xFormatter = xFormat;
+ aLocale = rLocale;
+ if(aNum.getLength() > 8)
+ SetStyle( GetStyle()|WB_VSCROLL);
+ for ( USHORT i = 0; i < aNum.getLength(); i++ )
+ {
+ InsertItem( i + 1, i );
+ if( i < 8 )
+ SetItemText( i + 1, SVX_RESSTR( RID_SVXSTR_SINGLENUM_DESCRIPTIONS + i ));
+ }
+}
+/* -----------------------------31.01.01 09:50--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxNumValueSet::SetOutlineNumberingSettings(
+ Sequence<Reference<XIndexAccess> >& rOutline,
+ Reference<XNumberingFormatter>& xFormat,
+ const Locale& rLocale)
+{
+ aOutlineSettings = rOutline;
+ xFormatter = xFormat;
+ aLocale = rLocale;
+ if(aOutlineSettings.getLength() > 8)
+ SetStyle( GetStyle() | WB_VSCROLL );
+ for ( sal_uInt16 i = 0; i < aOutlineSettings.getLength(); i++ )
+ {
+ InsertItem( i + 1, i );
+ if( i < 8 )
+ SetItemText( i + 1, SVX_RESSTR( RID_SVXSTR_OUTLINENUM_DESCRIPTIONS + i ));
+ }
+}
+
+SvxBmpNumValueSet::SvxBmpNumValueSet( Window* pParent, const ResId& rResId/*, const List& rStrNames*/ ) :
+
+ SvxNumValueSet( pParent, rResId, NUM_PAGETYPE_BMP ),
+// rStrList ( rStrNames ),
+ bGrfNotFound( FALSE )
+
+{
+ GalleryExplorer::BeginLocking(GALLERY_THEME_BULLETS);
+ SetStyle( GetStyle() | WB_VSCROLL );
+ SetLineCount( 3 );
+ aFormatTimer.SetTimeout(300);
+ aFormatTimer.SetTimeoutHdl(LINK(this, SvxBmpNumValueSet, FormatHdl_Impl));
+}
+
+/*-----------------13.02.97 09.41-------------------
+
+--------------------------------------------------*/
+
+ SvxBmpNumValueSet::~SvxBmpNumValueSet()
+{
+ GalleryExplorer::EndLocking(GALLERY_THEME_BULLETS);
+ aFormatTimer.Stop();
+}
+/*-----------------13.02.97 09.41-------------------
+
+--------------------------------------------------*/
+
+void SvxBmpNumValueSet::UserDraw( const UserDrawEvent& rUDEvt )
+{
+ SvxNumValueSet::UserDraw(rUDEvt);
+
+ Rectangle aRect = rUDEvt.GetRect();
+ OutputDevice* pDev = rUDEvt.GetDevice();
+ USHORT nItemId = rUDEvt.GetItemId();
+ Point aBLPos = aRect.TopLeft();
+
+ int nRectHeight = aRect.GetHeight();
+ Size aSize(nRectHeight/8, nRectHeight/8);
+
+ Graphic aGraphic;
+ if(!GalleryExplorer::GetGraphicObj( GALLERY_THEME_BULLETS, nItemId - 1,
+ &aGraphic, NULL))
+ {
+ bGrfNotFound = TRUE;
+ }
+ else
+ {
+ Point aPos(aBLPos.X() + 5, 0);
+ for( USHORT i = 0; i < 3; i++ )
+ {
+ USHORT nY = 11 + i * 33;
+ aPos.Y() = aBLPos.Y() + nRectHeight * nY / 100;
+ aGraphic.Draw( pDev, aPos, aSize );
+ }
+ }
+}
+
+/*-----------------14.02.97 07.34-------------------
+
+--------------------------------------------------*/
+
+IMPL_LINK(SvxBmpNumValueSet, FormatHdl_Impl, Timer*, EMPTYARG)
+{
+ // nur, wenn eine Grafik nicht da war, muss formatiert werden
+ if(bGrfNotFound)
+ {
+ bGrfNotFound = FALSE;
+ Format();
+ }
+ Invalidate();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/svxbmpnumvalueset.src b/svx/source/dialog/svxbmpnumvalueset.src
new file mode 100644
index 000000000000..ad43a5ee9ee6
--- /dev/null
+++ b/svx/source/dialog/svxbmpnumvalueset.src
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+
+String RID_SVXSTR_BULLET_DESCRIPTION_0
+{
+ Text [en-US] = "Solid small circular bullets";
+};
+String RID_SVXSTR_BULLET_DESCRIPTION_1
+{
+ Text [en-US] = "Solid large circular bullets";
+};
+String RID_SVXSTR_BULLET_DESCRIPTION_2
+{
+ Text [en-US] = "Solid diamond bullets";
+};
+String RID_SVXSTR_BULLET_DESCRIPTION_3
+{
+ Text [en-US] = "Solid large square bullets";
+};
+String RID_SVXSTR_BULLET_DESCRIPTION_4
+{
+ Text [en-US] = "Right pointing arrow bullets filled out";
+};
+String RID_SVXSTR_BULLET_DESCRIPTION_5
+{
+ Text [en-US] = "Right pointing arrow bullets";
+};
+String RID_SVXSTR_BULLET_DESCRIPTION_6
+{
+ Text [en-US] = "Check mark bullets";
+};
+String RID_SVXSTR_BULLET_DESCRIPTION_7
+{
+ Text [en-US] = "Tick mark bullets";
+};
+String RID_SVXSTR_SINGLENUM_DESCRIPTION_0
+{
+ Text [en-US] = "Number 1) 2) 3)";
+};
+String RID_SVXSTR_SINGLENUM_DESCRIPTION_1
+{
+ Text [en-US] = "Number 1. 2. 3.";
+};
+String RID_SVXSTR_SINGLENUM_DESCRIPTION_2
+{
+ Text [en-US] = "Number (1) (2) (3)";
+};
+String RID_SVXSTR_SINGLENUM_DESCRIPTION_3
+{
+ Text [en-US] = "Uppercase Roman number I. II. III.";
+};
+String RID_SVXSTR_SINGLENUM_DESCRIPTION_4
+{
+ Text [en-US] = "Uppercase letter A) B) C)";
+};
+String RID_SVXSTR_SINGLENUM_DESCRIPTION_5
+{
+ Text [en-US] = "Lowercase letter a) b) c)";
+};
+String RID_SVXSTR_SINGLENUM_DESCRIPTION_6
+{
+ Text [en-US] = "Lowercase letter (a) (b) (c)";
+};
+String RID_SVXSTR_SINGLENUM_DESCRIPTION_7
+{
+ Text [en-US] = "Lowercase Roman number i. ii. iii.";
+};
+
+String RID_SVXSTR_OUTLINENUM_DESCRIPTION_0
+{
+ Text [en-US] = "Numeric, numeric, lowercase letters, solid small circular bullet";
+};
+String RID_SVXSTR_OUTLINENUM_DESCRIPTION_1
+{
+ Text [en-US] = "Numeric, lowercase letters, solid small circular bullet";
+};
+String RID_SVXSTR_OUTLINENUM_DESCRIPTION_2
+{
+ Text [en-US] = "Numeric, lowercase letters, lowercase Roman, uppercase letters, solid small circular bullet";
+};
+String RID_SVXSTR_OUTLINENUM_DESCRIPTION_3
+{
+ Text [en-US] = "Numeric";
+};
+String RID_SVXSTR_OUTLINENUM_DESCRIPTION_4
+{
+ Text [en-US] = "Uppercase Roman, uppercase letters, lowercase Roman, lowercase letters, solid small circular bullet";
+};
+String RID_SVXSTR_OUTLINENUM_DESCRIPTION_5
+{
+ Text [en-US] = "Uppercase letters, uppercase Roman, lowercase letters, lowercase Roman, solid small circular bullet";
+};
+String RID_SVXSTR_OUTLINENUM_DESCRIPTION_6
+{
+ Text [en-US] = "Numeric with all sublevels";
+};
+String RID_SVXSTR_OUTLINENUM_DESCRIPTION_7
+{
+ Text [en-US] = "Right pointing bullet, right pointing arrow bullet, solid diamond bullet, solid small circular bullet";
+};
+
diff --git a/svx/source/dialog/svxdlg.cxx b/svx/source/dialog/svxdlg.cxx
new file mode 100644
index 000000000000..da5caf40e540
--- /dev/null
+++ b/svx/source/dialog/svxdlg.cxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svxdlg.hxx>
+
+SvxAbstractDialogFactory* SvxAbstractDialogFactory::Create()
+{
+ return dynamic_cast< SvxAbstractDialogFactory* >( VclAbstractDialogFactory::Create() );
+}
+
+SvxAbstractDialogFactory::~SvxAbstractDialogFactory()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/svxgrahicitem.cxx b/svx/source/dialog/svxgrahicitem.cxx
new file mode 100644
index 000000000000..f2e248e3388a
--- /dev/null
+++ b/svx/source/dialog/svxgrahicitem.cxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "svxgrahicitem.hxx"
+TYPEINIT1(SvxGraphicItem,SfxPoolItem);
+SvxGraphicItem::SvxGraphicItem( USHORT _nWhich, const Graphic& rGraphic )
+ : SfxPoolItem( _nWhich ), aGraphic( rGraphic )
+{
+
+}
+SvxGraphicItem::SvxGraphicItem( const SvxGraphicItem& rItem)
+ : SfxPoolItem( rItem.Which() ), aGraphic( rItem.aGraphic )
+{
+}
+
+int SvxGraphicItem::operator==( const SfxPoolItem& rItem) const
+{
+ return ((SvxGraphicItem&)rItem).aGraphic == aGraphic;
+}
+
+SfxPoolItem* SvxGraphicItem::Clone( SfxItemPool * ) const
+{
+ return new SvxGraphicItem( *this );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx
new file mode 100644
index 000000000000..c1fc7880b969
--- /dev/null
+++ b/svx/source/dialog/svxruler.cxx
@@ -0,0 +1,3961 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <string.h>
+#include <limits.h>
+#include <tools/shl.hxx>
+#include <vcl/image.hxx>
+#include <svl/eitem.hxx>
+#include <svl/rectitem.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <svl/smplhint.hxx>
+
+
+
+
+
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <svx/ruler.hxx>
+#include "rlrcitem.hxx"
+#include "rulritem.hxx"
+#include <editeng/tstpitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include "editeng/protitem.hxx"
+#include <vcl/svapp.hxx>
+#ifndef RULER_TAB_RTL
+#define RULER_TAB_RTL ((USHORT)0x0010)
+#endif
+
+// STATIC DATA -----------------------------------------------------------
+
+#define CTRL_ITEM_COUNT 14
+#define GAP 10
+#define OBJECT_BORDER_COUNT 4
+#define TAB_GAP 1
+#define INDENT_GAP 2
+#define INDENT_FIRST_LINE 4
+#define INDENT_LEFT_MARGIN 5
+#define INDENT_RIGHT_MARGIN 6
+#define INDENT_LEFT_BORDER 2
+#define INDENT_RIGHT_BORDER 3
+#define INDENT_COUNT 5 //without the first two old values
+
+#define PIXEL_H_ADJUST( l1, l2 ) PixelHAdjust(l1,l2)
+
+#ifdef DEBUGLIN
+
+inline long ToMM(Window *pWin, long lVal)
+{
+ return pWin->PixelToLogic(Size(lVal, 0), MapMode(MAP_MM)).Width();
+}
+
+void Debug_Impl(Window *pWin, SvxColumnItem& rColItem)
+{
+ String aTmp("Aktuell: ");
+ aTmp += rColItem.GetActColumn();
+ aTmp += " ColLeft: ";
+ aTmp += String(ToMM(pWin, rColItem.GetLeft()));
+ aTmp += " ColRight: ";
+ aTmp += String(ToMM(pWin, rColItem.GetRight()));
+ for(USHORT i = 0; i < rColItem.Count(); ++i) {
+ aTmp += " Start: ";
+ aTmp += String(ToMM(pWin, rColItem[i].nStart));
+ aTmp += " End: ";
+ aTmp += String(ToMM(pWin, rColItem[i].nEnd));
+ }
+
+ InfoBox(0, aTmp).Execute();
+}
+
+void Debug_Impl(Window *pWin, const SvxLongLRSpaceItem& rLRSpace)
+{
+ String aTmp("Left: ");
+ aTmp += pWin->PixelToLogic(Size(rLRSpace.GetLeft(), 0), MapMode(MAP_MM)).Width();
+ aTmp += " Right: ";
+ aTmp +=pWin->PixelToLogic(Size(rLRSpace.GetRight(), 0), MapMode(MAP_MM)).Width();
+ InfoBox(0, aTmp).Execute();
+}
+
+void Debug_Impl(Window *pWin, const SvxLongULSpaceItem& rULSpace)
+{
+ String aTmp("Upper: ");
+ aTmp += pWin->PixelToLogic(Size(rULSpace.GetUpper(), 0), MapMode(MAP_MM)).Width();
+ aTmp += " Lower: ";
+ aTmp += pWin->PixelToLogic(Size(rULSpace.GetLower(), 0), MapMode(MAP_MM)).Width();
+
+ InfoBox(0, aTmp).Execute();
+}
+
+void DebugTabStops_Impl(const SvxTabStopItem& rTabs)
+{
+ String aTmp("Tabs: ");
+
+ // Def Tabs loeschen
+ for(USHORT i = 0; i < rTabs.Count(); ++i)
+ {
+ aTmp += String(rTabs[i].GetTabPos() / 56);
+ aTmp += " : ";
+ }
+ InfoBox(0, aTmp).Execute();
+}
+
+void DebugParaMargin_Impl(const SvxLRSpaceItem& rLRSpace)
+{
+ String aTmp("ParaLeft: ");
+ aTmp += rLRSpace.GetTxtLeft() / 56;
+ aTmp += " ParaRight: ";
+ aTmp += rLRSpace.GetRight() / 56;
+ aTmp += " FLI: ";
+ aTmp += rLRSpace.GetTxtFirstLineOfst() / 56;
+ InfoBox(0, aTmp).Execute();
+}
+
+#endif // DEBUGLIN
+#ifdef DEBUG_RULER
+#include <vcl/svapp.hxx>
+#include <vcl/lstbox.hxx>
+class RulerDebugWindow : public Window
+{
+ ListBox aBox;
+public:
+ RulerDebugWindow(Window* pParent) :
+ Window(pParent, WB_BORDER|WB_SIZEMOVE|WB_DIALOGCONTROL|WB_CLIPCHILDREN|WB_SYSTEMWINDOW),
+ aBox(this, WB_BORDER)
+ {
+ Size aOutput(200, 400);
+ SetOutputSizePixel(aOutput);
+ aBox.SetSizePixel(aOutput);
+ aBox.Show();
+ Show();
+ Size aParentSize(pParent->GetOutputSizePixel());
+ Size aOwnSize(GetSizePixel());
+ aParentSize.Width() -= aOwnSize.Width();
+ aParentSize.Height() -= aOwnSize.Height();
+ SetPosPixel(Point(aParentSize.Width(), aParentSize.Height()));
+ }
+ ~RulerDebugWindow();
+
+ ListBox& GetLBox() {return aBox;}
+ static void AddDebugText(const sal_Char* pDescription, const String& rText );
+};
+static RulerDebugWindow* pDebugWindow = 0;
+
+RulerDebugWindow::~RulerDebugWindow()
+{
+ pDebugWindow = 0;
+}
+void RulerDebugWindow::AddDebugText(const sal_Char* pDescription, const String& rText )
+{
+ if(!pDebugWindow)
+ {
+ Window* pParent = Application::GetFocusWindow();
+ while(pParent->GetParent())
+ pParent = pParent->GetParent();
+ pDebugWindow = new RulerDebugWindow(pParent);
+ }
+ String sContent(String::CreateFromAscii(pDescription));
+ sContent += rText;
+ USHORT nPos = pDebugWindow->GetLBox().InsertEntry(sContent);
+ pDebugWindow->GetLBox().SelectEntryPos(nPos);
+ pDebugWindow->GrabFocus();
+}
+
+#define ADD_DEBUG_TEXT(cDescription, sValue) \
+ RulerDebugWindow::AddDebugText(cDescription, sValue);
+
+#define REMOVE_DEBUG_WINDOW \
+ delete pDebugWindow; \
+ pDebugWindow = 0;
+
+#else
+#define ADD_DEBUG_TEXT(cDescription, sValue)
+#define REMOVE_DEBUG_WINDOW
+#endif
+
+struct SvxRuler_Impl {
+ USHORT *pPercBuf;
+ USHORT *pBlockBuf;
+ USHORT nPercSize;
+ long nTotalDist;
+ long lOldWinPos;
+ long lMaxLeftLogic;
+ long lMaxRightLogic;
+ long lLastLMargin;
+ long lLastRMargin;
+ SvxProtectItem aProtectItem;
+ SfxBoolItem* pTextRTLItem;
+ USHORT nControlerItems;
+ USHORT nIdx;
+ USHORT nColLeftPix, nColRightPix; // Pixelwerte fuer linken / rechten Rand
+ // bei Spalten; gepuffert, um Umrechenfehler
+ // zu vermeiden.
+ // Muesste vielleicht fuer weitere Werte
+ // aufgebohrt werden
+ BOOL bIsTableRows : 1; // pColumnItem contains table rows instead of columns
+ //#i24363# tab stops relative to indent
+ BOOL bIsTabsRelativeToIndent : 1; // Tab stops relative to paragraph indent?
+ SvxRuler_Impl() :
+ pPercBuf(0), pBlockBuf(0),
+ nPercSize(0), nTotalDist(0),
+ lOldWinPos(0),
+ lMaxLeftLogic(0), lMaxRightLogic(0),
+ lLastLMargin(0), lLastRMargin(0),
+ aProtectItem(SID_RULER_PROTECT),
+ pTextRTLItem(0), nControlerItems(0),
+ nIdx(0),
+ nColLeftPix(0), nColRightPix(0),
+
+ bIsTableRows(FALSE),
+ bIsTabsRelativeToIndent(TRUE)
+ {
+ }
+ ~SvxRuler_Impl()
+ {
+ nPercSize = 0; nTotalDist = 0;
+ delete[] pPercBuf; delete[] pBlockBuf; pPercBuf = 0;
+ delete pTextRTLItem;
+ }
+ void SetPercSize(USHORT nSize);
+
+};
+
+
+
+void SvxRuler_Impl::SetPercSize(USHORT nSize)
+{
+ if(nSize > nPercSize)
+ {
+ delete[] pPercBuf;
+ delete[] pBlockBuf;
+ pPercBuf = new USHORT[nPercSize = nSize];
+ pBlockBuf = new USHORT[nPercSize = nSize];
+ }
+ size_t nSize2 = sizeof(USHORT) * nPercSize;
+ memset(pPercBuf, 0, nSize2);
+ memset(pBlockBuf, 0, nSize2);
+}
+
+
+// Konstruktor des Lineals
+
+// SID_ATTR_ULSPACE, SID_ATTR_LRSPACE
+// erwartet als Parameter SvxULSpaceItem f"ur Seitenr"ander
+// (entweder links/rechts oder oben/unten)
+// Lineal: SetMargin1, SetMargin2
+
+// SID_RULER_PAGE_POS
+// erwartet als Parameter Anfangswert der Seite sowie Seitenbreite
+// Lineal: SetPagePos
+
+// SID_ATTR_TABSTOP
+// erwartet: SvxTabStopItem
+// Lineal: SetTabs
+
+// SID_ATTR_PARA_LRSPACE
+// linker, rechter Absatzrand bei H-Lineal
+// Lineal: SetIndents
+
+// SID_RULER_BORDERS
+// Tabellenraender, Spalten
+// erwartet: so etwas wie SwTabCols
+// Lineal: SetBorders
+
+
+SvxRuler::SvxRuler
+(
+ Window* pParent, // StarView Parent
+ Window* pWin, // Ausgabefenster; wird fuer Umrechnung logische
+ // Einheiten <-> Pixel verwendet
+ USHORT flags, // Anzeige Flags, siehe ruler.hxx
+ SfxBindings &rBindings, // zugeordnete Bindings
+ WinBits nWinStyle // StarView WinBits
+)
+: Ruler(pParent, nWinStyle),
+ pCtrlItem(new SvxRulerItem *[CTRL_ITEM_COUNT]),
+ pLRSpaceItem(0),
+ pMinMaxItem(0),
+ pULSpaceItem(0),
+ pTabStopItem(0),
+ pParaItem(0),
+ pParaBorderItem(0),
+ pPagePosItem(0),
+ pColumnItem(0),
+ pObjectItem(0),
+ pEditWin(pWin),
+ pRuler_Imp(new SvxRuler_Impl),
+ bAppSetNullOffset(FALSE), //Wird der 0-Offset des Lineals
+ //durch die appl. gesetzt?
+ lLogicNullOffset(0),
+ lAppNullOffset(LONG_MAX),
+ lMinFrame(5),
+ lInitialDragPos(0),
+ nFlags(flags),
+ nDragType(NONE),
+ nDefTabType(RULER_TAB_LEFT),
+ nTabCount(0),
+ nTabBufSize(0),
+ lDefTabDist(50),
+ lTabPos(-1),
+ pTabs(0),
+ pIndents(0),
+ pBorders(new RulerBorder[1]), //wg 1 Spaltiger Tabellen
+ nBorderCount(0),
+ pObjectBorders(0),
+ pBindings(&rBindings),
+ nDragOffset(0),
+ nMaxLeft(0),
+ nMaxRight(0),
+ bValid(FALSE),
+ bListening(FALSE),
+ bActive(TRUE)
+
+/*
+ [Beschreibung]
+
+ ctor;
+ Datenpuffer initialisieren; ControllerItems werden erzeugt
+
+*/
+{
+ memset(pCtrlItem, 0, sizeof(SvxRulerItem *) * CTRL_ITEM_COUNT);
+
+ rBindings.EnterRegistrations();
+
+ // Unterstuetzte Items anlegen
+ USHORT i = 0;
+ // Seitenraender
+
+ pCtrlItem[i++] = new SvxRulerItem(SID_RULER_LR_MIN_MAX, *this, rBindings);
+ if((nWinStyle & WB_VSCROLL) == WB_VSCROLL)
+ {
+ bHorz = FALSE;
+ pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_LONG_ULSPACE, *this, rBindings);
+ }
+ else
+ {
+ bHorz = TRUE;
+ pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_LONG_LRSPACE, *this, rBindings);
+ }
+
+ // Seitenposition
+ pCtrlItem[i++] = new SvxRulerItem(SID_RULER_PAGE_POS, *this, rBindings);
+
+ if((nFlags & SVXRULER_SUPPORT_TABS) == SVXRULER_SUPPORT_TABS)
+ {
+ USHORT nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
+ pCtrlItem[i++] = new SvxRulerItem(nTabStopId, *this, rBindings);
+ SetExtraType(RULER_EXTRA_TAB, nDefTabType);
+ }
+
+
+ if(0 != (nFlags & (SVXRULER_SUPPORT_PARAGRAPH_MARGINS |SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL)))
+ {
+ if(bHorz)
+ pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE, *this, rBindings);
+ else
+ pCtrlItem[i++] = new SvxRulerItem(SID_ATTR_PARA_LRSPACE_VERTICAL, *this, rBindings);
+ pIndents = new RulerIndent[5+INDENT_GAP];
+ memset(pIndents, 0, sizeof(RulerIndent)*(3+INDENT_GAP));
+ pIndents[0].nStyle = RULER_STYLE_DONTKNOW;
+ pIndents[1].nStyle = RULER_STYLE_DONTKNOW;
+ pIndents[INDENT_FIRST_LINE].nStyle = RULER_INDENT_TOP;
+ pIndents[INDENT_LEFT_MARGIN].nStyle = RULER_INDENT_BOTTOM;
+ pIndents[INDENT_RIGHT_MARGIN].nStyle = RULER_INDENT_BOTTOM;
+ pIndents[INDENT_LEFT_BORDER].nStyle = RULER_INDENT_BORDER;
+ pIndents[INDENT_RIGHT_BORDER].nStyle = RULER_INDENT_BORDER;
+ for(USHORT nIn = 0; nIn < 7; nIn++)
+ pIndents[nIn].nPos = 0;
+ }
+
+ if((nFlags & SVXRULER_SUPPORT_BORDERS) == SVXRULER_SUPPORT_BORDERS)
+ {
+ pCtrlItem[i++] = new SvxRulerItem(bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL, *this, rBindings);
+ pCtrlItem[i++] = new SvxRulerItem(bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL, *this, rBindings);
+ }
+
+ pCtrlItem[i++] = new SvxRulerItem(SID_RULER_TEXT_RIGHT_TO_LEFT, *this, rBindings);
+
+ if((nFlags & SVXRULER_SUPPORT_OBJECT) == SVXRULER_SUPPORT_OBJECT)
+ {
+ pCtrlItem[i++] = new SvxRulerItem(SID_RULER_OBJECT, *this, rBindings );
+ pObjectBorders = new RulerBorder[OBJECT_BORDER_COUNT];
+ size_t nSize = sizeof( RulerBorder ) * OBJECT_BORDER_COUNT;
+ memset(pObjectBorders, 0, nSize);
+ for(USHORT nBorder = 0; nBorder < OBJECT_BORDER_COUNT; ++nBorder)
+ {
+ pObjectBorders[nBorder].nPos = 0;
+ pObjectBorders[nBorder].nWidth = 0;
+ pObjectBorders[nBorder].nStyle = RULER_BORDER_MOVEABLE;
+ }
+ }
+
+ pCtrlItem[i++] = new SvxRulerItem( SID_RULER_PROTECT, *this, rBindings );
+ pCtrlItem[i++] = new SvxRulerItem(SID_RULER_BORDER_DISTANCE, *this, rBindings);
+ pRuler_Imp->nControlerItems=i;
+
+ if((nFlags & SVXRULER_SUPPORT_SET_NULLOFFSET) ==
+ SVXRULER_SUPPORT_SET_NULLOFFSET)
+ SetExtraType(RULER_EXTRA_NULLOFFSET, 0);
+
+ rBindings.LeaveRegistrations();
+}
+
+
+__EXPORT SvxRuler::~SvxRuler()
+/*
+ [Beschreibung]
+
+ Destruktor Lineal
+ Freigabe interner Puffer
+
+
+*/
+{
+ REMOVE_DEBUG_WINDOW
+ if(bListening)
+ EndListening(*pBindings);
+
+ pBindings->EnterRegistrations();
+
+ for(USHORT i = 0; i < CTRL_ITEM_COUNT && pCtrlItem[i]; ++i)
+ delete pCtrlItem[i];
+ delete[] pCtrlItem;
+
+ delete pLRSpaceItem;
+ delete pMinMaxItem;
+ delete pULSpaceItem;
+ delete pTabStopItem;
+ delete pParaItem;
+ delete pParaBorderItem;
+ delete pPagePosItem;
+ delete pColumnItem;
+ delete pObjectItem;
+ delete[] pIndents;
+ delete[] pBorders;
+ delete[] pObjectBorders;
+ delete[] pTabs;
+ delete pRuler_Imp;
+
+ pBindings->LeaveRegistrations();
+}
+
+/*
+
+ [Beschreibung]
+
+ Interne Umrechenroutinen
+
+*/
+
+long SvxRuler::ConvertHPosPixel(long nVal) const
+{
+ return pEditWin->LogicToPixel(Size(nVal, 0)).Width();
+}
+
+long SvxRuler::ConvertVPosPixel(long nVal) const
+{
+ return pEditWin->LogicToPixel(Size(0, nVal)).Height();
+}
+
+long SvxRuler::ConvertHSizePixel(long nVal) const
+{
+ return pEditWin->LogicToPixel(Size(nVal, 0)).Width();
+}
+
+long SvxRuler::ConvertVSizePixel(long nVal) const
+{
+ return pEditWin->LogicToPixel(Size(0, nVal)).Height();
+}
+
+long SvxRuler::ConvertPosPixel(long nVal) const
+{
+ return bHorz ? ConvertHPosPixel(nVal): ConvertVPosPixel(nVal);
+}
+
+long SvxRuler::ConvertSizePixel(long nVal) const
+{
+ return bHorz? ConvertHSizePixel(nVal): ConvertVSizePixel(nVal);
+}
+
+
+inline long SvxRuler::ConvertHPosLogic(long nVal) const
+{
+ return pEditWin->PixelToLogic(Size(nVal, 0)).Width();
+}
+
+inline long SvxRuler::ConvertVPosLogic(long nVal) const
+{
+ return pEditWin->PixelToLogic(Size(0, nVal)).Height();
+}
+
+inline long SvxRuler::ConvertHSizeLogic(long nVal) const
+{
+ return pEditWin->PixelToLogic(Size(nVal, 0)).Width();
+}
+
+inline long SvxRuler::ConvertVSizeLogic(long nVal) const
+{
+ return pEditWin->PixelToLogic(Size(0, nVal)).Height();
+}
+
+inline long SvxRuler::ConvertPosLogic(long nVal) const
+{
+ return bHorz? ConvertHPosLogic(nVal): ConvertVPosLogic(nVal);
+}
+
+inline long SvxRuler::ConvertSizeLogic(long nVal) const
+{
+ return bHorz? ConvertHSizeLogic(nVal): ConvertVSizeLogic(nVal);
+}
+
+long SvxRuler::PixelHAdjust(long nVal, long nValOld) const
+{
+ if(ConvertHSizePixel(nVal)!=ConvertHSizePixel(nValOld))
+ return nVal;
+ else
+ return nValOld;
+}
+
+long SvxRuler::PixelVAdjust(long nVal, long nValOld) const
+{
+ if(ConvertVSizePixel(nVal)!=ConvertVSizePixel(nValOld))
+ return nVal;
+ else
+ return nValOld;
+}
+
+long SvxRuler::PixelAdjust(long nVal, long nValOld) const
+{
+ if(ConvertSizePixel(nVal)!=ConvertSizePixel(nValOld))
+ return nVal;
+ else
+ return nValOld;
+}
+
+
+inline USHORT SvxRuler::GetObjectBordersOff(USHORT nIdx) const
+{
+ return bHorz? nIdx: nIdx + 2;
+}
+
+
+
+void SvxRuler::UpdateFrame()
+
+/*
+ [Beschreibung]
+
+ Linken, oberen Rand aktualisieren
+ Items werden in die Darstellung des Lineals uebersetzt.
+
+*/
+
+{
+ const USHORT nMarginStyle =
+ ( pRuler_Imp->aProtectItem.IsSizeProtected() ||
+ pRuler_Imp->aProtectItem.IsPosProtected() ) ?
+ 0 : RULER_MARGIN_SIZEABLE;
+
+ if(pLRSpaceItem && pPagePosItem)
+ {
+ // wenn keine Initialisierung durch App Defaultverhalten
+ const long nOld = lLogicNullOffset;
+ lLogicNullOffset = pColumnItem?
+ pColumnItem->GetLeft(): pLRSpaceItem->GetLeft();
+ if(bAppSetNullOffset)
+ lAppNullOffset += lLogicNullOffset - nOld;
+ if(!bAppSetNullOffset || lAppNullOffset == LONG_MAX)
+ {
+ Ruler::SetNullOffset(ConvertHPosPixel(lLogicNullOffset));
+ SetMargin1( 0, nMarginStyle );
+ lAppNullOffset = 0;
+ }
+ else
+ SetMargin1( ConvertHPosPixel( lAppNullOffset ), nMarginStyle );
+ long lRight = 0;
+ // bei Tabelle rechten Rand der Tabelle auswerten
+ if(pColumnItem && pColumnItem->IsTable())
+ lRight = pColumnItem->GetRight();
+ else
+ lRight = pLRSpaceItem->GetRight();
+
+ ULONG aWidth=
+ ConvertHPosPixel(pPagePosItem->GetWidth() - lRight -
+ lLogicNullOffset + lAppNullOffset);
+ SetMargin2( aWidth, nMarginStyle );
+ }
+ else
+ if(pULSpaceItem && pPagePosItem)
+ {
+ // Nullpunkt aus oberem Rand des umgebenden Rahmens
+ const long nOld = lLogicNullOffset;
+ lLogicNullOffset = pColumnItem?
+ pColumnItem->GetLeft(): pULSpaceItem->GetUpper();
+ if(bAppSetNullOffset)
+ lAppNullOffset += lLogicNullOffset - nOld;
+ if(!bAppSetNullOffset || lAppNullOffset == LONG_MAX) {
+ Ruler::SetNullOffset(ConvertVPosPixel(lLogicNullOffset));
+ lAppNullOffset = 0;
+ SetMargin1( 0, nMarginStyle );
+ }
+ else
+ SetMargin1( ConvertVPosPixel( lAppNullOffset ),nMarginStyle );
+
+ long lLower = pColumnItem ?
+ pColumnItem->GetRight() : pULSpaceItem->GetLower();
+
+ SetMargin2(ConvertVPosPixel(pPagePosItem->GetHeight() - lLower -
+ lLogicNullOffset + lAppNullOffset),
+ nMarginStyle );
+ }
+ else
+ {
+ // schaltet die Anzeige aus
+ SetMargin1();
+ SetMargin2();
+ }
+ if(pColumnItem)
+ {
+ pRuler_Imp->nColLeftPix = (USHORT) ConvertSizePixel(pColumnItem->GetLeft());
+ pRuler_Imp->nColRightPix = (USHORT) ConvertSizePixel(pColumnItem->GetRight());
+ }
+
+}
+
+void SvxRuler::MouseMove( const MouseEvent& rMEvt )
+{
+ if( bActive )
+ {
+ pBindings->Update( SID_RULER_LR_MIN_MAX );
+ pBindings->Update( SID_ATTR_LONG_ULSPACE );
+ pBindings->Update( SID_ATTR_LONG_LRSPACE );
+ pBindings->Update( SID_RULER_PAGE_POS );
+ pBindings->Update( bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL);
+ pBindings->Update( bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL);
+ pBindings->Update( bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
+ pBindings->Update( bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL);
+ pBindings->Update( SID_RULER_OBJECT );
+ pBindings->Update( SID_RULER_PROTECT );
+ }
+ Ruler::MouseMove( rMEvt );
+}
+void SvxRuler::StartListening_Impl()
+{
+ if(!bListening)
+ {
+ bValid = FALSE;
+ StartListening(*pBindings);
+ bListening = TRUE;
+ }
+}
+
+void SvxRuler::UpdateFrame
+(
+ const SvxLongLRSpaceItem *pItem // neuer Wert LRSpace
+)
+
+/*
+ [Beschreibung]
+
+ Neuen Wert fuer LRSpace merken; alten gfs. loeschen
+
+*/
+
+{
+ if(bActive)
+ {
+ delete pLRSpaceItem; pLRSpaceItem = 0;
+ if(pItem)
+ pLRSpaceItem = new SvxLongLRSpaceItem(*pItem);
+ StartListening_Impl();
+ }
+}
+
+
+void SvxRuler::UpdateFrameMinMax
+(
+ const SfxRectangleItem *pItem // Werte fuer MinMax
+)
+
+/*
+ [Beschreibung]
+
+ Neuen Wert fuer MinMax setzen; alten gfs. loeschen
+
+*/
+
+{
+ if(bActive)
+ {
+ delete pMinMaxItem; pMinMaxItem = 0;
+ if(pItem)
+ pMinMaxItem = new SfxRectangleItem(*pItem);
+ }
+}
+
+
+void SvxRuler::UpdateFrame
+(
+ const SvxLongULSpaceItem *pItem // neuer Wert
+)
+
+/*
+ [Beschreibung]
+
+ Rechten / unteren Rand aktualisieren
+
+*/
+
+
+{
+ if(bActive && !bHorz)
+ {
+ delete pULSpaceItem; pULSpaceItem = 0;
+ if(pItem)
+ pULSpaceItem = new SvxLongULSpaceItem(*pItem);
+ StartListening_Impl();
+ }
+}
+
+void SvxRuler::Update( const SvxProtectItem* pItem )
+{
+ if( pItem ) pRuler_Imp->aProtectItem = *pItem;
+}
+/* -----------------------------22.08.2002 13:10------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxRuler::UpdateTextRTL(const SfxBoolItem* pItem)
+{
+ if(bActive && bHorz)
+ {
+ delete pRuler_Imp->pTextRTLItem; pRuler_Imp->pTextRTLItem = 0;
+ if(pItem)
+ pRuler_Imp->pTextRTLItem = new SfxBoolItem(*pItem);
+ SetTextRTL(pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue());
+ StartListening_Impl();
+ }
+}
+
+void SvxRuler::Update
+(
+ const SvxColumnItem *pItem, // neuer Wert
+ USHORT nSID //Slot Id to identify NULL items
+)
+
+/*
+ [Beschreibung]
+
+ Neuen Wert fuer Spaltendarstellung setzen
+
+*/
+
+{
+ if(bActive)
+ {
+ if(pItem)
+ {
+ delete pColumnItem; pColumnItem = 0;
+ pRuler_Imp->bIsTableRows = (pItem->Which() == SID_RULER_ROWS || pItem->Which() == SID_RULER_ROWS_VERTICAL);
+ pColumnItem = new SvxColumnItem(*pItem);
+ if(!bHorz && !pRuler_Imp->bIsTableRows)
+ pColumnItem->SetWhich(SID_RULER_BORDERS_VERTICAL);
+ }
+ else if(pColumnItem && pColumnItem->Which() == nSID)
+ //there are two groups of column items table/frame columns and table rows
+ //both can occur in vertical or horizontal mode
+ //the horizontal ruler handles the SID_RULER_BORDERS and SID_RULER_ROWS_VERTICAL
+ //and the vertical handles SID_RULER_BORDERS_VERTICAL and SID_RULER_ROWS
+ //if pColumnItem is already set with one of the ids then a NULL pItem argument
+ //must not delete it
+ {
+ delete pColumnItem; pColumnItem = 0;
+ pRuler_Imp->bIsTableRows = FALSE;
+ }
+ StartListening_Impl();
+ }
+}
+
+
+void SvxRuler::UpdateColumns()
+/*
+ [Beschreibung]
+
+ Anzeige der Spaltendarstellung aktualisieren
+
+*/
+{
+ if(pColumnItem && pColumnItem->Count() > 1)
+ {
+ if( nBorderCount < pColumnItem->Count())
+ {
+ delete[] pBorders;
+ nBorderCount = pColumnItem->Count();
+ pBorders = new RulerBorder[nBorderCount];
+ }
+ USHORT _nFlags = RULER_BORDER_VARIABLE;
+ BOOL bProtectColumns =
+ pRuler_Imp->aProtectItem.IsSizeProtected() ||
+ pRuler_Imp->aProtectItem.IsPosProtected();
+ if( !bProtectColumns )
+ _nFlags |= RULER_BORDER_MOVEABLE;
+ if( pColumnItem->IsTable() )
+ _nFlags |= RULER_BORDER_TABLE;
+ else
+ if ( !bProtectColumns )
+ _nFlags |= RULER_BORDER_SIZEABLE;
+
+ USHORT nBorders = pColumnItem->Count();
+ if(!pRuler_Imp->bIsTableRows)
+ --nBorders;
+ for(USHORT i = 0; i < nBorders; ++i)
+ {
+ pBorders[i].nStyle = _nFlags;
+ if(!(*pColumnItem)[i].bVisible)
+ pBorders[i].nStyle |= RULER_STYLE_INVISIBLE;
+ pBorders[i].nPos =
+ ConvertPosPixel((*pColumnItem)[i].nEnd + lAppNullOffset);
+ if(pColumnItem->Count() == i + 1)
+ {
+ //with table rows the end of the table is contained in the
+ //column item but it has no width!
+ pBorders[i].nWidth = 0;
+ }
+ else
+ {
+ pBorders[i].nWidth =
+ ConvertSizePixel((*pColumnItem)[i+1].nStart -
+ (*pColumnItem)[i].nEnd);
+ }
+ pBorders[i].nMinPos =
+ ConvertPosPixel((*pColumnItem)[i].nEndMin + lAppNullOffset);
+ pBorders[i].nMaxPos =
+ ConvertPosPixel((*pColumnItem)[i].nEndMax + lAppNullOffset);
+ }
+ SetBorders(pColumnItem->Count()-1, pBorders);
+ }
+ else
+ {
+ SetBorders();
+ }
+}
+
+
+void SvxRuler::UpdateObject()
+
+/*
+ [Beschreibung]
+
+ Anzeige der Objektdarstellung aktualisieren
+
+*/
+
+{
+ if(pObjectItem)
+ {
+ DBG_ASSERT(pObjectBorders, "kein Buffer");
+ // !! zum Seitenrand
+ long nMargin = pLRSpaceItem? pLRSpaceItem->GetLeft(): 0;
+ pObjectBorders[0].nPos =
+ ConvertPosPixel(pObjectItem->GetStartX() -
+ nMargin + lAppNullOffset);
+ pObjectBorders[1].nPos =
+ ConvertPosPixel(pObjectItem->GetEndX() - nMargin + lAppNullOffset);
+ nMargin = pULSpaceItem? pULSpaceItem->GetUpper(): 0;
+ pObjectBorders[2].nPos =
+ ConvertPosPixel(pObjectItem->GetStartY() -
+ nMargin + lAppNullOffset);
+ pObjectBorders[3].nPos =
+ ConvertPosPixel(pObjectItem->GetEndY() - nMargin + lAppNullOffset);
+
+ const USHORT nOff = GetObjectBordersOff(0);
+ SetBorders(2, pObjectBorders + nOff);
+ }
+ else
+ {
+ SetBorders();
+ }
+}
+
+
+void SvxRuler::UpdatePara()
+
+/*
+ [Beschreibung]
+
+ Anzeige der Absatzeinzuege aktualisieren:
+ Linken Rand, Erstzeileneinzug, rechten Rand Absatz aktualisieren
+ pIndents[0] = Buffer fuer alten Einzug
+ pIndents[1] = Buffer fuer alten Einzug
+ pIndents[INDENT_FIRST_LINE] = Erstzeileneinzug
+ pIndents[3] = linker Rand
+ pIndents[4] = rechter Rand
+ pIndents[5] = left border distance
+ pIndents[6] = right border distance
+
+*/
+
+{
+ // Abhaengigkeit zu PagePosItem
+ if(pParaItem && pPagePosItem && !pObjectItem)
+ {
+ BOOL bRTLText = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
+ // Erstzeileneinzug, ist negativ zum linken Absatzrand
+ long nLeftFrameMargin = GetLeftFrameMargin();
+ long nRightFrameMargin = GetRightFrameMargin();
+ if(bRTLText)
+ pIndents[INDENT_FIRST_LINE].nPos =
+ ConvertHPosPixel(
+ nRightFrameMargin -
+ pParaItem->GetTxtLeft() -
+ pParaItem->GetTxtFirstLineOfst() + lAppNullOffset );
+ else
+ pIndents[INDENT_FIRST_LINE].nPos =
+ ConvertHPosPixel(
+ nLeftFrameMargin +
+ pParaItem->GetTxtLeft() +
+ pParaItem->GetTxtFirstLineOfst() +
+ lAppNullOffset);
+ if( pParaItem->IsAutoFirst() )
+ pIndents[INDENT_FIRST_LINE].nStyle |= RULER_STYLE_INVISIBLE;
+ else
+ pIndents[INDENT_FIRST_LINE].nStyle &= ~RULER_STYLE_INVISIBLE;
+
+ if(bRTLText)
+ {
+ // left margin
+ pIndents[INDENT_LEFT_MARGIN].nPos =
+ ConvertHPosPixel(
+ nRightFrameMargin -
+ pParaItem->GetTxtLeft() + lAppNullOffset);
+ // right margin
+ pIndents[INDENT_RIGHT_MARGIN].nPos =
+ ConvertHPosPixel(
+ nLeftFrameMargin +
+ pParaItem->GetRight() + lAppNullOffset);
+ }
+ else
+ {
+ // linker Rand
+ pIndents[INDENT_LEFT_MARGIN].nPos =
+ ConvertHPosPixel(
+ nLeftFrameMargin +
+ pParaItem->GetTxtLeft() + lAppNullOffset);
+ // rechter Rand, immer negativ zum rechten Rand des umgebenden Frames
+ pIndents[INDENT_RIGHT_MARGIN].nPos =
+ ConvertHPosPixel(
+ nRightFrameMargin -
+ pParaItem->GetRight() + lAppNullOffset);
+ }
+ if(pParaBorderItem)
+ {
+ pIndents[INDENT_LEFT_BORDER].nPos =
+ ConvertHPosPixel( nLeftFrameMargin + lAppNullOffset);
+ pIndents[INDENT_RIGHT_BORDER].nPos =
+ ConvertHPosPixel(nRightFrameMargin - lAppNullOffset);
+ pIndents[INDENT_LEFT_BORDER].nStyle = pIndents[INDENT_RIGHT_BORDER].nStyle &= ~RULER_STYLE_INVISIBLE;
+ }
+ else
+ pIndents[INDENT_LEFT_BORDER].nStyle = pIndents[INDENT_RIGHT_BORDER].nStyle |= RULER_STYLE_INVISIBLE;
+
+ SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
+ }
+ else
+ {
+ if(pIndents)
+ {
+ pIndents[INDENT_FIRST_LINE].nPos =
+ pIndents[INDENT_LEFT_MARGIN].nPos =
+ pIndents[INDENT_RIGHT_MARGIN].nPos = 0;
+ }
+ SetIndents(); // ausschalten
+ }
+}
+
+
+void SvxRuler::UpdatePara
+(
+ const SvxLRSpaceItem *pItem // neuer Wert Absatzeinzuege
+)
+
+/*
+ [Beschreibung]
+
+ Neuen Wert Absatzeinzuege merken
+*/
+
+{
+ if(bActive)
+ {
+ delete pParaItem; pParaItem = 0;
+ if(pItem)
+ pParaItem = new SvxLRSpaceItem(*pItem);
+ StartListening_Impl();
+ }
+}
+void SvxRuler::UpdateParaBorder(const SvxLRSpaceItem * pItem )
+/*
+ [Description]
+ Border distance
+*/
+
+{
+ if(bActive)
+ {
+ delete pParaBorderItem; pParaBorderItem = 0;
+ if(pItem)
+ pParaBorderItem = new SvxLRSpaceItem(*pItem);
+ StartListening_Impl();
+ }
+}
+
+
+void SvxRuler::UpdatePage()
+
+/*
+ [Beschreibung]
+
+ Anzeige von Postion und Breite der Seite aktualisieren
+
+*/
+
+{
+ if(pPagePosItem)
+ {
+ // alle Objekte werden automatisch angepasst
+ if(bHorz)
+ SetPagePos(
+ pEditWin->LogicToPixel(pPagePosItem->GetPos()).X(),
+ pEditWin->LogicToPixel(Size(pPagePosItem->GetWidth(),0)).
+ Width());
+ else
+ SetPagePos(
+ pEditWin->LogicToPixel(pPagePosItem->GetPos()).Y(),
+ pEditWin->LogicToPixel(Size(0, pPagePosItem->GetHeight())).
+ Height());
+ if(bAppSetNullOffset)
+ SetNullOffset(ConvertSizePixel(-lAppNullOffset + lLogicNullOffset));
+ }
+ else
+ SetPagePos();
+
+ long lPos = 0;
+ Point aOwnPos = GetPosPixel();
+ Point aEdtWinPos = pEditWin->GetPosPixel();
+ if( Application::GetSettings().GetLayoutRTL() && bHorz )
+ {
+ //#i73321# in RTL the window and the ruler is not mirrored but the
+ // influence of the vertical ruler is inverted
+ Size aOwnSize = GetSizePixel();
+ Size aEdtWinSize = pEditWin->GetSizePixel();
+ lPos = aOwnSize.Width() - aEdtWinSize.Width();
+ lPos -= (aEdtWinPos - aOwnPos).X();
+ }
+ else
+ {
+ Point aPos(aEdtWinPos - aOwnPos);
+ lPos= bHorz ? aPos.X() : aPos.Y();
+ }
+
+// Leider bekommen wir den Offset des Editfensters zum Lineal nie
+// per Statusmeldung. Also setzen wir ihn selbst, wenn noetig.
+
+ if(lPos!=pRuler_Imp->lOldWinPos)
+ {
+ pRuler_Imp->lOldWinPos=lPos;
+ SetWinPos(lPos);
+ }
+}
+
+
+void SvxRuler::Update
+(
+ const SvxPagePosSizeItem *pItem // neuer Wert Seitenattribute
+)
+
+/*
+ [Beschreibung]
+
+ Neuen Wert Seitenattribute merken
+
+*/
+
+{
+ if(bActive)
+ {
+ delete pPagePosItem; pPagePosItem = 0;
+ if(pItem)
+ pPagePosItem = new SvxPagePosSizeItem(*pItem);
+ StartListening_Impl();
+ }
+}
+
+
+//
+
+void SvxRuler::SetDefTabDist
+(
+ long l // Neuer Abstand fuer DefaultTabs in App-Metrik
+)
+
+/*
+ [Beschreibung]
+
+ Neuer Abstand fuer DefaultTabs wird gesetzt
+
+*/
+
+{
+
+ lDefTabDist = l;
+ UpdateTabs();
+}
+
+
+long SvxRuler::GetDefTabDist() const
+
+/*
+ [Beschreibung]
+
+ Wert fuer DefaultTabs erfragen (wird in App.-Methik geliefert)
+
+*/
+
+{
+ return lDefTabDist;
+}
+
+
+USHORT ToSvTab_Impl(SvxTabAdjust eAdj)
+
+/*
+ [Beschreibung]
+
+ Interne Konvertierungsroutinen zwischen SV-Tab.-Enum und Svx
+
+*/
+
+{
+ switch(eAdj) {
+ case SVX_TAB_ADJUST_LEFT: return RULER_TAB_LEFT;
+ case SVX_TAB_ADJUST_RIGHT: return RULER_TAB_RIGHT;
+ case SVX_TAB_ADJUST_DECIMAL: return RULER_TAB_DECIMAL;
+ case SVX_TAB_ADJUST_CENTER: return RULER_TAB_CENTER;
+ case SVX_TAB_ADJUST_DEFAULT: return RULER_TAB_DEFAULT;
+ default: ;//prevent warning
+ }
+ return 0;
+}
+
+
+SvxTabAdjust ToAttrTab_Impl(USHORT eAdj)
+{
+ switch(eAdj) {
+ case RULER_TAB_LEFT: return SVX_TAB_ADJUST_LEFT ;
+ case RULER_TAB_RIGHT: return SVX_TAB_ADJUST_RIGHT ;
+ case RULER_TAB_DECIMAL: return SVX_TAB_ADJUST_DECIMAL ;
+ case RULER_TAB_CENTER: return SVX_TAB_ADJUST_CENTER ;
+ case RULER_TAB_DEFAULT: return SVX_TAB_ADJUST_DEFAULT ;
+ }
+ return SVX_TAB_ADJUST_LEFT;
+}
+
+
+void SvxRuler::UpdateTabs()
+
+/*
+ [Beschreibung]
+
+ Anzeige der Tabulatoren
+
+*/
+
+{
+ if(IsDrag())
+ return;
+ if(pPagePosItem && pParaItem && pTabStopItem && !pObjectItem)
+ {
+ // Puffer fuer DefaultTabStop
+ // Abstand letzter Tab <-> Rechter Absatzrand / DefaultTabDist
+ BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
+ long nLeftFrameMargin = GetLeftFrameMargin();
+ long nRightFrameMargin = GetRightFrameMargin();
+
+ //#i24363# tab stops relative to indent
+ const long nParaItemTxtLeft = pParaItem->GetTxtLeft();
+
+ const long lParaIndent = nLeftFrameMargin + nParaItemTxtLeft;
+
+ const long lLastTab =
+ pTabStopItem->Count()?
+ ConvertHPosPixel((*pTabStopItem)[pTabStopItem->Count()-1].GetTabPos()): 0;
+ const long lPosPixel =
+ ConvertHPosPixel(lParaIndent) + lLastTab;
+ const long lRightIndent =
+ ConvertHPosPixel(nRightFrameMargin - pParaItem->GetRight());
+ long nDefTabDist = ConvertHPosPixel(lDefTabDist);
+ if( !nDefTabDist )
+ nDefTabDist = 1;
+ const USHORT nDefTabBuf = lPosPixel > lRightIndent ||
+ lLastTab > lRightIndent
+ ? 0
+ : (USHORT)( (lRightIndent - lPosPixel) / nDefTabDist );
+
+ if(pTabStopItem->Count() + TAB_GAP + nDefTabBuf > nTabBufSize)
+ {
+ delete[] pTabs;
+ // 10 (GAP) auf Vorrat
+ nTabBufSize = pTabStopItem->Count() + TAB_GAP + nDefTabBuf + GAP;
+ pTabs = new RulerTab[nTabBufSize];
+ }
+
+ nTabCount = 0;
+ USHORT j;
+ //#i24363# tab stops relative to indent
+ const long lRightPixMargin = ConvertSizePixel(nRightFrameMargin - nParaItemTxtLeft );
+ const long lParaIndentPix = ConvertSizePixel(lParaIndent);
+ for(j = 0; j < pTabStopItem->Count(); ++j)
+ {
+ const SvxTabStop *pTab = &(*pTabStopItem)[j];
+ pTabs[nTabCount+TAB_GAP].nPos =
+ ConvertHPosPixel(
+ (pRuler_Imp->bIsTabsRelativeToIndent ? lParaIndent : 0 ) + pTab->GetTabPos() + lAppNullOffset);
+ if(bRTL)
+ {
+ pTabs[nTabCount+TAB_GAP].nPos = lParaIndentPix + lRightPixMargin - pTabs[nTabCount+TAB_GAP].nPos;
+ }
+ pTabs[nTabCount+TAB_GAP].nStyle = ToSvTab_Impl(pTab->GetAdjustment());
+ ++nTabCount;
+ }
+ if(!pTabStopItem->Count())
+ pTabs[0].nPos = bRTL ? lRightPixMargin : lParaIndentPix;
+
+ // Rest mit Default-Tabs fuellen
+ if(bRTL)
+ {
+ for(j = 0; j < nDefTabBuf; ++j)
+ {
+ pTabs[nTabCount + TAB_GAP].nPos =
+ pTabs[nTabCount].nPos - nDefTabDist;
+
+ if(j == 0 )
+ pTabs[nTabCount + TAB_GAP].nPos -=
+ ((pTabs[nTabCount + TAB_GAP].nPos - lRightPixMargin)
+ % nDefTabDist );
+ if(pTabs[nTabCount+TAB_GAP].nPos <= lParaIndentPix)
+ break;
+ pTabs[nTabCount + TAB_GAP].nStyle = RULER_TAB_DEFAULT;
+ ++nTabCount;
+ }
+ }
+ else
+ {
+ for(j = 0; j < nDefTabBuf; ++j)
+ {
+ if( j == 0 )
+ {
+ //set the first default tab stop
+ if(pRuler_Imp->bIsTabsRelativeToIndent)
+ {
+ pTabs[nTabCount + TAB_GAP].nPos =
+ (pTabs[nTabCount].nPos + nDefTabDist);
+ pTabs[nTabCount + TAB_GAP].nPos -=
+ ((pTabs[nTabCount + TAB_GAP].nPos - lParaIndentPix)
+ % nDefTabDist );
+ }
+ else
+ {
+ if( pTabs[nTabCount].nPos < 0 )
+ {
+ pTabs[nTabCount + TAB_GAP].nPos = ( pTabs[nTabCount].nPos / nDefTabDist ) * nDefTabDist;
+ }
+ else
+ {
+ pTabs[nTabCount + TAB_GAP].nPos = ( pTabs[nTabCount].nPos / nDefTabDist + 1 ) * nDefTabDist;
+ }
+ }
+
+ }
+ else
+ {
+ //simply add the default distance to the last position
+ pTabs[nTabCount + TAB_GAP].nPos =
+ pTabs[nTabCount].nPos + nDefTabDist;
+ }
+
+ if(pTabs[nTabCount+TAB_GAP].nPos >= lRightIndent)
+ break;
+ pTabs[nTabCount + TAB_GAP].nStyle = RULER_TAB_DEFAULT;
+ ++nTabCount;
+ }
+ }
+ SetTabs(nTabCount, pTabs+TAB_GAP);
+ DBG_ASSERT(nTabCount + TAB_GAP <= nTabBufSize, "BufferSize zu klein");
+ }
+ else
+ {
+ SetTabs();
+ }
+}
+
+
+void SvxRuler::Update
+(
+ const SvxTabStopItem *pItem // Neuer Wert fuer Tabulatoren
+)
+
+/*
+ [Beschreibung]
+
+ Neuen Wert fuer Tabulatoren merken; alten gfs. loeschen
+
+*/
+
+{
+ if(bActive)
+ {
+ delete pTabStopItem; pTabStopItem = 0;
+ if(pItem)
+ {
+ pTabStopItem = new SvxTabStopItem(*pItem);
+ if(!bHorz)
+ pTabStopItem->SetWhich(SID_ATTR_TABSTOP_VERTICAL);
+ }
+ StartListening_Impl();
+ }
+}
+
+
+void SvxRuler::Update
+(
+ const SvxObjectItem *pItem // Neuer Wert fuer Objekte
+)
+
+/*
+ [Beschreibung]
+
+ Neuen Wert fuer Objekte merken
+
+*/
+
+{
+ if(bActive)
+ {
+ delete pObjectItem; pObjectItem = 0;
+ if(pItem)
+ pObjectItem = new SvxObjectItem(*pItem);
+ StartListening_Impl();
+ }
+}
+
+
+void SvxRuler::SetNullOffsetLogic
+(
+ long lVal // Setzen des logischen NullOffsets
+)
+{
+ lAppNullOffset = lLogicNullOffset - lVal;
+ bAppSetNullOffset = TRUE;
+ Ruler::SetNullOffset(ConvertSizePixel(lVal));
+ Update();
+}
+
+
+void SvxRuler::Update()
+
+/*
+ [Beschreibung]
+
+ Aktualisierung der Anzeige anstossen
+
+*/
+
+{
+ if(IsDrag())
+ return;
+ UpdatePage();
+ UpdateFrame();
+ if((nFlags & SVXRULER_SUPPORT_OBJECT) == SVXRULER_SUPPORT_OBJECT)
+ UpdateObject();
+ else
+ UpdateColumns();
+
+ if(0 != (nFlags & (SVXRULER_SUPPORT_PARAGRAPH_MARGINS |SVXRULER_SUPPORT_PARAGRAPH_MARGINS_VERTICAL)))
+ UpdatePara();
+ if(0 != (nFlags & SVXRULER_SUPPORT_TABS))
+ UpdateTabs();
+}
+
+
+inline long SvxRuler::GetPageWidth() const
+{
+ return bHorz ? pPagePosItem->GetWidth() : pPagePosItem->GetHeight();
+
+}
+
+
+inline long SvxRuler::GetFrameLeft() const
+
+/*
+ [Beschreibung]
+
+ Erfragen des linken Randes in Pixeln
+
+*/
+
+
+{
+ return bAppSetNullOffset?
+ GetMargin1() + ConvertSizePixel(lLogicNullOffset):
+ Ruler::GetNullOffset();
+}
+
+inline void SvxRuler::SetFrameLeft(long l)
+
+/*
+ [Beschreibung]
+
+ Setzen des linken Randes in Pixeln
+
+*/
+
+{
+ BOOL bProtectColumns =
+ pRuler_Imp->aProtectItem.IsSizeProtected() ||
+ pRuler_Imp->aProtectItem.IsPosProtected();
+ if(bAppSetNullOffset)
+ SetMargin1(l - ConvertSizePixel(lLogicNullOffset),
+ bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE);
+ else
+ Ruler::SetNullOffset(l);
+}
+
+
+long SvxRuler::GetFirstLineIndent() const
+
+/*
+ [Beschreibung]
+
+ Erstzeileneinzug in Pixels erfragen
+*/
+
+{
+ return pParaItem? pIndents[INDENT_FIRST_LINE].nPos: GetMargin1();
+}
+
+
+long SvxRuler::GetLeftIndent() const
+
+/*
+ [Beschreibung]
+
+ Linken Absatzrand in Pixels erfragen
+*/
+
+{
+ return pParaItem? pIndents[INDENT_LEFT_MARGIN].nPos: GetMargin1();
+}
+
+
+
+long SvxRuler::GetRightIndent() const
+
+/*
+ [Beschreibung]
+
+ Rechten Absatzrand in Pixels erfragen
+*/
+
+{
+ return pParaItem? pIndents[INDENT_RIGHT_MARGIN].nPos: GetMargin2();
+}
+
+
+long SvxRuler::GetLogicRightIndent() const
+
+/*
+ [Beschreibung]
+
+ Rechten Absatzrand in Logic erfragen
+*/
+
+{
+ return pParaItem ? GetRightFrameMargin()-pParaItem->GetRight() : GetRightFrameMargin();
+}
+
+// linker Rand in App-Werten; ist entweder der Seitenrand (=0)
+// oder der linke Rand der Spalte, die im Spaltenattribut als
+// altuelle Spalte eingestellt ist.
+
+long SvxRuler::GetLeftFrameMargin() const
+{
+ // #126721# for some unknown reason the current column is set to 0xffff
+ DBG_ASSERT(!pColumnItem || pColumnItem->GetActColumn() < pColumnItem->Count(),
+ "issue #126721# - invalid current column!");
+ long nLeft =
+ pColumnItem && pColumnItem->Count() && pColumnItem->GetActColumn() < pColumnItem->Count() ?
+ (*pColumnItem)[pColumnItem->GetActColumn()].nStart : 0;
+ if(pParaBorderItem && (!pColumnItem || pColumnItem->IsTable()))
+ nLeft += pParaBorderItem->GetLeft();
+ return nLeft;
+}
+
+inline long SvxRuler::GetLeftMin() const
+{
+ DBG_ASSERT(pMinMaxItem, "kein MinMax-Wert gesetzt");
+ return pMinMaxItem?
+ bHorz? pMinMaxItem->GetValue().Left(): pMinMaxItem->GetValue().Top()
+ : 0;
+}
+
+inline long SvxRuler::GetRightMax() const
+{
+ DBG_ASSERT(pMinMaxItem, "kein MinMax-Wert gesetzt");
+ return pMinMaxItem?
+ bHorz? pMinMaxItem->GetValue().Right(): pMinMaxItem->GetValue().Bottom()
+ : 0;
+}
+
+
+long SvxRuler::GetRightFrameMargin() const
+
+/*
+ [Beschreibung]
+
+ Rechten umgebenden Rand erfragen (in logischen Einheiten)
+
+*/
+
+{
+ if(pColumnItem)
+ {
+ if(!IsActLastColumn( TRUE ))
+ {
+ long nRet = (*pColumnItem)[GetActRightColumn( TRUE )].nEnd;
+ if(pColumnItem->IsTable() && pParaBorderItem)
+ nRet -= pParaBorderItem->GetRight();
+ return nRet;
+ }
+ }
+
+ long l = lLogicNullOffset;
+
+ // gfs. rechten Tabelleneinzug abziehen
+ if(pColumnItem && pColumnItem->IsTable())
+ l += pColumnItem->GetRight();
+ else if(bHorz && pLRSpaceItem)
+ l += pLRSpaceItem->GetRight();
+ else if(!bHorz && pULSpaceItem)
+ l += pULSpaceItem->GetLower();
+
+ if(pParaBorderItem &&
+ (!pColumnItem || pColumnItem->IsTable()||IsActLastColumn( TRUE )))
+ l += pParaBorderItem->GetRight();
+
+ if(bHorz)
+ l = pPagePosItem->GetWidth() - l;
+ else
+ l = pPagePosItem->GetHeight() - l;
+ return l;
+}
+
+#define NEG_FLAG ( (nFlags & SVXRULER_SUPPORT_NEGATIVE_MARGINS) == \
+ SVXRULER_SUPPORT_NEGATIVE_MARGINS )
+#define TAB_FLAG ( pColumnItem && pColumnItem->IsTable() )
+
+long SvxRuler::GetCorrectedDragPos( BOOL bLeft, BOOL bRight )
+
+/*
+ [Beschreibung]
+
+ Korrigiert die Position innerhalb der errechneten Grenzwerte.
+ Die Grenzwerte sind in Pixel relativ zum Seitenrand.
+
+*/
+
+{
+ const long lNullPix = Ruler::GetNullOffset();
+ long lDragPos = GetDragPos() + lNullPix;
+ADD_DEBUG_TEXT("lDragPos: ", String::CreateFromInt32(lDragPos))
+ BOOL bHoriRows = bHorz && pRuler_Imp->bIsTableRows;
+ if((bLeft || (bHoriRows)) && lDragPos < nMaxLeft)
+ lDragPos = nMaxLeft;
+ else if((bRight||bHoriRows) && lDragPos > nMaxRight)
+ lDragPos = nMaxRight;
+ return lDragPos - lNullPix;
+}
+
+
+
+void ModifyTabs_Impl
+(
+ USHORT nCount, // Anzahl Tabs
+ RulerTab *pTabs, // Tab-Puffer
+ long lDiff // zu addierende Differenz
+ )
+
+/*
+ [Beschreibung]
+
+ Hilfsroutine; alle Tabs um einen festen Wert verschieben
+
+*/
+{
+ if( pTabs )
+ for(USHORT i = 0; i < nCount; ++i) pTabs[i].nPos += lDiff;
+}
+
+
+
+void SvxRuler::DragMargin1()
+
+/*
+ [Beschreibung]
+
+ Draggen des linken Frame-Randes
+
+*/
+{
+ const long lDragPos = GetCorrectedDragPos( !TAB_FLAG || !NEG_FLAG, TRUE );
+ DrawLine_Impl(lTabPos, ( TAB_FLAG && NEG_FLAG ) ? 3 : 7, bHorz);
+ if(pColumnItem&&
+ (//nDragType & DRAG_OBJECT_SIZE_LINEAR ||
+ nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL))
+ DragBorders();
+ AdjustMargin1(lDragPos);
+}
+void SvxRuler::AdjustMargin1(long lDiff)
+{
+ const long nOld = bAppSetNullOffset? GetMargin1(): GetNullOffset();
+ const long lDragPos = lDiff;
+ BOOL bProtectColumns =
+ pRuler_Imp->aProtectItem.IsSizeProtected() ||
+ pRuler_Imp->aProtectItem.IsPosProtected();
+
+ const USHORT nMarginStyle =
+ bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE;
+
+ if(!bAppSetNullOffset)
+ {
+ long _lDiff = lDragPos;
+ SetNullOffset(nOld + _lDiff);
+ if(!pColumnItem||!(nDragType & DRAG_OBJECT_SIZE_LINEAR))
+ {
+ SetMargin2( GetMargin2() - _lDiff, nMarginStyle );
+
+ if(!pColumnItem && !pObjectItem && pParaItem)
+ {
+ // Rechten Einzug an alter Position
+ pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
+ SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
+ }
+ if(pObjectItem)
+ {
+ pObjectBorders[GetObjectBordersOff(0)].nPos -= _lDiff;
+ pObjectBorders[GetObjectBordersOff(1)].nPos -= _lDiff;
+ SetBorders(2, pObjectBorders + GetObjectBordersOff(0));
+ }
+ if(pColumnItem)
+ {
+ for(USHORT i = 0; i < pColumnItem->Count()-1; ++i)
+ pBorders[i].nPos -= _lDiff;
+ SetBorders(pColumnItem->Count()-1, pBorders);
+ if(pColumnItem->IsFirstAct())
+ {
+ // Rechten Einzug an alter Position
+ if(pParaItem)
+ {
+ pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
+ SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
+ }
+ }
+ else
+ {
+ if(pParaItem)
+ {
+ pIndents[INDENT_FIRST_LINE].nPos -= _lDiff;
+ pIndents[INDENT_LEFT_MARGIN].nPos -= _lDiff;
+ pIndents[INDENT_RIGHT_MARGIN].nPos -= _lDiff;
+ SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
+ }
+ }
+ if(pTabStopItem&& (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
+ &&!IsActFirstColumn())
+ {
+ ModifyTabs_Impl(nTabCount+TAB_GAP, pTabs, -_lDiff);
+ SetTabs(nTabCount, pTabs+TAB_GAP);
+ }
+ }
+ }
+ }
+ else
+ {
+ long _lDiff = lDragPos - nOld;
+ SetMargin1(nOld + _lDiff, nMarginStyle );
+
+ if(!pColumnItem||!(nDragType & (DRAG_OBJECT_SIZE_LINEAR |
+ DRAG_OBJECT_SIZE_PROPORTIONAL)))
+ {
+ if(!pColumnItem && !pObjectItem && pParaItem)
+ {
+ // Linke Einzuege an alter Position
+ pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
+ pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
+ SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
+ }
+
+ if(pColumnItem)
+ {
+ for(USHORT i = 0; i < pColumnItem->Count()-1; ++i)
+ pBorders[i].nPos += _lDiff;
+ SetBorders(pColumnItem->Count()-1, pBorders);
+ if(pColumnItem->IsFirstAct())
+ {
+ // Linke Einzuege an alter Position
+ if(pParaItem)
+ {
+ pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
+ pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
+ SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
+ }
+ }
+ else
+ {
+ if(pParaItem)
+ {
+ pIndents[INDENT_FIRST_LINE].nPos += _lDiff;
+ pIndents[INDENT_LEFT_MARGIN].nPos += _lDiff;
+ pIndents[INDENT_RIGHT_MARGIN].nPos += _lDiff;
+ SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
+ }
+ }
+ }
+ if(pTabStopItem)
+ {
+ ModifyTabs_Impl(nTabCount+TAB_GAP, pTabs, _lDiff);
+ SetTabs(nTabCount, pTabs+TAB_GAP);
+ }
+ }
+ }
+}
+
+
+void SvxRuler::DragMargin2()
+/*
+ [Beschreibung]
+
+ Draggen des rechten Frame-Randes
+
+*/
+{
+ const long lDragPos = GetCorrectedDragPos( TRUE, !TAB_FLAG || !NEG_FLAG);
+ DrawLine_Impl(lTabPos, ( TAB_FLAG && NEG_FLAG ) ? 5 : 7, bHorz);
+ long lDiff = lDragPos - GetMargin2();
+
+ if(pRuler_Imp->bIsTableRows && !bHorz && pColumnItem&&
+ (//nDragType & DRAG_OBJECT_SIZE_LINEAR ||
+ nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL))
+ DragBorders();
+
+ BOOL bProtectColumns =
+ pRuler_Imp->aProtectItem.IsSizeProtected() ||
+ pRuler_Imp->aProtectItem.IsPosProtected();
+ const USHORT nMarginStyle =
+ bProtectColumns ? 0 : RULER_MARGIN_SIZEABLE;
+ SetMargin2( lDragPos, nMarginStyle );
+
+ // Rechten Einzug an alter Position
+ if((!pColumnItem || IsActLastColumn()) && pParaItem)
+ {
+ pIndents[INDENT_FIRST_LINE].nPos += lDiff;
+ SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
+ }
+}
+
+
+void SvxRuler::DragIndents()
+/*
+ [Beschreibung]
+
+ Draggen der Absatzeinzuege
+
+*/
+{
+ const long lDragPos = NEG_FLAG ? GetDragPos() : GetCorrectedDragPos();
+ const USHORT nIdx = GetDragAryPos()+INDENT_GAP;
+ const long lDiff = pIndents[nIdx].nPos - lDragPos;
+
+ if((nIdx == INDENT_FIRST_LINE ||
+ nIdx == INDENT_LEFT_MARGIN ) &&
+ (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
+ DRAG_OBJECT_LEFT_INDENT_ONLY)
+ pIndents[INDENT_FIRST_LINE].nPos -= lDiff;
+
+ pIndents[nIdx].nPos = lDragPos;
+
+ SetIndents(INDENT_COUNT, pIndents + INDENT_GAP);
+ DrawLine_Impl(lTabPos, 1, bHorz);
+}
+
+
+void SvxRuler::DrawLine_Impl(long &_lTabPos, int nNew, BOOL Hori)
+/*
+ [Beschreibung]
+
+ Ausgaberoutine fuer Hilfslinie beim Vereschieben von Tabs, Tabellen-
+ und anderen Spalten
+
+*/
+{
+ if(Hori)
+ {
+ const long nHeight = pEditWin->GetOutputSize().Height();
+ Point aZero=pEditWin->GetMapMode().GetOrigin();
+ if(_lTabPos!=-1)
+ pEditWin->InvertTracking(
+ Rectangle( Point(_lTabPos, -aZero.Y()),
+ Point(_lTabPos, -aZero.Y()+nHeight)),
+ SHOWTRACK_SPLIT | SHOWTRACK_CLIP );
+ if( nNew & 1 )
+ {
+
+ _lTabPos = ConvertHSizeLogic(
+ GetCorrectedDragPos( ( nNew&4 ) != 0, ( nNew&2 ) != 0 ) +
+ GetNullOffset() );
+ if(pPagePosItem)
+ _lTabPos += pPagePosItem->GetPos().X();
+ pEditWin->InvertTracking(
+ Rectangle(Point(_lTabPos, -aZero.Y()),
+ Point(_lTabPos, -aZero.Y()+nHeight)),
+ SHOWTRACK_CLIP | SHOWTRACK_SPLIT );
+ }
+ }
+ else
+ {
+ const long nWidth = pEditWin->GetOutputSize().Width();
+ Point aZero=pEditWin->GetMapMode().GetOrigin();
+ if(_lTabPos != -1)
+ {
+ pEditWin->InvertTracking(
+ Rectangle( Point(-aZero.X(), _lTabPos),
+ Point(-aZero.X()+nWidth, _lTabPos)),
+ SHOWTRACK_SPLIT | SHOWTRACK_CLIP );
+ }
+
+ if(nNew & 1)
+ {
+ _lTabPos = ConvertVSizeLogic(GetCorrectedDragPos()+GetNullOffset());
+ if(pPagePosItem)
+ _lTabPos += pPagePosItem->GetPos().Y();
+ pEditWin->InvertTracking(
+ Rectangle( Point(-aZero.X(), _lTabPos),
+ Point(-aZero.X()+nWidth, _lTabPos)),
+ SHOWTRACK_CLIP | SHOWTRACK_SPLIT );
+ }
+ }
+}
+
+
+
+
+void SvxRuler::DragTabs()
+
+/*
+ [Beschreibung]
+
+ Draggen von Tabs
+
+*/
+{
+
+ long lDragPos = GetCorrectedDragPos(TRUE, FALSE);
+
+ USHORT nIdx = GetDragAryPos()+TAB_GAP;
+ DrawLine_Impl(lTabPos, 7, bHorz);
+
+ long nDiff = lDragPos - pTabs[nIdx].nPos;
+
+ if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
+ {
+
+ for(USHORT i = nIdx; i < nTabCount; ++i)
+ {
+ pTabs[i].nPos += nDiff;
+ // auf Maximum begrenzen
+ if(pTabs[i].nPos > GetMargin2())
+ pTabs[nIdx].nStyle |= RULER_STYLE_INVISIBLE;
+ else
+ pTabs[nIdx].nStyle &= ~RULER_STYLE_INVISIBLE;
+ }
+ }
+ else if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
+ {
+ pRuler_Imp->nTotalDist -= nDiff;
+ pTabs[nIdx].nPos = lDragPos;
+ for(USHORT i = nIdx+1; i < nTabCount; ++i)
+ {
+ if(pTabs[i].nStyle & RULER_TAB_DEFAULT)
+ // bei den DefaultTabs kann abgebrochen werden
+ break;
+ long nDelta = pRuler_Imp->nTotalDist * pRuler_Imp->pPercBuf[i];
+ nDelta /= 1000;
+ pTabs[i].nPos = pTabs[nIdx].nPos + nDelta;
+ if(pTabs[i].nPos+GetNullOffset() > nMaxRight)
+ pTabs[i].nStyle |= RULER_STYLE_INVISIBLE;
+ else
+ pTabs[i].nStyle &= ~RULER_STYLE_INVISIBLE;
+ }
+ }
+ else
+ pTabs[nIdx].nPos = lDragPos;
+
+ if(IsDragDelete())
+ pTabs[nIdx].nStyle |= RULER_STYLE_INVISIBLE;
+ else
+ pTabs[nIdx].nStyle &= ~RULER_STYLE_INVISIBLE;
+ SetTabs(nTabCount, pTabs+TAB_GAP);
+}
+
+
+
+void SvxRuler::SetActive(BOOL bOn)
+{
+ if(bOn)
+ {
+ Activate();
+/* pBindings->Invalidate( SID_RULER_LR_MIN_MAX, TRUE, TRUE );
+ pBindings->Update( SID_RULER_LR_MIN_MAX );
+ pBindings->Invalidate( SID_ATTR_LONG_ULSPACE, TRUE, TRUE );
+ pBindings->Update( SID_ATTR_LONG_ULSPACE );
+ pBindings->Invalidate( SID_ATTR_LONG_LRSPACE, TRUE, TRUE );
+ pBindings->Update( SID_ATTR_LONG_LRSPACE );
+ pBindings->Invalidate( SID_RULER_PAGE_POS, TRUE, TRUE );
+ pBindings->Update( SID_RULER_PAGE_POS );
+ pBindings->Invalidate( SID_ATTR_TABSTOP, TRUE, TRUE );
+ pBindings->Update( SID_ATTR_TABSTOP );
+ pBindings->Invalidate( SID_ATTR_PARA_LRSPACE, TRUE, TRUE );
+ pBindings->Update( SID_ATTR_PARA_LRSPACE );
+ pBindings->Invalidate( SID_RULER_BORDERS, TRUE, TRUE );
+ pBindings->Update( SID_RULER_BORDERS );
+ pBindings->Invalidate( SID_RULER_OBJECT, TRUE, TRUE );
+ pBindings->Update( SID_RULER_OBJECT );
+ pBindings->Invalidate( SID_RULER_PROTECT, TRUE, TRUE );
+ pBindings->Update( SID_RULER_PROTECT );*/
+ }
+ else
+ Deactivate();
+ if(bActive!=bOn)
+ {
+ pBindings->EnterRegistrations();
+ if(bOn)
+ for(USHORT i=0;i<pRuler_Imp->nControlerItems;i++)
+ pCtrlItem[i]->ReBind();
+ else
+ for(USHORT j=0;j<pRuler_Imp->nControlerItems;j++)
+ pCtrlItem[j]->UnBind();
+ pBindings->LeaveRegistrations();
+ }
+ bActive = bOn;
+}
+
+
+
+
+void SvxRuler::UpdateParaContents_Impl
+(
+ long l, // Differenz
+ UpdateType eType // Art (alle, links oder rechts)
+)
+
+/*
+ [Beschreibung]
+
+ Hilfsroutine; Mitfuehren von Tabulatoren und Absatzraendern
+
+*/
+{
+ switch(eType) {
+ case MOVE_RIGHT:
+ pIndents[INDENT_RIGHT_MARGIN].nPos += l;
+ break;
+ case MOVE_ALL:
+ pIndents[INDENT_RIGHT_MARGIN].nPos += l;
+ // no break
+ case MOVE_LEFT:
+ {
+ pIndents[INDENT_FIRST_LINE].nPos += l;
+ pIndents[INDENT_LEFT_MARGIN].nPos += l;
+ if ( pTabs )
+ {
+ for(USHORT i = 0; i < nTabCount+TAB_GAP;++i)
+ pTabs[i].nPos += l;
+ SetTabs(nTabCount, pTabs+TAB_GAP);
+ }
+ break;
+ }
+ }
+ SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
+}
+
+
+
+void SvxRuler::DragBorders()
+
+/*
+ [Beschreibung]
+
+ Draggen von Borders (Tabellen- und anderen Spalten)
+
+*/
+{
+ BOOL bLeftIndentsCorrected = FALSE, bRightIndentsCorrected = FALSE;
+ int nIdx;
+
+ if(GetDragType()==RULER_TYPE_BORDER)
+ {
+ DrawLine_Impl(lTabPos, 7, bHorz);
+ nIdx = GetDragAryPos();
+ }
+ else
+ nIdx=0;
+
+ USHORT nDragSize = GetDragSize();
+ long lDiff = 0;
+
+ // the drag position has to be corrected to be able to prevent borders from passing each other
+ long lPos = GetCorrectedDragPos();
+
+
+ switch(nDragSize)
+ {
+ case RULER_DRAGSIZE_MOVE:
+ {
+ADD_DEBUG_TEXT("lLastLMargin: ", String::CreateFromInt32(pRuler_Imp->lLastLMargin))
+ lDiff = GetDragType()==RULER_TYPE_BORDER ?
+ lPos-nDragOffset - pBorders[nIdx].nPos
+ : GetDragType() == RULER_TYPE_MARGIN1 ? lPos - pRuler_Imp->lLastLMargin : lPos - pRuler_Imp->lLastRMargin;
+
+// pBorders[nIdx].nPos += lDiff;
+// lDiff = pBorders[nIdx].nPos - nOld;
+ if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
+ {
+ long nRight = GetMargin2()-lMinFrame; // rechter Begrenzer
+ for(int i = nBorderCount-2; i >= nIdx; --i)
+ {
+ long l = pBorders[i].nPos;
+ pBorders[i].nPos += lDiff;
+ pBorders[i].nPos = Min(pBorders[i].nPos, nRight - pBorders[i].nWidth);
+ nRight = pBorders[i].nPos - lMinFrame;
+ // RR der Spalte aktualisieren
+ if(i == GetActRightColumn())
+ {
+ UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_RIGHT);
+ bRightIndentsCorrected = TRUE;
+ }
+ // LAR, EZE der Spalte aktualisieren
+ else if(i == GetActLeftColumn())
+ {
+ UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_LEFT);
+ bLeftIndentsCorrected = TRUE;
+ }
+ }
+ }
+ else if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
+ {
+ int nLimit;
+ long lLeft;
+ int nStartLimit = nBorderCount-2;
+ switch(GetDragType())
+ {
+ default: ;//prevent warning
+ DBG_ERROR("svx::SvxRuler::DragBorders(), unknown drag type!" );
+ case RULER_TYPE_BORDER:
+ if(pRuler_Imp->bIsTableRows)
+ {
+ pBorders[nIdx].nPos += lDiff;
+ if(bHorz)
+ {
+ lLeft = pBorders[nIdx].nPos;
+ pRuler_Imp->nTotalDist -= lDiff;
+ nLimit=nIdx+1;
+ }
+ else
+ {
+ lLeft = 0;
+ nStartLimit = nIdx - 1;
+ pRuler_Imp->nTotalDist += lDiff;
+ nLimit = 0;
+ }
+ }
+ else
+ {
+ nLimit=nIdx+1;
+ pBorders[nIdx].nPos += lDiff;
+ lLeft = pBorders[nIdx].nPos;
+ pRuler_Imp->nTotalDist-=lDiff;
+ }
+ break;
+ case RULER_TYPE_MARGIN1:
+ nLimit=0;
+ lLeft=pRuler_Imp->lLastLMargin+lDiff;
+ pRuler_Imp->nTotalDist-=lDiff;
+ break;
+ case RULER_TYPE_MARGIN2:
+ nLimit = 0;
+ lLeft= 0;//pRuler_Imp->lLastRMargin + lDiff;
+ nStartLimit = nBorderCount - 2;
+ pRuler_Imp->nTotalDist += lDiff;
+ break;
+ }
+
+ for(int i = nStartLimit; i >= nLimit; --i)
+ {
+
+ long l = pBorders[i].nPos;
+ pBorders[i].nPos=lLeft+
+ (pRuler_Imp->nTotalDist*pRuler_Imp->pPercBuf[i])/1000+
+ pRuler_Imp->pBlockBuf[i];
+
+ // RR der Spalte aktualisieren
+ if(!pRuler_Imp->bIsTableRows)
+ {
+ if(i == GetActRightColumn())
+ {
+ UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_RIGHT);
+ bRightIndentsCorrected = TRUE;
+ }
+ // LAR, EZE der Spalte aktualisieren
+ else if(i == GetActLeftColumn())
+ {
+ UpdateParaContents_Impl(pBorders[i].nPos - l, MOVE_LEFT);
+ bLeftIndentsCorrected = TRUE;
+ }
+ }
+ }
+ if(pRuler_Imp->bIsTableRows)
+ {
+ //in vertical tables the left borders have to be moved
+ if(bHorz)
+ {
+ for(int i = 0; i < nIdx; ++i)
+ pBorders[i].nPos += lDiff;
+ AdjustMargin1(lDiff);
+ }
+ else
+ {
+ //otherwise the right borders are moved
+ for(int i = pColumnItem->Count() - 1; i > nIdx; --i)
+ pBorders[i].nPos += lDiff;
+ SetMargin2( GetMargin2() + lDiff, 0 );
+ }
+ }
+ }
+ else if(pRuler_Imp->bIsTableRows)
+ {
+ //moving rows: if a row is resized all following rows
+ //have to be moved by the same amount.
+ //This includes the left border when the table is not limited
+ //to a lower frame border.
+ int nLimit;
+ long lLeft;
+ if(GetDragType()==RULER_TYPE_BORDER)
+ {
+ nLimit=nIdx+1;
+ lLeft=(pBorders[nIdx].nPos+=lDiff);
+ }
+ else
+ {
+ nLimit=0;
+ lLeft=pRuler_Imp->lLastLMargin+lDiff;
+ }
+ //in vertical tables the left borders have to be moved
+ if(bHorz)
+ {
+ for(int i = 0; i < nIdx; ++i)
+ {
+ pBorders[i].nPos += lDiff;
+ }
+ AdjustMargin1(lDiff);
+ }
+ else
+ {
+ //otherwise the right borders are moved
+ for(int i = nBorderCount-2; i >= nLimit; --i)
+ {
+ pBorders[i].nPos += lDiff;
+ }
+ SetMargin2( GetMargin2() + lDiff, 0 );
+ }
+ }
+ else
+ pBorders[nIdx].nPos+=lDiff;
+ break;
+ }
+ case RULER_DRAGSIZE_1:
+ {
+ lDiff = lPos - pBorders[nIdx].nPos;
+ pBorders[nIdx].nWidth += pBorders[nIdx].nPos - lPos;
+ pBorders[nIdx].nPos = lPos;
+ break;
+ }
+ case RULER_DRAGSIZE_2:
+ {
+ const long nOld = pBorders[nIdx].nWidth;
+ pBorders[nIdx].nWidth = lPos - pBorders[nIdx].nPos;
+ lDiff = pBorders[nIdx].nWidth - nOld;
+ break;
+ }
+ }
+ if(!bRightIndentsCorrected &&
+ GetActRightColumn() == nIdx &&
+ nDragSize != RULER_DRAGSIZE_2 && pIndents &&
+ !pRuler_Imp->bIsTableRows)
+ {
+ UpdateParaContents_Impl(lDiff, MOVE_RIGHT);
+ }
+ else if(!bLeftIndentsCorrected &&
+ GetActLeftColumn()==nIdx &&
+ nDragSize != RULER_DRAGSIZE_1 && pIndents)
+ {
+ UpdateParaContents_Impl(lDiff, MOVE_LEFT);
+ }
+ SetBorders(pColumnItem->Count()-1, pBorders);
+}
+
+
+void SvxRuler::DragObjectBorder()
+
+/*
+ [Beschreibung]
+
+ Draggen von Objektraendern
+
+*/
+{
+ if(RULER_DRAGSIZE_MOVE == GetDragSize())
+ {
+ const long lPos = GetCorrectedDragPos();
+ const USHORT nIdx = GetDragAryPos();
+ pObjectBorders[GetObjectBordersOff(nIdx)].nPos = lPos;
+ SetBorders(2, pObjectBorders + GetObjectBordersOff(0));
+ DrawLine_Impl(lTabPos, 7, bHorz);
+
+ }
+}
+
+
+void SvxRuler::ApplyMargins()
+/*
+ [Beschreibung]
+
+ Anwenden von Randeinstellungen; durch Draggen veraendert.
+
+*/
+{
+ const SfxPoolItem *pItem = 0;
+ USHORT nId = SID_ATTR_LONG_LRSPACE;
+ if(bHorz)
+ {
+ const long lOldNull = lLogicNullOffset;
+ if(pRuler_Imp->lMaxLeftLogic!=-1&&nMaxLeft==GetMargin1()+Ruler::GetNullOffset())
+ pLRSpaceItem->SetLeft(lLogicNullOffset=pRuler_Imp->lMaxLeftLogic);
+ else
+ pLRSpaceItem->SetLeft(PixelHAdjust(
+ lLogicNullOffset = ConvertHPosLogic(GetFrameLeft()) -
+ lAppNullOffset, pLRSpaceItem->GetLeft()));
+
+ if(bAppSetNullOffset)
+ lAppNullOffset += lLogicNullOffset - lOldNull;
+
+ if(pRuler_Imp->lMaxRightLogic!=-1
+ &&nMaxRight==GetMargin2()+Ruler::GetNullOffset())
+ pLRSpaceItem->SetRight(GetPageWidth()-pRuler_Imp->lMaxRightLogic);
+ else
+ pLRSpaceItem->SetRight(
+ PixelHAdjust(
+ Max((long)0,pPagePosItem->GetWidth() -
+ pLRSpaceItem->GetLeft() -
+ (ConvertHPosLogic(GetMargin2()) -
+ lAppNullOffset)),pLRSpaceItem->GetRight()));
+ pItem = pLRSpaceItem;
+#ifdef DEBUGLIN
+ Debug_Impl(pEditWin,*pLRSpaceItem);
+#endif // DEBUGLIN
+ }
+ else {
+ const long lOldNull = lLogicNullOffset;
+ pULSpaceItem->SetUpper(
+ PixelVAdjust(
+ lLogicNullOffset =
+ ConvertVPosLogic(GetFrameLeft()) -
+ lAppNullOffset,pULSpaceItem->GetUpper()));
+ if(bAppSetNullOffset)
+ lAppNullOffset += lLogicNullOffset - lOldNull;
+ pULSpaceItem->SetLower(
+ PixelVAdjust(
+ Max((long)0, pPagePosItem->GetHeight() -
+ pULSpaceItem->GetUpper() -
+ (ConvertVPosLogic(GetMargin2()) -
+ lAppNullOffset)),pULSpaceItem->GetLower()));
+ pItem = pULSpaceItem;
+ nId = SID_ATTR_LONG_ULSPACE;
+#ifdef DEBUGLIN
+ Debug_Impl(pEditWin,*pULSpaceItem);
+#endif // DEBUGLIN
+ }
+ pBindings->GetDispatcher()->Execute( nId, SFX_CALLMODE_RECORD, pItem, 0L );
+ if(pTabStopItem)
+ UpdateTabs();
+}
+
+
+void SvxRuler::ApplyIndents()
+/*
+ [Beschreibung]
+
+ Anwenden von Absatzeinstellungen; durch Draggen veraendert.
+
+*/
+{
+ long nNewTxtLeft;
+ if(pColumnItem&&!IsActFirstColumn( TRUE ))
+ {
+ long nLeftCol=GetActLeftColumn( TRUE );
+ nNewTxtLeft =
+ PixelHAdjust(
+ ConvertHPosLogic(
+ pIndents[INDENT_LEFT_MARGIN].nPos-
+ (pBorders[nLeftCol].nPos +
+ pBorders[nLeftCol].nWidth))-
+ lAppNullOffset,pParaItem->GetTxtLeft());
+ }
+ else
+ nNewTxtLeft =
+ PixelHAdjust(
+ ConvertHPosLogic(pIndents[INDENT_LEFT_MARGIN].nPos),
+ pParaItem->GetTxtLeft());
+
+ BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
+
+ long nNewFirstLineOffset;
+ if(bRTL)
+ {
+ long nRightFrameMargin = GetRightFrameMargin();
+ nNewFirstLineOffset = PixelHAdjust(nRightFrameMargin -
+ ConvertHPosLogic(pIndents[INDENT_FIRST_LINE].nPos ) -
+ lAppNullOffset,
+ pParaItem->GetTxtFirstLineOfst());
+ }
+ else
+ nNewFirstLineOffset=
+ PixelHAdjust(
+ ConvertHPosLogic(pIndents[INDENT_FIRST_LINE].nPos -
+ pIndents[INDENT_LEFT_MARGIN].nPos) -
+ lAppNullOffset,
+ pParaItem->GetTxtFirstLineOfst());
+
+ // #62986# : Ist der neue TxtLeft kleiner als der alte FirstLineIndent,
+ // dann geht die Differenz verloren und der Absatz wird insgesamt
+ // zu weit eingerueckt, deswegen erst den FirstLineOffset setzen, dann den TxtLeft
+ if(bRTL)
+ {
+ long nLeftFrameMargin = GetLeftFrameMargin();
+ long nRightFrameMargin = GetRightFrameMargin();
+ nNewTxtLeft = nRightFrameMargin - nNewTxtLeft - nLeftFrameMargin;
+ nNewFirstLineOffset -= nNewTxtLeft;
+ if(pParaBorderItem)
+ {
+ nNewTxtLeft += pParaBorderItem->GetLeft() + pParaBorderItem->GetRight();
+ nNewFirstLineOffset -= pParaBorderItem->GetRight();
+ }
+ }
+ pParaItem->SetTxtFirstLineOfst(
+ sal::static_int_cast< short >(nNewFirstLineOffset));
+ pParaItem->SetTxtLeft(nNewTxtLeft);
+
+ if(pColumnItem && ((!bRTL && !IsActLastColumn( TRUE ))|| (bRTL && !IsActFirstColumn())))
+ {
+ if(bRTL)
+ {
+ long nActBorder = pBorders[GetActLeftColumn( TRUE )].nPos;
+ long nRightMargin = pIndents[INDENT_RIGHT_MARGIN].nPos;
+ long nConvert = ConvertHPosLogic( nRightMargin - nActBorder );
+ pParaItem->SetRight( PixelHAdjust( nConvert - lAppNullOffset, pParaItem->GetRight() ) );
+ }
+ else
+ {
+ pParaItem->SetRight(
+ PixelHAdjust(
+ ConvertHPosLogic(
+ pBorders[GetActRightColumn( TRUE )].nPos -
+ pIndents[INDENT_RIGHT_MARGIN].nPos) -
+ lAppNullOffset,
+ pParaItem->GetRight()));
+ }
+
+ }
+ else
+ {
+ if(bRTL)
+ {
+ pParaItem->SetRight( PixelHAdjust(
+ ConvertHPosLogic(GetMargin1() +
+ pIndents[INDENT_RIGHT_MARGIN].nPos) - GetLeftFrameMargin() +
+ (pParaBorderItem ? pParaBorderItem->GetLeft() : 0) -
+ lAppNullOffset, pParaItem->GetRight()));
+ }
+ else
+ {
+ pParaItem->SetRight( PixelHAdjust(
+ ConvertHPosLogic(GetMargin2() -
+ pIndents[INDENT_RIGHT_MARGIN].nPos) -
+ lAppNullOffset, pParaItem->GetRight()));
+ }
+ }
+ USHORT nParaId = bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL;
+ pBindings->GetDispatcher()->Execute( nParaId, SFX_CALLMODE_RECORD, pParaItem, 0L );
+ UpdateTabs();
+}
+
+
+void SvxRuler::ApplyTabs()
+/*
+ [Beschreibung]
+
+ Anwenden von Tabulatoreinstellungen; durch Draggen veraendert.
+
+*/
+{
+ BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
+ const USHORT nCoreIdx = GetDragAryPos();
+ if(IsDragDelete())
+ {
+ pTabStopItem->Remove(nCoreIdx);
+ }
+ else if(DRAG_OBJECT_SIZE_LINEAR & nDragType ||
+ DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType)
+ {
+ SvxTabStopItem *pItem = new SvxTabStopItem(pTabStopItem->Which());
+ //remove default tab stops
+ for ( USHORT i = 0; i < pItem->Count(); )
+ {
+ if ( SVX_TAB_ADJUST_DEFAULT == (*pItem)[i].GetAdjustment() )
+ {
+ pItem->Remove(i);
+ continue;
+ }
+ ++i;
+ }
+
+ USHORT j;
+ for(j = 0; j < nCoreIdx; ++j)
+ {
+ pItem->Insert((*pTabStopItem)[j]);
+ }
+ for(; j < pTabStopItem->Count(); ++j)
+ {
+ SvxTabStop aTabStop = (*pTabStopItem)[j];
+ aTabStop.GetTabPos() = PixelHAdjust(
+ ConvertHPosLogic(pTabs[j+TAB_GAP].nPos -
+ GetLeftIndent()) -
+ lAppNullOffset,
+ aTabStop.GetTabPos());
+ pItem->Insert(aTabStop);
+ }
+ delete pTabStopItem;
+ pTabStopItem = pItem;
+ }
+ else if( pTabStopItem->Count() == 0 )
+ return;
+ else
+ {
+ SvxTabStop aTabStop = (*pTabStopItem)[nCoreIdx];
+ if(pRuler_Imp->lMaxRightLogic!=-1&&
+ pTabs[nCoreIdx+TAB_GAP].nPos+Ruler::GetNullOffset()==nMaxRight)
+ aTabStop.GetTabPos() = pRuler_Imp->lMaxRightLogic-lLogicNullOffset;
+ else
+ {
+ if(bRTL)
+ {
+ //#i24363# tab stops relative to indent
+ const long nTmpLeftIndent = pRuler_Imp->bIsTabsRelativeToIndent ?
+ GetLeftIndent() :
+ ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset );
+
+ aTabStop.GetTabPos() = PixelHAdjust(
+ ConvertHPosLogic( nTmpLeftIndent - pTabs[nCoreIdx+TAB_GAP].nPos) - lAppNullOffset,
+ aTabStop.GetTabPos());
+ }
+ else
+ {
+ //#i24363# tab stops relative to indent
+ const long nTmpLeftIndent = pRuler_Imp->bIsTabsRelativeToIndent ?
+ GetLeftIndent() :
+ 0;
+
+ aTabStop.GetTabPos() = PixelHAdjust(
+ ConvertHPosLogic( pTabs[nCoreIdx+TAB_GAP].nPos - nTmpLeftIndent ) - lAppNullOffset,
+ aTabStop.GetTabPos() );
+ }
+ }
+ pTabStopItem->Remove(nCoreIdx);
+ pTabStopItem->Insert(aTabStop);
+ }
+ USHORT nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
+ pBindings->GetDispatcher()->Execute( nTabStopId, SFX_CALLMODE_RECORD, pTabStopItem, 0L );
+ UpdateTabs();
+}
+
+
+void SvxRuler::ApplyBorders()
+/*
+ [Beschreibung]
+
+ Anwenden von (Tabellen-)Spalteneinstellungen; durch Draggen veraendert.
+
+*/
+{
+ if(pColumnItem->IsTable())
+ {
+ long l = GetFrameLeft();
+ if(l != pRuler_Imp->nColLeftPix)
+ pColumnItem->SetLeft( PixelHAdjust(
+ ConvertHPosLogic(l) - lAppNullOffset, pColumnItem->GetLeft()));
+ l = GetMargin2();
+ if(l != pRuler_Imp->nColRightPix)
+ {
+ long nWidthOrHeight = bHorz ? pPagePosItem->GetWidth() : pPagePosItem->GetHeight();
+ pColumnItem->SetRight( PixelHAdjust( nWidthOrHeight -
+ pColumnItem->GetLeft() - ConvertHPosLogic(l) -
+ lAppNullOffset, pColumnItem->GetRight() ) );
+ }
+ }
+ for(USHORT i = 0; i < pColumnItem->Count()-1; ++i)
+ {
+ long& nEnd = (*pColumnItem)[i].nEnd;
+ nEnd = PIXEL_H_ADJUST(
+ ConvertPosLogic(pBorders[i].nPos),
+ (*pColumnItem)[i].nEnd);
+ long& nStart = (*pColumnItem)[i+1].nStart;
+ nStart = PIXEL_H_ADJUST(
+ ConvertSizeLogic(pBorders[i].nPos +
+ pBorders[i].nWidth) -
+ lAppNullOffset,
+ (*pColumnItem)[i+1].nStart);
+ // Es kann sein, dass aufgrund der PIXEL_H_ADJUST rejustierung auf
+ // alte Werte die Breite < 0 wird. Das rerejustieren wir.
+ if( nEnd > nStart )
+ nStart = nEnd;
+ }
+#ifdef DEBUGLIN
+ Debug_Impl(pEditWin,*pColumnItem);
+#endif // DEBUGLIN
+ SfxBoolItem aFlag(SID_RULER_ACT_LINE_ONLY,
+ nDragType & DRAG_OBJECT_ACTLINE_ONLY? TRUE: FALSE);
+ USHORT nColId = pRuler_Imp->bIsTableRows ? (bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL) :
+ (bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
+ pBindings->GetDispatcher()->Execute( nColId, SFX_CALLMODE_RECORD, pColumnItem, &aFlag, 0L );
+}
+
+void SvxRuler::ApplyObject()
+/*
+ [Beschreibung]
+
+ Anwenden von Objekteinstellungen; durch Draggen veraendert.
+
+*/
+{
+ // zum Seitenrand
+ long nMargin = pLRSpaceItem? pLRSpaceItem->GetLeft(): 0;
+ pObjectItem->SetStartX(
+ PixelAdjust(
+ ConvertPosLogic(pObjectBorders[0].nPos)
+ + nMargin - lAppNullOffset,pObjectItem->GetStartX()));
+ pObjectItem->SetEndX(
+ PixelAdjust(
+ ConvertPosLogic(pObjectBorders[1].nPos)
+ + nMargin - lAppNullOffset,pObjectItem->GetEndX()));
+ nMargin = pULSpaceItem? pULSpaceItem->GetUpper(): 0;
+ pObjectItem->SetStartY(
+ PixelAdjust(
+ ConvertPosLogic(pObjectBorders[2].nPos)
+ + nMargin - lAppNullOffset,pObjectItem->GetStartY()));
+ pObjectItem->SetEndY(
+ PixelAdjust(
+ ConvertPosLogic(pObjectBorders[3].nPos)
+ + nMargin - lAppNullOffset,pObjectItem->GetEndY()));
+ pBindings->GetDispatcher()->Execute( SID_RULER_OBJECT, SFX_CALLMODE_RECORD, pObjectItem, 0L );
+}
+
+void SvxRuler::PrepareProportional_Impl(RulerType eType)
+/*
+ [Beschreibung]
+
+ Vorbereitung proportionales Draggen; es wird der proportionale
+ Anteil bezogen auf die Gesamtbreite in Promille berechnet.
+
+*/
+{
+ pRuler_Imp->nTotalDist = GetMargin2();
+ switch((int)eType)
+ {
+ case RULER_TYPE_MARGIN2:
+ case RULER_TYPE_MARGIN1:
+ case RULER_TYPE_BORDER:
+ {
+ DBG_ASSERT(pColumnItem, "kein ColumnItem");
+
+ pRuler_Imp->SetPercSize(pColumnItem->Count());
+
+ long lPos;
+ long lWidth=0;
+ USHORT nStart;
+ USHORT nIdx=GetDragAryPos();
+ lWidth=0;
+ long lActWidth=0;
+ long lActBorderSum;
+ long lOrigLPos;
+
+ if(eType != RULER_TYPE_BORDER)
+ {
+ lOrigLPos = GetMargin1();
+ nStart = 0;
+ lActBorderSum = 0;
+ }
+ else
+ {
+ if(pRuler_Imp->bIsTableRows &&!bHorz)
+ {
+ lOrigLPos = GetMargin1();
+ nStart = 0;
+ }
+ else
+ {
+ lOrigLPos = pBorders[nIdx].nPos + pBorders[nIdx].nWidth;
+ nStart = 1;
+ }
+ lActBorderSum = pBorders[nIdx].nWidth;
+ }
+
+ //in horizontal mode the percentage value has to be
+ //calculated on a "current change" position base
+ //because the height of the table changes while dragging
+ if(pRuler_Imp->bIsTableRows && RULER_TYPE_BORDER == eType)
+ {
+ USHORT nStartBorder;
+ USHORT nEndBorder;
+ if(bHorz)
+ {
+ nStartBorder = nIdx + 1;
+ nEndBorder = pColumnItem->Count() - 1;
+ }
+ else
+ {
+ nStartBorder = 0;
+ nEndBorder = nIdx;
+ }
+
+ lWidth = pBorders[nIdx].nPos;
+ if(bHorz)
+ lWidth = GetMargin2() - lWidth;
+ pRuler_Imp->nTotalDist = lWidth;
+ lPos = lOrigLPos = pBorders[nIdx].nPos;
+
+ for(USHORT i = nStartBorder; i < nEndBorder; ++i)
+ {
+ if(bHorz)
+ {
+ lActWidth += pBorders[i].nPos - lPos;
+ lPos = pBorders[i].nPos + pBorders[i].nWidth;
+ }
+ else
+ lActWidth = pBorders[i].nPos;
+ pRuler_Imp->pPercBuf[i] = (USHORT)((lActWidth * 1000)
+ / pRuler_Imp->nTotalDist);
+ pRuler_Imp->pBlockBuf[i] = (USHORT)lActBorderSum;
+ lActBorderSum += pBorders[i].nWidth;
+ }
+ }
+ else
+ {
+ lPos = lOrigLPos;
+ for(USHORT ii = nStart; ii < pColumnItem->Count() - 1; ++ii)
+ {
+ lWidth += pBorders[ii].nPos - lPos;
+ lPos = pBorders[ii].nPos + pBorders[ii].nWidth;
+ }
+
+ lWidth += GetMargin2() - lPos;
+ pRuler_Imp->nTotalDist = lWidth;
+ lPos = lOrigLPos;
+
+ for(USHORT i = nStart; i < pColumnItem->Count() - 1; ++i)
+ {
+ lActWidth += pBorders[i].nPos - lPos;
+ lPos = pBorders[i].nPos + pBorders[i].nWidth;
+ pRuler_Imp->pPercBuf[i] = (USHORT)((lActWidth * 1000)
+ / pRuler_Imp->nTotalDist);
+ pRuler_Imp->pBlockBuf[i] = (USHORT)lActBorderSum;
+ lActBorderSum += pBorders[i].nWidth;
+ }
+ }
+ }
+ break;
+ case RULER_TYPE_TAB:
+ {
+ const USHORT nIdx = GetDragAryPos()+TAB_GAP;
+ pRuler_Imp->nTotalDist -= pTabs[nIdx].nPos;
+ pRuler_Imp->SetPercSize(nTabCount);
+ for(USHORT n=0;n<=nIdx;pRuler_Imp->pPercBuf[n++]=0) ;
+ for(USHORT i = nIdx+1; i < nTabCount; ++i)
+ {
+ const long nDelta = pTabs[i].nPos - pTabs[nIdx].nPos;
+ pRuler_Imp->pPercBuf[i] = (USHORT)((nDelta * 1000) / pRuler_Imp->nTotalDist);
+ }
+ break;
+ }
+ }
+}
+
+
+void SvxRuler::EvalModifier()
+
+/*
+ [Beschreibung]
+
+ Modifier Draggen auswerten
+
+ Shift: Linear verschieben
+ Control: Proportional verschieben
+ Shift+Control: Tabelle: nur aktuelle Zeile
+ alt: Bemassungspfeile (n.i.) //!!
+
+*/
+
+{
+ USHORT nModifier = GetDragModifier();
+ if(pRuler_Imp->bIsTableRows)
+ {
+ //rows can only be moved in one way, additionally current column is possible
+ if(nModifier == KEY_SHIFT)
+ nModifier = 0;
+ }
+ switch(nModifier)
+ {
+ case KEY_SHIFT:
+ nDragType = DRAG_OBJECT_SIZE_LINEAR;
+ break;
+ case KEY_MOD1: {
+ const RulerType eType = GetDragType();
+ nDragType = DRAG_OBJECT_SIZE_PROPORTIONAL;
+ if( RULER_TYPE_TAB == eType ||
+ ( ( RULER_TYPE_BORDER == eType || RULER_TYPE_MARGIN1 == eType ||
+ RULER_TYPE_MARGIN2 == eType ) &&
+ pColumnItem ) )
+ PrepareProportional_Impl(eType);
+ break;
+ }
+ case KEY_MOD1 | KEY_SHIFT:
+ if(GetDragType()!=RULER_TYPE_MARGIN1&&
+ GetDragType()!=RULER_TYPE_MARGIN2)
+ nDragType = DRAG_OBJECT_ACTLINE_ONLY;
+ break;
+ // alt: Bemassungspfeile
+ }
+}
+
+
+void __EXPORT SvxRuler::Click()
+
+/*
+ [Beschreibung]
+
+ Ueberladener Handler SV; setzt Tab per Dispatcheraufruf
+
+*/
+
+{
+ Ruler::Click();
+ if( bActive )
+ {
+ pBindings->Update( SID_RULER_LR_MIN_MAX );
+ pBindings->Update( SID_ATTR_LONG_ULSPACE );
+ pBindings->Update( SID_ATTR_LONG_LRSPACE );
+ pBindings->Update( SID_RULER_PAGE_POS );
+ pBindings->Update( bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL);
+ pBindings->Update( bHorz ? SID_ATTR_PARA_LRSPACE : SID_ATTR_PARA_LRSPACE_VERTICAL);
+ pBindings->Update( bHorz ? SID_RULER_BORDERS : SID_RULER_BORDERS_VERTICAL);
+ pBindings->Update( bHorz ? SID_RULER_ROWS : SID_RULER_ROWS_VERTICAL);
+ pBindings->Update( SID_RULER_OBJECT );
+ pBindings->Update( SID_RULER_PROTECT );
+ pBindings->Update( SID_ATTR_PARA_LRSPACE_VERTICAL );
+ }
+ BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
+ if(pTabStopItem &&
+ (nFlags & SVXRULER_SUPPORT_TABS) == SVXRULER_SUPPORT_TABS)
+ {
+ BOOL bContentProtected = pRuler_Imp->aProtectItem.IsCntntProtected();
+ if( bContentProtected ) return;
+ const long lPos = GetClickPos();
+ if((bRTL && lPos < Min(GetFirstLineIndent(), GetLeftIndent()) && lPos > GetRightIndent()) ||
+ (!bRTL && lPos > Min(GetFirstLineIndent(), GetLeftIndent()) && lPos < GetRightIndent()))
+ {
+ //convert position in left-to-right text
+ long nTabPos;
+ //#i24363# tab stops relative to indent
+ if(bRTL)
+ nTabPos = ( pRuler_Imp->bIsTabsRelativeToIndent ?
+ GetLeftIndent() :
+ ConvertHPosPixel( GetRightFrameMargin() + lAppNullOffset ) ) -
+ lPos;
+ else
+ nTabPos = lPos -
+ ( pRuler_Imp->bIsTabsRelativeToIndent ?
+ GetLeftIndent() :
+ 0 );
+
+ SvxTabStop aTabStop(ConvertHPosLogic(nTabPos),
+ ToAttrTab_Impl(nDefTabType));
+ pTabStopItem->Insert(aTabStop);
+ UpdateTabs();
+ }
+ }
+}
+
+
+BOOL SvxRuler::CalcLimits
+(
+ long &nMax1, // zu setzenden Minimalwert
+ long &nMax2, // zu setzenden Maximalwert
+ BOOL
+) const
+/*
+ [Beschreibung]
+
+ Defaultimplementierung der virtuellen Funktion; kann die Applikation
+ ueberladen, um eine eigene Grenzwertbehandlung zu implementieren.
+ Die Werte sind auf die Seite bezogen.
+*/
+{
+ nMax1 = LONG_MIN;
+ nMax2 = LONG_MAX;
+ return FALSE;
+}
+
+
+void SvxRuler::CalcMinMax()
+
+/*
+ [Beschreibung]
+
+ Berechnet die Grenzwerte fuers Draggen; diese sind in Pixeln
+ relativ zum Seitenrand
+
+*/
+
+{
+ BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
+ const long lNullPix = ConvertPosPixel(lLogicNullOffset);
+ pRuler_Imp->lMaxLeftLogic=pRuler_Imp->lMaxRightLogic=-1;
+ switch(GetDragType())
+ {
+ case RULER_TYPE_MARGIN1:
+ { // linker Rand umgebender Frame
+ // DragPos - NOf zwischen links - rechts
+ pRuler_Imp->lMaxLeftLogic = GetLeftMin();
+ nMaxLeft=ConvertSizePixel(pRuler_Imp->lMaxLeftLogic);
+
+ if(!pColumnItem || pColumnItem->Count() == 1 )
+ {
+ if(bRTL)
+ {
+ nMaxRight = lNullPix - GetRightIndent() +
+ Max(GetFirstLineIndent(), GetLeftIndent()) -
+ lMinFrame;
+ }
+ else
+ {
+ nMaxRight = lNullPix + GetRightIndent() -
+ Max(GetFirstLineIndent(), GetLeftIndent()) -
+ lMinFrame;
+ }
+ }
+ else if(pRuler_Imp->bIsTableRows)
+ {
+ //top border is not moveable when table rows are displayed
+ // protection of content means the margin is not moveable - it's just a page break inside of a cell
+ if(bHorz && !pRuler_Imp->aProtectItem.IsCntntProtected())
+ {
+ nMaxLeft = pBorders[0].nMinPos + lNullPix;
+ if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
+ nMaxRight = GetRightIndent() + lNullPix -
+ (pColumnItem->Count() - 1 ) * lMinFrame;
+ else
+ nMaxRight = pBorders[0].nPos - lMinFrame + lNullPix;
+ }
+ else
+ nMaxLeft = nMaxRight = lNullPix;
+ }
+ else
+ {
+ if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
+ //nDragType & DRAG_OBJECT_SIZE_LINEAR)
+ {
+ nMaxRight=lNullPix+CalcPropMaxRight();
+ }
+ else if(nDragType & DRAG_OBJECT_SIZE_LINEAR)
+ {
+ nMaxRight = ConvertPosPixel(
+ GetPageWidth() - (
+ (pColumnItem->IsTable() && pLRSpaceItem)
+ ? pLRSpaceItem->GetRight() : 0))
+ - GetMargin2() + GetMargin1();
+ }
+ else
+ {
+ nMaxRight = lNullPix - lMinFrame;
+ if(pColumnItem->IsFirstAct())
+ {
+ if(bRTL)
+ {
+ nMaxRight += Min(
+ pBorders[0].nPos,
+ Max(GetFirstLineIndent(), GetLeftIndent()) - GetRightIndent());
+ }
+ else
+ {
+ nMaxRight += Min(
+ pBorders[0].nPos, GetRightIndent() -
+ Max(GetFirstLineIndent(), GetLeftIndent()));
+ }
+ }
+ else if( pColumnItem->Count() > 1 )
+ nMaxRight += pBorders[0].nPos;
+ else
+ nMaxRight +=GetRightIndent() -
+ Max(GetFirstLineIndent(), GetLeftIndent());
+ // den linken Tabellen-Rand nicht ueber den Seitenrand ziehen
+ if(pLRSpaceItem&&pColumnItem->IsTable())
+ {
+ long nTmp=ConvertSizePixel(pLRSpaceItem->GetLeft());
+ if(nTmp>nMaxLeft)
+ nMaxLeft=nTmp;
+ }
+ }
+ }
+ break;
+ }
+ case RULER_TYPE_MARGIN2:
+ { // rechter Rand umgebender Frame
+ pRuler_Imp->lMaxRightLogic =
+ pMinMaxItem ?
+ GetPageWidth() - GetRightMax() : GetPageWidth();
+ nMaxRight = ConvertSizePixel(pRuler_Imp->lMaxRightLogic);
+
+
+ if(!pColumnItem)
+ {
+ if(bRTL)
+ {
+ nMaxLeft = GetMargin2() + GetRightIndent() -
+ Max(GetFirstLineIndent(),GetLeftIndent()) - GetMargin1()+
+ lMinFrame + lNullPix;
+ }
+ else
+ {
+ nMaxLeft = GetMargin2() - GetRightIndent() +
+ Max(GetFirstLineIndent(),GetLeftIndent()) - GetMargin1()+
+ lMinFrame + lNullPix;
+ }
+ }
+ else if(pRuler_Imp->bIsTableRows)
+ {
+ // get the bottom move range from the last border position - only available for rows!
+ // protection of content means the margin is not moveable - it's just a page break inside of a cell
+ if(bHorz || pRuler_Imp->aProtectItem.IsCntntProtected())
+ {
+ nMaxLeft = nMaxRight = pBorders[pColumnItem->Count() - 1].nMaxPos + lNullPix;
+ }
+ else
+ {
+ if(nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)
+ {
+ nMaxLeft = (pColumnItem->Count()) * lMinFrame + lNullPix;
+ }
+ else
+ {
+ if(pColumnItem->Count() > 1)
+ nMaxLeft = pBorders[pColumnItem->Count() - 2].nPos + lMinFrame + lNullPix;
+ else
+ nMaxLeft = lMinFrame + lNullPix;
+ }
+ if(pColumnItem->Count() > 1)
+ nMaxRight = pBorders[pColumnItem->Count() - 2].nMaxPos + lNullPix;
+ else
+ nMaxRight -= GetRightIndent() - lNullPix;
+ }
+ }
+ else
+ {
+ nMaxLeft = lMinFrame + lNullPix;
+ if(IsActLastColumn() || pColumnItem->Count() < 2 ) //Falls letzte Spalte aktiv
+ {
+ if(bRTL)
+ {
+ nMaxLeft = lMinFrame + lNullPix + GetMargin2() +
+ GetRightIndent() - Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ }
+ else
+ {
+ nMaxLeft = lMinFrame + lNullPix + GetMargin2() -
+ GetRightIndent() + Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ }
+ }
+ if( pColumnItem->Count() >= 2 )
+ {
+ long nNewMaxLeft =
+ lMinFrame + lNullPix +
+ pBorders[pColumnItem->Count()-2].nPos +
+ pBorders[pColumnItem->Count()-2].nWidth;
+ nMaxLeft=Max(nMaxLeft,nNewMaxLeft);
+ }
+
+ }
+ break;
+ }
+ case RULER_TYPE_BORDER:
+ { // Tabelle, Spalten (Modifier)
+ const USHORT nIdx = GetDragAryPos();
+ switch(GetDragSize())
+ {
+ case RULER_DRAGSIZE_1 :
+ {
+ nMaxRight = pBorders[nIdx].nPos +
+ pBorders[nIdx].nWidth + lNullPix;
+
+ if(0 == nIdx)
+ nMaxLeft = lNullPix;
+ else
+ nMaxLeft = pBorders[nIdx-1].nPos +
+ pBorders[nIdx-1].nWidth + lNullPix;
+ if(nIdx == pColumnItem->GetActColumn())
+ {
+ if(bRTL)
+ {
+ nMaxLeft += pBorders[nIdx].nPos +
+ GetRightIndent() - Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ }
+ else
+ {
+ nMaxLeft += pBorders[nIdx].nPos -
+ GetRightIndent() + Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ }
+ if(0 != nIdx)
+ nMaxLeft -= pBorders[nIdx-1].nPos +
+ pBorders[nIdx-1].nWidth;
+ }
+ nMaxLeft += lMinFrame;
+ nMaxLeft += nDragOffset;
+ break;
+ }
+ case RULER_DRAGSIZE_MOVE:
+ {
+ if(pColumnItem)
+ {
+ //nIdx contains the position of the currently moved item
+ //next visible separator on the left
+ USHORT nLeftCol=GetActLeftColumn(FALSE, nIdx);
+ //next visible separator on the right
+ USHORT nRightCol=GetActRightColumn(FALSE, nIdx);
+ //next separator on the left - regardless if visible or not
+ USHORT nActLeftCol=GetActLeftColumn();
+ //next separator on the right - regardless if visible or not
+ USHORT nActRightCol=GetActRightColumn();
+ if(pColumnItem->IsTable())
+ {
+ if(nDragType & DRAG_OBJECT_ACTLINE_ONLY)
+ {
+ //the current row/column should be modified only
+ //then the next/previous visible border position
+ //marks the min/max positions
+ nMaxLeft = nLeftCol == USHRT_MAX ?
+ 0 :
+ pBorders[nLeftCol].nPos;
+ //rows can always be increased without a limit
+ if(pRuler_Imp->bIsTableRows)
+ nMaxRight = pBorders[nIdx].nMaxPos;
+ else
+ nMaxRight = nRightCol == USHRT_MAX ?
+ GetMargin2():
+ pBorders[nRightCol].nPos;
+ nMaxLeft += lNullPix;
+ nMaxRight += lNullPix;
+ }
+ else
+ {
+ if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType && !bHorz && pRuler_Imp->bIsTableRows)
+ nMaxLeft = (nIdx + 1) * lMinFrame + lNullPix;
+ else
+ nMaxLeft = pBorders[nIdx].nMinPos + lNullPix;
+ if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType||
+ (DRAG_OBJECT_SIZE_LINEAR & nDragType) )
+ {
+ if(pRuler_Imp->bIsTableRows)
+ {
+ if(bHorz)
+ nMaxRight = GetRightIndent() + lNullPix -
+ (pColumnItem->Count() - nIdx - 1) * lMinFrame;
+ else
+ nMaxRight = pBorders[nIdx].nMaxPos + lNullPix;
+ }
+ else
+ nMaxRight=lNullPix+CalcPropMaxRight(nIdx);
+ }
+ else
+ nMaxRight = pBorders[nIdx].nMaxPos + lNullPix;
+ }
+ nMaxLeft += lMinFrame;
+ nMaxRight -= lMinFrame;
+
+ }
+ else
+ {
+ if(nLeftCol==USHRT_MAX)
+ nMaxLeft=lNullPix;
+ else
+ nMaxLeft = pBorders[nLeftCol].nPos +
+ pBorders[nLeftCol].nWidth + lNullPix;
+
+ if(nActRightCol == nIdx)
+ {
+ if(bRTL)
+ {
+ nMaxLeft += pBorders[nIdx].nPos +
+ GetRightIndent() - Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ if(nActLeftCol!=USHRT_MAX)
+ nMaxLeft -= pBorders[nActLeftCol].nPos +
+ pBorders[nActLeftCol].nWidth;
+ }
+ else
+ {
+ nMaxLeft += pBorders[nIdx].nPos -
+ GetRightIndent() + Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ if(nActLeftCol!=USHRT_MAX)
+ nMaxLeft -= pBorders[nActLeftCol].nPos +
+ pBorders[nActLeftCol].nWidth;
+ }
+ }
+ nMaxLeft += lMinFrame;
+ nMaxLeft += nDragOffset;
+
+ // nMaxRight
+ // linear / proprotional verschieben
+ if(DRAG_OBJECT_SIZE_PROPORTIONAL & nDragType||
+ (DRAG_OBJECT_SIZE_LINEAR & nDragType) )
+ {
+ nMaxRight=lNullPix+CalcPropMaxRight(nIdx);
+ }
+ else if(DRAG_OBJECT_SIZE_LINEAR & nDragType)
+ {
+ nMaxRight=lNullPix+GetMargin2()-GetMargin1()+
+ (nBorderCount-nIdx-1)*lMinFrame;
+ }
+ else
+ {
+ if(nRightCol==USHRT_MAX)
+ { // letzte Spalte
+ nMaxRight = GetMargin2() + lNullPix;
+ if(IsActLastColumn())
+ {
+ if(bRTL)
+ {
+ nMaxRight -=
+ GetMargin2() + GetRightIndent() -
+ Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ }
+ else
+ {
+ nMaxRight -=
+ GetMargin2() - GetRightIndent() +
+ Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ }
+ nMaxRight += pBorders[nIdx].nPos +
+ pBorders[nIdx].nWidth;
+ }
+ }
+ else
+ {
+ nMaxRight = lNullPix + pBorders[nRightCol].nPos;
+ USHORT nNotHiddenRightCol =
+ GetActRightColumn(TRUE, nIdx);
+
+ if( nActLeftCol == nIdx )
+ {
+ long nBorder = nNotHiddenRightCol ==
+ USHRT_MAX ?
+ GetMargin2() :
+ pBorders[nNotHiddenRightCol].nPos;
+ if(bRTL)
+ {
+ nMaxRight -= nBorder + GetRightIndent() -
+ Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ }
+ else
+ {
+ nMaxRight -= nBorder - GetRightIndent() +
+ Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ }
+ nMaxRight += pBorders[nIdx].nPos +
+ pBorders[nIdx].nWidth;
+ }
+ }
+ nMaxRight -= lMinFrame;
+ nMaxRight -= pBorders[nIdx].nWidth;
+ }
+ }
+ }
+ // ObjectItem
+ else
+ {
+ if(pObjectItem->HasLimits())
+ {
+ if(CalcLimits(nMaxLeft, nMaxRight, nIdx & 1? FALSE: TRUE))
+ {
+ nMaxLeft = ConvertPosPixel(nMaxLeft);
+ nMaxRight = ConvertPosPixel(nMaxRight);
+ }
+ }
+ else
+ {
+ nMaxLeft = LONG_MIN;
+ nMaxRight = LONG_MAX;
+ }
+ }
+ break;
+ }
+ case RULER_DRAGSIZE_2:
+ {
+ nMaxLeft = lNullPix + pBorders[nIdx].nPos;
+ if(nIdx == pColumnItem->Count()-2) { // letzte Spalte
+ nMaxRight = GetMargin2() + lNullPix;
+ if(pColumnItem->IsLastAct()) {
+ nMaxRight -=
+ GetMargin2() - GetRightIndent() +
+ Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ nMaxRight += pBorders[nIdx].nPos +
+ pBorders[nIdx].nWidth;
+ }
+ }
+ else {
+ nMaxRight = lNullPix + pBorders[nIdx+1].nPos;
+ if(pColumnItem->GetActColumn()-1 == nIdx) {
+ nMaxRight -= pBorders[nIdx+1].nPos - GetRightIndent() +
+ Max(GetFirstLineIndent(),
+ GetLeftIndent());
+ nMaxRight += pBorders[nIdx].nPos +
+ pBorders[nIdx].nWidth;
+ }
+ }
+ nMaxRight -= lMinFrame;
+ nMaxRight -= pBorders[nIdx].nWidth;
+ break;
+ }
+ }
+ nMaxRight += nDragOffset;
+ break;
+ }
+ case RULER_TYPE_INDENT:
+ {
+ const USHORT nIdx = GetDragAryPos();
+ switch(nIdx) {
+ case INDENT_FIRST_LINE - INDENT_GAP:
+ case INDENT_LEFT_MARGIN - INDENT_GAP:
+ {
+ if(bRTL)
+ {
+ nMaxLeft = lNullPix + GetRightIndent();
+
+ if(pColumnItem && !pColumnItem->IsFirstAct())
+ nMaxLeft += pBorders[pColumnItem->GetActColumn()-1].nPos +
+ pBorders[pColumnItem->GetActColumn()-1].nWidth;
+ nMaxRight = lNullPix + GetMargin2();
+
+ // zusammem draggen
+ if((INDENT_FIRST_LINE - INDENT_GAP) != nIdx &&
+ (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
+ DRAG_OBJECT_LEFT_INDENT_ONLY)
+ {
+ if(GetLeftIndent() > GetFirstLineIndent())
+ nMaxLeft += GetLeftIndent() - GetFirstLineIndent();
+ else
+ nMaxRight -= GetFirstLineIndent() - GetLeftIndent();
+ }
+ }
+ else
+ {
+ nMaxLeft = lNullPix;
+
+ if(pColumnItem && !pColumnItem->IsFirstAct())
+ nMaxLeft += pBorders[pColumnItem->GetActColumn()-1].nPos +
+ pBorders[pColumnItem->GetActColumn()-1].nWidth;
+ nMaxRight = lNullPix + GetRightIndent() - lMinFrame;
+
+ // zusammem draggen
+ if((INDENT_FIRST_LINE - INDENT_GAP) != nIdx &&
+ (nDragType & DRAG_OBJECT_LEFT_INDENT_ONLY) !=
+ DRAG_OBJECT_LEFT_INDENT_ONLY)
+ {
+ if(GetLeftIndent() > GetFirstLineIndent())
+ nMaxLeft += GetLeftIndent() - GetFirstLineIndent();
+ else
+ nMaxRight -= GetFirstLineIndent() - GetLeftIndent();
+ }
+ }
+ }
+ break;
+ case INDENT_RIGHT_MARGIN - INDENT_GAP:
+ {
+ if(bRTL)
+ {
+ nMaxLeft = lNullPix;
+ nMaxRight = lNullPix + Min(GetFirstLineIndent(), GetLeftIndent()) - lMinFrame;
+ if(pColumnItem)
+ {
+ USHORT nRightCol=GetActRightColumn( TRUE );
+ if(!IsActLastColumn( TRUE ))
+ nMaxRight += pBorders[nRightCol].nPos;
+ else
+ nMaxRight += GetMargin2();
+ }
+ else
+ nMaxLeft += GetMargin1();
+ nMaxLeft += lMinFrame;
+ }
+ else
+ {
+ nMaxLeft = lNullPix +
+ Max(GetFirstLineIndent(), GetLeftIndent());
+ nMaxRight = lNullPix;
+ if(pColumnItem)
+ {
+ USHORT nRightCol=GetActRightColumn( TRUE );
+ if(!IsActLastColumn( TRUE ))
+ nMaxRight += pBorders[nRightCol].nPos;
+ else
+ nMaxRight += GetMargin2();
+ }
+ else
+ nMaxRight += GetMargin2();
+ nMaxLeft += lMinFrame;
+ }
+ }
+ break;
+ }
+ break;
+ }
+ case RULER_TYPE_TAB: // Tabs (Modifier)
+ /*
+ links = NOf + Max(LAR, EZ)
+ rechts = NOf + RAR
+ */
+ nMaxLeft = bRTL ? lNullPix + GetRightIndent()
+ : lNullPix + Min(GetFirstLineIndent(), GetLeftIndent());
+ pRuler_Imp->lMaxRightLogic=GetLogicRightIndent()+lLogicNullOffset;
+ nMaxRight = ConvertSizePixel(pRuler_Imp->lMaxRightLogic);
+ break;
+ default: ; //prevent warning
+ }
+#ifdef DEBUGLIN
+ {
+ String aStr("MinLeft: ");
+ Size aSize(nMaxLeft + lNullPix, 0);
+ Size aSize2(nMaxRight + lNullPix, 0);
+ aSize = pEditWin->PixelToLogic(aSize, MapMode(MAP_MM));
+ aSize2 = pEditWin->PixelToLogic(aSize2, MapMode(MAP_MM));
+ aStr += String(aSize.Width());
+ aStr += " MaxRight: ";
+ aStr += String(aSize2.Width());
+ InfoBox(0, aStr).Execute();
+ }
+#endif
+}
+
+
+long __EXPORT SvxRuler::StartDrag()
+
+/*
+ [Beschreibung]
+
+ Beginn eines Drag-Vorgangs (SV-Handler); wertet Modifier aus
+ und berechnet Grenzwerte
+
+ [Querverweise]
+
+ <SvxRuler::EvalModifier()>
+ <SvxRuler::CalcMinMax()>
+ <SvxRuler::EndDrag()>
+
+*/
+
+{
+ BOOL bContentProtected = pRuler_Imp->aProtectItem.IsCntntProtected();
+ if(!bValid)
+ return FALSE;
+
+ pRuler_Imp->lLastLMargin=GetMargin1();
+ pRuler_Imp->lLastRMargin=GetMargin2();
+ long bOk = 1;
+ if(GetStartDragHdl().IsSet())
+ bOk = Ruler::StartDrag();
+ if(bOk) {
+ lInitialDragPos = GetDragPos();
+ switch(GetDragType()) {
+ case RULER_TYPE_MARGIN1: // linker Rand umgebender Frame
+ case RULER_TYPE_MARGIN2: // rechter Rand umgebender Frame
+ if((bHorz && pLRSpaceItem) || (!bHorz && pULSpaceItem))
+ {
+ if(pColumnItem)
+ EvalModifier();
+ else
+ nDragType = DRAG_OBJECT;
+ }
+ else
+ bOk = FALSE;
+ break;
+ case RULER_TYPE_BORDER: // Tabelle, Spalten (Modifier)
+ if(pColumnItem)
+ {
+ nDragOffset = pColumnItem->IsTable()? 0 :
+ GetDragPos() - pBorders[GetDragAryPos()].nPos;
+ EvalModifier();
+
+ }
+ else
+ nDragOffset = 0;
+ break;
+ case RULER_TYPE_INDENT: { // Absatzeinzuege (Modifier)
+ if( bContentProtected )
+ return FALSE;
+ USHORT nIndent = INDENT_LEFT_MARGIN;
+ if((nIndent) == GetDragAryPos() + INDENT_GAP) { // Linker Absatzeinzug
+ pIndents[0] = pIndents[INDENT_FIRST_LINE];
+ pIndents[0].nStyle |= RULER_STYLE_DONTKNOW;
+ EvalModifier();
+ }
+ else
+ nDragType = DRAG_OBJECT;
+ pIndents[1] = pIndents[GetDragAryPos()+INDENT_GAP];
+ pIndents[1].nStyle |= RULER_STYLE_DONTKNOW;
+ break;
+ }
+ case RULER_TYPE_TAB: // Tabs (Modifier)
+ if( bContentProtected ) return FALSE;
+ EvalModifier();
+ pTabs[0] = pTabs[GetDragAryPos()+1];
+ pTabs[0].nStyle |= RULER_STYLE_DONTKNOW;
+ break;
+ default:
+ nDragType = NONE;
+ }
+ }
+ else
+ nDragType = NONE;
+ if(bOk)
+ CalcMinMax();
+ return bOk;
+}
+
+
+void __EXPORT SvxRuler::Drag()
+/*
+ [Beschreibung]
+
+ SV-Draghandler
+
+*/
+{
+ if(IsDragCanceled())
+ {
+ Ruler::Drag();
+ return;
+ }
+ switch(GetDragType()) {
+ case RULER_TYPE_MARGIN1: // linker Rand umgebender Frame
+ DragMargin1();
+ pRuler_Imp->lLastLMargin=GetMargin1();
+ break;
+ case RULER_TYPE_MARGIN2: // rechter Rand umgebender Frame
+ DragMargin2();
+ pRuler_Imp->lLastRMargin = GetMargin2();
+ break;
+ case RULER_TYPE_INDENT: // Absatzeinzuege
+ DragIndents();
+ break;
+ case RULER_TYPE_BORDER: // Tabelle, Spalten
+ if(pColumnItem)
+ DragBorders();
+ else if(pObjectItem)
+ DragObjectBorder();
+ break;
+ case RULER_TYPE_TAB: // Tabs
+ DragTabs();
+ break;
+ default: ;//prevent warning
+ }
+ Ruler::Drag();
+}
+
+
+void __EXPORT SvxRuler::EndDrag()
+/*
+ [Beschreibung]
+
+ SV-Handler; wird beim Beenden des Draggens gerufen.
+ Stoesst die Aktualisierung der Daten der Applikation an, indem
+ durch Aufruf der jeweiligen Apply...()- Methoden die Daten an die
+ Applikation geschickt werden.
+
+*/
+{
+ const BOOL bUndo = IsDragCanceled();
+ const long lPos = GetDragPos();
+ DrawLine_Impl(lTabPos, 6, bHorz);
+ lTabPos=-1;
+ if(!bUndo)
+ switch(GetDragType())
+ {
+ case RULER_TYPE_MARGIN1: // linker, oberer Rand umgebender Frame
+ case RULER_TYPE_MARGIN2: // rechter, unterer Rand umgebender Frame
+ {
+ if(!pColumnItem || !pColumnItem->IsTable())
+ ApplyMargins();
+
+ if(pColumnItem &&
+ (pColumnItem->IsTable() ||
+ (nDragType & DRAG_OBJECT_SIZE_PROPORTIONAL)))
+ ApplyBorders();
+
+ }
+ break;
+ case RULER_TYPE_BORDER: // Tabelle, Spalten
+ if(lInitialDragPos != lPos ||
+ (pRuler_Imp->bIsTableRows && bHorz)) //special case - the null offset is changed here
+ {
+ if(pColumnItem)
+ {
+ ApplyBorders();
+ if(bHorz)
+ UpdateTabs();
+ }
+ else if(pObjectItem)
+ ApplyObject();
+ }
+ break;
+ case RULER_TYPE_INDENT: // Absatzeinzuege
+ if(lInitialDragPos != lPos)
+ ApplyIndents();
+ SetIndents(INDENT_COUNT, pIndents+INDENT_GAP);
+ break;
+ case RULER_TYPE_TAB: // Tabs
+ {
+ ApplyTabs();
+ pTabs[GetDragAryPos()].nStyle &= ~RULER_STYLE_INVISIBLE;
+ SetTabs(nTabCount, pTabs+TAB_GAP);
+ }
+ break;
+ default: ; //prevent warning
+ }
+ nDragType = NONE;
+ Ruler::EndDrag();
+ if(bUndo)
+ for(USHORT i=0;i<pRuler_Imp->nControlerItems;i++)
+ {
+ pCtrlItem[i]->ClearCache();
+ pCtrlItem[i]->GetBindings().Invalidate(pCtrlItem[i]->GetId());
+ // pCtrlItem[i]->UnBind();
+// pCtrlItem[i]->ReBind();
+ }
+}
+
+
+void __EXPORT SvxRuler::ExtraDown()
+
+/*
+ [Beschreibung]
+
+ Ueberladene SV-Methode; setzt den neuen Typ fuer den Defaulttabulator.
+*/
+
+{
+ // Tabulator Typ umschalten
+ if(pTabStopItem &&
+ (nFlags & SVXRULER_SUPPORT_TABS) == SVXRULER_SUPPORT_TABS) {
+ ++nDefTabType;
+ if(RULER_TAB_DEFAULT == nDefTabType)
+ nDefTabType = RULER_TAB_LEFT;
+ SetExtraType(RULER_EXTRA_TAB, nDefTabType);
+ }
+ Ruler::ExtraDown();
+}
+
+
+void __EXPORT SvxRuler::Notify(SfxBroadcaster&, const SfxHint& rHint)
+/*
+
+ [Beschreibung]
+
+ Benachrichtigung durch die Bindings, dass die Statusaktualisierung
+ beendet ist.
+ Das Lineal aktualisiert seine Darstellung und meldet sich bei den
+ Bindings wieder ab.
+
+*/
+
+{
+ // Aktualisierung anstossen
+ if(bActive &&
+ rHint.Type() == TYPE(SfxSimpleHint) &&
+ ((SfxSimpleHint&) rHint ).GetId() == SFX_HINT_UPDATEDONE ) {
+ Update();
+ EndListening(*pBindings);
+ bValid = TRUE;
+ bListening = FALSE;
+ }
+}
+
+
+IMPL_LINK_INLINE_START( SvxRuler, MenuSelect, Menu *, pMenu )
+
+/*
+ [Beschreibung]
+
+ Handler des Kontextmenues fuer das Umschalten der Masseinheit
+
+*/
+
+{
+ SetUnit(FieldUnit(pMenu->GetCurItemId()));
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvxRuler, MenuSelect, Menu *, pMenu )
+
+
+IMPL_LINK( SvxRuler, TabMenuSelect, Menu *, pMenu )
+
+/*
+ [Beschreibung]
+
+ Handler des Tabulatormenues fuer das Setzen des Typs
+
+*/
+
+{
+ if(pTabStopItem && pTabStopItem->Count() > pRuler_Imp->nIdx)
+ {
+ SvxTabStop aTabStop = (*pTabStopItem)[pRuler_Imp->nIdx];
+ aTabStop.GetAdjustment() = ToAttrTab_Impl(pMenu->GetCurItemId()-1);
+ pTabStopItem->Remove(pRuler_Imp->nIdx);
+ pTabStopItem->Insert(aTabStop);
+ USHORT nTabStopId = bHorz ? SID_ATTR_TABSTOP : SID_ATTR_TABSTOP_VERTICAL;
+ pBindings->GetDispatcher()->Execute( nTabStopId, SFX_CALLMODE_RECORD, pTabStopItem, 0L );
+ UpdateTabs();
+ pRuler_Imp->nIdx = 0;
+ }
+ return 0;
+}
+
+
+void SvxRuler::Command( const CommandEvent& rCEvt )
+
+/*
+ [Beschreibung]
+
+ Mauskontextmenue fuer das Umschalten der Masseinheit
+
+*/
+
+{
+ if ( COMMAND_CONTEXTMENU == rCEvt.GetCommand() )
+ {
+ CancelDrag();
+ BOOL bRTL = pRuler_Imp->pTextRTLItem && pRuler_Imp->pTextRTLItem->GetValue();
+ if ( pTabs &&
+ RULER_TYPE_TAB ==
+ GetType( rCEvt.GetMousePosPixel(), &pRuler_Imp->nIdx ) &&
+ pTabs[pRuler_Imp->nIdx+TAB_GAP].nStyle < RULER_TAB_DEFAULT )
+ {
+ PopupMenu aMenu;
+ aMenu.SetSelectHdl(LINK(this, SvxRuler, TabMenuSelect));
+ VirtualDevice aDev;
+ const Size aSz(RULER_TAB_WIDTH+2, RULER_TAB_HEIGHT+2);
+ aDev.SetOutputSize(aSz);
+ aDev.SetBackground(Wallpaper(Color(COL_WHITE)));
+ const Point aPt(aSz.Width() / 2, aSz.Height() / 2);
+
+ for ( USHORT i = RULER_TAB_LEFT; i < RULER_TAB_DEFAULT; ++i )
+ {
+ USHORT nStyle = bRTL ? i|RULER_TAB_RTL : i;
+ nStyle |= (USHORT)(bHorz ? WB_HORZ : WB_VERT);
+ DrawTab(&aDev, aPt, nStyle);
+ aMenu.InsertItem(i+1,
+ String(ResId(RID_SVXSTR_RULER_START+i, DIALOG_MGR())),
+ Image(aDev.GetBitmap(Point(), aSz), Color(COL_WHITE)));
+ aMenu.CheckItem(i+1, i == pTabs[pRuler_Imp->nIdx+TAB_GAP].nStyle);
+ aDev.SetOutputSize(aSz); // device loeschen
+ }
+ aMenu.Execute( this, rCEvt.GetMousePosPixel() );
+ }
+ else
+ {
+ PopupMenu aMenu(ResId(RID_SVXMN_RULER, DIALOG_MGR()));
+ aMenu.SetSelectHdl(LINK(this, SvxRuler, MenuSelect));
+ FieldUnit eUnit = GetUnit();
+ const USHORT nCount = aMenu.GetItemCount();
+
+ BOOL bReduceMetric = 0 != (nFlags &SVXRULER_SUPPORT_REDUCED_METRIC);
+ for ( USHORT i = nCount; i; --i )
+ {
+ const USHORT nId = aMenu.GetItemId(i - 1);
+ aMenu.CheckItem(nId, nId == (USHORT)eUnit);
+ if(bReduceMetric &&
+ (nId == FUNIT_M ||
+ nId == FUNIT_KM ||
+ nId == FUNIT_FOOT ||
+ nId == FUNIT_MILE ||
+ nId == FUNIT_CHAR ||
+ nId == FUNIT_LINE ))
+ {
+ if (( nId == FUNIT_CHAR ) && bHorz )
+ ;
+ else if (( nId == FUNIT_LINE ) && !bHorz )
+ ;
+ else
+ aMenu.RemoveItem(i - 1);
+ }
+ }
+ aMenu.Execute( this, rCEvt.GetMousePosPixel() );
+ }
+ }
+ else
+ Ruler::Command( rCEvt );
+}
+
+
+USHORT SvxRuler::GetActRightColumn(
+ BOOL bForceDontConsiderHidden, USHORT nAct ) const
+{
+ if( nAct == USHRT_MAX )
+ nAct = pColumnItem->GetActColumn();
+ else nAct++; //Damit man die ActDrag uebergeben kann
+
+ BOOL bConsiderHidden = !bForceDontConsiderHidden &&
+ !( nDragType & DRAG_OBJECT_ACTLINE_ONLY );
+
+ while( nAct < pColumnItem->Count() - 1 )
+ {
+ if( (*pColumnItem)[nAct].bVisible || bConsiderHidden )
+ return nAct;
+ else
+ nAct++;
+ }
+ return USHRT_MAX;
+}
+
+
+
+USHORT SvxRuler::GetActLeftColumn(
+ BOOL bForceDontConsiderHidden, USHORT nAct ) const
+{
+ if(nAct==USHRT_MAX)
+ nAct=pColumnItem->GetActColumn();
+
+ USHORT nLOffs=1;
+
+ BOOL bConsiderHidden = !bForceDontConsiderHidden &&
+ !( nDragType & DRAG_OBJECT_ACTLINE_ONLY );
+
+ while(nAct>=nLOffs)
+ {
+ if( (*pColumnItem)[ nAct - nLOffs ].bVisible || bConsiderHidden )
+ return nAct-nLOffs;
+ else
+ nLOffs++;
+ }
+ return USHRT_MAX;
+}
+
+
+BOOL SvxRuler::IsActLastColumn(
+ BOOL bForceDontConsiderHidden, USHORT nAct) const
+{
+ return GetActRightColumn(bForceDontConsiderHidden, nAct)==USHRT_MAX;
+}
+
+BOOL SvxRuler::IsActFirstColumn(
+ BOOL bForceDontConsiderHidden, USHORT nAct) const
+{
+ return GetActLeftColumn(bForceDontConsiderHidden, nAct)==USHRT_MAX;
+}
+
+long SvxRuler::CalcPropMaxRight(USHORT nCol) const
+{
+
+ if(!(nDragType & DRAG_OBJECT_SIZE_LINEAR))
+ {
+
+ // ausgehend vom rechten Rand die Mindestbreiten
+ // aller betroffenen Spalten abziehen
+ long _nMaxRight = GetMargin2()-GetMargin1();
+
+ long lFences=0;
+ long lMinSpace=USHRT_MAX;
+ long lOldPos;
+ long lColumns=0;
+ USHORT nStart;
+ if(!pColumnItem->IsTable())
+ {
+ if(nCol==USHRT_MAX)
+ {
+ lOldPos=GetMargin1();
+ nStart=0;
+ }
+ else
+ {
+ lOldPos=pBorders[nCol].nPos+pBorders[nCol].nWidth;
+ nStart=nCol+1;
+ lFences=pBorders[nCol].nWidth;
+ }
+
+ for(USHORT i = nStart; i < nBorderCount-1; ++i)
+ {
+ long lWidth=pBorders[i].nPos-lOldPos;
+ lColumns+=lWidth;
+ if(lWidth<lMinSpace)
+ lMinSpace=lWidth;
+ lOldPos=pBorders[i].nPos+pBorders[i].nWidth;
+ lFences+=pBorders[i].nWidth;
+ }
+ long lWidth=GetMargin2()-lOldPos;
+ lColumns+=lWidth;
+ if(lWidth<lMinSpace)
+ lMinSpace=lWidth;
+ }
+ else
+ {
+ USHORT nActCol;
+ if(nCol==USHRT_MAX) //CalcMinMax fuer LeftMargin
+ {
+ lOldPos=GetMargin1();
+ }
+ else
+ {
+ lOldPos=pBorders[nCol].nPos;
+ }
+ lColumns=GetMargin2()-lOldPos;
+ nActCol=nCol;
+ lFences=0;
+ while(nActCol<nBorderCount||nActCol==USHRT_MAX)
+ {
+ USHORT nRight;
+ if(nActCol==USHRT_MAX)
+ {
+ nRight=0;
+ while(!(*pColumnItem)[nRight].bVisible)
+ nRight++;
+ }
+ else
+ nRight=GetActRightColumn(FALSE, nActCol);
+ long lWidth;
+ if(nRight!=USHRT_MAX)
+ {
+ lWidth=pBorders[nRight].nPos-lOldPos;
+ lOldPos=pBorders[nRight].nPos;
+ }
+ else
+ lWidth=GetMargin2()-lOldPos;
+ nActCol=nRight;
+ if(lWidth<lMinSpace)
+ lMinSpace=lWidth;
+ if(nActCol==USHRT_MAX)
+ break;
+ }
+ }
+
+ _nMaxRight-=(long)(lFences+lMinFrame/(float)lMinSpace*lColumns);
+ return _nMaxRight;
+ }
+ else
+ {
+ if(pColumnItem->IsTable())
+ {
+ USHORT nVisCols=0;
+ for(USHORT i=GetActRightColumn(FALSE, nCol);i<nBorderCount;)
+ {
+ if((*pColumnItem)[i].bVisible)
+ nVisCols++;
+ i=GetActRightColumn(FALSE, i);
+ }
+ return GetMargin2()-GetMargin1()-(nVisCols+1)*lMinFrame;
+ }
+ else
+ {
+ long lWidth=0;
+ for(USHORT i=nCol;i<nBorderCount-1;i++)
+ {
+ lWidth+=lMinFrame+pBorders[i].nWidth;
+ }
+ return GetMargin2()-GetMargin1()-lWidth;
+ }
+ }
+}
+/*-- 29.11.2007 08:24:23---------------------------------------------------
+ //#i24363# tab stops relative to indent
+ -----------------------------------------------------------------------*/
+void SvxRuler::SetTabsRelativeToIndent( BOOL bRel )
+{
+ pRuler_Imp->bIsTabsRelativeToIndent = bRel;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/swframeexample.cxx b/svx/source/dialog/swframeexample.cxx
new file mode 100644
index 000000000000..a9aff0893e7b
--- /dev/null
+++ b/svx/source/dialog/swframeexample.cxx
@@ -0,0 +1,739 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+
+#include <tools/poly.hxx>
+#include <vcl/metric.hxx>
+#include <vcl/svapp.hxx>
+#include <svtools/colorcfg.hxx>
+#include <swframeexample.hxx>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
+#include <com/sun/star/text/WrapTextMode.hpp>
+
+using namespace ::com::sun::star::text;
+
+#define FLYINFLY_BORDER 3
+#define DEMOTEXT "Ij"
+#define C2S(cChar) UniString::CreateFromAscii(cChar)
+
+
+SvxSwFrameExample::SvxSwFrameExample( Window *pParent, const ResId& rResID ) :
+
+ Window(pParent, rResID),
+
+ nHAlign (HoriOrientation::CENTER),
+ nHRel (RelOrientation::FRAME),
+ nVAlign (VertOrientation::TOP),
+ nVRel (RelOrientation::PRINT_AREA),
+ nWrap (WrapTextMode_NONE),
+ nAnchor (TextContentAnchorType_AT_PAGE),
+ bTrans (FALSE),
+ aRelPos (Point(0,0))
+{
+ InitColors_Impl();
+ SetMapMode(MAP_PIXEL);
+}
+
+SvxSwFrameExample::~SvxSwFrameExample()
+{
+}
+
+void SvxSwFrameExample::InitColors_Impl( void )
+{
+ const StyleSettings& rSettings = GetSettings().GetStyleSettings();
+ m_aBgCol = Color( rSettings.GetWindowColor() ); // old: COL_WHITE
+
+ BOOL bHC = rSettings.GetHighContrastMode();
+
+ m_aFrameColor = Color( COL_LIGHTGREEN );
+ m_aAlignColor = Color( COL_LIGHTRED );
+ m_aTransColor = Color( COL_TRANSPARENT );
+
+ m_aTxtCol = bHC?
+ svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR).nColor :
+ Color( COL_GRAY ); // old: COL_GRAY
+ m_aPrintAreaCol = bHC? m_aTxtCol : Color( COL_GRAY );
+ m_aBorderCol = m_aTxtCol; // old: COL_BLACK;
+ m_aBlankCol = bHC? m_aTxtCol : Color( COL_LIGHTGRAY );
+ m_aBlankFrameCol = bHC? m_aTxtCol : Color( COL_GRAY );
+}
+
+void SvxSwFrameExample::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ if( rDCEvt.GetType() == DATACHANGED_SETTINGS && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ InitColors_Impl();
+}
+
+void SvxSwFrameExample::InitAllRects_Impl()
+{
+// const Size aSz(GetOutputSizePixel());
+
+ // Seite
+// aPage.SetSize(Size(aSz.Width() - 3, aSz.Height() - 3));
+ aPage.SetSize( GetOutputSizePixel() );
+
+ ULONG nOutWPix = aPage.GetWidth();
+ ULONG nOutHPix = aPage.GetHeight();
+
+ // PrintArea
+ ULONG nLBorder;
+ ULONG nRBorder;
+ ULONG nTBorder;
+ ULONG nBBorder;
+
+ ULONG nLTxtBorder;
+ ULONG nRTxtBorder;
+ ULONG nTTxtBorder;
+ ULONG nBTxtBorder;
+
+ if (nAnchor != TextContentAnchorType_AS_CHARACTER)
+ {
+ nLBorder = 14;
+ nRBorder = 10;
+ nTBorder = 10;
+ nBBorder = 15;
+
+ nLTxtBorder = 8;
+ nRTxtBorder = 4;
+ nTTxtBorder = 2;
+ nBTxtBorder = 2;
+ }
+ else
+ {
+ nLBorder = 2;
+ nRBorder = 2;
+ nTBorder = 2;
+ nBBorder = 2;
+
+ nLTxtBorder = 2;
+ nRTxtBorder = 2;
+ nTTxtBorder = 2;
+ nBTxtBorder = 2;
+ }
+ aPagePrtArea = Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder));
+
+ // Beispiel-Text: Vorbereiten fuer die Textausgabe
+ // Eine Textzeile
+ aTextLine = aPagePrtArea;
+ aTextLine.SetSize(Size(aTextLine.GetWidth(), 2));
+ aTextLine.Left() += nLTxtBorder;
+ aTextLine.Right() -= nRTxtBorder;
+ aTextLine.Move(0, nTTxtBorder);
+
+ // Rechteck um Absatz incl. Raender
+ USHORT nLines = (USHORT)((aPagePrtArea.GetHeight() / 2 - nTTxtBorder - nBTxtBorder)
+ / (aTextLine.GetHeight() + 2));
+ aPara = aPagePrtArea;
+ aPara.SetSize(Size(aPara.GetWidth(),
+ (aTextLine.GetHeight() + 2) * nLines + nTTxtBorder + nBTxtBorder));
+
+ // Rechteck um Absatz ohne Raender
+ aParaPrtArea = aPara;
+ aParaPrtArea.Left() += nLTxtBorder;
+ aParaPrtArea.Right() -= nRTxtBorder;
+ aParaPrtArea.Top() += nTTxtBorder;
+ aParaPrtArea.Bottom() -= nBTxtBorder;
+
+ if (nAnchor == TextContentAnchorType_AS_CHARACTER || nAnchor == TextContentAnchorType_AT_CHARACTER)
+ {
+ Font aFont = OutputDevice::GetDefaultFont(
+ DEFAULTFONT_LATIN_TEXT, Application::GetSettings().GetLanguage(),
+ DEFAULTFONT_FLAGS_ONLYONE, this );
+ aFont.SetColor( m_aTxtCol );
+ aFont.SetFillColor( m_aBgCol );
+ aFont.SetWeight(WEIGHT_NORMAL);
+
+ if (nAnchor == TextContentAnchorType_AS_CHARACTER)
+ {
+ aFont.SetSize(Size(0, aParaPrtArea.GetHeight() - 2));
+ SetFont(aFont);
+ aParaPrtArea.SetSize(Size(GetTextWidth(C2S(DEMOTEXT)), GetTextHeight()));
+ }
+ else
+ {
+ aFont.SetSize(Size(0, aParaPrtArea.GetHeight() / 2));
+ SetFont(aFont);
+ aAutoCharFrame.SetSize(Size(GetTextWidth('A'), GetTextHeight()));
+ aAutoCharFrame.SetPos(Point(aParaPrtArea.Left() + (aParaPrtArea.GetWidth() - aAutoCharFrame.GetWidth()) / 2,
+ aParaPrtArea.Top() + (aParaPrtArea.GetHeight() - aAutoCharFrame.GetHeight()) / 2));
+ }
+ }
+
+ // Innerer Frame fuer am Frame verankerte Rahmen
+ aFrameAtFrame = aPara;
+ aFrameAtFrame.Left() += 9;
+ aFrameAtFrame.Right() -= 5;
+ aFrameAtFrame.Bottom() += 5;
+ aFrameAtFrame.SetPos(Point(aFrameAtFrame.Left() + 2, (aPagePrtArea.Bottom() - aFrameAtFrame.GetHeight()) / 2 + 5));
+
+ // Groesse des zu positionierenden Rahmens
+ if (nAnchor != TextContentAnchorType_AS_CHARACTER)
+ {
+ ULONG nLFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nLBorder : nLTxtBorder;
+ ULONG nRFBorder = nAnchor == TextContentAnchorType_AT_PAGE ? nRBorder : nRTxtBorder;
+
+ switch (nHRel)
+ {
+ case RelOrientation::PAGE_LEFT:
+ case RelOrientation::FRAME_LEFT:
+ aFrmSize = Size(nLFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
+ break;
+
+ case RelOrientation::PAGE_RIGHT:
+ case RelOrientation::FRAME_RIGHT:
+ aFrmSize = Size(nRFBorder - 4, (aTextLine.GetHeight() + 2) * 3);
+ break;
+
+ default:
+ aFrmSize = Size(nLBorder - 3, (aTextLine.GetHeight() + 2) * 3);
+ break;
+ }
+ aFrmSize.Width() = Max(5L, aFrmSize.Width());
+ aFrmSize.Height() = Max(5L, aFrmSize.Height());
+ }
+ else
+ {
+ ULONG nFreeWidth = aPagePrtArea.GetWidth() - GetTextWidth(C2S(DEMOTEXT));
+
+ aFrmSize = Size(nFreeWidth / 2, (aTextLine.GetHeight() + 2) * 3);
+ aDrawObj.SetSize(Size(Max(5L, (long)nFreeWidth / 3L), Max(5L, aFrmSize.Height() * 3L)));
+ aDrawObj.SetPos(Point(aParaPrtArea.Right() + 1, aParaPrtArea.Bottom() / 2));
+ aParaPrtArea.Right() = aDrawObj.Right();
+ }
+}
+
+void SvxSwFrameExample::CalcBoundRect_Impl(Rectangle &rRect)
+{
+ switch (nAnchor)
+ {
+ case TextContentAnchorType_AT_PAGE:
+ {
+ switch (nHRel)
+ {
+ case RelOrientation::FRAME:
+ case RelOrientation::PAGE_FRAME:
+ rRect.Left() = aPage.Left();
+ rRect.Right() = aPage.Right();
+ break;
+
+ case RelOrientation::PRINT_AREA:
+ case RelOrientation::PAGE_PRINT_AREA:
+ rRect.Left() = aPagePrtArea.Left();
+ rRect.Right() = aPagePrtArea.Right();
+ break;
+
+ case RelOrientation::PAGE_LEFT:
+ rRect.Left() = aPage.Left();
+ rRect.Right() = aPagePrtArea.Left();
+ break;
+
+ case RelOrientation::PAGE_RIGHT:
+ rRect.Left() = aPagePrtArea.Right();
+ rRect.Right() = aPage.Right();
+ break;
+ }
+
+ switch (nVRel)
+ {
+ case RelOrientation::PRINT_AREA:
+ case RelOrientation::PAGE_PRINT_AREA:
+ rRect.Top() = aPagePrtArea.Top();
+ rRect.Bottom() = aPagePrtArea.Bottom();
+ break;
+
+ case RelOrientation::FRAME:
+ case RelOrientation::PAGE_FRAME:
+ rRect.Top() = aPage.Top();
+ rRect.Bottom() = aPage.Bottom();
+ break;
+ }
+ }
+ break;
+
+ case TextContentAnchorType_AT_FRAME:
+ {
+ switch (nHRel)
+ {
+ case RelOrientation::FRAME:
+ case RelOrientation::PAGE_FRAME:
+ rRect.Left() = aFrameAtFrame.Left();
+ rRect.Right() = aFrameAtFrame.Right();
+ break;
+
+ case RelOrientation::PRINT_AREA:
+ case RelOrientation::PAGE_PRINT_AREA:
+ rRect.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
+ rRect.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
+ break;
+
+ case RelOrientation::PAGE_RIGHT:
+ rRect.Left() = aFrameAtFrame.Left();
+ rRect.Right() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
+ break;
+
+ case RelOrientation::PAGE_LEFT:
+ rRect.Left() = aFrameAtFrame.Right();
+ rRect.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
+ break;
+ }
+
+ switch (nVRel)
+ {
+ case RelOrientation::FRAME:
+ case RelOrientation::PAGE_FRAME:
+ rRect.Top() = aFrameAtFrame.Top();
+ rRect.Bottom() = aFrameAtFrame.Bottom();
+ break;
+
+ case RelOrientation::PRINT_AREA:
+ case RelOrientation::PAGE_PRINT_AREA:
+ rRect.Top() = aFrameAtFrame.Top() + FLYINFLY_BORDER;
+ rRect.Bottom() = aFrameAtFrame.Bottom() - FLYINFLY_BORDER;
+ break;
+ }
+ }
+ break;
+ case TextContentAnchorType_AT_PARAGRAPH:
+ case TextContentAnchorType_AT_CHARACTER:
+ {
+ switch (nHRel)
+ {
+ case RelOrientation::FRAME:
+ rRect.Left() = aPara.Left();
+ rRect.Right() = aPara.Right();
+ break;
+
+ case RelOrientation::PRINT_AREA:
+ rRect.Left() = aParaPrtArea.Left();
+ rRect.Right() = aParaPrtArea.Right();
+ break;
+
+ case RelOrientation::PAGE_LEFT:
+ rRect.Left() = aPage.Left();
+ rRect.Right() = aPagePrtArea.Left();
+ break;
+
+ case RelOrientation::PAGE_RIGHT:
+ rRect.Left() = aPagePrtArea.Right();
+ rRect.Right() = aPage.Right();
+ break;
+
+ case RelOrientation::PAGE_FRAME:
+ rRect.Left() = aPage.Left();
+ rRect.Right() = aPage.Right();
+ break;
+
+ case RelOrientation::PAGE_PRINT_AREA:
+ rRect.Left() = aPagePrtArea.Left();
+ rRect.Right() = aPagePrtArea.Right();
+ break;
+
+ case RelOrientation::FRAME_LEFT:
+ rRect.Left() = aPara.Left();
+ rRect.Right() = aParaPrtArea.Left();
+ break;
+
+ case RelOrientation::FRAME_RIGHT:
+ rRect.Left() = aParaPrtArea.Right();
+ rRect.Right() = aPara.Right();
+ break;
+
+ case RelOrientation::CHAR:
+ rRect.Left() = aAutoCharFrame.Left();
+ rRect.Right() = aAutoCharFrame.Left();
+ break;
+ }
+
+ switch (nVRel)
+ {
+ case RelOrientation::FRAME:
+ rRect.Top() = aPara.Top();
+ rRect.Bottom() = aPara.Bottom();
+ break;
+
+ case RelOrientation::PRINT_AREA:
+ rRect.Top() = aParaPrtArea.Top();
+ rRect.Bottom() = aParaPrtArea.Bottom();
+ break;
+
+ case RelOrientation::CHAR:
+ if (nVAlign != VertOrientation::NONE &&
+ nVAlign != VertOrientation::CHAR_BOTTOM)
+ rRect.Top() = aAutoCharFrame.Top();
+ else
+ rRect.Top() = aAutoCharFrame.Bottom();
+ rRect.Bottom() = aAutoCharFrame.Bottom();
+ break;
+ // OD 12.11.2003 #i22341#
+ case RelOrientation::TEXT_LINE:
+ rRect.Top() = aAutoCharFrame.Top();
+ rRect.Bottom() = aAutoCharFrame.Top();
+ break;
+ }
+ }
+ break;
+
+ case TextContentAnchorType_AS_CHARACTER:
+ rRect.Left() = aParaPrtArea.Left();
+ rRect.Right() = aParaPrtArea.Right();
+
+ switch (nVAlign)
+ {
+ case VertOrientation::NONE:
+ case VertOrientation::TOP:
+ case VertOrientation::CENTER:
+ case VertOrientation::BOTTOM:
+ {
+ FontMetric aMetric(GetFontMetric());
+
+ rRect.Top() = aParaPrtArea.Bottom() - aMetric.GetDescent();
+ rRect.Bottom() = rRect.Top();
+ }
+ break;
+
+ default:
+
+ case VertOrientation::LINE_TOP:
+ case VertOrientation::LINE_CENTER:
+ case VertOrientation::LINE_BOTTOM:
+ rRect.Top() = aParaPrtArea.Top();
+ rRect.Bottom() = aDrawObj.Bottom();
+ break;
+
+ case VertOrientation::CHAR_TOP:
+ case VertOrientation::CHAR_CENTER:
+ case VertOrientation::CHAR_BOTTOM:
+ rRect.Top() = aParaPrtArea.Top();
+ rRect.Bottom() = aParaPrtArea.Bottom();
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+Rectangle SvxSwFrameExample::DrawInnerFrame_Impl(const Rectangle &rRect, const Color &rFillColor, const Color &rBorderColor)
+{
+ DrawRect_Impl(rRect, rFillColor, rBorderColor);
+
+ // Bereich, zu dem relativ positioniert wird, bestimmen
+ Rectangle aRect(rRect); // aPagePrtArea = Default
+ CalcBoundRect_Impl(aRect);
+
+ if (nAnchor == TextContentAnchorType_AT_FRAME && &rRect == &aPagePrtArea)
+ {
+ // Testabsatz zeichnen
+ Rectangle aTxt(aTextLine);
+ sal_Int32 nStep = aTxt.GetHeight() + 2;
+ USHORT nLines = (USHORT)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
+
+ for (USHORT i = 0; i < nLines; i++)
+ {
+ if (i == nLines - 1)
+ aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
+ DrawRect_Impl(aTxt, m_aTxtCol, m_aTransColor);
+ aTxt.Move(0, nStep);
+ }
+ }
+
+ return aRect;
+}
+
+void SvxSwFrameExample::Paint(const Rectangle&)
+{
+ InitAllRects_Impl();
+
+ // Schatten zeichnen
+// Rectangle aShadow(aPage);
+// aShadow += Point(3, 3);
+// DrawRect_Impl(aShadow, Color(COL_GRAY), aTransColor);
+
+ // Seite zeichnen
+ DrawRect_Impl( aPage, m_aBgCol, m_aBorderCol );
+
+ // PrintArea zeichnen
+ Rectangle aRect = DrawInnerFrame_Impl( aPagePrtArea, m_aTransColor, m_aPrintAreaCol );
+
+ if (nAnchor == TextContentAnchorType_AT_FRAME)
+ aRect = DrawInnerFrame_Impl( aFrameAtFrame, m_aBgCol, m_aBorderCol );
+
+ long lXPos = 0;
+ long lYPos = 0;
+
+ // Horizontale Ausrichtung
+ //
+ if (nAnchor != TextContentAnchorType_AS_CHARACTER)
+ {
+ switch (nHAlign)
+ {
+ case HoriOrientation::RIGHT:
+ {
+ lXPos = aRect.Right() - aFrmSize.Width() + 1;
+ break;
+ }
+ case HoriOrientation::CENTER:
+ {
+ lXPos = aRect.Left() + (aRect.GetWidth() - aFrmSize.Width()) / 2;
+ break;
+ }
+ case HoriOrientation::NONE:
+ {
+ lXPos = aRect.Left() + aRelPos.X();
+ break;
+ }
+
+ default: // HoriOrientation::LEFT
+ lXPos = aRect.Left();
+ break;
+ }
+ }
+ else
+ lXPos = aRect.Right() + 2;
+
+ // Vertikale Ausrichtung
+ //
+ if (nAnchor != TextContentAnchorType_AS_CHARACTER)
+ {
+ switch (nVAlign)
+ {
+ case VertOrientation::BOTTOM:
+ case VertOrientation::LINE_BOTTOM:
+ {
+ // OD 12.11.2003 #i22341#
+ if ( nVRel != RelOrientation::TEXT_LINE )
+ {
+ lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
+ }
+ else
+ {
+ lYPos = aRect.Top();
+ }
+ break;
+ }
+ case VertOrientation::CENTER:
+ case VertOrientation::LINE_CENTER:
+ {
+ lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
+ break;
+ }
+ case VertOrientation::NONE:
+ {
+ // OD 12.11.2003 #i22341#
+ if ( nVRel != RelOrientation::CHAR && nVRel != RelOrientation::TEXT_LINE )
+ lYPos = aRect.Top() + aRelPos.Y();
+ else
+ lYPos = aRect.Top() - aRelPos.Y();
+ break;
+ }
+ default:
+ // OD 12.11.2003 #i22341#
+ if ( nVRel != RelOrientation::TEXT_LINE )
+ {
+ lYPos = aRect.Top();
+ }
+ else
+ {
+ lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
+ }
+ break;
+ }
+ }
+ else
+ {
+ switch(nVAlign)
+ {
+ case VertOrientation::CENTER:
+ case VertOrientation::CHAR_CENTER:
+ case VertOrientation::LINE_CENTER:
+ lYPos = aRect.Top() + (aRect.GetHeight() - aFrmSize.Height()) / 2;
+ break;
+
+ case VertOrientation::TOP:
+ case VertOrientation::CHAR_BOTTOM:
+ case VertOrientation::LINE_BOTTOM:
+ lYPos = aRect.Bottom() - aFrmSize.Height() + 1;
+ break;
+
+/* case VertOrientation::NONE:
+ case VertOrientation::BOTTOM:
+ case VertOrientation::CHAR_TOP:
+ case VertOrientation::LINE_TOP:*/
+ default:
+ lYPos = aRect.Top() - aRelPos.Y();
+ break;
+ }
+ }
+
+ Rectangle aFrmRect(Point(lXPos, lYPos), aFrmSize);
+
+ Rectangle *pOuterFrame = &aPage;
+
+ if (nAnchor == TextContentAnchorType_AT_FRAME)
+ pOuterFrame = &aFrameAtFrame;
+
+ if (aFrmRect.Left() < pOuterFrame->Left())
+ aFrmRect.Move(pOuterFrame->Left() - aFrmRect.Left(), 0);
+ if (aFrmRect.Right() > pOuterFrame->Right())
+ aFrmRect.Move(pOuterFrame->Right() - aFrmRect.Right(), 0);
+
+ if (aFrmRect.Top() < pOuterFrame->Top())
+ aFrmRect.Move(0, pOuterFrame->Top() - aFrmRect.Top());
+ if (aFrmRect.Bottom() > pOuterFrame->Bottom())
+ aFrmRect.Move(0, pOuterFrame->Bottom() - aFrmRect.Bottom());
+
+ // Testabsatz zeichnen
+ const long nTxtLineHeight = aTextLine.GetHeight();
+ Rectangle aTxt(aTextLine);
+ sal_Int32 nStep;
+ USHORT nLines;
+
+ if (nAnchor == TextContentAnchorType_AT_FRAME)
+ {
+ aTxt.Left() = aFrameAtFrame.Left() + FLYINFLY_BORDER;
+ aTxt.Right() = aFrameAtFrame.Right() - FLYINFLY_BORDER;
+ aTxt.Top() = aFrameAtFrame.Top() + FLYINFLY_BORDER;
+ aTxt.Bottom() = aTxt.Top() + aTextLine.GetHeight() - 1;
+
+ nStep = aTxt.GetHeight() + 2;
+ nLines = (USHORT)(((aFrameAtFrame.GetHeight() - 2 * FLYINFLY_BORDER) * 2 / 3)
+ / (aTxt.GetHeight() + 2));
+ }
+ else
+ {
+ nStep = aTxt.GetHeight() + 2;
+ nLines = (USHORT)(aParaPrtArea.GetHeight() / (aTextLine.GetHeight() + 2));
+ }
+
+ if (nAnchor != TextContentAnchorType_AS_CHARACTER)
+ {
+ // Text simulieren
+ //
+ const long nOldR = aTxt.Right();
+ const long nOldL = aTxt.Left();
+
+ // OD 12.11.2003 #i22341#
+ const bool bIgnoreWrap = nAnchor == TextContentAnchorType_AT_CHARACTER &&
+ ( nHRel == RelOrientation::CHAR || nVRel == RelOrientation::CHAR ||
+ nVRel == RelOrientation::TEXT_LINE );
+
+ for (USHORT i = 0; i < nLines; ++i)
+ {
+ if (i == (nLines - 1))
+ aTxt.SetSize(Size(aTxt.GetWidth() / 2, aTxt.GetHeight()));
+
+ if (aTxt.IsOver(aFrmRect) && nAnchor != TextContentAnchorType_AS_CHARACTER && !bIgnoreWrap)
+ {
+ switch(nWrap)
+ {
+ case WrapTextMode_NONE:
+ aTxt.Top() = aFrmRect.Bottom() + nTxtLineHeight;
+ aTxt.Bottom() = aTxt.Top() + nTxtLineHeight - 1;
+ break;
+
+ case WrapTextMode_LEFT:
+ aTxt.Right() = aFrmRect.Left();
+ break;
+
+ case WrapTextMode_RIGHT:
+ aTxt.Left() = aFrmRect.Right();
+ break;
+ }
+ }
+ if (pOuterFrame->IsInside(aTxt))
+ DrawRect_Impl( aTxt, m_aTxtCol, m_aTransColor );
+
+ aTxt.Move(0, nStep);
+ aTxt.Right() = nOldR;
+ aTxt.Left() = nOldL;
+ }
+ aTxt.Move(0, -nStep);
+
+ if (nAnchor != TextContentAnchorType_AT_FRAME && aTxt.Bottom() > aParaPrtArea.Bottom())
+ {
+ // Text wurde durch Rahmen verdraengt, daher Para-Hoehe anpassen
+ ULONG nDiff = aTxt.Bottom() - aParaPrtArea.Bottom();
+ aParaPrtArea.Bottom() += nDiff;
+ aPara.Bottom() += nDiff;
+
+ CalcBoundRect_Impl(aRect);
+
+ aParaPrtArea.Bottom() -= nDiff;
+ aPara.Bottom() -= nDiff;
+ }
+ if (nAnchor == TextContentAnchorType_AT_CHARACTER && bIgnoreWrap)
+ DrawText(aAutoCharFrame, 'A');
+ }
+ else
+ {
+ DrawText(aParaPrtArea, C2S(DEMOTEXT));
+ DrawRect_Impl(aDrawObj, m_aBlankCol, m_aBlankFrameCol );
+ }
+
+ // Rechteck zeichnen, zu dem der Rahmen ausgerichtet wird:
+ DrawRect_Impl(aRect, m_aTransColor, m_aAlignColor);
+
+ // Frame anzeigen
+ BOOL bDontFill = (nAnchor == TextContentAnchorType_AT_CHARACTER && aFrmRect.IsOver(aAutoCharFrame)) ? TRUE : bTrans;
+ DrawRect_Impl( aFrmRect, bDontFill? m_aTransColor : m_aBgCol, m_aFrameColor );
+}
+
+void SvxSwFrameExample::SetRelPos(const Point& rP)
+{
+ aRelPos = rP;
+
+ if (aRelPos.X() > 0)
+ aRelPos.X() = 5;
+ if (aRelPos.X() < 0)
+ aRelPos.X() = -5;
+
+ if (aRelPos.Y() > 0)
+ aRelPos.Y() = 5;
+ if (aRelPos.Y() < 0)
+ aRelPos.Y() = -5;
+}
+
+void SvxSwFrameExample::DrawRect_Impl(const Rectangle &rRect, const Color &rFillColor, const Color &rLineColor)
+{
+ SetFillColor(rFillColor);
+ SetLineColor(rLineColor);
+ Window::DrawRect(rRect);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/swframeposstrings.cxx b/svx/source/dialog/swframeposstrings.cxx
new file mode 100644
index 000000000000..ac90ddc70a10
--- /dev/null
+++ b/svx/source/dialog/swframeposstrings.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <swframeposstrings.hxx>
+#include <tools/rc.hxx>
+#include <tools/debug.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+
+class SvxSwFramePosString_Impl : public Resource
+{
+ friend class SvxSwFramePosString;
+ String aStrings[SvxSwFramePosString::STR_MAX];
+public:
+ SvxSwFramePosString_Impl();
+};
+SvxSwFramePosString_Impl::SvxSwFramePosString_Impl() :
+ Resource(SVX_RES(RID_SVXSW_FRAMEPOSITIONS))
+{
+ for(USHORT i = 0; i < SvxSwFramePosString::STR_MAX; i++)
+ {
+ //string ids have to start at 1
+ aStrings[i] = String(SVX_RES(i + 1));
+ }
+ FreeResource();
+}
+/*-- 04.03.2004 13:14:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SvxSwFramePosString::SvxSwFramePosString() :
+ pImpl(new SvxSwFramePosString_Impl)
+{
+}
+/*-- 04.03.2004 13:14:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SvxSwFramePosString::~SvxSwFramePosString()
+{
+ delete pImpl;
+}
+/*-- 04.03.2004 13:14:48---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+const String& SvxSwFramePosString::GetString(StringId eId)
+{
+ DBG_ASSERT(eId >= 0 && eId < STR_MAX, "invalid StringId");
+ if(!(eId >= 0 && eId < STR_MAX))
+ eId = LEFT;
+ return pImpl->aStrings[eId];
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/swframeposstrings.src b/svx/source/dialog/swframeposstrings.src
new file mode 100644
index 000000000000..5455e736c4ba
--- /dev/null
+++ b/svx/source/dialog/swframeposstrings.src
@@ -0,0 +1,245 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <svx/dialogs.hrc>
+
+//the following defines have to match the (enum values + 1) in swframeposstrings.hxx!
+#define STR_LEFT 1
+#define STR_RIGHT 2
+#define STR_FROMLEFT 3
+#define STR_MIR_LEFT 4
+#define STR_MIR_RIGHT 5
+#define STR_MIR_FROMLEFT 6
+#define STR_FRAME 7
+#define STR_PRTAREA 8
+#define STR_REL_PG_LEFT 9
+#define STR_REL_PG_RIGHT 10
+#define STR_REL_FRM_LEFT 11
+#define STR_REL_FRM_RIGHT 12
+#define STR_MIR_REL_PG_LEFT 13
+#define STR_MIR_REL_PG_RIGHT 14
+#define STR_MIR_REL_FRM_LEFT 15
+#define STR_MIR_REL_FRM_RIGHT 16
+#define STR_REL_PG_FRAME 17
+#define STR_REL_PG_PRTAREA 18
+#define STR_REL_BASE 19
+#define STR_REL_CHAR 20
+#define STR_REL_ROW 21
+#define STR_REL_BORDER 22
+#define STR_REL_PRTAREA 23
+#define STR_FLY_REL_PG_LEFT 24
+#define STR_FLY_REL_PG_RIGHT 25
+#define STR_FLY_REL_PG_FRAME 26
+#define STR_FLY_REL_PG_PRTAREA 27
+#define STR_FLY_MIR_REL_PG_LEFT 28
+#define STR_FLY_MIR_REL_PG_RIGHT 29
+#define STR_TOP 30
+#define STR_BOTTOM 31
+#define STR_CENTER_HORI 32
+#define STR_CENTER_VERT 33
+#define STR_FROMTOP 34
+#define STR_FROMBOTTOM 35
+#define STR_BELOW 36
+#define STR_FROMRIGHT 37
+#define STR_REL_PG_TOP 38
+#define STR_REL_PG_BOTTOM 39
+#define STR_REL_FRM_TOP 40
+#define STR_REL_FRM_BOTTOM 41
+#define STR_REL_LINE 42
+
+Resource RID_SVXSW_FRAMEPOSITIONS
+{
+ String STR_LEFT
+ {
+ Text [ en-US ] = "Left" ;
+ };
+ String STR_MIR_LEFT
+ {
+ Text [ en-US ] = "Inside" ;
+ };
+ String STR_RIGHT
+ {
+ Text [ en-US ] = "Right" ;
+ };
+ String STR_MIR_RIGHT
+ {
+ Text [ en-US ] = "Outside" ;
+ };
+ String STR_CENTER_VERT
+ {
+ Text [ en-US ] = "Center" ;
+ };
+ String STR_FROMLEFT
+ {
+ Text [ en-US ] = "From left" ;
+ };
+ String STR_MIR_FROMLEFT
+ {
+ Text [ en-US ] = "From inside" ;
+ };
+ String STR_FRAME
+ {
+ Text [ en-US ] = "Paragraph area" ;
+ };
+ String STR_PRTAREA
+ {
+ Text [ en-US ] = "Paragraph text area" ;
+ };
+ String STR_REL_PG_LEFT
+ {
+ Text [ en-US ] = "Left page border" ;
+ };
+ String STR_MIR_REL_PG_LEFT
+ {
+ Text [ en-US ] = "Inner page border" ;
+ };
+ String STR_REL_PG_RIGHT
+ {
+ Text [ en-US ] = "Right page border" ;
+ };
+ String STR_MIR_REL_PG_RIGHT
+ {
+ Text [ en-US ] = "Outer page border" ;
+ };
+ String STR_REL_FRM_LEFT
+ {
+ Text [ en-US ] = "Left paragraph border" ;
+ };
+ String STR_MIR_REL_FRM_LEFT
+ {
+ Text [ en-US ] = "Inner paragraph border" ;
+ };
+ String STR_REL_FRM_RIGHT
+ {
+ Text [ en-US ] = "Right paragraph border" ;
+ };
+ String STR_MIR_REL_FRM_RIGHT
+ {
+ Text [ en-US ] = "Outer paragraph border" ;
+ };
+ String STR_REL_PG_FRAME
+ {
+ Text [ en-US ] = "Entire page" ;
+ };
+ String STR_REL_PG_PRTAREA
+ {
+ Text [ en-US ] = "Page text area" ;
+ };
+ String STR_TOP
+ {
+ Text [ en-US ] = "Top" ;
+ };
+ String STR_BOTTOM
+ {
+ Text [ en-US ] = "Bottom" ;
+ };
+ String STR_CENTER_HORI
+ {
+ Text [ en-US ] = "Center" ;
+ };
+ String STR_FROMTOP
+ {
+ Text [ en-US ] = "From top" ;
+ };
+ String STR_FROMBOTTOM
+ {
+ Text [ en-US ] = "From bottom" ;
+ };
+ String STR_BELOW
+ {
+ Text [ en-US ] = "Below" ;
+ };
+ String STR_FROMRIGHT
+ {
+ Text [ en-US ] = "From right" ;
+ };
+ String STR_REL_PG_TOP
+ {
+ Text [ en-US ] = "Top page border" ;
+ };
+ String STR_REL_PG_BOTTOM
+ {
+ Text [ en-US ] = "Bottom page border" ;
+ };
+ String STR_REL_FRM_TOP
+ {
+ Text [ en-US ] = "Top paragraph border" ;
+ };
+ String STR_REL_FRM_BOTTOM
+ {
+ Text [ en-US ] = "Bottom paragraph border" ;
+ };
+ String STR_REL_BORDER
+ {
+ Text [ en-US ] = "Margin" ;
+ };
+ String STR_REL_PRTAREA
+ {
+ Text [ en-US ] = "Paragraph text area" ;
+ };
+ String STR_FLY_REL_PG_LEFT
+ {
+ Text [ en-US ] = "Left frame border" ;
+ };
+ String STR_FLY_MIR_REL_PG_LEFT
+ {
+ Text [ en-US ] = "Inner frame border" ;
+ };
+ String STR_FLY_REL_PG_RIGHT
+ {
+ Text [ en-US ] = "Right frame border" ;
+ };
+ String STR_FLY_MIR_REL_PG_RIGHT
+ {
+ Text [ en-US ] = "Outer frame border" ;
+ };
+ String STR_FLY_REL_PG_FRAME
+ {
+ Text [ en-US ] = "Entire frame" ;
+ };
+ String STR_FLY_REL_PG_PRTAREA
+ {
+ Text [ en-US ] = "Frame text area" ;
+ };
+ String STR_REL_BASE
+ {
+ Text [ en-US ] = "Base line" ;
+ };
+ String STR_REL_CHAR
+ {
+ Text [ en-US ] = "Character" ;
+ };
+ String STR_REL_ROW
+ {
+ Text [ en-US ] = "Row" ;
+ };
+ // OD 05.01.2004 #i22341#
+ String STR_REL_LINE
+ {
+ Text [ en-US ] = "Line of text" ;
+ };
+};
+
diff --git a/svx/source/dialog/txencbox.cxx b/svx/source/dialog/txencbox.cxx
new file mode 100644
index 000000000000..581f5f8f08f7
--- /dev/null
+++ b/svx/source/dialog/txencbox.cxx
@@ -0,0 +1,256 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "txencbox.hxx"
+#include "txenctab.hxx"
+#include <svx/dialogs.hrc>
+#include "svx/dbcharsethelper.hxx"
+#include <vcl/svapp.hxx>
+#include <rtl/tencinfo.h>
+#include <rtl/locale.h>
+#include <osl/nlsupport.h>
+
+//========================================================================
+// class SvxTextEncodingBox
+//========================================================================
+
+SvxTextEncodingBox::SvxTextEncodingBox( Window* pParent, const ResId& rResId )
+ :
+ ListBox( pParent, rResId )
+{
+ m_pEncTable = new SvxTextEncodingTable;
+}
+
+//------------------------------------------------------------------------
+
+SvxTextEncodingBox::~SvxTextEncodingBox()
+{
+ delete m_pEncTable;
+}
+
+//------------------------------------------------------------------------
+
+USHORT SvxTextEncodingBox::EncodingToPos_Impl( rtl_TextEncoding nEnc ) const
+{
+ USHORT nCount = GetEntryCount();
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ if ( nEnc == rtl_TextEncoding( (ULONG)GetEntryData(i) ) )
+ return i;
+ }
+ return LISTBOX_ENTRY_NOTFOUND;
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEncodingBox::FillFromTextEncodingTable(
+ sal_Bool bExcludeImportSubsets, sal_uInt32 nExcludeInfoFlags,
+ sal_uInt32 nButIncludeInfoFlags )
+{
+ rtl_TextEncodingInfo aInfo;
+ aInfo.StructSize = sizeof(rtl_TextEncodingInfo);
+ sal_uInt32 nCount = m_pEncTable->Count();
+ for ( sal_uInt32 j=0; j<nCount; j++ )
+ {
+ BOOL bInsert = TRUE;
+ rtl_TextEncoding nEnc = rtl_TextEncoding( m_pEncTable->GetValue( j ) );
+ if ( nExcludeInfoFlags )
+ {
+ if ( !rtl_getTextEncodingInfo( nEnc, &aInfo ) )
+ bInsert = FALSE;
+ else
+ {
+ if ( (aInfo.Flags & nExcludeInfoFlags) == 0 )
+ {
+ if ( (nExcludeInfoFlags & RTL_TEXTENCODING_INFO_UNICODE) &&
+ ((nEnc == RTL_TEXTENCODING_UCS2) ||
+ nEnc == RTL_TEXTENCODING_UCS4) )
+ bInsert = FALSE; // InfoFlags don't work for Unicode :-(
+ }
+ else if ( (aInfo.Flags & nButIncludeInfoFlags) == 0 )
+ bInsert = FALSE;
+ }
+ }
+ if ( bInsert )
+ {
+ if ( bExcludeImportSubsets )
+ {
+ switch ( nEnc )
+ {
+ // subsets of RTL_TEXTENCODING_GB_18030
+ case RTL_TEXTENCODING_GB_2312 :
+ case RTL_TEXTENCODING_GBK :
+ case RTL_TEXTENCODING_MS_936 :
+ bInsert = FALSE;
+ break;
+ }
+ }
+ if ( bInsert )
+ InsertTextEncoding( nEnc, m_pEncTable->GetString( j ) );
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEncodingBox::FillFromDbTextEncodingMap(
+ sal_Bool bExcludeImportSubsets, sal_uInt32 nExcludeInfoFlags,
+ sal_uInt32 nButIncludeInfoFlags )
+{
+ rtl_TextEncodingInfo aInfo;
+ aInfo.StructSize = sizeof(rtl_TextEncodingInfo);
+ svxform::ODataAccessCharsetHelper aCSH;
+ ::std::vector< rtl_TextEncoding > aEncs;
+ sal_Int32 nCount = aCSH.getSupportedTextEncodings( aEncs );
+ for ( USHORT j=0; j<nCount; j++ )
+ {
+ BOOL bInsert = TRUE;
+ rtl_TextEncoding nEnc = rtl_TextEncoding( aEncs[j] );
+ if ( nExcludeInfoFlags )
+ {
+ if ( !rtl_getTextEncodingInfo( nEnc, &aInfo ) )
+ bInsert = FALSE;
+ else
+ {
+ if ( (aInfo.Flags & nExcludeInfoFlags) == 0 )
+ {
+ if ( (nExcludeInfoFlags & RTL_TEXTENCODING_INFO_UNICODE) &&
+ ((nEnc == RTL_TEXTENCODING_UCS2) ||
+ nEnc == RTL_TEXTENCODING_UCS4) )
+ bInsert = FALSE; // InfoFlags don't work for Unicode :-(
+ }
+ else if ( (aInfo.Flags & nButIncludeInfoFlags) == 0 )
+ bInsert = FALSE;
+ }
+ }
+ if ( bInsert )
+ {
+ if ( bExcludeImportSubsets )
+ {
+ switch ( nEnc )
+ {
+ // subsets of RTL_TEXTENCODING_GB_18030
+ case RTL_TEXTENCODING_GB_2312 :
+ case RTL_TEXTENCODING_GBK :
+ case RTL_TEXTENCODING_MS_936 :
+ bInsert = FALSE;
+ break;
+ }
+ }
+ // CharsetMap offers a RTL_TEXTENCODING_DONTKNOW for internal use,
+ // makes no sense here and would result in an empty string as list
+ // entry.
+ if ( bInsert && nEnc != RTL_TEXTENCODING_DONTKNOW )
+ InsertTextEncoding( nEnc );
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEncodingBox::FillWithMimeAndSelectBest()
+{
+ FillFromTextEncodingTable( sal_False, 0xffffffff, RTL_TEXTENCODING_INFO_MIME );
+ rtl_TextEncoding nEnc = SvtSysLocale::GetBestMimeEncoding();
+ SelectTextEncoding( nEnc );
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEncodingBox::InsertTextEncoding( const rtl_TextEncoding nEnc,
+ const String& rEntry, USHORT nPos )
+{
+ USHORT nAt = InsertEntry( rEntry, nPos );
+ SetEntryData( nAt, (void*)(ULONG)nEnc );
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEncodingBox::InsertTextEncoding( const rtl_TextEncoding nEnc, USHORT nPos )
+{
+ const String& rEntry = m_pEncTable->GetTextString( nEnc );
+ if ( rEntry.Len() )
+ InsertTextEncoding( nEnc, rEntry, nPos );
+ else
+ {
+#ifdef DBG_UTIL
+ ByteString aMsg( "SvxTextEncodingBox::InsertTextEncoding: no resource string for text encoding: " );
+ aMsg += ByteString::CreateFromInt32( nEnc );
+ DBG_ERRORFILE( aMsg.GetBuffer() );
+#endif
+ }
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEncodingBox::RemoveTextEncoding( const rtl_TextEncoding nEnc )
+{
+ USHORT nAt = EncodingToPos_Impl( nEnc );
+
+ if ( nAt != LISTBOX_ENTRY_NOTFOUND )
+ RemoveEntry( nAt );
+}
+
+//------------------------------------------------------------------------
+
+rtl_TextEncoding SvxTextEncodingBox::GetSelectTextEncoding() const
+{
+ USHORT nPos = GetSelectEntryPos();
+
+ if ( nPos != LISTBOX_ENTRY_NOTFOUND )
+ return rtl_TextEncoding( (ULONG)GetEntryData(nPos) );
+ else
+ return RTL_TEXTENCODING_DONTKNOW;
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEncodingBox::SelectTextEncoding( const rtl_TextEncoding nEnc, BOOL bSelect )
+{
+ USHORT nAt = EncodingToPos_Impl( nEnc );
+
+ if ( nAt != LISTBOX_ENTRY_NOTFOUND )
+ SelectEntryPos( nAt, bSelect );
+}
+
+//------------------------------------------------------------------------
+
+BOOL SvxTextEncodingBox::IsTextEncodingSelected( const rtl_TextEncoding nEnc ) const
+{
+ USHORT nAt = EncodingToPos_Impl( nEnc );
+
+ if ( nAt != LISTBOX_ENTRY_NOTFOUND )
+ return IsEntryPosSelected( nAt );
+ else
+ return FALSE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/txenctab.cxx b/svx/source/dialog/txenctab.cxx
new file mode 100644
index 000000000000..b06f31ec4ac5
--- /dev/null
+++ b/svx/source/dialog/txenctab.cxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/dialogs.hrc> // -> RID_SVXSTR_TEXTENCODING_TABLE
+#include <svx/dialmgr.hxx>
+#include "txenctab.hxx"
+#include <tools/shl.hxx>
+
+//------------------------------------------------------------------------
+
+SvxTextEncodingTable::SvxTextEncodingTable()
+ :
+ ResStringArray( SVX_RES( RID_SVXSTR_TEXTENCODING_TABLE ) )
+{
+}
+
+//------------------------------------------------------------------------
+
+SvxTextEncodingTable::~SvxTextEncodingTable()
+{
+}
+
+//------------------------------------------------------------------------
+
+const String& SvxTextEncodingTable::GetTextString( const rtl_TextEncoding nEnc ) const
+{
+ sal_uInt32 nPos = FindIndex( (long)nEnc );
+
+ if ( RESARRAY_INDEX_NOTFOUND != nPos && nPos < Count() )
+ return ResStringArray::GetString( nPos );
+
+ static String aEmptyString;
+ return aEmptyString;
+}
+
+//------------------------------------------------------------------------
+
+rtl_TextEncoding SvxTextEncodingTable::GetTextEncoding( const String& rStr ) const
+{
+ sal_uInt32 nCount = Count();
+
+ for ( sal_uInt32 i = 0; i < nCount; ++i )
+ {
+ if ( rStr == ResStringArray::GetString( i ) )
+ return rtl_TextEncoding( GetValue( i ) );
+ }
+ return RTL_TEXTENCODING_DONTKNOW;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/dialog/txenctab.src b/svx/source/dialog/txenctab.src
new file mode 100644
index 000000000000..7cc40bbcd22f
--- /dev/null
+++ b/svx/source/dialog/txenctab.src
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+ // include ---------------------------------------------------------------
+
+#include <svx/dialogs.hrc>
+
+#define _SOLAR_RSC_INVOKED
+#include <rtl/textenc.h>
+#define PairedList ItemList
+// Encodings for which no conversion exist yet are commented out.
+
+ // RID_SVXSTR_TEXTENCODING_TABLE ----------------------------------------------------
+StringArray RID_SVXSTR_TEXTENCODING_TABLE
+{
+ PairedList [ en-US ] =
+ {
+ < "Western Europe (Windows-1252/WinLatin 1)" ; RTL_TEXTENCODING_MS_1252 ; > ;
+ < "Western Europe (Apple Macintosh)" ; RTL_TEXTENCODING_APPLE_ROMAN ; > ;
+ < "Western Europe (DOS/OS2-850/International)" ; RTL_TEXTENCODING_IBM_850 ; > ;
+ < "Western Europe (DOS/OS2-437/US)" ; RTL_TEXTENCODING_IBM_437 ; > ;
+ < "Western Europe (DOS/OS2-860/Portuguese)" ; RTL_TEXTENCODING_IBM_860 ; > ;
+ < "Western Europe (DOS/OS2-861/Icelandic)" ; RTL_TEXTENCODING_IBM_861 ; > ;
+ < "Western Europe (DOS/OS2-863/French (Can.))" ; RTL_TEXTENCODING_IBM_863 ; > ;
+ < "Western Europe (DOS/OS2-865/Nordic)" ; RTL_TEXTENCODING_IBM_865 ; > ;
+ < "Western Europe (ASCII/US)" ; RTL_TEXTENCODING_ASCII_US ; > ;
+ < "Western Europe (ISO-8859-1)" ; RTL_TEXTENCODING_ISO_8859_1 ; > ;
+ < "Eastern Europe (ISO-8859-2)" ; RTL_TEXTENCODING_ISO_8859_2 ; > ;
+ < "Latin 3 (ISO-8859-3)" ; RTL_TEXTENCODING_ISO_8859_3 ; > ;
+ < "Baltic (ISO-8859-4)" ; RTL_TEXTENCODING_ISO_8859_4 ; > ;
+ < "Cyrillic (ISO-8859-5)" ; RTL_TEXTENCODING_ISO_8859_5 ; > ;
+ < "Arabic (ISO-8859-6)" ; RTL_TEXTENCODING_ISO_8859_6 ; > ;
+ < "Greek (ISO-8859-7)" ; RTL_TEXTENCODING_ISO_8859_7 ; > ;
+ < "Hebrew (ISO-8859-8)" ; RTL_TEXTENCODING_ISO_8859_8 ; > ;
+ < "Turkish (ISO-8859-9)" ; RTL_TEXTENCODING_ISO_8859_9 ; > ;
+ < "Western Europe (ISO-8859-14)" ; RTL_TEXTENCODING_ISO_8859_14 ; > ;
+ < "Western Europe (ISO-8859-15/EURO)" ; RTL_TEXTENCODING_ISO_8859_15 ; > ;
+ < "Greek (DOS/OS2-737)" ; RTL_TEXTENCODING_IBM_737 ; > ;
+ < "Baltic (DOS/OS2-775)" ; RTL_TEXTENCODING_IBM_775 ; > ;
+ < "Eastern Europe (DOS/OS2-852)" ; RTL_TEXTENCODING_IBM_852 ; > ;
+ < "Cyrillic (DOS/OS2-855)" ; RTL_TEXTENCODING_IBM_855 ; > ;
+ < "Turkish (DOS/OS2-857)" ; RTL_TEXTENCODING_IBM_857 ; > ;
+ < "Hebrew (DOS/OS2-862)" ; RTL_TEXTENCODING_IBM_862 ; > ;
+ < "Arabic (DOS/OS2-864)" ; RTL_TEXTENCODING_IBM_864 ; > ;
+ < "Cyrillic (DOS/OS2-866/Russian)" ; RTL_TEXTENCODING_IBM_866 ; > ;
+ < "Greek (DOS/OS2-869/Modern)" ; RTL_TEXTENCODING_IBM_869 ; > ;
+ < "Eastern Europe (Windows-1250/WinLatin 2)" ; RTL_TEXTENCODING_MS_1250 ; > ;
+ < "Cyrillic (Windows-1251)" ; RTL_TEXTENCODING_MS_1251 ; > ;
+ < "Greek (Windows-1253)" ; RTL_TEXTENCODING_MS_1253 ; > ;
+ < "Turkish (Windows-1254)" ; RTL_TEXTENCODING_MS_1254 ; > ;
+ < "Hebrew (Windows-1255)" ; RTL_TEXTENCODING_MS_1255 ; > ;
+ < "Arabic (Windows-1256)" ; RTL_TEXTENCODING_MS_1256 ; > ;
+ < "Baltic (Windows-1257)" ; RTL_TEXTENCODING_MS_1257 ; > ;
+ < "Eastern Europe (Apple Macintosh)" ; RTL_TEXTENCODING_APPLE_CENTEURO ; > ;
+ < "Eastern Europe (Apple Macintosh/Croatian)" ; RTL_TEXTENCODING_APPLE_CROATIAN ; > ;
+ < "Cyrillic (Apple Macintosh)" ; RTL_TEXTENCODING_APPLE_CYRILLIC ; > ;
+ < "Greek (Apple Macintosh)" ; RTL_TEXTENCODING_APPLE_GREEK ; > ;
+ < "Western Europe (Apple Macintosh/Icelandic)" ; RTL_TEXTENCODING_APPLE_ICELAND ; > ;
+ < "Eastern Europe (Apple Macintosh/Rumanian)" ; RTL_TEXTENCODING_APPLE_ROMANIAN ; > ;
+ < "Turkish (Apple Macintosh)" ; RTL_TEXTENCODING_APPLE_TURKISH ; > ;
+ < "Cyrillic (Apple Macintosh/Ukrainian)" ; RTL_TEXTENCODING_APPLE_UKRAINIAN ; > ;
+ < "Chinese simplified (Apple Macintosh)" ; RTL_TEXTENCODING_APPLE_CHINSIMP ; > ;
+ < "Chinese traditional (Apple Macintosh)" ; RTL_TEXTENCODING_APPLE_CHINTRAD ; > ;
+ < "Japanese (Apple Macintosh)" ; RTL_TEXTENCODING_APPLE_JAPANESE ; > ;
+ < "Korean (Apple Macintosh)" ; RTL_TEXTENCODING_APPLE_KOREAN ; > ;
+ < "Japanese (Windows-932)" ; RTL_TEXTENCODING_MS_932 ; > ;
+ < "Chinese simplified (Windows-936)" ; RTL_TEXTENCODING_MS_936 ; > ;
+ < "Korean (Windows-949)" ; RTL_TEXTENCODING_MS_949 ; > ;
+ < "Chinese traditional (Windows-950)" ; RTL_TEXTENCODING_MS_950 ; > ;
+ < "Japanese (Shift-JIS)" ; RTL_TEXTENCODING_SHIFT_JIS ; > ;
+ < "Chinese simplified (GB-2312)" ; RTL_TEXTENCODING_GB_2312 ; > ;
+ < "Chinese simplified (GB-18030)" ; RTL_TEXTENCODING_GB_18030 ; > ;
+ < "Chinese traditional (GBT-12345)" ; RTL_TEXTENCODING_GBT_12345 ; > ;
+ < "Chinese simplified (GBK/GB-2312-80)" ; RTL_TEXTENCODING_GBK ; > ;
+ < "Chinese traditional (Big5)" ; RTL_TEXTENCODING_BIG5 ; > ;
+ < "Chinese traditional (BIG5-HKSCS)" ; RTL_TEXTENCODING_BIG5_HKSCS ; > ;
+ < "Japanese (EUC-JP)" ; RTL_TEXTENCODING_EUC_JP ; > ;
+ < "Chinese simplified (EUC-CN)" ; RTL_TEXTENCODING_EUC_CN ; > ;
+ < "Chinese traditional (EUC-TW)" ; RTL_TEXTENCODING_EUC_TW ; > ;
+ < "Japanese (ISO-2022-JP)" ; RTL_TEXTENCODING_ISO_2022_JP ; > ;
+ < "Chinese simplified (ISO-2022-CN)" ; RTL_TEXTENCODING_ISO_2022_CN ; > ;
+ < "Cyrillic (KOI8-R)" ; RTL_TEXTENCODING_KOI8_R ; > ;
+ < "Unicode (UTF-7)" ; RTL_TEXTENCODING_UTF7 ; > ;
+ < "Unicode (UTF-8)" ; RTL_TEXTENCODING_UTF8 ; > ;
+ < "Eastern Europe (ISO-8859-10)" ; RTL_TEXTENCODING_ISO_8859_10 ; > ;
+ < "Eastern Europe (ISO-8859-13)" ; RTL_TEXTENCODING_ISO_8859_13 ; > ;
+ < "Korean (EUC-KR)" ; RTL_TEXTENCODING_EUC_KR ; > ;
+ < "Korean (ISO-2022-KR)" ; RTL_TEXTENCODING_ISO_2022_KR ; > ;
+ < "Korean (Windows-Johab-1361)" ; RTL_TEXTENCODING_MS_1361 ; > ;
+ < "Unicode" ; RTL_TEXTENCODING_UCS2 ; > ;
+ < "Thai (ISO-8859-11/TIS-620)" ; RTL_TEXTENCODING_TIS_620 ; > ;
+ < "Thai (Windows-874)" ; RTL_TEXTENCODING_MS_874 ; > ;
+ < "Cyrillic (KOI8-U)" ; RTL_TEXTENCODING_KOI8_U ; > ;
+ < "Cyrillic (PT154)" ; RTL_TEXTENCODING_PT154 ; > ;
+ };
+};
+ // ********************************************************************** EOF
+
diff --git a/svx/source/dialog/ucsubset.src b/svx/source/dialog/ucsubset.src
new file mode 100755
index 000000000000..160b0defe565
--- /dev/null
+++ b/svx/source/dialog/ucsubset.src
@@ -0,0 +1,511 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+ // include ---------------------------------------------------------------
+#include <svx/ucsubset.hrc>
+
+/*
+ * strings for unicode range descriptions (used e.g. by charmap)
+ * (see the Unicode Standard & TrueType::OS2.ulUnicodeRange description)
+ */
+
+Resource RID_SUBSETMAP
+{
+String RID_SUBSETSTR_BASIC_LATIN
+{
+ Text [ en-US ] = "Basic Latin";
+ };
+String RID_SUBSETSTR_LATIN_1
+{
+ Text [ en-US ] = "Latin-1";
+ };
+String RID_SUBSETSTR_LATIN_EXTENDED_A
+{
+ Text [ en-US ] = "Latin Extended-A";
+ };
+String RID_SUBSETSTR_LATIN_EXTENDED_B
+{
+ Text [ en-US ] = "Latin Extended-B";
+ };
+String RID_SUBSETSTR_IPA_EXTENSIONS
+{
+ Text [ en-US ] = "IPA Extensions";
+ };
+String RID_SUBSETSTR_SPACING_MODIFIERS
+{
+ Text [ en-US ] = "Spacing Modifier Letters";
+ };
+String RID_SUBSETSTR_COMB_DIACRITICAL
+{
+ Text [ en-US ] = "Combining Diacritical Marks";
+ };
+String RID_SUBSETSTR_BASIC_GREEK
+{
+ Text [ en-US ] = "Basic Greek";
+ };
+String RID_SUBSETSTR_GREEK_SYMS_COPTIC
+{
+ Text [ en-US ] = "Greek Symbols And Coptic";
+ };
+String RID_SUBSETSTR_CYRILLIC
+{
+ Text [ en-US ] = "Cyrillic";
+ };
+String RID_SUBSETSTR_CYRILLIC_SUPPL
+{
+ Text [ en-US ] = "Cyrillic Supplementary";
+ };
+String RID_SUBSETSTR_ARMENIAN
+{
+ Text [ en-US ] = "Armenian";
+ };
+String RID_SUBSETSTR_BASIC_HEBREW
+{
+ Text [ en-US ] = "Basic Hebrew";
+ };
+String RID_SUBSETSTR_HEBREW_EXTENDED
+{
+ Text [ en-US ] = "Hebrew Extended";
+ };
+String RID_SUBSETSTR_BASIC_ARABIC
+{
+ Text [ en-US ] = "Basic Arabic";
+ };
+String RID_SUBSETSTR_ARABIC_EXTENDED
+{
+ Text [ en-US ] = "Arabic Extended";
+
+ };
+String RID_SUBSETSTR_DEVANAGARI
+{
+ Text [ en-US ] = "Devanagari";
+ };
+String RID_SUBSETSTR_BENGALI
+{
+ Text [ en-US ] = "Bengali";
+ };
+String RID_SUBSETSTR_GURMUKHI
+{
+ Text [ en-US ] = "Gurmukhi";
+ };
+String RID_SUBSETSTR_GUJARATI
+{
+ Text [ en-US ] = "Gujarati";
+ };
+String RID_SUBSETSTR_ORIYA
+{
+ Text [ en-US ] = "Oriya";
+ };
+String RID_SUBSETSTR_TAMIL
+{
+ Text [ en-US ] = "Tamil";
+ };
+String RID_SUBSETSTR_TELUGU
+{
+ Text [ en-US ] = "Telugu";
+
+ };
+String RID_SUBSETSTR_KANNADA
+{
+ Text [ en-US ] = "Kannada";
+ };
+String RID_SUBSETSTR_MALAYALAM
+{
+ Text [ en-US ] = "Malayalam";
+ };
+String RID_SUBSETSTR_THAI
+{
+ Text [ en-US ] = "Thai";
+ };
+String RID_SUBSETSTR_LAO
+{
+ Text [ en-US ] = "Lao";
+ };
+String RID_SUBSETSTR_BASIC_GEORGIAN
+{
+ Text [ en-US ] = "Basic Georgian";
+ };
+String RID_SUBSETSTR_GEORGIAN_EXTENDED
+{
+ Text [ en-US ] = "Georgian Extended";
+ };
+String RID_SUBSETSTR_HANGUL_JAMO
+{
+ Text [ en-US ] = "Hangul Jamo";
+ };
+String RID_SUBSETSTR_LATIN_EXTENDED_ADDS
+{
+ Text [ en-US ] = "Latin Extended Additionals";
+ };
+String RID_SUBSETSTR_GREEK_EXTENDED
+{
+ Text [ en-US ] = "Greek Extended";
+ };
+String RID_SUBSETSTR_GENERAL_PUNCTUATION
+{
+ Text [ en-US ] = "General punctuation";
+ };
+String RID_SUBSETSTR_SUB_SUPER_SCRIPTS
+{
+ Text [ en-US ] = "Superscripts and Subscripts";
+ };
+String RID_SUBSETSTR_CURRENCY_SYMBOLS
+{
+ Text [ en-US ] = "Currency Symbols";
+ };
+String RID_SUBSETSTR_COMB_DIACRITIC_SYMS
+{
+ Text [ en-US ] = "Combining Diacritical Symbols";
+ };
+String RID_SUBSETSTR_LETTERLIKE_SYMBOLS
+{
+ Text [ en-US ] = "Letterlike Symbols";
+ };
+String RID_SUBSETSTR_NUMBER_FORMS
+{
+ Text [ en-US ] = "Number Forms";
+ };
+String RID_SUBSETSTR_ARROWS
+{
+ Text [ en-US ] = "Arrows";
+ };
+String RID_SUBSETSTR_MATH_OPERATORS
+{
+ Text [ en-US ] = "Mathematical Operators";
+ };
+String RID_SUBSETSTR_MISC_TECHNICAL
+{
+ Text [ en-US ] = "Miscellaneous Technical";
+
+ };
+String RID_SUBSETSTR_CONTROL_PICTURES
+{
+ Text [ en-US ] = "Control Pictures";
+ };
+String RID_SUBSETSTR_OPTICAL_CHAR_REC
+{
+ Text [ en-US ] = "Optical Character Recognition";
+ };
+String RID_SUBSETSTR_ENCLOSED_ALPHANUM
+{
+ Text [ en-US ] = "Enclosed Alphanumerics";
+ };
+String RID_SUBSETSTR_BOX_DRAWING
+{
+ Text [ en-US ] = "Box Drawing";
+ };
+String RID_SUBSETSTR_BLOCK_ELEMENTS
+{
+ Text [ en-US ] = "Block Elements";
+ };
+String RID_SUBSETSTR_GEOMETRIC_SHAPES
+{
+ Text [ en-US ] = "Geometric Shapes";
+ };
+String RID_SUBSETSTR_MISC_DINGBATS
+{
+ Text [ en-US ] = "Miscellaneous Symbols";
+
+ };
+String RID_SUBSETSTR_DINGBATS
+{
+ Text [ en-US ] = "Dingbats";
+
+ };
+String RID_SUBSETSTR_CJK_SYMS_PUNCTUATION
+{
+ Text [ en-US ] = "CJK Symbols And Punctuation";
+ };
+String RID_SUBSETSTR_HIRAGANA
+{
+ Text [ en-US ] = "Hiragana";
+ };
+String RID_SUBSETSTR_KATAKANA
+{
+ Text [ en-US ] = "Katakana";
+ };
+String RID_SUBSETSTR_BOPOMOFO
+{
+ Text [ en-US ] = "Bopomofo";
+ };
+String RID_SUBSETSTR_HANGUL_COMPAT_JAMO
+{
+ Text [ en-US ] = "Hangul Compatibility Jamo";
+ };
+String RID_SUBSETSTR_CJK_MISC
+{
+ Text [ en-US ] = "CJK Miscellaneous";
+ };
+String RID_SUBSETSTR_ENCLOSED_CJK_LETTERS
+{
+ Text [ en-US ] = "Enclosed CJK Letters And Months";
+ };
+String RID_SUBSETSTR_CJK_COMPATIBILITY
+{
+ Text [ en-US ] = "CJK Compatibility";
+
+ };
+String RID_SUBSETSTR_HANGUL
+{
+ Text [ en-US ] = "Hangul";
+ };
+String RID_SUBSETSTR_CJK_UNIFIED_IDGRAPH
+{
+ Text [ en-US ] = "CJK Unified Ideographs";
+ };
+String RID_SUBSETSTR_CJK_EXT_A_UNIFIED_IDGRAPH
+{
+ Text [ en-US ] = "CJK Unified Ideographs Extension-A";
+ };
+String RID_SUBSETSTR_PRIVATE_USE_AREA
+{
+ Text [ en-US ] = "Private Use Area";
+ };
+String RID_SUBSETSTR_CJK_COMPAT_IDGRAPHS
+{
+ Text [ en-US ] = "CJK Compatibility Ideographs";
+ };
+String RID_SUBSETSTR_ALPHA_PRESENTATION
+{
+ Text [ en-US ] = "Alphabetic Presentation Forms";
+ };
+String RID_SUBSETSTR_ARABIC_PRESENT_A
+{
+ Text [ en-US ] = "Arabic Presentation Forms-A";
+
+ };
+String RID_SUBSETSTR_COMBINING_HALF_MARKS
+{
+ Text [ en-US ] = "Combining Half Marks";
+ };
+String RID_SUBSETSTR_CJK_COMPAT_FORMS
+{
+ Text [ en-US ] = "CJK Compatibility Forms";
+ };
+String RID_SUBSETSTR_SMALL_FORM_VARIANTS
+{
+ Text [ en-US ] = "Small Form Variants";
+
+ };
+String RID_SUBSETSTR_ARABIC_PRESENT_B
+{
+ Text [ en-US ] = "Arabic Presentation Forms-B";
+ };
+String RID_SUBSETSTR_HALFW_FULLW_FORMS
+{
+ Text [ en-US ] = "Half-width and Full-width Forms";
+ };
+String RID_SUBSETSTR_SPECIALS
+{
+ Text [ en-US ] = "Specials";
+ };
+String RID_SUBSETSTR_HANGUL_GA
+{
+ Text [ en-US ] = "Hangul Ga";
+ };
+String RID_SUBSETSTR_HANGUL_NA
+{
+ Text [ en-US ] = "Hangul Na";
+ };
+String RID_SUBSETSTR_HANGUL_DA
+{
+ Text [ en-US ] = "Hangul Da";
+ };
+String RID_SUBSETSTR_HANGUL_RA
+{
+ Text [ en-US ] = "Hangul Ra";
+ };
+String RID_SUBSETSTR_HANGUL_MA
+{
+ Text [ en-US ] = "Hangul Ma";
+ };
+String RID_SUBSETSTR_HANGUL_BA
+{
+ Text [ en-US ] = "Hangul Ba";
+ };
+String RID_SUBSETSTR_HANGUL_SA
+{
+ Text [ en-US ] = "Hangul Sa";
+ };
+String RID_SUBSETSTR_HANGUL_AH
+{
+ Text [ en-US ] = "Hangul Ah";
+ };
+String RID_SUBSETSTR_HANGUL_JA
+{
+ Text [ en-US ] = "Hangul Ja";
+ };
+String RID_SUBSETSTR_HANGUL_CHA
+{
+ Text [ en-US ] = "Hangul Cha";
+ };
+String RID_SUBSETSTR_HANGUL_KA
+{
+ Text [ en-US ] = "Hangul Ka";
+ };
+String RID_SUBSETSTR_HANGUL_TA
+{
+ Text [ en-US ] = "Hangul Ta";
+ };
+String RID_SUBSETSTR_HANGUL_PA
+{
+ Text [ en-US ] = "Hangul Pa";
+ };
+String RID_SUBSETSTR_HANGUL_HA
+{
+ Text [ en-US ] = "Hangul Ha";
+ };
+String RID_SUBSETSTR_YI
+{
+ Text [ en-US ] = "Yi";
+ };
+String RID_SUBSETSTR_SINHALA
+{
+ Text [ en-US ] = "Sinhala";
+ };
+String RID_SUBSETSTR_TIBETAN
+{
+ Text [ en-US ] = "Tibetan";
+ };
+String RID_SUBSETSTR_MYANMAR
+{
+ Text [ en-US ] = "Myanmar";
+ };
+String RID_SUBSETSTR_KHMER
+{
+ Text [ en-US ] = "Khmer";
+ };
+String RID_SUBSETSTR_OGHAM
+{
+ Text [ en-US ] = "Ogham";
+ };
+String RID_SUBSETSTR_RUNIC
+{
+ Text [ en-US ] = "Runic";
+ };
+String RID_SUBSETSTR_SYRIAC
+{
+ Text [ en-US ] = "Syriac";
+ };
+String RID_SUBSETSTR_THAANA
+{
+ Text [ en-US ] = "Thaana";
+ };
+String RID_SUBSETSTR_ETHIOPIC
+{
+ Text [ en-US ] = "Ethiopic";
+ };
+String RID_SUBSETSTR_CHEROKEE
+{
+ Text [ en-US ] = "Cherokee";
+ };
+String RID_SUBSETSTR_CANADIAN_ABORIGINAL
+{
+ Text [ en-US ] = "Canadan Aboriginal Syllables";
+ };
+String RID_SUBSETSTR_MONGOLIAN
+{
+ Text [ en-US ] = "Mongolian";
+ };
+
+String RID_SUBSETSTR_MISC_MATH_SYMS_A
+{
+ Text [ en-US ] = "Miscellaneous Mathematical Symbols-A";
+ };
+
+String RID_SUBSETSTR_SUPPL_ARROWS_A
+{
+ Text [ en-US ] = "Supplemental Arrows-A";
+ };
+
+String RID_SUBSETSTR_BRAILLE_PATTERNS
+{
+ Text [ en-US ] = "Braille Patterns";
+ };
+
+String RID_SUBSETSTR_SUPPL_ARROWS_B
+{
+ Text [ en-US ] = "Supplemental Arrows-B";
+ };
+
+String RID_SUBSETSTR_MISC_MATH_SYMS_B
+{
+ Text [ en-US ] = "Miscellaneous Mathematical Symbols-B";
+ };
+
+String RID_SUBSETSTR_CJK_RADICAL_SUPPL
+{
+ Text [ en-US ] = "CJK Radical Supplement";
+ };
+
+String RID_SUBSETSTR_KANXI_RADICALS
+{
+ Text [ en-US ] = "Kanxi Radicals";
+ };
+
+String RID_SUBSETSTR_IDEO_DESC_CHARS
+{
+ Text [ en-US ] = "Ideographic Description Characters";
+ };
+
+String RID_SUBSETSTR_TAGALOG
+{
+ Text [ en-US ] = "Tagalog";
+ };
+
+String RID_SUBSETSTR_HANUNOO
+{
+ Text [ en-US ] = "Hanunoo";
+ };
+
+String RID_SUBSETSTR_TAGBANWA
+{
+ Text [ en-US ] = "Tagbanwa";
+ };
+
+String RID_SUBSETSTR_BUHID
+{
+ Text [ en-US ] = "Buhid";
+ };
+
+String RID_SUBSETSTR_KANBUN
+{
+ Text [ en-US ] = "Kanbun";
+ };
+
+String RID_SUBSETSTR_BOPOMOFO_EXTENDED
+{
+ Text [ en-US ] = "Bopomofo Extended";
+ };
+
+String RID_SUBSETSTR_KATAKANA_PHONETIC
+{
+ Text [ en-US ] = "Katakana Phonetics";
+ };
+};
+
+// ********************************************************************** EOF
diff --git a/svx/source/dialog/wrapfield.cxx b/svx/source/dialog/wrapfield.cxx
new file mode 100644
index 000000000000..2d4256d16220
--- /dev/null
+++ b/svx/source/dialog/wrapfield.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "wrapfield.hxx"
+
+namespace svx {
+
+// ============================================================================
+
+WrapField::WrapField( Window* pParent, WinBits nWinStyle ) :
+ NumericField( pParent, nWinStyle )
+{
+}
+
+WrapField::WrapField( Window* pParent, const ResId& rResId ) :
+ NumericField( pParent, rResId )
+{
+}
+
+void WrapField::Up()
+{
+ SetValue( ((GetValue() + GetSpinSize() - GetMin()) % (GetMax() + 1)) + GetMin() );
+ GetUpHdl().Call( this );
+}
+
+void WrapField::Down()
+{
+ SetValue( ((GetValue() - GetSpinSize() + GetMax() + 1 - GetMin()) % (GetMax() + 1)) + GetMin() );
+ GetDownHdl().Call( this );
+}
+
+// ============================================================================
+
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/camera3d.cxx b/svx/source/engine3d/camera3d.cxx
new file mode 100644
index 000000000000..2753de8e81b3
--- /dev/null
+++ b/svx/source/engine3d/camera3d.cxx
@@ -0,0 +1,395 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/camera3d.hxx>
+#include <tools/stream.hxx>
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+Camera3D::Camera3D(const basegfx::B3DPoint& rPos, const basegfx::B3DPoint& rLookAt,
+ double fFocalLen, double fBankAng) :
+ aResetPos(rPos),
+ aResetLookAt(rLookAt),
+ fResetFocalLength(fFocalLen),
+ fResetBankAngle(fBankAng),
+ fBankAngle(fBankAng),
+ bAutoAdjustProjection(TRUE)
+{
+ SetVPD(0);
+ SetPosition(rPos);
+ SetLookAt(rLookAt);
+ SetFocalLength(fFocalLen);
+}
+
+/*************************************************************************
+|*
+|* Default-Konstruktor
+|*
+\************************************************************************/
+
+Camera3D::Camera3D()
+{
+ basegfx::B3DPoint aVector3D(0.0 ,0.0 ,1.0);
+ Camera3D(aVector3D, basegfx::B3DPoint());
+}
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+void Camera3D::Reset()
+{
+ SetVPD(0);
+ fBankAngle = fResetBankAngle;
+ SetPosition(aResetPos);
+ SetLookAt(aResetLookAt);
+ SetFocalLength(fResetFocalLength);
+}
+
+/*************************************************************************
+|*
+|* Defaultwerte fuer Reset setzen
+|*
+\************************************************************************/
+
+void Camera3D::SetDefaults(const basegfx::B3DPoint& rPos, const basegfx::B3DPoint& rLookAt,
+ double fFocalLen, double fBankAng)
+{
+ aResetPos = rPos;
+ aResetLookAt = rLookAt;
+ fResetFocalLength = fFocalLen;
+ fResetBankAngle = fBankAng;
+}
+
+/*************************************************************************
+|*
+|* ViewWindow setzen und PRP anpassen
+|*
+\************************************************************************/
+
+void Camera3D::SetViewWindow(double fX, double fY, double fW, double fH)
+{
+ Viewport3D::SetViewWindow(fX, fY, fW, fH);
+ if ( bAutoAdjustProjection )
+ SetFocalLength(fFocalLength);
+}
+
+/*************************************************************************
+|*
+|* Kameraposition setzen
+|*
+\************************************************************************/
+
+void Camera3D::SetPosition(const basegfx::B3DPoint& rNewPos)
+{
+ if ( rNewPos != aPosition )
+ {
+ aPosition = rNewPos;
+ SetVRP(aPosition);
+ SetVPN(aPosition - aLookAt);
+ SetBankAngle(fBankAngle);
+ }
+}
+
+/*************************************************************************
+|*
+|* Blickpunkt setzen
+|*
+\************************************************************************/
+
+void Camera3D::SetLookAt(const basegfx::B3DPoint& rNewLookAt)
+{
+ if ( rNewLookAt != aLookAt )
+ {
+ aLookAt = rNewLookAt;
+ SetVPN(aPosition - aLookAt);
+ SetBankAngle(fBankAngle);
+ }
+}
+
+/*************************************************************************
+|*
+|* Position und Blickpunkt setzen
+|*
+\************************************************************************/
+
+void Camera3D::SetPosAndLookAt(const basegfx::B3DPoint& rNewPos,
+ const basegfx::B3DPoint& rNewLookAt)
+{
+ if ( rNewPos != aPosition || rNewLookAt != aLookAt )
+ {
+ aPosition = rNewPos;
+ aLookAt = rNewLookAt;
+
+ SetVRP(aPosition);
+ SetVPN(aPosition - aLookAt);
+ SetBankAngle(fBankAngle);
+ }
+}
+
+/*************************************************************************
+|*
+|* seitlichen Neigungswinkel setzen
+|*
+\************************************************************************/
+
+void Camera3D::SetBankAngle(double fAngle)
+{
+ basegfx::B3DVector aDiff(aPosition - aLookAt);
+ basegfx::B3DVector aPrj(aDiff);
+ fBankAngle = fAngle;
+
+ if ( aDiff.getY() == 0 )
+ {
+ aPrj.setY(-1.0);
+ }
+ else
+ { // aPrj = Projektion von aDiff auf die XZ-Ebene
+ aPrj.setY(0.0);
+
+ if ( aDiff.getY() < 0.0 )
+ {
+ aPrj = -aPrj;
+ }
+ }
+
+ // von aDiff nach oben zeigenden View-Up-Vektor berechnen
+ aPrj = aPrj.getPerpendicular(aDiff);
+ aPrj = aPrj.getPerpendicular(aDiff);
+ aDiff.normalize();
+
+ // auf Z-Achse rotieren, dort um BankAngle drehen und zurueck
+ basegfx::B3DHomMatrix aTf;
+ const double fV(sqrt(aDiff.getY() * aDiff.getY() + aDiff.getZ() * aDiff.getZ()));
+
+ if ( fV != 0.0 )
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(aDiff.getY() / fV);
+ const double fCos(aDiff.getZ() / fV);
+
+ aTemp.set(1, 1, fCos);
+ aTemp.set(2, 2, fCos);
+ aTemp.set(2, 1, fSin);
+ aTemp.set(1, 2, -fSin);
+
+ aTf *= aTemp;
+ }
+
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(-aDiff.getX());
+ const double fCos(fV);
+
+ aTemp.set(0, 0, fCos);
+ aTemp.set(2, 2, fCos);
+ aTemp.set(0, 2, fSin);
+ aTemp.set(2, 0, -fSin);
+
+ aTf *= aTemp;
+ }
+
+ aTf.rotate(0.0, 0.0, fBankAngle);
+
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(aDiff.getX());
+ const double fCos(fV);
+
+ aTemp.set(0, 0, fCos);
+ aTemp.set(2, 2, fCos);
+ aTemp.set(0, 2, fSin);
+ aTemp.set(2, 0, -fSin);
+
+ aTf *= aTemp;
+ }
+
+ if ( fV != 0.0 )
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(-aDiff.getY() / fV);
+ const double fCos(aDiff.getZ() / fV);
+
+ aTemp.set(1, 1, fCos);
+ aTemp.set(2, 2, fCos);
+ aTemp.set(2, 1, fSin);
+ aTemp.set(1, 2, -fSin);
+
+ aTf *= aTemp;
+ }
+
+ SetVUV(aTf * aPrj);
+}
+
+/*************************************************************************
+|*
+|* Brennweite setzen
+|*
+\************************************************************************/
+
+void Camera3D::SetFocalLength(double fLen)
+{
+ if ( fLen < 5 )
+ fLen = 5;
+ SetPRP(basegfx::B3DPoint(0.0, 0.0, fLen / 35.0 * aViewWin.W));
+ fFocalLength = fLen;
+}
+
+/*************************************************************************
+|*
+|* Um die Kameraposition drehen, LookAt wird dabei veraendert
+|*
+\************************************************************************/
+
+void Camera3D::Rotate(double fHAngle, double fVAngle)
+{
+ basegfx::B3DHomMatrix aTf;
+ basegfx::B3DVector aDiff(aLookAt - aPosition);
+ const double fV(sqrt(aDiff.getX() * aDiff.getX() + aDiff.getZ() * aDiff.getZ()));
+
+ if ( fV != 0.0 )
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(aDiff.getZ() / fV);
+ const double fCos(aDiff.getX() / fV);
+
+ aTemp.set(0, 0, fCos);
+ aTemp.set(2, 2, fCos);
+ aTemp.set(0, 2, fSin);
+ aTemp.set(2, 0, -fSin);
+
+ aTf *= aTemp;
+ }
+
+ {
+ aTf.rotate(0.0, 0.0, fVAngle);
+ }
+
+ if ( fV != 0.0 )
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(-aDiff.getZ() / fV);
+ const double fCos(aDiff.getX() / fV);
+
+ aTemp.set(0, 0, fCos);
+ aTemp.set(2, 2, fCos);
+ aTemp.set(0, 2, fSin);
+ aTemp.set(2, 0, -fSin);
+
+ aTf *= aTemp;
+ }
+
+ {
+ aTf.rotate(0.0, fHAngle, 0.0);
+ }
+
+ aDiff *= aTf;
+ SetLookAt(aPosition + aDiff);
+}
+
+
+/*************************************************************************
+|*
+|* Um den Blickpunkt drehen, Position wird dabei veraendert
+|*
+\************************************************************************/
+
+void Camera3D::RotateAroundLookAt(double fHAngle, double fVAngle)
+{
+ basegfx::B3DHomMatrix aTf;
+ basegfx::B3DVector aDiff(aPosition - aLookAt);
+ const double fV(sqrt(aDiff.getX() * aDiff.getX() + aDiff.getZ() * aDiff.getZ()));
+
+ if ( fV != 0.0 )
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(aDiff.getZ() / fV);
+ const double fCos(aDiff.getX() / fV);
+
+ aTemp.set(0, 0, fCos);
+ aTemp.set(2, 2, fCos);
+ aTemp.set(0, 2, fSin);
+ aTemp.set(2, 0, -fSin);
+
+ aTf *= aTemp;
+ }
+
+ {
+ aTf.rotate(0.0, 0.0, fVAngle);
+ }
+
+ if ( fV != 0.0 )
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(-aDiff.getZ() / fV);
+ const double fCos(aDiff.getX() / fV);
+
+ aTemp.set(0, 0, fCos);
+ aTemp.set(2, 2, fCos);
+ aTemp.set(0, 2, fSin);
+ aTemp.set(2, 0, -fSin);
+
+ aTf *= aTemp;
+ }
+
+ {
+ aTf.rotate(0.0, fHAngle, 0.0);
+ }
+
+ aDiff *= aTf;
+ SetPosition(aLookAt + aDiff);
+}
+
+/*************************************************************************
+|*
+|* FG: ??? Setzt wohl die Projektionsebene in eine bestimmte Tiefe
+|*
+\************************************************************************/
+
+void Camera3D::SetFocalLengthWithCorrect(double fLen)
+{
+ if ( fLen < 5.0 )
+ {
+ fLen = 5.0;
+ }
+
+ SetPRP(basegfx::B3DPoint(0.0, 0.0, aPRP.getZ() * fLen / fFocalLength));
+ fFocalLength = fLen;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/cube3d.cxx b/svx/source/engine3d/cube3d.cxx
new file mode 100644
index 000000000000..444d031ee73f
--- /dev/null
+++ b/svx/source/engine3d/cube3d.cxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+#include <svx/cube3d.hxx>
+#include "globl3d.hxx"
+#include <basegfx/point/b3dpoint.hxx>
+#include <basegfx/polygon/b3dpolygon.hxx>
+#include <svx/sdr/contact/viewcontactofe3dcube.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// #110094# DrawContact section
+
+sdr::contact::ViewContact* E3dCubeObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfE3dCube(*this);
+}
+
+TYPEINIT1(E3dCubeObj, E3dCompoundObject);
+
+/*************************************************************************
+|*
+|* Konstruktor: |
+|* 3D-Quader erzeugen; aPos: Zentrum oder links, unten, hinten |__
+|* (abhaengig von bPosIsCenter) /
+|*
+\************************************************************************/
+
+E3dCubeObj::E3dCubeObj(E3dDefaultAttributes& rDefault, basegfx::B3DPoint aPos, const basegfx::B3DVector& r3DSize)
+: E3dCompoundObject(rDefault)
+{
+ // Defaults setzen
+ SetDefaultAttributes(rDefault);
+
+ // uebergebene drueberbuegeln
+ aCubePos = aPos;
+ aCubeSize = r3DSize;
+}
+
+E3dCubeObj::E3dCubeObj()
+: E3dCompoundObject()
+{
+ // Defaults setzen
+ E3dDefaultAttributes aDefault;
+ SetDefaultAttributes(aDefault);
+}
+
+void E3dCubeObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
+{
+ aCubePos = rDefault.GetDefaultCubePos();
+ aCubeSize = rDefault.GetDefaultCubeSize();
+ nSideFlags = rDefault.GetDefaultCubeSideFlags();
+ bPosIsCenter = rDefault.GetDefaultCubePosIsCenter();
+}
+
+/*************************************************************************
+|*
+|* Identifier zurueckgeben
+|*
+\************************************************************************/
+
+UINT16 E3dCubeObj::GetObjIdentifier() const
+{
+ return E3D_CUBEOBJ_ID;
+}
+
+/*************************************************************************
+|*
+|* Wandle das Objekt in ein Gruppenobjekt bestehend aus 6 Polygonen
+|*
+\************************************************************************/
+
+SdrObject *E3dCubeObj::DoConvertToPolyObj(BOOL /*bBezier*/) const
+{
+ return NULL;
+}
+
+/*************************************************************************
+|*
+|* Zuweisungsoperator
+|*
+\************************************************************************/
+
+void E3dCubeObj::operator=(const SdrObject& rObj)
+{
+ // erstmal alle Childs kopieren
+ E3dCompoundObject::operator=(rObj);
+
+ // weitere Parameter kopieren
+ const E3dCubeObj& r3DObj = (const E3dCubeObj&)rObj;
+
+ aCubePos = r3DObj.aCubePos;
+ aCubeSize = r3DObj.aCubeSize;
+ bPosIsCenter = r3DObj.bPosIsCenter;
+ nSideFlags = r3DObj.nSideFlags;
+}
+
+/*************************************************************************
+|*
+|* Lokale Parameter setzen mit Geometrieneuerzeugung
+|*
+\************************************************************************/
+
+void E3dCubeObj::SetCubePos(const basegfx::B3DPoint& rNew)
+{
+ if(aCubePos != rNew)
+ {
+ aCubePos = rNew;
+ ActionChanged();
+ }
+}
+
+void E3dCubeObj::SetCubeSize(const basegfx::B3DVector& rNew)
+{
+ if(aCubeSize != rNew)
+ {
+ aCubeSize = rNew;
+ ActionChanged();
+ }
+}
+
+void E3dCubeObj::SetPosIsCenter(BOOL bNew)
+{
+ if(bPosIsCenter != bNew)
+ {
+ bPosIsCenter = bNew;
+ ActionChanged();
+ }
+}
+
+void E3dCubeObj::SetSideFlags(UINT16 nNew)
+{
+ if(nSideFlags != nNew)
+ {
+ nSideFlags = nNew;
+ ActionChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (singular)
+|*
+\************************************************************************/
+
+void E3dCubeObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulCube3d);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (plural)
+|*
+\************************************************************************/
+
+void E3dCubeObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralCube3d);
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/deflt3d.cxx b/svx/source/engine3d/deflt3d.cxx
new file mode 100644
index 000000000000..ae5f9bc8bec4
--- /dev/null
+++ b/svx/source/engine3d/deflt3d.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/deflt3d.hxx>
+#include <svx/cube3d.hxx>
+#include <svx/svxids.hrc>
+#include <editeng/colritem.hxx>
+#include <svx/e3ditem.hxx>
+
+/*************************************************************************
+|*
+|* Klasse zum verwalten der 3D-Default Attribute
+|*
+\************************************************************************/
+
+// Konstruktor
+E3dDefaultAttributes::E3dDefaultAttributes()
+{
+ Reset();
+}
+
+void E3dDefaultAttributes::Reset()
+{
+ // Compound-Objekt
+ bDefaultCreateNormals = TRUE;
+ bDefaultCreateTexture = TRUE;
+
+ // Cube-Objekt
+ aDefaultCubePos = basegfx::B3DPoint(-500.0, -500.0, -500.0);
+ aDefaultCubeSize = basegfx::B3DVector(1000.0, 1000.0, 1000.0);
+ nDefaultCubeSideFlags = CUBE_FULL;
+ bDefaultCubePosIsCenter = FALSE;
+
+ // Sphere-Objekt
+ aDefaultSphereCenter = basegfx::B3DPoint(0.0, 0.0, 0.0);
+ aDefaultSphereSize = basegfx::B3DPoint(1000.0, 1000.0, 1000.0);
+
+ // Lathe-Objekt
+ nDefaultLatheEndAngle = 3600;
+ bDefaultLatheSmoothed = TRUE;
+ bDefaultLatheSmoothFrontBack = FALSE;
+ bDefaultLatheCharacterMode = FALSE;
+ bDefaultLatheCloseFront = TRUE;
+ bDefaultLatheCloseBack = TRUE;
+
+ // Extrude-Objekt
+ bDefaultExtrudeSmoothed = TRUE;
+ bDefaultExtrudeSmoothFrontBack = FALSE;
+ bDefaultExtrudeCharacterMode = FALSE;
+ bDefaultExtrudeCloseFront = TRUE;
+ bDefaultExtrudeCloseBack = TRUE;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/dragmt3d.cxx b/svx/source/engine3d/dragmt3d.cxx
new file mode 100644
index 000000000000..e55f7975d4f4
--- /dev/null
+++ b/svx/source/engine3d/dragmt3d.cxx
@@ -0,0 +1,792 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <dragmt3d.hxx>
+#include <tools/shl.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/svddrgmt.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/polysc3d.hxx>
+#include <svx/e3dundo.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/sdr/overlay/overlaypolypolygon.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+#include <drawinglayer/geometry/viewinformation3d.hxx>
+#include <svx/e3dsceneupdater.hxx>
+
+TYPEINIT1(E3dDragMethod, SdrDragMethod);
+
+/*************************************************************************
+|*
+|* Konstruktor aller 3D-DragMethoden
+|*
+\************************************************************************/
+
+E3dDragMethod::E3dDragMethod (
+ SdrDragView &_rView,
+ const SdrMarkList& rMark,
+ E3dDragConstraint eConstr,
+ BOOL bFull)
+: SdrDragMethod(_rView),
+ meConstraint(eConstr),
+ mbMoveFull(bFull),
+ mbMovedAtAll(FALSE)
+{
+ // Fuer alle in der selektion befindlichen 3D-Objekte
+ // eine Unit anlegen
+ const long nCnt(rMark.GetMarkCount());
+ static bool bDoInvalidate(false);
+ long nObjs(0);
+
+ if(mbMoveFull)
+ {
+ // for non-visible 3D objects fallback to wireframe interaction
+ bool bInvisibleObjects(false);
+
+ for(nObjs = 0;!bInvisibleObjects && nObjs < nCnt;nObjs++)
+ {
+ E3dObject* pE3dObj = dynamic_cast< E3dObject* >(rMark.GetMark(nObjs)->GetMarkedSdrObj());
+
+ if(pE3dObj)
+ {
+ if(!pE3dObj->HasFillStyle() && !pE3dObj->HasLineStyle())
+ {
+ bInvisibleObjects = true;
+ }
+ }
+ }
+
+ if(bInvisibleObjects)
+ {
+ mbMoveFull = false;
+ }
+ }
+
+ for(nObjs = 0;nObjs < nCnt;nObjs++)
+ {
+ E3dObject* pE3dObj = dynamic_cast< E3dObject* >(rMark.GetMark(nObjs)->GetMarkedSdrObj());
+
+ if(pE3dObj)
+ {
+ // fill new interaction unit
+ E3dDragMethodUnit aNewUnit;
+ aNewUnit.mp3DObj = pE3dObj;
+
+ // get transformations
+ aNewUnit.maInitTransform = aNewUnit.maTransform = pE3dObj->GetTransform();
+
+ if(pE3dObj->GetParentObj())
+ {
+ // get transform between object and world, normally scene transform
+ aNewUnit.maInvDisplayTransform = aNewUnit.maDisplayTransform = pE3dObj->GetParentObj()->GetFullTransform();
+ aNewUnit.maInvDisplayTransform.invert();
+ }
+
+ // SnapRects der beteiligten Objekte invalidieren, um eine
+ // Neuberechnung beim Setzen der Marker zu erzwingen
+ if(bDoInvalidate)
+ {
+ pE3dObj->SetRectsDirty();
+ }
+
+ if(!mbMoveFull)
+ {
+ // create wireframe visualisation for parent coordinate system
+ aNewUnit.maWireframePoly.clear();
+ aNewUnit.maWireframePoly = pE3dObj->CreateWireframe();
+ aNewUnit.maWireframePoly.transform(aNewUnit.maTransform);
+ }
+
+ // FullBound ermitteln
+ maFullBound.Union(pE3dObj->GetSnapRect());
+
+ // Unit einfuegen
+ maGrp.push_back(aNewUnit);
+ }
+ }
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void E3dDragMethod::TakeSdrDragComment(XubString& /*rStr*/) const
+{
+}
+
+/*************************************************************************
+|*
+|* Erstelle das Drahtgittermodel fuer alle Aktionen
+|*
+\************************************************************************/
+
+bool E3dDragMethod::BeginSdrDrag()
+{
+ if(E3DDRAG_CONSTR_Z == meConstraint)
+ {
+ const sal_uInt32 nCnt(maGrp.size());
+ DragStat().Ref1() = maFullBound.Center();
+
+ for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
+ {
+ E3dDragMethodUnit& rCandidate = maGrp[nOb];
+ rCandidate.mnStartAngle = GetAngle(DragStat().GetStart() - DragStat().GetRef1());
+ rCandidate.mnLastAngle = 0;
+ }
+ }
+ else
+ {
+ maLastPos = DragStat().GetStart();
+ }
+
+ if(!mbMoveFull)
+ {
+ Show();
+ }
+
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* Schluss
+|*
+\************************************************************************/
+
+bool E3dDragMethod::EndSdrDrag(bool /*bCopy*/)
+{
+ const sal_uInt32 nCnt(maGrp.size());
+
+ if(!mbMoveFull)
+ {
+ // WireFrame ausblenden
+ Hide();
+ }
+
+ // Alle Transformationen anwenden und UnDo's anlegen
+ if(mbMovedAtAll)
+ {
+ const bool bUndo = getSdrDragView().IsUndoEnabled();
+ if( bUndo )
+ getSdrDragView().BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_ROTATE));
+ sal_uInt32 nOb(0);
+
+ for(nOb=0;nOb<nCnt;nOb++)
+ {
+ E3dDragMethodUnit& rCandidate = maGrp[nOb];
+ E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
+ rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
+ if( bUndo )
+ {
+ getSdrDragView().AddUndo(new E3dRotateUndoAction(rCandidate.mp3DObj->GetModel(),
+ rCandidate.mp3DObj, rCandidate.maInitTransform,
+ rCandidate.maTransform));
+ }
+ }
+ if( bUndo )
+ getSdrDragView().EndUndo();
+ }
+
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* Abbruch
+|*
+\************************************************************************/
+
+void E3dDragMethod::CancelSdrDrag()
+{
+ if(mbMoveFull)
+ {
+ if(mbMovedAtAll)
+ {
+ const sal_uInt32 nCnt(maGrp.size());
+
+ for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
+ {
+ // Transformation restaurieren
+ E3dDragMethodUnit& rCandidate = maGrp[nOb];
+ E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
+ rCandidate.mp3DObj->SetTransform(rCandidate.maInitTransform);
+ }
+ }
+ }
+ else
+ {
+ // WireFrame ausblenden
+ Hide();
+ }
+}
+
+/*************************************************************************
+|*
+|* Gemeinsames MoveSdrDrag()
+|*
+\************************************************************************/
+
+void E3dDragMethod::MoveSdrDrag(const Point& /*rPnt*/)
+{
+ mbMovedAtAll = true;
+}
+
+/*************************************************************************
+|*
+|* Zeichne das Drahtgittermodel
+|*
+\************************************************************************/
+
+// for migration from XOR to overlay
+void E3dDragMethod::CreateOverlayGeometry(::sdr::overlay::OverlayManager& rOverlayManager)
+{
+ const sal_uInt32 nCnt(maGrp.size());
+ basegfx::B2DPolyPolygon aResult;
+
+ for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
+ {
+ E3dDragMethodUnit& rCandidate = maGrp[nOb];
+ SdrPageView* pPV = getSdrDragView().GetSdrPageView();
+
+ if(pPV && pPV->HasMarkedObjPageView())
+ {
+ const basegfx::B3DPolyPolygon aCandidate(rCandidate.maWireframePoly);
+ const sal_uInt32 nPlyCnt(aCandidate.count());
+
+ if(nPlyCnt)
+ {
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+ const basegfx::B3DHomMatrix aWorldToView(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection() * aViewInfo3D.getOrientation());
+ const basegfx::B3DHomMatrix aTransform(aWorldToView * rCandidate.maDisplayTransform);
+
+ // transform to relative scene coordinates
+ basegfx::B2DPolyPolygon aPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aCandidate, aTransform));
+
+ // transform to 2D view coordinates
+ aPolyPolygon.transform(rVCScene.getObjectTransformation());
+
+ aResult.append(aPolyPolygon);
+ }
+ }
+ }
+
+ if(aResult.count())
+ {
+ ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aResult);
+ rOverlayManager.add(*pNew);
+ addToOverlayObjectList(*pNew);
+ }
+}
+
+/*************************************************************************
+
+ E3dDragRotate
+
+*************************************************************************/
+
+TYPEINIT1(E3dDragRotate, E3dDragMethod);
+
+E3dDragRotate::E3dDragRotate(SdrDragView &_rView,
+ const SdrMarkList& rMark,
+ E3dDragConstraint eConstr,
+ BOOL bFull)
+: E3dDragMethod(_rView, rMark, eConstr, bFull)
+{
+ // Zentrum aller selektierten Objekte in Augkoordinaten holen
+ const sal_uInt32 nCnt(maGrp.size());
+
+ if(nCnt)
+ {
+ const E3dScene *pScene = maGrp[0].mp3DObj->GetScene();
+
+ if(pScene)
+ {
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+
+ for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
+ {
+ E3dDragMethodUnit& rCandidate = maGrp[nOb];
+ basegfx::B3DPoint aObjCenter = rCandidate.mp3DObj->GetBoundVolume().getCenter();
+ const basegfx::B3DHomMatrix aTransform(aViewInfo3D.getOrientation() * rCandidate.maDisplayTransform * rCandidate.maInitTransform);
+
+ aObjCenter = aTransform * aObjCenter;
+ maGlobalCenter += aObjCenter;
+ }
+
+ // Teilen durch Anzahl
+ if(nCnt > 1)
+ {
+ maGlobalCenter /= (double)nCnt;
+ }
+
+ // get rotate center and transform to 3D eye coordinates
+ basegfx::B2DPoint aRotCenter2D(Ref1().X(), Ref1().Y());
+
+ // from world to relative scene using inverse getObjectTransformation()
+ basegfx::B2DHomMatrix aInverseObjectTransform(rVCScene.getObjectTransformation());
+ aInverseObjectTransform.invert();
+ aRotCenter2D = aInverseObjectTransform * aRotCenter2D;
+
+ // from 3D view to 3D eye
+ basegfx::B3DPoint aRotCenter3D(aRotCenter2D.getX(), aRotCenter2D.getY(), 0.0);
+ basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
+ aInverseViewToEye.invert();
+ aRotCenter3D = aInverseViewToEye * aRotCenter3D;
+
+ // X,Y des RotCenter und Tiefe der gemeinsamen Objektmitte aus
+ // Rotationspunkt im Raum benutzen
+ maGlobalCenter.setX(aRotCenter3D.getX());
+ maGlobalCenter.setY(aRotCenter3D.getY());
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Das Objekt wird bewegt, bestimme die Winkel
+|*
+\************************************************************************/
+
+void E3dDragRotate::MoveSdrDrag(const Point& rPnt)
+{
+ // call parent
+ E3dDragMethod::MoveSdrDrag(rPnt);
+
+ if(DragStat().CheckMinMoved(rPnt))
+ {
+ // Modifier holen
+ sal_uInt16 nModifier = 0;
+ if(getSdrDragView().ISA(E3dView))
+ {
+ const MouseEvent& rLastMouse = ((E3dView&)getSdrDragView()).GetMouseEvent();
+ nModifier = rLastMouse.GetModifier();
+ }
+
+ // Alle Objekte rotieren
+ const sal_uInt32 nCnt(maGrp.size());
+
+ for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
+ {
+ // Rotationswinkel bestimmen
+ double fWAngle, fHAngle;
+ E3dDragMethodUnit& rCandidate = maGrp[nOb];
+
+ if(E3DDRAG_CONSTR_Z == meConstraint)
+ {
+ fWAngle = NormAngle360(GetAngle(rPnt - DragStat().GetRef1()) -
+ rCandidate.mnStartAngle) - rCandidate.mnLastAngle;
+ rCandidate.mnLastAngle = (long)fWAngle + rCandidate.mnLastAngle;
+ fWAngle /= 100.0;
+ fHAngle = 0.0;
+ }
+ else
+ {
+ fWAngle = 90.0 * (double)(rPnt.X() - maLastPos.X())
+ / (double)maFullBound.GetWidth();
+ fHAngle = 90.0 * (double)(rPnt.Y() - maLastPos.Y())
+ / (double)maFullBound.GetHeight();
+ }
+ long nSnap = 0;
+
+ if(!getSdrDragView().IsRotateAllowed(FALSE))
+ nSnap = 90;
+
+ if(nSnap != 0)
+ {
+ fWAngle = (double)(((long) fWAngle + nSnap/2) / nSnap * nSnap);
+ fHAngle = (double)(((long) fHAngle + nSnap/2) / nSnap * nSnap);
+ }
+
+ // nach radiant
+ fWAngle *= F_PI180;
+ fHAngle *= F_PI180;
+
+ // Transformation bestimmen
+ basegfx::B3DHomMatrix aRotMat;
+ if(E3DDRAG_CONSTR_Y & meConstraint)
+ {
+ if(nModifier & KEY_MOD2)
+ aRotMat.rotate(0.0, 0.0, fWAngle);
+ else
+ aRotMat.rotate(0.0, fWAngle, 0.0);
+ }
+ else if(E3DDRAG_CONSTR_Z & meConstraint)
+ {
+ if(nModifier & KEY_MOD2)
+ aRotMat.rotate(0.0, fWAngle, 0.0);
+ else
+ aRotMat.rotate(0.0, 0.0, fWAngle);
+ }
+ if(E3DDRAG_CONSTR_X & meConstraint)
+ {
+ aRotMat.rotate(fHAngle, 0.0, 0.0);
+ }
+
+ // Transformation in Eye-Koordinaten, dort rotieren
+ // und zurueck
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+ basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
+ aInverseOrientation.invert();
+
+ basegfx::B3DHomMatrix aTransMat(rCandidate.maDisplayTransform);
+ aTransMat *= aViewInfo3D.getOrientation();
+ aTransMat.translate(-maGlobalCenter.getX(), -maGlobalCenter.getY(), -maGlobalCenter.getZ());
+ aTransMat *= aRotMat;
+ aTransMat.translate(maGlobalCenter.getX(), maGlobalCenter.getY(), maGlobalCenter.getZ());
+ aTransMat *= aInverseOrientation;
+ aTransMat *= rCandidate.maInvDisplayTransform;
+
+ // ...und anwenden
+ rCandidate.maTransform *= aTransMat;
+
+ if(mbMoveFull)
+ {
+ E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
+ rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
+ }
+ else
+ {
+ Hide();
+ rCandidate.maWireframePoly.transform(aTransMat);
+ Show();
+ }
+ }
+ maLastPos = rPnt;
+ DragStat().NextMove(rPnt);
+ }
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+Pointer E3dDragRotate::GetSdrDragPointer() const
+{
+ return Pointer(POINTER_ROTATE);
+}
+
+/*************************************************************************
+|*
+|* E3dDragMove
+|* Diese DragMethod wird nur bei Translationen innerhalb von 3D-Scenen
+|* benoetigt. Wird eine 3D-Scene selbst verschoben, so wird diese DragMethod
+|* nicht verwendet.
+|*
+\************************************************************************/
+
+TYPEINIT1(E3dDragMove, E3dDragMethod);
+
+E3dDragMove::E3dDragMove(SdrDragView &_rView,
+ const SdrMarkList& rMark,
+ SdrHdlKind eDrgHdl,
+ E3dDragConstraint eConstr,
+ BOOL bFull)
+: E3dDragMethod(_rView, rMark, eConstr, bFull),
+ meWhatDragHdl(eDrgHdl)
+{
+ switch(meWhatDragHdl)
+ {
+ case HDL_LEFT:
+ maScaleFixPos = maFullBound.RightCenter();
+ break;
+ case HDL_RIGHT:
+ maScaleFixPos = maFullBound.LeftCenter();
+ break;
+ case HDL_UPPER:
+ maScaleFixPos = maFullBound.BottomCenter();
+ break;
+ case HDL_LOWER:
+ maScaleFixPos = maFullBound.TopCenter();
+ break;
+ case HDL_UPLFT:
+ maScaleFixPos = maFullBound.BottomRight();
+ break;
+ case HDL_UPRGT:
+ maScaleFixPos = maFullBound.BottomLeft();
+ break;
+ case HDL_LWLFT:
+ maScaleFixPos = maFullBound.TopRight();
+ break;
+ case HDL_LWRGT:
+ maScaleFixPos = maFullBound.TopLeft();
+ break;
+ default:
+ // Bewegen des Objektes, HDL_MOVE
+ break;
+ }
+
+ // Override wenn IsResizeAtCenter()
+ if(getSdrDragView().IsResizeAtCenter())
+ {
+ meWhatDragHdl = HDL_USER;
+ maScaleFixPos = maFullBound.Center();
+ }
+}
+
+/*************************************************************************
+|*
+|* Das Objekt wird bewegt, bestimme die Translation
+|*
+\************************************************************************/
+
+void E3dDragMove::MoveSdrDrag(const Point& rPnt)
+{
+ // call parent
+ E3dDragMethod::MoveSdrDrag(rPnt);
+
+ if(DragStat().CheckMinMoved(rPnt))
+ {
+ if(HDL_MOVE == meWhatDragHdl)
+ {
+ // Translation
+ // Bewegungsvektor bestimmen
+ basegfx::B3DPoint aGlobalMoveHead((double)(rPnt.X() - maLastPos.X()), (double)(rPnt.Y() - maLastPos.Y()), 32768.0);
+ basegfx::B3DPoint aGlobalMoveTail(0.0, 0.0, 32768.0);
+ const sal_uInt32 nCnt(maGrp.size());
+
+ // Modifier holen
+ sal_uInt16 nModifier(0);
+
+ if(getSdrDragView().ISA(E3dView))
+ {
+ const MouseEvent& rLastMouse = ((E3dView&)getSdrDragView()).GetMouseEvent();
+ nModifier = rLastMouse.GetModifier();
+ }
+
+ for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
+ {
+ E3dDragMethodUnit& rCandidate = maGrp[nOb];
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+
+ // move coor from 2d world to 3d Eye
+ basegfx::B2DPoint aGlobalMoveHead2D((double)(rPnt.X() - maLastPos.X()), (double)(rPnt.Y() - maLastPos.Y()));
+ basegfx::B2DPoint aGlobalMoveTail2D(0.0, 0.0);
+ basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
+
+ aInverseSceneTransform.invert();
+ aGlobalMoveHead2D = aInverseSceneTransform * aGlobalMoveHead2D;
+ aGlobalMoveTail2D = aInverseSceneTransform * aGlobalMoveTail2D;
+
+ basegfx::B3DPoint aMoveHead3D(aGlobalMoveHead2D.getX(), aGlobalMoveHead2D.getY(), 0.5);
+ basegfx::B3DPoint aMoveTail3D(aGlobalMoveTail2D.getX(), aGlobalMoveTail2D.getY(), 0.5);
+ basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
+ aInverseViewToEye.invert();
+
+ aMoveHead3D = aInverseViewToEye * aMoveHead3D;
+ aMoveTail3D = aInverseViewToEye * aMoveTail3D;
+
+ // eventually switch movement from XY to XZ plane
+ if(nModifier & KEY_MOD2)
+ {
+ double fZwi = aMoveHead3D.getY();
+ aMoveHead3D.setY(aMoveHead3D.getZ());
+ aMoveHead3D.setZ(fZwi);
+
+ fZwi = aMoveTail3D.getY();
+ aMoveTail3D.setY(aMoveTail3D.getZ());
+ aMoveTail3D.setZ(fZwi);
+ }
+
+ // Bewegungsvektor von Aug-Koordinaten nach Parent-Koordinaten
+ basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
+ aInverseOrientation.invert();
+ basegfx::B3DHomMatrix aCompleteTrans(rCandidate.maInvDisplayTransform * aInverseOrientation);
+
+ aMoveHead3D = aCompleteTrans * aMoveHead3D;
+ aMoveTail3D = aCompleteTrans* aMoveTail3D;
+
+ // build transformation
+ basegfx::B3DHomMatrix aTransMat;
+ basegfx::B3DPoint aTranslate(aMoveHead3D - aMoveTail3D);
+ aTransMat.translate(aTranslate.getX(), aTranslate.getY(), aTranslate.getZ());
+
+ // ...and apply
+ rCandidate.maTransform *= aTransMat;
+
+ if(mbMoveFull)
+ {
+ E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
+ rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
+ }
+ else
+ {
+ Hide();
+ rCandidate.maWireframePoly.transform(aTransMat);
+ Show();
+ }
+ }
+ }
+ else
+ {
+ // Skalierung
+ // Skalierungsvektor bestimmen
+ Point aStartPos = DragStat().GetStart();
+ const sal_uInt32 nCnt(maGrp.size());
+
+ for(sal_uInt32 nOb(0); nOb < nCnt; nOb++)
+ {
+ E3dDragMethodUnit& rCandidate = maGrp[nOb];
+ const basegfx::B3DPoint aObjectCenter(rCandidate.mp3DObj->GetBoundVolume().getCenter());
+
+ // transform from 2D world view to 3D eye
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rCandidate.mp3DObj->GetScene()->GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+
+ basegfx::B2DPoint aGlobalScaleStart2D((double)(aStartPos.X()), (double)(aStartPos.Y()));
+ basegfx::B2DPoint aGlobalScaleNext2D((double)(rPnt.X()), (double)(rPnt.Y()));
+ basegfx::B2DPoint aGlobalScaleFixPos2D((double)(maScaleFixPos.X()), (double)(maScaleFixPos.Y()));
+ basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
+
+ aInverseSceneTransform.invert();
+ aGlobalScaleStart2D = aInverseSceneTransform * aGlobalScaleStart2D;
+ aGlobalScaleNext2D = aInverseSceneTransform * aGlobalScaleNext2D;
+ aGlobalScaleFixPos2D = aInverseSceneTransform * aGlobalScaleFixPos2D;
+
+ basegfx::B3DPoint aGlobalScaleStart3D(aGlobalScaleStart2D.getX(), aGlobalScaleStart2D.getY(), aObjectCenter.getZ());
+ basegfx::B3DPoint aGlobalScaleNext3D(aGlobalScaleNext2D.getX(), aGlobalScaleNext2D.getY(), aObjectCenter.getZ());
+ basegfx::B3DPoint aGlobalScaleFixPos3D(aGlobalScaleFixPos2D.getX(), aGlobalScaleFixPos2D.getY(), aObjectCenter.getZ());
+ basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
+
+ aInverseViewToEye.invert();
+ basegfx::B3DPoint aScStart(aInverseViewToEye * aGlobalScaleStart3D);
+ basegfx::B3DPoint aScNext(aInverseViewToEye * aGlobalScaleNext3D);
+ basegfx::B3DPoint aScFixPos(aInverseViewToEye * aGlobalScaleFixPos3D);
+
+ // constraints?
+ switch(meWhatDragHdl)
+ {
+ case HDL_LEFT:
+ case HDL_RIGHT:
+ // constrain to auf X -> Y equal
+ aScNext.setY(aScFixPos.getY());
+ break;
+ case HDL_UPPER:
+ case HDL_LOWER:
+ // constrain to auf Y -> X equal
+ aScNext.setX(aScFixPos.getX());
+ break;
+ default:
+ break;
+ }
+
+ // get scale vector in eye coordinates
+ basegfx::B3DPoint aScaleVec(aScStart - aScFixPos);
+ aScaleVec.setZ(1.0);
+
+ if(aScaleVec.getX() != 0.0)
+ {
+ aScaleVec.setX((aScNext.getX() - aScFixPos.getX()) / aScaleVec.getX());
+ }
+ else
+ {
+ aScaleVec.setX(1.0);
+ }
+
+ if(aScaleVec.getY() != 0.0)
+ {
+ aScaleVec.setY((aScNext.getY() - aScFixPos.getY()) / aScaleVec.getY());
+ }
+ else
+ {
+ aScaleVec.setY(1.0);
+ }
+
+ // SHIFT-key used?
+ if(getSdrDragView().IsOrtho())
+ {
+ if(fabs(aScaleVec.getX()) > fabs(aScaleVec.getY()))
+ {
+ // X is biggest
+ aScaleVec.setY(aScaleVec.getX());
+ }
+ else
+ {
+ // Y is biggest
+ aScaleVec.setX(aScaleVec.getY());
+ }
+ }
+
+ // build transformation
+ basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
+ aInverseOrientation.invert();
+
+ basegfx::B3DHomMatrix aNewTrans = rCandidate.maInitTransform;
+ aNewTrans *= rCandidate.maDisplayTransform;
+ aNewTrans *= aViewInfo3D.getOrientation();
+ aNewTrans.translate(-aScFixPos.getX(), -aScFixPos.getY(), -aScFixPos.getZ());
+ aNewTrans.scale(aScaleVec.getX(), aScaleVec.getY(), aScaleVec.getZ());
+ aNewTrans.translate(aScFixPos.getX(), aScFixPos.getY(), aScFixPos.getZ());
+ aNewTrans *= aInverseOrientation;
+ aNewTrans *= rCandidate.maInvDisplayTransform;
+
+ // ...und anwenden
+ rCandidate.maTransform = aNewTrans;
+
+ if(mbMoveFull)
+ {
+ E3DModifySceneSnapRectUpdater aUpdater(rCandidate.mp3DObj);
+ rCandidate.mp3DObj->SetTransform(rCandidate.maTransform);
+ }
+ else
+ {
+ Hide();
+ rCandidate.maWireframePoly.clear();
+ rCandidate.maWireframePoly = rCandidate.mp3DObj->CreateWireframe();
+ rCandidate.maWireframePoly.transform(rCandidate.maTransform);
+ Show();
+ }
+ }
+ }
+ maLastPos = rPnt;
+ DragStat().NextMove(rPnt);
+ }
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+Pointer E3dDragMove::GetSdrDragPointer() const
+{
+ return Pointer(POINTER_MOVE);
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/e3dsceneupdater.cxx b/svx/source/engine3d/e3dsceneupdater.cxx
new file mode 100644
index 000000000000..f5b71fc859fa
--- /dev/null
+++ b/svx/source/engine3d/e3dsceneupdater.cxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/e3dsceneupdater.hxx>
+#include <drawinglayer/geometry/viewinformation3d.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/scene3d.hxx>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+E3DModifySceneSnapRectUpdater::E3DModifySceneSnapRectUpdater(const SdrObject* pObject)
+: mpScene(0),
+ mpViewInformation3D(0)
+{
+ // Secure old 3D transformation stack before modification
+ if(pObject)
+ {
+ const E3dObject* pE3dObject = dynamic_cast< const E3dObject* >(pObject);
+
+ if(pE3dObject)
+ {
+ mpScene = pE3dObject->GetScene();
+
+ if(mpScene && mpScene->GetScene() == mpScene)
+ {
+ // if there is a scene and it's the outmost scene, get current 3D range
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(mpScene->GetViewContact());
+ const basegfx::B3DRange aAllContentRange(rVCScene.getAllContentRange3D());
+
+ if(aAllContentRange.isEmpty())
+ {
+ // no content, nothing to do
+ mpScene = 0;
+ }
+ else
+ {
+ // secure current 3D transformation stack
+ mpViewInformation3D = new drawinglayer::geometry::ViewInformation3D(rVCScene.getViewInformation3D(aAllContentRange));
+ }
+ }
+ }
+ }
+}
+
+E3DModifySceneSnapRectUpdater::~E3DModifySceneSnapRectUpdater()
+{
+ if(mpScene && mpViewInformation3D)
+ {
+ // after changing parts of the scene, use the secured last 3d transformation stack and the new content
+ // range to calculate a new, eventually expanded or shrunk, 2D geometry for the scene and apply it.
+ // Get new content range
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(mpScene->GetViewContact());
+ basegfx::B3DRange aAllContentRange(rVCScene.getAllContentRange3D());
+
+ // only change when there is still content; else let scene stay at old SnapRect
+ if(!aAllContentRange.isEmpty())
+ {
+ // check if object transform of scene has changed
+ if(mpViewInformation3D->getObjectTransformation() != mpScene->GetTransform())
+ {
+ // If Yes, it needs to be updated since it's - for historical reasons -
+ // part of the basic 3d transformation stack of the scene
+ drawinglayer::geometry::ViewInformation3D* pNew = new drawinglayer::geometry::ViewInformation3D(
+ mpScene->GetTransform(), // replace object transformation with new local transform
+ mpViewInformation3D->getOrientation(),
+ mpViewInformation3D->getProjection(),
+ mpViewInformation3D->getDeviceToView(),
+ mpViewInformation3D->getViewTime(),
+ mpViewInformation3D->getExtendedInformationSequence());
+ delete mpViewInformation3D;
+ mpViewInformation3D = pNew;
+ }
+
+ // transform content range to scene-relative coordinates using old 3d transformation stack
+ aAllContentRange.transform(mpViewInformation3D->getObjectToView());
+
+ // build 2d relative content range
+ basegfx::B2DRange aSnapRange(
+ aAllContentRange.getMinX(), aAllContentRange.getMinY(),
+ aAllContentRange.getMaxX(), aAllContentRange.getMaxY());
+
+ // transform to 2D world coordiantes using scene's 2D transformation
+ aSnapRange.transform(rVCScene.getObjectTransformation());
+
+ // snap to (old) integer
+ const Rectangle aNewSnapRect(
+ sal_Int32(floor(aSnapRange.getMinX())), sal_Int32(floor(aSnapRange.getMinY())),
+ sal_Int32(ceil(aSnapRange.getMaxX())), sal_Int32(ceil(aSnapRange.getMaxY())));
+
+ // set as new SnapRect and invalidate bound volume
+ if(mpScene->GetSnapRect() != aNewSnapRect)
+ {
+ mpScene->SetSnapRect(aNewSnapRect);
+ mpScene->InvalidateBoundVolume();
+ }
+ }
+ }
+
+ delete mpViewInformation3D;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/e3dundo.cxx b/svx/source/engine3d/e3dundo.cxx
new file mode 100644
index 000000000000..aaba36b06639
--- /dev/null
+++ b/svx/source/engine3d/e3dundo.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/e3dundo.hxx>
+#include <svx/svdmodel.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/view3d.hxx>
+#include <svx/scene3d.hxx>
+#include <svx/e3dsceneupdater.hxx>
+
+/************************************************************************/
+
+TYPEINIT1(E3dUndoAction, SfxUndoAction);
+
+/************************************************************************\
+|*
+|* Destruktor der Basisklasse
+|*
+\************************************************************************/
+E3dUndoAction::~E3dUndoAction ()
+{
+}
+
+/************************************************************************\
+|*
+|* Repeat gibt es nicht
+|*
+\************************************************************************/
+BOOL E3dUndoAction::CanRepeat(SfxRepeatTarget&) const
+{
+ return FALSE;
+}
+
+/************************************************************************/
+
+TYPEINIT1(E3dRotateUndoAction, E3dUndoAction);
+
+/************************************************************************
+
+ E3dRotateUndoAction
+
+************************************************************************/
+
+/************************************************************************\
+|*
+|* Undodestruktor fuer 3D-Rotation
+|*
+\************************************************************************/
+E3dRotateUndoAction::~E3dRotateUndoAction ()
+{
+}
+
+/************************************************************************\
+|*
+|* Undo fuer 3D-Rotation ueber die Rotationsmatrizen
+|*
+\************************************************************************/
+void E3dRotateUndoAction::Undo ()
+{
+ E3DModifySceneSnapRectUpdater aUpdater(pMy3DObj);
+ pMy3DObj->SetTransform(aMyOldRotation);
+}
+
+/************************************************************************\
+|*
+|* Undo fuer 3D-Rotation ueber die Rotationsmatrizen
+|*
+\************************************************************************/
+void E3dRotateUndoAction::Redo ()
+{
+ E3DModifySceneSnapRectUpdater aUpdater(pMy3DObj);
+ pMy3DObj->SetTransform(aMyNewRotation);
+}
+
+/*************************************************************************
+|*
+|* E3dAttributesUndoAction
+|*
+\************************************************************************/
+
+TYPEINIT1(E3dAttributesUndoAction, SdrUndoAction);
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+E3dAttributesUndoAction::E3dAttributesUndoAction( SdrModel &rModel,
+ E3dView* p3dView,
+ E3dObject* pInObject,
+ const SfxItemSet& rNewSet,
+ const SfxItemSet& rOldSet,
+ BOOL bUseSubObj)
+: SdrUndoAction( rModel ),
+ pObject ( pInObject ),
+ pView ( p3dView ),
+ bUseSubObjects(bUseSubObj),
+ aNewSet ( rNewSet ),
+ aOldSet ( rOldSet )
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+E3dAttributesUndoAction::~E3dAttributesUndoAction()
+{
+}
+
+/*************************************************************************
+|*
+|* Undo()
+|* Implementiert ueber Set3DAttributes(), um die Attribute nur an einer
+|* Stelle pflegen zu muessen!
+|*
+\************************************************************************/
+void E3dAttributesUndoAction::Undo()
+{
+ E3DModifySceneSnapRectUpdater aUpdater(pObject);
+ pObject->SetMergedItemSetAndBroadcast(aOldSet);
+}
+
+/*************************************************************************
+|*
+|* Redo()
+|*
+\************************************************************************/
+void E3dAttributesUndoAction::Redo()
+{
+ E3DModifySceneSnapRectUpdater aUpdater(pObject);
+ pObject->SetMergedItemSetAndBroadcast(aNewSet);
+}
+
+/*************************************************************************
+|*
+|* Mehrfaches Undo nicht moeglich
+|*
+\************************************************************************/
+BOOL E3dAttributesUndoAction::CanRepeat(SfxRepeatTarget& /*rView*/) const
+{
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* Mehrfaches Undo nicht moeglich
+|*
+\************************************************************************/
+void E3dAttributesUndoAction::Repeat()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/extrud3d.cxx b/svx/source/engine3d/extrud3d.cxx
new file mode 100644
index 000000000000..112606f89a30
--- /dev/null
+++ b/svx/source/engine3d/extrud3d.cxx
@@ -0,0 +1,267 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+#include <svx/svdpage.hxx>
+#include "globl3d.hxx"
+#include <svx/extrud3d.hxx>
+#include <svx/scene3d.hxx>
+
+#include <svx/svxids.hrc>
+#include <svx/xpoly.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svx3ditems.hxx>
+#include <svx/sdr/properties/e3dextrudeproperties.hxx>
+#include <svx/sdr/contact/viewcontactofe3dextrude.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b3dpolygontools.hxx>
+#include <basegfx/polygon/b3dpolypolygontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// #110094# DrawContact section
+
+sdr::contact::ViewContact* E3dExtrudeObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfE3dExtrude(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+sdr::properties::BaseProperties* E3dExtrudeObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::E3dExtrudeProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(E3dExtrudeObj, E3dCompoundObject);
+
+/*************************************************************************
+|*
+|* Konstruktor, erzeugt zwei Deckelflaechen-PolyPolygone und (PointCount-1)
+|* Seitenflaechen-Rechtecke aus dem uebergebenen PolyPolygon
+|*
+\************************************************************************/
+
+E3dExtrudeObj::E3dExtrudeObj(E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon& rPP, double fDepth)
+: E3dCompoundObject(rDefault),
+ maExtrudePolygon(rPP)
+{
+ // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
+ basegfx::B2DHomMatrix aMirrorY;
+ aMirrorY.scale(1.0, -1.0);
+ maExtrudePolygon.transform(aMirrorY);
+
+ // Defaults setzen
+ SetDefaultAttributes(rDefault);
+
+ // set extrude depth
+ GetProperties().SetObjectItemDirect(Svx3DDepthItem((sal_uInt32)(fDepth + 0.5)));
+}
+
+E3dExtrudeObj::E3dExtrudeObj()
+: E3dCompoundObject()
+{
+ // Defaults setzen
+ E3dDefaultAttributes aDefault;
+ SetDefaultAttributes(aDefault);
+}
+
+void E3dExtrudeObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
+{
+ GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultExtrudeSmoothed()));
+ GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultExtrudeSmoothFrontBack()));
+ GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultExtrudeCharacterMode()));
+ GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultExtrudeCloseFront()));
+ GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultExtrudeCloseBack()));
+
+ // Bei extrudes defaultmaessig StdTexture in X und Y
+ GetProperties().SetObjectItemDirect(Svx3DTextureProjectionXItem(1));
+ GetProperties().SetObjectItemDirect(Svx3DTextureProjectionYItem(1));
+}
+
+/*************************************************************************
+|*
+|* Identifier zurueckgeben
+|*
+\************************************************************************/
+
+UINT16 E3dExtrudeObj::GetObjIdentifier() const
+{
+ return E3D_EXTRUDEOBJ_ID;
+}
+
+/*************************************************************************
+|*
+|* Zuweisungsoperator
+|*
+\************************************************************************/
+
+void E3dExtrudeObj::operator=(const SdrObject& rObj)
+{
+ // erstmal alle Childs kopieren
+ E3dCompoundObject::operator=(rObj);
+
+ // weitere Parameter kopieren
+ const E3dExtrudeObj& r3DObj = (const E3dExtrudeObj&)rObj;
+
+ maExtrudePolygon = r3DObj.maExtrudePolygon;
+}
+
+/*************************************************************************
+|*
+|* Lokale Parameter setzen mit Geometrieneuerzeugung
+|*
+\************************************************************************/
+
+void E3dExtrudeObj::SetExtrudePolygon(const basegfx::B2DPolyPolygon &rNew)
+{
+ if(maExtrudePolygon != rNew)
+ {
+ maExtrudePolygon = rNew;
+ ActionChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (singular)
+|*
+\************************************************************************/
+
+void E3dExtrudeObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulExtrude3d);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (plural)
+|*
+\************************************************************************/
+
+void E3dExtrudeObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralExtrude3d);
+}
+
+/*************************************************************************
+|*
+|* Aufbrechen
+|*
+\************************************************************************/
+
+BOOL E3dExtrudeObj::IsBreakObjPossible()
+{
+ return TRUE;
+}
+
+SdrAttrObj* E3dExtrudeObj::GetBreakObj()
+{
+ basegfx::B3DPolyPolygon aFrontSide;
+ basegfx::B3DPolyPolygon aBackSide;
+
+ if(maExtrudePolygon.count())
+ {
+ basegfx::B2DPolyPolygon aTemp(maExtrudePolygon);
+ aTemp.removeDoublePoints();
+ aTemp = basegfx::tools::correctOrientations(aTemp);
+ const basegfx::B2VectorOrientation aOrient = basegfx::tools::getOrientation(aTemp.getB2DPolygon(0L));
+
+ if(basegfx::ORIENTATION_POSITIVE == aOrient)
+ {
+ aTemp.flip();
+ }
+
+ aFrontSide = basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(aTemp);
+ }
+
+ if(aFrontSide.count())
+ {
+ aBackSide = aFrontSide;
+
+ if(GetExtrudeDepth())
+ {
+ basegfx::B3DHomMatrix aTransform;
+
+ if(100 != GetPercentBackScale())
+ {
+ // scale polygon from center
+ const double fScaleFactor(GetPercentBackScale() / 100.0);
+ const basegfx::B3DRange aPolyPolyRange(basegfx::tools::getRange(aBackSide));
+ const basegfx::B3DPoint aCenter(aPolyPolyRange.getCenter());
+
+ aTransform.translate(-aCenter.getX(), -aCenter.getY(), -aCenter.getZ());
+ aTransform.scale(fScaleFactor, fScaleFactor, fScaleFactor);
+ aTransform.translate(aCenter.getX(), aCenter.getY(), aCenter.getZ());
+ }
+
+ // translate by extrude depth
+ aTransform.translate(0.0, 0.0, (double)GetExtrudeDepth());
+
+ aBackSide.transform(aTransform);
+ }
+ }
+
+ if(aBackSide.count())
+ {
+ // create PathObj
+ basegfx::B2DPolyPolygon aPoly = TransformToScreenCoor(aBackSide);
+ SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aPoly);
+
+ if(pPathObj)
+ {
+ SfxItemSet aSet(GetObjectItemSet());
+ aSet.Put(XLineStyleItem(XLINE_SOLID));
+ pPathObj->SetMergedItemSet(aSet);
+ }
+
+ return pPathObj;
+ }
+
+ return 0;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/float3d.cxx b/svx/source/engine3d/float3d.cxx
new file mode 100644
index 000000000000..c71aa59827b6
--- /dev/null
+++ b/svx/source/engine3d/float3d.cxx
@@ -0,0 +1,3335 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <sfx2/dispatch.hxx>
+#include <sfx2/module.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/eitem.hxx>
+#include <svtools/colrdlg.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/viewsh.hxx>
+#include <tools/shl.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/svdmodel.hxx>
+#include <globl3d.hxx>
+#include <svx/view3d.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/sphere3d.hxx>
+#include <svx/scene3d.hxx>
+#include <svx/camera3d.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/fmpage.hxx>
+#include <svx/polysc3d.hxx>
+#include <editeng/eeitem.hxx>
+#include <svl/style.hxx>
+#include <dlgutil.hxx>
+
+#include <dlgutil.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/viewpt3d.hxx> // ProjectionType
+
+#include <svx/svxids.hrc>
+#include <svx/dialogs.hrc>
+
+#include <editeng/colritem.hxx>
+#include <svx/e3ditem.hxx>
+
+#include <gallery.hxx>
+#define GALLERY_THEME "3D"
+#include <svl/whiter.hxx>
+
+#include <svx/float3d.hxx>
+#include "float3d.hrc"
+
+SFX_IMPL_DOCKINGWINDOW( Svx3DChildWindow, SID_3D_WIN )
+
+struct Svx3DWinImpl
+{
+ SfxItemPool* pPool;
+ Image maImgLightOnH;
+ Image maImgLightOffH;
+};
+
+#define SETHCIMAGE(btn,res) \
+{ \
+ Bitmap aBmp( SVX_RES( res ) ); \
+ Image aImage( aBmp, COL_LIGHTMAGENTA ); \
+ btn.SetModeImage( aImage, BMP_COLOR_HIGHCONTRAST ); \
+}
+
+namespace {
+ /** Get the dispatcher from the current view frame, or, if that is not
+ available, from the given bindings.
+ @param pBindings
+ May be NULL.
+ @returns NULL when both the current view frame is NULL and the given
+ bindings are NULL.
+ */
+ SfxDispatcher* LocalGetDispatcher (const SfxBindings* pBindings)
+ {
+ SfxDispatcher* pDispatcher = NULL;
+
+ if (SfxViewFrame::Current() != NULL)
+ pDispatcher = SfxViewFrame::Current()->GetDispatcher();
+ else if (pBindings != NULL)
+ pDispatcher = pBindings->GetDispatcher();
+
+ return pDispatcher;
+ }
+}
+
+
+/*************************************************************************
+|* Svx3DWin - FloatingWindow
+\************************************************************************/
+__EXPORT Svx3DWin::Svx3DWin( SfxBindings* pInBindings,
+ SfxChildWindow *pCW, Window* pParent ) :
+ SfxDockingWindow ( pInBindings, pCW, pParent,
+ SVX_RES( RID_SVXFLOAT_3D ) ),
+ aBtnGeo ( this, SVX_RES( BTN_GEO ) ),
+ aBtnRepresentation ( this, SVX_RES( BTN_REPRESENTATION ) ),
+ aBtnLight ( this, SVX_RES( BTN_LIGHT ) ),
+ aBtnTexture ( this, SVX_RES( BTN_TEXTURE ) ),
+ aBtnMaterial ( this, SVX_RES( BTN_MATERIAL ) ),
+ aBtnUpdate ( this, SVX_RES( BTN_UPDATE ) ),
+ aBtnAssign ( this, SVX_RES( BTN_ASSIGN ) ),
+
+ // Geometrie
+ aFtPercentDiagonal ( this, SVX_RES( FT_PERCENT_DIAGONAL ) ),
+ aMtrPercentDiagonal ( this, SVX_RES( MTR_PERCENT_DIAGONAL ) ),
+ aFtBackscale ( this, SVX_RES( FT_BACKSCALE ) ),
+ aMtrBackscale ( this, SVX_RES( MTR_BACKSCALE ) ),
+ aFtEndAngle ( this, SVX_RES( FT_END_ANGLE ) ),
+ aMtrEndAngle ( this, SVX_RES( MTR_END_ANGLE ) ),
+ aFtDepth ( this, SVX_RES( FT_DEPTH ) ),
+ aMtrDepth ( this, SVX_RES( MTR_DEPTH ) ),
+ aFLGeometrie ( this, SVX_RES( FL_GEOMETRIE ) ),
+
+ aFtHorizontal ( this, SVX_RES( FT_HORIZONTAL ) ),
+ aNumHorizontal ( this, SVX_RES( NUM_HORIZONTAL ) ),
+ aFtVertical ( this, SVX_RES( FT_VERTICAL ) ),
+ aNumVertical ( this, SVX_RES( NUM_VERTICAL ) ),
+ aFLSegments ( this, SVX_RES( FL_SEGMENTS ) ),
+
+ aBtnNormalsObj ( this, SVX_RES( BTN_NORMALS_OBJ ) ),
+ aBtnNormalsFlat ( this, SVX_RES( BTN_NORMALS_FLAT ) ),
+ aBtnNormalsSphere ( this, SVX_RES( BTN_NORMALS_SPHERE ) ),
+ aBtnNormalsInvert ( this, SVX_RES( BTN_NORMALS_INVERT ) ),
+ aBtnTwoSidedLighting( this, SVX_RES( BTN_TWO_SIDED_LIGHTING ) ),
+ aFLNormals ( this, SVX_RES( FL_NORMALS ) ),
+
+ aBtnDoubleSided ( this, SVX_RES( BTN_DOUBLE_SIDED ) ),
+
+ // Darstellung
+ aFtShademode ( this, SVX_RES( FT_SHADEMODE ) ),
+ aLbShademode ( this, SVX_RES( LB_SHADEMODE ) ),
+ aBtnShadow3d ( this, SVX_RES( BTN_SHADOW_3D ) ),
+ aFtSlant ( this, SVX_RES( FT_SLANT ) ),
+ aMtrSlant ( this, SVX_RES( MTR_SLANT ) ),
+ aFLShadow ( this, SVX_RES( FL_SHADOW ) ),
+ aFtDistance ( this, SVX_RES( FT_DISTANCE ) ),
+ aMtrDistance ( this, SVX_RES( MTR_DISTANCE ) ),
+ aFtFocalLeng ( this, SVX_RES( FT_FOCAL_LENGTH ) ),
+ aMtrFocalLength ( this, SVX_RES( MTR_FOCAL_LENGTH ) ),
+ aFLCamera ( this, SVX_RES( FL_CAMERA ) ),
+ aFLRepresentation ( this, SVX_RES( FL_REPRESENTATION ) ),
+
+ // Beleuchtung
+ aBtnLight1 ( this, SVX_RES( BTN_LIGHT_1 ) ),
+ aBtnLight2 ( this, SVX_RES( BTN_LIGHT_2 ) ),
+ aBtnLight3 ( this, SVX_RES( BTN_LIGHT_3 ) ),
+ aBtnLight4 ( this, SVX_RES( BTN_LIGHT_4 ) ),
+ aBtnLight5 ( this, SVX_RES( BTN_LIGHT_5 ) ),
+ aBtnLight6 ( this, SVX_RES( BTN_LIGHT_6 ) ),
+ aBtnLight7 ( this, SVX_RES( BTN_LIGHT_7 ) ),
+ aBtnLight8 ( this, SVX_RES( BTN_LIGHT_8 ) ),
+ aLbLight1 ( this, SVX_RES( LB_LIGHT_1 ) ),
+ aLbLight2 ( this, SVX_RES( LB_LIGHT_2 ) ),
+ aLbLight3 ( this, SVX_RES( LB_LIGHT_3 ) ),
+ aLbLight4 ( this, SVX_RES( LB_LIGHT_4 ) ),
+ aLbLight5 ( this, SVX_RES( LB_LIGHT_5 ) ),
+ aLbLight6 ( this, SVX_RES( LB_LIGHT_6 ) ),
+ aLbLight7 ( this, SVX_RES( LB_LIGHT_7 ) ),
+ aLbLight8 ( this, SVX_RES( LB_LIGHT_8 ) ),
+
+ aBtnLightColor ( this, SVX_RES( BTN_LIGHT_COLOR ) ),
+ aFTLightsource ( this, SVX_RES( FT_LIGHTSOURCE ) ),
+
+ // #99694# Keyboard shortcuts activate the next control, so the
+ // order needed to be changed here
+ aFTAmbientlight ( this, SVX_RES( FT_AMBIENTLIGHT ) ), // Text label
+ aLbAmbientlight ( this, SVX_RES( LB_AMBIENTLIGHT ) ), // ListBox
+ aBtnAmbientColor ( this, SVX_RES( BTN_AMBIENT_COLOR ) ), // color button
+
+ aFLLight ( this, SVX_RES( FL_LIGHT ) ),
+
+ // Textures
+ aFtTexKind ( this, SVX_RES( FT_TEX_KIND ) ),
+ aBtnTexLuminance ( this, SVX_RES( BTN_TEX_LUMINANCE ) ),
+ aBtnTexColor ( this, SVX_RES( BTN_TEX_COLOR ) ),
+ aFtTexMode ( this, SVX_RES( FT_TEX_MODE ) ),
+ aBtnTexReplace ( this, SVX_RES( BTN_TEX_REPLACE ) ),
+ aBtnTexModulate ( this, SVX_RES( BTN_TEX_MODULATE ) ),
+ aBtnTexBlend ( this, SVX_RES( BTN_TEX_BLEND ) ),
+ aFtTexProjectionX ( this, SVX_RES( FT_TEX_PROJECTION_X ) ),
+ aBtnTexObjectX ( this, SVX_RES( BTN_TEX_OBJECT_X ) ),
+ aBtnTexParallelX ( this, SVX_RES( BTN_TEX_PARALLEL_X ) ),
+ aBtnTexCircleX ( this, SVX_RES( BTN_TEX_CIRCLE_X ) ),
+ aFtTexProjectionY ( this, SVX_RES( FT_TEX_PROJECTION_Y ) ),
+ aBtnTexObjectY ( this, SVX_RES( BTN_TEX_OBJECT_Y ) ),
+ aBtnTexParallelY ( this, SVX_RES( BTN_TEX_PARALLEL_Y ) ),
+ aBtnTexCircleY ( this, SVX_RES( BTN_TEX_CIRCLE_Y ) ),
+ aFtTexFilter ( this, SVX_RES( FT_TEX_FILTER ) ),
+ aBtnTexFilter ( this, SVX_RES( BTN_TEX_FILTER ) ),
+ aFLTexture ( this, SVX_RES( FL_TEXTURE ) ),
+
+ // Material
+ aFtMatFavorites ( this, SVX_RES( FT_MAT_FAVORITES ) ),
+ aLbMatFavorites ( this, SVX_RES( LB_MAT_FAVORITES ) ),
+ aFtMatColor ( this, SVX_RES( FT_MAT_COLOR ) ),
+ aLbMatColor ( this, SVX_RES( LB_MAT_COLOR ) ),
+ aBtnMatColor ( this, SVX_RES( BTN_MAT_COLOR ) ),
+ aFtMatEmission ( this, SVX_RES( FT_MAT_EMISSION ) ),
+ aLbMatEmission ( this, SVX_RES( LB_MAT_EMISSION ) ),
+ aBtnEmissionColor ( this, SVX_RES( BTN_EMISSION_COLOR ) ),
+ aFtMatSpecular ( this, SVX_RES( FT_MAT_SPECULAR ) ),
+ aLbMatSpecular ( this, SVX_RES( LB_MAT_SPECULAR ) ),
+ aBtnSpecularColor ( this, SVX_RES( BTN_SPECULAR_COLOR ) ),
+ aFtMatSpecularIntensity( this, SVX_RES( FT_MAT_SPECULAR_INTENSITY ) ),
+ aMtrMatSpecularIntensity( this, SVX_RES( MTR_MAT_SPECULAR_INTENSITY ) ),
+ aFLMatSpecular ( this, SVX_RES( FL_MAT_SPECULAR ) ),
+ aFLMaterial ( this, SVX_RES( FL_MATERIAL ) ),
+
+ // Unterer Bereich
+ aBtnConvertTo3D ( this, SVX_RES( BTN_CHANGE_TO_3D ) ),
+ aBtnLatheObject ( this, SVX_RES( BTN_LATHE_OBJ ) ),
+ aBtnPerspective ( this, SVX_RES( BTN_PERSPECTIVE ) ),
+ aCtlPreview ( this, SVX_RES( CTL_PREVIEW ) ),
+ aCtlLightPreview ( this, SVX_RES( CTL_LIGHT_PREVIEW ) ),
+
+ aImgLightOn ( SVX_RES( RID_SVXIMAGE_LIGHT_ON ) ),
+ aImgLightOff ( SVX_RES( RID_SVXIMAGE_LIGHT_OFF ) ),
+
+ bUpdate ( FALSE ),
+ eViewType ( VIEWTYPE_GEO ),
+
+ pModel ( NULL ),
+ pFmPage ( NULL ),
+ pVDev ( NULL ),
+ p3DView ( NULL ),
+ pFavorSetList ( NULL ),
+ pMatFavSetList ( NULL ),
+
+ pBindings ( pInBindings ),
+ pControllerItem(0L),
+ pConvertTo3DItem(0L),
+ pConvertTo3DLatheItem(0L),
+// pPool ( NULL ),
+ mpImpl ( new Svx3DWinImpl() ),
+ mpRemember2DAttributes(NULL),
+ bOnly3DChanged ( FALSE )
+{
+ SETHCIMAGE( aBtnGeo, BMP_GEO_H );
+ SETHCIMAGE( aBtnRepresentation, BMP_REPRESENTATION_H );
+ SETHCIMAGE( aBtnLight, BMP_3DLIGHT_H );
+ SETHCIMAGE( aBtnTexture, BMP_TEXTURE_H );
+ SETHCIMAGE( aBtnMaterial, BMP_MATERIAL_H );
+ SETHCIMAGE( aBtnUpdate, BMP_UPDATE_H );
+ SETHCIMAGE( aBtnAssign, BMP_ASSIGN_H );
+ SETHCIMAGE( aBtnNormalsObj, BMP_NORMALS_OBJ_H );
+ SETHCIMAGE( aBtnNormalsFlat, BMP_NORMALS_FLAT_H );
+ SETHCIMAGE( aBtnNormalsSphere, BMP_NORMALS_SPHERE_H );
+ SETHCIMAGE( aBtnTwoSidedLighting, BMP_TWO_SIDED_LIGHTING_H );
+ SETHCIMAGE( aBtnNormalsInvert, BMP_NORMALS_INVERT_H );
+ SETHCIMAGE( aBtnDoubleSided, BMP_DOUBLE_SIDED_H );
+ SETHCIMAGE( aBtnShadow3d, BMP_SHADOW_3D_H );
+ SETHCIMAGE( aBtnLight1, BMP_LIGHT_H );
+ SETHCIMAGE( aBtnLight2, BMP_LIGHT_H );
+ SETHCIMAGE( aBtnLight3, BMP_LIGHT_H );
+ SETHCIMAGE( aBtnLight4, BMP_LIGHT_H );
+ SETHCIMAGE( aBtnLight5, BMP_LIGHT_H );
+ SETHCIMAGE( aBtnLight6, BMP_LIGHT_H );
+ SETHCIMAGE( aBtnLight7, BMP_LIGHT_H );
+ SETHCIMAGE( aBtnLight8, BMP_LIGHT_H );
+ SETHCIMAGE( aBtnLightColor, BMP_LIGHT_COLOR_H );
+ SETHCIMAGE( aBtnAmbientColor, BMP_AMBIENT_COLOR_H );
+ SETHCIMAGE( aBtnTexLuminance, BMP_TEX_LUMINANCE_H );
+ SETHCIMAGE( aBtnTexColor, BMP_TEX_COLOR_H );
+ SETHCIMAGE( aBtnTexReplace, BMP_TEX_REPLACE_H );
+ SETHCIMAGE( aBtnTexModulate, BMP_TEX_MODULATE_H );
+ SETHCIMAGE( aBtnTexBlend, BMP_TEX_BLEND_H );
+ SETHCIMAGE( aBtnTexParallelX, BMP_TEX_PARALLEL_H );
+ SETHCIMAGE( aBtnTexCircleX, BMP_TEX_CIRCLE_H );
+ SETHCIMAGE( aBtnTexObjectX, BMP_TEX_OBJECT_H );
+ SETHCIMAGE( aBtnTexParallelY, BMP_TEX_PARALLEL_H );
+ SETHCIMAGE( aBtnTexCircleY, BMP_TEX_CIRCLE_H );
+ SETHCIMAGE( aBtnTexObjectY, BMP_TEX_OBJECT_H );
+ SETHCIMAGE( aBtnTexFilter, BMP_TEX_FILTER_H );
+ SETHCIMAGE( aBtnMatColor, BMP_COLORDLG_H );
+ SETHCIMAGE( aBtnEmissionColor, BMP_COLORDLG_H );
+ SETHCIMAGE( aBtnSpecularColor, BMP_COLORDLG_H );
+ SETHCIMAGE( aBtnPerspective, BMP_PERSPECTIVE_H );
+ SETHCIMAGE( aBtnConvertTo3D, BMP_CHANGE_TO_3D_H );
+ SETHCIMAGE( aBtnLatheObject, BMP_LATHE_OBJ_H );
+
+ mpImpl->pPool = NULL;
+ mpImpl->maImgLightOnH = Image( SVX_RES( RID_SVXIMAGE_LIGHT_ON_H ) );
+ mpImpl->maImgLightOffH = Image( SVX_RES( RID_SVXIMAGE_LIGHT_OFF_H ) );
+ FreeResource();
+
+ // Metrik einstellen
+ eFUnit = pInBindings->GetDispatcher()->GetModule()->GetFieldUnit();
+
+ aMtrDepth.SetUnit( eFUnit );
+ aMtrDistance.SetUnit( eFUnit );
+ aMtrFocalLength.SetUnit( eFUnit );
+
+ pControllerItem = new Svx3DCtrlItem(SID_3D_STATE, this, pBindings);
+ pConvertTo3DItem = new SvxConvertTo3DItem(SID_CONVERT_TO_3D, pBindings);
+ pConvertTo3DLatheItem = new SvxConvertTo3DItem(SID_CONVERT_TO_3D_LATHE_FAST, pBindings);
+
+ aBtnAssign.SetClickHdl( LINK( this, Svx3DWin, ClickAssignHdl ) );
+ aBtnUpdate.SetClickHdl( LINK( this, Svx3DWin, ClickUpdateHdl ) );
+
+ Link aLink( LINK( this, Svx3DWin, ClickViewTypeHdl ) );
+ aBtnGeo.SetClickHdl( aLink );
+ aBtnRepresentation.SetClickHdl( aLink );
+ aBtnLight.SetClickHdl( aLink );
+ aBtnTexture.SetClickHdl( aLink );
+ aBtnMaterial.SetClickHdl( aLink );
+
+ aLink = LINK( this, Svx3DWin, ClickHdl );
+ aBtnPerspective.SetClickHdl( aLink );
+ aBtnConvertTo3D.SetClickHdl( aLink );
+ aBtnLatheObject.SetClickHdl( aLink );
+
+ // Geometrie
+ aBtnNormalsObj.SetClickHdl( aLink );
+ aBtnNormalsFlat.SetClickHdl( aLink );
+ aBtnNormalsSphere.SetClickHdl( aLink );
+ aBtnTwoSidedLighting.SetClickHdl( aLink );
+ aBtnNormalsInvert.SetClickHdl( aLink );
+ aBtnDoubleSided.SetClickHdl( aLink );
+
+ // Darstellung
+ aBtnShadow3d.SetClickHdl( aLink );
+
+ // Beleuchtung
+ aBtnLight1.SetClickHdl( aLink );
+ aBtnLight2.SetClickHdl( aLink );
+ aBtnLight3.SetClickHdl( aLink );
+ aBtnLight4.SetClickHdl( aLink );
+ aBtnLight5.SetClickHdl( aLink );
+ aBtnLight6.SetClickHdl( aLink );
+ aBtnLight7.SetClickHdl( aLink );
+ aBtnLight8.SetClickHdl( aLink );
+
+ // Textures
+ aBtnTexLuminance.SetClickHdl( aLink );
+ aBtnTexColor.SetClickHdl( aLink );
+ aBtnTexReplace.SetClickHdl( aLink );
+ aBtnTexModulate.SetClickHdl( aLink );
+ //aBtnTexBlend.SetClickHdl( aLink );
+ aBtnTexParallelX.SetClickHdl( aLink );
+ aBtnTexCircleX.SetClickHdl( aLink );
+ aBtnTexObjectX.SetClickHdl( aLink );
+ aBtnTexParallelY.SetClickHdl( aLink );
+ aBtnTexCircleY.SetClickHdl( aLink );
+ aBtnTexObjectY.SetClickHdl( aLink );
+ aBtnTexFilter.SetClickHdl( aLink );
+
+ // Material
+ aLink = LINK( this, Svx3DWin, ClickColorHdl );
+ aBtnLightColor.SetClickHdl( aLink );
+ aBtnAmbientColor.SetClickHdl( aLink );
+ aBtnMatColor.SetClickHdl( aLink );
+ aBtnEmissionColor.SetClickHdl( aLink );
+ aBtnSpecularColor.SetClickHdl( aLink );
+
+
+ aLink = LINK( this, Svx3DWin, SelectHdl );
+ aLbMatFavorites.SetSelectHdl( aLink );
+ aLbMatColor.SetSelectHdl( aLink );
+ aLbMatEmission.SetSelectHdl( aLink );
+ aLbMatSpecular.SetSelectHdl( aLink );
+ aLbLight1.SetSelectHdl( aLink );
+ aLbLight2.SetSelectHdl( aLink );
+ aLbLight3.SetSelectHdl( aLink );
+ aLbLight4.SetSelectHdl( aLink );
+ aLbLight5.SetSelectHdl( aLink );
+ aLbLight6.SetSelectHdl( aLink );
+ aLbLight7.SetSelectHdl( aLink );
+ aLbLight8.SetSelectHdl( aLink );
+ aLbAmbientlight.SetSelectHdl( aLink );
+ aLbShademode.SetSelectHdl( aLink );
+
+ aLink = LINK( this, Svx3DWin, ModifyHdl );
+ aMtrMatSpecularIntensity.SetModifyHdl( aLink );
+ aNumHorizontal.SetModifyHdl( aLink );
+ aNumVertical.SetModifyHdl( aLink );
+ aMtrSlant.SetModifyHdl( aLink );
+
+ // Preview-Callback
+ aLink = LINK( this, Svx3DWin, ChangeLightCallbackHdl );
+ aCtlLightPreview.SetUserInteractiveChangeCallback(aLink);
+ aLink = LINK( this, Svx3DWin, ChangeSelectionCallbackHdl );
+ aCtlLightPreview.SetUserSelectionChangeCallback(aLink);
+
+ aSize = GetOutputSizePixel();
+ SetMinOutputSizePixel( aSize );
+
+ Construct();
+
+ // Initiierung der Initialisierung der ColorLBs
+ SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
+ if (pDispatcher != NULL)
+ {
+ SfxBoolItem aItem( SID_3D_INIT, TRUE );
+ pDispatcher->Execute(
+ SID_3D_INIT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+
+ Reset();
+}
+
+// -----------------------------------------------------------------------
+__EXPORT Svx3DWin::~Svx3DWin()
+{
+ //delete pMatFavSetList;
+ delete p3DView;
+ delete pVDev;
+ delete pModel;
+
+ delete pControllerItem;
+ delete pConvertTo3DItem;
+ delete pConvertTo3DLatheItem;
+
+ if(mpRemember2DAttributes)
+ delete mpRemember2DAttributes;
+
+ delete mpImpl;
+}
+
+// -----------------------------------------------------------------------
+void Svx3DWin::Construct()
+{
+ aBtnGeo.Check();
+ Link aLink( LINK( this, Svx3DWin, ClickViewTypeHdl ) );
+ aLink.Call( &aBtnGeo );
+ aCtlLightPreview.Hide();
+}
+
+// -----------------------------------------------------------------------
+void Svx3DWin::Reset()
+{
+ // Diverse Initialisierungen, default ist AllAttributes
+ aLbShademode.SelectEntryPos( 0 );
+ aMtrMatSpecularIntensity.SetValue( 50 );
+
+ aBtnLight1.Check();
+ ClickUpdateHdl( NULL );
+
+ // Nichts selektieren, um Fehler beim erstselektieren zu vermeiden
+ aCtlLightPreview.GetSvx3DLightControl().SelectLight(0);
+}
+
+bool Svx3DWin::GetUILightState( ImageButton& aBtn ) const
+{
+ return (aBtn.GetModeImage() == aImgLightOn) || (aBtn.GetModeImage() == mpImpl->maImgLightOnH);
+}
+
+void Svx3DWin::SetUILightState( ImageButton& aBtn, bool bState )
+{
+ aBtn.SetModeImage( bState ? aImgLightOn : aImgLightOff );
+ aBtn.SetModeImage( bState ? mpImpl->maImgLightOnH : mpImpl->maImgLightOffH, BMP_COLOR_HIGHCONTRAST );
+}
+
+// -----------------------------------------------------------------------
+void Svx3DWin::Update( SfxItemSet& rAttrs )
+{
+ // remember 2d attributes
+ if(mpRemember2DAttributes)
+ mpRemember2DAttributes->ClearItem();
+ else
+ mpRemember2DAttributes = new SfxItemSet(*rAttrs.GetPool(),
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
+ 0, 0);
+
+ SfxWhichIter aIter(*mpRemember2DAttributes);
+ sal_uInt16 nWhich(aIter.FirstWhich());
+
+ while(nWhich)
+ {
+ SfxItemState eState = rAttrs.GetItemState(nWhich, FALSE);
+ if(SFX_ITEM_DONTCARE == eState)
+ mpRemember2DAttributes->InvalidateItem(nWhich);
+ else if(SFX_ITEM_SET == eState)
+ mpRemember2DAttributes->Put(rAttrs.Get(nWhich, FALSE));
+
+ nWhich = aIter.NextWhich();
+ }
+
+ // construct field values
+ const SfxPoolItem* pItem;
+ //BOOL bUpdate = FALSE;
+
+ // evtl. PoolUnit ermitteln
+ if( !mpImpl->pPool )
+ {
+ mpImpl->pPool = rAttrs.GetPool();
+ DBG_ASSERT( mpImpl->pPool, "Wo ist der Pool?" );
+ ePoolUnit = mpImpl->pPool->GetMetric( SID_ATTR_LINE_WIDTH );
+ }
+ eFUnit = GetModuleFieldUnit( rAttrs );
+
+
+// Segmentanzahl aenderbar ? und andere Stati
+ SfxItemState eState = rAttrs.GetItemState( SID_ATTR_3D_INTERN, FALSE, &pItem );
+ if( SFX_ITEM_SET == eState )
+ {
+ UINT32 nState = ( ( const SfxUInt32Item* )pItem )->GetValue();
+ //BOOL bLathe = (BOOL) ( nState & 1 );
+ BOOL bExtrude = (BOOL) ( nState & 2 );
+ BOOL bSphere = (BOOL) ( nState & 4 );
+ BOOL bCube = (BOOL) ( nState & 8 );
+
+ BOOL bChart = (BOOL) ( nState & 32 ); // Chart
+
+ if( !bChart )
+ {
+ // Bei Cube-Objekten werden keine Segmente eingestellt
+ aFtHorizontal.Enable( !bCube );
+ aNumHorizontal.Enable( !bCube );
+ aFtVertical.Enable( !bCube );
+ aNumVertical.Enable( !bCube );
+ aFLSegments.Enable( !bCube );
+
+ aFtPercentDiagonal.Enable( !bCube && !bSphere );
+ aMtrPercentDiagonal.Enable( !bCube && !bSphere );
+ aFtBackscale.Enable( !bCube && !bSphere );
+ aMtrBackscale.Enable( !bCube && !bSphere );
+ aFtDepth.Enable( !bCube && !bSphere );
+ aMtrDepth.Enable( !bCube && !bSphere );
+ if( bCube )
+ {
+ aNumHorizontal.SetEmptyFieldValue();
+ aNumVertical.SetEmptyFieldValue();
+ }
+ if( bCube || bSphere )
+ {
+ aMtrPercentDiagonal.SetEmptyFieldValue();
+ aMtrBackscale.SetEmptyFieldValue();
+ aMtrDepth.SetEmptyFieldValue();
+ }
+
+ // Nur bei Lathe-Objekten gibt es einen Endwinkel
+ aFtEndAngle.Enable( !bExtrude && !bCube && !bSphere );
+ aMtrEndAngle.Enable( !bExtrude && !bCube && !bSphere );
+ if( bExtrude || bCube || bSphere )
+ aMtrEndAngle.SetEmptyFieldValue();
+ }
+ else
+ {
+ // Geometrie
+ aFtHorizontal.Enable( FALSE );
+ aNumHorizontal.Enable( FALSE );
+ aNumHorizontal.SetEmptyFieldValue();
+ aFtVertical.Enable( FALSE );
+ aNumVertical.Enable( FALSE );
+ aNumVertical.SetEmptyFieldValue();
+ aFLSegments.Enable( FALSE );
+ aFtEndAngle.Enable( FALSE );
+ aMtrEndAngle.Enable( FALSE );
+ aMtrEndAngle.SetEmptyFieldValue();
+ aFtDepth.Enable( FALSE );
+ aMtrDepth.Enable( FALSE );
+ aMtrDepth.SetEmptyFieldValue();
+
+ // Darstellung
+ aBtnShadow3d.Enable( FALSE );
+ aFtSlant.Enable( FALSE );
+ aMtrSlant.Enable( FALSE );
+ aFLShadow.Enable( FALSE );
+
+ aFtDistance.Enable( FALSE );
+ aMtrDistance.Enable( FALSE );
+ aMtrDistance.SetEmptyFieldValue();
+ aFtFocalLeng.Enable( FALSE );
+ aMtrFocalLength.Enable( FALSE );
+ aMtrFocalLength.SetEmptyFieldValue();
+ aFLCamera.Enable( FALSE );
+
+ // Unterer Bereich
+ aBtnConvertTo3D.Enable( FALSE );
+ aBtnLatheObject.Enable( FALSE );
+ }
+ }
+// Bitmapfuellung ? -> Status
+ BOOL bBitmap(FALSE);
+ eState = rAttrs.GetItemState(XATTR_FILLSTYLE);
+ if(eState != SFX_ITEM_DONTCARE)
+ {
+ XFillStyle eXFS = (XFillStyle)((const XFillStyleItem&)rAttrs.Get(XATTR_FILLSTYLE)).GetValue();
+ bBitmap = (eXFS == XFILL_BITMAP || eXFS == XFILL_GRADIENT || eXFS == XFILL_HATCH);
+ }
+
+ aFtTexKind.Enable( bBitmap );
+ aBtnTexLuminance.Enable( bBitmap );
+ aBtnTexColor.Enable( bBitmap );
+ aFtTexMode.Enable( bBitmap );
+ aBtnTexReplace.Enable( bBitmap );
+ aBtnTexModulate.Enable( bBitmap );
+ aBtnTexBlend.Enable( bBitmap );
+ aFtTexProjectionX.Enable( bBitmap );
+ aBtnTexParallelX.Enable( bBitmap );
+ aBtnTexCircleX.Enable( bBitmap );
+ aBtnTexObjectX.Enable( bBitmap );
+ aFtTexProjectionY.Enable( bBitmap );
+ aBtnTexParallelY.Enable( bBitmap );
+ aBtnTexCircleY.Enable( bBitmap );
+ aBtnTexObjectY.Enable( bBitmap );
+ aFtTexFilter.Enable( bBitmap );
+ aBtnTexFilter.Enable( bBitmap );
+ aFLTexture.Enable( bBitmap );
+
+
+// Geometrie
+ // Anzahl Segmente (horizontal)
+ if( aNumHorizontal.IsEnabled() )
+ {
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_HORZ_SEGS);
+ if(eState != SFX_ITEM_DONTCARE)
+ {
+ sal_uInt32 nValue = ((const Svx3DHorizontalSegmentsItem&)rAttrs.Get(SDRATTR_3DOBJ_HORZ_SEGS)).GetValue();
+ if(nValue != (sal_uInt32 )aNumHorizontal.GetValue())
+ {
+ aNumHorizontal.SetValue( nValue );
+ // evtl. am Ende...
+ // aCtlLightPreview.GetSvx3DLightControl().SetHorizontalSegments( (UINT16)nValue );
+ bUpdate = TRUE;
+ }
+ else if( aNumHorizontal.IsEmptyFieldValue() )
+ aNumHorizontal.SetValue( nValue );
+ }
+ else
+ {
+ if( !aNumHorizontal.IsEmptyFieldValue() )
+ {
+ aNumHorizontal.SetEmptyFieldValue();
+ bUpdate = TRUE;
+ }
+ }
+ }
+
+ // Anzahl Segmente (vertikal)
+ if( aNumVertical.IsEnabled() )
+ {
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_VERT_SEGS);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT32 nValue = ((const Svx3DVerticalSegmentsItem&)rAttrs.Get(SDRATTR_3DOBJ_VERT_SEGS)).GetValue();
+ if( nValue != (UINT32) aNumVertical.GetValue() )
+ {
+ aNumVertical.SetValue( nValue );
+ // evtl. am Ende...
+ //aCtlLightPreview.GetSvx3DLightControl().SetVerticalSegments( (UINT16)nValue );
+ bUpdate = TRUE;
+ }
+ else if( aNumVertical.IsEmptyFieldValue() )
+ aNumVertical.SetValue( nValue );
+ }
+ else
+ {
+ if( !aNumVertical.IsEmptyFieldValue() )
+ {
+ aNumVertical.SetEmptyFieldValue();
+ bUpdate = TRUE;
+ }
+ }
+ }
+
+ // Tiefe
+ if( aMtrDepth.IsEnabled() )
+ {
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_DEPTH);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT32 nValue = ((const Svx3DDepthItem&)rAttrs.Get(SDRATTR_3DOBJ_DEPTH)).GetValue();
+ UINT32 nValue2 = GetCoreValue( aMtrDepth, ePoolUnit );
+ if( nValue != nValue2 )
+ {
+ if( eFUnit != aMtrDepth.GetUnit() )
+ SetFieldUnit( aMtrDepth, eFUnit );
+
+ SetMetricValue( aMtrDepth, nValue, ePoolUnit );
+ bUpdate = TRUE;
+ }
+ else if( aMtrDepth.IsEmptyFieldValue() )
+ aMtrDepth.SetValue( aMtrDepth.GetValue() );
+ }
+ else
+ {
+ if( !aMtrDepth.IsEmptyFieldValue() )
+ {
+ aMtrDepth.SetEmptyFieldValue();
+ bUpdate = TRUE;
+ }
+ }
+ }
+
+ // Doppelwandig/-seitig
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_DOUBLE_SIDED);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ BOOL bValue = ((const Svx3DDoubleSidedItem&)rAttrs.Get(SDRATTR_3DOBJ_DOUBLE_SIDED)).GetValue();
+ if( bValue != aBtnDoubleSided.IsChecked() )
+ {
+ aBtnDoubleSided.Check( bValue );
+ bUpdate = TRUE;
+ }
+ else if( aBtnDoubleSided.GetState() == STATE_DONTKNOW )
+ aBtnDoubleSided.Check( bValue );
+ }
+ else
+ {
+ if( aBtnDoubleSided.GetState() != STATE_DONTKNOW )
+ {
+ aBtnDoubleSided.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+
+ // Kantenrundung
+ if( aMtrPercentDiagonal.IsEnabled() )
+ {
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_PERCENT_DIAGONAL);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT16 nValue = ((const Svx3DPercentDiagonalItem&)rAttrs.Get(SDRATTR_3DOBJ_PERCENT_DIAGONAL)).GetValue();
+ if( nValue != aMtrPercentDiagonal.GetValue() )
+ {
+ aMtrPercentDiagonal.SetValue( nValue );
+ bUpdate = TRUE;
+ }
+ else if( aMtrPercentDiagonal.IsEmptyFieldValue() )
+ aMtrPercentDiagonal.SetValue( nValue );
+ }
+ else
+ {
+ if( !aMtrPercentDiagonal.IsEmptyFieldValue() )
+ {
+ aMtrPercentDiagonal.SetEmptyFieldValue();
+ bUpdate = TRUE;
+ }
+ }
+ }
+
+ // Tiefenskalierung
+ if( aMtrBackscale.IsEnabled() )
+ {
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_BACKSCALE);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT16 nValue = ((const Svx3DBackscaleItem&)rAttrs.Get(SDRATTR_3DOBJ_BACKSCALE)).GetValue();
+ if( nValue != aMtrBackscale.GetValue() )
+ {
+ aMtrBackscale.SetValue( nValue );
+ bUpdate = TRUE;
+ }
+ else if( aMtrBackscale.IsEmptyFieldValue() )
+ aMtrBackscale.SetValue( nValue );
+ }
+ else
+ {
+ if( !aMtrBackscale.IsEmptyFieldValue() )
+ {
+ aMtrBackscale.SetEmptyFieldValue();
+ bUpdate = TRUE;
+ }
+ }
+ }
+
+ // Endwinkel
+ if( aMtrEndAngle.IsEnabled() )
+ {
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_END_ANGLE);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ INT32 nValue = ((const Svx3DEndAngleItem&)rAttrs.Get(SDRATTR_3DOBJ_END_ANGLE)).GetValue();
+ if( nValue != aMtrEndAngle.GetValue() )
+ {
+ aMtrEndAngle.SetValue( nValue );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( !aMtrEndAngle.IsEmptyFieldValue() )
+ {
+ aMtrEndAngle.SetEmptyFieldValue();
+ bUpdate = TRUE;
+ }
+ }
+ }
+
+ // Normalentyp
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_NORMALS_KIND);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT16 nValue = ((const Svx3DNormalsKindItem&)rAttrs.Get(SDRATTR_3DOBJ_NORMALS_KIND)).GetValue();
+
+ if( ( !aBtnNormalsObj.IsChecked() && nValue == 0 ) ||
+ ( !aBtnNormalsFlat.IsChecked() && nValue == 1 ) ||
+ ( !aBtnNormalsSphere.IsChecked() && nValue == 2 ) )
+ {
+ aBtnNormalsObj.Check( nValue == 0 );
+ aBtnNormalsFlat.Check( nValue == 1 );
+ aBtnNormalsSphere.Check( nValue == 2 );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aBtnNormalsObj.IsChecked() ||
+ aBtnNormalsFlat.IsChecked() ||
+ aBtnNormalsSphere.IsChecked() )
+ {
+ aBtnNormalsObj.Check( FALSE );
+ aBtnNormalsFlat.Check( FALSE );
+ aBtnNormalsSphere.Check( FALSE );
+ bUpdate = TRUE;
+ }
+ }
+
+ // Normalen invertieren
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_NORMALS_INVERT);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ BOOL bValue = ((const Svx3DNormalsInvertItem&)rAttrs.Get(SDRATTR_3DOBJ_NORMALS_INVERT)).GetValue();
+ if( bValue != aBtnNormalsInvert.IsChecked() )
+ {
+ aBtnNormalsInvert.Check( bValue );
+ bUpdate = TRUE;
+ }
+ else if( aBtnNormalsInvert.GetState() == STATE_DONTKNOW )
+ aBtnNormalsInvert.Check( bValue );
+ }
+ else
+ {
+ if( aBtnNormalsInvert.GetState() != STATE_DONTKNOW )
+ {
+ aBtnNormalsInvert.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+
+ // 2-seitige Beleuchtung
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ BOOL bValue = ((const Svx3DTwoSidedLightingItem&)rAttrs.Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING)).GetValue();
+ if( bValue != aBtnTwoSidedLighting.IsChecked() )
+ {
+ aBtnTwoSidedLighting.Check( bValue );
+ bUpdate = TRUE;
+ }
+ else if( aBtnTwoSidedLighting.GetState() == STATE_DONTKNOW )
+ aBtnTwoSidedLighting.Check( bValue );
+ }
+ else
+ {
+ if( aBtnTwoSidedLighting.GetState() != STATE_DONTKNOW )
+ {
+ aBtnTwoSidedLighting.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+
+// Darstellung
+ // Shademode
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_SHADE_MODE);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT16 nValue = ((const Svx3DShadeModeItem&)rAttrs.Get(SDRATTR_3DSCENE_SHADE_MODE)).GetValue();
+ if( nValue != aLbShademode.GetSelectEntryPos() )
+ {
+ aLbShademode.SelectEntryPos( nValue );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbShademode.GetSelectEntryCount() != 0 )
+ {
+ aLbShademode.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+
+ // 3D-Shatten
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_SHADOW_3D);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ BOOL bValue = ((const Svx3DShadow3DItem&)rAttrs.Get(SDRATTR_3DOBJ_SHADOW_3D)).GetValue();
+ if( bValue != aBtnShadow3d.IsChecked() )
+ {
+ aBtnShadow3d.Check( bValue );
+ aFtSlant.Enable( bValue );
+ aMtrSlant.Enable( bValue );
+ bUpdate = TRUE;
+ }
+ else if( aBtnShadow3d.GetState() == STATE_DONTKNOW )
+ aBtnShadow3d.Check( bValue );
+ }
+ else
+ {
+ if( aBtnShadow3d.GetState() != STATE_DONTKNOW )
+ {
+ aBtnShadow3d.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+
+ // Neigung (Schatten)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_SHADOW_SLANT);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT16 nValue = ((const Svx3DShadowSlantItem&)rAttrs.Get(SDRATTR_3DSCENE_SHADOW_SLANT)).GetValue();
+ if( nValue != aMtrSlant.GetValue() )
+ {
+ aMtrSlant.SetValue( nValue );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( !aMtrSlant.IsEmptyFieldValue() )
+ {
+ aMtrSlant.SetEmptyFieldValue();
+ bUpdate = TRUE;
+ }
+ }
+
+ // Distanz
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_DISTANCE);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT32 nValue = ((const Svx3DDistanceItem&)rAttrs.Get(SDRATTR_3DSCENE_DISTANCE)).GetValue();
+ UINT32 nValue2 = GetCoreValue( aMtrDistance, ePoolUnit );
+ if( nValue != nValue2 )
+ {
+ if( eFUnit != aMtrDistance.GetUnit() )
+ SetFieldUnit( aMtrDistance, eFUnit );
+
+ SetMetricValue( aMtrDistance, nValue, ePoolUnit );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( !aMtrDepth.IsEmptyFieldValue() )
+ {
+ aMtrDepth.SetEmptyFieldValue();
+ bUpdate = TRUE;
+ }
+ }
+
+ // Brennweite
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_FOCAL_LENGTH);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT32 nValue = ((const Svx3DFocalLengthItem&)rAttrs.Get(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue();
+ UINT32 nValue2 = GetCoreValue( aMtrFocalLength, ePoolUnit );
+ if( nValue != nValue2 )
+ {
+ if( eFUnit != aMtrFocalLength.GetUnit() )
+ SetFieldUnit( aMtrFocalLength, eFUnit );
+
+ SetMetricValue( aMtrFocalLength, nValue, ePoolUnit );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( !aMtrFocalLength.IsEmptyFieldValue() )
+ {
+ aMtrFocalLength.SetEmptyFieldValue();
+ bUpdate = TRUE;
+ }
+ }
+
+// Beleuchtung
+ Color aColor;
+ basegfx::B3DVector aVector;
+ // Licht 1 (Farbe)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_1);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DLightcolor1Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue();
+ ColorLB* pLb = &aLbLight1;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbLight1.GetSelectEntryCount() != 0 )
+ {
+ aLbLight1.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 1 (an/aus)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_1);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bool bOn = ((const Svx3DLightOnOff1Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue() != 0;
+ if( ( bOn && !GetUILightState( aBtnLight1 )) ||
+ ( !bOn && GetUILightState( aBtnLight1 )) )
+ {
+ SetUILightState( aBtnLight1, bOn );
+ bUpdate = TRUE;
+ }
+ if( aBtnLight1.GetState() == STATE_DONTKNOW )
+ aBtnLight1.Check( aBtnLight1.IsChecked() );
+ }
+ else
+ {
+ if( aBtnLight1.GetState() != STATE_DONTKNOW )
+ {
+ aBtnLight1.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 1 (Richtung)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_1);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bUpdate = TRUE;
+ }
+
+ // Licht 2 (Farbe)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_2);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DLightcolor2Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue();
+ ColorLB* pLb = &aLbLight2;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbLight2.GetSelectEntryCount() != 0 )
+ {
+ aLbLight2.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 2 (an/aus)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_2);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bool bOn = ((const Svx3DLightOnOff2Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue() != 0;
+ if( ( bOn && !GetUILightState( aBtnLight2 )) ||
+ ( !bOn && GetUILightState( aBtnLight2 )) )
+ {
+ SetUILightState( aBtnLight2, bOn );
+ bUpdate = TRUE;
+ }
+ if( aBtnLight2.GetState() == STATE_DONTKNOW )
+ aBtnLight2.Check( aBtnLight2.IsChecked() );
+ }
+ else
+ {
+ if( aBtnLight2.GetState() != STATE_DONTKNOW )
+ {
+ aBtnLight2.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 2 (Richtung)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_2);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bUpdate = TRUE;
+ }
+
+ // Licht 3 (Farbe)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_3);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DLightcolor3Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue();
+ ColorLB* pLb = &aLbLight3;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbLight3.GetSelectEntryCount() != 0 )
+ {
+ aLbLight3.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 3 (an/aus)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_3);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bool bOn = ((const Svx3DLightOnOff3Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue() != 0;
+ if( ( bOn && !GetUILightState( aBtnLight3)) ||
+ ( !bOn && GetUILightState( aBtnLight3)) )
+ {
+ SetUILightState( aBtnLight3, bOn );
+ bUpdate = TRUE;
+ }
+ if( aBtnLight3.GetState() == STATE_DONTKNOW )
+ aBtnLight3.Check( aBtnLight3.IsChecked() );
+ }
+ else
+ {
+ if( aBtnLight3.GetState() != STATE_DONTKNOW )
+ {
+ aBtnLight3.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 3 (Richtung)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_3);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bUpdate = TRUE;
+ }
+
+ // Licht 4 (Farbe)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_4);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DLightcolor4Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue();
+ ColorLB* pLb = &aLbLight4;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbLight4.GetSelectEntryCount() != 0 )
+ {
+ aLbLight4.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 4 (an/aus)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_4);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bool bOn = ((const Svx3DLightOnOff4Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue() != 0;
+ if( ( bOn && !GetUILightState( aBtnLight4 )) ||
+ ( !bOn && GetUILightState( aBtnLight4 )) )
+ {
+ SetUILightState( aBtnLight4, bOn );
+ bUpdate = TRUE;
+ }
+ if( aBtnLight4.GetState() == STATE_DONTKNOW )
+ aBtnLight4.Check( aBtnLight4.IsChecked() );
+ }
+ else
+ {
+ if( aBtnLight4.GetState() != STATE_DONTKNOW )
+ {
+ aBtnLight4.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 4 (Richtung)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_4);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bUpdate = TRUE;
+ }
+
+ // Licht 5 (Farbe)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_5);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DLightcolor5Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue();
+ ColorLB* pLb = &aLbLight5;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbLight5.GetSelectEntryCount() != 0 )
+ {
+ aLbLight5.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 5 (an/aus)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_5);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bool bOn = ((const Svx3DLightOnOff5Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue() != 0;
+ if( ( bOn && !GetUILightState( aBtnLight5 )) ||
+ ( !bOn && GetUILightState( aBtnLight5 )) )
+ {
+ SetUILightState( aBtnLight5, bOn );
+ bUpdate = TRUE;
+ }
+ if( aBtnLight5.GetState() == STATE_DONTKNOW )
+ aBtnLight5.Check( aBtnLight5.IsChecked() );
+ }
+ else
+ {
+ if( aBtnLight5.GetState() != STATE_DONTKNOW )
+ {
+ aBtnLight5.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 5 (Richtung)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_5);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bUpdate = TRUE;
+ }
+
+ // Licht 6 (Farbe)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_6);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DLightcolor6Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue();
+ ColorLB* pLb = &aLbLight6;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbLight6.GetSelectEntryCount() != 0 )
+ {
+ aLbLight6.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 6 (an/aus)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_6);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bool bOn = ((const Svx3DLightOnOff6Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue() != 0;
+ if( ( bOn && !GetUILightState( aBtnLight6 )) ||
+ ( !bOn && GetUILightState( aBtnLight6 )) )
+ {
+ SetUILightState( aBtnLight6, bOn );
+ bUpdate = TRUE;
+ }
+ if( aBtnLight6.GetState() == STATE_DONTKNOW )
+ aBtnLight6.Check( aBtnLight6.IsChecked() );
+ }
+ else
+ {
+ if( aBtnLight6.GetState() != STATE_DONTKNOW )
+ {
+ aBtnLight6.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 6 (Richtung)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_6);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bUpdate = TRUE;
+ }
+
+ // Licht 7 (Farbe)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_7);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DLightcolor7Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue();
+ ColorLB* pLb = &aLbLight7;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbLight7.GetSelectEntryCount() != 0 )
+ {
+ aLbLight7.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 7 (an/aus)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_7);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bool bOn = ((const Svx3DLightOnOff7Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue() != 0;
+ if( ( bOn && !GetUILightState( aBtnLight7 )) ||
+ ( !bOn && GetUILightState( aBtnLight7 )) )
+ {
+ SetUILightState( aBtnLight7 , bOn );
+ bUpdate = TRUE;
+ }
+ if( aBtnLight7.GetState() == STATE_DONTKNOW )
+ aBtnLight7.Check( aBtnLight7.IsChecked() );
+ }
+ else
+ {
+ if( aBtnLight7.GetState() != STATE_DONTKNOW )
+ {
+ aBtnLight7.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 7 (Richtung)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_7);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bUpdate = TRUE;
+ }
+
+ // Licht 8 (Farbe)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTCOLOR_8);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DLightcolor8Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue();
+ ColorLB* pLb = &aLbLight8;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbLight8.GetSelectEntryCount() != 0 )
+ {
+ aLbLight8.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 8 (an/aus)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTON_8);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bool bOn = ((const Svx3DLightOnOff8Item&)rAttrs.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue() != 0;
+ if( ( bOn && !GetUILightState( aBtnLight8 )) ||
+ ( !bOn && GetUILightState( aBtnLight8 )) )
+ {
+ SetUILightState( aBtnLight8, bOn );
+ bUpdate = TRUE;
+ }
+ if( aBtnLight8.GetState() == STATE_DONTKNOW )
+ aBtnLight8.Check( aBtnLight8.IsChecked() );
+ }
+ else
+ {
+ if( aBtnLight8.GetState() != STATE_DONTKNOW )
+ {
+ aBtnLight8.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+ // Licht 8 (Richtung)
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_LIGHTDIRECTION_8);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ bUpdate = TRUE;
+ }
+
+ // Umgebungslicht
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_AMBIENTCOLOR);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DAmbientcolorItem&)rAttrs.Get(SDRATTR_3DSCENE_AMBIENTCOLOR)).GetValue();
+ ColorLB* pLb = &aLbAmbientlight;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbAmbientlight.GetSelectEntryCount() != 0 )
+ {
+ aLbAmbientlight.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+
+
+// Textures
+ // Art
+ if( bBitmap )
+ {
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_KIND);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT16 nValue = ((const Svx3DTextureKindItem&)rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_KIND)).GetValue();
+
+ if( ( !aBtnTexLuminance.IsChecked() && nValue == 1 ) ||
+ ( !aBtnTexColor.IsChecked() && nValue == 3 ) )
+ {
+ aBtnTexLuminance.Check( nValue == 1 );
+ aBtnTexColor.Check( nValue == 3 );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aBtnTexLuminance.IsChecked() ||
+ aBtnTexColor.IsChecked() )
+ {
+ aBtnTexLuminance.Check( FALSE );
+ aBtnTexColor.Check( FALSE );
+ bUpdate = TRUE;
+ }
+ }
+
+ // Modus
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_MODE);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT16 nValue = ((const Svx3DTextureModeItem&)rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_MODE)).GetValue();
+
+ if( ( !aBtnTexReplace.IsChecked() && nValue == 1 ) ||
+ ( !aBtnTexModulate.IsChecked() && nValue == 2 ) )
+ {
+ aBtnTexReplace.Check( nValue == 1 );
+ aBtnTexModulate.Check( nValue == 2 );
+ //aBtnTexBlend.Check( nValue == 2 );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aBtnTexReplace.IsChecked() ||
+ aBtnTexModulate.IsChecked() )
+ {
+ aBtnTexReplace.Check( FALSE );
+ aBtnTexModulate.Check( FALSE );
+ //aBtnTexBlend.Check( FALSE );
+ bUpdate = TRUE;
+ }
+ }
+
+ // Projektion X
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_PROJ_X);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT16 nValue = ((const Svx3DTextureProjectionXItem&)rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X)).GetValue();
+
+ if( ( !aBtnTexObjectX.IsChecked() && nValue == 0 ) ||
+ ( !aBtnTexParallelX.IsChecked() && nValue == 1 ) ||
+ ( !aBtnTexCircleX.IsChecked() && nValue == 2 ) )
+ {
+ aBtnTexObjectX.Check( nValue == 0 );
+ aBtnTexParallelX.Check( nValue == 1 );
+ aBtnTexCircleX.Check( nValue == 2 );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aBtnTexObjectX.IsChecked() ||
+ aBtnTexParallelX.IsChecked() ||
+ aBtnTexCircleX.IsChecked() )
+ {
+ aBtnTexObjectX.Check( FALSE );
+ aBtnTexParallelX.Check( FALSE );
+ aBtnTexCircleX.Check( FALSE );
+ bUpdate = TRUE;
+ }
+ }
+
+ // Projektion Y
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_PROJ_Y);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT16 nValue = ((const Svx3DTextureProjectionYItem&)rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y)).GetValue();
+
+ if( ( !aBtnTexObjectY.IsChecked() && nValue == 0 ) ||
+ ( !aBtnTexParallelY.IsChecked() && nValue == 1 ) ||
+ ( !aBtnTexCircleY.IsChecked() && nValue == 2 ) )
+ {
+ aBtnTexObjectY.Check( nValue == 0 );
+ aBtnTexParallelY.Check( nValue == 1 );
+ aBtnTexCircleY.Check( nValue == 2 );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aBtnTexObjectY.IsChecked() ||
+ aBtnTexParallelY.IsChecked() ||
+ aBtnTexCircleY.IsChecked() )
+ {
+ aBtnTexObjectY.Check( FALSE );
+ aBtnTexParallelY.Check( FALSE );
+ aBtnTexCircleY.Check( FALSE );
+ bUpdate = TRUE;
+ }
+ }
+
+ // Filter
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_TEXTURE_FILTER);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ BOOL bValue = ((const Svx3DTextureFilterItem&)rAttrs.Get(SDRATTR_3DOBJ_TEXTURE_FILTER)).GetValue();
+ if( bValue != aBtnTexFilter.IsChecked() )
+ {
+ aBtnTexFilter.Check( bValue );
+ bUpdate = TRUE;
+ }
+ if( aBtnTexFilter.GetState() == STATE_DONTKNOW )
+ aBtnTexFilter.Check( bValue );
+ }
+ else
+ {
+ if( aBtnTexFilter.GetState() != STATE_DONTKNOW )
+ {
+ aBtnTexFilter.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+ }
+
+
+ // Material Favoriten
+ aLbMatFavorites.SelectEntryPos( 0 );
+
+ // Objektfarbe
+ eState = rAttrs.GetItemState(XATTR_FILLCOLOR);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const XFillColorItem&)rAttrs.Get(XATTR_FILLCOLOR)).GetColorValue();
+ ColorLB* pLb = &aLbMatColor;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbMatColor.GetSelectEntryCount() != 0 )
+ {
+ aLbMatColor.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+
+ // Slebstleuchtfarbe
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_EMISSION);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DMaterialEmissionItem&)rAttrs.Get(SDRATTR_3DOBJ_MAT_EMISSION)).GetValue();
+ ColorLB* pLb = &aLbMatEmission;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbMatEmission.GetSelectEntryCount() != 0 )
+ {
+ aLbMatEmission.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+
+ // Glanzpunkt
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_SPECULAR);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ aColor = ((const Svx3DMaterialSpecularItem&)rAttrs.Get(SDRATTR_3DOBJ_MAT_SPECULAR)).GetValue();
+ ColorLB* pLb = &aLbMatSpecular;
+ if( aColor != pLb->GetSelectEntryColor() )
+ {
+ LBSelectColor( pLb, aColor );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( aLbMatSpecular.GetSelectEntryCount() != 0 )
+ {
+ aLbMatSpecular.SetNoSelection();
+ bUpdate = TRUE;
+ }
+ }
+
+ // Glanzpunkt Intensitaet
+ eState = rAttrs.GetItemState(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ UINT16 nValue = ((const Svx3DMaterialSpecularIntensityItem&)rAttrs.Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY)).GetValue();
+ if( nValue != aMtrMatSpecularIntensity.GetValue() )
+ {
+ aMtrMatSpecularIntensity.SetValue( nValue );
+ bUpdate = TRUE;
+ }
+ }
+ else
+ {
+ if( !aMtrMatSpecularIntensity.IsEmptyFieldValue() )
+ {
+ aMtrMatSpecularIntensity.SetEmptyFieldValue();
+ bUpdate = TRUE;
+ }
+ }
+
+
+// Sonstige
+ // Perspektive
+ eState = rAttrs.GetItemState(SDRATTR_3DSCENE_PERSPECTIVE);
+ if( eState != SFX_ITEM_DONTCARE )
+ {
+ ProjectionType ePT = (ProjectionType)((const Svx3DPerspectiveItem&)rAttrs.Get(SDRATTR_3DSCENE_PERSPECTIVE)).GetValue();
+ if( ( !aBtnPerspective.IsChecked() && ePT == PR_PERSPECTIVE ) ||
+ ( aBtnPerspective.IsChecked() && ePT == PR_PARALLEL ) )
+ {
+ aBtnPerspective.Check( ePT == PR_PERSPECTIVE );
+ bUpdate = TRUE;
+ }
+ if( aBtnPerspective.GetState() == STATE_DONTKNOW )
+ aBtnPerspective.Check( ePT == PR_PERSPECTIVE );
+ }
+ else
+ {
+ if( aBtnPerspective.GetState() != STATE_DONTKNOW )
+ {
+ aBtnPerspective.SetState( STATE_DONTKNOW );
+ bUpdate = TRUE;
+ }
+ }
+
+ if( !bUpdate && !bOnly3DChanged )
+ {
+ // Eventuell sind aber die 2D-Attribute unterschiedlich. Vergleiche
+ // diese und entscheide
+
+
+ bUpdate = TRUE;
+ }
+
+ if( bUpdate || bOnly3DChanged )
+ {
+ // Preview updaten
+ SfxItemSet aSet(rAttrs);
+
+ // set LineStyle hard to XLINE_NONE when it's not set so that
+ // the default (XLINE_SOLID) is not used for 3d preview
+ if(SFX_ITEM_SET != aSet.GetItemState(XATTR_LINESTYLE, FALSE))
+ aSet.Put(XLineStyleItem(XLINE_NONE));
+
+ // set FillColor hard to WHITE when it's SFX_ITEM_DONTCARE so that
+ // the default (Blue7) is not used for 3d preview
+ if(SFX_ITEM_DONTCARE == aSet.GetItemState(XATTR_FILLCOLOR, FALSE))
+ aSet.Put(XFillColorItem(String(), Color(COL_WHITE)));
+
+ aCtlPreview.Set3DAttributes(aSet);
+ aCtlLightPreview.GetSvx3DLightControl().Set3DAttributes(aSet);
+
+ // try to select light corresponding to active button
+ sal_uInt32 nNumber(0xffffffff);
+
+ if(aBtnLight1.IsChecked())
+ nNumber = 0;
+ else if(aBtnLight2.IsChecked())
+ nNumber = 1;
+ else if(aBtnLight3.IsChecked())
+ nNumber = 2;
+ else if(aBtnLight4.IsChecked())
+ nNumber = 3;
+ else if(aBtnLight5.IsChecked())
+ nNumber = 4;
+ else if(aBtnLight6.IsChecked())
+ nNumber = 5;
+ else if(aBtnLight7.IsChecked())
+ nNumber = 6;
+ else if(aBtnLight8.IsChecked())
+ nNumber = 7;
+
+ if(nNumber != 0xffffffff)
+ {
+ aCtlLightPreview.GetSvx3DLightControl().SelectLight(nNumber);
+ }
+ }
+
+ // handle state of converts possible
+ aBtnConvertTo3D.Enable(pConvertTo3DItem->GetState());
+ aBtnLatheObject.Enable(pConvertTo3DLatheItem->GetState());
+}
+
+// -----------------------------------------------------------------------
+void Svx3DWin::GetAttr( SfxItemSet& rAttrs )
+{
+ // get remembered 2d attributes from the dialog
+ if(mpRemember2DAttributes)
+ {
+ SfxWhichIter aIter(*mpRemember2DAttributes);
+ sal_uInt16 nWhich(aIter.FirstWhich());
+
+ while(nWhich)
+ {
+ SfxItemState eState = mpRemember2DAttributes->GetItemState(nWhich, FALSE);
+ if(SFX_ITEM_DONTCARE == eState)
+ rAttrs.InvalidateItem(nWhich);
+ else if(SFX_ITEM_SET == eState)
+ rAttrs.Put(mpRemember2DAttributes->Get(nWhich, FALSE));
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+
+// Sonstige, muss vorne stehen da auf allen Seiten
+ // Perspektive
+ if( aBtnPerspective.GetState() != STATE_DONTKNOW )
+ {
+ UINT16 nValue;
+ if( aBtnPerspective.IsChecked() )
+ nValue = PR_PERSPECTIVE;
+ else
+ nValue = PR_PARALLEL;
+ rAttrs.Put(Svx3DPerspectiveItem(nValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_PERSPECTIVE);
+
+// Geometrie
+ // evtl. PoolUnit ermitteln (Falls dies in Update() nicht passiert ist)
+ if( !mpImpl->pPool )
+ {
+ DBG_ERROR( "Kein Pool in GetAttr()! Evtl. inkompatibel zu drviewsi.cxx ?" );
+ mpImpl->pPool = rAttrs.GetPool();
+ DBG_ASSERT( mpImpl->pPool, "Wo ist der Pool?" );
+ ePoolUnit = mpImpl->pPool->GetMetric( SID_ATTR_LINE_WIDTH );
+
+ eFUnit = GetModuleFieldUnit( rAttrs );
+ }
+
+ // Anzahl Segmente (horizontal)
+ if( !aNumHorizontal.IsEmptyFieldValue() )
+ {
+ sal_uInt32 nValue = static_cast<sal_uInt32>(aNumHorizontal.GetValue());
+ rAttrs.Put(Svx3DHorizontalSegmentsItem(nValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_HORZ_SEGS);
+
+ // Anzahl Segmente (vertikal)
+ if( !aNumVertical.IsEmptyFieldValue() )
+ {
+ UINT32 nValue = static_cast<UINT32>(aNumVertical.GetValue());
+ rAttrs.Put(Svx3DVerticalSegmentsItem(nValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_VERT_SEGS);
+
+ // Tiefe
+ if( !aMtrDepth.IsEmptyFieldValue() )
+ {
+ UINT32 nValue = GetCoreValue( aMtrDepth, ePoolUnit );
+ rAttrs.Put(Svx3DDepthItem(nValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_DEPTH);
+
+ // Doppelseitig
+ TriState eState = aBtnDoubleSided.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = STATE_CHECK == eState;
+ rAttrs.Put(Svx3DDoubleSidedItem(bValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_DOUBLE_SIDED);
+
+ // Kantenrundung
+ if( !aMtrPercentDiagonal.IsEmptyFieldValue() )
+ {
+ UINT16 nValue = (UINT16) aMtrPercentDiagonal.GetValue();
+ rAttrs.Put(Svx3DPercentDiagonalItem(nValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_PERCENT_DIAGONAL);
+
+ // Tiefenskalierung
+ if( !aMtrBackscale.IsEmptyFieldValue() )
+ {
+ UINT16 nValue = (UINT16)aMtrBackscale.GetValue();
+ rAttrs.Put(Svx3DBackscaleItem(nValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_BACKSCALE);
+
+ // Endwinkel
+ if( !aMtrEndAngle.IsEmptyFieldValue() )
+ {
+ UINT16 nValue = (UINT16)aMtrEndAngle.GetValue();
+ rAttrs.Put(Svx3DEndAngleItem(nValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_END_ANGLE);
+
+ // Normalentyp
+ UINT16 nValue = 99;
+ if( aBtnNormalsObj.IsChecked() )
+ nValue = 0;
+ else if( aBtnNormalsFlat.IsChecked() )
+ nValue = 1;
+ else if( aBtnNormalsSphere.IsChecked() )
+ nValue = 2;
+
+ if( nValue <= 2 )
+ rAttrs.Put(Svx3DNormalsKindItem(nValue));
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_NORMALS_KIND);
+
+ // Normalen invertieren
+ eState = aBtnNormalsInvert.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = STATE_CHECK == eState;
+ rAttrs.Put(Svx3DNormalsInvertItem(bValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_NORMALS_INVERT);
+
+ // 2-seitige Beleuchtung
+ eState = aBtnTwoSidedLighting.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = STATE_CHECK == eState;
+ rAttrs.Put(Svx3DTwoSidedLightingItem(bValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING);
+
+// Darstellung
+ // Shademode
+ if( aLbShademode.GetSelectEntryCount() )
+ {
+ nValue = aLbShademode.GetSelectEntryPos();
+ rAttrs.Put(Svx3DShadeModeItem(nValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_SHADE_MODE);
+
+ // 3D-Shatten
+ eState = aBtnShadow3d.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = STATE_CHECK == eState;
+ rAttrs.Put(Svx3DShadow3DItem(bValue));
+ rAttrs.Put(SdrShadowItem(bValue));
+ }
+ else
+ {
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_SHADOW_3D);
+ rAttrs.InvalidateItem(SDRATTR_SHADOW);
+ }
+
+ // Neigung (Schatten)
+ if( !aMtrSlant.IsEmptyFieldValue() )
+ {
+ UINT16 nValue2 = (UINT16) aMtrSlant.GetValue();
+ rAttrs.Put(Svx3DShadowSlantItem(nValue2));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_SHADOW_SLANT);
+
+ // Distanz
+ if( !aMtrDistance.IsEmptyFieldValue() )
+ {
+ UINT32 nValue2 = GetCoreValue( aMtrDistance, ePoolUnit );
+ rAttrs.Put(Svx3DDistanceItem(nValue2));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_DISTANCE);
+
+ // Brennweite
+ if( !aMtrFocalLength.IsEmptyFieldValue() )
+ {
+ UINT32 nValue2 = GetCoreValue( aMtrFocalLength, ePoolUnit );
+ rAttrs.Put(Svx3DFocalLengthItem(nValue2));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
+
+// Beleuchtung
+ Image aImg;
+ basegfx::B3DVector aVector;
+ Color aColor;
+ const SfxItemSet aLightItemSet(aCtlLightPreview.GetSvx3DLightControl().Get3DAttributes());
+
+ // Licht 1 Farbe
+ if( aLbLight1.GetSelectEntryCount() )
+ {
+ aColor = aLbLight1.GetSelectEntryColor();
+ rAttrs.Put(Svx3DLightcolor1Item(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_1);
+ // Licht 1 (an/aus)
+ eState = aBtnLight1.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = GetUILightState( aBtnLight1 );
+ rAttrs.Put(Svx3DLightOnOff1Item(bValue));
+
+ // Licht 1 (Richtung)
+ if( bValue )
+ {
+ rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1));
+ }
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_1);
+
+
+ // Licht 2 Farbe
+ if( aLbLight2.GetSelectEntryCount() )
+ {
+ aColor = aLbLight2.GetSelectEntryColor();
+ rAttrs.Put(Svx3DLightcolor2Item(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_2);
+ // Licht 2 (an/aus)
+ eState = aBtnLight2.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = GetUILightState( aBtnLight2 );
+ rAttrs.Put(Svx3DLightOnOff2Item(bValue));
+
+ // Licht 2 (Richtung)
+ if( bValue )
+ {
+ rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2));
+ }
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_2);
+
+ // Licht 3 Farbe
+ if( aLbLight3.GetSelectEntryCount() )
+ {
+ aColor = aLbLight3.GetSelectEntryColor();
+ rAttrs.Put(Svx3DLightcolor3Item(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_3);
+ // Licht 3 (an/aus)
+ eState = aBtnLight3.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = GetUILightState( aBtnLight3 );
+ rAttrs.Put(Svx3DLightOnOff3Item(bValue));
+
+ // Licht 3 (Richtung)
+ if( bValue )
+ {
+ rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3));
+ }
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_3);
+
+ // Licht 4 Farbe
+ if( aLbLight4.GetSelectEntryCount() )
+ {
+ aColor = aLbLight4.GetSelectEntryColor();
+ rAttrs.Put(Svx3DLightcolor4Item(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_4);
+ // Licht 4 (an/aus)
+ eState = aBtnLight4.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = GetUILightState( aBtnLight4 );
+ rAttrs.Put(Svx3DLightOnOff4Item(bValue));
+
+ // Licht 4 (Richtung)
+ if( bValue )
+ {
+ rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4));
+ }
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_4);
+
+ // Licht 5 Farbe
+ if( aLbLight5.GetSelectEntryCount() )
+ {
+ aColor = aLbLight5.GetSelectEntryColor();
+ rAttrs.Put(Svx3DLightcolor5Item(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_5);
+ // Licht 5 (an/aus)
+ eState = aBtnLight5.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = GetUILightState( aBtnLight5 );
+ rAttrs.Put(Svx3DLightOnOff5Item(bValue));
+
+ // Licht 5 (Richtung)
+ if( bValue )
+ {
+ rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5));
+ }
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_5);
+
+ // Licht 6 Farbe
+ if( aLbLight6.GetSelectEntryCount() )
+ {
+ aColor = aLbLight6.GetSelectEntryColor();
+ rAttrs.Put(Svx3DLightcolor6Item(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_6);
+ // Licht 6 (an/aus)
+ eState = aBtnLight6.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = GetUILightState( aBtnLight6 );
+ rAttrs.Put(Svx3DLightOnOff6Item(bValue));
+
+ // Licht 6 (Richtung)
+ if( bValue )
+ {
+ rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6));
+ }
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_6);
+
+ // Licht 7 Farbe
+ if( aLbLight7.GetSelectEntryCount() )
+ {
+ aColor = aLbLight7.GetSelectEntryColor();
+ rAttrs.Put(Svx3DLightcolor7Item(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_7);
+ // Licht 7 (an/aus)
+ eState = aBtnLight7.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = GetUILightState( aBtnLight7 );
+ rAttrs.Put(Svx3DLightOnOff7Item(bValue));
+
+ // Licht 7 (Richtung)
+ if( bValue )
+ {
+ rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7));
+ }
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_7);
+
+ // Licht 8 Farbe
+ if( aLbLight8.GetSelectEntryCount() )
+ {
+ aColor = aLbLight8.GetSelectEntryColor();
+ rAttrs.Put(Svx3DLightcolor8Item(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTCOLOR_8);
+ // Licht 8 (an/aus)
+ eState = aBtnLight8.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = GetUILightState( aBtnLight8 );
+ rAttrs.Put(Svx3DLightOnOff8Item(bValue));
+
+ // Licht 8 (Richtung)
+ if( bValue )
+ {
+ rAttrs.Put(aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8));
+ }
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_LIGHTON_8);
+
+ // Umgebungslicht
+ if( aLbAmbientlight.GetSelectEntryCount() )
+ {
+ aColor = aLbAmbientlight.GetSelectEntryColor();
+ rAttrs.Put(Svx3DAmbientcolorItem(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DSCENE_AMBIENTCOLOR);
+
+// Textures
+ // Art
+ nValue = 3;
+ if( aBtnTexLuminance.IsChecked() )
+ nValue = 1;
+ else if( aBtnTexColor.IsChecked() )
+ nValue = 3;
+
+ if( nValue == 1 || nValue == 3 )
+ rAttrs.Put(Svx3DTextureKindItem(nValue));
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_KIND);
+
+
+ // Modus
+ nValue = 99;
+ if( aBtnTexReplace.IsChecked() )
+ nValue = 1;
+ else if( aBtnTexModulate.IsChecked() )
+ nValue = 2;
+ //else if( aBtnTexBlend.IsChecked() )
+ // nValue = 2;
+
+ if( nValue == 1 || nValue == 2 )
+ rAttrs.Put(Svx3DTextureModeItem(nValue));
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_MODE);
+
+ // Projektion X
+ nValue = 99;
+ if( aBtnTexObjectX.IsChecked() )
+ nValue = 0;
+ else if( aBtnTexParallelX.IsChecked() )
+ nValue = 1;
+ else if( aBtnTexCircleX.IsChecked() )
+ nValue = 2;
+
+ if( nValue <= 2 )
+ rAttrs.Put(Svx3DTextureProjectionXItem(nValue));
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_PROJ_X);
+
+ // Projektion Y
+ nValue = 99;
+ if( aBtnTexObjectY.IsChecked() )
+ nValue = 0;
+ else if( aBtnTexParallelY.IsChecked() )
+ nValue = 1;
+ else if( aBtnTexCircleY.IsChecked() )
+ nValue = 2;
+
+ if( nValue <= 2 )
+ rAttrs.Put(Svx3DTextureProjectionYItem(nValue));
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_PROJ_Y);
+
+
+ // Filter
+ eState = aBtnTexFilter.GetState();
+ if( eState != STATE_DONTKNOW )
+ {
+ BOOL bValue = STATE_CHECK == eState;
+ rAttrs.Put(Svx3DTextureFilterItem(bValue));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_TEXTURE_FILTER);
+
+
+// Material
+ // Objektfarbe
+ if( aLbMatColor.GetSelectEntryCount() )
+ {
+ aColor = aLbMatColor.GetSelectEntryColor();
+ rAttrs.Put( XFillColorItem( String(), aColor) );
+ }
+ else
+ {
+ rAttrs.InvalidateItem( XATTR_FILLCOLOR );
+ }
+
+ // Slebstleuchtfarbe
+ if( aLbMatEmission.GetSelectEntryCount() )
+ {
+ aColor = aLbMatEmission.GetSelectEntryColor();
+ rAttrs.Put(Svx3DMaterialEmissionItem(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_EMISSION);
+
+ // Glanzpunkt
+ if( aLbMatSpecular.GetSelectEntryCount() )
+ {
+ aColor = aLbMatSpecular.GetSelectEntryColor();
+ rAttrs.Put(Svx3DMaterialSpecularItem(aColor));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_SPECULAR);
+
+ // Glanzpunkt Intensitaet
+ if( !aMtrMatSpecularIntensity.IsEmptyFieldValue() )
+ {
+ UINT16 nValue2 = (UINT16) aMtrMatSpecularIntensity.GetValue();
+ rAttrs.Put(Svx3DMaterialSpecularIntensityItem(nValue2));
+ }
+ else
+ rAttrs.InvalidateItem(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY);
+}
+
+// -----------------------------------------------------------------------
+void __EXPORT Svx3DWin::Resize()
+{
+ if ( !IsFloatingMode() ||
+ !GetFloatingWindow()->IsRollUp() )
+ {
+ Size aWinSize( GetOutputSizePixel() ); // vorher rSize im Resizing()
+
+ if( aWinSize.Height() >= GetMinOutputSizePixel().Height() &&
+ aWinSize.Width() >= GetMinOutputSizePixel().Width() )
+ {
+ Size aDiffSize;
+ aDiffSize.Width() = aWinSize.Width() - aSize.Width();
+ aDiffSize.Height() = aWinSize.Height() - aSize.Height();
+
+ Point aXPt;
+ Point aYPt;
+ aXPt.X() = aDiffSize.Width();
+ aYPt.Y() = aDiffSize.Height();
+
+ Size aObjSize;
+
+ // Hide
+ aBtnUpdate.Hide();
+ aBtnAssign.Hide();
+
+ aBtnConvertTo3D.Hide();
+ aBtnLatheObject.Hide();
+ aBtnPerspective.Hide();
+
+ aCtlPreview.Hide();
+ aCtlLightPreview.Hide();
+
+ aFLGeometrie.Hide();
+ aFLRepresentation.Hide();
+ aFLLight.Hide();
+ aFLTexture.Hide();
+ aFLMaterial.Hide();
+
+ // Verschieben / Resizen
+ aBtnUpdate.SetPosPixel( aBtnUpdate.GetPosPixel() + aXPt );
+ aBtnAssign.SetPosPixel( aBtnAssign.GetPosPixel() + aXPt );
+
+ // Preview-Controls
+ aObjSize = aCtlPreview.GetOutputSizePixel();
+ aObjSize.Width() += aDiffSize.Width();
+ aObjSize.Height() += aDiffSize.Height();
+ aCtlPreview.SetOutputSizePixel( aObjSize );
+ aCtlLightPreview.SetOutputSizePixel( aObjSize );
+
+ // Groups
+ aObjSize = aFLGeometrie.GetOutputSizePixel();
+ aObjSize.Width() += aDiffSize.Width();
+ aFLGeometrie.SetOutputSizePixel( aObjSize );
+ aFLSegments.SetOutputSizePixel( aObjSize );
+ aFLShadow.SetOutputSizePixel( aObjSize );
+ aFLCamera.SetOutputSizePixel( aObjSize );
+ aFLRepresentation.SetOutputSizePixel( aObjSize );
+ aFLLight.SetOutputSizePixel( aObjSize );
+ aFLTexture.SetOutputSizePixel( aObjSize );
+ aFLMaterial.SetOutputSizePixel( aObjSize );
+
+ // Y-Position der unteren Buttons
+ aBtnConvertTo3D.SetPosPixel( aBtnConvertTo3D.GetPosPixel() + aYPt );
+ aBtnLatheObject.SetPosPixel( aBtnLatheObject.GetPosPixel() + aYPt );
+ aBtnPerspective.SetPosPixel( aBtnPerspective.GetPosPixel() + aYPt );
+
+ // Show
+ aBtnUpdate.Show();
+ aBtnAssign.Show();
+
+ aBtnConvertTo3D.Show();
+ aBtnLatheObject.Show();
+ aBtnPerspective.Show();
+
+ if( aBtnGeo.IsChecked() )
+ ClickViewTypeHdl( &aBtnGeo );
+ if( aBtnRepresentation.IsChecked() )
+ ClickViewTypeHdl( &aBtnRepresentation );
+ if( aBtnLight.IsChecked() )
+ ClickViewTypeHdl( &aBtnLight );
+ if( aBtnTexture.IsChecked() )
+ ClickViewTypeHdl( &aBtnTexture );
+ if( aBtnMaterial.IsChecked() )
+ ClickViewTypeHdl( &aBtnMaterial );
+
+ aSize = aWinSize;
+ }
+ }
+
+ SfxDockingWindow::Resize();
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( Svx3DWin, ClickUpdateHdl, void *, EMPTYARG )
+{
+ bUpdate = !aBtnUpdate.IsChecked();
+ aBtnUpdate.Check( bUpdate );
+
+ if( bUpdate )
+ {
+ SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
+ if (pDispatcher != NULL)
+ {
+ SfxBoolItem aItem( SID_3D_STATE, TRUE );
+ pDispatcher->Execute(
+ SID_3D_STATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+ }
+ else
+ {
+ // Controls koennen u.U. disabled sein
+ }
+
+ return( 0L );
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( Svx3DWin, ClickAssignHdl, void *, EMPTYARG )
+{
+ SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
+ if (pDispatcher != NULL)
+ {
+ SfxBoolItem aItem( SID_3D_ASSIGN, TRUE );
+ pDispatcher->Execute(
+ SID_3D_ASSIGN, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+
+ return( 0L );
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( Svx3DWin, ClickViewTypeHdl, void *, pBtn )
+{
+
+ if( pBtn )
+ {
+ // Da das permanente Updaten der Preview zu teuer waere
+ BOOL bUpdatePreview = aBtnLight.IsChecked();
+
+ aBtnGeo.Check( &aBtnGeo == pBtn );
+ aBtnRepresentation.Check( &aBtnRepresentation == pBtn );
+ aBtnLight.Check( &aBtnLight == pBtn );
+ aBtnTexture.Check( &aBtnTexture == pBtn );
+ aBtnMaterial.Check( &aBtnMaterial == pBtn );
+
+ if( aBtnGeo.IsChecked() )
+ eViewType = VIEWTYPE_GEO;
+ if( aBtnRepresentation.IsChecked() )
+ eViewType = VIEWTYPE_REPRESENTATION;
+ if( aBtnLight.IsChecked() )
+ eViewType = VIEWTYPE_LIGHT;
+ if( aBtnTexture.IsChecked() )
+ eViewType = VIEWTYPE_TEXTURE;
+ if( aBtnMaterial.IsChecked() )
+ eViewType = VIEWTYPE_MATERIAL;
+
+ // Geometrie
+ if( eViewType == VIEWTYPE_GEO )
+ {
+ aFtHorizontal.Show();
+ aNumHorizontal.Show();
+ aFtVertical.Show();
+ aNumVertical.Show();
+ aFLSegments.Show();
+ aFtPercentDiagonal.Show();
+ aMtrPercentDiagonal.Show();
+ aFtBackscale.Show();
+ aMtrBackscale.Show();
+ aFtEndAngle.Show();
+ aMtrEndAngle.Show();
+ aFtDepth.Show();
+ aMtrDepth.Show();
+ aFLGeometrie.Show();
+
+ aBtnNormalsObj.Show();
+ aBtnNormalsFlat.Show();
+ aBtnNormalsSphere.Show();
+ aBtnTwoSidedLighting.Show();
+ aBtnNormalsInvert.Show();
+ aFLNormals.Show();
+ aBtnDoubleSided.Show();
+ }
+ else
+ {
+ aFtHorizontal.Hide();
+ aNumHorizontal.Hide();
+ aFtVertical.Hide();
+ aNumVertical.Hide();
+ aFLSegments.Hide();
+ aFtPercentDiagonal.Hide();
+ aMtrPercentDiagonal.Hide();
+ aFtBackscale.Hide();
+ aMtrBackscale.Hide();
+ aFtEndAngle.Hide();
+ aMtrEndAngle.Hide();
+ aFtDepth.Hide();
+ aMtrDepth.Hide();
+ aFLGeometrie.Hide();
+
+ aBtnNormalsObj.Hide();
+ aBtnNormalsFlat.Hide();
+ aBtnNormalsSphere.Hide();
+ aBtnTwoSidedLighting.Hide();
+ aBtnNormalsInvert.Hide();
+ aFLNormals.Hide();
+ aBtnDoubleSided.Hide();
+ }
+
+ // Darstellung
+ if( eViewType == VIEWTYPE_REPRESENTATION )
+ {
+ aFtShademode.Show();
+ aLbShademode.Show();
+ aBtnShadow3d.Show();
+ aFtSlant.Show();
+ aMtrSlant.Show();
+ aFLShadow.Show();
+ aFtDistance.Show();
+ aMtrDistance.Show();
+ aFtFocalLeng.Show();
+ aMtrFocalLength.Show();
+ aFLCamera.Show();
+ aFLRepresentation.Show();
+ }
+ else
+ {
+ aFtShademode.Hide();
+ aLbShademode.Hide();
+ aBtnShadow3d.Hide();
+ aFtSlant.Hide();
+ aMtrSlant.Hide();
+ aFLShadow.Hide();
+ aFtDistance.Hide();
+ aMtrDistance.Hide();
+ aFtFocalLeng.Hide();
+ aMtrFocalLength.Hide();
+ aFLCamera.Hide();
+ aFLRepresentation.Hide();
+ }
+
+ // Beleuchtung
+ if( eViewType == VIEWTYPE_LIGHT )
+ {
+ aBtnLight1.Show();
+ aBtnLight2.Show();
+ aBtnLight3.Show();
+ aBtnLight4.Show();
+ aBtnLight5.Show();
+ aBtnLight6.Show();
+ aBtnLight7.Show();
+ aBtnLight8.Show();
+ //aLbLight1.Show();
+ aBtnLightColor.Show();
+ aFTLightsource.Show();
+ aLbAmbientlight.Show();
+ aBtnAmbientColor.Show();
+ aFTAmbientlight.Show();
+ aFLLight.Show();
+ //aFtLightX.Show();
+ //aFtLightY.Show();
+ //aFtLightZ.Show();
+ //aGrpLightInfo.Show();
+
+ ColorLB* pLb = GetLbByButton();
+ if( pLb )
+ pLb->Show();
+
+ aCtlLightPreview.Show();
+ aCtlPreview.Hide();
+ }
+ else
+ {
+ aBtnLight1.Hide();
+ aBtnLight2.Hide();
+ aBtnLight3.Hide();
+ aBtnLight4.Hide();
+ aBtnLight5.Hide();
+ aBtnLight6.Hide();
+ aBtnLight7.Hide();
+ aBtnLight8.Hide();
+ aLbLight1.Hide();
+ aLbLight2.Hide();
+ aLbLight3.Hide();
+ aLbLight4.Hide();
+ aLbLight5.Hide();
+ aLbLight6.Hide();
+ aLbLight7.Hide();
+ aLbLight8.Hide();
+ aBtnLightColor.Hide();
+ aFTLightsource.Hide();
+ aLbAmbientlight.Hide();
+ aBtnAmbientColor.Hide();
+ aFTAmbientlight.Hide();
+ aFLLight.Hide();
+
+ if( !aCtlPreview.IsVisible() )
+ {
+ aCtlPreview.Show();
+ aCtlLightPreview.Hide();
+ }
+ }
+
+ // Textures
+ if( eViewType == VIEWTYPE_TEXTURE )
+ {
+ aFtTexKind.Show();
+ aBtnTexLuminance.Show();
+ aBtnTexColor.Show();
+ aFtTexMode.Show();
+ aBtnTexReplace.Show();
+ aBtnTexModulate.Show();
+ //aBtnTexBlend.Show();
+ aFtTexProjectionX.Show();
+ aBtnTexParallelX.Show();
+ aBtnTexCircleX.Show();
+ aBtnTexObjectX.Show();
+ aFtTexProjectionY.Show();
+ aBtnTexParallelY.Show();
+ aBtnTexCircleY.Show();
+ aBtnTexObjectY.Show();
+ aFtTexFilter.Show();
+ aBtnTexFilter.Show();
+ aFLTexture.Show();
+ }
+ else
+ {
+ aFtTexKind.Hide();
+ aBtnTexLuminance.Hide();
+ aBtnTexColor.Hide();
+ aFtTexMode.Hide();
+ aBtnTexReplace.Hide();
+ aBtnTexModulate.Hide();
+ aBtnTexBlend.Hide();
+ aFtTexProjectionX.Hide();
+ aBtnTexParallelX.Hide();
+ aBtnTexCircleX.Hide();
+ aBtnTexObjectX.Hide();
+ aFtTexProjectionY.Hide();
+ aBtnTexParallelY.Hide();
+ aBtnTexCircleY.Hide();
+ aBtnTexObjectY.Hide();
+ aFtTexFilter.Hide();
+ aBtnTexFilter.Hide();
+ aFLTexture.Hide();
+ }
+
+ // Material
+ if( eViewType == VIEWTYPE_MATERIAL )
+ {
+ aFtMatFavorites.Show();
+ aLbMatFavorites.Show();
+ aFtMatColor.Show();
+ aLbMatColor.Show();
+ aBtnMatColor.Show();
+ aFtMatEmission.Show();
+ aLbMatEmission.Show();
+ aBtnEmissionColor.Show();
+ aFtMatSpecular.Show();
+ aLbMatSpecular.Show();
+ aBtnSpecularColor.Show();
+ aFtMatSpecularIntensity.Show();
+ aMtrMatSpecularIntensity.Show();
+ aFLMatSpecular.Show();
+ aFLMaterial.Show();
+ }
+ else
+ {
+ aFtMatFavorites.Hide();
+ aLbMatFavorites.Hide();
+ aFtMatColor.Hide();
+ aLbMatColor.Hide();
+ aBtnMatColor.Hide();
+ aFtMatEmission.Hide();
+ aLbMatEmission.Hide();
+ aBtnEmissionColor.Hide();
+ aFtMatSpecular.Hide();
+ aLbMatSpecular.Hide();
+ aBtnSpecularColor.Hide();
+ aFtMatSpecularIntensity.Hide();
+ aMtrMatSpecularIntensity.Hide();
+ aFLMatSpecular.Hide();
+ aFLMaterial.Hide();
+ }
+ if( bUpdatePreview && !aBtnLight.IsChecked() )
+ UpdatePreview();
+
+ }
+ else
+ {
+ aBtnGeo.Check( eViewType == VIEWTYPE_GEO );
+ aBtnRepresentation.Check( eViewType == VIEWTYPE_REPRESENTATION );
+ aBtnLight.Check( eViewType == VIEWTYPE_LIGHT );
+ aBtnTexture.Check( eViewType == VIEWTYPE_TEXTURE );
+ aBtnMaterial.Check( eViewType == VIEWTYPE_MATERIAL );
+ }
+ return( 0L );
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( Svx3DWin, ClickHdl, PushButton *, pBtn )
+{
+ BOOL bUpdatePreview = FALSE;
+
+ if( pBtn )
+ {
+ USHORT nSId = 0;
+
+ if( pBtn == &aBtnConvertTo3D )
+ {
+ nSId = SID_CONVERT_TO_3D;
+ }
+ else if( pBtn == &aBtnLatheObject )
+ {
+ nSId = SID_CONVERT_TO_3D_LATHE_FAST;
+ }
+ // Geometrie
+ else if( pBtn == &aBtnNormalsObj ||
+ pBtn == &aBtnNormalsFlat ||
+ pBtn == &aBtnNormalsSphere )
+ {
+ aBtnNormalsObj.Check( pBtn == &aBtnNormalsObj );
+ aBtnNormalsFlat.Check( pBtn == &aBtnNormalsFlat );
+ aBtnNormalsSphere.Check( pBtn == &aBtnNormalsSphere );
+ bUpdatePreview = TRUE;
+ }
+ else if( pBtn == &aBtnLight1 ||
+ pBtn == &aBtnLight2 ||
+ pBtn == &aBtnLight3 ||
+ pBtn == &aBtnLight4 ||
+ pBtn == &aBtnLight5 ||
+ pBtn == &aBtnLight6 ||
+ pBtn == &aBtnLight7 ||
+ pBtn == &aBtnLight8 )
+ {
+ // Beleuchtung
+ ColorLB* pLb = GetLbByButton( pBtn );
+ pLb->Show();
+
+ if( pBtn->IsChecked() )
+ {
+ SetUILightState( *(ImageButton*)pBtn, !GetUILightState( *(ImageButton*)pBtn ) );
+ }
+ else
+ {
+ pBtn->Check();
+
+ if( pBtn != &aBtnLight1 && aBtnLight1.IsChecked() )
+ {
+ aBtnLight1.Check( FALSE );
+ aLbLight1.Hide();
+ }
+ if( pBtn != &aBtnLight2 && aBtnLight2.IsChecked() )
+ {
+ aBtnLight2.Check( FALSE );
+ aLbLight2.Hide();
+ }
+ if( pBtn != &aBtnLight3 && aBtnLight3.IsChecked() )
+ {
+ aBtnLight3.Check( FALSE );
+ aLbLight3.Hide();
+ }
+ if( pBtn != &aBtnLight4 && aBtnLight4.IsChecked() )
+ {
+ aBtnLight4.Check( FALSE );
+ aLbLight4.Hide();
+ }
+ if( pBtn != &aBtnLight5 && aBtnLight5.IsChecked() )
+ {
+ aBtnLight5.Check( FALSE );
+ aLbLight5.Hide();
+ }
+ if( pBtn != &aBtnLight6 && aBtnLight6.IsChecked() )
+ {
+ aBtnLight6.Check( FALSE );
+ aLbLight6.Hide();
+ }
+ if( pBtn != &aBtnLight7 && aBtnLight7.IsChecked() )
+ {
+ aBtnLight7.Check( FALSE );
+ aLbLight7.Hide();
+ }
+ if( pBtn != &aBtnLight8 && aBtnLight8.IsChecked() )
+ {
+ aBtnLight8.Check( FALSE );
+ aLbLight8.Hide();
+ }
+ }
+ BOOL bEnable = GetUILightState( *(ImageButton*)pBtn );
+ aBtnLightColor.Enable( bEnable );
+ pLb->Enable( bEnable );
+
+ ClickLightHdl( pBtn );
+ bUpdatePreview = TRUE;
+ }
+ // Textures
+ else if( pBtn == &aBtnTexLuminance ||
+ pBtn == &aBtnTexColor )
+ {
+ aBtnTexLuminance.Check( pBtn == &aBtnTexLuminance );
+ aBtnTexColor.Check( pBtn == &aBtnTexColor );
+ bUpdatePreview = TRUE;
+ }
+ else if( pBtn == &aBtnTexReplace ||
+ pBtn == &aBtnTexModulate )// ||
+ //pBtn == &aBtnTexBlend )
+ {
+ aBtnTexReplace.Check( pBtn == &aBtnTexReplace );
+ aBtnTexModulate.Check( pBtn == &aBtnTexModulate );
+ //aBtnTexBlend.Check( pBtn == &aBtnTexBlend );
+ bUpdatePreview = TRUE;
+ }
+ else if( pBtn == &aBtnTexParallelX ||
+ pBtn == &aBtnTexCircleX ||
+ pBtn == &aBtnTexObjectX )
+ {
+ aBtnTexParallelX.Check( pBtn == &aBtnTexParallelX );
+ aBtnTexCircleX.Check( pBtn == &aBtnTexCircleX );
+ aBtnTexObjectX.Check( pBtn == &aBtnTexObjectX );
+ bUpdatePreview = TRUE;
+ }
+ else if( pBtn == &aBtnTexParallelY ||
+ pBtn == &aBtnTexCircleY ||
+ pBtn == &aBtnTexObjectY )
+ {
+ aBtnTexParallelY.Check( pBtn == &aBtnTexParallelY );
+ aBtnTexCircleY.Check( pBtn == &aBtnTexCircleY );
+ aBtnTexObjectY.Check( pBtn == &aBtnTexObjectY );
+ bUpdatePreview = TRUE;
+ }
+ else if( pBtn == &aBtnShadow3d )
+ {
+ pBtn->Check( !pBtn->IsChecked() );
+ aFtSlant.Enable( pBtn->IsChecked() );
+ aMtrSlant.Enable( pBtn->IsChecked() );
+ bUpdatePreview = TRUE;
+ }
+ // Sonstige (keine Gruppen)
+ else if( pBtn != NULL )
+ {
+ pBtn->Check( !pBtn->IsChecked() );
+ bUpdatePreview = TRUE;
+ }
+
+ if( nSId > 0 )
+ {
+ SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
+ if (pDispatcher != NULL)
+ {
+ SfxBoolItem aItem( nSId, TRUE );
+ pDispatcher->Execute(
+ nSId, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+ }
+ else if( bUpdatePreview == TRUE )
+ UpdatePreview();
+ }
+ return( 0L );
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( Svx3DWin, ClickColorHdl, PushButton *, pBtn )
+{
+ SvColorDialog aColorDlg( this );
+ ColorLB* pLb;
+
+ if( pBtn == &aBtnLightColor )
+ pLb = GetLbByButton();
+ else if( pBtn == &aBtnAmbientColor )
+ pLb = &aLbAmbientlight;
+ else if( pBtn == &aBtnMatColor )
+ pLb = &aLbMatColor;
+ else if( pBtn == &aBtnEmissionColor )
+ pLb = &aLbMatEmission;
+ else // if( pBtn == &aBtnSpecularColor )
+ pLb = &aLbMatSpecular;
+
+ Color aColor = pLb->GetSelectEntryColor();
+
+ aColorDlg.SetColor( aColor );
+ if( aColorDlg.Execute() == RET_OK )
+ {
+ aColor = aColorDlg.GetColor();
+ if( LBSelectColor( pLb, aColor ) )
+ SelectHdl( pLb );
+ }
+ return( 0L );
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( Svx3DWin, SelectHdl, void *, p )
+{
+ if( p )
+ {
+ Color aColor;
+ BOOL bUpdatePreview = FALSE;
+
+ // Material
+ if( p == &aLbMatFavorites )
+ {
+ Color aColObj( COL_WHITE );
+ Color aColEmis( COL_BLACK );
+ Color aColSpec( COL_WHITE );
+ USHORT nSpecIntens = 20;
+
+ USHORT nPos = aLbMatFavorites.GetSelectEntryPos();
+ switch( nPos )
+ {
+ case 1: // Metall
+ {
+ aColObj = Color(230,230,255);
+ aColEmis = Color(10,10,30);
+ aColSpec = Color(200,200,200);
+ nSpecIntens = 20;
+ }
+ break;
+
+ case 2: // Gold
+ {
+ aColObj = Color(230,255,0);
+ aColEmis = Color(51,0,0);
+ aColSpec = Color(255,255,240);
+ nSpecIntens = 20;
+ }
+ break;
+
+ case 3: // Chrom
+ {
+ aColObj = Color(36,117,153);
+ aColEmis = Color(18,30,51);
+ aColSpec = Color(230,230,255);
+ nSpecIntens = 2;
+ }
+ break;
+
+ case 4: // Plastik
+ {
+ aColObj = Color(255,48,57);
+ aColEmis = Color(35,0,0);
+ aColSpec = Color(179,202,204);
+ nSpecIntens = 60;
+ }
+ break;
+
+ case 5: // Holz
+ {
+ aColObj = Color(153,71,1);
+ aColEmis = Color(21,22,0);
+ aColSpec = Color(255,255,153);
+ nSpecIntens = 75;
+ }
+ break;
+ }
+ LBSelectColor( &aLbMatColor, aColObj );
+ LBSelectColor( &aLbMatEmission, aColEmis );
+ LBSelectColor( &aLbMatSpecular, aColSpec );
+ aMtrMatSpecularIntensity.SetValue( nSpecIntens );
+
+ bUpdatePreview = TRUE;
+ }
+ else if( p == &aLbMatColor ||
+ p == &aLbMatEmission ||
+ p == &aLbMatSpecular )
+ {
+ aLbMatFavorites.SelectEntryPos( 0 );
+ bUpdatePreview = TRUE;
+ }
+ // Beleuchtung
+ else if( p == &aLbAmbientlight )
+ {
+ bUpdatePreview = TRUE;
+ }
+ else if( p == &aLbLight1 ||
+ p == &aLbLight2 ||
+ p == &aLbLight3 ||
+ p == &aLbLight4 ||
+ p == &aLbLight5 ||
+ p == &aLbLight6 ||
+ p == &aLbLight7 ||
+ p == &aLbLight8 )
+ {
+ bUpdatePreview = TRUE;
+ }
+ else if( p == &aLbShademode )
+ bUpdatePreview = TRUE;
+
+ if( bUpdatePreview == TRUE )
+ UpdatePreview();
+ }
+ return( 0L );
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( Svx3DWin, ModifyHdl, void*, pField )
+{
+ if( pField )
+ {
+ BOOL bUpdatePreview = FALSE;
+
+ // Material
+ if( pField == &aMtrMatSpecularIntensity )
+ {
+ bUpdatePreview = TRUE;
+ }
+ else if( pField == &aNumHorizontal )
+ {
+ bUpdatePreview = TRUE;
+ }
+ else if( pField == &aNumVertical )
+ {
+ bUpdatePreview = TRUE;
+ }
+ else if( pField == &aMtrSlant )
+ {
+ bUpdatePreview = TRUE;
+ }
+
+ if( bUpdatePreview == TRUE )
+ UpdatePreview();
+ }
+ return( 0L );
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( Svx3DWin, ClickLightHdl, PushButton*, pBtn )
+{
+
+ if( pBtn )
+ {
+ USHORT nLightSource = GetLightSource( pBtn );
+ ColorLB* pLb = GetLbByButton( pBtn );
+ Color aColor( pLb->GetSelectEntryColor() );
+ SfxItemSet aLightItemSet(aCtlLightPreview.GetSvx3DLightControl().Get3DAttributes());
+ const bool bOnOff(GetUILightState( *(ImageButton*)pBtn ));
+
+ switch(nLightSource)
+ {
+ case 0: aLightItemSet.Put(Svx3DLightcolor1Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff1Item(bOnOff)); break;
+ case 1: aLightItemSet.Put(Svx3DLightcolor2Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff2Item(bOnOff)); break;
+ case 2: aLightItemSet.Put(Svx3DLightcolor3Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff3Item(bOnOff)); break;
+ case 3: aLightItemSet.Put(Svx3DLightcolor4Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff4Item(bOnOff)); break;
+ case 4: aLightItemSet.Put(Svx3DLightcolor5Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff5Item(bOnOff)); break;
+ case 5: aLightItemSet.Put(Svx3DLightcolor6Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff6Item(bOnOff)); break;
+ case 6: aLightItemSet.Put(Svx3DLightcolor7Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff7Item(bOnOff)); break;
+ default:
+ case 7: aLightItemSet.Put(Svx3DLightcolor8Item(aColor)); aLightItemSet.Put(Svx3DLightOnOff8Item(bOnOff)); break;
+ }
+
+ aCtlLightPreview.GetSvx3DLightControl().Set3DAttributes(aLightItemSet);
+ aCtlLightPreview.GetSvx3DLightControl().SelectLight(nLightSource);
+ aCtlLightPreview.CheckSelection();
+ }
+ return( 0L );
+}
+
+
+// -----------------------------------------------------------------------
+IMPL_LINK( Svx3DWin, DoubleClickHdl, void*, EMPTYARG )
+{
+ //USHORT nItemId = aCtlFavorites.GetSelectItemId();
+
+ //SfxItemSet* pSet = (SfxItemSet*) pFavorSetList->GetObject( nItemId - 1 );
+ //Update( *pSet );
+
+ // und zuweisen
+ ClickAssignHdl( NULL );
+
+ return( 0L );
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( Svx3DWin, ChangeLightCallbackHdl, void*, EMPTYARG )
+{
+ return( 0L );
+}
+
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( Svx3DWin, ChangeSelectionCallbackHdl, void*, EMPTYARG )
+{
+ const sal_uInt32 nLight(aCtlLightPreview.GetSvx3DLightControl().GetSelectedLight());
+ PushButton* pBtn = 0;
+
+ switch( nLight )
+ {
+ case 0: pBtn = &aBtnLight1; break;
+ case 1: pBtn = &aBtnLight2; break;
+ case 2: pBtn = &aBtnLight3; break;
+ case 3: pBtn = &aBtnLight4; break;
+ case 4: pBtn = &aBtnLight5; break;
+ case 5: pBtn = &aBtnLight6; break;
+ case 6: pBtn = &aBtnLight7; break;
+ case 7: pBtn = &aBtnLight8; break;
+ default: break;
+ }
+
+ if( pBtn )
+ ClickHdl( pBtn );
+ else
+ {
+ // Zustand: Keine Lampe selektiert
+ if( aBtnLight1.IsChecked() )
+ {
+ aBtnLight1.Check( FALSE );
+ aLbLight1.Enable( FALSE );
+ }
+ else if( aBtnLight2.IsChecked() )
+ {
+ aBtnLight2.Check( FALSE );
+ aLbLight2.Enable( FALSE );
+ }
+ else if( aBtnLight3.IsChecked() )
+ {
+ aBtnLight3.Check( FALSE );
+ aLbLight3.Enable( FALSE );
+ }
+ else if( aBtnLight4.IsChecked() )
+ {
+ aBtnLight4.Check( FALSE );
+ aLbLight4.Enable( FALSE );
+ }
+ else if( aBtnLight5.IsChecked() )
+ {
+ aBtnLight5.Check( FALSE );
+ aLbLight5.Enable( FALSE );
+ }
+ else if( aBtnLight6.IsChecked() )
+ {
+ aBtnLight6.Check( FALSE );
+ aLbLight6.Enable( FALSE );
+ }
+ else if( aBtnLight7.IsChecked() )
+ {
+ aBtnLight7.Check( FALSE );
+ aLbLight7.Enable( FALSE );
+ }
+ else if( aBtnLight8.IsChecked() )
+ {
+ aBtnLight8.Check( FALSE );
+ aLbLight8.Enable( FALSE );
+ }
+ aBtnLightColor.Enable( FALSE );
+ }
+
+ return( 0L );
+}
+
+// -----------------------------------------------------------------------
+// Methode um sicherzustellen, dass die LB auch mit einer Farbe gesetzt ist
+// Liefert TRUE zurueck, falls Farbe hinzugefuegt wurde
+// -----------------------------------------------------------------------
+BOOL Svx3DWin::LBSelectColor( ColorLB* pLb, const Color& rColor )
+{
+ BOOL bRet = FALSE;
+
+ pLb->SetNoSelection();
+ pLb->SelectEntry( rColor );
+ if( pLb->GetSelectEntryCount() == 0 )
+ {
+ String aStr(SVX_RES(RID_SVXFLOAT3D_FIX_R));
+
+ aStr += String::CreateFromInt32((INT32)rColor.GetRed());
+ aStr += sal_Unicode(' ');
+ aStr += String(SVX_RES(RID_SVXFLOAT3D_FIX_G));
+ aStr += String::CreateFromInt32((INT32)rColor.GetGreen());
+ aStr += sal_Unicode(' ');
+ aStr += String(SVX_RES(RID_SVXFLOAT3D_FIX_B));
+ aStr += String::CreateFromInt32((INT32)rColor.GetBlue());
+
+ USHORT nPos = pLb->InsertEntry( rColor, aStr );
+ pLb->SelectEntryPos( nPos );
+ bRet = TRUE;
+ }
+ return( bRet );
+}
+
+// -----------------------------------------------------------------------
+void Svx3DWin::UpdatePreview()
+{
+ if( pModel == NULL )
+ pModel = new FmFormModel();
+
+ if(bOnly3DChanged)
+ {
+ // slot executen
+ SfxDispatcher* pDispatcher = LocalGetDispatcher(pBindings);
+ if (pDispatcher != NULL)
+ {
+ SfxBoolItem aItem( SID_3D_STATE, TRUE );
+ pDispatcher->Execute(
+ SID_3D_STATE, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+ // Flag zuruecksetzen
+ bOnly3DChanged = FALSE;
+ }
+
+ // ItemSet besorgen
+ SfxItemSet aSet( pModel->GetItemPool(), SDRATTR_START, SDRATTR_END);
+
+ // Attribute holen und im Preview setzen
+ GetAttr( aSet );
+ aCtlPreview.Set3DAttributes( aSet );
+ aCtlLightPreview.GetSvx3DLightControl().Set3DAttributes( aSet );
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// document is to be reloaded, destroy remembered ItemSet (#83951#)
+void Svx3DWin::DocumentReload()
+{
+ if(mpRemember2DAttributes)
+ delete mpRemember2DAttributes;
+ mpRemember2DAttributes = 0L;
+}
+
+// -----------------------------------------------------------------------
+void Svx3DWin::InitColorLB( const SdrModel* pDoc )
+{
+ aLbLight1.Fill( pDoc->GetColorTable() );
+ aLbLight2.CopyEntries( aLbLight1 );
+ aLbLight3.CopyEntries( aLbLight1 );
+ aLbLight4.CopyEntries( aLbLight1 );
+ aLbLight5.CopyEntries( aLbLight1 );
+ aLbLight6.CopyEntries( aLbLight1 );
+ aLbLight7.CopyEntries( aLbLight1 );
+ aLbLight8.CopyEntries( aLbLight1 );
+ aLbAmbientlight.CopyEntries( aLbLight1 );
+ aLbMatColor.CopyEntries( aLbLight1 );
+ aLbMatEmission.CopyEntries( aLbLight1 );
+ aLbMatSpecular.CopyEntries( aLbLight1 );
+
+ // Erstmal...
+ Color aColWhite( COL_WHITE );
+ Color aColBlack( COL_BLACK );
+ aLbLight1.SelectEntry( aColWhite );
+ aLbLight2.SelectEntry( aColWhite );
+ aLbLight3.SelectEntry( aColWhite );
+ aLbLight4.SelectEntry( aColWhite );
+ aLbLight5.SelectEntry( aColWhite );
+ aLbLight6.SelectEntry( aColWhite );
+ aLbLight7.SelectEntry( aColWhite );
+ aLbLight8.SelectEntry( aColWhite );
+ aLbAmbientlight.SelectEntry( aColBlack );
+ aLbMatColor.SelectEntry( aColWhite );
+ aLbMatEmission.SelectEntry( aColBlack );
+ aLbMatSpecular.SelectEntry( aColWhite );
+}
+
+// -----------------------------------------------------------------------
+USHORT Svx3DWin::GetLightSource( const PushButton* pBtn )
+{
+ USHORT nLight = 8;
+
+ if( pBtn == NULL )
+ {
+ if( aBtnLight1.IsChecked() )
+ nLight = 0;
+ else if( aBtnLight2.IsChecked() )
+ nLight = 1;
+ else if( aBtnLight3.IsChecked() )
+ nLight = 2;
+ else if( aBtnLight4.IsChecked() )
+ nLight = 3;
+ else if( aBtnLight5.IsChecked() )
+ nLight = 4;
+ else if( aBtnLight6.IsChecked() )
+ nLight = 5;
+ else if( aBtnLight7.IsChecked() )
+ nLight = 6;
+ else if( aBtnLight8.IsChecked() )
+ nLight = 7;
+ }
+ else
+ {
+ if( pBtn == &aBtnLight1 )
+ nLight = 0;
+ else if( pBtn == &aBtnLight2 )
+ nLight = 1;
+ else if( pBtn == &aBtnLight3 )
+ nLight = 2;
+ else if( pBtn == &aBtnLight4 )
+ nLight = 3;
+ else if( pBtn == &aBtnLight5 )
+ nLight = 4;
+ else if( pBtn == &aBtnLight6 )
+ nLight = 5;
+ else if( pBtn == &aBtnLight7 )
+ nLight = 6;
+ else if( pBtn == &aBtnLight8 )
+ nLight = 7;
+ }
+ return( nLight );
+};
+
+// -----------------------------------------------------------------------
+ColorLB* Svx3DWin::GetLbByButton( const PushButton* pBtn )
+{
+ ColorLB* pLb = NULL;
+
+ if( pBtn == NULL )
+ {
+ if( aBtnLight1.IsChecked() )
+ pLb = &aLbLight1;
+ else if( aBtnLight2.IsChecked() )
+ pLb = &aLbLight2;
+ else if( aBtnLight3.IsChecked() )
+ pLb = &aLbLight3;
+ else if( aBtnLight4.IsChecked() )
+ pLb = &aLbLight4;
+ else if( aBtnLight5.IsChecked() )
+ pLb = &aLbLight5;
+ else if( aBtnLight6.IsChecked() )
+ pLb = &aLbLight6;
+ else if( aBtnLight7.IsChecked() )
+ pLb = &aLbLight7;
+ else if( aBtnLight8.IsChecked() )
+ pLb = &aLbLight8;
+ }
+ else
+ {
+ if( pBtn == &aBtnLight1 )
+ pLb = &aLbLight1;
+ else if( pBtn == &aBtnLight2 )
+ pLb = &aLbLight2;
+ else if( pBtn == &aBtnLight3 )
+ pLb = &aLbLight3;
+ else if( pBtn == &aBtnLight4 )
+ pLb = &aLbLight4;
+ else if( pBtn == &aBtnLight5 )
+ pLb = &aLbLight5;
+ else if( pBtn == &aBtnLight6 )
+ pLb = &aLbLight6;
+ else if( pBtn == &aBtnLight7 )
+ pLb = &aLbLight7;
+ else if( pBtn == &aBtnLight8 )
+ pLb = &aLbLight8;
+ }
+ return( pLb );
+};
+
+/*************************************************************************
+|*
+|* Ableitung vom SfxChildWindow als "Behaelter" fuer Effekte
+|*
+\************************************************************************/
+__EXPORT Svx3DChildWindow::Svx3DChildWindow( Window* _pParent,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( _pParent, nId )
+{
+ Svx3DWin* pWin = new Svx3DWin( pBindings, this, _pParent );
+ pWindow = pWin;
+
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+
+ pWin->Initialize( pInfo );
+}
+
+/*************************************************************************
+|*
+|* ControllerItem fuer 3DStatus
+|*
+\************************************************************************/
+Svx3DCtrlItem::Svx3DCtrlItem( USHORT _nId,
+ Svx3DWin* pWin,
+ SfxBindings* _pBindings) :
+ SfxControllerItem( _nId, *_pBindings ),
+ p3DWin( pWin )
+{
+}
+
+// -----------------------------------------------------------------------
+void __EXPORT Svx3DCtrlItem::StateChanged( USHORT /*nSId*/,
+ SfxItemState /*eState*/, const SfxPoolItem* /*pItem*/ )
+{
+}
+
+/*************************************************************************
+|*
+|* ControllerItem fuer Status Slot SID_CONVERT_TO_3D
+|*
+\************************************************************************/
+
+SvxConvertTo3DItem::SvxConvertTo3DItem(UINT16 _nId, SfxBindings* _pBindings)
+: SfxControllerItem(_nId, *_pBindings),
+ bState(FALSE)
+{
+}
+
+void SvxConvertTo3DItem::StateChanged(UINT16 /*_nId*/, SfxItemState eState, const SfxPoolItem* /*pState*/)
+{
+ BOOL bNewState = (eState != SFX_ITEM_DISABLED);
+ if(bNewState != bState)
+ {
+ bState = bNewState;
+ SfxDispatcher* pDispatcher = LocalGetDispatcher(&GetBindings());
+ if (pDispatcher != NULL)
+ {
+ SfxBoolItem aItem( SID_3D_STATE, TRUE );
+ pDispatcher->Execute(
+ SID_3D_STATE, SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD, &aItem, 0L);
+ }
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/float3d.src b/svx/source/engine3d/float3d.src
new file mode 100644
index 000000000000..1f77b7f81936
--- /dev/null
+++ b/svx/source/engine3d/float3d.src
@@ -0,0 +1,1420 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+#include "float3d.hrc"
+#define WIDTH 158
+#define HEIGHT 209
+#define BORDER 3
+#define BUTTON_WIDTH 13
+#define BUTTON_HEIGHT 13
+#define VT_BUTTON_WIDTH 18
+#define GROUP_Y (BORDER + BUTTON_HEIGHT + 3)
+#define GROUP_HEIGHT 95
+#define GROUP_WIDTH (WIDTH - 2 * BORDER)
+#define GROUP_PREV_X 60
+#define GROUP_PREV_Y (GROUP_Y + GROUP_HEIGHT + 1)
+#define GROUP_PREV_WIDTH (WIDTH - BORDER - GROUP_PREV_X)
+#define GROUP_PREV_HEIGHT (HEIGHT - GROUP_PREV_Y - BORDER)
+#define IMG_BUTTON_HEIGHT 15
+#define IMG_BUTTON_NEXT (IMG_BUTTON_HEIGHT + 2)
+#define IMG_BUTTON_SIZE MAP_APPFONT( BUTTON_WIDTH, IMG_BUTTON_HEIGHT )
+#define FIXED_LINE_HEIGHT 8
+#define FIXED_LINE_SIZE MAP_APPFONT( GROUP_WIDTH, FIXED_LINE_HEIGHT )
+#define TOP_FIXED_LINE_POS MAP_APPFONT( BORDER, 2+BORDER + IMG_BUTTON_HEIGHT )
+#define FT_WIDTH_SHORT 56
+#define FT_WIDTH_LONG 89
+#define FT_HEIGHT 8
+#define FT_OFFSET_NEXT (FT_HEIGHT + 6)
+#define FT_INDENT (BORDER + 6)
+#define FIRST_FT_START_Y (2+BORDER+IMG_BUTTON_HEIGHT + 13)
+#define SEGMENTS_START_Y (FIRST_FT_START_Y + 3*FT_OFFSET_NEXT + 13)
+#define NORMALS_START_Y (SEGMENTS_START_Y + 2*13)
+#define NORMALS_BT_START_Y (SEGMENTS_START_Y + 2*13 +11)
+#define SHADOW_START_Y (FIRST_FT_START_Y + 13)
+#define CAMERA_START_Y (SHADOW_START_Y + FT_OFFSET_NEXT + 13)
+#define SPECULAR_START_Y (FIRST_FT_START_Y + 2*FT_OFFSET_NEXT + 13)
+
+#define MASKCOLOR MaskColor = Color { Red=0xFFFF; Green=0x0000; Blue=0xFFFF; };
+
+
+DockingWindow RID_SVXFLOAT_3D
+{
+ HelpID = SID_3D_WIN ;
+ Border = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Sizeable = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ Dockable = TRUE ;
+ EnableResizing = TRUE ;
+ Size = MAP_APPFONT ( WIDTH , HEIGHT ) ;
+ Text [ en-US ] = "3D Effects" ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+
+ ImageButton BTN_GEO
+ {
+ Pos = MAP_APPFONT ( 4 , BORDER ) ;
+ Size = MAP_APPFONT ( VT_BUTTON_WIDTH , IMG_BUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "3dgeo.bmp" ; };
+ MASKCOLOR
+ };
+ QuickHelpText [ en-US ] = "Geometry" ;
+ };
+ ImageButton BTN_REPRESENTATION
+ {
+ Pos = MAP_APPFONT ( 22 , BORDER ) ;
+ Size = MAP_APPFONT ( VT_BUTTON_WIDTH , IMG_BUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "3drepres.bmp" ; };
+ MASKCOLOR
+ };
+ QuickHelpText [ en-US ] = "Shading" ;
+ };
+ ImageButton BTN_LIGHT
+ {
+ Pos = MAP_APPFONT ( 40 , BORDER ) ;
+ Size = MAP_APPFONT ( VT_BUTTON_WIDTH , IMG_BUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "3dlight.bmp" ; };
+ MASKCOLOR
+ };
+ QuickHelpText [ en-US ] = "Illumination" ;
+ };
+ ImageButton BTN_TEXTURE
+ {
+ Pos = MAP_APPFONT ( 58 , BORDER ) ;
+ Size = MAP_APPFONT ( VT_BUTTON_WIDTH , IMG_BUTTON_HEIGHT ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "3dtextur.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Textures" ;
+ };
+ ImageButton BTN_MATERIAL
+ {
+ Pos = MAP_APPFONT ( 76 , BORDER ) ;
+ Size = MAP_APPFONT ( VT_BUTTON_WIDTH , IMG_BUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "material.bmp" ; };
+ MASKCOLOR
+ };
+ QuickHelpText [ en-US ] = "Material" ;
+ };
+
+ ImageButton BTN_UPDATE
+ {
+ Pos = MAP_APPFONT ( WIDTH - BORDER - BUTTON_WIDTH * 2 , BORDER ) ;
+ Size = IMG_BUTTON_SIZE;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "sc10350.bmp" ; };
+ MASKCOLOR
+ };
+ QuickHelpText [ en-US ] = "Update" ;
+ };
+ ImageButton BTN_ASSIGN
+ {
+ Pos = MAP_APPFONT ( WIDTH - BORDER - BUTTON_WIDTH , BORDER ) ;
+ Size = IMG_BUTTON_SIZE;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "apply.bmp" ; };
+ MASKCOLOR
+ };
+ QuickHelpText [ en-US ] = "Assign" ;
+ };
+ // Unterer Teil
+ ImageButton BTN_CHANGE_TO_3D
+ {
+ Pos = MAP_APPFONT ( 9 , 200 - BUTTON_HEIGHT ) ;
+ Size = IMG_BUTTON_SIZE;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "convrt3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Convert to 3D" ;
+ };
+ ImageButton BTN_LATHE_OBJ
+ {
+ Pos = MAP_APPFONT ( 9 + BUTTON_WIDTH + 1 , 200 - BUTTON_HEIGHT ) ;
+ Size = IMG_BUTTON_SIZE;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "rotate3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Convert to Lathe Object" ;
+ };
+ ImageButton BTN_PERSPECTIVE
+ {
+ Pos = MAP_APPFONT ( 9 + ( BUTTON_WIDTH + 1 ) * 2 , 200 - BUTTON_HEIGHT ) ;
+ Size = IMG_BUTTON_SIZE;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "persp3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Perspective On/Off" ;
+ };
+ Control CTL_PREVIEW
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , 124 ) ;
+ Size = MAP_APPFONT ( 83 , 76 ) ;
+ TabStop = TRUE ;
+ };
+ Control CTL_LIGHT_PREVIEW
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , 124 ) ;
+ Size = MAP_APPFONT ( 83 , 76 ) ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_GEOMETRIE
+ {
+ Pos = TOP_FIXED_LINE_POS;
+ Size = FIXED_LINE_SIZE;
+ Text [ en-US ] = "Geometry" ;
+ };
+ FixedText FT_PERCENT_DIAGONAL
+ {
+ Pos = MAP_APPFONT ( FT_INDENT, FIRST_FT_START_Y );
+ Size = MAP_APPFONT ( FT_WIDTH_LONG , FT_HEIGHT ) ;
+ Text [ en-US ] = "R~ounded edges" ;
+ };
+ MetricField MTR_PERCENT_DIAGONAL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_LONG + 1 , FIRST_FT_START_Y - 2 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ SpinSize = 5 ;
+ Maximum = 100 ;
+ Last = 100 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = "%" ;
+ };
+ FixedText FT_BACKSCALE
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + FT_OFFSET_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_LONG , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Scaled depth" ;
+ };
+ MetricField MTR_BACKSCALE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_LONG + 1,
+ FIRST_FT_START_Y + FT_OFFSET_NEXT - 2 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ SpinSize = 5 ;
+ Maximum = 10000 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = "%" ;
+ Last = 10000 ;
+ };
+ FixedText FT_END_ANGLE
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + 2*FT_OFFSET_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_LONG , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Rotation angle" ;
+ };
+ MetricField MTR_END_ANGLE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_LONG + 1,
+ FIRST_FT_START_Y + 2*FT_OFFSET_NEXT - 2 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ SpinSize = 5 ;
+ Unit = FUNIT_CUSTOM ;
+ Maximum = 36000 ;
+ Last = 36000 ;
+ DecimalDigits = 1 ;
+ CustomUnitText [ en-US ] = " degree(s)";
+ };
+ FixedText FT_DEPTH
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + 3*FT_OFFSET_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_LONG , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Depth" ;
+ };
+ MetricField MTR_DEPTH
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_LONG + 1,
+ FIRST_FT_START_Y + 3*FT_OFFSET_NEXT - 2 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Unit = FUNIT_MM ;
+ StrictFormat = TRUE ;
+ Minimum = 0 ;
+ First = 0 ;
+ Maximum = 10000000 ;
+ Last = 10000000 ;
+ DecimalDigits = 2 ;
+ SpinSize = 100 ;
+ };
+ FixedLine FL_SEGMENTS
+ {
+ Pos = MAP_APPFONT ( BORDER , SEGMENTS_START_Y ) ;
+ Size = FIXED_LINE_SIZE;
+ Text [ en-US ] = "Segments" ;
+ };
+ // Geometrie
+ FixedText FT_HORIZONTAL
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , SEGMENTS_START_Y+13 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "~Horizontal" ;
+ };
+ NumericField NUM_HORIZONTAL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + 42, SEGMENTS_START_Y+13-2 ) ;
+ Size = MAP_APPFONT ( 22 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 2 ;
+ First = 2 ;
+ Maximum = 256 ;
+ Last = 256 ;
+ };
+ FixedText FT_VERTICAL
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + 74 , SEGMENTS_START_Y+13 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "~Vertical" ;
+ };
+ NumericField NUM_VERTICAL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + 114+2 , SEGMENTS_START_Y+13-2 ) ;
+ Size = MAP_APPFONT ( 22 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 2 ;
+ First = 2 ;
+ Maximum = 256 ;
+ Last = 256 ;
+ };
+
+ FixedLine FL_NORMALS
+ {
+ Pos = MAP_APPFONT ( BORDER , NORMALS_START_Y ) ;
+ Size = MAP_APPFONT ( 54 , 8 ) ;
+ Text [ en-US ] = "Normals" ;
+ };
+ ImageButton BTN_NORMALS_OBJ
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , NORMALS_BT_START_Y ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "normobjs.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Object-Specific" ;
+ };
+ ImageButton BTN_NORMALS_FLAT
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + (1+BUTTON_WIDTH) , NORMALS_BT_START_Y ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "normflat.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Flat" ;
+ };
+ ImageButton BTN_NORMALS_SPHERE
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + (1+BUTTON_WIDTH) * 2 , NORMALS_BT_START_Y ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "normsphe.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Spherical" ;
+ };
+ ImageButton BTN_NORMALS_INVERT
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , NORMALS_BT_START_Y + IMG_BUTTON_NEXT ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "invert3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Invert Normals" ;
+ };
+ ImageButton BTN_TWO_SIDED_LIGHTING
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + (1+BUTTON_WIDTH) * 2 ,
+ NORMALS_BT_START_Y + IMG_BUTTON_NEXT ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "lght2sid.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Double-Sided Illumination" ;
+ };
+ ImageButton BTN_DOUBLE_SIDED
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , NORMALS_BT_START_Y + 2*IMG_BUTTON_NEXT ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "doublesi.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Double-Sided" ;
+ };
+
+ // Darstellung
+ FixedText FT_SHADEMODE
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Mode" ;
+ };
+ ListBox LB_SHADEMODE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , 30 ) ;
+ Size = MAP_APPFONT ( 83 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Flat" ; > ;
+ < "Phong" ; > ;
+ < "Gouraud" ; > ;
+ };
+ };
+ FixedLine FL_SHADOW
+ {
+ Pos = MAP_APPFONT ( BORDER , SHADOW_START_Y ) ;
+ Size = FIXED_LINE_SIZE;
+ Text [ en-US ] = "Shadow" ;
+ };
+ ImageButton BTN_SHADOW_3D
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , SHADOW_START_Y + 11 ) ;
+ Size = IMG_BUTTON_SIZE;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "shadow3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "3D Shadowing On/Off" ;
+ };
+ FixedText FT_SLANT
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + BUTTON_WIDTH + 3 , SHADOW_START_Y + 11 + 2 ) ;
+ Size = MAP_APPFONT ( 68 , FT_HEIGHT ) ;
+ Right = TRUE;
+ Text [ en-US ] = "S~urface angle" ;
+ };
+ MetricField MTR_SLANT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 99 , SHADOW_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ SpinSize = 5 ;
+ Maximum = 90 ;
+ Unit = FUNIT_CUSTOM ;
+ Last = 90 ;
+ CustomUnitText [ en-US ] = " degree(s)";
+ };
+
+ FixedLine FL_CAMERA
+ {
+ Pos = MAP_APPFONT ( BORDER , CAMERA_START_Y ) ;
+ Size = FIXED_LINE_SIZE;
+ Text [ en-US ] = "Camera" ;
+ };
+ FixedText FT_DISTANCE
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , CAMERA_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_LONG , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Distance" ;
+ };
+ MetricField MTR_DISTANCE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_LONG + 1 ,
+ CAMERA_START_Y + 11 - 2 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ StrictFormat = TRUE ;
+ Unit = FUNIT_MM ;
+ Minimum = 1 ;
+ First = 1 ;
+ Maximum = 1000000 ;
+ Last = 1000000 ;
+ DecimalDigits = 2 ;
+ SpinSize = 100 ;
+ };
+ FixedText FT_FOCAL_LENGTH
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , CAMERA_START_Y + 11 + FT_OFFSET_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_LONG , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Focal length" ;
+ };
+ MetricField MTR_FOCAL_LENGTH
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_LONG + 1 ,
+ CAMERA_START_Y + 11 + FT_OFFSET_NEXT - 2 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ StrictFormat = TRUE ;
+ Unit = FUNIT_MM ;
+ Minimum = 1 ;
+ First = 1 ;
+ Maximum = 1000000 ;
+ Last = 1000000 ;
+ DecimalDigits = 2 ;
+ SpinSize = 100 ;
+ };
+ FixedLine FL_REPRESENTATION
+ {
+ Pos = TOP_FIXED_LINE_POS;
+ Size = FIXED_LINE_SIZE;
+ Text [ en-US ] = "Shading" ;
+ };
+ // Beleuchtung
+ FixedText FT_LIGHTSOURCE
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_LONG , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Light source" ;
+ };
+ ImageButton BTN_LIGHT_1
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 12 , 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "light.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Light Source 1" ;
+ };
+ ImageButton BTN_LIGHT_2
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + 13 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 12 , 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "light.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Light Source 2" ;
+ };
+ ImageButton BTN_LIGHT_3
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + 2*13 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 12 , 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "light.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Light Source 3" ;
+ };
+ ImageButton BTN_LIGHT_4
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + 3*13 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 12 , 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "light.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Light Source 4" ;
+ };
+ ImageButton BTN_LIGHT_5
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + 26 ) ;
+ Size = MAP_APPFONT ( 12 , 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "light.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Light Source 5" ;
+ };
+ ImageButton BTN_LIGHT_6
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + 13, FIRST_FT_START_Y + 26 ) ;
+ Size = MAP_APPFONT ( 12 , 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "light.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Light Source 6" ;
+ };
+ ImageButton BTN_LIGHT_7
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + 2*13, FIRST_FT_START_Y + 26 ) ;
+ Size = MAP_APPFONT ( 12 , 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "light.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Light Source 7" ;
+ };
+ ImageButton BTN_LIGHT_8
+ {
+ Pos = MAP_APPFONT ( FT_INDENT +3*13 , FIRST_FT_START_Y + 26 ) ;
+ Size = MAP_APPFONT ( 12 , 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "light.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Light Source 8" ;
+ };
+ ListBox LB_LIGHT_1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_LIGHT_2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_LIGHT_3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_LIGHT_4
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_LIGHT_5
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_LIGHT_6
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_LIGHT_7
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_LIGHT_8
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ImageButton BTN_LIGHT_COLOR
+ {
+ Pos = MAP_APPFONT ( 137 , FIRST_FT_START_Y + 11 ) ;
+ Size = MAP_APPFONT ( 12 , 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "colordlg.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Colors Dialog" ;
+ };
+ FixedText FT_AMBIENTLIGHT
+ {
+ Pos = MAP_APPFONT ( FT_INDENT, FIRST_FT_START_Y + 53 ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Ambient light" ;
+ };
+ ListBox LB_AMBIENTLIGHT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 , FIRST_FT_START_Y + 53 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ImageButton BTN_AMBIENT_COLOR
+ {
+ Pos = MAP_APPFONT ( 137 , FIRST_FT_START_Y + 53 ) ;
+ Size = MAP_APPFONT ( 12 , 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "colordlg.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Colors Dialog" ;
+ };
+
+ FixedLine FL_LIGHT
+ {
+ Pos = TOP_FIXED_LINE_POS;
+ Size = FIXED_LINE_SIZE ;
+ Text [ en-US ] = "Illumination" ;
+ };
+ // Texturen
+ FixedText FT_TEX_KIND
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Type" ;
+ };
+ ImageButton BTN_TEX_LUMINANCE
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1,
+ FIRST_FT_START_Y - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "luminanc.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Black & White" ;
+ };
+ ImageButton BTN_TEX_COLOR
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 + BUTTON_WIDTH,
+ FIRST_FT_START_Y - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "color.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Color" ;
+ };
+ FixedText FT_TEX_MODE
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + IMG_BUTTON_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Mode" ;
+ };
+ ImageButton BTN_TEX_REPLACE
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1,
+ FIRST_FT_START_Y + IMG_BUTTON_NEXT - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "replac3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Only Texture" ;
+ };
+ ImageButton BTN_TEX_MODULATE
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 + BUTTON_WIDTH,
+ FIRST_FT_START_Y + IMG_BUTTON_NEXT - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "modula3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Texture and Shading" ;
+ };
+ ImageButton BTN_TEX_BLEND
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 + 2*BUTTON_WIDTH,
+ FIRST_FT_START_Y + IMG_BUTTON_NEXT - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "blend3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Texture, Shadow and Color" ;
+ };
+ FixedText FT_TEX_PROJECTION_X
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + 2*IMG_BUTTON_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Projection X" ;
+ };
+ ImageButton BTN_TEX_OBJECT_X
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1,
+ FIRST_FT_START_Y + 2*IMG_BUTTON_NEXT - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "objspc3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Object-Specific" ;
+ };
+ ImageButton BTN_TEX_PARALLEL_X
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 + BUTTON_WIDTH,
+ FIRST_FT_START_Y + 2*IMG_BUTTON_NEXT - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "parallel.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Parallel" ;
+ };
+ ImageButton BTN_TEX_CIRCLE_X
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 + 2*BUTTON_WIDTH,
+ FIRST_FT_START_Y + 2*IMG_BUTTON_NEXT - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "sphere3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Circular" ;
+ };
+ FixedText FT_TEX_PROJECTION_Y
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + 3*IMG_BUTTON_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "P~rojection Y" ;
+ };
+ ImageButton BTN_TEX_OBJECT_Y
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1,
+ FIRST_FT_START_Y + 3*IMG_BUTTON_NEXT - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "objspc3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Object-Specific" ;
+ };
+ ImageButton BTN_TEX_PARALLEL_Y
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 + BUTTON_WIDTH,
+ FIRST_FT_START_Y + 3*IMG_BUTTON_NEXT - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "parallel.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Parallel" ;
+ };
+ ImageButton BTN_TEX_CIRCLE_Y
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 + 2*BUTTON_WIDTH,
+ FIRST_FT_START_Y + 3*IMG_BUTTON_NEXT - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "sphere3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Circular" ;
+ };
+ FixedText FT_TEX_FILTER
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + 4*IMG_BUTTON_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Filtering" ;
+ };
+ ImageButton BTN_TEX_FILTER
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1,
+ FIRST_FT_START_Y + 4*IMG_BUTTON_NEXT - 2 ) ;
+ Size = IMG_BUTTON_SIZE;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "filter3d.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Filtering On/Off" ;
+ };
+ FixedLine FL_TEXTURE
+ {
+ Pos = TOP_FIXED_LINE_POS;
+ Size = FIXED_LINE_SIZE;
+ Text [ en-US ] = "Textures" ;
+ };
+ // Material
+ /* Control CTL_MATERIAL
+ {
+ //HelpId = HID_SD_CTL_FAVORITES ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( BORDER + 6 , GROUP_Y + 9 ) ;
+ Size = MAP_APPFONT ( GROUP_WIDTH - 12 , GROUP_HEIGHT - 15 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+*/
+ // Materialeditor
+ FixedText FT_MAT_FAVORITES
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Favorites" ;
+ };
+ ListBox LB_MAT_FAVORITES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1,
+ FIRST_FT_START_Y - 2 ) ;
+ Size = MAP_APPFONT ( 83 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "User-defined" ; > ;
+ < "Metal" ; > ;
+ < "Gold" ; > ;
+ < "Chrome" ; > ;
+ < "Plastic" ; > ;
+ < "Wood" ; > ;
+ };
+ };
+ FixedText FT_MAT_COLOR
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + FT_OFFSET_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Object color" ;
+ };
+ ListBox LB_MAT_COLOR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 ,
+ FIRST_FT_START_Y + FT_OFFSET_NEXT - 2 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ImageButton BTN_MAT_COLOR
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 72 ,
+ FIRST_FT_START_Y + FT_OFFSET_NEXT - 2 ) ;
+ Size = MAP_APPFONT ( 12, 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "colordlg.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Colors Dialog" ;
+ };
+ FixedText FT_MAT_EMISSION
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , FIRST_FT_START_Y + 2*FT_OFFSET_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Illumination color" ;
+ };
+ ListBox LB_MAT_EMISSION
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 ,
+ FIRST_FT_START_Y + 2*FT_OFFSET_NEXT - 2 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ImageButton BTN_EMISSION_COLOR
+ {
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 72 ,
+ FIRST_FT_START_Y + 2*FT_OFFSET_NEXT - 2 ) ;
+ Size = MAP_APPFONT ( 12, 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "colordlg.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Colors Dialog" ;
+ };
+
+ FixedLine FL_MAT_SPECULAR
+ {
+ Pos = MAP_APPFONT ( BORDER , SPECULAR_START_Y ) ;
+ Size = FIXED_LINE_SIZE;
+ Text [ en-US ] = "Specular" ;
+ };
+ FixedText FT_MAT_SPECULAR
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , SPECULAR_START_Y + 13 ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "~Color" ;
+ };
+ ListBox LB_MAT_SPECULAR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1, SPECULAR_START_Y + 13 - 2 ) ;
+ Size = MAP_APPFONT ( 68 , 100 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ImageButton BTN_SPECULAR_COLOR
+ {
+ Pos = MAP_APPFONT ( 137 , SPECULAR_START_Y + 13 - 2 ) ;
+ Size = MAP_APPFONT ( 12, 14 ) ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "colordlg.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Colors Dialog" ;
+ };
+ FixedText FT_MAT_SPECULAR_INTENSITY
+ {
+ Pos = MAP_APPFONT ( FT_INDENT , SPECULAR_START_Y + 13 + FT_OFFSET_NEXT ) ;
+ Size = MAP_APPFONT ( FT_WIDTH_SHORT , FT_HEIGHT ) ;
+ Text [ en-US ] = "I~ntensity" ;
+ };
+ MetricField MTR_MAT_SPECULAR_INTENSITY
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( FT_INDENT + FT_WIDTH_SHORT + 1 ,
+ SPECULAR_START_Y + 13 + FT_OFFSET_NEXT ) ;
+ Size = MAP_APPFONT ( 68 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = "%" ;
+ Minimum = 1 ;
+ First = 1 ;
+ Maximum = 100 ;
+ Last = 100 ;
+ SpinSize = 1 ;
+ };
+ /*
+ ImageButton BTN_MAT_FAVORITES {
+ Pos = MAP_APPFONT( BORDER, GROUP_PREV_Y+1 );
+ Size = IMG_BUTTON_SIZE;
+ QuickHelpText = "Material Favoriten" ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "matfavor.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE;
+ };
+ ImageButton BTN_MAT_EDITOR {
+ Pos = MAP_APPFONT( BORDER + BUTTON_WIDTH, GROUP_PREV_Y+1 );
+ Size = IMG_BUTTON_SIZE;
+ QuickHelpText = "Material Editor" ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "matedit.bmp" ; };
+ MASKCOLOR
+ };
+ TabStop = TRUE;
+ };
+*/
+ FixedLine FL_MATERIAL
+ {
+ Pos = TOP_FIXED_LINE_POS;
+ Size = FIXED_LINE_SIZE;
+ Text [ en-US ] = "Material" ;
+ };
+
+ Bitmap BMP_GEO_H
+ {
+ File = "3dgeo_h.bmp";
+ };
+
+ Bitmap BMP_REPRESENTATION_H
+ {
+ File = "3drepres_h.bmp";
+ };
+
+ Bitmap BMP_3DLIGHT_H
+ {
+ File = "3dlight_h.bmp";
+ };
+
+ Bitmap BMP_TEXTURE_H
+ {
+ File = "3dtextur_h.bmp";
+ };
+
+ Bitmap BMP_MATERIAL_H
+ {
+ File = "material_h.bmp";
+ };
+
+ Bitmap BMP_UPDATE_H
+ {
+ File = "sc10350_h.bmp";
+ };
+
+ Bitmap BMP_ASSIGN_H
+ {
+ File = "apply_h.bmp";
+ };
+
+ Bitmap BMP_CHANGE_TO_3D_H
+ {
+ File = "convrt3d_h.bmp";
+ };
+
+ Bitmap BMP_LATHE_OBJ_H
+ {
+ File = "rotate3d_h.bmp";
+ };
+
+ Bitmap BMP_PERSPECTIVE_H
+ {
+ File = "persp3d_h.bmp";
+ };
+
+ Bitmap BMP_NORMALS_OBJ_H
+ {
+ File = "normobjs_h.bmp";
+ };
+
+ Bitmap BMP_NORMALS_FLAT_H
+ {
+ File = "normflat_h.bmp";
+ };
+
+ Bitmap BMP_NORMALS_SPHERE_H
+ {
+ File = "normsphe_h.bmp";
+ };
+
+ Bitmap BMP_NORMALS_INVERT_H
+ {
+ File = "invert3d_h.bmp";
+ };
+
+ Bitmap BMP_TWO_SIDED_LIGHTING_H
+ {
+ File = "lght2sid_h.bmp";
+ };
+
+ Bitmap BMP_DOUBLE_SIDED_H
+ {
+ File = "doublesi_h.bmp";
+ };
+
+ Bitmap BMP_SHADOW_3D_H
+ {
+ File = "shadow3d_h.bmp";
+ };
+
+ Bitmap BMP_LIGHT_H
+ {
+ File = "light_h.bmp";
+ };
+
+ Bitmap BMP_LIGHT_COLOR_H
+ {
+ File = "colordlg_h.bmp";
+ };
+
+ Bitmap BMP_AMBIENT_COLOR_H
+ {
+ File = "colordlg_h.bmp";
+ };
+
+ Bitmap BMP_TEX_LUMINANCE_H
+ {
+ File = "luminanc_h.bmp";
+ };
+
+ Bitmap BMP_TEX_COLOR_H
+ {
+ File = "color_h.bmp";
+ };
+
+ Bitmap BMP_TEX_REPLACE_H
+ {
+ File = "replac3d_h.bmp";
+ };
+
+ Bitmap BMP_TEX_MODULATE_H
+ {
+ File = "modula3d_h.bmp";
+ };
+
+ Bitmap BMP_TEX_BLEND_H
+ {
+ File = "blend3d_h.bmp";
+ };
+
+ Bitmap BMP_TEX_OBJECT_H
+ {
+ File = "objspc3d_h.bmp";
+ };
+
+ Bitmap BMP_TEX_PARALLEL_H
+ {
+ File = "parallel_h.bmp";
+ };
+
+ Bitmap BMP_TEX_CIRCLE_H
+ {
+ File = "sphere3d_h.bmp";
+ };
+
+ Bitmap BMP_TEX_FILTER_H
+ {
+ File = "filter3d_h.bmp";
+ };
+
+ Bitmap BMP_COLORDLG_H
+ {
+ File = "colordlg_h.bmp";
+ };
+};
+
+Image RID_SVXIMAGE_LIGHT_ON
+{
+ ImageBitmap = Bitmap { File = "lighton.bmp" ; };
+ MASKCOLOR
+};
+
+Image RID_SVXIMAGE_LIGHT_OFF
+{
+ ImageBitmap = Bitmap { File = "light.bmp" ; };
+ MASKCOLOR
+};
+
+Image RID_SVXIMAGE_LIGHT_ON_H
+{
+ ImageBitmap = Bitmap { File = "lighton_h.bmp" ; };
+ MASKCOLOR
+};
+
+Image RID_SVXIMAGE_LIGHT_OFF_H
+{
+ ImageBitmap = Bitmap { File = "light_h.bmp" ; };
+ MASKCOLOR
+};
+
+Image RID_SVXIMAGE_COLORDLG
+{
+ ImageBitmap = Bitmap { File = "colordlg.bmp" ; };
+ MASKCOLOR
+};
+
+Image RID_SVXIMAGE_COLORDLG_H
+{
+ ImageBitmap = Bitmap { File = "colordlg_h.bmp" ; };
+ MASKCOLOR
+};
+
+/*Image RID_SVXIMAGE_LIGHT_ON_SELECTED {
+ ImageBitmap = Bitmap { File = "lightons.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMAGE_LIGHT_OFF_SELECTED {
+ ImageBitmap = Bitmap { File = "lightsel.bmp" ; };
+ MASKCOLOR
+};*/
+
+String RID_SVXFLOAT3D_FAVORITE
+{
+ Text [ en-US ] = "Favorite";
+};
+String RID_SVXFLOAT3D_FIX_X
+{
+ Text [ en-US ] = "X";
+};
+String RID_SVXFLOAT3D_FIX_Y
+{
+ Text [ en-US ] = "Y";
+};
+String RID_SVXFLOAT3D_FIX_Z
+{
+ Text [ en-US ] = "Z";
+};
+String RID_SVXFLOAT3D_FIX_R
+{
+ Text [ en-US ] = "R:";
+};
+String RID_SVXFLOAT3D_FIX_G
+{
+ Text [ en-US ] = "G:";
+};
+String RID_SVXFLOAT3D_FIX_B
+{
+ Text [ en-US ] = "B:";
+
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/engine3d/helperhittest3d.cxx b/svx/source/engine3d/helperhittest3d.cxx
new file mode 100644
index 000000000000..a7177f1cc04e
--- /dev/null
+++ b/svx/source/engine3d/helperhittest3d.cxx
@@ -0,0 +1,298 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/helperhittest3d.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/scene3d.hxx>
+#include <svditer.hxx>
+#include <drawinglayer/processor3d/cutfindprocessor3d.hxx>
+#include <svx/sdr/contact/viewcontactofe3d.hxx>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+#include <com/sun/star/uno/Sequence.h>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+class ImplPairDephAndObject
+{
+private:
+ const E3dCompoundObject* mpObject;
+ double mfDepth;
+
+public:
+ ImplPairDephAndObject(const E3dCompoundObject* pObject, double fDepth)
+ : mpObject(pObject),
+ mfDepth(fDepth)
+ {}
+
+ // for ::std::sort
+ bool operator<(const ImplPairDephAndObject& rComp) const
+ {
+ return (mfDepth < rComp.mfDepth);
+ }
+
+ // data read access
+ const E3dCompoundObject* getObject() const { return mpObject; }
+ double getDepth() const { return mfDepth; }
+};
+
+//////////////////////////////////////////////////////////////////////////////
+
+void getAllHit3DObjectWithRelativePoint(
+ const basegfx::B3DPoint& rFront,
+ const basegfx::B3DPoint& rBack,
+ const E3dCompoundObject& rObject,
+ const drawinglayer::geometry::ViewInformation3D& rObjectViewInformation3D,
+ ::std::vector< basegfx::B3DPoint >& o_rResult,
+ bool bAnyHit)
+{
+ o_rResult.clear();
+
+ if(!rFront.equal(rBack))
+ {
+ // rObject is a E3dCompoundObject, so it cannot be a scene (which is a E3dObject)
+ const sdr::contact::ViewContactOfE3d& rVCObject = static_cast< sdr::contact::ViewContactOfE3d& >(rObject.GetViewContact());
+ const drawinglayer::primitive3d::Primitive3DSequence aPrimitives(rVCObject.getViewIndependentPrimitive3DSequence());
+
+ if(aPrimitives.hasElements())
+ {
+ // make BoundVolume empty and overlapping test for speedup
+ const basegfx::B3DRange aObjectRange(drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(aPrimitives, rObjectViewInformation3D));
+
+ if(!aObjectRange.isEmpty())
+ {
+ const basegfx::B3DRange aFrontBackRange(rFront, rBack);
+
+ if(aObjectRange.overlaps(aFrontBackRange))
+ {
+ // bound volumes hit, geometric cut tests needed
+ drawinglayer::processor3d::CutFindProcessor aCutFindProcessor(rObjectViewInformation3D, rFront, rBack, bAnyHit);
+ aCutFindProcessor.process(aPrimitives);
+ o_rResult = aCutFindProcessor.getCutPoints();
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+E3dScene* fillViewInformation3DForCompoundObject(drawinglayer::geometry::ViewInformation3D& o_rViewInformation3D, const E3dCompoundObject& rCandidate)
+{
+ // Search for root scene (outmost scene) of the 3d object since e.g. in chart, multiple scenes may
+ // be placed between object and outmost scene. On that search, remember the in-between scene's
+ // transformation for the correct complete ObjectTransformation. For historical reasons, the
+ // root scene's own object transformation is part of the scene's ViewTransformation, o do not
+ // add it. For more details, see ViewContactOfE3dScene::createViewInformation3D.
+ E3dScene* pParentScene = dynamic_cast< E3dScene* >(rCandidate.GetParentObj());
+ E3dScene* pRootScene = 0;
+ basegfx::B3DHomMatrix aInBetweenSceneMatrix;
+
+ while(pParentScene)
+ {
+ E3dScene* pParentParentScene = dynamic_cast< E3dScene* >(pParentScene->GetParentObj());
+
+ if(pParentParentScene)
+ {
+ // pParentScene is a in-between scene
+ aInBetweenSceneMatrix = pParentScene->GetTransform() * aInBetweenSceneMatrix;
+ }
+ else
+ {
+ // pParentScene is the root scene
+ pRootScene = pParentScene;
+ }
+
+ pParentScene = pParentParentScene;
+ }
+
+ if(pRootScene)
+ {
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
+
+ if(aInBetweenSceneMatrix.isIdentity())
+ {
+ o_rViewInformation3D = rVCScene.getViewInformation3D();
+ }
+ else
+ {
+ // build new ViewInformation containing all transforms for the candidate
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+
+ o_rViewInformation3D = drawinglayer::geometry::ViewInformation3D(
+ aViewInfo3D.getObjectTransformation() * aInBetweenSceneMatrix,
+ aViewInfo3D.getOrientation(),
+ aViewInfo3D.getProjection(),
+ aViewInfo3D.getDeviceToView(),
+ aViewInfo3D.getViewTime(),
+ aViewInfo3D.getExtendedInformationSequence());
+ }
+ }
+ else
+ {
+ const uno::Sequence< beans::PropertyValue > aEmptyParameters;
+ o_rViewInformation3D = drawinglayer::geometry::ViewInformation3D(aEmptyParameters);
+ }
+
+ return pRootScene;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+SVX_DLLPUBLIC void getAllHit3DObjectsSortedFrontToBack(
+ const basegfx::B2DPoint& rPoint,
+ const E3dScene& rScene,
+ ::std::vector< const E3dCompoundObject* >& o_rResult)
+{
+ o_rResult.clear();
+ SdrObjList* pList = rScene.GetSubList();
+
+ if(pList && pList->GetObjCount())
+ {
+ // prepare relative HitPoint. To do so, get the VC of the 3DScene and from there
+ // the Scene's 2D transformation. Multiplying with the inverse transformation
+ // will create a point relative to the 3D scene as unit-2d-object
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(rScene.GetViewContact());
+ basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
+ aInverseSceneTransform.invert();
+ const basegfx::B2DPoint aRelativePoint(aInverseSceneTransform * rPoint);
+
+ // check if test point is inside scene's area at all
+ if(aRelativePoint.getX() >= 0.0 && aRelativePoint.getX() <= 1.0 && aRelativePoint.getY() >= 0.0 && aRelativePoint.getY() <= 1.0)
+ {
+ SdrObjListIter aIterator(*pList, IM_DEEPNOGROUPS);
+ ::std::vector< ImplPairDephAndObject > aDepthAndObjectResults;
+ const uno::Sequence< beans::PropertyValue > aEmptyParameters;
+ drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters);
+
+ while(aIterator.IsMore())
+ {
+ const E3dCompoundObject* pCandidate = dynamic_cast< const E3dCompoundObject* >(aIterator.Next());
+
+ if(pCandidate)
+ {
+ fillViewInformation3DForCompoundObject(aViewInfo3D, *pCandidate);
+
+ // create HitPoint Front and Back, transform to object coordinates
+ basegfx::B3DHomMatrix aViewToObject(aViewInfo3D.getObjectToView());
+ aViewToObject.invert();
+ const basegfx::B3DPoint aFront(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 0.0));
+ const basegfx::B3DPoint aBack(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 1.0));
+
+ if(!aFront.equal(aBack))
+ {
+ // get all hit points with object
+ ::std::vector< basegfx::B3DPoint > aHitsWithObject;
+ getAllHit3DObjectWithRelativePoint(aFront, aBack, *pCandidate, aViewInfo3D, aHitsWithObject, false);
+
+ for(sal_uInt32 a(0); a < aHitsWithObject.size(); a++)
+ {
+ const basegfx::B3DPoint aPointInViewCoordinates(aViewInfo3D.getObjectToView() * aHitsWithObject[a]);
+ aDepthAndObjectResults.push_back(ImplPairDephAndObject(pCandidate, aPointInViewCoordinates.getZ()));
+ }
+ }
+ }
+ }
+
+ // fill nRetval
+ const sal_uInt32 nCount(aDepthAndObjectResults.size());
+
+ if(nCount)
+ {
+ // sort aDepthAndObjectResults by depth
+ ::std::sort(aDepthAndObjectResults.begin(), aDepthAndObjectResults.end());
+
+ // copy SdrObject pointers to return result set
+ ::std::vector< ImplPairDephAndObject >::iterator aIterator2(aDepthAndObjectResults.begin());
+
+ for(;aIterator2 != aDepthAndObjectResults.end(); aIterator2++)
+ {
+ o_rResult.push_back(aIterator2->getObject());
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+bool checkHitSingle3DObject(
+ const basegfx::B2DPoint& rPoint,
+ const E3dCompoundObject& rCandidate)
+{
+ const uno::Sequence< beans::PropertyValue > aEmptyParameters;
+ drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters);
+ E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, rCandidate);
+
+ if(pRootScene)
+ {
+ // prepare relative HitPoint. To do so, get the VC of the 3DScene and from there
+ // the Scene's 2D transformation. Multiplying with the inverse transformation
+ // will create a point relative to the 3D scene as unit-2d-object
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
+ basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
+ aInverseSceneTransform.invert();
+ const basegfx::B2DPoint aRelativePoint(aInverseSceneTransform * rPoint);
+
+ // check if test point is inside scene's area at all
+ if(aRelativePoint.getX() >= 0.0 && aRelativePoint.getX() <= 1.0 && aRelativePoint.getY() >= 0.0 && aRelativePoint.getY() <= 1.0)
+ {
+ // create HitPoint Front and Back, transform to object coordinates
+ basegfx::B3DHomMatrix aViewToObject(aViewInfo3D.getObjectToView());
+ aViewToObject.invert();
+ const basegfx::B3DPoint aFront(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 0.0));
+ const basegfx::B3DPoint aBack(aViewToObject * basegfx::B3DPoint(aRelativePoint.getX(), aRelativePoint.getY(), 1.0));
+
+ if(!aFront.equal(aBack))
+ {
+ // get all hit points with object
+ ::std::vector< basegfx::B3DPoint > aHitsWithObject;
+ getAllHit3DObjectWithRelativePoint(aFront, aBack, rCandidate, aViewInfo3D, aHitsWithObject, true);
+
+ if(aHitsWithObject.size())
+ {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/helperminimaldepth3d.cxx b/svx/source/engine3d/helperminimaldepth3d.cxx
new file mode 100644
index 000000000000..bbe70996a520
--- /dev/null
+++ b/svx/source/engine3d/helperminimaldepth3d.cxx
@@ -0,0 +1,215 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <helperminimaldepth3d.hxx>
+#include <drawinglayer/processor3d/baseprocessor3d.hxx>
+#include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
+#include <drawinglayer/primitive3d/transformprimitive3d.hxx>
+#include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
+#include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx>
+#include <svx/sdr/contact/viewcontactofe3d.hxx>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/scene3d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace processor3d
+ {
+ class MinimalDephInViewExtractor : public BaseProcessor3D
+ {
+ private:
+ // the value which will be fetched as result
+ double mfMinimalDepth;
+
+ // as tooling, the process() implementation takes over API handling and calls this
+ // virtual render method when the primitive implementation is BasePrimitive3D-based.
+ virtual void processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate);
+
+ public:
+ MinimalDephInViewExtractor(const geometry::ViewInformation3D& rViewInformation)
+ : BaseProcessor3D(rViewInformation),
+ mfMinimalDepth(DBL_MAX)
+ {}
+
+ // data access
+ double getMinimalDepth() const { return mfMinimalDepth; }
+ };
+
+ void MinimalDephInViewExtractor::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate)
+ {
+ // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch
+ switch(rCandidate.getPrimitive3DID())
+ {
+ case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D :
+ {
+ // transform group. Remember current transformations
+ const primitive3d::TransformPrimitive3D& rPrimitive = static_cast< const primitive3d::TransformPrimitive3D& >(rCandidate);
+ const geometry::ViewInformation3D aLastViewInformation3D(getViewInformation3D());
+
+ // create new transformation; add new object transform from right side
+ const geometry::ViewInformation3D aNewViewInformation3D(
+ aLastViewInformation3D.getObjectTransformation() * rPrimitive.getTransformation(),
+ aLastViewInformation3D.getOrientation(),
+ aLastViewInformation3D.getProjection(),
+ aLastViewInformation3D.getDeviceToView(),
+ aLastViewInformation3D.getViewTime(),
+ aLastViewInformation3D.getExtendedInformationSequence());
+ updateViewInformation(aNewViewInformation3D);
+
+ // let break down
+ process(rPrimitive.getChildren());
+
+ // restore transformations
+ updateViewInformation(aLastViewInformation3D);
+ break;
+ }
+ case PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D :
+ {
+ // PolygonHairlinePrimitive3D
+ const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(rCandidate);
+ const basegfx::B3DPolygon& rPolygon = rPrimitive.getB3DPolygon();
+ const sal_uInt32 nCount(rPolygon.count());
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ const basegfx::B3DPoint aPointInView(getViewInformation3D().getObjectToView() * rPolygon.getB3DPoint(a));
+
+ if(aPointInView.getZ() < mfMinimalDepth)
+ {
+ mfMinimalDepth = aPointInView.getZ();
+ }
+ }
+
+ break;
+ }
+ case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D :
+ {
+ // PolyPolygonMaterialPrimitive3D
+ const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(rCandidate);
+ const basegfx::B3DPolyPolygon& rPolyPolygon = rPrimitive.getB3DPolyPolygon();
+ const sal_uInt32 nPolyCount(rPolyPolygon.count());
+
+ for(sal_uInt32 a(0); a < nPolyCount; a++)
+ {
+ const basegfx::B3DPolygon aPolygon(rPolyPolygon.getB3DPolygon(a));
+ const sal_uInt32 nCount(aPolygon.count());
+
+ for(sal_uInt32 b(0); b < nCount; b++)
+ {
+ const basegfx::B3DPoint aPointInView(getViewInformation3D().getObjectToView() * aPolygon.getB3DPoint(b));
+
+ if(aPointInView.getZ() < mfMinimalDepth)
+ {
+ mfMinimalDepth = aPointInView.getZ();
+ }
+ }
+ }
+
+ break;
+ }
+ default :
+ {
+ // process recursively
+ process(rCandidate.get3DDecomposition(getViewInformation3D()));
+ break;
+ }
+ }
+ }
+ } // end of namespace processor3d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// changed to create values using VCs, Primitive3DSequence and ViewInformation3D to allow
+// removal of old 3D bucket geometry. There is one slight difference in the result, it's
+// in [0.0 .. 1.0] for Z-Depth since the scaling of the scene as 2D object is no longer
+// part of the 3D transformations. This could be added since the ViewContactOfE3dScene is
+// given, but is not needed since the permutation of the depth values needs only be correct
+// relative to each other
+
+double getMinimalDepthInViewCoordinates(const E3dCompoundObject& rObject)
+{
+ // this is a E3dCompoundObject, so it cannot be a scene (which is a E3dObject).
+ // Get primitive sequence using VC
+ const sdr::contact::ViewContactOfE3d& rVCObject = static_cast< sdr::contact::ViewContactOfE3d& >(rObject.GetViewContact());
+ const drawinglayer::primitive3d::Primitive3DSequence aPrimitives = rVCObject.getViewIndependentPrimitive3DSequence();
+ double fRetval(DBL_MAX);
+
+ if(aPrimitives.hasElements())
+ {
+ const E3dScene* pScene = rObject.GetScene();
+
+ if(pScene)
+ {
+ // get ViewInformation3D from scene using VC
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+
+ // the scene's object transformation is already part of aViewInfo3D.getObjectTransformation()
+ // for historical reasons (see ViewContactOfE3dScene::createViewInformation3D for more info)
+ // and the object's transform is part of aPrimitives (and taken into account when decomposing
+ // to PolygonHairlinePrimitive3D and PolyPolygonMaterialPrimitive3D). The missing part may be
+ // some Scene SdrObjects lying in-between which may need to be added. This is e.g. used in chart,
+ // and generally allowed in 3d scenes an their 3d object hierarchy
+ basegfx::B3DHomMatrix aInBetweenSceneMatrix;
+ E3dScene* pParentScene = dynamic_cast< E3dScene* >(rObject.GetParentObj());
+
+ while(pParentScene && pParentScene != pScene)
+ {
+ aInBetweenSceneMatrix = pParentScene->GetTransform() * aInBetweenSceneMatrix;
+ pParentScene = dynamic_cast< E3dScene* >(pParentScene->GetParentObj());
+ }
+
+ // build new ViewInformation containing all transforms
+ const drawinglayer::geometry::ViewInformation3D aNewViewInformation3D(
+ aViewInfo3D.getObjectTransformation() * aInBetweenSceneMatrix,
+ aViewInfo3D.getOrientation(),
+ aViewInfo3D.getProjection(),
+ aViewInfo3D.getDeviceToView(),
+ aViewInfo3D.getViewTime(),
+ aViewInfo3D.getExtendedInformationSequence());
+
+ // create extractor helper, proccess geometry and get return value
+ drawinglayer::processor3d::MinimalDephInViewExtractor aExtractor(aNewViewInformation3D);
+ aExtractor.process(aPrimitives);
+ fRetval = aExtractor.getMinimalDepth();
+ }
+ }
+
+ return fRetval;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/helperminimaldepth3d.hxx b/svx/source/engine3d/helperminimaldepth3d.hxx
new file mode 100644
index 000000000000..9a7fd359c817
--- /dev/null
+++ b/svx/source/engine3d/helperminimaldepth3d.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 INCLUDED_SVX_HELPERMINIMALDEPTH_HXX
+#define INCLUDED_SVX_HELPERMINIMALDEPTH_HXX
+
+#include <sal/types.h>
+
+//////////////////////////////////////////////////////////////////////////////
+// predefines
+
+class E3dCompoundObject;
+class E3dScene;
+
+//////////////////////////////////////////////////////////////////////////////
+/** support extracting the minimal depth of a 3d object in it's scene
+
+ @param rObject
+ The 3D Object from which the minimal depth needs to be calculated. The scene
+ is defined by the object already
+
+ @return
+ The minimal depth of this object in unified ViewCoordinates. This is the
+ Z-Coordinate of one object point in the range of [0.0 .. 1.0]. ViewCoordinates
+ means the transformations (esp. rotation) of the scene are taken into account
+
+*/
+// support extracting the minimal depth of a 3d object in it's scene
+
+double getMinimalDepthInViewCoordinates(const E3dCompoundObject& rObject);
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif // INCLUDED_SVX_HELPERMINIMALDEPTH_HXX
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx
new file mode 100644
index 000000000000..681520a14589
--- /dev/null
+++ b/svx/source/engine3d/lathe3d.cxx
@@ -0,0 +1,280 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+#include <tools/poly.hxx>
+#include <svx/svdpage.hxx>
+#include "globl3d.hxx"
+#include <svx/lathe3d.hxx>
+#include <svx/xpoly.hxx>
+#include <svx/svxids.hrc>
+#include <svx/svdopath.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svx3ditems.hxx>
+#include <svx/sdr/properties/e3dlatheproperties.hxx>
+#include <svx/sdr/contact/viewcontactofe3dlathe.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// #110094# DrawContact section
+
+sdr::contact::ViewContact* E3dLatheObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfE3dLathe(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+sdr::properties::BaseProperties* E3dLatheObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::E3dLatheProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(E3dLatheObj, E3dCompoundObject);
+
+/*************************************************************************
+|*
+|* Konstruktor aus 3D-Polygon, Scale gibt den Umrechnungsfaktor fuer
+|* die Koordinaten an
+|*
+\************************************************************************/
+
+E3dLatheObj::E3dLatheObj(E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon rPoly2D)
+: E3dCompoundObject(rDefault),
+ maPolyPoly2D(rPoly2D)
+{
+ // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
+ basegfx::B2DHomMatrix aMirrorY;
+ aMirrorY.scale(1.0, -1.0);
+ maPolyPoly2D.transform(aMirrorY);
+
+ // Defaults setzen
+ SetDefaultAttributes(rDefault);
+
+ // Ueberfluessige Punkte entfernen, insbesondere doppelte
+ // Start- und Endpunkte verhindern
+ maPolyPoly2D.removeDoublePoints();
+
+ if(maPolyPoly2D.count())
+ {
+ const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L));
+ sal_uInt32 nSegCnt(rPoly.count());
+
+ if(nSegCnt && !rPoly.isClosed())
+ {
+ nSegCnt -= 1;
+ }
+
+ GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt));
+ }
+}
+
+/*************************************************************************
+|*
+|* Leer-Konstruktor
+|*
+\************************************************************************/
+
+E3dLatheObj::E3dLatheObj()
+: E3dCompoundObject()
+{
+ // Defaults setzen
+ E3dDefaultAttributes aDefault;
+ SetDefaultAttributes(aDefault);
+}
+
+void E3dLatheObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
+{
+ GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultLatheSmoothed()));
+ GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultLatheSmoothFrontBack()));
+ GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultLatheCharacterMode()));
+ GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultLatheCloseFront()));
+ GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultLatheCloseBack()));
+}
+
+/*************************************************************************
+|*
+|* Identifier zurueckgeben
+|*
+\************************************************************************/
+
+UINT16 E3dLatheObj::GetObjIdentifier() const
+{
+ return E3D_LATHEOBJ_ID;
+}
+
+/*************************************************************************
+|*
+|* Zuweisungsoperator
+|*
+\************************************************************************/
+
+void E3dLatheObj::operator=(const SdrObject& rObj)
+{
+ // erstmal alle Childs kopieren
+ E3dCompoundObject::operator=(rObj);
+
+ // weitere Parameter kopieren
+ const E3dLatheObj& r3DObj = (const E3dLatheObj&)rObj;
+
+ maPolyPoly2D = r3DObj.maPolyPoly2D;
+}
+
+/*************************************************************************
+|*
+|* Wandle das Objekt in ein Gruppenobjekt bestehend aus n Polygonen
+|*
+\************************************************************************/
+
+SdrObject *E3dLatheObj::DoConvertToPolyObj(BOOL /*bBezier*/) const
+{
+ return NULL;
+}
+
+/*************************************************************************
+|*
+|* Neue Segmentierung (Beschreibung siehe Header-File)
+|*
+\************************************************************************/
+
+void E3dLatheObj::ReSegment(sal_uInt32 nHSegs, sal_uInt32 nVSegs)
+{
+ if ((nHSegs != GetHorizontalSegments() || nVSegs != GetVerticalSegments()) &&
+ (nHSegs != 0 || nVSegs != 0))
+ {
+ GetProperties().SetObjectItemDirect(Svx3DHorizontalSegmentsItem(nHSegs));
+ GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nVSegs));
+
+ ActionChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* Lokale Parameter setzen mit Geometrieneuerzeugung
+|*
+\************************************************************************/
+
+void E3dLatheObj::SetPolyPoly2D(const basegfx::B2DPolyPolygon& rNew)
+{
+ if(maPolyPoly2D != rNew)
+ {
+ maPolyPoly2D = rNew;
+ maPolyPoly2D.removeDoublePoints();
+
+ if(maPolyPoly2D.count())
+ {
+ const basegfx::B2DPolygon rPoly(maPolyPoly2D.getB2DPolygon(0L));
+ sal_uInt32 nSegCnt(rPoly.count());
+
+ if(nSegCnt && !rPoly.isClosed())
+ {
+ nSegCnt -= 1;
+ }
+
+ GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nSegCnt));
+ }
+
+ ActionChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (singular)
+|*
+\************************************************************************/
+
+void E3dLatheObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulLathe3d);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (plural)
+|*
+\************************************************************************/
+
+void E3dLatheObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralLathe3d);
+}
+
+/*************************************************************************
+|*
+|* Aufbrechen
+|*
+\************************************************************************/
+
+BOOL E3dLatheObj::IsBreakObjPossible()
+{
+ return TRUE;
+}
+
+SdrAttrObj* E3dLatheObj::GetBreakObj()
+{
+ // create PathObj
+ basegfx::B3DPolyPolygon aLathePoly3D(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(maPolyPoly2D));
+ basegfx::B2DPolyPolygon aTransPoly(TransformToScreenCoor(aLathePoly3D));
+ SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aTransPoly);
+
+ if(pPathObj)
+ {
+ // Attribute setzen
+ SfxItemSet aSet(GetObjectItemSet());
+
+ // Linien aktivieren, um Objekt garantiert sichtbar zu machen
+ aSet.Put(XLineStyleItem(XLINE_SOLID));
+
+ pPathObj->SetMergedItemSet(aSet);
+ }
+
+ return pPathObj;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/makefile.mk b/svx/source/engine3d/makefile.mk
new file mode 100644
index 000000000000..71916df4a83c
--- /dev/null
+++ b/svx/source/engine3d/makefile.mk
@@ -0,0 +1,76 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+TARGET=engine3d
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+LIB1TARGET= $(SLB)$/$(TARGET)-core.lib
+LIB1OBJFILES= \
+ $(SLO)$/e3dsceneupdater.obj \
+ $(SLO)$/helperminimaldepth3d.obj \
+ $(SLO)$/helperhittest3d.obj \
+ $(SLO)$/obj3d.obj \
+ $(SLO)$/scene3d.obj \
+ $(SLO)$/polysc3d.obj \
+ $(SLO)$/cube3d.obj \
+ $(SLO)$/sphere3d.obj \
+ $(SLO)$/extrud3d.obj \
+ $(SLO)$/lathe3d.obj \
+ $(SLO)$/polygn3d.obj \
+ $(SLO)$/svx3ditems.obj \
+ $(SLO)$/deflt3d.obj \
+ $(SLO)$/e3dundo.obj \
+ $(SLO)$/viewpt3d2.obj \
+ $(SLO)$/camera3d.obj \
+ $(SLO)$/objfac3d.obj \
+ $(SLO)$/dragmt3d.obj \
+ $(SLO)$/view3d.obj \
+ $(SLO)$/view3d1.obj
+
+LIB2TARGET= $(SLB)$/$(TARGET).lib
+LIB2OBJFILES= \
+ $(SLO)$/float3d.obj
+
+SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES)
+
+SRS1NAME=engine3d
+SRC1FILES=\
+ string3d.src \
+ float3d.src
+
+.INCLUDE : target.mk
diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx
new file mode 100644
index 000000000000..5516022c170c
--- /dev/null
+++ b/svx/source/engine3d/obj3d.cxx
@@ -0,0 +1,1283 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+#include <svx/svdview.hxx>
+#include <svx/svdattr.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdmodel.hxx>
+#include "svditer.hxx"
+#include "globl3d.hxx"
+#include <svx/camera3d.hxx>
+#include <svx/scene3d.hxx>
+#include <svx/polysc3d.hxx>
+#include <svx/cube3d.hxx>
+#include <svx/lathe3d.hxx>
+#include <svx/sphere3d.hxx>
+#include <svx/extrud3d.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/xtable.hxx>
+#include <svx/xflclit.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+#include <svx/xlnclit.hxx>
+#include <svl/metitem.hxx>
+#include <svx/xtable.hxx>
+#include <svx/xfillit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <vcl/virdev.hxx>
+#include <tools/poly.hxx>
+#include <tools/b3dtrans.hxx>
+#include <svx/svxids.hrc>
+#include <editeng/colritem.hxx>
+#include <svx/e3ditem.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/svdpagv.hxx>
+#include <vcl/gradient.hxx>
+#include <vcl/metaact.hxx>
+#include <svx/svx3ditems.hxx>
+#include <svl/whiter.hxx>
+#include <svtools/colorcfg.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/xgrscit.hxx>
+#include "svdoimp.hxx"
+#include <svx/sdr/properties/e3dproperties.hxx>
+#include <svx/sdr/properties/e3dcompoundproperties.hxx>
+#include <basegfx/polygon/b3dpolypolygontools.hxx>
+#include <basegfx/point/b3dpoint.hxx>
+#include <basegfx/vector/b3dvector.hxx>
+#include <svx/xlndsit.hxx>
+#include <basegfx/matrix/b3dhommatrix.hxx>
+#include <basegfx/polygon/b3dpolygon.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b3dpolygontools.hxx>
+#include <svx/helperhittest3d.hxx>
+#include <svx/sdr/contact/viewcontactofe3d.hxx>
+#include <drawinglayer/geometry/viewinformation3d.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+#include <basegfx/polygon/b3dpolypolygontools.hxx>
+#include <svx/e3dsceneupdater.hxx>
+
+#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+/*************************************************************************
+|*
+|* Liste fuer 3D-Objekte
+|*
+\************************************************************************/
+
+TYPEINIT1(E3dObjList, SdrObjList);
+
+E3dObjList::E3dObjList(SdrModel* pNewModel, SdrPage* pNewPage, E3dObjList* pNewUpList)
+: SdrObjList(pNewModel, pNewPage, pNewUpList)
+{
+}
+
+E3dObjList::E3dObjList(const E3dObjList& rSrcList)
+: SdrObjList(rSrcList)
+{
+}
+
+E3dObjList::~E3dObjList()
+{
+}
+
+void E3dObjList::NbcInsertObject(SdrObject* pObj, ULONG nPos, const SdrInsertReason* pReason)
+{
+ // Owner holen
+ DBG_ASSERT(GetOwnerObj()->ISA(E3dObject), "AW: Einfuegen 3DObject in Parent != 3DObject");
+
+ // Ist es ueberhaupt ein 3D-Objekt?
+ if(pObj && pObj->ISA(E3dObject))
+ {
+ // Normales 3D Objekt, einfuegen mittels
+ // call parent
+ SdrObjList::NbcInsertObject(pObj, nPos, pReason);
+ }
+ else
+ {
+ // Kein 3D Objekt, fuege in Seite statt in Szene ein...
+ GetOwnerObj()->GetPage()->InsertObject(pObj, nPos);
+ }
+}
+
+void E3dObjList::InsertObject(SdrObject* pObj, ULONG nPos, const SdrInsertReason* pReason)
+{
+ OSL_ENSURE(GetOwnerObj()->ISA(E3dObject), "Insert 3DObject in non-3D Parent");
+ //E3DModifySceneSnapRectUpdater aUpdater(GetOwnerObj());
+
+ // call parent
+ SdrObjList::InsertObject(pObj, nPos, pReason);
+
+ E3dScene* pScene = ((E3dObject*)GetOwnerObj())->GetScene();
+ if(pScene)
+ {
+ pScene->Cleanup3DDepthMapper();
+ }
+}
+
+SdrObject* E3dObjList::NbcRemoveObject(ULONG nObjNum)
+{
+ DBG_ASSERT(GetOwnerObj()->ISA(E3dObject), "AW: Entfernen 3DObject aus Parent != 3DObject");
+ //E3DModifySceneSnapRectUpdater aUpdater(GetOwnerObj());
+
+ // call parent
+ SdrObject* pRetval = SdrObjList::NbcRemoveObject(nObjNum);
+
+ E3dScene* pScene = ((E3dObject*)GetOwnerObj())->GetScene();
+ if(pScene)
+ {
+ pScene->Cleanup3DDepthMapper();
+ }
+
+ return pRetval;
+}
+
+SdrObject* E3dObjList::RemoveObject(ULONG nObjNum)
+{
+ OSL_ENSURE(GetOwnerObj()->ISA(E3dObject), "3DObject is removed from non-3D Parent");
+ //E3DModifySceneSnapRectUpdater aUpdater(GetOwnerObj());
+
+ // call parent
+ SdrObject* pRetval = SdrObjList::RemoveObject(nObjNum);
+
+ E3dScene* pScene = ((E3dObject*)GetOwnerObj())->GetScene();
+ if(pScene)
+ {
+ pScene->Cleanup3DDepthMapper();
+ }
+
+ return pRetval;
+}
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+//////////////////////////////////////////////////////////////////////////////
+
+sdr::properties::BaseProperties* E3dObject::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::E3dProperties(*this);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(E3dObject, SdrAttrObj);
+
+E3dObject::E3dObject()
+: maSubList(),
+ maLocalBoundVol(),
+ maTransformation(),
+ maFullTransform(),
+ mbTfHasChanged(true),
+ mbIsSelected(false)
+{
+ bIs3DObj = true;
+ maSubList.SetOwnerObj(this);
+ maSubList.SetListKind(SDROBJLIST_GROUPOBJ);
+ bClosedObj = true;
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+E3dObject::~E3dObject()
+{
+}
+
+/*************************************************************************
+|*
+|* Selektions-Flag setzen
+|*
+\************************************************************************/
+
+void E3dObject::SetSelected(bool bNew)
+{
+ if((bool)mbIsSelected != bNew)
+ {
+ mbIsSelected = bNew;
+ }
+
+ for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
+ {
+ E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
+
+ if(pCandidate)
+ {
+ pCandidate->SetSelected(bNew);
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Aufbrechen, default-Implementierungen
+|*
+\************************************************************************/
+
+BOOL E3dObject::IsBreakObjPossible()
+{
+ return FALSE;
+}
+
+SdrAttrObj* E3dObject::GetBreakObj()
+{
+ return 0L;
+}
+
+/*************************************************************************
+|*
+|* SetRectsDirty muss ueber die lokale SdrSubList gehen
+|*
+\************************************************************************/
+
+void E3dObject::SetRectsDirty(sal_Bool bNotMyself)
+{
+ // call parent
+ SdrAttrObj::SetRectsDirty(bNotMyself);
+
+ for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
+ {
+ E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
+
+ if(pCandidate)
+ {
+ pCandidate->SetRectsDirty(bNotMyself);
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Inventor zurueckgeben
+|*
+\************************************************************************/
+
+UINT32 E3dObject::GetObjInventor() const
+{
+ return E3dInventor;
+}
+
+/*************************************************************************
+|*
+|* Identifier zurueckgeben
+|*
+\************************************************************************/
+
+UINT16 E3dObject::GetObjIdentifier() const
+{
+ return E3D_OBJECT_ID;
+}
+
+/*************************************************************************
+|*
+|* Faehigkeiten des Objektes feststellen
+|*
+\************************************************************************/
+
+void E3dObject::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bResizeFreeAllowed = TRUE;
+ rInfo.bResizePropAllowed = TRUE;
+ rInfo.bRotateFreeAllowed = TRUE;
+ rInfo.bRotate90Allowed = TRUE;
+ rInfo.bMirrorFreeAllowed = FALSE;
+ rInfo.bMirror45Allowed = FALSE;
+ rInfo.bMirror90Allowed = FALSE;
+ rInfo.bShearAllowed = FALSE;
+ rInfo.bEdgeRadiusAllowed = FALSE;
+ rInfo.bCanConvToPath = FALSE;
+
+ // no transparence for 3d objects
+ rInfo.bTransparenceAllowed = FALSE;
+
+ // gradient depends on fillstyle
+ // BM *** check if SetItem is NULL ***
+ XFillStyle eFillStyle = ((XFillStyleItem&)(GetMergedItem(XATTR_FILLSTYLE))).GetValue();
+ rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT);
+
+ // Umwandeln von 3D-Koerpern in Gruppe von Polygonen:
+ //
+ // Erst mal nicht moeglich, da die Erzeugung einer Gruppe von
+ // 2D-Polygonen notwendig waere, die tiefensortiert werden muessten,
+ // also bei Durchdringugnen auch gegeneinander geschnitten werden
+ // muessten. Auch die Texturkoorinaten waeren ein ungeloestes
+ // Problem.
+ rInfo.bCanConvToPoly = FALSE;
+ rInfo.bCanConvToContour = FALSE;
+ rInfo.bCanConvToPathLineToArea = FALSE;
+ rInfo.bCanConvToPolyLineToArea = FALSE;
+}
+
+/*************************************************************************
+|*
+|* Layer setzen
+|*
+\************************************************************************/
+
+void E3dObject::NbcSetLayer(SdrLayerID nLayer)
+{
+ SdrAttrObj::NbcSetLayer(nLayer);
+
+ for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
+ {
+ E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
+
+ if(pCandidate)
+ {
+ pCandidate->NbcSetLayer(nLayer);
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* ObjList auch an SubList setzen
+|*
+\************************************************************************/
+
+void E3dObject::SetObjList(SdrObjList* pNewObjList)
+{
+ SdrObject::SetObjList(pNewObjList);
+ maSubList.SetUpList(pNewObjList);
+}
+
+/*************************************************************************
+|*
+|* Layer setzen
+|*
+\************************************************************************/
+
+void E3dObject::SetPage(SdrPage* pNewPage)
+{
+ SdrAttrObj::SetPage(pNewPage);
+ maSubList.SetPage(pNewPage);
+}
+
+/*************************************************************************
+|*
+|* Layer setzen
+|*
+\************************************************************************/
+
+void E3dObject::SetModel(SdrModel* pNewModel)
+{
+ SdrAttrObj::SetModel(pNewModel);
+ maSubList.SetModel(pNewModel);
+}
+
+/*************************************************************************
+|*
+|* resize object, used from old 2d interfaces, e.g. in Move/Scale dialog
+|* (F4)
+|*
+\************************************************************************/
+void E3dObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ // Bewegung in X,Y im Augkoordinatensystem
+ E3dScene* pScene = GetScene();
+
+ if(pScene)
+ {
+ // transform pos from 2D world to 3D eye
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+ basegfx::B2DPoint aScaleCenter2D((double)rRef.X(), (double)rRef.Y());
+ basegfx::B2DHomMatrix aInverseSceneTransform(rVCScene.getObjectTransformation());
+
+ aInverseSceneTransform.invert();
+ aScaleCenter2D = aInverseSceneTransform * aScaleCenter2D;
+
+ basegfx::B3DPoint aScaleCenter3D(aScaleCenter2D.getX(), aScaleCenter2D.getY(), 0.5);
+ basegfx::B3DHomMatrix aInverseViewToEye(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection());
+
+ aInverseViewToEye.invert();
+ aScaleCenter3D = aInverseViewToEye * aScaleCenter3D;
+
+ // scale-faktoren holen
+ double fScaleX(xFact);
+ double fScaleY(yFact);
+
+ // build transform
+ basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
+ aInverseOrientation.invert();
+ basegfx::B3DHomMatrix mFullTransform(GetFullTransform());
+ basegfx::B3DHomMatrix mTrans(mFullTransform);
+
+ mTrans *= aViewInfo3D.getOrientation();
+ mTrans.translate(-aScaleCenter3D.getX(), -aScaleCenter3D.getY(), -aScaleCenter3D.getZ());
+ mTrans.scale(fScaleX, fScaleY, 1.0);
+ mTrans.translate(aScaleCenter3D.getX(), aScaleCenter3D.getY(), aScaleCenter3D.getZ());
+ mTrans *= aInverseOrientation;
+ mFullTransform.invert();
+ mTrans *= mFullTransform;
+
+ // anwenden
+ basegfx::B3DHomMatrix mObjTrans(GetTransform());
+ mObjTrans *= mTrans;
+
+ E3DModifySceneSnapRectUpdater aUpdater(this);
+ SetTransform(mObjTrans);
+ }
+}
+
+/*************************************************************************
+|*
+|* Objekt verschieben in 2D, wird bei Cursortasten benoetigt
+|*
+\************************************************************************/
+void E3dObject::NbcMove(const Size& rSize)
+{
+ // Bewegung in X,Y im Augkoordinatensystem
+ E3dScene* pScene = GetScene();
+
+ if(pScene)
+ {
+ // Abmessungen der Szene in 3D und 2D als Vergleich
+ Rectangle aRect = pScene->GetSnapRect();
+
+ // Transformation Weltkoordinaten bis eine VOR Objektkoordinaten holen
+ basegfx::B3DHomMatrix mInvDispTransform;
+ if(GetParentObj())
+ {
+ mInvDispTransform = GetParentObj()->GetFullTransform();
+ mInvDispTransform.invert();
+ }
+
+ // BoundVolume from 3d world to 3d eye
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pScene->GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+ basegfx::B3DRange aEyeVol(pScene->GetBoundVolume());
+ aEyeVol.transform(aViewInfo3D.getOrientation());
+
+ // build relative movement vector in eye coordinates
+ basegfx::B3DPoint aMove(
+ (double)rSize.Width() * aEyeVol.getWidth() / (double)aRect.GetWidth(),
+ (double)-rSize.Height() * aEyeVol.getHeight() / (double)aRect.GetHeight(),
+ 0.0);
+ basegfx::B3DPoint aPos(0.0, 0.0, 0.0);
+
+ // movement vektor to local coordinates of objects' parent
+ basegfx::B3DHomMatrix aInverseOrientation(aViewInfo3D.getOrientation());
+ aInverseOrientation.invert();
+ basegfx::B3DHomMatrix aCompleteTrans(mInvDispTransform * aInverseOrientation);
+
+ aMove = aCompleteTrans * aMove;
+ aPos = aCompleteTrans * aPos;
+
+ // build transformation and apply
+ basegfx::B3DHomMatrix aTranslate;
+ aTranslate.translate(aMove.getX() - aPos.getX(), aMove.getY() - aPos.getY(), aMove.getZ() - aPos.getZ());
+
+ E3DModifySceneSnapRectUpdater aUpdater(pScene);
+ SetTransform(aTranslate * GetTransform());
+ }
+}
+
+/*************************************************************************
+|*
+|* liefere die Sublist, aber nur dann, wenn darin Objekte enthalten sind !
+|*
+\************************************************************************/
+
+SdrObjList* E3dObject::GetSubList() const
+{
+ return &(const_cast< E3dObjList& >(maSubList));
+}
+
+/*************************************************************************
+|*
+|* SnapRect berechnen
+|*
+\************************************************************************/
+
+void E3dObject::RecalcSnapRect()
+{
+ maSnapRect = Rectangle();
+
+ for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
+ {
+ E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
+
+ if(pCandidate)
+ {
+ maSnapRect.Union(pCandidate->GetSnapRect());
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Einfuegen eines 3D-Objekts an den Parent weitermelden, damit dieser
+|* ggf. eine Sonderbehandlung fuer spezielle Objekte durchfuehren kann
+|* (z.B. Light/Label in E3dScene)
+|*
+\************************************************************************/
+
+void E3dObject::NewObjectInserted(const E3dObject* p3DObj)
+{
+ if(GetParentObj())
+ GetParentObj()->NewObjectInserted(p3DObj);
+}
+
+/*************************************************************************
+|*
+|* Parent ueber Aenderung der Struktur (z.B. durch Transformation)
+|* informieren; dabei wird das Objekt, in welchem die Aenderung
+|* aufgetreten ist, uebergeben
+|*
+\************************************************************************/
+
+void E3dObject::StructureChanged()
+{
+ if ( GetParentObj() )
+ {
+ GetParentObj()->InvalidateBoundVolume();
+ GetParentObj()->StructureChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* 3D-Objekt einfuegen
+|*
+\************************************************************************/
+
+void E3dObject::Insert3DObj(E3dObject* p3DObj)
+{
+ DBG_ASSERT(p3DObj, "Insert3DObj mit NULL-Zeiger!");
+ SdrPage* pPg = pPage;
+ maSubList.InsertObject(p3DObj);
+ pPage = pPg;
+ InvalidateBoundVolume();
+ NewObjectInserted(p3DObj);
+ StructureChanged();
+}
+
+void E3dObject::Remove3DObj(E3dObject* p3DObj)
+{
+ DBG_ASSERT(p3DObj, "Remove3DObj mit NULL-Zeiger!");
+
+ if(p3DObj->GetParentObj() == this)
+ {
+ SdrPage* pPg = pPage;
+ maSubList.RemoveObject(p3DObj->GetOrdNum());
+ pPage = pPg;
+
+ InvalidateBoundVolume();
+ StructureChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* Parent holen
+|*
+\************************************************************************/
+
+E3dObject* E3dObject::GetParentObj() const
+{
+ E3dObject* pRetval = NULL;
+
+ if(GetObjList()
+ && GetObjList()->GetOwnerObj()
+ && GetObjList()->GetOwnerObj()->ISA(E3dObject))
+ pRetval = ((E3dObject*)GetObjList()->GetOwnerObj());
+ return pRetval;
+}
+
+/*************************************************************************
+|*
+|* Uebergeordnetes Szenenobjekt bestimmen
+|*
+\************************************************************************/
+
+E3dScene* E3dObject::GetScene() const
+{
+ if(GetParentObj())
+ return GetParentObj()->GetScene();
+ return NULL;
+}
+
+/*************************************************************************
+|*
+|* umschliessendes Volumen inklusive aller Kindobjekte berechnen
+|*
+\************************************************************************/
+
+basegfx::B3DRange E3dObject::RecalcBoundVolume() const
+{
+ basegfx::B3DRange aRetval;
+ const sal_uInt32 nObjCnt(maSubList.GetObjCount());
+
+ if(nObjCnt)
+ {
+ for(sal_uInt32 a(0); a < nObjCnt; a++)
+ {
+ const E3dObject* p3DObject = dynamic_cast< const E3dObject* >(maSubList.GetObj(a));
+
+ if(p3DObject)
+ {
+ basegfx::B3DRange aLocalRange(p3DObject->GetBoundVolume());
+ aLocalRange.transform(p3DObject->GetTransform());
+ aRetval.expand(aLocalRange);
+ }
+ }
+ }
+ else
+ {
+ // single 3D object
+ const sdr::contact::ViewContactOfE3d* pVCOfE3D = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&GetViewContact());
+
+ if(pVCOfE3D)
+ {
+ // BoundVolume is without 3D object transformation, use correct sequence
+ const drawinglayer::primitive3d::Primitive3DSequence xLocalSequence(pVCOfE3D->getVIP3DSWithoutObjectTransform());
+
+ if(xLocalSequence.hasElements())
+ {
+ const uno::Sequence< beans::PropertyValue > aEmptyParameters;
+ const drawinglayer::geometry::ViewInformation3D aLocalViewInformation3D(aEmptyParameters);
+
+ aRetval = drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(
+ xLocalSequence, aLocalViewInformation3D);
+ }
+ }
+ }
+
+ return aRetval;
+}
+
+/*************************************************************************
+|*
+|* umschliessendes Volumen zurueckgeben und ggf. neu berechnen
+|*
+\************************************************************************/
+
+const basegfx::B3DRange& E3dObject::GetBoundVolume() const
+{
+ if(maLocalBoundVol.isEmpty())
+ {
+ const_cast< E3dObject* >(this)->maLocalBoundVol = RecalcBoundVolume();
+ }
+
+ return maLocalBoundVol;
+}
+
+void E3dObject::InvalidateBoundVolume()
+{
+ maLocalBoundVol.reset();
+}
+
+/*************************************************************************
+|*
+|* Aederung des BoundVolumes an alle Kindobjekte weitergeben
+|*
+\************************************************************************/
+
+void E3dObject::SetBoundVolInvalid()
+{
+ InvalidateBoundVolume();
+
+ for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
+ {
+ E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
+
+ if(pCandidate)
+ {
+ pCandidate->SetBoundVolInvalid();
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Aederung der Transformation an alle Kindobjekte weitergeben
+|*
+\************************************************************************/
+
+void E3dObject::SetTransformChanged()
+{
+ InvalidateBoundVolume();
+ mbTfHasChanged = true;
+
+ for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
+ {
+ E3dObject* pCandidate = dynamic_cast< E3dObject* >(maSubList.GetObj(a));
+
+ if(pCandidate)
+ {
+ pCandidate->SetTransformChanged();
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* hierarchische Transformation ueber alle Parents bestimmen, in
+|* maFullTransform ablegen und diese zurueckgeben
+|*
+\************************************************************************/
+
+const basegfx::B3DHomMatrix& E3dObject::GetFullTransform() const
+{
+ if(mbTfHasChanged)
+ {
+ basegfx::B3DHomMatrix aNewFullTransformation(maTransformation);
+
+ if ( GetParentObj() )
+ {
+ aNewFullTransformation = GetParentObj()->GetFullTransform() * aNewFullTransformation;
+ }
+
+ const_cast< E3dObject* >(this)->maFullTransform = aNewFullTransformation;
+ const_cast< E3dObject* >(this)->mbTfHasChanged = false;
+ }
+
+ return maFullTransform;
+}
+
+/*************************************************************************
+|*
+|* Transformationsmatrix abfragen
+|*
+\************************************************************************/
+
+const basegfx::B3DHomMatrix& E3dObject::GetTransform() const
+{
+ return maTransformation;
+}
+
+/*************************************************************************
+|*
+|* Transformationsmatrix setzen
+|*
+\************************************************************************/
+
+void E3dObject::NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix)
+{
+ if(maTransformation != rMatrix)
+ {
+ maTransformation = rMatrix;
+ SetTransformChanged();
+ StructureChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* Transformationsmatrix setzen mit Repaint-Broadcast
+|*
+\************************************************************************/
+
+void E3dObject::SetTransform(const basegfx::B3DHomMatrix& rMatrix)
+{
+ if(rMatrix != maTransformation)
+ {
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetTransform(rMatrix);
+ SetChanged();
+ BroadcastObjectChange();
+ if (pUserCall != NULL) pUserCall->Changed(*this, SDRUSERCALL_RESIZE, Rectangle());
+ }
+}
+
+/*************************************************************************
+|*
+|* Linien fuer die Wireframe-Darstellung des Objekts dem uebergebenen
+|* basegfx::B3DPolygon hinzufuegen
+|*
+\************************************************************************/
+
+basegfx::B3DPolyPolygon E3dObject::CreateWireframe() const
+{
+ const basegfx::B3DRange aBoundVolume(GetBoundVolume());
+ return basegfx::tools::createCubePolyPolygonFromB3DRange(aBoundVolume);
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (singular)
+|*
+\************************************************************************/
+
+void E3dObject::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulObj3d);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (plural)
+|*
+\************************************************************************/
+
+void E3dObject::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralObj3d);
+}
+
+/*************************************************************************
+|*
+|* Zuweisungsoperator
+|*
+\************************************************************************/
+
+void E3dObject::operator=(const SdrObject& rObj)
+{
+ SdrObject::operator=(rObj);
+
+ const E3dObject& r3DObj = (const E3dObject&) rObj;
+ if (r3DObj.GetSubList())
+ {
+ maSubList.CopyObjects(*r3DObj.GetSubList());
+ }
+
+ // BoundVol kann uebernommen werden, da die Childs auch kopiert werden
+ maLocalBoundVol = r3DObj.maLocalBoundVol;
+ maTransformation = r3DObj.maTransformation;
+
+ // Da sich der Parent geaendert haben kann, Gesamttransformation beim
+ // naechsten Mal auf jeden Fall neu bestimmen
+ SetTransformChanged();
+
+ // Selektionsstatus kopieren
+ mbIsSelected = r3DObj.mbIsSelected;
+}
+
+/*************************************************************************
+|*
+|* erstelle neues GeoData-Objekt
+|*
+\************************************************************************/
+
+SdrObjGeoData *E3dObject::NewGeoData() const
+{
+ // Theoretisch duerfen auch nur Szenen ihre GeoDatas erstellen und verwalten !!
+ // AW: Dies stimmt nicht mehr, diese Stelle ist mit der neuen Engine OK!
+ return new E3DObjGeoData;
+}
+
+/*************************************************************************
+|*
+|* uebergebe aktuelle werte an das GeoData-Objekt
+|*
+\************************************************************************/
+
+void E3dObject::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ SdrAttrObj::SaveGeoData (rGeo);
+
+ ((E3DObjGeoData &) rGeo).maLocalBoundVol = maLocalBoundVol;
+ ((E3DObjGeoData &) rGeo).maTransformation = maTransformation;
+}
+
+/*************************************************************************
+|*
+|* uebernehme werte aus dem GeoData-Objekt
+|*
+\************************************************************************/
+
+void E3dObject::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ maLocalBoundVol = ((E3DObjGeoData &) rGeo).maLocalBoundVol;
+ E3DModifySceneSnapRectUpdater aUpdater(this);
+ NbcSetTransform(((E3DObjGeoData &) rGeo).maTransformation);
+ SdrAttrObj::RestGeoData (rGeo);
+}
+
+/*************************************************************************
+|*
+|* Rotation eines 3d-Koerpers
+|*
+\************************************************************************/
+// 2D-rotation eines 3D-Koerpers, normalerweise macht das die Szene selbst
+// Ist aber eine korrekte Implementierung, denn alles was passiert ist eine
+// Rotation um die Achse die senkrecht auf dem Bildschirm steht und zwar
+// unabhaengig davon, wie die Szene bisher gedreht worden ist.
+
+void E3dObject::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ // Also derzeit sind die Klebepunkte relativ zum aOutRect der Szene definiert. Vor dem Drehen
+ // werden die Klebepunkte relativ zur Seite definiert. Sie nehmen an der Drehung der Szene noch nicht Teil
+ // dafuer gibt es den
+ SetGlueReallyAbsolute(TRUE);
+
+ // SendRepaintBroadcast();
+ double fWinkelInRad = nWink/100 * F_PI180;
+
+ basegfx::B3DHomMatrix aRotateZ;
+ aRotateZ.rotate(0.0, 0.0, fWinkelInRad);
+ NbcSetTransform(aRotateZ * GetTransform());
+
+ SetRectsDirty(); // Veranlasst eine Neuberechnung aller BoundRects
+ NbcRotateGluePoints(rRef,nWink,sn,cs); // Rotiert die Klebepunkte (die haben noch Koordinaten relativ
+ // zum Urpsung des Blattes
+ SetGlueReallyAbsolute(FALSE); // ab jetzt sind sie wieder relativ zum BoundRect (also dem aOutRect definiert)
+}
+
+/*************************************************************************/
+
+//////////////////////////////////////////////////////////////////////////////
+
+sdr::properties::BaseProperties* E3dCompoundObject::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::E3dCompoundProperties(*this);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(E3dCompoundObject, E3dObject);
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+E3dCompoundObject::E3dCompoundObject()
+: E3dObject(),
+ aMaterialAmbientColor(),
+ bCreateNormals(false),
+ bCreateTexture(false)
+{
+ // Defaults setzen
+ E3dDefaultAttributes aDefault;
+ SetDefaultAttributes(aDefault);
+}
+
+E3dCompoundObject::E3dCompoundObject(E3dDefaultAttributes& rDefault)
+: E3dObject(),
+ aMaterialAmbientColor(),
+ bCreateNormals(false),
+ bCreateTexture(false)
+{
+ // Defaults setzen
+ SetDefaultAttributes(rDefault);
+}
+
+void E3dCompoundObject::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
+{
+ // Defaults setzen
+ aMaterialAmbientColor = rDefault.GetDefaultAmbientColor();
+
+ bCreateNormals = rDefault.GetDefaultCreateNormals();
+ bCreateTexture = rDefault.GetDefaultCreateTexture();
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+E3dCompoundObject::~E3dCompoundObject ()
+{
+}
+
+/*************************************************************************
+|*
+|* Drag-Polygon zurueckgeben
+|*
+\************************************************************************/
+
+basegfx::B2DPolyPolygon E3dCompoundObject::TakeXorPoly() const
+{
+ basegfx::B2DPolyPolygon aRetval;
+ const uno::Sequence< beans::PropertyValue > aEmptyParameters;
+ drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters);
+ E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this);
+
+ if(pRootScene)
+ {
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
+ const basegfx::B3DPolyPolygon aCubePolyPolygon(CreateWireframe());
+ aRetval = basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aCubePolyPolygon,
+ aViewInfo3D.getObjectToView() * GetTransform());
+ aRetval.transform(rVCScene.getObjectTransformation());
+ }
+
+ return aRetval;
+}
+
+/*************************************************************************
+|*
+|* Anzahl der Handles zurueckgeben
+|*
+\************************************************************************/
+
+sal_uInt32 E3dCompoundObject::GetHdlCount() const
+{
+ // 8 Eckpunkte + 1 E3dVolumeMarker (= Wireframe-Darstellung)
+ return 9L;
+}
+
+/*************************************************************************
+|*
+|* Handle-Liste fuellen
+|*
+\************************************************************************/
+
+void E3dCompoundObject::AddToHdlList(SdrHdlList& rHdlList) const
+{
+ const uno::Sequence< beans::PropertyValue > aEmptyParameters;
+ drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters);
+ E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this);
+
+ if(pRootScene)
+ {
+ const basegfx::B3DRange aBoundVolume(GetBoundVolume());
+
+ if(!aBoundVolume.isEmpty())
+ {
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
+
+ for(sal_uInt32 a(0); a < 8; a++)
+ {
+ basegfx::B3DPoint aPos3D;
+
+ switch(a)
+ {
+ case 0 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMinZ()); break;
+ case 1 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break;
+ case 2 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMinZ()); break;
+ case 3 : aPos3D.setX(aBoundVolume.getMinX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break;
+ case 4 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMinZ()); break;
+ case 5 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMinY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break;
+ case 6 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMinZ()); break;
+ case 7 : aPos3D.setX(aBoundVolume.getMaxX()); aPos3D.setY(aBoundVolume.getMaxY()); aPos3D.setZ(aBoundVolume.getMaxZ()); break;
+ }
+
+ // to 3d view coor
+ aPos3D *= aViewInfo3D.getObjectToView() * GetTransform();
+
+ // create 2d relative scene
+ basegfx::B2DPoint aPos2D(aPos3D.getX(), aPos3D.getY());
+
+ // to 2d world coor
+ aPos2D *= rVCScene.getObjectTransformation();
+
+ rHdlList.AddHdl(new SdrHdl(Point(basegfx::fround(aPos2D.getX()), basegfx::fround(aPos2D.getY())), HDL_BWGT));
+ }
+ }
+ }
+
+ const basegfx::B2DPolyPolygon aPolyPolygon(TakeXorPoly());
+
+ if(aPolyPolygon.count())
+ {
+ E3dVolumeMarker* pVolMarker = new E3dVolumeMarker(aPolyPolygon);
+ rHdlList.AddHdl(pVolMarker);
+ }
+}
+
+/*************************************************************************
+|*
+|* Identifier zurueckgeben
+|*
+\************************************************************************/
+
+UINT16 E3dCompoundObject::GetObjIdentifier() const
+{
+ return E3D_COMPOUNDOBJ_ID;
+}
+
+/*************************************************************************
+|*
+|* SnapRect berechnen
+|*
+\************************************************************************/
+
+void E3dCompoundObject::RecalcSnapRect()
+{
+ const uno::Sequence< beans::PropertyValue > aEmptyParameters;
+ drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters);
+ E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this);
+ maSnapRect = Rectangle();
+
+ if(pRootScene)
+ {
+ // get VC of 3D candidate
+ const sdr::contact::ViewContactOfE3d* pVCOfE3D = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&GetViewContact());
+
+ if(pVCOfE3D)
+ {
+ // get 3D primitive sequence
+ const drawinglayer::primitive3d::Primitive3DSequence xLocalSequence(pVCOfE3D->getViewIndependentPrimitive3DSequence());
+
+ if(xLocalSequence.hasElements())
+ {
+ // get BoundVolume
+ basegfx::B3DRange aBoundVolume(drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(
+ xLocalSequence, aViewInfo3D));
+
+ // transform bound volume to relative scene coordinates
+ aBoundVolume.transform(aViewInfo3D.getObjectToView());
+
+ // build 2d relative scene range
+ basegfx::B2DRange aSnapRange(
+ aBoundVolume.getMinX(), aBoundVolume.getMinY(),
+ aBoundVolume.getMaxX(), aBoundVolume.getMaxY());
+
+ // transform to 2D world coordiantes
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
+ aSnapRange.transform(rVCScene.getObjectTransformation());
+
+ // snap to integer
+ maSnapRect = Rectangle(
+ sal_Int32(floor(aSnapRange.getMinX())), sal_Int32(floor(aSnapRange.getMinY())),
+ sal_Int32(ceil(aSnapRange.getMaxX())), sal_Int32(ceil(aSnapRange.getMaxY())));
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Copy-Operator
+|*
+\************************************************************************/
+
+void E3dCompoundObject::operator=(const SdrObject& rObj)
+{
+ // erstmal alle Childs kopieren
+ E3dObject::operator=(rObj);
+
+ // weitere Parameter kopieren
+ const E3dCompoundObject& r3DObj = (const E3dCompoundObject&) rObj;
+
+ bCreateNormals = r3DObj.bCreateNormals;
+ bCreateTexture = r3DObj.bCreateTexture;
+ aMaterialAmbientColor = r3DObj.aMaterialAmbientColor;
+}
+
+/*************************************************************************
+|*
+|* Parameter Geometrieerzeugung setzen
+|*
+\************************************************************************/
+
+void E3dCompoundObject::SetCreateNormals(BOOL bNew)
+{
+ if(bCreateNormals != bNew)
+ {
+ bCreateNormals = bNew;
+ ActionChanged();
+ }
+}
+
+void E3dCompoundObject::SetCreateTexture(BOOL bNew)
+{
+ if(bCreateTexture != bNew)
+ {
+ bCreateTexture = bNew;
+ ActionChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* Material des Objektes
+|*
+\************************************************************************/
+
+void E3dCompoundObject::SetMaterialAmbientColor(const Color& rColor)
+{
+ if(aMaterialAmbientColor != rColor)
+ {
+ aMaterialAmbientColor = rColor;
+ }
+}
+
+/*************************************************************************
+|*
+|* convert given basegfx::B3DPolyPolygon to screen coor
+|*
+\************************************************************************/
+
+basegfx::B2DPolyPolygon E3dCompoundObject::TransformToScreenCoor(const basegfx::B3DPolyPolygon& rCandidate)
+{
+ const uno::Sequence< beans::PropertyValue > aEmptyParameters;
+ drawinglayer::geometry::ViewInformation3D aViewInfo3D(aEmptyParameters);
+ E3dScene* pRootScene = fillViewInformation3DForCompoundObject(aViewInfo3D, *this);
+ basegfx::B2DPolyPolygon aRetval;
+
+ if(pRootScene)
+ {
+ aRetval = basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(rCandidate,
+ aViewInfo3D.getObjectToView() * GetTransform());
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(pRootScene->GetViewContact());
+ aRetval.transform(rVCScene.getObjectTransformation());
+ }
+
+ return aRetval;
+}
+
+sal_Bool E3dCompoundObject::IsAOrdNumRemapCandidate(E3dScene*& prScene) const
+{
+ if(GetObjList()
+ && GetObjList()->GetOwnerObj()
+ && GetObjList()->GetOwnerObj()->ISA(E3dScene))
+ {
+ prScene = (E3dScene*)GetObjList()->GetOwnerObj();
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/objfac3d.cxx b/svx/source/engine3d/objfac3d.cxx
new file mode 100644
index 000000000000..0244032b1f10
--- /dev/null
+++ b/svx/source/engine3d/objfac3d.cxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/svdpage.hxx>
+#include "globl3d.hxx"
+#include <svx/polysc3d.hxx>
+#include <svx/cube3d.hxx>
+#include <svx/sphere3d.hxx>
+#include <svx/extrud3d.hxx>
+#include <svx/lathe3d.hxx>
+#include <svx/polygn3d.hxx>
+#include "objfac3d.hxx"
+#include <svx/svdobj.hxx>
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+static BOOL bInit = FALSE;
+
+E3dObjFactory::E3dObjFactory()
+{
+ if ( !bInit )
+ {
+ SdrObjFactory::InsertMakeObjectHdl(LINK(this, E3dObjFactory, MakeObject));
+ bInit = TRUE;
+ }
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+E3dObjFactory::~E3dObjFactory()
+{
+}
+
+/*************************************************************************
+|*
+|* Chart-interne Objekte erzeugen
+|*
+\************************************************************************/
+
+IMPL_LINK( E3dObjFactory, MakeObject, SdrObjFactory*, pObjFactory)
+{
+ if ( pObjFactory->nInventor == E3dInventor )
+ {
+ switch ( pObjFactory->nIdentifier )
+ {
+ case E3D_POLYSCENE_ID:
+ pObjFactory->pNewObj = new E3dPolyScene();
+ break;
+ case E3D_POLYGONOBJ_ID :
+ pObjFactory->pNewObj = new E3dPolygonObj();
+ break;
+ case E3D_CUBEOBJ_ID :
+ pObjFactory->pNewObj = new E3dCubeObj();
+ break;
+ case E3D_SPHEREOBJ_ID:
+ // FG: ruft den dummy constructor, da dieser Aufruf nur beim Laden von Dokumenten erfolgt.
+ // die wirkliche Anzahkl Segmente wird aber erst nach dem Laden der Member festgelegt.
+ // dies hat zur Folge das die erste Kugel gleich wieder zerstoert wird, obwohl sie nie
+ // gebraucht worden ist.
+ pObjFactory->pNewObj = new E3dSphereObj(123);
+ break;
+ case E3D_EXTRUDEOBJ_ID:
+ pObjFactory->pNewObj = new E3dExtrudeObj();
+ break;
+ case E3D_LATHEOBJ_ID:
+ pObjFactory->pNewObj = new E3dLatheObj();
+ break;
+ case E3D_COMPOUNDOBJ_ID:
+ pObjFactory->pNewObj = new E3dCompoundObject();
+ break;
+ }
+ }
+ return 0;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/polygn3d.cxx b/svx/source/engine3d/polygn3d.cxx
new file mode 100644
index 000000000000..4dd347c544f9
--- /dev/null
+++ b/svx/source/engine3d/polygn3d.cxx
@@ -0,0 +1,364 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/polygn3d.hxx>
+#include <svx/svdpage.hxx>
+#include "globl3d.hxx"
+#include <basegfx/point/b3dpoint.hxx>
+#include <svx/sdr/contact/viewcontactofe3dpolygon.hxx>
+#include <basegfx/polygon/b3dpolygon.hxx>
+#include <basegfx/polygon/b3dpolygontools.hxx>
+
+TYPEINIT1(E3dPolygonObj, E3dCompoundObject);
+
+//////////////////////////////////////////////////////////////////////////////
+// #110094# DrawContact section
+
+sdr::contact::ViewContact* E3dPolygonObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfE3dPolygon(*this);
+}
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+E3dPolygonObj::E3dPolygonObj(
+ E3dDefaultAttributes& rDefault,
+ const basegfx::B3DPolyPolygon& rPolyPoly3D,
+ BOOL bLinOnly)
+: E3dCompoundObject(rDefault),
+ bLineOnly(bLinOnly)
+{
+ // Geometrie setzen
+ SetPolyPolygon3D(rPolyPoly3D);
+
+ // Default-Normals erzeugen
+ CreateDefaultNormals();
+
+ // Default-Texturkoordinaten erzeugen
+ CreateDefaultTexture();
+}
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+E3dPolygonObj::E3dPolygonObj(
+ E3dDefaultAttributes& rDefault,
+ const basegfx::B3DPolyPolygon& rPolyPoly3D,
+ const basegfx::B3DPolyPolygon& rPolyNormals3D,
+ BOOL bLinOnly)
+: E3dCompoundObject(rDefault),
+ bLineOnly(bLinOnly)
+{
+ // Geometrie und Normalen setzen
+ SetPolyPolygon3D(rPolyPoly3D);
+ SetPolyNormals3D(rPolyNormals3D);
+
+ // Default-Texturkoordinaten erzeugen
+ CreateDefaultTexture();
+}
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+E3dPolygonObj::E3dPolygonObj(
+ E3dDefaultAttributes& rDefault,
+ const basegfx::B3DPolyPolygon& rPolyPoly3D,
+ const basegfx::B3DPolyPolygon& rPolyNormals3D,
+ const basegfx::B2DPolyPolygon& rPolyTexture2D,
+ BOOL bLinOnly)
+: E3dCompoundObject(rDefault),
+ bLineOnly(bLinOnly)
+{
+ SetPolyPolygon3D(rPolyPoly3D);
+ SetPolyNormals3D(rPolyNormals3D);
+ SetPolyTexture2D(rPolyTexture2D);
+}
+
+/*************************************************************************
+|*
+|* Leer-Konstruktor
+|*
+\************************************************************************/
+
+E3dPolygonObj::E3dPolygonObj()
+: E3dCompoundObject(),
+ bLineOnly(false) // added missing initialisation
+{
+ // Keine Geometrie erzeugen
+}
+
+/*************************************************************************
+|*
+|* Default-Normalen erzeugen
+|*
+\************************************************************************/
+
+void E3dPolygonObj::CreateDefaultNormals()
+{
+ basegfx::B3DPolyPolygon aPolyNormals;
+
+ // Komplettes PolyPolygon mit den Ebenennormalen anlegen
+ for(sal_uInt32 a(0L); a < aPolyPoly3D.count(); a++)
+ {
+ // Quellpolygon finden
+ const basegfx::B3DPolygon aPolygon(aPolyPoly3D.getB3DPolygon(a));
+
+ // Neues Polygon fuer Normalen anlegen
+ basegfx::B3DPolygon aNormals;
+
+ // Normale holen (und umdrehen)
+ basegfx::B3DVector aNormal(-basegfx::tools::getNormal(aPolygon));
+
+ // Neues Polygon fuellen
+ for(sal_uInt32 b(0L); b < aPolygon.count(); b++)
+ {
+ aNormals.append(aNormal);
+ }
+
+ // Neues Polygon in PolyPolygon einfuegen
+ aPolyNormals.append(aNormals);
+ }
+
+ // Default-Normalen setzen
+ SetPolyNormals3D(aPolyNormals);
+}
+
+/*************************************************************************
+|*
+|* Default-Texturkoordinaten erzeugen
+|*
+\************************************************************************/
+
+void E3dPolygonObj::CreateDefaultTexture()
+{
+ basegfx::B2DPolyPolygon aPolyTexture;
+
+ // Komplettes PolyPolygon mit den Texturkoordinaten anlegen
+ // Die Texturkoordinaten erstrecken sich ueber X,Y und Z
+ // ueber die gesamten Extremwerte im Bereich 0.0 .. 1.0
+ for(sal_uInt32 a(0L); a < aPolyPoly3D.count(); a++)
+ {
+ // Quellpolygon finden
+ const basegfx::B3DPolygon& aPolygon(aPolyPoly3D.getB3DPolygon(a));
+
+ // Gesamtgroesse des Objektes feststellen
+ basegfx::B3DRange aVolume(basegfx::tools::getRange(aPolygon));
+
+ // Normale holen
+ basegfx::B3DVector aNormal(basegfx::tools::getNormal(aPolygon));
+ aNormal.setX(fabs(aNormal.getX()));
+ aNormal.setY(fabs(aNormal.getY()));
+ aNormal.setZ(fabs(aNormal.getZ()));
+
+ // Entscheiden, welche Koordinaten als Source fuer das
+ // Mapping benutzt werden sollen
+ UINT16 nSourceMode = 0;
+
+ // Groessten Freiheitsgrad ermitteln
+ if(!(aNormal.getX() > aNormal.getY() && aNormal.getX() > aNormal.getZ()))
+ {
+ if(aNormal.getY() > aNormal.getZ())
+ {
+ // Y ist am groessten, benutze X,Z als mapping
+ nSourceMode = 1;
+ }
+ else
+ {
+ // Z ist am groessten, benutze X,Y als mapping
+ nSourceMode = 2;
+ }
+ }
+
+ // Neues Polygon fuer Texturkoordinaten anlegen
+ basegfx::B2DPolygon aTexture;
+
+ // Neues Polygon fuellen
+ for(sal_uInt32 b(0L); b < aPolygon.count(); b++)
+ {
+ basegfx::B2DPoint aTex;
+ const basegfx::B3DPoint aCandidate(aPolygon.getB3DPoint(b));
+
+ switch(nSourceMode)
+ {
+ case 0: // Quelle ist Y,Z
+ if(aVolume.getHeight())
+ aTex.setX((aCandidate.getY() - aVolume.getMinY()) / aVolume.getHeight());
+ if(aVolume.getDepth())
+ aTex.setY((aCandidate.getZ() - aVolume.getMinZ()) / aVolume.getDepth());
+ break;
+
+ case 1: // Quelle ist X,Z
+ if(aVolume.getWidth())
+ aTex.setX((aCandidate.getX() - aVolume.getMinX()) / aVolume.getWidth());
+ if(aVolume.getDepth())
+ aTex.setY((aCandidate.getZ() - aVolume.getMinZ()) / aVolume.getDepth());
+ break;
+
+ case 2: // Quelle ist X,Y
+ if(aVolume.getWidth())
+ aTex.setX((aCandidate.getX() - aVolume.getMinX()) / aVolume.getWidth());
+ if(aVolume.getHeight())
+ aTex.setY((aCandidate.getY() - aVolume.getMinY()) / aVolume.getHeight());
+ break;
+ }
+
+ aTexture.append(aTex);
+ }
+
+ // Neues Polygon in PolyPolygon einfuegen
+ aPolyTexture.append(aTexture);
+ }
+
+ // Default-Texturkoordinaten setzen
+ SetPolyTexture2D(aPolyTexture);
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+E3dPolygonObj::~E3dPolygonObj()
+{
+}
+
+/*************************************************************************
+|*
+|* Identifier zurueckgeben
+|*
+\************************************************************************/
+
+UINT16 E3dPolygonObj::GetObjIdentifier() const
+{
+ return E3D_POLYGONOBJ_ID;
+}
+
+/*************************************************************************
+|*
+|* Polygon setzen
+|*
+\************************************************************************/
+
+void E3dPolygonObj::SetPolyPolygon3D(const basegfx::B3DPolyPolygon& rNewPolyPoly3D)
+{
+ if ( aPolyPoly3D != rNewPolyPoly3D )
+ {
+ // Neues PolyPolygon; kopieren
+ aPolyPoly3D = rNewPolyPoly3D;
+
+ // Geometrie neu erzeugen
+ ActionChanged();
+ }
+}
+
+void E3dPolygonObj::SetPolyNormals3D(const basegfx::B3DPolyPolygon& rNewPolyNormals3D)
+{
+ if ( aPolyNormals3D != rNewPolyNormals3D )
+ {
+ // Neue Normalen; kopieren
+ aPolyNormals3D = rNewPolyNormals3D;
+
+ // Geometrie neu erzeugen
+ ActionChanged();
+ }
+}
+
+void E3dPolygonObj::SetPolyTexture2D(const basegfx::B2DPolyPolygon& rNewPolyTexture2D)
+{
+ if ( aPolyTexture2D != rNewPolyTexture2D )
+ {
+ // Neue Texturkoordinaten; kopieren
+ aPolyTexture2D = rNewPolyTexture2D;
+
+ // Geometrie neu erzeugen
+ ActionChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* Wandle das Objekt in ein Gruppenobjekt bestehend aus 6 Polygonen
+|*
+\************************************************************************/
+
+SdrObject *E3dPolygonObj::DoConvertToPolyObj(BOOL /*bBezier*/) const
+{
+ return NULL;
+}
+
+/*************************************************************************
+|*
+|* Zuweisungsoperator
+|*
+\************************************************************************/
+
+void E3dPolygonObj::operator=(const SdrObject& rObj)
+{
+ // erstmal alle Childs kopieren
+ E3dCompoundObject::operator=(rObj);
+
+ // weitere Parameter kopieren
+ const E3dPolygonObj& r3DObj = (const E3dPolygonObj&)rObj;
+
+ aPolyPoly3D = r3DObj.aPolyPoly3D;
+ aPolyNormals3D = r3DObj.aPolyNormals3D;
+ aPolyTexture2D = r3DObj.aPolyTexture2D;
+ bLineOnly = r3DObj.bLineOnly;
+}
+
+/*************************************************************************
+|*
+|* LineOnly setzen
+|*
+\************************************************************************/
+
+void E3dPolygonObj::SetLineOnly(BOOL bNew)
+{
+ if(bNew != bLineOnly)
+ {
+ bLineOnly = bNew;
+ ActionChanged();
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/polysc3d.cxx b/svx/source/engine3d/polysc3d.cxx
new file mode 100644
index 000000000000..86e251a9c35e
--- /dev/null
+++ b/svx/source/engine3d/polysc3d.cxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/xfillit.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdogrp.hxx>
+#include "svditer.hxx"
+#include <svx/svdetc.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdpool.hxx>
+#include <svl/style.hxx>
+#include "globl3d.hxx"
+#include <svx/polysc3d.hxx>
+#include <svx/xlnclit.hxx>
+#include <svl/metitem.hxx>
+#include <svx/xtable.hxx>
+#include <svx/xlnwtit.hxx>
+
+#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1(E3dPolyScene, E3dScene);
+
+E3dPolyScene::E3dPolyScene()
+: E3dScene()
+{
+}
+
+E3dPolyScene::E3dPolyScene(E3dDefaultAttributes& rDefault)
+: E3dScene(rDefault)
+{
+}
+
+/*************************************************************************
+|*
+|* Identifier zurueckgeben
+|*
+\************************************************************************/
+
+UINT16 E3dPolyScene::GetObjIdentifier() const
+{
+ return E3D_POLYSCENE_ID;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx
new file mode 100644
index 000000000000..43e0db674257
--- /dev/null
+++ b/svx/source/engine3d/scene3d.cxx
@@ -0,0 +1,887 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+#include "svditer.hxx"
+
+#if defined( UNX ) || defined( ICC )
+#include <stdlib.h>
+#endif
+#include "globl3d.hxx"
+#include <svx/svdpage.hxx>
+#include <svl/style.hxx>
+#include <svx/scene3d.hxx>
+#include <svx/e3dundo.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svxids.hrc>
+#include <editeng/colritem.hxx>
+#include <svx/e3ditem.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/svx3ditems.hxx>
+#include <svl/whiter.hxx>
+#include <svx/xflftrit.hxx>
+#include <svx/sdr/properties/e3dsceneproperties.hxx>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+#include <svx/svddrag.hxx>
+#include <helperminimaldepth3d.hxx>
+#include <algorithm>
+#include <drawinglayer/geometry/viewinformation3d.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <svx/e3dsceneupdater.hxx>
+
+#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
+
+//////////////////////////////////////////////////////////////////////////////
+// #110988#
+
+class ImpRemap3DDepth
+{
+ sal_uInt32 mnOrdNum;
+ double mfMinimalDepth;
+
+ // bitfield
+ unsigned mbIsScene : 1;
+
+public:
+ ImpRemap3DDepth(sal_uInt32 nOrdNum, double fMinimalDepth);
+ ImpRemap3DDepth(sal_uInt32 nOrdNum);
+ ~ImpRemap3DDepth();
+
+ // for ::std::sort
+ bool operator<(const ImpRemap3DDepth& rComp) const;
+
+ sal_uInt32 GetOrdNum() const { return mnOrdNum; }
+ sal_Bool IsScene() const { return mbIsScene; }
+};
+
+ImpRemap3DDepth::ImpRemap3DDepth(sal_uInt32 nOrdNum, double fMinimalDepth)
+: mnOrdNum(nOrdNum),
+ mfMinimalDepth(fMinimalDepth),
+ mbIsScene(sal_False)
+{
+}
+
+ImpRemap3DDepth::ImpRemap3DDepth(sal_uInt32 nOrdNum)
+: mnOrdNum(nOrdNum),
+ mbIsScene(sal_True)
+{
+}
+
+ImpRemap3DDepth::~ImpRemap3DDepth()
+{
+}
+
+bool ImpRemap3DDepth::operator<(const ImpRemap3DDepth& rComp) const
+{
+ if(IsScene())
+ {
+ return sal_False;
+ }
+ else
+ {
+ if(rComp.IsScene())
+ {
+ return sal_True;
+ }
+ else
+ {
+ return mfMinimalDepth < rComp.mfMinimalDepth;
+ }
+ }
+}
+
+// typedefs for a vector of ImpRemap3DDepths
+typedef ::std::vector< ImpRemap3DDepth > ImpRemap3DDepthVector;
+
+//////////////////////////////////////////////////////////////////////////////
+// #110988#
+
+class Imp3DDepthRemapper
+{
+ ImpRemap3DDepthVector maVector;
+
+public:
+ Imp3DDepthRemapper(E3dScene& rScene);
+ ~Imp3DDepthRemapper();
+
+ sal_uInt32 RemapOrdNum(sal_uInt32 nOrdNum) const;
+};
+
+Imp3DDepthRemapper::Imp3DDepthRemapper(E3dScene& rScene)
+{
+ // only called when rScene.GetSubList() and nObjCount > 1L
+ SdrObjList* pList = rScene.GetSubList();
+ const sal_uInt32 nObjCount(pList->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nObjCount; a++)
+ {
+ SdrObject* pCandidate = pList->GetObj(a);
+
+ if(pCandidate)
+ {
+ if(pCandidate->ISA(E3dCompoundObject))
+ {
+ // single 3d object, calc depth
+ const double fMinimalDepth(getMinimalDepthInViewCoordinates(static_cast< const E3dCompoundObject& >(*pCandidate)));
+ ImpRemap3DDepth aEntry(a, fMinimalDepth);
+ maVector.push_back(aEntry);
+ }
+ else
+ {
+ // scene, use standard entry for scene
+ ImpRemap3DDepth aEntry(a);
+ maVector.push_back(aEntry);
+ }
+ }
+ }
+
+ // now, we need to sort the maVector by it's members minimal depth. The
+ // smaller, the nearer to the viewer.
+ ::std::sort(maVector.begin(), maVector.end());
+}
+
+Imp3DDepthRemapper::~Imp3DDepthRemapper()
+{
+}
+
+sal_uInt32 Imp3DDepthRemapper::RemapOrdNum(sal_uInt32 nOrdNum) const
+{
+ if(nOrdNum < maVector.size())
+ {
+ nOrdNum = maVector[(maVector.size() - 1) - nOrdNum].GetOrdNum();
+ }
+
+ return nOrdNum;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* E3dScene::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::E3dSceneProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// #110094# DrawContact section
+
+sdr::contact::ViewContact* E3dScene::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfE3dScene(*this);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(E3dScene, E3dObject);
+
+/*************************************************************************
+|*
+|* E3dScene-Konstruktor
+|*
+\************************************************************************/
+
+E3dScene::E3dScene()
+: E3dObject(),
+ aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
+ mp3DDepthRemapper(0L),
+ bDrawOnlySelected(false)
+{
+ // Defaults setzen
+ E3dDefaultAttributes aDefault;
+ SetDefaultAttributes(aDefault);
+}
+
+E3dScene::E3dScene(E3dDefaultAttributes& rDefault)
+: E3dObject(),
+ aCamera(basegfx::B3DPoint(0.0, 0.0, 4.0), basegfx::B3DPoint()),
+ mp3DDepthRemapper(0L),
+ bDrawOnlySelected(false)
+{
+ // Defaults setzen
+ SetDefaultAttributes(rDefault);
+}
+
+void E3dScene::SetDefaultAttributes(E3dDefaultAttributes& /*rDefault*/)
+{
+ // Fuer OS/2 die FP-Exceptions abschalten
+#if defined(OS2)
+#define SC_FPEXCEPTIONS_ON() _control87( MCW_EM, 0 )
+#define SC_FPEXCEPTIONS_OFF() _control87( MCW_EM, MCW_EM )
+ SC_FPEXCEPTIONS_OFF();
+#endif
+
+ // Fuer WIN95/NT die FP-Exceptions abschalten
+#if defined(WNT) || defined(WIN)
+#define SC_FPEXCEPTIONS_ON() _control87( _MCW_EM, 0 )
+#define SC_FPEXCEPTIONS_OFF() _control87( _MCW_EM, _MCW_EM )
+ SC_FPEXCEPTIONS_OFF();
+#endif
+
+ // Defaults setzen
+ aCamera.SetViewWindow(-2, -2, 4, 4);
+ aCameraSet.SetDeviceRectangle(-2, 2, -2, 2);
+ aCamera.SetDeviceWindow(Rectangle(0, 0, 10, 10));
+ Rectangle aRect(0, 0, 10, 10);
+ aCameraSet.SetViewportRectangle(aRect);
+
+ // set defaults for Camera from ItemPool
+ aCamera.SetProjection(GetPerspective());
+ basegfx::B3DPoint aActualPosition(aCamera.GetPosition());
+ double fNew = GetDistance();
+
+ if(fabs(fNew - aActualPosition.getZ()) > 1.0)
+ {
+ aCamera.SetPosition( basegfx::B3DPoint( aActualPosition.getX(), aActualPosition.getY(), fNew) );
+ }
+
+ fNew = GetFocalLength() / 100.0;
+ aCamera.SetFocalLength(fNew);
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+E3dScene::~E3dScene()
+{
+ // #110988#
+ ImpCleanup3DDepthMapper();
+}
+
+basegfx::B2DPolyPolygon E3dScene::TakeXorPoly() const
+{
+ const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D());
+ const basegfx::B3DPolyPolygon aCubePolyPolygon(CreateWireframe());
+
+ basegfx::B2DPolyPolygon aRetval(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aCubePolyPolygon,
+ aViewInfo3D.getObjectToView()));
+ aRetval.transform(rVCScene.getObjectTransformation());
+
+ return aRetval;
+}
+
+// #110988#
+void E3dScene::ImpCleanup3DDepthMapper()
+{
+ if(mp3DDepthRemapper)
+ {
+ delete mp3DDepthRemapper;
+ mp3DDepthRemapper = 0L;
+ }
+}
+
+// #110988#
+sal_uInt32 E3dScene::RemapOrdNum(sal_uInt32 nNewOrdNum) const
+{
+ if(!mp3DDepthRemapper)
+ {
+ const sal_uInt32 nObjCount(GetSubList() ? GetSubList()->GetObjCount() : 0L);
+
+ if(nObjCount > 1L)
+ {
+ ((E3dScene*)this)->mp3DDepthRemapper = new Imp3DDepthRemapper((E3dScene&)(*this));
+ }
+ }
+
+ if(mp3DDepthRemapper)
+ {
+ return mp3DDepthRemapper->RemapOrdNum(nNewOrdNum);
+ }
+
+ return nNewOrdNum;
+}
+
+/*************************************************************************
+|*
+|* Identifier zurueckgeben
+|*
+\************************************************************************/
+
+UINT16 E3dScene::GetObjIdentifier() const
+{
+ return E3D_SCENE_ID;
+}
+
+void E3dScene::SetBoundRectDirty()
+{
+ E3dScene* pScene = GetScene();
+
+ if(pScene == this)
+ {
+ // avoid resetting aOutRect which in case of a 3D scene used as 2d object
+ // is model data,not re-creatable view data
+ }
+ else
+ {
+ // if not the outmost scene it is used as group in 3d, call parent
+ E3dObject::SetBoundRectDirty();
+ }
+}
+
+/*************************************************************************
+|*
+|* SetSnapRect
+|*
+\************************************************************************/
+
+void E3dScene::NbcSetSnapRect(const Rectangle& rRect)
+{
+ SetRectsDirty();
+ E3dObject::NbcSetSnapRect(rRect);
+ aCamera.SetDeviceWindow(rRect);
+ aCameraSet.SetViewportRectangle((Rectangle&)rRect);
+
+ // #110988#
+ ImpCleanup3DDepthMapper();
+}
+
+/*************************************************************************
+|*
+|* Objekt verschieben
+|*
+\************************************************************************/
+
+void E3dScene::NbcMove(const Size& rSize)
+{
+ Rectangle aNewSnapRect = GetSnapRect();
+ MoveRect(aNewSnapRect, rSize);
+ NbcSetSnapRect(aNewSnapRect);
+}
+
+/*************************************************************************
+|*
+|* Objekt Resizen
+|*
+\************************************************************************/
+
+void E3dScene::NbcResize(const Point& rRef, const Fraction& rXFact,
+ const Fraction& rYFact)
+{
+ Rectangle aNewSnapRect = GetSnapRect();
+ ResizeRect(aNewSnapRect, rRef, rXFact, rYFact);
+ NbcSetSnapRect(aNewSnapRect);
+}
+
+/*************************************************************************
+|*
+|* Neue Kamera setzen, und dabei die Szene und ggf. das BoundVolume
+|* als geaendert markieren
+|*
+\************************************************************************/
+
+void E3dScene::SetCamera(const Camera3D& rNewCamera)
+{
+ // Alte Kamera setzen
+ aCamera = rNewCamera;
+ ((sdr::properties::E3dSceneProperties&)GetProperties()).SetSceneItemsFromCamera();
+
+ SetRectsDirty();
+
+ // Neue Kamera aus alter fuellen
+ Camera3D& rCam = (Camera3D&)GetCamera();
+
+ // Ratio abschalten
+ if(rCam.GetAspectMapping() == AS_NO_MAPPING)
+ GetCameraSet().SetRatio(0.0);
+
+ // Abbildungsgeometrie setzen
+ basegfx::B3DPoint aVRP(rCam.GetViewPoint());
+ basegfx::B3DVector aVPN(aVRP - rCam.GetVRP());
+ basegfx::B3DVector aVUV(rCam.GetVUV());
+
+ // #91047# use SetViewportValues() to set VRP, VPN and VUV as vectors, too.
+ // Else these values would not be exported/imported correctly.
+ GetCameraSet().SetViewportValues(aVRP, aVPN, aVUV);
+
+ // Perspektive setzen
+ GetCameraSet().SetPerspective(rCam.GetProjection() == PR_PERSPECTIVE);
+ GetCameraSet().SetViewportRectangle((Rectangle&)rCam.GetDeviceWindow());
+
+ // #110988#
+ ImpCleanup3DDepthMapper();
+}
+
+/*************************************************************************
+|*
+|* 3D-Objekt einfuegen
+|*
+\************************************************************************/
+
+void E3dScene::NewObjectInserted(const E3dObject* p3DObj)
+{
+ E3dObject::NewObjectInserted(p3DObj);
+
+ if ( p3DObj == this )
+ return;
+
+ // #110988#
+ ImpCleanup3DDepthMapper();
+}
+
+/*************************************************************************
+|*
+|* Parent ueber Aenderung eines Childs informieren
+|*
+\************************************************************************/
+
+void E3dScene::StructureChanged()
+{
+ E3dObject::StructureChanged();
+ SetRectsDirty();
+
+ // #110988#
+ ImpCleanup3DDepthMapper();
+}
+
+/*************************************************************************
+|*
+|* Uebergeordnetes Szenenobjekt bestimmen
+|*
+\************************************************************************/
+
+E3dScene* E3dScene::GetScene() const
+{
+ if(GetParentObj())
+ return GetParentObj()->GetScene();
+ else
+ return (E3dScene*)this;
+}
+
+void E3dScene::removeAllNonSelectedObjects()
+{
+ E3DModifySceneSnapRectUpdater aUpdater(this);
+
+ for(sal_uInt32 a(0); a < maSubList.GetObjCount(); a++)
+ {
+ SdrObject* pObj = maSubList.GetObj(a);
+
+ if(pObj)
+ {
+ bool bRemoveObject(false);
+
+ if(pObj->ISA(E3dScene))
+ {
+ E3dScene* pScene = (E3dScene*)pObj;
+
+ // iterate over this sub-scene
+ pScene->removeAllNonSelectedObjects();
+
+ // check object count. Empty scenes can be deleted
+ const sal_uInt32 nObjCount(pScene->GetSubList() ? pScene->GetSubList()->GetObjCount() : 0);
+
+ if(!nObjCount)
+ {
+ // all objects removed, scene can be removed, too
+ bRemoveObject = true;
+ }
+ }
+ else if(pObj->ISA(E3dCompoundObject))
+ {
+ E3dCompoundObject* pCompound = (E3dCompoundObject*)pObj;
+
+ if(!pCompound->GetSelected())
+ {
+ bRemoveObject = true;
+ }
+ }
+
+ if(bRemoveObject)
+ {
+ maSubList.NbcRemoveObject(pObj->GetOrdNum());
+ a--;
+ SdrObject::Free(pObj);
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Zuweisungsoperator
+|*
+\************************************************************************/
+
+void E3dScene::operator=(const SdrObject& rObj)
+{
+ E3dObject::operator=(rObj);
+
+ const E3dScene& r3DObj = (const E3dScene&) rObj;
+ aCamera = r3DObj.aCamera;
+
+ // neu ab 377:
+ aCameraSet = r3DObj.aCameraSet;
+ ((sdr::properties::E3dSceneProperties&)GetProperties()).SetSceneItemsFromCamera();
+
+ // SetSnapRect(r3DObj.GetSnapRect());
+ InvalidateBoundVolume();
+ RebuildLists();
+ SetRectsDirty();
+
+ // #110988#
+ ImpCleanup3DDepthMapper();
+
+ // #i101941#
+ // After a Scene as model object is cloned, the used
+ // ViewContactOfE3dScene is created and partially used
+ // to calculate Bound/SnapRects, but - since quite some
+ // values are buffered at the VC - not really well
+ // initialized. It would be possible to always watch for
+ // preconditions of buffered data, but this would be expensive
+ // and would create a lot of short living data structures.
+ // It is currently better to flush that data, e.g. by using
+ // ActionChanged at the VC which will for this class
+ // flush that cached data and initalize it's valid reconstruction
+ GetViewContact().ActionChanged();
+}
+
+/*************************************************************************
+|*
+|* Licht- und Labelobjektlisten neu aufbauen (nach Laden, Zuweisung)
+|*
+\************************************************************************/
+
+void E3dScene::RebuildLists()
+{
+ // zuerst loeschen
+ SdrLayerID nCurrLayerID = GetLayer();
+
+ SdrObjListIter a3DIterator(maSubList, IM_FLAT);
+
+ // dann alle Objekte in der Szene pruefen
+ while ( a3DIterator.IsMore() )
+ {
+ E3dObject* p3DObj = (E3dObject*) a3DIterator.Next();
+ p3DObj->NbcSetLayer(nCurrLayerID);
+ NewObjectInserted(p3DObj);
+ }
+}
+
+/*************************************************************************
+|*
+|* erstelle neues GeoData-Objekt
+|*
+\************************************************************************/
+
+SdrObjGeoData *E3dScene::NewGeoData() const
+{
+ return new E3DSceneGeoData;
+}
+
+/*************************************************************************
+|*
+|* uebergebe aktuelle werte an das GeoData-Objekt
+|*
+\************************************************************************/
+
+void E3dScene::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ E3dObject::SaveGeoData (rGeo);
+
+ ((E3DSceneGeoData &) rGeo).aCamera = aCamera;
+}
+
+/*************************************************************************
+|*
+|* uebernehme werte aus dem GeoData-Objekt
+|*
+\************************************************************************/
+
+void E3dScene::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ // #i94832# removed E3DModifySceneSnapRectUpdater here.
+ // It should not be needed, is already part of E3dObject::RestGeoData
+ E3dObject::RestGeoData (rGeo);
+ SetCamera (((E3DSceneGeoData &) rGeo).aCamera);
+}
+
+/*************************************************************************
+|*
+|* Am StyleSheet wurde etwas geaendert, also Scene aendern
+|*
+\************************************************************************/
+
+void E3dScene::Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
+{
+ SetRectsDirty();
+ E3dObject::Notify(rBC, rHint);
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void E3dScene::RotateScene (const Point& rRef, long /*nWink*/, double sn, double cs)
+{
+ Point UpperLeft, LowerRight, Center, NewCenter;
+
+ UpperLeft = aOutRect.TopLeft();
+ LowerRight = aOutRect.BottomRight();
+
+ long dxOutRectHalf = labs(UpperLeft.X() - LowerRight.X());
+ dxOutRectHalf /= 2;
+ long dyOutRectHalf = labs(UpperLeft.Y() - LowerRight.Y());
+ dyOutRectHalf /= 2;
+
+ Rectangle RectQuelle(aOutRect), RectZiel(aOutRect);
+
+ // Nur der Mittelpunkt wird bewegt. Die Ecken werden von NbcMove bewegt.
+ // Fuer das Drehen wird von mir ein kartesisches Koordinatensystem verwendet in dem der Drehpunkt
+ // der Nullpunkt ist und die Y- Achse nach oben ansteigt, die X-Achse nach rechts.
+ // Dies muss bei den Y-Werten beachtet werden. (Auf dem Blatt zeigt die Y-Achse nach unten
+ Center.X() = (UpperLeft.X() + dxOutRectHalf) - rRef.X();
+ Center.Y() = -((UpperLeft.Y() + dyOutRectHalf) - rRef.Y());
+ // Ein paar Spezialfaelle zuerst abhandeln (n*90 Grad n ganzzahlig)
+ if (sn==1.0 && cs==0.0) { // 90deg
+ NewCenter.X() = -Center.Y();
+ NewCenter.Y() = -Center.X();
+ } else if (sn==0.0 && cs==-1.0) { // 180deg
+ NewCenter.X() = -Center.X();
+ NewCenter.Y() = -Center.Y();
+ } else if (sn==-1.0 && cs==0.0) { // 270deg
+ NewCenter.X() = Center.Y();
+ NewCenter.Y() = -Center.X();
+ }
+ else // Hier wird um einen beliebigen Winkel in mathematisch positiver Richtung gedreht!
+ { // xneu = x * cos(alpha) - y * sin(alpha)
+ // yneu = x * sin(alpha) + y * cos(alpha)
+ // Unten Rechts wird nicht gedreht: die Seiten von RectQuelle muessen parallel
+ // zu den Koordinatenachsen bleiben.
+ NewCenter.X() = (long) (Center.X() * cs - Center.Y() * sn);
+ NewCenter.Y() = (long) (Center.X() * sn + Center.Y() * cs);
+ }
+
+ Size Differenz;
+ Point DiffPoint = (NewCenter - Center);
+ Differenz.Width() = DiffPoint.X();
+ Differenz.Height() = -DiffPoint.Y(); // Man beachte dass die Y-Achse nach unten positiv gezaehlt wird.
+ NbcMove (Differenz); // fuehrt die eigentliche Koordinatentransformation durch.
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (singular)
+|*
+\************************************************************************/
+
+void E3dScene::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulScene3d);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (plural)
+|*
+\************************************************************************/
+
+void E3dScene::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralScene3d);
+}
+
+/*************************************************************************
+|*
+|* Die NbcRotate-Routine ueberlaedt die des SdrObject. Die Idee ist die Scene
+|* drehen zu koennen und relativ zur Lage der Scene dann auch die Objekte
+|* in der Scene
+|*
+\************************************************************************/
+
+void E3dScene::NbcSetTransform(const basegfx::B3DHomMatrix& rMatrix)
+{
+ if(maTransformation != rMatrix)
+ {
+ // call parent
+ E3dObject::NbcSetTransform(rMatrix);
+ }
+}
+
+void E3dScene::SetTransform(const basegfx::B3DHomMatrix& rMatrix)
+{
+ if(rMatrix != maTransformation)
+ {
+ // call parent
+ E3dObject::SetTransform(rMatrix);
+ }
+}
+
+void E3dScene::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ // Also derzeit sind die Klebepunkte relativ zum aOutRect der Szene definiert. Vor dem Drehen
+ // werden die Klebepunkte relativ zur Seite definiert. Sie nehmen an der Drehung der Szene noch nicht Teil
+ // dafuer gibt es den
+ SetGlueReallyAbsolute(TRUE);
+
+ // So dass war die Szene, ab jetzt kommen die Objekte in der Szene
+ // 3D-Objekte gibt es nur ein einziges das kann zwar mehrere Flaechen haben aber die Flaechen
+ // muessen ja nicht zusammenhaengend sein
+ // es ermoeglicht den Zugriff auf Kindobjekte
+ // Ich gehe also die gesamte Liste durch und rotiere um die Z-Achse die durch den
+ // Mittelpunkt von aOutRect geht (Satz von Steiner), also RotateZ
+
+ RotateScene (rRef, nWink, sn, cs); // Rotiert die Szene
+ double fWinkelInRad = nWink/100 * F_PI180;
+
+ basegfx::B3DHomMatrix aRotation;
+ aRotation.rotate(0.0, 0.0, fWinkelInRad);
+ NbcSetTransform(aRotation * GetTransform());
+
+ SetRectsDirty(); // Veranlasst eine Neuberechnung aller BoundRects
+ NbcRotateGluePoints(rRef,nWink,sn,cs); // Rotiert die Klebepunkte (die haben noch Koordinaten relativ
+ // zum Urpsung des Blattes
+ SetGlueReallyAbsolute(FALSE); // ab jetzt sind sie wieder relativ zum BoundRect (also dem aOutRect definiert)
+ SetRectsDirty();
+}
+
+/*************************************************************************
+|*
+|* SnapRect berechnen
+|*
+\************************************************************************/
+
+void E3dScene::RecalcSnapRect()
+{
+ E3dScene* pScene = GetScene();
+
+ if(pScene == this)
+ {
+ // Szene wird als 2D-Objekt benutzt, nimm SnapRect aus der
+ // 2D Bildschrimdarstellung
+ Camera3D& rCam = (Camera3D&)pScene->GetCamera();
+ maSnapRect = rCam.GetDeviceWindow();
+ }
+ else
+ {
+ // Szene ist selbst Mitglied einer anderen Szene, hole das
+ // SnapRect als zusammengesetztes Objekt
+ E3dObject::RecalcSnapRect();
+ }
+}
+
+/*************************************************************************
+|*
+|* Aufbrechen
+|*
+\************************************************************************/
+
+BOOL E3dScene::IsBreakObjPossible()
+{
+ // Szene ist aufzubrechen, wenn alle Mitglieder aufzubrechen sind
+ SdrObjListIter a3DIterator(maSubList, IM_DEEPWITHGROUPS);
+
+ while ( a3DIterator.IsMore() )
+ {
+ E3dObject* pObj = (E3dObject*) a3DIterator.Next();
+ DBG_ASSERT(pObj->ISA(E3dObject), "AW: In Szenen sind nur 3D-Objekte erlaubt!");
+ if(!pObj->IsBreakObjPossible())
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+basegfx::B3DVector E3dScene::GetShadowPlaneDirection() const
+{
+ double fWink = (double)GetShadowSlant() * F_PI180;
+ basegfx::B3DVector aShadowPlaneDir(0.0, sin(fWink), cos(fWink));
+ aShadowPlaneDir.normalize();
+ return aShadowPlaneDir;
+}
+
+void E3dScene::SetShadowPlaneDirection(const basegfx::B3DVector& rVec)
+{
+ UINT16 nSceneShadowSlant = (UINT16)((atan2(rVec.getY(), rVec.getZ()) / F_PI180) + 0.5);
+ GetProperties().SetObjectItemDirect(Svx3DShadowSlantItem(nSceneShadowSlant));
+}
+
+basegfx::B2DPolyPolygon E3dScene::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
+{
+ return TakeXorPoly();
+}
+
+bool E3dScene::BegCreate(SdrDragStat& rStat)
+{
+ rStat.SetOrtho4Possible();
+ Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
+ aRect1.Justify();
+ rStat.SetActionRect(aRect1);
+ NbcSetSnapRect(aRect1);
+ return TRUE;
+}
+
+bool E3dScene::MovCreate(SdrDragStat& rStat)
+{
+ Rectangle aRect1;
+ rStat.TakeCreateRect(aRect1);
+ aRect1.Justify();
+ rStat.SetActionRect(aRect1);
+ NbcSetSnapRect(aRect1);
+ SetBoundRectDirty();
+ bSnapRectDirty=TRUE;
+ return TRUE;
+}
+
+bool E3dScene::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ Rectangle aRect1;
+ rStat.TakeCreateRect(aRect1);
+ aRect1.Justify();
+ NbcSetSnapRect(aRect1);
+ SetRectsDirty();
+ return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
+}
+
+bool E3dScene::BckCreate(SdrDragStat& /*rStat*/)
+{
+ return FALSE;
+}
+
+void E3dScene::BrkCreate(SdrDragStat& /*rStat*/)
+{
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/sphere3d.cxx b/svx/source/engine3d/sphere3d.cxx
new file mode 100644
index 000000000000..7ee6a34618d4
--- /dev/null
+++ b/svx/source/engine3d/sphere3d.cxx
@@ -0,0 +1,229 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include "globl3d.hxx"
+#include <svx/sphere3d.hxx>
+
+#include <svx/svxids.hrc>
+#include <svx/svx3ditems.hxx>
+#include <svx/sdr/properties/e3dsphereproperties.hxx>
+#include <basegfx/vector/b3dvector.hxx>
+#include <basegfx/point/b3dpoint.hxx>
+#include <svx/sdr/contact/viewcontactofe3dsphere.hxx>
+#include <basegfx/polygon/b3dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// #110094# DrawContact section
+
+sdr::contact::ViewContact* E3dSphereObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfE3dSphere(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+sdr::properties::BaseProperties* E3dSphereObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::E3dSphereProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(E3dSphereObj, E3dCompoundObject);
+
+/*************************************************************************
+|*
+|* Kugel aus Polygonfacetten nach Laengen und Breitengrad aufbauen
+|*
+\************************************************************************/
+
+E3dSphereObj::E3dSphereObj(E3dDefaultAttributes& rDefault, const basegfx::B3DPoint& rCenter, const basegfx::B3DVector& r3DSize)
+: E3dCompoundObject(rDefault)
+{
+ // Defaults setzen
+ SetDefaultAttributes(rDefault);
+
+ // Uebergebene drueberbuegeln
+ aCenter = rCenter;
+ aSize = r3DSize;
+}
+
+E3dSphereObj::E3dSphereObj()
+: E3dCompoundObject()
+{
+ // Defaults setzen
+ E3dDefaultAttributes aDefault;
+ SetDefaultAttributes(aDefault);
+}
+
+/*************************************************************************
+|*
+|* Kugel erzeugen ohne die Polygone darin zu erzeugen
+|*
+\************************************************************************/
+
+// FG: Dieser Aufruf erfolgt von der 3D-Object Factory (objfac3d.cxx) und zwar ausschliesslich beim
+// laden von Dokumenten. Hier braucht man keinen CreateSphere-Aufruf, denn die wirkliche
+// Anzahl Segmente ist ja noch nicht bekannt. Dies war bis zum 10.2.97 ein (kleines)
+// Speicherleck.
+E3dSphereObj::E3dSphereObj(int /*dummy*/) // den Parameter braucht es um unterscheiden zu koennen, welcher
+{ // der beiden Konstruktoren gemeint ist. Der obige halt per Default
+ // Defaults setzen
+ E3dDefaultAttributes aDefault;
+ SetDefaultAttributes(aDefault);
+}
+
+void E3dSphereObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
+{
+ // Defaults setzen
+ aCenter = rDefault.GetDefaultSphereCenter();
+ aSize = rDefault.GetDefaultSphereSize();
+}
+
+/*************************************************************************
+|*
+|* Identifier zurueckgeben
+|*
+\************************************************************************/
+
+UINT16 E3dSphereObj::GetObjIdentifier() const
+{
+ return E3D_SPHEREOBJ_ID;
+}
+
+/*************************************************************************
+|*
+|* Wandle das Objekt in ein Gruppenobjekt bestehend aus n Polygonen
+|*
+\************************************************************************/
+
+SdrObject *E3dSphereObj::DoConvertToPolyObj(BOOL /*bBezier*/) const
+{
+ return NULL;
+}
+
+/*************************************************************************
+|*
+|* Leer-Konstruktor
+|*
+\************************************************************************/
+
+void E3dSphereObj::ReSegment(sal_uInt32 nHSegs, sal_uInt32 nVSegs)
+{
+ if((nHSegs != GetHorizontalSegments() || nVSegs != GetVerticalSegments()) && (nHSegs != 0 || nVSegs != 0))
+ {
+ GetProperties().SetObjectItemDirect(Svx3DHorizontalSegmentsItem(nHSegs));
+ GetProperties().SetObjectItemDirect(Svx3DVerticalSegmentsItem(nVSegs));
+
+ ActionChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* Zuweisungsoperator
+|*
+\************************************************************************/
+
+void E3dSphereObj::operator=(const SdrObject& rObj)
+{
+ // erstmal alle Childs kopieren
+ E3dCompoundObject::operator=(rObj);
+
+ // weitere Parameter kopieren
+ const E3dSphereObj& r3DObj = (const E3dSphereObj&) rObj;
+
+ aCenter = r3DObj.aCenter;
+ aSize = r3DObj.aSize;
+}
+
+/*************************************************************************
+|*
+|* Lokale Parameter setzen mit Geometrieneuerzeugung
+|*
+\************************************************************************/
+
+void E3dSphereObj::SetCenter(const basegfx::B3DPoint& rNew)
+{
+ if(aCenter != rNew)
+ {
+ aCenter = rNew;
+ ActionChanged();
+ }
+}
+
+void E3dSphereObj::SetSize(const basegfx::B3DVector& rNew)
+{
+ if(aSize != rNew)
+ {
+ aSize = rNew;
+ ActionChanged();
+ }
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (singular)
+|*
+\************************************************************************/
+
+void E3dSphereObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulSphere3d);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+/*************************************************************************
+|*
+|* Get the name of the object (plural)
+|*
+\************************************************************************/
+
+void E3dSphereObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralSphere3d);
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/string3d.src b/svx/source/engine3d/string3d.src
new file mode 100644
index 000000000000..ffcc2e8e8689
--- /dev/null
+++ b/svx/source/engine3d/string3d.src
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ------------------------------------------------------------------
+#include <svx/dialogs.hrc>
+ // pragma -------------------------------------------------------------------
+
+ // Strings fuer die Draw-Dialoge --------------------------------------------
+String RID_SVX_3D_CREATE_LATHE
+{
+ Text [ en-US ] = "Create 3D rotation object" ;
+};
+String RID_SVX_3D_UNDO_EXCHANGE_PASTE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Objekt(e) einfügen : Objekt(e) einf³gen */
+ /* ### ACHTUNG: Neuer Text in Resource? Objekt(e) einfügen : Objekt(e) einf³gen */
+ Text [ en-US ] = "Insert object(s)" ;
+};
+String RID_SVX_3D_UNDO_SEGMENTS
+{
+ Text [ en-US ] = "Number of segments" ;
+};
+String RID_SVX_3D_UNDO_DEEPTH
+{
+ Text [ en-US ] = "Object depth" ;
+};
+String RID_SVX_3D_UNDO_FOCAL
+{
+ Text [ en-US ] = "Focal length" ;
+};
+String RID_SVX_3D_UNDO_CAMPOS
+{
+ Text [ en-US ] = "Camera position" ;
+};
+String RID_SVX_3D_UNDO_ROTATE
+{
+ Text [ en-US ] = "Rotate 3D object" ;
+};
+String RID_SVX_3D_UNDO_EXTRUDE
+{
+ Text [ en-US ] = "Create extrusion object" ;
+};
+String RID_SVX_3D_UNDO_LATHE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Rotationskörper erstellen : Rotationsk÷rper erstellen */
+ /* ### ACHTUNG: Neuer Text in Resource? Rotationskörper erstellen : Rotationsk÷rper erstellen */
+ Text [ en-US ] = "Create rotation object" ;
+};
+String RID_SVX_3D_UNDO_BREAK_LATHE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Rotationskörper aufbrechen : Rotationsk÷rper aufbrechen */
+ /* ### ACHTUNG: Neuer Text in Resource? Rotationskörper aufbrechen : Rotationsk÷rper aufbrechen */
+ Text [ en-US ] = "Split 3D object" ;
+};
+String RID_SVX_3D_UNDO_ATTRIBUTES
+{
+ Text [ en-US ] = "3D Attributes" ;
+};
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/engine3d/svx3ditems.cxx b/svx/source/engine3d/svx3ditems.cxx
new file mode 100644
index 000000000000..fba7365d1287
--- /dev/null
+++ b/svx/source/engine3d/svx3ditems.cxx
@@ -0,0 +1,550 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/svx3ditems.hxx>
+#include <com/sun/star/drawing/NormalsKind.hpp>
+#include <com/sun/star/drawing/TextureProjectionMode.hpp>
+#include <com/sun/star/drawing/TextureKind.hpp>
+#include <com/sun/star/drawing/TextureMode.hpp>
+#include <com/sun/star/drawing/ProjectionMode.hpp>
+#include <com/sun/star/drawing/ShadeMode.hpp>
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+Svx3DPercentDiagonalItem::Svx3DPercentDiagonalItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DOBJ_PERCENT_DIAGONAL, nVal)
+{}
+
+Svx3DBackscaleItem::Svx3DBackscaleItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DOBJ_BACKSCALE, nVal)
+{}
+
+Svx3DDepthItem::Svx3DDepthItem(sal_uInt32 nVal)
+: SfxUInt32Item(SDRATTR_3DOBJ_DEPTH, nVal)
+{}
+
+Svx3DHorizontalSegmentsItem::Svx3DHorizontalSegmentsItem(sal_uInt32 nVal)
+: SfxUInt32Item(SDRATTR_3DOBJ_HORZ_SEGS, nVal)
+{}
+
+Svx3DVerticalSegmentsItem::Svx3DVerticalSegmentsItem(sal_uInt32 nVal)
+: SfxUInt32Item(SDRATTR_3DOBJ_VERT_SEGS, nVal)
+{}
+
+Svx3DEndAngleItem::Svx3DEndAngleItem(sal_uInt32 nVal)
+: SfxUInt32Item(SDRATTR_3DOBJ_END_ANGLE, nVal)
+{}
+
+Svx3DDoubleSidedItem::Svx3DDoubleSidedItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DOBJ_DOUBLE_SIDED, bVal)
+{}
+
+//////////////////////////////////////////////////////////////////////////////
+// #i28528#
+// Added extra Item (Bool) for chart2 to be able to show reduced line geometry
+
+Svx3DReducedLineGeometryItem::Svx3DReducedLineGeometryItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY, bVal)
+{}
+
+sal_uInt16 Svx3DReducedLineGeometryItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
+{
+ return 1;
+}
+
+SfxPoolItem* Svx3DReducedLineGeometryItem::Create(SvStream& rIn, sal_uInt16 nItemVersion) const
+{
+ SfxBoolItem* pRetval = new Svx3DReducedLineGeometryItem();
+
+ if(nItemVersion > 0)
+ {
+ SfxBoolItem aBoolItem(Which(), rIn);
+ pRetval->SetValue(aBoolItem.GetValue());
+ }
+
+ return pRetval;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+Svx3DNormalsKindItem::Svx3DNormalsKindItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DOBJ_NORMALS_KIND, nVal)
+{}
+
+Svx3DNormalsInvertItem::Svx3DNormalsInvertItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DOBJ_NORMALS_INVERT, bVal)
+{}
+
+Svx3DTextureProjectionXItem::Svx3DTextureProjectionXItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DOBJ_TEXTURE_PROJ_X, nVal)
+{}
+
+Svx3DTextureProjectionYItem::Svx3DTextureProjectionYItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DOBJ_TEXTURE_PROJ_Y, nVal)
+{}
+
+Svx3DShadow3DItem::Svx3DShadow3DItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DOBJ_SHADOW_3D, bVal)
+{}
+
+Svx3DMaterialColorItem::Svx3DMaterialColorItem(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DOBJ_MAT_COLOR)
+{}
+
+Svx3DMaterialEmissionItem::Svx3DMaterialEmissionItem(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DOBJ_MAT_EMISSION)
+{}
+
+Svx3DMaterialSpecularItem::Svx3DMaterialSpecularItem(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DOBJ_MAT_SPECULAR)
+{}
+
+Svx3DMaterialSpecularIntensityItem::Svx3DMaterialSpecularIntensityItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY, nVal)
+{}
+
+Svx3DTextureKindItem::Svx3DTextureKindItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DOBJ_TEXTURE_KIND, nVal)
+{}
+
+Svx3DTextureModeItem::Svx3DTextureModeItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DOBJ_TEXTURE_MODE, nVal)
+{}
+
+Svx3DTextureFilterItem::Svx3DTextureFilterItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DOBJ_TEXTURE_FILTER, bVal)
+{}
+
+Svx3DPerspectiveItem::Svx3DPerspectiveItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DSCENE_PERSPECTIVE, nVal)
+{}
+
+Svx3DDistanceItem::Svx3DDistanceItem(sal_uInt32 nVal)
+: SfxUInt32Item(SDRATTR_3DSCENE_DISTANCE, nVal)
+{}
+
+Svx3DFocalLengthItem::Svx3DFocalLengthItem(sal_uInt32 nVal)
+: SfxUInt32Item(SDRATTR_3DSCENE_FOCAL_LENGTH, nVal)
+{}
+
+Svx3DTwoSidedLightingItem::Svx3DTwoSidedLightingItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING, bVal)
+{}
+
+Svx3DLightcolor1Item::Svx3DLightcolor1Item(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DSCENE_LIGHTCOLOR_1)
+{}
+
+Svx3DLightcolor2Item::Svx3DLightcolor2Item(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DSCENE_LIGHTCOLOR_2)
+{}
+
+Svx3DLightcolor3Item::Svx3DLightcolor3Item(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DSCENE_LIGHTCOLOR_3)
+{}
+
+Svx3DLightcolor4Item::Svx3DLightcolor4Item(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DSCENE_LIGHTCOLOR_4)
+{}
+
+Svx3DLightcolor5Item::Svx3DLightcolor5Item(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DSCENE_LIGHTCOLOR_5)
+{}
+
+Svx3DLightcolor6Item::Svx3DLightcolor6Item(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DSCENE_LIGHTCOLOR_6)
+{}
+
+Svx3DLightcolor7Item::Svx3DLightcolor7Item(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DSCENE_LIGHTCOLOR_7)
+{}
+
+Svx3DLightcolor8Item::Svx3DLightcolor8Item(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DSCENE_LIGHTCOLOR_8)
+{}
+
+Svx3DAmbientcolorItem::Svx3DAmbientcolorItem(const Color& rCol)
+: SvxColorItem(rCol, SDRATTR_3DSCENE_AMBIENTCOLOR)
+{}
+
+Svx3DLightOnOff1Item::Svx3DLightOnOff1Item(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DSCENE_LIGHTON_1, bVal)
+{}
+
+Svx3DLightOnOff2Item::Svx3DLightOnOff2Item(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DSCENE_LIGHTON_2, bVal)
+{}
+
+Svx3DLightOnOff3Item::Svx3DLightOnOff3Item(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DSCENE_LIGHTON_3, bVal)
+{}
+
+Svx3DLightOnOff4Item::Svx3DLightOnOff4Item(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DSCENE_LIGHTON_4, bVal)
+{}
+
+Svx3DLightOnOff5Item::Svx3DLightOnOff5Item(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DSCENE_LIGHTON_5, bVal)
+{}
+
+Svx3DLightOnOff6Item::Svx3DLightOnOff6Item(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DSCENE_LIGHTON_6, bVal)
+{}
+
+Svx3DLightOnOff7Item::Svx3DLightOnOff7Item(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DSCENE_LIGHTON_7, bVal)
+{}
+
+Svx3DLightOnOff8Item::Svx3DLightOnOff8Item(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DSCENE_LIGHTON_8, bVal)
+{}
+
+Svx3DLightDirection1Item::Svx3DLightDirection1Item(const basegfx::B3DVector& rVec)
+: SvxB3DVectorItem(SDRATTR_3DSCENE_LIGHTDIRECTION_1, rVec)
+{}
+
+Svx3DLightDirection2Item::Svx3DLightDirection2Item(const basegfx::B3DVector& rVec)
+: SvxB3DVectorItem(SDRATTR_3DSCENE_LIGHTDIRECTION_2, rVec)
+{}
+
+Svx3DLightDirection3Item::Svx3DLightDirection3Item(const basegfx::B3DVector& rVec)
+: SvxB3DVectorItem(SDRATTR_3DSCENE_LIGHTDIRECTION_3, rVec)
+{}
+
+Svx3DLightDirection4Item::Svx3DLightDirection4Item(const basegfx::B3DVector& rVec)
+: SvxB3DVectorItem(SDRATTR_3DSCENE_LIGHTDIRECTION_4, rVec)
+{}
+
+Svx3DLightDirection5Item::Svx3DLightDirection5Item(const basegfx::B3DVector& rVec)
+: SvxB3DVectorItem(SDRATTR_3DSCENE_LIGHTDIRECTION_5, rVec)
+{}
+
+Svx3DLightDirection6Item::Svx3DLightDirection6Item(const basegfx::B3DVector& rVec)
+: SvxB3DVectorItem(SDRATTR_3DSCENE_LIGHTDIRECTION_6, rVec)
+{}
+
+Svx3DLightDirection7Item::Svx3DLightDirection7Item(const basegfx::B3DVector& rVec)
+: SvxB3DVectorItem(SDRATTR_3DSCENE_LIGHTDIRECTION_7, rVec)
+{}
+
+Svx3DLightDirection8Item::Svx3DLightDirection8Item(const basegfx::B3DVector& rVec)
+: SvxB3DVectorItem(SDRATTR_3DSCENE_LIGHTDIRECTION_8, rVec)
+{}
+
+Svx3DShadowSlantItem::Svx3DShadowSlantItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DSCENE_SHADOW_SLANT, nVal)
+{}
+
+Svx3DShadeModeItem::Svx3DShadeModeItem(sal_uInt16 nVal)
+: SfxUInt16Item(SDRATTR_3DSCENE_SHADE_MODE, nVal)
+{}
+
+//////////////////////////////////////////////////////////////////////////////
+// #107245#
+
+Svx3DSmoothNormalsItem::Svx3DSmoothNormalsItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DOBJ_SMOOTH_NORMALS, bVal)
+{}
+
+sal_uInt16 Svx3DSmoothNormalsItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
+{
+ return 1;
+}
+
+SfxPoolItem* Svx3DSmoothNormalsItem::Create(SvStream& rIn, sal_uInt16 nItemVersion) const
+{
+ SfxBoolItem* pRetval = new Svx3DSmoothNormalsItem();
+
+ if(nItemVersion > 0)
+ {
+ SfxBoolItem aBoolItem(Which(), rIn);
+ pRetval->SetValue(aBoolItem.GetValue());
+ }
+
+ return pRetval;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// #107245#
+
+Svx3DSmoothLidsItem::Svx3DSmoothLidsItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DOBJ_SMOOTH_LIDS, bVal)
+{}
+
+sal_uInt16 Svx3DSmoothLidsItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
+{
+ return 1;
+}
+
+SfxPoolItem* Svx3DSmoothLidsItem::Create(SvStream& rIn, sal_uInt16 nItemVersion) const
+{
+ SfxBoolItem* pRetval = new Svx3DSmoothLidsItem();
+
+ if(nItemVersion > 0)
+ {
+ SfxBoolItem aBoolItem(Which(), rIn);
+ pRetval->SetValue(aBoolItem.GetValue());
+ }
+
+ return pRetval;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// #107245#
+
+Svx3DCharacterModeItem::Svx3DCharacterModeItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DOBJ_CHARACTER_MODE, bVal)
+{}
+
+sal_uInt16 Svx3DCharacterModeItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
+{
+ return 1;
+}
+
+SfxPoolItem* Svx3DCharacterModeItem::Create(SvStream& rIn, sal_uInt16 nItemVersion) const
+{
+ SfxBoolItem* pRetval = new Svx3DCharacterModeItem();
+
+ if(nItemVersion > 0)
+ {
+ SfxBoolItem aBoolItem(Which(), rIn);
+ pRetval->SetValue(aBoolItem.GetValue());
+ }
+
+ return pRetval;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// #107245#
+
+Svx3DCloseFrontItem::Svx3DCloseFrontItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DOBJ_CLOSE_FRONT, bVal)
+{}
+
+sal_uInt16 Svx3DCloseFrontItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
+{
+ return 1;
+}
+
+SfxPoolItem* Svx3DCloseFrontItem::Create(SvStream& rIn, sal_uInt16 nItemVersion) const
+{
+ SfxBoolItem* pRetval = new Svx3DCloseFrontItem();
+
+ if(nItemVersion > 0)
+ {
+ SfxBoolItem aBoolItem(Which(), rIn);
+ pRetval->SetValue(aBoolItem.GetValue());
+ }
+
+ return pRetval;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// #107245#
+
+Svx3DCloseBackItem::Svx3DCloseBackItem(BOOL bVal)
+: SfxBoolItem(SDRATTR_3DOBJ_CLOSE_BACK, bVal)
+{}
+
+sal_uInt16 Svx3DCloseBackItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
+{
+ return 1;
+}
+
+SfxPoolItem* Svx3DCloseBackItem::Create(SvStream& rIn, sal_uInt16 nItemVersion) const
+{
+ SfxBoolItem* pRetval = new Svx3DCloseBackItem();
+
+ if(nItemVersion > 0)
+ {
+ SfxBoolItem aBoolItem(Which(), rIn);
+ pRetval->SetValue(aBoolItem.GetValue());
+ }
+
+ return pRetval;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+// Svx3DNormalsKindItem: use drawing::NormalsKind
+bool Svx3DNormalsKindItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::NormalsKind)GetValue();
+ return true;
+}
+
+bool Svx3DNormalsKindItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::NormalsKind eVar;
+ if(!(rVal >>= eVar))
+ return false;
+ SetValue((sal_Int16)eVar);
+ return true;
+}
+
+SfxPoolItem* Svx3DNormalsKindItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new Svx3DNormalsKindItem(*this);
+}
+
+// Svx3DTextureProjectionXItem: use drawing::TextureProjectionMode
+bool Svx3DTextureProjectionXItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::TextureProjectionMode)GetValue();
+ return true;
+}
+
+bool Svx3DTextureProjectionXItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::TextureProjectionMode eVar;
+ if(!(rVal >>= eVar))
+ return false;
+ SetValue((sal_Int16)eVar);
+ return true;
+}
+
+SfxPoolItem* Svx3DTextureProjectionXItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new Svx3DTextureProjectionXItem(*this);
+}
+
+// Svx3DTextureProjectionYItem: use drawing::TextureProjectionMode
+bool Svx3DTextureProjectionYItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::TextureProjectionMode)GetValue();
+ return true;
+}
+
+bool Svx3DTextureProjectionYItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::TextureProjectionMode eVar;
+ if(!(rVal >>= eVar))
+ return false;
+ SetValue((sal_Int16)eVar);
+ return true;
+}
+
+SfxPoolItem* Svx3DTextureProjectionYItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new Svx3DTextureProjectionYItem(*this);
+}
+
+// Svx3DTextureKindItem: use drawing::TextureKind
+bool Svx3DTextureKindItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::TextureKind)GetValue();
+ return true;
+}
+
+bool Svx3DTextureKindItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::TextureKind eVar;
+ if(!(rVal >>= eVar))
+ return false;
+ SetValue((sal_Int16)eVar);
+ return true;
+}
+
+SfxPoolItem* Svx3DTextureKindItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new Svx3DTextureKindItem(*this);
+}
+
+// Svx3DTextureModeItem: use drawing:TextureMode
+bool Svx3DTextureModeItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::TextureMode)GetValue();
+ return true;
+}
+
+bool Svx3DTextureModeItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::TextureMode eVar;
+ if(!(rVal >>= eVar))
+ return false;
+ SetValue((sal_Int16)eVar);
+ return true;
+}
+
+SfxPoolItem* Svx3DTextureModeItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new Svx3DTextureModeItem(*this);
+}
+
+// Svx3DPerspectiveItem: use drawing::ProjectionMode
+bool Svx3DPerspectiveItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::ProjectionMode)GetValue();
+ return true;
+}
+
+bool Svx3DPerspectiveItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::ProjectionMode eVar;
+ if(!(rVal >>= eVar))
+ return false;
+ SetValue((sal_Int16)eVar);
+ return true;
+}
+
+SfxPoolItem* Svx3DPerspectiveItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new Svx3DPerspectiveItem(*this);
+}
+
+// Svx3DShadeModeItem: use drawing::ShadeMode
+bool Svx3DShadeModeItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::ShadeMode)GetValue();
+ return true;
+}
+
+bool Svx3DShadeModeItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::ShadeMode eVar;
+ if(!(rVal >>= eVar))
+ return false;
+ SetValue((sal_Int16)eVar);
+ return true;
+}
+
+SfxPoolItem* Svx3DShadeModeItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new Svx3DShadeModeItem(*this);
+}
+
+// EOF
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx
new file mode 100644
index 000000000000..e1b3102f168b
--- /dev/null
+++ b/svx/source/engine3d/view3d.cxx
@@ -0,0 +1,1930 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <vcl/wrkwin.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdopath.hxx>
+#include <tools/shl.hxx>
+#include "svditer.hxx"
+#include <svx/svdpool.hxx>
+#include <svx/svdorect.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svxids.hrc>
+#include <editeng/colritem.hxx>
+#include <svx/xtable.hxx>
+#include <svx/svdview.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include "globl3d.hxx"
+#include <svx/obj3d.hxx>
+#include <svx/lathe3d.hxx>
+#include <svx/sphere3d.hxx>
+#include <svx/extrud3d.hxx>
+#include <svx/cube3d.hxx>
+#include <svx/polysc3d.hxx>
+#include "dragmt3d.hxx"
+#include <svx/view3d.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xflbmtit.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/sdr/overlay/overlaypolypolygon.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <sdrpaintwindow.hxx>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+#include <drawinglayer/geometry/viewinformation3d.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
+#include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+
+#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
+
+TYPEINIT1(E3dView, SdrView);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Migrate Marking
+
+class Impl3DMirrorConstructOverlay
+{
+ // The OverlayObjects
+ ::sdr::overlay::OverlayObjectList maObjects;
+
+ // the view
+ const E3dView& mrView;
+
+ // the object count
+ sal_uInt32 mnCount;
+
+ // the unmirrored polygons
+ basegfx::B2DPolyPolygon* mpPolygons;
+
+ // the overlay geometry from selected objects
+ drawinglayer::primitive2d::Primitive2DSequence maFullOverlay;
+
+public:
+ Impl3DMirrorConstructOverlay(const E3dView& rView);
+ ~Impl3DMirrorConstructOverlay();
+
+ void SetMirrorAxis(Point aMirrorAxisA, Point aMirrorAxisB);
+};
+
+Impl3DMirrorConstructOverlay::Impl3DMirrorConstructOverlay(const E3dView& rView)
+: maObjects(),
+ mrView(rView),
+ mnCount(rView.GetMarkedObjectCount()),
+ mpPolygons(0),
+ maFullOverlay()
+{
+ if(mnCount)
+ {
+ if(mrView.IsSolidDragging())
+ {
+ SdrPageView* pPV = rView.GetSdrPageView();
+
+ if(pPV && pPV->PageWindowCount())
+ {
+ sdr::contact::ObjectContact& rOC = pPV->GetPageWindow(0)->GetObjectContact();
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ // Do not use the last ViewPort set at the OC at the last ProcessDisplay()
+ rOC.resetViewPort();
+
+ for(sal_uInt32 a(0);a < mnCount;a++)
+ {
+ SdrObject* pObject = mrView.GetMarkedObjectByIndex(a);
+
+ if(pObject)
+ {
+ sdr::contact::ViewContact& rVC = pObject->GetViewContact();
+ sdr::contact::ViewObjectContact& rVOC = rVC.GetViewObjectContact(rOC);
+
+ const drawinglayer::primitive2d::Primitive2DSequence aNewSequence(rVOC.getPrimitive2DSequenceHierarchy(aDisplayInfo));
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(maFullOverlay, aNewSequence);
+ }
+ }
+ }
+ }
+ else
+ {
+ mpPolygons = new basegfx::B2DPolyPolygon[mnCount];
+
+ for(sal_uInt32 a(0); a < mnCount; a++)
+ {
+ SdrObject* pObject = mrView.GetMarkedObjectByIndex(a);
+ mpPolygons[mnCount - (a + 1)] = pObject->TakeXorPoly();
+ }
+ }
+ }
+}
+
+Impl3DMirrorConstructOverlay::~Impl3DMirrorConstructOverlay()
+{
+ // The OverlayObjects are cleared using the destructor of OverlayObjectList.
+ // That destructor calls clear() at the list which removes all objects from the
+ // OverlayManager and deletes them.
+ if(!mrView.IsSolidDragging())
+ {
+ delete[] mpPolygons;
+ }
+}
+
+void Impl3DMirrorConstructOverlay::SetMirrorAxis(Point aMirrorAxisA, Point aMirrorAxisB)
+{
+ // get rid of old overlay objects
+ maObjects.clear();
+
+ // create new ones
+ for(sal_uInt32 a(0); a < mrView.PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = mrView.GetPaintWindow(a);
+ ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
+
+ if(pTargetOverlay)
+ {
+ // buld transfoprmation: translate and rotate so that given edge is
+ // on x axis, them mirror in y and translate back
+ const basegfx::B2DVector aEdge(aMirrorAxisB.X() - aMirrorAxisA.X(), aMirrorAxisB.Y() - aMirrorAxisA.Y());
+ basegfx::B2DHomMatrix aMatrixTransform(basegfx::tools::createTranslateB2DHomMatrix(
+ -aMirrorAxisA.X(), -aMirrorAxisA.Y()));
+ aMatrixTransform.rotate(-atan2(aEdge.getY(), aEdge.getX()));
+ aMatrixTransform.scale(1.0, -1.0);
+ aMatrixTransform.rotate(atan2(aEdge.getY(), aEdge.getX()));
+ aMatrixTransform.translate(aMirrorAxisA.X(), aMirrorAxisA.Y());
+
+ if(mrView.IsSolidDragging())
+ {
+ if(maFullOverlay.hasElements())
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aContent(maFullOverlay);
+
+ if(!aMatrixTransform.isIdentity())
+ {
+ // embed in transformation group
+ drawinglayer::primitive2d::Primitive2DReference aTransformPrimitive2D(new drawinglayer::primitive2d::TransformPrimitive2D(aMatrixTransform, aContent));
+ aContent = drawinglayer::primitive2d::Primitive2DSequence(&aTransformPrimitive2D, 1);
+ }
+
+ // if we have full overlay from selected objects, embed with 50% transparence, the
+ // transformation is added to the OverlayPrimitive2DSequenceObject
+ drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparencePrimitive2D(new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(aContent, 0.5));
+ aContent = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedTransparencePrimitive2D, 1);
+
+ sdr::overlay::OverlayPrimitive2DSequenceObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aContent);
+
+ pTargetOverlay->add(*pNew);
+ maObjects.append(*pNew);
+ }
+ }
+ else
+ {
+ for(sal_uInt32 b(0); b < mnCount; b++)
+ {
+ // apply to polygon
+ basegfx::B2DPolyPolygon aPolyPolygon(mpPolygons[b]);
+ aPolyPolygon.transform(aMatrixTransform);
+
+ ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aPolyPolygon);
+ pTargetOverlay->add(*pNew);
+ maObjects.append(*pNew);
+ }
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Konstruktor 1
+|*
+\************************************************************************/
+
+E3dView::E3dView(SdrModel* pModel, OutputDevice* pOut) :
+ SdrView(pModel, pOut)
+{
+ InitView ();
+}
+
+/*************************************************************************
+|*
+|* DrawMarkedObj ueberladen, da eventuell nur einzelne 3D-Objekte
+|* gezeichnet werden sollen
+|*
+\************************************************************************/
+
+void E3dView::DrawMarkedObj(OutputDevice& rOut) const
+{
+ // Existieren 3D-Objekte, deren Szenen nicht selektiert sind?
+ BOOL bSpecialHandling = FALSE;
+ E3dScene *pScene = NULL;
+
+ long nCnt = GetMarkedObjectCount();
+ for(long nObjs = 0;nObjs < nCnt;nObjs++)
+ {
+ SdrObject *pObj = GetMarkedObjectByIndex(nObjs);
+ if(pObj && pObj->ISA(E3dCompoundObject))
+ {
+ // zugehoerige Szene
+ pScene = ((E3dCompoundObject*)pObj)->GetScene();
+ if(pScene && !IsObjMarked(pScene))
+ bSpecialHandling = TRUE;
+ }
+ // Alle SelectionFlags zuruecksetzen
+ if(pObj && pObj->ISA(E3dObject))
+ {
+ pScene = ((E3dObject*)pObj)->GetScene();
+ if(pScene)
+ pScene->SetSelected(FALSE);
+ }
+ }
+
+ if(bSpecialHandling)
+ {
+ // SelectionFlag bei allen zu 3D Objekten gehoerigen
+ // Szenen und deren Objekten auf nicht selektiert setzen
+ long nObjs;
+ for(nObjs = 0;nObjs < nCnt;nObjs++)
+ {
+ SdrObject *pObj = GetMarkedObjectByIndex(nObjs);
+ if(pObj && pObj->ISA(E3dCompoundObject))
+ {
+ // zugehoerige Szene
+ pScene = ((E3dCompoundObject*)pObj)->GetScene();
+ if(pScene)
+ pScene->SetSelected(FALSE);
+ }
+ }
+
+ // bei allen direkt selektierten Objekten auf selektiert setzen
+ SdrMark* pM = NULL;
+
+ for(nObjs = 0;nObjs < nCnt;nObjs++)
+ {
+ SdrObject *pObj = GetMarkedObjectByIndex(nObjs);
+ if(pObj && pObj->ISA(E3dObject))
+ {
+ // Objekt markieren
+ E3dObject* p3DObj = (E3dObject*)pObj;
+ p3DObj->SetSelected(TRUE);
+ pScene = p3DObj->GetScene();
+ pM = GetSdrMarkByIndex(nObjs);
+ }
+ }
+
+ if(pScene)
+ {
+ // code from parent
+ SortMarkedObjects();
+
+ pScene->SetDrawOnlySelected(TRUE);
+ pScene->SingleObjectPainter(rOut); // #110094#-17
+ pScene->SetDrawOnlySelected(FALSE);
+ }
+
+ // SelectionFlag zuruecksetzen
+ for(nObjs = 0;nObjs < nCnt;nObjs++)
+ {
+ SdrObject *pObj = GetMarkedObjectByIndex(nObjs);
+ if(pObj && pObj->ISA(E3dCompoundObject))
+ {
+ // zugehoerige Szene
+ pScene = ((E3dCompoundObject*)pObj)->GetScene();
+ if(pScene)
+ pScene->SetSelected(FALSE);
+ }
+ }
+ }
+ else
+ {
+ // call parent
+ SdrExchangeView::DrawMarkedObj(rOut);
+ }
+}
+
+/*************************************************************************
+|*
+|* Model holen ueberladen, da bei einzelnen 3D Objekten noch eine Szene
+|* untergeschoben werden muss
+|*
+\************************************************************************/
+
+SdrModel* E3dView::GetMarkedObjModel() const
+{
+ // Existieren 3D-Objekte, deren Szenen nicht selektiert sind?
+ bool bSpecialHandling(false);
+ const sal_uInt32 nCount(GetMarkedObjectCount());
+ sal_uInt32 nObjs(0);
+ E3dScene *pScene = 0;
+
+ for(nObjs = 0; nObjs < nCount; nObjs++)
+ {
+ const SdrObject* pObj = GetMarkedObjectByIndex(nObjs);
+
+ if(!bSpecialHandling && pObj && pObj->ISA(E3dCompoundObject))
+ {
+ // if the object is selected, but it's scene not,
+ // we need special handling
+ pScene = ((E3dCompoundObject*)pObj)->GetScene();
+
+ if(pScene && !IsObjMarked(pScene))
+ {
+ bSpecialHandling = true;
+ }
+ }
+
+ if(pObj && pObj->ISA(E3dObject))
+ {
+ // reset all selection flags at 3D objects
+ pScene = ((E3dObject*)pObj)->GetScene();
+
+ if(pScene)
+ {
+ pScene->SetSelected(false);
+ }
+ }
+ }
+
+ if(!bSpecialHandling)
+ {
+ // call parent
+ return SdrView::GetMarkedObjModel();
+ }
+
+ SdrModel* pNewModel = 0;
+ Rectangle aSelectedSnapRect;
+
+ // set 3d selection flags at all directly selected objects
+ // and collect SnapRect of selected objects
+ for(nObjs = 0; nObjs < nCount; nObjs++)
+ {
+ SdrObject *pObj = GetMarkedObjectByIndex(nObjs);
+
+ if(pObj && pObj->ISA(E3dCompoundObject))
+ {
+ // mark object, but not scenes
+ E3dCompoundObject* p3DObj = (E3dCompoundObject*)pObj;
+ p3DObj->SetSelected(true);
+ aSelectedSnapRect.Union(p3DObj->GetSnapRect());
+ }
+ }
+
+ // create new mark list which contains all indirectly selected3d
+ // scenes as selected objects
+ SdrMarkList aOldML(GetMarkedObjectList());
+ SdrMarkList aNewML;
+ SdrMarkList& rCurrentMarkList = ((E3dView*)this)->GetMarkedObjectListWriteAccess();
+ rCurrentMarkList = aNewML;
+
+ for(nObjs = 0; nObjs < nCount; nObjs++)
+ {
+ SdrObject *pObj = aOldML.GetMark(nObjs)->GetMarkedSdrObj();
+
+ if(pObj && pObj->ISA(E3dObject))
+ {
+ pScene = ((E3dObject*)pObj)->GetScene();
+
+ if(pScene && !IsObjMarked(pScene) && GetSdrPageView())
+ {
+ ((E3dView*)this)->MarkObj(pScene, GetSdrPageView(), FALSE, TRUE);
+ }
+ }
+ }
+
+ // call parent. This will copy all scenes and the selection flags at the 3d objectss. So
+ // it will be possible to delete all non-selected 3d objects from the cloned 3d scenes
+ pNewModel = SdrView::GetMarkedObjModel();
+
+ if(pNewModel)
+ {
+ for(sal_uInt16 nPg(0); nPg < pNewModel->GetPageCount(); nPg++)
+ {
+ const SdrPage* pSrcPg=pNewModel->GetPage(nPg);
+ const sal_uInt32 nObAnz(pSrcPg->GetObjCount());
+
+ for(sal_uInt32 nOb(0); nOb < nObAnz; nOb++)
+ {
+ const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
+
+ if(pSrcOb->ISA(E3dScene))
+ {
+ pScene = (E3dScene*)pSrcOb;
+
+ // delete all not intentionally cloned 3d objects
+ pScene->removeAllNonSelectedObjects();
+
+ // reset select flags and set SnapRect of all selected objects
+ pScene->SetSelected(false);
+ pScene->SetSnapRect(aSelectedSnapRect);
+ }
+ }
+ }
+ }
+
+ // restore old selection
+ rCurrentMarkList = aOldML;
+
+ // model zurueckgeben
+ return pNewModel;
+}
+
+/*************************************************************************
+|*
+|* Bei Paste muss - falls in eine Scene eingefuegt wird - die
+|* Objekte der Szene eingefuegt werden, die Szene selbst aber nicht
+|*
+\************************************************************************/
+
+BOOL E3dView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, UINT32 nOptions)
+{
+ BOOL bRetval = FALSE;
+
+ // Liste holen
+ Point aPos(rPos);
+ SdrObjList* pDstList = pLst;
+ ImpGetPasteObjList(aPos, pDstList);
+
+ if(!pDstList)
+ return FALSE;
+
+ // Owner der Liste holen
+ SdrObject* pOwner = pDstList->GetOwnerObj();
+ if(pOwner && pOwner->ISA(E3dScene))
+ {
+ E3dScene* pDstScene = (E3dScene*)pOwner;
+ BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_EXCHANGE_PASTE));
+
+ // Alle Objekte aus E3dScenes kopieren und direkt einfuegen
+ for(sal_uInt16 nPg(0); nPg < rMod.GetPageCount(); nPg++)
+ {
+ const SdrPage* pSrcPg=rMod.GetPage(nPg);
+ sal_uInt32 nObAnz(pSrcPg->GetObjCount());
+
+ // calculate offset for paste
+ Rectangle aR = pSrcPg->GetAllObjBoundRect();
+ Point aDist(aPos - aR.Center());
+
+ // Unterobjekte von Szenen einfuegen
+ for(sal_uInt32 nOb(0); nOb < nObAnz; nOb++)
+ {
+ const SdrObject* pSrcOb = pSrcPg->GetObj(nOb);
+ if(pSrcOb->ISA(E3dScene))
+ {
+ E3dScene* pSrcScene = (E3dScene*)pSrcOb;
+ ImpCloneAll3DObjectsToDestScene(pSrcScene, pDstScene, aDist);
+ }
+ }
+ }
+ EndUndo();
+ }
+ else
+ {
+ // call parent
+ bRetval = SdrView::Paste(rMod, rPos, pLst, nOptions);
+ }
+
+ // und Rueckgabewert liefern
+ return bRetval;
+}
+
+// #83403# Service routine used from local Clone() and from SdrCreateView::EndCreateObj(...)
+BOOL E3dView::ImpCloneAll3DObjectsToDestScene(E3dScene* pSrcScene, E3dScene* pDstScene, Point /*aOffset*/)
+{
+ BOOL bRetval(FALSE);
+
+ if(pSrcScene && pDstScene)
+ {
+ const sdr::contact::ViewContactOfE3dScene& rVCSceneDst = static_cast< sdr::contact::ViewContactOfE3dScene& >(pDstScene->GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3DDst(rVCSceneDst.getViewInformation3D());
+ const sdr::contact::ViewContactOfE3dScene& rVCSceneSrc = static_cast< sdr::contact::ViewContactOfE3dScene& >(pSrcScene->GetViewContact());
+ const drawinglayer::geometry::ViewInformation3D aViewInfo3DSrc(rVCSceneSrc.getViewInformation3D());
+
+ for(sal_uInt32 i(0); i < pSrcScene->GetSubList()->GetObjCount(); i++)
+ {
+ E3dCompoundObject* pCompoundObj = dynamic_cast< E3dCompoundObject* >(pSrcScene->GetSubList()->GetObj(i));
+
+ if(pCompoundObj)
+ {
+ // #116235#
+ E3dCompoundObject* pNewCompoundObj = dynamic_cast< E3dCompoundObject* >(pCompoundObj->Clone());
+
+ if(pNewCompoundObj)
+ {
+ // get dest scene's current range in 3D world coordinates
+ const basegfx::B3DHomMatrix aSceneToWorldTrans(pDstScene->GetFullTransform());
+ basegfx::B3DRange aSceneRange(pDstScene->GetBoundVolume());
+ aSceneRange.transform(aSceneToWorldTrans);
+
+ // get new object's implied object transformation
+ const basegfx::B3DHomMatrix aNewObjectTrans(pNewCompoundObj->GetTransform());
+
+ // get new object's range in 3D world coordinates in dest scene
+ // as if it were already added
+ const basegfx::B3DHomMatrix aObjectToWorldTrans(aSceneToWorldTrans * aNewObjectTrans);
+ basegfx::B3DRange aObjectRange(pNewCompoundObj->GetBoundVolume());
+ aObjectRange.transform(aObjectToWorldTrans);
+
+ // get scale adaption
+ const basegfx::B3DVector aSceneScale(aSceneRange.getRange());
+ const basegfx::B3DVector aObjectScale(aObjectRange.getRange());
+ double fScale(1.0);
+
+ // if new object's size in X,Y or Z is bigger that 80% of dest scene, adapt scale
+ // to not change the scene by the inserted object
+ const double fSizeFactor(0.5);
+
+ if(aObjectScale.getX() * fScale > aSceneScale.getX() * fSizeFactor)
+ {
+ const double fObjSize(aObjectScale.getX() * fScale);
+ const double fFactor((aSceneScale.getX() * fSizeFactor) / (basegfx::fTools::equalZero(fObjSize) ? 1.0 : fObjSize));
+ fScale *= fFactor;
+ }
+
+ if(aObjectScale.getY() * fScale > aSceneScale.getY() * fSizeFactor)
+ {
+ const double fObjSize(aObjectScale.getY() * fScale);
+ const double fFactor((aSceneScale.getY() * fSizeFactor) / (basegfx::fTools::equalZero(fObjSize) ? 1.0 : fObjSize));
+ fScale *= fFactor;
+ }
+
+ if(aObjectScale.getZ() * fScale > aSceneScale.getZ() * fSizeFactor)
+ {
+ const double fObjSize(aObjectScale.getZ() * fScale);
+ const double fFactor((aSceneScale.getZ() * fSizeFactor) / (basegfx::fTools::equalZero(fObjSize) ? 1.0 : fObjSize));
+ fScale *= fFactor;
+ }
+
+ // get translation adaption
+ const basegfx::B3DPoint aSceneCenter(aSceneRange.getCenter());
+ const basegfx::B3DPoint aObjectCenter(aObjectRange.getCenter());
+
+ // build full modification transform. The object's transformation
+ // shall be modified, so start at object coordinates; transform to 3d world coor
+ basegfx::B3DHomMatrix aModifyingTransform(aObjectToWorldTrans);
+
+ // translate to absolute center in 3d world coor
+ aModifyingTransform.translate(-aObjectCenter.getX(), -aObjectCenter.getY(), -aObjectCenter.getZ());
+
+ // scale to dest size in 3d world coor
+ aModifyingTransform.scale(fScale, fScale, fScale);
+
+ // translate to dest scene center in 3d world coor
+ aModifyingTransform.translate(aSceneCenter.getX(), aSceneCenter.getY(), aSceneCenter.getZ());
+
+ // transform from 3d world to dest object coordinates
+ basegfx::B3DHomMatrix aWorldToObject(aObjectToWorldTrans);
+ aWorldToObject.invert();
+ aModifyingTransform = aWorldToObject * aModifyingTransform;
+
+ // correct implied object transform by applying changing one in object coor
+ pNewCompoundObj->SetTransform(aModifyingTransform * aNewObjectTrans);
+
+ // fill and insert new object
+ pNewCompoundObj->SetModel(pDstScene->GetModel());
+ pNewCompoundObj->SetPage(pDstScene->GetPage());
+ pNewCompoundObj->NbcSetLayer(pCompoundObj->GetLayer());
+ pNewCompoundObj->NbcSetStyleSheet(pCompoundObj->GetStyleSheet(), sal_True);
+ pDstScene->Insert3DObj(pNewCompoundObj);
+ bRetval = TRUE;
+
+ // Undo anlegen
+ if( GetModel()->IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNewCompoundObj));
+ }
+ }
+ }
+ }
+
+ return bRetval;
+}
+
+/*************************************************************************
+|*
+|* 3D-Konvertierung moeglich?
+|*
+\************************************************************************/
+
+BOOL E3dView::IsConvertTo3DObjPossible() const
+{
+ BOOL bAny3D(FALSE);
+ BOOL bGroupSelected(FALSE);
+ BOOL bRetval(TRUE);
+
+ for(sal_uInt32 a=0;!bAny3D && a<GetMarkedObjectCount();a++)
+ {
+ SdrObject *pObj = GetMarkedObjectByIndex(a);
+ if(pObj)
+ {
+ ImpIsConvertTo3DPossible(pObj, bAny3D, bGroupSelected);
+ }
+ }
+
+ bRetval = !bAny3D
+ && (
+ IsConvertToPolyObjPossible(FALSE)
+ || IsConvertToPathObjPossible(FALSE)
+ || IsImportMtfPossible());
+ return bRetval;
+}
+
+void E3dView::ImpIsConvertTo3DPossible(SdrObject* pObj, BOOL& rAny3D,
+ BOOL& rGroupSelected) const
+{
+ if(pObj)
+ {
+ if(pObj->ISA(E3dObject))
+ {
+ rAny3D = TRUE;
+ }
+ else
+ {
+ if(pObj->IsGroupObject())
+ {
+ SdrObjListIter aIter(*pObj, IM_DEEPNOGROUPS);
+ while(aIter.IsMore())
+ {
+ SdrObject* pNewObj = aIter.Next();
+ ImpIsConvertTo3DPossible(pNewObj, rAny3D, rGroupSelected);
+ }
+ rGroupSelected = TRUE;
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* 3D-Konvertierung zu Extrude ausfuehren
+|*
+\************************************************************************/
+#include <editeng/eeitem.hxx>
+
+void E3dView::ImpChangeSomeAttributesFor3DConversion(SdrObject* pObj)
+{
+ if(pObj->ISA(SdrTextObj))
+ {
+ const SfxItemSet& rSet = pObj->GetMergedItemSet();
+ const SvxColorItem& rTextColorItem = (const SvxColorItem&)rSet.Get(EE_CHAR_COLOR);
+ if(rTextColorItem.GetValue() == RGB_Color(COL_BLACK))
+ {
+ // Bei schwarzen Textobjekten wird die Farbe auf grau gesetzt
+ if(pObj->GetPage())
+ {
+ // #84864# if black is only default attribute from
+ // pattern set it hard so that it is used in undo.
+ pObj->SetMergedItem(SvxColorItem(RGB_Color(COL_BLACK), EE_CHAR_COLOR));
+
+ // add undo now
+ if( GetModel()->IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, false));
+ }
+
+ pObj->SetMergedItem(SvxColorItem(RGB_Color(COL_GRAY), EE_CHAR_COLOR));
+ }
+ }
+}
+
+void E3dView::ImpChangeSomeAttributesFor3DConversion2(SdrObject* pObj)
+{
+ if(pObj->ISA(SdrPathObj))
+ {
+ const SfxItemSet& rSet = pObj->GetMergedItemSet();
+ sal_Int32 nLineWidth = ((const XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue();
+ XLineStyle eLineStyle = (XLineStyle)((const XLineStyleItem&)rSet.Get(XATTR_LINESTYLE)).GetValue();
+ XFillStyle eFillStyle = ITEMVALUE(rSet, XATTR_FILLSTYLE, XFillStyleItem);
+
+ if(((SdrPathObj*)pObj)->IsClosed()
+ && eLineStyle == XLINE_SOLID
+ && !nLineWidth
+ && eFillStyle != XFILL_NONE)
+ {
+ if(pObj->GetPage() && GetModel()->IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, false));
+ pObj->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pObj->SetMergedItem(XLineWidthItem(0L));
+ }
+ }
+}
+
+void E3dView::ImpCreateSingle3DObjectFlat(E3dScene* pScene, SdrObject* pObj, BOOL bExtrude, double fDepth, basegfx::B2DHomMatrix& rLatheMat)
+{
+ // Einzelnes PathObject, dieses umwanden
+ SdrPathObj* pPath = PTR_CAST(SdrPathObj, pObj);
+
+ if(pPath)
+ {
+ E3dDefaultAttributes aDefault = Get3DDefaultAttributes();
+ if(bExtrude)
+ aDefault.SetDefaultExtrudeCharacterMode(TRUE);
+ else
+ aDefault.SetDefaultLatheCharacterMode(TRUE);
+
+ // ItemSet des Ursprungsobjektes holen
+ SfxItemSet aSet(pObj->GetMergedItemSet());
+
+ XFillStyle eFillStyle = ITEMVALUE(aSet, XATTR_FILLSTYLE, XFillStyleItem);
+
+ // Linienstil ausschalten
+ aSet.Put(XLineStyleItem(XLINE_NONE));
+
+ // Feststellen, ob ein FILL_Attribut gesetzt ist.
+ if(!pPath->IsClosed() || eFillStyle == XFILL_NONE)
+ {
+ // Das SdrPathObj ist nicht gefuellt, lasse die
+ // vordere und hintere Flaeche weg. Ausserdem ist
+ // eine beidseitige Darstellung notwendig.
+ aDefault.SetDefaultExtrudeCloseFront(FALSE);
+ aDefault.SetDefaultExtrudeCloseBack(FALSE);
+
+ aSet.Put(Svx3DDoubleSidedItem(TRUE));
+
+ // Fuellattribut setzen
+ aSet.Put(XFillStyleItem(XFILL_SOLID));
+
+ // Fuellfarbe muss auf Linienfarbe, da das Objekt vorher
+ // nur eine Linie war
+ Color aColorLine = ((const XLineColorItem&)(aSet.Get(XATTR_LINECOLOR))).GetColorValue();
+ aSet.Put(XFillColorItem(String(), aColorLine));
+ }
+
+ // Neues Extrude-Objekt erzeugen
+ E3dObject* p3DObj = NULL;
+ if(bExtrude)
+ {
+ p3DObj = new E3dExtrudeObj(aDefault, pPath->GetPathPoly(), fDepth);
+ }
+ else
+ {
+ basegfx::B2DPolyPolygon aPolyPoly2D(pPath->GetPathPoly());
+ aPolyPoly2D.transform(rLatheMat);
+ p3DObj = new E3dLatheObj(aDefault, aPolyPoly2D);
+ }
+
+ // Attribute setzen
+ if(p3DObj)
+ {
+ p3DObj->NbcSetLayer(pObj->GetLayer());
+
+ p3DObj->SetMergedItemSet(aSet);
+
+ p3DObj->NbcSetStyleSheet(pObj->GetStyleSheet(), sal_True);
+
+ // Neues 3D-Objekt einfuegen
+ pScene->Insert3DObj(p3DObj);
+ }
+ }
+}
+
+void E3dView::ImpCreate3DObject(E3dScene* pScene, SdrObject* pObj, BOOL bExtrude, double fDepth, basegfx::B2DHomMatrix& rLatheMat)
+{
+ if(pObj)
+ {
+ // change text color attribute for not so dark colors
+ if(pObj->IsGroupObject())
+ {
+ SdrObjListIter aIter(*pObj, IM_DEEPWITHGROUPS);
+ while(aIter.IsMore())
+ {
+ SdrObject* pGroupMember = aIter.Next();
+ ImpChangeSomeAttributesFor3DConversion(pGroupMember);
+ }
+ }
+ else
+ ImpChangeSomeAttributesFor3DConversion(pObj);
+
+ // convert completely to path objects
+ SdrObject* pNewObj1 = pObj->ConvertToPolyObj(FALSE, FALSE);
+
+ if(pNewObj1)
+ {
+ // change text color attribute for not so dark colors
+ if(pNewObj1->IsGroupObject())
+ {
+ SdrObjListIter aIter(*pNewObj1, IM_DEEPWITHGROUPS);
+ while(aIter.IsMore())
+ {
+ SdrObject* pGroupMember = aIter.Next();
+ ImpChangeSomeAttributesFor3DConversion2(pGroupMember);
+ }
+ }
+ else
+ ImpChangeSomeAttributesFor3DConversion2(pNewObj1);
+
+ // convert completely to path objects
+ SdrObject* pNewObj2 = pObj->ConvertToContourObj(pNewObj1, TRUE);
+
+ if(pNewObj2)
+ {
+ // add all to flat scene
+ if(pNewObj2->IsGroupObject())
+ {
+ SdrObjListIter aIter(*pNewObj2, IM_DEEPWITHGROUPS);
+ while(aIter.IsMore())
+ {
+ SdrObject* pGroupMember = aIter.Next();
+ ImpCreateSingle3DObjectFlat(pScene, pGroupMember, bExtrude, fDepth, rLatheMat);
+ }
+ }
+ else
+ ImpCreateSingle3DObjectFlat(pScene, pNewObj2, bExtrude, fDepth, rLatheMat);
+
+ // delete zwi object
+ if(pNewObj2 != pObj && pNewObj2 != pNewObj1 && pNewObj2)
+ SdrObject::Free( pNewObj2 );
+ }
+
+ // delete zwi object
+ if(pNewObj1 != pObj && pNewObj1)
+ SdrObject::Free( pNewObj1 );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* 3D-Konvertierung zu Extrude steuern
+|*
+\************************************************************************/
+
+void E3dView::ConvertMarkedObjTo3D(BOOL bExtrude, basegfx::B2DPoint aPnt1, basegfx::B2DPoint aPnt2)
+{
+ if(AreObjectsMarked())
+ {
+ // Undo anlegen
+ if(bExtrude)
+ BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_EXTRUDE));
+ else
+ BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_LATHE));
+
+ // Neue Szene fuer zu erzeugende 3D-Objekte anlegen
+ E3dScene* pScene = new E3dPolyScene(Get3DDefaultAttributes());
+
+ // Rechteck bestimmen und evtl. korrigieren
+ Rectangle aRect = GetAllMarkedRect();
+ if(aRect.GetWidth() <= 1)
+ aRect.SetSize(Size(500, aRect.GetHeight()));
+ if(aRect.GetHeight() <= 1)
+ aRect.SetSize(Size(aRect.GetWidth(), 500));
+
+ // Tiefe relativ zur Groesse der Selektion bestimmen
+ double fDepth = 0.0;
+ double fRot3D = 0.0;
+ basegfx::B2DHomMatrix aLatheMat;
+
+ if(bExtrude)
+ {
+ double fW = (double)aRect.GetWidth();
+ double fH = (double)aRect.GetHeight();
+ fDepth = sqrt(fW*fW + fH*fH) / 6.0;
+ }
+ if(!bExtrude)
+ {
+ // Transformation fuer Polygone Rotationskoerper erstellen
+ if(aPnt1 != aPnt2)
+ {
+ // Rotation um Kontrollpunkt1 mit eigestelltem Winkel
+ // fuer 3D Koordinaten
+ basegfx::B2DPoint aDiff(aPnt1 - aPnt2);
+ fRot3D = atan2(aDiff.getY(), aDiff.getX()) - F_PI2;
+
+ if(basegfx::fTools::equalZero(fabs(fRot3D)))
+ fRot3D = 0.0;
+
+ if(fRot3D != 0.0)
+ {
+ aLatheMat = basegfx::tools::createRotateAroundPoint(aPnt2, -fRot3D)
+ * aLatheMat;
+ }
+ }
+
+ if(aPnt2.getX() != 0.0)
+ {
+ // Translation auf Y=0 - Achse
+ aLatheMat.translate(-aPnt2.getX(), 0.0);
+ }
+ else
+ {
+ aLatheMat.translate((double)-aRect.Left(), 0.0);
+ }
+
+ // Inverse Matrix bilden, um die Zielausdehnung zu bestimmen
+ basegfx::B2DHomMatrix aInvLatheMat(aLatheMat);
+ aInvLatheMat.invert();
+
+ // SnapRect Ausdehnung mittels Spiegelung an der Rotationsachse
+ // erweitern
+ for(UINT32 a=0;a<GetMarkedObjectCount();a++)
+ {
+ SdrMark* pMark = GetSdrMarkByIndex(a);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ Rectangle aTurnRect = pObj->GetSnapRect();
+ basegfx::B2DPoint aRot;
+ Point aRotPnt;
+
+ aRot = basegfx::B2DPoint(aTurnRect.Left(), -aTurnRect.Top());
+ aRot *= aLatheMat;
+ aRot.setX(-aRot.getX());
+ aRot *= aInvLatheMat;
+ aRotPnt = Point((long)(aRot.getX() + 0.5), (long)(-aRot.getY() - 0.5));
+ aRect.Union(Rectangle(aRotPnt, aRotPnt));
+
+ aRot = basegfx::B2DPoint(aTurnRect.Left(), -aTurnRect.Bottom());
+ aRot *= aLatheMat;
+ aRot.setX(-aRot.getX());
+ aRot *= aInvLatheMat;
+ aRotPnt = Point((long)(aRot.getX() + 0.5), (long)(-aRot.getY() - 0.5));
+ aRect.Union(Rectangle(aRotPnt, aRotPnt));
+
+ aRot = basegfx::B2DPoint(aTurnRect.Right(), -aTurnRect.Top());
+ aRot *= aLatheMat;
+ aRot.setX(-aRot.getX());
+ aRot *= aInvLatheMat;
+ aRotPnt = Point((long)(aRot.getX() + 0.5), (long)(-aRot.getY() - 0.5));
+ aRect.Union(Rectangle(aRotPnt, aRotPnt));
+
+ aRot = basegfx::B2DPoint(aTurnRect.Right(), -aTurnRect.Bottom());
+ aRot *= aLatheMat;
+ aRot.setX(-aRot.getX());
+ aRot *= aInvLatheMat;
+ aRotPnt = Point((long)(aRot.getX() + 0.5), (long)(-aRot.getY() - 0.5));
+ aRect.Union(Rectangle(aRotPnt, aRotPnt));
+ }
+ }
+
+ // Ueber die Selektion gehen und in 3D wandeln, komplett mit
+ // Umwandeln in SdrPathObject, auch Schriften
+ for(UINT32 a=0;a<GetMarkedObjectCount();a++)
+ {
+ SdrMark* pMark = GetSdrMarkByIndex(a);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ ImpCreate3DObject(pScene, pObj, bExtrude, fDepth, aLatheMat);
+ }
+
+ if(pScene->GetSubList() && pScene->GetSubList()->GetObjCount() != 0)
+ {
+ // Alle angelegten Objekte Tiefenarrangieren
+ if(bExtrude)
+ DoDepthArrange(pScene, fDepth);
+
+ // 3D-Objekte auf die Mitte des Gesamtrechtecks zentrieren
+ basegfx::B3DPoint aCenter(pScene->GetBoundVolume().getCenter());
+ basegfx::B3DHomMatrix aMatrix;
+
+ aMatrix.translate(-aCenter.getX(), -aCenter.getY(), -aCenter.getZ());
+ pScene->SetTransform(aMatrix * pScene->GetTransform()); // #112587#
+
+ // Szene initialisieren
+ pScene->NbcSetSnapRect(aRect);
+ basegfx::B3DRange aBoundVol = pScene->GetBoundVolume();
+ InitScene(pScene, (double)aRect.GetWidth(), (double)aRect.GetHeight(), aBoundVol.getDepth());
+
+ // Szene anstelle des ersten selektierten Objektes einfuegen
+ // und alle alten Objekte weghauen
+ SdrObject* pRepObj = GetMarkedObjectByIndex(0);
+ SdrPageView* pPV = GetSdrPageViewOfMarkedByIndex(0);
+ MarkObj(pRepObj, pPV, TRUE);
+ ReplaceObjectAtView(pRepObj, *pPV, pScene, FALSE);
+ DeleteMarked();
+ MarkObj(pScene, pPV);
+
+ // Rotationskoerper um Rotationsachse drehen
+ basegfx::B3DHomMatrix aRotate;
+
+ if(!bExtrude && fRot3D != 0.0)
+ {
+ aRotate.rotate(0.0, 0.0, fRot3D);
+ }
+
+ // Default-Rotation setzen
+ {
+ double XRotateDefault = 20;
+ aRotate.rotate(DEG2RAD(XRotateDefault), 0.0, 0.0);
+ }
+
+ if(!aRotate.isIdentity())
+ {
+ pScene->SetTransform(aRotate * pScene->GetTransform());
+ }
+
+ // SnapRects der Objekte ungueltig
+ pScene->SetSnapRect(aRect);
+ }
+ else
+ {
+ // Es wurden keine 3D Objekte erzeugt, schmeiss alles weg
+ delete pScene;
+ }
+
+ // Undo abschliessen
+ EndUndo();
+ }
+}
+
+/*************************************************************************
+|*
+|* Alle enthaltenen Extrude-Objekte Tiefenarrangieren
+|*
+\************************************************************************/
+
+struct E3dDepthNeighbour
+{
+ E3dDepthNeighbour* mpNext;
+ E3dExtrudeObj* mpObj;
+ basegfx::B2DPolyPolygon maPreparedPolyPolygon;
+
+ E3dDepthNeighbour()
+ : mpNext(0),
+ mpObj(0),
+ maPreparedPolyPolygon()
+ {
+ }
+};
+
+struct E3dDepthLayer
+{
+ E3dDepthLayer* mpDown;
+ E3dDepthNeighbour* mpNext;
+
+ E3dDepthLayer()
+ : mpDown(0),
+ mpNext(0)
+ {
+ }
+
+ ~E3dDepthLayer()
+ {
+ while(mpNext)
+ {
+ E3dDepthNeighbour* pSucc = mpNext->mpNext;
+ delete mpNext;
+ mpNext = pSucc;
+ }
+ }
+};
+
+void E3dView::DoDepthArrange(E3dScene* pScene, double fDepth)
+{
+ if(pScene && pScene->GetSubList() && pScene->GetSubList()->GetObjCount() > 1)
+ {
+ SdrObjList* pSubList = pScene->GetSubList();
+ SdrObjListIter aIter(*pSubList, IM_FLAT);
+ E3dDepthLayer* pBaseLayer = NULL;
+ E3dDepthLayer* pLayer = NULL;
+ INT32 nNumLayers = 0;
+
+ while(aIter.IsMore())
+ {
+ E3dExtrudeObj* pExtrudeObj = dynamic_cast< E3dExtrudeObj* >(aIter.Next());
+
+ if(pExtrudeObj)
+ {
+ const basegfx::B2DPolyPolygon aExtrudePoly(
+ basegfx::tools::prepareForPolygonOperation(pExtrudeObj->GetExtrudePolygon()));
+ const SfxItemSet& rLocalSet = pExtrudeObj->GetMergedItemSet();
+ const XFillStyle eLocalFillStyle = ITEMVALUE(rLocalSet, XATTR_FILLSTYLE, XFillStyleItem);
+ const Color aLocalColor = ((const XFillColorItem&)(rLocalSet.Get(XATTR_FILLCOLOR))).GetColorValue();
+
+ // sort in ExtrudeObj
+ if(pLayer)
+ {
+ // do we have overlap with an object of this layer?
+ bool bOverlap(false);
+ E3dDepthNeighbour* pAct = pLayer->mpNext;
+
+ while(!bOverlap && pAct)
+ {
+ // do pAct->mpObj and pExtrudeObj overlap? Check by
+ // using logical AND clipping
+ const basegfx::B2DPolyPolygon aAndPolyPolygon(
+ basegfx::tools::solvePolygonOperationAnd(
+ aExtrudePoly,
+ pAct->maPreparedPolyPolygon));
+
+ bOverlap = (0 != aAndPolyPolygon.count());
+
+ if(bOverlap)
+ {
+ // second ciriteria: is another fillstyle or color used?
+ const SfxItemSet& rCompareSet = pAct->mpObj->GetMergedItemSet();
+
+ XFillStyle eCompareFillStyle = ITEMVALUE(rCompareSet, XATTR_FILLSTYLE, XFillStyleItem);
+
+ if(eLocalFillStyle == eCompareFillStyle)
+ {
+ if(eLocalFillStyle == XFILL_SOLID)
+ {
+ Color aCompareColor = ((const XFillColorItem&)(rCompareSet.Get(XATTR_FILLCOLOR))).GetColorValue();
+
+ if(aCompareColor == aLocalColor)
+ {
+ bOverlap = FALSE;
+ }
+ }
+ else if(eLocalFillStyle == XFILL_NONE)
+ {
+ bOverlap = FALSE;
+ }
+ }
+ }
+
+ pAct = pAct->mpNext;
+ }
+
+ if(bOverlap)
+ {
+ // yes, start a new layer
+ pLayer->mpDown = new E3dDepthLayer;
+ pLayer = pLayer->mpDown;
+ nNumLayers++;
+ pLayer->mpNext = new E3dDepthNeighbour;
+ pLayer->mpNext->mpObj = pExtrudeObj;
+ pLayer->mpNext->maPreparedPolyPolygon = aExtrudePoly;
+ }
+ else
+ {
+ // no, add to current layer
+ E3dDepthNeighbour* pNewNext = new E3dDepthNeighbour;
+ pNewNext->mpObj = pExtrudeObj;
+ pNewNext->maPreparedPolyPolygon = aExtrudePoly;
+ pNewNext->mpNext = pLayer->mpNext;
+ pLayer->mpNext = pNewNext;
+ }
+ }
+ else
+ {
+ // first layer ever
+ pBaseLayer = new E3dDepthLayer;
+ pLayer = pBaseLayer;
+ nNumLayers++;
+ pLayer->mpNext = new E3dDepthNeighbour;
+ pLayer->mpNext->mpObj = pExtrudeObj;
+ pLayer->mpNext->maPreparedPolyPolygon = aExtrudePoly;
+ }
+ }
+ }
+
+ // number of layers is done
+ if(nNumLayers > 1)
+ {
+ // need to be arranged
+ double fMinDepth = fDepth * 0.8;
+ double fStep = (fDepth - fMinDepth) / (double)nNumLayers;
+ pLayer = pBaseLayer;
+
+ while(pLayer)
+ {
+ // move along layer
+ E3dDepthNeighbour* pAct = pLayer->mpNext;
+
+ while(pAct)
+ {
+ // adapt extrude value
+ pAct->mpObj->SetMergedItem(SfxUInt32Item(SDRATTR_3DOBJ_DEPTH, sal_uInt32(fMinDepth + 0.5)));
+
+ // next
+ pAct = pAct->mpNext;
+ }
+
+ // next layer
+ pLayer = pLayer->mpDown;
+ fMinDepth += fStep;
+ }
+ }
+
+ // cleanup
+ while(pBaseLayer)
+ {
+ pLayer = pBaseLayer->mpDown;
+ delete pBaseLayer;
+ pBaseLayer = pLayer;
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Drag beginnen, vorher ggf. Drag-Methode fuer 3D-Objekte erzeugen
+|*
+\************************************************************************/
+
+BOOL E3dView::BegDragObj(const Point& rPnt, OutputDevice* pOut,
+ SdrHdl* pHdl, short nMinMov,
+ SdrDragMethod* pForcedMeth)
+{
+ if(Is3DRotationCreationActive() && GetMarkedObjectCount())
+ {
+ // bestimme alle selektierten Polygone und gebe die gespiegelte Hilfsfigur aus
+ mpMirrorOverlay->SetMirrorAxis(aRef1, aRef2);
+ }
+ else
+ {
+ BOOL bOwnActionNecessary;
+ if (pHdl == NULL)
+ {
+ bOwnActionNecessary = TRUE;
+ }
+ else if (pHdl->IsVertexHdl() || pHdl->IsCornerHdl())
+ {
+ bOwnActionNecessary = TRUE;
+ }
+ else
+ {
+ bOwnActionNecessary = FALSE;
+ }
+
+ if(bOwnActionNecessary && GetMarkedObjectCount() >= 1)
+ {
+ E3dDragConstraint eConstraint = E3DDRAG_CONSTR_XYZ;
+ BOOL bThereAreRootScenes = FALSE;
+ BOOL bThereAre3DObjects = FALSE;
+ long nCnt = GetMarkedObjectCount();
+ for(long nObjs = 0;nObjs < nCnt;nObjs++)
+ {
+ SdrObject *pObj = GetMarkedObjectByIndex(nObjs);
+ if(pObj)
+ {
+ if(pObj->ISA(E3dScene) && ((E3dScene*)pObj)->GetScene() == pObj)
+ bThereAreRootScenes = TRUE;
+ if(pObj->ISA(E3dObject))
+ bThereAre3DObjects = TRUE;
+ }
+ }
+ if( bThereAre3DObjects )
+ {
+ eDragHdl = ( pHdl == NULL ? HDL_MOVE : pHdl->GetKind() );
+ switch ( eDragMode )
+ {
+ case SDRDRAG_ROTATE:
+ case SDRDRAG_SHEAR:
+ {
+ switch ( eDragHdl )
+ {
+ case HDL_LEFT:
+ case HDL_RIGHT:
+ {
+ eConstraint = E3DDRAG_CONSTR_X;
+ }
+ break;
+
+ case HDL_UPPER:
+ case HDL_LOWER:
+ {
+ eConstraint = E3DDRAG_CONSTR_Y;
+ }
+ break;
+
+ case HDL_UPLFT:
+ case HDL_UPRGT:
+ case HDL_LWLFT:
+ case HDL_LWRGT:
+ {
+ eConstraint = E3DDRAG_CONSTR_Z;
+ }
+ break;
+ default: break;
+ }
+
+ // die nicht erlaubten Rotationen ausmaskieren
+ eConstraint = E3dDragConstraint(eConstraint& eDragConstraint);
+ pForcedMeth = new E3dDragRotate(*this, GetMarkedObjectList(), eConstraint, IsSolidDragging());
+ }
+ break;
+
+ case SDRDRAG_MOVE:
+ {
+ if(!bThereAreRootScenes)
+ {
+ pForcedMeth = new E3dDragMove(*this, GetMarkedObjectList(), eDragHdl, eConstraint, IsSolidDragging());
+ }
+ }
+ break;
+
+ // spaeter mal
+ case SDRDRAG_MIRROR:
+ case SDRDRAG_CROOK:
+ case SDRDRAG_DISTORT:
+ case SDRDRAG_TRANSPARENCE:
+ case SDRDRAG_GRADIENT:
+ default:
+ {
+ }
+ break;
+ }
+ }
+ }
+ }
+ return SdrView::BegDragObj(rPnt, pOut, pHdl, nMinMov, pForcedMeth);
+}
+
+/*************************************************************************
+|*
+|* Pruefen, obj 3D-Szene markiert ist
+|*
+\************************************************************************/
+
+BOOL E3dView::HasMarkedScene()
+{
+ return (GetMarkedScene() != NULL);
+}
+
+/*************************************************************************
+|*
+|* Pruefen, obj 3D-Szene markiert ist
+|*
+\************************************************************************/
+
+E3dScene* E3dView::GetMarkedScene()
+{
+ ULONG nCnt = GetMarkedObjectCount();
+
+ for ( ULONG i = 0; i < nCnt; i++ )
+ if ( GetMarkedObjectByIndex(i)->ISA(E3dScene) )
+ return (E3dScene*) GetMarkedObjectByIndex(i);
+
+ return NULL;
+}
+
+/*************************************************************************
+|*
+|* aktuelles 3D-Zeichenobjekt setzen, dafuer Szene erzeugen
+|*
+\************************************************************************/
+
+E3dScene* E3dView::SetCurrent3DObj(E3dObject* p3DObj)
+{
+ DBG_ASSERT(p3DObj != NULL, "Nana, wer steckt denn hier 'nen NULL-Zeiger rein?");
+ E3dScene* pScene = NULL;
+
+ // get transformed BoundVolume of the object
+ basegfx::B3DRange aVolume(p3DObj->GetBoundVolume());
+ aVolume.transform(p3DObj->GetTransform());
+ double fW(aVolume.getWidth());
+ double fH(aVolume.getHeight());
+
+ Rectangle aRect(0,0, (long) fW, (long) fH);
+
+ pScene = new E3dPolyScene(Get3DDefaultAttributes());
+
+ InitScene(pScene, fW, fH, aVolume.getMaxZ() + ((fW + fH) / 4.0));
+
+ pScene->Insert3DObj(p3DObj);
+ pScene->NbcSetSnapRect(aRect);
+
+ return pScene;
+}
+
+/*************************************************************************
+|*
+|* neu erzeugte Szene initialisieren
+|*
+\************************************************************************/
+
+void E3dView::InitScene(E3dScene* pScene, double fW, double fH, double fCamZ)
+{
+ Camera3D aCam(pScene->GetCamera());
+
+ aCam.SetAutoAdjustProjection(FALSE);
+ aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
+ basegfx::B3DPoint aLookAt;
+
+ double fDefaultCamPosZ = GetDefaultCamPosZ();
+ basegfx::B3DPoint aCamPos(0.0, 0.0, fCamZ < fDefaultCamPosZ ? fDefaultCamPosZ : fCamZ);
+
+ aCam.SetPosAndLookAt(aCamPos, aLookAt);
+ aCam.SetFocalLength(GetDefaultCamFocal());
+ aCam.SetDefaults(basegfx::B3DPoint(0.0, 0.0, fDefaultCamPosZ), aLookAt, GetDefaultCamFocal());
+ pScene->SetCamera(aCam);
+}
+
+/*************************************************************************
+|*
+|* startsequenz fuer die erstellung eines 3D-Rotationskoerpers
+|*
+\************************************************************************/
+
+void E3dView::Start3DCreation()
+{
+ if (GetMarkedObjectCount())
+ {
+ // irgendwelche Markierungen ermitteln und ausschalten
+ //HMHBOOL bVis = IsMarkHdlShown();
+
+ //HMHif (bVis) HideMarkHdl();
+
+ // bestimme die koordinaten fuer JOEs Mirrorachse
+ // entgegen der normalen Achse wird diese an die linke Seite des Objektes
+ // positioniert
+ long nOutMin = 0;
+ long nOutMax = 0;
+ long nMinLen = 0;
+ long nObjDst = 0;
+ long nOutHgt = 0;
+ OutputDevice* pOut = GetFirstOutputDevice(); //GetWin(0);
+
+ // erstmal Darstellungsgrenzen bestimmen
+ if (pOut != NULL)
+ {
+ nMinLen = pOut->PixelToLogic(Size(0,50)).Height();
+ nObjDst = pOut->PixelToLogic(Size(0,20)).Height();
+
+ long nDst = pOut->PixelToLogic(Size(0,10)).Height();
+
+ nOutMin = -pOut->GetMapMode().GetOrigin().Y();
+ nOutMax = pOut->GetOutputSize().Height() - 1 + nOutMin;
+ nOutMin += nDst;
+ nOutMax -= nDst;
+
+ if (nOutMax - nOutMin < nDst)
+ {
+ nOutMin += nOutMax + 1;
+ nOutMin /= 2;
+ nOutMin -= (nDst + 1) / 2;
+ nOutMax = nOutMin + nDst;
+ }
+
+ nOutHgt = nOutMax - nOutMin;
+
+ long nTemp = nOutHgt / 4;
+ if (nTemp > nMinLen) nMinLen = nTemp;
+ }
+
+ // und dann die Markierungen oben und unten an das Objekt heften
+ basegfx::B2DRange aR;
+ for(sal_uInt32 nMark(0L); nMark < GetMarkedObjectCount(); nMark++)
+ {
+ SdrObject* pMark = GetMarkedObjectByIndex(nMark);
+ basegfx::B2DPolyPolygon aXPP(pMark->TakeXorPoly());
+ aR.expand(basegfx::tools::getRange(aXPP));
+ }
+
+ basegfx::B2DPoint aCenter(aR.getCenter());
+ long nMarkHgt = basegfx::fround(aR.getHeight()) - 1;
+ long nHgt = nMarkHgt + nObjDst * 2;
+
+ if (nHgt < nMinLen) nHgt = nMinLen;
+
+ long nY1 = basegfx::fround(aCenter.getY()) - (nHgt + 1) / 2;
+ long nY2 = nY1 + nHgt;
+
+ if (pOut && (nMinLen > nOutHgt)) nMinLen = nOutHgt;
+ if (pOut)
+ {
+ if (nY1 < nOutMin)
+ {
+ nY1 = nOutMin;
+ if (nY2 < nY1 + nMinLen) nY2 = nY1 + nMinLen;
+ }
+ if (nY2 > nOutMax)
+ {
+ nY2 = nOutMax;
+ if (nY1 > nY2 - nMinLen) nY1 = nY2 - nMinLen;
+ }
+ }
+
+ aRef1.X() = basegfx::fround(aR.getMinX()); // Initial Achse um 2/100mm nach links
+ aRef1.Y() = nY1;
+ aRef2.X() = aRef1.X();
+ aRef2.Y() = nY2;
+
+ // Markierungen einschalten
+ SetMarkHandles();
+
+ //HMHif (bVis) ShowMarkHdl();
+ if (AreObjectsMarked()) MarkListHasChanged();
+
+ // SpiegelPolygone SOFORT zeigen
+ const SdrHdlList &aHdlList = GetHdlList();
+ mpMirrorOverlay = new Impl3DMirrorConstructOverlay(*this);
+ mpMirrorOverlay->SetMirrorAxis(aHdlList.GetHdl(HDL_REF1)->GetPos(), aHdlList.GetHdl(HDL_REF2)->GetPos());
+ //CreateMirrorPolygons ();
+ //ShowMirrorPolygons (aHdlList.GetHdl (HDL_REF1)->GetPos (),
+ // aHdlList.GetHdl (HDL_REF2)->GetPos ());
+ }
+}
+
+/*************************************************************************
+|*
+|* was passiert bei einer Mausbewegung, wenn das Objekt erstellt wird ?
+|*
+\************************************************************************/
+
+void E3dView::MovAction(const Point& rPnt)
+{
+ if(Is3DRotationCreationActive())
+ {
+ SdrHdl* pHdl = GetDragHdl();
+
+ if (pHdl)
+ {
+ SdrHdlKind eHdlKind = pHdl->GetKind();
+
+ // reagiere nur bei einer spiegelachse
+ if ((eHdlKind == HDL_REF1) ||
+ (eHdlKind == HDL_REF2) ||
+ (eHdlKind == HDL_MIRX))
+ {
+ const SdrHdlList &aHdlList = GetHdlList ();
+
+ // loesche das gespiegelte Polygon, spiegele das Original und zeichne es neu
+ //ShowMirrored ();
+ SdrView::MovAction (rPnt);
+ mpMirrorOverlay->SetMirrorAxis(
+ aHdlList.GetHdl (HDL_REF1)->GetPos(),
+ aHdlList.GetHdl (HDL_REF2)->GetPos());
+ }
+ }
+ else
+ {
+ SdrView::MovAction (rPnt);
+ }
+ }
+ else
+ {
+ SdrView::MovAction (rPnt);
+ }
+}
+
+/*************************************************************************
+|*
+|* Schluss. Objekt und evtl. Unterobjekte ueber ImpCreate3DLathe erstellen
+|* [FG] Mit dem Parameterwert TRUE (SDefault: FALSE) wird einfach ein
+|* Rotationskoerper erzeugt, ohne den Benutzer die Lage der
+|* Achse fetlegen zu lassen. Es reicht dieser Aufruf, falls
+|* ein Objekt selektiert ist. (keine Initialisierung noetig)
+|*
+\************************************************************************/
+
+void E3dView::End3DCreation(BOOL bUseDefaultValuesForMirrorAxes)
+{
+ ResetCreationActive();
+
+ if(AreObjectsMarked())
+ {
+ if(bUseDefaultValuesForMirrorAxes)
+ {
+ Rectangle aRect = GetAllMarkedRect();
+ if(aRect.GetWidth() <= 1)
+ aRect.SetSize(Size(500, aRect.GetHeight()));
+ if(aRect.GetHeight() <= 1)
+ aRect.SetSize(Size(aRect.GetWidth(), 500));
+
+ basegfx::B2DPoint aPnt1(aRect.Left(), -aRect.Top());
+ basegfx::B2DPoint aPnt2(aRect.Left(), -aRect.Bottom());
+
+ ConvertMarkedObjTo3D(FALSE, aPnt1, aPnt2);
+ }
+ else
+ {
+ // Hilfsfigur ausschalten
+ // bestimme aus den Handlepositionen und den Versatz der Punkte
+ const SdrHdlList &aHdlList = GetHdlList();
+ Point aMirrorRef1 = aHdlList.GetHdl(HDL_REF1)->GetPos();
+ Point aMirrorRef2 = aHdlList.GetHdl(HDL_REF2)->GetPos();
+
+ basegfx::B2DPoint aPnt1(aMirrorRef1.X(), -aMirrorRef1.Y());
+ basegfx::B2DPoint aPnt2(aMirrorRef2.X(), -aMirrorRef2.Y());
+
+ ConvertMarkedObjTo3D(FALSE, aPnt1, aPnt2);
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+E3dView::~E3dView ()
+{
+}
+
+/*************************************************************************
+|*
+|* beende das erzeugen und loesche die polygone
+|*
+\************************************************************************/
+
+void E3dView::ResetCreationActive ()
+{
+ if(mpMirrorOverlay)
+ {
+ delete mpMirrorOverlay;
+ mpMirrorOverlay = 0L;
+ }
+}
+
+/*************************************************************************
+|*
+|* Klasse initialisieren
+|*
+\************************************************************************/
+
+void E3dView::InitView ()
+{
+ eDragConstraint = E3DDRAG_CONSTR_XYZ;
+ fDefaultScaleX =
+ fDefaultScaleY =
+ fDefaultScaleZ = 1.0;
+ fDefaultRotateX =
+ fDefaultRotateY =
+ fDefaultRotateZ = 0.0;
+ fDefaultExtrusionDeepth = 1000; // old: 2000;
+ fDefaultLightIntensity = 0.8; // old: 0.6;
+ fDefaultAmbientIntensity = 0.4;
+ nHDefaultSegments = 12;
+ nVDefaultSegments = 12;
+ aDefaultLightColor = RGB_Color(COL_WHITE);
+ aDefaultAmbientColor = RGB_Color(COL_BLACK);
+ bDoubleSided = FALSE;
+ mpMirrorOverlay = 0L;
+}
+
+/*************************************************************************
+|*
+|* Koennen die selektierten Objekte aufgebrochen werden?
+|*
+\************************************************************************/
+
+BOOL E3dView::IsBreak3DObjPossible() const
+{
+ ULONG nCount = GetMarkedObjectCount();
+
+ if (nCount > 0)
+ {
+ ULONG i = 0;
+
+ while (i < nCount)
+ {
+ SdrObject* pObj = GetMarkedObjectByIndex(i);
+
+ if (pObj && pObj->ISA(E3dObject))
+ {
+ if(!(((E3dObject*)pObj)->IsBreakObjPossible()))
+ return FALSE;
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ i++;
+ }
+ }
+ else
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* Selektierte Lathe-Objekte aufbrechen
+|*
+\************************************************************************/
+
+void E3dView::Break3DObj()
+{
+ if(IsBreak3DObjPossible())
+ {
+ // ALLE selektierten Objekte werden gewandelt
+ UINT32 nCount = GetMarkedObjectCount();
+
+ BegUndo(String(SVX_RESSTR(RID_SVX_3D_UNDO_BREAK_LATHE)));
+ for(UINT32 a=0;a<nCount;a++)
+ {
+ E3dObject* pObj = (E3dObject*)GetMarkedObjectByIndex(a);
+ BreakSingle3DObj(pObj);
+ }
+ DeleteMarked();
+ EndUndo();
+ }
+}
+
+void E3dView::BreakSingle3DObj(E3dObject* pObj)
+{
+ if(pObj->ISA(E3dScene))
+ {
+ SdrObjList* pSubList = pObj->GetSubList();
+ SdrObjListIter aIter(*pSubList, IM_FLAT);
+
+ while(aIter.IsMore())
+ {
+ E3dObject* pSubObj = (E3dObject*)aIter.Next();
+ BreakSingle3DObj(pSubObj);
+ }
+ }
+ else
+ {
+ SdrAttrObj* pNewObj = pObj->GetBreakObj();
+ if(pNewObj)
+ {
+ InsertObjectAtView(pNewObj, *GetSdrPageView(), SDRINSERT_DONTMARK);
+ pNewObj->SetChanged();
+ pNewObj->BroadcastObjectChange();
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Szenen mischen
+|*
+\************************************************************************/
+
+void E3dView::MergeScenes ()
+{
+ ULONG nCount = GetMarkedObjectCount();
+
+ if (nCount > 0)
+ {
+ ULONG nObj = 0;
+ SdrObject *pObj = GetMarkedObjectByIndex(nObj);
+ E3dScene *pScene = new E3dPolyScene(Get3DDefaultAttributes());
+ basegfx::B3DRange aBoundVol;
+ Rectangle aAllBoundRect (GetMarkedObjBoundRect ());
+ Point aCenter (aAllBoundRect.Center());
+
+ while (pObj)
+ {
+ if (pObj->ISA(E3dScene))
+ {
+ /**********************************************************
+ * Es ist eine 3D-Scene oder 3D-PolyScene
+ **********************************************************/
+ SdrObjList* pSubList = ((E3dObject*) pObj)->GetSubList();
+
+ SdrObjListIter aIter(*pSubList, IM_FLAT);
+
+ while (aIter.IsMore())
+ {
+ /******************************************************
+ * LatheObjekte suchen
+ ******************************************************/
+ SdrObject* pSubObj = aIter.Next();
+
+ E3dObject *pNewObj = 0;
+
+ switch (pSubObj->GetObjIdentifier())
+ {
+ case E3D_CUBEOBJ_ID :
+ pNewObj = new E3dCubeObj;
+ *(E3dCubeObj*)pNewObj = *(E3dCubeObj*)pSubObj;
+ break;
+
+ case E3D_SPHEREOBJ_ID:
+ pNewObj = new E3dSphereObj;
+ *(E3dSphereObj*)pNewObj = *(E3dSphereObj*)pSubObj;
+ break;
+
+ case E3D_EXTRUDEOBJ_ID:
+ pNewObj = new E3dExtrudeObj;
+ *(E3dExtrudeObj*)pNewObj = *(E3dExtrudeObj*)pSubObj;
+ break;
+
+ case E3D_LATHEOBJ_ID:
+ pNewObj = new E3dLatheObj;
+ *(E3dLatheObj*)pNewObj = *(E3dLatheObj*)pSubObj;
+ break;
+
+ case E3D_COMPOUNDOBJ_ID:
+ pNewObj = new E3dCompoundObject;
+ *(E3dCompoundObject*)pNewObj = *(E3dCompoundObject*)pSubObj;
+ break;
+ }
+
+ Rectangle aBoundRect = pSubObj->GetCurrentBoundRect();
+
+ basegfx::B3DHomMatrix aMatrix;
+ aMatrix.translate(aBoundRect.Left() - aCenter.getX(), aCenter.getY(), 0.0);
+ pNewObj->SetTransform(aMatrix * pNewObj->GetTransform()); // #112587#
+
+ if (pNewObj) aBoundVol.expand(pNewObj->GetBoundVolume());
+ pScene->Insert3DObj (pNewObj);
+ }
+ }
+
+ nObj++;
+
+ if (nObj < nCount)
+ {
+ pObj = GetMarkedObjectByIndex(nObj);
+ }
+ else
+ {
+ pObj = NULL;
+ }
+ }
+
+ double fW = aAllBoundRect.GetWidth();
+ double fH = aAllBoundRect.GetHeight();
+ Rectangle aRect(0,0, (long) fW, (long) fH);
+
+ InitScene(pScene, fW, fH, aBoundVol.getMaxZ() + + ((fW + fH) / 4.0));
+ pScene->NbcSetSnapRect(aRect);
+
+ Camera3D &aCamera = (Camera3D&) pScene->GetCamera ();
+ basegfx::B3DPoint aMinVec(aBoundVol.getMinimum());
+ basegfx::B3DPoint aMaxVec(aBoundVol.getMaximum());
+ double fDeepth(fabs(aMaxVec.getZ() - aMinVec.getZ()));
+
+ aCamera.SetPRP(basegfx::B3DPoint(0.0, 0.0, 1000.0));
+ double fDefaultCamPosZ(GetDefaultCamPosZ());
+ aCamera.SetPosition(basegfx::B3DPoint(0.0, 0.0, fDefaultCamPosZ + fDeepth / 2.0));
+ aCamera.SetFocalLength(GetDefaultCamFocal());
+ pScene->SetCamera (aCamera);
+
+ // SnapRects der Objekte ungueltig
+ pScene->SetRectsDirty();
+
+ InsertObjectAtView(pScene, *(GetSdrPageViewOfMarkedByIndex(0)));
+
+ // SnapRects der Objekte ungueltig
+ pScene->SetRectsDirty();
+ }
+}
+
+/*************************************************************************
+|*
+|* Possibilities, hauptsaechlich gruppieren/ungruppieren
+|*
+\************************************************************************/
+void E3dView::CheckPossibilities()
+{
+ // call parent
+ SdrView::CheckPossibilities();
+
+ // Weitere Flags bewerten
+ if(bGroupPossible || bUnGroupPossible || bGrpEnterPossible)
+ {
+ INT32 nMarkCnt = GetMarkedObjectCount();
+ BOOL bCoumpound = FALSE;
+ BOOL b3DObject = FALSE;
+ for(INT32 nObjs = 0L; (nObjs < nMarkCnt) && !bCoumpound; nObjs++)
+ {
+ SdrObject *pObj = GetMarkedObjectByIndex(nObjs);
+ if(pObj && pObj->ISA(E3dCompoundObject))
+ bCoumpound = TRUE;
+ if(pObj && pObj->ISA(E3dObject))
+ b3DObject = TRUE;
+ }
+
+ // Bisher: Es sind ZWEI oder mehr beliebiger Objekte selektiert.
+ // Nachsehen, ob CompoundObjects beteiligt sind. Falls ja,
+ // das Gruppieren verbieten.
+ if(bGroupPossible && bCoumpound)
+ bGroupPossible = FALSE;
+
+ if(bUnGroupPossible && b3DObject)
+ bUnGroupPossible = FALSE;
+
+ if(bGrpEnterPossible && bCoumpound)
+ bGrpEnterPossible = FALSE;
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/view3d1.cxx b/svx/source/engine3d/view3d1.cxx
new file mode 100644
index 000000000000..8e34e7e99757
--- /dev/null
+++ b/svx/source/engine3d/view3d1.cxx
@@ -0,0 +1,232 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <tools/shl.hxx>
+#include "svditer.hxx"
+#include <svx/svdpool.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svxids.hrc>
+#include <svx/xtable.hxx>
+#include <svx/fmview.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include "globl3d.hxx"
+#include <svx/obj3d.hxx>
+#include <svx/polysc3d.hxx>
+#include <svx/e3ditem.hxx>
+#include <editeng/colritem.hxx>
+#include <svx/lathe3d.hxx>
+#include <svx/sphere3d.hxx>
+#include <svx/extrud3d.hxx>
+#include <svx/e3dundo.hxx>
+#include <svx/view3d.hxx>
+#include <svx/cube3d.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/e3dsceneupdater.hxx>
+
+/*************************************************************************
+|*
+|* Konvertierung in Polygone
+|*
+\************************************************************************/
+
+void E3dView::ConvertMarkedToPolyObj(BOOL bLineToArea)
+{
+ SdrObject* pNewObj = NULL;
+
+ if (GetMarkedObjectCount() == 1)
+ {
+ SdrObject* pObj = GetMarkedObjectByIndex(0);
+
+ if (pObj && pObj->ISA(E3dPolyScene))
+ {
+ BOOL bBezier = FALSE;
+ pNewObj = ((E3dPolyScene*) pObj)->ConvertToPolyObj(bBezier, bLineToArea);
+
+ if (pNewObj)
+ {
+ BegUndo(SVX_RESSTR(RID_SVX_3D_UNDO_EXTRUDE));
+ ReplaceObjectAtView(pObj, *GetSdrPageView(), pNewObj);
+ EndUndo();
+ }
+ }
+ }
+
+ if (!pNewObj)
+ {
+ SdrView::ConvertMarkedToPolyObj(bLineToArea);
+ }
+}
+
+/*************************************************************************
+|*
+|* Get3DAttributes
+|*
+\************************************************************************/
+
+void Imp_E3dView_InorderRun3DObjects(const SdrObject* pObj, sal_uInt32& rMask)
+{
+ if(pObj->ISA(E3dLatheObj))
+ {
+ rMask |= 0x0001;
+ }
+ else if(pObj->ISA(E3dExtrudeObj))
+ {
+ rMask |= 0x0002;
+ }
+ else if(pObj->ISA(E3dSphereObj))
+ {
+ rMask |= 0x0004;
+ }
+ else if(pObj->ISA(E3dCubeObj))
+ {
+ rMask |= 0x0008;
+ }
+ else if(pObj->IsGroupObject())
+ {
+ SdrObjList* pList = pObj->GetSubList();
+ for(sal_uInt32 a(0); a < pList->GetObjCount(); a++)
+ Imp_E3dView_InorderRun3DObjects(pList->GetObj(a), rMask);
+ }
+}
+
+SfxItemSet E3dView::Get3DAttributes(E3dScene* pInScene, BOOL /*bOnly3DAttr*/) const
+{
+ // ItemSet mit entspr. Bereich anlegen
+ SfxItemSet aSet(
+ pMod->GetItemPool(),
+ SDRATTR_START, SDRATTR_END,
+ SID_ATTR_3D_INTERN, SID_ATTR_3D_INTERN,
+ 0, 0);
+
+ sal_uInt32 nSelectedItems(0L);
+
+ if(pInScene)
+ {
+ // special scene
+ aSet.Put(pInScene->GetMergedItemSet());
+ }
+ else
+ {
+ // get attributes from all selected objects
+ MergeAttrFromMarked(aSet, FALSE);
+
+ // calc flags for SID_ATTR_3D_INTERN
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ sal_uInt32 nMarkCnt(rMarkList.GetMarkCount());
+
+ for(sal_uInt32 a(0); a < nMarkCnt; a++)
+ {
+ SdrObject* pObj = GetMarkedObjectByIndex(a);
+ Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
+ }
+ }
+
+ // setze SID_ATTR_3D_INTERN auf den Status der selektierten Objekte
+ aSet.Put(SfxUInt32Item(SID_ATTR_3D_INTERN, nSelectedItems));
+
+ // DefaultValues pflegen
+ if(!nSelectedItems && !pInScene)
+ {
+ // Defaults holen und hinzufuegen
+ SfxItemSet aDefaultSet(pMod->GetItemPool(), SDRATTR_3D_FIRST, SDRATTR_3D_LAST);
+ GetAttributes(aDefaultSet);
+ aSet.Put(aDefaultSet);
+
+ // ... aber keine Linien fuer 3D
+ aSet.Put(XLineStyleItem (XLINE_NONE));
+
+ // #84061# new defaults for distance and focal length
+ aSet.Put(Svx3DDistanceItem(100));
+ aSet.Put(Svx3DFocalLengthItem(10000));
+ }
+
+ // ItemSet zurueckgeben
+ return(aSet);
+}
+
+/*************************************************************************
+|*
+|* Set3DAttributes:
+|*
+\************************************************************************/
+
+void E3dView::Set3DAttributes( const SfxItemSet& rAttr, E3dScene* pInScene, BOOL bReplaceAll)
+{
+ sal_uInt32 nSelectedItems(0L);
+
+ if(pInScene)
+ {
+ //pInScene->SetItemSetAndBroadcast(rAttr, bReplaceAll);
+ pInScene->SetMergedItemSetAndBroadcast(rAttr, bReplaceAll);
+ }
+ else
+ {
+ // #i94832# removed usage of E3DModifySceneSnapRectUpdater here.
+ // They are not needed here, they are already handled in SetAttrToMarked
+
+ // set at selected objects
+ SetAttrToMarked(rAttr, bReplaceAll);
+
+ // old run
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ const sal_uInt32 nMarkCnt(rMarkList.GetMarkCount());
+
+ for(sal_uInt32 a(0); a < nMarkCnt; a++)
+ {
+ SdrObject* pObj = GetMarkedObjectByIndex(a);
+ Imp_E3dView_InorderRun3DObjects(pObj, nSelectedItems);
+ }
+ }
+
+ // DefaultValues pflegen
+ if(!nSelectedItems && !pInScene)
+ {
+ // Defaults setzen
+ SfxItemSet aDefaultSet(pMod->GetItemPool(), SDRATTR_3D_FIRST, SDRATTR_3D_LAST);
+ aDefaultSet.Put(rAttr);
+ SetAttributes(aDefaultSet);
+
+ }
+}
+
+double E3dView::GetDefaultCamPosZ()
+{
+ return (double)((const SfxUInt32Item&)pMod->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_DISTANCE)).GetValue();
+}
+
+double E3dView::GetDefaultCamFocal()
+{
+ return (double)((const SfxUInt32Item&)pMod->GetItemPool().GetDefaultItem(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/engine3d/viewpt3d2.cxx b/svx/source/engine3d/viewpt3d2.cxx
new file mode 100644
index 000000000000..cb3b42b9f577
--- /dev/null
+++ b/svx/source/engine3d/viewpt3d2.cxx
@@ -0,0 +1,397 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/viewpt3d.hxx>
+#include <svx/volume3d.hxx>
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+Viewport3D::Viewport3D() :
+ aVRP(0, 0, 5),
+ aVPN(0, 0, 1),
+ aVUV(0, 1, 1),
+ aPRP(0, 0, 2),
+ fVPD(-3),
+ fNearClipDist (0.0),
+ fFarClipDist (0.0),
+ eProjection(PR_PERSPECTIVE),
+ eAspectMapping(AS_NO_MAPPING),
+ aDeviceRect(Point(0,0), Size(-1,-1)),
+ aViewPoint (0, 0, 5000),
+ bTfValid(0),
+ fWRatio (1.0),
+ fHRatio (1.0)
+{
+ aViewWin.X = -1; aViewWin.Y = -1;
+ aViewWin.W = 2; aViewWin.H = 2;
+}
+
+/*************************************************************************
+|*
+|* ViewWindow (in View-Koordinaten) setzen
+|*
+\************************************************************************/
+
+void Viewport3D::SetViewWindow(double fX, double fY, double fW, double fH)
+{
+ aViewWin.X = fX;
+ aViewWin.Y = fY;
+ if ( fW > 0 ) aViewWin.W = fW;
+ else aViewWin.W = 1.0;
+ if ( fH > 0 ) aViewWin.H = fH;
+ else aViewWin.H = 1.0;
+
+ fWRatio = aDeviceRect.GetWidth() / aViewWin.W;
+ fHRatio = aDeviceRect.GetHeight() / aViewWin.H;
+}
+
+/*************************************************************************
+|*
+|* ViewWindow zurueckgeben
+|*
+\************************************************************************/
+
+void Viewport3D::GetViewWindow(double& rX, double& rY,
+ double& rW, double& rH) const
+{
+ rX = aViewWin.X;
+ rY = aViewWin.Y;
+ rW = aViewWin.W;
+ rH = aViewWin.H;
+}
+
+/*************************************************************************
+|*
+|* Beobachterposition (PRP) in Weltkoordinaten zurueckgeben
+|*
+\************************************************************************/
+
+const basegfx::B3DPoint& Viewport3D::GetViewPoint()
+{
+ MakeTransform();
+
+ return aViewPoint;
+}
+
+/*************************************************************************
+|*
+|* Transformationsmatrix zurueckgeben
+|*
+\************************************************************************/
+
+const basegfx::B3DHomMatrix& Viewport3D::GetViewTransform()
+{
+ MakeTransform();
+
+ return aViewTf;
+}
+
+
+
+
+
+
+
+/*************************************************************************
+|*
+|* View-Transformationsmatrix berechnen
+|*
+\************************************************************************/
+
+void Viewport3D::MakeTransform(void)
+{
+ if ( !bTfValid )
+ {
+ double fV, fXupVp, fYupVp;
+ aViewPoint = aVRP + aVPN * aPRP.getZ();
+
+ // auf Einheitsmatrix zuruecksetzen
+ aViewTf.identity();
+
+ // in den Ursprung verschieben
+ aViewTf.translate(-aVRP.getX(), -aVRP.getY(), -aVRP.getZ());
+
+ // fV = Laenge der Projektion von aVPN auf die yz-Ebene:
+ fV = aVPN.getYZLength();
+
+ if ( fV != 0 )
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(aVPN.getY() / fV);
+ const double fCos(aVPN.getZ() / fV);
+ aTemp.set(2, 2, fCos);
+ aTemp.set(1, 1, fCos);
+ aTemp.set(2, 1, fSin);
+ aTemp.set(1, 2, -fSin);
+ aViewTf *= aTemp;
+ }
+
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(-aVPN.getX());
+ const double fCos(fV);
+ aTemp.set(2, 2, fCos);
+ aTemp.set(0, 0, fCos);
+ aTemp.set(0, 2, fSin);
+ aTemp.set(2, 0, -fSin);
+ aViewTf *= aTemp;
+ }
+
+ // X- und Y-Koordinaten des View Up Vektors in das (vorlaeufige)
+ // View-Koordinatensytem umrechnen
+ fXupVp = aViewTf.get(0, 0) * aVUV.getX() + aViewTf.get(0, 1) * aVUV.getY() + aViewTf.get(0, 2) * aVUV.getZ();
+ fYupVp = aViewTf.get(1, 0) * aVUV.getX() + aViewTf.get(1, 1) * aVUV.getY() + aViewTf.get(1, 2) * aVUV.getZ();
+ fV = sqrt(fXupVp * fXupVp + fYupVp * fYupVp);
+
+ if ( fV != 0 )
+ {
+ basegfx::B3DHomMatrix aTemp;
+ const double fSin(fXupVp / fV);
+ const double fCos(fYupVp / fV);
+ aTemp.set(1, 1, fCos);
+ aTemp.set(0, 0, fCos);
+ aTemp.set(1, 0, fSin);
+ aTemp.set(0, 1, -fSin);
+ aViewTf *= aTemp;
+ }
+
+ bTfValid = TRUE;
+ }
+}
+
+/*************************************************************************
+|*
+|* DeviceWindow des Ausgabegeraetes setzen
+|*
+\************************************************************************/
+
+void Viewport3D::SetDeviceWindow(const Rectangle& rRect)
+{
+ long nNewW = rRect.GetWidth();
+ long nNewH = rRect.GetHeight();
+ long nOldW = aDeviceRect.GetWidth();
+ long nOldH = aDeviceRect.GetHeight();
+
+ switch ( eAspectMapping )
+ {
+ double fRatio, fTmp;
+
+ // Mapping, ohne die reale Groesse der Objekte im Device-Window
+ // zu aendern
+ case AS_HOLD_SIZE:
+ // Wenn Device ungueltig (w, h = -1), zunaechst
+ // View mit AsHoldX anpassen
+ if ( nOldW > 0 && nOldH > 0 )
+ {
+ fRatio = (double) nNewW / nOldW;
+ aViewWin.X *= fRatio;
+ aViewWin.W *= fRatio;
+ fRatio = (double) nNewH / nOldH;
+ aViewWin.Y *= fRatio;
+ aViewWin.H *= fRatio;
+ break;
+ }
+ case AS_HOLD_X:
+ // View-Hoehe an -Breite anpassen
+ fRatio = (double) nNewH / nNewW;
+ fTmp = aViewWin.H;
+ aViewWin.H = aViewWin.W * fRatio;
+ aViewWin.Y = aViewWin.Y * aViewWin.H / fTmp;
+ break;
+
+ case AS_HOLD_Y:
+ // View-Breite an -Hoehe anpassen
+ fRatio = (double) nNewW / nNewH;
+ fTmp = aViewWin.W;
+ aViewWin.W = aViewWin.H * fRatio;
+ aViewWin.X = aViewWin.X * aViewWin.W / fTmp;
+ break;
+ default: break;
+ }
+ fWRatio = nNewW / aViewWin.W;
+ fHRatio = nNewH / aViewWin.H;
+
+ aDeviceRect = rRect;
+}
+
+
+
+
+
+
+
+
+
+
+/*************************************************************************
+|*
+|* 3D-Punkt auf Viewplane projizieren
+|*
+\************************************************************************/
+
+basegfx::B3DPoint Viewport3D::DoProjection(const basegfx::B3DPoint& rVec) const
+{
+ basegfx::B3DPoint aVec(rVec);
+
+ if ( eProjection == PR_PERSPECTIVE )
+ {
+ double fPrDist = fVPD - aPRP.getZ();
+
+ if ( aPRP.getZ() == rVec.getZ() )
+ {
+ aVec.setX(0.0);
+ aVec.setY(0.0);
+ }
+ else
+ {
+ // Das ist die Version fuer beliebigen PRP, wird aber
+ // aus Performancegruenden nicht verwendet
+ fPrDist /= aVec.getZ() - aPRP.getZ();
+ aVec.setX(aVec.getX() * fPrDist);
+ aVec.setY(aVec.getY() * fPrDist);
+ }
+ }
+
+ return aVec;
+}
+
+/*************************************************************************
+|*
+|* 3D-Punkt auf Geraetekoordinaten mappen
+|*
+\************************************************************************/
+
+basegfx::B3DPoint Viewport3D::MapToDevice(const basegfx::B3DPoint& rVec) const
+{
+ basegfx::B3DPoint aRetval;
+
+ // Y-Koordinate subtrahieren, da die Device-Y-Achse von oben
+ // nach unten verlaeuft
+ aRetval.setX((double)aDeviceRect.Left() + ((rVec.getX() - aViewWin.X) * fWRatio));
+ aRetval.setY((double)aDeviceRect.Bottom() - ((rVec.getY() - aViewWin.Y) * fHRatio));
+ aRetval.setZ(rVec.getZ());
+
+ return aRetval;
+}
+
+/*************************************************************************
+|*
+|* View Reference Point setzen
+|*
+\************************************************************************/
+
+void Viewport3D::SetVRP(const basegfx::B3DPoint& rNewVRP)
+{
+ aVRP = rNewVRP;
+ bTfValid = FALSE;
+}
+
+/*************************************************************************
+|*
+|* View Plane Normal setzen
+|*
+\************************************************************************/
+
+void Viewport3D::SetVPN(const basegfx::B3DVector& rNewVPN)
+{
+ aVPN = rNewVPN;
+ aVPN.normalize();
+ bTfValid = FALSE;
+}
+
+/*************************************************************************
+|*
+|* View Up Vector setzen
+|*
+\************************************************************************/
+
+void Viewport3D::SetVUV(const basegfx::B3DVector& rNewVUV)
+{
+ aVUV = rNewVUV;
+ bTfValid = FALSE;
+}
+
+/*************************************************************************
+|*
+|* Center Of Projection setzen
+|*
+\************************************************************************/
+
+void Viewport3D::SetPRP(const basegfx::B3DPoint& rNewPRP)
+{
+ aPRP = rNewPRP;
+ aPRP.setX(0.0);
+ aPRP.setY(0.0);
+ bTfValid = FALSE;
+}
+
+/*************************************************************************
+|*
+|* View Plane Distance setzen
+|*
+\************************************************************************/
+
+void Viewport3D::SetVPD(double fNewVPD)
+{
+ fVPD = fNewVPD;
+ bTfValid = FALSE;
+}
+
+/*************************************************************************
+|*
+|* Abstand der vorderen Clippingebene setzen
+|*
+\************************************************************************/
+
+void Viewport3D::SetNearClipDist(double fNewNCD)
+{
+ fNearClipDist = fNewNCD;
+ bTfValid = FALSE;
+}
+
+/*************************************************************************
+|*
+|* Abstand der hinteren Clippingebene setzen
+|*
+\************************************************************************/
+
+void Viewport3D::SetFarClipDist(double fNewFCD)
+{
+ fFarClipDist = fNewFCD;
+ bTfValid = FALSE;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/fmcomp/dbaexchange.cxx b/svx/source/fmcomp/dbaexchange.cxx
new file mode 100644
index 000000000000..57e812cd3ea1
--- /dev/null
+++ b/svx/source/fmcomp/dbaexchange.cxx
@@ -0,0 +1,730 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/dbaexchange.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#include "fmprop.hrc"
+#include <comphelper/extract.hxx>
+#include <sot/formats.hxx>
+#include <sot/exchange.hxx>
+#include <comphelper/propertysetinfo.hxx>
+#include "fmprop.hrc"
+#include <tools/urlobj.hxx>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::datatransfer;
+ using namespace ::comphelper;
+
+ //====================================================================
+ //= OColumnTransferable
+ //====================================================================
+ //--------------------------------------------------------------------
+ OColumnTransferable::OColumnTransferable(const ::rtl::OUString& _rDatasource
+ ,const ::rtl::OUString& _rConnectionResource
+ ,const sal_Int32 _nCommandType
+ ,const ::rtl::OUString& _rCommand
+ ,const ::rtl::OUString& _rFieldName
+ ,sal_Int32 _nFormats)
+ :m_nFormatFlags(_nFormats)
+ {
+ implConstruct(_rDatasource,_rConnectionResource,_nCommandType, _rCommand, _rFieldName);
+ }
+
+ //--------------------------------------------------------------------
+ OColumnTransferable::OColumnTransferable(const ODataAccessDescriptor& _rDescriptor, sal_Int32 _nFormats )
+ :m_nFormatFlags(_nFormats)
+ {
+ ::rtl::OUString sDataSource, sDatabaseLocation, sConnectionResource, sCommand, sFieldName;
+ if ( _rDescriptor.has( daDataSource ) ) _rDescriptor[ daDataSource ] >>= sDataSource;
+ if ( _rDescriptor.has( daDatabaseLocation ) ) _rDescriptor[ daDatabaseLocation ] >>= sDatabaseLocation;
+ if ( _rDescriptor.has( daConnectionResource ) ) _rDescriptor[ daConnectionResource ] >>= sConnectionResource;
+ if ( _rDescriptor.has( daCommand ) ) _rDescriptor[ daCommand ] >>= sCommand;
+ if ( _rDescriptor.has( daColumnName ) ) _rDescriptor[ daColumnName ] >>= sFieldName;
+
+ sal_Int32 nCommandType = CommandType::TABLE;
+ OSL_VERIFY( _rDescriptor[ daCommandType ] >>= nCommandType );
+
+
+ implConstruct(
+ sDataSource.getLength() ? sDataSource : sDatabaseLocation,
+ sConnectionResource, nCommandType, sCommand, sFieldName );
+
+ if ( m_nFormatFlags & CTF_COLUMN_DESCRIPTOR )
+ {
+ if ( _rDescriptor.has( daConnection ) )
+ m_aDescriptor[ daConnection ] = _rDescriptor[ daConnection ];
+ if ( _rDescriptor.has( daColumnObject ) )
+ m_aDescriptor[ daColumnObject ] = _rDescriptor[ daColumnObject ];
+ }
+ }
+
+ //--------------------------------------------------------------------
+ OColumnTransferable::OColumnTransferable(const Reference< XPropertySet >& _rxForm,
+ const ::rtl::OUString& _rFieldName, const Reference< XPropertySet >& _rxColumn,
+ const Reference< XConnection >& _rxConnection, sal_Int32 _nFormats)
+ :m_nFormatFlags(_nFormats)
+ {
+ OSL_ENSURE(_rxForm.is(), "OColumnTransferable::OColumnTransferable: invalid form!");
+ // collect the necessary information from the form
+ ::rtl::OUString sCommand;
+ sal_Int32 nCommandType = CommandType::TABLE;
+ ::rtl::OUString sDatasource,sURL;
+
+ sal_Bool bTryToParse = sal_True;
+ try
+ {
+ _rxForm->getPropertyValue(FM_PROP_COMMANDTYPE) >>= nCommandType;
+ _rxForm->getPropertyValue(FM_PROP_COMMAND) >>= sCommand;
+ _rxForm->getPropertyValue(FM_PROP_DATASOURCE) >>= sDatasource;
+ _rxForm->getPropertyValue(FM_PROP_URL) >>= sURL;
+ bTryToParse = ::cppu::any2bool(_rxForm->getPropertyValue(FM_PROP_ESCAPE_PROCESSING));
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "OColumnTransferable::OColumnTransferable: could not collect essential data source attributes !");
+ }
+
+ // If the data source is an SQL-statement and simple enough (means "select <field list> from <table> where ....")
+ // we are able to fake the drag information we are about to create.
+ if (bTryToParse && (CommandType::COMMAND == nCommandType))
+ {
+ try
+ {
+ Reference< XTablesSupplier > xSupTab;
+ _rxForm->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSupTab;
+
+ if(xSupTab.is())
+ {
+ Reference< XNameAccess > xNames = xSupTab->getTables();
+ if (xNames.is())
+ {
+ Sequence< ::rtl::OUString > aTables = xNames->getElementNames();
+ if (1 == aTables.getLength())
+ {
+ sCommand = aTables[0];
+ nCommandType = CommandType::TABLE;
+ }
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "OColumnTransferable::OColumnTransferable: could not collect essential data source attributes (part two) !");
+ }
+ }
+
+ implConstruct(sDatasource, sURL,nCommandType, sCommand, _rFieldName);
+
+ if ((m_nFormatFlags & CTF_COLUMN_DESCRIPTOR) == CTF_COLUMN_DESCRIPTOR)
+ {
+ if (_rxColumn.is())
+ m_aDescriptor[daColumnObject] <<= _rxColumn;
+ if (_rxConnection.is())
+ m_aDescriptor[daConnection] <<= _rxConnection;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ sal_uInt32 OColumnTransferable::getDescriptorFormatId()
+ {
+ static sal_uInt32 s_nFormat = (sal_uInt32)-1;
+ if ((sal_uInt32)-1 == s_nFormat)
+ {
+ s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"dbaccess.ColumnDescriptorTransfer\""));
+ OSL_ENSURE((sal_uInt32)-1 != s_nFormat, "OColumnTransferable::getDescriptorFormatId: bad exchange id!");
+ }
+ return s_nFormat;
+ }
+
+ //--------------------------------------------------------------------
+ void OColumnTransferable::implConstruct( const ::rtl::OUString& _rDatasource
+ ,const ::rtl::OUString& _rConnectionResource
+ ,const sal_Int32 _nCommandType
+ ,const ::rtl::OUString& _rCommand
+ , const ::rtl::OUString& _rFieldName)
+ {
+ const sal_Unicode cSeparator = sal_Unicode(11);
+ const ::rtl::OUString sSeparator(&cSeparator, 1);
+
+ m_sCompatibleFormat = ::rtl::OUString();
+ m_sCompatibleFormat += _rDatasource;
+ m_sCompatibleFormat += sSeparator;
+ m_sCompatibleFormat += _rCommand;
+ m_sCompatibleFormat += sSeparator;
+
+ sal_Unicode cCommandType;
+ switch (_nCommandType)
+ {
+ case CommandType::TABLE:
+ cCommandType = '0';
+ break;
+ case CommandType::QUERY:
+ cCommandType = '1';
+ break;
+ default:
+ cCommandType = '2';
+ break;
+ }
+ m_sCompatibleFormat += ::rtl::OUString(&cCommandType, 1);
+ m_sCompatibleFormat += sSeparator;
+ m_sCompatibleFormat += _rFieldName;
+
+ m_aDescriptor.clear();
+ if ((m_nFormatFlags & CTF_COLUMN_DESCRIPTOR) == CTF_COLUMN_DESCRIPTOR)
+ {
+ m_aDescriptor.setDataSource(_rDatasource);
+ if ( _rConnectionResource.getLength() )
+ m_aDescriptor[daConnectionResource] <<= _rConnectionResource;
+
+ m_aDescriptor[daCommand] <<= _rCommand;
+ m_aDescriptor[daCommandType] <<= _nCommandType;
+ m_aDescriptor[daColumnName] <<= _rFieldName;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void OColumnTransferable::AddSupportedFormats()
+ {
+ if (CTF_CONTROL_EXCHANGE & m_nFormatFlags)
+ AddFormat(SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE);
+
+ if (CTF_FIELD_DESCRIPTOR & m_nFormatFlags)
+ AddFormat(SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE);
+
+ if (CTF_COLUMN_DESCRIPTOR & m_nFormatFlags)
+ AddFormat(getDescriptorFormatId());
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OColumnTransferable::GetData( const DataFlavor& _rFlavor )
+ {
+ const sal_uInt32 nFormatId = SotExchange::GetFormat(_rFlavor);
+ switch (nFormatId)
+ {
+ case SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE:
+ case SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE:
+ return SetString(m_sCompatibleFormat, _rFlavor);
+ }
+ if (nFormatId == getDescriptorFormatId())
+ return SetAny( makeAny( m_aDescriptor.createPropertyValueSequence() ), _rFlavor );
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OColumnTransferable::canExtractColumnDescriptor(const DataFlavorExVector& _rFlavors, sal_Int32 _nFormats)
+ {
+ sal_Bool bFieldFormat = 0 != (_nFormats & CTF_FIELD_DESCRIPTOR);
+ sal_Bool bControlFormat = 0 != (_nFormats & CTF_CONTROL_EXCHANGE);
+ sal_Bool bDescriptorFormat = 0 != (_nFormats & CTF_COLUMN_DESCRIPTOR);
+ for ( DataFlavorExVector::const_iterator aCheck = _rFlavors.begin();
+ aCheck != _rFlavors.end();
+ ++aCheck
+ )
+ {
+ if (bFieldFormat && (SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE == aCheck->mnSotId))
+ return sal_True;
+ if (bControlFormat && (SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE == aCheck->mnSotId))
+ return sal_True;
+ if (bDescriptorFormat && (getDescriptorFormatId() == aCheck->mnSotId))
+ return sal_True;
+ }
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ ODataAccessDescriptor OColumnTransferable::extractColumnDescriptor(const TransferableDataHelper& _rData)
+ {
+ if (_rData.HasFormat(getDescriptorFormatId()))
+ {
+ // the object has a real descriptor object (not just the old compatible format)
+
+ // extract the any from the transferable
+ DataFlavor aFlavor;
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+#endif
+ SotExchange::GetFormatDataFlavor(getDescriptorFormatId(), aFlavor);
+ OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid data format (no flavor)!");
+
+ Any aDescriptor = _rData.GetAny(aFlavor);
+
+ // extract the property value sequence
+ Sequence< PropertyValue > aDescriptorProps;
+#if OSL_DEBUG_LEVEL > 0
+ bSuccess =
+#endif
+ aDescriptor >>= aDescriptorProps;
+ OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid clipboard format!");
+
+ // build the real descriptor
+ return ODataAccessDescriptor(aDescriptorProps);
+ }
+
+ // only the old (compatible) format exists -> use the other extract method ...
+ ::rtl::OUString sDatasource, sCommand, sFieldName,sDatabaseLocation,sConnectionResource;
+ sal_Int32 nCommandType = CommandType::COMMAND;
+
+ ODataAccessDescriptor aDescriptor;
+ if (extractColumnDescriptor(_rData, sDatasource, sDatabaseLocation,sConnectionResource,nCommandType, sCommand, sFieldName))
+ {
+ // and build an own descriptor
+ if ( sDatasource.getLength() )
+ aDescriptor[daDataSource] <<= sDatasource;
+ if ( sDatabaseLocation.getLength() )
+ aDescriptor[daDatabaseLocation] <<= sDatabaseLocation;
+ if ( sConnectionResource.getLength() )
+ aDescriptor[daConnectionResource] <<= sConnectionResource;
+
+ aDescriptor[daCommand] <<= sCommand;
+ aDescriptor[daCommandType] <<= nCommandType;
+ aDescriptor[daColumnName] <<= sFieldName;
+ }
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OColumnTransferable::extractColumnDescriptor(const TransferableDataHelper& _rData
+ ,::rtl::OUString& _rDatasource
+ ,::rtl::OUString& _rDatabaseLocation
+ ,::rtl::OUString& _rConnectionResource
+ ,sal_Int32& _nCommandType
+ ,::rtl::OUString& _rCommand
+ ,::rtl::OUString& _rFieldName)
+ {
+ if ( _rData.HasFormat(getDescriptorFormatId()) )
+ {
+ ODataAccessDescriptor aDescriptor = extractColumnDescriptor(_rData);
+ if ( aDescriptor.has(daDataSource) )
+ aDescriptor[daDataSource] >>= _rDatasource;
+ if ( aDescriptor.has(daDatabaseLocation) )
+ aDescriptor[daDatabaseLocation] >>= _rDatabaseLocation;
+ if ( aDescriptor.has(daConnectionResource) )
+ aDescriptor[daConnectionResource] >>= _rConnectionResource;
+
+ aDescriptor[daCommand] >>= _rCommand;
+ aDescriptor[daCommandType] >>= _nCommandType;
+ aDescriptor[daColumnName] >>= _rFieldName;
+ return sal_True;
+ }
+
+ // check if we have a (string) format we can use ....
+ SotFormatStringId nRecognizedFormat = 0;
+ if (_rData.HasFormat(SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE))
+ nRecognizedFormat = SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE;
+ if (_rData.HasFormat(SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE))
+ nRecognizedFormat = SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE;
+ if (!nRecognizedFormat)
+ return sal_False;
+
+ String sFieldDescription;
+ const_cast<TransferableDataHelper&>(_rData).GetString(nRecognizedFormat, sFieldDescription);
+
+ const sal_Unicode cSeparator = sal_Unicode(11);
+ _rDatasource = sFieldDescription.GetToken(0, cSeparator);
+ _rCommand = sFieldDescription.GetToken(1, cSeparator);
+ _nCommandType = sFieldDescription.GetToken(2, cSeparator).ToInt32();
+ _rFieldName = sFieldDescription.GetToken(3, cSeparator);
+
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ void OColumnTransferable::addDataToContainer( TransferDataContainer* _pContainer )
+ {
+ OSL_ENSURE( _pContainer, "OColumnTransferable::addDataToContainer: invalid container!" );
+ if ( _pContainer )
+ {
+ if ( m_nFormatFlags & CTF_FIELD_DESCRIPTOR )
+ _pContainer->CopyAny( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE, makeAny( m_sCompatibleFormat ) );
+
+ if ( m_nFormatFlags & CTF_CONTROL_EXCHANGE )
+ _pContainer->CopyAny( SOT_FORMATSTR_ID_SBA_CTRLDATAEXCHANGE, makeAny( m_sCompatibleFormat ) );
+
+ if ( m_nFormatFlags & CTF_COLUMN_DESCRIPTOR )
+ {
+ Any aContent = makeAny( m_aDescriptor.createPropertyValueSequence() );
+ _pContainer->CopyAny(
+ sal::static_int_cast< USHORT >( getDescriptorFormatId() ),
+ aContent );
+ }
+ }
+ }
+
+ //====================================================================
+ //= ODataAccessObjectTransferable
+ //====================================================================
+ ODataAccessObjectTransferable::ODataAccessObjectTransferable(
+ const ::rtl::OUString& _rDatasource
+ ,const ::rtl::OUString& _rConnectionResource
+ ,const sal_Int32 _nCommandType
+ ,const ::rtl::OUString& _rCommand
+ )
+ {
+ construct(_rDatasource,_rConnectionResource,_nCommandType,_rCommand,NULL,(CommandType::COMMAND == _nCommandType),_rCommand);
+ }
+ //--------------------------------------------------------------------
+ ODataAccessObjectTransferable::ODataAccessObjectTransferable(
+ const ::rtl::OUString& _rDatasource
+ ,const ::rtl::OUString& _rConnectionResource
+ ,const sal_Int32 _nCommandType
+ ,const ::rtl::OUString& _rCommand
+ ,const Reference< XConnection >& _rxConnection)
+ {
+ OSL_ENSURE(_rxConnection.is(),"Wrong ctor used.!");
+ construct(_rDatasource,_rConnectionResource,_nCommandType,_rCommand,_rxConnection,(CommandType::COMMAND == _nCommandType),_rCommand);
+ }
+
+ // -----------------------------------------------------------------------------
+ ODataAccessObjectTransferable::ODataAccessObjectTransferable(const Reference< XPropertySet >& _rxLivingForm)
+ {
+ // collect some properties of the form
+ ::rtl::OUString sDatasourceName,sConnectionResource;
+ sal_Int32 nObjectType = CommandType::COMMAND;
+ ::rtl::OUString sObjectName;
+ Reference< XConnection > xConnection;
+ try
+ {
+ _rxLivingForm->getPropertyValue(FM_PROP_COMMANDTYPE) >>= nObjectType;
+ _rxLivingForm->getPropertyValue(FM_PROP_COMMAND) >>= sObjectName;
+ _rxLivingForm->getPropertyValue(FM_PROP_DATASOURCE) >>= sDatasourceName;
+ _rxLivingForm->getPropertyValue(FM_PROP_URL) >>= sConnectionResource;
+ _rxLivingForm->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConnection;
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "ODataAccessObjectTransferable::ODataAccessObjectTransferable: could not collect essential form attributes !");
+ return;
+ }
+
+ String sObjectKind = (CommandType::TABLE == nObjectType) ? String('1') : String('0');
+
+ // check if the SQL-statement is modified
+ ::rtl::OUString sCompleteStatement;
+ try
+ {
+ _rxLivingForm->getPropertyValue(FM_PROP_ACTIVECOMMAND) >>= sCompleteStatement;
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "ODataAccessObjectTransferable::ODataAccessObjectTransferable: could not collect essential form attributes (part two) !");
+ return;
+ }
+
+ construct( sDatasourceName
+ ,sConnectionResource
+ ,nObjectType
+ ,sObjectName,xConnection
+ ,!((CommandType::QUERY == nObjectType))
+ ,sCompleteStatement);
+ }
+
+ // -----------------------------------------------------------------------------
+ void ODataAccessObjectTransferable::AddSupportedFormats()
+ {
+ sal_Int32 nObjectType = CommandType::COMMAND;
+ m_aDescriptor[daCommandType] >>= nObjectType;
+ switch (nObjectType)
+ {
+ case CommandType::TABLE:
+ AddFormat(SOT_FORMATSTR_ID_DBACCESS_TABLE);
+ break;
+ case CommandType::QUERY:
+ AddFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY);
+ break;
+ case CommandType::COMMAND:
+ AddFormat(SOT_FORMATSTR_ID_DBACCESS_COMMAND);
+ break;
+ }
+
+ sal_Int32 nDescriptorLen = m_sCompatibleObjectDescription.getLength();
+ if (nDescriptorLen)
+ {
+ if (m_sCompatibleObjectDescription.getStr()[nDescriptorLen] == 11)
+ m_sCompatibleObjectDescription = m_sCompatibleObjectDescription.copy(0, nDescriptorLen - 1);
+
+ if (nDescriptorLen)
+ AddFormat(SOT_FORMATSTR_ID_SBA_DATAEXCHANGE);
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool ODataAccessObjectTransferable::GetData( const DataFlavor& rFlavor )
+ {
+ ULONG nFormat = SotExchange::GetFormat(rFlavor);
+ switch (nFormat)
+ {
+ case SOT_FORMATSTR_ID_DBACCESS_TABLE:
+ case SOT_FORMATSTR_ID_DBACCESS_QUERY:
+ case SOT_FORMATSTR_ID_DBACCESS_COMMAND:
+ return SetAny( makeAny(m_aDescriptor.createPropertyValueSequence()), rFlavor );
+
+ case SOT_FORMATSTR_ID_SBA_DATAEXCHANGE:
+ return SetString(m_sCompatibleObjectDescription, rFlavor);
+ }
+ return sal_False;
+ }
+
+ // -----------------------------------------------------------------------------
+ sal_Bool ODataAccessObjectTransferable::canExtractObjectDescriptor(const DataFlavorExVector& _rFlavors)
+ {
+ for ( DataFlavorExVector::const_iterator aCheck = _rFlavors.begin();
+ aCheck != _rFlavors.end();
+ ++aCheck
+ )
+ {
+ if (SOT_FORMATSTR_ID_DBACCESS_TABLE == aCheck->mnSotId)
+ return sal_True;
+ if (SOT_FORMATSTR_ID_DBACCESS_QUERY == aCheck->mnSotId)
+ return sal_True;
+ if (SOT_FORMATSTR_ID_DBACCESS_COMMAND == aCheck->mnSotId)
+ return sal_True;
+ }
+ return sal_False;
+ }
+
+ // -----------------------------------------------------------------------------
+ ODataAccessDescriptor ODataAccessObjectTransferable::extractObjectDescriptor(const TransferableDataHelper& _rData)
+ {
+ sal_Int32 nKnownFormatId = 0;
+ if ( _rData.HasFormat( SOT_FORMATSTR_ID_DBACCESS_TABLE ) )
+ nKnownFormatId = SOT_FORMATSTR_ID_DBACCESS_TABLE;
+ if ( _rData.HasFormat( SOT_FORMATSTR_ID_DBACCESS_QUERY ) )
+ nKnownFormatId = SOT_FORMATSTR_ID_DBACCESS_QUERY;
+ if ( _rData.HasFormat( SOT_FORMATSTR_ID_DBACCESS_COMMAND ) )
+ nKnownFormatId = SOT_FORMATSTR_ID_DBACCESS_COMMAND;
+
+ if (0 != nKnownFormatId)
+ {
+ // extract the any from the transferable
+ DataFlavor aFlavor;
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+#endif
+ SotExchange::GetFormatDataFlavor(nKnownFormatId, aFlavor);
+ OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid data format (no flavor)!");
+
+ Any aDescriptor = _rData.GetAny(aFlavor);
+
+ // extract the property value sequence
+ Sequence< PropertyValue > aDescriptorProps;
+#if OSL_DEBUG_LEVEL > 0
+ bSuccess =
+#endif
+ aDescriptor >>= aDescriptorProps;
+ OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid clipboard format!");
+
+ // build the real descriptor
+ return ODataAccessDescriptor(aDescriptorProps);
+ }
+
+ OSL_ENSURE( sal_False, "OColumnTransferable::extractColumnDescriptor: unsupported formats only!" );
+ return ODataAccessDescriptor();
+ }
+
+ // -----------------------------------------------------------------------------
+ void ODataAccessObjectTransferable::addCompatibleSelectionDescription( const Sequence< Any >& _rSelRows )
+ {
+ const sal_Unicode cSeparator(11);
+ const ::rtl::OUString sSeparator(&cSeparator, 1);
+
+ const Any* pSelRows = _rSelRows.getConstArray();
+ const Any* pSelRowsEnd = pSelRows + _rSelRows.getLength();
+ for ( ; pSelRows < pSelRowsEnd; ++pSelRows )
+ {
+ sal_Int32 nSelectedRow( 0 );
+ OSL_VERIFY( *pSelRows >>= nSelectedRow );
+
+ m_sCompatibleObjectDescription += ::rtl::OUString::valueOf((sal_Int32)nSelectedRow);
+ m_sCompatibleObjectDescription += sSeparator;
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ void ODataAccessObjectTransferable::ObjectReleased()
+ {
+ m_aDescriptor.clear();
+ }
+ // -----------------------------------------------------------------------------
+ void ODataAccessObjectTransferable::construct( const ::rtl::OUString& _rDatasource
+ ,const ::rtl::OUString& _rConnectionResource
+ ,const sal_Int32 _nCommandType
+ ,const ::rtl::OUString& _rCommand
+ ,const Reference< XConnection >& _rxConnection
+ ,sal_Bool _bAddCommand
+ ,const ::rtl::OUString& _sActiveCommand)
+ {
+ m_aDescriptor.setDataSource(_rDatasource);
+ // build the descriptor (the property sequence)
+ if ( _rConnectionResource.getLength() )
+ m_aDescriptor[daConnectionResource] <<= _rConnectionResource;
+ if ( _rxConnection.is() )
+ m_aDescriptor[daConnection] <<= _rxConnection;
+ m_aDescriptor[daCommand] <<= _rCommand;
+ m_aDescriptor[daCommandType] <<= _nCommandType;
+
+ // extract the single values from the sequence
+
+ ::rtl::OUString sObjectName;
+ ::rtl::OUString sDatasourceName = _rDatasource;
+ sObjectName = _rCommand;
+
+ // for compatibility: create a string which can be used for the SOT_FORMATSTR_ID_SBA_DATAEXCHANGE format
+
+ sal_Bool bTreatAsStatement = (CommandType::COMMAND == _nCommandType);
+ // statements are - in this old and ugly format - described as queries
+
+ const sal_Unicode cSeparator = sal_Unicode(11);
+ const ::rtl::OUString sSeparator(&cSeparator, 1);
+
+ const sal_Unicode cTableMark = '1';
+ const sal_Unicode cQueryMark = '0';
+
+ // build the descriptor string
+ m_sCompatibleObjectDescription += sDatasourceName;
+ m_sCompatibleObjectDescription += sSeparator;
+ m_sCompatibleObjectDescription += bTreatAsStatement ? ::rtl::OUString() : sObjectName;
+ m_sCompatibleObjectDescription += sSeparator;
+ switch (_nCommandType)
+ {
+ case CommandType::TABLE:
+ m_sCompatibleObjectDescription += ::rtl::OUString(&cTableMark, 1);
+ break;
+ case CommandType::QUERY:
+ m_sCompatibleObjectDescription += ::rtl::OUString(&cQueryMark, 1);
+ break;
+ case CommandType::COMMAND:
+ m_sCompatibleObjectDescription += ::rtl::OUString(&cQueryMark, 1);
+ // think of it as a query
+ break;
+ }
+ m_sCompatibleObjectDescription += sSeparator;
+ m_sCompatibleObjectDescription += _bAddCommand ? _sActiveCommand : ::rtl::OUString();
+ m_sCompatibleObjectDescription += sSeparator;
+ }
+
+ //--------------------------------------------------------------------
+ OMultiColumnTransferable::OMultiColumnTransferable(const Sequence< PropertyValue >& _aDescriptors) : m_aDescriptors(_aDescriptors)
+ {
+ }
+ //--------------------------------------------------------------------
+ sal_uInt32 OMultiColumnTransferable::getDescriptorFormatId()
+ {
+ static sal_uInt32 s_nFormat = (sal_uInt32)-1;
+ if ((sal_uInt32)-1 == s_nFormat)
+ {
+ s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"dbaccess.MultipleColumnDescriptorTransfer\""));
+ OSL_ENSURE((sal_uInt32)-1 != s_nFormat, "OColumnTransferable::getDescriptorFormatId: bad exchange id!");
+ }
+ return s_nFormat;
+ }
+ //--------------------------------------------------------------------
+ void OMultiColumnTransferable::AddSupportedFormats()
+ {
+ AddFormat(getDescriptorFormatId());
+ }
+ //--------------------------------------------------------------------
+ void OMultiColumnTransferable::push_back(ODataAccessDescriptor& _aDescriptor)
+ {
+ const sal_Int32 nCount = m_aDescriptors.getLength();
+ m_aDescriptors.realloc(nCount+1);
+ m_aDescriptors[nCount].Value <<= _aDescriptor.createPropertyValueSequence();
+ }
+ //--------------------------------------------------------------------
+ sal_Bool OMultiColumnTransferable::GetData( const DataFlavor& _rFlavor )
+ {
+ const sal_uInt32 nFormatId = SotExchange::GetFormat(_rFlavor);
+ if (nFormatId == getDescriptorFormatId())
+ {
+ return SetAny( makeAny( m_aDescriptors ), _rFlavor );
+ }
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OMultiColumnTransferable::canExtractDescriptor(const DataFlavorExVector& _rFlavors)
+ {
+ DataFlavorExVector::const_iterator aCheck = _rFlavors.begin();
+ for ( ;
+ aCheck != _rFlavors.end() && getDescriptorFormatId() == aCheck->mnSotId;
+ ++aCheck
+ )
+ ;
+
+ return aCheck == _rFlavors.end();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< PropertyValue > OMultiColumnTransferable::extractDescriptor(const TransferableDataHelper& _rData)
+ {
+ Sequence< PropertyValue > aList;
+ if (_rData.HasFormat(getDescriptorFormatId()))
+ {
+ // extract the any from the transferable
+ DataFlavor aFlavor;
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+#endif
+ SotExchange::GetFormatDataFlavor(getDescriptorFormatId(), aFlavor);
+ OSL_ENSURE(bSuccess, "OColumnTransferable::extractColumnDescriptor: invalid data format (no flavor)!");
+
+ _rData.GetAny(aFlavor) >>= aList;
+ } // if (_rData.HasFormat(getDescriptorFormatId()))
+ return aList;
+ }
+ // -----------------------------------------------------------------------------
+ void OMultiColumnTransferable::ObjectReleased()
+ {
+ m_aDescriptors.realloc(0);
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/fmcomp/dbaobjectex.cxx b/svx/source/fmcomp/dbaobjectex.cxx
new file mode 100644
index 000000000000..8f50991d3195
--- /dev/null
+++ b/svx/source/fmcomp/dbaobjectex.cxx
@@ -0,0 +1,185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/dbaobjectex.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#include "fmprop.hrc"
+#include <comphelper/extract.hxx>
+#include <sot/formats.hxx>
+#include <sot/exchange.hxx>
+#include <comphelper/propertysetinfo.hxx>
+#include "fmprop.hrc"
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::datatransfer;
+ using namespace ::comphelper;
+
+ //====================================================================
+ //= OComponentTransferable
+ //====================================================================
+ //--------------------------------------------------------------------
+ OComponentTransferable::OComponentTransferable(const ::rtl::OUString& _rDatasourceOrLocation
+ ,const Reference< XContent>& _xContent)
+ {
+ m_aDescriptor.setDataSource(_rDatasourceOrLocation);
+ m_aDescriptor[daComponent] <<= _xContent;
+ }
+
+
+ //--------------------------------------------------------------------
+ sal_uInt32 OComponentTransferable::getDescriptorFormatId(sal_Bool _bExtractForm)
+ {
+ static sal_uInt32 s_nReportFormat = (sal_uInt32)-1;
+ static sal_uInt32 s_nFormFormat = (sal_uInt32)-1;
+ if ( _bExtractForm && (sal_uInt32)-1 == s_nFormFormat )
+ {
+ s_nFormFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"dbaccess.FormComponentDescriptorTransfer\"" ));
+ OSL_ENSURE((sal_uInt32)-1 != s_nFormFormat, "OComponentTransferable::getDescriptorFormatId: bad exchange id!");
+ }
+ else if ( !_bExtractForm && (sal_uInt32)-1 == s_nReportFormat)
+ {
+ s_nReportFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"dbaccess.ReportComponentDescriptorTransfer\""));
+ OSL_ENSURE((sal_uInt32)-1 != s_nReportFormat, "OComponentTransferable::getDescriptorFormatId: bad exchange id!");
+ }
+ return _bExtractForm ? s_nFormFormat : s_nReportFormat;
+ }
+
+ //--------------------------------------------------------------------
+ void OComponentTransferable::AddSupportedFormats()
+ {
+ sal_Bool bForm = sal_True;
+ try
+ {
+ Reference<XPropertySet> xProp;
+ m_aDescriptor[daComponent] >>= xProp;
+ if ( xProp.is() )
+ xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsForm"))) >>= bForm;
+ }
+ catch(Exception)
+ {}
+ AddFormat(getDescriptorFormatId(bForm));
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OComponentTransferable::GetData( const DataFlavor& _rFlavor )
+ {
+ const sal_uInt32 nFormatId = SotExchange::GetFormat(_rFlavor);
+ if ( nFormatId == getDescriptorFormatId(sal_True) || nFormatId == getDescriptorFormatId(sal_False) )
+ return SetAny( makeAny( m_aDescriptor.createPropertyValueSequence() ), _rFlavor );
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OComponentTransferable::canExtractComponentDescriptor(const DataFlavorExVector& _rFlavors,sal_Bool _bForm )
+ {
+ DataFlavorExVector::const_iterator aEnd = _rFlavors.end();
+ for ( DataFlavorExVector::const_iterator aCheck = _rFlavors.begin();
+ aCheck != aEnd;
+ ++aCheck
+ )
+ {
+ if ( getDescriptorFormatId(_bForm) == aCheck->mnSotId )
+ return sal_True;
+ }
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ ODataAccessDescriptor OComponentTransferable::extractComponentDescriptor(const TransferableDataHelper& _rData)
+ {
+ sal_Bool bForm = _rData.HasFormat(getDescriptorFormatId(sal_True));
+ if ( bForm || _rData.HasFormat(getDescriptorFormatId(sal_False)) )
+ {
+ // the object has a real descriptor object (not just the old compatible format)
+
+ // extract the any from the transferable
+ DataFlavor aFlavor;
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+#endif
+ SotExchange::GetFormatDataFlavor(getDescriptorFormatId(bForm), aFlavor);
+ OSL_ENSURE(bSuccess, "OComponentTransferable::extractColumnDescriptor: invalid data format (no flavor)!");
+
+ Any aDescriptor = _rData.GetAny(aFlavor);
+
+ // extract the property value sequence
+ Sequence< PropertyValue > aDescriptorProps;
+#if OSL_DEBUG_LEVEL > 0
+ bSuccess =
+#endif
+ aDescriptor >>= aDescriptorProps;
+ OSL_ENSURE(bSuccess, "OComponentTransferable::extractColumnDescriptor: invalid clipboard format!");
+
+ // build the real descriptor
+ return ODataAccessDescriptor(aDescriptorProps);
+ }
+
+ return ODataAccessDescriptor();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OComponentTransferable::extractComponentDescriptor(const TransferableDataHelper& _rData
+ ,sal_Bool _bExtractForm
+ , ::rtl::OUString& _rDatasourceOrLocation
+ , ::com::sun::star::uno::Reference< XContent>& _xContent)
+ {
+ if ( _rData.HasFormat( getDescriptorFormatId(_bExtractForm)) )
+ {
+ ODataAccessDescriptor aDescriptor = extractComponentDescriptor(_rData);
+ _rDatasourceOrLocation = aDescriptor.getDataSource();
+ aDescriptor[daComponent] >>= _xContent;
+ return sal_True;
+ }
+
+ return sal_False;
+ }
+//........................................................................
+} // namespace svx
+//........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
new file mode 100644
index 000000000000..03623fbafd7a
--- /dev/null
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -0,0 +1,2146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "dbexch.hrc"
+#include "fmgridif.hxx"
+#include "fmitems.hxx"
+#include "fmprop.hrc"
+#include "svx/fmtools.hxx"
+#include "fmresids.hrc"
+#include "fmservs.hxx"
+#include "fmurl.hxx"
+#include "formcontrolfactory.hxx"
+#include "gridcell.hxx"
+#include "gridcols.hxx"
+#include "svx/dbaexchange.hxx"
+#include "svx/dialmgr.hxx"
+#include "svx/dialogs.hrc"
+#include "svx/fmgridcl.hxx"
+#include "svx/svxdlg.hxx"
+#include "svx/svxids.hrc"
+#include "trace.hxx"
+
+#include <com/sun/star/form/XConfirmDeleteListener.hpp>
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/RowChangeAction.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/util/XNumberFormats.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+
+#ifndef _SVSTDARR_STRINGSDTOR
+#define _SVSTDARR_STRINGSDTOR
+#define _SVSTDARR_ULONGS
+#include <svl/svstdarr.hxx>
+#endif
+
+#include <comphelper/extract.hxx>
+#include <comphelper/numbers.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/property.hxx>
+#include <connectivity/dbtools.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/eitem.hxx>
+#include <svtools/fmtfield.hxx>
+#include <svl/numuno.hxx>
+#include <tools/multisel.hxx>
+#include <tools/shl.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/help.hxx>
+#include <vcl/image.hxx>
+#include <vcl/longcurr.hxx>
+#include <vcl/menu.hxx>
+
+#include <math.h>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::container;
+using namespace ::cppu;
+using namespace ::svxform;
+using namespace ::svx;
+
+//==============================================================================
+//------------------------------------------------------------------------------
+::rtl::OUString FieldServiceFromId(sal_Int32 nID)
+{
+ switch (nID)
+ {
+ case SID_FM_EDIT : return FM_COL_TEXTFIELD;
+ case SID_FM_COMBOBOX : return FM_COL_COMBOBOX;
+ case SID_FM_LISTBOX : return FM_COL_LISTBOX;
+ case SID_FM_CHECKBOX : return FM_COL_CHECKBOX;
+ case SID_FM_DATEFIELD : return FM_COL_DATEFIELD;
+ case SID_FM_TIMEFIELD : return FM_COL_TIMEFIELD;
+ case SID_FM_NUMERICFIELD : return FM_COL_NUMERICFIELD;
+ case SID_FM_CURRENCYFIELD : return FM_COL_CURRENCYFIELD;
+ case SID_FM_PATTERNFIELD : return FM_COL_PATTERNFIELD;
+ case SID_FM_FORMATTEDFIELD : return FM_COL_FORMATTEDFIELD;
+ }
+ return ::rtl::OUString();
+}
+
+//==============================================================================
+struct FmGridHeaderData
+{
+ ODataAccessDescriptor aDropData;
+ Point aDropPosPixel;
+ sal_Int8 nDropAction;
+ Reference< XInterface > xDroppedStatement;
+ Reference< XInterface > xDroppedResultSet;
+};
+
+//==============================================================================
+//------------------------------------------------------------------------------
+const sal_Int16 nChangeTypeOffset = 1000;
+void SetMenuItem(const ImageList& rList, sal_uInt16 nID, Menu* pMenu, Menu& rNewMenu, sal_Bool bDesignMode = sal_True, sal_Int16 nOffset = nChangeTypeOffset)
+{
+ pMenu->SetItemImage(nID, rList.GetImage(nID));
+ pMenu->EnableItem(nID, bDesignMode);
+ rNewMenu.InsertItem(nID + nOffset, pMenu->GetItemText(nID));
+ rNewMenu.SetItemImage(nID + nOffset, rList.GetImage(nID));
+ rNewMenu.SetHelpId(nID + nOffset, pMenu->GetHelpId(nID));
+ rNewMenu.EnableItem(nID + nOffset, bDesignMode);
+}
+
+//------------------------------------------------------------------------------
+FmGridHeader::FmGridHeader( BrowseBox* pParent, WinBits nWinBits)
+ :EditBrowserHeader(pParent, nWinBits)
+ ,DropTargetHelper(this)
+ ,m_pImpl(new FmGridHeaderData)
+{
+}
+
+//------------------------------------------------------------------------------
+FmGridHeader::~FmGridHeader()
+{
+ delete m_pImpl;
+}
+
+//------------------------------------------------------------------------------
+sal_uInt16 FmGridHeader::GetModelColumnPos(sal_uInt16 nId) const
+{
+ return static_cast<FmGridControl*>(GetParent())->GetModelColumnPos(nId);
+}
+//---------------------------------------------------------------------------------------
+void FmGridHeader::notifyColumnSelect(sal_uInt16 nColumnId)
+{
+ sal_uInt16 nPos = GetModelColumnPos(nColumnId);
+ Reference< XIndexAccess > xColumns(((FmGridControl*)GetParent())->GetPeer()->getColumns(), UNO_QUERY);
+ if ( nPos < xColumns->getCount() )
+ {
+ Reference< XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY);
+ if ( xSelSupplier.is() )
+ {
+ Reference< XPropertySet > xColumn;
+ xColumns->getByIndex(nPos) >>= xColumn;
+ xSelSupplier->select(makeAny(xColumn));
+ }
+ }
+}
+//------------------------------------------------------------------------------
+void FmGridHeader::Select()
+{
+ EditBrowserHeader::Select();
+ notifyColumnSelect(GetCurItemId());
+}
+
+//------------------------------------------------------------------------------
+void FmGridHeader::RequestHelp( const HelpEvent& rHEvt )
+{
+ sal_uInt16 nItemId = GetItemId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
+ if ( nItemId )
+ {
+ if ( rHEvt.GetMode() & (HELPMODE_QUICK | HELPMODE_BALLOON) )
+ {
+ Rectangle aItemRect = GetItemRect( nItemId );
+ Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
+ aItemRect.Left() = aPt.X();
+ aItemRect.Top() = aPt.Y();
+ aPt = OutputToScreenPixel( aItemRect.BottomRight() );
+ aItemRect.Right() = aPt.X();
+ aItemRect.Bottom() = aPt.Y();
+
+ sal_uInt16 nPos = GetModelColumnPos(nItemId);
+ Reference< ::com::sun::star::container::XIndexContainer > xColumns(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
+ try
+ {
+ Reference< ::com::sun::star::beans::XPropertySet > xColumn(xColumns->getByIndex(nPos),UNO_QUERY);
+ ::rtl::OUString aHelpText;
+ xColumn->getPropertyValue(FM_PROP_HELPTEXT) >>= aHelpText;
+ if ( !aHelpText.getLength() )
+ xColumn->getPropertyValue(FM_PROP_DESCRIPTION) >>= aHelpText;
+ if ( aHelpText.getLength() )
+ {
+ if ( rHEvt.GetMode() & HELPMODE_BALLOON )
+ Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText );
+ else
+ Help::ShowQuickHelp( this, aItemRect, aHelpText );
+ return;
+ }
+ }
+ catch(Exception&)
+ {
+ return;
+ }
+ }
+ }
+ EditBrowserHeader::RequestHelp( rHEvt );
+}
+
+//------------------------------------------------------------------------------
+sal_Int8 FmGridHeader::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ // drop allowed in design mode only
+ if (!static_cast<FmGridControl*>(GetParent())->IsDesignMode())
+ return DND_ACTION_NONE;
+
+ // search for recognized formats
+ const DataFlavorExVector& rFlavors = GetDataFlavorExVector();
+ if (OColumnTransferable::canExtractColumnDescriptor(rFlavors, CTF_COLUMN_DESCRIPTOR | CTF_FIELD_DESCRIPTOR))
+ return rEvt.mnAction;
+
+ return DND_ACTION_NONE;
+}
+
+//------------------------------------------------------------------------------
+sal_Int8 FmGridHeader::ExecuteDrop( const ExecuteDropEvent& _rEvt )
+{
+ if (!static_cast<FmGridControl*>(GetParent())->IsDesignMode())
+ return DND_ACTION_NONE;
+
+ TransferableDataHelper aDroppedData(_rEvt.maDropEvent.Transferable);
+
+ // check the formats
+ sal_Bool bColumnDescriptor = OColumnTransferable::canExtractColumnDescriptor(aDroppedData.GetDataFlavorExVector(), CTF_COLUMN_DESCRIPTOR);
+ sal_Bool bFieldDescriptor = OColumnTransferable::canExtractColumnDescriptor(aDroppedData.GetDataFlavorExVector(), CTF_FIELD_DESCRIPTOR);
+ if (!bColumnDescriptor && !bFieldDescriptor)
+ {
+ DBG_ERROR("FmGridHeader::ExecuteDrop: should never have reached this (no extractable format)!");
+ return DND_ACTION_NONE;
+ }
+
+ // extract the descriptor
+ ::rtl::OUString sDatasouce, sCommand, sFieldName,sDatabaseLocation,sConnnectionResource;
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ Reference< XPreparedStatement > xStatement;
+ Reference< XResultSet > xResultSet;
+ Reference< XPropertySet > xField;
+ Reference< XConnection > xConnection;
+
+ ODataAccessDescriptor aColumn = OColumnTransferable::extractColumnDescriptor(aDroppedData);
+ if (aColumn.has(daDataSource)) aColumn[daDataSource] >>= sDatasouce;
+ if (aColumn.has(daDatabaseLocation)) aColumn[daDatabaseLocation] >>= sDatabaseLocation;
+ if (aColumn.has(daConnectionResource)) aColumn[daConnectionResource] >>= sConnnectionResource;
+ if (aColumn.has(daCommand)) aColumn[daCommand] >>= sCommand;
+ if (aColumn.has(daCommandType)) aColumn[daCommandType] >>= nCommandType;
+ if (aColumn.has(daColumnName)) aColumn[daColumnName] >>= sFieldName;
+ if (aColumn.has(daColumnObject))aColumn[daColumnObject] >>= xField;
+ if (aColumn.has(daConnection)) aColumn[daConnection] >>= xConnection;
+
+ if ( !sFieldName.getLength()
+ || !sCommand.getLength()
+ || ( !sDatasouce.getLength()
+ && !sDatabaseLocation.getLength()
+ && !xConnection.is()
+ )
+ )
+ {
+ DBG_ERROR( "FmGridHeader::ExecuteDrop: somebody started a nonsense drag operation!!" );
+ return DND_ACTION_NONE;
+ }
+
+ try
+ {
+ // need a connection
+ if (!xConnection.is())
+ { // the transferable did not contain the connection -> build an own one
+ try
+ {
+ ::rtl::OUString sSignificantSource( sDatasouce.getLength() ? sDatasouce : sDatabaseLocation );
+ xConnection = OStaticDataAccessTools().getConnection_withFeedback(sSignificantSource, ::rtl::OUString(),::rtl::OUString(),static_cast<FmGridControl*>(GetParent())->getServiceManager());
+ }
+ catch(NoSuchElementException&)
+ { // allowed, means sDatasouce isn't a valid data source name ....
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmGridHeader::ExecuteDrop: could not retrieve the database access object !");
+ }
+
+ if (!xConnection.is())
+ {
+ DBG_ERROR("FmGridHeader::ExecuteDrop: could not retrieve the database access object !");
+ return DND_ACTION_NONE;
+ }
+ }
+
+ // try to obtain the column object
+ if (!xField.is())
+ {
+#ifdef DBG_UTIL
+ Reference< XServiceInfo > xServiceInfo(xConnection, UNO_QUERY);
+ DBG_ASSERT(xServiceInfo.is() && xServiceInfo->supportsService(SRV_SDB_CONNECTION), "FmGridHeader::ExecuteDrop: invalid connection (no database access connection !)");
+#endif
+
+ Reference< XNameAccess > xFields;
+ switch (nCommandType)
+ {
+ case CommandType::TABLE:
+ {
+ Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
+ Reference< XColumnsSupplier > xSupplyColumns;
+ xSupplyTables->getTables()->getByName(sCommand) >>= xSupplyColumns;
+ xFields = xSupplyColumns->getColumns();
+ }
+ break;
+ case CommandType::QUERY:
+ {
+ Reference< XQueriesSupplier > xSupplyQueries(xConnection, UNO_QUERY);
+ Reference< XColumnsSupplier > xSupplyColumns;
+ xSupplyQueries->getQueries()->getByName(sCommand) >>= xSupplyColumns;
+ xFields = xSupplyColumns->getColumns();
+ }
+ break;
+ default:
+ {
+ xStatement = xConnection->prepareStatement(sCommand);
+ // not interested in any results
+
+ Reference< XPropertySet > xStatProps(xStatement,UNO_QUERY);
+ xStatProps->setPropertyValue(rtl::OUString::createFromAscii("MaxRows"), makeAny(sal_Int32(0)));
+
+ xResultSet = xStatement->executeQuery();
+ Reference< XColumnsSupplier > xSupplyCols(xResultSet, UNO_QUERY);
+ if (xSupplyCols.is())
+ xFields = xSupplyCols->getColumns();
+ }
+ }
+
+ if (xFields.is() && xFields->hasByName(sFieldName))
+ xFields->getByName(sFieldName) >>= xField;
+
+ if (!xField.is())
+ {
+ ::comphelper::disposeComponent(xStatement);
+ return DND_ACTION_NONE;
+ }
+ }
+
+ // do the drop asynchronously
+ // (85957 - UI actions within the drop are not allowed, but we want to open a popup menu)
+ m_pImpl->aDropData = aColumn;
+ m_pImpl->aDropData[daConnection] <<= xConnection;
+ m_pImpl->aDropData[daColumnObject] <<= xField;
+
+ m_pImpl->nDropAction = _rEvt.mnAction;
+ m_pImpl->aDropPosPixel = _rEvt.maPosPixel;
+ m_pImpl->xDroppedStatement = xStatement;
+ m_pImpl->xDroppedResultSet = xResultSet;
+
+ PostUserEvent(LINK(this, FmGridHeader, OnAsyncExecuteDrop));
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("FmGridHeader::ExecuteDrop: caught an exception while creatin' the column !");
+ ::comphelper::disposeComponent(xStatement);
+ return sal_False;
+ }
+
+ return DND_ACTION_LINK;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( FmGridHeader, OnAsyncExecuteDrop, void*, /*NOTINTERESTEDIN*/ )
+{
+ ::rtl::OUString sCommand, sFieldName,sURL;
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ Reference< XPropertySet > xField;
+ Reference< XConnection > xConnection;
+
+ ::rtl::OUString sDatasouce = m_pImpl->aDropData.getDataSource();
+ if ( !sDatasouce.getLength() && m_pImpl->aDropData.has(daConnectionResource) )
+ m_pImpl->aDropData[daConnectionResource] >>= sURL;
+ m_pImpl->aDropData[daCommand] >>= sCommand;
+ m_pImpl->aDropData[daCommandType] >>= nCommandType;
+ m_pImpl->aDropData[daColumnName] >>= sFieldName;
+ m_pImpl->aDropData[daConnection] >>= xConnection;
+ m_pImpl->aDropData[daColumnObject] >>= xField;
+
+ try
+ {
+ // need number formats
+ Reference< XNumberFormatsSupplier > xSupplier = OStaticDataAccessTools().getNumberFormats(xConnection, sal_True);
+ Reference< XNumberFormats > xNumberFormats;
+ if (xSupplier.is())
+ xNumberFormats = xSupplier->getNumberFormats();
+ if (!xNumberFormats.is())
+ {
+ ::comphelper::disposeComponent(m_pImpl->xDroppedResultSet);
+ ::comphelper::disposeComponent(m_pImpl->xDroppedStatement);
+ return 0L;
+ }
+
+ // Vom Feld werden nun zwei Informationen benoetigt:
+ // a.) Name des Feldes fuer Label und ControlSource
+ // b.) FormatKey, um festzustellen, welches Feld erzeugt werden soll
+ sal_Int32 nDataType = 0;
+ xField->getPropertyValue(FM_PROP_FIELDTYPE) >>= nDataType;
+ // diese Datentypen koennen im Gridcontrol nicht verarbeitet werden
+ switch (nDataType)
+ {
+ case DataType::BLOB:
+ case DataType::LONGVARBINARY:
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::OTHER:
+ ::comphelper::disposeComponent(m_pImpl->xDroppedResultSet);
+ ::comphelper::disposeComponent(m_pImpl->xDroppedStatement);
+ return 0L;
+ }
+
+ // Erstellen der Column
+ Reference< XIndexContainer > xCols(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
+ Reference< XGridColumnFactory > xFactory(xCols, UNO_QUERY);
+
+ Point aPos = OutputToScreenPixel(m_pImpl->aDropPosPixel);
+ sal_uInt16 nColId = GetItemId(m_pImpl->aDropPosPixel);
+ // EinfuegePosition, immer vor der aktuellen Spalte
+ sal_uInt16 nPos = GetModelColumnPos(nColId);
+ Reference< XPropertySet > xCol, xSecondCol;
+
+ // erzeugen der Column in abhaengigkeit vom type, default textfeld
+ SvULongs aPossibleTypes;
+ switch (nDataType)
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ aPossibleTypes.Insert(SID_FM_CHECKBOX, aPossibleTypes.Count());
+ break;
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ aPossibleTypes.Insert(SID_FM_NUMERICFIELD, aPossibleTypes.Count());
+ aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ break;
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ aPossibleTypes.Insert(SID_FM_NUMERICFIELD, aPossibleTypes.Count());
+ break;
+ case DataType::TIMESTAMP:
+ aPossibleTypes.Insert(SID_FM_TWOFIELDS_DATE_N_TIME, aPossibleTypes.Count());
+ aPossibleTypes.Insert(SID_FM_DATEFIELD, aPossibleTypes.Count());
+ aPossibleTypes.Insert(SID_FM_TIMEFIELD, aPossibleTypes.Count());
+ aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ break;
+ case DataType::DATE:
+ aPossibleTypes.Insert(SID_FM_DATEFIELD, aPossibleTypes.Count());
+ aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ break;
+ case DataType::TIME:
+ aPossibleTypes.Insert(SID_FM_TIMEFIELD, aPossibleTypes.Count());
+ aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ default:
+ aPossibleTypes.Insert(SID_FM_EDIT, aPossibleTypes.Count());
+ aPossibleTypes.Insert(SID_FM_FORMATTEDFIELD, aPossibleTypes.Count());
+ break;
+ }
+ // if it's a currency field, a a "currency field" option
+ try
+ {
+ if ( ::comphelper::hasProperty(FM_PROP_ISCURRENCY, xField)
+ && ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_ISCURRENCY)))
+ aPossibleTypes.Insert(SID_FM_CURRENCYFIELD, 0);
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmGridHeader::ExecuteDrop: Exception occured!");
+ }
+
+ sal_Int32 nPreferedType = -1;
+ sal_Bool bDateNTimeCol = sal_False;
+ if (aPossibleTypes.Count() != 0)
+ {
+ nPreferedType = aPossibleTypes[0];
+ if ((m_pImpl->nDropAction == DND_ACTION_LINK) && (aPossibleTypes.Count() > 1))
+ {
+ ImageList aImageList( SVX_RES(RID_SVXIMGLIST_FMEXPL) );
+
+ PopupMenu aInsertMenu(SVX_RES(RID_SVXMNU_COLS));
+ PopupMenu aTypeMenu;
+ PopupMenu* pMenu = aInsertMenu.GetPopupMenu(SID_FM_INSERTCOL);
+ for (sal_uInt32 i=0; i<aPossibleTypes.Count(); ++i)
+ SetMenuItem(aImageList, sal_uInt16(aPossibleTypes[(sal_uInt16)i]), pMenu, aTypeMenu, sal_True, 0);
+ nPreferedType = aTypeMenu.Execute(this, m_pImpl->aDropPosPixel);
+ }
+
+ bDateNTimeCol = nPreferedType == SID_FM_TWOFIELDS_DATE_N_TIME;
+ sal_uInt16 nColCount = bDateNTimeCol ? 2 : 1;
+ ::rtl::OUString sFieldService;
+ while (nColCount--)
+ {
+ if (bDateNTimeCol)
+ nPreferedType = nColCount ? SID_FM_DATEFIELD : SID_FM_TIMEFIELD;
+
+ sFieldService = FieldServiceFromId(nPreferedType);
+ Reference< XPropertySet > xThisRoundCol;
+ if ( sFieldService.getLength() )
+ xThisRoundCol = xFactory->createColumn(sFieldService);
+ if (nColCount)
+ xSecondCol = xThisRoundCol;
+ else
+ xCol = xThisRoundCol;
+ }
+ }
+
+ if (!xCol.is() || (bDateNTimeCol && !xSecondCol.is()))
+ {
+ ::comphelper::disposeComponent(xCol); // in case only the creation of the second column failed
+ ::comphelper::disposeComponent(m_pImpl->xDroppedResultSet);
+ ::comphelper::disposeComponent(m_pImpl->xDroppedStatement);
+ return 0L;
+ }
+
+ if (bDateNTimeCol)
+ {
+ String sTimePostfix( SVX_RES( RID_STR_POSTFIX_TIME ) );
+ xCol->setPropertyValue(FM_PROP_LABEL, makeAny( ::rtl::OUString( sFieldName + sTimePostfix ) ) );
+
+ String sDatePostfix( SVX_RES( RID_STR_POSTFIX_DATE ) );
+ xSecondCol->setPropertyValue(FM_PROP_LABEL, makeAny( ::rtl::OUString( sFieldName + sDatePostfix ) ) );
+ }
+ else
+ xCol->setPropertyValue(FM_PROP_LABEL, makeAny(sFieldName));
+
+ FormControlFactory aControlFactory( ::comphelper::getProcessServiceFactory() );
+ aControlFactory.initializeControlModel( DocumentClassification::classifyHostDocument( xCols ), xCol );
+ aControlFactory.initializeFieldDependentProperties( xField, xCol, xNumberFormats );
+
+ xCol->setPropertyValue(FM_PROP_CONTROLSOURCE, makeAny(sFieldName));
+ if ( xSecondCol.is() )
+ xSecondCol->setPropertyValue(FM_PROP_CONTROLSOURCE, makeAny(sFieldName));
+
+ if (bDateNTimeCol)
+ {
+ String sRealName,sPurePostfix;
+
+ String aPostfix[] = {
+ String( SVX_RES( RID_STR_POSTFIX_DATE ) ),
+ String( SVX_RES( RID_STR_POSTFIX_TIME ) )
+ };
+
+ for ( size_t i=0; i<2; ++i )
+ {
+ sPurePostfix = aPostfix[i];
+ sPurePostfix.EraseLeadingChars(' ');
+ sPurePostfix.EraseLeadingChars('(');
+ sPurePostfix.EraseTrailingChars(')');
+ sRealName = sFieldName;
+ sRealName += '_';
+ sRealName += sPurePostfix;
+ if (i)
+ xSecondCol->setPropertyValue(FM_PROP_NAME, makeAny(::rtl::OUString(sRealName)));
+ else
+ xCol->setPropertyValue(FM_PROP_NAME, makeAny(::rtl::OUString(sRealName)));
+ }
+ }
+ else
+ xCol->setPropertyValue(FM_PROP_NAME, makeAny(sFieldName));
+
+ // jetzt einfuegen
+ Any aElement;
+ aElement <<= xCol;
+ xCols->insertByIndex(nPos, aElement);
+
+ if (bDateNTimeCol)
+ {
+ aElement <<= xSecondCol;
+ xCols->insertByIndex(nPos == (sal_uInt16)-1 ? nPos : ++nPos, aElement);
+ }
+
+ // ist die component::Form an die Datenbankangebunden?
+ Reference< XFormComponent > xFormCp(xCols, UNO_QUERY);
+ Reference< XPropertySet > xForm(xFormCp->getParent(), UNO_QUERY);
+ if (xForm.is())
+ {
+ if (!::comphelper::getString(xForm->getPropertyValue(FM_PROP_DATASOURCE)).getLength())
+ {
+ if ( sDatasouce.getLength() )
+ xForm->setPropertyValue(FM_PROP_DATASOURCE, makeAny(sDatasouce));
+ else
+ xForm->setPropertyValue(FM_PROP_URL, makeAny(sURL));
+ }
+
+ if (!::comphelper::getString(xForm->getPropertyValue(FM_PROP_COMMAND)).getLength())
+ {
+ xForm->setPropertyValue(FM_PROP_COMMAND, makeAny(sCommand));
+ Any aCommandType;
+ switch (nCommandType)
+ {
+ case CommandType::TABLE:
+ aCommandType <<= (sal_Int32)CommandType::TABLE;
+ break;
+ case CommandType::QUERY:
+ aCommandType <<= (sal_Int32)CommandType::QUERY;
+ break;
+ default:
+ aCommandType <<= (sal_Int32)CommandType::COMMAND;
+ xForm->setPropertyValue(FM_PROP_ESCAPE_PROCESSING, bool2any((sal_Bool)(2 == nCommandType)));
+ break;
+ }
+ xForm->setPropertyValue(FM_PROP_COMMANDTYPE, aCommandType);
+ }
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("FmGridHeader::OnAsyncExecuteDrop: caught an exception while creatin' the column !");
+ ::comphelper::disposeComponent(m_pImpl->xDroppedResultSet);
+ ::comphelper::disposeComponent(m_pImpl->xDroppedStatement);
+ return 0L;
+ }
+
+ ::comphelper::disposeComponent(m_pImpl->xDroppedResultSet);
+ ::comphelper::disposeComponent(m_pImpl->xDroppedStatement);
+ return 1L;
+}
+
+//------------------------------------------------------------------------------
+void FmGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu)
+{
+ sal_Bool bDesignMode = static_cast<FmGridControl*>(GetParent())->IsDesignMode();
+
+ Reference< ::com::sun::star::container::XIndexContainer > xCols(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
+ // Aufbau des Insert Menues
+ // mark the column if nColId != HEADERBAR_ITEM_NOTFOUND
+ if(nColId > 0)
+ {
+ sal_uInt16 nPos2 = GetModelColumnPos(nColId);
+
+ Reference< ::com::sun::star::container::XIndexContainer > xColumns(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
+ Reference< ::com::sun::star::beans::XPropertySet> xColumn;
+ ::cppu::extractInterface(xColumn, xColumns->getByIndex(nPos2));
+ Reference< ::com::sun::star::view::XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY);
+ if (xSelSupplier.is())
+ xSelSupplier->select(makeAny(xColumn));
+ }
+
+ // EinfuegePosition, immer vor der aktuellen Spalte
+ sal_uInt16 nPos = GetModelColumnPos(nColId);
+ sal_Bool bMarked = nColId && static_cast<FmGridControl*>(GetParent())->isColumnMarked(nColId);
+
+ ImageList aImageList( SVX_RES(RID_SVXIMGLIST_FMEXPL) );
+ PopupMenu* pControlMenu = new PopupMenu;
+
+ PopupMenu* pMenu = rMenu.GetPopupMenu(SID_FM_INSERTCOL);
+ if (pMenu)
+ {
+ SetMenuItem(aImageList, SID_FM_EDIT, pMenu, *pControlMenu, bDesignMode);
+ SetMenuItem(aImageList, SID_FM_CHECKBOX, pMenu, *pControlMenu, bDesignMode);
+ SetMenuItem(aImageList, SID_FM_COMBOBOX, pMenu, *pControlMenu, bDesignMode);
+ SetMenuItem(aImageList, SID_FM_LISTBOX, pMenu, *pControlMenu, bDesignMode);
+ SetMenuItem(aImageList, SID_FM_DATEFIELD, pMenu, *pControlMenu, bDesignMode);
+ SetMenuItem(aImageList, SID_FM_TIMEFIELD, pMenu, *pControlMenu, bDesignMode);
+ SetMenuItem(aImageList, SID_FM_NUMERICFIELD, pMenu, *pControlMenu, bDesignMode);
+ SetMenuItem(aImageList, SID_FM_CURRENCYFIELD, pMenu, *pControlMenu, bDesignMode);
+ SetMenuItem(aImageList, SID_FM_PATTERNFIELD, pMenu, *pControlMenu, bDesignMode);
+ SetMenuItem(aImageList, SID_FM_FORMATTEDFIELD, pMenu, *pControlMenu, bDesignMode);
+ }
+
+ if (pMenu && xCols.is() && nColId)
+ {
+ Reference< ::com::sun::star::beans::XPropertySet > xSet;
+ ::cppu::extractInterface(xSet, xCols->getByIndex(nPos));
+ sal_Int16 nClassId;
+ xSet->getPropertyValue(FM_PROP_CLASSID) >>= nClassId;
+
+ Reference< ::com::sun::star::io::XPersistObject > xServiceQuestion(xSet, UNO_QUERY);
+ sal_Int32 nColType = xServiceQuestion.is() ? getColumnTypeByModelName(xServiceQuestion->getServiceName()) : 0;
+ if (nColType == TYPE_TEXTFIELD)
+ { // edit fields and formatted fields have the same service name, thus getColumnTypeByModelName returns TYPE_TEXTFIELD
+ // in both cases. And as columns don't have an ::com::sun::star::lang::XServiceInfo interface, we have to distinguish both
+ // types via the existence of special properties
+ Reference< ::com::sun::star::beans::XPropertySet > xProps(xSet, UNO_QUERY);
+ if (xProps.is())
+ {
+ Reference< ::com::sun::star::beans::XPropertySetInfo > xPropsInfo = xProps->getPropertySetInfo();
+ if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(FM_PROP_FORMATSSUPPLIER))
+ nColType = TYPE_FORMATTEDFIELD;
+ }
+ }
+
+ pControlMenu->EnableItem(SID_FM_EDIT + nChangeTypeOffset, bDesignMode && (nColType != TYPE_TEXTFIELD));
+ pControlMenu->EnableItem(SID_FM_COMBOBOX + nChangeTypeOffset, bDesignMode && (nColType != TYPE_COMBOBOX));
+ pControlMenu->EnableItem(SID_FM_LISTBOX + nChangeTypeOffset, bDesignMode && (nColType != TYPE_LISTBOX));
+ pControlMenu->EnableItem(SID_FM_CHECKBOX + nChangeTypeOffset, bDesignMode && (nColType != TYPE_CHECKBOX));
+ pControlMenu->EnableItem(SID_FM_DATEFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_DATEFIELD));
+ pControlMenu->EnableItem(SID_FM_NUMERICFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_NUMERICFIELD));
+ pControlMenu->EnableItem(SID_FM_TIMEFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_TIMEFIELD));
+ pControlMenu->EnableItem(SID_FM_CURRENCYFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_CURRENCYFIELD));
+ pControlMenu->EnableItem(SID_FM_PATTERNFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_PATTERNFIELD));
+ pControlMenu->EnableItem(SID_FM_FORMATTEDFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_FORMATTEDFIELD));
+ rMenu.SetPopupMenu(SID_FM_CHANGECOL, pControlMenu);
+ }
+
+ rMenu.EnableItem(SID_FM_INSERTCOL, bDesignMode && xCols.is());
+ rMenu.EnableItem(SID_FM_DELETECOL, bDesignMode && bMarked && xCols.is());
+ rMenu.EnableItem(SID_FM_CHANGECOL, bDesignMode && bMarked && xCols.is());
+ rMenu.EnableItem(SID_FM_SHOW_PROPERTY_BROWSER, bDesignMode && bMarked && xCols.is());
+
+ PopupMenu* pShowColsMenu = rMenu.GetPopupMenu(SID_FM_SHOWCOLS);
+ sal_uInt16 nHiddenCols = 0;
+ if (pShowColsMenu)
+ {
+ if (xCols.is())
+ {
+ // check for hidden cols
+ Reference< ::com::sun::star::beans::XPropertySet > xCurCol;
+ Any aHidden,aName;
+ for (sal_uInt16 i=0; i<xCols->getCount(); ++i)
+ {
+ ::cppu::extractInterface(xCurCol, xCols->getByIndex(i));
+ DBG_ASSERT(xCurCol.is(), "FmGridHeader::PreExecuteColumnContextMenu : the Peer has invalid columns !");
+ aHidden = xCurCol->getPropertyValue(FM_PROP_HIDDEN);
+ DBG_ASSERT(aHidden.getValueType().getTypeClass() == TypeClass_BOOLEAN,
+ "FmGridHeader::PreExecuteColumnContextMenu : the property 'hidden' should be boolean !");
+ if (::comphelper::getBOOL(aHidden))
+ {
+ // put the column name into the 'show col' menu
+ if (nHiddenCols < 16)
+ { // (only the first 16 items to keep the menu rather small)
+ aName = xCurCol->getPropertyValue(FM_PROP_LABEL);
+ pShowColsMenu->InsertItem(nHiddenCols + 1, ::comphelper::getString(aName), 0, nHiddenCols);
+ // the ID is arbitrary, but should be unique within the whole menu
+ }
+ ++nHiddenCols;
+ }
+ }
+ }
+ pShowColsMenu->EnableItem(SID_FM_SHOWCOLS_MORE, xCols.is() && (nHiddenCols > 16));
+ pShowColsMenu->EnableItem(SID_FM_SHOWALLCOLS, xCols.is() && (nHiddenCols > 0));
+ }
+
+ // allow the 'hide column' item ?
+ sal_Bool bAllowHide = bMarked; // a column is marked
+ bAllowHide = bAllowHide || (!bDesignMode && (nPos != (sal_uInt16)-1)); // OR we are in alive mode and have hit a column
+ bAllowHide = bAllowHide && xCols.is(); // AND we have a column container
+ bAllowHide = bAllowHide && (xCols->getCount()-nHiddenCols > 1); // AND there are at least two visible columns
+ rMenu.EnableItem(SID_FM_HIDECOL, bAllowHide);
+
+ sal_Bool bChecked = sal_False;
+ if (bMarked)
+ {
+
+ SfxViewFrame* pCurrentFrame = SfxViewFrame::Current();
+ SfxItemState eState = SFX_ITEM_UNKNOWN;
+ // ask the bindings of the current view frame (which should be the one we're residing in) for the state
+ if (pCurrentFrame)
+ {
+ SfxPoolItem* pItem = NULL;
+ eState = pCurrentFrame->GetBindings().QueryState(SID_FM_CTL_PROPERTIES, pItem);
+
+ if (eState >= SFX_ITEM_AVAILABLE && pItem )
+ {
+ bChecked = pItem->ISA(SfxBoolItem) && ((SfxBoolItem*)pItem)->GetValue();
+ rMenu.CheckItem(SID_FM_SHOW_PROPERTY_BROWSER,bChecked);
+ }
+ delete pItem;
+ }
+ }
+}
+
+enum InspectorAction { eOpenInspector, eCloseInspector, eUpdateInspector, eNone };
+
+//------------------------------------------------------------------------------
+void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
+{
+ Reference< ::com::sun::star::container::XIndexContainer > xCols(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
+ sal_uInt16 nPos = GetModelColumnPos(nColId);
+
+ // remove and delet the menu we inserted in PreExecuteColumnContextMenu
+ PopupMenu* pControlMenu = rMenu.GetPopupMenu(SID_FM_CHANGECOL);
+ delete pControlMenu;
+
+ ::rtl::OUString aFieldType;
+ sal_Bool bReplace = sal_False;
+ InspectorAction eInspectorAction = eNone;
+ Reference< XPropertySet > xColumnToInspect;
+ switch (nExecutionResult)
+ {
+ case SID_FM_DELETECOL:
+ {
+ Reference< XInterface > xCol;
+ ::cppu::extractInterface(xCol, xCols->getByIndex(nPos));
+ xCols->removeByIndex(nPos);
+ ::comphelper::disposeComponent(xCol);
+ } break;
+ case SID_FM_SHOW_PROPERTY_BROWSER:
+ eInspectorAction = rMenu.IsItemChecked( SID_FM_SHOW_PROPERTY_BROWSER ) ? eOpenInspector : eCloseInspector;
+ xColumnToInspect.set( xCols->getByIndex( nPos ), UNO_QUERY );
+ break;
+ case SID_FM_EDIT + nChangeTypeOffset:
+ bReplace = sal_True;
+ case SID_FM_EDIT:
+ aFieldType = FM_COL_TEXTFIELD;
+ break;
+ case SID_FM_COMBOBOX + nChangeTypeOffset:
+ bReplace = sal_True;
+ case SID_FM_COMBOBOX:
+ aFieldType = FM_COL_COMBOBOX;
+ break;
+ case SID_FM_LISTBOX + nChangeTypeOffset:
+ bReplace = sal_True;
+ case SID_FM_LISTBOX:
+ aFieldType = FM_COL_LISTBOX;
+ break;
+ case SID_FM_CHECKBOX + nChangeTypeOffset:
+ bReplace = sal_True;
+ case SID_FM_CHECKBOX:
+ aFieldType = FM_COL_CHECKBOX;
+ break;
+ case SID_FM_DATEFIELD + nChangeTypeOffset:
+ bReplace = sal_True;
+ case SID_FM_DATEFIELD:
+ aFieldType = FM_COL_DATEFIELD;
+ break;
+ case SID_FM_TIMEFIELD + nChangeTypeOffset:
+ bReplace = sal_True;
+ case SID_FM_TIMEFIELD:
+ aFieldType = FM_COL_TIMEFIELD;
+ break;
+ case SID_FM_NUMERICFIELD + nChangeTypeOffset:
+ bReplace = sal_True;
+ case SID_FM_NUMERICFIELD:
+ aFieldType = FM_COL_NUMERICFIELD;
+ break;
+ case SID_FM_CURRENCYFIELD + nChangeTypeOffset:
+ bReplace = sal_True;
+ case SID_FM_CURRENCYFIELD:
+ aFieldType = FM_COL_CURRENCYFIELD;
+ break;
+ case SID_FM_PATTERNFIELD + nChangeTypeOffset:
+ bReplace = sal_True;
+ case SID_FM_PATTERNFIELD:
+ aFieldType = FM_COL_PATTERNFIELD;
+ break;
+ case SID_FM_FORMATTEDFIELD + nChangeTypeOffset:
+ bReplace = sal_True;
+ case SID_FM_FORMATTEDFIELD:
+ aFieldType = FM_COL_FORMATTEDFIELD;
+ break;
+ case SID_FM_HIDECOL:
+ {
+ Reference< ::com::sun::star::beans::XPropertySet > xCurCol;
+ ::cppu::extractInterface(xCurCol, xCols->getByIndex(nPos));
+ xCurCol->setPropertyValue(FM_PROP_HIDDEN, makeAny((sal_Bool)sal_True));
+ }
+ break;
+ case SID_FM_SHOWCOLS_MORE:
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractFmShowColsDialog* pDlg = pFact->CreateFmShowColsDialog(NULL);
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ pDlg->SetColumns(xCols);
+ pDlg->Execute();
+ delete pDlg;
+ }
+
+ }
+ break;
+ case SID_FM_SHOWALLCOLS:
+ {
+ // just iterate through all the cols ...
+ Reference< ::com::sun::star::beans::XPropertySet > xCurCol;
+ for (sal_uInt16 i=0; i<xCols->getCount(); ++i)
+ {
+ ::cppu::extractInterface(xCurCol, xCols->getByIndex(i));
+ xCurCol->setPropertyValue(FM_PROP_HIDDEN, makeAny((sal_Bool)sal_False));
+ }
+ // TODO : there must be a more clever way to do this ....
+ // with the above the view is updated after every single model update ...
+ }
+ break;
+ default:
+ if (nExecutionResult>0 && nExecutionResult<=16)
+ { // it was a "show column/<colname>" command (there are at most 16 such items)
+ // search the nExecutionResult'th hidden col
+ Reference< ::com::sun::star::beans::XPropertySet > xCurCol;
+ for (sal_uInt16 i=0; i<xCols->getCount() && nExecutionResult; ++i)
+ {
+ ::cppu::extractInterface(xCurCol, xCols->getByIndex(i));
+ Any aHidden = xCurCol->getPropertyValue(FM_PROP_HIDDEN);
+ if (::comphelper::getBOOL(aHidden))
+ if (!--nExecutionResult)
+ {
+ xCurCol->setPropertyValue(FM_PROP_HIDDEN, makeAny((sal_Bool)sal_False));
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ if ( aFieldType.getLength() )
+ {
+ try
+ {
+ Reference< XGridColumnFactory > xFactory( xCols, UNO_QUERY_THROW );
+ Reference< XPropertySet > xNewCol( xFactory->createColumn( aFieldType ), UNO_SET_THROW );
+
+ if ( bReplace )
+ {
+ // ein paar Properties hinueberretten
+ Reference< XPropertySet > xReplaced( xCols->getByIndex( nPos ), UNO_QUERY );
+
+ OStaticDataAccessTools().TransferFormComponentProperties(
+ xReplaced, xNewCol, Application::GetSettings().GetUILocale() );
+
+ xCols->replaceByIndex( nPos, makeAny( xNewCol ) );
+ ::comphelper::disposeComponent( xReplaced );
+
+ eInspectorAction = eUpdateInspector;
+ xColumnToInspect = xNewCol;
+ }
+ else
+ {
+ FormControlFactory factory( ::comphelper::getProcessServiceFactory() );
+
+ ::rtl::OUString sLabel = factory.getDefaultUniqueName_ByComponentType(
+ Reference< XNameAccess >( xCols, UNO_QUERY_THROW ), xNewCol );
+ xNewCol->setPropertyValue( FM_PROP_LABEL, makeAny( sLabel ) );
+ xNewCol->setPropertyValue( FM_PROP_NAME, makeAny( sLabel ) );
+
+ factory.initializeControlModel( DocumentClassification::classifyHostDocument( xCols ), xNewCol );
+
+ xCols->insertByIndex( nPos, makeAny( xNewCol ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ SfxViewFrame* pCurrentFrame = SfxViewFrame::Current();
+ OSL_ENSURE( pCurrentFrame, "FmGridHeader::PostExecuteColumnContextMenu: no view frame -> no bindings -> no property browser!" );
+ if ( pCurrentFrame )
+ {
+ if ( eInspectorAction == eUpdateInspector )
+ {
+ if ( !pCurrentFrame->HasChildWindow( SID_FM_SHOW_PROPERTIES ) )
+ eInspectorAction = eNone;
+ }
+
+ if ( eInspectorAction != eNone )
+ {
+ FmInterfaceItem aIFaceItem( SID_FM_SHOW_PROPERTY_BROWSER, xColumnToInspect );
+ SfxBoolItem aShowItem( SID_FM_SHOW_PROPERTIES, eInspectorAction == eCloseInspector ? FALSE : TRUE );
+
+ pCurrentFrame->GetBindings().GetDispatcher()->Execute( SID_FM_SHOW_PROPERTY_BROWSER, SFX_CALLMODE_ASYNCHRON,
+ &aIFaceItem, &aShowItem, 0L );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmGridHeader::triggerColumnContextMenu( const ::Point& _rPreferredPos )
+{
+ // the affected col
+ sal_uInt16 nColId = GetItemId( _rPreferredPos );
+
+ // the menu
+ PopupMenu aContextMenu( SVX_RES( RID_SVXMNU_COLS ) );
+
+ // let derivees modify the menu
+ PreExecuteColumnContextMenu( nColId, aContextMenu );
+ aContextMenu.RemoveDisabledEntries( sal_True, sal_True );
+
+ // execute the menu
+ sal_uInt16 nResult = aContextMenu.Execute( this, _rPreferredPos );
+
+ // let derivees handle the result
+ PostExecuteColumnContextMenu( nColId, aContextMenu, nResult );
+}
+
+//------------------------------------------------------------------------------
+void FmGridHeader::Command(const CommandEvent& rEvt)
+{
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ if (!rEvt.IsMouseEvent())
+ return;
+
+ triggerColumnContextMenu( rEvt.GetMousePosPixel() );
+ }
+ break;
+ default:
+ EditBrowserHeader::Command(rEvt);
+ }
+}
+
+//------------------------------------------------------------------------------
+FmGridControl::FmGridControl(
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxFactory,
+ Window* pParent,
+ FmXGridPeer* _pPeer,
+ WinBits nBits)
+ :DbGridControl(_rxFactory, pParent, nBits)
+ ,m_pPeer(_pPeer)
+ ,m_nCurrentSelectedColumn(-1)
+ ,m_nMarkedColumnId(BROWSER_INVALIDID)
+ ,m_bSelecting(sal_False)
+ ,m_bInColumnMove(sal_False)
+{
+ EnableInteractiveRowHeight( );
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::Command(const CommandEvent& _rEvt)
+{
+ if ( COMMAND_CONTEXTMENU == _rEvt.GetCommand() )
+ {
+ FmGridHeader* pMyHeader = static_cast< FmGridHeader* >( GetHeaderBar() );
+ if ( pMyHeader && !_rEvt.IsMouseEvent() )
+ { // context menu requested by keyboard
+ if ( 1 == GetSelectColumnCount() || IsDesignMode() )
+ {
+ sal_uInt16 nSelId = GetColumnId(
+ sal::static_int_cast< USHORT >( FirstSelectedColumn() ) );
+ ::Rectangle aColRect( GetFieldRectPixel( 0, nSelId, sal_False ) );
+
+ Point aRelativePos( pMyHeader->ScreenToOutputPixel( OutputToScreenPixel( aColRect.TopCenter() ) ) );
+ pMyHeader->triggerColumnContextMenu( aRelativePos, FmGridHeader::AccessControl() );
+
+ // handled
+ return;
+ }
+ }
+ }
+
+ DbGridControl::Command( _rEvt );
+}
+
+// ::com::sun::star::beans::XPropertyChangeListener
+//------------------------------------------------------------------------------
+void FmGridControl::propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt)
+{
+ if (evt.PropertyName == FM_PROP_ROWCOUNT)
+ {
+ // if we're not in the main thread call AdjustRows asynchronously
+ implAdjustInSolarThread(sal_True);
+ return;
+ }
+
+ const DbGridRowRef& xRow = GetCurrentRow();
+ // waehrend Positionierung wird kein abgleich der Properties vorgenommen
+ Reference<XPropertySet> xSet(evt.Source,UNO_QUERY);
+ if (xRow.Is() && (::cppu::any2bool(xSet->getPropertyValue(FM_PROP_ISNEW))|| CompareBookmark(getDataSource()->getBookmark(), xRow->GetBookmark())))
+ {
+ if (evt.PropertyName == FM_PROP_ISMODIFIED)
+ {
+ // modified or clean ?
+ GridRowStatus eStatus = ::comphelper::getBOOL(evt.NewValue) ? GRS_MODIFIED : GRS_CLEAN;
+ if (eStatus != xRow->GetStatus())
+ {
+ xRow->SetStatus(eStatus);
+ SolarMutexGuard aGuard;
+ RowModified(GetCurrentPos());
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::SetDesignMode(sal_Bool bMode)
+{
+ sal_Bool bOldMode = IsDesignMode();
+ DbGridControl::SetDesignMode(bMode);
+ if (bOldMode != bMode)
+ {
+ if (!bMode)
+ {
+ // selection aufheben
+ markColumn(USHRT_MAX);
+ }
+ else
+ {
+ Reference< ::com::sun::star::container::XIndexContainer > xColumns(GetPeer()->getColumns());
+ Reference< ::com::sun::star::view::XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY);
+ if (xSelSupplier.is())
+ {
+ Any aSelection = xSelSupplier->getSelection();
+ Reference< ::com::sun::star::beans::XPropertySet > xColumn;
+ if (aSelection.getValueType().getTypeClass() == TypeClass_INTERFACE)
+ ::cppu::extractInterface(xColumn, aSelection);
+ Reference< XInterface > xCurrent;
+ for (sal_uInt16 i=0; i<xColumns->getCount(); ++i)
+ {
+ ::cppu::extractInterface(xCurrent, xColumns->getByIndex(i));
+ if (xCurrent == xColumn)
+ {
+ markColumn(GetColumnIdFromModelPos(i));
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::DeleteSelectedRows()
+{
+ if (!m_pSeekCursor)
+ return;
+
+ // how many rows are selected?
+ sal_Int32 nSelectedRows = GetSelectRowCount();
+
+ // the current line should be deleted but it is currently in edit mode
+ if ( IsCurrentAppending() )
+ return;
+ // is the insert row selected
+ if (GetEmptyRow().Is() && IsRowSelected(GetRowCount() - 1))
+ nSelectedRows -= 1;
+
+ // nothing to do
+ if (nSelectedRows <= 0)
+ return;
+
+ // try to confirm the delete
+ Reference< ::com::sun::star::frame::XDispatchProvider > xDispatcher = (::com::sun::star::frame::XDispatchProvider*)GetPeer();
+ if (xDispatcher.is())
+ {
+ ::com::sun::star::util::URL aUrl;
+ aUrl.Complete = FMURL_CONFIRM_DELETION;
+ // #100312# ------------
+ Reference< ::com::sun::star::util::XURLTransformer > xTransformer(
+ ::comphelper::getProcessServiceFactory()->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer")), UNO_QUERY);
+ if( xTransformer.is() )
+ xTransformer->parseStrict( aUrl );
+
+ Reference< ::com::sun::star::frame::XDispatch > xDispatch = xDispatcher->queryDispatch(aUrl, rtl::OUString(), 0);
+ Reference< ::com::sun::star::form::XConfirmDeleteListener > xConfirm(xDispatch, UNO_QUERY);
+ if (xConfirm.is())
+ {
+ ::com::sun::star::sdb::RowChangeEvent aEvent;
+ aEvent.Source = (Reference< XInterface > )(*getDataSource());
+ aEvent.Rows = nSelectedRows;
+ aEvent.Action = ::com::sun::star::sdb::RowChangeAction::DELETE;
+ if (!xConfirm->confirmDelete(aEvent))
+ return;
+ }
+ }
+
+ const MultiSelection* pRowSelection = GetSelection();
+ if ( pRowSelection && pRowSelection->IsAllSelected() )
+ {
+ BeginCursorAction();
+ CursorWrapper* pCursor = getDataSource();
+ Reference< XResultSetUpdate > xUpdateCursor((Reference< XInterface >)*pCursor, UNO_QUERY);
+ try
+ {
+ pCursor->beforeFirst();
+ while( pCursor->next() )
+ xUpdateCursor->deleteRow();
+
+ SetUpdateMode(sal_False);
+ SetNoSelection();
+
+ xUpdateCursor->moveToInsertRow();
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(0,"Exception caught while deleting rows!");
+ }
+ // An den DatenCursor anpassen
+ AdjustDataSource(sal_True);
+ EndCursorAction();
+ SetUpdateMode(sal_True);
+ }
+ else
+ {
+ Reference< ::com::sun::star::sdbcx::XDeleteRows > xDeleteThem((Reference< XInterface >)*getDataSource(), UNO_QUERY);
+
+ // colect the bookmarks of the selected rows
+ Sequence < Any> aBookmarks = getSelectionBookmarks();
+
+ // determine the next row to position after deletion
+ Any aBookmark;
+ sal_Bool bNewPos = sal_False;
+ // if the current row isn't selected we take the row as row after deletion
+ OSL_ENSURE( GetCurrentRow().Is(), "FmGridControl::DeleteSelectedRows: no current row here?" );
+ // crash reports suggest it can happen we don't have a current row - how?
+ // #154303# / 2008-04-23 / frank.schoenheit@sun.com
+ if ( !IsRowSelected( GetCurrentPos() ) && !IsCurrentAppending() && GetCurrentRow().Is() )
+ {
+ aBookmark = GetCurrentRow()->GetBookmark();
+ bNewPos = sal_True;
+ }
+ else
+ {
+ // we look for the first row after the selected block for selection
+ long nIdx = LastSelectedRow() + 1;
+ if (nIdx < GetRowCount() - 1)
+ {
+ // there is a next row to position on
+ if (SeekCursor(nIdx))
+ {
+ GetSeekRow()->SetState(m_pSeekCursor, sal_True);
+
+ bNewPos = sal_True;
+ // if it's not the row for inserting we keep the bookmark
+ if (!IsInsertionRow(nIdx))
+ aBookmark = m_pSeekCursor->getBookmark();
+ }
+ }
+ else
+ {
+ // we look for the first row before the selected block for selection after deletion
+ nIdx = FirstSelectedRow() - 1;
+ if (nIdx >= 0 && SeekCursor(nIdx))
+ {
+ GetSeekRow()->SetState(m_pSeekCursor, sal_True);
+
+ bNewPos = sal_True;
+ aBookmark = m_pSeekCursor->getBookmark();
+ }
+ }
+ }
+
+ // Sind alle Zeilen Selectiert
+ // Zweite bedingung falls keine einguegeZeile existiert
+ sal_Bool bAllSelected = GetTotalCount() == nSelectedRows || GetRowCount() == nSelectedRows;
+
+ BeginCursorAction();
+
+ // now delete the row
+ Sequence <sal_Int32> aDeletedRows;
+ SetUpdateMode( FALSE );
+ try
+ {
+ aDeletedRows = xDeleteThem->deleteRows(aBookmarks);
+ }
+ catch(SQLException&)
+ {
+ }
+ SetUpdateMode( TRUE );
+
+ // how many rows are deleted?
+ sal_Int32 nDeletedRows = 0;
+ const sal_Int32* pSuccess = aDeletedRows.getConstArray();
+ for (sal_Int32 i = 0; i < aDeletedRows.getLength(); i++)
+ {
+ if (pSuccess[i])
+ ++nDeletedRows;
+ }
+
+ // sind Zeilen geloescht worden?
+ if (nDeletedRows)
+ {
+ SetUpdateMode(sal_False);
+ SetNoSelection();
+ try
+ {
+ // did we delete all the rows than try to move to the next possible row
+ if (nDeletedRows == aDeletedRows.getLength())
+ {
+ // there exists a new position to move on
+ if (bNewPos)
+ {
+ if (aBookmark.hasValue())
+ getDataSource()->moveToBookmark(aBookmark);
+ // no valid bookmark so move to the insert row
+ else
+ {
+ Reference< XResultSetUpdate > xUpdateCursor((Reference< XInterface >)*m_pDataCursor, UNO_QUERY);
+ xUpdateCursor->moveToInsertRow();
+ }
+ }
+ else
+ {
+ Reference< ::com::sun::star::beans::XPropertySet > xSet((Reference< XInterface >)*m_pDataCursor, UNO_QUERY);
+
+ sal_Int32 nRecordCount(0);
+ xSet->getPropertyValue(FM_PROP_ROWCOUNT) >>= nRecordCount;
+ if ( m_pDataCursor->rowDeleted() )
+ --nRecordCount;
+
+ // there are no rows left and we have an insert row
+ if (!nRecordCount && GetEmptyRow().Is())
+ {
+ Reference< XResultSetUpdate > xUpdateCursor((Reference< XInterface >)*m_pDataCursor, UNO_QUERY);
+ xUpdateCursor->moveToInsertRow();
+ }
+ else if (nRecordCount)
+ // move to the first row
+ getDataSource()->first();
+ }
+ }
+ // not all the rows where deleted, so move to the first row which remained in the resultset
+ else
+ {
+ for (sal_Int32 i = 0; i < aDeletedRows.getLength(); i++)
+ {
+ if (!pSuccess[i])
+ {
+ getDataSource()->moveToBookmark(aBookmarks.getConstArray()[i]);
+ break;
+ }
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ try
+ {
+ // positioning went wrong so try to move to the first row
+ getDataSource()->first();
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+
+ // An den DatenCursor anpassen
+ AdjustDataSource(sal_True);
+
+ // es konnten nicht alle Zeilen geloescht werden
+ // da nie nicht geloeschten wieder selektieren
+ if (nDeletedRows < nSelectedRows)
+ {
+ // waren alle selektiert
+ if (bAllSelected)
+ {
+ SelectAll();
+ if (IsInsertionRow(GetRowCount() - 1)) // einfuegeZeile nicht
+ SelectRow(GetRowCount() - 1, sal_False);
+ }
+ else
+ {
+ // select the remaining rows
+ for (sal_Int32 i = 0; i < aDeletedRows.getLength(); i++)
+ {
+ try
+ {
+ if (!pSuccess[i])
+ {
+ m_pSeekCursor->moveToBookmark(m_pDataCursor->getBookmark());
+ SetSeekPos(m_pSeekCursor->getRow() - 1);
+ SelectRow(GetSeekPos());
+ }
+ }
+ catch(const Exception&)
+ {
+ // keep the seekpos in all cases
+ SetSeekPos(m_pSeekCursor->getRow() - 1);
+ }
+ }
+ }
+ }
+
+ EndCursorAction();
+ SetUpdateMode(sal_True);
+ }
+ else // Zeile konnte nicht geloescht werden
+ {
+ EndCursorAction();
+ try
+ {
+ // currentrow is the insert row?
+ if (!IsCurrentAppending())
+ getDataSource()->refreshRow();
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ }
+
+ // if there is no selection anymore we can start editing
+ if (!GetSelectRowCount())
+ ActivateCell();
+}
+
+
+// XCurrentRecordListener
+//------------------------------------------------------------------------------
+void FmGridControl::positioned(const ::com::sun::star::lang::EventObject& /*rEvent*/)
+{
+ TRACE_RANGE("FmGridControl::positioned");
+ // position on the data source (force it to be done in the main thread)
+ implAdjustInSolarThread(sal_False);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmGridControl::commit()
+{
+ // Commit nur ausfuehren, wenn nicht bereits ein Update vom ::com::sun::star::form::component::GridControl ausgefuehrt
+ // wird
+ if (!IsUpdating())
+ {
+ if (Controller().Is() && Controller()->IsModified())
+ {
+ if (!SaveModified())
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::inserted(const ::com::sun::star::lang::EventObject& /*rEvent*/)
+{
+ const DbGridRowRef& xRow = GetCurrentRow();
+ if (!xRow.Is())
+ return;
+
+ // Zeile ist eingefuegt worden, dann den status und mode zuruecksetzen
+ xRow->SetState(m_pDataCursor, sal_False);
+ xRow->SetNew(sal_False);
+
+}
+
+// XCancelUpdateRecordListener
+//------------------------------------------------------------------------------
+void FmGridControl::restored(const ::com::sun::star::lang::EventObject& rEvent)
+{
+ if (!GetCurrentRow().Is())
+ return;
+
+ sal_Bool bAppending = GetCurrentRow()->IsNew();
+ sal_Bool bDirty = GetCurrentRow()->IsModified();
+ if (bAppending && (EditBrowseBox::IsModified() || bDirty))
+ {
+ if (Controller().Is())
+ Controller()->ClearModified();
+
+ // jetzt die Zeile herausnehmen
+ RowRemoved(GetRowCount() - 1, 1, sal_True);
+ GetNavigationBar().InvalidateAll();
+ }
+
+ positioned(rEvent);
+}
+
+//------------------------------------------------------------------------------
+BrowserHeader* FmGridControl::imp_CreateHeaderBar(BrowseBox* pParent)
+{
+ DBG_ASSERT( pParent == this, "FmGridControl::imp_CreateHeaderBar: parent?" );
+ return new FmGridHeader( pParent );
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::markColumn(sal_uInt16 nId)
+{
+ if (GetHeaderBar() && m_nMarkedColumnId != nId)
+ {
+ // deselektieren
+ if (m_nMarkedColumnId != BROWSER_INVALIDID)
+ {
+ HeaderBarItemBits aBits = GetHeaderBar()->GetItemBits(m_nMarkedColumnId) & ~HIB_FLAT;
+ GetHeaderBar()->SetItemBits(m_nMarkedColumnId, aBits);
+ }
+
+
+ if (nId != BROWSER_INVALIDID)
+ {
+ HeaderBarItemBits aBits = GetHeaderBar()->GetItemBits(nId) | HIB_FLAT;
+ GetHeaderBar()->SetItemBits(nId, aBits);
+ }
+ m_nMarkedColumnId = nId;
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmGridControl::isColumnMarked(sal_uInt16 nId) const
+{
+ return m_nMarkedColumnId == nId;
+}
+
+//------------------------------------------------------------------------------
+long FmGridControl::QueryMinimumRowHeight()
+{
+ long nMinimalLogicHeight = 20; // 0.2 cm
+ long nMinimalPixelHeight = LogicToPixel( Point( 0, nMinimalLogicHeight ), MAP_10TH_MM ).Y();
+ return CalcZoom( nMinimalPixelHeight );
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::RowHeightChanged()
+{
+ DbGridControl::RowHeightChanged();
+
+ Reference< XPropertySet > xModel( GetPeer()->getColumns(), UNO_QUERY );
+ DBG_ASSERT( xModel.is(), "FmGridControl::RowHeightChanged: no model!" );
+ if ( xModel.is() )
+ {
+ try
+ {
+ sal_Int32 nUnzoomedPixelHeight = CalcReverseZoom( GetDataRowHeight() );
+ Any aProperty = makeAny( (sal_Int32)PixelToLogic( Point( 0, nUnzoomedPixelHeight ), MAP_10TH_MM ).Y() );
+ xModel->setPropertyValue( FM_PROP_ROWHEIGHT, aProperty );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmGridControl::RowHeightChanged: caught an exception!" );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::ColumnResized(sal_uInt16 nId)
+{
+ DbGridControl::ColumnResized(nId);
+
+ // Wert ans model uebergeben
+ DbGridColumn* pCol = DbGridControl::GetColumns().GetObject(GetModelColumnPos(nId));
+ Reference< ::com::sun::star::beans::XPropertySet > xColModel(pCol->getModel());
+ if (xColModel.is())
+ {
+ Any aWidth;
+ sal_Int32 nColumnWidth = GetColumnWidth(nId);
+ nColumnWidth = CalcReverseZoom(nColumnWidth);
+ // Umrechnen in 10THMM
+ aWidth <<= (sal_Int32)PixelToLogic(Point(nColumnWidth,0),MAP_10TH_MM).X();
+ xColModel->setPropertyValue(FM_PROP_WIDTH, aWidth);
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::CellModified()
+{
+ DbGridControl::CellModified();
+ GetPeer()->CellModified();
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::BeginCursorAction()
+{
+ DbGridControl::BeginCursorAction();
+ m_pPeer->stopCursorListening();
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::EndCursorAction()
+{
+ m_pPeer->startCursorListening();
+ DbGridControl::EndCursorAction();
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::ColumnMoved(sal_uInt16 nId)
+{
+ m_bInColumnMove = sal_True;
+
+ DbGridControl::ColumnMoved(nId);
+ Reference< ::com::sun::star::container::XIndexContainer > xColumns(GetPeer()->getColumns());
+
+ if (xColumns.is())
+ {
+ // suchen der Spalte und verschieben im Model
+ // ColumnPos holen
+ DbGridColumn* pCol = DbGridControl::GetColumns().GetObject(GetModelColumnPos(nId));
+ Reference< ::com::sun::star::beans::XPropertySet > xCol;
+
+ // Einfuegen muß sich an den Column Positionen orientieren
+ sal_Int32 i;
+ Reference< XInterface > xCurrent;
+ for (i = 0; !xCol.is() && i < xColumns->getCount(); i++)
+ {
+ ::cppu::extractInterface(xCurrent, xColumns->getByIndex(i));
+ if (xCurrent == pCol->getModel())
+ {
+ xCol = pCol->getModel();
+ break;
+ }
+ }
+
+ DBG_ASSERT(i < xColumns->getCount(), "Falscher ::com::sun::star::sdbcx::Index");
+ xColumns->removeByIndex(i);
+ Any aElement;
+ aElement <<= xCol;
+ xColumns->insertByIndex(GetModelColumnPos(nId), aElement);
+ pCol->setModel(xCol);
+ // if the column which is shown here is selected ...
+ if ( isColumnSelected(nId,pCol) )
+ markColumn(nId); // ... -> mark it
+ }
+
+ m_bInColumnMove = sal_False;
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::InitColumnsByModels(const Reference< ::com::sun::star::container::XIndexContainer >& xColumns)
+{
+ // Spalten wieder neu setzen
+ // wenn es nur eine HandleColumn gibt, dann nicht
+ if (GetModelColCount())
+ {
+ RemoveColumns();
+ InsertHandleColumn();
+ }
+
+ if (!xColumns.is())
+ return;
+
+ SetUpdateMode(sal_False);
+
+ // Einfuegen mu� sich an den Column Positionen orientieren
+ sal_Int32 i;
+ String aName;
+ Any aWidth;
+ for (i = 0; i < xColumns->getCount(); ++i)
+ {
+ Reference< ::com::sun::star::beans::XPropertySet > xCol;
+ ::cppu::extractInterface(xCol, xColumns->getByIndex(i));
+
+ aName = (const sal_Unicode*)::comphelper::getString(xCol->getPropertyValue(FM_PROP_LABEL));
+
+ aWidth = xCol->getPropertyValue(FM_PROP_WIDTH);
+ sal_Int32 nWidth = 0;
+ if (aWidth >>= nWidth)
+ nWidth = LogicToPixel(Point(nWidth,0),MAP_10TH_MM).X();
+
+ AppendColumn(aName, (sal_uInt16)nWidth);
+ DbGridColumn* pCol = DbGridControl::GetColumns().GetObject(i);
+ pCol->setModel(xCol);
+ }
+
+ // und jetzt noch die hidden columns rausnehmen
+ // (wir haben das nicht gleich in der oberen Schleife gemacht, da wir dann Probleme mit den
+ // IDs der Spalten bekommen haetten : AppendColumn vergibt die automatisch, die Spalte _nach_
+ // einer versteckten braucht aber eine um eine erhoehte ID ....
+ Any aHidden;
+ for (i = 0; i < xColumns->getCount(); ++i)
+ {
+ Reference< ::com::sun::star::beans::XPropertySet > xCol;
+ ::cppu::extractInterface(xCol, xColumns->getByIndex(i));
+ aHidden = xCol->getPropertyValue(FM_PROP_HIDDEN);
+ if (::comphelper::getBOOL(aHidden))
+ HideColumn(GetColumnIdFromModelPos((sal_uInt16)i));
+ }
+
+ SetUpdateMode(sal_True);
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::InitColumnByField(
+ DbGridColumn* _pColumn, const Reference< XPropertySet >& _rxColumnModel,
+ const Reference< XNameAccess >& _rxFieldsByNames, const Reference< XIndexAccess >& _rxFieldsByIndex )
+{
+ DBG_ASSERT( _rxFieldsByNames == _rxFieldsByIndex, "FmGridControl::InitColumnByField: invalid container interfaces!" );
+
+ // lookup the column which belongs to the control source
+ ::rtl::OUString sFieldName;
+ _rxColumnModel->getPropertyValue( FM_PROP_CONTROLSOURCE ) >>= sFieldName;
+ Reference< XPropertySet > xField;
+ _rxColumnModel->getPropertyValue( FM_PROP_BOUNDFIELD ) >>= xField;
+
+
+ if ( !xField.is() && /*sFieldName.getLength() && */_rxFieldsByNames->hasByName( sFieldName ) ) // #i93452# do not check for name length
+ _rxFieldsByNames->getByName( sFieldName ) >>= xField;
+
+ // determine the position of this column
+ sal_Int32 nFieldPos = -1;
+ if ( xField.is() )
+ {
+ Reference< XPropertySet > xCheck;
+ sal_Int32 nFieldCount = _rxFieldsByIndex->getCount();
+ for ( sal_Int32 i = 0; i < nFieldCount; ++i)
+ {
+ _rxFieldsByIndex->getByIndex( i ) >>= xCheck;
+ if ( xField.get() == xCheck.get() )
+ {
+ nFieldPos = i;
+ break;
+ }
+ }
+ }
+
+ if ( xField.is() && ( nFieldPos >= 0 ) )
+ {
+ // some data types are not allowed
+ sal_Int32 nDataType = DataType::OTHER;
+ xField->getPropertyValue( FM_PROP_FIELDTYPE ) >>= nDataType;
+
+ sal_Bool bIllegalType = sal_False;
+ switch ( nDataType )
+ {
+ case DataType::BLOB:
+ case DataType::LONGVARBINARY:
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::OTHER:
+ bIllegalType = sal_True;
+ break;
+ }
+
+ if ( bIllegalType )
+ {
+ _pColumn->SetObject( (sal_Int16)nFieldPos );
+ return;
+ }
+/*
+ // handle readonly columns
+ sal_Bool bReadOnly = sal_True;
+ xField->getPropertyValue( FM_PROP_ISREADONLY ) >>= bReadOnly;
+ _pColumn->SetReadOnly( bReadOnly );
+*/
+ }
+
+ // the control type is determined by the ColumnServiceName
+ static ::rtl::OUString s_sPropColumnServiceName( RTL_CONSTASCII_USTRINGPARAM( "ColumnServiceName" ) );
+ if ( !::comphelper::hasProperty( s_sPropColumnServiceName, _rxColumnModel ) )
+ return;
+
+ _pColumn->setModel( _rxColumnModel );
+
+ ::rtl::OUString sColumnServiceName;
+ _rxColumnModel->getPropertyValue( s_sPropColumnServiceName ) >>= sColumnServiceName;
+
+ sal_Int32 nTypeId = getColumnTypeByModelName( sColumnServiceName );
+ _pColumn->CreateControl( nFieldPos, xField, nTypeId );
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::InitColumnsByFields(const Reference< ::com::sun::star::container::XIndexAccess >& _rxFields)
+{
+ if ( !_rxFields.is() )
+ return;
+
+ // Spalten initialisieren
+ Reference< XIndexContainer > xColumns( GetPeer()->getColumns() );
+ Reference< XNameAccess > xFieldsAsNames( _rxFields, UNO_QUERY );
+
+ // Einfuegen muss sich an den Column Positionen orientieren
+ for (sal_Int32 i = 0; i < xColumns->getCount(); i++)
+ {
+ DbGridColumn* pCol = GetColumns().GetObject(i);
+ OSL_ENSURE(pCol,"No grid column!");
+ if ( pCol )
+ {
+ Reference< XPropertySet > xColumnModel;
+ ::cppu::extractInterface( xColumnModel, xColumns->getByIndex( i ) );
+
+ InitColumnByField( pCol, xColumnModel, xFieldsAsNames, _rxFields );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::HideColumn(sal_uInt16 nId)
+{
+ DbGridControl::HideColumn(nId);
+
+ sal_uInt16 nPos = GetModelColumnPos(nId);
+ if (nPos == (sal_uInt16)-1)
+ return;
+
+ DbGridColumn* pColumn = GetColumns().GetObject(nPos);
+ if (pColumn->IsHidden())
+ GetPeer()->columnHidden(pColumn);
+
+ if (nId == m_nMarkedColumnId)
+ m_nMarkedColumnId = (sal_uInt16)-1;
+}
+// -----------------------------------------------------------------------------
+sal_Bool FmGridControl::isColumnSelected(sal_uInt16 /*nId*/,DbGridColumn* _pColumn)
+{
+ OSL_ENSURE(_pColumn,"Column can not be null!");
+ sal_Bool bSelected = sal_False;
+ // if the column which is shown here is selected ...
+ Reference< ::com::sun::star::view::XSelectionSupplier > xSelSupplier(GetPeer()->getColumns(), UNO_QUERY);
+ if ( xSelSupplier.is() )
+ {
+ Reference< ::com::sun::star::beans::XPropertySet > xColumn;
+ xSelSupplier->getSelection() >>= xColumn;
+ bSelected = (xColumn.get() == _pColumn->getModel().get());
+ }
+ return bSelected;
+}
+
+//------------------------------------------------------------------------------
+void FmGridControl::ShowColumn(sal_uInt16 nId)
+{
+ DbGridControl::ShowColumn(nId);
+
+ sal_uInt16 nPos = GetModelColumnPos(nId);
+ if (nPos == (sal_uInt16)-1)
+ return;
+
+ DbGridColumn* pColumn = GetColumns().GetObject(nPos);
+ if (!pColumn->IsHidden())
+ GetPeer()->columnVisible(pColumn);
+
+ // if the column which is shown here is selected ...
+ if ( isColumnSelected(nId,pColumn) )
+ markColumn(nId); // ... -> mark it
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmGridControl::selectBookmarks(const Sequence< Any >& _rBookmarks)
+{
+ SolarMutexGuard aGuard;
+ // need to lock the SolarMutex so that no paint call disturbs us ...
+
+ if ( !m_pSeekCursor )
+ {
+ DBG_ERROR( "FmGridControl::selectBookmarks: no seek cursor!" );
+ return sal_False;
+ }
+
+ const Any* pBookmark = _rBookmarks.getConstArray();
+ const Any* pBookmarkEnd = pBookmark + _rBookmarks.getLength();
+
+ SetNoSelection();
+
+ sal_Bool bAllSuccessfull = sal_True;
+ try
+ {
+ for (; pBookmark != pBookmarkEnd; ++pBookmark)
+ {
+ // move the seek cursor to the row given
+ if (m_pSeekCursor->moveToBookmark(*pBookmark))
+ SelectRow( m_pSeekCursor->getRow() - 1);
+ else
+ bAllSuccessfull = sal_False;
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmGridControl::selectBookmarks: could not move to one of the bookmarks!");
+ return sal_False;
+ }
+
+ return bAllSuccessfull;
+}
+
+//------------------------------------------------------------------------------
+Sequence< Any> FmGridControl::getSelectionBookmarks()
+{
+ // lock our update so no paint-triggered seeks interfere ...
+ SetUpdateMode(sal_False);
+
+ sal_Int32 nSelectedRows = GetSelectRowCount(), i = 0;
+ Sequence< Any> aBookmarks(nSelectedRows);
+ if ( nSelectedRows )
+ {
+ Any* pBookmarks = (Any*)aBookmarks.getArray();
+
+ // (I'm not sure if the problem isn't deeper : The szenario : a large table displayed by a grid with a
+ // thread-safe cursor (dBase). On loading the sdb-cursor started a counting thread. While this counting progress
+ // was running, I tried do delete 3 records from within the grid. Deletion caused a SeekCursor, which did a
+ // m_pSeekCursor->moveRelative and a m_pSeekCursor->getPosition.
+ // Unfortunally the first call caused a propertyChanged(RECORDCOUNT) which resulted in a repaint of the
+ // navigation bar and the grid. The latter itself will result in SeekRow calls. So after (successfully) returning
+ // from the moveRelative the getPosition returns an invalid value. And so the SeekCursor fails.
+ // In the consequence ALL parts of code where two calls to the seek cursor are done, while the second call _relys_ on
+ // the first one, should be secured against recursion, with a broad-minded interpretion of "recursion" : if any of these
+ // code parts is executed, no other should be accessible. But this sounds very difficult to achieve ....
+ // )
+
+ // The next problem caused by the same behaviuor (SeekCursor causes a propertyChanged) : when adjusting rows we implicitly
+ // change our selection. So a "FirstSelected(); SeekCursor(); NextSelected();" may produce unpredictable results.
+ // That's why we _first_ collect the indicies of the selected rows and _then_ their bookmarks.
+ long nIdx = FirstSelectedRow();
+ while (nIdx >= 0)
+ {
+ // (we misuse the bookmarks array for this ...)
+ pBookmarks[i++] <<= (sal_Int32)nIdx;
+ nIdx = NextSelectedRow();
+ }
+ DBG_ASSERT(i == nSelectedRows, "FmGridControl::DeleteSelectedRows : could not collect the row indicies !");
+
+ for (i=0; i<nSelectedRows; ++i)
+ {
+ nIdx = ::comphelper::getINT32(pBookmarks[i]);
+ if (IsInsertionRow(nIdx))
+ {
+ // leerzeile nicht loeschen
+ aBookmarks.realloc(--nSelectedRows);
+ SelectRow(nIdx,sal_False); // selection aufheben fuer leerzeile
+ break;
+ }
+
+ // Zunaechst den DatenCursor auf den selektierten Satz pos.
+ if (SeekCursor(nIdx))
+ {
+ GetSeekRow()->SetState(m_pSeekCursor, sal_True);
+
+ pBookmarks[i] = m_pSeekCursor->getBookmark();
+ }
+ #ifdef DBG_UTIL
+ else
+ DBG_ERROR("FmGridControl::DeleteSelectedRows : a bookmark could not be determined !");
+ #endif
+ }
+ }
+ SetUpdateMode(sal_True);
+
+ // if one of the SeekCursor-calls failed ....
+ aBookmarks.realloc(i);
+
+ // (the alternative : while collecting the bookmarks lock our propertyChanged, this should resolve both our problems.
+ // but this would be incompatible as we need a locking flag, then ...)
+
+ return aBookmarks;
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ ::rtl::OUString getColumnPropertyFromPeer(FmXGridPeer* _pPeer,sal_Int32 _nPosition,const ::rtl::OUString& _sPropName)
+ {
+ ::rtl::OUString sRetText;
+ if ( _pPeer && _nPosition != -1)
+ {
+ Reference<XIndexContainer> xIndex = _pPeer->getColumns();
+ if ( xIndex.is() && xIndex->getCount() > _nPosition )
+ {
+ Reference<XPropertySet> xProp;
+ xIndex->getByIndex( _nPosition ) >>= xProp;
+ if ( xProp.is() )
+ xProp->getPropertyValue( _sPropName ) >>= sRetText;
+ }
+ }
+ return sRetText;
+ }
+}
+// Object data and state ------------------------------------------------------
+::rtl::OUString FmGridControl::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType _eObjType,sal_Int32 _nPosition ) const
+{
+ ::rtl::OUString sRetText;
+ switch( _eObjType )
+ {
+ case ::svt::BBTYPE_BROWSEBOX:
+ if ( GetPeer() )
+ {
+ Reference<XPropertySet> xProp(GetPeer()->getColumns(),UNO_QUERY);
+ if ( xProp.is() )
+ xProp->getPropertyValue(FM_PROP_NAME) >>= sRetText;
+ }
+ break;
+ case ::svt::BBTYPE_COLUMNHEADERCELL:
+ sRetText = getColumnPropertyFromPeer(
+ GetPeer(),
+ GetModelColumnPos(
+ sal::static_int_cast< sal_uInt16 >(_nPosition)),
+ FM_PROP_LABEL);
+ break;
+ default:
+ sRetText = DbGridControl::GetAccessibleObjectName(_eObjType,_nPosition);
+ }
+ return sRetText;
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString FmGridControl::GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType _eObjType,sal_Int32 _nPosition ) const
+{
+ ::rtl::OUString sRetText;
+ switch( _eObjType )
+ {
+ case ::svt::BBTYPE_BROWSEBOX:
+ if ( GetPeer() )
+ {
+ Reference<XPropertySet> xProp(GetPeer()->getColumns(),UNO_QUERY);
+ if ( xProp.is() )
+ {
+ xProp->getPropertyValue(FM_PROP_HELPTEXT) >>= sRetText;
+ if ( !sRetText.getLength() )
+ xProp->getPropertyValue(FM_PROP_DESCRIPTION) >>= sRetText;
+ }
+ }
+ break;
+ case ::svt::BBTYPE_COLUMNHEADERCELL:
+ sRetText = getColumnPropertyFromPeer(
+ GetPeer(),
+ GetModelColumnPos(
+ sal::static_int_cast< sal_uInt16 >(_nPosition)),
+ FM_PROP_HELPTEXT);
+ if ( !sRetText.getLength() )
+ sRetText = getColumnPropertyFromPeer(
+ GetPeer(),
+ GetModelColumnPos(
+ sal::static_int_cast< sal_uInt16 >(_nPosition)),
+ FM_PROP_DESCRIPTION);
+
+ break;
+ default:
+ sRetText = DbGridControl::GetAccessibleObjectDescription(_eObjType,_nPosition);
+ }
+ return sRetText;
+}
+// -----------------------------------------------------------------------------
+void FmGridControl::Select()
+{
+ DbGridControl::Select();
+ // ... betrifft das unsere Spalten ?
+ const MultiSelection* pColumnSelection = GetColumnSelection();
+
+ sal_uInt16 nSelectedColumn =
+ pColumnSelection && pColumnSelection->GetSelectCount()
+ ? sal::static_int_cast< sal_uInt16 >(
+ ((MultiSelection*)pColumnSelection)->FirstSelected())
+ : SAL_MAX_UINT16;
+ // die HandleColumn wird nicht selektiert
+ switch (nSelectedColumn)
+ {
+ case SAL_MAX_UINT16: break; // no selection
+ case 0 : nSelectedColumn = SAL_MAX_UINT16; break;
+ // handle col can't be seledted
+ default :
+ // get the model col pos instead of the view col pos
+ nSelectedColumn = GetModelColumnPos(GetColumnIdFromViewPos(nSelectedColumn - 1));
+ break;
+ }
+
+ if (nSelectedColumn != m_nCurrentSelectedColumn)
+ {
+ // VOR dem Aufruf des select am SelectionSupplier !
+ m_nCurrentSelectedColumn = nSelectedColumn;
+
+ if (!m_bSelecting)
+ {
+ m_bSelecting = sal_True;
+
+ try
+ {
+ Reference< XIndexAccess > xColumns(GetPeer()->getColumns(), UNO_QUERY);
+ Reference< XSelectionSupplier > xSelSupplier(xColumns, UNO_QUERY);
+ if (xSelSupplier.is())
+ {
+ if (nSelectedColumn != SAL_MAX_UINT16)
+ {
+ Reference< XPropertySet > xColumn;
+ ::cppu::extractInterface(xColumn,xColumns->getByIndex(nSelectedColumn));
+ xSelSupplier->select(makeAny(xColumn));
+ }
+ else
+ {
+ xSelSupplier->select(Any());
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+
+
+ m_bSelecting = sal_False;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Int32 FmGridControl::GetSelectedColumn() const
+{
+ return m_nCurrentSelectedColumn;
+}
+// -----------------------------------------------------------------------------
+void FmGridControl::KeyInput( const KeyEvent& rKEvt )
+{
+ sal_Bool bDone = sal_False;
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ if ( IsDesignMode()
+ && !rKeyCode.IsShift()
+ && !rKeyCode.IsMod1()
+ && !rKeyCode.IsMod2()
+ && GetParent() )
+ {
+ switch ( rKeyCode.GetCode() )
+ {
+ case KEY_ESCAPE:
+ GetParent()->GrabFocus();
+ bDone = sal_True;
+ break;
+ case KEY_DELETE:
+ if ( GetSelectColumnCount() && GetPeer() && m_nCurrentSelectedColumn >= 0 )
+ {
+ Reference< ::com::sun::star::container::XIndexContainer > xCols(GetPeer()->getColumns());
+ if ( xCols.is() )
+ {
+ try
+ {
+ if ( m_nCurrentSelectedColumn < xCols->getCount() )
+ {
+ Reference< XInterface > xCol;
+ xCols->getByIndex(m_nCurrentSelectedColumn) >>= xCol;
+ xCols->removeByIndex(m_nCurrentSelectedColumn);
+ ::comphelper::disposeComponent(xCol);
+ }
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(0,"exception occured while deleting a column");
+ }
+ }
+ }
+ bDone = sal_True;
+ break;
+ }
+ }
+ if ( !bDone )
+ DbGridControl::KeyInput( rKEvt );
+}
+// -----------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx
new file mode 100644
index 000000000000..6941fd670d64
--- /dev/null
+++ b/svx/source/fmcomp/fmgridif.cxx
@@ -0,0 +1,2968 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmgridif.hxx"
+#include "fmprop.hrc"
+#include "fmservs.hxx"
+#include "svx/fmtools.hxx"
+#include "fmurl.hxx"
+#include "formcontrolfactory.hxx"
+#include "gridcell.hxx"
+#include "sdbdatacolumn.hxx"
+#include "svx/fmgridcl.hxx"
+#include "svx/svxids.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/container.hxx>
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <sal/macros.h>
+
+using namespace ::svxform;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star;
+
+using ::com::sun::star::sdbcx::XColumnsSupplier;
+using ::com::sun::star::frame::XDispatchProviderInterceptor;
+using ::com::sun::star::frame::XDispatchProvider;
+using ::com::sun::star::accessibility::XAccessible;
+using ::com::sun::star::accessibility::XAccessibleContext;
+using ::com::sun::star::sdb::XRowSetSupplier;
+using ::com::sun::star::awt::XVclWindowPeer;
+
+
+//------------------------------------------------------------------
+::com::sun::star::awt::FontDescriptor ImplCreateFontDescriptor( const Font& rFont )
+{
+ ::com::sun::star::awt::FontDescriptor aFD;
+ aFD.Name = rFont.GetName();
+ aFD.StyleName = rFont.GetStyleName();
+ aFD.Height = (sal_Int16)rFont.GetSize().Height();
+ aFD.Width = (sal_Int16)rFont.GetSize().Width();
+ aFD.Family = (sal_Int16)rFont.GetFamily();
+ aFD.CharSet = rFont.GetCharSet();
+ aFD.Pitch = (sal_Int16)rFont.GetPitch();
+ aFD.CharacterWidth = VCLUnoHelper::ConvertFontWidth( rFont.GetWidthType() );
+ aFD.Weight= VCLUnoHelper::ConvertFontWeight( rFont.GetWeight() );
+ aFD.Slant = (::com::sun::star::awt::FontSlant)rFont.GetItalic();
+ aFD.Underline = (sal_Int16)rFont.GetUnderline();
+ aFD.Strikeout = (sal_Int16)rFont.GetStrikeout();
+ aFD.Orientation = rFont.GetOrientation();
+ aFD.Kerning = rFont.IsKerning();
+ aFD.WordLineMode = rFont.IsWordLineMode();
+ aFD.Type = 0; // ??? => Nur an Metric...
+ return aFD;
+}
+
+//------------------------------------------------------------------
+Font ImplCreateFont( const ::com::sun::star::awt::FontDescriptor& rDescr )
+{
+ Font aFont;
+ aFont.SetName( rDescr.Name );
+ aFont.SetStyleName( rDescr.StyleName );
+ aFont.SetSize( ::Size( rDescr.Width, rDescr.Height ) );
+ aFont.SetFamily( (FontFamily)rDescr.Family );
+ aFont.SetCharSet( (CharSet)rDescr.CharSet );
+ aFont.SetPitch( (FontPitch)rDescr.Pitch );
+ aFont.SetWidthType( VCLUnoHelper::ConvertFontWidth( rDescr.CharacterWidth ) );
+ aFont.SetWeight( VCLUnoHelper::ConvertFontWeight( rDescr.Weight ) );
+ aFont.SetItalic( (FontItalic)rDescr.Slant );
+ aFont.SetUnderline( (::FontUnderline)rDescr.Underline );
+ aFont.SetStrikeout( (::FontStrikeout)rDescr.Strikeout );
+ aFont.SetOrientation( (sal_Int16)rDescr.Orientation );
+ aFont.SetKerning( rDescr.Kerning );
+ aFont.SetWordLineMode( rDescr.WordLineMode );
+ return aFont;
+}
+
+//==================================================================
+//= FmXModifyMultiplexer
+//==================================================================
+//------------------------------------------------------------------
+FmXModifyMultiplexer::FmXModifyMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex )
+ :OWeakSubObject( rSource )
+ ,OInterfaceContainerHelper( _rMutex )
+{
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXModifyMultiplexer::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ Any aReturn;
+ aReturn = ::cppu::queryInterface(_rType,
+ static_cast< ::com::sun::star::util::XModifyListener*>(this),
+ static_cast< XEventListener*>(this)
+ );
+
+ if (!aReturn.hasValue())
+ aReturn = OWeakSubObject::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+void FmXModifyMultiplexer::disposing(const EventObject& ) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------
+void FmXModifyMultiplexer::modified(const EventObject& e) throw( RuntimeException )
+{
+ EventObject aMulti( e);
+ aMulti.Source = &m_rParent;
+ notifyEach( &XModifyListener::modified, aMulti );
+}
+
+//==================================================================
+//= FmXUpdateMultiplexer
+//==================================================================
+//------------------------------------------------------------------
+FmXUpdateMultiplexer::FmXUpdateMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex )
+ :OWeakSubObject( rSource )
+ ,OInterfaceContainerHelper( _rMutex )
+{
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXUpdateMultiplexer::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ Any aReturn;
+ aReturn = ::cppu::queryInterface(_rType,
+ static_cast< XUpdateListener*>(this),
+ static_cast< XEventListener*>(this)
+ );
+
+ if (!aReturn.hasValue())
+ aReturn = OWeakSubObject::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+void FmXUpdateMultiplexer::disposing(const EventObject& ) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------
+sal_Bool FmXUpdateMultiplexer::approveUpdate(const EventObject &e) throw( RuntimeException )
+{
+ EventObject aMulti( e );
+ aMulti.Source = &m_rParent;
+
+ sal_Bool bResult = sal_True;
+ if (getLength())
+ {
+ ::cppu::OInterfaceIteratorHelper aIter(*this);
+ while ( bResult && aIter.hasMoreElements() )
+ bResult = static_cast< XUpdateListener* >( aIter.next() )->approveUpdate( aMulti );
+ }
+
+ return bResult;
+}
+
+//------------------------------------------------------------------
+void FmXUpdateMultiplexer::updated(const EventObject &e) throw( RuntimeException )
+{
+ EventObject aMulti( e );
+ aMulti.Source = &m_rParent;
+ notifyEach( &XUpdateListener::updated, aMulti );
+}
+
+
+//==================================================================
+//= FmXSelectionMultiplexer
+//==================================================================
+//------------------------------------------------------------------
+FmXSelectionMultiplexer::FmXSelectionMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex )
+ :OWeakSubObject( rSource )
+ ,OInterfaceContainerHelper( _rMutex )
+{
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXSelectionMultiplexer::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ Any aReturn;
+ aReturn = ::cppu::queryInterface(_rType,
+ static_cast< XSelectionChangeListener*>(this),
+ static_cast< XEventListener*>(this)
+ );
+
+ if (!aReturn.hasValue())
+ aReturn = OWeakSubObject::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+void FmXSelectionMultiplexer::disposing(const EventObject& ) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXSelectionMultiplexer::selectionChanged( const EventObject& _rEvent ) throw (RuntimeException)
+{
+ EventObject aMulti(_rEvent);
+ aMulti.Source = &m_rParent;
+ notifyEach( &XSelectionChangeListener::selectionChanged, aMulti );
+}
+
+//==================================================================
+//= FmXContainerMultiplexer
+//==================================================================
+//------------------------------------------------------------------
+FmXContainerMultiplexer::FmXContainerMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex )
+ :OWeakSubObject( rSource )
+ ,OInterfaceContainerHelper( _rMutex )
+{
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXContainerMultiplexer::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ Any aReturn;
+ aReturn = ::cppu::queryInterface(_rType,
+ static_cast< XContainerListener*>(this),
+ static_cast< XEventListener*>(this)
+ );
+
+ if (!aReturn.hasValue())
+ aReturn = OWeakSubObject::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+void FmXContainerMultiplexer::disposing(const EventObject& ) throw( RuntimeException )
+{
+}
+//------------------------------------------------------------------
+void FmXContainerMultiplexer::elementInserted(const ContainerEvent& e) throw( RuntimeException )
+{
+ ContainerEvent aMulti( e );
+ aMulti.Source = &m_rParent;
+ notifyEach( &XContainerListener::elementInserted, aMulti );
+}
+
+//------------------------------------------------------------------
+void FmXContainerMultiplexer::elementRemoved(const ContainerEvent& e) throw( RuntimeException )
+{
+ ContainerEvent aMulti( e );
+ aMulti.Source = &m_rParent;
+ notifyEach( &XContainerListener::elementRemoved, aMulti );
+}
+
+
+//------------------------------------------------------------------
+void FmXContainerMultiplexer::elementReplaced(const ContainerEvent& e) throw( RuntimeException )
+{
+ ContainerEvent aMulti( e );
+ aMulti.Source = &m_rParent;
+ notifyEach( &XContainerListener::elementReplaced, aMulti );
+}
+
+//==================================================================
+//= FmXGridControlMultiplexer
+//==================================================================
+//------------------------------------------------------------------
+FmXGridControlMultiplexer::FmXGridControlMultiplexer( ::cppu::OWeakObject& rSource, ::osl::Mutex& _rMutex )
+ :OWeakSubObject( rSource )
+ ,OInterfaceContainerHelper( _rMutex )
+{
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXGridControlMultiplexer::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ Any aReturn;
+ aReturn = ::cppu::queryInterface( _rType,
+ static_cast< XGridControlListener*>(this)
+ );
+
+ if (!aReturn.hasValue())
+ aReturn = OWeakSubObject::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+void FmXGridControlMultiplexer::disposing( const EventObject& ) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridControlMultiplexer::columnChanged( const EventObject& _event ) throw (RuntimeException)
+{
+ EventObject aForwardedEvent( _event );
+ aForwardedEvent.Source = &m_rParent;
+ notifyEach( &XGridControlListener::columnChanged, aForwardedEvent );
+}
+
+//==================================================================
+//= FmXGridControl
+//==================================================================
+
+//------------------------------------------------------------------
+Reference< XInterface > SAL_CALL FmXGridControl_NewInstance_Impl(const Reference< XMultiServiceFactory>& _rxFactory)
+{
+ return *(new FmXGridControl(_rxFactory));
+}
+DBG_NAME(FmXGridControl )
+//------------------------------------------------------------------------------
+FmXGridControl::FmXGridControl(const Reference< XMultiServiceFactory >& _rxFactory)
+ :m_aModifyListeners(*this, GetMutex())
+ ,m_aUpdateListeners(*this, GetMutex())
+ ,m_aContainerListeners(*this, GetMutex())
+ ,m_aSelectionListeners(*this, GetMutex())
+ ,m_aGridControlListeners(*this, GetMutex())
+ ,m_nPeerCreationLevel(0)
+ ,m_bInDraw(sal_False)
+ ,m_xServiceFactory(_rxFactory)
+{
+ DBG_CTOR(FmXGridControl ,NULL);
+}
+
+//------------------------------------------------------------------------------
+FmXGridControl::~FmXGridControl()
+{
+ DBG_DTOR(FmXGridControl ,NULL);
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXGridControl::queryAggregation(const Type& _rType) throw (RuntimeException)
+{
+ Any aReturn = FmXGridControl_BASE::queryInterface(_rType);
+
+ if (!aReturn.hasValue())
+ aReturn = UnoControl::queryAggregation( _rType );
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+Sequence< Type> SAL_CALL FmXGridControl::getTypes( ) throw(RuntimeException)
+{
+ return comphelper::concatSequences(UnoControl::getTypes(),FmXGridControl_BASE::getTypes());
+}
+
+//------------------------------------------------------------------
+Sequence<sal_Int8> SAL_CALL FmXGridControl::getImplementationId( ) throw(RuntimeException)
+{
+ static ::cppu::OImplementationId* pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FmXGridControl::supportsService(const ::rtl::OUString& ServiceName) throw()
+{
+ ::comphelper::StringSequence aSupported = getSupportedServiceNames();
+ const ::rtl::OUString * pArray = aSupported.getConstArray();
+ for( sal_Int32 i = 0; i < aSupported.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL FmXGridControl::getImplementationName() throw()
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.form.FmXGridControl");
+}
+
+//------------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL FmXGridControl::getSupportedServiceNames() throw()
+{
+ Sequence< ::rtl::OUString > aServiceNames(2);
+ aServiceNames[0] = FM_SUN_CONTROL_GRIDCONTROL;
+ aServiceNames[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.UnoControl");
+ return aServiceNames;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::dispose() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ EventObject aEvt;
+ aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
+ m_aModifyListeners.disposeAndClear(aEvt);
+ m_aUpdateListeners.disposeAndClear(aEvt);
+ m_aContainerListeners.disposeAndClear(aEvt);
+
+ UnoControl::dispose();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString FmXGridControl::GetComponentServiceName()
+{
+ ::rtl::OUString aName = ::rtl::OUString::createFromAscii("DBGrid");
+ return aName;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FmXGridControl::setModel(const Reference< ::com::sun::star::awt::XControlModel >& rModel) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if (!UnoControl::setModel(rModel))
+ return sal_False;
+
+ Reference< XGridPeer > xGridPeer(getPeer(), UNO_QUERY);
+ if (xGridPeer.is())
+ {
+ Reference< XIndexContainer > xCols(mxModel, UNO_QUERY);
+ xGridPeer->setColumns(xCols);
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+FmXGridPeer* FmXGridControl::imp_CreatePeer(Window* pParent)
+{
+ FmXGridPeer* pReturn = new FmXGridPeer(m_xServiceFactory);
+
+ // translate properties into WinBits
+ WinBits nStyle = WB_TABSTOP;
+ Reference< XPropertySet > xModelSet(getModel(), UNO_QUERY);
+ if (xModelSet.is())
+ {
+ try
+ {
+ if (::comphelper::getINT16(xModelSet->getPropertyValue(FM_PROP_BORDER)))
+ nStyle |= WB_BORDER;
+ }
+ catch(const Exception&)
+ {
+ OSL_ASSERT(!"Can not get style");
+ }
+ }
+
+ pReturn->Create(pParent, nStyle);
+ return pReturn;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::createPeer(const Reference< ::com::sun::star::awt::XToolkit >& /*rToolkit*/, const Reference< ::com::sun::star::awt::XWindowPeer >& rParentPeer) throw( RuntimeException )
+{
+ if ( !mxModel.is() )
+ throw DisposedException( ::rtl::OUString(), *this );
+
+ DBG_ASSERT(/*(0 == m_nPeerCreationLevel) && */!mbCreatingPeer, "FmXGridControl::createPeer : recursion!");
+ // I think this should never assert, now that we're using the base class' mbCreatingPeer in addition to
+ // our own m_nPeerCreationLevel
+ // But I'm not sure as I don't _fully_ understand the underlying toolkit implementations ....
+ // (if this asserts, we still need m_nPeerCreationLevel. If not, we could omit it ....)
+ // 14.05.2001 - 86836 - frank.schoenheit@germany.sun.com
+
+ // TODO: why the hell this whole class does not use any mutex?
+
+ if (!getPeer().is())
+ {
+ mbCreatingPeer = sal_True;
+ // mbCreatingPeer is virtually the same as m_nPeerCreationLevel, but it's the base class' method
+ // to prevent recursion.
+
+ Window* pParentWin = NULL;
+ if (rParentPeer.is())
+ {
+ VCLXWindow* pParent = VCLXWindow::GetImplementation(rParentPeer);
+ if (pParent)
+ pParentWin = pParent->GetWindow();
+ }
+
+ FmXGridPeer* pPeer = imp_CreatePeer(pParentWin);
+ DBG_ASSERT(pPeer != NULL, "FmXGridControl::createPeer : imp_CreatePeer didn't return a peer !");
+ setPeer( pPeer );
+
+ // lesen der properties aus dem model
+// ++m_nPeerCreationLevel;
+ updateFromModel();
+
+ // folgendes unschoene Szenario : updateFromModel fuehrt zu einem propertiesChanged am Control,
+ // das stellt fest, dass sich eine 'kritische' Property geaendert hat (zum Beispiel "Border") und
+ // legt daraufhin eine neue Peer an, was wieder hier im createPeer landet, wir legen also eine
+ // zweite FmXGridPeer an und initialisieren die. Dann kommen wir in der ersten Inkarnation aus
+ // dem updsateFromModel raus und arbeiten dort weiter mit dem pPeer, das jetzt eigentlich schon
+ // veraltet ist (da ja in der zweiten Inkarnation eine andere Peer angelegt wurde).
+ // Deswegen also der Aufwand mit dem PeerCreationLevel, das stellt sicher, dass wir die in dem
+ // tiefsten Level angelegte Peer wirklich verwenden, sie aber erst im top-level
+ // initialisieren.
+// if (--m_nPeerCreationLevel == 0)
+ {
+ DBG_ASSERT(getPeer().is(), "FmXGridControl::createPeer : something went wrong ... no top level peer !");
+ pPeer = FmXGridPeer::getImplementation(getPeer());
+
+ setPosSize( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight, ::com::sun::star::awt::PosSize::POSSIZE );
+
+ Reference< XIndexContainer > xColumns(getModel(), UNO_QUERY);
+ if (xColumns.is())
+ pPeer->setColumns(xColumns);
+
+ if (maComponentInfos.bVisible)
+ pPeer->setVisible(sal_True);
+
+ if (!maComponentInfos.bEnable)
+ pPeer->setEnable(sal_False);
+
+ if (maWindowListeners.getLength())
+ pPeer->addWindowListener( &maWindowListeners );
+
+ if (maFocusListeners.getLength())
+ pPeer->addFocusListener( &maFocusListeners );
+
+ if (maKeyListeners.getLength())
+ pPeer->addKeyListener( &maKeyListeners );
+
+ if (maMouseListeners.getLength())
+ pPeer->addMouseListener( &maMouseListeners );
+
+ if (maMouseMotionListeners.getLength())
+ pPeer->addMouseMotionListener( &maMouseMotionListeners );
+
+ if (maPaintListeners.getLength())
+ pPeer->addPaintListener( &maPaintListeners );
+
+ if (m_aModifyListeners.getLength())
+ pPeer->addModifyListener( &m_aModifyListeners );
+
+ if (m_aUpdateListeners.getLength())
+ pPeer->addUpdateListener( &m_aUpdateListeners );
+
+ if (m_aContainerListeners.getLength())
+ pPeer->addContainerListener( &m_aContainerListeners );
+
+ // forward the design mode
+ sal_Bool bForceAlivePeer = m_bInDraw && !maComponentInfos.bVisible;
+ // (we force a alive-mode peer if we're in "draw", cause in this case the peer will be used for drawing in
+ // foreign devices. We ensure this with the visibility check as an living peer is assumed to be noncritical
+ // only if invisible)
+ Any aOldCursorBookmark;
+ if (!mbDesignMode || bForceAlivePeer)
+ {
+ Reference< XFormComponent > xComp(getModel(), UNO_QUERY);
+ if (xComp.is())
+ {
+ Reference< XRowSet > xForm(xComp->getParent(), UNO_QUERY);
+ // is the form alive?
+ // we can see that if the form contains columns
+ Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xColumnsSupplier(xForm, UNO_QUERY);
+ if (xColumnsSupplier.is())
+ {
+ if (Reference< XIndexAccess > (xColumnsSupplier->getColumns(),UNO_QUERY)->getCount())
+ {
+ // we get only a new bookmark if the resultset is not forwardonly
+ if (::comphelper::getINT32(Reference< XPropertySet > (xForm, UNO_QUERY)->getPropertyValue(FM_PROP_RESULTSET_TYPE)) != ResultSetType::FORWARD_ONLY)
+ {
+ // as the FmGridControl touches the data source it is connected to we have to remember the current
+ // cursor position (and restore afterwards)
+ // OJ: but only when we stand on a valid row
+ Reference< XResultSet > xResultSet(xForm, UNO_QUERY);
+ if ( !xResultSet->isBeforeFirst() && !xResultSet->isAfterLast() )
+ {
+ try
+ {
+ aOldCursorBookmark = Reference< ::com::sun::star::sdbcx::XRowLocate > (xForm, UNO_QUERY)->getBookmark();
+ }
+ catch( const Exception& e )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ (void)e;
+ }
+ }
+ }
+ }
+ }
+ pPeer->setRowSet(xForm);
+ }
+ }
+ pPeer->setDesignMode(mbDesignMode && !bForceAlivePeer);
+
+ try
+ {
+ if (aOldCursorBookmark.hasValue())
+ { // we have a valid bookmark, so we have to restore the cursor's position
+ Reference< XFormComponent > xComp(getModel(), UNO_QUERY);
+ Reference< ::com::sun::star::sdbcx::XRowLocate > xLocate(xComp->getParent(), UNO_QUERY);
+ xLocate->moveToBookmark(aOldCursorBookmark);
+ }
+ }
+ catch( const Exception& e )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ (void)e;
+ }
+
+ Reference< ::com::sun::star::awt::XView > xPeerView(getPeer(), UNO_QUERY);
+ xPeerView->setZoom( maComponentInfos.nZoomX, maComponentInfos.nZoomY );
+ xPeerView->setGraphics( mxGraphics );
+ }
+ mbCreatingPeer = sal_False;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXGridControl::addModifyListener(const Reference< ::com::sun::star::util::XModifyListener >& l) throw( RuntimeException )
+{
+ m_aModifyListeners.addInterface( l );
+ if( getPeer().is() && m_aModifyListeners.getLength() == 1 )
+ {
+ Reference< ::com::sun::star::util::XModifyBroadcaster > xGrid(getPeer(), UNO_QUERY);
+ xGrid->addModifyListener( &m_aModifyListeners);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FmXGridControl::select( const Any& _rSelection ) throw (IllegalArgumentException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Reference< XSelectionSupplier > xPeer(getPeer(), UNO_QUERY);
+ return xPeer->select(_rSelection);
+}
+
+//------------------------------------------------------------------------------
+Any SAL_CALL FmXGridControl::getSelection( ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Reference< XSelectionSupplier > xPeer(getPeer(), UNO_QUERY);
+ return xPeer->getSelection();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::addSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aSelectionListeners.addInterface( _rxListener );
+ if( getPeer().is() && 1 == m_aSelectionListeners.getLength() )
+ {
+ Reference< XSelectionSupplier > xGrid(getPeer(), UNO_QUERY);
+ xGrid->addSelectionChangeListener( &m_aSelectionListeners);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
+{
+ if( getPeer().is() && 1 == m_aSelectionListeners.getLength() )
+ {
+ Reference< XSelectionSupplier > xGrid(getPeer(), UNO_QUERY);
+ xGrid->removeSelectionChangeListener( &m_aSelectionListeners);
+ }
+ m_aSelectionListeners.removeInterface( _rxListener );
+}
+
+//------------------------------------------------------------------------------
+Sequence< sal_Bool > SAL_CALL FmXGridControl::queryFieldDataType( const Type& xType ) throw(RuntimeException)
+{
+ if (getPeer().is())
+ {
+ Reference< XGridFieldDataSupplier > xPeerSupplier(getPeer(), UNO_QUERY);
+ if (xPeerSupplier.is())
+ return xPeerSupplier->queryFieldDataType(xType);
+ }
+
+ return Sequence<sal_Bool>();
+}
+
+//------------------------------------------------------------------------------
+Sequence< Any > SAL_CALL FmXGridControl::queryFieldData( sal_Int32 nRow, const Type& xType ) throw(RuntimeException)
+{
+ if (getPeer().is())
+ {
+ Reference< XGridFieldDataSupplier > xPeerSupplier(getPeer(), UNO_QUERY);
+ if (xPeerSupplier.is())
+ return xPeerSupplier->queryFieldData(nRow, xType);
+ }
+
+ return Sequence< Any>();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::removeModifyListener(const Reference< ::com::sun::star::util::XModifyListener >& l) throw( RuntimeException )
+{
+ if( getPeer().is() && m_aModifyListeners.getLength() == 1 )
+ {
+ Reference< ::com::sun::star::util::XModifyBroadcaster > xGrid(getPeer(), UNO_QUERY);
+ xGrid->removeModifyListener( &m_aModifyListeners);
+ }
+ m_aModifyListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::draw( sal_Int32 x, sal_Int32 y ) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ m_bInDraw = sal_True;
+ UnoControl::draw(x, y);
+ m_bInDraw = sal_False;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::setDesignMode(sal_Bool bOn) throw( RuntimeException )
+{
+ ::com::sun::star::util::ModeChangeEvent aModeChangeEvent;
+
+ // --- <mutex_lock> ---
+ {
+ SolarMutexGuard aGuard;
+
+ Reference< XRowSetSupplier > xGrid(getPeer(), UNO_QUERY);
+
+ if (xGrid.is() && (bOn != mbDesignMode || (!bOn && !xGrid->getRowSet().is())))
+ {
+ if (bOn)
+ {
+ xGrid->setRowSet(Reference< XRowSet > ());
+ }
+ else
+ {
+ Reference< XFormComponent > xComp(getModel(), UNO_QUERY);
+ if (xComp.is())
+ {
+ Reference< XRowSet > xForm(xComp->getParent(), UNO_QUERY);
+ xGrid->setRowSet(xForm);
+ }
+ }
+
+ mbDesignMode = bOn;
+
+ Reference< XVclWindowPeer > xVclWindowPeer( getPeer(), UNO_QUERY );
+ if (xVclWindowPeer.is())
+ xVclWindowPeer->setDesignMode(bOn);
+ }
+ mbDesignMode = bOn;
+
+ // dispose our current AccessibleContext, if we have one
+ // (changing the design mode implies having a new implementation for this context,
+ // so the old one must be declared DEFUNC)
+ disposeAccessibleContext();
+
+ // prepare firing an event
+ aModeChangeEvent.Source = *this;
+ aModeChangeEvent.NewMode = ::rtl::OUString::createFromAscii( mbDesignMode ? "design" : "alive" );
+ }
+
+ // --- </mutex_lock> ---
+ maModeChangeListeners.notifyEach( &XModeChangeListener::modeChanged, aModeChangeEvent );
+}
+
+// XBoundComponent
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::addUpdateListener(const Reference< XUpdateListener >& l) throw( RuntimeException )
+{
+ m_aUpdateListeners.addInterface( l );
+ if( getPeer().is() && m_aUpdateListeners.getLength() == 1 )
+ {
+ Reference< XBoundComponent > xBound(getPeer(), UNO_QUERY);
+ xBound->addUpdateListener( &m_aUpdateListeners);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::removeUpdateListener(const Reference< XUpdateListener >& l) throw( RuntimeException )
+{
+ if( getPeer().is() && m_aUpdateListeners.getLength() == 1 )
+ {
+ Reference< XBoundComponent > xBound(getPeer(), UNO_QUERY);
+ xBound->removeUpdateListener( &m_aUpdateListeners);
+ }
+ m_aUpdateListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FmXGridControl::commit() throw( RuntimeException )
+{
+ Reference< XBoundComponent > xBound(getPeer(), UNO_QUERY);
+ if (xBound.is())
+ return xBound->commit();
+ else
+ return sal_True;
+}
+
+// XContainer
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::addContainerListener(const Reference< XContainerListener >& l) throw( RuntimeException )
+{
+ m_aContainerListeners.addInterface( l );
+ if( getPeer().is() && m_aContainerListeners.getLength() == 1 )
+ {
+ Reference< XContainer > xContainer(getPeer(), UNO_QUERY);
+ xContainer->addContainerListener( &m_aContainerListeners);
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::removeContainerListener(const Reference< XContainerListener >& l) throw( RuntimeException )
+{
+ if( getPeer().is() && m_aContainerListeners.getLength() == 1 )
+ {
+ Reference< XContainer > xContainer(getPeer(), UNO_QUERY);
+ xContainer->removeContainerListener( &m_aContainerListeners);
+ }
+ m_aContainerListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::frame::XDispatch > SAL_CALL FmXGridControl::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::frame::XDispatchProvider > xPeerProvider(getPeer(), UNO_QUERY);
+ if (xPeerProvider.is())
+ return xPeerProvider->queryDispatch(aURL, aTargetFrameName, nSearchFlags);
+ else
+ return Reference< ::com::sun::star::frame::XDispatch > ();
+}
+
+//------------------------------------------------------------------------------
+Sequence< Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL FmXGridControl::queryDispatches(const Sequence< ::com::sun::star::frame::DispatchDescriptor>& aDescripts) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::frame::XDispatchProvider > xPeerProvider(getPeer(), UNO_QUERY);
+ if (xPeerProvider.is())
+ return xPeerProvider->queryDispatches(aDescripts);
+ else
+ return Sequence< Reference< ::com::sun::star::frame::XDispatch > >();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::registerDispatchProviderInterceptor(const Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& _xInterceptor) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::frame::XDispatchProviderInterception > xPeerInterception(getPeer(), UNO_QUERY);
+ if (xPeerInterception.is())
+ xPeerInterception->registerDispatchProviderInterceptor(_xInterceptor);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::releaseDispatchProviderInterceptor(const Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& _xInterceptor) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::frame::XDispatchProviderInterception > xPeerInterception(getPeer(), UNO_QUERY);
+ if (xPeerInterception.is())
+ xPeerInterception->releaseDispatchProviderInterceptor(_xInterceptor);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::addGridControlListener( const Reference< XGridControlListener >& _listener ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( GetMutex() );
+
+ m_aGridControlListeners.addInterface( _listener );
+ if ( getPeer().is() && 1 == m_aGridControlListeners.getLength() )
+ {
+ Reference< XGridControl > xPeerGrid( getPeer(), UNO_QUERY );
+ if ( xPeerGrid.is() )
+ xPeerGrid->addGridControlListener( &m_aGridControlListeners );
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::removeGridControlListener( const Reference< XGridControlListener >& _listener ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( GetMutex() );
+
+ if( getPeer().is() && 1 == m_aGridControlListeners.getLength() )
+ {
+ Reference< XGridControl > xPeerGrid( getPeer(), UNO_QUERY );
+ if ( xPeerGrid.is() )
+ xPeerGrid->removeGridControlListener( &m_aGridControlListeners );
+ }
+
+ m_aGridControlListeners.removeInterface( _listener );
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 SAL_CALL FmXGridControl::getCurrentColumnPosition() throw( RuntimeException )
+{
+ Reference< XGridControl > xGrid( getPeer(), UNO_QUERY );
+ return xGrid.is() ? xGrid->getCurrentColumnPosition() : -1;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::setCurrentColumnPosition(sal_Int16 nPos) throw( RuntimeException )
+{
+ Reference< XGridControl > xGrid( getPeer(), UNO_QUERY );
+ if ( xGrid.is() )
+ {
+ SolarMutexGuard aGuard;
+ xGrid->setCurrentColumnPosition( nPos );
+ }
+}
+
+// XElementAccess
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FmXGridControl::hasElements() throw( RuntimeException )
+{
+ Reference< XElementAccess > xPeer(getPeer(), UNO_QUERY);
+ return xPeer.is() ? xPeer->hasElements() : 0;
+}
+
+//------------------------------------------------------------------------------
+Type SAL_CALL FmXGridControl::getElementType( ) throw(RuntimeException)
+{
+ return ::getCppuType((const Reference< ::com::sun::star::awt::XTextComponent >*)NULL);
+}
+
+// XEnumerationAccess
+//------------------------------------------------------------------------------
+Reference< XEnumeration > SAL_CALL FmXGridControl::createEnumeration() throw( RuntimeException )
+{
+ Reference< XEnumerationAccess > xPeer(getPeer(), UNO_QUERY);
+ if (xPeer.is())
+ return xPeer->createEnumeration();
+ else
+ return new ::comphelper::OEnumerationByIndex(this);
+}
+
+// XIndexAccess
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL FmXGridControl::getCount() throw( RuntimeException )
+{
+ Reference< XIndexAccess > xPeer(getPeer(), UNO_QUERY);
+ return xPeer.is() ? xPeer->getCount() : 0;
+}
+
+//------------------------------------------------------------------------------
+Any SAL_CALL FmXGridControl::getByIndex(sal_Int32 _nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+{
+ Reference< XIndexAccess > xPeer(getPeer(), UNO_QUERY);
+ if (!xPeer.is())
+ throw IndexOutOfBoundsException();
+
+ return xPeer->getByIndex(_nIndex);
+}
+
+// ::com::sun::star::util::XModeSelector
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridControl::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException )
+{
+ Reference< ::com::sun::star::util::XModeSelector > xPeer(getPeer(), UNO_QUERY);
+ if (!xPeer.is())
+ throw NoSupportException();
+
+ xPeer->setMode(Mode);
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL FmXGridControl::getMode() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::util::XModeSelector > xPeer(getPeer(), UNO_QUERY);
+ return xPeer.is() ? xPeer->getMode() : ::rtl::OUString();
+}
+
+//------------------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL FmXGridControl::getSupportedModes() throw( RuntimeException )
+{
+ Reference< ::com::sun::star::util::XModeSelector > xPeer(getPeer(), UNO_QUERY);
+ return xPeer.is() ? xPeer->getSupportedModes() : ::comphelper::StringSequence();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FmXGridControl::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::util::XModeSelector > xPeer(getPeer(), UNO_QUERY);
+ return xPeer.is() ? xPeer->supportsMode(Mode) : sal_False;
+}
+
+//==============================================================================
+//= FmXGridPeer
+//==============================================================================
+// helper class which prevents that in the peer's header the FmGridListener must be known
+class FmXGridPeer::GridListenerDelegator : public FmGridListener
+{
+protected:
+ FmXGridPeer* m_pPeer;
+
+public:
+ GridListenerDelegator( FmXGridPeer* _pPeer );
+
+protected:
+ virtual void selectionChanged();
+ virtual void columnChanged();
+};
+
+//------------------------------------------------------------------
+FmXGridPeer::GridListenerDelegator::GridListenerDelegator(FmXGridPeer* _pPeer)
+ :m_pPeer(_pPeer)
+{
+ DBG_ASSERT(m_pPeer, "GridListenerDelegator::GridListenerDelegator");
+}
+
+//------------------------------------------------------------------
+void FmXGridPeer::GridListenerDelegator::selectionChanged()
+{
+ m_pPeer->selectionChanged();
+}
+
+//------------------------------------------------------------------
+void FmXGridPeer::GridListenerDelegator::columnChanged()
+{
+ m_pPeer->columnChanged();
+}
+
+//==============================================================================
+//------------------------------------------------------------------
+Reference< XInterface > FmXGridPeer_CreateInstance(const Reference< XMultiServiceFactory>& _rxFactory)
+{
+ FmXGridPeer* pNewObject = new FmXGridPeer(_rxFactory);
+ pNewObject->Create(NULL, WB_TABSTOP);
+ return *pNewObject;
+}
+
+//------------------------------------------------------------------
+Sequence< Type> SAL_CALL FmXGridPeer::getTypes( ) throw(RuntimeException)
+{
+ return comphelper::concatSequences( VCLXWindow::getTypes(), FmXGridPeer_BASE::getTypes() );
+}
+
+//------------------------------------------------------------------
+Sequence<sal_Int8> SAL_CALL FmXGridPeer::getImplementationId( ) throw(RuntimeException)
+{
+ static ::cppu::OImplementationId* pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXGridPeer::queryInterface(const Type& _rType) throw (RuntimeException)
+{
+ Any aReturn = FmXGridPeer_BASE::queryInterface(_rType);
+
+ if (!aReturn.hasValue())
+ aReturn = VCLXWindow::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//------------------------------------------------------------------
+void FmXGridPeer::selectionChanged()
+{
+ EventObject aSource;
+ aSource.Source = static_cast< ::cppu::OWeakObject* >(this);
+ m_aSelectionListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aSource);
+}
+
+//------------------------------------------------------------------
+void FmXGridPeer::columnChanged()
+{
+ EventObject aEvent( *this );
+ m_aGridControlListeners.notifyEach( &XGridControlListener::columnChanged, aEvent );
+}
+
+//------------------------------------------------------------------
+namespace fmgridif
+{
+ const ::rtl::OUString getDataModeIdentifier()
+ {
+ static ::rtl::OUString s_sDataModeIdentifier = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) );
+ return s_sDataModeIdentifier;
+ }
+}
+using namespace fmgridif;
+
+//------------------------------------------------------------------
+FmXGridPeer::FmXGridPeer(const Reference< XMultiServiceFactory >& _rxFactory)
+ :m_aModifyListeners(m_aMutex)
+ ,m_aUpdateListeners(m_aMutex)
+ ,m_aContainerListeners(m_aMutex)
+ ,m_aSelectionListeners(m_aMutex)
+ ,m_aGridControlListeners(m_aMutex)
+ ,m_aMode( getDataModeIdentifier() )
+ ,m_nCursorListening(0)
+ ,m_bInterceptingDispatch(sal_False)
+ ,m_pStateCache(NULL)
+ ,m_pDispatchers(NULL)
+ ,m_pGridListener(NULL)
+ ,m_xServiceFactory(_rxFactory)
+{
+ // nach diesem Constructor muss Create gerufen werden !
+ m_pGridListener = new GridListenerDelegator( this );
+}
+
+//------------------------------------------------------------------------------
+FmGridControl* FmXGridPeer::imp_CreateControl(Window* pParent, WinBits nStyle)
+{
+ return new FmGridControl(m_xServiceFactory, pParent, this, nStyle);
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::Create(Window* pParent, WinBits nStyle)
+{
+ FmGridControl* pWin = imp_CreateControl(pParent, nStyle);
+ DBG_ASSERT(pWin != NULL, "FmXGridPeer::Create : imp_CreateControl didn't return a control !");
+
+ pWin->SetStateProvider(LINK(this, FmXGridPeer, OnQueryGridSlotState));
+ pWin->SetSlotExecutor(LINK(this, FmXGridPeer, OnExecuteGridSlot));
+
+ // want to hear about row selections
+ pWin->setGridListener( m_pGridListener );
+
+ // Init muß immer aufgerufen werden
+ pWin->Init();
+ pWin->SetComponentInterface(this);
+
+ getSupportedURLs();
+}
+
+//------------------------------------------------------------------------------
+FmXGridPeer::~FmXGridPeer()
+{
+ setRowSet(Reference< XRowSet > ());
+ setColumns(Reference< XIndexContainer > ());
+
+ delete m_pGridListener;
+}
+
+//------------------------------------------------------------------------------
+const Sequence< sal_Int8 >& FmXGridPeer::getUnoTunnelImplementationId() throw()
+{
+ static Sequence< sal_Int8 > * pSeq = 0;
+ if( !pSeq )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+//------------------------------------------------------------------------------
+FmXGridPeer* FmXGridPeer::getImplementation( const Reference< XInterface >& _rxIFace ) throw()
+{
+ FmXGridPeer* pReturn = NULL;
+ Reference< XUnoTunnel > xTunnel(_rxIFace, UNO_QUERY);
+ if (xTunnel.is())
+ pReturn = reinterpret_cast<FmXGridPeer*>(xTunnel->getSomething(getUnoTunnelImplementationId()));
+
+ return pReturn;
+}
+
+//------------------------------------------------------------------------------
+sal_Int64 SAL_CALL FmXGridPeer::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException)
+{
+ sal_Int64 nReturn(0);
+
+ if ( (_rIdentifier.getLength() == 16)
+ && (0 == rtl_compareMemory( getUnoTunnelImplementationId().getConstArray(), _rIdentifier.getConstArray(), 16 ))
+ )
+ {
+ nReturn = reinterpret_cast<sal_Int64>(this);
+ }
+ else
+ nReturn = VCLXWindow::getSomething(_rIdentifier);
+
+ return nReturn;
+}
+
+// XEventListener
+//------------------------------------------------------------------------------
+void FmXGridPeer::disposing(const EventObject& e) throw( RuntimeException )
+{
+using namespace ::com::sun::star::util;
+ bool bKnownSender = false;
+
+ Reference< XIndexContainer > xCols( e.Source, UNO_QUERY );
+ if ( xCols.is() )
+ {
+ setColumns(Reference< XIndexContainer > ());
+ bKnownSender = true;
+ }
+
+ Reference< XRowSet > xCursor(e.Source, UNO_QUERY);
+ if (xCursor.is())
+ {
+ setRowSet( m_xCursor );
+ m_xCursor = NULL;
+ bKnownSender = true;
+ }
+
+
+ if ( !bKnownSender && m_pDispatchers )
+ {
+ const Sequence< URL>& aSupportedURLs = getSupportedURLs();
+ const URL* pSupportedURLs = aSupportedURLs.getConstArray();
+ for ( sal_uInt16 i=0; i < ( aSupportedURLs.getLength() ) && !bKnownSender; ++i, ++pSupportedURLs )
+ {
+ if ( m_pDispatchers[i] == e.Source )
+ {
+ m_pDispatchers[i]->removeStatusListener( static_cast< ::com::sun::star::frame::XStatusListener* >( this ), *pSupportedURLs );
+ m_pDispatchers[i] = NULL;
+ m_pStateCache[i] = 0;
+ bKnownSender = true;
+ }
+ }
+ }
+
+ if ( !bKnownSender )
+ VCLXWindow::disposing(e);
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::addModifyListener(const Reference< ::com::sun::star::util::XModifyListener >& l) throw( RuntimeException )
+{
+ m_aModifyListeners.addInterface( l );
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::removeModifyListener(const Reference< ::com::sun::star::util::XModifyListener >& l) throw( RuntimeException )
+{
+ m_aModifyListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------------------
+#define LAST_KNOWN_TYPE FormComponentType::PATTERNFIELD
+Sequence< sal_Bool > SAL_CALL FmXGridPeer::queryFieldDataType( const Type& xType ) throw(RuntimeException)
+{
+ // eine 'Konvertierungstabelle'
+ static sal_Bool bCanConvert[LAST_KNOWN_TYPE][4] =
+ {
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::CONTROL
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::COMMANDBUTTON
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::RADIOBUTTON
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::IMAGEBUTTON
+ { sal_False, sal_False, sal_False, sal_True }, // FormComponentType::CHECKBOX
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::LISTBOX
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::COMBOBOX
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::GROUPBOX
+ { sal_True , sal_False, sal_False, sal_False }, // FormComponentType::TEXTFIELD
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::FIXEDTEXT
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::GRIDCONTROL
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::FILECONTROL
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::HIDDENCONTROL
+ { sal_False, sal_False, sal_False, sal_False }, // FormComponentType::IMAGECONTROL
+ { sal_True , sal_True , sal_True , sal_False }, // FormComponentType::DATEFIELD
+ { sal_True , sal_True , sal_False, sal_False }, // FormComponentType::TIMEFIELD
+ { sal_True , sal_True , sal_False, sal_False }, // FormComponentType::NUMERICFIELD
+ { sal_True , sal_True , sal_False, sal_False }, // FormComponentType::CURRENCYFIELD
+ { sal_True , sal_False, sal_False, sal_False } // FormComponentType::PATTERNFIELD
+ };
+
+
+ sal_Int16 nMapColumn = -1;
+ switch (xType.getTypeClass())
+ {
+ case TypeClass_STRING : nMapColumn = 0; break;
+ case TypeClass_FLOAT:
+ case TypeClass_DOUBLE : nMapColumn = 1; break;
+ case TypeClass_SHORT:
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_UNSIGNED_SHORT : nMapColumn = 2; break;
+ case TypeClass_BOOLEAN : nMapColumn = 3; break;
+ default:
+ break;
+ }
+
+ Reference< XIndexContainer > xColumns = getColumns();
+
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ sal_Int32 nColumns = pGrid->GetViewColCount();
+
+ DbGridColumns aColumns = pGrid->GetColumns();
+
+ Sequence<sal_Bool> aReturnSequence(nColumns);
+ sal_Bool* pReturnArray = aReturnSequence.getArray();
+
+ sal_Bool bRequestedAsAny = (xType.getTypeClass() == TypeClass_ANY);
+
+ DbGridColumn* pCol;
+ Reference< ::com::sun::star::sdb::XColumn > xFieldContent;
+ Reference< XPropertySet > xCurrentColumn;
+ for (sal_Int32 i=0; i<nColumns; ++i)
+ {
+ if (bRequestedAsAny)
+ {
+ pReturnArray[i] = sal_True;
+ continue;
+ }
+
+ pReturnArray[i] = sal_False;
+
+ sal_uInt16 nModelPos = pGrid->GetModelColumnPos(pGrid->GetColumnIdFromViewPos((sal_uInt16)i));
+ DBG_ASSERT(nModelPos != (sal_uInt16)-1, "FmXGridPeer::queryFieldDataType : no model pos !");
+
+ pCol = aColumns.GetObject(nModelPos);
+ const DbGridRowRef xRow = pGrid->GetSeekRow();
+ xFieldContent = (xRow.Is() && xRow->HasField(pCol->GetFieldPos())) ? xRow->GetField(pCol->GetFieldPos()).getColumn() : Reference< ::com::sun::star::sdb::XColumn > ();
+ if (!xFieldContent.is())
+ // can't supply anything without a field content
+ // FS - 07.12.99 - 54391
+ continue;
+
+ xColumns->getByIndex(nModelPos) >>= xCurrentColumn;
+ if (!::comphelper::hasProperty(FM_PROP_CLASSID, xCurrentColumn))
+ continue;
+
+ sal_Int16 nClassId = sal_Int16();
+ xCurrentColumn->getPropertyValue(FM_PROP_CLASSID) >>= nClassId;
+ if (nClassId>LAST_KNOWN_TYPE)
+ continue;
+ DBG_ASSERT(nClassId>0, "FmXGridPeer::queryFieldDataType : somebody changed the definition of the FormComponentType enum !");
+
+ if (nMapColumn != -1)
+ pReturnArray[i] = bCanConvert[nClassId-1][nMapColumn];
+ }
+
+ return aReturnSequence;
+}
+
+//------------------------------------------------------------------------------
+Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type& xType ) throw(RuntimeException)
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ DBG_ASSERT(pGrid && pGrid->IsOpen(), "FmXGridPeer::queryFieldData : have no valid grid window !");
+ if (!pGrid || !pGrid->IsOpen())
+ return Sequence< Any>();
+
+ // das Control zur angegebenen Row fahren
+ if (!pGrid->SeekRow(nRow))
+ {
+ throw IllegalArgumentException();
+ }
+
+ // don't use GetCurrentRow as this isn't affected by the above SeekRow
+ // FS - 30.09.99 - 68644
+ DbGridRowRef xPaintRow = pGrid->GetPaintRow();
+ ENSURE_OR_THROW( xPaintRow.Is(), "invalid paint row" );
+
+ // die Columns des Controls brauche ich fuer GetFieldText
+ DbGridColumns aColumns = pGrid->GetColumns();
+
+ // und durch alle Spalten durch
+ sal_Int32 nColumnCount = pGrid->GetViewColCount();
+
+ Sequence< Any> aReturnSequence(nColumnCount);
+ Any* pReturnArray = aReturnSequence.getArray();
+
+ sal_Bool bRequestedAsAny = (xType.getTypeClass() == TypeClass_ANY);
+ Reference< ::com::sun::star::sdb::XColumn > xFieldContent;
+ DbGridColumn* pCol;
+ for (sal_Int32 i=0; i < nColumnCount; ++i)
+ {
+ sal_uInt16 nModelPos = pGrid->GetModelColumnPos(pGrid->GetColumnIdFromViewPos((sal_uInt16)i));
+ DBG_ASSERT(nModelPos != (sal_uInt16)-1, "FmXGridPeer::queryFieldData : invalid model pos !");
+
+ // don't use GetCurrentFieldValue to determine the field content as this isn't affected by the above SeekRow
+ // FS - 30.09.99 - 68644
+ pCol = aColumns.GetObject(nModelPos);
+ xFieldContent = xPaintRow->HasField( pCol->GetFieldPos() )
+ ? xPaintRow->GetField( pCol->GetFieldPos() ).getColumn()
+ : Reference< XColumn > ();
+
+ if ( !xFieldContent.is() )
+ continue;
+
+ if (bRequestedAsAny)
+ {
+ Reference< XPropertySet > xFieldSet(xFieldContent, UNO_QUERY);
+ pReturnArray[i] = xFieldSet->getPropertyValue(FM_PROP_VALUE);
+ }
+ else
+ {
+ switch (xType.getTypeClass())
+ {
+ // Strings werden direkt ueber das GetFieldText abgehandelt
+ case TypeClass_STRING :
+ {
+ String sText = aColumns.GetObject(nModelPos)->GetCellText( xPaintRow, pGrid->getNumberFormatter() );
+ pReturnArray[i] <<= ::rtl::OUString(sText);
+ }
+ break;
+ // alles andere wird an der DatabaseVariant erfragt
+ case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break;
+ case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break;
+ case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break;
+ case TypeClass_LONG : pReturnArray[i] <<= (sal_Int32)xFieldContent->getLong(); break;
+ case TypeClass_UNSIGNED_SHORT : pReturnArray[i] <<= (sal_uInt16)xFieldContent->getShort(); break;
+ case TypeClass_UNSIGNED_LONG : pReturnArray[i] <<= (sal_uInt32)xFieldContent->getLong(); break;
+ case TypeClass_BOOLEAN : ::comphelper::setBOOL(pReturnArray[i],xFieldContent->getBoolean()); break;
+ default:
+ {
+ throw IllegalArgumentException();
+ }
+ }
+ }
+ }
+ return aReturnSequence;
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::CellModified()
+{
+ EventObject aEvt;
+ aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
+ m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt );
+}
+
+// XPropertyChangeListener
+//------------------------------------------------------------------------------
+void FmXGridPeer::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ // want to do a lot of VCL stuff here ...
+ // this should not be (deadlock) critical, as by definition, every component should release
+ // any own mutexes before notifying
+
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if (!pGrid)
+ return;
+
+ // DatenbankEvent
+ Reference< XRowSet > xCursor(evt.Source, UNO_QUERY);
+ if (evt.PropertyName == FM_PROP_VALUE || m_xCursor == evt.Source)
+ pGrid->propertyChange(evt);
+ else if (pGrid && m_xColumns.is() && m_xColumns->hasElements())
+ {
+ // zunaechst raussuchen welche Column sich geaendert hat
+ ::comphelper::InterfaceRef xCurrent;
+ sal_Int32 i;
+
+ for ( i = 0; i < m_xColumns->getCount(); i++)
+ {
+ ::cppu::extractInterface(xCurrent, m_xColumns->getByIndex(i));
+ if (evt.Source == xCurrent)
+ break;
+ }
+
+ if (i >= m_xColumns->getCount())
+ // this is valid because we are listening at the cursor, too (RecordCount, -status, edit mode)
+ return;
+
+ sal_uInt16 nId = pGrid->GetColumnIdFromModelPos((sal_uInt16)i);
+ sal_Bool bInvalidateColumn = sal_False;
+
+ if (evt.PropertyName == FM_PROP_LABEL)
+ {
+ String aName = ::comphelper::getString(evt.NewValue);
+ if (aName != pGrid->GetColumnTitle(nId))
+ pGrid->SetColumnTitle(nId, aName);
+ }
+ else if (evt.PropertyName == FM_PROP_WIDTH)
+ {
+ sal_Int32 nWidth = 0;
+ if (evt.NewValue.getValueType().getTypeClass() == TypeClass_VOID)
+ nWidth = pGrid->GetDefaultColumnWidth(pGrid->GetColumnTitle(nId));
+ // GetDefaultColumnWidth already considerd the zoom factor
+ else
+ {
+ sal_Int32 nTest = 0;
+ if (evt.NewValue >>= nTest)
+ {
+ nWidth = pGrid->LogicToPixel(Point(nTest,0),MAP_10TH_MM).X();
+ // take the zoom factor into account
+ nWidth = pGrid->CalcZoom(nWidth);
+ }
+ }
+ if (nWidth != (sal_Int32(pGrid->GetColumnWidth(nId))))
+ {
+ if (pGrid->IsEditing())
+ {
+ pGrid->DeactivateCell();
+ pGrid->ActivateCell();
+ }
+ pGrid->SetColumnWidth(nId, nWidth);
+ }
+ }
+ else if (evt.PropertyName == FM_PROP_HIDDEN)
+ {
+ DBG_ASSERT(evt.NewValue.getValueType().getTypeClass() == TypeClass_BOOLEAN,
+ "FmXGridPeer::propertyChange : the property 'hidden' should be of type boolean !");
+ if (::comphelper::getBOOL(evt.NewValue))
+ pGrid->HideColumn(nId);
+ else
+ pGrid->ShowColumn(nId);
+ }
+ else if (evt.PropertyName == FM_PROP_ALIGN)
+ {
+ // it design mode it doesn't matter
+ if (!isDesignMode())
+ {
+ DbGridColumn* pCol = pGrid->GetColumns().GetObject(i);
+
+ pCol->SetAlignmentFromModel(-1);
+ bInvalidateColumn = sal_True;
+ }
+ }
+ else if (evt.PropertyName == FM_PROP_FORMATKEY)
+ {
+ if (!isDesignMode())
+ bInvalidateColumn = sal_True;
+ }
+
+ // need to invalidate the affected column ?
+ if (bInvalidateColumn)
+ {
+ sal_Bool bWasEditing = pGrid->IsEditing();
+ if (bWasEditing)
+ pGrid->DeactivateCell();
+
+ ::Rectangle aColRect = pGrid->GetFieldRect(nId);
+ aColRect.Top() = 0;
+ aColRect.Bottom() = pGrid->GetSizePixel().Height();
+ pGrid->Invalidate(aColRect);
+
+ if (bWasEditing)
+ pGrid->ActivateCell();
+ }
+ }
+}
+
+// XBoundComponent
+//------------------------------------------------------------------------------
+void FmXGridPeer::addUpdateListener(const Reference< XUpdateListener >& l) throw( RuntimeException )
+{
+ m_aUpdateListeners.addInterface(l);
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::removeUpdateListener(const Reference< XUpdateListener >& l) throw( RuntimeException )
+{
+ m_aUpdateListeners.removeInterface(l);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmXGridPeer::commit() throw( RuntimeException )
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if (!m_xCursor.is() || !pGrid)
+ return sal_True;
+
+ EventObject aEvt(static_cast< ::cppu::OWeakObject* >(this));
+ ::cppu::OInterfaceIteratorHelper aIter(m_aUpdateListeners);
+ sal_Bool bCancel = sal_False;
+ while (aIter.hasMoreElements() && !bCancel)
+ if ( !static_cast< XUpdateListener* >( aIter.next() )->approveUpdate( aEvt ) )
+ bCancel = sal_True;
+
+ if (!bCancel)
+ bCancel = !pGrid->commit();
+
+ if (!bCancel)
+ m_aUpdateListeners.notifyEach( &XUpdateListener::updated, aEvt );
+ return !bCancel;
+}
+
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::cursorMoved(const EventObject& _rEvent) throw( RuntimeException )
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ // we are not interested in move to insert row only in the resetted event
+ // which is fired after positioning an the insert row
+ if (pGrid && pGrid->IsOpen() && !::comphelper::getBOOL(Reference< XPropertySet > (_rEvent.Source, UNO_QUERY)->getPropertyValue(FM_PROP_ISNEW)))
+ pGrid->positioned(_rEvent);
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::rowChanged(const EventObject& _rEvent) throw( RuntimeException )
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if (pGrid && pGrid->IsOpen())
+ {
+ if (m_xCursor->rowUpdated() && !pGrid->IsCurrentAppending())
+ pGrid->RowModified(pGrid->GetCurrentPos());
+ else if (m_xCursor->rowInserted())
+ pGrid->inserted(_rEvent);
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException )
+{
+ // not interested in ...
+ // (our parent is a form which means we get a loaded or reloaded after this rowSetChanged)
+}
+
+// XLoadListener
+//------------------------------------------------------------------------------
+void FmXGridPeer::loaded(const EventObject& /*rEvent*/) throw( RuntimeException )
+{
+ updateGrid(m_xCursor);
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException )
+{
+ updateGrid( Reference< XRowSet > (NULL) );
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::reloading(const EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ // empty the grid
+ updateGrid( Reference< XRowSet > (NULL) );
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::unloading(const EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ // empty the grid
+ updateGrid( Reference< XRowSet > (NULL) );
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::reloaded(const EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ updateGrid(m_xCursor);
+}
+
+// XGridPeer
+//------------------------------------------------------------------------------
+Reference< XIndexContainer > FmXGridPeer::getColumns() throw( RuntimeException )
+{
+ return m_xColumns;
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::addColumnListeners(const Reference< XPropertySet >& xCol)
+{
+ static const ::rtl::OUString aPropsListenedTo[] =
+ {
+ FM_PROP_LABEL, FM_PROP_WIDTH, FM_PROP_HIDDEN, FM_PROP_ALIGN, FM_PROP_FORMATKEY
+ };
+
+ // as not all properties have to be supported by all columns we have to check this
+ // before adding a listener
+ Reference< XPropertySetInfo > xInfo = xCol->getPropertySetInfo();
+ Property aPropDesc;
+ const ::rtl::OUString* pProps = aPropsListenedTo;
+ const ::rtl::OUString* pPropsEnd = pProps + SAL_N_ELEMENTS( aPropsListenedTo );
+ for (; pProps != pPropsEnd; ++pProps)
+ {
+ if ( xInfo->hasPropertyByName( *pProps ) )
+ {
+ aPropDesc = xInfo->getPropertyByName( *pProps );
+ if ( 0 != ( aPropDesc.Attributes & PropertyAttribute::BOUND ) )
+ xCol->addPropertyChangeListener( *pProps, this );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::removeColumnListeners(const Reference< XPropertySet >& xCol)
+{
+ // the same props as in addColumnListeners ... linux has problems with global static UStrings, so
+ // we have to do it this way ....
+ static ::rtl::OUString aPropsListenedTo[] =
+ {
+ FM_PROP_LABEL, FM_PROP_WIDTH, FM_PROP_HIDDEN, FM_PROP_ALIGN, FM_PROP_FORMATKEY
+ };
+
+ Reference< XPropertySetInfo > xInfo = xCol->getPropertySetInfo();
+ for (sal_uInt16 i=0; i < SAL_N_ELEMENTS(aPropsListenedTo); ++i)
+ if (xInfo->hasPropertyByName(aPropsListenedTo[i]))
+ xCol->removePropertyChangeListener(aPropsListenedTo[i], this);
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::setColumns(const Reference< XIndexContainer >& Columns) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ FmGridControl* pGrid = static_cast< FmGridControl* >( GetWindow() );
+
+ if (m_xColumns.is())
+ {
+ Reference< XPropertySet > xCol;
+ for (sal_Int32 i = 0; i < m_xColumns->getCount(); i++)
+ {
+ ::cppu::extractInterface(xCol, m_xColumns->getByIndex(i));
+ removeColumnListeners(xCol);
+ }
+ Reference< XContainer > xContainer(m_xColumns, UNO_QUERY);
+ xContainer->removeContainerListener(this);
+
+ Reference< XSelectionSupplier > xSelSupplier(m_xColumns, UNO_QUERY);
+ xSelSupplier->removeSelectionChangeListener(this);
+
+ Reference< XReset > xColumnReset(m_xColumns, UNO_QUERY);
+ if (xColumnReset.is())
+ xColumnReset->removeResetListener((XResetListener*)this);
+ }
+ if (Columns.is())
+ {
+ Reference< XContainer > xContainer(Columns, UNO_QUERY);
+ xContainer->addContainerListener(this);
+
+ Reference< XSelectionSupplier > xSelSupplier(Columns, UNO_QUERY);
+ xSelSupplier->addSelectionChangeListener(this);
+
+ Reference< XPropertySet > xCol;
+ for (sal_Int32 i = 0; i < Columns->getCount(); i++)
+ {
+ ::cppu::extractInterface(xCol, Columns->getByIndex(i));
+ addColumnListeners(xCol);
+ }
+
+ Reference< XReset > xColumnReset(Columns, UNO_QUERY);
+ if (xColumnReset.is())
+ xColumnReset->addResetListener((XResetListener*)this);
+ }
+ m_xColumns = Columns;
+ if (pGrid)
+ {
+ pGrid->InitColumnsByModels(m_xColumns);
+
+ if (m_xColumns.is())
+ {
+ EventObject aEvt(m_xColumns);
+ selectionChanged(aEvt);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::setDesignMode(sal_Bool bOn) throw( RuntimeException )
+{
+ if (bOn != isDesignMode())
+ {
+ Window* pWin = GetWindow();
+ if (pWin)
+ ((FmGridControl*) pWin)->SetDesignMode(bOn);
+ }
+
+ if (bOn)
+ DisConnectFromDispatcher();
+ else
+ UpdateDispatches(); // will connect if not already connected and just update else
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmXGridPeer::isDesignMode() throw( RuntimeException )
+{
+ Window* pWin = GetWindow();
+ if (pWin)
+ return ((FmGridControl*) pWin)->IsDesignMode();
+ else
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::elementInserted(const ContainerEvent& evt) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ // Handle Column beruecksichtigen
+ if (!pGrid || !m_xColumns.is() || pGrid->IsInColumnMove() || m_xColumns->getCount() == ((sal_Int32)pGrid->GetModelColCount()))
+ return;
+
+ Reference< XPropertySet > xSet;
+ ::cppu::extractInterface(xSet, evt.Element);
+ addColumnListeners(xSet);
+
+ Reference< XPropertySet > xNewColumn(xSet);
+ String aName = ::comphelper::getString(xNewColumn->getPropertyValue(FM_PROP_LABEL));
+ Any aWidth = xNewColumn->getPropertyValue(FM_PROP_WIDTH);
+ sal_Int32 nWidth = 0;
+ if (aWidth >>= nWidth)
+ nWidth = pGrid->LogicToPixel(Point(nWidth,0),MAP_10TH_MM).X();
+
+ pGrid->AppendColumn(aName, (sal_uInt16)nWidth, (sal_Int16)::comphelper::getINT32(evt.Accessor));
+
+ // jetzt die Spalte setzen
+ DbGridColumn* pCol = pGrid->GetColumns().GetObject(::comphelper::getINT32(evt.Accessor));
+ pCol->setModel(xNewColumn);
+
+ Any aHidden = xNewColumn->getPropertyValue(FM_PROP_HIDDEN);
+ if (::comphelper::getBOOL(aHidden))
+ pGrid->HideColumn(pCol->GetId());
+
+ FormControlFactory( m_xServiceFactory ).initializeTextFieldLineEnds( xNewColumn );
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::elementReplaced(const ContainerEvent& evt) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+
+ // Handle Column beruecksichtigen
+ if (!pGrid || !m_xColumns.is() || pGrid->IsInColumnMove())
+ return;
+
+ Reference< XPropertySet > xNewColumn;
+ Reference< XPropertySet > xOldColumn;
+ ::cppu::extractInterface(xNewColumn, evt.Element);
+ ::cppu::extractInterface(xOldColumn, evt.ReplacedElement);
+
+ sal_Bool bWasEditing = pGrid->IsEditing();
+ if (bWasEditing)
+ pGrid->DeactivateCell();
+
+ pGrid->RemoveColumn(pGrid->GetColumnIdFromModelPos((sal_uInt16)::comphelper::getINT32(evt.Accessor)));
+
+ removeColumnListeners(xOldColumn);
+ addColumnListeners(xNewColumn);
+
+ String aName = ::comphelper::getString(xNewColumn->getPropertyValue(FM_PROP_LABEL));
+ Any aWidth = xNewColumn->getPropertyValue(FM_PROP_WIDTH);
+ sal_Int32 nWidth = 0;
+ if (aWidth >>= nWidth)
+ nWidth = pGrid->LogicToPixel(Point(nWidth,0),MAP_10TH_MM).X();
+ sal_uInt16 nNewId = pGrid->AppendColumn(aName, (sal_uInt16)nWidth, (sal_Int16)::comphelper::getINT32(evt.Accessor));
+ sal_uInt16 nNewPos = pGrid->GetModelColumnPos(nNewId);
+
+ // set the model of the new column
+ DbGridColumn* pCol = pGrid->GetColumns().GetObject(nNewPos);
+
+ // for initializong this grid column, we need the fields of the grid's data source
+ Reference< XColumnsSupplier > xSuppColumns;
+ CursorWrapper* pGridDataSource = pGrid->getDataSource();
+ if ( pGridDataSource )
+ xSuppColumns = xSuppColumns.query( (Reference< XInterface >)( *pGridDataSource ) );
+ Reference< XNameAccess > xColumnsByName;
+ if ( xSuppColumns.is() )
+ xColumnsByName = xSuppColumns->getColumns();
+ Reference< XIndexAccess > xColumnsByIndex( xColumnsByName, UNO_QUERY );
+
+ if ( xColumnsByIndex.is() )
+ pGrid->InitColumnByField( pCol, xNewColumn, xColumnsByName, xColumnsByIndex );
+ else
+ // the simple version, applies when the grid is not yet connected to a data source
+ pCol->setModel(xNewColumn);
+
+ if (bWasEditing)
+ pGrid->ActivateCell();
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::elementRemoved(const ContainerEvent& evt) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+
+ // Handle Column beruecksichtigen
+ if (!pGrid || !m_xColumns.is() || pGrid->IsInColumnMove() || m_xColumns->getCount() == ((sal_Int32)pGrid->GetModelColCount()))
+ return;
+
+ pGrid->RemoveColumn(pGrid->GetColumnIdFromModelPos((sal_uInt16)::comphelper::getINT32(evt.Accessor)));
+
+ Reference< XPropertySet > xOldColumn;
+ ::cppu::extractInterface(xOldColumn, evt.Element);
+ removeColumnListeners(xOldColumn);
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::setProperty( const ::rtl::OUString& PropertyName, const Any& Value) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+
+ sal_Bool bVoid = !Value.hasValue();
+
+ if ( 0 == PropertyName.compareTo( FM_PROP_TEXTLINECOLOR ) )
+ {
+ ::Color aTextLineColor( bVoid ? COL_TRANSPARENT : ::comphelper::getINT32( Value ) );
+ if (bVoid)
+ {
+ pGrid->SetTextLineColor();
+ pGrid->GetDataWindow().SetTextLineColor();
+ }
+ else
+ {
+ pGrid->SetTextLineColor(aTextLineColor);
+ pGrid->GetDataWindow().SetTextLineColor(aTextLineColor);
+ }
+
+ // need to forward this to the columns
+ DbGridColumns& rColumns = const_cast<DbGridColumns&>(pGrid->GetColumns());
+ DbGridColumn* pLoop = rColumns.First();
+ while (pLoop)
+ {
+ FmXGridCell* pXCell = pLoop->GetCell();
+ if (pXCell)
+ {
+ if (bVoid)
+ pXCell->SetTextLineColor();
+ else
+ pXCell->SetTextLineColor(aTextLineColor);
+ }
+
+ pLoop = rColumns.Next();
+ }
+
+ if (isDesignMode())
+ pGrid->Invalidate();
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_FONTEMPHASISMARK ) )
+ {
+ Font aGridFont = pGrid->GetControlFont();
+ sal_Int16 nValue = ::comphelper::getINT16(Value);
+ aGridFont.SetEmphasisMark( nValue );
+ pGrid->SetControlFont( aGridFont );
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_FONTRELIEF ) )
+ {
+ Font aGridFont = pGrid->GetControlFont();
+ sal_Int16 nValue = ::comphelper::getINT16(Value);
+ aGridFont.SetRelief( (FontRelief)nValue );
+ pGrid->SetControlFont( aGridFont );
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_HELPURL ) )
+ {
+ String sHelpURL(::comphelper::getString(Value));
+ String sPattern;
+ sPattern.AssignAscii("HID:");
+ if (sHelpURL.Equals(sPattern, 0, sPattern.Len()))
+ {
+ String sID = sHelpURL.Copy(sPattern.Len());
+ pGrid->SetHelpId(sID.ToInt32());
+ }
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_DISPLAYSYNCHRON ) )
+ {
+ pGrid->setDisplaySynchron(::comphelper::getBOOL(Value));
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_CURSORCOLOR ) )
+ {
+ if (bVoid)
+ pGrid->SetCursorColor(COL_TRANSPARENT);
+ else
+ pGrid->SetCursorColor( ::Color(::comphelper::getINT32(Value)));
+ if (isDesignMode())
+ pGrid->Invalidate();
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_ALWAYSSHOWCURSOR ) )
+ {
+ pGrid->EnablePermanentCursor(::comphelper::getBOOL(Value));
+ if (isDesignMode())
+ pGrid->Invalidate();
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_FONT ) )
+ {
+ if ( bVoid )
+ pGrid->SetControlFont( Font() );
+ else
+ {
+ ::com::sun::star::awt::FontDescriptor aFont;
+ if (Value >>= aFont)
+ {
+ Font aNewVclFont;
+ if (::comphelper::operator!=(aFont, ::comphelper::getDefaultFont())) // ist das der Default
+ aNewVclFont = ImplCreateFont( aFont );
+
+ // need to add relief and emphasis (they're stored in a VCL-Font, but not in a FontDescriptor
+ Font aOldVclFont = pGrid->GetControlFont();
+ aNewVclFont.SetRelief( aOldVclFont.GetRelief() );
+ aNewVclFont.SetEmphasisMark( aOldVclFont.GetEmphasisMark() );
+
+ // now set it ...
+ pGrid->SetControlFont( aNewVclFont );
+
+ // if our row-height property is void (which means "calculate it font-dependent") we have
+ // to adjust the control's row height
+ Reference< XPropertySet > xModelSet(getColumns(), UNO_QUERY);
+ if (xModelSet.is() && ::comphelper::hasProperty(FM_PROP_ROWHEIGHT, xModelSet))
+ {
+ Any aHeight = xModelSet->getPropertyValue(FM_PROP_ROWHEIGHT);
+ if (!aHeight.hasValue())
+ pGrid->SetDataRowHeight(0);
+ }
+
+ }
+ }
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_BACKGROUNDCOLOR ) )
+ {
+ if ( bVoid )
+ {
+ pGrid->SetControlBackground();
+ }
+ else
+ {
+ ::Color aColor( ::comphelper::getINT32(Value) );
+ pGrid->SetBackground( aColor );
+ pGrid->SetControlBackground( aColor );
+ }
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_TEXTCOLOR ) )
+ {
+ if ( bVoid )
+ {
+ pGrid->SetControlForeground();
+ }
+ else
+ {
+ ::Color aColor( ::comphelper::getINT32(Value) );
+ pGrid->SetTextColor( aColor );
+ pGrid->SetControlForeground( aColor );
+ }
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_ROWHEIGHT ) )
+ {
+ sal_Int32 nLogHeight(0);
+ if (Value >>= nLogHeight)
+ {
+ sal_Int32 nHeight = pGrid->LogicToPixel(Point(0,nLogHeight),MAP_10TH_MM).Y();
+ // take the zoom factor into account
+ nHeight = pGrid->CalcZoom(nHeight);
+ pGrid->SetDataRowHeight(nHeight);
+ }
+ else if (bVoid)
+ pGrid->SetDataRowHeight(0);
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_HASNAVIGATION ) )
+ {
+ if (Value.getValueType() == ::getBooleanCppuType())
+ pGrid->EnableNavigationBar(*(sal_Bool*)Value.getValue());
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_RECORDMARKER ) )
+ {
+ if (Value.getValueType() == ::getBooleanCppuType())
+ pGrid->EnableHandle(*(sal_Bool*)Value.getValue());
+ }
+ else if ( 0 == PropertyName.compareTo( FM_PROP_ENABLED ) )
+ {
+ if (Value.getValueType() == ::getBooleanCppuType())
+ {
+ // Im DesignModus nur das Datenfenster disablen
+ // Sonst kann das Control nicht mehr konfiguriert werden
+ if (isDesignMode())
+ pGrid->GetDataWindow().Enable(*(sal_Bool*)Value.getValue());
+ else
+ pGrid->Enable(*(sal_Bool*)Value.getValue());
+ }
+ }
+ else
+ VCLXWindow::setProperty( PropertyName, Value );
+}
+
+//------------------------------------------------------------------------------
+Reference< XAccessibleContext > FmXGridPeer::CreateAccessibleContext()
+{
+ Reference< XAccessibleContext > xContext;
+
+ // use the AccessibleContext provided by the VCL window
+ Window* pGrid = GetWindow();
+ if ( pGrid )
+ {
+ Reference< XAccessible > xAcc( pGrid->GetAccessible( TRUE ) );
+ if ( xAcc.is() )
+ xContext = xAcc->getAccessibleContext();
+ // TODO: this has a slight conceptual problem:
+ //
+ // We know that the XAccessible and XAccessibleContext implementation of the browse
+ // box is the same (the class implements both interfaces), which, speaking strictly,
+ // is bad here (means when a browse box acts as UnoControl): We (the FmXGridPeer) are
+ // the XAccessible here, and the browse box should be able to provide us an XAccessibleContext,
+ // but it should _not_ be the XAccessible itself.
+ // However, as long as no client implementation uses dirty hacks such as querying an
+ // XAccessibleContext for XAccessible, this should not be a problem.
+ }
+
+ if ( !xContext.is() )
+ xContext = VCLXWindow::CreateAccessibleContext( );
+
+ return xContext;
+}
+
+//------------------------------------------------------------------------------
+Any FmXGridPeer::getProperty( const ::rtl::OUString& _rPropertyName ) throw( RuntimeException )
+{
+ Any aProp;
+ if (GetWindow())
+ {
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ Window* pDataWindow = &pGrid->GetDataWindow();
+
+ if ( 0 == _rPropertyName.compareTo( FM_PROP_NAME ) )
+ {
+ Font aFont = pDataWindow->GetControlFont();
+ aProp <<= ImplCreateFontDescriptor( aFont );
+ }
+ else if ( 0 == _rPropertyName.compareTo( FM_PROP_TEXTCOLOR ) )
+ {
+ aProp <<= (sal_Int32)pDataWindow->GetControlForeground().GetColor();
+ }
+ else if ( 0 == _rPropertyName.compareTo( FM_PROP_BACKGROUNDCOLOR ) )
+ {
+ aProp <<= (sal_Int32)pDataWindow->GetControlBackground().GetColor();
+ }
+ else if ( 0 == _rPropertyName.compareTo( FM_PROP_ROWHEIGHT ) )
+ {
+ sal_Int32 nPixelHeight = pGrid->GetDataRowHeight();
+ // take the zoom factor into account
+ nPixelHeight = pGrid->CalcReverseZoom(nPixelHeight);
+ aProp <<= (sal_Int32)pGrid->PixelToLogic(Point(0,nPixelHeight),MAP_10TH_MM).Y();
+ }
+ else if ( 0 == _rPropertyName.compareTo( FM_PROP_HASNAVIGATION ) )
+ {
+ sal_Bool bHasNavBar = pGrid->HasNavigationBar();
+ aProp <<= (sal_Bool)bHasNavBar;
+ }
+ else if ( 0 == _rPropertyName.compareTo( FM_PROP_RECORDMARKER ) )
+ {
+ sal_Bool bHasHandle = pGrid->HasHandle();
+ aProp <<= (sal_Bool)bHasHandle;
+ }
+ else if ( 0 == _rPropertyName.compareTo( FM_PROP_ENABLED ) )
+ {
+ aProp <<= (sal_Bool)pDataWindow->IsEnabled();
+ }
+ else
+ aProp = VCLXWindow::getProperty( _rPropertyName );
+ }
+ return aProp;
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::dispose() throw( RuntimeException )
+{
+ EventObject aEvt;
+ aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
+ m_aModifyListeners.disposeAndClear(aEvt);
+ m_aUpdateListeners.disposeAndClear(aEvt);
+ m_aContainerListeners.disposeAndClear(aEvt);
+ VCLXWindow::dispose();
+
+ // release all interceptors
+ // discovered during #100312# - 2002-10-23 - fs@openoffice.org
+ Reference< XDispatchProviderInterceptor > xInterceptor( m_xFirstDispatchInterceptor );
+ m_xFirstDispatchInterceptor.clear();
+ while ( xInterceptor.is() )
+ {
+ // tell the interceptor it has a new (means no) predecessor
+ xInterceptor->setMasterDispatchProvider( NULL );
+
+ // ask for it's successor
+ Reference< XDispatchProvider > xSlave = xInterceptor->getSlaveDispatchProvider();
+ // and give it the new (means no) successoert
+ xInterceptor->setSlaveDispatchProvider( NULL );
+
+ // start over with the next chain element
+ xInterceptor = xInterceptor.query( xSlave );
+ }
+
+ DisConnectFromDispatcher();
+ setRowSet(Reference< XRowSet > ());
+}
+
+// XContainer
+//------------------------------------------------------------------------------
+void FmXGridPeer::addContainerListener(const Reference< XContainerListener >& l) throw( RuntimeException )
+{
+ m_aContainerListeners.addInterface( l );
+}
+//------------------------------------------------------------------------------
+void FmXGridPeer::removeContainerListener(const Reference< XContainerListener >& l) throw( RuntimeException )
+{
+ m_aContainerListeners.removeInterface( l );
+}
+
+// ::com::sun::star::data::XDatabaseCursorSupplier
+//------------------------------------------------------------------------------
+void FmXGridPeer::startCursorListening()
+{
+ if (!m_nCursorListening)
+ {
+ Reference< XRowSet > xRowSet(m_xCursor, UNO_QUERY);
+ if (xRowSet.is())
+ xRowSet->addRowSetListener(this);
+
+ Reference< XReset > xReset(m_xCursor, UNO_QUERY);
+ if (xReset.is())
+ xReset->addResetListener(this);
+
+ // alle Listener anmelden
+ Reference< XPropertySet > xSet(m_xCursor, UNO_QUERY);
+ if (xSet.is())
+ {
+ xSet->addPropertyChangeListener(FM_PROP_ISMODIFIED, this);
+ xSet->addPropertyChangeListener(FM_PROP_ROWCOUNT, this);
+ }
+ }
+ m_nCursorListening++;
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::stopCursorListening()
+{
+ if (!--m_nCursorListening)
+ {
+ Reference< XRowSet > xRowSet(m_xCursor, UNO_QUERY);
+ if (xRowSet.is())
+ xRowSet->removeRowSetListener(this);
+
+ Reference< XReset > xReset(m_xCursor, UNO_QUERY);
+ if (xReset.is())
+ xReset->removeResetListener(this);
+
+ Reference< XPropertySet > xSet(m_xCursor, UNO_QUERY);
+ if (xSet.is())
+ {
+ xSet->removePropertyChangeListener(FM_PROP_ISMODIFIED, this);
+ xSet->removePropertyChangeListener(FM_PROP_ROWCOUNT, this);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::updateGrid(const Reference< XRowSet >& _rxCursor)
+{
+ FmGridControl* pGrid = (FmGridControl*)GetWindow();
+ if (pGrid)
+ pGrid->setDataSource(_rxCursor);
+}
+
+//------------------------------------------------------------------------------
+Reference< XRowSet > FmXGridPeer::getRowSet() throw( RuntimeException )
+{
+ return m_xCursor;
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::setRowSet(const Reference< XRowSet >& _rDatabaseCursor) throw( RuntimeException )
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if (!pGrid || !m_xColumns.is() || !m_xColumns->getCount())
+ return;
+ // alle Listener abmelden
+ if (m_xCursor.is())
+ {
+ Reference< XLoadable > xLoadable(m_xCursor, UNO_QUERY);
+ // only if the form is loaded we set the rowset
+ if (xLoadable.is())
+ {
+ stopCursorListening();
+ xLoadable->removeLoadListener(this);
+ }
+ }
+
+ m_xCursor = _rDatabaseCursor;
+
+ if (pGrid)
+ {
+ Reference< XLoadable > xLoadable(m_xCursor, UNO_QUERY);
+ // only if the form is loaded we set the rowset
+ if (xLoadable.is() && xLoadable->isLoaded())
+ pGrid->setDataSource(m_xCursor);
+ else
+ pGrid->setDataSource(Reference< XRowSet > ());
+
+ if (xLoadable.is())
+ {
+ startCursorListening();
+ xLoadable->addLoadListener(this);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridPeer::addGridControlListener( const Reference< XGridControlListener >& _listener ) throw( RuntimeException )
+{
+ m_aGridControlListeners.addInterface( _listener );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridPeer::removeGridControlListener( const Reference< XGridControlListener >& _listener ) throw( RuntimeException )
+{
+ m_aGridControlListeners.removeInterface( _listener );
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 FmXGridPeer::getCurrentColumnPosition() throw( RuntimeException )
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ return pGrid ? pGrid->GetViewColumnPos(pGrid->GetCurColumnId()) : -1;
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::setCurrentColumnPosition(sal_Int16 nPos) throw( RuntimeException )
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if (pGrid)
+ pGrid->GoToColumnId(pGrid->GetColumnIdFromViewPos(nPos));
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::selectionChanged(const EventObject& evt) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if (pGrid)
+ {
+ Reference< ::com::sun::star::view::XSelectionSupplier > xSelSupplier(evt.Source, UNO_QUERY);
+ Any aSelection = xSelSupplier->getSelection();
+ DBG_ASSERT(aSelection.getValueType().getTypeClass() == TypeClass_INTERFACE, "FmXGridPeer::selectionChanged : invalid selection !");
+ Reference< XPropertySet > xSelection;
+ aSelection >>= xSelection;
+ if (xSelection.is())
+ {
+ Reference< XPropertySet > xCol;
+ sal_Int32 i = 0;
+ sal_Int32 nColCount = m_xColumns->getCount();
+
+ for (; i < nColCount; ++i)
+ {
+ m_xColumns->getByIndex(i) >>= xCol;
+ if ( xCol == xSelection )
+ {
+ pGrid->markColumn(pGrid->GetColumnIdFromModelPos((sal_uInt16)i));
+ break;
+ }
+ }
+ // fuer das VCL-Control muessen die Columns 1-basiert sein
+ // die Selektion an das VCL-Control weiterreichen, wenn noetig
+ if ( i != pGrid->GetSelectedColumn() )
+ { // (wenn das nicht greift, wurde das selectionChanged implizit von dem Control selber ausgeloest
+ if ( i < nColCount )
+ {
+ pGrid->SelectColumnPos(pGrid->GetViewColumnPos(pGrid->GetColumnIdFromModelPos( (sal_uInt16)i )) + 1, sal_True);
+ // SelectColumnPos hat wieder zu einem impliziten ActivateCell gefuehrt
+ if (pGrid->IsEditing())
+ pGrid->DeactivateCell();
+ }
+ else
+ pGrid->SetNoSelection();
+ }
+ }
+ else
+ pGrid->markColumn(USHRT_MAX);
+ }
+}
+
+// XElementAccess
+//------------------------------------------------------------------------------
+sal_Bool FmXGridPeer::hasElements() throw( RuntimeException )
+{
+ return getCount() != 0;
+}
+
+//------------------------------------------------------------------------------
+Type SAL_CALL FmXGridPeer::getElementType( ) throw(RuntimeException)
+{
+ return ::getCppuType((Reference< ::com::sun::star::awt::XControl> *)NULL);
+}
+
+// XEnumerationAccess
+//------------------------------------------------------------------------------
+Reference< XEnumeration > FmXGridPeer::createEnumeration() throw( RuntimeException )
+{
+ return new ::comphelper::OEnumerationByIndex(this);
+}
+
+// XIndexAccess
+//------------------------------------------------------------------------------
+sal_Int32 FmXGridPeer::getCount() throw( RuntimeException )
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if (pGrid)
+ return pGrid->GetViewColCount();
+ else
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+Any FmXGridPeer::getByIndex(sal_Int32 _nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if (_nIndex < 0 ||
+ _nIndex >= getCount() || !pGrid)
+ throw IndexOutOfBoundsException();
+
+ Any aElement;
+ // get the columnid
+ sal_uInt16 nId = pGrid->GetColumnIdFromViewPos((sal_uInt16)_nIndex);
+ // get the list position
+ sal_uInt16 nPos = pGrid->GetModelColumnPos(nId);
+
+ DbGridColumn* pCol = pGrid->GetColumns().GetObject(nPos);
+// DBG_ASSERT(pCol && pCol->GetCell(), "FmXGridPeer::getByIndex(): Invalid cell");
+ Reference< ::com::sun::star::awt::XControl > xControl(pCol->GetCell());
+ aElement <<= xControl;
+
+ return aElement;
+}
+
+// ::com::sun::star::util::XModeSelector
+//------------------------------------------------------------------------------
+void FmXGridPeer::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException )
+{
+ if (!supportsMode(Mode))
+ throw NoSupportException();
+
+ if (Mode == m_aMode)
+ return;
+
+ m_aMode = Mode;
+
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if ( Mode == ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) )
+ pGrid->SetFilterMode(sal_True);
+ else
+ {
+ pGrid->SetFilterMode(sal_False);
+ pGrid->setDataSource(m_xCursor);
+ }
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString FmXGridPeer::getMode() throw( RuntimeException )
+{
+ return m_aMode;
+}
+
+//------------------------------------------------------------------------------
+::comphelper::StringSequence FmXGridPeer::getSupportedModes() throw( RuntimeException )
+{
+ static ::comphelper::StringSequence aModes;
+ if (!aModes.getLength())
+ {
+ aModes.realloc(2);
+ ::rtl::OUString* pModes = aModes.getArray();
+ pModes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) );
+ pModes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) );
+ }
+ return aModes;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmXGridPeer::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException )
+{
+ ::comphelper::StringSequence aModes(getSupportedModes());
+ const ::rtl::OUString* pModes = aModes.getConstArray();
+ for (sal_Int32 i = aModes.getLength(); i > 0; )
+ {
+ if (pModes[--i] == Mode)
+ return sal_True;
+ }
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::columnVisible(DbGridColumn* pColumn)
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+
+ sal_Int32 _nIndex = pGrid->GetModelColumnPos(pColumn->GetId());
+ Reference< ::com::sun::star::awt::XControl > xControl(pColumn->GetCell());
+ ContainerEvent aEvt;
+ aEvt.Source = (XContainer*)this;
+ aEvt.Accessor <<= _nIndex;
+ aEvt.Element <<= xControl;
+
+ m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvt );
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::columnHidden(DbGridColumn* pColumn)
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+
+ sal_Int32 _nIndex = pGrid->GetModelColumnPos(pColumn->GetId());
+ Reference< ::com::sun::star::awt::XControl > xControl(pColumn->GetCell());
+ ContainerEvent aEvt;
+ aEvt.Source = (XContainer*)this;
+ aEvt.Accessor <<= _nIndex;
+ aEvt.Element <<= xControl;
+
+ m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvt );
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::draw( sal_Int32 x, sal_Int32 y ) throw( RuntimeException )
+{
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ sal_Int32 nOldFlags = pGrid->GetBrowserFlags();
+ pGrid->SetBrowserFlags(nOldFlags | EBBF_NOROWPICTURE);
+
+ VCLXWindow::draw(x, y);
+
+ pGrid->SetBrowserFlags(nOldFlags);
+}
+
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::frame::XDispatch > FmXGridPeer::queryDispatch(const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::frame::XDispatch > xResult;
+
+ // first ask our interceptor chain
+ if (m_xFirstDispatchInterceptor.is() && !m_bInterceptingDispatch)
+ {
+ m_bInterceptingDispatch = sal_True;
+ // safety against recursion : as we are master of the first chain element and slave of the last one we would
+ // have an infinite loop without this if no dispatcher can fullfill the rewuest)
+ xResult = m_xFirstDispatchInterceptor->queryDispatch(aURL, aTargetFrameName, nSearchFlags);
+ m_bInterceptingDispatch = sal_False;
+ }
+
+ // then ask ourself : we don't have any dispatches
+ return xResult;
+}
+
+//------------------------------------------------------------------------------
+Sequence< Reference< ::com::sun::star::frame::XDispatch > > FmXGridPeer::queryDispatches(const Sequence< ::com::sun::star::frame::DispatchDescriptor>& aDescripts) throw( RuntimeException )
+{
+ if (m_xFirstDispatchInterceptor.is())
+ return m_xFirstDispatchInterceptor->queryDispatches(aDescripts);
+
+ // then ask ourself : we don't have any dispatches
+ return Sequence< Reference< ::com::sun::star::frame::XDispatch > >();
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::registerDispatchProviderInterceptor(const Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& _xInterceptor) throw( RuntimeException )
+{
+ if (_xInterceptor.is())
+ {
+ if (m_xFirstDispatchInterceptor.is())
+ {
+ Reference< ::com::sun::star::frame::XDispatchProvider > xFirstProvider(m_xFirstDispatchInterceptor, UNO_QUERY);
+ // there is already an interceptor; the new one will become its master
+ _xInterceptor->setSlaveDispatchProvider(xFirstProvider);
+ m_xFirstDispatchInterceptor->setMasterDispatchProvider(xFirstProvider);
+ }
+ else
+ {
+ // it is the first interceptor; set ourself as slave
+ _xInterceptor->setSlaveDispatchProvider((::com::sun::star::frame::XDispatchProvider*)this);
+ }
+
+ // we are the master of the chain's first interceptor
+ m_xFirstDispatchInterceptor = _xInterceptor;
+ m_xFirstDispatchInterceptor->setMasterDispatchProvider((::com::sun::star::frame::XDispatchProvider*)this);
+
+ // we have a new interceptor and we're alive ?
+ if (!isDesignMode())
+ // -> check for new dispatchers
+ UpdateDispatches();
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::releaseDispatchProviderInterceptor(const Reference< ::com::sun::star::frame::XDispatchProviderInterceptor >& _xInterceptor) throw( RuntimeException )
+{
+ if (!_xInterceptor.is())
+ return;
+
+ Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > xChainWalk(m_xFirstDispatchInterceptor);
+
+ if (m_xFirstDispatchInterceptor == _xInterceptor)
+ { // our chain will have a new first element
+ Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > xSlave(m_xFirstDispatchInterceptor->getSlaveDispatchProvider(), UNO_QUERY);
+ m_xFirstDispatchInterceptor = xSlave;
+ }
+ // do this before removing the interceptor from the chain as we won't know it's slave afterwards)
+
+ while (xChainWalk.is())
+ {
+ // walk along the chain of interceptors and look for the interceptor that has to be removed
+ Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > xSlave(xChainWalk->getSlaveDispatchProvider(), UNO_QUERY);
+
+ if (xChainWalk == _xInterceptor)
+ {
+ // old master may be an interceptor too
+ Reference< ::com::sun::star::frame::XDispatchProviderInterceptor > xMaster(xChainWalk->getMasterDispatchProvider(), UNO_QUERY);
+
+ // unchain the interceptor that has to be removed
+ xChainWalk->setSlaveDispatchProvider(Reference< ::com::sun::star::frame::XDispatchProvider > ());
+ xChainWalk->setMasterDispatchProvider(Reference< ::com::sun::star::frame::XDispatchProvider > ());
+
+ // reconnect the chain
+ if (xMaster.is())
+ {
+ if (xSlave.is())
+ xMaster->setSlaveDispatchProvider(Reference< ::com::sun::star::frame::XDispatchProvider >::query(xSlave));
+ else
+ // it's the first interceptor of the chain, set ourself as slave
+ xMaster->setSlaveDispatchProvider((::com::sun::star::frame::XDispatchProvider*)this);
+ }
+ else
+ {
+ // the chain's first element was removed, set ourself as new master of the second one
+ if (xSlave.is())
+ xSlave->setMasterDispatchProvider((::com::sun::star::frame::XDispatchProvider*)this);
+ }
+ }
+
+ xChainWalk = xSlave;
+ }
+ // our interceptor chain has changed and we're alive ?
+ if (!isDesignMode())
+ // -> check the dispatchers
+ UpdateDispatches();
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) throw( RuntimeException )
+{
+ DBG_ASSERT(m_pStateCache, "FmXGridPeer::statusChanged : invalid call !");
+ DBG_ASSERT(m_pDispatchers, "FmXGridPeer::statusChanged : invalid call !");
+
+ Sequence< ::com::sun::star::util::URL>& aUrls = getSupportedURLs();
+ const ::com::sun::star::util::URL* pUrls = aUrls.getConstArray();
+
+ Sequence<sal_uInt16> aSlots = getSupportedGridSlots();
+ const sal_uInt16* pSlots = aSlots.getConstArray();
+
+ sal_uInt16 i;
+ for (i=0; i<aUrls.getLength(); ++i, ++pUrls, ++pSlots)
+ {
+ if (pUrls->Main == Event.FeatureURL.Main)
+ {
+ DBG_ASSERT(m_pDispatchers[i] == Event.Source, "FmXGridPeer::statusChanged : the event source is a little bit suspect !");
+ m_pStateCache[i] = Event.IsEnabled;
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if (*pSlots != SID_FM_RECORD_UNDO)
+ pGrid->GetNavigationBar().InvalidateState(*pSlots);
+ break;
+ }
+ }
+ DBG_ASSERT(i<aUrls.getLength(), "FmXGridPeer::statusChanged : got a call for an unknown url !");
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmXGridPeer::approveReset(const EventObject& /*rEvent*/) throw( RuntimeException )
+{
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FmXGridPeer::select( const Any& _rSelection ) throw (IllegalArgumentException, RuntimeException)
+{
+ Sequence< Any > aBookmarks;
+ if ( !( _rSelection >>= aBookmarks ) )
+ throw IllegalArgumentException();
+
+ FmGridControl* pVclControl = static_cast<FmGridControl*>(GetWindow());
+ return pVclControl->selectBookmarks(aBookmarks);
+
+ // TODO:
+ // speaking strictly, we would have to adjust our model, as our ColumnSelection may have changed.
+ // Our model is a XSelectionSupplier, too, it handles the selection of single columns.
+ // This is somewhat strange, as selection should be a view (not a model) aspect.
+ // So for a clean solution, we should handle column selection ourself, and the model shouldn't
+ // deal with selection at all.
+}
+
+//------------------------------------------------------------------------------
+Any SAL_CALL FmXGridPeer::getSelection( ) throw (RuntimeException)
+{
+ FmGridControl* pVclControl = static_cast<FmGridControl*>(GetWindow());
+ Sequence< Any > aSelectionBookmarks = pVclControl->getSelectionBookmarks();
+ return makeAny(aSelectionBookmarks);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridPeer::addSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aSelectionListeners.addInterface( _rxListener );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXGridPeer::removeSelectionChangeListener( const Reference< XSelectionChangeListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aSelectionListeners.removeInterface( _rxListener );
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::resetted(const EventObject& rEvent) throw( RuntimeException )
+{
+ if (m_xColumns == rEvent.Source)
+ { // my model was reset -> refresh the grid content
+ FmGridControl* pGrid = (FmGridControl*)GetWindow();
+ if (!pGrid)
+ return;
+ SolarMutexGuard aGuard;
+ pGrid->resetCurrentRow();
+ }
+ // if the cursor fired a reset event we seem to be on the insert row
+ else if (m_xCursor == rEvent.Source)
+ {
+ SolarMutexGuard aGuard;
+ FmGridControl* pGrid = (FmGridControl*) GetWindow();
+ if (pGrid && pGrid->IsOpen())
+ pGrid->positioned(rEvent);
+ }
+}
+
+//------------------------------------------------------------------------------
+Sequence<sal_uInt16>& FmXGridPeer::getSupportedGridSlots()
+{
+ static Sequence<sal_uInt16> aSupported;
+ if (aSupported.getLength() == 0)
+ {
+ sal_uInt16 nSupported[] = {
+ DbGridControl::NavigationBar::RECORD_FIRST,
+ DbGridControl::NavigationBar::RECORD_PREV,
+ DbGridControl::NavigationBar::RECORD_NEXT,
+ DbGridControl::NavigationBar::RECORD_LAST,
+ DbGridControl::NavigationBar::RECORD_NEW,
+ SID_FM_RECORD_UNDO
+ };
+ aSupported.realloc(SAL_N_ELEMENTS(nSupported));
+ sal_uInt16* pSupported = aSupported.getArray();
+ for (sal_uInt16 i=0; i<aSupported.getLength(); ++i, ++pSupported)
+ *pSupported = nSupported[i];
+ }
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::com::sun::star::util::URL>& FmXGridPeer::getSupportedURLs()
+{
+ static Sequence< ::com::sun::star::util::URL> aSupported;
+ if (aSupported.getLength() == 0)
+ {
+ static ::rtl::OUString sSupported[] = {
+ FMURL_RECORD_MOVEFIRST,
+ FMURL_RECORD_MOVEPREV,
+ FMURL_RECORD_MOVENEXT,
+ FMURL_RECORD_MOVELAST,
+ FMURL_RECORD_MOVETONEW,
+ FMURL_RECORD_UNDO
+ };
+ aSupported.realloc(SAL_N_ELEMENTS(sSupported));
+ ::com::sun::star::util::URL* pSupported = aSupported.getArray();
+ sal_uInt16 i;
+
+ for ( i = 0; i < aSupported.getLength(); ++i, ++pSupported)
+ pSupported->Complete = sSupported[i];
+
+ // let an ::com::sun::star::util::URL-transformer normalize the URLs
+ Reference< ::com::sun::star::util::XURLTransformer > xTransformer(
+ ::comphelper::getProcessServiceFactory()->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer")),
+ UNO_QUERY);
+ pSupported = aSupported.getArray();
+ if (xTransformer.is())
+ {
+ for (i=0; i<aSupported.getLength(); ++i)
+ xTransformer->parseStrict(pSupported[i]);
+ }
+ }
+
+ return aSupported;
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::UpdateDispatches()
+{
+ if (!m_pStateCache)
+ { // we don't have any dispatchers yet -> do the initial connect
+ ConnectToDispatcher();
+ return;
+ }
+
+ sal_uInt16 nDispatchersGot = 0;
+ const Sequence< ::com::sun::star::util::URL>& aSupportedURLs = getSupportedURLs();
+ const ::com::sun::star::util::URL* pSupportedURLs = aSupportedURLs.getConstArray();
+ Reference< ::com::sun::star::frame::XDispatch > xNewDispatch;
+ for (sal_uInt16 i=0; i<aSupportedURLs.getLength(); ++i, ++pSupportedURLs)
+ {
+ xNewDispatch = queryDispatch(*pSupportedURLs, rtl::OUString(), 0);
+ if (xNewDispatch != m_pDispatchers[i])
+ {
+ if (m_pDispatchers[i].is())
+ m_pDispatchers[i]->removeStatusListener((::com::sun::star::frame::XStatusListener*)this, *pSupportedURLs);
+ m_pDispatchers[i] = xNewDispatch;
+ if (m_pDispatchers[i].is())
+ m_pDispatchers[i]->addStatusListener((::com::sun::star::frame::XStatusListener*)this, *pSupportedURLs);
+ }
+ if (m_pDispatchers[i].is())
+ ++nDispatchersGot;
+ }
+
+ if (!nDispatchersGot)
+ {
+ delete[] m_pStateCache;
+ delete[] m_pDispatchers;
+ m_pStateCache = NULL;
+ m_pDispatchers = NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::ConnectToDispatcher()
+{
+ DBG_ASSERT((m_pStateCache != NULL) == (m_pDispatchers != NULL), "FmXGridPeer::ConnectToDispatcher : inconsistent !");
+ if (m_pStateCache)
+ { // already connected -> just do an update
+ UpdateDispatches();
+ return;
+ }
+
+ const Sequence< ::com::sun::star::util::URL>& aSupportedURLs = getSupportedURLs();
+
+ // _before_ adding the status listeners (as the add should result in a statusChanged-call) !
+ m_pStateCache = new sal_Bool[aSupportedURLs.getLength()];
+ m_pDispatchers = new Reference< ::com::sun::star::frame::XDispatch > [aSupportedURLs.getLength()];
+
+ sal_uInt16 nDispatchersGot = 0;
+ const ::com::sun::star::util::URL* pSupportedURLs = aSupportedURLs.getConstArray();
+ for (sal_uInt16 i=0; i<aSupportedURLs.getLength(); ++i, ++pSupportedURLs)
+ {
+ m_pStateCache[i] = 0;
+ m_pDispatchers[i] = queryDispatch(*pSupportedURLs, rtl::OUString(), 0);
+ if (m_pDispatchers[i].is())
+ {
+ m_pDispatchers[i]->addStatusListener((::com::sun::star::frame::XStatusListener*)this, *pSupportedURLs);
+ ++nDispatchersGot;
+ }
+ }
+
+ if (!nDispatchersGot)
+ {
+ delete[] m_pStateCache;
+ delete[] m_pDispatchers;
+ m_pStateCache = NULL;
+ m_pDispatchers = NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXGridPeer::DisConnectFromDispatcher()
+{
+ if (!m_pStateCache || !m_pDispatchers)
+ return;
+ // we're not connected
+
+ const Sequence< ::com::sun::star::util::URL>& aSupportedURLs = getSupportedURLs();
+ const ::com::sun::star::util::URL* pSupportedURLs = aSupportedURLs.getConstArray();
+ for (sal_uInt16 i=0; i<aSupportedURLs.getLength(); ++i, ++pSupportedURLs)
+ {
+ if (m_pDispatchers[i].is())
+ m_pDispatchers[i]->removeStatusListener((::com::sun::star::frame::XStatusListener*)this, *pSupportedURLs);
+ }
+
+ delete[] m_pStateCache;
+ delete[] m_pDispatchers;
+ m_pStateCache = NULL;
+ m_pDispatchers = NULL;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FmXGridPeer, OnQueryGridSlotState, void*, pSlot)
+{
+ if (!m_pStateCache)
+ return -1; // unspecified
+
+ sal_uInt16 nSlot = (sal_uInt16)(sal_uIntPtr)pSlot;
+
+ // search the given slot with our supported sequence
+ Sequence<sal_uInt16>& aSupported = getSupportedGridSlots();
+ const sal_uInt16* pSlots = aSupported.getConstArray();
+ for (sal_uInt16 i=0; i<aSupported.getLength(); ++i)
+ {
+ if (pSlots[i] == nSlot)
+ {
+ if (!m_pDispatchers[i].is())
+ return -1; // nothing known about this slot
+ else
+ return m_pStateCache[i];
+ }
+ }
+
+ return -1;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FmXGridPeer, OnExecuteGridSlot, void*, pSlot)
+{
+ if (!m_pDispatchers)
+ return 0; // not handled
+
+ Sequence< ::com::sun::star::util::URL>& aUrls = getSupportedURLs();
+ const ::com::sun::star::util::URL* pUrls = aUrls.getConstArray();
+
+ Sequence<sal_uInt16> aSlots = getSupportedGridSlots();
+ const sal_uInt16* pSlots = aSlots.getConstArray();
+
+ DBG_ASSERT(aSlots.getLength() == aUrls.getLength(), "FmXGridPeer::OnExecuteGridSlot : inconstent data returned by getSupportedURLs/getSupportedGridSlots !");
+
+ sal_uInt16 nSlot = (sal_uInt16)(sal_uIntPtr)pSlot;
+ for (sal_uInt16 i=0; i<aSlots.getLength(); ++i, ++pUrls, ++pSlots)
+ {
+ if (*pSlots == nSlot)
+ {
+ if (m_pDispatchers[i].is())
+ {
+ // commit any changes done so far, if it's not the undoRecord URL
+ if ( 0 == pUrls->Complete.compareTo( FMURL_RECORD_UNDO ) || commit() )
+ m_pDispatchers[i]->dispatch(*pUrls, Sequence< PropertyValue>());
+
+ return 1; // handled
+ }
+ }
+ }
+
+ return 0; // not handled
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
new file mode 100644
index 000000000000..3abf290269c1
--- /dev/null
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -0,0 +1,4842 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+#include "fmprop.hrc"
+#include "fmresids.hrc"
+#include "svx/fmtools.hxx"
+#include "gridcell.hxx"
+#include "gridcols.hxx"
+#include "sdbdatacolumn.hxx"
+
+#include <com/sun/star/awt/LineEndFormat.hpp>
+#include <com/sun/star/awt/MouseWheelBehavior.hpp>
+#include <com/sun/star/awt/VisualEffect.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/XBoundComponent.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XStatement.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+
+#include <comphelper/extract.hxx>
+#include <comphelper/numbers.hxx>
+#include <comphelper/property.hxx>
+#include <connectivity/formattedcolumnvalue.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <i18npool/lang.h>
+
+#include <rtl/math.hxx>
+#include <svtools/calendar.hxx>
+#include <svtools/fmtfield.hxx>
+#include <svl/numuno.hxx>
+#include <svtools/svmedit.hxx>
+#include <svx/dialmgr.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/shl.hxx>
+#include <vcl/longcurr.hxx>
+
+#include <math.h>
+#include <stdio.h>
+
+using namespace ::connectivity;
+using namespace ::connectivity::simple;
+using namespace ::svxform;
+using namespace ::comphelper;
+using namespace ::svt;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::form;
+
+using ::com::sun::star::util::XNumberFormatter;
+namespace MouseWheelBehavior = ::com::sun::star::awt::MouseWheelBehavior;
+
+String INVALIDTEXT = String::CreateFromAscii("###");
+String OBJECTTEXT = String::CreateFromAscii("<OBJECT>");
+ // TODO: resource
+
+//==================================================================
+//= helper
+//==================================================================
+namespace
+{
+ static LineEnd getModelLineEndSetting( const Reference< XPropertySet >& _rxModel )
+ {
+ LineEnd eFormat = LINEEND_LF;
+
+ try
+ {
+ sal_Int16 nLineEndFormat = awt::LineEndFormat::LINE_FEED;
+
+ Reference< XPropertySetInfo > xPSI;
+ if ( _rxModel.is() )
+ xPSI = _rxModel->getPropertySetInfo();
+
+ OSL_ENSURE( xPSI.is(), "getModelLineEndSetting: invalid column model!" );
+ if ( xPSI.is() && xPSI->hasPropertyByName( FM_PROP_LINEENDFORMAT ) )
+ {
+ OSL_VERIFY( _rxModel->getPropertyValue( FM_PROP_LINEENDFORMAT ) >>= nLineEndFormat );
+
+ switch ( nLineEndFormat )
+ {
+ case awt::LineEndFormat::CARRIAGE_RETURN: eFormat = LINEEND_CR; break;
+ case awt::LineEndFormat::LINE_FEED: eFormat = LINEEND_LF; break;
+ case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED: eFormat = LINEEND_CRLF; break;
+ default:
+ OSL_ENSURE( sal_False, "getModelLineEndSetting: what's this?" );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "getModelLineEndSetting: caught an exception!" );
+ }
+ return eFormat;
+ }
+}
+
+//==================================================================
+//= DbGridColumn
+//==================================================================
+//------------------------------------------------------------------------------
+CellControllerRef DbGridColumn::s_xEmptyController;
+
+//------------------------------------------------------------------------------
+void DbGridColumn::CreateControl(sal_Int32 _nFieldPos, const Reference< ::com::sun::star::beans::XPropertySet >& xField, sal_Int32 nTypeId)
+{
+ Clear();
+
+ m_nTypeId = (sal_Int16)nTypeId;
+ if (xField != m_xField)
+ {
+ // Grundeinstellung
+ m_xField = xField;
+ xField->getPropertyValue(FM_PROP_FORMATKEY) >>= m_nFormatKey;
+ m_nFieldPos = (sal_Int16)_nFieldPos;
+ m_bReadOnly = ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_ISREADONLY));
+ m_bAutoValue = ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_AUTOINCREMENT));
+ m_nFieldType = (sal_Int16)::comphelper::getINT32(xField->getPropertyValue(FM_PROP_FIELDTYPE));
+
+ switch (m_nFieldType)
+ {
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ m_bDateTime = sal_True;
+
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::BIGINT:
+ case DataType::FLOAT:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ m_nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
+ m_bNumeric = sal_True;
+ break;
+ default:
+ m_nAlign = ::com::sun::star::awt::TextAlign::LEFT;
+ break;
+ }
+ }
+
+ DbCellControl* pCellControl = NULL;
+ if (m_rParent.IsFilterMode())
+ {
+ pCellControl = new DbFilterField(m_rParent.getServiceManager(),*this);
+ }
+ else
+ {
+
+ switch (nTypeId)
+ {
+ case TYPE_CHECKBOX: pCellControl = new DbCheckBox(*this); break;
+ case TYPE_COMBOBOX: pCellControl = new DbComboBox(*this); break;
+ case TYPE_CURRENCYFIELD: pCellControl = new DbCurrencyField(*this); break;
+ case TYPE_DATEFIELD: pCellControl = new DbDateField(*this); break;
+ case TYPE_LISTBOX: pCellControl = new DbListBox(*this); break;
+ case TYPE_NUMERICFIELD: pCellControl = new DbNumericField(*this); break;
+ case TYPE_PATTERNFIELD: pCellControl = new DbPatternField( *this, ::comphelper::ComponentContext( m_rParent.getServiceManager() ) ); break;
+ case TYPE_TEXTFIELD: pCellControl = new DbTextField(*this); break;
+ case TYPE_TIMEFIELD: pCellControl = new DbTimeField(*this); break;
+ case TYPE_FORMATTEDFIELD: pCellControl = new DbFormattedField(*this); break;
+ default:
+ DBG_ERROR("DbGridColumn::CreateControl: Unknown Column");
+ return;
+ }
+
+ }
+ Reference< XRowSet > xCur;
+ if (m_rParent.getDataSource())
+ xCur = Reference< XRowSet > ((Reference< XInterface >)*m_rParent.getDataSource(), UNO_QUERY);
+ // TODO : the cursor wrapper should use an XRowSet interface, too
+
+ pCellControl->Init( m_rParent.GetDataWindow(), xCur );
+
+ // now create the control wrapper
+ if (m_rParent.IsFilterMode())
+ m_pCell = new FmXFilterCell(this, pCellControl);
+ else
+ {
+ switch (nTypeId)
+ {
+ case TYPE_CHECKBOX: m_pCell = new FmXCheckBoxCell( this, *pCellControl ); break;
+ case TYPE_LISTBOX: m_pCell = new FmXListBoxCell( this, *pCellControl ); break;
+ case TYPE_COMBOBOX: m_pCell = new FmXComboBoxCell( this, *pCellControl ); break;
+ default:
+ m_pCell = new FmXEditCell( this, *pCellControl );
+ }
+ }
+ m_pCell->acquire();
+ m_pCell->init();
+
+ impl_toggleScriptManager_nothrow( true );
+
+ // only if we use have a bound field, we use a a controller for displaying the
+ // window in the grid
+ if (m_xField.is())
+ m_xController = pCellControl->CreateController();
+}
+
+//------------------------------------------------------------------------------
+void DbGridColumn::impl_toggleScriptManager_nothrow( bool _bAttach )
+{
+ try
+ {
+ Reference< container::XChild > xChild( m_xModel, UNO_QUERY_THROW );
+ Reference< script::XEventAttacherManager > xManager( xChild->getParent(), UNO_QUERY_THROW );
+ Reference< container::XIndexAccess > xContainer( xChild->getParent(), UNO_QUERY_THROW );
+
+ sal_Int32 nIndexInParent( getElementPos( xContainer, m_xModel ) );
+
+ Reference< XInterface > xCellInterface( *m_pCell, UNO_QUERY );
+ if ( _bAttach )
+ xManager->attach( nIndexInParent, xCellInterface, makeAny( xCellInterface ) );
+ else
+ xManager->detach( nIndexInParent, xCellInterface );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridColumn::UpdateFromField(const DbGridRow* pRow, const Reference< XNumberFormatter >& xFormatter)
+{
+ if (m_pCell && m_pCell->ISA(FmXFilterCell))
+ PTR_CAST(FmXFilterCell, m_pCell)->Update();
+ else if (pRow && pRow->IsValid() && m_nFieldPos >= 0 && m_pCell && pRow->HasField(m_nFieldPos))
+ {
+ PTR_CAST(FmXDataCell, m_pCell)->UpdateFromField( pRow->GetField( m_nFieldPos ).getColumn(), xFormatter );
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridColumn::Commit()
+{
+ sal_Bool bResult = sal_True;
+ if (!m_bInSave && m_pCell)
+ {
+ m_bInSave = sal_True;
+ bResult = m_pCell->Commit();
+
+ // store the data into the model
+ FmXDataCell* pDataCell = PTR_CAST(FmXDataCell, m_pCell);
+ if (bResult && pDataCell)
+ {
+ Reference< ::com::sun::star::form::XBoundComponent > xComp(m_xModel, UNO_QUERY);
+ if (xComp.is())
+ bResult = xComp->commit();
+ }
+ m_bInSave = sal_False;
+ }
+ return bResult;
+}
+
+//------------------------------------------------------------------------------
+DbGridColumn::~DbGridColumn()
+{
+ Clear();
+}
+
+//------------------------------------------------------------------------------
+void DbGridColumn::setModel(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xModel)
+{
+ if ( m_pCell )
+ impl_toggleScriptManager_nothrow( false );
+
+ m_xModel = _xModel;
+
+ if ( m_pCell )
+ impl_toggleScriptManager_nothrow( true );
+}
+
+//------------------------------------------------------------------------------
+void DbGridColumn::Clear()
+{
+ if ( m_pCell )
+ {
+ impl_toggleScriptManager_nothrow( false );
+
+ m_pCell->dispose();
+ m_pCell->release();
+ m_pCell = NULL;
+ }
+
+ m_xController = NULL;
+ m_xField = NULL;
+
+ m_nFormatKey = 0;
+ m_nFieldPos = -1;
+ m_bReadOnly = sal_True;
+ m_bAutoValue = sal_False;
+ m_nFieldType = DataType::OTHER;
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 DbGridColumn::SetAlignment(sal_Int16 _nAlign)
+{
+ if (_nAlign == -1)
+ { // 'Standard'
+ if (m_xField.is())
+ {
+ sal_Int32 nType = 0;
+ m_xField->getPropertyValue(FM_PROP_FIELDTYPE) >>= nType;
+
+ switch (nType)
+ {
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ case DataType::BIGINT:
+ case DataType::INTEGER:
+ case DataType::SMALLINT:
+ case DataType::TINYINT:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ _nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ _nAlign = ::com::sun::star::awt::TextAlign::CENTER;
+ break;
+ default:
+ _nAlign = ::com::sun::star::awt::TextAlign::LEFT;
+ break;
+ }
+ }
+ else
+ _nAlign = ::com::sun::star::awt::TextAlign::LEFT;
+ }
+
+ m_nAlign = _nAlign;
+ if (m_pCell && m_pCell->isAlignedController())
+ m_pCell->AlignControl(m_nAlign);
+
+ return m_nAlign;
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 DbGridColumn::SetAlignmentFromModel(sal_Int16 nStandardAlign)
+{
+ Any aAlign( m_xModel->getPropertyValue(FM_PROP_ALIGN));
+ if (aAlign.hasValue())
+ {
+ sal_Int16 nTest = sal_Int16();
+ if (aAlign >>= nTest)
+ nStandardAlign = nTest;
+ }
+ return SetAlignment(nStandardAlign);
+}
+
+//------------------------------------------------------------------------------
+void DbGridColumn::setLock(sal_Bool _bLock)
+{
+ if (m_bLocked == _bLock)
+ return;
+ m_bLocked = _bLock;
+
+ // is the column we represent active ?
+ if (m_bHidden)
+ return; // no, it isn't (or at least it shouldn't be ...)
+
+ if (m_rParent.GetCurColumnId() == m_nId)
+ {
+ m_rParent.DeactivateCell();
+ m_rParent.ActivateCell(m_rParent.GetCurRow(), m_rParent.GetCurColumnId());
+ }
+}
+
+//------------------------------------------------------------------------------
+String DbGridColumn::GetCellText(const DbGridRow* pRow, const Reference< XNumberFormatter >& xFormatter) const
+{
+ String aText;
+ if (m_pCell && m_pCell->ISA(FmXFilterCell))
+ return aText;
+
+ if (!pRow || !pRow->IsValid())
+ aText = INVALIDTEXT;
+ else if (pRow->HasField(m_nFieldPos))
+ {
+ aText = GetCellText( pRow->GetField( m_nFieldPos ).getColumn(), xFormatter );
+ }
+ return aText;
+}
+
+//------------------------------------------------------------------------------
+String DbGridColumn::GetCellText(const Reference< ::com::sun::star::sdb::XColumn >& xField, const Reference< XNumberFormatter >& xFormatter) const
+{
+ String aText;
+ if (xField.is())
+ {
+ FmXTextCell* pTextCell = PTR_CAST(FmXTextCell, m_pCell);
+ if (pTextCell)
+ aText = pTextCell->GetText(xField, xFormatter);
+ else if (m_bObject)
+ aText = OBJECTTEXT;
+ }
+ return aText;
+}
+
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::sdb::XColumn > DbGridColumn::GetCurrentFieldValue() const
+{
+ Reference< ::com::sun::star::sdb::XColumn > xField;
+ const DbGridRowRef xRow = m_rParent.GetCurrentRow();
+ if (xRow.Is() && xRow->HasField(m_nFieldPos))
+ {
+ xField = xRow->GetField(m_nFieldPos).getColumn();
+ }
+ return xField;
+}
+
+//------------------------------------------------------------------------------
+void DbGridColumn::Paint(OutputDevice& rDev,
+ const Rectangle& rRect,
+ const DbGridRow* pRow,
+ const Reference< XNumberFormatter >& xFormatter)
+{
+ bool bEnabled = ( rDev.GetOutDevType() != OUTDEV_WINDOW )
+ || ( static_cast< Window& >( rDev ).IsEnabled() );
+
+ FmXDataCell* pDataCell = PTR_CAST(FmXDataCell, m_pCell);
+ if (pDataCell)
+ {
+ if (!pRow || !pRow->IsValid())
+ {
+ sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_CENTER;
+ if ( !bEnabled )
+ nStyle |= TEXT_DRAW_DISABLE;
+
+ rDev.DrawText(rRect, INVALIDTEXT, nStyle);
+ }
+ else if (m_bAutoValue && pRow->IsNew())
+ {
+ static String aAutoText(SVX_RES(RID_STR_AUTOFIELD));
+ sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_VCENTER;
+ if ( !bEnabled )
+ nStyle |= TEXT_DRAW_DISABLE;
+
+ switch (GetAlignment())
+ {
+ case ::com::sun::star::awt::TextAlign::RIGHT:
+ nStyle |= TEXT_DRAW_RIGHT;
+ break;
+ case ::com::sun::star::awt::TextAlign::CENTER:
+ nStyle |= TEXT_DRAW_CENTER;
+ break;
+ default:
+ nStyle |= TEXT_DRAW_LEFT;
+ }
+
+ rDev.DrawText(rRect, aAutoText , nStyle);
+ }
+ else if (pRow->HasField(m_nFieldPos))
+ {
+ pDataCell->PaintFieldToCell(rDev, rRect, pRow->GetField( m_nFieldPos ).getColumn(), xFormatter);
+ }
+ }
+ else if (!m_pCell)
+ {
+ if (!pRow || !pRow->IsValid())
+ {
+ sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_CENTER;
+ if ( !bEnabled )
+ nStyle |= TEXT_DRAW_DISABLE;
+
+ rDev.DrawText(rRect, INVALIDTEXT, nStyle);
+ }
+ else if (pRow->HasField(m_nFieldPos) && m_bObject)
+ {
+ sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_CENTER;
+ if ( !bEnabled )
+ nStyle |= TEXT_DRAW_DISABLE;
+ rDev.DrawText(rRect, OBJECTTEXT, nStyle);
+ }
+ }
+ else if ( m_pCell->ISA( FmXFilterCell ) )
+ static_cast< FmXFilterCell* >( m_pCell )->PaintCell( rDev, rRect );
+}
+
+//------------------------------------------------------------------------------
+void DbGridColumn::ImplInitWindow( Window& rParent, const InitWindowFacet _eInitWhat )
+{
+ if ( m_pCell )
+ m_pCell->ImplInitWindow( rParent, _eInitWhat );
+}
+
+//==============================================================================
+//= cell controls
+//==============================================================================
+TYPEINIT0( DbCellControl )
+TYPEINIT1( DbLimitedLengthField, DbCellControl )
+TYPEINIT1( DbTextField, DbLimitedLengthField )
+TYPEINIT1( DbFormattedField, DbLimitedLengthField )
+TYPEINIT1( DbCheckBox, DbCellControl )
+TYPEINIT1( DbComboBox, DbCellControl )
+TYPEINIT1( DbListBox, DbCellControl )
+TYPEINIT1( DbPatternField, DbCellControl )
+TYPEINIT1( DbSpinField, DbCellControl )
+TYPEINIT1( DbDateField, DbSpinField )
+TYPEINIT1( DbTimeField, DbSpinField )
+TYPEINIT1( DbCurrencyField, DbSpinField )
+TYPEINIT1( DbNumericField, DbSpinField )
+TYPEINIT1( DbFilterField, DbCellControl )
+
+//------------------------------------------------------------------------------
+DbCellControl::DbCellControl( DbGridColumn& _rColumn, sal_Bool /*_bText*/ )
+ :OPropertyChangeListener(m_aMutex)
+ ,m_pFieldChangeBroadcaster(NULL)
+ ,m_bTransparent( sal_False )
+ ,m_bAlignedController( sal_True )
+ ,m_bAccessingValueProperty( sal_False )
+ ,m_rColumn( _rColumn )
+ ,m_pPainter( NULL )
+ ,m_pWindow( NULL )
+{
+ Reference< XPropertySet > xColModelProps( _rColumn.getModel(), UNO_QUERY );
+ if ( xColModelProps.is() )
+ {
+ // if our model's format key changes we want to propagate the new value to our windows
+ m_pModelChangeBroadcaster = new ::comphelper::OPropertyChangeMultiplexer(this, Reference< ::com::sun::star::beans::XPropertySet > (_rColumn.getModel(), UNO_QUERY));
+ m_pModelChangeBroadcaster->acquire();
+
+ // be listener for some common properties
+ implDoPropertyListening( FM_PROP_READONLY, sal_False );
+ implDoPropertyListening( FM_PROP_ENABLED, sal_False );
+
+ // add as listener for all know "value" properties
+ implDoPropertyListening( FM_PROP_VALUE, sal_False );
+ implDoPropertyListening( FM_PROP_STATE, sal_False );
+ implDoPropertyListening( FM_PROP_TEXT, sal_False );
+ implDoPropertyListening( FM_PROP_EFFECTIVE_VALUE, sal_False );
+
+ // be listener at the bound field as well
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( xColModelProps->getPropertySetInfo(), UNO_SET_THROW );
+ if ( xPSI->hasPropertyByName( FM_PROP_BOUNDFIELD ) )
+ {
+ Reference< XPropertySet > xField;
+ xColModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ) >>= xField;
+ if ( xField.is() )
+ {
+ m_pFieldChangeBroadcaster = new ::comphelper::OPropertyChangeMultiplexer(this, xField);
+ m_pFieldChangeBroadcaster->acquire();
+ m_pFieldChangeBroadcaster->addProperty( FM_PROP_ISREADONLY );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "DbCellControl::doPropertyListening: caught an exception!" );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::implDoPropertyListening( const ::rtl::OUString& _rPropertyName, sal_Bool _bWarnIfNotExistent )
+{
+ try
+ {
+ Reference< XPropertySet > xColModelProps( m_rColumn.getModel(), UNO_QUERY );
+ Reference< XPropertySetInfo > xPSI;
+ if ( xColModelProps.is() )
+ xPSI = xColModelProps->getPropertySetInfo();
+
+ DBG_ASSERT( !_bWarnIfNotExistent || ( xPSI.is() && xPSI->hasPropertyByName( _rPropertyName ) ),
+ "DbCellControl::doPropertyListening: no property set info or non-existent property!" );
+ (void)_bWarnIfNotExistent;
+
+ if ( xPSI.is() && xPSI->hasPropertyByName( _rPropertyName ) )
+ m_pModelChangeBroadcaster->addProperty( _rPropertyName );
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "DbCellControl::doPropertyListening: caught an exception!" );
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::doPropertyListening( const ::rtl::OUString& _rPropertyName )
+{
+ implDoPropertyListening( _rPropertyName );
+}
+//------------------------------------------------------------------------------
+void lcl_clearBroadCaster(::comphelper::OPropertyChangeMultiplexer*& _pBroadcaster)
+{
+ if ( _pBroadcaster )
+ {
+ _pBroadcaster->dispose();
+ _pBroadcaster->release();
+ _pBroadcaster = NULL;
+ // no delete, this is done implicitly
+ }
+}
+//------------------------------------------------------------------------------
+DbCellControl::~DbCellControl()
+{
+ lcl_clearBroadCaster(m_pModelChangeBroadcaster);
+ lcl_clearBroadCaster(m_pFieldChangeBroadcaster);
+
+ delete m_pWindow;
+ delete m_pPainter;
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::implValuePropertyChanged( )
+{
+ OSL_ENSURE( !isValuePropertyLocked(),
+ "DbCellControl::implValuePropertyChanged: not to be called with the value property locked!" );
+
+ if ( m_pWindow )
+ {
+ if ( m_rColumn.getModel().is() )
+ updateFromModel( m_rColumn.getModel() );
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::implAdjustGenericFieldSetting( const Reference< XPropertySet >& /*_rxModel*/ )
+{
+ // nothing to to here
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::_propertyChanged(const PropertyChangeEvent& _rEvent) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ Reference< XPropertySet > xSourceProps( _rEvent.Source, UNO_QUERY );
+
+ if ( _rEvent.PropertyName.equals( FM_PROP_VALUE )
+ || _rEvent.PropertyName.equals( FM_PROP_STATE )
+ || _rEvent.PropertyName.equals( FM_PROP_TEXT )
+ || _rEvent.PropertyName.equals( FM_PROP_EFFECTIVE_VALUE )
+ )
+ { // it was one of the known "value" properties
+ if ( !isValuePropertyLocked() )
+ {
+ implValuePropertyChanged( );
+ }
+ }
+ else if ( _rEvent.PropertyName.equals( FM_PROP_READONLY ) )
+ {
+ implAdjustReadOnly( xSourceProps, true);
+ }
+ else if ( _rEvent.PropertyName.equals( FM_PROP_ISREADONLY ) )
+ {
+ sal_Bool bReadOnly = sal_True;
+ _rEvent.NewValue >>= bReadOnly;
+ m_rColumn.SetReadOnly(bReadOnly);
+ implAdjustReadOnly( xSourceProps, false);
+ }
+ else if ( _rEvent.PropertyName.equals( FM_PROP_ENABLED ) )
+ {
+ implAdjustEnabled( xSourceProps );
+ }
+ else
+ implAdjustGenericFieldSetting( xSourceProps );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbCellControl::Commit()
+{
+ // lock the listening for value property changes
+ lockValueProperty();
+ // commit the content of the control into the model's value property
+ sal_Bool bReturn = sal_False;
+ try
+ {
+ bReturn = commitControl();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ // unlock the listening for value property changes
+ unlockValueProperty();
+ // outta here
+ return bReturn;
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::ImplInitWindow( Window& rParent, const InitWindowFacet _eInitWhat )
+{
+ Window* pWindows[] = { m_pPainter, m_pWindow };
+
+ if ( ( _eInitWhat & InitWritingMode ) != 0 )
+ {
+ for ( size_t i=0; i < SAL_N_ELEMENTS( pWindows ); ++i )
+ {
+ if ( pWindows[i] )
+ pWindows[i]->EnableRTL( rParent.IsRTLEnabled() );
+ }
+ }
+
+ if ( ( _eInitWhat & InitFont ) != 0 )
+ {
+ for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
+ {
+ if ( !pWindows[i] )
+ continue;
+
+ pWindows[i]->SetZoom( rParent.GetZoom() );
+
+ const StyleSettings& rStyleSettings = pWindows[i]->GetSettings().GetStyleSettings();
+ Font aFont = rStyleSettings.GetFieldFont();
+ aFont.SetTransparent( isTransparent() );
+
+ if ( rParent.IsControlFont() )
+ {
+ pWindows[i]->SetControlFont( rParent.GetControlFont() );
+ aFont.Merge( rParent.GetControlFont() );
+ }
+ else
+ pWindows[i]->SetControlFont();
+
+ pWindows[i]->SetZoomedPointFont( aFont );
+ }
+ }
+
+ if ( ( ( _eInitWhat & InitFont ) != 0 )
+ || ( ( _eInitWhat & InitForeground ) != 0 )
+ )
+ {
+ Color aTextColor( rParent.IsControlForeground() ? rParent.GetControlForeground() : rParent.GetTextColor() );
+
+ sal_Bool bTextLineColor = rParent.IsTextLineColor();
+ Color aTextLineColor( rParent.GetTextLineColor() );
+
+ for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
+ {
+ if ( pWindows[i] )
+ {
+ pWindows[i]->SetTextColor(aTextColor);
+ if (rParent.IsControlForeground())
+ pWindows[i]->SetControlForeground(aTextColor);
+
+ if (bTextLineColor)
+ pWindows[i]->SetTextLineColor();
+ else
+ pWindows[i]->SetTextLineColor(aTextLineColor);
+ }
+ }
+ }
+
+ if ( ( _eInitWhat & InitBackground ) != 0 )
+ {
+ if (rParent.IsControlBackground())
+ {
+ Color aColor( rParent.GetControlBackground());
+ for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
+ {
+ if ( pWindows[i] )
+ {
+ if ( isTransparent() )
+ pWindows[i]->SetBackground();
+ else
+ {
+ pWindows[i]->SetBackground(aColor);
+ pWindows[i]->SetControlBackground(aColor);
+ }
+ pWindows[i]->SetFillColor(aColor);
+ }
+ }
+ }
+ else
+ {
+ if (m_pPainter)
+ {
+ if ( isTransparent() )
+ m_pPainter->SetBackground();
+ else
+ m_pPainter->SetBackground(rParent.GetBackground());
+ m_pPainter->SetFillColor(rParent.GetFillColor());
+ }
+
+ if (m_pWindow)
+ {
+ if ( isTransparent() )
+ m_pWindow->SetBackground(rParent.GetBackground());
+ else
+ m_pWindow->SetFillColor(rParent.GetFillColor());
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxModel,bool i_bReadOnly )
+{
+ DBG_ASSERT( m_pWindow, "DbCellControl::implAdjustReadOnly: not to be called without window!" );
+ DBG_ASSERT( _rxModel.is(), "DbCellControl::implAdjustReadOnly: invalid model!" );
+ if ( m_pWindow && _rxModel.is() )
+ {
+ Edit* pEditWindow = dynamic_cast< Edit* >( m_pWindow );
+ if ( pEditWindow )
+ {
+ sal_Bool bReadOnly = m_rColumn.IsReadOnly();
+ if ( !bReadOnly )
+ {
+ _rxModel->getPropertyValue( i_bReadOnly ? FM_PROP_READONLY : FM_PROP_ISREADONLY) >>= bReadOnly;
+ }
+ static_cast< Edit* >( m_pWindow )->SetReadOnly( bReadOnly );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::implAdjustEnabled( const Reference< XPropertySet >& _rxModel )
+{
+ DBG_ASSERT( m_pWindow, "DbCellControl::implAdjustEnabled: not to be called without window!" );
+ DBG_ASSERT( _rxModel.is(), "DbCellControl::implAdjustEnabled: invalid model!" );
+ if ( m_pWindow && _rxModel.is() )
+ {
+ sal_Bool bEnable = sal_True;
+ _rxModel->getPropertyValue( FM_PROP_ENABLED ) >>= bEnable;
+ m_pWindow->Enable( bEnable );
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::Init( Window& rParent, const Reference< XRowSet >& _rxCursor )
+{
+ ImplInitWindow( rParent, InitAll );
+
+ if ( m_pWindow )
+ {
+ // align the control
+ if ( isAlignedController() )
+ AlignControl( m_rColumn.GetAlignment() );
+
+ try
+ {
+ // some other common properties
+ Reference< XPropertySet > xModel( m_rColumn.getModel(), UNO_SET_THROW );
+ Reference< XPropertySetInfo > xModelPSI( xModel->getPropertySetInfo(), UNO_SET_THROW );
+
+ if ( xModelPSI->hasPropertyByName( FM_PROP_READONLY ) )
+ {
+ implAdjustReadOnly( xModel,true );
+ }
+
+ if ( xModelPSI->hasPropertyByName( FM_PROP_ENABLED ) )
+ {
+ implAdjustEnabled( xModel );
+ }
+
+ if ( xModelPSI->hasPropertyByName( FM_PROP_MOUSE_WHEEL_BEHAVIOR ) )
+ {
+ sal_Int16 nWheelBehavior = MouseWheelBehavior::SCROLL_FOCUS_ONLY;
+ OSL_VERIFY( xModel->getPropertyValue( FM_PROP_MOUSE_WHEEL_BEHAVIOR ) >>= nWheelBehavior );
+ USHORT nVclSetting = MOUSE_WHEEL_FOCUS_ONLY;
+ switch ( nWheelBehavior )
+ {
+ case MouseWheelBehavior::SCROLL_DISABLED: nVclSetting = MOUSE_WHEEL_DISABLE; break;
+ case MouseWheelBehavior::SCROLL_FOCUS_ONLY: nVclSetting = MOUSE_WHEEL_FOCUS_ONLY; break;
+ case MouseWheelBehavior::SCROLL_ALWAYS: nVclSetting = MOUSE_WHEEL_ALWAYS; break;
+ default:
+ OSL_ENSURE( false, "DbCellControl::Init: invalid MouseWheelBehavior!" );
+ break;
+ }
+
+ AllSettings aSettings = m_pWindow->GetSettings();
+ MouseSettings aMouseSettings = aSettings.GetMouseSettings();
+ aMouseSettings.SetWheelBehavior( nVclSetting );
+ aSettings.SetMouseSettings( aMouseSettings );
+ m_pWindow->SetSettings( aSettings, TRUE );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ m_xCursor = _rxCursor;
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::SetTextLineColor()
+{
+ if (m_pWindow)
+ m_pWindow->SetTextLineColor();
+ if (m_pPainter)
+ m_pPainter->SetTextLineColor();
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::SetTextLineColor(const Color& _rColor)
+{
+ if (m_pWindow)
+ m_pWindow->SetTextLineColor(_rColor);
+ if (m_pPainter)
+ m_pPainter->SetTextLineColor(_rColor);
+}
+
+namespace
+{
+ static void lcl_implAlign( Window* _pWindow, WinBits _nAlignmentBit )
+ {
+ WinBits nStyle = _pWindow->GetStyle();
+ nStyle &= ~(WB_LEFT | WB_RIGHT | WB_CENTER);
+ _pWindow->SetStyle( nStyle | _nAlignmentBit );
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::AlignControl(sal_Int16 nAlignment)
+{
+ WinBits nAlignmentBit = 0;
+ switch (nAlignment)
+ {
+ case ::com::sun::star::awt::TextAlign::RIGHT:
+ nAlignmentBit = WB_RIGHT;
+ break;
+ case ::com::sun::star::awt::TextAlign::CENTER:
+ nAlignmentBit = WB_CENTER;
+ break;
+ default:
+ nAlignmentBit = WB_LEFT;
+ break;
+ }
+ lcl_implAlign( m_pWindow, nAlignmentBit );
+ if ( m_pPainter )
+ lcl_implAlign( m_pPainter, nAlignmentBit );
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::PaintCell( OutputDevice& _rDev, const Rectangle& _rRect )
+{
+ if ( m_pPainter->GetParent() == &_rDev )
+ {
+ m_pPainter->SetPaintTransparent( sal_True );
+ m_pPainter->SetBackground( );
+ m_pPainter->SetControlBackground( _rDev.GetFillColor() );
+ m_pPainter->SetControlForeground( _rDev.GetTextColor() );
+ m_pPainter->SetTextColor( _rDev.GetTextColor() );
+ m_pPainter->SetTextFillColor( _rDev.GetTextColor() );
+
+ Font aFont( _rDev.GetFont() );
+ aFont.SetTransparent( TRUE );
+ m_pPainter->SetFont( aFont );
+
+ m_pPainter->SetPosSizePixel( _rRect.TopLeft(), _rRect.GetSize() );
+ m_pPainter->Show();
+ m_pPainter->Update();
+ m_pPainter->SetParentUpdateMode( sal_False );
+ m_pPainter->Hide();
+ m_pPainter->SetParentUpdateMode( sal_True );
+ }
+ else
+ m_pPainter->Draw( &_rDev, _rRect.TopLeft(), _rRect.GetSize(), 0 );
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::PaintFieldToCell( OutputDevice& _rDev, const Rectangle& _rRect, const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
+{
+ m_pPainter->SetText( GetFormatText( _rxField, _rxFormatter ) );
+ PaintCell( _rDev, _rRect );
+}
+
+//------------------------------------------------------------------------------
+double DbCellControl::GetValue(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter) const
+{
+ double fValue = 0;
+ if (m_rColumn.IsNumeric())
+ {
+ try
+ {
+ fValue = _rxField->getDouble();
+ }
+ catch(const Exception&) { }
+ }
+ else
+ {
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ fValue = _rxField->getDouble();
+ bSuccess = sal_True;
+ }
+ catch(const Exception&) { }
+ if (!bSuccess)
+ {
+ try
+ {
+ fValue = xFormatter->convertStringToNumber(m_rColumn.GetKey(), _rxField->getString());
+ }
+ catch(const Exception&) { }
+ }
+ }
+ return fValue;
+}
+
+//------------------------------------------------------------------------------
+void DbCellControl::invalidatedController()
+{
+ m_rColumn.GetParent().refreshController(m_rColumn.GetId(), DbGridControl::GrantControlAccess());
+}
+
+/*************************************************************************/
+// CellModels
+/*************************************************************************/
+
+//==============================================================================
+//= DbLimitedLengthField
+//==============================================================================
+//------------------------------------------------------------------------------
+DbLimitedLengthField::DbLimitedLengthField( DbGridColumn& _rColumn )
+ :DbCellControl( _rColumn )
+{
+ doPropertyListening( FM_PROP_MAXTEXTLEN );
+}
+
+//------------------------------------------------------------------------------
+void DbLimitedLengthField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
+{
+ DBG_ASSERT( m_pWindow, "DbLimitedLengthField::implAdjustGenericFieldSetting: not to be called without window!" );
+ DBG_ASSERT( _rxModel.is(), "DbLimitedLengthField::implAdjustGenericFieldSetting: invalid model!" );
+ if ( m_pWindow && _rxModel.is() )
+ {
+ sal_Int16 nMaxLen = 0;
+ _rxModel->getPropertyValue( FM_PROP_MAXTEXTLEN ) >>= nMaxLen;
+ implSetMaxTextLen( nMaxLen );
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbLimitedLengthField::implSetEffectiveMaxTextLen( sal_Int16 _nMaxLen )
+{
+ dynamic_cast< Edit* >( m_pWindow )->SetMaxTextLen( _nMaxLen );
+ if ( m_pPainter )
+ dynamic_cast< Edit* >( m_pPainter )->SetMaxTextLen( _nMaxLen );
+}
+
+//==============================================================================
+//= DbTextField
+//==============================================================================
+//------------------------------------------------------------------------------
+DbTextField::DbTextField(DbGridColumn& _rColumn)
+ :DbLimitedLengthField(_rColumn)
+ ,m_pEdit( NULL )
+ ,m_pPainterImplementation( NULL )
+ ,m_nKeyType(::com::sun::star::util::NumberFormat::TEXT)
+ ,m_bIsSimpleEdit( sal_True )
+{
+}
+
+//------------------------------------------------------------------------------
+DbTextField::~DbTextField( )
+{
+ DELETEZ( m_pPainterImplementation );
+ DELETEZ( m_pEdit );
+}
+
+//------------------------------------------------------------------------------
+void DbTextField::Init( Window& rParent, const Reference< XRowSet >& xCursor)
+{
+ sal_Int16 nAlignment = m_rColumn.SetAlignmentFromModel(-1);
+
+ Reference< XPropertySet > xModel( m_rColumn.getModel() );
+
+ WinBits nStyle = WB_LEFT;
+ switch (nAlignment)
+ {
+ case awt::TextAlign::RIGHT:
+ nStyle = WB_RIGHT;
+ break;
+
+ case awt::TextAlign::CENTER:
+ nStyle = WB_CENTER;
+ break;
+ }
+
+ // is this a multi-line field?
+ sal_Bool bIsMultiLine = sal_False;
+ try
+ {
+ if ( xModel.is() )
+ {
+ OSL_VERIFY( xModel->getPropertyValue( FM_PROP_MULTILINE ) >>= bIsMultiLine );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "DbTextField::Init: caught an exception while determining the multi-line capabilities!" );
+ }
+
+ m_bIsSimpleEdit = !bIsMultiLine;
+ if ( bIsMultiLine )
+ {
+ m_pWindow = new MultiLineTextCell( &rParent, nStyle );
+ m_pEdit = new MultiLineEditImplementation( *static_cast< MultiLineTextCell* >( m_pWindow ) );
+
+ m_pPainter = new MultiLineTextCell( &rParent, nStyle );
+ m_pPainterImplementation = new MultiLineEditImplementation( *static_cast< MultiLineTextCell* >( m_pPainter ) );
+ }
+ else
+ {
+ m_pWindow = new Edit( &rParent, nStyle );
+ m_pEdit = new EditImplementation( *static_cast< Edit* >( m_pWindow ) );
+
+ m_pPainter = new Edit( &rParent, nStyle );
+ m_pPainterImplementation = new EditImplementation( *static_cast< Edit* >( m_pPainter ) );
+ }
+
+ if ( WB_LEFT == nStyle )
+ {
+ // this is so that when getting the focus, the selection is oriented left-to-right
+ AllSettings aSettings = m_pWindow->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.SetSelectionOptions(
+ aStyleSettings.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST);
+ aSettings.SetStyleSettings(aStyleSettings);
+ m_pWindow->SetSettings(aSettings);
+ }
+
+ implAdjustGenericFieldSetting( xModel );
+
+ if (m_rColumn.GetParent().getNumberFormatter().is() && m_rColumn.GetKey())
+ m_nKeyType = comphelper::getNumberFormatType(m_rColumn.GetParent().getNumberFormatter()->getNumberFormatsSupplier()->getNumberFormats(), m_rColumn.GetKey());
+
+ DbLimitedLengthField::Init( rParent, xCursor );
+}
+
+//------------------------------------------------------------------------------
+CellControllerRef DbTextField::CreateController() const
+{
+ return new EditCellController( m_pEdit );
+}
+
+//------------------------------------------------------------------------------
+void DbTextField::PaintFieldToCell( OutputDevice& _rDev, const Rectangle& _rRect, const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
+{
+ if ( m_pPainterImplementation )
+ m_pPainterImplementation->SetText( GetFormatText( _rxField, _rxFormatter, NULL ) );
+
+ DbLimitedLengthField::PaintFieldToCell( _rDev, _rRect, _rxField, _rxFormatter );
+}
+
+//------------------------------------------------------------------------------
+String DbTextField::GetFormatText(const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter, Color** /*ppColor*/)
+{
+ ::rtl::OUString aString;
+ if ( _rxField.is() )
+ try
+ {
+ aString = getValue( _rxField, xFormatter, m_rColumn.GetParent().getNullDate(), m_rColumn.GetKey(), m_nKeyType);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return aString;
+}
+
+//------------------------------------------------------------------------------
+void DbTextField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter)
+{
+ m_pEdit->SetText( GetFormatText( _rxField, xFormatter ) );
+ m_pEdit->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
+}
+
+//------------------------------------------------------------------------------
+void DbTextField::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbTextField::updateFromModel: invalid call!" );
+
+ ::rtl::OUString sText;
+ _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText;
+
+ xub_StrLen nMaxTextLen = m_pEdit->GetMaxTextLen();
+ if ( EDIT_NOLIMIT != nMaxTextLen && sText.getLength() > nMaxTextLen )
+ {
+ sal_Int32 nDiff = sText.getLength() - nMaxTextLen;
+ sText = sText.replaceAt(sText.getLength() - nDiff,nDiff,::rtl::OUString());
+ }
+
+
+ m_pEdit->SetText( sText );
+ m_pEdit->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbTextField::commitControl()
+{
+ ::rtl::OUString aText( m_pEdit->GetText( getModelLineEndSetting( m_rColumn.getModel() ) ) );
+ // we have to check if the length before we can decide if the value was modified
+ xub_StrLen nMaxTextLen = m_pEdit->GetMaxTextLen();
+ if ( EDIT_NOLIMIT != nMaxTextLen )
+ {
+ ::rtl::OUString sOldValue;
+ m_rColumn.getModel()->getPropertyValue( FM_PROP_TEXT ) >>= sOldValue;
+ // if the new value didn't change we must set the old long value again
+ if ( sOldValue.getLength() > nMaxTextLen && sOldValue.compareTo(aText,nMaxTextLen) == 0 )
+ aText = sOldValue;
+ }
+ m_rColumn.getModel()->setPropertyValue( FM_PROP_TEXT, makeAny( aText ) );
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void DbTextField::implSetEffectiveMaxTextLen( sal_Int16 _nMaxLen )
+{
+ if ( m_pEdit )
+ m_pEdit->SetMaxTextLen( _nMaxLen );
+ if ( m_pPainterImplementation )
+ m_pPainterImplementation->SetMaxTextLen( _nMaxLen );
+}
+
+//==============================================================================
+//= DbFormattedField
+//==============================================================================
+DBG_NAME(DbFormattedField);
+//------------------------------------------------------------------------------
+DbFormattedField::DbFormattedField(DbGridColumn& _rColumn)
+ :DbLimitedLengthField(_rColumn)
+ ,m_nKeyType(::com::sun::star::util::NumberFormat::UNDEFINED)
+{
+ DBG_CTOR(DbFormattedField,NULL);
+
+ // if our model's format key changes we want to propagate the new value to our windows
+ doPropertyListening( FM_PROP_FORMATKEY );
+}
+
+//------------------------------------------------------------------------------
+DbFormattedField::~DbFormattedField()
+{
+ DBG_DTOR(DbFormattedField,NULL);
+}
+
+//------------------------------------------------------------------------------
+void DbFormattedField::Init( Window& rParent, const Reference< XRowSet >& xCursor)
+{
+ sal_Int16 nAlignment = m_rColumn.SetAlignmentFromModel(-1);
+
+ Reference< ::com::sun::star::beans::XPropertySet > xUnoModel = m_rColumn.getModel();
+
+ switch (nAlignment)
+ {
+ case ::com::sun::star::awt::TextAlign::RIGHT:
+ m_pWindow = new FormattedField( &rParent, WB_RIGHT );
+ m_pPainter = new FormattedField( &rParent, WB_RIGHT );
+ break;
+
+ case ::com::sun::star::awt::TextAlign::CENTER:
+ m_pWindow = new FormattedField( &rParent, WB_CENTER );
+ m_pPainter = new FormattedField( &rParent, WB_CENTER );
+ break;
+ default:
+ m_pWindow = new FormattedField( &rParent, WB_LEFT );
+ m_pPainter = new FormattedField( &rParent, WB_LEFT );
+
+ // Alles nur damit die Selektion bei Focuserhalt von rechts nach links geht
+ AllSettings aSettings = m_pWindow->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.SetSelectionOptions(
+ aStyleSettings.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST);
+ aSettings.SetStyleSettings(aStyleSettings);
+ m_pWindow->SetSettings(aSettings);
+ }
+
+ implAdjustGenericFieldSetting( xUnoModel );
+
+ static_cast< FormattedField* >( m_pWindow )->SetStrictFormat( sal_False );
+ static_cast< FormattedField* >( m_pPainter )->SetStrictFormat( sal_False );
+ // wenn man _irgendeine_ Formatierung zulaesst, kann man da sowieso keine Eingabe-Ueberpruefung
+ // machen (das FormattedField unterstuetzt das sowieso nicht, nur abgeleitete Klassen)
+
+ // von dem Uno-Model den Formatter besorgen
+ // (Ich koennte theoretisch auch ueber den ::com::sun::star::util::NumberFormatter gehen, den mir der Cursor bestimmt
+ // liefern wuerde. Das Problem dabei ist, dass ich mich eigentlich nicht darauf verlassen
+ // kann, dass die beiden Formatter die selben sind, sauber ist das Ganze, wenn ich ueber das
+ // UNO-Model gehe.)
+ sal_Int32 nFormatKey = -1;
+
+ // mal sehen, ob das Model einen hat ...
+ DBG_ASSERT(::comphelper::hasProperty(FM_PROP_FORMATSSUPPLIER, xUnoModel), "DbFormattedField::Init : invalid UNO model !");
+ Any aSupplier( xUnoModel->getPropertyValue(FM_PROP_FORMATSSUPPLIER));
+ if (aSupplier.hasValue())
+ {
+ ::cppu::extractInterface(m_xSupplier, aSupplier);
+ if (m_xSupplier.is())
+ {
+ // wenn wir den Supplier vom Model nehmen, dann auch den Key
+ Any aFmtKey( xUnoModel->getPropertyValue(FM_PROP_FORMATKEY));
+ if (aFmtKey.hasValue())
+ {
+ DBG_ASSERT(aFmtKey.getValueType().getTypeClass() == TypeClass_LONG, "DbFormattedField::Init : invalid format key property (no sal_Int32) !");
+ nFormatKey = ::comphelper::getINT32(aFmtKey);
+ }
+ else
+ {
+ DBG_WARNING("DbFormattedField::Init : my uno-model has no format-key, but a formats supplier !");
+ // the OFormattedModel which we usually are working with ensures that the model has a format key
+ // as soon as the form is loaded. Unfortunally this method here is called from within loaded, too.
+ // So if our LoadListener is called before the LoadListener of the model, this "else case" is
+ // allowed.
+ // Of course our property listener for the FormatKey property will notify us if the prop is changed,
+ // so this here isn't really bad ....
+ nFormatKey = 0;
+ }
+ }
+ }
+
+ // nein ? vielleicht die ::com::sun::star::form::component::Form hinter dem Cursor ?
+ if (!m_xSupplier.is())
+ {
+ Reference< XRowSet > xCursorForm(xCursor, UNO_QUERY);
+ if (xCursorForm.is())
+ { // wenn wir vom Cursor den Formatter nehmen, dann auch den Key vom Feld, an das wir gebunden sind
+ m_xSupplier = getNumberFormats(getRowSetConnection(xCursorForm), sal_False);
+
+ if (m_rColumn.GetField().is())
+ nFormatKey = ::comphelper::getINT32(m_rColumn.GetField()->getPropertyValue(FM_PROP_FORMATKEY));
+ }
+ }
+
+ SvNumberFormatter* pFormatterUsed = NULL;
+ if (m_xSupplier.is())
+ {
+ SvNumberFormatsSupplierObj* pImplmentation = SvNumberFormatsSupplierObj::getImplementation(m_xSupplier);
+ if (pImplmentation)
+ pFormatterUsed = pImplmentation->GetNumberFormatter();
+ else
+ // alles hingfaellig : der Supplier ist vom falschen Typ, dann koennen wir uns auch nicht darauf verlassen, dass
+ // ein Standard-Formatter den (eventuell nicht-Standard-)Key kennt.
+ nFormatKey = -1;
+ }
+
+ // einen Standard-Formatter ...
+ if (pFormatterUsed == NULL)
+ {
+ pFormatterUsed = ((FormattedField*)m_pWindow)->StandardFormatter();
+ DBG_ASSERT(pFormatterUsed != NULL, "DbFormattedField::Init : no standard formatter given by the numeric field !");
+ }
+ // ... und einen Standard-Key
+ if (nFormatKey == -1)
+ nFormatKey = 0;
+
+ m_nKeyType = comphelper::getNumberFormatType(m_xSupplier->getNumberFormats(), nFormatKey);
+
+ ((FormattedField*)m_pWindow)->SetFormatter(pFormatterUsed);
+ ((FormattedField*)m_pPainter)->SetFormatter(pFormatterUsed);
+
+ ((FormattedField*)m_pWindow)->SetFormatKey(nFormatKey);
+ ((FormattedField*)m_pPainter)->SetFormatKey(nFormatKey);
+
+ ((FormattedField*)m_pWindow)->TreatAsNumber(m_rColumn.IsNumeric());
+ ((FormattedField*)m_pPainter)->TreatAsNumber(m_rColumn.IsNumeric());
+
+ // Min- und Max-Werte
+ if (m_rColumn.IsNumeric())
+ {
+ sal_Bool bClearMin = sal_True;
+ if (::comphelper::hasProperty(FM_PROP_EFFECTIVE_MIN, xUnoModel))
+ {
+ Any aMin( xUnoModel->getPropertyValue(FM_PROP_EFFECTIVE_MIN));
+ if (aMin.getValueType().getTypeClass() != TypeClass_VOID)
+ {
+ DBG_ASSERT(aMin.getValueType().getTypeClass() == TypeClass_DOUBLE, "DbFormattedField::Init : the model has an invalid min value !");
+ double dMin = ::comphelper::getDouble(aMin);
+ ((FormattedField*)m_pWindow)->SetMinValue(dMin);
+ ((FormattedField*)m_pPainter)->SetMinValue(dMin);
+ bClearMin = sal_False;
+ }
+ }
+ if (bClearMin)
+ {
+ ((FormattedField*)m_pWindow)->ClearMinValue();
+ ((FormattedField*)m_pPainter)->ClearMinValue();
+ }
+ sal_Bool bClearMax = sal_True;
+ if (::comphelper::hasProperty(FM_PROP_EFFECTIVE_MAX, xUnoModel))
+ {
+ Any aMin( xUnoModel->getPropertyValue(FM_PROP_EFFECTIVE_MAX));
+ if (aMin.getValueType().getTypeClass() != TypeClass_VOID)
+ {
+ DBG_ASSERT(aMin.getValueType().getTypeClass() == TypeClass_DOUBLE, "DbFormattedField::Init : the model has an invalid max value !");
+ double dMin = ::comphelper::getDouble(aMin);
+ ((FormattedField*)m_pWindow)->SetMaxValue(dMin);
+ ((FormattedField*)m_pPainter)->SetMaxValue(dMin);
+ bClearMax = sal_False;
+ }
+ }
+ if (bClearMax)
+ {
+ ((FormattedField*)m_pWindow)->ClearMaxValue();
+ ((FormattedField*)m_pPainter)->ClearMaxValue();
+ }
+ }
+
+ // den Default-Wert
+ Any aDefault( xUnoModel->getPropertyValue(FM_PROP_EFFECTIVE_DEFAULT));
+ if (aDefault.hasValue())
+ { // das Ding kann ein double oder ein String sein
+ switch (aDefault.getValueType().getTypeClass())
+ {
+ case TypeClass_DOUBLE:
+ if (m_rColumn.IsNumeric())
+ {
+ ((FormattedField*)m_pWindow)->SetDefaultValue(::comphelper::getDouble(aDefault));
+ ((FormattedField*)m_pPainter)->SetDefaultValue(::comphelper::getDouble(aDefault));
+ }
+ else
+ {
+ String sConverted;
+ Color* pDummy;
+ pFormatterUsed->GetOutputString(::comphelper::getDouble(aDefault), 0, sConverted, &pDummy);
+ ((FormattedField*)m_pWindow)->SetDefaultText(sConverted);
+ ((FormattedField*)m_pPainter)->SetDefaultText(sConverted);
+ }
+ break;
+ case TypeClass_STRING:
+ {
+ String sDefault( ::comphelper::getString(aDefault) );
+ if (m_rColumn.IsNumeric())
+ {
+ double dVal;
+ sal_uInt32 nTestFormat(0);
+ if (pFormatterUsed->IsNumberFormat(sDefault, nTestFormat, dVal))
+ {
+ ((FormattedField*)m_pWindow)->SetDefaultValue(dVal);
+ ((FormattedField*)m_pPainter)->SetDefaultValue(dVal);
+ }
+ }
+ else
+ {
+ ((FormattedField*)m_pWindow)->SetDefaultText(sDefault);
+ ((FormattedField*)m_pPainter)->SetDefaultText(sDefault);
+ }
+ }
+ default:
+ DBG_ERROR( "DbFormattedField::Init: unexpected value type!" );
+ break;
+ }
+ }
+ DbLimitedLengthField::Init( rParent, xCursor );
+}
+
+//------------------------------------------------------------------------------
+CellControllerRef DbFormattedField::CreateController() const
+{
+ return new ::svt::FormattedFieldCellController( static_cast< FormattedField* >( m_pWindow ) );
+}
+
+//------------------------------------------------------------------------------
+void DbFormattedField::_propertyChanged( const PropertyChangeEvent& _rEvent ) throw( RuntimeException )
+{
+ if (_rEvent.PropertyName.compareTo(FM_PROP_FORMATKEY) == COMPARE_EQUAL)
+ {
+ sal_Int32 nNewKey = _rEvent.NewValue.hasValue() ? ::comphelper::getINT32(_rEvent.NewValue) : 0;
+ m_nKeyType = comphelper::getNumberFormatType(m_xSupplier->getNumberFormats(), nNewKey);
+
+ DBG_ASSERT(m_pWindow && m_pPainter, "DbFormattedField::_propertyChanged : where are my windows ?");
+ if (m_pWindow)
+ static_cast< FormattedField* >( m_pWindow )->SetFormatKey( nNewKey );
+ if (m_pPainter)
+ static_cast< FormattedField* >( m_pPainter )->SetFormatKey( nNewKey );
+ }
+ else
+ {
+ DbLimitedLengthField::_propertyChanged( _rEvent );
+ }
+}
+
+//------------------------------------------------------------------------------
+String DbFormattedField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/, Color** ppColor)
+{
+ // defaultmaessig keine Farb-Angabe
+ if (ppColor != NULL)
+ *ppColor = NULL;
+
+ // NULL-Wert -> leerer Text
+ if (!_rxField.is())
+ return String();
+
+ String aText;
+ try
+ {
+ if (m_rColumn.IsNumeric())
+ {
+ // das IsNumeric an der Column sagt nichts aus ueber die Klasse des benutzen Formates, sondern
+ // ueber die des an die Column gebundenen Feldes. Wenn man also eine FormattedField-Spalte an
+ // ein double-Feld bindet und als Text formatiert, liefert m_rColumn.IsNumeric() sal_True. Das heisst
+ // also einfach, dass ich den Inhalt der Variant mittels getDouble abfragen kann, und dann kann
+ // ich den Rest (die Formatierung) dem FormattedField ueberlassen.
+ double dValue = getValue(_rxField, m_rColumn.GetParent().getNullDate(), m_nKeyType);
+ if (_rxField->wasNull())
+ return aText;
+ ((FormattedField*)m_pPainter)->SetValue(dValue);
+ }
+ else
+ {
+ // Hier kann ich nicht mit einem double arbeiten, da das Feld mir keines liefern kann.
+ // Also einfach den Text vom ::com::sun::star::util::NumberFormatter in die richtige ::com::sun::star::form::component::Form brinden lassen.
+ aText = (const sal_Unicode*)_rxField->getString();
+ if (_rxField->wasNull())
+ return aText;
+ ((FormattedField*)m_pPainter)->SetTextFormatted(aText);
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ aText = m_pPainter->GetText();
+ if (ppColor != NULL)
+ *ppColor = ((FormattedField*)m_pPainter)->GetLastOutputColor();
+
+ return aText;
+}
+
+//------------------------------------------------------------------------------
+void DbFormattedField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
+{
+ try
+ {
+ FormattedField* pFormattedWindow = static_cast<FormattedField*>(m_pWindow);
+ if (!_rxField.is())
+ { // NULL-Wert -> leerer Text
+ m_pWindow->SetText(String());
+ }
+ else if (m_rColumn.IsNumeric())
+ {
+ // das IsNumeric an der Column sagt nichts aus ueber die Klasse des benutzen Formates, sondern
+ // ueber die des an die Column gebundenen Feldes. Wenn man also eine FormattedField-Spalte an
+ // ein double-Feld bindet und als Text formatiert, liefert m_rColumn.IsNumeric() sal_True. Das heisst
+ // also einfach, dass ich den Inhalt der Variant mittels getDouble abfragen kann, und dann kann
+ // ich den Rest (die Formatierung) dem FormattedField ueberlassen.
+ double dValue = getValue(_rxField, m_rColumn.GetParent().getNullDate(), m_nKeyType);
+ if (_rxField->wasNull())
+ m_pWindow->SetText(String());
+ else
+ pFormattedWindow->SetValue(dValue);
+ }
+ else
+ {
+ // Hier kann ich nicht mit einem double arbeiten, da das Feld mir keines liefern kann.
+ // Also einfach den Text vom ::com::sun::star::util::NumberFormatter in die richtige ::com::sun::star::form::component::Form brinden lassen.
+ String sText( _rxField->getString());
+
+ pFormattedWindow->SetTextFormatted( sText );
+ pFormattedWindow->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbFormattedField::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbFormattedField::updateFromModel: invalid call!" );
+
+ FormattedField* pFormattedWindow = static_cast< FormattedField* >( m_pWindow );
+
+ ::rtl::OUString sText;
+ Any aValue = _rxModel->getPropertyValue( FM_PROP_EFFECTIVE_VALUE );
+ if ( aValue >>= sText )
+ { // our effective value is transfered as string
+ pFormattedWindow->SetTextFormatted( sText );
+ pFormattedWindow->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
+ }
+ else
+ {
+ double dValue = 0;
+ aValue >>= dValue;
+ pFormattedWindow->SetValue(dValue);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbFormattedField::commitControl()
+{
+ Any aNewVal;
+ FormattedField& rField = *(FormattedField*)m_pWindow;
+ DBG_ASSERT(&rField == m_pWindow, "DbFormattedField::commitControl : can't work with a window other than my own !");
+ if (m_rColumn.IsNumeric())
+ {
+ if (rField.GetText().Len() != 0)
+ aNewVal <<= rField.GetValue();
+ // ein LeerString wird erst mal standardmaessig als void weitergereicht
+ }
+ else
+ aNewVal <<= ::rtl::OUString(rField.GetTextValue());
+
+ m_rColumn.getModel()->setPropertyValue(FM_PROP_EFFECTIVE_VALUE, aNewVal);
+ return sal_True;
+}
+
+//==============================================================================
+//= DbCheckBox
+//==============================================================================
+//------------------------------------------------------------------------------
+DbCheckBox::DbCheckBox( DbGridColumn& _rColumn )
+ :DbCellControl( _rColumn, sal_True )
+{
+ setAlignedController( sal_False );
+}
+
+namespace
+{
+ void setCheckBoxStyle( Window* _pWindow, USHORT nStyle )
+ {
+ AllSettings aSettings = _pWindow->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.SetCheckBoxStyle( nStyle );
+ aSettings.SetStyleSettings( aStyleSettings );
+ _pWindow->SetSettings( aSettings );
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbCheckBox::Init( Window& rParent, const Reference< XRowSet >& xCursor )
+{
+ setTransparent( sal_True );
+
+ m_pWindow = new CheckBoxControl( &rParent );
+ m_pPainter = new CheckBoxControl( &rParent );
+
+ m_pWindow->SetPaintTransparent( sal_True );
+ m_pPainter->SetPaintTransparent( sal_True );
+
+ m_pPainter->SetBackground();
+
+ try
+ {
+ Reference< XPropertySet > xModel( m_rColumn.getModel(), UNO_SET_THROW );
+
+ sal_Int16 nStyle = awt::VisualEffect::LOOK3D;
+ OSL_VERIFY( xModel->getPropertyValue( FM_PROP_VISUALEFFECT ) >>= nStyle );
+
+ setCheckBoxStyle( m_pWindow, nStyle == awt::VisualEffect::FLAT ? STYLE_CHECKBOX_MONO : STYLE_CHECKBOX_WIN );
+ setCheckBoxStyle( m_pPainter, nStyle == awt::VisualEffect::FLAT ? STYLE_CHECKBOX_MONO : STYLE_CHECKBOX_WIN );
+
+ sal_Bool bTristate = sal_True;
+ OSL_VERIFY( xModel->getPropertyValue( FM_PROP_TRISTATE ) >>= bTristate );
+ static_cast< CheckBoxControl* >( m_pWindow )->GetBox().EnableTriState( bTristate );
+ static_cast< CheckBoxControl* >( m_pPainter )->GetBox().EnableTriState( bTristate );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ DbCellControl::Init( rParent, xCursor );
+}
+
+//------------------------------------------------------------------------------
+CellControllerRef DbCheckBox::CreateController() const
+{
+ return new CheckBoxCellController((CheckBoxControl*)m_pWindow);
+}
+//------------------------------------------------------------------------------
+static void lcl_setCheckBoxState( const Reference< ::com::sun::star::sdb::XColumn >& _rxField,
+ CheckBoxControl* _pCheckBoxControl )
+{
+ TriState eState = STATE_DONTKNOW;
+ if (_rxField.is())
+ {
+ try
+ {
+ sal_Bool bValue = _rxField->getBoolean();
+ if (!_rxField->wasNull())
+ eState = bValue ? STATE_CHECK : STATE_NOCHECK;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ _pCheckBoxControl->GetBox().SetState(eState);
+}
+
+//------------------------------------------------------------------------------
+void DbCheckBox::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
+{
+ lcl_setCheckBoxState( _rxField, static_cast<CheckBoxControl*>(m_pWindow) );
+}
+
+//------------------------------------------------------------------------------
+void DbCheckBox::PaintFieldToCell(OutputDevice& rDev, const Rectangle& rRect,
+ const Reference< ::com::sun::star::sdb::XColumn >& _rxField,
+ const Reference< XNumberFormatter >& xFormatter)
+{
+ lcl_setCheckBoxState( _rxField, static_cast<CheckBoxControl*>(m_pPainter) );
+ DbCellControl::PaintFieldToCell( rDev, rRect, _rxField, xFormatter );
+}
+
+//------------------------------------------------------------------------------
+void DbCheckBox::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCheckBox::updateFromModel: invalid call!" );
+
+ sal_Int16 nState = STATE_DONTKNOW;
+ _rxModel->getPropertyValue( FM_PROP_STATE ) >>= nState;
+ static_cast< CheckBoxControl* >( m_pWindow )->GetBox().SetState( static_cast< TriState >( nState ) );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbCheckBox::commitControl()
+{
+#if OSL_DEBUG_LEVEL > 0
+ Any aVal = makeAny( (sal_Int16)( static_cast< CheckBoxControl* >( m_pWindow )->GetBox().GetState() ) );
+#endif
+ m_rColumn.getModel()->setPropertyValue( FM_PROP_STATE,
+ makeAny( (sal_Int16)( static_cast< CheckBoxControl* >( m_pWindow )->GetBox().GetState() ) ) );
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+XubString DbCheckBox::GetFormatText(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
+{
+ return XubString();
+}
+
+//==============================================================================
+//= DbPatternField
+//------------------------------------------------------------------------------
+DbPatternField::DbPatternField( DbGridColumn& _rColumn, const ::comphelper::ComponentContext& _rContext )
+ :DbCellControl( _rColumn )
+ ,m_aContext( _rContext )
+{
+ doPropertyListening( FM_PROP_LITERALMASK );
+ doPropertyListening( FM_PROP_EDITMASK );
+ doPropertyListening( FM_PROP_STRICTFORMAT );
+}
+
+//------------------------------------------------------------------------------
+void DbPatternField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
+{
+ DBG_ASSERT( m_pWindow, "DbPatternField::implAdjustGenericFieldSetting: not to be called without window!" );
+ DBG_ASSERT( _rxModel.is(), "DbPatternField::implAdjustGenericFieldSetting: invalid model!" );
+ if ( m_pWindow && _rxModel.is() )
+ {
+ ::rtl::OUString aLitMask;
+ ::rtl::OUString aEditMask;
+ sal_Bool bStrict = sal_False;
+
+ _rxModel->getPropertyValue( FM_PROP_LITERALMASK ) >>= aLitMask;
+ _rxModel->getPropertyValue( FM_PROP_EDITMASK ) >>= aEditMask;
+ _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) >>= bStrict;
+
+ ByteString aAsciiEditMask( aEditMask.getStr(), RTL_TEXTENCODING_ASCII_US );
+
+ static_cast< PatternField* >( m_pWindow )->SetMask( aAsciiEditMask, aLitMask );
+ static_cast< PatternField* >( m_pPainter )->SetMask( aAsciiEditMask, aLitMask );
+ static_cast< PatternField* >( m_pWindow )->SetStrictFormat( bStrict );
+ static_cast< PatternField* >( m_pPainter )->SetStrictFormat( bStrict );
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbPatternField::Init( Window& rParent, const Reference< XRowSet >& xCursor)
+{
+ m_rColumn.SetAlignmentFromModel(-1);
+
+ m_pWindow = new PatternField( &rParent, 0 );
+ m_pPainter= new PatternField( &rParent, 0 );
+
+ Reference< XPropertySet > xModel( m_rColumn.getModel() );
+ implAdjustGenericFieldSetting( xModel );
+
+ DbCellControl::Init( rParent, xCursor );
+}
+
+//------------------------------------------------------------------------------
+CellControllerRef DbPatternField::CreateController() const
+{
+ return new SpinCellController( static_cast< PatternField* >( m_pWindow ) );
+}
+
+//------------------------------------------------------------------------------
+String DbPatternField::impl_formatText( const String& _rText )
+{
+ m_pPainter->SetText( _rText );
+ static_cast< PatternField* >( m_pPainter )->ReformatAll();
+ return m_pPainter->GetText();
+}
+
+//------------------------------------------------------------------------------
+String DbPatternField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
+{
+ bool bIsForPaint = _rxField != m_rColumn.GetField();
+ ::std::auto_ptr< ::dbtools::FormattedColumnValue >& rpFormatter = bIsForPaint ? m_pPaintFormatter : m_pValueFormatter;
+
+ if ( !rpFormatter.get() )
+ {
+ DBToolsObjectFactory aFactory;
+ rpFormatter = aFactory.createFormattedColumnValue(
+ m_aContext, getCursor(), Reference< XPropertySet >( _rxField, UNO_QUERY ) );
+ OSL_ENSURE( rpFormatter.get(), "DbPatternField::Init: no value formatter!" );
+ }
+ else
+ OSL_ENSURE( rpFormatter->getColumn() == _rxField, "DbPatternField::GetFormatText: my value formatter is working for another field ...!" );
+ // re-creating the value formatter here everytime would be quite expensive ...
+
+ String sText;
+ if ( rpFormatter.get() )
+ sText = rpFormatter->getFormattedValue();
+
+ return impl_formatText( sText );
+}
+
+//------------------------------------------------------------------------------
+void DbPatternField::UpdateFromField( const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
+{
+ static_cast< Edit* >( m_pWindow )->SetText( GetFormatText( _rxField, _rxFormatter ) );
+ static_cast< Edit* >( m_pWindow )->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
+}
+
+//------------------------------------------------------------------------------
+void DbPatternField::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbPatternField::updateFromModel: invalid call!" );
+
+ ::rtl::OUString sText;
+ _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText;
+
+ static_cast< Edit* >( m_pWindow )->SetText( impl_formatText( sText ) );
+ static_cast< Edit* >( m_pWindow )->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbPatternField::commitControl()
+{
+ String aText(m_pWindow->GetText());
+ m_rColumn.getModel()->setPropertyValue(FM_PROP_TEXT, makeAny(::rtl::OUString(aText)));
+ return sal_True;
+}
+
+//==============================================================================
+//= DbSpinField
+//==============================================================================
+//------------------------------------------------------------------------------
+DbSpinField::DbSpinField( DbGridColumn& _rColumn, sal_Int16 _nStandardAlign )
+ :DbCellControl( _rColumn )
+ ,m_nStandardAlign( _nStandardAlign )
+{
+}
+
+//------------------------------------------------------------------------------
+void DbSpinField::Init( Window& _rParent, const Reference< XRowSet >& _rxCursor )
+{
+ m_rColumn.SetAlignmentFromModel( m_nStandardAlign );
+
+ Reference< XPropertySet > xModel( m_rColumn.getModel() );
+
+ // determine the WinBits for the field
+ WinBits nFieldStyle = 0;
+ if ( ::comphelper::getBOOL( xModel->getPropertyValue( FM_PROP_SPIN ) ) )
+ nFieldStyle = WB_REPEAT | WB_SPIN;
+ // create the fields
+ m_pWindow = createField( &_rParent, nFieldStyle, xModel );
+ m_pPainter = createField( &_rParent, nFieldStyle, xModel );
+
+ // adjust all other settings which depend on the property values
+ implAdjustGenericFieldSetting( xModel );
+
+ // call the base class
+ DbCellControl::Init( _rParent, _rxCursor );
+}
+
+//------------------------------------------------------------------------------
+CellControllerRef DbSpinField::CreateController() const
+{
+ return new SpinCellController( static_cast< SpinField* >( m_pWindow ) );
+}
+
+//==============================================================================
+//= DbNumericField
+//==============================================================================
+//------------------------------------------------------------------------------
+DbNumericField::DbNumericField( DbGridColumn& _rColumn )
+ :DbSpinField( _rColumn )
+{
+ doPropertyListening( FM_PROP_DECIMAL_ACCURACY );
+ doPropertyListening( FM_PROP_VALUEMIN );
+ doPropertyListening( FM_PROP_VALUEMAX );
+ doPropertyListening( FM_PROP_VALUESTEP );
+ doPropertyListening( FM_PROP_STRICTFORMAT );
+ doPropertyListening( FM_PROP_SHOWTHOUSANDSEP );
+}
+
+//------------------------------------------------------------------------------
+void DbNumericField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
+{
+ DBG_ASSERT( m_pWindow, "DbNumericField::implAdjustGenericFieldSetting: not to be called without window!" );
+ DBG_ASSERT( _rxModel.is(), "DbNumericField::implAdjustGenericFieldSetting: invalid model!" );
+ if ( m_pWindow && _rxModel.is() )
+ {
+ sal_Int32 nMin = (sal_Int32)getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMIN ) );
+ sal_Int32 nMax = (sal_Int32)getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMAX ) );
+ sal_Int32 nStep = (sal_Int32)getDouble( _rxModel->getPropertyValue( FM_PROP_VALUESTEP ) );
+ sal_Bool bStrict = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
+ sal_Int16 nScale = getINT16( _rxModel->getPropertyValue( FM_PROP_DECIMAL_ACCURACY ) );
+ sal_Bool bThousand = getBOOL( _rxModel->getPropertyValue( FM_PROP_SHOWTHOUSANDSEP ) );
+
+ static_cast< DoubleNumericField* >( m_pWindow )->SetMinValue(nMin);
+ static_cast< DoubleNumericField* >( m_pWindow )->SetMaxValue(nMax);
+ static_cast< DoubleNumericField* >( m_pWindow )->SetSpinSize(nStep);
+ static_cast< DoubleNumericField* >( m_pWindow )->SetStrictFormat(bStrict);
+
+ static_cast< DoubleNumericField* >( m_pPainter )->SetMinValue(nMin);
+ static_cast< DoubleNumericField* >( m_pPainter )->SetMaxValue(nMax);
+ static_cast< DoubleNumericField* >( m_pPainter )->SetStrictFormat(bStrict);
+
+
+ // dem Field und dem Painter einen Formatter spendieren
+ // zuerst testen, ob ich von dem Service hinter einer Connection bekommen kann
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier;
+ Reference< XRowSet > xForm;
+ if ( m_rColumn.GetParent().getDataSource() )
+ xForm = Reference< XRowSet >( ( Reference< XInterface > )*m_rColumn.GetParent().getDataSource(), UNO_QUERY );
+ if ( xForm.is() )
+ xSupplier = getNumberFormats( getRowSetConnection( xForm ), sal_True );
+ SvNumberFormatter* pFormatterUsed = NULL;
+ if ( xSupplier.is() )
+ {
+ SvNumberFormatsSupplierObj* pImplmentation = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
+ pFormatterUsed = pImplmentation ? pImplmentation->GetNumberFormatter() : NULL;
+ }
+ if ( NULL == pFormatterUsed )
+ { // der Cursor fuehrte nicht zum Erfolg -> Standard
+ pFormatterUsed = static_cast< DoubleNumericField* >( m_pWindow )->StandardFormatter();
+ DBG_ASSERT( pFormatterUsed != NULL, "DbNumericField::implAdjustGenericFieldSetting: no standard formatter given by the numeric field !" );
+ }
+ static_cast< DoubleNumericField* >( m_pWindow )->SetFormatter( pFormatterUsed );
+ static_cast< DoubleNumericField* >( m_pPainter )->SetFormatter( pFormatterUsed );
+
+ // und dann ein Format generieren, dass die gewuenschten Nachkommastellen usw. hat
+ String sFormatString;
+ LanguageType aAppLanguage = Application::GetSettings().GetUILanguage();
+ pFormatterUsed->GenerateFormat( sFormatString, 0, aAppLanguage, bThousand, sal_False, nScale );
+
+ static_cast< DoubleNumericField* >( m_pWindow )->SetFormat( sFormatString, aAppLanguage );
+ static_cast< DoubleNumericField* >( m_pPainter )->SetFormat( sFormatString, aAppLanguage );
+ }
+}
+
+//------------------------------------------------------------------------------
+SpinField* DbNumericField::createField( Window* _pParent, WinBits _nFieldStyle, const Reference< XPropertySet >& /*_rxModel*/ )
+{
+ return new DoubleNumericField( _pParent, _nFieldStyle );
+}
+
+namespace
+{
+ //--------------------------------------------------------------------------
+ static String lcl_setFormattedNumeric_nothrow( DoubleNumericField& _rField, const DbCellControl& _rControl,
+ const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
+ {
+ String sValue;
+ if ( _rxField.is() )
+ {
+ try
+ {
+ double fValue = _rControl.GetValue( _rxField, _rxFormatter );
+ if ( !_rxField->wasNull() )
+ {
+ _rField.SetValue( fValue );
+ sValue = _rField.GetText();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return sValue;
+ }
+}
+
+//------------------------------------------------------------------------------
+String DbNumericField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter, Color** /*ppColor*/)
+{
+ return lcl_setFormattedNumeric_nothrow( *dynamic_cast< DoubleNumericField* >( m_pPainter ), *this, _rxField, _rxFormatter );
+}
+
+//------------------------------------------------------------------------------
+void DbNumericField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter)
+{
+ lcl_setFormattedNumeric_nothrow( *dynamic_cast< DoubleNumericField* >( m_pWindow ), *this, _rxField, _rxFormatter );
+}
+
+//------------------------------------------------------------------------------
+void DbNumericField::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbNumericField::updateFromModel: invalid call!" );
+
+ double dValue = 0;
+ if ( _rxModel->getPropertyValue( FM_PROP_VALUE ) >>= dValue )
+ static_cast< DoubleNumericField* >( m_pWindow )->SetValue( dValue );
+ else
+ m_pWindow->SetText( String() );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbNumericField::commitControl()
+{
+ String aText( m_pWindow->GetText());
+ Any aVal;
+
+ if (aText.Len() != 0) // nicht null
+ {
+ double fValue = ((DoubleNumericField*)m_pWindow)->GetValue();
+ aVal <<= (double)fValue;
+ }
+ m_rColumn.getModel()->setPropertyValue(FM_PROP_VALUE, aVal);
+ return sal_True;
+}
+
+//==============================================================================
+//= DbCurrencyField
+//==============================================================================
+//------------------------------------------------------------------------------
+DbCurrencyField::DbCurrencyField(DbGridColumn& _rColumn)
+ :DbSpinField( _rColumn )
+ ,m_nScale( 0 )
+{
+ doPropertyListening( FM_PROP_DECIMAL_ACCURACY );
+ doPropertyListening( FM_PROP_VALUEMIN );
+ doPropertyListening( FM_PROP_VALUEMAX );
+ doPropertyListening( FM_PROP_VALUESTEP );
+ doPropertyListening( FM_PROP_STRICTFORMAT );
+ doPropertyListening( FM_PROP_SHOWTHOUSANDSEP );
+ doPropertyListening( FM_PROP_CURRENCYSYMBOL );
+}
+
+//------------------------------------------------------------------------------
+void DbCurrencyField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
+{
+ DBG_ASSERT( m_pWindow, "DbCurrencyField::implAdjustGenericFieldSetting: not to be called without window!" );
+ DBG_ASSERT( _rxModel.is(), "DbCurrencyField::implAdjustGenericFieldSetting: invalid model!" );
+ if ( m_pWindow && _rxModel.is() )
+ {
+ m_nScale = getINT16( _rxModel->getPropertyValue( FM_PROP_DECIMAL_ACCURACY ) );
+ double nMin = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMIN ) );
+ double nMax = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMAX ) );
+ double nStep = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUESTEP ) );
+ sal_Bool bStrict = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
+ sal_Bool bThousand = getBOOL( _rxModel->getPropertyValue( FM_PROP_SHOWTHOUSANDSEP ) );
+ ::rtl::OUString aStr( getString( _rxModel->getPropertyValue(FM_PROP_CURRENCYSYMBOL ) ) );
+
+ static_cast< LongCurrencyField* >( m_pWindow )->SetUseThousandSep( bThousand );
+ static_cast< LongCurrencyField* >( m_pWindow )->SetDecimalDigits( m_nScale );
+ static_cast< LongCurrencyField* >( m_pWindow )->SetCurrencySymbol( aStr );
+ static_cast< LongCurrencyField* >( m_pWindow )->SetFirst( nMin );
+ static_cast< LongCurrencyField* >( m_pWindow )->SetLast( nMax );
+ static_cast< LongCurrencyField* >( m_pWindow )->SetMin( nMin );
+ static_cast< LongCurrencyField* >( m_pWindow )->SetMax( nMax );
+ static_cast< LongCurrencyField* >( m_pWindow )->SetSpinSize( nStep );
+ static_cast< LongCurrencyField* >( m_pWindow )->SetStrictFormat( bStrict );
+
+ static_cast< LongCurrencyField* >( m_pPainter )->SetUseThousandSep( bThousand );
+ static_cast< LongCurrencyField* >( m_pPainter )->SetDecimalDigits( m_nScale );
+ static_cast< LongCurrencyField* >( m_pPainter )->SetCurrencySymbol( aStr );
+ static_cast< LongCurrencyField* >( m_pPainter )->SetFirst( nMin );
+ static_cast< LongCurrencyField* >( m_pPainter )->SetLast( nMax );
+ static_cast< LongCurrencyField* >( m_pPainter )->SetMin( nMin );
+ static_cast< LongCurrencyField* >( m_pPainter )->SetMax( nMax );
+ static_cast< LongCurrencyField* >( m_pPainter )->SetStrictFormat( bStrict );
+ }
+}
+
+//------------------------------------------------------------------------------
+SpinField* DbCurrencyField::createField( Window* _pParent, WinBits _nFieldStyle, const Reference< XPropertySet >& /*_rxModel*/ )
+{
+ return new LongCurrencyField( _pParent, _nFieldStyle );
+}
+
+//------------------------------------------------------------------------------
+double DbCurrencyField::GetCurrency(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter) const
+{
+ double fValue = GetValue(_rxField, xFormatter);
+ if (m_nScale)
+ {
+ // OSL_TRACE("double = %.64f ",fValue);
+ fValue = ::rtl::math::pow10Exp(fValue, m_nScale);
+ fValue = ::rtl::math::round(fValue, 0);
+ }
+ return fValue;
+}
+
+namespace
+{
+ //--------------------------------------------------------------------------
+ static String lcl_setFormattedCurrency_nothrow( LongCurrencyField& _rField, const DbCurrencyField& _rControl,
+ const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
+ {
+ String sValue;
+ if ( _rxField.is() )
+ {
+ try
+ {
+ double fValue = _rControl.GetCurrency( _rxField, _rxFormatter );
+ if ( !_rxField->wasNull() )
+ {
+ _rField.SetValue( fValue );
+ BigInt aValue = _rField.GetCorrectedValue();
+ sValue = aValue.GetString();
+ sValue = _rField.GetText();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return sValue;
+ }
+}
+
+//------------------------------------------------------------------------------
+String DbCurrencyField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter, Color** /*ppColor*/)
+{
+ return lcl_setFormattedCurrency_nothrow( *dynamic_cast< LongCurrencyField* >( m_pPainter ), *this, _rxField, _rxFormatter );
+}
+
+//------------------------------------------------------------------------------
+void DbCurrencyField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter)
+{
+ lcl_setFormattedCurrency_nothrow( *dynamic_cast< LongCurrencyField* >( m_pWindow ), *this, _rxField, _rxFormatter );
+}
+
+//------------------------------------------------------------------------------
+void DbCurrencyField::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCurrencyField::updateFromModel: invalid call!" );
+
+ double dValue = 0;
+ if ( _rxModel->getPropertyValue( FM_PROP_VALUE ) >>= dValue )
+ {
+ if ( m_nScale )
+ {
+ dValue = ::rtl::math::pow10Exp( dValue, m_nScale );
+ dValue = ::rtl::math::round(dValue, 0);
+ }
+
+ static_cast< LongCurrencyField* >( m_pWindow )->SetValue( dValue );
+ }
+ else
+ m_pWindow->SetText( String() );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbCurrencyField::commitControl()
+{
+ String aText( m_pWindow->GetText());
+ Any aVal;
+ if (aText.Len() != 0) // nicht null
+ {
+ double fValue = ((LongCurrencyField*)m_pWindow)->GetValue();
+ if (m_nScale)
+ {
+ fValue /= ::rtl::math::pow10Exp(1.0, m_nScale);
+ //fValue = ::rtl::math::round(fValue, m_nScale);
+ }
+ aVal <<= (double)fValue;
+ }
+ m_rColumn.getModel()->setPropertyValue(FM_PROP_VALUE, aVal);
+ return sal_True;
+}
+
+//==============================================================================
+//= DbDateField
+//==============================================================================
+//------------------------------------------------------------------------------
+DbDateField::DbDateField( DbGridColumn& _rColumn )
+ :DbSpinField( _rColumn )
+{
+ doPropertyListening( FM_PROP_DATEFORMAT );
+ doPropertyListening( FM_PROP_DATEMIN );
+ doPropertyListening( FM_PROP_DATEMAX );
+ doPropertyListening( FM_PROP_STRICTFORMAT );
+ doPropertyListening( FM_PROP_DATE_SHOW_CENTURY );
+}
+
+//------------------------------------------------------------------------------
+SpinField* DbDateField::createField( Window* _pParent, WinBits _nFieldStyle, const Reference< XPropertySet >& _rxModel )
+{
+ // check if there is a DropDown property set to TRUE
+ sal_Bool bDropDown = !hasProperty( FM_PROP_DROPDOWN, _rxModel )
+ || getBOOL( _rxModel->getPropertyValue( FM_PROP_DROPDOWN ) );
+ if ( bDropDown )
+ _nFieldStyle |= WB_DROPDOWN;
+
+ CalendarField* pField = new CalendarField( _pParent, _nFieldStyle );
+
+ pField->EnableToday();
+ pField->EnableNone();
+
+ return pField;
+}
+
+//------------------------------------------------------------------------------
+void DbDateField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
+{
+ DBG_ASSERT( m_pWindow, "DbDateField::implAdjustGenericFieldSetting: not to be called without window!" );
+ DBG_ASSERT( _rxModel.is(), "DbDateField::implAdjustGenericFieldSetting: invalid model!" );
+ if ( m_pWindow && _rxModel.is() )
+ {
+ sal_Int16 nFormat = getINT16( _rxModel->getPropertyValue( FM_PROP_DATEFORMAT ) );
+ sal_Int32 nMin = getINT32( _rxModel->getPropertyValue( FM_PROP_DATEMIN ) );
+ sal_Int32 nMax = getINT32( _rxModel->getPropertyValue( FM_PROP_DATEMAX ) );
+ sal_Bool bStrict = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
+
+ Any aCentury = _rxModel->getPropertyValue( FM_PROP_DATE_SHOW_CENTURY );
+ if ( aCentury.getValueType().getTypeClass() != TypeClass_VOID )
+ {
+ sal_Bool bShowDateCentury = getBOOL( aCentury );
+
+ static_cast<DateField*>( m_pWindow )->SetShowDateCentury( bShowDateCentury );
+ static_cast<DateField*>( m_pPainter )->SetShowDateCentury( bShowDateCentury );
+ }
+
+ static_cast< DateField* >( m_pWindow )->SetExtDateFormat( (ExtDateFieldFormat)nFormat );
+ static_cast< DateField* >( m_pWindow )->SetMin( nMin );
+ static_cast< DateField* >( m_pWindow )->SetMax( nMax );
+ static_cast< DateField* >( m_pWindow )->SetStrictFormat( bStrict );
+ static_cast< DateField* >( m_pWindow )->EnableEmptyFieldValue( TRUE );
+
+ static_cast< DateField* >( m_pPainter )->SetExtDateFormat( (ExtDateFieldFormat)nFormat );
+ static_cast< DateField* >( m_pPainter )->SetMin( nMin );
+ static_cast< DateField* >( m_pPainter )->SetMax( nMax );
+ static_cast< DateField* >( m_pPainter )->SetStrictFormat( bStrict );
+ static_cast< DateField* >( m_pPainter )->EnableEmptyFieldValue( TRUE );
+ }
+}
+
+namespace
+{
+ //--------------------------------------------------------------------------
+ static String lcl_setFormattedDate_nothrow( DateField& _rField, const Reference< XColumn >& _rxField )
+ {
+ String sDate;
+ if ( _rxField.is() )
+ {
+ try
+ {
+ ::com::sun::star::util::Date aValue = _rxField->getDate();
+ if ( _rxField->wasNull() )
+ _rField.SetText( sDate );
+ else
+ {
+ _rField.SetDate( ::Date( aValue.Day, aValue.Month, aValue.Year ) );
+ sDate = _rField.GetText();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return sDate;
+ }
+}
+//------------------------------------------------------------------------------
+String DbDateField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
+{
+ return lcl_setFormattedDate_nothrow( *dynamic_cast< DateField* >( m_pPainter ), _rxField );
+}
+
+//------------------------------------------------------------------------------
+void DbDateField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
+{
+ lcl_setFormattedDate_nothrow( *dynamic_cast< DateField* >( m_pWindow ), _rxField );
+}
+
+//------------------------------------------------------------------------------
+void DbDateField::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbDateField::updateFromModel: invalid call!" );
+
+ sal_Int32 nDate = 0;
+ if ( _rxModel->getPropertyValue( FM_PROP_DATE ) >>= nDate )
+ static_cast< DateField* >( m_pWindow )->SetDate( ::Date( nDate ) );
+ else
+ static_cast< DateField* >( m_pWindow )->SetText( String() );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbDateField::commitControl()
+{
+ String aText( m_pWindow->GetText());
+ Any aVal;
+ if (aText.Len() != 0)
+ aVal <<= (sal_Int32)static_cast<DateField*>(m_pWindow)->GetDate().GetDate();
+ else
+ aVal.clear();
+
+ m_rColumn.getModel()->setPropertyValue(FM_PROP_DATE, aVal);
+ return sal_True;
+}
+
+//==============================================================================
+//= DbTimeField
+//==============================================================================
+//------------------------------------------------------------------------------
+DbTimeField::DbTimeField( DbGridColumn& _rColumn )
+ :DbSpinField( _rColumn, ::com::sun::star::awt::TextAlign::LEFT )
+{
+ doPropertyListening( FM_PROP_TIMEFORMAT );
+ doPropertyListening( FM_PROP_TIMEMIN );
+ doPropertyListening( FM_PROP_TIMEMAX );
+ doPropertyListening( FM_PROP_STRICTFORMAT );
+}
+
+//------------------------------------------------------------------------------
+SpinField* DbTimeField::createField( Window* _pParent, WinBits _nFieldStyle, const Reference< XPropertySet >& /*_rxModel*/ )
+{
+ return new TimeField( _pParent, _nFieldStyle );
+}
+
+//------------------------------------------------------------------------------
+void DbTimeField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
+{
+ DBG_ASSERT( m_pWindow, "DbTimeField::implAdjustGenericFieldSetting: not to be called without window!" );
+ DBG_ASSERT( _rxModel.is(), "DbTimeField::implAdjustGenericFieldSetting: invalid model!" );
+ if ( m_pWindow && _rxModel.is() )
+ {
+ sal_Int16 nFormat = getINT16( _rxModel->getPropertyValue( FM_PROP_TIMEFORMAT ) );
+ sal_Int32 nMin = getINT32( _rxModel->getPropertyValue( FM_PROP_TIMEMIN ) );
+ sal_Int32 nMax = getINT32( _rxModel->getPropertyValue( FM_PROP_TIMEMAX ) );
+ sal_Bool bStrict = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
+
+ static_cast< TimeField* >( m_pWindow )->SetExtFormat( (ExtTimeFieldFormat)nFormat );
+ static_cast< TimeField* >( m_pWindow )->SetMin( nMin );
+ static_cast< TimeField* >( m_pWindow )->SetMax( nMax );
+ static_cast< TimeField* >( m_pWindow )->SetStrictFormat( bStrict );
+ static_cast< TimeField* >( m_pWindow )->EnableEmptyFieldValue( TRUE );
+
+ static_cast< TimeField* >( m_pPainter )->SetExtFormat( (ExtTimeFieldFormat)nFormat );
+ static_cast< TimeField* >( m_pPainter )->SetMin( nMin );
+ static_cast< TimeField* >( m_pPainter )->SetMax( nMax );
+ static_cast< TimeField* >( m_pPainter )->SetStrictFormat( bStrict );
+ static_cast< TimeField* >( m_pPainter )->EnableEmptyFieldValue( TRUE );
+ }
+}
+
+namespace
+{
+ //--------------------------------------------------------------------------
+ static String lcl_setFormattedTime_nothrow( TimeField& _rField, const Reference< XColumn >& _rxField )
+ {
+ String sTime;
+ if ( _rxField.is() )
+ {
+ try
+ {
+ ::com::sun::star::util::Time aValue = _rxField->getTime();
+ if ( _rxField->wasNull() )
+ _rField.SetText( sTime );
+ else
+ {
+ _rField.SetTime( ::Time( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.HundredthSeconds ) );
+ sTime = _rField.GetText();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return sTime;
+ }
+}
+//------------------------------------------------------------------------------
+String DbTimeField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
+{
+ return lcl_setFormattedTime_nothrow( *static_cast< TimeField* >( m_pPainter ), _rxField );
+}
+
+//------------------------------------------------------------------------------
+void DbTimeField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
+{
+ lcl_setFormattedTime_nothrow( *static_cast< TimeField* >( m_pWindow ), _rxField );
+}
+
+//------------------------------------------------------------------------------
+void DbTimeField::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbTimeField::updateFromModel: invalid call!" );
+
+ sal_Int32 nTime = 0;
+ if ( _rxModel->getPropertyValue( FM_PROP_DATE ) >>= nTime )
+ static_cast< TimeField* >( m_pWindow )->SetTime( ::Time( nTime ) );
+ else
+ static_cast< TimeField* >( m_pWindow )->SetText( String() );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbTimeField::commitControl()
+{
+ String aText( m_pWindow->GetText());
+ Any aVal;
+ if (aText.Len() != 0)
+ aVal <<= (sal_Int32)static_cast<TimeField*>(m_pWindow)->GetTime().GetTime();
+ else
+ aVal.clear();
+
+ m_rColumn.getModel()->setPropertyValue(FM_PROP_TIME, aVal);
+ return sal_True;
+}
+
+//==============================================================================
+//= DbComboBox
+//==============================================================================
+//------------------------------------------------------------------------------
+DbComboBox::DbComboBox(DbGridColumn& _rColumn)
+ :DbCellControl(_rColumn)
+ ,m_nKeyType(::com::sun::star::util::NumberFormat::UNDEFINED)
+{
+ setAlignedController( sal_False );
+
+ doPropertyListening( FM_PROP_STRINGITEMLIST );
+ doPropertyListening( FM_PROP_LINECOUNT );
+}
+
+//------------------------------------------------------------------------------
+void DbComboBox::_propertyChanged( const PropertyChangeEvent& _rEvent ) throw( RuntimeException )
+{
+ if ( _rEvent.PropertyName.equals( FM_PROP_STRINGITEMLIST ) )
+ {
+ SetList(_rEvent.NewValue);
+ }
+ else
+ {
+ DbCellControl::_propertyChanged( _rEvent ) ;
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbComboBox::SetList(const Any& rItems)
+{
+ ComboBoxControl* pField = (ComboBoxControl*)m_pWindow;
+ pField->Clear();
+
+ ::comphelper::StringSequence aTest;
+ if (rItems >>= aTest)
+ {
+ const ::rtl::OUString* pStrings = aTest.getConstArray();
+ sal_Int32 nItems = aTest.getLength();
+ for (sal_Int32 i = 0; i < nItems; ++i, ++pStrings )
+ pField->InsertEntry(*pStrings, LISTBOX_APPEND);
+
+ // tell the grid control that this controller is invalid and has to be re-initialized
+ invalidatedController();
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbComboBox::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
+{
+ DBG_ASSERT( m_pWindow, "DbComboBox::implAdjustGenericFieldSetting: not to be called without window!" );
+ DBG_ASSERT( _rxModel.is(), "DbComboBox::implAdjustGenericFieldSetting: invalid model!" );
+ if ( m_pWindow && _rxModel.is() )
+ {
+ sal_Int16 nLines = getINT16( _rxModel->getPropertyValue( FM_PROP_LINECOUNT ) );
+ static_cast< ComboBoxControl* >( m_pWindow )->SetDropDownLineCount( nLines );
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbComboBox::Init( Window& rParent, const Reference< XRowSet >& xCursor )
+{
+ m_rColumn.SetAlignmentFromModel(::com::sun::star::awt::TextAlign::LEFT);
+
+ m_pWindow = new ComboBoxControl( &rParent );
+
+ // selection von rechts nach links
+ AllSettings aSettings = m_pWindow->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.SetSelectionOptions(
+ aStyleSettings.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST);
+ aSettings.SetStyleSettings(aStyleSettings);
+ m_pWindow->SetSettings(aSettings, sal_True);
+
+ // some initial properties
+ Reference< XPropertySet > xModel(m_rColumn.getModel());
+ SetList( xModel->getPropertyValue( FM_PROP_STRINGITEMLIST ) );
+ implAdjustGenericFieldSetting( xModel );
+
+ if (m_rColumn.GetParent().getNumberFormatter().is())
+ m_nKeyType = comphelper::getNumberFormatType(m_rColumn.GetParent().getNumberFormatter()->getNumberFormatsSupplier()->getNumberFormats(), m_rColumn.GetKey());
+
+ DbCellControl::Init( rParent, xCursor );
+}
+
+//------------------------------------------------------------------------------
+CellControllerRef DbComboBox::CreateController() const
+{
+ return new ComboBoxCellController((ComboBoxControl*)m_pWindow);
+}
+
+//------------------------------------------------------------------------------
+String DbComboBox::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter, Color** /*ppColor*/)
+{
+ ::rtl::OUString aString;
+ if (_rxField.is())
+ try
+ {
+ aString = getValue( _rxField, xFormatter, m_rColumn.GetParent().getNullDate(), m_rColumn.GetKey(), m_nKeyType );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aString;
+}
+
+//------------------------------------------------------------------------------
+void DbComboBox::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter)
+{
+ m_pWindow->SetText(GetFormatText(_rxField, xFormatter));
+}
+
+//------------------------------------------------------------------------------
+void DbComboBox::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbComboBox::updateFromModel: invalid call!" );
+
+ ::rtl::OUString sText;
+ _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText;
+
+ static_cast< ComboBox* >( m_pWindow )->SetText( sText );
+ static_cast< ComboBox* >( m_pWindow )->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbComboBox::commitControl()
+{
+ String aText( m_pWindow->GetText());
+ m_rColumn.getModel()->setPropertyValue(FM_PROP_TEXT, makeAny(::rtl::OUString(aText)));
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+DbListBox::DbListBox(DbGridColumn& _rColumn)
+ :DbCellControl(_rColumn)
+ ,m_bBound(sal_False)
+{
+ setAlignedController( sal_False );
+
+ doPropertyListening( FM_PROP_STRINGITEMLIST );
+ doPropertyListening( FM_PROP_LINECOUNT );
+}
+
+//------------------------------------------------------------------------------
+void DbListBox::_propertyChanged( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ) throw( RuntimeException )
+{
+ if ( _rEvent.PropertyName.equals( FM_PROP_STRINGITEMLIST ) )
+ {
+ SetList(_rEvent.NewValue);
+ }
+ else
+ {
+ DbCellControl::_propertyChanged( _rEvent ) ;
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbListBox::SetList(const Any& rItems)
+{
+ ListBoxControl* pField = (ListBoxControl*)m_pWindow;
+
+ pField->Clear();
+ m_bBound = sal_False;
+
+ ::comphelper::StringSequence aTest;
+ if (rItems >>= aTest)
+ {
+ const ::rtl::OUString* pStrings = aTest.getConstArray();
+ sal_Int32 nItems = aTest.getLength();
+ if (nItems)
+ {
+ for (sal_Int32 i = 0; i < nItems; ++i, ++pStrings )
+ pField->InsertEntry(*pStrings, LISTBOX_APPEND);
+
+ m_rColumn.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ) >>= m_aValueList;
+ m_bBound = m_aValueList.getLength() > 0;
+
+ // tell the grid control that this controller is invalid and has to be re-initialized
+ invalidatedController();
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbListBox::Init( Window& rParent, const Reference< XRowSet >& xCursor)
+{
+ m_rColumn.SetAlignment(::com::sun::star::awt::TextAlign::LEFT);
+
+ m_pWindow = new ListBoxControl( &rParent );
+
+ // some initial properties
+ Reference< XPropertySet > xModel( m_rColumn.getModel() );
+ SetList( xModel->getPropertyValue( FM_PROP_STRINGITEMLIST ) );
+ implAdjustGenericFieldSetting( xModel );
+
+ DbCellControl::Init( rParent, xCursor );
+}
+
+//------------------------------------------------------------------------------
+void DbListBox::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
+{
+ DBG_ASSERT( m_pWindow, "DbListBox::implAdjustGenericFieldSetting: not to be called without window!" );
+ DBG_ASSERT( _rxModel.is(), "DbListBox::implAdjustGenericFieldSetting: invalid model!" );
+ if ( m_pWindow && _rxModel.is() )
+ {
+ sal_Int16 nLines = getINT16( _rxModel->getPropertyValue( FM_PROP_LINECOUNT ) );
+ static_cast< ListBoxControl* >( m_pWindow )->SetDropDownLineCount( nLines );
+ }
+}
+
+//------------------------------------------------------------------------------
+CellControllerRef DbListBox::CreateController() const
+{
+ return new ListBoxCellController((ListBoxControl*)m_pWindow);
+}
+
+//------------------------------------------------------------------------------
+String DbListBox::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
+{
+ String sText;
+ if ( _rxField.is() )
+ {
+ try
+ {
+ sText = _rxField->getString();
+ if ( m_bBound )
+ {
+ Sequence< sal_Int16 > aPosSeq = ::comphelper::findValue( m_aValueList, sText, sal_True );
+ if ( aPosSeq.getLength() )
+ sText = static_cast<ListBox*>(m_pWindow)->GetEntry(aPosSeq.getConstArray()[0]);
+ else
+ sText = String();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return sText;
+}
+
+//------------------------------------------------------------------------------
+void DbListBox::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter)
+{
+ String sFormattedText( GetFormatText( _rxField, xFormatter ) );
+ if ( sFormattedText.Len() )
+ static_cast< ListBox* >( m_pWindow )->SelectEntry( sFormattedText );
+ else
+ static_cast< ListBox* >( m_pWindow )->SetNoSelection();
+}
+
+//------------------------------------------------------------------------------
+void DbListBox::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbListBox::updateFromModel: invalid call!" );
+
+ Sequence< sal_Int16 > aSelection;
+ _rxModel->getPropertyValue( FM_PROP_SELECT_SEQ );
+
+ sal_Int16 nSelection = -1;
+ if ( aSelection.getLength() > 0 )
+ nSelection = aSelection[ 0 ];
+
+ ListBox* pListBox = static_cast< ListBox* >( m_pWindow );
+
+ if ( ( nSelection >= 0 ) && ( nSelection < pListBox->GetEntryCount() ) )
+ pListBox->SelectEntryPos( nSelection );
+ else
+ pListBox->SetNoSelection( );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbListBox::commitControl()
+{
+ Any aVal;
+ Sequence<sal_Int16> aSelectSeq;
+ if (static_cast<ListBox*>(m_pWindow)->GetSelectEntryCount())
+ {
+ aSelectSeq.realloc(1);
+ *(sal_Int16 *)aSelectSeq.getArray() = (sal_Int16)static_cast<ListBox*>(m_pWindow)->GetSelectEntryPos();
+ }
+ aVal <<= aSelectSeq;
+ m_rColumn.getModel()->setPropertyValue(FM_PROP_SELECT_SEQ, aVal);
+ return sal_True;
+}
+
+
+DBG_NAME(DbFilterField);
+/*************************************************************************/
+DbFilterField::DbFilterField(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,DbGridColumn& _rColumn)
+ :DbCellControl(_rColumn)
+ ,OSQLParserClient(_rxORB)
+ ,m_nControlClass(::com::sun::star::form::FormComponentType::TEXTFIELD)
+ ,m_bFilterList(sal_False)
+ ,m_bFilterListFilled(sal_False)
+ ,m_bBound(sal_False)
+{
+ DBG_CTOR(DbFilterField,NULL);
+
+ setAlignedController( sal_False );
+}
+
+//------------------------------------------------------------------------------
+DbFilterField::~DbFilterField()
+{
+ if (m_nControlClass == ::com::sun::star::form::FormComponentType::CHECKBOX)
+ ((CheckBoxControl*)m_pWindow)->SetClickHdl( Link() );
+
+ DBG_DTOR(DbFilterField,NULL);
+}
+
+//------------------------------------------------------------------------------
+void DbFilterField::PaintCell(OutputDevice& rDev, const Rectangle& rRect)
+{
+ static sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_VCENTER | TEXT_DRAW_LEFT;
+ switch (m_nControlClass)
+ {
+ case FormComponentType::CHECKBOX:
+ DbCellControl::PaintCell( rDev, rRect );
+ break;
+ case FormComponentType::LISTBOX:
+ rDev.DrawText(rRect, static_cast<ListBox*>(m_pWindow)->GetSelectEntry(), nStyle);
+ break;
+ default:
+ rDev.DrawText(rRect, m_aText, nStyle);
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbFilterField::SetList(const Any& rItems, sal_Bool bComboBox)
+{
+ ::comphelper::StringSequence aTest;
+ rItems >>= aTest;
+ const ::rtl::OUString* pStrings = aTest.getConstArray();
+ sal_Int32 nItems = aTest.getLength();
+ if (nItems)
+ {
+ if (bComboBox)
+ {
+ ComboBox* pField = (ComboBox*)m_pWindow;
+ for (sal_Int32 i = 0; i < nItems; ++i, ++pStrings )
+ pField->InsertEntry(*pStrings, LISTBOX_APPEND);
+ }
+ else
+ {
+ ListBox* pField = (ListBox*)m_pWindow;
+ for (sal_Int32 i = 0; i < nItems; ++i, ++pStrings )
+ pField->InsertEntry(*pStrings, LISTBOX_APPEND);
+
+ m_rColumn.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ) >>= m_aValueList;
+ m_bBound = m_aValueList.getLength() > 0;
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbFilterField::CreateControl(Window* pParent, const Reference< ::com::sun::star::beans::XPropertySet >& xModel)
+{
+ switch (m_nControlClass)
+ {
+ case ::com::sun::star::form::FormComponentType::CHECKBOX:
+ m_pWindow = new CheckBoxControl(pParent);
+ m_pWindow->SetPaintTransparent( sal_True );
+ ((CheckBoxControl*)m_pWindow)->SetClickHdl( LINK( this, DbFilterField, OnClick ) );
+
+ m_pPainter = new CheckBoxControl(pParent);
+ m_pPainter->SetPaintTransparent( sal_True );
+ m_pPainter->SetBackground();
+ break;
+ case ::com::sun::star::form::FormComponentType::LISTBOX:
+ {
+ m_pWindow = new ListBoxControl(pParent);
+ sal_Int16 nLines = ::comphelper::getINT16(xModel->getPropertyValue(FM_PROP_LINECOUNT));
+ Any aItems = xModel->getPropertyValue(FM_PROP_STRINGITEMLIST);
+ SetList(aItems, m_nControlClass == ::com::sun::star::form::FormComponentType::COMBOBOX);
+ static_cast<ListBox*>(m_pWindow)->SetDropDownLineCount(nLines);
+ } break;
+ case ::com::sun::star::form::FormComponentType::COMBOBOX:
+ {
+ m_pWindow = new ComboBoxControl(pParent);
+
+ AllSettings aSettings = m_pWindow->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.SetSelectionOptions(
+ aStyleSettings.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST);
+ aSettings.SetStyleSettings(aStyleSettings);
+ m_pWindow->SetSettings(aSettings, sal_True);
+
+ if (!m_bFilterList)
+ {
+ sal_Int16 nLines = ::comphelper::getINT16(xModel->getPropertyValue(FM_PROP_LINECOUNT));
+ Any aItems = xModel->getPropertyValue(FM_PROP_STRINGITEMLIST);
+ SetList(aItems, m_nControlClass == ::com::sun::star::form::FormComponentType::COMBOBOX);
+ ((ComboBox*)m_pWindow)->SetDropDownLineCount(nLines);
+ }
+ else
+ ((ComboBox*)m_pWindow)->SetDropDownLineCount(5);
+
+ } break;
+ default:
+ {
+ m_pWindow = new Edit(pParent, WB_LEFT);
+ AllSettings aSettings = m_pWindow->GetSettings();
+ StyleSettings aStyleSettings = aSettings.GetStyleSettings();
+ aStyleSettings.SetSelectionOptions(
+ aStyleSettings.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST);
+ aSettings.SetStyleSettings(aStyleSettings);
+ m_pWindow->SetSettings(aSettings, sal_True);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbFilterField::Init( Window& rParent, const Reference< XRowSet >& xCursor )
+{
+ Reference< ::com::sun::star::beans::XPropertySet > xModel(m_rColumn.getModel());
+ m_rColumn.SetAlignment(::com::sun::star::awt::TextAlign::LEFT);
+
+ if (xModel.is())
+ {
+ m_bFilterList = ::comphelper::hasProperty(FM_PROP_FILTERPROPOSAL, xModel) && ::comphelper::getBOOL(xModel->getPropertyValue(FM_PROP_FILTERPROPOSAL));
+ if (m_bFilterList)
+ m_nControlClass = ::com::sun::star::form::FormComponentType::COMBOBOX;
+ else
+ {
+ sal_Int16 nClassId = ::comphelper::getINT16(xModel->getPropertyValue(FM_PROP_CLASSID));
+ switch (nClassId)
+ {
+ case FormComponentType::CHECKBOX:
+ case FormComponentType::LISTBOX:
+ case FormComponentType::COMBOBOX:
+ m_nControlClass = nClassId;
+ break;
+ default:
+ if (m_bFilterList)
+ m_nControlClass = FormComponentType::COMBOBOX;
+ else
+ m_nControlClass = FormComponentType::TEXTFIELD;
+ }
+ }
+ }
+
+ CreateControl( &rParent, xModel );
+ DbCellControl::Init( rParent, xCursor );
+
+ // filter cells are never readonly
+ // 31.07.2002 - 101584 - fs@openoffice.org
+ Edit* pAsEdit = dynamic_cast< Edit* >( m_pWindow );
+ if ( pAsEdit )
+ pAsEdit->SetReadOnly( sal_False );
+}
+
+//------------------------------------------------------------------------------
+CellControllerRef DbFilterField::CreateController() const
+{
+ CellControllerRef xController;
+ switch (m_nControlClass)
+ {
+ case ::com::sun::star::form::FormComponentType::CHECKBOX:
+ xController = new CheckBoxCellController((CheckBoxControl*)m_pWindow);
+ break;
+ case ::com::sun::star::form::FormComponentType::LISTBOX:
+ xController = new ListBoxCellController((ListBoxControl*)m_pWindow);
+ break;
+ case ::com::sun::star::form::FormComponentType::COMBOBOX:
+ xController = new ComboBoxCellController((ComboBoxControl*)m_pWindow);
+ break;
+ default:
+ if (m_bFilterList)
+ xController = new ComboBoxCellController((ComboBoxControl*)m_pWindow);
+ else
+ xController = new EditCellController((Edit*)m_pWindow);
+ }
+ return xController;
+}
+
+//------------------------------------------------------------------------------
+void DbFilterField::updateFromModel( Reference< XPropertySet > _rxModel )
+{
+ OSL_ENSURE( _rxModel.is() && m_pWindow, "DbFilterField::updateFromModel: invalid call!" );
+ (void)_rxModel;
+
+ OSL_ENSURE( sal_False, "DbListBox::updateFromModel: not implemented yet (how the hell did you reach this?)!" );
+ // TODO: implement this.
+ // remember: updateFromModel should be some kind of opposite of commitControl
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbFilterField::commitControl()
+{
+ String aText(m_aText);
+ switch (m_nControlClass)
+ {
+ case ::com::sun::star::form::FormComponentType::CHECKBOX:
+ return sal_True;
+ case ::com::sun::star::form::FormComponentType::LISTBOX:
+ if (static_cast<ListBox*>(m_pWindow)->GetSelectEntryCount())
+ {
+ sal_Int16 nPos = (sal_Int16)static_cast<ListBox*>(m_pWindow)->GetSelectEntryPos();
+ aText = (const sal_Unicode*)m_aValueList.getConstArray()[nPos];
+ }
+ else
+ aText.Erase();
+
+ if (m_aText != aText)
+ {
+ m_aText = aText;
+ m_aCommitLink.Call(this);
+ }
+ return sal_True;
+ default:
+ aText = m_pWindow->GetText();
+ }
+
+ if (m_aText != aText)
+ {
+ // check the text with the SQL-Parser
+ String aNewText(aText);
+ aNewText.EraseTrailingChars();
+ if (aNewText.Len() != 0)
+ {
+ ::rtl::OUString aErrorMsg;
+ Reference< XNumberFormatter > xNumberFormatter(m_rColumn.GetParent().getNumberFormatter());
+
+ ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree(aErrorMsg, aNewText,xNumberFormatter, m_rColumn.GetField());
+ if (xParseNode.is())
+ {
+ ::rtl::OUString aPreparedText;
+
+ ::com::sun::star::lang::Locale aAppLocale = Application::GetSettings().GetUILocale();
+
+ Reference< XRowSet > xDataSourceRowSet(
+ (Reference< XInterface >)*m_rColumn.GetParent().getDataSource(), UNO_QUERY);
+ Reference< XConnection > xConnection(getRowSetConnection(xDataSourceRowSet));
+
+ xParseNode->parseNodeToPredicateStr(aPreparedText,
+ xConnection,
+ xNumberFormatter,
+ m_rColumn.GetField(),aAppLocale,'.',
+ getParseContext());
+ m_aText = aPreparedText;
+ }
+ else
+ {
+ // display the error and return sal_False
+ String aTitle( SVX_RES(RID_STR_SYNTAXERROR) );
+
+ SQLException aError;
+ aError.Message = aErrorMsg;
+ displayException(aError, m_pWindow->GetParent());
+ // TODO: transport the title
+
+ return sal_False;
+ }
+ }
+ else
+ m_aText = aText;
+
+ m_pWindow->SetText(m_aText);
+ m_aCommitLink.Call(this);
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void DbFilterField::SetText(const String& rText)
+{
+ m_aText = rText;
+ switch (m_nControlClass)
+ {
+ case ::com::sun::star::form::FormComponentType::CHECKBOX:
+ {
+ TriState eState;
+ if (rText.EqualsAscii("1"))
+ eState = STATE_CHECK;
+ else if (rText.EqualsAscii("0"))
+ eState = STATE_NOCHECK;
+ else
+ eState = STATE_DONTKNOW;
+
+ ((CheckBoxControl*)m_pWindow)->GetBox().SetState(eState);
+ ((CheckBoxControl*)m_pPainter)->GetBox().SetState(eState);
+ } break;
+ case ::com::sun::star::form::FormComponentType::LISTBOX:
+ {
+ String aText;
+ Sequence<sal_Int16> aPosSeq = ::comphelper::findValue(m_aValueList, m_aText, sal_True);
+ if (aPosSeq.getLength())
+ static_cast<ListBox*>(m_pWindow)->SelectEntryPos(aPosSeq.getConstArray()[0], sal_True);
+ else
+ static_cast<ListBox*>(m_pWindow)->SetNoSelection();
+ } break;
+ default:
+ m_pWindow->SetText(m_aText);
+ }
+
+ // now force a repaint on the window
+ m_rColumn.GetParent().RowModified(0,m_rColumn.GetId());
+}
+
+//------------------------------------------------------------------------------
+void DbFilterField::Update()
+{
+ // should we fill the combobox with a filter proposal?
+ if (m_bFilterList && !m_bFilterListFilled)
+ {
+ m_bFilterListFilled = sal_True;
+ Reference< ::com::sun::star::beans::XPropertySet > xField = m_rColumn.GetField();
+ if (!xField.is())
+ return;
+
+ ::rtl::OUString aName;
+ xField->getPropertyValue(FM_PROP_NAME) >>= aName;
+
+ // the columnmodel
+ Reference< ::com::sun::star::container::XChild > xModelAsChild(m_rColumn.getModel(), UNO_QUERY);
+ // the grid model
+ xModelAsChild = Reference< ::com::sun::star::container::XChild > (xModelAsChild->getParent(),UNO_QUERY);
+ Reference< XRowSet > xForm(xModelAsChild->getParent(), UNO_QUERY);
+ if (!xForm.is())
+ return;
+
+ Reference<XPropertySet> xFormProp(xForm,UNO_QUERY);
+ Reference< XTablesSupplier > xSupTab;
+ xFormProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSupTab;
+
+ Reference< XConnection > xConnection(getRowSetConnection(xForm));
+ if (!xSupTab.is())
+ return;
+
+ // search the field
+ Reference< XColumnsSupplier > xSupCol(xSupTab,UNO_QUERY);
+ Reference< ::com::sun::star::container::XNameAccess > xFieldNames = xSupCol->getColumns();
+ if (!xFieldNames->hasByName(aName))
+ return;
+
+ Reference< ::com::sun::star::container::XNameAccess > xTablesNames = xSupTab->getTables();
+ Reference< ::com::sun::star::beans::XPropertySet > xComposerFieldAsSet(xFieldNames->getByName(aName),UNO_QUERY);
+
+ if (xComposerFieldAsSet.is() && ::comphelper::hasProperty(FM_PROP_TABLENAME, xComposerFieldAsSet) &&
+ ::comphelper::hasProperty(FM_PROP_FIELDSOURCE, xComposerFieldAsSet))
+ {
+ ::rtl::OUString aFieldName;
+ ::rtl::OUString aTableName;
+ xComposerFieldAsSet->getPropertyValue(FM_PROP_FIELDSOURCE) >>= aFieldName;
+ xComposerFieldAsSet->getPropertyValue(FM_PROP_TABLENAME) >>= aTableName;
+
+ // no possibility to create a select statement
+ // looking for the complete table name
+ if (!xTablesNames->hasByName(aTableName))
+ return;
+
+ // ein Statement aufbauen und abschicken als query
+ // Access to the connection
+ Reference< XStatement > xStatement;
+ Reference< XResultSet > xListCursor;
+ Reference< ::com::sun::star::sdb::XColumn > xDataField;
+
+ try
+ {
+ Reference< XDatabaseMetaData > xMeta = xConnection->getMetaData();
+
+ String aQuote( xMeta->getIdentifierQuoteString());
+ String aStatement;
+ aStatement.AssignAscii("SELECT DISTINCT ");
+
+ aStatement += String(quoteName(aQuote, aName));
+ if (aFieldName.getLength() && aName != aFieldName)
+ {
+ aStatement.AppendAscii(" AS ");
+ aStatement += quoteName(aQuote, aFieldName).getStr();
+ }
+
+ aStatement.AppendAscii(" FROM ");
+
+ Reference< XPropertySet > xTableNameAccess( xTablesNames->getByName(aTableName), UNO_QUERY_THROW );
+ aStatement += composeTableNameForSelect( xConnection, xTableNameAccess ).getStr();
+
+ xStatement = xConnection->createStatement();
+ Reference< ::com::sun::star::beans::XPropertySet > xStatementProps(xStatement, UNO_QUERY);
+ xStatementProps->setPropertyValue(FM_PROP_ESCAPE_PROCESSING, makeAny((sal_Bool)sal_True));
+
+ xListCursor = xStatement->executeQuery(aStatement);
+
+ Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xSupplyCols(xListCursor, UNO_QUERY);
+ Reference< ::com::sun::star::container::XIndexAccess > xFields(xSupplyCols->getColumns(), UNO_QUERY);
+ ::cppu::extractInterface(xDataField, xFields->getByIndex(0));
+ if (!xDataField.is())
+ return;
+ }
+ catch(const Exception&)
+ {
+ ::comphelper::disposeComponent(xStatement);
+ return;
+ }
+
+ sal_Int16 i = 0;
+ ::std::vector< ::rtl::OUString > aStringList;
+ aStringList.reserve(16);
+ ::rtl::OUString aStr;
+ com::sun::star::util::Date aNullDate = m_rColumn.GetParent().getNullDate();
+ sal_Int32 nFormatKey = m_rColumn.GetKey();
+ Reference< XNumberFormatter > xFormatter = m_rColumn.GetParent().getNumberFormatter();
+ sal_Int16 nKeyType = ::comphelper::getNumberFormatType(xFormatter->getNumberFormatsSupplier()->getNumberFormats(), nFormatKey);
+
+ while (!xListCursor->isAfterLast() && i++ < SHRT_MAX) // max anzahl eintraege
+ {
+ aStr = getValue(xDataField, xFormatter, aNullDate, nFormatKey, nKeyType);
+ aStringList.push_back(aStr);
+ xListCursor->next();
+ }
+
+ // filling the entries for the combobox
+ for (::std::vector< ::rtl::OUString >::const_iterator iter = aStringList.begin();
+ iter != aStringList.end(); ++iter)
+ ((ComboBox*)m_pWindow)->InsertEntry(*iter, LISTBOX_APPEND);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+XubString DbFilterField::GetFormatText(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
+{
+ return XubString();
+}
+
+//------------------------------------------------------------------
+void DbFilterField::UpdateFromField(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/)
+{
+ DBG_ERROR( "DbFilterField::UpdateFromField: cannot update a filter control from a field!" );
+}
+
+//------------------------------------------------------------------
+IMPL_LINK( DbFilterField, OnClick, void*, EMPTYARG )
+{
+ TriState eState = ((CheckBoxControl*)m_pWindow)->GetBox().GetState();
+ String aText;
+
+ switch (eState)
+ {
+ case STATE_CHECK:
+ aText.AssignAscii("1");
+ break;
+ case STATE_NOCHECK:
+ aText.AssignAscii("0");
+ break;
+ case STATE_DONTKNOW:
+ aText = String();
+ break;
+ }
+
+ if (m_aText != aText)
+ {
+ m_aText = aText;
+ m_aCommitLink.Call(this);
+ }
+ return 1;
+}
+
+/*************************************************************************/
+TYPEINIT0(FmXGridCell);
+
+
+DBG_NAME(FmXGridCell);
+//-----------------------------------------------------------------------------
+FmXGridCell::FmXGridCell( DbGridColumn* pColumn, DbCellControl* _pControl )
+ :OComponentHelper(m_aMutex)
+ ,m_pColumn(pColumn)
+ ,m_pCellControl( _pControl )
+ ,m_aWindowListeners( m_aMutex )
+ ,m_aFocusListeners( m_aMutex )
+ ,m_aKeyListeners( m_aMutex )
+ ,m_aMouseListeners( m_aMutex )
+ ,m_aMouseMotionListeners( m_aMutex )
+{
+ DBG_CTOR(FmXGridCell,NULL);
+}
+
+//-----------------------------------------------------------------------------
+void FmXGridCell::init()
+{
+ Window* pEventWindow( getEventWindow() );
+ if ( pEventWindow )
+ pEventWindow->AddEventListener( LINK( this, FmXGridCell, OnWindowEvent ) );
+}
+
+//-----------------------------------------------------------------------------
+Window* FmXGridCell::getEventWindow() const
+{
+ if ( m_pCellControl )
+ return &m_pCellControl->GetWindow();
+ return NULL;
+}
+
+//-----------------------------------------------------------------------------
+FmXGridCell::~FmXGridCell()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR(FmXGridCell,NULL);
+}
+
+//------------------------------------------------------------------
+void FmXGridCell::SetTextLineColor()
+{
+ if (m_pCellControl)
+ m_pCellControl->SetTextLineColor();
+}
+
+//------------------------------------------------------------------
+void FmXGridCell::SetTextLineColor(const Color& _rColor)
+{
+ if (m_pCellControl)
+ m_pCellControl->SetTextLineColor(_rColor);
+}
+
+// XTypeProvider
+//------------------------------------------------------------------
+Sequence< Type > SAL_CALL FmXGridCell::getTypes( ) throw (RuntimeException)
+{
+ Sequence< uno::Type > aTypes = ::comphelper::concatSequences(
+ ::cppu::OComponentHelper::getTypes(),
+ FmXGridCell_Base::getTypes()
+ );
+ if ( m_pCellControl )
+ aTypes = ::comphelper::concatSequences(
+ aTypes,
+ FmXGridCell_WindowBase::getTypes()
+ );
+ return aTypes;
+}
+
+//------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( FmXGridCell )
+
+// OComponentHelper
+//-----------------------------------------------------------------------------
+void FmXGridCell::disposing()
+{
+ lang::EventObject aEvent( *this );
+ m_aWindowListeners.disposeAndClear( aEvent );
+ m_aFocusListeners.disposeAndClear( aEvent );
+ m_aKeyListeners.disposeAndClear( aEvent );
+ m_aMouseListeners.disposeAndClear( aEvent );
+ m_aMouseMotionListeners.disposeAndClear( aEvent );
+
+ OComponentHelper::disposing();
+ m_pColumn = NULL;
+ DELETEZ(m_pCellControl);
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXGridCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
+{
+ Any aReturn = OComponentHelper::queryAggregation( _rType );
+
+ if ( !aReturn.hasValue() )
+ aReturn = FmXGridCell_Base::queryInterface( _rType );
+
+ if ( !aReturn.hasValue() && ( m_pCellControl != NULL ) )
+ aReturn = FmXGridCell_WindowBase::queryInterface( _rType );
+
+ return aReturn;
+}
+
+// ::com::sun::star::awt::XControl
+//-----------------------------------------------------------------------------
+Reference< XInterface > FmXGridCell::getContext() throw( RuntimeException )
+{
+ return Reference< XInterface > ();
+}
+
+//-----------------------------------------------------------------------------
+Reference< ::com::sun::star::awt::XControlModel > FmXGridCell::getModel() throw( ::com::sun::star::uno::RuntimeException )
+{
+ return Reference< ::com::sun::star::awt::XControlModel > (m_pColumn->getModel(), UNO_QUERY);
+}
+
+// ::com::sun::star::form::XBoundControl
+//------------------------------------------------------------------
+sal_Bool FmXGridCell::getLock() throw( RuntimeException )
+{
+ return m_pColumn->isLocked();
+}
+
+//------------------------------------------------------------------
+void FmXGridCell::setLock(sal_Bool _bLock) throw( RuntimeException )
+{
+ if (getLock() == _bLock)
+ return;
+ else
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_pColumn->setLock(_bLock);
+ }
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::setPosSize( ::sal_Int32 _XX, ::sal_Int32 _Y, ::sal_Int32 _Width, ::sal_Int32 _Height, ::sal_Int16 _Flags ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "FmXGridCell::setPosSize: not implemented" );
+ (void)_XX;
+ (void)_Y;
+ (void)_Width;
+ (void)_Height;
+ (void)_Flags;
+ // not allowed to tamper with this for a grid cell
+}
+
+//------------------------------------------------------------------
+awt::Rectangle SAL_CALL FmXGridCell::getPosSize( ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "FmXGridCell::getPosSize: not implemented" );
+ return awt::Rectangle();
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::setVisible( ::sal_Bool _Visible ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "FmXGridCell::setVisible: not implemented" );
+ (void)_Visible;
+ // not allowed to tamper with this for a grid cell
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::setEnable( ::sal_Bool _Enable ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "FmXGridCell::setEnable: not implemented" );
+ (void)_Enable;
+ // not allowed to tamper with this for a grid cell
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::setFocus( ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "FmXGridCell::setFocus: not implemented" );
+ // not allowed to tamper with this for a grid cell
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::addWindowListener( const Reference< awt::XWindowListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aWindowListeners.addInterface( _rxListener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::removeWindowListener( const Reference< awt::XWindowListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aWindowListeners.removeInterface( _rxListener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::addFocusListener( const Reference< awt::XFocusListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aFocusListeners.addInterface( _rxListener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::removeFocusListener( const Reference< awt::XFocusListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aFocusListeners.removeInterface( _rxListener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::addKeyListener( const Reference< awt::XKeyListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aKeyListeners.addInterface( _rxListener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::removeKeyListener( const Reference< awt::XKeyListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aKeyListeners.removeInterface( _rxListener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::addMouseListener( const Reference< awt::XMouseListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aMouseListeners.addInterface( _rxListener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::removeMouseListener( const Reference< awt::XMouseListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aMouseListeners.removeInterface( _rxListener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::addMouseMotionListener( const Reference< awt::XMouseMotionListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aMouseMotionListeners.addInterface( _rxListener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::removeMouseMotionListener( const Reference< awt::XMouseMotionListener >& _rxListener ) throw (RuntimeException)
+{
+ m_aMouseMotionListeners.removeInterface( _rxListener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::addPaintListener( const Reference< awt::XPaintListener >& _rxListener ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "FmXGridCell::addPaintListener: not implemented" );
+ (void)_rxListener;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXGridCell::removePaintListener( const Reference< awt::XPaintListener >& _rxListener ) throw (RuntimeException)
+{
+ OSL_ENSURE( false, "FmXGridCell::removePaintListener: not implemented" );
+ (void)_rxListener;
+}
+
+//------------------------------------------------------------------
+IMPL_LINK( FmXGridCell, OnWindowEvent, VclWindowEvent*, _pEvent )
+{
+ ENSURE_OR_THROW( _pEvent, "illegal event pointer" );
+ ENSURE_OR_THROW( _pEvent->GetWindow(), "illegal window" );
+ onWindowEvent( _pEvent->GetId(), *_pEvent->GetWindow(), _pEvent->GetData() );
+ return 1L;
+}
+
+//------------------------------------------------------------------------------
+void FmXGridCell::onFocusGained( const awt::FocusEvent& _rEvent )
+{
+ m_aFocusListeners.notifyEach( &awt::XFocusListener::focusGained, _rEvent );
+}
+
+//------------------------------------------------------------------------------
+void FmXGridCell::onFocusLost( const awt::FocusEvent& _rEvent )
+{
+ m_aFocusListeners.notifyEach( &awt::XFocusListener::focusLost, _rEvent );
+}
+
+//------------------------------------------------------------------------------
+void FmXGridCell::onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData )
+{
+ switch ( _nEventId )
+ {
+ case VCLEVENT_CONTROL_GETFOCUS:
+ case VCLEVENT_WINDOW_GETFOCUS:
+ case VCLEVENT_CONTROL_LOSEFOCUS:
+ case VCLEVENT_WINDOW_LOSEFOCUS:
+ {
+ if ( ( _rWindow.IsCompoundControl()
+ && ( _nEventId == VCLEVENT_CONTROL_GETFOCUS
+ || _nEventId == VCLEVENT_CONTROL_LOSEFOCUS
+ )
+ )
+ || ( !_rWindow.IsCompoundControl()
+ && ( _nEventId == VCLEVENT_WINDOW_GETFOCUS
+ || _nEventId == VCLEVENT_WINDOW_LOSEFOCUS
+ )
+ )
+ )
+ {
+ if ( !m_aFocusListeners.getLength() )
+ break;
+
+ bool bFocusGained = ( _nEventId == VCLEVENT_CONTROL_GETFOCUS ) || ( _nEventId == VCLEVENT_WINDOW_GETFOCUS );
+
+ awt::FocusEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.FocusFlags = _rWindow.GetGetFocusFlags();
+ aEvent.Temporary = sal_False;
+
+ if ( bFocusGained )
+ onFocusGained( aEvent );
+ else
+ onFocusLost( aEvent );
+ }
+ }
+ break;
+ case VCLEVENT_WINDOW_MOUSEBUTTONDOWN:
+ case VCLEVENT_WINDOW_MOUSEBUTTONUP:
+ {
+ if ( !m_aMouseListeners.getLength() )
+ break;
+
+ const bool bButtonDown = ( _nEventId == VCLEVENT_WINDOW_MOUSEBUTTONDOWN );
+
+ awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *static_cast< const ::MouseEvent* >( _pEventData ), *this ) );
+ m_aMouseListeners.notifyEach( bButtonDown ? &awt::XMouseListener::mousePressed : &awt::XMouseListener::mouseReleased, aEvent );
+ }
+ break;
+ case VCLEVENT_WINDOW_MOUSEMOVE:
+ {
+ const MouseEvent& rMouseEvent = *static_cast< const ::MouseEvent* >( _pEventData );
+ if ( rMouseEvent.IsEnterWindow() || rMouseEvent.IsLeaveWindow() )
+ {
+ if ( m_aMouseListeners.getLength() != 0 )
+ {
+ awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) );
+ m_aMouseListeners.notifyEach( rMouseEvent.IsEnterWindow() ? &awt::XMouseListener::mouseEntered: &awt::XMouseListener::mouseExited, aEvent );
+ }
+ }
+ else if ( !rMouseEvent.IsEnterWindow() && !rMouseEvent.IsLeaveWindow() )
+ {
+ if ( m_aMouseMotionListeners.getLength() != 0 )
+ {
+ awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) );
+ aEvent.ClickCount = 0;
+ const bool bSimpleMove = ( ( rMouseEvent.GetMode() & MOUSE_SIMPLEMOVE ) != 0 );
+ m_aMouseMotionListeners.notifyEach( bSimpleMove ? &awt::XMouseMotionListener::mouseMoved: &awt::XMouseMotionListener::mouseDragged, aEvent );
+ }
+ }
+ }
+ break;
+ case VCLEVENT_WINDOW_KEYINPUT:
+ case VCLEVENT_WINDOW_KEYUP:
+ {
+ if ( !m_aKeyListeners.getLength() )
+ break;
+
+ const bool bKeyPressed = ( _nEventId == VCLEVENT_WINDOW_KEYINPUT );
+ awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent( *static_cast< const ::KeyEvent* >( _pEventData ), *this ) );
+ m_aKeyListeners.notifyEach( bKeyPressed ? &awt::XKeyListener::keyPressed: &awt::XKeyListener::keyReleased, aEvent );
+ }
+ break;
+ }
+}
+
+/*************************************************************************/
+TYPEINIT1(FmXDataCell, FmXGridCell);
+//------------------------------------------------------------------------------
+void FmXDataCell::PaintFieldToCell(OutputDevice& rDev, const Rectangle& rRect,
+ const Reference< ::com::sun::star::sdb::XColumn >& _rxField,
+ const Reference< XNumberFormatter >& xFormatter)
+{
+ m_pCellControl->PaintFieldToCell( rDev, rRect, _rxField, xFormatter );
+}
+
+//------------------------------------------------------------------------------
+void FmXDataCell::UpdateFromColumn()
+{
+ Reference< ::com::sun::star::sdb::XColumn > xField(m_pColumn->GetCurrentFieldValue());
+ if (xField.is())
+ m_pCellControl->UpdateFromField(xField, m_pColumn->GetParent().getNumberFormatter());
+}
+
+/*************************************************************************/
+TYPEINIT1(FmXTextCell, FmXDataCell);
+
+FmXTextCell::FmXTextCell( DbGridColumn* pColumn, DbCellControl& _rControl )
+ :FmXDataCell( pColumn, _rControl )
+ ,m_bFastPaint( sal_True )
+{
+}
+
+//------------------------------------------------------------------------------
+void FmXTextCell::PaintFieldToCell(OutputDevice& rDev,
+ const Rectangle& rRect,
+ const Reference< ::com::sun::star::sdb::XColumn >& _rxField,
+ const Reference< XNumberFormatter >& xFormatter)
+{
+ if ( !m_bFastPaint )
+ {
+ FmXDataCell::PaintFieldToCell( rDev, rRect, _rxField, xFormatter );
+ return;
+ }
+
+ sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_VCENTER;
+ if ( ( rDev.GetOutDevType() == OUTDEV_WINDOW ) && !static_cast< Window& >( rDev ).IsEnabled() )
+ nStyle |= TEXT_DRAW_DISABLE;
+
+ switch (m_pColumn->GetAlignment())
+ {
+ case ::com::sun::star::awt::TextAlign::RIGHT:
+ nStyle |= TEXT_DRAW_RIGHT;
+ break;
+ case ::com::sun::star::awt::TextAlign::CENTER:
+ nStyle |= TEXT_DRAW_CENTER;
+ break;
+ default:
+ nStyle |= TEXT_DRAW_LEFT;
+ }
+
+ Color* pColor = NULL;
+ String aText = GetText(_rxField, xFormatter, &pColor);
+ if (pColor != NULL)
+ {
+ Color aOldTextColor( rDev.GetTextColor() );
+ rDev.SetTextColor( *pColor );
+ rDev.DrawText(rRect, aText, nStyle);
+ rDev.SetTextColor( aOldTextColor );
+ }
+ else
+ rDev.DrawText(rRect, aText, nStyle);
+}
+
+
+/*************************************************************************/
+
+DBG_NAME(FmXEditCell);
+//------------------------------------------------------------------------------
+FmXEditCell::FmXEditCell( DbGridColumn* pColumn, DbCellControl& _rControl )
+ :FmXTextCell( pColumn, _rControl )
+ ,m_aTextListeners(m_aMutex)
+ ,m_aChangeListeners( m_aMutex )
+ ,m_pEditImplementation( NULL )
+ ,m_bOwnEditImplementation( false )
+{
+ DBG_CTOR(FmXEditCell,NULL);
+
+ DbTextField* pTextField = PTR_CAST( DbTextField, &_rControl );
+ if ( pTextField )
+ {
+
+ m_pEditImplementation = pTextField->GetEditImplementation();
+ if ( !pTextField->IsSimpleEdit() )
+ m_bFastPaint = sal_False;
+ }
+ else
+ {
+ m_pEditImplementation = new EditImplementation( static_cast< Edit& >( _rControl.GetWindow() ) );
+ m_bOwnEditImplementation = true;
+ }
+}
+
+//------------------------------------------------------------------
+FmXEditCell::~FmXEditCell()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+
+ DBG_DTOR(FmXEditCell,NULL);
+}
+
+// OComponentHelper
+//-----------------------------------------------------------------------------
+void FmXEditCell::disposing()
+{
+ ::com::sun::star::lang::EventObject aEvt(*this);
+ m_aTextListeners.disposeAndClear(aEvt);
+ m_aChangeListeners.disposeAndClear(aEvt);
+
+ m_pEditImplementation->SetModifyHdl( Link() );
+ if ( m_bOwnEditImplementation )
+ delete m_pEditImplementation;
+ m_pEditImplementation = NULL;
+
+ FmXDataCell::disposing();
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXEditCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
+{
+ Any aReturn = FmXTextCell::queryAggregation( _rType );
+
+ if ( !aReturn.hasValue() )
+ aReturn = FmXEditCell_Base::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//-------------------------------------------------------------------------
+Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXEditCell::getTypes( ) throw(RuntimeException)
+{
+ return ::comphelper::concatSequences(
+ FmXTextCell::getTypes(),
+ FmXEditCell_Base::getTypes()
+ );
+}
+
+//------------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( FmXEditCell )
+
+// ::com::sun::star::awt::XTextComponent
+//------------------------------------------------------------------------------
+void SAL_CALL FmXEditCell::addTextListener(const Reference< ::com::sun::star::awt::XTextListener >& l) throw( RuntimeException )
+{
+ m_aTextListeners.addInterface( l );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXEditCell::removeTextListener(const Reference< ::com::sun::star::awt::XTextListener >& l) throw( RuntimeException )
+{
+ m_aTextListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXEditCell::setText( const ::rtl::OUString& aText ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pEditImplementation )
+ {
+ m_pEditImplementation->SetText( aText );
+
+ // In JAVA wird auch ein textChanged ausgeloest, in VCL nicht.
+ // ::com::sun::star::awt::Toolkit soll JAVA-komform sein...
+ onTextChanged();
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXEditCell::insertText(const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pEditImplementation )
+ {
+ m_pEditImplementation->SetSelection( Selection( rSel.Min, rSel.Max ) );
+ m_pEditImplementation->ReplaceSelected( aText );
+ }
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL FmXEditCell::getText() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::rtl::OUString aText;
+ if ( m_pEditImplementation )
+ {
+ if ( m_pEditImplementation->GetControl().IsVisible() && m_pColumn->GetParent().getDisplaySynchron())
+ {
+ // if the display isn't sync with the cursor we can't ask the edit field
+ LineEnd eLineEndFormat = m_pColumn ? getModelLineEndSetting( m_pColumn->getModel() ) : LINEEND_LF;
+ aText = m_pEditImplementation->GetText( eLineEndFormat );
+ }
+ else
+ {
+ Reference< ::com::sun::star::sdb::XColumn > xField(m_pColumn->GetCurrentFieldValue());
+ if (xField.is())
+ aText = GetText(xField, m_pColumn->GetParent().getNumberFormatter());
+ }
+ }
+ return aText;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL FmXEditCell::getSelectedText( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::rtl::OUString aText;
+ if ( m_pEditImplementation )
+ {
+ LineEnd eLineEndFormat = m_pColumn ? getModelLineEndSetting( m_pColumn->getModel() ) : LINEEND_LF;
+ aText = m_pEditImplementation->GetSelected( eLineEndFormat );
+ }
+ return aText;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXEditCell::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pEditImplementation )
+ m_pEditImplementation->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
+}
+
+//------------------------------------------------------------------------------
+::com::sun::star::awt::Selection SAL_CALL FmXEditCell::getSelection( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Selection aSel;
+ if ( m_pEditImplementation )
+ aSel = m_pEditImplementation->GetSelection();
+
+ return ::com::sun::star::awt::Selection(aSel.Min(), aSel.Max());
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FmXEditCell::isEditable( void ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return ( m_pEditImplementation && !m_pEditImplementation->IsReadOnly() && m_pEditImplementation->GetControl().IsEnabled() ) ? sal_True : sal_False;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXEditCell::setEditable( sal_Bool bEditable ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pEditImplementation )
+ m_pEditImplementation->SetReadOnly( !bEditable );
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 SAL_CALL FmXEditCell::getMaxTextLen() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return m_pEditImplementation ? m_pEditImplementation->GetMaxTextLen() : 0;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXEditCell::setMaxTextLen( sal_Int16 nLen ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_pEditImplementation )
+ m_pEditImplementation->SetMaxTextLen( nLen );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXEditCell::addChangeListener( const Reference< form::XChangeListener >& _Listener ) throw (RuntimeException)
+{
+ m_aChangeListeners.addInterface( _Listener );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXEditCell::removeChangeListener( const Reference< form::XChangeListener >& _Listener ) throw (RuntimeException)
+{
+ m_aChangeListeners.removeInterface( _Listener );
+}
+
+//------------------------------------------------------------------------------
+void FmXEditCell::onTextChanged()
+{
+ ::com::sun::star::awt::TextEvent aEvent;
+ aEvent.Source = *this;
+ m_aTextListeners.notifyEach( &awt::XTextListener::textChanged, aEvent );
+}
+
+//------------------------------------------------------------------------------
+void FmXEditCell::onFocusGained( const awt::FocusEvent& _rEvent )
+{
+ FmXTextCell::onFocusGained( _rEvent );
+ m_sValueOnEnter = getText();
+}
+
+//------------------------------------------------------------------------------
+void FmXEditCell::onFocusLost( const awt::FocusEvent& _rEvent )
+{
+ FmXTextCell::onFocusLost( _rEvent );
+
+ if ( getText() != m_sValueOnEnter )
+ {
+ lang::EventObject aEvent( *this );
+ m_aChangeListeners.notifyEach( &XChangeListener::changed, aEvent );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXEditCell::onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData )
+{
+ switch ( _nEventId )
+ {
+ case VCLEVENT_EDIT_MODIFY:
+ {
+ if ( m_pEditImplementation && m_aTextListeners.getLength() )
+ onTextChanged();
+ return;
+ }
+ }
+
+ FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData );
+}
+
+/*************************************************************************/
+DBG_NAME(FmXCheckBoxCell);
+//------------------------------------------------------------------------------
+FmXCheckBoxCell::FmXCheckBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl )
+ :FmXDataCell( pColumn, _rControl )
+ ,m_aItemListeners(m_aMutex)
+ ,m_aActionListeners( m_aMutex )
+ ,m_pBox( & static_cast< CheckBoxControl& >( _rControl.GetWindow() ).GetBox() )
+{
+ DBG_CTOR(FmXCheckBoxCell,NULL);
+}
+
+//------------------------------------------------------------------
+FmXCheckBoxCell::~FmXCheckBoxCell()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR(FmXCheckBoxCell,NULL);
+}
+
+// OComponentHelper
+//-----------------------------------------------------------------------------
+void FmXCheckBoxCell::disposing()
+{
+ ::com::sun::star::lang::EventObject aEvt(*this);
+ m_aItemListeners.disposeAndClear(aEvt);
+ m_aActionListeners.disposeAndClear(aEvt);
+
+ static_cast< CheckBoxControl& >( m_pCellControl->GetWindow() ).SetClickHdl(Link());
+ m_pBox = NULL;
+
+ FmXDataCell::disposing();
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXCheckBoxCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
+{
+ Any aReturn = FmXDataCell::queryAggregation( _rType );
+
+ if ( !aReturn.hasValue() )
+ aReturn = FmXCheckBoxCell_Base::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//-------------------------------------------------------------------------
+Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXCheckBoxCell::getTypes( ) throw(RuntimeException)
+{
+ return ::comphelper::concatSequences(
+ FmXDataCell::getTypes(),
+ FmXCheckBoxCell_Base::getTypes()
+ );
+}
+
+//------------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( FmXCheckBoxCell )
+
+//------------------------------------------------------------------
+void SAL_CALL FmXCheckBoxCell::addItemListener( const Reference< ::com::sun::star::awt::XItemListener >& l ) throw( RuntimeException )
+{
+ m_aItemListeners.addInterface( l );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXCheckBoxCell::removeItemListener( const Reference< ::com::sun::star::awt::XItemListener >& l ) throw( RuntimeException )
+{
+ m_aItemListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXCheckBoxCell::setState( short n ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (m_pBox)
+ {
+ UpdateFromColumn();
+ m_pBox->SetState( (TriState)n );
+ }
+}
+
+//------------------------------------------------------------------
+short SAL_CALL FmXCheckBoxCell::getState() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (m_pBox)
+ {
+ UpdateFromColumn();
+ return (short)m_pBox->GetState();
+ }
+ return STATE_DONTKNOW;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXCheckBoxCell::enableTriState( sal_Bool b ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (m_pBox)
+ m_pBox->EnableTriState( b );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXCheckBoxCell::addActionListener( const Reference< awt::XActionListener >& _Listener ) throw (RuntimeException)
+{
+ m_aActionListeners.addInterface( _Listener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXCheckBoxCell::removeActionListener( const Reference< awt::XActionListener >& _Listener ) throw (RuntimeException)
+{
+ m_aActionListeners.removeInterface( _Listener );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXCheckBoxCell::setLabel( const ::rtl::OUString& _Label ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pColumn )
+ {
+ DbGridControl& rGrid( m_pColumn->GetParent() );
+ rGrid.SetColumnTitle( rGrid.GetColumnId( m_pColumn->GetFieldPos() ), _Label );
+ }
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXCheckBoxCell::setActionCommand( const ::rtl::OUString& _Command ) throw (RuntimeException)
+{
+ m_aActionCommand = _Command;
+}
+
+//------------------------------------------------------------------
+Window* FmXCheckBoxCell::getEventWindow() const
+{
+ return m_pBox;
+}
+
+//------------------------------------------------------------------
+void FmXCheckBoxCell::onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData )
+{
+ switch ( _nEventId )
+ {
+ case VCLEVENT_CHECKBOX_TOGGLE:
+ {
+ // check boxes are to be committed immediately (this holds for ordinary check box controls in
+ // documents, and this must hold for check boxes in grid columns, too
+ // 91210 - 22.08.2001 - frank.schoenheit@sun.com
+ m_pCellControl->Commit();
+
+ Reference< XWindow > xKeepAlive( this );
+ if ( m_aItemListeners.getLength() && m_pBox )
+ {
+ awt::ItemEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.Highlighted = sal_False;
+ aEvent.Selected = m_pBox->GetState();
+ m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
+ }
+ if ( m_aActionListeners.getLength() )
+ {
+ awt::ActionEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.ActionCommand = m_aActionCommand;
+ m_aActionListeners.notifyEach( &awt::XActionListener::actionPerformed, aEvent );
+ }
+ }
+ break;
+
+ default:
+ FmXDataCell::onWindowEvent( _nEventId, _rWindow, _pEventData );
+ break;
+ }
+}
+
+/*************************************************************************/
+
+DBG_NAME(FmXListBoxCell);
+//------------------------------------------------------------------------------
+FmXListBoxCell::FmXListBoxCell(DbGridColumn* pColumn, DbCellControl& _rControl)
+ :FmXTextCell( pColumn, _rControl )
+ ,m_aItemListeners(m_aMutex)
+ ,m_aActionListeners(m_aMutex)
+ ,m_pBox( &static_cast< ListBox& >( _rControl.GetWindow() ) )
+{
+ DBG_CTOR(FmXListBoxCell,NULL);
+
+ m_pBox->SetDoubleClickHdl( LINK( this, FmXListBoxCell, OnDoubleClick ) );
+}
+
+//------------------------------------------------------------------
+FmXListBoxCell::~FmXListBoxCell()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR(FmXListBoxCell,NULL);
+}
+
+// OComponentHelper
+//-----------------------------------------------------------------------------
+void FmXListBoxCell::disposing()
+{
+ ::com::sun::star::lang::EventObject aEvt(*this);
+ m_aItemListeners.disposeAndClear(aEvt);
+ m_aActionListeners.disposeAndClear(aEvt);
+
+ m_pBox->SetSelectHdl( Link() );
+ m_pBox->SetDoubleClickHdl( Link() );
+ m_pBox = NULL;
+
+ FmXTextCell::disposing();
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXListBoxCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
+{
+ Any aReturn = FmXTextCell::queryAggregation(_rType);
+
+ if ( !aReturn.hasValue() )
+ aReturn = FmXListBoxCell_Base::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//-------------------------------------------------------------------------
+Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXListBoxCell::getTypes( ) throw(RuntimeException)
+{
+ return ::comphelper::concatSequences(
+ FmXTextCell::getTypes(),
+ FmXListBoxCell_Base::getTypes()
+ );
+}
+
+//------------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( FmXListBoxCell )
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::addItemListener(const Reference< ::com::sun::star::awt::XItemListener >& l) throw( RuntimeException )
+{
+ m_aItemListeners.addInterface( l );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::removeItemListener(const Reference< ::com::sun::star::awt::XItemListener >& l) throw( RuntimeException )
+{
+ m_aItemListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::addActionListener(const Reference< ::com::sun::star::awt::XActionListener >& l) throw( RuntimeException )
+{
+ m_aActionListeners.addInterface( l );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::removeActionListener(const Reference< ::com::sun::star::awt::XActionListener >& l) throw( RuntimeException )
+{
+ m_aActionListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::addItem(const ::rtl::OUString& aItem, sal_Int16 nPos) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (m_pBox)
+ m_pBox->InsertEntry( aItem, nPos );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::addItems(const ::comphelper::StringSequence& aItems, sal_Int16 nPos) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (m_pBox)
+ {
+ sal_uInt16 nP = nPos;
+ for ( sal_uInt16 n = 0; n < aItems.getLength(); n++ )
+ {
+ m_pBox->InsertEntry( aItems.getConstArray()[n], nP );
+ if ( nPos != -1 ) // Nicht wenn 0xFFFF, weil LIST_APPEND
+ nP++;
+ }
+ }
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::removeItems(sal_Int16 nPos, sal_Int16 nCount) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pBox )
+ {
+ for ( sal_uInt16 n = nCount; n; )
+ m_pBox->RemoveEntry( nPos + (--n) );
+ }
+}
+
+//------------------------------------------------------------------
+sal_Int16 SAL_CALL FmXListBoxCell::getItemCount() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_pBox ? m_pBox->GetEntryCount() : 0;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL FmXListBoxCell::getItem(sal_Int16 nPos) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ String aItem;
+ if (m_pBox)
+ aItem = m_pBox->GetEntry( nPos );
+ return aItem;
+}
+//------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL FmXListBoxCell::getItems() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::comphelper::StringSequence aSeq;
+ if (m_pBox)
+ {
+ sal_uInt16 nEntries = m_pBox ->GetEntryCount();
+ aSeq = ::comphelper::StringSequence( nEntries );
+ for ( sal_uInt16 n = nEntries; n; )
+ {
+ --n;
+ aSeq.getArray()[n] = m_pBox ->GetEntry( n );
+ }
+ }
+ return aSeq;
+}
+
+//------------------------------------------------------------------
+sal_Int16 SAL_CALL FmXListBoxCell::getSelectedItemPos() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (m_pBox)
+ {
+ UpdateFromColumn();
+ return m_pBox->GetSelectEntryPos();
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------
+Sequence< sal_Int16 > SAL_CALL FmXListBoxCell::getSelectedItemsPos() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Sequence<sal_Int16> aSeq;
+
+ if (m_pBox)
+ {
+ UpdateFromColumn();
+ sal_uInt16 nSelEntries = m_pBox->GetSelectEntryCount();
+ aSeq = Sequence<sal_Int16>( nSelEntries );
+ for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
+ aSeq.getArray()[n] = m_pBox->GetSelectEntryPos( n );
+ }
+ return aSeq;
+}
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL FmXListBoxCell::getSelectedItem() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ String aItem;
+ if (m_pBox)
+ {
+ UpdateFromColumn();
+ aItem = m_pBox->GetSelectEntry();
+ }
+
+ return aItem;
+}
+
+//------------------------------------------------------------------
+::comphelper::StringSequence SAL_CALL FmXListBoxCell::getSelectedItems() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::comphelper::StringSequence aSeq;
+
+ if (m_pBox)
+ {
+ UpdateFromColumn();
+ sal_uInt16 nSelEntries = m_pBox->GetSelectEntryCount();
+ aSeq = ::comphelper::StringSequence( nSelEntries );
+ for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
+ aSeq.getArray()[n] = m_pBox->GetSelectEntry( n );
+ }
+ return aSeq;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::selectItemPos(sal_Int16 nPos, sal_Bool bSelect) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (m_pBox)
+ m_pBox->SelectEntryPos( nPos, bSelect );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::selectItemsPos(const Sequence< sal_Int16 >& aPositions, sal_Bool bSelect) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (m_pBox)
+ {
+ for ( sal_uInt16 n = (sal_uInt16)aPositions.getLength(); n; )
+ m_pBox->SelectEntryPos( (sal_uInt16) aPositions.getConstArray()[--n], bSelect );
+ }
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::selectItem(const ::rtl::OUString& aItem, sal_Bool bSelect) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (m_pBox)
+ m_pBox->SelectEntry( aItem, bSelect );
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL FmXListBoxCell::isMutipleMode() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ sal_Bool bMulti = sal_False;
+ if (m_pBox)
+ bMulti = m_pBox->IsMultiSelectionEnabled();
+ return bMulti;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::setMultipleMode(sal_Bool bMulti) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (m_pBox)
+ m_pBox->EnableMultiSelection( bMulti );
+}
+
+//------------------------------------------------------------------
+sal_Int16 SAL_CALL FmXListBoxCell::getDropDownLineCount() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ sal_Int16 nLines = 0;
+ if (m_pBox)
+ nLines = m_pBox->GetDropDownLineCount();
+
+ return nLines;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::setDropDownLineCount(sal_Int16 nLines) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (m_pBox)
+ m_pBox->SetDropDownLineCount( nLines );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXListBoxCell::makeVisible(sal_Int16 nEntry) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (m_pBox)
+ m_pBox->SetTopEntry( nEntry );
+}
+
+//------------------------------------------------------------------
+void FmXListBoxCell::onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData )
+{
+ if ( ( &_rWindow == m_pBox )
+ && ( _nEventId == VCLEVENT_LISTBOX_SELECT )
+ )
+ {
+ OnDoubleClick( NULL );
+
+ ::com::sun::star::awt::ItemEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.Highlighted = sal_False;
+
+ // Bei Mehrfachselektion 0xFFFF, sonst die ID
+ aEvent.Selected = (m_pBox->GetSelectEntryCount() == 1 )
+ ? m_pBox->GetSelectEntryPos() : 0xFFFF;
+
+ m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
+ return;
+ }
+
+ FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData );
+}
+
+
+//------------------------------------------------------------------
+IMPL_LINK( FmXListBoxCell, OnDoubleClick, void*, EMPTYARG )
+{
+ if (m_pBox)
+ {
+ ::cppu::OInterfaceIteratorHelper aIt( m_aActionListeners );
+
+ ::com::sun::star::awt::ActionEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.ActionCommand = m_pBox->GetSelectEntry();
+
+ while( aIt.hasMoreElements() )
+ ((::com::sun::star::awt::XActionListener *)aIt.next())->actionPerformed( aEvent );
+ }
+ return 1;
+}
+
+
+/*************************************************************************/
+
+DBG_NAME( FmXComboBoxCell );
+
+//------------------------------------------------------------------------------
+FmXComboBoxCell::FmXComboBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl )
+ :FmXTextCell( pColumn, _rControl )
+ ,m_aItemListeners( m_aMutex )
+ ,m_aActionListeners( m_aMutex )
+ ,m_pComboBox( &static_cast< ComboBox& >( _rControl.GetWindow() ) )
+{
+ DBG_CTOR( FmXComboBoxCell, NULL );
+}
+
+//------------------------------------------------------------------------------
+FmXComboBoxCell::~FmXComboBoxCell()
+{
+ if ( !OComponentHelper::rBHelper.bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR( FmXComboBoxCell, NULL );
+}
+
+//-----------------------------------------------------------------------------
+void FmXComboBoxCell::disposing()
+{
+ ::com::sun::star::lang::EventObject aEvt(*this);
+ m_aItemListeners.disposeAndClear(aEvt);
+ m_aActionListeners.disposeAndClear(aEvt);
+
+ FmXTextCell::disposing();
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXComboBoxCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
+{
+ Any aReturn = FmXTextCell::queryAggregation(_rType);
+
+ if ( !aReturn.hasValue() )
+ aReturn = FmXComboBoxCell_Base::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//-------------------------------------------------------------------------
+Sequence< Type > SAL_CALL FmXComboBoxCell::getTypes( ) throw(RuntimeException)
+{
+ return ::comphelper::concatSequences(
+ FmXTextCell::getTypes(),
+ FmXComboBoxCell_Base::getTypes()
+ );
+}
+
+//------------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( FmXComboBoxCell )
+
+//------------------------------------------------------------------
+void SAL_CALL FmXComboBoxCell::addItemListener(const Reference< awt::XItemListener >& l) throw( RuntimeException )
+{
+ m_aItemListeners.addInterface( l );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXComboBoxCell::removeItemListener(const Reference< awt::XItemListener >& l) throw( RuntimeException )
+{
+ m_aItemListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXComboBoxCell::addActionListener(const Reference< awt::XActionListener >& l) throw( RuntimeException )
+{
+ m_aActionListeners.addInterface( l );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXComboBoxCell::removeActionListener(const Reference< awt::XActionListener >& l) throw( RuntimeException )
+{
+ m_aActionListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXComboBoxCell::addItem( const ::rtl::OUString& _Item, sal_Int16 _Pos ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pComboBox )
+ m_pComboBox->InsertEntry( _Item, _Pos );
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXComboBoxCell::addItems( const Sequence< ::rtl::OUString >& _Items, sal_Int16 _Pos ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pComboBox )
+ {
+ sal_uInt16 nP = _Pos;
+ for ( sal_uInt16 n = 0; n < _Items.getLength(); n++ )
+ {
+ m_pComboBox->InsertEntry( _Items.getConstArray()[n], nP );
+ if ( _Pos != -1 )
+ nP++;
+ }
+ }
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXComboBoxCell::removeItems( sal_Int16 _Pos, sal_Int16 _Count ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pComboBox )
+ {
+ for ( sal_uInt16 n = _Count; n; )
+ m_pComboBox->RemoveEntry( _Pos + (--n) );
+ }
+}
+
+//------------------------------------------------------------------
+sal_Int16 SAL_CALL FmXComboBoxCell::getItemCount() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_pComboBox ? m_pComboBox->GetEntryCount() : 0;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL FmXComboBoxCell::getItem( sal_Int16 _Pos ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ String sItem;
+ if ( m_pComboBox )
+ sItem = m_pComboBox->GetEntry( _Pos );
+ return sItem;
+}
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL FmXComboBoxCell::getItems() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Sequence< ::rtl::OUString > aItems;
+ if ( m_pComboBox )
+ {
+ sal_uInt16 nEntries = m_pComboBox->GetEntryCount();
+ aItems.realloc( nEntries );
+ ::rtl::OUString* pItem = aItems.getArray();
+ for ( sal_uInt16 n=0; n<nEntries; ++n, ++pItem )
+ *pItem = m_pComboBox->GetEntry( n );
+ }
+ return aItems;
+}
+
+//------------------------------------------------------------------
+sal_Int16 SAL_CALL FmXComboBoxCell::getDropDownLineCount() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ sal_Int16 nLines = 0;
+ if ( m_pComboBox )
+ nLines = m_pComboBox->GetDropDownLineCount();
+
+ return nLines;
+}
+
+//------------------------------------------------------------------
+void SAL_CALL FmXComboBoxCell::setDropDownLineCount(sal_Int16 nLines) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pComboBox )
+ m_pComboBox->SetDropDownLineCount( nLines );
+}
+
+//------------------------------------------------------------------------------
+void FmXComboBoxCell::onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData )
+{
+
+ switch ( _nEventId )
+ {
+ case VCLEVENT_COMBOBOX_SELECT:
+ {
+ awt::ItemEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.Highlighted = sal_False;
+
+ // Bei Mehrfachselektion 0xFFFF, sonst die ID
+ aEvent.Selected = ( m_pComboBox->GetSelectEntryCount() == 1 )
+ ? m_pComboBox->GetSelectEntryPos()
+ : 0xFFFF;
+ m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
+ }
+ break;
+
+ default:
+ FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData );
+ break;
+ }
+}
+
+/*************************************************************************/
+TYPEINIT1(FmXFilterCell, FmXGridCell);
+
+//------------------------------------------------------------------------------
+Reference< XInterface > FmXFilterCell_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& /*_rxFactory*/)
+{
+ return *new FmXFilterCell();
+}
+
+DBG_NAME(FmXFilterCell);
+//------------------------------------------------------------------------------
+FmXFilterCell::FmXFilterCell(DbGridColumn* pColumn, DbCellControl* pControl )
+ :FmXGridCell( pColumn, pControl )
+ ,m_aTextListeners(m_aMutex)
+{
+ DBG_CTOR(FmXFilterCell,NULL);
+
+ DBG_ASSERT( m_pCellControl->ISA( DbFilterField ), "FmXFilterCell::FmXFilterCell: invalid cell control!" );
+ static_cast< DbFilterField* >( m_pCellControl )->SetCommitHdl( LINK( this, FmXFilterCell, OnCommit ) );
+}
+
+//------------------------------------------------------------------
+FmXFilterCell::~FmXFilterCell()
+{
+ if (!OComponentHelper::rBHelper.bDisposed)
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR(FmXFilterCell,NULL);
+}
+
+// XUnoTunnel
+//------------------------------------------------------------------------------
+sal_Int64 SAL_CALL FmXFilterCell::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException)
+{
+ sal_Int64 nReturn(0);
+
+ if ( (_rIdentifier.getLength() == 16)
+ && (0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), _rIdentifier.getConstArray(), 16 ))
+ )
+ {
+ nReturn = reinterpret_cast<sal_Int64>(this);
+ }
+
+ return nReturn;
+}
+
+//------------------------------------------------------------------------------
+const Sequence<sal_Int8>& FmXFilterCell::getUnoTunnelId()
+{
+ static Sequence< sal_Int8 > * pSeq = 0;
+ if( !pSeq )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+//------------------------------------------------------------------------------
+FmXFilterCell* FmXFilterCell::getImplementation(const Reference< ::com::sun::star::awt::XControl >& _rxObject)
+{
+ Reference< ::com::sun::star::lang::XUnoTunnel > xTunnel(
+ _rxObject, UNO_QUERY);
+ if (xTunnel.is())
+ return reinterpret_cast<FmXFilterCell*>(xTunnel->getSomething(getUnoTunnelId()));
+ return NULL;
+}
+
+//------------------------------------------------------------------------------
+void FmXFilterCell::PaintCell( OutputDevice& rDev, const Rectangle& rRect )
+{
+ static_cast< DbFilterField* >( m_pCellControl )->PaintCell( rDev, rRect );
+}
+
+// OComponentHelper
+//-----------------------------------------------------------------------------
+void FmXFilterCell::disposing()
+{
+ ::com::sun::star::lang::EventObject aEvt(*this);
+ m_aTextListeners.disposeAndClear(aEvt);
+
+ ((DbFilterField*)m_pCellControl)->SetCommitHdl(Link());
+
+ FmXGridCell::disposing();
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXFilterCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
+{
+ Any aReturn = FmXGridCell::queryAggregation(_rType);
+
+ if ( !aReturn.hasValue() )
+ aReturn = FmXFilterCell_Base::queryInterface( _rType );
+
+ return aReturn;
+}
+
+//-------------------------------------------------------------------------
+Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXFilterCell::getTypes( ) throw(RuntimeException)
+{
+ return ::comphelper::concatSequences(
+ FmXGridCell::getTypes(),
+ FmXFilterCell_Base::getTypes()
+ );
+}
+
+//------------------------------------------------------------------------------
+IMPLEMENT_GET_IMPLEMENTATION_ID( FmXFilterCell )
+
+// ::com::sun::star::awt::XTextComponent
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFilterCell::addTextListener(const Reference< ::com::sun::star::awt::XTextListener >& l) throw( RuntimeException )
+{
+ m_aTextListeners.addInterface( l );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFilterCell::removeTextListener(const Reference< ::com::sun::star::awt::XTextListener >& l) throw( RuntimeException )
+{
+ m_aTextListeners.removeInterface( l );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFilterCell::setText( const ::rtl::OUString& aText ) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ((DbFilterField*)m_pCellControl)->SetText(aText);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFilterCell::insertText( const ::com::sun::star::awt::Selection& /*rSel*/, const ::rtl::OUString& /*aText*/ ) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL FmXFilterCell::getText() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return ((DbFilterField*)m_pCellControl)->GetText();
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL FmXFilterCell::getSelectedText( void ) throw( RuntimeException )
+{
+ return getText();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFilterCell::setSelection( const ::com::sun::star::awt::Selection& /*aSelection*/ ) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------------
+::com::sun::star::awt::Selection SAL_CALL FmXFilterCell::getSelection( void ) throw( RuntimeException )
+{
+ return ::com::sun::star::awt::Selection();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FmXFilterCell::isEditable( void ) throw( RuntimeException )
+{
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFilterCell::setEditable( sal_Bool /*bEditable*/ ) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------------
+sal_Int16 SAL_CALL FmXFilterCell::getMaxTextLen() throw( RuntimeException )
+{
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFilterCell::setMaxTextLen( sal_Int16 /*nLen*/ ) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( FmXFilterCell, OnCommit, void*, EMPTYARG )
+{
+ ::cppu::OInterfaceIteratorHelper aIt( m_aTextListeners );
+ ::com::sun::star::awt::TextEvent aEvt;
+ aEvt.Source = *this;
+ while( aIt.hasMoreElements() )
+ ((::com::sun::star::awt::XTextListener *)aIt.next())->textChanged( aEvt );
+ return 1;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/fmcomp/gridcols.cxx b/svx/source/fmcomp/gridcols.cxx
new file mode 100644
index 000000000000..ad0c94b5e1dd
--- /dev/null
+++ b/svx/source/fmcomp/gridcols.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "gridcols.hxx"
+#include <tools/debug.hxx>
+#include <comphelper/types.hxx>
+#include "fmservs.hxx"
+#include "svx/fmtools.hxx"
+using namespace ::com::sun::star::uno;
+
+//------------------------------------------------------------------------------
+const ::comphelper::StringSequence& getColumnTypes()
+{
+ static ::comphelper::StringSequence aColumnTypes(10);
+ if (!aColumnTypes.getConstArray()[0].getLength())
+ {
+ ::rtl::OUString* pNames = aColumnTypes.getArray();
+ pNames[TYPE_CHECKBOX] = FM_COL_CHECKBOX;
+ pNames[TYPE_COMBOBOX] = FM_COL_COMBOBOX;
+ pNames[TYPE_CURRENCYFIELD] = FM_COL_CURRENCYFIELD;
+ pNames[TYPE_DATEFIELD] = FM_COL_DATEFIELD;
+ pNames[TYPE_FORMATTEDFIELD] = FM_COL_FORMATTEDFIELD;
+ pNames[TYPE_LISTBOX] = FM_COL_LISTBOX;
+ pNames[TYPE_NUMERICFIELD] = FM_COL_NUMERICFIELD;
+ pNames[TYPE_PATTERNFIELD] = FM_COL_PATTERNFIELD;
+ pNames[TYPE_TEXTFIELD] = FM_COL_TEXTFIELD;
+ pNames[TYPE_TIMEFIELD] = FM_COL_TIMEFIELD;
+ }
+ return aColumnTypes;
+}
+
+//------------------------------------------------------------------
+// Vergleichen von PropertyInfo
+extern "C" int
+#if defined( WNT )
+ __cdecl
+#endif
+#if defined( ICC ) && defined( OS2 )
+_Optlink
+#endif
+ NameCompare(const void* pFirst, const void* pSecond)
+{
+ return ((::rtl::OUString*)pFirst)->compareTo(*(::rtl::OUString*)pSecond);
+}
+
+namespace
+{
+ //------------------------------------------------------------------------------
+ sal_Int32 lcl_findPos(const ::rtl::OUString& aStr, const Sequence< ::rtl::OUString>& rList)
+ {
+ const ::rtl::OUString* pStrList = rList.getConstArray();
+ ::rtl::OUString* pResult = (::rtl::OUString*) bsearch(&aStr, (void*)pStrList, rList.getLength(), sizeof(::rtl::OUString),
+ &NameCompare);
+
+ if (pResult)
+ return (pResult - pStrList);
+ else
+ return -1;
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName)
+{
+ const ::rtl::OUString aModelPrefix = ::rtl::OUString::createFromAscii("com.sun.star.form.component.");
+ const ::rtl::OUString aCompatibleModelPrefix = ::rtl::OUString::createFromAscii("stardiv.one.form.component.");
+
+ sal_Int32 nTypeId = -1;
+ if (aModelName == FM_COMPONENT_EDIT)
+ nTypeId = TYPE_TEXTFIELD;
+ else
+ {
+ sal_Int32 nPrefixPos = aModelName.indexOf(aModelPrefix);
+#ifdef DBG_UTIL
+ sal_Int32 nCompatiblePrefixPos = aModelName.indexOf(aCompatibleModelPrefix);
+ DBG_ASSERT( (nPrefixPos != -1) || (nCompatiblePrefixPos != -1), "::getColumnTypeByModelName() : wrong servivce !");
+#endif
+
+ ::rtl::OUString aColumnType = (nPrefixPos != -1)
+ ? aModelName.copy(aModelPrefix.getLength())
+ : aModelName.copy(aCompatibleModelPrefix.getLength());
+
+ const ::comphelper::StringSequence& rColumnTypes = getColumnTypes();
+ nTypeId = lcl_findPos(aColumnType, rColumnTypes);
+ }
+ return nTypeId;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
new file mode 100644
index 000000000000..1af6a9e23cce
--- /dev/null
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -0,0 +1,3888 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+#include "fmhelp.hrc"
+#include <svx/gridctrl.hxx>
+#include "gridcell.hxx"
+#include "svx/dbtoolsclient.hxx"
+#include "svx/fmtools.hxx"
+#include <svtools/stringtransfer.hxx>
+
+#include "fmprop.hrc"
+#include <svtools/stringtransfer.hxx>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#include <com/sun/star/sdb/RowChangeAction.hpp>
+#include <com/sun/star/sdb/XRowsChangeBroadcaster.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <comphelper/extract.hxx>
+#include <tools/resid.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/sound.hxx>
+#include <vcl/menu.hxx>
+
+#include "fmresids.hrc"
+
+#include <svx/svxids.hrc>
+#include <tools/shl.hxx>
+#include <svx/dialmgr.hxx>
+#include "fmservs.hxx"
+#include "sdbdatacolumn.hxx"
+
+#define HANDLE_ID 0
+
+#include <comphelper/stl_types.hxx>
+#include <comphelper/property.hxx>
+#include "trace.hxx"
+
+#include <algorithm>
+
+using namespace ::svxform;
+using namespace ::svt;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::container;
+using namespace com::sun::star::accessibility;
+
+#define ROWSTATUS(row) !row.Is() ? "NULL" : row->GetStatus() == GRS_CLEAN ? "CLEAN" : row->GetStatus() == GRS_MODIFIED ? "MODIFIED" : row->GetStatus() == GRS_DELETED ? "DELETED" : "INVALID"
+
+
+#define DEFAULT_BROWSE_MODE \
+ BROWSER_COLUMNSELECTION \
+ | BROWSER_MULTISELECTION \
+ | BROWSER_KEEPSELECTION \
+ | BROWSER_TRACKING_TIPS \
+ | BROWSER_HLINESFULL \
+ | BROWSER_VLINESFULL \
+ | BROWSER_HEADERBAR_NEW \
+
+class RowSetEventListener : public ::cppu::WeakImplHelper1<XRowsChangeListener>
+{
+ DbGridControl* m_pControl;
+public:
+ RowSetEventListener(DbGridControl* i_pControl) : m_pControl(i_pControl)
+ {
+ }
+private:
+ // XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& /*i_aEvt*/) throw ( RuntimeException )
+ {
+ }
+ virtual void SAL_CALL rowsChanged(const ::com::sun::star::sdb::RowsChangeEvent& i_aEvt) throw ( RuntimeException )
+ {
+ if ( i_aEvt.Action == RowChangeAction::UPDATE )
+ {
+ ::DbGridControl::GrantControlAccess aAccess;
+ CursorWrapper* pSeek = m_pControl->GetSeekCursor(aAccess);
+ const DbGridRowRef& rSeekRow = m_pControl->GetSeekRow(aAccess);
+ const Any* pIter = i_aEvt.Bookmarks.getConstArray();
+ const Any* pEnd = pIter + i_aEvt.Bookmarks.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ pSeek->moveToBookmark(*pIter);
+ // get the data
+ rSeekRow->SetState(pSeek, sal_True);
+ sal_Int32 nSeekPos = pSeek->getRow() - 1;
+ m_pControl->SetSeekPos(nSeekPos,aAccess);
+ m_pControl->RowModified(nSeekPos);
+ }
+ }
+ }
+};
+//==============================================================================
+
+class GridFieldValueListener;
+DECLARE_STL_MAP(sal_uInt16, GridFieldValueListener*, ::std::less<sal_uInt16>, ColumnFieldValueListeners);
+
+//==============================================================================
+
+DBG_NAME(GridFieldValueListener)
+class GridFieldValueListener : protected ::comphelper::OPropertyChangeListener
+{
+ osl::Mutex m_aMutex;
+ DbGridControl& m_rParent;
+ ::comphelper::OPropertyChangeMultiplexer* m_pRealListener;
+ sal_uInt16 m_nId;
+ sal_Int16 m_nSuspended;
+ sal_Bool m_bDisposed : 1;
+
+public:
+ GridFieldValueListener(DbGridControl& _rParent, const Reference< XPropertySet >& xField, sal_uInt16 _nId);
+ virtual ~GridFieldValueListener();
+
+ virtual void _propertyChanged(const PropertyChangeEvent& evt) throw( RuntimeException );
+
+ void suspend() { ++m_nSuspended; }
+ void resume() { --m_nSuspended; }
+
+ void dispose();
+};
+//------------------------------------------------------------------------------
+GridFieldValueListener::GridFieldValueListener(DbGridControl& _rParent, const Reference< XPropertySet >& _rField, sal_uInt16 _nId)
+ :OPropertyChangeListener(m_aMutex)
+ ,m_rParent(_rParent)
+ ,m_pRealListener(NULL)
+ ,m_nId(_nId)
+ ,m_nSuspended(0)
+ ,m_bDisposed(sal_False)
+{
+ DBG_CTOR(GridFieldValueListener, NULL);
+ if (_rField.is())
+ {
+ m_pRealListener = new ::comphelper::OPropertyChangeMultiplexer(this, _rField);
+ m_pRealListener->addProperty(FM_PROP_VALUE);
+ m_pRealListener->acquire();
+ }
+}
+
+//------------------------------------------------------------------------------
+GridFieldValueListener::~GridFieldValueListener()
+{
+ DBG_DTOR(GridFieldValueListener, NULL);
+ dispose();
+}
+
+//------------------------------------------------------------------------------
+void GridFieldValueListener::_propertyChanged(const PropertyChangeEvent& _evt) throw( RuntimeException )
+{
+ DBG_ASSERT(m_nSuspended>=0, "GridFieldValueListener::_propertyChanged : resume > suspend !");
+ if (m_nSuspended <= 0)
+ m_rParent.FieldValueChanged(m_nId, _evt);
+}
+
+//------------------------------------------------------------------------------
+void GridFieldValueListener::dispose()
+{
+ if (m_bDisposed)
+ {
+ DBG_ASSERT(m_pRealListener == NULL, "GridFieldValueListener::dispose : inconsistent !");
+ return;
+ }
+
+ if (m_pRealListener)
+ {
+ m_pRealListener->dispose();
+ m_pRealListener->release();
+ m_pRealListener = NULL;
+ }
+
+ m_bDisposed = sal_True;
+ m_rParent.FieldListenerDisposing(m_nId);
+}
+
+//==============================================================================
+
+class DisposeListenerGridBridge : public FmXDisposeListener
+{
+ osl::Mutex m_aMutex;
+ DbGridControl& m_rParent;
+ FmXDisposeMultiplexer* m_pRealListener;
+
+public:
+ DisposeListenerGridBridge( DbGridControl& _rParent, const Reference< XComponent >& _rxObject, sal_Int16 _rId = -1);
+ virtual ~DisposeListenerGridBridge();
+
+ virtual void disposing(const EventObject& _rEvent, sal_Int16 _nId) throw( RuntimeException ) { m_rParent.disposing(_nId, _rEvent); }
+};
+
+//==============================================================================
+
+
+DBG_NAME(DisposeListenerGridBridge)
+//------------------------------------------------------------------------------
+DisposeListenerGridBridge::DisposeListenerGridBridge(DbGridControl& _rParent, const Reference< XComponent >& _rxObject, sal_Int16 _rId)
+ :FmXDisposeListener(m_aMutex)
+ ,m_rParent(_rParent)
+ ,m_pRealListener(NULL)
+{
+ DBG_CTOR(DisposeListenerGridBridge,NULL);
+
+ if (_rxObject.is())
+ {
+ m_pRealListener = new FmXDisposeMultiplexer(this, _rxObject, _rId);
+ m_pRealListener->acquire();
+ }
+}
+
+//------------------------------------------------------------------------------
+DisposeListenerGridBridge::~DisposeListenerGridBridge()
+{
+ if (m_pRealListener)
+ {
+ m_pRealListener->dispose();
+ m_pRealListener->release();
+ m_pRealListener = NULL;
+ }
+
+ DBG_DTOR(DisposeListenerGridBridge,NULL);
+}
+
+//==============================================================================
+
+static sal_uInt16 ControlMap[] =
+ {
+ DbGridControl::NavigationBar::RECORD_TEXT,
+ DbGridControl::NavigationBar::RECORD_ABSOLUTE,
+ DbGridControl::NavigationBar::RECORD_OF,
+ DbGridControl::NavigationBar::RECORD_COUNT,
+ DbGridControl::NavigationBar::RECORD_FIRST,
+ DbGridControl::NavigationBar::RECORD_NEXT,
+ DbGridControl::NavigationBar::RECORD_PREV,
+ DbGridControl::NavigationBar::RECORD_LAST,
+ DbGridControl::NavigationBar::RECORD_NEW,
+ 0
+ };
+
+//------------------------------------------------------------------------------
+sal_Bool CompareBookmark(const Any& aLeft, const Any& aRight)
+{
+ return ::comphelper::compare(aLeft, aRight);
+}
+
+//==============================================================================
+class FmXGridSourcePropListener : public ::comphelper::OPropertyChangeListener
+{
+ DbGridControl* m_pParent;
+
+ // a DbGridControl has no mutex, so we use our own as the base class expects one
+ osl::Mutex m_aMutex;
+ sal_Int16 m_nSuspended;
+
+public:
+ FmXGridSourcePropListener(DbGridControl* _pParent);
+
+ void suspend() { ++m_nSuspended; }
+ void resume() { --m_nSuspended; }
+
+ virtual void _propertyChanged(const PropertyChangeEvent& evt) throw( RuntimeException );
+};
+
+//------------------------------------------------------------------------------
+FmXGridSourcePropListener::FmXGridSourcePropListener(DbGridControl* _pParent)
+ :OPropertyChangeListener(m_aMutex)
+ ,m_pParent(_pParent)
+ ,m_nSuspended(0)
+{
+ DBG_ASSERT(m_pParent, "FmXGridSourcePropListener::FmXGridSourcePropListener : invalid parent !");
+}
+
+//------------------------------------------------------------------------------
+void FmXGridSourcePropListener::_propertyChanged(const PropertyChangeEvent& evt) throw( RuntimeException )
+{
+ DBG_ASSERT(m_nSuspended>=0, "FmXGridSourcePropListener::_propertyChanged : resume > suspend !");
+ if (m_nSuspended <= 0)
+ m_pParent->DataSourcePropertyChanged(evt);
+}
+
+//==============================================================================
+//------------------------------------------------------------------------------
+DbGridControl::NavigationBar::AbsolutePos::AbsolutePos(Window* pParent, WinBits nStyle)
+ :NumericField(pParent, nStyle)
+{
+ SetMin(1);
+ SetFirst(1);
+ SetSpinSize(1);
+
+ SetDecimalDigits(0);
+ SetStrictFormat(sal_True);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::NavigationBar::AbsolutePos::KeyInput(const KeyEvent& rEvt)
+{
+ if (rEvt.GetKeyCode() == KEY_RETURN && GetText().Len())
+ {
+ sal_Int64 nRecord = GetValue();
+ if (nRecord < GetMin() || nRecord > GetMax())
+ return;
+ else
+ ((NavigationBar*)GetParent())->PositionDataSource(static_cast<sal_Int32>(nRecord));
+ }
+ else if (rEvt.GetKeyCode() == KEY_TAB)
+ GetParent()->GetParent()->GrabFocus();
+ else
+ NumericField::KeyInput(rEvt);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::NavigationBar::AbsolutePos::LoseFocus()
+{
+ NumericField::LoseFocus();
+ sal_Int64 nRecord = GetValue();
+ if (nRecord < GetMin() || nRecord > GetMax())
+ return;
+ else
+ {
+ ((NavigationBar*)GetParent())->PositionDataSource(static_cast<sal_Int32>(nRecord));
+ ((NavigationBar*)GetParent())->InvalidateState(NavigationBar::RECORD_ABSOLUTE);
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::NavigationBar::PositionDataSource(sal_Int32 nRecord)
+{
+ if (m_bPositioning)
+ return;
+ // the MoveToPosition may cause a LoseFocus which would lead to a second MoveToPosition, so protect agains this
+ // recursion
+ // 68167 - 13.08.99 - FS
+ m_bPositioning = sal_True;
+ ((DbGridControl*)GetParent())->MoveToPosition(nRecord - 1);
+ m_bPositioning = sal_False;
+}
+
+//------------------------------------------------------------------------------
+DbGridControl::NavigationBar::NavigationBar(Window* pParent, WinBits nStyle)
+ :Control(pParent, nStyle)
+ ,m_aRecordText(this, WB_VCENTER)
+ ,m_aAbsolute(this, WB_VCENTER)
+ ,m_aRecordOf(this, WB_VCENTER)
+ ,m_aRecordCount(this, WB_CENTER | WB_VCENTER)
+ ,m_aFirstBtn(this, WB_RECTSTYLE|WB_NOPOINTERFOCUS)
+ ,m_aPrevBtn(this, WB_REPEAT|WB_RECTSTYLE|WB_NOPOINTERFOCUS)
+ ,m_aNextBtn(this, WB_REPEAT|WB_RECTSTYLE|WB_NOPOINTERFOCUS)
+ ,m_aLastBtn(this, WB_RECTSTYLE|WB_NOPOINTERFOCUS)
+ ,m_aNewBtn(this, WB_RECTSTYLE|WB_NOPOINTERFOCUS)
+ ,m_nDefaultWidth(0)
+ ,m_nCurrentPos(-1)
+ ,m_bPositioning(sal_False)
+{
+ m_aFirstBtn.SetSymbol(SYMBOL_FIRST);
+ m_aPrevBtn.SetSymbol(SYMBOL_PREV);
+ m_aNextBtn.SetSymbol(SYMBOL_NEXT);
+ m_aLastBtn.SetSymbol(SYMBOL_LAST);
+ m_aNewBtn.SetModeImage(((DbGridControl*)pParent)->GetImage(DbGridControl_Base::NEW));
+
+ m_aFirstBtn.SetHelpId(HID_GRID_TRAVEL_FIRST);
+ m_aPrevBtn.SetHelpId(HID_GRID_TRAVEL_PREV);
+ m_aNextBtn.SetHelpId(HID_GRID_TRAVEL_NEXT);
+ m_aLastBtn.SetHelpId(HID_GRID_TRAVEL_LAST);
+ m_aNewBtn.SetHelpId(HID_GRID_TRAVEL_NEW);
+ m_aAbsolute.SetHelpId(HID_GRID_TRAVEL_ABSOLUTE);
+ m_aRecordCount.SetHelpId(HID_GRID_NUMBEROFRECORDS);
+
+ // Handler fuer Buttons einrichten
+ m_aFirstBtn.SetClickHdl(LINK(this,NavigationBar,OnClick));
+ m_aPrevBtn.SetClickHdl(LINK(this,NavigationBar,OnClick));
+ m_aNextBtn.SetClickHdl(LINK(this,NavigationBar,OnClick));
+ m_aLastBtn.SetClickHdl(LINK(this,NavigationBar,OnClick));
+ m_aNewBtn.SetClickHdl(LINK(this,NavigationBar,OnClick));
+
+ m_aRecordText.SetText(XubString(SVX_RES(RID_STR_REC_TEXT)));
+ m_aRecordOf.SetText(XubString(SVX_RES(RID_STR_REC_FROM_TEXT)));
+ m_aRecordCount.SetText('?');
+
+ m_nDefaultWidth = ArrangeControls();
+
+ m_aFirstBtn.Disable();
+ m_aPrevBtn.Disable();
+ m_aNextBtn.Disable();
+ m_aLastBtn.Disable();
+ m_aNewBtn.Disable();
+ m_aRecordText.Disable();
+ m_aRecordOf.Disable();
+ m_aRecordCount.Disable();
+ m_aAbsolute.Disable();
+
+ AllSettings aSettings = m_aNextBtn.GetSettings();
+ MouseSettings aMouseSettings = aSettings.GetMouseSettings();
+ aMouseSettings.SetButtonRepeat(aMouseSettings.GetButtonRepeat() / 4);
+ aSettings.SetMouseSettings(aMouseSettings);
+ m_aNextBtn.SetSettings(aSettings, sal_True);
+ m_aPrevBtn.SetSettings(aSettings, sal_True);
+
+ m_aFirstBtn.Show();
+ m_aPrevBtn.Show();
+ m_aNextBtn.Show();
+ m_aLastBtn.Show();
+ m_aNewBtn.Show();
+ m_aRecordText.Show();
+ m_aRecordOf.Show();
+ m_aRecordCount.Show();
+ m_aAbsolute.Show();
+}
+
+namespace
+{
+ void SetPosAndSize(Button& _rButton,Point& _rPos,const Size& _rSize)
+ {
+ _rButton.SetPosPixel( _rPos );
+ _rButton.SetSizePixel( _rSize );
+ _rPos.X() += (sal_uInt16)_rSize.Width();
+ }
+}
+//------------------------------------------------------------------------------
+sal_uInt16 DbGridControl::NavigationBar::ArrangeControls()
+{
+ // Positionierung der Controls
+ // Basisgroessen ermitteln
+ sal_uInt16 nX = 0;
+ sal_uInt16 nY = 0;
+ Rectangle aRect(((DbGridControl*)GetParent())->GetControlArea());
+ const long nH = aRect.GetSize().Height();
+ Size aBorder = LogicToPixel(Size(3, 3),MAP_APPFONT);
+ aBorder = Size(CalcZoom(aBorder.Width()), CalcZoom(aBorder.Height()));
+
+ // Controls Groessen und Positionen setzen
+ //
+ XubString aText = m_aRecordText.GetText();
+ long nTextWidth = m_aRecordText.GetTextWidth(aText);
+ m_aRecordText.SetPosPixel(Point(nX,nY) );
+ m_aRecordText.SetSizePixel(Size(nTextWidth,nH));
+ nX = sal::static_int_cast< sal_uInt16 >(nX + nTextWidth + aBorder.Width());
+
+ m_aAbsolute.SetPosPixel( Point(nX,nY));
+ m_aAbsolute.SetSizePixel( Size(3*nH,aRect.GetSize().Height()) ); // Heuristik XXXXXXX
+ nX = sal::static_int_cast< sal_uInt16 >(nX + (3*nH) + aBorder.Width());
+
+ aText = m_aRecordOf.GetText();
+ nTextWidth = m_aRecordOf.GetTextWidth(aText);
+ m_aRecordOf.SetPosPixel(Point(nX,nY) );
+ m_aRecordOf.SetSizePixel(Size(nTextWidth,nH));
+ nX = sal::static_int_cast< sal_uInt16 >(nX + nTextWidth + aBorder.Width());
+
+ nTextWidth = m_aRecordCount.GetTextWidth( String::CreateFromAscii("0000000 (00000) *") );
+ m_aRecordCount.SetPosPixel(Point(nX,nY) );
+ m_aRecordCount.SetSizePixel(Size(nTextWidth,nH));
+ nX = sal::static_int_cast< sal_uInt16 >(nX + nTextWidth + aBorder.Width());
+
+ Point aButtonPos(nX,nY);
+ Size aButtonSize(nH,nH);
+ SetPosAndSize(m_aFirstBtn, aButtonPos, aButtonSize);
+ SetPosAndSize(m_aPrevBtn, aButtonPos, aButtonSize);
+ SetPosAndSize(m_aNextBtn, aButtonPos, aButtonSize);
+ SetPosAndSize(m_aLastBtn, aButtonPos, aButtonSize);
+ SetPosAndSize(m_aNewBtn, aButtonPos, aButtonSize);
+
+ nX = sal::static_int_cast< sal_uInt16 >(
+ aButtonPos.X() + (sal_uInt16)(nH + aBorder.Width()));
+
+ // Ist der Font des Edits groesser als das Feld?
+ Font aOutputFont = m_aAbsolute.GetFont();
+ if (aOutputFont.GetSize().Height() > nH)
+ {
+ Font aApplFont = OutputDevice::GetDefaultFont(
+ DEFAULTFONT_SANS_UNICODE,
+ Application::GetSettings().GetUILanguage(),
+ DEFAULTFONT_FLAGS_ONLYONE,
+ this
+ );
+ aApplFont.SetSize( Size( 0, nH - 2 ) );
+ m_aAbsolute.SetControlFont( aApplFont );
+
+ aApplFont.SetTransparent( sal_True );
+ m_aRecordText.SetControlFont( aApplFont );
+ m_aRecordOf.SetControlFont( aApplFont );
+ m_aRecordCount.SetControlFont( aApplFont );
+ }
+ return nX;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(DbGridControl::NavigationBar, OnClick, Button *, pButton )
+{
+ DbGridControl* pParent = (DbGridControl*)GetParent();
+
+ if (pParent->m_aMasterSlotExecutor.IsSet())
+ {
+ long lResult = 0;
+ if (pButton == &m_aFirstBtn)
+ lResult = pParent->m_aMasterSlotExecutor.Call((void*)RECORD_FIRST);
+ else if( pButton == &m_aPrevBtn )
+ lResult = pParent->m_aMasterSlotExecutor.Call((void*)RECORD_PREV);
+ else if( pButton == &m_aNextBtn )
+ lResult = pParent->m_aMasterSlotExecutor.Call((void*)RECORD_NEXT);
+ else if( pButton == &m_aLastBtn )
+ lResult = pParent->m_aMasterSlotExecutor.Call((void*)RECORD_LAST);
+ else if( pButton == &m_aNewBtn )
+ lResult = pParent->m_aMasterSlotExecutor.Call((void*)RECORD_NEW);
+
+ if (lResult)
+ // the link already handled it
+ return 0;
+ }
+
+ if (pButton == &m_aFirstBtn)
+ pParent->MoveToFirst();
+ else if( pButton == &m_aPrevBtn )
+ pParent->MoveToPrev();
+ else if( pButton == &m_aNextBtn )
+ pParent->MoveToNext();
+ else if( pButton == &m_aLastBtn )
+ pParent->MoveToLast();
+ else if( pButton == &m_aNewBtn )
+ pParent->AppendNew();
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::NavigationBar::InvalidateAll(sal_Int32 nCurrentPos, sal_Bool bAll)
+{
+ if (m_nCurrentPos != nCurrentPos || nCurrentPos < 0 || bAll)
+ {
+ DbGridControl* pParent = (DbGridControl*)GetParent();
+
+ sal_Int32 nAdjustedRowCount = pParent->GetRowCount() - ((pParent->GetOptions() & DbGridControl::OPT_INSERT) ? 2 : 1);
+
+ // Wann mu� alles invalidiert werden
+ bAll = bAll || m_nCurrentPos <= 0;
+ bAll = bAll || nCurrentPos <= 0;
+ bAll = bAll || m_nCurrentPos >= nAdjustedRowCount;
+ bAll = bAll || nCurrentPos >= nAdjustedRowCount;
+
+ if ( bAll )
+ {
+ m_nCurrentPos = nCurrentPos;
+ int i = 0;
+ while (ControlMap[i])
+ SetState(ControlMap[i++]);
+ }
+ else // befindet sich in der Mitte
+ {
+ m_nCurrentPos = nCurrentPos;
+ SetState(NavigationBar::RECORD_COUNT);
+ SetState(NavigationBar::RECORD_ABSOLUTE);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::NavigationBar::GetState(sal_uInt16 nWhich) const
+{
+ DbGridControl* pParent = (DbGridControl*)GetParent();
+
+ if (!pParent->IsOpen() || pParent->IsDesignMode() || !pParent->IsEnabled()
+ || pParent->IsFilterMode() )
+ return sal_False;
+ else
+ {
+ // check if we have a master state provider
+ if (pParent->m_aMasterStateProvider.IsSet())
+ {
+ long nState = pParent->m_aMasterStateProvider.Call(reinterpret_cast< void* >( nWhich ) );
+ if (nState>=0)
+ return (nState>0);
+ }
+
+ sal_Bool bAvailable = sal_True;
+
+ switch (nWhich)
+ {
+ case NavigationBar::RECORD_FIRST:
+ case NavigationBar::RECORD_PREV:
+ bAvailable = m_nCurrentPos > 0;
+ break;
+ case NavigationBar::RECORD_NEXT:
+ if(pParent->m_bRecordCountFinal)
+ {
+ bAvailable = m_nCurrentPos < pParent->GetRowCount() - 1;
+ if (!bAvailable && pParent->GetOptions() & DbGridControl::OPT_INSERT)
+ bAvailable = (m_nCurrentPos == pParent->GetRowCount() - 2) && pParent->IsModified();
+ }
+ break;
+ case NavigationBar::RECORD_LAST:
+ if(pParent->m_bRecordCountFinal)
+ {
+ if (pParent->GetOptions() & DbGridControl::OPT_INSERT)
+ bAvailable = pParent->IsCurrentAppending() ? pParent->GetRowCount() > 1 :
+ m_nCurrentPos != pParent->GetRowCount() - 2;
+ else
+ bAvailable = m_nCurrentPos != pParent->GetRowCount() - 1;
+ }
+ break;
+ case NavigationBar::RECORD_NEW:
+ bAvailable = (pParent->GetOptions() & DbGridControl::OPT_INSERT) && pParent->GetRowCount() && m_nCurrentPos < pParent->GetRowCount() - 1;
+ break;
+ case NavigationBar::RECORD_ABSOLUTE:
+ bAvailable = pParent->GetRowCount() > 0;
+ break;
+ }
+ return bAvailable;
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::NavigationBar::SetState(sal_uInt16 nWhich)
+{
+ sal_Bool bAvailable = GetState(nWhich);
+ DbGridControl* pParent = (DbGridControl*)GetParent();
+ Window* pWnd = NULL;
+ switch (nWhich)
+ {
+ case NavigationBar::RECORD_FIRST:
+ pWnd = &m_aFirstBtn;
+ break;
+ case NavigationBar::RECORD_PREV:
+ pWnd = &m_aPrevBtn;
+ break;
+ case NavigationBar::RECORD_NEXT:
+ pWnd = &m_aNextBtn;
+ break;
+ case NavigationBar::RECORD_LAST:
+ pWnd = &m_aLastBtn;
+ break;
+ case NavigationBar::RECORD_NEW:
+ pWnd = &m_aNewBtn;
+ break;
+ case NavigationBar::RECORD_ABSOLUTE:
+ pWnd = &m_aAbsolute;
+ if (bAvailable)
+ {
+ if (pParent->m_nTotalCount >= 0)
+ {
+ if (pParent->IsCurrentAppending())
+ m_aAbsolute.SetMax(pParent->m_nTotalCount + 1);
+ else
+ m_aAbsolute.SetMax(pParent->m_nTotalCount);
+ }
+ else
+ m_aAbsolute.SetMax(LONG_MAX);
+
+ m_aAbsolute.SetValue(m_nCurrentPos + 1);
+ }
+ else
+ m_aAbsolute.SetText(String());
+ break;
+ case NavigationBar::RECORD_TEXT:
+ pWnd = &m_aRecordText;
+ break;
+ case NavigationBar::RECORD_OF:
+ pWnd = &m_aRecordOf;
+ break;
+ case NavigationBar::RECORD_COUNT:
+ {
+ pWnd = &m_aRecordCount;
+ String aText;
+ if (bAvailable)
+ {
+ if (pParent->GetOptions() & DbGridControl::OPT_INSERT)
+ {
+ if (pParent->IsCurrentAppending() && !pParent->IsModified())
+ aText = String::CreateFromInt32(pParent->GetRowCount());
+ else
+ aText = String::CreateFromInt32(pParent->GetRowCount() - 1);
+ }
+ else
+ aText = String::CreateFromInt32(pParent->GetRowCount());
+ if(!pParent->m_bRecordCountFinal)
+ aText += String::CreateFromAscii(" *");
+ }
+ else
+ aText = String();
+
+ // add the number of selected rows, if applicable
+ if (pParent->GetSelectRowCount())
+ {
+ String aExtendedInfo(aText);
+ aExtendedInfo.AppendAscii(" (");
+ aExtendedInfo += String::CreateFromInt32(pParent->GetSelectRowCount());
+ aExtendedInfo += ')';
+ pWnd->SetText(aExtendedInfo);
+ }
+ else
+ pWnd->SetText(aText);
+
+ pParent->SetRealRowCount(aText);
+ } break;
+ }
+ DBG_ASSERT(pWnd, "kein Fenster");
+ if (pWnd && (pWnd->IsEnabled() != bAvailable))
+ // this "pWnd->IsEnabled() != bAvailable" is a little hack : Window::Enable always generates a user
+ // event (ImplGenerateMouseMove) even if nothing happened. This may lead to some unwanted effects, so we
+ // do this check.
+ // For further explanation see Bug 69900.
+ // FS - 18.11.99
+ pWnd->Enable(bAvailable);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::NavigationBar::Resize()
+{
+ Control::Resize();
+ ArrangeControls();
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::NavigationBar::Paint(const Rectangle& rRect)
+{
+ Control::Paint(rRect);
+ Point aAbsolutePos = m_aAbsolute.GetPosPixel();
+ Size aAbsoluteSize = m_aAbsolute.GetSizePixel();
+
+ DrawLine(Point(aAbsolutePos.X() - 1, 0 ),
+ Point(aAbsolutePos.X() - 1, aAbsolutePos.Y() + aAbsoluteSize.Height()));
+
+ DrawLine(Point(aAbsolutePos.X() + aAbsoluteSize.Width() + 1, 0 ),
+ Point(aAbsolutePos.X() + aAbsoluteSize.Width() + 1, aAbsolutePos.Y() + aAbsoluteSize.Height()));
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::NavigationBar::StateChanged( StateChangedType nType )
+{
+ Control::StateChanged( nType );
+
+ Window* pWindows[] = { &m_aRecordText,
+ &m_aAbsolute,
+ &m_aRecordOf,
+ &m_aRecordCount,
+ &m_aFirstBtn,
+ &m_aPrevBtn,
+ &m_aNextBtn,
+ &m_aLastBtn,
+ &m_aNewBtn
+ };
+
+ switch ( nType )
+ {
+ case STATE_CHANGE_MIRRORING:
+ {
+ BOOL bIsRTLEnabled = IsRTLEnabled();
+ for ( size_t i=0; i < SAL_N_ELEMENTS( pWindows ); ++i )
+ pWindows[i]->EnableRTL( bIsRTLEnabled );
+ }
+ break;
+
+ case STATE_CHANGE_ZOOM:
+ {
+ Fraction aZoom = GetZoom();
+
+ // not all of these controls need to know the new zoom, but to be sure ...
+ Font aFont( GetSettings().GetStyleSettings().GetFieldFont() );
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+
+ for (size_t i=0; i < SAL_N_ELEMENTS(pWindows); ++i)
+ {
+ pWindows[i]->SetZoom(aZoom);
+ pWindows[i]->SetZoomedPointFont(aFont);
+ }
+
+ SetZoomedPointFont( aFont );
+
+ // rearrange the controls
+ m_nDefaultWidth = ArrangeControls();
+ }
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+DbGridRow::DbGridRow(CursorWrapper* pCur, sal_Bool bPaintCursor)
+ :m_bIsNew(sal_False)
+{
+
+ if (pCur && pCur->Is())
+ {
+ Reference< XIndexAccess > xColumns(pCur->getColumns(), UNO_QUERY);
+ DataColumn* pColumn;
+ for (sal_Int32 i = 0; i < xColumns->getCount(); ++i)
+ {
+ Reference< XPropertySet > xColSet;
+ ::cppu::extractInterface(xColSet, xColumns->getByIndex(i));
+ pColumn = new DataColumn(xColSet);
+ m_aVariants.Insert(pColumn, LIST_APPEND);
+ }
+
+ if (pCur->rowDeleted())
+ m_eStatus = GRS_DELETED;
+ else
+ {
+ if (bPaintCursor)
+ m_eStatus = (pCur->isAfterLast() || pCur->isBeforeFirst()) ? GRS_INVALID : GRS_CLEAN;
+ else
+ {
+ Reference< XPropertySet > xSet = pCur->getPropertySet();
+ if (xSet.is())
+ {
+ m_bIsNew = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISNEW));
+ if (!m_bIsNew && (pCur->isAfterLast() || pCur->isBeforeFirst()))
+ m_eStatus = GRS_INVALID;
+ else if (::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISMODIFIED)))
+ m_eStatus = GRS_MODIFIED;
+ else
+ m_eStatus = GRS_CLEAN;
+ }
+ else
+ m_eStatus = GRS_INVALID;
+ }
+ }
+ if (!m_bIsNew && IsValid())
+ m_aBookmark = pCur->getBookmark();
+ else
+ m_aBookmark = Any();
+ }
+ else
+ m_eStatus = GRS_INVALID;
+}
+
+//------------------------------------------------------------------------------
+DbGridRow::~DbGridRow()
+{
+ sal_uInt32 nCount = m_aVariants.Count();
+ for (sal_uInt32 i = 0; i < nCount; i++)
+ delete m_aVariants.GetObject(i);
+}
+
+//------------------------------------------------------------------------------
+void DbGridRow::SetState(CursorWrapper* pCur, sal_Bool bPaintCursor)
+{
+ if (pCur && pCur->Is())
+ {
+ if (pCur->rowDeleted())
+ {
+ m_eStatus = GRS_DELETED;
+ m_bIsNew = sal_False;
+ }
+ else
+ {
+ m_eStatus = GRS_CLEAN;
+ if (!bPaintCursor)
+ {
+ Reference< XPropertySet > xSet = pCur->getPropertySet();
+ DBG_ASSERT(xSet.is(), "DbGridRow::SetState : invalid cursor !");
+
+ if (::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISMODIFIED)))
+ m_eStatus = GRS_MODIFIED;
+ m_bIsNew = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISNEW));
+ }
+ else
+ m_bIsNew = sal_False;
+ }
+
+ try
+ {
+ if (!m_bIsNew && IsValid())
+ m_aBookmark = pCur->getBookmark();
+ else
+ m_aBookmark = Any();
+ }
+ catch(SQLException&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ m_aBookmark = Any();
+ m_eStatus = GRS_INVALID;
+ m_bIsNew = sal_False;
+ }
+ }
+ else
+ {
+ m_aBookmark = Any();
+ m_eStatus = GRS_INVALID;
+ m_bIsNew = sal_False;
+ }
+}
+
+DBG_NAME(DbGridControl);
+//------------------------------------------------------------------------------
+DbGridControl::DbGridControl(
+ Reference< XMultiServiceFactory > _rxFactory,
+ Window* pParent,
+ WinBits nBits)
+ :DbGridControl_Base(pParent, EBBF_NONE, nBits, DEFAULT_BROWSE_MODE )
+ ,m_xServiceFactory(_rxFactory)
+ ,m_aBar(this)
+ ,m_nAsynAdjustEvent(0)
+ ,m_pDataSourcePropMultiplexer(NULL)
+ ,m_pDataSourcePropListener(NULL)
+ ,m_pFieldListeners(NULL)
+ ,m_pCursorDisposeListener(NULL)
+ ,m_pGridListener(NULL)
+ ,m_pDataCursor(NULL)
+ ,m_pSeekCursor(NULL)
+ ,m_nSeekPos(-1)
+ ,m_nTotalCount(-1)
+ ,m_aNullDate(OTypeConversionClient().getStandardDate())
+ ,m_nMode(DEFAULT_BROWSE_MODE)
+ ,m_nCurrentPos(-1)
+ ,m_nDeleteEvent(0)
+ ,m_nOptions(OPT_READONLY)
+ ,m_nOptionMask(OPT_INSERT | OPT_UPDATE | OPT_DELETE)
+ ,m_nLastColId((USHORT)-1)
+ ,m_nLastRowId(-1)
+ ,m_bDesignMode(sal_False)
+ ,m_bRecordCountFinal(sal_False)
+ ,m_bMultiSelection(sal_True)
+ ,m_bNavigationBar(sal_True)
+ ,m_bSynchDisplay(sal_True)
+ ,m_bForceROController(sal_False)
+ ,m_bHandle(sal_True)
+ ,m_bFilterMode(sal_False)
+ ,m_bWantDestruction(sal_False)
+ ,m_bInAdjustDataSource(sal_False)
+ ,m_bPendingAdjustRows(sal_False)
+ ,m_bHideScrollbars( sal_False )
+ ,m_bUpdating(sal_False)
+{
+ DBG_CTOR(DbGridControl,NULL);
+
+ String sName(SVX_RES(RID_STR_NAVIGATIONBAR));
+ m_aBar.SetAccessibleName(sName);
+ m_aBar.Show();
+ ImplInitWindow( InitAll );
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::InsertHandleColumn()
+{
+ // Handle Column einfuegen
+ // Da die BrowseBox ohne handleColums Paintprobleme hat
+ // wird diese versteckt
+ if (HasHandle())
+ BrowseBox::InsertHandleColumn(GetDefaultColumnWidth(String()));
+ else
+ BrowseBox::InsertHandleColumn(0);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::Init()
+{
+ BrowserHeader* pNewHeader = CreateHeaderBar(this);
+ pHeader->SetMouseTransparent(sal_False);
+
+ SetHeaderBar(pNewHeader);
+ SetMode(m_nMode);
+ SetCursorColor(Color(0xFF, 0, 0));
+
+ InsertHandleColumn();
+}
+
+//------------------------------------------------------------------------------
+DbGridControl::~DbGridControl()
+{
+ RemoveColumns();
+
+ {
+ m_bWantDestruction = sal_True;
+ osl::MutexGuard aGuard(m_aDestructionSafety);
+ if (m_pFieldListeners)
+ DisconnectFromFields();
+ if (m_pCursorDisposeListener)
+ {
+ delete m_pCursorDisposeListener;
+ m_pCursorDisposeListener = NULL;
+ }
+ }
+
+ if (m_nDeleteEvent)
+ Application::RemoveUserEvent(m_nDeleteEvent);
+
+ if (m_pDataSourcePropMultiplexer)
+ {
+ m_pDataSourcePropMultiplexer->dispose();
+ m_pDataSourcePropMultiplexer->release(); // this should delete the multiplexer
+ delete m_pDataSourcePropListener;
+ m_pDataSourcePropMultiplexer = NULL;
+ m_pDataSourcePropListener = NULL;
+ }
+ m_xRowSetListener.clear();
+
+ delete m_pDataCursor;
+ delete m_pSeekCursor;
+
+ DBG_DTOR(DbGridControl,NULL);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::StateChanged( StateChangedType nType )
+{
+ DbGridControl_Base::StateChanged( nType );
+
+ switch (nType)
+ {
+ case STATE_CHANGE_MIRRORING:
+ ImplInitWindow( InitWritingMode );
+ Invalidate();
+ break;
+
+ case STATE_CHANGE_ZOOM:
+ {
+ ImplInitWindow( InitFont );
+
+ // and give it a chance to rearrange
+ Point aPoint = GetControlArea().TopLeft();
+ sal_uInt16 nX = (sal_uInt16)aPoint.X();
+ ArrangeControls(nX, (sal_uInt16)aPoint.Y());
+ ReserveControlArea((sal_uInt16)nX);
+ }
+ break;
+ case STATE_CHANGE_CONTROLFONT:
+ ImplInitWindow( InitFont );
+ Invalidate();
+ break;
+ case STATE_CHANGE_CONTROLFOREGROUND:
+ ImplInitWindow( InitForeground );
+ Invalidate();
+ break;
+ case STATE_CHANGE_CONTROLBACKGROUND:
+ ImplInitWindow( InitBackground );
+ Invalidate();
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ DbGridControl_Base::DataChanged( rDCEvt );
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS ) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitWindow( InitAll );
+ Invalidate();
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::Select()
+{
+ DbGridControl_Base::Select();
+
+ // as the selected rows may have changed, udate the according display in our navigation bar
+ m_aBar.InvalidateState(NavigationBar::RECORD_COUNT);
+
+ if (m_pGridListener)
+ m_pGridListener->selectionChanged();
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::ImplInitWindow( const InitWindowFacet _eInitWhat )
+{
+ for ( sal_uInt32 i = 0; i < m_aColumns.Count(); ++i )
+ {
+ DbGridColumn* pCol = m_aColumns.GetObject(i);
+ if (pCol)
+ pCol->ImplInitWindow( GetDataWindow(), _eInitWhat );
+ }
+
+ if ( ( _eInitWhat & InitWritingMode ) != 0 )
+ {
+ if ( m_bNavigationBar )
+ {
+ m_aBar.EnableRTL( IsRTLEnabled() );
+ }
+ }
+
+ if ( ( _eInitWhat & InitFont ) != 0 )
+ {
+ if ( m_bNavigationBar )
+ {
+ Font aFont = m_aBar.GetSettings().GetStyleSettings().GetFieldFont();
+ if ( IsControlFont() )
+ m_aBar.SetControlFont( GetControlFont() );
+ else
+ m_aBar.SetControlFont();
+
+ m_aBar.SetZoom( GetZoom() );
+ }
+ }
+
+ if ( ( _eInitWhat & InitBackground ) != 0 )
+ {
+ if (IsControlBackground())
+ {
+ GetDataWindow().SetBackground(GetControlBackground());
+ GetDataWindow().SetControlBackground(GetControlBackground());
+ GetDataWindow().SetFillColor(GetControlBackground());
+ }
+ else
+ {
+ GetDataWindow().SetControlBackground();
+ GetDataWindow().SetFillColor(GetFillColor());
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::RemoveRows(sal_Bool bNewCursor)
+{
+ // Hat sich der DatenCursor verandert ?
+ if (!bNewCursor)
+ {
+ DELETEZ(m_pSeekCursor);
+ m_xPaintRow = m_xDataRow = m_xEmptyRow = m_xCurrentRow = m_xSeekRow = NULL;
+ m_nCurrentPos = m_nSeekPos = -1;
+ m_nOptions = OPT_READONLY;
+
+ RowRemoved(0, GetRowCount(), sal_False);
+ m_nTotalCount = -1;
+ }
+ else
+ {
+ RemoveRows();
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::RemoveRows()
+{
+ // we're going to remove all columns and all row, so deactivate the current cell
+ if (IsEditing())
+ DeactivateCell();
+
+ // alle Columns deinitialisieren
+ // existieren Spalten, dann alle Controller freigeben
+ for (sal_uInt32 i = 0; i < m_aColumns.Count(); i++)
+ m_aColumns.GetObject(i)->Clear();
+
+ DELETEZ(m_pSeekCursor);
+ DELETEZ(m_pDataCursor);
+
+ m_xPaintRow = m_xDataRow = m_xEmptyRow = m_xCurrentRow = m_xSeekRow = NULL;
+ m_nCurrentPos = m_nSeekPos = m_nTotalCount = -1;
+ m_nOptions = OPT_READONLY;
+
+ // Anzahl Saetze im Browser auf 0 zuruecksetzen
+ DbGridControl_Base::RemoveRows();
+ m_aBar.InvalidateAll(m_nCurrentPos, sal_True);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::ArrangeControls(sal_uInt16& nX, sal_uInt16 nY)
+{
+ // Positionierung der Controls
+ if (m_bNavigationBar)
+ {
+ nX = m_aBar.GetDefaultWidth();
+ Rectangle aRect(GetControlArea());
+ m_aBar.SetPosSizePixel(Point(0,nY + 1), Size(nX, aRect.GetSize().Height() - 1));
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::EnableHandle(sal_Bool bEnable)
+{
+ if (m_bHandle == bEnable)
+ return;
+
+ // HandleColumn wird nur ausgeblendet,
+ // da es sonst etliche Probleme mit dem Zeichnen gibt
+ RemoveColumn(0);
+ m_bHandle = bEnable;
+ InsertHandleColumn();
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ bool adjustModeForScrollbars( BrowserMode& _rMode, sal_Bool _bNavigationBar, sal_Bool _bHideScrollbars )
+ {
+ BrowserMode nOldMode = _rMode;
+
+ if ( !_bNavigationBar )
+ {
+ _rMode &= ~BROWSER_AUTO_HSCROLL;
+ }
+
+ if ( _bHideScrollbars )
+ {
+ _rMode |= ( BROWSER_NO_HSCROLL | BROWSER_NO_VSCROLL );
+ _rMode &= ~( BROWSER_AUTO_HSCROLL | BROWSER_AUTO_VSCROLL );
+ }
+ else
+ {
+ _rMode |= ( BROWSER_AUTO_HSCROLL | BROWSER_AUTO_VSCROLL );
+ _rMode &= ~( BROWSER_NO_HSCROLL | BROWSER_NO_VSCROLL );
+ }
+
+ // note: if we have a navigation bar, we always have a AUTO_HSCROLL. In particular,
+ // _bHideScrollbars is ignored then
+ if ( _bNavigationBar )
+ {
+ _rMode |= BROWSER_AUTO_HSCROLL;
+ _rMode &= ~BROWSER_NO_HSCROLL;
+ }
+
+ return nOldMode != _rMode;
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::EnableNavigationBar(sal_Bool bEnable)
+{
+ if (m_bNavigationBar == bEnable)
+ return;
+
+ m_bNavigationBar = bEnable;
+
+ if (bEnable)
+ {
+ m_aBar.Show();
+ m_aBar.Enable();
+ m_aBar.InvalidateAll(m_nCurrentPos, sal_True);
+
+ if ( adjustModeForScrollbars( m_nMode, m_bNavigationBar, m_bHideScrollbars ) )
+ SetMode( m_nMode );
+
+ // liefert die Groe�e der Reserved ControlArea
+ Point aPoint = GetControlArea().TopLeft();
+ sal_uInt16 nX = (sal_uInt16)aPoint.X();
+
+ ArrangeControls(nX, (sal_uInt16)aPoint.Y());
+ ReserveControlArea((sal_uInt16)nX);
+ }
+ else
+ {
+ m_aBar.Hide();
+ m_aBar.Disable();
+
+ if ( adjustModeForScrollbars( m_nMode, m_bNavigationBar, m_bHideScrollbars ) )
+ SetMode( m_nMode );
+
+ ReserveControlArea();
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_uInt16 DbGridControl::SetOptions(sal_uInt16 nOpt)
+{
+ DBG_ASSERT(!m_xCurrentRow || !m_xCurrentRow->IsModified(),
+ "DbGridControl::SetOptions : please do not call when editing a record (things are much easier this way ;) !");
+
+ // for the next setDataSource (which is triggered by a refresh, for instance)
+ m_nOptionMask = nOpt;
+
+ // normalize the new options
+ Reference< XPropertySet > xDataSourceSet = m_pDataCursor->getPropertySet();
+ if (xDataSourceSet.is())
+ {
+ // feststellen welche Updatem�glichkeiten bestehen
+ sal_Int32 nPrivileges = 0;
+ xDataSourceSet->getPropertyValue(FM_PROP_PRIVILEGES) >>= nPrivileges;
+ if ((nPrivileges & Privilege::INSERT) == 0)
+ nOpt &= ~OPT_INSERT;
+ if ((nPrivileges & Privilege::UPDATE) == 0)
+ nOpt &= ~OPT_UPDATE;
+ if ((nPrivileges & Privilege::DELETE) == 0)
+ nOpt &= ~OPT_DELETE;
+ }
+ else
+ nOpt = OPT_READONLY;
+
+ // need to do something after that ?
+ if (nOpt == m_nOptions)
+ return m_nOptions;
+
+ // the 'update' option only affects our BrowserMode (with or w/o focus rect)
+ BrowserMode nNewMode = m_nMode;
+ if ((m_nMode & BROWSER_CURSOR_WO_FOCUS) == 0)
+ {
+ if (nOpt & OPT_UPDATE)
+ nNewMode |= BROWSER_HIDECURSOR;
+ else
+ nNewMode &= ~BROWSER_HIDECURSOR;
+ }
+ else
+ nNewMode &= ~BROWSER_HIDECURSOR;
+ // should not be neccessary if EnablePermanentCursor is used to change the cursor behaviour, but to be sure ...
+
+ if (nNewMode != m_nMode)
+ {
+ SetMode(nNewMode);
+ m_nMode = nNewMode;
+ }
+
+ // _after_ setting the mode because this results in an ActivateCell
+ DeactivateCell();
+
+ sal_Bool bInsertChanged = (nOpt & OPT_INSERT) != (m_nOptions & OPT_INSERT);
+ m_nOptions = nOpt;
+ // we need to set this before the code below because it indirectly uses m_nOptions
+
+ // the 'insert' option affects our empty row
+ if (bInsertChanged)
+ {
+ if (m_nOptions & OPT_INSERT)
+ { // the insert option is to be set
+ m_xEmptyRow = new DbGridRow();
+ RowInserted(GetRowCount(), 1, sal_True);
+ }
+ else
+ { // the insert option is to be reset
+ m_xEmptyRow = NULL;
+ if ((GetCurRow() == GetRowCount() - 1) && (GetCurRow() > 0))
+ GoToRowColumnId(GetCurRow() - 1, GetCurColumnId());
+ RowRemoved(GetRowCount(), 1, sal_True);
+ }
+ }
+
+ // the 'delete' options has no immediate consequences
+
+ ActivateCell();
+ Invalidate();
+ return m_nOptions;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::ForceHideScrollbars( sal_Bool _bForce )
+{
+ if ( m_bHideScrollbars == _bForce )
+ return;
+
+ m_bHideScrollbars = _bForce;
+
+ if ( adjustModeForScrollbars( m_nMode, m_bNavigationBar, m_bHideScrollbars ) )
+ SetMode( m_nMode );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::IsForceHideScrollbars() const
+{
+ return m_bHideScrollbars;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::EnablePermanentCursor(sal_Bool bEnable)
+{
+ if (IsPermanentCursorEnabled() == bEnable)
+ return;
+
+ if (bEnable)
+ {
+ m_nMode &= ~BROWSER_HIDECURSOR; // without this BROWSER_CURSOR_WO_FOCUS won't have any affect
+ m_nMode |= BROWSER_CURSOR_WO_FOCUS;
+ }
+ else
+ {
+ if (m_nOptions & OPT_UPDATE)
+ m_nMode |= BROWSER_HIDECURSOR; // no cursor at all
+ else
+ m_nMode &= ~BROWSER_HIDECURSOR; // at least the "non-permanent" cursor
+
+ m_nMode &= ~BROWSER_CURSOR_WO_FOCUS;
+ }
+ SetMode(m_nMode);
+
+ sal_Bool bWasEditing = IsEditing();
+ DeactivateCell();
+ if (bWasEditing)
+ ActivateCell();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::IsPermanentCursorEnabled() const
+{
+ return ((m_nMode & BROWSER_CURSOR_WO_FOCUS) != 0) && ((m_nMode & BROWSER_HIDECURSOR) == 0);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::refreshController(sal_uInt16 _nColId, GrantControlAccess /*_aAccess*/)
+{
+ if ((GetCurColumnId() == _nColId) && IsEditing())
+ { // the controller which is currently active needs to be refreshed
+ DeactivateCell();
+ ActivateCell();
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::SetMultiSelection(sal_Bool bMulti)
+{
+ m_bMultiSelection = bMulti;
+ if (m_bMultiSelection)
+ m_nMode |= BROWSER_MULTISELECTION;
+ else
+ m_nMode &= ~BROWSER_MULTISELECTION;
+
+ SetMode(m_nMode);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::setDataSource(const Reference< XRowSet >& _xCursor, sal_uInt16 nOpts)
+{
+ if (!_xCursor.is() && !m_pDataCursor)
+ return;
+
+ if (m_pDataSourcePropMultiplexer)
+ {
+ m_pDataSourcePropMultiplexer->dispose();
+ m_pDataSourcePropMultiplexer->release(); // this should delete the multiplexer
+ delete m_pDataSourcePropListener;
+ m_pDataSourcePropMultiplexer = NULL;
+ m_pDataSourcePropListener = NULL;
+ }
+ m_xRowSetListener.clear();
+
+ // is the new cursor valid ?
+ // the cursor is only valid if it contains some columns
+ // if there is no cursor or the cursor is not valid we have to clean up an leave
+ if (!_xCursor.is() || !Reference< XColumnsSupplier > (_xCursor, UNO_QUERY)->getColumns()->hasElements())
+ {
+ RemoveRows();
+ return;
+ }
+
+ // Hat sich der DatenCursor verandert ?
+ sal_uInt16 nCurPos = GetColumnPos(GetCurColumnId());
+
+ SetUpdateMode(sal_False);
+ RemoveRows();
+ DisconnectFromFields();
+
+ DELETEZ(m_pCursorDisposeListener);
+
+ {
+ ::osl::MutexGuard aGuard(m_aAdjustSafety);
+ if (m_nAsynAdjustEvent)
+ {
+ // the adjust was thought to work with the old cursor which we don't have anymore
+ RemoveUserEvent(m_nAsynAdjustEvent);
+ m_nAsynAdjustEvent = 0;
+ }
+ }
+
+ // get a new formatter and data cursor
+ m_xFormatter = NULL;
+ OStaticDataAccessTools aStaticTools;
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier = aStaticTools.getNumberFormats(aStaticTools.getRowSetConnection(_xCursor), sal_True);
+ if (xSupplier.is() && m_xServiceFactory.is())
+ {
+ m_xFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(
+ m_xServiceFactory->createInstance(FM_NUMBER_FORMATTER),
+ UNO_QUERY);
+ if (m_xFormatter.is())
+ {
+ m_xFormatter->attachNumberFormatsSupplier(xSupplier);
+
+ // retrieve the datebase of the Numberformatter
+ try
+ {
+ xSupplier->getNumberFormatSettings()->getPropertyValue(rtl::OUString::createFromAscii("NullDate")) >>= m_aNullDate;
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+
+ m_pDataCursor = new CursorWrapper(_xCursor);
+
+ // now create a cursor for painting rows
+ // we need that cursor only if we are not in insert only mode
+ Reference< XResultSet > xClone;
+ Reference< XResultSetAccess > xAccess( _xCursor, UNO_QUERY );
+ try
+ {
+ xClone = xAccess.is() ? xAccess->createResultSet() : Reference< XResultSet > ();
+ }
+ catch(Exception&)
+ {
+ }
+ if (xClone.is())
+ m_pSeekCursor = new CursorWrapper(xClone);
+
+ // property listening on the data source
+ // (Normally one class would be sufficient : the multiplexer which could forward the property change to us.
+ // But for that we would have been derived from ::comphelper::OPropertyChangeListener, which isn't exported.
+ // So we introduce a second class, which is a ::comphelper::OPropertyChangeListener (in the implementation file we know this class)
+ // and forwards the property changes to a our special method "DataSourcePropertyChanged".)
+ if (m_pDataCursor)
+ {
+ m_pDataSourcePropListener = new FmXGridSourcePropListener(this);
+ m_pDataSourcePropMultiplexer = new ::comphelper::OPropertyChangeMultiplexer(m_pDataSourcePropListener, m_pDataCursor->getPropertySet() );
+ m_pDataSourcePropMultiplexer->acquire();
+ m_pDataSourcePropMultiplexer->addProperty(FM_PROP_ISMODIFIED);
+ m_pDataSourcePropMultiplexer->addProperty(FM_PROP_ISNEW);
+ }
+
+ BrowserMode nOldMode = m_nMode;
+ if (m_pSeekCursor)
+ {
+ try
+ {
+ Reference< XPropertySet > xSet(_xCursor, UNO_QUERY);
+ if (xSet.is())
+ {
+ // feststellen welche Updatemoeglichkeiten bestehen
+ sal_Int32 nConcurrency = ResultSetConcurrency::READ_ONLY;
+ xSet->getPropertyValue(FM_PROP_RESULTSET_CONCURRENCY) >>= nConcurrency;
+
+ if ( ResultSetConcurrency::UPDATABLE == nConcurrency )
+ {
+ sal_Int32 nPrivileges = 0;
+ xSet->getPropertyValue(FM_PROP_PRIVILEGES) >>= nPrivileges;
+
+ // Insert Option should be set if insert only otherwise you won't see any rows
+ // and no insertion is possible
+ if ((m_nOptionMask & OPT_INSERT) && ((nPrivileges & Privilege::INSERT) == Privilege::INSERT) && (nOpts & OPT_INSERT))
+ m_nOptions |= OPT_INSERT;
+ if ((m_nOptionMask & OPT_UPDATE) && ((nPrivileges & Privilege::UPDATE) == Privilege::UPDATE) && (nOpts & OPT_UPDATE))
+ m_nOptions |= OPT_UPDATE;
+ if ((m_nOptionMask & OPT_DELETE) && ((nPrivileges & Privilege::DELETE) == Privilege::DELETE) && (nOpts & OPT_DELETE))
+ m_nOptions |= OPT_DELETE;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ sal_Bool bPermanentCursor = IsPermanentCursorEnabled();
+ m_nMode = DEFAULT_BROWSE_MODE;
+
+ if ( bPermanentCursor )
+ {
+ m_nMode |= BROWSER_CURSOR_WO_FOCUS;
+ m_nMode &= ~BROWSER_HIDECURSOR;
+ }
+ else
+ {
+ // Duerfen Updates gemacht werden, kein Focus-RechtEck
+ if ( m_nOptions & OPT_UPDATE )
+ m_nMode |= BROWSER_HIDECURSOR;
+ }
+
+ if ( m_bMultiSelection )
+ m_nMode |= BROWSER_MULTISELECTION;
+ else
+ m_nMode &= ~BROWSER_MULTISELECTION;
+
+ adjustModeForScrollbars( m_nMode, m_bNavigationBar, m_bHideScrollbars );
+
+ Reference< XColumnsSupplier > xSupplyColumns(_xCursor, UNO_QUERY);
+ if (xSupplyColumns.is())
+ InitColumnsByFields(Reference< XIndexAccess > (xSupplyColumns->getColumns(), UNO_QUERY));
+
+ ConnectToFields();
+ }
+
+ sal_uInt32 nRecordCount(0);
+
+ if (m_pSeekCursor)
+ {
+ Reference< XPropertySet > xSet = m_pDataCursor->getPropertySet();
+ xSet->getPropertyValue(FM_PROP_ROWCOUNT) >>= nRecordCount;
+ m_bRecordCountFinal = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ROWCOUNTFINAL));
+
+ m_xRowSetListener = new RowSetEventListener(this);
+ Reference< XRowsChangeBroadcaster> xChangeBroad(xSet,UNO_QUERY);
+ if ( xChangeBroad.is( ) )
+ xChangeBroad->addRowsChangeListener(m_xRowSetListener);
+
+
+ // insert the currently known rows
+ // and one row if we are able to insert rows
+ if (m_nOptions & OPT_INSERT)
+ {
+ // insert the empty row for insertion
+ m_xEmptyRow = new DbGridRow();
+ ++nRecordCount;
+ }
+ if (nRecordCount)
+ {
+ m_xPaintRow = m_xSeekRow = new DbGridRow(m_pSeekCursor, sal_True);
+ m_xDataRow = new DbGridRow(m_pDataCursor, sal_False);
+ RowInserted(0, nRecordCount, sal_False);
+
+ if (m_xSeekRow->IsValid())
+ try
+ {
+ m_nSeekPos = m_pSeekCursor->getRow() - 1;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ m_nSeekPos = -1;
+ }
+ }
+ else
+ {
+ // no rows so we don't need a seekcursor
+ DELETEZ(m_pSeekCursor);
+ }
+ }
+
+ // Zur alten Spalte gehen
+ if (!nCurPos || nCurPos >= ColCount())
+ nCurPos = 1;
+
+ // there are rows so go to the selected current column
+ if (nRecordCount)
+ GoToRowColumnId(0, GetColumnId(nCurPos));
+ // else stop the editing if neccessary
+ else if (IsEditing())
+ DeactivateCell();
+
+ // now reset the mode
+ if (m_nMode != nOldMode)
+ SetMode(m_nMode);
+
+ // beim Resizen wird RecalcRows gerufen
+ if (!IsResizing() && GetRowCount())
+ RecalcRows(GetTopRow(), GetVisibleRows(), sal_True);
+
+ m_aBar.InvalidateAll(m_nCurrentPos, sal_True);
+ SetUpdateMode(sal_True);
+
+ // start listening on the seek cursor
+ if (m_pSeekCursor)
+ m_pCursorDisposeListener = new DisposeListenerGridBridge(*this, Reference< XComponent > ((Reference< XInterface >)*m_pSeekCursor, UNO_QUERY), 0);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::RemoveColumns()
+{
+ if ( IsEditing() )
+ DeactivateCell();
+
+ for (sal_uInt32 i = 0; i < m_aColumns.Count(); i++)
+ delete m_aColumns.GetObject(i);
+ m_aColumns.Clear();
+
+ DbGridControl_Base::RemoveColumns();
+}
+
+//------------------------------------------------------------------------------
+DbGridColumn* DbGridControl::CreateColumn(sal_uInt16 nId) const
+{
+ return new DbGridColumn(nId, *(DbGridControl*)this);
+}
+
+//------------------------------------------------------------------------------
+sal_uInt16 DbGridControl::AppendColumn(const XubString& rName, sal_uInt16 nWidth, sal_uInt16 nModelPos, sal_uInt16 nId)
+{
+ DBG_ASSERT(nId == (sal_uInt16)-1, "DbGridControl::AppendColumn : I want to set the ID myself ...");
+ sal_uInt16 nRealPos = nModelPos;
+ if (nModelPos != HEADERBAR_APPEND)
+ {
+ // calc the view pos. we can't use our converting functions because the new column
+ // has no VCL-representation, yet.
+ sal_Int16 nViewPos = nModelPos;
+ while (nModelPos--)
+ {
+ if (m_aColumns.GetObject(nModelPos)->IsHidden())
+ --nViewPos;
+ }
+ // restore nModelPos, we need it later
+ nModelPos = nRealPos;
+ // the position the base class gets is the view pos + 1 (because of the handle column)
+ nRealPos = nViewPos + 1;
+ }
+
+ // calculate the new id
+ for (nId=1; (GetModelColumnPos(nId) != GRID_COLUMN_NOT_FOUND) && (nId<=m_aColumns.Count()); ++nId)
+ ;
+ DBG_ASSERT(GetViewColumnPos(nId) == (sal_uInt16)-1, "DbGridControl::AppendColumn : inconsistent internal state !");
+ // my column's models say "there is no column with id nId", but the view (the base class) says "there is a column ..."
+
+ DbGridControl_Base::AppendColumn(rName, nWidth, nRealPos, nId);
+ if (nModelPos == HEADERBAR_APPEND)
+ m_aColumns.Insert(CreateColumn(nId), LIST_APPEND);
+ else
+ m_aColumns.Insert(CreateColumn(nId), nModelPos);
+
+ return nId;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::RemoveColumn(sal_uInt16 nId)
+{
+ sal_Int16 nIndex = GetModelColumnPos(nId);
+ DbGridControl_Base::RemoveColumn(nId);
+ delete m_aColumns.Remove(nIndex);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::ColumnMoved(sal_uInt16 nId)
+{
+ DbGridControl_Base::ColumnMoved(nId);
+
+ // remove the col from the model
+ sal_Int16 nOldModelPos = GetModelColumnPos(nId);
+#ifdef DBG_UTIL
+ DbGridColumn* pCol = m_aColumns.GetObject((sal_uInt32)nOldModelPos);
+ DBG_ASSERT(!pCol->IsHidden(), "DbGridControl::ColumnMoved : moved a hidden col ? how this ?");
+#endif
+
+ // for the new model pos we can't use GetModelColumnPos because we are altering the model at the moment
+ // so the method won't work (in fact it would return the old model pos)
+
+ // the new view pos is calculated easily
+ sal_uInt16 nNewViewPos = GetViewColumnPos(nId);
+
+ // from that we can compute the new model pos
+ sal_uInt16 nNewModelPos;
+ for (nNewModelPos = 0; nNewModelPos < m_aColumns.Count(); ++nNewModelPos)
+ {
+ if (!m_aColumns.GetObject(nNewModelPos)->IsHidden())
+ {
+ if (!nNewViewPos)
+ break;
+ else
+ --nNewViewPos;
+ }
+ }
+ DBG_ASSERT(nNewModelPos<m_aColumns.Count(), "DbGridControl::ColumnMoved : could not find the new model position !");
+
+ // this will work. of course the model isn't fully consistent with our view right now, but let's
+ // look at the situation : a column has been moved with in the VIEW from pos m to n, say m<n (in the
+ // other case we can use analogue arguments).
+ // All cols k with m<k<=n have been shifted left on pos, the former col m now has pos n.
+ // In the model this affects a range of cols x to y, where x<=m and y<=n. And the number of hidden cols
+ // within this range is constant, so we may calculate the view pos from the model pos in the above way.
+ //
+ // for instance, let's look at a grid with six columns where the third one is hidden. this will
+ // initially look like this :
+ //
+ // +---+---+---+---+---+---+
+ // model pos | 0 | 1 |*2*| 3 | 4 | 5 |
+ // +---+---+---+---+---+---+
+ // ID | 1 | 2 | 3 | 4 | 5 | 6 |
+ // +---+---+---+---+---+---+
+ // view pos | 0 | 1 | - | 2 | 3 | 4 |
+ // +---+---+---+---+---+---+
+ //
+ // if we move the column at (view) pos 1 to (view) pos 3 we have :
+ //
+ // +---+---+---+---+---+---+
+ // model pos | 0 | 3 |*2*| 4 | 1 | 5 | // not reflecting the changes, yet
+ // +---+---+---+---+---+---+
+ // ID | 1 | 4 | 3 | 5 | 2 | 6 | // already reflecting the changes
+ // +---+---+---+---+---+---+
+ // view pos | 0 | 1 | - | 2 | 3 | 4 |
+ // +---+---+---+---+---+---+
+ //
+ // or, sorted by the out-of-date model positions :
+ //
+ // +---+---+---+---+---+---+
+ // model pos | 0 | 1 |*2*| 3 | 4 | 5 |
+ // +---+---+---+---+---+---+
+ // ID | 1 | 2 | 3 | 4 | 5 | 6 |
+ // +---+---+---+---+---+---+
+ // view pos | 0 | 3 | - | 1 | 2 | 4 |
+ // +---+---+---+---+---+---+
+ //
+ // We know the new view pos (3) of the moved column because our base class tells us. So we look at our
+ // model for the 4th (the pos is zero-based) visible column, it is at (model) position 4. And this is
+ // exactly the pos where we have to re-insert our column's model, so it looks ike this :
+ //
+ // +---+---+---+---+---+---+
+ // model pos | 0 |*1*| 2 | 3 | 4 | 5 |
+ // +---+---+---+---+---+---+
+ // ID | 1 | 3 | 4 | 5 | 2 | 6 |
+ // +---+---+---+---+---+---+
+ // view pos | 0 | - | 1 | 2 | 3 | 4 |
+ // +---+---+---+---+---+---+
+ //
+ // Now, all is consistent again.
+ // (except of the hidden column : The cycling of the cols occured on the model, not on the view. maybe
+ // the user expected the latter but there really is no good argument against our method ;) ...)
+ //
+ // And no, this large explanation isn't just because I wanted to play a board game or something like
+ // that. It's because it took me a while to see it myself, and the whole theme (hidden cols, model col
+ // positions, view col positions) is really painful (at least for me) so the above pictures helped me a lot ;)
+
+ m_aColumns.Insert(m_aColumns.Remove((sal_uInt32)nOldModelPos), nNewModelPos);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::SeekRow(long nRow)
+{
+ // in filter mode or in insert only mode we don't have any cursor!
+ if ( !SeekCursor( nRow ) )
+ return sal_False;
+
+ if ( IsFilterMode() )
+ {
+ DBG_ASSERT( IsFilterRow( nRow ), "DbGridControl::SeekRow(): No filter row, wrong mode" );
+ m_xPaintRow = m_xEmptyRow;
+ }
+ else
+ {
+ // on the current position we have to take the current row for display as we want
+ // to have the most recent values for display
+ if ( ( nRow == m_nCurrentPos ) && getDisplaySynchron() )
+ m_xPaintRow = m_xCurrentRow;
+ // seek to the empty insert row
+ else if ( IsInsertionRow( nRow ) )
+ m_xPaintRow = m_xEmptyRow;
+ else
+ {
+ m_xSeekRow->SetState( m_pSeekCursor, sal_True );
+ m_xPaintRow = m_xSeekRow;
+ }
+ }
+
+ DbGridControl_Base::SeekRow(nRow);
+
+ return m_nSeekPos >= 0;
+}
+//------------------------------------------------------------------------------
+// Wird aufgerufen, wenn die dargestellte Datenmenge sich aendert
+//------------------------------------------------------------------------------
+void DbGridControl::VisibleRowsChanged( long nNewTopRow, sal_uInt16 nLinesOnScreen )
+{
+ RecalcRows(nNewTopRow, nLinesOnScreen , sal_False);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::RecalcRows(long nNewTopRow, sal_uInt16 nLinesOnScreen, sal_Bool bUpdateCursor)
+{
+ DBG_CHKTHIS( DbGridControl, NULL );
+ // Wenn kein Cursor -> keine Rows im Browser.
+ if (!m_pSeekCursor)
+ {
+ DBG_ASSERT(GetRowCount() == 0,"DbGridControl: ohne Cursor darf es keine Rows geben");
+ return;
+ }
+
+ // ignore any updates implicit made
+ sal_Bool bDisablePaint = !bUpdateCursor && IsPaintEnabled();
+ if (bDisablePaint)
+ EnablePaint(sal_False);
+
+ // Cache an den sichtbaren Bereich anpassen
+ Reference< XPropertySet > xSet = m_pSeekCursor->getPropertySet();
+ sal_Int32 nCacheSize = 0;
+ xSet->getPropertyValue(FM_PROP_FETCHSIZE) >>= nCacheSize;
+ sal_Bool bCacheAligned = sal_False;
+ // Nach der Initialisierung (m_nSeekPos < 0) keine Cursorbewegung, da bereits auf den ersten
+ // Satz positioniert
+ long nDelta = nNewTopRow - GetTopRow();
+ // Limit fuer relative Positionierung
+ long nLimit = (nCacheSize) ? nCacheSize / 2 : 0;
+
+ // mehr Zeilen auf dem Bildschirm als im Cache
+ if (nLimit < nLinesOnScreen)
+ {
+ Any aCacheSize;
+ aCacheSize <<= sal_Int32(nLinesOnScreen*2);
+ xSet->setPropertyValue(FM_PROP_FETCHSIZE, aCacheSize);
+ // jetzt auf alle Faelle den Cursor anpassen
+ bUpdateCursor = sal_True;
+ bCacheAligned = sal_True;
+ nLimit = nLinesOnScreen;
+ }
+
+ // Im folgenden werden die Positionierungen so vorgenommen, da� sichergestellt ist
+ // da� ausreichend Zeilen im DatenCache vorhanden sind
+
+ // Fenster geht nach unten, weniger als zwei Fenster Differenz
+ // oder Cache angepasst und noch kein Rowcount
+ if (nDelta < nLimit && (nDelta > 0
+ || (bCacheAligned && m_nTotalCount < 0)) )
+ SeekCursor(nNewTopRow + nLinesOnScreen - 1, sal_False);
+ else if (nDelta < 0 && Abs(nDelta) < nLimit)
+ SeekCursor(nNewTopRow, sal_False);
+ else if (nDelta != 0 || bUpdateCursor)
+ SeekCursor(nNewTopRow, sal_True);
+
+ AdjustRows();
+
+ // ignore any updates implicit made
+ EnablePaint(sal_True);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::RowInserted(long nRow, long nNumRows, sal_Bool bDoPaint, sal_Bool bKeepSelection)
+{
+ if (nNumRows)
+ {
+ if (m_bRecordCountFinal && m_nTotalCount < 0)
+ {
+ // if we have an insert row we have to reduce to count by 1
+ // as the total count reflects only the existing rows in database
+ m_nTotalCount = GetRowCount() + nNumRows;
+ if (m_xEmptyRow.Is())
+ --m_nTotalCount;
+ }
+ else if (m_nTotalCount >= 0)
+ m_nTotalCount += nNumRows;
+
+ DbGridControl_Base::RowInserted(nRow, nNumRows, bDoPaint, bKeepSelection);
+ m_aBar.InvalidateState(NavigationBar::RECORD_COUNT);
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::RowRemoved(long nRow, long nNumRows, sal_Bool bDoPaint)
+{
+ if (nNumRows)
+ {
+ if (m_bRecordCountFinal && m_nTotalCount < 0)
+ {
+ m_nTotalCount = GetRowCount() - nNumRows;
+ // if we have an insert row reduce by 1
+ if (m_xEmptyRow.Is())
+ --m_nTotalCount;
+ }
+ else if (m_nTotalCount >= 0)
+ m_nTotalCount -= nNumRows;
+
+ DbGridControl_Base::RowRemoved(nRow, nNumRows, bDoPaint);
+ m_aBar.InvalidateState(NavigationBar::RECORD_COUNT);
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::AdjustRows()
+{
+ if (!m_pSeekCursor)
+ return;
+
+ Reference< XPropertySet > xSet = m_pDataCursor->getPropertySet();
+
+ // Aktualisieren des RecordCounts
+ sal_Int32 nRecordCount = 0;
+ xSet->getPropertyValue(FM_PROP_ROWCOUNT) >>= nRecordCount;
+ if (!m_bRecordCountFinal)
+ m_bRecordCountFinal = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ROWCOUNTFINAL));
+
+ // hat sich die aktuelle Anzahl Rows veraendert
+ // hierbei muss auch beruecksichtigt werden,
+ // das eine zusaetzliche Zeile zum einfuegen von Datensaetzen vorhanden sein kann
+
+ // zusaetzliche AppendRow fuers einfuegen
+ if (m_nOptions & OPT_INSERT)
+ ++nRecordCount;
+
+ // wird gerade eingefuegt, dann gehoert die gerade hinzuzufuegende
+ // Zeile nicht zum RecordCount und die Appendrow ebenfalls nicht
+ if (!IsUpdating() && m_bRecordCountFinal && IsModified() && m_xCurrentRow != m_xEmptyRow &&
+ m_xCurrentRow->IsNew())
+ ++nRecordCount;
+ // das ist mit !m_bUpdating abgesichert : innerhalb von SaveRow (m_bUpdating == sal_True) wuerde sonst der Datensatz, den ich editiere
+ // (und den SaveRow gerade angefuegt hat, wodurch diese Methode hier getriggert wurde), doppelt zaehlen : einmal ist er schon
+ // in dem normalen RecordCount drin, zum zweiten wuerde er hier gezaehlt werden (60787 - FS)
+
+ if (nRecordCount != GetRowCount())
+ {
+ long nDelta = GetRowCount() - (long)nRecordCount;
+ if (nDelta > 0) // zuviele
+ {
+ RowRemoved(GetRowCount() - nDelta, nDelta, sal_False);
+ // es sind Zeilen weggefallen, dann ab der aktuellen Position neu zeichen
+ Invalidate();
+ }
+ else // zuwenig
+ RowInserted(GetRowCount(), -nDelta, sal_True);
+ }
+
+ if (m_bRecordCountFinal && m_nTotalCount < 0)
+ {
+ if (m_nOptions & OPT_INSERT)
+ m_nTotalCount = GetRowCount() - 1;
+ else
+ m_nTotalCount = GetRowCount();
+ }
+ m_aBar.InvalidateState(NavigationBar::RECORD_COUNT);
+}
+
+//------------------------------------------------------------------------------
+DbGridControl_Base::RowStatus DbGridControl::GetRowStatus(long nRow) const
+{
+ if (IsFilterRow(nRow))
+ return DbGridControl_Base::FILTER;
+ else if (m_nCurrentPos >= 0 && nRow == m_nCurrentPos)
+ {
+ // neue Zeile
+ if (!IsValid(m_xCurrentRow))
+ return DbGridControl_Base::DELETED;
+ else if (IsModified())
+ return DbGridControl_Base::MODIFIED;
+ else if (m_xCurrentRow->IsNew())
+ return DbGridControl_Base::CURRENTNEW;
+ else
+ return DbGridControl_Base::CURRENT;
+ }
+ else if (IsInsertionRow(nRow))
+ return DbGridControl_Base::NEW;
+ else if (!IsValid(m_xSeekRow))
+ return DbGridControl_Base::DELETED;
+ else
+ return DbGridControl_Base::CLEAN;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::PaintStatusCell(OutputDevice& rDev, const Rectangle& rRect) const
+{
+ DbGridControl_Base::PaintStatusCell(rDev, rRect);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::PaintCell(OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId) const
+{
+ if (!IsValid(m_xPaintRow))
+ return;
+
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(nColumnId));
+ if (pColumn)
+ {
+ Rectangle aArea(rRect);
+ if ((GetMode() & BROWSER_CURSOR_WO_FOCUS) == BROWSER_CURSOR_WO_FOCUS)
+ {
+ aArea.Top() += 1;
+ aArea.Bottom() -= 1;
+ }
+ pColumn->Paint(rDev, aArea, m_xPaintRow, getNumberFormatter());
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::CursorMoving(long nNewRow, sal_uInt16 nNewCol)
+{
+ DBG_CHKTHIS( DbGridControl, NULL );
+
+ DeactivateCell( sal_False );
+
+ if ( m_pDataCursor
+ && ( m_nCurrentPos != nNewRow )
+ && !SetCurrent( nNewRow )
+ )
+ {
+ ActivateCell();
+ return sal_False;
+ }
+
+ if ( !DbGridControl_Base::CursorMoving( nNewRow, nNewCol ) )
+ return sal_False;
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::SetCurrent(long nNewRow)
+{
+ // Each movement of the datacursor must start with BeginCursorAction and end with
+ // EndCursorAction to block all notifications during the movement
+ BeginCursorAction();
+
+ try
+ {
+ // Abgleichen der Positionen
+ if (SeekCursor(nNewRow))
+ {
+ if (IsFilterRow(nNewRow)) // special mode for filtering
+ {
+ m_xCurrentRow = m_xDataRow = m_xPaintRow = m_xEmptyRow;
+ m_nCurrentPos = nNewRow;
+ }
+ else
+ {
+ sal_Bool bNewRowInserted = sal_False;
+ // Should we go to the insertrow ?
+ if (IsInsertionRow(nNewRow))
+ {
+ // to we need to move the cursor to the insert row?
+ // we need to insert the if the current row isn't the insert row or if the
+ // cursor triggered the move by itselt and we need a reinitialization of the row
+ Reference< XPropertySet > xCursorProps = m_pDataCursor->getPropertySet();
+ if ( !::comphelper::getBOOL(xCursorProps->getPropertyValue(FM_PROP_ISNEW)) )
+ {
+ Reference< XResultSetUpdate > xUpdateCursor((Reference< XInterface >)*m_pDataCursor, UNO_QUERY);
+ xUpdateCursor->moveToInsertRow();
+ }
+ bNewRowInserted = sal_True;
+ }
+ else
+ {
+
+ if ( !m_pSeekCursor->isBeforeFirst() && !m_pSeekCursor->isAfterLast() )
+ {
+ Any aBookmark = m_pSeekCursor->getBookmark();
+ if (!m_xCurrentRow || m_xCurrentRow->IsNew() || !CompareBookmark(aBookmark, m_pDataCursor->getBookmark()))
+ {
+ // adjust the cursor to the new desired row
+ if (!m_pDataCursor->moveToBookmark(aBookmark))
+ {
+ EndCursorAction();
+ return sal_False;
+ }
+ }
+ }
+ }
+ m_xDataRow->SetState(m_pDataCursor, sal_False);
+ m_xCurrentRow = m_xDataRow;
+
+ long nPaintPos = -1;
+ // do we have to repaint the last regular row in case of setting defaults or autovalues
+ if (m_nCurrentPos >= 0 && m_nCurrentPos >= (GetRowCount() - 2))
+ nPaintPos = m_nCurrentPos;
+
+ m_nCurrentPos = nNewRow;
+
+ // repaint the new row to display all defaults
+ if (bNewRowInserted)
+ RowModified(m_nCurrentPos);
+ if (nPaintPos >= 0)
+ RowModified(nPaintPos);
+ }
+ }
+ else
+ {
+ DBG_ERROR("DbGridControl::SetCurrent : SeekRow failed !");
+ EndCursorAction();
+ return sal_False;
+ }
+ }
+ catch ( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ EndCursorAction();
+ return sal_False;
+ }
+
+ EndCursorAction();
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::CursorMoved()
+{
+ DBG_CHKTHIS( DbGridControl, NULL );
+
+ // CursorBewegung durch loeschen oder einfuegen von Zeilen
+ if (m_pDataCursor && m_nCurrentPos != GetCurRow())
+ {
+ DeactivateCell(sal_True);
+ SetCurrent(GetCurRow());
+ }
+
+ DbGridControl_Base::CursorMoved();
+ m_aBar.InvalidateAll(m_nCurrentPos);
+
+ // select the new column when they moved
+ if ( IsDesignMode() && GetSelectedColumnCount() > 0 && GetCurColumnId() )
+ {
+ SelectColumnId( GetCurColumnId() );
+ }
+
+ if ( m_nLastColId != GetCurColumnId() )
+ onColumnChange();
+ m_nLastColId = GetCurColumnId();
+
+ if ( m_nLastRowId != GetCurRow() )
+ onRowChange();
+ m_nLastRowId = GetCurRow();
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::onRowChange()
+{
+ // not interested in
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::onColumnChange()
+{
+ if ( m_pGridListener )
+ m_pGridListener->columnChanged();
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::setDisplaySynchron(sal_Bool bSync)
+{
+ if (bSync != m_bSynchDisplay)
+ {
+ m_bSynchDisplay = bSync;
+ if (m_bSynchDisplay)
+ AdjustDataSource(sal_False);
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::forceSyncDisplay()
+{
+ sal_Bool bOld = getDisplaySynchron();
+ setDisplaySynchron(sal_True);
+ if (!bOld)
+ setDisplaySynchron(bOld);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::forceROController(sal_Bool bForce)
+{
+ if (m_bForceROController == bForce)
+ return;
+
+ m_bForceROController = bForce;
+ // alle Columns durchgehen und denen Bescheid geben
+ for (sal_uInt16 i=0; i<m_aColumns.Count(); ++i)
+ {
+ DbGridColumn* pColumn = m_aColumns.GetObject(i);
+ if (!pColumn)
+ continue;
+
+ CellController* pReturn = &pColumn->GetController();
+ if (!pReturn)
+ continue;
+
+ // nur wenn es eine Edit-Zeile ist, kann ich ihr das forced read-only mitgeben
+ if (!pReturn->ISA(EditCellController) && !pReturn->ISA(SpinCellController))
+ continue;
+
+ Edit& rEdit = (Edit&)pReturn->GetWindow();
+ rEdit.SetReadOnly(m_bForceROController);
+ if (m_bForceROController)
+ rEdit.SetStyle(rEdit.GetStyle() | WB_NOHIDESELECTION);
+ else
+ rEdit.SetStyle(rEdit.GetStyle() & ~WB_NOHIDESELECTION);
+ }
+
+ // die aktive Zelle erneut aktivieren, da sich ihr Controller geaendert haben kann
+ if (IsEditing())
+ DeactivateCell();
+ ActivateCell();
+}
+
+
+//------------------------------------------------------------------------------
+void DbGridControl::AdjustDataSource(sal_Bool bFull)
+{
+ TRACE_RANGE("DbGridControl::AdjustDataSource");
+ SolarMutexGuard aGuard;
+ // wird die aktuelle Zeile gerade neu bestimmt,
+ // wird kein abgleich vorgenommen
+
+ if (bFull)
+ m_xCurrentRow = NULL;
+ // if we are on the same row only repaint
+ // but this is only possible for rows which are not inserted, in that case the comparision result
+ // may not be correct
+ else
+ if ( m_xCurrentRow.Is()
+ && !m_xCurrentRow->IsNew()
+ && !m_pDataCursor->isBeforeFirst()
+ && !m_pDataCursor->isAfterLast()
+ && !m_pDataCursor->rowDeleted()
+ )
+ {
+ sal_Bool bEqualBookmarks = CompareBookmark( m_xCurrentRow->GetBookmark(), m_pDataCursor->getBookmark() );
+
+ sal_Bool bDataCursorIsOnNew = sal_False;
+ m_pDataCursor->getPropertySet()->getPropertyValue( FM_PROP_ISNEW ) >>= bDataCursorIsOnNew;
+
+ if ( bEqualBookmarks && !bDataCursorIsOnNew )
+ {
+ // position of my data cursor is the same as the position our current row points tpo
+ // sync the status, repaint, done
+ DBG_ASSERT(m_xDataRow == m_xCurrentRow, "Fehler in den Datenzeilen");
+ TRACE_RANGE_MESSAGE1("same position, new state : %s", ROWSTATUS(m_xCurrentRow));
+ RowModified(m_nCurrentPos);
+ return;
+ }
+ }
+
+ // weg von der Row des DatenCursors
+ if (m_xPaintRow == m_xCurrentRow)
+ m_xPaintRow = m_xSeekRow;
+
+ // keine aktuelle Zeile dann komplett anpassen
+ if (!m_xCurrentRow)
+ AdjustRows();
+
+ sal_Int32 nNewPos = AlignSeekCursor();
+ if (nNewPos < 0) // keine Position gefunden
+ return;
+
+ m_bInAdjustDataSource = TRUE;
+ if (nNewPos != m_nCurrentPos)
+ {
+ if (m_bSynchDisplay)
+ DbGridControl_Base::GoToRow(nNewPos);
+
+ if (!m_xCurrentRow.Is())
+ // das tritt zum Beispiel auf, wenn man die n (n>1) letzten Datensaetze geloescht hat, waehrend der Cursor auf dem letzten
+ // steht : AdjustRows entfernt dann zwei Zeilen aus der BrowseBox, wodurch diese ihre CurrentRow um zwei nach unten
+ // korrigiert, so dass dann das GoToRow in's Leere laeuft (da wir uns ja angeblich schon an der richtigen Position
+ // befinden)
+ SetCurrent(nNewPos);
+ }
+ else
+ {
+ SetCurrent(nNewPos);
+ RowModified(nNewPos);
+ }
+ m_bInAdjustDataSource = FALSE;
+
+ // Wird der DatenCursor von aussen bewegt, wird die selektion aufgehoben
+ SetNoSelection();
+ m_aBar.InvalidateAll(m_nCurrentPos, m_xCurrentRow.Is());
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 DbGridControl::AlignSeekCursor()
+{
+ DBG_CHKTHIS( DbGridControl, NULL );
+ // Positioniert den SeekCursor auf den DatenCursor, Daten werden nicht uebertragen
+
+ if (!m_pSeekCursor)
+ return -1;
+
+ Reference< XPropertySet > xSet = m_pDataCursor->getPropertySet();
+
+ // jetzt den seekcursor an den DatenCursor angleichen
+ if (::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISNEW)))
+ m_nSeekPos = GetRowCount() - 1;
+ else
+ {
+ try
+ {
+ if ( m_pDataCursor->isBeforeFirst() )
+ {
+ // this is somewhat strange, but can nevertheless happen
+ DBG_WARNING( "DbGridControl::AlignSeekCursor: nobody should tamper with my cursor this way (before first)!" );
+ m_pSeekCursor->first();
+ m_pSeekCursor->previous();
+ m_nSeekPos = -1;
+ }
+ else if ( m_pDataCursor->isAfterLast() )
+ {
+ DBG_WARNING( "DbGridControl::AlignSeekCursor: nobody should tamper with my cursor this way (after last)!" );
+ m_pSeekCursor->last();
+ m_pSeekCursor->next();
+ m_nSeekPos = -1;
+ }
+ else
+ {
+ m_pSeekCursor->moveToBookmark(m_pDataCursor->getBookmark());
+ if (!CompareBookmark(m_pDataCursor->getBookmark(), m_pSeekCursor->getBookmark()))
+ // dummerweise kann das moveToBookmark indirekt dazu fuehren, dass der Seek-Cursor wieder neu positoniert wird (wenn
+ // naemlich das mit all seinen zu feuernden Events relativ komplexe moveToBookmark irgendwo ein Update ausloest),
+ // also muss ich es nochmal versuchen
+ m_pSeekCursor->moveToBookmark(m_pDataCursor->getBookmark());
+ // Nicht dass das jetzt nicht auch schief gegangen sein koennte, aber es ist zumindest unwahrscheinlicher geworden.
+ // Und die Alternative waere eine Schleife so lange bis es stimmt, und das kann auch nicht die Loesung sein
+ m_nSeekPos = m_pSeekCursor->getRow() - 1;
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ return m_nSeekPos;
+}
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::SeekCursor(long nRow, sal_Bool bAbsolute)
+{
+ DBG_CHKTHIS( DbGridControl, NULL );
+ // Positioniert den SeekCursor, Daten werden nicht uebertragen
+
+ // additions for the filtermode
+ if (IsFilterRow(nRow))
+ {
+ m_nSeekPos = 0;
+ return sal_True;
+ }
+
+ if (!m_pSeekCursor)
+ return sal_False;
+
+ // Befinden wir uns gerade beim Einfuegen
+ if (IsValid(m_xCurrentRow) && m_xCurrentRow->IsNew() &&
+ nRow >= m_nCurrentPos)
+ {
+ // dann darf auf alle Faelle nicht weiter nach unten gescrollt werden
+ // da der letzte Datensatz bereits erreicht wurde!
+ if (nRow == m_nCurrentPos)
+ {
+ // auf die aktuelle Zeile bewegt, dann muß kein abgleich gemacht werden, wenn
+ // gerade ein Datensatz eingefuegt wird
+ m_nSeekPos = nRow;
+ }
+ else if (IsInsertionRow(nRow)) // Leerzeile zum Einfuegen von Datensaetzen
+ m_nSeekPos = nRow;
+ }
+ else if (IsInsertionRow(nRow)) // Leerzeile zum Einfuegen von Datensaetzen
+ m_nSeekPos = nRow;
+ else if ((-1 == nRow) && (GetRowCount() == ((m_nOptions & OPT_INSERT) ? 1 : 0)) && m_pSeekCursor->isAfterLast())
+ m_nSeekPos = nRow;
+ else
+ {
+
+ sal_Bool bSuccess=sal_False;
+ long nSteps = 0;
+ try
+ {
+ if ( m_pSeekCursor->rowDeleted() )
+ {
+ // somebody deleted the current row of the seek cursor. Move it away from this row.
+ m_pSeekCursor->next();
+ if ( m_pSeekCursor->isAfterLast() || m_pSeekCursor->isBeforeFirst() )
+ bAbsolute = sal_True;
+ }
+
+ if ( !bAbsolute )
+ {
+ DBG_ASSERT( !m_pSeekCursor->isAfterLast() && !m_pSeekCursor->isBeforeFirst(),
+ "DbGridControl::SeekCursor: how did the seek cursor get to this position?!" );
+ nSteps = nRow - (m_pSeekCursor->getRow() - 1);
+ bAbsolute = bAbsolute || (abs(nSteps) > 100);
+ }
+
+ if ( bAbsolute )
+ {
+ bSuccess = m_pSeekCursor->absolute(nRow + 1);
+ if (bSuccess)
+ m_nSeekPos = nRow;
+ }
+ else
+ {
+ if (nSteps > 0) // auf den letzten benoetigten Datensatz positionieren
+ {
+ if (m_pSeekCursor->isAfterLast())
+ bSuccess = sal_False;
+ else if (m_pSeekCursor->isBeforeFirst())
+ bSuccess = m_pSeekCursor->absolute(nSteps);
+ else
+ bSuccess = m_pSeekCursor->relative(nSteps);
+ }
+ else if (nSteps < 0)
+ {
+ if (m_pSeekCursor->isBeforeFirst())
+ bSuccess = sal_False;
+ else if (m_pSeekCursor->isAfterLast())
+ bSuccess = m_pSeekCursor->absolute(nSteps);
+ else
+ bSuccess = m_pSeekCursor->relative(nSteps);
+ }
+ else
+ {
+ m_nSeekPos = nRow;
+ return sal_True;
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("DbGridControl::SeekCursor : failed ...");
+ }
+
+ try
+ {
+ if (!bSuccess)
+ {
+ if (bAbsolute || nSteps > 0)
+ bSuccess = m_pSeekCursor->last();
+ else
+ bSuccess = m_pSeekCursor->first();
+ }
+
+ if (bSuccess)
+ m_nSeekPos = m_pSeekCursor->getRow() - 1;
+ else
+ m_nSeekPos = -1;
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("DbGridControl::SeekCursor : failed ...");
+ m_nSeekPos = -1; // kein Datensatz mehr vorhanden
+ }
+ }
+ return m_nSeekPos == nRow;
+}
+//------------------------------------------------------------------------------
+void DbGridControl::MoveToFirst()
+{
+ if (m_pSeekCursor && (GetCurRow() != 0))
+ MoveToPosition(0);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::MoveToLast()
+{
+ if (!m_pSeekCursor)
+ return;
+
+ if (m_nTotalCount < 0) // RecordCount steht noch nicht fest
+ {
+ try
+ {
+ sal_Bool bRes = m_pSeekCursor->last();
+
+ if (bRes)
+ {
+ m_nSeekPos = m_pSeekCursor->getRow() - 1;
+ AdjustRows();
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ }
+
+ // auf den letzen Datensatz positionieren, nicht auf die Leerzeile
+ if (m_nOptions & OPT_INSERT)
+ {
+ if ((GetRowCount() - 1) > 0)
+ MoveToPosition(GetRowCount() - 2);
+ }
+ else if (GetRowCount())
+ MoveToPosition(GetRowCount() - 1);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::MoveToPrev()
+{
+ long nNewRow = std::max(GetCurRow() - 1L, 0L);
+ if (GetCurRow() != nNewRow)
+ MoveToPosition(nNewRow);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::MoveToNext()
+{
+ if (!m_pSeekCursor)
+ return;
+
+ if (m_nTotalCount > 0)
+ {
+ // move the data cursor to the right position
+ long nNewRow = std::min(GetRowCount() - 1, GetCurRow() + 1);
+ if (GetCurRow() != nNewRow)
+ MoveToPosition(nNewRow);
+ }
+ else
+ {
+ sal_Bool bOk = sal_False;
+ try
+ {
+ // try to move to next row
+ // when not possible our paint cursor is already on the last row
+ // then we must be sure that the data cursor is on the position
+ // we call ourself again
+ bOk = m_pSeekCursor->next();
+ if (bOk)
+ {
+ m_nSeekPos = m_pSeekCursor->getRow() - 1;
+ MoveToPosition(GetCurRow() + 1);
+ }
+ }
+ catch(SQLException &)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if(!bOk)
+ {
+ AdjustRows();
+ if (m_nTotalCount > 0) // only to avoid infinte recursion
+ MoveToNext();
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::MoveToPosition(sal_uInt32 nPos)
+{
+ if (!m_pSeekCursor)
+ return;
+
+ if (m_nTotalCount < 0 && (long)nPos >= GetRowCount())
+ {
+ try
+ {
+ if (!m_pSeekCursor->absolute(nPos + 1))
+ {
+ AdjustRows();
+ Sound::Beep();
+ return;
+ }
+ else
+ {
+ m_nSeekPos = m_pSeekCursor->getRow() - 1;
+ AdjustRows();
+ }
+ }
+ catch(Exception&)
+ {
+ return;
+ }
+ }
+ DbGridControl_Base::GoToRow(nPos);
+ m_aBar.InvalidateAll(m_nCurrentPos);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::AppendNew()
+{
+ if (!m_pSeekCursor || !(m_nOptions & OPT_INSERT))
+ return;
+
+ if (m_nTotalCount < 0) // RecordCount steht noch nicht fest
+ {
+ try
+ {
+ sal_Bool bRes = m_pSeekCursor->last();
+
+ if (bRes)
+ {
+ m_nSeekPos = m_pSeekCursor->getRow() - 1;
+ AdjustRows();
+ }
+ }
+ catch(Exception&)
+ {
+ return;
+ }
+ }
+
+ long nNewRow = m_nTotalCount + 1;
+ if (nNewRow > 0 && GetCurRow() != nNewRow)
+ MoveToPosition(nNewRow - 1);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::SetDesignMode(sal_Bool bMode)
+{
+ if (IsDesignMode() != bMode)
+ {
+ // Enable/Disable f�r den Designmode anpassen damit die Headerbar konfigurierbar bleibt
+ if (bMode)
+ {
+ if (!IsEnabled())
+ {
+ Enable();
+ GetDataWindow().Disable();
+ }
+ }
+ else
+ {
+ // komplett disablen
+ if (!GetDataWindow().IsEnabled())
+ Disable();
+ }
+
+ m_bDesignMode = bMode;
+ GetDataWindow().SetMouseTransparent(bMode);
+ SetMouseTransparent(bMode);
+
+ m_aBar.InvalidateAll(m_nCurrentPos, sal_True);
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::SetFilterMode(sal_Bool bMode)
+{
+ if (IsFilterMode() != bMode)
+ {
+ m_bFilterMode = bMode;
+
+ if (bMode)
+ {
+ SetUpdateMode(sal_False);
+
+ // es gibt kein Cursor mehr
+ if (IsEditing())
+ DeactivateCell();
+ RemoveRows(sal_False);
+
+ m_xEmptyRow = new DbGridRow();
+
+ // setting the new filter controls
+ for (sal_uInt16 i = 0; i<m_aColumns.Count(); ++i)
+ {
+ DbGridColumn* pCurCol = m_aColumns.GetObject(i);
+ if (!pCurCol->IsHidden())
+ pCurCol->UpdateControl();
+ }
+
+ // one row for filtering
+ RowInserted(0, 1, sal_True);
+ SetUpdateMode(sal_True);
+ }
+ else
+ setDataSource(Reference< XRowSet > ());
+ }
+}
+// -----------------------------------------------------------------------------
+String DbGridControl::GetCellText(long _nRow, USHORT _nColId) const
+{
+ DbGridColumn* pColumn = m_aColumns.GetObject( GetModelColumnPos( _nColId ) );
+ String sRet;
+ if ( const_cast<DbGridControl*>(this)->SeekRow(_nRow) )
+ sRet = GetCurrentRowCellText(pColumn, m_xPaintRow);
+ return sRet;
+}
+//------------------------------------------------------------------------------
+XubString DbGridControl::GetCurrentRowCellText(DbGridColumn* pColumn,const DbGridRowRef& _rRow) const
+{
+ // Ausgabe des Textes fuer eine Zelle
+ XubString aText;
+ if ( pColumn && IsValid(m_xPaintRow) )
+ aText = pColumn->GetCellText(_rRow, m_xFormatter);
+ return aText;
+}
+
+//------------------------------------------------------------------------------
+sal_uInt32 DbGridControl::GetTotalCellWidth(long nRow, sal_uInt16 nColId)
+{
+ if (SeekRow(nRow))
+ {
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(nColId));
+ return GetDataWindow().GetTextWidth(GetCurrentRowCellText(pColumn,m_xPaintRow));
+ }
+ else
+ return 30; //xxxx
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::PreExecuteRowContextMenu(sal_uInt16 /*nRow*/, PopupMenu& rMenu)
+{
+ sal_Bool bDelete = (m_nOptions & OPT_DELETE) && GetSelectRowCount() && !IsCurrentAppending();
+ // ist nur die Leerzeile selektiert, dann nicht loeschen
+ bDelete = bDelete && !((m_nOptions & OPT_INSERT) && GetSelectRowCount() == 1 && IsRowSelected(GetRowCount() - 1));
+
+ rMenu.EnableItem(SID_FM_DELETEROWS, bDelete);
+ rMenu.EnableItem(SID_FM_RECORD_SAVE, IsModified());
+
+ // the undo is more difficult
+ sal_Bool bCanUndo = IsModified();
+ long nState = -1;
+ if (m_aMasterStateProvider.IsSet())
+ nState = m_aMasterStateProvider.Call((void*)SID_FM_RECORD_UNDO);
+ bCanUndo &= ( 0 != nState );
+
+ rMenu.EnableItem(SID_FM_RECORD_UNDO, bCanUndo);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::PostExecuteRowContextMenu(sal_uInt16 /*nRow*/, const PopupMenu& /*rMenu*/, sal_uInt16 nExecutionResult)
+{
+ switch (nExecutionResult)
+ {
+ case SID_FM_DELETEROWS:
+ // delete asynchron
+ if (m_nDeleteEvent)
+ Application::RemoveUserEvent(m_nDeleteEvent);
+ m_nDeleteEvent = Application::PostUserEvent(LINK(this,DbGridControl,OnDelete));
+ break;
+ case SID_FM_RECORD_UNDO:
+ Undo();
+ break;
+ case SID_FM_RECORD_SAVE:
+ SaveRow();
+ break;
+ default:
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::DataSourcePropertyChanged(const PropertyChangeEvent& evt) throw( RuntimeException )
+{
+ TRACE_RANGE("DbGridControl::DataSourcePropertyChanged");
+ SolarMutexGuard aGuard;
+ // prop "IsModified" changed ?
+ // during update don't care about the modified state
+ if (!IsUpdating() && evt.PropertyName.compareTo(FM_PROP_ISMODIFIED) == COMPARE_EQUAL)
+ {
+ Reference< XPropertySet > xSource(evt.Source, UNO_QUERY);
+ DBG_ASSERT( xSource.is(), "DbGridControl::DataSourcePropertyChanged: invalid event source!" );
+ sal_Bool bIsNew = sal_False;
+ if (xSource.is())
+ bIsNew = ::comphelper::getBOOL(xSource->getPropertyValue(FM_PROP_ISNEW));
+
+ if (bIsNew && m_xCurrentRow.Is())
+ {
+ DBG_ASSERT(::comphelper::getBOOL(xSource->getPropertyValue(FM_PROP_ROWCOUNTFINAL)), "DbGridControl::DataSourcePropertyChanged : somebody moved the form to a new record before the row count was final !");
+ sal_Int32 nRecordCount = 0;
+ xSource->getPropertyValue(FM_PROP_ROWCOUNT) >>= nRecordCount;
+ if (::comphelper::getBOOL(evt.NewValue))
+ { // modified state changed from sal_False to sal_True and we're on a insert row
+ // -> we've to add a new grid row
+ if ((nRecordCount == GetRowCount() - 1) && m_xCurrentRow->IsNew())
+ {
+ RowInserted(GetRowCount(), 1, sal_True);
+ InvalidateStatusCell(m_nCurrentPos);
+ m_aBar.InvalidateAll(m_nCurrentPos);
+ }
+ }
+ else
+ { // modified state changed from sal_True to sal_False and we're on a insert row
+ // we have two "new row"s at the moment : the one we're editing currently (where the current
+ // column is the only dirty element) and a "new new" row which is completely clean. As the first
+ // one is about to be cleaned, too, the second one is obsolet now.
+ if (m_xCurrentRow->IsNew() && nRecordCount == (GetRowCount() - 2))
+ {
+ RowRemoved(GetRowCount() - 1, 1, sal_True);
+ InvalidateStatusCell(m_nCurrentPos);
+ m_aBar.InvalidateAll(m_nCurrentPos);
+ }
+ }
+ }
+ if (m_xCurrentRow.Is())
+ {
+ m_xCurrentRow->SetStatus(::comphelper::getBOOL(evt.NewValue) ? GRS_MODIFIED : GRS_CLEAN);
+ m_xCurrentRow->SetNew( bIsNew );
+ InvalidateStatusCell(m_nCurrentPos);
+ TRACE_RANGE_MESSAGE1("modified flag changed, new state : %s", ROWSTATUS(m_xCurrentRow));
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::StartDrag( sal_Int8 /*nAction*/, const Point& rPosPixel )
+{
+ if (!m_pSeekCursor || IsResizing())
+ return;
+
+ sal_uInt16 nColId = GetColumnAtXPosPixel(rPosPixel.X());
+ long nRow = GetRowAtYPosPixel(rPosPixel.Y());
+ if (nColId != HANDLE_ID && nRow >= 0)
+ {
+ if (GetDataWindow().IsMouseCaptured())
+ GetDataWindow().ReleaseMouse();
+
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(nColId));
+ OStringTransferable* pTransferable = new OStringTransferable(GetCurrentRowCellText(pColumn,m_xPaintRow));
+ Reference< XTransferable > xEnsureDelete(pTransferable);
+ pTransferable->StartDrag(this, DND_ACTION_COPY);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::canCopyCellText(sal_Int32 _nRow, sal_Int16 _nColId)
+{
+ return (_nRow >= 0)
+ && (_nRow < GetRowCount())
+ && (_nColId > HANDLE_ID)
+ && (_nColId <= ColCount());
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::copyCellText(sal_Int32 _nRow, sal_Int16 _nColId)
+{
+ DBG_ASSERT(canCopyCellText(_nRow, _nColId), "DbGridControl::copyCellText: invalid call!");
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(_nColId));
+ SeekRow(_nRow);
+ OStringTransfer::CopyString( GetCurrentRowCellText( pColumn,m_xPaintRow ), this );
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::executeRowContextMenu( long _nRow, const Point& _rPreferredPos )
+{
+ PopupMenu aContextMenu( SVX_RES( RID_SVXMNU_ROWS ) );
+
+ PreExecuteRowContextMenu( (sal_uInt16)_nRow, aContextMenu );
+ aContextMenu.RemoveDisabledEntries( sal_True, sal_True );
+ PostExecuteRowContextMenu( (sal_uInt16)_nRow, aContextMenu, aContextMenu.Execute( this, _rPreferredPos ) );
+
+ // TODO: why this weird cast to sal_uInt16? What if we really have more than 65535 lines?
+ // -> change this to sal_uInt32
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::Command(const CommandEvent& rEvt)
+{
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ if ( !m_pSeekCursor )
+ {
+ DbGridControl_Base::Command(rEvt);
+ return;
+ }
+
+ if ( !rEvt.IsMouseEvent() )
+ { // context menu requested by keyboard
+ if ( GetSelectRowCount() )
+ {
+ long nRow = FirstSelectedRow( );
+
+ ::Rectangle aRowRect( GetRowRectPixel( nRow, sal_True ) );
+ executeRowContextMenu( nRow, aRowRect.LeftCenter() );
+
+ // handled
+ return;
+ }
+ }
+
+ sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
+ long nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y());
+
+ if (nColId == HANDLE_ID)
+ {
+ executeRowContextMenu( nRow, rEvt.GetMousePosPixel() );
+ }
+ else if (canCopyCellText(nRow, nColId))
+ {
+ PopupMenu aContextMenu(SVX_RES(RID_SVXMNU_CELL));
+ aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
+ switch (aContextMenu.Execute(this, rEvt.GetMousePosPixel()))
+ {
+ case SID_COPY:
+ copyCellText(nRow, nColId);
+ break;
+ }
+ }
+ else
+ {
+ DbGridControl_Base::Command(rEvt);
+ return;
+ }
+ }
+ default:
+ DbGridControl_Base::Command(rEvt);
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(DbGridControl, OnDelete, void*, /*EMPTYTAG*/ )
+{
+ DBG_CHKTHIS(DbGridControl, NULL );
+ m_nDeleteEvent = 0;
+ DeleteSelectedRows();
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::DeleteSelectedRows()
+{
+ DBG_ASSERT(GetSelection(), "keine selection!!!");
+
+ if (!m_pSeekCursor)
+ return;
+
+/* Application::EnterWait();
+ Reference< XPropertySet > xSet = (XPropertySet*)xSeekCursor->queryInterface(XPropertySet::getSmartUik());
+
+ // wenn mehr als 25 Datensaetze geloescht werden, wird der Cache abgeschaltet
+ // da das loeschen ansonsten zu langsam wird
+ sal_uInt16 nCacheSize = 0;
+ if (GetSelectRowCount() > 25)
+ {
+ // CacheSize merken und Cache zuruecksetzen
+ nCacheSize = xSet->getPropertyValue(L"CacheSize").getUINT16();
+ if (nCacheSize)
+ xSet->setPropertyValue(L"CacheSize", Any(sal_uInt16(0)));
+ } */
+
+
+ /*
+ // mu� der Cache wiederhergestellt werden?
+ if (nCacheSize)
+ {
+ // Cache wieder einschalten
+ xSet->setPropertyValue(L"CacheSize", Any(sal_uInt16(nCacheSize)));
+
+ // Browser neu einstellen
+ RecalcRows(GetTopRow(), GetVisibleRows(), sal_True);
+
+ // aktuelle Zeile aktualisieren
+ SeekCursor(GetCurRow());
+ if (IsAppendRow(m_nSeekPos))
+ xDataCursor->addRecord();
+ else
+ {
+ Any aBookmark = xSeekCursor->getBookmark();
+ xDataCursor->moveToBookmark(aBookmark);
+ }
+ m_xCurrentRow = new DbGridRow(xDataCursor);
+ m_nCurrentPos = m_nSeekPos;
+
+ // complett invalidieren
+ Invalidate();
+ }
+ else
+ // Browser neu einstellen
+ RecalcRows(GetTopRow(), GetVisibleRows(), sal_True);
+
+ // gibt es keine Selection mehr?
+ if (!GetSelectRowCount())
+ ActivateCell();
+
+ m_aBar.InvalidateAll();
+ Application::LeaveWait();
+
+ m_bUpdating = sal_False;
+*/
+}
+
+//------------------------------------------------------------------------------
+CellController* DbGridControl::GetController(long /*nRow*/, sal_uInt16 nColumnId)
+{
+ if (!IsValid(m_xCurrentRow) || !IsEnabled())
+ return NULL;
+
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(nColumnId));
+ if (!pColumn)
+ return NULL;
+
+ CellController* pReturn = NULL;
+ if (IsFilterMode())
+ pReturn = &pColumn->GetController();
+ else
+ {
+ if (::comphelper::hasProperty(FM_PROP_ENABLED, pColumn->getModel()))
+ {
+ if (!::comphelper::getBOOL(pColumn->getModel()->getPropertyValue(FM_PROP_ENABLED)))
+ return NULL;
+ }
+
+ sal_Bool bInsert = (m_xCurrentRow->IsNew() && (m_nOptions & OPT_INSERT));
+ sal_Bool bUpdate = (!m_xCurrentRow->IsNew() && (m_nOptions & OPT_UPDATE));
+
+ if ((bInsert && !pColumn->IsAutoValue()) || bUpdate || m_bForceROController)
+ {
+ pReturn = &pColumn->GetController();
+ if (pReturn)
+ {
+ // wenn es eine Edit-Zeile ist, kann ich ihr das forced read-only mitgeben
+ if (!pReturn->ISA(EditCellController) && !pReturn->ISA(SpinCellController))
+ // ich konnte den Controller in forceROController nicht auf ReadOnly setzen
+ if (!bInsert && !bUpdate)
+ // ich bin nur hier, da m_bForceROController gesetzt war
+ // -> lieber kein Controller als einer ohne RO
+ pReturn = NULL;
+ }
+ }
+ }
+ return pReturn;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::InitController(CellControllerRef& /*rController*/, long /*nRow*/, sal_uInt16 nColumnId)
+{
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(nColumnId));
+ if (pColumn)
+ pColumn->UpdateFromField(m_xCurrentRow, m_xFormatter);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::CellModified()
+{
+ TRACE_RANGE("DbGridControl::CellModified");
+
+ {
+ ::osl::MutexGuard aGuard(m_aAdjustSafety);
+ if (m_nAsynAdjustEvent)
+ {
+ TRACE_RANGE_MESSAGE1("forcing a synchron call to ", m_bPendingAdjustRows ? "AdjustRows" : "AdustDataSource");
+ RemoveUserEvent(m_nAsynAdjustEvent);
+ m_nAsynAdjustEvent = 0;
+
+ // force the call : this should be no problem as we're probably running in the solar thread here
+ // (cell modified is triggered by user actions)
+ if (m_bPendingAdjustRows)
+ AdjustRows();
+ else
+ AdjustDataSource();
+ }
+ }
+
+ if (!IsFilterMode() && IsValid(m_xCurrentRow) && !m_xCurrentRow->IsModified())
+ {
+ // Einschalten des Editiermodus
+ // Datensatz soll eingefuegt werden
+ if (m_xCurrentRow->IsNew())
+ {
+ m_xCurrentRow->SetStatus(GRS_MODIFIED);
+ TRACE_RANGE_MESSAGE("current row is new, new state : MODIFIED");
+ // wenn noch keine Zeile hinzugefuegt wurde, dann neue hinzunehmen
+ if (m_nCurrentPos == GetRowCount() - 1)
+ {
+ // RowCount um einen erhoehen
+ RowInserted(GetRowCount(), 1, sal_True);
+ InvalidateStatusCell(m_nCurrentPos);
+ m_aBar.InvalidateAll(m_nCurrentPos);
+ }
+ }
+ else if (m_xCurrentRow->GetStatus() != GRS_MODIFIED)
+ {
+ m_xCurrentRow->SetState(m_pDataCursor, sal_False);
+ TRACE_RANGE_MESSAGE1("current row is not new, after SetState, new state : %s", ROWSTATUS(m_xCurrentRow));
+ m_xCurrentRow->SetStatus(GRS_MODIFIED);
+ TRACE_RANGE_MESSAGE("current row is not new, new state : MODIFIED");
+ InvalidateStatusCell(m_nCurrentPos);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::Dispatch(sal_uInt16 nId)
+{
+ if (nId == BROWSER_CURSORENDOFFILE)
+ {
+ if (m_nOptions & OPT_INSERT)
+ AppendNew();
+ else
+ MoveToLast();
+ }
+ else
+ DbGridControl_Base::Dispatch(nId);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::Undo()
+{
+ if (!IsFilterMode() && IsValid(m_xCurrentRow) && IsModified())
+ {
+ // check if we have somebody doin' the UNDO for us
+ long nState = -1;
+ if (m_aMasterStateProvider.IsSet())
+ nState = m_aMasterStateProvider.Call((void*)SID_FM_RECORD_UNDO);
+ if (nState>0)
+ { // yes, we have, and the slot is enabled
+ DBG_ASSERT(m_aMasterSlotExecutor.IsSet(), "DbGridControl::Undo : a state, but no execute link ?");
+ long lResult = m_aMasterSlotExecutor.Call((void*)SID_FM_RECORD_UNDO);
+ if (lResult)
+ // handled
+ return;
+ }
+ else if (nState == 0)
+ // yes, we have, and the slot is disabled
+ return;
+
+ BeginCursorAction();
+
+ sal_Bool bAppending = m_xCurrentRow->IsNew();
+ sal_Bool bDirty = m_xCurrentRow->IsModified();
+
+ try
+ {
+ // Editieren abbrechen
+ Reference< XResultSetUpdate > xUpdateCursor((Reference< XInterface >)*m_pDataCursor, UNO_QUERY);
+ // no effects if we're not updating currently
+ if (bAppending)
+ // just refresh the row
+ xUpdateCursor->moveToInsertRow();
+ else
+ xUpdateCursor->cancelRowUpdates();
+
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ EndCursorAction();
+
+ m_xDataRow->SetState(m_pDataCursor, sal_False);
+ if (&m_xPaintRow == &m_xCurrentRow)
+ m_xPaintRow = m_xCurrentRow = m_xDataRow;
+ else
+ m_xCurrentRow = m_xDataRow;
+
+ if (bAppending && (DbGridControl_Base::IsModified() || bDirty))
+ // remove the row
+ if (m_nCurrentPos == GetRowCount() - 2)
+ { // maybe we already removed it (in resetCurrentRow, called if the above moveToInsertRow
+ // caused our data source form to be reset - which should be the usual case ....)
+ RowRemoved(GetRowCount() - 1, 1, sal_True);
+ m_aBar.InvalidateAll(m_nCurrentPos);
+ }
+
+ RowModified(m_nCurrentPos);
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::resetCurrentRow()
+{
+ if (IsModified())
+ {
+ // scenario : we're on the insert row, the row is dirty, and thus there exists a "second" insert row (which
+ // is clean). Normally in DataSourcePropertyChanged we would remove this second row if the modified state of
+ // the insert row changes from sal_True to sal_False. But if our current cell is the only modified element (means the
+ // data source isn't modified) and we're reset this DataSourcePropertyChanged would never be called, so we
+ // would never delete the obsolet "second insert row". Thus in this special case this method here
+ // is the only possibility to determine the redundance of the row (resetCurrentRow is called when the
+ // "first insert row" is about to be cleaned, so of course the "second insert row" is redundant now)
+ Reference< XPropertySet > xDataSource = getDataSource()->getPropertySet();
+ if (xDataSource.is() && !::comphelper::getBOOL(xDataSource->getPropertyValue(FM_PROP_ISMODIFIED)))
+ {
+ // are we on a new row currently ?
+ if (m_xCurrentRow->IsNew())
+ {
+ if (m_nCurrentPos == GetRowCount() - 2)
+ {
+ RowRemoved(GetRowCount() - 1, 1, sal_True);
+ m_aBar.InvalidateAll(m_nCurrentPos);
+ }
+ }
+ }
+
+ // update the rows
+ m_xDataRow->SetState(m_pDataCursor, sal_False);
+ if (&m_xPaintRow == &m_xCurrentRow)
+ m_xPaintRow = m_xCurrentRow = m_xDataRow;
+ else
+ m_xCurrentRow = m_xDataRow;
+ }
+
+ RowModified(GetCurRow()); // will update the current controller if affected
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::RowModified( long nRow, sal_uInt16 /*nColId*/ )
+{
+ if (nRow == m_nCurrentPos && IsEditing())
+ {
+ CellControllerRef aTmpRef = Controller();
+ aTmpRef->ClearModified();
+ InitController(aTmpRef, m_nCurrentPos, GetCurColumnId());
+ }
+ DbGridControl_Base::RowModified(nRow);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::IsModified() const
+{
+ return !IsFilterMode() && IsValid(m_xCurrentRow) && (m_xCurrentRow->IsModified() || DbGridControl_Base::IsModified());
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::IsCurrentAppending() const
+{
+ return m_xCurrentRow.Is() && m_xCurrentRow->IsNew();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::IsInsertionRow(long nRow) const
+{
+ return (m_nOptions & OPT_INSERT) && m_nTotalCount >= 0 && (nRow == GetRowCount() - 1);
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::SaveModified()
+{
+ TRACE_RANGE("DbGridControl::SaveModified");
+ DBG_ASSERT(IsValid(m_xCurrentRow), "GridControl:: Invalid row");
+ if (!IsValid(m_xCurrentRow))
+ return sal_True;
+
+ // Uebernimmt die Dateneingabe fuer das Feld
+ // Hat es aenderungen im aktuellen Eingabefeld gegeben ?
+ if (!DbGridControl_Base::IsModified())
+ return sal_True;
+
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(GetCurColumnId()));
+ sal_Bool bOK = pColumn->Commit();
+ DBG_ASSERT( Controller().Is(), "DbGridControl::SaveModified: was modified, by have no controller?!" );
+ if ( !Controller().Is() )
+ // this might happen if the callbacks implicitly triggered by Commit
+ // fiddled with the form or the control ...
+ // (Note that this here is a workaround, at most. We need a general concept how
+ // to treat this, you can imagine an arbitrary number of scenarios where a callback
+ // triggers something which leaves us in an expected state.)
+ // #i67147# / 2006-07-17 / frank.schoenheit@sun.com
+ return bOK;
+
+ if (bOK)
+ {
+ Controller()->ClearModified();
+
+ if ( IsValid(m_xCurrentRow) )
+ {
+ m_xCurrentRow->SetState(m_pDataCursor, sal_False);
+ TRACE_RANGE_MESSAGE1("explicit SetState, new state : %s", ROWSTATUS(m_xCurrentRow));
+ InvalidateStatusCell( m_nCurrentPos );
+ }
+#ifdef DBG_UTIL
+ else
+ {
+ TRACE_RANGE_MESSAGE1("no SetState, new state : %s", ROWSTATUS(m_xCurrentRow));
+ }
+#endif
+ }
+ else
+ {
+ // reset the modified flag ....
+ Controller()->SetModified();
+ }
+
+ return bOK;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::SaveRow()
+{
+ TRACE_RANGE("DbGridControl::SaveRow");
+ // gueltige Zeile
+ if (!IsValid(m_xCurrentRow) || !IsModified())
+ return sal_True;
+ // Wert des Controllers noch nicht gespeichert
+ else if (Controller().Is() && Controller()->IsModified())
+ {
+ if (!SaveModified())
+ return sal_False;
+ }
+ m_bUpdating = sal_True;
+
+ BeginCursorAction();
+ sal_Bool bAppending = m_xCurrentRow->IsNew();
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ Reference< XResultSetUpdate > xUpdateCursor((Reference< XInterface >)*m_pDataCursor, UNO_QUERY);
+ if (bAppending)
+ xUpdateCursor->insertRow();
+ else
+ xUpdateCursor->updateRow();
+ bSuccess = sal_True;
+ }
+ catch(SQLException& e)
+ {
+ (void)e; // make compiler happy
+ EndCursorAction();
+ m_bUpdating = sal_False;
+ return sal_False;
+ }
+
+ try
+ {
+ if (bSuccess)
+ {
+ // if we are appending we still sit on the insert row
+ // we don't move just clear the flags not to move on the current row
+ m_xCurrentRow->SetState(m_pDataCursor, sal_False);
+ TRACE_RANGE_MESSAGE1("explicit SetState after a successfull update, new state : %s", ROWSTATUS(m_xCurrentRow));
+ m_xCurrentRow->SetNew(sal_False);
+
+ // adjust the seekcursor if it is on the same position as the datacursor
+ if (m_nSeekPos == m_nCurrentPos || bAppending)
+ {
+ // get the bookmark to refetch the data
+ // in insert mode we take the new bookmark of the data cursor
+ Any aBookmark = bAppending ? m_pDataCursor->getBookmark() : m_pSeekCursor->getBookmark();
+ m_pSeekCursor->moveToBookmark(aBookmark);
+ // get the data
+ m_xSeekRow->SetState(m_pSeekCursor, sal_True);
+ m_nSeekPos = m_pSeekCursor->getRow() - 1;
+ }
+ }
+ // and repaint the row
+ RowModified(m_nCurrentPos);
+ }
+ catch(Exception&)
+ {
+ }
+
+ m_bUpdating = sal_False;
+ EndCursorAction();
+
+ // The old code returned (nRecords != 0) here.
+ // Me thinks this is wrong : If something goes wrong while update the record, an exception will be thrown,
+ // which results in a "return sal_False" (see above). If no exception is thrown, everything is fine. If nRecords
+ // is zero, this simply means all fields had their original values.
+ // FS - 06.12.99 - 70502
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+long DbGridControl::PreNotify(NotifyEvent& rEvt)
+{
+ // keine Events der Navbar behandeln
+ if (m_aBar.IsWindowOrChild(rEvt.GetWindow()))
+ return BrowseBox::PreNotify(rEvt);
+
+ switch (rEvt.GetType())
+ {
+ case EVENT_KEYINPUT:
+ {
+ const KeyEvent* pKeyEvent = rEvt.GetKeyEvent();
+
+ sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode();
+ sal_Bool bShift = pKeyEvent->GetKeyCode().IsShift();
+ sal_Bool bCtrl = pKeyEvent->GetKeyCode().IsMod1();
+ sal_Bool bAlt = pKeyEvent->GetKeyCode().IsMod2();
+ if ( ( KEY_TAB == nCode ) && bCtrl && !bAlt )
+ {
+ // Ctrl-Tab is used to step out of the control, without traveling to the
+ // remaining cells first
+ // -> build a new key event without the Ctrl-key, and let the very base class handle it
+ KeyCode aNewCode( KEY_TAB, bShift, sal_False, sal_False, sal_False );
+ KeyEvent aNewEvent( pKeyEvent->GetCharCode(), aNewCode );
+
+ // call the Control - our direct base class will interpret this in a way we do not want (and do
+ // a cell traveling)
+ Control::KeyInput( aNewEvent );
+ return 1;
+ }
+
+ if ( !bShift && !bCtrl && ( KEY_ESCAPE == nCode ) )
+ {
+ if (IsModified())
+ {
+ Undo();
+ return 1;
+ }
+ }
+ else if ( ( KEY_DELETE == nCode ) && !bShift && !bCtrl ) // delete rows
+ {
+ if ((m_nOptions & OPT_DELETE) && GetSelectRowCount())
+ {
+ // delete asynchron
+ if (m_nDeleteEvent)
+ Application::RemoveUserEvent(m_nDeleteEvent);
+ m_nDeleteEvent = Application::PostUserEvent(LINK(this,DbGridControl,OnDelete));
+ return 1;
+ }
+ }
+ } // kein break!
+ default:
+ return DbGridControl_Base::PreNotify(rEvt);
+ }
+}
+
+//------------------------------------------------------------------------------
+sal_Bool DbGridControl::IsTabAllowed(sal_Bool bRight) const
+{
+ if (bRight)
+ // Tab nur wenn nicht auf der letzten Zelle
+ return GetCurRow() < (GetRowCount() - 1) || !m_bRecordCountFinal ||
+ GetViewColumnPos(GetCurColumnId()) < (GetViewColCount() - 1);
+ else
+ {
+ // Tab nur wenn nicht auf der ersten Zelle
+ return GetCurRow() > 0 || (GetCurColumnId() && GetViewColumnPos(GetCurColumnId()) > 0);
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::KeyInput( const KeyEvent& rEvt )
+{
+ if (rEvt.GetKeyCode().GetFunction() == KEYFUNC_COPY)
+ {
+ long nRow = GetCurRow();
+ sal_uInt16 nColId = GetCurColumnId();
+ if (nRow >= 0 && nRow < GetRowCount() && nColId < ColCount())
+ {
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(nColId));
+ OStringTransfer::CopyString( GetCurrentRowCellText( pColumn,m_xPaintRow ), this );
+ return;
+ }
+ }
+ DbGridControl_Base::KeyInput(rEvt);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::HideColumn(sal_uInt16 nId)
+{
+ DeactivateCell();
+
+ // determine the col for the focus to set to after removal
+ sal_uInt16 nPos = GetViewColumnPos(nId);
+ sal_uInt16 nNewColId = nPos == (ColCount()-1)
+ ? GetColumnIdFromViewPos(nPos-1) // last col is to be removed -> take the previous
+ : GetColumnIdFromViewPos(nPos+1); // take the next
+
+ long lCurrentWidth = GetColumnWidth(nId);
+ DbGridControl_Base::RemoveColumn(nId);
+ // don't use my own RemoveColumn, this would remove it from m_aColumns, too
+
+ // update my model
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(nId));
+ DBG_ASSERT(pColumn, "DbGridControl::HideColumn : somebody did hide a nonexistent column !");
+ if (pColumn)
+ {
+ pColumn->m_bHidden = sal_True;
+ pColumn->m_nLastVisibleWidth = CalcReverseZoom(lCurrentWidth);
+ }
+
+ // and reset the focus
+ if ( nId == GetCurColumnId() )
+ GoToColumnId( nNewColId );
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::ShowColumn(sal_uInt16 nId)
+{
+ sal_uInt16 nPos = GetModelColumnPos(nId);
+ DBG_ASSERT(nPos != (sal_uInt16)-1, "DbGridControl::ShowColumn : invalid argument !");
+ if (nPos == (sal_uInt16)-1)
+ return;
+
+ DbGridColumn* pColumn = m_aColumns.GetObject(nPos);
+ if (!pColumn->IsHidden())
+ {
+ DBG_ASSERT(GetViewColumnPos(nId) != (sal_uInt16)-1, "DbGridControl::ShowColumn : inconsistent internal state !");
+ // if the column isn't marked as hidden, it should be visible, shouldn't it ?
+ return;
+ }
+ DBG_ASSERT(GetViewColumnPos(nId) == (sal_uInt16)-1, "DbGridControl::ShowColumn : inconsistent internal state !");
+ // the opposite situation ...
+
+ // to determine the new view position we need an adjacent non-hidden column
+ sal_uInt16 nNextNonHidden = (sal_uInt16)-1;
+ // first search the cols to the right
+ for (sal_uInt16 i = nPos + 1; i<m_aColumns.Count(); ++i)
+ {
+ DbGridColumn* pCurCol = m_aColumns.GetObject(i);
+ if (!pCurCol->IsHidden())
+ {
+ nNextNonHidden = i;
+ break;
+ }
+ }
+ if ((nNextNonHidden == (sal_uInt16)-1) && (nPos > 0))
+ {
+ // then to the left
+ for (sal_uInt16 i = nPos; i>0; --i)
+ {
+ DbGridColumn* pCurCol = m_aColumns.GetObject(i-1);
+ if (!pCurCol->IsHidden())
+ {
+ nNextNonHidden = i-1;
+ break;
+ }
+ }
+ }
+ sal_uInt16 nNewViewPos = (nNextNonHidden == (sal_uInt16)-1)
+ ? 1 // there is no visible column -> insert behinde the handle col
+ : GetViewColumnPos(m_aColumns.GetObject(nNextNonHidden)->GetId()) + 1;
+ // the first non-handle col has "view pos" 0, but the pos arg for InsertDataColumn expects
+ // a position 1 for the first non-handle col -> +1
+ DBG_ASSERT(nNewViewPos != (sal_uInt16)-1, "DbGridControl::ShowColumn : inconsistent internal state !");
+ // we found a col marked as visible but got no view pos for it ...
+
+ if ((nNextNonHidden<nPos) && (nNextNonHidden != (sal_uInt16)-1))
+ // nNextNonHidden is a column to the left, so we want to insert the new col _right_ beside it's pos
+ ++nNewViewPos;
+
+ DeactivateCell();
+
+ ::rtl::OUString aName;
+ pColumn->getModel()->getPropertyValue(FM_PROP_LABEL) >>= aName;
+ InsertDataColumn(nId, aName, CalcZoom(pColumn->m_nLastVisibleWidth), HIB_CENTER | HIB_VCENTER | HIB_CLICKABLE, nNewViewPos);
+ pColumn->m_bHidden = sal_False;
+
+ ActivateCell();
+ Invalidate();
+}
+
+//------------------------------------------------------------------------------
+sal_uInt16 DbGridControl::GetColumnIdFromModelPos( sal_uInt16 nPos ) const
+{
+ if (nPos >= m_aColumns.Count())
+ {
+ DBG_ERROR("DbGridControl::GetColumnIdFromModelPos : invalid argument !");
+ return (sal_uInt16)-1;
+ }
+
+ DbGridColumn* pCol = m_aColumns.GetObject(nPos);
+#if (OSL_DEBUG_LEVEL > 0) || defined DBG_UTIL
+ // in der Debug-Version rechnen wir die ModelPos in eine ViewPos um und vergleichen das mit dem Wert,
+ // den wir zurueckliefern werden (nId an der entsprechenden Col in m_aColumns)
+
+ if (!pCol->IsHidden())
+ { // macht nur Sinn, wenn die Spalte sichtbar ist
+ sal_uInt16 nViewPos = nPos;
+ for (sal_uInt16 i=0; i<m_aColumns.Count() && i<nPos; ++i)
+ if (m_aColumns.GetObject(i)->IsHidden())
+ --nViewPos;
+
+ DBG_ASSERT(pCol && GetColumnIdFromViewPos(nViewPos) == pCol->GetId(),
+ "DbGridControl::GetColumnIdFromModelPos : this isn't consistent .... did I misunderstand something ?");
+ }
+#endif
+ return pCol->GetId();
+}
+
+//------------------------------------------------------------------------------
+sal_uInt16 DbGridControl::GetModelColumnPos( sal_uInt16 nId ) const
+{
+ for (sal_uInt16 i=0; i<m_aColumns.Count(); ++i)
+ if (m_aColumns.GetObject(i)->GetId() == nId)
+ return i;
+
+ return GRID_COLUMN_NOT_FOUND;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::implAdjustInSolarThread(BOOL _bRows)
+{
+ TRACE_RANGE("DbGridControl::implAdjustInSolarThread");
+ ::osl::MutexGuard aGuard(m_aAdjustSafety);
+ if (::osl::Thread::getCurrentIdentifier() != Application::GetMainThreadIdentifier())
+ {
+ m_nAsynAdjustEvent = PostUserEvent(LINK(this, DbGridControl, OnAsyncAdjust), reinterpret_cast< void* >( _bRows ));
+ m_bPendingAdjustRows = _bRows;
+#ifdef DBG_UTIL
+ if (_bRows)
+ TRACE_RANGE_MESSAGE("posting an AdjustRows")
+ else
+ TRACE_RANGE_MESSAGE("posting an AdjustDataSource")
+#endif
+ }
+ else
+ {
+#ifdef DBG_UTIL
+ if (_bRows)
+ TRACE_RANGE_MESSAGE("doing an AdjustRows")
+ else
+ TRACE_RANGE_MESSAGE("doing an AdjustDataSource")
+#endif
+ // always adjust the rows before adjusting the data source
+ // If this is not necessary (because the row count did not change), nothing is done
+ // The problem is that we can't rely on the order of which the calls come in: If the cursor was moved
+ // to a position behind row count know 'til now, the cursorMoved notification may come before the
+ // RowCountChanged notification
+ // 94093 - 02.11.2001 - frank.schoenheit@sun.com
+ AdjustRows();
+
+ if ( !_bRows )
+ AdjustDataSource();
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(DbGridControl, OnAsyncAdjust, void*, pAdjustWhat)
+{
+ m_nAsynAdjustEvent = 0;
+
+ AdjustRows();
+ // see implAdjustInSolarThread for a comment why we do this every time
+
+ if ( !pAdjustWhat )
+ AdjustDataSource();
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::BeginCursorAction()
+{
+ if (m_pFieldListeners)
+ {
+ ColumnFieldValueListeners* pListeners = (ColumnFieldValueListeners*)m_pFieldListeners;
+ ConstColumnFieldValueListenersIterator aIter = pListeners->begin();
+ while (aIter != pListeners->end())
+ {
+ GridFieldValueListener* pCurrent = (*aIter).second;
+ if (pCurrent)
+ pCurrent->suspend();
+ ++aIter;
+ }
+ }
+
+ if (m_pDataSourcePropListener)
+ m_pDataSourcePropListener->suspend();
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::EndCursorAction()
+{
+ if (m_pFieldListeners)
+ {
+ ColumnFieldValueListeners* pListeners = (ColumnFieldValueListeners*)m_pFieldListeners;
+ ConstColumnFieldValueListenersIterator aIter = pListeners->begin();
+ while (aIter != pListeners->end())
+ {
+ GridFieldValueListener* pCurrent = (*aIter).second;
+ if (pCurrent)
+ pCurrent->resume();
+ ++aIter;
+ }
+ }
+
+ if (m_pDataSourcePropListener)
+ m_pDataSourcePropListener->resume();
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::ConnectToFields()
+{
+ ColumnFieldValueListeners* pListeners = (ColumnFieldValueListeners*)m_pFieldListeners;
+ DBG_ASSERT(!pListeners || pListeners->size() == 0, "DbGridControl::ConnectToFields : please call DisconnectFromFields first !");
+
+ if (!pListeners)
+ {
+ pListeners = new ColumnFieldValueListeners;
+ m_pFieldListeners = pListeners;
+ }
+
+ for (sal_Int32 i=0; i<(sal_Int32)m_aColumns.Count(); ++i)
+ {
+ DbGridColumn* pCurrent = m_aColumns.GetObject(i);
+ sal_uInt16 nViewPos = pCurrent ? GetViewColumnPos(pCurrent->GetId()) : (sal_uInt16)-1;
+ if ((sal_uInt16)-1 == nViewPos)
+ continue;
+
+ Reference< XPropertySet > xField = pCurrent->GetField();
+ if (!xField.is())
+ continue;
+
+ // column is visible and bound here
+ GridFieldValueListener*& rpListener = (*pListeners)[pCurrent->GetId()];
+ DBG_ASSERT(!rpListener, "DbGridControl::ConnectToFields : already a listener for this column ?!");
+ rpListener = new GridFieldValueListener(*this, xField, pCurrent->GetId());
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::DisconnectFromFields()
+{
+ if (!m_pFieldListeners)
+ return;
+
+ ColumnFieldValueListeners* pListeners = (ColumnFieldValueListeners*)m_pFieldListeners;
+ while (pListeners->size())
+ {
+#ifdef DBG_UTIL
+ sal_Int32 nOldSize = pListeners->size();
+#endif
+ pListeners->begin()->second->dispose();
+ DBG_ASSERT(nOldSize > (sal_Int32)pListeners->size(), "DbGridControl::DisconnectFromFields : dispose on a listener should result in a removal from my list !");
+ }
+
+ delete pListeners;
+ m_pFieldListeners = NULL;
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::FieldValueChanged(sal_uInt16 _nId, const PropertyChangeEvent& /*_evt*/)
+{
+ osl::MutexGuard aPreventDestruction(m_aDestructionSafety);
+ // needed as this may run in a thread other than the main one
+ if (GetRowStatus(GetCurRow()) != DbGridControl_Base::MODIFIED)
+ // all other cases are handled elsewhere
+ return;
+
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(_nId));
+ if (pColumn)
+ {
+ sal_Bool bAcquiredPaintSafety = sal_False;
+ while (!m_bWantDestruction && !bAcquiredPaintSafety)
+ bAcquiredPaintSafety = Application::GetSolarMutex().tryToAcquire();
+
+ if (m_bWantDestruction)
+ { // at this moment, within another thread, our destructor tries to destroy the listener which called this method
+ // => don't do anything
+ // 73365 - 23.02.00 - FS
+ if (bAcquiredPaintSafety)
+ // though the above while-loop suggests that (m_bWantDestruction && bAcquiredPaintSafety) is impossible,
+ // it isnt't, as m_bWantDestruction isn't protected with any mutex
+ Application::GetSolarMutex().release();
+ return;
+ }
+ // here we got the solar mutex, transfer it to a guard for safety reasons
+ SolarMutexGuard aPaintSafety;
+ Application::GetSolarMutex().release();
+
+ // and finally do the update ...
+ pColumn->UpdateFromField(m_xCurrentRow, m_xFormatter);
+ RowModified(GetCurRow(), _nId);
+ }
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::FieldListenerDisposing(sal_uInt16 _nId)
+{
+ ColumnFieldValueListeners* pListeners = (ColumnFieldValueListeners*)m_pFieldListeners;
+ if (!pListeners)
+ {
+ DBG_ERROR("DbGridControl::FieldListenerDisposing : invalid call (have no listener array) !");
+ return;
+ }
+
+ ColumnFieldValueListenersIterator aPos = pListeners->find(_nId);
+ if (aPos == pListeners->end())
+ {
+ DBG_ERROR("DbGridControl::FieldListenerDisposing : invalid call (did not find the listener) !");
+ return;
+ }
+
+ delete aPos->second;
+
+ pListeners->erase(aPos);
+}
+
+//------------------------------------------------------------------------------
+void DbGridControl::disposing(sal_uInt16 _nId, const EventObject& /*_rEvt*/)
+{
+ if (_nId == 0)
+ { // the seek cursor is beeing disposed
+ ::osl::MutexGuard aGuard(m_aAdjustSafety);
+ setDataSource(NULL,0); // our clone was disposed so we set our datasource to null to avoid later acces to it
+ if (m_nAsynAdjustEvent)
+ {
+ RemoveUserEvent(m_nAsynAdjustEvent);
+ m_nAsynAdjustEvent = 0;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Int32 DbGridControl::GetAccessibleControlCount() const
+{
+ return DbGridControl_Base::GetAccessibleControlCount() + 1; // the navigation control
+}
+// -----------------------------------------------------------------------------
+Reference<XAccessible > DbGridControl::CreateAccessibleControl( sal_Int32 _nIndex )
+{
+ Reference<XAccessible > xRet;
+ if ( _nIndex == DbGridControl_Base::GetAccessibleControlCount() )
+ {
+ xRet = m_aBar.GetAccessible();
+ }
+ else
+ xRet = DbGridControl_Base::CreateAccessibleControl( _nIndex );
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+Reference< XAccessible > DbGridControl::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
+{
+ USHORT nColumnId = GetColumnId( _nColumnPos );
+ DbGridColumn* pColumn = m_aColumns.GetObject(GetModelColumnPos(nColumnId));
+ if ( pColumn )
+ {
+ Reference< ::com::sun::star::awt::XControl> xInt(pColumn->GetCell());
+ Reference< ::com::sun::star::awt::XCheckBox> xBox(xInt,UNO_QUERY);
+ if ( xBox.is() )
+ {
+ TriState eValue = STATE_NOCHECK;
+ switch( xBox->getState() )
+ {
+ case 0:
+ eValue = STATE_NOCHECK;
+ break;
+ case 1:
+ eValue = STATE_CHECK;
+ break;
+ case 2:
+ eValue = STATE_DONTKNOW;
+ break;
+ }
+ return DbGridControl_Base::CreateAccessibleCheckBoxCell( _nRow, _nColumnPos,eValue,TRUE );
+ }
+ }
+ return DbGridControl_Base::CreateAccessibleCell( _nRow, _nColumnPos );
+}
+// -----------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/fmcomp/gridctrl.src b/svx/source/fmcomp/gridctrl.src
new file mode 100644
index 000000000000..f6e4c164046f
--- /dev/null
+++ b/svx/source/fmcomp/gridctrl.src
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "fmresids.hrc"
+#include <svx/svxids.hrc>
+#include "globlmn.hrc"
+#include "fmhelp.hrc"
+Menu RID_SVXMNU_ROWS
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_FM_DELETEROWS ;
+ HelpID = SID_FM_DELETEROWS ;
+ Text [ en-US ] = "Delete Rows" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_RECORD_SAVE ;
+ HelpID = SID_FM_RECORD_SAVE ;
+ Text [ en-US ] = "Save Record" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_RECORD_UNDO ;
+ HelpID = SID_FM_RECORD_UNDO ;
+ Text [ en-US ] = "Undo: Data entry" ;
+ };
+ };
+};
+Menu RID_SVXMNU_COLS
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_FM_INSERTCOL ;
+ HelpID = SID_FM_INSERTCOL ;
+ Text [ en-US ] = "Insert ~Column" ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_FM_EDIT ;
+ HelpID = SID_FM_EDIT ;
+ Text [ en-US ] = "Text Box" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CHECKBOX ;
+ HelpID = SID_FM_CHECKBOX ;
+ Text [ en-US ] = "Check Box" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_COMBOBOX ;
+ HelpID = SID_FM_COMBOBOX ;
+ Text [ en-US ] = "Combo Box" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_LISTBOX ;
+ HelpID = SID_FM_LISTBOX ;
+ Text [ en-US ] = "List Box" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_DATEFIELD ;
+ HelpID = SID_FM_DATEFIELD ;
+ Text [ en-US ] = "Date Field" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_TIMEFIELD ;
+ HelpID = SID_FM_TIMEFIELD ;
+ Text [ en-US ] = "Time Field" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_NUMERICFIELD ;
+ HelpID = SID_FM_NUMERICFIELD ;
+ Text [ en-US ] = "Numeric Field" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CURRENCYFIELD ;
+ HelpID = SID_FM_CURRENCYFIELD ;
+ Text [ en-US ] = "Currency Field" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_PATTERNFIELD ;
+ HelpID = SID_FM_PATTERNFIELD ;
+ Text [ en-US ] = "Pattern Field" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_FORMATTEDFIELD ;
+ HelpID = SID_FM_FORMATTEDFIELD ;
+ Text [ en-US ] = "Formatted Field" ;
+ };
+ MenuItem
+ {
+ // this is a dummy which is never used herein but for copy to newly built menus
+ Identifier = SID_FM_TWOFIELDS_DATE_N_TIME;
+ HelpId = HID_CONTROLS_DATE_N_TIME;
+ Text [ en-US ] = "Date and Time Field" ;
+ Disable = True;
+ };
+ };
+ };
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CHANGECOL ;
+ HelpID = SID_FM_CHANGECOL ;
+ Text [ en-US ] = "~Replace with" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_DELETECOL ;
+ HelpID = SID_FM_DELETECOL ;
+ Text [ en-US ] = "Delete Column" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_HIDECOL ;
+ HelpID = SID_FM_HIDECOL ;
+ Text [ en-US ] = "~Hide Column";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_SHOWCOLS ;
+ HelpID = SID_FM_SHOWCOLS ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_FM_SHOWCOLS_MORE ;
+ HelpID = SID_FM_SHOWCOLS_MORE ;
+ Text [ en-US ] = "~More...";
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_SHOWALLCOLS ;
+ HelpID = SID_FM_SHOWALLCOLS ;
+ Text [ en-US ] = "~All";
+ };
+ };
+ };
+ Text [ en-US ] = "~Show Columns";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_SHOW_PROPERTY_BROWSER ;
+ HelpID = SID_FM_SHOW_PROPERTY_BROWSER ;
+ Text [ en-US ] = "Column..." ;
+ };
+ };
+};
+
+Menu RID_SVXMNU_CELL
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_EDIT_COPY
+ };
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/fmcomp/makefile.mk b/svx/source/fmcomp/makefile.mk
new file mode 100644
index 000000000000..aa4e9eaba186
--- /dev/null
+++ b/svx/source/fmcomp/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+TARGET=fmcomp
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=fmcomp
+SRC1FILES= \
+ gridctrl.src
+
+LIB1TARGET= $(SLB)$/$(TARGET)-core.lib
+LIB1OBJFILES= \
+ $(SLO)$/dbaexchange.obj \
+ $(SLO)$/gridcols.obj \
+ $(SLO)$/gridctrl.obj \
+ $(SLO)$/gridcell.obj \
+ $(SLO)$/fmgridcl.obj \
+ $(SLO)$/fmgridif.obj \
+ $(SLO)$/trace.obj \
+ $(SLO)$/xmlexchg.obj
+
+LIB2TARGET= $(SLB)$/$(TARGET).lib
+LIB2OBJFILES= \
+ $(SLO)$/dbaobjectex.obj
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/fmcomp/trace.cxx b/svx/source/fmcomp/trace.cxx
new file mode 100644
index 000000000000..b43aece3d844
--- /dev/null
+++ b/svx/source/fmcomp/trace.cxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "trace.hxx"
+#include <tools/debug.hxx>
+
+#if defined(DBG_UTIL)
+
+//==============================================================================
+
+//------------------------------------------------------------------------------
+::osl::Mutex Tracer::s_aMapSafety;
+::std::map< ::oslThreadIdentifier, INT32, ::std::less< oslThreadIdentifier > >
+ Tracer::s_aThreadIndents;
+
+//------------------------------------------------------------------------------
+Tracer::Tracer(const char* _pBlockDescription)
+ :m_sBlockDescription(_pBlockDescription)
+{
+ ::osl::MutexGuard aGuard(s_aMapSafety);
+ INT32 nIndent = s_aThreadIndents[ ::osl::Thread::getCurrentIdentifier() ]++;
+
+ ByteString sIndent;
+ while (nIndent--)
+ sIndent += '\t';
+
+ ByteString sThread( ByteString::CreateFromInt32( (INT32)::osl::Thread::getCurrentIdentifier() ) );
+ sThread += '\t';
+
+ ByteString sMessage(sThread);
+ sMessage += sIndent;
+ sMessage += m_sBlockDescription;
+ sMessage += " {";
+ DBG_TRACE(sMessage.GetBuffer());
+}
+
+//------------------------------------------------------------------------------
+Tracer::~Tracer()
+{
+ ::osl::MutexGuard aGuard(s_aMapSafety);
+ INT32 nIndent = --s_aThreadIndents[ ::osl::Thread::getCurrentIdentifier() ];
+
+ ByteString sIndent;
+ while (nIndent--)
+ sIndent += '\t';
+
+ ByteString sThread( ByteString::CreateFromInt32( (INT32)::osl::Thread::getCurrentIdentifier() ) );
+ sThread += '\t';
+
+ ByteString sMessage(sThread);
+ sMessage += sIndent;
+ sMessage += "} // ";
+ sMessage += m_sBlockDescription;
+ DBG_TRACE(sMessage.GetBuffer());
+}
+
+//------------------------------------------------------------------------------
+void Tracer::TraceString(const char* _pMessage)
+{
+ ::osl::MutexGuard aGuard(s_aMapSafety);
+ INT32 nIndent = s_aThreadIndents[ ::osl::Thread::getCurrentIdentifier() ];
+
+ ByteString sIndent;
+ while (nIndent--)
+ sIndent += '\t';
+
+ ByteString sThread( ByteString::CreateFromInt32( (INT32)::osl::Thread::getCurrentIdentifier() ) );
+ sThread += '\t';
+
+ ByteString sMessage(sThread);
+ sMessage += sIndent;
+ sMessage += m_sBlockDescription;
+ sMessage += ": ";
+ sMessage += _pMessage;
+ DBG_TRACE(sMessage.GetBuffer());
+}
+
+//------------------------------------------------------------------------------
+void Tracer::TraceString1StringParam(const char* _pMessage, const char* _pParam)
+{
+ ::osl::MutexGuard aGuard(s_aMapSafety);
+ INT32 nIndent = s_aThreadIndents[ ::osl::Thread::getCurrentIdentifier() ];
+
+ ByteString sIndent;
+ while (nIndent--)
+ sIndent += '\t';
+
+ ByteString sThread( ByteString::CreateFromInt32( (INT32)::osl::Thread::getCurrentIdentifier() ) );
+ sThread += '\t';
+
+ ByteString sMessage(sThread);
+ sMessage += sIndent;
+ sMessage += m_sBlockDescription;
+ sMessage += ": ";
+ sMessage += _pMessage;
+ DBG_TRACE1(sMessage.GetBuffer(), _pParam);
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/fmcomp/xmlexchg.cxx b/svx/source/fmcomp/xmlexchg.cxx
new file mode 100644
index 000000000000..c1d1bc43aa49
--- /dev/null
+++ b/svx/source/fmcomp/xmlexchg.cxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "xmlexchg.hxx"
+#include <sot/formats.hxx>
+#include <sot/exchange.hxx>
+#include <tools/debug.hxx>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ using namespace ::com::sun::star::datatransfer;
+
+ //====================================================================
+ //= OXFormsTransferable
+ //====================================================================
+ //--------------------------------------------------------------------
+ OXFormsTransferable::OXFormsTransferable( const OXFormsDescriptor &rhs ) :
+ m_aDescriptor(rhs)
+ {
+ }
+ //--------------------------------------------------------------------
+ sal_uInt32 OXFormsTransferable::getDescriptorFormatId()
+ {
+ static sal_uInt32 s_nFormat = (sal_uInt32)-1;
+ if ((sal_uInt32)-1 == s_nFormat)
+ {
+ s_nFormat = SotExchange::RegisterFormatName( String::CreateFromAscii("application/x-openoffice;windows_formatname=\"???\"") );
+ OSL_ENSURE( (sal_uInt32)-1 != s_nFormat, "OXFormsTransferable::getDescriptorFormatId: bad exchange id!" );
+ }
+ return s_nFormat;
+ }
+ //--------------------------------------------------------------------
+ void OXFormsTransferable::AddSupportedFormats()
+ {
+ AddFormat( SOT_FORMATSTR_ID_XFORMS );
+ }
+ //--------------------------------------------------------------------
+ sal_Bool OXFormsTransferable::GetData( const DataFlavor& _rFlavor )
+ {
+ const sal_uInt32 nFormatId = SotExchange::GetFormat( _rFlavor );
+ if ( SOT_FORMATSTR_ID_XFORMS == nFormatId )
+ {
+ return SetString( ::rtl::OUString( String::CreateFromAscii("XForms-Transferable") ), _rFlavor );
+ }
+ return sal_False;
+ }
+ //--------------------------------------------------------------------
+ const OXFormsDescriptor &OXFormsTransferable::extractDescriptor( const TransferableDataHelper &_rData ) {
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::datatransfer;
+ Reference<XTransferable> &transfer = const_cast<Reference<XTransferable> &>(_rData.GetTransferable());
+ XTransferable *pInterface = transfer.get();
+ OXFormsTransferable *pThis = dynamic_cast<OXFormsTransferable *>(pInterface);
+ DBG_ASSERT(pThis,"XTransferable is NOT an OXFormsTransferable???");
+ return pThis->m_aDescriptor;
+ }
+
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/ParseContext.cxx b/svx/source/form/ParseContext.cxx
new file mode 100644
index 000000000000..d49d9bb36b69
--- /dev/null
+++ b/svx/source/form/ParseContext.cxx
@@ -0,0 +1,252 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+#include "ParseContext.hxx"
+#include "stringlistresource.hxx"
+#include "fmresids.hrc"
+
+#include <svx/dialmgr.hxx>
+
+#include <unotools/syslocale.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/debug.hxx>
+#include <osl/mutex.hxx>
+
+using namespace svxform;
+using namespace ::connectivity;
+//==========================================================================
+//= OSystemParseContext
+//==========================================================================
+DBG_NAME(OSystemParseContext)
+//-----------------------------------------------------------------------------
+OSystemParseContext::OSystemParseContext() : IParseContext()
+{
+ DBG_CTOR(OSystemParseContext,NULL);
+ SolarMutexGuard aGuard;
+
+ ::svx::StringListResource aKeywords( SVX_RES( RID_RSC_SQL_INTERNATIONAL ) );
+ aKeywords.get( m_aLocalizedKeywords );
+}
+
+//-----------------------------------------------------------------------------
+OSystemParseContext::~OSystemParseContext()
+{
+ DBG_DTOR(OSystemParseContext,NULL);
+}
+
+//-----------------------------------------------------------------------------
+::com::sun::star::lang::Locale OSystemParseContext::getPreferredLocale( ) const
+{
+ return SvtSysLocale().GetLocaleData().getLocale();
+}
+
+//-----------------------------------------------------------------------------
+::rtl::OUString OSystemParseContext::getErrorMessage(ErrorCode _eCode) const
+{
+ String aMsg;
+ SolarMutexGuard aGuard;
+ switch (_eCode)
+ {
+ case ERROR_GENERAL: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_ERROR); break;
+ case ERROR_VALUE_NO_LIKE: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_VALUE_NO_LIKE); break;
+ case ERROR_FIELD_NO_LIKE: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_FIELD_NO_LIKE); break;
+ case ERROR_INVALID_COMPARE: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_CRIT_NO_COMPARE); break;
+ case ERROR_INVALID_INT_COMPARE: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_INT_NO_VALID); break;
+ case ERROR_INVALID_DATE_COMPARE: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_ACCESS_DAT_NO_VALID); break;
+ case ERROR_INVALID_REAL_COMPARE: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_REAL_NO_VALID); break;
+ case ERROR_INVALID_TABLE: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_TABLE); break;
+ case ERROR_INVALID_TABLE_OR_QUERY: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_TABLE_OR_QUERY); break;
+ case ERROR_INVALID_COLUMN: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_COLUMN); break;
+ case ERROR_INVALID_TABLE_EXIST: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_TABLE_EXISTS); break;
+ case ERROR_INVALID_QUERY_EXIST: aMsg = SVX_RES(RID_STR_SVT_SQL_SYNTAX_QUERY_EXISTS); break;
+ case ERROR_NONE: break;
+ }
+ return aMsg;
+}
+
+//-----------------------------------------------------------------------------
+::rtl::OString OSystemParseContext::getIntlKeywordAscii(InternationalKeyCode _eKey) const
+{
+ size_t nIndex = 0;
+ switch ( _eKey )
+ {
+ case KEY_LIKE: nIndex = 0; break;
+ case KEY_NOT: nIndex = 1; break;
+ case KEY_NULL: nIndex = 2; break;
+ case KEY_TRUE: nIndex = 3; break;
+ case KEY_FALSE: nIndex = 4; break;
+ case KEY_IS: nIndex = 5; break;
+ case KEY_BETWEEN: nIndex = 6; break;
+ case KEY_OR: nIndex = 7; break;
+ case KEY_AND: nIndex = 8; break;
+ case KEY_AVG: nIndex = 9; break;
+ case KEY_COUNT: nIndex = 10; break;
+ case KEY_MAX: nIndex = 11; break;
+ case KEY_MIN: nIndex = 12; break;
+ case KEY_SUM: nIndex = 13; break;
+ case KEY_EVERY: nIndex = 14; break;
+ case KEY_ANY: nIndex = 15; break;
+ case KEY_SOME: nIndex = 16; break;
+ case KEY_STDDEV_POP: nIndex = 17; break;
+ case KEY_STDDEV_SAMP: nIndex = 18; break;
+ case KEY_VAR_SAMP: nIndex = 19; break;
+ case KEY_VAR_POP: nIndex = 20; break;
+ case KEY_COLLECT: nIndex = 21; break;
+ case KEY_FUSION: nIndex = 22; break;
+ case KEY_INTERSECTION: nIndex = 23; break;
+ case KEY_NONE:
+ DBG_ERROR( "OSystemParseContext::getIntlKeywordAscii: illegal argument!" );
+ break;
+ }
+
+ OSL_ENSURE( nIndex < m_aLocalizedKeywords.size(), "OSystemParseContext::getIntlKeywordAscii: invalid index!" );
+
+ ByteString sKeyword;
+ if ( nIndex < m_aLocalizedKeywords.size() )
+ sKeyword = ByteString( m_aLocalizedKeywords[nIndex], RTL_TEXTENCODING_UTF8 );
+ return sKeyword;
+}
+
+//-----------------------------------------------------------------------------
+static sal_Unicode lcl_getSeparatorChar( const String& _rSeparator, sal_Unicode _nFallback )
+{
+ DBG_ASSERT( 0 < _rSeparator.Len(), "::lcl_getSeparatorChar: invalid decimal separator!" );
+
+ sal_Unicode nReturn( _nFallback );
+ if ( _rSeparator.Len() )
+ nReturn = static_cast< sal_Char >( _rSeparator.GetBuffer( )[0] );
+ return nReturn;
+}
+
+//-----------------------------------------------------------------------------
+sal_Unicode OSystemParseContext::getNumDecimalSep( ) const
+{
+ return lcl_getSeparatorChar( SvtSysLocale().GetLocaleData().getNumDecimalSep(), '.' );
+}
+
+//-----------------------------------------------------------------------------
+sal_Unicode OSystemParseContext::getNumThousandSep( ) const
+{
+ return lcl_getSeparatorChar( SvtSysLocale().GetLocaleData().getNumThousandSep(), ',' );
+}
+// -----------------------------------------------------------------------------
+IParseContext::InternationalKeyCode OSystemParseContext::getIntlKeyCode(const ::rtl::OString& rToken) const
+{
+ static IParseContext::InternationalKeyCode Intl_TokenID[] =
+ {
+ KEY_LIKE, KEY_NOT, KEY_NULL, KEY_TRUE,
+ KEY_FALSE, KEY_IS, KEY_BETWEEN, KEY_OR,
+ KEY_AND, KEY_AVG, KEY_COUNT, KEY_MAX,
+ KEY_MIN, KEY_SUM, KEY_EVERY,
+ KEY_ANY, KEY_SOME, KEY_STDDEV_POP,
+ KEY_STDDEV_SAMP, KEY_VAR_SAMP, KEY_VAR_POP,
+ KEY_COLLECT, KEY_FUSION, KEY_INTERSECTION
+ };
+
+ sal_uInt32 nCount = SAL_N_ELEMENTS( Intl_TokenID );
+ for (sal_uInt32 i = 0; i < nCount; i++)
+ {
+ ::rtl::OString aKey = getIntlKeywordAscii(Intl_TokenID[i]);
+ if (rToken.equalsIgnoreAsciiCase(aKey))
+ return Intl_TokenID[i];
+ }
+
+ return KEY_NONE;
+}
+
+
+// =============================================================================
+// =============================================================================
+namespace
+{
+ // -----------------------------------------------------------------------------
+ ::osl::Mutex& getSafteyMutex()
+ {
+ static ::osl::Mutex s_aSafety;
+ return s_aSafety;
+ }
+ // -----------------------------------------------------------------------------
+ oslInterlockedCount& getCounter()
+ {
+ static oslInterlockedCount s_nCounter;
+ return s_nCounter;
+ }
+ // -----------------------------------------------------------------------------
+ OSystemParseContext* getSharedContext(OSystemParseContext* _pContext = NULL,sal_Bool _bSet = sal_False)
+ {
+ static OSystemParseContext* s_pSharedContext = NULL;
+ if ( _pContext && !s_pSharedContext )
+ {
+ s_pSharedContext = _pContext;
+ return s_pSharedContext;
+ }
+ if ( _bSet )
+ {
+ OSystemParseContext* pReturn = _pContext ? _pContext : s_pSharedContext;
+ s_pSharedContext = _pContext;
+ return pReturn;
+ }
+ return s_pSharedContext;
+ }
+ // -----------------------------------------------------------------------------
+}
+// -----------------------------------------------------------------------------
+OParseContextClient::OParseContextClient()
+{
+ ::osl::MutexGuard aGuard( getSafteyMutex() );
+ if ( 1 == osl_incrementInterlockedCount( &getCounter() ) )
+ { // first instance
+ getSharedContext( new OSystemParseContext );
+ }
+}
+
+// -----------------------------------------------------------------------------
+OParseContextClient::~OParseContextClient()
+{
+ {
+ ::osl::MutexGuard aGuard( getSafteyMutex() );
+ if ( 0 == osl_decrementInterlockedCount( &getCounter() ) )
+ delete getSharedContext(NULL,sal_True);
+ }
+}
+// -----------------------------------------------------------------------------
+const OSystemParseContext* OParseContextClient::getParseContext() const
+{
+ return getSharedContext();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/dataaccessdescriptor.cxx b/svx/source/form/dataaccessdescriptor.cxx
new file mode 100644
index 000000000000..5b75dbe2f3bd
--- /dev/null
+++ b/svx/source/form/dataaccessdescriptor.cxx
@@ -0,0 +1,569 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/dataaccessdescriptor.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/propertysetinfo.hxx>
+#include <comphelper/genericpropertyset.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <tools/urlobj.hxx>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::comphelper;
+
+#define CONST_CHAR( propname ) propname, sizeof(propname) - 1
+
+#ifndef SVX_LIGHT
+ //====================================================================
+ //= ODADescriptorImpl
+ //====================================================================
+ class ODADescriptorImpl
+ {
+ protected:
+ sal_Bool m_bSetOutOfDate : 1;
+ sal_Bool m_bSequenceOutOfDate : 1;
+
+ public:
+ typedef ::std::map< DataAccessDescriptorProperty, Any > DescriptorValues;
+ DescriptorValues m_aValues;
+ Sequence< PropertyValue > m_aAsSequence;
+ Reference< XPropertySet > m_xAsSet;
+
+ typedef ::std::map< ::rtl::OUString, PropertyMapEntry* > MapString2PropertyEntry;
+
+ public:
+ ODADescriptorImpl();
+ ODADescriptorImpl(const ODADescriptorImpl& _rSource);
+
+ void invalidateExternRepresentations();
+
+ void updateSequence();
+ void updateSet();
+
+ /** builds the descriptor from a property value sequence
+ @return <TRUE/>
+ if and only if the sequence contained valid properties only
+ */
+ sal_Bool buildFrom( const Sequence< PropertyValue >& _rValues );
+
+ /** builds the descriptor from a property set
+ @return <TRUE/>
+ if and only if the set contained valid properties only
+ */
+ sal_Bool buildFrom( const Reference< XPropertySet >& _rValues );
+
+ protected:
+ static PropertyValue buildPropertyValue( const DescriptorValues::const_iterator& _rPos );
+ static const MapString2PropertyEntry& getPropertyMap( );
+ static PropertyMapEntry* getPropertyMapEntry( const DescriptorValues::const_iterator& _rPos );
+ };
+
+ //--------------------------------------------------------------------
+ ODADescriptorImpl::ODADescriptorImpl()
+ :m_bSetOutOfDate(sal_True)
+ ,m_bSequenceOutOfDate(sal_True)
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ODADescriptorImpl::ODADescriptorImpl(const ODADescriptorImpl& _rSource)
+ :m_bSetOutOfDate( _rSource.m_bSetOutOfDate )
+ ,m_bSequenceOutOfDate( _rSource.m_bSequenceOutOfDate )
+ ,m_aValues( _rSource.m_aValues )
+ {
+ if (!m_bSetOutOfDate)
+ m_xAsSet = _rSource.m_xAsSet;
+ if (!m_bSequenceOutOfDate)
+ m_aAsSequence = _rSource.m_aAsSequence;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool ODADescriptorImpl::buildFrom( const Sequence< PropertyValue >& _rValues )
+ {
+ const MapString2PropertyEntry& rProperties = getPropertyMap();
+
+ sal_Bool bValidPropsOnly = sal_True;
+
+ // loop through the sequence, and fill our m_aValues
+ const PropertyValue* pValues = _rValues.getConstArray();
+ const PropertyValue* pValuesEnd = pValues + _rValues.getLength();
+ for (;pValues != pValuesEnd; ++pValues)
+ {
+ MapString2PropertyEntry::const_iterator aPropPos = rProperties.find( pValues->Name );
+ if ( aPropPos != rProperties.end() )
+ {
+ DataAccessDescriptorProperty eProperty = (DataAccessDescriptorProperty)aPropPos->second->mnHandle;
+ m_aValues[eProperty] = pValues->Value;
+ }
+ else
+ // unknown property
+ bValidPropsOnly = sal_False;
+ }
+
+ if (bValidPropsOnly)
+ {
+ m_aAsSequence = _rValues;
+ m_bSequenceOutOfDate = sal_False;
+ }
+ else
+ m_bSequenceOutOfDate = sal_True;
+
+ return bValidPropsOnly;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool ODADescriptorImpl::buildFrom( const Reference< XPropertySet >& _rxValues )
+ {
+ Reference< XPropertySetInfo > xPropInfo;
+ if (_rxValues.is())
+ xPropInfo = _rxValues->getPropertySetInfo();
+ if (!xPropInfo.is())
+ {
+ OSL_ENSURE(sal_False, "ODADescriptorImpl::buildFrom: invalid property set!");
+ return sal_False;
+ }
+
+ // build a PropertyValue sequence with the current values
+ Sequence< Property > aProperties = xPropInfo->getProperties();
+ const Property* pProperty = aProperties.getConstArray();
+ const Property* pPropertyEnd = pProperty + aProperties.getLength();
+
+ Sequence< PropertyValue > aValues(aProperties.getLength());
+ PropertyValue* pValues = aValues.getArray();
+
+ for (;pProperty != pPropertyEnd; ++pProperty, ++pValues)
+ {
+ pValues->Name = pProperty->Name;
+ pValues->Value = _rxValues->getPropertyValue(pProperty->Name);
+ }
+
+ sal_Bool bValidPropsOnly = buildFrom(aValues);
+ if (bValidPropsOnly)
+ {
+ m_xAsSet = _rxValues;
+ m_bSetOutOfDate = sal_False;
+ }
+ else
+ m_bSetOutOfDate = sal_True;
+
+ return bValidPropsOnly;
+ }
+
+ //--------------------------------------------------------------------
+ void ODADescriptorImpl::invalidateExternRepresentations()
+ {
+ m_bSetOutOfDate = sal_True;
+ m_bSequenceOutOfDate = sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ const ODADescriptorImpl::MapString2PropertyEntry& ODADescriptorImpl::getPropertyMap( )
+ {
+ // the properties we know
+ static MapString2PropertyEntry s_aProperties;
+ if ( s_aProperties.empty() )
+ {
+ static PropertyMapEntry s_aDesriptorProperties[] =
+ {
+ { CONST_CHAR("ActiveConnection"), daConnection, &::getCppuType( static_cast< Reference< XConnection >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("BookmarkSelection"), daBookmarkSelection, &::getBooleanCppuType( ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("Column"), daColumnObject, &::getCppuType( static_cast< Reference< XPropertySet >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("ColumnName"), daColumnName, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("Command"), daCommand, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("CommandType"), daCommandType, &::getCppuType( static_cast< sal_Int32* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("Component"), daComponent, &::getCppuType( static_cast< Reference< XContent >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("ConnectionResource"), daConnectionResource, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("Cursor"), daCursor, &::getCppuType( static_cast< Reference< XResultSet>* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("DataSourceName"), daDataSource, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("DatabaseLocation"), daDatabaseLocation, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("EscapeProcessing"), daEscapeProcessing, &::getBooleanCppuType( ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("Filter"), daFilter, &::getCppuType( static_cast< ::rtl::OUString* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { CONST_CHAR("Selection"), daSelection, &::getCppuType( static_cast< Sequence< Any >* >(NULL) ), PropertyAttribute::TRANSIENT, 0 },
+ { NULL, 0, 0, NULL, 0, 0 }
+ };
+
+ PropertyMapEntry* pEntry = s_aDesriptorProperties;
+ while ( pEntry->mpName )
+ {
+ s_aProperties[ ::rtl::OUString::createFromAscii( pEntry->mpName ) ] = pEntry;
+ ++pEntry;
+ }
+ }
+
+ return s_aProperties;
+ }
+
+ //--------------------------------------------------------------------
+ PropertyMapEntry* ODADescriptorImpl::getPropertyMapEntry( const DescriptorValues::const_iterator& _rPos )
+ {
+ const MapString2PropertyEntry& rProperties = getPropertyMap();
+
+ sal_Int32 nNeededHandle = (sal_Int32)(_rPos->first);
+
+ for ( MapString2PropertyEntry::const_iterator loop = rProperties.begin();
+ loop != rProperties.end();
+ ++loop
+ )
+ {
+ if ( nNeededHandle == loop->second->mnHandle )
+ return loop->second;
+ }
+ throw RuntimeException();
+ }
+
+ //--------------------------------------------------------------------
+ PropertyValue ODADescriptorImpl::buildPropertyValue( const DescriptorValues::const_iterator& _rPos )
+ {
+ // the map entry
+ PropertyMapEntry* pProperty = getPropertyMapEntry( _rPos );
+
+ // build the property value
+ PropertyValue aReturn;
+ aReturn.Name = ::rtl::OUString( pProperty->mpName, pProperty->mnNameLen, RTL_TEXTENCODING_ASCII_US );
+ aReturn.Handle = pProperty->mnHandle;
+ aReturn.Value = _rPos->second;
+ aReturn.State = PropertyState_DIRECT_VALUE;
+
+ // outta here
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void ODADescriptorImpl::updateSequence()
+ {
+ if (!m_bSequenceOutOfDate)
+ return;
+
+ m_aAsSequence.realloc(m_aValues.size());
+ PropertyValue* pValue = m_aAsSequence.getArray();
+
+ // loop through all our values
+ for ( DescriptorValues::const_iterator aLoop = m_aValues.begin();
+ aLoop != m_aValues.end();
+ ++aLoop, ++pValue
+ )
+ {
+ *pValue = buildPropertyValue(aLoop);
+ }
+
+ // don't need to rebuild next time
+ m_bSequenceOutOfDate = sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ void ODADescriptorImpl::updateSet()
+ {
+ if (!m_bSetOutOfDate)
+ return;
+
+ // will be the current values
+ Sequence< PropertyValue > aValuesToSet(m_aValues.size());
+ PropertyValue* pValuesToSet = aValuesToSet.getArray();
+
+ // build a new property set info
+ PropertySetInfo* pPropSetInfo = new PropertySetInfo;
+
+ // loop through all our values
+ for ( DescriptorValues::const_iterator aLoop = m_aValues.begin();
+ aLoop != m_aValues.end();
+ ++aLoop, ++pValuesToSet
+ )
+ {
+ PropertyMapEntry* pMapEntry = getPropertyMapEntry( aLoop );
+ pPropSetInfo->add( pMapEntry, 1 );
+
+ *pValuesToSet = buildPropertyValue(aLoop);
+ }
+
+ // create the generic set
+ m_xAsSet = GenericPropertySet_CreateInstance( pPropSetInfo );
+
+ // no we have the set, still need to set the current values
+ const PropertyValue* pSetValues = aValuesToSet.getConstArray();
+ const PropertyValue* pSetValuesEnd = pSetValues + aValuesToSet.getLength();
+ for (; pSetValues != pSetValuesEnd; ++pSetValues)
+ m_xAsSet->setPropertyValue(pSetValues->Name, pSetValues->Value);
+
+ // don't need to rebuild next time
+ m_bSetOutOfDate = sal_True;
+ }
+#endif
+
+ //====================================================================
+ //= ODataAccessDescriptor
+ //====================================================================
+ //--------------------------------------------------------------------
+ ODataAccessDescriptor::ODataAccessDescriptor()
+#ifndef SVX_LIGHT
+ :m_pImpl(new ODADescriptorImpl)
+#else
+ :m_pImpl(NULL)
+#endif
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ODataAccessDescriptor::ODataAccessDescriptor( const ODataAccessDescriptor& _rSource )
+#ifndef SVX_LIGHT
+ :m_pImpl(new ODADescriptorImpl(*_rSource.m_pImpl))
+#else
+ :m_pImpl(NULL)
+#endif
+ {
+ }
+
+ //--------------------------------------------------------------------
+ const ODataAccessDescriptor& ODataAccessDescriptor::operator=(const ODataAccessDescriptor& _rSource)
+ {
+#ifndef SVX_LIGHT
+ delete m_pImpl;
+ m_pImpl = new ODADescriptorImpl(*_rSource.m_pImpl);
+#else
+ OSL_ENSURE(sal_False, "ODataAccessDescriptor::operator=: not available in the SVX_LIGHT version!");
+#endif
+ return *this;
+ }
+
+ //--------------------------------------------------------------------
+ ODataAccessDescriptor::ODataAccessDescriptor( const Reference< XPropertySet >& _rValues )
+#ifndef SVX_LIGHT
+ :m_pImpl(new ODADescriptorImpl)
+#else
+ :m_pImpl(NULL)
+#endif
+ {
+#ifndef SVX_LIGHT
+ m_pImpl->buildFrom(_rValues);
+#else
+ OSL_ENSURE(sal_False, "ODataAccessDescriptor::ODataAccessDescriptor: not available in the SVX_LIGHT version!");
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ ODataAccessDescriptor::ODataAccessDescriptor( const Any& _rValues )
+#ifndef SVX_LIGHT
+ :m_pImpl(new ODADescriptorImpl)
+#else
+ :m_pImpl(NULL)
+#endif
+ {
+#ifndef SVX_LIGHT
+ // check if we know the format in the Any
+ Sequence< PropertyValue > aValues;
+ Reference< XPropertySet > xValues;
+ if ( _rValues >>= aValues )
+ m_pImpl->buildFrom( aValues );
+ else if ( _rValues >>= xValues )
+ m_pImpl->buildFrom( xValues );
+#else
+ OSL_ENSURE(sal_False, "ODataAccessDescriptor::ODataAccessDescriptor: not available in the SVX_LIGHT version!");
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ ODataAccessDescriptor::ODataAccessDescriptor( const Sequence< PropertyValue >& _rValues )
+#ifndef SVX_LIGHT
+ :m_pImpl(new ODADescriptorImpl)
+#else
+ :m_pImpl(NULL)
+#endif
+ {
+#ifndef SVX_LIGHT
+ m_pImpl->buildFrom(_rValues);
+#else
+ OSL_ENSURE(sal_False, "ODataAccessDescriptor::ODataAccessDescriptor: not available in the SVX_LIGHT version!");
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ ODataAccessDescriptor::~ODataAccessDescriptor()
+ {
+ delete m_pImpl;
+ }
+
+ //--------------------------------------------------------------------
+ void ODataAccessDescriptor::clear()
+ {
+#ifndef SVX_LIGHT
+ m_pImpl->m_aValues.clear();
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ void ODataAccessDescriptor::erase(DataAccessDescriptorProperty _eWhich)
+ {
+#ifndef SVX_LIGHT
+ OSL_ENSURE(has(_eWhich), "ODataAccessDescriptor::erase: invalid call!");
+ if (has(_eWhich))
+ m_pImpl->m_aValues.erase(_eWhich);
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool ODataAccessDescriptor::has(DataAccessDescriptorProperty _eWhich) const
+ {
+#ifndef SVX_LIGHT
+ return m_pImpl->m_aValues.find(_eWhich) != m_pImpl->m_aValues.end();
+#else
+ return sal_False;
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ const Any& ODataAccessDescriptor::operator [] ( DataAccessDescriptorProperty _eWhich ) const
+ {
+#ifndef SVX_LIGHT
+ if (!has(_eWhich))
+ {
+ OSL_ENSURE(sal_False, "ODataAccessDescriptor::operator[]: invalid acessor!");
+ static const Any aDummy;
+ return aDummy;
+ }
+
+ return m_pImpl->m_aValues[_eWhich];
+#else
+ static const Any aDummy;
+ return aDummy;
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ Any& ODataAccessDescriptor::operator[] ( DataAccessDescriptorProperty _eWhich )
+ {
+#ifndef SVX_LIGHT
+ m_pImpl->invalidateExternRepresentations();
+ return m_pImpl->m_aValues[_eWhich];
+#else
+ static const Any aDummy;
+ return aDummy;
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ void ODataAccessDescriptor::initializeFrom(const Reference< XPropertySet >& _rxValues, sal_Bool _bClear)
+ {
+#ifndef SVX_LIGHT
+ if (_bClear)
+ clear();
+ m_pImpl->buildFrom(_rxValues);
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ void ODataAccessDescriptor::initializeFrom(const Sequence< PropertyValue >& _rValues, sal_Bool _bClear)
+ {
+#ifndef SVX_LIGHT
+ if (_bClear)
+ clear();
+ m_pImpl->buildFrom(_rValues);
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< PropertyValue > ODataAccessDescriptor::createPropertyValueSequence()
+ {
+#ifndef SVX_LIGHT
+ m_pImpl->updateSequence();
+ return m_pImpl->m_aAsSequence;
+#else
+ return Sequence< PropertyValue >();
+#endif
+ }
+ //--------------------------------------------------------------------
+ Sequence< Any > ODataAccessDescriptor::createAnySequence()
+ {
+#ifndef SVX_LIGHT
+ m_pImpl->updateSequence();
+ Sequence< Any > aRet(m_pImpl->m_aAsSequence.getLength());
+ const PropertyValue* pBegin = m_pImpl->m_aAsSequence.getConstArray();
+ const PropertyValue* pEnd = pBegin + m_pImpl->m_aAsSequence.getLength();
+ for(sal_Int32 i=0;pBegin != pEnd;++pBegin,++i)
+ aRet[i] <<= *pBegin;
+ return aRet;
+#else
+ return Sequence< createAnySequence >();
+#endif
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > ODataAccessDescriptor::createPropertySet()
+ {
+#ifndef SVX_LIGHT
+ m_pImpl->updateSet();
+ return m_pImpl->m_xAsSet;
+#else
+ return Reference< XPropertySet >();
+#endif
+ }
+ //--------------------------------------------------------------------
+ ::rtl::OUString ODataAccessDescriptor::getDataSource() const
+ {
+#ifndef SVX_LIGHT
+ ::rtl::OUString sDataSourceName;
+ if ( has(daDataSource) )
+ (*this)[daDataSource] >>= sDataSourceName;
+ else if ( has(daDatabaseLocation) )
+ (*this)[daDatabaseLocation] >>= sDataSourceName;
+ return sDataSourceName;
+#else
+ return ::rtl::OUString();
+#endif
+ }
+ //--------------------------------------------------------------------
+ void ODataAccessDescriptor::setDataSource(const ::rtl::OUString& _sDataSourceNameOrLocation)
+ {
+#ifndef SVX_LIGHT
+ if ( _sDataSourceNameOrLocation.getLength() )
+ {
+ INetURLObject aURL(_sDataSourceNameOrLocation);
+ (*this)[ (( aURL.GetProtocol() == INET_PROT_FILE ) ? daDatabaseLocation : daDataSource)] <<= _sDataSourceNameOrLocation;
+ }
+ else
+ (*this)[ daDataSource ] <<= ::rtl::OUString();
+#endif
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/databaselocationinput.cxx b/svx/source/form/databaselocationinput.cxx
new file mode 100644
index 000000000000..ce6842e9b889
--- /dev/null
+++ b/svx/source/form/databaselocationinput.cxx
@@ -0,0 +1,317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svx/databaselocationinput.hxx"
+#include "svx/dialmgr.hxx"
+
+#include "fmresids.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <svtools/urlcontrol.hxx>
+#include <svl/filenotation.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/confignode.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <vcl/button.hxx>
+#include <vcl/msgbox.hxx>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Exception;
+ /** === end UNO using === **/
+ namespace TemplateDescription = ::com::sun::star::ui::dialogs::TemplateDescription;
+
+ //====================================================================
+ //= DatabaseLocationInputController_Impl
+ //====================================================================
+ class DatabaseLocationInputController_Impl
+ {
+ public:
+ DatabaseLocationInputController_Impl(
+ const ::comphelper::ComponentContext& _rContext,
+ ::svt::OFileURLControl& _rLocationInput,
+ PushButton& _rBrowseButton
+ );
+ ~DatabaseLocationInputController_Impl();
+
+ bool prepareCommit();
+ void setURL( const String& _rURL );
+ String getURL() const;
+
+ private:
+ void impl_initFilterProperties_nothrow();
+ void impl_onBrowseButtonClicked();
+ void impl_onLocationModified();
+ String impl_getCurrentURL() const;
+
+ DECL_LINK( OnControlAction, VclWindowEvent* );
+
+ private:
+ const ::comphelper::ComponentContext m_aContext;
+ ::svt::OFileURLControl& m_rLocationInput;
+ PushButton& m_rBrowseButton;
+ Sequence< ::rtl::OUString > m_aFilterExtensions;
+ ::rtl::OUString m_sFilterUIName;
+ bool m_bNeedExistenceCheck;
+ };
+
+ //--------------------------------------------------------------------
+ DatabaseLocationInputController_Impl::DatabaseLocationInputController_Impl( const ::comphelper::ComponentContext& _rContext,
+ ::svt::OFileURLControl& _rLocationInput, PushButton& _rBrowseButton )
+ :m_aContext( _rContext )
+ ,m_rLocationInput( _rLocationInput )
+ ,m_rBrowseButton( _rBrowseButton )
+ ,m_aFilterExtensions()
+ ,m_sFilterUIName()
+ ,m_bNeedExistenceCheck( true )
+ {
+ impl_initFilterProperties_nothrow();
+
+ // forward the allowed extensions to the input control
+ ::rtl::OUStringBuffer aExtensionList;
+ for ( const ::rtl::OUString* pExtension = m_aFilterExtensions.getConstArray();
+ pExtension != m_aFilterExtensions.getConstArray() + m_aFilterExtensions.getLength();
+ ++pExtension
+ )
+ {
+ aExtensionList.append( *pExtension );
+ aExtensionList.append( (sal_Unicode)';' );
+ }
+ m_rLocationInput.SetFilter( aExtensionList.makeStringAndClear() );
+
+ m_rBrowseButton.AddEventListener( LINK( this, DatabaseLocationInputController_Impl, OnControlAction ) );
+ m_rLocationInput.AddEventListener( LINK( this, DatabaseLocationInputController_Impl, OnControlAction ) );
+ }
+
+ //--------------------------------------------------------------------
+ DatabaseLocationInputController_Impl::~DatabaseLocationInputController_Impl()
+ {
+ m_rBrowseButton.RemoveEventListener( LINK( this, DatabaseLocationInputController_Impl, OnControlAction ) );
+ m_rLocationInput.RemoveEventListener( LINK( this, DatabaseLocationInputController_Impl, OnControlAction ) );
+ }
+
+ //--------------------------------------------------------------------
+ bool DatabaseLocationInputController_Impl::prepareCommit()
+ {
+ ::rtl::OUString sURL( impl_getCurrentURL() );
+ if ( !sURL.getLength() )
+ return false;
+
+ // check if the name exists
+ if ( m_bNeedExistenceCheck )
+ {
+ if ( ::utl::UCBContentHelper::Exists( sURL ) )
+ {
+ QueryBox aBox( m_rLocationInput.GetSystemWindow(), WB_YES_NO, SVX_RES( RID_STR_ALREADYEXISTOVERWRITE ) );
+ if ( aBox.Execute() != RET_YES )
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ void DatabaseLocationInputController_Impl::setURL( const String& _rURL )
+ {
+ ::svt::OFileNotation aTransformer( _rURL );
+ m_rLocationInput.SetText( aTransformer.get( ::svt::OFileNotation::N_SYSTEM ) );
+ }
+
+ //--------------------------------------------------------------------
+ String DatabaseLocationInputController_Impl::getURL() const
+ {
+ return impl_getCurrentURL();
+ }
+
+ //--------------------------------------------------------------------
+ void DatabaseLocationInputController_Impl::impl_initFilterProperties_nothrow()
+ {
+ try
+ {
+ // get the name of the default filter for database documents
+ ::utl::OConfigurationTreeRoot aConfig(
+ ::utl::OConfigurationTreeRoot::createWithServiceFactory(
+ m_aContext.getLegacyServiceFactory(),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Setup/Office/Factories/com.sun.star.sdb.OfficeDatabaseDocument" ) )
+ ) );
+ ::rtl::OUString sDatabaseFilter;
+ OSL_VERIFY( aConfig.getNodeValue( "ooSetupFactoryActualFilter" ) >>= sDatabaseFilter );
+
+ // get the type this filter is responsible for
+ Reference< XNameAccess > xFilterFactory(
+ m_aContext.createComponent( "com.sun.star.document.FilterFactory" ),
+ UNO_QUERY_THROW );
+ ::comphelper::NamedValueCollection aFilterProperties( xFilterFactory->getByName( sDatabaseFilter ) );
+ ::rtl::OUString sDocumentType = aFilterProperties.getOrDefault( "Type", ::rtl::OUString() );
+
+ // get the extension(s) for this type
+ Reference< XNameAccess > xTypeDetection(
+ m_aContext.createComponent( "com.sun.star.document.TypeDetection" ),
+ UNO_QUERY_THROW );
+
+ ::comphelper::NamedValueCollection aTypeProperties( xTypeDetection->getByName( sDocumentType ) );
+ m_aFilterExtensions = aTypeProperties.getOrDefault( "Extensions", m_aFilterExtensions );
+ m_sFilterUIName = aTypeProperties.getOrDefault( "UIName", m_sFilterUIName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // ensure we have at least one extension
+ OSL_ENSURE( m_aFilterExtensions.getLength(),
+ "DatabaseLocationInputController_Impl::impl_initFilterProperties_nothrow: unable to determine the file extension(s)!" );
+ if ( m_aFilterExtensions.getLength() == 0 )
+ {
+ m_aFilterExtensions.realloc(1);
+ m_aFilterExtensions[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "*.odb" ) );
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ IMPL_LINK( DatabaseLocationInputController_Impl, OnControlAction, VclWindowEvent*, _pEvent )
+ {
+ if ( ( _pEvent->GetWindow() == &m_rBrowseButton )
+ && ( _pEvent->GetId() == VCLEVENT_BUTTON_CLICK )
+ )
+ {
+ impl_onBrowseButtonClicked();
+ }
+
+ if ( ( _pEvent->GetWindow() == &m_rLocationInput )
+ && ( _pEvent->GetId() == VCLEVENT_EDIT_MODIFY )
+ )
+ {
+ impl_onLocationModified();
+ }
+
+ return 0L;
+ }
+
+ // -----------------------------------------------------------------------------
+ String DatabaseLocationInputController_Impl::impl_getCurrentURL() const
+ {
+ String sCurrentFile( m_rLocationInput.GetText() );
+ if ( sCurrentFile.Len() )
+ {
+ ::svt::OFileNotation aCurrentFile( sCurrentFile );
+ sCurrentFile = aCurrentFile.get( ::svt::OFileNotation::N_URL );
+ }
+ return sCurrentFile;
+ }
+
+ // -----------------------------------------------------------------------------
+ void DatabaseLocationInputController_Impl::impl_onBrowseButtonClicked()
+ {
+ ::sfx2::FileDialogHelper aFileDlg(
+ TemplateDescription::FILESAVE_AUTOEXTENSION,
+ WB_STDMODAL | WB_SAVEAS,
+ m_rLocationInput.GetSystemWindow()
+ );
+ aFileDlg.SetDisplayDirectory( impl_getCurrentURL() );
+
+ aFileDlg.AddFilter( m_sFilterUIName, ::rtl::OUStringBuffer().appendAscii( "*." ).append( m_aFilterExtensions[0] ).makeStringAndClear() );
+ aFileDlg.SetCurrentFilter( m_sFilterUIName );
+
+ if ( aFileDlg.Execute() == ERRCODE_NONE )
+ {
+ INetURLObject aURL( aFileDlg.GetPath() );
+ if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ ::svt::OFileNotation aFileNotation( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+ m_rLocationInput.SetText( aFileNotation.get( ::svt::OFileNotation::N_SYSTEM ) );
+ m_rLocationInput.GetModifyHdl().Call( &m_rLocationInput );
+ // the dialog already checked for the file's existence, so we don't need to, again
+ m_bNeedExistenceCheck = false;
+ }
+ }
+ }
+
+ // -----------------------------------------------------------------------------
+ void DatabaseLocationInputController_Impl::impl_onLocationModified()
+ {
+ m_bNeedExistenceCheck = true;
+ }
+
+ //====================================================================
+ //= DatabaseLocationInputController
+ //====================================================================
+ //--------------------------------------------------------------------
+ DatabaseLocationInputController::DatabaseLocationInputController( const ::comphelper::ComponentContext& _rContext,
+ ::svt::OFileURLControl& _rLocationInput, PushButton& _rBrowseButton )
+ :m_pImpl( new DatabaseLocationInputController_Impl( _rContext, _rLocationInput, _rBrowseButton ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DatabaseLocationInputController::~DatabaseLocationInputController()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool DatabaseLocationInputController::prepareCommit()
+ {
+ return m_pImpl->prepareCommit();
+ }
+
+ //--------------------------------------------------------------------
+ void DatabaseLocationInputController::setURL( const String& _rURL )
+ {
+ m_pImpl->setURL( _rURL );
+ }
+
+ //--------------------------------------------------------------------
+ String DatabaseLocationInputController::getURL() const
+ {
+ return m_pImpl->getURL();
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/datalistener.cxx b/svx/source/form/datalistener.cxx
new file mode 100644
index 000000000000..7488ea83c8e1
--- /dev/null
+++ b/svx/source/form/datalistener.cxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "datalistener.hxx"
+#include "datanavi.hxx"
+
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::dom::events;
+
+//............................................................................
+namespace svxform
+{
+//............................................................................
+
+ DataListener::DataListener( DataNavigatorWindow* pNaviWin ) :
+
+ m_pNaviWin( pNaviWin )
+
+ {
+ DBG_ASSERT( m_pNaviWin, "DataListener::Ctor(): no navigator win" );
+ }
+
+ DataListener::~DataListener()
+ {
+ }
+
+ // XContainerListener
+ void SAL_CALL DataListener::elementInserted( const ContainerEvent& /*Event*/ ) throw (RuntimeException)
+ {
+ m_pNaviWin->NotifyChanges();
+ }
+
+ void SAL_CALL DataListener::elementRemoved( const ContainerEvent& /*Event*/ ) throw (RuntimeException)
+ {
+ m_pNaviWin->NotifyChanges();
+ }
+
+ void SAL_CALL DataListener::elementReplaced( const ContainerEvent& /*Event*/ ) throw (RuntimeException)
+ {
+ m_pNaviWin->NotifyChanges();
+ }
+
+ // XFrameActionListener
+ void SAL_CALL DataListener::frameAction( const FrameActionEvent& rActionEvt ) throw (RuntimeException)
+ {
+ if ( FrameAction_COMPONENT_ATTACHED == rActionEvt.Action ||
+ FrameAction_COMPONENT_REATTACHED == rActionEvt.Action )
+ {
+ m_pNaviWin->NotifyChanges( FrameAction_COMPONENT_REATTACHED == rActionEvt.Action );
+ }
+ }
+
+ // xml::dom::events::XEventListener
+ void SAL_CALL DataListener::handleEvent( const Reference< XEvent >& /*evt*/ ) throw (RuntimeException)
+ {
+ m_pNaviWin->NotifyChanges();
+ }
+
+ // lang::XEventListener
+ void SAL_CALL DataListener::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
+ {
+ DBG_ERRORFILE( "disposing" );
+ }
+
+//............................................................................
+} // namespace svxform
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/datanavi.cxx b/svx/source/form/datanavi.cxx
new file mode 100644
index 000000000000..4d202f79784c
--- /dev/null
+++ b/svx/source/form/datanavi.cxx
@@ -0,0 +1,3735 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+#include "datanavi.hxx"
+#include "fmservs.hxx"
+
+#include "datanavi.hrc"
+#include "fmresids.hrc"
+#include "fmhelp.hrc"
+#include <svx/svxids.hrc>
+#include <tools/rcid.h>
+#include <tools/diagnose_ex.h>
+#include "xmlexchg.hxx"
+#include <svx/dialmgr.hxx>
+#include <svx/fmshell.hxx>
+#include <svtools/miscopt.hxx>
+#include <unotools/pathoptions.hxx>
+#include <unotools/viewoptions.hxx>
+#include <svtools/svtools.hrc>
+#include <sfx2/app.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/objitem.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include <com/sun/star/xforms/XFormsSupplier.hpp>
+#include <com/sun/star/xml/dom/XDocument.hpp>
+#include <com/sun/star/xml/dom/DOMException.hpp>
+#include <com/sun/star/form/binding/XValueBinding.hpp>
+#include <comphelper/processfactory.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::xml::dom::events;
+using namespace ::svx;
+
+namespace css = ::com::sun::star;
+
+#define CFGNAME_DATANAVIGATOR DEFINE_CONST_UNICODE("DataNavigator")
+#define CFGNAME_SHOWDETAILS DEFINE_CONST_UNICODE("ShowDetails")
+#define MSG_VARIABLE DEFINE_CONST_UNICODE("%1")
+#define MODELNAME DEFINE_CONST_UNICODE("$MODELNAME")
+#define INSTANCENAME DEFINE_CONST_UNICODE("$INSTANCENAME")
+#define ELEMENTNAME DEFINE_CONST_UNICODE("$ELEMENTNAME")
+#define ATTRIBUTENAME DEFINE_CONST_UNICODE("$ATTRIBUTENAME")
+#define SUBMISSIONNAME DEFINE_CONST_UNICODE("$SUBMISSIONNAME")
+#define BINDINGNAME DEFINE_CONST_UNICODE("$BINDINGNAME")
+
+//............................................................................
+namespace svxform
+{
+//............................................................................
+
+ // properties of instance
+ #define PN_INSTANCE_MODEL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Instance" ) )
+ #define PN_INSTANCE_ID ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) )
+ #define PN_INSTANCE_URL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) )
+ #define PN_INSTANCE_URLONCE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URLOnce" ) )
+
+ // properties of binding
+ #define PN_BINDING_ID ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BindingID" ) )
+ #define PN_BINDING_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BindingExpression" ) )
+ #define PN_BINDING_MODEL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) )
+ #define PN_BINDING_NAMESPACES ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModelNamespaces" ) )
+ #define PN_BINDING_MODELID ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModelID" ) )
+ #define PN_READONLY_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReadonlyExpression" ) )
+ #define PN_RELEVANT_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RelevantExpression" ) )
+ #define PN_REQUIRED_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RequiredExpression" ) )
+ #define PN_CONSTRAINT_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConstraintExpression" ) )
+ #define PN_CALCULATE_EXPR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CalculateExpression" ) )
+ #define PN_BINDING_TYPE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) )
+ #define PN_BINDING_READONLY ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReadOnly" ) )
+ #define PN_BINDING_ENABLED ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) )
+
+ // properties of submission
+ #define PN_SUBMISSION_ID ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ID" ) )
+ #define PN_SUBMISSION_BIND ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bind" ) )
+ #define PN_SUBMISSION_REF ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Ref" ) )
+ #define PN_SUBMISSION_ACTION ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Action" ) )
+ #define PN_SUBMISSION_METHOD ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Method" ) )
+ #define PN_SUBMISSION_MODEL ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) )
+ #define PN_SUBMISSION_REPLACE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Replace" ) )
+
+ // submission methods
+ #define SUBMITMETHOD_POST ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "post" ) )
+ #define SUBMITMETHOD_GET ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "get" ) )
+ #define SUBMITMETHOD_PUT ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "put" ) )
+
+ // other const strings
+ #define TRUE_VALUE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true()" ) )
+ #define FALSE_VALUE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false()" ) )
+ #define NEW_ELEMENT ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "newElement" ) )
+ #define NEW_ATTRIBUTE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "newAttribute" ) )
+ #define EVENTTYPE_SUBTREE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DOMSubtreeModified" ) )
+ #define EVENTTYPE_CHARDATA ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DOMCharacterDataModified" ) )
+ #define EVENTTYPE_ATTR ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DOMAttrModified" ) )
+
+ #define MIN_PAGE_COUNT 3 // at least one instance, one submission and one binding page
+
+ struct ItemNode
+ {
+ Reference< css::xml::dom::XNode > m_xNode;
+ Reference< XPropertySet > m_xPropSet;
+
+ ItemNode( const Reference< css::xml::dom::XNode >& _rxNode ) :
+ m_xNode( _rxNode ) {}
+ ItemNode( const Reference< XPropertySet >& _rxSet ) :
+ m_xPropSet( _rxSet ) {}
+
+ DataGroupType GetDataGroupType() const;
+ };
+
+ //========================================================================
+ // class DataTreeListBox
+ //========================================================================
+ DataTreeListBox::DataTreeListBox( XFormsPage* pPage, DataGroupType _eGroup, const ResId& rResId ) :
+
+ SvTreeListBox( pPage, rResId ),
+
+ m_pXFormsPage ( pPage ),
+ m_eGroup ( _eGroup )
+
+ {
+ EnableContextMenuHandling();
+
+ if ( DGTInstance == m_eGroup )
+ SetDragDropMode( SV_DRAGDROP_CTRL_MOVE |SV_DRAGDROP_CTRL_COPY | SV_DRAGDROP_APP_COPY );
+ }
+
+ DataTreeListBox::~DataTreeListBox()
+ {
+ DeleteAndClear();
+ }
+
+ sal_Int8 DataTreeListBox::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
+ {
+ return DND_ACTION_NONE;
+ }
+ sal_Int8 DataTreeListBox::ExecuteDrop( const ExecuteDropEvent& /*rEvt*/ )
+ {
+ return DND_ACTION_NONE;
+ }
+ void DataTreeListBox::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
+ {
+ SvLBoxEntry* pSelected = FirstSelected();
+ if ( !pSelected )
+ // no drag without an entry
+ return;
+
+ if ( m_eGroup == DGTBinding )
+ // for the moment, bindings cannot be dragged.
+ // #i59395# / 2005-12-15 / frank.schoenheit@sun.com
+ return;
+
+ // GetServiceNameForNode() requires a datatype repository which
+ // will be automatically build if requested???
+ Reference< css::xforms::XModel > xModel( m_pXFormsPage->GetXFormsHelper(), UNO_QUERY );
+ Reference< css::xforms::XDataTypeRepository > xDataTypes =
+ xModel->getDataTypeRepository();
+ if(!xDataTypes.is())
+ return;
+
+ using namespace ::com::sun::star::uno;
+ typedef com::sun::star::form::binding::XValueBinding XValueBinding_t;
+
+ ItemNode *pItemNode = static_cast<ItemNode*>(pSelected->GetUserData());
+
+ if ( !pItemNode )
+ {
+ // the only known (and allowed?) case where this happens are sub-entries of a submission
+ // entry
+ DBG_ASSERT( DGTSubmission == m_eGroup, "DataTreeListBox::StartDrag: how this?" );
+ pSelected = GetParent( pSelected );
+ DBG_ASSERT( pSelected && !GetParent( pSelected ), "DataTreeListBox::StartDrag: what kind of entry *is* this?" );
+ // on the submission page, we have only top-level entries (the submission themself)
+ // plus direct children of those (facets of a submission)
+ pItemNode = pSelected ? static_cast< ItemNode* >( pSelected->GetUserData() ) : NULL;
+ if ( !pItemNode )
+ return;
+ }
+
+ OXFormsDescriptor desc;
+ desc.szName = GetEntryText(pSelected);
+ if(pItemNode->m_xNode.is()) {
+ // a valid node interface tells us that we need to create a control from a binding
+ desc.szServiceName = m_pXFormsPage->GetServiceNameForNode(pItemNode->m_xNode);
+ desc.xPropSet = m_pXFormsPage->GetBindingForNode(pItemNode->m_xNode);
+ DBG_ASSERT( desc.xPropSet.is(), "DataTreeListBox::StartDrag(): invalid node binding" );
+ }
+ else {
+ desc.szServiceName = FM_COMPONENT_COMMANDBUTTON;
+ desc.xPropSet = pItemNode->m_xPropSet;
+ }
+ OXFormsTransferable *pTransferable = new OXFormsTransferable(desc);
+ Reference< XTransferable > xEnsureDelete = pTransferable;
+ if(pTransferable) {
+ EndSelection();
+ pTransferable->StartDrag( this, DND_ACTION_COPY );
+ }
+ }
+
+ PopupMenu* DataTreeListBox::CreateContextMenu()
+ {
+ PopupMenu* pMenu = new PopupMenu( SVX_RES( RID_MENU_DATANAVIGATOR ) );
+ if ( DGTInstance == m_eGroup )
+ pMenu->RemoveItem( pMenu->GetItemPos( TBI_ITEM_ADD ) );
+ else
+ {
+ pMenu->RemoveItem( pMenu->GetItemPos( TBI_ITEM_ADD_ELEMENT ) );
+ pMenu->RemoveItem( pMenu->GetItemPos( TBI_ITEM_ADD_ATTRIBUTE ) );
+
+ if ( DGTSubmission == m_eGroup )
+ {
+ pMenu->SetItemText( TBI_ITEM_ADD, SVX_RESSTR( RID_STR_DATANAV_ADD_SUBMISSION ) );
+ pMenu->SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( RID_STR_DATANAV_EDIT_SUBMISSION ) );
+ pMenu->SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( RID_STR_DATANAV_REMOVE_SUBMISSION ) );
+ }
+ else
+ {
+ pMenu->SetItemText( TBI_ITEM_ADD, SVX_RESSTR( RID_STR_DATANAV_ADD_BINDING ) );
+ pMenu->SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( RID_STR_DATANAV_EDIT_BINDING ) );
+ pMenu->SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( RID_STR_DATANAV_REMOVE_BINDING ) );
+ }
+ }
+ m_pXFormsPage->EnableMenuItems( pMenu );
+ return pMenu;
+ }
+
+ void DataTreeListBox::ExcecuteContextMenuAction( USHORT _nSelectedPopupEntry )
+ {
+ m_pXFormsPage->DoMenuAction( _nSelectedPopupEntry );
+ }
+
+ void DataTreeListBox::RemoveEntry( SvLBoxEntry* _pEntry )
+ {
+ if ( _pEntry )
+ {
+ delete static_cast< ItemNode* >( _pEntry->GetUserData() );
+ SvTreeListBox::GetModel()->Remove( _pEntry );
+ }
+ }
+
+ void DataTreeListBox::DeleteAndClear()
+ {
+ ULONG i, nCount = GetEntryCount();
+ for ( i = 0; i < nCount; ++i )
+ {
+ SvLBoxEntry* pEntry = GetEntry(i);
+ if ( pEntry )
+ delete static_cast< ItemNode* >( pEntry->GetUserData() );
+ }
+
+ Clear();
+ }
+
+ //========================================================================
+ // class XFormsPage
+ //========================================================================
+ XFormsPage::XFormsPage( Window* pParent, DataNavigatorWindow* _pNaviWin, DataGroupType _eGroup ) :
+
+ TabPage( pParent, SVX_RES( RID_SVX_XFORMS_TABPAGES ) ),
+
+ m_aToolBox ( this, SVX_RES( TB_ITEMS ) ),
+ m_aItemList ( this, _eGroup, SVX_RES( LB_ITEMS ) ),
+ m_pNaviWin ( _pNaviWin ),
+ m_bHasModel ( false ),
+ m_eGroup ( _eGroup ),
+ m_TbxImageList ( SVX_RES( IL_TBX_BMPS ) ),
+ m_TbxHCImageList( SVX_RES( IL_TBX_BMPS_HC ) )
+
+ {
+ FreeResource();
+
+ const ImageList& rImageList =
+ GetBackground().GetColor().IsDark() ? m_TbxHCImageList : m_TbxImageList;
+ m_aToolBox.SetItemImage( TBI_ITEM_ADD, rImageList.GetImage( IID_ITEM_ADD ) );
+ m_aToolBox.SetItemImage( TBI_ITEM_ADD_ELEMENT, rImageList.GetImage( IID_ITEM_ADD_ELEMENT ) );
+ m_aToolBox.SetItemImage( TBI_ITEM_ADD_ATTRIBUTE, rImageList.GetImage( IID_ITEM_ADD_ATTRIBUTE ) );
+ m_aToolBox.SetItemImage( TBI_ITEM_EDIT, rImageList.GetImage( IID_ITEM_EDIT ) );
+ m_aToolBox.SetItemImage( TBI_ITEM_REMOVE, rImageList.GetImage( IID_ITEM_REMOVE ) );
+
+ if ( DGTInstance == m_eGroup )
+ m_aToolBox.RemoveItem( m_aToolBox.GetItemPos( TBI_ITEM_ADD ) );
+ else
+ {
+ m_aToolBox.RemoveItem( m_aToolBox.GetItemPos( TBI_ITEM_ADD_ELEMENT ) );
+ m_aToolBox.RemoveItem( m_aToolBox.GetItemPos( TBI_ITEM_ADD_ATTRIBUTE ) );
+
+ if ( DGTSubmission == m_eGroup )
+ {
+ m_aToolBox.SetItemText( TBI_ITEM_ADD, SVX_RESSTR( RID_STR_DATANAV_ADD_SUBMISSION ) );
+ m_aToolBox.SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( RID_STR_DATANAV_EDIT_SUBMISSION ) );
+ m_aToolBox.SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( RID_STR_DATANAV_REMOVE_SUBMISSION ) );
+ }
+ else
+ {
+ m_aToolBox.SetItemText( TBI_ITEM_ADD, SVX_RESSTR( RID_STR_DATANAV_ADD_BINDING ) );
+ m_aToolBox.SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( RID_STR_DATANAV_EDIT_BINDING ) );
+ m_aToolBox.SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( RID_STR_DATANAV_REMOVE_BINDING ) );
+ }
+ }
+
+ const Size aTbxSz( m_aToolBox.CalcWindowSizePixel() );
+ m_aToolBox.SetSizePixel( aTbxSz );
+ m_aToolBox.SetOutStyle( SvtMiscOptions().GetToolboxStyle() );
+ m_aToolBox.SetSelectHdl( LINK( this, XFormsPage, TbxSelectHdl ) );
+ Point aPos = m_aItemList.GetPosPixel();
+ aPos.Y() = aTbxSz.Height();
+ m_aItemList.SetPosPixel( aPos );
+
+ m_aItemList.SetSelectHdl( LINK( this, XFormsPage, ItemSelectHdl ) );
+ m_aItemList.SetNodeDefaultImages();
+ WinBits nBits = WB_BORDER | WB_TABSTOP | WB_HIDESELECTION | WB_NOINITIALSELECTION;
+ if ( DGTInstance == m_eGroup || DGTSubmission == m_eGroup )
+ nBits |= WB_HASBUTTONS | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONSATROOT;
+ m_aItemList.SetWindowBits( m_aItemList.GetStyle() | nBits );
+ m_aItemList.Show();
+ ItemSelectHdl( &m_aItemList );
+ }
+ //------------------------------------------------------------------------
+ XFormsPage::~XFormsPage()
+ {
+ }
+ //------------------------------------------------------------------------
+ IMPL_LINK( XFormsPage, TbxSelectHdl, ToolBox *, EMPTYARG )
+ {
+ DoToolBoxAction( m_aToolBox.GetCurItemId() );
+ return 0;
+ }
+ //------------------------------------------------------------------------
+ IMPL_LINK( XFormsPage, ItemSelectHdl, DataTreeListBox *, EMPTYARG )
+ {
+ EnableMenuItems( NULL );
+ return 0;
+ }
+ //------------------------------------------------------------------------
+ void XFormsPage::AddChildren(
+ SvLBoxEntry* _pParent, const ImageList& _rImgLst,
+ const Reference< css::xml::dom::XNode >& _xNode )
+ {
+ DBG_ASSERT( m_xUIHelper.is(), "XFormsPage::AddChildren(): invalid UIHelper" );
+
+ try
+ {
+ Reference< css::xml::dom::XNodeList > xNodeList = _xNode->getChildNodes();
+ if ( xNodeList.is() )
+ {
+ bool bShowDetails = m_pNaviWin->IsShowDetails();
+ sal_Int32 i, nNodeCount = xNodeList->getLength();
+ for ( i = 0; i < nNodeCount; ++i )
+ {
+ Reference< css::xml::dom::XNode > xChild = xNodeList->item(i);
+ css::xml::dom::NodeType eChildType = xChild->getNodeType();
+ Image aExpImg, aCollImg;
+ switch ( eChildType )
+ {
+ case css::xml::dom::NodeType_ATTRIBUTE_NODE:
+ aExpImg = aCollImg = _rImgLst.GetImage( IID_ATTRIBUTE );
+ break;
+ case css::xml::dom::NodeType_ELEMENT_NODE:
+ aExpImg = aCollImg = _rImgLst.GetImage( IID_ELEMENT );
+ break;
+ case css::xml::dom::NodeType_TEXT_NODE:
+ aExpImg = aCollImg = _rImgLst.GetImage( IID_TEXT );
+ break;
+ default:
+ aExpImg = aCollImg = _rImgLst.GetImage( IID_OTHER );
+ }
+
+ ::rtl::OUString sName = m_xUIHelper->getNodeDisplayName( xChild, bShowDetails );
+ if ( sName.getLength() > 0 )
+ {
+ ItemNode* pNode = new ItemNode( xChild );
+ SvLBoxEntry* pEntry = m_aItemList.InsertEntry(
+ sName, aExpImg, aCollImg, _pParent, FALSE, LIST_APPEND, pNode );
+ if ( xChild->hasAttributes() )
+ {
+ Reference< css::xml::dom::XNamedNodeMap > xMap = xChild->getAttributes();
+ if ( xMap.is() )
+ {
+ aExpImg = aCollImg = _rImgLst.GetImage( IID_ATTRIBUTE );
+ sal_Int32 j, nMapLen = xMap->getLength();
+ for ( j = 0; j < nMapLen; ++j )
+ {
+ Reference< css::xml::dom::XNode > xAttr = xMap->item(j);
+ pNode = new ItemNode( xAttr );
+ ::rtl::OUString sAttrName =
+ m_xUIHelper->getNodeDisplayName( xAttr, bShowDetails );
+ m_aItemList.InsertEntry(
+ sAttrName, aExpImg, aCollImg,
+ pEntry, FALSE, LIST_APPEND, pNode );
+ }
+ }
+ }
+ if ( xChild->hasChildNodes() )
+ AddChildren( pEntry, _rImgLst, xChild );
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ //------------------------------------------------------------------------
+ bool XFormsPage::DoToolBoxAction( USHORT _nToolBoxID ) {
+
+ bool bHandled = false;
+ bool bIsDocModified = false;
+ m_pNaviWin->DisableNotify( true );
+
+ switch ( _nToolBoxID )
+ {
+ case TBI_ITEM_ADD:
+ case TBI_ITEM_ADD_ELEMENT:
+ case TBI_ITEM_ADD_ATTRIBUTE:
+ {
+ bHandled = true;
+ Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
+ DBG_ASSERT( xModel.is(), "XFormsPage::DoToolBoxAction(): Action without model" );
+ if ( DGTSubmission == m_eGroup )
+ {
+ AddSubmissionDialog aDlg( this, NULL, m_xUIHelper );
+ if ( aDlg.Execute() == RET_OK && aDlg.GetNewSubmission().is() )
+ {
+ try
+ {
+ Reference< css::xforms::XSubmission > xNewSubmission = aDlg.GetNewSubmission();
+ Reference< XSet > xSubmissions( xModel->getSubmissions(), UNO_QUERY );
+ xSubmissions->insert( makeAny( xNewSubmission ) );
+ Reference< XPropertySet > xNewPropSet( xNewSubmission, UNO_QUERY );
+ SvLBoxEntry* pEntry = AddEntry( xNewPropSet );
+ m_aItemList.Select( pEntry, TRUE );
+ bIsDocModified = true;
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while adding submission" );
+ }
+ }
+ }
+ else
+ {
+ DataItemType eType = DITElement;
+ SvLBoxEntry* pEntry = m_aItemList.FirstSelected();
+ ItemNode* pNode = NULL;
+ Reference< css::xml::dom::XNode > xParentNode;
+ Reference< XPropertySet > xNewBinding;
+ USHORT nResId = 0;
+ bool bIsElement = true;
+ if ( DGTInstance == m_eGroup )
+ {
+ if ( m_sInstanceURL.Len() > 0 )
+ {
+ LinkedInstanceWarningBox aMsgBox( this );
+ if ( aMsgBox.Execute() != RET_OK )
+ return bHandled;
+ }
+
+ DBG_ASSERT( pEntry, "XFormsPage::DoToolBoxAction(): no entry" );
+ ItemNode* pParentNode = static_cast< ItemNode* >( pEntry->GetUserData() );
+ DBG_ASSERT( pParentNode, "XFormsPage::DoToolBoxAction(): no parent node" );
+ xParentNode = pParentNode->m_xNode;
+ Reference< css::xml::dom::XNode > xNewNode;
+ if ( TBI_ITEM_ADD_ELEMENT == _nToolBoxID )
+ {
+ try
+ {
+ nResId = RID_STR_DATANAV_ADD_ELEMENT;
+ xNewNode = m_xUIHelper->createElement( xParentNode, NEW_ELEMENT );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while create element" );
+ }
+ }
+ else
+ {
+ nResId = RID_STR_DATANAV_ADD_ATTRIBUTE;
+ bIsElement = false;
+ eType = DITAttribute;
+ try
+ {
+ xNewNode = m_xUIHelper->createAttribute( xParentNode, NEW_ATTRIBUTE );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while create attribute" );
+ }
+ }
+
+ try
+ {
+ xNewNode = xParentNode->appendChild( xNewNode );
+ }
+ catch ( css::xml::dom::DOMException& e )
+ {
+ if ( e.Code == css::xml::dom::DOMExceptionType_DOMSTRING_SIZE_ERR )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): domexception: size error" );
+ }
+ DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): domexception while append child" );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while append child" );
+ }
+
+ try
+ {
+ Reference< css::xml::dom::XNode > xPNode;
+ if ( xNewNode.is() )
+ xPNode = xNewNode->getParentNode();
+ // attributes don't have parents in the DOM model
+ DBG_ASSERT( TBI_ITEM_ADD_ATTRIBUTE == _nToolBoxID
+ || xPNode.is(), "XFormsPage::DoToolboxAction(): node not added" );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
+ }
+
+ try
+ {
+ m_xUIHelper->getBindingForNode( xNewNode, sal_True );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while get binding for node" );
+ }
+ pNode = new ItemNode( xNewNode );
+ }
+ else
+ {
+ try
+ {
+ nResId = RID_STR_DATANAV_ADD_BINDING;
+ xNewBinding = xModel->createBinding();
+ Reference< XSet > xBindings( xModel->getBindings(), UNO_QUERY );
+ xBindings->insert( makeAny( xNewBinding ) );
+ pNode = new ItemNode( xNewBinding );
+ eType = DITBinding;
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolBoxAction(): exception while adding binding" );
+ }
+ }
+
+ AddDataItemDialog aDlg( this, pNode, m_xUIHelper );
+ aDlg.SetText( SVX_RESSTR( nResId ) );
+ aDlg.InitText( eType );
+ short nReturn = aDlg.Execute();
+ if ( DGTInstance == m_eGroup )
+ {
+ if ( RET_OK == nReturn )
+ {
+ SvLBoxEntry* pNewEntry = AddEntry( pNode, bIsElement );
+ m_aItemList.MakeVisible( pNewEntry );
+ m_aItemList.Select( pNewEntry, TRUE );
+ bIsDocModified = true;
+ }
+ else
+ {
+ try
+ {
+ Reference< css::xml::dom::XNode > xPNode;
+ Reference< css::xml::dom::XNode > xNode =
+ xParentNode->removeChild( pNode->m_xNode );
+ if ( xNode.is() )
+ xPNode = xNode->getParentNode();
+ DBG_ASSERT( !xPNode.is(), "XFormsPage::RemoveEntry(): node not removed" );
+ delete pNode;
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
+ }
+ }
+ }
+ else
+ {
+ if ( RET_OK == nReturn )
+ {
+ SvLBoxEntry* pNewEntry = AddEntry( xNewBinding );
+ m_aItemList.Select( pNewEntry, TRUE );
+ bIsDocModified = true;
+ }
+ else
+ {
+ try
+ {
+ Reference< XSet > xBindings( xModel->getBindings(), UNO_QUERY );
+ xBindings->remove( makeAny( xNewBinding ) );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
+ }
+ }
+ delete pNode;
+ }
+ }
+ }
+ break;
+
+ case TBI_ITEM_EDIT:
+ {
+ bHandled = true;
+ SvLBoxEntry* pEntry = m_aItemList.FirstSelected();
+ if ( pEntry )
+ {
+ if ( DGTSubmission == m_eGroup && m_aItemList.GetParent( pEntry ) )
+ pEntry = m_aItemList.GetParent( pEntry );
+ ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
+ if ( DGTInstance == m_eGroup || DGTBinding == m_eGroup )
+ {
+ if ( DGTInstance == m_eGroup && m_sInstanceURL.Len() > 0 )
+ {
+ LinkedInstanceWarningBox aMsgBox( this );
+ if ( aMsgBox.Execute() != RET_OK )
+ return bHandled;
+ }
+
+ AddDataItemDialog aDlg( this, pNode, m_xUIHelper );
+ DataItemType eType = DITElement;
+ USHORT nResId = RID_STR_DATANAV_EDIT_ELEMENT;
+ if ( pNode && pNode->m_xNode.is() )
+ {
+ try
+ {
+ css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
+ if ( eChildType == css::xml::dom::NodeType_ATTRIBUTE_NODE )
+ {
+ nResId = RID_STR_DATANAV_EDIT_ATTRIBUTE;
+ eType = DITAttribute;
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
+ }
+ }
+ else if ( DGTBinding == m_eGroup )
+ {
+ nResId = RID_STR_DATANAV_EDIT_BINDING;
+ eType = DITBinding;
+ }
+ aDlg.SetText( SVX_RESSTR( nResId ) );
+ aDlg.InitText( eType );
+ if ( aDlg.Execute() == RET_OK )
+ {
+ // Set the new name
+ String sNewName;
+ if ( DGTInstance == m_eGroup )
+ {
+ try
+ {
+ sNewName = m_xUIHelper->getNodeDisplayName(
+ pNode->m_xNode, m_pNaviWin->IsShowDetails() );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
+ }
+ }
+ else
+ {
+ try
+ {
+ String sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
+ ::rtl::OUString sTemp;
+ pNode->m_xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
+ sNewName += String( sTemp );
+ sNewName += sDelim;
+ pNode->m_xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
+ sNewName += String( sTemp );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::DoToolboxAction(): exception caught" );
+ }
+ }
+
+ m_aItemList.SetEntryText( pEntry, sNewName );
+ bIsDocModified = true;
+ }
+ }
+ else
+ {
+ AddSubmissionDialog aDlg( this, pNode, m_xUIHelper );
+ aDlg.SetText( SVX_RESSTR( RID_STR_DATANAV_EDIT_SUBMISSION ) );
+ if ( aDlg.Execute() == RET_OK )
+ {
+ EditEntry( pNode->m_xPropSet );
+ bIsDocModified = true;
+ }
+ }
+ }
+ }
+ break;
+
+ case TBI_ITEM_REMOVE:
+ {
+ bHandled = true;
+ if ( DGTInstance == m_eGroup && m_sInstanceURL.Len() > 0 )
+ {
+ LinkedInstanceWarningBox aMsgBox( this );
+ if ( aMsgBox.Execute() != RET_OK )
+ return bHandled;
+ }
+ bIsDocModified = RemoveEntry();
+ }
+ break;
+
+ case MID_INSERT_CONTROL:
+ {
+ OSL_ENSURE( false, "XFormsPage::DoToolboxAction: MID_INSERT_CONTROL not implemented, yet!" );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( false, "XFormsPage::DoToolboxAction: unknown ID!" );
+ break;
+ }
+
+ m_pNaviWin->DisableNotify( false );
+ EnableMenuItems( NULL );
+ if ( bIsDocModified )
+ m_pNaviWin->SetDocModified();
+ return bHandled;
+ }
+
+ //------------------------------------------------------------------------
+ SvLBoxEntry* XFormsPage::AddEntry( ItemNode* _pNewNode, bool _bIsElement )
+ {
+ SvLBoxEntry* pParent = m_aItemList.FirstSelected();
+ const ImageList& rImageList = GetSettings().GetStyleSettings().GetHighContrastMode()
+ ? m_pNaviWin->GetItemHCImageList()
+ : m_pNaviWin->GetItemImageList();
+ USHORT nImageID = ( _bIsElement ) ? IID_ELEMENT : IID_ATTRIBUTE;
+ Image aImage = rImageList.GetImage( nImageID );
+ ::rtl::OUString sName;
+ try
+ {
+ sName = m_xUIHelper->getNodeDisplayName(
+ _pNewNode->m_xNode, m_pNaviWin->IsShowDetails() );
+ }
+ catch ( Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return m_aItemList.InsertEntry(
+ sName, aImage, aImage, pParent, FALSE, LIST_APPEND, _pNewNode );
+ }
+ //------------------------------------------------------------------------
+ class lcl_ResourceString
+ {
+ protected:
+ lcl_ResourceString()
+ {
+ }
+
+ lcl_ResourceString( const lcl_ResourceString& );
+
+ virtual ~lcl_ResourceString()
+ {
+ }
+
+ // load UI resources from resource file
+ void init()
+ {
+ // create a resource manager, for the svx resource file
+ // and the UI locale
+ ByteString aResourceFile( "svx" );
+ ResMgr* pResMgr = ResMgr::CreateResMgr(
+ aResourceFile.GetBuffer(),
+ Application::GetSettings().GetUILocale() );
+
+ // load the resources for the AddSubmission modal dialog.
+ // This will create our own resource context.
+ ResId aRes( RID_SVXDLG_ADD_SUBMISSION, *pResMgr );
+ aRes.SetRT( RSC_MODALDIALOG );
+ pResMgr->GetResource( aRes );
+
+ // now, we can access the local resources from the dialog's
+ // resource context
+ _initResources(pResMgr);
+
+ // clean up: remove context, and delete the resource manager
+ // ( Increment(..) is needed since PopContext() requires that
+ // the file pointer is at the end. )
+ pResMgr->Increment( pResMgr->GetRemainSize() );
+ pResMgr->PopContext();
+ delete pResMgr;
+ }
+
+ // load resources... to be overloaded in sub-classes
+ virtual void _initResources( ResMgr* pMgr ) = 0;
+ };
+
+ class lcl_ReplaceString : public lcl_ResourceString
+ {
+ rtl::OUString m_sDoc_UI;
+ rtl::OUString m_sInstance_UI;
+ rtl::OUString m_sNone_UI;
+
+ rtl::OUString m_sDoc_API;
+ rtl::OUString m_sInstance_API;
+ rtl::OUString m_sNone_API;
+
+ lcl_ReplaceString() :
+ lcl_ResourceString(),
+ m_sDoc_API( RTL_CONSTASCII_USTRINGPARAM("all") ),
+ m_sInstance_API( RTL_CONSTASCII_USTRINGPARAM("instance") ),
+ m_sNone_API( RTL_CONSTASCII_USTRINGPARAM("none") )
+ {
+ init();
+ }
+
+ lcl_ReplaceString( const lcl_ReplaceString& );
+
+ virtual ~lcl_ReplaceString()
+ {
+ }
+
+ // load UI resources from resource file
+ virtual void _initResources( ResMgr * pMgr )
+ {
+ // now, we can access the local resources from the dialog's
+ // resource context
+ m_sDoc_UI = String( ResId( STR_REPLACE_DOC, *pMgr ) );
+ m_sInstance_UI = String( ResId( STR_REPLACE_INST, *pMgr ) );
+ m_sNone_UI = String( ResId( STR_REPLACE_NONE, *pMgr ) );
+ }
+
+ public:
+
+ /** create and obtain the singleton instance */
+ static const lcl_ReplaceString& get()
+ {
+ // keep the singleton instance here
+ static lcl_ReplaceString* m_pInstance = NULL;
+
+ if( m_pInstance == NULL )
+ m_pInstance = new lcl_ReplaceString();
+ return *m_pInstance;
+ }
+
+ /** convert submission replace string from API value to UI value.
+ Use 'none' as default. */
+ rtl::OUString toUI( const rtl::OUString& rStr ) const
+ {
+ if( rStr == m_sDoc_API )
+ return m_sDoc_UI;
+ else if( rStr == m_sInstance_API )
+ return m_sInstance_UI;
+ else
+ return m_sNone_UI;
+ }
+
+ /** convert submission replace string from UI to API.
+ Use 'none' as default. */
+ rtl::OUString toAPI( const rtl::OUString& rStr ) const
+ {
+ if( rStr == m_sDoc_UI )
+ return m_sDoc_API;
+ else if( rStr == m_sInstance_UI )
+ return m_sInstance_API;
+ else
+ return m_sNone_API;
+ }
+ };
+
+ class lcl_MethodString : public lcl_ResourceString
+ {
+ rtl::OUString m_sPost_UI;
+ rtl::OUString m_sPut_UI;
+ rtl::OUString m_sGet_UI;
+
+ rtl::OUString m_sPost_API;
+ rtl::OUString m_sPut_API;
+ rtl::OUString m_sGet_API;
+
+ lcl_MethodString() :
+ lcl_ResourceString(),
+ m_sPost_API( RTL_CONSTASCII_USTRINGPARAM("post") ),
+ m_sPut_API( RTL_CONSTASCII_USTRINGPARAM("put") ),
+ m_sGet_API( RTL_CONSTASCII_USTRINGPARAM("get") )
+ {
+ init();
+ }
+
+ lcl_MethodString( const lcl_MethodString& );
+
+ virtual ~lcl_MethodString()
+ {
+ }
+
+ // load UI resources from resource file
+ virtual void _initResources(ResMgr* pMgr)
+ {
+ m_sPost_UI = String( ResId( STR_METHOD_POST, *pMgr ) );
+ m_sPut_UI = String( ResId( STR_METHOD_PUT, *pMgr ) );
+ m_sGet_UI = String( ResId( STR_METHOD_GET, *pMgr ) );
+ }
+
+ public:
+
+ /** create and obtain the singleton instance */
+ static const lcl_MethodString& get()
+ {
+ // keep the singleton instance here
+ static lcl_MethodString* m_pInstance = NULL;
+
+ if( m_pInstance == NULL )
+ m_pInstance = new lcl_MethodString();
+ return *m_pInstance;
+ }
+
+ /** convert from API to UI; put is default. */
+ rtl::OUString toUI( const rtl::OUString& rStr ) const
+ {
+ if( rStr == m_sGet_API )
+ return m_sGet_UI;
+ else if( rStr == m_sPost_API )
+ return m_sPost_UI;
+ else
+ return m_sPut_UI;
+ }
+
+ /** convert from UI to API; put is default */
+ rtl::OUString toAPI( const rtl::OUString& rStr ) const
+ {
+ if( rStr == m_sGet_UI )
+ return m_sGet_API;
+ else if( rStr == m_sPost_UI )
+ return m_sPost_API;
+ else
+ return m_sPut_API;
+ }
+ };
+
+ //------------------------------------------------------------------------
+ SvLBoxEntry* XFormsPage::AddEntry( const Reference< XPropertySet >& _rEntry )
+ {
+ SvLBoxEntry* pEntry = NULL;
+ const ImageList& rImageList = GetSettings().GetStyleSettings().GetHighContrastMode()
+ ? m_pNaviWin->GetItemHCImageList()
+ : m_pNaviWin->GetItemImageList();
+ Image aImage = rImageList.GetImage( IID_ELEMENT );
+
+ ItemNode* pNode = new ItemNode( _rEntry );
+ rtl::OUString sTemp;
+
+ if ( DGTSubmission == m_eGroup )
+ {
+ try
+ {
+ // ID
+ _rEntry->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
+ pEntry = m_aItemList.InsertEntry( sTemp, aImage, aImage, NULL, FALSE, LIST_APPEND, pNode );
+ // Action
+ _rEntry->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp;
+ String sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_ACTION );
+ sEntry += String( sTemp );
+ m_aItemList.InsertEntry( sEntry, aImage, aImage, pEntry );
+ // Method
+ _rEntry->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp;
+ sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_METHOD );
+ sEntry += String( lcl_MethodString::get().toUI( sTemp ) );
+ m_aItemList.InsertEntry( sEntry, aImage, aImage, pEntry );
+ // Ref
+ _rEntry->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp;
+ sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_REF );
+ sEntry += String( sTemp );
+ m_aItemList.InsertEntry( sEntry, aImage, aImage, pEntry );
+ // Bind
+ _rEntry->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp;
+ sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_BIND );
+ sEntry += String( sTemp );
+ m_aItemList.InsertEntry( sEntry, aImage, aImage, pEntry );
+ // Replace
+ _rEntry->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp;
+ sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_REPLACE );
+ sEntry += String( lcl_ReplaceString::get().toUI( sTemp ) );
+ m_aItemList.InsertEntry( sEntry, aImage, aImage, pEntry );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::AddEntry(Ref): exception caught" );
+ }
+ }
+ else // then Binding Page
+ {
+ try
+ {
+ String sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
+ ::rtl::OUString sName;
+ _rEntry->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
+ sName += String( sTemp );
+ sName += sDelim;
+ _rEntry->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
+ sName += String( sTemp );
+ pEntry = m_aItemList.InsertEntry(
+ sName, aImage, aImage, NULL, FALSE, LIST_APPEND, pNode );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::AddEntry(Ref): exception caught" );
+ }
+ }
+
+ return pEntry;
+ }
+
+ //------------------------------------------------------------------------
+ void XFormsPage::EditEntry( const Reference< XPropertySet >& _rEntry )
+ {
+ SvLBoxEntry* pEntry = NULL;
+ rtl::OUString sTemp;
+
+ if ( DGTSubmission == m_eGroup )
+ {
+ try
+ {
+ pEntry = m_aItemList.FirstSelected();
+
+ // #i36262# may be called for submission entry *or* for
+ // submission children. If we don't have any children, we
+ // assume the latter case and use the parent
+ if( m_aItemList.GetEntry( pEntry, 0 ) == NULL )
+ {
+ pEntry = m_aItemList.GetModel()->GetParent( pEntry );
+ }
+
+ _rEntry->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
+ m_aItemList.SetEntryText( pEntry, sTemp );
+
+ _rEntry->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp;
+ String sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_BIND );
+ sEntry += String( sTemp );
+ ULONG nPos = 0;
+ SvLBoxEntry* pChild = m_aItemList.GetEntry( pEntry, nPos++ );
+ m_aItemList.SetEntryText( pChild, sEntry );
+ _rEntry->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp;
+ sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_REF );
+ sEntry += String( sTemp );
+ pChild = m_aItemList.GetEntry( pEntry, nPos++ );
+ m_aItemList.SetEntryText( pChild, sEntry );
+ _rEntry->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp;
+ sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_ACTION );
+ sEntry += String( sTemp );
+ pChild = m_aItemList.GetEntry( pEntry, nPos++ );
+ m_aItemList.SetEntryText( pChild, sEntry );
+ _rEntry->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp;
+ sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_METHOD );
+ sEntry += String( lcl_MethodString::get().toUI( sTemp ) );
+ pChild = m_aItemList.GetEntry( pEntry, nPos++ );
+ m_aItemList.SetEntryText( pChild, sEntry );
+ _rEntry->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp;
+ sEntry = SVX_RESSTR( RID_STR_DATANAV_SUBM_REPLACE );
+ sEntry += String( lcl_ReplaceString::get().toUI( sTemp ) );
+ pChild = m_aItemList.GetEntry( pEntry, nPos++ );
+ m_aItemList.SetEntryText( pChild, sEntry );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::EditEntry(): exception caught" );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ bool XFormsPage::RemoveEntry()
+ {
+ bool bRet = false;
+ SvLBoxEntry* pEntry = m_aItemList.FirstSelected();
+ if ( pEntry &&
+ ( DGTInstance != m_eGroup || m_aItemList.GetParent( pEntry ) ) )
+ {
+ Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
+ DBG_ASSERT( xModel.is(), "XFormsPage::RemoveEntry(): no model" );
+ ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
+ DBG_ASSERT( pNode, "XFormsPage::RemoveEntry(): no node" );
+
+ if ( DGTInstance == m_eGroup )
+ {
+ try
+ {
+ DBG_ASSERT( pNode->m_xNode.is(), "XFormsPage::RemoveEntry(): no XNode" );
+ css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
+ bool bIsElement = ( eChildType == css::xml::dom::NodeType_ELEMENT_NODE );
+ USHORT nResId = bIsElement ? RID_QRY_REMOVE_ELEMENT : RID_QRY_REMOVE_ATTRIBUTE;
+ String sVar = bIsElement ? ELEMENTNAME : ATTRIBUTENAME;
+ QueryBox aQBox( this, SVX_RES( nResId ) );
+ String sMessText = aQBox.GetMessText();
+ sMessText.SearchAndReplace(
+ sVar, m_xUIHelper->getNodeDisplayName( pNode->m_xNode, sal_False ) );
+ aQBox.SetMessText( sMessText );
+ if ( aQBox.Execute() == RET_YES )
+ {
+ SvLBoxEntry* pParent = m_aItemList.GetParent( pEntry );
+ DBG_ASSERT( pParent, "XFormsPage::RemoveEntry(): no parent entry" );
+ ItemNode* pParentNode = static_cast< ItemNode* >( pParent->GetUserData() );
+ DBG_ASSERT( pParentNode && pParentNode->m_xNode.is(), "XFormsPage::RemoveEntry(): no parent XNode" );
+
+ Reference< css::xml::dom::XNode > xPNode;
+ Reference< css::xml::dom::XNode > xNode =
+ pParentNode->m_xNode->removeChild( pNode->m_xNode );
+ if ( xNode.is() )
+ xPNode = xNode->getParentNode();
+ DBG_ASSERT( !xPNode.is(), "XFormsPage::RemoveEntry(): node not removed" );
+ bRet = true;
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::RemoveEntry(): exception caught" );
+ }
+ }
+ else
+ {
+ DBG_ASSERT( pNode->m_xPropSet.is(), "XFormsPage::RemoveEntry(): no propset" );
+ bool bSubmission = ( DGTSubmission == m_eGroup );
+ USHORT nResId = bSubmission ? RID_QRY_REMOVE_SUBMISSION : RID_QRY_REMOVE_BINDING;
+ rtl::OUString sProperty = bSubmission ? PN_SUBMISSION_ID : PN_BINDING_ID;
+ String sSearch = bSubmission ? SUBMISSIONNAME : BINDINGNAME;
+ rtl::OUString sName;
+ try
+ {
+ pNode->m_xPropSet->getPropertyValue( sProperty ) >>= sName;
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::RemoveEntry(): exception caught" );
+ }
+ QueryBox aQBox( this, SVX_RES( nResId ) );
+ String sMessText = aQBox.GetMessText();
+ sMessText.SearchAndReplace( sSearch, String( sName ) );
+ aQBox.SetMessText( sMessText );
+ if ( aQBox.Execute() == RET_YES )
+ {
+ try
+ {
+ if ( bSubmission )
+ xModel->getSubmissions()->remove( makeAny( pNode->m_xPropSet ) );
+ else // then Binding Page
+ xModel->getBindings()->remove( makeAny( pNode->m_xPropSet ) );
+ bRet = true;
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::RemoveEntry(): exception caught" );
+ }
+ }
+ }
+
+ if ( bRet )
+ m_aItemList.RemoveEntry( pEntry );
+ }
+
+ return bRet;
+ }
+
+ //------------------------------------------------------------------------
+ long XFormsPage::Notify( NotifyEvent& rNEvt )
+ {
+ long nHandled = 0;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ USHORT nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+
+ switch ( nCode )
+ {
+ case KEY_DELETE:
+ nHandled = DoMenuAction( TBI_ITEM_REMOVE );
+ break;
+ }
+ }
+
+ return nHandled ? nHandled : Window::Notify( rNEvt );
+ }
+ //------------------------------------------------------------------------
+ void XFormsPage::Resize()
+ {
+ Size aSize = GetOutputSizePixel();
+ Size aTbxSize = m_aToolBox.GetSizePixel();
+ aTbxSize.Width() = aSize.Width();
+ m_aToolBox.SetSizePixel( aTbxSize );
+ aSize.Width() -= 4;
+ aSize.Height() -= ( 4 + aTbxSize.Height() );
+ m_aItemList.SetPosSizePixel( Point( 2, 2 + aTbxSize.Height() ), aSize );
+ }
+ //------------------------------------------------------------------------
+ String XFormsPage::SetModel( const Reference< css::xforms::XModel >& _xModel, USHORT _nPagePos )
+ {
+ DBG_ASSERT( _xModel.is(), "XFormsPage::SetModel(): invalid model" );
+
+ m_xUIHelper = Reference< css::xforms::XFormsUIHelper1 >( _xModel, UNO_QUERY );
+ String sRet;
+ m_bHasModel = true;
+ const ImageList& rImageList = GetSettings().GetStyleSettings().GetHighContrastMode()
+ ? m_pNaviWin->GetItemHCImageList()
+ : m_pNaviWin->GetItemImageList();
+
+ switch ( m_eGroup )
+ {
+ case DGTInstance :
+ {
+ DBG_ASSERT( _nPagePos != TAB_PAGE_NOTFOUND, "XFormsPage::SetModel(): invalid page position" );
+ try
+ {
+ Reference< XContainer > xContainer( _xModel->getInstances(), UNO_QUERY );
+ if ( xContainer.is() )
+ m_pNaviWin->AddContainerBroadcaster( xContainer );
+
+ USHORT nIter = 0;
+ Reference< XEnumerationAccess > xNumAccess( _xModel->getInstances(), UNO_QUERY );
+ if ( xNumAccess.is() )
+ {
+ Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
+ if ( xNum.is() && xNum->hasMoreElements() )
+ {
+ while ( xNum->hasMoreElements() )
+ {
+ if ( nIter == _nPagePos )
+ {
+ Sequence< PropertyValue > xPropSeq;
+ Any aAny = xNum->nextElement();
+ if ( aAny >>= xPropSeq )
+ sRet = LoadInstance( xPropSeq, rImageList );
+ else
+ {
+ DBG_ERRORFILE( "XFormsPage::SetModel(): invalid instance" );
+ }
+ break;
+ }
+ else
+ {
+ xNum->nextElement();
+ nIter++;
+ }
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::SetModel(): exception caught" );
+ }
+ break;
+ }
+
+ case DGTSubmission :
+ {
+ DBG_ASSERT( TAB_PAGE_NOTFOUND == _nPagePos, "XFormsPage::SetModel(): invalid page position" );
+ try
+ {
+ Reference< XContainer > xContainer( _xModel->getSubmissions(), UNO_QUERY );
+ if ( xContainer.is() )
+ m_pNaviWin->AddContainerBroadcaster( xContainer );
+
+ Reference< XEnumerationAccess > xNumAccess( _xModel->getSubmissions(), UNO_QUERY );
+ if ( xNumAccess.is() )
+ {
+ Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
+ if ( xNum.is() && xNum->hasMoreElements() )
+ {
+ while ( xNum->hasMoreElements() )
+ {
+ Reference< XPropertySet > xPropSet;
+ Any aAny = xNum->nextElement();
+ if ( aAny >>= xPropSet )
+ AddEntry( xPropSet );
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::SetModel(): exception caught" );
+ }
+ break;
+ }
+
+ case DGTBinding :
+ {
+ DBG_ASSERT( TAB_PAGE_NOTFOUND == _nPagePos, "XFormsPage::SetModel(): invalid page position" );
+ try
+ {
+ Reference< XContainer > xContainer( _xModel->getBindings(), UNO_QUERY );
+ if ( xContainer.is() )
+ m_pNaviWin->AddContainerBroadcaster( xContainer );
+
+ Reference< XEnumerationAccess > xNumAccess( _xModel->getBindings(), UNO_QUERY );
+ if ( xNumAccess.is() )
+ {
+ Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
+ if ( xNum.is() && xNum->hasMoreElements() )
+ {
+ Image aImage1 = rImageList.GetImage( IID_ELEMENT );
+ Image aImage2 = rImageList.GetImage( IID_ELEMENT );
+ String sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
+ while ( xNum->hasMoreElements() )
+ {
+ Reference< XPropertySet > xPropSet;
+ Any aAny = xNum->nextElement();
+ if ( aAny >>= xPropSet )
+ {
+ String sEntry;
+ rtl::OUString sTemp;
+ xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
+ sEntry += String( sTemp );
+ sEntry += sDelim;
+ xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
+ sEntry += String( sTemp );
+
+ ItemNode* pNode = new ItemNode( xPropSet );
+ m_aItemList.InsertEntry(
+ sEntry, aImage1, aImage2, NULL, FALSE, LIST_APPEND, pNode );
+ }
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::SetModel(): exception caught" );
+ }
+ break;
+ }
+ default:
+ DBG_ERROR( "XFormsPage::SetModel: unknown group!" );
+ break;
+ }
+
+ EnableMenuItems( NULL );
+
+ return sRet;
+ }
+ //------------------------------------------------------------------------
+ void XFormsPage::ClearModel()
+ {
+ m_bHasModel = false;
+ m_aItemList.DeleteAndClear();
+ }
+ //------------------------------------------------------------------------
+ String XFormsPage::LoadInstance(
+ const Sequence< PropertyValue >& _xPropSeq, const ImageList& _rImgLst )
+ {
+ String sRet;
+ rtl::OUString sTemp;
+ rtl::OUString sInstModel = PN_INSTANCE_MODEL;
+ rtl::OUString sInstName = PN_INSTANCE_ID;
+ rtl::OUString sInstURL = PN_INSTANCE_URL;
+ const PropertyValue* pProps = _xPropSeq.getConstArray();
+ const PropertyValue* pPropsEnd = pProps + _xPropSeq.getLength();
+ for ( ; pProps != pPropsEnd; ++pProps )
+ {
+ if ( sInstModel.compareTo( pProps->Name ) == 0 )
+ {
+ Reference< css::xml::dom::XNode > xRoot;
+ if ( pProps->Value >>= xRoot )
+ {
+ try
+ {
+ Reference< XEventTarget > xTarget( xRoot, UNO_QUERY );
+ if ( xTarget.is() )
+ m_pNaviWin->AddEventBroadcaster( xTarget );
+
+ #if OSL_DEBUG_LEVEL > 0
+ css::xml::dom::NodeType eNodeType = xRoot->getNodeType(); (void)eNodeType;
+ #endif
+ ::rtl::OUString sNodeName =
+ m_xUIHelper->getNodeDisplayName( xRoot, m_pNaviWin->IsShowDetails() );
+ if ( sNodeName.getLength() == 0 )
+ sNodeName = xRoot->getNodeName();
+ if ( xRoot->hasChildNodes() )
+ AddChildren( NULL, _rImgLst, xRoot );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::LoadInstance(): exception caught" );
+ }
+ }
+ }
+ else if ( sInstName.compareTo( pProps->Name ) == 0 && ( pProps->Value >>= sTemp ) )
+ m_sInstanceName = sRet = sTemp;
+ else if ( sInstURL.compareTo( pProps->Name ) == 0 && ( pProps->Value >>= sTemp ) )
+ m_sInstanceURL = sTemp;
+ }
+
+ return sRet;
+ }
+
+ //------------------------------------------------------------------------
+ bool XFormsPage::DoMenuAction( USHORT _nMenuID )
+ {
+ return DoToolBoxAction( _nMenuID );
+ }
+
+ //------------------------------------------------------------------------
+ void XFormsPage::EnableMenuItems( Menu* _pMenu )
+ {
+ BOOL bEnableAdd = FALSE;
+ BOOL bEnableEdit = FALSE;
+ BOOL bEnableRemove = FALSE;
+
+ SvLBoxEntry* pEntry = m_aItemList.FirstSelected();
+ if ( pEntry )
+ {
+ bEnableAdd = TRUE;
+ bool bSubmitChild = false;
+ if ( DGTSubmission == m_eGroup && m_aItemList.GetParent( pEntry ) )
+ {
+ pEntry = m_aItemList.GetParent( pEntry );
+ bSubmitChild = true;
+ }
+ ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
+ if ( pNode && ( pNode->m_xNode.is() || pNode->m_xPropSet.is() ) )
+ {
+ bEnableEdit = TRUE;
+ bEnableRemove = ( bSubmitChild != true );
+ if ( DGTInstance == m_eGroup && !m_aItemList.GetParent( pEntry ) )
+ bEnableRemove = FALSE;
+ if ( pNode->m_xNode.is() )
+ {
+ try
+ {
+ css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
+ if ( eChildType != css::xml::dom::NodeType_ELEMENT_NODE
+ && eChildType != css::xml::dom::NodeType_DOCUMENT_NODE )
+ {
+ bEnableAdd = FALSE;
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::EnableMenuItems(): exception caught" );
+ }
+ }
+ }
+ }
+ else if ( m_eGroup != DGTInstance )
+ bEnableAdd = TRUE;
+
+ m_aToolBox.EnableItem( TBI_ITEM_ADD, bEnableAdd );
+ m_aToolBox.EnableItem( TBI_ITEM_ADD_ELEMENT, bEnableAdd );
+ m_aToolBox.EnableItem( TBI_ITEM_ADD_ATTRIBUTE, bEnableAdd );
+ m_aToolBox.EnableItem( TBI_ITEM_EDIT, bEnableEdit );
+ m_aToolBox.EnableItem( TBI_ITEM_REMOVE, bEnableRemove );
+
+ if ( _pMenu )
+ {
+ _pMenu->EnableItem( TBI_ITEM_ADD, bEnableAdd );
+ _pMenu->EnableItem( TBI_ITEM_ADD_ELEMENT, bEnableAdd );
+ _pMenu->EnableItem( TBI_ITEM_ADD_ATTRIBUTE, bEnableAdd );
+ _pMenu->EnableItem( TBI_ITEM_EDIT, bEnableEdit );
+ _pMenu->EnableItem( TBI_ITEM_REMOVE, bEnableRemove );
+ }
+ if ( DGTInstance == m_eGroup )
+ {
+ USHORT nResId1 = RID_STR_DATANAV_EDIT_ELEMENT;
+ USHORT nResId2 = RID_STR_DATANAV_REMOVE_ELEMENT;
+ if ( pEntry )
+ {
+ ItemNode* pNode = static_cast< ItemNode* >( pEntry->GetUserData() );
+ if ( pNode && pNode->m_xNode.is() )
+ {
+ try
+ {
+ css::xml::dom::NodeType eChildType = pNode->m_xNode->getNodeType();
+ if ( eChildType == css::xml::dom::NodeType_ATTRIBUTE_NODE )
+ {
+ nResId1 = RID_STR_DATANAV_EDIT_ATTRIBUTE;
+ nResId2 = RID_STR_DATANAV_REMOVE_ATTRIBUTE;
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "XFormsPage::EnableMenuItems(): exception caught" );
+ }
+ }
+ }
+ m_aToolBox.SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( nResId1 ) );
+ m_aToolBox.SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( nResId2 ) );
+ if ( _pMenu )
+ {
+ _pMenu->SetItemText( TBI_ITEM_EDIT, SVX_RESSTR( nResId1 ) );
+ _pMenu->SetItemText( TBI_ITEM_REMOVE, SVX_RESSTR( nResId2 ) );
+ }
+ }
+ }
+
+
+ //========================================================================
+ // class DataNavigatorWindow
+ //========================================================================
+ DataNavigatorWindow::DataNavigatorWindow( Window* pParent, SfxBindings* pBindings ) :
+
+ Window( pParent, SVX_RES( RID_SVXWIN_DATANAVIGATOR ) ),
+
+ m_aModelsBox ( this, SVX_RES( LB_MODELS ) ),
+ m_aModelBtn ( this, SVX_RES( MB_MODELS ) ),
+ m_aTabCtrl ( this, SVX_RES( TC_ITEMS ) ),
+ m_aInstanceBtn ( this, SVX_RES( MB_INSTANCES ) ),
+
+ m_pInstPage ( NULL ),
+ m_pSubmissionPage ( NULL ),
+ m_pBindingPage ( NULL ),
+
+ m_nMinWidth ( 0 ),
+ m_nMinHeight ( 0 ),
+ m_nBorderHeight ( 0 ),
+ m_nLastSelectedPos ( LISTBOX_ENTRY_NOTFOUND ),
+ m_bShowDetails ( false ),
+ m_bIsNotifyDisabled ( false ),
+
+ m_aItemImageList ( SVX_RES( IL_ITEM_BMPS ) ),
+ m_aItemHCImageList ( SVX_RES( IL_ITEM_BMPS_HC ) ),
+ m_xDataListener ( new DataListener( this ) )
+
+ {
+ FreeResource();
+
+ // init minimal metric
+ m_a2Size = LogicToPixel( Size( 2, 2 ), MAP_APPFONT );
+ m_a3Size = LogicToPixel( Size( 3, 3 ), MAP_APPFONT );
+ Size aOutSz = GetOutputSizePixel();
+ Size aLogSize = PixelToLogic( aOutSz, MAP_APPFONT );
+ m_nMinWidth = aLogSize.Width();
+ m_nMinHeight = aLogSize.Height();
+ m_nBorderHeight = 4*m_a3Size.Height() +
+ m_aModelBtn.GetSizePixel().Height() + m_aInstanceBtn.GetSizePixel().Height();
+
+ // handler
+ m_aModelsBox.SetSelectHdl( LINK( this, DataNavigatorWindow, ModelSelectHdl ) );
+ Link aLink = LINK( this, DataNavigatorWindow, MenuSelectHdl );
+ m_aModelBtn.SetSelectHdl( aLink );
+ m_aInstanceBtn.SetSelectHdl( aLink );
+ aLink = LINK( this, DataNavigatorWindow, MenuActivateHdl );
+ m_aModelBtn.SetActivateHdl( aLink );
+ m_aInstanceBtn.SetActivateHdl( aLink );
+ m_aTabCtrl.SetActivatePageHdl( LINK( this, DataNavigatorWindow, ActivatePageHdl ) );
+ m_aUpdateTimer.SetTimeout( 2000 );
+ m_aUpdateTimer.SetTimeoutHdl( LINK( this, DataNavigatorWindow, UpdateHdl ) );
+
+ // init tabcontrol
+ m_aTabCtrl.Show();
+ sal_Int32 nPageId = TID_INSTANCE;
+ SvtViewOptions aViewOpt( E_TABDIALOG, CFGNAME_DATANAVIGATOR );
+ if ( aViewOpt.Exists() )
+ {
+ nPageId = aViewOpt.GetPageID();
+ aViewOpt.GetUserItem(CFGNAME_SHOWDETAILS) >>= m_bShowDetails;
+ }
+
+ Menu* pMenu = m_aInstanceBtn.GetPopupMenu();
+ pMenu->SetItemBits( MID_SHOW_DETAILS, MIB_CHECKABLE );
+ pMenu->CheckItem( MID_SHOW_DETAILS, m_bShowDetails );
+
+ m_aTabCtrl.SetCurPageId( static_cast< USHORT >( nPageId ) );
+ ActivatePageHdl( &m_aTabCtrl );
+
+ // get our frame
+ DBG_ASSERT( pBindings != NULL,
+ "DataNavigatorWindow::LoadModels(): no SfxBindings; can't get frame" );
+ m_xFrame = Reference<XFrame>(
+ pBindings->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(),
+ UNO_QUERY );
+ DBG_ASSERT( m_xFrame.is(), "DataNavigatorWindow::LoadModels(): no frame" );
+ // add frameaction listener
+ Reference< XFrameActionListener > xListener(
+ static_cast< XFrameActionListener* >( m_xDataListener.get() ), UNO_QUERY );
+ m_xFrame->addFrameActionListener( xListener );
+
+ // load xforms models of the current document
+ LoadModels();
+ }
+ //------------------------------------------------------------------------
+ DataNavigatorWindow::~DataNavigatorWindow()
+ {
+ SvtViewOptions aViewOpt( E_TABDIALOG, CFGNAME_DATANAVIGATOR );
+ aViewOpt.SetPageID( static_cast< sal_Int32 >( m_aTabCtrl.GetCurPageId() ) );
+ Any aAny;
+ aAny <<= m_bShowDetails;
+ aViewOpt.SetUserItem(CFGNAME_SHOWDETAILS,aAny);
+
+ delete m_pInstPage;
+ delete m_pSubmissionPage;
+ delete m_pBindingPage;
+
+ sal_Int32 i, nCount = m_aPageList.size();
+ for ( i = 0; i < nCount; ++i )
+ delete m_aPageList[i];
+ Reference< XFrameActionListener > xListener(
+ static_cast< XFrameActionListener* >( m_xDataListener.get() ), UNO_QUERY );
+ m_xFrame->removeFrameActionListener( xListener );
+ RemoveBroadcaster();
+ m_xDataListener.clear();
+ }
+
+ // -----------------------------------------------------------------------
+ IMPL_LINK( DataNavigatorWindow, ModelSelectHdl, ListBox *, pBox )
+ {
+ USHORT nPos = m_aModelsBox.GetSelectEntryPos();
+ // pBox == NULL, if you want to force a new fill.
+ if ( nPos != m_nLastSelectedPos || !pBox )
+ {
+ m_nLastSelectedPos = nPos;
+ ClearAllPageModels( pBox != NULL );
+ InitPages();
+ SetPageModel();
+ }
+
+ return 0;
+ }
+ // -----------------------------------------------------------------------
+ IMPL_LINK( DataNavigatorWindow, MenuSelectHdl, MenuButton *, pBtn )
+ {
+ bool bIsDocModified = false;
+ Reference< css::xforms::XFormsUIHelper1 > xUIHelper;
+ USHORT nSelectedPos = m_aModelsBox.GetSelectEntryPos();
+ ::rtl::OUString sSelectedModel( m_aModelsBox.GetEntry( nSelectedPos ) );
+ Reference< css::xforms::XModel > xModel;
+ try
+ {
+ Any aAny = m_xDataContainer->getByName( sSelectedModel );
+ if ( aAny >>= xModel )
+ xUIHelper = Reference< css::xforms::XFormsUIHelper1 >( xModel, UNO_QUERY );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
+ }
+ DBG_ASSERT( xUIHelper.is(), "DataNavigatorWindow::MenuSelectHdl(): no UIHelper" );
+
+ m_bIsNotifyDisabled = true;
+
+ if ( &m_aModelBtn == pBtn )
+ {
+ switch ( pBtn->GetCurItemId() )
+ {
+ case MID_MODELS_ADD :
+ {
+ AddModelDialog aDlg( this, false );
+ bool bShowDialog = true;
+ while ( bShowDialog )
+ {
+ bShowDialog = false;
+ if ( aDlg.Execute() == RET_OK )
+ {
+ String sNewName = aDlg.GetName();
+ sal_Bool bDocumentData = aDlg.GetModifyDoc();
+
+ if ( m_aModelsBox.GetEntryPos( sNewName ) != LISTBOX_ENTRY_NOTFOUND )
+ {
+ // error: model name already exists
+ ErrorBox aErrBox( this, SVX_RES( RID_ERR_DOUBLE_MODELNAME ) );
+ String sMessText = aErrBox.GetMessText();
+ sMessText.SearchAndReplace( MSG_VARIABLE, sNewName );
+ aErrBox.SetMessText( sMessText );
+ aErrBox.Execute();
+ bShowDialog = true;
+ }
+ else
+ {
+ try
+ {
+ // add new model to frame model
+ Reference< css::xforms::XModel > xNewModel(
+ xUIHelper->newModel( m_xFrameModel, sNewName ), UNO_SET_THROW );
+
+ Reference< XPropertySet > xModelProps( xNewModel, UNO_QUERY_THROW );
+ xModelProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) ),
+ makeAny( sal_Bool( !bDocumentData ) ) );
+
+ USHORT nNewPos = m_aModelsBox.InsertEntry( sNewName );
+ m_aModelsBox.SelectEntryPos( nNewPos );
+ ModelSelectHdl( &m_aModelsBox );
+ bIsDocModified = true;
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
+ }
+ }
+ }
+ }
+ break;
+ }
+ case MID_MODELS_EDIT :
+ {
+ AddModelDialog aDlg( this, true );
+ aDlg.SetName( sSelectedModel );
+
+ bool bDocumentData( false );
+ try
+ {
+ Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY_THROW );
+ Reference< XNameContainer > xXForms( xFormsSupp->getXForms(), UNO_SET_THROW );
+ Reference< XPropertySet > xModelProps( xXForms->getByName( sSelectedModel ), UNO_QUERY_THROW );
+ sal_Bool bExternalData = sal_False;
+ OSL_VERIFY( xModelProps->getPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) ) ) >>= bExternalData );
+ bDocumentData = ( bExternalData == sal_False );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ aDlg.SetModifyDoc( bDocumentData );
+
+ if ( aDlg.Execute() == RET_OK )
+ {
+ if ( aDlg.GetModifyDoc() != bool( bDocumentData ) )
+ {
+ bDocumentData = aDlg.GetModifyDoc();
+ try
+ {
+ Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY_THROW );
+ Reference< XNameContainer > xXForms( xFormsSupp->getXForms(), UNO_SET_THROW );
+ Reference< XPropertySet > xModelProps( xXForms->getByName( sSelectedModel ), UNO_QUERY_THROW );
+ xModelProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) ),
+ makeAny( sal_Bool( !bDocumentData ) ) );
+ bIsDocModified = true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ String sNewName = aDlg.GetName();
+ if ( sNewName.Len() > 0 && ( sNewName != String( sSelectedModel ) ) )
+ {
+ try
+ {
+ xUIHelper->renameModel( m_xFrameModel, sSelectedModel, sNewName );
+
+ m_aModelsBox.RemoveEntry( nSelectedPos );
+ nSelectedPos = m_aModelsBox.InsertEntry( sNewName );
+ m_aModelsBox.SelectEntryPos( nSelectedPos );
+ bIsDocModified = true;
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
+ }
+ }
+ }
+ break;
+ }
+ case MID_MODELS_REMOVE :
+ {
+ QueryBox aQBox( this, SVX_RES( RID_QRY_REMOVE_MODEL ) );
+ String sText = aQBox.GetMessText();
+ sText.SearchAndReplace( MODELNAME, sSelectedModel );
+ aQBox.SetMessText( sText );
+ if ( aQBox.Execute() == RET_YES )
+ {
+ try
+ {
+ xUIHelper->removeModel( m_xFrameModel, sSelectedModel );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
+ }
+ m_aModelsBox.RemoveEntry( nSelectedPos );
+ if ( m_aModelsBox.GetEntryCount() <= nSelectedPos )
+ nSelectedPos = m_aModelsBox.GetEntryCount() - 1;
+ m_aModelsBox.SelectEntryPos( nSelectedPos );
+ ModelSelectHdl( &m_aModelsBox );
+ bIsDocModified = true;
+ }
+ break;
+ }
+ default:
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" );
+ }
+ }
+ }
+ else if ( &m_aInstanceBtn == pBtn )
+ {
+ switch ( pBtn->GetCurItemId() )
+ {
+ case MID_INSTANCES_ADD :
+ {
+ AddInstanceDialog aDlg( this, false );
+ if ( aDlg.Execute() == RET_OK )
+ {
+ USHORT nInst = GetNewPageId();
+ ::rtl::OUString sName = aDlg.GetName();
+ ::rtl::OUString sURL = aDlg.GetURL();
+ bool bLinkOnce = aDlg.IsLinkInstance();
+ try
+ {
+ Reference< css::xml::dom::XDocument > xNewInst =
+ xUIHelper->newInstance( sName, sURL, !bLinkOnce );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
+ }
+ ModelSelectHdl( NULL );
+ m_aTabCtrl.SetCurPageId( nInst );
+ XFormsPage* pPage = GetCurrentPage( nInst );
+ pPage->SetInstanceName(sName);
+ pPage->SetInstanceURL(sURL);
+ pPage->SetLinkOnce(bLinkOnce);
+ ActivatePageHdl( &m_aTabCtrl );
+ bIsDocModified = true;
+ }
+ break;
+ }
+ case MID_INSTANCES_EDIT :
+ {
+ USHORT nId = 0;
+ XFormsPage* pPage = GetCurrentPage( nId );
+ if ( pPage )
+ {
+ AddInstanceDialog aDlg( this, true );
+ aDlg.SetName( pPage->GetInstanceName() );
+ aDlg.SetURL( pPage->GetInstanceURL() );
+ aDlg.SetLinkInstance( pPage->GetLinkOnce() );
+ String sOldName = aDlg.GetName();
+ if ( aDlg.Execute() == RET_OK )
+ {
+ String sNewName = aDlg.GetName();
+ ::rtl::OUString sURL = aDlg.GetURL();
+ bool bLinkOnce = aDlg.IsLinkInstance();
+ try
+ {
+ xUIHelper->renameInstance( sOldName,
+ sNewName,
+ sURL,
+ !bLinkOnce );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
+ }
+ pPage->SetInstanceName(sNewName);
+ pPage->SetInstanceURL(sURL);
+ pPage->SetLinkOnce(bLinkOnce);
+ m_aTabCtrl.SetPageText( nId, sNewName );
+ bIsDocModified = true;
+ }
+ }
+ break;
+ }
+ case MID_INSTANCES_REMOVE :
+ {
+ USHORT nId = 0;
+ XFormsPage* pPage = GetCurrentPage( nId );
+ if ( pPage )
+ {
+ String sInstName = pPage->GetInstanceName();
+ QueryBox aQBox( this, SVX_RES( RID_QRY_REMOVE_INSTANCE ) );
+ String sMessText = aQBox.GetMessText();
+ sMessText.SearchAndReplace( INSTANCENAME, sInstName );
+ aQBox.SetMessText( sMessText );
+ if ( aQBox.Execute() == RET_YES )
+ {
+ bool bDoRemove = false;
+ if ( nId > TID_INSTANCE )
+ {
+ PageList::iterator aPageListEnd = m_aPageList.end();
+ PageList::iterator aFoundPage =
+ std::find( m_aPageList.begin(), aPageListEnd, pPage );
+ if ( aFoundPage != aPageListEnd )
+ {
+ m_aPageList.erase( aFoundPage );
+ delete pPage;
+ bDoRemove = true;
+ }
+ }
+ else
+ {
+ DELETEZ( m_pInstPage );
+ bDoRemove = true;
+ }
+
+ if ( bDoRemove )
+ {
+ try
+ {
+ xUIHelper->removeInstance( sInstName );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): exception caught" );
+ }
+ m_aTabCtrl.RemovePage( nId );
+ m_aTabCtrl.SetCurPageId( TID_INSTANCE );
+ ModelSelectHdl( NULL );
+ bIsDocModified = true;
+ }
+ }
+ }
+ break;
+ }
+ case MID_SHOW_DETAILS :
+ {
+ m_bShowDetails = !m_bShowDetails;
+ m_aInstanceBtn.GetPopupMenu()->CheckItem( MID_SHOW_DETAILS, m_bShowDetails );
+ ModelSelectHdl( &m_aModelsBox );
+ break;
+ }
+ default:
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): wrong menu item" );
+ }
+ }
+ }
+ else
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuSelectHdl(): wrong button" );
+ }
+
+ m_bIsNotifyDisabled = false;
+
+ if ( bIsDocModified )
+ SetDocModified();
+ return 0;
+ }
+ // -----------------------------------------------------------------------
+ IMPL_LINK( DataNavigatorWindow, MenuActivateHdl, MenuButton *, pBtn )
+ {
+ Menu* pMenu = pBtn->GetPopupMenu();
+
+ if ( &m_aInstanceBtn == pBtn )
+ {
+ bool bIsInstPage = ( m_aTabCtrl.GetCurPageId() >= TID_INSTANCE );
+ pMenu->EnableItem( MID_INSTANCES_EDIT, bIsInstPage );
+ pMenu->EnableItem( MID_INSTANCES_REMOVE,
+ bIsInstPage && m_aTabCtrl.GetPageCount() > MIN_PAGE_COUNT );
+ pMenu->EnableItem( MID_SHOW_DETAILS, bIsInstPage );
+ }
+ else if ( &m_aModelBtn == pBtn )
+ {
+ // we need at least one model!
+ pMenu->EnableItem( MID_MODELS_REMOVE, m_aModelsBox.GetEntryCount() > 1 );
+ }
+ else
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::MenuActivateHdl(): wrong button" );
+ }
+ return 0;
+ }
+ // -----------------------------------------------------------------------
+ IMPL_LINK( DataNavigatorWindow, ActivatePageHdl, TabControl *, EMPTYARG )
+ {
+ USHORT nId = 0;
+ XFormsPage* pPage = GetCurrentPage( nId );
+ if ( pPage )
+ {
+ m_aTabCtrl.SetTabPage( nId, pPage );
+ if ( m_xDataContainer.is() && !pPage->HasModel() )
+ SetPageModel();
+ }
+
+ return 0;
+ }
+ // -----------------------------------------------------------------------
+ IMPL_LINK( DataNavigatorWindow, UpdateHdl, Timer *, EMPTYARG )
+ {
+ ModelSelectHdl( NULL );
+ return 0;
+ }
+ // -----------------------------------------------------------------------
+ XFormsPage* DataNavigatorWindow::GetCurrentPage( USHORT& rCurId )
+ {
+ rCurId = m_aTabCtrl.GetCurPageId();
+ XFormsPage* pPage = NULL;
+ switch ( rCurId )
+ {
+ case TID_SUBMISSION:
+ {
+ if ( !m_pSubmissionPage )
+ m_pSubmissionPage = new XFormsPage( &m_aTabCtrl, this, DGTSubmission );
+ pPage = m_pSubmissionPage;
+ break;
+ }
+
+ case TID_BINDINGS:
+ {
+ if ( !m_pBindingPage )
+ m_pBindingPage = new XFormsPage( &m_aTabCtrl, this, DGTBinding );
+ pPage = m_pBindingPage;
+ break;
+ }
+
+ case TID_INSTANCE:
+ {
+ if ( !m_pInstPage )
+ m_pInstPage = new XFormsPage( &m_aTabCtrl, this, DGTInstance );
+ pPage = m_pInstPage;
+ break;
+ }
+ }
+
+ if ( rCurId > TID_INSTANCE )
+ {
+ USHORT nPos = m_aTabCtrl.GetPagePos( rCurId );
+ if ( HasFirstInstancePage() && nPos > 0 )
+ nPos--;
+ if ( m_aPageList.size() > nPos )
+ pPage = m_aPageList[nPos];
+ else
+ {
+ pPage = new XFormsPage( &m_aTabCtrl, this, DGTInstance );
+ m_aPageList.push_back( pPage );
+ }
+ }
+
+ return pPage;
+ }
+ // -----------------------------------------------------------------------
+ void DataNavigatorWindow::LoadModels()
+ {
+ if ( !m_xFrameModel.is() )
+ {
+ // get model of active frame
+ Reference< XController > xCtrl = m_xFrame->getController();
+ if ( xCtrl.is() )
+ {
+ try
+ {
+ m_xFrameModel = xCtrl->getModel();
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::LoadModels(): exception caught" );
+ }
+ }
+ }
+
+ if ( m_xFrameModel.is() )
+ {
+ try
+ {
+ ::rtl::OUString sURL = m_xFrameModel->getURL();
+ Reference< css::xforms::XFormsSupplier > xFormsSupp( m_xFrameModel, UNO_QUERY );
+ if ( xFormsSupp.is() )
+ {
+ Reference< XNameContainer > xContainer = xFormsSupp->getXForms();
+ if ( xContainer.is() )
+ {
+ m_xDataContainer = xContainer;
+ Sequence< ::rtl::OUString > aNameList = m_xDataContainer->getElementNames();
+ sal_Int32 i, nCount = aNameList.getLength();
+ ::rtl::OUString* pNames = aNameList.getArray();
+ for ( i = 0; i < nCount; ++i )
+ {
+ Any aAny = m_xDataContainer->getByName( pNames[i] );
+ Reference< css::xforms::XModel > xFormsModel;
+ if ( aAny >>= xFormsModel )
+ m_aModelsBox.InsertEntry( xFormsModel->getID() );
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::LoadModels(): exception caught" );
+ }
+ }
+
+ if ( m_aModelsBox.GetEntryCount() > 0 )
+ {
+ m_aModelsBox.SelectEntryPos(0);
+ ModelSelectHdl( &m_aModelsBox );
+ }
+ }
+ // -----------------------------------------------------------------------
+ void DataNavigatorWindow::SetPageModel()
+ {
+ rtl::OUString sModel( m_aModelsBox.GetSelectEntry() );
+ try
+ {
+ Any aAny = m_xDataContainer->getByName( sModel );
+ Reference< css::xforms::XModel > xFormsModel;
+ if ( aAny >>= xFormsModel )
+ {
+ USHORT nPagePos = TAB_PAGE_NOTFOUND;
+ USHORT nId = 0;
+ XFormsPage* pPage = GetCurrentPage( nId );
+ DBG_ASSERT( pPage, "DataNavigatorWindow::SetPageModel(): no page" );
+ if ( nId >= TID_INSTANCE )
+ // instance page
+ nPagePos = m_aTabCtrl.GetPagePos( nId );
+ m_bIsNotifyDisabled = true;
+ String sText = pPage->SetModel( xFormsModel, nPagePos );
+ m_bIsNotifyDisabled = false;
+ if ( sText.Len() > 0 )
+ m_aTabCtrl.SetPageText( nId, sText );
+ }
+ }
+ catch ( NoSuchElementException& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): no such element" );
+ }
+ catch( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): unexpected exception" );
+ }
+ }
+ // -----------------------------------------------------------------------
+ void DataNavigatorWindow::InitPages()
+ {
+ rtl::OUString sModel( m_aModelsBox.GetSelectEntry() );
+ try
+ {
+ Any aAny = m_xDataContainer->getByName( sModel );
+ Reference< css::xforms::XModel > xModel;
+ if ( aAny >>= xModel )
+ {
+ Reference< XEnumerationAccess > xNumAccess( xModel->getInstances(), UNO_QUERY );
+ if ( xNumAccess.is() )
+ {
+ Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
+ if ( xNum.is() && xNum->hasMoreElements() )
+ {
+ sal_Int32 nAlreadyLoadedCount = m_aPageList.size();
+ if ( !HasFirstInstancePage() && nAlreadyLoadedCount > 0 )
+ nAlreadyLoadedCount--;
+ sal_Int32 nIdx = 0;
+ while ( xNum->hasMoreElements() )
+ {
+ if ( nIdx > nAlreadyLoadedCount )
+ {
+ Sequence< PropertyValue > xPropSeq;
+ if ( xNum->nextElement() >>= xPropSeq )
+ CreateInstancePage( xPropSeq );
+ else
+ {
+ DBG_ERRORFILE( "DataNavigator::InitPages(): invalid instance" );
+ }
+ }
+ else
+ xNum->nextElement();
+ nIdx++;
+ }
+ }
+ }
+ }
+ }
+ catch ( NoSuchElementException& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): no such element" );
+ }
+ catch( Exception& )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::SetPageModel(): unexpected exception" );
+ }
+ }
+ // -----------------------------------------------------------------------
+ void DataNavigatorWindow::ClearAllPageModels( bool bClearPages )
+ {
+ if ( m_pInstPage )
+ m_pInstPage->ClearModel();
+ if ( m_pSubmissionPage )
+ m_pSubmissionPage->ClearModel();
+ if ( m_pBindingPage )
+ m_pBindingPage->ClearModel();
+
+ sal_Int32 i, nCount = m_aPageList.size();
+ for ( i = 0; i < nCount; ++i )
+ {
+ XFormsPage* pPage = m_aPageList[i];
+ pPage->ClearModel();
+ if ( bClearPages )
+ delete pPage;
+ }
+
+ if ( bClearPages )
+ {
+ m_aPageList.clear();
+ while ( m_aTabCtrl.GetPageCount() > MIN_PAGE_COUNT )
+ m_aTabCtrl.RemovePage( m_aTabCtrl.GetPageId( 1 ) );
+ }
+ }
+ // -----------------------------------------------------------------------
+ void DataNavigatorWindow::CreateInstancePage( const Sequence< PropertyValue >& _xPropSeq )
+ {
+ rtl::OUString sInstName;
+ rtl::OUString sID( PN_INSTANCE_ID );
+ const PropertyValue* pProps = _xPropSeq.getConstArray();
+ const PropertyValue* pPropsEnd = pProps + _xPropSeq.getLength();
+ for ( ; pProps != pPropsEnd; ++pProps )
+ {
+ if ( sID.compareTo( pProps->Name ) == 0 )
+ {
+ pProps->Value >>= sInstName;
+ break;
+ }
+ }
+
+ USHORT nPageId = GetNewPageId();
+ if ( sInstName.getLength() == 0 )
+ {
+ DBG_ERRORFILE( "DataNavigatorWindow::CreateInstancePage(): instance without name" );
+ String sTemp = String::CreateFromAscii( "untitled" );
+ sTemp += String::CreateFromInt32( nPageId );
+ sInstName = sTemp;
+ }
+ m_aTabCtrl.InsertPage( nPageId, sInstName, m_aTabCtrl.GetPageCount() - 2 );
+ }
+
+ //------------------------------------------------------------------------
+ bool DataNavigatorWindow::HasFirstInstancePage() const
+ {
+ return ( m_aTabCtrl.GetPageId( 0 ) == TID_INSTANCE );
+ }
+
+ //------------------------------------------------------------------------
+ USHORT DataNavigatorWindow::GetNewPageId() const
+ {
+ USHORT i, nMax = 0, nCount = m_aTabCtrl.GetPageCount();
+ for ( i = 0; i < nCount; ++i )
+ {
+ if ( nMax < m_aTabCtrl.GetPageId(i) )
+ nMax = m_aTabCtrl.GetPageId(i);
+ }
+ return ( nMax + 1 );
+ }
+
+ //------------------------------------------------------------------------
+ void DataNavigatorWindow::Resize()
+ {
+ Window::Resize();
+
+ Size aOutSz = GetOutputSizePixel();
+ long nWidth = Max( aOutSz.Width(), m_nMinWidth );
+ long nHeight = Max( aOutSz.Height(), m_nMinHeight );
+
+ Size aSz = m_aModelsBox.GetSizePixel();
+ aSz.Width() = nWidth - 3*m_a3Size.Width() - m_aModelBtn.GetSizePixel().Width();
+ m_aModelsBox.SetSizePixel( aSz );
+ Point aPos = m_aModelBtn.GetPosPixel();
+ aPos.X() = m_aModelsBox.GetPosPixel().X() + aSz.Width() + m_a3Size.Width();
+ m_aModelBtn.SetPosPixel( aPos );
+
+ aSz = m_aTabCtrl.GetSizePixel();
+ aSz.Width() = nWidth - 2*m_a3Size.Width();
+ aSz.Height() = nHeight - m_nBorderHeight;
+ m_aTabCtrl.SetSizePixel( aSz );
+ // Instance button positioning
+ aPos = m_aInstanceBtn.GetPosPixel();
+ // right aligned
+ aPos.X() = nWidth - m_aInstanceBtn.GetSizePixel().Width() - m_a3Size.Width();
+ // under the tabcontrol
+ aPos.Y() = m_aTabCtrl.GetPosPixel().Y() + aSz.Height() + m_a3Size.Height();
+ m_aInstanceBtn.SetPosPixel( aPos );
+ }
+
+ //------------------------------------------------------------------------
+ void DataNavigatorWindow::SetDocModified()
+ {
+ SfxObjectShell* pCurrentDoc = SfxObjectShell::Current();
+ DBG_ASSERT( pCurrentDoc, "DataNavigatorWindow::SetDocModified(): no objectshell" );
+ if ( !pCurrentDoc->IsModified() && pCurrentDoc->IsEnableSetModified() )
+ pCurrentDoc->SetModified();
+ }
+
+ //------------------------------------------------------------------------
+ void DataNavigatorWindow::NotifyChanges( bool _bLoadAll )
+ {
+ if ( !m_bIsNotifyDisabled )
+ {
+ if ( _bLoadAll )
+ {
+ // reset all members
+ RemoveBroadcaster();
+ m_xDataContainer.clear();
+ m_xFrameModel.clear();
+ m_aModelsBox.Clear();
+ m_nLastSelectedPos = LISTBOX_ENTRY_NOTFOUND;
+ // for a reload
+ LoadModels();
+ }
+ else
+ m_aUpdateTimer.Start();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void DataNavigatorWindow::AddContainerBroadcaster( const XContainer_ref& xContainer )
+ {
+ Reference< XContainerListener > xListener(
+ static_cast< XContainerListener* >( m_xDataListener.get() ), UNO_QUERY );
+ xContainer->addContainerListener( xListener );
+ m_aContainerList.push_back( xContainer );
+ }
+
+ //------------------------------------------------------------------------
+ void DataNavigatorWindow::AddEventBroadcaster( const XEventTarget_ref& xTarget )
+ {
+ Reference< XEventListener > xListener(
+ static_cast< XEventListener* >( m_xDataListener.get() ), UNO_QUERY );
+ xTarget->addEventListener( EVENTTYPE_CHARDATA, xListener, true );
+ xTarget->addEventListener( EVENTTYPE_CHARDATA, xListener, false );
+ xTarget->addEventListener( EVENTTYPE_ATTR, xListener, true );
+ xTarget->addEventListener( EVENTTYPE_ATTR, xListener, false );
+ m_aEventTargetList.push_back( xTarget );
+ }
+
+ //------------------------------------------------------------------------
+ void DataNavigatorWindow::RemoveBroadcaster()
+ {
+ Reference< XContainerListener > xContainerListener(
+ static_cast< XContainerListener* >( m_xDataListener.get() ), UNO_QUERY );
+ sal_Int32 i, nCount = m_aContainerList.size();
+ for ( i = 0; i < nCount; ++i )
+ m_aContainerList[i]->removeContainerListener( xContainerListener );
+ Reference< XEventListener > xEventListener(
+ static_cast< XEventListener* >( m_xDataListener.get() ), UNO_QUERY );
+ nCount = m_aEventTargetList.size();
+ for ( i = 0; i < nCount; ++i )
+ {
+ m_aEventTargetList[i]->removeEventListener( EVENTTYPE_CHARDATA, xEventListener, true );
+ m_aEventTargetList[i]->removeEventListener( EVENTTYPE_CHARDATA, xEventListener, false );
+ m_aEventTargetList[i]->removeEventListener( EVENTTYPE_ATTR, xEventListener, true );
+ m_aEventTargetList[i]->removeEventListener( EVENTTYPE_ATTR, xEventListener, false );
+ }
+ }
+
+ //========================================================================
+ // class DataNavigator
+ //========================================================================
+ DBG_NAME(DataNavigator)
+ //------------------------------------------------------------------------
+ DataNavigator::DataNavigator( SfxBindings* _pBindings, SfxChildWindow* _pMgr, Window* _pParent ) :
+
+ SfxDockingWindow( _pBindings, _pMgr, _pParent,
+ WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_ROLLABLE|WB_3DLOOK|WB_DOCKABLE) ),
+ SfxControllerItem( SID_FM_DATANAVIGATOR_CONTROL, *_pBindings ),
+
+ m_aDataWin( this, _pBindings )
+
+ {
+ DBG_CTOR(DataNavigator,NULL);
+
+ SetHelpId( HID_DATA_NAVIGATOR_WIN );
+ SetText( SVX_RES( RID_STR_DATANAVIGATOR ) );
+
+ Size aSize = m_aDataWin.GetOutputSizePixel();
+ Size aLogSize = PixelToLogic( aSize, MAP_APPFONT );
+ SfxDockingWindow::SetFloatingSize( aLogSize );
+
+ m_aDataWin.Show();
+ }
+
+ //------------------------------------------------------------------------
+ DataNavigator::~DataNavigator()
+ {
+ DBG_DTOR(DataNavigator,NULL);
+ }
+
+ //-----------------------------------------------------------------------
+ void DataNavigator::Update( FmFormShell* /*pFormShell*/ )
+ {
+ }
+ //-----------------------------------------------------------------------
+ void DataNavigator::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
+ {
+ if ( !pState || SID_FM_DATANAVIGATOR_CONTROL != nSID )
+ return;
+
+ if ( eState >= SFX_ITEM_AVAILABLE )
+ {
+ FmFormShell* pShell = PTR_CAST( FmFormShell,((SfxObjectItem*)pState)->GetShell() );
+ Update( pShell );
+ }
+ else
+ Update( NULL );
+ }
+
+ //-----------------------------------------------------------------------
+ void DataNavigator::GetFocus()
+ {
+ SfxDockingWindow::GetFocus();
+ }
+
+ //-----------------------------------------------------------------------
+ sal_Bool DataNavigator::Close()
+ {
+ Update( NULL );
+ return SfxDockingWindow::Close();
+ }
+
+ //-----------------------------------------------------------------------
+ Size DataNavigator::CalcDockingSize( SfxChildAlignment eAlign )
+ {
+ if ( ( eAlign == SFX_ALIGN_TOP ) || ( eAlign == SFX_ALIGN_BOTTOM ) )
+ return Size();
+
+ return SfxDockingWindow::CalcDockingSize( eAlign );
+ }
+
+ //-----------------------------------------------------------------------
+ SfxChildAlignment DataNavigator::CheckAlignment( SfxChildAlignment eActAlign, SfxChildAlignment eAlign )
+ {
+ switch ( eAlign )
+ {
+ case SFX_ALIGN_LEFT:
+ case SFX_ALIGN_RIGHT:
+ case SFX_ALIGN_NOALIGNMENT:
+ return eAlign;
+ default:
+ break;
+ }
+ return eActAlign;
+ }
+
+ //------------------------------------------------------------------------
+ void DataNavigator::Resize()
+ {
+ SfxDockingWindow::Resize();
+
+ Size aLogOutputSize = PixelToLogic( GetOutputSizePixel(), MAP_APPFONT );
+ Size aLogExplSize = aLogOutputSize;
+ aLogExplSize.Width() -= 2;
+ aLogExplSize.Height() -= 2;
+
+ Point aExplPos = LogicToPixel( Point(1,1), MAP_APPFONT );
+ Size aExplSize = LogicToPixel( aLogExplSize, MAP_APPFONT );
+
+ m_aDataWin.SetPosSizePixel( aExplPos, aExplSize );
+ }
+
+
+ //========================================================================
+ // class NavigatorFrameManager
+ //========================================================================
+
+ //-----------------------------------------------------------------------
+ SFX_IMPL_DOCKINGWINDOW( DataNavigatorManager, SID_FM_SHOW_DATANAVIGATOR )
+
+ //-----------------------------------------------------------------------
+ DataNavigatorManager::DataNavigatorManager(
+ Window* _pParent, sal_uInt16 _nId, SfxBindings* _pBindings, SfxChildWinInfo* _pInfo ) :
+
+ SfxChildWindow( _pParent, _nId )
+
+ {
+ pWindow = new DataNavigator( _pBindings, this, _pParent );
+ eChildAlignment = SFX_ALIGN_RIGHT;
+ pWindow->SetSizePixel( Size( 250, 400 ) );
+ ( (SfxDockingWindow*)pWindow )->Initialize( _pInfo );
+ }
+
+ //========================================================================
+ // class AddDataItemDialog
+ //========================================================================
+
+ AddDataItemDialog::AddDataItemDialog(
+ Window* pParent, ItemNode* _pNode,
+ const Reference< css::xforms::XFormsUIHelper1 >& _rUIHelper ) :
+
+ ModalDialog( pParent, SVX_RES( RID_SVXDLG_ADD_DATAITEM ) ),
+
+ m_aItemFL ( this, SVX_RES( FL_ITEM ) ),
+ m_aNameFT ( this, SVX_RES( FT_NAME ) ),
+ m_aNameED ( this, SVX_RES( ED_NAME ) ),
+ m_aDefaultFT ( this, SVX_RES( FT_DEFAULT ) ),
+ m_aDefaultED ( this, SVX_RES( ED_DEFAULT ) ),
+ m_aDefaultBtn ( this, SVX_RES( PB_DEFAULT ) ),
+ m_aSettingsFL ( this, SVX_RES( FL_SETTINGS ) ),
+ m_aDataTypeFT ( this, SVX_RES( FT_DATATYPE ) ),
+ m_aDataTypeLB ( this, SVX_RES( LB_DATATYPE ) ),
+ m_aRequiredCB ( this, SVX_RES( CB_REQUIRED ) ),
+ m_aRequiredBtn ( this, SVX_RES( PB_REQUIRED ) ),
+ m_aRelevantCB ( this, SVX_RES( CB_RELEVANT ) ),
+ m_aRelevantBtn ( this, SVX_RES( PB_RELEVANT ) ),
+ m_aConstraintCB ( this, SVX_RES( CB_CONSTRAINT ) ),
+ m_aConstraintBtn( this, SVX_RES( PB_CONSTRAINT ) ),
+ m_aReadonlyCB ( this, SVX_RES( CB_READONLY ) ),
+ m_aReadonlyBtn ( this, SVX_RES( PB_READONLY ) ),
+ m_aCalculateCB ( this, SVX_RES( CB_CALCULATE ) ),
+ m_aCalculateBtn ( this, SVX_RES( PB_CALCULATE ) ),
+ m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN ) ),
+ m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK ) ),
+ m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC ) ),
+ m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP ) ),
+
+ m_xUIHelper ( _rUIHelper ),
+ m_pItemNode ( _pNode ),
+ m_eItemType ( DITNone ),
+ m_sFL_Element ( SVX_RES( STR_FIXEDLINE_ELEMENT ) ),
+ m_sFL_Attribute ( SVX_RES( STR_FIXEDLINE_ATTRIBUTE ) ),
+ m_sFL_Binding ( SVX_RES( STR_FIXEDLINE_BINDING ) ),
+ m_sFT_BindingExp( SVX_RES( STR_FIXEDTEXT_BINDING ) )
+
+ {
+ FreeResource();
+ m_aDataTypeLB.SetDropDownLineCount( 10 );
+
+ InitDialog();
+ InitFromNode();
+ InitDataTypeBox();
+ CheckHdl( NULL );
+ }
+
+ //------------------------------------------------------------------------
+ AddDataItemDialog::~AddDataItemDialog()
+ {
+ if ( m_xTempBinding.is() )
+ {
+ Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
+ if ( xModel.is() )
+ {
+ try
+ {
+ Reference < XSet > xBindings = xModel->getBindings();
+ if ( xBindings.is() )
+ xBindings->remove( makeAny( m_xTempBinding ) );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddDataItemDialog::Dtor(): exception caught" );
+ }
+ }
+ }
+ if( m_xUIHelper.is() && m_xBinding.is() )
+ {
+ // remove binding, if it does not convey 'useful' information
+ m_xUIHelper->removeBindingIfUseless( m_xBinding );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( AddDataItemDialog, CheckHdl, CheckBox *, pBox )
+ {
+ // Condition buttons are only enable if their check box is checked
+ m_aReadonlyBtn.Enable( m_aReadonlyCB.IsChecked() );
+ m_aRequiredBtn.Enable( m_aRequiredCB.IsChecked() );
+ m_aRelevantBtn.Enable( m_aRelevantCB.IsChecked() );
+ m_aConstraintBtn.Enable( m_aConstraintCB.IsChecked() );
+ m_aCalculateBtn.Enable( m_aCalculateCB.IsChecked() );
+
+ if ( pBox && m_xTempBinding.is() )
+ {
+ ::rtl::OUString sTemp, sPropName;
+ if ( &m_aRequiredCB == pBox )
+ sPropName = PN_REQUIRED_EXPR;
+ else if ( &m_aRelevantCB == pBox )
+ sPropName = PN_RELEVANT_EXPR;
+ else if ( &m_aConstraintCB == pBox )
+ sPropName = PN_CONSTRAINT_EXPR;
+ else if ( &m_aReadonlyCB == pBox )
+ sPropName = PN_READONLY_EXPR;
+ else if ( &m_aCalculateCB == pBox )
+ sPropName = PN_CALCULATE_EXPR;
+ bool bIsChecked = ( pBox->IsChecked() != FALSE );
+ m_xTempBinding->getPropertyValue( sPropName ) >>= sTemp;
+ if ( bIsChecked && sTemp.getLength() == 0 )
+ sTemp = TRUE_VALUE;
+ else if ( !bIsChecked && sTemp.getLength() > 0 )
+ sTemp = ::rtl::OUString();
+ m_xTempBinding->setPropertyValue( sPropName, makeAny( sTemp ) );
+ }
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( AddDataItemDialog, ConditionHdl, PushButton *, pBtn )
+ {
+ ::rtl::OUString sTemp, sPropName;
+ if ( &m_aDefaultBtn == pBtn )
+ sPropName = PN_BINDING_EXPR;
+ else if ( &m_aRequiredBtn == pBtn )
+ sPropName = PN_REQUIRED_EXPR;
+ else if ( &m_aRelevantBtn == pBtn )
+ sPropName = PN_RELEVANT_EXPR;
+ else if ( &m_aConstraintBtn == pBtn )
+ sPropName = PN_CONSTRAINT_EXPR;
+ else if ( &m_aReadonlyBtn == pBtn )
+ sPropName = PN_READONLY_EXPR;
+ else if ( &m_aCalculateBtn == pBtn )
+ sPropName = PN_CALCULATE_EXPR;
+ AddConditionDialog aDlg( this, sPropName, m_xTempBinding );
+ bool bIsDefBtn = ( &m_aDefaultBtn == pBtn );
+ String sCondition;
+ if ( bIsDefBtn )
+ sCondition = m_aDefaultED.GetText();
+ else
+ {
+ m_xTempBinding->getPropertyValue( sPropName ) >>= sTemp;
+ if ( sTemp.getLength() == 0 )
+ sTemp = TRUE_VALUE;
+ sCondition = sTemp;
+ }
+ aDlg.SetCondition( sCondition );
+
+ if ( aDlg.Execute() == RET_OK )
+ {
+ String sNewCondition = aDlg.GetCondition();
+ if ( bIsDefBtn )
+ m_aDefaultED.SetText( sNewCondition );
+ else
+ {
+
+ m_xTempBinding->setPropertyValue(
+ sPropName, makeAny( ::rtl::OUString( sNewCondition ) ) );
+ }
+ }
+ return 0;
+ }
+
+ void copyPropSet( const Reference< XPropertySet >& xFrom, Reference< XPropertySet >& xTo )
+ {
+ DBG_ASSERT( xFrom.is(), "copyPropSet(): no source" );
+ DBG_ASSERT( xTo.is(), "copyPropSet(): no target" );
+
+ try
+ {
+ // get property names & infos, and iterate over target properties
+ Sequence< Property > aProperties = xTo->getPropertySetInfo()->getProperties();
+ sal_Int32 nProperties = aProperties.getLength();
+ const Property* pProperties = aProperties.getConstArray();
+ Reference< XPropertySetInfo > xFromInfo = xFrom->getPropertySetInfo();
+ for ( sal_Int32 i = 0; i < nProperties; ++i )
+ {
+ const ::rtl::OUString& rName = pProperties[i].Name;
+
+ // if both set have the property, copy the value
+ // (catch and ignore exceptions, if any)
+ if ( xFromInfo->hasPropertyByName( rName ) )
+ {
+ // don't set readonly properties
+ Property aProperty = xFromInfo->getPropertyByName( rName );
+ if ( ( aProperty.Attributes & PropertyAttribute::READONLY ) == 0 )
+ xTo->setPropertyValue(rName, xFrom->getPropertyValue( rName ));
+ }
+ // else: no property? then ignore.
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "copyPropSet(): exception caught" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( AddDataItemDialog, OKHdl, OKButton *, EMPTYARG )
+ {
+ bool bIsHandleBinding = ( DITBinding == m_eItemType );
+ bool bIsHandleText = ( DITText == m_eItemType );
+ ::rtl::OUString sNewName( m_aNameED.GetText() );
+
+ if ( ( !bIsHandleBinding && !bIsHandleText && !m_xUIHelper->isValidXMLName( sNewName ) ) ||
+ ( bIsHandleBinding && sNewName.getLength() == 0 ) )
+ {
+ // Error and don't close the dialog
+ ErrorBox aErrBox( this, SVX_RES( RID_ERR_INVALID_XMLNAME ) );
+ String sMessText = aErrBox.GetMessText();
+ sMessText.SearchAndReplace( MSG_VARIABLE, sNewName );
+ aErrBox.SetMessText( sMessText );
+ aErrBox.Execute();
+ return 0;
+ }
+
+ ::rtl::OUString sDataType( m_aDataTypeLB.GetSelectEntry() );
+ m_xTempBinding->setPropertyValue( PN_BINDING_TYPE, makeAny( sDataType ) );
+
+ if ( bIsHandleBinding )
+ {
+ // copy properties from temp binding to original binding
+ copyPropSet( m_xTempBinding, m_pItemNode->m_xPropSet );
+ try
+ {
+ ::rtl::OUString sValue = m_aNameED.GetText();
+ m_pItemNode->m_xPropSet->setPropertyValue( PN_BINDING_ID, makeAny( sValue ) );
+ sValue = m_aDefaultED.GetText();
+ m_pItemNode->m_xPropSet->setPropertyValue( PN_BINDING_EXPR, makeAny( sValue ) );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddDataDialog::OKHdl(): exception caught" );
+ }
+ }
+ else
+ {
+ // copy properties from temp binding to original binding
+ copyPropSet( m_xTempBinding, m_xBinding );
+ try
+ {
+ if ( bIsHandleText )
+ m_xUIHelper->setNodeValue( m_pItemNode->m_xNode, m_aDefaultED.GetText() );
+ else
+ {
+ Reference< css::xml::dom::XNode > xNewNode =
+ m_xUIHelper->renameNode( m_pItemNode->m_xNode, m_aNameED.GetText() );
+ m_xUIHelper->setNodeValue( xNewNode, m_aDefaultED.GetText() );
+ m_pItemNode->m_xNode = xNewNode;
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddDataDialog::OKHdl(): exception caught" );
+ }
+ }
+ // then close the dialog
+ EndDialog( RET_OK );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ void AddDataItemDialog::InitDialog()
+ {
+ // set handler
+ Link aLink = LINK( this, AddDataItemDialog, CheckHdl );
+ m_aRequiredCB.SetClickHdl( aLink );
+ m_aRelevantCB.SetClickHdl( aLink );
+ m_aConstraintCB.SetClickHdl( aLink );
+ m_aReadonlyCB.SetClickHdl( aLink );
+ m_aCalculateCB.SetClickHdl( aLink );
+
+ aLink = LINK( this, AddDataItemDialog, ConditionHdl );
+ m_aDefaultBtn.SetClickHdl( aLink );
+ m_aRequiredBtn.SetClickHdl( aLink );
+ m_aRelevantBtn.SetClickHdl( aLink );
+ m_aConstraintBtn.SetClickHdl( aLink );
+ m_aReadonlyBtn.SetClickHdl( aLink );
+ m_aCalculateBtn.SetClickHdl( aLink );
+
+ m_aOKBtn.SetClickHdl( LINK( this, AddDataItemDialog, OKHdl ) );
+ }
+
+ //------------------------------------------------------------------------
+ void AddDataItemDialog::InitFromNode()
+ {
+ if ( m_pItemNode )
+ {
+ if ( m_pItemNode->m_xNode.is() )
+ {
+ try
+ {
+ // detect type of the node
+ css::xml::dom::NodeType eChildType = m_pItemNode->m_xNode->getNodeType();
+ switch ( eChildType )
+ {
+ case css::xml::dom::NodeType_ATTRIBUTE_NODE:
+ m_eItemType = DITAttribute;
+ break;
+ case css::xml::dom::NodeType_ELEMENT_NODE:
+ m_eItemType = DITElement;
+ break;
+ case css::xml::dom::NodeType_TEXT_NODE:
+ m_eItemType = DITText;
+ break;
+ default:
+ DBG_ERROR( "AddDataItemDialog::InitFronNode: cannot handle this node type!" );
+ break;
+ }
+
+ /** Get binding of the node and clone it
+ Then use this temporary binding in the dialog.
+ When the user click OK the temporary binding will be copied
+ into the original binding.
+ */
+
+ Reference< css::xml::dom::XNode > xNode = m_pItemNode->m_xNode;
+ m_xBinding = m_xUIHelper->getBindingForNode( xNode, sal_True );
+ if ( m_xBinding.is() )
+ {
+ Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
+ if ( xModel.is() )
+ {
+ m_xTempBinding = m_xUIHelper->cloneBindingAsGhost( m_xBinding );
+ Reference < XSet > xBindings = xModel->getBindings();
+ if ( xBindings.is() )
+ xBindings->insert( makeAny( m_xTempBinding ) );
+ }
+ }
+
+ if ( m_eItemType != DITText )
+ {
+ ::rtl::OUString sName( m_xUIHelper->getNodeName( m_pItemNode->m_xNode ) );
+ m_aNameED.SetText( sName );
+ }
+ m_aDefaultED.SetText( m_pItemNode->m_xNode->getNodeValue() );
+ }
+ catch( Exception& )
+ {
+ DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
+ }
+ }
+ else if ( m_pItemNode->m_xPropSet.is() )
+ {
+ m_eItemType = DITBinding;
+ Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
+ if ( xModel.is() )
+ {
+ try
+ {
+ m_xTempBinding = m_xUIHelper->cloneBindingAsGhost( m_pItemNode->m_xPropSet );
+ Reference < XSet > xBindings = xModel->getBindings();
+ if ( xBindings.is() )
+ xBindings->insert( makeAny( m_xTempBinding ) );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
+ }
+ }
+ rtl::OUString sTemp;
+ try
+ {
+ Reference< XPropertySetInfo > xInfo = m_pItemNode->m_xPropSet->getPropertySetInfo();
+ if ( xInfo->hasPropertyByName( PN_BINDING_ID ) )
+ {
+ m_pItemNode->m_xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
+ m_aNameED.SetText( sTemp );
+ m_pItemNode->m_xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
+ m_aDefaultED.SetText( sTemp );
+ }
+ else if ( xInfo->hasPropertyByName( PN_SUBMISSION_BIND ) )
+ {
+ m_pItemNode->m_xPropSet->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
+ m_aNameED.SetText( sTemp );
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
+ }
+
+ Size a3and1Sz = LogicToPixel( Size( 3, 1 ), MAP_APPFONT );
+ Size aNewSz = m_aDefaultED.GetSizePixel();
+ Point aNewPnt = m_aDefaultED.GetPosPixel();
+ aNewPnt.Y() += a3and1Sz.Height();
+ aNewSz.Width() -= ( m_aDefaultBtn.GetSizePixel().Width() + a3and1Sz.Width() );
+ m_aDefaultED.SetPosSizePixel( aNewPnt, aNewSz );
+ m_aDefaultBtn.Show();
+ }
+
+ if ( m_xTempBinding.is() )
+ {
+ ::rtl::OUString sTemp;
+ try
+ {
+ if ( ( m_xTempBinding->getPropertyValue( PN_REQUIRED_EXPR ) >>= sTemp )
+ && sTemp.getLength() > 0 )
+ m_aRequiredCB.Check( TRUE );
+ if ( ( m_xTempBinding->getPropertyValue( PN_RELEVANT_EXPR ) >>= sTemp )
+ && sTemp.getLength() > 0 )
+ m_aRelevantCB.Check( TRUE );
+ if ( ( m_xTempBinding->getPropertyValue( PN_CONSTRAINT_EXPR ) >>= sTemp )
+ && sTemp.getLength() > 0 )
+ m_aConstraintCB.Check( TRUE );
+ if ( ( m_xTempBinding->getPropertyValue( PN_READONLY_EXPR ) >>= sTemp )
+ && sTemp.getLength() > 0 )
+ m_aReadonlyCB.Check( TRUE );
+ if ( ( m_xTempBinding->getPropertyValue( PN_CALCULATE_EXPR ) >>= sTemp )
+ && sTemp.getLength() > 0 )
+ m_aCalculateCB.Check( TRUE );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddDataItemDialog::InitFromNode(): exception caught" );
+ }
+ }
+ }
+
+ if ( DITText == m_eItemType )
+ {
+ long nDelta = m_aButtonsFL.GetPosPixel().Y() - m_aSettingsFL.GetPosPixel().Y();
+ size_t i = 0;
+ Window* pWinsForHide[] =
+ {
+ &m_aSettingsFL, &m_aDataTypeFT, &m_aDataTypeLB, &m_aRequiredCB,
+ &m_aRequiredBtn, &m_aRelevantCB, &m_aRelevantBtn, &m_aConstraintCB,
+ &m_aConstraintBtn, &m_aReadonlyCB, &m_aReadonlyBtn, &m_aCalculateCB,
+ &m_aCalculateBtn
+ };
+ Window** pCurrent = pWinsForHide;
+ for ( ; i < SAL_N_ELEMENTS( pWinsForHide ); ++i, ++pCurrent )
+ (*pCurrent)->Hide();
+
+ Window* pWinsForMove[] =
+ {
+ &m_aButtonsFL, &m_aOKBtn, &m_aEscBtn, &m_aHelpBtn
+ };
+ pCurrent = pWinsForMove;
+ for ( i = 0; i < SAL_N_ELEMENTS( pWinsForMove ); ++i, ++pCurrent )
+ {
+ Point aNewPos = (*pCurrent)->GetPosPixel();
+ aNewPos.Y() -= nDelta;
+ (*pCurrent)->SetPosPixel( aNewPos );
+ }
+ Size aNewWinSz = GetSizePixel();
+ aNewWinSz.Height() -= nDelta;
+ SetSizePixel( aNewWinSz );
+
+ m_aNameFT.Disable();
+ m_aNameED.Disable();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void AddDataItemDialog::InitDataTypeBox()
+ {
+ if ( m_eItemType != DITText )
+ {
+ Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
+ if ( xModel.is() )
+ {
+ try
+ {
+ Reference< css::xforms::XDataTypeRepository > xDataTypes =
+ xModel->getDataTypeRepository();
+ if ( xDataTypes.is() )
+ {
+ Sequence< ::rtl::OUString > aNameList = xDataTypes->getElementNames();
+ sal_Int32 i, nCount = aNameList.getLength();
+ ::rtl::OUString* pNames = aNameList.getArray();
+ for ( i = 0; i < nCount; ++i )
+ m_aDataTypeLB.InsertEntry( pNames[i] );
+ }
+
+ if ( m_xTempBinding.is() )
+ {
+ rtl::OUString sTemp;
+ if ( m_xTempBinding->getPropertyValue( PN_BINDING_TYPE ) >>= sTemp )
+ {
+ USHORT nPos = m_aDataTypeLB.GetEntryPos( String( sTemp ) );
+ if ( LISTBOX_ENTRY_NOTFOUND == nPos )
+ nPos = m_aDataTypeLB.InsertEntry( sTemp );
+ m_aDataTypeLB.SelectEntryPos( nPos );
+ }
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddDataItemDialog::InitDataTypeBox(): exception caught" );
+ }
+ }
+ }
+ }
+
+ void AddDataItemDialog::InitText( DataItemType _eType )
+ {
+ String sText;
+
+ switch ( _eType )
+ {
+ case DITAttribute :
+ {
+ sText = m_sFL_Attribute;
+ break;
+ }
+
+ case DITBinding :
+ {
+ sText = m_sFL_Binding;
+ m_aDefaultFT.SetText( m_sFT_BindingExp );
+ break;
+ }
+
+ default:
+ {
+ sText = m_sFL_Element;
+ }
+ }
+
+ m_aItemFL.SetText( sText );
+ }
+
+ //========================================================================
+ // class AddConditionDialog
+ //========================================================================
+
+ AddConditionDialog::AddConditionDialog(
+ Window* pParent, const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertySet >& _rPropSet ) :
+
+ ModalDialog( pParent, SVX_RES( RID_SVXDLG_ADD_CONDITION ) ),
+
+ m_aConditionFT ( this, SVX_RES( FT_CONDITION ) ),
+ m_aConditionED ( this, SVX_RES( ED_CONDITION ) ),
+ m_aResultFT ( this, SVX_RES( FT_RESULT ) ),
+ m_aResultWin ( this, SVX_RES( FT_RESULT_PREVIEW ) ),
+ m_aEditNamespacesBtn( this, SVX_RES( PB_EDIT_NAMESPACES ) ),
+ m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN ) ),
+ m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK ) ),
+ m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC ) ),
+ m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP ) ),
+
+ m_sPropertyName ( _rPropertyName ),
+ m_xBinding ( _rPropSet )
+
+ {
+ FreeResource();
+
+ DBG_ASSERT( m_xBinding.is(), "AddConditionDialog::Ctor(): no Binding" );
+
+ m_aResultWin.SetBackground( m_aConditionED.GetBackground() );
+ m_aConditionED.SetModifyHdl( LINK( this, AddConditionDialog, ModifyHdl ) );
+ m_aEditNamespacesBtn.SetClickHdl( LINK( this, AddConditionDialog, EditHdl ) );
+ m_aOKBtn.SetClickHdl( LINK( this, AddConditionDialog, OKHdl ) );
+ m_aResultTimer.SetTimeout( 500 );
+ m_aResultTimer.SetTimeoutHdl( LINK( this, AddConditionDialog, ResultHdl ) );
+
+ if ( m_sPropertyName.getLength() > 0 )
+ {
+ try
+ {
+ rtl::OUString sTemp;
+ if ( ( m_xBinding->getPropertyValue( m_sPropertyName ) >>= sTemp )
+ && sTemp.getLength() > 0 )
+ {
+ m_aConditionED.SetText( sTemp );
+ }
+ else
+ {
+//! m_xBinding->setPropertyValue( m_sPropertyName, makeAny( TRUE_VALUE ) );
+ m_aConditionED.SetText( TRUE_VALUE );
+ }
+
+ Reference< css::xforms::XModel > xModel;
+ if ( ( m_xBinding->getPropertyValue( PN_BINDING_MODEL ) >>= xModel ) && xModel.is() )
+ m_xUIHelper = Reference< css::xforms::XFormsUIHelper1 >( xModel, UNO_QUERY );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddConditionDialog::Ctor(): exception caught" );
+ }
+ }
+
+ DBG_ASSERT( m_xUIHelper.is(), "AddConditionDialog::Ctor(): no UIHelper" );
+ ResultHdl( &m_aResultTimer );
+ }
+
+ //------------------------------------------------------------------------
+ AddConditionDialog::~AddConditionDialog()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( AddConditionDialog, EditHdl, PushButton *, EMPTYARG )
+ {
+ Reference< XNameContainer > xNameContnr;
+ try
+ {
+ m_xBinding->getPropertyValue( PN_BINDING_NAMESPACES ) >>= xNameContnr;
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddDataItemDialog::EditHdl(): exception caught" );
+ }
+ NamespaceItemDialog aDlg( this, xNameContnr );
+ aDlg.Execute();
+ try
+ {
+ m_xBinding->setPropertyValue( PN_BINDING_NAMESPACES, makeAny( xNameContnr ) );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddDataItemDialog::EditHdl(): exception caught" );
+ }
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( AddConditionDialog, OKHdl, OKButton *, EMPTYARG )
+ {
+/*!!!
+ try
+ {
+ if ( m_xBinding.is() )
+ m_xBinding->setPropertyValue( m_sPropertyName, makeAny( ::rtl::OUString( m_aConditionED.GetText() ) ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_ERRORFILE( "AddConditionDialog, OKHdl: caught an exception!" );
+ }
+*/
+ EndDialog( RET_OK );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( AddConditionDialog, ModifyHdl, MultiLineEdit *, EMPTYARG )
+ {
+ m_aResultTimer.Start();
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( AddConditionDialog, ResultHdl, Timer *, EMPTYARG )
+ {
+ String sCondition = m_aConditionED.GetText().EraseLeadingChars().EraseTrailingChars();
+ String sResult;
+ if ( sCondition.Len() > 0 )
+ {
+ try
+ {
+ sResult = m_xUIHelper->getResultForExpression( m_xBinding, ( m_sPropertyName == PN_BINDING_EXPR ), sCondition );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddConditionDialog::ResultHdl(): exception caught" );
+ }
+ }
+ m_aResultWin.SetText( sResult );
+ return 0;
+ }
+
+ //========================================================================
+ // class NamespaceItemDialog
+ //========================================================================
+
+ NamespaceItemDialog::NamespaceItemDialog(
+ AddConditionDialog* _pCondDlg, Reference< XNameContainer >& _rContainer ) :
+
+ ModalDialog( _pCondDlg, SVX_RES( RID_SVXDLG_NAMESPACE_ITEM ) ),
+
+ m_aNamespacesFT ( this, SVX_RES( FT_NAMESPACES ) ),
+ m_aNamespacesList ( this, SVX_RES( LB_NAMESPACES ) ),
+ m_aAddNamespaceBtn ( this, SVX_RES( PB_ADD_NAMESPACE ) ),
+ m_aEditNamespaceBtn ( this, SVX_RES( PB_EDIT_NAMESPACE ) ),
+ m_aDeleteNamespaceBtn ( this, SVX_RES( PB_DELETE_NAMESPACE ) ),
+ m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN ) ),
+ m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK ) ),
+ m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC ) ),
+ m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP ) ),
+
+ m_pConditionDlg ( _pCondDlg ),
+ m_rNamespaces ( _rContainer )
+
+ {
+ static long aStaticTabs[]= { 3, 0, 35, 200 };
+ m_aNamespacesList.SvxSimpleTable::SetTabs( aStaticTabs );
+ String sHeader = String( SVX_RES( STR_HEADER_PREFIX ) );
+ sHeader += '\t';
+ sHeader += String( SVX_RES( STR_HEADER_URL ) );
+ m_aNamespacesList.InsertHeaderEntry(
+ sHeader, HEADERBAR_APPEND, HIB_LEFT /*| HIB_FIXEDPOS | HIB_FIXED*/ );
+
+ FreeResource();
+
+ m_aNamespacesList.SetSelectHdl( LINK( this, NamespaceItemDialog, SelectHdl ) );
+ Link aLink = LINK( this, NamespaceItemDialog, ClickHdl );
+ m_aAddNamespaceBtn.SetClickHdl( aLink );
+ m_aEditNamespaceBtn.SetClickHdl( aLink );
+ m_aDeleteNamespaceBtn.SetClickHdl( aLink );
+ m_aOKBtn.SetClickHdl( LINK( this, NamespaceItemDialog, OKHdl ) );
+
+ LoadNamespaces();
+ SelectHdl( &m_aNamespacesList );
+ }
+
+ //------------------------------------------------------------------------
+ NamespaceItemDialog::~NamespaceItemDialog()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( NamespaceItemDialog, SelectHdl, SvxSimpleTable *, EMPTYARG )
+ {
+ BOOL bEnable = ( m_aNamespacesList.FirstSelected() != NULL );
+ m_aEditNamespaceBtn.Enable( bEnable );
+ m_aDeleteNamespaceBtn.Enable( bEnable );
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( NamespaceItemDialog, ClickHdl, PushButton *, pBtn )
+ {
+ if ( &m_aAddNamespaceBtn == pBtn )
+ {
+ ManageNamespaceDialog aDlg( this, m_pConditionDlg, false );
+ if ( aDlg.Execute() == RET_OK )
+ {
+ String sEntry = aDlg.GetPrefix();
+ sEntry += '\t';
+ sEntry += aDlg.GetURL();
+ m_aNamespacesList.InsertEntry( sEntry );
+ }
+ }
+ else if ( &m_aEditNamespaceBtn == pBtn )
+ {
+ ManageNamespaceDialog aDlg( this, m_pConditionDlg, true );
+ SvLBoxEntry* pEntry = m_aNamespacesList.FirstSelected();
+ DBG_ASSERT( pEntry, "NamespaceItemDialog::ClickHdl(): no entry" );
+ String sPrefix( m_aNamespacesList.GetEntryText( pEntry, 0 ) );
+ aDlg.SetNamespace(
+ sPrefix,
+ m_aNamespacesList.GetEntryText( pEntry, 1 ) );
+ if ( aDlg.Execute() == RET_OK )
+ {
+ // if a prefix was changed, mark the old prefix as 'removed'
+ if( sPrefix != aDlg.GetPrefix() )
+ m_aRemovedList.push_back( sPrefix );
+
+ m_aNamespacesList.SetEntryText( aDlg.GetPrefix(), pEntry, 0 );
+ m_aNamespacesList.SetEntryText( aDlg.GetURL(), pEntry, 1 );
+ }
+ }
+ else if ( &m_aDeleteNamespaceBtn == pBtn )
+ {
+ SvLBoxEntry* pEntry = m_aNamespacesList.FirstSelected();
+ DBG_ASSERT( pEntry, "NamespaceItemDialog::ClickHdl(): no entry" );
+ ::rtl::OUString sPrefix( m_aNamespacesList.GetEntryText( pEntry, 0 ) );
+ m_aRemovedList.push_back( sPrefix );
+ m_aNamespacesList.GetModel()->Remove( pEntry );
+ }
+ else
+ {
+ DBG_ERRORFILE( "NamespaceItemDialog::ClickHdl(): invalid button" );
+ }
+
+ SelectHdl( &m_aNamespacesList );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( NamespaceItemDialog, OKHdl, OKButton *, EMPTYARG )
+ {
+ try
+ {
+ // update namespace container
+ sal_Int32 i, nRemovedCount = m_aRemovedList.size();
+ for( i = 0; i < nRemovedCount; ++i )
+ m_rNamespaces->removeByName( m_aRemovedList[i] );
+
+ sal_Int32 nEntryCount = m_aNamespacesList.GetEntryCount();
+ for( i = 0; i < nEntryCount; ++i )
+ {
+ SvLBoxEntry* pEntry = m_aNamespacesList.GetEntry(i);
+ ::rtl::OUString sPrefix( m_aNamespacesList.GetEntryText( pEntry, 0 ) );
+ ::rtl::OUString sURL( m_aNamespacesList.GetEntryText( pEntry, 1 ) );
+
+ if ( m_rNamespaces->hasByName( sPrefix ) )
+ m_rNamespaces->replaceByName( sPrefix, makeAny( sURL ) );
+ else
+ m_rNamespaces->insertByName( sPrefix, makeAny( sURL ) );
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "NamespaceItemDialog::OKHdl(): exception caught" );
+ }
+ // and close the dialog
+ EndDialog( RET_OK );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ void NamespaceItemDialog::LoadNamespaces()
+ {
+ try
+ {
+ Sequence< ::rtl::OUString > aAllNames = m_rNamespaces->getElementNames();
+ const ::rtl::OUString* pAllNames = aAllNames.getConstArray();
+ const ::rtl::OUString* pAllNamesEnd = pAllNames + aAllNames.getLength();
+ for ( ; pAllNames != pAllNamesEnd; ++pAllNames )
+ {
+ ::rtl::OUString sURL;
+ ::rtl::OUString sPrefix = *pAllNames;
+ if ( m_rNamespaces->hasByName( sPrefix ) )
+ {
+ Any aAny = m_rNamespaces->getByName( sPrefix );
+ if ( aAny >>= sURL )
+ {
+ String sEntry( sPrefix );
+ sEntry += '\t';
+ sEntry += String( sURL );
+
+ m_aNamespacesList.InsertEntry( sEntry );
+ }
+ }
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "NamespaceItemDialog::LoadNamespaces(): exception caught" );
+ }
+ }
+
+ //========================================================================
+ // class ManageNamespaceDialog
+ //========================================================================
+
+ ManageNamespaceDialog::ManageNamespaceDialog(
+ Window* pParent, AddConditionDialog* _pCondDlg, bool _bIsEdit ) :
+
+ ModalDialog( pParent, SVX_RES( RID_SVXDLG_MANAGE_NAMESPACE ) ),
+
+ m_aPrefixFT ( this, SVX_RES( FT_PREFIX ) ),
+ m_aPrefixED ( this, SVX_RES( ED_PREFIX ) ),
+ m_aUrlFT ( this, SVX_RES( FT_URL ) ),
+ m_aUrlED ( this, SVX_RES( ED_URL ) ),
+ m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN ) ),
+ m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK ) ),
+ m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC ) ),
+ m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP ) ),
+
+ m_pConditionDlg ( _pCondDlg )
+
+ {
+ if ( _bIsEdit )
+ SetText( String( SVX_RES( STR_EDIT_TEXT ) ) );
+
+ FreeResource();
+
+ m_aOKBtn.SetClickHdl( LINK( this, ManageNamespaceDialog, OKHdl ) );
+ }
+
+ //------------------------------------------------------------------------
+ ManageNamespaceDialog::~ManageNamespaceDialog()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( ManageNamespaceDialog, OKHdl, OKButton *, EMPTYARG )
+ {
+ String sPrefix = m_aPrefixED.GetText();
+
+ try
+ {
+ if ( !m_pConditionDlg->GetUIHelper()->isValidPrefixName( sPrefix ) )
+ {
+ ErrorBox aErrBox( this, SVX_RES( RID_ERR_INVALID_XMLPREFIX ) );
+ String sMessText = aErrBox.GetMessText();
+ sMessText.SearchAndReplace( MSG_VARIABLE, sPrefix );
+ aErrBox.SetMessText( sMessText );
+ aErrBox.Execute();
+ return 0;
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "ManageNamespacesDialog::OKHdl(): exception caught" );
+ }
+
+ // no error so close the dialog
+ EndDialog( RET_OK );
+ return 0;
+ }
+
+ //========================================================================
+ // class AddSubmissionDialog
+ //========================================================================
+
+ AddSubmissionDialog::AddSubmissionDialog(
+ Window* pParent, ItemNode* _pNode,
+ const Reference< css::xforms::XFormsUIHelper1 >& _rUIHelper ) :
+
+ ModalDialog( pParent, SVX_RES( RID_SVXDLG_ADD_SUBMISSION ) ),
+
+ m_aSubmissionFL ( this, SVX_RES( FL_SUBMISSION ) ),
+ m_aNameFT ( this, SVX_RES( FT_SUBMIT_NAME ) ),
+ m_aNameED ( this, SVX_RES( ED_SUBMIT_NAME ) ),
+ m_aActionFT ( this, SVX_RES( FT_SUBMIT_ACTION ) ),
+ m_aActionED ( this, SVX_RES( ED_SUBMIT_ACTION ) ),
+ m_aMethodFT ( this, SVX_RES( FT_SUBMIT_METHOD ) ),
+ m_aMethodLB ( this, SVX_RES( LB_SUBMIT_METHOD ) ),
+ m_aRefFT ( this, SVX_RES( FT_SUBMIT_REF ) ),
+ m_aRefED ( this, SVX_RES( ED_SUBMIT_REF ) ),
+ m_aRefBtn ( this, SVX_RES( PB_SUBMIT_REF ) ),
+ m_aBindFT ( this, SVX_RES( FT_SUBMIT_BIND ) ),
+ m_aBindLB ( this, SVX_RES( LB_SUBMIT_BIND ) ),
+ m_aReplaceFT ( this, SVX_RES( FT_SUBMIT_REPLACE ) ),
+ m_aReplaceLB ( this, SVX_RES( LB_SUBMIT_REPLACE ) ),
+
+ m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN ) ),
+ m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK ) ),
+ m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC ) ),
+ m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP ) ),
+
+ m_pItemNode ( _pNode ),
+ m_xUIHelper ( _rUIHelper )
+
+ {
+ FillAllBoxes(); // we need local resources here, so call before FreeResource!!!
+
+ FreeResource();
+
+ m_aRefBtn.SetClickHdl( LINK( this, AddSubmissionDialog, RefHdl ) );
+ m_aOKBtn.SetClickHdl( LINK( this, AddSubmissionDialog, OKHdl ) );
+ }
+
+ //------------------------------------------------------------------------
+ AddSubmissionDialog::~AddSubmissionDialog()
+ {
+ // #i38991# if we have added a binding, we need to remove it as well.
+ if( m_xCreatedBinding.is() && m_xUIHelper.is() )
+ m_xUIHelper->removeBindingIfUseless( m_xCreatedBinding );
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( AddSubmissionDialog, RefHdl, PushButton *, EMPTYARG )
+ {
+ AddConditionDialog aDlg( this, PN_BINDING_EXPR, m_xTempBinding );
+ aDlg.SetCondition( m_aRefED.GetText() );
+ if ( aDlg.Execute() == RET_OK )
+ m_aRefED.SetText( aDlg.GetCondition() );
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( AddSubmissionDialog, OKHdl, OKButton *, EMPTYARG )
+ {
+ rtl::OUString sName(m_aNameED.GetText());
+ if(!sName.getLength()) {
+
+ ErrorBox aErrorBox(this,SVX_RES(RID_ERR_EMPTY_SUBMISSIONNAME));
+ aErrorBox.SetText( Application::GetDisplayName() );
+ aErrorBox.Execute();
+ return 0;
+ }
+
+ if ( !m_xSubmission.is() )
+ {
+ DBG_ASSERT( !m_xNewSubmission.is(),
+ "AddSubmissionDialog::OKHdl(): new submission already exists" );
+
+ // add a new submission
+ Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
+ if ( xModel.is() )
+ {
+ try
+ {
+ m_xNewSubmission = xModel->createSubmission();
+ m_xSubmission = Reference< XPropertySet >( m_xNewSubmission, UNO_QUERY );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddSubmissionDialog::OKHdl(): exception caught" );
+ }
+ }
+ }
+
+ if ( m_xSubmission.is() )
+ {
+ rtl::OUString sTemp = m_aNameED.GetText();
+ try
+ {
+ m_xSubmission->setPropertyValue( PN_SUBMISSION_ID, makeAny( sTemp ) );
+ sTemp = m_aActionED.GetText();
+ m_xSubmission->setPropertyValue( PN_SUBMISSION_ACTION, makeAny( sTemp ) );
+ sTemp = lcl_MethodString::get().toAPI( m_aMethodLB.GetSelectEntry() );
+ m_xSubmission->setPropertyValue( PN_SUBMISSION_METHOD, makeAny( sTemp ) );
+ sTemp = m_aRefED.GetText();
+ m_xSubmission->setPropertyValue( PN_SUBMISSION_REF, makeAny( sTemp ) );
+ String sEntry = m_aBindLB.GetSelectEntry();
+ sEntry.Erase( sEntry.Search( ':' ) );
+ sTemp = sEntry;
+ m_xSubmission->setPropertyValue( PN_SUBMISSION_BIND, makeAny( sTemp ) );
+ sTemp = lcl_ReplaceString::get().toAPI( m_aReplaceLB.GetSelectEntry() );
+ m_xSubmission->setPropertyValue( PN_SUBMISSION_REPLACE, makeAny( sTemp ) );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddSubmissionDialog::OKHdl(): exception caught" );
+ }
+ }
+
+ EndDialog( RET_OK );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ void AddSubmissionDialog::FillAllBoxes()
+ {
+ // method box
+ m_aMethodLB.InsertEntry( String( SVX_RES( STR_METHOD_POST ) ) );
+ m_aMethodLB.InsertEntry( String( SVX_RES( STR_METHOD_PUT ) ) );
+ m_aMethodLB.InsertEntry( String( SVX_RES( STR_METHOD_GET ) ) );
+ m_aMethodLB.SelectEntryPos(0);
+
+ // binding box
+ Reference< css::xforms::XModel > xModel( m_xUIHelper, UNO_QUERY );
+ if ( xModel.is() )
+ {
+ try
+ {
+ Reference< XEnumerationAccess > xNumAccess( xModel->getBindings(), UNO_QUERY );
+ if ( xNumAccess.is() )
+ {
+ Reference < XEnumeration > xNum = xNumAccess->createEnumeration();
+ if ( xNum.is() && xNum->hasMoreElements() )
+ {
+ String sDelim( RTL_CONSTASCII_STRINGPARAM( ": " ) );
+ while ( xNum->hasMoreElements() )
+ {
+ Reference< XPropertySet > xPropSet;
+ Any aAny = xNum->nextElement();
+ if ( aAny >>= xPropSet )
+ {
+ String sEntry;
+ rtl::OUString sTemp;
+ xPropSet->getPropertyValue( PN_BINDING_ID ) >>= sTemp;
+ sEntry += String( sTemp );
+ sEntry += sDelim;
+ xPropSet->getPropertyValue( PN_BINDING_EXPR ) >>= sTemp;
+ sEntry += String( sTemp );
+ m_aBindLB.InsertEntry( sEntry );
+
+ if ( !m_xTempBinding.is() )
+ m_xTempBinding = xPropSet;
+ }
+ }
+ }
+ }
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddSubmissionDialog::FillAllBoxes(): exception caught" );
+ }
+ }
+
+ // #i36342# we need a temporary binding; create one if no existing binding
+ // is found
+ if( !m_xTempBinding.is() )
+ {
+ m_xCreatedBinding = m_xUIHelper->getBindingForNode(
+ Reference<css::xml::dom::XNode>(
+ xModel->getDefaultInstance()->getDocumentElement(),
+ UNO_QUERY_THROW ),
+ sal_True );
+ m_xTempBinding = m_xCreatedBinding;
+ }
+
+ // replace box
+ m_aReplaceLB.InsertEntry( String( SVX_RES( STR_REPLACE_NONE ) ) );
+ m_aReplaceLB.InsertEntry( String( SVX_RES( STR_REPLACE_INST ) ) );
+ m_aReplaceLB.InsertEntry( String( SVX_RES( STR_REPLACE_DOC ) ) );
+
+
+ // init the controls with the values of the submission
+ if ( m_pItemNode && m_pItemNode->m_xPropSet.is() )
+ {
+ m_xSubmission = m_pItemNode->m_xPropSet;
+ rtl::OUString sTemp;
+ try
+ {
+ m_xSubmission->getPropertyValue( PN_SUBMISSION_ID ) >>= sTemp;
+ m_aNameED.SetText( sTemp );
+ m_xSubmission->getPropertyValue( PN_SUBMISSION_ACTION ) >>= sTemp;
+ m_aActionED.SetText( sTemp );
+ m_xSubmission->getPropertyValue( PN_SUBMISSION_REF ) >>= sTemp;
+ m_aRefED.SetText( sTemp );
+
+ m_xSubmission->getPropertyValue( PN_SUBMISSION_METHOD ) >>= sTemp;
+ sTemp = lcl_MethodString::get().toUI( sTemp );
+ USHORT nPos = m_aMethodLB.GetEntryPos( String( sTemp ) );
+ if ( LISTBOX_ENTRY_NOTFOUND == nPos )
+ nPos = m_aMethodLB.InsertEntry( sTemp );
+ m_aMethodLB.SelectEntryPos( nPos );
+
+ m_xSubmission->getPropertyValue( PN_SUBMISSION_BIND ) >>= sTemp;
+ nPos = m_aBindLB.GetEntryPos( String( sTemp ) );
+ if ( LISTBOX_ENTRY_NOTFOUND == nPos )
+ nPos = m_aBindLB.InsertEntry( sTemp );
+ m_aBindLB.SelectEntryPos( nPos );
+
+ m_xSubmission->getPropertyValue( PN_SUBMISSION_REPLACE ) >>= sTemp;
+ sTemp = lcl_ReplaceString::get().toUI( sTemp );
+ if ( sTemp.getLength() == 0 )
+ sTemp = m_aReplaceLB.GetEntry(0); // first entry == "none"
+ nPos = m_aReplaceLB.GetEntryPos( String( sTemp ) );
+ if ( LISTBOX_ENTRY_NOTFOUND == nPos )
+ nPos = m_aReplaceLB.InsertEntry( sTemp );
+ m_aReplaceLB.SelectEntryPos( nPos );
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "AddSubmissionDialog::FillAllBoxes(): exception caught" );
+ }
+ }
+
+ m_aRefBtn.Enable( m_xTempBinding.is() );
+ }
+
+ //========================================================================
+ // class AddModelDialog
+ //========================================================================
+
+ AddModelDialog::AddModelDialog( Window* pParent, bool _bEdit ) :
+
+ ModalDialog( pParent, SVX_RES( RID_SVXDLG_ADD_MODEL ) ),
+
+ m_aModelFL ( this, SVX_RES( FL_MODEL ) ),
+ m_aNameFT ( this, SVX_RES( FT_MODEL_NAME ) ),
+ m_aNameED ( this, SVX_RES( ED_MODEL_NAME ) ),
+ m_aModifyCB ( this, SVX_RES( CB_MODIFIES_DOCUMENT ) ),
+ m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN ) ),
+ m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK ) ),
+ m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC ) ),
+ m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP ) )
+
+ {
+ if ( _bEdit )
+ SetText( String( SVX_RES( STR_EDIT_TEXT ) ) );
+
+ FreeResource();
+ }
+
+ AddModelDialog::~AddModelDialog()
+ {
+ }
+
+ //========================================================================
+ // class AddInstanceDialog
+ //========================================================================
+
+ AddInstanceDialog::AddInstanceDialog( Window* pParent, bool _bEdit ) :
+
+ ModalDialog( pParent, SVX_RES( RID_SVXDLG_ADD_INSTANCE ) ),
+
+ m_aInstanceFL ( this, SVX_RES( FL_INSTANCE ) ),
+ m_aNameFT ( this, SVX_RES( FT_INST_NAME ) ),
+ m_aNameED ( this, SVX_RES( ED_INST_NAME ) ),
+ m_aURLFT ( this, SVX_RES( FT_INST_URL ) ),
+ m_aURLED ( this, SVX_RES( ED_INST_URL ) ),
+ m_aFilePickerBtn ( this, SVX_RES( PB_FILEPICKER ) ),
+ m_aLinkInstanceCB ( this, SVX_RES( CB_INST_LINKINST ) ),
+ m_aButtonsFL ( this, SVX_RES( FL_DATANAV_BTN ) ),
+ m_aOKBtn ( this, SVX_RES( BTN_DATANAV_OK ) ),
+ m_aEscBtn ( this, SVX_RES( BTN_DATANAV_ESC ) ),
+ m_aHelpBtn ( this, SVX_RES( BTN_DATANAV_HELP ) )
+
+ {
+ if ( _bEdit )
+ SetText( String( SVX_RES( STR_EDIT_TEXT ) ) );
+
+ FreeResource();
+
+ m_aURLED.DisableHistory();
+ m_aFilePickerBtn.SetClickHdl( LINK( this, AddInstanceDialog, FilePickerHdl ) );
+
+ // load the filter name from fps_office resource
+ m_sAllFilterName = String( ResId( STR_FILTERNAME_ALL, *CREATEVERSIONRESMGR(fps_office) ) );
+ }
+
+ AddInstanceDialog::~AddInstanceDialog()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( AddInstanceDialog, FilePickerHdl, PushButton *, EMPTYARG )
+ {
+ ::sfx2::FileDialogHelper aDlg(
+ css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
+ INetURLObject aFile( SvtPathOptions().GetWorkPath() );
+
+ aDlg.AddFilter( m_sAllFilterName, DEFINE_CONST_UNICODE(FILEDIALOG_FILTER_ALL) );
+ String sFilterName( DEFINE_CONST_UNICODE("XML") );
+ aDlg.AddFilter( sFilterName, DEFINE_CONST_UNICODE("*.xml") );
+ aDlg.SetCurrentFilter( sFilterName );
+ aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ if( aDlg.Execute() == ERRCODE_NONE )
+ m_aURLED.SetText( aDlg.GetPath() );
+
+ return 0;
+ }
+
+ //========================================================================
+ // class LinkedInstanceWarningBox
+ //========================================================================
+
+ LinkedInstanceWarningBox::LinkedInstanceWarningBox( Window* pParent ) :
+
+ MessBox( pParent, SVX_RES( RID_QRY_LINK_WARNING ) )
+
+ {
+ SetText( Application::GetDisplayName() );
+ SetImage( QueryBox::GetStandardImage() );
+ AddButton( SVX_RESSTR( RID_STR_DATANAV_LINKWARN_BUTTON ), BUTTONID_OK, BUTTONDIALOG_DEFBUTTON );
+ AddButton( BUTTON_CANCEL, BUTTONID_CANCEL, BUTTONDIALOG_CANCELBUTTON );
+ }
+
+//............................................................................
+} // namespace svxform
+//............................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/datanavi.src b/svx/source/form/datanavi.src
new file mode 100644
index 000000000000..5d4aaf69b26b
--- /dev/null
+++ b/svx/source/form/datanavi.src
@@ -0,0 +1,1160 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "datanavi.hrc"
+#include "globlmn.hrc"
+#include "fmresids.hrc"
+#include "fmhelp.hrc"
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+
+TabPage RID_SVX_XFORMS_TABPAGES
+{
+ Hide = TRUE ;
+ DialogControl = TRUE;
+ Size = MAP_APPFONT ( 63 , 100 ) ;
+ ToolBox TB_ITEMS
+ {
+ HelpId = HID_XFORMS_TOOLBOX ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = TBI_ITEM_ADD ;
+ HelpId = HID_XFORMS_TOOLBOX_ITEM_ADD ;
+ Text [ en-US ] = "Add Item" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_ITEM_ADD_ELEMENT ;
+ HelpId = HID_XFORMS_TOOLBOX_ITEM_ADD_ELEMENT ;
+ Text [ en-US ] = "Add Element" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_ITEM_ADD_ATTRIBUTE ;
+ HelpId = HID_XFORMS_TOOLBOX_ITEM_ADD_ATTRIBUTE ;
+ Text [ en-US ] = "Add Attribute" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_ITEM_EDIT ;
+ HelpId = HID_XFORMS_TOOLBOX_ITEM_EDIT ;
+ Text [ en-US ] = "Edit" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+ ToolBoxItem
+ {
+ Identifier = TBI_ITEM_REMOVE ;
+ HelpId = HID_XFORMS_TOOLBOX_ITEM_REMOVE ;
+ Text [ en-US ] = "Delete" ;
+ };
+ };
+ };
+ Control LB_ITEMS
+ {
+ HelpId = HID_XFORMS_ITEMS_LIST ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 63 , 100 ) ;
+ Border = TRUE ;
+ TabStop = TRUE;
+ };
+#define IMG_LST \
+IdList = \
+{ \
+ IID_ITEM_ADD ; \
+ IID_ITEM_ADD_ELEMENT ; \
+ IID_ITEM_ADD_ATTRIBUTE ; \
+ IID_ITEM_EDIT ; \
+ IID_ITEM_REMOVE ; \
+}; \
+IdCount = { 5 ; } ;
+
+ ImageList IL_TBX_BMPS
+ {
+ Prefix = "tb";
+ MASKCOLOR
+ IMG_LST
+ };
+ ImageList IL_TBX_BMPS_HC
+ {
+ Prefix = "tbh";
+ MASKCOLOR
+ IMG_LST
+ };
+#undef IMG_LST
+};
+
+Window RID_SVXWIN_DATANAVIGATOR
+{
+ OutputSize = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ DialogControl = TRUE ;
+ HelpId = HID_DATA_NAVIGATOR_WIN ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 300 , 400 ) ;
+ ListBox LB_MODELS
+ {
+ HelpId = HID_XFORMS_MODELS_LIST ;
+ Pos = MAP_APPFONT ( 3 , 4 ) ;
+ Size = MAP_APPFONT ( 63 , 45 ) ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ MenuButton MB_MODELS
+ {
+ HelpId = HID_XFORMS_MODELS_MENUBTN ;
+ Pos = MAP_APPFONT ( 69 , 3 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Models";
+ ButtonMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MID_MODELS_ADD ;
+ HelpId = HID_MN_XFORMS_MODELS_ADD ;
+ Text [ en-US ] = "~Add..." ;
+ };
+ MenuItem
+ {
+ Identifier = MID_MODELS_EDIT ;
+ HelpId = HID_MN_XFORMS_MODELS_EDIT ;
+ Text [ en-US ] = "~Edit..." ;
+ };
+ MenuItem
+ {
+ Identifier = MID_MODELS_REMOVE ;
+ HelpId = HID_MN_XFORMS_MODELS_REMOVE ;
+ Text [ en-US ] = "~Remove" ;
+ };
+ };
+ };
+ };
+ TabControl TC_ITEMS
+ {
+ HelpId = HID_XFORMS_TAB_CONTROL ;
+ Pos = MAP_APPFONT ( 3, 20 ) ;
+ TabStop = TRUE;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TID_INSTANCE ;
+ Text [ en-US ] = "Instance";
+ };
+ PageItem
+ {
+ Identifier = TID_SUBMISSION ;
+ Text [ en-US ] = "Submissions";
+ };
+ PageItem
+ {
+ Identifier = TID_BINDINGS ;
+ Text [ en-US ] = "Bindings";
+ };
+ };
+ };
+ MenuButton MB_INSTANCES
+ {
+ HelpId = HID_XFORMS_INSTANCES_MENUBTN ;
+ Pos = MAP_APPFONT ( 69 , 133 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Instances";
+ ButtonMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MID_INSTANCES_ADD ;
+ HelpId = HID_MN_XFORMS_INSTANCES_ADD ;
+ Text [ en-US ] = "~Add..." ;
+ };
+ MenuItem
+ {
+ Identifier = MID_INSTANCES_EDIT ;
+ HelpId = HID_MN_XFORMS_INSTANCES_EDIT ;
+ Text [ en-US ] = "~Edit..." ;
+ };
+ MenuItem
+ {
+ Identifier = MID_INSTANCES_REMOVE ;
+ HelpId = HID_MN_XFORMS_INSTANCES_REMOVE ;
+ Text [ en-US ] = "~Remove" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE;
+ };
+ MenuItem
+ {
+ Identifier = MID_SHOW_DETAILS ;
+ HelpId = HID_MN_XFORMS_SHOW_DETAILS ;
+ Text [ en-US ] = "~Show Details" ;
+ };
+ };
+ };
+ };
+
+#define IMG_LST2 \
+IdList = \
+{ \
+ IID_GROUP_CLOSED ; \
+ IID_GROUP_OPEN ; \
+ IID_ELEMENT ; \
+ IID_ATTRIBUTE ; \
+ IID_TEXT ; \
+ IID_OTHER ; \
+}; \
+IdCount = { 6 ; } ;
+
+ ImageList IL_ITEM_BMPS
+ {
+ Prefix = "da";
+ MASKCOLOR
+ IMG_LST2
+ };
+ ImageList IL_ITEM_BMPS_HC
+ {
+ Prefix = "dah";
+ MASKCOLOR
+ IMG_LST2
+ };
+};
+
+QueryBox RID_QRY_REMOVE_MODEL
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_NO ;
+ Message [ en-US ] = "Deleting the model '$MODELNAME' affects all controls currently bound to this model.\nDo you really want to delete this model?" ;
+};
+
+QueryBox RID_QRY_REMOVE_INSTANCE
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_NO ;
+ Message [ en-US ] = "Deleting the instance '$INSTANCENAME' affects all controls currently bound to this instance.\nDo you really want to delete this instance?" ;
+};
+
+QueryBox RID_QRY_REMOVE_ELEMENT
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_NO ;
+ Message [ en-US ] = "Deleting the element '$ELEMENTNAME' affects all controls currently bound to this element.\nDo you really want to delete this element?" ;
+};
+
+QueryBox RID_QRY_REMOVE_ATTRIBUTE
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_NO ;
+ Message [ en-US ] = "Do you really want to delete the attribute '$ATTRIBUTENAME'?" ;
+};
+
+QueryBox RID_QRY_REMOVE_SUBMISSION
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_NO ;
+ Message [ en-US ] = "Deleting the submission '$SUBMISSIONNAME' affects all controls currently bound to this submission.\n\nDo you really want to delete this submission?" ;
+};
+
+QueryBox RID_QRY_REMOVE_BINDING
+{
+ Buttons = WB_YES_NO ;
+ DefButton = WB_DEF_NO ;
+ Message [ en-US ] = "Deleting the binding '$BINDINGNAME' affects all controls currently bound to this binding.\n\nDo you really want to delete this binding?" ;
+};
+
+MessBox RID_QRY_LINK_WARNING
+{
+ Buttons = 0 ;
+ Message [ en-US ] = "This instance is linked with the form.\n\nThe changes you make to this instance will be lost when the form is reloaded.\n\nHow do you want to proceed?" ;
+};
+
+ErrorBox RID_ERR_INVALID_XMLNAME
+{
+ Buttons = WB_OK ;
+ Message [ en-US ] = "The name '%1' is not valid in XML. Please enter a different name." ;
+};
+
+ErrorBox RID_ERR_INVALID_XMLPREFIX
+{
+ Buttons = WB_OK ;
+ Message [ en-US ] = "The prefix '%1' is not valid in XML. Please enter a different prefix." ;
+};
+
+ErrorBox RID_ERR_DOUBLE_MODELNAME
+{
+ Buttons = WB_OK ;
+ Message [ en-US ] = "The name '%1' already exists. Please enter a new name." ;
+};
+
+ErrorBox RID_ERR_EMPTY_SUBMISSIONNAME
+{
+ Buttons = WB_OK ;
+ Message [ en-US ] = "The submission must have a name." ;
+};
+
+ModalDialog RID_SVXDLG_ADD_DATAITEM
+{
+ HelpID = HID_XFORMS_ADDDATAITEM_DLG ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 180 , 186 ) ;
+ Moveable = TRUE ;
+ FixedLine FL_ITEM
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( 172 , 8 ) ;
+ Text [ en-US ] = "Item" ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 6 , 15 ) ;
+ Size = MAP_APPFONT ( 69 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Name" ;
+ };
+ Edit ED_NAME
+ {
+ Pos = MAP_APPFONT ( 78 , 14 ) ;
+ Size = MAP_APPFONT ( 96 , 12 ) ;
+ Border = TRUE ;
+ };
+ FixedText FT_DEFAULT
+ {
+ Pos = MAP_APPFONT ( 6 , 30 ) ;
+ Size = MAP_APPFONT ( 69 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Default Value" ;
+ };
+ Edit ED_DEFAULT
+ {
+ Pos = MAP_APPFONT ( 78 , 29 ) ;
+ Size = MAP_APPFONT ( 96 , 12 ) ;
+ Border = TRUE ;
+ };
+ PushButton PB_DEFAULT
+ {
+ Pos = MAP_APPFONT ( 160 , 29 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text = "..." ;
+ };
+ FixedLine FL_SETTINGS
+ {
+ Pos = MAP_APPFONT ( 4 , 44 ) ;
+ Size = MAP_APPFONT ( 172 , 8 ) ;
+ Text [ en-US ] = "Settings" ;
+ };
+ FixedText FT_DATATYPE
+ {
+ Pos = MAP_APPFONT ( 6 , 56 ) ;
+ Size = MAP_APPFONT ( 69 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Data Type" ;
+ };
+ ListBox LB_DATATYPE
+ {
+ Pos = MAP_APPFONT ( 78 , 55 ) ;
+ Size = MAP_APPFONT ( 96 , 45 ) ;
+ Border = TRUE ;
+ DropDown = TRUE;
+ };
+ CheckBox CB_REQUIRED
+ {
+ Pos = MAP_APPFONT ( 6 , 72 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Required" ;
+ };
+ PushButton PB_REQUIRED
+ {
+ Pos = MAP_APPFONT ( 78 , 70 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Condition" ;
+ };
+ CheckBox CB_RELEVANT
+ {
+ Pos = MAP_APPFONT ( 6 , 89 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "R~elevant" ;
+ };
+ PushButton PB_RELEVANT
+ {
+ Pos = MAP_APPFONT ( 78 , 87 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Condition" ;
+ };
+ CheckBox CB_CONSTRAINT
+ {
+ Pos = MAP_APPFONT ( 6 , 106 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Constraint" ;
+ };
+ PushButton PB_CONSTRAINT
+ {
+ Pos = MAP_APPFONT ( 78 , 104 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Condition" ;
+ };
+ CheckBox CB_READONLY
+ {
+ Pos = MAP_APPFONT ( 6 , 123 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Read-~only" ;
+ };
+ PushButton PB_READONLY
+ {
+ Pos = MAP_APPFONT ( 78 , 121 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Condition" ;
+ };
+ CheckBox CB_CALCULATE
+ {
+ Pos = MAP_APPFONT ( 6 , 140 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Calc~ulate" ;
+ };
+ PushButton PB_CALCULATE
+ {
+ Pos = MAP_APPFONT ( 78 , 138 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Condition" ;
+ };
+ FixedLine FL_DATANAV_BTN
+ {
+ Pos = MAP_APPFONT ( 4 , 155 ) ;
+ Size = MAP_APPFONT ( 172 , 8 ) ;
+ };
+ OKButton BTN_DATANAV_OK
+ {
+ Pos = MAP_APPFONT ( 15 , 166 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_DATANAV_ESC
+ {
+ Pos = MAP_APPFONT ( 68 , 166 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_DATANAV_HELP
+ {
+ Pos = MAP_APPFONT ( 124 , 166 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_FIXEDLINE_ELEMENT
+ {
+ Text [ en-US ] = "Element" ;
+ };
+ String STR_FIXEDLINE_ATTRIBUTE
+ {
+ Text [ en-US ] = "Attribute" ;
+ };
+ String STR_FIXEDLINE_BINDING
+ {
+ Text [ en-US ] = "Binding" ;
+ };
+ String STR_FIXEDTEXT_BINDING
+ {
+ Text [ en-US ] = "Binding expression" ;
+ };
+};
+
+Menu RID_MENU_DATANAVIGATOR
+{
+ ItemList =
+ {
+ // MID_INSERT_CONTROL not implemented, yet (#i99890#)
+ /*MenuItem
+ {
+ Identifier = MID_INSERT_CONTROL ;
+ HelpId = HID_XFORMS_MID_INSERT_CONTROL ;
+ Text [ en-US ] = "Insert Control" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE;
+ };*/
+ MenuItem
+ {
+ Identifier = TBI_ITEM_ADD ;
+ HelpId = HID_XFORMS_TOOLBOX_ITEM_ADD ;
+ Text [ en-US ] = "Add Item" ;
+ };
+ MenuItem
+ {
+ Identifier = TBI_ITEM_ADD_ELEMENT ;
+ HelpId = HID_XFORMS_TOOLBOX_ITEM_ADD_ELEMENT ;
+ Text [ en-US ] = "Add Element" ;
+ };
+ MenuItem
+ {
+ Identifier = TBI_ITEM_ADD_ATTRIBUTE ;
+ HelpId = HID_XFORMS_TOOLBOX_ITEM_ADD_ATTRIBUTE ;
+ Text [ en-US ] = "Add Attribute" ;
+ };
+ MenuItem
+ {
+ Identifier = TBI_ITEM_EDIT ;
+ HelpId = HID_XFORMS_TOOLBOX_ITEM_EDIT ;
+ Text [ en-US ] = "Edit" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE;
+ };
+ MenuItem
+ {
+ Identifier = TBI_ITEM_REMOVE ;
+ HelpId = HID_XFORMS_TOOLBOX_ITEM_REMOVE ;
+ Text [ en-US ] = "Delete" ;
+ };
+ };
+};
+
+ModalDialog RID_SVXDLG_ADD_CONDITION
+{
+ HelpID = HID_XFORMS_ADDCONDITION_DLG ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 210 , 150 ) ;
+ Text [ en-US ] = "Add Condition" ;
+ Moveable = TRUE ;
+ FixedText FT_CONDITION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 198 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Condition" ;
+ };
+ MultiLineEdit ED_CONDITION
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 198 , 34 ) ;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ IgnoreTab = TRUE;
+ };
+ FixedText FT_RESULT
+ {
+ Pos = MAP_APPFONT ( 6 , 51 ) ;
+ Size = MAP_APPFONT ( 198 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Result" ;
+ };
+ FixedText FT_RESULT_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 6 , 62 ) ;
+ Size = MAP_APPFONT ( 198 , 34 ) ;
+ Border = TRUE;
+ TabStop = TRUE ;
+ Left = TRUE ;
+ WordBreak = TRUE ;
+ };
+ PushButton PB_EDIT_NAMESPACES
+ {
+ Pos = MAP_APPFONT ( 132 , 102 ) ;
+ Size = MAP_APPFONT ( 72 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Edit Namespaces..." ;
+ };
+ FixedLine FL_DATANAV_BTN
+ {
+ Pos = MAP_APPFONT ( 4 , 119 ) ;
+ Size = MAP_APPFONT ( 202 , 8 ) ;
+ };
+ OKButton BTN_DATANAV_OK
+ {
+ Pos = MAP_APPFONT ( 45 , 130 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_DATANAV_ESC
+ {
+ Pos = MAP_APPFONT ( 98 , 130 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_DATANAV_HELP
+ {
+ Pos = MAP_APPFONT ( 154 , 130 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+};
+
+ModalDialog RID_SVXDLG_NAMESPACE_ITEM
+{
+ HelpID = HID_XFORMS_NAMESPACEITEM_DLG ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 240 , 120 ) ;
+ Text [ en-US ] = "Namespaces for Forms" ;
+ Moveable = TRUE ;
+ FixedText FT_NAMESPACES
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 228 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Namespaces" ;
+ };
+ Control LB_NAMESPACES
+ {
+ HelpId = HID_XFORMS_NAMESPACEITEM_LIST;
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 175 , 72 ) ;
+ Border = TRUE ;
+ TabStop = TRUE ;
+ };
+ PushButton PB_ADD_NAMESPACE
+ {
+ Pos = MAP_APPFONT ( 184 , 14 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Add..." ;
+ };
+ PushButton PB_EDIT_NAMESPACE
+ {
+ Pos = MAP_APPFONT ( 184 , 31 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Edit..." ;
+ };
+ PushButton PB_DELETE_NAMESPACE
+ {
+ Pos = MAP_APPFONT ( 184 , 48 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Delete" ;
+ };
+ FixedLine FL_DATANAV_BTN
+ {
+ Pos = MAP_APPFONT ( 4 , 89 ) ;
+ Size = MAP_APPFONT ( 232 , 8 ) ;
+ };
+ OKButton BTN_DATANAV_OK
+ {
+ Pos = MAP_APPFONT ( 75 , 100 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_DATANAV_ESC
+ {
+ Pos = MAP_APPFONT ( 128 , 100 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_DATANAV_HELP
+ {
+ Pos = MAP_APPFONT ( 184 , 100 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_HEADER_PREFIX
+ {
+ Text [ en-US ] = "Prefix" ;
+ };
+ String STR_HEADER_URL
+ {
+ Text [ en-US ] = "URL" ;
+ };
+};
+
+ModalDialog RID_SVXDLG_MANAGE_NAMESPACE
+{
+ HelpID = HID_XFORMS_MANAGENAMESPACE_DLG ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 210 , 60 ) ;
+ Text [ en-US ] = "Add Namespace" ;
+ Moveable = TRUE ;
+ FixedText FT_PREFIX
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Prefix" ;
+ };
+ Edit ED_PREFIX
+ {
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 45 , 12 ) ;
+ Border = TRUE;
+ };
+ FixedText FT_URL
+ {
+ Pos = MAP_APPFONT ( 54 , 3 ) ;
+ Size = MAP_APPFONT ( 150 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~URL" ;
+ };
+ Edit ED_URL
+ {
+ Pos = MAP_APPFONT ( 54 , 14 ) ;
+ Size = MAP_APPFONT ( 150 , 12 ) ;
+ Border = TRUE;
+ };
+ FixedLine FL_DATANAV_BTN
+ {
+ Pos = MAP_APPFONT ( 4 , 29 ) ;
+ Size = MAP_APPFONT ( 202 , 8 ) ;
+ };
+ OKButton BTN_DATANAV_OK
+ {
+ Pos = MAP_APPFONT ( 45 , 40 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_DATANAV_ESC
+ {
+ Pos = MAP_APPFONT ( 98 , 40 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_DATANAV_HELP
+ {
+ Pos = MAP_APPFONT ( 154 , 40 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_EDIT_TEXT
+ {
+ Text [ en-US ] = "Edit Namespace" ;
+ };
+};
+
+ModalDialog RID_SVXDLG_ADD_SUBMISSION
+{
+ HelpID = HID_XFORMS_ADDSUBMISSION_DLG ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 180 , 136 ) ;
+ Text [ en-US ] = "Add Submission" ;
+ Moveable = TRUE ;
+ FixedLine FL_SUBMISSION
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( 172 , 8 ) ;
+ Text [ en-US ] = "Submission" ;
+ };
+ FixedText FT_SUBMIT_NAME
+ {
+ Pos = MAP_APPFONT ( 6 , 16 ) ;
+ Size = MAP_APPFONT ( 69 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Name" ;
+ };
+ Edit ED_SUBMIT_NAME
+ {
+ Pos = MAP_APPFONT ( 78 , 14 ) ;
+ Size = MAP_APPFONT ( 96 , 12 ) ;
+ Border = TRUE ;
+ };
+ FixedText FT_SUBMIT_ACTION
+ {
+ Pos = MAP_APPFONT ( 6 , 31 ) ;
+ Size = MAP_APPFONT ( 69 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Action" ;
+ };
+ Edit ED_SUBMIT_ACTION
+ {
+ Pos = MAP_APPFONT ( 78 , 29 ) ;
+ Size = MAP_APPFONT ( 96 , 12 ) ;
+ Border = TRUE ;
+ };
+ FixedText FT_SUBMIT_METHOD
+ {
+ Pos = MAP_APPFONT ( 6 , 46 ) ;
+ Size = MAP_APPFONT ( 69 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Method" ;
+ };
+ ListBox LB_SUBMIT_METHOD
+ {
+ Pos = MAP_APPFONT ( 78 , 44 ) ;
+ Size = MAP_APPFONT ( 96 , 51 ) ;
+ Border = TRUE ;
+ DropDown = TRUE;
+ };
+ FixedText FT_SUBMIT_REF
+ {
+ Pos = MAP_APPFONT ( 6 , 62 ) ;
+ Size = MAP_APPFONT ( 69 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "Binding e~xpression" ;
+ };
+ Edit ED_SUBMIT_REF
+ {
+ Pos = MAP_APPFONT ( 78 , 60 ) ;
+ Size = MAP_APPFONT ( 79, 12 ) ;
+ Border = TRUE ;
+ };
+ PushButton PB_SUBMIT_REF
+ {
+ Pos = MAP_APPFONT ( 159 , 59 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~..." ;
+ };
+ FixedText FT_SUBMIT_BIND
+ {
+ Pos = MAP_APPFONT ( 6 , 77 ) ;
+ Size = MAP_APPFONT ( 69 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Binding" ;
+ };
+ ListBox LB_SUBMIT_BIND
+ {
+ Pos = MAP_APPFONT ( 78 , 75 ) ;
+ Size = MAP_APPFONT ( 96 , 51 ) ;
+ Border = TRUE ;
+ DropDown = TRUE;
+ };
+ FixedText FT_SUBMIT_REPLACE
+ {
+ Pos = MAP_APPFONT ( 6 , 92 ) ;
+ Size = MAP_APPFONT ( 69 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Replace" ;
+ };
+ ListBox LB_SUBMIT_REPLACE
+ {
+ Pos = MAP_APPFONT ( 78 , 90 ) ;
+ Size = MAP_APPFONT ( 96 , 51 ) ;
+ Border = TRUE ;
+ DropDown = TRUE;
+ };
+ FixedLine FL_DATANAV_BTN
+ {
+ Pos = MAP_APPFONT ( 4 , 105 ) ;
+ Size = MAP_APPFONT ( 172 , 8 ) ;
+ };
+ OKButton BTN_DATANAV_OK
+ {
+ Pos = MAP_APPFONT ( 15 , 116 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_DATANAV_ESC
+ {
+ Pos = MAP_APPFONT ( 68 , 116 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_DATANAV_HELP
+ {
+ Pos = MAP_APPFONT ( 124 , 116 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ String STR_METHOD_POST
+ {
+ Text [ en-US ] = "Post" ;
+ };
+ String STR_METHOD_PUT
+ {
+ Text [ en-US ] = "Put" ;
+ };
+ String STR_METHOD_GET
+ {
+ Text [ en-US ] = "Get" ;
+ };
+ String STR_REPLACE_NONE
+ {
+ Text [ en-US ] = "None" ;
+ };
+ String STR_REPLACE_INST
+ {
+ Text [ en-US ] = "Instance" ;
+ };
+ String STR_REPLACE_DOC
+ {
+ Text [ en-US ] = "Document" ;
+ };
+};
+
+ModalDialog RID_SVXDLG_ADD_MODEL
+{
+ HelpID = HID_XFORMS_ADDMODEL_DLG ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 180 , 82 ) ;
+ Text [ en-US ] = "Add Model" ;
+ Moveable = TRUE ;
+ FixedLine FL_INSTANCE
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( 172 , 8 ) ;
+ Text [ en-US ] = "Model" ;
+ };
+ FixedText FT_INST_NAME
+ {
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 51 , 12 ) ;
+ LeftLabel = TRUE ;
+ VCenter = TRUE;
+ Text [ en-US ] = "~Name" ;
+ };
+ Edit ED_INST_NAME
+ {
+ Pos = MAP_APPFONT ( 60 , 14 ) ;
+ Size = MAP_APPFONT ( 114 , 12 ) ;
+ Border = TRUE ;
+ };
+ CheckBox CB_MODIFIES_DOCUMENT
+ {
+ Pos = MAP_APPFONT( 6, 32 );
+ Size = MAP_APPFONT( 168, 16 );
+ Top = TRUE;
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "Model data updates change document's modification status";
+ };
+ FixedLine FL_DATANAV_BTN
+ {
+ Pos = MAP_APPFONT ( 4 , 51 ) ;
+ Size = MAP_APPFONT ( 172 , 8 ) ;
+ };
+ OKButton BTN_DATANAV_OK
+ {
+ Pos = MAP_APPFONT ( 15 , 62 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_DATANAV_ESC
+ {
+ Pos = MAP_APPFONT ( 68 , 62 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_DATANAV_HELP
+ {
+ Pos = MAP_APPFONT ( 124 , 62 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_EDIT_TEXT
+ {
+ Text [ en-US ] = "Edit Model" ;
+ };
+};
+
+ModalDialog RID_SVXDLG_ADD_INSTANCE
+{
+ HelpID = HID_XFORMS_ADDINSTANCE_DLG ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 210 , 88 ) ;
+ Text [ en-US ] = "Add Instance" ;
+ Moveable = TRUE ;
+ FixedLine FL_INSTANCE
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( 202 , 8 ) ;
+ Text [ en-US ] = "Instance" ;
+ };
+ FixedText FT_INST_NAME
+ {
+ Pos = MAP_APPFONT ( 6 , 15 ) ;
+ Size = MAP_APPFONT ( 51 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~Name" ;
+ };
+ Edit ED_INST_NAME
+ {
+ Pos = MAP_APPFONT ( 60 , 14 ) ;
+ Size = MAP_APPFONT ( 144 , 12 ) ;
+ Border = TRUE ;
+ };
+ FixedText FT_INST_URL
+ {
+ Pos = MAP_APPFONT ( 6 , 30 ) ;
+ Size = MAP_APPFONT ( 51 , 8 ) ;
+ LeftLabel = TRUE ;
+ Text [ en-US ] = "~URL" ;
+ };
+ ComboBox ED_INST_URL
+ {
+ Pos = MAP_APPFONT ( 60 , 29 ) ;
+ Size = MAP_APPFONT ( 127 , 48 ) ;
+ DropDown = TRUE ;
+ Border = TRUE ;
+ };
+ PushButton PB_FILEPICKER
+ {
+ Pos = MAP_APPFONT ( 190 , 28 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ TabStop = TRUE ;
+ Text = "~..." ;
+ };
+ CheckBox CB_INST_LINKINST
+ {
+ Pos = MAP_APPFONT ( 6 , 44 ) ;
+ Size = MAP_APPFONT ( 198 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Link instance" ;
+ };
+ FixedLine FL_DATANAV_BTN
+ {
+ Pos = MAP_APPFONT ( 4 , 57 ) ;
+ Size = MAP_APPFONT ( 202 , 8 ) ;
+ };
+ OKButton BTN_DATANAV_OK
+ {
+ Pos = MAP_APPFONT ( 45 , 68 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_DATANAV_ESC
+ {
+ Pos = MAP_APPFONT ( 98 , 68 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_DATANAV_HELP
+ {
+ Pos = MAP_APPFONT ( 154 , 68 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_EDIT_TEXT
+ {
+ Text [ en-US ] = "Edit Instance" ;
+ };
+};
+
+String RID_STR_DATANAV_SUBM_PARENT
+{
+ Text [ en-US ] = "Submission: " ;
+};
+String RID_STR_DATANAV_SUBM_ID
+{
+ Text [ en-US ] = "ID: " ;
+};
+String RID_STR_DATANAV_SUBM_BIND
+{
+ Text [ en-US ] = "Binding: " ;
+};
+String RID_STR_DATANAV_SUBM_REF
+{
+ Text [ en-US ] = "Reference: " ;
+};
+String RID_STR_DATANAV_SUBM_ACTION
+{
+ Text [ en-US ] = "Action: " ;
+};
+String RID_STR_DATANAV_SUBM_METHOD
+{
+ Text [ en-US ] = "Method: " ;
+};
+String RID_STR_DATANAV_SUBM_REPLACE
+{
+ Text [ en-US ] = "Replace: " ;
+};
+String RID_STR_DATANAV_ADD_ELEMENT
+{
+ Text [ en-US ] = "Add Element" ;
+};
+String RID_STR_DATANAV_EDIT_ELEMENT
+{
+ Text [ en-US ] = "Edit Element" ;
+};
+String RID_STR_DATANAV_REMOVE_ELEMENT
+{
+ Text [ en-US ] = "Delete Element" ;
+};
+String RID_STR_DATANAV_ADD_ATTRIBUTE
+{
+ Text [ en-US ] = "Add Attribute" ;
+};
+String RID_STR_DATANAV_EDIT_ATTRIBUTE
+{
+ Text [ en-US ] = "Edit Attribute" ;
+};
+String RID_STR_DATANAV_REMOVE_ATTRIBUTE
+{
+ Text [ en-US ] = "Delete Attribute" ;
+};
+String RID_STR_DATANAV_ADD_BINDING
+{
+ Text [ en-US ] = "Add Binding" ;
+};
+String RID_STR_DATANAV_EDIT_BINDING
+{
+ Text [ en-US ] = "Edit Binding" ;
+};
+String RID_STR_DATANAV_REMOVE_BINDING
+{
+ Text [ en-US ] = "Delete Binding" ;
+};
+String RID_STR_DATANAV_ADD_SUBMISSION
+{
+ Text [ en-US ] = "Add Submission" ;
+};
+String RID_STR_DATANAV_EDIT_SUBMISSION
+{
+ Text [ en-US ] = "Edit Submission" ;
+};
+String RID_STR_DATANAV_REMOVE_SUBMISSION
+{
+ Text [ en-US ] = "Delete Submission" ;
+};
+String RID_STR_DATANAV_LINKWARN_BUTTON
+{
+ Text [ en-US ] = "~Edit" ;
+};
+
diff --git a/svx/source/form/dbcharsethelper.cxx b/svx/source/form/dbcharsethelper.cxx
new file mode 100644
index 000000000000..3e9b4ff8a509
--- /dev/null
+++ b/svx/source/form/dbcharsethelper.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "svx/dbcharsethelper.hxx"
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= ODataAccessCharsetHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ ODataAccessCharsetHelper::ODataAccessCharsetHelper( )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool ODataAccessCharsetHelper::ensureLoaded() const
+ {
+ if ( !ODbtoolsClient::ensureLoaded() )
+ return false;
+ m_xCharsetHelper = getFactory()->createCharsetHelper( );
+ return m_xCharsetHelper.is();
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/dbtoolsclient.cxx b/svx/source/form/dbtoolsclient.cxx
new file mode 100644
index 000000000000..6f8c1d30992e
--- /dev/null
+++ b/svx/source/form/dbtoolsclient.cxx
@@ -0,0 +1,368 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include "svx/dbtoolsclient.hxx"
+#include <osl/diagnose.h>
+#include <connectivity/formattedcolumnvalue.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ using namespace ::connectivity::simple;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::container;
+
+ //====================================================================
+ //= ODbtoolsClient
+ //====================================================================
+ ::osl::Mutex ODbtoolsClient::s_aMutex;
+ sal_Int32 ODbtoolsClient::s_nClients = 0;
+ oslModule ODbtoolsClient::s_hDbtoolsModule = NULL;
+ createDataAccessToolsFactoryFunction
+ ODbtoolsClient::s_pFactoryCreationFunc = NULL;
+
+ //--------------------------------------------------------------------
+ ODbtoolsClient::ODbtoolsClient()
+ {
+ m_bCreateAlready = FALSE;
+ }
+
+ //--------------------------------------------------------------------
+ bool ODbtoolsClient::ensureLoaded() const
+ {
+ if ( !m_bCreateAlready )
+ {
+ m_bCreateAlready = true;
+
+ registerClient();
+ if ( s_pFactoryCreationFunc )
+ { // loading the lib succeeded
+ void* pUntypedFactory = (*s_pFactoryCreationFunc)();
+ IDataAccessToolsFactory* pDBTFactory = static_cast< IDataAccessToolsFactory* >( pUntypedFactory );
+ OSL_ENSURE( pDBTFactory, "ODbtoolsClient::ODbtoolsClient: no factory returned!" );
+ if ( pDBTFactory )
+ {
+ m_xDataAccessFactory = pDBTFactory;
+ // by definition, the factory was aquired once
+ m_xDataAccessFactory->release();
+ }
+ }
+ }
+ return m_xDataAccessFactory.is();
+ }
+
+ //--------------------------------------------------------------------
+ ODbtoolsClient::~ODbtoolsClient()
+ {
+ // clear the factory _before_ revoking the client
+ // (the revocation may unload the DBT lib)
+ m_xDataAccessFactory = NULL;
+ // revoke the client
+ if ( m_bCreateAlready )
+ revokeClient();
+ }
+
+ //--------------------------------------------------------------------
+ extern "C" { static void SAL_CALL thisModule() {} }
+
+ void ODbtoolsClient::registerClient()
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ if (1 == ++s_nClients)
+ {
+ OSL_ENSURE(NULL == s_hDbtoolsModule, "ODbtoolsClient::registerClient: inconsistence: already have a module!");
+ OSL_ENSURE(NULL == s_pFactoryCreationFunc, "ODbtoolsClient::registerClient: inconsistence: already have a factory function!");
+
+ const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii(
+ SVLIBRARY( "dbtools" )
+ );
+
+ // load the dbtools library
+ s_hDbtoolsModule = osl_loadModuleRelative(
+ &thisModule, sModuleName.pData, 0);
+ OSL_ENSURE(NULL != s_hDbtoolsModule, "ODbtoolsClient::registerClient: could not load the dbtools library!");
+ if (NULL != s_hDbtoolsModule)
+ {
+ // get the symbol for the method creating the factory
+ const ::rtl::OUString sFactoryCreationFunc = ::rtl::OUString::createFromAscii("createDataAccessToolsFactory");
+ // reinterpret_cast<createDataAccessToolsFactoryFunction>
+ s_pFactoryCreationFunc = (createDataAccessToolsFactoryFunction)(
+ osl_getFunctionSymbol(s_hDbtoolsModule, sFactoryCreationFunc.pData));
+
+ if (NULL == s_pFactoryCreationFunc)
+ { // did not find the symbol
+ OSL_ENSURE(sal_False, "ODbtoolsClient::registerClient: could not find the symbol for creating the factory!");
+ osl_unloadModule(s_hDbtoolsModule);
+ s_hDbtoolsModule = NULL;
+ }
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ODbtoolsClient::revokeClient()
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ if (0 == --s_nClients)
+ {
+ s_pFactoryCreationFunc = NULL;
+ if (s_hDbtoolsModule)
+ osl_unloadModule(s_hDbtoolsModule);
+ s_hDbtoolsModule = NULL;
+ }
+
+ OSL_ENSURE(s_nClients >= 0,"Illegall call of revokeClient()");
+ }
+
+ //====================================================================
+ //= OStaticDataAccessTools
+ //====================================================================
+ //--------------------------------------------------------------------
+ OStaticDataAccessTools::OStaticDataAccessTools()
+ {
+ }
+
+ //--------------------------------------------------------------------
+
+ bool OStaticDataAccessTools::ensureLoaded() const
+ {
+ if ( !ODbtoolsClient::ensureLoaded() )
+ return false;
+ m_xDataAccessTools = getFactory()->getDataAccessTools();
+ return m_xDataAccessTools.is();
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XNumberFormatsSupplier > OStaticDataAccessTools::getNumberFormats(const Reference< XConnection>& _rxConn, sal_Bool _bAllowDefault) const
+ {
+ Reference< XNumberFormatsSupplier > xReturn;
+ if ( ensureLoaded() )
+ xReturn = m_xDataAccessTools->getNumberFormats(_rxConn, _bAllowDefault);
+ return xReturn;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 OStaticDataAccessTools::getDefaultNumberFormat( const Reference< XPropertySet >& _xColumn, const Reference< XNumberFormatTypes >& _xTypes, const Locale& _rLocale )
+ {
+ sal_Int32 nReturn = 0;
+ if ( ensureLoaded() )
+ nReturn = m_xDataAccessTools->getDefaultNumberFormat( _xColumn, _xTypes, _rLocale );
+ return nReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XConnection> OStaticDataAccessTools::getConnection_withFeedback(const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rUser, const ::rtl::OUString& _rPwd, const Reference< XMultiServiceFactory>& _rxFactory) const
+ SAL_THROW ( (SQLException) )
+ {
+ Reference< XConnection > xReturn;
+ if ( ensureLoaded() )
+ xReturn = m_xDataAccessTools->getConnection_withFeedback(_rDataSourceName, _rUser, _rPwd, _rxFactory);
+ return xReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XConnection > OStaticDataAccessTools::connectRowset( const Reference< XRowSet >& _rxRowSet,
+ const Reference< XMultiServiceFactory >& _rxFactory, sal_Bool _bSetAsActiveConnection ) const
+ SAL_THROW ( ( SQLException, WrappedTargetException, RuntimeException ) )
+ {
+ Reference< XConnection > xReturn;
+ if ( ensureLoaded() )
+ xReturn = m_xDataAccessTools->connectRowset( _rxRowSet, _rxFactory, _bSetAsActiveConnection );
+ return xReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XConnection > OStaticDataAccessTools::getRowSetConnection(const Reference< XRowSet >& _rxRowSet) const SAL_THROW ( (RuntimeException) )
+ {
+ Reference< XConnection > xReturn;
+ if ( ensureLoaded() )
+ xReturn = m_xDataAccessTools->getRowSetConnection(_rxRowSet);
+ return xReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void OStaticDataAccessTools::TransferFormComponentProperties(const Reference< XPropertySet>& _rxOld,
+ const Reference< XPropertySet>& _rxNew, const Locale& _rLocale) const
+ {
+ if ( ensureLoaded() )
+ m_xDataAccessTools->TransferFormComponentProperties(_rxOld, _rxNew, _rLocale);
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString OStaticDataAccessTools::quoteName(const ::rtl::OUString& _rQuote, const ::rtl::OUString& _rName) const
+ {
+ ::rtl::OUString sReturn;
+ if ( ensureLoaded() )
+ sReturn = m_xDataAccessTools->quoteName(_rQuote, _rName);
+ return sReturn;
+ }
+
+ // ------------------------------------------------
+ ::rtl::OUString OStaticDataAccessTools::composeTableNameForSelect( const Reference< XConnection >& _rxConnection, const Reference< XPropertySet>& _xTable ) const
+ {
+ ::rtl::OUString sReturn;
+ if ( ensureLoaded() )
+ sReturn = m_xDataAccessTools->composeTableNameForSelect( _rxConnection, _xTable );
+ return sReturn;
+ }
+
+ //--------------------------------------------------------------------
+ SQLContext OStaticDataAccessTools::prependContextInfo(SQLException& _rException, const Reference< XInterface >& _rxContext,
+ const ::rtl::OUString& _rContextDescription, const ::rtl::OUString& _rContextDetails) const
+ {
+ SQLContext aReturn;
+ if ( ensureLoaded() )
+ aReturn = m_xDataAccessTools->prependContextInfo(_rException, _rxContext, _rContextDescription, _rContextDetails);
+ return aReturn;
+ }
+
+ //----------------------------------------------------------------
+ Reference< XDataSource > OStaticDataAccessTools::getDataSource( const ::rtl::OUString& _rsRegisteredName, const Reference< XMultiServiceFactory>& _rxFactory ) const
+ {
+ Reference< XDataSource > xReturn;
+ if ( ensureLoaded() )
+ xReturn = m_xDataAccessTools->getDataSource(_rsRegisteredName,_rxFactory);
+ return xReturn;
+ }
+
+ //----------------------------------------------------------------
+ sal_Bool OStaticDataAccessTools::canInsert(const Reference< XPropertySet>& _rxCursorSet) const
+ {
+ sal_Bool bRet = sal_False;
+ if ( ensureLoaded() )
+ bRet = m_xDataAccessTools->canInsert( _rxCursorSet );
+ return bRet;
+ }
+
+ //----------------------------------------------------------------
+ sal_Bool OStaticDataAccessTools::canUpdate(const Reference< XPropertySet>& _rxCursorSet) const
+ {
+ sal_Bool bRet = sal_False;
+ if ( ensureLoaded() )
+ bRet = m_xDataAccessTools->canUpdate( _rxCursorSet );
+ return bRet;
+ }
+
+ //----------------------------------------------------------------
+ sal_Bool OStaticDataAccessTools::canDelete(const Reference< XPropertySet>& _rxCursorSet) const
+ {
+ sal_Bool bRet = sal_False;
+ if ( ensureLoaded() )
+ bRet = m_xDataAccessTools->canDelete( _rxCursorSet );
+ return bRet;
+ }
+
+ //----------------------------------------------------------------
+ Reference< XNameAccess > OStaticDataAccessTools::getFieldsByCommandDescriptor( const Reference< XConnection >& _rxConnection,
+ const sal_Int32 _nCommandType, const ::rtl::OUString& _rCommand,
+ Reference< XComponent >& _rxKeepFieldsAlive, ::dbtools::SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
+ {
+ Reference< XNameAccess > aFields;
+ if ( ensureLoaded() )
+ aFields = m_xDataAccessTools->getFieldsByCommandDescriptor( _rxConnection, _nCommandType,
+ _rCommand, _rxKeepFieldsAlive, _pErrorInfo );
+
+ return aFields;
+ }
+
+ //----------------------------------------------------------------
+ Sequence< ::rtl::OUString > OStaticDataAccessTools::getFieldNamesByCommandDescriptor(
+ const Reference< XConnection >& _rxConnection, const sal_Int32 _nCommandType,
+ const ::rtl::OUString& _rCommand, ::dbtools::SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) )
+ {
+ Sequence< ::rtl::OUString > aNames;
+ if ( ensureLoaded() )
+ aNames = m_xDataAccessTools->getFieldNamesByCommandDescriptor( _rxConnection, _nCommandType,
+ _rCommand, _pErrorInfo );
+ return aNames;
+ }
+
+ //----------------------------------------------------------------
+ bool OStaticDataAccessTools::isEmbeddedInDatabase( const Reference< XInterface >& _rxComponent, Reference< XConnection >& _rxActualConnection )
+ {
+ bool bReturn = false;
+ if ( ensureLoaded() )
+ bReturn = m_xDataAccessTools->isEmbeddedInDatabase( _rxComponent, _rxActualConnection );
+ return bReturn;
+ }
+
+ //----------------------------------------------------------------
+ bool OStaticDataAccessTools::isEmbeddedInDatabase( const Reference< XInterface >& _rxComponent )
+ {
+ bool bReturn = false;
+ if ( ensureLoaded() )
+ {
+ Reference< XConnection > xDummy;
+ bReturn = m_xDataAccessTools->isEmbeddedInDatabase( _rxComponent, xDummy );
+ }
+ return bReturn;
+ }
+
+ //====================================================================
+ //= DBToolsObjectFactory
+ //====================================================================
+ //----------------------------------------------------------------
+ DBToolsObjectFactory::DBToolsObjectFactory()
+ {
+ }
+
+ //----------------------------------------------------------------
+ DBToolsObjectFactory::~DBToolsObjectFactory()
+ {
+ }
+
+ //----------------------------------------------------------------
+ ::std::auto_ptr< ::dbtools::FormattedColumnValue > DBToolsObjectFactory::createFormattedColumnValue(
+ const ::comphelper::ComponentContext& _rContext, const Reference< XRowSet >& _rxRowSet, const Reference< XPropertySet >& _rxColumn )
+ {
+ ::std::auto_ptr< ::dbtools::FormattedColumnValue > pValue;
+ if ( ensureLoaded() )
+ pValue = getFactory()->createFormattedColumnValue( _rContext, _rxRowSet, _rxColumn );
+ return pValue;
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/delayedevent.cxx b/svx/source/form/delayedevent.cxx
new file mode 100644
index 000000000000..95a08c158997
--- /dev/null
+++ b/svx/source/form/delayedevent.cxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * 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.
+ *
+************************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include "delayedevent.hxx"
+
+#include <osl/diagnose.h>
+#include <vcl/svapp.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= DelayedEvent
+ //====================================================================
+ //--------------------------------------------------------------------
+ void DelayedEvent::Call( void* _pArg )
+ {
+ CancelPendingCall();
+ OSL_POSTCOND( m_nEventId == 0, "DelayedEvent::Call: CancelPendingCall did not work!" );
+
+ m_nEventId = Application::PostUserEvent( LINK( this, DelayedEvent, OnCall ), _pArg );
+ }
+
+ //--------------------------------------------------------------------
+ void DelayedEvent::CancelPendingCall()
+ {
+ if ( m_nEventId )
+ Application::RemoveUserEvent( m_nEventId );
+ m_nEventId = 0;
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( DelayedEvent, OnCall, void*, _pArg )
+ {
+ m_nEventId = 0;
+ return m_aHandler.Call( _pArg );
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx
new file mode 100644
index 000000000000..5176265d773e
--- /dev/null
+++ b/svx/source/form/filtnav.cxx
@@ -0,0 +1,2088 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+
+#include "filtnav.hxx"
+#include "fmexch.hxx"
+#include "fmhelp.hrc"
+#include "fmitems.hxx"
+#include "fmprop.hrc"
+#include "fmresids.hrc"
+#include "gridcell.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/processfactory.hxx>
+#include <svx/fmtools.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/uno3.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <fmservs.hxx>
+#include <fmshimp.hxx>
+#include <rtl/logfile.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objitem.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/svxids.hrc>
+#include <tools/shl.hxx>
+#include <vcl/wrkwin.hxx>
+
+#include <functional>
+
+#define SYNC_DELAY 200
+#define DROP_ACTION_TIMER_INITIAL_TICKS 10
+ // solange dauert es, bis das Scrollen anspringt
+#define DROP_ACTION_TIMER_SCROLL_TICKS 3
+ // in diesen Intervallen wird jeweils eine Zeile gescrollt
+#define DROP_ACTION_TIMER_TICK_BASE 10
+ // das ist die Basis, mit der beide Angaben multipliziert werden (in ms)
+
+using namespace ::svxform;
+using namespace ::connectivity::simple;
+using namespace ::connectivity;
+
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::awt::TextEvent;
+ using ::com::sun::star::container::XIndexAccess;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::form::runtime::XFormController;
+ using ::com::sun::star::form::runtime::XFilterController;
+ using ::com::sun::star::form::runtime::XFilterControllerListener;
+ using ::com::sun::star::form::runtime::FilterEvent;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::form::XForm;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::awt::XControl;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::util::XNumberFormatsSupplier;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::util::XNumberFormatter;
+ using ::com::sun::star::sdbc::XRowSet;
+ using ::com::sun::star::lang::Locale;
+ using ::com::sun::star::sdb::SQLContext;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::awt::XTextComponent;
+ using ::com::sun::star::uno::Sequence;
+ /** === end UNO using === **/
+
+//========================================================================
+OFilterItemExchange::OFilterItemExchange()
+{
+}
+
+//------------------------------------------------------------------------
+void OFilterItemExchange::AddSupportedFormats()
+{
+ AddFormat(getFormatId());
+}
+
+//------------------------------------------------------------------------
+sal_uInt32 OFilterItemExchange::getFormatId()
+{
+ static sal_uInt32 s_nFormat = (sal_uInt32)-1;
+ if ((sal_uInt32)-1 == s_nFormat)
+ {
+ s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"form.FilterControlExchange\""));
+ DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OFilterExchangeHelper::getFormatId: bad exchange id!");
+ }
+ return s_nFormat;
+}
+
+//------------------------------------------------------------------------
+OLocalExchange* OFilterExchangeHelper::createExchange() const
+{
+ return new OFilterItemExchange;
+}
+
+//========================================================================
+TYPEINIT0(FmFilterData);
+Image FmFilterData::GetImage( BmpColorMode /*_eMode*/ ) const
+{
+ return Image();
+}
+
+//========================================================================
+TYPEINIT1(FmParentData, FmFilterData);
+//------------------------------------------------------------------------
+FmParentData::~FmParentData()
+{
+ for (::std::vector<FmFilterData*>::const_iterator i = m_aChildren.begin();
+ i != m_aChildren.end(); i++)
+ delete (*i);
+}
+
+//========================================================================
+TYPEINIT1(FmFormItem, FmParentData);
+//------------------------------------------------------------------------
+Image FmFormItem::GetImage( BmpColorMode _eMode ) const
+{
+ static Image aImage;
+ static Image aImage_HC;
+
+ if (!aImage)
+ {
+ ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) );
+ ImageList aNavigatorImages_HC( SVX_RES( RID_SVXIMGLIST_FMEXPL_HC ) );
+
+ aImage = aNavigatorImages.GetImage( RID_SVXIMG_FORM );
+ aImage_HC = aNavigatorImages_HC.GetImage( RID_SVXIMG_FORM );
+ }
+ return ( BMP_COLOR_HIGHCONTRAST == _eMode ) ? aImage_HC : aImage;
+}
+
+//========================================================================
+TYPEINIT1(FmFilterItems, FmParentData);
+//------------------------------------------------------------------------
+FmFilterItem* FmFilterItems::Find( const ::sal_Int32 _nFilterComponentIndex ) const
+{
+ for ( ::std::vector< FmFilterData* >::const_iterator i = m_aChildren.begin();
+ i != m_aChildren.end();
+ ++i
+ )
+ {
+ FmFilterItem* pCondition = PTR_CAST( FmFilterItem, *i );
+ DBG_ASSERT( pCondition, "FmFilterItems::Find: Wrong element in container!" );
+ if ( _nFilterComponentIndex == pCondition->GetComponentIndex() )
+ return pCondition;
+ }
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+Image FmFilterItems::GetImage( BmpColorMode _eMode ) const
+{
+ static Image aImage;
+ static Image aImage_HC;
+
+ if (!aImage)
+ {
+ ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) );
+ ImageList aNavigatorImages_HC( SVX_RES( RID_SVXIMGLIST_FMEXPL_HC ) );
+
+ aImage = aNavigatorImages.GetImage( RID_SVXIMG_FILTER );
+ aImage_HC = aNavigatorImages_HC.GetImage( RID_SVXIMG_FILTER );
+ }
+ return ( BMP_COLOR_HIGHCONTRAST == _eMode ) ? aImage_HC : aImage;
+}
+
+//========================================================================
+TYPEINIT1(FmFilterItem, FmFilterData);
+//------------------------------------------------------------------------
+FmFilterItem::FmFilterItem( const Reference< XMultiServiceFactory >& _rxFactory,
+ FmFilterItems* pParent,
+ const ::rtl::OUString& aFieldName,
+ const ::rtl::OUString& aText,
+ const sal_Int32 _nComponentIndex )
+ :FmFilterData(_rxFactory,pParent, aText)
+ ,m_aFieldName(aFieldName)
+ ,m_nComponentIndex( _nComponentIndex )
+{
+}
+
+//------------------------------------------------------------------------
+Image FmFilterItem::GetImage( BmpColorMode _eMode ) const
+{
+ static Image aImage;
+ static Image aImage_HC;
+
+ if (!aImage)
+ {
+ ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) );
+ ImageList aNavigatorImages_HC( SVX_RES( RID_SVXIMGLIST_FMEXPL_HC ) );
+
+ aImage = aNavigatorImages.GetImage( RID_SVXIMG_FIELD );
+ aImage_HC = aNavigatorImages_HC.GetImage( RID_SVXIMG_FIELD );
+ }
+ return ( BMP_COLOR_HIGHCONTRAST == _eMode ) ? aImage_HC : aImage;
+}
+
+//========================================================================
+// Hints for communicatition between model and view
+//========================================================================
+class FmFilterHint : public SfxHint
+{
+ FmFilterData* m_pData;
+
+public:
+ TYPEINFO();
+ FmFilterHint(FmFilterData* pData):m_pData(pData){}
+ FmFilterData* GetData() const { return m_pData; }
+};
+TYPEINIT1( FmFilterHint, SfxHint );
+
+//========================================================================
+class FmFilterInsertedHint : public FmFilterHint
+{
+ sal_Int32 m_nPos; // Position relative to the parent of the data
+
+public:
+ TYPEINFO();
+ FmFilterInsertedHint(FmFilterData* pData, sal_Int32 nRelPos)
+ :FmFilterHint(pData)
+ ,m_nPos(nRelPos){}
+
+ sal_Int32 GetPos() const { return m_nPos; }
+};
+TYPEINIT1( FmFilterInsertedHint, FmFilterHint );
+
+//========================================================================
+class FmFilterRemovedHint : public FmFilterHint
+{
+public:
+ TYPEINFO();
+ FmFilterRemovedHint(FmFilterData* pData)
+ :FmFilterHint(pData){}
+
+};
+TYPEINIT1( FmFilterRemovedHint, FmFilterHint );
+
+//========================================================================
+class FmFilterTextChangedHint : public FmFilterHint
+{
+public:
+ TYPEINFO();
+ FmFilterTextChangedHint(FmFilterData* pData)
+ :FmFilterHint(pData){}
+
+};
+TYPEINIT1( FmFilterTextChangedHint, FmFilterHint );
+
+//========================================================================
+class FilterClearingHint : public SfxHint
+{
+public:
+ TYPEINFO();
+ FilterClearingHint(){}
+};
+TYPEINIT1( FilterClearingHint, SfxHint );
+
+//========================================================================
+class FmFilterCurrentChangedHint : public SfxHint
+{
+public:
+ TYPEINFO();
+ FmFilterCurrentChangedHint(){}
+};
+TYPEINIT1( FmFilterCurrentChangedHint, SfxHint );
+
+//========================================================================
+// class FmFilterAdapter, Listener an den FilterControls
+//========================================================================
+class FmFilterAdapter : public ::cppu::WeakImplHelper1< XFilterControllerListener >
+{
+ FmFilterModel* m_pModel;
+ Reference< XIndexAccess > m_xControllers;
+
+public:
+ FmFilterAdapter(FmFilterModel* pModel, const Reference< XIndexAccess >& xControllers);
+
+// XEventListener
+ virtual void SAL_CALL disposing(const EventObject& Source) throw( RuntimeException );
+
+// XFilterControllerListener
+ virtual void SAL_CALL predicateExpressionChanged( const FilterEvent& _Event ) throw (RuntimeException);
+ virtual void SAL_CALL disjunctiveTermRemoved( const FilterEvent& _Event ) throw (RuntimeException);
+ virtual void SAL_CALL disjunctiveTermAdded( const FilterEvent& _Event ) throw (RuntimeException);
+
+// helpers
+ void dispose() throw( RuntimeException );
+
+ void AddOrRemoveListener( const Reference< XIndexAccess >& _rxControllers, const bool _bAdd );
+
+ void setText(sal_Int32 nPos,
+ const FmFilterItem* pFilterItem,
+ const ::rtl::OUString& rText);
+};
+
+//------------------------------------------------------------------------
+FmFilterAdapter::FmFilterAdapter(FmFilterModel* pModel, const Reference< XIndexAccess >& xControllers)
+ :m_pModel( pModel )
+ ,m_xControllers( xControllers )
+{
+ AddOrRemoveListener( m_xControllers, true );
+}
+
+//------------------------------------------------------------------------
+void FmFilterAdapter::dispose() throw( RuntimeException )
+{
+ AddOrRemoveListener( m_xControllers, false );
+}
+
+//------------------------------------------------------------------------
+void FmFilterAdapter::AddOrRemoveListener( const Reference< XIndexAccess >& _rxControllers, const bool _bAdd )
+{
+ for (sal_Int32 i = 0, nLen = _rxControllers->getCount(); i < nLen; ++i)
+ {
+ Reference< XIndexAccess > xElement( _rxControllers->getByIndex(i), UNO_QUERY );
+
+ // step down
+ AddOrRemoveListener( xElement, _bAdd );
+
+ // handle this particular controller
+ Reference< XFilterController > xController( xElement, UNO_QUERY );
+ OSL_ENSURE( xController.is(), "FmFilterAdapter::InsertElements: no XFilterController, cannot sync data!" );
+ if ( xController.is() )
+ {
+ if ( _bAdd )
+ xController->addFilterControllerListener( this );
+ else
+ xController->removeFilterControllerListener( this );
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFilterAdapter::setText(sal_Int32 nRowPos,
+ const FmFilterItem* pFilterItem,
+ const ::rtl::OUString& rText)
+{
+ FmFormItem* pFormItem = PTR_CAST( FmFormItem, pFilterItem->GetParent()->GetParent() );
+
+ try
+ {
+ Reference< XFilterController > xController( pFormItem->GetController(), UNO_QUERY_THROW );
+ xController->setPredicateExpression( pFilterItem->GetComponentIndex(), nRowPos, rText );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+
+// XEventListener
+//------------------------------------------------------------------------
+void SAL_CALL FmFilterAdapter::disposing(const EventObject& /*e*/) throw( RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------
+namespace
+{
+ ::rtl::OUString lcl_getLabelName_nothrow( const Reference< XControl >& _rxControl )
+ {
+ ::rtl::OUString sLabelName;
+ try
+ {
+ Reference< XControl > xControl( _rxControl, UNO_SET_THROW );
+ Reference< XPropertySet > xModel( xControl->getModel(), UNO_QUERY_THROW );
+ sLabelName = getLabelName( xModel );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sLabelName;
+ }
+
+ Reference< XPropertySet > lcl_getBoundField_nothrow( const Reference< XControl >& _rxControl )
+ {
+ Reference< XPropertySet > xField;
+ try
+ {
+ Reference< XControl > xControl( _rxControl, UNO_SET_THROW );
+ Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW );
+ xField.set( xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xField;
+ }
+}
+
+// XFilterControllerListener
+//------------------------------------------------------------------------
+void FmFilterAdapter::predicateExpressionChanged( const FilterEvent& _Event ) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if ( !m_pModel )
+ return;
+
+ // the controller which sent the event
+ Reference< XFormController > xController( _Event.Source, UNO_QUERY_THROW );
+ Reference< XFilterController > xFilterController( _Event.Source, UNO_QUERY_THROW );
+ Reference< XForm > xForm( xController->getModel(), UNO_QUERY_THROW );
+
+ FmFormItem* pFormItem = m_pModel->Find( m_pModel->m_aChildren, xForm );
+ OSL_ENSURE( pFormItem, "FmFilterAdapter::predicateExpressionChanged: don't know this form!" );
+ if ( !pFormItem )
+ return;
+
+ const sal_Int32 nActiveTerm( xFilterController->getActiveTerm() );
+
+ FmFilterItems* pFilter = PTR_CAST( FmFilterItems, pFormItem->GetChildren()[ nActiveTerm ] );
+ FmFilterItem* pFilterItem = pFilter->Find( _Event.FilterComponent );
+ if ( pFilterItem )
+ {
+ if ( _Event.PredicateExpression.getLength())
+ {
+ pFilterItem->SetText( _Event.PredicateExpression );
+ // UI benachrichtigen
+ FmFilterTextChangedHint aChangeHint(pFilterItem);
+ m_pModel->Broadcast( aChangeHint );
+ }
+ else
+ {
+ // no text anymore so remove the condition
+ m_pModel->Remove(pFilterItem);
+ }
+ }
+ else
+ {
+ // searching the component by field name
+ ::rtl::OUString aFieldName( lcl_getLabelName_nothrow( xFilterController->getFilterComponent( _Event.FilterComponent ) ) );
+
+ pFilterItem = new FmFilterItem( m_pModel->getORB(), pFilter, aFieldName, _Event.PredicateExpression, _Event.FilterComponent );
+ m_pModel->Insert(pFilter->GetChildren().end(), pFilterItem);
+ }
+
+ // ensure there's one empty term in the filter, just in case the active term was previously empty
+ m_pModel->EnsureEmptyFilterRows( *pFormItem );
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL FmFilterAdapter::disjunctiveTermRemoved( const FilterEvent& _Event ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ Reference< XFormController > xController( _Event.Source, UNO_QUERY_THROW );
+ Reference< XFilterController > xFilterController( _Event.Source, UNO_QUERY_THROW );
+ Reference< XForm > xForm( xController->getModel(), UNO_QUERY_THROW );
+
+ FmFormItem* pFormItem = m_pModel->Find( m_pModel->m_aChildren, xForm );
+ OSL_ENSURE( pFormItem, "FmFilterAdapter::disjunctiveTermRemoved: don't know this form!" );
+ if ( !pFormItem )
+ return;
+
+ ::std::vector< FmFilterData* >& rTermItems = pFormItem->GetChildren();
+ const bool bValidIndex = ( _Event.DisjunctiveTerm >= 0 ) && ( (size_t)_Event.DisjunctiveTerm < rTermItems.size() );
+ OSL_ENSURE( bValidIndex, "FmFilterAdapter::disjunctiveTermRemoved: invalid term index!" );
+ if ( !bValidIndex )
+ return;
+
+ // if the first term was removed, then the to-be first term needs its text updated
+ if ( _Event.DisjunctiveTerm == 0 )
+ {
+ rTermItems[1]->SetText( String( SVX_RES( RID_STR_FILTER_FILTER_FOR ) ) );
+ FmFilterTextChangedHint aChangeHint( rTermItems[1] );
+ m_pModel->Broadcast( aChangeHint );
+ }
+
+ // finally remove the entry from the model
+ m_pModel->Remove( rTermItems.begin() + _Event.DisjunctiveTerm );
+
+ // ensure there's one empty term in the filter, just in case the currently removed one was the last empty one
+ m_pModel->EnsureEmptyFilterRows( *pFormItem );
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL FmFilterAdapter::disjunctiveTermAdded( const FilterEvent& _Event ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ Reference< XFormController > xController( _Event.Source, UNO_QUERY_THROW );
+ Reference< XFilterController > xFilterController( _Event.Source, UNO_QUERY_THROW );
+ Reference< XForm > xForm( xController->getModel(), UNO_QUERY_THROW );
+
+ FmFormItem* pFormItem = m_pModel->Find( m_pModel->m_aChildren, xForm );
+ OSL_ENSURE( pFormItem, "FmFilterAdapter::disjunctiveTermAdded: don't know this form!" );
+ if ( !pFormItem )
+ return;
+
+ const sal_Int32 nInsertPos = _Event.DisjunctiveTerm;
+ bool bValidIndex = ( nInsertPos >= 0 ) && ( (size_t)nInsertPos <= pFormItem->GetChildren().size() );
+ if ( !bValidIndex )
+ {
+ OSL_ENSURE( false, "FmFilterAdapter::disjunctiveTermAdded: invalid index!" );
+ return;
+ }
+
+ const ::std::vector< FmFilterData* >::iterator insertPos = pFormItem->GetChildren().begin() + nInsertPos;
+
+ FmFilterItems* pFilterItems = new FmFilterItems( m_pModel->getORB(), pFormItem, String( SVX_RES( RID_STR_FILTER_FILTER_OR ) ) );
+ m_pModel->Insert( insertPos, pFilterItems );
+}
+
+//========================================================================
+// class FmFilterModel
+//========================================================================
+TYPEINIT1(FmFilterModel, FmParentData);
+//------------------------------------------------------------------------
+FmFilterModel::FmFilterModel(const Reference< XMultiServiceFactory >& _rxFactory)
+ :FmParentData(_rxFactory,NULL, ::rtl::OUString())
+ ,OSQLParserClient(_rxFactory)
+ ,m_xORB(_rxFactory)
+ ,m_pAdapter(NULL)
+ ,m_pCurrentItems(NULL)
+{
+}
+
+//------------------------------------------------------------------------
+FmFilterModel::~FmFilterModel()
+{
+ Clear();
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::Clear()
+{
+ // notify
+ FilterClearingHint aClearedHint;
+ Broadcast( aClearedHint );
+
+ // loose endings
+ if (m_pAdapter)
+ {
+ m_pAdapter->dispose();
+ m_pAdapter->release();
+ m_pAdapter= NULL;
+ }
+
+ m_pCurrentItems = NULL;
+ m_xController = NULL;
+ m_xControllers = NULL;
+
+ for (::std::vector<FmFilterData*>::const_iterator i = m_aChildren.begin();
+ i != m_aChildren.end(); i++)
+ delete (*i);
+
+ m_aChildren.clear();
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, const Reference< XFormController > & xCurrent)
+{
+ if ( xCurrent == m_xController )
+ return;
+
+ if (!xControllers.is())
+ {
+ Clear();
+ return;
+ }
+
+ // there is only a new current controller
+ if ( m_xControllers != xControllers )
+ {
+ Clear();
+
+ m_xControllers = xControllers;
+ Update(m_xControllers, this);
+
+ DBG_ASSERT(xCurrent.is(), "FmFilterModel::Update(...) no current controller");
+
+ // Listening for TextChanges
+ m_pAdapter = new FmFilterAdapter(this, xControllers);
+ m_pAdapter->acquire();
+
+ SetCurrentController(xCurrent);
+ EnsureEmptyFilterRows( *this );
+ }
+ else
+ SetCurrentController(xCurrent);
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, FmParentData* pParent)
+{
+ try
+ {
+ sal_Int32 nCount = xControllers->getCount();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ Reference< XFormController > xController( xControllers->getByIndex(i), UNO_QUERY_THROW );
+
+ Reference< XPropertySet > xFormProperties( xController->getModel(), UNO_QUERY_THROW );
+ ::rtl::OUString aName;
+ OSL_VERIFY( xFormProperties->getPropertyValue( FM_PROP_NAME ) >>= aName );
+
+ // Insert a new item for the form
+ FmFormItem* pFormItem = new FmFormItem( m_xORB, pParent, xController, aName );
+ Insert( pParent->GetChildren().end(), pFormItem );
+
+ Reference< XFilterController > xFilterController( pFormItem->GetFilterController(), UNO_SET_THROW );
+
+ // insert the existing filters for the form
+ String aTitle( SVX_RES( RID_STR_FILTER_FILTER_FOR ) );
+
+ Sequence< Sequence< ::rtl::OUString > > aExpressions = xFilterController->getPredicateExpressions();
+ for ( const Sequence< ::rtl::OUString >* pConjunctionTerm = aExpressions.getConstArray();
+ pConjunctionTerm != aExpressions.getConstArray() + aExpressions.getLength();
+ ++pConjunctionTerm
+ )
+ {
+ // we always display one row, even if there's no term to be displayed
+ FmFilterItems* pFilterItems = new FmFilterItems( m_xORB, pFormItem, aTitle );
+ Insert( pFormItem->GetChildren().end(), pFilterItems );
+
+ const Sequence< ::rtl::OUString >& rDisjunction( *pConjunctionTerm );
+ for ( const ::rtl::OUString* pDisjunctiveTerm = rDisjunction.getConstArray();
+ pDisjunctiveTerm != rDisjunction.getConstArray() + rDisjunction.getLength();
+ ++pDisjunctiveTerm
+ )
+ {
+ if ( pDisjunctiveTerm->getLength() == 0 )
+ // no condition for this particular component in this particular conjunction term
+ continue;
+
+ const sal_Int32 nComponentIndex = pDisjunctiveTerm - rDisjunction.getConstArray();
+
+ // determine the display name of the control
+ const Reference< XControl > xFilterControl( xFilterController->getFilterComponent( nComponentIndex ) );
+ const ::rtl::OUString sDisplayName( lcl_getLabelName_nothrow( xFilterControl ) );
+
+ // insert a new entry
+ FmFilterItem* pANDCondition = new FmFilterItem( m_xORB, pFilterItems, sDisplayName, *pDisjunctiveTerm, nComponentIndex );
+ Insert( pFilterItems->GetChildren().end(), pANDCondition );
+ }
+
+ // title for the next conditions
+ aTitle = SVX_RES( RID_STR_FILTER_FILTER_OR );
+ }
+
+ // now add dependent controllers
+ Reference< XIndexAccess > xControllerAsIndex( xController, UNO_QUERY );
+ Update( xControllerAsIndex, pFormItem );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------
+FmFormItem* FmFilterModel::Find(const ::std::vector<FmFilterData*>& rItems, const Reference< XFormController > & xController) const
+{
+ for (::std::vector<FmFilterData*>::const_iterator i = rItems.begin();
+ i != rItems.end(); i++)
+ {
+ FmFormItem* pForm = PTR_CAST(FmFormItem,*i);
+ if (pForm)
+ {
+ if ( xController == pForm->GetController() )
+ return pForm;
+ else
+ {
+ pForm = Find(pForm->GetChildren(), xController);
+ if (pForm)
+ return pForm;
+ }
+ }
+ }
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+FmFormItem* FmFilterModel::Find(const ::std::vector<FmFilterData*>& rItems, const Reference< XForm >& xForm) const
+{
+ for (::std::vector<FmFilterData*>::const_iterator i = rItems.begin();
+ i != rItems.end(); i++)
+ {
+ FmFormItem* pForm = PTR_CAST(FmFormItem,*i);
+ if (pForm)
+ {
+ if (xForm == pForm->GetController()->getModel())
+ return pForm;
+ else
+ {
+ pForm = Find(pForm->GetChildren(), xForm);
+ if (pForm)
+ return pForm;
+ }
+ }
+ }
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::SetCurrentController(const Reference< XFormController > & xCurrent)
+{
+ if ( xCurrent == m_xController )
+ return;
+
+ m_xController = xCurrent;
+
+ FmFormItem* pItem = Find( m_aChildren, xCurrent );
+ if ( !pItem )
+ return;
+
+ try
+ {
+ Reference< XFilterController > xFilterController( m_xController, UNO_QUERY_THROW );
+ const sal_Int32 nActiveTerm( xFilterController->getActiveTerm() );
+ if ( pItem->GetChildren().size() > (size_t)nActiveTerm )
+ {
+ SetCurrentItems( static_cast< FmFilterItems* >( pItem->GetChildren()[ nActiveTerm ] ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::AppendFilterItems( FmFormItem& _rFormItem )
+{
+ // insert the condition behind the last filter items
+ ::std::vector<FmFilterData*>::reverse_iterator iter;
+ for ( iter = _rFormItem.GetChildren().rbegin();
+ iter != _rFormItem.GetChildren().rend();
+ ++iter
+ )
+ {
+ if ((*iter)->ISA(FmFilterItems))
+ break;
+ }
+
+ sal_Int32 nInsertPos = iter.base() - _rFormItem.GetChildren().begin();
+ // delegate this to the FilterController, it will notify us, which will let us update our model
+ try
+ {
+ Reference< XFilterController > xFilterController( _rFormItem.GetFilterController(), UNO_SET_THROW );
+ if ( nInsertPos >= xFilterController->getDisjunctiveTerms() )
+ xFilterController->appendEmptyDisjunctiveTerm();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::Insert(const ::std::vector<FmFilterData*>::iterator& rPos, FmFilterData* pData)
+{
+ ::std::vector<FmFilterData*>& rItems = pData->GetParent()->GetChildren();
+ sal_Int32 nPos = rPos == rItems.end() ? LIST_APPEND : rPos - rItems.begin();
+ rItems.insert(rPos, pData);
+
+ // UI benachrichtigen
+ FmFilterInsertedHint aInsertedHint(pData, nPos);
+ Broadcast( aInsertedHint );
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::Remove(FmFilterData* pData)
+{
+ FmParentData* pParent = pData->GetParent();
+ ::std::vector<FmFilterData*>& rItems = pParent->GetChildren();
+
+ // erase the item from the model
+ ::std::vector<FmFilterData*>::iterator i = ::std::find(rItems.begin(), rItems.end(), pData);
+ DBG_ASSERT(i != rItems.end(), "FmFilterModel::Remove(): unknown Item");
+ // position within the parent
+ sal_Int32 nPos = i - rItems.begin();
+ if (pData->ISA(FmFilterItems))
+ {
+ FmFormItem* pFormItem = (FmFormItem*)pParent;
+
+ try
+ {
+ Reference< XFilterController > xFilterController( pFormItem->GetFilterController(), UNO_SET_THROW );
+
+ bool bEmptyLastTerm = ( ( nPos == 0 ) && xFilterController->getDisjunctiveTerms() == 1 );
+ if ( bEmptyLastTerm )
+ {
+ // remove all children (by setting an empty predicate expression)
+ ::std::vector< FmFilterData* >& rChildren = ((FmFilterItems*)pData)->GetChildren();
+ while ( !rChildren.empty() )
+ {
+ ::std::vector< FmFilterData* >::iterator removePos = rChildren.end() - 1;
+ FmFilterItem* pFilterItem = PTR_CAST( FmFilterItem, *removePos );
+ m_pAdapter->setText( nPos, pFilterItem, ::rtl::OUString() );
+ Remove( removePos );
+ }
+ }
+ else
+ {
+ xFilterController->removeDisjunctiveTerm( nPos );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else // FormItems can not be deleted
+ {
+ FmFilterItem* pFilterItem = PTR_CAST(FmFilterItem, pData);
+
+ // if its the last condition remove the parent
+ if (rItems.size() == 1)
+ Remove(pFilterItem->GetParent());
+ else
+ {
+ // find the position of the father within his father
+ ::std::vector<FmFilterData*>& rParentParentItems = pData->GetParent()->GetParent()->GetChildren();
+ ::std::vector<FmFilterData*>::iterator j = ::std::find(rParentParentItems.begin(), rParentParentItems.end(), pFilterItem->GetParent());
+ DBG_ASSERT(j != rParentParentItems.end(), "FmFilterModel::Remove(): unknown Item");
+ sal_Int32 nParentPos = j - rParentParentItems.begin();
+
+ // EmptyText removes the filter
+ m_pAdapter->setText(nParentPos, pFilterItem, ::rtl::OUString());
+ Remove( i );
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::Remove( const ::std::vector<FmFilterData*>::iterator& rPos )
+{
+ // remove from parent's child list
+ FmFilterData* pData = *rPos;
+ pData->GetParent()->GetChildren().erase( rPos );
+
+ // notify the view, this will remove the actual SvLBoxEntry
+ FmFilterRemovedHint aRemoveHint( pData );
+ Broadcast( aRemoveHint );
+
+ delete pData;
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmFilterModel::ValidateText(FmFilterItem* pItem, UniString& rText, UniString& rErrorMsg) const
+{
+ FmFormItem* pFormItem = PTR_CAST( FmFormItem, pItem->GetParent()->GetParent() );
+ try
+ {
+ Reference< XFormController > xFormController( pFormItem->GetController() );
+ // obtain the connection of the form belonging to the controller
+ OStaticDataAccessTools aStaticTools;
+ Reference< XRowSet > xRowSet( xFormController->getModel(), UNO_QUERY_THROW );
+ Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( xRowSet ) );
+
+ // obtain a number formatter for this connection
+ // TODO: shouldn't this be cached?
+ Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats( xConnection, sal_True );
+ Reference< XNumberFormatter > xFormatter( m_xORB->createInstance( FM_NUMBER_FORMATTER ), UNO_QUERY );
+ xFormatter->attachNumberFormatsSupplier( xFormatSupplier );
+
+ // get the field (database column) which the item is responsible for
+ Reference< XFilterController > xFilterController( xFormController, UNO_QUERY_THROW );
+ Reference< XPropertySet > xField( lcl_getBoundField_nothrow( xFilterController->getFilterComponent( pItem->GetComponentIndex() ) ), UNO_SET_THROW );
+
+ // parse the given text as filter predicate
+ ::rtl::OUString aErr, aTxt( rText );
+ ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( aErr, aTxt, xFormatter, xField );
+ rErrorMsg = aErr;
+ rText = aTxt;
+ if ( xParseNode.is() )
+ {
+ ::rtl::OUString aPreparedText;
+ Locale aAppLocale = Application::GetSettings().GetUILocale();
+ xParseNode->parseNodeToPredicateStr(
+ aPreparedText, xConnection, xFormatter, xField, aAppLocale, '.', getParseContext() );
+ rText = aPreparedText;
+ return sal_True;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sal_False;
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::Append(FmFilterItems* pItems, FmFilterItem* pFilterItem)
+{
+ Insert(pItems->GetChildren().end(), pFilterItem);
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::SetTextForItem(FmFilterItem* pItem, const ::rtl::OUString& rText)
+{
+ ::std::vector<FmFilterData*>& rItems = pItem->GetParent()->GetParent()->GetChildren();
+ ::std::vector<FmFilterData*>::iterator i = ::std::find(rItems.begin(), rItems.end(), pItem->GetParent());
+ sal_Int32 nParentPos = i - rItems.begin();
+
+ m_pAdapter->setText(nParentPos, pItem, rText);
+
+ if (!rText)
+ Remove(pItem);
+ else
+ {
+ // Change the text
+ pItem->SetText(rText);
+ FmFilterTextChangedHint aChangeHint(pItem);
+ Broadcast( aChangeHint );
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::SetCurrentItems(FmFilterItems* pCurrent)
+{
+ if (m_pCurrentItems == pCurrent)
+ return;
+
+ // search for the condition
+ if (pCurrent)
+ {
+ FmFormItem* pFormItem = (FmFormItem*)pCurrent->GetParent();
+ ::std::vector<FmFilterData*>& rItems = pFormItem->GetChildren();
+ ::std::vector<FmFilterData*>::const_iterator i = ::std::find(rItems.begin(), rItems.end(), pCurrent);
+
+ if (i != rItems.end())
+ {
+ // determine the filter position
+ sal_Int32 nPos = i - rItems.begin();
+ try
+ {
+ Reference< XFilterController > xFilterController( pFormItem->GetFilterController(), UNO_SET_THROW );
+ xFilterController->setActiveTerm( nPos );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( m_xController != pFormItem->GetController() )
+ // calls SetCurrentItems again
+ SetCurrentController( pFormItem->GetController() );
+ else
+ m_pCurrentItems = pCurrent;
+ }
+ else
+ m_pCurrentItems = NULL;
+ }
+ else
+ m_pCurrentItems = NULL;
+
+
+ // UI benachrichtigen
+ FmFilterCurrentChangedHint aHint;
+ Broadcast( aHint );
+}
+
+//------------------------------------------------------------------------
+void FmFilterModel::EnsureEmptyFilterRows( FmParentData& _rItem )
+{
+ // checks whether for each form there's one free level for input
+ ::std::vector< FmFilterData* >& rChildren = _rItem.GetChildren();
+ sal_Bool bAppendLevel = _rItem.ISA( FmFormItem );
+
+ for ( ::std::vector<FmFilterData*>::iterator i = rChildren.begin();
+ i != rChildren.end();
+ ++i
+ )
+ {
+ FmFilterItems* pItems = PTR_CAST(FmFilterItems, *i);
+ if ( pItems && pItems->GetChildren().empty() )
+ {
+ bAppendLevel = sal_False;
+ break;
+ }
+
+ FmFormItem* pFormItem = PTR_CAST(FmFormItem, *i);
+ if (pFormItem)
+ {
+ EnsureEmptyFilterRows( *pFormItem );
+ continue;
+ }
+ }
+
+ if ( bAppendLevel )
+ {
+ FmFormItem* pFormItem = PTR_CAST( FmFormItem, &_rItem );
+ OSL_ENSURE( pFormItem, "FmFilterModel::EnsureEmptyFilterRows: no FmFormItem, but a FmFilterItems child?" );
+ if ( pFormItem )
+ AppendFilterItems( *pFormItem );
+ }
+}
+
+//========================================================================
+// class FmFilterItemsString
+//========================================================================
+class FmFilterItemsString : public SvLBoxString
+{
+public:
+ FmFilterItemsString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const XubString& rStr )
+ :SvLBoxString(pEntry,nFlags,rStr){}
+
+ virtual void Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry);
+ virtual void InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData);
+};
+
+const int nxDBmp = 12;
+//------------------------------------------------------------------------
+void FmFilterItemsString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 /*nFlags*/, SvLBoxEntry* pEntry )
+{
+ FmFilterItems* pRow = (FmFilterItems*)pEntry->GetUserData();
+ FmFormItem* pForm = (FmFormItem*)pRow->GetParent();
+
+ // current filter is significant painted
+ const bool bIsCurrentFilter = pForm->GetChildren()[ pForm->GetFilterController()->getActiveTerm() ] == pRow;
+ if ( bIsCurrentFilter )
+ {
+ rDev.Push( PUSH_LINECOLOR );
+
+ rDev.SetLineColor( rDev.GetTextColor() );
+
+ Rectangle aRect( rPos, GetSize( &rDev, pEntry ) );
+ Point aFirst( rPos.X(), aRect.Bottom() - 6 );
+ Point aSecond(aFirst .X() + 2, aFirst.Y() + 3 );
+
+ rDev.DrawLine( aFirst, aSecond );
+
+ aFirst = aSecond;
+ aFirst.X() += 1;
+ aSecond.X() += 6;
+ aSecond.Y() -= 5;
+
+ rDev.DrawLine( aFirst, aSecond );
+
+ rDev.Pop();
+ }
+
+ rDev.DrawText( Point(rPos.X() + nxDBmp, rPos.Y()), GetText() );
+}
+
+//------------------------------------------------------------------------
+void FmFilterItemsString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData)
+{
+ if( !pViewData )
+ pViewData = pView->GetViewDataItem( pEntry, this );
+
+ Size aSize(pView->GetTextWidth(GetText()), pView->GetTextHeight());
+ aSize.Width() += nxDBmp;
+ pViewData->aSize = aSize;
+}
+
+//========================================================================
+// class FmFilterString
+//========================================================================
+class FmFilterString : public SvLBoxString
+{
+ UniString m_aName;
+
+public:
+ FmFilterString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const XubString& rStr, const UniString& aName)
+ :SvLBoxString(pEntry,nFlags,rStr)
+ ,m_aName(aName)
+ {
+ m_aName.AppendAscii(": ");
+ }
+
+ virtual void Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry);
+ virtual void InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData);
+};
+
+const int nxD = 4;
+
+//------------------------------------------------------------------------
+void FmFilterString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry, SvViewDataItem* pViewData)
+{
+ if( !pViewData )
+ pViewData = pView->GetViewDataItem( pEntry, this );
+
+ Font aOldFont( pView->GetFont());
+ Font aFont( aOldFont );
+ aFont.SetWeight(WEIGHT_BOLD);
+ pView->SetFont( aFont );
+
+ Size aSize(pView->GetTextWidth(m_aName), pView->GetTextHeight());
+ pView->SetFont( aOldFont );
+ aSize.Width() += pView->GetTextWidth(GetText()) + nxD;
+ pViewData->aSize = aSize;
+}
+
+//------------------------------------------------------------------------
+void FmFilterString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 /*nFlags*/, SvLBoxEntry* /*pEntry*/ )
+{
+ Font aOldFont( rDev.GetFont());
+ Font aFont( aOldFont );
+ aFont.SetWeight(WEIGHT_BOLD);
+ rDev.SetFont( aFont );
+
+ Point aPos(rPos);
+ rDev.DrawText( aPos, m_aName );
+
+ // position for the second text
+ aPos.X() += rDev.GetTextWidth(m_aName) + nxD;
+ rDev.SetFont( aOldFont );
+ rDev.DrawText( aPos, GetText() );
+}
+
+//========================================================================
+// class FmFilterNavigator
+//========================================================================
+FmFilterNavigator::FmFilterNavigator( Window* pParent )
+ :SvTreeListBox( pParent, WB_HASBUTTONS|WB_HASLINES|WB_BORDER|WB_HASBUTTONSATROOT )
+ ,m_pModel( NULL )
+ ,m_pEditingCurrently( NULL )
+ ,m_aControlExchange( this )
+ ,m_aTimerCounter( 0 )
+ ,m_aDropActionType( DA_SCROLLUP )
+{
+ SetHelpId( HID_FILTER_NAVIGATOR );
+
+ {
+ {
+ ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) );
+ SetNodeBitmaps(
+ aNavigatorImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ),
+ aNavigatorImages.GetImage( RID_SVXIMG_EXPANDEDNODE ),
+ BMP_COLOR_NORMAL
+ );
+ }
+ {
+ ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL_HC ) );
+ SetNodeBitmaps(
+ aNavigatorImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ),
+ aNavigatorImages.GetImage( RID_SVXIMG_EXPANDEDNODE ),
+ BMP_COLOR_HIGHCONTRAST
+ );
+ }
+ }
+
+ m_pModel = new FmFilterModel(comphelper::getProcessServiceFactory());
+ StartListening( *m_pModel );
+
+ EnableInplaceEditing( sal_True );
+ SetSelectionMode(MULTIPLE_SELECTION);
+
+ SetDragDropMode(0xFFFF);
+
+ m_aDropActionTimer.SetTimeoutHdl(LINK(this, FmFilterNavigator, OnDropActionTimer));
+}
+
+//------------------------------------------------------------------------
+FmFilterNavigator::~FmFilterNavigator()
+{
+ EndListening( *m_pModel );
+ delete m_pModel;
+}
+
+//------------------------------------------------------------------------
+void FmFilterNavigator::Clear()
+{
+ m_pModel->Clear();
+}
+
+//------------------------------------------------------------------------
+void FmFilterNavigator::UpdateContent(const Reference< XIndexAccess > & xControllers, const Reference< XFormController > & xCurrent)
+{
+ if (xCurrent == m_pModel->GetCurrentController())
+ return;
+
+ m_pModel->Update(xControllers, xCurrent);
+
+ // expand the filters for the current controller
+ SvLBoxEntry* pEntry = FindEntry(m_pModel->GetCurrentForm());
+ if (pEntry && !IsExpanded(pEntry))
+ {
+ SelectAll(sal_False);
+
+ if (!IsExpanded(pEntry))
+ Expand(pEntry);
+
+ pEntry = FindEntry(m_pModel->GetCurrentItems());
+ if (pEntry)
+ {
+ if (!IsExpanded(pEntry))
+ Expand(pEntry);
+ Select(pEntry, sal_True);
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmFilterNavigator::EditingEntry( SvLBoxEntry* pEntry, Selection& rSelection )
+{
+ m_pEditingCurrently = pEntry;
+ if (!SvTreeListBox::EditingEntry( pEntry, rSelection ))
+ return sal_False;
+
+ return pEntry && ((FmFilterData*)pEntry->GetUserData())->ISA(FmFilterItem);
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmFilterNavigator::EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText )
+{
+ DBG_ASSERT(pEntry == m_pEditingCurrently, "FmFilterNavigator::EditedEntry: suspicious entry!");
+ m_pEditingCurrently = NULL;
+
+ if (EditingCanceled())
+ return sal_True;
+
+ DBG_ASSERT(((FmFilterData*)pEntry->GetUserData())->ISA(FmFilterItem),
+ "FmFilterNavigator::EditedEntry() wrong entry");
+
+ UniString aText(rNewText);
+ aText.EraseTrailingChars();
+ aText.EraseLeadingChars();
+ if (aText.Len() == 0)
+ {
+ // deleting the entry asynchron
+ ULONG nEvent;
+ PostUserEvent(nEvent, LINK(this, FmFilterNavigator, OnRemove), pEntry);
+ }
+ else
+ {
+ UniString aErrorMsg;
+
+ if (m_pModel->ValidateText((FmFilterItem*)pEntry->GetUserData(), aText, aErrorMsg))
+ {
+ GrabFocus();
+ // this will set the text at the FmFilterItem, as well as update any filter controls
+ // which are connected to this particular entry
+ m_pModel->SetTextForItem( static_cast< FmFilterItem* >( pEntry->GetUserData() ), aText );
+
+ SetCursor( pEntry, sal_True );
+ SetEntryText( pEntry, aText );
+ }
+ else
+ {
+ // display the error and return sal_False
+ SQLContext aError;
+ aError.Message = String(SVX_RES(RID_STR_SYNTAXERROR));
+ aError.Details = aErrorMsg;
+ displayException(aError, this);
+
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( FmFilterNavigator, OnRemove, SvLBoxEntry*, pEntry )
+{
+ // now remove the entry
+ m_pModel->Remove((FmFilterData*) pEntry->GetUserData());
+ return 0L;
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( FmFilterNavigator, OnDropActionTimer, void*, EMPTYARG )
+{
+ if (--m_aTimerCounter > 0)
+ return 0L;
+
+ switch (m_aDropActionType)
+ {
+ case DA_SCROLLUP :
+ ScrollOutputArea(1);
+ m_aTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
+ break;
+ case DA_SCROLLDOWN :
+ ScrollOutputArea(-1);
+ m_aTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
+ break;
+ case DA_EXPANDNODE:
+ {
+ SvLBoxEntry* pToExpand = GetEntry(m_aTimerTriggered);
+ if (pToExpand && (GetChildCount(pToExpand) > 0) && !IsExpanded(pToExpand))
+ // tja, eigentlich muesste ich noch testen, ob die Node nicht schon expandiert ist, aber ich
+ // habe dazu weder in den Basisklassen noch im Model eine Methode gefunden ...
+ // aber ich denke, die BK sollte es auch so vertragen
+ Expand(pToExpand);
+
+ // nach dem Expand habe ich im Gegensatz zum Scrollen natuerlich nix mehr zu tun
+ m_aDropActionTimer.Stop();
+ }
+ break;
+ }
+ return 0L;
+}
+
+
+//------------------------------------------------------------------------
+sal_Int8 FmFilterNavigator::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ Point aDropPos = rEvt.maPosPixel;
+
+ // kuemmern wir uns erst mal um moeglich DropActions (Scrollen und Aufklappen)
+ if (rEvt.mbLeaving)
+ {
+ if (m_aDropActionTimer.IsActive())
+ m_aDropActionTimer.Stop();
+ }
+ else
+ {
+ sal_Bool bNeedTrigger = sal_False;
+ // auf dem ersten Eintrag ?
+ if ((aDropPos.Y() >= 0) && (aDropPos.Y() < GetEntryHeight()))
+ {
+ m_aDropActionType = DA_SCROLLUP;
+ bNeedTrigger = sal_True;
+ }
+ else
+ {
+ // auf dem letzten (bzw. in dem Bereich, den ein Eintrag einnehmen wuerde, wenn er unten genau buendig
+ // abschliessen wuerde) ?
+ if ((aDropPos.Y() < GetSizePixel().Height()) && (aDropPos.Y() >= GetSizePixel().Height() - GetEntryHeight()))
+ {
+ m_aDropActionType = DA_SCROLLDOWN;
+ bNeedTrigger = sal_True;
+ }
+ else
+ { // is it an entry whith children, and not yet expanded?
+ SvLBoxEntry* pDropppedOn = GetEntry(aDropPos);
+ if (pDropppedOn && (GetChildCount(pDropppedOn) > 0) && !IsExpanded(pDropppedOn))
+ {
+ // -> aufklappen
+ m_aDropActionType = DA_EXPANDNODE;
+ bNeedTrigger = sal_True;
+ }
+ }
+ }
+ if (bNeedTrigger && (m_aTimerTriggered != aDropPos))
+ {
+ // neu anfangen zu zaehlen
+ m_aTimerCounter = DROP_ACTION_TIMER_INITIAL_TICKS;
+ // die Pos merken, da ich auch QueryDrops bekomme, wenn sich die Maus gar nicht bewegt hat
+ m_aTimerTriggered = aDropPos;
+ // und den Timer los
+ if (!m_aDropActionTimer.IsActive()) // gibt es den Timer schon ?
+ {
+ m_aDropActionTimer.SetTimeout(DROP_ACTION_TIMER_TICK_BASE);
+ m_aDropActionTimer.Start();
+ }
+ }
+ else if (!bNeedTrigger)
+ m_aDropActionTimer.Stop();
+ }
+
+
+ // Hat das Object das richtige Format?
+ if (!m_aControlExchange.isDragSource())
+ return DND_ACTION_NONE;
+
+ if (!m_aControlExchange->hasFormat(GetDataFlavorExVector()))
+ return DND_ACTION_NONE;
+
+ // do we conain the formitem?
+ if (!FindEntry(m_aControlExchange->getFormItem()))
+ return DND_ACTION_NONE;
+
+ SvLBoxEntry* pDropTarget = GetEntry(aDropPos);
+ if (!pDropTarget)
+ return DND_ACTION_NONE;
+
+ FmFilterData* pData = (FmFilterData*)pDropTarget->GetUserData();
+ FmFormItem* pForm = NULL;
+ if (pData->ISA(FmFilterItem))
+ {
+ pForm = PTR_CAST(FmFormItem,pData->GetParent()->GetParent());
+ if (pForm != m_aControlExchange->getFormItem())
+ return DND_ACTION_NONE;
+ }
+ else if (pData->ISA(FmFilterItems))
+ {
+ pForm = PTR_CAST(FmFormItem,pData->GetParent());
+ if (pForm != m_aControlExchange->getFormItem())
+ return DND_ACTION_NONE;
+ }
+ else
+ return DND_ACTION_NONE;
+
+ return rEvt.mnAction;
+}
+// -----------------------------------------------------------------------------
+namespace
+{
+ FmFilterItems* getTargetItems(SvLBoxEntry* _pTarget)
+ {
+ FmFilterData* pData = static_cast<FmFilterData*>(_pTarget->GetUserData());
+ FmFilterItems* pTargetItems = pData->ISA(FmFilterItems)
+ ?
+ PTR_CAST(FmFilterItems,pData)
+ :
+ PTR_CAST(FmFilterItems,pData->GetParent());
+ return pTargetItems;
+ }
+}
+//------------------------------------------------------------------------
+sal_Int8 FmFilterNavigator::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ // ware schlecht, wenn nach dem Droppen noch gescrollt wird ...
+ if (m_aDropActionTimer.IsActive())
+ m_aDropActionTimer.Stop();
+
+ // Format-Ueberpruefung
+ if (!m_aControlExchange.isDragSource())
+ return DND_ACTION_NONE;
+
+ // das Ziel des Drop sowie einige Daten darueber
+ Point aDropPos = rEvt.maPosPixel;
+ SvLBoxEntry* pDropTarget = GetEntry( aDropPos );
+ if (!pDropTarget)
+ return DND_ACTION_NONE;
+
+ // search the container where to add the items
+ FmFilterItems* pTargetItems = getTargetItems(pDropTarget);
+ SelectAll(sal_False);
+ SvLBoxEntry* pEntry = FindEntry(pTargetItems);
+ Select(pEntry, sal_True);
+ SetCurEntry(pEntry);
+
+ insertFilterItem(m_aControlExchange->getDraggedEntries(),pTargetItems,DND_ACTION_COPY == rEvt.mnAction);
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+void FmFilterNavigator::InitEntry(SvLBoxEntry* pEntry,
+ const XubString& rStr,
+ const Image& rImg1,
+ const Image& rImg2,
+ SvLBoxButtonKind eButtonKind)
+{
+ SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
+ SvLBoxString* pString = NULL;
+
+ if (((FmFilterData*)pEntry->GetUserData())->ISA(FmFilterItem))
+ pString = new FmFilterString(pEntry, 0, rStr, ((FmFilterItem*)pEntry->GetUserData())->GetFieldName());
+ else if (((FmFilterData*)pEntry->GetUserData())->ISA(FmFilterItems))
+ pString = new FmFilterItemsString(pEntry, 0, rStr );
+
+ if (pString)
+ pEntry->ReplaceItem( pString, 1 );
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmFilterNavigator::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
+{
+ if (bSelect == IsSelected(pEntry)) // das passiert manchmal, ich glaube, die Basisklasse geht zu sehr auf Nummer sicher ;)
+ return sal_True;
+
+ if (SvTreeListBox::Select(pEntry, bSelect))
+ {
+ if (bSelect)
+ {
+ FmFormItem* pFormItem = NULL;
+ if (((FmFilterData*)pEntry->GetUserData())->ISA(FmFilterItem))
+ pFormItem = (FmFormItem*)((FmFilterItem*)pEntry->GetUserData())->GetParent()->GetParent();
+ else if (((FmFilterData*)pEntry->GetUserData())->ISA(FmFilterItems))
+ pFormItem = (FmFormItem*)((FmFilterItem*)pEntry->GetUserData())->GetParent()->GetParent();
+ else if (((FmFilterData*)pEntry->GetUserData())->ISA(FmFormItem))
+ pFormItem = (FmFormItem*)pEntry->GetUserData();
+
+ if (pFormItem)
+ {
+ // will the controller be exchanged?
+ if (((FmFilterData*)pEntry->GetUserData())->ISA(FmFilterItem))
+ m_pModel->SetCurrentItems((FmFilterItems*)((FmFilterItem*)pEntry->GetUserData())->GetParent());
+ else if (((FmFilterData*)pEntry->GetUserData())->ISA(FmFilterItems))
+ m_pModel->SetCurrentItems((FmFilterItems*)pEntry->GetUserData());
+ else if (((FmFilterData*)pEntry->GetUserData())->ISA(FmFormItem))
+ m_pModel->SetCurrentController(((FmFormItem*)pEntry->GetUserData())->GetController());
+ }
+ }
+ return sal_True;
+ }
+ else
+ return sal_False;
+}
+
+//------------------------------------------------------------------------
+void FmFilterNavigator::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ if (rHint.ISA(FmFilterInsertedHint))
+ {
+ FmFilterInsertedHint* pHint = (FmFilterInsertedHint*)&rHint;
+ Insert(pHint->GetData(), pHint->GetPos());
+ }
+ else if( rHint.ISA(FilterClearingHint) )
+ {
+ SvTreeListBox::Clear();
+ }
+ else if( rHint.ISA(FmFilterRemovedHint) )
+ {
+ FmFilterRemovedHint* pHint = (FmFilterRemovedHint*)&rHint;
+ Remove(pHint->GetData());
+ }
+ else if( rHint.ISA(FmFilterTextChangedHint) )
+ {
+ FmFilterTextChangedHint* pHint = (FmFilterTextChangedHint*)&rHint;
+ SvLBoxEntry* pEntry = FindEntry(pHint->GetData());
+ if (pEntry)
+ SetEntryText( pEntry, pHint->GetData()->GetText());
+ }
+ else if( rHint.ISA(FmFilterCurrentChangedHint) )
+ {
+ // invalidate the entries
+ for (SvLBoxEntry* pEntry = First(); pEntry != NULL;
+ pEntry = Next(pEntry))
+ GetModel()->InvalidateEntry( pEntry );
+ }
+}
+
+//------------------------------------------------------------------------
+SvLBoxEntry* FmFilterNavigator::FindEntry(const FmFilterData* pItem) const
+{
+ SvLBoxEntry* pEntry = NULL;
+ if (pItem)
+ {
+ for (pEntry = First(); pEntry != NULL; pEntry = Next( pEntry ))
+ {
+ FmFilterData* pEntryItem = (FmFilterData*)pEntry->GetUserData();
+ if (pEntryItem == pItem)
+ break;
+ }
+ }
+ return pEntry;
+}
+
+//------------------------------------------------------------------------
+void FmFilterNavigator::Insert(FmFilterData* pItem, sal_Int32 nPos)
+{
+ const FmParentData* pParent = pItem->GetParent() ? pItem->GetParent() : GetFilterModel();
+
+ // insert the item
+ SvLBoxEntry* pParentEntry = FindEntry( pParent );
+ SvLBoxEntry* pNewEntry = InsertEntry(pItem->GetText(), pItem->GetImage(), pItem->GetImage(), pParentEntry, sal_False, nPos, pItem );
+ if ( pNewEntry )
+ {
+ SetExpandedEntryBmp( pNewEntry, pItem->GetImage( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST );
+ SetCollapsedEntryBmp( pNewEntry, pItem->GetImage( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST );
+ }
+ if ( pParentEntry )
+ Expand( pParentEntry );
+}
+
+//------------------------------------------------------------------------
+void FmFilterNavigator::Remove(FmFilterData* pItem)
+{
+ // der Entry zu den Daten
+ SvLBoxEntry* pEntry = FindEntry(pItem);
+
+ if (pEntry == m_pEditingCurrently)
+ // cancel editing
+ EndEditing(sal_True);
+
+ if (pEntry)
+ GetModel()->Remove( pEntry );
+}
+// -----------------------------------------------------------------------------
+FmFormItem* FmFilterNavigator::getSelectedFilterItems(::std::vector<FmFilterItem*>& _rItemList)
+{
+ // be sure that the data is only used within only one form!
+ FmFormItem* pFirstItem = NULL;
+
+ sal_Bool bHandled = sal_True;
+ sal_Bool bFoundSomething = sal_False;
+ for (SvLBoxEntry* pEntry = FirstSelected();
+ bHandled && pEntry != NULL;
+ pEntry = NextSelected(pEntry))
+ {
+ FmFilterItem* pFilter = PTR_CAST(FmFilterItem, (FmFilterData*)pEntry->GetUserData());
+ if (pFilter)
+ {
+ FmFormItem* pForm = PTR_CAST(FmFormItem,pFilter->GetParent()->GetParent());
+ if (!pForm)
+ bHandled = sal_False;
+ else if (!pFirstItem)
+ pFirstItem = pForm;
+ else if (pFirstItem != pForm)
+ bHandled = sal_False;
+
+ if (bHandled)
+ {
+ _rItemList.push_back(pFilter);
+ bFoundSomething = sal_True;
+ }
+ }
+ }
+ if ( !bHandled || !bFoundSomething )
+ pFirstItem = NULL;
+ return pFirstItem;
+}
+// -----------------------------------------------------------------------------
+void FmFilterNavigator::insertFilterItem(const ::std::vector<FmFilterItem*>& _rFilterList,FmFilterItems* _pTargetItems,sal_Bool _bCopy)
+{
+ ::std::vector<FmFilterItem*>::const_iterator aEnd = _rFilterList.end();
+ for ( ::std::vector< FmFilterItem* >::const_iterator i = _rFilterList.begin();
+ i != aEnd;
+ ++i
+ )
+ {
+ FmFilterItem* pLookupItem( *i );
+ if ( pLookupItem->GetParent() == _pTargetItems )
+ continue;
+
+ FmFilterItem* pFilterItem = _pTargetItems->Find( pLookupItem->GetComponentIndex() );
+ String aText = pLookupItem->GetText();
+ if ( !pFilterItem )
+ {
+ pFilterItem = new FmFilterItem( m_pModel->getORB(), _pTargetItems, pLookupItem->GetFieldName(), aText, pLookupItem->GetComponentIndex() );
+ m_pModel->Append( _pTargetItems, pFilterItem );
+ }
+
+ if ( !_bCopy )
+ m_pModel->Remove( pLookupItem );
+
+ // now set the text for the new dragged item
+ m_pModel->SetTextForItem( pFilterItem, aText );
+ }
+
+ m_pModel->EnsureEmptyFilterRows( *_pTargetItems->GetParent() );
+}
+
+//------------------------------------------------------------------------------
+void FmFilterNavigator::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
+{
+ EndSelection();
+
+ // be sure that the data is only used within a only one form!
+ m_aControlExchange.prepareDrag();
+
+ ::std::vector<FmFilterItem*> aItemList;
+ if ( FmFormItem* pFirstItem = getSelectedFilterItems(aItemList) )
+ {
+ m_aControlExchange->setDraggedEntries(aItemList);
+ m_aControlExchange->setFormItem(pFirstItem);
+ m_aControlExchange.startDrag( DND_ACTION_COPYMOVE );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmFilterNavigator::Command( const CommandEvent& rEvt )
+{
+ sal_Bool bHandled = sal_False;
+ switch (rEvt.GetCommand())
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ // die Stelle, an der geklickt wurde
+ Point aWhere;
+ SvLBoxEntry* pClicked = NULL;
+ if (rEvt.IsMouseEvent())
+ {
+ aWhere = rEvt.GetMousePosPixel();
+ pClicked = GetEntry(aWhere);
+ if (pClicked == NULL)
+ break;
+
+ if (!IsSelected(pClicked))
+ {
+ SelectAll(sal_False);
+ Select(pClicked, sal_True);
+ SetCurEntry(pClicked);
+ }
+ }
+ else
+ {
+ pClicked = GetCurEntry();
+ if (!pClicked)
+ break;
+ aWhere = GetEntryPosition( pClicked );
+ }
+
+ ::std::vector<FmFilterData*> aSelectList;
+ for (SvLBoxEntry* pEntry = FirstSelected();
+ pEntry != NULL;
+ pEntry = NextSelected(pEntry))
+ {
+ // don't delete forms
+ FmFormItem* pForm = PTR_CAST(FmFormItem, (FmFilterData*)pEntry->GetUserData());
+ if (!pForm)
+ aSelectList.push_back((FmFilterData*)pEntry->GetUserData());
+ }
+ if (aSelectList.size() == 1)
+ {
+ // don't delete the only empty row of a form
+ FmFilterItems* pFilterItems = PTR_CAST(FmFilterItems, aSelectList[0]);
+ if (pFilterItems && pFilterItems->GetChildren().empty()
+ && pFilterItems->GetParent()->GetChildren().size() == 1)
+ aSelectList.clear();
+ }
+
+ PopupMenu aContextMenu(SVX_RES(RID_FM_FILTER_MENU));
+
+ // every condition could be deleted except the first one if its the only one
+ aContextMenu.EnableItem( SID_FM_DELETE, !aSelectList.empty() );
+
+ //
+ sal_Bool bEdit = PTR_CAST(FmFilterItem, (FmFilterData*)pClicked->GetUserData()) != NULL &&
+ IsSelected(pClicked) && GetSelectionCount() == 1;
+
+ aContextMenu.EnableItem( SID_FM_FILTER_EDIT,
+ bEdit );
+ aContextMenu.EnableItem( SID_FM_FILTER_IS_NULL,
+ bEdit );
+ aContextMenu.EnableItem( SID_FM_FILTER_IS_NOT_NULL,
+ bEdit );
+
+ aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
+ sal_uInt16 nSlotId = aContextMenu.Execute( this, aWhere );
+ switch( nSlotId )
+ {
+ case SID_FM_FILTER_EDIT:
+ {
+ EditEntry( pClicked );
+ } break;
+ case SID_FM_FILTER_IS_NULL:
+ case SID_FM_FILTER_IS_NOT_NULL:
+ {
+ UniString aErrorMsg;
+ UniString aText;
+ if (nSlotId == SID_FM_FILTER_IS_NULL)
+ aText.AssignAscii("IS NULL");
+ else
+ aText.AssignAscii("IS NOT NULL");
+
+ m_pModel->ValidateText((FmFilterItem*)pClicked->GetUserData(),
+ aText, aErrorMsg);
+ m_pModel->SetTextForItem((FmFilterItem*)pClicked->GetUserData(), aText);
+ } break;
+ case SID_FM_DELETE:
+ {
+ DeleteSelection();
+ } break;
+ }
+ bHandled = sal_True;
+ } break;
+ }
+
+ if (!bHandled)
+ SvTreeListBox::Command( rEvt );
+}
+// -----------------------------------------------------------------------------
+SvLBoxEntry* FmFilterNavigator::getNextEntry(SvLBoxEntry* _pStartWith)
+{
+ SvLBoxEntry* pEntry = _pStartWith ? _pStartWith : LastSelected();
+ pEntry = Next(pEntry);
+ // we need the next filter entry
+ while( pEntry && GetChildCount( pEntry ) == 0 && pEntry != Last() )
+ pEntry = Next(pEntry);
+ return pEntry;
+}
+// -----------------------------------------------------------------------------
+SvLBoxEntry* FmFilterNavigator::getPrevEntry(SvLBoxEntry* _pStartWith)
+{
+ SvLBoxEntry* pEntry = _pStartWith ? _pStartWith : FirstSelected();
+ pEntry = Prev(pEntry);
+ // check if the previous entry is a filter, if so get the next prev
+ if ( pEntry && GetChildCount( pEntry ) != 0 )
+ {
+ pEntry = Prev(pEntry);
+ // if the entry is still no leaf return
+ if ( pEntry && GetChildCount( pEntry ) != 0 )
+ pEntry = NULL;
+ }
+ return pEntry;
+}
+//------------------------------------------------------------------------
+void FmFilterNavigator::KeyInput(const KeyEvent& rKEvt)
+{
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+
+ switch ( rKeyCode.GetCode() )
+ {
+ case KEY_UP:
+ case KEY_DOWN:
+ {
+ if ( !rKeyCode.IsMod1() || !rKeyCode.IsMod2() || rKeyCode.IsShift() )
+ break;
+
+ ::std::vector<FmFilterItem*> aItemList;
+ if ( !getSelectedFilterItems( aItemList ) )
+ break;
+
+ ::std::mem_fun1_t<SvLBoxEntry*,FmFilterNavigator,SvLBoxEntry*> getter = ::std::mem_fun(&FmFilterNavigator::getNextEntry);
+ if ( rKeyCode.GetCode() == KEY_UP )
+ getter = ::std::mem_fun(&FmFilterNavigator::getPrevEntry);
+
+ SvLBoxEntry* pTarget = getter( this, NULL );
+ if ( !pTarget )
+ break;
+
+ FmFilterItems* pTargetItems = getTargetItems( pTarget );
+ if ( !pTargetItems )
+ break;
+
+ ::std::vector<FmFilterItem*>::const_iterator aEnd = aItemList.end();
+ sal_Bool bNextTargetItem = sal_True;
+ while ( bNextTargetItem )
+ {
+ ::std::vector<FmFilterItem*>::const_iterator i = aItemList.begin();
+ for (; i != aEnd; ++i)
+ {
+ if ( (*i)->GetParent() == pTargetItems )
+ {
+ pTarget = getter(this,pTarget);
+ if ( !pTarget )
+ return;
+ pTargetItems = getTargetItems( pTarget );
+ break;
+ }
+ else
+ {
+ FmFilterItem* pFilterItem = pTargetItems->Find( (*i)->GetComponentIndex() );
+ // we found the text component so jump above
+ if ( pFilterItem )
+ {
+ pTarget = getter( this, pTarget );
+ if ( !pTarget )
+ return;
+
+ pTargetItems = getTargetItems( pTarget );
+ break;
+ }
+ }
+ }
+ bNextTargetItem = i != aEnd && pTargetItems;
+ }
+
+ if ( pTargetItems )
+ {
+ insertFilterItem( aItemList, pTargetItems );
+ return;
+ }
+ }
+ break;
+
+ case KEY_DELETE:
+ {
+ if ( rKeyCode.GetModifier() )
+ break;
+
+ if ( !IsSelected( First() ) || GetEntryCount() > 1 )
+ DeleteSelection();
+ return;
+ }
+ }
+
+ SvTreeListBox::KeyInput(rKEvt);
+}
+
+//------------------------------------------------------------------------------
+void FmFilterNavigator::DeleteSelection()
+{
+ // to avoid the deletion of an entry twice (e.g. deletion of a parent and afterward
+ // the deletion of it's child, i have to shrink the selecton list
+ ::std::vector<SvLBoxEntry*> aEntryList;
+ for (SvLBoxEntry* pEntry = FirstSelected();
+ pEntry != NULL;
+ pEntry = NextSelected(pEntry))
+ {
+ FmFilterItem* pFilterItem = PTR_CAST(FmFilterItem, (FmFilterData*)pEntry->GetUserData());
+ if (pFilterItem && IsSelected(GetParent(pEntry)))
+ continue;
+
+ FmFormItem* pForm = PTR_CAST(FmFormItem, (FmFilterData*)pEntry->GetUserData());
+ if (!pForm)
+ aEntryList.push_back(pEntry);
+ }
+
+ // Remove the selection
+ SelectAll(FALSE);
+
+ for (::std::vector<SvLBoxEntry*>::reverse_iterator i = aEntryList.rbegin();
+ // link problems with operator ==
+ i.base() != aEntryList.rend().base(); i++)
+ {
+ m_pModel->Remove((FmFilterData*)(*i)->GetUserData());
+ }
+}
+// -----------------------------------------------------------------------------
+
+//========================================================================
+// class FmFilterNavigatorWin
+//========================================================================
+FmFilterNavigatorWin::FmFilterNavigatorWin( SfxBindings* _pBindings, SfxChildWindow* _pMgr,
+ Window* _pParent )
+ :SfxDockingWindow( _pBindings, _pMgr, _pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_ROLLABLE|WB_3DLOOK|WB_DOCKABLE) )
+ ,SfxControllerItem( SID_FM_FILTER_NAVIGATOR_CONTROL, *_pBindings )
+{
+ SetHelpId( HID_FILTER_NAVIGATOR_WIN );
+
+ m_pNavigator = new FmFilterNavigator( this );
+ m_pNavigator->Show();
+ SetText( SVX_RES(RID_STR_FILTER_NAVIGATOR) );
+ SfxDockingWindow::SetFloatingSize( Size(200,200) );
+}
+
+//------------------------------------------------------------------------
+FmFilterNavigatorWin::~FmFilterNavigatorWin()
+{
+ delete m_pNavigator;
+}
+
+//-----------------------------------------------------------------------
+void FmFilterNavigatorWin::UpdateContent(FmFormShell* pFormShell)
+{
+ if (!pFormShell)
+ m_pNavigator->UpdateContent( NULL, NULL );
+ else
+ {
+ Reference< XFormController > xController(pFormShell->GetImpl()->getActiveInternalController());
+ Reference< XIndexAccess > xContainer;
+ if (xController.is())
+ {
+ Reference< XChild > xChild(xController, UNO_QUERY);
+ for (Reference< XInterface > xParent(xChild->getParent());
+ xParent.is();
+ xParent = xChild.is() ? xChild->getParent() : Reference< XInterface > ())
+ {
+ xContainer = Reference< XIndexAccess > (xParent, UNO_QUERY);
+ xChild = Reference< XChild > (xParent, UNO_QUERY);
+ }
+ }
+ m_pNavigator->UpdateContent(xContainer, xController);
+ }
+}
+
+//-----------------------------------------------------------------------
+void FmFilterNavigatorWin::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ if( !pState || SID_FM_FILTER_NAVIGATOR_CONTROL != nSID )
+ return;
+
+ if( eState >= SFX_ITEM_AVAILABLE )
+ {
+ FmFormShell* pShell = PTR_CAST( FmFormShell,((SfxObjectItem*)pState)->GetShell() );
+ UpdateContent( pShell );
+ }
+ else
+ UpdateContent( NULL );
+}
+
+//-----------------------------------------------------------------------
+sal_Bool FmFilterNavigatorWin::Close()
+{
+ if ( m_pNavigator && m_pNavigator->IsEditingActive() )
+ m_pNavigator->EndEditing();
+
+ if ( m_pNavigator && m_pNavigator->IsEditingActive() )
+ // the EndEditing was vetoed (perhaps of an syntax error or such)
+ return sal_False;
+
+ UpdateContent( NULL );
+ return SfxDockingWindow::Close();
+}
+
+//-----------------------------------------------------------------------
+void FmFilterNavigatorWin::FillInfo( SfxChildWinInfo& rInfo ) const
+{
+ SfxDockingWindow::FillInfo( rInfo );
+ rInfo.bVisible = sal_False;
+}
+
+//-----------------------------------------------------------------------
+Size FmFilterNavigatorWin::CalcDockingSize( SfxChildAlignment eAlign )
+{
+ if ( ( eAlign == SFX_ALIGN_TOP ) || ( eAlign == SFX_ALIGN_BOTTOM ) )
+ return Size();
+
+ return SfxDockingWindow::CalcDockingSize( eAlign );
+}
+
+//-----------------------------------------------------------------------
+SfxChildAlignment FmFilterNavigatorWin::CheckAlignment( SfxChildAlignment eActAlign, SfxChildAlignment eAlign )
+{
+ switch (eAlign)
+ {
+ case SFX_ALIGN_LEFT:
+ case SFX_ALIGN_RIGHT:
+ case SFX_ALIGN_NOALIGNMENT:
+ return (eAlign);
+ default:
+ break;
+ }
+
+ return (eActAlign);
+}
+
+//------------------------------------------------------------------------
+void FmFilterNavigatorWin::Resize()
+{
+ SfxDockingWindow::Resize();
+
+ Size aLogOutputSize = PixelToLogic( GetOutputSizePixel(), MAP_APPFONT );
+ Size aLogExplSize = aLogOutputSize;
+ aLogExplSize.Width() -= 6;
+ aLogExplSize.Height() -= 6;
+
+ Point aExplPos = LogicToPixel( Point(3,3), MAP_APPFONT );
+ Size aExplSize = LogicToPixel( aLogExplSize, MAP_APPFONT );
+
+ m_pNavigator->SetPosSizePixel( aExplPos, aExplSize );
+}
+// -----------------------------------------------------------------------------
+void FmFilterNavigatorWin::GetFocus()
+{
+ // oj #97405#
+ if ( m_pNavigator )
+ m_pNavigator->GrabFocus();
+}
+// -----------------------------------------------------------------------------
+
+
+//========================================================================
+// class FmFilterNavigatorWinMgr
+//========================================================================
+SFX_IMPL_DOCKINGWINDOW( FmFilterNavigatorWinMgr, SID_FM_FILTER_NAVIGATOR )
+
+//-----------------------------------------------------------------------
+FmFilterNavigatorWinMgr::FmFilterNavigatorWinMgr( Window *_pParent, sal_uInt16 _nId,
+ SfxBindings *_pBindings, SfxChildWinInfo* _pInfo )
+ :SfxChildWindow( _pParent, _nId )
+{
+ pWindow = new FmFilterNavigatorWin( _pBindings, this, _pParent );
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+ ((SfxDockingWindow*)pWindow)->Initialize( _pInfo );
+}
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/filtnav.src b/svx/source/form/filtnav.src
new file mode 100644
index 000000000000..36c12a001e00
--- /dev/null
+++ b/svx/source/form/filtnav.src
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/svxids.hrc>
+#include "fmresids.hrc"
+Menu RID_FM_FILTER_MENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_FM_DELETE ;
+ HelpID = SID_FM_DELETE ;
+ Text [ en-US ] = "~Delete" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_FILTER_EDIT ;
+ HelpID = SID_FM_FILTER_EDIT ;
+ Text [ en-US ] = "~Edit" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_FILTER_IS_NULL ;
+ HelpID = SID_FM_FILTER_IS_NULL ;
+ Text [ en-US ] = "~Is Null" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_FILTER_IS_NOT_NULL ;
+ HelpID = SID_FM_FILTER_IS_NOT_NULL ;
+ Text [ en-US ] = "I~s not Null" ;
+ };
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx
new file mode 100644
index 000000000000..6f9ad0a5a4db
--- /dev/null
+++ b/svx/source/form/fmPropBrw.cxx
@@ -0,0 +1,727 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+
+#include "fmhelp.hrc"
+#include "fmprop.hrc"
+#include "fmPropBrw.hxx"
+#include "fmresids.hrc"
+#include "fmservs.hxx"
+#include "fmshimp.hxx"
+#include "fmpgeimp.hxx"
+
+#include "svx/dialmgr.hxx"
+#include "svx/fmpage.hxx"
+#include "svx/fmshell.hxx"
+#include "svx/sdrpagewindow.hxx"
+#include "svx/svdpagv.hxx"
+#include "svx/svxids.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/awt/XLayoutConstrains.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/inspection/ObjectInspector.hpp>
+#include <com/sun/star/inspection/ObjectInspectorModel.hpp>
+#include <com/sun/star/form/inspection/DefaultFormComponentInspectorModel.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/inspection/DefaultHelpProvider.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/property.hxx>
+#include <cppuhelper/component_context.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objitem.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <toolkit/unohlp.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/shl.hxx>
+#include <unotools/confignode.hxx>
+#include <vcl/stdtext.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::inspection;
+using namespace ::com::sun::star::form::inspection;
+using ::com::sun::star::awt::XWindow;
+
+/*************************************************************************/
+//========================================================================
+//= FmPropBrwMgr
+//========================================================================
+//-----------------------------------------------------------------------
+SFX_IMPL_FLOATINGWINDOW(FmPropBrwMgr, SID_FM_SHOW_PROPERTIES)
+
+//-----------------------------------------------------------------------
+FmPropBrwMgr::FmPropBrwMgr( Window* _pParent, sal_uInt16 _nId,
+ SfxBindings* _pBindings, SfxChildWinInfo* _pInfo)
+ :SfxChildWindow(_pParent, _nId)
+{
+ pWindow = new FmPropBrw( ::comphelper::getProcessServiceFactory(), _pBindings, this, _pParent, _pInfo );
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+ ((SfxFloatingWindow*)pWindow)->Initialize( _pInfo );
+}
+
+//========================================================================
+//========================================================================
+const long STD_WIN_SIZE_X = 300;
+const long STD_WIN_SIZE_Y = 350;
+
+const long STD_MIN_SIZE_X = 250;
+const long STD_MIN_SIZE_Y = 250;
+
+const long STD_WIN_POS_X = 50;
+const long STD_WIN_POS_Y = 50;
+const long WIN_BORDER = 2;
+const long MIN_WIN_SIZE_X = 50;
+const long MIN_WIN_SIZE_Y = 50;
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::svxform;
+
+::rtl::OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
+{
+ sal_uInt16 nClassNameResourceId = 0;
+
+ switch ( nClassId )
+ {
+ case FormComponentType::TEXTFIELD:
+ {
+ Reference< XInterface > xIFace;
+ aUnoObj >>= xIFace;
+ nClassNameResourceId = RID_STR_PROPTITLE_EDIT;
+ if (xIFace.is())
+ { // we have a chance to check if it's a formatted field model
+ Reference< XServiceInfo > xInfo(xIFace, UNO_QUERY);
+ if (xInfo.is() && (xInfo->supportsService(FM_SUN_COMPONENT_FORMATTEDFIELD)))
+ nClassNameResourceId = RID_STR_PROPTITLE_FORMATTED;
+ else if (!xInfo.is())
+ {
+ // couldn't distinguish between formatted and edit with the service name, so try with the properties
+ Reference< XPropertySet > xProps(xIFace, UNO_QUERY);
+ if (xProps.is())
+ {
+ Reference< XPropertySetInfo > xPropsInfo = xProps->getPropertySetInfo();
+ if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(FM_PROP_FORMATSSUPPLIER))
+ nClassNameResourceId = RID_STR_PROPTITLE_FORMATTED;
+ }
+ }
+ }
+ }
+ break;
+
+ case FormComponentType::COMMANDBUTTON:
+ nClassNameResourceId = RID_STR_PROPTITLE_PUSHBUTTON; break;
+ case FormComponentType::RADIOBUTTON:
+ nClassNameResourceId = RID_STR_PROPTITLE_RADIOBUTTON; break;
+ case FormComponentType::CHECKBOX:
+ nClassNameResourceId = RID_STR_PROPTITLE_CHECKBOX; break;
+ case FormComponentType::LISTBOX:
+ nClassNameResourceId = RID_STR_PROPTITLE_LISTBOX; break;
+ case FormComponentType::COMBOBOX:
+ nClassNameResourceId = RID_STR_PROPTITLE_COMBOBOX; break;
+ case FormComponentType::GROUPBOX:
+ nClassNameResourceId = RID_STR_PROPTITLE_GROUPBOX; break;
+ case FormComponentType::IMAGEBUTTON:
+ nClassNameResourceId = RID_STR_PROPTITLE_IMAGEBUTTON; break;
+ case FormComponentType::FIXEDTEXT:
+ nClassNameResourceId = RID_STR_PROPTITLE_FIXEDTEXT; break;
+ case FormComponentType::GRIDCONTROL:
+ nClassNameResourceId = RID_STR_PROPTITLE_DBGRID; break;
+ case FormComponentType::FILECONTROL:
+ nClassNameResourceId = RID_STR_PROPTITLE_FILECONTROL; break;
+ case FormComponentType::DATEFIELD:
+ nClassNameResourceId = RID_STR_PROPTITLE_DATEFIELD; break;
+ case FormComponentType::TIMEFIELD:
+ nClassNameResourceId = RID_STR_PROPTITLE_TIMEFIELD; break;
+ case FormComponentType::NUMERICFIELD:
+ nClassNameResourceId = RID_STR_PROPTITLE_NUMERICFIELD; break;
+ case FormComponentType::CURRENCYFIELD:
+ nClassNameResourceId = RID_STR_PROPTITLE_CURRENCYFIELD; break;
+ case FormComponentType::PATTERNFIELD:
+ nClassNameResourceId = RID_STR_PROPTITLE_PATTERNFIELD; break;
+ case FormComponentType::IMAGECONTROL:
+ nClassNameResourceId = RID_STR_PROPTITLE_IMAGECONTROL; break;
+ case FormComponentType::HIDDENCONTROL:
+ nClassNameResourceId = RID_STR_PROPTITLE_HIDDEN; break;
+ case FormComponentType::SCROLLBAR:
+ nClassNameResourceId = RID_STR_PROPTITLE_SCROLLBAR; break;
+ case FormComponentType::SPINBUTTON:
+ nClassNameResourceId = RID_STR_PROPTITLE_SPINBUTTON; break;
+ case FormComponentType::NAVIGATIONBAR:
+ nClassNameResourceId = RID_STR_PROPTITLE_NAVBAR; break;
+ case FormComponentType::CONTROL:
+ default:
+ nClassNameResourceId = RID_STR_CONTROL; break;
+ }
+
+ if ( !nClassNameResourceId )
+ return ::rtl::OUString();
+
+ return ::rtl::OUString( String( SVX_RES( nClassNameResourceId ) ) );
+}
+
+//========================================================================
+// class FmPropBrw
+//========================================================================
+DBG_NAME(FmPropBrw);
+//------------------------------------------------------------------------
+FmPropBrw::FmPropBrw( const Reference< XMultiServiceFactory >& _xORB, SfxBindings* _pBindings,
+ SfxChildWindow* _pMgr, Window* _pParent, const SfxChildWinInfo* _pInfo )
+ :SfxFloatingWindow(_pBindings, _pMgr, _pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_3DLOOK|WB_ROLLABLE) )
+ ,SfxControllerItem(SID_FM_PROPERTY_CONTROL, *_pBindings)
+ ,m_bInitialStateChange(sal_True)
+ ,m_bInStateChange( false )
+ ,m_xORB(_xORB)
+{
+ DBG_CTOR(FmPropBrw,NULL);
+
+ ::Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
+ SetMinOutputSizePixel(::Size(STD_MIN_SIZE_X,STD_MIN_SIZE_Y));
+ SetOutputSizePixel(aPropWinSize);
+ SetUniqueId(UID_FORMPROPBROWSER_FRAME);
+
+ try
+ {
+ // create a frame wrapper for myself
+ m_xMeAsFrame = Reference< XFrame >(m_xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Frame")), UNO_QUERY);
+ if (m_xMeAsFrame.is())
+ {
+ // create an intermediate window, which is to be the container window of the frame
+ // Do *not* use |this| as container window for the frame, this would result in undefined
+ // responsiblity for this window (as soon as we initialize a frame with a window, the frame
+ // is responsible for it's life time, but |this| is controlled by the belonging SfxChildWindow)
+ // #i34249# - 2004-09-27 - fs@openoffice.org
+ Window* pContainerWindow = new Window( this );
+ pContainerWindow->Show();
+ m_xFrameContainerWindow = VCLUnoHelper::GetInterface ( pContainerWindow );
+
+ m_xMeAsFrame->initialize( m_xFrameContainerWindow );
+ m_xMeAsFrame->setName(::rtl::OUString::createFromAscii("form property browser"));
+ if ( _pBindings->GetDispatcher() )
+ {
+ ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFramesSupplier >
+ xSupp ( _pBindings->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY );
+// if ( xSupp.is() )
+// xSupp->getFrames()->append( m_xMeAsFrame );
+ // Don't append frame to frame hierachy to prevent UI_DEACTIVATE messages
+ // #i31834# - 2004-07-27 - cd@openoffice.org
+ }
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("FmPropBrw::FmPropBrw: could not create/initialize my frame!");
+ m_xMeAsFrame.clear();
+ }
+
+ if (m_xMeAsFrame.is())
+ _pMgr->SetFrame( m_xMeAsFrame );
+
+
+ if ( m_xBrowserComponentWindow.is() )
+ m_xBrowserComponentWindow->setVisible( sal_True );
+
+ if ( _pInfo )
+ m_sLastActivePage = _pInfo->aExtraString;
+}
+
+//------------------------------------------------------------------------
+void FmPropBrw::Resize()
+{
+ SfxFloatingWindow::Resize();
+
+ if ( m_xFrameContainerWindow.is() )
+ {
+ try
+ {
+ ::Size aOutputSize( GetOutputSizePixel() );
+ m_xFrameContainerWindow->setPosSize( 0, 0, aOutputSize.Width(), aOutputSize.Height(), awt::PosSize::POSSIZE );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmPropBrw::Resize: caught an exception!" );
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+FmPropBrw::~FmPropBrw()
+{
+ if (m_xBrowserController.is())
+ implDetachController();
+ try
+ {
+ // remove our own properties from the component context. We cannot ensure that the component context
+ // is freed (there might be refcount problems :-\), so at least ensure the context itself
+ // does hold the objects anymore
+ Reference<XNameContainer> xName(m_xInspectorContext,uno::UNO_QUERY);
+ if ( xName.is() )
+ {
+ const ::rtl::OUString pProps[] = { ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) )
+ , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) )
+ , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) )
+ , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ) };
+ for ( size_t i = 0; i < SAL_N_ELEMENTS(pProps); ++i )
+ xName->removeByName( pProps[i] );
+ }
+ }
+ catch (const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ DBG_DTOR(FmPropBrw,NULL);
+}
+
+//-----------------------------------------------------------------------
+::rtl::OUString FmPropBrw::getCurrentPage() const
+{
+ ::rtl::OUString sCurrentPage;
+ try
+ {
+ if ( m_xBrowserController.is() )
+ {
+ OSL_VERIFY( m_xBrowserController->getViewData() >>= sCurrentPage );
+ }
+
+ if ( !sCurrentPage.getLength() )
+ sCurrentPage = m_sLastActivePage;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmPropBrw::getCurrentPage: caught an exception while retrieving the current page!" );
+ }
+ return sCurrentPage;
+}
+
+//-----------------------------------------------------------------------
+void FmPropBrw::implDetachController()
+{
+ m_sLastActivePage = getCurrentPage();
+
+ implSetNewSelection( InterfaceBag() );
+
+ if ( m_xMeAsFrame.is() )
+ {
+ try
+ {
+ m_xMeAsFrame->setComponent(NULL, NULL);
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmPropBrw::implDetachController: caught an exception while resetting the component!" );
+ }
+ }
+
+ // we attached a frame to the controller manually, so we need to manually tell it that it's detached, too
+ // 96068 - 09.01.2002 - fs@openoffice.org
+ if ( m_xBrowserController.is() )
+ m_xBrowserController->attachFrame( NULL );
+
+ m_xBrowserController.clear();
+ m_xInspectorModel.clear();
+ m_xMeAsFrame.clear();
+}
+
+//-----------------------------------------------------------------------
+sal_Bool FmPropBrw::Close()
+{
+ // suspend the controller (it is allowed to veto)
+ if ( m_xMeAsFrame.is() )
+ {
+ try
+ {
+ Reference< XController > xController( m_xMeAsFrame->getController() );
+ if ( xController.is() && !xController->suspend( sal_True ) )
+ return sal_False;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmPropBrw::Close: caught an exception while asking the controller!" );
+ }
+ }
+
+ implDetachController();
+
+ if( IsRollUp() )
+ RollDown();
+
+ // remember our bindings: while we're closed, we're deleted, too, so accessing the bindings after this
+ // would be deadly
+ // 10/19/00 - 79321 - FS
+ SfxBindings& rBindings = SfxControllerItem::GetBindings();
+
+ sal_Bool bClose = SfxFloatingWindow::Close();
+
+ if (bClose)
+ {
+ rBindings.Invalidate(SID_FM_CTL_PROPERTIES);
+ rBindings.Invalidate(SID_FM_PROPERTIES);
+ }
+
+ return bClose;
+}
+
+//-----------------------------------------------------------------------
+bool FmPropBrw::implIsReadOnlyModel() const
+{
+ try
+ {
+ if ( m_xInspectorModel.is() )
+ return m_xInspectorModel->getIsReadOnly();
+ return false;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return true;
+}
+
+//-----------------------------------------------------------------------
+void FmPropBrw::implSetNewSelection( const InterfaceBag& _rSelection )
+{
+ if ( m_xBrowserController.is() )
+ {
+ try
+ {
+ Reference< XObjectInspector > xInspector( m_xBrowserController, UNO_QUERY_THROW );
+
+ // tell it the objects to inspect
+ Sequence< Reference< XInterface > > aSelection( _rSelection.size() );
+ ::std::copy( _rSelection.begin(), _rSelection.end(), aSelection.getArray() );
+
+ xInspector->inspect( aSelection );
+ }
+ catch( const VetoException& )
+ {
+ return;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmPropBrw::implSetNewSelection: caught an unexpected exception!" );
+ return;
+ }
+
+ // set the new title according to the selected object
+ String sTitle;
+
+ if ( _rSelection.empty() )
+ {
+ sTitle = String( SVX_RES( RID_STR_NO_PROPERTIES ) );
+ }
+ else if ( _rSelection.size() > 1 )
+ {
+ // no form component and (no form or no name) -> Multiselection
+ sTitle = String( SVX_RES( RID_STR_PROPERTIES_CONTROL ) );
+ sTitle += String( SVX_RES( RID_STR_PROPTITLE_MULTISELECT ) );
+ }
+ else
+ {
+ Reference< XPropertySet > xSingleSelection( *_rSelection.begin(), UNO_QUERY);
+ if ( ::comphelper::hasProperty( FM_PROP_CLASSID, xSingleSelection ) )
+ {
+ sal_Int16 nClassID = FormComponentType::CONTROL;
+ xSingleSelection->getPropertyValue( FM_PROP_CLASSID ) >>= nClassID;
+
+ sTitle = String( SVX_RES( RID_STR_PROPERTIES_CONTROL ) );
+ sTitle += String( GetUIHeadlineName( nClassID, makeAny( xSingleSelection ) ) );
+ }
+ else if ( Reference< XForm >( xSingleSelection, UNO_QUERY ).is() )
+ sTitle = String( SVX_RES( RID_STR_PROPERTIES_FORM ) );
+ }
+
+ if ( implIsReadOnlyModel() )
+ sTitle += String( SVX_RES( RID_STR_READONLY_VIEW ) );
+
+ SetText( sTitle );
+
+ // #95343# ---------------------------------
+ Reference< ::com::sun::star::awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY );
+ if( xLayoutConstrains.is() )
+ {
+ ::Size aConstrainedSize;
+ ::com::sun::star::awt::Size aMinSize = xLayoutConstrains->getMinimumSize();
+
+ sal_Int32 nLeft(0), nTop(0), nRight(0), nBottom(0);
+ GetBorder( nLeft, nTop, nRight, nBottom );
+ aMinSize.Width += nLeft + nRight + 8;
+ aMinSize.Height += nTop + nBottom + 8;
+
+ aConstrainedSize.setHeight( aMinSize.Height );
+ aConstrainedSize.setWidth( aMinSize.Width );
+ SetMinOutputSizePixel( aConstrainedSize );
+ aConstrainedSize = GetOutputSizePixel();
+ sal_Bool bResize = sal_False;
+ if( aConstrainedSize.Width() < aMinSize.Width )
+ {
+ aConstrainedSize.setWidth( aMinSize.Width );
+ bResize = sal_True;
+ }
+ if( aConstrainedSize.Height() < aMinSize.Height )
+ {
+ aConstrainedSize.setHeight( aMinSize.Height );
+ bResize = sal_True;
+ }
+ if( bResize )
+ SetOutputSizePixel( aConstrainedSize );
+ }
+ }
+}
+
+//-----------------------------------------------------------------------
+void FmPropBrw::FillInfo( SfxChildWinInfo& rInfo ) const
+{
+ rInfo.bVisible = sal_False;
+ rInfo.aExtraString = getCurrentPage();
+}
+
+//-----------------------------------------------------------------------
+IMPL_LINK( FmPropBrw, OnAsyncGetFocus, void*, /*NOTINTERESTEDIN*/ )
+{
+ if (m_xBrowserComponentWindow.is())
+ m_xBrowserComponentWindow->setFocus();
+ return 0L;
+}
+
+//-----------------------------------------------------------------------
+namespace
+{
+ static bool lcl_shouldEnableHelpSection( const Reference< XMultiServiceFactory >& _rxFactory )
+ {
+ const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/Forms/PropertyBrowser/" ) );
+ const ::rtl::OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "DirectHelp" ) );
+
+ ::utl::OConfigurationTreeRoot aConfiguration(
+ ::utl::OConfigurationTreeRoot::createWithServiceFactory( _rxFactory, sConfigName ) );
+
+ bool bEnabled = false;
+ OSL_VERIFY( aConfiguration.getNodeValue( sPropertyName ) >>= bEnabled );
+ return bEnabled;
+ }
+}
+//-----------------------------------------------------------------------
+void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell )
+{
+ // the document in which we live
+ Reference< XInterface > xDocument;
+ if ( _pFormShell && _pFormShell->GetObjectShell() )
+ xDocument = _pFormShell->GetObjectShell()->GetModel();
+
+ // the context of the controls in our document
+ Reference< awt::XControlContainer > xControlContext;
+ if ( _pFormShell && _pFormShell->GetFormView() )
+ {
+ SdrPageView* pPageView = _pFormShell->GetFormView()->GetSdrPageView();
+
+ if(pPageView)
+ {
+ SdrPageWindow* pPageWindow = pPageView->GetPageWindow(0L);
+
+ if(pPageWindow)
+ {
+ xControlContext = pPageWindow->GetControlContainer();
+ }
+ }
+ }
+
+ // the default parent window for message boxes
+ Reference< XWindow > xParentWindow( VCLUnoHelper::GetInterface ( this ) );
+
+ // the mapping from control models to control shapes
+ Reference< XMap > xControlMap;
+ FmFormPage* pFormPage = _pFormShell ? _pFormShell->GetCurPage() : NULL;
+ if ( pFormPage )
+ xControlMap = pFormPage->GetImpl().getControlToShapeMap();
+
+ // our own component context
+ Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW );
+ Reference< XComponentContext > xOwnContext(
+ xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
+ UNO_QUERY_THROW );
+
+ // a ComponentContext for the
+ ::cppu::ContextEntry_Init aHandlerContextInfo[] =
+ {
+ ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( xDocument ) ),
+ ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( xParentWindow ) ),
+ ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) ), makeAny( xControlContext ) ),
+ ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ), makeAny( xControlMap ) )
+ };
+ m_xInspectorContext.set(
+ ::cppu::createComponentContext( aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ),
+ xOwnContext ) );
+
+ bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB );
+
+ // an object inspector model
+ m_xInspectorModel =
+ bEnableHelpSection
+ ? DefaultFormComponentInspectorModel::createWithHelpSection( m_xInspectorContext, 3, 5 )
+ : DefaultFormComponentInspectorModel::createDefault( m_xInspectorContext );
+
+ // an object inspector
+ m_xBrowserController = m_xBrowserController.query(
+ ObjectInspector::createWithModel(
+ m_xInspectorContext, m_xInspectorModel
+ ) );
+
+ if ( !m_xBrowserController.is() )
+ {
+ ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspector" ) );
+ ShowServiceNotAvailableError( GetParent(), sServiceName, sal_True );
+ }
+ else
+ {
+ m_xBrowserController->attachFrame( m_xMeAsFrame );
+ m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow();
+ DBG_ASSERT( m_xBrowserComponentWindow.is(), "FmPropBrw::impl_createPropertyBrowser_throw: attached the controller, but have no component window!" );
+ }
+
+ if ( bEnableHelpSection )
+ {
+ Reference< XObjectInspector > xInspector( m_xBrowserController, UNO_QUERY_THROW );
+ Reference< XObjectInspectorUI > xInspectorUI( xInspector->getInspectorUI() );
+ Reference< XInterface > xDefaultHelpProvider( DefaultHelpProvider::create( m_xInspectorContext, xInspectorUI ) );
+ }
+}
+
+//-----------------------------------------------------------------------
+void FmPropBrw::impl_ensurePropertyBrowser_nothrow( FmFormShell* _pFormShell )
+{
+ // the document in which we live
+ Reference< XInterface > xDocument;
+ SfxObjectShell* pObjectShell = _pFormShell ? _pFormShell->GetObjectShell() : NULL;
+ if ( pObjectShell )
+ xDocument = pObjectShell->GetModel();
+ if ( ( xDocument == m_xLastKnownDocument ) && m_xBrowserController.is() )
+ // nothing to do
+ return;
+
+ try
+ {
+ // clean up any previous instances of the object inspector
+ if ( m_xMeAsFrame.is() )
+ m_xMeAsFrame->setComponent( NULL, NULL );
+ else
+ ::comphelper::disposeComponent( m_xBrowserController );
+ m_xBrowserController.clear();
+ m_xInspectorModel.clear();
+ m_xBrowserComponentWindow.clear();
+
+ // and create a new one
+ impl_createPropertyBrowser_throw( _pFormShell );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_xLastKnownDocument = xDocument;
+}
+
+//-----------------------------------------------------------------------
+void FmPropBrw::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState)
+{
+ if (!pState || SID_FM_PROPERTY_CONTROL != nSID)
+ return;
+
+ m_bInStateChange = true;
+ try
+ {
+ if (eState >= SFX_ITEM_AVAILABLE)
+ {
+ FmFormShell* pShell = PTR_CAST(FmFormShell,((SfxObjectItem*)pState)->GetShell());
+ InterfaceBag aSelection;
+ if ( pShell )
+ pShell->GetImpl()->getCurrentSelection( aSelection );
+
+ impl_ensurePropertyBrowser_nothrow( pShell );
+
+ // set the new object to inspect
+ implSetNewSelection( aSelection );
+
+ // if this is the first time we're here, some additional things need to be done ...
+ if ( m_bInitialStateChange )
+ {
+ // if we're just newly created, we want to have the focus
+ PostUserEvent( LINK( this, FmPropBrw, OnAsyncGetFocus ) );
+
+ // and additionally, we want to show the page which was active during
+ // our previous incarnation
+ if ( m_sLastActivePage.getLength() )
+ {
+ try
+ {
+ if ( m_xBrowserController.is() )
+ m_xBrowserController->restoreViewData( makeAny( m_sLastActivePage ) );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmPropBrw::StateChanged: caught an exception while setting the initial page!" );
+ }
+ }
+
+ m_bInitialStateChange = sal_False;
+ }
+
+ }
+ else
+ {
+ implSetNewSelection( InterfaceBag() );
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("FmPropBrw::StateChanged: Exception occured!");
+ }
+ m_bInStateChange = false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmcontrolbordermanager.cxx b/svx/source/form/fmcontrolbordermanager.cxx
new file mode 100644
index 000000000000..fbbd9eb15c57
--- /dev/null
+++ b/svx/source/form/fmcontrolbordermanager.cxx
@@ -0,0 +1,443 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmcontrolbordermanager.hxx"
+
+#include "fmprop.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/awt/XListBox.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::form::validation;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ //--------------------------------------------------------------------
+ static void setUnderline( const Reference< XVclWindowPeer >& _rxPeer, const UnderlineDescriptor& _rUnderline )
+ {
+ OSL_ENSURE( _rxPeer.is(), "setUnderline: invalid peer!" );
+
+ // the underline type is an aspect of the font
+ FontDescriptor aFont;
+ OSL_VERIFY( _rxPeer->getProperty( FM_PROP_FONT ) >>= aFont );
+ aFont.Underline = _rUnderline.nUnderlineType;
+ _rxPeer->setProperty( FM_PROP_FONT, makeAny( aFont ) );
+ // the underline color is a separate property
+ _rxPeer->setProperty( FM_PROP_TEXTLINECOLOR, makeAny( _rUnderline.nUnderlineColor ) );
+ }
+
+ //--------------------------------------------------------------------
+ static void getUnderline( const Reference< XVclWindowPeer >& _rxPeer, UnderlineDescriptor& _rUnderline )
+ {
+ OSL_ENSURE( _rxPeer.is(), "getUnderline: invalid peer!" );
+
+ FontDescriptor aFont;
+ OSL_VERIFY( _rxPeer->getProperty( FM_PROP_FONT ) >>= aFont );
+ _rUnderline.nUnderlineType = aFont.Underline;
+
+ OSL_VERIFY( _rxPeer->getProperty( FM_PROP_TEXTLINECOLOR ) >>= _rUnderline.nUnderlineColor );
+ }
+
+ //--------------------------------------------------------------------
+ static void getBorder( const Reference< XVclWindowPeer >& _rxPeer, BorderDescriptor& _rBoder )
+ {
+ OSL_ENSURE( _rxPeer.is(), "getBorder: invalid peer!" );
+
+ OSL_VERIFY( _rxPeer->getProperty( FM_PROP_BORDER ) >>= _rBoder.nBorderType );
+ OSL_VERIFY( _rxPeer->getProperty( FM_PROP_BORDERCOLOR ) >>= _rBoder.nBorderColor );
+ }
+
+ //--------------------------------------------------------------------
+ static void setBorder( const Reference< XVclWindowPeer >& _rxPeer, const BorderDescriptor& _rBoder )
+ {
+ OSL_ENSURE( _rxPeer.is(), "setBorder: invalid peer!" );
+
+ _rxPeer->setProperty( FM_PROP_BORDER, makeAny( _rBoder.nBorderType ) );
+ _rxPeer->setProperty( FM_PROP_BORDERCOLOR, makeAny( _rBoder.nBorderColor ) );
+ }
+
+ //====================================================================
+ //= ControlBorderManager
+ //====================================================================
+ //--------------------------------------------------------------------
+ ControlBorderManager::ControlBorderManager()
+ :m_nFocusColor ( 0x000000FF )
+ ,m_nMouseHoveColor( 0x007098BE )
+ ,m_nInvalidColor ( 0x00FF0000 )
+ ,m_bDynamicBorderColors( false )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ControlBorderManager::~ControlBorderManager()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool ControlBorderManager::canColorBorder( const Reference< XVclWindowPeer >& _rxPeer )
+ {
+ OSL_PRECOND( _rxPeer.is(), "ControlBorderManager::canColorBorder: invalid peer!" );
+
+ PeerBag::const_iterator aPos = m_aColorableControls.find( _rxPeer );
+ if ( aPos != m_aColorableControls.end() )
+ return true;
+
+ aPos = m_aNonColorableControls.find( _rxPeer );
+ if ( aPos != m_aNonColorableControls.end() )
+ return false;
+
+ // this peer is not yet known
+
+ // no border coloring for controls which are not for text input
+ // #i37434# / 2004-11-19 / frank.schoenheit@sun.com
+ Reference< XTextComponent > xText( _rxPeer, UNO_QUERY );
+ Reference< XListBox > xListBox( _rxPeer, UNO_QUERY );
+ if ( xText.is() || xListBox.is() )
+ {
+ sal_Int16 nBorderStyle = VisualEffect::NONE;
+ OSL_VERIFY( _rxPeer->getProperty( FM_PROP_BORDER ) >>= nBorderStyle );
+ if ( nBorderStyle == VisualEffect::FLAT )
+ // if you change this to also accept LOOK3D, then this would also work, but look ugly
+ {
+ m_aColorableControls.insert( _rxPeer );
+ return true;
+ }
+ }
+
+ m_aNonColorableControls.insert( _rxPeer );
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ ControlStatus ControlBorderManager::getControlStatus( const Reference< XControl >& _rxControl ) SAL_THROW(())
+ {
+ ControlStatus nStatus = CONTROL_STATUS_NONE;
+
+ if ( _rxControl.get() == m_aFocusControl.xControl.get() )
+ nStatus |= CONTROL_STATUS_FOCUSED;
+
+ if ( _rxControl.get() == m_aMouseHoverControl.xControl.get() )
+ nStatus |= CONTROL_STATUS_MOUSE_HOVER;
+
+ if ( m_aInvalidControls.find( ControlData( _rxControl ) ) != m_aInvalidControls.end() )
+ nStatus |= CONTROL_STATUS_INVALID;
+
+ return nStatus;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 ControlBorderManager::getControlColorByStatus( ControlStatus _nStatus )
+ {
+ // "invalid" is ranked highest
+ if ( _nStatus & CONTROL_STATUS_INVALID )
+ return m_nInvalidColor;
+
+ // then, "focused" is more important than ...
+ if ( _nStatus & CONTROL_STATUS_FOCUSED )
+ return m_nFocusColor;
+
+ // ... "mouse over"
+ if ( _nStatus & CONTROL_STATUS_MOUSE_HOVER )
+ return m_nMouseHoveColor;
+
+ OSL_ENSURE( sal_False, "ControlBorderManager::getControlColorByStatus: invalid status!" );
+ return 0x00000000;
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::updateBorderStyle( const Reference< XControl >& _rxControl, const Reference< XVclWindowPeer >& _rxPeer, const BorderDescriptor& _rFallback ) SAL_THROW(())
+ {
+ OSL_PRECOND( _rxControl.is() && _rxPeer.is(), "ControlBorderManager::updateBorderStyle: invalid parameters!" );
+
+ ControlStatus nStatus = getControlStatus( _rxControl );
+ BorderDescriptor aBorder;
+ aBorder.nBorderType = ( nStatus == CONTROL_STATUS_NONE )
+ ? _rFallback.nBorderType
+ : VisualEffect::FLAT;
+ aBorder.nBorderColor = ( nStatus == CONTROL_STATUS_NONE )
+ ? _rFallback.nBorderColor
+ : getControlColorByStatus( nStatus );
+ setBorder( _rxPeer, aBorder );
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::determineOriginalBorderStyle( const Reference< XControl >& _rxControl, BorderDescriptor& _rData ) const
+ {
+ _rData = ControlData();
+ if ( m_aFocusControl.xControl.get() == _rxControl.get() )
+ {
+ _rData = m_aFocusControl;
+ }
+ else if ( m_aMouseHoverControl.xControl.get() == _rxControl.get() )
+ {
+ _rData = m_aMouseHoverControl;
+ }
+ else
+ {
+ ControlBag::const_iterator aPos = m_aInvalidControls.find( _rxControl );
+ if ( aPos != m_aInvalidControls.end() )
+ {
+ _rData = *aPos;
+ }
+ else
+ {
+ Reference< XVclWindowPeer > xPeer( _rxControl->getPeer(), UNO_QUERY );
+ getBorder( xPeer, _rData );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::controlStatusGained( const Reference< XInterface >& _rxControl, ControlData& _rControlData ) SAL_THROW(())
+ {
+ if ( _rxControl == _rControlData.xControl )
+ // nothing to do - though suspicious
+ return;
+
+ Reference< XControl > xAsControl( _rxControl, UNO_QUERY );
+ DBG_ASSERT( xAsControl.is(), "ControlBorderManager::controlStatusGained: invalid control!" );
+ if ( !xAsControl.is() )
+ return;
+
+ try
+ {
+ Reference< XVclWindowPeer > xPeer( xAsControl->getPeer(), UNO_QUERY );
+ if ( xPeer.is() && canColorBorder( xPeer ) )
+ {
+ // remember the control and it's current border color
+ _rControlData.xControl.clear(); // so determineOriginalBorderStyle doesn't get confused
+
+ determineOriginalBorderStyle( xAsControl, _rControlData );
+
+ _rControlData.xControl = xAsControl;
+
+ updateBorderStyle( xAsControl, xPeer, _rControlData );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ControlBorderManager::controlStatusGained: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::controlStatusLost( const Reference< XInterface >& _rxControl, ControlData& _rControlData ) SAL_THROW(())
+ {
+ if ( _rxControl != _rControlData.xControl )
+ // nothing to do
+ return;
+
+ OSL_PRECOND( _rControlData.xControl.is(), "ControlBorderManager::controlStatusLost: invalid control data - this will crash!" );
+ try
+ {
+ Reference< XVclWindowPeer > xPeer( _rControlData.xControl->getPeer(), UNO_QUERY );
+ if ( xPeer.is() && canColorBorder( xPeer ) )
+ {
+ ControlData aPreviousStatus( _rControlData );
+ _rControlData = ControlData();
+ updateBorderStyle( aPreviousStatus.xControl, xPeer, aPreviousStatus );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ControlBorderManager::controlStatusLost: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::enableDynamicBorderColor( )
+ {
+ m_bDynamicBorderColors = true;
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::disableDynamicBorderColor( )
+ {
+ m_bDynamicBorderColors = false;
+ restoreAll();
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::setStatusColor( ControlStatus _nStatus, sal_Int32 _nColor )
+ {
+ switch ( _nStatus )
+ {
+ case CONTROL_STATUS_FOCUSED:
+ m_nFocusColor = _nColor;
+ break;
+ case CONTROL_STATUS_MOUSE_HOVER:
+ m_nMouseHoveColor = _nColor;
+ break;
+ case CONTROL_STATUS_INVALID:
+ m_nInvalidColor = _nColor;
+ break;
+ default:
+ OSL_ENSURE( sal_False, "ControlBorderManager::setStatusColor: invalid status!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::restoreAll()
+ {
+ if ( m_aFocusControl.xControl.is() )
+ controlStatusLost( m_aFocusControl.xControl, m_aFocusControl );
+ if ( m_aMouseHoverControl.xControl.is() )
+ controlStatusLost( m_aMouseHoverControl.xControl, m_aMouseHoverControl );
+
+ ControlBag aInvalidControls;
+ m_aInvalidControls.swap( aInvalidControls );
+
+ for ( ControlBag::const_iterator loop = aInvalidControls.begin();
+ loop != aInvalidControls.end();
+ ++loop
+ )
+ {
+ Reference< XVclWindowPeer > xPeer( loop->xControl->getPeer(), UNO_QUERY );
+ if ( xPeer.is() )
+ {
+ updateBorderStyle( loop->xControl, xPeer, *loop );
+ xPeer->setProperty( FM_PROP_HELPTEXT, makeAny( loop->sOriginalHelpText ) );
+ setUnderline( xPeer, *loop );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::focusGained( const Reference< XInterface >& _rxControl ) SAL_THROW(())
+ {
+ if ( m_bDynamicBorderColors )
+ controlStatusGained( _rxControl, m_aFocusControl );
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::focusLost( const Reference< XInterface >& _rxControl ) SAL_THROW(())
+ {
+ if ( m_bDynamicBorderColors )
+ controlStatusLost( _rxControl, m_aFocusControl );
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::mouseEntered( const Reference< XInterface >& _rxControl ) SAL_THROW(())
+ {
+ if ( m_bDynamicBorderColors )
+ controlStatusGained( _rxControl, m_aMouseHoverControl );
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::mouseExited( const Reference< XInterface >& _rxControl ) SAL_THROW(())
+ {
+ if ( m_bDynamicBorderColors )
+ controlStatusLost( _rxControl, m_aMouseHoverControl );
+ }
+
+ //--------------------------------------------------------------------
+ void ControlBorderManager::validityChanged( const Reference< XControl >& _rxControl, const Reference< XValidatableFormComponent >& _rxValidatable ) SAL_THROW(())
+ {
+ try
+ {
+ OSL_ENSURE( _rxControl.is(), "ControlBorderManager::validityChanged: invalid control!" );
+ OSL_ENSURE( _rxValidatable.is(), "ControlBorderManager::validityChanged: invalid validatable!" );
+
+ Reference< XVclWindowPeer > xPeer( _rxControl.is() ? _rxControl->getPeer() : Reference< XWindowPeer >(), UNO_QUERY );
+ if ( !xPeer.is() || !_rxValidatable.is() )
+ return;
+
+ ControlData aData( _rxControl );
+
+ if ( _rxValidatable->isValid() )
+ {
+ ControlBag::iterator aPos = m_aInvalidControls.find( aData );
+ if ( aPos != m_aInvalidControls.end() )
+ { // invalid before, valid now
+ ControlData aOriginalLayout( *aPos );
+ m_aInvalidControls.erase( aPos );
+
+ // restore all the things we used to indicate invalidity
+ if ( m_bDynamicBorderColors )
+ updateBorderStyle( _rxControl, xPeer, aOriginalLayout );
+ xPeer->setProperty( FM_PROP_HELPTEXT, makeAny( aOriginalLayout.sOriginalHelpText ) );
+ setUnderline( xPeer, aOriginalLayout );
+ }
+ return;
+ }
+
+ // we're here in the INVALID case
+ if ( m_aInvalidControls.find( _rxControl ) == m_aInvalidControls.end() )
+ { // valid before, invalid now
+
+ // remember the current border
+ determineOriginalBorderStyle( _rxControl, aData );
+ // and tool tip
+ xPeer->getProperty( FM_PROP_HELPTEXT ) >>= aData.sOriginalHelpText;
+ // and font
+ getUnderline( xPeer, aData );
+
+ m_aInvalidControls.insert( aData );
+
+ // update the border to the new invalidity
+ if ( m_bDynamicBorderColors && canColorBorder( xPeer ) )
+ updateBorderStyle( _rxControl, xPeer, aData );
+ else
+ {
+ // and also the new font
+ setUnderline( xPeer, UnderlineDescriptor( com::sun::star::awt::FontUnderline::WAVE, m_nInvalidColor ) );
+ }
+ }
+
+ // update the explanation for invalidity (this is always done, even if the validity did not change)
+ Reference< XValidator > xValidator = _rxValidatable->getValidator();
+ OSL_ENSURE( xValidator.is(), "ControlBorderManager::validityChanged: invalid, but no validator?" );
+ ::rtl::OUString sExplainInvalidity = xValidator.is() ? xValidator->explainInvalid( _rxValidatable->getCurrentValue() ) : ::rtl::OUString();
+ xPeer->setProperty( FM_PROP_HELPTEXT, makeAny( sExplainInvalidity ) );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ControlBorderManager::validityChanged: caught an exception!" );
+ }
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmcontrollayout.cxx b/svx/source/form/fmcontrollayout.cxx
new file mode 100644
index 000000000000..33ba99b9dc39
--- /dev/null
+++ b/svx/source/form/fmcontrollayout.cxx
@@ -0,0 +1,331 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmcontrollayout.hxx"
+#include "fmprop.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/awt/VisualEffect.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XChild.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/processfactory.hxx>
+#include <i18npool/mslangid.hxx>
+#include <unotools/syslocale.hxx>
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/outdev.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ using namespace ::utl;
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::lang::Locale;
+ using ::com::sun::star::awt::FontDescriptor;
+ using ::com::sun::star::style::XStyleFamiliesSupplier;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::container::XChild;
+ /** === end UNO using === **/
+ namespace FormComponentType = ::com::sun::star::form::FormComponentType;
+ namespace VisualEffect = ::com::sun::star::awt::VisualEffect;
+ namespace ScriptType = ::com::sun::star::i18n::ScriptType;
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //....................................................................
+ template< class INTERFACE_TYPE >
+ Reference< INTERFACE_TYPE > getTypedModelNode( const Reference< XInterface >& _rxModelNode )
+ {
+ Reference< INTERFACE_TYPE > xTypedNode( _rxModelNode, UNO_QUERY );
+ if ( xTypedNode.is() )
+ return xTypedNode;
+ else
+ {
+ Reference< XChild > xChild( _rxModelNode, UNO_QUERY );
+ if ( xChild.is() )
+ return getTypedModelNode< INTERFACE_TYPE >( xChild->getParent() );
+ else
+ return NULL;
+ }
+ }
+
+ //....................................................................
+ static bool lcl_getDocumentDefaultStyleAndFamily( const Reference< XInterface >& _rxDocument, ::rtl::OUString& _rFamilyName, ::rtl::OUString& _rStyleName ) SAL_THROW(( Exception ))
+ {
+ bool bSuccess = true;
+ Reference< XServiceInfo > xDocumentSI( _rxDocument, UNO_QUERY );
+ if ( xDocumentSI.is() )
+ {
+ if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) ) )
+ || xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.WebDocument" ) ) )
+ )
+ {
+ _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphStyles" ) );
+ _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+ }
+ else if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocument" ) ) ) )
+ {
+ _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) );
+ _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Default" ) );
+ }
+ else if ( xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DrawingDocument" ) ) )
+ || xDocumentSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.PresentationDocument" ) ) )
+ )
+ {
+ _rFamilyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "graphics" ) );
+ _rStyleName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "standard" ) );
+ }
+ else
+ bSuccess = false;
+ }
+ return bSuccess;
+ }
+
+ //....................................................................
+ static void lcl_initializeControlFont( const Reference< XPropertySet >& _rxModel )
+ {
+ try
+ {
+ Reference< XPropertySet > xStyle( ControlLayouter::getDefaultDocumentTextStyle( _rxModel ), UNO_SET_THROW );
+ Reference< XPropertySetInfo > xStylePSI( xStyle->getPropertySetInfo(), UNO_SET_THROW );
+
+ // determine the script type associated with the system locale
+ const SvtSysLocale aSysLocale;
+ const LocaleDataWrapper& rSysLocaleData = aSysLocale.GetLocaleData();
+ const sal_Int16 eSysLocaleScriptType = MsLangId::getScriptType( MsLangId::convertLocaleToLanguage( rSysLocaleData.getLocale() ) );
+
+ // depending on this script type, use the right property from the document's style which controls the
+ // default locale for document content
+ const sal_Char* pCharLocalePropertyName = "CharLocale";
+ switch ( eSysLocaleScriptType )
+ {
+ case ScriptType::LATIN:
+ // already defaulted above
+ break;
+ case ScriptType::ASIAN:
+ pCharLocalePropertyName = "CharLocaleAsian";
+ break;
+ case ScriptType::COMPLEX:
+ pCharLocalePropertyName = "CharLocaleComplex";
+ break;
+ default:
+ OSL_ENSURE( false, "lcl_initializeControlFont: unexpected script type for system locale!" );
+ break;
+ }
+
+ ::rtl::OUString sCharLocalePropertyName = ::rtl::OUString::createFromAscii( pCharLocalePropertyName );
+ Locale aDocumentCharLocale;
+ if ( xStylePSI->hasPropertyByName( sCharLocalePropertyName ) )
+ {
+ OSL_VERIFY( xStyle->getPropertyValue( sCharLocalePropertyName ) >>= aDocumentCharLocale );
+ }
+ // fall back to CharLocale property at the style
+ if ( !aDocumentCharLocale.Language.getLength() )
+ {
+ sCharLocalePropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharLocale" ) );
+ if ( xStylePSI->hasPropertyByName( sCharLocalePropertyName ) )
+ {
+ OSL_VERIFY( xStyle->getPropertyValue( sCharLocalePropertyName ) >>= aDocumentCharLocale );
+ }
+ }
+ // fall back to the system locale
+ if ( !aDocumentCharLocale.Language.getLength() )
+ {
+ aDocumentCharLocale = rSysLocaleData.getLocale();
+ }
+
+ // retrieve a default font for this locale, and set it at the control
+ Font aFont = OutputDevice::GetDefaultFont( DEFAULTFONT_SANS, MsLangId::convertLocaleToLanguage( aDocumentCharLocale ), DEFAULTFONT_FLAGS_ONLYONE );
+ FontDescriptor aFontDesc = VCLUnoHelper::CreateFontDescriptor( aFont );
+ _rxModel->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontDescriptor" ) ),
+ makeAny( aFontDesc )
+ );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //====================================================================
+ //= ControlLayouter
+ //====================================================================
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > ControlLayouter::getDefaultDocumentTextStyle( const Reference< XPropertySet >& _rxModel )
+ {
+ // the style family collection
+ Reference< XStyleFamiliesSupplier > xSuppStyleFamilies( getTypedModelNode< XStyleFamiliesSupplier >( _rxModel.get() ), UNO_SET_THROW );
+ Reference< XNameAccess > xStyleFamilies( xSuppStyleFamilies->getStyleFamilies(), UNO_SET_THROW );
+
+ // the names of the family, and the style - depends on the document type we live in
+ ::rtl::OUString sFamilyName, sStyleName;
+ if ( !lcl_getDocumentDefaultStyleAndFamily( xSuppStyleFamilies.get(), sFamilyName, sStyleName ) )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unknown document type!" ) ), NULL );
+
+ // the concrete style
+ Reference< XNameAccess > xStyleFamily( xStyleFamilies->getByName( sFamilyName ), UNO_QUERY_THROW );
+ return Reference< XPropertySet >( xStyleFamily->getByName( sStyleName ), UNO_QUERY_THROW );
+ }
+
+ //--------------------------------------------------------------------
+ void ControlLayouter::initializeControlLayout( const Reference< XPropertySet >& _rxControlModel, DocumentType _eDocType )
+ {
+ DBG_ASSERT( _rxControlModel.is(), "ControlLayouter::initializeControlLayout: invalid model!" );
+ if ( !_rxControlModel.is() )
+ return;
+
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( _rxControlModel->getPropertySetInfo(), UNO_SET_THROW );
+
+ // the control type
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ _rxControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId;
+
+ // the document type
+ if ( _eDocType == eUnknownDocumentType )
+ _eDocType = DocumentClassification::classifyHostDocument( _rxControlModel.get() );
+
+ // let's see what the configuration says about the visual effect
+ OConfigurationNode aConfig = getLayoutSettings( _eDocType );
+ Any aVisualEffect = aConfig.getNodeValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VisualEffect" ) ) );
+ if ( aVisualEffect.hasValue() )
+ {
+ ::rtl::OUString sVisualEffect;
+ OSL_VERIFY( aVisualEffect >>= sVisualEffect );
+
+ sal_Int16 nVisualEffect = VisualEffect::NONE;
+ if ( sVisualEffect.equalsAscii( "flat" ) )
+ nVisualEffect = VisualEffect::FLAT;
+ else if ( sVisualEffect.equalsAscii( "3D" ) )
+ nVisualEffect = VisualEffect::LOOK3D;
+
+ if ( xPSI->hasPropertyByName( FM_PROP_BORDER ) )
+ {
+ if ( ( nClassId != FormComponentType::COMMANDBUTTON )
+ && ( nClassId != FormComponentType::RADIOBUTTON )
+ && ( nClassId != FormComponentType::CHECKBOX )
+ && ( nClassId != FormComponentType::GROUPBOX )
+ && ( nClassId != FormComponentType::FIXEDTEXT )
+ && ( nClassId != FormComponentType::SCROLLBAR )
+ && ( nClassId != FormComponentType::SPINBUTTON )
+ )
+ {
+ _rxControlModel->setPropertyValue( FM_PROP_BORDER, makeAny( nVisualEffect ) );
+ if ( ( nVisualEffect == VisualEffect::FLAT )
+ && ( xPSI->hasPropertyByName( FM_PROP_BORDERCOLOR ) )
+ )
+ // light gray flat border
+ _rxControlModel->setPropertyValue( FM_PROP_BORDERCOLOR, makeAny( (sal_Int32)0x00C0C0C0 ) );
+ }
+ }
+ if ( xPSI->hasPropertyByName( FM_PROP_VISUALEFFECT ) )
+ _rxControlModel->setPropertyValue( FM_PROP_VISUALEFFECT, makeAny( nVisualEffect ) );
+ }
+
+ // the font (only if we use the document's ref devices for rendering control text, otherwise, the
+ // default font of VCL controls is assumed to be fine)
+ if ( useDocumentReferenceDevice( _eDocType )
+ && xPSI->hasPropertyByName( FM_PROP_FONT )
+ )
+ lcl_initializeControlFont( _rxControlModel );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ControlLayouter::initializeControlLayout: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::utl::OConfigurationNode ControlLayouter::getLayoutSettings( DocumentType _eDocType )
+ {
+ ::rtl::OUString sConfigName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/Forms/ControlLayout/" ) );
+ sConfigName += DocumentClassification::getModuleIdentifierForDocumentType( _eDocType );
+ return OConfigurationTreeRoot::createWithServiceFactory(
+ ::comphelper::getProcessServiceFactory(), // TODO
+ sConfigName );
+ }
+
+ //--------------------------------------------------------------------
+ bool ControlLayouter::useDynamicBorderColor( DocumentType _eDocType )
+ {
+ OConfigurationNode aConfig = getLayoutSettings( _eDocType );
+ Any aDynamicBorderColor = aConfig.getNodeValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DynamicBorderColors" ) ) );
+ bool bDynamicBorderColor = false;
+ OSL_VERIFY( aDynamicBorderColor >>= bDynamicBorderColor );
+ return bDynamicBorderColor;
+ }
+
+ //--------------------------------------------------------------------
+ bool ControlLayouter::useDocumentReferenceDevice( DocumentType _eDocType )
+ {
+ if ( _eDocType == eUnknownDocumentType )
+ return false;
+ OConfigurationNode aConfig = getLayoutSettings( _eDocType );
+ Any aUseRefDevice = aConfig.getNodeValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseDocumentTextMetrics" ) ) );
+ bool bUseRefDevice = false;
+ OSL_VERIFY( aUseRefDevice >>= bUseRefDevice );
+ return bUseRefDevice;
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmdmod.cxx b/svx/source/form/fmdmod.cxx
new file mode 100644
index 000000000000..877ea51088ab
--- /dev/null
+++ b/svx/source/form/fmdmod.cxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <sal/macros.h>
+#include <svx/fmdmod.hxx>
+#include "fmservs.hxx"
+#include <fmobj.hxx>
+#include <svx/unoshape.hxx>
+#include <comphelper/processfactory.hxx>
+#include <svx/fmglob.hxx>
+
+using namespace ::svxform;
+
+//-----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxFmMSFactory::createInstance(const ::rtl::OUString& ServiceSpecifier) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException )
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRet;
+ if ( ServiceSpecifier.indexOf( ::rtl::OUString::createFromAscii("com.sun.star.form.component.") ) == 0 )
+ {
+ xRet = ::comphelper::getProcessServiceFactory()->createInstance(ServiceSpecifier);
+ }
+ else if ( ServiceSpecifier == ::rtl::OUString( ::rtl::OUString::createFromAscii("com.sun.star.drawing.ControlShape") ) )
+ {
+ SdrObject* pObj = new FmFormObj(OBJ_FM_CONTROL);
+ xRet = *new SvxShapeControl(pObj);
+ }
+ if (!xRet.is())
+ xRet = SvxUnoDrawMSFactory::createInstance(ServiceSpecifier);
+ return xRet;
+}
+
+//-----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvxFmMSFactory::createInstanceWithArguments(const ::rtl::OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments) throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException )
+{
+ return SvxUnoDrawMSFactory::createInstanceWithArguments(ServiceSpecifier, Arguments );
+}
+
+//-----------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SvxFmMSFactory::getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException )
+{
+ static const ::rtl::OUString aSvxComponentServiceNameList[] =
+ {
+ FM_SUN_COMPONENT_TEXTFIELD,
+ FM_SUN_COMPONENT_FORM,
+ FM_SUN_COMPONENT_LISTBOX,
+ FM_SUN_COMPONENT_COMBOBOX,
+ FM_SUN_COMPONENT_RADIOBUTTON,
+ FM_SUN_COMPONENT_GROUPBOX,
+ FM_SUN_COMPONENT_FIXEDTEXT,
+ FM_SUN_COMPONENT_COMMANDBUTTON,
+ FM_SUN_COMPONENT_CHECKBOX,
+ FM_SUN_COMPONENT_GRIDCONTROL,
+ FM_SUN_COMPONENT_IMAGEBUTTON,
+ FM_SUN_COMPONENT_FILECONTROL,
+ FM_SUN_COMPONENT_TIMEFIELD,
+ FM_SUN_COMPONENT_DATEFIELD,
+ FM_SUN_COMPONENT_NUMERICFIELD,
+ FM_SUN_COMPONENT_CURRENCYFIELD,
+ FM_SUN_COMPONENT_PATTERNFIELD,
+ FM_SUN_COMPONENT_HIDDENCONTROL,
+ FM_SUN_COMPONENT_IMAGECONTROL
+ };
+
+ static const sal_uInt16 nSvxComponentServiceNameListCount = SAL_N_ELEMENTS(aSvxComponentServiceNameList);
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSeq( nSvxComponentServiceNameListCount );
+ ::rtl::OUString* pStrings = aSeq.getArray();
+ for( sal_uInt16 nIdx = 0; nIdx < nSvxComponentServiceNameListCount; nIdx++ )
+ pStrings[nIdx] = aSvxComponentServiceNameList[nIdx];
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aParentSeq( SvxUnoDrawMSFactory::getAvailableServiceNames() );
+ return concatServiceNames( aParentSeq, aSeq );
+}
+
+/*
+// XServiceManager
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SvxFmDrawModel::createInstance(const ::rtl::OUString& ServiceName)
+ const throw( ::com::sun::star::lang::ServiceNotRegisteredException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException )
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xRet;
+ sal_uInt16 nTokenCount = ServiceName.getTokenCount('.');
+ if (nTokenCount == 5 &&
+ ServiceName.getToken( 0, '.' ) == ::rtl::OUString::createFromAscii("stardiv") &&
+ ServiceName.getToken( 1, '.' ) == ::rtl::OUString::createFromAscii("one") &&
+ ServiceName.getToken( 2, '.' ) == ::rtl::OUString::createFromAscii("form") &&
+ ServiceName.getToken( 3, '.' ) == ::rtl::OUString::createFromAscii("component"))
+ {
+ xRet = ::comphelper::getProcessServiceFactory()->createInstance(ServiceName);
+ }
+ else
+ if (nTokenCount == 4 &&
+ ServiceName.getToken( 0, '.' ) == ::rtl::OUString::createFromAscii("stardiv") &&
+ ServiceName.getToken( 1, '.' ) == ::rtl::OUString::createFromAscii("one") &&
+ ServiceName.getToken( 2, '.' ) == ::rtl::OUString::createFromAscii("drawing") &&
+ ServiceName.getToken( 3, '.' ) == ::rtl::OUString::createFromAscii("ControlShape"))
+ {
+ SdrObject* pObj = new FmFormObj();
+ xRet = *new SvxShapeControl(pObj);
+ }
+ if (!xRet.is())
+ xRet = SvxUnoDrawModel::createInstance(ServiceName);
+ return xRet;
+}
+*/
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmdocumentclassification.cxx b/svx/source/form/fmdocumentclassification.cxx
new file mode 100644
index 000000000000..bbef532dd0ed
--- /dev/null
+++ b/svx/source/form/fmdocumentclassification.cxx
@@ -0,0 +1,214 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmdocumentclassification.hxx"
+#include "svx/dbtoolsclient.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/xforms/XFormsSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/frame/XModule.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ namespace
+ {
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::frame::XModule;
+
+ //....................................................................
+ template< class TYPE >
+ Reference< TYPE > getTypedModelNode( const Reference< XInterface >& _rxModelNode )
+ {
+ Reference< TYPE > xTypedNode( _rxModelNode, UNO_QUERY );
+ if ( xTypedNode.is() )
+ return xTypedNode;
+ else
+ {
+ Reference< XChild > xChild( _rxModelNode, UNO_QUERY );
+ if ( xChild.is() )
+ return getTypedModelNode< TYPE >( xChild->getParent() );
+ else
+ return Reference< TYPE >();
+ }
+ }
+
+ //....................................................................
+ Reference< XModel > getDocument( const Reference< XInterface >& _rxModelNode )
+ {
+ return getTypedModelNode< XModel >( _rxModelNode );
+ }
+ }
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::xforms;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::sdbc;
+
+ //====================================================================
+ //====================================================================
+ namespace
+ {
+ //----------------------------------------------------------------
+ struct ModuleInfo
+ {
+ const sal_Char* pAsciiModuleOrServiceName;
+ DocumentType eType;
+ };
+
+ //----------------------------------------------------------------
+ const ModuleInfo* lcl_getModuleInfo()
+ {
+ static const ModuleInfo aModuleInfo[] =
+ {
+ { "com.sun.star.text.TextDocument", eTextDocument },
+ { "com.sun.star.text.WebDocument", eWebDocument },
+ { "com.sun.star.sheet.SpreadsheetDocument", eSpreadsheetDocument },
+ { "com.sun.star.drawing.DrawingDocument", eDrawingDocument },
+ { "com.sun.star.presentation.PresentationDocument", ePresentationDocument },
+ { "com.sun.star.xforms.XMLFormDocument", eEnhancedForm },
+ { "com.sun.star.sdb.FormDesign", eDatabaseForm },
+ { "com.sun.star.sdb.TextReportDesign", eDatabaseReport },
+ { "com.sun.star.text.GlobalDocument", eTextDocument },
+ { NULL, eUnknownDocumentType }
+ };
+ return aModuleInfo;
+ }
+ }
+
+ //====================================================================
+ //= DocumentClassification
+ //====================================================================
+ //--------------------------------------------------------------------
+ DocumentType DocumentClassification::classifyDocument( const Reference< XModel >& _rxDocumentModel ) SAL_THROW(())
+ {
+ DocumentType eType( eUnknownDocumentType );
+
+ OSL_ENSURE( _rxDocumentModel.is(), "DocumentClassification::classifyDocument: invalid document!" );
+ if ( !_rxDocumentModel.is() )
+ return eType;
+
+ try
+ {
+ // first, check whether the document has a ModuleIdentifier which we know
+ ::rtl::OUString sModuleIdentifier;
+ Reference< XModule > xModule( _rxDocumentModel, UNO_QUERY );
+ if ( xModule.is() )
+ eType = getDocumentTypeForModuleIdentifier( xModule->getIdentifier() );
+ if ( eType != eUnknownDocumentType )
+ return eType;
+
+ // second, check whether it supports one of the services we know
+ Reference< XServiceInfo > xSI( _rxDocumentModel, UNO_QUERY_THROW );
+ const ModuleInfo* pModuleInfo = lcl_getModuleInfo();
+ while ( pModuleInfo->pAsciiModuleOrServiceName )
+ {
+ if ( xSI->supportsService( ::rtl::OUString::createFromAscii( pModuleInfo->pAsciiModuleOrServiceName ) ) )
+ return pModuleInfo->eType;
+ ++pModuleInfo;
+ }
+
+ // last: uhm, there is no last resort
+ OSL_ENSURE( false, "DocumentClassification::classifyDocument: unknown document!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return eType;
+ }
+
+ //--------------------------------------------------------------------
+ DocumentType DocumentClassification::classifyHostDocument( const Reference< XInterface >& _rxFormComponent ) SAL_THROW(())
+ {
+ DocumentType eType( eUnknownDocumentType );
+
+ try
+ {
+ Reference< XModel > xDocument( getDocument( _rxFormComponent.get() ) );
+ if ( !xDocument.is() )
+ return eUnknownDocumentType;
+ eType = classifyDocument( xDocument );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "DocumentClassification::classifyHostDocument: caught an exception!" );
+ }
+
+ return eType;
+ }
+
+ //--------------------------------------------------------------------
+ DocumentType DocumentClassification::getDocumentTypeForModuleIdentifier( const ::rtl::OUString& _rModuleIdentifier )
+ {
+ const ModuleInfo* pModuleInfo = lcl_getModuleInfo();
+ while ( pModuleInfo->pAsciiModuleOrServiceName )
+ {
+ if ( _rModuleIdentifier.equalsAscii( pModuleInfo->pAsciiModuleOrServiceName ) )
+ return pModuleInfo->eType;
+ ++pModuleInfo;
+ }
+ return eUnknownDocumentType;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString DocumentClassification::getModuleIdentifierForDocumentType( DocumentType _eType )
+ {
+ const ModuleInfo* pModuleInfo = lcl_getModuleInfo();
+ while ( pModuleInfo->pAsciiModuleOrServiceName )
+ {
+ if ( pModuleInfo->eType == _eType )
+ return ::rtl::OUString::createFromAscii( pModuleInfo->pAsciiModuleOrServiceName );
+ ++pModuleInfo;
+ }
+ return ::rtl::OUString();
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmdpage.cxx b/svx/source/form/fmdpage.cxx
new file mode 100644
index 000000000000..ae828beee237
--- /dev/null
+++ b/svx/source/form/fmdpage.cxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/fmpage.hxx>
+#include "fmobj.hxx"
+#include <svx/fmglob.hxx>
+#include <svx/fmdpage.hxx>
+#include <svx/unoshape.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/typeprovider.hxx>
+
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::form::XFormsSupplier2;
+
+DBG_NAME(SvxFmDrawPage)
+SvxFmDrawPage::SvxFmDrawPage( SdrPage* pInPage ) :
+ SvxDrawPage( pInPage )
+{
+ DBG_CTOR(SvxFmDrawPage,NULL);
+}
+
+SvxFmDrawPage::~SvxFmDrawPage() throw ()
+{
+ DBG_DTOR(SvxFmDrawPage,NULL);
+}
+
+::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL SvxFmDrawPage::getImplementationId() throw(::com::sun::star::uno::RuntimeException)
+{
+ static ::cppu::OImplementationId* pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+Any SAL_CALL SvxFmDrawPage::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
+{
+ Any aRet = ::cppu::queryInterface ( _rType
+ , static_cast< XFormsSupplier2* >( this )
+ , static_cast< XFormsSupplier* >( this )
+ );
+ if ( !aRet.hasValue() )
+ aRet = SvxDrawPage::queryAggregation( _rType );
+
+ return aRet;
+}
+
+/***********************************************************************
+* *
+***********************************************************************/
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL SvxFmDrawPage::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypes(SvxDrawPage::getTypes());
+ aTypes.realloc(aTypes.getLength() + 1);
+ ::com::sun::star::uno::Type* pTypes = aTypes.getArray();
+
+ pTypes[aTypes.getLength()-1] = ::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier>*)0);
+ return aTypes;
+}
+
+SdrObject *SvxFmDrawPage::_CreateSdrObject( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > & xDescr ) throw ()
+{
+ ::rtl::OUString aShapeType( xDescr->getShapeType() );
+
+ if ( aShapeType.equalsAscii( "com.sun.star.drawing.ShapeControl" ) // compatibility
+ || aShapeType.equalsAscii( "com.sun.star.drawing.ControlShape" )
+ )
+ return new FmFormObj( OBJ_FM_CONTROL );
+ else
+ return SvxDrawPage::_CreateSdrObject( xDescr );
+
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > SvxFmDrawPage::_CreateShape( SdrObject *pObj ) const throw ()
+{
+ if( FmFormInventor == pObj->GetObjInventor() )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape = (SvxShape*)new SvxShapeControl( pObj );
+ return xShape;
+ }
+ else
+ return SvxDrawPage::_CreateShape( pObj );
+}
+
+// XFormsSupplier
+::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > SAL_CALL SvxFmDrawPage::getForms(void) throw( ::com::sun::star::uno::RuntimeException )
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xForms;
+
+ FmFormPage *pFmPage = PTR_CAST( FmFormPage, GetSdrPage() );
+ if( pFmPage )
+ xForms = pFmPage->GetForms();
+
+ return xForms;
+}
+
+// XFormsSupplier2
+sal_Bool SAL_CALL SvxFmDrawPage::hasForms(void) throw( ::com::sun::star::uno::RuntimeException )
+{
+ sal_Bool bHas = sal_False;
+ FmFormPage* pFormPage = PTR_CAST( FmFormPage, GetSdrPage() );
+ if ( pFormPage )
+ bHas = pFormPage->GetForms( false ).is();
+ return bHas;
+}
+
+// ::com::sun::star::lang::XServiceInfo
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL SvxFmDrawPage::getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException )
+{
+ return SvxDrawPage::getSupportedServiceNames();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmexch.cxx b/svx/source/form/fmexch.cxx
new file mode 100644
index 000000000000..565611f61bb6
--- /dev/null
+++ b/svx/source/form/fmexch.cxx
@@ -0,0 +1,443 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "fmexch.hxx"
+
+#include <sot/storage.hxx>
+#include <svl/itempool.hxx>
+
+#include <dbexch.hrc>
+#include <sot/formats.hxx>
+#include <svtools/svtreebx.hxx>
+#include <tools/diagnose_ex.h>
+
+#define _SVSTDARR_ULONGS
+#include <svl/svstdarr.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::datatransfer;
+
+ //====================================================================
+ //= OLocalExchange
+ //====================================================================
+ //--------------------------------------------------------------------
+ OLocalExchange::OLocalExchange( )
+ :m_bDragging( sal_False )
+ ,m_bClipboardOwner( sal_False )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchange::copyToClipboard( Window* _pWindow, const GrantAccess& )
+ {
+ if ( m_bClipboardOwner )
+ { // simulate a lostOwnership to notify parties interested in
+ if ( m_aClipboardListener.IsSet() )
+ m_aClipboardListener.Call( this );
+ }
+
+ m_bClipboardOwner = sal_True;
+ CopyToClipboard( _pWindow );
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchange::clear()
+ {
+ if ( isClipboardOwner() )
+ {
+ try
+ {
+ Reference< clipboard::XClipboard > xClipBoard( getOwnClipboard() );
+ if ( xClipBoard.is() )
+ xClipBoard->setContents( NULL, NULL );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_bClipboardOwner = sal_False;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OLocalExchange::lostOwnership( const Reference< clipboard::XClipboard >& _rxClipboard, const Reference< XTransferable >& _rxTrans ) throw(RuntimeException)
+ {
+ TransferableHelper::implCallOwnLostOwnership( _rxClipboard, _rxTrans );
+ m_bClipboardOwner = sal_False;
+
+ if ( m_aClipboardListener.IsSet() )
+ m_aClipboardListener.Call( this );
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchange::startDrag( Window* _pWindow, sal_Int8 _nDragSourceActions, const GrantAccess& )
+ {
+ m_bDragging = sal_True;
+ StartDrag( _pWindow, _nDragSourceActions );
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchange::DragFinished( sal_Int8 nDropAction )
+ {
+ TransferableHelper::DragFinished( nDropAction );
+ m_bDragging = sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OLocalExchange::hasFormat( const DataFlavorExVector& _rFormats, sal_uInt32 _nFormatId )
+ {
+ DataFlavorExVector::const_iterator aSearch;
+
+ for ( aSearch = _rFormats.begin(); aSearch != _rFormats.end(); ++aSearch )
+ if ( aSearch->mnSotId == _nFormatId )
+ break;
+
+ return aSearch != _rFormats.end();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OLocalExchange::GetData( const ::com::sun::star::datatransfer::DataFlavor& /*_rFlavor*/ )
+ {
+ return sal_False; // do not have any formats by default
+ }
+
+ //====================================================================
+ //= OControlTransferData
+ //====================================================================
+ //--------------------------------------------------------------------
+ OControlTransferData::OControlTransferData( )
+ :m_pFocusEntry( NULL )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ OControlTransferData::OControlTransferData( const Reference< XTransferable >& _rxTransferable )
+ :m_pFocusEntry( NULL )
+ {
+ TransferableDataHelper aExchangedData( _rxTransferable );
+
+ // try the formats we know
+ if ( OControlExchange::hasControlPathFormat( aExchangedData.GetDataFlavorExVector() ) )
+ { // paths to the controls, relative to a root
+ Sequence< Any > aControlPathData;
+ if ( aExchangedData.GetAny( OControlExchange::getControlPathFormatId() ) >>= aControlPathData )
+ {
+ DBG_ASSERT( aControlPathData.getLength() >= 2, "OControlTransferData::OControlTransferData: invalid data for the control path format!" );
+ if ( aControlPathData.getLength() >= 2 )
+ {
+ aControlPathData[0] >>= m_xFormsRoot;
+ aControlPathData[1] >>= m_aControlPaths;
+ }
+ }
+ else
+ {
+ DBG_ERROR( "OControlTransferData::OControlTransferData: invalid data for the control path format (2)!" );
+ }
+ }
+ if ( OControlExchange::hasHiddenControlModelsFormat( aExchangedData.GetDataFlavorExVector() ) )
+ { // sequence of models of hidden controls
+ aExchangedData.GetAny( OControlExchange::getHiddenControlModelsFormatId() ) >>= m_aHiddenControlModels;
+ }
+
+ updateFormats( );
+ }
+
+ //--------------------------------------------------------------------
+ static sal_Bool lcl_fillDataFlavorEx( SotFormatStringId nId, DataFlavorEx& _rFlavor )
+ {
+ _rFlavor.mnSotId = nId;
+ return SotExchange::GetFormatDataFlavor( _rFlavor.mnSotId, _rFlavor );
+ }
+
+ //--------------------------------------------------------------------
+ void OControlTransferData::updateFormats( )
+ {
+ m_aCurrentFormats.clear();
+ m_aCurrentFormats.reserve( 3 );
+
+ DataFlavorEx aFlavor;
+
+ if ( m_aHiddenControlModels.getLength() )
+ {
+ if ( lcl_fillDataFlavorEx( OControlExchange::getHiddenControlModelsFormatId(), aFlavor ) )
+ m_aCurrentFormats.push_back( aFlavor );
+ }
+
+ if ( m_xFormsRoot.is() && m_aControlPaths.getLength() )
+ {
+ if ( lcl_fillDataFlavorEx( OControlExchange::getControlPathFormatId(), aFlavor ) )
+ m_aCurrentFormats.push_back( aFlavor );
+ }
+
+ if ( !m_aSelectedEntries.empty() )
+ {
+ if ( lcl_fillDataFlavorEx( OControlExchange::getFieldExchangeFormatId(), aFlavor ) )
+ m_aCurrentFormats.push_back( aFlavor );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ size_t OControlTransferData::onEntryRemoved( SvLBoxEntry* _pEntry )
+ {
+ m_aSelectedEntries.erase( _pEntry );
+ return m_aSelectedEntries.size();
+ }
+
+ //--------------------------------------------------------------------
+ void OControlTransferData::addSelectedEntry( SvLBoxEntry* _pEntry )
+ {
+ m_aSelectedEntries.insert( _pEntry );
+ }
+
+ //--------------------------------------------------------------------
+ void OControlTransferData::setFocusEntry( SvLBoxEntry* _pFocusEntry )
+ {
+ m_pFocusEntry = _pFocusEntry;
+ }
+
+ //------------------------------------------------------------------------
+ void OControlTransferData::addHiddenControlsFormat(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqInterfaces)
+ {
+ m_aHiddenControlModels = seqInterfaces;
+ }
+
+ //------------------------------------------------------------------------
+ void OControlTransferData::buildPathFormat(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot)
+ {
+ m_aControlPaths.realloc(0);
+
+ sal_Int32 nEntryCount = m_aSelectedEntries.size();
+ if (nEntryCount == 0)
+ return;
+
+ m_aControlPaths.realloc(nEntryCount);
+ ::com::sun::star::uno::Sequence<sal_uInt32>* pAllPaths = m_aControlPaths.getArray();
+ for ( ListBoxEntrySet::const_iterator loop = m_aSelectedEntries.begin();
+ loop != m_aSelectedEntries.end();
+ ++loop, ++pAllPaths
+ )
+ {
+ // erst mal sammeln wir den Pfad in einem Array ein
+ ::std::vector< sal_uInt32 > aCurrentPath;
+ SvLBoxEntry* pCurrentEntry = *loop;
+
+ SvLBoxEntry* pLoop = pCurrentEntry;
+ while (pLoop != pRoot)
+ {
+ aCurrentPath.push_back(pLoop->GetChildListPos());
+ pLoop = pTreeBox->GetParent(pLoop);
+ DBG_ASSERT((pLoop != NULL) || (pRoot == 0), "OControlTransferData::buildPathFormat: invalid root or entry !");
+ // pLoop == NULL heisst, dass ich am oberen Ende angelangt bin, dann sollte das Ganze abbrechen, was nur bei pRoot == NULL der Fall sein wird
+ }
+
+ // dann koennen wir ihn in die ::com::sun::star::uno::Sequence uebertragen
+ Sequence<sal_uInt32>& rCurrentPath = *pAllPaths;
+ sal_Int32 nDepth = aCurrentPath.size();
+
+ rCurrentPath.realloc(nDepth);
+ sal_uInt32* pSeq = rCurrentPath.getArray();
+ sal_Int32 j,k;
+ for (j = nDepth - 1, k = 0; k<nDepth; --j, ++k)
+ pSeq[j] = aCurrentPath[k];
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OControlTransferData::buildListFromPath(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot)
+ {
+ ListBoxEntrySet aEmpty;
+ m_aSelectedEntries.swap( aEmpty );
+
+ sal_Int32 nControls = m_aControlPaths.getLength();
+ const ::com::sun::star::uno::Sequence<sal_uInt32>* pPaths = m_aControlPaths.getConstArray();
+ for (sal_Int32 i=0; i<nControls; ++i)
+ {
+ sal_Int32 nThisPatLength = pPaths[i].getLength();
+ const sal_uInt32* pThisPath = pPaths[i].getConstArray();
+ SvLBoxEntry* pSearch = pRoot;
+ for (sal_Int32 j=0; j<nThisPatLength; ++j)
+ pSearch = pTreeBox->GetEntry(pSearch, pThisPath[j]);
+
+ m_aSelectedEntries.insert( pSearch );
+ }
+ }
+
+ //====================================================================
+ //= OControlExchange
+ //====================================================================
+ //--------------------------------------------------------------------
+ OControlExchange::OControlExchange( )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool OControlExchange::GetData( const DataFlavor& _rFlavor )
+ {
+ const sal_uInt32 nFormatId = SotExchange::GetFormat( _rFlavor );
+
+ if ( getControlPathFormatId( ) == nFormatId )
+ {
+ // ugly. We have to pack all the info into one object
+ Sequence< Any > aCompleteInfo( 2 );
+ OSL_ENSURE( m_xFormsRoot.is(), "OLocalExchange::GetData: invalid forms root for this format!" );
+ aCompleteInfo.getArray()[ 0 ] <<= m_xFormsRoot;
+ aCompleteInfo.getArray()[ 1 ] <<= m_aControlPaths;
+
+ SetAny( makeAny( aCompleteInfo ), _rFlavor );
+ }
+ else if ( getHiddenControlModelsFormatId() == nFormatId )
+ {
+ // just need to transfer the models
+ SetAny( makeAny( m_aHiddenControlModels ), _rFlavor );
+ }
+ else
+ return OLocalExchange::GetData( _rFlavor );
+
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ void OControlExchange::AddSupportedFormats()
+ {
+ if (m_pFocusEntry && !m_aSelectedEntries.empty())
+ AddFormat(getFieldExchangeFormatId());
+
+ if (m_aControlPaths.getLength())
+ AddFormat(getControlPathFormatId());
+
+ if (m_aHiddenControlModels.getLength())
+ AddFormat(getHiddenControlModelsFormatId());
+ }
+
+ //--------------------------------------------------------------------
+ sal_uInt32 OControlExchange::getControlPathFormatId()
+ {
+ static sal_uInt32 s_nFormat = (sal_uInt32)-1;
+ if ((sal_uInt32)-1 == s_nFormat)
+ {
+ s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"svxform.ControlPathExchange\""));
+ DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OControlExchange::getControlPathFormatId: bad exchange id!");
+ }
+ return s_nFormat;
+ }
+
+ //--------------------------------------------------------------------
+ sal_uInt32 OControlExchange::getHiddenControlModelsFormatId()
+ {
+ static sal_uInt32 s_nFormat = (sal_uInt32)-1;
+ if ((sal_uInt32)-1 == s_nFormat)
+ {
+ s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"svxform.HiddenControlModelsExchange\""));
+ DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OControlExchange::getHiddenControlModelsFormatId: bad exchange id!");
+ }
+ return s_nFormat;
+ }
+
+ //--------------------------------------------------------------------
+ sal_uInt32 OControlExchange::getFieldExchangeFormatId()
+ {
+ static sal_uInt32 s_nFormat = (sal_uInt32)-1;
+ if ((sal_uInt32)-1 == s_nFormat)
+ {
+ s_nFormat = SotExchange::RegisterFormatName(String::CreateFromAscii("application/x-openoffice;windows_formatname=\"svxform.FieldNameExchange\""));
+ DBG_ASSERT((sal_uInt32)-1 != s_nFormat, "OControlExchange::getFieldExchangeFormatId: bad exchange id!");
+ }
+ return s_nFormat;
+ }
+
+ //====================================================================
+ //= OControlExchangeHelper
+ //====================================================================
+ OLocalExchange* OControlExchangeHelper::createExchange() const
+ {
+ return new OControlExchange;
+ }
+
+ //====================================================================
+ //= OLocalExchangeHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ OLocalExchangeHelper::OLocalExchangeHelper(Window* _pDragSource)
+ :m_pDragSource(_pDragSource)
+ ,m_pTransferable(NULL)
+ {
+ }
+
+ //--------------------------------------------------------------------
+ OLocalExchangeHelper::~OLocalExchangeHelper()
+ {
+ implReset();
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchangeHelper::startDrag( sal_Int8 nDragSourceActions )
+ {
+ DBG_ASSERT(m_pTransferable, "OLocalExchangeHelper::startDrag: not prepared!");
+ m_pTransferable->startDrag( m_pDragSource, nDragSourceActions, OLocalExchange::GrantAccess() );
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchangeHelper::copyToClipboard( ) const
+ {
+ DBG_ASSERT( m_pTransferable, "OLocalExchangeHelper::copyToClipboard: not prepared!" );
+ m_pTransferable->copyToClipboard( m_pDragSource, OLocalExchange::GrantAccess() );
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchangeHelper::implReset()
+ {
+ if (m_pTransferable)
+ {
+ m_pTransferable->setClipboardListener( Link() );
+ m_pTransferable->release();
+ m_pTransferable = NULL;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void OLocalExchangeHelper::prepareDrag( )
+ {
+ DBG_ASSERT(!m_pTransferable || !m_pTransferable->isDragging(), "OLocalExchangeHelper::prepareDrag: recursive DnD?");
+
+ implReset();
+ m_pTransferable = createExchange();
+ m_pTransferable->acquire();
+ }
+
+//........................................................................
+}
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmexpl.cxx b/svx/source/form/fmexpl.cxx
new file mode 100644
index 000000000000..82fc2d224174
--- /dev/null
+++ b/svx/source/form/fmexpl.cxx
@@ -0,0 +1,698 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmresids.hrc"
+#include "fmexpl.hrc"
+#include "fmexpl.hxx"
+
+#include "fmhelp.hrc"
+#include <svx/fmglob.hxx>
+#include "fmservs.hxx"
+#include <svx/fmmodel.hxx>
+#include "fmexch.hxx"
+#include "fmundo.hxx"
+#include "fmpgeimp.hxx"
+
+#include <svx/svxids.hrc>
+
+#include "fmprop.hrc"
+#include <svx/dialmgr.hxx>
+#include "svditer.hxx"
+#include <svx/svdouno.hxx>
+#include <fmundo.hxx>
+#include <svx/svdobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <vcl/menu.hxx>
+#include <sfx2/objitem.hxx>
+#include <sfx2/request.hxx>
+#include <tools/shl.hxx>
+
+#include <vcl/wrkwin.hxx>
+#include <vcl/sound.hxx>
+#include <svx/fmshell.hxx>
+#include "fmshimp.hxx"
+#include <svx/fmpage.hxx>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <comphelper/property.hxx>
+#include <comphelper/processfactory.hxx>
+#include <osl/diagnose.h>
+#include <rtl/logfile.hxx>
+
+using namespace ::svxform;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+
+//========================================================================
+
+SV_IMPL_PTRARR_SORT( FmEntryDataArray, FmEntryDataPtr )
+SV_IMPL_PTRARR_SORT( SvLBoxEntrySortedArray, SvLBoxEntryPtr )
+
+//========================================================================
+// class FmNavInsertedHint
+//========================================================================
+TYPEINIT1( FmNavInsertedHint, SfxHint );
+DBG_NAME(FmNavInsertedHint);
+//------------------------------------------------------------------------
+FmNavInsertedHint::FmNavInsertedHint( FmEntryData* pInsertedEntryData, sal_uInt32 nRelPos )
+ :pEntryData( pInsertedEntryData )
+ ,nPos( nRelPos )
+
+{
+ DBG_CTOR(FmNavInsertedHint,NULL);
+}
+
+//------------------------------------------------------------------------
+FmNavInsertedHint::~FmNavInsertedHint()
+{
+ DBG_DTOR(FmNavInsertedHint,NULL);
+}
+
+
+//========================================================================
+// class FmNavInsertedHint
+//========================================================================
+TYPEINIT1( FmNavModelReplacedHint, SfxHint );
+DBG_NAME(FmNavModelReplacedHint);
+//------------------------------------------------------------------------
+FmNavModelReplacedHint::FmNavModelReplacedHint( FmEntryData* pAffectedEntryData )
+ :pEntryData( pAffectedEntryData )
+{
+ DBG_CTOR(FmNavModelReplacedHint,NULL);
+}
+
+//------------------------------------------------------------------------
+FmNavModelReplacedHint::~FmNavModelReplacedHint()
+{
+ DBG_DTOR(FmNavModelReplacedHint,NULL);
+}
+
+//========================================================================
+// class FmNavRemovedHint
+//========================================================================
+TYPEINIT1( FmNavRemovedHint, SfxHint );
+DBG_NAME(FmNavRemovedHint);
+//------------------------------------------------------------------------
+FmNavRemovedHint::FmNavRemovedHint( FmEntryData* pRemovedEntryData )
+ :pEntryData( pRemovedEntryData )
+{
+ DBG_CTOR(FmNavRemovedHint,NULL);
+}
+
+//------------------------------------------------------------------------
+FmNavRemovedHint::~FmNavRemovedHint()
+{
+ DBG_DTOR(FmNavRemovedHint,NULL);
+}
+
+
+//========================================================================
+// class FmNavNameChangedHint
+//========================================================================
+TYPEINIT1( FmNavNameChangedHint, SfxHint );
+DBG_NAME(FmNavNameChangedHint);
+//------------------------------------------------------------------------
+FmNavNameChangedHint::FmNavNameChangedHint( FmEntryData* pData, const ::rtl::OUString& rNewName )
+ :pEntryData( pData )
+ ,aNewName( rNewName )
+{
+ DBG_CTOR(FmNavNameChangedHint,NULL);
+}
+
+//------------------------------------------------------------------------
+FmNavNameChangedHint::~FmNavNameChangedHint()
+{
+ DBG_DTOR(FmNavNameChangedHint,NULL);
+}
+
+//========================================================================
+// class FmNavClearedHint
+//========================================================================
+TYPEINIT1( FmNavClearedHint, SfxHint );
+DBG_NAME(FmNavClearedHint);
+//------------------------------------------------------------------------
+FmNavClearedHint::FmNavClearedHint()
+{
+ DBG_CTOR(FmNavClearedHint,NULL);
+}
+
+//------------------------------------------------------------------------
+FmNavClearedHint::~FmNavClearedHint()
+{
+ DBG_DTOR(FmNavClearedHint,NULL);
+}
+
+//========================================================================
+// class FmNavRequestSelectHint
+//========================================================================
+TYPEINIT1(FmNavRequestSelectHint, SfxHint);
+
+//========================================================================
+// class FmNavViewMarksChanged
+//========================================================================
+TYPEINIT1(FmNavViewMarksChanged, SfxHint);
+
+//========================================================================
+// class FmEntryDataList
+//========================================================================
+DBG_NAME(FmEntryDataList);
+//------------------------------------------------------------------------
+FmEntryDataList::FmEntryDataList()
+{
+ DBG_CTOR(FmEntryDataList,NULL);
+}
+
+//------------------------------------------------------------------------
+FmEntryDataList::~FmEntryDataList()
+{
+ DBG_DTOR(FmEntryDataList,NULL);
+}
+
+
+//========================================================================
+// class FmEntryData
+//========================================================================
+TYPEINIT0( FmEntryData );
+DBG_NAME(FmEntryData);
+//------------------------------------------------------------------------
+FmEntryData::FmEntryData( FmEntryData* pParentData, const Reference< XInterface >& _rxIFace )
+ :pParent( pParentData )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmEntryData::FmEntryData" );
+ DBG_CTOR(FmEntryData,NULL);
+ pChildList = new FmEntryDataList();
+
+ newObject( _rxIFace );
+}
+
+//------------------------------------------------------------------------
+FmEntryData::~FmEntryData()
+{
+ Clear();
+ delete pChildList;
+ DBG_DTOR(FmEntryData,NULL);
+}
+
+//------------------------------------------------------------------------
+void FmEntryData::newObject( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIFace )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmEntryData::newObject" );
+ // do not just copy, normalize it
+ m_xNormalizedIFace = Reference< XInterface >( _rxIFace, UNO_QUERY );
+ m_xProperties = m_xProperties.query( m_xNormalizedIFace );
+ m_xChild = m_xChild.query( m_xNormalizedIFace );
+}
+
+//------------------------------------------------------------------------
+FmEntryData::FmEntryData( const FmEntryData& rEntryData )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmEntryData::FmEntryData" );
+ pChildList = new FmEntryDataList();
+ aText = rEntryData.GetText();
+ m_aNormalImage = rEntryData.GetNormalImage();
+ m_aHCImage = rEntryData.GetHCImage();
+ pParent = rEntryData.GetParent();
+
+ FmEntryData* pChildData;
+ sal_uInt32 nEntryCount = rEntryData.GetChildList()->Count();
+ for( sal_uInt32 i=0; i<nEntryCount; i++ )
+ {
+ pChildData = rEntryData.GetChildList()->GetObject(i);
+ FmEntryData* pNewChildData = pChildData->Clone();
+ pChildList->Insert( pNewChildData, LIST_APPEND );
+ }
+
+ m_xNormalizedIFace = rEntryData.m_xNormalizedIFace;
+ m_xProperties = rEntryData.m_xProperties;
+ m_xChild = rEntryData.m_xChild;
+}
+
+//------------------------------------------------------------------------
+void FmEntryData::Clear()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmEntryData::Clear" );
+ for (;;)
+ {
+ FmEntryData* pEntryData = GetChildList()->Remove(ULONG(0));
+ if (pEntryData == NULL)
+ break;
+ delete pEntryData;
+ }
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmEntryData::IsEqualWithoutChilds( FmEntryData* pEntryData )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmEntryData::IsEqualWithoutChilds" );
+ if(this == pEntryData)
+ return sal_True;
+
+ if( !pEntryData )
+ return sal_False;
+
+ if( !aText.equals(pEntryData->GetText()))
+ return sal_False;
+
+ if( !pEntryData->GetParent() && pParent )
+ return sal_False;
+
+ if( pEntryData->GetParent() && !pParent )
+ return sal_False;
+
+ if( !pEntryData->GetParent() && !pParent )
+ return sal_True;
+
+ if( !pParent->IsEqualWithoutChilds(pEntryData->GetParent()) )
+ return sal_False;
+
+ return sal_True;
+}
+
+
+//========================================================================
+// class FmFormData
+//========================================================================
+TYPEINIT1( FmFormData, FmEntryData );
+DBG_NAME(FmFormData);
+//------------------------------------------------------------------------
+FmFormData::FmFormData( const Reference< XForm >& _rxForm, const ImageList& _rNormalImages, const ImageList& _rHCImages, FmFormData* _pParent )
+ :FmEntryData( _pParent, _rxForm )
+ ,m_xForm( _rxForm )
+{
+ DBG_CTOR(FmEntryData,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Images setzen
+
+ m_aNormalImage = _rNormalImages.GetImage( RID_SVXIMG_FORM );
+ m_aHCImage = _rHCImages.GetImage( RID_SVXIMG_FORM );
+
+ //////////////////////////////////////////////////////////////////////
+ // Titel setzen
+ if (m_xForm.is())
+ {
+ Reference< XPropertySet > xSet(m_xForm, UNO_QUERY);
+ if (xSet.is())
+ {
+ ::rtl::OUString aEntryName(::comphelper::getString(xSet->getPropertyValue( FM_PROP_NAME )));
+ SetText(aEntryName);
+ }
+ }
+ else
+ SetText( ::rtl::OUString() );
+}
+
+//------------------------------------------------------------------------
+FmFormData::~FmFormData()
+{
+ DBG_DTOR(FmEntryData,NULL);
+}
+
+//------------------------------------------------------------------------
+FmFormData::FmFormData( const FmFormData& rFormData )
+ :FmEntryData( rFormData )
+{
+ DBG_CTOR(FmEntryData,NULL);
+ m_xForm = rFormData.GetFormIface();
+}
+
+//------------------------------------------------------------------------
+FmEntryData* FmFormData::Clone()
+{
+ return new FmFormData( *this );
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmFormData::IsEqualWithoutChilds( FmEntryData* pEntryData )
+{
+ if(this == pEntryData)
+ return sal_True;
+ if( !pEntryData->ISA(FmFormData) )
+ return sal_False;
+ FmFormData* pFormData = (FmFormData*)pEntryData;
+ if( (XForm*)m_xForm.get() != (XForm*)pFormData->GetFormIface().get() )
+ return sal_False;
+
+ return FmEntryData::IsEqualWithoutChilds( pFormData );
+}
+
+
+//========================================================================
+// class FmControlData
+//========================================================================
+TYPEINIT1( FmControlData, FmEntryData );
+DBG_NAME(FmControlData);
+//------------------------------------------------------------------------
+FmControlData::FmControlData( const Reference< XFormComponent >& _rxComponent, const ImageList& _rNormalImages, const ImageList& _rHCImages, FmFormData* _pParent )
+ :FmEntryData( _pParent, _rxComponent )
+ ,m_xFormComponent( _rxComponent )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmControlData::FmControlData" );
+ DBG_CTOR(FmControlData,NULL);
+ //////////////////////////////////////////////////////////////////////
+ // Images setzen
+ m_aNormalImage = GetImage( _rNormalImages );
+ m_aHCImage = GetImage( _rHCImages );
+
+ //////////////////////////////////////////////////////////////////////
+ // Titel setzen
+ Reference< XPropertySet > xSet(m_xFormComponent, UNO_QUERY);
+ if( xSet.is() )
+ {
+#ifdef DBG_UTIL
+ ::rtl::OUString aEntryName = ::comphelper::getString(xSet->getPropertyValue( FM_PROP_NAME ));
+#endif
+ SetText( ::comphelper::getString(xSet->getPropertyValue( FM_PROP_NAME )));
+ }
+}
+
+//------------------------------------------------------------------------
+FmControlData::~FmControlData()
+{
+ DBG_DTOR(FmControlData,NULL);
+}
+
+//------------------------------------------------------------------------
+FmControlData::FmControlData( const FmControlData& rControlData )
+ :FmEntryData( rControlData )
+{
+ DBG_CTOR(FmControlData,NULL);
+ m_xFormComponent = rControlData.GetFormComponent();
+}
+
+//------------------------------------------------------------------------
+FmEntryData* FmControlData::Clone()
+{
+ return new FmControlData( *this );
+}
+
+//------------------------------------------------------------------------
+Image FmControlData::GetImage(const ImageList& ilNavigatorImages) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmControlData::FmControlData" );
+ //////////////////////////////////////////////////////////////////////
+ // Default-Image
+ Image aImage = ilNavigatorImages.GetImage( RID_SVXIMG_CONTROL );
+
+ Reference< XServiceInfo > xInfo( m_xFormComponent, UNO_QUERY );
+ if (!m_xFormComponent.is())
+ return aImage;
+
+ //////////////////////////////////////////////////////////////////////
+ // Spezielle Control-Images
+ sal_Int16 nObjectType = getControlTypeByObject(xInfo);
+ switch (nObjectType)
+ {
+ case OBJ_FM_BUTTON:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_BUTTON );
+ break;
+
+ case OBJ_FM_FIXEDTEXT:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_FIXEDTEXT );
+ break;
+
+ case OBJ_FM_EDIT:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_EDIT );
+ break;
+
+ case OBJ_FM_RADIOBUTTON:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_RADIOBUTTON );
+ break;
+
+ case OBJ_FM_CHECKBOX:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_CHECKBOX );
+ break;
+
+ case OBJ_FM_LISTBOX:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_LISTBOX );
+ break;
+
+ case OBJ_FM_COMBOBOX:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_COMBOBOX );
+ break;
+
+ case OBJ_FM_NAVIGATIONBAR:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_NAVIGATIONBAR );
+ break;
+
+ case OBJ_FM_GROUPBOX:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_GROUPBOX );
+ break;
+
+ case OBJ_FM_IMAGEBUTTON:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_IMAGEBUTTON );
+ break;
+
+ case OBJ_FM_FILECONTROL:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_FILECONTROL );
+ break;
+
+ case OBJ_FM_HIDDEN:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_HIDDEN );
+ break;
+
+ case OBJ_FM_DATEFIELD:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_DATEFIELD );
+ break;
+
+ case OBJ_FM_TIMEFIELD:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_TIMEFIELD );
+ break;
+
+ case OBJ_FM_NUMERICFIELD:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_NUMERICFIELD );
+ break;
+
+ case OBJ_FM_CURRENCYFIELD:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_CURRENCYFIELD );
+ break;
+
+ case OBJ_FM_PATTERNFIELD:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_PATTERNFIELD );
+ break;
+
+ case OBJ_FM_IMAGECONTROL:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_IMAGECONTROL );
+ break;
+
+ case OBJ_FM_FORMATTEDFIELD:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_FORMATTEDFIELD );
+ break;
+
+ case OBJ_FM_GRID:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_GRID );
+ break;
+
+ case OBJ_FM_SCROLLBAR:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_SCROLLBAR );
+ break;
+
+ case OBJ_FM_SPINBUTTON:
+ aImage = ilNavigatorImages.GetImage( RID_SVXIMG_SPINBUTTON);
+ break;
+ }
+
+ return aImage;
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmControlData::IsEqualWithoutChilds( FmEntryData* pEntryData )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmControlData::IsEqualWithoutChilds" );
+ if(this == pEntryData)
+ return sal_True;
+
+ if( !pEntryData->ISA(FmControlData) )
+ return sal_False;
+ FmControlData* pControlData = (FmControlData*)pEntryData;
+
+ if( (XFormComponent*)m_xFormComponent.get() != (XFormComponent*)pControlData->GetFormComponent().get() )
+ return sal_False;
+
+ return FmEntryData::IsEqualWithoutChilds( pControlData );
+}
+
+//------------------------------------------------------------------------
+void FmControlData::ModelReplaced( const Reference< XFormComponent >& _rxNew, const ImageList& _rNormalImages, const ImageList& _rHCImages )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmControlData::ModelReplaced" );
+ m_xFormComponent = _rxNew;
+ newObject( m_xFormComponent );
+
+ // Images neu setzen
+ m_aNormalImage = GetImage( _rNormalImages );
+ m_aHCImage = GetImage( _rHCImages );
+}
+
+//............................................................................
+namespace svxform
+{
+//............................................................................
+
+ //========================================================================
+ // class NavigatorFrame
+ //========================================================================
+ DBG_NAME(NavigatorFrame)
+ //------------------------------------------------------------------------
+ NavigatorFrame::NavigatorFrame( SfxBindings* _pBindings, SfxChildWindow* _pMgr,
+ Window* _pParent )
+ :SfxDockingWindow( _pBindings, _pMgr, _pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_ROLLABLE|WB_3DLOOK|WB_DOCKABLE) )
+ ,SfxControllerItem( SID_FM_FMEXPLORER_CONTROL, *_pBindings )
+ {
+ DBG_CTOR(NavigatorFrame,NULL);
+ SetHelpId( HID_FORM_NAVIGATOR_WIN );
+
+ m_pNavigatorTree = new NavigatorTree(comphelper::getProcessServiceFactory(), this );
+ m_pNavigatorTree->Show();
+ SetText( SVX_RES(RID_STR_FMEXPLORER) );
+ SfxDockingWindow::SetFloatingSize( Size(200,200) );
+ }
+
+ //------------------------------------------------------------------------
+ NavigatorFrame::~NavigatorFrame()
+ {
+ delete m_pNavigatorTree;
+ DBG_DTOR(NavigatorFrame,NULL);
+ }
+
+ //-----------------------------------------------------------------------
+ void NavigatorFrame::UpdateContent( FmFormShell* pFormShell )
+ {
+ m_pNavigatorTree->UpdateContent( pFormShell );
+ }
+
+ //-----------------------------------------------------------------------
+ void NavigatorFrame::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState )
+ {
+ if( !pState || SID_FM_FMEXPLORER_CONTROL != nSID )
+ return;
+
+ if( eState >= SFX_ITEM_AVAILABLE )
+ {
+ FmFormShell* pShell = PTR_CAST( FmFormShell,((SfxObjectItem*)pState)->GetShell() );
+ UpdateContent( pShell );
+ }
+ else
+ UpdateContent( NULL );
+ }
+
+ //-----------------------------------------------------------------------
+ void NavigatorFrame::GetFocus()
+ {
+ if ( m_pNavigatorTree )
+ m_pNavigatorTree->GrabFocus();
+ else
+ SfxDockingWindow::GetFocus();
+ }
+
+ //-----------------------------------------------------------------------
+ sal_Bool NavigatorFrame::Close()
+ {
+ UpdateContent( NULL );
+ return SfxDockingWindow::Close();
+ }
+
+ //-----------------------------------------------------------------------
+ void NavigatorFrame::FillInfo( SfxChildWinInfo& rInfo ) const
+ {
+ SfxDockingWindow::FillInfo( rInfo );
+ rInfo.bVisible = sal_False;
+ }
+
+ //-----------------------------------------------------------------------
+ Size NavigatorFrame::CalcDockingSize( SfxChildAlignment eAlign )
+ {
+ if ( ( eAlign == SFX_ALIGN_TOP ) || ( eAlign == SFX_ALIGN_BOTTOM ) )
+ return Size();
+
+ return SfxDockingWindow::CalcDockingSize( eAlign );
+ }
+
+ //-----------------------------------------------------------------------
+ SfxChildAlignment NavigatorFrame::CheckAlignment( SfxChildAlignment _eActAlign, SfxChildAlignment _eAlign )
+ {
+ if ( ( _eAlign == SFX_ALIGN_LEFT ) || ( _eAlign == SFX_ALIGN_RIGHT ) || ( _eAlign == SFX_ALIGN_NOALIGNMENT ) )
+ return _eAlign;
+ return _eActAlign;
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorFrame::Resize()
+ {
+ SfxDockingWindow::Resize();
+
+ Size aLogOutputSize = PixelToLogic( GetOutputSizePixel(), MAP_APPFONT );
+ Size aLogExplSize = aLogOutputSize;
+ aLogExplSize.Width() -= 6;
+ aLogExplSize.Height() -= 6;
+
+ Point aExplPos = LogicToPixel( Point(3,3), MAP_APPFONT );
+ Size aExplSize = LogicToPixel( aLogExplSize, MAP_APPFONT );
+
+ m_pNavigatorTree->SetPosSizePixel( aExplPos, aExplSize );
+ }
+
+
+ //========================================================================
+ // class NavigatorFrameManager
+ //========================================================================
+
+ //-----------------------------------------------------------------------
+ SFX_IMPL_DOCKINGWINDOW( NavigatorFrameManager, SID_FM_SHOW_FMEXPLORER )
+
+ //-----------------------------------------------------------------------
+ NavigatorFrameManager::NavigatorFrameManager( Window* _pParent, sal_uInt16 _nId,
+ SfxBindings* _pBindings, SfxChildWinInfo* _pInfo )
+ :SfxChildWindow( _pParent, _nId )
+ {
+ pWindow = new NavigatorFrame( _pBindings, this, _pParent );
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+ ((SfxDockingWindow*)pWindow)->Initialize( _pInfo );
+ }
+
+//............................................................................
+} // namespace svxform
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmexpl.src b/svx/source/form/fmexpl.src
new file mode 100644
index 000000000000..218df02f07af
--- /dev/null
+++ b/svx/source/form/fmexpl.src
@@ -0,0 +1,378 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/svxids.hrc>
+#include "fmresids.hrc"
+#include "fmexpl.hrc"
+#include "globlmn.hrc"
+Menu RID_FMEXPLORER_POPUPMENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_FM_NEW ;
+ HelpID = SID_FM_NEW ;
+ Text [ en-US ] = "~New" ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_FM_NEW_FORM ;
+ HelpID = SID_FM_NEW_FORM ;
+ Text [ en-US ] = "Form" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_NEW_HIDDEN ;
+ HelpID = SID_FM_NEW_HIDDEN ;
+ Text [ en-US ] = "Hidden Control" ;
+ };
+ };
+ };
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CHANGECONTROLTYPE ;
+ HelpID = SID_FM_CHANGECONTROLTYPE ;
+ Text [ en-US ] = "Replace with";
+ };
+ MenuItem { ITEM_EDIT_CUT };
+ MenuItem { ITEM_EDIT_COPY };
+ MenuItem { ITEM_EDIT_PASTE };
+ MenuItem
+ {
+ Identifier = SID_FM_DELETE ;
+ HelpID = SID_FM_DELETE ;
+ Text [ en-US ] = "~Delete" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_TAB_DIALOG ;
+ HelpID = SID_FM_TAB_DIALOG ;
+ Text [ en-US ] = "Tab Order..." ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_RENAME_OBJECT ;
+ HelpID = SID_FM_RENAME_OBJECT ;
+ Text [ en-US ] = "~Rename" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_SHOW_PROPERTY_BROWSER ;
+ HelpID = SID_FM_SHOW_PROPERTY_BROWSER ;
+ Text [ en-US ] = "Propert~ies" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_OPEN_READONLY ;
+ HelpID = SID_FM_OPEN_READONLY ;
+ Text [ en-US ] = "Open in Design Mode" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_AUTOCONTROLFOCUS ;
+ HelpID = SID_FM_AUTOCONTROLFOCUS ;
+ Text [ en-US ] = "Automatic Control Focus";
+ };
+ };
+};
+
+Menu RID_FMSHELL_CONVERSIONMENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_EDIT ;
+ HelpID = SID_FM_CONVERTTO_EDIT ;
+ Command = ".uno:ConvertToEdit" ;
+ Text [ en-US ] = "~Text Box";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_BUTTON ;
+ HelpID = SID_FM_CONVERTTO_BUTTON ;
+ Command = ".uno:ConvertToButton" ;
+ Text [ en-US ] = "~Button";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_FIXEDTEXT ;
+ HelpID = SID_FM_CONVERTTO_FIXEDTEXT ;
+ Command = ".uno:ConvertToFixed" ;
+ Text [ en-US ] = "La~bel field";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_GROUPBOX ;
+ HelpID = SID_FM_CONVERTTO_GROUPBOX ;
+ Command = ".uno:ConvertToGroup" ;
+ Text [ en-US ] = "G~roup Box";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_LISTBOX ;
+ HelpID = SID_FM_CONVERTTO_LISTBOX ;
+ Command = ".uno:ConvertToList" ;
+ Text [ en-US ] = "L~ist Box";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_CHECKBOX ;
+ HelpID = SID_FM_CONVERTTO_CHECKBOX ;
+ Command = ".uno:ConvertToCheckBox" ;
+ Text [ en-US ] = "~Check Box";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_RADIOBUTTON ;
+ HelpID = SID_FM_CONVERTTO_RADIOBUTTON ;
+ Command = ".uno:ConvertToRadio" ;
+ Text [ en-US ] = "~Radio Button";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_COMBOBOX ;
+ HelpID = SID_FM_CONVERTTO_COMBOBOX ;
+ Command = ".uno:ConvertToCombo" ;
+ Text [ en-US ] = "Combo Bo~x";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_IMAGEBUTTON ;
+ HelpID = SID_FM_CONVERTTO_IMAGEBUTTON ;
+ Command = ".uno:ConvertToImageBtn" ;
+ Text [ en-US ] = "I~mage Button";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_FILECONTROL ;
+ HelpID = SID_FM_CONVERTTO_FILECONTROL ;
+ Command = ".uno:ConvertToFileControl" ;
+ Text [ en-US ] = "~File Selection";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_DATE ;
+ HelpID = SID_FM_CONVERTTO_DATE ;
+ Command = ".uno:ConvertToDate" ;
+ Text [ en-US ] = "~Date Field";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_TIME ;
+ HelpID = SID_FM_CONVERTTO_TIME ;
+ Command = ".uno:ConvertToTime" ;
+ Text [ en-US ] = "Tim~e Field";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_NUMERIC ;
+ HelpID = SID_FM_CONVERTTO_NUMERIC ;
+ Command = ".uno:ConvertToNumeric" ;
+ Text [ en-US ] = "~Numerical Field";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_CURRENCY ;
+ HelpID = SID_FM_CONVERTTO_CURRENCY ;
+ Command = ".uno:ConvertToCurrency" ;
+ Text [ en-US ] = "C~urrency Field";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_PATTERN ;
+ HelpID = SID_FM_CONVERTTO_PATTERN ;
+ Command = ".uno:ConvertToPattern" ;
+ Text [ en-US ] = "~Pattern Field";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_IMAGECONTROL ;
+ HelpID = SID_FM_CONVERTTO_IMAGECONTROL ;
+ Command = ".uno:ConvertToImageControl" ;
+ Text [ en-US ] = "Ima~ge Control";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_FORMATTED ;
+ HelpID = SID_FM_CONVERTTO_FORMATTED ;
+ Command = ".uno:ConvertToFormatted" ;
+ Text [ en-US ] = "Fo~rmatted Field";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_SCROLLBAR ;
+ HelpID = SID_FM_CONVERTTO_SCROLLBAR ;
+ Command = ".uno:ConvertToScrollBar" ;
+ Text [ en-US ] = "Scroll bar";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_SPINBUTTON;
+ HelpID = SID_FM_CONVERTTO_SPINBUTTON;
+ Command = ".uno:ConvertToSpinButton" ;
+ Text [ en-US ] = "Spin Button";
+ };
+ MenuItem
+ {
+ Identifier = SID_FM_CONVERTTO_NAVIGATIONBAR;
+ HelpID = SID_FM_CONVERTTO_NAVIGATIONBAR;
+ Command = ".uno:ConvertToNavigationBar" ;
+ Text [ en-US ] = "Navigation Bar" ;
+ };
+ };
+};
+
+#define NAVIGATOR_IMAGEIDS \
+ IdList = \
+ { \
+ RID_SVXIMG_BUTTON ; \
+ RID_SVXIMG_RADIOBUTTON ; \
+ RID_SVXIMG_CHECKBOX ; \
+ RID_SVXIMG_FIXEDTEXT ; \
+ RID_SVXIMG_GROUPBOX ; \
+ RID_SVXIMG_EDIT ; \
+ RID_SVXIMG_LISTBOX ; \
+ RID_SVXIMG_COMBOBOX ; \
+ RID_SVXIMG_NAVIGATIONBAR ; \
+ RID_SVXIMG_CONTROL ; \
+ RID_SVXIMG_FORM ; \
+ RID_SVXIMG_FORMS ; \
+ RID_SVXIMG_COLLAPSEDNODE ; \
+ RID_SVXIMG_EXPANDEDNODE ; \
+ RID_SVXIMG_IMAGEBUTTON ; \
+ RID_SVXIMG_FILECONTROL ; \
+ RID_SVXIMG_DATEFIELD ; \
+ RID_SVXIMG_TIMEFIELD ; \
+ RID_SVXIMG_NUMERICFIELD ; \
+ RID_SVXIMG_CURRENCYFIELD ; \
+ RID_SVXIMG_PATTERNFIELD ; \
+ RID_SVXIMG_HIDDEN ; \
+ RID_SVXIMG_IMAGECONTROL ; \
+ RID_SVXIMG_GRID ; \
+ RID_SVXIMG_FILTER ; \
+ RID_SVXIMG_FORMATTEDFIELD ; \
+ RID_SVXIMG_DATE_N_TIME_FIELDS ; \
+ RID_SVXIMG_FIELD ; \
+ RID_SVXIMG_SCROLLBAR; \
+ RID_SVXIMG_SPINBUTTON; \
+ }; \
+ IdCount = 30
+
+ImageList RID_SVXIMGLIST_FMEXPL
+{
+ Prefix = "sx";
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+ NAVIGATOR_IMAGEIDS;
+};
+
+ImageList RID_SVXIMGLIST_FMEXPL_HC
+{
+ Prefix = "sxh";
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+ NAVIGATOR_IMAGEIDS;
+};
+
+ModalDialog RID_SVXDLG_SETFORM
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 200 , 200 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ GroupBox GB_PATH
+ {
+ Pos = MAP_APPFONT ( 6 , 149 ) ;
+ Size = MAP_APPFONT ( 188 , 25 ) ;
+ Text [ en-US ] = "Path" ;
+ };
+ FixedText FT_PATH
+ {
+ Pos = MAP_APPFONT ( 12 , 155 ) ;
+ Size = MAP_APPFONT ( 156 , 15 ) ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 6 , 180 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 59 , 180 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 123 , 180 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Select form" ;
+};
+DockingWindow RID_SVX_FMEXPLORER
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 200 , 200 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Text [ en-US ] = "Form Navigator" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/form/fmitems.cxx b/svx/source/form/fmitems.cxx
new file mode 100644
index 000000000000..bb7748e0013a
--- /dev/null
+++ b/svx/source/form/fmitems.cxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "fmitems.hxx"
+
+#include <svx/svxids.hrc>
+#include <tools/stream.hxx>
+
+//========================================================================
+// class FmInterfaceItem
+//========================================================================
+TYPEINIT1(FmInterfaceItem, SfxPoolItem);
+
+//------------------------------------------------------------------------------
+int FmInterfaceItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
+ return( xInterface == ((FmInterfaceItem&)rAttr).GetInterface() );
+}
+
+//------------------------------------------------------------------------------
+SfxPoolItem* FmInterfaceItem::Clone( SfxItemPool* ) const
+{
+ return new FmInterfaceItem( *this );
+}
+
+//------------------------------------------------------------------------------
+SvStream& FmInterfaceItem::Store( SvStream& rStrm , sal_uInt16 /*nItemVersion*/ ) const
+{
+ DBG_ERROR( "FmInterfaceItem::Store: not implemented!" );
+ return rStrm;
+}
+
+//------------------------------------------------------------------------------
+SfxPoolItem* FmInterfaceItem::Create( SvStream& /*rStrm*/, sal_uInt16 ) const
+{
+ DBG_ERROR( "FmInterfaceItem::Create: not implemented!" );
+ return new FmInterfaceItem( *this );
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmmodel.cxx b/svx/source/form/fmmodel.cxx
new file mode 100644
index 000000000000..ab61edb44b1c
--- /dev/null
+++ b/svx/source/form/fmmodel.cxx
@@ -0,0 +1,372 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmundo.hxx"
+#include "fmdocumentclassification.hxx"
+#include "fmcontrollayout.hxx"
+
+#include <svx/fmmodel.hxx>
+#include <svx/fmpage.hxx>
+#include <svx/svdobj.hxx>
+#include <tools/debug.hxx>
+
+#ifndef SVX_LIGHT
+#include <sfx2/objsh.hxx>
+#else
+class SfxObjectShell;
+#endif
+
+#include <boost/optional.hpp>
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::container::XNameContainer;
+using namespace svxform;
+
+TYPEINIT1(FmFormModel, SdrModel);
+
+struct FmFormModelImplData
+{
+ FmXUndoEnvironment* pUndoEnv;
+ sal_Bool bOpenInDesignIsDefaulted;
+ sal_Bool bMovingPage;
+ ::boost::optional< sal_Bool >
+ aControlsUseRefDevice;
+
+ FmFormModelImplData()
+ :pUndoEnv( NULL )
+ ,bOpenInDesignIsDefaulted( sal_True )
+ ,bMovingPage( sal_False )
+ ,aControlsUseRefDevice()
+ {
+ }
+};
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+FmFormModel::FmFormModel(SfxItemPool* pPool, SfxObjectShell* pPers)
+ :SdrModel(pPool, pPers, LOADREFCOUNTS)
+ ,m_pImpl(NULL)
+ ,m_pObjShell(0)
+ ,m_bOpenInDesignMode(sal_False)
+ ,m_bAutoControlFocus(sal_False)
+{
+#ifndef SVX_LIGHT
+ m_pImpl = new FmFormModelImplData;
+ m_pImpl->pUndoEnv = new FmXUndoEnvironment(*this);
+ m_pImpl->pUndoEnv->acquire();
+#endif
+}
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+FmFormModel::FmFormModel(const XubString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers)
+ :SdrModel(rPath, pPool, pPers)
+ ,m_pImpl(NULL)
+ ,m_pObjShell(0)
+ ,m_bOpenInDesignMode(sal_False)
+ ,m_bAutoControlFocus(sal_False)
+{
+#ifndef SVX_LIGHT
+ m_pImpl = new FmFormModelImplData;
+ m_pImpl->pUndoEnv = new FmXUndoEnvironment(*this);
+ m_pImpl->pUndoEnv->acquire();
+#endif
+}
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+FmFormModel::FmFormModel(SfxItemPool* pPool, SfxObjectShell* pPers,
+ bool bUseExtColorTable
+ )
+ :SdrModel(pPool, pPers, bUseExtColorTable, LOADREFCOUNTS)
+ ,m_pImpl(NULL)
+ ,m_pObjShell(0)
+ ,m_bOpenInDesignMode(sal_False)
+ ,m_bAutoControlFocus(sal_False)
+{
+#ifndef SVX_LIGHT
+ m_pImpl = new FmFormModelImplData;
+ m_pImpl->pUndoEnv = new FmXUndoEnvironment(*this);
+ m_pImpl->pUndoEnv->acquire();
+#endif
+}
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+FmFormModel::FmFormModel(const XubString& rPath, SfxItemPool* pPool, SfxObjectShell* pPers,
+ bool bUseExtColorTable)
+ :SdrModel(rPath, pPool, pPers, bUseExtColorTable, LOADREFCOUNTS)
+ ,m_pImpl( NULL )
+ ,m_pObjShell(0)
+ ,m_bOpenInDesignMode(sal_False)
+ ,m_bAutoControlFocus(sal_False)
+{
+#ifndef SVX_LIGHT
+ m_pImpl = new FmFormModelImplData;
+ m_pImpl->pUndoEnv = new FmXUndoEnvironment(*this);
+ m_pImpl->pUndoEnv->acquire();
+#endif
+}
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+\************************************************************************/
+FmFormModel::~FmFormModel()
+{
+#ifndef SVX_LIGHT
+ if (m_pObjShell && m_pImpl->pUndoEnv->IsListening(*m_pObjShell))
+ SetObjectShell(NULL);
+
+ ClearUndoBuffer();
+ // minimale grenze fuer undos
+ SetMaxUndoActionCount(1);
+
+ m_pImpl->pUndoEnv->release();
+ delete m_pImpl;
+
+#endif
+}
+
+/*************************************************************************
+|*
+|* Erzeugt eine neue Seite
+|*
+\************************************************************************/
+SdrPage* FmFormModel::AllocPage(bool bMasterPage)
+{
+ return new FmFormPage(*this, NULL, bMasterPage);
+}
+
+/*************************************************************************
+|*
+|* InsertPage
+|*
+\************************************************************************/
+void FmFormModel::InsertPage(SdrPage* pPage, sal_uInt16 nPos)
+{
+#ifndef SVX_LIGHT
+ // hack solange Methode intern
+ if (m_pObjShell && !m_pImpl->pUndoEnv->IsListening( *m_pObjShell ))
+ SetObjectShell(m_pObjShell);
+#endif
+
+ SdrModel::InsertPage( pPage, nPos );
+}
+
+/*************************************************************************
+|*
+|* MovePage
+|*
+\************************************************************************/
+void FmFormModel::MovePage( USHORT nPgNum, USHORT nNewPos )
+{
+#ifndef SVX_LIGHT
+ m_pImpl->bMovingPage = sal_True;
+ // see InsertPage for this
+#endif
+
+ SdrModel::MovePage( nPgNum, nNewPos );
+
+#ifndef SVX_LIGHT
+ m_pImpl->bMovingPage = sal_False;
+#endif
+}
+
+/*************************************************************************
+|*
+|* RemovePage
+|*
+\************************************************************************/
+SdrPage* FmFormModel::RemovePage(sal_uInt16 nPgNum)
+{
+ FmFormPage* pToBeRemovedPage = dynamic_cast< FmFormPage* >( GetPage( nPgNum ) );
+ OSL_ENSURE( pToBeRemovedPage, "FmFormModel::RemovePage: *which page*?" );
+
+#ifndef SVX_LIGHT
+ if ( pToBeRemovedPage )
+ {
+ Reference< XNameContainer > xForms( pToBeRemovedPage->GetForms( false ) );
+ if ( xForms.is() )
+ m_pImpl->pUndoEnv->RemoveForms( xForms );
+ }
+#endif
+
+ FmFormPage* pRemovedPage = (FmFormPage*)SdrModel::RemovePage(nPgNum);
+ OSL_ENSURE( pRemovedPage == pToBeRemovedPage, "FmFormModel::RemovePage: inconsistency!" );
+ return pRemovedPage;
+}
+
+/*************************************************************************
+|*
+|* InsertMasterPage
+|*
+\************************************************************************/
+void FmFormModel::InsertMasterPage(SdrPage* pPage, sal_uInt16 nPos)
+{
+#ifndef SVX_LIGHT
+ // hack solange Methode intern
+ if (m_pObjShell && !m_pImpl->pUndoEnv->IsListening( *m_pObjShell ))
+ SetObjectShell(m_pObjShell);
+#endif
+
+ SdrModel::InsertMasterPage(pPage, nPos);
+}
+
+/*************************************************************************
+|*
+|* RemoveMasterPage
+|*
+\************************************************************************/
+SdrPage* FmFormModel::RemoveMasterPage(sal_uInt16 nPgNum)
+{
+ FmFormPage* pPage = (FmFormPage*)SdrModel::RemoveMasterPage(nPgNum);
+
+#ifndef SVX_LIGHT
+ if ( pPage )
+ {
+ Reference< XNameContainer > xForms( pPage->GetForms( false ) );
+ if ( xForms.is() )
+ m_pImpl->pUndoEnv->RemoveForms( xForms );
+ }
+#endif
+
+ return pPage;
+}
+
+//------------------------------------------------------------------------
+SdrLayerID FmFormModel::GetControlExportLayerId( const SdrObject& rObj ) const
+{
+ return rObj.GetLayer();
+}
+
+//------------------------------------------------------------------------
+void FmFormModel::implSetOpenInDesignMode( sal_Bool _bOpenDesignMode, sal_Bool _bForce )
+{
+ if( ( _bOpenDesignMode != m_bOpenInDesignMode ) || _bForce )
+ {
+ m_bOpenInDesignMode = _bOpenDesignMode;
+
+ if ( m_pObjShell )
+ m_pObjShell->SetModified( sal_True );
+ }
+ // no matter if we really did it or not - from now on, it does not count as defaulted anymore
+ m_pImpl->bOpenInDesignIsDefaulted = sal_False;
+}
+
+//------------------------------------------------------------------------
+void FmFormModel::SetOpenInDesignMode( sal_Bool bOpenDesignMode )
+{
+#ifndef SVX_LIGHT
+ implSetOpenInDesignMode( bOpenDesignMode, sal_False );
+#endif
+}
+
+#ifndef SVX_LIGHT
+//------------------------------------------------------------------------
+sal_Bool FmFormModel::OpenInDesignModeIsDefaulted( )
+{
+ return m_pImpl->bOpenInDesignIsDefaulted;
+}
+#endif
+
+//------------------------------------------------------------------------
+sal_Bool FmFormModel::ControlsUseRefDevice() const
+{
+ if ( !m_pImpl->aControlsUseRefDevice )
+ {
+ DocumentType eDocType = eUnknownDocumentType;
+ if ( m_pObjShell )
+ eDocType = DocumentClassification::classifyHostDocument( m_pObjShell->GetModel() );
+ m_pImpl->aControlsUseRefDevice.reset( ControlLayouter::useDocumentReferenceDevice( eDocType ) );
+ }
+ return *m_pImpl->aControlsUseRefDevice;
+}
+
+//------------------------------------------------------------------------
+void FmFormModel::SetAutoControlFocus( sal_Bool _bAutoControlFocus )
+{
+#ifndef SVX_LIGHT
+ if( _bAutoControlFocus != m_bAutoControlFocus )
+ {
+ m_bAutoControlFocus = _bAutoControlFocus;
+ m_pObjShell->SetModified( sal_True );
+ }
+#endif
+}
+
+//------------------------------------------------------------------------
+void FmFormModel::SetObjectShell( SfxObjectShell* pShell )
+{
+#ifndef SVX_LIGHT
+ if (pShell == m_pObjShell)
+ return;
+
+ if (m_pObjShell)
+ {
+ m_pImpl->pUndoEnv->EndListening( *this );
+ m_pImpl->pUndoEnv->EndListening( *m_pObjShell );
+ }
+
+ m_pObjShell = pShell;
+
+ if (m_pObjShell)
+ {
+ m_pImpl->pUndoEnv->SetReadOnly( m_pObjShell->IsReadOnly() || m_pObjShell->IsReadOnlyUI(), FmXUndoEnvironment::Accessor() );
+
+ if (!m_pImpl->pUndoEnv->IsReadOnly())
+ m_pImpl->pUndoEnv->StartListening(*this);
+
+ m_pImpl->pUndoEnv->StartListening( *m_pObjShell );
+ }
+#endif
+}
+
+//------------------------------------------------------------------------
+FmXUndoEnvironment& FmFormModel::GetUndoEnv()
+{
+ return *m_pImpl->pUndoEnv;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx
new file mode 100644
index 000000000000..703a66aaecb8
--- /dev/null
+++ b/svx/source/form/fmobj.cxx
@@ -0,0 +1,739 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "fmobj.hxx"
+#include "fmprop.hrc"
+#include "fmvwimp.hxx"
+#include "fmpgeimp.hxx"
+#include "fmresids.hrc"
+#include "svx/fmview.hxx"
+#include "svx/fmglob.hxx"
+#include "svx/fmpage.hxx"
+#include "editeng/editeng.hxx"
+#include "svx/svdovirt.hxx"
+#include "svx/fmmodel.hxx"
+#include "svx/dialmgr.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XDevice.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+/** === end UNO includes === **/
+#include "svx/fmtools.hxx"
+
+#include <tools/shl.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/processfactory.hxx>
+#include <toolkit/awt/vclxdevice.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/resmgr.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::script;
+using namespace ::com::sun::star::container;
+using namespace ::svxform;
+
+TYPEINIT1(FmFormObj, SdrUnoObj);
+DBG_NAME(FmFormObj);
+//------------------------------------------------------------------
+FmFormObj::FmFormObj(const ::rtl::OUString& rModelName,sal_Int32 _nType)
+ :SdrUnoObj ( rModelName )
+ ,m_nPos ( -1 )
+ ,m_nType ( _nType )
+ ,m_pLastKnownRefDevice ( NULL )
+{
+ DBG_CTOR(FmFormObj, NULL);
+
+ // normally, this is done in SetUnoControlModel, but if the call happened in the base class ctor,
+ // then our incarnation of it was not called (since we were not constructed at this time).
+ impl_checkRefDevice_nothrow( true );
+}
+
+//------------------------------------------------------------------
+FmFormObj::FmFormObj( sal_Int32 _nType )
+ :SdrUnoObj ( String() )
+ ,m_nPos ( -1 )
+ ,m_nType ( _nType )
+ ,m_pLastKnownRefDevice ( NULL )
+{
+ DBG_CTOR(FmFormObj, NULL);
+}
+
+//------------------------------------------------------------------
+FmFormObj::~FmFormObj()
+{
+ DBG_DTOR(FmFormObj, NULL);
+
+ Reference< XComponent> xHistory(m_xEnvironmentHistory, UNO_QUERY);
+ if (xHistory.is())
+ xHistory->dispose();
+
+ m_xEnvironmentHistory = NULL;
+ m_aEventsHistory.realloc(0);
+}
+
+//------------------------------------------------------------------
+void FmFormObj::SetObjEnv(const Reference< XIndexContainer > & xForm, const sal_Int32 nIdx,
+ const Sequence< ScriptEventDescriptor >& rEvts)
+{
+ m_xParent = xForm;
+ aEvts = rEvts;
+ m_nPos = nIdx;
+}
+
+//------------------------------------------------------------------
+void FmFormObj::ClearObjEnv()
+{
+ m_xParent.clear();
+ aEvts.realloc( 0 );
+ m_nPos = -1;
+}
+
+//------------------------------------------------------------------
+void FmFormObj::impl_checkRefDevice_nothrow( bool _force )
+{
+ const FmFormModel* pFormModel = PTR_CAST( FmFormModel, GetModel() );
+ if ( !pFormModel || !pFormModel->ControlsUseRefDevice() )
+ return;
+
+ OutputDevice* pCurrentRefDevice = pFormModel ? pFormModel->GetRefDevice() : NULL;
+ if ( ( m_pLastKnownRefDevice == pCurrentRefDevice ) && !_force )
+ return;
+
+ Reference< XControlModel > xControlModel( GetUnoControlModel() );
+ if ( !xControlModel.is() )
+ return;
+
+ m_pLastKnownRefDevice = pCurrentRefDevice;
+ if ( m_pLastKnownRefDevice == NULL )
+ return;
+
+ try
+ {
+ Reference< XPropertySet > xModelProps( GetUnoControlModel(), UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xPropertyInfo( xModelProps->getPropertySetInfo(), UNO_SET_THROW );
+
+ static const ::rtl::OUString sRefDevicePropName( RTL_CONSTASCII_USTRINGPARAM( "ReferenceDevice" ) );
+ if ( xPropertyInfo->hasPropertyByName( sRefDevicePropName ) )
+ {
+ VCLXDevice* pUnoRefDevice = new VCLXDevice;
+ pUnoRefDevice->SetOutputDevice( m_pLastKnownRefDevice );
+ Reference< XDevice > xRefDevice( pUnoRefDevice );
+ xModelProps->setPropertyValue( sRefDevicePropName, makeAny( xRefDevice ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------
+void FmFormObj::impl_isolateControlModel_nothrow()
+{
+ try
+ {
+ Reference< XChild > xControlModel( GetUnoControlModel(), UNO_QUERY );
+ if ( xControlModel.is() )
+ {
+ Reference< XIndexContainer> xParent( xControlModel->getParent(), UNO_QUERY );
+ if ( xParent.is() )
+ {
+ sal_Int32 nPos = getElementPos( xParent.get(), xControlModel );
+ xParent->removeByIndex( nPos );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------
+void FmFormObj::SetPage(SdrPage* _pNewPage)
+{
+ if ( GetPage() == _pNewPage )
+ {
+ SdrUnoObj::SetPage(_pNewPage);
+ return;
+ }
+
+ FmFormPage* pOldFormPage = PTR_CAST( FmFormPage, GetPage() );
+ if ( pOldFormPage )
+ pOldFormPage->GetImpl().formObjectRemoved( *this );
+
+ FmFormPage* pNewFormPage = PTR_CAST( FmFormPage, _pNewPage );
+ if ( !pNewFormPage )
+ { // Maybe it makes sense to create an environment history here : if somebody set's our page to NULL, and we have a valid page before,
+ // me may want to remember our place within the old page. For this we could create a new m_xEnvironmentHistory to store it.
+ // So the next SetPage with a valid new page would restore that environment within the new page.
+ // But for the original Bug (#57300#) we don't need that, so I omit it here. Maybe this will be implemented later.
+ impl_isolateControlModel_nothrow();
+ SdrUnoObj::SetPage(_pNewPage);
+ return;
+ }
+
+ Reference< XIndexContainer > xNewPageForms( pNewFormPage->GetForms( true ), UNO_QUERY );
+ Reference< XIndexContainer > xNewParent;
+ Sequence< ScriptEventDescriptor> aNewEvents;
+
+ // calc the new parent for my model (within the new page's forms hierarchy)
+ // do we have a history ? (from :Clone)
+ if ( m_xEnvironmentHistory.is() )
+ {
+ // the element in m_xEnvironmentHistory which is equivalent to my new parent (which (perhaps) has to be created within _pNewPage->GetForms)
+ // is the right-most element in the tree.
+ Reference< XIndexContainer > xRightMostLeaf = m_xEnvironmentHistory;
+ try
+ {
+ while ( xRightMostLeaf->getCount() )
+ {
+ xRightMostLeaf.set(
+ xRightMostLeaf->getByIndex( xRightMostLeaf->getCount() - 1 ),
+ UNO_QUERY_THROW
+ );
+ }
+
+ xNewParent.set( ensureModelEnv( xRightMostLeaf, xNewPageForms ), UNO_QUERY_THROW );
+
+ // we successfully cloned the environment in m_xEnvironmentHistory, so we can use m_aEventsHistory
+ // (which describes the events of our model at the moment m_xEnvironmentHistory was created)
+ aNewEvents = m_aEventsHistory;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ if ( !xNewParent.is() )
+ {
+ // are we a valid part of our current page forms ?
+ Reference< XIndexContainer > xOldForms;
+ if ( pOldFormPage )
+ xOldForms.set( pOldFormPage->GetForms(), UNO_QUERY_THROW );
+
+ if ( xOldForms.is() )
+ {
+ // search (upward from our model) for xOldForms
+ Reference< XChild > xSearch( GetUnoControlModel(), UNO_QUERY );
+ while (xSearch.is())
+ {
+ if ( xSearch == xOldForms )
+ break;
+ xSearch = Reference< XChild >( xSearch->getParent(), UNO_QUERY );
+ }
+ if ( xSearch.is() ) // implies xSearch == xOldForms, which means we're a valid part of our current page forms hierarchy
+ {
+ Reference< XChild > xMeAsChild( GetUnoControlModel(), UNO_QUERY );
+ xNewParent.set( ensureModelEnv( xMeAsChild->getParent(), xNewPageForms ), UNO_QUERY );
+
+ if ( xNewParent.is() )
+ {
+ try
+ {
+ // transfer the events from our (model's) parent to the new (model's) parent, too
+ Reference< XEventAttacherManager > xEventManager(xMeAsChild->getParent(), UNO_QUERY);
+ Reference< XIndexAccess > xManagerAsIndex(xEventManager, UNO_QUERY);
+ if (xManagerAsIndex.is())
+ {
+ sal_Int32 nPos = getElementPos(xManagerAsIndex, xMeAsChild);
+ if (nPos >= 0)
+ aNewEvents = xEventManager->getScriptEvents(nPos);
+ }
+ else
+ aNewEvents = aEvts;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ }
+ }
+
+ // now set the page
+ SdrUnoObj::SetPage(_pNewPage);
+
+ // place my model within the new parent container
+ if (xNewParent.is())
+ {
+ Reference< XFormComponent > xMeAsFormComp(GetUnoControlModel(), UNO_QUERY);
+ if (xMeAsFormComp.is())
+ {
+ // check if I have another parent (and remove me, if neccessary)
+ Reference< XIndexContainer > xOldParent(xMeAsFormComp->getParent(), UNO_QUERY);
+ if (xOldParent.is())
+ {
+ sal_Int32 nPos = getElementPos(Reference< XIndexAccess > (xOldParent, UNO_QUERY), xMeAsFormComp);
+ if (nPos > -1)
+ xOldParent->removeByIndex(nPos);
+ }
+ // and insert into the new container
+ xNewParent->insertByIndex(xNewParent->getCount(), makeAny(xMeAsFormComp));
+
+ // transfer the events
+ if (aNewEvents.getLength())
+ {
+ try
+ {
+ Reference< XEventAttacherManager > xEventManager(xNewParent, UNO_QUERY);
+ Reference< XIndexAccess > xManagerAsIndex(xEventManager, UNO_QUERY);
+ if (xManagerAsIndex.is())
+ {
+ sal_Int32 nPos = getElementPos(xManagerAsIndex, xMeAsFormComp);
+ DBG_ASSERT(nPos >= 0, "FmFormObj::SetPage : inserted but not present ?");
+ xEventManager->registerScriptEvents(nPos, aNewEvents);
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ }
+ }
+ }
+
+ // delete my history
+ Reference< XComponent> xHistory(m_xEnvironmentHistory, UNO_QUERY);
+ if (xHistory.is())
+ xHistory->dispose();
+
+ m_xEnvironmentHistory = NULL;
+ m_aEventsHistory.realloc(0);
+
+ if ( pNewFormPage )
+ pNewFormPage->GetImpl().formObjectInserted( *this );
+}
+
+//------------------------------------------------------------------
+sal_uInt32 FmFormObj::GetObjInventor() const
+{
+ return FmFormInventor;
+}
+
+//------------------------------------------------------------------
+sal_uInt16 FmFormObj::GetObjIdentifier() const
+{
+ return OBJ_UNO;
+}
+
+//------------------------------------------------------------------
+void FmFormObj::clonedFrom(const FmFormObj* _pSource)
+{
+ DBG_ASSERT(_pSource != NULL, "FmFormObj::clonedFrom : invalid source !");
+ Reference< XComponent> xHistory(m_xEnvironmentHistory, UNO_QUERY);
+ if (xHistory.is())
+ xHistory->dispose();
+
+ m_xEnvironmentHistory = NULL;
+ m_aEventsHistory.realloc(0);
+
+ Reference< XChild > xSourceAsChild(_pSource->GetUnoControlModel(), UNO_QUERY);
+ if (!xSourceAsChild.is())
+ return;
+
+ Reference< XInterface > xSourceContainer = xSourceAsChild->getParent();
+
+ m_xEnvironmentHistory = Reference< XIndexContainer >(
+ ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.form.Forms")),
+ UNO_QUERY);
+ DBG_ASSERT(m_xEnvironmentHistory.is(), "FmFormObj::clonedFrom : could not create a forms collection !");
+
+ if (m_xEnvironmentHistory.is())
+ {
+ ensureModelEnv(xSourceContainer, m_xEnvironmentHistory);
+ m_aEventsHistory = aEvts;
+ // if we we're clone there was a call to operator=, so aEvts are excatly the events we need here ...
+ }
+}
+
+//------------------------------------------------------------------
+SdrObject* FmFormObj::Clone() const
+{
+ SdrObject* pReturn = SdrUnoObj::Clone();
+
+ FmFormObj* pFormObject = PTR_CAST(FmFormObj, pReturn);
+ DBG_ASSERT(pFormObject != NULL, "FmFormObj::Clone : invalid clone !");
+ if (pFormObject)
+ pFormObject->clonedFrom(this);
+
+ return pReturn;
+}
+
+//------------------------------------------------------------------
+void FmFormObj::NbcReformatText()
+{
+ impl_checkRefDevice_nothrow( false );
+ SdrUnoObj::NbcReformatText();
+}
+
+//------------------------------------------------------------------
+void FmFormObj::operator= (const SdrObject& rObj)
+{
+ SdrUnoObj::operator= (rObj);
+
+ FmFormObj* pFormObj = PTR_CAST(FmFormObj, &rObj);
+ if (pFormObj)
+ {
+ // liegt das UnoControlModel in einer Eventumgebung,
+ // dann koennen noch Events zugeordnet sein
+ Reference< XFormComponent > xContent(pFormObj->xUnoControlModel, UNO_QUERY);
+ if (xContent.is())
+ {
+ Reference< XEventAttacherManager > xManager(xContent->getParent(), UNO_QUERY);
+ Reference< XIndexAccess > xManagerAsIndex(xManager, UNO_QUERY);
+ if (xManagerAsIndex.is())
+ {
+ sal_Int32 nPos = getElementPos( xManagerAsIndex, xContent );
+ if ( nPos >= 0 )
+ aEvts = xManager->getScriptEvents( nPos );
+ }
+ }
+ else
+ aEvts = pFormObj->aEvts;
+ }
+}
+
+//------------------------------------------------------------------
+namespace
+{
+ String lcl_getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement)
+ {
+ Reference< ::com::sun::star::form::XFormComponent> xChild(_xElement, UNO_QUERY);
+ Reference< ::com::sun::star::container::XIndexAccess> xParent;
+ if (xChild.is())
+ xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY);
+
+ // while the current content is a form
+ String sReturn;
+ String sCurrentIndex;
+ while (xChild.is())
+ {
+ // get the content's relative pos within it's parent container
+ sal_Int32 nPos = getElementPos(xParent, xChild);
+
+ // prepend this current relaive pos
+ sCurrentIndex = String::CreateFromInt32(nPos);
+ if (sReturn.Len() != 0)
+ {
+ sCurrentIndex += '\\';
+ sCurrentIndex += sReturn;
+ }
+
+ sReturn = sCurrentIndex;
+
+ // travel up
+ if (::comphelper::query_interface((Reference< XInterface >)xParent,xChild))
+ xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY);
+ }
+
+ _rTopLevelElement = xParent;
+ return sReturn;
+ }
+}
+
+//------------------------------------------------------------------
+Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > & _rSourceContainer, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > _rTopLevelDestContainer)
+{
+ Reference< XInterface > xTopLevelSouce;
+ String sAccessPath = lcl_getFormComponentAccessPath(_rSourceContainer, xTopLevelSouce);
+ if (!xTopLevelSouce.is())
+ // somthing went wrong, maybe _rSourceContainer isn't part of a valid forms hierarchy
+ return Reference< XInterface > ();
+
+ Reference< XIndexContainer > xDestContainer(_rTopLevelDestContainer);
+ Reference< XIndexContainer > xSourceContainer(xTopLevelSouce, UNO_QUERY);
+ DBG_ASSERT(xSourceContainer.is(), "FmFormObj::ensureModelEnv : the top level source is invalid !");
+
+ for (xub_StrLen i=0; i<sAccessPath.GetTokenCount('\\'); ++i)
+ {
+ sal_uInt16 nIndex = (sal_uInt16)sAccessPath.GetToken(i, '\\').ToInt32();
+
+ // get the DSS of the source form (we have to find an aquivalent for)
+ DBG_ASSERT(nIndex<xSourceContainer->getCount(), "FmFormObj::ensureModelEnv : invalid access path !");
+ Reference< XPropertySet > xSourceForm;
+ xSourceContainer->getByIndex(nIndex) >>= xSourceForm;
+ DBG_ASSERT(xSourceForm.is(), "FmFormObj::ensureModelEnv : invalid source form !");
+
+ Any aSrcCursorSource, aSrcCursorSourceType, aSrcDataSource;
+ DBG_ASSERT(::comphelper::hasProperty(FM_PROP_COMMAND, xSourceForm) && ::comphelper::hasProperty(FM_PROP_COMMANDTYPE, xSourceForm)
+ && ::comphelper::hasProperty(FM_PROP_DATASOURCE, xSourceForm), "FmFormObj::ensureModelEnv : invalid access path or invalid form (missing props) !");
+ // the parent access path should refer to a row set
+ try
+ {
+ aSrcCursorSource = xSourceForm->getPropertyValue(FM_PROP_COMMAND);
+ aSrcCursorSourceType = xSourceForm->getPropertyValue(FM_PROP_COMMANDTYPE);
+ aSrcDataSource = xSourceForm->getPropertyValue(FM_PROP_DATASOURCE);
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmFormObj::ensureModelEnv : could not retrieve a source DSS !");
+ }
+
+
+ // calc the number of (source) form siblings with the same DSS
+ Reference< XPropertySet > xCurrentSourceForm, xCurrentDestForm;
+ sal_Int16 nCurrentSourceIndex = 0, nCurrentDestIndex = 0;
+ while (nCurrentSourceIndex <= nIndex)
+ {
+ sal_Bool bEqualDSS = sal_False;
+ while (!bEqualDSS) // (we don't have to check nCurrentSourceIndex here : it's bound by nIndex)
+ {
+ xSourceContainer->getByIndex(nCurrentSourceIndex) >>= xCurrentSourceForm;
+ DBG_ASSERT(xCurrentSourceForm.is(), "FmFormObj::ensureModelEnv : invalid form ancestor (2) !");
+ bEqualDSS = sal_False;
+ if (::comphelper::hasProperty(FM_PROP_DATASOURCE, xCurrentSourceForm))
+ { // it is a form
+ try
+ {
+ if ( ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_COMMAND), aSrcCursorSource)
+ && ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_COMMANDTYPE), aSrcCursorSourceType)
+ && ::comphelper::compare(xCurrentSourceForm->getPropertyValue(FM_PROP_DATASOURCE), aSrcDataSource)
+ )
+ {
+ bEqualDSS = sal_True;
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmFormObj::ensureModelEnv : exception while getting a sibling's DSS !");
+ }
+
+ }
+ ++nCurrentSourceIndex;
+ }
+
+ DBG_ASSERT(bEqualDSS, "FmFormObj::ensureModelEnv : found no source form !");
+ // ??? at least the nIndex-th one should have been found ???
+
+ // now search the next one with the given DSS (within the destination container)
+ bEqualDSS = sal_False;
+ while (!bEqualDSS && (nCurrentDestIndex < xDestContainer->getCount()))
+ {
+ xDestContainer->getByIndex(nCurrentDestIndex) >>= xCurrentDestForm;
+ DBG_ASSERT(xCurrentDestForm.is(), "FmFormObj::ensureModelEnv : invalid destination form !");
+ bEqualDSS = sal_False;
+ if (::comphelper::hasProperty(FM_PROP_DATASOURCE, xCurrentDestForm))
+ { // it is a form
+ try
+ {
+ if ( ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_COMMAND), aSrcCursorSource)
+ && ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_COMMANDTYPE), aSrcCursorSourceType)
+ && ::comphelper::compare(xCurrentDestForm->getPropertyValue(FM_PROP_DATASOURCE), aSrcDataSource)
+ )
+ {
+ bEqualDSS = sal_True;
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmFormObj::ensureModelEnv : exception while getting a destination DSS !");
+ }
+
+ }
+ ++nCurrentDestIndex;
+ }
+
+ if (!bEqualDSS)
+ { // There is at least one more source form with the given DSS than destination forms are.
+ // correct this ...
+ try
+ {
+ // create and insert (into the destination) a copy of the form
+ xCurrentDestForm.set(
+ ::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.form.component.DataForm" ) ),
+ UNO_QUERY_THROW );
+ ::comphelper::copyProperties( xCurrentSourceForm, xCurrentDestForm );
+
+ DBG_ASSERT(nCurrentDestIndex == xDestContainer->getCount(), "FmFormObj::ensureModelEnv : something went wrong with the numbers !");
+ xDestContainer->insertByIndex(nCurrentDestIndex, makeAny(xCurrentDestForm));
+
+ ++nCurrentDestIndex;
+ // like nCurrentSourceIndex, nCurrentDestIndex now points 'behind' the form it actally means
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmFormObj::ensureModelEnv : something went seriously wrong while creating a new form !");
+ // no more options anymore ...
+ return Reference< XInterface > ();
+ }
+
+ }
+ }
+
+ // now xCurrentDestForm is a form equivalent to xSourceForm (which means they have the same DSS and the same number
+ // of left siblings with the same DSS, which counts for all their ancestors, too)
+
+ // go down
+ xDestContainer = Reference< XIndexContainer > (xCurrentDestForm, UNO_QUERY);
+ xSourceContainer = Reference< XIndexContainer > (xSourceForm, UNO_QUERY);
+ DBG_ASSERT(xDestContainer.is() && xSourceContainer.is(), "FmFormObj::ensureModelEnv : invalid container !");
+ }
+
+ return Reference< XInterface > (xDestContainer, UNO_QUERY);
+}
+
+//------------------------------------------------------------------
+void FmFormObj::SetModel( SdrModel* _pNewModel )
+{
+ SdrUnoObj::SetModel( _pNewModel );
+ impl_checkRefDevice_nothrow();
+}
+
+//------------------------------------------------------------------
+FmFormObj* FmFormObj::GetFormObject( SdrObject* _pSdrObject )
+{
+ FmFormObj* pFormObject = dynamic_cast< FmFormObj* >( _pSdrObject );
+ if ( !pFormObject )
+ {
+ SdrVirtObj* pVirtualObject = dynamic_cast< SdrVirtObj* >( _pSdrObject );
+ if ( pVirtualObject )
+ pFormObject = dynamic_cast< FmFormObj* >( &pVirtualObject->ReferencedObj() );
+ }
+ return pFormObject;
+}
+
+//------------------------------------------------------------------
+const FmFormObj* FmFormObj::GetFormObject( const SdrObject* _pSdrObject )
+{
+ const FmFormObj* pFormObject = dynamic_cast< const FmFormObj* >( _pSdrObject );
+ if ( !pFormObject )
+ {
+ const SdrVirtObj* pVirtualObject = dynamic_cast< const SdrVirtObj* >( _pSdrObject );
+ if ( pVirtualObject )
+ pFormObject = dynamic_cast< const FmFormObj* >( &pVirtualObject->GetReferencedObj() );
+ }
+ return pFormObject;
+}
+
+//------------------------------------------------------------------
+void FmFormObj::SetUnoControlModel( const Reference< com::sun::star::awt::XControlModel >& _rxModel )
+{
+ SdrUnoObj::SetUnoControlModel( _rxModel );
+
+ // TODO: call something like formObjectInserted at the form page, to tell it the new model
+
+ impl_checkRefDevice_nothrow( true );
+}
+
+//------------------------------------------------------------------
+bool FmFormObj::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd )
+{
+ bool bResult = SdrUnoObj::EndCreate(rStat, eCmd);
+ if ( bResult && SDRCREATE_FORCEEND == eCmd && rStat.GetView() )
+ {
+ if ( pPage )
+ {
+ FmFormPage& rPage = dynamic_cast< FmFormPage& >( *pPage );
+
+ try
+ {
+ Reference< XFormComponent > xContent( xUnoControlModel, UNO_QUERY_THROW );
+ Reference< XForm > xParentForm( xContent->getParent(), UNO_QUERY );
+
+ Reference< XIndexContainer > xFormToInsertInto;
+
+ if ( !xParentForm.is() )
+ { // model is not yet part of a form component hierachy
+ xParentForm.set( rPage.GetImpl().findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW );
+ xFormToInsertInto.set( xParentForm, UNO_QUERY_THROW );
+ }
+
+ rPage.GetImpl().setUniqueName( xContent, xParentForm );
+
+ if ( xFormToInsertInto.is() )
+ xFormToInsertInto->insertByIndex( xFormToInsertInto->getCount(), makeAny( xContent ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ FmFormView* pView( dynamic_cast< FmFormView* >( rStat.GetView() ) );
+ FmXFormView* pViewImpl = pView ? pView->GetImpl() : NULL;
+ OSL_ENSURE( pViewImpl, "FmFormObj::EndCreate: no view!?" );
+ if ( pViewImpl )
+ pViewImpl->onCreatedFormObject( *this );
+ }
+ return bResult;
+}
+
+//------------------------------------------------------------------------------
+void FmFormObj::BrkCreate( SdrDragStat& rStat )
+{
+ SdrUnoObj::BrkCreate( rStat );
+ impl_isolateControlModel_nothrow();
+}
+
+// -----------------------------------------------------------------------------
+sal_Int32 FmFormObj::getType() const
+{
+ return m_nType;
+}
+
+// -----------------------------------------------------------------------------
+// #i70852# overload Layer interface to force to FormColtrol layer
+
+SdrLayerID FmFormObj::GetLayer() const
+{
+ // #i72535#
+ // i70852 was too radical, in SW obects (and thus, FormControls, too)
+ // get moved to invisible layers to hide them (e.g. in hidden sections).
+ // This means that form controls ARE allowed to be on other layers than
+ // the form control layer ATM and that being member of form control layer
+ // is no criteria to find all FormControls of a document.
+ // To fix, use parent functionality
+ return SdrUnoObj::GetLayer();
+}
+
+void FmFormObj::NbcSetLayer(SdrLayerID nLayer)
+{
+ // #i72535#
+ // See above. To fix, use parent functionality
+ return SdrUnoObj::NbcSetLayer(nLayer);
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmobjfac.cxx b/svx/source/form/fmobjfac.cxx
new file mode 100644
index 000000000000..611411517104
--- /dev/null
+++ b/svx/source/form/fmobjfac.cxx
@@ -0,0 +1,266 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <comphelper/stl_types.hxx>
+#include <svx/svdobj.hxx>
+#include "svx/fmtools.hxx"
+#include "fmservs.hxx"
+
+#include "fmobjfac.hxx"
+
+#include <svx/fmglob.hxx>
+
+#include "fmobj.hxx"
+#include "fmshimp.hxx"
+
+#include <svx/fmshell.hxx>
+
+#include <svx/svxids.hrc>
+#include "tbxform.hxx"
+#include <tools/resid.hxx>
+
+#include "fmresids.hrc"
+#include <tools/shl.hxx>
+#include <svx/dialmgr.hxx>
+#include "fmservs.hxx"
+#include "tabwin.hxx"
+#include "fmexpl.hxx"
+#include "filtnav.hxx"
+
+#include "fmprop.hrc"
+#include "fmPropBrw.hxx"
+#include "datanavi.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::svxform;
+
+static BOOL bInit = FALSE;
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+FmFormObjFactory::FmFormObjFactory()
+{
+ if ( !bInit )
+ {
+ SdrObjFactory::InsertMakeObjectHdl(LINK(this, FmFormObjFactory, MakeObject));
+
+ //////////////////////////////////////////////////////////////////////
+ // Konfigurations-::com::sun::star::frame::Controller und NavigationBar registrieren
+ SvxFmTbxCtlConfig::RegisterControl( SID_FM_CONFIG );
+ SvxFmTbxCtlAbsRec::RegisterControl( SID_FM_RECORD_ABSOLUTE );
+ SvxFmTbxCtlRecText::RegisterControl( SID_FM_RECORD_TEXT );
+ SvxFmTbxCtlRecFromText::RegisterControl( SID_FM_RECORD_FROM_TEXT );
+ SvxFmTbxCtlRecTotal::RegisterControl( SID_FM_RECORD_TOTAL );
+ SvxFmTbxPrevRec::RegisterControl( SID_FM_RECORD_PREV );
+ SvxFmTbxNextRec::RegisterControl( SID_FM_RECORD_NEXT );
+ ControlConversionMenuController::RegisterControl(SID_FM_CHANGECONTROLTYPE);
+
+ // Registrieung von globalen fenstern
+ FmFieldWinMgr::RegisterChildWindow();
+ FmPropBrwMgr::RegisterChildWindow();
+ NavigatorFrameManager::RegisterChildWindow();
+ DataNavigatorManager::RegisterChildWindow();
+ FmFilterNavigatorWinMgr::RegisterChildWindow();
+
+ //////////////////////////////////////////////////////////////////////
+ // Interface fuer die Formshell registrieren
+ FmFormShell::RegisterInterface(0);
+
+ ImplSmartRegisterUnoServices();
+ bInit = TRUE;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+\************************************************************************/
+FmFormObjFactory::~FmFormObjFactory()
+{
+}
+
+
+/*************************************************************************
+|*
+|* ::com::sun::star::form::Form-Objekte erzeugen
+|*
+\************************************************************************/
+namespace
+{
+ void lcl_initProperty( FmFormObj* _pObject, const ::rtl::OUString& _rPropName, const Any& _rValue )
+ {
+ try
+ {
+ Reference< XPropertySet > xModelSet( _pObject->GetUnoControlModel(), UNO_QUERY );
+ if ( xModelSet.is() )
+ xModelSet->setPropertyValue( _rPropName, _rValue );
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "lcl_initProperty: caught an exception!" );
+ }
+ }
+}
+
+IMPL_LINK(FmFormObjFactory, MakeObject, SdrObjFactory*, pObjFactory)
+{
+ if (pObjFactory->nInventor == FmFormInventor)
+ {
+ ::rtl::OUString sServiceSpecifier;
+
+ typedef ::std::vector< ::std::pair< ::rtl::OUString, Any > > PropertyValueArray;
+ PropertyValueArray aInitialProperties;
+
+ switch ( pObjFactory->nIdentifier )
+ {
+ case OBJ_FM_EDIT:
+ sServiceSpecifier = FM_COMPONENT_EDIT;
+ break;
+
+ case OBJ_FM_BUTTON:
+ sServiceSpecifier = FM_COMPONENT_COMMANDBUTTON;
+ break;
+
+ case OBJ_FM_FIXEDTEXT:
+ sServiceSpecifier = FM_COMPONENT_FIXEDTEXT;
+ break;
+
+ case OBJ_FM_LISTBOX:
+ sServiceSpecifier = FM_COMPONENT_LISTBOX;
+ break;
+
+ case OBJ_FM_CHECKBOX:
+ sServiceSpecifier = FM_COMPONENT_CHECKBOX;
+ break;
+
+ case OBJ_FM_RADIOBUTTON:
+ sServiceSpecifier = FM_COMPONENT_RADIOBUTTON;
+ break;
+
+ case OBJ_FM_GROUPBOX:
+ sServiceSpecifier = FM_COMPONENT_GROUPBOX;
+ break;
+
+ case OBJ_FM_COMBOBOX:
+ sServiceSpecifier = FM_COMPONENT_COMBOBOX;
+ break;
+
+ case OBJ_FM_GRID:
+ sServiceSpecifier = FM_COMPONENT_GRID;
+ break;
+
+ case OBJ_FM_IMAGEBUTTON:
+ sServiceSpecifier = FM_COMPONENT_IMAGEBUTTON;
+ break;
+
+ case OBJ_FM_FILECONTROL:
+ sServiceSpecifier = FM_COMPONENT_FILECONTROL;
+ break;
+
+ case OBJ_FM_DATEFIELD:
+ sServiceSpecifier = FM_COMPONENT_DATEFIELD;
+ break;
+
+ case OBJ_FM_TIMEFIELD:
+ sServiceSpecifier = FM_COMPONENT_TIMEFIELD;
+ aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_TIMEMAX, makeAny( (sal_Int32)( Time( 23, 59, 59, 99 ).GetTime() ) ) ) );
+ break;
+
+ case OBJ_FM_NUMERICFIELD:
+ sServiceSpecifier = FM_COMPONENT_NUMERICFIELD;
+ break;
+
+ case OBJ_FM_CURRENCYFIELD:
+ sServiceSpecifier = FM_COMPONENT_CURRENCYFIELD;
+ break;
+
+ case OBJ_FM_PATTERNFIELD:
+ sServiceSpecifier = FM_COMPONENT_PATTERNFIELD;
+ break;
+
+ case OBJ_FM_HIDDEN:
+ sServiceSpecifier = FM_COMPONENT_HIDDEN;
+ break;
+
+ case OBJ_FM_IMAGECONTROL:
+ sServiceSpecifier = FM_COMPONENT_IMAGECONTROL;
+ break;
+
+ case OBJ_FM_FORMATTEDFIELD:
+ sServiceSpecifier = FM_COMPONENT_FORMATTEDFIELD;
+ break;
+
+ case OBJ_FM_NAVIGATIONBAR:
+ sServiceSpecifier = FM_SUN_COMPONENT_NAVIGATIONBAR;
+ break;
+
+ case OBJ_FM_SCROLLBAR:
+ sServiceSpecifier = FM_SUN_COMPONENT_SCROLLBAR;
+ aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
+ break;
+
+ case OBJ_FM_SPINBUTTON:
+ sServiceSpecifier = FM_SUN_COMPONENT_SPINBUTTON;
+ aInitialProperties.push_back( PropertyValueArray::value_type( FM_PROP_BORDER, makeAny( (sal_Int16)0 ) ) );
+ break;
+ }
+
+ // create the actual object
+ if ( sServiceSpecifier.getLength() )
+ pObjFactory->pNewObj = new FmFormObj( sServiceSpecifier, pObjFactory->nIdentifier );
+ else
+ pObjFactory->pNewObj = new FmFormObj( pObjFactory->nIdentifier );
+
+ // initialize some properties which we want to differ from the defaults
+ for ( PropertyValueArray::const_iterator aInitProp = aInitialProperties.begin();
+ aInitProp != aInitialProperties.end();
+ ++aInitProp
+ )
+ {
+ lcl_initProperty(
+ static_cast< FmFormObj* >( pObjFactory->pNewObj ),
+ aInitProp->first,
+ aInitProp->second
+ );
+ }
+ }
+
+ return 0;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx
new file mode 100644
index 000000000000..962837e53bda
--- /dev/null
+++ b/svx/source/form/fmpage.cxx
@@ -0,0 +1,274 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <sal/macros.h>
+
+#define ENABLE_BYTESTRING_STREAM_OPERATORS
+#include <svx/fmpage.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+
+
+#include <svx/fmmodel.hxx>
+
+#ifndef SVX_LIGHT
+#include "fmobj.hxx"
+#endif
+
+#ifndef SVX_LIGHT
+#include "fmresids.hrc"
+#endif
+#include <tools/shl.hxx>
+#include <svx/dialmgr.hxx>
+
+#ifndef SVX_LIGHT
+#include "fmpgeimp.hxx"
+#endif
+
+#ifndef SVX_LIGHT
+#include <sfx2/objsh.hxx>
+#endif
+#include "svditer.hxx"
+#include <svx/svdview.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/help.hxx>
+
+
+#ifndef SVX_LIGHT
+#include <svx/fmglob.hxx>
+#include "fmprop.hrc"
+#include "fmundo.hxx"
+#include "svx/fmtools.hxx"
+using namespace ::svxform;
+#endif
+#include <comphelper/property.hxx>
+#include <rtl/logfile.hxx>
+
+using com::sun::star::uno::Reference;
+using com::sun::star::uno::UNO_QUERY;
+using com::sun::star::container::XChild;
+using com::sun::star::container::XNameContainer;
+
+TYPEINIT1(FmFormPage, SdrPage);
+
+//------------------------------------------------------------------
+FmFormPage::FmFormPage(FmFormModel& rModel, StarBASIC* _pBasic, bool bMasterPage)
+ :SdrPage(rModel, bMasterPage)
+#ifndef SVX_LIGHT
+ ,m_pImpl( new FmFormPageImpl( *this ) )
+#else
+ ,m_pImpl(NULL)
+#endif
+ ,m_pBasic(_pBasic)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::FmFormPage" );
+}
+
+//------------------------------------------------------------------
+FmFormPage::FmFormPage(const FmFormPage& rPage)
+ :SdrPage(rPage)
+#ifndef SVX_LIGHT
+ ,m_pImpl(new FmFormPageImpl( *this, rPage.GetImpl() ) )
+#else
+ ,m_pImpl(NULL)
+#endif
+ ,m_pBasic(0)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::FmFormPage" );
+ m_sPageName = rPage.m_sPageName;
+}
+
+//------------------------------------------------------------------
+FmFormPage::~FmFormPage()
+{
+#ifndef SVX_LIGHT
+ delete m_pImpl;
+#endif
+}
+
+//------------------------------------------------------------------
+void FmFormPage::SetModel(SdrModel* pNewModel)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::SetModel" );
+ /* #35055# */
+ // we want to call the super's "SetModel" method even if the model is the
+ // same, in case code somewhere in the system depends on it. But our code
+ // doesn't, so get the old model to do a check.
+ SdrModel *pOldModel = GetModel();
+
+ SdrPage::SetModel( pNewModel );
+
+ /* #35055# */
+ if ( ( pOldModel != pNewModel ) && m_pImpl )
+ {
+ try
+ {
+ Reference< XNameContainer > xForms( m_pImpl->getForms( false ) );
+ if ( xForms.is() )
+ {
+ // we want to keep the current collection, just reset the model
+ // with which it's associated.
+ Reference< XChild > xAsChild( xForms, UNO_QUERY );
+ if ( xAsChild.is() )
+ {
+ FmFormModel* pDrawModel = (FmFormModel*) GetModel();
+ SfxObjectShell* pObjShell = pDrawModel->GetObjectShell();
+ if ( pObjShell )
+ xAsChild->setParent( pObjShell->GetModel() );
+ }
+ }
+ }
+ catch( ::com::sun::star::uno::Exception ex )
+ {
+ OSL_ENSURE( sal_False, "UNO Exception caught resetting model for m_pImpl (FmFormPageImpl) in FmFormPage::SetModel" );
+ }
+ }
+}
+
+//------------------------------------------------------------------
+SdrPage* FmFormPage::Clone() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::Clone" );
+ return new FmFormPage(*this);
+ // hier fehlt noch ein kopieren der Objekte
+}
+
+//------------------------------------------------------------------
+void FmFormPage::InsertObject(SdrObject* pObj, ULONG nPos,
+ const SdrInsertReason* pReason)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::InsertObject" );
+ SdrPage::InsertObject( pObj, nPos, pReason );
+#ifndef SVX_LIGHT
+ if (GetModel() && (!pReason || pReason->GetReason() != SDRREASON_STREAMING))
+ ((FmFormModel*)GetModel())->GetUndoEnv().Inserted(pObj);
+#endif
+}
+
+//------------------------------------------------------------------
+const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > & FmFormPage::GetForms( bool _bForceCreate ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::GetForms" );
+#ifndef SVX_LIGHT
+ const SdrPage& rMasterPage( *this );
+ const FmFormPage* pFormPage = dynamic_cast< const FmFormPage* >( &rMasterPage );
+ OSL_ENSURE( pFormPage, "FmFormPage::GetForms: referenced page is no FmFormPage - is this allowed?!" );
+ if ( !pFormPage )
+ pFormPage = this;
+
+ return pFormPage->m_pImpl->getForms( _bForceCreate );
+#else
+ static ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > aRef;
+ return aRef;
+#endif
+}
+
+//------------------------------------------------------------------
+sal_Bool FmFormPage::RequestHelp( Window* pWindow, SdrView* pView,
+ const HelpEvent& rEvt )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::RequestHelp" );
+#ifndef SVX_LIGHT
+ if( pView->IsAction() )
+ return sal_False;
+
+ Point aPos = rEvt.GetMousePosPixel();
+ aPos = pWindow->ScreenToOutputPixel( aPos );
+ aPos = pWindow->PixelToLogic( aPos );
+
+ SdrObject* pObj = NULL;
+ SdrPageView* pPV = NULL;
+ if ( !pView->PickObj( aPos, 0, pObj, pPV, SDRSEARCH_DEEP ) )
+ return sal_False;
+
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
+ if ( !pFormObject )
+ return sal_False;
+
+ UniString aHelpText;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xSet( pFormObject->GetUnoControlModel(), ::com::sun::star::uno::UNO_QUERY );
+ if (xSet.is())
+ {
+ if (::comphelper::hasProperty(FM_PROP_HELPTEXT, xSet))
+ aHelpText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_HELPTEXT)).getStr();
+
+ if (!aHelpText.Len() && ::comphelper::hasProperty(FM_PROP_TARGET_URL, xSet))
+ {
+ ::rtl::OUString aText = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_TARGET_URL));
+ INetURLObject aUrl(aText);
+
+ // testen, ob es ein Protokoll-Typ ist, den ich anzeigen will
+ INetProtocol aProtocol = aUrl.GetProtocol();
+ static const INetProtocol s_aQuickHelpSupported[] =
+ { INET_PROT_FTP, INET_PROT_HTTP, INET_PROT_FILE, INET_PROT_MAILTO, INET_PROT_NEWS,
+ INET_PROT_HTTPS, INET_PROT_JAVASCRIPT, INET_PROT_IMAP, INET_PROT_POP3,
+ INET_PROT_VIM, INET_PROT_LDAP
+ };
+ for (sal_uInt16 i=0; i < SAL_N_ELEMENTS(s_aQuickHelpSupported); ++i)
+ if (s_aQuickHelpSupported[i] == aProtocol)
+ {
+ aHelpText = INetURLObject::decode(aUrl.GetURLNoPass(), '%', INetURLObject::DECODE_UNAMBIGUOUS);
+ break;
+ }
+ }
+ }
+ if ( aHelpText.Len() != 0 )
+ {
+ // Hilfe anzeigen
+ Rectangle aItemRect = pObj->GetCurrentBoundRect();
+ aItemRect = pWindow->LogicToPixel( aItemRect );
+ Point aPt = pWindow->OutputToScreenPixel( aItemRect.TopLeft() );
+ aItemRect.Left() = aPt.X();
+ aItemRect.Top() = aPt.Y();
+ aPt = pWindow->OutputToScreenPixel( aItemRect.BottomRight() );
+ aItemRect.Right() = aPt.X();
+ aItemRect.Bottom() = aPt.Y();
+ if( rEvt.GetMode() == HELPMODE_BALLOON )
+ Help::ShowBalloon( pWindow, aItemRect.Center(), aItemRect, aHelpText);
+ else
+ Help::ShowQuickHelp( pWindow, aItemRect, aHelpText );
+ }
+#endif
+ return sal_True;
+}
+
+//------------------------------------------------------------------
+SdrObject* FmFormPage::RemoveObject(ULONG nObjNum)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPage::RemoveObject" );
+ SdrObject* pObj = SdrPage::RemoveObject(nObjNum);
+#ifndef SVX_LIGHT
+ if (pObj && GetModel())
+ ((FmFormModel*)GetModel())->GetUndoEnv().Removed(pObj);
+#endif
+ return pObj;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmpgeimp.cxx b/svx/source/form/fmpgeimp.cxx
new file mode 100644
index 000000000000..44f2067b510d
--- /dev/null
+++ b/svx/source/form/fmpgeimp.cxx
@@ -0,0 +1,742 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svxerr.hxx"
+#include "fmpgeimp.hxx"
+#include "fmundo.hxx"
+#include "svx/fmtools.hxx"
+#include "fmprop.hrc"
+#include "fmservs.hxx"
+#include "fmobj.hxx"
+#include "formcontrolfactory.hxx"
+#include "svditer.hxx"
+#include "fmresids.hrc"
+#include "svx/dbtoolsclient.hxx"
+#include "treevisitor.hxx"
+
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/container/EnumerableMap.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+
+#include <sfx2/objsh.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/fmpage.hxx>
+#include <svx/fmmodel.hxx>
+#include <tools/resid.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/shl.hxx>
+#include <vcl/stdtext.hxx>
+#include <svx/dialmgr.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/types.hxx>
+#include <unotools/streamwrap.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::form;
+using ::com::sun::star::util::XCloneable;
+using ::com::sun::star::awt::XControlModel;
+using ::com::sun::star::container::XMap;
+using ::com::sun::star::container::EnumerableMap;
+using ::com::sun::star::drawing::XControlShape;
+using namespace ::svxform;
+
+DBG_NAME(FmFormPageImpl)
+//------------------------------------------------------------------------------
+FmFormPageImpl::FmFormPageImpl( FmFormPage& _rPage )
+ :m_rPage( _rPage )
+ ,m_bFirstActivation( sal_True )
+ ,m_bAttemptedFormCreation( false )
+ ,m_bInFind( false )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::FmFormPageImpl" );
+ DBG_CTOR(FmFormPageImpl,NULL);
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ typedef Reference< XInterface > FormComponent;
+
+ class FormComponentInfo
+ {
+ public:
+ size_t childCount( const FormComponent& _component ) const
+ {
+ Reference< XIndexAccess > xContainer( _component, UNO_QUERY );
+ if ( xContainer.is() )
+ return xContainer->getCount();
+ return 0;
+ }
+
+ FormComponent getChild( const FormComponent& _component, size_t _index ) const
+ {
+ Reference< XIndexAccess > xContainer( _component, UNO_QUERY_THROW );
+ return FormComponent( xContainer->getByIndex( _index ), UNO_QUERY );
+ }
+ };
+
+ typedef ::std::pair< FormComponent, FormComponent > FormComponentPair;
+
+ class FormHierarchyComparator
+ {
+ public:
+ FormHierarchyComparator()
+ {
+ }
+
+ size_t childCount( const FormComponentPair& _components ) const
+ {
+ size_t lhsCount = m_aComponentInfo.childCount( _components.first );
+ size_t rhsCount = m_aComponentInfo.childCount( _components.second );
+ if ( lhsCount != rhsCount )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Found inconsistent form component hierarchies (1)!" ) ), NULL );
+ return lhsCount;
+ }
+
+ FormComponentPair getChild( const FormComponentPair& _components, size_t _index ) const
+ {
+ return FormComponentPair(
+ m_aComponentInfo.getChild( _components.first, _index ),
+ m_aComponentInfo.getChild( _components.second, _index )
+ );
+ }
+ private:
+ FormComponentInfo m_aComponentInfo;
+ };
+
+ typedef ::std::map< Reference< XControlModel >, Reference< XControlModel >, ::comphelper::OInterfaceCompare< XControlModel > > MapControlModels;
+
+ class FormComponentAssignment
+ {
+ public:
+ FormComponentAssignment( MapControlModels& _out_controlModelMap )
+ :m_rControlModelMap( _out_controlModelMap )
+ {
+ }
+
+ void process( const FormComponentPair& _component )
+ {
+ Reference< XControlModel > lhsControlModel( _component.first, UNO_QUERY );
+ Reference< XControlModel > rhsControlModel( _component.second, UNO_QUERY );
+ if ( lhsControlModel.is() != rhsControlModel.is() )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Found inconsistent form component hierarchies (2)!" ) ), NULL );
+
+ if ( lhsControlModel.is() )
+ m_rControlModelMap[ lhsControlModel ] = rhsControlModel;
+ }
+
+ private:
+ MapControlModels& m_rControlModelMap;
+ };
+}
+
+//------------------------------------------------------------------------------
+FmFormPageImpl::FmFormPageImpl( FmFormPage& _rPage, const FmFormPageImpl& rImpl )
+ :m_rPage( _rPage )
+ ,m_bFirstActivation( sal_True )
+ ,m_bAttemptedFormCreation( false )
+{
+ DBG_CTOR(FmFormPageImpl,NULL);
+
+ // clone the Forms collection
+ Reference< XCloneable > xCloneable( const_cast< FmFormPageImpl& >( rImpl ).getForms( false ), UNO_QUERY );
+ if ( !xCloneable.is() )
+ {
+ // great, nothing to do
+ OSL_ENSURE( !const_cast< FmFormPageImpl& >( rImpl ).getForms( false ).is(), "FmFormPageImpl::FmFormPageImpl: a non-cloneable forms container!?" );
+ return;
+ }
+ try
+ {
+ m_xForms.set( xCloneable->createClone(), UNO_QUERY_THROW );
+
+ // create a mapping between the original control models and their clones
+ MapControlModels aModelAssignment;
+
+ typedef TreeVisitor< FormComponentPair, FormHierarchyComparator, FormComponentAssignment > FormComponentVisitor;
+ FormComponentVisitor aVisitor = FormComponentVisitor( FormHierarchyComparator() );
+
+ FormComponentAssignment aAssignmentProcessor( aModelAssignment );
+ aVisitor.process( FormComponentPair( xCloneable, m_xForms ), aAssignmentProcessor );
+
+ // assign the cloned models to their SdrObjects
+ SdrObjListIter aForeignIter( rImpl.m_rPage );
+ SdrObjListIter aOwnIter( m_rPage );
+
+ OSL_ENSURE( aForeignIter.IsMore() == aOwnIter.IsMore(), "FmFormPageImpl::FmFormPageImpl: inconsistent number of objects (1)!" );
+ while ( aForeignIter.IsMore() && aOwnIter.IsMore() )
+ {
+ FmFormObj* pForeignObj = dynamic_cast< FmFormObj* >( aForeignIter.Next() );
+ FmFormObj* pOwnObj = dynamic_cast< FmFormObj* >( aOwnIter.Next() );
+
+ bool bForeignIsForm = pForeignObj && ( pForeignObj->GetObjInventor() == FmFormInventor );
+ bool bOwnIsForm = pOwnObj && ( pOwnObj->GetObjInventor() == FmFormInventor );
+
+ if ( bForeignIsForm != bOwnIsForm )
+ {
+ OSL_ENSURE( false, "FmFormPageImpl::FmFormPageImpl: inconsistent ordering of objects!" );
+ // don't attempt to do further assignments, something's completely messed up
+ break;
+ }
+ if ( !bForeignIsForm )
+ // no form control -> next round
+ continue;
+
+ Reference< XControlModel > xForeignModel( pForeignObj->GetUnoControlModel() );
+ OSL_ENSURE( xForeignModel.is(), "FmFormPageImpl::FmFormPageImpl: control shape without control!" );
+ if ( !xForeignModel.is() )
+ // the SdrObject does not have a UNO Control Model. This is pathological, but well ... So the cloned
+ // SdrObject will also not have a UNO Control Model.
+ continue;
+
+ OSL_ENSURE( !pOwnObj->GetUnoControlModel().is(), "FmFormPageImpl::FmFormPageImpl: there already is a control model for the target object!" );
+
+ MapControlModels::const_iterator assignment = aModelAssignment.find( xForeignModel );
+ OSL_ENSURE( assignment != aModelAssignment.end(), "FmFormPageImpl::FmFormPageImpl: no clone found for this model!" );
+ if ( assignment == aModelAssignment.end() )
+ // the source SdrObject has a model, but it is not part of the model hierarchy in rImpl.getForms().
+ // Pathological, too ...
+ continue;
+
+ pOwnObj->SetUnoControlModel( assignment->second );
+ }
+ OSL_ENSURE( aForeignIter.IsMore() == aOwnIter.IsMore(), "FmFormPageImpl::FmFormPageImpl: inconsistent number of objects (2)!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+Reference< XMap > FmFormPageImpl::getControlToShapeMap()
+{
+ Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY );
+ if ( xControlShapeMap.is() )
+ return xControlShapeMap;
+
+ xControlShapeMap = impl_createControlShapeMap_nothrow();
+ m_aControlShapeMap = xControlShapeMap;
+ return xControlShapeMap;
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ static void lcl_insertFormObject_throw( const FmFormObj& _object, const Reference< XMap >& _map )
+ {
+ // the control model
+ Reference< XControlModel > xControlModel( _object.GetUnoControlModel(), UNO_QUERY );
+ OSL_ENSURE( xControlModel.is(), "lcl_insertFormObject_throw: suspicious: no control model!" );
+ if ( !xControlModel.is() )
+ return;
+
+ Reference< XControlShape > xControlShape( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY );
+ OSL_ENSURE( xControlShape.is(), "lcl_insertFormObject_throw: suspicious: no control shape!" );
+ if ( !xControlShape.is() )
+ return;
+
+ _map->put( makeAny( xControlModel ), makeAny( xControlShape ) );
+ }
+
+ static void lcl_removeFormObject( const FmFormObj& _object, const Reference< XMap >& _map )
+ {
+ // the control model
+ Reference< XControlModel > xControlModel( _object.GetUnoControlModel(), UNO_QUERY );
+ OSL_ENSURE( xControlModel.is(), "lcl_removeFormObject: suspicious: no control model!" );
+ if ( !xControlModel.is() )
+ return;
+
+ #if OSL_DEBUG_LEVEL > 0
+ Any aOldAssignment =
+ #endif
+ _map->remove( makeAny( xControlModel ) );
+ OSL_ENSURE( aOldAssignment == makeAny( Reference< XControlShape >( const_cast< FmFormObj& >( _object ).getUnoShape(), UNO_QUERY ) ),
+ "lcl_removeFormObject: map was inconsistent!" );
+ }
+}
+
+//------------------------------------------------------------------------------
+Reference< XMap > FmFormPageImpl::impl_createControlShapeMap_nothrow()
+{
+ Reference< XMap > xMap;
+
+ try
+ {
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ xMap.set( EnumerableMap::create( aContext.getUNOContext(),
+ ::cppu::UnoType< XControlModel >::get(),
+ ::cppu::UnoType< XControlShape >::get()
+ ).get(), UNO_SET_THROW );
+
+ SdrObjListIter aPageIter( m_rPage );
+ while ( aPageIter.IsMore() )
+ {
+ // only FmFormObjs are what we're interested in
+ FmFormObj* pCurrent = FmFormObj::GetFormObject( aPageIter.Next() );
+ if ( !pCurrent )
+ continue;
+
+ lcl_insertFormObject_throw( *pCurrent, xMap );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xMap;
+}
+
+//------------------------------------------------------------------------------
+const Reference< XNameContainer >& FmFormPageImpl::getForms( bool _bForceCreate )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::getForms" );
+ if ( m_xForms.is() || !_bForceCreate )
+ return m_xForms;
+
+ if ( !m_bAttemptedFormCreation )
+ {
+ m_bAttemptedFormCreation = true;
+
+ const ::rtl::OUString sFormsCollectionServiceName = ::rtl::OUString::createFromAscii("com.sun.star.form.Forms");
+ m_xForms = Reference< XNameContainer > (
+ ::comphelper::getProcessServiceFactory()->createInstance( sFormsCollectionServiceName ),
+ UNO_QUERY
+ );
+ DBG_ASSERT( m_xForms.is(), "FmFormPageImpl::getForms: could not create a forms collection!" );
+
+ if ( m_aFormsCreationHdl.IsSet() )
+ {
+ m_aFormsCreationHdl.Call( this );
+ }
+
+ FmFormModel* pFormsModel = PTR_CAST( FmFormModel, m_rPage.GetModel() );
+
+ // give the newly created collection a place in the universe
+ Reference< XChild > xAsChild( m_xForms, UNO_QUERY );
+ if ( xAsChild.is() )
+ {
+ SfxObjectShell* pObjShell = pFormsModel ? pFormsModel->GetObjectShell() : NULL;
+ if ( pObjShell )
+ xAsChild->setParent( pObjShell->GetModel() );
+ }
+
+ // tell the UNDO environment that we have a new forms collection
+ if ( pFormsModel )
+ pFormsModel->GetUndoEnv().AddForms( m_xForms );
+ }
+ return m_xForms;
+}
+
+//------------------------------------------------------------------------------
+FmFormPageImpl::~FmFormPageImpl()
+{
+ xCurrentForm = NULL;
+
+ ::comphelper::disposeComponent( m_xForms );
+ DBG_DTOR(FmFormPageImpl,NULL);
+}
+
+//------------------------------------------------------------------------------
+bool FmFormPageImpl::validateCurForm()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::validateCurForm" );
+ if ( !xCurrentForm.is() )
+ return false;
+
+ Reference< XChild > xAsChild( xCurrentForm, UNO_QUERY );
+ DBG_ASSERT( xAsChild.is(), "FmFormPageImpl::validateCurForm: a form which is no child??" );
+ if ( !xAsChild.is() || !xAsChild->getParent().is() )
+ xCurrentForm.clear();
+
+ return xCurrentForm.is();
+}
+
+//------------------------------------------------------------------------------
+void FmFormPageImpl::setCurForm(Reference< ::com::sun::star::form::XForm > xForm)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::setCurForm" );
+ xCurrentForm = xForm;
+}
+
+//------------------------------------------------------------------------------
+Reference< XForm > FmFormPageImpl::getDefaultForm()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::getDefaultForm" );
+ Reference< XForm > xForm;
+
+ Reference< XNameContainer > xForms( getForms() );
+
+ // by default, we use our "current form"
+ if ( !validateCurForm() )
+ {
+ // check whether there is a "standard" form
+ if ( xForms->hasElements() )
+ {
+ // suche die Standardform
+ ::rtl::OUString sStandardFormname = String( SVX_RES( RID_STR_STDFORMNAME ) );
+
+ try
+ {
+ if ( xForms->hasByName( sStandardFormname ) )
+ xForm.set( xForms->getByName( sStandardFormname ), UNO_QUERY_THROW );
+ else
+ {
+ Reference< XIndexAccess > xFormsByIndex( xForms, UNO_QUERY_THROW );
+ xForm.set( xFormsByIndex->getByIndex(0), UNO_QUERY_THROW );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ else
+ {
+ xForm = xCurrentForm;
+ }
+
+ // did not find an existing suitable form -> create a new one
+ if ( !xForm.is() )
+ {
+ SdrModel* pModel = m_rPage.GetModel();
+
+ if( pModel->IsUndoEnabled() )
+ {
+ XubString aStr(SVX_RES(RID_STR_FORM));
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+ aUndoStr.SearchAndReplace('#', aStr);
+ pModel->BegUndo(aUndoStr);
+ }
+
+ try
+ {
+ xForm.set( ::comphelper::getProcessServiceFactory()->createInstance( FM_SUN_COMPONENT_FORM ), UNO_QUERY );
+
+ // a form should always have the command type table as default
+ Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW );
+ xFormProps->setPropertyValue( FM_PROP_COMMANDTYPE, makeAny( sal_Int32( CommandType::TABLE ) ) );
+
+ // and the "Standard" name
+ ::rtl::OUString sName = String( SVX_RES( RID_STR_STDFORMNAME ) );
+ xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) );
+
+ Reference< XIndexContainer > xContainer( xForms, UNO_QUERY );
+ if( pModel->IsUndoEnabled() )
+ {
+ pModel->AddUndo(new FmUndoContainerAction(*(FmFormModel*)pModel,
+ FmUndoContainerAction::Inserted,
+ xContainer,
+ xForm,
+ xContainer->getCount()));
+ }
+ xForms->insertByName( sName, makeAny( xForm ) );
+ xCurrentForm = xForm;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ xForm.clear();
+ }
+
+ if( pModel->IsUndoEnabled() )
+ pModel->EndUndo();
+ }
+
+ return xForm;
+}
+
+//------------------------------------------------------------------------------
+Reference< ::com::sun::star::form::XForm > FmFormPageImpl::findPlaceInFormComponentHierarchy(
+ const Reference< XFormComponent > & rContent, const Reference< XDataSource > & rDatabase,
+ const ::rtl::OUString& rDBTitle, const ::rtl::OUString& rCursorSource, sal_Int32 nCommandType )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::findPlaceInFormComponentHierarchy" );
+ // if the control already is child of a form, don't do anything
+ if (!rContent.is() || rContent->getParent().is())
+ return NULL;
+
+ Reference< XForm > xForm;
+
+ // Wenn Datenbank und CursorSource gesetzt sind, dann wird
+ // die Form anhand dieser Kriterien gesucht, ansonsten nur aktuelle
+ // und die StandardForm
+ if (rDatabase.is() && rCursorSource.getLength())
+ {
+ validateCurForm();
+
+ // erst in der aktuellen form suchen
+ xForm = findFormForDataSource( xCurrentForm, rDatabase, rCursorSource, nCommandType );
+
+ Reference< ::com::sun::star::container::XIndexAccess > xFormsByIndex( getForms(), UNO_QUERY );
+ DBG_ASSERT(xFormsByIndex.is(), "FmFormPageImpl::findPlaceInFormComponentHierarchy : no index access for my forms collection !");
+ sal_Int32 nCount = xFormsByIndex->getCount();
+ for (sal_Int32 i = 0; !xForm.is() && i < nCount; i++)
+ {
+ Reference< ::com::sun::star::form::XForm > xToSearch;
+ xFormsByIndex->getByIndex(i) >>= xToSearch;
+ xForm = findFormForDataSource( xToSearch, rDatabase, rCursorSource, nCommandType );
+ }
+
+ // wenn keine ::com::sun::star::form gefunden, dann eine neue erzeugen
+ if (!xForm.is())
+ {
+ SdrModel* pModel = m_rPage.GetModel();
+
+ const bool bUndo = pModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString aStr(SVX_RES(RID_STR_FORM));
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+ aUndoStr.SearchAndReplace('#', aStr);
+ pModel->BegUndo(aUndoStr);
+ }
+
+ xForm = Reference< ::com::sun::star::form::XForm >(::comphelper::getProcessServiceFactory()->createInstance(FM_SUN_COMPONENT_FORM), UNO_QUERY);
+ // a form should always have the command type table as default
+ Reference< ::com::sun::star::beans::XPropertySet > xFormProps(xForm, UNO_QUERY);
+ try { xFormProps->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny(sal_Int32(CommandType::TABLE))); }
+ catch(Exception&) { }
+
+ if (rDBTitle.getLength())
+ xFormProps->setPropertyValue(FM_PROP_DATASOURCE,makeAny(rDBTitle));
+ else
+ {
+ Reference< ::com::sun::star::beans::XPropertySet > xDatabaseProps(rDatabase, UNO_QUERY);
+ Any aDatabaseUrl = xDatabaseProps->getPropertyValue(FM_PROP_URL);
+ xFormProps->setPropertyValue(FM_PROP_DATASOURCE, aDatabaseUrl);
+ }
+
+ xFormProps->setPropertyValue(FM_PROP_COMMAND,makeAny(rCursorSource));
+ xFormProps->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny(nCommandType));
+
+ Reference< ::com::sun::star::container::XNameAccess > xNamedSet( getForms(), UNO_QUERY );
+
+ const bool bTableOrQuery = ( CommandType::TABLE == nCommandType ) || ( CommandType::QUERY == nCommandType );
+ ::rtl::OUString sName = FormControlFactory::getUniqueName( xNamedSet,
+ bTableOrQuery ? rCursorSource : ::rtl::OUString( String( SVX_RES( RID_STR_STDFORMNAME ) ) ) );
+
+ xFormProps->setPropertyValue( FM_PROP_NAME, makeAny( sName ) );
+
+ if( bUndo )
+ {
+ Reference< ::com::sun::star::container::XIndexContainer > xContainer( getForms(), UNO_QUERY );
+ pModel->AddUndo(new FmUndoContainerAction(*(FmFormModel*)pModel,
+ FmUndoContainerAction::Inserted,
+ xContainer,
+ xForm,
+ xContainer->getCount()));
+ }
+
+ getForms()->insertByName( sName, makeAny( xForm ) );
+
+ if( bUndo )
+ pModel->EndUndo();
+ }
+ xCurrentForm = xForm;
+ }
+
+ xForm = getDefaultForm();
+ return xForm;
+}
+
+//------------------------------------------------------------------------------
+Reference< XForm > FmFormPageImpl::findFormForDataSource(
+ const Reference< XForm > & rForm, const Reference< XDataSource > & _rxDatabase,
+ const ::rtl::OUString& _rCursorSource, sal_Int32 nCommandType)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFormPageImpl::findFormForDataSource" );
+ Reference< XForm > xResultForm;
+ Reference< XRowSet > xDBForm(rForm, UNO_QUERY);
+ Reference< XPropertySet > xFormProps(rForm, UNO_QUERY);
+ if (!xDBForm.is() || !xFormProps.is())
+ return xResultForm;
+
+ OSL_ENSURE(_rxDatabase.is(), "FmFormPageImpl::findFormForDataSource: invalid data source!");
+ ::rtl::OUString sLookupName; // the name of the data source we're looking for
+ ::rtl::OUString sFormDataSourceName; // the name of the data source the current connection in the form is based on
+ try
+ {
+ Reference< XPropertySet > xDSProps(_rxDatabase, UNO_QUERY);
+ if (xDSProps.is())
+ xDSProps->getPropertyValue(FM_PROP_NAME) >>= sLookupName;
+
+ xFormProps->getPropertyValue(FM_PROP_DATASOURCE) >>= sFormDataSourceName;
+ // if there's no DataSourceName set at the form, check whether we can deduce one from its
+ // ActiveConnection
+ if (0 == sFormDataSourceName.getLength())
+ {
+ Reference< XConnection > xFormConnection;
+ xFormProps->getPropertyValue( FM_PROP_ACTIVE_CONNECTION ) >>= xFormConnection;
+ if ( !xFormConnection.is() )
+ OStaticDataAccessTools().isEmbeddedInDatabase( xFormProps, xFormConnection );
+ if (xFormConnection.is())
+ {
+ Reference< XChild > xConnAsChild(xFormConnection, UNO_QUERY);
+ if (xConnAsChild.is())
+ {
+ Reference< XDataSource > xFormDS(xConnAsChild->getParent(), UNO_QUERY);
+ if (xFormDS.is())
+ {
+ xDSProps = xDSProps.query(xFormDS);
+ if (xDSProps.is())
+ xDSProps->getPropertyValue(FM_PROP_NAME) >>= sFormDataSourceName;
+ }
+ }
+ }
+ }
+ }
+ catch(const Exception& e)
+ {
+ (void)e;
+ OSL_ENSURE(sal_False, "FmFormPageImpl::findFormForDataSource: caught an exception!");
+ }
+
+ if (sLookupName == sFormDataSourceName)
+ {
+ // jetzt noch ueberpruefen ob CursorSource und Type uebereinstimmen
+ ::rtl::OUString aCursorSource = ::comphelper::getString(xFormProps->getPropertyValue(FM_PROP_COMMAND));
+ sal_Int32 nType = ::comphelper::getINT32(xFormProps->getPropertyValue(FM_PROP_COMMANDTYPE));
+ if (!aCursorSource.getLength() || ((nType == nCommandType) && (aCursorSource == _rCursorSource))) // found the form
+ {
+ xResultForm = rForm;
+ // Ist noch keine Datenquelle gesetzt, wird dieses hier nachgeholt
+ if (!aCursorSource.getLength())
+ {
+ xFormProps->setPropertyValue(FM_PROP_COMMAND, makeAny(_rCursorSource));
+ xFormProps->setPropertyValue(FM_PROP_COMMANDTYPE, makeAny((sal_Int32)nCommandType));
+ }
+ }
+ }
+
+ // as long as xResultForm is NULL, search the child forms of rForm
+ Reference< XIndexAccess > xComponents(rForm, UNO_QUERY);
+ sal_Int32 nCount = xComponents->getCount();
+ for (sal_Int32 i = 0; !xResultForm.is() && i < nCount; ++i)
+ {
+ Reference< ::com::sun::star::form::XForm > xSearchForm;
+ xComponents->getByIndex(i) >>= xSearchForm;
+ // continue searching in the sub form
+ if (xSearchForm.is())
+ xResultForm = findFormForDataSource( xSearchForm, _rxDatabase, _rCursorSource, nCommandType );
+ }
+ return xResultForm;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString FmFormPageImpl::setUniqueName(const Reference< XFormComponent > & xFormComponent, const Reference< XForm > & xControls)
+{
+#if OSL_DEBUG_LEVEL > 0
+ try
+ {
+ Reference< XChild > xChild( xFormComponent, UNO_QUERY_THROW );
+ OSL_ENSURE( !xChild->getParent().is(), "FmFormPageImpl::setUniqueName: to be called before insertion!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+#endif
+ ::rtl::OUString sName;
+ Reference< ::com::sun::star::beans::XPropertySet > xSet(xFormComponent, UNO_QUERY);
+ if (xSet.is())
+ {
+ sName = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_NAME ) );
+ Reference< ::com::sun::star::container::XNameAccess > xNameAcc(xControls, UNO_QUERY);
+
+ if (!sName.getLength() || xNameAcc->hasByName(sName))
+ {
+ // setzen eines default Namens ueber die ClassId
+ sal_Int16 nClassId( FormComponentType::CONTROL );
+ xSet->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId;
+
+ ::rtl::OUString sDefaultName = FormControlFactory::getDefaultUniqueName_ByComponentType(
+ Reference< XNameAccess >( xControls, UNO_QUERY ), xSet );
+
+ // bei Radiobuttons, die einen Namen haben, diesen nicht ueberschreiben!
+ if (!sName.getLength() || nClassId != ::com::sun::star::form::FormComponentType::RADIOBUTTON)
+ {
+ xSet->setPropertyValue(FM_PROP_NAME, makeAny(sDefaultName));
+ }
+
+ sName = sDefaultName;
+ }
+ }
+ return sName;
+}
+
+//------------------------------------------------------------------
+void FmFormPageImpl::formObjectInserted( const FmFormObj& _object )
+{
+ Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY );
+ if ( !xControlShapeMap.is() )
+ // our map does not exist -> not interested in this event
+ return;
+
+ try
+ {
+ lcl_insertFormObject_throw( _object, xControlShapeMap );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+void FmFormPageImpl::formObjectRemoved( const FmFormObj& _object )
+{
+ Reference< XMap > xControlShapeMap( m_aControlShapeMap.get(), UNO_QUERY );
+ if ( !xControlShapeMap.is() )
+ // our map does not exist -> not interested in this event
+ return;
+
+ try
+ {
+ lcl_removeFormObject( _object, xControlShapeMap );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmscriptingenv.cxx b/svx/source/form/fmscriptingenv.cxx
new file mode 100644
index 000000000000..af6f46aa95d3
--- /dev/null
+++ b/svx/source/form/fmscriptingenv.cxx
@@ -0,0 +1,580 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "fmscriptingenv.hxx"
+#include <svx/fmmodel.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/script/XScriptListener.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/EventObject.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+/** === end UNO includes === **/
+#include <tools/diagnose_ex.h>
+#include <cppuhelper/implbase1.hxx>
+#include <comphelper/implementationreference.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/processfactory.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <sfx2/objsh.hxx>
+
+#include <boost/shared_ptr.hpp>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::script::XEventAttacherManager;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::script::XScriptListener;
+ using ::com::sun::star::script::ScriptEvent;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::reflection::InvocationTargetException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::container::XHierarchicalNameAccess;
+ using ::com::sun::star::reflection::XInterfaceMethodTypeDescription;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::awt::XControl;
+ using ::com::sun::star::beans::XPropertySet;
+ /** === end UNO using === **/
+
+ class FormScriptingEnvironment;
+
+ //====================================================================
+ //= FormScriptListener
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < XScriptListener
+ > FormScriptListener_Base;
+
+ /** implements the XScriptListener interface, is used by FormScriptingEnvironment
+ */
+ class FormScriptListener :public FormScriptListener_Base
+ {
+ private:
+ ::osl::Mutex m_aMutex;
+ ::rtl::Reference< FormScriptingEnvironment > m_pScriptExecutor;
+
+ public:
+ FormScriptListener( const ::rtl::Reference< FormScriptingEnvironment >& _pScriptExecutor );
+
+ // XScriptListener
+ virtual void SAL_CALL firing( const ScriptEvent& aEvent ) throw (RuntimeException);
+ virtual Any SAL_CALL approveFiring( const ScriptEvent& aEvent ) throw (InvocationTargetException, RuntimeException);
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+
+ // lifetime control
+ void SAL_CALL dispose();
+
+ protected:
+ ~FormScriptListener();
+
+ private:
+ /** determines whether calling a given method at a given listener interface can be done asynchronously
+
+ @param _rListenerType
+ the name of the UNO type whose method is to be checked
+ @param _rMethodName
+ the name of the method at the interface determined by _rListenerType
+
+ @return
+ <TRUE/> if and only if the method is declared <code>oneway</code>, i.e. can be called asynchronously
+ */
+ bool impl_allowAsynchronousCall_nothrow( const ::rtl::OUString& _rListenerType, const ::rtl::OUString& _rMethodName ) const;
+
+ /** determines whether the instance is already disposed
+ */
+ bool impl_isDisposed_nothrow() const { return !m_pScriptExecutor.is(); }
+
+ /** fires the given script event in a thread-safe manner
+
+ This methods calls our script executor's doFireScriptEvent, with previously releasing the given mutex guard,
+ but ensuring that our script executor is not deleted between this release and the actual call.
+
+ @param _rGuard
+ a clearable guard to our mutex. Must be the only active guard to our mutex.
+ @param _rEvent
+ the event to fire
+ @param _pSyncronousResult
+ a place to take a possible result of the script call.
+
+ @precond
+ m_pScriptExecutor is not <NULL/>.
+ */
+ void impl_doFireScriptEvent_nothrow( ::osl::ClearableMutexGuard& _rGuard, const ScriptEvent& _rEvent, Any* _pSyncronousResult );
+
+ private:
+ DECL_LINK( OnAsyncScriptEvent, ScriptEvent* );
+ };
+
+ //====================================================================
+ //= FormScriptingEnvironment
+ //====================================================================
+ class FormScriptingEnvironment : public IFormScriptingEnvironment
+ {
+ private:
+ typedef ::comphelper::ImplementationReference< FormScriptListener, XScriptListener > ListenerImplementation;
+
+ private:
+ ::osl::Mutex m_aMutex;
+ oslInterlockedCount m_refCount;
+ ListenerImplementation m_pScriptListener;
+ FmFormModel& m_rFormModel;
+ bool m_bDisposed;
+
+ public:
+ FormScriptingEnvironment( FmFormModel& _rModel );
+ virtual ~FormScriptingEnvironment();
+
+ // callback for FormScriptListener
+ void doFireScriptEvent( const ScriptEvent& _rEvent, Any* _pSyncronousResult );
+
+ // IFormScriptingEnvironment
+ virtual void registerEventAttacherManager( const Reference< XEventAttacherManager >& _rxManager );
+ virtual void revokeEventAttacherManager( const Reference< XEventAttacherManager >& _rxManager );
+ virtual void dispose();
+
+ // IReference
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+
+ private:
+ void impl_registerOrRevoke_throw( const Reference< XEventAttacherManager >& _rxManager, bool _bRegister );
+
+ private:
+ FormScriptingEnvironment(); // never implemented
+ FormScriptingEnvironment( const FormScriptingEnvironment& ); // never implemented
+ FormScriptingEnvironment& operator=( const FormScriptingEnvironment& ); // never implemented
+ };
+
+ //====================================================================
+ //= FormScriptListener
+ //====================================================================
+ //--------------------------------------------------------------------
+ FormScriptListener::FormScriptListener( const ::rtl::Reference< FormScriptingEnvironment >& _pScriptExecutor )
+ :m_pScriptExecutor( _pScriptExecutor )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ FormScriptListener::~FormScriptListener()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool FormScriptListener::impl_allowAsynchronousCall_nothrow( const ::rtl::OUString& _rListenerType, const ::rtl::OUString& _rMethodName ) const
+ {
+ bool bAllowAsynchronousCall = false;
+ try
+ {
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference< XHierarchicalNameAccess > xTypeDescriptions( aContext.getSingleton( "com.sun.star.reflection.theTypeDescriptionManager" ), UNO_QUERY_THROW );
+
+ ::rtl::OUString sMethodDescription( _rListenerType );
+ sMethodDescription += ::rtl::OUString::createFromAscii( "::" );
+ sMethodDescription += _rMethodName;
+
+ Reference< XInterfaceMethodTypeDescription > xMethod( xTypeDescriptions->getByHierarchicalName( sMethodDescription ), UNO_QUERY_THROW );
+ bAllowAsynchronousCall = xMethod->isOneway();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bAllowAsynchronousCall;
+ }
+
+ //--------------------------------------------------------------------
+ void FormScriptListener::impl_doFireScriptEvent_nothrow( ::osl::ClearableMutexGuard& _rGuard, const ScriptEvent& _rEvent, Any* _pSyncronousResult )
+ {
+ OSL_PRECOND( m_pScriptExecutor.is(), "FormScriptListener::impl_doFireScriptEvent_nothrow: this will crash!" );
+
+ ::rtl::Reference< FormScriptingEnvironment > pExecutor( m_pScriptExecutor );
+ _rGuard.clear();
+ pExecutor->doFireScriptEvent( _rEvent, _pSyncronousResult );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormScriptListener::firing( const ScriptEvent& _rEvent ) throw (RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ static const ::rtl::OUString vbaInterOp =
+ ::rtl::OUString::createFromAscii("VBAInterop");
+ if ( _rEvent.ScriptType.equals(vbaInterOp) )
+ return; // not handled here
+
+ if ( impl_isDisposed_nothrow() )
+ return;
+
+ if ( !impl_allowAsynchronousCall_nothrow( _rEvent.ListenerType.getTypeName(), _rEvent.MethodName ) )
+ {
+ impl_doFireScriptEvent_nothrow( aGuard, _rEvent, NULL );
+ return;
+ }
+
+ acquire();
+ Application::PostUserEvent( LINK( this, FormScriptListener, OnAsyncScriptEvent ), new ScriptEvent( _rEvent ) );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL FormScriptListener::approveFiring( const ScriptEvent& _rEvent ) throw (InvocationTargetException, RuntimeException)
+ {
+ Any aResult;
+
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ if ( !impl_isDisposed_nothrow() )
+ impl_doFireScriptEvent_nothrow( aGuard, _rEvent, &aResult );
+
+ return aResult;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormScriptListener::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormScriptListener::dispose()
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_pScriptExecutor = NULL;
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( FormScriptListener, OnAsyncScriptEvent, ScriptEvent*, _pEvent )
+ {
+ OSL_PRECOND( _pEvent != NULL, "FormScriptListener::OnAsyncScriptEvent: invalid event!" );
+ if ( !_pEvent )
+ return 1L;
+
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ if ( !impl_isDisposed_nothrow() )
+ impl_doFireScriptEvent_nothrow( aGuard, *_pEvent, NULL );
+ }
+
+ delete _pEvent;
+ // we acquired ourself immediately before posting the event
+ release();
+ return 0L;
+ }
+
+ //====================================================================
+ //= FormScriptingEnvironment
+ //====================================================================
+ //--------------------------------------------------------------------
+ FormScriptingEnvironment::FormScriptingEnvironment( FmFormModel& _rModel )
+ :m_refCount( 0 )
+ ,m_pScriptListener( NULL )
+ ,m_rFormModel( _rModel )
+ ,m_bDisposed( false )
+ {
+ m_pScriptListener = ListenerImplementation( new FormScriptListener( this ) );
+ // note that this is a cyclic reference between the FormScriptListener and the FormScriptingEnvironment
+ // This cycle is broken up when our instance is disposed.
+ }
+
+ //--------------------------------------------------------------------
+ FormScriptingEnvironment::~FormScriptingEnvironment()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void FormScriptingEnvironment::impl_registerOrRevoke_throw( const Reference< XEventAttacherManager >& _rxManager, bool _bRegister )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !_rxManager.is() )
+ throw IllegalArgumentException();
+ if ( m_bDisposed )
+ throw DisposedException();
+
+ try
+ {
+ if ( _bRegister )
+ _rxManager->addScriptListener( m_pScriptListener.getRef() );
+ else
+ _rxManager->removeScriptListener( m_pScriptListener.getRef() );
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void FormScriptingEnvironment::registerEventAttacherManager( const Reference< XEventAttacherManager >& _rxManager )
+ {
+ impl_registerOrRevoke_throw( _rxManager, true );
+ }
+
+ //--------------------------------------------------------------------
+ void FormScriptingEnvironment::revokeEventAttacherManager( const Reference< XEventAttacherManager >& _rxManager )
+ {
+ impl_registerOrRevoke_throw( _rxManager, false );
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL FormScriptingEnvironment::acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL FormScriptingEnvironment::release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ {
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+ }
+
+ //--------------------------------------------------------------------
+ IFormScriptingEnvironment::~IFormScriptingEnvironment()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //................................................................
+ //. NewStyleUNOScript
+ //................................................................
+ class SAL_NO_VTABLE IScript
+ {
+ public:
+ virtual void invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult ) = 0;
+
+ virtual ~IScript() { }
+ };
+ typedef ::boost::shared_ptr< IScript > PScript;
+
+ //................................................................
+ //. NewStyleUNOScript
+ //................................................................
+ class NewStyleUNOScript : public IScript
+ {
+ SfxObjectShell& m_rObjectShell;
+ const ::rtl::OUString m_sScriptCode;
+
+ public:
+ NewStyleUNOScript( SfxObjectShell& _rObjectShell, const ::rtl::OUString& _rScriptCode )
+ :m_rObjectShell( _rObjectShell )
+ ,m_sScriptCode( _rScriptCode )
+ {
+ }
+
+ // IScript
+ virtual void invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult );
+ };
+
+ //................................................................
+ void NewStyleUNOScript::invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult )
+ {
+ Sequence< sal_Int16 > aOutArgsIndex;
+ Sequence< Any > aOutArgs;
+ EventObject aEvent;
+ Any aCaller;
+ if ( ( _rArguments.getLength() > 0 ) && ( _rArguments[ 0 ] >>= aEvent ) )
+ {
+ try
+ {
+ Reference< XControl > xControl( aEvent.Source, UNO_QUERY_THROW );
+ Reference< XPropertySet > xProps( xControl->getModel(), UNO_QUERY_THROW );
+ aCaller = xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ) );
+ }
+ catch( Exception& ) {}
+ }
+ m_rObjectShell.CallXScript( m_sScriptCode, _rArguments, _rSynchronousResult, aOutArgsIndex, aOutArgs, true, aCaller.hasValue() ? &aCaller : 0 );
+ }
+
+ //................................................................
+ //. QualifiedBasicScript
+ //................................................................
+ class QualifiedBasicScript : public IScript
+ {
+ SfxObjectShell& m_rObjectShell;
+ const ::rtl::OUString m_sMacroLocation;
+ const ::rtl::OUString m_sScriptCode;
+
+ public:
+ QualifiedBasicScript( SfxObjectShell& _rObjectShell, const ::rtl::OUString& _rLocation, const ::rtl::OUString& _rScriptCode )
+ :m_rObjectShell( _rObjectShell )
+ ,m_sMacroLocation( _rLocation )
+ ,m_sScriptCode( _rScriptCode )
+ {
+ }
+
+ // IScript
+ virtual void invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult );
+ };
+
+ //................................................................
+ void QualifiedBasicScript::invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult )
+ {
+ m_rObjectShell.CallStarBasicScript( m_sScriptCode, m_sMacroLocation,
+ &_rArguments, &_rSynchronousResult );
+ }
+
+ //................................................................
+ //. UnqualifiedBasicScript
+ //................................................................
+ class UnqualifiedBasicScript : public IScript
+ {
+ SfxObjectShell& m_rObjectShell;
+ const ::rtl::OUString m_sScriptCode;
+
+ public:
+ UnqualifiedBasicScript( SfxObjectShell& _rObjectShell, const ::rtl::OUString& _rScriptCode )
+ :m_rObjectShell( _rObjectShell )
+ ,m_sScriptCode( _rScriptCode )
+ {
+ }
+
+ // IScript
+ virtual void invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult );
+ };
+
+ //................................................................
+ void UnqualifiedBasicScript::invoke( const Sequence< Any >& _rArguments, Any& _rSynchronousResult )
+ {
+ m_rObjectShell.CallScript( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ), m_sScriptCode,
+ &_rArguments, &_rSynchronousResult );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void FormScriptingEnvironment::doFireScriptEvent( const ScriptEvent& _rEvent, Any* _pSyncronousResult )
+ {
+ SolarMutexClearableGuard aSolarGuard;
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ if ( m_bDisposed )
+ return;
+
+ SfxObjectShellRef xObjectShell = m_rFormModel.GetObjectShell();
+ if( !xObjectShell.Is() )
+ return;
+
+ // the script to execute
+ PScript pScript;
+
+ if ( !_rEvent.ScriptType.equalsAscii( "StarBasic" ) )
+ {
+ pScript.reset( new NewStyleUNOScript( *xObjectShell, _rEvent.ScriptCode ) );
+ }
+ else
+ {
+ ::rtl::OUString sScriptCode = _rEvent.ScriptCode;
+ ::rtl::OUString sMacroLocation;
+
+ // is there a location in the script name ("application" or "document")?
+ sal_Int32 nPrefixLen = sScriptCode.indexOf( ':' );
+ DBG_ASSERT( 0 <= nPrefixLen, "FormScriptingEnvironment::doFireScriptEvent: Basic script name in old format encountered!" );
+
+ if ( 0 <= nPrefixLen )
+ {
+ // and it has such a prefix
+ sMacroLocation = sScriptCode.copy( 0, nPrefixLen );
+ DBG_ASSERT( 0 == sMacroLocation.compareToAscii( "document" )
+ || 0 == sMacroLocation.compareToAscii( "application" ),
+ "FormScriptingEnvironment::doFireScriptEvent: invalid (unknown) prefix!" );
+
+ // strip the prefix: the SfxObjectShell::CallScript knows nothing about such prefixes
+ sScriptCode = sScriptCode.copy( nPrefixLen + 1 );
+ }
+
+ if ( sMacroLocation.getLength() )
+ { // we have a StarBasic macro with fully-qualified macro location
+ pScript.reset( new QualifiedBasicScript( *xObjectShell, sMacroLocation, sScriptCode ) );
+ }
+ else
+ { // we have a StarBasic macro without qualified location - let the object shell gues ....
+ pScript.reset( new UnqualifiedBasicScript( *xObjectShell, sScriptCode ) );
+ }
+ }
+
+ OSL_ENSURE( pScript.get(), "FormScriptingEnvironment::doFireScriptEvent: no script to execute!" );
+ if ( !pScript.get() )
+ // this is an internal error in the above code
+ throw RuntimeException();
+
+ aGuard.clear();
+ aSolarGuard.clear();
+
+ Any aIgnoreResult;
+ pScript->invoke( _rEvent.Arguments, _pSyncronousResult ? *_pSyncronousResult : aIgnoreResult );
+ pScript.reset();
+
+ {
+ // object shells are not thread safe, so guard the destruction
+ SolarMutexGuard aSolarGuarsReset;
+ xObjectShell = NULL;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void FormScriptingEnvironment::dispose()
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_bDisposed = true;
+ m_pScriptListener->dispose();
+ }
+
+ //--------------------------------------------------------------------
+ PFormScriptingEnvironment createDefaultFormScriptingEnvironment( FmFormModel& _rModel )
+ {
+ return new FormScriptingEnvironment( _rModel );
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmservs.cxx b/svx/source/form/fmservs.cxx
new file mode 100644
index 000000000000..8e578f5ec030
--- /dev/null
+++ b/svx/source/form/fmservs.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/container/XSet.hpp>
+#include <cppuhelper/factory.hxx>
+#include <comphelper/processfactory.hxx>
+#include "fmservs.hxx"
+
+// ------------------------------------------------------------------------
+#define DECL_SERVICE(ImplName) \
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ImplName##_NewInstance_Impl(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &) throw( ::com::sun::star::uno::Exception );
+
+#define REGISTER_SERVICE(ImplName, ServiceName) \
+ sString = (ServiceName); \
+ xSingleFactory = ::cppu::createSingleFactory(xServiceFactory, \
+ ::rtl::OUString(), ImplName##_NewInstance_Impl, \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString>(&sString, 1)); \
+ if (xSingleFactory.is()) \
+ xSet->insert(::com::sun::star::uno::makeAny(xSingleFactory));
+
+
+ DECL_SERVICE( FmXGridControl )
+ DECL_SERVICE( FormController )
+ DECL_SERVICE( LegacyFormController )
+
+
+// ------------------------------------------------------------------------
+namespace svxform
+{
+
+#define DECL_SELFAWARE_SERVICE( ClassName ) \
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ClassName##_Create( \
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ); \
+ ::rtl::OUString SAL_CALL ClassName##_GetImplementationName(); \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL ClassName##_GetSupportedServiceNames(); \
+
+
+#define REGISTER_SELFAWARE_SERVICE( ClassName ) \
+ xSingleFactory = ::cppu::createSingleFactory( xServiceFactory, \
+ ClassName##_GetImplementationName(), \
+ ClassName##_Create, \
+ ClassName##_GetSupportedServiceNames() \
+ ); \
+ if ( xSingleFactory.is() ) \
+ xSet->insert( ::com::sun::star::uno::makeAny( xSingleFactory ) );
+
+
+ // ------------------------------------------------------------------------
+ DECL_SELFAWARE_SERVICE( OAddConditionDialog )
+
+ // ------------------------------------------------------------------------
+ void ImplSmartRegisterUnoServices()
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory(::comphelper::getProcessServiceFactory(), ::com::sun::star::uno::UNO_QUERY);
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XSet > xSet(xServiceFactory, ::com::sun::star::uno::UNO_QUERY);
+ if (!xSet.is())
+ return;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString> aServices;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > xSingleFactory;
+
+ ::rtl::OUString sString;
+
+ // ------------------------------------------------------------------------
+ // FormController
+ REGISTER_SERVICE( FormController, FM_FORM_CONTROLLER );
+ REGISTER_SERVICE( LegacyFormController, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ) );
+
+ // ------------------------------------------------------------------------
+ // FormController
+ REGISTER_SELFAWARE_SERVICE( OAddConditionDialog );
+
+ // ------------------------------------------------------------------------
+ // DBGridControl
+ REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRID); // compatibility
+ REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRIDCONTROL);
+ REGISTER_SERVICE(FmXGridControl, FM_SUN_CONTROL_GRIDCONTROL);
+ };
+
+} // namespace svxform
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx
new file mode 100644
index 000000000000..3996728c4c7a
--- /dev/null
+++ b/svx/source/form/fmshell.cxx
@@ -0,0 +1,1513 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "fmvwimp.hxx"
+#include <svx/fmshell.hxx>
+#include "svx/fmtools.hxx"
+#include "fmservs.hxx"
+#include "fmprop.hrc"
+#include "fmpgeimp.hxx"
+#include "fmitems.hxx"
+#include "fmundo.hxx"
+#include <vcl/waitobj.hxx>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/whiter.hxx>
+#include <sfx2/app.hxx>
+#include <svl/intitem.hxx>
+#include <svl/visitem.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/fmpage.hxx>
+#include "svditer.hxx"
+#include "fmobj.hxx"
+
+#include <svx/svxids.hrc>
+
+#include "fmresids.hrc"
+#include "fmexch.hxx"
+#include <svx/fmglob.hxx>
+#include <svl/eitem.hxx>
+#include <tools/shl.hxx>
+#include <tools/diagnose_ex.h>
+#include <svx/svdpage.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/dialmgr.hxx>
+#include "fmshimp.hxx"
+#include <svx/svdpagv.hxx>
+#include <sfx2/objitem.hxx>
+#include <sfx2/viewsh.hxx>
+#include <vcl/sound.hxx>
+#include "fmexpl.hxx"
+#include "formcontrolling.hxx"
+#include <svl/numuno.hxx>
+#include <connectivity/dbtools.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/processfactory.hxx>
+#include "fmdocumentclassification.hxx"
+#include "formtoolbars.hxx"
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+
+#include "svx/sdrobjectfilter.hxx"
+
+#define HANDLE_SQL_ERRORS( action, successflag, context, message ) \
+ try \
+ { \
+ successflag = sal_False; \
+ action; \
+ successflag = sal_True; \
+ } \
+ catch(::com::sun::star::sdbc::SQLException& e) \
+ { \
+ ::com::sun::star::sdb::SQLContext eExtendedInfo = \
+ GetImpl()->prependContextInfo(e, Reference< XInterface > (), context, ::rtl::OUString()); \
+ displayException(eExtendedInfo); \
+ } \
+ catch(Exception&) \
+ { \
+ DBG_ERROR(message); \
+ } \
+
+
+#define DO_SAFE_WITH_ERROR( action, message ) try { action; } catch(Exception&) { DBG_ERROR(message); }
+
+#define FmFormShell
+#include "svxslots.hxx"
+
+#include <svx/svxids.hrc>
+#include "tbxform.hxx"
+#include <comphelper/property.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+// wird fuer Invalidate verwendet -> mitpflegen
+// aufsteigend sortieren !!!!!!
+sal_uInt16 ControllerSlotMap[] = // slots des Controllers
+{
+ SID_FM_CONFIG,
+ SID_FM_PUSHBUTTON,
+ SID_FM_RADIOBUTTON,
+ SID_FM_CHECKBOX,
+ SID_FM_FIXEDTEXT,
+ SID_FM_GROUPBOX,
+ SID_FM_EDIT,
+ SID_FM_LISTBOX,
+ SID_FM_COMBOBOX,
+ SID_FM_DBGRID,
+ SID_FM_IMAGEBUTTON,
+ SID_FM_FILECONTROL,
+ SID_FM_NAVIGATIONBAR,
+ SID_FM_CTL_PROPERTIES,
+ SID_FM_PROPERTIES,
+ SID_FM_TAB_DIALOG,
+ SID_FM_ADD_FIELD,
+ SID_FM_DESIGN_MODE,
+ SID_FM_SHOW_FMEXPLORER,
+ SID_FM_SHOW_PROPERTIES,
+ SID_FM_FMEXPLORER_CONTROL,
+ SID_FM_DATEFIELD,
+ SID_FM_TIMEFIELD,
+ SID_FM_NUMERICFIELD,
+ SID_FM_CURRENCYFIELD,
+ SID_FM_PATTERNFIELD,
+ SID_FM_OPEN_READONLY,
+ SID_FM_IMAGECONTROL,
+ SID_FM_USE_WIZARDS,
+ SID_FM_FORMATTEDFIELD,
+ SID_FM_FILTER_NAVIGATOR,
+ SID_FM_AUTOCONTROLFOCUS,
+ SID_FM_SCROLLBAR,
+ SID_FM_SPINBUTTON,
+ SID_FM_SHOW_DATANAVIGATOR,
+ SID_FM_DATANAVIGATOR_CONTROL,
+
+ 0
+};
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::form::runtime;
+using namespace ::com::sun::star::frame;
+using namespace ::svxform;
+
+//========================================================================
+// class FmDesignModeChangedHint
+//========================================================================
+TYPEINIT1( FmDesignModeChangedHint, SfxHint );
+
+//------------------------------------------------------------------------
+FmDesignModeChangedHint::FmDesignModeChangedHint( sal_Bool bDesMode )
+ :m_bDesignMode( bDesMode )
+{
+}
+
+//------------------------------------------------------------------------
+FmDesignModeChangedHint::~FmDesignModeChangedHint()
+{
+}
+
+//========================================================================
+const sal_uInt32 FM_UI_FEATURE_SHOW_DATABASEBAR = 0x00000001;
+const sal_uInt32 FM_UI_FEATURE_SHOW_FIELD = 0x00000002;
+const sal_uInt32 FM_UI_FEATURE_SHOW_PROPERTIES = 0x00000004;
+const sal_uInt32 FM_UI_FEATURE_SHOW_EXPLORER = 0x00000008;
+const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERBAR = 0x00000010;
+const sal_uInt32 FM_UI_FEATURE_SHOW_FILTERNAVIGATOR = 0x00000020;
+const sal_uInt32 FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR = 0x00000040;
+const sal_uInt32 FM_UI_FEATURE_TB_CONTROLS = 0x00000080;
+const sal_uInt32 FM_UI_FEATURE_TB_MORECONTROLS = 0x00000100;
+const sal_uInt32 FM_UI_FEATURE_TB_FORMDESIGN = 0x00000200;
+const sal_uInt32 FM_UI_FEATURE_SHOW_DATANAVIGATOR = 0x00000400;
+
+SFX_IMPL_INTERFACE(FmFormShell, SfxShell, SVX_RES(RID_STR_FORMSHELL))
+{
+ SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_NAVIGATION|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_READONLYDOC,
+ SVX_RES(RID_SVXTBX_FORM_NAVIGATION),
+ FM_UI_FEATURE_SHOW_DATABASEBAR );
+
+ SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_NAVIGATION|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_READONLYDOC,
+ SVX_RES(RID_SVXTBX_FORM_FILTER),
+ FM_UI_FEATURE_SHOW_FILTERBAR );
+
+ SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_READONLYDOC,
+ SVX_RES( RID_SVXTBX_TEXT_CONTROL_ATTRIBUTES ),
+ FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR );
+
+ SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_ADD_FIELD, FM_UI_FEATURE_SHOW_FIELD);
+ SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_PROPERTIES, FM_UI_FEATURE_SHOW_PROPERTIES);
+ SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_FMEXPLORER, FM_UI_FEATURE_SHOW_EXPLORER);
+ SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_FILTER_NAVIGATOR, FM_UI_FEATURE_SHOW_FILTERNAVIGATOR);
+ SFX_FEATURED_CHILDWINDOW_REGISTRATION(SID_FM_SHOW_DATANAVIGATOR, FM_UI_FEATURE_SHOW_DATANAVIGATOR);
+
+ SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD,
+ SVX_RES( RID_SVXTBX_CONTROLS ),
+ FM_UI_FEATURE_TB_CONTROLS );
+
+ SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD,
+ SVX_RES( RID_SVXTBX_MORECONTROLS ),
+ FM_UI_FEATURE_TB_MORECONTROLS );
+
+ SFX_FEATURED_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD,
+ SVX_RES( RID_SVXTBX_FORMDESIGN ),
+ FM_UI_FEATURE_TB_FORMDESIGN );
+}
+
+//========================================================================
+TYPEINIT1(FmFormShell,SfxShell)
+
+//------------------------------------------------------------------------
+FmFormShell::FmFormShell( SfxViewShell* _pParent, FmFormView* pView )
+ :SfxShell(_pParent)
+ ,m_pImpl(new FmXFormShell(*this, _pParent->GetViewFrame()))
+ ,m_pFormView( pView )
+ ,m_pFormModel( NULL )
+ ,m_pParentShell(_pParent)
+ ,m_nLastSlot( 0 )
+ ,m_bDesignMode( sal_True )
+ ,m_bHasForms(sal_False)
+{
+ m_pImpl->acquire();
+ SetPool( &SFX_APP()->GetPool() );
+ SetName( String::CreateFromAscii( "Form" ) );
+
+ SetView(m_pFormView);
+}
+
+//------------------------------------------------------------------------
+FmFormShell::~FmFormShell()
+{
+ if ( m_pFormView )
+ SetView( NULL );
+
+ m_pImpl->dispose();
+ m_pImpl->release();
+ m_pImpl = NULL;
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::NotifyMarkListChanged(FmFormView* pWhichView)
+{
+ FmNavViewMarksChanged aChangeNotification(pWhichView);
+ Broadcast(aChangeNotification);
+}
+
+//------------------------------------------------------------------------
+sal_uInt16 FmFormShell::PrepareClose(sal_Bool bUI, sal_Bool bForBrowsing)
+{
+ if ( GetImpl()->didPrepareClose() )
+ // we already did a PrepareClose for the current modifications of the current form
+ // 2002-11-12 #104702# - fs@openoffice.org
+ return sal_True;
+
+ sal_Bool bResult = sal_True;
+ // Save the data records, not in DesignMode and FilterMode
+ if (!m_bDesignMode && !GetImpl()->isInFilterMode() &&
+ m_pFormView && m_pFormView->GetActualOutDev() &&
+ m_pFormView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW)
+ {
+ SdrPageView* pCurPageView = m_pFormView->GetSdrPageView();
+
+ // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pFormView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND;
+ SdrPageWindow* pWindow = pCurPageView ? pCurPageView->FindPageWindow(*((OutputDevice*)m_pFormView->GetActualOutDev())) : 0L;
+
+ if(pWindow)
+ {
+ // Zunaechst werden die aktuellen Inhalte der Controls gespeichert
+ // Wenn alles glatt gelaufen ist, werden die modifizierten Datensaetze gespeichert
+ if ( GetImpl()->getActiveController().is() )
+ {
+ const ::svx::ControllerFeatures& rController = GetImpl()->getActiveControllerFeatures();
+ if ( rController->commitCurrentControl() )
+ {
+ sal_Bool bModified = rController->isModifiedRow();
+
+ if ( bModified && bUI )
+ {
+ QueryBox aQry(NULL, SVX_RES(RID_QRY_SAVEMODIFIED));
+ if (bForBrowsing)
+ aQry.AddButton(SVX_RES(RID_STR_NEW_TASK), RET_NEWTASK,
+ BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON);
+
+ switch (aQry.Execute())
+ {
+ case RET_NO:
+ bModified = sal_False;
+ GetImpl()->didPrepareClose( sal_True );
+ break;
+
+ case RET_CANCEL:
+ return sal_False;
+
+ case RET_NEWTASK:
+ return RET_NEWTASK;
+ }
+
+ if ( bModified )
+ bResult = rController->commitCurrentRecord( );
+ }
+ }
+ }
+ }
+ }
+ return bResult;
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::impl_setDesignMode(sal_Bool bDesign)
+{
+ if (m_pFormView)
+ {
+ if (!bDesign)
+ m_nLastSlot = SID_FM_DESIGN_MODE;
+
+ GetImpl()->SetDesignMode(bDesign);
+ // mein m_bDesignMode wird auch von der Impl gesetzt ...
+ }
+ else
+ {
+ m_bHasForms = sal_False;
+ m_bDesignMode = bDesign;
+ UIFeatureChanged();
+ }
+
+ GetViewShell()->GetViewFrame()->GetBindings().Invalidate(ControllerSlotMap);
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmFormShell::HasUIFeature( sal_uInt32 nFeature )
+{
+ sal_Bool bResult = sal_False;
+ if ((nFeature & FM_UI_FEATURE_SHOW_DATABASEBAR) == FM_UI_FEATURE_SHOW_DATABASEBAR)
+ {
+ // nur wenn auch formulare verfuegbar
+ bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar() && !GetImpl()->isInFilterMode();
+ }
+ else if ((nFeature & FM_UI_FEATURE_SHOW_FILTERBAR) == FM_UI_FEATURE_SHOW_FILTERBAR)
+ {
+ // nur wenn auch formulare verfuegbar
+ bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
+ }
+ else if ((nFeature & FM_UI_FEATURE_SHOW_FILTERNAVIGATOR) == FM_UI_FEATURE_SHOW_FILTERNAVIGATOR)
+ {
+ bResult = !m_bDesignMode && GetImpl()->hasDatabaseBar() && GetImpl()->isInFilterMode();
+ }
+ else if ((nFeature & FM_UI_FEATURE_SHOW_FIELD) == FM_UI_FEATURE_SHOW_FIELD)
+ {
+ bResult = m_bDesignMode && m_pFormView && m_bHasForms;
+ }
+ else if ((nFeature & FM_UI_FEATURE_SHOW_PROPERTIES) == FM_UI_FEATURE_SHOW_PROPERTIES)
+ {
+ bResult = m_bDesignMode && m_pFormView && m_bHasForms;
+ }
+ else if ((nFeature & FM_UI_FEATURE_SHOW_EXPLORER) == FM_UI_FEATURE_SHOW_EXPLORER)
+ {
+ bResult = m_bDesignMode; // OJ #101593# && m_pFormView && m_bHasForms;
+ }
+ else if ( ( nFeature & FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR ) == FM_UI_FEATURE_SHOW_TEXT_CONTROL_BAR )
+ {
+ bResult = !GetImpl()->IsReadonlyDoc() && m_pImpl->IsActiveControl( true );
+ }
+ else if ((nFeature & FM_UI_FEATURE_SHOW_DATANAVIGATOR) == FM_UI_FEATURE_SHOW_DATANAVIGATOR)
+ {
+ bResult = GetImpl()->isEnhancedForm();
+ }
+ else if ( ( ( nFeature & FM_UI_FEATURE_TB_CONTROLS ) == FM_UI_FEATURE_TB_CONTROLS )
+ || ( ( nFeature & FM_UI_FEATURE_TB_MORECONTROLS ) == FM_UI_FEATURE_TB_MORECONTROLS )
+ || ( ( nFeature & FM_UI_FEATURE_TB_FORMDESIGN ) == FM_UI_FEATURE_TB_FORMDESIGN )
+ )
+ {
+ bResult = sal_True;
+ }
+
+ return bResult;
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::Execute(SfxRequest &rReq)
+{
+ sal_uInt16 nSlot = rReq.GetSlot();
+
+ //////////////////////////////////////////////////////////////////////
+ // MasterSlot setzen
+ switch( nSlot )
+ {
+ case SID_FM_PUSHBUTTON:
+ case SID_FM_RADIOBUTTON:
+ case SID_FM_CHECKBOX:
+ case SID_FM_FIXEDTEXT:
+ case SID_FM_GROUPBOX:
+ case SID_FM_LISTBOX:
+ case SID_FM_COMBOBOX:
+ case SID_FM_NAVIGATIONBAR:
+ case SID_FM_EDIT:
+ case SID_FM_DBGRID:
+ case SID_FM_IMAGEBUTTON:
+ case SID_FM_IMAGECONTROL:
+ case SID_FM_FILECONTROL:
+ case SID_FM_DATEFIELD:
+ case SID_FM_TIMEFIELD:
+ case SID_FM_NUMERICFIELD:
+ case SID_FM_CURRENCYFIELD:
+ case SID_FM_PATTERNFIELD:
+ case SID_FM_FORMATTEDFIELD:
+ case SID_FM_SCROLLBAR:
+ case SID_FM_SPINBUTTON:
+ m_nLastSlot = nSlot;
+ GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG );
+ break;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Identifier und Inventor des Uno-Controls setzen
+ sal_uInt16 nIdentifier = 0;
+ switch( nSlot )
+ {
+ case SID_FM_CHECKBOX:
+ nIdentifier = OBJ_FM_CHECKBOX;
+ break;
+ case SID_FM_PUSHBUTTON:
+ nIdentifier = OBJ_FM_BUTTON;
+ break;
+ case SID_FM_FIXEDTEXT:
+ nIdentifier = OBJ_FM_FIXEDTEXT;
+ break;
+ case SID_FM_LISTBOX:
+ nIdentifier = OBJ_FM_LISTBOX;
+ break;
+ case SID_FM_EDIT:
+ nIdentifier = OBJ_FM_EDIT;
+ break;
+ case SID_FM_RADIOBUTTON:
+ nIdentifier = OBJ_FM_RADIOBUTTON;
+ break;
+ case SID_FM_GROUPBOX:
+ nIdentifier = OBJ_FM_GROUPBOX;
+ break;
+ case SID_FM_COMBOBOX:
+ nIdentifier = OBJ_FM_COMBOBOX;
+ break;
+ case SID_FM_NAVIGATIONBAR:
+ nIdentifier = OBJ_FM_NAVIGATIONBAR;
+ break;
+ case SID_FM_DBGRID:
+ nIdentifier = OBJ_FM_GRID;
+ break;
+ case SID_FM_IMAGEBUTTON:
+ nIdentifier = OBJ_FM_IMAGEBUTTON;
+ break;
+ case SID_FM_IMAGECONTROL:
+ nIdentifier = OBJ_FM_IMAGECONTROL;
+ break;
+ case SID_FM_FILECONTROL:
+ nIdentifier = OBJ_FM_FILECONTROL;
+ break;
+ case SID_FM_DATEFIELD:
+ nIdentifier = OBJ_FM_DATEFIELD;
+ break;
+ case SID_FM_TIMEFIELD:
+ nIdentifier = OBJ_FM_TIMEFIELD;
+ break;
+ case SID_FM_NUMERICFIELD:
+ nIdentifier = OBJ_FM_NUMERICFIELD;
+ break;
+ case SID_FM_CURRENCYFIELD:
+ nIdentifier = OBJ_FM_CURRENCYFIELD;
+ break;
+ case SID_FM_PATTERNFIELD:
+ nIdentifier = OBJ_FM_PATTERNFIELD;
+ break;
+ case SID_FM_FORMATTEDFIELD:
+ nIdentifier = OBJ_FM_FORMATTEDFIELD;
+ break;
+ case SID_FM_SCROLLBAR:
+ nIdentifier = OBJ_FM_SCROLLBAR;
+ break;
+ case SID_FM_SPINBUTTON:
+ nIdentifier = OBJ_FM_SPINBUTTON;
+ break;
+ }
+
+ switch ( nSlot )
+ {
+ case SID_FM_CHECKBOX:
+ case SID_FM_PUSHBUTTON:
+ case SID_FM_FIXEDTEXT:
+ case SID_FM_LISTBOX:
+ case SID_FM_EDIT:
+ case SID_FM_RADIOBUTTON:
+ case SID_FM_COMBOBOX:
+ case SID_FM_NAVIGATIONBAR:
+ case SID_FM_GROUPBOX:
+ case SID_FM_DBGRID:
+ case SID_FM_IMAGEBUTTON:
+ case SID_FM_IMAGECONTROL:
+ case SID_FM_FILECONTROL:
+ case SID_FM_DATEFIELD:
+ case SID_FM_TIMEFIELD:
+ case SID_FM_NUMERICFIELD:
+ case SID_FM_CURRENCYFIELD:
+ case SID_FM_PATTERNFIELD:
+ case SID_FM_FORMATTEDFIELD:
+ case SID_FM_SCROLLBAR:
+ case SID_FM_SPINBUTTON:
+ {
+ SFX_REQUEST_ARG( rReq, pGrabFocusItem, SfxBoolItem, SID_FM_TOGGLECONTROLFOCUS, sal_False );
+ if ( pGrabFocusItem && pGrabFocusItem->GetValue() )
+ { // see below
+ SfxViewShell* pShell = GetViewShell();
+ Window* pShellWnd = pShell ? pShell->GetWindow() : NULL;
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ break;
+ }
+
+ SfxUInt16Item aIdentifierItem( SID_FM_CONTROL_IDENTIFIER, nIdentifier );
+ SfxUInt32Item aInventorItem( SID_FM_CONTROL_INVENTOR, FmFormInventor );
+ const SfxPoolItem* pArgs[] =
+ {
+ &aIdentifierItem, &aInventorItem, NULL
+ };
+ const SfxPoolItem* pInternalArgs[] =
+ {
+ NULL
+ };
+
+ GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_CREATE_CONTROL, SFX_CALLMODE_ASYNCHRON,
+ pArgs, rReq.GetModifier(), pInternalArgs );
+
+ if ( rReq.GetModifier() & KEY_MOD1 )
+ {
+ // #99013# if selected with control key, return focus to current view
+ // do this asynchron, so that the creation can be finished first
+ // reusing the SID_FM_TOGGLECONTROLFOCUS is somewhat hacky ... which it wouldn't if it would have another
+ // name, so I do not really have a big problem with this ....
+ SfxBoolItem aGrabFocusIndicatorItem( SID_FM_TOGGLECONTROLFOCUS, sal_True );
+ GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( nSlot, SFX_CALLMODE_ASYNCHRON,
+ &aGrabFocusIndicatorItem, NULL );
+ }
+
+ rReq.Done();
+ } break;
+ }
+
+ // Individuelle Aktionen
+ switch( nSlot )
+ {
+ case SID_FM_MORE_CONTROLS:
+ case SID_FM_FORM_DESIGN_TOOLS:
+ {
+ FormToolboxes aToolboxAccess( GetImpl()->getHostFrame() );
+ aToolboxAccess.toggleToolbox( nSlot );
+ rReq.Done();
+ }
+ break;
+
+ case SID_FM_TOGGLECONTROLFOCUS:
+ {
+ FmFormView* pFormView = GetFormView();
+ if ( !pFormView )
+ break;
+
+ // if we execute this ourself, then either the application does not implement an own handling for this,
+ // of we're on the top of the dispatcher stack, which means a control has the focus.
+ // In the latter case, we put the focus to the document window, otherwise, we focus the first control
+ const bool bHasControlFocus = GetImpl()->HasControlFocus();
+ if ( bHasControlFocus )
+ {
+ const OutputDevice* pDevice = GetCurrentViewDevice();
+ Window* pWindow = dynamic_cast< Window* >( const_cast< OutputDevice* >( pDevice ) );
+ if ( pWindow )
+ pWindow->GrabFocus();
+ }
+ else
+ {
+ pFormView->GrabFirstControlFocus( );
+ }
+ }
+ break;
+
+ case SID_FM_VIEW_AS_GRID:
+ GetImpl()->CreateExternalView();
+ break;
+ case SID_FM_CONVERTTO_EDIT :
+ case SID_FM_CONVERTTO_BUTTON :
+ case SID_FM_CONVERTTO_FIXEDTEXT :
+ case SID_FM_CONVERTTO_LISTBOX :
+ case SID_FM_CONVERTTO_CHECKBOX :
+ case SID_FM_CONVERTTO_RADIOBUTTON :
+ case SID_FM_CONVERTTO_GROUPBOX :
+ case SID_FM_CONVERTTO_COMBOBOX :
+ case SID_FM_CONVERTTO_IMAGEBUTTON :
+ case SID_FM_CONVERTTO_FILECONTROL :
+ case SID_FM_CONVERTTO_DATE :
+ case SID_FM_CONVERTTO_TIME :
+ case SID_FM_CONVERTTO_NUMERIC :
+ case SID_FM_CONVERTTO_CURRENCY :
+ case SID_FM_CONVERTTO_PATTERN :
+ case SID_FM_CONVERTTO_IMAGECONTROL :
+ case SID_FM_CONVERTTO_FORMATTED :
+ case SID_FM_CONVERTTO_SCROLLBAR :
+ case SID_FM_CONVERTTO_SPINBUTTON :
+ case SID_FM_CONVERTTO_NAVIGATIONBAR :
+ GetImpl()->executeControlConversionSlot( nSlot );
+ // nach dem Konvertieren die Selektion neu bestimmern, da sich ja das selektierte Objekt
+ // geaendert hat
+ GetImpl()->SetSelection(GetFormView()->GetMarkedObjectList());
+ break;
+ case SID_FM_LEAVE_CREATE:
+ m_nLastSlot = 0;
+ GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG );
+ rReq.Done();
+ break;
+ case SID_FM_SHOW_PROPERTY_BROWSER:
+ {
+ SFX_REQUEST_ARG( rReq, pShowItem, SfxBoolItem, SID_FM_SHOW_PROPERTIES, sal_False );
+ sal_Bool bShow = sal_True;
+ if ( pShowItem )
+ bShow = pShowItem->GetValue();
+ GetImpl()->ShowSelectionProperties( bShow );
+
+ rReq.Done();
+ } break;
+
+ case SID_FM_PROPERTIES:
+ {
+ // PropertyBrowser anzeigen
+ SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nSlot, sal_False);
+ sal_Bool bShow = pShowItem ? pShowItem->GetValue() : sal_True;
+
+ InterfaceBag aOnlyTheForm;
+ aOnlyTheForm.insert( Reference< XInterface >( GetImpl()->getCurrentForm(), UNO_QUERY ) );
+ GetImpl()->setCurrentSelection( aOnlyTheForm );
+
+ GetImpl()->ShowSelectionProperties( bShow );
+
+ rReq.Done();
+ } break;
+
+ case SID_FM_CTL_PROPERTIES:
+ {
+ SFX_REQUEST_ARG(rReq, pShowItem, SfxBoolItem, nSlot, sal_False);
+ sal_Bool bShow = pShowItem ? pShowItem->GetValue() : sal_True;
+
+ OSL_ENSURE( GetImpl()->onlyControlsAreMarked(), "FmFormShell::Execute: ControlProperties should be disabled!" );
+ if ( bShow )
+ GetImpl()->selectLastMarkedControls();
+ GetImpl()->ShowSelectionProperties( bShow );
+
+ rReq.Done();
+ } break;
+ case SID_FM_SHOW_PROPERTIES:
+ case SID_FM_ADD_FIELD:
+ case SID_FM_FILTER_NAVIGATOR:
+ case SID_FM_SHOW_DATANAVIGATOR :
+ {
+ GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq );
+ rReq.Done();
+ } break;
+ case SID_FM_SHOW_FMEXPLORER:
+ {
+ if (!m_pFormView) // setzen der ::com::sun::star::sdbcx::View Forcieren
+ GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_CREATE_SW_DRAWVIEW);
+
+ GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq);
+ rReq.Done();
+ }
+ break;
+
+ case SID_FM_TAB_DIALOG:
+ {
+ GetImpl()->ExecuteTabOrderDialog( Reference< XTabControllerModel >( GetImpl()->getCurrentForm(), UNO_QUERY ) );
+ rReq.Done();
+ }
+ break;
+
+ case SID_FM_DESIGN_MODE:
+ {
+ SFX_REQUEST_ARG(rReq, pDesignItem, SfxBoolItem, nSlot, sal_False);
+ sal_Bool bDesignMode = pDesignItem ? pDesignItem->GetValue() : !m_bDesignMode;
+ SetDesignMode( bDesignMode );
+ if ( m_bDesignMode == bDesignMode )
+ rReq.Done();
+
+ m_nLastSlot = SID_FM_DESIGN_MODE;
+ GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_FM_CONFIG );
+ }
+ break;
+
+ case SID_FM_AUTOCONTROLFOCUS:
+ {
+ FmFormModel* pModel = GetFormModel();
+ DBG_ASSERT(pModel, "FmFormShell::Execute : invalid call !");
+ // should have been disabled in GetState if we don't have a FormModel
+ pModel->SetAutoControlFocus( !pModel->GetAutoControlFocus() );
+ GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS);
+ }
+ break;
+ case SID_FM_OPEN_READONLY:
+ {
+ FmFormModel* pModel = GetFormModel();
+ DBG_ASSERT(pModel, "FmFormShell::Execute : invalid call !");
+ // should have been disabled in GetState if we don't have a FormModel
+ pModel->SetOpenInDesignMode( !pModel->GetOpenInDesignMode() );
+ GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY);
+ }
+ break;
+ case SID_FM_USE_WIZARDS:
+ {
+ GetImpl()->SetWizardUsing(!GetImpl()->GetWizardUsing());
+ GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_USE_WIZARDS);
+ }
+ break;
+ case SID_FM_SEARCH:
+ {
+ const ::svx::ControllerFeatures& rController = GetImpl()->getActiveControllerFeatures();
+ if ( rController->commitCurrentControl() && rController->commitCurrentRecord() )
+ GetImpl()->ExecuteSearch();
+ rReq.Done();
+ }
+ break;
+
+ case SID_FM_RECORD_FIRST:
+ case SID_FM_RECORD_PREV:
+ case SID_FM_RECORD_NEXT:
+ case SID_FM_RECORD_LAST:
+ case SID_FM_RECORD_NEW:
+ case SID_FM_REFRESH:
+ case SID_FM_REFRESH_FORM_CONTROL:
+ case SID_FM_RECORD_DELETE:
+ case SID_FM_RECORD_UNDO:
+ case SID_FM_RECORD_SAVE:
+ case SID_FM_REMOVE_FILTER_SORT:
+ case SID_FM_SORTDOWN:
+ case SID_FM_SORTUP:
+ case SID_FM_AUTOFILTER:
+ case SID_FM_ORDERCRIT:
+ case SID_FM_FORM_FILTERED:
+ {
+ GetImpl()->ExecuteFormSlot( nSlot );
+ rReq.Done();
+ }
+ break;
+
+ case SID_FM_RECORD_ABSOLUTE:
+ {
+ const ::svx::ControllerFeatures& rController = GetImpl()->getNavControllerFeatures();
+ sal_Int32 nRecord = -1;
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ const SfxPoolItem* pItem;
+ if ( ( pArgs->GetItemState( FN_PARAM_1, sal_True, &pItem ) ) == SFX_ITEM_SET )
+ {
+ const SfxInt32Item* pTypedItem = PTR_CAST( SfxInt32Item, pItem );
+ if ( pTypedItem )
+ nRecord = Max( pTypedItem->GetValue(), sal_Int32(0) );
+ }
+ }
+ else
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT( pFact, "no dialog factory!" );
+ if ( pFact )
+ {
+ ::std::auto_ptr< AbstractFmInputRecordNoDialog > dlg( pFact->CreateFmInputRecordNoDialog( NULL ) );
+ DBG_ASSERT( dlg.get(), "Dialogdiet fail!" );
+ dlg->SetValue( rController->getCursor()->getRow() );
+ if ( dlg->Execute() == RET_OK )
+ nRecord = dlg->GetValue();
+
+ rReq.AppendItem( SfxInt32Item( FN_PARAM_1, nRecord ) );
+ }
+ }
+
+ if ( nRecord != -1 )
+ rController->execute( nSlot, ::rtl::OUString::createFromAscii( "Position" ), makeAny( (sal_Int32)nRecord ) );
+
+ rReq.Done();
+ } break;
+ case SID_FM_FILTER_EXECUTE:
+ case SID_FM_FILTER_EXIT:
+ {
+ sal_Bool bCancelled = ( SID_FM_FILTER_EXIT == nSlot );
+ sal_Bool bReopenNavigator = sal_False;
+
+ if ( !bCancelled )
+ {
+ // if the filter navigator is still open, we need to close it, so it can possibly
+ // commit it's most recent changes
+ if ( GetViewShell() && GetViewShell()->GetViewFrame() )
+ if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR ) )
+ {
+ GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
+ bReopenNavigator = sal_True;
+ }
+
+ Reference< runtime::XFormController > xController( GetImpl()->getActiveController() );
+
+ if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR )
+ // closing the window was denied, for instance because of a invalid criterion
+
+ || ( xController.is()
+ && !GetImpl()->getActiveControllerFeatures()->commitCurrentControl( )
+ )
+ // committing the controller was denied
+ )
+ {
+ rReq.Done();
+ break;
+ }
+ }
+
+ GetImpl()->stopFiltering( !bCancelled );
+ rReq.Done();
+
+ if ( bReopenNavigator )
+ // we closed the navigator only to implicitly commit it (as we do not have another
+ // direct wire to it), but to the user, it should look it it was always open
+ GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
+ }
+ break;
+
+ case SID_FM_FILTER_START:
+ {
+ GetImpl()->startFiltering();
+ rReq.Done();
+
+ // initially open the filter navigator, the whole form based filter is pretty useless without it
+ SfxBoolItem aIdentifierItem( SID_FM_FILTER_NAVIGATOR, TRUE );
+ GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_FILTER_NAVIGATOR, SFX_CALLMODE_ASYNCHRON,
+ &aIdentifierItem, NULL );
+ } break;
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::GetState(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch( nWhich )
+ {
+ case SID_FM_MORE_CONTROLS:
+ case SID_FM_FORM_DESIGN_TOOLS:
+ {
+ FormToolboxes aToolboxAccess( GetImpl()->getHostFrame() );
+ rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible( nWhich ) ) );
+ }
+ break;
+
+ case SID_FM_FILTER_EXECUTE:
+ case SID_FM_FILTER_EXIT:
+ if (!GetImpl()->isInFilterMode())
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_FM_USE_WIZARDS:
+ if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ rSet.Put( SfxVisibilityItem( nWhich, sal_False ) );
+ else if (!m_bDesignMode || !GetFormModel())
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem(nWhich, GetImpl()->GetWizardUsing() ) );
+ break;
+ case SID_FM_AUTOCONTROLFOCUS:
+ if (!m_bDesignMode || !GetFormModel())
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem(nWhich, GetFormModel()->GetAutoControlFocus() ) );
+ break;
+ case SID_FM_OPEN_READONLY:
+ if (!m_bDesignMode || !GetFormModel())
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem(nWhich, GetFormModel()->GetOpenInDesignMode() ) );
+ break;
+
+ case SID_FM_NAVIGATIONBAR:
+ case SID_FM_DBGRID:
+ if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ {
+ rSet.Put( SfxVisibilityItem( nWhich, sal_False ) );
+ break;
+ }
+ // NO break!
+
+ case SID_FM_SCROLLBAR:
+ case SID_FM_IMAGECONTROL:
+ case SID_FM_FILECONTROL:
+ case SID_FM_CURRENCYFIELD:
+ case SID_FM_PATTERNFIELD:
+ case SID_FM_IMAGEBUTTON:
+ case SID_FM_RADIOBUTTON:
+ case SID_FM_COMBOBOX:
+ case SID_FM_GROUPBOX:
+ case SID_FM_CHECKBOX:
+ case SID_FM_PUSHBUTTON:
+ case SID_FM_FIXEDTEXT:
+ case SID_FM_LISTBOX:
+ case SID_FM_EDIT:
+ case SID_FM_DATEFIELD:
+ case SID_FM_TIMEFIELD:
+ case SID_FM_NUMERICFIELD:
+ case SID_FM_FORMATTEDFIELD:
+ case SID_FM_SPINBUTTON:
+ if (!m_bDesignMode)
+ rSet.DisableItem( nWhich );
+ else
+ {
+ sal_Bool bLayerLocked = sal_False;
+ if (m_pFormView)
+ {
+ // Ist der ::com::sun::star::drawing::Layer gelocked, so m???ssen die Slots disabled werden. #36897
+ SdrPageView* pPV = m_pFormView->GetSdrPageView();
+ if (pPV != NULL)
+ bLayerLocked = pPV->IsLayerLocked(m_pFormView->GetActiveLayer());
+ }
+ if (bLayerLocked)
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem(nWhich, (nWhich==m_nLastSlot)) );
+ }
+ break;
+ case SID_FM_FILTER_NAVIGATOR_CONTROL:
+ {
+ if (GetImpl()->isInFilterMode())
+ rSet.Put(SfxObjectItem(nWhich, this));
+ else
+ rSet.Put(SfxObjectItem(nWhich));
+ } break;
+ case SID_FM_FIELDS_CONTROL:
+ case SID_FM_PROPERTY_CONTROL:
+ {
+ if (!m_bDesignMode || !m_pFormView || !m_bHasForms)
+ rSet.Put(SfxObjectItem(nWhich));
+ else
+ rSet.Put(SfxObjectItem(nWhich, this));
+
+ } break;
+ case SID_FM_FMEXPLORER_CONTROL:
+ case SID_FM_DATANAVIGATOR_CONTROL :
+ {
+ if (!m_bDesignMode || !m_pFormView)
+ rSet.Put(SfxObjectItem(nWhich));
+ else
+ rSet.Put(SfxObjectItem(nWhich, this));
+
+ } break;
+ case SID_FM_ADD_FIELD:
+ case SID_FM_SHOW_FMEXPLORER:
+ case SID_FM_SHOW_PROPERTIES:
+ case SID_FM_FILTER_NAVIGATOR:
+ case SID_FM_SHOW_DATANAVIGATOR:
+ {
+ if ( GetViewShell()->GetViewFrame()->KnowsChildWindow(nWhich) )
+ rSet.Put( SfxBoolItem( nWhich, GetViewShell()->GetViewFrame()->HasChildWindow(nWhich)) );
+ else
+ rSet.DisableItem(nWhich);
+ } break;
+
+ case SID_FM_SHOW_PROPERTY_BROWSER:
+ {
+ rSet.Put(SfxBoolItem(GetImpl()->IsPropBrwOpen()));
+ }
+ break;
+
+ case SID_FM_CTL_PROPERTIES:
+ {
+ // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
+ // auf den neuesten Stand zu bringen
+ if (GetImpl()->IsSelectionUpdatePending())
+ GetImpl()->ForceUpdateSelection(sal_False);
+
+ if ( !m_pFormView || !m_bDesignMode || !GetImpl()->onlyControlsAreMarked() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ sal_Bool bChecked = GetImpl()->IsPropBrwOpen() && !GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
+ // if the property browser is open, and only controls are marked, and the current selection
+ // does not consist of only the current form, then the current selection is the (composition of)
+ // the currently marked controls
+ rSet.Put( SfxBoolItem( nWhich, bChecked ) );
+ }
+ } break;
+
+ case SID_FM_PROPERTIES:
+ {
+ // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
+ // auf den neuesten Stand zu bringen
+ if (GetImpl()->IsSelectionUpdatePending())
+ GetImpl()->ForceUpdateSelection(sal_False);
+
+ if ( !m_pFormView || !m_bDesignMode || !GetImpl()->getCurrentForm().is() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ sal_Bool bChecked = GetImpl()->IsPropBrwOpen() && GetImpl()->isSolelySelected( GetImpl()->getCurrentForm() );
+ rSet.Put(SfxBoolItem(nWhich, bChecked));
+ }
+ } break;
+ case SID_FM_TAB_DIALOG:
+ // der Impl eventuell die Moeglichjkeit geben, ihre an der aktuellen MarkList ausgerichteten Objekte
+ // auf den neuesten Stand zu bringen
+ if (GetImpl()->IsSelectionUpdatePending())
+ GetImpl()->ForceUpdateSelection(sal_False);
+
+ if (!m_pFormView || !m_bDesignMode || !GetImpl()->getCurrentForm().is() )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_FM_CONFIG:
+ rSet.Put(SfxUInt16Item(nWhich, m_nLastSlot));
+ break;
+ case SID_FM_DESIGN_MODE:
+ if (!m_pFormView || GetImpl()->IsReadonlyDoc() )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem(nWhich, m_bDesignMode) );
+ break;
+ case SID_FM_SEARCH:
+ case SID_FM_RECORD_FIRST:
+ case SID_FM_RECORD_NEXT:
+ case SID_FM_RECORD_PREV:
+ case SID_FM_RECORD_LAST:
+ case SID_FM_RECORD_NEW:
+ case SID_FM_RECORD_DELETE:
+ case SID_FM_RECORD_ABSOLUTE:
+ case SID_FM_RECORD_TOTAL:
+ case SID_FM_RECORD_SAVE:
+ case SID_FM_RECORD_UNDO:
+ case SID_FM_FORM_FILTERED:
+ case SID_FM_REMOVE_FILTER_SORT:
+ case SID_FM_SORTUP:
+ case SID_FM_SORTDOWN:
+ case SID_FM_ORDERCRIT:
+ case SID_FM_FILTER_START:
+ case SID_FM_AUTOFILTER:
+ case SID_FM_REFRESH:
+ case SID_FM_REFRESH_FORM_CONTROL:
+ case SID_FM_VIEW_AS_GRID:
+ GetFormState(rSet,nWhich);
+ break;
+
+ case SID_FM_CHANGECONTROLTYPE:
+ {
+ if ( !m_pFormView || !m_bDesignMode )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ if ( !GetImpl()->canConvertCurrentSelectionToControl( OBJ_FM_FIXEDTEXT ) )
+ // if it cannot be converted to a fixed text, it is no single control
+ rSet.DisableItem( nWhich );
+ }
+ } break;
+
+ case SID_FM_CONVERTTO_FILECONTROL :
+ case SID_FM_CONVERTTO_CURRENCY :
+ case SID_FM_CONVERTTO_PATTERN :
+ case SID_FM_CONVERTTO_IMAGECONTROL :
+ case SID_FM_CONVERTTO_SCROLLBAR :
+ case SID_FM_CONVERTTO_NAVIGATIONBAR :
+ case SID_FM_CONVERTTO_IMAGEBUTTON :
+ case SID_FM_CONVERTTO_EDIT :
+ case SID_FM_CONVERTTO_BUTTON :
+ case SID_FM_CONVERTTO_FIXEDTEXT :
+ case SID_FM_CONVERTTO_LISTBOX :
+ case SID_FM_CONVERTTO_CHECKBOX :
+ case SID_FM_CONVERTTO_RADIOBUTTON :
+ case SID_FM_CONVERTTO_GROUPBOX :
+ case SID_FM_CONVERTTO_COMBOBOX :
+ case SID_FM_CONVERTTO_DATE :
+ case SID_FM_CONVERTTO_TIME :
+ case SID_FM_CONVERTTO_NUMERIC :
+ case SID_FM_CONVERTTO_FORMATTED :
+ case SID_FM_CONVERTTO_SPINBUTTON :
+ {
+ if ( !m_pFormView || !m_bDesignMode || !GetImpl()->canConvertCurrentSelectionToControl( nWhich ) )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ rSet.Put( SfxBoolItem( nWhich, sal_False ) );
+ // just to have a defined state (available and not checked)
+ }
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::GetFormState(SfxItemSet &rSet, sal_uInt16 nWhich)
+{
+ if ( !GetImpl()->getNavController().is()
+ || !isRowSetAlive(GetImpl()->getNavController()->getModel())
+ || !m_pFormView
+ || m_bDesignMode
+ || !GetImpl()->getActiveForm().is()
+ || GetImpl()->isInFilterMode()
+ )
+ rSet.DisableItem(nWhich);
+ else
+ {
+ sal_Bool bEnable = sal_False;
+ try
+ {
+ switch (nWhich)
+ {
+ case SID_FM_VIEW_AS_GRID:
+ if (GetImpl()->getHostFrame().is() && GetImpl()->getNavController().is())
+ {
+ bEnable = sal_True;
+ sal_Bool bDisplayingCurrent =
+ GetImpl()->getInternalForm(
+ Reference< XForm >( GetImpl()->getNavController()->getModel(), UNO_QUERY )
+ ) == GetImpl()->getExternallyDisplayedForm();
+ rSet.Put(SfxBoolItem(nWhich, bDisplayingCurrent));
+ }
+ break;
+
+ case SID_FM_SEARCH:
+ {
+ Reference< ::com::sun::star::beans::XPropertySet > xNavSet(GetImpl()->getActiveForm(), UNO_QUERY);
+ sal_Int32 nCount = ::comphelper::getINT32(xNavSet->getPropertyValue(FM_PROP_ROWCOUNT));
+ bEnable = nCount != 0;
+ } break;
+ case SID_FM_RECORD_ABSOLUTE:
+ case SID_FM_RECORD_TOTAL:
+ {
+ FeatureState aState;
+ GetImpl()->getNavControllerFeatures()->getState( nWhich, aState );
+ if ( SID_FM_RECORD_ABSOLUTE == nWhich )
+ {
+ sal_Int32 nPosition = 0;
+ aState.State >>= nPosition;
+ rSet.Put( SfxInt32Item( nWhich, nPosition ) );
+ }
+ else if ( SID_FM_RECORD_TOTAL == nWhich )
+ {
+ ::rtl::OUString sTotalCount;
+ aState.State >>= sTotalCount;
+ rSet.Put( SfxStringItem( nWhich, sTotalCount ) );
+ }
+ bEnable = aState.Enabled;
+ }
+ break;
+
+ // first, prev, next, last, and absolute affect the nav controller, not the
+ // active controller
+ case SID_FM_RECORD_FIRST:
+ case SID_FM_RECORD_PREV:
+ case SID_FM_RECORD_NEXT:
+ case SID_FM_RECORD_LAST:
+ case SID_FM_RECORD_NEW:
+ case SID_FM_RECORD_SAVE:
+ case SID_FM_RECORD_UNDO:
+ case SID_FM_RECORD_DELETE:
+ case SID_FM_REFRESH:
+ case SID_FM_REFRESH_FORM_CONTROL:
+ case SID_FM_REMOVE_FILTER_SORT:
+ case SID_FM_SORTUP:
+ case SID_FM_SORTDOWN:
+ case SID_FM_AUTOFILTER:
+ case SID_FM_ORDERCRIT:
+ bEnable = GetImpl()->IsFormSlotEnabled( nWhich );
+ break;
+
+ case SID_FM_FORM_FILTERED:
+ {
+ FeatureState aState;
+ bEnable = GetImpl()->IsFormSlotEnabled( nWhich, &aState );
+
+ rSet.Put( SfxBoolItem( nWhich, ::comphelper::getBOOL( aState.State ) ) );
+ }
+ break;
+
+ case SID_FM_FILTER_START:
+ bEnable = GetImpl()->getActiveControllerFeatures()->canDoFormFilter();
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "FmFormShell::GetFormState: caught an exception while determining the state!" );
+ }
+ if (!bEnable)
+ rSet.DisableItem(nWhich);
+ }
+}
+
+//------------------------------------------------------------------------
+FmFormPage* FmFormShell::GetCurPage() const
+{
+ FmFormPage* pP = NULL;
+ if (m_pFormView && m_pFormView->GetSdrPageView())
+ pP = PTR_CAST(FmFormPage,m_pFormView->GetSdrPageView()->GetPage());
+ return pP;
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::SetView( FmFormView* _pView )
+{
+ if ( m_pFormView )
+ {
+ if ( IsActive() )
+ GetImpl()->viewDeactivated( *m_pFormView );
+
+ m_pFormView->SetFormShell( NULL, FmFormView::FormShellAccess() );
+ m_pFormView = NULL;
+ m_pFormModel = NULL;
+ }
+
+ if ( !_pView )
+ return;
+
+ m_pFormView = _pView;
+ m_pFormView->SetFormShell( this, FmFormView::FormShellAccess() );
+ m_pFormModel = (FmFormModel*)m_pFormView->GetModel();
+
+ impl_setDesignMode( m_pFormView->IsDesignMode() );
+
+ // We activate our view if we are activated ourself, but sometimes the Activate precedes the SetView.
+ // But here we know both the view and our activation state so we at least are able to pass the latter
+ // to the former.
+ // FS - 30.06.99 - 67308
+ if ( IsActive() )
+ GetImpl()->viewActivated( *m_pFormView );
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::DetermineForms(sal_Bool bInvalidate)
+{
+ // Existieren Formulare auf der aktuellen Page
+ sal_Bool bForms = GetImpl()->hasForms();
+ if (bForms != m_bHasForms)
+ {
+ m_bHasForms = bForms;
+ if (bInvalidate)
+ UIFeatureChanged();
+ }
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmFormShell::GetY2KState(sal_uInt16& nReturn)
+{
+ return GetImpl()->GetY2KState(nReturn);
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::SetY2KState(sal_uInt16 n)
+{
+ GetImpl()->SetY2KState(n);
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::Activate(sal_Bool bMDI)
+{
+ SfxShell::Activate(bMDI);
+
+ if ( m_pFormView )
+ GetImpl()->viewActivated( *m_pFormView, sal_True );
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::Deactivate(sal_Bool bMDI)
+{
+ SfxShell::Deactivate(bMDI);
+
+ if ( m_pFormView )
+ GetImpl()->viewDeactivated( *m_pFormView, sal_False );
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::ExecuteTextAttribute( SfxRequest& _rReq )
+{
+ m_pImpl->ExecuteTextAttribute( _rReq );
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::GetTextAttributeState( SfxItemSet& _rSet )
+{
+ m_pImpl->GetTextAttributeState( _rSet );
+}
+
+//------------------------------------------------------------------------
+bool FmFormShell::IsActiveControl() const
+{
+ return m_pImpl->IsActiveControl();
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::ForgetActiveControl()
+{
+ m_pImpl->ForgetActiveControl();
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::SetControlActivationHandler( const Link& _rHdl )
+{
+ m_pImpl->SetControlActivationHandler( _rHdl );
+}
+
+//------------------------------------------------------------------------
+namespace
+{
+ SdrUnoObj* lcl_findUnoObject( const SdrObjList& _rObjList, const Reference< XControlModel >& _rxModel )
+ {
+ SdrObjListIter aIter( _rObjList );
+ while ( aIter.IsMore() )
+ {
+ SdrObject* pObject = aIter.Next();
+ SdrUnoObj* pUnoObject = pObject ? PTR_CAST( SdrUnoObj, pObject ) : NULL;
+ if ( !pUnoObject )
+ continue;
+
+ Reference< XControlModel > xControlModel = pUnoObject->GetUnoControlModel();
+ if ( !xControlModel.is() )
+ continue;
+
+ if ( _rxModel == xControlModel )
+ return pUnoObject;
+ }
+ return NULL;
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::ToggleControlFocus( const SdrUnoObj& i_rUnoObject, const SdrView& i_rView, OutputDevice& i_rDevice ) const
+{
+ try
+ {
+ // check if the focus currently is in a control
+ // Well, okay, do it the other way 'round: Check whether the current control of the active controller
+ // actually has the focus. This should be equivalent.
+ const bool bHasControlFocus = GetImpl()->HasControlFocus();
+
+ if ( bHasControlFocus )
+ {
+ Window* pWindow( dynamic_cast< Window* >( &i_rDevice ) );
+ OSL_ENSURE( pWindow, "FmFormShell::ToggleControlFocus: I need a Window, really!" );
+ if ( pWindow )
+ pWindow->GrabFocus();
+ }
+ else
+ {
+ Reference< XControl > xControl;
+ GetFormControl( i_rUnoObject.GetUnoControlModel(), i_rView, i_rDevice, xControl );
+ Reference< XWindow > xControlWindow( xControl, UNO_QUERY );
+ if ( xControlWindow.is() )
+ xControlWindow->setFocus();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------
+namespace
+{
+ class FocusableControlsFilter : public ::svx::ISdrObjectFilter
+ {
+ public:
+ FocusableControlsFilter( const SdrView& i_rView, const OutputDevice& i_rDevice )
+ :m_rView( i_rView )
+ ,m_rDevice( i_rDevice )
+ {
+ }
+
+ public:
+ virtual bool includeObject( const SdrObject& i_rObject ) const
+ {
+ const SdrUnoObj* pUnoObj = dynamic_cast< const SdrUnoObj* >( &i_rObject );
+ if ( !pUnoObj )
+ return false;
+
+ Reference< XControl > xControl = pUnoObj->GetUnoControl( m_rView, m_rDevice );
+ return FmXFormView::isFocusable( xControl );
+ }
+
+ private:
+ const SdrView& m_rView;
+ const OutputDevice& m_rDevice;
+ };
+}
+
+//------------------------------------------------------------------------
+::std::auto_ptr< ::svx::ISdrObjectFilter > FmFormShell::CreateFocusableControlFilter( const SdrView& i_rView, const OutputDevice& i_rDevice ) const
+{
+ ::std::auto_ptr< ::svx::ISdrObjectFilter > pFilter;
+
+ if ( !i_rView.IsDesignMode() )
+ pFilter.reset( new FocusableControlsFilter( i_rView, i_rDevice ) );
+
+ return pFilter;
+}
+
+//------------------------------------------------------------------------
+SdrUnoObj* FmFormShell::GetFormControl( const Reference< XControlModel >& _rxModel, const SdrView& _rView, const OutputDevice& _rDevice, Reference< XControl >& _out_rxControl ) const
+{
+ if ( !_rxModel.is() )
+ return NULL;
+
+ // we can only retrieve controls for SdrObjects which belong to page which is actually displayed in the given view
+ SdrPageView* pPageView = _rView.GetSdrPageView();
+ SdrPage* pPage = pPageView ? pPageView->GetPage() : NULL;
+ OSL_ENSURE( pPage, "FmFormShell::GetFormControl: no page displayed in the given view!" );
+ if ( !pPage )
+ return NULL;
+
+ SdrUnoObj* pUnoObject = lcl_findUnoObject( *pPage, _rxModel );
+ if ( pUnoObject )
+ {
+ _out_rxControl = pUnoObject->GetUnoControl( _rView, _rDevice );
+ return pUnoObject;
+ }
+
+#if OSL_DEBUG_LEVEL > 0
+ // perhaps we are fed with a control model which lives on a page other than the one displayed
+ // in the given view. This is worth being reported as error, in non-product builds.
+ FmFormModel* pModel = GetFormModel();
+ if ( pModel )
+ {
+ sal_uInt16 pageCount = pModel->GetPageCount();
+ for ( sal_uInt16 page = 0; page < pageCount; ++page )
+ {
+ pPage = pModel->GetPage( page );
+ OSL_ENSURE( pPage, "FmFormShell::GetFormControl: NULL page encountered!" );
+ if ( !pPage )
+ continue;
+
+ pUnoObject = lcl_findUnoObject( *pPage, _rxModel );
+ OSL_ENSURE( !pUnoObject, "FmFormShell::GetFormControl: the given control model belongs to a wrong page (displayed elsewhere)!" );
+ }
+ }
+#endif
+
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+Reference< runtime::XFormController > FmFormShell::GetFormController( const Reference< XForm >& _rxForm, const SdrView& _rView, const OutputDevice& _rDevice ) const
+{
+ const FmFormView* pFormView = dynamic_cast< const FmFormView* >( &_rView );
+ if ( !pFormView )
+ return NULL;
+
+ return pFormView->GetFormController( _rxForm, _rDevice );
+}
+
+//------------------------------------------------------------------------
+void FmFormShell::SetDesignMode( sal_Bool _bDesignMode )
+{
+ if ( _bDesignMode == m_bDesignMode )
+ return;
+
+ FmFormModel* pModel = GetFormModel();
+ if (pModel)
+ // fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente
+ // Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes
+ // auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das
+ // OEditModel an seinem Control.)
+ pModel->GetUndoEnv().Lock();
+
+ // dann die eigentliche Umschaltung
+ if ( m_bDesignMode || PrepareClose( sal_True ) )
+ impl_setDesignMode(!m_bDesignMode );
+
+ // und mein Undo-Environment wieder an
+ if ( pModel )
+ pModel->GetUndoEnv().UnLock();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
new file mode 100644
index 000000000000..743c73586996
--- /dev/null
+++ b/svx/source/form/fmshimp.cxx
@@ -0,0 +1,4342 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+#include "fmitems.hxx"
+#include "fmobj.hxx"
+#include "fmpgeimp.hxx"
+#include "svx/fmtools.hxx"
+#include "fmprop.hrc"
+#include "fmresids.hrc"
+#include "fmservs.hxx"
+#include "fmshimp.hxx"
+#include "fmtextcontrolshell.hxx"
+#include "fmundo.hxx"
+#include "fmurl.hxx"
+#include "fmvwimp.hxx"
+#include "formtoolbars.hxx"
+#include "gridcols.hxx"
+#include "svditer.hxx"
+#include "svx/dialmgr.hxx"
+#include "svx/dialogs.hrc"
+#include "svx/fmglob.hxx"
+#include "svx/fmmodel.hxx"
+#include "svx/fmpage.hxx"
+#include "svx/fmshell.hxx"
+#include "svx/obj3d.hxx"
+#include "svx/sdrpagewindow.hxx"
+#include "svx/svdpagv.hxx"
+#include "svx/svxdlg.hxx"
+#include "svx/svxids.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/awt/XCheckBox.hpp>
+#include <com/sun/star/awt/XListBox.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/form/ListSourceType.hpp>
+#include <com/sun/star/form/XBoundComponent.hpp>
+#include <com/sun/star/form/XBoundControl.hpp>
+#include <com/sun/star/form/XGrid.hpp>
+#include <com/sun/star/form/XGridPeer.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/form/XReset.hpp>
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/binding/XListEntrySink.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/util/XModeSelector.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <comphelper/evtmethodhelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/stl_types.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/logfile.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/frame.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/viewsh.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/color.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/shl.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
+#include <osl/mutex.hxx>
+
+#include <algorithm>
+#include <functional>
+
+// wird fuer Invalidate verwendet -> mitpflegen
+sal_uInt16 DatabaseSlotMap[] =
+{
+ SID_FM_RECORD_FIRST,
+ SID_FM_RECORD_NEXT,
+ SID_FM_RECORD_PREV,
+ SID_FM_RECORD_LAST,
+ SID_FM_RECORD_NEW,
+ SID_FM_RECORD_DELETE,
+ SID_FM_RECORD_ABSOLUTE,
+ SID_FM_RECORD_TOTAL,
+ SID_FM_RECORD_SAVE,
+ SID_FM_RECORD_UNDO,
+ SID_FM_REMOVE_FILTER_SORT,
+ SID_FM_SORTUP,
+ SID_FM_SORTDOWN,
+ SID_FM_ORDERCRIT,
+ SID_FM_AUTOFILTER,
+ SID_FM_FORM_FILTERED,
+ SID_FM_REFRESH,
+ SID_FM_REFRESH_FORM_CONTROL,
+ SID_FM_SEARCH,
+ SID_FM_FILTER_START,
+ SID_FM_VIEW_AS_GRID,
+ 0
+};
+
+// wird fuer Invalidate verwendet -> mitpflegen
+// aufsteigend sortieren !!!!!!
+sal_Int16 DlgSlotMap[] = // slots des Controllers
+{
+ SID_FM_CTL_PROPERTIES,
+ SID_FM_PROPERTIES,
+ SID_FM_TAB_DIALOG,
+ SID_FM_ADD_FIELD,
+ SID_FM_SHOW_FMEXPLORER,
+ SID_FM_FIELDS_CONTROL,
+ SID_FM_SHOW_PROPERTIES,
+ SID_FM_PROPERTY_CONTROL,
+ SID_FM_FMEXPLORER_CONTROL,
+ SID_FM_SHOW_DATANAVIGATOR,
+ SID_FM_DATANAVIGATOR_CONTROL,
+ 0
+};
+
+sal_Int16 SelObjectSlotMap[] = // vom SelObject abhaengige Slots
+{
+ SID_FM_CONVERTTO_EDIT,
+ SID_FM_CONVERTTO_BUTTON,
+ SID_FM_CONVERTTO_FIXEDTEXT,
+ SID_FM_CONVERTTO_LISTBOX,
+ SID_FM_CONVERTTO_CHECKBOX,
+ SID_FM_CONVERTTO_RADIOBUTTON,
+ SID_FM_CONVERTTO_GROUPBOX,
+ SID_FM_CONVERTTO_COMBOBOX,
+ SID_FM_CONVERTTO_IMAGEBUTTON,
+ SID_FM_CONVERTTO_FILECONTROL,
+ SID_FM_CONVERTTO_DATE,
+ SID_FM_CONVERTTO_TIME,
+ SID_FM_CONVERTTO_NUMERIC,
+ SID_FM_CONVERTTO_CURRENCY,
+ SID_FM_CONVERTTO_PATTERN,
+ SID_FM_CONVERTTO_IMAGECONTROL,
+ SID_FM_CONVERTTO_FORMATTED,
+ SID_FM_CONVERTTO_SCROLLBAR,
+ SID_FM_CONVERTTO_SPINBUTTON,
+ SID_FM_CONVERTTO_NAVIGATIONBAR,
+
+ SID_FM_FMEXPLORER_CONTROL,
+ SID_FM_DATANAVIGATOR_CONTROL,
+
+ 0
+};
+
+// die folgenden Arrays muessen kosistent sein, also einander entsprechende Eintraege an der selben relativen Position
+// innerhalb ihres jeweiligen Arrays stehen
+sal_Int16 nConvertSlots[] =
+{
+ SID_FM_CONVERTTO_EDIT,
+ SID_FM_CONVERTTO_BUTTON,
+ SID_FM_CONVERTTO_FIXEDTEXT,
+ SID_FM_CONVERTTO_LISTBOX,
+ SID_FM_CONVERTTO_CHECKBOX,
+ SID_FM_CONVERTTO_RADIOBUTTON,
+ SID_FM_CONVERTTO_GROUPBOX,
+ SID_FM_CONVERTTO_COMBOBOX,
+ SID_FM_CONVERTTO_IMAGEBUTTON,
+ SID_FM_CONVERTTO_FILECONTROL,
+ SID_FM_CONVERTTO_DATE,
+ SID_FM_CONVERTTO_TIME,
+ SID_FM_CONVERTTO_NUMERIC,
+ SID_FM_CONVERTTO_CURRENCY,
+ SID_FM_CONVERTTO_PATTERN,
+ SID_FM_CONVERTTO_IMAGECONTROL,
+ SID_FM_CONVERTTO_FORMATTED,
+ SID_FM_CONVERTTO_SCROLLBAR,
+ SID_FM_CONVERTTO_SPINBUTTON,
+ SID_FM_CONVERTTO_NAVIGATIONBAR
+};
+
+sal_Int16 nCreateSlots[] =
+{
+ SID_FM_EDIT,
+ SID_FM_PUSHBUTTON,
+ SID_FM_FIXEDTEXT,
+ SID_FM_LISTBOX,
+ SID_FM_CHECKBOX,
+ SID_FM_RADIOBUTTON,
+ SID_FM_GROUPBOX,
+ SID_FM_COMBOBOX,
+ SID_FM_IMAGEBUTTON,
+ SID_FM_FILECONTROL,
+ SID_FM_DATEFIELD,
+ SID_FM_TIMEFIELD,
+ SID_FM_NUMERICFIELD,
+ SID_FM_CURRENCYFIELD,
+ SID_FM_PATTERNFIELD,
+ SID_FM_IMAGECONTROL,
+ SID_FM_FORMATTEDFIELD,
+ SID_FM_SCROLLBAR,
+ SID_FM_SPINBUTTON,
+ SID_FM_NAVIGATIONBAR
+};
+
+sal_Int16 nObjectTypes[] =
+{
+ OBJ_FM_EDIT,
+ OBJ_FM_BUTTON,
+ OBJ_FM_FIXEDTEXT,
+ OBJ_FM_LISTBOX,
+ OBJ_FM_CHECKBOX,
+ OBJ_FM_RADIOBUTTON,
+ OBJ_FM_GROUPBOX,
+ OBJ_FM_COMBOBOX,
+ OBJ_FM_IMAGEBUTTON,
+ OBJ_FM_FILECONTROL,
+ OBJ_FM_DATEFIELD,
+ OBJ_FM_TIMEFIELD,
+ OBJ_FM_NUMERICFIELD,
+ OBJ_FM_CURRENCYFIELD,
+ OBJ_FM_PATTERNFIELD,
+ OBJ_FM_IMAGECONTROL,
+ OBJ_FM_FORMATTEDFIELD,
+ OBJ_FM_SCROLLBAR,
+ OBJ_FM_SPINBUTTON,
+ OBJ_FM_NAVIGATIONBAR
+};
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::ui;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::form::binding;
+using namespace ::com::sun::star::form::runtime;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::script;
+using namespace ::svxform;
+using namespace ::svx;
+
+//==============================================================================
+//= helper
+//==============================================================================
+namespace
+{
+ //..........................................................................
+ void collectInterfacesFromMarkList( const SdrMarkList& _rMarkList, InterfaceBag& /* [out] */ _rInterfaces )
+ {
+ _rInterfaces.clear();
+
+ sal_uInt32 nMarkCount = _rMarkList.GetMarkCount();
+ for ( sal_uInt32 i = 0; i < nMarkCount; ++i)
+ {
+ SdrObject* pCurrent = _rMarkList.GetMark( i )->GetMarkedSdrObj();
+
+ SdrObjListIter* pGroupIterator = NULL;
+ if ( pCurrent->IsGroupObject() )
+ {
+ pGroupIterator = new SdrObjListIter( *pCurrent->GetSubList() );
+ pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
+ }
+
+ while ( pCurrent )
+ {
+ FmFormObj* pAsFormObject = FmFormObj::GetFormObject( pCurrent );
+ // note this will de-reference virtual objects, if necessary/possible
+ if ( pAsFormObject )
+ {
+ Reference< XInterface > xControlModel( pAsFormObject->GetUnoControlModel(), UNO_QUERY );
+ // the UNO_QUERY is important for normalization
+ if ( xControlModel.is() )
+ _rInterfaces.insert( xControlModel );
+ }
+
+ // next element
+ pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
+ }
+
+ if ( pGroupIterator )
+ delete pGroupIterator;
+ }
+ }
+
+ //..........................................................................
+ sal_Int16 GridView2ModelPos(const Reference< XIndexAccess>& rColumns, sal_Int16 nViewPos)
+ {
+ try
+ {
+ if (rColumns.is())
+ {
+ // loop through all columns
+ sal_Int16 i;
+ Reference< XPropertySet> xCur;
+ for (i=0; i<rColumns->getCount(); ++i)
+ {
+ rColumns->getByIndex(i) >>= xCur;
+ if (!::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN)))
+ {
+ // for every visible col : if nViewPos is greater zero, decrement it, else we
+ // have found the model position
+ if (!nViewPos)
+ break;
+ else
+ --nViewPos;
+ }
+ }
+ if (i<rColumns->getCount())
+ return i;
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return (sal_Int16)-1;
+ }
+
+ //..........................................................................
+ void TransferEventScripts(const Reference< XControlModel>& xModel, const Reference< XControl>& xControl,
+ const Sequence< ScriptEventDescriptor>& rTransferIfAvailable)
+ {
+ // first check if we have a XEventAttacherManager for the model
+ Reference< XChild> xModelChild(xModel, UNO_QUERY);
+ if (!xModelChild.is())
+ return; // nothing to do
+
+ Reference< XEventAttacherManager> xEventManager(xModelChild->getParent(), UNO_QUERY);
+ if (!xEventManager.is())
+ return; // nothing to do
+
+ if (!rTransferIfAvailable.getLength())
+ return; // nothing to do
+
+ // check for the index of the model within it's parent
+ Reference< XIndexAccess> xParentIndex(xModelChild->getParent(), UNO_QUERY);
+ if (!xParentIndex.is())
+ return; // nothing to do
+ sal_Int32 nIndex = getElementPos(xParentIndex, xModel);
+ if (nIndex<0 || nIndex>=xParentIndex->getCount())
+ return; // nothing to do
+
+ // then we need informations about the listeners supported by the control and the model
+ Sequence< Type> aModelListeners;
+ Sequence< Type> aControlListeners;
+
+ Reference< XIntrospection> xModelIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY);
+ Reference< XIntrospection> xControlIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY);
+
+ if (xModelIntrospection.is() && xModel.is())
+ {
+ Any aModel(makeAny(xModel));
+ aModelListeners = xModelIntrospection->inspect(aModel)->getSupportedListeners();
+ }
+
+ if (xControlIntrospection.is() && xControl.is())
+ {
+ Any aControl(makeAny(xControl));
+ aControlListeners = xControlIntrospection->inspect(aControl)->getSupportedListeners();
+ }
+
+ sal_Int32 nMaxNewLen = aModelListeners.getLength() + aControlListeners.getLength();
+ if (!nMaxNewLen)
+ return; // the model and the listener don't support any listeners (or we were unable to retrieve these infos)
+
+ Sequence< ScriptEventDescriptor> aTransferable(nMaxNewLen);
+ ScriptEventDescriptor* pTransferable = aTransferable.getArray();
+
+ const ScriptEventDescriptor* pCurrent = rTransferIfAvailable.getConstArray();
+ sal_Int32 i,j,k;
+ for (i=0; i<rTransferIfAvailable.getLength(); ++i, ++pCurrent)
+ {
+ // search the model/control idl classes for the event described by pCurrent
+ for ( Sequence< Type>* pCurrentArray = &aModelListeners;
+ pCurrentArray;
+ pCurrentArray = (pCurrentArray == &aModelListeners) ? &aControlListeners : NULL
+ )
+ {
+ const Type* pCurrentListeners = pCurrentArray->getConstArray();
+ for (j=0; j<pCurrentArray->getLength(); ++j, ++pCurrentListeners)
+ {
+ UniString aListener = (*pCurrentListeners).getTypeName();
+ xub_StrLen nTokens = aListener.GetTokenCount('.');
+ if (nTokens)
+ aListener = aListener.GetToken(nTokens - 1, '.');
+
+ if (aListener == pCurrent->ListenerType.getStr())
+ // the current ScriptEventDescriptor doesn't match the current listeners class
+ continue;
+
+ // now check the methods
+ Sequence< ::rtl::OUString> aMethodsNames = ::comphelper::getEventMethodsForType(*pCurrentListeners);
+
+ const ::rtl::OUString* pMethodsNames = aMethodsNames.getConstArray();
+ for (k=0; k<aMethodsNames.getLength(); ++k, ++pMethodsNames)
+ {
+ if ((*pMethodsNames).compareTo(pCurrent->EventMethod) != COMPARE_EQUAL)
+ // the current ScriptEventDescriptor doesn't match the current listeners current method
+ continue;
+
+ // we can transfer the script event : the model (control) supports it
+ *pTransferable = *pCurrent;
+ ++pTransferable;
+ break;
+ }
+ if (k<aMethodsNames.getLength())
+ break;
+ }
+ }
+ }
+
+ sal_Int32 nRealNewLen = pTransferable - aTransferable.getArray();
+ aTransferable.realloc(nRealNewLen);
+
+ xEventManager->registerScriptEvents(nIndex, aTransferable);
+ }
+
+ //------------------------------------------------------------------------------
+ ::rtl::OUString getServiceNameByControlType(sal_Int16 nType)
+ {
+ switch (nType)
+ {
+ case OBJ_FM_EDIT : return FM_COMPONENT_TEXTFIELD;
+ case OBJ_FM_BUTTON : return FM_COMPONENT_COMMANDBUTTON;
+ case OBJ_FM_FIXEDTEXT : return FM_COMPONENT_FIXEDTEXT;
+ case OBJ_FM_LISTBOX : return FM_COMPONENT_LISTBOX;
+ case OBJ_FM_CHECKBOX : return FM_COMPONENT_CHECKBOX;
+ case OBJ_FM_RADIOBUTTON : return FM_COMPONENT_RADIOBUTTON;
+ case OBJ_FM_GROUPBOX : return FM_COMPONENT_GROUPBOX;
+ case OBJ_FM_COMBOBOX : return FM_COMPONENT_COMBOBOX;
+ case OBJ_FM_GRID : return FM_COMPONENT_GRIDCONTROL;
+ case OBJ_FM_IMAGEBUTTON : return FM_COMPONENT_IMAGEBUTTON;
+ case OBJ_FM_FILECONTROL : return FM_COMPONENT_FILECONTROL;
+ case OBJ_FM_DATEFIELD : return FM_COMPONENT_DATEFIELD;
+ case OBJ_FM_TIMEFIELD : return FM_COMPONENT_TIMEFIELD;
+ case OBJ_FM_NUMERICFIELD : return FM_COMPONENT_NUMERICFIELD;
+ case OBJ_FM_CURRENCYFIELD : return FM_COMPONENT_CURRENCYFIELD;
+ case OBJ_FM_PATTERNFIELD : return FM_COMPONENT_PATTERNFIELD;
+ case OBJ_FM_HIDDEN : return FM_COMPONENT_HIDDENCONTROL;
+ case OBJ_FM_IMAGECONTROL : return FM_COMPONENT_IMAGECONTROL;
+ case OBJ_FM_FORMATTEDFIELD : return FM_COMPONENT_FORMATTEDFIELD;
+ case OBJ_FM_SCROLLBAR : return FM_SUN_COMPONENT_SCROLLBAR;
+ case OBJ_FM_SPINBUTTON : return FM_SUN_COMPONENT_SPINBUTTON;
+ case OBJ_FM_NAVIGATIONBAR : return FM_SUN_COMPONENT_NAVIGATIONBAR;
+ }
+ return ::rtl::OUString();
+ }
+
+}
+
+//------------------------------------------------------------------------------
+// check if the control has one of the interfaces we can use for searching
+// *_pCurrentText will be filled with the current text of the control (as used when searching this control)
+sal_Bool IsSearchableControl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxControl,
+ ::rtl::OUString* _pCurrentText )
+{
+ if ( !_rxControl.is() )
+ return sal_False;
+
+ Reference< XTextComponent > xAsText( _rxControl, UNO_QUERY );
+ if ( xAsText.is() )
+ {
+ if ( _pCurrentText )
+ *_pCurrentText = xAsText->getText();
+ return sal_True;
+ }
+
+ Reference< XListBox > xListBox( _rxControl, UNO_QUERY );
+ if ( xListBox.is() )
+ {
+ if ( _pCurrentText )
+ *_pCurrentText = xListBox->getSelectedItem();
+ return sal_True;
+ }
+
+ Reference< XCheckBox > xCheckBox( _rxControl, UNO_QUERY );
+ if ( xCheckBox.is() )
+ {
+ if ( _pCurrentText )
+ {
+ switch ( (TriState)xCheckBox->getState() )
+ {
+ case STATE_NOCHECK: *_pCurrentText = ::rtl::OUString::createFromAscii( "0" ); break;
+ case STATE_CHECK: *_pCurrentText = ::rtl::OUString::createFromAscii( "1" ); break;
+ default: *_pCurrentText = ::rtl::OUString(); break;
+ }
+ }
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmXBoundFormFieldIterator::ShouldStepInto(const Reference< XInterface>& _rContainer) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXBoundFormFieldIterator::ShouldStepInto" );
+ if (_rContainer == m_xStartingPoint)
+ // would be quite stupid to step over the root ....
+ return sal_True;
+
+ return Reference< XControlModel>(_rContainer, UNO_QUERY).is();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmXBoundFormFieldIterator::ShouldHandleElement(const Reference< XInterface>& _rElement)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXBoundFormFieldIterator::ShouldHandleElement" );
+ if (!_rElement.is())
+ // NULL element
+ return sal_False;
+
+ if (Reference< XForm>(_rElement, UNO_QUERY).is() || Reference< XGrid>(_rElement, UNO_QUERY).is())
+ // a forms or a grid
+ return sal_False;
+
+ Reference< XPropertySet> xSet(_rElement, UNO_QUERY);
+ if (!xSet.is() || !::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
+ // no "BoundField" property
+ return sal_False;
+
+ Any aVal( xSet->getPropertyValue(FM_PROP_BOUNDFIELD) );
+ if (aVal.getValueTypeClass() != TypeClass_INTERFACE)
+ // void or invalid property value
+ return sal_False;
+
+ return aVal.hasValue();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool isControlList(const SdrMarkList& rMarkList)
+{
+ // enthaelt die liste nur Controls und mindestens ein control
+ sal_uInt32 nMarkCount = rMarkList.GetMarkCount();
+ sal_Bool bControlList = nMarkCount != 0;
+
+ sal_Bool bHadAnyLeafs = sal_False;
+
+ for (sal_uInt32 i = 0; i < nMarkCount && bControlList; i++)
+ {
+ SdrObject *pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ E3dObject* pAs3DObject = PTR_CAST(E3dObject, pObj);
+ // E3dObject's do not contain any 2D-objects (by definition)
+ // we need this extra check here : an E3dObject->IsGroupObject says "YES", but an SdrObjListIter working
+ // with an E3dObject doesn't give me any Nodes (E3dObject has a sub list, but no members in that list,
+ // cause there implementation differs from the one of "normal" SdrObject's. Unfortunally SdrObject::IsGroupObject
+ // doesn't check the element count of the sub list, which is simply a bug in IsGroupObject we can't fix at the moment).
+ // So at the end of this function bControlList would have the same value it was initialized with above : sal_True
+ // And this would be wrong :)
+ // 03.02.00 - 72529 - FS
+ if (!pAs3DObject)
+ {
+ if (pObj->IsGroupObject())
+ {
+ SdrObjListIter aIter(*pObj->GetSubList());
+ while (aIter.IsMore() && bControlList)
+ {
+ bControlList = FmFormInventor == aIter.Next()->GetObjInventor();
+ bHadAnyLeafs = sal_True;
+ }
+ }
+ else
+ {
+ bHadAnyLeafs = sal_True;
+ bControlList = FmFormInventor == pObj->GetObjInventor();
+ }
+ }
+ }
+
+ return bControlList && bHadAnyLeafs;
+}
+
+//------------------------------------------------------------------------
+Reference< XForm > GetForm(const Reference< XInterface>& _rxElement)
+{
+ Reference< XForm > xForm( _rxElement, UNO_QUERY );
+ if ( xForm.is() )
+ return xForm;
+
+ Reference< XChild > xChild( _rxElement, UNO_QUERY );
+ if ( xChild.is() )
+ return GetForm( xChild->getParent() );
+
+ return Reference< XForm >();
+}
+
+//========================================================================
+// class FmXFormShell_Base_Disambiguation
+//========================================================================
+FmXFormShell_Base_Disambiguation::FmXFormShell_Base_Disambiguation( ::osl::Mutex& _rMutex )
+ :FmXFormShell_BD_BASE( _rMutex )
+{
+}
+
+void SAL_CALL FmXFormShell_Base_Disambiguation::disposing()
+{
+ WeakComponentImplHelperBase::disposing();
+ // Note:
+ // This is a HACK.
+ // Normally it should be sufficient to call the "disposing" of our direct
+ // base class, but SUN PRO 5 does not like this and claims there is a conflict
+ // with the XEventListener::disposing(EventObject) of our various listener
+ // base classes.
+}
+
+//========================================================================
+// class FmXFormShell
+//========================================================================
+DBG_NAME(FmXFormShell);
+//------------------------------------------------------------------------
+FmXFormShell::FmXFormShell( FmFormShell& _rShell, SfxViewFrame* _pViewFrame )
+ :FmXFormShell_BASE(m_aMutex)
+ ,FmXFormShell_CFGBASE(::rtl::OUString::createFromAscii("Office.Common/Misc"), CONFIG_MODE_DELAYED_UPDATE)
+ ,m_eNavigate( NavigationBarMode_NONE )
+ ,m_nInvalidationEvent( 0 )
+ ,m_nActivationEvent( 0 )
+ ,m_pShell( &_rShell )
+ ,m_pTextShell( new ::svx::FmTextControlShell( _pViewFrame ) )
+ ,m_aActiveControllerFeatures( ::comphelper::getProcessServiceFactory(), this )
+ ,m_aNavControllerFeatures( ::comphelper::getProcessServiceFactory(), this )
+ ,m_eDocumentType( eUnknownDocumentType )
+ ,m_nLockSlotInvalidation( 0 )
+ ,m_bHadPropertyBrowserInDesignMode( sal_False )
+ ,m_bTrackProperties( sal_True )
+ ,m_bUseWizards( sal_True )
+ ,m_bDatabaseBar( sal_False )
+ ,m_bInActivate( sal_False )
+ ,m_bSetFocus( sal_False )
+ ,m_bFilterMode( sal_False )
+ ,m_bChangingDesignMode( sal_False )
+ ,m_bPreparedClose( sal_False )
+ ,m_bFirstActivation( sal_True )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::FmXFormShell" );
+ DBG_CTOR(FmXFormShell,NULL);
+ m_aMarkTimer.SetTimeout(100);
+ m_aMarkTimer.SetTimeoutHdl(LINK(this,FmXFormShell,OnTimeOut));
+
+ if ( _pViewFrame )
+ m_xAttachedFrame = _pViewFrame->GetFrame().GetFrameInterface();
+
+ // to prevent deletion of this we acquire our refcounter once
+ ::comphelper::increment(FmXFormShell_BASE::m_refCount);
+
+ // correct the refcounter
+ ::comphelper::decrement(FmXFormShell_BASE::m_refCount);
+
+ // cache the current configuration settings we're interested in
+ implAdjustConfigCache();
+ // and register for changes on this settings
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii("FormControlPilotsEnabled");
+ EnableNotification(aNames);
+}
+
+//------------------------------------------------------------------------
+FmXFormShell::~FmXFormShell()
+{
+ delete m_pTextShell;
+ DBG_DTOR(FmXFormShell,NULL);
+}
+
+//------------------------------------------------------------------
+Reference< XModel > FmXFormShell::getContextDocument() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::getContextDocument" );
+ Reference< XModel > xModel;
+
+ // determine the type of document we live in
+ try
+ {
+ Reference< XController > xController;
+ if ( m_xAttachedFrame.is() )
+ xController = m_xAttachedFrame->getController();
+ if ( xController.is() )
+ xModel = xController->getModel();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xModel;
+}
+
+//------------------------------------------------------------------
+bool FmXFormShell::isEnhancedForm() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::isEnhancedForm" );
+ return getDocumentType() == eEnhancedForm;
+}
+
+//------------------------------------------------------------------
+bool FmXFormShell::impl_checkDisposed() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::impl_checkDisposed" );
+ if ( !m_pShell )
+ {
+ OSL_ENSURE( false, "FmXFormShell::impl_checkDisposed: already disposed!" );
+ return true;
+ }
+ return false;
+}
+
+//------------------------------------------------------------------
+::svxform::DocumentType FmXFormShell::getDocumentType() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::getDocumentType" );
+ if ( m_eDocumentType != eUnknownDocumentType )
+ return m_eDocumentType;
+
+ // determine the type of document we live in
+ Reference< XModel > xModel = getContextDocument();
+ if ( xModel.is() )
+ m_eDocumentType = DocumentClassification::classifyDocument( xModel );
+ else
+ {
+ OSL_ENSURE( sal_False, "FmXFormShell::getDocumentType: can't determine the document type!" );
+ m_eDocumentType = eTextDocument;
+ // fallback, just to have a defined state
+ }
+
+ return m_eDocumentType;
+}
+
+//------------------------------------------------------------------
+bool FmXFormShell::IsReadonlyDoc() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::IsReadonlyDoc" );
+ if ( impl_checkDisposed() )
+ return true;
+
+ FmFormModel* pModel = m_pShell->GetFormModel();
+ if ( pModel && pModel->GetObjectShell() )
+ return pModel->GetObjectShell()->IsReadOnly() || pModel->GetObjectShell()->IsReadOnlyUI();
+ return true;
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FmXFormShell::queryInterface( const Type& type) throw ( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::queryInterface" );
+ return FmXFormShell_BASE::queryInterface(type);
+}
+//------------------------------------------------------------------------------
+Sequence< Type > SAL_CALL FmXFormShell::getTypes( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::getTypes" );
+ return FmXFormShell_BASE::getTypes();
+}
+//------------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL FmXFormShell::getImplementationId() throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::getImplementationId" );
+ static ::cppu::OImplementationId* pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+// EventListener
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFormShell::disposing(const EventObject& e) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::disposing" );
+ impl_checkDisposed();
+
+ if (m_xActiveController == e.Source)
+ {
+ // wird der Controller freigeben dann alles loslassen
+ stopListening();
+ m_xActiveForm = NULL;
+ m_xActiveController = NULL;
+ m_xNavigationController = NULL;
+
+ m_aActiveControllerFeatures.dispose();
+ m_aNavControllerFeatures.dispose();
+
+ if ( m_pShell )
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
+ }
+
+ if (e.Source == m_xExternalViewController)
+ {
+ Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY );
+ OSL_ENSURE( xFormController.is(), "FmXFormShell::disposing: invalid external view controller!" );
+ if (xFormController.is())
+ xFormController->removeActivateListener((XFormControllerListener*)this);
+
+ Reference< ::com::sun::star::lang::XComponent> xComp(m_xExternalViewController, UNO_QUERY);
+ if (xComp.is())
+ xComp->removeEventListener((XEventListener*)(XPropertyChangeListener*)this);
+
+ m_xExternalViewController = NULL;
+ m_xExternalDisplayedForm = NULL;
+ m_xExtViewTriggerController = NULL;
+
+ InvalidateSlot( SID_FM_VIEW_AS_GRID, sal_False );
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFormShell::propertyChange(const PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::propertyChange" );
+ if ( impl_checkDisposed() )
+ return;
+
+ if (evt.PropertyName == FM_PROP_ROWCOUNT)
+ {
+ // Das gleich folgenden Update erzwingt ein Neu-Painten der entsprechenden Slots. Wenn ich mich aber hier nicht
+ // in dem HauptThread der Applikation befinde (weil zum Beispiel ein Cursor gerade Datensaetze zaehlt und mir dabei
+ // immer diese PropertyChanges beschert), kann sich das mit en normalen Paints im HauptThread der Applikation beissen.
+ // (Solche Paints passieren zum Beispiel, wenn man einfach nur eine andere Applikation ueber das Office legt und wieder
+ // zurueckschaltet).
+ // Deshalb die Benutzung des SolarMutex, der sichert das ab.
+ ::osl::SolarMutex& rSolarSafety = Application::GetSolarMutex();
+ if (rSolarSafety.tryToAcquire())
+ {
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_RECORD_TOTAL , sal_True, sal_False);
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Update(SID_FM_RECORD_TOTAL);
+ rSolarSafety.release();
+ }
+ else
+ {
+ // with the following the slot is invalidated asynchron
+ LockSlotInvalidation(sal_True);
+ InvalidateSlot(SID_FM_RECORD_TOTAL, sal_False);
+ LockSlotInvalidation(sal_False);
+ }
+ }
+
+ // this may be called from a non-main-thread so invalidate the shell asynchronously
+ LockSlotInvalidation(sal_True);
+ InvalidateSlot(0, 0); // special meaning : invalidate m_pShell
+ LockSlotInvalidation(sal_False);
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::invalidateFeatures" );
+ if ( impl_checkDisposed() )
+ return;
+
+ OSL_ENSURE( _rFeatures.size() > 0, "FmXFormShell::invalidateFeatures: invalid arguments!" );
+
+ if ( m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame() )
+ {
+ // unfortunately, SFX requires sal_uInt16
+ ::std::vector< sal_uInt16 > aSlotIds;
+ aSlotIds.reserve( _rFeatures.size() );
+ ::std::copy( _rFeatures.begin(),
+ _rFeatures.end(),
+ ::std::insert_iterator< ::std::vector< sal_uInt16 > >( aSlotIds, aSlotIds.begin() )
+ );
+
+ // furthermore, SFX wants a terminating 0
+ aSlotIds.push_back( 0 );
+
+ // and, last but not least, SFX wants the ids to be sorted
+ ::std::sort( aSlotIds.begin(), aSlotIds.end() - 1 );
+
+ sal_uInt16 *pSlotIds = aSlotIds.empty() ? 0 : &(aSlotIds[0]);
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( pSlotIds );
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFormShell::formActivated(const EventObject& rEvent) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::formActivated" );
+ if ( impl_checkDisposed() )
+ return;
+
+ Reference< runtime::XFormController > xController( rEvent.Source, UNO_QUERY_THROW );
+ m_pTextShell->formActivated( xController );
+ setActiveController( xController );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFormShell::formDeactivated(const EventObject& rEvent) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::formDeactivated" );
+ if ( impl_checkDisposed() )
+ return;
+
+ Reference< runtime::XFormController > xController( rEvent.Source, UNO_QUERY_THROW );
+ m_pTextShell->formDeactivated( xController );
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::disposing" );
+ impl_checkDisposed();
+
+ FmXFormShell_BASE::disposing();
+
+ if ( m_pShell && !m_pShell->IsDesignMode() )
+ setActiveController( NULL, sal_True );
+ // do NOT save the content of the old form (the second parameter tells this)
+ // if we're here, then we expect that PrepareClose has been called, and thus the user
+ // got a chance to commit or reject any changes. So in case we're here and there
+ // are still uncommitted changes, the user explicitly wanted this.
+ // 2002-11-11 - 104702 - fs@openoffice.org
+
+ m_pTextShell->dispose();
+
+ m_xAttachedFrame = NULL;
+
+ CloseExternalFormViewer();
+
+ while ( m_aLoadingPages.size() )
+ {
+ Application::RemoveUserEvent( m_aLoadingPages.front().nEventId );
+ m_aLoadingPages.pop();
+ }
+
+ {
+ ::osl::MutexGuard aGuard(m_aInvalidationSafety);
+ if (m_nInvalidationEvent)
+ {
+ Application::RemoveUserEvent(m_nInvalidationEvent);
+ m_nInvalidationEvent = 0;
+ }
+ if ( m_nActivationEvent )
+ {
+ Application::RemoveUserEvent( m_nActivationEvent );
+ m_nActivationEvent = 0;
+ }
+ }
+
+ {
+ ::osl::ClearableMutexGuard aGuard(m_aAsyncSafety);
+ aGuard.clear();
+
+ DBG_ASSERT(!m_nInvalidationEvent, "FmXFormShell::~FmXFormShell : still have an invalidation event !");
+ // should habe been deleted while beeing disposed
+
+ m_aMarkTimer.Stop();
+ }
+
+ DisableNotification();
+
+ RemoveElement( m_xForms );
+ m_xForms.clear();
+
+ impl_switchActiveControllerListening( false );
+ m_xActiveController = NULL;
+ m_xActiveForm = NULL;
+
+ m_pShell = NULL;
+ m_xNavigationController = NULL;
+ m_xCurrentForm = NULL;
+ m_xLastGridFound = NULL;
+ m_xAttachedFrame = NULL;
+ m_xExternalViewController = NULL;
+ m_xExtViewTriggerController = NULL;
+ m_xExternalDisplayedForm = NULL;
+ m_xLastGridFound = NULL;
+
+ InterfaceBag aEmpty;
+ m_aCurrentSelection.swap( aEmpty );
+
+ m_aActiveControllerFeatures.dispose();
+ m_aNavControllerFeatures.dispose();
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::UpdateSlot( sal_Int16 _nId )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::UpdateSlot" );
+ if ( impl_checkDisposed() )
+ return;
+
+ ::osl::MutexGuard aGuard(m_aInvalidationSafety);
+
+ if ( m_nLockSlotInvalidation )
+ {
+ OSL_ENSURE( sal_False, "FmXFormShell::UpdateSlot: cannot update if invalidation is currently locked!" );
+ InvalidateSlot( _nId, sal_False );
+ }
+ else
+ {
+ OSL_ENSURE( _nId, "FmXFormShell::UpdateSlot: can't update the complete shell!" );
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate( _nId, sal_True, sal_True );
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Update( _nId );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::InvalidateSlot( sal_Int16 nId, sal_Bool bWithId )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::InvalidateSlot" );
+ if ( impl_checkDisposed() )
+ return;
+
+ ::osl::MutexGuard aGuard(m_aInvalidationSafety);
+ if (m_nLockSlotInvalidation)
+ {
+ m_arrInvalidSlots.Insert(nId, m_arrInvalidSlots.Count());
+ BYTE nFlags = ( bWithId ? 0x01 : 0 );
+ m_arrInvalidSlots_Flags.Insert(nFlags, m_arrInvalidSlots_Flags.Count());
+ }
+ else
+ if (nId)
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(nId, sal_True, bWithId);
+ else
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::LockSlotInvalidation(sal_Bool bLock)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::LockSlotInvalidation" );
+ if ( impl_checkDisposed() )
+ return;
+
+ ::osl::MutexGuard aGuard(m_aInvalidationSafety);
+ DBG_ASSERT(bLock || m_nLockSlotInvalidation>0, "FmXFormShell::LockSlotInvalidation : invalid call !");
+
+ if (bLock)
+ ++m_nLockSlotInvalidation;
+ else if (!--m_nLockSlotInvalidation)
+ {
+ // alles, was sich waehrend der gelockten Phase angesammelt hat, (asynchron) invalidieren
+ if (!m_nInvalidationEvent)
+ m_nInvalidationEvent = Application::PostUserEvent(LINK(this, FmXFormShell, OnInvalidateSlots));
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FmXFormShell, OnInvalidateSlots, void*, EMPTYARG)
+{
+ if ( impl_checkDisposed() )
+ return 0L;
+
+ ::osl::MutexGuard aGuard(m_aInvalidationSafety);
+ m_nInvalidationEvent = 0;
+
+ DBG_ASSERT(m_arrInvalidSlots.Count() == m_arrInvalidSlots_Flags.Count(),
+ "FmXFormShell::OnInvalidateSlots : inconsistent slot arrays !");
+ BYTE nFlags;
+ for (sal_Int16 i=0; i<m_arrInvalidSlots.Count(); ++i)
+ {
+ nFlags = m_arrInvalidSlots_Flags[i];
+
+ if (m_arrInvalidSlots[i])
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(m_arrInvalidSlots[i], sal_True, (nFlags & 0x01));
+ else
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
+ }
+
+ m_arrInvalidSlots.Remove(0, m_arrInvalidSlots.Count());
+ m_arrInvalidSlots_Flags.Remove(0, m_arrInvalidSlots_Flags.Count());
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::ForceUpdateSelection(sal_Bool bAllowInvalidation)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::ForceUpdateSelection" );
+ if ( impl_checkDisposed() )
+ return;
+
+ if (IsSelectionUpdatePending())
+ {
+ m_aMarkTimer.Stop();
+
+ // die Invalidierung der Slots, die implizit von SetSelection besorgt wird, eventuell abschalten
+ if (!bAllowInvalidation)
+ LockSlotInvalidation(sal_True);
+
+ SetSelection(m_pShell->GetFormView()->GetMarkedObjectList());
+
+ if (!bAllowInvalidation)
+ LockSlotInvalidation(sal_False);
+ }
+}
+
+//------------------------------------------------------------------------------
+PopupMenu* FmXFormShell::GetConversionMenu()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::GetConversionMenu" );
+ const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
+ BOOL bIsHiContrastMode = rSettings.GetHighContrastMode();
+
+ PopupMenu* pNewMenu = new PopupMenu(SVX_RES( RID_FMSHELL_CONVERSIONMENU ));
+
+ ImageList aImageList( SVX_RES( bIsHiContrastMode ? RID_SVXIMGLIST_FMEXPL_HC : RID_SVXIMGLIST_FMEXPL) );
+ for ( size_t i = 0; i < SAL_N_ELEMENTS( nConvertSlots ); ++i )
+ {
+ // das entsprechende Image dran
+ pNewMenu->SetItemImage(nConvertSlots[i], aImageList.GetImage(nCreateSlots[i]));
+ }
+
+ return pNewMenu;
+}
+
+//------------------------------------------------------------------------------
+bool FmXFormShell::isControlConversionSlot( sal_uInt16 nSlotId )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::isControlConversionSlot" );
+ for ( size_t i = 0; i < SAL_N_ELEMENTS( nConvertSlots ); ++i )
+ if (nConvertSlots[i] == nSlotId)
+ return true;
+ return false;
+}
+
+//------------------------------------------------------------------------------
+bool FmXFormShell::executeControlConversionSlot( sal_uInt16 _nSlotId )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::executeControlConversionSlot" );
+ OSL_PRECOND( canConvertCurrentSelectionToControl( _nSlotId ), "FmXFormShell::executeControlConversionSlot: illegal call!" );
+ InterfaceBag::const_iterator aSelectedElement = m_aCurrentSelection.begin();
+ if ( aSelectedElement == m_aCurrentSelection.end() )
+ return false;
+
+ return executeControlConversionSlot( Reference< XFormComponent >( *aSelectedElement, UNO_QUERY ), _nSlotId );
+}
+
+//------------------------------------------------------------------------------
+bool FmXFormShell::executeControlConversionSlot( const Reference< XFormComponent >& _rxObject, sal_uInt16 _nSlotId )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::executeControlConversionSlot" );
+ if ( impl_checkDisposed() )
+ return false;
+
+ OSL_ENSURE( _rxObject.is(), "FmXFormShell::executeControlConversionSlot: invalid object!" );
+ if ( !_rxObject.is() )
+ return false;
+
+ SdrPage* pPage = m_pShell->GetCurPage();
+ FmFormPage* pFormPage = pPage ? dynamic_cast< FmFormPage* >( pPage ) : NULL;
+ OSL_ENSURE( pFormPage, "FmXFormShell::executeControlConversionSlot: no current (form) page!" );
+ if ( !pFormPage )
+ return false;
+
+ OSL_ENSURE( isSolelySelected( _rxObject ),
+ "FmXFormShell::executeControlConversionSlot: hmm ... shouldn't this parameter be redundant?" );
+
+ for ( size_t lookupSlot = 0; lookupSlot < SAL_N_ELEMENTS( nConvertSlots ); ++lookupSlot )
+ {
+ if (nConvertSlots[lookupSlot] == _nSlotId)
+ {
+ Reference< XInterface > xNormalizedObject( _rxObject, UNO_QUERY );
+
+ FmFormObj* pFormObject = NULL;
+ SdrObjListIter aPageIter( *pFormPage );
+ while ( aPageIter.IsMore() )
+ {
+ SdrObject* pCurrent = aPageIter.Next();
+ pFormObject = FmFormObj::GetFormObject( pCurrent );
+ if ( !pFormObject )
+ continue;
+
+ Reference< XInterface > xCurrentNormalized( pFormObject->GetUnoControlModel(), UNO_QUERY );
+ if ( xCurrentNormalized.get() == xNormalizedObject.get() )
+ break;
+
+ pFormObject = NULL;
+ }
+
+ if ( !pFormObject )
+ return false;
+
+ ::rtl::OUString sNewName( getServiceNameByControlType( nObjectTypes[ lookupSlot ] ) );
+ Reference< XControlModel> xNewModel( ::comphelper::getProcessServiceFactory()->createInstance( sNewName ), UNO_QUERY );
+ if (!xNewModel.is())
+ return false;
+
+ Reference< XControlModel> xOldModel( pFormObject->GetUnoControlModel() );
+ Reference< XServiceInfo> xModelInfo(xOldModel, UNO_QUERY);
+
+ // Properties uebertragen
+ Reference< XPropertySet> xOldSet(xOldModel, UNO_QUERY);
+ Reference< XPropertySet> xNewSet(xNewModel, UNO_QUERY);
+
+
+ Locale aNewLanguage = Application::GetSettings().GetUILocale();
+ TransferFormComponentProperties(xOldSet, xNewSet, aNewLanguage);
+
+ Sequence< ::com::sun::star::script::ScriptEventDescriptor> aOldScripts;
+ Reference< XChild> xChild(xOldModel, UNO_QUERY);
+ if (xChild.is())
+ {
+ Reference< XIndexAccess> xParent(xChild->getParent(), UNO_QUERY);
+
+ // remember old script events
+ Reference< ::com::sun::star::script::XEventAttacherManager> xEvManager(xChild->getParent(), UNO_QUERY);
+ if (xParent.is() && xEvManager.is())
+ {
+ sal_Int32 nIndex = getElementPos(xParent, xOldModel);
+ if (nIndex>=0 && nIndex<xParent->getCount())
+ aOldScripts = xEvManager->getScriptEvents(nIndex);
+ }
+
+ // replace the mdoel within the parent container
+ Reference< XIndexContainer> xIndexParent(xChild->getParent(), UNO_QUERY);
+ if (xIndexParent.is())
+ {
+ // the form container works with FormComponents
+ Reference< XFormComponent> xComponent(xNewModel, UNO_QUERY);
+ DBG_ASSERT(xComponent.is(), "FmXFormShell::executeControlConversionSlot: the new model is no form component !");
+ Any aNewModel(makeAny(xComponent));
+ try
+ {
+
+ sal_Int32 nIndex = getElementPos(xParent, xOldModel);
+ if (nIndex>=0 && nIndex<xParent->getCount())
+ xIndexParent->replaceByIndex(nIndex, aNewModel);
+ else
+ {
+ DBG_ERROR("FmXFormShell::executeControlConversionSlot: could not replace the model !");
+ Reference< ::com::sun::star::lang::XComponent> xNewComponent(xNewModel, UNO_QUERY);
+ if (xNewComponent.is())
+ xNewComponent->dispose();
+ return false;
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmXFormShell::executeControlConversionSlot: could not replace the model !");
+ Reference< ::com::sun::star::lang::XComponent> xNewComponent(xNewModel, UNO_QUERY);
+ if (xNewComponent.is())
+ xNewComponent->dispose();
+ return false;
+ }
+
+ }
+ }
+
+ // special handling for the LabelControl-property : can only be set when the model is placed
+ // within the forms hierarchy
+ if (::comphelper::hasProperty(FM_PROP_CONTROLLABEL, xOldSet) && ::comphelper::hasProperty(FM_PROP_CONTROLLABEL, xNewSet))
+ {
+ try
+ {
+ xNewSet->setPropertyValue(FM_PROP_CONTROLLABEL, xOldSet->getPropertyValue(FM_PROP_CONTROLLABEL));
+ }
+ catch(Exception&)
+ {
+ }
+
+ }
+
+ // neues Model setzen
+ pFormObject->SetChanged();
+ pFormObject->SetUnoControlModel(xNewModel);
+
+ // transfer script events
+ // (do this _after_ SetUnoControlModel as we need the new (implicitly created) control)
+ if (aOldScripts.getLength())
+ {
+ // das Control zum Model suchen
+ Reference< XControlContainer > xControlContainer( getControlContainerForView() );
+
+ Sequence< Reference< XControl> > aControls( xControlContainer->getControls() );
+ const Reference< XControl>* pControls = aControls.getConstArray();
+
+ sal_uInt32 nLen = aControls.getLength();
+ Reference< XControl> xControl;
+ for (sal_uInt32 i=0 ; i<nLen; ++i)
+ {
+ if (pControls[i]->getModel() == xNewModel)
+ {
+ xControl = pControls[i];
+ break;
+ }
+ }
+ TransferEventScripts(xNewModel, xControl, aOldScripts);
+ }
+
+ // transfer value bindings, if possible
+ {
+ Reference< XBindableValue > xOldBindable( xOldModel, UNO_QUERY );
+ Reference< XBindableValue > xNewBindable( xNewModel, UNO_QUERY );
+ if ( xOldBindable.is() )
+ {
+ try
+ {
+ if ( xNewBindable.is() )
+ xNewBindable->setValueBinding( xOldBindable->getValueBinding() );
+ xOldBindable->setValueBinding( NULL );
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ // same for list entry sources
+ {
+ Reference< XListEntrySink > xOldSink( xOldModel, UNO_QUERY );
+ Reference< XListEntrySink > xNewSink( xNewModel, UNO_QUERY );
+ if ( xOldSink.is() )
+ {
+ try
+ {
+ if ( xNewSink.is() )
+ xNewSink->setListEntrySource( xOldSink->getListEntrySource() );
+ xOldSink->setListEntrySource( NULL );
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ // create an undo action
+ FmFormModel* pModel = m_pShell->GetFormModel();
+ DBG_ASSERT(pModel != NULL, "FmXFormShell::executeControlConversionSlot: my shell has no model !");
+ if (pModel && pModel->IsUndoEnabled() )
+ {
+ pModel->AddUndo(new FmUndoModelReplaceAction(*pModel, pFormObject, xOldModel));
+ }
+ else
+ {
+ FmUndoModelReplaceAction::DisposeElement( xOldModel );
+ }
+
+ return true;
+ }
+ }
+ return false;
+}
+
+//------------------------------------------------------------------------------
+bool FmXFormShell::canConvertCurrentSelectionToControl( sal_Int16 nConversionSlot )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::canConvertCurrentSelectionToControl" );
+ if ( m_aCurrentSelection.empty() )
+ return false;
+
+ InterfaceBag::const_iterator aCheck = m_aCurrentSelection.begin();
+ Reference< XServiceInfo > xElementInfo( *aCheck, UNO_QUERY );
+ if ( !xElementInfo.is() )
+ // no service info -> cannot determine this
+ return false;
+
+ if ( ++aCheck != m_aCurrentSelection.end() )
+ // more than one element
+ return false;
+
+ if ( Reference< XForm >::query( xElementInfo ).is() )
+ // it's a form
+ return false;
+
+ sal_Int16 nObjectType = getControlTypeByObject( xElementInfo );
+
+ if ( ( OBJ_FM_HIDDEN == nObjectType )
+ || ( OBJ_FM_CONTROL == nObjectType )
+ || ( OBJ_FM_GRID == nObjectType )
+ )
+ return false; // those types cannot be converted
+
+ DBG_ASSERT(SAL_N_ELEMENTS(nConvertSlots) == SAL_N_ELEMENTS(nObjectTypes),
+ "FmXFormShell::canConvertCurrentSelectionToControl: nConvertSlots & nObjectTypes must have the same size !");
+
+ for ( size_t i = 0; i < SAL_N_ELEMENTS( nConvertSlots ); ++i )
+ if (nConvertSlots[i] == nConversionSlot)
+ return nObjectTypes[i] != nObjectType;
+
+ return sal_True; // all other slots: assume "yes"
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::checkControlConversionSlotsForCurrentSelection( Menu& rMenu )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::checkControlConversionSlotsForCurrentSelection" );
+ for (sal_Int16 i=0; i<rMenu.GetItemCount(); ++i)
+ // der Context ist schon von einem Typ, der dem Eitnrag entspricht -> disable
+ rMenu.EnableItem( rMenu.GetItemId(i), canConvertCurrentSelectionToControl( rMenu.GetItemId( i ) ) );
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::LoopGrids(sal_Int16 nWhat)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::LoopGrids" );
+ if ( impl_checkDisposed() )
+ return;
+
+ Reference< XIndexContainer> xControlModels(m_xActiveForm, UNO_QUERY);
+ if (xControlModels.is())
+ {
+ for (sal_Int16 i=0; i<xControlModels->getCount(); ++i)
+ {
+ Reference< XPropertySet> xModelSet;
+ xControlModels->getByIndex(i) >>= xModelSet;
+ if (!xModelSet.is())
+ continue;
+
+ if (!::comphelper::hasProperty(FM_PROP_CLASSID, xModelSet))
+ continue;
+ sal_Int16 nClassId = ::comphelper::getINT16(xModelSet->getPropertyValue(FM_PROP_CLASSID));
+ if (FormComponentType::GRIDCONTROL != nClassId)
+ continue;
+
+ if (!::comphelper::hasProperty(FM_PROP_CURSORCOLOR, xModelSet) || !::comphelper::hasProperty(FM_PROP_ALWAYSSHOWCURSOR, xModelSet) || !::comphelper::hasProperty(FM_PROP_DISPLAYSYNCHRON, xModelSet))
+ continue;
+
+ switch (nWhat & GA_SYNC_MASK)
+ {
+ case GA_DISABLE_SYNC:
+ {
+ sal_Bool bB(sal_False);
+ xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(&bB,getBooleanCppuType()));
+ }
+ break;
+ case GA_FORCE_SYNC:
+ {
+ Any aOldVal( xModelSet->getPropertyValue(FM_PROP_DISPLAYSYNCHRON) );
+ sal_Bool bB(sal_True);
+ xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(&bB,getBooleanCppuType()));
+ xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, aOldVal);
+ }
+ break;
+ case GA_ENABLE_SYNC:
+ {
+ sal_Bool bB(sal_True);
+ xModelSet->setPropertyValue(FM_PROP_DISPLAYSYNCHRON, Any(&bB,getBooleanCppuType()));
+ }
+ break;
+ }
+
+ if (nWhat & GA_DISABLE_ROCTRLR)
+ {
+ sal_Bool bB(sal_False);
+ xModelSet->setPropertyValue(FM_PROP_ALWAYSSHOWCURSOR, Any(&bB,getBooleanCppuType()));
+ Reference< XPropertyState> xModelPropState(xModelSet, UNO_QUERY);
+ if (xModelPropState.is())
+ xModelPropState->setPropertyToDefault(FM_PROP_CURSORCOLOR);
+ else
+ xModelSet->setPropertyValue(FM_PROP_CURSORCOLOR, Any()); // this should be the default
+ }
+ else if (nWhat & GA_ENABLE_ROCTRLR)
+ {
+ sal_Bool bB(sal_True);
+ xModelSet->setPropertyValue(FM_PROP_ALWAYSSHOWCURSOR, Any(&bB,getBooleanCppuType()));
+ xModelSet->setPropertyValue(FM_PROP_CURSORCOLOR, makeAny(sal_Int32(COL_LIGHTRED)));
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+Reference< XControlContainer > FmXFormShell::getControlContainerForView()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::getControlContainerForView" );
+ if ( impl_checkDisposed() )
+ return NULL;
+
+ SdrPageView* pPageView = NULL;
+ if ( m_pShell && m_pShell->GetFormView() )
+ pPageView = m_pShell->GetFormView()->GetSdrPageView();
+
+ Reference< XControlContainer> xControlContainer;
+ if ( pPageView )
+ xControlContainer = pPageView->GetPageWindow(0)->GetControlContainer();
+
+ return xControlContainer;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::ExecuteTabOrderDialog( const Reference< XTabControllerModel >& _rxForForm )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::ExecuteTabOrderDialog" );
+ if ( impl_checkDisposed() )
+ return;
+
+ OSL_PRECOND( _rxForForm.is(), "FmXFormShell::ExecuteTabOrderDialog: invalid tabbing model!" );
+ if ( !_rxForForm.is() )
+ return;
+
+ try
+ {
+ Sequence< Any > aDialogArgs( 3 );
+ aDialogArgs[0] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TabbingModel" ) ),
+ makeAny( _rxForForm )
+ );
+ aDialogArgs[1] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) ),
+ makeAny( getControlContainerForView() )
+ );
+
+ Reference< XWindow > xParentWindow;
+ if ( m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame() )
+ xParentWindow = VCLUnoHelper::GetInterface ( &m_pShell->GetViewShell()->GetViewFrame()->GetWindow() );
+ aDialogArgs[2] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ) ),
+ makeAny( xParentWindow )
+ );
+
+ Reference< dialogs::XExecutableDialog > xDialog(
+ ::comphelper::getProcessServiceFactory()->createInstanceWithArguments(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.ui.TabOrderDialog" ) ),
+ aDialogArgs
+ ),
+ UNO_QUERY
+ );
+ OSL_ENSURE( xDialog.is(), "FmXFormShell::ExecuteTabOrderDialog: could not create the dialog!" );
+
+ if ( xDialog.is() )
+ xDialog->execute();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmXFormShell::ExecuteTabOrderDialog: caught an exception!" );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::ExecuteSearch()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::ExecuteSearch" );
+ if ( impl_checkDisposed() )
+ return;
+
+ // eine Sammlung aller (logischen) Formulare
+ FmFormArray aEmpty;
+ m_aSearchForms.swap( aEmpty );
+ ::std::vector< String > aContextNames;
+ impl_collectFormSearchContexts_nothrow( m_pShell->GetCurPage()->GetForms(), ::rtl::OUString(), m_aSearchForms, aContextNames );
+ OSL_POSTCOND( m_aSearchForms.size() == aContextNames.size(),
+ "FmXFormShell::ExecuteSearch: nonsense!" );
+ if ( m_aSearchForms.size() != aContextNames.size() )
+ return;
+
+ // filter out the forms which do not contain valid controls at all
+ {
+ FmFormArray aValidForms;
+ ::std::vector< String > aValidContexts;
+ FmFormArray::const_iterator form = m_aSearchForms.begin();
+ ::std::vector< String >::const_iterator contextName = aContextNames.begin();
+ for ( ; form != m_aSearchForms.end(); ++form, ++contextName )
+ {
+ FmSearchContext aTestContext;
+ aTestContext.nContext = static_cast< sal_Int16 >( form - m_aSearchForms.begin() );
+ sal_uInt32 nValidControls = OnSearchContextRequest( &aTestContext );
+ if ( nValidControls > 0 )
+ {
+ aValidForms.push_back( *form );
+ aValidContexts.push_back( *contextName );
+ }
+ }
+
+ m_aSearchForms.swap( aValidForms );
+ aContextNames.swap( aValidContexts );
+ }
+
+ if (m_aSearchForms.size() == 0)
+ { // es gibt keine Controls, die alle Bedingungen fuer eine Suche erfuellen
+ ErrorBox(NULL, WB_OK, SVX_RESSTR(RID_STR_NODATACONTROLS)).Execute();
+ return;
+ }
+
+ // jetzt brauche ich noch einen 'initial context'
+ sal_Int16 nInitialContext = 0;
+ Reference< XForm> xActiveForm( getActiveForm());
+ for ( size_t i=0; i<m_aSearchForms.size(); ++i )
+ {
+ if (m_aSearchForms.at(i) == xActiveForm)
+ {
+ nInitialContext = (sal_Int16)i;
+ break;
+ }
+ }
+
+ // wenn der Dialog initial den Text des aktiven Controls anbieten soll, muss dieses ein XTextComponent-Interface habe,
+ // ausserdem macht das nur Sinn, wenn das aktuelle Feld auch an ein Tabellen- (oder was-auch-immer-)Feld gebunden ist
+ UniString strActiveField;
+ UniString strInitialText;
+ // ... das bekomme ich von meinem FormController
+ DBG_ASSERT(m_xActiveController.is(), "FmXFormShell::ExecuteSearch : no active controller !");
+ Reference< XControl> xActiveControl( m_xActiveController->getCurrentControl());
+ if (xActiveControl.is())
+ {
+ // das Control kann mir sein Model sagen ...
+ Reference< XControlModel> xActiveModel( xActiveControl->getModel());
+ DBG_ASSERT(xActiveModel.is(), "FmXFormShell::ExecuteSearch : active control has no model !");
+
+ // das Model frage ich nach der ControlSource-Eigenschaft ...
+ Reference< XPropertySet> xProperties(xActiveControl->getModel(), UNO_QUERY);
+ if (::comphelper::hasProperty(FM_PROP_CONTROLSOURCE, xProperties) && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xProperties))
+ {
+ Reference< XPropertySet> xField;
+ xProperties->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
+ if (xField.is()) // (nur wenn das Ding wirklich gebunden ist)
+ {
+ // und das Control selber nach einem TextComponent-Interface (damit ich mir dort den Text abholen kann)
+ Reference< XTextComponent> xText(xActiveControl, UNO_QUERY);
+ if (xText.is())
+ {
+ strActiveField = getLabelName(xProperties).getStr();
+ strInitialText = xText->getText().getStr();
+ }
+ }
+ }
+ else
+ {
+ // das Control selber hat keine ControlSource, aber vielleicht ist es ein GridControl
+ Reference< XGrid> xGrid(xActiveControl, UNO_QUERY);
+ if (xGrid.is())
+ {
+ // fuer strActiveField brauche ich die die ControlSource der Column, dafuer den Columns-Container, dafuer die
+ // GridPeer
+ Reference< XGridPeer> xGridPeer(xActiveControl->getPeer(), UNO_QUERY);
+ Reference< XIndexAccess> xColumns;
+ if (xGridPeer.is())
+ xColumns = Reference< XIndexAccess>(xGridPeer->getColumns(),UNO_QUERY);
+
+ sal_Int16 nViewCol = xGrid->getCurrentColumnPosition();
+ sal_Int16 nModelCol = GridView2ModelPos(xColumns, nViewCol);
+ Reference< XPropertySet> xCurrentCol;
+ if(xColumns.is())
+ xColumns->getByIndex(nModelCol) >>= xCurrentCol;
+ if (xCurrentCol.is())
+ strActiveField = ::comphelper::getString(xCurrentCol->getPropertyValue(FM_PROP_LABEL)).getStr();
+
+ // the text fo the current column
+ Reference< XIndexAccess> xColControls(xGridPeer, UNO_QUERY);
+ Reference< XInterface> xCurControl;
+ xColControls->getByIndex(nViewCol) >>= xCurControl;
+ ::rtl::OUString sInitialText;
+ if (IsSearchableControl(xCurControl, &sInitialText))
+ strInitialText = sInitialText.getStr();
+ }
+ }
+ }
+
+ // um eventuelle GridControls, die ich kenne, kuemmern
+ LoopGrids(GA_DISABLE_SYNC /*| GA_ENABLE_ROCTRLR*/);
+
+ // jetzt bin ich reif fuer den Dialog
+ // wenn die potentiellen Deadlocks, die durch die Benutzung des Solar-Mutex in MTs VCLX...-Klasen entstehen, irgendwann mal
+ // ausgeraeumt sind, sollte hier ein SM_USETHREAD rein, denn die Suche in einem eigenen Thread ist doch etwas fluessiger
+ // sollte allerdings irgendwie von dem unterliegenden Cursor abhaengig gemacht werden, DAO zum Beispiel ist nicht thread-sicher
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ AbstractFmSearchDialog* pDialog = NULL;
+ if ( pFact )
+ pDialog = pFact->CreateFmSearchDialog( &m_pShell->GetViewShell()->GetViewFrame()->GetWindow(), strInitialText, aContextNames, nInitialContext, LINK( this, FmXFormShell, OnSearchContextRequest ) );
+ DBG_ASSERT( pDialog, "FmXFormShell::ExecuteSearch: could not create the search dialog!" );
+ if ( pDialog )
+ {
+ pDialog->SetActiveField( strActiveField );
+ pDialog->SetFoundHandler( LINK( this, FmXFormShell, OnFoundData ) );
+ pDialog->SetCanceledNotFoundHdl( LINK( this, FmXFormShell, OnCanceledNotFound ) );
+ pDialog->Execute();
+ delete pDialog;
+ }
+
+ // GridControls wieder restaurieren
+ LoopGrids(GA_ENABLE_SYNC | GA_DISABLE_ROCTRLR);
+
+ m_pShell->GetFormView()->UnMarkAll(m_pShell->GetFormView()->GetSdrPageView());
+ // da ich in OnFoundData (fals ich dort war) Controls markiert habe
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmXFormShell::GetY2KState(sal_uInt16& n)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::GetY2KState" );
+ if ( impl_checkDisposed() )
+ return sal_False;
+
+ if (m_pShell->IsDesignMode())
+ // im Design-Modus (ohne aktive Controls) soll sich das Haupt-Dokument darum kuemmern
+ return sal_False;
+
+ Reference< XForm> xForm( getActiveForm());
+ if (!xForm.is())
+ // kein aktuelles Formular (also insbesondere kein aktuelles Control) -> das Haupt-Dokument soll sich kuemmern
+ return sal_False;
+
+ Reference< XRowSet> xDB(xForm, UNO_QUERY);
+ DBG_ASSERT(xDB.is(), "FmXFormShell::GetY2KState : current form has no dbform-interface !");
+
+ Reference< XNumberFormatsSupplier> xSupplier( getNumberFormats(OStaticDataAccessTools().getRowSetConnection(xDB), sal_False));
+ if (xSupplier.is())
+ {
+ Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
+ if (xSet.is())
+ {
+ try
+ {
+ Any aVal( xSet->getPropertyValue(::rtl::OUString::createFromAscii("TwoDigitDateStart")) );
+ aVal >>= n;
+ return sal_True;
+ }
+ catch(Exception&)
+ {
+ }
+
+ }
+ }
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::SetY2KState(sal_uInt16 n)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::SetY2KState" );
+ if ( impl_checkDisposed() )
+ return;
+
+ Reference< XForm > xActiveForm( getActiveForm());
+ Reference< XRowSet > xActiveRowSet( xActiveForm, UNO_QUERY );
+ if ( xActiveRowSet.is() )
+ {
+ Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( getRowSetConnection( xActiveRowSet ), sal_False ) );
+ if (xSupplier.is())
+ {
+ Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
+ if (xSet.is())
+ {
+ try
+ {
+ Any aVal;
+ aVal <<= n;
+ xSet->setPropertyValue(::rtl::OUString::createFromAscii("TwoDigitDateStart"), aVal);
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmXFormShell::SetY2KState: Exception occured!");
+ }
+
+ }
+ return;
+ }
+ }
+
+ // kein aktives Formular gefunden -> alle aktuell vorhandenen Formulare durchiterieren
+ Reference< XIndexAccess> xCurrentForms( m_xForms);
+ if (!xCurrentForms.is())
+ { // im alive-Modus sind meine Forms nicht gesetzt, wohl aber die an der Page
+ if (m_pShell->GetCurPage())
+ xCurrentForms = Reference< XIndexAccess>( m_pShell->GetCurPage()->GetForms( false ), UNO_QUERY );
+ }
+ if (!xCurrentForms.is())
+ return;
+
+ ::comphelper::IndexAccessIterator aIter(xCurrentForms);
+ Reference< XInterface> xCurrentElement( aIter.Next());
+ while (xCurrentElement.is())
+ {
+ // ist das aktuelle Element eine DatabaseForm ?
+ Reference< XRowSet> xElementAsRowSet( xCurrentElement, UNO_QUERY );
+ if ( xElementAsRowSet.is() )
+ {
+ Reference< XNumberFormatsSupplier > xSupplier( getNumberFormats( getRowSetConnection( xElementAsRowSet ), sal_False ) );
+ if (!xSupplier.is())
+ continue;
+
+ Reference< XPropertySet> xSet(xSupplier->getNumberFormatSettings());
+ if (xSet.is())
+ {
+ try
+ {
+ Any aVal;
+ aVal <<= n;
+ xSet->setPropertyValue(::rtl::OUString::createFromAscii("TwoDigitDateStart"), aVal);
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmXFormShell::SetY2KState: Exception occured!");
+ }
+
+ }
+ }
+ xCurrentElement = aIter.Next();
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::CloseExternalFormViewer()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::CloseExternalFormViewer" );
+ if ( impl_checkDisposed() )
+ return;
+
+ if (!m_xExternalViewController.is())
+ return;
+
+ Reference< ::com::sun::star::frame::XFrame> xExternalViewFrame( m_xExternalViewController->getFrame());
+ Reference< ::com::sun::star::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY);
+ if (!xCommLink.is())
+ return;
+
+ xExternalViewFrame->setComponent(NULL,NULL);
+ ::comphelper::disposeComponent(xExternalViewFrame);
+ m_xExternalViewController = NULL;
+ m_xExtViewTriggerController = NULL;
+ m_xExternalDisplayedForm = NULL;
+}
+
+//------------------------------------------------------------------------------
+Reference< XResultSet> FmXFormShell::getInternalForm(const Reference< XResultSet>& _xForm) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::getInternalForm" );
+ if ( impl_checkDisposed() )
+ return NULL;
+
+ Reference< runtime::XFormController> xExternalCtrlr(m_xExternalViewController, UNO_QUERY);
+ if (xExternalCtrlr.is() && (_xForm == xExternalCtrlr->getModel()))
+ {
+ DBG_ASSERT(m_xExternalDisplayedForm.is(), "FmXFormShell::getInternalForm : invalid external form !");
+ return m_xExternalDisplayedForm;
+ }
+ return _xForm;
+}
+
+//------------------------------------------------------------------------------
+Reference< XForm> FmXFormShell::getInternalForm(const Reference< XForm>& _xForm) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::getInternalForm" );
+ if ( impl_checkDisposed() )
+ return NULL;
+
+ Reference< runtime::XFormController > xExternalCtrlr(m_xExternalViewController, UNO_QUERY);
+ if (xExternalCtrlr.is() && (_xForm == xExternalCtrlr->getModel()))
+ {
+ DBG_ASSERT(m_xExternalDisplayedForm.is(), "FmXFormShell::getInternalForm : invalid external form !");
+ return Reference< XForm>(m_xExternalDisplayedForm, UNO_QUERY);
+ }
+ return _xForm;
+}
+
+//------------------------------------------------------------------------
+namespace
+{
+ static bool lcl_isNavigationRelevant( sal_Int32 _nWhich )
+ {
+ return ( _nWhich == SID_FM_RECORD_FIRST )
+ || ( _nWhich == SID_FM_RECORD_PREV )
+ || ( _nWhich == SID_FM_RECORD_NEXT )
+ || ( _nWhich == SID_FM_RECORD_LAST )
+ || ( _nWhich == SID_FM_RECORD_NEW );
+ }
+}
+
+//------------------------------------------------------------------------------
+bool FmXFormShell::IsFormSlotEnabled( sal_Int32 _nSlot, FeatureState* _pCompleteState )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::IsFormSlotEnabled" );
+ const ::svx::ControllerFeatures& rController =
+ lcl_isNavigationRelevant( _nSlot )
+ ? getNavControllerFeatures()
+ : getActiveControllerFeatures();
+
+ if ( !_pCompleteState )
+ return rController->isEnabled( _nSlot );
+
+ rController->getState( _nSlot, *_pCompleteState );
+ return _pCompleteState->Enabled;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::ExecuteFormSlot( sal_Int32 _nSlot )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::ExecuteFormSlot" );
+ const ::svx::ControllerFeatures& rController =
+ lcl_isNavigationRelevant( _nSlot )
+ ? getNavControllerFeatures()
+ : getActiveControllerFeatures();
+
+ rController->execute( _nSlot );
+
+ if ( _nSlot == SID_FM_RECORD_UNDO )
+ {
+ // if we're doing an UNDO, *and* if the affected form is the form which we also display
+ // as external view, then we need to reset the controls of the external form, too
+ if ( getInternalForm( getActiveForm() ) == m_xExternalDisplayedForm )
+ {
+ Reference< XIndexAccess > xContainer( m_xExternalDisplayedForm, UNO_QUERY );
+ if ( xContainer.is() )
+ {
+ Reference< XReset > xReset;
+ for ( sal_Int32 i = 0; i < xContainer->getCount(); ++i )
+ {
+ if ( ( xContainer->getByIndex( i ) >>= xReset ) && xReset.is() )
+ {
+ // no resets on sub forms
+ Reference< XForm > xAsForm( xReset, UNO_QUERY );
+ if ( !xAsForm.is() )
+ xReset->reset();
+ }
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::impl_switchActiveControllerListening( const bool _bListen )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::impl_switchActiveControllerListening" );
+ Reference< XComponent> xComp( m_xActiveController, UNO_QUERY );
+ if ( !xComp.is() )
+ return;
+
+ if ( _bListen )
+ xComp->addEventListener( (XFormControllerListener*)this );
+ else
+ xComp->removeEventListener( (XFormControllerListener*)this );
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::setActiveController( const Reference< runtime::XFormController >& xController, sal_Bool _bNoSaveOldContent )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::setActiveController" );
+ if ( impl_checkDisposed() )
+ return;
+
+ if (m_bChangingDesignMode)
+ return;
+ DBG_ASSERT(!m_pShell->IsDesignMode(), "nur im alive mode verwenden");
+
+ // Ist die Routine ein zweites Mal gerufen worden,
+ // dann sollte der Focus nicht mehr umgesetzt werden
+ if (m_bInActivate)
+ {
+ m_bSetFocus = xController != m_xActiveController;
+ return;
+ }
+
+ if (xController != m_xActiveController)
+ {
+ ::osl::ClearableMutexGuard aGuard(m_aAsyncSafety);
+ // switch all nav dispatchers belonging to the form of the current nav controller to 'non active'
+ Reference< XResultSet> xNavigationForm;
+ if (m_xNavigationController.is())
+ xNavigationForm = Reference< XResultSet>(m_xNavigationController->getModel(), UNO_QUERY);
+ aGuard.clear();
+
+ m_bInActivate = sal_True;
+
+ // check if the 2 controllers serve different forms
+ Reference< XResultSet> xOldForm;
+ if (m_xActiveController.is())
+ xOldForm = Reference< XResultSet>(m_xActiveController->getModel(), UNO_QUERY);
+ Reference< XResultSet> xNewForm;
+ if (xController.is())
+ xNewForm = Reference< XResultSet>(xController->getModel(), UNO_QUERY);
+ xOldForm = getInternalForm(xOldForm);
+ xNewForm = getInternalForm(xNewForm);
+
+ sal_Bool bDifferentForm = ( xOldForm.get() != xNewForm.get() );
+ sal_Bool bNeedSave = bDifferentForm && !_bNoSaveOldContent;
+ // we save the content of the old form if we move to a new form, and saving old content is allowed
+
+ if ( m_xActiveController.is() && bNeedSave )
+ {
+ // beim Wechsel des Controllers den Inhalt speichern, ein Commit
+ // wurde bereits ausgefuehrt
+ if ( m_aActiveControllerFeatures->commitCurrentControl() )
+ {
+ m_bSetFocus = sal_True;
+ if ( m_aActiveControllerFeatures->isModifiedRow() )
+ {
+ sal_Bool bIsNew = m_aActiveControllerFeatures->isInsertionRow();
+ sal_Bool bResult = m_aActiveControllerFeatures->commitCurrentRecord();
+ if ( !bResult && m_bSetFocus )
+ {
+ // if we couldn't save the current record, set the focus back to the
+ // current control
+ Reference< XWindow > xWindow( m_xActiveController->getCurrentControl(), UNO_QUERY );
+ if ( xWindow.is() )
+ xWindow->setFocus();
+ m_bInActivate = sal_False;
+ return;
+ }
+ else if ( bResult && bIsNew )
+ {
+ Reference< XResultSet > xCursor( m_aActiveControllerFeatures->getCursor().get() );
+ if ( xCursor.is() )
+ {
+ DO_SAFE( xCursor->last(); );
+ }
+ }
+ }
+ }
+ }
+
+ stopListening();
+
+ impl_switchActiveControllerListening( false );
+
+ m_aActiveControllerFeatures.dispose();
+ m_xActiveController = xController;
+ if ( m_xActiveController.is() )
+ m_aActiveControllerFeatures.assign( m_xActiveController );
+
+ impl_switchActiveControllerListening( true );
+
+ if ( m_xActiveController.is() )
+ m_xActiveForm = getInternalForm( Reference< XForm >( m_xActiveController->getModel(), UNO_QUERY ) );
+ else
+ m_xActiveForm = NULL;
+
+ startListening();
+
+ // activate all dispatchers belonging to form of the new navigation controller
+ xNavigationForm = NULL;
+ if (m_xNavigationController.is())
+ xNavigationForm = Reference< XResultSet>(m_xNavigationController->getModel(), UNO_QUERY);
+
+ m_bInActivate = sal_False;
+
+ m_pShell->UIFeatureChanged();
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
+
+ InvalidateSlot(SID_FM_FILTER_NAVIGATOR_CONTROL, sal_True);
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::getCurrentSelection( InterfaceBag& /* [out] */ _rSelection ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::getCurrentSelection" );
+ _rSelection = m_aCurrentSelection;
+}
+
+//------------------------------------------------------------------------------
+bool FmXFormShell::setCurrentSelectionFromMark( const SdrMarkList& _rMarkList )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::setCurrentSelectionFromMark" );
+ m_aLastKnownMarkedControls.clear();
+
+ if ( ( _rMarkList.GetMarkCount() > 0 ) && isControlList( _rMarkList ) )
+ collectInterfacesFromMarkList( _rMarkList, m_aLastKnownMarkedControls );
+
+ return setCurrentSelection( m_aLastKnownMarkedControls );
+}
+
+//------------------------------------------------------------------------------
+bool FmXFormShell::selectLastMarkedControls()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::selectLastMarkedControls" );
+ return setCurrentSelection( m_aLastKnownMarkedControls );
+}
+
+//------------------------------------------------------------------------------
+bool FmXFormShell::setCurrentSelection( const InterfaceBag& _rSelection )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::setCurrentSelection" );
+ if ( impl_checkDisposed() )
+ return false;
+
+ DBG_ASSERT( m_pShell->IsDesignMode(), "FmXFormShell::setCurrentSelection: only to be used in design mode!" );
+
+ if ( _rSelection.empty() && m_aCurrentSelection.empty() )
+ // nothing to do
+ return false;
+
+ if ( _rSelection.size() == m_aCurrentSelection.size() )
+ {
+ InterfaceBag::const_iterator aNew = _rSelection.begin();
+ InterfaceBag::const_iterator aOld = m_aCurrentSelection.begin();
+ for ( ; aNew != _rSelection.end(); ++aNew, ++aOld )
+ {
+ OSL_ENSURE( Reference< XInterface >( *aNew, UNO_QUERY ).get() == aNew->get(), "FmXFormShell::setCurrentSelection: new interface not normalized!" );
+ OSL_ENSURE( Reference< XInterface >( *aOld, UNO_QUERY ).get() == aOld->get(), "FmXFormShell::setCurrentSelection: old interface not normalized!" );
+
+ if ( aNew->get() != aOld->get() )
+ break;
+ }
+
+ if ( aNew == _rSelection.end() )
+ // both bags equal
+ return false;
+ }
+
+ // the following is some strange code to ensure that when you have two grid controls in a document,
+ // only one of them can have a selected column.
+ // TODO: this should happen elsewhere, but not here - shouldn't it?
+ if ( !m_aCurrentSelection.empty() )
+ {
+ Reference< XChild > xCur; if ( m_aCurrentSelection.size() == 1 ) xCur = xCur.query( *m_aCurrentSelection.begin() );
+ Reference< XChild > xNew; if ( _rSelection.size() == 1 ) xNew = xNew.query( *_rSelection.begin() );
+
+ // is there nothing to be selected, or the parents differ, and the parent of the current object
+ // is a selection supplier, then deselect
+ if ( xCur.is() && ( !xNew.is() || ( xCur->getParent() != xNew->getParent() ) ) )
+ {
+ Reference< XSelectionSupplier > xSel( xCur->getParent(), UNO_QUERY );
+ if ( xSel.is() )
+ xSel->select( Any() );
+ }
+ }
+
+ m_aCurrentSelection = _rSelection;
+
+ // determine the form which all the selected obj�cts belong to, if any
+ Reference< XForm > xNewCurrentForm;
+ for ( InterfaceBag::const_iterator loop = m_aCurrentSelection.begin();
+ loop != m_aCurrentSelection.end();
+ ++loop
+ )
+ {
+ Reference< XForm > xThisRoundsForm( GetForm( *loop ) );
+ OSL_ENSURE( xThisRoundsForm.is(), "FmXFormShell::setCurrentSelection: *everything* should belong to a form!" );
+
+ if ( !xNewCurrentForm.is() )
+ { // the first form we encounterd
+ xNewCurrentForm = xThisRoundsForm;
+ }
+ else if ( xNewCurrentForm != xThisRoundsForm )
+ { // different forms -> no "current form" at all
+ xNewCurrentForm.clear();
+ break;
+ }
+ }
+
+ if ( !m_aCurrentSelection.empty() )
+ impl_updateCurrentForm( xNewCurrentForm );
+
+ // ensure some slots are updated
+ for ( size_t i = 0; i < SAL_N_ELEMENTS( SelObjectSlotMap ); ++i )
+ InvalidateSlot( SelObjectSlotMap[i], sal_False);
+
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool FmXFormShell::isSolelySelected( const Reference< XInterface >& _rxObject )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::isSolelySelected" );
+ return ( m_aCurrentSelection.size() == 1 ) && ( *m_aCurrentSelection.begin() == _rxObject );
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::forgetCurrentForm()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::forgetCurrentForm" );
+ if ( !m_xCurrentForm.is() )
+ return;
+
+ // reset ...
+ impl_updateCurrentForm( NULL );
+
+ // ... and try finding a new current form
+ // #i88186# / 2008-04-12 / frank.schoenheit@sun.com
+ impl_defaultCurrentForm_nothrow();
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::impl_updateCurrentForm( const Reference< XForm >& _rxNewCurForm )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::impl_updateCurrentForm" );
+ if ( impl_checkDisposed() )
+ return;
+
+ m_xCurrentForm = _rxNewCurForm;
+
+ // propagate to the FormPage(Impl)
+ FmFormPage* pPage = m_pShell->GetCurPage();
+ if ( pPage )
+ pPage->GetImpl().setCurForm( m_xCurrentForm );
+
+ // ensure the UI which depends on the current form is up-to-date
+ for ( size_t i = 0; i < SAL_N_ELEMENTS( DlgSlotMap ); ++i )
+ InvalidateSlot( DlgSlotMap[i], sal_False );
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::startListening()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::startListening" );
+ if ( impl_checkDisposed() )
+ return;
+
+ Reference< XRowSet> xDatabaseForm(m_xActiveForm, UNO_QUERY);
+ if (xDatabaseForm.is() && getRowSetConnection(xDatabaseForm).is())
+ {
+ Reference< XPropertySet> xActiveFormSet(m_xActiveForm, UNO_QUERY);
+ if (xActiveFormSet.is())
+ {
+ // wenn es eine Datenquelle gibt, dann den Listener aufbauen
+ // TODO: this is strange - shouldn't this depend on a isLoaded instead of
+ // a "has command value"? Finally, the command value only means that it was
+ // intended to be loaded, not that it actually *is* loaded
+ ::rtl::OUString aSource = ::comphelper::getString(xActiveFormSet->getPropertyValue(FM_PROP_COMMAND));
+ if (aSource.getLength())
+ {
+ m_bDatabaseBar = sal_True;
+
+ xActiveFormSet->getPropertyValue(FM_PROP_NAVIGATION) >>= m_eNavigate;
+
+ switch (m_eNavigate)
+ {
+ case NavigationBarMode_PARENT:
+ {
+ // suchen des Controllers, ueber den eine Navigation moeglich ist
+ Reference< XChild> xChild(m_xActiveController, UNO_QUERY);
+ Reference< runtime::XFormController > xParent;
+ while (xChild.is())
+ {
+ xChild = Reference< XChild>(xChild->getParent(), UNO_QUERY);
+ xParent = Reference< runtime::XFormController >(xChild, UNO_QUERY);
+ Reference< XPropertySet> xParentSet;
+ if (xParent.is())
+ xParentSet = Reference< XPropertySet>(xParent->getModel(), UNO_QUERY);
+ if (xParentSet.is())
+ {
+ xParentSet->getPropertyValue(FM_PROP_NAVIGATION) >>= m_eNavigate;
+ if (m_eNavigate == NavigationBarMode_CURRENT)
+ break;
+ }
+ }
+ m_xNavigationController = xParent;
+ }
+ break;
+
+ case NavigationBarMode_CURRENT:
+ m_xNavigationController = m_xActiveController;
+ break;
+
+ default:
+ m_xNavigationController = NULL;
+ m_bDatabaseBar = sal_False;
+ }
+
+ m_aNavControllerFeatures.dispose();
+ if ( m_xNavigationController.is() && ( m_xNavigationController != m_xActiveController ) )
+ m_aNavControllerFeatures.assign( m_xNavigationController );
+
+ // an dem Controller, der die Navigation regelt, wg. RecordCount lauschen
+ Reference< XPropertySet> xNavigationSet;
+ if (m_xNavigationController.is())
+ {
+ xNavigationSet = Reference< XPropertySet>(m_xNavigationController->getModel(), UNO_QUERY);
+ if (xNavigationSet.is())
+ xNavigationSet->addPropertyChangeListener(FM_PROP_ROWCOUNT,this);
+ }
+ return;
+ }
+ }
+ }
+
+ m_eNavigate = NavigationBarMode_NONE;
+ m_bDatabaseBar = sal_False;
+ m_xNavigationController = NULL;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::stopListening()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::stopListening" );
+ if ( impl_checkDisposed() )
+ return;
+
+ Reference< XRowSet> xDatabaseForm(m_xActiveForm, UNO_QUERY);
+ if ( xDatabaseForm.is() )
+ {
+ if (m_xNavigationController.is())
+ {
+ Reference< XPropertySet> xSet(m_xNavigationController->getModel(), UNO_QUERY);
+ if (xSet.is())
+ xSet->removePropertyChangeListener(FM_PROP_ROWCOUNT, this);
+
+ }
+ }
+
+ m_bDatabaseBar = sal_False;
+ m_eNavigate = NavigationBarMode_NONE;
+ m_xNavigationController = NULL;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::ShowSelectionProperties( sal_Bool bShow )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::ShowSelectionProperties" );
+ if ( impl_checkDisposed() )
+ return;
+
+ // if the window is already visible, only update the state
+ sal_Bool bHasChild = m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_SHOW_PROPERTIES );
+ if ( bHasChild && bShow )
+ UpdateSlot( SID_FM_PROPERTY_CONTROL );
+
+ // else toggle state
+ else
+ m_pShell->GetViewShell()->GetViewFrame()->ToggleChildWindow(SID_FM_SHOW_PROPERTIES);
+
+ InvalidateSlot( SID_FM_PROPERTIES, sal_False );
+ InvalidateSlot( SID_FM_CTL_PROPERTIES, sal_False );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FmXFormShell, OnFoundData, FmFoundRecordInformation*, pfriWhere)
+{
+ if ( impl_checkDisposed() )
+ return 0;
+
+ DBG_ASSERT((pfriWhere->nContext >= 0) && (pfriWhere->nContext < (sal_Int16)m_aSearchForms.size()),
+ "FmXFormShell::OnFoundData : ungueltiger Kontext !");
+ Reference< XForm> xForm( m_aSearchForms.at(pfriWhere->nContext));
+ DBG_ASSERT(xForm.is(), "FmXFormShell::OnFoundData : ungueltige Form !");
+
+ Reference< XRowLocate> xCursor(xForm, UNO_QUERY);
+ if (!xCursor.is())
+ return 0; // was soll ich da machen ?
+
+ // zum Datensatz
+ try
+ {
+ xCursor->moveToBookmark(pfriWhere->aPosition);
+ }
+ catch(const SQLException&)
+ {
+ OSL_ENSURE(0,"Can position on bookmark!");
+ }
+
+ LoopGrids(GA_FORCE_SYNC);
+
+ // und zum Feld (dazu habe ich vor dem Start des Suchens die XVclComponent-Interfaces eingesammelt)
+ DBG_ASSERT(pfriWhere->nFieldPos < m_arrSearchedControls.Count(), "FmXFormShell::OnFoundData : ungueltige Daten uebergeben !");
+ SdrObject* pObject = m_arrSearchedControls.GetObject(pfriWhere->nFieldPos);
+ DBG_ASSERT(pObject != NULL, "FmXFormShell::OnFoundData : unerwartet : ungueltiges VclControl-Interface");
+
+ m_pShell->GetFormView()->UnMarkAll(m_pShell->GetFormView()->GetSdrPageView());
+ m_pShell->GetFormView()->MarkObj(pObject, m_pShell->GetFormView()->GetSdrPageView());
+
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pObject );
+ Reference< XControlModel > xControlModel( pFormObject ? pFormObject->GetUnoControlModel() : Reference< XControlModel >() );
+ DBG_ASSERT( xControlModel.is(), "FmXFormShell::OnFoundData: invalid control!" );
+ if ( !xControlModel.is() )
+ return 0;
+
+ // disable the permanent cursor for the last grid we found a record
+ if (m_xLastGridFound.is() && (m_xLastGridFound != xControlModel))
+ {
+ Reference< XPropertySet> xOldSet(m_xLastGridFound, UNO_QUERY);
+ xOldSet->setPropertyValue(FM_PROP_ALWAYSSHOWCURSOR, makeAny( (sal_Bool)sal_False ) );
+ Reference< XPropertyState> xOldSetState(xOldSet, UNO_QUERY);
+ if (xOldSetState.is())
+ xOldSetState->setPropertyToDefault(FM_PROP_CURSORCOLOR);
+ else
+ xOldSet->setPropertyValue(FM_PROP_CURSORCOLOR, Any());
+ }
+
+ // wenn das Feld sich in einem GridControl befindet, muss ich dort noch in die entsprechende Spalte gehen
+ sal_Int32 nGridColumn = m_arrRelativeGridColumn.GetObject(pfriWhere->nFieldPos);
+ if (nGridColumn != -1)
+ { // dummer weise muss ich mir das Control erst wieder besorgen
+ Reference< XControl> xControl( impl_getControl( xControlModel, *pFormObject ) );
+ Reference< XGrid> xGrid(xControl, UNO_QUERY);
+ DBG_ASSERT(xGrid.is(), "FmXFormShell::OnFoundData : ungueltiges Control !");
+ // wenn eine der Asserts anschlaegt, habe ich beim Aufbauen von m_arrSearchedControls wohl was falsch gemacht
+
+ // enable a permanent cursor for the grid so we can see the found text
+ Reference< XPropertySet> xModelSet(xControlModel, UNO_QUERY);
+ DBG_ASSERT(xModelSet.is(), "FmXFormShell::OnFoundData : invalid control model (no property set) !");
+ xModelSet->setPropertyValue( FM_PROP_ALWAYSSHOWCURSOR, makeAny( (sal_Bool)sal_True ) );
+ xModelSet->setPropertyValue( FM_PROP_CURSORCOLOR, makeAny( sal_Int32( COL_LIGHTRED ) ) );
+ m_xLastGridFound = xControlModel;
+
+ if ( xGrid.is() )
+ xGrid->setCurrentColumnPosition((sal_Int16)nGridColumn);
+ }
+
+ // als der Cursor neu positioniert wurde, habe ich (in positioned) meine Formularleisten-Slots invalidiert, aber das greift
+ // hier dummerweise nicht, da i.A. ja der (modale) Suchdialog oben ist ... also Gewalt ...
+ sal_uInt16 nPos = 0;
+ while (DatabaseSlotMap[nPos])
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().Update(DatabaseSlotMap[nPos++]);
+ // leider geht das Update im Gegensatz zum Invalidate nur mit einzelnen Slots)
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FmXFormShell, OnCanceledNotFound, FmFoundRecordInformation*, pfriWhere)
+{
+ if ( impl_checkDisposed() )
+ return 0;
+
+ DBG_ASSERT((pfriWhere->nContext >= 0) && (pfriWhere->nContext < (sal_Int16)m_aSearchForms.size()),
+ "FmXFormShell::OnCanceledNotFound : ungueltiger Kontext !");
+ Reference< XForm> xForm( m_aSearchForms.at(pfriWhere->nContext));
+ DBG_ASSERT(xForm.is(), "FmXFormShell::OnCanceledNotFound : ungueltige Form !");
+
+ Reference< XRowLocate> xCursor(xForm, UNO_QUERY);
+ if (!xCursor.is())
+ return 0; // was soll ich da machen ?
+
+ // zum Datensatz
+ try
+ {
+ xCursor->moveToBookmark(pfriWhere->aPosition);
+ }
+ catch(const SQLException&)
+ {
+ OSL_ENSURE(0,"Can position on bookmark!");
+ }
+
+
+ m_pShell->GetFormView()->UnMarkAll(m_pShell->GetFormView()->GetSdrPageView());
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FmXFormShell, OnSearchContextRequest, FmSearchContext*, pfmscContextInfo)
+{
+ if ( impl_checkDisposed() )
+ return 0;
+
+ DBG_ASSERT(pfmscContextInfo->nContext < (sal_Int16)m_aSearchForms.size(), "FmXFormShell::OnSearchContextRequest : invalid parameter !");
+ Reference< XForm> xForm( m_aSearchForms.at(pfmscContextInfo->nContext));
+ DBG_ASSERT(xForm.is(), "FmXFormShell::OnSearchContextRequest : unexpected : invalid context !");
+
+ Reference< XResultSet> xIter(xForm, UNO_QUERY);
+ DBG_ASSERT(xIter.is(), "FmXFormShell::OnSearchContextRequest : unexpected : context has no iterator !");
+
+ // --------------------------------------------------------------------------------------------
+ // die Liste der zu involvierenden Felder zusammenstellen (sind die ControlSources aller Felder, die eine solche Eigenschaft habe)
+ UniString strFieldList, sFieldDisplayNames;
+ m_arrSearchedControls.Remove(0, m_arrSearchedControls.Count());
+ m_arrRelativeGridColumn.Remove(0, m_arrRelativeGridColumn.Count());
+
+ // folgendes kleines Problem : Ich brauche, um gefundene Felder zu markieren, SdrObjekte. Um hier festzustellen, welche Controls
+ // ich in die Suche einbeziehen soll, brauche ich Controls (also XControl-Interfaces). Ich muss also ueber eines von beiden
+ // iterieren und mir das jeweils andere besorgen. Dummerweise gibt es keine direkte Verbindung zwischen beiden Welten (abgesehen
+ // von einem GetUnoControl an SdrUnoObject, das aber ein OutputDevice verlangt, womit ich nichts anfangen kann).
+ // Allerdings komme ich sowohl von einem Control als auch von einem SdrObject zum Model, und damit ist mir mit einer doppelten
+ // Schleife die Zuordnung SdrObject<->Control moeglich.
+ // Die Alternative zu dieser (unschoenen und sicher auch nicht ganz fixen) Loesung waere, auf das Cachen der SdrObjects zu
+ // verzichten, was dann aber in OnFoundData zu wesentlicher Mehrarbeit fuehren wuerde (da ich mir dort jedesmal das SdrObject
+ // erst besorgen muesste). Da aber OnFoundData i.d.R. oefter aufgerufen wird als ExecuteSearch, erledige ich das hier.
+
+ Reference< XNameAccess> xValidFormFields;
+ Reference< XColumnsSupplier> xSupplyCols(xIter, UNO_QUERY);
+ DBG_ASSERT(xSupplyCols.is(), "FmXFormShell::OnSearchContextRequest : invalid cursor : no columns supplier !");
+ if (xSupplyCols.is())
+ xValidFormFields = xSupplyCols->getColumns();
+ DBG_ASSERT(xValidFormFields.is(), "FmXFormShell::OnSearchContextRequest : form has no fields !");
+
+ // aktuelle(r) Page/Controller
+ FmFormPage* pCurrentPage = m_pShell->GetCurPage();
+ DBG_ASSERT(pCurrentPage!=NULL, "FmXFormShell::OnSearchContextRequest : no page !");
+ // alle Sdr-Controls dieser Seite durchsuchen ...
+ ::rtl::OUString sControlSource, aName;
+
+ SdrObjListIter aPageIter( *pCurrentPage );
+ while ( aPageIter.IsMore() )
+ {
+ SdrObject* pCurrent = aPageIter.Next();
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pCurrent );
+ // note that in case pCurrent is a virtual object, pFormObject points to the referenced object
+
+ if ( !pFormObject )
+ continue;
+
+ // the current object's model, in different tastes
+ Reference< XControlModel> xControlModel( pFormObject->GetUnoControlModel() );
+ Reference< XFormComponent > xCurrentFormComponent( xControlModel, UNO_QUERY );
+ DBG_ASSERT( xCurrentFormComponent.is(), "FmXFormShell::OnSearchContextRequest: invalid objects!" );
+ if ( !xCurrentFormComponent.is() )
+ continue;
+
+ // does the component belong to the form which we're interested in?
+ if ( xCurrentFormComponent->getParent() != xForm )
+ continue;
+
+ // ... nach der ControlSource-Eigenschaft fragen
+ SearchableControlIterator iter( xCurrentFormComponent );
+ Reference< XControl> xControl;
+ // das Control, das als Model xControlModel hat
+ // (das folgende while kann mehrmals durchlaufen werden, ohne dass das Control sich aendert, dann muss
+ // ich nicht jedesmal neu suchen)
+
+ Reference< XInterface > xSearchable( iter.Next() );
+ while ( xSearchable.is() )
+ {
+ sControlSource = iter.getCurrentValue();
+ if ( sControlSource.getLength() == 0 )
+ { // das aktuelle Element hat keine ControlSource, also ist es ein GridControl (das ist das einzige, was
+ // der SearchableControlIterator noch zulaesst)
+ xControl = impl_getControl( xControlModel, *pFormObject );
+ DBG_ASSERT(xControl.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !");
+
+ Reference< XGridPeer> xGridPeer;
+ if ( xControl.is() )
+ xGridPeer.set( xControl->getPeer(), UNO_QUERY );
+ do
+ {
+ if (!xGridPeer.is())
+ break;
+
+ Reference< XIndexAccess> xPeerContainer(xGridPeer, UNO_QUERY);
+ if (!xPeerContainer.is())
+ break;
+
+ Reference< XIndexAccess> xModelColumns(xGridPeer->getColumns(), UNO_QUERY);
+ DBG_ASSERT(xModelColumns.is(), "FmXFormShell::OnSearchContextRequest : there is a grid control without columns !");
+ // the case 'no columns' should be indicated with an empty container, I think ...
+ DBG_ASSERT(xModelColumns->getCount() >= xPeerContainer->getCount(), "FmXFormShell::OnSearchContextRequest : impossible : have more view than model columns !");
+
+ Reference< XInterface> xCurrentColumn;
+ for (sal_Int16 nViewPos=0; nViewPos<xPeerContainer->getCount(); ++nViewPos)
+ {
+ xPeerContainer->getByIndex(nViewPos) >>= xCurrentColumn;
+ if (!xCurrentColumn.is())
+ continue;
+
+ // can we use this column control fo searching ?
+ if (!IsSearchableControl(xCurrentColumn))
+ continue;
+
+ sal_Int16 nModelPos = GridView2ModelPos(xModelColumns, nViewPos);
+ Reference< XPropertySet> xCurrentColModel;
+ xModelColumns->getByIndex(nModelPos) >>= xCurrentColModel;
+ aName = ::comphelper::getString(xCurrentColModel->getPropertyValue(FM_PROP_CONTROLSOURCE));
+ // the cursor has a field matching the control source ?
+ if (xValidFormFields->hasByName(aName))
+ {
+ strFieldList += aName.getStr();
+ strFieldList += ';';
+
+ sFieldDisplayNames += ::comphelper::getString(xCurrentColModel->getPropertyValue(FM_PROP_LABEL)).getStr();
+ sFieldDisplayNames += ';';
+
+ pfmscContextInfo->arrFields.push_back(xCurrentColumn);
+
+ // und das SdrObjekt zum Feld
+ m_arrSearchedControls.C40_INSERT(SdrObject, pCurrent, m_arrSearchedControls.Count());
+ // die Nummer der Spalte
+ m_arrRelativeGridColumn.Insert(nViewPos, m_arrRelativeGridColumn.Count());
+ }
+ }
+ } while (sal_False);
+ }
+ else
+ {
+ if (sControlSource.getLength() && xValidFormFields->hasByName(sControlSource))
+ {
+ // jetzt brauche ich das Control zum SdrObject
+ if (!xControl.is())
+ {
+ xControl = impl_getControl( xControlModel, *pFormObject );
+ DBG_ASSERT(xControl.is(), "FmXFormShell::OnSearchContextRequest : didn't ::std::find a control with requested model !");
+ }
+
+ if (IsSearchableControl(xControl))
+ { // alle Tests ueberstanden -> in die Liste mit aufnehmen
+ strFieldList += sControlSource.getStr();
+ strFieldList += ';';
+
+ // the label which should appear for the control :
+ sFieldDisplayNames += getLabelName(Reference< XPropertySet>(xControlModel, UNO_QUERY)).getStr();
+ sFieldDisplayNames += ';';
+
+ // das SdrObjekt merken (beschleunigt die Behandlung in OnFoundData)
+ m_arrSearchedControls.C40_INSERT(SdrObject, pCurrent, m_arrSearchedControls.Count());
+
+ // die Nummer der Spalte (hier ein Dummy, nur fuer GridControls interesant)
+ m_arrRelativeGridColumn.Insert(-1, m_arrRelativeGridColumn.Count());
+
+ // und fuer die formatierte Suche ...
+ pfmscContextInfo->arrFields.push_back(Reference< XInterface>(xControl, UNO_QUERY));
+ }
+ }
+ }
+
+ xSearchable = iter.Next();
+ }
+ }
+
+ strFieldList.EraseTrailingChars(';');
+ sFieldDisplayNames.EraseTrailingChars(';');
+
+ if (!pfmscContextInfo->arrFields.size())
+ {
+ pfmscContextInfo->arrFields.clear();
+ pfmscContextInfo->xCursor = NULL;
+ pfmscContextInfo->strUsedFields.Erase();
+ return 0L;
+ }
+
+ pfmscContextInfo->xCursor = xIter;
+ pfmscContextInfo->strUsedFields = strFieldList;
+ pfmscContextInfo->sFieldDisplayNames = sFieldDisplayNames;
+
+ // 66463 - 31.05.99 - FS
+ // wenn der Cursor sich in einem anderen RecordMode als STANDARD befindet, ruecksetzen
+ Reference< XPropertySet> xCursorSet(pfmscContextInfo->xCursor, UNO_QUERY);
+ Reference< XResultSetUpdate> xUpdateCursor(pfmscContextInfo->xCursor, UNO_QUERY);
+ if (xUpdateCursor.is() && xCursorSet.is() && xCursorSet.is())
+ {
+ if (::comphelper::getBOOL(xCursorSet->getPropertyValue(FM_PROP_ISNEW)))
+ xUpdateCursor->moveToCurrentRow();
+ else if (::comphelper::getBOOL(xCursorSet->getPropertyValue(FM_PROP_ISMODIFIED)))
+ xUpdateCursor->cancelRowUpdates();
+ }
+
+ return pfmscContextInfo->arrFields.size();
+}
+
+ // XContainerListener
+//------------------------------------------------------------------------------
+void FmXFormShell::elementInserted(const ContainerEvent& evt) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::elementInserted" );
+ if ( impl_checkDisposed() )
+ return;
+
+ // neues Object zum lauschen
+ Reference< XInterface> xTemp;
+ evt.Element >>= xTemp;
+ AddElement(xTemp);
+ m_pShell->DetermineForms(sal_True);
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::elementReplaced(const ContainerEvent& evt) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::elementReplaced" );
+ if ( impl_checkDisposed() )
+ return;
+
+ Reference< XInterface> xTemp;
+ evt.ReplacedElement >>= xTemp;
+ RemoveElement(xTemp);
+ evt.Element >>= xTemp;
+ AddElement(xTemp);
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::elementRemoved(const ContainerEvent& evt) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::elementRemoved" );
+ if ( impl_checkDisposed() )
+ return;
+
+ Reference< XInterface> xTemp;
+ evt.Element >>= xTemp;
+ RemoveElement(xTemp);
+ m_pShell->DetermineForms(sal_True);
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::UpdateForms( sal_Bool _bInvalidate )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::UpdateForms" );
+ if ( impl_checkDisposed() )
+ return;
+
+ Reference< XIndexAccess > xForms;
+
+ FmFormPage* pPage = m_pShell->GetCurPage();
+ if ( pPage )
+ {
+ if ( m_pShell->m_bDesignMode )
+ xForms = xForms.query( pPage->GetForms( false ) );
+ }
+
+ if ( m_xForms != xForms )
+ {
+ RemoveElement( m_xForms );
+ m_xForms = xForms;
+ AddElement( m_xForms );
+ }
+
+ m_pShell->DetermineForms( _bInvalidate );
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::AddElement(const Reference< XInterface>& _xElement)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::AddElement" );
+ if ( impl_checkDisposed() )
+ return;
+ impl_AddElement_nothrow(_xElement);
+}
+// -----------------------------------------------------------------------------
+void FmXFormShell::impl_AddElement_nothrow(const Reference< XInterface>& Element)
+{
+ // am Container horchen
+ const Reference< XIndexContainer> xContainer(Element, UNO_QUERY);
+ if (xContainer.is())
+ {
+ const sal_uInt32 nCount = xContainer->getCount();
+ Reference< XInterface> xElement;
+ for (sal_uInt32 i = 0; i < nCount; ++i)
+ {
+ xElement.set(xContainer->getByIndex(i),UNO_QUERY);
+ impl_AddElement_nothrow(xElement);
+ }
+
+ const Reference< XContainer> xCont(Element, UNO_QUERY);
+ if (xCont.is())
+ xCont->addContainerListener(this);
+ }
+
+ const Reference< ::com::sun::star::view::XSelectionSupplier> xSelSupplier(Element, UNO_QUERY);
+ if (xSelSupplier.is())
+ xSelSupplier->addSelectionChangeListener(this);
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::RemoveElement(const Reference< XInterface>& Element)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::RemoveElement" );
+ if ( impl_checkDisposed() )
+ return;
+ impl_RemoveElement_nothrow(Element);
+}
+//------------------------------------------------------------------------------
+void FmXFormShell::impl_RemoveElement_nothrow(const Reference< XInterface>& Element)
+{
+ const Reference< ::com::sun::star::view::XSelectionSupplier> xSelSupplier(Element, UNO_QUERY);
+ if (xSelSupplier.is())
+ xSelSupplier->removeSelectionChangeListener(this);
+
+ // Verbindung zu Kindern aufheben
+ const Reference< XIndexContainer> xContainer(Element, UNO_QUERY);
+ if (xContainer.is())
+ {
+ const Reference< XContainer> xCont(Element, UNO_QUERY);
+ if (xCont.is())
+ xCont->removeContainerListener(this);
+
+ const sal_uInt32 nCount = xContainer->getCount();
+ Reference< XInterface> xElement;
+ for (sal_uInt32 i = 0; i < nCount; i++)
+ {
+ xElement.set(xContainer->getByIndex(i),UNO_QUERY);
+ impl_RemoveElement_nothrow(xElement);
+ }
+ }
+
+ InterfaceBag::iterator wasSelectedPos = m_aCurrentSelection.find( Element );
+ if ( wasSelectedPos != m_aCurrentSelection.end() )
+ m_aCurrentSelection.erase( wasSelectedPos );
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::selectionChanged(const EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::selectionChanged" );
+ if ( impl_checkDisposed() )
+ return;
+
+ Reference< XSelectionSupplier > xSupplier( rEvent.Source, UNO_QUERY );
+ Reference< XInterface > xSelObj( xSupplier->getSelection(), UNO_QUERY );
+ // es wurde eine Selektion weggenommen, dieses kann nur durch die Shell vorgenommen werden
+ if ( !xSelObj.is() )
+ return;
+
+ EnableTrackProperties(sal_False);
+
+ sal_Bool bMarkChanged = m_pShell->GetFormView()->checkUnMarkAll(rEvent.Source);
+ Reference< XForm > xNewForm( GetForm( rEvent.Source ) );
+
+ InterfaceBag aNewSelection;
+ aNewSelection.insert( Reference< XInterface >( xSelObj, UNO_QUERY ) );
+
+ if ( setCurrentSelection( aNewSelection ) && IsPropBrwOpen() )
+ ShowSelectionProperties( sal_True );
+
+ EnableTrackProperties(sal_True);
+
+ if ( bMarkChanged )
+ m_pShell->NotifyMarkListChanged( m_pShell->GetFormView() );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FmXFormShell, OnTimeOut, void*, /*EMPTYTAG*/)
+{
+ if ( impl_checkDisposed() )
+ return 0;
+
+ if (m_pShell->IsDesignMode() && m_pShell->GetFormView())
+ SetSelection(m_pShell->GetFormView()->GetMarkedObjectList());
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::SetSelectionDelayed()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::SetSelectionDelayed" );
+ if ( impl_checkDisposed() )
+ return;
+
+ if (m_pShell->IsDesignMode() && IsTrackPropertiesEnabled() && !m_aMarkTimer.IsActive())
+ m_aMarkTimer.Start();
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::SetSelection(const SdrMarkList& rMarkList)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::SetSelection" );
+ if ( impl_checkDisposed() )
+ return;
+
+ DetermineSelection(rMarkList);
+ m_pShell->NotifyMarkListChanged(m_pShell->GetFormView());
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::DetermineSelection(const SdrMarkList& rMarkList)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::DetermineSelection" );
+ if ( setCurrentSelectionFromMark( rMarkList ) && IsPropBrwOpen() )
+ ShowSelectionProperties( sal_True );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FmXFormShell::IsPropBrwOpen() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::IsPropBrwOpen" );
+ if ( impl_checkDisposed() )
+ return sal_False;
+
+ return( ( m_pShell->GetViewShell() && m_pShell->GetViewShell()->GetViewFrame() ) ?
+ m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow(SID_FM_SHOW_PROPERTIES) : sal_False );
+}
+
+//------------------------------------------------------------------------------
+class FmXFormShell::SuspendPropertyTracking
+{
+private:
+ FmXFormShell& m_rShell;
+ sal_Bool m_bEnabled;
+
+public:
+ SuspendPropertyTracking( FmXFormShell& _rShell )
+ :m_rShell( _rShell )
+ ,m_bEnabled( sal_False )
+ {
+ if ( m_rShell.IsTrackPropertiesEnabled() )
+ {
+ m_rShell.EnableTrackProperties( sal_False );
+ m_bEnabled = sal_True;
+ }
+ }
+
+ ~SuspendPropertyTracking( )
+ {
+ if ( m_bEnabled ) // note that ( sal_False != m_bEnabled ) implies ( NULL != m_pShell )
+ m_rShell.EnableTrackProperties( sal_True );
+ }
+};
+
+//------------------------------------------------------------------------------
+void FmXFormShell::SetDesignMode(sal_Bool bDesign)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::SetDesignMode" );
+ if ( impl_checkDisposed() )
+ return;
+
+ DBG_ASSERT(m_pShell->GetFormView(), "FmXFormShell::SetDesignMode : invalid call (have no shell or no view) !");
+ m_bChangingDesignMode = sal_True;
+
+ // 67506 - 15.07.99 - FS
+ // if we're switching off the design mode we have to force the property browser to be closed
+ // so it can commit it's changes _before_ we load the forms
+ if (!bDesign)
+ {
+ m_bHadPropertyBrowserInDesignMode = m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow(SID_FM_SHOW_PROPERTIES);
+ if (m_bHadPropertyBrowserInDesignMode)
+ m_pShell->GetViewShell()->GetViewFrame()->ToggleChildWindow(SID_FM_SHOW_PROPERTIES);
+ }
+
+ FmFormView* pFormView = m_pShell->GetFormView();
+ if (bDesign)
+ {
+ // we are currently filtering, so stop filtering
+ if (m_bFilterMode)
+ stopFiltering(sal_False);
+
+ // an den Objekten meiner MarkList als Listener abmelden
+ pFormView->GetImpl()->stopMarkListWatching();
+ }
+ else
+ {
+ m_aMarkTimer.Stop();
+
+ SuspendPropertyTracking aSuspend( *this );
+ pFormView->GetImpl()->saveMarkList( sal_True );
+ }
+
+ if (bDesign && m_xExternalViewController.is())
+ CloseExternalFormViewer();
+
+ pFormView->ChangeDesignMode(bDesign);
+
+ // Listener benachrichtigen
+ FmDesignModeChangedHint aChangedHint( bDesign );
+ m_pShell->Broadcast(aChangedHint);
+
+ m_pShell->m_bDesignMode = bDesign;
+ UpdateForms( sal_False );
+
+ m_pTextShell->designModeChanged( m_pShell->m_bDesignMode );
+
+ if (bDesign)
+ {
+ SdrMarkList aList;
+ {
+ // during changing the mark list, don't track the selected objects in the property browser
+ SuspendPropertyTracking aSuspend( *this );
+ // restore the marks
+ pFormView->GetImpl()->restoreMarkList( aList );
+ }
+
+ // synchronize with the restored mark list
+ if ( aList.GetMarkCount() )
+ SetSelection( aList );
+ }
+ else
+ {
+ // am Model der View als Listener anmelden (damit ich mitbekomme, wenn jemand waehrend des Alive-Modus
+ // Controls loescht, die ich eigentlich mit saveMarkList gespeichert habe) (60343)
+ pFormView->GetImpl()->startMarkListWatching();
+ }
+
+ m_pShell->UIFeatureChanged();
+
+ // 67506 - 15.07.99 - FS
+ if (bDesign && m_bHadPropertyBrowserInDesignMode)
+ {
+ // The UIFeatureChanged performes an update (a check of the available features) asynchronously.
+ // So we can't call ShowSelectionProperties directly as the according feature isn't enabled yet.
+ // That's why we use an asynchron execution on the dispatcher.
+ // (And that's why this has to be done AFTER the UIFeatureChanged.)
+ m_pShell->GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_SHOW_PROPERTY_BROWSER, SFX_CALLMODE_ASYNCHRON );
+ }
+ m_bChangingDesignMode = sal_False;
+}
+
+//------------------------------------------------------------------------------
+Reference< XControl> FmXFormShell::impl_getControl( const Reference< XControlModel >& i_rxModel, const FmFormObj& i_rKnownFormObj )
+{
+ if ( impl_checkDisposed() )
+ return NULL;
+
+ Reference< XControl > xControl;
+ try
+ {
+ Reference< XControlContainer> xControlContainer( getControlContainerForView(), UNO_SET_THROW );
+
+ Sequence< Reference< XControl > > seqControls( xControlContainer->getControls() );
+ const Reference< XControl >* pControls = seqControls.getArray();
+ // ... die ich dann durchsuchen kann
+ for (sal_Int32 i=0; i<seqControls.getLength(); ++i)
+ {
+ xControl.set( pControls[i], UNO_SET_THROW );
+ Reference< XControlModel > xCurrentModel( xControl->getModel() );
+ if ( xCurrentModel == i_rxModel )
+ break;
+ xControl.clear();
+ }
+
+ if ( !xControl.is() )
+ {
+ // fallabck (some controls might not have been created, yet, since they were never visible so far)
+ Reference< XControl > xContainerControl( xControlContainer, UNO_QUERY_THROW );
+ const Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerControl->getPeer() );
+ ENSURE_OR_THROW( pContainerWindow, "unexpected control container implementation" );
+
+ const SdrView* pSdrView = m_pShell ? m_pShell->GetFormView() : NULL;
+ ENSURE_OR_THROW( pSdrView, "no current view" );
+
+ xControl.set( i_rKnownFormObj.GetUnoControl( *pSdrView, *pContainerWindow ), UNO_QUERY_THROW );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ OSL_ENSURE( xControl.is(), "FmXFormShell::impl_getControl: no control found!" );
+ return xControl;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::impl_collectFormSearchContexts_nothrow( const Reference< XInterface>& _rxStartingPoint,
+ const ::rtl::OUString& _rCurrentLevelPrefix, FmFormArray& _out_rForms, ::std::vector< String >& _out_rNames )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::impl_collectFormSearchContexts_nothrow" );
+ try
+ {
+ Reference< XIndexAccess> xContainer( _rxStartingPoint, UNO_QUERY );
+ if ( !xContainer.is() )
+ return;
+
+ sal_Int32 nCount( xContainer->getCount() );
+ if ( nCount == 0 )
+ return;
+
+ ::rtl::OUString sCurrentFormName;
+ ::rtl::OUStringBuffer aNextLevelPrefix;
+ for ( sal_Int32 i=0; i<nCount; ++i )
+ {
+ // is the current child a form?
+ Reference< XForm > xCurrentAsForm( xContainer->getByIndex(i), UNO_QUERY );
+ if ( !xCurrentAsForm.is() )
+ continue;
+
+ Reference< XNamed > xNamed( xCurrentAsForm, UNO_QUERY_THROW );
+ sCurrentFormName = xNamed->getName();
+
+ // the name of the current form
+ ::rtl::OUStringBuffer sCompleteCurrentName( sCurrentFormName );
+ if ( _rCurrentLevelPrefix.getLength() )
+ {
+ sCompleteCurrentName.appendAscii( " (" );
+ sCompleteCurrentName.append ( _rCurrentLevelPrefix );
+ sCompleteCurrentName.appendAscii( ")" );
+ }
+
+ // the prefix for the next level
+ aNextLevelPrefix = _rCurrentLevelPrefix;
+ if ( _rCurrentLevelPrefix.getLength() )
+ aNextLevelPrefix.append( (sal_Unicode)'/' );
+ aNextLevelPrefix.append( sCurrentFormName );
+
+ // remember both the form and it's "display name"
+ _out_rForms.push_back( xCurrentAsForm );
+ _out_rNames.push_back( sCompleteCurrentName.makeStringAndClear() );
+
+ // und absteigen
+ impl_collectFormSearchContexts_nothrow( xCurrentAsForm, aNextLevelPrefix.makeStringAndClear(), _out_rForms, _out_rNames );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::startFiltering()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::startFiltering" );
+ if ( impl_checkDisposed() )
+ return;
+
+ // setting all forms in filter mode
+ FmXFormView* pXView = m_pShell->GetFormView()->GetImpl();
+
+ // if the active controller is our external one we have to use the trigger controller
+ Reference< XControlContainer> xContainer;
+ if (getActiveController() == m_xExternalViewController)
+ {
+ DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::startFiltering : inconsistent : active external controller, but noone triggered this !");
+ xContainer = m_xExtViewTriggerController->getContainer();
+ }
+ else
+ xContainer = getActiveController()->getContainer();
+
+ FmWinRecList::iterator i = pXView->findWindow(xContainer);
+ if (i != pXView->getWindowList().end())
+ {
+ const ::std::vector< Reference< runtime::XFormController> >& rControllerList = (*i)->GetList();
+ for (::std::vector< Reference< runtime::XFormController> >::const_iterator j = rControllerList.begin();
+ j != rControllerList.end(); ++j)
+ {
+ Reference< XModeSelector> xModeSelector(*j, UNO_QUERY);
+ if (xModeSelector.is())
+ xModeSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) );
+ }
+ }
+
+ m_bFilterMode = sal_True;
+
+ m_pShell->UIFeatureChanged();
+ SfxViewFrame* pViewFrame = m_pShell->GetViewShell()->GetViewFrame();
+ pViewFrame->GetBindings().InvalidateShell( *m_pShell );
+
+ if ( pViewFrame->KnowsChildWindow( SID_FM_FILTER_NAVIGATOR )
+ && !pViewFrame->HasChildWindow( SID_FM_FILTER_NAVIGATOR )
+ )
+ {
+ pViewFrame->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR );
+ }
+}
+
+//------------------------------------------------------------------------------
+void saveFilter(const Reference< runtime::XFormController >& _rxController)
+{
+ Reference< XPropertySet> xFormAsSet(_rxController->getModel(), UNO_QUERY);
+ Reference< XPropertySet> xControllerAsSet(_rxController, UNO_QUERY);
+ Reference< XIndexAccess> xControllerAsIndex(_rxController, UNO_QUERY);
+
+ // call the subcontroller
+ Reference< runtime::XFormController > xController;
+ for (sal_Int32 i = 0, nCount = xControllerAsIndex->getCount(); i < nCount; ++i)
+ {
+ xControllerAsIndex->getByIndex(i) >>= xController;
+ saveFilter(xController);
+ }
+
+ try
+ {
+
+ xFormAsSet->setPropertyValue(FM_PROP_FILTER, xControllerAsSet->getPropertyValue(FM_PROP_FILTER));
+ xFormAsSet->setPropertyValue(FM_PROP_APPLYFILTER, makeAny( (sal_Bool)sal_True ) );
+ }
+ catch (const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::stopFiltering(sal_Bool bSave)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::stopFiltering" );
+ if ( impl_checkDisposed() )
+ return;
+
+ m_bFilterMode = sal_False;
+
+ FmXFormView* pXView = m_pShell->GetFormView()->GetImpl();
+
+ // if the active controller is our external one we have to use the trigger controller
+ Reference< XControlContainer> xContainer;
+ if (getActiveController() == m_xExternalViewController)
+ {
+ DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::stopFiltering : inconsistent : active external controller, but noone triggered this !");
+ xContainer = m_xExtViewTriggerController->getContainer();
+ }
+ else
+ xContainer = getActiveController()->getContainer();
+
+ FmWinRecList::iterator i = pXView->findWindow(xContainer);
+ if (i != pXView->getWindowList().end())
+ {
+ const ::std::vector< Reference< runtime::XFormController > >& rControllerList = (*i)->GetList();
+ ::std::vector < ::rtl::OUString > aOriginalFilters;
+ ::std::vector < sal_Bool > aOriginalApplyFlags;
+
+ if (bSave)
+ {
+ for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin();
+ j != rControllerList.end(); ++j)
+ {
+ if (bSave)
+ { // remember the current filter settings in case we're goin to reload the forms below (which may fail)
+ try
+ {
+ Reference< XPropertySet > xFormAsSet((*j)->getModel(), UNO_QUERY);
+ aOriginalFilters.push_back(::comphelper::getString(xFormAsSet->getPropertyValue(FM_PROP_FILTER)));
+ aOriginalApplyFlags.push_back(::comphelper::getBOOL(xFormAsSet->getPropertyValue(FM_PROP_APPLYFILTER)));
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmXFormShell::stopFiltering : could not get the original filter !");
+ // put dummies into the arrays so the they have the right size
+
+ if (aOriginalFilters.size() == aOriginalApplyFlags.size())
+ // the first getPropertyValue failed -> use two dummies
+ aOriginalFilters.push_back( ::rtl::OUString() );
+ aOriginalApplyFlags.push_back( sal_False );
+ }
+ }
+ saveFilter(*j);
+ }
+ }
+ for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin();
+ j != rControllerList.end(); ++j)
+ {
+
+ Reference< XModeSelector> xModeSelector(*j, UNO_QUERY);
+ if (xModeSelector.is())
+ xModeSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) );
+ }
+ if (bSave) // execute the filter
+ {
+ const ::std::vector< Reference< runtime::XFormController > > & rControllers = (*i)->GetList();
+ for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllers.begin();
+ j != rControllers.end(); ++j)
+ {
+ Reference< XLoadable> xReload((*j)->getModel(), UNO_QUERY);
+ if (!xReload.is())
+ continue;
+ Reference< XPropertySet > xFormSet(xReload, UNO_QUERY);
+
+ try
+ {
+ xReload->reload();
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmXFormShell::stopFiltering: Exception occured!");
+ }
+
+ if (!isRowSetAlive(xFormSet))
+ { // something went wrong -> restore the original state
+ ::rtl::OUString sOriginalFilter = aOriginalFilters[ j - rControllers.begin() ];
+ sal_Bool bOriginalApplyFlag = aOriginalApplyFlags[ j - rControllers.begin() ];
+ try
+ {
+ xFormSet->setPropertyValue(FM_PROP_FILTER, makeAny(sOriginalFilter));
+ xFormSet->setPropertyValue(FM_PROP_APPLYFILTER, makeAny(bOriginalApplyFlag));
+ xReload->reload();
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+ }
+ }
+
+ m_pShell->UIFeatureChanged();
+ m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell);
+}
+
+//------------------------------------------------------------------------------
+void clearFilter(const Reference< runtime::XFormController >& _rxController)
+{
+ Reference< XPropertySet> xControllerAsSet(_rxController, UNO_QUERY);
+ Reference< XIndexAccess> xControllerAsIndex(_rxController, UNO_QUERY);
+
+ // call the subcontroller
+ Reference< runtime::XFormController > xController;
+ for (sal_Int32 i = 0, nCount = xControllerAsIndex->getCount();
+ i < nCount; i++)
+ {
+ xControllerAsIndex->getByIndex(i) >>= xController;
+ clearFilter(xController);
+ }
+
+ // clear the filter
+ Reference< XIndexContainer> xContainer;
+ xControllerAsSet->getPropertyValue(FM_PROP_FILTERSUPPLIER) >>= xContainer;
+ if (xContainer.is())
+ {
+ // clear the current filter
+ Sequence< PropertyValue> aCondition;
+
+ // as there is always an empty row, if we have a filter:
+ if (xContainer->getCount())
+ {
+ xControllerAsSet->setPropertyValue(FM_PROP_CURRENTFILTER, makeAny(sal_Int32(xContainer->getCount() - 1)));
+ while (xContainer->getCount() > 1)
+ xContainer->removeByIndex(0);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::clearFilter()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::clearFilter" );
+ if ( impl_checkDisposed() )
+ return;
+
+ FmXFormView* pXView = m_pShell->GetFormView()->GetImpl();
+
+ // if the active controller is our external one we have to use the trigger controller
+ Reference< XControlContainer> xContainer;
+ if (getActiveController() == m_xExternalViewController)
+ {
+ DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::clearFilter : inconsistent : active external controller, but noone triggered this !");
+ xContainer = m_xExtViewTriggerController->getContainer();
+ }
+ else
+ xContainer = getActiveController()->getContainer();
+
+ FmWinRecList::iterator i = pXView->findWindow(xContainer);
+ if (i != pXView->getWindowList().end())
+ {
+ const ::std::vector< Reference< runtime::XFormController > > & rControllerList = (*i)->GetList();
+ for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin();
+ j != rControllerList.end(); ++j)
+ {
+ ::clearFilter(*j);
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::CreateExternalView()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::CreateExternalView" );
+ if ( impl_checkDisposed() )
+ return;
+
+ DBG_ASSERT(m_xAttachedFrame.is(), "FmXFormShell::CreateExternalView : no frame !");
+
+ // the frame the external view is displayed in
+ sal_Bool bAlreadyExistent = m_xExternalViewController.is();
+ Reference< ::com::sun::star::frame::XFrame> xExternalViewFrame;
+ ::rtl::OUString sFrameName = ::rtl::OUString::createFromAscii("_beamer");
+ sal_Int32 nSearchFlags = ::com::sun::star::frame::FrameSearchFlag::CHILDREN | ::com::sun::star::frame::FrameSearchFlag::CREATE;
+
+ Reference< runtime::XFormController > xCurrentNavController( getNavController());
+ // the creation of the "partwindow" may cause a deactivate of the document which will result in our nav controller to be set to NULL
+
+ // _first_ check if we have any valid fields we can use for the grid view
+ // FS - 21.10.99 - 69219
+ {
+ FmXBoundFormFieldIterator aModelIterator(xCurrentNavController->getModel());
+ Reference< XPropertySet> xCurrentModelSet;
+ sal_Bool bHaveUsableControls = sal_False;
+ while ((xCurrentModelSet = Reference< XPropertySet>(aModelIterator.Next(), UNO_QUERY)).is())
+ {
+ // the FmXBoundFormFieldIterator only supplies controls with a valid control source
+ // so we just have to check the field type
+ sal_Int16 nClassId = ::comphelper::getINT16(xCurrentModelSet->getPropertyValue(FM_PROP_CLASSID));
+ switch (nClassId)
+ {
+ case FormComponentType::IMAGECONTROL:
+ case FormComponentType::CONTROL:
+ continue;
+ }
+ bHaveUsableControls = sal_True;
+ break;
+ }
+
+ if (!bHaveUsableControls)
+ {
+ ErrorBox(NULL, WB_OK, SVX_RESSTR(RID_STR_NOCONTROLS_FOR_EXTERNALDISPLAY)).Execute();
+ return;
+ }
+ }
+
+ // load the component for external form views
+ if (!bAlreadyExistent)
+ {
+ URL aWantToDispatch;
+ aWantToDispatch.Complete = FMURL_COMPONENT_FORMGRIDVIEW;
+
+ Reference< ::com::sun::star::frame::XDispatchProvider> xProv(m_xAttachedFrame, UNO_QUERY);
+ Reference< ::com::sun::star::frame::XDispatch> xDisp;
+ if (xProv.is())
+ xDisp = xProv->queryDispatch(aWantToDispatch, sFrameName, nSearchFlags);
+ if (xDisp.is())
+ {
+ xDisp->dispatch(aWantToDispatch, Sequence< PropertyValue>());
+ }
+
+ // with this the component should be loaded, now search the frame where it resides in
+ xExternalViewFrame = m_xAttachedFrame->findFrame(sFrameName, ::com::sun::star::frame::FrameSearchFlag::CHILDREN);
+ if (xExternalViewFrame.is())
+ {
+ m_xExternalViewController = xExternalViewFrame->getController();
+ Reference< ::com::sun::star::lang::XComponent> xComp(m_xExternalViewController, UNO_QUERY);
+ if (xComp.is())
+ xComp->addEventListener((XEventListener*)(XPropertyChangeListener*)this);
+ }
+ }
+ else
+ {
+ xExternalViewFrame = m_xExternalViewController->getFrame();
+ Reference< ::com::sun::star::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY);
+
+ // if we display the active form we interpret the slot as "remove it"
+ Reference< XForm> xCurrentModel(xCurrentNavController->getModel(), UNO_QUERY);
+ if ((xCurrentModel == m_xExternalDisplayedForm) || (getInternalForm(xCurrentModel) == m_xExternalDisplayedForm))
+ {
+ if ( m_xExternalViewController == getActiveController() )
+ {
+ Reference< runtime::XFormController > xAsFormController( m_xExternalViewController, UNO_QUERY );
+ ControllerFeatures aHelper( ::comphelper::getProcessServiceFactory(), xAsFormController, NULL );
+ aHelper->commitCurrentControl();
+ }
+
+ Reference< runtime::XFormController > xNewController(m_xExtViewTriggerController);
+ CloseExternalFormViewer();
+ setActiveController(xNewController);
+ return;
+ }
+
+ URL aClearURL;
+ aClearURL.Complete = FMURL_GRIDVIEW_CLEARVIEW;
+
+ Reference< ::com::sun::star::frame::XDispatch> xClear( xCommLink->queryDispatch(aClearURL, ::rtl::OUString::createFromAscii(""), 0));
+ if (xClear.is())
+ xClear->dispatch(aClearURL, Sequence< PropertyValue>());
+ }
+
+ // TODO: We need an interceptor at the xSupplier, which forwards all queryDispatch requests to the FormController
+ // instance for which this "external view" was triggered
+
+ // get the dispatch interface of the frame so we can communicate (interceptable) with the controller
+ Reference< ::com::sun::star::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY);
+
+ if (m_xExternalViewController.is())
+ {
+ DBG_ASSERT(xCommLink.is(), "FmXFormShell::CreateExternalView : the component doesn't have the necessary interfaces !");
+ // collect the dispatchers we will need
+ URL aAddColumnURL;
+ aAddColumnURL.Complete = FMURL_GRIDVIEW_ADDCOLUMN;
+ Reference< ::com::sun::star::frame::XDispatch> xAddColumnDispatch( xCommLink->queryDispatch(aAddColumnURL, ::rtl::OUString::createFromAscii(""), 0));
+ URL aAttachURL;
+ aAttachURL.Complete = FMURL_GRIDVIEW_ATTACHTOFORM;
+ Reference< ::com::sun::star::frame::XDispatch> xAttachDispatch( xCommLink->queryDispatch(aAttachURL, ::rtl::OUString::createFromAscii(""), 0));
+
+ if (xAddColumnDispatch.is() && xAttachDispatch.is())
+ {
+ DBG_ASSERT(xCurrentNavController.is(), "FmXFormShell::CreateExternalView : invalid call : have no nav controller !");
+ // first : dispatch the descriptions for the columns to add
+ Sequence< Reference< XControl> > aCurrentControls(xCurrentNavController->getControls());
+
+ sal_Int16 nAddedColumns = 0;
+
+ // for radio buttons we need some special structures
+ DECLARE_STL_USTRINGACCESS_MAP(Sequence< ::rtl::OUString>, MapUString2UstringSeq);
+ DECLARE_STL_ITERATORS(MapUString2UstringSeq);
+ DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUString, FmMapUString2UString);
+ DECLARE_STL_USTRINGACCESS_MAP(sal_Int16, FmMapUString2Int16);
+ DECLARE_STL_ITERATORS(FmMapUString2Int16);
+
+ MapUString2UstringSeq aRadioValueLists;
+ MapUString2UstringSeq aRadioListSources;
+ FmMapUString2UString aRadioControlSources;
+ FmMapUString2Int16 aRadioPositions;
+
+ FmXBoundFormFieldIterator aModelIterator(xCurrentNavController->getModel());
+ Reference< XPropertySet> xCurrentModelSet;
+ Any aCurrentBoundField;
+ ::rtl::OUString sColumnType,aGroupName,sControlSource;
+ Sequence< Property> aProps;
+ Reference< XPropertySet> xCurrentBoundField;
+ while ((xCurrentModelSet = Reference< XPropertySet>(aModelIterator.Next(), UNO_QUERY)).is())
+ {
+ xCurrentModelSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xCurrentBoundField;
+ OSL_ENSURE(xCurrentModelSet.is(),"xCurrentModelSet is null!");
+ // create a description of the column to be created
+ // first : determine it's type
+
+ sal_Int16 nClassId = ::comphelper::getINT16(xCurrentModelSet->getPropertyValue(FM_PROP_CLASSID));
+ switch (nClassId)
+ {
+ case FormComponentType::RADIOBUTTON:
+ {
+ // get the label of the button (this is the access key for our structures)
+ aGroupName = getLabelName(xCurrentModelSet);
+
+ // add the reference value of the radio button to the list source sequence
+ Sequence< ::rtl::OUString>& aThisGroupLabels = aRadioListSources[aGroupName];
+ sal_Int32 nNewSizeL = aThisGroupLabels.getLength() + 1;
+ aThisGroupLabels.realloc(nNewSizeL);
+ aThisGroupLabels.getArray()[nNewSizeL - 1] = ::comphelper::getString(xCurrentModelSet->getPropertyValue(FM_PROP_REFVALUE));
+
+ // add the label to the value list sequence
+ Sequence< ::rtl::OUString>& aThisGroupControlSources = aRadioValueLists[aGroupName];
+ sal_Int32 nNewSizeC = aThisGroupControlSources.getLength() + 1;
+ aThisGroupControlSources.realloc(nNewSizeC);
+ aThisGroupControlSources.getArray()[nNewSizeC - 1] = ::comphelper::getString(xCurrentModelSet->getPropertyValue(FM_PROP_LABEL));
+
+ // remember the controls source of the radio group
+ sControlSource = ::comphelper::getString(xCurrentModelSet->getPropertyValue(FM_PROP_CONTROLSOURCE));
+ if (aRadioControlSources.find(aGroupName) == aRadioControlSources.end())
+ aRadioControlSources[aGroupName] = sControlSource;
+#ifdef DBG_UTIL
+ else
+ DBG_ASSERT(aRadioControlSources[aGroupName] == sControlSource,
+ "FmXFormShell::CreateExternalView : inconsistent radio buttons detected !");
+ // (radio buttons with the same name should have the same control source)
+#endif
+ // remember the position within the columns
+ if (aRadioPositions.find(aGroupName) == aRadioPositions.end())
+ aRadioPositions[aGroupName] = (sal_Int16)nAddedColumns;
+
+ // any further handling is done below
+ }
+ continue;
+
+ case FormComponentType::IMAGECONTROL:
+ case FormComponentType::CONTROL:
+ // no grid columns for these types (though they have a control source)
+ continue;
+ case FormComponentType::CHECKBOX:
+ sColumnType = FM_COL_CHECKBOX; break;
+ case FormComponentType::LISTBOX:
+ sColumnType = FM_COL_LISTBOX; break;
+ case FormComponentType::COMBOBOX:
+ sColumnType = FM_COL_COMBOBOX; break;
+ case FormComponentType::DATEFIELD:
+ sColumnType = FM_COL_DATEFIELD; break;
+ case FormComponentType::TIMEFIELD:
+ sColumnType = FM_COL_TIMEFIELD; break;
+ case FormComponentType::NUMERICFIELD:
+ sColumnType = FM_COL_NUMERICFIELD; break;
+ case FormComponentType::CURRENCYFIELD:
+ sColumnType = FM_COL_CURRENCYFIELD; break;
+ case FormComponentType::PATTERNFIELD:
+ sColumnType = FM_COL_PATTERNFIELD; break;
+
+ case FormComponentType::TEXTFIELD:
+ {
+ sColumnType = FM_COL_TEXTFIELD;
+ // we know at least two different controls which are TextFields : the basic edit field and the formatted
+ // field. we distinguish them by their service name
+ Reference< XServiceInfo> xInfo(xCurrentModelSet, UNO_QUERY);
+ if (xInfo.is())
+ {
+ sal_Int16 nObjectType = getControlTypeByObject(xInfo);
+ if (OBJ_FM_FORMATTEDFIELD == nObjectType)
+ sColumnType = FM_COL_FORMATTEDFIELD;
+ }
+ }
+ break;
+ default:
+ sColumnType = FM_COL_TEXTFIELD; break;
+ }
+
+ const sal_Int16 nDispatchArgs = 3;
+ Sequence< PropertyValue> aDispatchArgs(nDispatchArgs);
+ PropertyValue* pDispatchArgs = aDispatchArgs.getArray();
+
+ // properties describing "meta data" about the column
+ // the type
+ pDispatchArgs->Name = FMARG_ADDCOL_COLUMNTYPE;
+ pDispatchArgs->Value <<= sColumnType;
+ ++pDispatchArgs;
+
+ // the pos : append the col
+ pDispatchArgs->Name = FMARG_ADDCOL_COLUMNPOS;
+ pDispatchArgs->Value <<= nAddedColumns;
+ ++pDispatchArgs;
+
+ // the properties to forward to the new column
+ Sequence< PropertyValue> aColumnProps(1);
+ PropertyValue* pColumnProps = aColumnProps.getArray();
+
+ // the label
+ pColumnProps->Name = FM_PROP_LABEL;
+ pColumnProps->Value <<= getLabelName(xCurrentModelSet);
+ ++pColumnProps;
+
+ // for all other props : transfer them
+ Reference< XPropertySetInfo> xControlModelInfo( xCurrentModelSet->getPropertySetInfo());
+ DBG_ASSERT(xControlModelInfo.is(), "FmXFormShell::CreateExternalView : the control model has no property info ! This will crash !");
+ aProps = xControlModelInfo->getProperties();
+ const Property* pProps = aProps.getConstArray();
+
+ // realloc the control description sequence
+ sal_Int32 nExistentDescs = pColumnProps - aColumnProps.getArray();
+ aColumnProps.realloc(nExistentDescs + aProps.getLength());
+ pColumnProps = aColumnProps.getArray() + nExistentDescs;
+
+ for (sal_Int32 i=0; i<aProps.getLength(); ++i, ++pProps)
+ {
+ if (pProps->Name.equals(FM_PROP_LABEL))
+ // already set
+ continue;
+ if (pProps->Name.equals(FM_PROP_DEFAULTCONTROL))
+ // allow the column's own "default control"
+ continue;
+ if (pProps->Attributes & PropertyAttribute::READONLY)
+ // assume that properties which are readonly for the control are ro for the column to be created, too
+ continue;
+
+ pColumnProps->Name = pProps->Name;
+ pColumnProps->Value = xCurrentModelSet->getPropertyValue(pProps->Name);
+ ++pColumnProps;
+ }
+ aColumnProps.realloc(pColumnProps - aColumnProps.getArray());
+
+ // columns props are a dispatch argument
+ pDispatchArgs->Name = ::rtl::OUString::createFromAscii("ColumnProperties"); // TODO : fmurl.*
+ pDispatchArgs->Value = makeAny(aColumnProps);
+ ++pDispatchArgs;
+ DBG_ASSERT(nDispatchArgs == (pDispatchArgs - aDispatchArgs.getConstArray()),
+ "FmXFormShell::CreateExternalView : forgot to adjust nDispatchArgs ?");
+
+ // dispatch the "add column"
+ xAddColumnDispatch->dispatch(aAddColumnURL, aDispatchArgs);
+ ++nAddedColumns;
+ }
+
+ // now for the radio button handling
+ sal_Int16 nOffset(0);
+ // properties describing the "direct" column properties
+ const sal_Int16 nListBoxDescription = 6;
+ Sequence< PropertyValue> aListBoxDescription(nListBoxDescription);
+ for ( ConstFmMapUString2UStringIterator aCtrlSource = aRadioControlSources.begin();
+ aCtrlSource != aRadioControlSources.end();
+ ++aCtrlSource, ++nOffset
+ )
+ {
+
+ PropertyValue* pListBoxDescription = aListBoxDescription.getArray();
+ // label
+ pListBoxDescription->Name = FM_PROP_LABEL;
+ pListBoxDescription->Value <<= (*aCtrlSource).first;
+ ++pListBoxDescription;
+
+ // control source
+ pListBoxDescription->Name = FM_PROP_CONTROLSOURCE;
+ pListBoxDescription->Value <<= (*aCtrlSource).second;
+ ++pListBoxDescription;
+
+ // bound column
+ pListBoxDescription->Name = FM_PROP_BOUNDCOLUMN;
+ pListBoxDescription->Value <<= (sal_Int16)1;
+ ++pListBoxDescription;
+
+ // content type
+ pListBoxDescription->Name = FM_PROP_LISTSOURCETYPE;
+ ListSourceType eType = ListSourceType_VALUELIST;
+ pListBoxDescription->Value = makeAny(eType);
+ ++pListBoxDescription;
+
+ // list source
+ MapUString2UstringSeq::const_iterator aCurrentListSource = aRadioListSources.find((*aCtrlSource).first);
+ DBG_ASSERT(aCurrentListSource != aRadioListSources.end(),
+ "FmXFormShell::CreateExternalView : inconsistent radio descriptions !");
+ pListBoxDescription->Name = FM_PROP_LISTSOURCE;
+ pListBoxDescription->Value = makeAny((*aCurrentListSource).second);
+ ++pListBoxDescription;
+
+ // value list
+ MapUString2UstringSeq::const_iterator aCurrentValueList = aRadioValueLists.find((*aCtrlSource).first);
+ DBG_ASSERT(aCurrentValueList != aRadioValueLists.end(),
+ "FmXFormShell::CreateExternalView : inconsistent radio descriptions !");
+ pListBoxDescription->Name = FM_PROP_STRINGITEMLIST;
+ pListBoxDescription->Value = makeAny(((*aCurrentValueList).second));
+ ++pListBoxDescription;
+
+ DBG_ASSERT(nListBoxDescription == (pListBoxDescription - aListBoxDescription.getConstArray()),
+ "FmXFormShell::CreateExternalView : forgot to adjust nListBoxDescription ?");
+
+ // properties describing the column "meta data"
+ const sal_Int16 nDispatchArgs = 3;
+ Sequence< PropertyValue> aDispatchArgs(nDispatchArgs);
+ PropertyValue* pDispatchArgs = aDispatchArgs.getArray();
+
+ // column type : listbox
+ pDispatchArgs->Name = FMARG_ADDCOL_COLUMNTYPE;
+ ::rtl::OUString fColName = FM_COL_LISTBOX;
+ pDispatchArgs->Value <<= fColName;
+// pDispatchArgs->Value <<= (::rtl::OUString)FM_COL_LISTBOX;
+ ++pDispatchArgs;
+
+ // column position
+ pDispatchArgs->Name = FMARG_ADDCOL_COLUMNPOS;
+ FmMapUString2Int16::const_iterator aOffset = aRadioPositions.find((*aCtrlSource).first);
+ DBG_ASSERT(aOffset != aRadioPositions.end(),
+ "FmXFormShell::CreateExternalView : inconsistent radio descriptions !");
+ sal_Int16 nPosition = (*aOffset).second;
+ nPosition = nPosition + nOffset;
+ // we alread inserted nOffset additinal columns ....
+ pDispatchArgs->Value <<= nPosition;
+ ++pDispatchArgs;
+
+ // the
+ pDispatchArgs->Name = ::rtl::OUString::createFromAscii("ColumnProperties"); // TODO : fmurl.*
+ pDispatchArgs->Value = makeAny(aListBoxDescription);
+ ++pDispatchArgs;
+ DBG_ASSERT(nDispatchArgs == (pDispatchArgs - aDispatchArgs.getConstArray()),
+ "FmXFormShell::CreateExternalView : forgot to adjust nDispatchArgs ?");
+
+ // dispatch the "add column"
+ xAddColumnDispatch->dispatch(aAddColumnURL, aDispatchArgs);
+ ++nAddedColumns;
+ }
+
+
+ DBG_ASSERT(nAddedColumns > 0, "FmXFormShell::CreateExternalView : no controls (inconsistent) !");
+ // we should have checked if we have any usable controls (see above).
+
+ // "load" the "form" of the external view
+ PropertyValue aArg;
+ aArg.Name = FMARG_ATTACHTO_MASTERFORM;
+ Reference< XResultSet> xForm(xCurrentNavController->getModel(), UNO_QUERY);
+ aArg.Value <<= xForm;
+
+ m_xExternalDisplayedForm = Reference< XResultSet>(xForm, UNO_QUERY);
+ // do this before dispatching the "attach" command, as the atach may result in a call to our queryDispatch (for the FormSlots)
+ // whichs needs the m_xExternalDisplayedForm
+
+ xAttachDispatch->dispatch(aAttachURL, Sequence< PropertyValue>(&aArg, 1));
+
+ m_xExtViewTriggerController = xCurrentNavController;
+
+ // we want to know modifications done in the external view
+ // if the external controller is a XFormController we can use all our default handlings for it
+ Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY );
+ OSL_ENSURE( xFormController.is(), "FmXFormShell::CreateExternalView:: invalid external view controller!" );
+ if (xFormController.is())
+ xFormController->addActivateListener((XFormControllerListener*)this);
+ }
+ }
+#ifdef DBG_UTIL
+ else
+ {
+ DBG_ERROR("FmXFormShell::CreateExternalView : could not create the external form view !");
+ }
+#endif
+ InvalidateSlot( SID_FM_VIEW_AS_GRID, sal_False );
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::implAdjustConfigCache()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::implAdjustConfigCache" );
+ // get (cache) the wizard usage flag
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii("FormControlPilotsEnabled");
+ Sequence< Any > aFlags = GetProperties(aNames);
+ if (1 == aFlags.getLength())
+ m_bUseWizards = ::cppu::any2bool(aFlags[0]);
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::Notify" );
+ if ( impl_checkDisposed() )
+ return;
+
+ const ::rtl::OUString* pSearch = _rPropertyNames.getConstArray();
+ const ::rtl::OUString* pSearchTil = pSearch + _rPropertyNames.getLength();
+ for (;pSearch < pSearchTil; ++pSearch)
+ if (0 == pSearch->compareToAscii("FormControlPilotsEnabled"))
+ {
+ implAdjustConfigCache();
+ InvalidateSlot( SID_FM_USE_WIZARDS, sal_True );
+ }
+}
+
+void FmXFormShell::Commit()
+{
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::SetWizardUsing(sal_Bool _bUseThem)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::SetWizardUsing" );
+ m_bUseWizards = _bUseThem;
+
+ Sequence< ::rtl::OUString > aNames(1);
+ aNames[0] = ::rtl::OUString::createFromAscii("FormControlPilotsEnabled");
+ Sequence< Any > aValues(1);
+ aValues[0] = ::cppu::bool2any(m_bUseWizards);
+ PutProperties(aNames, aValues);
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::viewDeactivated( FmFormView& _rCurrentView, sal_Bool _bDeactivateController /* = sal_True */ )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::viewDeactivated" );
+
+ if ( _rCurrentView.GetImpl() && !_rCurrentView.IsDesignMode() )
+ {
+ _rCurrentView.GetImpl()->Deactivate( _bDeactivateController );
+ }
+
+ // if we have an async load operation pending for the 0-th page for this view,
+ // we need to cancel this
+ // 103727 - 2002-09-26 - fs@openoffice.org
+ FmFormPage* pPage = _rCurrentView.GetCurPage();
+ if ( pPage )
+ {
+ // move all events from our queue to a new one, omit the events for the deactivated
+ // page
+ ::std::queue< FmLoadAction > aNewEvents;
+ while ( m_aLoadingPages.size() )
+ {
+ FmLoadAction aAction = m_aLoadingPages.front();
+ m_aLoadingPages.pop();
+ if ( pPage != aAction.pPage )
+ {
+ aNewEvents.push( aAction );
+ }
+ else
+ {
+ Application::RemoveUserEvent( aAction.nEventId );
+ }
+ }
+ m_aLoadingPages = aNewEvents;
+ }
+
+ // remove callbacks at the page
+ if ( pPage )
+ {
+ pPage->GetImpl().SetFormsCreationHdl( Link() );
+ }
+ UpdateForms( sal_True );
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( FmXFormShell, OnFirstTimeActivation, void*, /*NOTINTERESTEDIN*/ )
+{
+ if ( impl_checkDisposed() )
+ return 0L;
+
+ m_nActivationEvent = 0;
+ SfxObjectShell* pDocument = m_pShell->GetObjectShell();
+
+ if ( pDocument && !pDocument->HasName() )
+ {
+ if ( isEnhancedForm() )
+ {
+ // show the data navigator
+ if ( !m_pShell->GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_SHOW_DATANAVIGATOR ) )
+ m_pShell->GetViewShell()->GetViewFrame()->ToggleChildWindow( SID_FM_SHOW_DATANAVIGATOR );
+ }
+ }
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( FmXFormShell, OnFormsCreated, FmFormPage*, /*_pPage*/ )
+{
+ UpdateForms( sal_True );
+ return 0L;
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::viewActivated( FmFormView& _rCurrentView, sal_Bool _bSyncAction /* = sal_False */ )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::viewActivated" );
+
+ FmFormPage* pPage = _rCurrentView.GetCurPage();
+
+ // activate our view if we are activated ourself
+ // FS - 30.06.99 - 67308
+ if ( _rCurrentView.GetImpl() && !_rCurrentView.IsDesignMode() )
+ {
+ // load forms for the page the current view belongs to
+ if ( pPage )
+ {
+ if ( !pPage->GetImpl().hasEverBeenActivated() )
+ loadForms( pPage, FORMS_LOAD | ( _bSyncAction ? FORMS_SYNC : FORMS_ASYNC ) );
+ pPage->GetImpl().setHasBeenActivated( );
+ }
+
+ // first-time initializations for the views
+ if ( !_rCurrentView.GetImpl()->hasEverBeenActivated( ) )
+ {
+ _rCurrentView.GetImpl()->onFirstViewActivation( PTR_CAST( FmFormModel, _rCurrentView.GetModel() ) );
+ _rCurrentView.GetImpl()->setHasBeenActivated( );
+ }
+
+ // activate the current view
+ _rCurrentView.GetImpl()->Activate( _bSyncAction );
+ }
+
+ // set callbacks at the page
+ if ( pPage )
+ {
+ pPage->GetImpl().SetFormsCreationHdl( LINK( this, FmXFormShell, OnFormsCreated ) );
+ }
+
+ UpdateForms( sal_True );
+
+ if ( !hasEverBeenActivated() )
+ {
+ m_nActivationEvent = Application::PostUserEvent( LINK( this, FmXFormShell, OnFirstTimeActivation ) );
+ setHasBeenActivated();
+ }
+
+ // find a default "current form", if there is none, yet
+ // #i88186# / 2008-04-12 / frank.schoenheit@sun.com
+ impl_defaultCurrentForm_nothrow();
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::impl_defaultCurrentForm_nothrow()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::impl_defaultCurrentForm_nothrow" );
+ if ( impl_checkDisposed() )
+ return;
+
+ if ( m_xCurrentForm.is() )
+ // no action required
+ return;
+
+ FmFormView* pFormView = m_pShell->GetFormView();
+ FmFormPage* pPage = pFormView ? pFormView->GetCurPage() : NULL;
+ if ( !pPage )
+ return;
+
+ try
+ {
+ Reference< XIndexAccess > xForms( pPage->GetForms( false ), UNO_QUERY );
+ if ( !xForms.is() || !xForms->hasElements() )
+ return;
+
+ Reference< XForm > xNewCurrentForm( xForms->getByIndex(0), UNO_QUERY_THROW );
+ impl_updateCurrentForm( xNewCurrentForm );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormShell::smartControlReset( const Reference< XIndexAccess >& _rxModels )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::smartControlReset" );
+ if (!_rxModels.is())
+ {
+ DBG_ERROR("FmXFormShell::smartControlReset: invalid container!");
+ return;
+ }
+
+ static const ::rtl::OUString sClassIdPropertyName = FM_PROP_CLASSID;
+ static const ::rtl::OUString sBoundFieldPropertyName = FM_PROP_BOUNDFIELD;
+ sal_Int32 nCount = _rxModels->getCount();
+ Reference< XPropertySet > xCurrent;
+ Reference< XPropertySetInfo > xCurrentInfo;
+ Reference< XPropertySet > xBoundField;
+
+ for (sal_Int32 i=0; i<nCount; ++i)
+ {
+ _rxModels->getByIndex(i) >>= xCurrent;
+ if (xCurrent.is())
+ xCurrentInfo = xCurrent->getPropertySetInfo();
+ else
+ xCurrentInfo.clear();
+ if (!xCurrentInfo.is())
+ continue;
+
+ if (xCurrentInfo->hasPropertyByName(sClassIdPropertyName))
+ { // it's a control model
+
+ // check if this control is bound to a living database field
+ if (xCurrentInfo->hasPropertyByName(sBoundFieldPropertyName))
+ xCurrent->getPropertyValue(sBoundFieldPropertyName) >>= xBoundField;
+ else
+ xBoundField.clear();
+
+ // reset only if it's *not* bound
+ bool bReset = !xBoundField.is();
+
+ // and additionally, check if it has an external value binding
+ Reference< XBindableValue > xBindable( xCurrent, UNO_QUERY );
+ if ( xBindable.is() && xBindable->getValueBinding().is() )
+ bReset = false;
+
+ if ( bReset )
+ {
+ Reference< XReset > xControlReset( xCurrent, UNO_QUERY );
+ if ( xControlReset.is() )
+ xControlReset->reset();
+ }
+ }
+ else
+ {
+ Reference< XIndexAccess > xContainer(xCurrent, UNO_QUERY);
+ if (xContainer.is())
+ smartControlReset(xContainer);
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( FmXFormShell, OnLoadForms, FmFormPage*, /*_pPage*/ )
+{
+ FmLoadAction aAction = m_aLoadingPages.front();
+ m_aLoadingPages.pop();
+
+ loadForms( aAction.pPage, aAction.nFlags & ~FORMS_ASYNC );
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ sal_Bool lcl_isLoadable( const Reference< XInterface >& _rxLoadable )
+ {
+ // determines whether a form should be loaded or not
+ // if there is no datasource or connection there is no reason to load a form
+ Reference< XPropertySet > xSet( _rxLoadable, UNO_QUERY );
+ if ( !xSet.is() )
+ return sal_False;
+ try
+ {
+ Reference< XConnection > xConn;
+ if ( OStaticDataAccessTools().isEmbeddedInDatabase( _rxLoadable.get(), xConn ) )
+ return sal_True;
+
+ // is there already a active connection
+ xSet->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConn;
+ if ( xConn.is() )
+ return sal_True;
+
+ ::rtl::OUString sPropertyValue;
+ OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DATASOURCE ) >>= sPropertyValue );
+ if ( sPropertyValue.getLength() )
+ return sal_True;
+
+ OSL_VERIFY( xSet->getPropertyValue( FM_PROP_URL ) >>= sPropertyValue );
+ if ( sPropertyValue.getLength() )
+ return sal_True;
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sal_False;
+ }
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::loadForms( FmFormPage* _pPage, const sal_uInt16 _nBehaviour /* FORMS_LOAD | FORMS_SYNC */ )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::loadForms" );
+ DBG_ASSERT( ( _nBehaviour & ( FORMS_ASYNC | FORMS_UNLOAD ) ) != ( FORMS_ASYNC | FORMS_UNLOAD ),
+ "FmXFormShell::loadForms: async loading not supported - this will heavily fail!" );
+
+ if ( _nBehaviour & FORMS_ASYNC )
+ {
+ m_aLoadingPages.push( FmLoadAction(
+ _pPage,
+ _nBehaviour,
+ Application::PostUserEvent( LINK( this, FmXFormShell, OnLoadForms ), _pPage )
+ ) );
+ return;
+ }
+
+ DBG_ASSERT( _pPage, "FmXFormShell::loadForms: invalid page!" );
+ if ( _pPage )
+ {
+ // lock the undo env so the forms can change non-transient properties while loading
+ // (without this my doc's modified flag would be set)
+ FmFormModel* pModel = PTR_CAST( FmFormModel, _pPage->GetModel() );
+ DBG_ASSERT( pModel, "FmXFormShell::loadForms: invalid model!" );
+ if ( pModel )
+ pModel->GetUndoEnv().Lock();
+
+ // load all forms
+ Reference< XIndexAccess > xForms;
+ xForms = xForms.query( _pPage->GetForms( false ) );
+
+ if ( xForms.is() )
+ {
+ Reference< XLoadable > xForm;
+ sal_Bool bFormWasLoaded = sal_False;
+ for ( sal_Int32 j = 0, nCount = xForms->getCount(); j < nCount; ++j )
+ {
+ xForms->getByIndex( j ) >>= xForm;
+ bFormWasLoaded = sal_False;
+ // a database form must be loaded for
+ try
+ {
+ if ( 0 == ( _nBehaviour & FORMS_UNLOAD ) )
+ {
+ if ( lcl_isLoadable( xForm ) && !xForm->isLoaded() )
+ xForm->load();
+ }
+ else
+ {
+ if ( xForm->isLoaded() )
+ {
+ bFormWasLoaded = sal_True;
+ xForm->unload();
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // reset the form if it was loaded
+ if ( bFormWasLoaded )
+ {
+ Reference< XIndexAccess > xContainer( xForm, UNO_QUERY );
+ DBG_ASSERT( xContainer.is(), "FmXFormShell::loadForms: the form is no container!" );
+ if ( xContainer.is() )
+ smartControlReset( xContainer );
+ }
+ }
+ }
+
+ if ( pModel )
+ // unlock the environment
+ pModel->GetUndoEnv().UnLock();
+ }
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::ExecuteTextAttribute( SfxRequest& _rReq )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::ExecuteTextAttribute" );
+ m_pTextShell->ExecuteTextAttribute( _rReq );
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::GetTextAttributeState( SfxItemSet& _rSet )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::GetTextAttributeState" );
+ m_pTextShell->GetTextAttributeState( _rSet );
+}
+
+//------------------------------------------------------------------------
+bool FmXFormShell::IsActiveControl( bool _bCountRichTextOnly ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::IsActiveControl" );
+ return m_pTextShell->IsActiveControl( _bCountRichTextOnly );
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::ForgetActiveControl()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::ForgetActiveControl" );
+ m_pTextShell->ForgetActiveControl();
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::SetControlActivationHandler( const Link& _rHdl )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::SetControlActivationHandler" );
+ m_pTextShell->SetControlActivationHandler( _rHdl );
+}
+//------------------------------------------------------------------------
+void FmXFormShell::handleShowPropertiesRequest()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::handleShowPropertiesRequest" );
+ if ( onlyControlsAreMarked() )
+ ShowSelectionProperties( sal_True );
+}
+
+//------------------------------------------------------------------------
+void FmXFormShell::handleMouseButtonDown( const SdrViewEvent& _rViewEvent )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::handleMouseButtonDown" );
+ // catch simple double clicks
+ if ( ( _rViewEvent.nMouseClicks == 2 ) && ( _rViewEvent.nMouseCode == MOUSE_LEFT ) )
+ {
+ if ( _rViewEvent.eHit == SDRHIT_MARKEDOBJECT )
+ {
+ if ( onlyControlsAreMarked() )
+ ShowSelectionProperties( sal_True );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+bool FmXFormShell::HasControlFocus() const
+{
+ bool bHasControlFocus = false;
+
+ try
+ {
+ Reference< XFormController > xController( getActiveController() );
+ Reference< XControl > xCurrentControl;
+ if ( xController.is() )
+ xCurrentControl.set( xController->getCurrentControl() );
+ if ( xCurrentControl.is() )
+ {
+ Reference< XWindow2 > xPeerWindow( xCurrentControl->getPeer(), UNO_QUERY_THROW );
+ bHasControlFocus = xPeerWindow->hasFocus();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return bHasControlFocus;
+}
+
+//==============================================================================
+//==============================================================================
+SearchableControlIterator::SearchableControlIterator(Reference< XInterface> xStartingPoint)
+ :IndexAccessIterator(xStartingPoint)
+{
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SearchableControlIterator::ShouldHandleElement(const Reference< XInterface>& xElement)
+{
+ // wenn das Ding eine ControlSource und einen BoundField-Property hat
+ Reference< XPropertySet> xProperties(xElement, UNO_QUERY);
+ if (::comphelper::hasProperty(FM_PROP_CONTROLSOURCE, xProperties) && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xProperties))
+ {
+ // und das BoundField gueltig ist
+ Reference< XPropertySet> xField;
+ xProperties->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
+ if (xField.is())
+ {
+ // nehmen wir's
+ m_sCurrentValue = ::comphelper::getString(xProperties->getPropertyValue(FM_PROP_CONTROLSOURCE));
+ return sal_True;
+ }
+ }
+
+ // wenn es ein Grid-Control ist
+ if (::comphelper::hasProperty(FM_PROP_CLASSID, xProperties))
+ {
+ Any aClassId( xProperties->getPropertyValue(FM_PROP_CLASSID) );
+ if (::comphelper::getINT16(aClassId) == FormComponentType::GRIDCONTROL)
+ {
+ m_sCurrentValue = ::rtl::OUString();
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SearchableControlIterator::ShouldStepInto(const Reference< XInterface>& /*xContainer*/) const
+{
+ return sal_True;
+}
+
+//==============================================================================
+//==============================================================================
+
+SV_IMPL_PTRARR(StatusForwarderArray, SfxStatusForwarder*)
+
+SFX_IMPL_MENU_CONTROL(ControlConversionMenuController, SfxBoolItem);
+
+//------------------------------------------------------------------------------
+ControlConversionMenuController::ControlConversionMenuController( sal_uInt16 _nId, Menu& _rMenu, SfxBindings& _rBindings )
+ :SfxMenuControl( _nId, _rBindings )
+ ,m_pMainMenu( &_rMenu )
+ ,m_pConversionMenu( NULL )
+{
+ if ( _nId == SID_FM_CHANGECONTROLTYPE )
+ {
+ m_pConversionMenu = FmXFormShell::GetConversionMenu();
+ _rMenu.SetPopupMenu( _nId, m_pConversionMenu );
+
+ for (sal_Int16 i=0; i<m_pConversionMenu->GetItemCount(); ++i)
+ {
+ _rBindings.Invalidate(m_pConversionMenu->GetItemId(i));
+ SfxStatusForwarder* pForwarder = new SfxStatusForwarder(m_pConversionMenu->GetItemId(i), *this);
+ m_aStatusForwarders.C40_INSERT(SfxStatusForwarder, pForwarder, m_aStatusForwarders.Count());
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+ControlConversionMenuController::~ControlConversionMenuController()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "ControlConversionMenuController::~ControlConversionMenuController" );
+ m_pMainMenu->SetPopupMenu(SID_FM_CHANGECONTROLTYPE, NULL);
+ delete m_pConversionMenu;
+}
+
+//------------------------------------------------------------------------------
+void ControlConversionMenuController::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState)
+{
+ if (nSID == GetId())
+ SfxMenuControl::StateChanged(nSID, eState, pState);
+ else if (FmXFormShell::isControlConversionSlot(nSID))
+ {
+ if ((m_pConversionMenu->GetItemPos(nSID) != MENU_ITEM_NOTFOUND) && (eState == SFX_ITEM_DISABLED))
+ {
+ m_pConversionMenu->RemoveItem(m_pConversionMenu->GetItemPos(nSID));
+ }
+ else if ((m_pConversionMenu->GetItemPos(nSID) == MENU_ITEM_NOTFOUND) && (eState != SFX_ITEM_DISABLED))
+ {
+ // We can't simply re-insert the item because we have a clear order for all the our items.
+ // So first we have to determine the position of the item to insert.
+ PopupMenu* pSource = FmXFormShell::GetConversionMenu();
+ USHORT nSourcePos = pSource->GetItemPos(nSID);
+ DBG_ASSERT(nSourcePos != MENU_ITEM_NOTFOUND, "ControlConversionMenuController::StateChanged : FmXFormShell supplied an invalid menu !");
+ USHORT nPrevInSource = nSourcePos;
+ USHORT nPrevInConversion = MENU_ITEM_NOTFOUND;
+ while (nPrevInSource>0)
+ {
+ sal_Int16 nPrevId = pSource->GetItemId(--nPrevInSource);
+
+ // do we have the source's predecessor in our conversion menu, too ?
+ nPrevInConversion = m_pConversionMenu->GetItemPos(nPrevId);
+ if (nPrevInConversion != MENU_ITEM_NOTFOUND)
+ break;
+ }
+ if (MENU_ITEM_NOTFOUND == nPrevInConversion)
+ // none of the items which precede the nSID-slot in the source menu are present in our conversion menu
+ nPrevInConversion = sal::static_int_cast< USHORT >(-1); // put the item at the first position
+ m_pConversionMenu->InsertItem(nSID, pSource->GetItemText(nSID), pSource->GetItemBits(nSID), ++nPrevInConversion);
+ m_pConversionMenu->SetItemImage(nSID, pSource->GetItemImage(nSID));
+ m_pConversionMenu->SetHelpId(nSID, pSource->GetHelpId(nSID));
+
+ delete pSource;
+ }
+ m_pMainMenu->EnableItem(SID_FM_CHANGECONTROLTYPE, m_pConversionMenu->GetItemCount() > 0);
+ }
+ else
+ {
+ DBG_ERROR("ControlConversionMenuController::StateChanged : unknown id !");
+ }
+}
+
+//==============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmsrccfg.cxx b/svx/source/form/fmsrccfg.cxx
new file mode 100644
index 000000000000..d632ffcc58e3
--- /dev/null
+++ b/svx/source/form/fmsrccfg.cxx
@@ -0,0 +1,366 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "fmsrccfg.hxx"
+#include <svl/filerec.hxx>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <comphelper/processfactory.hxx>
+
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::i18n;
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ // ====================================================================
+ // = struct FmSearchParams - Parameter einer Suche
+ // ====================================================================
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:17:34 -----------------------------------------------
+
+ FmSearchParams::FmSearchParams()
+ :nTransliterationFlags( 0 )
+ ,nSearchForType ( 0 )
+ ,nPosition ( MATCHING_ANYWHERE )
+ ,nLevOther ( 2 )
+ ,nLevShorter ( 2 )
+ ,nLevLonger ( 2 )
+ ,bLevRelaxed ( sal_True )
+ ,bAllFields ( sal_False )
+ ,bUseFormatter ( sal_True )
+ ,bBackwards ( sal_False )
+ ,bWildcard ( sal_False )
+ ,bRegular ( sal_False )
+ ,bApproxSearch ( sal_False )
+ ,bSoundsLikeCJK ( sal_False )
+ {
+ nTransliterationFlags =
+ TransliterationModules_ignoreSpace_ja_JP
+ | TransliterationModules_ignoreMiddleDot_ja_JP
+ | TransliterationModules_ignoreProlongedSoundMark_ja_JP
+ | TransliterationModules_ignoreSeparator_ja_JP
+ | TransliterationModules_IGNORE_CASE;
+ }
+
+ //---------------------------------------------------------------------
+ //--- 21.08.01 13:31:48 -----------------------------------------------
+
+ sal_Bool FmSearchParams::isIgnoreWidthCJK( ) const
+ {
+ return 0 != (nTransliterationFlags & TransliterationModules_IGNORE_WIDTH);
+ }
+
+ //---------------------------------------------------------------------
+ //--- 21.08.01 13:32:03 -----------------------------------------------
+
+ void FmSearchParams::setIgnoreWidthCJK( sal_Bool _bIgnore )
+ {
+ if ( _bIgnore )
+ nTransliterationFlags |= TransliterationModules_IGNORE_WIDTH;
+ else
+ nTransliterationFlags &= ~TransliterationModules_IGNORE_WIDTH;
+ }
+
+ //---------------------------------------------------------------------
+ //--- 21.08.01 13:47:52 -----------------------------------------------
+
+ sal_Bool FmSearchParams::isCaseSensitive( ) const
+ {
+ return 0 == (nTransliterationFlags & TransliterationModules_IGNORE_CASE);
+ }
+
+ //---------------------------------------------------------------------
+ //--- 21.08.01 13:48:00 -----------------------------------------------
+
+ void FmSearchParams::setCaseSensitive( sal_Bool _bCase )
+ {
+ if ( _bCase )
+ nTransliterationFlags &= ~TransliterationModules_IGNORE_CASE;
+ else
+ nTransliterationFlags |= TransliterationModules_IGNORE_CASE;
+ }
+
+ // ====================================================================
+ // = maps from ascii values to int values
+ // ====================================================================
+
+ struct Ascii2Int16
+ {
+ const sal_Char* pAscii;
+ sal_Int16 nValue;
+ };
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:28:38 -----------------------------------------------
+
+ static const Ascii2Int16* lcl_getSearchForTypeValueMap()
+ {
+ static const Ascii2Int16 s_aSearchForTypeMap[] =
+ {
+ { "text", 0 },
+ { "null", 1 },
+ { "non-null", 2 },
+ { NULL, -1 }
+ };
+ return s_aSearchForTypeMap;
+ }
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:28:38 -----------------------------------------------
+
+ static const Ascii2Int16* lcl_getSearchPositionValueMap()
+ {
+ static const Ascii2Int16 s_aSearchPositionMap[] =
+ {
+ { "anywhere-in-field", MATCHING_ANYWHERE },
+ { "beginning-of-field", MATCHING_BEGINNING },
+ { "end-of-field", MATCHING_END },
+ { "complete-field", MATCHING_WHOLETEXT },
+ { NULL, -1 }
+ };
+ return s_aSearchPositionMap;
+ }
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:30:15 -----------------------------------------------
+
+ static sal_Int16 lcl_implMapAsciiValue( const ::rtl::OUString& _rAsciiValue, const Ascii2Int16* _pMap )
+ {
+ // search the map for the given ascii value
+ const Ascii2Int16* pSearch = _pMap;
+ while ( pSearch && pSearch->pAscii )
+ {
+ if ( 0 == _rAsciiValue.compareToAscii( pSearch->pAscii ) )
+ // found
+ return pSearch->nValue;
+ ++pSearch;
+ }
+
+ DBG_ERROR(
+ ( ::rtl::OString( "lcl_implMapAsciiValue: could not convert the ascii value " )
+ += ::rtl::OString( _rAsciiValue.getStr(), _rAsciiValue.getLength(), RTL_TEXTENCODING_ASCII_US )
+ += ::rtl::OString( " !" )
+ ).getStr()
+ );
+ return -1;
+ }
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:33:06 -----------------------------------------------
+
+ static const sal_Char* lcl_implMapIntValue( const sal_Int16 _nValue, const Ascii2Int16* _pMap )
+ {
+ // search the map for the given integer value
+ const Ascii2Int16* pSearch = _pMap;
+ while ( pSearch && pSearch->pAscii )
+ {
+ if ( _nValue == pSearch->nValue )
+ // found
+ return pSearch->pAscii;
+ ++pSearch;
+ }
+
+ DBG_ERROR(
+ ( ::rtl::OString( "lcl_implMapIntValue: could not convert the integer value " )
+ += ::rtl::OString::valueOf( (sal_Int32)_nValue )
+ += ::rtl::OString( " !" )
+ ).getStr()
+ );
+ static const sal_Char* s_pDummy = "";
+ // just as a fallback ....
+ return s_pDummy;
+ }
+
+ // ====================================================================
+ // = class FmSearchConfigItem - ein ConfigItem, dass sich Suchparameter merkt
+ // ====================================================================
+
+#define TA( c ) &c, getCppuType( &c )
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:19:59 -----------------------------------------------
+
+ FmSearchConfigItem::FmSearchConfigItem()
+ :OConfigurationValueContainer( ::comphelper::getProcessServiceFactory(), m_aMutex, "/org.openoffice.Office.DataAccess/FormSearchOptions", CVC_UPDATE_ACCESS | CVC_LAZY_UPDATE, 2 )
+ {
+ // register our members so the data exchange with the node values is done automatically
+
+ registerExchangeLocation( "SearchHistory", TA( aHistory ) );
+ registerExchangeLocation( "LevenshteinOther", TA( nLevOther ) );
+ registerExchangeLocation( "LevenshteinShorter", TA( nLevShorter ) );
+ registerExchangeLocation( "LevenshteinLonger", TA( nLevLonger ) );
+ registerExchangeLocation( "IsLevenshteinRelaxed", TA( bLevRelaxed ) );
+ registerExchangeLocation( "IsSearchAllFields", TA( bAllFields ) );
+ registerExchangeLocation( "IsUseFormatter", TA( bUseFormatter ) );
+ registerExchangeLocation( "IsBackwards", TA( bBackwards ) );
+ registerExchangeLocation( "IsWildcardSearch", TA( bWildcard ) );
+ registerExchangeLocation( "IsUseRegularExpression", TA( bRegular ) );
+ registerExchangeLocation( "IsSimilaritySearch", TA( bApproxSearch ) );
+ registerExchangeLocation( "IsUseAsianOptions", TA( bSoundsLikeCJK ) );
+
+ // the properties which need to be translated
+ registerExchangeLocation( "SearchType", TA( m_sSearchForType ) );
+ registerExchangeLocation( "SearchPosition", TA( m_sSearchPosition ) );
+
+ registerExchangeLocation( "IsMatchCase", TA( m_bIsMatchCase ) );
+ registerExchangeLocation( "Japanese/IsMatchFullHalfWidthForms", TA( m_bIsMatchFullHalfWidthForms ) );
+ registerExchangeLocation( "Japanese/IsMatchHiraganaKatakana", TA( m_bIsMatchHiraganaKatakana ) );
+ registerExchangeLocation( "Japanese/IsMatchContractions", TA( m_bIsMatchContractions ) );
+ registerExchangeLocation( "Japanese/IsMatchMinusDashCho-on", TA( m_bIsMatchMinusDashCho_on ) );
+ registerExchangeLocation( "Japanese/IsMatchRepeatCharMarks", TA( m_bIsMatchRepeatCharMarks ) );
+ registerExchangeLocation( "Japanese/IsMatchVariantFormKanji", TA( m_bIsMatchVariantFormKanji ) );
+ registerExchangeLocation( "Japanese/IsMatchOldKanaForms", TA( m_bIsMatchOldKanaForms ) );
+ registerExchangeLocation( "Japanese/IsMatch_DiZi_DuZu", TA( m_bIsMatch_DiZi_DuZu ) );
+ registerExchangeLocation( "Japanese/IsMatch_BaVa_HaFa", TA( m_bIsMatch_BaVa_HaFa ) );
+ registerExchangeLocation( "Japanese/IsMatch_TsiThiChi_DhiZi", TA( m_bIsMatch_TsiThiChi_DhiZi ) );
+ registerExchangeLocation( "Japanese/IsMatch_HyuIyu_ByuVyu", TA( m_bIsMatch_HyuIyu_ByuVyu ) );
+ registerExchangeLocation( "Japanese/IsMatch_SeShe_ZeJe", TA( m_bIsMatch_SeShe_ZeJe ) );
+ registerExchangeLocation( "Japanese/IsMatch_IaIya", TA( m_bIsMatch_IaIya ) );
+ registerExchangeLocation( "Japanese/IsMatch_KiKu", TA( m_bIsMatch_KiKu ) );
+ registerExchangeLocation( "Japanese/IsIgnorePunctuation", TA( m_bIsIgnorePunctuation ) );
+ registerExchangeLocation( "Japanese/IsIgnoreWhitespace", TA( m_bIsIgnoreWhitespace ) );
+ registerExchangeLocation( "Japanese/IsIgnoreProlongedSoundMark",TA( m_bIsIgnoreProlongedSoundMark ) );
+ registerExchangeLocation( "Japanese/IsIgnoreMiddleDot", TA( m_bIsIgnoreMiddleDot ) );
+
+ read( );
+ }
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:19:57 -----------------------------------------------
+
+ FmSearchConfigItem::~FmSearchConfigItem()
+ {
+ commit( );
+ }
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:20:48 -----------------------------------------------
+
+ void FmSearchConfigItem::implTranslateFromConfig( )
+ {
+ // the search-for string
+ nSearchForType = lcl_implMapAsciiValue( m_sSearchForType, lcl_getSearchForTypeValueMap() );
+
+ // the search position
+ nPosition = lcl_implMapAsciiValue( m_sSearchPosition, lcl_getSearchPositionValueMap() );
+
+ // the transliteration flags
+ nTransliterationFlags = 0;
+
+ if ( !m_bIsMatchCase ) nTransliterationFlags |= TransliterationModules_IGNORE_CASE;
+ if ( m_bIsMatchFullHalfWidthForms ) nTransliterationFlags |= TransliterationModules_IGNORE_WIDTH;
+ if ( m_bIsMatchHiraganaKatakana ) nTransliterationFlags |= TransliterationModules_IGNORE_KANA;
+ if ( m_bIsMatchContractions ) nTransliterationFlags |= TransliterationModules_ignoreSize_ja_JP;
+ if ( m_bIsMatchMinusDashCho_on ) nTransliterationFlags |= TransliterationModules_ignoreMinusSign_ja_JP;
+ if ( m_bIsMatchRepeatCharMarks ) nTransliterationFlags |= TransliterationModules_ignoreIterationMark_ja_JP;
+ if ( m_bIsMatchVariantFormKanji ) nTransliterationFlags |= TransliterationModules_ignoreTraditionalKanji_ja_JP;
+ if ( m_bIsMatchOldKanaForms ) nTransliterationFlags |= TransliterationModules_ignoreTraditionalKana_ja_JP;
+ if ( m_bIsMatch_DiZi_DuZu ) nTransliterationFlags |= TransliterationModules_ignoreZiZu_ja_JP;
+ if ( m_bIsMatch_BaVa_HaFa ) nTransliterationFlags |= TransliterationModules_ignoreBaFa_ja_JP;
+ if ( m_bIsMatch_TsiThiChi_DhiZi ) nTransliterationFlags |= TransliterationModules_ignoreTiJi_ja_JP;
+ if ( m_bIsMatch_HyuIyu_ByuVyu ) nTransliterationFlags |= TransliterationModules_ignoreHyuByu_ja_JP;
+ if ( m_bIsMatch_SeShe_ZeJe ) nTransliterationFlags |= TransliterationModules_ignoreSeZe_ja_JP;
+ if ( m_bIsMatch_IaIya ) nTransliterationFlags |= TransliterationModules_ignoreIandEfollowedByYa_ja_JP;
+ if ( m_bIsMatch_KiKu ) nTransliterationFlags |= TransliterationModules_ignoreKiKuFollowedBySa_ja_JP;
+
+ if ( m_bIsIgnorePunctuation ) nTransliterationFlags |= TransliterationModules_ignoreSeparator_ja_JP;
+ if ( m_bIsIgnoreWhitespace ) nTransliterationFlags |= TransliterationModules_ignoreSpace_ja_JP;
+ if ( m_bIsIgnoreProlongedSoundMark ) nTransliterationFlags |= TransliterationModules_ignoreProlongedSoundMark_ja_JP;
+ if ( m_bIsIgnoreMiddleDot ) nTransliterationFlags |= TransliterationModules_ignoreMiddleDot_ja_JP;
+ }
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:42:23 -----------------------------------------------
+
+ void FmSearchConfigItem::implTranslateToConfig( )
+ {
+ // the search-for string
+ m_sSearchForType = ::rtl::OUString::createFromAscii( lcl_implMapIntValue( nSearchForType, lcl_getSearchForTypeValueMap() ) );
+
+ // the search position
+ m_sSearchPosition = ::rtl::OUString::createFromAscii( lcl_implMapIntValue( nPosition, lcl_getSearchPositionValueMap() ) );
+
+ // the transliteration flags
+
+ m_bIsMatchCase = ( 0 == ( nTransliterationFlags & TransliterationModules_IGNORE_CASE ) );
+ m_bIsMatchFullHalfWidthForms = ( 0 != ( nTransliterationFlags & TransliterationModules_IGNORE_WIDTH ) );
+ m_bIsMatchHiraganaKatakana = ( 0 != ( nTransliterationFlags & TransliterationModules_IGNORE_KANA ) );
+ m_bIsMatchContractions = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreSize_ja_JP ) );
+ m_bIsMatchMinusDashCho_on = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreMinusSign_ja_JP ) );
+ m_bIsMatchRepeatCharMarks = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreIterationMark_ja_JP ) );
+ m_bIsMatchVariantFormKanji = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreTraditionalKanji_ja_JP ) );
+ m_bIsMatchOldKanaForms = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreTraditionalKana_ja_JP ) );
+ m_bIsMatch_DiZi_DuZu = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreZiZu_ja_JP ) );
+ m_bIsMatch_BaVa_HaFa = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreBaFa_ja_JP ) );
+ m_bIsMatch_TsiThiChi_DhiZi = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreTiJi_ja_JP ) );
+ m_bIsMatch_HyuIyu_ByuVyu = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreHyuByu_ja_JP ) );
+ m_bIsMatch_SeShe_ZeJe = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreSeZe_ja_JP ) );
+ m_bIsMatch_IaIya = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreIandEfollowedByYa_ja_JP ) );
+ m_bIsMatch_KiKu = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreKiKuFollowedBySa_ja_JP ) );
+
+ m_bIsIgnorePunctuation = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreSeparator_ja_JP ) );
+ m_bIsIgnoreWhitespace = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreSpace_ja_JP ) );
+ m_bIsIgnoreProlongedSoundMark = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreProlongedSoundMark_ja_JP ) );
+ m_bIsIgnoreMiddleDot = ( 0 != ( nTransliterationFlags & TransliterationModules_ignoreMiddleDot_ja_JP ) );
+ }
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:20:01 -----------------------------------------------
+
+ const FmSearchParams& FmSearchConfigItem::getParams() const
+ {
+ // ensure that the properties which are not stored directly are up-to-date
+ const_cast< FmSearchConfigItem* >( this )->implTranslateFromConfig( );
+
+ // and return our FmSearchParams part
+ return *this;
+ }
+
+ //---------------------------------------------------------------------
+ //--- 20.08.01 18:41:57 -----------------------------------------------
+
+ void FmSearchConfigItem::setParams( const FmSearchParams& _rParams )
+ {
+ // copy the FmSearchParams part
+ *static_cast< FmSearchParams* >( this ) = _rParams;
+
+ // translate the settings not represented by a direct config value
+ implTranslateToConfig();
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmsrcimp.cxx b/svx/source/form/fmsrcimp.cxx
new file mode 100644
index 000000000000..b836e299bb27
--- /dev/null
+++ b/svx/source/form/fmsrcimp.cxx
@@ -0,0 +1,1300 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmresids.hrc"
+#include "svx/fmtools.hxx"
+#include "fmsrccfg.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/wldcrd.hxx>
+#include <vcl/msgbox.hxx>
+#include <tools/shl.hxx>
+#include <svx/dialmgr.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <vcl/svapp.hxx>
+#include <unotools/textsearch.hxx>
+#include <com/sun/star/util/SearchOptions.hpp>
+#include <com/sun/star/util/SearchAlgorithms.hpp>
+#include <com/sun/star/util/SearchResult.hpp>
+#include <com/sun/star/util/SearchFlags.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/i18n/CollatorOptions.hpp>
+
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormats.hpp>
+#include <comphelper/processfactory.hxx>
+
+#include "fmprop.hrc"
+#include "fmservs.hxx"
+#include "fmsrcimp.hxx"
+#include <svx/fmsearch.hxx>
+
+#include <comphelper/numbers.hxx>
+#include <unotools/syslocale.hxx>
+
+#define EQUAL_BOOKMARKS(a, b) a == b
+
+#define IFACECAST(c) ((const Reference< XInterface >&)c)
+ // SUN C52 has some ambiguities without this cast ....
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::beans;
+using namespace ::svxform;
+
+// ***************************************************************************************************
+
+// ***************************************************************************************************
+
+SV_IMPL_OBJARR(SvInt32Array, sal_Int32);
+
+//========================================================================
+// = FmSearchThread
+//------------------------------------------------------------------------
+void FmSearchThread::run()
+{
+ m_pEngine->SearchNextImpl();
+};
+
+//------------------------------------------------------------------------
+void FmSearchThread::onTerminated()
+{
+ if (m_aTerminationHdl.IsSet())
+ m_aTerminationHdl.Call(this);
+ delete this;
+}
+
+//========================================================================
+// = FmRecordCountListener
+
+// SMART_UNO_IMPLEMENTATION(FmRecordCountListener, UsrObject);
+
+DBG_NAME(FmRecordCountListener);
+//------------------------------------------------------------------------
+FmRecordCountListener::FmRecordCountListener(const Reference< ::com::sun::star::sdbc::XResultSet > & dbcCursor)
+{
+ DBG_CTOR(FmRecordCountListener,NULL);
+
+ m_xListening = Reference< ::com::sun::star::beans::XPropertySet > (dbcCursor, UNO_QUERY);
+ if (!m_xListening.is())
+ return;
+
+ if (::comphelper::getBOOL(m_xListening->getPropertyValue(FM_PROP_ROWCOUNTFINAL)))
+ {
+ m_xListening = NULL;
+ // there's nothing to do as the record count is already known
+ return;
+ }
+
+ m_xListening->addPropertyChangeListener(FM_PROP_ROWCOUNT, (::com::sun::star::beans::XPropertyChangeListener*)this);
+}
+
+//------------------------------------------------------------------------
+Link FmRecordCountListener::SetPropChangeHandler(const Link& lnk)
+{
+ Link lnkReturn = m_lnkWhoWantsToKnow;
+ m_lnkWhoWantsToKnow = lnk;
+
+ if (m_xListening.is())
+ NotifyCurrentCount();
+
+ return lnkReturn;
+}
+
+//------------------------------------------------------------------------
+FmRecordCountListener::~FmRecordCountListener()
+{
+
+ DBG_DTOR(FmRecordCountListener,NULL);
+}
+
+//------------------------------------------------------------------------
+void FmRecordCountListener::DisConnect()
+{
+ if(m_xListening.is())
+ m_xListening->removePropertyChangeListener(FM_PROP_ROWCOUNT, (::com::sun::star::beans::XPropertyChangeListener*)this);
+ m_xListening = NULL;
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL FmRecordCountListener::disposing(const ::com::sun::star::lang::EventObject& /*Source*/) throw( RuntimeException )
+{
+ DBG_ASSERT(m_xListening.is(), "FmRecordCountListener::disposing should never have been called without a propset !");
+ DisConnect();
+}
+
+//------------------------------------------------------------------------
+void FmRecordCountListener::NotifyCurrentCount()
+{
+ if (m_lnkWhoWantsToKnow.IsSet())
+ {
+ DBG_ASSERT(m_xListening.is(), "FmRecordCountListener::NotifyCurrentCount : I have no propset ... !?");
+ void* pTheCount = (void*)::comphelper::getINT32(m_xListening->getPropertyValue(FM_PROP_ROWCOUNT));
+ m_lnkWhoWantsToKnow.Call(pTheCount);
+ }
+}
+
+//------------------------------------------------------------------------
+void FmRecordCountListener::propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& /*evt*/) throw(::com::sun::star::uno::RuntimeException)
+{
+ NotifyCurrentCount();
+}
+
+//========================================================================
+// FmSearchEngine - local classes
+//------------------------------------------------------------------------
+SimpleTextWrapper::SimpleTextWrapper(const Reference< ::com::sun::star::awt::XTextComponent > & _xText)
+ :ControlTextWrapper(_xText.get())
+ ,m_xText(_xText)
+{
+ DBG_ASSERT(m_xText.is(), "FmSearchEngine::SimpleTextWrapper::SimpleTextWrapper : invalid argument !");
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString SimpleTextWrapper::getCurrentText() const
+{
+ return m_xText->getText();
+}
+
+//------------------------------------------------------------------------
+ListBoxWrapper::ListBoxWrapper(const Reference< ::com::sun::star::awt::XListBox > & _xBox)
+ :ControlTextWrapper(_xBox.get())
+ ,m_xBox(_xBox)
+{
+ DBG_ASSERT(m_xBox.is(), "FmSearchEngine::ListBoxWrapper::ListBoxWrapper : invalid argument !");
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString ListBoxWrapper::getCurrentText() const
+{
+ return m_xBox->getSelectedItem();
+}
+
+//------------------------------------------------------------------------
+CheckBoxWrapper::CheckBoxWrapper(const Reference< ::com::sun::star::awt::XCheckBox > & _xBox)
+ :ControlTextWrapper(_xBox.get())
+ ,m_xBox(_xBox)
+{
+ DBG_ASSERT(m_xBox.is(), "FmSearchEngine::CheckBoxWrapper::CheckBoxWrapper : invalid argument !");
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString CheckBoxWrapper::getCurrentText() const
+{
+ switch ((TriState)m_xBox->getState())
+ {
+ case STATE_NOCHECK: return rtl::OUString::createFromAscii("0");
+ case STATE_CHECK: return rtl::OUString::createFromAscii("1");
+ default: break;
+ }
+ return rtl::OUString();
+}
+
+//========================================================================
+// = FmSearchEngine
+//------------------------------------------------------------------------
+sal_Bool FmSearchEngine::MoveCursor()
+{
+ sal_Bool bSuccess = sal_True;
+ try
+ {
+ if (m_bForward)
+ if (m_xSearchCursor.isLast())
+ m_xSearchCursor.first();
+ else
+ m_xSearchCursor.next();
+ else
+ if (m_xSearchCursor.isFirst())
+ {
+ FmRecordCountListener* prclListener = new FmRecordCountListener(m_xSearchCursor);
+ prclListener->acquire();
+ prclListener->SetPropChangeHandler(LINK(this, FmSearchEngine, OnNewRecordCount));
+
+ m_xSearchCursor.last();
+
+ prclListener->DisConnect();
+ prclListener->release();
+ }
+ else
+ m_xSearchCursor.previous();
+ }
+ catch(::com::sun::star::sdbc::SQLException e)
+ {
+#if OSL_DEBUG_LEVEL > 0
+ String sDebugMessage;
+ sDebugMessage.AssignAscii("FmSearchEngine::MoveCursor : catched a DatabaseException (");
+ sDebugMessage += (const sal_Unicode*)e.SQLState;
+ sDebugMessage.AppendAscii(") !");
+ DBG_ERROR(ByteString(sDebugMessage, RTL_TEXTENCODING_ASCII_US).GetBuffer());
+#endif
+ bSuccess = sal_False;
+ }
+ catch(Exception e)
+ {
+#if OSL_DEBUG_LEVEL > 0
+ UniString sDebugMessage;
+ sDebugMessage.AssignAscii("FmSearchEngine::MoveCursor : catched an Exception (");
+ sDebugMessage += (const sal_Unicode*)e.Message;
+ sDebugMessage.AppendAscii(") !");
+ DBG_ERROR(ByteString(sDebugMessage, RTL_TEXTENCODING_ASCII_US).GetBuffer());
+#endif
+ bSuccess = sal_False;
+ }
+ catch(...)
+ {
+ DBG_ERROR("FmSearchEngine::MoveCursor : catched an unknown Exception !");
+ bSuccess = sal_False;
+ }
+
+ return bSuccess;
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmSearchEngine::MoveField(sal_Int32& nPos, FieldCollectionIterator& iter, const FieldCollectionIterator& iterBegin, const FieldCollectionIterator& iterEnd)
+{
+ sal_Bool bSuccess(sal_True);
+ if (m_bForward)
+ {
+ ++iter;
+ ++nPos;
+ if (iter == iterEnd)
+ {
+ bSuccess = MoveCursor();
+ iter = iterBegin;
+ nPos = 0;
+ }
+ } else
+ {
+ if (iter == iterBegin)
+ {
+ bSuccess = MoveCursor();
+ iter = iterEnd;
+ nPos = iter-iterBegin;
+ }
+ --iter;
+ --nPos;
+ }
+ return bSuccess;
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::BuildAndInsertFieldInfo(const Reference< ::com::sun::star::container::XIndexAccess > & xAllFields, sal_Int32 nField)
+{
+ DBG_ASSERT( xAllFields.is() && ( nField >= 0 ) && ( nField < xAllFields->getCount() ),
+ "FmSearchEngine::BuildAndInsertFieldInfo: invalid field descriptor!" );
+
+ // das Feld selber
+ Reference< XInterface > xCurrentField;
+ xAllFields->getByIndex(nField) >>= xCurrentField;
+
+ // von dem weiss ich jetzt, dass es den DatabaseRecord-Service unterstuetzt (hoffe ich)
+ // fuer den FormatKey und den Typ brauche ich das PropertySet
+ Reference< ::com::sun::star::beans::XPropertySet > xProperties(xCurrentField, UNO_QUERY);
+
+ // die FieldInfo dazu aufbauen
+ FieldInfo fiCurrent;
+ fiCurrent.xContents = Reference< ::com::sun::star::sdb::XColumn > (xCurrentField, UNO_QUERY);
+ fiCurrent.nFormatKey = ::comphelper::getINT32(xProperties->getPropertyValue(FM_PROP_FORMATKEY));
+ fiCurrent.bDoubleHandling = sal_False;
+ if (m_xFormatSupplier.is())
+ {
+ Reference< ::com::sun::star::util::XNumberFormats > xNumberFormats(m_xFormatSupplier->getNumberFormats());
+
+ sal_Int16 nFormatType = ::comphelper::getNumberFormatType(xNumberFormats, fiCurrent.nFormatKey) & ~((sal_Int16)::com::sun::star::util::NumberFormat::DEFINED);
+ fiCurrent.bDoubleHandling = (nFormatType != ::com::sun::star::util::NumberFormat::TEXT);
+ }
+
+ // und merken
+ m_arrUsedFields.insert(m_arrUsedFields.end(), fiCurrent);
+
+}
+//------------------------------------------------------------------------
+::rtl::OUString FmSearchEngine::FormatField(const FieldInfo& rField)
+{
+ DBG_ASSERT(!m_bUsingTextComponents, "FmSearchEngine::FormatField : im UsingTextComponents-Mode bitte FormatField(sal_Int32) benutzen !");
+
+ if (!m_xFormatter.is())
+ return ::rtl::OUString();
+ // sonst werden Datumsflder zum Beispiel zu irgendeinem Default-Wert formatiert
+
+ ::rtl::OUString sReturn;
+ try
+ {
+ if (rField.bDoubleHandling)
+ {
+ double fValue = rField.xContents->getDouble();
+ if (!rField.xContents->wasNull())
+ sReturn = m_xFormatter->convertNumberToString(rField.nFormatKey, fValue);
+ }
+ else
+ {
+ ::rtl::OUString sValue = rField.xContents->getString();
+ if (!rField.xContents->wasNull())
+ sReturn = m_xFormatter->formatString(rField.nFormatKey, sValue);
+ }
+ }
+ catch(...)
+ {
+ }
+
+
+ return sReturn;
+}
+
+//------------------------------------------------------------------------
+::rtl::OUString FmSearchEngine::FormatField(sal_Int32 nWhich)
+{
+ if (m_bUsingTextComponents)
+ {
+ DBG_ASSERT((sal_uInt32)nWhich < m_aControlTexts.size(), "FmSearchEngine::FormatField(sal_Int32) : invalid position !");
+ DBG_ASSERT(m_aControlTexts[nWhich] != NULL, "FmSearchEngine::FormatField(sal_Int32) : invalid object in array !");
+ DBG_ASSERT(m_aControlTexts[nWhich]->getControl().is(), "FmSearchEngine::FormatField : invalid control !");
+
+ if (m_nCurrentFieldIndex != -1)
+ {
+ DBG_ASSERT((nWhich == 0) || (nWhich == m_nCurrentFieldIndex), "FmSearchEngine::FormatField : Parameter nWhich ist ungueltig");
+ // analoge Situation wie unten
+ nWhich = m_nCurrentFieldIndex;
+ }
+
+ DBG_ASSERT((nWhich >= 0) && ((sal_uInt32)nWhich < m_aControlTexts.size()),
+ "FmSearchEngine::FormatField : invalid argument nWhich !");
+ return m_aControlTexts[m_nCurrentFieldIndex == -1 ? nWhich : m_nCurrentFieldIndex]->getCurrentText();
+ }
+ else
+ {
+ if (m_nCurrentFieldIndex != -1)
+ {
+ DBG_ASSERT((nWhich == 0) || (nWhich == m_nCurrentFieldIndex), "FmSearchEngine::FormatField : Parameter nWhich ist ungueltig");
+ // ich bin im single-field-modus, da ist auch die richtige Feld-Nummer erlaubt, obwohl dann der richtige ::com::sun::star::sdbcx::Index
+ // fuer meinen Array-Zugriff natuerlich 0 ist
+ nWhich = 0;
+ }
+
+ DBG_ASSERT((nWhich>=0) && (nWhich < (m_arrUsedFields.end() - m_arrUsedFields.begin())),
+ "FmSearchEngine::FormatField : Parameter nWhich ist ungueltig");
+ return FormatField(m_arrUsedFields[nWhich]);
+ }
+}
+
+//------------------------------------------------------------------------
+FmSearchEngine::SEARCH_RESULT FmSearchEngine::SearchSpecial(sal_Bool _bSearchForNull, sal_Int32& nFieldPos,
+ FieldCollectionIterator& iterFieldLoop, const FieldCollectionIterator& iterBegin, const FieldCollectionIterator& iterEnd)
+{
+ // die Startposition merken
+ Any aStartMark;
+ try { aStartMark = m_xSearchCursor.getBookmark(); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); return SR_ERROR; }
+ FieldCollectionIterator iterInitialField = iterFieldLoop;
+
+ // --------------------------------------------------------------
+ sal_Bool bFound(sal_False);
+ sal_Bool bMovedAround(sal_False);
+ do
+ {
+ if (m_eMode == SM_ALLOWSCHEDULE)
+ {
+ Application::Reschedule();
+ Application::Reschedule();
+ // do 2 reschedules because of #70226# : some things done within this loop's body may cause an user event
+ // to be posted (deep within vcl), and these user events will be handled before any keyinput or paintings
+ // or anything like that. So within each loop we create one user event and handle one user event (and no
+ // paintings and these), so the office seems to be frozen while searching.
+ // FS - 70226 - 02.12.99
+ }
+
+ // der aktuell zu vergleichende Inhalt
+ iterFieldLoop->xContents->getString(); // needed for wasNull
+ bFound = _bSearchForNull == iterFieldLoop->xContents->wasNull();
+ if (bFound)
+ break;
+
+ // naechstes Feld (implizit naechster Datensatz, wenn noetig)
+ if (!MoveField(nFieldPos, iterFieldLoop, iterBegin, iterEnd))
+ { // beim Bewegen auf das naechste Feld ging was schief ... weitermachen ist nicht drin, da das naechste Mal genau
+ // das selbe bestimmt wieder schief geht, also Abbruch
+ // vorher aber noch, damit das Weitersuchen an der aktuellen Position weitermacht :
+ try { m_aPreviousLocBookmark = m_xSearchCursor.getBookmark(); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+ m_iterPreviousLocField = iterFieldLoop;
+ // und wech
+ return SR_ERROR;
+ }
+
+ Any aCurrentBookmark;
+ try { aCurrentBookmark = m_xSearchCursor.getBookmark(); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); return SR_ERROR; }
+
+ bMovedAround = EQUAL_BOOKMARKS(aStartMark, aCurrentBookmark) && (iterFieldLoop == iterInitialField);
+
+ if (nFieldPos == 0)
+ // das heisst, ich habe mich auf einen neuen Datensatz bewegt
+ PropagateProgress(bMovedAround);
+ // if we moved to the starting position we don't have to propagate an 'overflow' message
+ // FS - 07.12.99 - 68530
+
+ // abbrechen gefordert ?
+ if (CancelRequested())
+ return SR_CANCELED;
+
+ } while (!bMovedAround);
+
+ return bFound ? SR_FOUND : SR_NOTFOUND;
+}
+
+//------------------------------------------------------------------------
+FmSearchEngine::SEARCH_RESULT FmSearchEngine::SearchWildcard(const ::rtl::OUString& strExpression, sal_Int32& nFieldPos,
+ FieldCollectionIterator& iterFieldLoop, const FieldCollectionIterator& iterBegin, const FieldCollectionIterator& iterEnd)
+{
+ // die Startposition merken
+ Any aStartMark;
+ try { aStartMark = m_xSearchCursor.getBookmark(); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); return SR_ERROR; }
+ FieldCollectionIterator iterInitialField = iterFieldLoop;
+
+ WildCard aSearchExpression(strExpression);
+
+ // --------------------------------------------------------------
+ sal_Bool bFound(sal_False);
+ sal_Bool bMovedAround(sal_False);
+ do
+ {
+ if (m_eMode == SM_ALLOWSCHEDULE)
+ {
+ Application::Reschedule();
+ Application::Reschedule();
+ // do 2 reschedules because of #70226# : some things done within this loop's body may cause an user event
+ // to be posted (deep within vcl), and these user events will be handled before any keyinput or paintings
+ // or anything like that. So within each loop we create one user event and hanel one user event (and no
+ // paintings and these), so the office seems to be frozen while searching.
+ // FS - 70226 - 02.12.99
+ }
+
+ // der aktuell zu vergleichende Inhalt
+ ::rtl::OUString sCurrentCheck;
+ if (m_bFormatter)
+ sCurrentCheck = FormatField(nFieldPos);
+ else
+ sCurrentCheck = iterFieldLoop->xContents->getString();
+
+ if (!GetCaseSensitive())
+ // norm the string
+ m_aCharacterClassficator.toLower_rtl(sCurrentCheck);
+
+ // jetzt ist der Test einfach ...
+ bFound = aSearchExpression.Matches(sCurrentCheck);
+
+ if (bFound)
+ break;
+
+ // naechstes Feld (implizit naechster Datensatz, wenn noetig)
+ if (!MoveField(nFieldPos, iterFieldLoop, iterBegin, iterEnd))
+ { // beim Bewegen auf das naechste Feld ging was schief ... weitermachen ist nicht drin, da das naechste Mal genau
+ // das selbe bestimmt wieder schief geht, also Abbruch
+ // vorher aber noch, damit das Weitersuchen an der aktuellen Position weitermacht :
+ try { m_aPreviousLocBookmark = m_xSearchCursor.getBookmark(); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+ m_iterPreviousLocField = iterFieldLoop;
+ // und wech
+ return SR_ERROR;
+ }
+
+ Any aCurrentBookmark;
+ try { aCurrentBookmark = m_xSearchCursor.getBookmark(); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); return SR_ERROR; }
+
+ bMovedAround = EQUAL_BOOKMARKS(aStartMark, aCurrentBookmark) && (iterFieldLoop == iterInitialField);
+
+ if (nFieldPos == 0)
+ // das heisst, ich habe mich auf einen neuen Datensatz bewegt
+ PropagateProgress(bMovedAround);
+ // if we moved to the starting position we don't have to propagate an 'overflow' message
+ // FS - 07.12.99 - 68530
+
+ // abbrechen gefordert ?
+ if (CancelRequested())
+ return SR_CANCELED;
+
+ } while (!bMovedAround);
+
+ return bFound ? SR_FOUND : SR_NOTFOUND;
+}
+
+//------------------------------------------------------------------------
+FmSearchEngine::SEARCH_RESULT FmSearchEngine::SearchRegularApprox(const ::rtl::OUString& strExpression, sal_Int32& nFieldPos,
+ FieldCollectionIterator& iterFieldLoop, const FieldCollectionIterator& iterBegin, const FieldCollectionIterator& iterEnd)
+{
+ DBG_ASSERT(m_bLevenshtein || m_bRegular,
+ "FmSearchEngine::SearchRegularApprox : ungueltiger Suchmodus !");
+ DBG_ASSERT(!m_bLevenshtein || !m_bRegular,
+ "FmSearchEngine::SearchRegularApprox : kann nicht nach regulaeren Ausdruecken und nach Aehnlichkeiten gleichzeitig suchen !");
+
+ // Startposition merken
+ Any aStartMark;
+ try { aStartMark = m_xSearchCursor.getBookmark(); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); return SR_ERROR; }
+ FieldCollectionIterator iterInitialField = iterFieldLoop;
+
+ // Parameter sammeln
+ SearchOptions aParam;
+ aParam.algorithmType = m_bRegular ? SearchAlgorithms_REGEXP : SearchAlgorithms_APPROXIMATE;
+ aParam.searchFlag = 0;
+ aParam.transliterateFlags = GetTransliterationFlags();
+ if ( !GetTransliteration() )
+ { // if transliteration is not enabled, the only flags which matter are IGNORE_CASE and IGNORE_WIDTH
+ aParam.transliterateFlags &= TransliterationModules_IGNORE_CASE | TransliterationModules_IGNORE_WIDTH;
+ }
+ if (m_bLevenshtein)
+ {
+ if (m_bLevRelaxed)
+ aParam.searchFlag |= SearchFlags::LEV_RELAXED;
+ aParam.changedChars = m_nLevOther;
+ aParam.deletedChars = m_nLevShorter;
+ aParam.insertedChars = m_nLevLonger;
+ }
+ aParam.searchString = strExpression;
+ aParam.Locale = SvtSysLocale().GetLocaleData().getLocale();
+ ::utl::TextSearch aLocalEngine(aParam);
+
+ // --------------------------------------------------------------
+ bool bFound = false;
+ sal_Bool bMovedAround(sal_False);
+ do
+ {
+ if (m_eMode == SM_ALLOWSCHEDULE)
+ {
+ Application::Reschedule();
+ Application::Reschedule();
+ // do 2 reschedules because of #70226# : some things done within this loop's body may cause an user event
+ // to be posted (deep within vcl), and these user events will be handled before any keyinput or paintings
+ // or anything like that. So within each loop we create one user event and handle one user event (and no
+ // paintings and these), so the office seems to be frozen while searching.
+ // FS - 70226 - 02.12.99
+ }
+
+ // der aktuell zu vergleichende Inhalt
+ ::rtl::OUString sCurrentCheck;
+ if (m_bFormatter)
+ sCurrentCheck = FormatField(nFieldPos);
+ else
+ sCurrentCheck = iterFieldLoop->xContents->getString();
+
+ // (don't care about case here, this is done by the TextSearch object, 'cause we passed our case parameter to it)
+
+ xub_StrLen nStart = 0, nEnd = (xub_StrLen)sCurrentCheck.getLength();
+ bFound = aLocalEngine.SearchFrwrd(sCurrentCheck, &nStart, &nEnd);
+ // das heisst hier 'forward' aber das bezieht sich nur auf die Suche innerhalb von sCurrentCheck, hat also mit
+ // der Richtung meines Datensatz-Durchwanderns nix zu tun (darum kuemmert sich MoveField)
+
+ // checken, ob die Position stimmt
+ if (bFound)
+ {
+ switch (m_nPosition)
+ {
+ case MATCHING_WHOLETEXT :
+ if (nEnd != sCurrentCheck.getLength())
+ {
+ bFound = false;
+ break;
+ }
+ // laeuft in den naechsten Case rein !
+ case MATCHING_BEGINNING :
+ if (nStart != 0)
+ bFound = false;
+ break;
+ case MATCHING_END :
+ if (nEnd != sCurrentCheck.getLength())
+ bFound = false;
+ break;
+ }
+ }
+
+ if (bFound) // immer noch ?
+ break;
+
+ // naechstes Feld (implizit naechster Datensatz, wenn noetig)
+ if (!MoveField(nFieldPos, iterFieldLoop, iterBegin, iterEnd))
+ { // beim Bewegen auf das naechste Feld ging was schief ... weitermachen ist nicht drin, da das naechste Mal genau
+ // das selbe bestimmt wieder schief geht, also Abbruch (ohne Fehlermeldung, von der erwarte ich, dass sie im Move
+ // angezeigt wurde)
+ // vorher aber noch, damit das Weitersuchen an der aktuellen Position weitermacht :
+ try { m_aPreviousLocBookmark = m_xSearchCursor.getBookmark(); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+ m_iterPreviousLocField = iterFieldLoop;
+ // und wech
+ return SR_ERROR;
+ }
+
+ Any aCurrentBookmark;
+ try { aCurrentBookmark = m_xSearchCursor.getBookmark(); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); return SR_ERROR; }
+ bMovedAround = EQUAL_BOOKMARKS(aStartMark, aCurrentBookmark) && (iterFieldLoop == iterInitialField);
+
+ if (nFieldPos == 0)
+ // das heisst, ich habe mich auf einen neuen Datensatz bewegt
+ PropagateProgress(bMovedAround);
+ // if we moved to the starting position we don't have to propagate an 'overflow' message
+ // FS - 07.12.99 - 68530
+
+ // abbrechen gefordert ?
+ if (CancelRequested())
+ return SR_CANCELED;
+
+ } while (!bMovedAround);
+
+ return bFound ? SR_FOUND : SR_NOTFOUND;
+}
+
+
+DBG_NAME(FmSearchEngine);
+//------------------------------------------------------------------------
+FmSearchEngine::FmSearchEngine(const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XResultSet > & xCursor, const ::rtl::OUString& sVisibleFields,
+ const Reference< XNumberFormatsSupplier > & xFormatSupplier, FMSEARCH_MODE eMode)
+
+ :m_xSearchCursor(xCursor)
+ ,m_xFormatSupplier(xFormatSupplier)
+ ,m_aCharacterClassficator( _rxORB, SvtSysLocale().GetLocaleData().getLocale() )
+ ,m_aStringCompare( _rxORB )
+ ,m_nCurrentFieldIndex(-2) // -1 hat schon eine Bedeutung, also nehme ich -2 fuer 'ungueltig'
+ ,m_bUsingTextComponents(sal_False)
+ ,m_eSearchForType(SEARCHFOR_STRING)
+ ,m_srResult(SR_FOUND)
+ ,m_bSearchingCurrently(sal_False)
+ ,m_bCancelAsynchRequest(sal_False)
+ ,m_eMode(eMode)
+ ,m_bFormatter(sal_False)
+ ,m_bForward(sal_False)
+ ,m_bWildcard(sal_False)
+ ,m_bRegular(sal_False)
+ ,m_bLevenshtein(sal_False)
+ ,m_bTransliteration(sal_False)
+ ,m_bLevRelaxed(sal_False)
+ ,m_nLevOther(0)
+ ,m_nLevShorter(0)
+ ,m_nLevLonger(0)
+ ,m_nPosition(MATCHING_ANYWHERE)
+ ,m_nTransliterationFlags(0)
+{
+ DBG_CTOR(FmSearchEngine,NULL);
+
+ m_xFormatter = Reference< ::com::sun::star::util::XNumberFormatter > (::comphelper::getProcessServiceFactory()
+ ->createInstance(FM_NUMBER_FORMATTER), UNO_QUERY);
+ if (m_xFormatter.is())
+ m_xFormatter->attachNumberFormatsSupplier(m_xFormatSupplier);
+
+ Init(sVisibleFields);
+}
+
+//------------------------------------------------------------------------
+FmSearchEngine::FmSearchEngine(const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XResultSet > & xCursor, const ::rtl::OUString& sVisibleFields,
+ const InterfaceArray& arrFields, FMSEARCH_MODE eMode)
+ :m_xSearchCursor(xCursor)
+ ,m_aCharacterClassficator( _rxORB, SvtSysLocale().GetLocaleData().getLocale() )
+ ,m_aStringCompare( _rxORB )
+ ,m_nCurrentFieldIndex(-2) // -1 hat schon eine Bedeutung, also nehme ich -2 fuer 'ungueltig'
+ ,m_bUsingTextComponents(sal_True)
+ ,m_xOriginalIterator(xCursor)
+ ,m_xClonedIterator(m_xOriginalIterator, sal_True)
+ ,m_eSearchForType(SEARCHFOR_STRING)
+ ,m_srResult(SR_FOUND)
+ ,m_bSearchingCurrently(sal_False)
+ ,m_bCancelAsynchRequest(sal_False)
+ ,m_eMode(eMode)
+ ,m_bFormatter(sal_True) // das muss konsistent sein mit m_xSearchCursor, der i.A. == m_xOriginalIterator ist
+ ,m_bForward(sal_False)
+ ,m_bWildcard(sal_False)
+ ,m_bRegular(sal_False)
+ ,m_bLevenshtein(sal_False)
+ ,m_bTransliteration(sal_False)
+ ,m_bLevRelaxed(sal_False)
+ ,m_nLevOther(0)
+ ,m_nLevShorter(0)
+ ,m_nLevLonger(0)
+ ,m_nPosition(MATCHING_ANYWHERE)
+ ,m_nTransliterationFlags(0)
+{
+ DBG_CTOR(FmSearchEngine,NULL);
+
+ fillControlTexts(arrFields);
+ Init(sVisibleFields);
+}
+
+//------------------------------------------------------------------------
+FmSearchEngine::~FmSearchEngine()
+{
+ clearControlTexts();
+
+ DBG_DTOR(FmSearchEngine,NULL);
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::SetIgnoreWidthCJK(sal_Bool bSet)
+{
+ if (bSet)
+ m_nTransliterationFlags |= TransliterationModules_IGNORE_WIDTH;
+ else
+ m_nTransliterationFlags &= ~TransliterationModules_IGNORE_WIDTH;
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmSearchEngine::GetIgnoreWidthCJK() const
+{
+ return 0 != (m_nTransliterationFlags & TransliterationModules_IGNORE_WIDTH);
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::SetCaseSensitive(sal_Bool bSet)
+{
+ if (bSet)
+ m_nTransliterationFlags &= ~TransliterationModules_IGNORE_CASE;
+ else
+ m_nTransliterationFlags |= TransliterationModules_IGNORE_CASE;
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmSearchEngine::GetCaseSensitive() const
+{
+ return 0 == (m_nTransliterationFlags & TransliterationModules_IGNORE_CASE);
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::clearControlTexts()
+{
+ for ( ControlTextSuppliersIterator aIter = m_aControlTexts.begin();
+ aIter < m_aControlTexts.end();
+ ++aIter
+ )
+ {
+ delete *aIter;
+ }
+ m_aControlTexts.clear();
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::fillControlTexts(const InterfaceArray& arrFields)
+{
+ clearControlTexts();
+ Reference< XInterface > xCurrent;
+ for (sal_uInt32 i=0; i<arrFields.size(); ++i)
+ {
+ xCurrent = arrFields.at(i);
+ DBG_ASSERT(xCurrent.is(), "FmSearchEngine::fillControlTexts : invalid field interface !");
+ // check which type of control this is
+ Reference< ::com::sun::star::awt::XTextComponent > xAsText(xCurrent, UNO_QUERY);
+ if (xAsText.is())
+ {
+ m_aControlTexts.insert(m_aControlTexts.end(), new SimpleTextWrapper(xAsText));
+ continue;
+ }
+
+ Reference< ::com::sun::star::awt::XListBox > xAsListBox(xCurrent, UNO_QUERY);
+ if (xAsListBox.is())
+ {
+ m_aControlTexts.insert(m_aControlTexts.end(), new ListBoxWrapper(xAsListBox));
+ continue;
+ }
+
+ Reference< ::com::sun::star::awt::XCheckBox > xAsCheckBox(xCurrent, UNO_QUERY);
+ DBG_ASSERT(xAsCheckBox.is(), "FmSearchEngine::fillControlTexts : invalid field interface (no supported type) !");
+ // we don't have any more options ...
+ m_aControlTexts.insert(m_aControlTexts.end(), new CheckBoxWrapper(xAsCheckBox));
+ }
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::Init(const ::rtl::OUString& sVisibleFields)
+{
+ // analyze the fields
+ // additionally, create the mapping: because the list of used columns can be shorter than the list
+ // of columns of the cursor, we need a mapping: "used column numer n" -> "cursor column m"
+ m_arrFieldMapping.Remove(0, m_arrFieldMapping.Count());
+
+ // important: The case of the columns does not need to be exact - for instance:
+ // - a user created a form which works on a table, for which the driver returns a column name "COLUMN"
+ // - the driver itself works case-insensitve with column names
+ // - a control in the form is bound to "column" - not the different case
+ // In such a scenario, the form and the field would work okay, but we here need to case for the different case
+ // explicitly
+ // 2003-01-09 - #i8755# - fs@openoffice.org
+
+ // so first of all, check if the database handles identifiers case sensitive
+ Reference< XConnection > xConn;
+ Reference< XDatabaseMetaData > xMeta;
+ Reference< XPropertySet > xCursorProps( IFACECAST( m_xSearchCursor ), UNO_QUERY );
+ if ( xCursorProps.is() )
+ {
+ try
+ {
+ xCursorProps->getPropertyValue( FM_PROP_ACTIVE_CONNECTION ) >>= xConn;
+ }
+ catch( Exception& ) { /* silent this - will be asserted below */ }
+ }
+ if ( xConn.is() )
+ xMeta = xConn->getMetaData();
+ OSL_ENSURE( xMeta.is(), "FmSearchEngine::Init: very strange cursor (could not derive connection meta data from it)!" );
+
+ sal_Bool bCaseSensitiveIdentifiers = sal_True; // assume case sensivity
+ if ( xMeta.is() )
+ bCaseSensitiveIdentifiers = xMeta->supportsMixedCaseQuotedIdentifiers();
+
+ // now that we have this information, we need a collator which is able to case (in)sentively compare strings
+ m_aStringCompare.loadDefaultCollator( SvtSysLocale().GetLocaleData().getLocale(),
+ bCaseSensitiveIdentifiers ? 0 : ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
+
+ try
+ {
+ // der Cursor kann mir einen Record (als PropertySet) liefern, dieser unterstuetzt den DatabaseRecord-Service
+ Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xSupplyCols(IFACECAST(m_xSearchCursor), UNO_QUERY);
+ DBG_ASSERT(xSupplyCols.is(), "FmSearchEngine::Init : invalid cursor (no columns supplier) !");
+ Reference< ::com::sun::star::container::XNameAccess > xAllFieldNames = xSupplyCols->getColumns();
+ Sequence< ::rtl::OUString > seqFieldNames = xAllFieldNames->getElementNames();
+ ::rtl::OUString* pFieldNames = seqFieldNames.getArray();
+
+
+ ::rtl::OUString sCurrentField;
+ UniString sVis(sVisibleFields.getStr());
+ xub_StrLen nLen = sVis.GetTokenCount();
+ for (xub_StrLen i=0; i<nLen; ++i)
+ {
+ sCurrentField = sVis.GetToken(i);
+
+ // in der Feld-Sammlung suchen
+ sal_Int32 nFoundIndex = -1;
+ for (sal_Int32 j=0; j<seqFieldNames.getLength(); ++j, ++pFieldNames)
+ {
+ if ( 0 == m_aStringCompare.compareString( *pFieldNames, sCurrentField ) )
+ {
+ nFoundIndex = j;
+ break;
+ }
+ }
+ // set the field selection back to the first
+ pFieldNames = seqFieldNames.getArray();;
+ DBG_ASSERT(nFoundIndex != -1, "FmSearchEngine::Init : Es wurden ungueltige Feldnamen angegeben !");
+ m_arrFieldMapping.Insert(nFoundIndex, m_arrFieldMapping.Count());
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("Exception occured!");
+ }
+
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::SetFormatterUsing(sal_Bool bSet)
+{
+ if (m_bFormatter == bSet)
+ return;
+ m_bFormatter = bSet;
+
+ if (m_bUsingTextComponents)
+ {
+ // ich benutzte keinen Formatter, sondern TextComponents -> der SearchIterator muss angepasst werden
+ try
+ {
+ if (m_bFormatter)
+ {
+ DBG_ASSERT(m_xSearchCursor == m_xClonedIterator, "FmSearchEngine::SetFormatterUsing : inkonsistenter Zustand !");
+ m_xSearchCursor = m_xOriginalIterator;
+ m_xSearchCursor.moveToBookmark(m_xClonedIterator.getBookmark());
+ // damit ich mit dem neuen Iterator wirklich dort weitermache, wo ich vorher aufgehoert habe
+ }
+ else
+ {
+ DBG_ASSERT(m_xSearchCursor == m_xOriginalIterator, "FmSearchEngine::SetFormatterUsing : inkonsistenter Zustand !");
+ m_xSearchCursor = m_xClonedIterator;
+ m_xSearchCursor.moveToBookmark(m_xOriginalIterator.getBookmark());
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // ich muss die Fields neu binden, da der Textaustausch eventuell ueber diese Fields erfolgt und sich der unterliegende Cursor
+ // geaendert hat
+ RebuildUsedFields(m_nCurrentFieldIndex, sal_True);
+ }
+ else
+ InvalidatePreviousLoc();
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::PropagateProgress(sal_Bool _bDontPropagateOverflow)
+{
+ if (m_aProgressHandler.IsSet())
+ {
+ FmSearchProgress aProgress;
+ try
+ {
+ aProgress.aSearchState = FmSearchProgress::STATE_PROGRESS;
+ aProgress.nCurrentRecord = m_xSearchCursor.getRow() - 1;
+ if (m_bForward)
+ aProgress.bOverflow = !_bDontPropagateOverflow && m_xSearchCursor.isFirst();
+ else
+ aProgress.bOverflow = !_bDontPropagateOverflow && m_xSearchCursor.isLast();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_aProgressHandler.Call(&aProgress);
+ }
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::SearchNextImpl()
+{
+ DBG_ASSERT(!(m_bWildcard && m_bRegular) && !(m_bRegular && m_bLevenshtein) && !(m_bLevenshtein && m_bWildcard),
+ "FmSearchEngine::SearchNextImpl : Suchparameter schliessen sich gegenseitig aus !");
+
+ DBG_ASSERT(m_xSearchCursor.is(), "FmSearchEngine::SearchNextImpl : habe ungueltigen Iterator !");
+
+ // die Parameter der Suche
+ ::rtl::OUString strSearchExpression(m_strSearchExpression); // brauche ich non-const
+ if (!GetCaseSensitive())
+ // norm the string
+ m_aCharacterClassficator.toLower_rtl(strSearchExpression);
+
+ if (!m_bRegular && !m_bLevenshtein)
+ { // 'normale' Suche fuehre ich auf jeden Fall ueber WildCards durch, muss aber vorher je nach Modus den ::rtl::OUString anpassen
+
+ if (!m_bWildcard)
+ { // da natuerlich in allen anderen Faellen auch * und ? im Suchstring erlaubt sind, aber nicht als WildCards zaehlen
+ // sollen, muss ich normieren
+ UniString aTmp(strSearchExpression.getStr());
+ static const UniString s_sStar = UniString::CreateFromAscii("\\*");
+ static const UniString s_sQuotation = UniString::CreateFromAscii("\\?");
+ aTmp.SearchAndReplaceAll('*', s_sStar);
+ aTmp.SearchAndReplaceAll('?', s_sQuotation);
+ strSearchExpression = aTmp;
+
+ switch (m_nPosition)
+ {
+ case MATCHING_ANYWHERE :
+ strSearchExpression = ::rtl::OUString::createFromAscii("*") + strSearchExpression
+ + ::rtl::OUString::createFromAscii("*");
+ break;
+ case MATCHING_BEGINNING :
+ strSearchExpression = strSearchExpression + ::rtl::OUString::createFromAscii("*");
+ break;
+ case MATCHING_END :
+ strSearchExpression = ::rtl::OUString::createFromAscii("*") + strSearchExpression;
+ break;
+ case MATCHING_WHOLETEXT :
+ break;
+ default :
+ DBG_ERROR("FmSearchEngine::SearchNextImpl() : die Methoden-Listbox duerfte nur 4 Eintraege enthalten ...");
+ }
+ }
+ }
+
+ // fuer Arbeit auf Feldliste
+ FieldCollectionIterator iterBegin = m_arrUsedFields.begin();
+ FieldCollectionIterator iterEnd = m_arrUsedFields.end();
+ FieldCollectionIterator iterFieldCheck;
+
+ sal_Int32 nFieldPos;
+
+ if (HasPreviousLoc())
+ {
+ DBG_ASSERT(EQUAL_BOOKMARKS(m_aPreviousLocBookmark, m_xSearchCursor.getBookmark()),
+ "FmSearchEngine::SearchNextImpl : ungueltige Position !");
+ iterFieldCheck = m_iterPreviousLocField;
+ // im Feld nach (oder vor) der letzten Fundstelle weitermachen
+ nFieldPos = iterFieldCheck - iterBegin;
+ MoveField(nFieldPos, iterFieldCheck, iterBegin, iterEnd);
+ }
+ else
+ {
+ if (m_bForward)
+ iterFieldCheck = iterBegin;
+ else
+ {
+ iterFieldCheck = iterEnd;
+ --iterFieldCheck;
+ }
+ nFieldPos = iterFieldCheck - iterBegin;
+ }
+
+ PropagateProgress(sal_True);
+ SEARCH_RESULT srResult;
+ if (m_eSearchForType != SEARCHFOR_STRING)
+ srResult = SearchSpecial(m_eSearchForType == SEARCHFOR_NULL, nFieldPos, iterFieldCheck, iterBegin, iterEnd);
+ else if (!m_bRegular && !m_bLevenshtein)
+ srResult = SearchWildcard(strSearchExpression, nFieldPos, iterFieldCheck, iterBegin, iterEnd);
+ else
+ srResult = SearchRegularApprox(strSearchExpression, nFieldPos, iterFieldCheck, iterBegin, iterEnd);
+
+ m_srResult = srResult;
+
+ if (SR_ERROR == m_srResult)
+ return;
+
+ // gefunden ?
+ if (SR_FOUND == m_srResult)
+ {
+ // die Pos merken
+ try { m_aPreviousLocBookmark = m_xSearchCursor.getBookmark(); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+ m_iterPreviousLocField = iterFieldCheck;
+ }
+ else
+ // die "letzte Fundstelle" invalidieren
+ InvalidatePreviousLoc();
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK(FmSearchEngine, OnSearchTerminated, FmSearchThread*, /*pThread*/)
+{
+ if (!m_aProgressHandler.IsSet())
+ return 0L;
+
+ FmSearchProgress aProgress;
+ try
+ {
+ switch (m_srResult)
+ {
+ case SR_ERROR :
+ aProgress.aSearchState = FmSearchProgress::STATE_ERROR;
+ break;
+ case SR_FOUND :
+ aProgress.aSearchState = FmSearchProgress::STATE_SUCCESSFULL;
+ aProgress.aBookmark = m_aPreviousLocBookmark;
+ aProgress.nFieldIndex = m_iterPreviousLocField - m_arrUsedFields.begin();
+ break;
+ case SR_NOTFOUND :
+ aProgress.aSearchState = FmSearchProgress::STATE_NOTHINGFOUND;
+ aProgress.aBookmark = m_xSearchCursor.getBookmark();
+ break;
+ case SR_CANCELED :
+ aProgress.aSearchState = FmSearchProgress::STATE_CANCELED;
+ aProgress.aBookmark = m_xSearchCursor.getBookmark();
+ break;
+ }
+ aProgress.nCurrentRecord = m_xSearchCursor.getRow() - 1;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // per definitionem muss der Link Thread-sicher sein (das verlange ich einfach), so dass ich mich um so etwas hier nicht kuemmern muss
+ m_aProgressHandler.Call(&aProgress);
+
+ m_bSearchingCurrently = sal_False;
+ return 0L;
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK(FmSearchEngine, OnNewRecordCount, void*, pCounterAsVoid)
+{
+ if (!m_aProgressHandler.IsSet())
+ return 0L;
+
+ FmSearchProgress aProgress;
+ aProgress.nCurrentRecord = (sal_uIntPtr)pCounterAsVoid;
+ aProgress.aSearchState = FmSearchProgress::STATE_PROGRESS_COUNTING;
+ m_aProgressHandler.Call(&aProgress);
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmSearchEngine::CancelRequested()
+{
+ m_aCancelAsynchAccess.acquire();
+ sal_Bool bReturn = m_bCancelAsynchRequest;
+ m_aCancelAsynchAccess.release();
+ return bReturn;
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::CancelSearch()
+{
+ m_aCancelAsynchAccess.acquire();
+ m_bCancelAsynchRequest = sal_True;
+ m_aCancelAsynchAccess.release();
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmSearchEngine::SwitchToContext(const Reference< ::com::sun::star::sdbc::XResultSet > & xCursor, const ::rtl::OUString& sVisibleFields, const InterfaceArray& arrFields,
+ sal_Int32 nFieldIndex)
+{
+ DBG_ASSERT(!m_bSearchingCurrently, "FmSearchEngine::SwitchToContext : please do not call while I'm searching !");
+ if (m_bSearchingCurrently)
+ return sal_False;
+
+ m_xSearchCursor = xCursor;
+ m_xOriginalIterator = xCursor;
+ m_xClonedIterator = CursorWrapper(m_xOriginalIterator, sal_True);
+ m_bUsingTextComponents = sal_True;
+
+ fillControlTexts(arrFields);
+
+ Init(sVisibleFields);
+ RebuildUsedFields(nFieldIndex, sal_True);
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::ImplStartNextSearch()
+{
+ m_bCancelAsynchRequest = sal_False;
+ m_bSearchingCurrently = sal_True;
+
+ if (m_eMode == SM_USETHREAD)
+ {
+ FmSearchThread* pSearcher = new FmSearchThread(this);
+ // der loescht sich nach Beendigung selber ...
+ pSearcher->setTerminationHandler(LINK(this, FmSearchEngine, OnSearchTerminated));
+
+ pSearcher->createSuspended();
+ pSearcher->setPriority(osl_Thread_PriorityLowest);
+ pSearcher->resume();
+ }
+ else
+ {
+ SearchNextImpl();
+ LINK(this, FmSearchEngine, OnSearchTerminated).Call(NULL);
+ }
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::SearchNext(const ::rtl::OUString& strExpression)
+{
+ m_strSearchExpression = strExpression;
+ m_eSearchForType = SEARCHFOR_STRING;
+ ImplStartNextSearch();
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::SearchNextSpecial(sal_Bool _bSearchForNull)
+{
+ m_eSearchForType = _bSearchForNull ? SEARCHFOR_NULL : SEARCHFOR_NOTNULL;
+ ImplStartNextSearch();
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::StartOver(const ::rtl::OUString& strExpression)
+{
+ try
+ {
+ if (m_bForward)
+ m_xSearchCursor.first();
+ else
+ m_xSearchCursor.last();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return;
+ }
+
+ InvalidatePreviousLoc();
+ SearchNext(strExpression);
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::StartOverSpecial(sal_Bool _bSearchForNull)
+{
+ try
+ {
+ if (m_bForward)
+ m_xSearchCursor.first();
+ else
+ m_xSearchCursor.last();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return;
+ }
+
+ InvalidatePreviousLoc();
+ SearchNextSpecial(_bSearchForNull);
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::InvalidatePreviousLoc()
+{
+ m_aPreviousLocBookmark.setValue(0,getVoidCppuType());
+ m_iterPreviousLocField = m_arrUsedFields.end();
+}
+
+//------------------------------------------------------------------------
+void FmSearchEngine::RebuildUsedFields(sal_Int32 nFieldIndex, sal_Bool bForce)
+{
+ if (!bForce && (nFieldIndex == m_nCurrentFieldIndex))
+ return;
+ // (da ich keinen Wechsel des Iterators von aussen zulasse, heisst selber ::com::sun::star::sdbcx::Index auch immer selbe Spalte, also habe ich nix zu tun)
+
+ DBG_ASSERT((nFieldIndex >= -1) && (nFieldIndex<m_arrFieldMapping.Count()), "FmSearchEngine::RebuildUsedFields : nFieldIndex ist ungueltig !");
+ // alle Felder, die ich durchsuchen muss, einsammeln
+ m_arrUsedFields.clear();
+ if (nFieldIndex == -1)
+ {
+ Reference< ::com::sun::star::container::XIndexAccess > xFields;
+ for (sal_uInt16 i=0; i<m_arrFieldMapping.Count(); ++i)
+ {
+ Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xSupplyCols(IFACECAST(m_xSearchCursor), UNO_QUERY);
+ DBG_ASSERT(xSupplyCols.is(), "FmSearchEngine::RebuildUsedFields : invalid cursor (no columns supplier) !");
+ xFields = Reference< ::com::sun::star::container::XIndexAccess > (xSupplyCols->getColumns(), UNO_QUERY);
+ BuildAndInsertFieldInfo(xFields, m_arrFieldMapping.GetObject(i));
+ }
+ }
+ else
+ {
+ Reference< ::com::sun::star::container::XIndexAccess > xFields;
+ Reference< ::com::sun::star::sdbcx::XColumnsSupplier > xSupplyCols(IFACECAST(m_xSearchCursor), UNO_QUERY);
+ DBG_ASSERT(xSupplyCols.is(), "FmSearchEngine::RebuildUsedFields : invalid cursor (no columns supplier) !");
+ xFields = Reference< ::com::sun::star::container::XIndexAccess > (xSupplyCols->getColumns(), UNO_QUERY);
+ BuildAndInsertFieldInfo(xFields, m_arrFieldMapping.GetObject((sal_uInt16)nFieldIndex));
+ }
+
+ m_nCurrentFieldIndex = nFieldIndex;
+ // und natuerlich beginne ich die naechste Suche wieder jungfraeulich
+ InvalidatePreviousLoc();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmstring.src b/svx/source/form/fmstring.src
new file mode 100644
index 000000000000..89771f126b53
--- /dev/null
+++ b/svx/source/form/fmstring.src
@@ -0,0 +1,491 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "fmresids.hrc"
+/* Strings fuer Uebersetzung */
+String RID_ERR_CONTEXT_ADDFORM
+{
+ Text [ en-US ] = "Error while creating form";
+};
+String RID_ERR_FIELDREQUIRED
+{
+ Text [ en-US ] = "Input required in field '#'. Please enter a value.";
+};
+String RID_ERR_DUPLICATE_NAME
+{
+ Text [ en-US ] = "Entry already exists.\nPlease choose another name.";
+};
+String RID_STR_FORMS
+{
+ Text [ en-US ] = "Forms";
+};
+String RID_STR_NO_PROPERTIES
+{
+ Text [ en-US ] = "No control selected";
+};
+String RID_STR_PROPERTIES_CONTROL
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Eigenschaften: : Kontrollelement Eigenschaften */
+ Text [ en-US ] = "Properties: ";
+};
+String RID_STR_PROPERTIES_FORM
+{
+ Text [ en-US ] = "Form Properties";
+};
+String RID_STR_FMEXPLORER
+{
+ Text [ en-US ] = "Form Navigator";
+};
+String RID_STR_FORM
+{
+ Text [ en-US ] = "Form";
+};
+Resource RID_RSC_TABWIN_PREFIX
+{
+ String 1
+ {
+ Text [ en-US ] = "Table";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Query";
+ };
+ String 3
+ {
+ Text [ en-US ] = "SQL";
+ };
+};
+String RID_STR_FORMSHELL
+{
+ Text = "Form Shell";
+};
+String RID_STR_STDFORMNAME
+{
+ Text [ en-US ]= "Form";
+};
+String RID_STR_PROPTITLE_HIDDEN
+{
+ Text [ en-US ] = "Hidden Control";
+};
+String RID_STR_CONTROL
+{
+ Text [ en-US ] = "Control";
+};
+String RID_STR_REC_TEXT
+{
+ Text [ en-US ] = "Record";
+};
+String RID_STR_REC_FROM_TEXT
+{
+ Text [ en-US ] = "of";
+};
+String RID_STR_FIELDSELECTION
+{
+ Text [ en-US ] = "Add field:";
+};
+String RID_STR_WRITEERROR
+{
+ Text [ en-US ] = "Error writing data to database";
+};
+
+String RID_STR_SYNTAXERROR
+{
+ Text [ en-US ] = "Syntax error in query expression";
+};
+
+String RID_STR_DELETECONFIRM_RECORD
+{
+ Text [ en-US ] = "You intend to delete 1 record.";
+};
+String RID_STR_DELETECONFIRM_RECORDS
+{
+ Text [ en-US ] = "# records will be deleted.";
+};
+String RID_STR_DELETECONFIRM
+{
+ Text [ en-US ] = "If you click Yes, you won't be able to undo this operation.\nDo you want to continue anyway?";
+};
+
+String RID_ERR_NO_ELEMENT
+{
+ Text [ en-US ] = "Choose an entry from the list or enter a text corresponding to one of the list items.";
+};
+String RID_STR_GROUPBOX
+{
+ Text [ en-US ] = "Frame element";
+};
+String RID_STR_NAVIGATION
+{
+ Text [ en-US ] = "Navigation";
+};
+String RID_STR_NAVIGATIONBAR
+{
+ Text [ en-US ] = "Navigation bar";
+};
+String RID_STR_COLUMN
+{
+ Text [ en-US ] = "Col";
+};
+String RID_STR_UNDO_PROPERTY
+{
+ Text [ en-US ] = "Set property '#'";
+};
+String RID_STR_UNDO_CONTAINER_INSERT
+{
+ Text [ en-US ] = "Insert in container";
+};
+String RID_STR_UNDO_CONTAINER_REMOVE
+{
+ Text [ en-US ] = "Delete #";
+};
+String RID_STR_UNDO_CONTAINER_REMOVE_MULTIPLE
+{
+ Text [ en-US ] = "Delete # objects";
+};
+String RID_STR_UNDO_CONTAINER_REPLACE
+{
+ Text [ en-US ] = "Replace a container element";
+};
+String RID_STR_UNDO_DELETE_LOGICAL
+{
+ Text [ en-US ] = "Delete structure";
+};
+String RID_STR_UNDO_MODEL_REPLACE
+{
+ Text [ en-US ] = "Replace Control";
+};
+String RID_STR_DATE
+{
+ Text [ en-US ] = "Date";
+};
+String RID_STR_TIME
+{
+ Text [ en-US ] = "Time";
+};
+String RID_STR_PROPTITLE_PUSHBUTTON
+{
+ Text [ en-US ] = "Push Button";
+};
+String RID_STR_PROPTITLE_RADIOBUTTON
+{
+ Text [ en-US ] = "Option Button";
+};
+String RID_STR_PROPTITLE_CHECKBOX
+{
+ Text [ en-US ] = "Check Box";
+};
+String RID_STR_PROPTITLE_FIXEDTEXT
+{
+ Text [ en-US ] = "Label Field";
+};
+String RID_STR_PROPTITLE_GROUPBOX
+{
+ Text [ en-US ] = "Group Box";
+};
+String RID_STR_PROPTITLE_EDIT
+{
+ Text [ en-US ] = "Text Box";
+};
+String RID_STR_PROPTITLE_FORMATTED
+{
+ Text [ en-US ] = "Formatted Field";
+};
+String RID_STR_PROPTITLE_LISTBOX
+{
+ Text [ en-US ] = "List Box";
+};
+String RID_STR_PROPTITLE_COMBOBOX
+{
+ Text [ en-US ] = "Combo Box";
+};
+String RID_STR_PROPTITLE_IMAGEBUTTON
+{
+ Text [ en-US ] = "Image Button";
+};
+String RID_STR_PROPTITLE_IMAGECONTROL
+{
+ Text [ en-US ] = "Image Control";
+};
+String RID_STR_PROPTITLE_FILECONTROL
+{
+ Text [ en-US ] = "File Selection";
+};
+String RID_STR_PROPTITLE_DATEFIELD
+{
+ Text [ en-US ] = "Date Field";
+};
+String RID_STR_PROPTITLE_TIMEFIELD
+{
+ Text [ en-US ] = "Time Field";
+};
+String RID_STR_PROPTITLE_NUMERICFIELD
+{
+ Text [ en-US ] = "Numeric Field";
+};
+String RID_STR_PROPTITLE_CURRENCYFIELD
+{
+ Text [ en-US ] = "Currency Field";
+};
+String RID_STR_PROPTITLE_PATTERNFIELD
+{
+ Text [ en-US ] = "Pattern Field";
+};
+String RID_STR_PROPTITLE_DBGRID
+{
+ Text [ en-US ] = "Table Control ";
+};
+String RID_STR_PROPTITLE_SCROLLBAR
+{
+ Text [ en-US ] = "Scrollbar";
+};
+String RID_STR_PROPTITLE_SPINBUTTON
+{
+ Text [ en-US ] = "Spin Button";
+};
+String RID_STR_PROPTITLE_NAVBAR
+{
+ Text [ en-US ] = "Navigation Bar";
+};
+String RID_STR_PROPTITLE_MULTISELECT
+{
+ Text [ en-US ] = "Multiselection";
+};
+String RID_STR_NODATACONTROLS
+{
+ Text [ en-US ] = "No data-related controls in the current form!";
+};
+String RID_STR_POSTFIX_DATE
+{
+ Text [ en-US ] = " (Date)";
+};
+String RID_STR_POSTFIX_TIME
+{
+ Text [ en-US ] = " (Time)";
+};
+String RID_STR_FILTER_NAVIGATOR
+{
+ Text [ en-US ] = "Filter navigator";
+};
+
+String RID_STR_FILTER_FILTER_FOR
+{
+ Text [ en-US ] = "Filter for";
+};
+
+String RID_STR_FILTER_FILTER_OR
+{
+ Text [ en-US ] = "Or";
+};
+
+String RID_STR_NOCONTROLS_FOR_EXTERNALDISPLAY
+{
+ Text [ en-US ] = "Valid bound controls which can be used in the table view do not exist in the current form.";
+};
+String RID_STR_AUTOFIELD
+{
+ Text [ en-US ] = "<AutoField>";
+};
+
+QueryBox RID_QRY_SAVEMODIFIED
+{
+ Buttons = WB_YES_NO_CANCEL ;
+ DefButton = WB_DEF_YES ;
+ Message [ en-US ] = "The content of the current form has been modified.\nDo you want to save your changes?";
+};
+Resource RID_RSC_SQL_INTERNATIONAL
+{
+ String 1
+ {
+ Text [ en-US ] = "LIKE";
+ };
+ String 2
+ {
+ Text [ en-US ] = "NOT";
+ };
+ String 3
+ {
+ Text [ en-US ] = "EMPTY";
+ };
+ String 4
+ {
+ Text [ en-US ] = "TRUE";
+ };
+ String 5
+ {
+ Text [ en-US ] = "FALSE";
+ };
+ String 6
+ {
+ Text [ en-US ] = "IS";
+ };
+ String 7
+ {
+ Text [ en-US ] = "BETWEEN";
+ };
+ String 8
+ {
+ Text [ en-US ] = "OR";
+ };
+ String 9
+ {
+ Text [ en-US ] = "AND";
+ };
+ String 10
+ {
+ Text [ en-US ] = "Average";
+ };
+ String 11
+ {
+ Text [ en-US ] = "Count";
+ };
+ String 12
+ {
+ Text [ en-US ] = "Maximum";
+ };
+ String 13
+ {
+ Text [ en-US ] = "Minimum";
+ };
+ String 14
+ {
+ Text [ en-US ] = "Sum";
+ };
+ String 15
+ {
+ Text [ en-US ] = "Every";
+ };
+ String 16
+ {
+ Text [ en-US ] = "Any";
+ };
+ String 17
+ {
+ Text [ en-US ] = "Some";
+ };
+ String 18
+ {
+ Text [ en-US ] = "STDDEV_POP";
+ };
+ String 19
+ {
+ Text [ en-US ] = "STDDEV_SAMP";
+ };
+ String 20
+ {
+ Text [ en-US ] = "VAR_SAMP";
+ };
+ String 21
+ {
+ Text [ en-US ] = "VAR_POP";
+ };
+ String 22
+ {
+ Text [ en-US ] = "Collect";
+ };
+ String 23
+ {
+ Text [ en-US ] = "Fusion";
+ };
+ String 24
+ {
+ Text [ en-US ] = "Intersection";
+ };
+};
+
+String RID_STR_SVT_SQL_SYNTAX_ERROR
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Syntaxfehler im SQL-Ausdruck : Fehlerhafte Syntax */
+ Text [ en-US ] = "Syntax error in SQL statement";
+};
+
+String RID_STR_SVT_SQL_SYNTAX_VALUE_NO_LIKE
+{
+ Text [ en-US ] = "The value #1 cannot be used with LIKE.";
+};
+
+String RID_STR_SVT_SQL_SYNTAX_FIELD_NO_LIKE
+{
+ Text [ en-US ] = "LIKE cannot be used with this field.";
+};
+
+String RID_STR_SVT_SQL_SYNTAX_ACCESS_DAT_NO_VALID
+{
+ Text [ en-US ] = "The value entered is not a valid date. Please enter a date in a valid format, for example, MM/DD/YY.";
+};
+
+String RID_STR_SVT_SQL_SYNTAX_INT_NO_VALID
+{
+ Text [ en-US ] = "The field cannot be compared with an integer.";
+};
+String RID_STR_SVT_SQL_SYNTAX_TABLE
+{
+ Text [ en-US ] = "The database does not contain a table named \"#\".";
+};
+String RID_STR_SVT_SQL_SYNTAX_TABLE_OR_QUERY
+{
+ Text [ en-US ] = "The database does contain neither a table nor a query named \"#\".";
+};
+String RID_STR_SVT_SQL_SYNTAX_TABLE_EXISTS
+{
+ Text [ en-US ] = "The database already contains a table or view with name \"#\".";
+};
+String RID_STR_SVT_SQL_SYNTAX_QUERY_EXISTS
+{
+ Text [ en-US ] = "The database already contains a query with name \"#\".";
+};
+String RID_STR_SVT_SQL_SYNTAX_COLUMN
+{
+ Text [ en-US ] = "The column \"#1\" is unknown in the table \"#2\".";
+};
+String RID_STR_SVT_SQL_SYNTAX_REAL_NO_VALID
+{
+ Text [ en-US ] = "The field cannot be compared with a floating point number.";
+};
+
+String RID_STR_SVT_SQL_SYNTAX_CRIT_NO_COMPARE
+{
+ Text [ en-US ] = "The entered criterion cannot be compared with this field.";
+};
+
+String RID_STR_DATANAVIGATOR
+{
+ Text [ en-US ] = "Data Navigator";
+};
+
+String RID_STR_READONLY_VIEW
+{
+ Text [ en-US ] = " (read-only)";
+};
+
+String RID_STR_ALREADYEXISTOVERWRITE
+{
+ Text [ en-US ] = "The file already exists. Overwrite?" ;
+};
+String RID_STR_OBJECT_LABEL
+{
+ Text [ en-US ] = "#object# label";
+};
diff --git a/svx/source/form/fmtextcontroldialogs.cxx b/svx/source/form/fmtextcontroldialogs.cxx
new file mode 100644
index 000000000000..c725eb4554ba
--- /dev/null
+++ b/svx/source/form/fmtextcontroldialogs.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "fmtextcontroldialogs.hxx"
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+
+#include <editeng/eeitem.hxx>
+
+#include "flagsdef.hxx"
+#include <svl/intitem.hxx>
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <svl/cjkoptions.hxx>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ //====================================================================
+ //= TextControlCharAttribDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ TextControlCharAttribDialog::TextControlCharAttribDialog( Window* pParent, const SfxItemSet& _rCoreSet, const SvxFontListItem& _rFontList )
+ :SfxTabDialog( pParent, SVX_RES( RID_SVXDLG_TEXTCONTROL_CHARATTR ), &_rCoreSet )
+ ,m_aFontList( _rFontList )
+ {
+ FreeResource();
+
+ AddTabPage( RID_SVXPAGE_CHAR_NAME);
+ AddTabPage( RID_SVXPAGE_CHAR_EFFECTS);
+ AddTabPage( RID_SVXPAGE_CHAR_POSITION);
+ }
+
+ //--------------------------------------------------------------------
+ TextControlCharAttribDialog::~TextControlCharAttribDialog()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void TextControlCharAttribDialog::PageCreated( USHORT _nId, SfxTabPage& _rPage )
+ {
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+
+ switch( _nId )
+ {
+ case RID_SVXPAGE_CHAR_NAME:
+ aSet.Put (m_aFontList);
+ _rPage.PageCreated(aSet);
+ break;
+
+ case RID_SVXPAGE_CHAR_EFFECTS:
+ aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP));
+ _rPage.PageCreated(aSet);
+ break;
+
+ case RID_SVXPAGE_CHAR_POSITION:
+ aSet.Put( SfxUInt32Item(SID_FLAG_TYPE, SVX_PREVIEW_CHARACTER) );
+ _rPage.PageCreated(aSet);
+ break;
+ }
+ }
+
+ //====================================================================
+ //= TextControlParaAttribDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ TextControlParaAttribDialog::TextControlParaAttribDialog( Window* _pParent, const SfxItemSet& _rCoreSet )
+ :SfxTabDialog( _pParent, SVX_RES( RID_SVXDLG_TEXTCONTROL_PARAATTR ), &_rCoreSet )
+ {
+ FreeResource();
+
+ AddTabPage( RID_SVXPAGE_STD_PARAGRAPH );
+ AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );
+
+ SvtCJKOptions aCJKOptions;
+ if( aCJKOptions.IsAsianTypographyEnabled() )
+ AddTabPage( RID_SVXPAGE_PARA_ASIAN );
+ else
+ RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
+
+ AddTabPage( RID_SVXPAGE_TABULATOR );
+ }
+
+ //--------------------------------------------------------------------
+ TextControlParaAttribDialog::~TextControlParaAttribDialog()
+ {
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmtextcontrolfeature.cxx b/svx/source/form/fmtextcontrolfeature.cxx
new file mode 100644
index 000000000000..1bf8ea49efda
--- /dev/null
+++ b/svx/source/form/fmtextcontrolfeature.cxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "fmtextcontrolfeature.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::util;
+
+ //====================================================================
+ //= FmTextControlFeature
+ //====================================================================
+ //--------------------------------------------------------------------
+ FmTextControlFeature::FmTextControlFeature( const Reference< XDispatch >& _rxDispatcher, const URL& _rFeatureURL, SfxSlotId _nSlotId, ISlotInvalidator* _pInvalidator )
+ :m_xDispatcher ( _rxDispatcher )
+ ,m_aFeatureURL ( _rFeatureURL )
+ ,m_nSlotId ( _nSlotId )
+ ,m_pInvalidator ( _pInvalidator )
+ ,m_bFeatureEnabled( false )
+ {
+ OSL_ENSURE( _rxDispatcher.is(), "FmTextControlFeature::FmTextControlFeature: invalid dispatcher!" );
+ OSL_ENSURE( m_nSlotId, "FmTextControlFeature::FmTextControlFeature: invalid slot id!" );
+ OSL_ENSURE( m_pInvalidator, "FmTextControlFeature::FmTextControlFeature: invalid invalidator!" );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ try
+ {
+ m_xDispatcher->addStatusListener( this, m_aFeatureURL );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmTextControlFeature::FmTextControlFeature: caught an exception!" );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ FmTextControlFeature::~FmTextControlFeature( )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void FmTextControlFeature::dispatch() const SAL_THROW(())
+ {
+ dispatch( Sequence< PropertyValue >( ) );
+ }
+
+ //--------------------------------------------------------------------
+ void FmTextControlFeature::dispatch( const Sequence< PropertyValue >& _rArgs ) const SAL_THROW(())
+ {
+ try
+ {
+ if ( m_xDispatcher.is() )
+ m_xDispatcher->dispatch( m_aFeatureURL, _rArgs );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmTextControlFeature::dispatch: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FmTextControlFeature::statusChanged( const FeatureStateEvent& _rState ) throw (RuntimeException)
+ {
+ m_aFeatureState = _rState.State;
+ m_bFeatureEnabled = _rState.IsEnabled;
+
+ if ( m_pInvalidator )
+ m_pInvalidator->Invalidate( m_nSlotId );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FmTextControlFeature::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
+ {
+ // nothing to do
+ }
+
+ //--------------------------------------------------------------------
+ void FmTextControlFeature::dispose() SAL_THROW(())
+ {
+ try
+ {
+ m_xDispatcher->removeStatusListener( this, m_aFeatureURL );
+ m_xDispatcher.clear();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmTextControlFeature::dispose: caught an exception!" );
+ }
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx
new file mode 100644
index 000000000000..e66820a11b7d
--- /dev/null
+++ b/svx/source/form/fmtextcontrolshell.cxx
@@ -0,0 +1,1401 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmprop.hrc"
+#include "fmresids.hrc"
+#include "fmtextcontroldialogs.hxx"
+#include "fmtextcontrolfeature.hxx"
+#include "fmtextcontrolshell.hxx"
+#include "editeng/crsditem.hxx"
+#include "svx/dialmgr.hxx"
+#include "editeng/editeng.hxx"
+#include "editeng/eeitem.hxx"
+#include "svx/fmglob.hxx"
+#include "editeng/scriptspaceitem.hxx"
+#include "svx/svxids.hrc"
+#include "editeng/udlnitem.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/awt/XMouseListener.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/msgpool.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/sfxuno.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/itempool.hxx>
+#include <svl/languageoptions.hxx>
+#include <svtools/stringtransfer.hxx>
+#include <svl/whiter.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/msgbox.hxx>
+#include <vcl/outdev.hxx>
+#include <osl/mutex.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::form::runtime;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+
+ //====================================================================
+ typedef USHORT WhichId;
+
+ //====================================================================
+ static SfxSlotId pTextControlSlots[] =
+ {
+ SID_CLIPBOARD_FORMAT_ITEMS,
+ SID_CUT,
+ SID_COPY,
+ SID_PASTE,
+ SID_SELECTALL,
+// SID_ATTR_TABSTOP, /* 2 */
+ SID_ATTR_CHAR_FONT,
+ SID_ATTR_CHAR_POSTURE,
+ SID_ATTR_CHAR_WEIGHT,
+ SID_ATTR_CHAR_SHADOWED,
+ SID_ATTR_CHAR_WORDLINEMODE,
+ SID_ATTR_CHAR_CONTOUR,
+ SID_ATTR_CHAR_STRIKEOUT,
+ SID_ATTR_CHAR_UNDERLINE,
+ SID_ATTR_CHAR_FONTHEIGHT,
+ SID_ATTR_CHAR_COLOR,
+ SID_ATTR_CHAR_KERNING,
+ SID_ATTR_CHAR_LANGUAGE, /* 20 */
+ SID_ATTR_CHAR_ESCAPEMENT,
+ SID_ATTR_PARA_ADJUST, /* 28 */
+ SID_ATTR_PARA_ADJUST_LEFT,
+ SID_ATTR_PARA_ADJUST_RIGHT,
+ SID_ATTR_PARA_ADJUST_CENTER,
+ SID_ATTR_PARA_ADJUST_BLOCK,
+ SID_ATTR_PARA_LINESPACE, /* 33 */
+ SID_ATTR_PARA_LINESPACE_10,
+ SID_ATTR_PARA_LINESPACE_15,
+ SID_ATTR_PARA_LINESPACE_20,
+ SID_ATTR_LRSPACE, /* 48 */
+ SID_ATTR_ULSPACE, /* 49 */
+ SID_ATTR_CHAR_AUTOKERN,
+ SID_SET_SUPER_SCRIPT,
+ SID_SET_SUB_SCRIPT,
+ SID_CHAR_DLG,
+ SID_PARA_DLG,
+// SID_TEXTDIRECTION_LEFT_TO_RIGHT, /* 907 */
+// SID_TEXTDIRECTION_TOP_TO_BOTTOM,
+ SID_ATTR_CHAR_SCALEWIDTH, /* 911 */
+ SID_ATTR_CHAR_RELIEF,
+ SID_ATTR_PARA_LEFT_TO_RIGHT, /* 950 */
+ SID_ATTR_PARA_RIGHT_TO_LEFT,
+ SID_ATTR_CHAR_OVERLINE,
+ 0
+ };
+
+ // slots which we are not responsible for on the SfxShell level, but
+ // need to handle during the "paragraph attributes" and/or "character
+ // attributes" dialogs
+ static SfxSlotId pDialogSlots[] =
+ {
+ SID_ATTR_TABSTOP,
+ SID_ATTR_PARA_HANGPUNCTUATION,
+ SID_ATTR_PARA_FORBIDDEN_RULES,
+ SID_ATTR_PARA_SCRIPTSPACE,
+ SID_ATTR_CHAR_LATIN_LANGUAGE,
+ SID_ATTR_CHAR_CJK_LANGUAGE,
+ SID_ATTR_CHAR_CTL_LANGUAGE,
+ SID_ATTR_CHAR_LATIN_FONT,
+ SID_ATTR_CHAR_CJK_FONT,
+ SID_ATTR_CHAR_CTL_FONT,
+ SID_ATTR_CHAR_LATIN_FONTHEIGHT,
+ SID_ATTR_CHAR_CJK_FONTHEIGHT,
+ SID_ATTR_CHAR_CTL_FONTHEIGHT,
+ SID_ATTR_CHAR_LATIN_WEIGHT,
+ SID_ATTR_CHAR_CJK_WEIGHT,
+ SID_ATTR_CHAR_CTL_WEIGHT,
+ SID_ATTR_CHAR_LATIN_POSTURE,
+ SID_ATTR_CHAR_CJK_POSTURE,
+ SID_ATTR_CHAR_CTL_POSTURE,
+ SID_ATTR_CHAR_EMPHASISMARK,
+ 0
+ };
+
+ //====================================================================
+ //= FmFocusListenerAdapter
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < XFocusListener
+ > FmFocusListenerAdapter_Base;
+ class FmFocusListenerAdapter : public FmFocusListenerAdapter_Base
+ {
+ private:
+ IFocusObserver* m_pObserver;
+ Reference< XWindow > m_xWindow;
+
+ public:
+ FmFocusListenerAdapter( const Reference< XControl >& _rxControl, IFocusObserver* _pObserver );
+
+ // clean up the instance
+ void dispose();
+
+ protected:
+ ~FmFocusListenerAdapter();
+
+ protected:
+ virtual void SAL_CALL focusGained( const FocusEvent& e ) throw (RuntimeException);
+ virtual void SAL_CALL focusLost( const FocusEvent& e ) throw (RuntimeException);
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+ };
+
+ //--------------------------------------------------------------------
+ DBG_NAME( FmFocusListenerAdapter )
+ //--------------------------------------------------------------------
+ FmFocusListenerAdapter::FmFocusListenerAdapter( const Reference< XControl >& _rxControl, IFocusObserver* _pObserver )
+ :m_pObserver( _pObserver )
+ ,m_xWindow( _rxControl, UNO_QUERY )
+ {
+ DBG_CTOR( FmFocusListenerAdapter, NULL );
+
+ DBG_ASSERT( m_xWindow.is(), "FmFocusListenerAdapter::FmFocusListenerAdapter: invalid control!" );
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ try
+ {
+ if ( m_xWindow.is() )
+ m_xWindow->addFocusListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ FmFocusListenerAdapter::~FmFocusListenerAdapter()
+ {
+ acquire();
+ dispose();
+
+ DBG_DTOR( FmFocusListenerAdapter, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void FmFocusListenerAdapter::dispose()
+ {
+ if ( m_xWindow.is() )
+ {
+ m_xWindow->removeFocusListener( this );
+ m_xWindow.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FmFocusListenerAdapter::focusGained( const FocusEvent& e ) throw (RuntimeException)
+ {
+ if ( m_pObserver )
+ m_pObserver->focusGained( e );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FmFocusListenerAdapter::focusLost( const FocusEvent& e ) throw (RuntimeException)
+ {
+ if ( m_pObserver )
+ m_pObserver->focusLost( e );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FmFocusListenerAdapter::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ (void)Source;
+ DBG_ASSERT( Source.Source == m_xWindow, "FmFocusListenerAdapter::disposing: where did this come from?" );
+ m_xWindow.clear();
+ }
+
+ //====================================================================
+ //= FmMouseListenerAdapter
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < XMouseListener
+ > FmMouseListenerAdapter_Base;
+ class FmMouseListenerAdapter : public FmMouseListenerAdapter_Base
+ {
+ private:
+ IContextRequestObserver* m_pObserver;
+ Reference< XWindow > m_xWindow;
+
+ public:
+ FmMouseListenerAdapter( const Reference< XControl >& _rxControl, IContextRequestObserver* _pObserver );
+
+ // clean up the instance
+ void dispose();
+
+ protected:
+ ~FmMouseListenerAdapter();
+
+ protected:
+ virtual void SAL_CALL mousePressed( const awt::MouseEvent& e ) throw (RuntimeException);
+ virtual void SAL_CALL mouseReleased( const awt::MouseEvent& e ) throw (RuntimeException);
+ virtual void SAL_CALL mouseEntered( const awt::MouseEvent& e ) throw (RuntimeException);
+ virtual void SAL_CALL mouseExited( const awt::MouseEvent& e ) throw (RuntimeException);
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+ };
+
+ //====================================================================
+ //= FmMouseListenerAdapter
+ //====================================================================
+ //--------------------------------------------------------------------
+ DBG_NAME( FmMouseListenerAdapter )
+ //--------------------------------------------------------------------
+ FmMouseListenerAdapter::FmMouseListenerAdapter( const Reference< XControl >& _rxControl, IContextRequestObserver* _pObserver )
+ :m_pObserver( _pObserver )
+ ,m_xWindow( _rxControl, UNO_QUERY )
+ {
+ DBG_CTOR( FmMouseListenerAdapter, NULL );
+
+ DBG_ASSERT( m_xWindow.is(), "FmMouseListenerAdapter::FmMouseListenerAdapter: invalid control!" );
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ try
+ {
+ if ( m_xWindow.is() )
+ m_xWindow->addMouseListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ FmMouseListenerAdapter::~FmMouseListenerAdapter()
+ {
+ acquire();
+ dispose();
+
+ DBG_DTOR( FmMouseListenerAdapter, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void FmMouseListenerAdapter::dispose()
+ {
+ if ( m_xWindow.is() )
+ {
+ m_xWindow->removeMouseListener( this );
+ m_xWindow.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FmMouseListenerAdapter::mousePressed( const awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ SolarMutexGuard aGuard;
+ // is this a request for a context menu?
+ if ( _rEvent.PopupTrigger )
+ {
+ if ( m_pObserver )
+ m_pObserver->contextMenuRequested( _rEvent );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FmMouseListenerAdapter::mouseReleased( const awt::MouseEvent& /*e*/ ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FmMouseListenerAdapter::mouseEntered( const awt::MouseEvent& /*e*/ ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FmMouseListenerAdapter::mouseExited( const awt::MouseEvent& /*e*/ ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FmMouseListenerAdapter::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ (void)Source;
+ DBG_ASSERT( Source.Source == m_xWindow, "FmMouseListenerAdapter::disposing: where did this come from?" );
+ m_xWindow.clear();
+ }
+
+ //====================================================================
+ //= FmTextControlShell
+ //====================================================================
+ //------------------------------------------------------------------------
+ namespace
+ {
+ //....................................................................
+ void lcl_translateUnoStateToItem( SfxSlotId _nSlot, const Any& _rUnoState, SfxItemSet& _rSet )
+ {
+ WhichId nWhich = _rSet.GetPool()->GetWhich( _nSlot );
+ if ( !_rUnoState.hasValue() )
+ {
+ if ( ( _nSlot != SID_CUT )
+ && ( _nSlot != SID_COPY )
+ && ( _nSlot != SID_PASTE )
+ )
+ {
+ _rSet.InvalidateItem( nWhich );
+ }
+ }
+ else
+ {
+ switch ( _rUnoState.getValueType().getTypeClass() )
+ {
+ case TypeClass_BOOLEAN:
+ {
+ sal_Bool bState = sal_False;
+ _rUnoState >>= bState;
+ if ( _nSlot == SID_ATTR_PARA_SCRIPTSPACE )
+ _rSet.Put( SvxScriptSpaceItem( bState, nWhich ) );
+ else
+ _rSet.Put( SfxBoolItem( nWhich, bState ) );
+ }
+ break;
+
+ default:
+ {
+ Sequence< PropertyValue > aComplexState;
+ if ( _rUnoState >>= aComplexState )
+ {
+ if ( !aComplexState.getLength() )
+ _rSet.InvalidateItem( nWhich );
+ else
+ {
+ SfxAllItemSet aAllItems( _rSet );
+ TransformParameters( _nSlot, aComplexState, aAllItems );
+ const SfxPoolItem* pTransformed = aAllItems.GetItem( nWhich );
+ OSL_ENSURE( pTransformed, "lcl_translateUnoStateToItem: non-empty parameter sequence leading to empty item?" );
+ if ( pTransformed )
+ _rSet.Put( *pTransformed );
+ else
+ _rSet.InvalidateItem( nWhich );
+ }
+ }
+ else
+ {
+ DBG_ERROR( "lcl_translateUnoStateToItem: invalid state!" );
+ }
+ }
+ }
+ }
+ }
+
+ //....................................................................
+ ::rtl::OUString lcl_getUnoSlotName( SfxApplication&, SfxSlotId _nSlotId )
+ {
+ ::rtl::OUString sSlotUnoName;
+
+ SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool( NULL );
+ const SfxSlot* pSlot = rSlotPool.GetSlot( _nSlotId );
+
+ const sal_Char* pAsciiUnoName = NULL;
+ if ( pSlot )
+ {
+ pAsciiUnoName = pSlot->GetUnoName();
+ }
+ else
+ {
+ // some hard-coded slots, which do not have a UNO name at SFX level, but which
+ // we nevertheless need to transport via UNO mechanisms, so we need a name
+ switch ( _nSlotId )
+ {
+ case SID_ATTR_PARA_HANGPUNCTUATION: pAsciiUnoName = "AllowHangingPunctuation"; break;
+ case SID_ATTR_PARA_FORBIDDEN_RULES: pAsciiUnoName = "ApplyForbiddenCharacterRules"; break;
+ case SID_ATTR_PARA_SCRIPTSPACE: pAsciiUnoName = "UseScriptSpacing"; break;
+ }
+ }
+
+ if ( pAsciiUnoName )
+ {
+ sSlotUnoName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:" ) );
+ sSlotUnoName += ::rtl::OUString::createFromAscii( pAsciiUnoName );
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else
+ {
+ ::rtl::OString sMessage( "lcl_getUnoSlotName: invalid slot id, or invalid slot, or no UNO name!\n" );
+ sMessage += "(slot id: ";
+ sMessage += ::rtl::OString::valueOf( (sal_Int32)_nSlotId );
+ sMessage += ")";
+ DBG_ERROR( sMessage );
+ }
+#endif
+ return sSlotUnoName;
+ }
+
+ //....................................................................
+ bool lcl_determineReadOnly( const Reference< XControl >& _rxControl )
+ {
+ bool bIsReadOnlyModel = true;
+ try
+ {
+ Reference< XPropertySet > xModelProps;
+ if ( _rxControl.is() )
+ xModelProps = xModelProps.query( _rxControl->getModel() );
+ Reference< XPropertySetInfo > xModelPropInfo;
+ if ( xModelProps.is() )
+ xModelPropInfo = xModelProps->getPropertySetInfo();
+
+ if ( !xModelPropInfo.is() || !xModelPropInfo->hasPropertyByName( FM_PROP_READONLY ) )
+ bIsReadOnlyModel = true;
+ else
+ {
+ sal_Bool bReadOnly = sal_True;
+ xModelProps->getPropertyValue( FM_PROP_READONLY ) >>= bReadOnly;
+ bIsReadOnlyModel = bReadOnly;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bIsReadOnlyModel;
+ }
+
+ //....................................................................
+ static Window* lcl_getWindow( const Reference< XControl >& _rxControl )
+ {
+ Window* pWindow = NULL;
+ try
+ {
+ Reference< XWindowPeer > xControlPeer;
+ if ( _rxControl.is() )
+ xControlPeer = _rxControl->getPeer();
+ if ( xControlPeer.is() )
+ pWindow = VCLUnoHelper::GetWindow( xControlPeer );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return pWindow;
+ }
+
+ //....................................................................
+ bool lcl_isRichText( const Reference< XControl >& _rxControl )
+ {
+ if ( !_rxControl.is() )
+ return false;
+
+ bool bIsRichText = false;
+ try
+ {
+ Reference< XPropertySet > xModelProps( _rxControl->getModel(), UNO_QUERY );
+ Reference< XPropertySetInfo > xPSI;
+ if ( xModelProps.is() )
+ xPSI = xModelProps->getPropertySetInfo();
+ ::rtl::OUString sRichTextPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RichText" ) );
+ if ( xPSI.is() && xPSI->hasPropertyByName( sRichTextPropertyName ) )
+ {
+ OSL_VERIFY( xModelProps->getPropertyValue( sRichTextPropertyName ) >>= bIsRichText );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bIsRichText;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ FmTextControlShell::FmTextControlShell( SfxViewFrame* _pFrame )
+ :m_bActiveControl( false )
+ ,m_bActiveControlIsReadOnly( true )
+ ,m_bActiveControlIsRichText( false )
+ ,m_pViewFrame( _pFrame )
+ ,m_rBindings( _pFrame->GetBindings() )
+ ,m_bNeedClipboardInvalidation( true )
+ {
+ m_aClipboardInvalidation.SetTimeoutHdl( LINK( this, FmTextControlShell, OnInvalidateClipboard ) );
+ m_aClipboardInvalidation.SetTimeout( 200 );
+ }
+
+ //------------------------------------------------------------------------
+ FmTextControlShell::~FmTextControlShell()
+ {
+ dispose();
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FmTextControlShell, OnInvalidateClipboard, void*, /*_pNotInterestedIn*/ )
+ {
+ if ( m_bNeedClipboardInvalidation )
+ {
+ DBG_TRACE( "FmTextControlShell::ClipBoard: invalidating clipboard slots" );
+ m_rBindings.Invalidate( SID_CUT );
+ m_rBindings.Invalidate( SID_COPY );
+ m_rBindings.Invalidate( SID_PASTE );
+ m_bNeedClipboardInvalidation = false;
+ }
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::transferFeatureStatesToItemSet( ControlFeatures& _rDispatchers, SfxAllItemSet& _rSet, bool _bTranslateLatin )
+ {
+ SfxItemPool& rPool = *_rSet.GetPool();
+
+ for ( ControlFeatures::const_iterator aFeature = _rDispatchers.begin();
+ aFeature != _rDispatchers.end();
+ ++aFeature
+ )
+ {
+ SfxSlotId nSlotId( aFeature->first );
+ #if OSL_DEBUG_LEVEL > 0
+ ::rtl::OUString sUnoSlotName;
+ if ( SFX_APP() )
+ sUnoSlotName = lcl_getUnoSlotName( *SFX_APP(), nSlotId );
+ else
+ sUnoSlotName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "<unknown>" ) );
+ ::rtl::OString sUnoSlotNameAscii( "\"" );
+ sUnoSlotNameAscii += ::rtl::OString( sUnoSlotName.getStr(), sUnoSlotName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ sUnoSlotNameAscii += "\"";
+ #endif
+
+ if ( _bTranslateLatin )
+ {
+ // A rich text control offers a dispatcher for the "Font" slot/feature.
+ // Sadly, the semantics of the dispatches is that the feature "Font" depends
+ // on the current cursor position: If it's on latin text, it's the "latin font"
+ // which is set up at the control. If it's on CJK text, it's the "CJK font", and
+ // aequivalent for "CTL font".
+ // The same holds for some other font related features/slots.
+ // Thus, we have separate dispatches for "Latin Font", "Latin Font Size", etc,
+ // which are only "virtual", in a sense that there exist no item with this id.
+ // So when we encounter such a dispatcher for, say, "Latin Font", we need to
+ // put an item into the set which has the "Font" id.
+
+ switch ( nSlotId )
+ {
+ case SID_ATTR_CHAR_LATIN_FONT: nSlotId = SID_ATTR_CHAR_FONT; break;
+ case SID_ATTR_CHAR_LATIN_FONTHEIGHT:nSlotId = SID_ATTR_CHAR_FONTHEIGHT; break;
+ case SID_ATTR_CHAR_LATIN_LANGUAGE: nSlotId = SID_ATTR_CHAR_LANGUAGE; break;
+ case SID_ATTR_CHAR_LATIN_POSTURE: nSlotId = SID_ATTR_CHAR_POSTURE; break;
+ case SID_ATTR_CHAR_LATIN_WEIGHT: nSlotId = SID_ATTR_CHAR_WEIGHT; break;
+ }
+ }
+
+ WhichId nWhich = rPool.GetWhich( nSlotId );
+ bool bIsInPool = rPool.IsInRange( nWhich );
+ if ( bIsInPool )
+ {
+ #if OSL_DEBUG_LEVEL > 0
+ bool bFeatureIsEnabled = aFeature->second->isFeatureEnabled();
+ ::rtl::OString sMessage( "FmTextControlShell::transferFeatureStatesToItemSet: found a feature state for " );
+ sMessage += sUnoSlotNameAscii;
+ if ( !bFeatureIsEnabled )
+ sMessage += " (disabled)";
+ DBG_TRACE( sMessage );
+ #endif
+
+ lcl_translateUnoStateToItem( nSlotId, aFeature->second->getFeatureState(), _rSet );
+ }
+ #if OSL_DEBUG_LEVEL > 0
+ else
+ {
+ ::rtl::OString sMessage( "FmTextControlShell::transferFeatureStatesToItemSet: found a feature state for " );
+ sMessage += sUnoSlotNameAscii;
+ sMessage += ", but could not translate it into an item!";
+ DBG_TRACE( sMessage );
+ }
+ #endif
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::executeAttributeDialog( AttributeSet _eSet, SfxRequest& _rReq )
+ {
+ const SvxFontListItem* pFontList = PTR_CAST( SvxFontListItem, m_pViewFrame->GetObjectShell()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
+ DBG_ASSERT( pFontList, "FmTextControlShell::executeAttributeDialog: no font list item!" );
+ if ( !pFontList )
+ return;
+
+ SfxItemPool* pPool = EditEngine::CreatePool();
+ pPool->FreezeIdRanges();
+ ::std::auto_ptr< SfxItemSet > pPureItems( new SfxItemSet( *pPool ) );
+
+ // put the current states of the items into the set
+ ::std::auto_ptr< SfxAllItemSet > pCurrentItems( new SfxAllItemSet( *pPureItems ) );
+ transferFeatureStatesToItemSet( m_aControlFeatures, *pCurrentItems );
+
+ // additional items, which we are not responsible for at the SfxShell level,
+ // but which need to be forwarded to the dialog, anyway
+ ControlFeatures aAdditionalFestures;
+ fillFeatureDispatchers( m_xActiveControl, pDialogSlots, aAdditionalFestures );
+ transferFeatureStatesToItemSet( aAdditionalFestures, *pCurrentItems, true );
+
+ ::std::auto_ptr< SfxTabDialog > pDialog ( _eSet == eCharAttribs
+ ? static_cast< SfxTabDialog* >( new TextControlCharAttribDialog( NULL, *pCurrentItems, *pFontList ) )
+ : static_cast< SfxTabDialog* >( new TextControlParaAttribDialog( NULL, *pCurrentItems ) ) );
+ if ( RET_OK == pDialog->Execute() )
+ {
+ const SfxItemSet& rModifiedItems = *pDialog->GetOutputItemSet();
+ for ( WhichId nWhich = pPool->GetFirstWhich(); nWhich <= pPool->GetLastWhich(); ++nWhich )
+ {
+ if ( rModifiedItems.GetItemState( nWhich ) == SFX_ITEM_SET )
+ {
+ SfxSlotId nSlotForItemSet = pPool->GetSlotId( nWhich );
+ const SfxPoolItem* pModifiedItem = rModifiedItems.GetItem( nWhich );
+
+
+ SfxSlotId nSlotForDispatcher = nSlotForItemSet;
+ switch ( nSlotForDispatcher )
+ {
+ case SID_ATTR_CHAR_FONT: nSlotForDispatcher = SID_ATTR_CHAR_LATIN_FONT; break;
+ case SID_ATTR_CHAR_FONTHEIGHT:nSlotForDispatcher = SID_ATTR_CHAR_LATIN_FONTHEIGHT; break;
+ case SID_ATTR_CHAR_LANGUAGE: nSlotForDispatcher = SID_ATTR_CHAR_LATIN_LANGUAGE; break;
+ case SID_ATTR_CHAR_POSTURE: nSlotForDispatcher = SID_ATTR_CHAR_LATIN_POSTURE; break;
+ case SID_ATTR_CHAR_WEIGHT: nSlotForDispatcher = SID_ATTR_CHAR_LATIN_WEIGHT; break;
+ }
+
+ // do we already have a dispatcher for this slot/feature?
+ ControlFeatures::const_iterator aFeaturePos = m_aControlFeatures.find( nSlotForDispatcher );
+ bool bFound = aFeaturePos != m_aControlFeatures.end( );
+
+ if ( !bFound )
+ {
+ aFeaturePos = aAdditionalFestures.find( nSlotForDispatcher );
+ bFound = aFeaturePos != aAdditionalFestures.end( );
+ }
+
+ if ( bFound )
+ {
+ Sequence< PropertyValue > aArgs;
+ // temporarily put the modified item into a "clean" set,
+ // and let TransformItems calc the respective UNO parameters
+ pPureItems->Put( *pModifiedItem );
+ TransformItems( nSlotForItemSet, *pPureItems, aArgs );
+ pPureItems->ClearItem( nWhich );
+
+ if ( ( nSlotForItemSet == SID_ATTR_PARA_HANGPUNCTUATION )
+ || ( nSlotForItemSet == SID_ATTR_PARA_FORBIDDEN_RULES )
+ || ( nSlotForItemSet == SID_ATTR_PARA_SCRIPTSPACE )
+ )
+ {
+ // these are no UNO slots, they need special handling since TransformItems cannot
+ // handle them
+ DBG_ASSERT( aArgs.getLength() == 0, "FmTextControlShell::executeAttributeDialog: these are no UNO slots - are they?" );
+
+ const SfxBoolItem* pBoolItem = PTR_CAST( SfxBoolItem, pModifiedItem );
+ DBG_ASSERT( pBoolItem, "FmTextControlShell::executeAttributeDialog: no bool item?!" );
+ if ( pBoolItem )
+ {
+ aArgs.realloc( 1 );
+ aArgs[ 0 ].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enable" ) );
+ aArgs[ 0 ].Value <<= (sal_Bool)pBoolItem->GetValue();
+ }
+ }
+
+ // dispatch this
+ aFeaturePos->second->dispatch( aArgs );
+ }
+ #if OSL_DEBUG_LEVEL > 0
+ else
+ {
+ ::rtl::OString sError( "FmTextControShell::executeAttributeDialog: Could not handle the following item:" );
+ sError += "\n SlotID: "; sError += ::rtl::OString::valueOf( (sal_Int32)nSlotForItemSet );
+ sError += "\n WhichID: "; sError += ::rtl::OString::valueOf( (sal_Int32)nWhich );
+ sError += "\n UNO name: ";
+
+ ::rtl::OUString sUnoSlotName = lcl_getUnoSlotName( *SFX_APP(), nSlotForItemSet );
+ if ( sUnoSlotName.getLength() )
+ sError += ::rtl::OString( sUnoSlotName.getStr(), sUnoSlotName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ else
+ sError += "unknown (no SfxSlot)";
+ DBG_ERROR( sError.getStr() );
+ }
+ #endif
+ }
+ }
+ _rReq.Done( rModifiedItems );
+ }
+
+ pDialog.reset();
+ pCurrentItems.reset();
+ pPureItems.reset();
+ SfxItemPool::Free(pPool);
+ }
+
+ //------------------------------------------------------------------------
+ bool FmTextControlShell::executeSelectAll( )
+ {
+ try
+ {
+ if ( m_xActiveTextComponent.is() )
+ {
+ sal_Int32 nTextLen = m_xActiveTextComponent->getText().getLength();
+ m_xActiveTextComponent->setSelection( awt::Selection( 0, nTextLen ) );
+ return true;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false; // not handled
+ }
+
+ //------------------------------------------------------------------------
+ bool FmTextControlShell::executeClipboardSlot( SfxSlotId _nSlot )
+ {
+ try
+ {
+ if ( m_xActiveTextComponent.is() )
+ {
+ switch ( _nSlot )
+ {
+ case SID_COPY:
+ case SID_CUT:
+ {
+ ::rtl::OUString sSelectedText( m_xActiveTextComponent->getSelectedText() );
+ ::svt::OStringTransfer::CopyString( sSelectedText, lcl_getWindow( m_xActiveControl ) );
+ if ( SID_CUT == _nSlot )
+ {
+ awt::Selection aSelection( m_xActiveTextComponent->getSelection() );
+ m_xActiveTextComponent->insertText( aSelection, ::rtl::OUString() );
+ }
+ }
+ break;
+ case SID_PASTE:
+ {
+ ::rtl::OUString sClipboardContent;
+ OSL_VERIFY( ::svt::OStringTransfer::PasteString( sClipboardContent, lcl_getWindow( m_xActiveControl ) ) );
+ awt::Selection aSelection( m_xActiveTextComponent->getSelection() );
+ m_xActiveTextComponent->insertText( aSelection, sClipboardContent );
+ }
+ break;
+ default:
+ OSL_ENSURE( sal_False, "FmTextControlShell::executeClipboardSlot: invalid slot!" );
+ }
+ return true;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false; // not handled
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::ExecuteTextAttribute( SfxRequest& _rReq )
+ {
+ SfxSlotId nSlot = _rReq.GetSlot();
+
+ ControlFeatures::const_iterator aFeaturePos = m_aControlFeatures.find( nSlot );
+ if ( aFeaturePos == m_aControlFeatures.end() )
+ {
+ // special slots
+ switch ( nSlot )
+ {
+ case SID_CHAR_DLG:
+ executeAttributeDialog( eCharAttribs, _rReq );
+ break;
+
+ case SID_PARA_DLG:
+ executeAttributeDialog( eParaAttribs, _rReq );
+ break;
+
+ case SID_SELECTALL:
+ executeSelectAll();
+ break;
+
+ case SID_CUT:
+ case SID_COPY:
+ case SID_PASTE:
+ executeClipboardSlot( nSlot );
+ break;
+
+ default:
+ DBG_ASSERT( aFeaturePos != m_aControlFeatures.end(), "FmTextControShell::ExecuteTextAttribute: I have no such dispatcher, and cannot handle it at all!" );
+ return;
+ }
+ }
+ else
+ {
+ // slots which are dispatched to the control
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_CHAR_STRIKEOUT:
+ case SID_ATTR_CHAR_UNDERLINE:
+ case SID_ATTR_CHAR_OVERLINE:
+ {
+ SfxItemSet aToggled( *_rReq.GetArgs() );
+
+ lcl_translateUnoStateToItem( nSlot, aFeaturePos->second->getFeatureState(), aToggled );
+ WhichId nWhich = aToggled.GetPool()->GetWhich( nSlot );
+ const SfxPoolItem* pItem = aToggled.GetItem( nWhich );
+ if ( ( SID_ATTR_CHAR_UNDERLINE == nSlot ) || ( SID_ATTR_CHAR_OVERLINE == nSlot ) )
+ {
+ const SvxOverlineItem* pTextLine = PTR_CAST( SvxOverlineItem, pItem );
+ DBG_ASSERT( pTextLine, "FmTextControlShell::ExecuteTextAttribute: ooops - no underline/overline item!" );
+ if ( pTextLine )
+ {
+ FontUnderline eTL = pTextLine->GetLineStyle();
+ if ( SID_ATTR_CHAR_UNDERLINE == nSlot ) {
+ aToggled.Put( SvxUnderlineItem( eTL == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, nWhich ) );
+ } else {
+ aToggled.Put( SvxOverlineItem( eTL == UNDERLINE_SINGLE ? UNDERLINE_NONE : UNDERLINE_SINGLE, nWhich ) );
+ }
+ }
+ }
+ else
+ {
+ const SvxCrossedOutItem* pCrossedOut = PTR_CAST( SvxCrossedOutItem, pItem );
+ DBG_ASSERT( pCrossedOut, "FmTextControlShell::ExecuteTextAttribute: ooops - no CrossedOut item!" );
+ if ( pCrossedOut )
+ {
+ FontStrikeout eFS = pCrossedOut->GetStrikeout();
+ aToggled.Put( SvxCrossedOutItem( eFS == STRIKEOUT_SINGLE ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, nWhich ) );
+ }
+ }
+
+ Sequence< PropertyValue > aArguments;
+ TransformItems( nSlot, aToggled, aArguments );
+ aFeaturePos->second->dispatch( aArguments );
+ }
+ break;
+
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ case SID_ATTR_CHAR_FONT:
+ case SID_ATTR_CHAR_POSTURE:
+ case SID_ATTR_CHAR_WEIGHT:
+ case SID_ATTR_CHAR_SHADOWED:
+ case SID_ATTR_CHAR_CONTOUR:
+ case SID_SET_SUPER_SCRIPT:
+ case SID_SET_SUB_SCRIPT:
+ {
+ const SfxItemSet* pArgs = _rReq.GetArgs();
+ Sequence< PropertyValue > aArgs;
+ if ( pArgs )
+ TransformItems( nSlot, *pArgs, aArgs );
+ aFeaturePos->second->dispatch( aArgs );
+ }
+ break;
+
+ default:
+ if ( aFeaturePos->second->isFeatureEnabled() )
+ aFeaturePos->second->dispatch();
+ break;
+ }
+ }
+ _rReq.Done();
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::GetTextAttributeState( SfxItemSet& _rSet )
+ {
+ SfxWhichIter aIter( _rSet );
+ sal_uInt16 nSlot = aIter.FirstWhich();
+ while ( nSlot )
+ {
+ if ( ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT )
+ || ( nSlot == SID_ATTR_PARA_RIGHT_TO_LEFT )
+ )
+ {
+ if ( !SvtLanguageOptions().IsCTLFontEnabled() )
+ {
+ _rSet.DisableItem( nSlot );
+ nSlot = aIter.NextWhich();
+ continue;
+ }
+ }
+
+ ControlFeatures::const_iterator aFeaturePos = m_aControlFeatures.find( nSlot );
+ if ( aFeaturePos != m_aControlFeatures.end() )
+ {
+ if ( aFeaturePos->second->isFeatureEnabled() )
+ lcl_translateUnoStateToItem( nSlot, aFeaturePos->second->getFeatureState(), _rSet );
+ else
+ _rSet.DisableItem( nSlot );
+ }
+ else
+ {
+ bool bDisable = false;
+
+ bool bNeedWriteableControl = false;
+ bool bNeedTextComponent = false;
+ bool bNeedSelection = false;
+
+ switch ( nSlot )
+ {
+ case SID_CHAR_DLG:
+ case SID_PARA_DLG:
+ bDisable |= m_aControlFeatures.empty();
+ bNeedWriteableControl = true;
+ break;
+
+ case SID_CUT:
+ bNeedSelection = true;
+ bNeedTextComponent = true;
+ bNeedWriteableControl = true;
+ DBG_TRACE( "FmTextControlShell::ClipBoard: need to invalidate again" );
+ m_bNeedClipboardInvalidation = true;
+ break;
+
+ case SID_PASTE:
+ {
+ Window* pActiveControlVCLWindow = lcl_getWindow( m_xActiveControl );
+ if ( pActiveControlVCLWindow )
+ {
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pActiveControlVCLWindow) );
+ bDisable |= !aDataHelper.HasFormat( SOT_FORMAT_STRING );
+ }
+ else
+ bDisable |= true;
+
+ bNeedTextComponent = true;
+ bNeedWriteableControl = true;
+ }
+ break;
+
+ case SID_COPY:
+ bNeedTextComponent = true;
+ bNeedSelection = true;
+ break;
+
+ case SID_SELECTALL:
+ bNeedTextComponent = true;
+ break;
+
+ default:
+ // slot is unknown at all
+ bDisable |= true;
+ break;
+ }
+ OSL_POSTCOND( !bNeedSelection || bNeedTextComponent, "FmTextControlShell::GetTextAttributeState: bNeedSelection should imply bNeedTextComponent!" );
+
+ if ( !bDisable && bNeedWriteableControl )
+ bDisable |= !IsActiveControl( ) || m_bActiveControlIsReadOnly;
+
+ if ( !bDisable && bNeedTextComponent )
+ bDisable |= !m_xActiveTextComponent.is();
+
+ if ( !bDisable && bNeedSelection )
+ {
+ awt::Selection aSelection = m_xActiveTextComponent->getSelection();
+ bDisable |= aSelection.Min == aSelection.Max;
+ }
+
+ if ( bDisable )
+ _rSet.DisableItem( nSlot );
+ }
+
+ nSlot = aIter.NextWhich();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ bool FmTextControlShell::IsActiveControl( bool _bCountRichTextOnly ) const
+ {
+ if ( _bCountRichTextOnly && !m_bActiveControlIsRichText )
+ return false;
+
+ return m_bActiveControl;
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::dispose()
+ {
+ if ( IsActiveControl() )
+ controlDeactivated();
+ if ( isControllerListening() )
+ stopControllerListening();
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::designModeChanged( bool /*_bNewDesignMode*/ )
+ {
+ m_rBindings.Invalidate( pTextControlSlots );
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::formActivated( const Reference< XFormController >& _rxController )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sTrace( "FmTextControlShell::formActivated: 0x" );
+ sTrace += ::rtl::OString::valueOf( (sal_IntPtr)_rxController.get(), 16 );
+ DBG_TRACE( sTrace );
+#endif
+
+ DBG_ASSERT( _rxController.is(), "FmTextControlShell::formActivated: invalid controller!" );
+ if ( !_rxController.is() )
+ return;
+
+ // sometimes, a form controller notifies activations, even if it's already activated
+ if ( m_xActiveController == _rxController )
+ return;
+
+ try
+ {
+ startControllerListening( _rxController );
+ controlActivated( _rxController->getCurrentControl() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::formDeactivated( const Reference< XFormController >& _rxController )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sTrace( "FmTextControlShell::formDeactivated: 0x" );
+ sTrace += ::rtl::OString::valueOf( (sal_IntPtr)_rxController.get(), 16 );
+ DBG_TRACE( sTrace );
+#endif
+ (void)_rxController;
+
+ if ( IsActiveControl() )
+ controlDeactivated();
+ if ( isControllerListening() )
+ stopControllerListening();
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::startControllerListening( const Reference< XFormController >& _rxController )
+ {
+ OSL_PRECOND( _rxController.is(), "FmTextControlShell::startControllerListening: invalid controller!" );
+ if ( !_rxController.is() )
+ return;
+
+ OSL_PRECOND( !isControllerListening(), "FmTextControlShell::startControllerListening: already listening!" );
+ if ( isControllerListening() )
+ stopControllerListening( );
+ DBG_ASSERT( !isControllerListening(), "FmTextControlShell::startControllerListening: inconsistence!" );
+
+ try
+ {
+ Sequence< Reference< XControl > > aControls( _rxController->getControls() );
+ m_aControlObservers.resize( 0 );
+ m_aControlObservers.reserve( aControls.getLength() );
+
+ const Reference< XControl >* pControls = aControls.getConstArray();
+ const Reference< XControl >* pControlsEnd = pControls + aControls.getLength();
+ for ( ; pControls != pControlsEnd; ++pControls )
+ {
+ m_aControlObservers.push_back( FocusListenerAdapter( new FmFocusListenerAdapter( *pControls, this ) ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_xActiveController = _rxController;
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::stopControllerListening( )
+ {
+ OSL_PRECOND( isControllerListening(), "FmTextControlShell::stopControllerListening: inconsistence!" );
+
+ // dispose all listeners associated with the controls of the active controller
+ for ( FocusListenerAdapters::iterator aLoop = m_aControlObservers.begin();
+ aLoop != m_aControlObservers.end();
+ ++aLoop
+ )
+ {
+ (*aLoop)->dispose();
+ }
+
+ FocusListenerAdapters aEmpty;
+ m_aControlObservers.swap( aEmpty );
+
+ m_xActiveController.clear();
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::implClearActiveControlRef()
+ {
+ // no more features for this control
+ for ( ControlFeatures::iterator aLoop = m_aControlFeatures.begin();
+ aLoop != m_aControlFeatures.end();
+ ++aLoop
+ )
+ {
+ aLoop->second->dispose();
+ }
+
+ ControlFeatures aEmpty;
+ m_aControlFeatures.swap( aEmpty );
+
+ if ( m_aContextMenuObserver.get() )
+ {
+ m_aContextMenuObserver->dispose();
+ m_aContextMenuObserver = MouseListenerAdapter();
+ }
+
+ if ( m_xActiveTextComponent.is() )
+ {
+ DBG_TRACE( "FmTextControlShell::ClipBoard: stopping timer for clipboard invalidation" );
+ m_aClipboardInvalidation.Stop();
+ }
+ // no more active control
+ m_xActiveControl.clear();
+ m_xActiveTextComponent.clear();
+ m_bActiveControlIsReadOnly = true;
+ m_bActiveControlIsRichText = false;
+ m_bActiveControl = false;
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::controlDeactivated( )
+ {
+ DBG_ASSERT( IsActiveControl(), "FmTextControlShell::controlDeactivated: no active control!" );
+
+ m_bActiveControl = false;
+
+ m_rBindings.Invalidate( pTextControlSlots );
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::controlActivated( const Reference< XControl >& _rxControl )
+ {
+ // ensure that all knittings with the previously active control are lost
+ if ( m_xActiveControl.is() )
+ implClearActiveControlRef();
+ DBG_ASSERT( m_aControlFeatures.empty(), "FmTextControlShell::controlActivated: should have no dispatchers when I'm here!" );
+
+#if OSL_DEBUG_LEVEL > 0
+ {
+ Sequence< Reference< XControl > > aActiveControls;
+ if ( m_xActiveController.is() )
+ aActiveControls = m_xActiveController->getControls();
+
+ bool bFoundThisControl = false;
+
+ const Reference< XControl >* pControls = aActiveControls.getConstArray();
+ const Reference< XControl >* pControlsEnd = pControls + aActiveControls.getLength();
+ for ( ; ( pControls != pControlsEnd ) && !bFoundThisControl; ++pControls )
+ {
+ if ( *pControls == _rxControl )
+ bFoundThisControl = true;
+ }
+ DBG_ASSERT( bFoundThisControl, "FmTextControlShell::controlActivated: only controls which belong to the active controller can be activated!" );
+ }
+#endif
+ // ask the control for dispatchers for our text-related slots
+ fillFeatureDispatchers( _rxControl, pTextControlSlots, m_aControlFeatures );
+
+ // remember this control
+ m_xActiveControl = _rxControl;
+ m_xActiveTextComponent = m_xActiveTextComponent.query( _rxControl );
+ m_bActiveControlIsReadOnly = lcl_determineReadOnly( m_xActiveControl );
+ m_bActiveControlIsRichText = lcl_isRichText( m_xActiveControl );
+
+ // if we found a rich text control, we need context menu support
+ if ( m_bActiveControlIsRichText )
+ {
+ DBG_ASSERT( NULL == m_aContextMenuObserver.get(), "FmTextControlShell::controlActivated: already have an observer!" );
+ m_aContextMenuObserver = MouseListenerAdapter( new FmMouseListenerAdapter( _rxControl, this ) );
+ }
+
+ if ( m_xActiveTextComponent.is() )
+ {
+ DBG_TRACE( "FmTextControlShell::ClipBoard: starting timer for clipboard invalidation" );
+ m_aClipboardInvalidation.Start();
+ }
+
+ m_bActiveControl = true;
+
+ m_rBindings.Invalidate( pTextControlSlots );
+
+ if ( m_pViewFrame )
+ m_pViewFrame->UIFeatureChanged();
+
+ // don't call the activation handler if we don't have any slots we can serve
+ // The activation handler is used to put the shell on the top of the dispatcher stack,
+ // so it's preferred when slots are distributed.
+ // Note that this is a slight hack, to prevent that we grab slots from the SfxDispatcher
+ // which should be served by other shells (e.g. Cut/Copy/Paste).
+ // A real solution would be a forwarding-mechanism for slots: We should be on the top
+ // if we're active, but if we cannot handle the slot, then we need to tell the dispatcher
+ // to skip our shell, and pass the slot to the next one. However, this mechanism is not
+ // not in place in SFX.
+ // Another possibility would be to have dedicated shells for the slots which we might
+ // or might not be able to serve. However, this could probably increase the number of
+ // shells too much (In theory, nearly every slot could have an own shell then).
+ //
+ // #i51621# / 2005-08-19 / frank.schoenheit@sun.com
+ bool bHaveAnyServeableSlots = m_xActiveTextComponent.is() || !m_aControlFeatures.empty();
+ if ( m_aControlActivationHandler.IsSet() && bHaveAnyServeableSlots )
+ m_aControlActivationHandler.Call( NULL );
+
+ m_bNeedClipboardInvalidation = true;
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::fillFeatureDispatchers( const Reference< XControl > _rxControl, SfxSlotId* _pZeroTerminatedSlots,
+ ControlFeatures& _rDispatchers )
+ {
+ Reference< XDispatchProvider > xProvider( _rxControl, UNO_QUERY );
+ SfxApplication* pApplication = SFX_APP();
+ DBG_ASSERT( pApplication, "FmTextControlShell::fillFeatureDispatchers: no SfxApplication!" );
+ if ( xProvider.is() && pApplication )
+ {
+ SfxSlotId* pSlots = _pZeroTerminatedSlots;
+ while ( *pSlots )
+ {
+ FmTextControlFeature* pDispatcher = implGetFeatureDispatcher( xProvider, pApplication, *pSlots );
+ if ( pDispatcher )
+ _rDispatchers.insert( ControlFeatures::value_type( *pSlots, ControlFeature( pDispatcher ) ) );
+
+ ++pSlots;
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::impl_parseURL_nothrow( URL& _rURL )
+ {
+ try
+ {
+ if ( !m_xURLTransformer.is() )
+ {
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ aContext.createComponent( "com.sun.star.util.URLTransformer", m_xURLTransformer );
+ }
+ if ( m_xURLTransformer.is() )
+ m_xURLTransformer->parseStrict( _rURL );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ FmTextControlFeature* FmTextControlShell::implGetFeatureDispatcher( const Reference< XDispatchProvider >& _rxProvider, SfxApplication* _pApplication, SfxSlotId _nSlot )
+ {
+ OSL_PRECOND( _rxProvider.is() && _pApplication, "FmTextControlShell::implGetFeatureDispatcher: invalid arg(s)!" );
+ URL aFeatureURL;
+ aFeatureURL.Complete = lcl_getUnoSlotName( *_pApplication, _nSlot );
+ impl_parseURL_nothrow( aFeatureURL );
+ Reference< XDispatch > xDispatcher = _rxProvider->queryDispatch( aFeatureURL, ::rtl::OUString(), 0xFF );
+ if ( xDispatcher.is() )
+ return new FmTextControlFeature( xDispatcher, aFeatureURL, _nSlot, this );
+ return NULL;
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::Invalidate( SfxSlotId _nSlot )
+ {
+ m_rBindings.Invalidate( _nSlot );
+ // despite this method being called "Invalidate", we also update here - this gives more immediate
+ // feedback in the UI
+ m_rBindings.Update( _nSlot );
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::focusGained( const ::com::sun::star::awt::FocusEvent& _rEvent )
+ {
+ Reference< XControl > xControl( _rEvent.Source, UNO_QUERY );
+
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sTrace( "FmTextControlShell::focusGained: 0x" );
+ sTrace += ::rtl::OString::valueOf( (sal_IntPtr)xControl.get(), 16 );
+ DBG_TRACE( sTrace );
+#endif
+
+ DBG_ASSERT( xControl.is(), "FmTextControlShell::focusGained: suspicious focus event!" );
+ if ( xControl.is() )
+ controlActivated( xControl );
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::focusLost( const ::com::sun::star::awt::FocusEvent& _rEvent )
+ {
+ Reference< XControl > xControl( _rEvent.Source, UNO_QUERY );
+
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sTrace( "FmTextControlShell::focusLost: 0x" );
+ sTrace += ::rtl::OString::valueOf( (sal_IntPtr)xControl.get(), 16 );
+ DBG_TRACE( sTrace );
+#endif
+
+ m_bActiveControl = false;
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::ForgetActiveControl()
+ {
+ implClearActiveControlRef();
+ }
+
+ //------------------------------------------------------------------------
+ void FmTextControlShell::contextMenuRequested( const awt::MouseEvent& /*_rEvent*/ )
+ {
+ m_rBindings.GetDispatcher()->ExecutePopup( SVX_RES( RID_FM_TEXTATTRIBUTE_MENU ) );
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmtools.cxx b/svx/source/form/fmtools.cxx
new file mode 100644
index 000000000000..34df23860f79
--- /dev/null
+++ b/svx/source/form/fmtools.cxx
@@ -0,0 +1,498 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmprop.hrc"
+#include "fmservs.hxx"
+#include "svx/fmtools.hxx"
+#include "svx/dbtoolsclient.hxx"
+#include "svx/fmglob.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/LineEndFormat.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XResultSetAccess.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/util/Language.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/util/XNumberFormats.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+/** === end UNO includes === **/
+
+#include <basic/sbxvar.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <comphelper/container.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/uno3.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/logfile.hxx>
+#include <rtl/math.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <toolkit/unohlp.hxx>
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <vcl/stdtext.hxx>
+#include <vcl/svapp.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::form;
+using namespace ::svxform;
+using namespace ::connectivity::simple;
+
+// ------------------------------------------------------------------------------
+namespace
+{
+ static bool lcl_shouldDisplayError( const Any& _rError )
+ {
+ SQLException aError;
+ if ( !( _rError >>= aError ) )
+ return true;
+
+ if ( aError.Message.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "[OOoBase]" ) ) != 0 )
+ // it is an exception *not* thrown by an OOo Base core component
+ return true;
+
+ // the only exception we do not display ATM is a RowSetVetoException, which
+ // has been raised because an XRowSetApprovalListener vetoed a change
+ if ( aError.ErrorCode + ErrorCondition::ROW_SET_OPERATION_VETOED == 0 )
+ return false;
+
+ // everything else is to be displayed
+ return true;
+ }
+}
+
+// ------------------------------------------------------------------------------
+void displayException(const Any& _rExcept, Window* _pParent)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::displayException" );
+ // check whether we need to display it
+ if ( !lcl_shouldDisplayError( _rExcept ) )
+ return;
+
+ try
+ {
+ // the parent window
+ Window* pParentWindow = _pParent ? _pParent : GetpApp()->GetDefDialogParent();
+ Reference< XWindow > xParentWindow = VCLUnoHelper::GetInterface(pParentWindow);
+
+ Sequence< Any > aArgs(2);
+ aArgs[0] <<= PropertyValue(::rtl::OUString::createFromAscii("SQLException"), 0, _rExcept, PropertyState_DIRECT_VALUE);
+ aArgs[1] <<= PropertyValue(::rtl::OUString::createFromAscii("ParentWindow"), 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE);
+
+ static ::rtl::OUString s_sDialogServiceName = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ErrorMessageDialog");
+ Reference< XExecutableDialog > xErrorDialog(
+ ::comphelper::getProcessServiceFactory()->createInstanceWithArguments(s_sDialogServiceName, aArgs), UNO_QUERY);
+ if (xErrorDialog.is())
+ xErrorDialog->execute();
+ else
+ ShowServiceNotAvailableError(pParentWindow, s_sDialogServiceName, sal_True);
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE(sal_False, "displayException: could not display the error message!");
+ }
+}
+
+// ------------------------------------------------------------------------------
+void displayException(const ::com::sun::star::sdbc::SQLException& _rExcept, Window* _pParent)
+{
+ displayException(makeAny(_rExcept), _pParent);
+}
+
+// ------------------------------------------------------------------------------
+void displayException(const ::com::sun::star::sdbc::SQLWarning& _rExcept, Window* _pParent)
+{
+ displayException(makeAny(_rExcept), _pParent);
+}
+
+// ------------------------------------------------------------------------------
+void displayException(const ::com::sun::star::sdb::SQLContext& _rExcept, Window* _pParent)
+{
+ displayException(makeAny(_rExcept), _pParent);
+}
+
+// ------------------------------------------------------------------------------
+void displayException(const ::com::sun::star::sdb::SQLErrorEvent& _rEvent, Window* _pParent)
+{
+ displayException(_rEvent.Reason, _pParent);
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 getElementPos(const Reference< ::com::sun::star::container::XIndexAccess>& xCont, const Reference< XInterface >& xElement)
+{
+ sal_Int32 nIndex = -1;
+ if (!xCont.is())
+ return nIndex;
+
+
+ Reference< XInterface > xNormalized( xElement, UNO_QUERY );
+ DBG_ASSERT( xNormalized.is(), "getElementPos: invalid element!" );
+ if ( xNormalized.is() )
+ {
+ // Feststellen an welcher Position sich das Kind befindet
+ nIndex = xCont->getCount();
+ while (nIndex--)
+ {
+ try
+ {
+ Reference< XInterface > xCurrent(xCont->getByIndex( nIndex ),UNO_QUERY);
+ DBG_ASSERT( xCurrent.get() == Reference< XInterface >( xCurrent, UNO_QUERY ).get(),
+ "getElementPos: container element not normalized!" );
+ if ( xNormalized.get() == xCurrent.get() )
+ break;
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR( "getElementPos: caught an exception!" );
+ }
+
+ }
+ }
+ return nIndex;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString getLabelName(const Reference< ::com::sun::star::beans::XPropertySet>& xControlModel)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getLabelName" );
+ if (!xControlModel.is())
+ return ::rtl::OUString();
+
+ if (::comphelper::hasProperty(FM_PROP_CONTROLLABEL, xControlModel))
+ {
+ Reference< ::com::sun::star::beans::XPropertySet> xLabelSet;
+ xControlModel->getPropertyValue(FM_PROP_CONTROLLABEL) >>= xLabelSet;
+ if (xLabelSet.is() && ::comphelper::hasProperty(FM_PROP_LABEL, xLabelSet))
+ {
+ Any aLabel( xLabelSet->getPropertyValue(FM_PROP_LABEL) );
+ if ((aLabel.getValueTypeClass() == TypeClass_STRING) && ::comphelper::getString(aLabel).getLength())
+ return ::comphelper::getString(aLabel);
+ }
+ }
+
+ return ::comphelper::getString(xControlModel->getPropertyValue(FM_PROP_CONTROLSOURCE));
+}
+
+//========================================================================
+// = CursorWrapper
+//------------------------------------------------------------------------
+CursorWrapper::CursorWrapper(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxCursor, sal_Bool bUseCloned)
+{
+ ImplConstruct(Reference< ::com::sun::star::sdbc::XResultSet>(_rxCursor, UNO_QUERY), bUseCloned);
+}
+
+//------------------------------------------------------------------------
+CursorWrapper::CursorWrapper(const Reference< ::com::sun::star::sdbc::XResultSet>& _rxCursor, sal_Bool bUseCloned)
+{
+ ImplConstruct(_rxCursor, bUseCloned);
+}
+
+//------------------------------------------------------------------------
+void CursorWrapper::ImplConstruct(const Reference< ::com::sun::star::sdbc::XResultSet>& _rxCursor, sal_Bool bUseCloned)
+{
+ if (bUseCloned)
+ {
+ Reference< ::com::sun::star::sdb::XResultSetAccess> xAccess(_rxCursor, UNO_QUERY);
+ try
+ {
+ m_xMoveOperations = xAccess.is() ? xAccess->createResultSet() : Reference< ::com::sun::star::sdbc::XResultSet>();
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ else
+ m_xMoveOperations = _rxCursor;
+
+ m_xBookmarkOperations = m_xBookmarkOperations.query( m_xMoveOperations );
+ m_xColumnsSupplier = m_xColumnsSupplier.query( m_xMoveOperations );
+ m_xPropertyAccess = m_xPropertyAccess.query( m_xMoveOperations );
+
+ if ( !m_xMoveOperations.is() || !m_xBookmarkOperations.is() || !m_xColumnsSupplier.is() || !m_xPropertyAccess.is() )
+ { // all or nothing !!
+ m_xMoveOperations = NULL;
+ m_xBookmarkOperations = NULL;
+ m_xColumnsSupplier = NULL;
+ }
+ else
+ m_xGeneric = m_xMoveOperations.get();
+}
+
+//------------------------------------------------------------------------
+const CursorWrapper& CursorWrapper::operator=(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxCursor)
+{
+ m_xMoveOperations = Reference< ::com::sun::star::sdbc::XResultSet>(_rxCursor, UNO_QUERY);
+ m_xBookmarkOperations = Reference< ::com::sun::star::sdbcx::XRowLocate>(_rxCursor, UNO_QUERY);
+ m_xColumnsSupplier = Reference< ::com::sun::star::sdbcx::XColumnsSupplier>(_rxCursor, UNO_QUERY);
+ if (!m_xMoveOperations.is() || !m_xBookmarkOperations.is() || !m_xColumnsSupplier.is())
+ { // all or nothing !!
+ m_xMoveOperations = NULL;
+ m_xBookmarkOperations = NULL;
+ m_xColumnsSupplier = NULL;
+ }
+ return *this;
+}
+
+//------------------------------------------------------------------------------
+FmXDisposeListener::~FmXDisposeListener()
+{
+ setAdapter(NULL);
+}
+
+//------------------------------------------------------------------------------
+void FmXDisposeListener::setAdapter(FmXDisposeMultiplexer* pAdapter)
+{
+ if (m_pAdapter)
+ {
+ ::osl::MutexGuard aGuard(m_rMutex);
+ m_pAdapter->release();
+ m_pAdapter = NULL;
+ }
+
+ if (pAdapter)
+ {
+ ::osl::MutexGuard aGuard(m_rMutex);
+ m_pAdapter = pAdapter;
+ m_pAdapter->acquire();
+ }
+}
+
+//==============================================================================
+DBG_NAME(FmXDisposeMultiplexer);
+//------------------------------------------------------------------------------
+FmXDisposeMultiplexer::FmXDisposeMultiplexer(FmXDisposeListener* _pListener, const Reference< ::com::sun::star::lang::XComponent>& _rxObject, sal_Int16 _nId)
+ :m_xObject(_rxObject)
+ ,m_pListener(_pListener)
+ ,m_nId(_nId)
+{
+ DBG_CTOR(FmXDisposeMultiplexer, NULL);
+ m_pListener->setAdapter(this);
+
+ if (m_xObject.is())
+ m_xObject->addEventListener(this);
+}
+
+//------------------------------------------------------------------------------
+FmXDisposeMultiplexer::~FmXDisposeMultiplexer()
+{
+ DBG_DTOR(FmXDisposeMultiplexer, NULL);
+}
+
+// ::com::sun::star::lang::XEventListener
+//------------------------------------------------------------------
+void FmXDisposeMultiplexer::disposing(const ::com::sun::star::lang::EventObject& _Source) throw( RuntimeException )
+{
+ Reference< ::com::sun::star::lang::XEventListener> xPreventDelete(this);
+
+ if (m_pListener)
+ {
+ m_pListener->disposing(_Source, m_nId);
+ m_pListener->setAdapter(NULL);
+ m_pListener = NULL;
+ }
+ m_xObject = NULL;
+}
+
+//------------------------------------------------------------------
+void FmXDisposeMultiplexer::dispose()
+{
+ if (m_xObject.is())
+ {
+ Reference< ::com::sun::star::lang::XEventListener> xPreventDelete(this);
+
+ m_xObject->removeEventListener(this);
+ m_xObject = NULL;
+
+ m_pListener->setAdapter(NULL);
+ m_pListener = NULL;
+ }
+}
+
+//==============================================================================
+//------------------------------------------------------------------------------
+sal_Int16 getControlTypeByObject(const Reference< ::com::sun::star::lang::XServiceInfo>& _rxObject)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getControlTypeByObject" );
+ // ask for the persistent service name
+ Reference< ::com::sun::star::io::XPersistObject> xPersistence(_rxObject, UNO_QUERY);
+ DBG_ASSERT(xPersistence.is(), "::getControlTypeByObject : argument shold be an ::com::sun::star::io::XPersistObject !");
+ if (!xPersistence.is())
+ return OBJ_FM_CONTROL;
+
+ ::rtl::OUString sPersistentServiceName = xPersistence->getServiceName();
+ if (sPersistentServiceName.equals(FM_COMPONENT_EDIT)) // 5.0-Name
+ {
+ // may be a simple edit field or a formatted field, dependent of the supported services
+ if (_rxObject->supportsService(FM_SUN_COMPONENT_FORMATTEDFIELD))
+ return OBJ_FM_FORMATTEDFIELD;
+ return OBJ_FM_EDIT;
+ }
+ if (sPersistentServiceName.equals(FM_COMPONENT_TEXTFIELD))
+ return OBJ_FM_EDIT;
+ if (sPersistentServiceName.equals(FM_COMPONENT_COMMANDBUTTON))
+ return OBJ_FM_BUTTON;
+ if (sPersistentServiceName.equals(FM_COMPONENT_FIXEDTEXT))
+ return OBJ_FM_FIXEDTEXT;
+ if (sPersistentServiceName.equals(FM_COMPONENT_LISTBOX))
+ return OBJ_FM_LISTBOX;
+ if (sPersistentServiceName.equals(FM_COMPONENT_CHECKBOX))
+ return OBJ_FM_CHECKBOX;
+ if (sPersistentServiceName.equals(FM_COMPONENT_RADIOBUTTON))
+ return OBJ_FM_RADIOBUTTON;
+ if (sPersistentServiceName.equals(FM_COMPONENT_GROUPBOX))
+ return OBJ_FM_GROUPBOX;
+ if (sPersistentServiceName.equals(FM_COMPONENT_COMBOBOX))
+ return OBJ_FM_COMBOBOX;
+ if (sPersistentServiceName.equals(FM_COMPONENT_GRID)) // 5.0-Name
+ return OBJ_FM_GRID;
+ if (sPersistentServiceName.equals(FM_COMPONENT_GRIDCONTROL))
+ return OBJ_FM_GRID;
+ if (sPersistentServiceName.equals(FM_COMPONENT_IMAGEBUTTON))
+ return OBJ_FM_IMAGEBUTTON;
+ if (sPersistentServiceName.equals(FM_COMPONENT_FILECONTROL))
+ return OBJ_FM_FILECONTROL;
+ if (sPersistentServiceName.equals(FM_COMPONENT_DATEFIELD))
+ return OBJ_FM_DATEFIELD;
+ if (sPersistentServiceName.equals(FM_COMPONENT_TIMEFIELD))
+ return OBJ_FM_TIMEFIELD;
+ if (sPersistentServiceName.equals(FM_COMPONENT_NUMERICFIELD))
+ return OBJ_FM_NUMERICFIELD;
+ if (sPersistentServiceName.equals(FM_COMPONENT_CURRENCYFIELD))
+ return OBJ_FM_CURRENCYFIELD;
+ if (sPersistentServiceName.equals(FM_COMPONENT_PATTERNFIELD))
+ return OBJ_FM_PATTERNFIELD;
+ if (sPersistentServiceName.equals(FM_COMPONENT_HIDDEN)) // 5.0-Name
+ return OBJ_FM_HIDDEN;
+ if (sPersistentServiceName.equals(FM_COMPONENT_HIDDENCONTROL))
+ return OBJ_FM_HIDDEN;
+ if (sPersistentServiceName.equals(FM_COMPONENT_IMAGECONTROL))
+ return OBJ_FM_IMAGECONTROL;
+ if (sPersistentServiceName.equals(FM_COMPONENT_FORMATTEDFIELD))
+ {
+ DBG_ERROR("::getControlTypeByObject : suspicious persistent service name (formatted field) !");
+ // objects with that service name should exist as they aren't compatible with older versions
+ return OBJ_FM_FORMATTEDFIELD;
+ }
+ if ( sPersistentServiceName.equals( FM_SUN_COMPONENT_SCROLLBAR ) )
+ return OBJ_FM_SCROLLBAR;
+ if ( sPersistentServiceName.equals( FM_SUN_COMPONENT_SPINBUTTON) )
+ return OBJ_FM_SPINBUTTON;
+ if (sPersistentServiceName.equals(FM_SUN_COMPONENT_NAVIGATIONBAR))
+ return OBJ_FM_NAVIGATIONBAR;
+
+ DBG_ERROR("::getControlTypeByObject : unknown object type !");
+ return OBJ_FM_CONTROL;
+}
+
+//------------------------------------------------------------------------------
+void setConnection(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, const Reference< ::com::sun::star::sdbc::XConnection>& _rxConn)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::setConnection" );
+ Reference< ::com::sun::star::beans::XPropertySet> xRowSetProps(_rxRowSet, UNO_QUERY);
+ if (xRowSetProps.is())
+ {
+ try
+ {
+ Any aConn(makeAny(_rxConn));
+ xRowSetProps->setPropertyValue(FM_PROP_ACTIVE_CONNECTION, aConn);
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("::setConnection : could not set the connection !");
+ }
+
+ }
+}
+//------------------------------------------------------------------------------
+sal_Bool isRowSetAlive(const Reference< XInterface >& _rxRowSet)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::isRowSetAlive" );
+ sal_Bool bIsAlive = sal_False;
+ Reference< ::com::sun::star::sdbcx::XColumnsSupplier> xSupplyCols(_rxRowSet, UNO_QUERY);
+ Reference< ::com::sun::star::container::XIndexAccess> xCols;
+ if (xSupplyCols.is())
+ xCols = Reference< ::com::sun::star::container::XIndexAccess>(xSupplyCols->getColumns(), UNO_QUERY);
+ if (xCols.is() && (xCols->getCount() > 0))
+ bIsAlive = sal_True;
+
+ return bIsAlive;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx
new file mode 100644
index 000000000000..0fdd52ae5b36
--- /dev/null
+++ b/svx/source/form/fmundo.cxx
@@ -0,0 +1,1350 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+#include "fmundo.hxx"
+#include "fmpgeimp.hxx"
+#include "svx/dbtoolsclient.hxx"
+#include "svditer.hxx"
+#include "fmobj.hxx"
+#include "fmprop.hrc"
+#include "fmresids.hrc"
+#include "svx/fmglob.hxx"
+#include "svx/dialmgr.hxx"
+#include "svx/fmmodel.hxx"
+#include "svx/fmpage.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/binding/XListEntrySink.hpp>
+#include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
+/** === end UNO includes === **/
+
+#include "svx/fmtools.hxx"
+#include <rtl/logfile.hxx>
+#include <svl/macitem.hxx>
+#include <tools/shl.hxx>
+#include <tools/diagnose_ex.h>
+#include <sfx2/objsh.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/sfx.hrc>
+#include <sfx2/event.hxx>
+#include <osl/mutex.hxx>
+#include <osl/mutex.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/stl_types.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::script;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::reflection;
+using namespace ::com::sun::star::form::binding;
+using namespace ::svxform;
+
+
+#include <com/sun/star/script/XScriptListener.hdl>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+typedef cppu::WeakImplHelper1< XScriptListener > ScriptEventListener_BASE;
+class ScriptEventListenerWrapper : public ScriptEventListener_BASE
+{
+public:
+ ScriptEventListenerWrapper( FmFormModel& _rModel) throw ( RuntimeException ) : pModel(&_rModel)
+ {
+
+ }
+ // XEventListener
+ virtual void SAL_CALL disposing(const EventObject& ) throw( RuntimeException ){}
+
+ // XScriptListener
+ virtual void SAL_CALL firing(const ScriptEvent& evt) throw(RuntimeException)
+ {
+ setModel();
+ if ( m_vbaListener.is() )
+ {
+ m_vbaListener->firing( evt );
+ }
+ }
+
+ virtual Any SAL_CALL approveFiring(const ScriptEvent& evt) throw( com::sun::star::reflection::InvocationTargetException, RuntimeException)
+ {
+ setModel();
+ if ( m_vbaListener.is() )
+ {
+ return m_vbaListener->approveFiring( evt );
+ }
+ return Any();
+ }
+
+private:
+ void setModel()
+ {
+ if ( !m_vbaListener.is() )
+ {
+ Reference < XPropertySet > xProps(
+ ::comphelper::getProcessServiceFactory(), UNO_QUERY );
+ if ( xProps.is() )
+ {
+ Reference< XComponentContext > xCtx( xProps->getPropertyValue(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY );
+ if ( xCtx.is() )
+ {
+ Reference< XMultiComponentFactory > xMFac(
+ xCtx->getServiceManager(), UNO_QUERY );
+ SfxObjectShellRef xObjSh = pModel->GetObjectShell();
+ Reference< XMultiServiceFactory > xDocFac;
+ if ( xObjSh.Is() )
+ xDocFac.set( xObjSh->GetModel(), UNO_QUERY );
+
+ if ( xMFac.is() )
+ {
+ m_vbaListener.set( xMFac->createInstanceWithContext(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "ooo.vba.EventListener" ) ), xCtx ),
+ UNO_QUERY_THROW );
+ }
+ }
+ }
+ }
+ Reference< XPropertySet > xProps( m_vbaListener, UNO_QUERY );
+ if ( xProps.is() )
+ {
+ try
+ {
+ SfxObjectShellRef xObjSh = pModel->GetObjectShell();
+ if ( xObjSh.Is() && m_vbaListener.is() )
+ {
+ Any aVal;
+ aVal <<= xObjSh->GetModel();
+ xProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Model" ) ),
+ aVal );
+ }
+ }
+ catch( Exception& )
+ {
+ //swallow any errors
+ }
+ }
+ }
+ FmFormModel* pModel;
+ Reference< XScriptListener > m_vbaListener;
+
+
+};
+
+//------------------------------------------------------------------------------
+// some helper structs for caching property infos
+//------------------------------------------------------------------------------
+struct PropertyInfo
+{
+ BOOL bIsTransientOrReadOnly : 1; // the property is transient or read-only, thus we need no undo action for it
+ BOOL bIsValueProperty : 1; // the property is the special value property, thus it may be handled
+ // as if it's transient or persistent
+};
+
+struct PropertySetInfo
+{
+ DECLARE_STL_USTRINGACCESS_MAP(PropertyInfo, AllProperties);
+
+ AllProperties aProps; // all properties of this set which we know so far
+ BOOL bHasEmptyControlSource; // sal_True -> the set has a DataField property, and the current value is an empty string
+ // sal_False -> the set has _no_ such property or it's value isn't empty
+};
+
+BOOL operator < (const Reference< XPropertySet >& lhs,
+ const Reference< XPropertySet >& rhs)
+{
+ return lhs.get() < rhs.get();
+}
+
+DECLARE_STL_STDKEY_MAP(Reference< XPropertySet >, PropertySetInfo, PropertySetInfoCache);
+
+//------------------------------------------------------------------------------
+
+String static_STR_UNDO_PROPERTY;
+//------------------------------------------------------------------------------
+DBG_NAME(FmXUndoEnvironment)
+//------------------------------------------------------------------------------
+FmXUndoEnvironment::FmXUndoEnvironment(FmFormModel& _rModel)
+ :rModel( _rModel )
+ ,m_pPropertySetCache( NULL )
+ ,m_pScriptingEnv( ::svxform::createDefaultFormScriptingEnvironment( _rModel ) )
+ ,m_Locks( 0 )
+ ,bReadOnly( sal_False )
+ ,m_bDisposed( false )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::FmXUndoEnvironment" );
+ DBG_CTOR(FmXUndoEnvironment,NULL);
+ try
+ {
+ m_vbaListener = new ScriptEventListenerWrapper( _rModel );
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+//------------------------------------------------------------------------------
+FmXUndoEnvironment::~FmXUndoEnvironment()
+{
+ DBG_DTOR(FmXUndoEnvironment,NULL);
+ if (m_pPropertySetCache)
+ delete static_cast<PropertySetInfoCache*>(m_pPropertySetCache);
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::dispose()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::dispose" );
+ OSL_ENSURE( !m_bDisposed, "FmXUndoEnvironment::dispose: disposed twice?" );
+ if ( !m_bDisposed )
+ return;
+
+ Lock();
+
+ sal_uInt16 nCount = rModel.GetPageCount();
+ sal_uInt16 i;
+ for (i = 0; i < nCount; i++)
+ {
+ FmFormPage* pPage = PTR_CAST( FmFormPage, rModel.GetPage(i) );
+ if ( pPage )
+ {
+ Reference< XInterface > xForms = pPage->GetForms( false ).get();
+ if ( xForms.is() )
+ RemoveElement( xForms );
+ }
+ }
+
+ nCount = rModel.GetMasterPageCount();
+ for (i = 0; i < nCount; i++)
+ {
+ FmFormPage* pPage = PTR_CAST( FmFormPage, rModel.GetMasterPage(i) );
+ if ( pPage )
+ {
+ Reference< XInterface > xForms = pPage->GetForms( false ).get();
+ if ( xForms.is() )
+ RemoveElement( xForms );
+ }
+ }
+
+ UnLock();
+
+ OSL_PRECOND( rModel.GetObjectShell(), "FmXUndoEnvironment::dispose: no object shell anymore!" );
+ if ( rModel.GetObjectShell() )
+ EndListening( *rModel.GetObjectShell() );
+
+ if ( IsListening( rModel ) )
+ EndListening( rModel );
+
+ m_pScriptingEnv->dispose();
+
+ m_bDisposed = true;
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::ModeChanged()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::ModeChanged" );
+ OSL_PRECOND( rModel.GetObjectShell(), "FmXUndoEnvironment::ModeChanged: no object shell anymore!" );
+ if ( !rModel.GetObjectShell() )
+ return;
+
+ if (bReadOnly != (rModel.GetObjectShell()->IsReadOnly() || rModel.GetObjectShell()->IsReadOnlyUI()))
+ {
+ bReadOnly = !bReadOnly;
+
+ sal_uInt16 nCount = rModel.GetPageCount();
+ sal_uInt16 i;
+ for (i = 0; i < nCount; i++)
+ {
+ FmFormPage* pPage = PTR_CAST( FmFormPage, rModel.GetPage(i) );
+ if ( pPage )
+ {
+ Reference< XInterface > xForms = pPage->GetForms( false ).get();
+ if ( xForms.is() )
+ TogglePropertyListening( xForms );
+ }
+ }
+
+ nCount = rModel.GetMasterPageCount();
+ for (i = 0; i < nCount; i++)
+ {
+ FmFormPage* pPage = PTR_CAST( FmFormPage, rModel.GetMasterPage(i) );
+ if ( pPage )
+ {
+ Reference< XInterface > xForms = pPage->GetForms( false ).get();
+ if ( xForms.is() )
+ TogglePropertyListening( xForms );
+ }
+ }
+
+ if (!bReadOnly)
+ StartListening(rModel);
+ else
+ EndListening(rModel);
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::Notify" );
+ if (rHint.ISA(SdrHint))
+ {
+ SdrHint* pSdrHint = (SdrHint*)&rHint;
+ switch( pSdrHint->GetKind() )
+ {
+ case HINT_OBJINSERTED:
+ {
+ SdrObject* pSdrObj = (SdrObject*)pSdrHint->GetObject();
+ Inserted( pSdrObj );
+ } break;
+ case HINT_OBJREMOVED:
+ {
+ SdrObject* pSdrObj = (SdrObject*)pSdrHint->GetObject();
+ Removed( pSdrObj );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ else if (rHint.ISA(SfxSimpleHint))
+ {
+ switch ( ((SfxSimpleHint&)rHint).GetId() )
+ {
+ case SFX_HINT_DYING:
+ dispose();
+ rModel.SetObjectShell( NULL );
+ break;
+ case SFX_HINT_MODECHANGED:
+ ModeChanged();
+ break;
+ }
+ }
+ else if (rHint.ISA(SfxEventHint))
+ {
+ switch (((SfxEventHint&)rHint).GetEventId())
+ {
+ case SFX_EVENT_CREATEDOC:
+ case SFX_EVENT_OPENDOC:
+ ModeChanged();
+ break;
+ }
+ }
+
+}
+
+//------------------------------------------------------------------
+void FmXUndoEnvironment::Inserted(SdrObject* pObj)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::Inserted" );
+ if (pObj->GetObjInventor() == FmFormInventor)
+ {
+ FmFormObj* pFormObj = PTR_CAST(FmFormObj, pObj);
+ Inserted( pFormObj );
+ }
+ else if (pObj->IsGroupObject())
+ {
+ SdrObjListIter aIter(*pObj->GetSubList());
+ while ( aIter.IsMore() )
+ Inserted( aIter.Next() );
+ }
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ sal_Bool lcl_searchElement(const Reference< XIndexAccess>& xCont, const Reference< XInterface >& xElement)
+ {
+ if (!xCont.is() || !xElement.is())
+ return sal_False;
+
+ sal_Int32 nCount = xCont->getCount();
+ Reference< XInterface > xComp;
+ for (sal_Int32 i = 0; i < nCount; i++)
+ {
+ try
+ {
+ xCont->getByIndex(i) >>= xComp;
+ if (xComp.is())
+ {
+ if ( xElement == xComp )
+ return sal_True;
+ else
+ {
+ Reference< XIndexAccess> xCont2(xComp, UNO_QUERY);
+ if (xCont2.is() && lcl_searchElement(xCont2, xElement))
+ return sal_True;
+ }
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return sal_False;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::Inserted(FmFormObj* pObj)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::Inserted" );
+ DBG_ASSERT( pObj, "FmXUndoEnvironment::Inserted: invalid object!" );
+ if ( !pObj )
+ return;
+
+ // ist das Control noch einer Form zugeordnet
+ Reference< XInterface > xModel(pObj->GetUnoControlModel(), UNO_QUERY);
+ Reference< XFormComponent > xContent(xModel, UNO_QUERY);
+ if (xContent.is() && pObj->GetPage())
+ {
+ // if the component doesn't belong to a form, yet, find one to insert into
+ if (!xContent->getParent().is())
+ {
+ try
+ {
+ Reference< XIndexContainer > xObjectParent = pObj->GetOriginalParent();
+
+ FmFormPage& rPage = dynamic_cast< FmFormPage& >( *pObj->GetPage() );
+ Reference< XIndexAccess > xForms( rPage.GetForms(), UNO_QUERY_THROW );
+
+ Reference< XIndexContainer > xNewParent;
+ Reference< XForm > xForm;
+ sal_Int32 nPos = -1;
+ if ( lcl_searchElement( xForms, xObjectParent ) )
+ {
+ // the form which was the parent of the object when it was removed is still
+ // part of the form component hierachy of the current page
+ xNewParent = xObjectParent;
+ xForm.set( xNewParent, UNO_QUERY_THROW );
+ nPos = ::std::min( pObj->GetOriginalIndex(), xNewParent->getCount() );
+ }
+ else
+ {
+ xForm.set( rPage.GetImpl().findPlaceInFormComponentHierarchy( xContent ), UNO_SET_THROW );
+ xNewParent.set( xForm, UNO_QUERY_THROW );
+ nPos = xNewParent->getCount();
+ }
+
+ rPage.GetImpl().setUniqueName( xContent, xForm );
+ xNewParent->insertByIndex( nPos, makeAny( xContent ) );
+
+ Reference< XEventAttacherManager > xManager( xNewParent, UNO_QUERY_THROW );
+ xManager->registerScriptEvents( nPos, pObj->GetOriginalEvents() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // FormObject zuruecksetzen
+ pObj->ClearObjEnv();
+ }
+}
+
+//------------------------------------------------------------------
+void FmXUndoEnvironment::Removed(SdrObject* pObj)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::Removed" );
+ if ( pObj->IsVirtualObj() )
+ // for virtual objects, we've already been notified of the removal of the master
+ // object, which is sufficient here
+ return;
+
+ if (pObj->GetObjInventor() == FmFormInventor)
+ {
+ FmFormObj* pFormObj = PTR_CAST(FmFormObj, pObj);
+ Removed(pFormObj);
+ }
+ else if (pObj->IsGroupObject())
+ {
+ SdrObjListIter aIter(*pObj->GetSubList());
+ while ( aIter.IsMore() )
+ Removed( aIter.Next() );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::Removed(FmFormObj* pObj)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::Removed" );
+ DBG_ASSERT( pObj, "FmXUndoEnvironment::Removed: invalid object!" );
+ if ( !pObj )
+ return;
+
+ // ist das Control noch einer Form zugeordnet
+ Reference< XFormComponent > xContent(pObj->GetUnoControlModel(), UNO_QUERY);
+ if (xContent.is())
+ {
+ // das Object wird aus einer Liste herausgenommen
+ // existiert ein Vater wird das Object beim beim Vater entfernt und
+ // am FormObject gemerkt!
+
+ // wird das Object wieder eingefuegt und ein Parent existiert, so wird dieser
+ // Parent wiederum gesetzt
+ Reference< XIndexContainer > xForm(xContent->getParent(), UNO_QUERY);
+ if (xForm.is())
+ {
+ Reference< XIndexAccess > xIndexAccess((XIndexContainer*)xForm.get());
+ // Feststellen an welcher Position sich das Kind befunden hat
+ const sal_Int32 nPos = getElementPos(xIndexAccess, xContent);
+ if (nPos >= 0)
+ {
+ Sequence< ScriptEventDescriptor > aEvts;
+ Reference< XEventAttacherManager > xManager(xForm, UNO_QUERY);
+ if (xManager.is())
+ aEvts = xManager->getScriptEvents(nPos);
+
+ try
+ {
+ pObj->SetObjEnv(xForm, nPos, aEvts);
+ xForm->removeByIndex(nPos);
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ }
+ }
+ }
+}
+
+// XEventListener
+//------------------------------------------------------------------------------
+void SAL_CALL FmXUndoEnvironment::disposing(const EventObject& e) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::disposing" );
+ // check if it's an object we have cached informations about
+ if (m_pPropertySetCache)
+ {
+ Reference< XPropertySet > xSourceSet(e.Source, UNO_QUERY);
+ if (xSourceSet.is())
+ {
+ PropertySetInfoCache* pCache = static_cast<PropertySetInfoCache*>(m_pPropertySetCache);
+ PropertySetInfoCacheIterator aSetPos = pCache->find(xSourceSet);
+ if (aSetPos != pCache->end())
+ pCache->erase(aSetPos);
+ }
+ }
+}
+
+// XPropertyChangeListener
+//------------------------------------------------------------------------------
+void SAL_CALL FmXUndoEnvironment::propertyChange(const PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::propertyChange" );
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ if (!IsLocked())
+ {
+ Reference< XPropertySet > xSet(evt.Source, UNO_QUERY);
+ if (!xSet.is())
+ return;
+
+ // if it's a "default value" property of a control model, set the according "value" property
+ static ::rtl::OUString pDefaultValueProperties[] = {
+ FM_PROP_DEFAULT_TEXT, FM_PROP_DEFAULTCHECKED, FM_PROP_DEFAULT_DATE, FM_PROP_DEFAULT_TIME,
+ FM_PROP_DEFAULT_VALUE, FM_PROP_DEFAULT_SELECT_SEQ, FM_PROP_EFFECTIVE_DEFAULT
+ };
+ const ::rtl::OUString aValueProperties[] = {
+ FM_PROP_TEXT, FM_PROP_STATE, FM_PROP_DATE, FM_PROP_TIME,
+ FM_PROP_VALUE, FM_PROP_SELECT_SEQ, FM_PROP_EFFECTIVE_VALUE
+ };
+ sal_Int32 nDefaultValueProps = SAL_N_ELEMENTS(pDefaultValueProperties);
+ OSL_ENSURE(SAL_N_ELEMENTS(aValueProperties) == nDefaultValueProps,
+ "FmXUndoEnvironment::propertyChange: inconsistence!");
+ for (sal_Int32 i=0; i<nDefaultValueProps; ++i)
+ {
+ if (0 == evt.PropertyName.compareTo(pDefaultValueProperties[i]))
+ {
+ try
+ {
+ xSet->setPropertyValue(aValueProperties[i], evt.NewValue);
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(sal_False, "FmXUndoEnvironment::propertyChange: could not adjust the value property!");
+ }
+ }
+ }
+
+ // no Undo for transient and readonly props. But unfortunately "transient" is not only that the
+ // "transient" flag is set for the property in question, instead is is somewhat more complex
+ // Transience criterions are:
+ // - the "transient" flag is set for the property
+ // - OR the control has a non-empty COntrolSource property, i.e. is intended to be bound
+ // to a database column. Note that it doesn't matter here whether the control actually
+ // *is* bound to a column
+ // - OR the control is bound to an external value via XBindableValue/XValueBinding
+ // which does not have a "ExternalData" property being <TRUE/>
+
+ if (!m_pPropertySetCache)
+ m_pPropertySetCache = new PropertySetInfoCache;
+ PropertySetInfoCache* pCache = static_cast<PropertySetInfoCache*>(m_pPropertySetCache);
+
+ // let's see if we know something about the set
+ PropertySetInfoCacheIterator aSetPos = pCache->find(xSet);
+ if (aSetPos == pCache->end())
+ {
+ PropertySetInfo aNewEntry;
+ if (!::comphelper::hasProperty(FM_PROP_CONTROLSOURCE, xSet))
+ {
+ aNewEntry.bHasEmptyControlSource = sal_False;
+ }
+ else
+ {
+ try
+ {
+ Any aCurrentControlSource = xSet->getPropertyValue(FM_PROP_CONTROLSOURCE);
+ aNewEntry.bHasEmptyControlSource = !aCurrentControlSource.hasValue() || (::comphelper::getString(aCurrentControlSource).getLength() == 0);
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ aSetPos = pCache->insert(PropertySetInfoCache::value_type(xSet,aNewEntry)).first;
+ DBG_ASSERT(aSetPos != pCache->end(), "FmXUndoEnvironment::propertyChange : just inserted it ... why it's not there ?");
+ }
+ else
+ { // is it the DataField property ?
+ if (evt.PropertyName.equals(FM_PROP_CONTROLSOURCE))
+ {
+ aSetPos->second.bHasEmptyControlSource = !evt.NewValue.hasValue() || (::comphelper::getString(evt.NewValue).getLength() == 0);
+ }
+ }
+
+ // now we have access to the cached info about the set
+ // let's see what we know about the property
+ PropertySetInfo::AllProperties& rPropInfos = aSetPos->second.aProps;
+ PropertySetInfo::AllPropertiesIterator aPropertyPos = rPropInfos.find(evt.PropertyName);
+ if (aPropertyPos == rPropInfos.end())
+ { // nothing 'til now ... have to change this ....
+ PropertyInfo aNewEntry;
+
+ // the attributes
+ INT32 nAttributes = xSet->getPropertySetInfo()->getPropertyByName(evt.PropertyName).Attributes;
+ aNewEntry.bIsTransientOrReadOnly = ((nAttributes & PropertyAttribute::READONLY) != 0) || ((nAttributes & PropertyAttribute::TRANSIENT) != 0);
+
+ // check if it is the special "DataFieldProperty"
+ aNewEntry.bIsValueProperty = sal_False;
+ try
+ {
+ if (::comphelper::hasProperty(FM_PROP_CONTROLSOURCEPROPERTY, xSet))
+ {
+ Any aControlSourceProperty = xSet->getPropertyValue(FM_PROP_CONTROLSOURCEPROPERTY);
+ ::rtl::OUString sControlSourceProperty;
+ aControlSourceProperty >>= sControlSourceProperty;
+
+ aNewEntry.bIsValueProperty = (sControlSourceProperty.equals(evt.PropertyName));
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // insert the new entry
+ aPropertyPos = rPropInfos.insert(PropertySetInfo::AllProperties::value_type(evt.PropertyName,aNewEntry)).first;
+ DBG_ASSERT(aPropertyPos != rPropInfos.end(), "FmXUndoEnvironment::propertyChange : just inserted it ... why it's not there ?");
+ }
+
+ // now we have access to the cached info about the property affected
+ // and are able to decide wether or not we need an undo action
+
+ bool bAddUndoAction = rModel.IsUndoEnabled();
+ // no UNDO for transient/readonly properties
+ if ( bAddUndoAction && aPropertyPos->second.bIsTransientOrReadOnly )
+ bAddUndoAction = false;
+
+ if ( bAddUndoAction && aPropertyPos->second.bIsValueProperty )
+ {
+ // no UNDO when the "value" property changes, but the ControlSource is non-empty
+ // (in this case the control is intended to be bound to a database column)
+ if ( !aSetPos->second.bHasEmptyControlSource )
+ bAddUndoAction = false;
+
+ // no UNDO if the control is currently bound to an external value
+ if ( bAddUndoAction )
+ {
+ Reference< XBindableValue > xBindable( evt.Source, UNO_QUERY );
+ Reference< XValueBinding > xBinding;
+ if ( xBindable.is() )
+ xBinding = xBindable->getValueBinding();
+
+ Reference< XPropertySet > xBindingProps;
+ Reference< XPropertySetInfo > xBindingPropsPSI;
+ if ( xBindable.is() )
+ xBindingProps.set( xBinding, UNO_QUERY );
+ if ( xBindingProps.is() )
+ xBindingPropsPSI = xBindingProps->getPropertySetInfo();
+ // TODO: we should cache all those things, else this might be too expensive.
+ // However, this requires we're notified of changes in the value binding
+
+ static const ::rtl::OUString s_sExternalData( RTL_CONSTASCII_USTRINGPARAM( "ExternalData" ) );
+ if ( xBindingPropsPSI.is() && xBindingPropsPSI->hasPropertyByName( s_sExternalData ) )
+ {
+ sal_Bool bExternalData = sal_True;
+ OSL_VERIFY( xBindingProps->getPropertyValue( s_sExternalData ) >>= bExternalData );
+ bAddUndoAction = !bExternalData;
+ }
+ else
+ bAddUndoAction = !xBinding.is();
+ }
+ }
+
+ if ( bAddUndoAction && ( evt.PropertyName == FM_PROP_STRINGITEMLIST ) )
+ {
+ Reference< XListEntrySink > xSink( evt.Source, UNO_QUERY );
+ if ( xSink.is() && xSink->getListEntrySource().is() )
+ // #i41029# / 2005-01-31 / frank.schoenheit@sun.com
+ bAddUndoAction = false;
+ }
+
+ if ( bAddUndoAction )
+ {
+ aGuard.clear();
+ // TODO: this is a potential race condition: two threads here could in theory
+ // add their undo actions out-of-order
+
+ SolarMutexGuard aSolarGuard;
+ rModel.AddUndo(new FmUndoPropertyAction(rModel, evt));
+ }
+ }
+ else
+ {
+ // if it's the DataField property we may have to adjust our cache
+ if (m_pPropertySetCache && evt.PropertyName.equals(FM_PROP_CONTROLSOURCE))
+ {
+ Reference< XPropertySet > xSet(evt.Source, UNO_QUERY);
+ PropertySetInfoCache* pCache = static_cast<PropertySetInfoCache*>(m_pPropertySetCache);
+ PropertySetInfo& rSetInfo = (*pCache)[xSet];
+ rSetInfo.bHasEmptyControlSource = !evt.NewValue.hasValue() || (::comphelper::getString(evt.NewValue).getLength() == 0);
+ }
+ }
+}
+
+// XContainerListener
+//------------------------------------------------------------------------------
+void SAL_CALL FmXUndoEnvironment::elementInserted(const ContainerEvent& evt) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::elementInserted" );
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // neues Object zum lauschen
+ Reference< XInterface > xIface;
+ evt.Element >>= xIface;
+ OSL_ENSURE(xIface.is(), "FmXUndoEnvironment::elementInserted: invalid container notification!");
+ AddElement(xIface);
+
+ implSetModified();
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::implSetModified()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::implSetModified" );
+ if ( !IsLocked() && rModel.GetObjectShell() )
+ {
+ rModel.GetObjectShell()->SetModified( sal_True );
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXUndoEnvironment::elementReplaced(const ContainerEvent& evt) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::elementReplaced" );
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XInterface > xIface;
+ evt.ReplacedElement >>= xIface;
+ OSL_ENSURE(xIface.is(), "FmXUndoEnvironment::elementReplaced: invalid container notification!");
+ RemoveElement(xIface);
+
+ evt.Element >>= xIface;
+ AddElement(xIface);
+
+ implSetModified();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXUndoEnvironment::elementRemoved(const ContainerEvent& evt) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::elementRemoved" );
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XInterface > xIface( evt.Element, UNO_QUERY );
+ OSL_ENSURE(xIface.is(), "FmXUndoEnvironment::elementRemoved: invalid container notification!");
+ RemoveElement(xIface);
+
+ implSetModified();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXUndoEnvironment::modified( const EventObject& /*aEvent*/ ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::modified" );
+ implSetModified();
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::AddForms(const Reference< XNameContainer > & rForms)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::AddForms" );
+ Lock();
+ Reference< XInterface > xInt(rForms, UNO_QUERY);
+ AddElement(xInt);
+ UnLock();
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::RemoveForms(const Reference< XNameContainer > & rForms)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::RemoveForms" );
+ Lock();
+ Reference< XInterface > xInt(rForms, UNO_QUERY);
+ RemoveElement(xInt);
+ UnLock();
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::TogglePropertyListening(const Reference< XInterface > & Element)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::TogglePropertyListening" );
+ // am Container horchen
+ Reference< XIndexContainer > xContainer(Element, UNO_QUERY);
+ if (xContainer.is())
+ {
+ sal_uInt32 nCount = xContainer->getCount();
+ Reference< XInterface > xIface;
+ for (sal_uInt32 i = 0; i < nCount; i++)
+ {
+ xContainer->getByIndex(i) >>= xIface;
+ TogglePropertyListening(xIface);
+ }
+ }
+
+ Reference< XPropertySet > xSet(Element, UNO_QUERY);
+ if (xSet.is())
+ {
+ if (!bReadOnly)
+ xSet->addPropertyChangeListener( ::rtl::OUString(), this );
+ else
+ xSet->removePropertyChangeListener( ::rtl::OUString(), this );
+ }
+}
+
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::switchListening( const Reference< XIndexContainer >& _rxContainer, bool _bStartListening ) SAL_THROW(())
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::switchListening" );
+ OSL_PRECOND( _rxContainer.is(), "FmXUndoEnvironment::switchListening: invalid container!" );
+ if ( !_rxContainer.is() )
+ return;
+
+ try
+ {
+ // if it's an EventAttacherManager, then we need to listen for
+ // script events
+ Reference< XEventAttacherManager > xManager( _rxContainer, UNO_QUERY );
+ if ( xManager.is() )
+ {
+ if ( _bStartListening )
+ {
+ m_pScriptingEnv->registerEventAttacherManager( xManager );
+ if ( m_vbaListener.is() )
+ xManager->addScriptListener( m_vbaListener );
+ }
+ else
+ {
+ m_pScriptingEnv->revokeEventAttacherManager( xManager );
+ if ( m_vbaListener.is() )
+ xManager->removeScriptListener( m_vbaListener );
+ }
+ }
+
+ // also handle all children of this element
+ sal_uInt32 nCount = _rxContainer->getCount();
+ Reference< XInterface > xInterface;
+ for ( sal_uInt32 i = 0; i < nCount; ++i )
+ {
+ _rxContainer->getByIndex( i ) >>= xInterface;
+ if ( _bStartListening )
+ AddElement( xInterface );
+ else
+ RemoveElement( xInterface );
+ }
+
+ // be notified of any changes in the container elements
+ Reference< XContainer > xSimpleContainer( _rxContainer, UNO_QUERY );
+ OSL_ENSURE( xSimpleContainer.is(), "FmXUndoEnvironment::switchListening: how are we expected to be notified of changes in the container?" );
+ if ( xSimpleContainer.is() )
+ {
+ if ( _bStartListening )
+ xSimpleContainer->addContainerListener( this );
+ else
+ xSimpleContainer->removeContainerListener( this );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmXUndoEnvironment::switchListening: caught an exception!" );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::switchListening( const Reference< XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(())
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::switchListening" );
+ OSL_PRECOND( _rxObject.is(), "FmXUndoEnvironment::switchListening: how should I listen at a NULL object?" );
+
+ try
+ {
+ if ( !bReadOnly )
+ {
+ Reference< XPropertySet > xProps( _rxObject, UNO_QUERY );
+ if ( xProps.is() )
+ {
+ if ( _bStartListening )
+ xProps->addPropertyChangeListener( ::rtl::OUString(), this );
+ else
+ xProps->removePropertyChangeListener( ::rtl::OUString(), this );
+ }
+ }
+
+ Reference< XModifyBroadcaster > xBroadcaster( _rxObject, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ {
+ if ( _bStartListening )
+ xBroadcaster->addModifyListener( this );
+ else
+ xBroadcaster->removeModifyListener( this );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmXUndoEnvironment::switchListening: caught an exception!" );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::AddElement(const Reference< XInterface >& _rxElement )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::AddElement" );
+ OSL_ENSURE( !m_bDisposed, "FmXUndoEnvironment::AddElement: not when I'm already disposed!" );
+
+ // am Container horchen
+ Reference< XIndexContainer > xContainer( _rxElement, UNO_QUERY );
+ if ( xContainer.is() )
+ switchListening( xContainer, true );
+
+ switchListening( _rxElement, true );
+}
+
+//------------------------------------------------------------------------------
+void FmXUndoEnvironment::RemoveElement(const Reference< XInterface >& _rxElement)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::RemoveElement" );
+ if ( m_bDisposed )
+ return;
+
+ switchListening( _rxElement, false );
+
+ if (!bReadOnly)
+ {
+ // reset the ActiveConnection if the form is to be removed. This will (should) free the resources
+ // associated with this connection
+ // 86299 - 05/02/2001 - frank.schoenheit@germany.sun.com
+ Reference< XForm > xForm( _rxElement, UNO_QUERY );
+ Reference< XPropertySet > xFormProperties( xForm, UNO_QUERY );
+ if ( xFormProperties.is() )
+ if ( !::svxform::OStaticDataAccessTools().isEmbeddedInDatabase( _rxElement ) )
+ // (if there is a connection in the context of the component, setting
+ // a new connection would be vetoed, anyway)
+ // #i34196# - 2004-09-21 - fs@openoffice.org
+ xFormProperties->setPropertyValue( FM_PROP_ACTIVE_CONNECTION, Any() );
+ }
+
+ Reference< XIndexContainer > xContainer( _rxElement, UNO_QUERY );
+ if ( xContainer.is() )
+ switchListening( xContainer, false );
+}
+
+
+//------------------------------------------------------------------------------
+FmUndoPropertyAction::FmUndoPropertyAction(FmFormModel& rNewMod, const PropertyChangeEvent& evt)
+ :SdrUndoAction(rNewMod)
+ ,xObj(evt.Source, UNO_QUERY)
+ ,aPropertyName(evt.PropertyName)
+ ,aNewValue(evt.NewValue)
+ ,aOldValue(evt.OldValue)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoPropertyAction::FmUndoPropertyAction" );
+ if (rNewMod.GetObjectShell())
+ rNewMod.GetObjectShell()->SetModified(sal_True);
+ if(static_STR_UNDO_PROPERTY.Len() == 0)
+ static_STR_UNDO_PROPERTY = SVX_RES(RID_STR_UNDO_PROPERTY);
+}
+
+
+//------------------------------------------------------------------------------
+void FmUndoPropertyAction::Undo()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoPropertyAction::Undo" );
+ FmXUndoEnvironment& rEnv = ((FmFormModel&)rMod).GetUndoEnv();
+
+ if (xObj.is() && !rEnv.IsLocked())
+ {
+ rEnv.Lock();
+ try
+ {
+ xObj->setPropertyValue( aPropertyName, aOldValue );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmUndoPropertyAction::Undo: caught an exception!" );
+ }
+ rEnv.UnLock();
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmUndoPropertyAction::Redo()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoPropertyAction::Redo" );
+ FmXUndoEnvironment& rEnv = ((FmFormModel&)rMod).GetUndoEnv();
+
+ if (xObj.is() && !rEnv.IsLocked())
+ {
+ rEnv.Lock();
+ try
+ {
+ xObj->setPropertyValue( aPropertyName, aNewValue );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmUndoPropertyAction::Redo: caught an exception!" );
+ }
+ rEnv.UnLock();
+ }
+}
+
+//------------------------------------------------------------------------------
+String FmUndoPropertyAction::GetComment() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoPropertyAction::GetComment" );
+ String aStr(static_STR_UNDO_PROPERTY);
+
+ aStr.SearchAndReplace( '#', aPropertyName );
+ return aStr;
+}
+
+
+DBG_NAME(FmUndoContainerAction);
+//------------------------------------------------------------------------------
+FmUndoContainerAction::FmUndoContainerAction(FmFormModel& _rMod,
+ Action _eAction,
+ const Reference< XIndexContainer > & xCont,
+ const Reference< XInterface > & xElem,
+ sal_Int32 nIdx)
+ :SdrUndoAction( _rMod )
+ ,m_xContainer( xCont )
+ ,m_nIndex( nIdx )
+ ,m_eAction( _eAction )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoContainerAction::FmUndoContainerAction" );
+ OSL_ENSURE( nIdx >= 0, "FmUndoContainerAction::FmUndoContainerAction: invalid index!" );
+ // some old code suggested this could be a valid argument. However, this code was
+ // buggy, and it *seemed* that nobody used it - so it was removed.
+
+ DBG_CTOR(FmUndoContainerAction,NULL);
+ if ( xCont.is() && xElem.is() )
+ {
+ // normalize
+ m_xElement = m_xElement.query( xElem );
+ if ( m_eAction == Removed )
+ {
+ if (m_nIndex >= 0)
+ {
+ Reference< XEventAttacherManager > xManager( xCont, UNO_QUERY );
+ if ( xManager.is() )
+ m_aEvents = xManager->getScriptEvents(m_nIndex);
+ }
+ else
+ m_xElement = NULL;
+
+ // we now own the element
+ m_xOwnElement = m_xElement;
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+FmUndoContainerAction::~FmUndoContainerAction()
+{
+ // if we own the object ....
+ DisposeElement( m_xOwnElement );
+ DBG_DTOR(FmUndoContainerAction,NULL);
+}
+
+//------------------------------------------------------------------------------
+
+void FmUndoContainerAction::DisposeElement( const Reference< XInterface > & xElem )
+{
+ Reference< XComponent > xComp( xElem, UNO_QUERY );
+ if ( xComp.is() )
+ {
+ // and the object does not have a parent
+ Reference< XChild > xChild( xElem, UNO_QUERY );
+ if ( xChild.is() && !xChild->getParent().is() )
+ // -> dispose it
+ xComp->dispose();
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmUndoContainerAction::implReInsert( ) SAL_THROW( ( Exception ) )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoContainerAction::implReInsert" );
+ if ( m_xContainer->getCount() >= m_nIndex )
+ {
+ // insert the element
+ Any aVal;
+ if ( m_xContainer->getElementType() == ::getCppuType( static_cast< const Reference< XFormComponent >* >( NULL ) ) )
+ {
+ aVal <<= Reference< XFormComponent >( m_xElement, UNO_QUERY );
+ }
+ else
+ {
+ aVal <<= Reference< XForm >( m_xElement, UNO_QUERY );
+ }
+ m_xContainer->insertByIndex( m_nIndex, aVal );
+
+ OSL_ENSURE( getElementPos( m_xContainer.get(), m_xElement ) == m_nIndex, "FmUndoContainerAction::implReInsert: insertion did not work!" );
+
+ // register the events
+ Reference< XEventAttacherManager > xManager( m_xContainer, UNO_QUERY );
+ if ( xManager.is() )
+ xManager->registerScriptEvents( m_nIndex, m_aEvents );
+
+ // we don't own the object anymore
+ m_xOwnElement = NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmUndoContainerAction::implReRemove( ) SAL_THROW( ( Exception ) )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoContainerAction::implReRemove" );
+ Reference< XInterface > xElement;
+ if ( ( m_nIndex >= 0 ) && ( m_nIndex < m_xContainer->getCount() ) )
+ m_xContainer->getByIndex( m_nIndex ) >>= xElement;
+
+ if ( xElement != m_xElement )
+ {
+ // the indexes in the container changed. Okay, so go the long way and
+ // manually determine the index
+ m_nIndex = getElementPos( m_xContainer.get(), m_xElement );
+ if ( m_nIndex != -1 )
+ xElement = m_xElement;
+ }
+
+ OSL_ENSURE( xElement == m_xElement, "FmUndoContainerAction::implReRemove: cannot find the element which I'm responsible for!" );
+ if ( xElement == m_xElement )
+ {
+ Reference< XEventAttacherManager > xManager( m_xContainer, UNO_QUERY );
+ if ( xManager.is() )
+ m_aEvents = xManager->getScriptEvents( m_nIndex );
+ m_xContainer->removeByIndex( m_nIndex );
+ // from now on, we own this object
+ m_xOwnElement = m_xElement;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmUndoContainerAction::Undo()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoContainerAction::Undo" );
+ FmXUndoEnvironment& rEnv = static_cast< FmFormModel& >( rMod ).GetUndoEnv();
+
+ if ( m_xContainer.is() && !rEnv.IsLocked() && m_xElement.is() )
+ {
+ rEnv.Lock();
+ try
+ {
+ switch ( m_eAction )
+ {
+ case Inserted:
+ implReRemove();
+ break;
+
+ case Removed:
+ implReInsert();
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmUndoContainerAction::Undo: caught an exception!" );
+ }
+ rEnv.UnLock();
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmUndoContainerAction::Redo()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoContainerAction::Redo" );
+ FmXUndoEnvironment& rEnv = static_cast< FmFormModel& >( rMod ).GetUndoEnv();
+ if ( m_xContainer.is() && !rEnv.IsLocked() && m_xElement.is() )
+ {
+ rEnv.Lock();
+ try
+ {
+ switch ( m_eAction )
+ {
+ case Inserted:
+ implReInsert();
+ break;
+
+ case Removed:
+ implReRemove();
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FmUndoContainerAction::Redo: caught an exception!" );
+ }
+ rEnv.UnLock();
+ }
+}
+
+//------------------------------------------------------------------------------
+FmUndoModelReplaceAction::FmUndoModelReplaceAction(FmFormModel& _rMod, SdrUnoObj* _pObject, const Reference< XControlModel > & _xReplaced)
+ :SdrUndoAction(_rMod)
+ ,m_xReplaced(_xReplaced)
+ ,m_pObject(_pObject)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoModelReplaceAction::FmUndoModelReplaceAction" );
+}
+
+//------------------------------------------------------------------------------
+FmUndoModelReplaceAction::~FmUndoModelReplaceAction()
+{
+ // dispose our element if nobody else is responsible for
+ DisposeElement(m_xReplaced);
+}
+
+//------------------------------------------------------------------------------
+
+void FmUndoModelReplaceAction::DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced )
+{
+ Reference< XComponent > xComp(xReplaced, UNO_QUERY);
+ if (xComp.is())
+ {
+ Reference< XChild > xChild(xReplaced, UNO_QUERY);
+ if (!xChild.is() || !xChild->getParent().is())
+ xComp->dispose();
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmUndoModelReplaceAction::Undo()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoModelReplaceAction::Undo" );
+ try
+ {
+ Reference< XControlModel > xCurrentModel( m_pObject->GetUnoControlModel() );
+
+ // replace the model within the parent
+ Reference< XChild > xCurrentAsChild( xCurrentModel, UNO_QUERY );
+ Reference< XNameContainer > xCurrentsParent;
+ if ( xCurrentAsChild.is() )
+ xCurrentsParent = xCurrentsParent.query( xCurrentAsChild->getParent() );
+ DBG_ASSERT( xCurrentsParent.is(), "FmUndoModelReplaceAction::Undo: invalid current model!" );
+
+ if ( xCurrentsParent.is() )
+ {
+ // the form container works with FormComponents
+ Reference< XFormComponent > xComponent( m_xReplaced, UNO_QUERY );
+ DBG_ASSERT( xComponent.is(), "FmUndoModelReplaceAction::Undo: the new model is no form component !" );
+
+ Reference< XPropertySet > xCurrentAsSet( xCurrentModel, UNO_QUERY );
+ DBG_ASSERT( ::comphelper::hasProperty(FM_PROP_NAME, xCurrentAsSet ), "FmUndoModelReplaceAction::Undo : one of the models is invalid !");
+
+ ::rtl::OUString sName;
+ xCurrentAsSet->getPropertyValue( FM_PROP_NAME ) >>= sName;
+ xCurrentsParent->replaceByName( sName, makeAny( xComponent ) );
+
+ m_pObject->SetUnoControlModel(m_xReplaced);
+ m_pObject->SetChanged();
+
+ m_xReplaced = xCurrentModel;
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("FmUndoModelReplaceAction::Undo : could not replace the model !");
+ }
+}
+
+//------------------------------------------------------------------------------
+String FmUndoModelReplaceAction::GetComment() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmUndoModelReplaceAction::GetComment" );
+ return SVX_RES(RID_STR_UNDO_MODEL_REPLACE);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx
new file mode 100644
index 000000000000..b8f328a80f75
--- /dev/null
+++ b/svx/source/form/fmview.cxx
@@ -0,0 +1,628 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <sfx2/docfile.hxx>
+#ifdef REFERENCE
+#undef REFERENCE
+#endif
+#include <svtools/ehdl.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/form/XReset.hpp>
+#include "fmvwimp.hxx"
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <basic/sbuno.hxx>
+#include <sfx2/macrconf.hxx>
+#include <basic/sbx.hxx>
+#include "fmitems.hxx"
+#include "fmobj.hxx"
+#include "svditer.hxx"
+#include <svx/svdpagv.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/fmview.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/fmpage.hxx>
+#include <svx/fmshell.hxx>
+#include "fmpgeimp.hxx"
+#include "svx/fmtools.hxx"
+#include "fmshimp.hxx"
+#include "fmservs.hxx"
+#include "fmprop.hrc"
+#include "fmundo.hxx"
+#include <svx/dataaccessdescriptor.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <vcl/svapp.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/stdtext.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include "sdrpaintwindow.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::util;
+using namespace ::svxform;
+using namespace ::svx;
+
+//========================================================================
+//------------------------------------------------------------------------
+TYPEINIT1(FmFormView, E3dView);
+
+//------------------------------------------------------------------------
+FmFormView::FmFormView( FmFormModel* pModel, OutputDevice* pOut )
+ :E3dView(pModel,pOut)
+{
+ Init();
+}
+
+//------------------------------------------------------------------------
+void FmFormView::Init()
+{
+ pFormShell = NULL;
+ pImpl = new FmXFormView(::comphelper::getProcessServiceFactory(),this);
+ pImpl->acquire();
+
+ //////////////////////////////////////////////////////////////////////
+ // Model setzen
+ SdrModel* pModel = GetModel();
+
+ DBG_ASSERT( pModel->ISA(FmFormModel), "Falsches Model" );
+ if( !pModel->ISA(FmFormModel) ) return;
+ FmFormModel* pFormModel = (FmFormModel*)pModel;
+
+ //////////////////////////////////////////////////////////////////////
+ // DesignMode vom Model holen
+ sal_Bool bInitDesignMode = pFormModel->GetOpenInDesignMode();
+ if ( pFormModel->OpenInDesignModeIsDefaulted( ) )
+ { // this means that nobody ever explicitly set this on the model, and the model has never
+ // been loaded from a stream.
+ // This means this is a newly created document. This means, we want to have it in design
+ // mode by default (though a newly created model returns true for GetOpenInDesignMode).
+ // We _want_ to have this because it makes a lot of hacks following the original fix
+ // for #94595# unnecessary
+ // #96399# - 2002-10-11 - fs@openoffice.org
+ DBG_ASSERT( !bInitDesignMode, "FmFormView::Init: doesn't the model default to FALSE anymore?" );
+ // if this asserts, either the on-contruction default in the model has changed (then this here
+ // may not be necessary anymore), or we're not dealing with a new document ....
+ bInitDesignMode = sal_True;
+ }
+
+ SfxObjectShell* pObjShell = pFormModel->GetObjectShell();
+ if ( pObjShell && pObjShell->GetMedium() )
+ {
+ const SfxPoolItem *pItem=0;
+ if ( pObjShell->GetMedium()->GetItemSet()->GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
+ {
+ Sequence< PropertyValue > aSeq;
+ ( ((SfxUnoAnyItem*)pItem)->GetValue() ) >>= aSeq;
+ ::comphelper::NamedValueCollection aComponentData( aSeq );
+ bInitDesignMode = aComponentData.getOrDefault( "ApplyFormDesignMode", bInitDesignMode );
+ }
+ }
+
+ if( pObjShell && pObjShell->IsReadOnly() )
+ bInitDesignMode = sal_False;
+
+ // dieses wird in der Shell vorgenommen
+ // bDesignMode = !bInitDesignMode; // erzwingt, dass SetDesignMode ausgefuehrt wird
+ SetDesignMode( bInitDesignMode );
+}
+
+//------------------------------------------------------------------------
+FmFormView::~FmFormView()
+{
+ if( pFormShell )
+ pFormShell->SetView( NULL );
+
+ pImpl->notifyViewDying();
+ pImpl->release();
+ pImpl = NULL;
+}
+
+//------------------------------------------------------------------------
+FmFormPage* FmFormView::GetCurPage()
+{
+ SdrPageView* pPageView = GetSdrPageView();
+ FmFormPage* pCurPage = pPageView ? PTR_CAST( FmFormPage, pPageView->GetPage() ) : NULL;
+ return pCurPage;
+}
+
+//------------------------------------------------------------------------
+void FmFormView::MarkListHasChanged()
+{
+ E3dView::MarkListHasChanged();
+
+ if ( pFormShell && IsDesignMode() )
+ {
+ FmFormObj* pObj = getMarkedGrid();
+ if ( pImpl->m_pMarkedGrid && pImpl->m_pMarkedGrid != pObj )
+ {
+ pImpl->m_pMarkedGrid = NULL;
+ if ( pImpl->m_xWindow.is() )
+ {
+ pImpl->m_xWindow->removeFocusListener(pImpl);
+ pImpl->m_xWindow = NULL;
+ }
+ SetMoveOutside(FALSE);
+ //OLMRefreshAllIAOManagers();
+ }
+
+ pFormShell->GetImpl()->SetSelectionDelayed();
+ }
+}
+
+namespace
+{
+ const SdrPageWindow* findPageWindow( const SdrPaintView* _pView, OutputDevice* _pWindow )
+ {
+ SdrPageView* pPageView = _pView->GetSdrPageView();
+ if(pPageView)
+ {
+ for ( sal_uInt32 window = 0; window < pPageView->PageWindowCount(); ++window )
+ {
+ const SdrPageWindow* pPageWindow = pPageView->GetPageWindow( window );
+ if ( !pPageWindow || &pPageWindow->GetPaintWindow().GetOutputDevice() != _pWindow )
+ continue;
+
+ return pPageWindow;
+ }
+ }
+ return NULL;
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFormView::AddWindowToPaintView(OutputDevice* pNewWin)
+{
+ E3dView::AddWindowToPaintView(pNewWin);
+
+ if ( !pNewWin )
+ return;
+
+ // look up the PageViewWindow for the newly inserted window, and care for it
+ // #i39269# / 2004-12-20 / frank.schoenheit@sun.com
+ const SdrPageWindow* pPageWindow = findPageWindow( this, pNewWin );
+ if ( pPageWindow )
+ pImpl->addWindow( *pPageWindow );
+}
+
+//------------------------------------------------------------------------
+void FmFormView::DeleteWindowFromPaintView(OutputDevice* pNewWin)
+{
+ const SdrPageWindow* pPageWindow = findPageWindow( this, pNewWin );
+ if ( pPageWindow )
+ pImpl->removeWindow( pPageWindow->GetControlContainer() );
+
+ E3dView::DeleteWindowFromPaintView(pNewWin);
+}
+
+//------------------------------------------------------------------------
+void FmFormView::ChangeDesignMode(sal_Bool bDesign)
+{
+ if (bDesign == IsDesignMode())
+ return;
+
+ FmFormModel* pModel = PTR_CAST(FmFormModel, GetModel());
+ if (pModel)
+ { // fuer die Zeit des Uebergangs das Undo-Environment ausschalten, das sichert, dass man dort auch nicht-transiente
+ // Properties mal eben aendern kann (sollte allerdings mit Vorsicht genossen und beim Rueckschalten des Modes
+ // auch immer wieder rueckgaegig gemacht werden. Ein Beispiel ist das Setzen der maximalen Text-Laenge durch das
+ // FmXEditModel an seinem Control.)
+ pModel->GetUndoEnv().Lock();
+ }
+
+ // --- 1. deactivate all controls if we are switching to design mode
+ if ( bDesign )
+ DeactivateControls( GetSdrPageView() );
+
+ // --- 2. simulate a deactivation (the shell will handle some things there ...?)
+ if ( pFormShell && pFormShell->GetImpl() )
+ pFormShell->GetImpl()->viewDeactivated( *this, sal_True );
+ else
+ pImpl->Deactivate( sal_True );
+
+ // --- 3. activate all controls, if we're switching to alive mode
+ if ( !bDesign )
+ ActivateControls( GetSdrPageView() );
+
+ // --- 4. load resp. unload the forms
+ FmFormPage* pCurPage = GetCurPage();
+ if ( pCurPage )
+ {
+ if ( pFormShell && pFormShell->GetImpl() )
+ pFormShell->GetImpl()->loadForms( pCurPage, ( bDesign ? FORMS_UNLOAD : FORMS_LOAD ) );
+ }
+
+ // --- 5. base class functionality
+ SetDesignMode( bDesign );
+
+ // --- 6. simulate a activation (the shell will handle some things there ...?)
+ OSL_PRECOND( pFormShell && pFormShell->GetImpl(), "FmFormView::ChangeDesignMode: is this really allowed? No shell?" );
+ if ( pFormShell && pFormShell->GetImpl() )
+ pFormShell->GetImpl()->viewActivated( *this );
+ else
+ pImpl->Activate();
+
+ if ( pCurPage )
+ {
+ if ( bDesign )
+ {
+ if ( GetActualOutDev() && GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW )
+ {
+ const Window* pWindow = static_cast< const Window* >( GetActualOutDev() );
+ const_cast< Window* >( pWindow )->GrabFocus();
+ }
+
+ // redraw UNO objects
+ if ( GetSdrPageView() )
+ {
+ SdrObjListIter aIter(*pCurPage);
+ while( aIter.IsMore() )
+ {
+ SdrObject* pObj = aIter.Next();
+ if (pObj && pObj->IsUnoObj())
+ {
+ // For redraw just use ActionChanged()
+ // pObj->BroadcastObjectChange();
+ pObj->ActionChanged();
+ }
+ }
+ }
+ }
+ else
+ {
+ // set the auto focus to the first control (if indicated by the model to do so)
+ sal_Bool bForceControlFocus = pModel ? pModel->GetAutoControlFocus() : sal_False;
+ if (bForceControlFocus)
+ pImpl->AutoFocus();
+ }
+ }
+
+ // und mein Undo-Environment wieder an
+ if (pModel)
+ pModel->GetUndoEnv().UnLock();
+}
+
+//------------------------------------------------------------------------
+void FmFormView::GrabFirstControlFocus( sal_Bool _bForceSync )
+{
+ if ( !IsDesignMode() )
+ pImpl->AutoFocus( _bForceSync );
+}
+
+//------------------------------------------------------------------------
+SdrPageView* FmFormView::ShowSdrPage(SdrPage* pPage)
+{
+ SdrPageView* pPV = E3dView::ShowSdrPage(pPage);
+
+ if (pPage)
+ {
+ if (!IsDesignMode())
+ {
+ // creating the controllers
+ ActivateControls(pPV);
+
+ // Alles deselektieren
+ UnmarkAll();
+ }
+ else if ( pFormShell && pFormShell->IsDesignMode() )
+ {
+ FmXFormShell* pFormShellImpl = pFormShell->GetImpl();
+ pFormShellImpl->UpdateForms( sal_True );
+
+ // damit der Formular-Navigator auf den Seitenwechsel reagieren kann
+ pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_FMEXPLORER_CONTROL , sal_True, sal_False);
+
+ pFormShellImpl->SetSelection(GetMarkedObjectList());
+ }
+ }
+
+ // notify our shell that we have been activated
+ if ( pFormShell && pFormShell->GetImpl() )
+ pFormShell->GetImpl()->viewActivated( *this );
+ else
+ pImpl->Activate();
+
+ return pPV;
+}
+
+//------------------------------------------------------------------------
+void FmFormView::HideSdrPage()
+{
+ // --- 1. deactivate controls
+ if ( !IsDesignMode() )
+ DeactivateControls(GetSdrPageView());
+
+ // --- 2. tell the shell the view is (going to be) deactivated
+ if ( pFormShell && pFormShell->GetImpl() )
+ pFormShell->GetImpl()->viewDeactivated( *this, sal_True );
+ else
+ pImpl->Deactivate( sal_True );
+
+ // --- 3. base class behavior
+ E3dView::HideSdrPage();
+}
+
+//------------------------------------------------------------------------
+SdrModel* FmFormView::GetMarkedObjModel() const
+{
+ return E3dView::GetMarkedObjModel();
+}
+
+//------------------------------------------------------------------------
+sal_Bool FmFormView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, sal_uInt32 nOptions)
+{
+ return E3dView::Paste(rMod, rPos, pLst, nOptions);
+}
+
+//------------------------------------------------------------------------
+void FmFormView::ActivateControls(SdrPageView* pPageView)
+{
+ if (!pPageView)
+ return;
+
+ for (sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); ++i)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
+ pImpl->addWindow(rPageWindow);
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFormView::DeactivateControls(SdrPageView* pPageView)
+{
+ if( !pPageView )
+ return;
+
+ for (sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); ++i)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
+ pImpl->removeWindow(rPageWindow.GetControlContainer() );
+ }
+}
+
+//------------------------------------------------------------------------
+SdrObject* FmFormView::CreateFieldControl( const ODataAccessDescriptor& _rColumnDescriptor )
+{
+ return pImpl->implCreateFieldControl( _rColumnDescriptor );
+}
+
+//------------------------------------------------------------------------
+SdrObject* FmFormView::CreateXFormsControl( const OXFormsDescriptor &_rDesc )
+{
+ return pImpl->implCreateXFormsControl(_rDesc);
+}
+
+//------------------------------------------------------------------------
+SdrObject* FmFormView::CreateFieldControl(const UniString& rFieldDesc) const
+{
+ ::rtl::OUString sDataSource = rFieldDesc.GetToken(0,sal_Unicode(11));
+ ::rtl::OUString sObjectName = rFieldDesc.GetToken(1,sal_Unicode(11));
+ sal_uInt16 nObjectType = (sal_uInt16)rFieldDesc.GetToken(2,sal_Unicode(11)).ToInt32();
+ ::rtl::OUString sFieldName = rFieldDesc.GetToken(3,sal_Unicode(11));
+
+ if (!sFieldName.getLength() || !sObjectName.getLength() || !sDataSource.getLength())
+ return NULL;
+
+ ODataAccessDescriptor aColumnDescriptor;
+ aColumnDescriptor.setDataSource(sDataSource);
+ aColumnDescriptor[ daCommand ] <<= sObjectName;
+ aColumnDescriptor[ daCommandType ] <<= nObjectType;
+ aColumnDescriptor[ daColumnName ] <<= sFieldName;
+
+ return pImpl->implCreateFieldControl( aColumnDescriptor );
+}
+
+//------------------------------------------------------------------------
+void FmFormView::InsertControlContainer(const Reference< ::com::sun::star::awt::XControlContainer > & xCC)
+{
+ if( !IsDesignMode() )
+ {
+ SdrPageView* pPageView = GetSdrPageView();
+ if( pPageView )
+ {
+ for( sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); i++ )
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
+
+ if( rPageWindow.GetControlContainer( false ) == xCC )
+ {
+ pImpl->addWindow(rPageWindow);
+ break;
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+void FmFormView::RemoveControlContainer(const Reference< ::com::sun::star::awt::XControlContainer > & xCC)
+{
+ if( !IsDesignMode() )
+ {
+ pImpl->removeWindow( xCC );
+ }
+}
+
+// -----------------------------------------------------------------------------
+SdrPaintWindow* FmFormView::BeginCompleteRedraw(OutputDevice* pOut)
+{
+ SdrPaintWindow* pPaintWindow = E3dView::BeginCompleteRedraw( pOut );
+ pImpl->suspendTabOrderUpdate();
+ return pPaintWindow;
+}
+
+// -----------------------------------------------------------------------------
+void FmFormView::EndCompleteRedraw( SdrPaintWindow& rPaintWindow, bool bPaintFormLayer )
+{
+ E3dView::EndCompleteRedraw( rPaintWindow, bPaintFormLayer );
+ pImpl->resumeTabOrderUpdate();
+}
+
+// -----------------------------------------------------------------------------
+BOOL FmFormView::KeyInput(const KeyEvent& rKEvt, Window* pWin)
+{
+ BOOL bDone = FALSE;
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ if ( IsDesignMode()
+ && rKeyCode.GetCode() == KEY_RETURN
+ )
+ {
+ // RETURN alone enters grid controls, for keyboard accessibility
+ if ( pWin
+ && !rKeyCode.IsShift()
+ && !rKeyCode.IsMod1()
+ && !rKeyCode.IsMod2()
+ )
+ {
+ FmFormObj* pObj = getMarkedGrid();
+ if ( pObj )
+ {
+ Reference< awt::XWindow > xWindow( pObj->GetUnoControl( *this, *pWin ), UNO_QUERY );
+ if ( xWindow.is() )
+ {
+ pImpl->m_pMarkedGrid = pObj;
+ pImpl->m_xWindow = xWindow;
+ // add as listener to get notified when ESC will be pressed inside the grid
+ pImpl->m_xWindow->addFocusListener(pImpl);
+ SetMoveOutside(TRUE);
+ //OLMRefreshAllIAOManagers();
+ xWindow->setFocus();
+ bDone = TRUE;
+ }
+ }
+ }
+ // Alt-RETURN alone shows the properties of the selection
+ if ( pFormShell
+ && pFormShell->GetImpl()
+ && !rKeyCode.IsShift()
+ && !rKeyCode.IsMod1()
+ && rKeyCode.IsMod2()
+ )
+ {
+ pFormShell->GetImpl()->handleShowPropertiesRequest();
+ }
+
+ }
+
+ if ( !bDone )
+ bDone = E3dView::KeyInput(rKEvt,pWin);
+ return bDone;
+}
+// -----------------------------------------------------------------------------
+sal_Bool FmFormView::checkUnMarkAll(const Reference< XInterface >& _xSource)
+{
+ Reference< ::com::sun::star::awt::XControl> xControl(pImpl->m_xWindow,UNO_QUERY);
+ sal_Bool bRet = !xControl.is() || !_xSource.is() || _xSource != xControl->getModel();
+ if ( bRet )
+ UnmarkAll();
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+BOOL FmFormView::MouseButtonDown( const MouseEvent& _rMEvt, Window* _pWin )
+{
+ BOOL bReturn = E3dView::MouseButtonDown( _rMEvt, _pWin );
+
+ if ( pFormShell && pFormShell->GetImpl() )
+ {
+ SdrViewEvent aViewEvent;
+ PickAnything( _rMEvt, SDRMOUSEBUTTONDOWN, aViewEvent );
+ pFormShell->GetImpl()->handleMouseButtonDown( aViewEvent );
+ }
+
+ return bReturn;
+}
+
+// -----------------------------------------------------------------------------
+FmFormObj* FmFormView::getMarkedGrid() const
+{
+ FmFormObj* pFormObject = NULL;
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ if ( 1 == rMarkList.GetMarkCount() )
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ if ( pMark )
+ {
+ pFormObject = FmFormObj::GetFormObject( pMark->GetMarkedSdrObj() );
+ if ( pFormObject )
+ {
+ Reference< XServiceInfo > xServInfo( pFormObject->GetUnoControlModel(), UNO_QUERY );
+ if ( !xServInfo.is() || !xServInfo->supportsService( FM_SUN_COMPONENT_GRIDCONTROL ) )
+ pFormObject = NULL;
+ }
+ }
+ }
+ return pFormObject;
+}
+
+// -----------------------------------------------------------------------------
+void FmFormView::createControlLabelPair( OutputDevice* _pOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
+ const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
+ sal_uInt16 _nControlObjectID, const ::rtl::OUString& _rFieldPostfix, UINT32 _nInventor, UINT16 _nLabelObjectID,
+ SdrPage* _pLabelPage, SdrPage* _pControlPage, SdrModel* _pModel, SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl )
+{
+ FmXFormView::createControlLabelPair(
+ ::comphelper::getProcessServiceFactory(),
+ *_pOutDev, _nXOffsetMM, _nYOffsetMM,
+ _rxField, _rxNumberFormats,
+ _nControlObjectID, _rFieldPostfix, _nInventor, _nLabelObjectID,
+ _pLabelPage, _pControlPage, _pModel,
+ _rpLabel, _rpControl
+ );
+}
+// -----------------------------------------------------------------------------
+Reference< runtime::XFormController > FmFormView::GetFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const
+{
+ return pImpl->getFormController( _rxForm, _rDevice );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
new file mode 100644
index 000000000000..c4d0f36f1f69
--- /dev/null
+++ b/svx/source/form/fmvwimp.cxx
@@ -0,0 +1,1961 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmdocumentclassification.hxx"
+#include "fmobj.hxx"
+#include "fmpgeimp.hxx"
+#include "fmprop.hrc"
+#include "fmresids.hrc"
+#include "fmservs.hxx"
+#include "fmshimp.hxx"
+#include "svx/fmtools.hxx"
+#include "fmundo.hxx"
+#include "fmvwimp.hxx"
+#include "formcontrolfactory.hxx"
+#include "sdrpaintwindow.hxx"
+#include "svditer.hxx"
+#include "svx/dataaccessdescriptor.hxx"
+#include "svx/dialmgr.hxx"
+#include "svx/fmglob.hxx"
+#include "svx/fmmodel.hxx"
+#include "svx/fmpage.hxx"
+#include "svx/fmshell.hxx"
+#include "svx/fmview.hxx"
+#include "svx/sdrpagewindow.hxx"
+#include "svx/svdogrp.hxx"
+#include "svx/svdpagv.hxx"
+#include "xmlexchg.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/awt/VisualEffect.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormats.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/form/XReset.hpp>
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/binding/XValueBinding.hpp>
+#include <com/sun/star/form/submission/XSubmissionSupplier.hpp>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/XTabController.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/numbers.hxx>
+#include <comphelper/property.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/msgbox.hxx>
+#include <vcl/stdtext.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/logfile.hxx>
+
+#include <algorithm>
+
+using namespace ::comphelper;
+using namespace ::svx;
+using namespace ::svxform;
+
+ using namespace ::com::sun::star;
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::style::VerticalAlignment_MIDDLE;
+ using ::com::sun::star::form::FormButtonType_SUBMIT;
+ using ::com::sun::star::form::binding::XValueBinding;
+ using ::com::sun::star::form::binding::XBindableValue;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::container::XIndexAccess;
+ using ::com::sun::star::form::XForm;
+ using ::com::sun::star::form::runtime::XFormController;
+ using ::com::sun::star::script::XEventAttacherManager;
+ using ::com::sun::star::awt::XTabControllerModel;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::container::XEnumeration;
+ using ::com::sun::star::task::XInteractionHandler;
+ using ::com::sun::star::lang::XInitialization;
+ using ::com::sun::star::awt::XTabController;
+ using ::com::sun::star::lang::XUnoTunnel;
+ using ::com::sun::star::awt::XControlContainer;
+ using ::com::sun::star::awt::XControl;
+ using ::com::sun::star::form::XFormComponent;
+ using ::com::sun::star::form::XForm;
+ using ::com::sun::star::lang::IndexOutOfBoundsException;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::container::XContainer;
+ using ::com::sun::star::container::ContainerEvent;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::beans::NamedValue;
+ using ::com::sun::star::sdb::SQLErrorEvent;
+ using ::com::sun::star::sdbc::XRowSet;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::container::XElementAccess;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::awt::FocusEvent;
+ using ::com::sun::star::ui::dialogs::XExecutableDialog;
+ using ::com::sun::star::sdbc::XDataSource;
+ using ::com::sun::star::container::XIndexContainer;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::sdb::SQLContext;
+ using ::com::sun::star::sdbc::SQLWarning;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::util::XNumberFormatsSupplier;
+ using ::com::sun::star::util::XNumberFormats;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ /** === end UNO using === **/
+ namespace FormComponentType = ::com::sun::star::form::FormComponentType;
+ namespace CommandType = ::com::sun::star::sdb::CommandType;
+ namespace DataType = ::com::sun::star::sdbc::DataType;
+
+//------------------------------------------------------------------------------
+class FmXFormView::ObjectRemoveListener : public SfxListener
+{
+ FmXFormView* m_pParent;
+public:
+ ObjectRemoveListener( FmXFormView* pParent );
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+};
+
+//========================================================================
+DBG_NAME(FmXPageViewWinRec)
+//------------------------------------------------------------------------
+FmXPageViewWinRec::FmXPageViewWinRec( const ::comphelper::ComponentContext& _rContext, const SdrPageWindow& _rWindow, FmXFormView* _pViewImpl )
+: m_xControlContainer( _rWindow.GetControlContainer() ),
+ m_aContext( _rContext ),
+ m_pViewImpl( _pViewImpl ),
+ m_pWindow( dynamic_cast< Window* >( &_rWindow.GetPaintWindow().GetOutputDevice() ) )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::FmXPageViewWinRec" );
+ DBG_CTOR(FmXPageViewWinRec,NULL);
+
+ // create an XFormController for every form
+ FmFormPage* pFormPage = dynamic_cast< FmFormPage* >( _rWindow.GetPageView().GetPage() );
+ DBG_ASSERT( pFormPage, "FmXPageViewWinRec::FmXPageViewWinRec: no FmFormPage found!" );
+ if ( pFormPage )
+ {
+ try
+ {
+ Reference< XIndexAccess > xForms( pFormPage->GetForms(), UNO_QUERY_THROW );
+ sal_uInt32 nLength = xForms->getCount();
+ for (sal_uInt32 i = 0; i < nLength; i++)
+ {
+ Reference< XForm > xForm( xForms->getByIndex(i), UNO_QUERY );
+ if ( xForm.is() )
+ setController( xForm, NULL );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+FmXPageViewWinRec::~FmXPageViewWinRec()
+{
+ DBG_DTOR(FmXPageViewWinRec,NULL);
+}
+
+//------------------------------------------------------------------
+void FmXPageViewWinRec::dispose()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::dispose" );
+ for ( ::std::vector< Reference< XFormController > >::const_iterator i = m_aControllerList.begin();
+ i != m_aControllerList.end();
+ ++i
+ )
+ {
+ try
+ {
+ Reference< XFormController > xController( *i, UNO_QUERY_THROW );
+
+ // detaching the events
+ Reference< XChild > xControllerModel( xController->getModel(), UNO_QUERY );
+ if ( xControllerModel.is() )
+ {
+ Reference< XEventAttacherManager > xEventManager( xControllerModel->getParent(), UNO_QUERY_THROW );
+ Reference< XInterface > xControllerNormalized( xController, UNO_QUERY_THROW );
+ xEventManager->detach( i - m_aControllerList.begin(), xControllerNormalized );
+ }
+
+ // dispose the formcontroller
+ Reference< XComponent > xComp( xController, UNO_QUERY_THROW );
+ xComp->dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ m_aControllerList.clear();
+}
+
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FmXPageViewWinRec::hasElements(void) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::hasElements" );
+ return getCount() != 0;
+}
+
+//------------------------------------------------------------------------------
+Type SAL_CALL FmXPageViewWinRec::getElementType(void) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::getElementType" );
+ return ::getCppuType((const Reference< XFormController>*)0);
+}
+
+// XEnumerationAccess
+//------------------------------------------------------------------------------
+Reference< XEnumeration > SAL_CALL FmXPageViewWinRec::createEnumeration(void) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::createEnumeration" );
+ return new ::comphelper::OEnumerationByIndex(this);
+}
+
+// XIndexAccess
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL FmXPageViewWinRec::getCount(void) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::getCount" );
+ return m_aControllerList.size();
+}
+
+//------------------------------------------------------------------------------
+Any SAL_CALL FmXPageViewWinRec::getByIndex(sal_Int32 nIndex) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::getByIndex" );
+ if (nIndex < 0 ||
+ nIndex >= getCount())
+ throw IndexOutOfBoundsException();
+
+ Any aElement;
+ aElement <<= m_aControllerList[nIndex];
+ return aElement;
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL FmXPageViewWinRec::makeVisible( const Reference< XControl >& _Control ) throw (RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+
+ Reference< XWindow > xWindow( _Control, UNO_QUERY );
+ if ( xWindow.is() && m_pViewImpl->getView() && m_pWindow )
+ {
+ awt::Rectangle aRect = xWindow->getPosSize();
+ ::Rectangle aNewRect( aRect.X, aRect.Y, aRect.X + aRect.Width, aRect.Y + aRect.Height );
+ aNewRect = m_pWindow->PixelToLogic( aNewRect );
+ m_pViewImpl->getView()->MakeVisible( aNewRect, *m_pWindow );
+ }
+}
+
+//------------------------------------------------------------------------
+Reference< XFormController > getControllerSearchChilds( const Reference< XIndexAccess > & xIndex, const Reference< XTabControllerModel > & xModel)
+{
+ if (xIndex.is() && xIndex->getCount())
+ {
+ Reference< XFormController > xController;
+
+ for (sal_Int32 n = xIndex->getCount(); n-- && !xController.is(); )
+ {
+ xIndex->getByIndex(n) >>= xController;
+ if ((XTabControllerModel*)xModel.get() == (XTabControllerModel*)xController->getModel().get())
+ return xController;
+ else
+ {
+ xController = getControllerSearchChilds(Reference< XIndexAccess > (xController, UNO_QUERY), xModel);
+ if ( xController.is() )
+ return xController;
+ }
+ }
+ }
+ return Reference< XFormController > ();
+}
+
+// Search the according controller
+//------------------------------------------------------------------------
+Reference< XFormController > FmXPageViewWinRec::getController( const Reference< XForm > & xForm ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::getController" );
+ Reference< XTabControllerModel > xModel(xForm, UNO_QUERY);
+ for (::std::vector< Reference< XFormController > >::const_iterator i = m_aControllerList.begin();
+ i != m_aControllerList.end(); i++)
+ {
+ if ((XTabControllerModel*)(*i)->getModel().get() == (XTabControllerModel*)xModel.get())
+ return *i;
+
+ // the current-round controller isn't the right one. perhaps one of it's children ?
+ Reference< XFormController > xChildSearch = getControllerSearchChilds(Reference< XIndexAccess > (*i, UNO_QUERY), xModel);
+ if (xChildSearch.is())
+ return xChildSearch;
+ }
+ return Reference< XFormController > ();
+}
+
+//------------------------------------------------------------------------
+void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, const Reference< XFormController >& _rxParentController )
+{
+ DBG_ASSERT( xForm.is(), "FmXPageViewWinRec::setController: there should be a form!" );
+ Reference< XIndexAccess > xFormCps(xForm, UNO_QUERY);
+ if (!xFormCps.is())
+ return;
+
+ Reference< XTabControllerModel > xTabOrder(xForm, UNO_QUERY);
+
+ // create a form controller
+ Reference< XFormController > xController( m_aContext.createComponent( FM_FORM_CONTROLLER ), UNO_QUERY );
+ if ( !xController.is() )
+ {
+ ShowServiceNotAvailableError( m_pWindow, FM_FORM_CONTROLLER, sal_True );
+ return;
+ }
+
+ Reference< XInteractionHandler > xHandler;
+ if ( _rxParentController.is() )
+ xHandler = _rxParentController->getInteractionHandler();
+ else
+ {
+ // TODO: should we create a default handler? Not really necessary, since the
+ // FormController itself has a default fallback
+ }
+ if ( xHandler.is() )
+ xController->setInteractionHandler( xHandler );
+
+ xController->setContext( this );
+
+ xController->setModel( xTabOrder );
+ xController->setContainer( m_xControlContainer );
+ xController->activateTabOrder();
+ xController->addActivateListener( m_pViewImpl );
+
+ if ( _rxParentController.is() )
+ _rxParentController->addChildController( xController );
+ else
+ {
+ m_aControllerList.push_back(xController);
+
+ xController->setParent( *this );
+
+ // attaching the events
+ Reference< XEventAttacherManager > xEventManager( xForm->getParent(), UNO_QUERY );
+ Reference< XInterface > xIfc(xController, UNO_QUERY);
+ xEventManager->attach(m_aControllerList.size() - 1, xIfc, makeAny(xController) );
+ }
+
+ // jetzt die Subforms durchgehen
+ sal_uInt32 nLength = xFormCps->getCount();
+ Reference< XForm > xSubForm;
+ for (sal_uInt32 i = 0; i < nLength; i++)
+ {
+ if ( xFormCps->getByIndex(i) >>= xSubForm )
+ setController( xSubForm, xController );
+ }
+}
+
+//------------------------------------------------------------------------
+void FmXPageViewWinRec::updateTabOrder( const Reference< XForm >& _rxForm )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::updateTabOrder" );
+ OSL_PRECOND( _rxForm.is(), "FmXPageViewWinRec::updateTabOrder: illegal argument!" );
+ if ( !_rxForm.is() )
+ return;
+
+ try
+ {
+ Reference< XTabController > xTabCtrl( getController( _rxForm ).get() );
+ if ( xTabCtrl.is() )
+ { // if there already is a TabController for this form, then delegate the "updateTabOrder" request
+ xTabCtrl->activateTabOrder();
+ }
+ else
+ { // otherwise, create a TabController
+
+ // if it's a sub form, then we must ensure there exist TabControllers
+ // for all its ancestors, too
+ Reference< XForm > xParentForm( _rxForm->getParent(), UNO_QUERY );
+ // there is a parent form -> look for the respective controller
+ Reference< XFormController > xParentController;
+ if ( xParentForm.is() )
+ xParentController.set( getController( xParentForm ), UNO_QUERY );
+
+ setController( _rxForm, xParentController );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------
+FmXFormView::FmXFormView(const ::comphelper::ComponentContext& _rContext, FmFormView* _pView )
+ :m_aContext( _rContext )
+ ,m_pMarkedGrid(NULL)
+ ,m_pView(_pView)
+ ,m_nActivationEvent(0)
+ ,m_nErrorMessageEvent( 0 )
+ ,m_nAutoFocusEvent( 0 )
+ ,m_nControlWizardEvent( 0 )
+ ,m_pWatchStoredList( NULL )
+ ,m_bFirstActivation( true )
+ ,m_isTabOrderUpdateSuspended( false )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::FmXFormView" );
+}
+
+//------------------------------------------------------------------------
+void FmXFormView::cancelEvents()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::cancelEvents" );
+ if ( m_nActivationEvent )
+ {
+ Application::RemoveUserEvent( m_nActivationEvent );
+ m_nActivationEvent = 0;
+ }
+
+ if ( m_nErrorMessageEvent )
+ {
+ Application::RemoveUserEvent( m_nErrorMessageEvent );
+ m_nErrorMessageEvent = 0;
+ }
+
+ if ( m_nAutoFocusEvent )
+ {
+ Application::RemoveUserEvent( m_nAutoFocusEvent );
+ m_nAutoFocusEvent = 0;
+ }
+
+ if ( m_nControlWizardEvent )
+ {
+ Application::RemoveUserEvent( m_nControlWizardEvent );
+ m_nControlWizardEvent = 0;
+ }
+}
+
+//------------------------------------------------------------------------
+void FmXFormView::notifyViewDying( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::notifyViewDying" );
+ DBG_ASSERT( m_pView, "FmXFormView::notifyViewDying: my view already died!" );
+ m_pView = NULL;
+ cancelEvents();
+}
+
+//------------------------------------------------------------------------
+FmXFormView::~FmXFormView()
+{
+ DBG_ASSERT(m_aWinList.size() == 0, "FmXFormView::~FmXFormView: Window list not empty!");
+
+ cancelEvents();
+
+ delete m_pWatchStoredList;
+ m_pWatchStoredList = NULL;
+}
+
+// EventListener
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFormView::disposing(const EventObject& Source) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::disposing" );
+ if ( m_xWindow.is() && Source.Source == m_xWindow )
+ removeGridWindowListening();
+}
+
+// XFormControllerListener
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFormView::formActivated(const EventObject& rEvent) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::formActivated" );
+ if ( m_pView && m_pView->GetFormShell() && m_pView->GetFormShell()->GetImpl() )
+ m_pView->GetFormShell()->GetImpl()->formActivated( rEvent );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFormView::formDeactivated(const EventObject& rEvent) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::formDeactivated" );
+ if ( m_pView && m_pView->GetFormShell() && m_pView->GetFormShell()->GetImpl() )
+ m_pView->GetFormShell()->GetImpl()->formDeactivated( rEvent );
+}
+
+// XContainerListener
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFormView::elementInserted(const ContainerEvent& evt) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::elementInserted" );
+ try
+ {
+ Reference< XControlContainer > xControlContainer( evt.Source, UNO_QUERY_THROW );
+ Reference< XControl > xControl( evt.Element, UNO_QUERY_THROW );
+ Reference< XFormComponent > xControlModel( xControl->getModel(), UNO_QUERY_THROW );
+ Reference< XForm > xForm( xControlModel->getParent(), UNO_QUERY_THROW );
+
+ if ( m_isTabOrderUpdateSuspended )
+ {
+ // remember the container and the control, so we can update the tab order on resumeTabOrderUpdate
+ m_aNeedTabOrderUpdate[ xControlContainer ].insert( xForm );
+ }
+ else
+ {
+ FmWinRecList::iterator pos = findWindow( xControlContainer );
+ if ( pos != m_aWinList.end() )
+ {
+ (*pos)->updateTabOrder( xForm );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFormView::elementReplaced(const ContainerEvent& evt) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::elementReplaced" );
+ elementInserted(evt);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FmXFormView::elementRemoved(const ContainerEvent& /*evt*/) throw( RuntimeException )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::elementRemoved" );
+}
+
+//------------------------------------------------------------------------------
+FmWinRecList::const_iterator FmXFormView::findWindow( const Reference< XControlContainer >& _rxCC ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::findWindow" );
+ for (FmWinRecList::const_iterator i = m_aWinList.begin();
+ i != m_aWinList.end(); i++)
+ {
+ if ( _rxCC == (*i)->getControlContainer() )
+ return i;
+ }
+ return m_aWinList.end();
+}
+
+//------------------------------------------------------------------------------
+FmWinRecList::iterator FmXFormView::findWindow( const Reference< XControlContainer >& _rxCC )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::findWindow" );
+ for (FmWinRecList::iterator i = m_aWinList.begin();
+ i != m_aWinList.end(); i++)
+ {
+ if ( _rxCC == (*i)->getControlContainer() )
+ return i;
+ }
+ return m_aWinList.end();
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::addWindow(const SdrPageWindow& rWindow)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::addWindow" );
+ FmFormPage* pFormPage = PTR_CAST( FmFormPage, rWindow.GetPageView().GetPage() );
+ if ( !pFormPage )
+ return;
+
+ Reference< XControlContainer > xCC = rWindow.GetControlContainer();
+ if ( xCC.is() && findWindow( xCC ) == m_aWinList.end())
+ {
+ FmXPageViewWinRec *pFmRec = new FmXPageViewWinRec( m_aContext, rWindow, this );
+ pFmRec->acquire();
+
+ m_aWinList.push_back(pFmRec);
+
+ // Am ControlContainer horchen um Aenderungen mitzbekommen
+ Reference< XContainer > xContainer( xCC, UNO_QUERY );
+ if (xContainer.is())
+ xContainer->addContainerListener(this);
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::removeWindow( const Reference< XControlContainer >& _rxCC )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::removeWindow" );
+ // Wird gerufen, wenn
+ // - in den Design-Modus geschaltet wird
+ // - ein Window geloescht wird, waehrend man im Design-Modus ist
+ // - der Control-Container fuer ein Window entfernt wird, waehrend
+ // der aktive Modus eingeschaltet ist.
+ FmWinRecList::iterator i = findWindow( _rxCC );
+ if (i != m_aWinList.end())
+ {
+ // Am ControlContainer horchen um Aenderungen mitzbekommen
+ Reference< XContainer > xContainer( _rxCC, UNO_QUERY );
+ if (xContainer.is())
+ xContainer->removeContainerListener(this);
+
+ (*i)->dispose();
+ (*i)->release();
+ m_aWinList.erase(i);
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::displayAsyncErrorMessage( const SQLErrorEvent& _rEvent )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::displayAsyncErrorMessage" );
+ DBG_ASSERT( 0 == m_nErrorMessageEvent, "FmXFormView::displayAsyncErrorMessage: not too fast, please!" );
+ // This should not happen - usually, the PostUserEvent is faster than any possible user
+ // interaction which could trigger a new error. If it happens, we need a queue for the events.
+ m_aAsyncError = _rEvent;
+ m_nErrorMessageEvent = Application::PostUserEvent( LINK( this, FmXFormView, OnDelayedErrorMessage ) );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FmXFormView, OnDelayedErrorMessage, void*, /*EMPTYTAG*/)
+{
+ m_nErrorMessageEvent = 0;
+ displayException( m_aAsyncError );
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::onFirstViewActivation( const FmFormModel* _pDocModel )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::onFirstViewActivation" );
+ if ( _pDocModel && _pDocModel->GetAutoControlFocus() )
+ m_nAutoFocusEvent = Application::PostUserEvent( LINK( this, FmXFormView, OnAutoFocus ) );
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::suspendTabOrderUpdate()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::suspendTabOrderUpdate" );
+ OSL_ENSURE( !m_isTabOrderUpdateSuspended, "FmXFormView::suspendTabOrderUpdate: nesting not allowed!" );
+ m_isTabOrderUpdateSuspended = true;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::resumeTabOrderUpdate()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::resumeTabOrderUpdate" );
+ OSL_ENSURE( m_isTabOrderUpdateSuspended, "FmXFormView::resumeTabOrderUpdate: not suspended!" );
+ m_isTabOrderUpdateSuspended = false;
+
+ // update the tab orders for all components which were collected since the suspendTabOrderUpdate call.
+ for ( MapControlContainerToSetOfForms::const_iterator container = m_aNeedTabOrderUpdate.begin();
+ container != m_aNeedTabOrderUpdate.end();
+ ++container
+ )
+ {
+ FmWinRecList::iterator pos = findWindow( container->first );
+ if ( pos == m_aWinList.end() )
+ continue;
+
+ for ( SetOfForms::const_iterator form = container->second.begin();
+ form != container->second.end();
+ ++form
+ )
+ {
+ (*pos)->updateTabOrder( *form );
+ }
+ }
+ m_aNeedTabOrderUpdate.clear();
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FmXFormView, OnActivate, void*, /*EMPTYTAG*/)
+{
+ m_nActivationEvent = 0;
+
+ if ( !m_pView )
+ {
+ DBG_ERROR( "FmXFormView::OnActivate: well .... seems we have a timing problem (the view already died)!" );
+ return 0;
+ }
+
+ // setting the controller to activate
+ if (m_pView->GetFormShell() && m_pView->GetActualOutDev() && m_pView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW)
+ {
+ Window* pWindow = const_cast<Window*>(static_cast<const Window*>(m_pView->GetActualOutDev()));
+ FmXPageViewWinRec* pFmRec = m_aWinList.size() ? m_aWinList[0] : NULL;
+ for (FmWinRecList::const_iterator i = m_aWinList.begin();
+ i != m_aWinList.end(); i++)
+ {
+ if (pWindow == (*i)->getWindow())
+ pFmRec =*i;
+ }
+
+ if (pFmRec)
+ {
+ for (::std::vector< Reference< XFormController > >::const_iterator i = pFmRec->GetList().begin();
+ i != pFmRec->GetList().end(); i++)
+ {
+ const Reference< XFormController > & xController = *i;
+ if (xController.is())
+ {
+ // Nur bei Datenbankformularen erfolgt eine aktivierung
+ Reference< XRowSet > xForm(xController->getModel(), UNO_QUERY);
+ if (xForm.is() && OStaticDataAccessTools().getRowSetConnection(xForm).is())
+ {
+ Reference< XPropertySet > xFormSet(xForm, UNO_QUERY);
+ if (xFormSet.is())
+ {
+ // wenn es eine Datenquelle gibt, dann als aktive ::com::sun::star::form setzen
+ ::rtl::OUString aSource = ::comphelper::getString(xFormSet->getPropertyValue(FM_PROP_COMMAND));
+ if (aSource.getLength())
+ {
+ // benachrichtigung der Shell
+ FmXFormShell* pShImpl = m_pView->GetFormShell()->GetImpl();
+ if (pShImpl)
+ pShImpl->setActiveController(xController);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::Activate(sal_Bool bSync)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::Activate" );
+ if (m_nActivationEvent)
+ {
+ Application::RemoveUserEvent(m_nActivationEvent);
+ m_nActivationEvent = 0;
+ }
+
+ if (bSync)
+ {
+ LINK(this,FmXFormView,OnActivate).Call(NULL);
+ }
+ else
+ m_nActivationEvent = Application::PostUserEvent(LINK(this,FmXFormView,OnActivate));
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::Deactivate(BOOL bDeactivateController)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::Deactivate" );
+ if (m_nActivationEvent)
+ {
+ Application::RemoveUserEvent(m_nActivationEvent);
+ m_nActivationEvent = 0;
+ }
+
+ FmXFormShell* pShImpl = m_pView->GetFormShell() ? m_pView->GetFormShell()->GetImpl() : NULL;
+ if (pShImpl && bDeactivateController)
+ pShImpl->setActiveController( NULL );
+}
+
+//------------------------------------------------------------------------------
+FmFormShell* FmXFormView::GetFormShell() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::GetFormShell" );
+ return m_pView ? m_pView->GetFormShell() : NULL;
+}
+// -----------------------------------------------------------------------------
+void FmXFormView::AutoFocus( sal_Bool _bSync )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::AutoFocus" );
+ if (m_nAutoFocusEvent)
+ Application::RemoveUserEvent(m_nAutoFocusEvent);
+
+ if ( _bSync )
+ OnAutoFocus( NULL );
+ else
+ m_nAutoFocusEvent = Application::PostUserEvent(LINK(this, FmXFormView, OnAutoFocus));
+}
+
+// -----------------------------------------------------------------------------
+bool FmXFormView::isFocusable( const Reference< XControl >& i_rControl )
+{
+ if ( !i_rControl.is() )
+ return false;
+
+ try
+ {
+ Reference< XPropertySet > xModelProps( i_rControl->getModel(), UNO_QUERY_THROW );
+
+ // only enabled controls are allowed to participate
+ sal_Bool bEnabled = sal_False;
+ OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_ENABLED ) >>= bEnabled );
+ if ( !bEnabled )
+ return false;
+
+ // check the class id of the control model
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ OSL_VERIFY( xModelProps->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId );
+
+ // controls which are not focussable
+ if ( ( FormComponentType::CONTROL != nClassId )
+ && ( FormComponentType::IMAGEBUTTON != nClassId )
+ && ( FormComponentType::GROUPBOX != nClassId )
+ && ( FormComponentType::FIXEDTEXT != nClassId )
+ && ( FormComponentType::HIDDENCONTROL != nClassId )
+ && ( FormComponentType::IMAGECONTROL != nClassId )
+ && ( FormComponentType::SCROLLBAR != nClassId )
+ && ( FormComponentType::SPINBUTTON!= nClassId )
+ )
+ {
+ return true;
+ }
+ }
+ catch( const Exception& e )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+static Reference< XControl > lcl_firstFocussableControl( const Sequence< Reference< XControl > >& _rControls )
+{
+ Reference< XControl > xReturn;
+
+ // loop through all the controls
+ const Reference< XControl >* pControls = _rControls.getConstArray();
+ const Reference< XControl >* pControlsEnd = _rControls.getConstArray() + _rControls.getLength();
+ for ( ; pControls != pControlsEnd; ++pControls )
+ {
+ if ( !pControls->is() )
+ continue;
+
+ if ( FmXFormView::isFocusable( *pControls ) )
+ {
+ xReturn = *pControls;
+ break;
+ }
+ }
+
+ if ( !xReturn.is() && _rControls.getLength() )
+ xReturn = _rControls[0];
+
+ return xReturn;
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ // .........................................................................
+ void lcl_ensureControlsOfFormExist_nothrow( const SdrPage& _rPage, const SdrView& _rView, const Window& _rWindow, const Reference< XForm >& _rxForm )
+ {
+ try
+ {
+ Reference< XInterface > xNormalizedForm( _rxForm, UNO_QUERY_THROW );
+
+ SdrObjListIter aSdrObjectLoop( _rPage, IM_DEEPNOGROUPS );
+ while ( aSdrObjectLoop.IsMore() )
+ {
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( aSdrObjectLoop.Next() );
+ if ( !pFormObject )
+ continue;
+
+ Reference< XChild > xModel( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
+ Reference< XInterface > xModelParent( xModel->getParent(), UNO_QUERY_THROW );
+
+ if ( xNormalizedForm.get() != xModelParent.get() )
+ continue;
+
+ pFormObject->GetUnoControl( _rView, _rWindow );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+Reference< XFormController > FmXFormView::getFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::getFormController" );
+ Reference< XFormController > xController;
+
+ for ( FmWinRecList::const_iterator rec = m_aWinList.begin(); rec != m_aWinList.end(); ++rec )
+ {
+ const FmXPageViewWinRec* pViewWinRec( *rec );
+ OSL_ENSURE( pViewWinRec, "FmXFormView::getFormController: invalid PageViewWinRec!" );
+ if ( !pViewWinRec || ( pViewWinRec->getWindow() != &_rDevice ) )
+ // wrong device
+ continue;
+
+ xController = pViewWinRec->getController( _rxForm );
+ if ( xController.is() )
+ break;
+ }
+ return xController;
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK(FmXFormView, OnAutoFocus, void*, /*EMPTYTAG*/)
+{
+ m_nAutoFocusEvent = 0;
+
+ // go to the first form of our page, examine it's TabController, go to it's first (in terms of the tab order)
+ // control, give it the focus
+
+ do
+ {
+
+ // get the forms collection of the page we belong to
+ FmFormPage* pPage = m_pView ? PTR_CAST( FmFormPage, m_pView->GetSdrPageView()->GetPage() ) : NULL;
+ Reference< XIndexAccess > xForms( pPage ? Reference< XIndexAccess >( pPage->GetForms(), UNO_QUERY ) : Reference< XIndexAccess >() );
+
+ const FmXPageViewWinRec* pViewWinRec = m_aWinList.size() ? m_aWinList[0] : NULL;
+ const Window* pWindow = pViewWinRec ? pViewWinRec->getWindow() : NULL;
+
+ OSL_ENSURE( xForms.is() && pWindow, "FmXFormView::OnAutoFocus: could not collect all essentials!" );
+ if ( !xForms.is() || !pWindow )
+ return 0L;
+
+ try
+ {
+ // go for the tab controller of the first form
+ if ( !xForms->getCount() )
+ break;
+ Reference< XForm > xForm( xForms->getByIndex( 0 ), UNO_QUERY_THROW );
+ Reference< XTabController > xTabController( pViewWinRec->getController( xForm ), UNO_QUERY_THROW );
+
+ // go for the first control of the controller
+ Sequence< Reference< XControl > > aControls( xTabController->getControls() );
+ if ( aControls.getLength() == 0 )
+ {
+ Reference< XElementAccess > xFormElementAccess( xForm, UNO_QUERY_THROW );
+ if ( xFormElementAccess->hasElements() )
+ {
+ // there are control models in the form, but no controls, yet.
+ // Well, since some time controls are created on demand only. In particular,
+ // they're normally created when they're first painted.
+ // Unfortunately, the FormController does not have any way to
+ // trigger the creation itself, so we must hack this ...
+ lcl_ensureControlsOfFormExist_nothrow( *pPage, *m_pView, *pWindow, xForm );
+ aControls = xTabController->getControls();
+ OSL_ENSURE( aControls.getLength(), "FmXFormView::OnAutoFocus: no controls at all!" );
+ }
+ }
+
+ // set the focus to this first control
+ Reference< XWindow > xControlWindow( lcl_firstFocussableControl( aControls ), UNO_QUERY );
+ if ( !xControlWindow.is() )
+ break;
+
+ xControlWindow->setFocus();
+
+ // ensure that the control is visible
+ // 80210 - 12/07/00 - FS
+ const Window* pCurrentWindow = dynamic_cast< const Window* >( m_pView->GetActualOutDev() );
+ if ( pCurrentWindow )
+ {
+ awt::Rectangle aRect = xControlWindow->getPosSize();
+ ::Rectangle aNonUnoRect( aRect.X, aRect.Y, aRect.X + aRect.Width, aRect.Y + aRect.Height );
+ m_pView->MakeVisible( pCurrentWindow->PixelToLogic( aNonUnoRect ), *const_cast< Window* >( pCurrentWindow ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ } // do
+ while ( false );
+
+ return 1L;
+}
+
+// -----------------------------------------------------------------------------
+void FmXFormView::onCreatedFormObject( FmFormObj& _rFormObject )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::onCreatedFormObject" );
+ FmFormShell* pShell = m_pView ? m_pView->GetFormShell() : NULL;
+ FmXFormShell* pShellImpl = pShell ? pShell->GetImpl() : NULL;
+ OSL_ENSURE( pShellImpl, "FmXFormView::onCreatedFormObject: no form shell!" );
+ if ( !pShellImpl )
+ return;
+
+ // it is valid that the form shell's forms collection is not initialized, yet
+ pShellImpl->UpdateForms( sal_True );
+
+ m_xLastCreatedControlModel.set( _rFormObject.GetUnoControlModel(), UNO_QUERY );
+ if ( !m_xLastCreatedControlModel.is() )
+ return;
+
+ // some initial property defaults
+ FormControlFactory aControlFactory( m_aContext );
+ aControlFactory.initializeControlModel( pShellImpl->getDocumentType(), _rFormObject );
+
+ if ( !pShellImpl->GetWizardUsing() )
+ return;
+
+ // #i31958# don't call wizards in XForms mode
+ if ( pShellImpl->isEnhancedForm() )
+ return;
+
+ // #i46898# no wizards if there is no Base installed - currently, all wizards are
+ // database related
+ if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ return;
+
+ if ( m_nControlWizardEvent )
+ Application::RemoveUserEvent( m_nControlWizardEvent );
+ m_nControlWizardEvent = Application::PostUserEvent( LINK( this, FmXFormView, OnStartControlWizard ) );
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK( FmXFormView, OnStartControlWizard, void*, /**/ )
+{
+ m_nControlWizardEvent = 0;
+ OSL_PRECOND( m_xLastCreatedControlModel.is(), "FmXFormView::OnStartControlWizard: illegal call!" );
+ if ( !m_xLastCreatedControlModel.is() )
+ return 0L;
+
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ try
+ {
+ OSL_VERIFY( m_xLastCreatedControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ const sal_Char* pWizardAsciiName = NULL;
+ switch ( nClassId )
+ {
+ case FormComponentType::GRIDCONTROL:
+ pWizardAsciiName = "com.sun.star.sdb.GridControlAutoPilot";
+ break;
+ case FormComponentType::LISTBOX:
+ case FormComponentType::COMBOBOX:
+ pWizardAsciiName = "com.sun.star.sdb.ListComboBoxAutoPilot";
+ break;
+ case FormComponentType::GROUPBOX:
+ pWizardAsciiName = "com.sun.star.sdb.GroupBoxAutoPilot";
+ break;
+ }
+
+ if ( pWizardAsciiName )
+ {
+ // build the argument list
+ ::comphelper::NamedValueCollection aWizardArgs;
+ aWizardArgs.put( "ObjectModel", m_xLastCreatedControlModel );
+
+ // create the wizard object
+ Reference< XExecutableDialog > xWizard;
+ try
+ {
+ m_aContext.createComponentWithArguments( pWizardAsciiName, aWizardArgs.getWrappedPropertyValues(), xWizard );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( !xWizard.is() )
+ {
+ ShowServiceNotAvailableError( NULL, String::CreateFromAscii( pWizardAsciiName ), sal_True );
+ }
+ else
+ {
+ // execute the wizard
+ try
+ {
+ xWizard->execute();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ m_xLastCreatedControlModel.clear();
+ return 1L;
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ void lcl_insertIntoFormComponentHierarchy_throw( const FmFormView& _rView, const SdrUnoObj& _rSdrObj,
+ const Reference< XDataSource >& _rxDataSource = NULL, const ::rtl::OUString& _rDataSourceName = ::rtl::OUString(),
+ const ::rtl::OUString& _rCommand = ::rtl::OUString(), const sal_Int32 _nCommandType = -1 )
+ {
+ FmFormPage& rPage = static_cast< FmFormPage& >( *_rView.GetSdrPageView()->GetPage() );
+
+ Reference< XFormComponent > xFormComponent( _rSdrObj.GetUnoControlModel(), UNO_QUERY_THROW );
+ Reference< XForm > xTargetForm(
+ rPage.GetImpl().findPlaceInFormComponentHierarchy( xFormComponent, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType ),
+ UNO_SET_THROW );
+
+ rPage.GetImpl().setUniqueName( xFormComponent, xTargetForm );
+
+ Reference< XIndexContainer > xFormAsContainer( xTargetForm, UNO_QUERY_THROW );
+ xFormAsContainer->insertByIndex( xFormAsContainer->getCount(), makeAny( xFormComponent ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescriptor& _rColumnDescriptor )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::implCreateFieldControl" );
+ // not if we're in design mode
+ if ( !m_pView->IsDesignMode() )
+ return NULL;
+
+ ::rtl::OUString sCommand, sFieldName;
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ SharedConnection xConnection;
+
+ ::rtl::OUString sDataSource = _rColumnDescriptor.getDataSource();
+ _rColumnDescriptor[ daCommand ] >>= sCommand;
+ _rColumnDescriptor[ daColumnName ] >>= sFieldName;
+ _rColumnDescriptor[ daCommandType ] >>= nCommandType;
+ {
+ Reference< XConnection > xExternalConnection;
+ _rColumnDescriptor[ daConnection ] >>= xExternalConnection;
+ xConnection.reset( xExternalConnection, SharedConnection::NoTakeOwnership );
+ }
+
+ if ( !sCommand.getLength()
+ || !sFieldName.getLength()
+ || ( !sDataSource.getLength()
+ && !xConnection.is()
+ )
+ )
+ {
+ DBG_ERROR( "FmXFormView::implCreateFieldControl: nonsense!" );
+ }
+
+ Reference< XDataSource > xDataSource;
+ SQLErrorEvent aError;
+ try
+ {
+ if ( xConnection.is() && !xDataSource.is() && !sDataSource.getLength() )
+ {
+ Reference< XChild > xChild( xConnection, UNO_QUERY );
+ if ( xChild.is() )
+ xDataSource = xDataSource.query( xChild->getParent() );
+ }
+
+ // obtain the data source
+ if ( !xDataSource.is() )
+ xDataSource = OStaticDataAccessTools().getDataSource( sDataSource, m_aContext.getLegacyServiceFactory() );
+
+ // and the connection, if necessary
+ if ( !xConnection.is() )
+ xConnection.reset( OStaticDataAccessTools().getConnection_withFeedback(
+ sDataSource,
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ m_aContext.getLegacyServiceFactory()
+ ) );
+ }
+ catch ( const SQLException& )
+ {
+ aError.Reason = ::cppu::getCaughtException();
+ }
+ catch( const Exception& ) { /* will be asserted below */ }
+ if (aError.Reason.hasValue())
+ {
+ displayAsyncErrorMessage( aError );
+ return NULL;
+ }
+
+ // need a data source and a connection here
+ if (!xDataSource.is() || !xConnection.is())
+ {
+ DBG_ERROR("FmXFormView::implCreateFieldControl : could not retrieve the data source or the connection!");
+ return NULL;
+ }
+
+ OStaticDataAccessTools aDBATools;
+ Reference< XComponent > xKeepFieldsAlive;
+ // go
+ try
+ {
+ // determine the table/query field which we should create a control for
+ Reference< XPropertySet > xField;
+
+ Reference< XNameAccess > xFields = aDBATools.getFieldsByCommandDescriptor(
+ xConnection, nCommandType, sCommand, xKeepFieldsAlive );
+
+ if (xFields.is() && xFields->hasByName(sFieldName))
+ xFields->getByName(sFieldName) >>= xField;
+ if ( !xField.is() )
+ return NULL;
+
+ Reference< XNumberFormatsSupplier > xSupplier( aDBATools.getNumberFormats( xConnection, sal_False ), UNO_SET_THROW );
+ Reference< XNumberFormats > xNumberFormats( xSupplier->getNumberFormats(), UNO_SET_THROW );
+
+ ::rtl::OUString sLabelPostfix;
+
+ ////////////////////////////////////////////////////////////////
+ // nur fuer Textgroesse
+ OutputDevice* pOutDev = NULL;
+ if (m_pView->GetActualOutDev() && m_pView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW)
+ pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev());
+ else
+ {// OutDev suchen
+ SdrPageView* pPageView = m_pView->GetSdrPageView();
+ if( pPageView && !pOutDev )
+ {
+ // const SdrPageViewWinList& rWinList = pPageView->GetWinList();
+ // const SdrPageViewWindows& rPageViewWindows = pPageView->GetPageViewWindows();
+
+ for( sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); i++ )
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
+
+ if( rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ pOutDev = &rPageWindow.GetPaintWindow().GetOutputDevice();
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !pOutDev )
+ return NULL;
+
+ sal_Int32 nDataType = ::comphelper::getINT32(xField->getPropertyValue(FM_PROP_FIELDTYPE));
+ if ((DataType::BINARY == nDataType) || (DataType::VARBINARY == nDataType))
+ return NULL;
+
+ //////////////////////////////////////////////////////////////////////
+ // determine the control type by examining the data type of the bound column
+ sal_uInt16 nOBJID = 0;
+ sal_Bool bDateNTimeField = sal_False;
+
+ sal_Bool bIsCurrency = sal_False;
+ if (::comphelper::hasProperty(FM_PROP_ISCURRENCY, xField))
+ bIsCurrency = ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_ISCURRENCY));
+
+ if (bIsCurrency)
+ nOBJID = OBJ_FM_CURRENCYFIELD;
+ else
+ switch (nDataType)
+ {
+ case DataType::BLOB:
+ case DataType::LONGVARBINARY:
+ nOBJID = OBJ_FM_IMAGECONTROL;
+ break;
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ nOBJID = OBJ_FM_EDIT;
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ return NULL;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nOBJID = OBJ_FM_CHECKBOX;
+ break;
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ nOBJID = OBJ_FM_NUMERICFIELD;
+ break;
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ nOBJID = OBJ_FM_FORMATTEDFIELD;
+ break;
+ case DataType::TIMESTAMP:
+ bDateNTimeField = sal_True;
+ sLabelPostfix = String( SVX_RES( RID_STR_POSTFIX_DATE ) );
+ // DON'T break !
+ case DataType::DATE:
+ nOBJID = OBJ_FM_DATEFIELD;
+ break;
+ case DataType::TIME:
+ nOBJID = OBJ_FM_TIMEFIELD;
+ break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ default:
+ nOBJID = OBJ_FM_EDIT;
+ break;
+ }
+ if (!nOBJID)
+ return NULL;
+
+ SdrUnoObj* pLabel( NULL );
+ SdrUnoObj* pControl( NULL );
+ if ( !createControlLabelPair( *pOutDev, 0, 0, xField, xNumberFormats, nOBJID, sLabelPostfix,
+ pLabel, pControl, xDataSource, sDataSource, sCommand, nCommandType )
+ )
+ {
+ return NULL;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // group objects
+ bool bCheckbox = ( OBJ_FM_CHECKBOX == nOBJID );
+ OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateFieldControl: why was there a label created for a check box?" );
+ if ( bCheckbox )
+ return pControl;
+
+ SdrObjGroup* pGroup = new SdrObjGroup();
+ SdrObjList* pObjList = pGroup->GetSubList();
+ pObjList->InsertObject( pLabel );
+ pObjList->InsertObject( pControl );
+
+ if ( bDateNTimeField )
+ { // so far we created a date field only, but we also need a time field
+ pLabel = pControl = NULL;
+ if ( createControlLabelPair( *pOutDev, 0, 1000, xField, xNumberFormats, OBJ_FM_TIMEFIELD,
+ String( SVX_RES( RID_STR_POSTFIX_TIME ) ), pLabel, pControl,
+ xDataSource, sDataSource, sCommand, nCommandType )
+ )
+ {
+ pObjList->InsertObject( pLabel );
+ pObjList->InsertObject( pControl );
+ }
+ }
+
+ return pGroup; // und fertig
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+
+ return NULL;
+}
+
+// -----------------------------------------------------------------------------
+SdrObject* FmXFormView::implCreateXFormsControl( const ::svx::OXFormsDescriptor &_rDesc )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::implCreateXFormsControl" );
+ // not if we're in design mode
+ if ( !m_pView->IsDesignMode() )
+ return NULL;
+
+ Reference< XComponent > xKeepFieldsAlive;
+
+ // go
+ try
+ {
+ // determine the table/query field which we should create a control for
+ Reference< XNumberFormats > xNumberFormats;
+ ::rtl::OUString sLabelPostfix = _rDesc.szName;
+
+ ////////////////////////////////////////////////////////////////
+ // nur fuer Textgroesse
+ OutputDevice* pOutDev = NULL;
+ if (m_pView->GetActualOutDev() && m_pView->GetActualOutDev()->GetOutDevType() == OUTDEV_WINDOW)
+ pOutDev = const_cast<OutputDevice*>(m_pView->GetActualOutDev());
+ else
+ {// OutDev suchen
+ SdrPageView* pPageView = m_pView->GetSdrPageView();
+ if( pPageView && !pOutDev )
+ {
+ // const SdrPageViewWinList& rWinList = pPageView->GetWinList();
+ // const SdrPageViewWindows& rPageViewWindows = pPageView->GetPageViewWindows();
+
+ for( sal_uInt32 i = 0L; i < pPageView->PageWindowCount(); i++ )
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(i);
+
+ if( rPageWindow.GetPaintWindow().GetOutputDevice().GetOutDevType() == OUTDEV_WINDOW)
+ {
+ pOutDev = &rPageWindow.GetPaintWindow().GetOutputDevice();
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !pOutDev )
+ return NULL;
+
+ //////////////////////////////////////////////////////////////////////
+ // The service name decides which control should be created
+ sal_uInt16 nOBJID = OBJ_FM_EDIT;
+ if(::rtl::OUString(_rDesc.szServiceName).equals((::rtl::OUString)FM_SUN_COMPONENT_NUMERICFIELD))
+ nOBJID = OBJ_FM_NUMERICFIELD;
+ if(::rtl::OUString(_rDesc.szServiceName).equals((::rtl::OUString)FM_SUN_COMPONENT_CHECKBOX))
+ nOBJID = OBJ_FM_CHECKBOX;
+ if(::rtl::OUString(_rDesc.szServiceName).equals((::rtl::OUString)FM_COMPONENT_COMMANDBUTTON))
+ nOBJID = OBJ_FM_BUTTON;
+
+ typedef ::com::sun::star::form::submission::XSubmission XSubmission_t;
+ Reference< XSubmission_t > xSubmission(_rDesc.xPropSet, UNO_QUERY);
+
+ // xform control or submission button?
+ if ( !xSubmission.is() )
+ {
+ SdrUnoObj* pLabel( NULL );
+ SdrUnoObj* pControl( NULL );
+ if ( !createControlLabelPair( *pOutDev, 0, 0, NULL, xNumberFormats, nOBJID, sLabelPostfix,
+ pLabel, pControl )
+ )
+ {
+ return NULL;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Now build the connection between the control and the data item.
+ Reference< XValueBinding > xValueBinding(_rDesc.xPropSet,UNO_QUERY);
+ Reference< XBindableValue > xBindableValue(pControl->GetUnoControlModel(),UNO_QUERY);
+
+ DBG_ASSERT( xBindableValue.is(), "FmXFormView::implCreateXFormsControl: control's not bindable!" );
+ if ( xBindableValue.is() )
+ xBindableValue->setValueBinding(xValueBinding);
+
+ bool bCheckbox = ( OBJ_FM_CHECKBOX == nOBJID );
+ OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateXFormsControl: why was there a label created for a check box?" );
+ if ( bCheckbox )
+ return pControl;
+
+ //////////////////////////////////////////////////////////////////////
+ // group objects
+ SdrObjGroup* pGroup = new SdrObjGroup();
+ SdrObjList* pObjList = pGroup->GetSubList();
+ pObjList->InsertObject(pLabel);
+ pObjList->InsertObject(pControl);
+
+ return pGroup;
+ }
+ else {
+
+ // create a button control
+ const MapMode eTargetMode( pOutDev->GetMapMode() );
+ const MapMode eSourceMode(MAP_100TH_MM);
+ const sal_uInt16 nObjID = OBJ_FM_BUTTON;
+ ::Size controlSize(4000, 500);
+ FmFormObj *pControl = static_cast<FmFormObj*>(SdrObjFactory::MakeNewObject( FmFormInventor, nObjID, NULL, NULL ));
+ controlSize.Width() = Fraction(controlSize.Width(), 1) * eTargetMode.GetScaleX();
+ controlSize.Height() = Fraction(controlSize.Height(), 1) * eTargetMode.GetScaleY();
+ ::Point controlPos( pOutDev->LogicToLogic( ::Point( controlSize.Width(), 0 ), eSourceMode, eTargetMode ) );
+ ::Rectangle controlRect( controlPos, pOutDev->LogicToLogic( controlSize, eSourceMode, eTargetMode ) );
+ pControl->SetLogicRect(controlRect);
+
+ // set the button label
+ Reference< XPropertySet > xControlSet(pControl->GetUnoControlModel(), UNO_QUERY);
+ xControlSet->setPropertyValue(FM_PROP_LABEL, makeAny(::rtl::OUString(_rDesc.szName)));
+
+ // connect the submission with the submission supplier (aka the button)
+ xControlSet->setPropertyValue( FM_PROP_BUTTON_TYPE,
+ makeAny( FormButtonType_SUBMIT ) );
+ typedef ::com::sun::star::form::submission::XSubmissionSupplier XSubmissionSupplier_t;
+ Reference< XSubmissionSupplier_t > xSubmissionSupplier(pControl->GetUnoControlModel(), UNO_QUERY);
+ xSubmissionSupplier->setSubmission(xSubmission);
+
+ return pControl;
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR("FmXFormView::implCreateXFormsControl: caught an exception while creating the control !");
+ }
+
+
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+bool FmXFormView::createControlLabelPair( OutputDevice& _rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM,
+ const Reference< XPropertySet >& _rxField, const Reference< XNumberFormats >& _rxNumberFormats,
+ sal_uInt16 _nControlObjectID, const ::rtl::OUString& _rFieldPostfix,
+ SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl,
+ const Reference< XDataSource >& _rxDataSource, const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rCommand, const sal_Int32 _nCommandType )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::createControlLabelPair" );
+ if ( !createControlLabelPair( m_aContext, _rOutDev, _nXOffsetMM, _nYOffsetMM,
+ _rxField, _rxNumberFormats, _nControlObjectID, _rFieldPostfix, FmFormInventor, OBJ_FM_FIXEDTEXT,
+ NULL, NULL, NULL, _rpLabel, _rpControl )
+ )
+ return false;
+
+ // insert the control model(s) into the form component hierachy
+ if ( _rpLabel )
+ lcl_insertIntoFormComponentHierarchy_throw( *m_pView, *_rpLabel, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType );
+ lcl_insertIntoFormComponentHierarchy_throw( *m_pView, *_rpControl, _rxDataSource, _rDataSourceName, _rCommand, _nCommandType );
+
+ // some context-dependent initializations
+ FormControlFactory aControlFactory( m_aContext );
+ if ( _rpLabel )
+ aControlFactory.initializeControlModel( impl_getDocumentType(), *_rpLabel );
+ aControlFactory.initializeControlModel( impl_getDocumentType(), *_rpControl );
+
+ return true;
+}
+
+//------------------------------------------------------------------------
+bool FmXFormView::createControlLabelPair( const ::comphelper::ComponentContext& _rContext,
+ OutputDevice& _rOutDev, sal_Int32 _nXOffsetMM, sal_Int32 _nYOffsetMM, const Reference< XPropertySet >& _rxField,
+ const Reference< XNumberFormats >& _rxNumberFormats, sal_uInt16 _nControlObjectID,
+ const ::rtl::OUString& _rFieldPostfix, UINT32 _nInventor, UINT16 _nLabelObjectID,
+ SdrPage* _pLabelPage, SdrPage* _pControlPage, SdrModel* _pModel, SdrUnoObj*& _rpLabel, SdrUnoObj*& _rpControl)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::createControlLabelPair" );
+ sal_Int32 nDataType = 0;
+ ::rtl::OUString sFieldName;
+ Any aFieldName;
+ if ( _rxField.is() )
+ {
+ nDataType = ::comphelper::getINT32(_rxField->getPropertyValue(FM_PROP_FIELDTYPE));
+ aFieldName = Any(_rxField->getPropertyValue(FM_PROP_NAME));
+ aFieldName >>= sFieldName;
+ }
+
+ // calculate the positions, respecting the settings of the target device
+ ::Size aTextSize( _rOutDev.GetTextWidth(sFieldName + _rFieldPostfix), _rOutDev.GetTextHeight() );
+
+ MapMode eTargetMode( _rOutDev.GetMapMode() ),
+ eSourceMode( MAP_100TH_MM );
+
+ // Textbreite ist mindestens 4cm
+ // Texthoehe immer halber cm
+ ::Size aDefTxtSize(4000, 500);
+ ::Size aDefSize(4000, 500);
+ ::Size aDefImageSize(4000, 4000);
+
+ ::Size aRealSize = _rOutDev.LogicToLogic(aTextSize, eTargetMode, eSourceMode);
+ aRealSize.Width() = std::max(aRealSize.Width(), aDefTxtSize.Width());
+ aRealSize.Height()= aDefSize.Height();
+
+ // adjust to scaling of the target device (#53523#)
+ aRealSize.Width() = long(Fraction(aRealSize.Width(), 1) * eTargetMode.GetScaleX());
+ aRealSize.Height() = long(Fraction(aRealSize.Height(), 1) * eTargetMode.GetScaleY());
+
+ // for boolean fields, we do not create a label, but just a checkbox
+ bool bNeedLabel = ( _nControlObjectID != OBJ_FM_CHECKBOX );
+
+ // the label
+ ::std::auto_ptr< SdrUnoObj > pLabel;
+ Reference< XPropertySet > xLabelModel;
+ if ( bNeedLabel )
+ {
+ pLabel.reset( dynamic_cast< SdrUnoObj* >(
+ SdrObjFactory::MakeNewObject( _nInventor, _nLabelObjectID, _pLabelPage, _pModel ) ) );
+ OSL_ENSURE( pLabel.get(), "FmXFormView::createControlLabelPair: could not create the label!" );
+ if ( !pLabel.get() )
+ return false;
+
+ xLabelModel.set( pLabel->GetUnoControlModel(), UNO_QUERY );
+ if ( xLabelModel.is() )
+ {
+ ::rtl::OUString sLabel;
+ if ( _rxField.is() && _rxField->getPropertySetInfo()->hasPropertyByName(FM_PROP_LABEL) )
+ _rxField->getPropertyValue(FM_PROP_LABEL) >>= sLabel;
+ if ( !sLabel.getLength() )
+ sLabel = sFieldName;
+
+ xLabelModel->setPropertyValue( FM_PROP_LABEL, makeAny( sLabel + _rFieldPostfix ) );
+ String sObjectLabel( SVX_RES( RID_STR_OBJECT_LABEL ) );
+ sObjectLabel.SearchAndReplaceAllAscii( "#object#", sFieldName );
+ xLabelModel->setPropertyValue( FM_PROP_NAME, makeAny( ::rtl::OUString( sObjectLabel ) ) );
+ }
+
+ pLabel->SetLogicRect( ::Rectangle(
+ _rOutDev.LogicToLogic( ::Point( _nXOffsetMM, _nYOffsetMM ), eSourceMode, eTargetMode ),
+ _rOutDev.LogicToLogic( aRealSize, eSourceMode, eTargetMode )
+ ) );
+ }
+
+ // the control
+ ::std::auto_ptr< SdrUnoObj > pControl( dynamic_cast< SdrUnoObj* >(
+ SdrObjFactory::MakeNewObject( _nInventor, _nControlObjectID, _pControlPage, _pModel ) ) );
+ OSL_ENSURE( pControl.get(), "FmXFormView::createControlLabelPair: could not create the control!" );
+ if ( !pControl.get() )
+ return false;
+
+ Reference< XPropertySet > xControlSet( pControl->GetUnoControlModel(), UNO_QUERY );
+ if ( !xControlSet.is() )
+ return false;
+
+ // size of the control
+ ::Size aControlSize( aDefSize );
+ switch ( nDataType )
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ aControlSize = aDefSize;
+ break;
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ aControlSize = aDefImageSize;
+ break;
+ }
+
+ if ( OBJ_FM_IMAGECONTROL == _nControlObjectID )
+ aControlSize = aDefImageSize;
+
+ aControlSize.Width() = long(Fraction(aControlSize.Width(), 1) * eTargetMode.GetScaleX());
+ aControlSize.Height() = long(Fraction(aControlSize.Height(), 1) * eTargetMode.GetScaleY());
+
+ pControl->SetLogicRect( ::Rectangle(
+ _rOutDev.LogicToLogic( ::Point( aRealSize.Width() + _nXOffsetMM, _nYOffsetMM ), eSourceMode, eTargetMode ),
+ _rOutDev.LogicToLogic( aControlSize, eSourceMode, eTargetMode )
+ ) );
+
+ // some initializations
+ Reference< XPropertySetInfo > xControlPropInfo = xControlSet->getPropertySetInfo();
+
+ if ( aFieldName.hasValue() )
+ {
+ xControlSet->setPropertyValue( FM_PROP_CONTROLSOURCE, aFieldName );
+ xControlSet->setPropertyValue( FM_PROP_NAME, aFieldName );
+ if ( !bNeedLabel )
+ {
+ // no dedicated label control => use the label property
+ if ( xControlPropInfo->hasPropertyByName( FM_PROP_LABEL ) )
+ xControlSet->setPropertyValue( FM_PROP_LABEL, makeAny( sFieldName + _rFieldPostfix ) );
+ else
+ OSL_ENSURE( false, "FmXFormView::createControlLabelPair: can't set a label for the control!" );
+ }
+ }
+
+ if ( (nDataType == DataType::LONGVARCHAR || nDataType == DataType::CLOB) && xControlPropInfo->hasPropertyByName( FM_PROP_MULTILINE ) )
+ {
+ xControlSet->setPropertyValue( FM_PROP_MULTILINE, makeAny( sal_Bool( sal_True ) ) );
+ }
+
+ // announce the label to the control
+ if ( xControlPropInfo->hasPropertyByName( FM_PROP_CONTROLLABEL ) && xLabelModel.is() )
+ {
+ try
+ {
+ xControlSet->setPropertyValue( FM_PROP_CONTROLLABEL, makeAny( xLabelModel ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ if ( _rxField.is() )
+ {
+ FormControlFactory aControlFactory( _rContext );
+ aControlFactory.initializeFieldDependentProperties( _rxField, xControlSet, _rxNumberFormats );
+ }
+
+ _rpLabel = pLabel.release();
+ _rpControl = pControl.release();
+ return true;
+}
+
+//------------------------------------------------------------------------------
+FmXFormView::ObjectRemoveListener::ObjectRemoveListener( FmXFormView* pParent )
+ :m_pParent( pParent )
+{
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::ObjectRemoveListener::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+{
+ if (rHint.ISA(SdrHint) && (((SdrHint&)rHint).GetKind() == HINT_OBJREMOVED))
+ m_pParent->ObjectRemovedInAliveMode(((SdrHint&)rHint).GetObject());
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::ObjectRemovedInAliveMode( const SdrObject* pObject )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::ObjectRemovedInAliveMode" );
+ // wenn das entfernte Objekt in meiner MarkList, die ich mir beim Umschalten in den Alive-Mode gemerkt habe, steht,
+ // muss ich es jetzt da rausnehmen, da ich sonst beim Zurueckschalten versuche, die Markierung wieder zu setzen
+ // (interesanterweise geht das nur bei gruppierten Objekten schief (beim Zugriff auf deren ObjList GPF), nicht bei einzelnen)
+
+ ULONG nCount = m_aMark.GetMarkCount();
+ for (ULONG i = 0; i < nCount; ++i)
+ {
+ SdrMark* pMark = m_aMark.GetMark(i);
+ SdrObject* pCurrent = pMark->GetMarkedSdrObj();
+ if (pObject == pCurrent)
+ {
+ m_aMark.DeleteMark(i);
+ return;
+ }
+ // ich brauche nicht in GroupObjects absteigen : wenn dort unten ein Objekt geloescht wird, dann bleibt der
+ // Zeiger auf das GroupObject, den ich habe, trotzdem weiter gueltig bleibt ...
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::stopMarkListWatching()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::stopMarkListWatching" );
+ if ( m_pWatchStoredList )
+ {
+ m_pWatchStoredList->EndListeningAll();
+ delete m_pWatchStoredList;
+ m_pWatchStoredList = NULL;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::startMarkListWatching()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::startMarkListWatching" );
+ if ( !m_pWatchStoredList )
+ {
+ m_pWatchStoredList = new ObjectRemoveListener( this );
+ FmFormModel* pModel = GetFormShell() ? GetFormShell()->GetFormModel() : NULL;
+ DBG_ASSERT( pModel != NULL, "FmXFormView::startMarkListWatching: shell has no model!" );
+ m_pWatchStoredList->StartListening( *static_cast< SfxBroadcaster* >( pModel ) );
+ }
+ else
+ {
+ DBG_ERROR( "FmXFormView::startMarkListWatching: already listening!" );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::saveMarkList( sal_Bool _bSmartUnmark )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::saveMarkList" );
+ if ( m_pView )
+ {
+ m_aMark = m_pView->GetMarkedObjectList();
+ if ( _bSmartUnmark )
+ {
+ ULONG nCount = m_aMark.GetMarkCount( );
+ for ( ULONG i = 0; i < nCount; ++i )
+ {
+ SdrMark* pMark = m_aMark.GetMark(i);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ if ( m_pView->IsObjMarked( pObj ) )
+ {
+ if ( pObj->IsGroupObject() )
+ {
+ SdrObjListIter aIter( *pObj->GetSubList() );
+ sal_Bool bMixed = sal_False;
+ while ( aIter.IsMore() && !bMixed )
+ bMixed = ( aIter.Next()->GetObjInventor() != FmFormInventor );
+
+ if ( !bMixed )
+ {
+ // all objects in the group are form objects
+ m_pView->MarkObj( pMark->GetMarkedSdrObj(), pMark->GetPageView(), sal_True /* unmark! */ );
+ }
+ }
+ else
+ {
+ if ( pObj->GetObjInventor() == FmFormInventor )
+ { // this is a form layer object
+ m_pView->MarkObj( pMark->GetMarkedSdrObj(), pMark->GetPageView(), sal_True /* unmark! */ );
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ DBG_ERROR( "FmXFormView::saveMarkList: invalid view!" );
+ m_aMark = SdrMarkList();
+ }
+}
+
+//--------------------------------------------------------------------------
+static sal_Bool lcl_hasObject( SdrObjListIter& rIter, SdrObject* pObj )
+{
+ sal_Bool bFound = sal_False;
+ while (rIter.IsMore() && !bFound)
+ bFound = pObj == rIter.Next();
+
+ rIter.Reset();
+ return bFound;
+}
+
+//------------------------------------------------------------------------------
+void FmXFormView::restoreMarkList( SdrMarkList& _rRestoredMarkList )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::restoreMarkList" );
+ if ( !m_pView )
+ return;
+
+ _rRestoredMarkList.Clear();
+
+ const SdrMarkList& rCurrentList = m_pView->GetMarkedObjectList();
+ FmFormPage* pPage = GetFormShell() ? GetFormShell()->GetCurPage() : NULL;
+ if (pPage)
+ {
+ if (rCurrentList.GetMarkCount())
+ { // there is a current mark ... hmm. Is it a subset of the mark we remembered in saveMarkList?
+ sal_Bool bMisMatch = sal_False;
+
+ // loop through all current marks
+ ULONG nCurrentCount = rCurrentList.GetMarkCount();
+ for ( ULONG i=0; i<nCurrentCount&& !bMisMatch; ++i )
+ {
+ const SdrObject* pCurrentMarked = rCurrentList.GetMark( i )->GetMarkedSdrObj();
+
+ // loop through all saved marks, check for equality
+ sal_Bool bFound = sal_False;
+ ULONG nSavedCount = m_aMark.GetMarkCount();
+ for ( ULONG j=0; j<nSavedCount && !bFound; ++j )
+ {
+ if ( m_aMark.GetMark( j )->GetMarkedSdrObj() == pCurrentMarked )
+ bFound = sal_True;
+ }
+
+ // did not find a current mark in the saved marks
+ if ( !bFound )
+ bMisMatch = sal_True;
+ }
+
+ if ( bMisMatch )
+ {
+ m_aMark.Clear();
+ _rRestoredMarkList = rCurrentList;
+ return;
+ }
+ }
+ // wichtig ist das auf die Objecte der markliste nicht zugegriffen wird
+ // da diese bereits zerstoert sein koennen
+ SdrPageView* pCurPageView = m_pView->GetSdrPageView();
+ SdrObjListIter aPageIter( *pPage );
+ sal_Bool bFound = sal_True;
+
+ // gibt es noch alle Objecte
+ ULONG nCount = m_aMark.GetMarkCount();
+ for (ULONG i = 0; i < nCount && bFound; i++)
+ {
+ SdrMark* pMark = m_aMark.GetMark(i);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ if (pObj->IsGroupObject())
+ {
+ SdrObjListIter aIter(*pObj->GetSubList());
+ while (aIter.IsMore() && bFound)
+ bFound = lcl_hasObject(aPageIter, aIter.Next());
+ }
+ else
+ bFound = lcl_hasObject(aPageIter, pObj);
+
+ bFound = bFound && pCurPageView == pMark->GetPageView();
+ }
+
+ if (bFound)
+ {
+ // Das LastObject auswerten
+ if (nCount) // Objecte jetzt Markieren
+ {
+ for (ULONG i = 0; i < nCount; i++)
+ {
+ SdrMark* pMark = m_aMark.GetMark(i);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ if ( pObj->GetObjInventor() == FmFormInventor )
+ if ( !m_pView->IsObjMarked( pObj ) )
+ m_pView->MarkObj( pObj, pMark->GetPageView() );
+ }
+
+ _rRestoredMarkList = m_aMark;
+ }
+ }
+ m_aMark.Clear();
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL FmXFormView::focusGained( const FocusEvent& /*e*/ ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::focusGained" );
+ if ( m_xWindow.is() && m_pView )
+ {
+ m_pView->SetMoveOutside( TRUE, FmFormView::ImplAccess() );
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL FmXFormView::focusLost( const FocusEvent& /*e*/ ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::focusLost" );
+ // when switch the focus outside the office the mark didn't change
+ // so we can not remove us as focus listener
+ if ( m_xWindow.is() && m_pView )
+ {
+ m_pView->SetMoveOutside( FALSE, FmFormView::ImplAccess() );
+ }
+}
+// -----------------------------------------------------------------------------
+void FmXFormView::removeGridWindowListening()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::removeGridWindowListening" );
+ if ( m_xWindow.is() )
+ {
+ m_xWindow->removeFocusListener(this);
+ if ( m_pView )
+ {
+ m_pView->SetMoveOutside( FALSE, FmFormView::ImplAccess() );
+ }
+ m_xWindow = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+DocumentType FmXFormView::impl_getDocumentType() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormView::impl_getDocumentType" );
+ if ( GetFormShell() && GetFormShell()->GetImpl() )
+ return GetFormShell()->GetImpl()->getDocumentType();
+ return eUnknownDocumentType;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/formcontrolfactory.cxx b/svx/source/form/formcontrolfactory.cxx
new file mode 100644
index 000000000000..8ef0256bf736
--- /dev/null
+++ b/svx/source/form/formcontrolfactory.cxx
@@ -0,0 +1,736 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * 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_svx.hxx"
+
+#include "svx/dbtoolsclient.hxx"
+#include "formcontrolfactory.hxx"
+#include "fmcontrollayout.hxx"
+#include "fmprop.hrc"
+#include "fmresids.hrc"
+#include "fmservs.hxx"
+#include "svx/dialmgr.hxx"
+#include "svx/svdouno.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/awt/ScrollBarOrientation.hpp>
+#include <com/sun/star/awt/MouseWheelBehavior.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/awt/LineEndFormat.hpp>
+#include <com/sun/star/awt/ImageScaleMode.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/numbers.hxx>
+#include <unotools/syslocale.hxx>
+#include <tools/gen.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <set>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::awt::XControlModel;
+ using ::com::sun::star::form::XFormComponent;
+ using ::com::sun::star::container::XIndexAccess;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::form::XGridColumnFactory;
+ using ::com::sun::star::style::VerticalAlignment_MIDDLE;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::uno::TypeClass_DOUBLE;
+ using ::com::sun::star::uno::TypeClass_LONG;
+ using ::com::sun::star::util::XNumberFormats;
+ using ::com::sun::star::util::XNumberFormatTypes;
+ using ::com::sun::star::awt::FontDescriptor;
+ using ::com::sun::star::lang::Locale;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::container::XNameAccess;
+ /** === end UNO using === **/
+ namespace FormComponentType = ::com::sun::star::form::FormComponentType;
+ namespace ScrollBarOrientation = ::com::sun::star::awt::ScrollBarOrientation;
+ namespace MouseWheelBehavior = ::com::sun::star::awt::MouseWheelBehavior;
+ namespace LineEndFormat = ::com::sun::star::awt::LineEndFormat;
+ namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode;
+ namespace DataType = ::com::sun::star::sdbc::DataType;
+ namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue;
+ namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
+
+ //====================================================================
+ //= FormControlFactory_Data
+ //====================================================================
+ struct FormControlFactory_Data
+ {
+ ::comphelper::ComponentContext m_aContext;
+
+ FormControlFactory_Data( const ::comphelper::ComponentContext& _rContext )
+ :m_aContext( _rContext )
+ {
+ }
+ };
+
+ //====================================================================
+ //= FormControlFactory
+ //====================================================================
+ //--------------------------------------------------------------------
+ FormControlFactory::FormControlFactory( const ::comphelper::ComponentContext& _rContext )
+ :m_pData( new FormControlFactory_Data( _rContext ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ FormControlFactory::~FormControlFactory()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 FormControlFactory::initializeControlModel( const DocumentType _eDocType, const SdrUnoObj& _rObject )
+ {
+ return initializeControlModel(
+ _eDocType,
+ Reference< XPropertySet >( _rObject.GetUnoControlModel(), UNO_QUERY ),
+ _rObject.GetCurrentBoundRect()
+ );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 FormControlFactory::initializeControlModel( const DocumentType _eDocType, const Reference< XPropertySet >& _rxControlModel )
+ {
+ return initializeControlModel(
+ _eDocType, _rxControlModel, Rectangle()
+ );
+ }
+
+ // -----------------------------------------------------------------------------
+ namespace
+ {
+ //....................................................................
+ static ::rtl::OUString lcl_getUniqueLabel_nothrow( const Reference< XPropertySet >& _rxControlModel, const ::rtl::OUString& _rBaseLabel )
+ {
+ ::rtl::OUString sLabel( _rBaseLabel );
+ try
+ {
+ typedef ::std::set< ::rtl::OUString > StringBag;
+ StringBag aUsedLabels;
+
+ Reference< XFormComponent > xFormComponent( _rxControlModel, UNO_QUERY_THROW );
+ Reference< XIndexAccess > xContainer( xFormComponent->getParent(), UNO_QUERY_THROW );
+ // loop through all siblings of the control model, and collect their labels
+ for ( sal_Int32 index=xContainer->getCount(); index>0; )
+ {
+ Reference< XPropertySet > xElement( xContainer->getByIndex( --index ), UNO_QUERY_THROW );
+ if ( xElement == _rxControlModel )
+ continue;
+
+ Reference< XPropertySetInfo > xPSI( xElement->getPropertySetInfo(), UNO_SET_THROW );
+ if ( !xPSI->hasPropertyByName( FM_PROP_LABEL ) )
+ continue;
+
+ ::rtl::OUString sElementLabel;
+ OSL_VERIFY( xElement->getPropertyValue( FM_PROP_LABEL ) >>= sElementLabel );
+ aUsedLabels.insert( sElementLabel );
+ }
+
+ // now find a free label
+ sal_Int32 i=2;
+ while ( aUsedLabels.find( sLabel ) != aUsedLabels.end() )
+ {
+ ::rtl::OUStringBuffer aBuffer( _rBaseLabel );
+ aBuffer.appendAscii( " " );
+ aBuffer.append( (sal_Int32)i++ );
+ sLabel = aBuffer.makeStringAndClear();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sLabel;
+ }
+
+ //....................................................................
+ static Sequence< PropertyValue > lcl_getDataSourceIndirectProperties( const Reference< XPropertySet >& _rxControlModel,
+ const ::comphelper::ComponentContext& _rContext )
+ {
+ OSL_PRECOND( _rxControlModel.is(), "lcl_getDataSourceIndirectProperties: invalid model!" );
+
+ Sequence< PropertyValue > aInfo;
+ try
+ {
+ Reference< XChild > xChild( _rxControlModel, UNO_QUERY );
+ Reference< XPropertySet > xForm;
+ if ( xChild.is() )
+ xForm = xForm.query( xChild->getParent() );
+
+ if ( Reference< XGridColumnFactory >( xForm, UNO_QUERY ).is() )
+ { // hmm. the model is a grid column, in real
+ xChild = xChild.query( xForm );
+ xForm = xForm.query( xChild->getParent() );
+ }
+
+ OSL_ENSURE( xForm.is(), "lcl_getDataSourceIndirectProperties: could not determine the form!" );
+ if ( !xForm.is() )
+ return aInfo;
+ ::rtl::OUString sDataSourceName;
+ xForm->getPropertyValue( FM_PROP_DATASOURCE ) >>= sDataSourceName;
+
+ Reference< XPropertySet > xDsProperties;
+ if ( sDataSourceName.getLength() )
+ xDsProperties = xDsProperties.query( OStaticDataAccessTools().getDataSource( sDataSourceName, _rContext.getLegacyServiceFactory() ) );
+ if ( xDsProperties.is() )
+ xDsProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Info" ) ) ) >>= aInfo;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "lcl_getDataSourceIndirectProperties: caught an exception!" );
+ }
+ return aInfo;
+ }
+
+ //....................................................................
+ static const sal_Char* aCharacterAndParagraphProperties[] =
+ {
+ "CharFontName",
+ "CharFontStyleName",
+ "CharFontFamily",
+ "CharFontCharSet",
+ "CharFontPitch",
+ "CharColor",
+ "CharEscapement",
+ "CharHeight",
+ "CharUnderline",
+ "CharWeight",
+ "CharPosture",
+ "CharAutoKerning",
+ "CharBackColor",
+ "CharBackTransparent",
+ "CharCaseMap",
+ "CharCrossedOut",
+ "CharFlash",
+ "CharStrikeout",
+ "CharWordMode",
+ "CharKerning",
+ "CharLocale",
+ "CharKeepTogether",
+ "CharNoLineBreak",
+ "CharShadowed",
+ "CharFontType",
+ "CharStyleName",
+ "CharContoured",
+ "CharCombineIsOn",
+ "CharCombinePrefix",
+ "CharCombineSuffix",
+ "CharEmphasize",
+ "CharRelief",
+ "RubyText",
+ "RubyAdjust",
+ "RubyCharStyleName",
+ "RubyIsAbove",
+ "CharRotation",
+ "CharRotationIsFitToLine",
+ "CharScaleWidth",
+ "HyperLinkURL",
+ "HyperLinkTarget",
+ "HyperLinkName",
+ "VisitedCharStyleName",
+ "UnvisitedCharStyleName",
+ "CharEscapementHeight",
+ "CharNoHyphenation",
+ "CharUnderlineColor",
+ "CharUnderlineHasColor",
+ "CharStyleNames",
+ "CharHeightAsian",
+ "CharWeightAsian",
+ "CharFontNameAsian",
+ "CharFontStyleNameAsian",
+ "CharFontFamilyAsian",
+ "CharFontCharSetAsian",
+ "CharFontPitchAsian",
+ "CharPostureAsian",
+ "CharLocaleAsian",
+ "ParaIsCharacterDistance",
+ "ParaIsForbiddenRules",
+ "ParaIsHangingPunctuation",
+ "CharHeightComplex",
+ "CharWeightComplex",
+ "CharFontNameComplex",
+ "CharFontStyleNameComplex",
+ "CharFontFamilyComplex",
+ "CharFontCharSetComplex",
+ "CharFontPitchComplex",
+ "CharPostureComplex",
+ "CharLocaleComplex",
+ "ParaAdjust",
+ "ParaLineSpacing",
+ "ParaBackColor",
+ "ParaBackTransparent",
+ "ParaBackGraphicURL",
+ "ParaBackGraphicFilter",
+ "ParaBackGraphicLocation",
+ "ParaLastLineAdjust",
+ "ParaExpandSingleWord",
+ "ParaLeftMargin",
+ "ParaRightMargin",
+ "ParaTopMargin",
+ "ParaBottomMargin",
+ "ParaLineNumberCount",
+ "ParaLineNumberStartValue",
+ "PageDescName",
+ "PageNumberOffset",
+ "ParaRegisterModeActive",
+ "ParaTabStops",
+ "ParaStyleName",
+ "DropCapFormat",
+ "DropCapWholeWord",
+ "ParaKeepTogether",
+ "Setting",
+ "ParaSplit",
+ "Setting",
+ "NumberingLevel",
+ "NumberingRules",
+ "NumberingStartValue",
+ "ParaIsNumberingRestart",
+ "NumberingStyleName",
+ "ParaOrphans",
+ "ParaWidows",
+ "ParaShadowFormat",
+ "LeftBorder",
+ "RightBorder",
+ "TopBorder",
+ "BottomBorder",
+ "BorderDistance",
+ "LeftBorderDistance",
+ "RightBorderDistance",
+ "TopBorderDistance",
+ "BottomBorderDistance",
+ "BreakType",
+ "DropCapCharStyleName",
+ "ParaFirstLineIndent",
+ "ParaIsAutoFirstLineIndent",
+ "ParaIsHyphenation",
+ "ParaHyphenationMaxHyphens",
+ "ParaHyphenationMaxLeadingChars",
+ "ParaHyphenationMaxTrailingChars",
+ "ParaVertAlignment",
+ "ParaUserDefinedAttributes",
+ "NumberingIsNumber",
+ "ParaIsConnectBorder",
+ NULL
+ };
+
+ //....................................................................
+ static void lcl_initializeCharacterAttributes( const Reference< XPropertySet >& _rxModel )
+ {
+ try
+ {
+ Reference< XPropertySet > xStyle( ControlLayouter::getDefaultDocumentTextStyle( _rxModel ), UNO_SET_THROW );
+
+ // transfer all properties which are described by the style
+ Reference< XPropertySetInfo > xSourcePropInfo( xStyle->getPropertySetInfo(), UNO_SET_THROW );
+ Reference< XPropertySetInfo > xDestPropInfo( _rxModel->getPropertySetInfo(), UNO_SET_THROW );
+
+ ::rtl::OUString sPropertyName;
+ const sal_Char** pCharacterProperty = aCharacterAndParagraphProperties;
+ while ( *pCharacterProperty )
+ {
+ sPropertyName = ::rtl::OUString::createFromAscii( *pCharacterProperty );
+
+ if ( xSourcePropInfo->hasPropertyByName( sPropertyName ) && xDestPropInfo->hasPropertyByName( sPropertyName ) )
+ _rxModel->setPropertyValue( sPropertyName, xStyle->getPropertyValue( sPropertyName ) );
+
+ ++pCharacterProperty;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 FormControlFactory::initializeControlModel( const DocumentType _eDocType, const Reference< XPropertySet >& _rxControlModel,
+ const Rectangle& _rControlBoundRect )
+ {
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+
+ OSL_ENSURE( _rxControlModel.is(), "FormControlFactory::initializeControlModel: invalid model!" );
+ if ( !_rxControlModel.is() )
+ return nClassId;
+
+ try
+ {
+ ControlLayouter::initializeControlLayout( _rxControlModel, _eDocType );
+
+ _rxControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId;
+ Reference< XPropertySetInfo > xPSI( _rxControlModel->getPropertySetInfo(), UNO_SET_THROW );
+ switch ( nClassId )
+ {
+ case FormComponentType::SCROLLBAR:
+ _rxControlModel->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LiveScroll" ) ), makeAny( (sal_Bool)sal_True ) );
+ // NO break!
+ case FormComponentType::SPINBUTTON:
+ {
+ sal_Int32 eOrientation = ScrollBarOrientation::HORIZONTAL;
+ if ( !_rControlBoundRect.IsEmpty() && ( _rControlBoundRect.GetWidth() < _rControlBoundRect.GetHeight() ) )
+ eOrientation = ScrollBarOrientation::VERTICAL;
+ _rxControlModel->setPropertyValue( FM_PROP_ORIENTATION, makeAny( eOrientation ) );
+ }
+ break;
+
+ case FormComponentType::LISTBOX:
+ case FormComponentType::COMBOBOX:
+ {
+ sal_Bool bDropDown = !_rControlBoundRect.IsEmpty() && ( _rControlBoundRect.GetWidth() >= 3 * _rControlBoundRect.GetHeight() );
+ if ( xPSI->hasPropertyByName( FM_PROP_DROPDOWN ) )
+ _rxControlModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) );
+ _rxControlModel->setPropertyValue( FM_PROP_LINECOUNT, makeAny( sal_Int16( 20 ) ) );
+ }
+ break;
+
+ case FormComponentType::TEXTFIELD:
+ {
+ initializeTextFieldLineEnds( _rxControlModel );
+ lcl_initializeCharacterAttributes( _rxControlModel );
+
+ if ( !_rControlBoundRect.IsEmpty()
+ && !( _rControlBoundRect.GetWidth() > 4 * _rControlBoundRect.GetHeight() )
+ )
+ {
+ if ( xPSI->hasPropertyByName( FM_PROP_MULTILINE ) )
+ _rxControlModel->setPropertyValue( FM_PROP_MULTILINE, makeAny( (sal_Bool)sal_True ) );
+ }
+ }
+ break;
+
+ case FormComponentType::RADIOBUTTON:
+ case FormComponentType::CHECKBOX:
+ case FormComponentType::FIXEDTEXT:
+ {
+ ::rtl::OUString sVertAlignPropertyName( RTL_CONSTASCII_USTRINGPARAM( "VerticalAlign" ) );
+ if ( xPSI->hasPropertyByName( sVertAlignPropertyName ) )
+ _rxControlModel->setPropertyValue( sVertAlignPropertyName, makeAny( VerticalAlignment_MIDDLE ) );
+ }
+ break;
+
+ case FormComponentType::IMAGEBUTTON:
+ case FormComponentType::IMAGECONTROL:
+ {
+ const ::rtl::OUString sScaleModeProperty( RTL_CONSTASCII_USTRINGPARAM( "ScaleMode" ) );
+ if ( xPSI->hasPropertyByName( sScaleModeProperty ) )
+ _rxControlModel->setPropertyValue( sScaleModeProperty, makeAny( ImageScaleMode::Isotropic ) );
+ }
+ break;
+ }
+
+ // initial default label for the control
+ if ( xPSI->hasPropertyByName( FM_PROP_LABEL ) )
+ {
+ ::rtl::OUString sExistingLabel;
+ OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_LABEL ) >>= sExistingLabel );
+ if ( !sExistingLabel.getLength() )
+ {
+ ::rtl::OUString sInitialLabel;
+ OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_NAME ) >>= sInitialLabel );
+
+ sal_uInt16 nTitleResId = 0;
+ switch ( nClassId )
+ {
+ case FormComponentType::COMMANDBUTTON: nTitleResId = RID_STR_PROPTITLE_PUSHBUTTON; break;
+ case FormComponentType::RADIOBUTTON: nTitleResId = RID_STR_PROPTITLE_RADIOBUTTON; break;
+ case FormComponentType::CHECKBOX: nTitleResId = RID_STR_PROPTITLE_CHECKBOX; break;
+ case FormComponentType::GROUPBOX: nTitleResId = RID_STR_PROPTITLE_GROUPBOX; break;
+ case FormComponentType::FIXEDTEXT: nTitleResId = RID_STR_PROPTITLE_FIXEDTEXT; break;
+ }
+
+ if ( nTitleResId )
+ sInitialLabel = String( SVX_RES( nTitleResId ) );
+
+ _rxControlModel->setPropertyValue(
+ FM_PROP_LABEL,
+ makeAny( lcl_getUniqueLabel_nothrow( _rxControlModel, sInitialLabel ) )
+ );
+ }
+ }
+
+ // strict format = yes is the default (i93467)
+ if ( xPSI->hasPropertyByName( FM_PROP_STRICTFORMAT ) )
+ {
+ _rxControlModel->setPropertyValue( FM_PROP_STRICTFORMAT, makeAny( sal_Bool( sal_True ) ) );
+ }
+
+ // mouse wheel: don't use it for scrolling by default (i110036)
+ if ( xPSI->hasPropertyByName( FM_PROP_MOUSE_WHEEL_BEHAVIOR ) )
+ {
+ _rxControlModel->setPropertyValue( FM_PROP_MOUSE_WHEEL_BEHAVIOR, makeAny( MouseWheelBehavior::SCROLL_DISABLED ) );
+ }
+
+ if ( xPSI->hasPropertyByName( FM_PROP_WRITING_MODE ) )
+ _rxControlModel->setPropertyValue( FM_PROP_WRITING_MODE, makeAny( WritingMode2::CONTEXT ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return nClassId;
+ }
+
+ //------------------------------------------------------------------------------
+ void FormControlFactory::initializeTextFieldLineEnds( const Reference< XPropertySet >& _rxModel )
+ {
+ OSL_PRECOND( _rxModel.is(), "initializeTextFieldLineEnds: invalid model!" );
+ if ( !_rxModel.is() )
+ return;
+
+ try
+ {
+ Reference< XPropertySetInfo > xInfo = _rxModel->getPropertySetInfo();
+ if ( !xInfo.is() || !xInfo->hasPropertyByName( FM_PROP_LINEENDFORMAT ) )
+ return;
+
+ // let's see if the data source which the form belongs to (if any)
+ // has a setting for the preferred line end format
+ sal_Bool bDosLineEnds = sal_False;
+ Sequence< PropertyValue > aInfo = lcl_getDataSourceIndirectProperties( _rxModel, m_pData->m_aContext );
+ const PropertyValue* pInfo = aInfo.getConstArray();
+ const PropertyValue* pInfoEnd = pInfo + aInfo.getLength();
+ for ( ; pInfo != pInfoEnd; ++pInfo )
+ {
+ if ( pInfo->Name.equalsAscii( "PreferDosLikeLineEnds" ) )
+ {
+ pInfo->Value >>= bDosLineEnds;
+ break;
+ }
+ }
+
+ sal_Int16 nLineEndFormat = bDosLineEnds ? LineEndFormat::CARRIAGE_RETURN_LINE_FEED : LineEndFormat::LINE_FEED;
+ _rxModel->setPropertyValue( FM_PROP_LINEENDFORMAT, makeAny( nLineEndFormat ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ void FormControlFactory::initializeFieldDependentProperties( const Reference< XPropertySet >& _rxDatabaseField,
+ const Reference< XPropertySet >& _rxControlModel, const Reference< XNumberFormats >& _rxNumberFormats )
+ {
+ OSL_PRECOND( _rxDatabaseField.is() && _rxControlModel.is(),
+ "FormControlFactory::initializeFieldDependentProperties: illegal params!" );
+ if ( !_rxDatabaseField.is() || !_rxControlModel.is() )
+ return;
+
+ try
+ {
+ ////////////////////////////////////////////////////////////////////////
+ // if the field has a numeric format, and the model has a "Scale" property, sync it
+ Reference< XPropertySetInfo > xFieldPSI( _rxDatabaseField->getPropertySetInfo(), UNO_SET_THROW );
+ Reference< XPropertySetInfo > xModelPSI( _rxControlModel->getPropertySetInfo(), UNO_SET_THROW );
+
+ if ( xModelPSI->hasPropertyByName( FM_PROP_DECIMAL_ACCURACY ) )
+ {
+ sal_Int32 nFormatKey = 0;
+ if ( xFieldPSI->hasPropertyByName( FM_PROP_FORMATKEY ) )
+ {
+ _rxDatabaseField->getPropertyValue( FM_PROP_FORMATKEY ) >>= nFormatKey;
+ }
+ else
+ {
+ nFormatKey = OStaticDataAccessTools().getDefaultNumberFormat(
+ _rxDatabaseField,
+ Reference< XNumberFormatTypes >( _rxNumberFormats, UNO_QUERY ),
+ SvtSysLocale().GetLocaleData().getLocale()
+ );
+ }
+
+ Any aScaleVal( ::comphelper::getNumberFormatDecimals( _rxNumberFormats, nFormatKey ) );
+ _rxControlModel->setPropertyValue( FM_PROP_DECIMAL_ACCURACY, aScaleVal );
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // minimum and maximum of the control according to the type of the database field
+ sal_Int32 nDataType = DataType::OTHER;
+ OSL_VERIFY( _rxDatabaseField->getPropertyValue( FM_PROP_FIELDTYPE ) >>= nDataType );
+
+ if ( xModelPSI->hasPropertyByName( FM_PROP_VALUEMIN )
+ && xModelPSI->hasPropertyByName( FM_PROP_VALUEMAX )
+ )
+ {
+ sal_Int32 nMinValue = -1000000000, nMaxValue = 1000000000;
+ switch ( nDataType )
+ {
+ case DataType::TINYINT : nMinValue = 0; nMaxValue = 255; break;
+ case DataType::SMALLINT : nMinValue = -32768; nMaxValue = 32767; break;
+ case DataType::INTEGER : nMinValue = 0x80000000; nMaxValue = 0x7FFFFFFF; break;
+ // double and singles are ignored
+ }
+
+ Any aValue;
+
+ // both the minimum and the maximum value properties can be either Long or Double
+ Property aProperty = xModelPSI->getPropertyByName( FM_PROP_VALUEMIN );
+ if ( aProperty.Type.getTypeClass() == TypeClass_DOUBLE )
+ aValue <<= (double)nMinValue;
+ else if ( aProperty.Type.getTypeClass() == TypeClass_LONG )
+ aValue <<= (sal_Int32)nMinValue;
+ else
+ {
+ DBG_ERROR( "FormControlFactory::initializeFieldDependentProperties: unexpected property type (MinValue)!" );
+ }
+ _rxControlModel->setPropertyValue( FM_PROP_VALUEMIN, aValue );
+
+ // both the minimum and the maximum value properties can be either Long or Double
+ aProperty = xModelPSI->getPropertyByName( FM_PROP_VALUEMAX );
+ if ( aProperty.Type.getTypeClass() == TypeClass_DOUBLE )
+ aValue <<= (double)nMaxValue;
+ else if ( aProperty.Type.getTypeClass() == TypeClass_LONG )
+ aValue <<= (sal_Int32)nMaxValue;
+ else
+ {
+ DBG_ERROR( "FormControlFactory::initializeFieldDependentProperties: unexpected property type (MaxValue)!" );
+ }
+ _rxControlModel->setPropertyValue( FM_PROP_VALUEMAX, aValue );
+ }
+
+ ////////////////////////////////////////////////////////////////////////
+ // a check box can be tristate if and only if the column it is bound to is nullable
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId );
+ if ( nClassId == FormComponentType::CHECKBOX )
+ {
+ sal_Int32 nNullable = ColumnValue::NULLABLE_UNKNOWN;
+ OSL_VERIFY( _rxDatabaseField->getPropertyValue( FM_PROP_ISNULLABLE ) >>= nNullable );
+ _rxControlModel->setPropertyValue( FM_PROP_TRISTATE, makeAny( sal_Bool( ColumnValue::NO_NULLS != nNullable ) ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ ::rtl::OUString FormControlFactory::getDefaultName( sal_Int16 _nClassId, const Reference< XServiceInfo >& _rxObject )
+ {
+ sal_uInt16 nResId(0);
+
+ switch ( _nClassId )
+ {
+ case FormComponentType::COMMANDBUTTON: nResId = RID_STR_PROPTITLE_PUSHBUTTON; break;
+ case FormComponentType::RADIOBUTTON: nResId = RID_STR_PROPTITLE_RADIOBUTTON; break;
+ case FormComponentType::CHECKBOX: nResId = RID_STR_PROPTITLE_CHECKBOX; break;
+ case FormComponentType::LISTBOX: nResId = RID_STR_PROPTITLE_LISTBOX; break;
+ case FormComponentType::COMBOBOX: nResId = RID_STR_PROPTITLE_COMBOBOX; break;
+ case FormComponentType::GROUPBOX: nResId = RID_STR_PROPTITLE_GROUPBOX; break;
+ case FormComponentType::IMAGEBUTTON: nResId = RID_STR_PROPTITLE_IMAGEBUTTON; break;
+ case FormComponentType::FIXEDTEXT: nResId = RID_STR_PROPTITLE_FIXEDTEXT; break;
+ case FormComponentType::GRIDCONTROL: nResId = RID_STR_PROPTITLE_DBGRID; break;
+ case FormComponentType::FILECONTROL: nResId = RID_STR_PROPTITLE_FILECONTROL; break;
+ case FormComponentType::DATEFIELD: nResId = RID_STR_PROPTITLE_DATEFIELD; break;
+ case FormComponentType::TIMEFIELD: nResId = RID_STR_PROPTITLE_TIMEFIELD; break;
+ case FormComponentType::NUMERICFIELD: nResId = RID_STR_PROPTITLE_NUMERICFIELD; break;
+ case FormComponentType::CURRENCYFIELD: nResId = RID_STR_PROPTITLE_CURRENCYFIELD; break;
+ case FormComponentType::PATTERNFIELD: nResId = RID_STR_PROPTITLE_PATTERNFIELD; break;
+ case FormComponentType::IMAGECONTROL: nResId = RID_STR_PROPTITLE_IMAGECONTROL; break;
+ case FormComponentType::HIDDENCONTROL: nResId = RID_STR_PROPTITLE_HIDDEN; break;
+ case FormComponentType::SCROLLBAR: nResId = RID_STR_PROPTITLE_SCROLLBAR; break;
+ case FormComponentType::SPINBUTTON: nResId = RID_STR_PROPTITLE_SPINBUTTON; break;
+ case FormComponentType::NAVIGATIONBAR: nResId = RID_STR_PROPTITLE_NAVBAR; break;
+
+ case FormComponentType::TEXTFIELD:
+ nResId = RID_STR_PROPTITLE_EDIT;
+ if ( _rxObject.is() && _rxObject->supportsService( FM_SUN_COMPONENT_FORMATTEDFIELD ) )
+ nResId = RID_STR_PROPTITLE_FORMATTED;
+ break;
+
+ default:
+ nResId = RID_STR_CONTROL; break;
+ }
+
+ return String( SVX_RES( nResId ) );
+ }
+
+ //------------------------------------------------------------------------------
+ ::rtl::OUString FormControlFactory::getDefaultUniqueName_ByComponentType( const Reference< XNameAccess >& _rxContainer,
+ const Reference< XPropertySet >& _rxObject )
+ {
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ OSL_VERIFY( _rxObject->getPropertyValue( FM_PROP_CLASSID ) >>= nClassId );
+ ::rtl::OUString sBaseName = getDefaultName( nClassId, Reference< XServiceInfo >( _rxObject, UNO_QUERY ) );
+
+ return getUniqueName( _rxContainer, sBaseName );
+ }
+
+ //------------------------------------------------------------------------------
+ ::rtl::OUString FormControlFactory::getUniqueName( const Reference< XNameAccess >& _rxContainer, const ::rtl::OUString& _rBaseName )
+ {
+ sal_Int32 n = 0;
+ ::rtl::OUString sName;
+ do
+ {
+ ::rtl::OUStringBuffer aBuf( _rBaseName );
+ aBuf.appendAscii( " " );
+ aBuf.append( ++n );
+ sName = aBuf.makeStringAndClear();
+ }
+ while ( _rxContainer->hasByName( sName ) );
+
+ return sName;
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx
new file mode 100644
index 000000000000..cb65e17ad192
--- /dev/null
+++ b/svx/source/form/formcontroller.cxx
@@ -0,0 +1,4320 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "fmcontrolbordermanager.hxx"
+#include "fmcontrollayout.hxx"
+#include "formcontroller.hxx"
+#include "formfeaturedispatcher.hxx"
+#include "fmdocumentclassification.hxx"
+#include "formcontrolling.hxx"
+#include "fmprop.hrc"
+#include "svx/dialmgr.hxx"
+#include "fmresids.hrc"
+#include "fmservs.hxx"
+#include "svx/fmtools.hxx"
+#include "fmurl.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/FocusChangeReason.hpp>
+#include <com/sun/star/awt/XCheckBox.hpp>
+#include <com/sun/star/awt/XComboBox.hpp>
+#include <com/sun/star/awt/XListBox.hpp>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XIdentifierReplace.hpp>
+#include <com/sun/star/form/TabulatorCycle.hpp>
+#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
+#include <com/sun/star/form/XBoundComponent.hpp>
+#include <com/sun/star/form/XBoundControl.hpp>
+#include <com/sun/star/form/XGridControl.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/form/XReset.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/sdb/ParametersRequest.hpp>
+#include <com/sun/star/sdb/RowChangeAction.hpp>
+#include <com/sun/star/sdb/XInteractionSupplyParameters.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/form/runtime/FormOperations.hpp>
+#include <com/sun/star/form/runtime/FormFeature.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/enumhelper.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/interaction.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/propagg.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <toolkit/controls/unocontrol.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/shl.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/logfile.hxx>
+
+#include <algorithm>
+#include <functional>
+
+using namespace ::com::sun::star;
+using namespace ::comphelper;
+using namespace ::connectivity;
+using namespace ::connectivity::simple;
+
+//------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ FormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB )
+{
+ return *( new ::svxform::FormController( _rxORB ) );
+}
+
+namespace svxform
+{
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::sdb::XColumn;
+ using ::com::sun::star::awt::XControl;
+ using ::com::sun::star::awt::XTabController;
+ using ::com::sun::star::awt::XToolkit;
+ using ::com::sun::star::awt::XWindowPeer;
+ using ::com::sun::star::form::XGrid;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::container::XIndexAccess;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::IndexOutOfBoundsException;
+ using ::com::sun::star::sdb::XInteractionSupplyParameters;
+ using ::com::sun::star::awt::XTextComponent;
+ using ::com::sun::star::awt::XTextListener;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::frame::XDispatch;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::uno::XAggregation;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::sdbc::XRowSet;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::util::XNumberFormatsSupplier;
+ using ::com::sun::star::util::XNumberFormatter;
+ using ::com::sun::star::sdbcx::XColumnsSupplier;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::container::XEnumeration;
+ using ::com::sun::star::form::XFormComponent;
+ using ::com::sun::star::form::runtime::XFormOperations;
+ using ::com::sun::star::form::runtime::FilterEvent;
+ using ::com::sun::star::form::runtime::XFilterControllerListener;
+ using ::com::sun::star::awt::XControlContainer;
+ using ::com::sun::star::container::XIdentifierReplace;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::form::XFormControllerListener;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::sdbc::XResultSet;
+ using ::com::sun::star::awt::XControlModel;
+ using ::com::sun::star::awt::XTabControllerModel;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::form::validation::XValidatableFormComponent;
+ using ::com::sun::star::form::XLoadable;
+ using ::com::sun::star::script::XEventAttacherManager;
+ using ::com::sun::star::form::XBoundControl;
+ using ::com::sun::star::beans::XPropertyChangeListener;
+ using ::com::sun::star::awt::TextEvent;
+ using ::com::sun::star::form::XBoundComponent;
+ using ::com::sun::star::awt::XCheckBox;
+ using ::com::sun::star::awt::XComboBox;
+ using ::com::sun::star::awt::XListBox;
+ using ::com::sun::star::awt::ItemEvent;
+ using ::com::sun::star::util::XModifyListener;
+ using ::com::sun::star::form::XReset;
+ using ::com::sun::star::frame::XDispatchProviderInterception;
+ using ::com::sun::star::form::XGridControl;
+ using ::com::sun::star::awt::XVclWindowPeer;
+ using ::com::sun::star::form::validation::XValidator;
+ using ::com::sun::star::awt::FocusEvent;
+ using ::com::sun::star::sdb::SQLContext;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::form::TabulatorCycle_RECORDS;
+ using ::com::sun::star::container::ContainerEvent;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::lang::Locale;
+ using ::com::sun::star::beans::NamedValue;
+ using ::com::sun::star::lang::NoSupportException;
+ using ::com::sun::star::sdb::RowChangeEvent;
+ using ::com::sun::star::frame::XStatusListener;
+ using ::com::sun::star::frame::XDispatchProviderInterceptor;
+ using ::com::sun::star::sdb::SQLErrorEvent;
+ using ::com::sun::star::form::DatabaseParameterEvent;
+ using ::com::sun::star::sdb::ParametersRequest;
+ using ::com::sun::star::task::XInteractionRequest;
+ using ::com::sun::star::util::URL;
+ using ::com::sun::star::frame::FeatureStateEvent;
+ using ::com::sun::star::form::runtime::XFormControllerContext;
+ using ::com::sun::star::task::XInteractionHandler;
+ using ::com::sun::star::form::runtime::FormOperations;
+ using ::com::sun::star::container::XContainer;
+ using ::com::sun::star::sdbc::SQLWarning;
+ /** === end UNO using === **/
+ namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue;
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+ namespace FocusChangeReason = ::com::sun::star::awt::FocusChangeReason;
+ namespace RowChangeAction = ::com::sun::star::sdb::RowChangeAction;
+ namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
+
+//==============================================================================
+// ColumnInfo
+//==============================================================================
+struct ColumnInfo
+{
+ // information about the column itself
+ Reference< XColumn > xColumn;
+ sal_Int32 nNullable;
+ sal_Bool bAutoIncrement;
+ sal_Bool bReadOnly;
+ ::rtl::OUString sName;
+
+ // information about the control(s) bound to this column
+
+ /// the first control which is bound to the given column, and which requires input
+ Reference< XControl > xFirstControlWithInputRequired;
+ /** the first grid control which contains a column which is bound to the given database column, and requires
+ input
+ */
+ Reference< XGrid > xFirstGridWithInputRequiredColumn;
+ /** if xFirstControlWithInputRequired is a grid control, then nRequiredGridColumn specifies the position
+ of the grid column which is actually bound
+ */
+ sal_Int32 nRequiredGridColumn;
+
+ ColumnInfo()
+ :xColumn()
+ ,nNullable( ColumnValue::NULLABLE_UNKNOWN )
+ ,bAutoIncrement( sal_False )
+ ,bReadOnly( sal_False )
+ ,sName()
+ ,xFirstControlWithInputRequired()
+ ,xFirstGridWithInputRequiredColumn()
+ ,nRequiredGridColumn( -1 )
+ {
+ }
+};
+
+//==============================================================================
+//= ColumnInfoCache
+//==============================================================================
+class ColumnInfoCache
+{
+public:
+ ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSupplier );
+
+ size_t getColumnCount() const { return m_aColumns.size(); }
+ const ColumnInfo& getColumnInfo( size_t _pos );
+
+ bool controlsInitialized() const { return m_bControlsInitialized; }
+ void initializeControls( const Sequence< Reference< XControl > >& _rControls );
+ void deinitializeControls();
+
+private:
+ typedef ::std::vector< ColumnInfo > ColumnInfos;
+ ColumnInfos m_aColumns;
+ bool m_bControlsInitialized;
+};
+
+//------------------------------------------------------------------------------
+ColumnInfoCache::ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSupplier )
+ :m_aColumns()
+ ,m_bControlsInitialized( false )
+{
+ try
+ {
+ m_aColumns.clear();
+
+ Reference< XColumnsSupplier > xSupplyCols( _rxColSupplier, UNO_SET_THROW );
+ Reference< XIndexAccess > xColumns( xSupplyCols->getColumns(), UNO_QUERY_THROW );
+ sal_Int32 nColumnCount = xColumns->getCount();
+ m_aColumns.reserve( nColumnCount );
+
+ Reference< XPropertySet > xColumnProps;
+ for ( sal_Int32 i = 0; i < nColumnCount; ++i )
+ {
+ ColumnInfo aColInfo;
+ aColInfo.xColumn.set( xColumns->getByIndex(i), UNO_QUERY_THROW );
+
+ xColumnProps.set( aColInfo.xColumn, UNO_QUERY_THROW );
+ OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_ISNULLABLE ) >>= aColInfo.nNullable );
+ OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_AUTOINCREMENT ) >>= aColInfo.bAutoIncrement );
+ OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_NAME ) >>= aColInfo.sName );
+ OSL_VERIFY( xColumnProps->getPropertyValue( FM_PROP_ISREADONLY ) >>= aColInfo.bReadOnly );
+
+ m_aColumns.push_back( aColInfo );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ bool lcl_isBoundTo( const Reference< XPropertySet >& _rxControlModel, const Reference< XInterface >& _rxNormDBField )
+ {
+ Reference< XInterface > xNormBoundField( _rxControlModel->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY );
+ return ( xNormBoundField.get() == _rxNormDBField.get() );
+ }
+
+ bool lcl_isInputRequired( const Reference< XPropertySet >& _rxControlModel )
+ {
+ sal_Bool bInputRequired = sal_True;
+ OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_INPUT_REQUIRED ) >>= bInputRequired );
+ return ( bInputRequired != sal_False );
+ }
+
+ void lcl_resetColumnControlInfo( ColumnInfo& _rColInfo )
+ {
+ _rColInfo.xFirstControlWithInputRequired.clear();
+ _rColInfo.xFirstGridWithInputRequiredColumn.clear();
+ _rColInfo.nRequiredGridColumn = -1;
+ }
+}
+
+//------------------------------------------------------------------------------
+void ColumnInfoCache::deinitializeControls()
+{
+ for ( ColumnInfos::iterator col = m_aColumns.begin();
+ col != m_aColumns.end();
+ ++col
+ )
+ {
+ lcl_resetColumnControlInfo( *col );
+ }
+}
+
+//------------------------------------------------------------------------------
+void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > >& _rControls )
+{
+ try
+ {
+ // for every of our known columns, find the controls which are bound to this column
+ for ( ColumnInfos::iterator col = m_aColumns.begin();
+ col != m_aColumns.end();
+ ++col
+ )
+ {
+ OSL_ENSURE( !col->xFirstControlWithInputRequired.is() && !col->xFirstGridWithInputRequiredColumn.is()
+ && ( col->nRequiredGridColumn == -1 ), "ColumnInfoCache::initializeControls: called me twice?" );
+
+ lcl_resetColumnControlInfo( *col );
+
+ Reference< XInterface > xNormColumn( col->xColumn, UNO_QUERY_THROW );
+
+ const Reference< XControl >* pControl( _rControls.getConstArray() );
+ const Reference< XControl >* pControlEnd( pControl + _rControls.getLength() );
+ for ( ; pControl != pControlEnd; ++pControl )
+ {
+ if ( !pControl->is() )
+ continue;
+
+ Reference< XPropertySet > xModel( (*pControl)->getModel(), UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xModelPSI( xModel->getPropertySetInfo(), UNO_SET_THROW );
+
+ // special handling for grid controls
+ Reference< XGrid > xGrid( *pControl, UNO_QUERY );
+ if ( xGrid.is() )
+ {
+ Reference< XIndexAccess > xGridColAccess( xModel, UNO_QUERY_THROW );
+ sal_Int32 gridColCount = xGridColAccess->getCount();
+ sal_Int32 gridCol = 0;
+ for ( gridCol = 0; gridCol < gridColCount; ++gridCol )
+ {
+ Reference< XPropertySet > xGridColumnModel( xGridColAccess->getByIndex( gridCol ), UNO_QUERY_THROW );
+
+ if ( !lcl_isBoundTo( xGridColumnModel, xNormColumn )
+ || !lcl_isInputRequired( xGridColumnModel )
+ )
+ continue; // with next grid column
+
+ break;
+ }
+
+ if ( gridCol < gridColCount )
+ {
+ // found a grid column which is bound to the given
+ col->xFirstGridWithInputRequiredColumn = xGrid;
+ col->nRequiredGridColumn = gridCol;
+ break;
+ }
+
+ continue; // with next control
+ }
+
+ if ( !xModelPSI->hasPropertyByName( FM_PROP_BOUNDFIELD )
+ || !lcl_isBoundTo( xModel, xNormColumn )
+ || !lcl_isInputRequired( xModel )
+ )
+ continue; // with next control
+
+ break;
+ }
+
+ if ( pControl == pControlEnd )
+ // did not find a control which is bound to this particular column, and for which the input is required
+ continue; // with next DB column
+
+ col->xFirstControlWithInputRequired = *pControl;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_bControlsInitialized = true;
+}
+
+//------------------------------------------------------------------------------
+const ColumnInfo& ColumnInfoCache::getColumnInfo( size_t _pos )
+{
+ if ( _pos >= m_aColumns.size() )
+ throw IndexOutOfBoundsException();
+
+ return m_aColumns[ _pos ];
+}
+
+//==================================================================
+// OParameterContinuation
+//==================================================================
+class OParameterContinuation : public OInteraction< XInteractionSupplyParameters >
+{
+ Sequence< PropertyValue > m_aValues;
+
+public:
+ OParameterContinuation() { }
+
+ Sequence< PropertyValue > getValues() const { return m_aValues; }
+
+// XInteractionSupplyParameters
+ virtual void SAL_CALL setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException);
+};
+
+//------------------------------------------------------------------
+void SAL_CALL OParameterContinuation::setParameters( const Sequence< PropertyValue >& _rValues ) throw(RuntimeException)
+{
+ m_aValues = _rValues;
+}
+
+//==================================================================
+// FmXAutoControl
+//==================================================================
+struct FmFieldInfo
+{
+ rtl::OUString aFieldName;
+ Reference< XPropertySet > xField;
+ Reference< XTextComponent > xText;
+
+ FmFieldInfo(const Reference< XPropertySet >& _xField, const Reference< XTextComponent >& _xText)
+ :xField(_xField)
+ ,xText(_xText)
+ {xField->getPropertyValue(FM_PROP_NAME) >>= aFieldName;}
+};
+
+//==================================================================
+// FmXAutoControl
+//==================================================================
+class FmXAutoControl: public UnoControl
+
+{
+ friend Reference< XInterface > SAL_CALL FmXAutoControl_NewInstance_Impl();
+
+public:
+ FmXAutoControl(){}
+
+ virtual ::rtl::OUString GetComponentServiceName() {return ::rtl::OUString::createFromAscii("Edit");}
+ virtual void SAL_CALL createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw( RuntimeException );
+
+protected:
+ virtual void ImplSetPeerProperty( const ::rtl::OUString& rPropName, const Any& rVal );
+};
+
+//------------------------------------------------------------------------------
+void FmXAutoControl::createPeer( const Reference< XToolkit > & rxToolkit, const Reference< XWindowPeer > & rParentPeer ) throw( RuntimeException )
+{
+ UnoControl::createPeer( rxToolkit, rParentPeer );
+
+ Reference< XTextComponent > xText(getPeer() , UNO_QUERY);
+ if (xText.is())
+ {
+ xText->setText(::rtl::OUString(String(SVX_RES(RID_STR_AUTOFIELD))));
+ xText->setEditable(sal_False);
+ }
+}
+
+//------------------------------------------------------------------------------
+void FmXAutoControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, const Any& rVal )
+{
+ // these properties are ignored
+ if (rPropName == FM_PROP_TEXT)
+ return;
+
+ UnoControl::ImplSetPeerProperty( rPropName, rVal );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( FormController, OnActivateTabOrder, void*, /*EMPTYTAG*/ )
+{
+ activateTabOrder();
+ return 1;
+}
+
+//------------------------------------------------------------------------------
+struct UpdateAllListeners : public ::std::unary_function< Reference< XDispatch >, bool >
+{
+ bool operator()( const Reference< XDispatch >& _rxDispatcher ) const
+ {
+ static_cast< ::svx::OSingleFeatureDispatcher* >( _rxDispatcher.get() )->updateAllListeners();
+ // the return is a dummy only so we can use this struct in a std::compose1 call
+ return true;
+ }
+};
+//..............................................................................
+IMPL_LINK( FormController, OnInvalidateFeatures, void*, /*_pNotInterestedInThisParam*/ )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ for ( ::std::set< sal_Int16 >::const_iterator aLoop = m_aInvalidFeatures.begin();
+ aLoop != m_aInvalidFeatures.end();
+ ++aLoop
+ )
+ {
+ DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( *aLoop );
+ if ( aDispatcherPos != m_aFeatureDispatchers.end() )
+ {
+ // TODO: for the real and actual listener notifications, we should release
+ // our mutex
+ UpdateAllListeners( )( aDispatcherPos->second );
+ }
+ }
+ return 1;
+}
+
+/*************************************************************************/
+
+DBG_NAME( FormController )
+//------------------------------------------------------------------
+FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB )
+ :FormController_BASE( m_aMutex )
+ ,OPropertySetHelper( FormController_BASE::rBHelper )
+ ,OSQLParserClient( _rxORB )
+ ,m_aContext( _rxORB )
+ ,m_aActivateListeners(m_aMutex)
+ ,m_aModifyListeners(m_aMutex)
+ ,m_aErrorListeners(m_aMutex)
+ ,m_aDeleteListeners(m_aMutex)
+ ,m_aRowSetApproveListeners(m_aMutex)
+ ,m_aParameterListeners(m_aMutex)
+ ,m_aFilterListeners(m_aMutex)
+ ,m_pControlBorderManager( new ::svxform::ControlBorderManager )
+ ,m_xFormOperations()
+ ,m_aMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) )
+ ,m_aLoadEvent( LINK( this, FormController, OnLoad ) )
+ ,m_aToggleEvent( LINK( this, FormController, OnToggleAutoFields ) )
+ ,m_aActivationEvent( LINK( this, FormController, OnActivated ) )
+ ,m_aDeactivationEvent( LINK( this, FormController, OnDeactivated ) )
+ ,m_nCurrentFilterPosition(-1)
+ ,m_bCurrentRecordModified(sal_False)
+ ,m_bCurrentRecordNew(sal_False)
+ ,m_bLocked(sal_False)
+ ,m_bDBConnection(sal_False)
+ ,m_bCycle(sal_False)
+ ,m_bCanInsert(sal_False)
+ ,m_bCanUpdate(sal_False)
+ ,m_bCommitLock(sal_False)
+ ,m_bModified(sal_False)
+ ,m_bControlsSorted(sal_False)
+ ,m_bFiltering(sal_False)
+ ,m_bAttachEvents(sal_True)
+ ,m_bDetachEvents(sal_True)
+ ,m_bAttemptedHandlerCreation( false )
+{
+ DBG_CTOR( FormController, NULL );
+
+ ::comphelper::increment(m_refCount);
+ {
+ {
+ m_xAggregate = Reference< XAggregation >(
+ m_aContext.createComponent( "com.sun.star.awt.TabController" ),
+ UNO_QUERY
+ );
+ DBG_ASSERT( m_xAggregate.is(), "FormController::FormController : could not create my aggregate !" );
+ m_xTabController = Reference< XTabController >( m_xAggregate, UNO_QUERY );
+ }
+
+ if ( m_xAggregate.is() )
+ m_xAggregate->setDelegator( *this );
+ }
+ ::comphelper::decrement(m_refCount);
+
+ m_aTabActivationTimer.SetTimeout( 500 );
+ m_aTabActivationTimer.SetTimeoutHdl( LINK( this, FormController, OnActivateTabOrder ) );
+
+ m_aFeatureInvalidationTimer.SetTimeout( 200 );
+ m_aFeatureInvalidationTimer.SetTimeoutHdl( LINK( this, FormController, OnInvalidateFeatures ) );
+}
+
+//------------------------------------------------------------------
+FormController::~FormController()
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ m_aLoadEvent.CancelPendingCall();
+ m_aToggleEvent.CancelPendingCall();
+ m_aActivationEvent.CancelPendingCall();
+ m_aDeactivationEvent.CancelPendingCall();
+
+ if ( m_aTabActivationTimer.IsActive() )
+ m_aTabActivationTimer.Stop();
+ }
+
+ if ( m_aFeatureInvalidationTimer.IsActive() )
+ m_aFeatureInvalidationTimer.Stop();
+
+ disposeAllFeaturesAndDispatchers();
+
+ if ( m_xFormOperations.is() )
+ m_xFormOperations->dispose();
+ m_xFormOperations.clear();
+
+ // Freigeben der Aggregation
+ if ( m_xAggregate.is() )
+ {
+ m_xAggregate->setDelegator( NULL );
+ m_xAggregate.clear();
+ }
+
+ DELETEZ( m_pControlBorderManager );
+
+ DBG_DTOR( FormController, NULL );
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL FormController::acquire() throw ()
+{
+ FormController_BASE::acquire();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL FormController::release() throw ()
+{
+ FormController_BASE::release();
+}
+
+//------------------------------------------------------------------
+Any SAL_CALL FormController::queryInterface( const Type& _rType ) throw(RuntimeException)
+{
+ Any aRet = FormController_BASE::queryInterface( _rType );
+ if ( !aRet.hasValue() )
+ aRet = OPropertySetHelper::queryInterface( _rType );
+ if ( !aRet.hasValue() )
+ aRet = m_xAggregate->queryAggregation( _rType );
+ return aRet;
+}
+
+//------------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL FormController::getImplementationId() throw( RuntimeException )
+{
+ static ::cppu::OImplementationId* pId = NULL;
+ if ( !pId )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !pId )
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+//------------------------------------------------------------------------------
+Sequence< Type > SAL_CALL FormController::getTypes( ) throw(RuntimeException)
+{
+ return comphelper::concatSequences(
+ FormController_BASE::getTypes(),
+ ::cppu::OPropertySetHelper::getTypes()
+ );
+}
+
+// XServiceInfo
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FormController::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException )
+{
+ Sequence< ::rtl::OUString> aSNL(getSupportedServiceNames());
+ const ::rtl::OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL FormController::getImplementationName() throw( RuntimeException )
+{
+ return ::rtl::OUString::createFromAscii( "org.openoffice.comp.svx.FormController" );
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> SAL_CALL FormController::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ // service names which are supported only, but cannot be used to created an
+ // instance at a service factory
+ Sequence< ::rtl::OUString > aNonCreatableServiceNames( 1 );
+ aNonCreatableServiceNames[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormControllerDispatcher" ) );
+
+ // services which can be used to created an instance at a service factory
+ Sequence< ::rtl::OUString > aCreatableServiceNames( getSupportedServiceNames_Static() );
+ return ::comphelper::concatSequences( aCreatableServiceNames, aNonCreatableServiceNames );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FormController::approveReset(const EventObject& /*rEvent*/) throw( RuntimeException )
+{
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::resetted(const EventObject& rEvent) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if (getCurrentControl().is() && (getCurrentControl()->getModel() == rEvent.Source))
+ m_bModified = sal_False;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> FormController::getSupportedServiceNames_Static(void)
+{
+ static Sequence< ::rtl::OUString> aServices;
+ if (!aServices.getLength())
+ {
+ aServices.realloc(2);
+ aServices.getArray()[0] = FM_FORM_CONTROLLER;
+ aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.control.TabController");
+ }
+ return aServices;
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ struct ResetComponentText : public ::std::unary_function< Reference< XTextComponent >, void >
+ {
+ void operator()( const Reference< XTextComponent >& _rxText )
+ {
+ _rxText->setText( ::rtl::OUString() );
+ }
+ };
+
+ struct RemoveComponentTextListener : public ::std::unary_function< Reference< XTextComponent >, void >
+ {
+ RemoveComponentTextListener( const Reference< XTextListener >& _rxListener )
+ :m_xListener( _rxListener )
+ {
+ }
+
+ void operator()( const Reference< XTextComponent >& _rxText )
+ {
+ _rxText->removeTextListener( m_xListener );
+ }
+
+ private:
+ Reference< XTextListener > m_xListener;
+ };
+}
+
+// -----------------------------------------------------------------------------
+void FormController::impl_setTextOnAllFilter_throw()
+{
+ // reset the text for all controls
+ ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), ResetComponentText() );
+
+ if ( m_aFilterRows.empty() )
+ // nothing to do anymore
+ return;
+
+ if ( m_nCurrentFilterPosition < 0 )
+ return;
+
+ // set the text for all filters
+ OSL_ENSURE( m_aFilterRows.size() > (size_t)m_nCurrentFilterPosition,
+ "FormController::impl_setTextOnAllFilter_throw: m_nCurrentFilterPosition too big" );
+
+ if ( (size_t)m_nCurrentFilterPosition < m_aFilterRows.size() )
+ {
+ FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ];
+ for ( FmFilterRow::const_iterator iter2 = rRow.begin();
+ iter2 != rRow.end();
+ ++iter2
+ )
+ {
+ iter2->first->setText( iter2->second );
+ }
+ }
+}
+// OPropertySetHelper
+//------------------------------------------------------------------------------
+sal_Bool FormController::convertFastPropertyValue( Any & /*rConvertedValue*/, Any & /*rOldValue*/,
+ sal_Int32 /*nHandle*/, const Any& /*rValue*/ )
+ throw( IllegalArgumentException )
+{
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+void FormController::setFastPropertyValue_NoBroadcast( sal_Int32 /*nHandle*/, const Any& /*rValue*/ )
+ throw( Exception )
+{
+}
+
+//------------------------------------------------------------------------------
+void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+{
+ switch (nHandle)
+ {
+ case FM_ATTR_FILTER:
+ {
+ ::rtl::OUStringBuffer aFilter;
+ OStaticDataAccessTools aStaticTools;
+ Reference<XConnection> xConnection(aStaticTools.getRowSetConnection(Reference< XRowSet>(m_xModelAsIndex, UNO_QUERY)));
+ if (xConnection.is())
+ {
+ Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData());
+ Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats( xConnection, sal_True ) );
+ Reference< XNumberFormatter> xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY_THROW );
+ xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
+
+ Reference< XColumnsSupplier> xSupplyCols(m_xModelAsIndex, UNO_QUERY);
+ Reference< XNameAccess> xFields(xSupplyCols->getColumns(), UNO_QUERY);
+
+ ::rtl::OUString aQuote( xMetaData->getIdentifierQuoteString() );
+
+ // now add the filter rows
+ try
+ {
+ for ( FmFilterRows::const_iterator row = m_aFilterRows.begin(); row != m_aFilterRows.end(); ++row )
+ {
+ const FmFilterRow& rRow = *row;
+
+ if ( rRow.empty() )
+ continue;
+
+ if ( aFilter.getLength() )
+ aFilter.appendAscii( " OR " );
+
+ aFilter.appendAscii( "( " );
+ for ( FmFilterRow::const_iterator condition = rRow.begin(); condition != rRow.end(); ++condition )
+ {
+ // get the field of the controls map
+ Reference< XControl > xControl( condition->first, UNO_QUERY_THROW );
+ Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW );
+ Reference< XPropertySet > xField( xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW );
+ if ( condition != rRow.begin() )
+ aFilter.appendAscii( " AND " );
+
+ ::rtl::OUString sFilterValue( condition->second );
+
+ ::rtl::OUString sErrorMsg, sCriteria;
+ ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( sErrorMsg, sFilterValue, xFormatter, xField );
+ OSL_ENSURE( xParseNode.is(), "FormController::getFastPropertyValue: could not parse the field value predicate!" );
+ if ( xParseNode.is() )
+ {
+ // don't use a parse context here, we need it unlocalized
+ xParseNode->parseNodeToStr( sCriteria, xConnection, NULL );
+ aFilter.append( sCriteria );
+ }
+ }
+ aFilter.appendAscii( " )" );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ aFilter.setLength(0);
+ }
+ }
+ rValue <<= aFilter.makeStringAndClear();
+ }
+ break;
+
+ case FM_ATTR_FORM_OPERATIONS:
+ rValue <<= m_xFormOperations;
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+Reference< XPropertySetInfo > FormController::getPropertySetInfo() throw( RuntimeException )
+{
+ static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//------------------------------------------------------------------------------
+#define DECL_PROP_CORE(varname, type) \
+pDesc[nPos++] = Property(FM_PROP_##varname, FM_ATTR_##varname, ::getCppuType((const type*)0),
+
+
+#define DECL_PROP1(varname, type, attrib1) \
+ DECL_PROP_CORE(varname, type) PropertyAttribute::attrib1)
+
+//------------------------------------------------------------------------------
+void FormController::fillProperties(
+ Sequence< Property >& /* [out] */ _rProps,
+ Sequence< Property >& /* [out] */ /*_rAggregateProps*/
+ ) const
+{
+ _rProps.realloc(2);
+ sal_Int32 nPos = 0;
+ Property* pDesc = _rProps.getArray();
+ DECL_PROP1(FILTER, rtl::OUString, READONLY);
+ DECL_PROP1(FORM_OPERATIONS, Reference< XFormOperations >, READONLY);
+}
+
+//------------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper& FormController::getInfoHelper()
+{
+ return *getArrayHelper();
+}
+
+// XFilterController
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::addFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException )
+{
+ m_aFilterListeners.addInterface( _Listener );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::removeFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException )
+{
+ m_aFilterListeners.removeInterface( _Listener );
+}
+
+//------------------------------------------------------------------------------
+::sal_Int32 SAL_CALL FormController::getFilterComponents() throw( ::com::sun::star::uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ return m_aFilterComponents.size();
+}
+
+//------------------------------------------------------------------------------
+::sal_Int32 SAL_CALL FormController::getDisjunctiveTerms() throw( ::com::sun::star::uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ return m_aFilterRows.size();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw( RuntimeException, IndexOutOfBoundsException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) || ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) )
+ throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
+
+ Reference< XTextComponent > xText( m_aFilterComponents[ _Component ] );
+ xText->setText( _PredicateExpression );
+
+ FmFilterRow& rFilterRow = m_aFilterRows[ _Term ];
+ if ( _PredicateExpression.getLength() )
+ rFilterRow[ xText ] = _PredicateExpression;
+ else
+ rFilterRow.erase( xText );
+}
+
+//------------------------------------------------------------------------------
+Reference< XControl > FormController::getFilterComponent( ::sal_Int32 _Component ) throw( RuntimeException, IndexOutOfBoundsException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) )
+ throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
+
+ return Reference< XControl >( m_aFilterComponents[ _Component ], UNO_QUERY );
+}
+
+//------------------------------------------------------------------------------
+Sequence< Sequence< ::rtl::OUString > > FormController::getPredicateExpressions() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ Sequence< Sequence< ::rtl::OUString > > aExpressions( m_aFilterRows.size() );
+ sal_Int32 termIndex = 0;
+ for ( FmFilterRows::const_iterator row = m_aFilterRows.begin();
+ row != m_aFilterRows.end();
+ ++row, ++termIndex
+ )
+ {
+ const FmFilterRow& rRow( *row );
+
+ Sequence< ::rtl::OUString > aConjunction( m_aFilterComponents.size() );
+ sal_Int32 componentIndex = 0;
+ for ( FilterComponents::const_iterator comp = m_aFilterComponents.begin();
+ comp != m_aFilterComponents.end();
+ ++comp, ++componentIndex
+ )
+ {
+ FmFilterRow::const_iterator predicate = rRow.find( *comp );
+ if ( predicate != rRow.end() )
+ aConjunction[ componentIndex ] = predicate->second;
+ }
+
+ aExpressions[ termIndex ] = aConjunction;
+ }
+
+ return aExpressions;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ // SYNCHRONIZED -->
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ if ( ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) )
+ throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
+
+ // if the to-be-deleted row is our current row, we need to shift
+ if ( _Term == m_nCurrentFilterPosition )
+ {
+ if ( m_nCurrentFilterPosition < sal_Int32( m_aFilterRows.size() - 1 ) )
+ ++m_nCurrentFilterPosition;
+ else
+ --m_nCurrentFilterPosition;
+ }
+
+ FmFilterRows::iterator pos = m_aFilterRows.begin() + _Term;
+ m_aFilterRows.erase( pos );
+
+ // adjust m_nCurrentFilterPosition if the removed row preceeded it
+ if ( _Term < m_nCurrentFilterPosition )
+ --m_nCurrentFilterPosition;
+
+ OSL_POSTCOND( ( m_nCurrentFilterPosition < 0 ) == ( m_aFilterRows.empty() ),
+ "FormController::removeDisjunctiveTerm: inconsistency!" );
+
+ // update the texts in the filter controls
+ impl_setTextOnAllFilter_throw();
+
+ FilterEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.DisjunctiveTerm = _Term;
+ aGuard.clear();
+ // <-- SYNCHRONIZED
+
+ m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermRemoved, aEvent );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::appendEmptyDisjunctiveTerm() throw (RuntimeException)
+{
+ // SYNCHRONIZED -->
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ impl_appendEmptyFilterRow( aGuard );
+ // <-- SYNCHRONIZED
+}
+
+//------------------------------------------------------------------------------
+::sal_Int32 SAL_CALL FormController::getActiveTerm() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ return m_nCurrentFilterPosition;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ if ( ( _ActiveTerm < 0 ) || ( _ActiveTerm >= getDisjunctiveTerms() ) )
+ throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
+
+ if ( _ActiveTerm == getActiveTerm() )
+ return;
+
+ m_nCurrentFilterPosition = _ActiveTerm;
+ impl_setTextOnAllFilter_throw();
+}
+
+// XElementAccess
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FormController::hasElements(void) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return !m_aChilds.empty();
+}
+
+//------------------------------------------------------------------------------
+Type SAL_CALL FormController::getElementType(void) throw( RuntimeException )
+{
+ return ::getCppuType((const Reference< XFormController>*)0);
+
+}
+
+// XEnumerationAccess
+//------------------------------------------------------------------------------
+Reference< XEnumeration > SAL_CALL FormController::createEnumeration(void) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return new ::comphelper::OEnumerationByIndex(this);
+}
+
+// XIndexAccess
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL FormController::getCount(void) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_aChilds.size();
+}
+
+//------------------------------------------------------------------------------
+Any SAL_CALL FormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (Index < 0 ||
+ Index >= (sal_Int32)m_aChilds.size())
+ throw IndexOutOfBoundsException();
+
+ return makeAny( m_aChilds[ Index ] );
+}
+
+// EventListener
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::disposing(const EventObject& e) throw( RuntimeException )
+{
+ // Ist der Container disposed worden
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XControlContainer > xContainer(e.Source, UNO_QUERY);
+ if (xContainer.is())
+ {
+ setContainer(Reference< XControlContainer > ());
+ }
+ else
+ {
+ // ist ein Control disposed worden
+ Reference< XControl > xControl(e.Source, UNO_QUERY);
+ if (xControl.is())
+ {
+ if (getContainer().is())
+ removeControl(xControl);
+ }
+ }
+}
+
+// OComponentHelper
+//-----------------------------------------------------------------------------
+void FormController::disposeAllFeaturesAndDispatchers() SAL_THROW(())
+{
+ for ( DispatcherContainer::iterator aDispatcher = m_aFeatureDispatchers.begin();
+ aDispatcher != m_aFeatureDispatchers.end();
+ ++aDispatcher
+ )
+ {
+ try
+ {
+ ::comphelper::disposeComponent( aDispatcher->second );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ m_aFeatureDispatchers.clear();
+}
+
+//-----------------------------------------------------------------------------
+void FormController::disposing(void)
+{
+ EventObject aEvt( *this );
+
+ // if we're still active, simulate a "deactivated" event
+ if ( m_xActiveControl.is() )
+ m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvt );
+
+ // notify all our listeners
+ m_aActivateListeners.disposeAndClear(aEvt);
+ m_aModifyListeners.disposeAndClear(aEvt);
+ m_aErrorListeners.disposeAndClear(aEvt);
+ m_aDeleteListeners.disposeAndClear(aEvt);
+ m_aRowSetApproveListeners.disposeAndClear(aEvt);
+ m_aParameterListeners.disposeAndClear(aEvt);
+ m_aFilterListeners.disposeAndClear(aEvt);
+
+ removeBoundFieldListener();
+ stopFiltering();
+
+ m_pControlBorderManager->restoreAll();
+
+ m_aFilterRows.clear();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_xActiveControl = NULL;
+ implSetCurrentControl( NULL );
+
+ // clean up our children
+ for (FmFormControllers::const_iterator i = m_aChilds.begin();
+ i != m_aChilds.end(); i++)
+ {
+ // search the position of the model within the form
+ Reference< XFormComponent > xForm((*i)->getModel(), UNO_QUERY);
+ sal_uInt32 nPos = m_xModelAsIndex->getCount();
+ Reference< XFormComponent > xTemp;
+ for( ; nPos; )
+ {
+
+ m_xModelAsIndex->getByIndex( --nPos ) >>= xTemp;
+ if ( xForm.get() == xTemp.get() )
+ {
+ Reference< XInterface > xIfc( *i, UNO_QUERY );
+ m_xModelAsManager->detach( nPos, xIfc );
+ break;
+ }
+ }
+
+ Reference< XComponent > (*i, UNO_QUERY)->dispose();
+ }
+ m_aChilds.clear();
+
+ disposeAllFeaturesAndDispatchers();
+
+ if ( m_xFormOperations.is() )
+ m_xFormOperations->dispose();
+ m_xFormOperations.clear();
+
+ if (m_bDBConnection)
+ unload();
+
+ setContainer( NULL );
+ setModel( NULL );
+ setParent( NULL );
+
+ ::comphelper::disposeComponent( m_xComposer );
+
+ m_bDBConnection = sal_False;
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ static bool lcl_shouldUseDynamicControlBorder( const Reference< XInterface >& _rxForm, const Any& _rDynamicColorProp )
+ {
+ bool bDoUse = false;
+ if ( !( _rDynamicColorProp >>= bDoUse ) )
+ {
+ DocumentType eDocType = DocumentClassification::classifyHostDocument( _rxForm );
+ return ControlLayouter::useDynamicBorderColor( eDocType );
+ }
+ return bDoUse;
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException )
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ if ( evt.PropertyName == FM_PROP_BOUNDFIELD )
+ {
+ Reference<XPropertySet> xOldBound;
+ evt.OldValue >>= xOldBound;
+ if ( !xOldBound.is() && evt.NewValue.hasValue() )
+ {
+ Reference< XControlModel > xControlModel(evt.Source,UNO_QUERY);
+ Reference< XControl > xControl = findControl(m_aControls,xControlModel,sal_False,sal_False);
+ if ( xControl.is() )
+ {
+ startControlModifyListening( xControl );
+ Reference<XPropertySet> xProp(xControlModel,UNO_QUERY);
+ if ( xProp.is() )
+ xProp->removePropertyChangeListener(FM_PROP_BOUNDFIELD, this);
+ }
+ }
+ }
+ else
+ {
+ sal_Bool bModifiedChanged = (evt.PropertyName == FM_PROP_ISMODIFIED);
+ sal_Bool bNewChanged = (evt.PropertyName == FM_PROP_ISNEW);
+ if (bModifiedChanged || bNewChanged)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (bModifiedChanged)
+ m_bCurrentRecordModified = ::comphelper::getBOOL(evt.NewValue);
+ else
+ m_bCurrentRecordNew = ::comphelper::getBOOL(evt.NewValue);
+
+ // toggle the locking
+ if (m_bLocked != determineLockState())
+ {
+ m_bLocked = !m_bLocked;
+ setLocks();
+ if (isListeningForChanges())
+ startListening();
+ else
+ stopListening();
+ }
+
+ if ( bNewChanged )
+ m_aToggleEvent.Call();
+
+ if (!m_bCurrentRecordModified)
+ m_bModified = sal_False;
+ }
+ else if ( evt.PropertyName == FM_PROP_DYNAMIC_CONTROL_BORDER )
+ {
+ bool bEnable = lcl_shouldUseDynamicControlBorder( evt.Source, evt.NewValue );
+ if ( bEnable )
+ {
+ m_pControlBorderManager->enableDynamicBorderColor();
+ if ( m_xActiveControl.is() )
+ m_pControlBorderManager->focusGained( m_xActiveControl.get() );
+ }
+ else
+ {
+ m_pControlBorderManager->disableDynamicBorderColor();
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+bool FormController::replaceControl( const Reference< XControl >& _rxExistentControl, const Reference< XControl >& _rxNewControl )
+{
+ bool bSuccess = false;
+ try
+ {
+ Reference< XIdentifierReplace > xContainer( getContainer(), UNO_QUERY );
+ DBG_ASSERT( xContainer.is(), "FormController::replaceControl: yes, it's not required by the service description, but XItentifierReplaces would be nice!" );
+ if ( xContainer.is() )
+ {
+ // look up the ID of _rxExistentControl
+ Sequence< sal_Int32 > aIdentifiers( xContainer->getIdentifiers() );
+ const sal_Int32* pIdentifiers = aIdentifiers.getConstArray();
+ const sal_Int32* pIdentifiersEnd = aIdentifiers.getConstArray() + aIdentifiers.getLength();
+ for ( ; pIdentifiers != pIdentifiersEnd; ++pIdentifiers )
+ {
+ Reference< XControl > xCheck( xContainer->getByIdentifier( *pIdentifiers ), UNO_QUERY );
+ if ( xCheck == _rxExistentControl )
+ break;
+ }
+ DBG_ASSERT( pIdentifiers != pIdentifiersEnd, "FormController::replaceControl: did not find the control in the container!" );
+ if ( pIdentifiers != pIdentifiersEnd )
+ {
+ bool bReplacedWasActive = ( m_xActiveControl.get() == _rxExistentControl.get() );
+ bool bReplacedWasCurrent = ( m_xCurrentControl.get() == _rxExistentControl.get() );
+
+ if ( bReplacedWasActive )
+ {
+ m_xActiveControl = NULL;
+ implSetCurrentControl( NULL );
+ }
+ else if ( bReplacedWasCurrent )
+ {
+ implSetCurrentControl( _rxNewControl );
+ }
+
+ // carry over the model
+ _rxNewControl->setModel( _rxExistentControl->getModel() );
+
+ xContainer->replaceByIdentifer( *pIdentifiers, makeAny( _rxNewControl ) );
+ bSuccess = true;
+
+ if ( bReplacedWasActive )
+ {
+ Reference< XWindow > xControlWindow( _rxNewControl, UNO_QUERY );
+ if ( xControlWindow.is() )
+ xControlWindow->setFocus();
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ Reference< XControl > xDisposeIt( bSuccess ? _rxExistentControl : _rxNewControl );
+ ::comphelper::disposeComponent( xDisposeIt );
+ return bSuccess;
+}
+
+//------------------------------------------------------------------------------
+void FormController::toggleAutoFields(sal_Bool bAutoFields)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+
+
+ Sequence< Reference< XControl > > aControlsCopy( m_aControls );
+ const Reference< XControl >* pControls = aControlsCopy.getConstArray();
+ sal_Int32 nControls = aControlsCopy.getLength();
+
+ if (bAutoFields)
+ {
+ // as we don't want new controls to be attached to the scripting environment
+ // we change attach flags
+ m_bAttachEvents = sal_False;
+ for (sal_Int32 i = nControls; i > 0;)
+ {
+ Reference< XControl > xControl = pControls[--i];
+ if (xControl.is())
+ {
+ Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
+ if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
+ {
+ // does the model use a bound field ?
+ Reference< XPropertySet > xField;
+ xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
+
+ // is it a autofield?
+ if ( xField.is()
+ && ::comphelper::hasProperty( FM_PROP_AUTOINCREMENT, xField )
+ && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_AUTOINCREMENT ) )
+ )
+ {
+ replaceControl( xControl, new FmXAutoControl );
+ }
+ }
+ }
+ }
+ m_bAttachEvents = sal_True;
+ }
+ else
+ {
+ m_bDetachEvents = sal_False;
+ for (sal_Int32 i = nControls; i > 0;)
+ {
+ Reference< XControl > xControl = pControls[--i];
+ if (xControl.is())
+ {
+ Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
+ if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
+ {
+ // does the model use a bound field ?
+ Reference< XPropertySet > xField;
+ xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
+
+ // is it a autofield?
+ if ( xField.is()
+ && ::comphelper::hasProperty( FM_PROP_AUTOINCREMENT, xField )
+ && ::comphelper::getBOOL( xField->getPropertyValue(FM_PROP_AUTOINCREMENT ) )
+ )
+ {
+ ::rtl::OUString sServiceName;
+ OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName );
+ Reference< XControl > xNewControl( m_aContext.createComponent( sServiceName ), UNO_QUERY );
+ replaceControl( xControl, xNewControl );
+ }
+ }
+ }
+ }
+ m_bDetachEvents = sal_True;
+ }
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FormController, OnToggleAutoFields, void*, EMPTYARG)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+
+ toggleAutoFields(m_bCurrentRecordNew);
+ return 1L;
+}
+
+// XTextListener
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeException )
+{
+ // SYNCHRONIZED -->
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ if (m_bFiltering)
+ {
+ Reference< XTextComponent > xText(e.Source,UNO_QUERY);
+ ::rtl::OUString aText = xText->getText();
+
+ if ( m_aFilterRows.empty() )
+ appendEmptyDisjunctiveTerm();
+
+ // Suchen der aktuellen Row
+ if ( ( (size_t)m_nCurrentFilterPosition >= m_aFilterRows.size() ) || ( m_nCurrentFilterPosition < 0 ) )
+ {
+ OSL_ENSURE( false, "FormController::textChanged: m_nCurrentFilterPosition is wrong!" );
+ return;
+ }
+
+ FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ];
+
+ // do we have a new filter
+ if (aText.getLength())
+ rRow[xText] = aText;
+ else
+ {
+ // do we have the control in the row
+ FmFilterRow::iterator iter = rRow.find(xText);
+ // erase the entry out of the row
+ if (iter != rRow.end())
+ rRow.erase(iter);
+ }
+
+ // multiplex the event to our FilterControllerListeners
+ FilterEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.FilterComponent = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xText ) - m_aFilterComponents.begin();
+ aEvent.DisjunctiveTerm = getActiveTerm();
+ aEvent.PredicateExpression = aText;
+
+ aGuard.clear();
+ // <-- SYNCHRONIZED
+
+ // notify the changed filter expression
+ m_aFilterListeners.notifyEach( &XFilterControllerListener::predicateExpressionChanged, aEvent );
+ }
+ else
+ impl_onModify();
+}
+
+// XItemListener
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::itemStateChanged(const ItemEvent& /*rEvent*/) throw( RuntimeException )
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ impl_onModify();
+}
+
+// XModificationBroadcaster
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::addModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ m_aModifyListeners.addInterface( l );
+}
+
+//------------------------------------------------------------------------------
+void FormController::removeModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ m_aModifyListeners.removeInterface( l );
+}
+
+// XModificationListener
+//------------------------------------------------------------------------------
+void FormController::modified( const EventObject& _rEvent ) throw( RuntimeException )
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+
+ try
+ {
+ if ( _rEvent.Source != m_xActiveControl )
+ { // let this control grab the focus
+ // (this case may happen if somebody moves the scroll wheel of the mouse over a control
+ // which does not have the focus)
+ // 85511 - 29.05.2001 - frank.schoenheit@germany.sun.com
+ //
+ // also, it happens when an image control gets a new image by double-clicking it
+ // #i88458# / 2009-01-12 / frank.schoenheit@sun.com
+ Reference< XWindow > xControlWindow( _rEvent.Source, UNO_QUERY_THROW );
+ xControlWindow->setFocus();
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ impl_onModify();
+}
+
+//------------------------------------------------------------------------------
+void FormController::impl_checkDisposed_throw() const
+{
+ if ( impl_isDisposed_nofail() )
+ throw DisposedException( ::rtl::OUString(), *const_cast< FormController* >( this ) );
+}
+
+//------------------------------------------------------------------------------
+void FormController::impl_onModify()
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_bModified )
+ m_bModified = sal_True;
+ }
+
+ EventObject aEvt(static_cast<cppu::OWeakObject*>(this));
+ m_aModifyListeners.notifyEach( &XModifyListener::modified, aEvt );
+}
+
+//------------------------------------------------------------------------------
+void FormController::impl_addFilterRow( const FmFilterRow& _row )
+{
+ m_aFilterRows.push_back( _row );
+
+ if ( m_aFilterRows.size() == 1 )
+ { // that's the first row ever
+ OSL_ENSURE( m_nCurrentFilterPosition == -1, "FormController::impl_addFilterRow: inconsistency!" );
+ m_nCurrentFilterPosition = 0;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify )
+{
+ // SYNCHRONIZED -->
+ impl_addFilterRow( FmFilterRow() );
+
+ // notify the listeners
+ FilterEvent aEvent;
+ aEvent.Source = *this;
+ aEvent.DisjunctiveTerm = (sal_Int32)m_aFilterRows.size() - 1;
+ _rClearBeforeNotify.clear();
+ // <-- SYNCHRONIZED
+ m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermAdded, aEvent );
+}
+
+//------------------------------------------------------------------------------
+sal_Bool FormController::determineLockState() const
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ // a.) in filter mode we are always locked
+ // b.) if we have no valid model or our model (a result set) is not alive -> we're locked
+ // c.) if we are inserting everything is OK and we are not locked
+ // d.) if are not updatable or on invalid position
+ Reference< XResultSet > xResultSet(m_xModelAsIndex, UNO_QUERY);
+ if (m_bFiltering || !xResultSet.is() || !isRowSetAlive(xResultSet))
+ return sal_True;
+ else
+ return (m_bCanInsert && m_bCurrentRecordNew) ? sal_False
+ : xResultSet->isBeforeFirst() || xResultSet->isAfterLast() || xResultSet->rowDeleted() || !m_bCanUpdate;
+}
+
+// FocusListener
+//------------------------------------------------------------------------------
+void FormController::focusGained(const FocusEvent& e) throw( RuntimeException )
+{
+ // SYNCHRONIZED -->
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ m_pControlBorderManager->focusGained( e.Source );
+
+ Reference< XControl > xControl(e.Source, UNO_QUERY);
+ if (m_bDBConnection)
+ {
+ // do we need to keep the locking of the commit
+ // we hold the lock as long as the control differs from the current
+ // otherwhise we disabled the lock
+ m_bCommitLock = m_bCommitLock && (XControl*)xControl.get() != (XControl*)m_xCurrentControl.get();
+ if (m_bCommitLock)
+ return;
+
+ // when do we have to commit a value to form or a filter
+ // a.) if the current value is modified
+ // b.) there must be a current control
+ // c.) and it must be different from the new focus owning control or
+ // d.) the focus is moving around (so we have only one control)
+
+ if ( ( m_bModified || m_bFiltering )
+ && m_xCurrentControl.is()
+ && ( ( xControl.get() != m_xCurrentControl.get() )
+ || ( ( e.FocusFlags & FocusChangeReason::AROUND )
+ && ( m_bCycle || m_bFiltering )
+ )
+ )
+ )
+ {
+ // check the old control if the content is ok
+#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
+ Reference< XBoundControl > xLockingTest(m_xCurrentControl, UNO_QUERY);
+ sal_Bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock();
+ OSL_ENSURE(!bControlIsLocked, "FormController::Gained: I'm modified and the current control is locked ? How this ?");
+ // normalerweise sollte ein gelocktes Control nicht modified sein, also muss wohl mein bModified aus einem anderen Kontext
+ // gesetzt worden sein, was ich nicht verstehen wuerde ...
+#endif
+ DBG_ASSERT(m_xCurrentControl.is(), "kein CurrentControl gesetzt");
+ // zunaechst das Control fragen ob es das IFace unterstuetzt
+ Reference< XBoundComponent > xBound(m_xCurrentControl, UNO_QUERY);
+ if (!xBound.is() && m_xCurrentControl.is())
+ xBound = Reference< XBoundComponent > (m_xCurrentControl->getModel(), UNO_QUERY);
+
+ // lock if we lose the focus during commit
+ m_bCommitLock = sal_True;
+
+ // Commit nicht erfolgreich, Focus zuruecksetzen
+ if (xBound.is() && !xBound->commit())
+ {
+ // the commit failed and we don't commit again until the current control
+ // which couldn't be commit gains the focus again
+ Reference< XWindow > xWindow(m_xCurrentControl, UNO_QUERY);
+ if (xWindow.is())
+ xWindow->setFocus();
+ return;
+ }
+ else
+ {
+ m_bModified = sal_False;
+ m_bCommitLock = sal_False;
+ }
+ }
+
+ if (!m_bFiltering && m_bCycle && (e.FocusFlags & FocusChangeReason::AROUND) && m_xCurrentControl.is())
+ {
+ SQLErrorEvent aErrorEvent;
+ OSL_ENSURE( m_xFormOperations.is(), "FormController::focusGained: hmm?" );
+ // should have been created in setModel
+ try
+ {
+ if ( e.FocusFlags & FocusChangeReason::FORWARD )
+ {
+ if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToNext ) )
+ m_xFormOperations->execute( FormFeature::MoveToNext );
+ }
+ else // backward
+ {
+ if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToPrevious ) )
+ m_xFormOperations->execute( FormFeature::MoveToPrevious );
+ }
+ }
+ catch ( const Exception& )
+ {
+ // don't handle this any further. That's an ... admissible error.
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ // Immer noch ein und dasselbe Control
+ if ( ( m_xActiveControl == xControl )
+ && ( xControl == m_xCurrentControl )
+ )
+ {
+ DBG_ASSERT(m_xCurrentControl.is(), "Kein CurrentControl selektiert");
+ return;
+ }
+
+ sal_Bool bActivated = !m_xActiveControl.is() && xControl.is();
+
+ m_xActiveControl = xControl;
+
+ implSetCurrentControl( xControl );
+ OSL_POSTCOND( m_xCurrentControl.is(), "implSetCurrentControl did nonsense!" );
+
+ if ( bActivated )
+ {
+ // (asynchronously) call activation handlers
+ m_aActivationEvent.Call();
+
+ // call modify listeners
+ if ( m_bModified )
+ m_aModifyListeners.notifyEach( &XModifyListener::modified, EventObject( *this ) );
+ }
+
+ // invalidate all features which depend on the currently focused control
+ if ( m_bDBConnection && !m_bFiltering )
+ implInvalidateCurrentControlDependentFeatures();
+
+ if ( !m_xCurrentControl.is() )
+ return;
+
+ // Control erhaelt Focus, dann eventuell in den sichtbaren Bereich
+ Reference< XFormControllerContext > xContext( m_xContext );
+ Reference< XControl > xCurrentControl( m_xCurrentControl );
+ aGuard.clear();
+ // <-- SYNCHRONIZED
+
+ if ( xContext.is() )
+ xContext->makeVisible( xCurrentControl );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( FormController, OnActivated, void*, /**/ )
+{
+ EventObject aEvent;
+ aEvent.Source = *this;
+ m_aActivateListeners.notifyEach( &XFormControllerListener::formActivated, aEvent );
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( FormController, OnDeactivated, void*, /**/ )
+{
+ EventObject aEvent;
+ aEvent.Source = *this;
+ m_aActivateListeners.notifyEach( &XFormControllerListener::formDeactivated, aEvent );
+
+ return 0L;
+}
+
+//------------------------------------------------------------------------------
+void FormController::focusLost(const FocusEvent& e) throw( RuntimeException )
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+
+ m_pControlBorderManager->focusLost( e.Source );
+
+ Reference< XControl > xControl(e.Source, UNO_QUERY);
+ Reference< XWindowPeer > xNext(e.NextFocus, UNO_QUERY);
+ Reference< XControl > xNextControl = isInList(xNext);
+ if (!xNextControl.is())
+ {
+ m_xActiveControl = NULL;
+ m_aDeactivationEvent.Call();
+ }
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL FormController::mousePressed( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException)
+{
+ // not interested in
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL FormController::mouseReleased( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException)
+{
+ // not interested in
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL FormController::mouseEntered( const awt::MouseEvent& _rEvent ) throw (RuntimeException)
+{
+ m_pControlBorderManager->mouseEntered( _rEvent.Source );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL FormController::mouseExited( const awt::MouseEvent& _rEvent ) throw (RuntimeException)
+{
+ m_pControlBorderManager->mouseExited( _rEvent.Source );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL FormController::componentValidityChanged( const EventObject& _rSource ) throw (RuntimeException)
+{
+ Reference< XControl > xControl( findControl( m_aControls, Reference< XControlModel >( _rSource.Source, UNO_QUERY ), sal_False, sal_False ) );
+ Reference< XValidatableFormComponent > xValidatable( _rSource.Source, UNO_QUERY );
+
+ OSL_ENSURE( xControl.is() && xValidatable.is(), "FormController::componentValidityChanged: huh?" );
+
+ if ( xControl.is() && xValidatable.is() )
+ m_pControlBorderManager->validityChanged( xControl, xValidatable );
+}
+
+//--------------------------------------------------------------------
+void FormController::setModel(const Reference< XTabControllerModel > & Model) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ DBG_ASSERT(m_xTabController.is(), "FormController::setModel : invalid aggregate !");
+
+ try
+ {
+ // disconnect from the old model
+ if (m_xModelAsIndex.is())
+ {
+ if (m_bDBConnection)
+ {
+ // we are currently working on the model
+ EventObject aEvt(m_xModelAsIndex);
+ unloaded(aEvt);
+ }
+
+ Reference< XLoadable > xForm(m_xModelAsIndex, UNO_QUERY);
+ if (xForm.is())
+ xForm->removeLoadListener(this);
+
+ Reference< XSQLErrorBroadcaster > xBroadcaster(m_xModelAsIndex, UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->removeSQLErrorListener(this);
+
+ Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(m_xModelAsIndex, UNO_QUERY);
+ if (xParamBroadcaster.is())
+ xParamBroadcaster->removeParameterListener(this);
+
+ }
+
+ disposeAllFeaturesAndDispatchers();
+
+ if ( m_xFormOperations.is() )
+ m_xFormOperations->dispose();
+ m_xFormOperations.clear();
+
+ // set the new model wait for the load event
+ if (m_xTabController.is())
+ m_xTabController->setModel(Model);
+ m_xModelAsIndex = Reference< XIndexAccess > (Model, UNO_QUERY);
+ m_xModelAsManager = Reference< XEventAttacherManager > (Model, UNO_QUERY);
+
+ // only if both ifaces exit, the controller will work successful
+ if (!m_xModelAsIndex.is() || !m_xModelAsManager.is())
+ {
+ m_xModelAsManager = NULL;
+ m_xModelAsIndex = NULL;
+ }
+
+ if (m_xModelAsIndex.is())
+ {
+ // re-create m_xFormOperations
+ m_xFormOperations.set( FormOperations::createWithFormController( m_aContext.getUNOContext(), this ), UNO_SET_THROW );
+ m_xFormOperations->setFeatureInvalidation( this );
+
+ // adding load and ui interaction listeners
+ Reference< XLoadable > xForm(Model, UNO_QUERY);
+ if (xForm.is())
+ xForm->addLoadListener(this);
+
+ Reference< XSQLErrorBroadcaster > xBroadcaster(Model, UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->addSQLErrorListener(this);
+
+ Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(Model, UNO_QUERY);
+ if (xParamBroadcaster.is())
+ xParamBroadcaster->addParameterListener(this);
+
+ // well, is the database already loaded?
+ // then we have to simulate a load event
+ Reference< XLoadable > xCursor(m_xModelAsIndex, UNO_QUERY);
+ if (xCursor.is() && xCursor->isLoaded())
+ {
+ EventObject aEvt(xCursor);
+ loaded(aEvt);
+ }
+
+ Reference< XPropertySet > xModelProps( m_xModelAsIndex, UNO_QUERY );
+ Reference< XPropertySetInfo > xPropInfo( xModelProps->getPropertySetInfo() );
+ if ( xPropInfo.is()
+ && xPropInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER )
+ && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_FOCUS )
+ && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_MOUSE )
+ && xPropInfo->hasPropertyByName( FM_PROP_CONTROL_BORDER_COLOR_INVALID )
+ )
+ {
+ bool bEnableDynamicControlBorder = lcl_shouldUseDynamicControlBorder(
+ xModelProps.get(), xModelProps->getPropertyValue( FM_PROP_DYNAMIC_CONTROL_BORDER ) );
+ if ( bEnableDynamicControlBorder )
+ m_pControlBorderManager->enableDynamicBorderColor();
+ else
+ m_pControlBorderManager->disableDynamicBorderColor();
+
+ sal_Int32 nColor = 0;
+ if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_FOCUS ) >>= nColor )
+ m_pControlBorderManager->setStatusColor( CONTROL_STATUS_FOCUSED, nColor );
+ if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_MOUSE ) >>= nColor )
+ m_pControlBorderManager->setStatusColor( CONTROL_STATUS_MOUSE_HOVER, nColor );
+ if ( xModelProps->getPropertyValue( FM_PROP_CONTROL_BORDER_COLOR_INVALID ) >>= nColor )
+ m_pControlBorderManager->setStatusColor( CONTROL_STATUS_INVALID, nColor );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+Reference< XTabControllerModel > FormController::getModel() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ DBG_ASSERT(m_xTabController.is(), "FormController::getModel : invalid aggregate !");
+ if (!m_xTabController.is())
+ return Reference< XTabControllerModel > ();
+ return m_xTabController->getModel();
+}
+
+//------------------------------------------------------------------------------
+void FormController::addToEventAttacher(const Reference< XControl > & xControl)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ OSL_ENSURE( xControl.is(), "FormController::addToEventAttacher: invalid control - how did you reach this?" );
+ if ( !xControl.is() )
+ return; /* throw IllegalArgumentException(); */
+
+ // anmelden beim Eventattacher
+ Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY);
+ if (xComp.is() && m_xModelAsIndex.is())
+ {
+ // Und die Position des ControlModel darin suchen
+ sal_uInt32 nPos = m_xModelAsIndex->getCount();
+ Reference< XFormComponent > xTemp;
+ for( ; nPos; )
+ {
+ m_xModelAsIndex->getByIndex(--nPos) >>= xTemp;
+ if ((XFormComponent*)xComp.get() == (XFormComponent*)xTemp.get())
+ {
+ Reference< XInterface > xIfc(xControl, UNO_QUERY);
+ m_xModelAsManager->attach( nPos, xIfc, makeAny(xControl) );
+ break;
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::removeFromEventAttacher(const Reference< XControl > & xControl)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ OSL_ENSURE( xControl.is(), "FormController::removeFromEventAttacher: invalid control - how did you reach this?" );
+ if ( !xControl.is() )
+ return; /* throw IllegalArgumentException(); */
+
+ // abmelden beim Eventattacher
+ Reference< XFormComponent > xComp(xControl->getModel(), UNO_QUERY);
+ if ( xComp.is() && m_xModelAsIndex.is() )
+ {
+ // Und die Position des ControlModel darin suchen
+ sal_uInt32 nPos = m_xModelAsIndex->getCount();
+ Reference< XFormComponent > xTemp;
+ for( ; nPos; )
+ {
+ m_xModelAsIndex->getByIndex(--nPos) >>= xTemp;
+ if ((XFormComponent*)xComp.get() == (XFormComponent*)xTemp.get())
+ {
+ Reference< XInterface > xIfc(xControl, UNO_QUERY);
+ m_xModelAsManager->detach( nPos, xIfc );
+ break;
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::setContainer(const Reference< XControlContainer > & xContainer) throw( RuntimeException )
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ Reference< XTabControllerModel > xTabModel(getModel());
+ DBG_ASSERT(xTabModel.is() || !xContainer.is(), "No Model defined");
+ // if we have a new container we need a model
+ DBG_ASSERT(m_xTabController.is(), "FormController::setContainer : invalid aggregate !");
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XContainer > xCurrentContainer;
+ if (m_xTabController.is())
+ xCurrentContainer = Reference< XContainer > (m_xTabController->getContainer(), UNO_QUERY);
+ if (xCurrentContainer.is())
+ {
+ xCurrentContainer->removeContainerListener(this);
+
+ if ( m_aTabActivationTimer.IsActive() )
+ m_aTabActivationTimer.Stop();
+
+ // clear the filter map
+ ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) );
+ m_aFilterComponents.clear();
+
+ // einsammeln der Controls
+ const Reference< XControl >* pControls = m_aControls.getConstArray();
+ const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
+ while ( pControls != pControlsEnd )
+ implControlRemoved( *pControls++, true );
+
+ // Datenbank spezifische Dinge vornehmen
+ if (m_bDBConnection && isListeningForChanges())
+ stopListening();
+
+ m_aControls.realloc( 0 );
+ }
+
+ if (m_xTabController.is())
+ m_xTabController->setContainer(xContainer);
+
+ // Welche Controls gehoeren zum Container ?
+ if (xContainer.is() && xTabModel.is())
+ {
+ Sequence< Reference< XControlModel > > aModels = xTabModel->getControlModels();
+ const Reference< XControlModel > * pModels = aModels.getConstArray();
+ Sequence< Reference< XControl > > aAllControls = xContainer->getControls();
+
+ sal_Int32 nCount = aModels.getLength();
+ m_aControls = Sequence< Reference< XControl > >( nCount );
+ Reference< XControl > * pControls = m_aControls.getArray();
+
+ // einsammeln der Controls
+ sal_Int32 i, j;
+ for (i = 0, j = 0; i < nCount; ++i, ++pModels )
+ {
+ Reference< XControl > xControl = findControl( aAllControls, *pModels, sal_False, sal_True );
+ if ( xControl.is() )
+ {
+ pControls[j++] = xControl;
+ implControlInserted( xControl, true );
+ }
+ }
+
+ // not every model had an associated control
+ if (j != i)
+ m_aControls.realloc(j);
+
+ // am Container horchen
+ Reference< XContainer > xNewContainer(xContainer, UNO_QUERY);
+ if (xNewContainer.is())
+ xNewContainer->addContainerListener(this);
+
+ // Datenbank spezifische Dinge vornehmen
+ if (m_bDBConnection)
+ {
+ m_bLocked = determineLockState();
+ setLocks();
+ if (!isLocked())
+ startListening();
+ }
+ }
+ // befinden sich die Controls in der richtigen Reihenfolge
+ m_bControlsSorted = sal_True;
+}
+
+//------------------------------------------------------------------------------
+Reference< XControlContainer > FormController::getContainer() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ DBG_ASSERT(m_xTabController.is(), "FormController::getContainer : invalid aggregate !");
+ if (!m_xTabController.is())
+ return Reference< XControlContainer > ();
+ return m_xTabController->getContainer();
+}
+
+//------------------------------------------------------------------------------
+Sequence< Reference< XControl > > FormController::getControls(void) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ if (!m_bControlsSorted)
+ {
+ Reference< XTabControllerModel > xModel = getModel();
+ if (!xModel.is())
+ return m_aControls;
+
+ Sequence< Reference< XControlModel > > aControlModels = xModel->getControlModels();
+ const Reference< XControlModel > * pModels = aControlModels.getConstArray();
+ sal_Int32 nModels = aControlModels.getLength();
+
+ Sequence< Reference< XControl > > aNewControls(nModels);
+
+ Reference< XControl > * pControls = aNewControls.getArray();
+ Reference< XControl > xControl;
+
+ // Umsortieren der Controls entsprechend der TabReihenfolge
+ sal_Int32 j = 0;
+ for (sal_Int32 i = 0; i < nModels; ++i, ++pModels )
+ {
+ xControl = findControl( m_aControls, *pModels, sal_True, sal_True );
+ if ( xControl.is() )
+ pControls[j++] = xControl;
+ }
+
+ // not every model had an associated control
+ if ( j != nModels )
+ aNewControls.realloc( j );
+
+ m_aControls = aNewControls;
+ m_bControlsSorted = sal_True;
+ }
+ return m_aControls;
+}
+
+//------------------------------------------------------------------------------
+void FormController::autoTabOrder() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ DBG_ASSERT(m_xTabController.is(), "FormController::autoTabOrder : invalid aggregate !");
+ if (m_xTabController.is())
+ m_xTabController->autoTabOrder();
+}
+
+//------------------------------------------------------------------------------
+void FormController::activateTabOrder() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ DBG_ASSERT(m_xTabController.is(), "FormController::activateTabOrder : invalid aggregate !");
+ if (m_xTabController.is())
+ m_xTabController->activateTabOrder();
+}
+
+//------------------------------------------------------------------------------
+void FormController::setControlLock(const Reference< XControl > & xControl)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ sal_Bool bLocked = isLocked();
+
+ // es wird gelockt
+ // a.) wenn der ganze Datensatz gesperrt ist
+ // b.) wenn das zugehoerige Feld gespeert ist
+ Reference< XBoundControl > xBound(xControl, UNO_QUERY);
+ if (xBound.is() && (( (bLocked && bLocked != xBound->getLock()) ||
+ !bLocked))) // beim entlocken immer einzelne Felder ueberprüfen
+ {
+ // gibt es eine Datenquelle
+ Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
+ if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
+ {
+ // wie sieht mit den Properties ReadOnly und Enable aus
+ sal_Bool bTouch = sal_True;
+ if (::comphelper::hasProperty(FM_PROP_ENABLED, xSet))
+ bTouch = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ENABLED));
+ if (::comphelper::hasProperty(FM_PROP_READONLY, xSet))
+ bTouch = !::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_READONLY));
+
+ if (bTouch)
+ {
+ Reference< XPropertySet > xField;
+ xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
+ if (xField.is())
+ {
+ if (bLocked)
+ xBound->setLock(bLocked);
+ else
+ {
+ try
+ {
+ Any aVal = xField->getPropertyValue(FM_PROP_ISREADONLY);
+ if (aVal.hasValue() && ::comphelper::getBOOL(aVal))
+ xBound->setLock(sal_True);
+ else
+ xBound->setLock(bLocked);
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ }
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::setLocks()
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ // alle Controls, die mit einer Datenquelle verbunden sind locken/unlocken
+ const Reference< XControl >* pControls = m_aControls.getConstArray();
+ const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
+ while ( pControls != pControlsEnd )
+ setControlLock( *pControls++ );
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ bool lcl_shouldListenForModifications( const Reference< XControl >& _rxControl, const Reference< XPropertyChangeListener >& _rxBoundFieldListener )
+ {
+ bool bShould = false;
+
+ Reference< XBoundComponent > xBound( _rxControl, UNO_QUERY );
+ if ( xBound.is() )
+ {
+ bShould = true;
+ }
+ else if ( _rxControl.is() )
+ {
+ Reference< XPropertySet > xModelProps( _rxControl->getModel(), UNO_QUERY );
+ if ( xModelProps.is() && ::comphelper::hasProperty( FM_PROP_BOUNDFIELD, xModelProps ) )
+ {
+ Reference< XPropertySet > xField;
+ xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ) >>= xField;
+ bShould = xField.is();
+
+ if ( !bShould && _rxBoundFieldListener.is() )
+ xModelProps->addPropertyChangeListener( FM_PROP_BOUNDFIELD, _rxBoundFieldListener );
+ }
+ }
+
+ return bShould;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::startControlModifyListening(const Reference< XControl > & xControl)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+
+ bool bModifyListening = lcl_shouldListenForModifications( xControl, this );
+
+ // artificial while
+ while ( bModifyListening )
+ {
+ Reference< XModifyBroadcaster > xMod(xControl, UNO_QUERY);
+ if (xMod.is())
+ {
+ xMod->addModifyListener(this);
+ break;
+ }
+
+ // alle die Text um vorzeitig ein modified zu erkennen
+ Reference< XTextComponent > xText(xControl, UNO_QUERY);
+ if (xText.is())
+ {
+ xText->addTextListener(this);
+ break;
+ }
+
+ Reference< XCheckBox > xBox(xControl, UNO_QUERY);
+ if (xBox.is())
+ {
+ xBox->addItemListener(this);
+ break;
+ }
+
+ Reference< XComboBox > xCbBox(xControl, UNO_QUERY);
+ if (xCbBox.is())
+ {
+ xCbBox->addItemListener(this);
+ break;
+ }
+
+ Reference< XListBox > xListBox(xControl, UNO_QUERY);
+ if (xListBox.is())
+ {
+ xListBox->addItemListener(this);
+ break;
+ }
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::stopControlModifyListening(const Reference< XControl > & xControl)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+
+ bool bModifyListening = lcl_shouldListenForModifications( xControl, NULL );
+
+ // kuenstliches while
+ while (bModifyListening)
+ {
+ Reference< XModifyBroadcaster > xMod(xControl, UNO_QUERY);
+ if (xMod.is())
+ {
+ xMod->removeModifyListener(this);
+ break;
+ }
+ // alle die Text um vorzeitig ein modified zu erkennen
+ Reference< XTextComponent > xText(xControl, UNO_QUERY);
+ if (xText.is())
+ {
+ xText->removeTextListener(this);
+ break;
+ }
+
+ Reference< XCheckBox > xBox(xControl, UNO_QUERY);
+ if (xBox.is())
+ {
+ xBox->removeItemListener(this);
+ break;
+ }
+
+ Reference< XComboBox > xCbBox(xControl, UNO_QUERY);
+ if (xCbBox.is())
+ {
+ xCbBox->removeItemListener(this);
+ break;
+ }
+
+ Reference< XListBox > xListBox(xControl, UNO_QUERY);
+ if (xListBox.is())
+ {
+ xListBox->removeItemListener(this);
+ break;
+ }
+ break;
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::startListening()
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ m_bModified = sal_False;
+
+ // jetzt anmelden bei gebundenen feldern
+ const Reference< XControl >* pControls = m_aControls.getConstArray();
+ const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
+ while ( pControls != pControlsEnd )
+ startControlModifyListening( *pControls++ );
+}
+
+//------------------------------------------------------------------------------
+void FormController::stopListening()
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ m_bModified = sal_False;
+
+ // jetzt anmelden bei gebundenen feldern
+ const Reference< XControl >* pControls = m_aControls.getConstArray();
+ const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
+ while ( pControls != pControlsEnd )
+ stopControlModifyListening( *pControls++ );
+}
+
+
+//------------------------------------------------------------------------------
+Reference< XControl > FormController::findControl(Sequence< Reference< XControl > >& _rControls, const Reference< XControlModel > & xCtrlModel ,sal_Bool _bRemove,sal_Bool _bOverWrite) const
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ DBG_ASSERT( xCtrlModel.is(), "findControl - welches ?!" );
+
+ Reference< XControl >* pControls = _rControls.getArray();
+ Reference< XControlModel > xModel;
+ for ( sal_Int32 i = 0, nCount = _rControls.getLength(); i < nCount; ++i, ++pControls )
+ {
+ if ( pControls->is() )
+ {
+ xModel = (*pControls)->getModel();
+ if ( xModel.get() == xCtrlModel.get() )
+ {
+ Reference< XControl > xControl( *pControls );
+ if ( _bRemove )
+ ::comphelper::removeElementAt( _rControls, i );
+ else if ( _bOverWrite )
+ *pControls = Reference< XControl >();
+ return xControl;
+ }
+ }
+ }
+ return Reference< XControl > ();
+}
+
+//------------------------------------------------------------------------------
+void FormController::implControlInserted( const Reference< XControl>& _rxControl, bool _bAddToEventAttacher )
+{
+ Reference< XWindow > xWindow( _rxControl, UNO_QUERY );
+ if ( xWindow.is() )
+ {
+ xWindow->addFocusListener( this );
+ xWindow->addMouseListener( this );
+
+ if ( _bAddToEventAttacher )
+ addToEventAttacher( _rxControl );
+ }
+
+ // add a dispatch interceptor to the control (if supported)
+ Reference< XDispatchProviderInterception > xInterception( _rxControl, UNO_QUERY );
+ if ( xInterception.is() )
+ createInterceptor( xInterception );
+
+ if ( _rxControl.is() )
+ {
+ Reference< XControlModel > xModel( _rxControl->getModel() );
+
+ // we want to know about the reset of the the model of our controls
+ // (for correctly resetting m_bModified)
+ Reference< XReset > xReset( xModel, UNO_QUERY );
+ if ( xReset.is() )
+ xReset->addResetListener( this );
+
+ // and we want to know about the validity, to visually indicate it
+ Reference< XValidatableFormComponent > xValidatable( xModel, UNO_QUERY );
+ if ( xValidatable.is() )
+ {
+ xValidatable->addFormComponentValidityListener( this );
+ m_pControlBorderManager->validityChanged( _rxControl, xValidatable );
+ }
+ }
+
+}
+
+//------------------------------------------------------------------------------
+void FormController::implControlRemoved( const Reference< XControl>& _rxControl, bool _bRemoveFromEventAttacher )
+{
+ Reference< XWindow > xWindow( _rxControl, UNO_QUERY );
+ if ( xWindow.is() )
+ {
+ xWindow->removeFocusListener( this );
+ xWindow->removeMouseListener( this );
+
+ if ( _bRemoveFromEventAttacher )
+ removeFromEventAttacher( _rxControl );
+ }
+
+ Reference< XDispatchProviderInterception > xInterception( _rxControl, UNO_QUERY);
+ if ( xInterception.is() )
+ deleteInterceptor( xInterception );
+
+ if ( _rxControl.is() )
+ {
+ Reference< XControlModel > xModel( _rxControl->getModel() );
+
+ Reference< XReset > xReset( xModel, UNO_QUERY );
+ if ( xReset.is() )
+ xReset->removeResetListener( this );
+
+ Reference< XValidatableFormComponent > xValidatable( xModel, UNO_QUERY );
+ if ( xValidatable.is() )
+ xValidatable->removeFormComponentValidityListener( this );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::implSetCurrentControl( const Reference< XControl >& _rxControl )
+{
+ if ( m_xCurrentControl.get() == _rxControl.get() )
+ return;
+
+ Reference< XGridControl > xGridControl( m_xCurrentControl, UNO_QUERY );
+ if ( xGridControl.is() )
+ xGridControl->removeGridControlListener( this );
+
+ m_xCurrentControl = _rxControl;
+
+ xGridControl.set( m_xCurrentControl, UNO_QUERY );
+ if ( xGridControl.is() )
+ xGridControl->addGridControlListener( this );
+}
+
+//------------------------------------------------------------------------------
+void FormController::insertControl(const Reference< XControl > & xControl)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ m_bControlsSorted = sal_False;
+ m_aControls.realloc(m_aControls.getLength() + 1);
+ m_aControls.getArray()[m_aControls.getLength() - 1] = xControl;
+
+ if ( m_pColumnInfoCache.get() )
+ m_pColumnInfoCache->deinitializeControls();
+
+ implControlInserted( xControl, m_bAttachEvents );
+
+ if (m_bDBConnection && !m_bFiltering)
+ setControlLock(xControl);
+
+ if (isListeningForChanges() && m_bAttachEvents)
+ startControlModifyListening( xControl );
+}
+
+//------------------------------------------------------------------------------
+void FormController::removeControl(const Reference< XControl > & xControl)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ const Reference< XControl >* pControls = m_aControls.getConstArray();
+ const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
+ while ( pControls != pControlsEnd )
+ {
+ if ( xControl.get() == (*pControls++).get() )
+ {
+ ::comphelper::removeElementAt( m_aControls, pControls - m_aControls.getConstArray() - 1 );
+ break;
+ }
+ }
+
+ FilterComponents::iterator componentPos = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl );
+ if ( componentPos != m_aFilterComponents.end() )
+ m_aFilterComponents.erase( componentPos );
+
+ implControlRemoved( xControl, m_bDetachEvents );
+
+ if ( isListeningForChanges() && m_bDetachEvents )
+ stopControlModifyListening( xControl );
+}
+
+// XLoadListener
+//------------------------------------------------------------------------------
+void FormController::loaded(const EventObject& rEvent) throw( RuntimeException )
+{
+ OSL_ENSURE( rEvent.Source == m_xModelAsIndex, "FormController::loaded: where did this come from?" );
+
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XRowSet > xForm(rEvent.Source, UNO_QUERY);
+ // do we have a connected data source
+ OStaticDataAccessTools aStaticTools;
+ if (xForm.is() && aStaticTools.getRowSetConnection(xForm).is())
+ {
+ Reference< XPropertySet > xSet(xForm, UNO_QUERY);
+ if (xSet.is())
+ {
+ Any aVal = xSet->getPropertyValue(FM_PROP_CYCLE);
+ sal_Int32 aVal2 = 0;
+ ::cppu::enum2int(aVal2,aVal);
+ m_bCycle = !aVal.hasValue() || aVal2 == TabulatorCycle_RECORDS;
+ m_bCanUpdate = aStaticTools.canUpdate(xSet);
+ m_bCanInsert = aStaticTools.canInsert(xSet);
+ m_bCurrentRecordModified = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISMODIFIED));
+ m_bCurrentRecordNew = ::comphelper::getBOOL(xSet->getPropertyValue(FM_PROP_ISNEW));
+
+ startFormListening( xSet, sal_False );
+
+ // set the locks for the current controls
+ if (getContainer().is())
+ {
+ m_aLoadEvent.Call();
+ }
+ }
+ else
+ {
+ m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False;
+ m_bCurrentRecordModified = sal_False;
+ m_bCurrentRecordNew = sal_False;
+ m_bLocked = sal_False;
+ }
+ m_bDBConnection = sal_True;
+ }
+ else
+ {
+ m_bDBConnection = sal_False;
+ m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False;
+ m_bCurrentRecordModified = sal_False;
+ m_bCurrentRecordNew = sal_False;
+ m_bLocked = sal_False;
+ }
+
+ Reference< XColumnsSupplier > xFormColumns( xForm, UNO_QUERY );
+ m_pColumnInfoCache.reset( xFormColumns.is() ? new ColumnInfoCache( xFormColumns ) : NULL );
+
+ updateAllDispatchers();
+}
+
+//------------------------------------------------------------------------------
+void FormController::updateAllDispatchers() const
+{
+ ::std::for_each(
+ m_aFeatureDispatchers.begin(),
+ m_aFeatureDispatchers.end(),
+ ::std::compose1(
+ UpdateAllListeners(),
+ ::std::select2nd< DispatcherContainer::value_type >()
+ )
+ );
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK(FormController, OnLoad, void*, EMPTYARG)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ m_bLocked = determineLockState();
+
+ setLocks();
+
+ if (!m_bLocked)
+ startListening();
+
+ // just one exception toggle the auto values
+ if (m_bCurrentRecordNew)
+ toggleAutoFields(sal_True);
+
+ return 1L;
+}
+
+//------------------------------------------------------------------------------
+void FormController::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ updateAllDispatchers();
+}
+
+//------------------------------------------------------------------------------
+void FormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ // do the same like in unloading
+ // just one exception toggle the auto values
+ m_aToggleEvent.CancelPendingCall();
+ unload();
+}
+
+//------------------------------------------------------------------------------
+void FormController::reloaded(const EventObject& aEvent) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ loaded(aEvent);
+}
+
+//------------------------------------------------------------------------------
+void FormController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ unload();
+}
+
+//------------------------------------------------------------------------------
+void FormController::unload() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ m_aLoadEvent.CancelPendingCall();
+
+ // be sure not to have autofields
+ if (m_bCurrentRecordNew)
+ toggleAutoFields(sal_False);
+
+ // remove bound field listing again
+ removeBoundFieldListener();
+
+ if (m_bDBConnection && isListeningForChanges())
+ stopListening();
+
+ Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY );
+ if ( m_bDBConnection && xSet.is() )
+ stopFormListening( xSet, sal_False );
+
+ m_bDBConnection = sal_False;
+ m_bCanInsert = m_bCanUpdate = m_bCycle = sal_False;
+ m_bCurrentRecordModified = m_bCurrentRecordNew = m_bLocked = sal_False;
+
+ m_pColumnInfoCache.reset( NULL );
+}
+
+// -----------------------------------------------------------------------------
+void FormController::removeBoundFieldListener()
+{
+ const Reference< XControl >* pControls = m_aControls.getConstArray();
+ const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength();
+ while ( pControls != pControlsEnd )
+ {
+ Reference< XPropertySet > xProp( *pControls++, UNO_QUERY );
+ if ( xProp.is() )
+ xProp->removePropertyChangeListener( FM_PROP_BOUNDFIELD, this );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::startFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly )
+{
+ try
+ {
+ if ( m_bCanInsert || m_bCanUpdate ) // form can be modified
+ {
+ _rxForm->addPropertyChangeListener( FM_PROP_ISNEW, this );
+ _rxForm->addPropertyChangeListener( FM_PROP_ISMODIFIED, this );
+
+ if ( !_bPropertiesOnly )
+ {
+ // set the Listener for UI interaction
+ Reference< XRowSetApproveBroadcaster > xApprove( _rxForm, UNO_QUERY );
+ if ( xApprove.is() )
+ xApprove->addRowSetApproveListener( this );
+
+ // listener for row set changes
+ Reference< XRowSet > xRowSet( _rxForm, UNO_QUERY );
+ if ( xRowSet.is() )
+ xRowSet->addRowSetListener( this );
+ }
+ }
+
+ Reference< XPropertySetInfo > xInfo = _rxForm->getPropertySetInfo();
+ if ( xInfo.is() && xInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER ) )
+ _rxForm->addPropertyChangeListener( FM_PROP_DYNAMIC_CONTROL_BORDER, this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::stopFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly )
+{
+ try
+ {
+ if ( m_bCanInsert || m_bCanUpdate )
+ {
+ _rxForm->removePropertyChangeListener( FM_PROP_ISNEW, this );
+ _rxForm->removePropertyChangeListener( FM_PROP_ISMODIFIED, this );
+
+ if ( !_bPropertiesOnly )
+ {
+ Reference< XRowSetApproveBroadcaster > xApprove( _rxForm, UNO_QUERY );
+ if (xApprove.is())
+ xApprove->removeRowSetApproveListener(this);
+
+ Reference< XRowSet > xRowSet( _rxForm, UNO_QUERY );
+ if ( xRowSet.is() )
+ xRowSet->removeRowSetListener( this );
+ }
+ }
+
+ Reference< XPropertySetInfo > xInfo = _rxForm->getPropertySetInfo();
+ if ( xInfo.is() && xInfo->hasPropertyByName( FM_PROP_DYNAMIC_CONTROL_BORDER ) )
+ _rxForm->removePropertyChangeListener( FM_PROP_DYNAMIC_CONTROL_BORDER, this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// com::sun::star::sdbc::XRowSetListener
+//------------------------------------------------------------------------------
+void FormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ // toggle the locking ?
+ if (m_bLocked != determineLockState())
+ {
+ m_bLocked = !m_bLocked;
+ setLocks();
+ if (isListeningForChanges())
+ startListening();
+ else
+ stopListening();
+ }
+
+ // neither the current control nor the current record are modified anymore
+ m_bCurrentRecordModified = m_bModified = sal_False;
+}
+
+//------------------------------------------------------------------------------
+void FormController::rowChanged(const EventObject& /*event*/) throw( RuntimeException )
+{
+ // not interested in ...
+}
+//------------------------------------------------------------------------------
+void FormController::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException )
+{
+ // not interested in ...
+}
+
+
+// XContainerListener
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::elementInserted(const ContainerEvent& evt) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ Reference< XControl > xControl( evt.Element, UNO_QUERY );
+ if ( !xControl.is() )
+ return;
+
+ Reference< XFormComponent > xModel(xControl->getModel(), UNO_QUERY);
+ if (xModel.is() && m_xModelAsIndex == xModel->getParent())
+ {
+ insertControl(xControl);
+
+ if ( m_aTabActivationTimer.IsActive() )
+ m_aTabActivationTimer.Stop();
+
+ m_aTabActivationTimer.Start();
+ }
+ // are we in filtermode and a XModeSelector has inserted an element
+ else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is())
+ {
+ xModel = Reference< XFormComponent > (evt.Source, UNO_QUERY);
+ if (xModel.is() && m_xModelAsIndex == xModel->getParent())
+ {
+ Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
+ if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
+ {
+ // does the model use a bound field ?
+ Reference< XPropertySet > xField;
+ xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
+
+ Reference< XTextComponent > xText(xControl, UNO_QUERY);
+ // may we filter the field?
+ if (xText.is() && xField.is() && ::comphelper::hasProperty(FM_PROP_SEARCHABLE, xField) &&
+ ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_SEARCHABLE)))
+ {
+ m_aFilterComponents.push_back( xText );
+ xText->addTextListener( this );
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::elementReplaced(const ContainerEvent& evt) throw( RuntimeException )
+{
+ // simulate an elementRemoved
+ ContainerEvent aRemoveEvent( evt );
+ aRemoveEvent.Element = evt.ReplacedElement;
+ aRemoveEvent.ReplacedElement = Any();
+ elementRemoved( aRemoveEvent );
+
+ // simulate an elementInserted
+ ContainerEvent aInsertEvent( evt );
+ aInsertEvent.ReplacedElement = Any();
+ elementInserted( aInsertEvent );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::elementRemoved(const ContainerEvent& evt) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ Reference< XControl > xControl;
+ evt.Element >>= xControl;
+ if (!xControl.is())
+ return;
+
+ Reference< XFormComponent > xModel(xControl->getModel(), UNO_QUERY);
+ if (xModel.is() && m_xModelAsIndex == xModel->getParent())
+ {
+ removeControl(xControl);
+ // TabOrder nicht neu berechnen, da das intern schon funktionieren muß!
+ }
+ // are we in filtermode and a XModeSelector has inserted an element
+ else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is())
+ {
+ FilterComponents::iterator componentPos = ::std::find(
+ m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl );
+ if ( componentPos != m_aFilterComponents.end() )
+ m_aFilterComponents.erase( componentPos );
+ }
+}
+
+//------------------------------------------------------------------------------
+Reference< XControl > FormController::isInList(const Reference< XWindowPeer > & xPeer) const
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ const Reference< XControl >* pControls = m_aControls.getConstArray();
+
+ sal_uInt32 nCtrls = m_aControls.getLength();
+ for ( sal_uInt32 n = 0; n < nCtrls && xPeer.is(); ++n, ++pControls )
+ {
+ if ( pControls->is() )
+ {
+ Reference< XVclWindowPeer > xCtrlPeer( (*pControls)->getPeer(), UNO_QUERY);
+ if ( ( xCtrlPeer.get() == xPeer.get() ) || xCtrlPeer->isChild( xPeer ) )
+ return *pControls;
+ }
+ }
+ return Reference< XControl > ();
+}
+
+//------------------------------------------------------------------------------
+void FormController::activateFirst() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ DBG_ASSERT(m_xTabController.is(), "FormController::activateFirst : invalid aggregate !");
+ if (m_xTabController.is())
+ m_xTabController->activateFirst();
+}
+
+//------------------------------------------------------------------------------
+void FormController::activateLast() throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ DBG_ASSERT(m_xTabController.is(), "FormController::activateLast : invalid aggregate !");
+ if (m_xTabController.is())
+ m_xTabController->activateLast();
+}
+
+// XFormController
+//------------------------------------------------------------------------------
+Reference< XFormOperations > SAL_CALL FormController::getFormOperations() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ return m_xFormOperations;
+}
+
+//------------------------------------------------------------------------------
+Reference< XControl> SAL_CALL FormController::getCurrentControl(void) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ return m_xCurrentControl;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::addActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ m_aActivateListeners.addInterface(l);
+}
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::removeActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ m_aActivateListeners.removeInterface(l);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::addChildController( const Reference< XFormController >& _ChildController ) throw( RuntimeException, IllegalArgumentException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ if ( !_ChildController.is() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+ // TODO: (localized) error message
+
+ // the parent of our (to-be-)child must be our own model
+ Reference< XFormComponent > xFormOfChild( _ChildController->getModel(), UNO_QUERY );
+ if ( !xFormOfChild.is() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+ // TODO: (localized) error message
+
+ if ( xFormOfChild->getParent() != m_xModelAsIndex )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+ // TODO: (localized) error message
+
+ m_aChilds.push_back( _ChildController );
+ _ChildController->setParent( *this );
+
+ // search the position of the model within the form
+ sal_uInt32 nPos = m_xModelAsIndex->getCount();
+ Reference< XFormComponent > xTemp;
+ for( ; nPos; )
+ {
+ m_xModelAsIndex->getByIndex(--nPos) >>= xTemp;
+ if ( xFormOfChild == xTemp )
+ {
+ Reference< XInterface > xIfc( _ChildController, UNO_QUERY );
+ m_xModelAsManager->attach( nPos, xIfc, makeAny( _ChildController) );
+ break;
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+Reference< XFormControllerContext > SAL_CALL FormController::getContext() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ return m_xContext;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::setContext( const Reference< XFormControllerContext >& _context ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ m_xContext = _context;
+}
+
+//------------------------------------------------------------------------------
+Reference< XInteractionHandler > SAL_CALL FormController::getInteractionHandler() throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ return m_xInteractionHandler;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::setInteractionHandler( const Reference< XInteractionHandler >& _interactionHandler ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+ m_xInteractionHandler = _interactionHandler;
+}
+
+//------------------------------------------------------------------------------
+void FormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ // create the composer
+ Reference< XRowSet > xForm(m_xModelAsIndex, UNO_QUERY);
+ Reference< XConnection > xConnection(OStaticDataAccessTools().getRowSetConnection(xForm));
+ if (xForm.is())
+ {
+ try
+ {
+ Reference< XMultiServiceFactory > xFactory( xConnection, UNO_QUERY_THROW );
+ m_xComposer.set(
+ xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ),
+ UNO_QUERY_THROW );
+
+ Reference< XPropertySet > xSet( xForm, UNO_QUERY );
+ ::rtl::OUString sStatement = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_ACTIVECOMMAND ) );
+ ::rtl::OUString sFilter = ::comphelper::getString( xSet->getPropertyValue( FM_PROP_FILTER ) );
+ m_xComposer->setElementaryQuery( sStatement );
+ m_xComposer->setFilter( sFilter );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ if (m_xComposer.is())
+ {
+ Sequence < PropertyValue> aLevel;
+ Sequence< Sequence < PropertyValue > > aFilterRows = m_xComposer->getStructuredFilter();
+
+ // ok, we recieve the list of filters as sequence of fieldnames, value
+ // now we have to transform the fieldname into UI names, that could be a label of the field or
+ // a aliasname or the fieldname itself
+
+ // first adjust the field names if necessary
+ Reference< XNameAccess > xQueryColumns =
+ Reference< XColumnsSupplier >( m_xComposer, UNO_QUERY_THROW )->getColumns();
+
+ for (::std::vector<FmFieldInfo>::iterator iter = rFieldInfos.begin();
+ iter != rFieldInfos.end(); iter++)
+ {
+ if ( xQueryColumns->hasByName((*iter).aFieldName) )
+ {
+ if ( (xQueryColumns->getByName((*iter).aFieldName) >>= (*iter).xField) && (*iter).xField.is() )
+ (*iter).xField->getPropertyValue(FM_PROP_REALNAME) >>= (*iter).aFieldName;
+ }
+ }
+
+ Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData());
+ // now transfer the filters into Value/TextComponent pairs
+ ::comphelper::UStringMixEqual aCompare(xMetaData->storesMixedCaseQuotedIdentifiers());
+
+ // need to parse criteria localized
+ OStaticDataAccessTools aStaticTools;
+ Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats(xConnection, sal_True));
+ Reference< XNumberFormatter> xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY );
+ xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
+ Locale aAppLocale = Application::GetSettings().GetUILocale();
+ LocaleDataWrapper aLocaleWrapper( m_aContext.getLegacyServiceFactory(), aAppLocale );
+
+ // retrieving the filter
+ const Sequence < PropertyValue >* pRow = aFilterRows.getConstArray();
+ for (sal_Int32 i = 0, nLen = aFilterRows.getLength(); i < nLen; ++i)
+ {
+ FmFilterRow aRow;
+
+ // search a field for the given name
+ const PropertyValue* pRefValues = pRow[i].getConstArray();
+ for (sal_Int32 j = 0, nLen1 = pRow[i].getLength(); j < nLen1; j++)
+ {
+ // look for the text component
+ Reference< XPropertySet > xField;
+ try
+ {
+ Reference< XPropertySet > xSet;
+ ::rtl::OUString aRealName;
+
+ // first look with the given name
+ if (xQueryColumns->hasByName(pRefValues[j].Name))
+ {
+ xQueryColumns->getByName(pRefValues[j].Name) >>= xSet;
+
+ // get the RealName
+ xSet->getPropertyValue(::rtl::OUString::createFromAscii("RealName")) >>= aRealName;
+
+ // compare the condition field name and the RealName
+ if (aCompare(aRealName, pRefValues[j].Name))
+ xField = xSet;
+ }
+ if (!xField.is())
+ {
+ // no we have to check every column to find the realname
+ Reference< XIndexAccess > xColumnsByIndex(xQueryColumns, UNO_QUERY);
+ for (sal_Int32 n = 0, nCount = xColumnsByIndex->getCount(); n < nCount; n++)
+ {
+ xColumnsByIndex->getByIndex(n) >>= xSet;
+ xSet->getPropertyValue(::rtl::OUString::createFromAscii("RealName")) >>= aRealName;
+ if (aCompare(aRealName, pRefValues[j].Name))
+ {
+ // get the column by its alias
+ xField = xSet;
+ break;
+ }
+ }
+ }
+ if (!xField.is())
+ continue;
+ }
+ catch (const Exception&)
+ {
+ continue;
+ }
+
+ // find the text component
+ for (::std::vector<FmFieldInfo>::iterator iter = rFieldInfos.begin();
+ iter != rFieldInfos.end(); iter++)
+ {
+ // we found the field so insert a new entry to the filter row
+ if ((*iter).xField == xField)
+ {
+ // do we already have the control ?
+ if (aRow.find((*iter).xText) != aRow.end())
+ {
+ ::rtl::OUString aCompText = aRow[(*iter).xText];
+ aCompText += ::rtl::OUString::createFromAscii(" ");
+ ::rtl::OString aVal = m_xParser->getContext().getIntlKeywordAscii(OParseContext::KEY_AND);
+ aCompText += ::rtl::OUString(aVal.getStr(),aVal.getLength(),RTL_TEXTENCODING_ASCII_US);
+ aCompText += ::rtl::OUString::createFromAscii(" ");
+ aCompText += ::comphelper::getString(pRefValues[j].Value);
+ aRow[(*iter).xText] = aCompText;
+ }
+ else
+ {
+ ::rtl::OUString sPredicate,sErrorMsg;
+ pRefValues[j].Value >>= sPredicate;
+ ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree(sErrorMsg, sPredicate, xFormatter, xField);
+ if ( xParseNode.is() )
+ {
+ ::rtl::OUString sCriteria;
+ xParseNode->parseNodeToPredicateStr( sCriteria
+ ,xConnection
+ ,xFormatter
+ ,xField
+ ,aAppLocale
+ ,(sal_Char)aLocaleWrapper.getNumDecimalSep().GetChar(0)
+ ,getParseContext());
+ aRow[(*iter).xText] = sCriteria;
+ }
+ }
+ }
+ }
+ }
+
+ if (aRow.empty())
+ continue;
+
+ impl_addFilterRow( aRow );
+ }
+ }
+
+ // now set the filter controls
+ for ( ::std::vector<FmFieldInfo>::iterator field = rFieldInfos.begin();
+ field != rFieldInfos.end();
+ ++field
+ )
+ {
+ m_aFilterComponents.push_back( field->xText );
+ }
+}
+
+//------------------------------------------------------------------------------
+void FormController::startFiltering()
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+
+ OStaticDataAccessTools aStaticTools;
+ Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( Reference< XRowSet >( m_xModelAsIndex, UNO_QUERY ) ) );
+ if ( !xConnection.is() )
+ // nothing to do - can't filter a form which is not connected
+ // 98023 - 19.03.2002 - fs@openoffice.org
+ return;
+
+ // stop listening for controls
+ if (isListeningForChanges())
+ stopListening();
+
+ m_bFiltering = sal_True;
+
+ // as we don't want new controls to be attached to the scripting environment
+ // we change attach flags
+ m_bAttachEvents = sal_False;
+
+ // Austauschen der Kontrols fuer das aktuelle Formular
+ Sequence< Reference< XControl > > aControlsCopy( m_aControls );
+ const Reference< XControl >* pControls = aControlsCopy.getConstArray();
+ sal_Int32 nControlCount = aControlsCopy.getLength();
+
+ // the control we have to activate after replacement
+ Reference< XDatabaseMetaData > xMetaData(xConnection->getMetaData());
+ Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, sal_True);
+ Reference< XNumberFormatter > xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY );
+ xFormatter->attachNumberFormatsSupplier(xFormatSupplier);
+
+ // structure for storing the field info
+ ::std::vector<FmFieldInfo> aFieldInfos;
+
+ for (sal_Int32 i = nControlCount; i > 0;)
+ {
+ Reference< XControl > xControl = pControls[--i];
+ if (xControl.is())
+ {
+ // no events for the control anymore
+ removeFromEventAttacher(xControl);
+
+ // do we have a mode selector
+ Reference< XModeSelector > xSelector(xControl, UNO_QUERY);
+ if (xSelector.is())
+ {
+ xSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) );
+
+ // listening for new controls of the selector
+ Reference< XContainer > xContainer(xSelector, UNO_QUERY);
+ if (xContainer.is())
+ xContainer->addContainerListener(this);
+
+ Reference< XEnumerationAccess > xElementAccess(xSelector, UNO_QUERY);
+ if (xElementAccess.is())
+ {
+ Reference< XEnumeration > xEnumeration(xElementAccess->createEnumeration());
+ Reference< XControl > xSubControl;
+ while (xEnumeration->hasMoreElements())
+ {
+ xEnumeration->nextElement() >>= xSubControl;
+ if (xSubControl.is())
+ {
+ Reference< XPropertySet > xSet(xSubControl->getModel(), UNO_QUERY);
+ if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
+ {
+ // does the model use a bound field ?
+ Reference< XPropertySet > xField;
+ xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
+
+ Reference< XTextComponent > xText(xSubControl, UNO_QUERY);
+ // may we filter the field?
+ if (xText.is() && xField.is() && ::comphelper::hasProperty(FM_PROP_SEARCHABLE, xField) &&
+ ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_SEARCHABLE)))
+ {
+ aFieldInfos.push_back(FmFieldInfo(xField, xText));
+ xText->addTextListener(this);
+ }
+ }
+ }
+ }
+ }
+ continue;
+ }
+
+ Reference< XPropertySet > xModel( xControl->getModel(), UNO_QUERY );
+ if (xModel.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xModel))
+ {
+ // does the model use a bound field ?
+ Any aVal = xModel->getPropertyValue(FM_PROP_BOUNDFIELD);
+ Reference< XPropertySet > xField;
+ aVal >>= xField;
+
+ // may we filter the field?
+
+ if ( xField.is()
+ && ::comphelper::hasProperty( FM_PROP_SEARCHABLE, xField )
+ && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_SEARCHABLE ) )
+ )
+ {
+ // create a filter control
+ Sequence< Any > aCreationArgs( 3 );
+ aCreationArgs[ 0 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "MessageParent" ), makeAny( VCLUnoHelper::GetInterface( getDialogParentWindow() ) ) );
+ aCreationArgs[ 1 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "NumberFormatter" ), makeAny( xFormatter ) );
+ aCreationArgs[ 2 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "ControlModel" ), makeAny( xModel ) );
+ Reference< XControl > xFilterControl(
+ m_aContext.createComponentWithArguments( "com.sun.star.form.control.FilterControl", aCreationArgs ),
+ UNO_QUERY
+ );
+ DBG_ASSERT( xFilterControl.is(), "FormController::startFiltering: could not create a filter control!" );
+
+ if ( replaceControl( xControl, xFilterControl ) )
+ {
+ Reference< XTextComponent > xFilterText( xFilterControl, UNO_QUERY );
+ aFieldInfos.push_back( FmFieldInfo( xField, xFilterText ) );
+ xFilterText->addTextListener(this);
+ }
+ }
+ }
+ else
+ {
+ // abmelden vom EventManager
+ }
+ }
+ }
+
+ // we have all filter controls now, so the next step is to read the filters from the form
+ // resolve all aliases and set the current filter to the according structure
+ setFilter(aFieldInfos);
+
+ Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY );
+ if ( xSet.is() )
+ stopFormListening( xSet, sal_True );
+
+ impl_setTextOnAllFilter_throw();
+
+ // lock all controls which are not used for filtering
+ m_bLocked = determineLockState();
+ setLocks();
+ m_bAttachEvents = sal_True;
+}
+
+//------------------------------------------------------------------------------
+void FormController::stopFiltering()
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ if ( !m_bFiltering ) // #104693# OJ
+ { // nothing to do
+ return;
+ }
+
+ m_bFiltering = sal_False;
+ m_bDetachEvents = sal_False;
+
+ ::comphelper::disposeComponent(m_xComposer);
+
+ // Austauschen der Kontrols fuer das aktuelle Formular
+ Sequence< Reference< XControl > > aControlsCopy( m_aControls );
+ const Reference< XControl > * pControls = aControlsCopy.getConstArray();
+ sal_Int32 nControlCount = aControlsCopy.getLength();
+
+ // clear the filter control map
+ ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) );
+ m_aFilterComponents.clear();
+
+ for ( sal_Int32 i = nControlCount; i > 0; )
+ {
+ Reference< XControl > xControl = pControls[--i];
+ if (xControl.is())
+ {
+ // now enable eventhandling again
+ addToEventAttacher(xControl);
+
+ Reference< XModeSelector > xSelector(xControl, UNO_QUERY);
+ if (xSelector.is())
+ {
+ xSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) );
+
+ // listening for new controls of the selector
+ Reference< XContainer > xContainer(xSelector, UNO_QUERY);
+ if (xContainer.is())
+ xContainer->removeContainerListener(this);
+ continue;
+ }
+
+ Reference< XPropertySet > xSet(xControl->getModel(), UNO_QUERY);
+ if (xSet.is() && ::comphelper::hasProperty(FM_PROP_BOUNDFIELD, xSet))
+ {
+ // does the model use a bound field ?
+ Reference< XPropertySet > xField;
+ xSet->getPropertyValue(FM_PROP_BOUNDFIELD) >>= xField;
+
+ // may we filter the field?
+ if ( xField.is()
+ && ::comphelper::hasProperty( FM_PROP_SEARCHABLE, xField )
+ && ::comphelper::getBOOL( xField->getPropertyValue( FM_PROP_SEARCHABLE ) )
+ )
+ {
+ ::rtl::OUString sServiceName;
+ OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName );
+ Reference< XControl > xNewControl( m_aContext.createComponent( sServiceName ), UNO_QUERY );
+ replaceControl( xControl, xNewControl );
+ }
+ }
+ }
+ }
+
+ Reference< XPropertySet > xSet( m_xModelAsIndex, UNO_QUERY );
+ if ( xSet.is() )
+ startFormListening( xSet, sal_True );
+
+ m_bDetachEvents = sal_True;
+
+ m_aFilterRows.clear();
+ m_nCurrentFilterPosition = -1;
+
+ // release the locks if possible
+ // lock all controls which are not used for filtering
+ m_bLocked = determineLockState();
+ setLocks();
+
+ // restart listening for control modifications
+ if (isListeningForChanges())
+ startListening();
+}
+
+// XModeSelector
+//------------------------------------------------------------------------------
+void FormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ if (!supportsMode(Mode))
+ throw NoSupportException();
+
+ if (Mode == m_aMode)
+ return;
+
+ m_aMode = Mode;
+
+ if ( Mode.equalsAscii( "FilterMode" ) )
+ startFiltering();
+ else
+ stopFiltering();
+
+ for (FmFormControllers::const_iterator i = m_aChilds.begin();
+ i != m_aChilds.end(); ++i)
+ {
+ Reference< XModeSelector > xMode(*i, UNO_QUERY);
+ if ( xMode.is() )
+ xMode->setMode(Mode);
+ }
+}
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL FormController::getMode(void) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ return m_aMode;
+}
+
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedModes(void) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ static Sequence< ::rtl::OUString > aModes;
+ if (!aModes.getLength())
+ {
+ aModes.realloc(2);
+ ::rtl::OUString* pModes = aModes.getArray();
+ pModes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) );
+ pModes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) );
+ }
+ return aModes;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FormController::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ Sequence< ::rtl::OUString > aModes(getSupportedModes());
+ const ::rtl::OUString* pModes = aModes.getConstArray();
+ for (sal_Int32 i = aModes.getLength(); i > 0; )
+ {
+ if (pModes[--i] == Mode)
+ return sal_True;
+ }
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+Window* FormController::getDialogParentWindow()
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ Window* pParentWindow = NULL;
+ try
+ {
+ Reference< XControl > xContainerControl( getContainer(), UNO_QUERY_THROW );
+ Reference< XWindowPeer > xContainerPeer( xContainerControl->getPeer(), UNO_QUERY_THROW );
+ pParentWindow = VCLUnoHelper::GetWindow( xContainerPeer );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return pParentWindow;
+}
+//------------------------------------------------------------------------------
+bool FormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, Reference< XControlModel >& /* [out] */ _rxFirstInvalidModel ) SAL_THROW(())
+{
+ try
+ {
+ Reference< XEnumerationAccess > xControlEnumAcc( getModel(), UNO_QUERY );
+ Reference< XEnumeration > xControlEnumeration;
+ if ( xControlEnumAcc.is() )
+ xControlEnumeration = xControlEnumAcc->createEnumeration();
+ OSL_ENSURE( xControlEnumeration.is(), "FormController::checkFormComponentValidity: cannot enumerate the controls!" );
+ if ( !xControlEnumeration.is() )
+ // assume all valid
+ return true;
+
+ Reference< XValidatableFormComponent > xValidatable;
+ while ( xControlEnumeration->hasMoreElements() )
+ {
+ if ( !( xControlEnumeration->nextElement() >>= xValidatable ) )
+ // control does not support validation
+ continue;
+
+ if ( xValidatable->isValid() )
+ continue;
+
+ Reference< XValidator > xValidator( xValidatable->getValidator() );
+ OSL_ENSURE( xValidator.is(), "FormController::checkFormComponentValidity: invalid, but no validator?" );
+ if ( !xValidator.is() )
+ // this violates the interface definition of css.form.validation.XValidatableFormComponent ...
+ continue;
+
+ _rFirstInvalidityExplanation = xValidator->explainInvalid( xValidatable->getCurrentValue() );
+ _rxFirstInvalidModel = _rxFirstInvalidModel.query( xValidatable );
+ return false;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------------
+Reference< XControl > FormController::locateControl( const Reference< XControlModel >& _rxModel ) SAL_THROW(())
+{
+ try
+ {
+ Sequence< Reference< XControl > > aControls( getControls() );
+ const Reference< XControl >* pControls = aControls.getConstArray();
+ const Reference< XControl >* pControlsEnd = aControls.getConstArray() + aControls.getLength();
+
+ for ( ; pControls != pControlsEnd; ++pControls )
+ {
+ OSL_ENSURE( pControls->is(), "FormController::locateControl: NULL-control?" );
+ if ( pControls->is() )
+ {
+ if ( ( *pControls)->getModel() == _rxModel )
+ return *pControls;
+ }
+ }
+ OSL_ENSURE( sal_False, "FormController::locateControl: did not find a control for this model!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return NULL;
+}
+
+//------------------------------------------------------------------------------
+namespace
+{
+ void displayErrorSetFocus( const String& _rMessage, const Reference< XControl >& _rxFocusControl, Window* _pDialogParent )
+ {
+ SQLContext aError;
+ aError.Message = String( SVX_RES( RID_STR_WRITEERROR ) );
+ aError.Details = _rMessage;
+ displayException( aError, _pDialogParent );
+
+ if ( _rxFocusControl.is() )
+ {
+ Reference< XWindow > xControlWindow( _rxFocusControl, UNO_QUERY );
+ OSL_ENSURE( xControlWindow.is(), "displayErrorSetFocus: invalid control!" );
+ if ( xControlWindow.is() )
+ xControlWindow->setFocus();
+ }
+ }
+
+ sal_Bool lcl_shouldValidateRequiredFields_nothrow( const Reference< XInterface >& _rxForm )
+ {
+ try
+ {
+ static ::rtl::OUString s_sFormsCheckRequiredFields( RTL_CONSTASCII_USTRINGPARAM( "FormsCheckRequiredFields" ) );
+
+ // first, check whether the form has a property telling us the answer
+ // this allows people to use the XPropertyContainer interface of a form to control
+ // the behaviour on a per-form basis.
+ Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xPSI( xFormProps->getPropertySetInfo() );
+ if ( xPSI->hasPropertyByName( s_sFormsCheckRequiredFields ) )
+ {
+ sal_Bool bShouldValidate = true;
+ OSL_VERIFY( xFormProps->getPropertyValue( s_sFormsCheckRequiredFields ) >>= bShouldValidate );
+ return bShouldValidate;
+ }
+
+ // next, check the data source which created the connection
+ Reference< XChild > xConnectionAsChild( xFormProps->getPropertyValue( FM_PROP_ACTIVE_CONNECTION ), UNO_QUERY_THROW );
+ Reference< XPropertySet > xDataSource( xConnectionAsChild->getParent(), UNO_QUERY );
+ if ( !xDataSource.is() )
+ // seldom (but possible): this is not a connection created by a data source
+ return sal_True;
+
+ Reference< XPropertySet > xDataSourceSettings(
+ xDataSource->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Settings" ) ) ),
+ UNO_QUERY_THROW );
+
+ sal_Bool bShouldValidate = true;
+ OSL_VERIFY( xDataSourceSettings->getPropertyValue( s_sFormsCheckRequiredFields ) >>= bShouldValidate );
+ return bShouldValidate;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sal_True;
+ }
+}
+
+// XRowSetApproveListener
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FormController::approveRowChange(const RowChangeEvent& _rEvent) throw( RuntimeException )
+{
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
+ sal_Bool bValid = sal_True;
+ if (aIter.hasMoreElements())
+ {
+ RowChangeEvent aEvt( _rEvent );
+ aEvt.Source = *this;
+ bValid = ((XRowSetApproveListener*)aIter.next())->approveRowChange(aEvt);
+ }
+
+ if ( !bValid )
+ return bValid;
+
+ if ( ( _rEvent.Action != RowChangeAction::INSERT )
+ && ( _rEvent.Action != RowChangeAction::UPDATE )
+ )
+ return bValid;
+
+ // if some of the control models are bound to validators, check them
+ ::rtl::OUString sInvalidityExplanation;
+ Reference< XControlModel > xInvalidModel;
+ if ( !checkFormComponentValidity( sInvalidityExplanation, xInvalidModel ) )
+ {
+ Reference< XControl > xControl( locateControl( xInvalidModel ) );
+ aGuard.clear();
+ displayErrorSetFocus( sInvalidityExplanation, xControl, getDialogParentWindow() );
+ return false;
+ }
+
+ // check values on NULL and required flag
+ if ( !lcl_shouldValidateRequiredFields_nothrow( _rEvent.Source ) )
+ return sal_True;
+
+ OSL_ENSURE( m_pColumnInfoCache.get(), "FormController::approveRowChange: no column infos!" );
+ if ( !m_pColumnInfoCache.get() )
+ return sal_True;
+
+ try
+ {
+ if ( !m_pColumnInfoCache->controlsInitialized() )
+ m_pColumnInfoCache->initializeControls( getControls() );
+
+ size_t colCount = m_pColumnInfoCache->getColumnCount();
+ for ( size_t col = 0; col < colCount; ++col )
+ {
+ const ColumnInfo& rColInfo = m_pColumnInfoCache->getColumnInfo( col );
+ if ( rColInfo.nNullable != ColumnValue::NO_NULLS )
+ continue;
+
+ if ( rColInfo.bAutoIncrement )
+ continue;
+
+ if ( rColInfo.bReadOnly )
+ continue;
+
+ if ( !rColInfo.xFirstControlWithInputRequired.is() && !rColInfo.xFirstGridWithInputRequiredColumn.is() )
+ continue;
+
+ // TODO: in case of binary fields, this "getString" below is extremely expensive
+ if ( rColInfo.xColumn->getString().getLength() || !rColInfo.xColumn->wasNull() )
+ continue;
+
+ String sMessage( SVX_RES( RID_ERR_FIELDREQUIRED ) );
+ sMessage.SearchAndReplace( '#', rColInfo.sName );
+
+ // the control to focus
+ Reference< XControl > xControl( rColInfo.xFirstControlWithInputRequired );
+ if ( !xControl.is() )
+ xControl.set( rColInfo.xFirstGridWithInputRequiredColumn, UNO_QUERY );
+
+ aGuard.clear();
+ displayErrorSetFocus( sMessage, rColInfo.xFirstControlWithInputRequired, getDialogParentWindow() );
+ return sal_False;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return true;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FormController::approveCursorMove(const EventObject& event) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
+ if (aIter.hasMoreElements())
+ {
+ EventObject aEvt(event);
+ aEvt.Source = *this;
+ return ((XRowSetApproveListener*)aIter.next())->approveCursorMove(aEvt);
+ }
+
+ return sal_True;
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FormController::approveRowSetChange(const EventObject& event) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners);
+ if (aIter.hasMoreElements())
+ {
+ EventObject aEvt(event);
+ aEvt.Source = *this;
+ return ((XRowSetApproveListener*)aIter.next())->approveRowSetChange(aEvt);
+ }
+
+ return sal_True;
+}
+
+// XRowSetApproveBroadcaster
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::addRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ m_aRowSetApproveListeners.addInterface(_rxListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::removeRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ m_aRowSetApproveListeners.removeInterface(_rxListener);
+}
+
+// XErrorListener
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::errorOccured(const SQLErrorEvent& aEvent) throw( RuntimeException )
+{
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ ::cppu::OInterfaceIteratorHelper aIter(m_aErrorListeners);
+ if (aIter.hasMoreElements())
+ {
+ SQLErrorEvent aEvt(aEvent);
+ aEvt.Source = *this;
+ ((XSQLErrorListener*)aIter.next())->errorOccured(aEvt);
+ }
+ else
+ {
+ aGuard.clear();
+ displayException( aEvent );
+ }
+}
+
+// XErrorBroadcaster
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::addSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ m_aErrorListeners.addInterface(aListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::removeSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ m_aErrorListeners.removeInterface(aListener);
+}
+
+// XDatabaseParameterBroadcaster2
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::addDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ m_aParameterListeners.addInterface(aListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::removeDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ m_aParameterListeners.removeInterface(aListener);
+}
+
+// XDatabaseParameterBroadcaster
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::addParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException )
+{
+ FormController::addDatabaseParameterListener( aListener );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::removeParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException )
+{
+ FormController::removeDatabaseParameterListener( aListener );
+}
+
+// XDatabaseParameterListener
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException )
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ ::cppu::OInterfaceIteratorHelper aIter(m_aParameterListeners);
+ if (aIter.hasMoreElements())
+ {
+ DatabaseParameterEvent aEvt(aEvent);
+ aEvt.Source = *this;
+ return ((XDatabaseParameterListener*)aIter.next())->approveParameter(aEvt);
+ }
+ else
+ {
+ // default handling: instantiate an interaction handler and let it handle the parameter request
+ try
+ {
+ if ( !ensureInteractionHandler() )
+ return sal_False;
+
+ // two continuations allowed: OK and Cancel
+ OParameterContinuation* pParamValues = new OParameterContinuation;
+ OInteractionAbort* pAbort = new OInteractionAbort;
+ // the request
+ ParametersRequest aRequest;
+ aRequest.Parameters = aEvent.Parameters;
+ aRequest.Connection = OStaticDataAccessTools().getRowSetConnection(Reference< XRowSet >(aEvent.Source, UNO_QUERY));
+ OInteractionRequest* pParamRequest = new OInteractionRequest(makeAny(aRequest));
+ Reference< XInteractionRequest > xParamRequest(pParamRequest);
+ // some knittings
+ pParamRequest->addContinuation(pParamValues);
+ pParamRequest->addContinuation(pAbort);
+
+ // handle the request
+ m_xInteractionHandler->handle(xParamRequest);
+
+ if (!pParamValues->wasSelected())
+ // canceled
+ return sal_False;
+
+ // transfer the values into the parameter supplier
+ Sequence< PropertyValue > aFinalValues = pParamValues->getValues();
+ if (aFinalValues.getLength() != aRequest.Parameters->getCount())
+ {
+ DBG_ERROR("FormController::approveParameter: the InteractionHandler returned nonsense!");
+ return sal_False;
+ }
+ const PropertyValue* pFinalValues = aFinalValues.getConstArray();
+ for (sal_Int32 i=0; i<aFinalValues.getLength(); ++i, ++pFinalValues)
+ {
+ Reference< XPropertySet > xParam;
+ ::cppu::extractInterface(xParam, aRequest.Parameters->getByIndex(i));
+ if (xParam.is())
+ {
+#ifdef DBG_UTIL
+ ::rtl::OUString sName;
+ xParam->getPropertyValue(FM_PROP_NAME) >>= sName;
+ DBG_ASSERT(sName.equals(pFinalValues->Name), "FormController::approveParameter: suspicious value names!");
+#endif
+ try { xParam->setPropertyValue(FM_PROP_VALUE, pFinalValues->Value); }
+ catch(Exception&)
+ {
+ DBG_ERROR("FormController::approveParameter: setting one of the properties failed!");
+ }
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return sal_True;
+}
+
+// XConfirmDeleteBroadcaster
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::addConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ m_aDeleteListeners.addInterface(aListener);
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::removeConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ m_aDeleteListeners.removeInterface(aListener);
+}
+
+// XConfirmDeleteListener
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent) throw( RuntimeException )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ impl_checkDisposed_throw();
+
+ ::cppu::OInterfaceIteratorHelper aIter(m_aDeleteListeners);
+ if (aIter.hasMoreElements())
+ {
+ RowChangeEvent aEvt(aEvent);
+ aEvt.Source = *this;
+ return ((XConfirmDeleteListener*)aIter.next())->confirmDelete(aEvt);
+ }
+ // default handling: instantiate an interaction handler and let it handle the request
+
+ String sTitle;
+ sal_Int32 nLength = aEvent.Rows;
+ if ( nLength > 1 )
+ {
+ sTitle = SVX_RES( RID_STR_DELETECONFIRM_RECORDS );
+ sTitle.SearchAndReplace( '#', String::CreateFromInt32( nLength ) );
+ }
+ else
+ sTitle = SVX_RES( RID_STR_DELETECONFIRM_RECORD );
+
+ try
+ {
+ if ( !ensureInteractionHandler() )
+ return sal_False;
+
+ // two continuations allowed: Yes and No
+ OInteractionApprove* pApprove = new OInteractionApprove;
+ OInteractionDisapprove* pDisapprove = new OInteractionDisapprove;
+
+ // the request
+ SQLWarning aWarning;
+ aWarning.Message = sTitle;
+ SQLWarning aDetails;
+ aDetails.Message = String( SVX_RES( RID_STR_DELETECONFIRM ) );
+ aWarning.NextException <<= aDetails;
+
+ OInteractionRequest* pRequest = new OInteractionRequest( makeAny( aWarning ) );
+ Reference< XInteractionRequest > xRequest( pRequest );
+
+ // some knittings
+ pRequest->addContinuation( pApprove );
+ pRequest->addContinuation( pDisapprove );
+
+ // handle the request
+ m_xInteractionHandler->handle( xRequest );
+
+ if ( pApprove->wasSelected() )
+ return sal_True;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::invalidateFeatures( const Sequence< ::sal_Int16 >& _Features ) throw (RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ // for now, just copy the ids of the features, because ....
+ ::std::copy( _Features.getConstArray(), _Features.getConstArray() + _Features.getLength(),
+ ::std::insert_iterator< ::std::set< sal_Int16 > >( m_aInvalidFeatures, m_aInvalidFeatures.begin() )
+ );
+
+ // ... we will do the real invalidation asynchronously
+ if ( !m_aFeatureInvalidationTimer.IsActive() )
+ m_aFeatureInvalidationTimer.Start();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::invalidateAllFeatures( ) throw (RuntimeException)
+{
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ Sequence< sal_Int16 > aInterceptedFeatures( m_aFeatureDispatchers.size() );
+ ::std::transform(
+ m_aFeatureDispatchers.begin(),
+ m_aFeatureDispatchers.end(),
+ aInterceptedFeatures.getArray(),
+ ::std::select1st< DispatcherContainer::value_type >()
+ );
+
+ aGuard.clear();
+ if ( aInterceptedFeatures.getLength() )
+ invalidateFeatures( aInterceptedFeatures );
+}
+
+//------------------------------------------------------------------------------
+Reference< XDispatch >
+FormController::interceptedQueryDispatch( const URL& aURL,
+ const ::rtl::OUString& /*aTargetFrameName*/, sal_Int32 /*nSearchFlags*/)
+ throw( RuntimeException )
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ Reference< XDispatch > xReturn;
+ // dispatches handled by ourself
+ if ( ( aURL.Complete == FMURL_CONFIRM_DELETION )
+ || ( ( aURL.Complete.equalsAscii( "private:/InteractionHandler" ) )
+ && ensureInteractionHandler()
+ )
+ )
+ xReturn = static_cast< XDispatch* >( this );
+
+ // dispatches of FormSlot-URLs we have to translate
+ if ( !xReturn.is() && m_xFormOperations.is() )
+ {
+ // find the slot id which corresponds to the URL
+ sal_Int32 nFeatureSlotId = ::svx::FeatureSlotTranslation::getControllerFeatureSlotIdForURL( aURL.Main );
+ sal_Int16 nFormFeature = ( nFeatureSlotId != -1 ) ? ::svx::FeatureSlotTranslation::getFormFeatureForSlotId( nFeatureSlotId ) : -1;
+ if ( nFormFeature > 0 )
+ {
+ // get the dispatcher for this feature, create if necessary
+ DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( nFormFeature );
+ if ( aDispatcherPos == m_aFeatureDispatchers.end() )
+ {
+ aDispatcherPos = m_aFeatureDispatchers.insert(
+ DispatcherContainer::value_type( nFormFeature, new ::svx::OSingleFeatureDispatcher( aURL, nFormFeature, m_xFormOperations, m_aMutex ) )
+ ).first;
+ }
+
+ OSL_ENSURE( aDispatcherPos->second.is(), "FormController::interceptedQueryDispatch: should have a dispatcher by now!" );
+ return aDispatcherPos->second;
+ }
+ }
+
+ // no more to offer
+ return xReturn;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArgs ) throw (RuntimeException)
+{
+ if ( _rArgs.getLength() != 1 )
+ {
+ DBG_ERROR( "FormController::dispatch: no arguments -> no dispatch!" );
+ return;
+ }
+
+ if ( _rURL.Complete.equalsAscii( "private:/InteractionHandler" ) )
+ {
+ Reference< XInteractionRequest > xRequest;
+ OSL_VERIFY( _rArgs[0].Value >>= xRequest );
+ if ( xRequest.is() )
+ handle( xRequest );
+ return;
+ }
+
+ if ( _rURL.Complete == FMURL_CONFIRM_DELETION )
+ {
+ DBG_ERROR( "FormController::dispatch: How do you expect me to return something via this call?" );
+ // confirmDelete has a return value - dispatch hasn't
+ return;
+ }
+
+ DBG_ERROR( "FormController::dispatch: unknown URL!" );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::addStatusListener( const Reference< XStatusListener >& _rxListener, const URL& _rURL ) throw (RuntimeException)
+{
+ if (_rURL.Complete == FMURL_CONFIRM_DELETION)
+ {
+ if (_rxListener.is())
+ { // send an initial statusChanged event
+ FeatureStateEvent aEvent;
+ aEvent.FeatureURL = _rURL;
+ aEvent.IsEnabled = sal_True;
+ _rxListener->statusChanged(aEvent);
+ // and don't add the listener at all (the status will never change)
+ }
+ }
+ else
+ OSL_ENSURE(sal_False, "FormController::addStatusListener: invalid (unsupported) URL!");
+}
+
+//------------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL FormController::getParent() throw( RuntimeException )
+{
+ return m_xParent;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::setParent( const Reference< XInterface >& Parent) throw( NoSupportException, RuntimeException )
+{
+ m_xParent = Parent;
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::removeStatusListener( const Reference< XStatusListener >& /*_rxListener*/, const URL& _rURL ) throw (RuntimeException)
+{
+ (void)_rURL;
+ OSL_ENSURE(_rURL.Complete == FMURL_CONFIRM_DELETION, "FormController::removeStatusListener: invalid (unsupported) URL!");
+ // we never really added the listener, so we don't need to remove it
+}
+
+//------------------------------------------------------------------------------
+Reference< XDispatchProviderInterceptor > FormController::createInterceptor(const Reference< XDispatchProviderInterception > & _xInterception)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+#ifdef DBG_UTIL
+ // check if we already have a interceptor for the given object
+ for ( ConstInterceptorsIterator aIter = m_aControlDispatchInterceptors.begin();
+ aIter != m_aControlDispatchInterceptors.end();
+ ++aIter
+ )
+ {
+ if ((*aIter)->getIntercepted() == _xInterception)
+ DBG_ERROR("FormController::createInterceptor : we already do intercept this objects dispatches !");
+ }
+#endif
+
+ DispatchInterceptionMultiplexer* pInterceptor = new DispatchInterceptionMultiplexer( _xInterception, this );
+ pInterceptor->acquire();
+ m_aControlDispatchInterceptors.insert( m_aControlDispatchInterceptors.end(), pInterceptor );
+
+ return pInterceptor;
+}
+
+//------------------------------------------------------------------------------
+bool FormController::ensureInteractionHandler()
+{
+ if ( m_xInteractionHandler.is() )
+ return true;
+ if ( m_bAttemptedHandlerCreation )
+ return false;
+ m_bAttemptedHandlerCreation = true;
+
+ m_xInteractionHandler.set( m_aContext.createComponent( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.task.InteractionHandler" ) ) ), UNO_QUERY );
+ OSL_ENSURE( m_xInteractionHandler.is(), "FormController::ensureInteractionHandler: could not create an interaction handler!" );
+ return m_xInteractionHandler.is();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL FormController::handle( const Reference< XInteractionRequest >& _rRequest ) throw (RuntimeException)
+{
+ if ( !ensureInteractionHandler() )
+ return;
+ m_xInteractionHandler->handle( _rRequest );
+}
+
+//------------------------------------------------------------------------------
+void FormController::deleteInterceptor(const Reference< XDispatchProviderInterception > & _xInterception)
+{
+ OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" );
+ // search the interceptor responsible for the given object
+ InterceptorsIterator aIter;
+ for ( aIter = m_aControlDispatchInterceptors.begin();
+ aIter != m_aControlDispatchInterceptors.end();
+ ++aIter
+ )
+ {
+ if ((*aIter)->getIntercepted() == _xInterception)
+ break;
+ }
+ if (aIter == m_aControlDispatchInterceptors.end())
+ {
+ return;
+ }
+
+ // log off the interception from it's interception object
+ DispatchInterceptionMultiplexer* pInterceptorImpl = *aIter;
+ pInterceptorImpl->dispose();
+ pInterceptorImpl->release();
+
+ // remove the interceptor from our array
+ m_aControlDispatchInterceptors.erase(aIter);
+}
+
+//--------------------------------------------------------------------
+void FormController::implInvalidateCurrentControlDependentFeatures()
+{
+ Sequence< sal_Int16 > aCurrentControlDependentFeatures(4);
+
+ aCurrentControlDependentFeatures[0] = FormFeature::SortAscending;
+ aCurrentControlDependentFeatures[1] = FormFeature::SortDescending;
+ aCurrentControlDependentFeatures[2] = FormFeature::AutoFilter;
+ aCurrentControlDependentFeatures[3] = FormFeature::RefreshCurrentControl;
+
+ invalidateFeatures( aCurrentControlDependentFeatures );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL FormController::columnChanged( const EventObject& /*_event*/ ) throw (RuntimeException)
+{
+ implInvalidateCurrentControlDependentFeatures();
+}
+
+} // namespace svxform
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx
new file mode 100644
index 000000000000..a1d8c987451b
--- /dev/null
+++ b/svx/source/form/formcontrolling.cxx
@@ -0,0 +1,608 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+#include "formcontrolling.hxx"
+#include "fmurl.hxx"
+#include "svx/svxids.hrc"
+#include "fmprop.hrc"
+#include "svx/fmtools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/runtime/FormOperations.hpp>
+#include <com/sun/star/form/runtime/FormFeature.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+#include <comphelper/anytostring.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <osl/diagnose.h>
+
+#include <functional>
+#include <algorithm>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::form::runtime::XFormController;
+ using ::com::sun::star::form::XForm;
+ using ::com::sun::star::form::runtime::FormOperations;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::sdbc::XRowSet;
+ using ::com::sun::star::form::runtime::FeatureState;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::beans::NamedValue;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::sdb::XSQLErrorBroadcaster;
+ using ::com::sun::star::sdb::SQLErrorEvent;
+ using ::com::sun::star::lang::EventObject;
+ /** === end UNO using === **/
+ namespace FormFeature = ::com::sun::star::form::runtime::FormFeature;
+
+ //====================================================================
+ //= FeatureSlotTranslation
+ //====================================================================
+ namespace
+ {
+ struct FeatureDescription
+ {
+ ::rtl::OUString sURL; // the URL
+ sal_Int32 nSlotId; // the SFX-compatible slot ID
+ sal_Int16 nFormFeature; // the css.form.runtime.FormFeature ID
+ };
+ typedef ::std::vector< FeatureDescription > FeatureDescriptions;
+
+ //................................................................
+ const FeatureDescriptions& getFeatureDescriptions()
+ {
+ static FeatureDescriptions s_aFeatureDescriptions;
+ if ( s_aFeatureDescriptions.empty() )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( s_aFeatureDescriptions.empty() )
+ {
+ FeatureDescription aDescriptions[] = {
+ { FMURL_FORM_POSITION, SID_FM_RECORD_ABSOLUTE, FormFeature::MoveAbsolute },
+ { FMURL_FORM_RECORDCOUNT, SID_FM_RECORD_TOTAL, FormFeature::TotalRecords },
+ { FMURL_RECORD_MOVEFIRST, SID_FM_RECORD_FIRST, FormFeature::MoveToFirst },
+ { FMURL_RECORD_MOVEPREV, SID_FM_RECORD_PREV, FormFeature::MoveToPrevious },
+ { FMURL_RECORD_MOVENEXT, SID_FM_RECORD_NEXT, FormFeature::MoveToNext },
+ { FMURL_RECORD_MOVELAST, SID_FM_RECORD_LAST, FormFeature::MoveToLast },
+ { FMURL_RECORD_MOVETONEW, SID_FM_RECORD_NEW, FormFeature::MoveToInsertRow },
+ { FMURL_RECORD_SAVE, SID_FM_RECORD_SAVE, FormFeature::SaveRecordChanges },
+ { FMURL_RECORD_DELETE, SID_FM_RECORD_DELETE, FormFeature::DeleteRecord },
+ { FMURL_FORM_REFRESH, SID_FM_REFRESH, FormFeature::ReloadForm },
+ { FMURL_FORM_REFRESH_CURRENT_CONTROL,
+ SID_FM_REFRESH_FORM_CONTROL,FormFeature::RefreshCurrentControl },
+ { FMURL_RECORD_UNDO, SID_FM_RECORD_UNDO, FormFeature::UndoRecordChanges },
+ { FMURL_FORM_SORT_UP, SID_FM_SORTUP, FormFeature::SortAscending },
+ { FMURL_FORM_SORT_DOWN, SID_FM_SORTDOWN, FormFeature::SortDescending },
+ { FMURL_FORM_SORT, SID_FM_ORDERCRIT, FormFeature::InteractiveSort },
+ { FMURL_FORM_AUTO_FILTER, SID_FM_AUTOFILTER, FormFeature::AutoFilter },
+ { FMURL_FORM_FILTER, SID_FM_FILTERCRIT, FormFeature::InteractiveFilter },
+ { FMURL_FORM_APPLY_FILTER, SID_FM_FORM_FILTERED, FormFeature::ToggleApplyFilter },
+ { FMURL_FORM_REMOVE_FILTER, SID_FM_REMOVE_FILTER_SORT, FormFeature::RemoveFilterAndSort }
+ };
+ for ( size_t i=0; i < SAL_N_ELEMENTS(aDescriptions); ++i )
+ s_aFeatureDescriptions.push_back( aDescriptions[i] );
+ }
+ };
+ return s_aFeatureDescriptions;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //................................................................
+ struct MatchFeatureDescriptionByURL : public ::std::unary_function< FeatureDescription, bool >
+ {
+ const ::rtl::OUString& m_rURL;
+ MatchFeatureDescriptionByURL( const ::rtl::OUString& _rURL ) :m_rURL( _rURL ) { }
+
+ bool operator()( const FeatureDescription& _compare )
+ {
+ return m_rURL == _compare.sURL;
+ }
+ };
+
+ //................................................................
+ struct MatchFeatureDescriptionBySlotId : public ::std::unary_function< FeatureDescription, bool >
+ {
+ sal_Int32 m_nSlotId;
+ MatchFeatureDescriptionBySlotId( sal_Int32 _nSlotId ) :m_nSlotId( _nSlotId ) { }
+
+ bool operator()( const FeatureDescription& _compare )
+ {
+ return m_nSlotId == _compare.nSlotId;
+ }
+ };
+
+ //................................................................
+ struct MatchFeatureDescriptionByFormFeature : public ::std::unary_function< FeatureDescription, bool >
+ {
+ sal_Int32 m_nFormFeature;
+ MatchFeatureDescriptionByFormFeature( sal_Int32 _nFormFeature ) :m_nFormFeature( _nFormFeature ) { }
+
+ bool operator()( const FeatureDescription& _compare )
+ {
+ return m_nFormFeature == _compare.nFormFeature;
+ }
+ };
+
+ //................................................................
+ struct FormFeatureToSlotId : public ::std::unary_function< sal_Int16, sal_Int32 >
+ {
+ sal_Int32 operator()( sal_Int16 _FormFeature )
+ {
+ return FeatureSlotTranslation::getSlotIdForFormFeature( _FormFeature );
+ }
+ };
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 FeatureSlotTranslation::getControllerFeatureSlotIdForURL( const ::rtl::OUString& _rMainURL )
+ {
+ const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
+ FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionByURL( _rMainURL ) );
+ return ( pos != rDescriptions.end() ) ? pos->nSlotId : -1;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString FeatureSlotTranslation::getControllerFeatureURLForSlotId( sal_Int32 _nSlotId )
+ {
+ const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
+ FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionBySlotId( _nSlotId ) );
+ OSL_ENSURE( pos != rDescriptions.end(), "FeatureSlotTranslation::getControllerFeatureURLForSlotId: not found!" );
+ return ( pos != rDescriptions.end() ) ? pos->sURL : ::rtl::OUString();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool FeatureSlotTranslation::isFeatureURL( const ::rtl::OUString& _rMainURL )
+ {
+ return ( _rMainURL.indexOf( FMURL_FORMSLOTS_PREFIX ) == 0 );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 FeatureSlotTranslation::getFormFeatureForSlotId( sal_Int32 _nSlotId )
+ {
+ const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
+ FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionBySlotId( _nSlotId ) );
+ OSL_ENSURE( pos != rDescriptions.end(), "FeatureSlotTranslation::getFormFeatureForSlotId: not found!" );
+ return ( pos != rDescriptions.end() ) ? pos->nFormFeature : -1;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 FeatureSlotTranslation::getSlotIdForFormFeature( sal_Int16 _nFormFeature )
+ {
+ const FeatureDescriptions& rDescriptions( getFeatureDescriptions() );
+ FeatureDescriptions::const_iterator pos = ::std::find_if( rDescriptions.begin(), rDescriptions.end(), MatchFeatureDescriptionByFormFeature( _nFormFeature ) );
+ OSL_ENSURE( pos != rDescriptions.end(), "FeatureSlotTranslation::getSlotIdForFormFeature: not found!" );
+ return ( pos != rDescriptions.end() ) ? pos->nSlotId : -1;
+ }
+
+ //====================================================================
+ //= ControllerFeatures
+ //====================================================================
+ //--------------------------------------------------------------------
+ ControllerFeatures::ControllerFeatures( const Reference< XMultiServiceFactory >& _rxORB, IControllerFeatureInvalidation* _pInvalidationCallback )
+ :m_aContext( _rxORB )
+ ,m_pInvalidationCallback( _pInvalidationCallback )
+ ,m_pImpl( NULL )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ControllerFeatures::ControllerFeatures( const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback )
+ :m_aContext( _rxORB )
+ ,m_pInvalidationCallback( _pInvalidationCallback )
+ ,m_pImpl( NULL )
+ {
+ assign( _rxController );
+ }
+
+ //--------------------------------------------------------------------
+ ControllerFeatures::ControllerFeatures( const Reference< XMultiServiceFactory >& _rxORB,
+ const Reference< XForm >& _rxForm, IControllerFeatureInvalidation* _pInvalidationCallback )
+ :m_aContext( _rxORB )
+ ,m_pInvalidationCallback( _pInvalidationCallback )
+ ,m_pImpl( NULL )
+ {
+ assign( _rxForm );
+ }
+
+ //--------------------------------------------------------------------
+ void ControllerFeatures::assign( const Reference< XFormController >& _rxController )
+ {
+ dispose();
+ m_pImpl = new FormControllerHelper( m_aContext, _rxController, m_pInvalidationCallback );
+ m_pImpl->acquire();
+ }
+
+ //--------------------------------------------------------------------
+ void ControllerFeatures::assign( const Reference< XForm >& _rxForm )
+ {
+ dispose();
+ m_pImpl = new FormControllerHelper( m_aContext, _rxForm, m_pInvalidationCallback );
+ m_pImpl->acquire();
+ }
+
+ //--------------------------------------------------------------------
+ ControllerFeatures::~ControllerFeatures()
+ {
+ dispose();
+ }
+
+ //--------------------------------------------------------------------
+ void ControllerFeatures::dispose()
+ {
+ if ( m_pImpl )
+ {
+ m_pImpl->dispose();
+ m_pImpl->release();
+ m_pImpl = NULL;
+ }
+ }
+
+ //====================================================================
+ //= FormControllerHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ FormControllerHelper::FormControllerHelper( const ::comphelper::ComponentContext& _rContext,
+ const Reference< XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback )
+ :m_aContext( _rContext )
+ ,m_pInvalidationCallback( _pInvalidationCallback )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ try
+ {
+ m_xFormOperations = FormOperations::createWithFormController( m_aContext.getUNOContext(), _rxController );
+ if ( m_xFormOperations.is() )
+ m_xFormOperations->setFeatureInvalidation( this );
+
+ // to prevent the controller from displaying any error messages which happen while we operate on it,
+ // we add ourself as XSQLErrorListener. By contract, a FormController displays errors if and only if
+ // no SQLErrorListeners are registered.
+ Reference< XSQLErrorBroadcaster > xErrorBroadcast( _rxController, UNO_QUERY_THROW );
+ xErrorBroadcast->addSQLErrorListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ FormControllerHelper::FormControllerHelper( const ::comphelper::ComponentContext& _rContext,
+ const Reference< XForm >& _rxForm, IControllerFeatureInvalidation* _pInvalidationCallback )
+ :m_aContext( _rContext )
+ ,m_pInvalidationCallback( _pInvalidationCallback )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ try
+ {
+ m_xFormOperations = FormOperations::createWithForm( m_aContext.getUNOContext(), _rxForm );
+ if ( m_xFormOperations.is() )
+ m_xFormOperations->setFeatureInvalidation( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ FormControllerHelper::~FormControllerHelper( )
+ {
+ try
+ {
+ acquire();
+ dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void FormControllerHelper::dispose()
+ {
+ if ( m_xFormOperations.is() )
+ m_xFormOperations->dispose();
+ m_xFormOperations.clear();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool FormControllerHelper::isEnabled( sal_Int32 _nSlotId ) const
+ {
+ if ( !m_xFormOperations.is() )
+ return sal_False;
+ return m_xFormOperations->isEnabled( FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ) );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XRowSet > FormControllerHelper::getCursor() const
+ {
+ Reference< XRowSet > xCursor;
+ if ( m_xFormOperations.is() )
+ xCursor = m_xFormOperations->getCursor();
+ return xCursor;
+ }
+
+ //--------------------------------------------------------------------
+ void FormControllerHelper::getState( sal_Int32 _nSlotId, FeatureState& _rState ) const
+ {
+ if ( m_xFormOperations.is() )
+ _rState = m_xFormOperations->getState( FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ) );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool FormControllerHelper::commitCurrentControl( ) const
+ {
+ return impl_operateForm_nothrow( COMMIT_CONTROL );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool FormControllerHelper::commitCurrentRecord() const
+ {
+ return impl_operateForm_nothrow( COMMIT_RECORD );
+ }
+
+ //--------------------------------------------------------------------
+ bool FormControllerHelper::moveRight( ) const
+ {
+ return impl_operateForm_nothrow( FormFeature::MoveToNext );
+ }
+
+ //--------------------------------------------------------------------
+ bool FormControllerHelper::moveLeft( ) const
+ {
+ return impl_operateForm_nothrow( FormFeature::MoveToPrevious );
+ }
+
+ //--------------------------------------------------------------------
+ void FormControllerHelper::execute( sal_Int32 _nSlotId, const ::rtl::OUString& _rParamName, const Any& _rParamValue ) const
+ {
+ Sequence< NamedValue > aArguments(1);
+ aArguments[0].Name = _rParamName;
+ aArguments[0].Value = _rParamValue;
+
+ impl_operateForm_nothrow( EXECUTE_ARGS, FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ), aArguments );
+ }
+
+ //--------------------------------------------------------------------
+ bool FormControllerHelper::impl_operateForm_nothrow( const FormOperation _eWhat, const sal_Int16 _nFeature,
+ const Sequence< NamedValue >& _rArguments ) const
+ {
+ if ( !m_xFormOperations.is() )
+ return false;
+
+ Any aError;
+ bool bSuccess = false;
+ const_cast< FormControllerHelper* >( this )->m_aOperationError.clear();
+ try
+ {
+ switch ( _eWhat )
+ {
+ case COMMIT_CONTROL:
+ bSuccess = m_xFormOperations->commitCurrentControl();
+ break;
+
+ case COMMIT_RECORD:
+ {
+ sal_Bool bDummy( sal_False );
+ bSuccess = m_xFormOperations->commitCurrentRecord( bDummy );
+ }
+ break;
+
+ case EXECUTE:
+ m_xFormOperations->execute( _nFeature );
+ bSuccess = true;
+ break;
+
+ case EXECUTE_ARGS:
+ m_xFormOperations->executeWithArguments( _nFeature, _rArguments );
+ bSuccess = true;
+ break;
+ }
+ }
+ catch ( const SQLException& )
+ {
+ aError = ::cppu::getCaughtException();
+ }
+ catch( const Exception& )
+ {
+ SQLException aFallbackError;
+ aFallbackError.Message = ::comphelper::anyToString( ::cppu::getCaughtException() );
+ aError <<= aFallbackError;
+ }
+
+ if ( bSuccess )
+ return true;
+
+ // display the error. Prefer the one reported in errorOccured over the one caught.
+ if ( m_aOperationError.hasValue() )
+ displayException( m_aOperationError );
+ else if ( aError.hasValue() )
+ displayException( aError );
+ else
+ OSL_ENSURE( false, "FormControllerHelper::impl_operateForm_nothrow: no success, but no error?" );
+
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ void FormControllerHelper::execute( sal_Int32 _nSlotId ) const
+ {
+ impl_operateForm_nothrow( EXECUTE, FeatureSlotTranslation::getFormFeatureForSlotId( _nSlotId ),
+ Sequence< NamedValue >() );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormControllerHelper::invalidateFeatures( const Sequence< ::sal_Int16 >& _Features ) throw (RuntimeException)
+ {
+ if ( !m_pInvalidationCallback )
+ // nobody's interested in ...
+ return;
+
+ ::std::vector< sal_Int32 > aFeatures( _Features.getLength() );
+ ::std::transform(
+ _Features.getConstArray(),
+ _Features.getConstArray() + _Features.getLength(),
+ aFeatures.begin(),
+ FormFeatureToSlotId()
+ );
+
+ m_pInvalidationCallback->invalidateFeatures( aFeatures );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormControllerHelper::invalidateAllFeatures() throw (RuntimeException)
+ {
+ if ( !m_pInvalidationCallback )
+ // nobody's interested in ...
+ return;
+
+ // actually, it's a little bit more than the supported features,
+ // but on the medium term, we are to support everything listed
+ // here
+ ::std::vector< sal_Int32 > aSupportedFeatures;
+ sal_Int32 pSupportedFeatures[] =
+ {
+ SID_FM_RECORD_FIRST,
+ SID_FM_RECORD_NEXT,
+ SID_FM_RECORD_PREV,
+ SID_FM_RECORD_LAST,
+ SID_FM_RECORD_NEW,
+ SID_FM_RECORD_DELETE,
+ SID_FM_RECORD_ABSOLUTE,
+ SID_FM_RECORD_TOTAL,
+ SID_FM_RECORD_SAVE,
+ SID_FM_RECORD_UNDO,
+ SID_FM_REMOVE_FILTER_SORT,
+ SID_FM_SORTUP,
+ SID_FM_SORTDOWN,
+ SID_FM_ORDERCRIT,
+ SID_FM_AUTOFILTER,
+ SID_FM_FILTERCRIT,
+ SID_FM_FORM_FILTERED,
+ SID_FM_REFRESH,
+ SID_FM_REFRESH_FORM_CONTROL,
+ SID_FM_SEARCH,
+ SID_FM_FILTER_START,
+ SID_FM_VIEW_AS_GRID
+ };
+ sal_Int32 nFeatureCount = SAL_N_ELEMENTS( pSupportedFeatures );
+ aSupportedFeatures.resize( nFeatureCount );
+ ::std::copy( pSupportedFeatures, pSupportedFeatures + nFeatureCount, aSupportedFeatures.begin() );
+
+ m_pInvalidationCallback->invalidateFeatures( aSupportedFeatures );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormControllerHelper::errorOccured( const SQLErrorEvent& _Event ) throw (RuntimeException)
+ {
+ OSL_ENSURE( !m_aOperationError.hasValue(), "FormControllerHelper::errorOccured: two errors during one operation?" );
+ m_aOperationError = _Event.Reason;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormControllerHelper::disposing( const EventObject& /*_Source*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool FormControllerHelper::isInsertionRow() const
+ {
+ sal_Bool bIs = sal_False;
+ if ( m_xFormOperations.is() )
+ bIs = m_xFormOperations->isInsertionRow();
+ return bIs;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool FormControllerHelper::isModifiedRow() const
+ {
+ sal_Bool bIs = sal_False;
+ if ( m_xFormOperations.is() )
+ bIs = m_xFormOperations->isModifiedRow();
+ return bIs;
+ }
+ //--------------------------------------------------------------------
+ bool FormControllerHelper::canDoFormFilter() const
+ {
+ if ( !m_xFormOperations.is() )
+ return false;
+
+ bool bCanDo = false;
+ try
+ {
+ Reference< XPropertySet > xCursorProperties( m_xFormOperations->getCursor(), UNO_QUERY_THROW );
+
+ bool bEscapeProcessing( false );
+ OSL_VERIFY( xCursorProperties->getPropertyValue( FM_PROP_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
+
+ ::rtl::OUString sActiveCommand;
+ OSL_VERIFY( xCursorProperties->getPropertyValue( FM_PROP_ACTIVECOMMAND ) >>= sActiveCommand );
+
+ bool bInsertOnlyForm( false );
+ OSL_VERIFY( xCursorProperties->getPropertyValue( FM_PROP_INSERTONLY ) >>= bInsertOnlyForm );
+
+ bCanDo = bEscapeProcessing && ( sActiveCommand.getLength() > 0 ) && !bInsertOnlyForm;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bCanDo;
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/formdispatchinterceptor.cxx b/svx/source/form/formdispatchinterceptor.cxx
new file mode 100644
index 000000000000..7841d7edc548
--- /dev/null
+++ b/svx/source/form/formdispatchinterceptor.cxx
@@ -0,0 +1,217 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * 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_svx.hxx"
+
+#include "formdispatchinterceptor.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <tools/debug.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::frame::XDispatchProviderInterception;
+ using ::com::sun::star::frame::XDispatchProviderInterceptor;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::util::URL;
+ using ::com::sun::star::frame::XDispatch;
+ using ::com::sun::star::frame::DispatchDescriptor;
+ using ::com::sun::star::frame::XDispatchProvider;
+ using ::com::sun::star::lang::EventObject;
+ /** === end UNO using === **/
+
+ //========================================================================
+ //= DispatchInterceptionMultiplexer
+ //========================================================================
+
+ DBG_NAME(DispatchInterceptionMultiplexer)
+ //------------------------------------------------------------------------
+ DispatchInterceptionMultiplexer::DispatchInterceptionMultiplexer(
+ const Reference< XDispatchProviderInterception >& _rxToIntercept, DispatchInterceptor* _pMaster )
+ :DispatchInterceptionMultiplexer_BASE(_pMaster && _pMaster->getInterceptorMutex() ? *_pMaster->getInterceptorMutex() : m_aFallback)
+ ,m_aFallback()
+ ,m_pMutex( _pMaster && _pMaster->getInterceptorMutex() ? _pMaster->getInterceptorMutex() : &m_aFallback )
+ ,m_xIntercepted(_rxToIntercept)
+ ,m_bListening(sal_False)
+ ,m_pMaster(_pMaster)
+ {
+ DBG_CTOR(DispatchInterceptionMultiplexer,NULL);
+
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ ::comphelper::increment(m_refCount);
+ if (_rxToIntercept.is())
+ {
+ _rxToIntercept->registerDispatchProviderInterceptor((XDispatchProviderInterceptor*)this);
+ // this should make us the top-level dispatch-provider for the component, via a call to our
+ // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill
+ Reference< XComponent> xInterceptedComponent(_rxToIntercept, UNO_QUERY);
+ if (xInterceptedComponent.is())
+ {
+ xInterceptedComponent->addEventListener(this);
+ m_bListening = sal_True;
+ }
+ }
+ ::comphelper::decrement(m_refCount);
+ }
+
+ //------------------------------------------------------------------------
+ DispatchInterceptionMultiplexer::~DispatchInterceptionMultiplexer()
+ {
+ if (!rBHelper.bDisposed)
+ dispose();
+
+ DBG_DTOR(DispatchInterceptionMultiplexer,NULL);
+ }
+
+ //------------------------------------------------------------------------------
+ Reference< XDispatch > SAL_CALL DispatchInterceptionMultiplexer::queryDispatch( const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ Reference< XDispatch> xResult;
+ // ask our 'real' interceptor
+ if (m_pMaster)
+ xResult = m_pMaster->interceptedQueryDispatch( aURL, aTargetFrameName, nSearchFlags);
+
+ // ask our slave provider
+ if (!xResult.is() && m_xSlaveDispatcher.is())
+ xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags);
+
+ return xResult;
+ }
+
+ //------------------------------------------------------------------------------
+ Sequence< Reference< XDispatch > > SAL_CALL
+ DispatchInterceptionMultiplexer::queryDispatches( const Sequence< DispatchDescriptor >& aDescripts ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ Sequence< Reference< XDispatch> > aReturn(aDescripts.getLength());
+ Reference< XDispatch>* pReturn = aReturn.getArray();
+ const DispatchDescriptor* pDescripts = aDescripts.getConstArray();
+ for (sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts)
+ {
+ *pReturn = queryDispatch(pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags);
+ }
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------------
+ Reference< XDispatchProvider > SAL_CALL DispatchInterceptionMultiplexer::getSlaveDispatchProvider( ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return m_xSlaveDispatcher;
+ }
+
+ //------------------------------------------------------------------------------
+ void SAL_CALL DispatchInterceptionMultiplexer::setSlaveDispatchProvider(const Reference< XDispatchProvider>& xNewDispatchProvider) throw( RuntimeException )
+ {
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ m_xSlaveDispatcher = xNewDispatchProvider;
+ }
+
+ //------------------------------------------------------------------------------
+ Reference< XDispatchProvider> SAL_CALL DispatchInterceptionMultiplexer::getMasterDispatchProvider(void) throw( RuntimeException )
+ {
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ return m_xMasterDispatcher;
+ }
+
+ //------------------------------------------------------------------------------
+ void SAL_CALL DispatchInterceptionMultiplexer::setMasterDispatchProvider(const Reference< XDispatchProvider>& xNewSupplier) throw( RuntimeException )
+ {
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ m_xMasterDispatcher = xNewSupplier;
+ }
+
+ //------------------------------------------------------------------------------
+ void SAL_CALL DispatchInterceptionMultiplexer::disposing(const EventObject& Source) throw( RuntimeException )
+ {
+ if (m_bListening)
+ {
+ Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY);
+ if (Source.Source == xIntercepted)
+ ImplDetach();
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ void DispatchInterceptionMultiplexer::ImplDetach()
+ {
+ ::osl::MutexGuard aGuard( *m_pMutex );
+ OSL_ENSURE(m_bListening, "DispatchInterceptionMultiplexer::ImplDetach: invalid call!");
+
+ // deregister ourself from the interception component
+ Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY);
+ if (xIntercepted.is())
+ xIntercepted->releaseDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this));
+
+ // m_xIntercepted = Reference< XDispatchProviderInterception >();
+ // Don't reset m_xIntercepted: It may be needed by our owner to check for which object we were
+ // responsible. As we hold the object with a weak reference only, this should be no problem.
+ // 88936 - 23.07.2001 - frank.schoenheit@sun.com
+ m_pMaster = NULL;
+ m_pMutex = &m_aFallback;
+ m_bListening = sal_False;
+ }
+
+ //------------------------------------------------------------------------------
+ void DispatchInterceptionMultiplexer::disposing()
+ {
+ // remove ourself as event listener from the interception component
+ if (m_bListening)
+ {
+ Reference< XComponent> xInterceptedComponent(m_xIntercepted.get(), UNO_QUERY);
+ if (xInterceptedComponent.is())
+ xInterceptedComponent->removeEventListener(static_cast<XEventListener*>(this));
+
+ // detach from the interception component
+ ImplDetach();
+ }
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/formfeaturedispatcher.cxx b/svx/source/form/formfeaturedispatcher.cxx
new file mode 100644
index 000000000000..b64ffad561cb
--- /dev/null
+++ b/svx/source/form/formfeaturedispatcher.cxx
@@ -0,0 +1,244 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "formfeaturedispatcher.hxx"
+
+#include <comphelper/namedvaluecollection.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::form::runtime;
+
+ //====================================================================
+ //= OSingleFeatureDispatcher
+ //====================================================================
+ //--------------------------------------------------------------------
+ OSingleFeatureDispatcher::OSingleFeatureDispatcher( const URL& _rFeatureURL, const sal_Int16 _nFormFeature,
+ const Reference< XFormOperations >& _rxFormOperations, ::osl::Mutex& _rMutex )
+ :m_rMutex( _rMutex )
+ ,m_aStatusListeners( _rMutex )
+ ,m_xFormOperations( _rxFormOperations )
+ ,m_aFeatureURL( _rFeatureURL )
+ ,m_nFormFeature( _nFormFeature )
+ ,m_bLastKnownEnabled( sal_False )
+ ,m_bDisposed( sal_False )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void OSingleFeatureDispatcher::dispose()
+ {
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ return;
+ }
+
+ EventObject aDisposeEvent( *this );
+ m_aStatusListeners.disposeAndClear( aDisposeEvent );
+
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ m_bDisposed = sal_True;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void OSingleFeatureDispatcher::getUnoState( FeatureStateEvent& /* [out] */ _rState ) const
+ {
+ _rState.Source = *const_cast< OSingleFeatureDispatcher* >( this );
+
+ FeatureState aState( m_xFormOperations->getState( m_nFormFeature ) );
+
+ _rState.FeatureURL = m_aFeatureURL;
+ _rState.IsEnabled = aState.Enabled;
+ _rState.Requery = sal_False;
+ _rState.State = aState.State;
+ }
+
+ //--------------------------------------------------------------------
+ void OSingleFeatureDispatcher::updateAllListeners()
+ {
+ ::osl::ClearableMutexGuard aGuard( m_rMutex );
+
+ FeatureStateEvent aUnoState;
+ getUnoState( aUnoState );
+
+ if ( ( m_aLastKnownState == aUnoState.State ) && ( m_bLastKnownEnabled == aUnoState.IsEnabled ) )
+ return;
+
+ m_aLastKnownState = aUnoState.State;
+ m_bLastKnownEnabled = aUnoState.IsEnabled;
+
+ notifyStatus( NULL, aGuard );
+ }
+
+ //--------------------------------------------------------------------
+ void OSingleFeatureDispatcher::notifyStatus( const Reference< XStatusListener >& _rxListener, ::osl::ClearableMutexGuard& _rFreeForNotification )
+ {
+ FeatureStateEvent aUnoState;
+ getUnoState( aUnoState );
+
+ if ( _rxListener.is() )
+ {
+ try
+ {
+ _rFreeForNotification.clear();
+ _rxListener->statusChanged( aUnoState );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OSingleFeatureDispatcher::notifyStatus: caught an exception!" );
+ }
+ }
+ else
+ {
+ ::cppu::OInterfaceIteratorHelper aIter( m_aStatusListeners );
+ _rFreeForNotification.clear();
+
+ while ( aIter.hasMoreElements() )
+ {
+ try
+ {
+ static_cast< XStatusListener* >( aIter.next() )->statusChanged( aUnoState );
+ }
+ catch( const DisposedException& )
+ {
+ OSL_ENSURE( sal_False, "OSingleFeatureDispatcher::notifyStatus: caught a DisposedException - removing the listener!" );
+ aIter.remove( );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OSingleFeatureDispatcher::notifyStatus: caught a generic exception while notifying a single listener!" );
+ }
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OSingleFeatureDispatcher::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArguments ) throw (RuntimeException)
+ {
+ ::osl::ClearableMutexGuard aGuard( m_rMutex );
+ checkAlive();
+
+ OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::dispatch: not responsible for this URL!" );
+ (void)_rURL;
+
+ if ( !m_xFormOperations->isEnabled( m_nFormFeature ) )
+ return;
+
+ // release our mutex before executing the command
+ sal_Int16 nFormFeature( m_nFormFeature );
+ Reference< XFormOperations > xFormOperations( m_xFormOperations );
+ aGuard.clear();
+
+ try
+ {
+ if ( !_rArguments.getLength() )
+ {
+ xFormOperations->execute( nFormFeature );
+ }
+ else
+ { // at the moment we only support one parameter
+ ::comphelper::NamedValueCollection aArgs( _rArguments );
+ xFormOperations->executeWithArguments( nFormFeature, aArgs.getNamedValues() );
+ }
+ }
+ catch( const RuntimeException& )
+ {
+ throw;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OSingleFeatureDispatcher::addStatusListener( const Reference< XStatusListener >& _rxControl, const URL& _rURL ) throw (RuntimeException)
+ {
+ (void)_rURL;
+ OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::addStatusListener: unexpected URL!" );
+ OSL_ENSURE( _rxControl.is(), "OSingleFeatureDispatcher::addStatusListener: senseless call!" );
+ if ( !_rxControl.is() )
+ return;
+
+ ::osl::ClearableMutexGuard aGuard( m_rMutex );
+ if ( m_bDisposed )
+ {
+ EventObject aDisposeEvent( *this );
+ aGuard.clear();
+ _rxControl->disposing( aDisposeEvent );
+ return;
+ }
+
+ m_aStatusListeners.addInterface( _rxControl );
+
+ // initially update the status
+ notifyStatus( _rxControl, aGuard );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OSingleFeatureDispatcher::removeStatusListener( const Reference< XStatusListener >& _rxControl, const URL& _rURL ) throw (RuntimeException)
+ {
+ (void)_rURL;
+ OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::removeStatusListener: unexpected URL!" );
+ OSL_ENSURE( _rxControl.is(), "OSingleFeatureDispatcher::removeStatusListener: senseless call!" );
+ if ( !_rxControl.is() )
+ return;
+
+ ::osl::MutexGuard aGuard( m_rMutex );
+ checkAlive();
+
+ m_aStatusListeners.removeInterface( _rxControl );
+ }
+
+ //--------------------------------------------------------------------
+ void OSingleFeatureDispatcher::checkAlive() const SAL_THROW((DisposedException))
+ {
+ if ( m_bDisposed )
+ throw DisposedException( ::rtl::OUString(), *const_cast< OSingleFeatureDispatcher* >( this ) );
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/formshell.src b/svx/source/form/formshell.src
new file mode 100644
index 000000000000..f92b762b84e3
--- /dev/null
+++ b/svx/source/form/formshell.src
@@ -0,0 +1,227 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "fmresids.hrc"
+#include <svx/svxids.hrc>
+#include <svx/dialogs.hrc>
+#include <sfx2/sfxsids.hrc>
+#include "globlmn.hrc"
+#include "helpid.hrc"
+
+Menu RID_FM_TEXTATTRIBUTE_MENU
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_FONT
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_FONTHEIGHT
+ };
+ MenuItem
+ {
+ Identifier = MENU_FM_TEXTATTRIBITES_STYLE;
+ HelpID = MENU_FM_TEXTATTRIBITES_STYLE;
+ Text [ en-US ] = "St~yle";
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_WEIGHT
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_POSTURE
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_OVERLINE
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_UNDERLINE
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_STRIKEOUT
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_SHADOWED
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_CONTOUR
+ };
+ MenuItem { Separator = TRUE; };
+ MenuItem
+ {
+ ITEM_FORMAT_SET_SUPER_SCRIPT
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_SET_SUB_SCRIPT
+ };
+ };
+ };
+ };
+ MenuItem
+ {
+ Identifier = MENU_FM_TEXTATTRIBITES_ALIGNMENT;
+ HelpID = MENU_FM_TEXTATTRIBITES_ALIGNMENT;
+ Text [ en-US ] = "~Alignment";
+ RadioCheck = TRUE;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ RadioCheck = TRUE;
+ ITEM_FORMAT_ATTR_PARA_ADJUST_LEFT
+ };
+ MenuItem
+ {
+ RadioCheck = TRUE;
+ ITEM_FORMAT_ATTR_PARA_ADJUST_RIGHT
+ };
+ MenuItem
+ {
+ RadioCheck = TRUE;
+ ITEM_FORMAT_ATTR_PARA_ADJUST_CENTER
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_PARA_ADJUST_BLOCK
+ RadioCheck = TRUE;
+ };
+ };
+ };
+ };
+ MenuItem
+ {
+ Identifier = MENU_FM_TEXTATTRIBITES_SPACING;
+ HelpID = MENU_FM_TEXTATTRIBITES_SPACING;
+ Text [ en-US ] = "~Line Spacing";
+ _MenuItemFlags = MIB_RADIOCHECK;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ RadioCheck = TRUE;
+ ITEM_FORMAT_PARA_LINESPACE_10
+ };
+ MenuItem
+ {
+ RadioCheck = TRUE;
+ ITEM_FORMAT_PARA_LINESPACE_15
+ };
+ MenuItem
+ {
+ RadioCheck = TRUE;
+ ITEM_FORMAT_PARA_LINESPACE_20
+ };
+ };
+ };
+ };
+ };
+};
+
+TabDialog RID_SVXDLG_TEXTCONTROL_CHARATTR
+{
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Moveable = TRUE;
+
+ Text [ en-US ] = "Character";
+
+ TabControl 1
+ {
+ OutputSize = TRUE;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_CHAR_NAME;
+ Text [ en-US ] = "Font";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_CHAR_EFFECTS;
+ Text [ en-US ] = "Font Effects";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_CHAR_POSITION;
+ Text [ en-US ] = "Position";
+ };
+ };
+ };
+};
+
+TabDialog RID_SVXDLG_TEXTCONTROL_PARAATTR
+{
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Moveable = TRUE;
+
+ Text [ en-US ] = "Paragraph";
+
+ TabControl 1
+ {
+ OutputSize = TRUE;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_STD_PARAGRAPH;
+ Text [ en-US ] = "Indents & Spacing";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_ALIGN_PARAGRAPH;
+ Text [ en-US ] = "Alignment";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_PARA_ASIAN;
+ Text [ en-US ] = "Asian Typography";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_TABULATOR;
+ Text [ en-US ] = "Tabs";
+ };
+ };
+ };
+};
diff --git a/svx/source/form/formtoolbars.cxx b/svx/source/form/formtoolbars.cxx
new file mode 100644
index 000000000000..a0835a864a8b
--- /dev/null
+++ b/svx/source/form/formtoolbars.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "formtoolbars.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+#include <svx/svxids.hrc>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::frame;
+
+ //====================================================================
+ //= FormToolboxes
+ //====================================================================
+ //--------------------------------------------------------------------
+ FormToolboxes::FormToolboxes( const Reference< XFrame >& _rxFrame )
+ {
+ // the layout manager
+ Reference< XPropertySet > xFrameProps( _rxFrame, UNO_QUERY );
+ if ( xFrameProps.is() )
+ xFrameProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" ) ) ) >>= m_xLayouter;
+ }
+
+ //--------------------------------------------------------------------
+ void FormToolboxes::toggleToolbox( USHORT _nSlotId ) const
+ {
+ try
+ {
+ Reference< XLayoutManager > xManager( m_xLayouter );
+ OSL_ENSURE( xManager. is(), "FormToolboxes::toggleToolbox: couldn't obtain the layout manager!" );
+ if ( xManager. is() )
+ {
+ ::rtl::OUString sToolboxResource( getToolboxResourceName( _nSlotId ) );
+ if ( xManager->isElementVisible( sToolboxResource ) )
+ {
+ xManager->hideElement( sToolboxResource );
+ xManager->destroyElement( sToolboxResource );
+ }
+ else
+ {
+ xManager->createElement( sToolboxResource );
+ xManager->showElement( sToolboxResource );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormToolboxes::toggleToolbox: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool FormToolboxes::isToolboxVisible( USHORT _nSlotId ) const
+ {
+ return m_xLayouter.is() && m_xLayouter->isElementVisible(
+ getToolboxResourceName( _nSlotId ) );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString FormToolboxes::getToolboxResourceName( USHORT _nSlotId ) const
+ {
+ OSL_ENSURE( ( _nSlotId == SID_FM_MORE_CONTROLS ) || ( _nSlotId == SID_FM_FORM_DESIGN_TOOLS ) || ( _nSlotId == SID_FM_CONFIG ),
+ "FormToolboxes::getToolboxResourceName: unsupported slot!" );
+
+ const sal_Char* pToolBarName = "formcontrols";
+ if ( _nSlotId == SID_FM_MORE_CONTROLS )
+ pToolBarName = "moreformcontrols";
+ else if ( _nSlotId == SID_FM_FORM_DESIGN_TOOLS )
+ pToolBarName = "formdesign";
+
+ ::rtl::OUString aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/" ));
+ aToolBarResStr += ::rtl::OUString::createFromAscii( pToolBarName );
+ return aToolBarResStr;
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/legacyformcontroller.cxx b/svx/source/form/legacyformcontroller.cxx
new file mode 100644
index 000000000000..fb7c564ff967
--- /dev/null
+++ b/svx/source/form/legacyformcontroller.cxx
@@ -0,0 +1,228 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * 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_svx.hxx"
+
+#include "fmservs.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/XFormController.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase2.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::awt::XControl;
+ using ::com::sun::star::awt::XTabControllerModel;
+ using ::com::sun::star::awt::XControlContainer;
+ using ::com::sun::star::lang::XServiceInfo;
+ /** === end UNO using === **/
+
+ using namespace ::com::sun::star;
+
+ //====================================================================
+ //= LegacyFormController
+ //====================================================================
+ typedef ::cppu::WeakImplHelper2 < form::XFormController
+ , XServiceInfo
+ > LegacyFormController_Base;
+ /** is an implementation of the legacy form controller service, namely css.form.FormController, supporting the
+ css.form.XFormController interface.
+
+ This legacy API is superseded by css.form.runtime.(X)FormController, and though we migrated all OOo-internal
+ usage of this old API, their might be clients external to OOo still using it (though this is rather unlikely).
+ */
+ class LegacyFormController : public LegacyFormController_Base
+ {
+ public:
+ static Reference< XInterface > Create( const Reference< XMultiServiceFactory >& _rxFactory )
+ {
+ return *( new LegacyFormController( _rxFactory ) );
+ }
+
+ protected:
+ LegacyFormController( const Reference< XMultiServiceFactory >& _rxFactory )
+ :m_xDelegator( _rxFactory->createInstance( FM_FORM_CONTROLLER ), UNO_QUERY_THROW )
+ {
+ }
+
+ // form::XFormController
+ virtual Reference< XControl > SAL_CALL getCurrentControl( ) throw (RuntimeException);
+ virtual void SAL_CALL addActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException);
+ virtual void SAL_CALL removeActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException);
+
+ // awt::XTabController
+ virtual void SAL_CALL setModel( const Reference< XTabControllerModel >& Model ) throw (RuntimeException);
+ virtual Reference< XTabControllerModel > SAL_CALL getModel( ) throw (RuntimeException);
+ virtual void SAL_CALL setContainer( const Reference< XControlContainer >& Container ) throw (RuntimeException);
+ virtual Reference< XControlContainer > SAL_CALL getContainer( ) throw (RuntimeException);
+ virtual Sequence< Reference< XControl > > SAL_CALL getControls( ) throw (RuntimeException);
+ virtual void SAL_CALL autoTabOrder( ) throw (RuntimeException);
+ virtual void SAL_CALL activateTabOrder( ) throw (RuntimeException);
+ virtual void SAL_CALL activateFirst( ) throw (RuntimeException);
+ virtual void SAL_CALL activateLast( ) throw (RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
+
+ private:
+ const Reference< form::runtime::XFormController > m_xDelegator;
+ };
+
+ //--------------------------------------------------------------------
+ Reference< XControl > SAL_CALL LegacyFormController::getCurrentControl( ) throw (RuntimeException)
+ {
+ return m_xDelegator->getCurrentControl();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL LegacyFormController::addActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException)
+ {
+ m_xDelegator->addActivateListener( _listener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL LegacyFormController::removeActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException)
+ {
+ m_xDelegator->removeActivateListener( _listener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL LegacyFormController::setModel( const Reference< XTabControllerModel >& _model ) throw (RuntimeException)
+ {
+ m_xDelegator->setModel( _model );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XTabControllerModel > SAL_CALL LegacyFormController::getModel( ) throw (RuntimeException)
+ {
+ return m_xDelegator->getModel();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL LegacyFormController::setContainer( const Reference< XControlContainer >& _container ) throw (RuntimeException)
+ {
+ m_xDelegator->setContainer( _container );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XControlContainer > SAL_CALL LegacyFormController::getContainer( ) throw (RuntimeException)
+ {
+ return m_xDelegator->getContainer();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Reference< XControl > > SAL_CALL LegacyFormController::getControls( ) throw (RuntimeException)
+ {
+ return m_xDelegator->getControls();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL LegacyFormController::autoTabOrder( ) throw (RuntimeException)
+ {
+ m_xDelegator->autoTabOrder();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL LegacyFormController::activateTabOrder( ) throw (RuntimeException)
+ {
+ m_xDelegator->activateTabOrder();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL LegacyFormController::activateFirst( ) throw (RuntimeException)
+ {
+ m_xDelegator->activateFirst();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL LegacyFormController::activateLast( ) throw (RuntimeException)
+ {
+ m_xDelegator->activateLast();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL LegacyFormController::getImplementationName( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.svx.LegacyFormController" ) );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL LegacyFormController::supportsService( const ::rtl::OUString& _serviceName ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() );
+ const ::rtl::OUString* pServices = aServices.getConstArray();
+ for ( sal_Int32 i = 0; i < aServices.getLength(); ++i, ++pServices )
+ if( pServices->equals( _serviceName ) )
+ return sal_True;
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL LegacyFormController::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aServices(2);
+ aServices.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) );
+ aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.control.TabController");
+ return aServices;
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+//------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ LegacyFormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB )
+{
+ return ::svxform::LegacyFormController::Create( _rxORB );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/makefile.mk b/svx/source/form/makefile.mk
new file mode 100644
index 000000000000..44bcd53d234f
--- /dev/null
+++ b/svx/source/form/makefile.mk
@@ -0,0 +1,123 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+TARGET=form
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(ENABLE_VBA)"=="YES"
+ CDEFS+=-DENABLE_VBA
+.ENDIF
+
+.IF "$(ENABLE_VBA)"=="YES"
+ CDEFS+=-DENABLE_VBA
+.ENDIF
+
+SRS1NAME=form
+SRC1FILES= \
+ fmexpl.src \
+ filtnav.src \
+ fmstring.src \
+ formshell.src \
+ datanavi.src
+
+LIB1TARGET= $(SLB)$/$(TARGET)-core.lib
+LIB1OBJFILES= \
+ $(SLO)$/formtoolbars.obj \
+ $(SLO)$/fmdocumentclassification.obj \
+ $(SLO)$/fmcontrolbordermanager.obj \
+ $(SLO)$/fmcontrollayout.obj \
+ $(SLO)$/fmtextcontroldialogs.obj \
+ $(SLO)$/fmtextcontrolfeature.obj \
+ $(SLO)$/fmtextcontrolshell.obj \
+ $(SLO)$/ParseContext.obj \
+ $(SLO)$/typeconversionclient.obj \
+ $(SLO)$/dbtoolsclient.obj \
+ $(SLO)$/sqlparserclient.obj \
+ $(SLO)$/dataaccessdescriptor.obj \
+ $(SLO)$/fmpage.obj \
+ $(SLO)$/fmundo.obj \
+ $(SLO)$/fmmodel.obj \
+ $(SLO)$/navigatortree.obj \
+ $(SLO)$/navigatortreemodel.obj \
+ $(SLO)$/fmexpl.obj \
+ $(SLO)$/formcontroller.obj \
+ $(SLO)$/fmpgeimp.obj \
+ $(SLO)$/fmvwimp.obj \
+ $(SLO)$/fmdpage.obj \
+ $(SLO)$/fmitems.obj \
+ $(SLO)$/fmobj.obj \
+ $(SLO)$/fmdmod.obj \
+ $(SLO)$/fmservs.obj \
+ $(SLO)$/typemap.obj \
+ $(SLO)$/fmexch.obj \
+ $(SLO)$/fmtools.obj \
+ $(SLO)$/fmshimp.obj \
+ $(SLO)$/fmshell.obj \
+ $(SLO)$/fmview.obj \
+ $(SLO)$/sdbdatacolumn.obj \
+ $(SLO)$/formcontrolling.obj \
+ $(SLO)$/formfeaturedispatcher.obj \
+ $(SLO)$/formdispatchinterceptor.obj \
+ $(SLO)$/datanavi.obj \
+ $(SLO)$/xfm_addcondition.obj \
+ $(SLO)$/datalistener.obj \
+ $(SLO)$/fmscriptingenv.obj \
+ $(SLO)$/stringlistresource.obj \
+ $(SLO)$/delayedevent.obj \
+ $(SLO)$/formcontrolfactory.obj \
+ $(SLO)$/legacyformcontroller.obj
+
+LIB2TARGET= $(SLB)$/$(TARGET).lib
+LIB2OBJFILES= \
+ $(SLO)$/dbcharsethelper.obj \
+ $(SLO)$/fmPropBrw.obj \
+ $(SLO)$/tbxform.obj \
+ $(SLO)$/fmobjfac.obj \
+ $(SLO)$/fmsrccfg.obj \
+ $(SLO)$/tabwin.obj \
+ $(SLO)$/filtnav.obj \
+ $(SLO)$/fmsrcimp.obj \
+ $(SLO)$/databaselocationinput.obj
+
+SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx
new file mode 100644
index 000000000000..518f2f2a6bd9
--- /dev/null
+++ b/svx/source/form/navigatortree.cxx
@@ -0,0 +1,2324 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/dialmgr.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/fmpage.hxx>
+#include <svx/svdpagv.hxx>
+#include "svditer.hxx"
+
+#include "fmhelp.hrc"
+#include "fmexpl.hrc"
+#include "fmexpl.hxx"
+#include "fmresids.hrc"
+#include "fmshimp.hxx"
+#include "fmservs.hxx"
+#include "fmundo.hxx"
+#include "fmpgeimp.hxx"
+#include "fmitems.hxx"
+#include "fmobj.hxx"
+#include "fmprop.hrc"
+#include <vcl/wrkwin.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/property.hxx>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <sdrpaintwindow.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <rtl/logfile.hxx>
+//............................................................................
+namespace svxform
+{
+//............................................................................
+
+ #define DROP_ACTION_TIMER_INITIAL_TICKS 10
+ // solange dauert es, bis das Scrollen anspringt
+ #define DROP_ACTION_TIMER_SCROLL_TICKS 3
+ // in diesen Intervallen wird jeweils eine Zeile gescrollt
+ #define DROP_ACTION_TIMER_TICK_BASE 10
+ // das ist die Basis, mit der beide Angaben multipliziert werden (in ms)
+
+ #define EXPLORER_SYNC_DELAY 200
+ // dieser Betrag an Millisekunden wird gewartet, ehe der Explorer nach einem Select oder Deselect die ::com::sun::star::sdbcx::View synchronisiert
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::datatransfer;
+ using namespace ::com::sun::star::datatransfer::clipboard;
+ using namespace ::com::sun::star::sdb;
+
+ //========================================================================
+ // helper
+ //========================================================================
+
+ typedef ::std::map< Reference< XInterface >, SdrObject*, ::comphelper::OInterfaceCompare< XInterface > >
+ MapModelToShape;
+ typedef MapModelToShape::value_type ModelShapePair;
+
+ //------------------------------------------------------------------------
+ void collectShapeModelMapping( SdrPage* _pPage, MapModelToShape& _rMapping )
+ {
+ OSL_ENSURE( _pPage, "collectShapeModelMapping: invalid arg!" );
+
+ _rMapping.clear();
+
+ SdrObjListIter aIter( *_pPage );
+ while ( aIter.IsMore() )
+ {
+ SdrObject* pSdrObject = aIter.Next();
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pSdrObject );
+ if ( !pFormObject )
+ continue;
+
+ Reference< XInterface > xNormalizedModel( pFormObject->GetUnoControlModel(), UNO_QUERY );
+ // note that this is normalized (i.e. queried for XInterface explicitly)
+
+#ifdef DBG_UTIL
+ ::std::pair< MapModelToShape::iterator, bool > aPos =
+#endif
+ _rMapping.insert( ModelShapePair( xNormalizedModel, pSdrObject ) );
+ DBG_ASSERT( aPos.second, "collectShapeModelMapping: model was already existent!" );
+ // if this asserts, this would mean we have 2 shapes pointing to the same model
+ }
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool isModelShapeMarked( FmEntryData* _pEntry, const MapModelToShape& _rModelMap, SdrMarkView* _pView )
+ {
+ DBG_ASSERT( _pEntry && _pView, "isModelShapeMarked: invalid arguments!" );
+ if ( !_pEntry || !_pView )
+ return sal_False;
+
+ DBG_ASSERT( _pEntry->GetElement().get() == Reference< XInterface >( _pEntry->GetElement(), UNO_QUERY ).get(),
+ "isModelShapeMarked: element of the FmEntryData is not normalized!" );
+ // normalization of the XInterface is a prerequisite for properly finding it in the map
+
+ sal_Bool bIsMarked = sal_False;
+
+ MapModelToShape::const_iterator aPos = _rModelMap.find( _pEntry->GetElement() );
+ if ( _rModelMap.end() != aPos )
+ { // there is a shape for this model ....
+ bIsMarked = _pView->IsObjMarked( aPos->second );
+ if ( !bIsMarked )
+ {
+ // IsObjMarked does not step down grouped objects, so the sal_False we
+ // have is not really reliable (while a sal_True would have been)
+ // Okay, travel the mark list, and see if there is a group marked, and our shape
+ // is a part of this group
+ sal_uInt32 nMarked = _pView->GetMarkedObjectList().GetMarkCount();
+ for ( sal_uInt32 i = 0; (i<nMarked ) && !bIsMarked; ++i )
+ {
+ SdrMark* pMark = _pView->GetMarkedObjectList().GetMark( i );
+ SdrObject* pObj = pMark ? pMark->GetMarkedSdrObj() : NULL;
+ if ( pObj && pObj->IsGroupObject() )
+ { // the i-th marked shape is a group shape
+ SdrObjListIter aIter( *pObj );
+ while ( aIter.IsMore() )
+ {
+ if ( aIter.Next() == aPos->second )
+ {
+ bIsMarked = sal_True;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return bIsMarked;
+ }
+
+ //========================================================================
+ // class NavigatorTree
+ //========================================================================
+
+ //------------------------------------------------------------------------
+ NavigatorTree::NavigatorTree( const Reference< XMultiServiceFactory >& _xORB,
+ Window* pParent )
+ :SvTreeListBox( pParent, WB_HASBUTTONS|WB_HASLINES|WB_BORDER|WB_HSCROLL ) // #100258# OJ WB_HSCROLL added
+ ,m_aControlExchange(this)
+ ,m_xORB(_xORB)
+ ,m_pNavModel( NULL )
+ ,m_pRootEntry(NULL)
+ ,m_pEditEntry(NULL)
+ ,nEditEvent(0)
+ ,m_sdiState(SDI_DIRTY)
+ ,m_aTimerTriggered(-1,-1)
+ ,m_aDropActionType( DA_SCROLLUP )
+ ,m_nSelectLock(0)
+ ,m_nFormsSelected(0)
+ ,m_nControlsSelected(0)
+ ,m_nHiddenControls(0)
+ ,m_aTimerCounter( DROP_ACTION_TIMER_INITIAL_TICKS )
+ ,m_bDragDataDirty(sal_False)
+ ,m_bPrevSelectionMixed(sal_False)
+ ,m_bMarkingObjects(sal_False)
+ ,m_bRootSelected(sal_False)
+ ,m_bInitialUpdate(sal_True)
+ ,m_bKeyboardCut( sal_False )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::NavigatorTree" );
+ SetHelpId( HID_FORM_NAVIGATOR );
+
+ m_aNavigatorImages = ImageList( SVX_RES( RID_SVXIMGLIST_FMEXPL ) );
+ m_aNavigatorImagesHC = ImageList( SVX_RES( RID_SVXIMGLIST_FMEXPL_HC ) );
+
+ SetNodeBitmaps(
+ m_aNavigatorImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ),
+ m_aNavigatorImages.GetImage( RID_SVXIMG_EXPANDEDNODE ),
+ BMP_COLOR_NORMAL
+ );
+ SetNodeBitmaps(
+ m_aNavigatorImagesHC.GetImage( RID_SVXIMG_COLLAPSEDNODE ),
+ m_aNavigatorImagesHC.GetImage( RID_SVXIMG_EXPANDEDNODE ),
+ BMP_COLOR_HIGHCONTRAST
+ );
+
+ SetDragDropMode(0xFFFF);
+ EnableInplaceEditing( sal_True );
+ SetSelectionMode(MULTIPLE_SELECTION);
+
+ m_pNavModel = new NavigatorTreeModel( m_aNavigatorImages, m_aNavigatorImagesHC );
+ Clear();
+
+ StartListening( *m_pNavModel );
+
+ m_aDropActionTimer.SetTimeoutHdl(LINK(this, NavigatorTree, OnDropActionTimer));
+
+ m_aSynchronizeTimer.SetTimeoutHdl(LINK(this, NavigatorTree, OnSynchronizeTimer));
+ SetSelectHdl(LINK(this, NavigatorTree, OnEntrySelDesel));
+ SetDeselectHdl(LINK(this, NavigatorTree, OnEntrySelDesel));
+ }
+
+ //------------------------------------------------------------------------
+ NavigatorTree::~NavigatorTree()
+ {
+ if( nEditEvent )
+ Application::RemoveUserEvent( nEditEvent );
+
+ if (m_aSynchronizeTimer.IsActive())
+ m_aSynchronizeTimer.Stop();
+
+ DBG_ASSERT(GetNavModel() != NULL, "NavigatorTree::~NavigatorTree : unerwartet : kein ExplorerModel");
+ EndListening( *m_pNavModel );
+ Clear();
+ delete m_pNavModel;
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::Clear()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Clear" );
+ m_pNavModel->Clear();
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::UpdateContent( FmFormShell* pFormShell )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::UpdateContent" );
+ if (m_bInitialUpdate)
+ {
+ GrabFocus();
+ m_bInitialUpdate = sal_False;
+ }
+
+ FmFormShell* pOldShell = GetNavModel()->GetFormShell();
+ FmFormPage* pOldPage = GetNavModel()->GetFormPage();
+ FmFormPage* pNewPage = pFormShell ? pFormShell->GetCurPage() : NULL;
+
+ if ((pOldShell != pFormShell) || (pOldPage != pNewPage))
+ {
+ // neue Shell, waehrend ich gerade editiere ?
+ if (IsEditingActive())
+ CancelTextEditing();
+
+ m_bDragDataDirty = sal_True; // sicherheitshalber, auch wenn ich gar nicht dragge
+ }
+ GetNavModel()->UpdateContent( pFormShell );
+
+ // wenn es eine Form gibt, die Root expandieren
+ if (m_pRootEntry && !IsExpanded(m_pRootEntry))
+ Expand(m_pRootEntry);
+ // wenn es GENAU eine Form gibt, auch diese expandieren
+ if (m_pRootEntry)
+ {
+ SvLBoxEntry* pFirst = FirstChild(m_pRootEntry);
+ if (pFirst && !NextSibling(pFirst))
+ Expand(pFirst);
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ sal_Bool NavigatorTree::implAllowExchange( sal_Int8 _nAction, sal_Bool* _pHasNonHidden )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAllowExchange" );
+ SvLBoxEntry* pCurEntry = GetCurEntry();
+ if (!pCurEntry)
+ return sal_False;
+
+ // die Informationen fuer das AcceptDrop und ExecuteDrop
+ CollectSelectionData(SDI_ALL);
+ if (!m_arrCurrentSelection.Count())
+ // nothing to do
+ return sal_False;
+
+ // testen, ob es sich vielleicht ausschliesslich um hidden controls handelt (dann koennte ich pCtrlExch noch ein
+ // zusaetzliches Format geben)
+ sal_Bool bHasNonHidden = sal_False;
+ for (sal_Int32 i=0; i<m_arrCurrentSelection.Count(); i++)
+ {
+ FmEntryData* pCurrent = static_cast< FmEntryData* >( m_arrCurrentSelection[(sal_uInt16)i]->GetUserData() );
+ if ( IsHiddenControl( pCurrent ) )
+ continue;
+ bHasNonHidden = sal_True;
+ break;
+ }
+
+ if ( bHasNonHidden && ( 0 == ( _nAction & DND_ACTION_MOVE ) ) )
+ // non-hidden controls need to be moved
+ return sal_False;
+
+ if ( _pHasNonHidden )
+ *_pHasNonHidden = bHasNonHidden;
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------------
+ sal_Bool NavigatorTree::implPrepareExchange( sal_Int8 _nAction )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implPrepareExchange" );
+ sal_Int32 i;
+
+ EndSelection();
+
+ sal_Bool bHasNonHidden = sal_False;
+ if ( !implAllowExchange( _nAction, &bHasNonHidden ) )
+ return sal_False;
+
+ m_aControlExchange.prepareDrag();
+ m_aControlExchange->setFocusEntry( GetCurEntry() );
+
+ for ( i = 0; i < m_arrCurrentSelection.Count(); ++i )
+ m_aControlExchange->addSelectedEntry(m_arrCurrentSelection[(sal_uInt16)i]);
+
+ m_aControlExchange->setFormsRoot( GetNavModel()->GetFormPage()->GetForms() );
+ m_aControlExchange->buildPathFormat( this, m_pRootEntry );
+
+ if (!bHasNonHidden)
+ {
+ // eine entsprechende Sequenz aufbauen
+ Sequence< Reference< XInterface > > seqIFaces(m_arrCurrentSelection.Count());
+ Reference< XInterface >* pArray = seqIFaces.getArray();
+ for (i=0; i<m_arrCurrentSelection.Count(); ++i, ++pArray)
+ *pArray = static_cast< FmEntryData* >( m_arrCurrentSelection[(sal_uInt16)i]->GetUserData() )->GetElement();
+
+ // und das neue Format
+ m_aControlExchange->addHiddenControlsFormat(seqIFaces);
+ }
+
+ m_bDragDataDirty = sal_False;
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------------
+ void NavigatorTree::StartDrag( sal_Int8 /*nAction*/, const ::Point& /*rPosPixel*/ )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::StartDrag" );
+ EndSelection();
+
+ if ( !implPrepareExchange( DND_ACTION_COPYMOVE ) )
+ // nothing to do or something went wrong
+ return;
+
+ // jetzt haben wir alle in der aktuelle Situation moeglichen Formate eingesammelt, es kann also losgehen ...
+ m_aControlExchange.startDrag( DND_ACTION_COPYMOVE );
+ }
+
+ //------------------------------------------------------------------------------
+ void NavigatorTree::Command( const CommandEvent& rEvt )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Command" );
+ sal_Bool bHandled = sal_False;
+ switch( rEvt.GetCommand() )
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ // die Stelle, an der geklickt wurde
+ ::Point ptWhere;
+ if (rEvt.IsMouseEvent())
+ {
+ ptWhere = rEvt.GetMousePosPixel();
+ SvLBoxEntry* ptClickedOn = GetEntry(ptWhere);
+ if (ptClickedOn == NULL)
+ break;
+ if ( !IsSelected(ptClickedOn) )
+ {
+ SelectAll(sal_False);
+ Select(ptClickedOn, sal_True);
+ SetCurEntry(ptClickedOn);
+ }
+ }
+ else
+ {
+ if (m_arrCurrentSelection.Count() == 0) // kann nur bei Kontextmenue ueber Tastatur passieren
+ break;
+
+ SvLBoxEntry* pCurrent = GetCurEntry();
+ if (!pCurrent)
+ break;
+ ptWhere = GetEntryPosition(pCurrent);
+ }
+
+ // meine Selektionsdaten auf den aktuellen Stand
+ CollectSelectionData(SDI_ALL);
+
+ // wenn mindestens ein Nicht-Root-Eintrag selektiert ist und die Root auch, dann nehme ich letztere aus der Selektion
+ // fix wieder raus
+ if ( (m_arrCurrentSelection.Count() > 1) && m_bRootSelected )
+ {
+ Select( m_pRootEntry, sal_False );
+ SetCursor( m_arrCurrentSelection.GetObject(0), sal_True);
+ }
+ sal_Bool bSingleSelection = (m_arrCurrentSelection.Count() == 1);
+
+
+ DBG_ASSERT( (m_arrCurrentSelection.Count() > 0) || m_bRootSelected, "keine Eintraege selektiert" );
+ // solte nicht passieren, da ich oben bei der IsSelected-Abfrage auf jeden Fall einen selektiert haette,
+ // wenn das vorher nicht der Fall gewesen waere
+
+
+ // das Menue zusammenbasteln
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ FmFormModel* pFormModel = pFormShell ? pFormShell->GetFormModel() : NULL;
+ if( pFormShell && pFormModel )
+ {
+ PopupMenu aContextMenu(SVX_RES(RID_FMEXPLORER_POPUPMENU));
+ PopupMenu* pSubMenuNew = aContextMenu.GetPopupMenu( SID_FM_NEW );
+
+ // das 'Neu'-Untermenue gibt es nur, wenn genau die Root oder genau ein Formular selektiert sind
+ aContextMenu.EnableItem( SID_FM_NEW, bSingleSelection && (m_nFormsSelected || m_bRootSelected) );
+
+ // 'Neu'\'Formular' unter genau den selben Bedingungen
+ pSubMenuNew->EnableItem( SID_FM_NEW_FORM, bSingleSelection && (m_nFormsSelected || m_bRootSelected) );
+ pSubMenuNew->SetItemImage(SID_FM_NEW_FORM, m_aNavigatorImages.GetImage(RID_SVXIMG_FORM));
+ pSubMenuNew->SetItemImage(SID_FM_NEW_HIDDEN, m_aNavigatorImages.GetImage(RID_SVXIMG_HIDDEN));
+
+ // 'Neu'\'verstecktes...', wenn genau ein Formular selektiert ist
+ pSubMenuNew->EnableItem( SID_FM_NEW_HIDDEN, bSingleSelection && m_nFormsSelected );
+
+ // 'Delete': everything which is not root can be removed
+ aContextMenu.EnableItem( SID_FM_DELETE, !m_bRootSelected );
+
+ // 'Cut', 'Copy' and 'Paste'
+ aContextMenu.EnableItem( SID_CUT, !m_bRootSelected && implAllowExchange( DND_ACTION_MOVE ) );
+ aContextMenu.EnableItem( SID_COPY, !m_bRootSelected && implAllowExchange( DND_ACTION_COPY ) );
+ aContextMenu.EnableItem( SID_PASTE, implAcceptPaste( ) );
+
+ // der TabDialog, wenn es genau ein Formular ist ...
+ aContextMenu.EnableItem( SID_FM_TAB_DIALOG, bSingleSelection && m_nFormsSelected );
+
+ // in XML forms, we don't allow for the properties of a form
+ // #i36484# / 2004-11-04 /- fs@openoffice.org
+ if ( pFormShell->GetImpl()->isEnhancedForm() && !m_nControlsSelected )
+ aContextMenu.RemoveItem( aContextMenu.GetItemPos( SID_FM_SHOW_PROPERTY_BROWSER ) );
+
+ // if the property browser is already open, we don't allow for the properties, too
+ if( pFormShell->GetImpl()->IsPropBrwOpen() )
+ aContextMenu.RemoveItem( aContextMenu.GetItemPos( SID_FM_SHOW_PROPERTY_BROWSER ) );
+ // and finally, if there's a mixed selection of forms and controls, disable the entry, too
+ else
+ aContextMenu.EnableItem( SID_FM_SHOW_PROPERTY_BROWSER,
+ (m_nControlsSelected && !m_nFormsSelected) || (!m_nControlsSelected && m_nFormsSelected) );
+
+ // Umbenennen gdw wenn ein Element und nicht die Root
+ aContextMenu.EnableItem( SID_FM_RENAME_OBJECT, bSingleSelection && !m_bRootSelected );
+
+ // der Reandonly-Eintrag ist nur auf der Root erlaubt
+ aContextMenu.EnableItem( SID_FM_OPEN_READONLY, m_bRootSelected );
+ // the same for automatic control focus
+ aContextMenu.EnableItem( SID_FM_AUTOCONTROLFOCUS, m_bRootSelected );
+
+ // die ConvertTo-Slots sind enabled, wenn genau ein Control selektiert ist, der
+ // dem Control entsprechende Slot ist disabled
+ if (!m_bRootSelected && !m_nFormsSelected && (m_nControlsSelected == 1))
+ {
+ aContextMenu.SetPopupMenu( SID_FM_CHANGECONTROLTYPE, FmXFormShell::GetConversionMenu() );
+#if OSL_DEBUG_LEVEL > 0
+ FmControlData* pCurrent = (FmControlData*)(m_arrCurrentSelection[0]->GetUserData());
+ OSL_ENSURE( pFormShell->GetImpl()->isSolelySelected( pCurrent->GetFormComponent() ),
+ "NavigatorTree::Command: inconsistency between the navigator selection, and the selection as the shell knows it!" );
+#endif
+
+ pFormShell->GetImpl()->checkControlConversionSlotsForCurrentSelection( *aContextMenu.GetPopupMenu( SID_FM_CHANGECONTROLTYPE ) );
+ }
+ else
+ aContextMenu.EnableItem( SID_FM_CHANGECONTROLTYPE, sal_False );
+
+ // jetzt alles, was disabled wurde, wech
+ aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
+ //////////////////////////////////////////////////////////
+ // OpenReadOnly setzen
+
+ aContextMenu.CheckItem( SID_FM_OPEN_READONLY, pFormModel->GetOpenInDesignMode() );
+ aContextMenu.CheckItem( SID_FM_AUTOCONTROLFOCUS, pFormModel->GetAutoControlFocus() );
+
+ sal_uInt16 nSlotId = aContextMenu.Execute( this, ptWhere );
+ switch( nSlotId )
+ {
+ case SID_FM_NEW_FORM:
+ {
+ XubString aStr(SVX_RES(RID_STR_FORM));
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+ aUndoStr.SearchAndReplace('#', aStr);
+
+ pFormModel->BegUndo(aUndoStr);
+ // der Slot war nur verfuegbar, wenn es genau einen selektierten Eintrag gibt und dieser die Root
+ // oder ein Formular ist
+ NewForm( m_arrCurrentSelection.GetObject(0) );
+ pFormModel->EndUndo();
+
+ } break;
+ case SID_FM_NEW_HIDDEN:
+ {
+ XubString aStr(SVX_RES(RID_STR_CONTROL));
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+ aUndoStr.SearchAndReplace('#', aStr);
+
+ pFormModel->BegUndo(aUndoStr);
+ // dieser Slot war guletig bei (genau) einem selektierten Formular
+ rtl::OUString fControlName = FM_COMPONENT_HIDDEN;
+ NewControl( fControlName, m_arrCurrentSelection.GetObject(0) );
+ pFormModel->EndUndo();
+
+ } break;
+
+ case SID_CUT:
+ doCut();
+ break;
+
+ case SID_COPY:
+ doCopy();
+ break;
+
+ case SID_PASTE:
+ doPaste();
+ break;
+
+ case SID_FM_DELETE:
+ {
+ DeleteSelection();
+ }
+ break;
+ case SID_FM_TAB_DIALOG:
+ {
+ // dieser Slot galt bei genau einem selektierten Formular
+ SvLBoxEntry* pSelectedForm = m_arrCurrentSelection.GetObject(0);
+ DBG_ASSERT( IsFormEntry(pSelectedForm), "NavigatorTree::Command: Dieser Eintrag muss ein FormEntry sein." );
+
+ FmFormData* pFormData = (FmFormData*)pSelectedForm->GetUserData();
+ Reference< XForm > xForm( pFormData->GetFormIface());
+
+ Reference< XTabControllerModel > xTabController(xForm, UNO_QUERY);
+ if( !xTabController.is() )
+ break;
+ GetNavModel()->GetFormShell()->GetImpl()->ExecuteTabOrderDialog( xTabController );
+ }
+ break;
+
+ case SID_FM_SHOW_PROPERTY_BROWSER:
+ {
+ ShowSelectionProperties(sal_True);
+ }
+ break;
+ case SID_FM_RENAME_OBJECT:
+ {
+ // das war bei genau einem Nicht-Root-Eintrag erlaubt
+ EditEntry( m_arrCurrentSelection.GetObject(0) );
+ }
+ break;
+ case SID_FM_OPEN_READONLY:
+ {
+ pFormModel->SetOpenInDesignMode( !pFormModel->GetOpenInDesignMode() );
+ pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_OPEN_READONLY);
+ }
+ break;
+ case SID_FM_AUTOCONTROLFOCUS:
+ {
+ pFormModel->SetAutoControlFocus( !pFormModel->GetAutoControlFocus() );
+ pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_AUTOCONTROLFOCUS);
+ }
+ break;
+ default:
+ if (pFormShell->GetImpl()->isControlConversionSlot(nSlotId))
+ {
+ FmControlData* pCurrent = (FmControlData*)(m_arrCurrentSelection[0]->GetUserData());
+ if ( pFormShell->GetImpl()->executeControlConversionSlot( pCurrent->GetFormComponent(), nSlotId ) )
+ ShowSelectionProperties();
+ }
+ }
+ }
+ bHandled = sal_True;
+ } break;
+ }
+
+ if (!bHandled)
+ SvTreeListBox::Command( rEvt );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTree::IsDeleteAllowed()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsDeleteAllowed" );
+ //////////////////////////////////////////////////////////////////////
+ // Haben wir eine Form...
+ SvLBoxEntry* pCurEntry = GetCurEntry();
+ sal_uInt32 nCurEntryPos = GetModel()->GetAbsPos( pCurEntry );
+
+ if( nCurEntryPos==0 ) // Root kann nicht geloescht werden
+ return sal_False;
+ else
+ return IsFormEntry(pCurEntry) || IsFormComponentEntry(pCurEntry);
+ }
+
+ //------------------------------------------------------------------------
+ SvLBoxEntry* NavigatorTree::FindEntry( FmEntryData* pEntryData )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::FindEntry" );
+ if( !pEntryData ) return NULL;
+ SvLBoxEntry* pCurEntry = First();
+ FmEntryData* pCurEntryData;
+ while( pCurEntry )
+ {
+ pCurEntryData = (FmEntryData*)pCurEntry->GetUserData();
+ if( pCurEntryData && pCurEntryData->IsEqualWithoutChilds(pEntryData) )
+ return pCurEntry;
+
+ pCurEntry = Next( pCurEntry );
+ }
+
+ return NULL;
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Notify" );
+ if( rHint.ISA(FmNavRemovedHint) )
+ {
+ FmNavRemovedHint* pRemovedHint = (FmNavRemovedHint*)&rHint;
+ FmEntryData* pEntryData = pRemovedHint->GetEntryData();
+ Remove( pEntryData );
+ }
+
+ else if( rHint.ISA(FmNavInsertedHint) )
+ {
+ FmNavInsertedHint* pInsertedHint = (FmNavInsertedHint*)&rHint;
+ FmEntryData* pEntryData = pInsertedHint->GetEntryData();
+ sal_uInt32 nRelPos = pInsertedHint->GetRelPos();
+ Insert( pEntryData, nRelPos );
+ }
+
+ else if( rHint.ISA(FmNavModelReplacedHint) )
+ {
+ FmEntryData* pData = ((FmNavModelReplacedHint*)&rHint)->GetEntryData();
+ SvLBoxEntry* pEntry = FindEntry( pData );
+ if (pEntry)
+ { // das Image neu setzen
+ SetCollapsedEntryBmp( pEntry, pData->GetNormalImage(), BMP_COLOR_NORMAL );
+ SetExpandedEntryBmp( pEntry, pData->GetNormalImage(), BMP_COLOR_NORMAL );
+
+ SetCollapsedEntryBmp( pEntry, pData->GetHCImage(), BMP_COLOR_HIGHCONTRAST );
+ SetExpandedEntryBmp( pEntry, pData->GetHCImage(), BMP_COLOR_HIGHCONTRAST );
+ }
+ }
+
+ else if( rHint.ISA(FmNavNameChangedHint) )
+ {
+ FmNavNameChangedHint* pNameChangedHint = (FmNavNameChangedHint*)&rHint;
+ SvLBoxEntry* pEntry = FindEntry( pNameChangedHint->GetEntryData() );
+ SetEntryText( pEntry, pNameChangedHint->GetNewName() );
+ }
+
+ else if( rHint.ISA(FmNavClearedHint) )
+ {
+ SvTreeListBox::Clear();
+
+ //////////////////////////////////////////////////////////////////////
+ // Default-Eintrag "Formulare"
+ Image aRootImage( m_aNavigatorImages.GetImage( RID_SVXIMG_FORMS ) );
+ m_pRootEntry = InsertEntry( SVX_RES(RID_STR_FORMS), aRootImage, aRootImage,
+ NULL, sal_False, 0, NULL );
+
+ if ( m_pRootEntry )
+ {
+ Image aHCRootImage( m_aNavigatorImagesHC.GetImage( RID_SVXIMG_FORMS ) );
+ SetExpandedEntryBmp( m_pRootEntry, aHCRootImage, BMP_COLOR_HIGHCONTRAST );
+ SetCollapsedEntryBmp( m_pRootEntry, aHCRootImage, BMP_COLOR_HIGHCONTRAST );
+ }
+ }
+ else if (!m_bMarkingObjects && rHint.ISA(FmNavRequestSelectHint))
+ { // wenn m_bMarkingObjects sal_True ist, markiere ich gerade selber Objekte, und da der ganze Mechanismus dahinter synchron ist,
+ // ist das genau der Hint, der durch mein Markieren ausgeloest wird, also kann ich ihn ignorieren
+ FmNavRequestSelectHint* pershHint = (FmNavRequestSelectHint*)&rHint;
+ FmEntryDataArray& arredToSelect = pershHint->GetItems();
+ SynchronizeSelection(arredToSelect);
+
+ if (pershHint->IsMixedSelection())
+ // in diesem Fall habe ich alles deselektiert, obwohl die View u.U. eine gemischte Markierung hatte
+ // ich muss also im naechsten Select den Navigator an die View anpassen
+ m_bPrevSelectionMixed = sal_True;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ SvLBoxEntry* NavigatorTree::Insert( FmEntryData* pEntryData, ULONG nRelPos )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Insert" );
+ //////////////////////////////////////////////////////////////////////
+ // Aktuellen Eintrag einfuegen
+ SvLBoxEntry* pParentEntry = FindEntry( pEntryData->GetParent() );
+ SvLBoxEntry* pNewEntry;
+
+ if( !pParentEntry )
+ pNewEntry = InsertEntry( pEntryData->GetText(),
+ pEntryData->GetNormalImage(), pEntryData->GetNormalImage(),
+ m_pRootEntry, sal_False, nRelPos, pEntryData );
+
+ else
+ pNewEntry = InsertEntry( pEntryData->GetText(),
+ pEntryData->GetNormalImage(), pEntryData->GetNormalImage(),
+ pParentEntry, sal_False, nRelPos, pEntryData );
+
+ if ( pNewEntry )
+ {
+ SetExpandedEntryBmp( pNewEntry, pEntryData->GetHCImage(), BMP_COLOR_HIGHCONTRAST );
+ SetCollapsedEntryBmp( pNewEntry, pEntryData->GetHCImage(), BMP_COLOR_HIGHCONTRAST );
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Root-Eintrag Root expandieren
+ if( !pParentEntry )
+ Expand( m_pRootEntry );
+
+ //////////////////////////////////////////////////////////////////////
+ // Childs einfuegen
+ FmEntryDataList* pChildList = pEntryData->GetChildList();
+ sal_uInt32 nChildCount = pChildList->Count();
+ FmEntryData* pChildData;
+ for( sal_uInt32 i=0; i<nChildCount; i++ )
+ {
+ pChildData = pChildList->GetObject(i);
+ Insert( pChildData, LIST_APPEND );
+ }
+
+ return pNewEntry;
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::Remove( FmEntryData* pEntryData )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Remove" );
+ if( !pEntryData )
+ return;
+
+ // der Entry zu den Daten
+ SvLBoxEntry* pEntry = FindEntry( pEntryData );
+ if (!pEntry)
+ return;
+
+ // Eintrag aus TreeListBox entfernen
+ // ich darf das Select, das ich ausloese, nicht behandeln :
+ // Select aendert die MarkList der View, wenn das gerade auch jemand anders macht und dabei ein Remove
+ // triggert, haben wir mit ziemlicher Sicherheit ein Problem - Paradebeispiel war das Gruppieren von Controls mit
+ // offenem Navigator ...)
+ LockSelectionHandling();
+
+ // ein kleines Problem : ich merke mir meine selektierten Daten, wenn mir jetzt jemand einen selektierten Eintrag
+ // unter dem Hintern wegschiesst, werde ich inkonsistent ... was schlecht waere
+ Select(pEntry, sal_False);
+
+ // beim eigentlichen Entfernen kann die Selection geaendert werden, da ich aber das SelectionHandling abgeschaltet
+ // habe, muss ich mich hinterher darum kuemmern
+ ULONG nExpectedSelectionCount = GetSelectionCount();
+
+ if( pEntry )
+ GetModel()->Remove( pEntry );
+
+ if (nExpectedSelectionCount != GetSelectionCount())
+ SynchronizeSelection();
+
+ // und standardmaessig behandle ich das Select natuerlich
+ UnlockSelectionHandling();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTree::IsFormEntry( SvLBoxEntry* pEntry )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsFormEntry" );
+ FmEntryData* pEntryData = (FmEntryData*)pEntry->GetUserData();
+ return !pEntryData || pEntryData->ISA(FmFormData);
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTree::IsFormComponentEntry( SvLBoxEntry* pEntry )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsFormComponentEntry" );
+ FmEntryData* pEntryData = (FmEntryData*)pEntry->GetUserData();
+ return pEntryData && pEntryData->ISA(FmControlData);
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTree::implAcceptPaste( )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAcceptPaste" );
+ SvLBoxEntry* pFirstSelected = FirstSelected();
+ if ( !pFirstSelected || NextSelected( pFirstSelected ) )
+ // no selected entry, or at least two selected entries
+ return sal_False;
+
+ // get the clipboard
+ TransferableDataHelper aClipboardContent( TransferableDataHelper::CreateFromSystemClipboard( this ) );
+
+ sal_Int8 nAction = m_aControlExchange.isClipboardOwner() && doingKeyboardCut( ) ? DND_ACTION_MOVE : DND_ACTION_COPY;
+ return ( nAction == implAcceptDataTransfer( aClipboardContent.GetDataFlavorExVector(), nAction, pFirstSelected, sal_False ) );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int8 NavigatorTree::implAcceptDataTransfer( const DataFlavorExVector& _rFlavors, sal_Int8 _nAction, const ::Point& _rDropPos, sal_Bool _bDnD )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAcceptDataTransfer" );
+ return implAcceptDataTransfer( _rFlavors, _nAction, GetEntry( _rDropPos ), _bDnD );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int8 NavigatorTree::implAcceptDataTransfer( const DataFlavorExVector& _rFlavors, sal_Int8 _nAction, SvLBoxEntry* _pTargetEntry, sal_Bool _bDnD )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implAcceptDataTransfer" );
+ // no target -> no drop
+ if (!_pTargetEntry)
+ return DND_ACTION_NONE;
+
+ // format check
+ sal_Bool bHasDefControlFormat = OControlExchange::hasFieldExchangeFormat( _rFlavors );
+ sal_Bool bHasControlPathFormat = OControlExchange::hasControlPathFormat( _rFlavors );
+ sal_Bool bHasHiddenControlsFormat = OControlExchange::hasHiddenControlModelsFormat( _rFlavors );
+ if (!bHasDefControlFormat && !bHasControlPathFormat && !bHasHiddenControlsFormat)
+ return DND_ACTION_NONE;
+
+ sal_Bool bSelfSource = _bDnD ? m_aControlExchange.isDragSource() : m_aControlExchange.isClipboardOwner();
+
+ if ( bHasHiddenControlsFormat )
+ { // bHasHiddenControlsFormat means that only hidden controls are part of the data
+
+ // hidden controls can be copied to a form only
+ if ( !_pTargetEntry || ( _pTargetEntry == m_pRootEntry ) || !IsFormEntry( _pTargetEntry ) )
+ return DND_ACTION_NONE;
+
+ return bSelfSource ? ( DND_ACTION_COPYMOVE & _nAction ) : DND_ACTION_COPY;
+ }
+
+ if ( !bSelfSource )
+ {
+ // DnD or CnP crossing navigator boundaries
+ // The main problem here is that the current API does not allow us to sneak into the content which
+ // is to be inserted. So we have to allow it for the moment, but maybe reject later on (in the real drop).
+
+ // TODO: this smart behaviour later on ... at the moment, we disallow data transfer crossing navigator
+ // boundaries.
+
+ return DND_ACTION_NONE;
+ }
+
+ DBG_ASSERT( _bDnD ? m_aControlExchange.isDragSource() : m_aControlExchange.isClipboardOwner(),
+ "NavigatorTree::implAcceptDataTransfer: here only with source=dest!" );
+ // somebody changed the logic of this method ...
+
+ // from here on, I can work with m_aControlExchange instead of _rData!
+
+ sal_Bool bForeignCollection = m_aControlExchange->getFormsRoot().get() != GetNavModel()->GetFormPage()->GetForms().get();
+ if ( bForeignCollection )
+ {
+ // crossing shell/page boundaries, we can exchange hidden controls only
+ // But if we survived the checks above, we do not have hidden controls.
+ // -> no data transfer
+ DBG_ASSERT( !bHasHiddenControlsFormat, "NavigatorTree::implAcceptDataTransfer: still hidden controls format!" );
+ // somebody changed the logic of this method ...
+
+ return DND_ACTION_COPY;
+ }
+
+ if (DND_ACTION_MOVE != _nAction) // 'normal' controls within a shell are moved only (never copied)
+ return DND_ACTION_NONE;
+
+ if ( m_bDragDataDirty || !bHasDefControlFormat )
+ {
+ if (!bHasControlPathFormat)
+ // ich befinde mich zwar in der Shell/Page, aus der die Controls stammen, habe aber kein Format, das den stattgefundenen
+ // Shell-Wechsel ueberlebt hat (SVX_FM_CONTROLS_AS_PATH)
+ return DND_ACTION_NONE;
+
+ // da die Shell waehrend des Draggens umgeschaltet wude, muss ich die Liste des ExchangeObjektes wieder neu aufbauen
+ // (dort stehen SvLBoxEntries drin, und die sind bei der Umschaltung floeten gegangen)
+ m_aControlExchange->buildListFromPath(this, m_pRootEntry);
+ m_bDragDataDirty = sal_False;
+ }
+
+ // die Liste der gedroppten Eintraege aus dem DragServer
+ const ListBoxEntrySet& aDropped = m_aControlExchange->selected();
+ DBG_ASSERT(aDropped.size() >= 1, "NavigatorTree::implAcceptDataTransfer: keine Eintraege !");
+
+ sal_Bool bDropTargetIsComponent = IsFormComponentEntry( _pTargetEntry );
+ //SvLBoxEntry* pDropTargetParent = GetParent( _pTargetEntry );
+
+ // conditions to disallow the drop
+ // 0) the root entry is part of the list (can't DnD the root!)
+ // 1) one of the draged entries is to be dropped onto it's own parent
+ // 2) - " - is to be dropped onto itself
+ // 3) - " - is a Form and to be dropped onto one of it's descendants
+ // 4) one of the entries is a control and to be dropped onto the root
+ // 5) a control or form will be dropped onto a control which is _not_ a sibling (dropping onto a sibling
+ // means moving the control)
+
+ // collect the ancestors of the drop targte (speeds up 3)
+ SvLBoxEntrySortedArray arrDropAnchestors;
+ SvLBoxEntry* pLoop = _pTargetEntry;
+ while (pLoop)
+ {
+ arrDropAnchestors.Insert(pLoop);
+ pLoop = GetParent(pLoop);
+ }
+
+ for ( ListBoxEntrySet::const_iterator dropped = aDropped.begin();
+ dropped != aDropped.end();
+ ++dropped
+ )
+ {
+ SvLBoxEntry* pCurrent = *dropped;
+ SvLBoxEntry* pCurrentParent = GetParent(pCurrent);
+
+ // test for 0)
+ if (pCurrent == m_pRootEntry)
+ return DND_ACTION_NONE;
+
+ // test for 1)
+ if ( _pTargetEntry == pCurrentParent )
+ return DND_ACTION_NONE;
+
+ // test for 2)
+ if (pCurrent == _pTargetEntry)
+ return DND_ACTION_NONE;
+
+ // test for 5)
+ // if ( bDropTargetIsComponent && (pDropTargetParent != pCurrentParent) )
+ if ( bDropTargetIsComponent ) // TODO : die obige Zeile wieder rein, dann muss aber ExecuteDrop das Vertauschen auch beherrschen
+ return DND_ACTION_NONE;
+
+ // test for 3)
+ if ( IsFormEntry(pCurrent) )
+ {
+ sal_uInt16 nPosition;
+ if ( arrDropAnchestors.Seek_Entry(pCurrent, &nPosition) )
+ return DND_ACTION_NONE;
+ } else if ( IsFormComponentEntry(pCurrent) )
+ {
+ // test for 4)
+ if (_pTargetEntry == m_pRootEntry)
+ return DND_ACTION_NONE;
+ }
+ }
+
+ return DND_ACTION_MOVE;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int8 NavigatorTree::AcceptDrop( const AcceptDropEvent& rEvt )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::AcceptDrop" );
+ ::Point aDropPos = rEvt.maPosPixel;
+
+ // kuemmern wir uns erst mal um moeglich DropActions (Scrollen und Aufklappen)
+ if (rEvt.mbLeaving)
+ {
+ if (m_aDropActionTimer.IsActive())
+ m_aDropActionTimer.Stop();
+ } else
+ {
+ sal_Bool bNeedTrigger = sal_False;
+ // auf dem ersten Eintrag ?
+ if ((aDropPos.Y() >= 0) && (aDropPos.Y() < GetEntryHeight()))
+ {
+ m_aDropActionType = DA_SCROLLUP;
+ bNeedTrigger = sal_True;
+ } else
+ // auf dem letzten (bzw. in dem Bereich, den ein Eintrag einnehmen wuerde, wenn er unten genau buendig
+ // abschliessen wuerde) ?
+ if ((aDropPos.Y() < GetSizePixel().Height()) && (aDropPos.Y() >= GetSizePixel().Height() - GetEntryHeight()))
+ {
+ m_aDropActionType = DA_SCROLLDOWN;
+ bNeedTrigger = sal_True;
+ } else
+ { // auf einem Entry mit Childs, der nicht aufgeklappt ist ?
+ SvLBoxEntry* pDropppedOn = GetEntry(aDropPos);
+ if (pDropppedOn && (GetChildCount(pDropppedOn) > 0) && !IsExpanded(pDropppedOn))
+ {
+ // -> aufklappen
+ m_aDropActionType = DA_EXPANDNODE;
+ bNeedTrigger = sal_True;
+ }
+ }
+
+ if (bNeedTrigger && (m_aTimerTriggered != aDropPos))
+ {
+ // neu anfangen zu zaehlen
+ m_aTimerCounter = DROP_ACTION_TIMER_INITIAL_TICKS;
+ // die Pos merken, da ich auch AcceptDrops bekomme, wenn sich die Maus gar nicht bewegt hat
+ m_aTimerTriggered = aDropPos;
+ // und den Timer los
+ if (!m_aDropActionTimer.IsActive()) // gibt es den Timer schon ?
+ {
+ m_aDropActionTimer.SetTimeout(DROP_ACTION_TIMER_TICK_BASE);
+ m_aDropActionTimer.Start();
+ }
+ } else if (!bNeedTrigger)
+ m_aDropActionTimer.Stop();
+ }
+
+ return implAcceptDataTransfer( GetDataFlavorExVector(), rEvt.mnAction, aDropPos, sal_True );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int8 NavigatorTree::implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, const ::Point& _rDropPos, sal_Bool _bDnD )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implExecuteDataTransfer" );
+ return implExecuteDataTransfer( _rData, _nAction, GetEntry( _rDropPos ), _bDnD );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int8 NavigatorTree::implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, SvLBoxEntry* _pTargetEntry, sal_Bool _bDnD )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::implExecuteDataTransfer" );
+ const DataFlavorExVector& rDataFlavors = _rData.GetDataFlavorExVector();
+
+ if ( DND_ACTION_NONE == implAcceptDataTransfer( rDataFlavors, _nAction, _pTargetEntry, _bDnD ) )
+ // under some platforms, it may happen that ExecuteDrop is called though AcceptDrop returned DND_ACTION_NONE
+ return DND_ACTION_NONE;
+
+ // ware schlecht, wenn nach dem Droppen noch gescrollt wird ...
+ if (m_aDropActionTimer.IsActive())
+ m_aDropActionTimer.Stop();
+
+ if (!_pTargetEntry)
+ // no target -> no drop
+ return DND_ACTION_NONE;
+
+ // format checks
+#ifdef DBG_UTIL
+ sal_Bool bHasHiddenControlsFormat = OControlExchange::hasHiddenControlModelsFormat( rDataFlavors );
+ sal_Bool bForeignCollection = _rData.getFormsRoot().get() != GetNavModel()->GetFormPage()->GetForms().get();
+ DBG_ASSERT(!bForeignCollection || bHasHiddenControlsFormat, "NavigatorTree::implExecuteDataTransfer: invalid format (AcceptDrop shouldn't have let this pass) !");
+ DBG_ASSERT(bForeignCollection || !m_bDragDataDirty, "NavigatorTree::implExecuteDataTransfer: invalid state (shell changed since last exchange resync) !");
+ // das sollte in AcceptDrop erledigt worden sein : dort wird in _rData die Liste der Controls aufgebaut und m_bDragDataDirty
+ // zurueckgesetzt
+#endif
+
+ if ( DND_ACTION_COPY == _nAction )
+ { // bHasHiddenControlsFormat means that only hidden controls are part of the data
+ DBG_ASSERT( bHasHiddenControlsFormat, "NavigatorTree::implExecuteDataTransfer: copy allowed for hidden controls only!" );
+ DBG_ASSERT( _pTargetEntry && ( _pTargetEntry != m_pRootEntry ) && IsFormEntry( _pTargetEntry ),
+ "NavigatorTree::implExecuteDataTransfer: should not be here!" );
+ // implAcceptDataTransfer should have caught both cases
+
+ DBG_ASSERT(bHasHiddenControlsFormat, "NavigatorTree::implExecuteDataTransfer: only copying of hidden controls is supported !");
+ // das sollte das AcceptDrop abgefangen haben
+
+ // da ich gleich die Zielobjekte alle selektieren will (und nur die)
+ SelectAll(sal_False);
+
+ Sequence< Reference< XInterface > > aControls = _rData.hiddenControls();
+ sal_Int32 nCount = aControls.getLength();
+ const Reference< XInterface >* pControls = aControls.getConstArray();
+
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ FmFormModel* pFormModel = pFormShell ? pFormShell->GetFormModel() : NULL;
+
+ // innerhalb eines Undo ...
+ if (pFormModel)
+ {
+ XubString aStr(SVX_RES(RID_STR_CONTROL));
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+ aUndoStr.SearchAndReplace('#', aStr);
+ pFormModel->BegUndo(aUndoStr);
+ }
+
+ // die Conrtols kopieren
+ for (sal_Int32 i=0; i<nCount; ++i)
+ {
+ // neues Control anlegen
+ rtl::OUString fControlName = FM_COMPONENT_HIDDEN;
+ FmControlData* pNewControlData = NewControl( fControlName, _pTargetEntry, sal_False);
+ Reference< XPropertySet > xNewPropSet( pNewControlData->GetPropertySet() );
+
+ // und die Properties des alten in das neue kopieren
+ Reference< XPropertySet > xCurrent(pControls[i], UNO_QUERY);
+#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
+ // nur mal eben sehen, ob das Ding tatsaechlich ein hidden control ist
+ sal_Int16 nClassId = ::comphelper::getINT16(xCurrent->getPropertyValue(FM_PROP_CLASSID));
+ OSL_ENSURE(nClassId == FormComponentType::HIDDENCONTROL, "NavigatorTree::implExecuteDataTransfer: invalid control in drop list !");
+ // wenn das SVX_FM_HIDDEN_CONTROLS-Format vorhanden ist, dann sollten wirklich nur hidden controls in der Sequenz
+ // stecken
+#endif // (OSL_DEBUG_LEVEL > 1) || DBG_UTIL
+ Reference< XPropertySetInfo > xPropInfo( xCurrent->getPropertySetInfo());
+ Sequence< Property> seqAllCurrentProps = xPropInfo->getProperties();
+ Property* pAllCurrentProps = seqAllCurrentProps.getArray();
+ for (sal_Int32 j=0; j<seqAllCurrentProps.getLength(); ++j)
+ {
+ ::rtl::OUString sCurrentProp = pAllCurrentProps[j].Name;
+ if (((pAllCurrentProps[j].Attributes & PropertyAttribute::READONLY) == 0) && (sCurrentProp != FM_PROP_NAME))
+ { // (read-only attribs werden natuerlich nicht gesetzt, dito der Name, den hat das NewControl schon eindeutig
+ // festgelegt)
+ xNewPropSet->setPropertyValue(sCurrentProp, xCurrent->getPropertyValue(sCurrentProp));
+ }
+ }
+
+ SvLBoxEntry* pToSelect = FindEntry(pNewControlData);
+ Select(pToSelect, sal_True);
+ if (i == 0)
+ SetCurEntry(pToSelect);
+ }
+
+ if (pFormModel)
+ pFormModel->EndUndo();
+
+ return _nAction;
+ }
+
+ if ( !OControlExchange::hasFieldExchangeFormat( _rData.GetDataFlavorExVector() ) )
+ {
+ // can't do anything without the internal format here ... usually happens when doing DnD or CnP
+ // over navigator boundaries
+ return DND_ACTION_NONE;
+ }
+
+ // some data for the target
+ sal_Bool bDropTargetIsForm = IsFormEntry(_pTargetEntry);
+ FmFormData* pTargetData = bDropTargetIsForm ? (FmFormData*)_pTargetEntry->GetUserData() : NULL;
+
+ DBG_ASSERT( DND_ACTION_COPY != _nAction, "NavigatorTree::implExecuteDataTransfer: somebody changed the logics!" );
+
+ // die Liste der gedraggten Eintraege
+ ListBoxEntrySet aDropped = _rData.selected();
+ DBG_ASSERT(aDropped.size() >= 1, "NavigatorTree::implExecuteDataTransfer: no entries!");
+
+ // die Shell und das Model
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ FmFormModel* pFormModel = pFormShell ? pFormShell->GetFormModel() : NULL;
+ if (!pFormModel)
+ return DND_ACTION_NONE;
+
+ // fuer's Undo
+ const bool bUndo = pFormModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString strUndoDescription(SVX_RES(RID_STR_UNDO_CONTAINER_REPLACE));
+ pFormModel->BegUndo(strUndoDescription);
+ }
+
+ // ich nehme vor dem Einfuegen eines Eintrages seine Selection raus, damit die Markierung dabei nicht flackert
+ // -> das Handeln des Select locken
+ LockSelectionHandling();
+
+ // jetzt durch alle gedroppten Eintraege ...
+ for ( ListBoxEntrySet::const_iterator dropped = aDropped.begin();
+ dropped != aDropped.end();
+ ++dropped
+ )
+ {
+ // ein paar Daten zum aktuellen Element
+ SvLBoxEntry* pCurrent = *dropped;
+ DBG_ASSERT(pCurrent != NULL, "NavigatorTree::implExecuteDataTransfer: ungueltiger Eintrag");
+ DBG_ASSERT(GetParent(pCurrent) != NULL, "NavigatorTree::implExecuteDataTransfer: ungueltiger Eintrag");
+ // die Root darf nicht gedraggt werden
+
+ FmEntryData* pCurrentUserData = (FmEntryData*)pCurrent->GetUserData();
+
+ Reference< XChild > xCurrentChild(pCurrentUserData->GetChildIFace(), UNO_QUERY);
+ Reference< XIndexContainer > xContainer(xCurrentChild->getParent(), UNO_QUERY);
+
+ FmFormData* pCurrentParentUserData = (FmFormData*)pCurrentUserData->GetParent();
+ DBG_ASSERT(pCurrentParentUserData == NULL || pCurrentParentUserData->ISA(FmFormData), "NavigatorTree::implExecuteDataTransfer: ungueltiges Parent");
+
+ // beim Vater austragen
+ if (pCurrentParentUserData)
+ pCurrentParentUserData->GetChildList()->Remove(pCurrentUserData);
+ else
+ GetNavModel()->GetRootList()->Remove(pCurrentUserData);
+
+ // aus dem Container entfernen
+ sal_Int32 nIndex = getElementPos(Reference< XIndexAccess > (xContainer, UNO_QUERY), xCurrentChild);
+ GetNavModel()->m_pPropChangeList->Lock();
+ // die Undo-Action fuer das Rausnehmen
+ if ( bUndo && GetNavModel()->m_pPropChangeList->CanUndo())
+ {
+ pFormModel->AddUndo(new FmUndoContainerAction(*pFormModel, FmUndoContainerAction::Removed,
+ xContainer, xCurrentChild, nIndex));
+ }
+ else if( !GetNavModel()->m_pPropChangeList->CanUndo() )
+ {
+ FmUndoContainerAction::DisposeElement( xCurrentChild );
+ }
+
+ // Events mitkopieren
+ Reference< XEventAttacherManager > xManager(xContainer, UNO_QUERY);
+ Sequence< ScriptEventDescriptor > aEvts;
+
+ if (xManager.is() && nIndex >= 0)
+ aEvts = xManager->getScriptEvents(nIndex);
+ xContainer->removeByIndex(nIndex);
+
+ // die Selection raus
+ Select(pCurrent, sal_False);
+ // und weg
+ Remove(pCurrentUserData);
+
+ // die Stelle innerhalb des DropParents, an der ich die gedroppten Eintraege einfuegen muss
+ if (pTargetData)
+ xContainer = Reference< XIndexContainer > (pTargetData->GetElement(), UNO_QUERY);
+ else
+ xContainer = Reference< XIndexContainer > (GetNavModel()->GetForms(), UNO_QUERY);
+
+ // immer ganz hinten einfuegen
+ nIndex = xContainer->getCount();
+
+ // UndoAction fuer das Einfuegen
+ if ( bUndo && GetNavModel()->m_pPropChangeList->CanUndo())
+ pFormModel->AddUndo(new FmUndoContainerAction(*pFormModel, FmUndoContainerAction::Inserted,
+ xContainer, xCurrentChild, nIndex));
+
+ // einfuegen im neuen Container
+ if (pTargetData)
+ {
+ // es wird in eine Form eingefuegt, dann brauche ich eine FormComponent
+ xContainer->insertByIndex( nIndex,
+ makeAny( Reference< XFormComponent >( xCurrentChild, UNO_QUERY ) ) );
+ }
+ else
+ {
+ xContainer->insertByIndex( nIndex,
+ makeAny( Reference< XForm >( xCurrentChild, UNO_QUERY ) ) );
+ }
+
+ if (aEvts.getLength())
+ {
+ xManager = Reference< XEventAttacherManager > (xContainer, UNO_QUERY);
+ if (xManager.is())
+ xManager->registerScriptEvents(nIndex, aEvts);
+ }
+
+ GetNavModel()->m_pPropChangeList->UnLock();
+
+ // zuerst dem Eintrag das neue Parent
+ pCurrentUserData->SetParent(pTargetData);
+
+ // dann dem Parent das neue Child
+ if (pTargetData)
+ pTargetData->GetChildList()->Insert(pCurrentUserData, nIndex);
+ else
+ GetNavModel()->GetRootList()->Insert(pCurrentUserData, nIndex);
+
+ // dann bei mir selber bekanntgeben und neu selektieren
+ SvLBoxEntry* pNew = Insert( pCurrentUserData, nIndex );
+ if ( ( aDropped.begin() == dropped ) && pNew )
+ {
+ SvLBoxEntry* pParent = GetParent( pNew );
+ if ( pParent )
+ Expand( pParent );
+ }
+ }
+
+ UnlockSelectionHandling();
+
+ if( bUndo )
+ pFormModel->EndUndo();
+
+ // During the move, the markings of the underlying view did not change (because the view is not affected by the logical
+ // hierarchy of the form/control models. But my selection changed - which means I have to adjust it according to the
+ // view marks, again.
+ SynchronizeSelection();
+
+ // in addition, with the move of controls such things as "the current form" may have changed - force the shell
+ // to update itself accordingly
+ if( pFormShell && pFormShell->GetImpl() && pFormShell->GetFormView() )
+ pFormShell->GetImpl()->DetermineSelection( pFormShell->GetFormView()->GetMarkedObjectList() );
+
+ if ( m_aControlExchange.isClipboardOwner() && ( DND_ACTION_MOVE == _nAction ) )
+ m_aControlExchange->clear();
+
+ return _nAction;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int8 NavigatorTree::ExecuteDrop( const ExecuteDropEvent& rEvt )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::ExecuteDrop" );
+ sal_Int8 nResult( DND_ACTION_NONE );
+
+ if ( m_aControlExchange.isDragSource() )
+ nResult = implExecuteDataTransfer( *m_aControlExchange, rEvt.mnAction, rEvt.maPosPixel, sal_True );
+ else
+ {
+ OControlTransferData aDroppedData( rEvt.maDropEvent.Transferable );
+ nResult = implExecuteDataTransfer( aDroppedData, rEvt.mnAction, rEvt.maPosPixel, sal_True );
+ }
+
+ return nResult;
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::doPaste()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::doPaste" );
+ try
+ {
+ if ( m_aControlExchange.isClipboardOwner() )
+ {
+ implExecuteDataTransfer( *m_aControlExchange, doingKeyboardCut( ) ? DND_ACTION_MOVE : DND_ACTION_COPY, FirstSelected(), sal_False );
+ }
+ else
+ {
+ // the clipboard content
+ Reference< XClipboard > xClipboard( GetClipboard() );
+ Reference< XTransferable > xTransferable;
+ if ( xClipboard.is() )
+ xTransferable = xClipboard->getContents();
+
+ OControlTransferData aClipboardContent( xTransferable );
+ implExecuteDataTransfer( aClipboardContent, DND_ACTION_COPY, FirstSelected(), sal_False );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "NavigatorTree::doPaste: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::doCopy()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::doCopy" );
+ if ( implPrepareExchange( DND_ACTION_COPY ) )
+ {
+ m_aControlExchange.setClipboardListener( LINK( this, NavigatorTree, OnClipboardAction ) );
+ m_aControlExchange.copyToClipboard( );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::ModelHasRemoved( SvListEntry* _pEntry )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::ModelHasRemoved" );
+ SvLBoxEntry* pTypedEntry = static_cast< SvLBoxEntry* >( _pEntry );
+ if ( doingKeyboardCut() )
+ m_aCutEntries.erase( pTypedEntry );
+
+ if ( m_aControlExchange.isDataExchangeActive() )
+ {
+ if ( 0 == m_aControlExchange->onEntryRemoved( pTypedEntry ) )
+ {
+ // last of the entries which we put into the clipboard has been deleted from the tree.
+ // Give up the clipboard ownership.
+ m_aControlExchange.clear();
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::doCut()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::doCut" );
+ if ( implPrepareExchange( DND_ACTION_MOVE ) )
+ {
+ m_aControlExchange.setClipboardListener( LINK( this, NavigatorTree, OnClipboardAction ) );
+ m_aControlExchange.copyToClipboard( );
+ m_bKeyboardCut = sal_True;
+
+ // mark all the entries we just "cut" into the clipboard as "nearly moved"
+ for ( sal_Int32 i=0; i<m_arrCurrentSelection.Count(); ++i )
+ {
+ SvLBoxEntry* pEntry = m_arrCurrentSelection[ (sal_uInt16)i ];
+ if ( pEntry )
+ {
+ m_aCutEntries.insert( pEntry );
+ pEntry->SetFlags( pEntry->GetFlags() | SV_ENTRYFLAG_SEMITRANSPARENT );
+ InvalidateEntry( pEntry );
+ }
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::KeyInput(const ::KeyEvent& rKEvt)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::KeyInput" );
+ const KeyCode& rCode = rKEvt.GetKeyCode();
+
+ // delete?
+ if (rKEvt.GetKeyCode().GetCode() == KEY_DELETE && !rKEvt.GetKeyCode().GetModifier())
+ {
+ DeleteSelection();
+ return;
+ }
+
+ // copy'n'paste?
+ switch ( rCode.GetFunction() )
+ {
+ case KEYFUNC_CUT:
+ doCut();
+ break;
+
+ case KEYFUNC_PASTE:
+ if ( implAcceptPaste() )
+ doPaste();
+ break;
+
+ case KEYFUNC_COPY:
+ doCopy();
+ break;
+
+ default:
+ break;
+ }
+
+ SvTreeListBox::KeyInput(rKEvt);
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTree::EditingEntry( SvLBoxEntry* pEntry, Selection& rSelection )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::EditingEntry" );
+ if (!SvTreeListBox::EditingEntry( pEntry, rSelection ))
+ return sal_False;
+
+ return (pEntry && (pEntry->GetUserData() != NULL));
+ // die Wurzel, die ich nicht umbenennen darf, hat als UserData NULL
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::NewForm( SvLBoxEntry* pParentEntry )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::NewForm" );
+ //////////////////////////////////////////////////////////////////////
+ // ParentFormData holen
+ if( !IsFormEntry(pParentEntry) )
+ return;
+
+ FmFormData* pParentFormData = (FmFormData*)pParentEntry->GetUserData();
+
+ //////////////////////////////////////////////////////////////////////
+ // Neue Form erzeugen
+ Reference< XForm > xNewForm(m_xORB->createInstance(FM_SUN_COMPONENT_FORM), UNO_QUERY);
+ if (!xNewForm.is())
+ return;
+
+ FmFormData* pNewFormData = new FmFormData( xNewForm, m_aNavigatorImages, m_aNavigatorImagesHC, pParentFormData );
+
+ //////////////////////////////////////////////////////////////////////
+ // Namen setzen
+ ::rtl::OUString aName = GenerateName(pNewFormData);
+ pNewFormData->SetText(aName);
+
+ Reference< XPropertySet > xPropertySet(xNewForm, UNO_QUERY);
+ if (!xPropertySet.is())
+ return;
+ try
+ {
+ xPropertySet->setPropertyValue( FM_PROP_NAME, makeAny(aName) );
+ // a form should always have the command type table as default
+ xPropertySet->setPropertyValue( FM_PROP_COMMANDTYPE, makeAny(sal_Int32(CommandType::TABLE)));
+ }
+ catch ( const Exception& )
+ {
+ DBG_ERROR("NavigatorTree::NewForm : could not set esssential properties !");
+ }
+
+
+ //////////////////////////////////////////////////////////////////////
+ // Form einfuegen
+ GetNavModel()->Insert( pNewFormData, LIST_APPEND, sal_True );
+
+ //////////////////////////////////////////////////////////////////////
+ // Neue Form als aktive Form setzen
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ if( pFormShell )
+ {
+ InterfaceBag aSelection;
+ aSelection.insert( Reference< XInterface >( xNewForm, UNO_QUERY ) );
+ pFormShell->GetImpl()->setCurrentSelection( aSelection );
+
+ pFormShell->GetViewShell()->GetViewFrame()->GetBindings().Invalidate(SID_FM_PROPERTIES,sal_True,sal_True);
+ }
+ GetNavModel()->SetModified();
+
+ //////////////////////////////////////////////////////////////////////
+ // In EditMode schalten
+ SvLBoxEntry* pNewEntry = FindEntry( pNewFormData );
+ EditEntry( pNewEntry );
+ }
+
+ //------------------------------------------------------------------------
+ FmControlData* NavigatorTree::NewControl( const ::rtl::OUString& rServiceName, SvLBoxEntry* pParentEntry, sal_Bool bEditName )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::NewControl" );
+ //////////////////////////////////////////////////////////////////////
+ // ParentForm holen
+ if (!GetNavModel()->GetFormShell())
+ return NULL;
+ if (!IsFormEntry(pParentEntry))
+ return NULL;
+
+ FmFormData* pParentFormData = (FmFormData*)pParentEntry->GetUserData();;
+ Reference< XForm > xParentForm( pParentFormData->GetFormIface());
+
+ //////////////////////////////////////////////////////////////////////
+ // Neue Component erzeugen
+ Reference< XFormComponent > xNewComponent(::comphelper::getProcessServiceFactory()->createInstance(rServiceName), UNO_QUERY);
+ if (!xNewComponent.is())
+ return NULL;
+
+ FmControlData* pNewFormControlData = new FmControlData( xNewComponent, m_aNavigatorImages, m_aNavigatorImagesHC, pParentFormData );
+
+ //////////////////////////////////////////////////////////////////////
+ // Namen setzen
+ FmFormView* pFormView = GetNavModel()->GetFormShell()->GetFormView();
+ SdrPageView* pPageView = pFormView->GetSdrPageView();
+ FmFormPage* pPage = (FmFormPage*)pPageView->GetPage();
+
+ ::rtl::OUString sName = pPage->GetImpl().setUniqueName( xNewComponent, xParentForm );
+
+ pNewFormControlData->SetText( sName );
+
+ //////////////////////////////////////////////////////////////////////
+ // FormComponent einfuegen
+ GetNavModel()->Insert( pNewFormControlData, LIST_APPEND, sal_True );
+ GetNavModel()->SetModified();
+
+ if (bEditName)
+ {
+ //////////////////////////////////////////////////////////////////////
+ // In EditMode schalten
+ SvLBoxEntry* pNewEntry = FindEntry( pNewFormControlData );
+ Select( pNewEntry, sal_True );
+ EditEntry( pNewEntry );
+ }
+
+ return pNewFormControlData;
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString NavigatorTree::GenerateName( FmEntryData* pEntryData )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::GenerateName" );
+ const sal_uInt16 nMaxCount = 99;
+ ::rtl::OUString aNewName;
+
+ //////////////////////////////////////////////////////////////////////
+ // BasisNamen erzeugen
+ UniString aBaseName;
+ if( pEntryData->ISA(FmFormData) )
+ aBaseName = SVX_RES( RID_STR_STDFORMNAME );
+
+ else if( pEntryData->ISA(FmControlData) )
+ aBaseName = SVX_RES( RID_STR_CONTROL );
+
+ //////////////////////////////////////////////////////////////////////
+ // Neuen Namen erstellen
+ FmFormData* pFormParentData = (FmFormData*)pEntryData->GetParent();
+
+ for( sal_Int32 i=0; i<nMaxCount; i++ )
+ {
+ aNewName = aBaseName;
+ if( i>0 )
+ {
+ aNewName += ::rtl::OUString::createFromAscii(" ");
+ aNewName += ::rtl::OUString::valueOf(i).getStr();
+ }
+
+ if( GetNavModel()->FindData(aNewName, pFormParentData,sal_False) == NULL )
+ break;
+ }
+
+ return aNewName;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTree::EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::EditedEntry" );
+ if (EditingCanceled())
+ return sal_True;
+
+ GrabFocus();
+ FmEntryData* pEntryData = (FmEntryData*)pEntry->GetUserData();
+ sal_Bool bRes = GetNavModel()->Rename( pEntryData, rNewText);
+ if( !bRes )
+ {
+ m_pEditEntry = pEntry;
+ nEditEvent = Application::PostUserEvent( LINK(this, NavigatorTree, OnEdit) );
+ } else
+ SetCursor(pEntry, sal_True);
+
+ return bRes;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( NavigatorTree, OnEdit, void*, EMPTYARG )
+ {
+ nEditEvent = 0;
+ EditEntry( m_pEditEntry );
+ m_pEditEntry = NULL;
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( NavigatorTree, OnDropActionTimer, void*, EMPTYARG )
+ {
+ if (--m_aTimerCounter > 0)
+ return 0L;
+
+ switch ( m_aDropActionType )
+ {
+ case DA_EXPANDNODE:
+ {
+ SvLBoxEntry* pToExpand = GetEntry(m_aTimerTriggered);
+ if (pToExpand && (GetChildCount(pToExpand) > 0) && !IsExpanded(pToExpand))
+ // tja, eigentlich muesste ich noch testen, ob die Node nicht schon expandiert ist, aber ich
+ // habe dazu weder in den Basisklassen noch im Model eine Methode gefunden ...
+ // aber ich denke, die BK sollte es auch so vertragen
+ Expand(pToExpand);
+
+ // nach dem Expand habe ich im Gegensatz zum Scrollen natuerlich nix mehr zu tun
+ m_aDropActionTimer.Stop();
+ }
+ break;
+
+ case DA_SCROLLUP :
+ ScrollOutputArea( 1 );
+ m_aTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
+ break;
+
+ case DA_SCROLLDOWN :
+ ScrollOutputArea( -1 );
+ m_aTimerCounter = DROP_ACTION_TIMER_SCROLL_TICKS;
+ break;
+
+ }
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK(NavigatorTree, OnEntrySelDesel, NavigatorTree*, /*pThis*/)
+ {
+ m_sdiState = SDI_DIRTY;
+
+ if (IsSelectionHandlingLocked())
+ return 0L;
+
+ if (m_aSynchronizeTimer.IsActive())
+ m_aSynchronizeTimer.Stop();
+
+ m_aSynchronizeTimer.SetTimeout(EXPLORER_SYNC_DELAY);
+ m_aSynchronizeTimer.Start();
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK(NavigatorTree, OnSynchronizeTimer, void*, EMPTYARG)
+ {
+ SynchronizeMarkList();
+ return 0L;
+ }
+
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( NavigatorTree, OnClipboardAction, void*, EMPTYARG )
+ {
+ if ( !m_aControlExchange.isClipboardOwner() )
+ {
+ if ( doingKeyboardCut() )
+ {
+ for ( ListBoxEntrySet::const_iterator i = m_aCutEntries.begin();
+ i != m_aCutEntries.end();
+ ++i
+ )
+ {
+ SvLBoxEntry* pEntry = *i;
+ if ( !pEntry )
+ continue;
+
+ pEntry->SetFlags( pEntry->GetFlags() & ~SV_ENTRYFLAG_SEMITRANSPARENT );
+ InvalidateEntry( pEntry );
+ }
+ ListBoxEntrySet aEmpty;
+ m_aCutEntries.swap( aEmpty );
+
+ m_bKeyboardCut = sal_False;
+ }
+ }
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::ShowSelectionProperties(sal_Bool bForce)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::ShowSelectionProperties" );
+ // zuerst brauche ich die FormShell
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ if (!pFormShell)
+ // keine Shell -> ich koennte kein curObject setzen -> raus
+ return;
+
+ CollectSelectionData(SDI_ALL);
+ DBG_ASSERT( m_nFormsSelected + m_nControlsSelected + (m_bRootSelected ? 1 : 0) == m_arrCurrentSelection.Count(),
+ "NavigatorTree::ShowSelectionProperties : selection meta data invalid !");
+
+
+ InterfaceBag aSelection;
+ sal_Bool bSetSelectionAsMarkList = sal_False;
+
+ if (m_bRootSelected)
+ ; // no properties for the root, neither for single nor for multi selection
+ else if ( m_nFormsSelected + m_nControlsSelected == 0 ) // none of the two should be less 0
+ ; // no selection -> no properties
+ else if ( m_nFormsSelected * m_nControlsSelected != 0 )
+ ; // mixed selection -> no properties
+ else
+ { // either only forms, or only controls are selected
+ if (m_arrCurrentSelection.Count() == 1)
+ {
+ if (m_nFormsSelected > 0)
+ { // es ist genau eine Form selektiert
+ FmFormData* pFormData = (FmFormData*)m_arrCurrentSelection.GetObject(0)->GetUserData();
+ aSelection.insert( Reference< XInterface >( pFormData->GetFormIface(), UNO_QUERY ) );
+ }
+ else
+ { // es ist genau ein Control selektiert (egal ob hidden oder normal)
+ FmEntryData* pEntryData = (FmEntryData*)m_arrCurrentSelection.GetObject(0)->GetUserData();
+
+ aSelection.insert( Reference< XInterface >( pEntryData->GetElement(), UNO_QUERY ) );
+ }
+ }
+ else
+ { // wir haben eine MultiSelection, also muessen wir ein MultiSet dafuer aufbauen
+ if (m_nFormsSelected > 0)
+ { // ... nur Forms
+ // erstmal die PropertySet-Interfaces der Forms einsammeln
+ for ( sal_Int32 i = 0; i < m_nFormsSelected; ++i )
+ {
+ FmFormData* pFormData = (FmFormData*)m_arrCurrentSelection.GetObject((USHORT)i)->GetUserData();
+ aSelection.insert( pFormData->GetPropertySet().get() );
+ }
+ }
+ else
+ { // ... nur Controls
+ if (m_nHiddenControls == m_nControlsSelected)
+ { // ein MultiSet fuer die Properties der hidden controls
+ for ( sal_Int32 i = 0; i < m_nHiddenControls; ++i )
+ {
+ FmEntryData* pEntryData = (FmEntryData*)m_arrCurrentSelection.GetObject((USHORT)i)->GetUserData();
+ aSelection.insert( pEntryData->GetPropertySet().get() );
+ }
+ }
+ else if (m_nHiddenControls == 0)
+ { // nur normale Controls
+ bSetSelectionAsMarkList = sal_True;
+ }
+ }
+ }
+
+ }
+
+ // und dann meine Form und mein SelObject
+ if ( bSetSelectionAsMarkList )
+ pFormShell->GetImpl()->setCurrentSelectionFromMark( pFormShell->GetFormView()->GetMarkedObjectList() );
+ else
+ pFormShell->GetImpl()->setCurrentSelection( aSelection );
+
+ if ( pFormShell->GetImpl()->IsPropBrwOpen() || bForce )
+ {
+ // und jetzt kann ich das Ganze dem PropertyBrowser uebergeben
+ pFormShell->GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_SHOW_PROPERTY_BROWSER, SFX_CALLMODE_ASYNCHRON );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::DeleteSelection()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::DeleteSelection" );
+ // die Root darf ich natuerlich nicht mitloeschen
+ sal_Bool bRootSelected = IsSelected(m_pRootEntry);
+ ULONG nSelectedEntries = GetSelectionCount();
+ if (bRootSelected && (nSelectedEntries > 1)) // die Root plus andere Elemente ?
+ Select(m_pRootEntry, sal_False); // ja -> die Root raus
+
+ if ((nSelectedEntries == 0) || bRootSelected) // immer noch die Root ?
+ return; // -> sie ist das einzige selektierte -> raus
+
+ DBG_ASSERT(!m_bPrevSelectionMixed, "NavigatorTree::DeleteSelection() : loeschen nicht erlaubt wenn Markierung und Selektion nciht konsistent");
+
+ // ich brauche unten das FormModel ...
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ if (!pFormShell)
+ return;
+ FmFormModel* pFormModel = pFormShell ? pFormShell->GetFormModel() : NULL;
+ if (!pFormModel)
+ return;
+
+ // jetzt muss ich noch die DeleteList etwas absichern : wenn man ein Formular und ein abhaengiges
+ // Element loescht - und zwar in dieser Reihenfolge - dann ist der SvLBoxEntryPtr des abhaengigen Elementes
+ // natuerlich schon ungueltig, wenn es geloescht werden soll ... diesen GPF, den es dann mit Sicherheit gibt,
+ // gilt es zu verhindern, also die 'normalisierte' Liste
+ CollectSelectionData( SDI_NORMALIZED );
+
+ // see below for why we need this mapping from models to shapes
+ FmFormView* pFormView = pFormShell->GetFormView();
+ SdrPageView* pPageView = pFormView ? pFormView->GetSdrPageView() : NULL;
+ SdrPage* pPage = pPageView ? pPageView->GetPage() : NULL;
+ DBG_ASSERT( pPage, "NavigatorTree::DeleteSelection: invalid form page!" );
+
+ MapModelToShape aModelShapes;
+ if ( pPage )
+ collectShapeModelMapping( pPage, aModelShapes );
+
+ // problem: we have to use ExplorerModel::Remove, since only this one properly deletes Form objects.
+ // But, the controls themself must be deleted via DeleteMarked (else, the Writer has some problems
+ // somewhere). In case I'd first delete the structure, then the controls, the UNDO would not work
+ // (since UNDO then would mean to first restore the controls, then the structure, means their parent
+ // form). The other way round, the EntryDatas would be invalid, if I'd first delete the controls and
+ // then go on to the strucure. This means I have to delete the forms *after* the normal controls, so
+ // that during UNDO, they're restored in the proper order.
+ pFormShell->GetImpl()->EnableTrackProperties(sal_False);
+ USHORT i;
+ for (i = m_arrCurrentSelection.Count(); i>0; --i)
+ {
+ FmEntryData* pCurrent = (FmEntryData*)(m_arrCurrentSelection.GetObject(i - 1)->GetUserData());
+
+ // eine Form ?
+ sal_Bool bIsForm = pCurrent->ISA(FmFormData);
+
+ // da ich das Loeschen im folgenden der View ueberlasse und dabei auf deren MarkList aufbaue, im Normalfall aber bei
+ // einem makierten Formular nur die direkt, nicht die indirekt abhaengigen Controls markiert werden, muss ich das hier
+ // noch nachholen
+ if (bIsForm)
+ MarkViewObj((FmFormData*)pCurrent, sal_True, sal_True); // das zweite sal_True heisst "deep"
+
+ // ein hidden control ?
+ sal_Bool bIsHidden = IsHiddenControl(pCurrent);
+
+ // Forms und hidden Controls muss ich behalten, alles andere nicht
+ if (!bIsForm && !bIsHidden)
+ {
+ // well, no form and no hidden control -> we can remove it from m_arrCurrentSelection, as it will
+ // be deleted automatically. This is because for every model (except forms and hidden control models)
+ // there exist a shape, which is marked _if_and_only_if_ the model is selected in our tree.
+ if ( aModelShapes.find( pCurrent->GetElement() ) != aModelShapes.end() )
+ {
+ // if there's a shape for the current entry, then either it is marked or it is in a
+ // hidden layer (#i28502#), or something like this.
+ // In the first case, it will be deleted below, in the second case, we currently don't
+ // delete it, as there's no real (working!) API for this, neither in UNO nor in non-UNO.
+ m_arrCurrentSelection.Remove( i - 1, 1 );
+ }
+ // In case there is no shape for the current entry, we keep the entry in m_arrCurrentSelection,
+ // since then we can definately remove it.
+ // #103597#
+ }
+ }
+ pFormShell->GetImpl()->EnableTrackProperties(sal_True);
+
+ // let the view delete the marked controls
+ pFormShell->GetFormView()->DeleteMarked();
+
+ // start UNDO at this point. Unfortunately, this results in 2 UNDO actions, since DeleteMarked is
+ // creating an own one. However, if we'd move it before DeleteMarked, Writer does not really like
+ // this ... :(
+ // 2004-07-05 - #i31038# - fs@openoffice.org
+ {
+ // ---------------
+ // initialize UNDO
+ String aUndoStr;
+ if ( m_arrCurrentSelection.Count() == 1 )
+ {
+ aUndoStr = SVX_RES(RID_STR_UNDO_CONTAINER_REMOVE);
+ if (m_nFormsSelected)
+ aUndoStr.SearchAndReplaceAscii( "#", SVX_RES( RID_STR_FORM ) );
+ else
+ // it must be a control (else the root would be selected, but it cannot be deleted)
+ aUndoStr.SearchAndReplaceAscii( "#", SVX_RES( RID_STR_CONTROL ) );
+ }
+ else
+ {
+ aUndoStr = SVX_RES(RID_STR_UNDO_CONTAINER_REMOVE_MULTIPLE);
+ aUndoStr.SearchAndReplaceAscii( "#", String::CreateFromInt32( m_arrCurrentSelection.Count() ) );
+ }
+ pFormModel->BegUndo(aUndoStr);
+ }
+
+ // remove remaining structure
+ for (i=0; i<m_arrCurrentSelection.Count(); ++i)
+ {
+ FmEntryData* pCurrent = (FmEntryData*)(m_arrCurrentSelection.GetObject(i)->GetUserData());
+
+ // if the entry still has children, we skipped deletion of one of those children.
+ // This may for instance be because the shape is in a hidden layer, where we're unable
+ // to remove it
+ if ( pCurrent->GetChildList()->Count() )
+ continue;
+
+ // noch ein kleines Problem, bevor ich das ganz loesche : wenn es eine Form ist und die Shell diese als CurrentObject
+ // kennt, dann muss ich ihr das natuerlich ausreden
+ if (pCurrent->ISA(FmFormData))
+ {
+ Reference< XForm > xCurrentForm( static_cast< FmFormData* >( pCurrent )->GetFormIface() );
+ if ( pFormShell->GetImpl()->getCurrentForm() == xCurrentForm ) // die Shell kennt die zu loeschende Form ?
+ pFormShell->GetImpl()->forgetCurrentForm(); // -> wegnehmen ...
+ }
+ GetNavModel()->Remove(pCurrent, sal_True);
+ }
+ pFormModel->EndUndo();
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::CollectSelectionData(SELDATA_ITEMS sdiHow)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::CollectSelectionData" );
+ DBG_ASSERT(sdiHow != SDI_DIRTY, "NavigatorTree::CollectSelectionData : ever thought about your parameter ? DIRTY ?");
+ if (sdiHow == m_sdiState)
+ return;
+
+ m_arrCurrentSelection.Remove((sal_uInt16)0, m_arrCurrentSelection.Count());
+ m_nFormsSelected = m_nControlsSelected = m_nHiddenControls = 0;
+ m_bRootSelected = sal_False;
+
+ SvLBoxEntry* pSelectionLoop = FirstSelected();
+ while (pSelectionLoop)
+ {
+ // erst mal die Zaehlung der verschiedenen Elemente
+ if (pSelectionLoop == m_pRootEntry)
+ m_bRootSelected = sal_True;
+ else
+ {
+ if (IsFormEntry(pSelectionLoop))
+ ++m_nFormsSelected;
+ else
+ {
+ ++m_nControlsSelected;
+ if (IsHiddenControl((FmEntryData*)(pSelectionLoop->GetUserData())))
+ ++m_nHiddenControls;
+ }
+ }
+
+ if (sdiHow == SDI_NORMALIZED)
+ {
+ // alles, was schon einen selektierten Vorfahr hat, nicht mitnehmen
+ if (pSelectionLoop == m_pRootEntry)
+ m_arrCurrentSelection.Insert(pSelectionLoop);
+ else
+ {
+ SvLBoxEntry* pParentLoop = GetParent(pSelectionLoop);
+ while (pParentLoop)
+ {
+ // eigentlich muesste ich testen, ob das Parent in der m_arrCurrentSelection steht ...
+ // Aber wenn es selektiert ist, dann steht es in m_arrCurrentSelection, oder wenigstens einer seiner Vorfahren,
+ // wenn der auch schon selektiert war. In beiden Faellen reicht also die Abfrage IsSelected
+ if (IsSelected(pParentLoop))
+ break;
+ else
+ {
+ if (m_pRootEntry == pParentLoop)
+ {
+ // bis (exclusive) zur Root gab es kein selektiertes Parent -> der Eintrag gehoert in die normalisierte Liste
+ m_arrCurrentSelection.Insert(pSelectionLoop);
+ break;
+ }
+ else
+ pParentLoop = GetParent(pParentLoop);
+ }
+ }
+ }
+ }
+ else if (sdiHow == SDI_NORMALIZED_FORMARK)
+ {
+ SvLBoxEntry* pParent = GetParent(pSelectionLoop);
+ if (!pParent || !IsSelected(pParent) || IsFormEntry(pSelectionLoop))
+ m_arrCurrentSelection.Insert(pSelectionLoop);
+ }
+ else
+ m_arrCurrentSelection.Insert(pSelectionLoop);
+
+
+ pSelectionLoop = NextSelected(pSelectionLoop);
+ }
+
+ m_sdiState = sdiHow;
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::SynchronizeSelection(FmEntryDataArray& arredToSelect)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::SynchronizeSelection" );
+ LockSelectionHandling();
+ if (arredToSelect.Count() == 0)
+ {
+ SelectAll(sal_False);
+ }
+ else
+ {
+ // erst mal gleiche ich meine aktuelle Selektion mit der geforderten SelectList ab
+ SvLBoxEntry* pSelection = FirstSelected();
+ while (pSelection)
+ {
+ FmEntryData* pCurrent = (FmEntryData*)pSelection->GetUserData();
+ if (pCurrent != NULL)
+ {
+ sal_uInt16 nPosition;
+ if ( arredToSelect.Seek_Entry(pCurrent, &nPosition) )
+ { // der Entry ist schon selektiert, steht aber auch in der SelectList -> er kann aus letzterer
+ // raus
+ arredToSelect.Remove(nPosition, 1);
+ } else
+ { // der Entry ist selektiert, aber steht nicht in der SelectList -> Selektion rausnehmen
+ Select(pSelection, sal_False);
+ // und sichtbar machen (kann ja sein, dass das die einzige Modifikation ist, die ich hier in dem
+ // ganzen Handler mache, dann sollte das zu sehen sein)
+ MakeVisible(pSelection);
+ }
+ }
+ else
+ Select(pSelection, sal_False);
+
+ pSelection = NextSelected(pSelection);
+ }
+
+ // jetzt habe ich in der SelectList genau die Eintraege, die noch selektiert werden muessen
+ // zwei Moeglichkeiten : 1) ich gehe durch die SelectList, besorge mir zu jedem Eintrag meinen SvLBoxEntry
+ // und selektiere diesen (waere irgendwie intuitiver ;)) 2) ich gehe durch alle meine SvLBoxEntries und selektiere
+ // genau die, die ich in der SelectList finde
+ // 1) braucht O(k*n) (k=Laenge der SelectList, n=Anzahl meiner Entries), plus den Fakt, dass FindEntry nicht den
+ // Pointer auf die UserDaten vergleicht, sondern ein aufwendigeres IsEqualWithoutChilds durchfuehrt
+ // 2) braucht O(n*log k), dupliziert aber etwas Code (naemlich den aus FindEntry)
+ // da das hier eine relativ oft aufgerufenen Stelle sein koennte (bei jeder Aenderung in der Markierung in der View !),
+ // nehme ich doch lieber letzteres
+ SvLBoxEntry* pLoop = First();
+ while( pLoop )
+ {
+ FmEntryData* pCurEntryData = (FmEntryData*)pLoop->GetUserData();
+ sal_uInt16 nPosition;
+ if ( arredToSelect.Seek_Entry(pCurEntryData, &nPosition) )
+ {
+ Select(pLoop, sal_True);
+ MakeVisible(pLoop);
+ SetCursor(pLoop, sal_True);
+ }
+
+ pLoop = Next( pLoop );
+ }
+ }
+ UnlockSelectionHandling();
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::SynchronizeSelection()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::SynchronizeSelection" );
+ // Shell und View
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ if(!pFormShell) return;
+
+ FmFormView* pFormView = pFormShell->GetFormView();
+ if (!pFormView) return;
+
+ GetNavModel()->BroadcastMarkedObjects(pFormView->GetMarkedObjectList());
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::SynchronizeMarkList()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::SynchronizeMarkList" );
+ // die Shell werde ich brauchen ...
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ if (!pFormShell) return;
+
+ CollectSelectionData(SDI_NORMALIZED_FORMARK);
+
+ // Die View soll jetzt kein Notify bei einer Aenderung der MarkList rauslassen
+ pFormShell->GetImpl()->EnableTrackProperties(sal_False);
+
+ UnmarkAllViewObj();
+
+ for (sal_uInt32 i=0; i<m_arrCurrentSelection.Count(); ++i)
+ {
+ SvLBoxEntry* pSelectionLoop = m_arrCurrentSelection.GetObject((USHORT)i);
+ // Bei Formselektion alle Controls dieser Form markieren
+ if (IsFormEntry(pSelectionLoop) && (pSelectionLoop != m_pRootEntry))
+ MarkViewObj((FmFormData*)pSelectionLoop->GetUserData(), sal_True, sal_False);
+
+ // Bei Controlselektion Control-SdrObjects markieren
+ else if (IsFormComponentEntry(pSelectionLoop))
+ {
+ FmControlData* pControlData = (FmControlData*)pSelectionLoop->GetUserData();
+ if (pControlData)
+ {
+ /////////////////////////////////////////////////////////////////
+ // Beim HiddenControl kann kein Object selektiert werden
+ Reference< XFormComponent > xFormComponent( pControlData->GetFormComponent());
+ if (!xFormComponent.is())
+ continue;
+ Reference< XPropertySet > xSet(xFormComponent, UNO_QUERY);
+ if (!xSet.is())
+ continue;
+
+ sal_uInt16 nClassId = ::comphelper::getINT16(xSet->getPropertyValue(FM_PROP_CLASSID));
+ if (nClassId != FormComponentType::HIDDENCONTROL)
+ MarkViewObj(pControlData, sal_True, sal_True);
+ }
+ }
+ }
+
+ // wenn der PropertyBrowser offen ist, muss ich den entsprechend meiner Selektion anpassen
+ // (NICHT entsprechend der MarkList der View : wenn ich ein Formular selektiert habe, sind in der
+ // View alle zugehoerigen Controls markiert, trotzdem moechte ich natuerlich die Formular-Eigenschaften
+ // sehen)
+ ShowSelectionProperties(sal_False);
+
+ // Flag an View wieder zuruecksetzen
+ pFormShell->GetImpl()->EnableTrackProperties(sal_True);
+
+ // wenn jetzt genau eine Form selektiert ist, sollte die Shell das als CurrentForm mitbekommen
+ // (wenn SelectionHandling nicht locked ist, kuemmert sich die View eigentlich in MarkListHasChanged drum,
+ // aber der Mechanismus greift zum Beispiel nicht, wenn die Form leer ist)
+ if ((m_arrCurrentSelection.Count() == 1) && (m_nFormsSelected == 1))
+ {
+ FmFormData* pSingleSelectionData = PTR_CAST( FmFormData, static_cast< FmEntryData* >( FirstSelected()->GetUserData() ) );
+ DBG_ASSERT( pSingleSelectionData, "NavigatorTree::SynchronizeMarkList: invalid selected form!" );
+ if ( pSingleSelectionData )
+ {
+ InterfaceBag aSelection;
+ aSelection.insert( Reference< XInterface >( pSingleSelectionData->GetFormIface(), UNO_QUERY ) );
+ pFormShell->GetImpl()->setCurrentSelection( aSelection );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTree::IsHiddenControl(FmEntryData* pEntryData)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::IsHiddenControl" );
+ if (pEntryData == NULL) return sal_False;
+
+ Reference< XPropertySet > xProperties( pEntryData->GetPropertySet() );
+ if (::comphelper::hasProperty(FM_PROP_CLASSID, xProperties))
+ {
+ Any aClassID = xProperties->getPropertyValue( FM_PROP_CLASSID );
+ return (::comphelper::getINT16(aClassID) == FormComponentType::HIDDENCONTROL);
+ }
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTree::Select( SvLBoxEntry* pEntry, sal_Bool bSelect )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::Select" );
+ if (bSelect == IsSelected(pEntry)) // das passiert manchmal, ich glaube, die Basisklasse geht zu sehr auf Nummer sicher ;)
+ return sal_True;
+
+ return SvTreeListBox::Select(pEntry, bSelect );
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTree::UnmarkAllViewObj()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::UnmarkAllViewObj" );
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ if( !pFormShell )
+ return;
+ FmFormView* pFormView = pFormShell->GetFormView();
+ pFormView->UnMarkAll();
+ }
+ //------------------------------------------------------------------------
+ void NavigatorTree::MarkViewObj(FmFormData* pFormData, sal_Bool bMark, sal_Bool bDeep )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::MarkViewObjects" );
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ if( !pFormShell )
+ return;
+
+ // first collect all sdrobjects
+ ::std::set< Reference< XFormComponent > > aObjects;
+ CollectObjects(pFormData,bDeep,aObjects);
+
+ //////////////////////////////////////////////////////////////////////
+ // In der Page das entsprechende SdrObj finden und selektieren
+ FmFormView* pFormView = pFormShell->GetFormView();
+ SdrPageView* pPageView = pFormView->GetSdrPageView();
+ SdrPage* pPage = pPageView->GetPage();
+ //FmFormPage* pFormPage = dynamic_cast< FmFormPage* >( pPage );
+
+ SdrObjListIter aIter( *pPage );
+ while ( aIter.IsMore() )
+ {
+ SdrObject* pSdrObject = aIter.Next();
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pSdrObject );
+ if ( !pFormObject )
+ continue;
+
+ Reference< XFormComponent > xControlModel( pFormObject->GetUnoControlModel(),UNO_QUERY );
+ if ( xControlModel.is() && aObjects.find(xControlModel) != aObjects.end() && bMark != pFormView->IsObjMarked( pSdrObject ) )
+ {
+ // unfortunately, the writer doesn't like marking an already-marked object, again, so reset the mark first
+ pFormView->MarkObj( pSdrObject, pPageView, !bMark, sal_False );
+ }
+ } // while ( aIter.IsMore() )
+ if ( bMark )
+ {
+ // make the mark visible
+ ::Rectangle aMarkRect( pFormView->GetAllMarkedRect());
+ for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
+ {
+ SdrPaintWindow* pPaintWindow = pFormView->GetPaintWindow( i );
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+ if ( ( OUTDEV_WINDOW == rOutDev.GetOutDevType() ) && !aMarkRect.IsEmpty() )
+ {
+ pFormView->MakeVisible( aMarkRect, (Window&)rOutDev );
+ }
+ } // for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
+ }
+ }
+ //------------------------------------------------------------------------
+ void NavigatorTree::CollectObjects(FmFormData* pFormData, sal_Bool bDeep, ::std::set< Reference< XFormComponent > >& _rObjects)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::MarkViewObjects" );
+ FmEntryDataList* pChildList = pFormData->GetChildList();
+ FmEntryData* pEntryData;
+ FmControlData* pControlData;
+ for( sal_uInt32 i=0; i < pChildList->Count(); ++i )
+ {
+ pEntryData = pChildList->GetObject(i);
+ if( pEntryData->ISA(FmControlData) )
+ {
+ pControlData = (FmControlData*)pEntryData;
+ _rObjects.insert(pControlData->GetFormComponent());
+ } // if( pEntryData->ISA(FmControlData) )
+ else if (bDeep && (pEntryData->ISA(FmFormData)))
+ CollectObjects((FmFormData*)pEntryData,bDeep,_rObjects);
+ } // for( sal_uInt32 i=0; i<pChildList->Count(); i++ )
+ }
+ //------------------------------------------------------------------------
+ void NavigatorTree::MarkViewObj( FmControlData* pControlData, sal_Bool bMarkHandles, sal_Bool bMark)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTree::MarkViewObj" );
+ if( !pControlData )
+ return;
+ FmFormShell* pFormShell = GetNavModel()->GetFormShell();
+ if( !pFormShell )
+ return;
+
+ //////////////////////////////////////////////////////////////////////
+ // In der Page das entsprechende SdrObj finden und selektieren
+ FmFormView* pFormView = pFormShell->GetFormView();
+ Reference< XFormComponent > xFormComponent( pControlData->GetFormComponent());
+ SdrPageView* pPageView = pFormView->GetSdrPageView();
+ SdrPage* pPage = pPageView->GetPage();
+
+ bool bPaint = false;
+ SdrObjListIter aIter( *pPage );
+ while ( aIter.IsMore() )
+ {
+ SdrObject* pSdrObject = aIter.Next();
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pSdrObject );
+ if ( !pFormObject )
+ continue;
+
+ Reference< XInterface > xControlModel( pFormObject->GetUnoControlModel() );
+ if ( xControlModel != xFormComponent )
+ continue;
+
+ // mark the object
+ if ( bMark != pFormView->IsObjMarked( pSdrObject ) )
+ // unfortunately, the writer doesn't like marking an already-marked object, again, so reset the mark first
+ pFormView->MarkObj( pSdrObject, pPageView, !bMark, sal_False );
+
+ if ( !bMarkHandles || !bMark )
+ continue;
+
+ bPaint = true;
+
+ } // while ( aIter.IsMore() )
+ if ( bPaint )
+ {
+ // make the mark visible
+ ::Rectangle aMarkRect( pFormView->GetAllMarkedRect());
+ for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
+ {
+ SdrPaintWindow* pPaintWindow = pFormView->GetPaintWindow( i );
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+ if ( OUTDEV_WINDOW == rOutDev.GetOutDevType() )
+ {
+ pFormView->MakeVisible( aMarkRect, (Window&)rOutDev );
+ }
+ } // for ( sal_uInt32 i = 0; i < pFormView->PaintWindowCount(); ++i )
+ }
+ }
+
+//............................................................................
+} // namespace svxform
+//............................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx
new file mode 100644
index 000000000000..0979606aaa95
--- /dev/null
+++ b/svx/source/form/navigatortreemodel.cxx
@@ -0,0 +1,1128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/dialmgr.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/fmpage.hxx>
+#include <svx/fmglob.hxx>
+#include "svditer.hxx"
+#include <svx/svdogrp.hxx>
+#include <svx/svdpagv.hxx>
+
+#include "fmprop.hrc"
+
+#include "fmundo.hxx"
+#include "fmhelp.hrc"
+#include "fmexpl.hrc"
+#include "fmexpl.hxx"
+#include "fmresids.hrc"
+#include "fmshimp.hxx"
+#include "fmobj.hxx"
+#include <sfx2/objsh.hxx>
+#include <tools/diagnose_ex.h>
+#include <rtl/logfile.hxx>
+#include <com/sun/star/container/XContainer.hpp>
+
+//............................................................................
+namespace svxform
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::sdb;
+
+ //========================================================================
+ // class OFormComponentObserver
+ //========================================================================
+ //------------------------------------------------------------------------
+ OFormComponentObserver::OFormComponentObserver(NavigatorTreeModel* _pModel)
+ :m_pNavModel(_pModel)
+ ,m_nLocks(0)
+ ,m_bCanUndo(sal_True)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::OFormComponentObserver" );
+ }
+
+ // XPropertyChangeListener
+ //------------------------------------------------------------------------
+ void SAL_CALL OFormComponentObserver::disposing(const EventObject& Source) throw( RuntimeException )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::disposing" );
+ Remove( Source.Source );
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OFormComponentObserver::propertyChange(const PropertyChangeEvent& evt) throw(RuntimeException)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::propertyChange" );
+ if( !m_pNavModel ) return;
+ if( evt.PropertyName != FM_PROP_NAME ) return;
+
+ Reference< XFormComponent > xFormComponent(evt.Source, UNO_QUERY);
+ Reference< XForm > xForm(evt.Source, UNO_QUERY);
+
+ FmEntryData* pEntryData( NULL );
+ if( xForm.is() )
+ pEntryData = m_pNavModel->FindData( xForm, m_pNavModel->GetRootList() );
+ else if( xFormComponent.is() )
+ pEntryData = m_pNavModel->FindData( xFormComponent, m_pNavModel->GetRootList() );
+
+ if( pEntryData )
+ {
+ ::rtl::OUString aNewName = ::comphelper::getString(evt.NewValue);
+ pEntryData->SetText( aNewName );
+ FmNavNameChangedHint aNameChangedHint( pEntryData, aNewName );
+ m_pNavModel->Broadcast( aNameChangedHint );
+ }
+ }
+
+ // XContainerListener
+ //------------------------------------------------------------------------------
+ void SAL_CALL OFormComponentObserver::elementInserted(const ContainerEvent& evt) throw(RuntimeException)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::elementInserted" );
+ if (IsLocked() || !m_pNavModel)
+ return;
+
+ // keine Undoaction einfuegen
+ m_bCanUndo = sal_False;
+
+ Reference< XInterface > xTemp;
+ evt.Element >>= xTemp;
+ Insert(xTemp, ::comphelper::getINT32(evt.Accessor));
+
+ m_bCanUndo = sal_True;
+ }
+
+ //------------------------------------------------------------------------------
+ void OFormComponentObserver::Insert(const Reference< XInterface > & xIface, sal_Int32 nIndex)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::Insert" );
+ Reference< XForm > xForm(xIface, UNO_QUERY);
+ if (xForm.is())
+ {
+ m_pNavModel->InsertForm(xForm, sal_uInt32(nIndex));
+ Reference< XIndexContainer > xContainer(xForm, UNO_QUERY);
+ Reference< XInterface > xTemp;
+ for (sal_Int32 i = 0; i < xContainer->getCount(); i++)
+ {
+ xContainer->getByIndex(i) >>= xTemp;
+ Insert(xTemp, i);
+ }
+ }
+ else
+ {
+ Reference< XFormComponent > xFormComp(xIface, UNO_QUERY);
+ if (xFormComp.is())
+ m_pNavModel->InsertFormComponent(xFormComp, sal_uInt32(nIndex));
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ void SAL_CALL OFormComponentObserver::elementReplaced(const ContainerEvent& evt) throw(RuntimeException)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::elementReplaced" );
+ if (IsLocked() || !m_pNavModel)
+ return;
+
+ m_bCanUndo = sal_False;
+
+ // EntryData loeschen
+ Reference< XFormComponent > xReplaced;
+ evt.ReplacedElement >>= xReplaced;
+ FmEntryData* pEntryData = m_pNavModel->FindData(xReplaced, m_pNavModel->GetRootList(), sal_True);
+ if (pEntryData)
+ {
+ if (pEntryData->ISA(FmControlData))
+ {
+ Reference< XFormComponent > xComp;
+ evt.Element >>= xComp;
+ DBG_ASSERT(xComp.is(), "OFormComponentObserver::elementReplaced : invalid argument !");
+ // an einer FmControlData sollte eine XFormComponent haengen
+ m_pNavModel->ReplaceFormComponent(xReplaced, xComp);
+ }
+ else if (pEntryData->ISA(FmFormData))
+ {
+ DBG_ERROR("replacing forms not implemented yet !");
+ }
+ }
+
+ m_bCanUndo = sal_True;
+ }
+
+ //------------------------------------------------------------------------------
+ void OFormComponentObserver::Remove( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxElement )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::Remove" );
+ if (IsLocked() || !m_pNavModel)
+ return;
+
+ m_bCanUndo = sal_False;
+
+ //////////////////////////////////////////////////////////
+ // EntryData loeschen
+ FmEntryData* pEntryData = m_pNavModel->FindData( _rxElement, m_pNavModel->GetRootList(), sal_True );
+ if (pEntryData)
+ m_pNavModel->Remove(pEntryData);
+
+ m_bCanUndo = sal_True;
+ }
+
+ //------------------------------------------------------------------------------
+ void SAL_CALL OFormComponentObserver::elementRemoved(const ContainerEvent& evt) throw(RuntimeException)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "OFormComponentObserver::elementRemoved" );
+ Reference< XInterface > xElement;
+ evt.Element >>= xElement;
+ Remove( xElement );
+ }
+
+ //========================================================================
+ // class NavigatorTreeModel
+ //========================================================================
+
+ //------------------------------------------------------------------------
+ NavigatorTreeModel::NavigatorTreeModel( const ImageList& _rNormalImages, const ImageList& _rHCImages )
+ :m_pFormShell(NULL)
+ ,m_pFormPage(NULL)
+ ,m_pFormModel(NULL)
+ ,m_aNormalImages( _rNormalImages )
+ ,m_aHCImages( _rHCImages )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::NavigatorTreeModel" );
+ m_pPropChangeList = new OFormComponentObserver(this);
+ m_pPropChangeList->acquire();
+ m_pRootList = new FmEntryDataList();
+ }
+
+ //------------------------------------------------------------------------
+ NavigatorTreeModel::~NavigatorTreeModel()
+ {
+ //////////////////////////////////////////////////////////////////////
+ // Als Listener abmelden
+ if( m_pFormShell)
+ {
+ FmFormModel* pFormModel = m_pFormShell->GetFormModel();
+ if( pFormModel && IsListening(*pFormModel))
+ EndListening( *pFormModel );
+
+ if (IsListening(*m_pFormShell))
+ EndListening(*m_pFormShell);
+ }
+
+ Clear();
+ delete m_pRootList;
+ m_pPropChangeList->ReleaseModel();
+ m_pPropChangeList->release();
+ }
+
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::SetModified( sal_Bool bMod )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::SetModified" );
+ if( !m_pFormShell ) return;
+ SfxObjectShell* pObjShell = m_pFormShell->GetFormModel()->GetObjectShell();
+ if( !pObjShell ) return;
+ pObjShell->SetModified( bMod );
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::Clear()
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Clear" );
+ Reference< XNameContainer > xForms( GetForms());
+ Reference< XContainer > xContainer(xForms, UNO_QUERY);
+ if (xContainer.is())
+ xContainer->removeContainerListener((XContainerListener*)m_pPropChangeList);
+
+ //////////////////////////////////////////////////////////////////////
+ // RootList loeschen
+ FmEntryData* pChildData;
+ FmEntryDataList* pRootList = GetRootList();
+
+ for( sal_uInt32 i=pRootList->Count(); i>0; i-- )
+ {
+ pChildData = pRootList->GetObject(i-1);
+ pRootList->Remove( pChildData );
+ delete pChildData;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // UI benachrichtigen
+ FmNavClearedHint aClearedHint;
+ Broadcast( aClearedHint );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XNameContainer > NavigatorTreeModel::GetForms() const
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::GetForms" );
+ if( !m_pFormShell || !m_pFormShell->GetCurPage())
+ return NULL;
+ else
+ return m_pFormShell->GetCurPage()->GetForms();
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::Insert(FmEntryData* pEntry, ULONG nRelPos, sal_Bool bAlterModel)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Insert" );
+ if (IsListening(*m_pFormModel))
+ EndListening(*m_pFormModel);
+
+ m_pPropChangeList->Lock();
+ FmFormData* pFolder = (FmFormData*) pEntry->GetParent();
+ Reference< XChild > xElement( pEntry->GetChildIFace() );
+ if (bAlterModel)
+ {
+ XubString aStr;
+ if (pEntry->ISA(FmFormData))
+ aStr = SVX_RES(RID_STR_FORM);
+ else
+ aStr = SVX_RES(RID_STR_CONTROL);
+
+ Reference< XIndexContainer > xContainer;
+ if (pFolder)
+ xContainer = Reference< XIndexContainer > (pFolder->GetFormIface(), UNO_QUERY);
+ else
+ xContainer = Reference< XIndexContainer > (GetForms(), UNO_QUERY);
+
+ bool bUndo = m_pFormModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_INSERT));
+ aUndoStr.SearchAndReplace('#', aStr);
+ m_pFormModel->BegUndo(aUndoStr);
+ }
+
+ if (nRelPos >= (sal_uInt32)xContainer->getCount())
+ nRelPos = (sal_uInt32)xContainer->getCount();
+
+ // UndoAction
+ if ( bUndo && m_pPropChangeList->CanUndo())
+ {
+ m_pFormModel->AddUndo(new FmUndoContainerAction(*m_pFormModel,
+ FmUndoContainerAction::Inserted,
+ xContainer,
+ xElement,
+ nRelPos));
+ }
+
+ // das Element muss den Typ haben, den der Container erwartet
+ if (xContainer->getElementType() ==
+ ::getCppuType((const Reference< XForm>*)0))
+
+ {
+ Reference< XForm > xElementAsForm(xElement, UNO_QUERY);
+ xContainer->insertByIndex(nRelPos, makeAny(xElementAsForm));
+ }
+ else if (xContainer->getElementType() ==
+ ::getCppuType((const Reference< XFormComponent>*)0))
+
+ {
+ Reference< XFormComponent > xElementAsComponent(xElement, UNO_QUERY);
+ xContainer->insertByIndex(nRelPos, makeAny(xElementAsComponent));
+ }
+ else
+ {
+ DBG_ERROR("NavigatorTreeModel::Insert : the parent container needs an elementtype I don't know !");
+ }
+
+ if( bUndo )
+ m_pFormModel->EndUndo();
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Als PropertyChangeListener anmelden
+ Reference< XPropertySet > xSet(xElement, UNO_QUERY);
+ if( xSet.is() )
+ xSet->addPropertyChangeListener( FM_PROP_NAME, m_pPropChangeList );
+
+ //////////////////////////////////////////////////////////////////////
+ // Daten aus Model entfernen
+ if (pEntry->ISA(FmFormData))
+ {
+ Reference< XContainer > xContainer(xElement, UNO_QUERY);
+ if (xContainer.is())
+ xContainer->addContainerListener((XContainerListener*)m_pPropChangeList);
+ }
+
+ if (pFolder)
+ pFolder->GetChildList()->Insert( pEntry, nRelPos );
+ else
+ GetRootList()->Insert( pEntry, nRelPos );
+
+ //////////////////////////////////////////////////////////////////////
+ // UI benachrichtigen
+ FmNavInsertedHint aInsertedHint( pEntry, nRelPos );
+ Broadcast( aInsertedHint );
+
+ m_pPropChangeList->UnLock();
+ if (IsListening(*m_pFormModel))
+ StartListening(*m_pFormModel);
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::Remove(FmEntryData* pEntry, sal_Bool bAlterModel)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Remove" );
+ //////////////////////////////////////////////////////////////////////
+ // Form und Parent holen
+ if (!pEntry || !m_pFormModel)
+ return;
+
+ if (IsListening(*m_pFormModel))
+ EndListening(*m_pFormModel);
+
+ const bool bUndo = m_pFormModel->IsUndoEnabled();
+
+ m_pPropChangeList->Lock();
+ FmFormData* pFolder = (FmFormData*) pEntry->GetParent();
+ Reference< XChild > xElement ( pEntry->GetChildIFace() );
+ if (bAlterModel)
+ {
+ XubString aStr;
+ if (pEntry->ISA(FmFormData))
+ aStr = SVX_RES(RID_STR_FORM);
+ else
+ aStr = SVX_RES(RID_STR_CONTROL);
+
+ if( bUndo )
+ {
+ XubString aUndoStr(SVX_RES(RID_STR_UNDO_CONTAINER_REMOVE));
+ aUndoStr.SearchAndReplace('#', aStr);
+ m_pFormModel->BegUndo(aUndoStr);
+ }
+ }
+
+ // jetzt die eigentliche Entfernung der Daten aus dem Model
+ if (pEntry->ISA(FmFormData))
+ RemoveForm((FmFormData*)pEntry);
+ else
+ RemoveFormComponent((FmControlData*)pEntry);
+
+
+ if (bAlterModel)
+ {
+ Reference< XIndexContainer > xContainer(xElement->getParent(), UNO_QUERY);
+ // aus dem Container entfernen
+ sal_Int32 nContainerIndex = getElementPos(xContainer.get(), xElement);
+ // UndoAction
+ if (nContainerIndex >= 0)
+ {
+ if ( bUndo && m_pPropChangeList->CanUndo())
+ {
+ m_pFormModel->AddUndo(new FmUndoContainerAction(*m_pFormModel,
+ FmUndoContainerAction::Removed,
+ xContainer,
+ xElement, nContainerIndex ));
+ }
+ else if( !m_pPropChangeList->CanUndo() )
+ {
+ FmUndoContainerAction::DisposeElement( xElement );
+ }
+
+ xContainer->removeByIndex(nContainerIndex );
+ }
+
+ if( bUndo )
+ m_pFormModel->EndUndo();
+ }
+
+ // beim Vater austragen
+ if (pFolder)
+ pFolder->GetChildList()->Remove(pEntry);
+ else
+ {
+ GetRootList()->Remove(pEntry);
+ //////////////////////////////////////////////////////////////////////
+ // Wenn keine Form mehr in der Root, an der Shell CurForm zuruecksetzen
+ if (!GetRootList()->Count())
+ m_pFormShell->GetImpl()->forgetCurrentForm();
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // UI benachrichtigen
+ FmNavRemovedHint aRemovedHint( pEntry );
+ Broadcast( aRemovedHint );
+
+ // Eintrag loeschen
+ delete pEntry;
+
+ m_pPropChangeList->UnLock();
+ StartListening(*m_pFormModel);
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::RemoveForm(FmFormData* pFormData)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::RemoveForm" );
+ //////////////////////////////////////////////////////////////////////
+ // Form und Parent holen
+ if (!pFormData || !m_pFormModel)
+ return;
+
+ FmEntryDataList* pChildList = pFormData->GetChildList();
+ sal_uInt32 nCount = pChildList->Count();
+ for (sal_uInt32 i = nCount; i > 0; i--)
+ {
+ FmEntryData* pEntryData = pChildList->GetObject(i - 1);
+
+ //////////////////////////////////////////////////////////////////////
+ // Child ist Form -> rekursiver Aufruf
+ if( pEntryData->ISA(FmFormData) )
+ RemoveForm( (FmFormData*)pEntryData);
+ else if( pEntryData->ISA(FmControlData) )
+ RemoveFormComponent((FmControlData*) pEntryData);
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Als PropertyChangeListener abmelden
+ Reference< XPropertySet > xSet( pFormData->GetPropertySet() );
+ if ( xSet.is() )
+ xSet->removePropertyChangeListener( FM_PROP_NAME, m_pPropChangeList );
+
+ Reference< XContainer > xContainer( pFormData->GetContainer() );
+ if (xContainer.is())
+ xContainer->removeContainerListener((XContainerListener*)m_pPropChangeList);
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::RemoveFormComponent(FmControlData* pControlData)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::RemoveFormComponent" );
+ //////////////////////////////////////////////////////////////////////
+ // Control und Parent holen
+ if (!pControlData)
+ return;
+
+ //////////////////////////////////////////////////////////////////////
+ // Als PropertyChangeListener abmelden
+ Reference< XPropertySet > xSet( pControlData->GetPropertySet() );
+ if (xSet.is())
+ xSet->removePropertyChangeListener( FM_PROP_NAME, m_pPropChangeList);
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::ClearBranch( FmFormData* pParentData )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::ClearBranch" );
+ //////////////////////////////////////////////////////////////////////
+ // Alle Eintraege dieses Zweiges loeschen
+ FmEntryDataList* pChildList = pParentData->GetChildList();
+ FmEntryData* pChildData;
+
+ for( sal_uInt32 i=pChildList->Count(); i>0; i-- )
+ {
+ pChildData = pChildList->GetObject(i-1);
+ if( pChildData->ISA(FmFormData) )
+ ClearBranch( (FmFormData*)pChildData );
+
+ pChildList->Remove( pChildData );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::FillBranch( FmFormData* pFormData )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::FillBranch" );
+ //////////////////////////////////////////////////////////////
+ // Forms aus der Root einfuegen
+ if( pFormData == NULL )
+ {
+ Reference< XIndexContainer > xForms(GetForms(), UNO_QUERY);
+ if (!xForms.is())
+ return;
+
+ Reference< XForm > xSubForm;
+ FmFormData* pSubFormData;
+ for (sal_Int32 i=0; i<xForms->getCount(); ++i)
+ {
+ DBG_ASSERT( xForms->getByIndex(i).getValueType() == ::getCppuType((const Reference< XForm>*)NULL),
+ "NavigatorTreeModel::FillBranch : the root container should supply only elements of type XForm");
+
+ xForms->getByIndex(i) >>= xSubForm;
+ pSubFormData = new FmFormData( xSubForm, m_aNormalImages, m_aHCImages, pFormData );
+ Insert( pSubFormData, LIST_APPEND );
+
+ //////////////////////////////////////////////////////////////
+ // Neuer Branch, wenn SubForm wiederum Subforms enthaelt
+ FillBranch( pSubFormData );
+ }
+ }
+
+ //////////////////////////////////////////////////////////////
+ // Componenten einfuegen
+ else
+ {
+ Reference< XIndexContainer > xComponents( GetFormComponents(pFormData));
+ if( !xComponents.is() ) return;
+
+ ::rtl::OUString aControlName;
+ Reference< XInterface > xInterface;
+ Reference< XPropertySet > xSet;
+ FmControlData* pNewControlData;
+ FmFormData* pSubFormData;
+
+ Reference< XFormComponent > xCurrentComponent;
+ for (sal_Int32 j=0; j<xComponents->getCount(); ++j)
+ {
+ xComponents->getByIndex(j) >>= xCurrentComponent;
+ Reference< XForm > xSubForm(xCurrentComponent, UNO_QUERY);
+
+ if (xSubForm.is())
+ { // die aktuelle Component ist eine Form
+ pSubFormData = new FmFormData(xSubForm, m_aNormalImages, m_aHCImages, pFormData);
+ Insert(pSubFormData, LIST_APPEND);
+
+ //////////////////////////////////////////////////////////////
+ // Neuer Branch, wenn SubForm wiederum Subforms enthaelt
+ FillBranch(pSubFormData);
+ }
+ else
+ {
+ pNewControlData = new FmControlData(xCurrentComponent, m_aNormalImages, m_aHCImages, pFormData);
+ Insert(pNewControlData, LIST_APPEND);
+ }
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::InsertForm(const Reference< XForm > & xForm, sal_uInt32 nRelPos)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::InsertForm" );
+ FmFormData* pFormData = (FmFormData*)FindData( xForm, GetRootList() );
+ if (pFormData)
+ return;
+
+ //////////////////////////////////////////////////////////
+ // ParentData setzen
+ Reference< XInterface > xIFace( xForm->getParent());
+ Reference< XForm > xParentForm(xIFace, UNO_QUERY);
+ FmFormData* pParentData = NULL;
+ if (xParentForm.is())
+ pParentData = (FmFormData*)FindData( xParentForm, GetRootList() );
+
+ pFormData = new FmFormData( xForm, m_aNormalImages, m_aHCImages, pParentData );
+ Insert( pFormData, nRelPos );
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::InsertFormComponent(const Reference< XFormComponent > & xComp, sal_uInt32 nRelPos)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::InsertFormComponent" );
+ //////////////////////////////////////////////////////////
+ // ParentData setzen
+ Reference< XInterface > xIFace( xComp->getParent());
+ Reference< XForm > xForm(xIFace, UNO_QUERY);
+ if (!xForm.is())
+ return;
+
+ FmFormData* pParentData = (FmFormData*)FindData( xForm, GetRootList() );
+ if( !pParentData )
+ {
+ pParentData = new FmFormData( xForm, m_aNormalImages, m_aHCImages, NULL );
+ Insert( pParentData, LIST_APPEND );
+ }
+
+ if (!FindData(xComp, pParentData->GetChildList(),sal_False))
+ {
+ //////////////////////////////////////////////////////////
+ // Neue EntryData setzen
+ FmEntryData* pNewEntryData = new FmControlData( xComp, m_aNormalImages, m_aHCImages, pParentData );
+
+ //////////////////////////////////////////////////////////
+ // Neue EntryData einfuegen
+ Insert( pNewEntryData, nRelPos );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::ReplaceFormComponent(const Reference< XFormComponent > & xOld, const Reference< XFormComponent > & xNew)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::ReplaceFormComponent" );
+ FmEntryData* pData = FindData(xOld, GetRootList(), sal_True);
+ DBG_ASSERT(pData && pData->ISA(FmControlData), "NavigatorTreeModel::ReplaceFormComponent : invalid argument !");
+ ((FmControlData*)pData)->ModelReplaced( xNew, m_aNormalImages, m_aHCImages );
+
+ FmNavModelReplacedHint aReplacedHint( pData );
+ Broadcast( aReplacedHint );
+ }
+
+ //------------------------------------------------------------------------
+ FmEntryData* NavigatorTreeModel::FindData(const Reference< XInterface > & xElement, FmEntryDataList* pDataList, sal_Bool bRecurs)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::FindData" );
+ // normalize
+ Reference< XInterface > xIFace( xElement, UNO_QUERY );
+
+ for (sal_uInt16 i=0; i < pDataList->Count(); i++)
+ {
+ FmEntryData* pEntryData = pDataList->GetObject(i);
+ if ( pEntryData->GetElement().get() == xIFace.get() )
+ return pEntryData;
+ else if (bRecurs)
+ {
+ pEntryData = FindData( xElement, pEntryData->GetChildList() );
+ if (pEntryData)
+ return pEntryData;
+ }
+ }
+ return NULL;
+ }
+
+ //------------------------------------------------------------------------
+ FmEntryData* NavigatorTreeModel::FindData( const ::rtl::OUString& rText, FmFormData* pParentData, sal_Bool bRecurs )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::FindData" );
+ FmEntryDataList* pDataList;
+ if( !pParentData )
+ pDataList = GetRootList();
+ else
+ pDataList = pParentData->GetChildList();
+
+ ::rtl::OUString aEntryText;
+ FmEntryData* pEntryData;
+ FmEntryData* pChildData;
+
+ for( sal_uInt16 i=0; i<pDataList->Count(); i++ )
+ {
+ pEntryData = pDataList->GetObject(i);
+ aEntryText = pEntryData->GetText();
+
+ if (rText == aEntryText)
+ return pEntryData;
+
+ if( bRecurs && pEntryData->ISA(FmFormData) )
+ {
+ pChildData = FindData( rText, (FmFormData*)pEntryData );
+ if( pChildData )
+ return pChildData;
+ }
+ }
+
+ return NULL;
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Notify" );
+ if( rHint.ISA(SdrHint) )
+ {
+ SdrHint* pSdrHint = (SdrHint*)&rHint;
+ switch( pSdrHint->GetKind() )
+ {
+ case HINT_OBJINSERTED:
+ InsertSdrObj(pSdrHint->GetObject());
+ break;
+ case HINT_OBJREMOVED:
+ RemoveSdrObj(pSdrHint->GetObject());
+ break;
+ default:
+ break;
+ }
+ }
+ // hat sich die shell verabschiedet?
+ else if ( rHint.ISA(SfxSimpleHint) && ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING)
+ UpdateContent((FmFormShell*)NULL);
+
+ // hat sich die Markierung der Controls veraendert ?
+ else if (rHint.ISA(FmNavViewMarksChanged))
+ {
+ FmNavViewMarksChanged* pvmcHint = (FmNavViewMarksChanged*)&rHint;
+ BroadcastMarkedObjects( pvmcHint->GetAffectedView()->GetMarkedObjectList() );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::InsertSdrObj( const SdrObject* pObj )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::InsertSdrObj" );
+ const FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
+ if ( pFormObject )
+ {
+ try
+ {
+ Reference< XFormComponent > xFormComponent( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
+ Reference< XIndexAccess > xContainer( xFormComponent->getParent(), UNO_QUERY_THROW );
+
+ sal_Int32 nPos = getElementPos( xContainer, xFormComponent );
+ InsertFormComponent( xFormComponent, nPos );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else if ( pObj->IsGroupObject() )
+ {
+ SdrObjListIter aIter( *pObj->GetSubList() );
+ while ( aIter.IsMore() )
+ InsertSdrObj( aIter.Next() );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::RemoveSdrObj( const SdrObject* pObj )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::RemoveSdrObj" );
+ const FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
+ if ( pFormObject )
+ {
+ try
+ {
+ Reference< XFormComponent > xFormComponent( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
+ FmEntryData* pEntryData = FindData( xFormComponent, GetRootList(), sal_True );
+ if ( pEntryData )
+ Remove( pEntryData );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ else if ( pObj->IsGroupObject() )
+ {
+ SdrObjListIter aIter( *pObj->GetSubList() );
+ while ( aIter.IsMore() )
+ RemoveSdrObj( aIter.Next() );
+ }
+ }
+
+ sal_Bool NavigatorTreeModel::InsertFormComponent(FmNavRequestSelectHint& rHint, SdrObject* pObject)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::InsertFormComponent" );
+ if ( pObject->ISA(SdrObjGroup) )
+ { // rekursiv absteigen
+ const SdrObjList *pChilds = ((SdrObjGroup*)pObject)->GetSubList();
+ for ( sal_uInt16 i=0; i<pChilds->GetObjCount(); ++i )
+ {
+ SdrObject* pCurrent = pChilds->GetObj(i);
+ if (!InsertFormComponent(rHint, pCurrent))
+ return sal_False;
+ }
+ }
+ else
+ {
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pObject );
+ if ( !pFormObject )
+ return sal_False;
+
+ try
+ {
+ Reference< XFormComponent > xFormViewControl( pFormObject->GetUnoControlModel(), UNO_QUERY_THROW );
+ FmEntryData* pControlData = FindData( xFormViewControl, GetRootList() );
+ if ( !pControlData )
+ return sal_False;
+
+ rHint.AddItem( pControlData );
+ return sal_True;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+ }
+
+ void NavigatorTreeModel::BroadcastMarkedObjects(const SdrMarkList& mlMarked)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::BroadcastMarkedObjects" );
+ // gehen wir durch alle markierten Objekte und suchen wir die raus, mit denen ich was anfangen kann
+ FmNavRequestSelectHint rshRequestSelection;
+ sal_Bool bIsMixedSelection = sal_False;
+
+ for (ULONG i=0; (i<mlMarked.GetMarkCount()) && !bIsMixedSelection; i++)
+ {
+ SdrObject* pobjCurrent = mlMarked.GetMark(i)->GetMarkedSdrObj();
+ bIsMixedSelection |= !InsertFormComponent(rshRequestSelection, pobjCurrent);
+ // bei einem Nicht-Form-Control liefert InsertFormComponent sal_False !
+ }
+
+ rshRequestSelection.SetMixedSelection(bIsMixedSelection);
+ if (bIsMixedSelection)
+ rshRequestSelection.ClearItems();
+
+ Broadcast(rshRequestSelection);
+ // eine leere Liste interpretiert der NavigatorTree so, dass er seine Selektion komplett rausnimmt
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::UpdateContent( const Reference< XNameContainer > & xForms )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::UpdateContent" );
+ //////////////////////////////////////////////////////////////////////
+ // Model von der Root aufwaerts neu fuellen
+ Clear();
+ if (xForms.is())
+ {
+ Reference< XContainer > xFormContainer(xForms, UNO_QUERY);
+ if (xFormContainer.is())
+ xFormContainer->addContainerListener((XContainerListener*)m_pPropChangeList);
+
+ FillBranch(NULL);
+
+ // jetzt in meinem Tree genau die das in meiner View markierte Control selektieren
+ // (bzw alle solchen), falls es eines gibt ...
+ if(!m_pFormShell) return; // keine Shell -> wech
+
+ FmFormView* pFormView = m_pFormShell->GetFormView();
+ DBG_ASSERT(pFormView != NULL, "NavigatorTreeModel::UpdateContent : keine FormView");
+ BroadcastMarkedObjects(pFormView->GetMarkedObjectList());
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void NavigatorTreeModel::UpdateContent( FmFormShell* pShell )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::UpdateContent" );
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Shell sich nicht veraendert hat, nichts machen
+ FmFormPage* pNewPage = pShell ? pShell->GetCurPage() : NULL;
+ if ((pShell == m_pFormShell) && (m_pFormPage == pNewPage))
+ return;
+
+ //////////////////////////////////////////////////////////////////////
+ // Als Listener abmelden
+ if( m_pFormShell )
+ {
+ if (m_pFormModel)
+ EndListening( *m_pFormModel );
+ m_pFormModel = NULL;
+ EndListening( *m_pFormShell );
+ Clear();
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Vollupdate
+ m_pFormShell = pShell;
+ if (m_pFormShell)
+ {
+ m_pFormPage = pNewPage;
+ UpdateContent(m_pFormPage->GetForms());
+ } else
+ m_pFormPage = NULL;
+
+ //////////////////////////////////////////////////////////////////////
+ // Als Listener neu anmelden
+ if( m_pFormShell )
+ {
+ StartListening( *m_pFormShell );
+ m_pFormModel = m_pFormShell->GetFormModel();
+ if( m_pFormModel )
+ StartListening( *m_pFormModel );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XIndexContainer > NavigatorTreeModel::GetFormComponents( FmFormData* pFormData )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::GetFormComponents" );
+ //////////////////////////////////////////////////////////////////////
+ // Von der Form Components holen
+ if (pFormData)
+ return Reference< XIndexContainer > (pFormData->GetFormIface(), UNO_QUERY);
+
+ return Reference< XIndexContainer > ();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTreeModel::CheckEntry( FmEntryData* pEntryData )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::CheckEntry" );
+ //////////////////////////////////////////////////////////////////////
+ // Nur Forms duerfen auf Doppeldeutigkeit untersucht werden
+ if( !pEntryData->ISA(FmFormData) ) return sal_True;
+
+ //////////////////////////////////////////////////////////////////////
+ // ChildListe des Parents holen
+ FmFormData* pParentData = (FmFormData*)pEntryData->GetParent();
+ FmEntryDataList* pChildList;
+ if( !pParentData )
+ pChildList = GetRootList();
+ else
+ pChildList = pParentData->GetChildList();
+
+ //////////////////////////////////////////////////////////////////////
+ // In ChildListe nach doppelten Namen suchen
+ ::rtl::OUString aChildText;
+ FmEntryData* pChildData;
+
+ for( sal_uInt16 i=0; i<pChildList->Count(); i++ )
+ {
+ pChildData = pChildList->GetObject(i);
+ aChildText = pChildData->GetText();
+
+ //////////////////////////////////////////////////////////////////////
+ // Gleichen Eintrag gefunden
+ if ( (aChildText == pEntryData->GetText())
+ && (pEntryData!=pChildData)
+ )
+ {
+
+
+ SQLContext aError;
+ aError.Message = String(SVX_RES(RID_ERR_CONTEXT_ADDFORM));
+ aError.Details = String(SVX_RES(RID_ERR_DUPLICATE_NAME));
+ displayException(aError);
+
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTreeModel::Rename( FmEntryData* pEntryData, const ::rtl::OUString& rNewText )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Rename" );
+ //////////////////////////////////////////////////////////////////////
+ // Wenn Name schon vorhanden, Fehlermeldung
+ pEntryData->SetText( rNewText );
+
+ //////////////////////////////////////////////////////////////////////
+ // PropertySet besorgen
+ Reference< XFormComponent > xFormComponent;
+
+ if( pEntryData->ISA(FmFormData) )
+ {
+ FmFormData* pFormData = (FmFormData*)pEntryData;
+ Reference< XForm > xForm( pFormData->GetFormIface());
+ xFormComponent = Reference< XFormComponent > (xForm, UNO_QUERY);
+ }
+
+ if( pEntryData->ISA(FmControlData) )
+ {
+ FmControlData* pControlData = (FmControlData*)pEntryData;
+ xFormComponent = pControlData->GetFormComponent();
+ }
+
+ if( !xFormComponent.is() ) return sal_False;
+ Reference< XPropertySet > xSet(xFormComponent, UNO_QUERY);
+ if( !xSet.is() ) return sal_False;
+
+ //////////////////////////////////////////////////////////////////////
+ // Namen setzen
+ xSet->setPropertyValue( FM_PROP_NAME, makeAny(rNewText) );
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool NavigatorTreeModel::IsNameAlreadyDefined( const ::rtl::OUString& rName, FmFormData* pParentData )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::IsNameAlreadyDefined" );
+ //////////////////////////////////////////////////////////////////////
+ // Form in der Root
+ if( !pParentData )
+ {
+ if (GetForms()->hasByName(rName))
+ return sal_True;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // Restliche Components
+ else
+ {
+ Reference< XNameContainer > xFormComponents(GetFormComponents(pParentData), UNO_QUERY);
+ if (xFormComponents.is() && xFormComponents->hasByName(rName))
+ return sal_True;
+ }
+
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------------
+ SdrObject* NavigatorTreeModel::GetSdrObj( FmControlData* pControlData )
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::GetSdrObj" );
+ if (!pControlData || !m_pFormShell)
+ return NULL;
+
+ //////////////////////////////////////////////////////////////////////
+ // In der Page das entsprechende SdrObj finden und selektieren
+ Reference< XFormComponent > xFormComponent( pControlData->GetFormComponent());
+ if (!xFormComponent.is())
+ return NULL;
+
+ FmFormView* pFormView = m_pFormShell->GetFormView();
+ SdrPageView* pPageView = pFormView->GetSdrPageView();
+ SdrPage* pPage = pPageView->GetPage();
+
+ SdrObjListIter aIter( *pPage );
+ return Search(aIter, xFormComponent);
+ }
+
+ //------------------------------------------------------------------
+ SdrObject* NavigatorTreeModel::Search(SdrObjListIter& rIter, const Reference< XFormComponent > & xComp)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "NavigatorTreeModel::Search" );
+ while (rIter.IsMore())
+ {
+ SdrObject* pObj = rIter.Next();
+ FmFormObj* pFormObject = FmFormObj::GetFormObject( pObj );
+ if ( pFormObject )
+ {
+ Reference< XFormComponent > xFormViewControl( pFormObject->GetUnoControlModel(), UNO_QUERY );
+ if ( xFormViewControl == xComp )
+ return pObj;
+ }
+ else if ( pObj->IsGroupObject() )
+ {
+ SdrObjListIter aIter( *pObj->GetSubList() );
+ pObj = Search( aIter, xComp );
+ if ( pObj )
+ return pObj;
+ }
+ }
+ return NULL;
+ }
+
+//............................................................................
+} // namespace svxform
+//............................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/sdbdatacolumn.cxx b/svx/source/form/sdbdatacolumn.cxx
new file mode 100644
index 000000000000..084bad82c2a5
--- /dev/null
+++ b/svx/source/form/sdbdatacolumn.cxx
@@ -0,0 +1,290 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "sdbdatacolumn.hxx"
+
+//..............................................................................
+namespace svxform
+{
+//..............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::io;
+ using namespace ::com::sun::star::container;
+
+ //==========================================================================
+ //= DataColumn - a class wrapping an object implementing a sdb::DataColumn service
+ //==========================================================================
+ DataColumn::DataColumn(const Reference< ::com::sun::star::beans::XPropertySet>& _rxIFace)
+ {
+ m_xPropertySet = _rxIFace;
+ m_xColumn = Reference< ::com::sun::star::sdb::XColumn>(_rxIFace, UNO_QUERY);
+ m_xColumnUpdate = Reference< ::com::sun::star::sdb::XColumnUpdate>(_rxIFace, UNO_QUERY);
+
+ if (!m_xPropertySet.is() || !m_xColumn.is())
+ {
+ m_xPropertySet = NULL;
+ m_xColumn = NULL;
+ m_xColumnUpdate = NULL;
+ }
+ }
+
+ // Reference< XPropertySet>
+ Reference< XPropertySetInfo> DataColumn::getPropertySetInfo() const throw( RuntimeException )
+ {
+ return m_xPropertySet->getPropertySetInfo();
+ }
+
+ void DataColumn::setPropertyValue(const ::rtl::OUString& aPropertyName, const Any& aValue) throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
+ {
+ m_xPropertySet->setPropertyValue(aPropertyName, aValue);
+ }
+
+ Any DataColumn::getPropertyValue(const ::rtl::OUString& PropertyName) const throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+ {
+ return m_xPropertySet->getPropertyValue(PropertyName);
+ }
+
+ void DataColumn::addPropertyChangeListener(const ::rtl::OUString& aPropertyName, const Reference< XPropertyChangeListener>& xListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+ {
+ m_xPropertySet->addPropertyChangeListener(aPropertyName, xListener);
+ }
+
+ void DataColumn::removePropertyChangeListener(const ::rtl::OUString& aPropertyName, const Reference< XPropertyChangeListener>& aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+ {
+ m_xPropertySet->removePropertyChangeListener(aPropertyName, aListener);
+ }
+
+ void DataColumn::addVetoableChangeListener(const ::rtl::OUString& PropertyName, const Reference< XVetoableChangeListener>& aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+ {
+ m_xPropertySet->addVetoableChangeListener(PropertyName, aListener);
+ }
+
+ void DataColumn::removeVetoableChangeListener(const ::rtl::OUString& PropertyName, const Reference< XVetoableChangeListener>& aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+ {
+ m_xPropertySet->removeVetoableChangeListener(PropertyName, aListener);
+ }
+
+ // XColumn
+ sal_Bool DataColumn::wasNull() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->wasNull();
+ }
+
+ ::rtl::OUString DataColumn::getString() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getString();
+ }
+
+ sal_Bool DataColumn::getBoolean() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getBoolean();
+ }
+
+ sal_Int8 DataColumn::getByte() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getByte();
+ }
+
+ sal_Int16 DataColumn::getShort() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getShort();
+ }
+
+ sal_Int32 DataColumn::getInt() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getInt();
+ }
+
+ sal_Int64 DataColumn::getLong() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getLong();
+ }
+
+ float DataColumn::getFloat() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getFloat();
+ }
+
+ double DataColumn::getDouble() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getDouble();
+ }
+
+ Sequence< sal_Int8 > DataColumn::getBytes() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getBytes();
+ }
+
+ com::sun::star::util::Date DataColumn::getDate() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getDate();
+ }
+
+ com::sun::star::util::Time DataColumn::getTime() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getTime();
+ }
+
+ com::sun::star::util::DateTime DataColumn::getTimestamp() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getTimestamp();
+ }
+
+ Reference< XInputStream> DataColumn::getBinaryStream() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getBinaryStream();
+ }
+
+ Reference< XInputStream> DataColumn::getCharacterStream() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getCharacterStream();
+ }
+
+ Any DataColumn::getObject(const Reference< XNameAccess>& typeMap) throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getObject(typeMap);
+ }
+
+ Reference< XRef> DataColumn::getRef() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getRef();
+ }
+
+ Reference< XBlob> DataColumn::getBlob() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getBlob();
+ }
+
+ Reference< XClob> DataColumn::getClob() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getClob();
+ }
+
+ Reference< XArray> DataColumn::getArray() throw( SQLException, RuntimeException )
+ {
+ return m_xColumn->getArray();
+ }
+
+ // XColumnUpdate
+ void DataColumn::updateNull() throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateNull();
+ }
+
+ void DataColumn::updateBoolean(sal_Bool x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateBoolean(x);
+ }
+
+ void DataColumn::updateByte(sal_Int8 x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateByte(x);
+ }
+
+ void DataColumn::updateShort(sal_Int16 x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateShort(x);
+ }
+
+ void DataColumn::updateInt(sal_Int32 x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateInt(x);
+ }
+
+ void DataColumn::updateLong(sal_Int64 x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateLong(x);
+ }
+
+ void DataColumn::updateFloat(float x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateFloat(x);
+ }
+
+ void DataColumn::updateDouble(double x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateDouble(x);
+ }
+
+ void DataColumn::updateString(const ::rtl::OUString& x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateString(x);
+ }
+
+ void DataColumn::updateBytes(const Sequence< sal_Int8 >& x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateBytes(x);
+ }
+
+ void DataColumn::updateDate(const com::sun::star::util::Date& x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateDate(x);
+ }
+
+ void DataColumn::updateTime(const com::sun::star::util::Time& x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateTime(x);
+ }
+
+ void DataColumn::updateTimestamp(const com::sun::star::util::DateTime& x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateTimestamp(x);
+ }
+
+ void DataColumn::updateBinaryStream(const Reference< XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateBinaryStream(x, length);
+ }
+
+ void DataColumn::updateCharacterStream(const Reference< XInputStream>& x, sal_Int32 length) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateCharacterStream(x, length);
+ }
+
+ void DataColumn::updateObject(const Any& x) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateObject(x);
+ }
+
+ void DataColumn::updateNumericObject(const Any& x, sal_Int32 scale) throw( SQLException, RuntimeException )
+ {
+ m_xColumnUpdate->updateNumericObject(x, scale);
+ }
+
+ //..............................................................................
+} // namespace svxform
+//..............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/sqlparserclient.cxx b/svx/source/form/sqlparserclient.cxx
new file mode 100644
index 000000000000..ba8ebe4aac10
--- /dev/null
+++ b/svx/source/form/sqlparserclient.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "sqlparserclient.hxx"
+#include "ParseContext.hxx"
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+
+ //====================================================================
+ //= OSQLParserClient
+ //====================================================================
+ //--------------------------------------------------------------------
+ OSQLParserClient::OSQLParserClient(const Reference< XMultiServiceFactory >& _rxORB)
+ {
+ m_xORB = _rxORB;
+ }
+ //--------------------------------------------------------------------
+ bool OSQLParserClient::ensureLoaded() const
+ {
+ if ( !ODbtoolsClient::ensureLoaded() )
+ return false;
+ m_xParser = getFactory()->createSQLParser(m_xORB,getParseContext());
+ return m_xParser.is();
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/stringlistresource.cxx b/svx/source/form/stringlistresource.cxx
new file mode 100644
index 000000000000..9e06f0851f2e
--- /dev/null
+++ b/svx/source/form/stringlistresource.cxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "stringlistresource.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <tools/rcid.h>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= StringListResource
+ //====================================================================
+ //--------------------------------------------------------------------
+ StringListResource::StringListResource( const ResId& _rResId )
+ :Resource( _rResId )
+ {
+ USHORT nLocalID = 1;
+ ResId aLocalID( nLocalID, *_rResId.GetResMgr() );
+ while ( IsAvailableRes( aLocalID.SetRT( RSC_STRING ) ) )
+ {
+ String sLocalString( aLocalID );
+ m_aStrings.push_back( sLocalString );
+ aLocalID = ResId( ++nLocalID, *_rResId.GetResMgr() );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ StringListResource::~StringListResource()
+ {
+ FreeResource();
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/tabwin.cxx b/svx/source/form/tabwin.cxx
new file mode 100644
index 000000000000..4748609b5ee7
--- /dev/null
+++ b/svx/source/form/tabwin.cxx
@@ -0,0 +1,470 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "tabwin.hxx"
+#include "svx/fmtools.hxx"
+#include "fmservs.hxx"
+#include "stringlistresource.hxx"
+
+#include <svx/svxids.hrc>
+#include <svx/dbaexchange.hxx>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/util/XLocalizedAliases.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/stl_types.hxx>
+
+#include "fmhelp.hrc"
+#include <svx/fmshell.hxx>
+#include "fmshimp.hxx"
+#include "svx/dbtoolsclient.hxx"
+#include <svx/fmpage.hxx>
+
+#include "fmpgeimp.hxx"
+
+#include "fmprop.hrc"
+
+#include "fmresids.hrc"
+#include <svx/dialmgr.hxx>
+#include <tools/shl.hxx>
+#include <svx/svdpagv.hxx>
+#include <sfx2/objitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <comphelper/property.hxx>
+#include <sfx2/frame.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+
+const long STD_WIN_POS_X = 50;
+const long STD_WIN_POS_Y = 50;
+
+const long STD_WIN_SIZE_X = 120;
+const long STD_WIN_SIZE_Y = 150;
+
+const long MIN_WIN_SIZE_X = 50;
+const long MIN_WIN_SIZE_Y = 50;
+
+const long LISTBOX_BORDER = 2;
+
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star;
+using namespace ::svxform;
+using namespace ::svx;
+
+
+struct ColumnInfo
+{
+ ::rtl::OUString sColumnName;
+ ::rtl::OUString sLabel;
+ bool bColumn;
+ ColumnInfo(const ::rtl::OUString& i_sColumnName,const ::rtl::OUString& i_sLabel)
+ : sColumnName(i_sColumnName)
+ , sLabel(i_sLabel)
+ , bColumn(true)
+ {
+ }
+ ColumnInfo(const ::rtl::OUString& i_sColumnName)
+ : sColumnName(i_sColumnName)
+ , bColumn(false)
+ {
+ }
+};
+
+void lcl_addToList( SvTreeListBox& _rListBox, const uno::Reference< container::XNameAccess>& i_xColumns )
+{
+ uno::Sequence< ::rtl::OUString > aEntries = i_xColumns->getElementNames();
+ const ::rtl::OUString* pEntries = aEntries.getConstArray();
+ sal_Int32 nEntries = aEntries.getLength();
+ for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries )
+ {
+ uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(*pEntries),UNO_QUERY_THROW);
+ ::rtl::OUString sLabel;
+ if ( xColumn->getPropertySetInfo()->hasPropertyByName(FM_PROP_LABEL) )
+ xColumn->getPropertyValue(FM_PROP_LABEL) >>= sLabel;
+ if ( sLabel.getLength() )
+ _rListBox.InsertEntry( sLabel,NULL,FALSE,LIST_APPEND,new ColumnInfo(*pEntries,sLabel) );
+ else
+ _rListBox.InsertEntry( *pEntries,NULL,FALSE,LIST_APPEND,new ColumnInfo(*pEntries,sLabel) );
+ }
+}
+//==================================================================
+// class FmFieldWinListBox
+//==================================================================
+DBG_NAME(FmFieldWinListBox)
+//------------------------------------------------------------------------------
+FmFieldWinListBox::FmFieldWinListBox( FmFieldWin* pParent )
+ :SvTreeListBox( pParent, WB_HASBUTTONS|WB_BORDER )
+ ,pTabWin( pParent )
+{
+ DBG_CTOR(FmFieldWinListBox,NULL);
+ SetHelpId( HID_FIELD_SEL );
+
+ SetHighlightRange( );
+}
+
+//------------------------------------------------------------------------------
+FmFieldWinListBox::~FmFieldWinListBox()
+{
+ DBG_DTOR(FmFieldWinListBox,NULL);
+}
+
+//------------------------------------------------------------------------------
+sal_Int8 FmFieldWinListBox::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
+{
+ return DND_ACTION_NONE;
+}
+
+//------------------------------------------------------------------------------
+sal_Int8 FmFieldWinListBox::ExecuteDrop( const ExecuteDropEvent& /*rEvt*/ )
+{
+ return DND_ACTION_NONE;
+}
+
+//------------------------------------------------------------------------------
+BOOL FmFieldWinListBox::DoubleClickHdl()
+{
+ if ( pTabWin->createSelectionControls() )
+ return sal_True;
+
+ return SvTreeListBox::DoubleClickHdl();
+}
+
+//------------------------------------------------------------------------------
+void FmFieldWinListBox::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ )
+{
+ SvLBoxEntry* pSelected = FirstSelected();
+ if (!pSelected)
+ // no drag without a field
+ return;
+
+ ::svx::ODataAccessDescriptor aDescriptor;
+ aDescriptor[ daDataSource ] <<= pTabWin->GetDatabaseName();
+ aDescriptor[ daConnection ] <<= pTabWin->GetConnection().getTyped();
+ aDescriptor[ daCommand ] <<= pTabWin->GetObjectName();
+ aDescriptor[ daCommandType ]<<= pTabWin->GetObjectType();
+ ColumnInfo* pInfo = static_cast<ColumnInfo*>(pSelected->GetUserData());
+ aDescriptor[ daColumnName ] <<= pInfo->sColumnName;
+
+ TransferableHelper* pTransferColumn = new OColumnTransferable(
+ aDescriptor, CTF_FIELD_DESCRIPTOR | CTF_CONTROL_EXCHANGE | CTF_COLUMN_DESCRIPTOR
+ );
+ Reference< XTransferable> xEnsureDelete = pTransferColumn;
+ if (pTransferColumn)
+ {
+ EndSelection();
+ pTransferColumn->StartDrag( this, DND_ACTION_COPY );
+ }
+}
+
+//========================================================================
+// class FmFieldWinData
+//========================================================================
+DBG_NAME(FmFieldWinData);
+//-----------------------------------------------------------------------
+FmFieldWinData::FmFieldWinData()
+{
+ DBG_CTOR(FmFieldWinData,NULL);
+}
+
+//-----------------------------------------------------------------------
+FmFieldWinData::~FmFieldWinData()
+{
+ DBG_DTOR(FmFieldWinData,NULL);
+}
+
+//========================================================================
+// class FmFieldWin
+//========================================================================
+DBG_NAME(FmFieldWin);
+//-----------------------------------------------------------------------
+FmFieldWin::FmFieldWin(SfxBindings* _pBindings, SfxChildWindow* _pMgr, Window* _pParent)
+ :SfxFloatingWindow(_pBindings, _pMgr, _pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE))
+ ,SfxControllerItem(SID_FM_FIELDS_CONTROL, *_pBindings)
+ ,::comphelper::OPropertyChangeListener(m_aMutex)
+ ,pData(new FmFieldWinData)
+ ,m_nObjectType(0)
+ ,m_pChangeListener(NULL)
+{
+ DBG_CTOR(FmFieldWin,NULL);
+ SetHelpId( HID_FIELD_SEL_WIN );
+
+ SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor()) );
+ pListBox = new FmFieldWinListBox( this );
+ pListBox->Show();
+ UpdateContent(NULL);
+ SetSizePixel(Size(STD_WIN_SIZE_X,STD_WIN_SIZE_Y));
+}
+
+//-----------------------------------------------------------------------
+FmFieldWin::~FmFieldWin()
+{
+ if (m_pChangeListener)
+ {
+ m_pChangeListener->dispose();
+ m_pChangeListener->release();
+ // delete m_pChangeListener;
+ }
+ delete pListBox;
+ delete pData;
+ DBG_DTOR(FmFieldWin,NULL);
+}
+
+//-----------------------------------------------------------------------
+void FmFieldWin::GetFocus()
+{
+ if ( pListBox )
+ pListBox->GrabFocus();
+ else
+ SfxFloatingWindow::GetFocus();
+}
+
+//-----------------------------------------------------------------------
+sal_Bool FmFieldWin::createSelectionControls( )
+{
+ SvLBoxEntry* pSelected = pListBox->FirstSelected();
+ if ( pSelected )
+ {
+ // build a descriptor for the currently selected field
+ ODataAccessDescriptor aDescr;
+ aDescr.setDataSource(GetDatabaseName());
+
+ aDescr[ daConnection ] <<= GetConnection().getTyped();
+
+ aDescr[ daCommand ] <<= GetObjectName();
+ aDescr[ daCommandType ] <<= GetObjectType();
+ ColumnInfo* pInfo = static_cast<ColumnInfo*>(pSelected->GetUserData());
+ aDescr[ daColumnName ] <<= pInfo->sColumnName;//::rtl::OUString( pListBox->GetEntryText( pSelected) );
+
+ // transfer this to the SFX world
+ SfxUnoAnyItem aDescriptorItem( SID_FM_DATACCESS_DESCRIPTOR, makeAny( aDescr.createPropertyValueSequence() ) );
+ const SfxPoolItem* pArgs[] =
+ {
+ &aDescriptorItem, NULL
+ };
+
+ // execute the create slot
+ GetBindings().Execute( SID_FM_CREATE_FIELDCONTROL, pArgs );
+ }
+
+ return NULL != pSelected;
+}
+
+//-----------------------------------------------------------------------
+long FmFieldWin::PreNotify( NotifyEvent& _rNEvt )
+{
+ if ( EVENT_KEYINPUT == _rNEvt.GetType() )
+ {
+ const KeyCode& rKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode();
+ if ( ( 0 == rKeyCode.GetModifier() ) && ( KEY_RETURN == rKeyCode.GetCode() ) )
+ {
+ if ( createSelectionControls() )
+ return 1;
+ }
+ }
+
+ return SfxFloatingWindow::PreNotify( _rNEvt );
+}
+
+//-----------------------------------------------------------------------
+sal_Bool FmFieldWin::Close()
+{
+ return SfxFloatingWindow::Close();
+}
+
+//-----------------------------------------------------------------------
+void FmFieldWin::_propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException )
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > xForm(evt.Source, ::com::sun::star::uno::UNO_QUERY);
+ UpdateContent(xForm);
+}
+
+//-----------------------------------------------------------------------
+void FmFieldWin::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState)
+{
+ if (!pState || SID_FM_FIELDS_CONTROL != nSID)
+ return;
+
+ if (eState >= SFX_ITEM_AVAILABLE)
+ {
+ FmFormShell* pShell = PTR_CAST(FmFormShell,((SfxObjectItem*)pState)->GetShell());
+ UpdateContent(pShell);
+ }
+ else
+ UpdateContent(NULL);
+}
+
+//-----------------------------------------------------------------------
+void FmFieldWin::UpdateContent(FmFormShell* pShell)
+{
+ pListBox->Clear();
+ String aTitle( SVX_RES( RID_STR_FIELDSELECTION ) );
+ SetText( aTitle );
+
+ if (!pShell || !pShell->GetImpl())
+ return;
+
+ Reference< XForm > xForm = pShell->GetImpl()->getCurrentForm();
+ if ( xForm.is() )
+ UpdateContent( xForm );
+}
+
+//-----------------------------------------------------------------------
+void FmFieldWin::UpdateContent(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > & xForm)
+{
+ try
+ {
+ // ListBox loeschen
+ pListBox->Clear();
+ UniString aTitle(SVX_RES(RID_STR_FIELDSELECTION));
+ SetText(aTitle);
+
+ if (!xForm.is())
+ return;
+
+ Reference< XPreparedStatement > xStatement;
+ Reference< XPropertySet > xSet(xForm, UNO_QUERY);
+
+ m_aObjectName = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_COMMAND));
+ m_aDatabaseName = ::comphelper::getString(xSet->getPropertyValue(FM_PROP_DATASOURCE));
+ m_nObjectType = ::comphelper::getINT32(xSet->getPropertyValue(FM_PROP_COMMANDTYPE));
+
+ // get the connection of the form
+ OStaticDataAccessTools aTools;
+ m_aConnection.reset(
+ aTools.connectRowset( Reference< XRowSet >( xForm, UNO_QUERY ), ::comphelper::getProcessServiceFactory(), sal_True ),
+ SharedConnection::NoTakeOwnership
+ );
+ // TODO: When incompatible changes (such as extending the "virtualdbtools" interface by ensureRowSetConnection)
+ // are allowed, again, we should change this: dbtools should consistently use SharedConnection all over
+ // the place, and connectRowset should be replaced with ensureRowSetConnection
+
+ // get the fields of the object
+
+ if ( m_aConnection.is() && m_aObjectName.getLength() )
+ {
+ Reference< XComponent > xKeepFieldsAlive;
+ Reference< XNameAccess > xColumns = getFieldsByCommandDescriptor( m_aConnection, m_nObjectType, m_aObjectName,xKeepFieldsAlive );
+ if ( xColumns.is() )
+ lcl_addToList(*pListBox,xColumns);
+ }
+
+ // Prefix setzen
+ UniString aPrefix;
+ StringListResource aPrefixes( SVX_RES( RID_RSC_TABWIN_PREFIX ) );
+
+ switch (m_nObjectType)
+ {
+ case CommandType::TABLE:
+ aPrefix = aPrefixes[0];
+ break;
+ case CommandType::QUERY:
+ aPrefix = aPrefixes[1];
+ break;
+ default:
+ aPrefix = aPrefixes[2];
+ break;
+ }
+
+ // an dem PropertySet nach Aenderungen der ControlSource lauschen
+ if (m_pChangeListener)
+ {
+ m_pChangeListener->dispose();
+ m_pChangeListener->release();
+ }
+ m_pChangeListener = new ::comphelper::OPropertyChangeMultiplexer(this, xSet);
+ m_pChangeListener->acquire();
+ m_pChangeListener->addProperty(FM_PROP_DATASOURCE);
+ m_pChangeListener->addProperty(FM_PROP_COMMAND);
+ m_pChangeListener->addProperty(FM_PROP_COMMANDTYPE);
+
+ // Titel setzen
+ aTitle.AppendAscii(" ");
+ aTitle += aPrefix;
+ aTitle.AppendAscii(" ");
+ aTitle += m_aObjectName.getStr();
+ SetText( aTitle );
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "FmTabWin::UpdateContent: caught an exception!" );
+ }
+}
+
+//-----------------------------------------------------------------------
+void FmFieldWin::Resize()
+{
+ SfxFloatingWindow::Resize();
+
+ Point aPos(GetPosPixel());
+ Size aOutputSize( GetOutputSizePixel() );
+
+ //////////////////////////////////////////////////////////////////////
+
+ // Groesse der ::com::sun::star::form::ListBox anpassen
+ Point aLBPos( LISTBOX_BORDER, LISTBOX_BORDER );
+ Size aLBSize( aOutputSize );
+ aLBSize.Width() -= (2*LISTBOX_BORDER);
+ aLBSize.Height() -= (2*LISTBOX_BORDER);
+
+ pListBox->SetPosSizePixel( aLBPos, aLBSize );
+}
+
+//-----------------------------------------------------------------------
+void FmFieldWin::FillInfo( SfxChildWinInfo& rInfo ) const
+{
+ rInfo.bVisible = sal_False;
+}
+
+//-----------------------------------------------------------------------
+SFX_IMPL_FLOATINGWINDOW(FmFieldWinMgr, SID_FM_ADD_FIELD)
+
+//-----------------------------------------------------------------------
+FmFieldWinMgr::FmFieldWinMgr(Window* _pParent, sal_uInt16 _nId,
+ SfxBindings* _pBindings, SfxChildWinInfo* _pInfo)
+ :SfxChildWindow(_pParent, _nId)
+{
+ pWindow = new FmFieldWin(_pBindings, this, _pParent);
+ SetHideNotDelete(sal_True);
+ eChildAlignment = SFX_ALIGN_NOALIGNMENT;
+ ((SfxFloatingWindow*)pWindow)->Initialize( _pInfo );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/tbxform.cxx b/svx/source/form/tbxform.cxx
new file mode 100644
index 000000000000..872a78ab356f
--- /dev/null
+++ b/svx/source/form/tbxform.cxx
@@ -0,0 +1,473 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+#include <tools/ref.hxx>
+#include <tools/shl.hxx>
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/fixed.hxx>
+#include "fmitems.hxx"
+#include "formtoolbars.hxx"
+
+
+#include <vcl/sound.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include "tbxctl.hxx"
+#include "tbxdraw.hxx"
+#include "tbxform.hxx"
+#include "fmresids.hrc"
+#include "fmitems.hxx"
+#include "fmhelp.hrc"
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using ::com::sun::star::beans::XPropertySet;
+
+
+//========================================================================
+// class SvxFmAbsRecWin
+//========================================================================
+
+// -----------------------------------------------------------------------
+SvxFmAbsRecWin::SvxFmAbsRecWin( Window* _pParent, SfxToolBoxControl* _pController )
+ :NumericField( _pParent, WB_BORDER )
+ ,m_pController(_pController)
+{
+ SetMin(1);
+ SetFirst(1);
+ SetSpinSize(1);
+ SetSizePixel( Size(70,19) );
+
+ SetDecimalDigits(0);
+ SetStrictFormat(TRUE);
+}
+
+// -----------------------------------------------------------------------
+SvxFmAbsRecWin::~SvxFmAbsRecWin()
+{
+}
+
+// -----------------------------------------------------------------------
+void SvxFmAbsRecWin::FirePosition( sal_Bool _bForce )
+{
+ if ( _bForce || ( GetText() != GetSavedValue() ) )
+ {
+ sal_Int64 nRecord = GetValue();
+ if (nRecord < GetMin() || nRecord > GetMax())
+ {
+ Sound::Beep();
+ return;
+ }
+
+ SfxInt32Item aPositionParam( FN_PARAM_1, static_cast<INT32>(nRecord) );
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Position" ));
+ aPositionParam.QueryValue( a );
+ aArgs[0].Value = a;
+ m_pController->Dispatch( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AbsoluteRecord" )),
+ aArgs );
+ m_pController->updateStatus();
+
+ SaveValue();
+ }
+}
+
+// -----------------------------------------------------------------------
+void SvxFmAbsRecWin::LoseFocus()
+{
+ FirePosition( sal_False );
+}
+
+// -----------------------------------------------------------------------
+void SvxFmAbsRecWin::KeyInput( const KeyEvent& rKeyEvent )
+{
+ if( rKeyEvent.GetKeyCode() == KEY_RETURN && GetText().Len() )
+ FirePosition( sal_True );
+ else
+ NumericField::KeyInput( rKeyEvent );
+}
+
+//========================================================================
+// class SvxFmTbxCtlConfig
+//========================================================================
+
+struct MapSlotToCmd
+{
+ USHORT nSlotId;
+ const char* pCommand;
+};
+
+static MapSlotToCmd SlotToCommands[] =
+{
+ { SID_FM_PUSHBUTTON, ".uno:Pushbutton" },
+ { SID_FM_RADIOBUTTON, ".uno:RadioButton" },
+ { SID_FM_CHECKBOX, ".uno:CheckBox" },
+ { SID_FM_FIXEDTEXT, ".uno:Label" },
+ { SID_FM_GROUPBOX, ".uno:GroupBox" },
+ { SID_FM_LISTBOX, ".uno:ListBox" },
+ { SID_FM_COMBOBOX, ".uno:ComboBox" },
+ { SID_FM_EDIT, ".uno:Edit" },
+ { SID_FM_DBGRID, ".uno:Grid" },
+ { SID_FM_IMAGEBUTTON, ".uno:Imagebutton" },
+ { SID_FM_IMAGECONTROL, ".uno:ImageControl" },
+ { SID_FM_FILECONTROL, ".uno:FileControl" },
+ { SID_FM_DATEFIELD, ".uno:DateField" },
+ { SID_FM_TIMEFIELD, ".uno:TimeField" },
+ { SID_FM_NUMERICFIELD, ".uno:NumericField" },
+ { SID_FM_CURRENCYFIELD, ".uno:CurrencyField" },
+ { SID_FM_PATTERNFIELD, ".uno:PatternField" },
+ { SID_FM_DESIGN_MODE, ".uno:SwitchControlDesignMode" },
+ { SID_FM_FORMATTEDFIELD, ".uno:FormattedField" },
+ { SID_FM_SCROLLBAR, ".uno:ScrollBar" },
+ { SID_FM_SPINBUTTON, ".uno:SpinButton" },
+ { 0, "" }
+};
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlConfig, SfxUInt16Item );
+
+//-----------------------------------------------------------------------
+SvxFmTbxCtlConfig::SvxFmTbxCtlConfig( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ : SfxToolBoxControl( nSlotId, nId, rTbx )
+ ,nLastSlot( 0 )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+}
+
+//-----------------------------------------------------------------------
+void SvxFmTbxCtlConfig::StateChanged(USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ if (nSID == SID_FM_CONFIG)
+ {
+ UINT16 nSlot = 0;
+ if (eState >= SFX_ITEM_AVAILABLE)
+ nSlot = ((SfxUInt16Item*)pState)->GetValue();
+
+ switch( nSlot )
+ {
+ case SID_FM_PUSHBUTTON:
+ case SID_FM_RADIOBUTTON:
+ case SID_FM_CHECKBOX:
+ case SID_FM_FIXEDTEXT:
+ case SID_FM_GROUPBOX:
+ case SID_FM_LISTBOX:
+ case SID_FM_COMBOBOX:
+ case SID_FM_NAVIGATIONBAR:
+ case SID_FM_EDIT:
+ case SID_FM_DBGRID:
+ case SID_FM_IMAGEBUTTON:
+ case SID_FM_IMAGECONTROL:
+ case SID_FM_FILECONTROL:
+ case SID_FM_DATEFIELD:
+ case SID_FM_TIMEFIELD:
+ case SID_FM_NUMERICFIELD:
+ case SID_FM_CURRENCYFIELD:
+ case SID_FM_PATTERNFIELD:
+ case SID_FM_DESIGN_MODE:
+ case SID_FM_FORMATTEDFIELD:
+ case SID_FM_SCROLLBAR:
+ case SID_FM_SPINBUTTON:
+ { // set a new image, matching to this slot
+ rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
+ aSlotURL += rtl::OUString::valueOf( sal_Int32( nSlot ));
+ Image aImage = GetImage( m_xFrame,
+ aSlotURL,
+ hasBigImages(),
+ GetToolBox().GetSettings().GetStyleSettings().GetHighContrastMode() );
+
+ GetToolBox().SetItemImage( GetId(), aImage );
+ nLastSlot = nSlot;
+ }
+ break;
+ }
+ }
+ SfxToolBoxControl::StateChanged( nSID, eState,pState );
+}
+
+//-----------------------------------------------------------------------
+SfxPopupWindowType SvxFmTbxCtlConfig::GetPopupWindowType() const
+{
+ return( nLastSlot == 0 ? SFX_POPUPWINDOW_ONCLICK : SFX_POPUPWINDOW_ONTIMEOUT );
+}
+
+//-----------------------------------------------------------------------
+SfxPopupWindow* SvxFmTbxCtlConfig::CreatePopupWindow()
+{
+ if ( GetSlotId() == SID_FM_CONFIG )
+ {
+ ::svxform::FormToolboxes aToolboxes( m_xFrame );
+ createAndPositionSubToolBar( aToolboxes.getToolboxResourceName( SID_FM_CONFIG ) );
+ }
+ return NULL;
+}
+
+//-----------------------------------------------------------------------
+void SvxFmTbxCtlConfig::Select( USHORT /*nModifier*/ )
+{
+ //////////////////////////////////////////////////////////////////////
+ // Click auf den Button SID_FM_CONFIG in der ObjectBar
+ if ( nLastSlot )
+ {
+ USHORT n = 0;
+ while( SlotToCommands[n].nSlotId > 0 )
+ {
+ if ( SlotToCommands[n].nSlotId == nLastSlot )
+ break;
+ n++;
+ }
+
+ if ( SlotToCommands[n].nSlotId > 0 )
+ {
+ Sequence< PropertyValue > aArgs;
+ Dispatch( rtl::OUString::createFromAscii( SlotToCommands[n].pCommand ),
+ aArgs );
+ }
+ }
+}
+
+
+//========================================================================
+// class SvxFmTbxCtlAbsRec
+//========================================================================
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlAbsRec, SfxInt32Item );
+DBG_NAME(SvxFmTbxCtlAbsRec);
+//-----------------------------------------------------------------------
+SvxFmTbxCtlAbsRec::SvxFmTbxCtlAbsRec( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ :SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ DBG_CTOR(SvxFmTbxCtlAbsRec,NULL);
+}
+
+//-----------------------------------------------------------------------
+SvxFmTbxCtlAbsRec::~SvxFmTbxCtlAbsRec()
+{
+ DBG_DTOR(SvxFmTbxCtlAbsRec,NULL);
+}
+
+//-----------------------------------------------------------------------
+void SvxFmTbxCtlAbsRec::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ USHORT nId = GetId();
+ ToolBox* pToolBox = &GetToolBox();
+ SvxFmAbsRecWin* pWin = (SvxFmAbsRecWin*)( pToolBox->GetItemWindow(nId) );
+
+ DBG_ASSERT( pWin, "Control not found!" );
+
+ if (pState)
+ {
+ const SfxInt32Item* pItem = PTR_CAST( SfxInt32Item, pState );
+ DBG_ASSERT( pItem, "SvxFmTbxCtlAbsRec::StateChanged: invalid item!" );
+ pWin->SetValue( pItem ? pItem->GetValue() : -1 );
+ }
+
+ BOOL bEnable = SFX_ITEM_DISABLED != eState && pState;
+ if (!bEnable)
+ pWin->SetText(String());
+
+ //////////////////////////////////////////////////////////////////////
+ // Enablen/disablen des Fensters
+ pToolBox->EnableItem(nId, bEnable);
+ SfxToolBoxControl::StateChanged( nSID, eState,pState );
+}
+
+//-----------------------------------------------------------------------
+Window* SvxFmTbxCtlAbsRec::CreateItemWindow( Window* pParent )
+{
+ SvxFmAbsRecWin* pWin = new SvxFmAbsRecWin( pParent, this );
+ pWin->SetUniqueId( UID_ABSOLUTE_RECORD_WINDOW );
+ return pWin;
+}
+
+
+//========================================================================
+// SvxFmTbxCtlRecText
+//========================================================================
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecText, SfxBoolItem );
+DBG_NAME(SvxFmTbxCtlRecText);
+//-----------------------------------------------------------------------
+SvxFmTbxCtlRecText::SvxFmTbxCtlRecText( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ :SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ DBG_CTOR(SvxFmTbxCtlRecText,NULL);
+}
+
+//-----------------------------------------------------------------------
+SvxFmTbxCtlRecText::~SvxFmTbxCtlRecText()
+{
+ DBG_DTOR(SvxFmTbxCtlRecText,NULL);
+}
+
+//-----------------------------------------------------------------------
+Window* SvxFmTbxCtlRecText::CreateItemWindow( Window* pParent )
+{
+ XubString aText( SVX_RES(RID_STR_REC_TEXT) );
+ FixedText* pFixedText = new FixedText( pParent );
+ Size aSize( pFixedText->GetTextWidth( aText ), pFixedText->GetTextHeight( ) );
+ pFixedText->SetText( aText );
+ aSize.Width() += 6;
+ pFixedText->SetSizePixel( aSize );
+ pFixedText->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
+
+ return pFixedText;
+}
+
+
+//========================================================================
+// SvxFmTbxCtlRecFromText
+//========================================================================
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecFromText, SfxBoolItem );
+DBG_NAME(SvxFmTbxCtlRecFromText);
+//-----------------------------------------------------------------------
+SvxFmTbxCtlRecFromText::SvxFmTbxCtlRecFromText( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ :SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ DBG_CTOR(SvxFmTbxCtlRecFromText,NULL);
+}
+
+//-----------------------------------------------------------------------
+SvxFmTbxCtlRecFromText::~SvxFmTbxCtlRecFromText()
+{
+ DBG_DTOR(SvxFmTbxCtlRecFromText,NULL);
+}
+
+//-----------------------------------------------------------------------
+Window* SvxFmTbxCtlRecFromText::CreateItemWindow( Window* pParent )
+{
+ XubString aText( SVX_RES(RID_STR_REC_FROM_TEXT) );
+ FixedText* pFixedText = new FixedText( pParent, WB_CENTER );
+ Size aSize( pFixedText->GetTextWidth( aText ), pFixedText->GetTextHeight( ) );
+ aSize.Width() += 12;
+ pFixedText->SetText( aText );
+ pFixedText->SetSizePixel( aSize );
+ pFixedText->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
+ return pFixedText;
+}
+
+
+//========================================================================
+// SvxFmTbxCtlRecTotal
+//========================================================================
+DBG_NAME(SvxFmTbxCtlRecTotal);
+SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxCtlRecTotal, SfxStringItem );
+
+//-----------------------------------------------------------------------
+SvxFmTbxCtlRecTotal::SvxFmTbxCtlRecTotal( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ :SfxToolBoxControl( nSlotId, nId, rTbx )
+ ,pFixedText( NULL )
+{
+ DBG_CTOR(SvxFmTbxCtlRecTotal,NULL);
+}
+
+//-----------------------------------------------------------------------
+SvxFmTbxCtlRecTotal::~SvxFmTbxCtlRecTotal()
+{
+ DBG_DTOR(SvxFmTbxCtlRecTotal,NULL);
+}
+
+//-----------------------------------------------------------------------
+Window* SvxFmTbxCtlRecTotal::CreateItemWindow( Window* pParent )
+{
+ pFixedText = new FixedText( pParent );
+ String aSample( "123456", sizeof( "123456" ) - 1 );
+ Size aSize( pFixedText->GetTextWidth( aSample ), pFixedText->GetTextHeight( ) );
+ aSize.Width() += 12;
+ pFixedText->SetSizePixel( aSize );
+ pFixedText->SetBackground();
+ pFixedText->SetPaintTransparent(TRUE);
+ return pFixedText;
+}
+
+//-----------------------------------------------------------------------
+void SvxFmTbxCtlRecTotal::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ //////////////////////////////////////////////////////////////////////
+ // Setzen des FixedTextes
+ if (GetSlotId() != SID_FM_RECORD_TOTAL)
+ return;
+
+ XubString aText;
+ if (pState)
+ aText = ((SfxStringItem*)pState)->GetValue();
+ else
+ aText = '?';
+
+ pFixedText->SetText( aText );
+ pFixedText->Update();
+ pFixedText->Flush();
+
+ SfxToolBoxControl::StateChanged( nSID, eState,pState );
+}
+
+//========================================================================
+// SvxFmTbxNextRec
+//========================================================================
+SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxNextRec, SfxBoolItem );
+
+//-----------------------------------------------------------------------
+SvxFmTbxNextRec::SvxFmTbxNextRec( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ :SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits(nId, rTbx.GetItemBits(nId) | TIB_REPEAT);
+
+ AllSettings aSettings = rTbx.GetSettings();
+ MouseSettings aMouseSettings = aSettings.GetMouseSettings();
+ aMouseSettings.SetButtonRepeat(aMouseSettings.GetButtonRepeat() / 4);
+ aSettings.SetMouseSettings(aMouseSettings);
+ rTbx.SetSettings(aSettings, TRUE);
+}
+
+//========================================================================
+// SvxFmTbxPrevRec
+//========================================================================
+SFX_IMPL_TOOLBOX_CONTROL( SvxFmTbxPrevRec, SfxBoolItem );
+
+//-----------------------------------------------------------------------
+SvxFmTbxPrevRec::SvxFmTbxPrevRec( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ :SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits(nId, rTbx.GetItemBits(nId) | TIB_REPEAT);
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/typeconversionclient.cxx b/svx/source/form/typeconversionclient.cxx
new file mode 100644
index 000000000000..b20b75a7dd3f
--- /dev/null
+++ b/svx/source/form/typeconversionclient.cxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "typeconversionclient.hxx"
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= OTypeConversionClient
+ //====================================================================
+ //--------------------------------------------------------------------
+ OTypeConversionClient::OTypeConversionClient()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool OTypeConversionClient::ensureLoaded() const
+ {
+ if ( !ODbtoolsClient::ensureLoaded() )
+ return false;
+ m_xTypeConversion = getFactory()->getTypeConversionHelper();
+ return m_xTypeConversion.is();
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/typemap.cxx b/svx/source/form/typemap.cxx
new file mode 100644
index 000000000000..dfb5a1b79ff9
--- /dev/null
+++ b/svx/source/form/typemap.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <sfx2/objitem.hxx>
+#include <sfx2/msg.hxx>
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/postitem.hxx>
+#include "clipfmtitem.hxx"
+#include <editeng/fhgtitem.hxx>
+#include "editeng/fontitem.hxx"
+#include <editeng/charreliefitem.hxx>
+#include <editeng/escpitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/wrlmitem.hxx>
+#include <editeng/charscaleitem.hxx>
+#include <editeng/akrnitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/kernitem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <editeng/adjitem.hxx>
+#include <editeng/emphitem.hxx>
+
+#include <editeng/memberids.hrc>
+#define SFX_TYPEMAP
+#include "svxslots.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/form/xfm_addcondition.cxx b/svx/source/form/xfm_addcondition.cxx
new file mode 100644
index 000000000000..90c5581d8781
--- /dev/null
+++ b/svx/source/form/xfm_addcondition.cxx
@@ -0,0 +1,193 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "xfm_addcondition.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+#include <cppuhelper/typeprovider.hxx>
+#include "datanavi.hxx"
+#include <vcl/msgbox.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+#define PROPERTY_ID_BINDING 5724
+#define PROPERTY_ID_FORM_MODEL 5725
+#define PROPERTY_ID_FACET_NAME 5726
+#define PROPERTY_ID_CONDITION_VALUE 5727
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::xforms;
+
+ //====================================================================
+ //= OAddConditionDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OAddConditionDialog_Create( const Reference< XMultiServiceFactory > & _rxORB )
+ {
+ return OAddConditionDialog::Create( _rxORB );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OAddConditionDialog_GetSupportedServiceNames()
+ {
+ ::comphelper::StringSequence aSupported( 1 );
+ aSupported.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xforms.ui.dialogs.AddCondition" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OAddConditionDialog_GetImplementationName()
+ {
+ return ::rtl::OUString::createFromAscii( "org.openoffice.comp.svx.OAddConditionDialog" );
+ }
+
+ //====================================================================
+ //= OAddConditionDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ OAddConditionDialog::OAddConditionDialog( const Reference< XMultiServiceFactory >& _rxORB )
+ :OAddConditionDialogBase( _rxORB )
+ {
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Binding" ) ),
+ PROPERTY_ID_BINDING,
+ PropertyAttribute::TRANSIENT,
+ &m_xBinding,
+ ::getCppuType( &m_xBinding )
+ );
+
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FacetName" ) ),
+ PROPERTY_ID_FACET_NAME,
+ PropertyAttribute::TRANSIENT,
+ &m_sFacetName,
+ ::getCppuType( &m_sFacetName )
+ );
+
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConditionValue" ) ),
+ PROPERTY_ID_CONDITION_VALUE,
+ PropertyAttribute::TRANSIENT,
+ &m_sConditionValue,
+ ::getCppuType( &m_sConditionValue )
+ );
+
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormModel" ) ),
+ PROPERTY_ID_FORM_MODEL,
+ PropertyAttribute::TRANSIENT,
+ &m_xWorkModel,
+ ::getCppuType( &m_xWorkModel )
+ );
+ }
+
+ //-------------------------------------------------------------------------
+ Sequence<sal_Int8> SAL_CALL OAddConditionDialog::getImplementationId( ) throw(RuntimeException)
+ {
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+ }
+
+ //-------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OAddConditionDialog::Create( const Reference< XMultiServiceFactory >& _rxFactory )
+ {
+ return *( new OAddConditionDialog( _rxFactory ) );
+ }
+
+ //-------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OAddConditionDialog::getImplementationName() throw(RuntimeException)
+ {
+ return OAddConditionDialog_GetImplementationName();
+ }
+
+ //-------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OAddConditionDialog::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return OAddConditionDialog_GetSupportedServiceNames();
+ }
+
+ //-------------------------------------------------------------------------
+ Reference<XPropertySetInfo> SAL_CALL OAddConditionDialog::getPropertySetInfo() throw(RuntimeException)
+ {
+ return createPropertySetInfo( getInfoHelper() );
+ }
+
+ //-------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& OAddConditionDialog::getInfoHelper()
+ {
+ return *const_cast< OAddConditionDialog* >( this )->getArrayHelper();
+ }
+
+ //------------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* OAddConditionDialog::createArrayHelper( ) const
+ {
+ Sequence< Property > aProperties;
+ describeProperties( aProperties );
+ return new ::cppu::OPropertyArrayHelper( aProperties );
+ }
+
+ //------------------------------------------------------------------------------
+ Dialog* OAddConditionDialog::createDialog(Window* _pParent)
+ {
+ if ( !m_xBinding.is() || !m_sFacetName.getLength() )
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ return new AddConditionDialog( _pParent, m_sFacetName, m_xBinding );
+ }
+
+ //------------------------------------------------------------------------------
+ void OAddConditionDialog::executedDialog( sal_Int16 _nExecutionResult )
+ {
+ OAddConditionDialogBase::executedDialog( _nExecutionResult );
+ if ( _nExecutionResult == RET_OK )
+ m_sConditionValue = static_cast< AddConditionDialog* >( m_pDialog )->GetCondition();
+ }
+
+//........................................................................
+} // namespace svxformv
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/codec.cxx b/svx/source/gallery2/codec.cxx
new file mode 100644
index 000000000000..c9067aa78914
--- /dev/null
+++ b/svx/source/gallery2/codec.cxx
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <tools/stream.hxx>
+#include <tools/zcodec.hxx>
+#include "codec.hxx"
+
+// ----------------
+// - GalleryCodec -
+// ----------------
+
+GalleryCodec::GalleryCodec( SvStream& rIOStm ) :
+ rStm( rIOStm )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+GalleryCodec::~GalleryCodec()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryCodec::IsCoded( SvStream& rStm, UINT32& rVersion )
+{
+ const ULONG nPos = rStm.Tell();
+ BOOL bRet;
+ BYTE cByte1, cByte2, cByte3, cByte4, cByte5, cByte6;
+
+ rStm >> cByte1 >> cByte2 >> cByte3 >> cByte4 >> cByte5 >> cByte6;
+
+ if ( cByte1 == 'S' && cByte2 == 'V' && cByte3 == 'R' && cByte4 == 'L' && cByte5 == 'E' && ( cByte6 == '1' || cByte6 == '2' ) )
+ {
+ rVersion = ( ( cByte6 == '1' ) ? 1 : 2 );
+ bRet = TRUE;
+ }
+ else
+ {
+ rVersion = 0;
+ bRet = FALSE;
+ }
+
+ rStm.Seek( nPos );
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryCodec::Write( SvStream& rStmToWrite )
+{
+ UINT32 nPos, nCompSize;
+
+ rStmToWrite.Seek( STREAM_SEEK_TO_END );
+ const UINT32 nSize = rStmToWrite.Tell();
+ rStmToWrite.Seek( 0UL );
+
+ rStm << 'S' << 'V' << 'R' << 'L' << 'E' << '2';
+ rStm << nSize;
+
+ nPos = rStm.Tell();
+ rStm.SeekRel( 4UL );
+
+ ZCodec aCodec;
+ aCodec.BeginCompression();
+ aCodec.Compress( rStmToWrite, rStm );
+ aCodec.EndCompression();
+
+ nCompSize = rStm.Tell() - nPos - 4UL;
+ rStm.Seek( nPos );
+ rStm << nCompSize;
+ rStm.Seek( STREAM_SEEK_TO_END );
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryCodec::Read( SvStream& rStmToRead )
+{
+ UINT32 nVersion = 0;
+
+ if( IsCoded( rStm, nVersion ) )
+ {
+ UINT32 nCompressedSize, nUnCompressedSize;
+
+ rStm.SeekRel( 6 );
+ rStm >> nUnCompressedSize >> nCompressedSize;
+
+ // decompress
+ if( 1 == nVersion )
+ {
+ BYTE* pCompressedBuffer = new BYTE[ nCompressedSize ]; rStm.Read( pCompressedBuffer, nCompressedSize );
+ BYTE* pInBuf = pCompressedBuffer;
+ BYTE* pOutBuf = new BYTE[ nUnCompressedSize ];
+ BYTE* pTmpBuf = pOutBuf;
+ BYTE* pLast = pOutBuf + nUnCompressedSize - 1;
+ ULONG nIndex = 0UL, nCountByte, nRunByte;
+ BOOL bEndDecoding = FALSE;
+
+ do
+ {
+ nCountByte = *pInBuf++;
+
+ if ( !nCountByte )
+ {
+ nRunByte = *pInBuf++;
+
+ if ( nRunByte > 2 )
+ {
+ // absolutes Fuellen
+ memcpy( &pTmpBuf[ nIndex ], pInBuf, nRunByte );
+ pInBuf += nRunByte;
+ nIndex += nRunByte;
+
+ // WORD-Alignment beachten
+ if ( nRunByte & 1 )
+ pInBuf++;
+ }
+ else if ( nRunByte == 1 ) // Ende des Bildes
+ bEndDecoding = TRUE;
+ }
+ else
+ {
+ const BYTE cVal = *pInBuf++;
+
+ memset( &pTmpBuf[ nIndex ], cVal, nCountByte );
+ nIndex += nCountByte;
+ }
+ }
+ while ( !bEndDecoding && ( pTmpBuf <= pLast ) );
+
+ rStmToRead.Write( pOutBuf, nUnCompressedSize );
+
+ delete[] pOutBuf;
+ delete[] pCompressedBuffer;
+ }
+ else if( 2 == nVersion )
+ {
+ ZCodec aCodec;
+
+ aCodec.BeginCompression();
+ aCodec.Decompress( rStm, rStmToRead );
+ aCodec.EndCompression();
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/codec.hxx b/svx/source/gallery2/codec.hxx
new file mode 100644
index 000000000000..d5985dcbd2d4
--- /dev/null
+++ b/svx/source/gallery2/codec.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <tools/gen.hxx>
+
+// ----------------
+// - GalleryCodec -
+// ----------------
+
+class SvStream;
+class SvMemoryStreamStream;
+
+class GalleryCodec
+{
+private:
+
+ SvStream& rStm;
+
+public:
+ GalleryCodec( SvStream& rIOStm );
+ ~GalleryCodec();
+
+ void Write( SvStream& rStmToWrite );
+ void Read( SvStream& rStmToRead );
+
+ static BOOL IsCoded( SvStream& rStm, UINT32& rVersion );
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galbrws.cxx b/svx/source/gallery2/galbrws.cxx
new file mode 100644
index 000000000000..4797e4ecbb32
--- /dev/null
+++ b/svx/source/gallery2/galbrws.cxx
@@ -0,0 +1,288 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <vcl/split.hxx>
+#include <vcl/ctrl.hxx>
+#include <unotools/pathoptions.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/sfxsids.hrc>
+#include "gallery.hrc"
+#include "svx/galmisc.hxx"
+#include "svx/gallery1.hxx"
+#include "galbrws1.hxx"
+#include "galbrws2.hxx"
+#include "galbrws.hxx"
+
+// -------------------
+// - GallerySplitter -
+// -------------------
+
+class GallerySplitter : public Splitter
+{
+protected:
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+public:
+
+ GallerySplitter( Window* pParent, const ResId& rResId );
+ virtual ~GallerySplitter();
+};
+
+// -----------------------------------------------------------------------------
+
+GallerySplitter::GallerySplitter( Window* pParent, const ResId& rResId ) :
+ Splitter( pParent, rResId )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+GallerySplitter::~GallerySplitter()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void GallerySplitter::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Splitter::DataChanged( rDCEvt );
+ static_cast< GalleryBrowser* >( GetParent() )->InitSettings();
+}
+
+// -------------------------
+// - SvxGalleryChildWindow -
+// -------------------------
+
+GalleryChildWindow::GalleryChildWindow( Window* _pParent, USHORT nId, SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( _pParent, nId )
+{
+ pWindow = new GalleryBrowser( pBindings, this, _pParent, GAL_RESID( RID_SVXDLG_GALLERYBROWSER ) );
+ eChildAlignment = SFX_ALIGN_TOP;
+ ( (GalleryBrowser*) pWindow )->Initialize( pInfo );
+};
+
+// -----------------------------------------------------------------------------
+
+GalleryChildWindow::~GalleryChildWindow()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SFX_IMPL_DOCKINGWINDOW( GalleryChildWindow, SID_GALLERY )
+
+// ------------------
+// - GalleryBrowser -
+// ------------------
+
+GalleryBrowser::GalleryBrowser( SfxBindings* _pBindings, SfxChildWindow* pCW,
+ Window* pParent, const ResId& rResId ) :
+ SfxDockingWindow( _pBindings, pCW, pParent, rResId )
+{
+ mpGallery = Gallery::GetGalleryInstance();
+ mpBrowser1 = new GalleryBrowser1( this, GAL_RESID( GALLERY_BROWSER1 ), mpGallery );
+ mpSplitter = new GallerySplitter( this, GAL_RESID( GALLERY_SPLITTER ) );
+ mpBrowser2 = new GalleryBrowser2( this, GAL_RESID( GALLERY_BROWSER2 ), mpGallery );
+
+ FreeResource();
+ SetMinOutputSizePixel( maLastSize = GetOutputSizePixel() );
+
+ mpBrowser1->SelectTheme( 0 );
+ mpBrowser1->Show( TRUE );
+ mpBrowser2->Show( TRUE );
+
+ mpSplitter->SetSplitHdl( LINK( this, GalleryBrowser, SplitHdl ) );
+ mpSplitter->Show( TRUE );
+
+ InitSettings();
+}
+
+// -----------------------------------------------------------------------------
+
+GalleryBrowser::~GalleryBrowser()
+{
+ delete mpBrowser2;
+ delete mpSplitter;
+ delete mpBrowser1;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser::InitSettings()
+{
+ SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
+ SetControlBackground( GALLERY_DLG_COLOR );
+ SetControlForeground( GALLERY_DLG_COLOR );
+
+ mpSplitter->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
+ mpSplitter->SetControlBackground( GALLERY_DLG_COLOR );
+ mpSplitter->SetControlForeground( GALLERY_DLG_COLOR );
+
+ mpBrowser1->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
+ mpBrowser1->SetControlBackground( GALLERY_DLG_COLOR );
+ mpBrowser1->SetControlForeground( GALLERY_DLG_COLOR );
+
+ mpBrowser2->SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
+ mpBrowser2->SetControlBackground( GALLERY_DLG_COLOR );
+ mpBrowser2->SetControlForeground( GALLERY_DLG_COLOR );
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser::Resize()
+{
+ SfxDockingWindow::Resize();
+
+ const long nFrameWidth = LogicToPixel( Size( 3, 0 ), MAP_APPFONT ).Width();
+ const long nFrameWidth2 = nFrameWidth << 1;
+ Size aMinSize( GetMinOutputSizePixel() );
+ Size aNewSize( GetOutputSizePixel() );
+ Point aSplitPos( mpSplitter->GetPosPixel() );
+ const Size aSplitSize( mpSplitter->GetOutputSizePixel() );
+
+ mpBrowser1->SetPosSizePixel( Point( nFrameWidth, nFrameWidth ),
+ Size( aSplitPos.X() - nFrameWidth, aNewSize.Height() - nFrameWidth2 ) );
+
+ mpSplitter->SetPosSizePixel( aSplitPos, Size( aSplitSize.Width(), aNewSize.Height() ) );
+ mpSplitter->SetDragRectPixel( Rectangle( Point( nFrameWidth2, 0 ), Size( aNewSize.Width() - ( nFrameWidth2 << 1 ) - aSplitSize.Width(), aNewSize.Height() ) ) );
+
+ mpBrowser2->SetPosSizePixel( Point( aSplitPos.X() + aSplitSize.Width(), nFrameWidth ),
+ Size( aNewSize.Width() - aSplitSize.Width() - aSplitPos.X() - nFrameWidth, aNewSize.Height() - nFrameWidth2 ) );
+
+ maLastSize = aNewSize;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryBrowser::KeyInput( const KeyEvent& rKEvt, Window* )
+{
+ const USHORT nCode = rKEvt.GetKeyCode().GetCode();
+ BOOL bRet = ( !rKEvt.GetKeyCode().IsMod1() &&
+ ( ( KEY_TAB == nCode ) || ( KEY_F6 == nCode && rKEvt.GetKeyCode().IsMod2() ) ) );
+
+ if( bRet )
+ {
+ if( !rKEvt.GetKeyCode().IsShift() )
+ {
+ if( mpBrowser1->mpThemes->HasChildPathFocus( TRUE ) )
+ mpBrowser2->GetViewWindow()->GrabFocus();
+ else if( mpBrowser2->GetViewWindow()->HasFocus() )
+ mpBrowser2->maViewBox.GrabFocus();
+ else if( mpBrowser2->maViewBox.HasFocus() )
+ mpBrowser1->maNewTheme.GrabFocus();
+ else
+ mpBrowser1->mpThemes->GrabFocus();
+ }
+ else
+ {
+ if( mpBrowser1->mpThemes->HasChildPathFocus( TRUE ) )
+ mpBrowser1->maNewTheme.GrabFocus();
+ else if( mpBrowser1->maNewTheme.HasFocus() )
+ mpBrowser2->maViewBox.GrabFocus();
+ else if( mpBrowser2->maViewBox.HasFocus() )
+ mpBrowser2->GetViewWindow()->GrabFocus();
+ else
+ mpBrowser1->mpThemes->GrabFocus();
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryBrowser::Close()
+{
+ return SfxDockingWindow::Close();
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser::GetFocus()
+{
+ SfxDockingWindow::GetFocus();
+ mpBrowser1->GrabFocus();
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser::ThemeSelectionHasChanged()
+{
+ mpBrowser2->SelectTheme( mpBrowser1->GetSelectedTheme() );
+}
+
+// -----------------------------------------------------------------------------
+
+INetURLObject GalleryBrowser::GetURL() const
+{
+ return mpBrowser2->GetURL();
+}
+
+// -----------------------------------------------------------------------------
+
+String GalleryBrowser::GetFilterName() const
+{
+ return mpBrowser2->GetFilterName();
+}
+
+// -----------------------------------------------------------------------------
+
+Graphic GalleryBrowser::GetGraphic() const
+{
+ return mpBrowser2->GetGraphic();
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryBrowser::GetVCDrawModel( FmFormModel& rModel ) const
+{
+ return mpBrowser2->GetVCDrawModel( rModel );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryBrowser::IsLinkage() const
+{
+ return mpBrowser2->IsLinkage();
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser, SplitHdl, void*, EMPTYARG )
+{
+ mpSplitter->SetPosPixel( Point( mpSplitter->GetSplitPosPixel(), mpSplitter->GetPosPixel().Y() ) );
+ Resize();
+
+ return 0L;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galbrws1.cxx b/svx/source/gallery2/galbrws1.cxx
new file mode 100644
index 000000000000..e379a01750fb
--- /dev/null
+++ b/svx/source/gallery2/galbrws1.cxx
@@ -0,0 +1,716 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <tools/datetime.hxx>
+#include <unotools/datetime.hxx>
+#include <vcl/msgbox.hxx>
+#include <ucbhelper/content.hxx>
+#include <sfx2/app.hxx>
+#include "helpid.hrc"
+#include "svx/gallery1.hxx"
+#include "galtheme.hxx"
+#include "svx/galmisc.hxx"
+#include "galbrws1.hxx"
+#include <com/sun/star/util/DateTime.hpp>
+#include "gallery.hrc"
+#include <algorithm>
+
+#include <svx/svxdlg.hxx>
+
+// --------------
+// - Namespaces -
+// --------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+// -----------------
+// - GalleryButton -
+// -----------------
+
+GalleryButton::GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits ) :
+ PushButton( pParent, nWinBits )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+GalleryButton::~GalleryButton()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryButton::KeyInput( const KeyEvent& rKEvt )
+{
+ if( !static_cast< GalleryBrowser1* >( GetParent() )->KeyInput( rKEvt, this ) )
+ PushButton::KeyInput( rKEvt );
+}
+
+// -----------------------
+// - GalleryThemeListBox -
+// -----------------------
+
+GalleryThemeListBox::GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits ) :
+ ListBox( pParent, nWinBits )
+{
+ InitSettings();
+}
+
+// -----------------------------------------------------------------------------
+
+GalleryThemeListBox::~GalleryThemeListBox()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryThemeListBox::InitSettings()
+{
+ SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
+ SetControlBackground( GALLERY_BG_COLOR );
+ SetControlForeground( GALLERY_FG_COLOR );
+}
+
+// -----------------------------------------------------------------------
+
+void GalleryThemeListBox::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ InitSettings();
+ else
+ ListBox::DataChanged( rDCEvt );
+}
+
+// -----------------------------------------------------------------------------
+
+long GalleryThemeListBox::PreNotify( NotifyEvent& rNEvt )
+{
+ long nDone = 0;
+
+ if( rNEvt.GetType() == EVENT_COMMAND )
+ {
+ const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
+
+ if( pCEvt && pCEvt->GetCommand() == COMMAND_CONTEXTMENU )
+ static_cast< GalleryBrowser1* >( GetParent() )->ShowContextMenu();
+ }
+ else if( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+
+ if( pKEvt )
+ nDone = static_cast< GalleryBrowser1* >( GetParent() )->KeyInput( *pKEvt, this );
+ }
+
+ return( nDone ? nDone : ListBox::PreNotify( rNEvt ) );
+}
+
+// -------------------
+// - GalleryBrowser1 -
+// -------------------
+
+GalleryBrowser1::GalleryBrowser1( GalleryBrowser* pParent, const ResId& rResId, Gallery* pGallery ) :
+ Control ( pParent, rResId ),
+ maNewTheme ( this, WB_3DLOOK ),
+ mpThemes ( new GalleryThemeListBox( this, WB_TABSTOP | WB_3DLOOK | WB_BORDER | WB_HSCROLL | WB_VSCROLL | WB_AUTOHSCROLL | WB_SORT ) ),
+ mpGallery ( pGallery ),
+ mpExchangeData ( new ExchangeData ),
+ mpThemePropsDlgItemSet( NULL ),
+ aImgNormal ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_NORMAL ) ),
+ aImgDefault ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_DEFAULT ) ),
+ aImgReadOnly ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_READONLY ) ),
+ aImgImported ( GalleryResGetBitmapEx( RID_SVXBMP_THEME_IMPORTED ) )
+{
+ StartListening( *mpGallery );
+
+ maNewTheme.SetHelpId( HID_GALLERY_NEWTHEME );
+ maNewTheme.SetText( String( GAL_RESID( RID_SVXSTR_GALLERY_CREATETHEME ) ) );
+ maNewTheme.SetClickHdl( LINK( this, GalleryBrowser1, ClickNewThemeHdl ) );
+
+ // disable creation of new themes if a writable directory is not available
+ if( mpGallery->GetUserURL().GetProtocol() == INET_PROT_NOT_VALID )
+ maNewTheme.Disable();
+
+ mpThemes->SetHelpId( HID_GALLERY_THEMELIST );
+ mpThemes->SetSelectHdl( LINK( this, GalleryBrowser1, SelectThemeHdl ) );
+
+ for( ULONG i = 0, nCount = mpGallery->GetThemeCount(); i < nCount; i++ )
+ ImplInsertThemeEntry( mpGallery->GetThemeInfo( i ) );
+
+ ImplAdjustControls();
+ maNewTheme.Show( TRUE );
+ mpThemes->Show( TRUE );
+}
+
+// -----------------------------------------------------------------------------
+
+GalleryBrowser1::~GalleryBrowser1()
+{
+ EndListening( *mpGallery );
+ delete mpThemes;
+ mpThemes = NULL;
+ delete mpExchangeData;
+ mpExchangeData = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+ULONG GalleryBrowser1::ImplInsertThemeEntry( const GalleryThemeEntry* pEntry )
+{
+ static const BOOL bShowHiddenThemes = ( getenv( "GALLERY_SHOW_HIDDEN_THEMES" ) != NULL );
+
+ ULONG nRet = LISTBOX_ENTRY_NOTFOUND;
+
+ if( pEntry && ( !pEntry->IsHidden() || bShowHiddenThemes ) )
+ {
+ const Image* pImage;
+
+ if( pEntry->IsImported() )
+ pImage = &aImgImported;
+ else if( pEntry->IsReadOnly() )
+ pImage = &aImgReadOnly;
+ else if( pEntry->IsDefault() )
+ pImage = &aImgDefault;
+ else
+ pImage = &aImgNormal;
+
+ nRet = mpThemes->InsertEntry( pEntry->GetThemeName(), *pImage );
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::ImplAdjustControls()
+{
+ const Size aOutSize( GetOutputSizePixel() );
+ const long nNewThemeHeight = LogicToPixel( Size( 0, 14 ), MAP_APPFONT ).Height();
+ const long nStartY = nNewThemeHeight + 4;
+
+ maNewTheme.SetPosSizePixel( Point(),
+ Size( aOutSize.Width(), nNewThemeHeight ) );
+
+ mpThemes->SetPosSizePixel( Point( 0, nStartY ),
+ Size( aOutSize.Width(), aOutSize.Height() - nStartY ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData )
+{
+ rData.pTheme = (GalleryTheme*) pThm;
+ rData.aEditedTitle = pThm->GetName();
+
+ try
+ {
+ ::ucbhelper::Content aCnt( pThm->GetThmURL().GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >() );
+ util::DateTime aDateTimeModified;
+ DateTime aDateTime;
+
+ aCnt.getPropertyValue( OUString::createFromAscii( "DateModified" ) ) >>= aDateTimeModified;
+ ::utl::typeConvert( aDateTimeModified, aDateTime );
+ rData.aThemeChangeDate = aDateTime;
+ rData.aThemeChangeTime = aDateTime;
+ }
+ catch( const ucb::ContentCreationException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+::std::vector< USHORT > GalleryBrowser1::ImplGetExecuteVector()
+{
+ ::std::vector< USHORT > aExecVector;
+ GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
+
+ if( pTheme )
+ {
+ BOOL bUpdateAllowed, bRenameAllowed, bRemoveAllowed;
+ static const BOOL bIdDialog = ( getenv( "GALLERY_ENABLE_ID_DIALOG" ) != NULL );
+
+ if( pTheme->IsReadOnly() )
+ bUpdateAllowed = bRenameAllowed = bRemoveAllowed = FALSE;
+ else if( pTheme->IsImported() )
+ {
+ bUpdateAllowed = FALSE;
+ bRenameAllowed = bRemoveAllowed = TRUE;
+ }
+ else if( pTheme->IsDefault() )
+ {
+ bUpdateAllowed = bRenameAllowed = TRUE;
+ bRemoveAllowed = FALSE;
+ }
+ else
+ bUpdateAllowed = bRenameAllowed = bRemoveAllowed = TRUE;
+
+ if( bUpdateAllowed && pTheme->GetObjectCount() )
+ aExecVector.push_back( MN_ACTUALIZE );
+
+ if( bRenameAllowed )
+ aExecVector.push_back( MN_RENAME );
+
+ if( bRemoveAllowed )
+ aExecVector.push_back( MN_DELETE );
+
+ if( bIdDialog && !pTheme->IsReadOnly() && !pTheme->IsImported() )
+ aExecVector.push_back( MN_ASSIGN_ID );
+
+ aExecVector.push_back( MN_PROPERTIES );
+
+ mpGallery->ReleaseTheme( pTheme, *this );
+ }
+
+ return aExecVector;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::ImplGalleryThemeProperties( const String & rThemeName, bool bCreateNew )
+{
+ DBG_ASSERT(!mpThemePropsDlgItemSet, "mpThemePropsDlgItemSet already set!");
+ mpThemePropsDlgItemSet = new SfxItemSet( SFX_APP()->GetPool() );
+ GalleryTheme* pTheme = mpGallery->AcquireTheme( rThemeName, *this );
+
+ ImplFillExchangeData( pTheme, *mpExchangeData );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Got no AbstractDialogFactory!");
+ VclAbstractDialog2* pThemeProps = pFact->CreateGalleryThemePropertiesDialog( NULL, mpExchangeData, mpThemePropsDlgItemSet );
+ DBG_ASSERT(pThemeProps, "Got no GalleryThemePropertiesDialog!");
+
+ if ( bCreateNew )
+ {
+ pThemeProps->StartExecuteModal(
+ LINK( this, GalleryBrowser1, EndNewThemePropertiesDlgHdl ) );
+ }
+ else
+ {
+ pThemeProps->StartExecuteModal(
+ LINK( this, GalleryBrowser1, EndThemePropertiesDlgHdl ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog, bool bCreateNew )
+{
+ long nRet = pDialog->GetResult();
+
+ if( nRet == RET_OK )
+ {
+ String aName( mpExchangeData->pTheme->GetName() );
+
+ if( mpExchangeData->aEditedTitle.Len() && aName != mpExchangeData->aEditedTitle )
+ {
+ const String aOldName( aName );
+ String aTitle( mpExchangeData->aEditedTitle );
+ USHORT nCount = 0;
+
+ while( mpGallery->HasTheme( aTitle ) && ( nCount++ < 16000 ) )
+ {
+ aTitle = mpExchangeData->aEditedTitle;
+ aTitle += ' ';
+ aTitle += String::CreateFromInt32( nCount );
+ }
+
+ mpGallery->RenameTheme( aOldName, aTitle );
+ }
+
+ if ( bCreateNew )
+ {
+ mpThemes->SelectEntry( mpExchangeData->pTheme->GetName() );
+ SelectThemeHdl( NULL );
+ }
+ }
+
+ String aThemeName( mpExchangeData->pTheme->GetName() );
+ mpGallery->ReleaseTheme( mpExchangeData->pTheme, *this );
+
+ if ( bCreateNew && ( nRet != RET_OK ) )
+ {
+ mpGallery->RemoveTheme( aThemeName );
+ }
+
+ // destroy mpThemeProps asynchronously
+ Application::PostUserEvent( LINK( this, GalleryBrowser1, DestroyThemePropertiesDlgHdl ) );
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser1, EndNewThemePropertiesDlgHdl, VclAbstractDialog2*, pDialog )
+{
+ ImplEndGalleryThemeProperties( pDialog, true );
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser1, EndThemePropertiesDlgHdl, VclAbstractDialog2*, pDialog )
+{
+ ImplEndGalleryThemeProperties( pDialog, false );
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser1, DestroyThemePropertiesDlgHdl, VclAbstractDialog2*, pDialog )
+{
+ delete pDialog;
+ delete mpThemePropsDlgItemSet;
+ mpThemePropsDlgItemSet = 0;
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::ImplExecute( USHORT nId )
+{
+ switch( nId )
+ {
+ case( MN_ACTUALIZE ):
+ {
+ GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ VclAbstractRefreshableDialog* aActualizeProgress = pFact->CreateActualizeProgressDialog( this, pTheme );
+ DBG_ASSERT(aActualizeProgress, "Dialogdiet fail!");
+
+ aActualizeProgress->Update();
+ aActualizeProgress->Execute();
+ mpGallery->ReleaseTheme( pTheme, *this );
+ delete aActualizeProgress;
+ }
+ }
+ break;
+
+ case( MN_DELETE ):
+ {
+ if( QueryBox( NULL, WB_YES_NO, String( GAL_RESID( RID_SVXSTR_GALLERY_DELETETHEME ) ) ).Execute() == RET_YES )
+ mpGallery->RemoveTheme( mpThemes->GetSelectEntry() );
+ }
+ break;
+
+ case( MN_RENAME ):
+ {
+ GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
+ const String aOldName( pTheme->GetName() );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");
+ AbstractTitleDialog* aDlg = pFact->CreateTitleDialog( this, aOldName );
+ DBG_ASSERT(aDlg, "Dialogdiet fail!");
+
+ if( aDlg->Execute() == RET_OK )
+ {
+ const String aNewName( aDlg->GetTitle() );
+
+ if( aNewName.Len() && ( aNewName != aOldName ) )
+ {
+ String aName( aNewName );
+ USHORT nCount = 0;
+
+ while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) )
+ {
+ aName = aNewName;
+ aName += ' ';
+ aName += String::CreateFromInt32( nCount );
+ }
+
+ mpGallery->RenameTheme( aOldName, aName );
+ }
+ }
+ mpGallery->ReleaseTheme( pTheme, *this );
+ delete aDlg;
+ }
+ break;
+
+ case( MN_ASSIGN_ID ):
+ {
+ GalleryTheme* pTheme = mpGallery->AcquireTheme( GetSelectedTheme(), *this );
+
+ if( pTheme && !pTheme->IsReadOnly() && !pTheme->IsImported() )
+ {
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractGalleryIdDialog* aDlg = pFact->CreateGalleryIdDialog( this, pTheme );
+ DBG_ASSERT(aDlg, "Dialogdiet fail!");
+
+ if( aDlg->Execute() == RET_OK )
+ pTheme->SetId( aDlg->GetId(), TRUE );
+ delete aDlg;
+ }
+ }
+
+ mpGallery->ReleaseTheme( pTheme, *this );
+ }
+ break;
+
+ case( MN_PROPERTIES ):
+ {
+ ImplGalleryThemeProperties( GetSelectedTheme(), false );
+ }
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::Resize()
+{
+ Control::Resize();
+ ImplAdjustControls();
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::GetFocus()
+{
+ Control::GetFocus();
+ if( mpThemes )
+ mpThemes->GrabFocus();
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ const GalleryHint& rGalleryHint = (const GalleryHint&) rHint;
+
+ switch( rGalleryHint.GetType() )
+ {
+ case( GALLERY_HINT_THEME_CREATED ):
+ ImplInsertThemeEntry( mpGallery->GetThemeInfo( rGalleryHint.GetThemeName() ) );
+ break;
+
+ case( GALLERY_HINT_THEME_RENAMED ):
+ {
+ const USHORT nCurSelectPos = mpThemes->GetSelectEntryPos();
+ const USHORT nRenameEntryPos = mpThemes->GetEntryPos( rGalleryHint.GetThemeName() );
+
+ mpThemes->RemoveEntry( rGalleryHint.GetThemeName() );
+ ImplInsertThemeEntry( mpGallery->GetThemeInfo( rGalleryHint.GetStringData() ) );
+
+ if( nCurSelectPos == nRenameEntryPos )
+ {
+ mpThemes->SelectEntry( rGalleryHint.GetStringData() );
+ SelectThemeHdl( NULL );
+ }
+ }
+ break;
+
+ case( GALLERY_HINT_THEME_REMOVED ):
+ {
+ mpThemes->RemoveEntry( rGalleryHint.GetThemeName() );
+ }
+ break;
+
+ case( GALLERY_HINT_CLOSE_THEME ):
+ {
+ const USHORT nCurSelectPos = mpThemes->GetSelectEntryPos();
+ const USHORT nCloseEntryPos = mpThemes->GetEntryPos( rGalleryHint.GetThemeName() );
+
+ if( nCurSelectPos == nCloseEntryPos )
+ {
+ if( nCurSelectPos < ( mpThemes->GetEntryCount() - 1 ) )
+ mpThemes->SelectEntryPos( nCurSelectPos + 1 );
+ else if( nCurSelectPos )
+ mpThemes->SelectEntryPos( nCurSelectPos - 1 );
+ else
+ mpThemes->SetNoSelection();
+
+ SelectThemeHdl( NULL );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser1::ShowContextMenu()
+{
+ Application::PostUserEvent( LINK( this, GalleryBrowser1, ShowContextMenuHdl ), this );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryBrowser1::KeyInput( const KeyEvent& rKEvt, Window* pWindow )
+{
+ BOOL bRet = static_cast< GalleryBrowser* >( GetParent() )->KeyInput( rKEvt, pWindow );
+
+ if( !bRet )
+ {
+ ::std::vector< USHORT > aExecVector( ImplGetExecuteVector() );
+ USHORT nExecuteId = 0;
+ BOOL bMod1 = rKEvt.GetKeyCode().IsMod1();
+
+ switch( rKEvt.GetKeyCode().GetCode() )
+ {
+ case( KEY_INSERT ):
+ ClickNewThemeHdl( NULL );
+ break;
+
+ case( KEY_I ):
+ {
+ if( bMod1 )
+ ClickNewThemeHdl( NULL );
+ }
+ break;
+
+ case( KEY_U ):
+ {
+ if( bMod1 )
+ nExecuteId = MN_ACTUALIZE;
+ }
+ break;
+
+ case( KEY_DELETE ):
+ nExecuteId = MN_DELETE;
+ break;
+
+ case( KEY_D ):
+ {
+ if( bMod1 )
+ nExecuteId = MN_DELETE;
+ }
+ break;
+
+ case( KEY_R ):
+ {
+ if( bMod1 )
+ nExecuteId = MN_RENAME;
+ }
+ break;
+
+ case( KEY_RETURN ):
+ {
+ if( bMod1 )
+ nExecuteId = MN_PROPERTIES;
+ }
+ break;
+ }
+
+ if( nExecuteId && ( ::std::find( aExecVector.begin(), aExecVector.end(), nExecuteId ) != aExecVector.end() ) )
+ {
+ ImplExecute( nExecuteId );
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser1, ShowContextMenuHdl, void*, EMPTYARG )
+{
+ ::std::vector< USHORT > aExecVector( ImplGetExecuteVector() );
+
+ if( aExecVector.size() )
+ {
+ PopupMenu aMenu( GAL_RESID( RID_SVXMN_GALLERY1 ) );
+
+ aMenu.EnableItem( MN_ACTUALIZE, ::std::find( aExecVector.begin(), aExecVector.end(), MN_ACTUALIZE ) != aExecVector.end() );
+ aMenu.EnableItem( MN_RENAME, ::std::find( aExecVector.begin(), aExecVector.end(), MN_RENAME ) != aExecVector.end() );
+ aMenu.EnableItem( MN_DELETE, ::std::find( aExecVector.begin(), aExecVector.end(), MN_DELETE ) != aExecVector.end() );
+ aMenu.EnableItem( MN_ASSIGN_ID, ::std::find( aExecVector.begin(), aExecVector.end(), MN_ASSIGN_ID ) != aExecVector.end() );
+ aMenu.EnableItem( MN_PROPERTIES, ::std::find( aExecVector.begin(), aExecVector.end(), MN_PROPERTIES ) != aExecVector.end() );
+ aMenu.SetSelectHdl( LINK( this, GalleryBrowser1, PopupMenuHdl ) );
+ aMenu.RemoveDisabledEntries();
+
+ const Rectangle aThemesRect( mpThemes->GetPosPixel(), mpThemes->GetOutputSizePixel() );
+ Point aSelPos( mpThemes->GetBoundingRectangle( mpThemes->GetSelectEntryPos() ).Center() );
+
+ aSelPos.X() = Max( Min( aSelPos.X(), aThemesRect.Right() ), aThemesRect.Left() );
+ aSelPos.Y() = Max( Min( aSelPos.Y(), aThemesRect.Bottom() ), aThemesRect.Top() );
+
+ aMenu.Execute( this, aSelPos );
+ }
+
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser1, PopupMenuHdl, Menu*, pMenu )
+{
+ ImplExecute( pMenu->GetCurItemId() );
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser1, SelectThemeHdl, void*, EMPTYARG )
+{
+ ( (GalleryBrowser*) GetParent() )->ThemeSelectionHasChanged();
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser1, ClickNewThemeHdl, void*, EMPTYARG )
+{
+ String aNewTheme( GAL_RESID( RID_SVXSTR_GALLERY_NEWTHEME ) );
+ String aName( aNewTheme );
+ ULONG nCount = 0;
+
+ while( mpGallery->HasTheme( aName ) && ( nCount++ < 16000 ) )
+ {
+ aName = aNewTheme;
+ aName += ' ';
+ aName += String::CreateFromInt32( nCount );
+ }
+
+ if( !mpGallery->HasTheme( aName ) && mpGallery->CreateTheme( aName ) )
+ {
+ ImplGalleryThemeProperties( aName, true );
+ }
+
+ return 0L;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galbrws1.hxx b/svx/source/gallery2/galbrws1.hxx
new file mode 100644
index 000000000000..fba8a8323df3
--- /dev/null
+++ b/svx/source/gallery2/galbrws1.hxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <vcl/menu.hxx>
+#include <svl/lstner.hxx>
+#include <vector>
+#include "galbrws.hxx"
+
+// -----------------
+// - GalleryButton -
+// -----------------
+
+class GalleryButton : public PushButton
+{
+private:
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+public:
+
+ GalleryButton( GalleryBrowser1* pParent, WinBits nWinBits );
+ ~GalleryButton();
+};
+
+// -----------------------
+// - GalleryThemeListBox -
+// -----------------------
+
+class GalleryThemeListBox : public ListBox
+{
+protected:
+
+ void InitSettings();
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+public:
+
+ GalleryThemeListBox( GalleryBrowser1* pParent, WinBits nWinBits );
+ ~GalleryThemeListBox();
+};
+
+// -------------------
+// - GalleryBrowser1 -
+// -------------------
+
+class Gallery;
+class GalleryThemeEntry;
+class GalleryTheme;
+class VclAbstractDialog2;
+struct ExchangeData;
+class SfxItemSet;
+
+class GalleryBrowser1 : public Control, SfxListener
+{
+ friend class GalleryBrowser;
+ friend class GalleryThemeListBox;
+ using Control::Notify;
+ using Window::KeyInput;
+
+private:
+
+ GalleryButton maNewTheme;
+ GalleryThemeListBox* mpThemes;
+ Gallery* mpGallery;
+ ExchangeData* mpExchangeData;
+ SfxItemSet* mpThemePropsDlgItemSet;
+
+ Image aImgNormal;
+ Image aImgDefault;
+ Image aImgReadOnly;
+ Image aImgImported;
+
+ void ImplAdjustControls();
+ ULONG ImplInsertThemeEntry( const GalleryThemeEntry* pEntry );
+ void ImplFillExchangeData( const GalleryTheme* pThm, ExchangeData& rData );
+ ::std::vector< USHORT > ImplGetExecuteVector();
+ void ImplExecute( USHORT nId );
+ void ImplGalleryThemeProperties( const String & rThemeName, bool bCreateNew );
+ void ImplEndGalleryThemeProperties( VclAbstractDialog2* pDialog, bool bCreateNew );
+
+ // Control
+ virtual void Resize();
+ virtual void GetFocus();
+
+ // SfxListener
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ DECL_LINK( ClickNewThemeHdl, void* );
+ DECL_LINK( SelectThemeHdl, void* );
+ DECL_LINK( ShowContextMenuHdl, void* );
+ DECL_LINK( PopupMenuHdl, Menu* );
+ DECL_LINK( EndNewThemePropertiesDlgHdl, VclAbstractDialog2* );
+ DECL_LINK( EndThemePropertiesDlgHdl, VclAbstractDialog2* );
+ DECL_LINK( DestroyThemePropertiesDlgHdl, VclAbstractDialog2* );
+
+public:
+
+ GalleryBrowser1( GalleryBrowser* pParent, const ResId& rResId, Gallery* pGallery );
+ ~GalleryBrowser1();
+
+ void SelectTheme( const String& rThemeName ) { mpThemes->SelectEntry( rThemeName ); SelectThemeHdl( NULL ); }
+ void SelectTheme( ULONG nThemePos ) { mpThemes->SelectEntryPos( (USHORT) nThemePos ); SelectThemeHdl( NULL ); }
+ String GetSelectedTheme() { return mpThemes->GetEntryCount() ? mpThemes->GetEntry( mpThemes->GetSelectEntryPos() ) : String(); }
+
+ void ShowContextMenu();
+ BOOL KeyInput( const KeyEvent& rKEvt, Window* pWindow );
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galbrws2.cxx b/svx/source/gallery2/galbrws2.cxx
new file mode 100644
index 000000000000..0b941558d221
--- /dev/null
+++ b/svx/source/gallery2/galbrws2.cxx
@@ -0,0 +1,1255 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+
+#include <sot/formats.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/valueset.hxx>
+#include <svl/urlbmk.hxx>
+#include <svl/stritem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
+#include <svtools/transfer.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/sfxsids.hrc>
+#include "svtools/filter.hxx"
+#include <editeng/brshitem.hxx>
+#include "helpid.hrc"
+#include "gallery.hxx"
+#include "galobj.hxx"
+#include "svx/gallery1.hxx"
+#include "galtheme.hxx"
+#include "galctrl.hxx"
+#include "svx/galmisc.hxx"
+#include "galbrws2.hxx"
+#include "gallery.hrc"
+#include <vcl/svapp.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/svxdlg.hxx>
+
+// -----------
+// - Defines -
+// -----------
+
+#undef GALLERY_USE_CLIPBOARD
+
+#define TBX_ID_ICON 1
+#define TBX_ID_LIST 2
+
+// -----------
+// - statics -
+// -----------
+
+GalleryBrowserMode GalleryBrowser2::meInitMode = GALLERYBROWSERMODE_ICON;
+
+// --------------------------
+// - GalleryBackgroundPopup -
+// --------------------------
+
+class GalleryBackgroundPopup : public PopupMenu, public SfxControllerItem
+{
+ const GalleryTheme* mpTheme;
+ ULONG mnObjectPos;
+
+ virtual void Select();
+ virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState );
+
+public:
+
+ GalleryBackgroundPopup( const GalleryTheme* pTheme, ULONG nObjectPos );
+ ~GalleryBackgroundPopup();
+};
+
+// ------------------------------------------------------------------------
+
+GalleryBackgroundPopup::GalleryBackgroundPopup( const GalleryTheme* pTheme, ULONG nObjectPos ) :
+ SfxControllerItem ( SID_GALLERY_BG_BRUSH, SfxViewFrame::Current()->GetBindings() ),
+ mpTheme ( pTheme ),
+ mnObjectPos ( nObjectPos )
+{
+ SfxViewFrame::Current()->GetBindings().Update( SID_GALLERY_BG_BRUSH );
+ RemoveDisabledEntries();
+}
+
+// ------------------------------------------------------------------------
+
+GalleryBackgroundPopup::~GalleryBackgroundPopup()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryBackgroundPopup::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pItem )
+{
+ if ( ( nSID == SID_GALLERY_BG_BRUSH ) && pItem && ( eState != SFX_ITEM_DISABLED ) )
+ {
+ SfxStringListItem* pStrLstItem;
+ SfxStringItem* pStrItem;
+
+ PopupMenu::Clear();
+
+ if( ( pStrLstItem = PTR_CAST( SfxStringListItem, pItem ) ) != NULL )
+ {
+ List* pList = pStrLstItem->GetList();
+
+ if( pList )
+ for ( ULONG i = 0, nCount = pList->Count(); i < nCount; i++ )
+ InsertItem( (USHORT) i + 1, *(String*) pList->GetObject( i ) );
+ }
+ else if( ( pStrItem = PTR_CAST( SfxStringItem, pItem ) ) != NULL )
+ InsertItem( 1, pStrItem->GetValue() );
+ else
+ {
+ DBG_ERROR( "SgaBGPopup::StateChanged(...): Wrong item type!" );
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryBackgroundPopup::Select()
+{
+ Menu::Select();
+
+ const INetURLObject aURL( mpTheme->GetObjectURL( mnObjectPos ) );
+ const SvxBrushItem aBrushItem( aURL.GetMainURL( INetURLObject::NO_DECODE ), String(), GPOS_TILED, SID_GALLERY_BG_BRUSH );
+ const SfxUInt16Item aPosItem( SID_GALLERY_BG_POS, GetCurItemId() - 1 );
+ const SfxStringItem aPathItem( SID_FILE_NAME, aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( SID_GALLERY_BG_BRUSH,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aBrushItem, &aPosItem, &aPathItem, 0L );
+}
+
+// ---------------------
+// - GalleryThemePopup -
+// ---------------------
+
+class GalleryThemePopup : public PopupMenu, public SfxControllerItem
+{
+ GalleryBackgroundPopup maBackgroundPopup;
+ const GalleryTheme* mpTheme;
+ ULONG mnObjectPos;
+ BOOL mbPreview;
+
+ virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState );
+
+public:
+
+ GalleryThemePopup( const GalleryTheme* pTheme, ULONG nObjectPos, BOOL bPreview );
+ ~GalleryThemePopup();
+};
+
+// ------------------------------------------------------------------------
+
+GalleryThemePopup::GalleryThemePopup( const GalleryTheme* pTheme, ULONG nObjectPos, BOOL bPreview ) :
+ PopupMenu ( GAL_RESID( RID_SVXMN_GALLERY2 ) ),
+ SfxControllerItem ( SID_GALLERY_ENABLE_ADDCOPY, SfxViewFrame::Current()->GetBindings() ),
+ maBackgroundPopup ( pTheme, nObjectPos ),
+ mpTheme ( pTheme ),
+ mnObjectPos ( nObjectPos ),
+ mbPreview ( bPreview )
+{
+ const SgaObjKind eObjKind = mpTheme->GetObjectKind( mnObjectPos );
+ PopupMenu* pAddMenu = GetPopupMenu( MN_ADDMENU );
+ SfxBindings& rBindings = SfxViewFrame::Current()->GetBindings();
+ INetURLObject aURL;
+
+ const_cast< GalleryTheme* >( mpTheme )->GetURL( mnObjectPos, aURL );
+ const BOOL bValidURL = ( aURL.GetProtocol() != INET_PROT_NOT_VALID );
+
+ pAddMenu->EnableItem( MN_ADD, bValidURL && SGA_OBJ_SOUND != eObjKind );
+ pAddMenu->EnableItem( MN_ADD_LINK, bValidURL && SGA_OBJ_SVDRAW != eObjKind );
+
+ EnableItem( MN_ADDMENU, pAddMenu->IsItemEnabled( MN_ADD ) || pAddMenu->IsItemEnabled( MN_ADD_LINK ) );
+ EnableItem( MN_PREVIEW, bValidURL );
+
+ CheckItem( MN_PREVIEW, mbPreview );
+
+ if( mpTheme->IsReadOnly() || !mpTheme->GetObjectCount() )
+ {
+ EnableItem( MN_DELETE, FALSE );
+ EnableItem( MN_TITLE, FALSE );
+
+ if( mpTheme->IsReadOnly() )
+ EnableItem( MN_PASTECLIPBOARD, FALSE );
+
+ if( !mpTheme->GetObjectCount() )
+ EnableItem( MN_COPYCLIPBOARD, FALSE );
+ }
+ else
+ {
+ EnableItem( MN_DELETE, !bPreview );
+ EnableItem( MN_TITLE, TRUE );
+ EnableItem( MN_COPYCLIPBOARD, TRUE );
+ EnableItem( MN_PASTECLIPBOARD, TRUE );
+ }
+
+#ifdef GALLERY_USE_CLIPBOARD
+ if( IsItemEnabled( MN_PASTECLIPBOARD ) )
+ {
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) );
+ BOOL bEnable = FALSE;
+
+ if( aDataHelper.GetFormatCount() )
+ {
+ if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) ||
+ aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) ||
+ aDataHelper.HasFormat( FORMAT_FILE ) ||
+ aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) ||
+ aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) ||
+ aDataHelper.HasFormat( FORMAT_BITMAP ) )
+ {
+ bEnable = TRUE;
+ }
+ }
+
+ if( !bEnable )
+ EnableItem( MN_PASTECLIPBOARD, FALSE );
+ }
+#else
+ EnableItem( MN_COPYCLIPBOARD, FALSE );
+ EnableItem( MN_PASTECLIPBOARD, FALSE );
+#endif
+
+ if( !maBackgroundPopup.GetItemCount() || ( eObjKind == SGA_OBJ_SVDRAW ) || ( eObjKind == SGA_OBJ_SOUND ) )
+ pAddMenu->EnableItem( MN_BACKGROUND, FALSE );
+ else
+ {
+ pAddMenu->EnableItem( MN_BACKGROUND, TRUE );
+ pAddMenu->SetPopupMenu( MN_BACKGROUND, &maBackgroundPopup );
+ }
+
+ rBindings.Update( SID_GALLERY_ENABLE_ADDCOPY );
+ RemoveDisabledEntries();
+}
+
+// ------------------------------------------------------------------------
+
+GalleryThemePopup::~GalleryThemePopup()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryThemePopup::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pItem )
+{
+ if( ( nSID == SID_GALLERY_ENABLE_ADDCOPY ) && pItem && ( eState != SFX_ITEM_DISABLED ) )
+ {
+ SfxBoolItem* pBoolItem = PTR_CAST( SfxBoolItem, pItem );
+ const SgaObjKind eObjKind = mpTheme->GetObjectKind( mnObjectPos );
+
+ DBG_ASSERT( pBoolItem || pBoolItem == 0, "SfxBoolItem erwartet!");
+
+ GetPopupMenu( MN_ADDMENU )->EnableItem( MN_ADD, pBoolItem->GetValue() && ( eObjKind != SGA_OBJ_SOUND ) );
+ }
+}
+
+// ------------------
+// - GalleryToolBox -
+// ------------------
+
+GalleryToolBox::GalleryToolBox( GalleryBrowser2* pParent ) :
+ ToolBox( pParent, WB_TABSTOP )
+{
+}
+
+// ------------------------------------------------------------------------
+
+GalleryToolBox::~GalleryToolBox()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryToolBox::KeyInput( const KeyEvent& rKEvt )
+{
+ if( !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
+ ToolBox::KeyInput( rKEvt );
+}
+
+// -------------------
+// - GalleryBrowser2 -
+// -------------------
+
+GalleryBrowser2::GalleryBrowser2( GalleryBrowser* pParent, const ResId& rResId, Gallery* pGallery ) :
+ Control ( pParent, rResId ),
+ mpGallery ( pGallery ),
+ mpCurTheme ( NULL ),
+ mpIconView ( new GalleryIconView( this, NULL ) ),
+ mpListView ( new GalleryListView( this, NULL ) ),
+ mpPreview ( new GalleryPreview( this, NULL ) ),
+ maViewBox ( this ),
+ maSeparator ( this, WB_VERT ),
+ maInfoBar ( this, WB_LEFT | WB_VCENTER ),
+ mnCurActionPos ( 0xffffffff ),
+ meMode ( GALLERYBROWSERMODE_NONE ),
+ meLastMode ( GALLERYBROWSERMODE_NONE ),
+ mbCurActionIsLinkage( FALSE )
+{
+ Image aDummyImage;
+ const Link aSelectHdl( LINK( this, GalleryBrowser2, SelectObjectHdl ) );
+ Font aInfoFont( maInfoBar.GetControlFont() );
+
+ maMiscOptions.AddListenerLink( LINK( this, GalleryBrowser2, MiscHdl ) );
+
+ maViewBox.InsertItem( TBX_ID_ICON, aDummyImage );
+ maViewBox.SetItemBits( TBX_ID_ICON, TIB_RADIOCHECK | TIB_AUTOCHECK );
+ maViewBox.SetHelpId( TBX_ID_ICON, HID_GALLERY_ICONVIEW );
+ maViewBox.SetQuickHelpText( TBX_ID_ICON, String( GAL_RESID( RID_SVXSTR_GALLERY_ICONVIEW ) ) );
+
+ maViewBox.InsertItem( TBX_ID_LIST, aDummyImage );
+ maViewBox.SetItemBits( TBX_ID_LIST, TIB_RADIOCHECK | TIB_AUTOCHECK );
+ maViewBox.SetHelpId( TBX_ID_LIST, HID_GALLERY_LISTVIEW );
+ maViewBox.SetQuickHelpText( TBX_ID_LIST, String( GAL_RESID( RID_SVXSTR_GALLERY_LISTVIEW ) ) );
+
+ maViewBox.SetBorder( 0, 1 );
+ MiscHdl( NULL );
+ maViewBox.SetSelectHdl( LINK( this, GalleryBrowser2, SelectTbxHdl ) );
+ maViewBox.Show();
+
+ maInfoBar.Show();
+ maSeparator.Show();
+
+ mpIconView->SetSelectHdl( aSelectHdl );
+ mpListView->SetSelectHdl( aSelectHdl );
+
+ InitSettings();
+
+ SetMode( ( GALLERYBROWSERMODE_PREVIEW != GalleryBrowser2::meInitMode ) ? GalleryBrowser2::meInitMode : GALLERYBROWSERMODE_ICON );
+}
+
+// -----------------------------------------------------------------------------
+
+GalleryBrowser2::~GalleryBrowser2()
+{
+ maMiscOptions.RemoveListenerLink( LINK( this, GalleryBrowser2, MiscHdl ) );
+
+ delete mpPreview;
+ delete mpListView;
+ delete mpIconView;
+
+ if( mpCurTheme )
+ mpGallery->ReleaseTheme( mpCurTheme, *this );
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::InitSettings()
+{
+ Font aInfoFont( maInfoBar.GetControlFont() );
+
+ aInfoFont.SetWeight( WEIGHT_BOLD );
+ aInfoFont.SetColor( GALLERY_FG_COLOR );
+ maInfoBar.SetControlFont( aInfoFont );
+
+ maInfoBar.SetBackground( Wallpaper( GALLERY_DLG_COLOR ) );
+ maInfoBar.SetControlBackground( GALLERY_DLG_COLOR );
+
+ maSeparator.SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
+ maSeparator.SetControlBackground( GALLERY_BG_COLOR );
+ maSeparator.SetControlForeground( GALLERY_FG_COLOR );
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ InitSettings();
+ else
+ Control::DataChanged( rDCEvt );
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::Resize()
+{
+ Control::Resize();
+
+ mpIconView->Hide();
+ mpListView->Hide();
+ mpPreview->Hide();
+
+ const Size aOutSize( GetOutputSizePixel() );
+ const Size aBoxSize( maViewBox.GetOutputSizePixel() );
+ const long nOffset = 2, nSepWidth = 2;
+ const long nInfoBarX = aBoxSize.Width() + ( nOffset * 3 ) + nSepWidth;
+ const Point aPt( 0, aBoxSize.Height() + 3 );
+ const Size aSz( aOutSize.Width(), aOutSize.Height() - aPt.Y() );
+
+ maSeparator.SetPosSizePixel( Point( aBoxSize.Width() + nOffset, 0 ), Size( nSepWidth, aBoxSize.Height() ) );
+ maInfoBar.SetPosSizePixel( Point( nInfoBarX, 0 ), Size( aOutSize.Width() - nInfoBarX, aBoxSize.Height() ) );
+
+ mpIconView->SetPosSizePixel( aPt, aSz );
+ mpListView->SetPosSizePixel( aPt, aSz );
+ mpPreview->SetPosSizePixel( aPt, aSz );
+
+ switch( GetMode() )
+ {
+ case( GALLERYBROWSERMODE_ICON ): mpIconView->Show(); break;
+ case( GALLERYBROWSERMODE_LIST ): mpListView->Show(); break;
+ case( GALLERYBROWSERMODE_PREVIEW ): mpPreview->Show(); break;
+
+ default:
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ const GalleryHint& rGalleryHint = (const GalleryHint&) rHint;
+
+ switch( rGalleryHint.GetType() )
+ {
+ case( GALLERY_HINT_THEME_UPDATEVIEW ):
+ {
+ if( GALLERYBROWSERMODE_PREVIEW == GetMode() )
+ SetMode( meLastMode );
+
+ ImplUpdateViews( (USHORT) rGalleryHint.GetData1() + 1 );
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int8 GalleryBrowser2::AcceptDrop( DropTargetHelper& rTarget, const AcceptDropEvent& )
+{
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( mpCurTheme && !mpCurTheme->IsReadOnly() && !mpCurTheme ->IsImported() )
+ {
+ if( !mpCurTheme->IsDragging() )
+ {
+ if( rTarget.IsDropFormatSupported( SOT_FORMATSTR_ID_DRAWING ) ||
+ rTarget.IsDropFormatSupported( SOT_FORMAT_FILE_LIST ) ||
+ rTarget.IsDropFormatSupported( FORMAT_FILE ) ||
+ rTarget.IsDropFormatSupported( SOT_FORMATSTR_ID_SVXB ) ||
+ rTarget.IsDropFormatSupported( FORMAT_GDIMETAFILE ) ||
+ rTarget.IsDropFormatSupported( FORMAT_BITMAP ) )
+ {
+ nRet = DND_ACTION_COPY;
+ }
+ }
+ else
+ nRet = DND_ACTION_COPY;
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int8 GalleryBrowser2::ExecuteDrop( DropTargetHelper&, const ExecuteDropEvent& rEvt )
+{
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( mpCurTheme )
+ {
+ Point aSelPos;
+ const ULONG nItemId = ImplGetSelectedItemId( &rEvt.maPosPixel, aSelPos );
+ const ULONG nInsertPos = ( nItemId ? ( nItemId - 1 ) : LIST_APPEND );
+
+ if( mpCurTheme->IsDragging() )
+ mpCurTheme->ChangeObjectPos( mpCurTheme->GetDragPos(), nInsertPos );
+ else
+ nRet = mpCurTheme->InsertTransferable( rEvt.maDropEvent.Transferable, nInsertPos );
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::StartDrag( Window*, const Point* pDragPoint )
+{
+ if( mpCurTheme )
+ {
+ Point aSelPos;
+ const ULONG nItemId = ImplGetSelectedItemId( pDragPoint, aSelPos );
+
+ if( nItemId )
+ mpCurTheme->StartDrag( this, nItemId - 1 );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::TogglePreview( Window*, const Point* )
+{
+ SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode );
+ GetViewWindow()->GrabFocus();
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::ShowContextMenu( Window*, const Point* pContextPoint )
+{
+ Point aSelPos;
+ const ULONG nItemId = ImplGetSelectedItemId( pContextPoint, aSelPos );
+
+ if( mpCurTheme && nItemId && ( nItemId <= mpCurTheme->GetObjectCount() ) )
+ {
+ ImplSelectItemId( nItemId );
+
+ SfxViewFrame* pCurrentViewFrame = SfxViewFrame::Current();
+ if ( pCurrentViewFrame )
+ {
+ SfxBindings& rBindings = pCurrentViewFrame->GetBindings();
+ rBindings.ENTERREGISTRATIONS();
+ GalleryThemePopup aMenu( mpCurTheme, nItemId - 1, GALLERYBROWSERMODE_PREVIEW == GetMode() );
+ rBindings.LEAVEREGISTRATIONS();
+ aMenu.SetSelectHdl( LINK( this, GalleryBrowser2, MenuSelectHdl ) );
+ aMenu.Execute( this, aSelPos );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryBrowser2::KeyInput( const KeyEvent& rKEvt, Window* pWindow )
+{
+ Point aSelPos;
+ const ULONG nItemId = ImplGetSelectedItemId( NULL, aSelPos );
+ BOOL bRet = static_cast< GalleryBrowser* >( GetParent() )->KeyInput( rKEvt, pWindow );
+
+ if( !bRet && !maViewBox.HasFocus() && nItemId && mpCurTheme )
+ {
+ USHORT nExecuteId = 0;
+ const SgaObjKind eObjKind = mpCurTheme->GetObjectKind( nItemId - 1 );
+ INetURLObject aURL;
+
+ const_cast< GalleryTheme* >( mpCurTheme )->GetURL( nItemId - 1, aURL );
+
+ const BOOL bValidURL = ( aURL.GetProtocol() != INET_PROT_NOT_VALID );
+ BOOL bPreview = bValidURL;
+ BOOL bAdd = bValidURL;
+ BOOL bAddLink = ( bValidURL && SGA_OBJ_SVDRAW != eObjKind );
+ BOOL bDelete = FALSE;
+ BOOL bTitle = FALSE;
+
+ if( !mpCurTheme->IsReadOnly() && mpCurTheme->GetObjectCount() )
+ {
+ bDelete = ( GALLERYBROWSERMODE_PREVIEW != GetMode() );
+ bTitle = TRUE;
+ }
+
+ switch( rKEvt.GetKeyCode().GetCode() )
+ {
+ case( KEY_SPACE ):
+ case( KEY_RETURN ):
+ case( KEY_P ):
+ {
+ if( bPreview )
+ {
+ TogglePreview( pWindow );
+ bRet = TRUE;
+ }
+ }
+ break;
+
+ case( KEY_INSERT ):
+ case( KEY_I ):
+ {
+ if( bAddLink && rKEvt.GetKeyCode().IsShift() && rKEvt.GetKeyCode().IsMod1() )
+ nExecuteId = MN_ADD_LINK;
+ else if( bAdd )
+ nExecuteId = MN_ADD;
+ }
+ break;
+
+ case( KEY_DELETE ):
+ case( KEY_D ):
+ {
+ if( bDelete )
+ nExecuteId = MN_DELETE;
+ }
+ break;
+
+ case( KEY_T ):
+ {
+ if( bTitle )
+ nExecuteId = MN_TITLE;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if( nExecuteId )
+ {
+ ImplExecute( nExecuteId );
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::SelectTheme( const String& rThemeName )
+{
+ delete mpIconView, mpIconView = NULL;
+ delete mpListView, mpListView = NULL;
+ delete mpPreview, mpPreview = NULL;
+
+ if( mpCurTheme )
+ mpGallery->ReleaseTheme( mpCurTheme, *this );
+
+ mpCurTheme = mpGallery->AcquireTheme( rThemeName, *this );
+
+ mpIconView = new GalleryIconView( this, mpCurTheme );
+ mpListView = new GalleryListView( this, mpCurTheme );
+ mpPreview = new GalleryPreview( this, mpCurTheme );
+
+ const Link aSelectHdl( LINK( this, GalleryBrowser2, SelectObjectHdl ) );
+
+ mpIconView->SetSelectHdl( aSelectHdl );
+ mpListView->SetSelectHdl( aSelectHdl );
+
+ if( GALLERYBROWSERMODE_PREVIEW == GetMode() )
+ meMode = meLastMode;
+
+ Resize();
+ ImplUpdateViews( 1 );
+
+ maViewBox.EnableItem( TBX_ID_ICON, TRUE );
+ maViewBox.EnableItem( TBX_ID_LIST, TRUE );
+ maViewBox.CheckItem( ( GALLERYBROWSERMODE_ICON == GetMode() ) ? TBX_ID_ICON : TBX_ID_LIST, TRUE );
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::SetMode( GalleryBrowserMode eMode )
+{
+ if( GetMode() != eMode )
+ {
+ meLastMode = GetMode();
+
+ switch( eMode )
+ {
+ case( GALLERYBROWSERMODE_ICON ):
+ {
+ mpListView->Hide();
+
+ mpPreview->Hide();
+ mpPreview->SetGraphic( Graphic() );
+ mpPreview->PreviewMedia( INetURLObject() );
+
+ mpIconView->Show();
+
+ maViewBox.EnableItem( TBX_ID_ICON, TRUE );
+ maViewBox.EnableItem( TBX_ID_LIST, TRUE );
+
+ maViewBox.CheckItem( TBX_ID_ICON, TRUE );
+ maViewBox.CheckItem( TBX_ID_LIST, FALSE );
+ }
+ break;
+
+ case( GALLERYBROWSERMODE_LIST ):
+ {
+ mpIconView->Hide();
+
+ mpPreview->Hide();
+ mpPreview->SetGraphic( Graphic() );
+ mpPreview->PreviewMedia( INetURLObject() );
+
+ mpListView->Show();
+
+ maViewBox.EnableItem( TBX_ID_ICON, TRUE );
+ maViewBox.EnableItem( TBX_ID_LIST, TRUE );
+
+ maViewBox.CheckItem( TBX_ID_ICON, FALSE );
+ maViewBox.CheckItem( TBX_ID_LIST, TRUE );
+ }
+ break;
+
+ case( GALLERYBROWSERMODE_PREVIEW ):
+ {
+ Graphic aGraphic;
+ Point aSelPos;
+ const ULONG nItemId = ImplGetSelectedItemId( NULL, aSelPos );
+
+ if( nItemId )
+ {
+ const ULONG nPos = nItemId - 1;
+
+ mpIconView->Hide();
+ mpListView->Hide();
+
+ if( mpCurTheme )
+ mpCurTheme->GetGraphic( nPos, aGraphic );
+
+ mpPreview->SetGraphic( aGraphic );
+ mpPreview->Show();
+
+ if( mpCurTheme && mpCurTheme->GetObjectKind( nPos ) == SGA_OBJ_SOUND )
+ mpPreview->PreviewMedia( mpCurTheme->GetObjectURL( nPos ) );
+
+ maViewBox.EnableItem( TBX_ID_ICON, FALSE );
+ maViewBox.EnableItem( TBX_ID_LIST, FALSE );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ GalleryBrowser2::meInitMode = meMode = eMode;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+Window* GalleryBrowser2::GetViewWindow() const
+{
+ Window* pRet;
+
+ switch( GetMode() )
+ {
+ case( GALLERYBROWSERMODE_LIST ): pRet = mpListView; break;
+ case( GALLERYBROWSERMODE_PREVIEW ): pRet = mpPreview; break;
+
+ default:
+ pRet = mpIconView;
+ break;
+ }
+
+ return pRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::Travel( GalleryBrowserTravel eTravel )
+{
+ if( mpCurTheme )
+ {
+ Point aSelPos;
+ const ULONG nItemId = ImplGetSelectedItemId( NULL, aSelPos );
+
+ if( nItemId )
+ {
+ ULONG nNewItemId = nItemId;
+
+ switch( eTravel )
+ {
+ case( GALLERYBROWSERTRAVEL_FIRST ): nNewItemId = 1; break;
+ case( GALLERYBROWSERTRAVEL_LAST ): nNewItemId = mpCurTheme->GetObjectCount(); break;
+ case( GALLERYBROWSERTRAVEL_PREVIOUS ): nNewItemId--; break;
+ case( GALLERYBROWSERTRAVEL_NEXT ): nNewItemId++; break;
+ default:
+ break;
+ }
+
+ if( nNewItemId < 1 )
+ nNewItemId = 1;
+ else if( nNewItemId > mpCurTheme->GetObjectCount() )
+ nNewItemId = mpCurTheme->GetObjectCount();
+
+ if( nNewItemId != nItemId )
+ {
+ ImplSelectItemId( nNewItemId );
+ ImplUpdateInfoBar();
+
+ if( GALLERYBROWSERMODE_PREVIEW == GetMode() )
+ {
+ Graphic aGraphic;
+ const ULONG nPos = nNewItemId - 1;
+
+ mpCurTheme->GetGraphic( nPos, aGraphic );
+ mpPreview->SetGraphic( aGraphic );
+
+ if( SGA_OBJ_SOUND == mpCurTheme->GetObjectKind( nPos ) )
+ mpPreview->PreviewMedia( mpCurTheme->GetObjectURL( nPos ) );
+
+ mpPreview->Invalidate();
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::ImplUpdateViews( USHORT nSelectionId )
+{
+ mpIconView->Hide();
+ mpListView->Hide();
+ mpPreview->Hide();
+
+ mpIconView->Clear();
+ mpListView->Clear();
+
+ if( mpCurTheme )
+ {
+ for( ULONG i = 0, nCount = mpCurTheme->GetObjectCount(); i < nCount; )
+ {
+ mpListView->RowInserted( i++ );
+ mpIconView->InsertItem( (USHORT) i );
+ }
+
+ ImplSelectItemId( ( ( nSelectionId > mpCurTheme->GetObjectCount() ) ? mpCurTheme->GetObjectCount() : nSelectionId ) );
+ }
+
+ switch( GetMode() )
+ {
+ case( GALLERYBROWSERMODE_ICON ): mpIconView->Show(); break;
+ case( GALLERYBROWSERMODE_LIST ): mpListView->Show(); break;
+ case( GALLERYBROWSERMODE_PREVIEW ): mpPreview->Show(); break;
+
+ default:
+ break;
+ }
+
+ ImplUpdateInfoBar();
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::ImplUpdateInfoBar()
+{
+ String aInfoText;
+
+ if( mpCurTheme )
+ {
+ Point aSelPos;
+ const ULONG nItemId = ImplGetSelectedItemId( NULL, aSelPos );
+
+ if( nItemId )
+ {
+ const ULONG nPos = nItemId - 1;
+
+ aInfoText = mpCurTheme->GetName();
+
+ if( nPos < mpCurTheme->GetObjectCount() )
+ {
+ SgaObject* pObj = mpCurTheme->AcquireObject( nPos );
+
+ if( pObj )
+ {
+ aInfoText = GetItemText( *mpCurTheme, *pObj, GALLERY_ITEM_THEMENAME | GALLERY_ITEM_TITLE | GALLERY_ITEM_PATH );
+ mpCurTheme->ReleaseObject( pObj );
+ }
+ }
+ }
+ }
+
+ maInfoBar.SetText( aInfoText );
+}
+
+// -----------------------------------------------------------------------------
+
+ULONG GalleryBrowser2::ImplGetSelectedItemId( const Point* pSelPos, Point& rSelPos )
+{
+ const Size aOutputSizePixel( GetOutputSizePixel() );
+ ULONG nRet = 0;
+
+ if( GALLERYBROWSERMODE_PREVIEW == GetMode() )
+ {
+ nRet = ( ( GALLERYBROWSERMODE_ICON == meLastMode ) ? mpIconView->GetSelectItemId() : ( mpListView->FirstSelectedRow() + 1 ) );
+
+ if( pSelPos )
+ rSelPos = GetPointerPosPixel();
+ else
+ rSelPos = Point( aOutputSizePixel.Width() >> 1, aOutputSizePixel.Height() >> 1 );
+ }
+ else if( GALLERYBROWSERMODE_ICON == GetMode() )
+ {
+ if( pSelPos )
+ {
+ nRet = mpIconView->GetItemId( *pSelPos );
+ rSelPos = GetPointerPosPixel();
+ }
+ else
+ {
+ nRet = mpIconView->GetSelectItemId();
+ rSelPos = mpIconView->GetItemRect( (USHORT) nRet ).Center();
+ }
+ }
+ else
+ {
+ if( pSelPos )
+ {
+ nRet = mpListView->GetRowAtYPosPixel( pSelPos->Y() ) + 1;
+ rSelPos = GetPointerPosPixel();
+ }
+ else
+ {
+ nRet = mpListView->FirstSelectedRow() + 1;
+ rSelPos = mpListView->GetFieldRectPixel( (USHORT) nRet, 1 ).Center();
+ }
+ }
+
+ rSelPos.X() = Max( Min( rSelPos.X(), aOutputSizePixel.Width() - 1L ), 0L );
+ rSelPos.Y() = Max( Min( rSelPos.Y(), aOutputSizePixel.Height() - 1L ), 0L );
+
+ if( nRet && ( !mpCurTheme || ( nRet > mpCurTheme->GetObjectCount() ) ) )
+ {
+ nRet = 0;
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::ImplSelectItemId( ULONG nItemId )
+{
+ if( nItemId )
+ {
+
+ mpIconView->SelectItem( (USHORT) nItemId );
+ mpListView->SelectRow( nItemId - 1 );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryBrowser2::ImplExecute( USHORT nId )
+{
+ Point aSelPos;
+ const ULONG nItemId = ImplGetSelectedItemId( NULL, aSelPos );
+
+ if( mpCurTheme && nItemId )
+ {
+ mnCurActionPos = nItemId - 1;
+
+ switch( nId )
+ {
+ case( MN_ADD ):
+ case( MN_ADD_LINK ):
+ {
+ sal_uInt32 nFormat = 0;
+
+ mbCurActionIsLinkage = ( MN_ADD_LINK == nId );
+
+ switch( mpCurTheme->GetObjectKind( mnCurActionPos ) )
+ {
+ case( SGA_OBJ_BMP ):
+ case( SGA_OBJ_ANIM ):
+ case( SGA_OBJ_INET ):
+ nFormat = SGA_FORMAT_GRAPHIC | SGA_FORMAT_STRING;
+ break;
+
+ case ( SGA_OBJ_SOUND ) :
+ nFormat = SGA_FORMAT_SOUND | SGA_FORMAT_STRING;
+ break;
+
+ case( SGA_OBJ_SVDRAW ):
+ nFormat = SGA_FORMAT_GRAPHIC | SGA_FORMAT_SVDRAW | SGA_FORMAT_STRING;
+ break;
+
+ default :
+ break;
+ }
+
+ const SfxUInt32Item aItem( SID_GALLERY_FORMATS, nFormat );
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute(
+ SID_GALLERY_FORMATS, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+ break;
+
+ case( MN_PREVIEW ):
+ SetMode( ( GALLERYBROWSERMODE_PREVIEW != GetMode() ) ? GALLERYBROWSERMODE_PREVIEW : meLastMode );
+ break;
+
+ case( MN_DELETE ):
+ {
+ if( !mpCurTheme->IsReadOnly() &&
+ QueryBox( NULL, WB_YES_NO, String( GAL_RESID( RID_SVXSTR_GALLERY_DELETEOBJ ) ) ).Execute() == RET_YES )
+ {
+ mpCurTheme->RemoveObject( mnCurActionPos );
+ }
+ }
+ break;
+
+ case( MN_TITLE ):
+ {
+ SgaObject* pObj = mpCurTheme->AcquireObject( mnCurActionPos );
+
+ if( pObj )
+ {
+ const String aOldTitle( GetItemText( *mpCurTheme, *pObj, GALLERY_ITEM_TITLE ) );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractTitleDialog* aDlg = pFact->CreateTitleDialog( this, aOldTitle );
+ DBG_ASSERT(aDlg, "Dialogdiet fail!");
+ if( aDlg->Execute() == RET_OK )
+ {
+ String aNewTitle( aDlg->GetTitle() );
+
+ if( ( !aNewTitle.Len() && pObj->GetTitle().Len() ) || ( aNewTitle != aOldTitle ) )
+ {
+ if( !aNewTitle.Len() )
+ aNewTitle = String( RTL_CONSTASCII_USTRINGPARAM( "__<empty>__" ) );
+
+ pObj->SetTitle( aNewTitle );
+ mpCurTheme->InsertObject( *pObj );
+ }
+ }
+
+ mpCurTheme->ReleaseObject( pObj );
+ delete aDlg;
+ }
+ }
+ }
+ break;
+
+ case( MN_COPYCLIPBOARD ):
+ {
+ Window* pWindow;
+
+ switch( GetMode() )
+ {
+ case( GALLERYBROWSERMODE_ICON ): pWindow = (Window*) mpIconView; break;
+ case( GALLERYBROWSERMODE_LIST ): pWindow = (Window*) mpListView; break;
+ case( GALLERYBROWSERMODE_PREVIEW ): pWindow = (Window*) mpPreview; break;
+
+ default:
+ pWindow = NULL;
+ break;
+ }
+
+ mpCurTheme->CopyToClipboard( pWindow, mnCurActionPos );
+ }
+ break;
+
+ case( MN_PASTECLIPBOARD ):
+ {
+ if( !mpCurTheme->IsReadOnly() )
+ {
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( this ) );
+ mpCurTheme->InsertTransferable( aDataHelper.GetTransferable(), mnCurActionPos );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+String GalleryBrowser2::GetItemText( const GalleryTheme& rTheme, const SgaObject& rObj, ULONG nItemTextFlags )
+{
+ INetURLObject aURL;
+ String aRet;
+
+ if( rTheme.IsImported() )
+ {
+ aURL = rTheme.GetParent()->GetImportURL( rTheme.GetName() );
+
+ aURL.removeSegment();
+ aURL.Append( rObj.GetURL().GetName() );
+ }
+ else
+ aURL = rObj.GetURL();
+
+ if( nItemTextFlags & GALLERY_ITEM_THEMENAME )
+ {
+ aRet += rTheme.GetName();
+ aRet += String( RTL_CONSTASCII_USTRINGPARAM( " - " ) );
+ }
+
+ if( nItemTextFlags & GALLERY_ITEM_TITLE )
+ {
+ String aTitle( rObj.GetTitle() );
+
+ if( !aTitle.Len() )
+ aTitle = aURL.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_UNAMBIGUOUS );
+
+ if( !aTitle.Len() )
+ {
+ aTitle = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+ aTitle = aTitle.GetToken( aTitle.GetTokenCount( '/' ) - 1, '/' );
+ }
+
+ aRet += aTitle;
+ }
+
+ if( nItemTextFlags & GALLERY_ITEM_PATH )
+ {
+ const String aPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
+
+ if( aPath.Len() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) )
+ aRet += String( RTL_CONSTASCII_USTRINGPARAM( " (" ) );
+
+ aRet += String(aURL.getFSysPath( INetURLObject::FSYS_DETECT ));
+
+ if( aPath.Len() && ( nItemTextFlags & GALLERY_ITEM_TITLE ) )
+ aRet += ')';
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+INetURLObject GalleryBrowser2::GetURL() const
+{
+ INetURLObject aURL;
+
+ if( mpCurTheme && mnCurActionPos != 0xffffffff )
+ aURL = mpCurTheme->GetObjectURL( mnCurActionPos );
+
+ return aURL;
+}
+
+// -----------------------------------------------------------------------------
+
+String GalleryBrowser2::GetFilterName() const
+{
+ String aFilterName;
+
+ if( mpCurTheme && mnCurActionPos != 0xffffffff )
+ {
+ const SgaObjKind eObjKind = mpCurTheme->GetObjectKind( mnCurActionPos );
+
+ if( ( SGA_OBJ_BMP == eObjKind ) || ( SGA_OBJ_ANIM == eObjKind ) )
+ {
+ GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter();
+ INetURLObject aURL; mpCurTheme->GetURL( mnCurActionPos, aURL );
+ sal_uInt16 nFilter = pFilter->GetImportFormatNumberForShortName( aURL.GetExtension() );
+
+ if( GRFILTER_FORMAT_DONTKNOW != nFilter )
+ aFilterName = pFilter->GetImportFormatName( nFilter );
+ }
+ }
+
+ return aFilterName;
+}
+
+// -----------------------------------------------------------------------------
+
+Graphic GalleryBrowser2::GetGraphic() const
+{
+ Graphic aGraphic;
+
+ if( mpCurTheme && mnCurActionPos != 0xffffffff )
+ mpCurTheme->GetGraphic( mnCurActionPos, aGraphic );
+
+ return aGraphic;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryBrowser2::GetVCDrawModel( FmFormModel& rModel ) const
+{
+ BOOL bRet = FALSE;
+
+ if( mpCurTheme && mnCurActionPos != 0xffffffff )
+ bRet = mpCurTheme->GetModel( mnCurActionPos, rModel );
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryBrowser2::IsLinkage() const
+{
+ return mbCurActionIsLinkage;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser2, MenuSelectHdl, Menu*, pMenu )
+{
+ if( pMenu )
+ ImplExecute( pMenu->GetCurItemId() );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser2, SelectObjectHdl, void*, EMPTYARG )
+{
+ ImplUpdateInfoBar();
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser2, SelectTbxHdl, ToolBox*, pBox )
+{
+ if( pBox->GetCurItemId() == TBX_ID_ICON )
+ SetMode( GALLERYBROWSERMODE_ICON );
+ else if( pBox->GetCurItemId() == TBX_ID_LIST )
+ SetMode( GALLERYBROWSERMODE_LIST );
+
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( GalleryBrowser2, MiscHdl, void*, EMPTYARG )
+{
+ const sal_Bool bHC = maViewBox.GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ maViewBox.SetOutStyle( maMiscOptions.GetToolboxStyle() );
+
+ BitmapEx aIconBmpEx = BitmapEx( Image( GAL_RESID( bHC? RID_SVXIMG_GALLERY_VIEW_ICON_HC : RID_SVXIMG_GALLERY_VIEW_ICON ) ).GetBitmapEx() );
+ BitmapEx aListBmpEx = BitmapEx( Image( GAL_RESID( bHC? RID_SVXIMG_GALLERY_VIEW_LIST_HC : RID_SVXIMG_GALLERY_VIEW_LIST ) ).GetBitmapEx() );
+
+ if( maMiscOptions.AreCurrentSymbolsLarge() )
+ {
+ const Size aLargeSize( 24, 24);
+
+ aIconBmpEx.Scale( aLargeSize );
+ aListBmpEx.Scale( aLargeSize );
+ }
+
+ maViewBox.SetItemImage( TBX_ID_ICON, aIconBmpEx );
+ maViewBox.SetItemImage( TBX_ID_LIST, aListBmpEx );
+ maViewBox.SetSizePixel( maViewBox.CalcWindowSizePixel() );
+
+ Resize();
+
+ return 0L;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galctrl.cxx b/svx/source/gallery2/galctrl.cxx
new file mode 100644
index 000000000000..d249ba8736f7
--- /dev/null
+++ b/svx/source/gallery2/galctrl.cxx
@@ -0,0 +1,726 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <vcl/svapp.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <avmedia/mediaplayer.hxx>
+#include "helpid.hrc"
+#include "galbrws2.hxx"
+#include "galtheme.hxx"
+#include "svx/galmisc.hxx"
+#include "galctrl.hxx"
+#include "editeng/AccessibleStringWrap.hxx"
+#include <editeng/svxfont.hxx>
+#include "galobj.hxx"
+#include <avmedia/mediawindow.hxx>
+#include "gallery.hrc"
+#include <svtools/filter.hxx>
+
+// -----------
+// - Defines -
+// -----------
+
+#define GALLERY_BRWBOX_TITLE 1
+#define GALLERY_BRWBOX_PATH 2
+
+// ------------------
+// - GalleryPreview -
+// ------------------
+
+GalleryPreview::GalleryPreview( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
+ Window( pParent, WB_TABSTOP | WB_BORDER ),
+ DropTargetHelper( this ),
+ DragSourceHelper( this ),
+ mpTheme( pTheme )
+{
+ SetHelpId( HID_GALLERY_WINDOW );
+ InitSettings();
+}
+
+// ------------------------------------------------------------------------
+
+GalleryPreview::GalleryPreview( Window* pParent, const ResId & rResId ) :
+ Window( pParent, rResId ),
+ DropTargetHelper( this ),
+ DragSourceHelper( this ),
+ mpTheme( NULL )
+{
+ SetHelpId( HID_GALLERY_PREVIEW );
+ InitSettings();
+}
+
+// ------------------------------------------------------------------------
+
+GalleryPreview::~GalleryPreview()
+{
+}
+
+
+bool GalleryPreview::SetGraphic( const INetURLObject& _aURL )
+{
+ bool bRet = true;
+ Graphic aGraphic;
+ if( ::avmedia::MediaWindow::isMediaURL( _aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
+ {
+ aGraphic = BitmapEx( GAL_RESID( RID_SVXBMP_GALLERY_MEDIA ) );
+ }
+ else
+ {
+ GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter();
+ GalleryProgress aProgress( pFilter );
+ if( pFilter->ImportGraphic( aGraphic, _aURL, GRFILTER_FORMAT_DONTKNOW ) )
+ bRet = false;
+ }
+
+ SetGraphic( aGraphic );
+ Invalidate();
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryPreview::InitSettings()
+{
+ SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
+ SetControlBackground( GALLERY_BG_COLOR );
+ SetControlForeground( GALLERY_FG_COLOR );
+}
+
+// -----------------------------------------------------------------------
+
+void GalleryPreview::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ InitSettings();
+ else
+ Window::DataChanged( rDCEvt );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryPreview::ImplGetGraphicCenterRect( const Graphic& rGraphic, Rectangle& rResultRect ) const
+{
+ const Size aWinSize( GetOutputSizePixel() );
+ Size aNewSize( LogicToPixel( rGraphic.GetPrefSize(), rGraphic.GetPrefMapMode() ) );
+ BOOL bRet = FALSE;
+
+ if( aNewSize.Width() && aNewSize.Height() )
+ {
+ // scale to fit window
+ const double fGrfWH = (double) aNewSize.Width() / aNewSize.Height();
+ const double fWinWH = (double) aWinSize.Width() / aWinSize.Height();
+
+ if ( fGrfWH < fWinWH )
+ {
+ aNewSize.Width() = (long) ( aWinSize.Height() * fGrfWH );
+ aNewSize.Height()= aWinSize.Height();
+ }
+ else
+ {
+ aNewSize.Width() = aWinSize.Width();
+ aNewSize.Height()= (long) ( aWinSize.Width() / fGrfWH);
+ }
+
+ const Point aNewPos( ( aWinSize.Width() - aNewSize.Width() ) >> 1,
+ ( aWinSize.Height() - aNewSize.Height() ) >> 1 );
+
+ rResultRect = Rectangle( aNewPos, aNewSize );
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryPreview::Paint( const Rectangle& rRect )
+{
+ Window::Paint( rRect );
+
+ if( ImplGetGraphicCenterRect( aGraphicObj.GetGraphic(), aPreviewRect ) )
+ {
+ const Point aPos( aPreviewRect.TopLeft() );
+ const Size aSize( aPreviewRect.GetSize() );
+
+ if( aGraphicObj.IsAnimated() )
+ aGraphicObj.StartAnimation( this, aPos, aSize );
+ else
+ aGraphicObj.Draw( this, aPos, aSize );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryPreview::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if( mpTheme && ( rMEvt.GetClicks() == 2 ) )
+ ( (GalleryBrowser2*) GetParent() )->TogglePreview( this );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryPreview::Command(const CommandEvent& rCEvt )
+{
+ Window::Command( rCEvt );
+
+ if( mpTheme && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ) )
+ ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this,
+ ( rCEvt.IsMouseEvent() ? &rCEvt.GetMousePosPixel() : NULL ) );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryPreview::KeyInput( const KeyEvent& rKEvt )
+{
+ if( mpTheme )
+ {
+ GalleryBrowser2* pBrowser = static_cast< GalleryBrowser2* >( GetParent() );
+
+ switch( rKEvt.GetKeyCode().GetCode() )
+ {
+ case( KEY_BACKSPACE ):
+ pBrowser->TogglePreview( this );
+ break;
+
+ case( KEY_HOME ):
+ pBrowser->Travel( GALLERYBROWSERTRAVEL_FIRST );
+ break;
+
+ case( KEY_END ):
+ pBrowser->Travel( GALLERYBROWSERTRAVEL_LAST );
+ break;
+
+ case( KEY_LEFT ):
+ case( KEY_UP ):
+ pBrowser->Travel( GALLERYBROWSERTRAVEL_PREVIOUS );
+ break;
+
+ case( KEY_RIGHT ):
+ case( KEY_DOWN ):
+ pBrowser->Travel( GALLERYBROWSERTRAVEL_NEXT );
+ break;
+
+ default:
+ {
+ if( !pBrowser->KeyInput( rKEvt, this ) )
+ Window::KeyInput( rKEvt );
+ }
+ break;
+ }
+ }
+ else
+ Window::KeyInput( rKEvt );
+}
+
+// ------------------------------------------------------------------------
+
+sal_Int8 GalleryPreview::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ sal_Int8 nRet;
+
+ if( mpTheme )
+ nRet = ( (GalleryBrowser2*) GetParent() )->AcceptDrop( *this, rEvt );
+ else
+ nRet = DND_ACTION_NONE;
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------
+
+sal_Int8 GalleryPreview::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ sal_Int8 nRet;
+
+ if( mpTheme )
+ nRet = ( (GalleryBrowser2*) GetParent() )->ExecuteDrop( *this, rEvt );
+ else
+ nRet = DND_ACTION_NONE;
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryPreview::StartDrag( sal_Int8, const Point& )
+{
+ if( mpTheme )
+ ( (GalleryBrowser2*) GetParent() )->StartDrag( this );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryPreview::PreviewMedia( const INetURLObject& rURL )
+{
+ if( rURL.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ ::avmedia::MediaFloater* pFloater = AVMEDIA_MEDIAWINDOW();
+
+ if( !pFloater )
+ {
+ SfxViewFrame::Current()->GetBindings().GetDispatcher()->Execute( SID_AVMEDIA_PLAYER, SFX_CALLMODE_SYNCHRON );
+ pFloater = AVMEDIA_MEDIAWINDOW();
+ }
+
+ if( pFloater )
+ pFloater->setURL( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ), true );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+// -------------------
+// - GalleryIconView -
+// -------------------
+
+GalleryIconView::GalleryIconView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
+ ValueSet( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_VSCROLL | WB_FLATVALUESET ),
+ DropTargetHelper( this ),
+ DragSourceHelper( this ),
+ mpTheme ( pTheme )
+{
+ EnableFullItemMode( FALSE );
+
+ SetHelpId( HID_GALLERY_WINDOW );
+ InitSettings();
+ SetExtraSpacing( 2 );
+ SetItemWidth( S_THUMB + 6 );
+ SetItemHeight( S_THUMB + 6 );
+}
+
+// ------------------------------------------------------------------------
+
+GalleryIconView::~GalleryIconView()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryIconView::InitSettings()
+{
+ SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
+ SetControlBackground( GALLERY_BG_COLOR );
+ SetControlForeground( GALLERY_FG_COLOR );
+ SetColor( GALLERY_BG_COLOR );
+}
+
+// -----------------------------------------------------------------------
+
+void GalleryIconView::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ InitSettings();
+ else
+ ValueSet::DataChanged( rDCEvt );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryIconView::UserDraw( const UserDrawEvent& rUDEvt )
+{
+ const USHORT nId = rUDEvt.GetItemId();
+
+ if( nId && mpTheme )
+ {
+ SgaObject* pObj = mpTheme->AcquireObject( nId - 1 );
+
+ if( pObj )
+ {
+ const Rectangle& rRect = rUDEvt.GetRect();
+ OutputDevice* pDev = rUDEvt.GetDevice();
+ Graphic aGraphic;
+
+ if( pObj->IsThumbBitmap() )
+ {
+ Bitmap aBmp( pObj->GetThumbBmp() );
+
+ if( pObj->GetObjKind() == SGA_OBJ_SOUND )
+ aBmp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
+
+ if( ( pDev->GetBitCount() <= 8 ) && ( aBmp.GetBitCount() >= 8 ) )
+ aBmp.Dither( BMP_DITHER_FLOYD );
+
+ aGraphic = aBmp;
+ }
+ else
+ aGraphic = pObj->GetThumbMtf();
+
+ Size aSize( aGraphic.GetSizePixel( pDev ) );
+
+ if ( aSize.Width() && aSize.Height() )
+ {
+ if( ( aSize.Width() > rRect.GetWidth() ) || ( aSize.Height() > rRect.GetHeight() ) )
+ {
+ Point aNewPos;
+ const double fBmpWH = (double) aSize.Width() / aSize.Height();
+ const double fThmpWH = (double) rRect.GetWidth() / rRect.GetHeight();
+
+ // Bitmap an Thumbgroesse anpassen
+ if ( fBmpWH < fThmpWH )
+ {
+ aSize.Width() = (long) ( rRect.GetHeight() * fBmpWH );
+ aSize.Height()= rRect.GetHeight();
+ }
+ else
+ {
+ aSize.Width() = rRect.GetWidth();
+ aSize.Height()= (long) ( rRect.GetWidth() / fBmpWH );
+ }
+ }
+
+ const Point aPos( ( ( rRect.GetWidth() - aSize.Width() ) >> 1 ) + rRect.Left(),
+ ( ( rRect.GetHeight() - aSize.Height() ) >> 1 ) + rRect.Top() );
+
+ aGraphic.Draw( pDev, aPos, aSize );
+ }
+
+ SetItemText( nId, GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_THEMENAME | GALLERY_ITEM_TITLE | GALLERY_ITEM_PATH ) );
+ mpTheme->ReleaseObject( pObj );
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryIconView::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ ValueSet::MouseButtonDown( rMEvt );
+
+ if( rMEvt.GetClicks() == 2 )
+ ( (GalleryBrowser2*) GetParent() )->TogglePreview( this, &rMEvt.GetPosPixel() );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryIconView::Command( const CommandEvent& rCEvt )
+{
+ ValueSet::Command( rCEvt );
+
+ if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
+ {
+ ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this,
+ ( rCEvt.IsMouseEvent() ? &rCEvt.GetMousePosPixel() : NULL ) );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryIconView::KeyInput( const KeyEvent& rKEvt )
+{
+ if( !mpTheme || !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
+ ValueSet::KeyInput( rKEvt );
+}
+
+// ------------------------------------------------------------------------
+
+sal_Int8 GalleryIconView::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ return( static_cast< GalleryBrowser2* >( GetParent() )->AcceptDrop( *this, rEvt ) );
+}
+
+// ------------------------------------------------------------------------
+
+sal_Int8 GalleryIconView::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ return( static_cast< GalleryBrowser2* >( GetParent() )->ExecuteDrop( *this, rEvt ) );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryIconView::StartDrag( sal_Int8, const Point& )
+{
+ const CommandEvent aEvt( GetPointerPosPixel(), COMMAND_STARTDRAG, TRUE );
+ Region aRegion;
+
+ // call this to initiate dragging for ValueSet
+ ValueSet::StartDrag( aEvt, aRegion );
+ static_cast< GalleryBrowser2* >( GetParent() )->StartDrag( this );
+}
+
+// -------------------
+// - GalleryListView -
+// -------------------
+
+GalleryListView::GalleryListView( GalleryBrowser2* pParent, GalleryTheme* pTheme ) :
+ BrowseBox( pParent, WB_TABSTOP | WB_3DLOOK | WB_BORDER ),
+ mpTheme( pTheme ),
+ mnCurRow( 0 ),
+ mbInit( FALSE )
+{
+ SetHelpId( HID_GALLERY_WINDOW );
+
+ InitSettings();
+
+ SetMode( BROWSER_AUTO_VSCROLL | BROWSER_AUTOSIZE_LASTCOL );
+ SetDataRowHeight( 28 );
+ InsertDataColumn( GALLERY_BRWBOX_TITLE, String( GAL_RESID( RID_SVXSTR_GALLERY_TITLE ) ), 256 );
+ InsertDataColumn( GALLERY_BRWBOX_PATH, String( GAL_RESID( RID_SVXSTR_GALLERY_PATH ) ), 256 );
+}
+
+// ------------------------------------------------------------------------
+
+GalleryListView::~GalleryListView()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryListView::InitSettings()
+{
+ SetBackground( Wallpaper( GALLERY_BG_COLOR ) );
+ SetControlBackground( GALLERY_BG_COLOR );
+ SetControlForeground( GALLERY_FG_COLOR );
+}
+
+// -----------------------------------------------------------------------
+
+void GalleryListView::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ InitSettings();
+ else
+ BrowseBox::DataChanged( rDCEvt );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryListView::SeekRow( long nRow )
+{
+ mnCurRow = nRow;
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------------
+
+String GalleryListView::GetCellText(long _nRow, USHORT nColumnId) const
+{
+ String sRet;
+ if( mpTheme && ( _nRow < static_cast< long >( mpTheme->GetObjectCount() ) ) )
+ {
+ SgaObject* pObj = mpTheme->AcquireObject( _nRow );
+
+ if( pObj )
+ {
+ sRet = GalleryBrowser2::GetItemText( *mpTheme, *pObj,
+ ( GALLERY_BRWBOX_TITLE == nColumnId ) ? GALLERY_ITEM_TITLE : GALLERY_ITEM_PATH );
+
+ mpTheme->ReleaseObject( pObj );
+ }
+ }
+
+ return sRet;;
+}
+
+// -----------------------------------------------------------------------------
+
+Rectangle GalleryListView::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex)
+{
+ DBG_ASSERT(_nColumnPos >= 0 && _nColumnPos <= USHRT_MAX, "GalleryListView::GetFieldCharacterBounds: _nColumnId overflow");
+ Rectangle aRect;
+ if ( SeekRow(_nRow) )
+ {
+ SvxFont aFont( GetFont() );
+ AccessibleStringWrap aStringWrap( *this, aFont, GetCellText(_nRow, sal::static_int_cast<USHORT>( GetColumnId( sal::static_int_cast<USHORT>(_nColumnPos) ) ) ) );
+
+ // get the bounds inside the string
+ aStringWrap.GetCharacterBounds(nIndex, aRect);
+
+ // offset to
+ }
+ return aRect;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 GalleryListView::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint)
+{
+ DBG_ASSERT(_nColumnPos >= 0 && _nColumnPos <= USHRT_MAX, "GalleryListView::GetFieldIndexAtPoint: _nColumnId overflow");
+ sal_Int32 nRet = -1;
+ if ( SeekRow(_nRow) )
+ {
+ SvxFont aFont( GetFont() );
+ AccessibleStringWrap aStringWrap( *this, aFont, GetCellText(_nRow, sal::static_int_cast<USHORT>(GetColumnId(sal::static_int_cast<USHORT>(_nColumnPos)))) );
+ nRet = aStringWrap.GetIndexAtPoint(_rPoint);
+ }
+ return nRet;
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryListView::PaintField( OutputDevice& rDev, const Rectangle& rRect, USHORT nColumnId ) const
+{
+ rDev.Push( PUSH_CLIPREGION );
+ rDev.IntersectClipRegion( rRect );
+
+ if( mpTheme && ( mnCurRow < mpTheme->GetObjectCount() ) )
+ {
+ SgaObject* pObj = mpTheme->AcquireObject( mnCurRow );
+
+ if( pObj )
+ {
+ const long nTextPosY = rRect.Top() + ( ( rRect.GetHeight() - rDev.GetTextHeight() ) >> 1 );
+
+ if( GALLERY_BRWBOX_TITLE == nColumnId )
+ {
+ Rectangle aOutputRect( rRect.TopLeft(), Size( rRect.GetHeight(), rRect.GetHeight() ) );
+ GraphicObject aGrfObj;
+
+ if( pObj->GetObjKind() == SGA_OBJ_SOUND )
+ aGrfObj = Graphic( BitmapEx( GAL_RESID( RID_SVXBMP_GALLERY_MEDIA ) ) );
+ else if( pObj->IsThumbBitmap() )
+ aGrfObj = Graphic( pObj->GetThumbBmp() );
+ else
+ aGrfObj = Graphic( pObj->GetThumbMtf() );
+
+ Size aSize( rDev.LogicToPixel( aGrfObj.GetPrefSize(), aGrfObj.GetPrefMapMode() ) );
+
+ if( aSize.Width() && aSize.Height() )
+ {
+ if( ( aSize.Width() > aOutputRect.GetWidth() ) || ( aSize.Height() > aOutputRect.GetHeight() ) )
+ {
+ Point aNewPos;
+ const double fBmpWH = (double) aSize.Width() / aSize.Height();
+ const double fThmpWH = (double) aOutputRect.GetWidth() / aOutputRect.GetHeight();
+
+ // Bitmap an Thumbgroesse anpassen
+ if ( fBmpWH < fThmpWH )
+ {
+ aSize.Width() = (long) ( aOutputRect.GetHeight() * fBmpWH );
+ aSize.Height()= aOutputRect.GetHeight();
+ }
+ else
+ {
+ aSize.Width() = aOutputRect.GetWidth();
+ aSize.Height()= (long) ( aOutputRect.GetWidth() / fBmpWH );
+ }
+ }
+
+ aSize.Width() = Max( aSize.Width(), 4L );
+ aSize.Height() = Max( aSize.Height(), 4L );
+
+ const Point aPos( ( ( aOutputRect.GetWidth() - aSize.Width() ) >> 1 ) + aOutputRect.Left(),
+ ( ( aOutputRect.GetHeight() - aSize.Height() ) >> 1 ) + aOutputRect.Top() );
+
+ aGrfObj.Draw( &rDev, aPos, aSize );
+ }
+
+ rDev.DrawText( Point( aOutputRect.Right() + 6, nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_TITLE ) );
+ }
+ else if( GALLERY_BRWBOX_PATH == nColumnId )
+ rDev.DrawText( Point( rRect.Left(), nTextPosY ), GalleryBrowser2::GetItemText( *mpTheme, *pObj, GALLERY_ITEM_PATH ) );
+
+ mpTheme->ReleaseObject( pObj );
+ }
+ }
+
+ rDev.Pop();
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryListView::Command( const CommandEvent& rCEvt )
+{
+ BrowseBox::Command( rCEvt );
+
+ if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
+ {
+ const Point* pPos = NULL;
+
+ if( rCEvt.IsMouseEvent() && ( GetRowAtYPosPixel( rCEvt.GetMousePosPixel().Y() ) != BROWSER_ENDOFSELECTION ) )
+ pPos = &rCEvt.GetMousePosPixel();
+
+ ( (GalleryBrowser2*) GetParent() )->ShowContextMenu( this, pPos );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryListView::KeyInput( const KeyEvent& rKEvt )
+{
+ if( !mpTheme || !static_cast< GalleryBrowser2* >( GetParent() )->KeyInput( rKEvt, this ) )
+ BrowseBox::KeyInput( rKEvt );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryListView::DoubleClick( const BrowserMouseEvent& rEvt )
+{
+ BrowseBox::DoubleClick( rEvt );
+
+ if( rEvt.GetRow() != BROWSER_ENDOFSELECTION )
+ ( (GalleryBrowser2*) GetParent() )->TogglePreview( this, &rEvt.GetPosPixel() );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryListView::Select()
+{
+ if( maSelectHdl.IsSet() )
+ maSelectHdl.Call( this );
+}
+
+// ------------------------------------------------------------------------
+
+sal_Int8 GalleryListView::AcceptDrop( const BrowserAcceptDropEvent& )
+{
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( mpTheme && !mpTheme->IsReadOnly() && !mpTheme ->IsImported() )
+ {
+ if( !mpTheme->IsDragging() )
+ nRet = DND_ACTION_COPY;
+ else
+ nRet = DND_ACTION_COPY;
+ }
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------
+
+sal_Int8 GalleryListView::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
+{
+ ExecuteDropEvent aEvt( rEvt );
+
+ aEvt.maPosPixel.Y() += GetTitleHeight();
+
+ return( ( (GalleryBrowser2*) GetParent() )->ExecuteDrop( *this, aEvt ) );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryListView::StartDrag( sal_Int8, const Point& rPosPixel )
+{
+ ( (GalleryBrowser2*) GetParent() )->StartDrag( this, &rPosPixel );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galexpl.cxx b/svx/source/gallery2/galexpl.cxx
new file mode 100644
index 000000000000..e2050d36b8fe
--- /dev/null
+++ b/svx/source/gallery2/galexpl.cxx
@@ -0,0 +1,518 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <unotools/pathoptions.hxx>
+#include <sfx2/viewfrm.hxx>
+#include "svx/gallery1.hxx"
+#include "galtheme.hxx"
+#include "galbrws.hxx"
+#include "gallery.hxx"
+#include "galobj.hxx"
+
+// -----------
+// - Statics -
+// -----------
+
+static SfxListener aLockListener;
+
+// -------------------
+// - GalleryExplorer -
+// -------------------
+
+Gallery* GalleryExplorer::ImplGetGallery()
+{
+ static Gallery* pGallery = NULL;
+
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+
+ if( !pGallery )
+ pGallery = Gallery::GetGalleryInstance();
+
+ return pGallery;
+}
+
+// ------------------------------------------------------------------------
+
+GalleryExplorer* GalleryExplorer::GetGallery()
+{
+ static GalleryExplorer* pThis = NULL;
+
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+
+ // only create a dummy object which can be accessed
+ if( !pThis )
+ pThis = new GalleryExplorer;
+
+ return pThis;
+}
+
+// ------------------------------------------------------------------------
+
+INetURLObject GalleryExplorer::GetURL() const
+{
+ return GALLERYBROWSER()->GetURL();
+}
+
+String GalleryExplorer::GetFilterName() const
+{
+ return GALLERYBROWSER()->GetFilterName();
+}
+
+// ------------------------------------------------------------------------
+
+Graphic GalleryExplorer::GetGraphic() const
+{
+ return GALLERYBROWSER()->GetGraphic();
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::GetVCDrawModel( FmFormModel& rModel ) const
+{
+ return GALLERYBROWSER()->GetVCDrawModel( rModel );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::IsLinkage() const
+{
+ return GALLERYBROWSER()->IsLinkage();
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::FillThemeList( List& rThemeList )
+{
+ Gallery* pGal = ImplGetGallery();
+
+ if( pGal )
+ {
+ for( ULONG i = 0, nCount = pGal->GetThemeCount(); i < nCount; i++ )
+ {
+ const GalleryThemeEntry* pEntry = pGal->GetThemeInfo( i );
+
+ if( pEntry && !pEntry->IsReadOnly() && !pEntry->IsHidden() )
+ rThemeList.Insert( new String( pEntry->GetThemeName() ), LIST_APPEND );
+ }
+ }
+
+ return( rThemeList.Count() > 0 );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::FillObjList( const String& rThemeName, List& rObjList )
+{
+ Gallery* pGal = ImplGetGallery();
+
+ if( pGal )
+ {
+ SfxListener aListener;
+ GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
+
+ if( pTheme )
+ {
+ for( ULONG i = 0, nCount = pTheme->GetObjectCount(); i < nCount; i++ )
+ rObjList.Insert( new String( pTheme->GetObjectURL( i ).GetMainURL( INetURLObject::NO_DECODE ) ), LIST_APPEND );
+
+ pGal->ReleaseTheme( pTheme, aListener );
+ }
+ }
+
+ return( rObjList.Count() > 0 );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::FillObjList( ULONG nThemeId, List& rObjList )
+{
+ Gallery* pGal = ImplGetGallery();
+ return( pGal ? FillObjList( pGal->GetThemeName( nThemeId ), rObjList ) : FALSE );
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool GalleryExplorer::FillObjListTitle( const sal_uInt32 nThemeId, std::vector< rtl::OUString >& rList )
+{
+ Gallery* pGal = ImplGetGallery();
+ if( pGal )
+ {
+ SfxListener aListener;
+ GalleryTheme* pTheme = pGal->AcquireTheme( pGal->GetThemeName( nThemeId ), aListener );
+
+ if( pTheme )
+ {
+ for( ULONG i = 0, nCount = pTheme->GetObjectCount(); i < nCount; i++ )
+ {
+ SgaObject* pObj = pTheme->AcquireObject( i );
+ if ( pObj )
+ {
+ rtl::OUString aTitle( pObj->GetTitle() );
+ rList.push_back( aTitle );
+ pTheme->ReleaseObject( pObj );
+ }
+ }
+ pGal->ReleaseTheme( pTheme, aListener );
+ }
+ }
+ return( rList.size() > 0 );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::InsertURL( const String& rThemeName, const String& rURL )
+{
+ return InsertURL( rThemeName, rURL, SGA_FORMAT_ALL );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::InsertURL( ULONG nThemeId, const String& rURL )
+{
+ return InsertURL( nThemeId, rURL, SGA_FORMAT_ALL );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::InsertURL( const String& rThemeName, const String& rURL, const ULONG )
+{
+ Gallery* pGal = ImplGetGallery();
+ BOOL bRet = FALSE;
+
+ if( pGal )
+ {
+ SfxListener aListener;
+ GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
+
+ if( pTheme )
+ {
+ INetURLObject aURL( rURL );
+ DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+ bRet = pTheme->InsertURL( aURL );
+ pGal->ReleaseTheme( pTheme, aListener );
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::InsertURL( ULONG nThemeId, const String& rURL, const ULONG nSgaFormat )
+{
+ Gallery* pGal = ImplGetGallery();
+ return( pGal ? InsertURL( pGal->GetThemeName( nThemeId ), rURL, nSgaFormat ) : FALSE );
+}
+
+// ------------------------------------------------------------------------
+
+ULONG GalleryExplorer::GetObjCount( const String& rThemeName )
+{
+ Gallery* pGal = ImplGetGallery();
+ ULONG nRet = 0;
+
+ if( pGal )
+ {
+ SfxListener aListener;
+ GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
+
+ if( pTheme )
+ {
+ nRet = pTheme->GetObjectCount();
+ pGal->ReleaseTheme( pTheme, aListener );
+ }
+ }
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------
+
+ULONG GalleryExplorer::GetObjCount( ULONG nThemeId )
+{
+ Gallery* pGal = ImplGetGallery();
+ return( pGal ? GetObjCount( pGal->GetThemeName( nThemeId ) ) : FALSE );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::GetGraphicObj( const String& rThemeName, ULONG nPos,
+ Graphic* pGraphic, Bitmap* pThumb,
+ BOOL bProgress )
+{
+ Gallery* pGal = ImplGetGallery();
+ BOOL bRet = FALSE;
+
+ if( pGal )
+ {
+ SfxListener aListener;
+ GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
+
+ if( pTheme )
+ {
+ if( pGraphic )
+ bRet = bRet || pTheme->GetGraphic( nPos, *pGraphic, bProgress );
+
+ if( pThumb )
+ bRet = bRet || pTheme->GetThumb( nPos, *pThumb, bProgress );
+
+ pGal->ReleaseTheme( pTheme, aListener );
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::GetGraphicObj( ULONG nThemeId, ULONG nPos,
+ Graphic* pGraphic, Bitmap* pThumb,
+ BOOL bProgress )
+{
+ Gallery* pGal = ImplGetGallery();
+ return( pGal ? GetGraphicObj( pGal->GetThemeName( nThemeId ), nPos, pGraphic, pThumb, bProgress ) : FALSE );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::InsertGraphicObj( const String& rThemeName, const Graphic& rGraphic )
+{
+ Gallery* pGal = ImplGetGallery();
+ BOOL bRet = FALSE;
+
+ if( pGal )
+ {
+ SfxListener aListener;
+ GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
+
+ if( pTheme )
+ {
+ bRet = pTheme->InsertGraphic( rGraphic );
+ pGal->ReleaseTheme( pTheme, aListener );
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::InsertGraphicObj( ULONG nThemeId, const Graphic& rGraphic )
+{
+ Gallery* pGal = ImplGetGallery();
+ return( pGal ? InsertGraphicObj( pGal->GetThemeName( nThemeId ), rGraphic ) : FALSE );
+}
+
+// ------------------------------------------------------------------------
+
+ULONG GalleryExplorer::GetSdrObjCount( const String& rThemeName )
+{
+ Gallery* pGal = ImplGetGallery();
+ ULONG nRet = 0;
+
+ if( pGal )
+ {
+ SfxListener aListener;
+ GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
+
+ if( pTheme )
+ {
+ for( ULONG i = 0, nCount = pTheme->GetObjectCount(); i < nCount; i++ )
+ if( SGA_OBJ_SVDRAW == pTheme->GetObjectKind( i ) )
+ nRet++;
+
+ pGal->ReleaseTheme( pTheme, aListener );
+ }
+ }
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------
+
+ULONG GalleryExplorer::GetSdrObjCount( ULONG nThemeId )
+{
+ Gallery* pGal = ImplGetGallery();
+ return( pGal ? GetSdrObjCount( pGal->GetThemeName( nThemeId ) ) : FALSE );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::GetSdrObj( const String& rThemeName, ULONG nSdrModelPos,
+ SdrModel* pModel, Bitmap* pThumb )
+{
+ Gallery* pGal = ImplGetGallery();
+ BOOL bRet = FALSE;
+
+ if( pGal )
+ {
+ SfxListener aListener;
+ GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
+
+ if( pTheme )
+ {
+ for( ULONG i = 0, nCount = pTheme->GetObjectCount(), nActPos = 0; ( i < nCount ) && !bRet; i++ )
+ {
+ if( SGA_OBJ_SVDRAW == pTheme->GetObjectKind( i ) )
+ {
+ if( nActPos++ == nSdrModelPos )
+ {
+ if( pModel )
+ bRet = bRet || pTheme->GetModel( i, *pModel, FALSE );
+
+ if( pThumb )
+ bRet = bRet || pTheme->GetThumb( i, *pThumb );
+ }
+ }
+ }
+
+ pGal->ReleaseTheme( pTheme, aListener );
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::GetSdrObj( ULONG nThemeId, ULONG nSdrModelPos,
+ SdrModel* pModel, Bitmap* pThumb )
+{
+ Gallery* pGal = ImplGetGallery();
+ return( pGal ? GetSdrObj( pGal->GetThemeName( nThemeId ), nSdrModelPos, pModel, pThumb ) : FALSE );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::InsertSdrObj( const String& rThemeName, FmFormModel& rModel )
+{
+ Gallery* pGal = ImplGetGallery();
+ BOOL bRet = FALSE;
+
+ if( pGal )
+ {
+ SfxListener aListener;
+ GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
+
+ if( pTheme )
+ {
+ bRet = pTheme->InsertModel( rModel );
+ pGal->ReleaseTheme( pTheme, aListener );
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryExplorer::InsertSdrObj( ULONG nThemeId, FmFormModel& rModel )
+{
+ Gallery* pGal = ImplGetGallery();
+ return( pGal ? InsertSdrObj( pGal->GetThemeName( nThemeId ), rModel ) : FALSE );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryExplorer::BeginLocking( const String& rThemeName )
+{
+ Gallery* pGal = ImplGetGallery();
+ BOOL bRet = FALSE;
+
+ if( pGal )
+ {
+ GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aLockListener );
+
+ if( pTheme )
+ {
+ pTheme->LockTheme();
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryExplorer::BeginLocking( ULONG nThemeId )
+{
+ Gallery* pGal = ImplGetGallery();
+ return( pGal ? BeginLocking( pGal->GetThemeName( nThemeId ) ) : FALSE );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryExplorer::EndLocking( const String& rThemeName )
+{
+ Gallery* pGal = ImplGetGallery();
+ BOOL bRet = FALSE;
+
+ if( pGal )
+ {
+ SfxListener aListener;
+ GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
+
+ if( pTheme )
+ {
+ const BOOL bReleaseLockedTheme = pTheme->UnlockTheme();
+
+ // release acquired theme
+ pGal->ReleaseTheme( pTheme, aListener );
+
+ if( bReleaseLockedTheme )
+ {
+ // release locked theme
+ pGal->ReleaseTheme( pTheme, aLockListener );
+ bRet = TRUE;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryExplorer::EndLocking( ULONG nThemeId )
+{
+ Gallery* pGal = ImplGetGallery();
+ return( pGal ? EndLocking( pGal->GetThemeName( nThemeId ) ) : FALSE );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryExplorer::DrawCentered( OutputDevice* pOut, const FmFormModel& rModel )
+{
+ return SgaObjectSvDraw::DrawCentered( pOut, rModel );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/gallery.src b/svx/source/gallery2/gallery.src
new file mode 100644
index 000000000000..4fe6116fecca
--- /dev/null
+++ b/svx/source/gallery2/gallery.src
@@ -0,0 +1,493 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <sfx2/sfxsids.hrc>
+#include "helpid.hrc"
+#include "gallery.hrc"
+
+/******************************************************************************/
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+
+DockingWindow RID_SVXDLG_GALLERYBROWSER
+{
+ HelpId = SID_GALLERY;
+ OutputSize = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 211, 100 ) ;
+ Text [ en-US ] = "Gallery";
+ Sizeable = TRUE;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ Dockable = TRUE ;
+ EnableResizing = TRUE ;
+
+ Control GALLERY_BROWSER1
+ {
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 69, 150 ) ;
+ Border = FALSE;
+ };
+
+ Splitter GALLERY_SPLITTER
+ {
+ Pos = MAP_APPFONT ( 70 , 0 ) ;
+ Size = MAP_APPFONT ( 3, 150 ) ;
+ HScroll = TRUE;
+ };
+
+ Control GALLERY_BROWSER2
+ {
+ Pos = MAP_APPFONT ( 73, 0 ) ;
+ Size = MAP_APPFONT ( 138, 150 ) ;
+ Border = FALSE;
+ };
+};
+
+/******************************************************************************/
+
+String RID_SVXSTR_GALLERY_ACTUALIZE_PROGRESS
+{
+ Text [ en-US ] = "Update";
+};
+String RID_SVXSTR_GALLERY_FOPENERROR
+{
+ Text [ en-US ] = "This file cannot be opened" ;
+};
+String RID_SVXSTR_GALLERY_NOTHEME
+{
+ Text [ en-US ] = "Invalid Theme Name!" ;
+};
+String RID_SVXSTR_GALLERY_DELETEOBJ
+{
+ Text [ en-US ] = "Do you really want to\ndelete this object?" ;
+};
+String RID_SVXSTR_GALLERY_DELETETHEME
+{
+ Text [ en-US ] = "Do you really want to\ndelete this theme?" ;
+};
+String RID_SVXSTR_EXTFORMAT1_SYS
+{
+ Text = "wav" ;
+};
+String RID_SVXSTR_EXTFORMAT1_UI
+{
+ Text [ en-US ] = "Wave - Sound File" ;
+};
+String RID_SVXSTR_EXTFORMAT2_SYS
+{
+ Text = "aif" ;
+};
+String RID_SVXSTR_EXTFORMAT2_UI
+{
+ Text [ en-US ] = "Audio Interchange File Format" ;
+};
+String RID_SVXSTR_EXTFORMAT3_SYS
+{
+ Text = "au" ;
+};
+String RID_SVXSTR_EXTFORMAT3_UI
+{
+ Text [ en-US ] = "AU - Sound File" ;
+};
+String RID_SVXSTR_GALLERY_FILTER
+{
+ Text [ en-US ] = "Graphics filter" ;
+};
+String RID_SVXSTR_GALLERY_LENGTH
+{
+ Text [ en-US ] = "Length:" ;
+};
+String RID_SVXSTR_GALLERY_SIZE
+{
+ Text [ en-US ] = "Size:" ;
+};
+String RID_SVXSTR_GALLERY_DELETEDD
+{
+ Text [ en-US ] = "Do you want to delete the linked file?" ;
+};
+String RID_SVXSTR_GALLERY_SGIERROR
+{
+ Text [ en-US ] = "This file cannot be opened.\nDo you want to enter a different search path? " ;
+};
+String RID_SVXSTR_GALLERY_NEWTHEME
+{
+ Text [ en-US ] = "New Theme" ;
+};
+String RID_SVXSTR_GALLERY_BROWSER
+{
+ Text [ en-US ] = "~Organizer..." ;
+};
+String RID_SVXSTR_GALLERY_THEMEERR
+{
+ Text [ en-US ] = "This theme name already exists.\nPlease choose a different one." ;
+};
+String RID_SVXSTR_GALLERY_IMPORTTHEME
+{
+ Text [ en-US ] = "I~mport..." ;
+};
+String RID_SVXSTR_GALLERY_CREATETHEME
+{
+ Text [ en-US ] = "New Theme..." ;
+};
+String RID_SVXSTR_GALLERY_DIALOGID
+{
+ Text [ en-US ] = "Assign ID" ;
+};
+String RID_SVXSTR_GALLERY_TITLE
+{
+ Text [ en-US ] = "Title" ;
+};
+String RID_SVXSTR_GALLERY_PATH
+{
+ Text [ en-US ] = "Path" ;
+};
+String RID_SVXSTR_GALLERY_ICONVIEW
+{
+ Text [ en-US ] = "Icon View";
+};
+String RID_SVXSTR_GALLERY_LISTVIEW
+{
+ Text [ en-US ] = "Detailed View";
+};
+
+/******************************************************************************/
+
+Bitmap RID_SVXBMP_GALLERY
+{
+ File = "lx03135.bmp" ;
+};
+
+Bitmap RID_SVXBMP_THEME_NORMAL
+{
+ File = "galnors.bmp" ;
+};
+
+Bitmap RID_SVXBMP_THEME_IMPORTED
+{
+ File = "galimps.bmp" ;
+};
+
+Bitmap RID_SVXBMP_THEME_READONLY
+{
+ File = "galrdos.bmp" ;
+};
+
+Bitmap RID_SVXBMP_THEME_DEFAULT
+{
+ File = "galdefs.bmp" ;
+};
+
+Bitmap RID_SVXBMP_GALLERY_MEDIA
+{
+ File = "galmedia.bmp";
+};
+
+Bitmap RID_SVXBMP_GALLERY_SOUND_1
+{
+ File = "galsnd1.bmp";
+};
+
+Bitmap RID_SVXBMP_GALLERY_SOUND_2
+{
+ File = "galsnd2.bmp";
+};
+
+Bitmap RID_SVXBMP_GALLERY_SOUND_3
+{
+ File = "galsnd3.bmp";
+};
+
+Bitmap RID_SVXBMP_GALLERY_SOUND_4
+{
+ File = "galsnd4.bmp";
+};
+
+Bitmap RID_SVXBMP_GALLERY_SOUND_5
+{
+ File = "galsnd5.bmp";
+};
+
+Bitmap RID_SVXBMP_GALLERY_SOUND_6
+{
+ File = "galsnd6.bmp";
+};
+
+Bitmap RID_SVXBMP_GALLERY_SOUND_7
+{
+ File = "galsnd7.bmp";
+};
+
+Image RID_SVXIMG_GALLERY_VIEW_ICON
+{
+ ImageBitmap = Bitmap { File = "galicon.bmp"; };
+ MASKCOLOR
+};
+
+Image RID_SVXIMG_GALLERY_VIEW_LIST
+{
+ ImageBitmap = Bitmap { File = "gallist.bmp"; };
+ MASKCOLOR
+};
+
+Image RID_SVXIMG_GALLERY_VIEW_ICON_HC
+{
+ ImageBitmap = Bitmap { File = "galicon_h.bmp"; };
+ MASKCOLOR
+};
+
+Image RID_SVXIMG_GALLERY_VIEW_LIST_HC
+{
+ ImageBitmap = Bitmap { File = "gallist_h.bmp"; };
+ MASKCOLOR
+};
+
+
+/******************************************************************************/
+
+Menu RID_SVXMN_GALLERY1
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_ACTUALIZE;
+ HelpId = HID_GALLERY_ACTUALIZE;
+ Text [ en-US ] = "Update";
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_DELETE ;
+ HelpId = HID_GALLERY_MN_DELETE ;
+ Text [ en-US ] = "~Delete" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_RENAME;
+ HelpId = HID_GALLERY_RENAME;
+ Text [ en-US ] = "~Rename" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_ASSIGN_ID;
+ Text [ en-US ] = "Assign ~ID" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_PROPERTIES;
+ HelpId = HID_GALLERY_PROPERTIES;
+ Text [ en-US ] = "Propert~ies..." ;
+ };
+ };
+};
+
+/******************************************************************************/
+
+Menu RID_SVXMN_GALLERY2
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_ADDMENU ;
+ HelpId = HID_GALLERY_MN_ADDMENU ;
+ Text [ en-US ] = "~Insert" ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = MN_ADD ;
+ HelpId = HID_GALLERY_MN_ADD ;
+ Text [ en-US ] = "~Copy" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_ADD_LINK ;
+ HelpId = HID_GALLERY_MN_ADD_LINK ;
+ Text [ en-US ] = "Link" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_BACKGROUND ;
+ HelpId = HID_GALLERY_MN_BACKGROUND ;
+ Text [ en-US ] = "Bac~kground" ;
+ };
+ };
+ };
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_PREVIEW ;
+ HelpId = HID_GALLERY_MN_PREVIEW ;
+ Text [ en-US ] = "~Preview" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_TITLE ;
+ HelpId = HID_GALLERY_TITLE;
+ Text [ en-US ] = "~Title" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_DELETE ;
+ HelpId = HID_GALLERY_MN_DELETE ;
+ Text [ en-US ] = "~Delete" ;
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = MN_COPYCLIPBOARD;
+ HelpId = HID_GALLERY_MN_COPYCLIPBOARD;
+ Text [ en-US ] = "~Copy" ;
+ };
+ MenuItem
+ {
+ Identifier = MN_PASTECLIPBOARD;
+ HelpId = HID_GALLERY_MN_PASTECLIPBOARD;
+ Text [ en-US ] = "~Insert" ;
+ };
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/gallery2/gallery1.cxx b/svx/source/gallery2/gallery1.cxx
new file mode 100644
index 000000000000..63a10022e71b
--- /dev/null
+++ b/svx/source/gallery2/gallery1.cxx
@@ -0,0 +1,925 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define ENABLE_BYTESTRING_STREAM_OPERATORS
+
+#include <tools/vcompat.hxx>
+#include <ucbhelper/content.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/pathoptions.hxx>
+#include <sfx2/docfile.hxx>
+#include "gallery.hxx"
+#include "gallery.hrc"
+#include "svx/galmisc.hxx"
+#include "galtheme.hxx"
+#include "svx/gallery1.hxx"
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+
+#define ENABLE_BYTESTRING_STREAM_OPERATORS
+
+// --------------
+// - Namespaces -
+// --------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+// ---------------------
+// - GalleryThemeEntry -
+// ---------------------
+
+GalleryThemeEntry::GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName,
+ UINT32 _nFileNumber, BOOL _bReadOnly, BOOL _bImported,
+ BOOL _bNewFile, UINT32 _nId, BOOL _bThemeNameFromResource ) :
+ nFileNumber ( _nFileNumber ),
+ nId ( _nId ),
+ bReadOnly ( _bReadOnly || _bImported ),
+ bImported ( _bImported ),
+ bThemeNameFromResource ( _bThemeNameFromResource )
+{
+ INetURLObject aURL( rBaseURL );
+ DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+ String aFileName( String( RTL_CONSTASCII_USTRINGPARAM( "sg" ) ) );
+
+ aURL.Append( ( aFileName += String::CreateFromInt32( nFileNumber ) ) += String( RTL_CONSTASCII_USTRINGPARAM( ".thm" ) ) );
+ aThmURL = ImplGetURLIgnoreCase( aURL );
+
+ aURL.setExtension( String( RTL_CONSTASCII_USTRINGPARAM( "sdg" ) ) );
+ aSdgURL = ImplGetURLIgnoreCase( aURL );
+
+ aURL.setExtension( String( RTL_CONSTASCII_USTRINGPARAM( "sdv" ) ) );
+ aSdvURL = ImplGetURLIgnoreCase( aURL );
+
+ SetModified( _bNewFile );
+
+ if( nId && bThemeNameFromResource )
+ aName = String( GAL_RESID( RID_GALLERYSTR_THEME_START + (USHORT) nId ) );
+
+ if( !aName.Len() )
+ aName = rName;
+}
+
+// -----------------------------------------------------------------------------
+
+INetURLObject GalleryThemeEntry::ImplGetURLIgnoreCase( const INetURLObject& rURL ) const
+{
+ INetURLObject aURL( rURL );
+ String aFileName;
+ BOOL bExists = FALSE;
+
+ // check original file name
+ if( FileExists( aURL ) )
+ bExists = TRUE;
+ else
+ {
+ // check upper case file name
+ aURL.setName( aURL.getName().toAsciiUpperCase() );
+
+ if( FileExists( aURL ) )
+ bExists = TRUE;
+ else
+ {
+ // check lower case file name
+ aURL.setName( aURL.getName().toAsciiLowerCase() );
+
+ if( FileExists( aURL ) )
+ bExists = TRUE;
+ }
+ }
+
+ return aURL;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryThemeEntry::SetName( const String& rNewName )
+{
+ if( aName != rNewName )
+ {
+ aName = rNewName;
+ SetModified( TRUE );
+ bThemeNameFromResource = FALSE;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryThemeEntry::SetId( UINT32 nNewId, BOOL bResetThemeName )
+{
+ nId = nNewId;
+ SetModified( TRUE );
+ bThemeNameFromResource = ( nId && bResetThemeName );
+}
+
+// ---------------------------
+// - GalleryImportThemeEntry -
+// ---------------------------
+
+SvStream& operator<<( SvStream& rOut, const GalleryImportThemeEntry& rEntry )
+{
+ ByteString aDummy;
+
+ rOut << ByteString( rEntry.aThemeName, RTL_TEXTENCODING_UTF8 ) <<
+ ByteString( rEntry.aUIName, RTL_TEXTENCODING_UTF8 ) <<
+ ByteString( String(rEntry.aURL.GetMainURL( INetURLObject::NO_DECODE )), RTL_TEXTENCODING_UTF8 ) <<
+ ByteString( rEntry.aImportName, RTL_TEXTENCODING_UTF8 ) <<
+ aDummy;
+
+ return rOut;
+}
+
+// ------------------------------------------------------------------------
+
+SvStream& operator>>( SvStream& rIn, GalleryImportThemeEntry& rEntry )
+{
+ ByteString aTmpStr;
+
+ rIn >> aTmpStr; rEntry.aThemeName = String( aTmpStr, RTL_TEXTENCODING_UTF8 );
+ rIn >> aTmpStr; rEntry.aUIName = String( aTmpStr, RTL_TEXTENCODING_UTF8 );
+ rIn >> aTmpStr; rEntry.aURL = INetURLObject( String( aTmpStr, RTL_TEXTENCODING_UTF8 ) );
+ rIn >> aTmpStr; rEntry.aImportName = String( aTmpStr, RTL_TEXTENCODING_UTF8 );
+ rIn >> aTmpStr;
+
+ return rIn;
+}
+
+// --------------------------
+// - GalleryThemeCacheEntry -
+// --------------------------
+
+class GalleryThemeCacheEntry
+{
+private:
+
+ const GalleryThemeEntry* mpThemeEntry;
+ GalleryTheme* mpTheme;
+
+public:
+
+ GalleryThemeCacheEntry( const GalleryThemeEntry* pThemeEntry, GalleryTheme* pTheme ) :
+ mpThemeEntry( pThemeEntry ), mpTheme( pTheme ) {}
+ ~GalleryThemeCacheEntry() { delete mpTheme; }
+
+ const GalleryThemeEntry* GetThemeEntry() const { return mpThemeEntry; }
+ GalleryTheme* GetTheme() const { return mpTheme; }
+};
+
+// -----------
+// - Gallery -
+// -----------
+
+Gallery::Gallery( const String& rMultiPath )
+: nReadTextEncoding ( gsl_getSystemTextEncoding() )
+, nLastFileNumber ( 0 )
+, bMultiPath ( FALSE )
+{
+ ImplLoad( rMultiPath );
+}
+
+// ------------------------------------------------------------------------
+
+Gallery::~Gallery()
+{
+ // Themen-Liste loeschen
+ for( GalleryThemeEntry* pThemeEntry = aThemeList.First(); pThemeEntry; pThemeEntry = aThemeList.Next() )
+ delete pThemeEntry;
+
+ // Import-Liste loeschen
+ for( GalleryImportThemeEntry* pImportEntry = aImportList.First(); pImportEntry; pImportEntry = aImportList.Next() )
+ delete pImportEntry;
+}
+
+// ------------------------------------------------------------------------
+
+Gallery* Gallery::GetGalleryInstance()
+{
+ static Gallery* pGallery = NULL;
+
+ if( !pGallery )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !pGallery )
+ {
+ pGallery = new Gallery( SvtPathOptions().GetGalleryPath() );
+ }
+ }
+
+ return pGallery;
+}
+
+// ------------------------------------------------------------------------
+
+void Gallery::ImplLoad( const String& rMultiPath )
+{
+ const USHORT nTokenCount = rMultiPath.GetTokenCount( ';' );
+ sal_Bool bIsReadOnlyDir;
+
+ bMultiPath = ( nTokenCount > 0 );
+
+ INetURLObject aCurURL(SvtPathOptions().GetConfigPath());
+ ImplLoadSubDirs( aCurURL, bIsReadOnlyDir );
+
+ if( !bIsReadOnlyDir )
+ aUserURL = aCurURL;
+
+ if( bMultiPath )
+ {
+ aRelURL = INetURLObject( rMultiPath.GetToken( 0, ';' ) );
+
+ for( USHORT i = 0UL; i < nTokenCount; i++ )
+ {
+ aCurURL = INetURLObject(rMultiPath.GetToken( i, ';' ));
+
+ ImplLoadSubDirs( aCurURL, bIsReadOnlyDir );
+
+ if( !bIsReadOnlyDir )
+ aUserURL = aCurURL;
+ }
+ }
+ else
+ aRelURL = INetURLObject( rMultiPath );
+
+ DBG_ASSERT( aUserURL.GetProtocol() != INET_PROT_NOT_VALID, "no writable Gallery user directory available" );
+ DBG_ASSERT( aRelURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+
+ ImplLoadImports();
+}
+
+// ------------------------------------------------------------------------
+
+void Gallery::ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbDirIsReadOnly )
+{
+ rbDirIsReadOnly = sal_False;
+
+ try
+ {
+ uno::Reference< ucb::XCommandEnvironment > xEnv;
+ ::ucbhelper::Content aCnt( rBaseURL.GetMainURL( INetURLObject::NO_DECODE ), xEnv );
+
+ uno::Sequence< OUString > aProps( 1 );
+ aProps.getArray()[ 0 ] = OUString::createFromAscii( "Url" );
+
+ uno::Reference< sdbc::XResultSet > xResultSet( aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
+
+ try
+ {
+ // check readonlyness the very hard way
+ INetURLObject aTestURL( rBaseURL );
+ String aTestFile( RTL_CONSTASCII_USTRINGPARAM( "cdefghij.klm" ) );
+
+ aTestURL.Append( aTestFile );
+ SvStream* pTestStm = ::utl::UcbStreamHelper::CreateStream( aTestURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE );
+
+ if( pTestStm )
+ {
+ *pTestStm << 1;
+
+ if( pTestStm->GetError() )
+ rbDirIsReadOnly = sal_True;
+
+ delete pTestStm;
+ KillFile( aTestURL );
+ }
+ else
+ rbDirIsReadOnly = sal_True;
+ }
+ catch( const ucb::ContentCreationException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ if( xResultSet.is() )
+ {
+ uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
+
+ if( xContentAccess.is() )
+ {
+ while( xResultSet->next() )
+ {
+ INetURLObject aThmURL( xContentAccess->queryContentIdentifierString() );
+
+ if(aThmURL.GetExtension().equalsIgnoreAsciiCaseAscii("thm"))
+ {
+ INetURLObject aSdgURL( aThmURL); aSdgURL.SetExtension( OUString::createFromAscii( "sdg" ) );
+ INetURLObject aSdvURL( aThmURL ); aSdvURL.SetExtension( OUString::createFromAscii( "sdv" ) );
+ const OUString aTitleProp( OUString::createFromAscii( "Title" ) );
+ const OUString aReadOnlyProp( OUString::createFromAscii( "IsReadOnly" ) );
+ OUString aTitle;
+ sal_Bool bReadOnly = sal_False;
+
+ try
+ {
+ ::ucbhelper::Content aThmCnt( aThmURL.GetMainURL( INetURLObject::NO_DECODE ), xEnv );
+ ::ucbhelper::Content aSdgCnt( aSdgURL.GetMainURL( INetURLObject::NO_DECODE ), xEnv );
+ ::ucbhelper::Content aSdvCnt( aSdvURL.GetMainURL( INetURLObject::NO_DECODE ), xEnv );
+
+ try
+ {
+ aThmCnt.getPropertyValue( aTitleProp ) >>= aTitle;
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ if( aTitle.getLength() )
+ {
+ try
+ {
+ aThmCnt.getPropertyValue( aReadOnlyProp ) >>= bReadOnly;
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ if( !bReadOnly )
+ {
+ try
+ {
+ aSdgCnt.getPropertyValue( aTitleProp ) >>= aTitle;
+ }
+ catch( const ::com::sun::star::uno::RuntimeException& )
+ {
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ if( aTitle.getLength() )
+ {
+ try
+ {
+ aSdgCnt.getPropertyValue( aReadOnlyProp ) >>= bReadOnly;
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ }
+ }
+
+ if( !bReadOnly )
+ {
+ try
+ {
+ aSdvCnt.getPropertyValue( aTitleProp ) >>= aTitle;
+ }
+ catch( const ::com::sun::star::uno::RuntimeException& )
+ {
+ }
+ catch( const ::com::sun::star::uno::Exception& )
+ {
+ }
+
+ if( aTitle.getLength() )
+ {
+ try
+ {
+ aSdvCnt.getPropertyValue( aReadOnlyProp ) >>= bReadOnly;
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ }
+ }
+
+ GalleryThemeEntry* pEntry = GalleryTheme::CreateThemeEntry( aThmURL, rbDirIsReadOnly || bReadOnly );
+
+ if( pEntry )
+ {
+ const ULONG nFileNumber = (ULONG) String(aThmURL.GetBase()).Erase( 0, 2 ).Erase( 6 ).ToInt32();
+
+ aThemeList.Insert( pEntry, LIST_APPEND );
+
+ if( nFileNumber > nLastFileNumber )
+ nLastFileNumber = nFileNumber;
+ }
+ }
+ }
+ catch( const ucb::ContentCreationException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ }
+ }
+ }
+ }
+ }
+ catch( const ucb::ContentCreationException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void Gallery::ImplLoadImports()
+{
+ INetURLObject aURL( GetUserURL() );
+
+ aURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( "gallery.sdi" ) ) );
+
+ if( FileExists( aURL ) )
+ {
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+ if( pIStm )
+ {
+ GalleryThemeEntry* pThemeEntry;
+ GalleryImportThemeEntry* pImportEntry;
+ INetURLObject aFile;
+ UINT32 nInventor;
+ UINT32 nCount;
+ UINT16 nId;
+ UINT16 i;
+ UINT16 nTempCharSet;
+
+ for( pImportEntry = aImportList.First(); pImportEntry; pImportEntry = aImportList.Next() )
+ delete pImportEntry;
+
+ aImportList.Clear();
+ *pIStm >> nInventor;
+
+ if( nInventor == COMPAT_FORMAT( 'S', 'G', 'A', '3' ) )
+ {
+ *pIStm >> nId >> nCount >> nTempCharSet;
+
+ for( i = 0; i < nCount; i++ )
+ {
+ pImportEntry = new GalleryImportThemeEntry;
+
+ *pIStm >> *pImportEntry;
+ aImportList.Insert( pImportEntry, LIST_APPEND );
+ aFile = INetURLObject( pImportEntry->aURL );
+ pThemeEntry = new GalleryThemeEntry( aFile,
+ pImportEntry->aUIName,
+ String(aFile.GetBase()).Erase( 0, 2 ).Erase( 6 ).ToInt32(),
+ TRUE, TRUE, FALSE, 0, FALSE );
+
+ aThemeList.Insert( pThemeEntry, LIST_APPEND );
+ }
+ }
+
+ delete pIStm;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void Gallery::ImplWriteImportList()
+{
+ INetURLObject aURL( GetUserURL() );
+ aURL.Append( ( String( "gallery.sdi", RTL_TEXTENCODING_UTF8 ) ) );
+ SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
+
+ if( pOStm )
+ {
+ const UINT32 nInventor = (UINT32) COMPAT_FORMAT( 'S', 'G', 'A', '3' );
+ const UINT16 nId = 0x0004;
+
+ *pOStm << nInventor << nId << (UINT32) aImportList.Count() << (UINT16) gsl_getSystemTextEncoding();
+
+ for( GalleryImportThemeEntry* pImportEntry = aImportList.First(); pImportEntry; pImportEntry = aImportList.Next() )
+ *pOStm << *pImportEntry;
+
+ if( pOStm->GetError() )
+ ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
+
+ delete pOStm;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+GalleryThemeEntry* Gallery::ImplGetThemeEntry( const String& rThemeName )
+{
+ GalleryThemeEntry* pFound = NULL;
+
+ if( rThemeName.Len() )
+ for( GalleryThemeEntry* pEntry = aThemeList.First(); pEntry && !pFound; pEntry = aThemeList.Next() )
+ if( rThemeName == pEntry->GetThemeName() )
+ pFound = pEntry;
+
+ return pFound;
+}
+
+// ------------------------------------------------------------------------
+
+GalleryImportThemeEntry* Gallery::ImplGetImportThemeEntry( const String& rImportName )
+{
+ GalleryImportThemeEntry* pFound = NULL;
+
+ for( GalleryImportThemeEntry* pImportEntry = aImportList.First(); pImportEntry && !pFound; pImportEntry = aImportList.Next() )
+ if ( rImportName == pImportEntry->aUIName )
+ pFound = pImportEntry;
+
+ return pFound;
+}
+
+// ------------------------------------------------------------------------
+
+String Gallery::GetThemeName( ULONG nThemeId ) const
+{
+ GalleryThemeEntry* pFound = NULL;
+
+ for( ULONG n = 0, nCount = aThemeList.Count(); n < nCount; n++ )
+ {
+ GalleryThemeEntry* pEntry = aThemeList.GetObject( n );
+
+ if( nThemeId == pEntry->GetId() )
+ pFound = pEntry;
+ }
+
+ // try fallback, if no entry was found
+ if( !pFound )
+ {
+ ByteString aFallback;
+
+ switch( nThemeId )
+ {
+ case( GALLERY_THEME_3D ): aFallback = "3D"; break;
+ case( GALLERY_THEME_BULLETS ): aFallback = "Bullets"; break;
+ case( GALLERY_THEME_HOMEPAGE ): aFallback = "Homepage"; break;
+ case( GALLERY_THEME_HTMLBUTTONS ): aFallback = "private://gallery/hidden/HtmlExportButtons"; break;
+ case( GALLERY_THEME_POWERPOINT ): aFallback = "private://gallery/hidden/imgppt"; break;
+ case( GALLERY_THEME_FONTWORK ): aFallback = "private://gallery/hidden/fontwork"; break;
+ case( GALLERY_THEME_FONTWORK_VERTICAL ): aFallback = "private://gallery/hidden/fontworkvertical"; break;
+ case( GALLERY_THEME_RULERS ): aFallback = "Rulers"; break;
+ case( GALLERY_THEME_SOUNDS ): aFallback = "Sounds"; break;
+
+ default:
+ break;
+ }
+
+ pFound = ( (Gallery*) this )->ImplGetThemeEntry( String::CreateFromAscii( aFallback.GetBuffer() ) );
+ }
+
+ return( pFound ? pFound->GetThemeName() : String() );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL Gallery::HasTheme( const String& rThemeName )
+{
+ return( ImplGetThemeEntry( rThemeName ) != NULL );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL Gallery::CreateTheme( const String& rThemeName, UINT32 nNumFrom )
+{
+ BOOL bRet = FALSE;
+
+ if( !HasTheme( rThemeName ) && ( GetUserURL().GetProtocol() != INET_PROT_NOT_VALID ) )
+ {
+ nLastFileNumber = nNumFrom > nLastFileNumber ? nNumFrom : nLastFileNumber + 1;
+ GalleryThemeEntry* pNewEntry = new GalleryThemeEntry( GetUserURL(), rThemeName,
+ nLastFileNumber,
+ FALSE, FALSE, TRUE, 0, FALSE );
+
+ aThemeList.Insert( pNewEntry, LIST_APPEND );
+ delete( new GalleryTheme( this, pNewEntry ) );
+ Broadcast( GalleryHint( GALLERY_HINT_THEME_CREATED, rThemeName ) );
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL Gallery::CreateImportTheme( const INetURLObject& rURL, const String& rImportName )
+{
+ INetURLObject aURL( rURL );
+ BOOL bRet = FALSE;
+
+ DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+
+ if( FileExists( aURL ) )
+ {
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+ if( pIStm )
+ {
+ ULONG nStmErr;
+ UINT16 nId;
+
+ *pIStm >> nId;
+
+ if( nId > 0x0004 )
+ ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
+ else
+ {
+ ByteString aTmpStr;
+ String aThemeName; *pIStm >> aTmpStr; aThemeName = String( aTmpStr, RTL_TEXTENCODING_UTF8 );
+ GalleryThemeEntry* pThemeEntry = new GalleryThemeEntry( aURL, rImportName,
+ String(aURL.GetBase()).Erase( 0, 2 ).Erase( 6 ).ToInt32(),
+ TRUE, TRUE, TRUE, 0, FALSE );
+ GalleryTheme* pImportTheme = new GalleryTheme( this, pThemeEntry );
+
+ pIStm->Seek( STREAM_SEEK_TO_BEGIN );
+ *pIStm >> *pImportTheme;
+ nStmErr = pIStm->GetError();
+
+ if( nStmErr )
+ {
+ delete pThemeEntry;
+ ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
+ }
+ else
+ {
+ String aName( rImportName );
+ String aNewName( aName );
+ ULONG nCount = 0;
+
+ aName += ' ';
+
+ while ( HasTheme( aNewName ) && ( nCount++ < 16000 ) )
+ {
+ aNewName = aName;
+ aNewName += String::CreateFromInt32( nCount );
+ }
+
+ pImportTheme->SetImportName( aNewName );
+ aThemeList.Insert( pThemeEntry, LIST_APPEND );
+
+ // Thema in Import-Liste eintragen und Import-Liste speichern
+ GalleryImportThemeEntry* pImportEntry = new GalleryImportThemeEntry;
+ pImportEntry->aThemeName = pImportEntry->aUIName = aNewName;
+ pImportEntry->aURL = rURL;
+ pImportEntry->aImportName = rImportName;
+ aImportList.Insert( pImportEntry, LIST_APPEND );
+ ImplWriteImportList();
+ bRet = TRUE;
+ }
+
+ delete pImportTheme;
+ }
+
+ delete pIStm;
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL Gallery::RenameTheme( const String& rOldName, const String& rNewName )
+{
+ GalleryThemeEntry* pThemeEntry = ImplGetThemeEntry( rOldName );
+ BOOL bRet = FALSE;
+
+ // Ueberpruefen, ob neuer Themenname schon vorhanden ist
+ if( pThemeEntry && !HasTheme( rNewName ) && ( !pThemeEntry->IsReadOnly() || pThemeEntry->IsImported() ) )
+ {
+ SfxListener aListener;
+ GalleryTheme* pThm = AcquireTheme( rOldName, aListener );
+
+ if( pThm )
+ {
+ const String aOldName( rOldName );
+
+ pThemeEntry->SetName( rNewName );
+ pThm->ImplWrite();
+
+ if( pThemeEntry->IsImported() )
+ {
+ pThm->SetImportName( rNewName );
+
+ GalleryImportThemeEntry* pImportEntry = ImplGetImportThemeEntry( rOldName );
+
+ if( pImportEntry )
+ {
+ pImportEntry->aUIName = rNewName;
+ ImplWriteImportList();
+ }
+ }
+
+ Broadcast( GalleryHint( GALLERY_HINT_THEME_RENAMED, aOldName, pThm->GetName() ) );
+ ReleaseTheme( pThm, aListener );
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL Gallery::RemoveTheme( const String& rThemeName )
+{
+ GalleryThemeEntry* pThemeEntry = ImplGetThemeEntry( rThemeName );
+ BOOL bRet = FALSE;
+
+ if( pThemeEntry && ( !pThemeEntry->IsReadOnly() || pThemeEntry->IsImported() ) )
+ {
+ Broadcast( GalleryHint( GALLERY_HINT_CLOSE_THEME, rThemeName ) );
+
+ if( pThemeEntry->IsImported() )
+ {
+ GalleryImportThemeEntry* pImportEntry = ImplGetImportThemeEntry( rThemeName );
+
+ if( pImportEntry )
+ {
+ delete aImportList.Remove( pImportEntry );
+ ImplWriteImportList();
+ }
+ }
+ else
+ {
+ SfxListener aListener;
+ GalleryTheme* pThm = AcquireTheme( rThemeName, aListener );
+
+ if( pThm )
+ {
+ INetURLObject aThmURL( pThm->GetThmURL() );
+ INetURLObject aSdgURL( pThm->GetSdgURL() );
+ INetURLObject aSdvURL( pThm->GetSdvURL() );
+
+ ReleaseTheme( pThm, aListener );
+
+ KillFile( aThmURL );
+ KillFile( aSdgURL );
+ KillFile( aSdvURL );
+ }
+ }
+
+ delete aThemeList.Remove( pThemeEntry );
+ Broadcast( GalleryHint( GALLERY_HINT_THEME_REMOVED, rThemeName ) );
+
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+INetURLObject Gallery::GetImportURL( const String& rThemeName )
+{
+ INetURLObject aURL;
+ GalleryImportThemeEntry* pImportEntry = ImplGetImportThemeEntry( rThemeName );
+
+ if( pImportEntry )
+ {
+ aURL = pImportEntry->aURL;
+ DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+ }
+
+ return aURL;
+}
+
+// ------------------------------------------------------------------------
+
+GalleryTheme* Gallery::ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry )
+{
+ GalleryTheme* pTheme = NULL;
+
+ if( pThemeEntry )
+ {
+ GalleryThemeCacheEntry* pEntry;
+
+ for( pEntry = (GalleryThemeCacheEntry*) aThemeCache.First(); pEntry && !pTheme; pEntry = (GalleryThemeCacheEntry*) aThemeCache.Next() )
+ if( pThemeEntry == pEntry->GetThemeEntry() )
+ pTheme = pEntry->GetTheme();
+
+ if( !pTheme )
+ {
+ INetURLObject aURL;
+
+ if( !pThemeEntry->IsImported() )
+ aURL = pThemeEntry->GetThmURL();
+ else
+ aURL = GetImportURL( pThemeEntry->GetThemeName() );
+
+ DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+
+ if( FileExists( aURL ) )
+ {
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+ if( pIStm )
+ {
+ pTheme = new GalleryTheme( this, (GalleryThemeEntry*) pThemeEntry );
+ *pIStm >> *pTheme;
+
+ if( pIStm->GetError() )
+ delete pTheme, pTheme = NULL;
+ else if( pThemeEntry->IsImported() )
+ pTheme->SetImportName( pThemeEntry->GetThemeName() );
+
+ delete pIStm;
+ }
+ }
+
+ if( pTheme )
+ aThemeCache.Insert( new GalleryThemeCacheEntry( pThemeEntry, pTheme ), LIST_APPEND );
+ }
+ }
+
+ return pTheme;
+}
+
+// ------------------------------------------------------------------------
+
+void Gallery::ImplDeleteCachedTheme( GalleryTheme* pTheme )
+{
+ GalleryThemeCacheEntry* pEntry;
+ BOOL bDone = FALSE;
+
+ for( pEntry = (GalleryThemeCacheEntry*) aThemeCache.First(); pEntry && !bDone; pEntry = (GalleryThemeCacheEntry*) aThemeCache.Next() )
+ {
+ if( pTheme == pEntry->GetTheme() )
+ {
+ delete (GalleryThemeCacheEntry*) aThemeCache.Remove( pEntry );
+ bDone = TRUE;
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+GalleryTheme* Gallery::AcquireTheme( const String& rThemeName, SfxListener& rListener )
+{
+ GalleryTheme* pTheme = NULL;
+ GalleryThemeEntry* pThemeEntry = ImplGetThemeEntry( rThemeName );
+
+ if( pThemeEntry && ( ( pTheme = ImplGetCachedTheme( pThemeEntry ) ) != NULL ) )
+ rListener.StartListening( *pTheme );
+
+ return pTheme;
+}
+
+// ------------------------------------------------------------------------
+
+void Gallery::ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener )
+{
+ if( pTheme )
+ {
+ rListener.EndListening( *pTheme );
+
+ if( !pTheme->HasListeners() )
+ ImplDeleteCachedTheme( pTheme );
+ }
+}
+
+BOOL GalleryThemeEntry::IsDefault() const
+{ return( ( nId > 0 ) && ( nId != ( RID_GALLERYSTR_THEME_MYTHEME - RID_GALLERYSTR_THEME_START ) ) ); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/gallerydrawmodel.hxx b/svx/source/gallery2/gallerydrawmodel.hxx
new file mode 100644
index 000000000000..0c6bd7d6e691
--- /dev/null
+++ b/svx/source/gallery2/gallerydrawmodel.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <sfx2/objsh.hxx>
+
+class FmFormModel;
+
+class SvxGalleryDrawModel
+{
+public:
+ SvxGalleryDrawModel();
+ ~SvxGalleryDrawModel();
+
+ FmFormModel* GetModel() const { return mpFormModel; }
+
+private:
+ SfxObjectShellLock mxDoc;
+ FmFormModel* mpFormModel;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx
new file mode 100644
index 000000000000..7a011b4ba6f5
--- /dev/null
+++ b/svx/source/gallery2/galmisc.cxx
@@ -0,0 +1,672 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <unotools/streamwrap.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/processfactory.hxx>
+#include <ucbhelper/content.hxx>
+#include <tools/resmgr.hxx>
+#include <tools/urlobj.hxx>
+#include <svl/solar.hrc>
+#include <svl/urihelper.hxx>
+#include <svtools/filter.hxx>
+#include <svl/itempool.hxx>
+#include <sfx2/docfile.hxx>
+#include <avmedia/mediawindow.hxx>
+#include <vcl/svapp.hxx>
+
+#include "svtools/filter.hxx"
+#include <svx/svdpage.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/fmview.hxx>
+#include <svx/unomodel.hxx>
+#include "codec.hxx"
+#include "gallery.hrc"
+#include "svx/gallery1.hxx"
+#include "galtheme.hxx"
+#include "svx/galmisc.hxx"
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <com/sun/star/ucb/TransferInfo.hpp>
+#include <com/sun/star/ucb/NameClash.hpp>
+
+// --------------
+// - Namespaces -
+// --------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+// ----------
+// - ResMgr -
+// ----------
+
+ResMgr* GetGalleryResMgr()
+{
+ static ResMgr* pGalleryResMgr = NULL;
+
+ if( !pGalleryResMgr )
+ {
+ ByteString aResMgrName( "gal" );
+ pGalleryResMgr = ResMgr::CreateResMgr(
+ aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
+ }
+
+ return pGalleryResMgr;
+}
+
+// -------------------------
+// - GalleryResGetBitmapEx -
+// -------------------------
+
+BitmapEx GalleryResGetBitmapEx( sal_uInt32 nId )
+{
+ BitmapEx aBmpEx( GAL_RESID( nId ) );
+
+ if( !aBmpEx.IsTransparent() )
+ aBmpEx = BitmapEx( aBmpEx.GetBitmap(), COL_LIGHTMAGENTA );
+
+ return aBmpEx;
+}
+
+// ----------------------
+// - SgaUserDataFactory -
+// ----------------------
+
+IMPL_LINK( SgaUserDataFactory, MakeUserData, SdrObjFactory*, pObjFactory )
+{
+ if ( pObjFactory->nInventor == IV_IMAPINFO && pObjFactory->nIdentifier == ID_IMAPINFO )
+ pObjFactory->pNewData = new SgaIMapInfo;
+
+ return 0L;
+}
+
+// ------------------------
+// - GalleryGraphicImport -
+// ------------------------
+
+USHORT GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic,
+ String& rFilterName, BOOL bShowProgress )
+{
+ USHORT nRet = SGA_IMPORT_NONE;
+ SfxMedium aMedium( rURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ, TRUE );
+ String aFilterName;
+
+ aMedium.DownLoad();
+
+ SvStream* pIStm = aMedium.GetInStream();
+
+ if( pIStm )
+ {
+ GraphicFilter* pGraphicFilter = GraphicFilter::GetGraphicFilter();
+ GalleryProgress* pProgress = bShowProgress ? new GalleryProgress( pGraphicFilter ) : NULL;
+ USHORT nFormat;
+
+ if( !pGraphicFilter->ImportGraphic( rGraphic, rURL.GetMainURL( INetURLObject::NO_DECODE ), *pIStm, GRFILTER_FORMAT_DONTKNOW, &nFormat ) )
+ {
+ rFilterName = pGraphicFilter->GetImportFormatName( nFormat );
+ nRet = SGA_IMPORT_FILE;
+ }
+
+ delete pProgress;
+ }
+
+ return nRet;
+}
+
+// -----------------------
+// - GallerySvDrawImport -
+// -----------------------
+
+BOOL GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel )
+{
+ UINT32 nVersion;
+ BOOL bRet = FALSE;
+
+ if( GalleryCodec::IsCoded( rIStm, nVersion ) )
+ {
+ SvMemoryStream aMemStm( 65535, 65535 );
+ GalleryCodec aCodec( rIStm );
+
+ aCodec.Read( aMemStm );
+ aMemStm.Seek( 0UL );
+
+ if( 1 == nVersion )
+ {
+ DBG_ERROR( "staroffice binary file formats are no longer supported inside the gallery!" );
+ bRet = false;
+ }
+ else if( 2 == nVersion )
+ {
+ // recall to read as XML
+ bRet = GallerySvDrawImport( aMemStm, rModel );
+ }
+ }
+ else
+ {
+ // read as XML
+ uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( rIStm ) );
+
+ rModel.GetItemPool().SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
+ uno::Reference< lang::XComponent > xComponent;
+
+ bRet = SvxDrawingLayerImport( &rModel, xInputStream, xComponent, "com.sun.star.comp.Draw.XMLOasisImporter" );
+ if( !bRet || (rModel.GetPageCount() == 0) )
+ {
+ rIStm.Seek(0);
+ bRet = SvxDrawingLayerImport( &rModel, xInputStream, xComponent, "com.sun.star.comp.Draw.XMLImporter" );
+ }
+
+ }
+
+ return bRet;
+}
+
+// ---------------------
+// - CreateIMapGraphic -
+// ---------------------
+
+BOOL CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap )
+{
+ BOOL bRet = FALSE;
+
+ if ( rModel.GetPageCount() )
+ {
+ const SdrPage* pPage = rModel.GetPage( 0 );
+ const SdrObject* pObj = pPage->GetObj( 0 );
+
+ if ( pPage->GetObjCount() == 1 && pObj->ISA( SdrGrafObj ) )
+ {
+ const USHORT nCount = pObj->GetUserDataCount();
+
+ // gibt es in den User-Daten eine IMap-Information?
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ const SdrObjUserData* pUserData = pObj->GetUserData( i );
+
+ if ( ( pUserData->GetInventor() == IV_IMAPINFO ) && ( pUserData->GetId() == ID_IMAPINFO ) )
+ {
+ rGraphic = ( (SdrGrafObj*) pObj )->GetGraphic();
+ rImageMap = ( (SgaIMapInfo*) pUserData )->GetImageMap();
+ bRet = TRUE;
+ break;
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// --------------------
+// - GetReducedString -
+// --------------------
+
+String GetReducedString( const INetURLObject& rURL, ULONG nMaxLen )
+{
+ String aReduced( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) );
+
+ aReduced = aReduced.GetToken( aReduced.GetTokenCount( '/' ) - 1, '/' );
+
+ if( INET_PROT_PRIV_SOFFICE != rURL.GetProtocol() )
+ {
+ sal_Unicode aDelimiter;
+ const String aPath( rURL.getFSysPath( INetURLObject::FSYS_DETECT, &aDelimiter ) );
+ const String aName( aReduced );
+
+ if( aPath.Len() > nMaxLen )
+ {
+ aReduced = aPath.Copy( 0, (USHORT)( nMaxLen - aName.Len() - 4 ) );
+ aReduced += String( RTL_CONSTASCII_USTRINGPARAM( "..." ) );
+ aReduced += aDelimiter;
+ aReduced += aName;
+ }
+ else
+ aReduced = aPath;
+ }
+
+ return aReduced;
+}
+
+// -----------------------------------------------------------------------------
+
+String GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL )
+{
+ String aRet;
+
+ if( rSvDrawObjURL.GetProtocol() == INET_PROT_PRIV_SOFFICE &&
+ String(rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE )).GetTokenCount( '/' ) == 3 )
+ {
+ aRet = String(rSvDrawObjURL.GetMainURL( INetURLObject::NO_DECODE )).GetToken( 2, '/' );
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL FileExists( const INetURLObject& rURL )
+{
+ BOOL bRet = FALSE;
+
+ if( rURL.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ try
+ {
+ ::ucbhelper::Content aCnt( rURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >() );
+ OUString aTitle;
+
+ aCnt.getPropertyValue( OUString::createFromAscii( "Title" ) ) >>= aTitle;
+ bRet = ( aTitle.getLength() > 0 );
+ }
+ catch( const ucb::ContentCreationException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL CreateDir( const INetURLObject& rURL )
+{
+ BOOL bRet = FileExists( rURL );
+
+ if( !bRet )
+ {
+ try
+ {
+ uno::Reference< ucb::XCommandEnvironment > aCmdEnv;
+ INetURLObject aNewFolderURL( rURL );
+ INetURLObject aParentURL( aNewFolderURL ); aParentURL.removeSegment();
+ ::ucbhelper::Content aParent( aParentURL.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv );
+ uno::Sequence< OUString > aProps( 1 );
+ uno::Sequence< uno::Any > aValues( 1 );
+
+ aProps.getArray()[ 0 ] = OUString::createFromAscii( "Title" );
+ aValues.getArray()[ 0 ] = uno::makeAny( OUString( aNewFolderURL.GetName() ) );
+
+ ::ucbhelper::Content aContent( aNewFolderURL.GetMainURL( INetURLObject::NO_DECODE ), aCmdEnv );
+ bRet = aParent.insertNewContent( OUString::createFromAscii( "application/vnd.sun.staroffice.fsys-folder" ), aProps, aValues, aContent );
+ }
+ catch( const ucb::ContentCreationException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL CopyFile( const INetURLObject& rSrcURL, const INetURLObject& rDstURL )
+{
+ BOOL bRet = FALSE;
+
+ try
+ {
+ ::ucbhelper::Content aDestPath( rDstURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >() );
+
+ aDestPath.executeCommand( OUString::createFromAscii( "transfer" ),
+ uno::makeAny( ucb::TransferInfo( sal_False, rSrcURL.GetMainURL( INetURLObject::NO_DECODE ),
+ rDstURL.GetName(), ucb::NameClash::OVERWRITE ) ) );
+ bRet = TRUE;
+ }
+ catch( const ucb::ContentCreationException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL KillFile( const INetURLObject& rURL )
+{
+ BOOL bRet = FileExists( rURL );
+
+ if( bRet )
+ {
+ try
+ {
+ ::ucbhelper::Content aCnt( rURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >() );
+ aCnt.executeCommand( OUString::createFromAscii( "delete" ), uno::makeAny( sal_Bool( sal_True ) ) );
+ }
+ catch( const ucb::ContentCreationException& )
+ {
+ bRet = FALSE;
+ }
+ catch( const uno::RuntimeException& )
+ {
+ bRet = FALSE;
+ }
+ catch( const uno::Exception& )
+ {
+ bRet = FALSE;
+ }
+ }
+
+ return bRet;
+}
+
+// -------------------
+// - GalleryProgress -
+// -------------------
+
+GalleryProgress::GalleryProgress( GraphicFilter* pFilter ) :
+ mpFilter( pFilter )
+{
+ uno::Reference< lang::XMultiServiceFactory > xMgr( ::utl::getProcessServiceFactory() );
+
+ if( xMgr.is() )
+ {
+ uno::Reference< awt::XProgressMonitor > xMonitor( xMgr->createInstance(
+ ::rtl::OUString::createFromAscii( "com.sun.star.awt.XProgressMonitor" ) ),
+ uno::UNO_QUERY );
+
+ if ( xMonitor.is() )
+ {
+ mxProgressBar = uno::Reference< awt::XProgressBar >( xMonitor, uno::UNO_QUERY );
+
+ if( mxProgressBar.is() )
+ {
+ String aProgressText;
+
+ if( mpFilter )
+ {
+ aProgressText = String( GAL_RESID( RID_SVXSTR_GALLERY_FILTER ) );
+// mpFilter->SetUpdatePercentHdl( LINK( this, GalleryProgress, Update ) ); // sj: progress wasn't working up from SO7 at all
+// // so I am removing this. The gallery progress should
+// // be changed to use the XStatusIndicator instead of XProgressMonitor
+ }
+ else
+ aProgressText = String( RTL_CONSTASCII_USTRINGPARAM( "Gallery" ) );
+
+ xMonitor->addText( String( RTL_CONSTASCII_USTRINGPARAM( "Gallery" ) ), aProgressText, sal_False ) ;
+ mxProgressBar->setRange( 0, GALLERY_PROGRESS_RANGE );
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+GalleryProgress::~GalleryProgress()
+{
+// if( mpFilter )
+// mpFilter->SetUpdatePercentHdl( Link() );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryProgress::Update( ULONG nVal, ULONG nMaxVal )
+{
+ if( mxProgressBar.is() && nMaxVal )
+ mxProgressBar->setValue( Min( (ULONG)( (double) nVal / nMaxVal * GALLERY_PROGRESS_RANGE ), (ULONG) GALLERY_PROGRESS_RANGE ) );
+}
+
+// -----------------------
+// - GalleryTransferable -
+// -----------------------
+
+GalleryTransferable::GalleryTransferable( GalleryTheme* pTheme, ULONG nObjectPos, bool bLazy ) :
+ mpTheme( pTheme ),
+ meObjectKind( mpTheme->GetObjectKind( nObjectPos ) ),
+ mnObjectPos( nObjectPos ),
+ mpGraphicObject( NULL ),
+ mpImageMap( NULL ),
+ mpURL( NULL )
+{
+ InitData( bLazy );
+}
+
+// ------------------------------------------------------------------------
+
+GalleryTransferable::~GalleryTransferable()
+{
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTransferable::InitData( bool bLazy )
+{
+ switch( meObjectKind )
+ {
+ case( SGA_OBJ_SVDRAW ):
+ {
+ if( !bLazy )
+ {
+ if( !mpGraphicObject )
+ {
+ Graphic aGraphic;
+
+ if( mpTheme->GetGraphic( mnObjectPos, aGraphic ) )
+ mpGraphicObject = new GraphicObject( aGraphic );
+ }
+
+ if( !mxModelStream.Is() )
+ {
+ mxModelStream = new SotStorageStream( String() );
+ mxModelStream->SetBufferSize( 16348 );
+
+ if( !mpTheme->GetModelStream( mnObjectPos, mxModelStream ) )
+ mxModelStream.Clear();
+ else
+ mxModelStream->Seek( 0 );
+ }
+ }
+ }
+ break;
+
+ case( SGA_OBJ_ANIM ):
+ case( SGA_OBJ_BMP ):
+ case( SGA_OBJ_INET ):
+ case( SGA_OBJ_SOUND ):
+ {
+ if( !mpURL )
+ {
+ mpURL = new INetURLObject;
+
+ if( !mpTheme->GetURL( mnObjectPos, *mpURL ) )
+ delete mpURL, mpURL = NULL;
+ }
+
+ if( ( SGA_OBJ_SOUND != meObjectKind ) && !mpGraphicObject )
+ {
+ Graphic aGraphic;
+
+ if( mpTheme->GetGraphic( mnObjectPos, aGraphic ) )
+ mpGraphicObject = new GraphicObject( aGraphic );
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR( "GalleryTransferable::GalleryTransferable: invalid object type" );
+ break;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTransferable::AddSupportedFormats()
+{
+ if( SGA_OBJ_SVDRAW == meObjectKind )
+ {
+ AddFormat( SOT_FORMATSTR_ID_DRAWING );
+ AddFormat( SOT_FORMATSTR_ID_SVXB );
+ AddFormat( FORMAT_GDIMETAFILE );
+ AddFormat( FORMAT_BITMAP );
+ }
+ else
+ {
+ if( mpURL )
+ AddFormat( FORMAT_FILE );
+
+ if( mpGraphicObject )
+ {
+ AddFormat( SOT_FORMATSTR_ID_SVXB );
+
+ if( mpGraphicObject->GetType() == GRAPHIC_GDIMETAFILE )
+ {
+ AddFormat( FORMAT_GDIMETAFILE );
+ AddFormat( FORMAT_BITMAP );
+ }
+ else
+ {
+ AddFormat( FORMAT_BITMAP );
+ AddFormat( FORMAT_GDIMETAFILE );
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool GalleryTransferable::GetData( const datatransfer::DataFlavor& rFlavor )
+{
+ sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
+ sal_Bool bRet = sal_False;
+
+ InitData( false );
+
+ if( ( SOT_FORMATSTR_ID_DRAWING == nFormat ) && ( SGA_OBJ_SVDRAW == meObjectKind ) )
+ {
+ bRet = ( mxModelStream.Is() && SetObject( &mxModelStream, 0, rFlavor ) );
+ }
+ else if( ( SOT_FORMATSTR_ID_SVIM == nFormat ) && mpImageMap )
+ {
+ // TODO/MBA: do we need a BaseURL here?!
+ bRet = SetImageMap( *mpImageMap, rFlavor );
+ }
+ else if( ( FORMAT_FILE == nFormat ) && mpURL )
+ {
+ bRet = SetString( mpURL->GetMainURL( INetURLObject::NO_DECODE ), rFlavor );
+ }
+ else if( ( SOT_FORMATSTR_ID_SVXB == nFormat ) && mpGraphicObject )
+ {
+ bRet = SetGraphic( mpGraphicObject->GetGraphic(), rFlavor );
+ }
+ else if( ( FORMAT_GDIMETAFILE == nFormat ) && mpGraphicObject )
+ {
+ bRet = SetGDIMetaFile( mpGraphicObject->GetGraphic().GetGDIMetaFile(), rFlavor );
+ }
+ else if( ( FORMAT_BITMAP == nFormat ) && mpGraphicObject )
+ {
+ bRet = SetBitmap( mpGraphicObject->GetGraphic().GetBitmap(), rFlavor );
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+sal_Bool GalleryTransferable::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject,
+ sal_uInt32, const datatransfer::DataFlavor& )
+{
+ sal_Bool bRet = sal_False;
+
+ if( pUserObject )
+ {
+ *rxOStm << *static_cast< SotStorageStream* >( pUserObject );
+ bRet = ( rxOStm->GetError() == ERRCODE_NONE );
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTransferable::DragFinished( sal_Int8 nDropAction )
+{
+ mpTheme->SetDragging( FALSE );
+ mpTheme->SetDragPos( 0 );
+ if ( nDropAction )
+ {
+ Window *pFocusWindow = Application::GetFocusWindow();
+ if ( pFocusWindow )
+ pFocusWindow->GrabFocusToDocument();
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTransferable::ObjectReleased()
+{
+ mxModelStream.Clear();
+ delete mpGraphicObject, mpGraphicObject = NULL;
+ delete mpImageMap, mpImageMap = NULL;
+ delete mpURL, mpURL = NULL;
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTransferable::CopyToClipboard( Window* pWindow )
+{
+ TransferableHelper::CopyToClipboard( pWindow );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTransferable::StartDrag( Window* pWindow, sal_Int8 nDragSourceActions,
+ sal_Int32 nDragPointer, sal_Int32 nDragImage )
+{
+ INetURLObject aURL;
+
+ if( mpTheme->GetURL( mnObjectPos, aURL ) && ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) )
+ {
+ mpTheme->SetDragging( sal_True );
+ mpTheme->SetDragPos( mnObjectPos );
+ TransferableHelper::StartDrag( pWindow, nDragSourceActions, nDragPointer, nDragImage );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
new file mode 100644
index 000000000000..6a727c3662cc
--- /dev/null
+++ b/svx/source/gallery2/galobj.cxx
@@ -0,0 +1,610 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define ENABLE_BYTESTRING_STREAM_OPERATORS
+
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <sfx2/objsh.hxx>
+#include <sfx2/docfac.hxx>
+
+#include <comphelper/classids.hxx>
+#include <unotools/pathoptions.hxx>
+
+#include <tools/rcid.h>
+#include <tools/vcompat.hxx>
+#include <vcl/virdev.hxx>
+#include <svl/itempool.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/fmview.hxx>
+#include <svx/fmpage.hxx>
+#include "gallery.hrc"
+#include "svx/galmisc.hxx"
+#include "galobj.hxx"
+#include <vcl/salbtype.hxx> // FRound
+#include <vcl/svapp.hxx>
+
+#include "gallerydrawmodel.hxx"
+
+using namespace ::com::sun::star;
+
+// -------------
+// - SgaObject -
+// -------------
+
+SgaObject::SgaObject() :
+ bIsValid ( FALSE ),
+ bIsThumbBmp ( TRUE )
+{
+}
+
+// ------------------------------------------------------------------------
+
+BOOL SgaObject::CreateThumb( const Graphic& rGraphic )
+{
+ BOOL bRet = FALSE;
+
+ if( rGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+ Size aBmpSize( aBmpEx.GetSizePixel() );
+
+ if( aBmpSize.Width() && aBmpSize.Height() )
+ {
+ const Color aWhite( COL_WHITE );
+
+ if( aBmpEx.GetPrefMapMode().GetMapUnit() != MAP_PIXEL &&
+ aBmpEx.GetPrefSize().Width() > 0 &&
+ aBmpEx.GetPrefSize().Height() > 0 )
+ {
+ Size aLogSize( OutputDevice::LogicToLogic( aBmpEx.GetPrefSize(), aBmpEx.GetPrefMapMode(), MAP_100TH_MM ) );
+
+ if( aLogSize.Width() > 0 && aLogSize.Height() > 0 )
+ {
+ double fFactorLog = static_cast< double >( aLogSize.Width() ) / aLogSize.Height();
+ double fFactorPix = static_cast< double >( aBmpSize.Width() ) / aBmpSize.Height();
+
+ if( fFactorPix > fFactorLog )
+ aBmpSize.Width() = FRound( aBmpSize.Height() * fFactorLog );
+ else
+ aBmpSize.Height() = FRound( aBmpSize.Width() / fFactorLog );
+
+ aBmpEx.SetSizePixel( aBmpSize );
+ }
+ }
+
+ aThumbBmp = aBmpEx.GetBitmap( &aWhite );
+
+ if( ( aBmpSize.Width() <= S_THUMB ) && ( aBmpSize.Height() <= S_THUMB ) )
+ {
+ aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
+ bRet = TRUE;
+ }
+ else
+ {
+ const float fFactor = (float) aBmpSize.Width() / aBmpSize.Height();
+ const Size aNewSize( Max( (long) (fFactor < 1. ? S_THUMB * fFactor : S_THUMB), 8L ),
+ Max( (long) (fFactor < 1. ? S_THUMB : S_THUMB / fFactor), 8L ) );
+
+ if( aThumbBmp.Scale( (double) aNewSize.Width() / aBmpSize.Width(),
+ (double) aNewSize.Height() / aBmpSize.Height(), BMP_SCALE_INTERPOLATE ) )
+ {
+ aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
+ bRet = TRUE;
+ }
+ }
+ }
+ }
+ else if( rGraphic.GetType() == GRAPHIC_GDIMETAFILE )
+ {
+ const Size aPrefSize( rGraphic.GetPrefSize() );
+ const double fFactor = (double)aPrefSize.Width() / (double)aPrefSize.Height();
+ Size aSize( S_THUMB, S_THUMB );
+ if ( fFactor < 1.0 )
+ aSize.Width() = (sal_Int32)( S_THUMB * fFactor );
+ else
+ aSize.Height() = (sal_Int32)( S_THUMB / fFactor );
+
+ const GraphicConversionParameters aParameters(aSize);
+ aThumbBmp = rGraphic.GetBitmap(aParameters);
+
+ if( !aThumbBmp.IsEmpty() )
+ {
+ aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+void SgaObject::WriteData( SvStream& rOut, const String& rDestDir ) const
+{
+ static const UINT32 nInventor = COMPAT_FORMAT( 'S', 'G', 'A', '3' );
+
+ rOut << nInventor << (UINT16) 0x0004 << GetVersion() << (UINT16) GetObjKind();
+ rOut << bIsThumbBmp;
+
+ if( bIsThumbBmp )
+ {
+ const USHORT nOldCompressMode = rOut.GetCompressMode();
+ const ULONG nOldVersion = rOut.GetVersion();
+
+ rOut.SetCompressMode( COMPRESSMODE_ZBITMAP );
+ rOut.SetVersion( SOFFICE_FILEFORMAT_50 );
+
+ rOut << aThumbBmp;
+
+ rOut.SetVersion( nOldVersion );
+ rOut.SetCompressMode( nOldCompressMode );
+ }
+ else
+ rOut << aThumbMtf;
+
+ String aURLWithoutDestDir = String(aURL.GetMainURL( INetURLObject::NO_DECODE ));
+ aURLWithoutDestDir.SearchAndReplace(rDestDir, String());
+ rOut << ByteString( aURLWithoutDestDir, RTL_TEXTENCODING_UTF8 );
+}
+
+// ------------------------------------------------------------------------
+
+void SgaObject::ReadData(SvStream& rIn, UINT16& rReadVersion )
+{
+ ByteString aTmpStr;
+ UINT32 nTmp32;
+ UINT16 nTmp16;
+
+ rIn >> nTmp32 >> nTmp16 >> rReadVersion >> nTmp16 >> bIsThumbBmp;
+
+ if( bIsThumbBmp )
+ rIn >> aThumbBmp;
+ else
+ rIn >> aThumbMtf;
+
+ rIn >> aTmpStr; aURL = INetURLObject( String( aTmpStr.GetBuffer(), RTL_TEXTENCODING_UTF8 ) );
+}
+
+// ------------------------------------------------------------------------
+
+const String SgaObject::GetTitle() const
+{
+ String aReturnValue( aTitle );
+ if ( !getenv( "GALLERY_SHOW_PRIVATE_TITLE" ) )
+ {
+ if ( aReturnValue.GetTokenCount( ':' ) == 3 )
+ {
+ String aPrivateInd ( aReturnValue.GetToken( 0, ':' ) );
+ String aResourceName( aReturnValue.GetToken( 1, ':' ) );
+ sal_Int32 nResId ( aReturnValue.GetToken( 2, ':' ).ToInt32() );
+ if ( aReturnValue.GetToken( 0, ':' ).EqualsAscii( "private" ) &&
+ aResourceName.Len() && ( nResId > 0 ) && ( nResId < 0x10000 ) )
+ {
+ ByteString aMgrName( aResourceName, RTL_TEXTENCODING_UTF8 );
+ ResMgr* pResMgr = ResMgr::CreateResMgr( aMgrName.GetBuffer(),
+ Application::GetSettings().GetUILocale() );
+ if ( pResMgr )
+ {
+ ResId aResId( (sal_uInt16)nResId, *pResMgr );
+ aResId.SetRT( RSC_STRING );
+ if ( pResMgr->IsAvailable( aResId ) )
+ {
+ aReturnValue = String( aResId );
+ }
+ delete pResMgr;
+ }
+ }
+ }
+ }
+ return aReturnValue;
+}
+
+// ------------------------------------------------------------------------
+
+void SgaObject::SetTitle( const String& rTitle )
+{
+ aTitle = rTitle;
+}
+
+// ------------------------------------------------------------------------
+
+SvStream& operator<<( SvStream& rOut, const SgaObject& rObj )
+{
+ rObj.WriteData( rOut, String() );
+ return rOut;
+}
+
+// ------------------------------------------------------------------------
+
+SvStream& operator>>( SvStream& rIn, SgaObject& rObj )
+{
+ UINT16 nReadVersion;
+
+ rObj.ReadData( rIn, nReadVersion );
+ rObj.bIsValid = ( rIn.GetError() == ERRCODE_NONE );
+
+ return rIn;
+}
+
+// ----------------
+// - SgaObjectBmp -
+// ----------------
+
+SgaObjectBmp::SgaObjectBmp()
+{
+}
+
+// ------------------------------------------------------------------------
+
+SgaObjectBmp::SgaObjectBmp( const INetURLObject& rURL )
+{
+ Graphic aGraphic;
+ String aFilter;
+
+ if ( SGA_IMPORT_NONE != GalleryGraphicImport( rURL, aGraphic, aFilter ) )
+ Init( aGraphic, rURL );
+}
+
+// ------------------------------------------------------------------------
+
+SgaObjectBmp::SgaObjectBmp( const Graphic& rGraphic, const INetURLObject& rURL, const String& )
+{
+ if( FileExists( rURL ) )
+ Init( rGraphic, rURL );
+}
+
+// ------------------------------------------------------------------------
+
+void SgaObjectBmp::Init( const Graphic& rGraphic, const INetURLObject& rURL )
+{
+ aURL = rURL;
+ bIsValid = CreateThumb( rGraphic );
+}
+
+// ------------------------------------------------------------------------
+
+void SgaObjectBmp::WriteData( SvStream& rOut, const String& rDestDir ) const
+{
+ String aDummyStr;
+ char aDummy[ 10 ];
+
+ // Version setzen
+ SgaObject::WriteData( rOut, rDestDir );
+ rOut.Write( aDummy, 10 );
+ rOut << ByteString( aDummyStr, RTL_TEXTENCODING_UTF8 ) << ByteString( aTitle, RTL_TEXTENCODING_UTF8 );
+}
+
+// ------------------------------------------------------------------------
+
+void SgaObjectBmp::ReadData( SvStream& rIn, UINT16& rReadVersion )
+{
+ ByteString aTmpStr;
+
+ SgaObject::ReadData( rIn, rReadVersion );
+ rIn.SeekRel( 10 ); // 16, 16, 32, 16
+ rIn >> aTmpStr; // dummy
+
+ if( rReadVersion >= 5 )
+ {
+ rIn >> aTmpStr; aTitle = String( aTmpStr.GetBuffer(), RTL_TEXTENCODING_UTF8 );
+ }
+}
+
+// ------------------
+// - SgaObjectSound -
+// ------------------
+
+SgaObjectSound::SgaObjectSound() :
+ eSoundType( SOUND_STANDARD )
+{
+}
+
+// ------------------------------------------------------------------------
+
+SgaObjectSound::SgaObjectSound( const INetURLObject& rURL ) :
+ eSoundType( SOUND_STANDARD )
+{
+ if( FileExists( rURL ) )
+ {
+ aURL = rURL;
+ aThumbBmp = Bitmap( Size( 1, 1 ), 1 );
+ bIsValid = TRUE;
+ }
+ else
+ bIsValid = FALSE;
+}
+
+// ------------------------------------------------------------------------
+
+SgaObjectSound::~SgaObjectSound()
+{
+}
+
+// ------------------------------------------------------------------------
+
+Bitmap SgaObjectSound::GetThumbBmp() const
+{
+ USHORT nId;
+
+ switch( eSoundType )
+ {
+ case( SOUND_COMPUTER ): nId = RID_SVXBMP_GALLERY_SOUND_1; break;
+ case( SOUND_MISC ): nId = RID_SVXBMP_GALLERY_SOUND_2; break;
+ case( SOUND_MUSIC ): nId = RID_SVXBMP_GALLERY_SOUND_3; break;
+ case( SOUND_NATURE ): nId = RID_SVXBMP_GALLERY_SOUND_4; break;
+ case( SOUND_SPEECH ): nId = RID_SVXBMP_GALLERY_SOUND_5; break;
+ case( SOUND_TECHNIC ): nId = RID_SVXBMP_GALLERY_SOUND_6; break;
+ case( SOUND_ANIMAL ): nId = RID_SVXBMP_GALLERY_SOUND_7; break;
+
+ // standard
+ default:
+ nId = RID_SVXBMP_GALLERY_MEDIA;
+ break;
+ }
+
+ const BitmapEx aBmpEx( GAL_RESID( nId ) );
+ const Color aTransColor( COL_WHITE );
+
+ return aBmpEx.GetBitmap( &aTransColor );
+}
+
+// ------------------------------------------------------------------------
+
+void SgaObjectSound::WriteData( SvStream& rOut, const String& rDestDir ) const
+{
+ SgaObject::WriteData( rOut, rDestDir );
+ rOut << (UINT16) eSoundType << ByteString( aTitle, RTL_TEXTENCODING_UTF8 );
+}
+
+// ------------------------------------------------------------------------
+
+void SgaObjectSound::ReadData( SvStream& rIn, UINT16& rReadVersion )
+{
+ SgaObject::ReadData( rIn, rReadVersion );
+
+ if( rReadVersion >= 5 )
+ {
+ ByteString aTmpStr;
+ UINT16 nTmp16;
+
+ rIn >> nTmp16; eSoundType = (GalSoundType) nTmp16;
+
+ if( rReadVersion >= 6 )
+ {
+ rIn >> aTmpStr; aTitle = String( aTmpStr.GetBuffer(), RTL_TEXTENCODING_UTF8 );
+ }
+ }
+}
+
+// -----------------
+// - SgaObjectAnim -
+// -----------------
+
+SgaObjectAnim::SgaObjectAnim()
+{
+}
+
+// ------------------------------------------------------------------------
+
+SgaObjectAnim::SgaObjectAnim( const Graphic& rGraphic,
+ const INetURLObject& rURL,
+ const String& )
+{
+ aURL = rURL;
+ bIsValid = CreateThumb( rGraphic );
+}
+
+// -----------------
+// - SgaObjectINet -
+// -----------------
+
+SgaObjectINet::SgaObjectINet()
+{
+}
+
+// ------------------------------------------------------------------------
+
+SgaObjectINet::SgaObjectINet( const Graphic& rGraphic, const INetURLObject& rURL, const String& rFormatName ) :
+ SgaObjectAnim ( rGraphic, rURL, rFormatName )
+{
+}
+
+// -------------------
+// - SgaObjectSvDraw -
+// -------------------
+
+SgaObjectSvDraw::SgaObjectSvDraw()
+{
+}
+
+// ------------------------------------------------------------------------
+
+SgaObjectSvDraw::SgaObjectSvDraw( const FmFormModel& rModel, const INetURLObject& rURL )
+{
+ aURL = rURL;
+ bIsValid = CreateThumb( rModel );
+}
+
+// ------------------------------------------------------------------------
+
+SvxGalleryDrawModel::SvxGalleryDrawModel()
+: mpFormModel( 0 )
+{
+ const String sFactoryURL(RTL_CONSTASCII_USTRINGPARAM("sdraw"));
+
+ mxDoc = SfxObjectShell::CreateObjectByFactoryName( sFactoryURL );
+
+ if( mxDoc.Is() )
+ {
+ mxDoc->DoInitNew(0);
+
+ uno::Reference< lang::XUnoTunnel > xTunnel( mxDoc->GetModel(), uno::UNO_QUERY );
+ if( xTunnel.is() )
+ {
+ mpFormModel = dynamic_cast< FmFormModel* >(
+ reinterpret_cast<SdrModel*>(xTunnel->getSomething(SdrModel::getUnoTunnelImplementationId())));
+ if( mpFormModel )
+ {
+ mpFormModel->InsertPage( mpFormModel->AllocPage( false ) );
+ }
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+SvxGalleryDrawModel::~SvxGalleryDrawModel()
+{
+ if( mxDoc.Is() )
+ mxDoc->DoClose();
+}
+
+// ------------------------------------------------------------------------
+
+SgaObjectSvDraw::SgaObjectSvDraw( SvStream& rIStm, const INetURLObject& rURL )
+{
+ SvxGalleryDrawModel aModel;
+
+ if( aModel.GetModel() )
+ {
+ if( GallerySvDrawImport( rIStm, *aModel.GetModel() ) )
+ {
+ aURL = rURL;
+ bIsValid = CreateThumb( *aModel.GetModel() );
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+BOOL SgaObjectSvDraw::CreateThumb( const FmFormModel& rModel )
+{
+ Graphic aGraphic;
+ ImageMap aImageMap;
+ BOOL bRet = FALSE;
+
+ if ( CreateIMapGraphic( rModel, aGraphic, aImageMap ) )
+ bRet = SgaObject::CreateThumb( aGraphic );
+ else
+ {
+ VirtualDevice aVDev;
+
+ aVDev.SetOutputSizePixel( Size( S_THUMB*2, S_THUMB*2 ) );
+
+ bRet = DrawCentered( &aVDev, rModel );
+ if( bRet )
+ {
+ aThumbBmp = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
+
+ Size aMS( 2, 2 );
+ BmpFilterParam aParam( aMS );
+ aThumbBmp.Filter( BMP_FILTER_MOSAIC, &aParam );
+ aThumbBmp.Scale( Size( S_THUMB, S_THUMB ) );
+
+ aThumbBmp.Convert( BMP_CONVERSION_8BIT_COLORS );
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL SgaObjectSvDraw::DrawCentered( OutputDevice* pOut, const FmFormModel& rModel )
+{
+ const FmFormPage* pPage = static_cast< const FmFormPage* >( rModel.GetPage( 0 ) );
+ BOOL bRet = FALSE;
+
+ if( pOut && pPage )
+ {
+ const Rectangle aObjRect( pPage->GetAllObjBoundRect() );
+ const Size aOutSizePix( pOut->GetOutputSizePixel() );
+
+ if( aObjRect.GetWidth() && aObjRect.GetHeight() && aOutSizePix.Width() > 2 && aOutSizePix.Height() > 2 )
+ {
+ FmFormView aView( const_cast< FmFormModel* >( &rModel ), pOut );
+ MapMode aMap( rModel.GetScaleUnit() );
+ Rectangle aDrawRectPix( Point( 1, 1 ), Size( aOutSizePix.Width() - 2, aOutSizePix.Height() - 2 ) );
+ const double fFactor = (double) aObjRect.GetWidth() / aObjRect.GetHeight();
+ Fraction aFrac( FRound( fFactor < 1. ? aDrawRectPix.GetWidth() * fFactor : aDrawRectPix.GetWidth() ),
+ pOut->LogicToPixel( aObjRect.GetSize(), aMap ).Width() );
+
+ aMap.SetScaleX( aFrac );
+ aMap.SetScaleY( aFrac );
+
+ const Size aDrawSize( pOut->PixelToLogic( aDrawRectPix.GetSize(), aMap ) );
+ Point aOrigin( pOut->PixelToLogic( aDrawRectPix.TopLeft(), aMap ) );
+
+ aOrigin.X() += ( ( aDrawSize.Width() - aObjRect.GetWidth() ) >> 1 ) - aObjRect.Left();
+ aOrigin.Y() += ( ( aDrawSize.Height() - aObjRect.GetHeight() ) >> 1 ) - aObjRect.Top();
+ aMap.SetOrigin( aOrigin );
+
+ aView.SetPageVisible( FALSE );
+ aView.SetBordVisible( FALSE );
+ aView.SetGridVisible( FALSE );
+ aView.SetHlplVisible( FALSE );
+ aView.SetGlueVisible( FALSE );
+
+ pOut->Push();
+ pOut->SetMapMode( aMap );
+ aView.ShowSdrPage( const_cast< FmFormPage* >( pPage ));
+ aView.CompleteRedraw( pOut, Rectangle( pOut->PixelToLogic( Point() ), pOut->GetOutputSize() ) );
+ pOut->Pop();
+
+ bRet = TRUE;
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+void SgaObjectSvDraw::WriteData( SvStream& rOut, const String& rDestDir ) const
+{
+ SgaObject::WriteData( rOut, rDestDir );
+ rOut << ByteString( aTitle, RTL_TEXTENCODING_UTF8 );
+}
+
+// ------------------------------------------------------------------------
+
+void SgaObjectSvDraw::ReadData( SvStream& rIn, UINT16& rReadVersion )
+{
+ SgaObject::ReadData( rIn, rReadVersion );
+
+ if( rReadVersion >= 5 )
+ {
+ ByteString aTmpStr;
+ rIn >> aTmpStr; aTitle = String( aTmpStr.GetBuffer(), RTL_TEXTENCODING_UTF8 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx
new file mode 100644
index 000000000000..20189c135848
--- /dev/null
+++ b/svx/source/gallery2/galtheme.cxx
@@ -0,0 +1,1601 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define ENABLE_BYTESTRING_STREAM_OPERATORS
+
+#include <tools/urlobj.hxx>
+#include <tools/vcompat.hxx>
+#include <unotools/streamwrap.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/tempfile.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <ucbhelper/content.hxx>
+#include <sot/storage.hxx>
+#include <sot/formats.hxx>
+#include <sot/filelist.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <svl/itempool.hxx>
+#include <sfx2/docfile.hxx>
+#include <avmedia/mediawindow.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/fmpage.hxx>
+#include "codec.hxx"
+#include <svx/unomodel.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/fmview.hxx>
+#include "svx/galmisc.hxx"
+#include "galtheme.hxx"
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include "galobj.hxx"
+#include <svx/gallery1.hxx>
+#include "galtheme.hrc"
+#include <vcl/lstbox.hxx>
+#include "gallerydrawmodel.hxx"
+
+// --------------
+// - Namespaces -
+// --------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+// ------------
+// - SgaTheme -
+// ------------
+
+GalleryTheme::GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry ) :
+ pParent ( pGallery ),
+ pThm ( pThemeEntry ),
+ mnThemeLockCount ( 0 ),
+ mnBroadcasterLockCount( 0 ),
+ nDragPos ( 0 ),
+ bDragging ( FALSE )
+{
+ ImplCreateSvDrawStorage();
+
+ if( pThm->IsImported() )
+ aImportName = pThm->GetThemeName();
+}
+
+// ------------------------------------------------------------------------
+
+GalleryTheme::~GalleryTheme()
+{
+ ImplWrite();
+
+ for( GalleryObject* pEntry = aObjectList.First(); pEntry; pEntry = aObjectList.Next() )
+ {
+ Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< ULONG >( pEntry ) ) );
+ delete pEntry;
+ Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< ULONG >( pEntry ) ) );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTheme::ImplCreateSvDrawStorage()
+{
+ if( !pThm->IsImported() )
+ {
+ aSvDrawStorageRef = new SvStorage( FALSE, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE ), pThm->IsReadOnly() ? STREAM_READ : STREAM_STD_READWRITE );
+ // #i50423# ReadOnly may not been set though the file can't be written (because of security reasons)
+ if ( ( aSvDrawStorageRef->GetError() != ERRCODE_NONE ) && !pThm->IsReadOnly() )
+ aSvDrawStorageRef = new SvStorage( FALSE, GetSdvURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+ }
+ else
+ aSvDrawStorageRef.Clear();
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryTheme::ImplWriteSgaObject( const SgaObject& rObj, ULONG nPos, GalleryObject* pExistentEntry )
+{
+ SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( GetSdgURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE );
+ BOOL bRet = FALSE;
+
+ if( pOStm )
+ {
+ const sal_uInt32 nOffset = pOStm->Seek( STREAM_SEEK_TO_END );
+
+ rObj.WriteData( *pOStm, m_aDestDir );
+
+ if( !pOStm->GetError() )
+ {
+ GalleryObject* pEntry;
+
+ if( !pExistentEntry )
+ {
+ pEntry = new GalleryObject;
+ aObjectList.Insert( pEntry, nPos );
+ }
+ else
+ pEntry = pExistentEntry;
+
+ pEntry->aURL = rObj.GetURL();
+ pEntry->nOffset = nOffset;
+ pEntry->eObjKind = rObj.GetObjKind();
+ bRet = TRUE;
+ }
+
+ delete pOStm;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+SgaObject* GalleryTheme::ImplReadSgaObject( GalleryObject* pEntry )
+{
+ SgaObject* pSgaObj = NULL;
+
+ if( pEntry )
+ {
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( GetSdgURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+ if( pIStm )
+ {
+ sal_uInt32 nInventor;
+
+ // Ueberpruefen, ob das File ein gueltiges SGA-File ist
+ pIStm->Seek( pEntry->nOffset );
+ *pIStm >> nInventor;
+
+ if( nInventor == COMPAT_FORMAT( 'S', 'G', 'A', '3' ) )
+ {
+ pIStm->Seek( pEntry->nOffset );
+
+ switch( pEntry->eObjKind )
+ {
+ case( SGA_OBJ_BMP ): pSgaObj = new SgaObjectBmp(); break;
+ case( SGA_OBJ_ANIM ): pSgaObj = new SgaObjectAnim(); break;
+ case( SGA_OBJ_INET ): pSgaObj = new SgaObjectINet(); break;
+ case( SGA_OBJ_SVDRAW ): pSgaObj = new SgaObjectSvDraw(); break;
+ case( SGA_OBJ_SOUND ): pSgaObj = new SgaObjectSound(); break;
+
+ default:
+ break;
+ }
+
+ if( pSgaObj )
+ {
+ *pIStm >> *pSgaObj;
+ pSgaObj->ImplUpdateURL( pEntry->aURL );
+ }
+ }
+
+ delete pIStm;
+ }
+ }
+
+ return pSgaObj;
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTheme::ImplRead()
+{
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( GetThmURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+ if( pIStm )
+ {
+ *pIStm >> *this;
+ delete pIStm;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTheme::ImplWrite()
+{
+ if( IsModified() )
+ {
+ INetURLObject aPathURL( GetThmURL() );
+
+ aPathURL.removeSegment();
+ aPathURL.removeFinalSlash();
+
+ DBG_ASSERT( aPathURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+
+ if( FileExists( aPathURL ) || CreateDir( aPathURL ) )
+ {
+#ifdef UNX
+ SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( GetThmURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_COPY_ON_SYMLINK | STREAM_TRUNC );
+#else
+ SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( GetThmURL().GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
+#endif
+
+ if( pOStm )
+ {
+ *pOStm << *this;
+ delete pOStm;
+ }
+
+ ImplSetModified( FALSE );
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+const GalleryObject* GalleryTheme::ImplGetGalleryObject( const INetURLObject& rURL )
+{
+ GalleryObject* pEntry = aObjectList.First();
+ GalleryObject* pFoundEntry = NULL;
+
+ for( ; pEntry && !pFoundEntry; pEntry = aObjectList.Next() )
+ if( pEntry->aURL == rURL )
+ pFoundEntry = pEntry;
+
+ return pFoundEntry;
+}
+
+// ------------------------------------------------------------------------
+
+INetURLObject GalleryTheme::ImplGetURL( const GalleryObject* pObject ) const
+{
+ INetURLObject aURL;
+
+ if( pObject )
+ {
+ if( IsImported() )
+ {
+ INetURLObject aPathURL( GetParent()->GetImportURL( GetName() ) );
+
+ aPathURL.removeSegment();
+ aPathURL.removeFinalSlash();
+ aPathURL.Append( pObject->aURL.GetName() );
+ aURL = aPathURL;
+ }
+ else
+ aURL = pObject->aURL;
+ }
+
+ return aURL;
+}
+
+// ------------------------------------------------------------------------
+
+INetURLObject GalleryTheme::ImplCreateUniqueURL( SgaObjKind eObjKind, ULONG nFormat )
+{
+ INetURLObject aDir( GetParent()->GetUserURL() );
+ INetURLObject aInfoFileURL( GetParent()->GetUserURL() );
+ INetURLObject aNewURL;
+ sal_uInt32 nNextNumber = 1999;
+ sal_Char const* pExt = NULL;
+ BOOL bExists;
+
+ aDir.Append( String( RTL_CONSTASCII_USTRINGPARAM( "dragdrop" ) ) );
+ CreateDir( aDir );
+
+ aInfoFileURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( "sdddndx1" ) ) );
+
+ // read next possible number
+ if( FileExists( aInfoFileURL ) )
+ {
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aInfoFileURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+ if( pIStm )
+ {
+ *pIStm >> nNextNumber;
+ delete pIStm;
+ }
+ }
+
+ // create extension
+ if( nFormat )
+ {
+ switch( nFormat )
+ {
+ case( CVT_BMP ): pExt = ".bmp"; break;
+ case( CVT_GIF ): pExt = ".gif"; break;
+ case( CVT_JPG ): pExt = ".jpg"; break;
+ case( CVT_MET ): pExt = ".met"; break;
+ case( CVT_PCT ): pExt = ".pct"; break;
+ case( CVT_PNG ): pExt = ".png"; break;
+ case( CVT_SVM ): pExt = ".svm"; break;
+ case( CVT_TIF ): pExt = ".tif"; break;
+ case( CVT_WMF ): pExt = ".wmf"; break;
+ case( CVT_EMF ): pExt = ".emf"; break;
+
+ default:
+ pExt = ".grf";
+ break;
+ }
+ }
+
+ do
+ {
+ // get URL
+ if( SGA_OBJ_SVDRAW == eObjKind )
+ {
+ String aFileName( RTL_CONSTASCII_USTRINGPARAM( "gallery/svdraw/dd" ) );
+ aNewURL = INetURLObject( aFileName += String::CreateFromInt32( ++nNextNumber % 99999999 ), INET_PROT_PRIV_SOFFICE );
+
+ bExists = FALSE;
+
+ for( GalleryObject* pEntry = aObjectList.First(); pEntry && !bExists; pEntry = aObjectList.Next() )
+ if( pEntry->aURL == aNewURL )
+ bExists = TRUE;
+ }
+ else
+ {
+ String aFileName( RTL_CONSTASCII_USTRINGPARAM( "dd" ) );
+
+ aFileName += String::CreateFromInt32( ++nNextNumber % 999999 );
+ aFileName += String( pExt, RTL_TEXTENCODING_ASCII_US );
+
+ aNewURL = aDir;
+ aNewURL.Append( aFileName );
+
+ bExists = FileExists( aNewURL );
+ }
+ }
+ while( bExists );
+
+ // write updated number
+ SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aInfoFileURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE );
+
+ if( pOStm )
+ {
+ *pOStm << nNextNumber;
+ delete pOStm;
+ }
+
+ return aNewURL;
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTheme::ImplBroadcast( ULONG nUpdatePos )
+{
+ if( !IsBroadcasterLocked() )
+ {
+ if( GetObjectCount() && ( nUpdatePos >= GetObjectCount() ) )
+ nUpdatePos = GetObjectCount() - 1;
+
+ Broadcast( GalleryHint( GALLERY_HINT_THEME_UPDATEVIEW, GetName(), nUpdatePos ) );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryTheme::UnlockTheme()
+{
+ DBG_ASSERT( mnThemeLockCount, "Theme is not locked" );
+
+ BOOL bRet = FALSE;
+
+ if( mnThemeLockCount )
+ {
+ --mnThemeLockCount;
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTheme::UnlockBroadcaster( ULONG nUpdatePos )
+{
+ DBG_ASSERT( mnBroadcasterLockCount, "Broadcaster is not locked" );
+
+ if( mnBroadcasterLockCount && !--mnBroadcasterLockCount )
+ ImplBroadcast( nUpdatePos );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryTheme::InsertObject( const SgaObject& rObj, ULONG nInsertPos )
+{
+ BOOL bRet = FALSE;
+
+ if( rObj.IsValid() )
+ {
+ GalleryObject* pEntry = aObjectList.First();
+ GalleryObject* pFoundEntry = NULL;
+
+ for( ; pEntry && !pFoundEntry; pEntry = aObjectList.Next() )
+ if( pEntry->aURL == rObj.GetURL() )
+ pFoundEntry = pEntry;
+
+ if( pFoundEntry )
+ {
+ GalleryObject aNewEntry;
+
+ // update title of new object if neccessary
+ if( !rObj.GetTitle().Len() )
+ {
+ SgaObject* pOldObj = ImplReadSgaObject( pFoundEntry );
+
+ if( pOldObj )
+ {
+ ( (SgaObject&) rObj ).SetTitle( pOldObj->GetTitle() );
+ delete pOldObj;
+ }
+ }
+ else if( rObj.GetTitle() == String( RTL_CONSTASCII_USTRINGPARAM( "__<empty>__" ) ) )
+ ( (SgaObject&) rObj ).SetTitle( String() );
+
+ ImplWriteSgaObject( rObj, nInsertPos, &aNewEntry );
+ pFoundEntry->nOffset = aNewEntry.nOffset;
+ }
+ else
+ ImplWriteSgaObject( rObj, nInsertPos, NULL );
+
+ ImplSetModified( bRet = TRUE );
+ ImplBroadcast( pFoundEntry ? aObjectList.GetPos( pFoundEntry ) : nInsertPos );
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+SgaObject* GalleryTheme::AcquireObject( ULONG nPos )
+{
+ return ImplReadSgaObject( aObjectList.GetObject( nPos ) );
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTheme::ReleaseObject( SgaObject* pObject )
+{
+ delete pObject;
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryTheme::RemoveObject( ULONG nPos )
+{
+ GalleryObject* pEntry = aObjectList.Remove( nPos );
+
+ if( !aObjectList.Count() )
+ KillFile( GetSdgURL() );
+
+ if( pEntry )
+ {
+ if( SGA_OBJ_SVDRAW == pEntry->eObjKind )
+ aSvDrawStorageRef->Remove( pEntry->aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< ULONG >( pEntry ) ) );
+ delete pEntry;
+ Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< ULONG >( pEntry ) ) );
+
+ ImplSetModified( TRUE );
+ ImplBroadcast( nPos );
+ }
+
+ return( pEntry != NULL );
+}
+
+// ------------------------------------------------------------------------
+
+BOOL GalleryTheme::ChangeObjectPos( ULONG nOldPos, ULONG nNewPos )
+{
+ BOOL bRet = FALSE;
+
+ if( nOldPos != nNewPos )
+ {
+ GalleryObject* pEntry = aObjectList.GetObject( nOldPos );
+
+ if( pEntry )
+ {
+ aObjectList.Insert( pEntry, nNewPos );
+
+ if( nNewPos < nOldPos )
+ nOldPos++;
+
+ aObjectList.Remove( nOldPos );
+ ImplSetModified( bRet = TRUE );
+ ImplBroadcast( ( nNewPos < nOldPos ) ? nNewPos : ( nNewPos - 1 ) );
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+void GalleryTheme::Actualize( const Link& rActualizeLink, GalleryProgress* pProgress )
+{
+ if( !IsReadOnly() && !IsImported() )
+ {
+ Graphic aGraphic;
+ String aFormat;
+ GalleryObject* pEntry;
+ const ULONG nCount = aObjectList.Count();
+ ULONG i;
+
+ LockBroadcaster();
+ bAbortActualize = FALSE;
+
+ // LoeschFlag zuruecksetzen
+ for ( i = 0; i < nCount; i++ )
+ aObjectList.GetObject( i )->bDummy = FALSE;
+
+ for( i = 0; ( i < nCount ) && !bAbortActualize; i++ )
+ {
+ if( pProgress )
+ pProgress->Update( i, nCount - 1 );
+
+ pEntry = aObjectList.GetObject( i );
+
+ const INetURLObject aURL( pEntry->aURL );
+
+ rActualizeLink.Call( (void*) &aURL );
+
+ // SvDraw-Objekte werden spaeter aktualisiert
+ if( pEntry->eObjKind != SGA_OBJ_SVDRAW )
+ {
+ // Hier muss noch etwas eingebaut werden,
+ // das Files auf den ensprechenden Eintrag matched
+ // Grafiken als Grafik-Objekte in die Gallery aufnehmen
+ if( pEntry->eObjKind == SGA_OBJ_SOUND )
+ {
+ SgaObjectSound aObjSound( aURL );
+ if( !InsertObject( aObjSound ) )
+ pEntry->bDummy = TRUE;
+ }
+ else
+ {
+ aGraphic.Clear();
+
+ if ( GalleryGraphicImport( aURL, aGraphic, aFormat ) )
+ {
+ SgaObject* pNewObj;
+
+ if ( SGA_OBJ_INET == pEntry->eObjKind )
+ pNewObj = (SgaObject*) new SgaObjectINet( aGraphic, aURL, aFormat );
+ else if ( aGraphic.IsAnimated() )
+ pNewObj = (SgaObject*) new SgaObjectAnim( aGraphic, aURL, aFormat );
+ else
+ pNewObj = (SgaObject*) new SgaObjectBmp( aGraphic, aURL, aFormat );
+
+ if( !InsertObject( *pNewObj ) )
+ pEntry->bDummy = TRUE;
+
+ delete pNewObj;
+ }
+ else
+ pEntry->bDummy = TRUE; // Loesch-Flag setzen
+ }
+ }
+ else
+ {
+ if ( aSvDrawStorageRef.Is() )
+ {
+ const String aStmName( GetSvDrawStreamNameFromURL( pEntry->aURL ) );
+ SvStorageStreamRef pIStm = aSvDrawStorageRef->OpenSotStream( aStmName, STREAM_READ );
+
+ if( pIStm && !pIStm->GetError() )
+ {
+ pIStm->SetBufferSize( 16384 );
+
+ SgaObjectSvDraw aNewObj( *pIStm, pEntry->aURL );
+
+ if( !InsertObject( aNewObj ) )
+ pEntry->bDummy = TRUE;
+
+ pIStm->SetBufferSize( 0L );
+ }
+ }
+ }
+ }
+
+ // remove all entries with set flag
+ pEntry = aObjectList.First();
+ while( pEntry )
+ {
+ if( pEntry->bDummy )
+ {
+ Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< ULONG >( pEntry ) ) );
+ delete aObjectList.Remove( pEntry );
+ Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< ULONG >( pEntry ) ) );
+
+ pEntry = aObjectList.GetCurObject();
+ }
+ else
+ pEntry = aObjectList.Next();
+ }
+
+ // update theme
+ ::utl::TempFile aTmp;
+ INetURLObject aInURL( GetSdgURL() );
+ INetURLObject aTmpURL( aTmp.GetURL() );
+
+ DBG_ASSERT( aInURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+ DBG_ASSERT( aTmpURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aInURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+ SvStream* pTmpStm = ::utl::UcbStreamHelper::CreateStream( aTmpURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
+
+ if( pIStm && pTmpStm )
+ {
+ pEntry = aObjectList.First();
+
+ while( pEntry )
+ {
+ SgaObject* pObj;
+
+ switch( pEntry->eObjKind )
+ {
+ case( SGA_OBJ_BMP ): pObj = new SgaObjectBmp(); break;
+ case( SGA_OBJ_ANIM ): pObj = new SgaObjectAnim(); break;
+ case( SGA_OBJ_INET ): pObj = new SgaObjectINet(); break;
+ case( SGA_OBJ_SVDRAW ): pObj = new SgaObjectSvDraw(); break;
+ case (SGA_OBJ_SOUND): pObj = new SgaObjectSound(); break;
+
+ default:
+ pObj = NULL;
+ break;
+ }
+
+ if( pObj )
+ {
+ pIStm->Seek( pEntry->nOffset );
+ *pIStm >> *pObj;
+ pEntry->nOffset = pTmpStm->Tell();
+ *pTmpStm << *pObj;
+ delete pObj;
+ }
+
+ pEntry = aObjectList.Next();
+ }
+ }
+ else
+ {
+ DBG_ERROR( "File(s) could not be opened" );
+ }
+
+ delete pIStm;
+ delete pTmpStm;
+
+ CopyFile( aTmpURL, aInURL );
+ KillFile( aTmpURL );
+
+ ULONG nStorErr = 0;
+
+ {
+ SvStorageRef aTempStorageRef( new SvStorage( FALSE, aTmpURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_STD_READWRITE ) );
+ aSvDrawStorageRef->CopyTo( aTempStorageRef );
+ nStorErr = aSvDrawStorageRef->GetError();
+ }
+
+ if( !nStorErr )
+ {
+ aSvDrawStorageRef.Clear();
+ CopyFile( aTmpURL, GetSdvURL() );
+ ImplCreateSvDrawStorage();
+ }
+
+ KillFile( aTmpURL );
+ ImplSetModified( TRUE );
+ ImplWrite();
+ UnlockBroadcaster();
+ }
+}
+
+// ------------------------------------------------------------------------
+
+GalleryThemeEntry* GalleryTheme::CreateThemeEntry( const INetURLObject& rURL, BOOL bReadOnly )
+{
+ DBG_ASSERT( rURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+
+ GalleryThemeEntry* pRet = NULL;
+
+ if( FileExists( rURL ) )
+ {
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( rURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+ if( pIStm )
+ {
+ String aThemeName;
+ sal_uInt32 nThemeId = 0;
+ sal_uInt16 nVersion;
+ BOOL bThemeNameFromResource = FALSE;
+
+ *pIStm >> nVersion;
+
+ if( nVersion <= 0x00ff )
+ {
+ ByteString aTmpStr;
+
+ *pIStm >> aTmpStr; aThemeName = String( aTmpStr.GetBuffer(), RTL_TEXTENCODING_UTF8 );
+
+ // Charakterkonvertierung durchfuehren
+ if( nVersion >= 0x0004 )
+ {
+ sal_uInt32 nCount;
+ sal_uInt16 nTemp16;
+
+ *pIStm >> nCount >> nTemp16;
+ pIStm->Seek( STREAM_SEEK_TO_END );
+
+ // pruefen, ob es sich um eine neuere Version handelt;
+ // daher um 520Bytes (8Bytes Kennung + 512Bytes Reserverpuffer ) zurueckspringen,
+ // falls dies ueberhaupt moeglich ist
+ if( pIStm->Tell() >= 520 )
+ {
+ sal_uInt32 nId1, nId2;
+
+ pIStm->SeekRel( -520 );
+ *pIStm >> nId1 >> nId2;
+
+ if( nId1 == COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) &&
+ nId2 == COMPAT_FORMAT( 'E', 'S', 'R', 'V' ) )
+ {
+ VersionCompat* pCompat = new VersionCompat( *pIStm, STREAM_READ );
+
+ *pIStm >> nThemeId;
+
+ if( pCompat->GetVersion() >= 2 )
+ {
+ *pIStm >> bThemeNameFromResource;
+ }
+
+ delete pCompat;
+ }
+ }
+ }
+
+ INetURLObject aPathURL( rURL );
+
+ aPathURL.removeSegment();
+ aPathURL.removeFinalSlash();
+ pRet = new GalleryThemeEntry( aPathURL, aThemeName,
+ String(rURL.GetBase()).Copy( 2, 6 ).ToInt32(),
+ bReadOnly, FALSE, FALSE, nThemeId,
+ bThemeNameFromResource );
+ }
+
+ delete pIStm;
+ }
+ }
+
+ return pRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::GetThumb( ULONG nPos, Bitmap& rBmp, BOOL )
+{
+ SgaObject* pObj = AcquireObject( nPos );
+ BOOL bRet = FALSE;
+
+ if( pObj )
+ {
+ rBmp = pObj->GetThumbBmp();
+ ReleaseObject( pObj );
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::GetGraphic( ULONG nPos, Graphic& rGraphic, BOOL bProgress )
+{
+ const GalleryObject* pObject = ImplGetGalleryObject( nPos );
+ BOOL bRet = FALSE;
+
+ if( pObject )
+ {
+ const INetURLObject aURL( ImplGetURL( pObject ) );
+
+ switch( pObject->eObjKind )
+ {
+ case( SGA_OBJ_BMP ):
+ case( SGA_OBJ_ANIM ):
+ case( SGA_OBJ_INET ):
+ {
+ String aFilterDummy;
+ bRet = ( GalleryGraphicImport( aURL, rGraphic, aFilterDummy, bProgress ) != SGA_IMPORT_NONE );
+ }
+ break;
+
+ case( SGA_OBJ_SVDRAW ):
+ {
+ SvxGalleryDrawModel aModel;
+
+ if( aModel.GetModel() )
+ {
+ if( GetModel( nPos, *aModel.GetModel(), bProgress ) )
+ {
+ ImageMap aIMap;
+
+ if( CreateIMapGraphic( *aModel.GetModel(), rGraphic, aIMap ) )
+ bRet = TRUE;
+ else
+ {
+ VirtualDevice aVDev;
+ aVDev.SetMapMode( MapMode( MAP_100TH_MM ) );
+ FmFormView aView( aModel.GetModel(), &aVDev );
+
+ aView.hideMarkHandles();
+ aView.ShowSdrPage(aView.GetModel()->GetPage(0));
+ aView.MarkAll();
+ rGraphic = aView.GetAllMarkedGraphic();
+ bRet = TRUE;
+ }
+ }
+ }
+ }
+ break;
+
+ case( SGA_OBJ_SOUND ):
+ {
+ SgaObject* pObj = AcquireObject( nPos );
+
+ if( pObj )
+ {
+ Bitmap aBmp( pObj->GetThumbBmp() );
+ aBmp.Replace( COL_LIGHTMAGENTA, COL_WHITE );
+ rGraphic = aBmp;
+ ReleaseObject( pObj );
+ bRet = TRUE;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::InsertGraphic( const Graphic& rGraphic, ULONG nInsertPos )
+{
+ BOOL bRet = FALSE;
+
+ if( rGraphic.GetType() != GRAPHIC_NONE )
+ {
+ ULONG nExportFormat = CVT_UNKNOWN;
+ const GfxLink aGfxLink( ( (Graphic&) rGraphic ).GetLink() );
+
+ if( aGfxLink.GetDataSize() )
+ {
+ switch( aGfxLink.GetType() )
+ {
+ case( GFX_LINK_TYPE_EPS_BUFFER ): nExportFormat = CVT_SVM; break;
+ case( GFX_LINK_TYPE_NATIVE_GIF ): nExportFormat = CVT_GIF; break;
+ case( GFX_LINK_TYPE_NATIVE_JPG ): nExportFormat = CVT_JPG; break;
+ case( GFX_LINK_TYPE_NATIVE_PNG ): nExportFormat = CVT_PNG; break;
+ case( GFX_LINK_TYPE_NATIVE_TIF ): nExportFormat = CVT_TIF; break;
+ case( GFX_LINK_TYPE_NATIVE_WMF ): nExportFormat = CVT_WMF; break;
+ case( GFX_LINK_TYPE_NATIVE_MET ): nExportFormat = CVT_MET; break;
+ case( GFX_LINK_TYPE_NATIVE_PCT ): nExportFormat = CVT_PCT; break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ if( rGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+ if( rGraphic.IsAnimated() )
+ nExportFormat = CVT_GIF;
+ else
+ nExportFormat = CVT_PNG;
+ }
+ else
+ nExportFormat = CVT_SVM;
+ }
+
+ const INetURLObject aURL( ImplCreateUniqueURL( SGA_OBJ_BMP, nExportFormat ) );
+ SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_TRUNC );
+
+ if( pOStm )
+ {
+ pOStm->SetVersion( SOFFICE_FILEFORMAT_50 );
+
+ if( CVT_SVM == nExportFormat )
+ {
+ GDIMetaFile aMtf( rGraphic.GetGDIMetaFile() );
+
+ aMtf.Write( *pOStm );
+ bRet = ( pOStm->GetError() == ERRCODE_NONE );
+ }
+ else
+ {
+ if( aGfxLink.GetDataSize() && aGfxLink.GetData() )
+ {
+ pOStm->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() );
+ bRet = ( pOStm->GetError() == ERRCODE_NONE );
+ }
+ else
+ bRet = ( GraphicConverter::Export( *pOStm, rGraphic, nExportFormat ) == ERRCODE_NONE );
+ }
+
+ delete pOStm;
+ }
+
+ if( bRet )
+ {
+ const SgaObjectBmp aObjBmp( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+ InsertObject( aObjBmp, nInsertPos );
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::GetModel( ULONG nPos, SdrModel& rModel, BOOL )
+{
+ const GalleryObject* pObject = ImplGetGalleryObject( nPos );
+ BOOL bRet = FALSE;
+
+ if( pObject && ( SGA_OBJ_SVDRAW == pObject->eObjKind ) )
+ {
+ const INetURLObject aURL( ImplGetURL( pObject ) );
+ SvStorageRef xStor( GetSvDrawStorage() );
+
+ if( xStor.Is() )
+ {
+ const String aStmName( GetSvDrawStreamNameFromURL( aURL ) );
+ SvStorageStreamRef xIStm( xStor->OpenSotStream( aStmName, STREAM_READ ) );
+
+ if( xIStm.Is() && !xIStm->GetError() )
+ {
+ xIStm->SetBufferSize( STREAMBUF_SIZE );
+ bRet = GallerySvDrawImport( *xIStm, rModel );
+ xIStm->SetBufferSize( 0L );
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::InsertModel( const FmFormModel& rModel, ULONG nInsertPos )
+{
+ INetURLObject aURL( ImplCreateUniqueURL( SGA_OBJ_SVDRAW ) );
+ SvStorageRef xStor( GetSvDrawStorage() );
+ BOOL bRet = FALSE;
+
+ if( xStor.Is() )
+ {
+ const String aStmName( GetSvDrawStreamNameFromURL( aURL ) );
+ SvStorageStreamRef xOStm( xStor->OpenSotStream( aStmName, STREAM_WRITE | STREAM_TRUNC ) );
+
+ if( xOStm.Is() && !xOStm->GetError() )
+ {
+ SvMemoryStream aMemStm( 65535, 65535 );
+ FmFormModel* pFormModel = (FmFormModel*) &rModel;
+
+ pFormModel->BurnInStyleSheetAttributes();
+
+ {
+ uno::Reference< io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( aMemStm ) );
+
+ if( xDocOut.is() )
+ SvxDrawingLayerExport( pFormModel, xDocOut );
+ }
+
+ aMemStm.Seek( 0 );
+
+ xOStm->SetBufferSize( 16348 );
+ GalleryCodec aCodec( *xOStm );
+ aCodec.Write( aMemStm );
+
+ if( !xOStm->GetError() )
+ {
+ SgaObjectSvDraw aObjSvDraw( rModel, aURL );
+ bRet = InsertObject( aObjSvDraw, nInsertPos );
+ }
+
+ xOStm->SetBufferSize( 0L );
+ xOStm->Commit();
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::GetModelStream( ULONG nPos, SotStorageStreamRef& rxModelStream, BOOL )
+{
+ const GalleryObject* pObject = ImplGetGalleryObject( nPos );
+ BOOL bRet = FALSE;
+
+ if( pObject && ( SGA_OBJ_SVDRAW == pObject->eObjKind ) )
+ {
+ const INetURLObject aURL( ImplGetURL( pObject ) );
+ SvStorageRef xStor( GetSvDrawStorage() );
+
+ if( xStor.Is() )
+ {
+ const String aStmName( GetSvDrawStreamNameFromURL( aURL ) );
+ SvStorageStreamRef xIStm( xStor->OpenSotStream( aStmName, STREAM_READ ) );
+
+ if( xIStm.Is() && !xIStm->GetError() )
+ {
+ UINT32 nVersion = 0;
+
+ xIStm->SetBufferSize( 16348 );
+
+ if( GalleryCodec::IsCoded( *xIStm, nVersion ) )
+ {
+ SvxGalleryDrawModel aModel;
+
+ if( aModel.GetModel() )
+ {
+ if( GallerySvDrawImport( *xIStm, *aModel.GetModel() ) )
+ {
+ aModel.GetModel()->BurnInStyleSheetAttributes();
+
+ {
+ uno::Reference< io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( *rxModelStream ) );
+
+ if( SvxDrawingLayerExport( aModel.GetModel(), xDocOut ) )
+ rxModelStream->Commit();
+ }
+ }
+
+ bRet = ( rxModelStream->GetError() == ERRCODE_NONE );
+ }
+ }
+
+ xIStm->SetBufferSize( 0 );
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::InsertModelStream( const SotStorageStreamRef& rxModelStream, ULONG nInsertPos )
+{
+ INetURLObject aURL( ImplCreateUniqueURL( SGA_OBJ_SVDRAW ) );
+ SvStorageRef xStor( GetSvDrawStorage() );
+ BOOL bRet = FALSE;
+
+ if( xStor.Is() )
+ {
+ const String aStmName( GetSvDrawStreamNameFromURL( aURL ) );
+ SvStorageStreamRef xOStm( xStor->OpenSotStream( aStmName, STREAM_WRITE | STREAM_TRUNC ) );
+
+ if( xOStm.Is() && !xOStm->GetError() )
+ {
+ GalleryCodec aCodec( *xOStm );
+ SvMemoryStream aMemStm( 65535, 65535 );
+
+ xOStm->SetBufferSize( 16348 );
+ aCodec.Write( *rxModelStream );
+
+ if( !xOStm->GetError() )
+ {
+ xOStm->Seek( 0 );
+ SgaObjectSvDraw aObjSvDraw( *xOStm, aURL );
+ bRet = InsertObject( aObjSvDraw, nInsertPos );
+ }
+
+ xOStm->SetBufferSize( 0L );
+ xOStm->Commit();
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::GetURL( ULONG nPos, INetURLObject& rURL, BOOL )
+{
+ const GalleryObject* pObject = ImplGetGalleryObject( nPos );
+ BOOL bRet = FALSE;
+
+ if( pObject )
+ {
+ rURL = INetURLObject( ImplGetURL( pObject ) );
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::InsertURL( const INetURLObject& rURL, ULONG nInsertPos )
+{
+ Graphic aGraphic;
+ String aFormat;
+ SgaObject* pNewObj = NULL;
+ const USHORT nImportRet = GalleryGraphicImport( rURL, aGraphic, aFormat );
+ BOOL bRet = FALSE;
+
+ if( nImportRet != SGA_IMPORT_NONE )
+ {
+ if ( SGA_IMPORT_INET == nImportRet )
+ pNewObj = (SgaObject*) new SgaObjectINet( aGraphic, rURL, aFormat );
+ else if ( aGraphic.IsAnimated() )
+ pNewObj = (SgaObject*) new SgaObjectAnim( aGraphic, rURL, aFormat );
+ else
+ pNewObj = (SgaObject*) new SgaObjectBmp( aGraphic, rURL, aFormat );
+ }
+ else if( ::avmedia::MediaWindow::isMediaURL( rURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) )
+ pNewObj = (SgaObject*) new SgaObjectSound( rURL );
+
+ if( pNewObj && InsertObject( *pNewObj, nInsertPos ) )
+ bRet = TRUE;
+
+ delete pNewObj;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, ULONG nInsertPos )
+{
+ INetURLObject aURL;
+ ::std::vector< INetURLObject > aURLVector;
+ BOOL bRet = FALSE;
+
+ try
+ {
+ ::ucbhelper::Content aCnt( rFileOrDirURL.GetMainURL( INetURLObject::NO_DECODE ), uno::Reference< ucb::XCommandEnvironment >() );
+ sal_Bool bFolder = false;
+
+ aCnt.getPropertyValue( OUString::createFromAscii( "IsFolder" ) ) >>= bFolder;
+
+ if( bFolder )
+ {
+ uno::Sequence< OUString > aProps( 1 );
+ aProps.getArray()[ 0 ] = OUString::createFromAscii( "Url" );
+ uno::Reference< sdbc::XResultSet > xResultSet( aCnt.createCursor( aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ) );
+
+ if( xResultSet.is() )
+ {
+ uno::Reference< ucb::XContentAccess > xContentAccess( xResultSet, uno::UNO_QUERY );
+
+ if( xContentAccess.is() )
+ {
+ while( xResultSet->next() )
+ {
+ aURL.SetSmartURL( xContentAccess->queryContentIdentifierString() );
+ aURLVector.push_back( aURL );
+ }
+ }
+ }
+ }
+ else
+ aURLVector.push_back( rFileOrDirURL );
+ }
+ catch( const ucb::ContentCreationException& )
+ {
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ ::std::vector< INetURLObject >::const_iterator aIter( aURLVector.begin() ), aEnd( aURLVector.end() );
+
+ while( aIter != aEnd )
+ bRet = bRet || InsertURL( *aIter++, nInsertPos );
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL GalleryTheme::InsertTransferable( const uno::Reference< datatransfer::XTransferable >& rxTransferable, ULONG nInsertPos )
+{
+ BOOL bRet = FALSE;
+
+ if( rxTransferable.is() )
+ {
+ TransferableDataHelper aDataHelper( rxTransferable );
+ Graphic* pGraphic = NULL;
+
+ if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) )
+ {
+ SotStorageStreamRef xModelStm;
+
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xModelStm ) )
+ bRet = InsertModelStream( xModelStm, nInsertPos );
+ }
+ else if( aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) ||
+ aDataHelper.HasFormat( FORMAT_FILE ) )
+ {
+ FileList aFileList;
+
+ if( aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) )
+ aDataHelper.GetFileList( SOT_FORMAT_FILE_LIST, aFileList );
+ else
+ {
+ String aFile;
+
+ aDataHelper.GetString( FORMAT_FILE, aFile );
+
+ if( aFile.Len() )
+ aFileList.AppendFile( aFile );
+ }
+
+ for( sal_uInt32 i = 0, nCount = aFileList.Count(); i < nCount; ++i )
+ {
+ const String aFile( aFileList.GetFile( i ) );
+ INetURLObject aURL( aFile );
+
+ if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
+ {
+ String aLocalURL;
+
+ if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFile, aLocalURL ) )
+ aURL = INetURLObject( aLocalURL );
+ }
+
+ if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ bRet = InsertFileOrDirURL( aURL, nInsertPos );
+ }
+ }
+ else
+ {
+ Graphic aGraphic;
+ ULONG nFormat = 0;
+
+ if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) )
+ nFormat = SOT_FORMATSTR_ID_SVXB;
+ else if( aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) )
+ nFormat = FORMAT_GDIMETAFILE;
+ else if( aDataHelper.HasFormat( FORMAT_BITMAP ) )
+ nFormat = FORMAT_BITMAP;
+
+ if( nFormat && aDataHelper.GetGraphic( nFormat, aGraphic ) )
+ pGraphic = new Graphic( aGraphic );
+ }
+
+ if( pGraphic )
+ {
+ bRet = FALSE;
+
+ if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVIM ) )
+ {
+
+ ImageMap aImageMap;
+
+ // according to KA we don't need a BaseURL here
+ if( aDataHelper.GetImageMap( SOT_FORMATSTR_ID_SVIM, aImageMap ) )
+ {
+ SvxGalleryDrawModel aModel;
+
+ if( aModel.GetModel() )
+ {
+ SgaUserDataFactory aFactory;
+
+ SdrPage* pPage = aModel.GetModel()->GetPage(0);
+ SdrGrafObj* pGrafObj = new SdrGrafObj( *pGraphic );
+
+ pGrafObj->InsertUserData( new SgaIMapInfo( aImageMap ) );
+ pPage->InsertObject( pGrafObj );
+ bRet = InsertModel( *aModel.GetModel(), nInsertPos );
+ }
+ }
+ }
+
+ if( !bRet )
+ bRet = InsertGraphic( *pGraphic, nInsertPos );
+
+ delete pGraphic;
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryTheme::CopyToClipboard( Window* pWindow, ULONG nPos )
+{
+ GalleryTransferable* pTransferable = new GalleryTransferable( this, nPos, false );
+ pTransferable->CopyToClipboard( pWindow );
+}
+
+// -----------------------------------------------------------------------------
+
+void GalleryTheme::StartDrag( Window* pWindow, ULONG nPos )
+{
+ GalleryTransferable* pTransferable = new GalleryTransferable( this, nPos, true );
+ pTransferable->StartDrag( pWindow, DND_ACTION_COPY | DND_ACTION_LINK );
+}
+
+// -----------------------------------------------------------------------------
+
+SvStream& GalleryTheme::WriteData( SvStream& rOStm ) const
+{
+ const INetURLObject aRelURL1( GetParent()->GetRelativeURL() );
+ const INetURLObject aRelURL2( GetParent()->GetUserURL() );
+ INetURLObject aNewURL, aTempURL;
+ sal_uInt32 nCount = GetObjectCount();
+ BOOL bRel;
+
+ rOStm << (sal_uInt16) 0x0004;
+ rOStm << ByteString( GetRealName(), RTL_TEXTENCODING_UTF8 );
+ rOStm << nCount << (sal_uInt16) gsl_getSystemTextEncoding();
+
+ for( sal_uInt32 i = 0; i < nCount; i++ )
+ {
+ const GalleryObject* pObj = ImplGetGalleryObject( i );
+ String aPath;
+
+ if( SGA_OBJ_SVDRAW == pObj->eObjKind )
+ {
+ aPath = GetSvDrawStreamNameFromURL( pObj->aURL );
+ bRel = FALSE;
+ }
+ else
+ {
+ aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
+ bRel = ( ( aPath.Erase( sal::static_int_cast< xub_StrLen >( aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) ) ) == String(aRelURL1.GetMainURL( INetURLObject::NO_DECODE ) ));
+
+ if( bRel && ( pObj->aURL.GetMainURL( INetURLObject::NO_DECODE ).getLength() > ( aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() + 1 ) ) )
+ {
+ aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
+ aPath = aPath.Erase( 0, sal::static_int_cast< xub_StrLen >( aRelURL1.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) );
+ }
+ else
+ {
+ aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
+ bRel = ( ( aPath.Erase( sal::static_int_cast< xub_StrLen >( aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) ) ) == String(aRelURL2.GetMainURL( INetURLObject::NO_DECODE ) ));
+
+ if( bRel && ( pObj->aURL.GetMainURL( INetURLObject::NO_DECODE ).getLength() > ( aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() + 1 ) ) )
+ {
+ aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
+ aPath = aPath.Erase( 0, sal::static_int_cast< xub_StrLen >( aRelURL2.GetMainURL( INetURLObject::NO_DECODE ).getLength() ) );
+ }
+ else
+ aPath = pObj->aURL.GetMainURL( INetURLObject::NO_DECODE );
+ }
+ }
+
+ aPath.SearchAndReplace(m_aDestDir, String());
+ rOStm << bRel << ByteString( aPath, RTL_TEXTENCODING_UTF8 ) << pObj->nOffset << (sal_uInt16) pObj->eObjKind;
+ }
+
+ // neuerdings wird ein 512-Byte-Reservepuffer gechrieben;
+ // um diesen zu erkennen werden zwei ULONG-Ids geschrieben
+ rOStm << COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) << COMPAT_FORMAT( 'E', 'S', 'R', 'V' );
+
+ const long nReservePos = rOStm.Tell();
+ VersionCompat* pCompat = new VersionCompat( rOStm, STREAM_WRITE, 2 );
+
+ rOStm << (sal_uInt32) GetId() << IsThemeNameFromResource(); // ab Version 2
+
+ delete pCompat;
+
+ // Rest des Puffers auffuellen
+ const long nRest = Max( 512L - ( (long) rOStm.Tell() - nReservePos ), 0L );
+
+ if( nRest )
+ {
+ char* pReserve = new char[ nRest ];
+ memset( pReserve, 0, nRest );
+ rOStm.Write( pReserve, nRest );
+ delete[] pReserve;
+ }
+
+ return rOStm;
+}
+
+// ------------------------------------------------------------------------
+
+SvStream& GalleryTheme::ReadData( SvStream& rIStm )
+{
+ sal_uInt32 nCount;
+ sal_uInt16 nVersion;
+ ByteString aTmpStr;
+ String aThemeName;
+ rtl_TextEncoding nTextEncoding;
+
+ aImportName = String();
+ rIStm >> nVersion >> aTmpStr >> nCount;
+
+ if( nVersion >= 0x0004 )
+ {
+ UINT16 nTmp16;
+ rIStm >> nTmp16;
+ nTextEncoding = (rtl_TextEncoding) nTmp16;
+ }
+ else
+ nTextEncoding = RTL_TEXTENCODING_UTF8;
+
+ aThemeName = String( aTmpStr.GetBuffer(), nTextEncoding );
+
+ if( nCount <= ( 1L << 14 ) )
+ {
+ GalleryObject* pObj;
+ INetURLObject aRelURL1( GetParent()->GetRelativeURL() );
+ INetURLObject aRelURL2( GetParent()->GetUserURL() );
+ sal_uInt32 nId1, nId2;
+ BOOL bRel;
+
+ for( pObj = aObjectList.First(); pObj; pObj = aObjectList.Next() )
+ {
+ Broadcast( GalleryHint( GALLERY_HINT_CLOSE_OBJECT, GetName(), reinterpret_cast< ULONG >( pObj ) ) );
+ delete pObj;
+ Broadcast( GalleryHint( GALLERY_HINT_OBJECT_REMOVED, GetName(), reinterpret_cast< ULONG >( pObj ) ) );
+ }
+
+ aObjectList.Clear();
+
+ for( sal_uInt32 i = 0; i < nCount; i++ )
+ {
+ pObj = new GalleryObject;
+
+ ByteString aTempFileName;
+ String aFileName;
+ String aPath;
+ sal_uInt16 nTemp;
+
+ rIStm >> bRel >> aTempFileName >> pObj->nOffset;
+ rIStm >> nTemp; pObj->eObjKind = (SgaObjKind) nTemp;
+
+ aFileName = String( aTempFileName.GetBuffer(), gsl_getSystemTextEncoding() );
+
+ if( bRel )
+ {
+ aFileName.SearchAndReplaceAll( '\\', '/' );
+ aPath = aRelURL1.GetMainURL( INetURLObject::NO_DECODE );
+
+ if( aFileName.GetChar( 0 ) != '/' )
+ aPath += '/';
+
+ aPath += aFileName;
+
+ pObj->aURL = INetURLObject( aPath );
+
+ if( !FileExists( pObj->aURL ) )
+ {
+ aPath = aRelURL2.GetMainURL( INetURLObject::NO_DECODE );
+
+ if( aFileName.GetChar( 0 ) != '/' )
+ aPath += '/';
+
+ aPath += aFileName;
+
+ // assign this URL, even in the case it is not valid (#94482)
+ pObj->aURL = INetURLObject( aPath );
+ }
+ }
+ else
+ {
+ if( SGA_OBJ_SVDRAW == pObj->eObjKind )
+ {
+ const static String aBaseURLStr( RTL_CONSTASCII_USTRINGPARAM( "gallery/svdraw/" ) );
+
+ String aDummyURL( aBaseURLStr );
+ pObj->aURL = INetURLObject( aDummyURL += aFileName, INET_PROT_PRIV_SOFFICE );
+ }
+ else
+ {
+ String aLocalURL;
+
+ pObj->aURL = INetURLObject( aFileName );
+
+ if( ( pObj->aURL.GetProtocol() == INET_PROT_NOT_VALID ) &&
+ ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aFileName, aLocalURL ) )
+ {
+ pObj->aURL = INetURLObject( aLocalURL );
+ }
+ }
+ }
+
+ aObjectList.Insert( pObj, LIST_APPEND );
+ }
+
+ rIStm >> nId1 >> nId2;
+
+ // in neueren Versionen befindet sich am Ende ein 512-Byte-Reservepuffer;
+ // die Daten befinden sich am Anfang dieses Puffers und
+ // sind durch eine VersionCompat geklammert
+ if( !rIStm.IsEof() &&
+ nId1 == COMPAT_FORMAT( 'G', 'A', 'L', 'R' ) &&
+ nId2 == COMPAT_FORMAT( 'E', 'S', 'R', 'V' ) )
+ {
+ VersionCompat* pCompat = new VersionCompat( rIStm, STREAM_READ );
+ sal_uInt32 nTemp32;
+ BOOL bThemeNameFromResource = FALSE;
+
+ rIStm >> nTemp32;
+
+ if( pCompat->GetVersion() >= 2 )
+ {
+ rIStm >> bThemeNameFromResource;
+ }
+
+ SetId( nTemp32, bThemeNameFromResource );
+ delete pCompat;
+ }
+ }
+ else
+ rIStm.SetError( SVSTREAM_READ_ERROR );
+
+ ImplSetModified( FALSE );
+
+ return rIStm;
+}
+
+// ------------------------------------------------------------------------
+
+SvStream& operator<<( SvStream& rOut, const GalleryTheme& rTheme )
+{
+ return rTheme.WriteData( rOut );
+}
+
+// ------------------------------------------------------------------------
+
+SvStream& operator>>( SvStream& rIn, GalleryTheme& rTheme )
+{
+ return rTheme.ReadData( rIn );
+}
+
+void GalleryTheme::ImplSetModified( BOOL bModified )
+{ pThm->SetModified( bModified ); }
+
+const String& GalleryTheme::GetRealName() const { return pThm->GetThemeName(); }
+const INetURLObject& GalleryTheme::GetThmURL() const { return pThm->GetThmURL(); }
+const INetURLObject& GalleryTheme::GetSdgURL() const { return pThm->GetSdgURL(); }
+const INetURLObject& GalleryTheme::GetSdvURL() const { return pThm->GetSdvURL(); }
+UINT32 GalleryTheme::GetId() const { return pThm->GetId(); }
+void GalleryTheme::SetId( UINT32 nNewId, BOOL bResetThemeName ) { pThm->SetId( nNewId, bResetThemeName ); }
+BOOL GalleryTheme::IsThemeNameFromResource() const { return pThm->IsNameFromResource(); }
+BOOL GalleryTheme::IsImported() const { return pThm->IsImported(); }
+BOOL GalleryTheme::IsReadOnly() const { return pThm->IsReadOnly(); }
+BOOL GalleryTheme::IsDefault() const { return pThm->IsDefault(); }
+BOOL GalleryTheme::IsModified() const { return pThm->IsModified(); }
+const String& GalleryTheme::GetName() const { return IsImported() ? aImportName : pThm->GetThemeName(); }
+
+void GalleryTheme::InsertAllThemes( ListBox& rListBox )
+{
+ for( USHORT i = RID_GALLERYSTR_THEME_FIRST; i <= RID_GALLERYSTR_THEME_LAST; i++ )
+ rListBox.InsertEntry( String( GAL_RESID( i ) ) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gallery2/galtheme.src b/svx/source/gallery2/galtheme.src
new file mode 100644
index 000000000000..99de47ab4c28
--- /dev/null
+++ b/svx/source/gallery2/galtheme.src
@@ -0,0 +1,1031 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "gallery.hrc"
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_3D
+{
+ Text [ en-US ] = "3D Effects";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ANIMATIONS
+{
+ Text [ en-US ] = "Animations";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_BULLETS
+{
+ Text [ en-US ] = "Bullets";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_OFFICE
+{
+ Text [ en-US ] = "Office";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_FLAGS
+{
+ Text [ en-US ] = "Flags";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_FLOWCHARTS
+{
+ Text [ en-US ] = "Flow Charts";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_EMOTICONS
+{
+ Text [ en-US ] = "Emoticons";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS
+{
+ Text [ en-US ] = "Pictures";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_BACKGROUNDS
+{
+ Text [ en-US ] = "Backgrounds";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_HOMEPAGE
+{
+ Text [ en-US ] = "Homepage";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_INTERACTION
+{
+ Text [ en-US ] = "Interaction";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS
+{
+ Text [ en-US ] = "Maps";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PEOPLE
+{
+ Text [ en-US ] = "People";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SURFACES
+{
+ Text [ en-US ] = "Surfaces";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_HTMLBUTTONS
+{
+ // !!! Don't translate, please !!!
+ Text = "private://gallery/hidden/HtmlExportButtons";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_POWERPOINT
+{
+ // !!! Don't translate, please !!!
+ Text = "private://gallery/hidden/imgppt";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_RULERS
+{
+ Text [ en-US ] = "Rulers";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SOUNDS
+{
+ Text [ en-US ] = "Sounds";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SYMBOLS
+{
+ Text [ en-US ] = "Symbols";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MYTHEME
+{
+ Text [ en-US ] = "My Theme";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_USERSOUNDS
+{
+ // !!! Don't translate, please !!!
+ Text = "private://gallery/hidden/usersounds";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ARROWS
+{
+ Text [ en-US ] = "Arrows";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_BALLOONS
+{
+ Text [ en-US ] = "Balloons";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_KEYBOARD
+{
+ Text [ en-US ] = "Keyboard";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_TIME
+{
+ Text [ en-US ] = "Time";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PRESENTATION
+{
+ Text [ en-US ] = "Presentation";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CALENDAR
+{
+ Text [ en-US ] = "Calendar";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_NAVIGATION
+{
+ Text [ en-US ] = "Navigation";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_COMMUNICATION
+{
+ Text [ en-US ] = "Communication";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_FINANCES
+{
+ Text [ en-US ] = "Finances";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_COMPUTER
+{
+ Text [ en-US ] = "Computers";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLIMA
+{
+ Text [ en-US ] = "Climate";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_EDUCATION
+{
+ Text [ en-US ] = "School & University";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_TROUBLE
+{
+ Text [ en-US ] = "Problem Solving";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SCREENBEANS
+{
+ Text [ en-US ] = "Screen Beans";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_FONTWORK
+{
+ // !!! Don't translate, please !!!
+ Text = "private://gallery/hidden/fontwork";
+};
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_FONTWORK_VERTICAL
+{
+ // !!! Don't translate, please !!!
+ Text = "private://gallery/hidden/fontworkvertical";
+};
+
+
+// -----------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_DUMMY5
+{
+ // !!! Don't translate, please !!!
+ Text = "Dummy 5";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SHAPES_POLYGONS
+{
+Text [ en-US ] = "Shapes - polygons";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SHAPES_1
+{
+Text [ en-US ] = "Shapes 1";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SHAPES_2
+{
+Text [ en-US ] = "Shapes 2";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ANIMALS
+{
+Text [ en-US ] = "Animals";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CARS
+{
+Text [ en-US ] = "Cars";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_BUGS
+{
+Text [ en-US ] = "Bugs";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CISCO_OTHER
+{
+Text [ en-US ] = "Cisco - Other";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CISCO_MEDIA
+{
+Text [ en-US ] = "Cisco - Media";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CISCO_PRODUCTS
+{
+Text [ en-US ] = "Cisco - Products";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CISCO_WAN_LAN
+{
+Text [ en-US ] = "Cisco - WAN - LAN";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_DOMINO_USUAL
+{
+Text [ en-US ] = "Domino - usual";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_DOMINO_NUMBERED
+{
+Text [ en-US ] = "Domino - numbered";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ELECTRONICS_PARTS_1
+{
+Text [ en-US ] = "Electronics - parts 1";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ELECTRONICS_PARTS_2
+{
+Text [ en-US ] = "Electronics - parts 2";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ELECTRONICS_PARTS_3
+{
+Text [ en-US ] = "Electronics - parts 3";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ELECTRONICS_PARTS_4
+{
+Text [ en-US ] = "Electronics - parts 4";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ELECTRONICS_CIRCUIT
+{
+Text [ en-US ] = "Electronics - circuit";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ELECTRONICS_SIGNS
+{
+Text [ en-US ] = "Electronics - signs";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ELECTRONICS_GAUGES
+{
+Text [ en-US ] = "Electronics - gauges";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PEOPLE_1
+{
+Text [ en-US ] = "People";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ARCHITECTURE_OVERLAY
+{
+Text [ en-US ] = "Architecture - overlay";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ARCHITECTURE_FURNITURES
+{
+Text [ en-US ] = "Architecture - furnitures";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ARCHITECTURE_BUILDINGS
+{
+Text [ en-US ] = "Architecture - buildings";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ARCHITECTURE_BATHROOM_KITCHEN
+{
+Text [ en-US ] = "Architecture - bathroom, kitchen";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ARCHITECTURE_KITCHEN
+{
+Text [ en-US ] = "Architecture - kitchen";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ARCHITECTURE_WINDOWS_DOORS
+{
+Text [ en-US ] = "Architecture - windows, doors";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_FLOWCHARTS_1
+{
+Text [ en-US ] = "Flowcharts";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_FLOWCHARTS_2
+{
+Text [ en-US ] = "Flowcharts 2";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_FORALSTUDIOA
+{
+Text [ en-US ] = "Foral-StudioA";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_FAUNA
+{
+Text [ en-US ] = "Photos - Fauna";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_BUILDINGS
+{
+Text [ en-US ] = "Photos - Buildings";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_PLANTS
+{
+Text [ en-US ] = "Photos - Plants";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_STATUES
+{
+Text [ en-US ] = "Photos - Statues";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_LANDSCAPES
+{
+Text [ en-US ] = "Photos - Landscapes";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_CITIES
+{
+Text [ en-US ] = "Photos - Cities";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_FLOWERS
+{
+Text [ en-US ] = "Photos - Flowers";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_THERAPEUTICS_GENERAL
+{
+Text [ en-US ] = "Therapeutics - general";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_WEATHER
+{
+Text [ en-US ] = "Weather";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_VECHILES
+{
+Text [ en-US ] = "Vehicles";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SIGNS
+{
+Text [ en-US ] = "Signs";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_BLUE_MAN
+{
+Text [ en-US ] = "Blue Man";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CHEMISTRY_AMINO_ACIDS
+{
+Text [ en-US ] = "Chemistry - Amino acids";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_LOGICAL_SIGNS
+{
+Text [ en-US ] = "Logical signs";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_LOGICAL_GATES
+{
+Text [ en-US ] = "Logical gates";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_LOGOS
+{
+Text [ en-US ] = "Logos";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SMILES
+{
+Text [ en-US ] = "Smilies";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ARROWS_1
+{
+Text [ en-US ] = "Arrows";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_01_CLOCK
+{
+Text [ en-US ] = "Clock - 01 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_02_CLOCK
+{
+Text [ en-US ] = "Clock - 02 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_03_CLOCK
+{
+Text [ en-US ] = "Clock - 03 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_04_CLOCK
+{
+Text [ en-US ] = "Clock - 04 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_05_CLOCK
+{
+Text [ en-US ] = "Clock - 05 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_06_CLOCK
+{
+Text [ en-US ] = "Clock - 06 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_07_CLOCK
+{
+Text [ en-US ] = "Clock - 07 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_08_CLOCK
+{
+Text [ en-US ] = "Clock - 08 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_09_CLOCK
+{
+Text [ en-US ] = "Clock - 09 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_10_CLOCK
+{
+Text [ en-US ] = "Clock - 10 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_11_CLOCK
+{
+Text [ en-US ] = "Clock - 11 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CLOCK_12_CLOCK
+{
+Text [ en-US ] = "Clock - 12 clock";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PNEUMATIC_PARTS
+{
+Text [ en-US ] = "Pneumatic - parts";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_COMPUTER_GENERAL
+{
+Text [ en-US ] = "Computer - general";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_COMPUTER_NETWORK
+{
+Text [ en-US ] = "Computer - network";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_COMPUTER_NETWORK_DEVICES
+{
+Text [ en-US ] = "Computer - network devices";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_COMPUTER_WIFI
+{
+Text [ en-US ] = "Computer - WIFI";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_NUMBERS
+{
+Text [ en-US ] = "Numbers";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SIGNS_DANGER
+{
+Text [ en-US ] = "Signs - danger";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_OBJECTS
+{
+Text [ en-US ] = "Objects";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_AFRICA
+{
+Text [ en-US ] = "Maps - Africa";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_UNITED_STATES_OF_AMERICA
+{
+Text [ en-US ] = "Maps - United States of America";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_AUSTRALIA
+{
+Text [ en-US ] = "Maps - Australia";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_ASIA
+{
+Text [ en-US ] = "Maps - Asia";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_SOUTH_AMERICA
+{
+Text [ en-US ] = "Maps - South America";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_EUROPE
+{
+Text [ en-US ] = "Maps - Europe";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_EUROPE_1
+{
+Text [ en-US ] = "Maps - Europe 1";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_FRANCE
+{
+Text [ en-US ] = "Maps - France";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_FRANCE_COUNTRIES
+{
+Text [ en-US ] = "Maps - France - countries";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_SIGNS
+{
+Text [ en-US ] = "Maps - signs";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_CANADA
+{
+Text [ en-US ] = "Maps - Canada";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_CONTINENTS
+{
+Text [ en-US ] = "Maps - Continents";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_MIDDLE_EAST
+{
+Text [ en-US ] = "Maps - Middle East";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_MIDDLE_AMERICA
+{
+Text [ en-US ] = "Maps - Middle America";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_MIDDLE_AGES
+{
+Text [ en-US ] = "Maps - Middle ages";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_MEXICO
+{
+Text [ en-US ] = "Maps - Mexico";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_ANCIENT_TIMES
+{
+Text [ en-US ] = "Maps - Ancient times";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_SYMBOLS
+{
+Text [ en-US ] = "Maps - symbols";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_HISTORY_1900
+{
+Text [ en-US ] = "Maps - history - 1900";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MAPS_WORLD
+{
+Text [ en-US ] = "Maps - World";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_CROPS
+{
+Text [ en-US ] = "Crops";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_FRACTIONS
+{
+Text [ en-US ] = "Fractions";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_FLAGS_1
+{
+Text [ en-US ] = "Flags";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MUSIC_INSTRUMENTS
+{
+Text [ en-US ] = "Music - instruments";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_MUSIC_SHEET_MUSIC
+{
+Text [ en-US ] = "Music - sheet music";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_SPECIAL_PICTOGRAMM
+{
+Text [ en-US ] = "Special Pictogramms";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_CELEBRATION
+{
+Text [ en-US ] = "Photos - Celebration";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_FOODSANDDRINKS
+{
+Text [ en-US ] = "Photos - Foods and Drinks";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_HUMANS
+{
+Text [ en-US ] = "Photos - Humans";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_OBJECTS
+{
+Text [ en-US ] = "Photos - Objects";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_SPACE
+{
+Text [ en-US ] = "Photos - Space";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_PHOTOS_TRAVEL
+{
+Text [ en-US ] = "Photos - Travel";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_OPENOFFICEORG_LOGOS
+{
+Text [ en-US ] = "OpenOffice.org logos";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_RELIGION
+{
+Text [ en-US ] = "Religion";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_BUILDINGS
+{
+Text [ en-US ] = "Buildings";
+};
+
+// ---------------------------------------------------------------------------+
+
+String RID_GALLERYSTR_THEME_HOMEPAGE2
+{
+Text [ en-US ] = "Homepage 2";
+};
+
+// ---------------------------------------------------------------------------
+
+String RID_GALLERYSTR_THEME_ELEMENTSBULLETS2
+{
+Text [ en-US ] = "Bullets 2";
+};
+
+// ---------------------------------------------------------------------------
diff --git a/svx/source/gallery2/makefile.mk b/svx/source/gallery2/makefile.mk
new file mode 100644
index 000000000000..7f1a3bb7a7d3
--- /dev/null
+++ b/svx/source/gallery2/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=svx
+TARGET=gal
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ gallery.src \
+ galtheme.src
+
+SLOFILES = \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/codec.obj
+
+EXCEPTIONSFILES = \
+ $(SLO)$/galbrws.obj \
+ $(SLO)$/galbrws1.obj \
+ $(SLO)$/galbrws2.obj \
+ $(SLO)$/galctrl.obj \
+ $(SLO)$/galexpl.obj \
+ $(SLO)$/gallery1.obj \
+ $(SLO)$/galmisc.obj \
+ $(SLO)$/galobj.obj \
+ $(SLO)$/galtheme.obj
+
+RESLIB1NAME = $(TARGET)
+RESLIB1IMAGES = $(PRJ)$/res
+RESLIB1SRSFILES = $(SRS)$/$(TARGET).srs
+
+# --- Targets --------------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/svx/source/gengal/gengal.cxx b/svx/source/gengal/gengal.cxx
new file mode 100644
index 000000000000..13fe12a16d1b
--- /dev/null
+++ b/svx/source/gengal/gengal.cxx
@@ -0,0 +1,321 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <memory>
+#include <list>
+
+#include <unotools/streamwrap.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/regpathhelper.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+
+#include <ucbhelper/contentbroker.hxx>
+#include <ucbhelper/configurationkeys.hxx>
+
+#include <tools/urlobj.hxx>
+#include <tools/fsys.hxx>
+#include <svtools/filedlg.hxx>
+
+#include <vcl/window.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/font.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/print.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/help.hxx>
+#include <vcl/scrbar.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <osl/file.hxx>
+#include <osl/process.h>
+#include <rtl/bootstrap.hxx>
+
+#include <galtheme.hxx>
+#include <svx/gallery1.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::lang;
+
+typedef ::std::list<rtl::OUString> FileNameList;
+
+class GalApp : public Application
+{
+public:
+ virtual void Main();
+
+protected:
+ Reference<XMultiServiceFactory> xMSF;
+ void Init();
+ void InitUCB();
+};
+
+Gallery* createGallery( const rtl::OUString& aGalleryURL )
+{
+ return new Gallery( aGalleryURL );
+}
+
+void disposeGallery( Gallery* pGallery )
+{
+ delete pGallery;
+}
+
+static void createTheme( rtl::OUString aThemeName,
+ rtl::OUString aGalleryURL,
+ rtl::OUString aDestDir,
+ UINT32 nNumFrom,
+ FileNameList &rFiles )
+{
+ Gallery * pGallery( createGallery( aGalleryURL ) );
+
+ if (!pGallery ) {
+ fprintf( stderr, "Could't acquire '%s'\n",
+ (const sal_Char *) rtl::OUStringToOString( aGalleryURL,
+ RTL_TEXTENCODING_UTF8 ) );
+ exit( 1 );
+ }
+ fprintf( stderr, "Work on gallery '%s'\n",
+ (const sal_Char *) rtl::OUStringToOString( aGalleryURL, RTL_TEXTENCODING_UTF8 ) );
+
+ fprintf( stderr, "Existing themes: %lu\n",
+ sal::static_int_cast< unsigned long >(
+ pGallery->GetThemeCount() ) );
+
+ if( !pGallery->HasTheme( aThemeName) ) {
+ if( !pGallery->CreateTheme( aThemeName, nNumFrom ) ) {
+ fprintf( stderr, "Failed to create theme\n" );
+ disposeGallery( pGallery );
+ exit( 1 );
+ }
+ }
+
+ fprintf( stderr, "Existing themes: %lu\n",
+ sal::static_int_cast< unsigned long >(
+ pGallery->GetThemeCount() ) );
+
+ SfxListener aListener;
+
+ GalleryTheme *pGalTheme = pGallery->AcquireTheme( aThemeName, aListener );
+ if ( pGalTheme == NULL ) {
+ fprintf( stderr, "Failed to acquire theme\n" );
+ disposeGallery( pGallery );
+ exit( 1 );
+ }
+
+ fprintf( stderr, "Using DestDir: %s\n",
+ (const sal_Char *) rtl::OUStringToOString( aDestDir, RTL_TEXTENCODING_UTF8 ) );
+ pGalTheme->SetDestDir(String(aDestDir));
+
+ FileNameList::const_iterator aIter;
+
+ for( aIter = rFiles.begin(); aIter != rFiles.end(); aIter++ )
+ {
+// Should/could use:
+// if ( ! pGalTheme->InsertFileOrDirURL( aURL ) ) {
+// Requires a load more components ...
+
+ Graphic aGraphic;
+ String aFormat;
+
+#if 1
+ if ( ! pGalTheme->InsertURL( *aIter ) )
+ fprintf( stderr, "Failed to import '%s'\n",
+ (const sal_Char *) rtl::OUStringToOString( *aIter, RTL_TEXTENCODING_UTF8 ) );
+ else
+ fprintf( stderr, "Imported file '%s' (%lu)\n",
+ (const sal_Char *) rtl::OUStringToOString( *aIter, RTL_TEXTENCODING_UTF8 ),
+ sal::static_int_cast< unsigned long >(
+ pGalTheme->GetObjectCount() ) );
+
+#else // only loads BMPs
+ SvStream *pStream = ::utl::UcbStreamHelper::CreateStream( *aIter, STREAM_READ );
+ if (!pStream) {
+ fprintf( stderr, "Can't find image to import\n" );
+ disposeGallery( pGallery );
+ exit (1);
+ }
+ *pStream >> aGraphic;
+ delete pStream;
+ if( aGraphic.GetType() == GRAPHIC_NONE )
+ {
+ fprintf( stderr, "Failed to load '%s'\n",
+ (const sal_Char *) rtl::OUStringToOString( *aIter, RTL_TEXTENCODING_UTF8 ) );
+ continue;
+ }
+
+ SgaObjectBmp aObject( aGraphic, *aIter, aFormat );
+ if ( ! aObject.IsValid() ) {
+ fprintf( stderr, "Failed to create thumbnail for image\n" );
+ continue;
+ }
+
+ if ( ! pGalTheme->InsertObject( aObject ) ) {
+ fprintf( stderr, "Failed to insert file or URL\n" );
+ continue;
+ }
+#endif
+ }
+
+ pGallery->ReleaseTheme( pGalTheme, aListener );
+ disposeGallery( pGallery );
+}
+
+static void PrintHelp()
+{
+ fprintf( stdout, "Utility to generate OO.o gallery files\n\n" );
+
+ fprintf( stdout, "using: gengal --name <name> --path <dir> [ --destdir <path> ]\n");
+ fprintf( stdout, " [ --number-from <num> ] [ files ... ]\n\n" );
+
+ fprintf( stdout, "options:\n");
+ fprintf( stdout, " --name <theme>\t\tdefines a name of the created or updated theme.\n");
+ fprintf( stdout, " --path <dir>\t\tdefines directory where the gallery files are created\n");
+ fprintf( stdout, "\t\t\tor updated.\n");
+ fprintf( stdout, " --destdir <dir>\tdefines a path prefix to be removed from the paths\n");
+ fprintf( stdout, "\t\t\tstored in the gallery files. It is useful to create\n");
+ fprintf( stdout, "\t\t\tRPM packages using the BuildRoot feature.\n");
+ fprintf( stdout, " --number-from <num>\tdefines minimal number for the newly created gallery\n");
+ fprintf( stdout, "\t\t\ttheme files.\n");
+ fprintf( stdout, " files\t\t\tlists files to be added to the gallery. Absolute paths\n");
+ fprintf( stdout, "\t\t\tare required.\n");
+}
+
+static rtl::OUString Smartify( const rtl::OUString &rPath )
+{
+ INetURLObject aURL;
+ aURL.SetSmartURL( rPath );
+ return aURL.GetMainURL( INetURLObject::NO_DECODE );
+}
+
+#define OUSTRING_CSTR( str ) \
+ rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ).getStr()
+
+void GalApp::Init()
+{
+ if( getenv( "OOO_INSTALL_PREFIX" ) == NULL ) {
+ rtl::OUString fileName = GetAppFileName();
+ int lastSlash = fileName.lastIndexOf( '/' );
+#ifdef WNT
+ // Don't know which directory separators GetAppFileName() returns on Windows.
+ // Be safe and take into consideration they might be backslashes.
+ if( fileName.lastIndexOf( '\\' ) > lastSlash )
+ lastSlash = fileName.lastIndexOf( '\\' );
+#endif
+ rtl::OUString baseBinDir = fileName.copy( 0, lastSlash );
+ rtl::OUString installPrefix = baseBinDir + rtl::OUString::createFromAscii( "/../.." );
+
+ rtl::OUString envVar(RTL_CONSTASCII_USTRINGPARAM("OOO_INSTALL_PREFIX"));
+ osl_setEnvironment(envVar.pData, installPrefix.pData);
+ }
+ OSL_TRACE( "OOO_INSTALL_PREFIX=%s", getenv( "OOO_INSTALL_PREFIX" ) );
+
+ Reference<XComponentContext> xComponentContext
+ = ::cppu::defaultBootstrap_InitialComponentContext();
+ xMSF = Reference<XMultiServiceFactory>
+ ( xComponentContext->getServiceManager(), UNO_QUERY );
+ if( !xMSF.is() )
+ fprintf( stderr, "Failed to bootstrap\n" );
+ ::comphelper::setProcessServiceFactory( xMSF );
+
+ InitUCB();
+}
+
+void GalApp::InitUCB()
+{
+ rtl::OUString aEmpty;
+ Sequence< Any > aArgs(6);
+ aArgs[0]
+ <<= rtl::OUString::createFromAscii(UCB_CONFIGURATION_KEY1_LOCAL);
+ aArgs[1]
+ <<= rtl::OUString::createFromAscii(UCB_CONFIGURATION_KEY2_OFFICE);
+ aArgs[2] <<= rtl::OUString::createFromAscii("PIPE");
+ aArgs[3] <<= aEmpty;
+ aArgs[4] <<= rtl::OUString::createFromAscii("PORTAL");
+ aArgs[5] <<= aEmpty;
+
+ if (! ::ucbhelper::ContentBroker::initialize( xMSF, aArgs ) )
+ fprintf( stderr, "Failed to init content broker\n" );
+}
+
+void GalApp::Main()
+{
+ bool bHelp = false;
+ rtl::OUString aPath, aDestDir;
+ rtl::OUString aName = rtl::OUString::createFromAscii( "Default name" );
+ UINT32 nNumFrom = 0;
+ FileNameList aFiles;
+
+ for( USHORT i = 0; i < GetCommandLineParamCount(); i++ )
+ {
+ rtl::OUString aParam = GetCommandLineParam( i );
+
+ if( aParam.equalsAscii( "--help" ) ||
+ aParam.equalsAscii( "-h" ) )
+ bHelp = true;
+
+ else if ( aParam.equalsAscii( "--name" ) )
+ aName = GetCommandLineParam( ++i );
+
+ else if ( aParam.equalsAscii( "--path" ) )
+ aPath = Smartify( GetCommandLineParam( ++i ) );
+
+ else if ( aParam.equalsAscii( "--destdir" ) )
+ aDestDir = GetCommandLineParam( ++i );
+
+ else if ( aParam.equalsAscii( "--number-from" ) )
+ nNumFrom = GetCommandLineParam( ++i ).ToInt32();
+
+ else
+ aFiles.push_back( Smartify( aParam ) );
+ }
+
+ if( bHelp )
+ {
+ PrintHelp();
+ return;
+ }
+
+ createTheme( aName, aPath, aDestDir, nNumFrom, aFiles );
+}
+
+GalApp aGalApp;
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/gengal/gengal.sh b/svx/source/gengal/gengal.sh
new file mode 100644
index 000000000000..2fccd222fc15
--- /dev/null
+++ b/svx/source/gengal/gengal.sh
@@ -0,0 +1,101 @@
+#!/bin/sh
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+# enable file locking
+SAL_ENABLE_FILE_LOCKING=1
+export SAL_ENABLE_FILE_LOCKING
+
+# resolve installation directory
+sd_cwd="`pwd`"
+if [ -h "$0" ] ; then
+ sd_basename=`basename "$0"`
+ sd_script=`ls -l "$0" | sed "s/.*${sd_basename} -> //g"`
+ cd "`dirname "$0"`"
+ cd "`dirname "$sd_script"`"
+else
+ cd "`dirname "$0"`"
+fi
+
+sd_prog="`pwd`"
+
+cd ..
+sd_binary=`basename "$0"`".bin"
+sd_inst="`pwd`"
+
+# change back directory
+cd "$sd_cwd"
+
+# check if all required patches are installed
+if [ -x "$sd_prog/sopatchlevel.sh" ]; then
+ "$sd_prog/sopatchlevel.sh"
+ if [ $? -eq 1 ]; then
+ exit 0
+ fi
+fi
+
+# set search path for shared libraries
+sd_platform=`uname -s`
+case $sd_platform in
+ AIX)
+ LIBPATH=${sd_prog}${LIBPATH+:${LIBPATH}}
+ export LIBPATH
+ ;;
+
+ Darwin)
+ DYLD_LIBRARY_PATH=${sd_prog}${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
+ export DYLD_LIBRARY_PATH
+ ;;
+
+ HP-UX)
+ SHLIB_PATH=${sd_prog}:/usr/openwin/lib${SHLIB_PATH:+:${SHLIB_PATH}}
+ export SHLIB_PATH
+ ;;
+
+ *)
+ LD_LIBRARY_PATH=${sd_prog}${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
+ export LD_LIBRARY_PATH
+ ;;
+esac
+
+# misc. environment variables
+unset XENVIRONMENT
+
+# set path so that other apps can be started just by name
+PATH="$sd_prog":$PATH
+export PATH
+
+OOO_INSTALL_PREFIX=${OOO_INSTALL_PREFIX-$sd_prog/../..}
+if ! test -e $OOO_INSTALL_PREFIX/basis-link; then
+ # Hack for vanilla OOo binaries' split install layout
+ OOO_INSTALL_PREFIX=$OOO_INSTALL_PREFIX/../openoffice.org3
+fi
+
+export OOO_INSTALL_PREFIX
+
+# execute binary
+exec "$sd_prog/$sd_binary" "$@"
diff --git a/svx/source/gengal/gengalrc.in b/svx/source/gengal/gengalrc.in
new file mode 100644
index 000000000000..00ae5eb3cd5e
--- /dev/null
+++ b/svx/source/gengal/gengalrc.in
@@ -0,0 +1,12 @@
+OOO_INSTALL_PREFIX_URL=file://${OOO_INSTALL_PREFIX}
+OOO_BASIS_URL=${OOO_INSTALL_PREFIX_URL}/basis-link
+OOO_BASIS_BIN_URL=${OOO_BASIS_URL}/program
+OOO_URE_URL=${OOO_BASIS_URL}/ure-link
+#
+#CFG_INIFILE=${OOO_BASIS_BIN_URL}/configmgrrc
+#BaseInstallation=${OOO_BASIS_URL}
+BRAND_BASE_DIR=${OOO_INSTALL_PREFIX_URL}
+OOO_BASE_DIR=${OOO_BASIS_URL}
+#
+UNO_TYPES=${OOO_URE_URL}/share/misc/types.rdb ${OOO_BASIS_BIN_URL}/offapi.rdb
+UNO_SERVICES=${OOO_URE_URL}/share/misc/services.rdb ${OOO_BASIS_BIN_URL}/services.rdb
diff --git a/svx/source/gengal/makefile.mk b/svx/source/gengal/makefile.mk
new file mode 100644
index 000000000000..eefe8679a139
--- /dev/null
+++ b/svx/source/gengal/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+
+TARGET=gengal
+TARGETTYPE=GUI
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SCRIPTFILES = $(BIN)$/gengal
+
+OBJFILES= $(OBJ)$/gengal.obj
+
+.IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
+APP1TARGET= $(TARGET)
+.ELSE # .IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
+APP1TARGET= $(TARGET).bin
+.ENDIF # .IF "$(GUI)"=="WNT" || "$(GUI)"=="OS2"
+
+APP1OBJS= $(OBJFILES)
+
+APP1STDLIBS=$(TOOLSLIB) \
+ $(SO2LIB) \
+ $(SVLLIB) \
+ $(COMPHELPERLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(VCLLIB) \
+ $(UCBHELPERLIB) \
+ $(SVXCORELIB)
+
+#.IF "$(COM)"=="GCC"
+#ADDOPTFILES=$(OBJ)$/gengal.obj
+#add_cflagscxx="-frtti -fexceptions"
+#.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : \
+ $(SCRIPTFILES)\
+ $(BIN)/gengalrc
+
+$(SCRIPTFILES) : $$(@:f:+".sh")
+ @tr -d "\015" < $(@:f:+".sh") > $@
+
+$(BIN)/%: %.in
+ cp $< $@
+
diff --git a/svx/source/inc/AccessibleFrameSelector.hxx b/svx/source/inc/AccessibleFrameSelector.hxx
new file mode 100644
index 000000000000..437a261f8f77
--- /dev/null
+++ b/svx/source/inc/AccessibleFrameSelector.hxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_ACCESSIBLEFRAMESELECTOR_HXX
+#define SVX_ACCESSIBLEFRAMESELECTOR_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
+#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
+#include <tools/resary.hxx>
+#include <cppuhelper/implbase5.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <comphelper/accessibleeventnotifier.hxx>
+#include <svx/framebordertype.hxx>
+
+class VclSimpleEvent;
+class VclWindowEvent;
+
+namespace svx {
+
+class FrameSelector;
+
+namespace a11y {
+
+// ============================================================================
+
+class AccFrameSelector :
+ public ::cppu::WeakImplHelper5<
+ ::com::sun::star::accessibility::XAccessible,
+ ::com::sun::star::accessibility::XAccessibleContext,
+ ::com::sun::star::accessibility::XAccessibleComponent,
+ ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
+ ::com::sun::star::lang::XServiceInfo
+ >,
+ public Resource
+{
+public:
+ explicit AccFrameSelector( FrameSelector& rFrameSel, FrameBorderType eBorder );
+
+ virtual ~AccFrameSelector();
+
+ //XAccessible
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
+
+ //XAccessibleContext
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ //XAccessibleComponent
+ virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isShowing( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isVisible( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFocusTraversable( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleEventBroadcaster
+ virtual void SAL_CALL addEventListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener) throw (::com::sun::star::uno::RuntimeException);
+
+ //XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ void Invalidate();
+ void NotifyFocusListeners(sal_Bool bGetFocus);
+
+protected:
+ DECL_LINK( WindowEventListener, VclSimpleEvent* );
+
+ virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
+
+ void NotifyAccessibleEvent( const sal_Int16 _nEventId,
+ const ::com::sun::star::uno::Any& _rOldValue,
+ const ::com::sun::star::uno::Any& _rNewValue );
+
+private:
+ void IsValid() throw (::com::sun::star::uno::RuntimeException);
+
+ FrameSelector* mpFrameSel;
+ ::osl::Mutex maFocusMutex;
+ ::osl::Mutex maPropertyMutex;
+
+ FrameBorderType meBorder;
+
+ ::cppu::OInterfaceContainerHelper maFocusListeners;
+ ::cppu::OInterfaceContainerHelper maPropertyListeners;
+
+ ResStringArray maNames;
+ ResStringArray maDescriptions;
+
+ ::comphelper::AccessibleEventNotifier::TClientId mnClientId;
+};
+
+// ============================================================================
+
+} // namespace a11y
+} // namespace svx
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/DGColorNameLookUp.hxx b/svx/source/inc/DGColorNameLookUp.hxx
new file mode 100644
index 000000000000..808e51f5a11a
--- /dev/null
+++ b/svx/source/inc/DGColorNameLookUp.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_ACCESSIBILITY_DG_COLOR_NAME_LOOK_UP_HXX
+#define _SVX_ACCESSIBILITY_DG_COLOR_NAME_LOOK_UP_HXX
+
+#include <rtl/ustrbuf.hxx>
+#include <hash_map>
+
+namespace accessibility {
+
+/** This is a color name lookup targeted to be used by the accessibility
+ <type>DescriptionGenerator</type> class (hence the DG prefix). It
+ encapsulates a <type>com.sun.star.drawing.ColorTable</type> and provides
+ an inverse look up of color names for given a numerical color
+ descriptions--the RGB values encoded as integer.
+
+ <p>The class itself is designed as singleton so that the
+ <type>com.sun.star.drawing.ColorTable</type> object needs to be created
+ only once.</p>
+
+ <p>The singleton instance of this class lives at the moment until the
+ application terminates. However, the color table from which it takes
+ its values may change during this time. Reacting to these changes
+ remains a task for the future.</p>
+*/
+class DGColorNameLookUp
+{
+public:
+ /** Return the single instance of this class. Use this to look up
+ color names with the <member>LookUpColor()</member> method.
+ */
+ static DGColorNameLookUp& Instance (void);
+
+ /** Return the color name of the color expressed by the given integer.
+ @param nColor
+ This integer is the sum of the 8 Bit red value shifted left 16
+ Bits, the green value shifted left 8 Bits, and the unshifted
+ blue value.
+ @return
+ The returned string is either the color name of the specified
+ color or, when no name exists, a string of the form "#RRGGBB"
+ with two hexadecimal digits for each color component.
+ */
+ ::rtl::OUString LookUpColor (long int nColor) const;
+
+private:
+ /// Define hash map type to convert numerical color values to names.
+ typedef std::hash_map<long int, ::rtl::OUString>
+ tColorValueToNameMap;
+
+ /// This ma translates from numerical color values to names.
+ tColorValueToNameMap maColorValueToNameMap;
+
+ /** The pointer to the only instance of this class. It is NULL until
+ the <member>Instance</member> is called for the first time.
+ */
+ static DGColorNameLookUp* mpInstance;
+
+ /// Create a new (the only) instance of this class.
+ DGColorNameLookUp (void);
+
+ /// The destructor is never called.
+ ~DGColorNameLookUp (void);
+
+ /// The copy constructor is not implemented.
+ DGColorNameLookUp (const DGColorNameLookUp&);
+
+ /// The assignment operator is not implemented.
+ DGColorNameLookUp& operator= (const DGColorNameLookUp&);
+};
+
+} // end of namespace accessibility
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/GraphCtlAccessibleContext.hxx b/svx/source/inc/GraphCtlAccessibleContext.hxx
new file mode 100644
index 000000000000..4512b3b0dbd2
--- /dev/null
+++ b/svx/source/inc/GraphCtlAccessibleContext.hxx
@@ -0,0 +1,279 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVXGRAPHACCESSIBLECONTEXT_HXX
+#define _SVXGRAPHACCESSIBLECONTEXT_HXX
+
+#include <cppuhelper/compbase7.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
+#include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
+#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <cppuhelper/weak.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XServiceName.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <osl/mutex.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <svl/lstner.hxx>
+
+#include <set>
+#include <map>
+
+#include <comphelper/servicehelper.hxx>
+#include <svx/rectenum.hxx>
+#include <svx/AccessibleShapeTreeInfo.hxx>
+#include <svx/IAccessibleViewForwarder.hxx>
+#include <svx/AccessibleShape.hxx>
+
+namespace com { namespace sun { namespace star { namespace awt {
+ struct Point;
+ struct Rectangle;
+ struct Size;
+ class XFocusListener;
+} } } }
+
+class Rectangle;
+class GraphCtrl;
+class Window;
+class SdrObject;
+class SdrModel;
+class SdrPage;
+class SdrView;
+
+/** @descr
+ This base class provides an implementation of the
+ <code>AccessibleContext</code> service.
+*/
+
+typedef ::cppu::WeakAggComponentImplHelper7<
+ ::com::sun::star::accessibility::XAccessible,
+ ::com::sun::star::accessibility::XAccessibleComponent,
+ ::com::sun::star::accessibility::XAccessibleContext,
+ ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
+ ::com::sun::star::accessibility::XAccessibleSelection,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::lang::XServiceName >
+ SvxGraphCtrlAccessibleContext_Base;
+
+class SvxGraphCtrlAccessibleContext : public SvxGraphCtrlAccessibleContext_Base, ::comphelper::OBaseMutex, SfxListener, ::accessibility::IAccessibleViewForwarder
+{
+public:
+ friend class GraphCtrl;
+
+ //===== internal ========================================================
+ SvxGraphCtrlAccessibleContext(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent,
+ GraphCtrl& rRepresentation,
+ const ::rtl::OUString* pName = NULL,
+ const ::rtl::OUString* pDescription = NULL );
+
+ void Notify( SfxBroadcaster& aBC, const SfxHint& aHint );
+
+protected:
+ virtual ~SvxGraphCtrlAccessibleContext();
+public:
+ //===== XAccessible =====================================================
+
+ /// Return the XAccessibleContext.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
+ getAccessibleContext (void) throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XAccessibleComponent ============================================
+
+ virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& rPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocation() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding() throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getForeground (void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getBackground (void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+
+ //===== XAccessibleContext ==============================================
+
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleChild (sal_Int32 nIndex) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleParent (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleDescription (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL getAccessibleRelationSet (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL getAccessibleStateSet (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::lang::Locale SAL_CALL getLocale (void) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
+// virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
+// virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) {}
+
+ //===== XComponent ========================================================
+
+ using ::cppu::WeakAggComponentImplHelperBase::addEventListener;
+ using ::cppu::WeakAggComponentImplHelperBase::removeEventListener;
+
+ //===== XAccessibleEventBroadcaster =====================================
+
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) throw (com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) throw (com::sun::star::uno::RuntimeException);
+
+ //===== XServiceInfo ====================================================
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService (const ::rtl::OUString& sServiceName) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames (void) throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XTypeProvider ===================================================
+
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId (void) throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XServiceName ====================================================
+
+ virtual ::rtl::OUString SAL_CALL getServiceName (void) throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XAccessibleSelection =============================================
+
+ virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL clearAccessibleSelection() throw (::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL selectAllAccessibleChildren() throw (::com::sun::star::uno::RuntimeException );
+ virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ //===== IAccessibleViewforwarder ========================================
+
+ virtual BOOL IsValid (void) const;
+ virtual Rectangle GetVisibleArea() const;
+ virtual Point LogicToPixel (const Point& rPoint) const;
+ virtual Size LogicToPixel (const Size& rSize) const;
+ virtual Point PixelToLogic (const Point& rPoint) const;
+ virtual Size PixelToLogic (const Size& rSize) const;
+
+protected:
+ //===== internals ========================================================
+
+ void checkChildIndex( long nIndexOfChild ) throw (::com::sun::star::lang::IndexOutOfBoundsException );
+ void checkChildIndexOnSelection( long nIndexOfChild ) throw (::com::sun::star::lang::IndexOutOfBoundsException );
+
+public:
+
+ /// Sets the name
+ void setName( const ::rtl::OUString& rName );
+
+ /// Sets the description
+ void setDescription( const ::rtl::OUString& rDescr );
+
+ /** This method is used by the graph control to tell the
+ accessibility object about a new model and view.
+ */
+ void setModelAndView (SdrModel* pModel, SdrView* pView);
+
+private:
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUniqueId( void );
+protected:
+
+ /** Return the object's current bounding box relative to the desktop,
+ i.e in absolute pixel coordinates.
+ @return
+ The returned rectangle is a bounding box of the object given in
+ absolute screen coordinates.
+ @raise DisposedException
+ When the object is already disposed then a
+ <type>DisposedException</type> is thrown.
+ */
+ virtual Rectangle GetBoundingBoxOnScreen(void) throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the parent object.
+ virtual Rectangle GetBoundingBox(void) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL disposing();
+
+private:
+ SdrObject* getSdrObject( sal_Int32 nIndex )
+ throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ void CommitChange (sal_Int16 aEventId, const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue);
+ void FireEvent (const ::com::sun::star::accessibility::AccessibleEventObject& aEvent);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessible( const SdrObject* pObj );
+
+ accessibility::AccessibleShapeTreeInfo maTreeInfo;
+
+ /// Reference to the parent object.
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible> mxParent;
+
+ /** Description of this object. This is not a constant because it can
+ be set from the outside.
+ */
+ ::rtl::OUString msDescription;
+
+ /** Name of this object.
+ */
+ ::rtl::OUString msName;
+
+ /// map of accessible shapes
+ struct SdrObjectCompareLess
+ {
+ bool operator()(const SdrObject* p1, const SdrObject* p2) const
+ {
+ return p1 < p2;
+ }
+ };
+ typedef ::std::map< const SdrObject*, ::accessibility::AccessibleShape*, SdrObjectCompareLess > ShapesMapType;
+ ShapesMapType mxShapes;
+
+ GraphCtrl* mpControl;
+
+ SdrModel* mpModel;
+ SdrPage* mpPage;
+ SdrView* mpView;
+
+ /// client id in the AccessibleEventNotifier queue
+ sal_uInt32 mnClientId;
+
+ sal_Bool mbDisposed;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/charmapacc.hxx b/svx/source/inc/charmapacc.hxx
new file mode 100644
index 000000000000..89ae2592372e
--- /dev/null
+++ b/svx/source/inc/charmapacc.hxx
@@ -0,0 +1,278 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <osl/mutex.hxx>
+#include <tools/list.hxx>
+#include <tools/color.hxx>
+#include <tools/string.hxx>
+#include <vcl/image.hxx>
+#include <rtl/uuid.h>
+#include <comphelper/accessibleselectionhelper.hxx>
+#include <com/sun/star/accessibility/XAccessibleTable.hpp>
+
+#include <vector>
+class SvxShowCharSet;
+
+namespace svx
+{
+ typedef ::cppu::ImplHelper1 < ::com::sun::star::accessibility::XAccessible
+ > OAccessibleHelper_Base_2;
+
+ class SvxShowCharSetAcc;
+ /** The class SvxShowCharSetVirtualAcc is used as a virtual class which contains the table and the scrollbar.
+ In the vcl control, the table and the scrollbar exists in one class. This is not feasible for the accessibility api.
+ */
+ class SvxShowCharSetVirtualAcc : public ::comphelper::OAccessibleComponentHelper,
+ public OAccessibleHelper_Base_2
+ {
+ SvxShowCharSet* mpParent; // the vcl control
+ SvxShowCharSetAcc* m_pTable; // the table, which holds the characters shown by the vcl control
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAcc; // the ref to the table
+ protected:
+ virtual ~SvxShowCharSetVirtualAcc();
+
+ virtual void SAL_CALL disposing();
+
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ) throw (::com::sun::star::uno::RuntimeException);
+ public:
+ SvxShowCharSetVirtualAcc( SvxShowCharSet* pParent );
+
+ // XInterface
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+
+ // XAccessibleComponent
+ virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+ //OAccessibleContextHelper
+ // XAccessibleContext - still waiting to be overwritten
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException) { return this; }
+ virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException);
+
+
+ // call the fireEvent method from the table when it exists.
+ void SAL_CALL fireEvent(
+ const sal_Int16 _nEventId,
+ const ::com::sun::star::uno::Any& _rOldValue,
+ const ::com::sun::star::uno::Any& _rNewValue
+ );
+
+ // simple access methods
+ inline SvxShowCharSetAcc* getTable() const { return m_pTable; }
+ inline SvxShowCharSet* getCharSetControl() const { return mpParent; }
+ };
+
+
+ class SvxShowCharSetItemAcc;
+ // ----------------
+ // - SvxShowCharSetItem -
+ // ----------------
+ /** Simple struct to hold some information about the single items of the table.
+ */
+ struct SvxShowCharSetItem
+ {
+ SvxShowCharSet& mrParent;
+ USHORT mnId;
+ XubString maText;
+ Rectangle maRect;
+ SvxShowCharSetItemAcc* m_pItem;
+ SvxShowCharSetAcc* m_pParent;
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAcc;
+
+ SvxShowCharSetItem( SvxShowCharSet& rParent,SvxShowCharSetAcc* _pParent,USHORT _nPos );
+ ~SvxShowCharSetItem();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > GetAccessible();
+ void ClearAccessible();
+ };
+
+ // -----------------------------------------------------------------------------
+
+ typedef ::cppu::ImplHelper2 < ::com::sun::star::accessibility::XAccessible,
+ ::com::sun::star::accessibility::XAccessibleTable
+ > OAccessibleHelper_Base;
+ // ---------------
+ // - SvxShowCharSetAcc -
+ // ---------------
+ /** The table implemtentation of the vcl control.
+ */
+
+ class SvxShowCharSetAcc : public ::comphelper::OAccessibleSelectionHelper,
+ public OAccessibleHelper_Base
+ {
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > m_aChildren;
+ SvxShowCharSetVirtualAcc* m_pParent; // the virtual parent
+ protected:
+ virtual void SAL_CALL disposing();
+ public:
+ SvxShowCharSetAcc( SvxShowCharSetVirtualAcc* _pParent );
+
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+
+ // XAccessibleComponent
+ virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+
+ //OAccessibleContextHelper
+ // XAccessibleContext - still waiting to be overwritten
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException) { return this; }
+ virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleTable
+ virtual sal_Int32 SAL_CALL getAccessibleRowCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleCaption( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleSummary( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+
+ inline void SAL_CALL fireEvent(
+ const sal_Int16 _nEventId,
+ const ::com::sun::star::uno::Any& _rOldValue,
+ const ::com::sun::star::uno::Any& _rNewValue
+ )
+ {
+ NotifyAccessibleEvent(_nEventId,_rOldValue,_rNewValue);
+ }
+ protected:
+
+ virtual ~SvxShowCharSetAcc();
+
+ // OCommonAccessibleSelection
+ // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
+ virtual sal_Bool
+ implIsSelected( sal_Int32 nAccessibleChildIndex )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
+ virtual void
+ implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ // OCommonAccessibleComponent
+ /// implements the calculation of the bounding rectangle - still waiting to be overwritten
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ) throw (::com::sun::star::uno::RuntimeException);
+ };
+
+ // ----------------
+ // - SvxShowCharSetItemAcc -
+ // ----------------
+ /** The child implementation of the table.
+ */
+ class SvxShowCharSetItemAcc : public ::comphelper::OAccessibleComponentHelper,
+ public OAccessibleHelper_Base_2
+ {
+ private:
+ SvxShowCharSetItem* mpParent;
+ protected:
+ virtual ~SvxShowCharSetItemAcc();
+
+ // OCommonAccessibleComponent
+ /// implements the calculation of the bounding rectangle - still waiting to be overwritten
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL implGetBounds( ) throw (::com::sun::star::uno::RuntimeException);
+ public:
+
+ // XInterface
+ DECLARE_XINTERFACE( )
+ DECLARE_XTYPEPROVIDER( )
+
+ SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent );
+
+ void ParentDestroyed();
+
+ // XAccessibleComponent
+ virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException);
+
+ //OAccessibleContextHelper
+ // XAccessibleContext - still waiting to be overwritten
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException) { return this; }
+
+ virtual sal_Int32 SAL_CALL getForeground( ) throw (::com::sun::star::uno::RuntimeException) { return mpParent->m_pParent->getForeground(); }
+ virtual sal_Int32 SAL_CALL getBackground( ) throw (::com::sun::star::uno::RuntimeException) { return mpParent->m_pParent->getBackground(); }
+
+ inline void SAL_CALL fireEvent(
+ const sal_Int16 _nEventId,
+ const ::com::sun::star::uno::Any& _rOldValue,
+ const ::com::sun::star::uno::Any& _rNewValue
+ )
+ {
+ NotifyAccessibleEvent(_nEventId,_rOldValue,_rNewValue);
+ }
+ };
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/clonelist.hxx b/svx/source/inc/clonelist.hxx
new file mode 100644
index 000000000000..f2522003454b
--- /dev/null
+++ b/svx/source/inc/clonelist.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _CLONELIST_HXX_
+#define _CLONELIST_HXX_
+
+#include <sal/types.h>
+#include <tools/list.hxx>
+
+// predeclarations
+class SdrObject;
+
+// #i13033#
+// New mechanism to hold a ist of all original and cloned objects for later
+// re-creating the connections for contained connectors
+class CloneList
+{
+ List maOriginalList;
+ List maCloneList;
+
+public:
+ CloneList();
+ ~CloneList();
+
+ void AddPair(const SdrObject* pOriginal, SdrObject* pClone);
+ sal_uInt32 Count() const;
+
+ const SdrObject* GetOriginal(sal_uInt32 nIndex) const;
+ SdrObject* GetClone(sal_uInt32 nIndex) const;
+
+ void CopyConnections() const;
+};
+
+#endif // _CLONELIST_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/datalistener.hxx b/svx/source/inc/datalistener.hxx
new file mode 100644
index 000000000000..b41427489d9c
--- /dev/null
+++ b/svx/source/inc/datalistener.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_DATALISTENER_HXX
+#define _SVX_DATALISTENER_HXX
+
+#include <cppuhelper/implbase3.hxx>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/frame/XFrameActionListener.hpp>
+#include <com/sun/star/xml/dom/events/XEventListener.hpp>
+
+//............................................................................
+namespace svxform
+{
+//............................................................................
+
+ class DataNavigatorWindow;
+
+ typedef cppu::WeakImplHelper3<
+ com::sun::star::container::XContainerListener,
+ com::sun::star::frame::XFrameActionListener,
+ com::sun::star::xml::dom::events::XEventListener > DataListener_t;
+
+ class DataListener : public DataListener_t
+ {
+ private:
+ DataNavigatorWindow* m_pNaviWin;
+
+ public:
+ DataListener( DataNavigatorWindow* pNaviWin );
+
+ protected:
+ ~DataListener();
+
+ public:
+ // XContainerListener
+ virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XFrameActionListener
+ virtual void SAL_CALL frameAction( const ::com::sun::star::frame::FrameActionEvent& Action ) throw (::com::sun::star::uno::RuntimeException);
+
+ // xml::dom::events::XEventListener
+ virtual void SAL_CALL handleEvent( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::events::XEvent >& evt ) throw (::com::sun::star::uno::RuntimeException);
+
+ // lang::XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+ };
+
+//............................................................................
+} // namespace svxform
+//............................................................................
+
+#endif // #ifndef _SVX_DATALISTENER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/datanavi.hrc b/svx/source/inc/datanavi.hrc
new file mode 100644
index 000000000000..fac792e7d10f
--- /dev/null
+++ b/svx/source/inc/datanavi.hrc
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * 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 _SVX_DATANAVI_HRC
+#define _SVX_DATANAVI_HRC
+
+// global
+#define FL_DATANAV_BTN 100
+#define BTN_DATANAV_OK 101
+#define BTN_DATANAV_ESC 102
+#define BTN_DATANAV_HELP 103
+
+// class XFormsInstancePage
+// Controls
+#define TB_ITEMS 10
+#define LB_ITEMS 11
+// Menu items
+#define MID_INSERT_CONTROL 100
+// ToolBox items
+#define TBI_ITEM_ADD 10
+#define TBI_ITEM_ADD_ELEMENT 11
+#define TBI_ITEM_ADD_ATTRIBUTE 12
+#define TBI_ITEM_EDIT 13
+#define TBI_ITEM_REMOVE 14
+// ImageLists
+#define IL_TBX_BMPS 20
+#define IL_TBX_BMPS_HC 21
+// ImageIndexes
+#define IID_ITEM_ADD 1
+#define IID_ITEM_ADD_ELEMENT 2
+#define IID_ITEM_ADD_ATTRIBUTE 3
+#define IID_ITEM_EDIT 4
+#define IID_ITEM_REMOVE 5
+
+// class DataNavigatorWindow
+// Controls
+#define LB_MODELS 10
+#define MB_MODELS 11
+#define TC_ITEMS 12
+#define MB_INSTANCES 13
+// MenuItems
+#define MID_MODELS_ADD 10
+#define MID_MODELS_EDIT 11
+#define MID_MODELS_REMOVE 12
+#define MID_INSTANCES_ADD 20
+#define MID_INSTANCES_EDIT 21
+#define MID_INSTANCES_REMOVE 22
+#define MID_SHOW_DETAILS 30
+// TabPage Ids
+#define TID_SUBMISSION 10
+#define TID_BINDINGS 11
+#define TID_INSTANCE 12
+// ImageLists
+#define IL_ITEM_BMPS 30
+#define IL_ITEM_BMPS_HC 31
+// ImageIndexes
+#define IID_GROUP_CLOSED 1
+#define IID_GROUP_OPEN 2
+#define IID_ELEMENT 3
+#define IID_ATTRIBUTE 4
+#define IID_TEXT 5
+#define IID_OTHER 6
+
+// class AddDataItemDialog
+#define FL_ITEM 10
+#define FT_NAME 11
+#define ED_NAME 12
+#define FT_DEFAULT 13
+#define ED_DEFAULT 14
+#define PB_DEFAULT 15
+#define FL_SETTINGS 16
+#define FT_DATATYPE 17
+#define LB_DATATYPE 18
+#define CB_REQUIRED 19
+#define PB_REQUIRED 20
+#define CB_RELEVANT 21
+#define PB_RELEVANT 22
+#define CB_CONSTRAINT 23
+#define PB_CONSTRAINT 24
+#define CB_READONLY 25
+#define PB_READONLY 26
+#define CB_CALCULATE 27
+#define PB_CALCULATE 28
+
+#define STR_FIXEDLINE_ELEMENT 10
+#define STR_FIXEDLINE_ATTRIBUTE 11
+#define STR_FIXEDLINE_BINDING 12
+#define STR_FIXEDTEXT_BINDING 13
+
+// class AddConditionDialog
+#define FT_CONDITION 10
+#define ED_CONDITION 11
+#define FT_RESULT 12
+#define FT_RESULT_PREVIEW 13
+#define PB_EDIT_NAMESPACES 14
+
+// class NamespaceItemDialog
+#define FT_NAMESPACES 10
+#define LB_NAMESPACES 11
+#define PB_ADD_NAMESPACE 12
+#define PB_EDIT_NAMESPACE 13
+#define PB_DELETE_NAMESPACE 14
+
+#define STR_HEADER_PREFIX 10
+#define STR_HEADER_URL 11
+
+// class ManageNamespaceDialog
+#define FT_PREFIX 10
+#define ED_PREFIX 11
+#define FT_URL 12
+#define ED_URL 13
+
+#define STR_EDIT_TEXT 10
+
+// class AddSubmissionDialog
+#define FL_SUBMISSION 10
+#define FT_SUBMIT_NAME 11
+#define ED_SUBMIT_NAME 12
+#define FT_SUBMIT_ACTION 13
+#define ED_SUBMIT_ACTION 14
+#define FT_SUBMIT_METHOD 15
+#define LB_SUBMIT_METHOD 16
+#define FT_SUBMIT_REF 17
+#define ED_SUBMIT_REF 18
+#define PB_SUBMIT_REF 19
+#define FT_SUBMIT_BIND 20
+#define LB_SUBMIT_BIND 21
+#define FT_SUBMIT_REPLACE 22
+#define LB_SUBMIT_REPLACE 23
+
+#define STR_METHOD_POST 10
+#define STR_METHOD_PUT 11
+#define STR_METHOD_GET 12
+#define STR_REPLACE_NONE 13
+#define STR_REPLACE_INST 14
+#define STR_REPLACE_DOC 15
+
+// class AddModelDialog
+#define FL_MODEL 10
+#define FT_MODEL_NAME 11
+#define ED_MODEL_NAME 12
+
+// class AddInstanceDialog
+#define FL_INSTANCE 10
+#define FT_INST_NAME 11
+#define ED_INST_NAME 12
+#define FT_INST_URL 13
+#define ED_INST_URL 14
+#define PB_FILEPICKER 15
+#define CB_INST_LINKINST 16
+
+// class AddModelDialog
+#define CB_MODIFIES_DOCUMENT 1
+
+#endif //_SVX_DATANAVI_HRC
+
diff --git a/svx/source/inc/datanavi.hxx b/svx/source/inc/datanavi.hxx
new file mode 100644
index 000000000000..18aad9bfd65b
--- /dev/null
+++ b/svx/source/inc/datanavi.hxx
@@ -0,0 +1,603 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_DATANAVI_HXX
+#define _SVX_DATANAVI_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/menubtn.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/tabctrl.hxx>
+#include <vcl/tabpage.hxx>
+#include <vcl/toolbox.hxx>
+#include <svtools/inettbc.hxx>
+#include <svtools/svmedit.hxx>
+#include <svtools/svtreebx.hxx>
+#include <sfx2/dockwin.hxx>
+#include <sfx2/ctrlitem.hxx>
+#include <svx/simptabl.hxx>
+#include <rtl/ref.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/xforms/XFormsUIHelper1.hpp>
+#include <com/sun/star/xforms/XModel.hpp>
+#include <com/sun/star/xforms/XSubmission.hpp>
+#include <com/sun/star/xml/dom/XNode.hpp>
+#include <com/sun/star/xml/dom/events/XEventTarget.hpp>
+
+#include "datalistener.hxx"
+#include <vector>
+
+// forward ---------------------------------------------------------------
+
+class FmFormShell;
+
+//========================================================================
+//............................................................................
+namespace svxform
+{
+//............................................................................
+
+ enum DataGroupType
+ {
+ DGTUnknown = 0,
+ DGTInstance,
+ DGTSubmission,
+ DGTBinding
+ };
+
+ enum DataItemType
+ {
+ DITNone = 0,
+ DITText,
+ DITAttribute,
+ DITElement,
+ DITBinding
+ };
+
+ struct ItemNode;
+ class XFormsPage;
+ class DataNavigatorWindow;
+ class AddInstanceDialog;
+
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::xforms::XFormsUIHelper1 > XFormsUIHelper1_ref;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::dom::XNode > XNode_ref;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > XPropertySet_ref;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::xforms::XModel > XModel_ref;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::container::XContainer > XContainer_ref;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::container::XNameContainer > XNameContainer_ref;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XFrame > XFrame_ref;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XModel > XFrameModel_ref;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::dom::events::XEventTarget > XEventTarget_ref;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::xforms::XSubmission > XSubmission_ref;
+
+ typedef ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue > PropertyValue_seq;
+
+ typedef std::vector< XContainer_ref > ContainerList;
+ typedef std::vector< XEventTarget_ref > EventTargetList;
+
+ //========================================================================
+ class DataTreeListBox : public SvTreeListBox
+ {
+ private:
+ XFormsPage* m_pXFormsPage;
+ DataGroupType m_eGroup;
+
+ protected:
+ using SvTreeListBox::ExecuteDrop;
+
+ public:
+ DataTreeListBox( XFormsPage* pPage, DataGroupType _eGroup, const ResId& rResId );
+ ~DataTreeListBox();
+
+ virtual PopupMenu* CreateContextMenu( void );
+ virtual void ExcecuteContextMenuAction( USHORT _nSelectedPopupEntry );
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+ void DeleteAndClear();
+ void RemoveEntry( SvLBoxEntry* _pEntry );
+ };
+
+ //========================================================================
+ class XFormsPage : public TabPage
+ {
+ private:
+ ToolBox m_aToolBox;
+ DataTreeListBox m_aItemList;
+
+ XFormsUIHelper1_ref m_xUIHelper;
+
+ DataNavigatorWindow* m_pNaviWin;
+ bool m_bHasModel;
+ DataGroupType m_eGroup;
+ ImageList m_TbxImageList;
+ ImageList m_TbxHCImageList;
+ // these strings are not valid on the Submission and Binding Page
+ // mb: furthermore these are properties of an instance, thus
+ // it would be much better to get/set them through the UIHelper
+ // interface.
+ String m_sInstanceName;
+ String m_sInstanceURL;
+ bool m_bLinkOnce;
+
+ DECL_LINK( TbxSelectHdl, ToolBox * );
+ DECL_LINK( ItemSelectHdl, DataTreeListBox * );
+
+ void AddChildren( SvLBoxEntry* _pParent,
+ const ImageList& _rImgLst,
+ const XNode_ref& _xNode );
+ bool DoToolBoxAction( USHORT _nToolBoxID );
+ SvLBoxEntry* AddEntry( ItemNode* _pNewNode, bool _bIsElement );
+ SvLBoxEntry* AddEntry( const XPropertySet_ref& _rPropSet );
+ void EditEntry( const XPropertySet_ref& _rPropSet );
+ bool RemoveEntry();
+
+ protected:
+ virtual long Notify( NotifyEvent& rNEvt );
+
+ public:
+ XFormsPage( Window* pParent, DataNavigatorWindow* _pNaviWin, DataGroupType _eGroup );
+ ~XFormsPage();
+
+ virtual void Resize();
+
+ inline bool HasModel() const { return m_bHasModel; }
+ String SetModel( const XModel_ref& _xModel, USHORT _nPagePos );
+ void ClearModel();
+ String LoadInstance( const PropertyValue_seq& _xPropSeq,
+ const ImageList& _rImgLst );
+
+ bool DoMenuAction( USHORT _nMenuID );
+ void EnableMenuItems( Menu* _pMenu );
+
+ inline SvLBoxEntry* GetSelectedItem() const { return m_aItemList.FirstSelected(); }
+ inline const String& GetInstanceName() const { return m_sInstanceName; }
+ inline const String& GetInstanceURL() const { return m_sInstanceURL; }
+ inline bool GetLinkOnce() const { return m_bLinkOnce; }
+ inline void SetInstanceName( const String &name ) { m_sInstanceName=name; }
+ inline void SetInstanceURL( const String &url ) { m_sInstanceURL=url; }
+ inline void SetLinkOnce( bool bLinkOnce ) { m_bLinkOnce=bLinkOnce; }
+
+ typedef com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> XPropertySet_t;
+ typedef com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode> XNode_t;
+
+ inline XPropertySet_t GetBindingForNode( const XNode_t &xNode ) { return m_xUIHelper->getBindingForNode(xNode,true); }
+ inline String GetServiceNameForNode( const XNode_t &xNode ) { return m_xUIHelper->getDefaultServiceNameForNode(xNode); }
+ inline XFormsUIHelper1_ref GetXFormsHelper( void ) const { return m_xUIHelper; }
+ };
+
+ //========================================================================
+
+ typedef std::vector< XFormsPage* > PageList;
+ typedef ::rtl::Reference < DataListener > DataListener_ref;
+
+ class DataNavigatorWindow : public Window
+ {
+ private:
+
+ ListBox m_aModelsBox;
+ MenuButton m_aModelBtn;
+ TabControl m_aTabCtrl;
+ MenuButton m_aInstanceBtn;
+
+ XFormsPage* m_pInstPage;
+ XFormsPage* m_pSubmissionPage;
+ XFormsPage* m_pBindingPage;
+
+ long m_nMinWidth;
+ long m_nMinHeight;
+ long m_nBorderHeight;
+ USHORT m_nLastSelectedPos;
+ bool m_bShowDetails;
+ bool m_bIsNotifyDisabled;
+ Size m_a2Size;
+ Size m_a3Size;
+ ImageList m_aItemImageList;
+ ImageList m_aItemHCImageList;
+ PageList m_aPageList;
+ ContainerList m_aContainerList;
+ EventTargetList m_aEventTargetList;
+ Timer m_aUpdateTimer;
+
+ DataListener_ref m_xDataListener;
+ XNameContainer_ref m_xDataContainer;
+ XFrame_ref m_xFrame;
+ XFrameModel_ref m_xFrameModel;
+
+ DECL_LINK( ModelSelectHdl, ListBox * );
+ DECL_LINK( MenuSelectHdl, MenuButton * );
+ DECL_LINK( MenuActivateHdl, MenuButton * );
+ DECL_LINK( ActivatePageHdl, TabControl* );
+ DECL_LINK( UpdateHdl, Timer* );
+
+ XFormsPage* GetCurrentPage( USHORT& rCurId );
+ void LoadModels();
+ void SetPageModel();
+ void ClearAllPageModels( bool bClearPages );
+ void InitPages();
+ void CreateInstancePage( const PropertyValue_seq& _xPropSeq );
+ bool HasFirstInstancePage() const;
+ USHORT GetNewPageId() const;
+
+ protected:
+ virtual void Resize();
+
+ public:
+ DataNavigatorWindow( Window* pParent, SfxBindings* pBindings );
+ ~DataNavigatorWindow();
+
+ void SetDocModified();
+ void NotifyChanges( bool _bLoadAll = false );
+ void AddContainerBroadcaster( const XContainer_ref& xContainer );
+ void AddEventBroadcaster( const XEventTarget_ref& xTarget );
+ void RemoveBroadcaster();
+
+ inline const ImageList& GetItemImageList() const { return m_aItemImageList; }
+ inline const ImageList& GetItemHCImageList() const { return m_aItemHCImageList; }
+ inline bool IsShowDetails() const { return m_bShowDetails; }
+ inline void DisableNotify( bool _bDisable ) { m_bIsNotifyDisabled = _bDisable; }
+ };
+
+ //========================================================================
+ class DataNavigator : public SfxDockingWindow, public SfxControllerItem
+ {
+ private:
+ DataNavigatorWindow m_aDataWin;
+
+ protected:
+ virtual void Resize();
+ virtual sal_Bool Close();
+ virtual void GetFocus();
+ virtual Size CalcDockingSize( SfxChildAlignment );
+ virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment );
+
+ public:
+ DataNavigator( SfxBindings* pBindings, SfxChildWindow* pMgr, Window* pParent );
+ virtual ~DataNavigator();
+
+ using Window::Update;
+ using SfxDockingWindow::StateChanged;
+
+ void Update( FmFormShell* pFormShell );
+ void StateChanged( sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+ };
+
+ //========================================================================
+ class SVX_DLLPUBLIC DataNavigatorManager : public SfxChildWindow
+ {
+ public:
+ SVX_DLLPRIVATE DataNavigatorManager( Window* pParent, sal_uInt16 nId,
+ SfxBindings* pBindings, SfxChildWinInfo* pInfo );
+ SFX_DECL_CHILDWINDOW( DataNavigatorManager );
+ };
+
+ //========================================================================
+ class AddDataItemDialog : public ModalDialog
+ {
+ private:
+
+ FixedLine m_aItemFL;
+ FixedText m_aNameFT;
+ Edit m_aNameED;
+ FixedText m_aDefaultFT;
+ Edit m_aDefaultED;
+ PushButton m_aDefaultBtn;
+
+ FixedLine m_aSettingsFL;
+ FixedText m_aDataTypeFT;
+ ListBox m_aDataTypeLB;
+
+ CheckBox m_aRequiredCB;
+ PushButton m_aRequiredBtn;
+ CheckBox m_aRelevantCB;
+ PushButton m_aRelevantBtn;
+ CheckBox m_aConstraintCB;
+ PushButton m_aConstraintBtn;
+ CheckBox m_aReadonlyCB;
+ PushButton m_aReadonlyBtn;
+ CheckBox m_aCalculateCB;
+ PushButton m_aCalculateBtn;
+
+ FixedLine m_aButtonsFL;
+ OKButton m_aOKBtn;
+ CancelButton m_aEscBtn;
+ HelpButton m_aHelpBtn;
+
+ XFormsUIHelper1_ref m_xUIHelper;
+ XPropertySet_ref m_xBinding;
+ XPropertySet_ref m_xTempBinding;
+
+ ItemNode* m_pItemNode;
+ DataItemType m_eItemType;
+ String m_sFL_Element;
+ String m_sFL_Attribute;
+ String m_sFL_Binding;
+ String m_sFT_BindingExp;
+
+ DECL_LINK( CheckHdl, CheckBox * );
+ DECL_LINK( ConditionHdl, PushButton * );
+ DECL_LINK( OKHdl, OKButton * );
+
+ void InitDialog();
+ void InitFromNode();
+ void InitDataTypeBox();
+
+ public:
+ AddDataItemDialog(
+ Window* pParent, ItemNode* _pNode, const XFormsUIHelper1_ref& _rUIHelper );
+ ~AddDataItemDialog();
+
+ void InitText( DataItemType _eType );
+ };
+
+ //========================================================================
+ class AddConditionDialog : public ModalDialog
+ {
+ private:
+ FixedText m_aConditionFT;
+ MultiLineEdit m_aConditionED;
+ FixedText m_aResultFT;
+ FixedText m_aResultWin;
+ PushButton m_aEditNamespacesBtn;
+ FixedLine m_aButtonsFL;
+ OKButton m_aOKBtn;
+ CancelButton m_aEscBtn;
+ HelpButton m_aHelpBtn;
+
+ Timer m_aResultTimer;
+ ::rtl::OUString m_sPropertyName;
+
+ XFormsUIHelper1_ref m_xUIHelper;
+ XPropertySet_ref m_xBinding;
+
+ DECL_LINK( ModifyHdl, MultiLineEdit * );
+ DECL_LINK( ResultHdl, Timer * );
+ DECL_LINK( EditHdl, PushButton * );
+ DECL_LINK( OKHdl, OKButton * );
+
+ public:
+ AddConditionDialog( Window* pParent,
+ const ::rtl::OUString& _rPropertyName, const XPropertySet_ref& _rBinding );
+ ~AddConditionDialog();
+
+ inline XFormsUIHelper1_ref GetUIHelper() const { return m_xUIHelper; }
+ inline String GetCondition() const { return m_aConditionED.GetText(); }
+ inline void SetCondition( const String& _rCondition );
+ };
+
+ inline void AddConditionDialog::SetCondition( const String& _rCondition )
+ {
+ m_aConditionED.SetText( _rCondition );
+ m_aResultTimer.Start();
+ }
+
+ //========================================================================
+ class NamespaceItemDialog : public ModalDialog
+ {
+ private:
+ typedef std::vector< ::rtl::OUString > PrefixList;
+
+ FixedText m_aNamespacesFT;
+ SvxSimpleTable m_aNamespacesList;
+ PushButton m_aAddNamespaceBtn;
+ PushButton m_aEditNamespaceBtn;
+ PushButton m_aDeleteNamespaceBtn;
+ FixedLine m_aButtonsFL;
+ OKButton m_aOKBtn;
+ CancelButton m_aEscBtn;
+ HelpButton m_aHelpBtn;
+
+ AddConditionDialog* m_pConditionDlg;
+ PrefixList m_aRemovedList;
+
+ XNameContainer_ref& m_rNamespaces;
+
+ DECL_LINK( SelectHdl, SvxSimpleTable * );
+ DECL_LINK( ClickHdl, PushButton * );
+ DECL_LINK( OKHdl, OKButton * );
+
+ void LoadNamespaces();
+
+ public:
+ NamespaceItemDialog( AddConditionDialog* pParent, XNameContainer_ref& _rContainer );
+ ~NamespaceItemDialog();
+ };
+
+ //========================================================================
+ class ManageNamespaceDialog : public ModalDialog
+ {
+ private:
+ FixedText m_aPrefixFT;
+ Edit m_aPrefixED;
+ FixedText m_aUrlFT;
+ Edit m_aUrlED;
+ FixedLine m_aButtonsFL;
+ OKButton m_aOKBtn;
+ CancelButton m_aEscBtn;
+ HelpButton m_aHelpBtn;
+
+ AddConditionDialog* m_pConditionDlg;
+
+ DECL_LINK( OKHdl, OKButton * );
+
+ public:
+ ManageNamespaceDialog( Window* pParent, AddConditionDialog* _pCondDlg, bool _bIsEdit );
+ ~ManageNamespaceDialog();
+
+ inline void SetNamespace( const String& _rPrefix, const String& _rURL );
+ inline String GetPrefix() const { return m_aPrefixED.GetText(); }
+ inline String GetURL() const { return m_aUrlED.GetText(); }
+ };
+
+ void ManageNamespaceDialog::SetNamespace( const String& _rPrefix, const String& _rURL )
+ {
+ m_aPrefixED.SetText( _rPrefix );
+ m_aUrlED.SetText( _rURL );
+ }
+
+ //========================================================================
+ class AddSubmissionDialog : public ModalDialog
+ {
+ private:
+ FixedLine m_aSubmissionFL;
+ FixedText m_aNameFT;
+ Edit m_aNameED;
+ FixedText m_aActionFT;
+ Edit m_aActionED;
+ FixedText m_aMethodFT;
+ ListBox m_aMethodLB;
+ FixedText m_aRefFT;
+ Edit m_aRefED;
+ PushButton m_aRefBtn;
+ FixedText m_aBindFT;
+ ListBox m_aBindLB;
+ FixedText m_aReplaceFT;
+ ListBox m_aReplaceLB;
+
+ FixedLine m_aButtonsFL;
+ OKButton m_aOKBtn;
+ CancelButton m_aEscBtn;
+ HelpButton m_aHelpBtn;
+
+ ItemNode* m_pItemNode;
+
+ XFormsUIHelper1_ref m_xUIHelper;
+ XSubmission_ref m_xNewSubmission;
+ XPropertySet_ref m_xSubmission;
+ XPropertySet_ref m_xTempBinding;
+ XPropertySet_ref m_xCreatedBinding;
+
+ DECL_LINK( RefHdl, PushButton * );
+ DECL_LINK( OKHdl, OKButton * );
+
+ void FillAllBoxes();
+
+ public:
+ AddSubmissionDialog( Window* pParent, ItemNode* _pNode,
+ const XFormsUIHelper1_ref& _rUIHelper );
+ ~AddSubmissionDialog();
+
+ inline const XSubmission_ref& GetNewSubmission() const { return m_xNewSubmission; }
+ };
+
+ //========================================================================
+ class AddModelDialog : public ModalDialog
+ {
+ private:
+ FixedLine m_aModelFL;
+ FixedText m_aNameFT;
+ Edit m_aNameED;
+ CheckBox m_aModifyCB;
+ FixedLine m_aButtonsFL;
+ OKButton m_aOKBtn;
+ CancelButton m_aEscBtn;
+ HelpButton m_aHelpBtn;
+
+ public:
+ AddModelDialog( Window* pParent, bool _bEdit );
+ ~AddModelDialog();
+
+ inline String GetName() const { return m_aNameED.GetText(); }
+ inline void SetName( const String& _rName ) { m_aNameED.SetText( _rName );}
+
+ inline bool GetModifyDoc() const { return bool( m_aModifyCB.IsChecked() ); }
+ inline void SetModifyDoc( const bool _bModify ) { m_aModifyCB.Check( _bModify ); }
+ };
+
+ //========================================================================
+ class AddInstanceDialog : public ModalDialog
+ {
+ private:
+ FixedLine m_aInstanceFL;
+ FixedText m_aNameFT;
+ Edit m_aNameED;
+ FixedText m_aURLFT;
+ SvtURLBox m_aURLED;
+ PushButton m_aFilePickerBtn;
+ CheckBox m_aLinkInstanceCB;
+ FixedLine m_aButtonsFL;
+ OKButton m_aOKBtn;
+ CancelButton m_aEscBtn;
+ HelpButton m_aHelpBtn;
+
+ String m_sAllFilterName;
+
+ DECL_LINK( FilePickerHdl, PushButton * );
+
+ public:
+ AddInstanceDialog( Window* pParent, bool _bEdit );
+ ~AddInstanceDialog();
+
+ inline void SetRenameMode();
+ inline String GetName() const { return m_aNameED.GetText(); }
+ inline void SetName( const String& _rName ) { m_aNameED.SetText( _rName );}
+ inline String GetURL() const { return m_aURLED.GetText(); }
+ inline void SetURL( const String& _rURL ) { m_aURLED.SetText( _rURL );}
+ inline bool IsLinkInstance() const { return ( m_aLinkInstanceCB.IsChecked() != FALSE ); }
+ inline void SetLinkInstance( bool _bLink ) { m_aLinkInstanceCB.Check( _bLink != false ); }
+ };
+
+ inline void AddInstanceDialog::SetRenameMode()
+ {
+ m_aURLFT.Disable();
+ m_aURLED.Disable();
+ m_aFilePickerBtn.Disable();
+ m_aLinkInstanceCB.Disable();
+ }
+
+ //========================================================================
+ class LinkedInstanceWarningBox : public MessBox
+ {
+ public:
+ LinkedInstanceWarningBox( Window* pParent );
+ };
+
+//............................................................................
+} // namespace svxform
+//............................................................................
+
+#endif // _SVX_DATANAVI_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/delayedevent.hxx b/svx/source/inc/delayedevent.hxx
new file mode 100644
index 000000000000..8f85a5208721
--- /dev/null
+++ b/svx/source/inc/delayedevent.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * 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 SVX_DELAYEDLINK_HXX
+#define SVX_DELAYEDLINK_HXX
+
+#include <tools/link.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= DelayedEvent
+ //====================================================================
+ /** small class which encapsulates posting a Link instance as ApplicationUserEvent
+
+ No thread safety at all here, just a little saving of code to type multiple times
+ */
+ class DelayedEvent
+ {
+ public:
+ DelayedEvent( const Link& _rHandler )
+ :m_aHandler( _rHandler )
+ ,m_nEventId( 0 )
+ {
+ }
+
+ ~DelayedEvent()
+ {
+ CancelPendingCall();
+ }
+
+ /** calls the handler asynchronously
+
+ If there's already a call pending, this previous call is cancelled.
+ */
+ void Call( void* _pArg = NULL );
+
+ /** cancels a call which is currently pending
+
+ If no call is currently pending, then this is ignored.
+ */
+ void CancelPendingCall();
+
+ private:
+ Link m_aHandler;
+ ULONG m_nEventId;
+
+ private:
+ DECL_LINK( OnCall, void* );
+
+ private:
+ DelayedEvent(); // never implemented
+ DelayedEvent( const DelayedEvent& ); // never implemented
+ DelayedEvent& operator=( const DelayedEvent& ); // never implemented
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_DELAYEDLINK_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/docrecovery.hxx b/svx/source/inc/docrecovery.hxx
new file mode 100644
index 000000000000..bd6f44002b9d
--- /dev/null
+++ b/svx/source/inc/docrecovery.hxx
@@ -0,0 +1,972 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_DOCRECOVERY_HXX
+#define _SVX_DOCRECOVERY_HXX
+
+#include <vcl/tabpage.hxx>
+#include <vcl/tabdlg.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/svmedit2.hxx>
+#include <svtools/svtreebx.hxx>
+#include <svx/simptabl.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+//===============================================
+// const
+
+#define RECOVERY_CMDPART_PROTOCOL ::rtl::OUString::createFromAscii("vnd.sun.star.autorecovery:")
+
+#define RECOVERY_CMDPART_DO_PREPARE_EMERGENCY_SAVE ::rtl::OUString::createFromAscii("/doPrepareEmergencySave" )
+#define RECOVERY_CMDPART_DO_EMERGENCY_SAVE ::rtl::OUString::createFromAscii("/doEmergencySave" )
+#define RECOVERY_CMDPART_DO_RECOVERY ::rtl::OUString::createFromAscii("/doAutoRecovery" )
+#define RECOVERY_CMDPART_DO_CRASHREPORT ::rtl::OUString::createFromAscii("/doCrashReport" )
+#define RECOVERY_CMDPART_DO_ENTRY_BACKUP ::rtl::OUString::createFromAscii("/doEntryBackup" )
+#define RECOVERY_CMDPART_DO_ENTRY_CLEANUP ::rtl::OUString::createFromAscii("/doEntryCleanUp" )
+
+#define RECOVERY_CMD_DO_PREPARE_EMERGENCY_SAVE ::rtl::OUString::createFromAscii("vnd.sun.star.autorecovery:/doPrepareEmergencySave")
+#define RECOVERY_CMD_DO_EMERGENCY_SAVE ::rtl::OUString::createFromAscii("vnd.sun.star.autorecovery:/doEmergencySave" )
+#define RECOVERY_CMD_DO_RECOVERY ::rtl::OUString::createFromAscii("vnd.sun.star.autorecovery:/doAutoRecovery" )
+#define RECOVERY_CMD_DO_CRASHREPORT ::rtl::OUString::createFromAscii("vnd.sun.star.autorecovery:/doCrashReport" )
+#define RECOVERY_CMD_DO_ENTRY_BACKUP ::rtl::OUString::createFromAscii("vnd.sun.star.autorecovery:/doEntryBackup" )
+#define RECOVERY_CMD_DO_ENTRY_CLEANUP ::rtl::OUString::createFromAscii("vnd.sun.star.autorecovery:/doEntryCleanUp" )
+
+#define SERVICENAME_PROGRESSFACTORY ::rtl::OUString::createFromAscii("com.sun.star.task.StatusIndicatorFactory")
+#define SERVICENAME_URLTRANSFORMER ::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )
+#define SERVICENAME_RECOVERYCORE ::rtl::OUString::createFromAscii("com.sun.star.frame.AutoRecovery" )
+#define SERVICENAME_FOLDERPICKER ::rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.FolderPicker" )
+#define SERVICENAME_DESKTOP ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop" )
+
+#define PROP_PARENTWINDOW ::rtl::OUString::createFromAscii("Window" )
+#define PROP_STATUSINDICATOR ::rtl::OUString::createFromAscii("StatusIndicator" )
+#define PROP_DISPATCHASYNCHRON ::rtl::OUString::createFromAscii("DispatchAsynchron")
+#define PROP_SAVEPATH ::rtl::OUString::createFromAscii("SavePath" )
+#define PROP_ENTRYID ::rtl::OUString::createFromAscii("EntryID" )
+#define PROP_ALLOWPARENTSHOW ::rtl::OUString::createFromAscii("AllowParentShow" )
+
+#define STATEPROP_ID ::rtl::OUString::createFromAscii("ID" )
+#define STATEPROP_STATE ::rtl::OUString::createFromAscii("DocumentState")
+#define STATEPROP_ORGURL ::rtl::OUString::createFromAscii("OriginalURL" )
+#define STATEPROP_TEMPURL ::rtl::OUString::createFromAscii("TempURL" )
+#define STATEPROP_FACTORYURL ::rtl::OUString::createFromAscii("FactoryURL" )
+#define STATEPROP_TEMPLATEURL ::rtl::OUString::createFromAscii("TemplateURL" )
+#define STATEPROP_TITLE ::rtl::OUString::createFromAscii("Title" )
+#define STATEPROP_MODULE ::rtl::OUString::createFromAscii("Module" )
+
+#define RECOVERY_OPERATIONSTATE_START ::rtl::OUString::createFromAscii("start" )
+#define RECOVERY_OPERATIONSTATE_STOP ::rtl::OUString::createFromAscii("stop" )
+#define RECOVERY_OPERATIONSTATE_UPDATE ::rtl::OUString::createFromAscii("update")
+
+#define DLG_RET_UNKNOWN -1
+#define DLG_RET_OK 1
+#define DLG_RET_CANCEL 0
+#define DLG_RET_BACK 100
+#define DLG_RET_OK_AUTOLUNCH 101
+
+//===============================================
+// namespace
+
+namespace svx{
+ namespace DocRecovery{
+
+#ifdef css
+# error "Who uses css? I need it as temp. namespace alias!"
+#else
+# define css ::com::sun::star
+#endif
+
+//===============================================
+enum EDocStates
+{
+ /* TEMP STATES */
+
+ /// default state, if a document was new created or loaded
+ E_UNKNOWN = 0,
+ /// modified against the original file
+ E_MODIFIED = 1,
+ /// an active document can be postponed to be saved later.
+ E_POSTPONED = 2,
+ /// was already handled during one AutoSave/Recovery session.
+ E_HANDLED = 4,
+ /** an action was started (saving/loading) ... Can be interesting later if the process may be was interrupted by an exception. */
+ E_TRY_SAVE = 8,
+ E_TRY_LOAD_BACKUP = 16,
+ E_TRY_LOAD_ORIGINAL = 32,
+
+ /* FINAL STATES */
+
+ /// the Auto/Emergency saved document isnt useable any longer
+ E_DAMAGED = 64,
+ /// the Auto/Emergency saved document isnt realy up-to-date (some changes can be missing)
+ E_INCOMPLETE = 128,
+ /// the Auto/Emergency saved document was processed successfully
+ E_SUCCEDED = 512
+};
+
+//===============================================
+enum ERecoveryState
+{
+ E_SUCCESSFULLY_RECOVERED,
+ E_ORIGINAL_DOCUMENT_RECOVERED,
+ E_RECOVERY_FAILED,
+ E_RECOVERY_IS_IN_PROGRESS,
+ E_NOT_RECOVERED_YET
+};
+
+//===============================================
+struct TURLInfo
+{
+ public:
+
+ /// unique ID, which is specified by the underlying autorecovery core!
+ sal_Int32 ID;
+
+ /// the full qualified document URL
+ ::rtl::OUString OrgURL;
+
+ /// the full qualified URL of the temp. file (if it's exists)
+ ::rtl::OUString TempURL;
+
+ /// a may be existing factory URL (e.g. for untitled documents)
+ ::rtl::OUString FactoryURL;
+
+ /// may be the document base on a template file !?
+ ::rtl::OUString TemplateURL;
+
+ /// the pure file name, without path, disc etcpp.
+ ::rtl::OUString DisplayName;
+
+ /// the application module, where this document was loaded
+ ::rtl::OUString Module;
+
+ /// state info as e.g. VALID, CORRUPTED, NON EXISTING ...
+ sal_Int32 DocState;
+
+ /// ui representation for DocState!
+ ERecoveryState RecoveryState;
+
+ /// standard icon
+ Image StandardImage;
+
+ /// high contrast icon
+ Image HCImage;
+
+ public:
+
+ TURLInfo()
+ : ID (-1 )
+ , DocState (E_UNKNOWN )
+ , RecoveryState(E_NOT_RECOVERED_YET)
+ {}
+};
+
+//===============================================
+typedef ::std::vector< TURLInfo > TURLList;
+
+//===============================================
+class IRecoveryUpdateListener
+{
+ public:
+
+ // inform listener about changed items, which should be refreshed
+ virtual void updateItems() = 0;
+
+ // inform listener about starting of the asynchronous recovery operation
+ virtual void start() = 0;
+
+ // inform listener about ending of the asynchronous recovery operation
+ virtual void end() = 0;
+
+ // TODO
+ virtual void stepNext(TURLInfo* pItem) = 0;
+};
+
+//===============================================
+class RecoveryCore : public ::cppu::WeakImplHelper1< css::frame::XStatusListener >
+{
+ //-------------------------------------------
+ // types, const
+ public:
+
+ //-------------------------------------------
+ // member
+ private:
+
+ /// TODO
+ css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
+
+ /// TODO
+ css::uno::Reference< css::frame::XDispatch > m_xRealCore;
+
+ /// TODO
+ css::uno::Reference< css::task::XStatusIndicator > m_xProgress;
+
+ /// TODO
+ TURLList m_lURLs;
+
+ /// TODO
+ IRecoveryUpdateListener* m_pListener;
+
+ /** @short knows the reason, why we listen on our internal m_xRealCore
+ member.
+
+ @descr Because we listen for different operations
+ on the core dispatch implementation, we must know,
+ which URL we have to use for deregistration!
+ */
+ sal_Bool m_bListenForSaving;
+
+ //-------------------------------------------
+ // native interface
+ public:
+
+ //---------------------------------------
+ /** @short TODO */
+ RecoveryCore(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
+ sal_Bool bUsedForSaving);
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual ~RecoveryCore();
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual css::uno::Reference< css::lang::XMultiServiceFactory > getSMGR();
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual TURLList* getURLListAccess();
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual sal_Bool existsBrokenTempEntries();
+ virtual sal_Bool existsNonRecoveredEntries();
+ static sal_Bool isBrokenTempEntry(const TURLInfo& rInfo);
+ virtual void saveBrokenTempEntries(const ::rtl::OUString& sSaveDir);
+ virtual void saveAllTempEntries(const ::rtl::OUString& sSaveDir);
+ virtual void forgetBrokenTempEntries();
+ virtual void forgetAllRecoveryEntries();
+ void forgetBrokenRecoveryEntries();
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual void setProgressHandler(const css::uno::Reference< css::task::XStatusIndicator >& xProgress);
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual void setUpdateListener(IRecoveryUpdateListener* pListener);
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual void doEmergencySavePrepare();
+ virtual void doEmergencySave();
+ virtual void doRecovery();
+
+ //---------------------------------------
+ /** @short TODO */
+ static ERecoveryState mapDocState2RecoverState(sal_Int32 eDocState);
+
+ //-------------------------------------------
+ // uno interface
+ public:
+
+ // css.frame.XStatusListener
+ virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& aEvent)
+ throw(css::uno::RuntimeException);
+
+ // css.lang.XEventListener
+ virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
+ throw(css::uno::RuntimeException);
+
+ //-------------------------------------------
+ // helper
+ private:
+
+ //---------------------------------------
+ /** @short starts listening on the internal EmergencySave/AutoRecovery core.
+ */
+ void impl_startListening();
+
+ //---------------------------------------
+ /** @short stop listening on the internal EmergencySave/AutoRecovery core.
+ */
+ void impl_stopListening();
+
+ //---------------------------------------
+ /** @short TODO */
+ css::util::URL impl_getParsedURL(const ::rtl::OUString& sURL);
+};
+
+//===============================================
+class PluginProgressWindow : public Window
+{
+ private:
+
+ css::uno::Reference< css::lang::XComponent > m_xProgress;
+
+ public:
+
+ PluginProgressWindow( Window* pParent ,
+ const css::uno::Reference< css::lang::XComponent >& xProgress);
+ ~PluginProgressWindow();
+};
+
+class PluginProgress : public ::cppu::WeakImplHelper2< css::task::XStatusIndicator ,
+ css::lang::XComponent >
+{
+
+ //-------------------------------------------
+ // member
+ private:
+
+ /** @short TODO */
+ css::uno::Reference< css::task::XStatusIndicatorFactory > m_xProgressFactory;
+
+ css::uno::Reference< css::task::XStatusIndicator > m_xProgress;
+
+ PluginProgressWindow* m_pPlugProgressWindow;
+
+ //-------------------------------------------
+ // native interface
+ public:
+
+ //---------------------------------------
+ /** @short TODO */
+ PluginProgress( Window* pParent,
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR );
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual ~PluginProgress();
+
+ //---------------------------------------
+ /** @short TODO */
+ Window* getPlugWindow();
+
+ //-------------------------------------------
+ // uno interface
+ public:
+
+ //---------------------------------------
+ // XStatusIndicator
+ virtual void SAL_CALL start(const ::rtl::OUString& sText ,
+ sal_Int32 nRange)
+ throw(css::uno::RuntimeException);
+
+ virtual void SAL_CALL end()
+ throw(css::uno::RuntimeException);
+
+ virtual void SAL_CALL setText(const ::rtl::OUString& sText)
+ throw(css::uno::RuntimeException);
+
+ virtual void SAL_CALL setValue(sal_Int32 nValue)
+ throw(css::uno::RuntimeException);
+
+ virtual void SAL_CALL reset()
+ throw(css::uno::RuntimeException);
+
+ //---------------------------------------
+ // XComponent
+ virtual void SAL_CALL dispose()
+ throw(css::uno::RuntimeException);
+
+ virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener >& xListener)
+ throw(css::uno::RuntimeException);
+
+ virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener)
+ throw(css::uno::RuntimeException);
+};
+
+//===============================================
+class IExtendedTabPage : public TabPage
+{
+ //-------------------------------------------
+ // member
+ protected:
+
+ short m_nResult;
+
+ //-------------------------------------------
+ // interface
+ public:
+
+ IExtendedTabPage( Window* pParent, WinBits nStyle = 0 )
+ : TabPage( pParent, nStyle )
+ , m_nResult(DLG_RET_UNKNOWN)
+ {}
+
+ IExtendedTabPage( Window* pParent, const ResId& rResId )
+ : TabPage( pParent, rResId )
+ , m_nResult(DLG_RET_UNKNOWN)
+ {}
+
+ virtual ~IExtendedTabPage()
+ {}
+
+ virtual short execute() = 0;
+ virtual void setDefButton() = 0;
+};
+
+typedef ::std::vector< IExtendedTabPage* > TTabPageList;
+
+//===============================================
+class TabDialog4Recovery : public TabDialog
+{
+ //-------------------------------------------
+ // member
+ private:
+
+ TTabPageList m_lTabPages;
+ TTabPageList::iterator m_pActualPage;
+
+ //-------------------------------------------
+ // interface
+ public:
+
+ TabDialog4Recovery(Window* pParent);
+ virtual ~TabDialog4Recovery();
+
+ virtual void addTabPage(IExtendedTabPage* pPage);
+ virtual short Execute();
+};
+
+//===============================================
+class SaveDialog : public IExtendedTabPage
+{
+ //-------------------------------------------
+ // member
+ private:
+
+ Window m_aTitleWin;
+ FixedText m_aTitleFT;
+ FixedLine m_aTitleFL;
+ FixedText m_aDescrFT;
+ FixedText m_aFileListFT;
+ ListBox m_aFileListLB;
+ FixedLine m_aBottomFL;
+ OKButton m_aOkBtn;
+
+ RecoveryCore* m_pCore;
+
+ //-------------------------------------------
+ // interface
+ public:
+
+ //---------------------------------------
+ /** @short create all child controls of this dialog.
+
+ @descr The dialog isnt shown nor it starts any
+ action by itself!
+
+ @param pParent
+ can point to a parent window.
+ If its set to 0, the defmodal-dialog-parent
+ is used automaticly.
+
+ @param pCore
+ provides access to the recovery core service
+ and the current list of open documents,
+ which should be shown inside this dialog.
+ */
+ SaveDialog(Window* pParent,
+ RecoveryCore* pCore );
+
+ //---------------------------------------
+ /** @short free all controls and used memory. */
+ virtual ~SaveDialog();
+
+ //---------------------------------------
+ /** @short TODO*/
+ virtual short execute();
+
+ //---------------------------------------
+ /** @short TODO*/
+ virtual void setDefButton();
+
+ DECL_LINK(OKButtonHdl, void*);
+};
+
+//===============================================
+class SaveProgressDialog : public ModalDialog
+ , public IRecoveryUpdateListener
+{
+ //-------------------------------------------
+ // member
+ private:
+
+ FixedText m_aHintFT;
+ FixedText m_aProgrFT;
+ String m_aProgrBaseTxt;
+ Window m_aProgrParent;
+
+ // @short TODO
+ RecoveryCore* m_pCore;
+
+ // @short TODO
+ css::uno::Reference< css::task::XStatusIndicator > m_xProgress;
+
+ //-------------------------------------------
+ // interface
+ public:
+
+ //---------------------------------------
+ /** @short create all child controls of this dialog.
+
+ @descr The dialog isnt shown nor it starts any
+ action by itself!
+
+ @param pParent
+ can point to a parent window.
+ If its set to 0, the defmodal-dialog-parent
+ is used automaticly.
+
+ @param pCore
+ used to start emegrency save.
+ */
+ SaveProgressDialog(Window* pParent,
+ RecoveryCore* pCore );
+
+ //---------------------------------------
+ /** @short free all controls and used memory. */
+ virtual ~SaveProgressDialog();
+
+ //---------------------------------------
+ /** @short start the emergency save operation. */
+ virtual short Execute();
+
+ // IRecoveryUpdateListener
+ virtual void updateItems();
+ virtual void stepNext(TURLInfo* pItem);
+ virtual void start();
+ virtual void end();
+};
+
+//===============================================
+class RecovDocListEntry : public SvLBoxString
+{
+ //-------------------------------------------
+ // interface
+ private:
+
+ //-------------------------------------------
+ // interface
+ public:
+
+ //---------------------------------------
+ /** @short TODO */
+ RecovDocListEntry( SvLBoxEntry* pEntry,
+ USHORT nFlags,
+ const String& sText );
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual void Paint(const Point& aPos ,
+ SvLBox& aDevice,
+ USHORT nFlags ,
+ SvLBoxEntry* pEntry );
+};
+
+//===============================================
+class RecovDocList : public SvxSimpleTable
+{
+ //-------------------------------------------
+ // member
+ public:
+
+ Image m_aGreenCheckImg;
+ Image m_aYellowCheckImg;
+ Image m_aRedCrossImg;
+ Image m_aGreenCheckImgHC;
+ Image m_aYellowCheckImgHC;
+ Image m_aRedCrossImgHC;
+
+ String m_aSuccessRecovStr;
+ String m_aOrigDocRecovStr;
+ String m_aRecovFailedStr;
+ String m_aRecovInProgrStr;
+ String m_aNotRecovYetStr;
+
+ //-------------------------------------------
+ // interface
+ public:
+
+ //---------------------------------------
+ /** @short TODO */
+ RecovDocList( Window* pParent,
+ const ResId& rResId );
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual ~RecovDocList();
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual void InitEntry( SvLBoxEntry* pEntry ,
+ const XubString& sText ,
+ const Image& aImage1,
+ const Image& aImage2,
+ SvLBoxButtonKind eButtonKind);
+};
+
+//===============================================
+class RecoveryDialog : public IExtendedTabPage
+ , public IRecoveryUpdateListener
+{
+ //-------------------------------------------
+ // member
+ private:
+ Window m_aTitleWin;
+ FixedText m_aTitleFT;
+ FixedLine m_aTitleFL;
+ FixedText m_aDescrFT;
+ FixedText m_aProgressFT;
+ Window m_aProgrParent;
+ FixedText m_aFileListFT;
+ RecovDocList m_aFileListLB;
+ FixedLine m_aBottomFL;
+ PushButton m_aNextBtn;
+ CancelButton m_aCancelBtn;
+ String m_aNextStr;
+ String m_aTitleRecoveryInProgress;
+ String m_aTitleRecoveryReport;
+ String m_aRecoveryOnlyFinish;
+ String m_aRecoveryOnlyFinishDescr;
+
+ PushButton* m_pDefButton;
+ RecoveryCore* m_pCore;
+ css::uno::Reference< css::task::XStatusIndicator > m_xProgress;
+ enum EInternalRecoveryState
+ {
+ E_RECOVERY_PREPARED, // dialog started ... recovery prepared
+ E_RECOVERY_IN_PROGRESS, // recovery core still in progress
+ E_RECOVERY_CORE_DONE, // recovery core finished it's task
+ E_RECOVERY_DONE, // user clicked "next" button
+ E_RECOVERY_CANCELED, // user clicked "cancel" button
+ E_RECOVERY_CANCELED_BEFORE, // user clicked "cancel" button before recovery was started
+ E_RECOVERY_CANCELED_AFTERWARDS, // user clicked "cancel" button after reovery was finished
+ E_RECOVERY_HANDLED // the recovery wizard page was shown already ... and will be shown now again ...
+ };
+ sal_Int32 m_eRecoveryState;
+ sal_Bool m_bWaitForUser;
+ sal_Bool m_bWaitForCore;
+ sal_Bool m_bUserDecideNext;
+ sal_Bool m_bWasRecoveryStarted;
+ sal_Bool m_bRecoveryOnly;
+
+ //-------------------------------------------
+ // member
+ public:
+
+ //---------------------------------------
+ /** @short TODO */
+ RecoveryDialog(Window* pParent,
+ RecoveryCore* pCore );
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual ~RecoveryDialog();
+
+ //---------------------------------------
+ // IRecoveryUpdateListener
+ virtual void updateItems();
+ virtual void stepNext(TURLInfo* pItem);
+ virtual void start();
+ virtual void end();
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual short execute();
+
+ //---------------------------------------
+ /** @short TODO*/
+ virtual void setDefButton();
+
+ //-------------------------------------------
+ // helper
+ private:
+
+ //---------------------------------------
+ /** @short TODO */
+ DECL_LINK(NextButtonHdl, void*);
+ DECL_LINK(CancelButtonHdl, void*);
+
+ //---------------------------------------
+ /** @short TODO */
+ void impl_refreshDocList();
+
+ //---------------------------------------
+ /** @short TODO */
+ String impl_getStatusString( const TURLInfo& rInfo ) const;
+};
+
+//===============================================
+class BrokenRecoveryDialog : public ModalDialog
+{
+ //-------------------------------------------
+ // member
+ private:
+ FixedText m_aDescrFT;
+ FixedText m_aFileListFT;
+ ListBox m_aFileListLB;
+ FixedText m_aSaveDirFT;
+ Edit m_aSaveDirED;
+ PushButton m_aSaveDirBtn;
+ FixedLine m_aBottomFL;
+ OKButton m_aOkBtn;
+ CancelButton m_aCancelBtn;
+
+ ::rtl::OUString m_sSavePath;
+ RecoveryCore* m_pCore;
+ sal_Bool m_bBeforeRecovery;
+ sal_Bool m_bExecutionNeeded;
+
+ //-------------------------------------------
+ // interface
+ public:
+
+ //---------------------------------------
+ /** @short TODO */
+ BrokenRecoveryDialog(Window* pParent ,
+ RecoveryCore* pCore ,
+ sal_Bool bBeforeRecovery);
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual ~BrokenRecoveryDialog();
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual sal_Bool isExecutionNeeded();
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual ::rtl::OUString getSaveDirURL();
+
+ //-------------------------------------------
+ // helper
+ private:
+
+ //---------------------------------------
+ /** @short TODO */
+ void impl_refresh();
+
+ //---------------------------------------
+ /** @short TODO */
+ DECL_LINK(SaveButtonHdl, void*);
+
+ //---------------------------------------
+ /** @short TODO */
+ DECL_LINK(OkButtonHdl, void*);
+
+ //---------------------------------------
+ /** @short TODO */
+ DECL_LINK(CancelButtonHdl, void*);
+
+ //---------------------------------------
+ /** @short TODO */
+ void impl_askForSavePath();
+};
+
+
+
+ class ErrorRepWelcomeDialog : public IExtendedTabPage
+ {
+ private:
+ Window maTitleWin;
+ FixedText maTitleFT;
+ FixedLine maTitleFL;
+ FixedText maDescrFT;
+
+ FixedLine maBottomFL;
+ PushButton maPrevBtn;
+ OKButton maNextBtn;
+ CancelButton maCancelBtn;
+
+ DECL_LINK( PrevBtnHdl, void* );
+ DECL_LINK( NextBtnHdl, void* );
+ DECL_LINK( CancelBtnHdl, void* );
+ public:
+ ErrorRepWelcomeDialog( Window* _pParent, sal_Bool _bAllowBack = sal_True );
+ virtual ~ErrorRepWelcomeDialog();
+ /** @short TODO*/
+ virtual short execute();
+
+ //---------------------------------------
+ /** @short TODO*/
+ virtual void setDefButton();
+ };
+
+ struct ErrorRepParams
+ {
+ ErrorRepParams()
+#ifdef WNT
+ : miHTTPConnectionType( 0 )
+#else
+ : miHTTPConnectionType( 1 )
+#endif
+ , mbAllowContact( false )
+ {}
+
+ String maHTTPProxyServer;
+ String maHTTPProxyPort;
+ int miHTTPConnectionType;
+ bool mbAllowContact;
+ String maReturnAddress;
+ String maSubject;
+ String maBody;
+ };
+
+ class ErrorDescriptionEdit : public MultiLineEdit
+ {
+ private:
+ DECL_LINK( ModifyHdl, void* );
+
+ public:
+ ErrorDescriptionEdit( Window* pParent, const ResId& rResId );
+ virtual ~ErrorDescriptionEdit();
+ };
+
+ class ErrorRepSendDialog : public IExtendedTabPage
+ {
+ private:
+ Window maTitleWin;
+ FixedText maTitleFT;
+ FixedLine maTitleFL;
+ FixedText maDescrFT;
+
+ FixedText maDocTypeFT;
+ Edit maDocTypeED;
+ FixedText maUsingFT;
+ ErrorDescriptionEdit maUsingML;
+ PushButton maShowRepBtn;
+ PushButton maOptBtn;
+ CheckBox maContactCB;
+ FixedText maEMailAddrFT;
+ Edit maEMailAddrED;
+
+ FixedLine maBottomFL;
+ PushButton maPrevBtn;
+ OKButton maNextBtn;
+ CancelButton maCancelBtn;
+
+ ErrorRepParams maParams;
+
+ DECL_LINK( ShowRepBtnHdl, void* );
+ DECL_LINK( OptBtnHdl, void* );
+ DECL_LINK( ContactCBHdl, void* );
+ DECL_LINK( PrevBtnHdl, void* );
+ DECL_LINK( SendBtnHdl, void* );
+ DECL_LINK( CancelBtnHdl, void* );
+
+ void initControls();
+
+ public:
+ ErrorRepSendDialog( Window* _pParent );
+ virtual ~ErrorRepSendDialog();
+
+ String GetDocType( void ) const;
+ String GetUsing( void ) const;
+ bool IsContactAllowed( void ) const;
+ String GetEMailAddress( void ) const;
+
+ bool ReadParams();
+ bool SaveParams();
+ bool SendReport();
+
+ /** @short TODO*/
+ virtual short execute();
+
+ //---------------------------------------
+ /** @short TODO*/
+ virtual void setDefButton();
+ };
+
+ class ErrorRepOptionsDialog : public ModalDialog
+ {
+ private:
+ FixedLine maProxyFL;
+ RadioButton maSystemBtn;
+ RadioButton maDirectBtn;
+ RadioButton maManualBtn;
+ FixedText maProxyServerFT;
+ Edit maProxyServerEd;
+ FixedText maProxyPortFT;
+ Edit maProxyPortEd;
+ FixedText maDescriptionFT;
+ FixedLine maButtonsFL;
+ OKButton maOKBtn;
+ CancelButton maCancelBtn;
+
+ ErrorRepParams& mrParams;
+
+ DECL_LINK( CancelBtnHdl, void* );
+ DECL_LINK( OKBtnHdl, void * );
+ DECL_LINK( ManualBtnHdl, void * );
+
+ public:
+ ErrorRepOptionsDialog( Window* _pParent, ErrorRepParams& rParams );
+ virtual ~ErrorRepOptionsDialog();
+ };
+
+ class ErrorRepEdit : public ExtMultiLineEdit
+ {
+ public:
+ ErrorRepEdit( Window* pParent, const ResId& rResId );
+ virtual ~ErrorRepEdit();
+ };
+
+ class ErrorRepPreviewDialog : public ModalDialog
+ {
+ private:
+ ErrorRepEdit maContentML;
+ OKButton maOKBtn;
+
+ long mnMinHeight;
+
+ public:
+ ErrorRepPreviewDialog( Window* _pParent );
+ virtual ~ErrorRepPreviewDialog();
+
+ virtual void Resize();
+ };
+ } // namespace DocRecovery
+} // namespace svx
+
+#undef css
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx
new file mode 100644
index 000000000000..8e5309335422
--- /dev/null
+++ b/svx/source/inc/filtnav.hxx
@@ -0,0 +1,374 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FILTNAV_HXX
+#define _SVX_FILTNAV_HXX
+
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/form/runtime/XFilterController.hpp>
+#include <svl/lstner.hxx>
+#include <svl/brdcst.hxx>
+
+#include <vcl/window.hxx>
+#include <sfx2/childwin.hxx>
+#include <svl/poolitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dockwin.hxx>
+#include <sfx2/ctrlitem.hxx>
+#include <vcl/image.hxx>
+#include <svtools/svtreebx.hxx>
+
+#include <vcl/dialog.hxx>
+#include <vcl/group.hxx>
+#include <vcl/dockwin.hxx>
+#include "svx/fmtools.hxx"
+#include "fmexch.hxx"
+#include <connectivity/sqlparse.hxx>
+#include "fmexch.hxx"
+#include "sqlparserclient.hxx"
+
+class FmFormShell;
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+class FmFilterItem;
+class FmFilterItems;
+class FmParentData;
+class FmFilterAdapter;
+
+//========================================================================
+// data structure for the filter model
+//========================================================================
+class FmFilterData
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+ FmParentData* m_pParent;
+ ::rtl::OUString m_aText;
+
+public:
+ TYPEINFO();
+ FmFilterData(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmParentData* pParent = NULL, const ::rtl::OUString& rText = ::rtl::OUString())
+ :m_xORB( _rxFactory )
+ ,m_pParent( pParent )
+ ,m_aText( rText )
+ {}
+ virtual ~FmFilterData(){}
+
+ void SetText( const ::rtl::OUString& rText ){ m_aText = rText; }
+ ::rtl::OUString GetText() const { return m_aText; }
+ FmParentData* GetParent() const {return m_pParent;}
+
+ virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const;
+};
+
+//========================================================================
+class FmParentData : public FmFilterData
+{
+protected:
+ ::std::vector< FmFilterData* > m_aChildren;
+
+public:
+ TYPEINFO();
+ FmParentData(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmParentData* pParent, const ::rtl::OUString& rText)
+ : FmFilterData(_rxFactory,pParent, rText)
+ {}
+ virtual ~FmParentData();
+
+ ::std::vector< FmFilterData* >& GetChildren() { return m_aChildren; }
+};
+
+//========================================================================
+// Item representing the forms and subforms
+class FmFormItem : public FmParentData
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterController > m_xFilterController;
+
+public:
+ TYPEINFO();
+
+ FmFormItem( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmParentData* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & _xController,
+ const ::rtl::OUString& _rText)
+ :FmParentData( _rxFactory, _pParent, _rText )
+ ,m_xController( _xController )
+ ,m_xFilterController( _xController, ::com::sun::star::uno::UNO_QUERY_THROW )
+ {
+ }
+
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >&
+ GetController() { return m_xController; }
+
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterController >&
+ GetFilterController() { return m_xFilterController; }
+
+ virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const;
+};
+
+//========================================================================
+class FmFilterItems : public FmParentData
+{
+public:
+ TYPEINFO();
+ FmFilterItems(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory):FmParentData(_rxFactory,NULL, ::rtl::OUString()){}
+ FmFilterItems(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmFormItem* pParent, const ::rtl::OUString& rText ):FmParentData(_rxFactory,pParent, rText){}
+
+ FmFilterItem* Find( const ::sal_Int32 _nFilterComponentIndex ) const;
+ virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const;
+};
+
+//========================================================================
+class FmFilterItem : public FmFilterData
+{
+ ::rtl::OUString m_aFieldName;
+ const sal_Int32 m_nComponentIndex;
+
+public:
+ TYPEINFO();
+ FmFilterItem(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,
+ FmFilterItems* pParent,
+ const ::rtl::OUString& aFieldName,
+ const ::rtl::OUString& aCondition,
+ const sal_Int32 _nComponentIndex
+ );
+
+ const ::rtl::OUString& GetFieldName() const {return m_aFieldName;}
+ sal_Int32 GetComponentIndex() const { return m_nComponentIndex; }
+
+ virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const;
+};
+
+//========================================================================
+class FmFilterModel : public FmParentData
+ ,public SfxBroadcaster
+ ,public ::svxform::OSQLParserClient
+{
+ friend class FmFilterAdapter;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xControllers;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+ FmFilterAdapter* m_pAdapter;
+ FmFilterItems* m_pCurrentItems;
+
+public:
+ TYPEINFO();
+ FmFilterModel(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+ virtual ~FmFilterModel();
+
+ void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent);
+ void Clear();
+ sal_Bool ValidateText(FmFilterItem* pItem, UniString& rText, UniString& rErrorMsg) const;
+ void Append(FmFilterItems* pItems, FmFilterItem* pFilterItem);
+ void SetTextForItem(FmFilterItem* pItem, const ::rtl::OUString& rText);
+
+ FmFormItem* GetCurrentForm() const {return m_pCurrentItems ? (FmFormItem*)m_pCurrentItems->GetParent() : NULL;}
+ FmFilterItems* GetCurrentItems() const {return m_pCurrentItems;}
+ void SetCurrentItems(FmFilterItems* pCurrent);
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const { return m_xORB; }
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & GetControllers() const {return m_xControllers;}
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & GetCurrentController() const {return m_xController;}
+ void SetCurrentController(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController);
+
+ void Remove(FmFilterData* pFilterItem);
+ void AppendFilterItems( FmFormItem& _rItem );
+ void EnsureEmptyFilterRows( FmParentData& _rItem );
+
+protected:
+ void Insert(const ::std::vector<FmFilterData*>::iterator& rPos, FmFilterData* pFilterItem);
+ void Remove( const ::std::vector<FmFilterData*>::iterator& rPos );
+ FmFormItem* Find(const ::std::vector<FmFilterData*>& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController) const;
+ FmFormItem* Find(const ::std::vector<FmFilterData*>& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm) const;
+ void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, FmParentData* pParent);
+};
+
+//========================================================================
+//========================================================================
+class OFilterItemExchange : public OLocalExchange
+{
+ ::std::vector<FmFilterItem*> m_aDraggedEntries;
+ FmFormItem* m_pFormItem; // ensure that we drop on the same form
+
+public:
+ OFilterItemExchange();
+
+ static sal_uInt32 getFormatId( );
+ inline static sal_Bool hasFormat( const DataFlavorExVector& _rFormats );
+
+ const ::std::vector<FmFilterItem*>& getDraggedEntries() const { return m_aDraggedEntries; }
+ void setDraggedEntries(const ::std::vector<FmFilterItem*>& _rList) { m_aDraggedEntries = _rList; }
+ FmFormItem* getFormItem() const { return m_pFormItem; }
+
+ void setFormItem( FmFormItem* _pItem ) { m_pFormItem = _pItem; }
+ void addSelectedItem( FmFilterItem* _pItem) { m_aDraggedEntries.push_back(_pItem); }
+
+protected:
+ virtual void AddSupportedFormats();
+};
+
+inline sal_Bool OFilterItemExchange::hasFormat( const DataFlavorExVector& _rFormats )
+{
+ return OLocalExchange::hasFormat( _rFormats, getFormatId() );
+}
+
+//====================================================================
+//= OFilterExchangeHelper
+//====================================================================
+class OFilterExchangeHelper : public OLocalExchangeHelper
+{
+public:
+ OFilterExchangeHelper(Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { }
+
+ OFilterItemExchange* operator->() const { return static_cast<OFilterItemExchange*>(m_pTransferable); }
+
+protected:
+ virtual OLocalExchange* createExchange() const;
+};
+
+//========================================================================
+class FmFilterNavigator : public SvTreeListBox, public SfxListener
+{
+ enum DROP_ACTION{ DA_SCROLLUP, DA_SCROLLDOWN, DA_EXPANDNODE };
+
+ FmFilterModel* m_pModel;
+ SvLBoxEntry* m_pEditingCurrently;
+ OFilterExchangeHelper m_aControlExchange;
+
+
+ AutoTimer m_aDropActionTimer;
+ unsigned short m_aTimerCounter;
+ Point m_aTimerTriggered; // die Position, an der der DropTimer angeschaltet wurde
+ DROP_ACTION m_aDropActionType;
+
+public:
+ FmFilterNavigator( Window* pParent );
+ virtual ~FmFilterNavigator();
+
+ void UpdateContent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent
+ );
+ const FmFilterModel* GetFilterModel() const {return m_pModel;}
+
+protected:
+ using Control::Notify;
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void Command( const CommandEvent& rEvt );
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+ virtual void InitEntry(SvLBoxEntry* pEntry, const XubString& rStr, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind);
+ virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True );
+ virtual sal_Bool EditingEntry( SvLBoxEntry* pEntry, Selection& rSelection );
+ virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
+
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+ void DeleteSelection();
+ void Clear();
+ SvLBoxEntry* FindEntry(const FmFilterData* pItem) const;
+ void Insert(FmFilterData* pItem, sal_Int32 nPos);
+ void Remove(FmFilterData* pItem);
+
+ DECL_LINK(OnRemove, SvLBoxEntry*);
+ DECL_LINK(OnEdited, SvLBoxEntry*);
+ DECL_LINK(OnDropActionTimer, void*);
+
+private:
+ /** returns the first form item and the selected FilterItems in the vector
+ @param _rItemList
+ Is filled inside. <OUT/>
+ @return
+ The first form item.
+ */
+ FmFormItem* getSelectedFilterItems(::std::vector<FmFilterItem*>& _rItemList);
+ /* inserts the filter items into the tree model and creates new FilterItems if needed.
+ @param _rFilterList
+ The items which should be inserted.
+ @param _pTargetItems
+ The target where to insert the items.
+ @param _bCopy
+ If <TRUE/> the items will not be removed from the model, otherwise they will.
+ */
+ void insertFilterItem(const ::std::vector<FmFilterItem*>& _rFilterList,FmFilterItems* _pTargetItems,sal_Bool _bCopy = sal_False);
+ SvLBoxEntry* getPrevEntry(SvLBoxEntry* _pStartWith = NULL);
+ SvLBoxEntry* getNextEntry(SvLBoxEntry* _pStartWith = NULL);
+
+ using SvTreeListBox::Select;
+ using SvTreeListBox::ExecuteDrop;
+ using SvTreeListBox::Insert;
+};
+
+//========================================================================
+class FmFilterNavigatorWin : public SfxDockingWindow, public SfxControllerItem
+{
+private:
+ FmFilterNavigator* m_pNavigator;
+
+protected:
+ virtual void Resize();
+ virtual sal_Bool Close();
+ virtual Size CalcDockingSize( SfxChildAlignment );
+ virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment );
+
+public:
+ FmFilterNavigatorWin( SfxBindings *pBindings, SfxChildWindow *pMgr,
+ Window* pParent );
+ virtual ~FmFilterNavigatorWin();
+
+ void UpdateContent( FmFormShell* pFormShell );
+ void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
+ void FillInfo( SfxChildWinInfo& rInfo ) const;
+
+ using SfxDockingWindow::StateChanged;
+
+ virtual void GetFocus();
+};
+
+//========================================================================
+class FmFilterNavigatorWinMgr : public SfxChildWindow
+{
+public:
+ FmFilterNavigatorWinMgr( Window *pParent, sal_uInt16 nId, SfxBindings *pBindings,
+ SfxChildWinInfo *pInfo );
+ SFX_DECL_CHILDWINDOW( FmFilterNavigatorWinMgr );
+};
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // _SVX_FILTNAV_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmPropBrw.hxx b/svx/source/inc/fmPropBrw.hxx
new file mode 100644
index 000000000000..b4765a799a1e
--- /dev/null
+++ b/svx/source/inc/fmPropBrw.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_FMPROPBRW_HXX
+#define SVX_FMPROPBRW_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/inspection/XObjectInspectorModel.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+/** === end UNO includes === **/
+
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/ctrlitem.hxx>
+#include <sfx2/childwin.hxx>
+#include "svx/fmtools.hxx"
+
+//========================================================================
+class FmPropBrwMgr : public SfxChildWindow
+{
+public:
+ FmPropBrwMgr(Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo);
+ SFX_DECL_CHILDWINDOW(FmPropBrwMgr);
+};
+
+class FmPropControl;
+class SfxBindings;
+class FmFormShell;
+//========================================================================
+class FmPropBrw : public SfxFloatingWindow, public SfxControllerItem
+{
+ sal_Bool m_bInitialStateChange;
+ bool m_bInStateChange;
+ ::rtl::OUString m_sLastActivePage;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ m_xInspectorContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
+ m_xMeAsFrame;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ m_xLastKnownDocument;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel >
+ m_xInspectorModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
+ m_xBrowserController;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >
+ m_xBrowserComponentWindow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >
+ m_xFrameContainerWindow;
+
+protected:
+ virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
+ virtual void FillInfo( SfxChildWinInfo& rInfo ) const;
+ virtual sal_Bool Close();
+
+ DECL_LINK( OnAsyncGetFocus, void* );
+
+ void implSetNewSelection( const InterfaceBag& _rSelection );
+ void implDetachController();
+ bool implIsReadOnlyModel() const;
+ ::rtl::OUString getCurrentPage() const;
+
+public:
+ FmPropBrw(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB,
+ SfxBindings* pBindings,
+ SfxChildWindow* pMgr,
+ Window* pParent,
+ const SfxChildWinInfo* _pInfo
+ );
+ virtual ~FmPropBrw();
+
+ using SfxFloatingWindow::StateChanged;
+
+protected:
+ virtual void Resize();
+
+private:
+ /** creates the PropertyBrowser (aka ObjectInspector) and plugs it into our frame
+
+ This method ensures that a new component is created every time the XModel which
+ we're working for changed. This is necessary since this model is part of the
+ ComponentContext we use to create the ObjectInspector.
+ */
+ void impl_ensurePropertyBrowser_nothrow( FmFormShell* _pFormShell );
+
+ /** creates a property browser
+
+ After this method returns, m_xBrowserController and m_xBrowserComponentWindow are
+ not <NULL/>.
+
+ @precond
+ we don't have an ObjectInspector, yet, i.e. m_xBrowserController and m_xBrowserComponentWindow
+ are <NULL/>.
+ */
+ void impl_createPropertyBrowser_throw( FmFormShell* _pFormShell );
+};
+#endif //SVX_FMPROPBRW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmcontrolbordermanager.hxx b/svx/source/inc/fmcontrolbordermanager.hxx
new file mode 100644
index 000000000000..3eddf6ce3f12
--- /dev/null
+++ b/svx/source/inc/fmcontrolbordermanager.hxx
@@ -0,0 +1,271 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX
+#define SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/VisualEffect.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
+/** === end UNO includes === **/
+#include <comphelper/stl_types.hxx>
+#include <comphelper/stl_types.hxx>
+
+#include <set>
+
+namespace com { namespace sun { namespace star { namespace form { namespace validation {
+ class XValidatableFormComponent;
+} } } } }
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ typedef sal_Int16 ControlStatus;
+
+ #define CONTROL_STATUS_NONE 0x00
+ #define CONTROL_STATUS_FOCUSED 0x01
+ #define CONTROL_STATUS_MOUSE_HOVER 0x02
+ #define CONTROL_STATUS_INVALID 0x04
+
+ //====================================================================
+ //= BorderDescriptor
+ //====================================================================
+ struct BorderDescriptor
+ {
+ sal_Int16 nBorderType;
+ sal_Int32 nBorderColor;
+
+ BorderDescriptor()
+ :nBorderType( ::com::sun::star::awt::VisualEffect::FLAT )
+ ,nBorderColor( 0x00000000 )
+ {
+ }
+ inline void clear()
+ {
+ nBorderType = ::com::sun::star::awt::VisualEffect::FLAT;
+ nBorderColor = 0x00000000;
+ }
+ };
+
+ //====================================================================
+ //= UnderlineDescriptor
+ //====================================================================
+ struct UnderlineDescriptor
+ {
+ sal_Int16 nUnderlineType;
+ sal_Int32 nUnderlineColor;
+
+ UnderlineDescriptor()
+ :nUnderlineType( ::com::sun::star::awt::FontUnderline::NONE )
+ ,nUnderlineColor( 0x00000000 )
+ {
+ }
+
+ UnderlineDescriptor( sal_Int16 _nUnderlineType, sal_Int32 _nUnderlineColor )
+ :nUnderlineType( _nUnderlineType )
+ ,nUnderlineColor( _nUnderlineColor )
+ {
+ }
+
+ inline void clear()
+ {
+ nUnderlineType = ::com::sun::star::awt::FontUnderline::NONE;
+ nUnderlineColor = 0x00000000;
+ }
+ };
+
+ //====================================================================
+ //= ControlData
+ //====================================================================
+ struct ControlData : public BorderDescriptor, UnderlineDescriptor
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > xControl;
+ ::rtl::OUString sOriginalHelpText;
+
+ ControlData() : BorderDescriptor() { }
+ ControlData( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl )
+ :xControl( _rxControl )
+ {
+ }
+ void clear()
+ {
+ BorderDescriptor::clear();
+ UnderlineDescriptor::clear();
+ xControl.clear();
+ sOriginalHelpText = ::rtl::OUString();
+ }
+ };
+
+ //====================================================================
+ //= ControlBorderManager
+ //====================================================================
+ /** manages the dynamic border color for form controls
+
+ Used by the <type>FormController</type>, this class manages the dynamic changes in the
+ border color of form controls. For this a set of events have to be forwarded to the manager
+ instance, which then will switch the border color depending on the mouse and focus status
+ of the controls.
+ */
+ class ControlBorderManager
+ {
+ private:
+ struct ControlDataCompare : public ::std::binary_function< ControlData, ControlData, bool >
+ {
+ bool operator()( const ControlData& _rLHS, const ControlData& _rRHS ) const
+ {
+ return _rLHS.xControl.get() < _rRHS.xControl.get();
+ }
+ };
+
+ typedef ::std::set< ControlData, ControlDataCompare > ControlBag;
+ typedef ::com::sun::star::awt::XVclWindowPeer WindowPeer;
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclWindowPeer > WindowPeerRef;
+ typedef ::std::set< WindowPeerRef, ::comphelper::OInterfaceCompare< WindowPeer > > PeerBag;
+
+ PeerBag m_aColorableControls;
+ PeerBag m_aNonColorableControls;
+
+ ControlData m_aFocusControl;
+ ControlData m_aMouseHoverControl;
+ ControlBag m_aInvalidControls;
+
+ // ----------------
+ // attributes
+ sal_Int32 m_nFocusColor;
+ sal_Int32 m_nMouseHoveColor;
+ sal_Int32 m_nInvalidColor;
+ bool m_bDynamicBorderColors;
+
+ public:
+ ControlBorderManager();
+ ~ControlBorderManager();
+
+ public:
+ void focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl ) SAL_THROW(());
+ void focusLost( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl ) SAL_THROW(());
+ void mouseEntered( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl ) SAL_THROW(());
+ void mouseExited( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl ) SAL_THROW(());
+
+ void validityChanged(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::validation::XValidatableFormComponent >& _rxValidatable
+ ) SAL_THROW(());
+
+ /// enables dynamic border color for the controls
+ void enableDynamicBorderColor( );
+ /// disables dynamic border color for the controls
+ void disableDynamicBorderColor( );
+
+ /** sets a color to be used for a given status
+ @param _nStatus
+ the status which the color should be applied for. Must not be CONTROL_STATUS_NONE
+ @param _nColor
+ the color to apply for the given status
+ */
+ void setStatusColor( ControlStatus _nStatus, sal_Int32 _nColor );
+
+ /** restores all colors of all controls where we possibly changed them
+ */
+ void restoreAll();
+
+ private:
+ /** called when a control got one of the two possible stati (focused, and hovered with the mouse)
+ @param _rxControl
+ the control which gained the status
+ @param _rControlData
+ the control's status data, as a reference to our respective member
+ */
+ void controlStatusGained(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl,
+ ControlData& _rControlData
+ ) SAL_THROW(());
+
+ /** called when a control lost one of the two possible stati (focused, and hovered with the mouse)
+ @param _rxControl
+ the control which lost the status
+ @param _rControlData
+ the control's status data, as a reference to our respective member
+ */
+ void controlStatusLost( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxControl, ControlData& _rControlData ) SAL_THROW(());
+
+ /** determines whether the border of a given peer can be colored
+ @param _rxPeer
+ the peer to examine. Must not be <NULL/>
+ */
+ bool canColorBorder( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclWindowPeer >& _rxPeer );
+
+ /** determines the status of the given control
+ */
+ ControlStatus getControlStatus( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ) SAL_THROW(());
+
+ /** retrieves the color associated with a given ControlStatus
+ @param _eStatus
+ the status of the control. Must not be <member>ControlStatus::none</member>
+ */
+ sal_Int32 getControlColorByStatus( ControlStatus _eStatus );
+
+ /** sets the border color for a given control, depending on its status
+ @param _rxControl
+ the control to set the border color for. Must not be <NULL/>
+ @param _rxPeer
+ the peer of the control, to be passed herein for optimization the caller usually needs it, anyway).
+ Must not be <NULL/>
+ @param _rFallback
+ the color/type to use when the control has the status CONTROL_STATUS_NONE
+ */
+ void updateBorderStyle(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XVclWindowPeer >& _rxPeer,
+ const BorderDescriptor& _rFallback
+ ) SAL_THROW(());
+
+ /** determines the to-be-remembered original border color and type for a control
+
+ The method also takes into account that the control may currently have an overwritten
+ border style
+
+ @param _rxControl
+ the control to examine. Must not be <NULL/>, and have a non-<NULL/> peer
+ */
+ void determineOriginalBorderStyle(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl,
+ BorderDescriptor& _rData
+ ) const;
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_SOURCE_INC_FMCONTROLBORDERMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmcontrollayout.hxx b/svx/source/inc/fmcontrollayout.hxx
new file mode 100644
index 000000000000..16000cfd338e
--- /dev/null
+++ b/svx/source/inc/fmcontrollayout.hxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_SOURCE_INC_FMCONTROLLAYOUT_HXX
+#define SVX_SOURCE_INC_FMCONTROLLAYOUT_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+#include "fmdocumentclassification.hxx"
+#include <unotools/confignode.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= ControlLayouter
+ //====================================================================
+ class ControlLayouter
+ {
+ public:
+ /** initializes the layout of a newly created form control (model)
+ */
+ static void initializeControlLayout(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
+ DocumentType _eDocType
+ );
+
+ /** determines whether for the given document type, dynamic control border coloring is enabled
+ */
+ static bool useDynamicBorderColor( DocumentType _eDocType );
+
+ /** determines whether for the given document type, form controls should use the document's reference device
+ for text rendering
+ */
+ static bool useDocumentReferenceDevice( DocumentType _eDocType );
+
+ /** gets the "default" style in a document which can be used if some default text format is needed
+
+ It depends on the type document type which concrete kind of style is returned, but it is expected to support
+ the css.style.CharacterProperties service.
+
+ @param _rxModel
+ a form component.
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getDefaultDocumentTextStyle( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+
+ private:
+ ControlLayouter(); // never implemented
+
+ private:
+ static ::utl::OConfigurationNode
+ getLayoutSettings(
+ DocumentType _eDocType
+ );
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_SOURCE_INC_FMCONTROLLAYOUT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmdocumentclassification.hxx b/svx/source/inc/fmdocumentclassification.hxx
new file mode 100644
index 000000000000..f6f528b68714
--- /dev/null
+++ b/svx/source/inc/fmdocumentclassification.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_SOURCE_INC_FMDOCUMENTCLASSIFICATION_HXX
+#define SVX_SOURCE_INC_FMDOCUMENTCLASSIFICATION_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= DocumentType
+ //====================================================================
+ enum DocumentType
+ {
+ eTextDocument,
+ eWebDocument,
+ eSpreadsheetDocument,
+ eDrawingDocument,
+ ePresentationDocument,
+ eEnhancedForm,
+ eDatabaseForm,
+ eDatabaseReport,
+
+ eUnknownDocumentType
+ };
+
+ //====================================================================
+ //= DocumentClassification
+ //====================================================================
+ class DocumentClassification
+ {
+ public:
+ /** classifies a document model
+ */
+ static DocumentType classifyDocument(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxDocumentModel
+ ) SAL_THROW(());
+
+ static DocumentType classifyHostDocument(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxFormComponent
+ ) SAL_THROW(());
+
+ static DocumentType getDocumentTypeForModuleIdentifier(
+ const ::rtl::OUString& _rModuleIdentifier
+ );
+
+ static ::rtl::OUString getModuleIdentifierForDocumentType(
+ DocumentType _eType
+ );
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_SOURCE_INC_FMDOCUMENTCLASSIFICATION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmexch.hxx b/svx/source/inc/fmexch.hxx
new file mode 100644
index 000000000000..b44293a59b36
--- /dev/null
+++ b/svx/source/inc/fmexch.hxx
@@ -0,0 +1,285 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMEXCH_HXX
+#define _SVX_FMEXCH_HXX
+
+#include <comphelper/stl_types.hxx>
+#include <svtools/transfer.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <tools/link.hxx>
+
+#include <svx/svxdllapi.h>
+
+class FmFormShell;
+class FmFormPage;
+class SvLBoxEntry;
+
+//========================================================================
+// Exchange types
+#define SVX_FM_FIELD_EXCH String("SvxFormFieldExch", sizeof("SvxFormFieldExch"))
+#define SVX_FM_CONTROL_EXCH String("SvxFormExplCtrlExch", sizeof("SvxFormExplCtrlExch"))
+#define SVX_FM_CONTROLS_AS_PATH String("SvxFormControlsAsPathExchange", sizeof("SvxFormControlsAsPathExchange"))
+#define SVX_FM_HIDDEN_CONTROLS String("SvxFormHiddenControlsExchange", sizeof("SvxFormHiddenControlsExchange"))
+#define SVX_FM_FILTER_FIELDS String("SvxFilterFieldExchange", sizeof("SvxFilterFieldExchange"))
+
+//========================================================================
+class SvTreeListBox;
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+
+ typedef ::std::set< SvLBoxEntry* > ListBoxEntrySet;
+
+ //====================================================================
+ //= OLocalExchange
+ //====================================================================
+ class SVX_DLLPUBLIC OLocalExchange : public TransferableHelper
+ {
+ private:
+ Link m_aClipboardListener;
+ sal_Bool m_bDragging : 1;
+ sal_Bool m_bClipboardOwner : 1;
+
+ public:
+ class GrantAccess
+ {
+ friend class OLocalExchangeHelper;
+ };
+
+ public:
+ OLocalExchange( );
+
+ sal_Bool isDragging() const { return m_bDragging; }
+ sal_Bool isClipboardOwner() const { return m_bClipboardOwner; }
+
+ void startDrag( Window* pWindow, sal_Int8 nDragSourceActions, const GrantAccess& );
+ void copyToClipboard( Window* _pWindow, const GrantAccess& );
+
+ void setClipboardListener( const Link& _rListener ) { m_aClipboardListener = _rListener; }
+
+ void clear();
+
+ static sal_Bool hasFormat( const DataFlavorExVector& _rFormats, sal_uInt32 _nFormatId );
+
+ protected:
+ // XClipboardOwner
+ virtual void SAL_CALL lostOwnership( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboard >& _rxClipboard, const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _rxTrans ) throw(::com::sun::star::uno::RuntimeException);
+
+ // TransferableHelper
+ virtual void DragFinished( sal_Int8 nDropAction );
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+
+ private:
+ void StartDrag( Window* pWindow, sal_Int8 nDragSourceActions, sal_Int32 nDragPointer = DND_POINTER_NONE, sal_Int32 nDragImage = DND_IMAGE_NONE )
+ { // don't allow this base class method to be called from outside
+ TransferableHelper::StartDrag(pWindow, nDragSourceActions, nDragPointer, nDragImage);
+ }
+ };
+
+ //====================================================================
+ //= OLocalExchangeHelper
+ //====================================================================
+ /// a helper for navigator windows (SvTreeListBox'es) which allow DnD within themself
+ class SVX_DLLPUBLIC OLocalExchangeHelper
+ {
+ protected:
+ Window* m_pDragSource;
+ OLocalExchange* m_pTransferable;
+
+ public:
+ OLocalExchangeHelper( Window* _pDragSource );
+ virtual ~OLocalExchangeHelper();
+
+ void prepareDrag( );
+
+ void startDrag( sal_Int8 nDragSourceActions );
+ void copyToClipboard( ) const;
+
+ inline sal_Bool isDragSource() const { return m_pTransferable && m_pTransferable->isDragging(); }
+ inline sal_Bool isClipboardOwner() const { return m_pTransferable && m_pTransferable->isClipboardOwner(); }
+ inline sal_Bool isDataExchangeActive( ) const { return isDragSource() || isClipboardOwner(); }
+ inline void clear() { if ( isDataExchangeActive() ) m_pTransferable->clear(); }
+
+ SVX_DLLPRIVATE void setClipboardListener( const Link& _rListener ) { if ( m_pTransferable ) m_pTransferable->setClipboardListener( _rListener ); }
+
+ protected:
+ SVX_DLLPRIVATE virtual OLocalExchange* createExchange() const = 0;
+
+ protected:
+ SVX_DLLPRIVATE void implReset();
+ };
+
+ //====================================================================
+ //= OControlTransferData
+ //====================================================================
+ class OControlTransferData
+ {
+ private:
+ typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< sal_uInt32 > > ControlPaths;
+
+ private:
+ DataFlavorExVector m_aCurrentFormats;
+
+ protected:
+ ListBoxEntrySet m_aSelectedEntries;
+ ControlPaths m_aControlPaths;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
+ m_aHiddenControlModels;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
+ m_xFormsRoot; // the root of the forms collection where the entries we represent reside
+ // this uniquely identifies the page and the document
+
+ SvLBoxEntry* m_pFocusEntry;
+
+ protected:
+ // updates m_aCurrentFormats with all formats we currently could supply
+ void updateFormats( );
+
+ public:
+ OControlTransferData( );
+
+ // ctor to construct the data from an arbitrary Transferable (usually clipboard data)
+ OControlTransferData(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& _rxTransferable
+ );
+
+ inline const DataFlavorExVector& GetDataFlavorExVector() const;
+
+ void addSelectedEntry( SvLBoxEntry* _pEntry );
+ void setFocusEntry( SvLBoxEntry* _pFocusEntry );
+
+ /** notifies the data transfer object that a certain entry has been removed from the owning tree
+
+ In case the removed entry is part of the transfer object's selection, the entry is removed from
+ the selection.
+
+ @param _pEntry
+ @return the number of entries remaining in the selection.
+ */
+ size_t onEntryRemoved( SvLBoxEntry* _pEntry );
+
+ void setFormsRoot(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& _rxFormsRoot
+ ) { m_xFormsRoot = _rxFormsRoot; }
+
+ void buildPathFormat(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot);
+ // baut aus m_aSelectedEntries m_aControlPaths auf
+ // (es wird davon ausgegangen, dass die Eintraege in m_aSelectedEntries sortiert sind in Bezug auf die Nachbar-Beziehung)
+
+
+ void buildListFromPath(SvTreeListBox* pTreeBox, SvLBoxEntry* pRoot);
+ // der umgekehrte Weg : wirft alles aus m_aSelectedEntries weg und baut es mittels m_aControlPaths neu auf
+
+ void addHiddenControlsFormat(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > seqInterfaces);
+ // fuegt ein SVX_FML_HIDDEN_CONTROLS-Format hinzu und merk sich dafuer die uebergebenen Interfaces
+ // (es erfolgt KEINE Ueberpruefung, ob dadurch auch tatsaechlich nur hidden Controls bezeichnet werden, dass muss der
+ // Aufrufer sicherstellen)
+
+ SvLBoxEntry* focused() const { return m_pFocusEntry; }
+ const ListBoxEntrySet& selected() const { return m_aSelectedEntries; }
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
+ hiddenControls() const { return m_aHiddenControlModels; }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
+ getFormsRoot() const { return m_xFormsRoot; }
+ };
+
+ //====================================================================
+ inline const DataFlavorExVector& OControlTransferData::GetDataFlavorExVector() const
+ {
+ const_cast< OControlTransferData* >( this )->updateFormats( );
+ return m_aCurrentFormats;
+ }
+
+ //====================================================================
+ //= OControlExchange
+ //====================================================================
+ class OControlExchange : public OLocalExchange, public OControlTransferData
+ {
+ public:
+ OControlExchange( );
+
+ public:
+ static sal_uInt32 getFieldExchangeFormatId( );
+ static sal_uInt32 getControlPathFormatId( );
+ static sal_uInt32 getHiddenControlModelsFormatId( );
+
+ inline static sal_Bool hasFieldExchangeFormat( const DataFlavorExVector& _rFormats );
+ inline static sal_Bool hasControlPathFormat( const DataFlavorExVector& _rFormats );
+ inline static sal_Bool hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats );
+
+ protected:
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual void AddSupportedFormats();
+ };
+
+ //====================================================================
+ //= OControlExchangeHelper
+ //====================================================================
+ class OControlExchangeHelper : public OLocalExchangeHelper
+ {
+ public:
+ OControlExchangeHelper(Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { }
+
+ OControlExchange* operator->() const { return static_cast< OControlExchange* >( m_pTransferable ); }
+ OControlExchange& operator*() const { return *static_cast< OControlExchange* >( m_pTransferable ); }
+
+ protected:
+ virtual OLocalExchange* createExchange() const;
+ };
+
+ //====================================================================
+ //====================================================================
+ inline sal_Bool OControlExchange::hasFieldExchangeFormat( const DataFlavorExVector& _rFormats )
+ {
+ return hasFormat( _rFormats, getFieldExchangeFormatId() );
+ }
+
+ inline sal_Bool OControlExchange::hasControlPathFormat( const DataFlavorExVector& _rFormats )
+ {
+ return hasFormat( _rFormats, getControlPathFormatId() );
+ }
+
+ inline sal_Bool OControlExchange::hasHiddenControlModelsFormat( const DataFlavorExVector& _rFormats )
+ {
+ return hasFormat( _rFormats, getHiddenControlModelsFormatId() );
+ }
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmexpl.hrc b/svx/source/inc/fmexpl.hrc
new file mode 100644
index 000000000000..ce4d88ee5185
--- /dev/null
+++ b/svx/source/inc/fmexpl.hrc
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * 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 _SVX_FMEXPL_HRC
+#define _SVX_FMEXPL_HRC
+
+#define FT_PATH 1
+
+#define GB_PATH 1
+
+#define PB_OK 1
+#define PB_CANCEL 2
+#define PB_HELP 3
+
+#endif //_SVX_FMEXPL_HRC
+
diff --git a/svx/source/inc/fmexpl.hxx b/svx/source/inc/fmexpl.hxx
new file mode 100644
index 000000000000..fe0ea0853129
--- /dev/null
+++ b/svx/source/inc/fmexpl.hxx
@@ -0,0 +1,614 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMEXPL_HXX
+#define _SVX_FMEXPL_HXX
+
+#include <svl/lstner.hxx>
+#include <svl/brdcst.hxx>
+#include <vcl/window.hxx>
+#include <sfx2/childwin.hxx>
+#include <svl/poolitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dockwin.hxx>
+#include <sfx2/ctrlitem.hxx>
+#include <vcl/image.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+/** === end UNO includes === **/
+
+#include <svtools/svtreebx.hxx>
+
+#include <vcl/dialog.hxx>
+#include <vcl/group.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/dockwin.hxx>
+#include <svx/fmview.hxx>
+
+#include "fmexch.hxx"
+
+class SdrObjListIter;
+class FmFormShell;
+class SdrObject;
+class FmFormModel;
+class FmFormView;
+class SdrMarkList;
+
+//========================================================================
+class FmEntryData;
+class FmNavInsertedHint : public SfxHint
+{
+ FmEntryData* pEntryData;
+ sal_uInt32 nPos;
+
+public:
+ TYPEINFO();
+ FmNavInsertedHint( FmEntryData* pInsertedEntryData, sal_uInt32 nRelPos );
+ virtual ~FmNavInsertedHint();
+
+ FmEntryData* GetEntryData() const { return pEntryData; }
+ sal_uInt32 GetRelPos() const { return nPos; }
+};
+
+//========================================================================
+class FmNavModelReplacedHint : public SfxHint
+{
+ FmEntryData* pEntryData; // die Daten des Eintrages, der ein neues Model bekommen hat
+
+public:
+ TYPEINFO();
+ FmNavModelReplacedHint( FmEntryData* pAffectedEntryData );
+ virtual ~FmNavModelReplacedHint();
+
+ FmEntryData* GetEntryData() const { return pEntryData; }
+};
+
+//========================================================================
+class FmNavRemovedHint : public SfxHint
+{
+ FmEntryData* pEntryData;
+
+public:
+ TYPEINFO();
+ FmNavRemovedHint( FmEntryData* pInsertedEntryData );
+ virtual ~FmNavRemovedHint();
+
+ FmEntryData* GetEntryData() const { return pEntryData; }
+};
+
+//========================================================================
+class FmNavNameChangedHint : public SfxHint
+{
+ FmEntryData* pEntryData;
+ ::rtl::OUString aNewName;
+
+public:
+ TYPEINFO();
+ FmNavNameChangedHint( FmEntryData* pData, const ::rtl::OUString& rNewName );
+ virtual ~FmNavNameChangedHint();
+
+ FmEntryData* GetEntryData() const { return pEntryData; }
+ ::rtl::OUString GetNewName() const { return aNewName; }
+};
+
+//========================================================================
+class FmNavClearedHint : public SfxHint
+{
+public:
+ TYPEINFO();
+ FmNavClearedHint();
+ virtual ~FmNavClearedHint();
+};
+
+//========================================================================
+class FmNavViewMarksChanged : public SfxHint
+{
+ FmFormView* pView;
+public:
+ TYPEINFO();
+ FmNavViewMarksChanged(FmFormView* pWhichView) { pView = pWhichView; }
+ virtual ~FmNavViewMarksChanged() {}
+
+ FmFormView* GetAffectedView() { return pView; }
+};
+
+//========================================================================
+class FmEntryDataList;
+class FmEntryData
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xNormalizedIFace;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xProperties;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild > m_xChild;
+
+protected:
+ Image m_aNormalImage;
+ Image m_aHCImage;
+ ::rtl::OUString aText;
+
+ FmEntryDataList* pChildList;
+ FmEntryData* pParent;
+
+protected:
+ void newObject( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIFace );
+
+public:
+ TYPEINFO();
+
+ FmEntryData( FmEntryData* pParentData, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rIFace );
+ FmEntryData( const FmEntryData& rEntryData );
+ virtual ~FmEntryData();
+
+ void Clear();
+ void SetText( const ::rtl::OUString& rText ){ aText = rText; }
+ void SetParent( FmEntryData* pParentData ){ pParent = pParentData; }
+
+ const Image& GetNormalImage() const { return m_aNormalImage; }
+ const Image& GetHCImage() const { return m_aHCImage; }
+
+ ::rtl::OUString GetText() const { return aText; }
+ FmEntryData* GetParent() const { return pParent; }
+ FmEntryDataList* GetChildList() const { return pChildList; }
+
+ virtual sal_Bool IsEqualWithoutChilds( FmEntryData* pEntryData );
+ virtual FmEntryData* Clone() = 0;
+
+ // note that the interface returned is normalized, i.e. querying the given XInterface of the object
+ // for XInterface must return the interface itself.
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& GetElement() const
+ {
+ return m_xNormalizedIFace;
+ }
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& GetPropertySet() const
+ {
+ return m_xProperties;
+ }
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XChild >& GetChildIFace() const
+ {
+ return m_xChild;
+ }
+};
+
+//========================================================================
+DECLARE_LIST( FmEntryDataBaseList, FmEntryData* )
+
+class FmEntryDataList : public FmEntryDataBaseList
+{
+public:
+ FmEntryDataList();
+ virtual ~FmEntryDataList();
+};
+
+//========================================================================
+// FmNavRequestSelectHint - jemand teilt dem NavigatorTree mit, dass er bestimmte Eintraege selektieren soll
+
+typedef FmEntryData* FmEntryDataPtr;
+SV_DECL_PTRARR_SORT( FmEntryDataArray, FmEntryDataPtr, 16, 16 )
+
+class FmNavRequestSelectHint : public SfxHint
+{
+ FmEntryDataArray m_arredToSelect;
+ sal_Bool m_bMixedSelection;
+public:
+ TYPEINFO();
+ FmNavRequestSelectHint() { }
+ virtual ~FmNavRequestSelectHint() {}
+
+ void SetMixedSelection(sal_Bool bMixedSelection) { m_bMixedSelection = bMixedSelection; }
+ sal_Bool IsMixedSelection() { return m_bMixedSelection; }
+ void AddItem(FmEntryData* pEntry) { m_arredToSelect.Insert(pEntry); }
+ void ClearItems() { m_arredToSelect.Remove(sal_uInt16(0), m_arredToSelect.Count()); }
+ FmEntryDataArray& GetItems() { return m_arredToSelect; }
+};
+
+//========================================================================
+class FmFormData : public FmEntryData
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > m_xForm;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > m_xContainer;
+
+public:
+ TYPEINFO();
+
+ FmFormData(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm,
+ const ImageList& _rNormalImages,
+ const ImageList& _rHCImages,
+ FmFormData* _pParent = NULL
+ );
+
+ FmFormData( const FmFormData& rFormData );
+ virtual ~FmFormData();
+
+ void SetForm( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm )
+ {
+ m_xForm = xForm;
+ m_xContainer = m_xContainer.query( m_xForm );
+ newObject( m_xForm );
+ }
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& GetFormIface() const { return m_xForm; }
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& GetContainer() const { return m_xContainer; }
+
+ virtual sal_Bool IsEqualWithoutChilds( FmEntryData* pEntryData );
+ virtual FmEntryData* Clone();
+};
+
+
+//========================================================================
+class FmControlData : public FmEntryData
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > m_xFormComponent;
+
+ Image GetImage(const ImageList& ilNavigatorImages) const;
+
+public:
+ TYPEINFO();
+
+ FmControlData(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >& _rxComponent,
+ const ImageList& _rNormalImages,
+ const ImageList& _rHCImages,
+ FmFormData* _pParent
+ );
+ FmControlData( const FmControlData& rControlData );
+ virtual ~FmControlData();
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >& GetFormComponent() const { return m_xFormComponent; }
+ virtual sal_Bool IsEqualWithoutChilds( FmEntryData* pEntryData );
+ virtual FmEntryData* Clone();
+
+ void ModelReplaced(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >& _rxNew,
+ const ImageList& _rNormalImages,
+ const ImageList& _rHCImages
+ );
+};
+
+
+//========================================================================
+//............................................................................
+namespace svxform
+{
+//............................................................................
+
+ class NavigatorTreeModel;
+ //========================================================================
+ // class OFormComponentObserver
+ //========================================================================
+ class OFormComponentObserver
+ :public ::cppu::WeakImplHelper2 < ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::container::XContainerListener
+ >
+ {
+ ::svxform::NavigatorTreeModel* m_pNavModel;
+ sal_uInt32 m_nLocks;
+ sal_Bool m_bCanUndo;
+
+ public:
+ OFormComponentObserver( ::svxform::NavigatorTreeModel* pModel );
+
+ // XEventListenerListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::beans::XPropertyChangeListener
+ virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XContainerListener
+
+ virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
+
+ void Lock() { m_nLocks++; }
+ void UnLock() { m_nLocks--; }
+ sal_Bool IsLocked() const { return m_nLocks != 0; }
+ sal_Bool CanUndo() const { return m_bCanUndo; }
+ void ReleaseModel() { m_pNavModel = NULL; }
+ protected:
+ void Insert(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xIface, sal_Int32 nIndex);
+ void Remove( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxElement );
+ };
+
+ //========================================================================
+ //= NavigatorTreeModel
+ //========================================================================
+ class NavigatorTreeModel : public SfxBroadcaster
+ ,public SfxListener
+ {
+ friend class NavigatorTree;
+ friend class OFormComponentObserver;
+
+ FmEntryDataList* m_pRootList;
+ FmFormShell* m_pFormShell;
+ FmFormPage* m_pFormPage;
+ FmFormModel* m_pFormModel;
+ OFormComponentObserver* m_pPropChangeList;
+
+ ImageList m_aNormalImages;
+ ImageList m_aHCImages;
+
+ void UpdateContent( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xForms );
+ FmControlData* CreateControlData( ::com::sun::star::form::XFormComponent* pFormComponent );
+
+ void InsertForm(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm, sal_uInt32 nRelPos);
+ void RemoveForm(FmFormData* pFormData);
+
+ void InsertFormComponent(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >& xComp, sal_uInt32 nRelPos);
+ void RemoveFormComponent(FmControlData* pControlData);
+ void InsertSdrObj(const SdrObject* pSdrObj);
+ void RemoveSdrObj(const SdrObject* pSdrObj);
+
+ void ReplaceFormComponent(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >& xOld, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >& xNew);
+
+ void BroadcastMarkedObjects(const SdrMarkList& mlMarked);
+ // einen RequestSelectHint mit den aktuell markierten Objekten broadcasten
+ sal_Bool InsertFormComponent(FmNavRequestSelectHint& rHint, SdrObject* pObject);
+ // ist ein Helper fuer vorherige, managet das Abteigen in SdrObjGroups
+ // Rueckgabe sal_True, wenn das Objekt eine FormComponent ist (oder rekursiv nur aus solchen besteht)
+
+ public:
+ NavigatorTreeModel( const ImageList& _rNormalImages, const ImageList& _rHCImages );
+ virtual ~NavigatorTreeModel();
+
+ void FillBranch( FmFormData* pParentData );
+ void ClearBranch( FmFormData* pParentData );
+ void UpdateContent( FmFormShell* pNewShell );
+
+ void Insert( FmEntryData* pEntryData, ULONG nRelPos = LIST_APPEND,
+ sal_Bool bAlterModel = sal_False );
+ void Remove( FmEntryData* pEntryData, sal_Bool bAlterModel = sal_False );
+
+ sal_Bool Rename( FmEntryData* pEntryData, const ::rtl::OUString& rNewText );
+ sal_Bool IsNameAlreadyDefined( const ::rtl::OUString& rName, FmFormData* pParentData );
+ void Clear();
+ sal_Bool CheckEntry( FmEntryData* pEntryData );
+ void SetModified( sal_Bool bMod=sal_True );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > GetForms() const;
+ FmFormShell* GetFormShell() const { return m_pFormShell; }
+ FmFormPage* GetFormPage() const { return m_pFormPage; }
+ FmEntryData* FindData( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xElement, FmEntryDataList* pDataList, sal_Bool bRecurs=sal_True );
+ FmEntryData* FindData( const ::rtl::OUString& rText, FmFormData* pParentData, sal_Bool bRecurs=sal_True );
+ FmEntryDataList* GetRootList() const { return m_pRootList; }
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > GetFormComponents( FmFormData* pParentFormData );
+ SdrObject* GetSdrObj( FmControlData* pControlData );
+ SdrObject* Search(SdrObjListIter& rIter, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >& xComp);
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+ };
+
+ //========================================================================
+ typedef SvLBoxEntry* SvLBoxEntryPtr;
+ SV_DECL_PTRARR_SORT( SvLBoxEntrySortedArray, SvLBoxEntryPtr, 16, 16 )
+
+ class NavigatorTree : public SvTreeListBox, public SfxListener
+ {
+ enum DROP_ACTION { DA_SCROLLUP, DA_SCROLLDOWN, DA_EXPANDNODE };
+ enum SELDATA_ITEMS { SDI_DIRTY, SDI_ALL, SDI_NORMALIZED, SDI_NORMALIZED_FORMARK };
+
+ // beim Droppen will ich scrollen und Folder aufklappen koennen, dafuer :
+ AutoTimer m_aDropActionTimer;
+ Timer m_aSynchronizeTimer;
+ // die Meta-Daten ueber meine aktuelle Selektion
+ SvLBoxEntrySortedArray m_arrCurrentSelection;
+ // the entries which, in the view, are currently marked as "cut" (painted semi-transparent)
+ ListBoxEntrySet m_aCutEntries;
+ // die Images, die ich brauche (und an FormDatas und EntryDatas weiterreiche)
+ ImageList m_aNavigatorImages;
+ ImageList m_aNavigatorImagesHC;
+
+ ::svxform::OControlExchangeHelper m_aControlExchange;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+ NavigatorTreeModel* m_pNavModel;
+ SvLBoxEntry* m_pRootEntry;
+ SvLBoxEntry* m_pEditEntry;
+
+ ULONG nEditEvent;
+
+ SELDATA_ITEMS m_sdiState;
+ Point m_aTimerTriggered; // die Position, an der der DropTimer angeschaltet wurde
+ DROP_ACTION m_aDropActionType;
+
+ sal_uInt16 m_nSelectLock;
+ sal_uInt16 m_nFormsSelected;
+ sal_uInt16 m_nControlsSelected;
+ sal_uInt16 m_nHiddenControls; // (die Zahl geht in m_nControlsSelected mit ein)
+
+ unsigned short m_aTimerCounter;
+
+ sal_Bool m_bDragDataDirty : 1; // dito
+ sal_Bool m_bPrevSelectionMixed : 1;
+ sal_Bool m_bMarkingObjects : 1; // wenn das sal_True ist, brauche ich auf die RequestSelectHints nicht reagieren
+ sal_Bool m_bRootSelected : 1;
+ sal_Bool m_bInitialUpdate : 1; // bin ich das erste Mal im UpdateContent ?
+ sal_Bool m_bKeyboardCut : 1;
+
+
+ void UpdateContent();
+ sal_Bool IsDeleteAllowed();
+ FmControlData* NewControl( const ::rtl::OUString& rServiceName, SvLBoxEntry* pParentEntry, sal_Bool bEditName = sal_True );
+ void NewForm( SvLBoxEntry* pParentEntry );
+ SvLBoxEntry* Insert( FmEntryData* pEntryData, ULONG nRelPos=LIST_APPEND );
+ void Remove( FmEntryData* pEntryData );
+
+
+ void CollectSelectionData(SELDATA_ITEMS sdiHow);
+ // sammelt in m_arrCurrentSelection die aktuell selektierten Eintraege, normalisiert die Liste wenn verlangt
+ // SDI_NORMALIZED bedeutet einfach, dass alle Eintraege, die schon einen selektierten Vorfahren haben, nicht mit gesammelt
+ // werden.
+ // SDI_NORMALIZED_FORMARK bedeutet, dass wie bei SDI_NORMALIZED verfahren wird, aber Eintraege, deren direktes Elter nicht
+ // selektiert ist, aufgenommen werden (unabhaengig vom Status weiterer Vorfahren), desgleichen Formulare, die selektiert sind,
+ // unabhaengig vom Status irgendwelcher Vorfahren
+ // Bei beiden Normalized-Modi enthalten die m_nFormsSelected, ... die richtige Anzahl, auch wenn nicht alle dieser Eintraege
+ // in m_arrCurrentSelection landen.
+ // SDI_DIRTY ist natuerlich nicht erlaubt als Parameter
+
+ // ein einziges Interface fuer alle selektierten Eintraege zusammensetzen
+ void ShowSelectionProperties(sal_Bool bForce = sal_False);
+ // alle selektierten Elemnte loeschen
+ void DeleteSelection();
+
+ void SynchronizeSelection(FmEntryDataArray& arredToSelect);
+ // nach dem Aufruf dieser Methode sind genau die Eintraege selektiert, die in dem Array bezeichnet sind
+ void SynchronizeSelection();
+ // macht das selbe, nimmt die MarkList der ::com::sun::star::sdbcx::View
+ void SynchronizeMarkList();
+ // umgekehrte Richtung von SynchronizeMarkList : markiert in der ::com::sun::star::sdbcx::View alle der aktuellen Selektion entsprechenden Controls
+
+ void CollectObjects(FmFormData* pFormData, sal_Bool bDeep, ::std::set< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > >& _rObjects);
+
+ // im Select aktualisiere ich normalerweise die Marklist der zugehoerigen ::com::sun::star::sdbcx::View, mit folgenden Funktionen
+ // kann ich das Locking dieses Verhaltens steuern
+ void LockSelectionHandling() { ++m_nSelectLock; }
+ void UnlockSelectionHandling() { --m_nSelectLock; }
+ sal_Bool IsSelectionHandlingLocked() const { return m_nSelectLock>0; }
+
+ sal_Bool IsHiddenControl(FmEntryData* pEntryData);
+
+ DECL_LINK( OnEdit, void* );
+ DECL_LINK( OnDropActionTimer, void* );
+
+ DECL_LINK(OnEntrySelDesel, NavigatorTree*);
+ DECL_LINK(OnSynchronizeTimer, void*);
+
+ DECL_LINK( OnClipboardAction, void* );
+
+ protected:
+ virtual void Command( const CommandEvent& rEvt );
+
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+ public:
+ NavigatorTree(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB, Window* pParent );
+ virtual ~NavigatorTree();
+
+ void Clear();
+ void UpdateContent( FmFormShell* pFormShell );
+ void MarkViewObj( FmFormData* pFormData, sal_Bool bMark, sal_Bool bDeep = sal_False );
+ void MarkViewObj( FmControlData* pControlData, sal_Bool bMarkHandles, sal_Bool bMark );
+ void UnmarkAllViewObj();
+
+ sal_Bool IsFormEntry( SvLBoxEntry* pEntry );
+ sal_Bool IsFormComponentEntry( SvLBoxEntry* pEntry );
+
+ ::rtl::OUString GenerateName( FmEntryData* pEntryData );
+
+ NavigatorTreeModel* GetNavModel() const { return m_pNavModel; }
+ SvLBoxEntry* FindEntry( FmEntryData* pEntryData );
+
+ virtual sal_Bool EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText );
+ virtual sal_Bool Select( SvLBoxEntry* pEntry, sal_Bool bSelect=sal_True );
+ virtual sal_Bool EditingEntry( SvLBoxEntry* pEntry, Selection& );
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+ virtual void ModelHasRemoved( SvListEntry* _pEntry );
+
+ using SvTreeListBox::Insert;
+ using SvTreeListBox::ExecuteDrop;
+ using SvTreeListBox::Select;
+ using SvTreeListBox::Notify;
+
+ private:
+ sal_Int8 implAcceptDataTransfer( const DataFlavorExVector& _rFlavors, sal_Int8 _nAction, const Point& _rDropPos, sal_Bool _bDnD );
+ sal_Int8 implAcceptDataTransfer( const DataFlavorExVector& _rFlavors, sal_Int8 _nAction, SvLBoxEntry* _pTargetEntry, sal_Bool _bDnD );
+
+ sal_Int8 implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, const Point& _rDropPos, sal_Bool _bDnD );
+ sal_Int8 implExecuteDataTransfer( const OControlTransferData& _rData, sal_Int8 _nAction, SvLBoxEntry* _pTargetEntry, sal_Bool _bDnD );
+
+ // check if a cut, copy, or drag operation can be started in the current situation
+ sal_Bool implAllowExchange( sal_Int8 _nAction, sal_Bool* _pHasNonHidden = NULL );
+ // check if a paste with the current clipboard content can be accepted
+ sal_Bool implAcceptPaste( );
+
+ // fills m_aControlExchange in preparation of a DnD or clipboard operation
+ sal_Bool implPrepareExchange( sal_Int8 _nAction );
+
+ void doPaste();
+ void doCopy();
+ void doCut();
+
+ sal_Bool doingKeyboardCut( ) const { return m_bKeyboardCut; }
+ };
+
+ //========================================================================
+ class NavigatorFrame : public SfxDockingWindow, public SfxControllerItem
+ {
+ private:
+ ::svxform::NavigatorTree* m_pNavigatorTree;
+
+ protected:
+ virtual void Resize();
+ virtual sal_Bool Close();
+ virtual void GetFocus();
+ virtual Size CalcDockingSize( SfxChildAlignment );
+ virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment );
+
+ using SfxDockingWindow::StateChanged;
+
+ public:
+ NavigatorFrame( SfxBindings *pBindings, SfxChildWindow *pMgr,
+ Window* pParent );
+ virtual ~NavigatorFrame();
+
+ void UpdateContent( FmFormShell* pFormShell );
+ void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
+ void FillInfo( SfxChildWinInfo& rInfo ) const;
+ };
+
+ //========================================================================
+ class SVX_DLLPUBLIC NavigatorFrameManager : public SfxChildWindow
+ {
+ public:
+ SVX_DLLPRIVATE NavigatorFrameManager( Window *pParent, sal_uInt16 nId, SfxBindings *pBindings,
+ SfxChildWinInfo *pInfo );
+ SFX_DECL_CHILDWINDOW( NavigatorFrameManager );
+ };
+
+//............................................................................
+} // namespace svxform
+//............................................................................
+
+#endif // _SVX_FMEXPL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmgroup.hxx b/svx/source/inc/fmgroup.hxx
new file mode 100644
index 000000000000..df57b92fefab
--- /dev/null
+++ b/svx/source/inc/fmgroup.hxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMGROUP_HXX
+#define _SVX_FMGROUP_HXX
+
+#include "fmcpont.hxx"
+
+#include <dbform.hxx>
+
+DECLARE_LIST( FmCtrlModelList, XInterface* );
+
+struct FmXGroupModel_Impl;
+
+//==================================================================
+// FmXGroupModel
+//==================================================================
+class FmXGroupModel : public XBoundControl,
+ public XLoadListener,
+ public XPropertyChangeListener,
+ public XGroup,
+ public FmXControlModel
+{
+ FmFormControlMap aControlMap;
+
+ friend Reflection* FmXGroupModel_getReflection();
+ FmXGroupModel_Impl* pGroupModelData; // Properties
+
+public:
+ FmXGroupModel();
+ virtual ~FmXGroupModel();
+
+ // UNO Anbindung
+ SMART_UNO_DECLARATION( FmXGroupModel, FmXControlModel );
+ virtual XInterface* queryInterface(UsrUik);
+ virtual XIdlClassRef getIdlClass();
+
+ // XGroup
+ virtual INT32 getFormControlCount();
+ virtual XFormControlRef getFormControlByName( const XubString& sName ) const;
+ virtual XFormControlRef getFormControlByIndex( INT32 Index ) const;
+ virtual void appendFormControl( const XFormControlRef& FormControl );
+ virtual XFormControlRef removeFormControl( const XFormControlRef& FormControl );
+
+ // XFormControl
+ virtual void setParent( const XFormRef& Parent );
+
+ // XEventListener
+ virtual void disposing( const EventObject& Source );
+
+ // XPropertiesChangeListener
+ virtual void propertyChange( const PropertyChangeEvent& evt );
+
+ // XLoadListener
+ virtual void loaded( const EventObject& rEvent );
+ virtual void unloaded( const EventObject& rEvent );
+
+ // XBoundControl
+ virtual void addBoundControlListener( const XBoundControlListenerRef& l );
+ virtual void removeBoundControlListener( const XBoundControlListenerRef& l );
+
+ // XPersistObject
+ virtual XubString getServiceName( void ) const;
+ virtual void write( const XObjectOutputStreamRef& OutStream );
+ virtual void read( const XObjectInputStreamRef& InStream );
+
+ // PropertySetInterface
+ virtual FmXPropertySetInfo* createPropertySetInfo() const;
+ virtual BOOL setPropertyValue( UINT16 nId, const XubString& aPropertyName,
+ const UsrAny& aValue,
+ PropertyChangeEventSequence* pSeq,
+ INT32 nIndex );
+ virtual UsrAny getPropertyValue( UINT16 nId, const XubString& aPropertyName ) const;
+ virtual void addPropertyChangeListener( const XubString& aPropertyName, const XPropertyChangeListenerRef& aListener );
+ virtual void removePropertyChangeListener( const XubString& aPropertyName, const XPropertyChangeListenerRef& aListener );
+};
+
+//==================================================================
+// FmXGroupModelInfo
+// Properties:
+//==================================================================
+class FmXGroupModelInfo : public FmXControlModelInfo
+{
+ friend class FmXGroupModel;
+
+protected:
+ FmXGroupModelInfo( const FmXGroupModel* pCp );
+ virtual void fillProperties( UINT32& nIndex, PropertySequence& aSeq ) const;
+};
+
+
+#endif // _SVX_FMGROUP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmhlpids.hrc b/svx/source/inc/fmhlpids.hrc
new file mode 100644
index 000000000000..70e7b51004f8
--- /dev/null
+++ b/svx/source/inc/fmhlpids.hrc
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * 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 _SVX_FMHLPIDS_HRC
+#define _SVX_FMHLPIDS_HRC
+
+// include -----------------------------------------------------------
+#ifndef _SVX_FMHELP_HRC
+#include "fmhelp.hrc"
+#endif
+
+#endif
+
diff --git a/svx/source/inc/fmitems.hxx b/svx/source/inc/fmitems.hxx
new file mode 100644
index 000000000000..350a39a0437b
--- /dev/null
+++ b/svx/source/inc/fmitems.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMITEMS_HXX
+#define _SVX_FMITEMS_HXX
+
+
+#include <svl/poolitem.hxx>
+#include <comphelper/uno3.hxx>
+// FORWARD_DECLARE_INTERFACE(awt,XControlContainer)
+FORWARD_DECLARE_INTERFACE(uno,Any)
+// class ::com::sun::star::uno::Any;
+
+//==================================================================
+class FmInterfaceItem : public SfxPoolItem
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInterface;
+
+public:
+ TYPEINFO();
+
+ FmInterfaceItem( const sal_uInt16 nId, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxInterface )
+ :SfxPoolItem( nId )
+ ,xInterface( rxInterface )
+ {}
+
+ inline FmInterfaceItem& operator=( const FmInterfaceItem &rCpy );
+
+ // "pure virtual Methoden" vom SfxPoolItem
+ virtual int operator==( const SfxPoolItem& ) const;
+
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
+ virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const;
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > GetInterface() const { return xInterface; }
+};
+
+inline FmInterfaceItem& FmInterfaceItem::operator=( const FmInterfaceItem &rCpy )
+{
+ xInterface = rCpy.xInterface;
+
+ return *this;
+}
+
+
+
+#endif // _SVX_FMITEMS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx
new file mode 100644
index 000000000000..3febbb2c1ff8
--- /dev/null
+++ b/svx/source/inc/fmobj.hxx
@@ -0,0 +1,136 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMOBJ_HXX
+#define _SVX_FMOBJ_HXX
+
+#include <svx/svdouno.hxx>
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+
+class FmFormView;
+
+//==================================================================
+// FmFormObj
+//==================================================================
+class FmXForms;
+class FmFormObj: public SdrUnoObj
+{
+ ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor > aEvts; // events des Objects
+ ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor> m_aEventsHistory;
+ // valid if and only if m_pEnvironmentHistory != NULL, this are the events which we're set when
+ // m_pEnvironmentHistory was created
+
+ FmFormView* m_pControlCreationView;
+ ULONG m_nControlCreationEvent;
+
+ // Informationen fuer die Controlumgebung
+ // werden nur vorgehalten, wenn ein Object sich nicht in einer Objectliste befindet
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer> m_xParent;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > m_xEnvironmentHistory;
+ sal_Int32 m_nPos;
+ sal_Int32 m_nType;
+
+ OutputDevice* m_pLastKnownRefDevice;
+ // the last ref device we know, as set at the model
+ // only to be used for comparison with the current ref device!
+
+public:
+ SVX_DLLPUBLIC FmFormObj(const ::rtl::OUString& rModelName,sal_Int32 _nType);
+ SVX_DLLPUBLIC FmFormObj(sal_Int32 _nType);
+
+ TYPEINFO();
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer>&
+ GetOriginalParent() const { return m_xParent; }
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >&
+ GetOriginalEvents() const { return aEvts; }
+ sal_Int32
+ GetOriginalIndex() const { return m_nPos; }
+
+ void SetObjEnv(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer>& xForm,
+ const sal_Int32 nIdx,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& rEvts );
+ void ClearObjEnv();
+
+public:
+ virtual ~FmFormObj();
+ virtual void SetPage(SdrPage* pNewPage);
+
+ virtual sal_uInt32 GetObjInventor() const;
+ virtual sal_uInt16 GetObjIdentifier() const;
+ virtual void NbcReformatText();
+
+ virtual SdrObject* Clone() const;
+ // #116235# virtual SdrObject* Clone(SdrPage* pPage, SdrModel* pModel) const;
+ virtual void operator= (const SdrObject& rObj);
+
+ virtual void SetModel(SdrModel* pNewModel);
+
+ virtual void clonedFrom(const FmFormObj* _pSource);
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> ensureModelEnv(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rSourceContainer, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer> _rTopLevelDestContainer);
+
+ /** returns the FmFormObj behind the given SdrObject
+
+ In case the SdrObject *is* an FmFormObject, this is a simple cast. In case the SdrObject
+ is a virtual object whose referenced object is an FmFormObj, then this referenced
+ object is returned. In all other cases, NULL is returned.
+ */
+ static FmFormObj* GetFormObject( SdrObject* _pSdrObject );
+ static const FmFormObj* GetFormObject( const SdrObject* _pSdrObject );
+
+ /** returns the type of this form object. See fmglob.hxx
+ */
+ sal_Int32 getType() const;
+
+ virtual void SetUnoControlModel( const ::com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& _rxModel );
+
+protected:
+ virtual bool EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd );
+ virtual void BrkCreate( SdrDragStat& rStat );
+
+ // #i70852# overload Layer interface to force to FormColtrol layer
+ virtual SdrLayerID GetLayer() const;
+ virtual void NbcSetLayer(SdrLayerID nLayer);
+
+private:
+ /** isolates the control model from its form component hierarchy, i.e. removes it from
+ its parent.
+ */
+ void impl_isolateControlModel_nothrow();
+
+ /** forwards the reference device of our SdrModel to the control model
+ */
+ void impl_checkRefDevice_nothrow( bool _force = false );
+};
+
+
+#endif // _FM_FMOBJ_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmpgeimp.hxx b/svx/source/inc/fmpgeimp.hxx
new file mode 100644
index 000000000000..640f9670036d
--- /dev/null
+++ b/svx/source/inc/fmpgeimp.hxx
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMUNOPGE_HXX
+#define _SVX_FMUNOPGE_HXX
+
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XMap.hpp>
+
+#include <tools/list.hxx>
+#include <tools/link.hxx>
+#include <comphelper/uno3.hxx>
+#include <cppuhelper/weakref.hxx>
+
+#include "svx/svxdllapi.h"
+#include <map>
+
+class SvStream;
+class FmFormObj;
+class FmFormPage;
+class SdrObject;
+
+//FORWARD_DECLARE_INTERFACE(uno,Reference)
+FORWARD_DECLARE_INTERFACE(io,XObjectOutputStream)
+FORWARD_DECLARE_INTERFACE(io,XObjectInputStream)
+FORWARD_DECLARE_INTERFACE(container,XIndexContainer)
+
+class SdrObjList;
+
+//==================================================================
+// FmFormPageImpl
+// lauscht an allen Containern, um festzustellen, wann Objecte
+// eingefuegt worden sind und wann diese entfernt wurden
+//==================================================================
+
+class SVX_DLLPRIVATE FmFormPageImpl
+{
+ ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >,SdrObject* > m_aComponentMap;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > xCurrentForm;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xForms;
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::container::XMap > m_aControlShapeMap;
+
+ FmFormPage& m_rPage;
+ Link m_aFormsCreationHdl;
+
+ sal_Bool m_bFirstActivation;
+ bool m_bAttemptedFormCreation;
+ bool m_bInFind;
+
+protected:
+ void Init();
+
+public:
+ FmFormPageImpl( FmFormPage& _rPage );
+ FmFormPageImpl( FmFormPage& _rPage, const FmFormPageImpl& rImpl );
+ ~FmFormPageImpl();
+
+ // nur wichtig fuer den DesignMode
+ void setCurForm(::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> xForm);
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> getDefaultForm();
+
+ /** finds a place in the form component hierarchy where to insert the given component
+
+ Note that no actual insertion happens, this is the responsibility of the caller (as
+ the caller might decide on a suitable place where in the returned container the insertion
+ should happen).
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findPlaceInFormComponentHierarchy(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& rContent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase = ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>(),
+ const ::rtl::OUString& rDBTitle = ::rtl::OUString(),
+ const ::rtl::OUString& rCursorSource = ::rtl::OUString(),
+ sal_Int32 nCommandType = 0
+ );
+
+ // activation handling
+ inline sal_Bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
+ inline void setHasBeenActivated( ) { m_bFirstActivation = sal_False; }
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& getForms( bool _bForceCreate = true );
+
+ void SetFormsCreationHdl( const Link& _rFormsCreationHdl ) { m_aFormsCreationHdl = _rFormsCreationHdl; }
+ const Link& GetFormsCreationHdl() const { return m_aFormsCreationHdl; }
+
+protected:
+ /** finds a form with a given data source signature
+ @param rForm
+ the form to start the search with. This form, including all possible sub forms,
+ will be examined
+ @param rDatabase
+ the data source which to which the found form must be bound
+ @param rCommand
+ the desired Command property value of the sought-after form
+ @param nCommandType
+ the desired CommandType property value of the sought-after form
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findFormForDataSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& rForm,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase,
+ const ::rtl::OUString& rCommand,
+ sal_Int32 nCommandType
+ );
+
+public:
+ ::rtl::OUString setUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& xFormComponent, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& xControls);
+
+ void formObjectInserted( const FmFormObj& _object );
+ void formObjectRemoved( const FmFormObj& _object );
+
+ /** returns an object mapping from control models to drawing shapes.
+ */
+ SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap > getControlToShapeMap();
+
+private:
+ /** validates whether <member>xCurrentForm</member> is still valid and to be used
+
+ There are situations where our current form becomes invalid, without us noticing this. Thus,
+ every method which accesses <member>xCurrentForm</member> should beforehand validate the current
+ form by calling this method.
+
+ If <member>xCurrentForm</member> is not valid anymore, it is reset to <NULL/>.
+
+ @return
+ <TRUE/> if and only if xCurrentForm is valid.
+
+ @since #i40086#
+ */
+ bool validateCurForm();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XMap >
+ impl_createControlShapeMap_nothrow();
+
+private:
+ FmFormPageImpl(); // never implemented
+ FmFormPageImpl( const FmFormPageImpl& ); // never implemented
+ FmFormPageImpl& operator=( const FmFormPageImpl& ); // never implemented
+};
+
+
+#endif // _SVX_FMUNOPGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmprop.hrc b/svx/source/inc/fmprop.hrc
new file mode 100644
index 000000000000..d9f49b2fcce1
--- /dev/null
+++ b/svx/source/inc/fmprop.hrc
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * 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 _SVX_FMPROP_HRC
+#define _SVX_FMPROP_HRC
+
+// PropertyId's, welche eine Zuordnung zu einen PropertyName haben, das koennten
+// auch in Zukunft WhichIds sein -> Itemset
+#define FM_ATTR_START 0
+
+#define FM_ATTR_FILTER ( FM_ATTR_START + 1 )
+#define FM_ATTR_FORM_OPERATIONS ( FM_ATTR_START + 2 )
+
+#define FM_PROP_NAME rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) )
+#define FM_PROP_CLASSID rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ClassId" ) )
+#define FM_PROP_ALIGN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Align" ) )
+#define FM_PROP_ROWCOUNT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowCount" ) )
+#define FM_PROP_ROWCOUNTFINAL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsRowCountFinal" ) )
+#define FM_PROP_FETCHSIZE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FetchSize" ) )
+#define FM_PROP_VALUE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value" ) )
+#define FM_PROP_VALUEMIN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ValueMin" ) )
+#define FM_PROP_VALUEMAX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ValueMax" ) )
+#define FM_PROP_VALUESTEP rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ValueStep" ) )
+#define FM_PROP_TEXT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text" ) )
+#define FM_PROP_LABEL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" ) )
+#define FM_PROP_NAVIGATION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NavigationBarMode" ) )
+#define FM_PROP_CYCLE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cycle" ) )
+#define FM_PROP_CONTROLSOURCE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataField" ) )
+#define FM_PROP_ENABLED rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Enabled" ) )
+#define FM_PROP_SPIN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Spin" ) )
+#define FM_PROP_READONLY rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ReadOnly" ) )
+#define FM_PROP_FILTER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Filter" ) )
+#define FM_PROP_AUTOINCREMENT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsAutoIncrement" ) )
+#define FM_PROP_WIDTH rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) )
+#define FM_PROP_SEARCHABLE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsSearchable" ) )
+#define FM_PROP_MULTILINE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MultiLine" ) )
+#define FM_PROP_TARGET_URL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ) )
+#define FM_PROP_DEFAULTCONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultControl" ) )
+#define FM_PROP_MAXTEXTLEN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxTextLen" ) )
+#define FM_PROP_DATE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Date" ) )
+#define FM_PROP_TIME rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Time" ) )
+#define FM_PROP_STATE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "State" ) )
+#define FM_PROP_TRISTATE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TriState" ) )
+#define FM_PROP_STRINGITEMLIST rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StringItemList" ) )
+#define FM_PROP_DEFAULT_TEXT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultText" ) )
+#define FM_PROP_DEFAULTCHECKED rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultState" ) )
+#define FM_PROP_DEFAULT_DATE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultDate" ) )
+#define FM_PROP_DEFAULT_TIME rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultTime" ) )
+#define FM_PROP_DEFAULT_VALUE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultValue" ) )
+#define FM_PROP_FORMATKEY rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormatKey" ) )
+#define FM_PROP_FORMATSSUPPLIER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormatsSupplier" ) )
+#define FM_PROP_LISTSOURCETYPE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ListSourceType" ) )
+#define FM_PROP_LISTSOURCE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ListSource" ) )
+#define FM_PROP_SELECT_SEQ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectedItems" ) )
+#define FM_PROP_VALUE_SEQ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ValueItemList" ) )
+#define FM_PROP_DEFAULT_SELECT_SEQ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultSelection" ) )
+#define FM_PROP_DECIMAL_ACCURACY rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DecimalAccuracy" ) )
+#define FM_PROP_EDITMASK rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EditMask" ) )
+#define FM_PROP_ISREADONLY rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) )
+#define FM_PROP_FIELDTYPE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) )
+#define FM_PROP_REFVALUE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RefValue" ) )
+#define FM_PROP_STRICTFORMAT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StrictFormat" ) )
+#define FM_PROP_DATASOURCE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataSourceName" ) )
+#define FM_PROP_LITERALMASK rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LiteralMask" ) )
+#define FM_PROP_SHOWTHOUSANDSEP rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ShowThousandsSeparator" ) )
+#define FM_PROP_CURRENCYSYMBOL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CurrencySymbol" ) )
+#define FM_PROP_DATEFORMAT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateFormat" ) )
+#define FM_PROP_DATEMIN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateMin" ) )
+#define FM_PROP_DATEMAX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateMax" ) )
+#define FM_PROP_DATE_SHOW_CENTURY rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateShowCentury" ) )
+#define FM_PROP_TIMEFORMAT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TimeFormat" ) )
+#define FM_PROP_TIMEMIN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TimeMin" ) )
+#define FM_PROP_TIMEMAX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TimeMax" ) )
+#define FM_PROP_LINECOUNT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineCount" ) )
+#define FM_PROP_BOUNDCOLUMN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BoundColumn" ) )
+#define FM_PROP_HASNAVIGATION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasNavigationBar" ) )
+#define FM_PROP_FONT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontDescriptor" ) )
+#define FM_PROP_BACKGROUNDCOLOR rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BackgroundColor" ) )
+#define FM_PROP_TEXTCOLOR rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextColor" ) )
+#define FM_PROP_BORDER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Border" ) )
+#define FM_PROP_DROPDOWN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dropdown" ) )
+#define FM_PROP_ROWHEIGHT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeight" ) )
+#define FM_PROP_HELPTEXT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpText" ) )
+#define FM_PROP_HELPURL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HelpURL" ) )
+#define FM_PROP_RECORDMARKER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasRecordMarker" ) )
+#define FM_PROP_BOUNDFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BoundField" ) )
+#define FM_PROP_EFFECTIVE_VALUE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EffectiveValue" ) )
+#define FM_PROP_EFFECTIVE_DEFAULT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EffectiveDefault" ) )
+#define FM_PROP_EFFECTIVE_MIN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EffectiveMin" ) )
+#define FM_PROP_EFFECTIVE_MAX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EffectiveMax" ) )
+#define FM_PROP_HIDDEN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Hidden" ) )
+#define FM_PROP_FILTERPROPOSAL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseFilterValueProposal" ) )
+#define FM_PROP_FIELDSOURCE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FieldSource" ) )
+#define FM_PROP_TABLENAME rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TableName" ) )
+#define FM_PROP_FILTERSUPPLIER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterSupplier" ) )
+#define FM_PROP_CURRENTFILTER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CurrentFilter" ) )
+#define FM_PROP_SELECTED_FIELDS rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectedFields" ) )
+#define FM_PROP_SELECTED_TABLES rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectedTables" ) )
+#define FM_PROP_THREADSAFE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThreadSafe" ) )
+#define FM_PROP_CONTROLLABEL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LabelControl" ) )
+#define FM_PROP_CURSORCOLOR rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CursorColor" ) )
+#define FM_PROP_ALWAYSSHOWCURSOR rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AlwaysShowCursor" ) )
+#define FM_PROP_DISPLAYSYNCHRON rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisplayIsSynchron" ) )
+#define FM_PROP_ISMODIFIED rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsModified" ) )
+#define FM_PROP_ISNEW rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsNew" ) )
+#define FM_PROP_PRIVILEGES rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Privileges" ) )
+#define FM_PROP_COMMAND rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Command" ) )
+#define FM_PROP_COMMANDTYPE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CommandType" ) )
+#define FM_PROP_RESULTSET_CONCURRENCY rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResultSetConcurrency" ) )
+#define FM_PROP_INSERTONLY rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IgnoreResult" ) )
+#define FM_PROP_RESULTSET_TYPE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ResultSetType" ) )
+#define FM_PROP_ESCAPE_PROCESSING rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EscapeProcessing" ) )
+#define FM_PROP_APPLYFILTER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ApplyFilter" ) )
+#define FM_PROP_ISNULLABLE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsNullable" ) )
+#define FM_PROP_ACTIVECOMMAND rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveCommand" ) )
+#define FM_PROP_ISCURRENCY rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsCurrency" ) )
+#define FM_PROP_URL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) )
+#define FM_PROP_ACTIVE_CONNECTION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ActiveConnection" ) )
+#define FM_PROP_SORT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Order" ) )
+#define FM_PROP_CONTROLSOURCEPROPERTY rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataFieldProperty" ) )
+#define FM_PROP_REALNAME rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RealName" ) )
+#define FM_PROP_TEXTLINECOLOR rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextLineColor" ) )
+#define FM_PROP_FONTEMPHASISMARK rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontEmphasisMark" ) )
+#define FM_PROP_FONTRELIEF rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontRelief" ) )
+#define FM_PROP_SCROLLVALUE_MIN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScrollValueMin" ) )
+#define FM_PROP_SCROLLVALUE_MAX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScrollValueMax" ) )
+#define FM_PROP_DEFAULT_SCROLLVALUE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultScrollValue" ) )
+#define FM_PROP_LINEINCREMENT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineIncrement" ) )
+#define FM_PROP_BLOCKINCREMENT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BlockIncrement" ) )
+#define FM_PROP_ORIENTATION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Orientation" ) )
+#define FM_PROP_REPEAT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Repeat" ) )
+#define FM_PROP_REPEATDELAY rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RepeatDelay" ) )
+#define FM_PROP_SYMBOLCOLOR rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SymbolColor" ) )
+#define FM_PROP_VISIBILESIZE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VisibleSize" ) )
+#define FM_PROP_SPINVALUE_MIN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SpinValueMin" ) )
+#define FM_PROP_SPINVALUE_MAX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SpinValueMax" ) )
+#define FM_PROP_DEFAULT_SPINVALUE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultSpinValue" ) )
+#define FM_PROP_SPININCREMENT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SpinIncrement" ) )
+#define FM_PROP_LINEENDFORMAT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineEndFormat" ) )
+#define FM_PROP_TOGGLE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Toggle" ) )
+#define FM_PROP_FOCUSONCLICK rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FocusOnClick" ) )
+#define FM_PROP_HIDEINACTIVESELECTION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HideInactiveSelection" ) )
+#define FM_PROP_VISUALEFFECT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VisualEffect" ) )
+#define FM_PROP_BORDERCOLOR rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BorderColor" ) )
+#define FM_PROP_DYNAMIC_CONTROL_BORDER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DynamicControlBorder" ) )
+#define FM_PROP_CONTROL_BORDER_COLOR_FOCUS rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlBorderColorOnFocus" ) )
+#define FM_PROP_CONTROL_BORDER_COLOR_MOUSE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlBorderColorOnHover" ) )
+#define FM_PROP_CONTROL_BORDER_COLOR_INVALID rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlBorderColorOnInvalid" ) )
+#define FM_PROP_BUTTON_TYPE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) )
+#define FM_PROP_FORM_OPERATIONS rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormOperations" ) )
+#define FM_PROP_INPUT_REQUIRED rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InputRequired" ) )
+#define FM_PROP_WRITING_MODE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WritingMode" ) )
+#define FM_PROP_MOUSE_WHEEL_BEHAVIOR rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MouseWheelBehavior" ) )
+#define FM_PROP_DESCRIPTION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Description" ) )
+
+#endif // _SVX_FMPROP_HRC
diff --git a/svx/source/inc/fmresids.hrc b/svx/source/inc/fmresids.hrc
new file mode 100644
index 000000000000..08982d8444ea
--- /dev/null
+++ b/svx/source/inc/fmresids.hrc
@@ -0,0 +1,264 @@
+/*************************************************************************
+ *
+ * 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 _SVX_FMRESIDS_HRC
+#define _SVX_FMRESIDS_HRC
+
+// include -----------------------------------------------------------
+#include <svl/solar.hrc>
+
+// unnamed ressources -------------------------------------------------------
+// sub ressources .....................
+
+// ImageList-Id's -----------------------------------------------------------
+#define RID_SVXIMGLIST_FMEXPL (RID_FORMS_START + 0)
+#define RID_SVXIMGLIST_FMEXPL_HC (RID_FORMS_START + 2)
+
+// Image-Id's -----------------------------------------------------------
+//#define SID_FMSLOTS_START (SID_SVX_START + 592) -> svxids.hrc
+#define RID_SVXIMG_FORM SID_FM_CONFIG
+#define RID_SVXIMG_CONTROL SID_CHOOSE_CONTROLS
+#define RID_SVXIMG_COLLAPSEDNODE (RID_FORMS_START + 2)
+#define RID_SVXIMG_EXPANDEDNODE (RID_FORMS_START + 3)
+#define RID_SVXIMG_BUTTON SID_FM_PUSHBUTTON
+#define RID_SVXIMG_RADIOBUTTON SID_FM_RADIOBUTTON
+#define RID_SVXIMG_CHECKBOX SID_FM_CHECKBOX
+#define RID_SVXIMG_FIXEDTEXT SID_FM_FIXEDTEXT
+#define RID_SVXIMG_GROUPBOX SID_FM_GROUPBOX
+#define RID_SVXIMG_EDIT SID_FM_EDIT
+#define RID_SVXIMG_LISTBOX SID_FM_LISTBOX
+#define RID_SVXIMG_COMBOBOX SID_FM_COMBOBOX
+#define RID_SVXIMG_FORMS (RID_FORMS_START +13)
+#define RID_SVXIMG_IMAGEBUTTON SID_FM_IMAGEBUTTON
+#define RID_SVXIMG_IMAGECONTROL SID_FM_IMAGECONTROL
+#define RID_SVXIMG_FILECONTROL SID_FM_FILECONTROL
+#define RID_SVXIMG_DATEFIELD SID_FM_DATEFIELD
+#define RID_SVXIMG_TIMEFIELD SID_FM_TIMEFIELD
+#define RID_SVXIMG_NUMERICFIELD SID_FM_NUMERICFIELD
+#define RID_SVXIMG_CURRENCYFIELD SID_FM_CURRENCYFIELD
+#define RID_SVXIMG_PATTERNFIELD SID_FM_PATTERNFIELD
+#define RID_SVXIMG_HIDDEN (RID_FORMS_START +22)
+#define RID_SVXIMG_GRID SID_FM_DBGRID
+#define RID_SVXIMG_FORMATTEDFIELD SID_FM_FORMATTEDFIELD
+#define RID_SVXIMG_FILTER SID_FM_FILTERCRIT
+#define RID_SVXIMG_DATE_N_TIME_FIELDS SID_FM_TWOFIELDS_DATE_N_TIME
+#define RID_SVXIMG_FIELD (RID_FORMS_START +27)
+#define RID_SVXIMG_SCROLLBAR SID_FM_SCROLLBAR
+#define RID_SVXIMG_SPINBUTTON SID_FM_SPINBUTTON
+#define RID_SVXIMG_NAVIGATIONBAR SID_FM_NAVIGATIONBAR
+
+// Dialog-Id's -----------------------------------------------------------
+#define RID_SVXTBX_FORM (RID_FORMS_START + 1)
+#define TBX_FORM (RID_FORMS_START + 2)
+#define RID_SVXDLG_ADD_TABLE (RID_FORMS_START + 3)
+#define RID_SVXDLG_TAB_ORDER (RID_FORMS_START + 4)
+#define RID_SVXDLG_SETFORM (RID_FORMS_START + 5)
+#define RID_SVX_FMEXPLORER (RID_FORMS_START + 6)
+#define RID_SVXDLG_ADD_DATAITEM (RID_FORMS_START + 12)
+#define RID_SVXDLG_ADD_CONDITION (RID_FORMS_START + 13)
+#define RID_SVXDLG_NAMESPACE_ITEM (RID_FORMS_START + 14)
+#define RID_SVXDLG_MANAGE_NAMESPACE (RID_FORMS_START + 15)
+#define RID_SVXDLG_ADD_SUBMISSION (RID_FORMS_START + 16)
+#define RID_SVXDLG_ADD_MODEL (RID_FORMS_START + 17)
+#define RID_SVXDLG_ADD_INSTANCE (RID_FORMS_START + 18)
+#define RID_SVXWIN_DATANAVIGATOR (RID_FORMS_START + 19)
+#define RID_SVX_XFORMS_TABPAGES (RID_FORMS_START + 20)
+
+// Toolbars ------------------------------------------------------------
+#define RID_SVXTBX_FORM_NAVIGATION (RID_FORMS_START + 1)
+#define RID_SVXTBX_FORM_FILTER (RID_FORMS_START + 2)
+#define RID_SVXTBX_TEXT_CONTROL_ATTRIBUTES (RID_FORMS_START + 3)
+#define RID_SVXTBX_CONTROLS (RID_FORMS_START + 4)
+#define RID_SVXTBX_MORECONTROLS (RID_FORMS_START + 5)
+#define RID_SVXTBX_FORMDESIGN (RID_FORMS_START + 6)
+
+// Menu-Id's -----------------------------------------------------------
+#define RID_FMEXPLORER_POPUPMENU (RID_FORMS_START + 0)
+#define RID_SVXMNU_ROWS (RID_FORMS_START + 1)
+#define RID_SVXMNU_COLS (RID_FORMS_START + 2)
+#define RID_SVXMNU_CELL (RID_FORMS_START + 3)
+#define RID_FMSHELL_CONVERSIONMENU (RID_FORMS_START + 4)
+#define RID_FM_FILTER_MENU (RID_FORMS_START + 5)
+#define RID_FM_TEXTATTRIBUTE_MENU (RID_FORMS_START + 6)
+#define MENU_FM_TEXTATTRIBITES_STYLE (RID_FORMS_START + 7)
+#define MENU_FM_TEXTATTRIBITES_ALIGNMENT (RID_FORMS_START + 8)
+#define MENU_FM_TEXTATTRIBITES_SPACING (RID_FORMS_START + 9)
+#define RID_MENU_DATANAVIGATOR (RID_FORMS_START + 10)
+
+// QueryBox-Id's -----------------------------------------------------------
+#define RID_QRY_SAVEMODIFIED (RID_FORMS_START + 1)
+#define RID_QRY_REMOVE_MODEL (RID_FORMS_START + 2)
+#define RID_QRY_REMOVE_INSTANCE (RID_FORMS_START + 3)
+#define RID_QRY_REMOVE_ELEMENT (RID_FORMS_START + 4)
+#define RID_QRY_REMOVE_ATTRIBUTE (RID_FORMS_START + 5)
+#define RID_QRY_LINK_WARNING (RID_FORMS_START + 6)
+#define RID_QRY_REMOVE_SUBMISSION (RID_FORMS_START + 7)
+#define RID_QRY_REMOVE_BINDING (RID_FORMS_START + 8)
+
+// ErrorBox-Id's -----------------------------------------------------------
+#define RID_ERR_INVALID_XMLNAME (RID_FORMS_START + 1)
+#define RID_ERR_INVALID_XMLPREFIX (RID_FORMS_START + 2)
+#define RID_ERR_DOUBLE_MODELNAME (RID_FORMS_START + 3)
+#define RID_ERR_EMPTY_SUBMISSIONNAME (RID_FORMS_START + 4)
+
+// String-Id's -----------------------------------------------------------
+#define RID_STR_FORMSHELL (RID_FORMS_START + 10)
+#define RID_STR_STDFORMNAME (RID_FORMS_START + 11)
+#define RID_STR_REC_TEXT (RID_FORMS_START + 12)
+#define RID_STR_REC_FROM_TEXT (RID_FORMS_START + 13)
+#define RID_STR_UNDO_PROPERTY (RID_FORMS_START + 14)
+#define RID_STR_UNDO_CONTAINER_INSERT (RID_FORMS_START + 15)
+#define RID_STR_UNDO_CONTAINER_REMOVE (RID_FORMS_START + 16)
+#define RID_STR_UNDO_CONTAINER_REMOVE_MULTIPLE (RID_FORMS_START + 27)
+#define RID_STR_UNDO_CONTAINER_REPLACE (RID_FORMS_START + 28)
+#define RID_STR_UNDO_TABORDER (RID_FORMS_START + 29)
+#define RID_STR_UNDO_DELETE_LOGICAL (RID_FORMS_START + 30)
+#define RID_STR_UNDO_MODEL_REPLACE (RID_FORMS_START + 31)
+#define RID_STR_NAVIGATIONBAR (RID_FORMS_START + 32)
+#define RID_STR_DEFAULT_CONTROL (RID_FORMS_START + 33)
+#define RID_STR_FORM (RID_FORMS_START + 36)
+#define RID_STR_FIELDSELECTION (RID_FORMS_START + 37)
+#define RID_STR_NO_PROPERTIES (RID_FORMS_START + 38)
+#define RID_STR_PROPERTIES_CONTROL (RID_FORMS_START + 39)
+#define RID_STR_PROPERTIES_FORM (RID_FORMS_START + 40)
+#define RID_STR_FMEXPLORER (RID_FORMS_START + 41)
+#define RID_STR_FORMS (RID_FORMS_START + 42)
+#define RID_STR_WRITEERROR (RID_FORMS_START + 43)
+#define RID_STR_DELETECONFIRM_RECORD (RID_FORMS_START + 44)
+#define RID_STR_DELETECONFIRM (RID_FORMS_START + 45)
+#define RID_STR_GROUPBOX (RID_FORMS_START + 46)
+#define RID_STR_NAVIGATION (RID_FORMS_START + 47)
+#define RID_STR_COLUMN (RID_FORMS_START + 48)
+#define RID_STR_DATE (RID_FORMS_START + 49)
+#define RID_STR_TIME (RID_FORMS_START + 50)
+#define RID_STR_PROPTITLE_NAVBAR (RID_FORMS_START + 51)
+#define RID_STR_PROPTITLE_PUSHBUTTON (RID_FORMS_START + 52)
+#define RID_STR_PROPTITLE_RADIOBUTTON (RID_FORMS_START + 53)
+#define RID_STR_PROPTITLE_CHECKBOX (RID_FORMS_START + 54)
+#define RID_STR_PROPTITLE_FIXEDTEXT (RID_FORMS_START + 55)
+#define RID_STR_PROPTITLE_GROUPBOX (RID_FORMS_START + 56)
+#define RID_STR_PROPTITLE_EDIT (RID_FORMS_START + 57)
+#define RID_STR_PROPTITLE_LISTBOX (RID_FORMS_START + 58)
+#define RID_STR_PROPTITLE_COMBOBOX (RID_FORMS_START + 59)
+#define RID_STR_PROPTITLE_IMAGEBUTTON (RID_FORMS_START + 60)
+#define RID_STR_PROPTITLE_IMAGECONTROL (RID_FORMS_START + 61)
+#define RID_STR_PROPTITLE_FILECONTROL (RID_FORMS_START + 62)
+#define RID_STR_PROPTITLE_DATEFIELD (RID_FORMS_START + 63)
+#define RID_STR_PROPTITLE_TIMEFIELD (RID_FORMS_START + 64)
+#define RID_STR_PROPTITLE_NUMERICFIELD (RID_FORMS_START + 65)
+#define RID_STR_PROPTITLE_CURRENCYFIELD (RID_FORMS_START + 66)
+#define RID_STR_PROPTITLE_PATTERNFIELD (RID_FORMS_START + 67)
+#define RID_STR_PROPTITLE_DBGRID (RID_FORMS_START + 68)
+#define RID_STR_PROPTITLE_MULTISELECT (RID_FORMS_START + 69)
+#define RID_STR_DELETECONFIRM_RECORDS (RID_FORMS_START + 70)
+#define RID_STR_CONTROL (RID_FORMS_START + 71)
+#define RID_STR_POSTFIX_DATE (RID_FORMS_START + 72)
+#define RID_STR_POSTFIX_TIME (RID_FORMS_START + 73)
+#define RID_STR_NODATACONTROLS (RID_FORMS_START + 77)
+#define RID_STR_FILTER_NAVIGATOR (RID_FORMS_START + 78)
+#define RID_STR_FILTER_FILTER_FOR (RID_FORMS_START + 79)
+#define RID_STR_FILTER_FILTER_OR (RID_FORMS_START + 80)
+#define RID_STR_PROPTITLE_FORMATTED (RID_FORMS_START + 81)
+#define RID_STR_SYNTAXERROR (RID_FORMS_START + 82)
+ // FREE
+#define RID_STR_NOCONTROLS_FOR_EXTERNALDISPLAY (RID_FORMS_START + 84)
+#define RID_STR_AUTOFIELD (RID_FORMS_START + 89)
+#define RID_STR_SVT_SQL_SYNTAX_ERROR (RID_FORMS_START + 90)
+#define RID_STR_SVT_SQL_SYNTAX_VALUE_NO_LIKE (RID_FORMS_START + 91)
+#define RID_STR_SVT_SQL_SYNTAX_FIELD_NO_LIKE (RID_FORMS_START + 92)
+#define RID_STR_SVT_SQL_SYNTAX_CRIT_NO_COMPARE (RID_FORMS_START + 93)
+#define RID_STR_SVT_SQL_SYNTAX_INT_NO_VALID (RID_FORMS_START + 94)
+#define RID_STR_SVT_SQL_SYNTAX_ACCESS_DAT_NO_VALID (RID_FORMS_START + 95)
+#define RID_STR_SVT_SQL_SYNTAX_REAL_NO_VALID (RID_FORMS_START + 96)
+#define RID_STR_SVT_SQL_SYNTAX_TABLE (RID_FORMS_START + 97)
+#define RID_STR_SVT_SQL_SYNTAX_COLUMN (RID_FORMS_START + 98)
+#define RID_STR_PROPTITLE_SCROLLBAR (RID_FORMS_START + 99)
+#define RID_STR_PROPTITLE_SPINBUTTON (RID_FORMS_START + 100)
+#define RID_STR_PROPTITLE_HIDDEN (RID_FORMS_START + 101)
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+#define RID_STR_DATANAVIGATOR (RID_FORMS_START + 124)
+#define RID_STR_DATANAV_SUBM_PARENT (RID_FORMS_START + 125)
+#define RID_STR_DATANAV_SUBM_ID (RID_FORMS_START + 126)
+#define RID_STR_DATANAV_SUBM_ACTION (RID_FORMS_START + 127)
+#define RID_STR_DATANAV_SUBM_METHOD (RID_FORMS_START + 128)
+#define RID_STR_DATANAV_SUBM_REF (RID_FORMS_START + 129)
+#define RID_STR_DATANAV_SUBM_BIND (RID_FORMS_START + 130)
+#define RID_STR_DATANAV_SUBM_REPLACE (RID_FORMS_START + 131)
+#define RID_STR_DATANAV_ADD_ELEMENT (RID_FORMS_START + 132)
+#define RID_STR_DATANAV_EDIT_ELEMENT (RID_FORMS_START + 133)
+#define RID_STR_DATANAV_REMOVE_ELEMENT (RID_FORMS_START + 134)
+#define RID_STR_DATANAV_ADD_ATTRIBUTE (RID_FORMS_START + 135)
+#define RID_STR_DATANAV_EDIT_ATTRIBUTE (RID_FORMS_START + 136)
+#define RID_STR_DATANAV_REMOVE_ATTRIBUTE (RID_FORMS_START + 137)
+#define RID_STR_DATANAV_ADD_BINDING (RID_FORMS_START + 138)
+#define RID_STR_DATANAV_EDIT_BINDING (RID_FORMS_START + 139)
+#define RID_STR_DATANAV_REMOVE_BINDING (RID_FORMS_START + 140)
+#define RID_STR_DATANAV_ADD_SUBMISSION (RID_FORMS_START + 141)
+#define RID_STR_DATANAV_EDIT_SUBMISSION (RID_FORMS_START + 142)
+#define RID_STR_DATANAV_REMOVE_SUBMISSION (RID_FORMS_START + 143)
+#define RID_STR_DATANAV_LINKWARN_BUTTON (RID_FORMS_START + 144)
+#define RID_STR_SVT_SQL_SYNTAX_TABLE_OR_QUERY (RID_FORMS_START + 145)
+#define RID_STR_SVT_SQL_SYNTAX_TABLE_EXISTS (RID_FORMS_START + 146)
+#define RID_STR_SVT_SQL_SYNTAX_QUERY_EXISTS (RID_FORMS_START + 147)
+#define RID_STR_READONLY_VIEW (RID_FORMS_START + 148)
+#define RID_STR_ALREADYEXISTOVERWRITE (RID_FORMS_START + 149)
+#define RID_STR_OBJECT_LABEL (RID_FORMS_START + 150)
+
+// Error-String-Id's -----------------------------------------------------------
+#define RID_ERR_START (RID_FORMS_START + 600)
+#define RID_ERR_CONTEXT_ADDFORM (RID_ERR_START + 0)
+#define RID_ERR_DUPLICATE_NAME (RID_ERR_START + 1)
+#define RID_ERR_FIELDREQUIRED (RID_ERR_START + 2)
+#define RID_ERR_NO_ELEMENT (RID_ERR_START + 4)
+
+// untyped resources ----------------------------------------------------------
+
+#define RID_RSC_TABWIN_PREFIX ( RID_FORMS_START + 0 )
+#define RID_RSC_SQL_INTERNATIONAL ( RID_FORMS_START + 1 )
+
+#endif // _FM_FMPAGE_HXX
+
diff --git a/svx/source/inc/fmscriptingenv.hxx b/svx/source/inc/fmscriptingenv.hxx
new file mode 100644
index 000000000000..52f5e3cc97f6
--- /dev/null
+++ b/svx/source/inc/fmscriptingenv.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_FMSCRIPTINGENV_HXX
+#define SVX_FMSCRIPTINGENV_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+/** === end UNO includes === **/
+#include <rtl/ref.hxx>
+
+class FmFormModel;
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= IFormScriptingEnvironment
+ //====================================================================
+ /** describes the interface implemented by a component which handles scripting requirements
+ in a form/control environment.
+ */
+ class SAL_NO_VTABLE IFormScriptingEnvironment : public ::rtl::IReference
+ {
+ public:
+ /** registers an XEventAttacherManager whose events should be monitored and handled
+
+ @param _rxManager
+ the XEventAttacherManager to monitor. Must not be <NULL/>.
+
+ @throws ::com::sun::star::lang::IllegalArgumentException
+ if <arg>_rxManager</arg> is <NULL/>
+ @throws ::com::sun::star::lang::DisposedException
+ if the instance is already disposed
+ @throws ::com::sun::star::uno::RuntimeException
+ if attaching as script listener to the manager fails with a RuntimeException itself
+ */
+ virtual void registerEventAttacherManager(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacherManager >& _rxManager ) = 0;
+
+ /** registers an XEventAttacherManager whose events should not be monitored and handled anymore
+
+ @param _rxManager
+ the XEventAttacherManager which was previously registered. Must not ne <NULL/>.
+
+ @throws ::com::sun::star::lang::IllegalArgumentException
+ if <arg>_rxManager</arg> is <NULL/>
+ @throws ::com::sun::star::lang::DisposedException
+ if the instance is already disposed
+ @throws ::com::sun::star::uno::RuntimeException
+ if removing as script listener from the manager fails with a RuntimeException itself
+ */
+ virtual void revokeEventAttacherManager(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacherManager >& _rxManager ) = 0;
+
+ /** disposes the scripting environment instance
+ */
+ virtual void dispose() = 0;
+
+ virtual ~IFormScriptingEnvironment();
+ };
+ typedef ::rtl::Reference< IFormScriptingEnvironment > PFormScriptingEnvironment;
+
+ //====================================================================
+ /** creates a default component implementing the IFormScriptingEnvironment interface
+ */
+ PFormScriptingEnvironment createDefaultFormScriptingEnvironment( FmFormModel& _rFormModel );
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_FMSCRIPTINGENV_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmservs.hxx b/svx/source/inc/fmservs.hxx
new file mode 100644
index 000000000000..3dd289aeacba
--- /dev/null
+++ b/svx/source/inc/fmservs.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMSERVS_HXX
+#define _SVX_FMSERVS_HXX
+
+#include <svx/svxdllapi.h>
+
+#define FM_NUMBER_FORMATTER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.NumberFormatter" ) )
+#define FM_COMPONENT_EDIT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.Edit" ) )
+#define FM_COMPONENT_TEXTFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.TextField" ) )
+#define FM_COMPONENT_LISTBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.ListBox" ) )
+#define FM_COMPONENT_COMBOBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.ComboBox" ) )
+#define FM_COMPONENT_RADIOBUTTON rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.RadioButton" ) )
+#define FM_COMPONENT_GROUPBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.GroupBox" ) )
+#define FM_COMPONENT_FIXEDTEXT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.FixedText" ) )
+#define FM_COMPONENT_COMMANDBUTTON rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.CommandButton" ) )
+#define FM_COMPONENT_CHECKBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.CheckBox" ) )
+#define FM_COMPONENT_GRID rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.Grid" ) )
+#define FM_COMPONENT_GRIDCONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.GridControl" ) )
+#define FM_COMPONENT_IMAGEBUTTON rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.ImageButton" ) )
+#define FM_COMPONENT_FILECONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.FileControl" ) )
+#define FM_COMPONENT_TIMEFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.TimeField" ) )
+#define FM_COMPONENT_DATEFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.DateField" ) )
+#define FM_COMPONENT_NUMERICFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.NumericField" ) )
+#define FM_COMPONENT_CURRENCYFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.CurrencyField" ) )
+#define FM_COMPONENT_PATTERNFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.PatternField" ) )
+#define FM_COMPONENT_FORMATTEDFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.FormattedField" ) )
+#define FM_COMPONENT_HIDDEN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.Hidden" ) )
+#define FM_COMPONENT_HIDDENCONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.HiddenControl" ) )
+#define FM_COMPONENT_IMAGECONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.ImageControl" ) )
+#define FM_CONTROL_GRID rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.control.Grid" ) )
+#define FM_CONTROL_GRIDCONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.control.GridControl" ) )
+#define FM_FORM_CONTROLLER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.runtime.FormController" ) )
+#define SRV_SDB_CONNECTION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.Connection" ) )
+#define FM_SUN_COMPONENT_FORM rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.Form" ) )
+#define FM_SUN_COMPONENT_TEXTFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.TextField" ) )
+#define FM_SUN_COMPONENT_LISTBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.ListBox" ) )
+#define FM_SUN_COMPONENT_COMBOBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.ComboBox" ) )
+#define FM_SUN_COMPONENT_RADIOBUTTON rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.RadioButton" ) )
+#define FM_SUN_COMPONENT_GROUPBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.GroupBox" ) )
+#define FM_SUN_COMPONENT_FIXEDTEXT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.FixedText" ) )
+#define FM_SUN_COMPONENT_COMMANDBUTTON rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.CommandButton" ) )
+#define FM_SUN_COMPONENT_CHECKBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.CheckBox" ) )
+#define FM_SUN_COMPONENT_GRIDCONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.GridControl" ) )
+#define FM_SUN_COMPONENT_IMAGEBUTTON rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.ImageButton" ) )
+#define FM_SUN_COMPONENT_FILECONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.FileControl" ) )
+#define FM_SUN_COMPONENT_TIMEFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.TimeField" ) )
+#define FM_SUN_COMPONENT_DATEFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.DateField" ) )
+#define FM_SUN_COMPONENT_NUMERICFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.NumericField" ) )
+#define FM_SUN_COMPONENT_CURRENCYFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.CurrencyField" ) )
+#define FM_SUN_COMPONENT_PATTERNFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.PatternField" ) )
+#define FM_SUN_COMPONENT_HIDDENCONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.HiddenControl" ) )
+#define FM_SUN_COMPONENT_IMAGECONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.DatabaseImageControl" ) )
+#define FM_SUN_COMPONENT_FORMATTEDFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.FormattedField" ) )
+#define FM_SUN_COMPONENT_SCROLLBAR rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.ScrollBar" ) )
+#define FM_SUN_COMPONENT_SPINBUTTON rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.SpinButton" ) )
+#define FM_SUN_COMPONENT_NAVIGATIONBAR rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.NavigationToolBar" ) )
+#define FM_SUN_CONTROL_GRIDCONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.control.GridControl" ) )
+
+namespace svxform
+{
+ SVX_DLLPUBLIC void ImplSmartRegisterUnoServices();
+} // namespace svxform
+
+#endif // _SVX_FMSERVS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx
new file mode 100644
index 000000000000..c08554409fbf
--- /dev/null
+++ b/svx/source/inc/fmshimp.hxx
@@ -0,0 +1,608 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMSHIMP_HXX
+#define _SVX_FMSHIMP_HXX
+
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdb/XSQLQueryComposer.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/container/ContainerEvent.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/util/XModifyListener.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/form/NavigationBarMode.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <com/sun/star/form/runtime/FeatureState.hpp>
+#include <vcl/timer.hxx>
+#include <sfx2/app.hxx>
+#include <svx/svdmark.hxx>
+#include <svx/fmsearch.hxx>
+#include <svx/svxids.hrc>
+#include <svl/svarray.hxx>
+#include <svl/lstner.hxx>
+
+#define _SVSTDARR_BOOLS
+#define _SVSTDARR_BYTES
+#define _SVSTDARR_LONGS
+#define _SVSTDARR_ULONGS
+#define _SVSTDARR_USHORTS
+#include <svl/svstdarr.hxx>
+#include <sfx2/mnuitem.hxx>
+#include "svx/fmtools.hxx"
+#include "fmsrccfg.hxx"
+#include <osl/mutex.hxx>
+#include <tools/debug.hxx>
+#include <cppuhelper/component.hxx>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/container.hxx>
+#include <cppuhelper/compbase4.hxx>
+#include <cppuhelper/compbase6.hxx>
+#include <unotools/configitem.hxx>
+#include "svx/dbtoolsclient.hxx"
+#include "formcontrolling.hxx"
+#include "fmdocumentclassification.hxx"
+
+#include <queue>
+#include <set>
+#include <vector>
+
+SV_DECL_PTRARR(SdrObjArray, SdrObject*, 32, 16)
+// SV_DECL_OBJARR(FmFormArray, ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>, 32, 16);
+DECLARE_STL_VECTOR( ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > ,FmFormArray);
+
+// catch databse exceptions if occur
+#define DO_SAFE(statement) try { statement; } catch( const Exception& ) { DBG_ERROR("unhandled exception (I tried to move a cursor (or something like that).)"); }
+
+#define GA_DISABLE_SYNC 1
+#define GA_FORCE_SYNC 2
+#define GA_ENABLE_SYNC 3
+#define GA_SYNC_MASK 3
+#define GA_DISABLE_ROCTRLR 4
+#define GA_ENABLE_ROCTRLR 8
+
+
+// flags for controlling the behaviour when calling loadForms
+#define FORMS_LOAD 0x0000 // default: simply load
+#define FORMS_SYNC 0x0000 // default: do in synchronous
+
+#define FORMS_UNLOAD 0x0001 // unload
+#define FORMS_ASYNC 0x0002 // do this async
+
+//==============================================================================
+// a class iterating through all fields of a form which are bound to a field
+// sub forms are ignored, grid columns (where the grid is a direct child of the form) are included
+class SAL_DLLPRIVATE FmXBoundFormFieldIterator : public ::comphelper::IndexAccessIterator
+{
+public:
+ FmXBoundFormFieldIterator(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rStartingPoint) : ::comphelper::IndexAccessIterator(_rStartingPoint) { }
+
+protected:
+ virtual sal_Bool ShouldHandleElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rElement);
+ virtual sal_Bool ShouldStepInto(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rContainer) const;
+};
+
+class FmFormPage;
+//========================================================================
+struct SAL_DLLPRIVATE FmLoadAction
+{
+ FmFormPage* pPage;
+ ULONG nEventId;
+ sal_uInt16 nFlags;
+
+ FmLoadAction( ) : pPage( NULL ), nEventId( 0 ), nFlags( 0 ) { }
+ FmLoadAction( FmFormPage* _pPage, sal_uInt16 _nFlags, ULONG _nEventId )
+ :pPage( _pPage ), nEventId( _nEventId ), nFlags( _nFlags )
+ {
+ }
+};
+
+//========================================================================
+class SfxViewFrame;
+typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::container::XContainerListener
+ , ::com::sun::star::view::XSelectionChangeListener
+ , ::com::sun::star::form::XFormControllerListener
+ > FmXFormShell_BD_BASE;
+
+//========================================================================
+class SAL_DLLPRIVATE FmXFormShell_Base_Disambiguation : public FmXFormShell_BD_BASE
+{
+ using ::com::sun::star::beans::XPropertyChangeListener::disposing;
+protected:
+ FmXFormShell_Base_Disambiguation( ::osl::Mutex& _rMutex );
+ virtual void SAL_CALL disposing();
+};
+
+//========================================================================
+namespace svx
+{
+ class FmTextControlShell;
+}
+
+//========================================================================
+typedef FmXFormShell_Base_Disambiguation FmXFormShell_BASE;
+typedef ::utl::ConfigItem FmXFormShell_CFGBASE;
+
+struct SdrViewEvent;
+class FmFormShell;
+class FmFormView;
+class FmFormObj;
+class SAL_DLLPRIVATE FmXFormShell :public FmXFormShell_BASE
+ ,public FmXFormShell_CFGBASE
+ ,public ::svxform::OStaticDataAccessTools
+ ,public ::svx::IControllerFeatureInvalidation
+{
+ friend class FmFormView;
+ friend class FmXFormView;
+ friend class WizardUsageConfigItem;
+
+ class SuspendPropertyTracking;
+ friend class SuspendPropertyTracking;
+
+ // Timer um verzoegerte Markierung vorzunehmen
+ Timer m_aMarkTimer;
+ SdrObjArray m_arrSearchedControls;
+ // We enable a permanent cursor for the grid we found a searched text, it's disabled in the next "found" event.
+ FmFormArray m_aSearchForms;
+
+ SvUShorts m_arrInvalidSlots;
+ SvBytes m_arrInvalidSlots_Flags;
+ // we explicitly switch off the propbrw before leaving the design mode
+ // this flag tells us if we have to switch it on again when reentering
+
+ ::osl::Mutex m_aAsyncSafety;
+ // secure the access to our thread related members
+ ::osl::Mutex m_aInvalidationSafety;
+ // secure the access to all our slot invalidation related members
+
+ ::com::sun::star::form::NavigationBarMode m_eNavigate; // Art der Navigation
+
+ // da ich beim Suchen fuer die Behandlung des "gefunden" ein SdrObject markieren will, besorge ich mir vor dem
+ // Hochreissen des Suchen-Dialoges alle relevanten Objekte
+ // (das Array ist damit auch nur waehrend des Suchvorganges gueltig)
+ SvLongs m_arrRelativeGridColumn;
+
+ ::osl::Mutex m_aMutex;
+ ULONG m_nInvalidationEvent;
+ ULONG m_nActivationEvent;
+ ::std::queue< FmLoadAction >
+ m_aLoadingPages;
+
+ FmFormShell* m_pShell;
+ ::svx::FmTextControlShell* m_pTextShell;
+
+ ::svx::ControllerFeatures m_aActiveControllerFeatures;
+ ::svx::ControllerFeatures m_aNavControllerFeatures;
+
+ // aktuelle Form, Controller
+ // nur im alive mode verfuegbar
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xActiveController;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xNavigationController;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > m_xActiveForm;
+
+ // Aktueller container einer Page
+ // nur im designmode verfuegbar
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xForms;
+
+ // the currently selected objects, as to be displayed in the property browser
+ InterfaceBag m_aCurrentSelection;
+ /// the currently selected form, or the form which all currently selected controls belong to, or <NULL/>
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > m_xCurrentForm;
+ /// the last selection/marking of controls only. Necessary to implement the "Control properties" slot
+ InterfaceBag m_aLastKnownMarkedControls;
+
+
+ // und das ist ebenfalls fuer's 'gefunden' : Beim Finden in GridControls brauche ich die Spalte, bekomme aber
+ // nur die Nummer des Feldes, die entspricht der Nummer der Spalte + <offset>, wobei der Offset von der Position
+ // des GridControls im Formular abhaengt. Also hier eine Umrechnung.
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> m_xLastGridFound;
+ // the frame we live in
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame> m_xAttachedFrame;
+ // Administration of external form views (see the SID_FM_VIEW_AS_GRID-slot)
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xExternalViewController; // the controller for the external form view
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xExtViewTriggerController; // the nav controller at the time the external display was triggered
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xExternalDisplayedForm; // the form which the external view is based on
+
+ mutable ::svxform::DocumentType
+ m_eDocumentType; /// the type of document we're living in
+ sal_Int16 m_nLockSlotInvalidation;
+ sal_Bool m_bHadPropertyBrowserInDesignMode : 1;
+
+ sal_Bool m_bTrackProperties : 1;
+ // soll ich (bzw. der Owner diese Impl-Klasse) mich um die Aktualisierung des ::com::sun::star::beans::Property-Browsers kuemmern ?
+
+ sal_Bool m_bUseWizards : 1;
+
+ sal_Bool m_bDatabaseBar : 1; // Gibt es eine Datenbankleiste
+ sal_Bool m_bInActivate : 1; // Wird ein Controller aktiviert
+ sal_Bool m_bSetFocus : 1; // Darf der Focus umgesetzt werden
+ sal_Bool m_bFilterMode : 1; // Wird gerade ein Filter auf die Controls angesetzt
+ sal_Bool m_bChangingDesignMode:1; // sal_True within SetDesignMode
+ sal_Bool m_bPreparedClose : 1; // for the current modification state of the current form
+ // PrepareClose had been called and the user denied to save changes
+ sal_Bool m_bFirstActivation : 1; // has the shell ever been activated?
+
+public:
+ // attribute access
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >&
+ getHostFrame() const { return m_xAttachedFrame; }
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >&
+ getExternallyDisplayedForm() const { return m_xExternalDisplayedForm; }
+
+ inline sal_Bool
+ didPrepareClose() const { return m_bPreparedClose; }
+ inline void
+ didPrepareClose( sal_Bool _bDid ) { m_bPreparedClose = _bDid; }
+
+public:
+ FmXFormShell(FmFormShell& _rShell, SfxViewFrame* _pViewFrame);
+
+ // UNO Anbindung
+ DECLARE_UNO3_DEFAULTS(FmXFormShell, FmXFormShell_BASE);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException );
+
+protected:
+ ~FmXFormShell();
+
+// XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+// EventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
+
+// ::com::sun::star::container::XContainerListener
+ virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+// XSelectionChangeListener
+ virtual void SAL_CALL selectionChanged(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+// ::com::sun::star::beans::XPropertyChangeListener
+ virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException );
+
+// ::com::sun::star::form::XFormControllerListener
+ virtual void SAL_CALL formActivated(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL formDeactivated(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+public:
+ void EnableTrackProperties( sal_Bool bEnable) { m_bTrackProperties = bEnable; }
+ sal_Bool IsTrackPropertiesEnabled() {return m_bTrackProperties;}
+
+ // activation handling
+ void viewActivated( FmFormView& _rCurrentView, sal_Bool _bSyncAction = sal_False );
+ void viewDeactivated( FmFormView& _rCurrentView, sal_Bool _bDeactivateController = sal_True );
+
+ // IControllerFeatureInvalidation
+ virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures );
+
+ void ExecuteTabOrderDialog( // execute SID_FM_TAB_DIALOG
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel >& _rxForForm
+ );
+
+ // stuff
+ void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
+ void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
+
+ /** updates m_xForms, to be either <NULL/>, if we're in alive mode, or our current page's forms collection,
+ if in design mode
+ */
+ void UpdateForms( sal_Bool _bInvalidate );
+
+ void ExecuteSearch(); // execute SID_FM_SEARCH
+ void CreateExternalView(); // execute SID_FM_VIEW_AS_GRID
+
+ sal_Bool GetY2KState(sal_uInt16& n);
+ void SetY2KState(sal_uInt16 n);
+
+protected:
+ // activation handling
+ inline sal_Bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
+ inline void setHasBeenActivated( ) { m_bFirstActivation = sal_False; }
+
+ // form handling
+ /// load or unload the forms on a page
+ void loadForms( FmFormPage* _pPage, const sal_uInt16 _nBehaviour = FORMS_LOAD | FORMS_SYNC );
+ void smartControlReset( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxModels );
+
+
+ void startListening();
+ void stopListening();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >
+ impl_getControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& i_rxModel,
+ const FmFormObj& i_rKnownFormObj
+ );
+
+ // sammelt in strNames die Namen aller Formulare
+ static void impl_collectFormSearchContexts_nothrow(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxStartingPoint,
+ const ::rtl::OUString& _rCurrentLevelPrefix,
+ FmFormArray& _out_rForms,
+ ::std::vector< String >& _out_rNames );
+
+ /** checks whether the instance is already disposed, if so, this is reported as assertion error (debug
+ builds only) and <TRUE/> is returned.
+ */
+ bool impl_checkDisposed() const;
+
+public:
+ // methode fuer nicht designmode (alive mode)
+ void setActiveController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& _xController, sal_Bool _bNoSaveOldContent = sal_False );
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getActiveController() const {return m_xActiveController;}
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getActiveInternalController() const { return m_xActiveController == m_xExternalViewController ? m_xExtViewTriggerController : m_xActiveController; }
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& getActiveForm() const {return m_xActiveForm;}
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getNavController() const {return m_xNavigationController;}
+
+ inline const ::svx::ControllerFeatures& getActiveControllerFeatures() const
+ { return m_aActiveControllerFeatures; }
+ inline const ::svx::ControllerFeatures& getNavControllerFeatures() const
+ { return m_aNavControllerFeatures.isAssigned() ? m_aNavControllerFeatures : m_aActiveControllerFeatures; }
+
+ /** announces a new "current selection"
+ @return
+ <TRUE/> if and only if the to-bet-set selection was different from the previous selection
+ */
+ bool setCurrentSelection( const InterfaceBag& _rSelection );
+
+ /** sets the new selection to the last known marked controls
+ */
+ bool selectLastMarkedControls();
+
+ /** retrieves the current selection
+ */
+ SVX_DLLPUBLIC void getCurrentSelection( InterfaceBag& /* [out] */ _rSelection ) const;
+
+ /** sets a new current selection as indicated by a mark list
+ @return
+ <TRUE/> if and only if the to-bet-set selection was different from the previous selection
+ */
+ bool setCurrentSelectionFromMark(const SdrMarkList& rMarkList);
+
+ /// returns the currently selected form, or the form which all currently selected controls belong to, or <NULL/>
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
+ getCurrentForm() const { return m_xCurrentForm; }
+ void forgetCurrentForm();
+ /// returns whether the last known marking contained only controls
+ sal_Bool onlyControlsAreMarked() const { return !m_aLastKnownMarkedControls.empty(); }
+
+ /// determines whether the current selection consists of exactly the given object
+ bool isSolelySelected(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject
+ );
+
+ /// handles a MouseButtonDown event of the FmFormView
+ void handleMouseButtonDown( const SdrViewEvent& _rViewEvent );
+ /// handles the request for showing the "Properties"
+ void handleShowPropertiesRequest();
+
+ sal_Bool hasForms() const {return m_xForms.is() && m_xForms->getCount() != 0;}
+ sal_Bool hasDatabaseBar() const {return m_bDatabaseBar;}
+ sal_Bool canNavigate() const {return m_xNavigationController.is();}
+
+ void ShowSelectionProperties( sal_Bool bShow );
+ sal_Bool IsPropBrwOpen() const;
+
+ void DetermineSelection(const SdrMarkList& rMarkList);
+ void SetSelection(const SdrMarkList& rMarkList);
+ void SetSelectionDelayed();
+
+ void SetDesignMode(sal_Bool bDesign);
+
+ sal_Bool GetWizardUsing() const { return m_bUseWizards; }
+ void SetWizardUsing(sal_Bool _bUseThem);
+
+ // Setzen des Filtermodus
+ sal_Bool isInFilterMode() const {return m_bFilterMode;}
+ void startFiltering();
+ void stopFiltering(sal_Bool bSave);
+ void clearFilter();
+
+ static PopupMenu* GetConversionMenu();
+ // ein Menue, das alle ControlConversion-Eintraege enthaelt
+
+ /// checks whethere a given control conversion slot can be applied to the current selection
+ bool canConvertCurrentSelectionToControl( sal_Int16 nConversionSlot );
+ /// enables or disables all conversion slots in a menu, according to the current selection
+ void checkControlConversionSlotsForCurrentSelection( Menu& rMenu );
+ /// executes a control conversion slot for a given object
+ bool executeControlConversionSlot( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent >& _rxObject, sal_uInt16 _nSlotId );
+ /** executes a control conversion slot for the current selection
+ @precond canConvertCurrentSelectionToControl( <arg>_nSlotId</arg> ) must return <TRUE/>
+ */
+ bool executeControlConversionSlot( sal_uInt16 _nSlotId );
+ /// checks whether the given slot id denotes a control conversion slot
+ static bool isControlConversionSlot( sal_uInt16 _nSlotId );
+
+ void ExecuteTextAttribute( SfxRequest& _rReq );
+ void GetTextAttributeState( SfxItemSet& _rSet );
+ bool IsActiveControl( bool _bCountRichTextOnly = false ) const;
+ void ForgetActiveControl();
+ void SetControlActivationHandler( const Link& _rHdl );
+
+ /// classifies our host document
+ ::svxform::DocumentType
+ getDocumentType() const;
+ bool isEnhancedForm() const;
+
+ /// determines whether our host document is currently read-only
+ bool IsReadonlyDoc() const;
+
+ // das Setzen des curObject/selObject/curForm erfolgt verzoegert (SetSelectionDelayed), mit den folgenden
+ // Funktionen laesst sich das abfragen/erzwingen
+ inline sal_Bool IsSelectionUpdatePending();
+ void ForceUpdateSelection(sal_Bool bLockInvalidation);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel> getContextDocument() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> getInternalForm(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& _xForm) const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> getInternalForm(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xForm) const;
+ // if the form belongs to the controller (extern) displaying a grid, the according internal form will
+ // be displayed, _xForm else
+
+ // check if the current control of the active controler has the focus
+ bool HasControlFocus() const;
+
+private:
+ DECL_LINK(OnFoundData, FmFoundRecordInformation*);
+ DECL_LINK(OnCanceledNotFound, FmFoundRecordInformation*);
+ DECL_LINK(OnSearchContextRequest, FmSearchContext*);
+ DECL_LINK(OnTimeOut, void*);
+ DECL_LINK(OnFirstTimeActivation, void*);
+ DECL_LINK(OnFormsCreated, FmFormPage*);
+
+ void LoopGrids(sal_Int16 nWhat);
+
+ // Invalidierung von Slots
+ void InvalidateSlot( sal_Int16 nId, sal_Bool bWithId );
+ void UpdateSlot( sal_Int16 nId );
+ // Locking der Invalidierung - wenn der interne Locking-Counter auf 0 geht, werden alle aufgelaufenen Slots
+ // (asynchron) invalidiert
+ void LockSlotInvalidation(sal_Bool bLock);
+
+ DECL_LINK(OnInvalidateSlots, void*);
+
+ void CloseExternalFormViewer();
+ // closes the task-local beamer displaying a grid view for a form
+
+ // ConfigItem related stuff
+ virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& _rPropertyNames);
+ virtual void Commit();
+ void implAdjustConfigCache();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ getControlContainerForView();
+
+ /** finds and sets a default for m_xCurrentForm, if it is currently NULL
+ */
+ void impl_defaultCurrentForm_nothrow();
+
+ /** sets m_xCurrentForm to the provided form, and udpates everything which
+ depends on the current form
+ */
+ void impl_updateCurrentForm( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxNewCurForm );
+
+ /** adds or removes ourself as XEventListener at m_xActiveController
+ */
+ void impl_switchActiveControllerListening( const bool _bListen );
+
+ /** add an element
+ */
+ void impl_AddElement_nothrow(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
+
+ /** remove an element
+ */
+ void impl_RemoveElement_nothrow(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
+
+ // ---------------------------------------------------
+ // asyncronous cursor actions/navigation slot handling
+
+public:
+ /** execute the given form slot
+ <p>Warning. Only a small set of slots implemented currently.</p>
+ @param _nSlot
+ the slot to execute
+ */
+ void ExecuteFormSlot( sal_Int32 _nSlot );
+
+ /** determines whether the current form slot is currently enabled
+ */
+ bool IsFormSlotEnabled( sal_Int32 _nSlot, ::com::sun::star::form::runtime::FeatureState* _pCompleteState = NULL );
+
+protected:
+ DECL_LINK( OnLoadForms, FmFormPage* );
+};
+
+//------------------------------------------------------------------------------
+inline sal_Bool FmXFormShell::IsSelectionUpdatePending()
+{
+ return m_aMarkTimer.IsActive();
+}
+
+// ========================================================================
+// = ein Iterator, der ausgehend von einem Interface ein Objekt sucht, dessen
+// = ::com::sun::star::beans::Property-Set eine ControlSource- sowie eine BoundField-Eigenschaft hat,
+// = wobei letztere einen Wert ungleich NULL haben muss.
+// = Wenn das Interface selber diese Bedingung nicht erfuellt, wird getestet,
+// = ob es ein Container ist (also ueber eine ::com::sun::star::container::XIndexAccess verfuegt), dann
+// = wird dort abgestiegen und fuer jedes Element des Containers das selbe
+// = versucht (wiederum eventuell mit Abstieg).
+// = Wenn irgendein Objekt dabei die geforderte Eigenschaft hat, entfaellt
+// = der Teil mit dem Container-Test fuer dieses Objekt.
+// =
+
+class SAL_DLLPRIVATE SearchableControlIterator : public ::comphelper::IndexAccessIterator
+{
+ ::rtl::OUString m_sCurrentValue;
+ // der aktuelle Wert der ControlSource-::com::sun::star::beans::Property
+
+public:
+ ::rtl::OUString getCurrentValue() const { return m_sCurrentValue; }
+
+public:
+ SearchableControlIterator(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xStartingPoint);
+
+ virtual sal_Bool ShouldHandleElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& rElement);
+ virtual sal_Bool ShouldStepInto(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xContainer) const;
+ virtual void Invalidate() { IndexAccessIterator::Invalidate(); m_sCurrentValue = ::rtl::OUString(); }
+};
+
+// ========================================================================
+SV_DECL_PTRARR_DEL(StatusForwarderArray, SfxStatusForwarder*, 16, 0)
+class SVX_DLLPUBLIC ControlConversionMenuController : public SfxMenuControl
+{
+protected:
+ StatusForwarderArray m_aStatusForwarders;
+ Menu* m_pMainMenu;
+ PopupMenu* m_pConversionMenu;
+
+public:
+ SVX_DLLPRIVATE ControlConversionMenuController(sal_uInt16 nId, Menu& rMenu, SfxBindings& rBindings);
+ SVX_DLLPRIVATE virtual ~ControlConversionMenuController();
+ SFX_DECL_MENU_CONTROL();
+
+ SVX_DLLPRIVATE virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState);
+};
+
+#endif // _SVX_FMSHIMP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmslotinvalidator.hxx b/svx/source/inc/fmslotinvalidator.hxx
new file mode 100644
index 000000000000..8c6a3e2682e2
--- /dev/null
+++ b/svx/source/inc/fmslotinvalidator.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_SOURCE_INC_FMSLOTINVALIDATOR_HXX
+#define SVX_SOURCE_INC_FMSLOTINVALIDATOR_HXX
+
+#include <tools/solar.h>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ typedef USHORT SfxSlotId;
+
+ //====================================================================
+ //= ISlotInvalidator
+ //====================================================================
+ class ISlotInvalidator
+ {
+ public:
+ virtual void Invalidate( SfxSlotId _nSlot ) = 0;
+ };
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+#endif // SVX_SOURCE_INC_FMSLOTINVALIDATOR_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmsrccfg.hxx b/svx/source/inc/fmsrccfg.hxx
new file mode 100644
index 000000000000..6ba0bd062f71
--- /dev/null
+++ b/svx/source/inc/fmsrccfg.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _FMSRCCF_HXX_
+#define _FMSRCCF_HXX_
+
+#include <tools/string.hxx>
+#include <unotools/configvaluecontainer.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include "svx/svxdllapi.h"
+
+// ===================================================================================================
+
+#define MATCHING_ANYWHERE 0
+#define MATCHING_BEGINNING 1
+#define MATCHING_END 2
+#define MATCHING_WHOLETEXT 3
+
+// diese Konstanten duerfen NICHT einfach geaendert werden, da der SearchDialog aus den Einstellungen seiner ListBox
+// keine Umrechnungen vornimmt, sondern die einfach in die entsprechenden Methoden der SearchEngine steckt
+// (wenn man also die Konstanten oder die Reihenfolge der Listbox-Eintraege im Dialog aendert, muss das jeweils andere
+// angepasst werden)
+
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ // ===================================================================================================
+ // = struct FmSearchParams - Parameter einer Suche
+ // ===================================================================================================
+
+ struct SVX_DLLPUBLIC FmSearchParams
+ {
+ protected:
+ sal_Int32 nTransliterationFlags;
+ // they're way too sensitive for direct access ....
+
+ public:
+ // no bit fields at all (want to pass the addresses to the OConfigurationValueContainer)
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ aHistory;
+ ::rtl::OUString sSingleSearchField;
+
+ sal_Int16 nSearchForType;
+ sal_Int16 nPosition;
+ sal_Int16 nLevOther;
+ sal_Int16 nLevShorter;
+ sal_Int16 nLevLonger;
+ sal_Bool bLevRelaxed;
+
+ sal_Bool bAllFields;
+ sal_Bool bUseFormatter;
+ sal_Bool bBackwards;
+ sal_Bool bWildcard;
+ sal_Bool bRegular;
+ sal_Bool bApproxSearch;
+ // the last three are mutually exclusive
+
+ sal_Bool bSoundsLikeCJK;
+
+ // ......................................
+ FmSearchParams();
+
+ sal_Bool isIgnoreWidthCJK( ) const;
+ void setIgnoreWidthCJK( sal_Bool _bIgnore );
+
+ sal_Int32 getTransliterationFlags( ) const { return nTransliterationFlags; }
+ void setTransliterationFlags( sal_Int32 _nFlags ) { nTransliterationFlags = _nFlags; }
+
+ sal_Bool isCaseSensitive( ) const;
+ void setCaseSensitive( sal_Bool _bCase );
+ };
+
+ // ===================================================================================================
+ // = class FmSearchConfigItem - ein ConfigItem, dass sich Suchparameter merkt
+ // ===================================================================================================
+
+ class SVX_DLLPUBLIC FmSearchConfigItem
+ :protected FmSearchParams
+ ,public ::utl::OConfigurationValueContainer
+ // order matters!
+ {
+ private:
+ ::osl::Mutex m_aMutex;
+
+ // wrapper properties:
+ // some of the members of FmSearchParams are must be translated to be stored in the configuration
+ ::rtl::OUString m_sSearchForType;
+ ::rtl::OUString m_sSearchPosition;
+
+ sal_Bool m_bIsMatchCase;
+ sal_Bool m_bIsMatchFullHalfWidthForms;
+ sal_Bool m_bIsMatchHiraganaKatakana;
+ sal_Bool m_bIsMatchContractions;
+ sal_Bool m_bIsMatchMinusDashCho_on;
+ sal_Bool m_bIsMatchRepeatCharMarks;
+ sal_Bool m_bIsMatchVariantFormKanji;
+ sal_Bool m_bIsMatchOldKanaForms;
+ sal_Bool m_bIsMatch_DiZi_DuZu;
+ sal_Bool m_bIsMatch_BaVa_HaFa;
+ sal_Bool m_bIsMatch_TsiThiChi_DhiZi;
+ sal_Bool m_bIsMatch_HyuIyu_ByuVyu;
+ sal_Bool m_bIsMatch_SeShe_ZeJe;
+ sal_Bool m_bIsMatch_IaIya;
+ sal_Bool m_bIsMatch_KiKu;
+ sal_Bool m_bIsIgnorePunctuation;
+ sal_Bool m_bIsIgnoreWhitespace;
+ sal_Bool m_bIsIgnoreProlongedSoundMark;
+ sal_Bool m_bIsIgnoreMiddleDot;
+
+ public:
+ FmSearchConfigItem();
+ ~FmSearchConfigItem();
+
+ const FmSearchParams& getParams( ) const;
+ void setParams( const FmSearchParams& _rParams );
+
+ private:
+ SVX_DLLPRIVATE void implTranslateFromConfig( );
+ SVX_DLLPRIVATE void implTranslateToConfig( );
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+// ===================================================================================================
+
+#endif // _FMSRCCF_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmsrcimp.hxx b/svx/source/inc/fmsrcimp.hxx
new file mode 100644
index 000000000000..2b2ce7ba9cc4
--- /dev/null
+++ b/svx/source/inc/fmsrcimp.hxx
@@ -0,0 +1,411 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _FMSRCIMP_HXX
+#define _FMSRCIMP_HXX
+
+#include <svx/fmtools.hxx>
+#include "svx/svxdllapi.h"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XCheckBox.hpp>
+#include <com/sun/star/awt/XListBox.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatter.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/stl_types.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <osl/mutex.hxx>
+#include <unotools/charclass.hxx>
+#include <unotools/collatorwrapper.hxx>
+#include <osl/thread.hxx>
+
+#ifndef _SVSTDARR_ULONGS
+#define _SVSTDARR_ULONGS
+#include <svl/svstdarr.hxx>
+#endif
+
+// ===================================================================================================
+// Hilfsstrukturen
+
+SV_DECL_OBJARR(SvInt32Array, sal_Int32, 16, 16)
+
+// ===================================================================================================
+// = class FmSearchThread - wie der Name schon sagt
+// ===================================================================================================
+
+class FmSearchEngine;
+class FmSearchThread : public ::osl::Thread
+{
+ FmSearchEngine* m_pEngine;
+ Link m_aTerminationHdl;
+
+ virtual void SAL_CALL run();
+ virtual void SAL_CALL onTerminated();
+
+public:
+ FmSearchThread(FmSearchEngine* pEngine) : m_pEngine(pEngine) { }
+ void setTerminationHandler(Link aHdl) { m_aTerminationHdl = aHdl; }
+};
+
+// ===================================================================================================
+// = struct FmSearchProgress - diese Struktur bekommt der Owner der SearchEngine fuer Status-Updates
+// = (und am Ende der Suche)
+// ===================================================================================================
+
+struct FmSearchProgress
+{
+ enum STATE { STATE_PROGRESS, STATE_PROGRESS_COUNTING, STATE_CANCELED, STATE_SUCCESSFULL, STATE_NOTHINGFOUND, STATE_ERROR };
+ // (Bewegung auf neuen Datensatz; Fortschritt beim Zaehlen von Datensaetzen; abgebrochen; Datensatz gefunden;
+ // nichts gefunden, irgendein nicht zu handelnder Fehler)
+ STATE aSearchState;
+
+ // aktueller Datensatz - immer gueltig (ist zum Beispiel bei Abbrechen auch fuer das Weitersuchen interesant)
+ sal_uInt32 nCurrentRecord;
+ // Ueberlauf - nur gueltig bei STATE_PROGRESS
+ sal_Bool bOverflow;
+
+ // die Position des Such-Cursors - bei STATE_SUCCESSFULL, STATE_CANCELED und STATE_NOTHING_FOUND gueltig
+ ::com::sun::star::uno::Any aBookmark;
+ // das Feld, in dem der Text gefunden wurde - bei STATE_SUCCESSFULL gueltig
+ sal_Int32 nFieldIndex;
+};
+
+// ===================================================================================================
+// = class FmRecordCountListener - Hilfsklasse fuer FmSearchEngine, lauscht an einem Cursor und teilt
+// = Aenderungem im RecordCount mit
+// ===================================================================================================
+
+class FmRecordCountListener : public ::cppu::WeakImplHelper1< ::com::sun::star::beans::XPropertyChangeListener>
+{
+// Atribute
+ Link m_lnkWhoWantsToKnow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xListening;
+
+// Attribut-Zugriff
+public:
+ Link SetPropChangeHandler(const Link& lnk);
+
+// Oprationen
+public:
+ FmRecordCountListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& dbcCursor);
+ // the set has to support the sdb::ResultSet service
+ virtual ~FmRecordCountListener();
+
+ // DECLARE_UNO3_AGG_DEFAULTS(FmPropertyListener, UsrObject);
+ // virtual sal_Bool queryInterface(::com::sun::star::uno::Uik aUik, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rOut);
+
+// ::com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::beans::XPropertyChangeListener
+ virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
+
+ void DisConnect();
+
+private:
+ void NotifyCurrentCount();
+
+};
+
+// ===================================================================================================
+// = class FmSearchEngine - Impl-Klasse fuer FmSearchDialog
+// ===================================================================================================
+
+namespace svxform {
+ // We have three possible control types we may search in, determined by the supported interfaces : ::com::sun::star::awt::XTextComponent, ::com::sun::star::awt::XListBox, ::com::sun::star::awt::XCheckBox.
+ // While searching we don't want to do this distinction for every control in every round. So we need some helpers.
+ class ControlTextWrapper
+ {
+ // attributes
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xControl;
+ // attribute access
+ public:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getControl() const{ return m_xControl; }
+ public:
+ ControlTextWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xControl) { m_xControl = _xControl; }
+ virtual ~ControlTextWrapper() { }
+
+ virtual ::rtl::OUString getCurrentText() const = 0;
+ };
+ class SimpleTextWrapper : public ControlTextWrapper
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > m_xText;
+ public:
+ SimpleTextWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& _xText);
+ virtual ::rtl::OUString getCurrentText() const;
+ };
+ class ListBoxWrapper : public ControlTextWrapper
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XListBox > m_xBox;
+ public:
+ ListBoxWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XListBox >& _xBox);
+ virtual ::rtl::OUString getCurrentText() const;
+ };
+ class CheckBoxWrapper : public ControlTextWrapper
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCheckBox > m_xBox;
+ public:
+ CheckBoxWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XCheckBox >& _xBox);
+ virtual ::rtl::OUString getCurrentText() const;
+ };
+}
+
+enum FMSEARCH_MODE { SM_BRUTE, SM_ALLOWSCHEDULE, SM_USETHREAD };
+
+DECLARE_STL_VECTOR( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>, InterfaceArray);
+
+class SVX_DLLPUBLIC FmSearchEngine
+{
+ friend class FmSearchThread;
+
+ enum SEARCH_RESULT { SR_FOUND, SR_NOTFOUND, SR_ERROR, SR_CANCELED };
+ enum SEARCHFOR_TYPE { SEARCHFOR_STRING, SEARCHFOR_NULL, SEARCHFOR_NOTNULL };
+
+ // zugrundeliegende Daten
+ CursorWrapper m_xSearchCursor;
+ SvInt32Array m_arrFieldMapping;
+ // da der Iterator durchaus mehr Spalten haben kann, als ich eigentlich verwalte (in meiner Feld-Listbox),
+ // muss ich mir hier ein Mapping dieser ::com::sun::star::form-Schluessel auf die Indizies der entsprechenden Spalten im Iterator halten
+
+ // der Formatter
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xFormatSupplier;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter;
+
+ CharClass m_aCharacterClassficator;
+ CollatorWrapper m_aStringCompare;
+
+ // die Sammlung aller interesanten Felder (bzw. ihre ::com::sun::star::data::XDatabaseVariant-Interfaces und ihre FormatKeys)
+ struct FieldInfo
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn > xContents;
+ sal_uInt32 nFormatKey;
+ sal_Bool bDoubleHandling;
+ };
+
+ DECLARE_STL_VECTOR(FieldInfo, FieldCollection);
+ FieldCollection m_arrUsedFields;
+ sal_Int32 m_nCurrentFieldIndex; // der letzte Parameter von RebuildUsedFields, ermoeglicht mir Checks in FormatField
+
+ DECLARE_STL_VECTOR(svxform::ControlTextWrapper*, ControlTextSuppliers);
+ ControlTextSuppliers m_aControlTexts;
+
+ sal_Bool m_bUsingTextComponents;
+ CursorWrapper m_xOriginalIterator;
+ CursorWrapper m_xClonedIterator;
+
+ // Daten fuer Entscheidung, in welchem Feld ich ein "Found" akzeptiere
+ ::com::sun::star::uno::Any m_aPreviousLocBookmark; // Position, an der ich zuletzt fuendig war
+ FieldCollectionIterator m_iterPreviousLocField; // dito Feld
+
+ // Kommunikation mit dem Thread, der die eigentliche Suche durchfuehrt
+ ::rtl::OUString m_strSearchExpression; // Hinrichtung
+ SEARCHFOR_TYPE m_eSearchForType; // dito
+ SEARCH_RESULT m_srResult; // Rueckrichtung
+
+ // der Link, dem ich Fortschritte und Ergebnisse mitteile
+ Link m_aProgressHandler;
+ sal_Bool m_bSearchingCurrently : 1; // laeuft gerade eine (asynchrone) Suche ?
+ sal_Bool m_bCancelAsynchRequest : 1; // soll abgebrochen werden ?
+ ::osl::Mutex m_aCancelAsynchAccess; // Zugriff auf m_bCancelAsynchRequest (eigentlich nur bei
+ // m_eMode == SM_USETHREAD interesant)
+ FMSEARCH_MODE m_eMode; //CHINA001 FmSearchDialog::SEARCH_MODE m_eMode; // der aktuelle Modus
+ // der aktuelle Modus
+
+ // Parameter fuer die Suche
+ sal_Bool m_bFormatter : 1; // Feldformatierung benutzen
+ sal_Bool m_bForward : 1; // Richtung
+ sal_Bool m_bWildcard : 1; // Platzhalter-Suche ?
+ sal_Bool m_bRegular : 1; // regulaerer Ausdruck
+ sal_Bool m_bLevenshtein : 1; // Levenshtein-Suche
+ sal_Bool m_bTransliteration : 1; // Levenshtein-Suche
+
+ sal_Bool m_bLevRelaxed : 1; // Parameter fuer Levenshtein-Suche
+ sal_uInt16 m_nLevOther;
+ sal_uInt16 m_nLevShorter;
+ sal_uInt16 m_nLevLonger;
+
+ sal_uInt16 m_nPosition; // wenn nicht regulaer oder lev, dann einer der MATCHING_...-Werte
+
+ sal_Int32 m_nTransliterationFlags;
+
+// -------------
+// Memberzugriff
+private:
+ SVX_DLLPRIVATE sal_Bool CancelRequested(); // liefert eine durch m_aCancelAsynchAccess gesicherte Auswertung von m_bCancelAsynchRequest
+
+public:
+ void SetCaseSensitive(sal_Bool bSet);
+ sal_Bool GetCaseSensitive() const;
+
+ void SetFormatterUsing(sal_Bool bSet); // das ist etwas umfangreicher, deshalb kein hier inline ....
+ sal_Bool GetFormatterUsing() const { return m_bFormatter; }
+
+ void SetDirection(sal_Bool bForward) { m_bForward = bForward; }
+ sal_Bool GetDirection() const { return m_bForward; }
+
+ void SetWildcard(sal_Bool bSet) { m_bWildcard = bSet; }
+ sal_Bool GetWildcard() const { return m_bWildcard; }
+
+ void SetRegular(sal_Bool bSet) { m_bRegular = bSet; }
+ sal_Bool GetRegular() const { return m_bRegular; }
+
+ void SetLevenshtein(sal_Bool bSet) { m_bLevenshtein = bSet; }
+ sal_Bool GetLevenshtein() const { return m_bLevenshtein; }
+
+ void SetIgnoreWidthCJK(sal_Bool bSet);
+ sal_Bool GetIgnoreWidthCJK() const;
+
+ void SetTransliteration(sal_Bool bSet) { m_bTransliteration = bSet; }
+ sal_Bool GetTransliteration() const { return m_bTransliteration; }
+
+ void SetLevRelaxed(sal_Bool bSet) { m_bLevRelaxed = bSet; }
+ sal_Bool GetLevRelaxed() const { return m_bLevRelaxed; }
+ void SetLevOther(sal_uInt16 nHowMuch) { m_nLevOther = nHowMuch; }
+ sal_uInt16 GetLevOther() const { return m_nLevOther; }
+ void SetLevShorter(sal_uInt16 nHowMuch) { m_nLevShorter = nHowMuch; }
+ sal_uInt16 GetLevShorter() const { return m_nLevShorter; }
+ void SetLevLonger(sal_uInt16 nHowMuch) { m_nLevLonger = nHowMuch; }
+ sal_uInt16 GetLevLonger() const { return m_nLevLonger; }
+ // die ganzen Lev-Werte werden nur bei m_bLevenshtein==sal_True beachtet
+
+ void SetTransliterationFlags(sal_Int32 _nFlags) { m_nTransliterationFlags = _nFlags; }
+ sal_Int32 GetTransliterationFlags() const { return m_nTransliterationFlags; }
+
+ void SetPosition(sal_uInt16 nValue) { m_nPosition = nValue; }
+ sal_uInt16 GetPosition() const { return m_nPosition; }
+ // Position wird bei m_bWildCard==sal_True nicht beachtet
+
+ FMSEARCH_MODE GetSearchMode() const { return m_eMode; }
+
+public:
+ /** zwei Constructoren, beide analog zu denen des FmSearchDialog, Erklaerung siehe also dort ....
+ xCursor muss jeweils den ::com::sun::star::data::DatabaseCursor-Service implementieren.
+ wenn eMode == SM_USETHREAD, sollte ein ProgressHandler gesetzt sein, da dann die Ergebnisuebermittlung ueber diesen
+ Handler erfolgt.
+ Ist eMode != SM_USETHREAD, kehren SearchNext und StarOver nicht zurueck, bevor die Suche (erfolgreich oder nicht) beendet
+ wurde, dann kann man das Ergebnis danach abfragen. Ist zusaetzlich der ProgressHandler gesetzt, wird dieser fuer jeden neuen
+ Datensatz sowie am Ende der Suche aufgerufen.
+ */
+ FmSearchEngine(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& xCursor,
+ const ::rtl::OUString& strVisibleFields,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& xFormat,
+ FMSEARCH_MODE eMode);//CHINA001 FmSearchDialog::SEARCH_MODE eMode);
+ FmSearchEngine(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& xCursor,
+ const ::rtl::OUString& strVisibleFields,
+ const InterfaceArray& arrFields,
+ FMSEARCH_MODE eMode); //CHINA001 FmSearchDialog::SEARCH_MODE eMode);
+
+ virtual ~FmSearchEngine();
+
+ /** der Link wird fuer jeden Datensatz und nach Beendigung der Suche aufgerufen, Parameter ist ein Zeiger auf
+ eine FmSearchProgress-Struktur
+ der Handler sollte auf jeden Fall Thread-sicher sein
+ */
+ void SetProgressHandler(Link aHdl) { m_aProgressHandler = aHdl; }
+
+ /// das naechste Vorkommen suchen (Werte fuer nDirection siehe DIRECTION_*-defines)
+ void SearchNext(const ::rtl::OUString& strExpression);
+ /// analogous, search for "NULL" (_bSearchForNull==sal_True) or "not NULL"
+ void SearchNextSpecial(sal_Bool _bSearchForNull);
+ /// das naechste Vorkommen suchen, abhaengig von nDirection wird dabei am Anfang oder am Ende neu begonnen
+ void StartOver(const ::rtl::OUString& strExpression);
+ /// analogous, search for "NULL" (_bSearchForNull==sal_True) or "not NULL"
+ void StartOverSpecial(sal_Bool _bSearchForNull);
+ /// die Angaben ueber letzte Fundstelle invalidieren
+ void InvalidatePreviousLoc();
+
+ /** baut m_arrUsedFields neu auf (nFieldIndex==-1 bedeutet alle Felder, ansonsten gibt es den Feldindex an)
+ wenn bForce nicht gesetzt ist, passiert bei nFieldIndex == m_nCurrentFieldIndex nichts
+ (ruft InvalidatePreviousLoc auf)
+ */
+ void RebuildUsedFields(sal_Int32 nFieldIndex, sal_Bool bForce = sal_False);
+ ::rtl::OUString FormatField(sal_Int32 nWhich);
+
+ /// kehrt sofort zurueck; nachdem wirklich abgebrochen wurde, wird der ProgressHandler mit STATE_CANCELED aufgerufen
+ void CancelSearch();
+
+ /** nur gueltig, wenn nicht gerade eine (asynchrone) Suche laeuft, die naechste Suche wird dann auf dem neuen Iterator
+ mit den neuen Parametern durchgefuehrt
+ */
+ sal_Bool SwitchToContext(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& xCursor, const ::rtl::OUString& strVisibleFields, const InterfaceArray& arrFields,
+ sal_Int32 nFieldIndex);
+
+protected:
+ void Init(const ::rtl::OUString& strVisibleFields);
+
+ void SearchNextImpl();
+ // diese Impl-Methode laeuft im SearchThread
+
+ // start a thread-search (or call SearchNextImpl directly, depending on the search mode)
+ void ImplStartNextSearch();
+
+private:
+ SVX_DLLPRIVATE void clearControlTexts();
+ SVX_DLLPRIVATE void fillControlTexts(const InterfaceArray& arrFields);
+
+ // three methods implementing a complete search loop (null/not null, wildcard, SearchText)
+ // (they all have some code in common, but with this solution we have do do a distinction only once per search (before
+ // starting the loop), not in every loop step
+ SVX_DLLPRIVATE SEARCH_RESULT SearchSpecial(sal_Bool _bSearchForNull, sal_Int32& nFieldPos, FieldCollectionIterator& iterFieldLoop,
+ const FieldCollectionIterator& iterBegin, const FieldCollectionIterator& iterEnd);
+ SVX_DLLPRIVATE SEARCH_RESULT SearchWildcard(const ::rtl::OUString& strExpression, sal_Int32& nFieldPos, FieldCollectionIterator& iterFieldLoop,
+ const FieldCollectionIterator& iterBegin, const FieldCollectionIterator& iterEnd);
+ SVX_DLLPRIVATE SEARCH_RESULT SearchRegularApprox(const ::rtl::OUString& strExpression, sal_Int32& nFieldPos, FieldCollectionIterator& iterFieldLoop,
+ const FieldCollectionIterator& iterBegin, const FieldCollectionIterator& iterEnd);
+
+ SVX_DLLPRIVATE void PropagateProgress(sal_Bool _bDontPropagateOverflow);
+ // ruft den ProgressHandler mit STATE_PROGRESS und der aktuellen Position des SearchIterators auf
+
+ // helpers, die ich mehrmals brauche
+ SVX_DLLPRIVATE sal_Bool MoveCursor();
+ // bewegt m_xSearchIterator unter Beachtung von Richtung/Ueberlauf Cursor
+ SVX_DLLPRIVATE sal_Bool MoveField(sal_Int32& nPos, FieldCollectionIterator& iter, const FieldCollectionIterator& iterBegin, const FieldCollectionIterator& iterEnd);
+ // bewegt den Iterator unter Beachtung von Richtung/Ueberlauf Iterator/Ueberlauf Cursor
+ SVX_DLLPRIVATE void BuildAndInsertFieldInfo(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xAllFields, sal_Int32 nField);
+ // baut eine FieldInfo zum Feld Nummer nField (in xAllFields) auf und fuegt sie zu m_arrUsedFields hinzu
+ // xAllFields muss den DatabaseRecord-Service unterstuetzen
+ SVX_DLLPRIVATE ::rtl::OUString FormatField(const FieldInfo& rField);
+ // formatiert das Feld mit dem NumberFormatter
+
+ SVX_DLLPRIVATE sal_Bool HasPreviousLoc() { return m_aPreviousLocBookmark.hasValue(); }
+
+ DECL_LINK(OnSearchTerminated, FmSearchThread*);
+ // wird vom SuchThread benutzt, nach Rueckkehr aus diesem Handler loescht sich der Thread selber
+ DECL_LINK(OnNewRecordCount, void*);
+};
+
+#endif // _FMSRCIMP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmtextcontroldialogs.hxx b/svx/source/inc/fmtextcontroldialogs.hxx
new file mode 100644
index 000000000000..56ffb7526b3a
--- /dev/null
+++ b/svx/source/inc/fmtextcontroldialogs.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_SOURCE_FORM_FMTEXTCONTROLDIALOGS_HXX
+#define SVX_SOURCE_FORM_FMTEXTCONTROLDIALOGS_HXX
+
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/tabdlg.hxx>
+#include <editeng/flstitem.hxx>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ //====================================================================
+ //= TextControlCharAttribDialog
+ //====================================================================
+ class TextControlCharAttribDialog : public SfxTabDialog
+ {
+ private:
+ SvxFontListItem m_aFontList;
+
+ public:
+ TextControlCharAttribDialog( Window* pParent, const SfxItemSet& _rCoreSet, const SvxFontListItem& _rFontList );
+ ~TextControlCharAttribDialog();
+
+ protected:
+ virtual void PageCreated( USHORT _nId, SfxTabPage& _rPage );
+ };
+
+ //====================================================================
+ //= TextControlParaAttribDialog
+ //====================================================================
+ class TextControlParaAttribDialog : public SfxTabDialog
+ {
+ public:
+ TextControlParaAttribDialog( Window* _pParent, const SfxItemSet& _rCoreSet );
+ ~TextControlParaAttribDialog();
+ };
+//........................................................................
+} // namespace svx
+//........................................................................
+
+#endif // SVX_SOURCE_FORM_FMTEXTCONTROLDIALOGS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmtextcontrolfeature.hxx b/svx/source/inc/fmtextcontrolfeature.hxx
new file mode 100644
index 000000000000..932c40f83a01
--- /dev/null
+++ b/svx/source/inc/fmtextcontrolfeature.hxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_SOURCE_INC_FMTEXTCONTROLFEATURE_HXX
+#define SVX_SOURCE_INC_FMTEXTCONTROLFEATURE_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/util/URL.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/implbase1.hxx>
+#include "fmslotinvalidator.hxx"
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ //====================================================================
+ //= FmTextControlFeature
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::frame::XStatusListener
+ > FmTextControlFeature_Base;
+
+ class FmTextControlFeature : public FmTextControlFeature_Base
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >
+ m_xDispatcher;
+ ::com::sun::star::util::URL m_aFeatureURL;
+ ::com::sun::star::uno::Any m_aFeatureState;
+ SfxSlotId m_nSlotId;
+ ISlotInvalidator* m_pInvalidator;
+ bool m_bFeatureEnabled;
+
+ public:
+ /** constructs an FmTextControlFeature object
+ @param _rxDispatcher
+ the dispatcher which the instance should work with
+ @param _rFeatureURL
+ the URL which the instance should be responsible for
+ */
+ FmTextControlFeature(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& _rxDispatcher,
+ const ::com::sun::star::util::URL& _rFeatureURL,
+ SfxSlotId _nId,
+ ISlotInvalidator* _pInvalidator
+ );
+
+ /// determines whether the feature we're responsible for is currently enabled
+ inline bool isFeatureEnabled( ) const { return m_bFeatureEnabled; }
+ inline const ::com::sun::star::uno::Any& getFeatureState( ) const { return m_aFeatureState; }
+
+ /** dispatches the feature URL to the dispatcher
+ */
+ void dispatch() const SAL_THROW(());
+
+ /** dispatches the feature URL to the dispatcher, with passing the given arguments
+ */
+ void dispatch( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ) const SAL_THROW(());
+
+ /// releases any resources associated with this instance
+ void dispose() SAL_THROW(());
+
+ protected:
+ ~FmTextControlFeature();
+
+ protected:
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& State ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+ };
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+#endif // SVX_SOURCE_INC_FMTEXTCONTROLFEATURE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmtextcontrolshell.hxx b/svx/source/inc/fmtextcontrolshell.hxx
new file mode 100644
index 000000000000..c65a8f4bafa3
--- /dev/null
+++ b/svx/source/inc/fmtextcontrolshell.hxx
@@ -0,0 +1,226 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX
+#define SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/awt/XMouseListener.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+/** === end UNO includes === **/
+#include <comphelper/implementationreference.hxx>
+#include <tools/link.hxx>
+#include <vcl/timer.hxx>
+#include "fmslotinvalidator.hxx"
+
+#include <vector>
+#include <map>
+
+class SfxRequest;
+class SfxItemSet;
+class SfxAllItemSet;
+class SfxBindings;
+class SfxViewFrame;
+class Window;
+class SfxApplication;
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ class FmFocusListenerAdapter;
+ class FmTextControlFeature;
+ class FmMouseListenerAdapter;
+
+ //====================================================================
+ //= IFocusObserver
+ //====================================================================
+ class IFocusObserver
+ {
+ public:
+ virtual void focusGained( const ::com::sun::star::awt::FocusEvent& _rEvent ) = 0;
+ virtual void focusLost( const ::com::sun::star::awt::FocusEvent& _rEvent ) = 0;
+ };
+
+ //====================================================================
+ //= IFocusObserver
+ //====================================================================
+ class IContextRequestObserver
+ {
+ public:
+ virtual void contextMenuRequested( const ::com::sun::star::awt::MouseEvent& _rEvent ) = 0;
+ };
+
+ //====================================================================
+ //= FmTextControlShell
+ //====================================================================
+ class FmTextControlShell :public IFocusObserver
+ ,public ISlotInvalidator
+ ,public IContextRequestObserver
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > m_xActiveControl;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > m_xActiveTextComponent;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xActiveController;
+#ifndef DONT_REMEMBER_LAST_CONTROL
+ // without this define, m_xActiveControl remembers the *last* active control, even
+ // if it, in the meantime, already lost the focus
+ bool m_bActiveControl;
+ // so we need an additional boolean flag telling whether the active cotrol
+ // is really focused
+#endif
+ bool m_bActiveControlIsReadOnly;
+ bool m_bActiveControlIsRichText;
+
+ // listening at all controls of the active controller for focus changes
+ typedef ::comphelper::ImplementationReference< FmFocusListenerAdapter, ::com::sun::star::awt::XFocusListener >
+ FocusListenerAdapter;
+ typedef ::std::vector< FocusListenerAdapter > FocusListenerAdapters;
+ FocusListenerAdapters m_aControlObservers;
+
+ typedef ::comphelper::ImplementationReference< FmMouseListenerAdapter, ::com::sun::star::awt::XMouseListener >
+ MouseListenerAdapter;
+ MouseListenerAdapter m_aContextMenuObserver;
+
+ // translating between "slots" of the framework and "features" of the active control
+ typedef ::comphelper::ImplementationReference< FmTextControlFeature, ::com::sun::star::frame::XStatusListener >
+ ControlFeature;
+ typedef ::std::map< SfxSlotId, ControlFeature, ::std::less< SfxSlotId > > ControlFeatures;
+ ControlFeatures m_aControlFeatures;
+
+ SfxViewFrame* m_pViewFrame;
+ // invalidating slots
+ SfxBindings& m_rBindings;
+ Link m_aControlActivationHandler;
+ AutoTimer m_aClipboardInvalidation;
+ bool m_bNeedClipboardInvalidation;
+
+ public:
+ FmTextControlShell( SfxViewFrame* _pFrame );
+ virtual ~FmTextControlShell();
+
+ // clean up any resources associated with this instance
+ void dispose();
+
+ void ExecuteTextAttribute( SfxRequest& _rReq );
+ void GetTextAttributeState( SfxItemSet& _rSet );
+ bool IsActiveControl( bool _bCountRichTextOnly = false ) const;
+ void ForgetActiveControl();
+ void SetControlActivationHandler( const Link& _rHdl ) { m_aControlActivationHandler = _rHdl; }
+
+ /** to be called when a form in our document has been activated
+ */
+ void formActivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController );
+ /** to be called when a form in our document has been deactivated
+ */
+ void formDeactivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController );
+
+ /** notifies the instance that the design mode has changed
+ */
+ void designModeChanged( bool _bNewDesignMode );
+
+ protected:
+ // IFocusObserver
+ virtual void focusGained( const ::com::sun::star::awt::FocusEvent& _rEvent );
+ virtual void focusLost( const ::com::sun::star::awt::FocusEvent& _rEvent );
+
+ // IContextRequestObserver
+ virtual void contextMenuRequested( const ::com::sun::star::awt::MouseEvent& _rEvent );
+
+ // ISlotInvalidator
+ virtual void Invalidate( SfxSlotId _nSlot );
+
+ protected:
+ enum AttributeSet { eCharAttribs, eParaAttribs };
+ void executeAttributeDialog( AttributeSet _eSet, SfxRequest& _rReq );
+ bool executeSelectAll( );
+ bool executeClipboardSlot( SfxSlotId _nSlot );
+
+ private:
+ inline bool isControllerListening() const { return !m_aControlObservers.empty(); }
+
+ FmTextControlFeature*
+ implGetFeatureDispatcher(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& _rxProvider,
+ SfxApplication* _pApplication,
+ SfxSlotId _nSlot
+ );
+
+ // fills the given structure with dispatchers for the given slots, for the given control
+ void fillFeatureDispatchers(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > _rxControl,
+ SfxSlotId* _pZeroTerminatedSlots,
+ ControlFeatures& _rDispatchers
+ );
+
+ /// creates SfxPoolItes for all features in the given set, and puts them into the given SfxAllItemSet
+ void transferFeatureStatesToItemSet(
+ ControlFeatures& _rDispatchers,
+ SfxAllItemSet& _rSet,
+ bool _bTranslateLatin = false
+ );
+
+ /// to be called when a control has been activated
+ void controlActivated( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl );
+ /// to be called when the currently active control has been deactivated
+ void controlDeactivated( );
+
+ void implClearActiveControlRef();
+
+ /** starts listening at all controls of the given controller for focus events
+ @precond
+ we don't have an active controller currently
+ */
+ void startControllerListening( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController );
+ /** stops listening at the active controller
+ @precond
+ we have an active controller currently
+ */
+ void stopControllerListening( );
+
+ /** parses the given URL's Complete member, by calling XURLTransformer::parseString
+ */
+ void impl_parseURL_nothrow( ::com::sun::star::util::URL& _rURL );
+
+ DECL_LINK( OnInvalidateClipboard, void* );
+ };
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+#endif // SVX_SOURCE_INC_FMTEXTCONTROLSHELL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmundo.hxx b/svx/source/inc/fmundo.hxx
new file mode 100644
index 000000000000..6967fe44247b
--- /dev/null
+++ b/svx/source/inc/fmundo.hxx
@@ -0,0 +1,232 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMUNDO_HXX
+#define _SVX_FMUNDO_HXX
+
+#include <svx/svdundo.hxx>
+#include <svx/svdouno.hxx>
+#include "fmscriptingenv.hxx"
+
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/XModifyListener.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <com/sun/star/script/ScriptEvent.hpp>
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/container/ContainerEvent.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/implbase3.hxx>
+
+
+#include <svl/lstner.hxx>
+#include <comphelper/uno3.hxx>
+
+class FmFormModel;
+class FmFormObj;
+class SdrObject;
+class FmXFormView;
+
+FORWARD_DECLARE_INTERFACE(awt,XControl)
+FORWARD_DECLARE_INTERFACE(awt,XControlContainer)
+//FORWARD_DECLARE_INTERFACE(uno,Reference)
+
+//==================================================================
+// FmUndoPropertyAction
+//==================================================================
+class FmUndoPropertyAction: public SdrUndoAction
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xObj;
+ ::rtl::OUString aPropertyName;
+ ::com::sun::star::uno::Any aNewValue;
+ ::com::sun::star::uno::Any aOldValue;
+
+public:
+ FmUndoPropertyAction(FmFormModel& rMod, const ::com::sun::star::beans::PropertyChangeEvent& evt);
+
+ virtual void Undo();
+ virtual void Redo();
+
+ virtual String GetComment() const;
+
+};
+
+//==================================================================
+// FmUndoContainerAction
+//==================================================================
+class FmUndoContainerAction: public SdrUndoAction
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
+ m_xContainer; // container which the action applies to
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ m_xElement; // object not owned by the action
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ m_xOwnElement; // object owned by the action
+ sal_Int32 m_nIndex; // index of the object within it's container
+ ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >
+ m_aEvents; // events of the object
+
+public:
+ enum Action
+ {
+ Inserted = 1,
+ Removed = 2
+ };
+
+private:
+ Action m_eAction;
+
+public:
+ FmUndoContainerAction(FmFormModel& rMod,
+ Action _eAction,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& xCont,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xElem,
+ sal_Int32 nIdx = -1);
+ ~FmUndoContainerAction();
+
+ virtual void Undo();
+ virtual void Redo();
+
+ static void DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xElem );
+
+protected:
+ void implReInsert( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
+ void implReRemove( ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
+};
+
+//==================================================================
+// FmUndoModelReplaceAction
+//==================================================================
+class FmUndoModelReplaceAction : public SdrUndoAction
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel> m_xReplaced;
+ SdrUnoObj* m_pObject;
+
+public:
+ FmUndoModelReplaceAction(FmFormModel& rMod, SdrUnoObj* pObject, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced);
+ ~FmUndoModelReplaceAction();
+
+ virtual void Undo();
+ virtual void Redo() { Undo(); }
+
+ virtual String GetComment() const;
+
+ static void DisposeElement( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xReplaced );
+};
+
+//========================================================================
+class SVX_DLLPRIVATE FmXUndoEnvironment
+ : public ::cppu::WeakImplHelper3< ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::container::XContainerListener
+ , ::com::sun::star::util::XModifyListener
+ >
+ , public SfxListener
+ // public ::cppu::OWeakObject
+{
+ FmFormModel& rModel;
+
+ void* m_pPropertySetCache;
+ ::svxform::PFormScriptingEnvironment m_pScriptingEnv;
+ oslInterlockedCount m_Locks;
+ ::osl::Mutex m_aMutex;
+ sal_Bool bReadOnly;
+ bool m_bDisposed;
+
+public:
+ FmXUndoEnvironment(FmFormModel& _rModel);
+ ~FmXUndoEnvironment();
+
+ // UNO Anbindung
+ // SMART_UNO_DECLARATION(FmXUndoEnvironment, ::cppu::OWeakObject);
+ // virtual sal_Bool queryInterface(UsrUik, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>&);
+ // virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass>> getIdlClasses(void);
+
+ void Lock() { osl_incrementInterlockedCount( &m_Locks ); }
+ void UnLock() { osl_decrementInterlockedCount( &m_Locks ); }
+ sal_Bool IsLocked() const { return m_Locks != 0; }
+
+ // access control
+ struct Accessor { friend class FmFormModel; private: Accessor() { } };
+
+ // addition and removal of form collections
+ void AddForms( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& rForms );
+ void RemoveForms( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& rForms );
+
+ // readonly-ness
+ void SetReadOnly( sal_Bool bRead, const Accessor& ) { bReadOnly = bRead; }
+ sal_Bool IsReadOnly() const {return bReadOnly;}
+
+protected:
+ // XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
+
+ // XContainerListener
+ virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
+
+ // XModifyListener
+ virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ void ModeChanged();
+ void dispose();
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+private:
+ void AddElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
+ void RemoveElement(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
+ void TogglePropertyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Element);
+
+ void implSetModified();
+
+ void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& _rxContainer, bool _bStartListening ) SAL_THROW(());
+ void switchListening( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxObject, bool _bStartListening ) SAL_THROW(());
+ ::com::sun::star::uno::Reference< com::sun::star::script::XScriptListener > m_vbaListener;
+public:
+ // Methoden zur Zuordnung von Controls zu Forms,
+ // werden von der Seite und der UndoUmgebung genutzt
+ void Inserted(SdrObject* pObj);
+ void Removed(SdrObject* pObj);
+
+ void Inserted(FmFormObj* pObj);
+ void Removed(FmFormObj* pObj);
+};
+
+
+#endif //_SVX_FMUNDO_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmurl.hxx b/svx/source/inc/fmurl.hxx
new file mode 100644
index 000000000000..2b8a686f1e21
--- /dev/null
+++ b/svx/source/inc/fmurl.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMURL_HXX
+#define _SVX_FMURL_HXX
+
+#define FMURL_FORMSLOTS_PREFIX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/" ) )
+#define FMURL_FORM_POSITION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/positionForm" ) )
+#define FMURL_FORM_RECORDCOUNT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/RecordCount" ) )
+#define FMURL_RECORD_MOVEFIRST rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/moveToFirst" ) )
+#define FMURL_RECORD_MOVEPREV rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/moveToPrev" ) )
+#define FMURL_RECORD_MOVENEXT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/moveToNext" ) )
+#define FMURL_RECORD_MOVELAST rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/moveToLast" ) )
+#define FMURL_RECORD_MOVETONEW rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/moveToNew" ) )
+#define FMURL_RECORD_UNDO rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/undoRecord" ) )
+#define FMURL_RECORD_SAVE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/saveRecord" ) )
+#define FMURL_RECORD_DELETE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/deleteRecord" ) )
+#define FMURL_FORM_REFRESH rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/refreshForm" ) )
+#define FMURL_FORM_REFRESH_CURRENT_CONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/refreshCurrentControl" ) )
+#define FMURL_FORM_SORT_UP rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/sortUp" ) )
+#define FMURL_FORM_SORT_DOWN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/sortDown" ) )
+#define FMURL_FORM_SORT rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/sort" ) )
+#define FMURL_FORM_AUTO_FILTER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/autoFilter" ) )
+#define FMURL_FORM_FILTER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/filter" ) )
+#define FMURL_FORM_APPLY_FILTER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/applyFilter" ) )
+#define FMURL_FORM_REMOVE_FILTER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormController/removeFilterOrder" ) )
+#define FMURL_CONFIRM_DELETION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormSlots/ConfirmDeletion" ) )
+#define FMURL_COMPONENT_FORMGRIDVIEW rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".component:DB/FormGridView" ) )
+#define FMURL_GRIDVIEW_CLEARVIEW rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormSlots/ClearView" ) )
+#define FMURL_GRIDVIEW_ADDCOLUMN rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormSlots/AddGridColumn" ) )
+#define FMURL_GRIDVIEW_ATTACHTOFORM rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormSlots/AttachToForm" ) )
+#define FMARG_ATTACHTO_MASTERFORM rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MasterForm" ) )
+#define FMARG_ADDCOL_COLUMNTYPE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnType" ) )
+#define FMARG_ADDCOL_COLUMNPOS rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnPosition" ) )
+
+#endif // _SVX_FMURL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/fmvwimp.hxx b/svx/source/inc/fmvwimp.hxx
new file mode 100644
index 000000000000..33f82ceb6b91
--- /dev/null
+++ b/svx/source/inc/fmvwimp.hxx
@@ -0,0 +1,317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMVWIMP_HXX
+#define _SVX_FMVWIMP_HXX
+
+#include "svx/svdmark.hxx"
+#include "fmdocumentclassification.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/form/runtime/XFormControllerContext.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/container/ContainerEvent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/sdb/SQLErrorEvent.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/stl_types.hxx>
+#include <tools/link.hxx>
+#include <tools/string.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/componentcontext.hxx>
+
+//class SdrPageViewWinRec;
+class SdrPageWindow;
+
+class SdrPageView;
+class SdrObject;
+class FmFormObj;
+class FmFormModel;
+class FmFormView;
+class FmFormShell;
+class Window;
+class OutputDevice;
+class SdrUnoObj;
+class SdrView;
+
+FORWARD_DECLARE_INTERFACE(awt,XControl)
+FORWARD_DECLARE_INTERFACE(awt,XWindow)
+FORWARD_DECLARE_INTERFACE(beans,XPropertySet)
+FORWARD_DECLARE_INTERFACE(util,XNumberFormats)
+
+class FmXFormView;
+
+namespace svx {
+ class ODataAccessDescriptor;
+ struct OXFormsDescriptor;
+}
+
+//==================================================================
+// FmXPageViewWinRec
+//==================================================================
+typedef ::cppu::WeakImplHelper2 < ::com::sun::star::container::XIndexAccess
+ , ::com::sun::star::form::runtime::XFormControllerContext
+ > FmXPageViewWinRec_Base;
+
+class FmXPageViewWinRec : public FmXPageViewWinRec_Base
+{
+ friend class FmXFormView;
+
+ ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > m_aControllerList;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xControlContainer;
+ ::comphelper::ComponentContext m_aContext;
+ FmXFormView* m_pViewImpl;
+ Window* m_pWindow;
+
+protected:
+ ~FmXPageViewWinRec();
+
+public:
+ FmXPageViewWinRec( const ::comphelper::ComponentContext& _rContext,
+ const SdrPageWindow&, FmXFormView* pView);
+ //const SdrPageViewWinRec*, FmXFormView* pView);
+
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException);
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 _Index) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XFormControllerContext
+ virtual void SAL_CALL makeVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _Control ) throw (::com::sun::star::uno::RuntimeException);
+
+ const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > >& GetList() {return m_aControllerList;}
+
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > getController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm ) const;
+ void setController(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxParentController );
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > getControlContainer() const { return m_xControlContainer; }
+ void updateTabOrder( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm );
+ void dispose();
+ Window* getWindow() const {return m_pWindow;}
+};
+
+typedef ::std::vector<FmXPageViewWinRec*> FmWinRecList;
+typedef ::std::set < ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
+ , ::comphelper::OInterfaceCompare< ::com::sun::star::form::XForm >
+ > SetOfForms;
+typedef ::std::map < ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ , SetOfForms
+ , ::comphelper::OInterfaceCompare< ::com::sun::star::awt::XControlContainer >
+ > MapControlContainerToSetOfForms;
+class SdrModel;
+//==================================================================
+// FmXFormView
+//==================================================================
+class FmXFormView : public ::cppu::WeakImplHelper3<
+ ::com::sun::star::form::XFormControllerListener,
+ ::com::sun::star::awt::XFocusListener,
+ ::com::sun::star::container::XContainerListener>
+{
+ friend class FmFormView;
+ friend class FmFormShell;
+ friend class FmXFormShell;
+ friend class FmXPageViewWinRec;
+ class ObjectRemoveListener;
+ friend class ObjectRemoveListener;
+
+ ::comphelper::ComponentContext m_aContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> m_xWindow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xLastCreatedControlModel;
+
+ FmFormObj* m_pMarkedGrid;
+ FmFormView* m_pView;
+ sal_uIntPtr m_nActivationEvent;
+ sal_uIntPtr m_nErrorMessageEvent; // event for an asynchronous error message. See also m_aAsyncError
+ sal_uIntPtr m_nAutoFocusEvent; // event for asynchronously setting the focus to a control
+ sal_uIntPtr m_nControlWizardEvent; // event for asynchronously setting the focus to a control
+
+ ::com::sun::star::sdb::SQLErrorEvent
+ m_aAsyncError; // error event which is to be displayed asyn. See m_nErrorMessageEvent.
+
+ FmWinRecList m_aWinList; // to be filled in alive mode only
+ MapControlContainerToSetOfForms
+ m_aNeedTabOrderUpdate;
+
+ // Liste der markierten Object, dient zur Restauration beim Umschalten von Alive in DesignMode
+ SdrMarkList m_aMark;
+ ObjectRemoveListener* m_pWatchStoredList;
+
+ bool m_bFirstActivation;
+ bool m_isTabOrderUpdateSuspended;
+
+ FmFormShell* GetFormShell() const;
+
+ void removeGridWindowListening();
+
+protected:
+ FmXFormView( const ::comphelper::ComponentContext& _rContext, FmFormView* _pView );
+ ~FmXFormView();
+
+ void saveMarkList( sal_Bool _bSmartUnmark = sal_True );
+ void restoreMarkList( SdrMarkList& _rRestoredMarkList );
+ void stopMarkListWatching();
+ void startMarkListWatching();
+
+ void notifyViewDying( );
+ // notifies this impl class that the anti-impl instance (m_pView) is going to die
+
+public:
+ // UNO Anbindung
+
+// ::com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::container::XContainerListener
+ virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw(::com::sun::star::uno::RuntimeException);
+
+// ::com::sun::star::form::XFormControllerListener
+ virtual void SAL_CALL formActivated(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL formDeactivated(const ::com::sun::star::lang::EventObject& rEvent) throw(::com::sun::star::uno::RuntimeException);
+
+ // XFocusListener
+ virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+
+ FmFormView* getView() const {return m_pView;}
+ FmWinRecList::const_iterator findWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC ) const;
+ const FmWinRecList& getWindowList() const {return m_aWinList;}
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >
+ getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const;
+
+ // activation handling
+ inline bool hasEverBeenActivated( ) const { return !m_bFirstActivation; }
+ inline void setHasBeenActivated( ) { m_bFirstActivation = false; }
+
+ void onFirstViewActivation( const FmFormModel* _pDocModel );
+
+ /** suspends the calls to activateTabOrder, which normally happen whenever for any ControlContainer of the view,
+ new controls are inserted. Cannot be nested, i.e. you need to call resumeTabOrderUpdate before calling
+ suspendTabOrderUpdate, again.
+ */
+ void suspendTabOrderUpdate();
+
+ /** resumes calls to activateTabOrder, and also does all pending calls which were collected since the last
+ suspendTabOrderUpdate call.
+ */
+ void resumeTabOrderUpdate();
+
+ void onCreatedFormObject( FmFormObj& _rFormObject );
+
+ static bool
+ isFocusable(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& i_rControl
+ );
+
+private:
+ FmWinRecList::iterator findWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC );
+ //void addWindow(const SdrPageViewWinRec*);
+ void addWindow(const SdrPageWindow&);
+ void removeWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC );
+ void Activate(sal_Bool bSync = sal_False);
+ void Deactivate(BOOL bDeactivateController = TRUE);
+
+ SdrObject* implCreateFieldControl( const ::svx::ODataAccessDescriptor& _rColumnDescriptor );
+ SdrObject* implCreateXFormsControl( const ::svx::OXFormsDescriptor &_rDesc );
+
+ static bool createControlLabelPair(
+ const ::comphelper::ComponentContext& _rContext,
+ OutputDevice& _rOutDev,
+ sal_Int32 _nXOffsetMM,
+ sal_Int32 _nYOffsetMM,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats,
+ sal_uInt16 _nControlObjectID,
+ const ::rtl::OUString& _rFieldPostfix,
+ UINT32 _nInventor,
+ UINT16 _nLabelObjectID,
+ SdrPage* _pLabelPage,
+ SdrPage* _pControlPage,
+ SdrModel* _pModel,
+ SdrUnoObj*& _rpLabel,
+ SdrUnoObj*& _rpControl
+ );
+
+ bool createControlLabelPair(
+ OutputDevice& _rOutDev,
+ sal_Int32 _nXOffsetMM,
+ sal_Int32 _nYOffsetMM,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats,
+ sal_uInt16 _nControlObjectID,
+ const ::rtl::OUString& _rFieldPostfix,
+ SdrUnoObj*& _rpLabel,
+ SdrUnoObj*& _rpControl,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource >& _rxDataSource = NULL,
+ const ::rtl::OUString& _rDataSourceName = ::rtl::OUString(),
+ const ::rtl::OUString& _rCommand= ::rtl::OUString(),
+ const sal_Int32 _nCommandType = -1
+ );
+
+ void ObjectRemovedInAliveMode(const SdrObject* pObject);
+
+ // asynchronously displays an error message. See also OnDelayedErrorMessage.
+ void displayAsyncErrorMessage( const ::com::sun::star::sdb::SQLErrorEvent& _rEvent );
+
+ // cancels all pending async events
+ void cancelEvents();
+
+ /// the the auto focus to the first (in terms of the tab order) control
+ void AutoFocus( sal_Bool _bSync = sal_False );
+ DECL_LINK( OnActivate, void* );
+ DECL_LINK( OnAutoFocus, void* );
+ DECL_LINK( OnDelayedErrorMessage, void* );
+ DECL_LINK( OnStartControlWizard, void* );
+
+private:
+ ::svxform::DocumentType impl_getDocumentType() const;
+};
+
+
+
+#endif // _SVX_FMVWIMP_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/formcontrolfactory.hxx b/svx/source/inc/formcontrolfactory.hxx
new file mode 100644
index 000000000000..2b3a5796c3d0
--- /dev/null
+++ b/svx/source/inc/formcontrolfactory.hxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+/*************************************************************************
+ * 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 SVX_FORMCONTROLMANAGER_HXX
+#define SVX_FORMCONTROLMANAGER_HXX
+
+#include "fmdocumentclassification.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/XNumberFormats.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+/** === end UNO includes === **/
+
+#include <memory>
+
+class SdrUnoObj;
+class Rectangle;
+
+namespace comphelper {
+ class ComponentContext;
+}
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= FormControlFactory
+ //====================================================================
+ struct FormControlFactory_Data;
+
+ class FormControlFactory
+ {
+ public:
+ FormControlFactory( const ::comphelper::ComponentContext& _rContext );
+ ~FormControlFactory();
+
+ /** initializes the given control model which is to be newly inserted into a document
+
+ @param _eDocType
+ the type of the document which the control is to be inserted into
+ @param _rxControlModel
+ the control model to be inserted
+ @param _rControlBoundRect
+ the bound rect of the control, if applicable
+ @return
+ the class ID of the control
+ */
+ sal_Int16 initializeControlModel(
+ const DocumentType _eDocType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
+ const Rectangle& _rControlBoundRect
+ );
+
+ sal_Int16 initializeControlModel( const DocumentType _eDocType, const SdrUnoObj& _rObject );
+ sal_Int16 initializeControlModel( const DocumentType _eDocType, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel );
+
+ void initializeTextFieldLineEnds(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
+ );
+
+ void initializeFieldDependentProperties(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDatabaseField,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormats >& _rxNumberFormats
+ );
+
+ static ::rtl::OUString getDefaultName(
+ const sal_Int16 nClassId,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo >& _rxObject
+ );
+
+ static ::rtl::OUString getDefaultUniqueName_ByComponentType(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxContainer,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObject
+ );
+
+ static ::rtl::OUString getUniqueName(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxContainer,
+ const ::rtl::OUString& _rBaseName
+ );
+
+ private:
+ ::std::auto_ptr< FormControlFactory_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_FORMCONTROLMANAGER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/formcontroller.hxx b/svx/source/inc/formcontroller.hxx
new file mode 100644
index 000000000000..8d364a98906a
--- /dev/null
+++ b/svx/source/inc/formcontroller.hxx
@@ -0,0 +1,594 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_FMCTRLER_HXX
+#define _SVX_FMCTRLER_HXX
+
+#include "delayedevent.hxx"
+#include "formdispatchinterceptor.hxx"
+#include "sqlparserclient.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/awt/XItemListener.hpp>
+#include <com/sun/star/awt/XMouseListener.hpp>
+#include <com/sun/star/awt/XTabController.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/form/DatabaseDeleteEvent.hpp>
+#include <com/sun/star/form/DatabaseParameterEvent.hpp>
+#include <com/sun/star/form/ErrorEvent.hpp>
+#include <com/sun/star/form/validation/XFormComponentValidityListener.hpp>
+#include <com/sun/star/form/XConfirmDeleteBroadcaster.hpp>
+#include <com/sun/star/form/XConfirmDeleteListener.hpp>
+#include <com/sun/star/form/XDatabaseParameterBroadcaster2.hpp>
+#include <com/sun/star/form/XDatabaseParameterListener.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/form/runtime/XFilterController.hpp>
+#include <com/sun/star/form/XFormControllerListener.hpp>
+#include <com/sun/star/form/XGridControlListener.hpp>
+#include <com/sun/star/form/XLoadListener.hpp>
+#include <com/sun/star/form/XResetListener.hpp>
+#include <com/sun/star/frame/DispatchDescriptor.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
+#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/sdb/XRowSetApproveBroadcaster.hpp>
+#include <com/sun/star/sdb/XRowSetApproveListener.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp>
+#include <com/sun/star/sdb/XSQLErrorListener.hpp>
+#include <com/sun/star/sdbc/XRowSetListener.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/util/XModeSelector.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <com/sun/star/util/XModifyListener.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/stl_types.hxx>
+#include <connectivity/sqlparse.hxx>
+#include <cppuhelper/propshlp.hxx>
+#include <tools/debug.hxx>
+#include <vcl/timer.hxx>
+
+#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22)
+#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22
+#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 22
+#include <comphelper/implbase_var.hxx>
+#endif
+
+struct FmXTextComponentLess : public ::std::binary_function< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent> , sal_Bool>
+{
+ sal_Bool operator() (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& x, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& y) const
+ {
+ return reinterpret_cast<sal_Int64>(x.get()) < reinterpret_cast<sal_Int64>(y.get());
+ }
+};
+
+typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::rtl::OUString, FmXTextComponentLess> FmFilterRow;
+typedef ::std::vector< FmFilterRow > FmFilterRows;
+typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > FmFormControllers;
+
+class FmFormView;
+class Window;
+
+namespace svxform
+{
+ typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > > FilterComponents;
+ class ControlBorderManager;
+ struct FmFieldInfo;
+
+ typedef ::comphelper::WeakComponentImplHelper22 < ::com::sun::star::form::runtime::XFormController
+ , ::com::sun::star::form::runtime::XFilterController
+ , ::com::sun::star::awt::XFocusListener
+ , ::com::sun::star::form::XLoadListener
+ , ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::awt::XTextListener
+ , ::com::sun::star::awt::XItemListener
+ , ::com::sun::star::container::XContainerListener
+ , ::com::sun::star::util::XModifyListener
+ , ::com::sun::star::form::XConfirmDeleteListener
+ , ::com::sun::star::sdb::XSQLErrorListener
+ , ::com::sun::star::sdbc::XRowSetListener
+ , ::com::sun::star::sdb::XRowSetApproveListener
+ , ::com::sun::star::form::XDatabaseParameterListener
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::form::XResetListener
+ , ::com::sun::star::frame::XDispatch
+ , ::com::sun::star::awt::XMouseListener
+ , ::com::sun::star::form::validation::XFormComponentValidityListener
+ , ::com::sun::star::task::XInteractionHandler
+ , ::com::sun::star::form::XGridControlListener
+ , ::com::sun::star::form::runtime::XFeatureInvalidation
+ > FormController_BASE;
+
+ //==================================================================
+ // FormController
+ //==================================================================
+ class ColumnInfoCache;
+ class SAL_DLLPRIVATE FormController :public ::comphelper::OBaseMutex
+ ,public FormController_BASE
+ ,public ::cppu::OPropertySetHelper
+ ,public DispatchInterceptor
+ ,public ::comphelper::OAggregationArrayUsageHelper< FormController >
+ ,public ::svxform::OSQLParserClient
+ {
+ typedef ::std::map < sal_Int16,
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >
+ > DispatcherContainer;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController> m_xTabController;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> m_xActiveControl, m_xCurrentControl;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xModelAsIndex;
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacherManager> m_xModelAsManager;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent;
+ ::comphelper::ComponentContext m_aContext;
+ // Composer used for checking filter conditions
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInteractionHandler;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > m_xContext;
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > m_aControls;
+ ::cppu::OInterfaceContainerHelper
+ m_aActivateListeners,
+ m_aModifyListeners,
+ m_aErrorListeners,
+ m_aDeleteListeners,
+ m_aRowSetApproveListeners,
+ m_aParameterListeners,
+ m_aFilterListeners;
+
+ FmFormControllers m_aChilds;
+ FilterComponents m_aFilterComponents;
+ FmFilterRows m_aFilterRows;
+
+ Timer m_aTabActivationTimer;
+ Timer m_aFeatureInvalidationTimer;
+
+ ::svxform::ControlBorderManager*
+ m_pControlBorderManager;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations >
+ m_xFormOperations;
+ DispatcherContainer m_aFeatureDispatchers;
+ ::std::set< sal_Int16 > m_aInvalidFeatures; // for asynchronous feature invalidation
+
+ ::rtl::OUString m_aMode;
+
+ ::svxform::DelayedEvent m_aLoadEvent;
+ ::svxform::DelayedEvent m_aToggleEvent;
+ ::svxform::DelayedEvent m_aActivationEvent;
+ ::svxform::DelayedEvent m_aDeactivationEvent;
+
+ ::std::auto_ptr< ColumnInfoCache >
+ m_pColumnInfoCache;
+
+ sal_Int32 m_nCurrentFilterPosition; // current level for filtering (or-criteria)
+
+ sal_Bool m_bCurrentRecordModified : 1;
+ sal_Bool m_bCurrentRecordNew : 1;
+ sal_Bool m_bLocked : 1;
+ sal_Bool m_bDBConnection : 1; // Focuslistener nur fuer Datenbankformulare
+ sal_Bool m_bCycle : 1;
+ sal_Bool m_bCanInsert : 1;
+ sal_Bool m_bCanUpdate : 1;
+ sal_Bool m_bCommitLock : 1; // lock the committing of controls see focusGained
+ sal_Bool m_bModified : 1; // ist der Inhalt eines Controls modifiziert ?
+ sal_Bool m_bControlsSorted : 1;
+ sal_Bool m_bFiltering : 1;
+ sal_Bool m_bAttachEvents : 1;
+ sal_Bool m_bDetachEvents : 1;
+ sal_Bool m_bAttemptedHandlerCreation : 1;
+
+ // as we want to intercept dispatches of _all_ controls we're responsible for, and an object implementing
+ // the ::com::sun::star::frame::XDispatchProviderInterceptor interface can intercept only _one_ objects dispatches, we need a helper class
+ DECLARE_STL_VECTOR(DispatchInterceptionMultiplexer*, Interceptors);
+ Interceptors m_aControlDispatchInterceptors;
+
+ public:
+ FormController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB );
+
+ protected:
+ ~FormController();
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL acquire() throw ();
+ virtual void SAL_CALL release() throw ();
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XDispatch
+ virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::container::XChild
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL getParent(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL setParent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Parent) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ // OPropertySetHelper
+ virtual sal_Bool SAL_CALL convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue )
+ throw( ::com::sun::star::lang::IllegalArgumentException );
+
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw( ::com::sun::star::uno::Exception );
+ virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ using OPropertySetHelper::getFastPropertyValue;
+
+ // XFilterController
+ virtual ::sal_Int32 SAL_CALL getFilterComponents() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getDisjunctiveTerms() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addFilterControllerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterControllerListener >& _Listener ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeFilterControllerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterControllerListener >& _Listener ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getFilterComponent( ::sal_Int32 _Component ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getPredicateExpressions() throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendEmptyDisjunctiveTerm() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getActiveTerm() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL hasElements(void) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::container::XEnumerationAccess
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration> SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::container::XContainerListener
+ virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XLoadListener
+ virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XModeSelector
+ virtual void SAL_CALL setMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException );
+ virtual ::rtl::OUString SAL_CALL getMode(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedModes(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::container::XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 Index) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
+
+ // XModifyBroadcaster
+ virtual void SAL_CALL addModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XFocusListener
+ virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XMouseListener
+ virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XFormComponentValidityListener
+ virtual void SAL_CALL componentValidityChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInteractionHandler
+ virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XGridControlListener
+ virtual void SAL_CALL columnChanged( const ::com::sun::star::lang::EventObject& _event ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::beans::XPropertyChangeListener -> aenderung der stati
+ virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTextListener -> modify setzen
+ virtual void SAL_CALL textChanged(const ::com::sun::star::awt::TextEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XItemListener -> modify setzen
+ virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XModifyListener -> modify setzen
+ virtual void SAL_CALL modified(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XFormController
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > SAL_CALL getFormOperations() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addChildController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _ChildController ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > SAL_CALL getContext() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext >& _context ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _interactionHandler ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XTabController
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > SAL_CALL getControls(void) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel>& Model) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel> SAL_CALL getModel() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL setContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer>& Container) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer> SAL_CALL getContainer() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL autoTabOrder() throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL activateTabOrder() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL activateFirst() throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL activateLast() throw( ::com::sun::star::uno::RuntimeException );
+
+ // com::sun::star::sdbc::XRowSetListener
+ virtual void SAL_CALL cursorMoved(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL rowChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL rowSetChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XRowSetApproveListener
+ virtual sal_Bool SAL_CALL approveCursorMove(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL approveRowChange(const ::com::sun::star::sdb::RowChangeEvent& event) throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL approveRowSetChange(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XRowSetApproveBroadcaster
+ virtual void SAL_CALL addRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XSQLErrorBroadcaster
+ virtual void SAL_CALL errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XSQLErrorListener
+ virtual void SAL_CALL addSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XDatabaseParameterBroadcaster2
+ virtual void SAL_CALL addDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XDatabaseParameterBroadcaster
+ virtual void SAL_CALL addParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XDatabaseParameterListener
+ virtual sal_Bool SAL_CALL approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XConfirmDeleteBroadcaster
+ virtual void SAL_CALL addConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XConfirmDeleteListener
+ virtual sal_Bool SAL_CALL confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XServiceInfo
+ virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw(::com::sun::star::uno::RuntimeException);
+
+ // XResetListener
+ virtual sal_Bool SAL_CALL approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XFeatureInvalidation
+ virtual void SAL_CALL invalidateFeatures( const ::com::sun::star::uno::Sequence< ::sal_Int16 >& Features ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL invalidateAllFeatures( ) throw (::com::sun::star::uno::RuntimeException);
+
+// method for registration
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void);
+
+ // comphelper::OPropertyArrayUsageHelper
+ virtual void fillProperties(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps
+ ) const;
+
+ protected:
+ // DispatchInterceptor
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch>
+ interceptedQueryDispatch(
+ const ::com::sun::star::util::URL& aURL,
+ const ::rtl::OUString& aTargetFrameName,
+ sal_Int32 nSearchFlags
+ ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::osl::Mutex* getInterceptorMutex() { return &m_aMutex; }
+
+ /// update all our dispatchers
+ void updateAllDispatchers() const;
+
+ /** disposes all dispatchers in m_aFeatureDispatchers, and empties m_aFeatureDispatchers
+ */
+ void disposeAllFeaturesAndDispatchers() SAL_THROW(());
+
+ void startFiltering();
+ void stopFiltering();
+ void setFilter(::std::vector<FmFieldInfo>&);
+ void startListening();
+ void stopListening();
+
+ /** ensures that we have an interaction handler, if possible
+
+ If an interaction handler was provided at creation time (<member>initialize</member>), this
+ one will be used. Else, an attempt is made to create an <type scope="com::sun::star::sdb">InteractionHandler</type>
+ is made.
+
+ @return <TRUE/>
+ if and only if <member>m_xInteractionHandler</member> is valid when the method returns
+ */
+ bool ensureInteractionHandler();
+
+ /** replaces one of our controls with another one
+
+ Upon successful replacing, the old control will be disposed. Also, internal members pointing
+ to the current or active control will be adjusted. Yet more, if the replaced control was
+ the active control, the new control will be made active.
+
+ @param _rxExistentControl
+ The control to replace. Must be one of the controls in our ControlContainer.
+ @param _rxNewControl
+ The control which should replace the existent control.
+ @return
+ <TRUE/> if and only if the control was successfully replaced
+ */
+ bool replaceControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxExistentControl,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxNewControl
+ );
+
+ // we're listening at all bound controls for modifications
+ void startControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl);
+ void stopControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl);
+
+ void setLocks();
+ void setControlLock(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl);
+ void addToEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl);
+ void removeFromEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl);
+ void toggleAutoFields(sal_Bool bAutoFields);
+ void unload() throw( ::com::sun::star::uno::RuntimeException );
+ void removeBoundFieldListener();
+
+ void startFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly );
+ void stopFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> findControl( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> >& rCtrls, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& rxCtrlModel, sal_Bool _bRemove, sal_Bool _bOverWrite ) const;
+
+ void insertControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl);
+ void removeControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl);
+
+ /// called when a new control is to be handled by the controller
+ void implControlInserted( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bAddToEventAttacher );
+ /// called when a control is not to be handled by the controller anymore
+ void implControlRemoved( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bRemoveFromEventAttacher );
+
+ /** sets m_xCurrentControl, plus does administrative tasks depending on it
+ */
+ void implSetCurrentControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl );
+
+ /** invalidates the FormFeatures which depend on the current control
+ */
+ void implInvalidateCurrentControlDependentFeatures();
+
+ bool impl_isDisposed_nofail() const { return FormController_BASE::rBHelper.bDisposed; }
+ void impl_checkDisposed_throw() const;
+
+ void impl_onModify();
+
+ /** adds the given filter row to m_aFilterRows, setting m_nCurrentFilterPosition to 0 if the newly added
+ row is the first one.
+
+ @precond
+ our mutex is locked
+ */
+ void impl_addFilterRow( const FmFilterRow& _row );
+
+ /** adds an empty filter row to m_aFilterRows, and notifies our listeners
+ */
+ void impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify );
+
+ sal_Bool isLocked() const {return m_bLocked;}
+ sal_Bool determineLockState() const;
+
+ Window* getDialogParentWindow();
+ // returns the window which should be used as parent window for dialogs
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor> createInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception);
+ // create a new interceptor, register it on the given object
+ void deleteInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception);
+ // if createInterceptor was called for the given object the according interceptor will be removed
+ // from the objects interceptor chain and released
+
+ /** checks all form controls belonging to our form for validity
+
+ If a form control supports the XValidatableFormComponent interface, this is used to determine
+ the validity of the control. If the interface is not supported, the control is supposed to be
+ valid.
+
+ @param _rFirstInvalidityExplanation
+ if the method returns <FALSE/> (i.e. if there is an invalid control), this string contains
+ the explanation for the invalidity, as obtained from the validator.
+
+ @param _rxFirstInvalidModel
+ if the method returns <FALSE/> (i.e. if there is an invalid control), this contains
+ the control model
+
+ @return
+ <TRUE/> if and only if all controls belonging to our form are valid
+ */
+ bool checkFormComponentValidity(
+ ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation,
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& /* [out] */ _rxFirstInvalidModel
+ ) SAL_THROW(());
+
+ /** locates the control which belongs to a given model
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >
+ locateControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ) SAL_THROW(());
+
+ // set the text for all filters
+ void impl_setTextOnAllFilter_throw();
+
+ // in filter mode we do not listen for changes
+ sal_Bool isListeningForChanges() const {return m_bDBConnection && !m_bFiltering && !isLocked();}
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> isInList(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& xPeer) const;
+
+ DECL_LINK( OnActivateTabOrder, void* );
+ DECL_LINK( OnInvalidateFeatures, void* );
+ DECL_LINK( OnLoad, void* );
+ DECL_LINK( OnToggleAutoFields, void* );
+ DECL_LINK( OnActivated, void* );
+ DECL_LINK( OnDeactivated, void* );
+ };
+
+} // namespace svxform
+
+#endif // _SVX_FMCTRLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/formcontrolling.hxx b/svx/source/inc/formcontrolling.hxx
new file mode 100644
index 000000000000..f334e30169e4
--- /dev/null
+++ b/svx/source/inc/formcontrolling.hxx
@@ -0,0 +1,311 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_FORMCONTROLLING_HXX
+#define SVX_FORMCONTROLLING_HXX
+
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/form/runtime/FeatureState.hpp>
+#include <com/sun/star/form/runtime/XFormOperations.hpp>
+#include <com/sun/star/sdb/XSQLErrorListener.hpp>
+
+#include <cppuhelper/implbase2.hxx>
+#include <comphelper/componentcontext.hxx>
+
+#include <vector>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ //====================================================================
+ //= FeatureSlotTranslation
+ //====================================================================
+ class FeatureSlotTranslation
+ {
+ public:
+ /// retrieves the feature id for a given feature URL
+ static sal_Int32 getControllerFeatureSlotIdForURL( const ::rtl::OUString& _rMainURL );
+
+ /// retrieves the feature URL for a given feature id
+ static ::rtl::OUString getControllerFeatureURLForSlotId( sal_Int32 _nSlotId );
+
+ /// determines whether the given URL is a controller feature URL
+ static sal_Bool isFeatureURL( const ::rtl::OUString& _rMainURL );
+
+ /// retrieves the css.form.runtime.FormFeature ID for a given slot ID
+ static sal_Int16 getFormFeatureForSlotId( sal_Int32 _nSlotId );
+
+ /// retrieves the slot id for a given css.form.runtime.FormFeature ID
+ static sal_Int32 getSlotIdForFormFeature( sal_Int16 _nFormFeature );
+ };
+
+ //====================================================================
+ //= IControllerFeatureInvalidation
+ //====================================================================
+ class IControllerFeatureInvalidation
+ {
+ public:
+ /** invalidates the given features
+
+ Invalidation means that any user interface representation (such as toolbox buttons), or
+ any dispatches associated with the features in question are potentially out-of-date, and
+ need to be updated
+
+ @param _rFeatures
+ Ids of the features to be invalidated.
+ */
+ virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ) = 0;
+ };
+
+ //====================================================================
+ //= ControllerFeatures
+ //====================================================================
+ class FormControllerHelper;
+ /** easier access to an FormControllerHelper instance
+ */
+ class ControllerFeatures
+ {
+ protected:
+ ::comphelper::ComponentContext m_aContext;
+ IControllerFeatureInvalidation* m_pInvalidationCallback; // necessary as long as m_pImpl is not yet constructed
+ FormControllerHelper* m_pImpl;
+
+ public:
+ /** standard ctor
+
+ The instance is not functional until <method>assign</method> is used.
+
+ @param _rxORB
+ a multi service factory for creating various needed components
+
+ @param _pInvalidationCallback
+ the callback for invalidating feature states
+ */
+ ControllerFeatures(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ IControllerFeatureInvalidation* _pInvalidationCallback
+ );
+
+ /** constructs the instance from a <type scope="com::sun::star::form::runtime">XFormController<type> instance
+
+ @param _rxORB
+ a multi service factory for creating various needed components
+
+ @param _rxController
+ The form controller which the helper should be responsible for. Must not
+ be <NULL/>, and must have a valid model (form).
+
+ @param _pInvalidationCallback
+ the callback for invalidating feature states
+ */
+ ControllerFeatures(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController,
+ IControllerFeatureInvalidation* _pInvalidationCallback
+ );
+
+ /** constructs the helper form a <type scope="com::sun::star::form">XForm<type> instance
+
+ Any functionality which depends on a controller will not be available.
+
+ @param _rxORB
+ a multi service factory for creating various needed components
+
+ @param _rxForm
+ The form which the helper should be responsible for. Must not be <NULL/>.
+
+ @param _pInvalidationCallback
+ the callback for invalidating feature states
+ */
+ ControllerFeatures(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm,
+ IControllerFeatureInvalidation* _pInvalidationCallback
+ );
+
+ /// dtor
+ ~ControllerFeatures();
+
+ /// checks whether the instance is properly assigned to a form and/or controller
+ inline bool isAssigned( ) const { return m_pImpl != NULL; }
+
+ /** assign to a controller
+ */
+ void assign(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController
+ );
+
+ /** assign to a controller
+ */
+ void assign(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm
+ );
+
+ /// clears the instance so that it cannot be used afterwards
+ void dispose();
+
+ // access to the instance which implements the functionality. Not to be used when not assigned
+ inline const FormControllerHelper* operator->() const { return m_pImpl; }
+ inline FormControllerHelper* operator->() { return m_pImpl; }
+ inline const FormControllerHelper& operator*() const { return *m_pImpl; }
+ inline FormControllerHelper& operator*() { return *m_pImpl; }
+ };
+
+ //====================================================================
+ //= FormControllerHelper
+ //====================================================================
+ typedef ::cppu::WeakImplHelper2 < ::com::sun::star::form::runtime::XFeatureInvalidation
+ , ::com::sun::star::sdb::XSQLErrorListener
+ > FormControllerHelper_Base;
+ /** is a helper class which manages form controller functionality (such as moveNext etc.).
+
+ <p>The class helps implementing form controller functionality, by providing
+ methods to determine the state of, and execute, various common form features.<br/>
+ A <em>feature</em> is for instance moving the form associated with the controller
+ to a certain position, or reloading the form, and so on.</p>
+ */
+ class FormControllerHelper : public FormControllerHelper_Base
+ {
+ protected:
+ ::comphelper::ComponentContext m_aContext;
+ IControllerFeatureInvalidation* m_pInvalidationCallback;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations >
+ m_xFormOperations;
+
+ ::com::sun::star::uno::Any m_aOperationError;
+
+ public:
+ /** constructs the helper from a <type scope="com::sun::star::form::runtime">XFormController<type> instance
+
+ @param _rContext
+ the context the component lives in
+ @param _rxController
+ The form controller which the helper should be responsible for. Must not
+ be <NULL/>, and must have a valid model (form).
+ @param _pInvalidationCallback
+ the callback for invalidating feature states
+ */
+ FormControllerHelper(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController,
+ IControllerFeatureInvalidation* _pInvalidationCallback
+ );
+
+ /** constructs the helper form a <type scope="com::sun::star::form">XForm<type> instance
+
+ Any functionality which depends on a controller will not be available.
+
+ @param _rContext
+ the context the component lives in
+ @param _rxForm
+ The form which the helper should be responsible for. Must not be <NULL/>.
+ @param _pInvalidationCallback
+ the callback for invalidating feature states
+ */
+ FormControllerHelper(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm,
+ IControllerFeatureInvalidation* _pInvalidationCallback
+ );
+
+ // forwards to the XFormOperations implementation
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >
+ getCursor() const;
+ void getState(
+ sal_Int32 _nSlotId,
+ ::com::sun::star::form::runtime::FeatureState& _out_rState
+ ) const;
+ sal_Bool isEnabled( sal_Int32 _nSlotId ) const;
+ void execute( sal_Int32 _nSlotId ) const;
+ void execute( sal_Int32 _nSlotId, const ::rtl::OUString& _rParamName, const ::com::sun::star::uno::Any& _rParamValue ) const;
+ sal_Bool commitCurrentRecord() const;
+ sal_Bool commitCurrentControl( ) const;
+ sal_Bool isInsertionRow() const;
+ sal_Bool isModifiedRow() const;
+
+ bool moveLeft( ) const;
+ bool moveRight( ) const;
+
+ bool canDoFormFilter() const;
+
+ /** disposes this instance.
+
+ After this method has been called, the instance is not functional anymore
+ */
+ void dispose();
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations >&
+ getFormOperations() const { return m_xFormOperations; }
+ protected:
+ /// dtor
+ ~FormControllerHelper();
+
+ // XFeatureInvalidation
+ virtual void SAL_CALL invalidateFeatures( const ::com::sun::star::uno::Sequence< ::sal_Int16 >& Features ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL invalidateAllFeatures() throw (::com::sun::star::uno::RuntimeException);
+
+ // XSQLErrorListener
+ virtual void SAL_CALL errorOccured( const ::com::sun::star::sdb::SQLErrorEvent& _Event ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ enum FormOperation { EXECUTE, EXECUTE_ARGS, COMMIT_CONTROL, COMMIT_RECORD };
+
+ bool impl_operateForm_nothrow(
+ const FormOperation _eWhat,
+ const sal_Int16 _nFeature, /* ignore for COMMIT_* */
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rArguments /* ignore except for EXECUTE_ARGS */
+ ) const;
+ bool impl_operateForm_nothrow( const FormOperation _eWhat ) const
+ {
+ return impl_operateForm_nothrow( _eWhat, 0, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >() );
+ }
+ bool impl_operateForm_nothrow( const sal_Int16 _nFeature ) const
+ {
+ return impl_operateForm_nothrow( EXECUTE, _nFeature, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >() );
+ }
+
+ private:
+ FormControllerHelper(); // never implemented
+ FormControllerHelper( const FormControllerHelper& ); // never implemented
+ FormControllerHelper& operator=( const FormControllerHelper& ); // never implemented
+ };
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+#endif // SVX_FORMCONTROLLING_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/formdispatchinterceptor.hxx b/svx/source/inc/formdispatchinterceptor.hxx
new file mode 100644
index 000000000000..4fbaf657b7f3
--- /dev/null
+++ b/svx/source/inc/formdispatchinterceptor.hxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * 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 SVX_FORMDISPATCHINTERCEPTOR_HXX
+#define SVX_FORMDISPATCHINTERCEPTOR_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
+#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/compbase2.hxx>
+#include <comphelper/uno3.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= DispatchInterceptor
+ //====================================================================
+ class DispatchInterceptor
+ {
+ public:
+ DispatchInterceptor() { }
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> interceptedQueryDispatch(
+ const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException ) = 0;
+
+ virtual ::osl::Mutex* getInterceptorMutex() = 0;
+ };
+
+ //====================================================================
+ //=
+ //====================================================================
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::frame::XDispatchProviderInterceptor
+ , ::com::sun::star::lang::XEventListener
+ > DispatchInterceptionMultiplexer_BASE;
+
+ class DispatchInterceptionMultiplexer : public DispatchInterceptionMultiplexer_BASE
+ {
+ ::osl::Mutex m_aFallback;
+ ::osl::Mutex* m_pMutex;
+
+ // the component which's dispatches we're intercepting
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProviderInterception >
+ m_xIntercepted;
+ sal_Bool m_bListening;
+
+ // the real interceptor
+ DispatchInterceptor* m_pMaster;
+
+ // chaining
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xSlaveDispatcher;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xMasterDispatcher;
+
+ virtual ~DispatchInterceptionMultiplexer();
+
+ public:
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception> getIntercepted() const { return m_xIntercepted; }
+
+ public:
+ DispatchInterceptionMultiplexer(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _rToIntercept,
+ DispatchInterceptor* _pMaster
+ );
+
+ // UNO
+ DECLARE_UNO3_DEFAULTS(DispatchInterceptionMultiplexer, DispatchInterceptionMultiplexer_BASE);
+
+ // ::com::sun::star::frame::XDispatchProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::frame::XDispatchProviderInterceptor
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewDispatchProvider ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSupplier ) throw(::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ protected:
+ void ImplDetach();
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_FORMDISPATCHINTERCEPTOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/formfeaturedispatcher.hxx b/svx/source/inc/formfeaturedispatcher.hxx
new file mode 100644
index 000000000000..a042924fdf78
--- /dev/null
+++ b/svx/source/inc/formfeaturedispatcher.hxx
@@ -0,0 +1,160 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_FMDISPATCH_HXX
+#define SVX_FMDISPATCH_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/form/runtime/XFormOperations.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ //====================================================================
+ //= OSingleFeatureDispatcher
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::frame::XDispatch
+ > OSingleFeatureDispatcher_Base;
+
+ class OSingleFeatureDispatcher : public OSingleFeatureDispatcher_Base
+ {
+ private:
+ ::osl::Mutex& m_rMutex;
+ ::cppu::OInterfaceContainerHelper m_aStatusListeners;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations >
+ m_xFormOperations;
+ const ::com::sun::star::util::URL m_aFeatureURL;
+ ::com::sun::star::uno::Any m_aLastKnownState;
+ const sal_Int16 m_nFormFeature;
+ sal_Bool m_bLastKnownEnabled;
+ sal_Bool m_bDisposed;
+
+ public:
+ /** constructs the dispatcher
+
+ @param _rFeatureURL
+ the URL of the feature which this instance is responsible for
+
+ @param _nFeatureId
+ the feature which this instance is responsible for
+
+ @param _rController
+ the controller which is responsible for providing the state of feature of this instance,
+ and for executing it. After disposing the dispatcher instance, the controller will
+ not be accessed anymore
+
+ @see dispose
+ */
+ OSingleFeatureDispatcher(
+ const ::com::sun::star::util::URL& _rFeatureURL,
+ const sal_Int16 _nFormFeature,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations >& _rxFormOperations,
+ ::osl::Mutex& _rMutex
+ );
+
+ /** disposes the dispatcher instance
+
+ All status listeners will, after receiving an <member scope="com::sun::star::lang">XEventListener::disposing</member>
+ call, be released.
+
+ The controller provided in the in constructor will not be used anymore after returning from this call.
+
+ No further requests to dispatch slots will be accepted.
+
+ Multiple calls are allowed: if the object already was disposed, then subsequent calls are
+ silently ignored.
+ */
+ void dispose();
+
+ /** notifies all our listeners of the current state
+ */
+ void updateAllListeners();
+
+ protected:
+ // XDispatch
+ virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArguments ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxControl, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxControl, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ /** notifies our current state to one or all listeners
+
+ @param _rxListener
+ the listener to notify. May be NULL, in this case all our listeners will be
+ notified with the current state
+
+ @param _rFreeForNotification
+ a guard which currently locks our mutex, and which is to be cleared
+ for actually doing the notification(s)
+ */
+ void notifyStatus(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener,
+ ::osl::ClearableMutexGuard& _rFreeForNotification
+ );
+
+ private:
+ /** checks whether our instance is alive
+
+ If the instance already received a <member>dispose</member> call, then a
+ <type scope="com::sun::star::lang">DisposedException</type> is thrown.
+
+ @precond
+ our Mutex is locked - else calling the method would not make sense, since
+ it's result could be out-of-date as soon as it's returned to the caller.
+ */
+ void checkAlive() const SAL_THROW((::com::sun::star::lang::DisposedException));
+
+ /** retrieves the current status of our feature, in a format which can be used
+ for UNO notifications
+
+ @precond
+ our mutex is locked
+ */
+ void getUnoState( ::com::sun::star::frame::FeatureStateEvent& /* [out] */ _rState ) const;
+
+ private:
+ OSingleFeatureDispatcher(); // never implemented
+ OSingleFeatureDispatcher( const OSingleFeatureDispatcher& ); // never implemented
+ OSingleFeatureDispatcher& operator=( const OSingleFeatureDispatcher& ); // never implemented
+ };
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/formtoolbars.hxx b/svx/source/inc/formtoolbars.hxx
new file mode 100644
index 000000000000..29900e4d1d88
--- /dev/null
+++ b/svx/source/inc/formtoolbars.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_SOURCE_INC_FORMTOOLBARS_HXX
+#define SVX_SOURCE_INC_FORMTOOLBARS_HXX
+
+#include "fmdocumentclassification.hxx"
+#include <com/sun/star/frame/XLayoutManager.hpp>
+
+#include <tools/solar.h>
+
+#include <svx/svxdllapi.h>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= FormToolboxes
+ //====================================================================
+ class FormToolboxes
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >
+ m_xLayouter;
+
+ public:
+ /** constructs an instance
+ @param _rxFrame
+ the frame to analyze
+ */
+ SVX_DLLPUBLIC FormToolboxes(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _rxFrame
+ );
+
+ public:
+ /** retrieves the URI for the toolbox associated with the given slot, depending
+ on the type of our document
+ */
+ SVX_DLLPUBLIC ::rtl::OUString
+ getToolboxResourceName( USHORT _nSlotId ) const;
+
+ /** toggles the toolbox associated with the given slot
+ */
+ SVX_DLLPUBLIC void toggleToolbox( USHORT _nSlotId ) const;
+
+ /** determines whether the toolbox associated with the given slot is currently visible
+ */
+ SVX_DLLPUBLIC bool isToolboxVisible( USHORT _nSlotId ) const;
+
+ /** ensures that a given toolbox is visible
+ */
+ inline void showToolbox( USHORT _SlotId ) const
+ {
+ if ( !isToolboxVisible( _SlotId ) )
+ toggleToolbox( _SlotId );
+ }
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_SOURCE_INC_FORMTOOLBARS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/frmsel.hrc b/svx/source/inc/frmsel.hrc
new file mode 100644
index 000000000000..fb6597c6f51d
--- /dev/null
+++ b/svx/source/inc/frmsel.hrc
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * 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 SVX_FRMSEL_HRC
+#define SVX_FRMSEL_HRC
+
+#define ARR_TEXTS 1
+#define ARR_DESCRIPTIONS 2
+
+// image: arrows and markers
+#define BMP_FRMSEL_ARROWS 3
+
+#endif
+
diff --git a/svx/source/inc/frmselimpl.hxx b/svx/source/inc/frmselimpl.hxx
new file mode 100644
index 000000000000..f804560a21f7
--- /dev/null
+++ b/svx/source/inc/frmselimpl.hxx
@@ -0,0 +1,307 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_FRMSELIMPL_HXX
+#define SVX_FRMSELIMPL_HXX
+
+#include <vcl/virdev.hxx>
+#include <vcl/image.hxx>
+#include <svx/frmsel.hxx>
+#include <svx/framelinkarray.hxx>
+#include <editeng/borderline.hxx>
+
+namespace svx {
+
+namespace a11y { class AccFrameSelector; }
+
+// ============================================================================
+
+class FrameBorder
+{
+public:
+ explicit FrameBorder( FrameBorderType eType );
+
+ inline FrameBorderType GetType() const { return meType; }
+
+ inline bool IsEnabled() const { return mbEnabled; }
+ void Enable( FrameSelFlags nFlags );
+
+ inline FrameBorderState GetState() const { return meState; }
+ void SetState( FrameBorderState eState );
+
+ inline bool IsSelected() const { return mbSelected; }
+ inline void Select( bool bSelect ) { mbSelected = bSelect; }
+
+ const SvxBorderLine& GetCoreStyle() const { return maCoreStyle; }
+ void SetCoreStyle( const SvxBorderLine* pStyle );
+
+ inline void SetUIColor( const Color& rColor ) {maUIStyle.SetColor( rColor ); }
+ inline const frame::Style& GetUIStyle() const { return maUIStyle; }
+
+ inline void ClearFocusArea() { maFocusArea.Clear(); }
+ void AddFocusPolygon( const Polygon& rFocus );
+ void MergeFocusToPolyPolygon( PolyPolygon& rPPoly ) const;
+
+ inline void ClearClickArea() { maClickArea.Clear(); }
+ void AddClickRect( const Rectangle& rRect );
+ bool ContainsClickPoint( const Point& rPos ) const;
+ void MergeClickAreaToPolyPolygon( PolyPolygon& rPPoly ) const;
+ Rectangle GetClickBoundRect() const;
+
+ void SetKeyboardNeighbors(
+ FrameBorderType eLeft, FrameBorderType eRight,
+ FrameBorderType eTop, FrameBorderType eBottom );
+ FrameBorderType GetKeyboardNeighbor( USHORT nKeyCode ) const;
+
+private:
+ const FrameBorderType meType; /// Frame border type (position in control).
+ FrameBorderState meState; /// Frame border state (on/off/don't care).
+ SvxBorderLine maCoreStyle; /// Core style from application.
+ frame::Style maUIStyle; /// Internal style to draw lines.
+ FrameBorderType meKeyLeft; /// Left neighbor for keyboard control.
+ FrameBorderType meKeyRight; /// Right neighbor for keyboard control.
+ FrameBorderType meKeyTop; /// Upper neighbor for keyboard control.
+ FrameBorderType meKeyBottom; /// Lower neighbor for keyboard control.
+ PolyPolygon maFocusArea; /// Focus drawing areas.
+ PolyPolygon maClickArea; /// Mouse click areas.
+ bool mbEnabled; /// true = Border enabled in control.
+ bool mbSelected; /// true = Border selected in control.
+};
+
+// ============================================================================
+
+typedef std::vector< FrameBorder* > FrameBorderPtrVec;
+
+struct FrameSelectorImpl : public Resource
+{
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible > XAccessibleRef;
+ typedef std::vector< a11y::AccFrameSelector* > AccessibleImplVec;
+ typedef std::vector< XAccessibleRef > XAccessibleRefVec;
+
+ FrameSelector& mrFrameSel; /// The control itself.
+ VirtualDevice maVirDev; /// For all buffered drawing operations.
+ ImageList maILArrows; /// Arrows in current system colors.
+ Color maBackCol; /// Background color.
+ Color maArrowCol; /// Selection arrow color.
+ Color maMarkCol; /// Selection marker color.
+ Color maHCLineCol; /// High contrast line color.
+ Point maVirDevPos; /// Position of virtual device in the control.
+ Point maMousePos; /// Last mouse pointer position.
+
+ FrameBorder maLeft; /// All data of left frame border.
+ FrameBorder maRight; /// All data of right frame border.
+ FrameBorder maTop; /// All data of top frame border.
+ FrameBorder maBottom; /// All data of bottom frame border.
+ FrameBorder maHor; /// All data of inner horizontal frame border.
+ FrameBorder maVer; /// All data of inner vertical frame border.
+ FrameBorder maTLBR; /// All data of top-left to bottom-right frame border.
+ FrameBorder maBLTR; /// All data of bottom-left to top-right frame border.
+ SvxBorderLine maCurrStyle; /// Current style and color for new borders.
+ frame::Array maArray; /// Frame link array to draw an array of frame borders.
+
+ FrameSelFlags mnFlags; /// Flags for enabled frame borders.
+ FrameBorderPtrVec maAllBorders; /// Pointers to all frame borders.
+ FrameBorderPtrVec maEnabBorders; /// Pointers to enables frame borders.
+ Link maSelectHdl; /// Selection handler.
+
+ long mnCtrlSize; /// Size of the control (always square).
+ long mnArrowSize; /// Size of an arrow image.
+ long mnLine1; /// Middle of left/top frame borders.
+ long mnLine2; /// Middle of inner frame borders.
+ long mnLine3; /// Middle of right/bottom frame borders.
+ long mnFocusOffs; /// Offset from frame border middle to draw focus.
+
+ bool mbHor; /// true = Inner horizontal frame border enabled.
+ bool mbVer; /// true = Inner vertical frame border enabled.
+ bool mbTLBR; /// true = Top-left to bottom-right frame border enabled.
+ bool mbBLTR; /// true = Bottom-left to top-right frame border enabled.
+ bool mbFullRepaint; /// Used for repainting (false = only copy virtual device).
+ bool mbAutoSelect; /// true = Auto select a frame border, if focus reaches control.
+ bool mbClicked; /// true = The control has been clicked at least one time.
+ bool mbHCMode; /// true = High contrast mode.
+
+ a11y::AccFrameSelector* mpAccess; /// Pointer to accessibility object of the control.
+ XAccessibleRef mxAccess; /// Reference to accessibility object of the control.
+ AccessibleImplVec maChildVec; /// Pointers to accessibility objects for frame borders.
+ XAccessibleRefVec mxChildVec; /// References to accessibility objects for frame borders.
+
+ explicit FrameSelectorImpl( FrameSelector& rFrameSel );
+ ~FrameSelectorImpl();
+
+ // initialization ---------------------------------------------------------
+
+ /** Initializes the control, enables/disables frame borders according to flags. */
+ void Initialize( FrameSelFlags nFlags );
+
+ /** Fills all color members from current style settings. */
+ void InitColors();
+ /** Creates the image list with selection arrows regarding current style settings. */
+ void InitArrowImageList();
+ /** Initializes global coordinates. */
+ void InitGlobalGeometry();
+ /** Initializes coordinates of all frame borders. */
+ void InitBorderGeometry();
+ /** Initializes click areas of all enabled frame borders. */
+ void InitClickAreas();
+ /** Draws the entire control into the internal virtual device. */
+ void InitVirtualDevice();
+
+ // frame border access ----------------------------------------------------
+
+ /** Returns the object representing the specified frame border. */
+ const FrameBorder& GetBorder( FrameBorderType eBorder ) const;
+ /** Returns the object representing the specified frame border (write access). */
+ FrameBorder& GetBorderAccess( FrameBorderType eBorder );
+
+ // drawing ----------------------------------------------------------------
+
+ /** Draws the background of the entire control (the gray areas between borders). */
+ void DrawBackground();
+
+ /** Draws selection arrows for the specified frame border. */
+ void DrawArrows( const FrameBorder& rBorder );
+ /** Draws arrows in current selection state for all enabled frame borders. */
+ void DrawAllArrows();
+
+ /** Returns the color that has to be used to draw a frame border. */
+ Color GetDrawLineColor( const Color& rColor ) const;
+ /** Draws all frame borders. */
+ void DrawAllFrameBorders();
+
+ /** Draws all contents of the control. */
+ void DrawVirtualDevice();
+ /** Copies contents of the virtual device to the control. */
+ void CopyVirDevToControl();
+
+ /** Draws tracking rectangles for all selected frame borders. */
+ void DrawAllTrackingRects();
+
+ /** Converts a mouse position to the virtual device position. */
+ Point GetDevPosFromMousePos( const Point& rMousePos ) const;
+
+ /** Invalidates the control.
+ @param bFullRepaint true = Full repaint; false = update selection only. */
+ void DoInvalidate( bool bFullRepaint );
+
+ // frame border state and style -------------------------------------------
+
+ /** Sets the state of the specified frame border. */
+ void SetBorderState( FrameBorder& rBorder, FrameBorderState eState );
+ /** Sets the core style of the specified frame border, or hides the frame border, if pStyle is 0. */
+ void SetBorderCoreStyle( FrameBorder& rBorder, const SvxBorderLine* pStyle );
+ /** Sets the color of the specified frame border. */
+ void SetBorderColor( FrameBorder& rBorder, const Color& rColor );
+
+ /** Changes the state of a frame border after a control event (mouse/keyboard). */
+ void ToggleBorderState( FrameBorder& rBorder );
+
+ // frame border selection -------------------------------------------------
+
+ /** Selects a frame border and schedules redraw. */
+ void SelectBorder( FrameBorder& rBorder, bool bSelect );
+ /** Grabs focus without auto-selection of a frame border, if no border selected. */
+ void SilentGrabFocus();
+
+ /** Returns true, if all selected frame borders are equal (or if nothing is selected). */
+ bool SelectedBordersEqual() const;
+};
+
+// ============================================================================
+
+/** Dummy predicate for frame border iterators to use all borders in a container. */
+struct FrameBorderDummy_Pred
+{
+ inline bool operator()( const FrameBorder* ) const { return true; }
+};
+
+/** Predicate for frame border iterators to use only visible borders in a container. */
+struct FrameBorderVisible_Pred
+{
+ inline bool operator()( const FrameBorder* pBorder ) const { return pBorder->GetState() == FRAMESTATE_SHOW; }
+};
+
+/** Predicate for frame border iterators to use only selected borders in a container. */
+struct FrameBorderSelected_Pred
+{
+ inline bool operator()( const FrameBorder* pBorder ) const { return pBorder->IsSelected(); }
+};
+
+/** Template class for all types of frame border iterators. */
+template< typename Cont, typename Iter, typename Pred >
+class FrameBorderIterBase
+{
+public:
+ typedef Cont container_type;
+ typedef Iter iterator_type;
+ typedef Pred predicate_type;
+ typedef typename Cont::value_type value_type;
+ typedef FrameBorderIterBase< Cont, Iter, Pred > this_type;
+
+ explicit FrameBorderIterBase( container_type& rCont );
+ inline bool Is() const { return maIt != maEnd; }
+ this_type& operator++();
+ inline value_type operator*() const { return *maIt; }
+
+private:
+ iterator_type maIt;
+ iterator_type maEnd;
+ predicate_type maPred;
+};
+
+/** Iterator for constant svx::FrameBorder containers, iterates over all borders. */
+typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderDummy_Pred >
+ FrameBorderCIter;
+
+/** Iterator for mutable svx::FrameBorder containers, iterates over all borders. */
+typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderDummy_Pred >
+ FrameBorderIter;
+
+/** Iterator for constant svx::FrameBorder containers, iterates over visible borders. */
+typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderVisible_Pred >
+ VisFrameBorderCIter;
+
+/** Iterator for mutable svx::FrameBorder containers, iterates over visible borders. */
+typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderVisible_Pred >
+ VisFrameBorderIter;
+
+/** Iterator for constant svx::FrameBorder containers, iterates over selected borders. */
+typedef FrameBorderIterBase< const FrameBorderPtrVec, FrameBorderPtrVec::const_iterator, FrameBorderSelected_Pred >
+ SelFrameBorderCIter;
+
+/** Iterator for mutable svx::FrameBorder containers, iterates over selected borders. */
+typedef FrameBorderIterBase< FrameBorderPtrVec, FrameBorderPtrVec::iterator, FrameBorderSelected_Pred >
+ SelFrameBorderIter;
+
+// ============================================================================
+
+} // namespace svx
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
new file mode 100644
index 000000000000..1f7fad2cc455
--- /dev/null
+++ b/svx/source/inc/gridcell.hxx
@@ -0,0 +1,1158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_GRIDCELL_HXX
+#define _SVX_GRIDCELL_HXX
+
+#include <svx/gridctrl.hxx>
+
+#include "sqlparserclient.hxx"
+#include "typeconversionclient.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/form/XBoundControl.hpp>
+#include <com/sun/star/awt/XTextComponent.hpp>
+#include <com/sun/star/awt/XListBox.hpp>
+#include <com/sun/star/awt/XComboBox.hpp>
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XCheckBox.hpp>
+#include <com/sun/star/awt/XButton.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/form/XChangeBroadcaster.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/propmultiplex.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/component.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/rtti.hxx>
+
+class DbCellControl;
+class Edit;
+class FmXGridCell;
+
+//==================================================================
+// FmMutexHelper
+//==================================================================
+class FmMutexHelper
+{
+protected:
+ ::osl::Mutex m_aMutex;
+};
+
+//==================================================================
+// DbGridColumn, Spaltenbeschreibung
+//==================================================================
+class DbGridColumn
+{
+ friend class DbGridControl;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xField; // Verbindung zum Datenbankfeld
+ ::svt::CellControllerRef m_xController; // Struktur zum Verwalten der Controls fuer eine Spalte
+ // diese wird von der DbBrowseBox auf die jeweiligen Zellen
+ // einer Spalte positioniert
+ FmXGridCell* m_pCell;
+
+protected:
+ DbGridControl& m_rParent;
+
+private:
+ sal_Int32 m_nLastVisibleWidth; // nur gueltig, wenn m_bHidden == sal_True
+ sal_Int32 m_nFormatKey;
+ sal_Int16 m_nFieldType;
+ sal_Int16 m_nTypeId;
+ sal_uInt16 m_nId;
+ sal_Int16 m_nFieldPos;
+ sal_Int16 m_nAlign; // wird mit TXT_ALIGN_LEFT .... angegeben
+ sal_Bool m_bReadOnly : 1;
+ sal_Bool m_bAutoValue : 1;
+ sal_Bool m_bInSave : 1;
+ sal_Bool m_bNumeric : 1;
+ sal_Bool m_bObject : 1; // Verweist die Column auf ein Object Datentyp?
+ sal_Bool m_bHidden : 1;
+ sal_Bool m_bLocked : 1;
+ sal_Bool m_bDateTime : 1;
+
+ static ::svt::CellControllerRef s_xEmptyController;
+ // used by locked columns
+public:
+ DbGridColumn(sal_uInt16 _nId, DbGridControl& rParent)
+ :m_pCell(NULL)
+ ,m_rParent(rParent)
+ ,m_nLastVisibleWidth(-1)
+ ,m_nFormatKey(0)
+ ,m_nFieldType(0)
+ ,m_nTypeId(0)
+ ,m_nId(_nId)
+ ,m_nFieldPos(-1)
+ ,m_nAlign(::com::sun::star::awt::TextAlign::LEFT)
+ ,m_bReadOnly(sal_False)
+ ,m_bAutoValue(sal_False)
+ ,m_bInSave(sal_False)
+ ,m_bNumeric(sal_False)
+ ,m_bObject(sal_False)
+ ,m_bHidden(sal_False)
+ ,m_bLocked(sal_False)
+ ,m_bDateTime(sal_False)
+ {
+ }
+
+ ~DbGridColumn();
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& getModel() const { return m_xModel; }
+ void setModel(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xModel);
+
+
+ sal_uInt16 GetId() const {return m_nId;}
+ sal_Bool IsReadOnly() const {return m_bReadOnly;}
+ sal_Bool IsAutoValue() const {return m_bAutoValue;}
+ sal_Bool IsUpdating() const {return m_bInSave;}
+ sal_Int16 GetAlignment() const {return m_nAlign;}
+ sal_Int16 GetType() const {return m_nFieldType;}
+ sal_Int16 GetFieldPos() const {return m_nFieldPos; }
+ sal_Bool IsNumeric() const {return m_bNumeric;}
+ sal_Bool IsDateTime() const {return m_bDateTime;}
+ sal_Bool IsObject() const {return m_bObject;}
+ sal_Bool IsHidden() const {return m_bHidden;}
+ sal_Int32 GetKey() const {return m_nFormatKey;}
+ const ::svt::CellControllerRef& GetController() const {return m_bLocked ? s_xEmptyController : m_xController;}
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& GetField() const {return m_xField;}
+ DbGridControl& GetParent() const {return m_rParent;}
+ FmXGridCell* GetCell() const {return m_pCell;}
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn > GetCurrentFieldValue() const;
+
+ // Zeichnen eines Feldes an einer Position, ist ein ::com::sun::star::sdbcx::View gesetzt
+ // uebernimmt dieser das Zeichnen, z.B. fuer CheckBoxen
+ void Paint(OutputDevice& rDev,
+ const Rectangle& rRect,
+ const DbGridRow* pRow,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+
+
+ // Inititialierung im alive mode
+ // Ist kein ColumnController gesetzt, wird eine DefaultInitialisierung
+ // vorgenommen
+ void CreateControl(sal_Int32 _nFieldPos, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xField, sal_Int32 nTypeId);
+ void UpdateControl()
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xField(m_xField);
+ CreateControl(m_nFieldPos, xField, m_nTypeId);
+ }
+
+ // Editieren einer Zelle
+ void UpdateFromField(const DbGridRow* pRow, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+ sal_Bool Commit();
+
+ // freigeben aller Daten, die fuer den AliveMode noetig sind
+ void Clear();
+
+ XubString GetCellText(const DbGridRow* pRow, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter) const;
+ XubString GetCellText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& xField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter) const;
+
+ void SetReadOnly(sal_Bool bRead){m_bReadOnly = bRead;}
+ void SetObject(sal_Int16 nPos) {m_bObject = m_bReadOnly = sal_True; m_nFieldPos = nPos;}
+
+ void ImplInitWindow( Window& rParent, const InitWindowFacet _eInitWhat );
+
+ // Properties, die auf den ::com::sun::star::frame::Controller durchschlagen koennen
+ sal_Int16 SetAlignment(sal_Int16 _nAlign);
+ // if _nAlign is -1, the alignment is calculated from the type of the field we are bound to
+ // the value really set is returned
+ sal_Int16 SetAlignmentFromModel(sal_Int16 nStandardAlign);
+ // set the alignment according to the "Align"-property of m_xModel, use the given standard
+ // alignment if the property if void, return the really set alignment
+
+ // column locking
+ sal_Bool isLocked() const { return m_bLocked; }
+ void setLock(sal_Bool _bLock);
+
+private:
+ /** attaches or detaches our cell object to the SctriptEventAttacherManager implemented
+ by our model's parent
+ */
+ void impl_toggleScriptManager_nothrow( bool _bAttach );
+};
+
+//==================================================================
+// DbCellControl, liefert die Daten fuer einen CellController
+// wird in der Regel nur für komplexe Controls wie z.B ComboBoxen
+// benoetigt
+//==================================================================
+class DbCellControl
+ :public ::svxform::OTypeConversionClient
+ ,public ::svxform::OStaticDataAccessTools
+ ,public FmMutexHelper // _before_ the listener, so the listener is to be destroyed first!
+ ,public ::comphelper::OPropertyChangeListener
+{
+private:
+ ::comphelper::OPropertyChangeMultiplexer* m_pModelChangeBroadcaster;
+ ::comphelper::OPropertyChangeMultiplexer* m_pFieldChangeBroadcaster;
+
+private:
+ sal_Bool m_bTransparent : 1;
+ sal_Bool m_bAlignedController : 1;
+ sal_Bool m_bAccessingValueProperty : 1;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >
+ m_xCursor;
+
+protected:
+ DbGridColumn& m_rColumn;
+ Window* m_pPainter;
+ Window* m_pWindow;
+
+protected:
+ // attribute access
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& getCursor() const { return m_xCursor; }
+
+ // control transparency
+ inline sal_Bool isTransparent( ) const { return m_bTransparent; }
+ inline void setTransparent( sal_Bool _bSet ) { m_bTransparent = _bSet; }
+
+ // control alignment
+ inline void setAlignedController( sal_Bool _bAlign = sal_True ) { m_bAlignedController = _bAlign; }
+
+
+ /** determined whether or not the value property is locked
+ @see lockValueProperty
+ */
+ inline sal_Bool isValuePropertyLocked() const;
+
+ /** locks the listening at the value property.
+ <p>This means that every subsequent change now done on the value property of the model ("Text", or "Value",
+ or whatever) is then ignored.<br/>
+ This base class uses this setting in <method>Commit</method>.</p>
+ @precond
+ Value locking can't be nested
+ @see unlockValueProperty
+ */
+ inline void lockValueProperty();
+ /** unlocks the listening at the value property
+ @see lockValueProperty
+ */
+ inline void unlockValueProperty();
+
+protected:
+ // adds the given property to the list of properties which we listen for
+ void doPropertyListening( const ::rtl::OUString& _rPropertyName );
+
+ // called whenever a property which affects field settings in general is called
+ // you should overwrite this method for every property you add yourself as listener to
+ // with doPropertyListening
+ virtual void implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+
+ // called by _propertyChanged if a property which denotes the column value has changed
+ void implValuePropertyChanged( );
+
+
+public:
+ TYPEINFO();
+ DbCellControl(DbGridColumn& _rColumn, sal_Bool _bText = sal_True);
+ virtual ~DbCellControl();
+
+
+ Window& GetWindow() const
+ {
+ ENSURE_OR_THROW( m_pWindow, "no window" );
+ return *m_pWindow;
+ }
+
+ // control alignment
+ inline sal_Bool isAlignedController() const { return m_bAlignedController; }
+ void AlignControl(sal_Int16 nAlignment);
+
+ void SetTextLineColor();
+ void SetTextLineColor(const Color& _rColor);
+
+ // Initialisieren bevor ein Control angezeigt wird
+ virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
+ virtual ::svt::CellControllerRef CreateController() const = 0;
+
+ // Schreiben des Wertes in das Model
+ sal_Bool Commit();
+
+ // Formatting the field data to output text
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL) = 0;
+
+ virtual void Update(){}
+ // Refresh the control by the field data
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter) = 0;
+
+ // Painten eines Zellinhalts im vorgegeben Rechteck
+ virtual void PaintFieldToCell( OutputDevice& rDev, const Rectangle& rRect, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+ virtual void PaintCell( OutputDevice& _rDev, const Rectangle& _rRect );
+
+ void ImplInitWindow( Window& rParent, const InitWindowFacet _eInitWhat );
+
+ double GetValue(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter) const;
+
+protected:
+ void invalidatedController();
+
+ /** commits the content of the control (e.g. the text of an edit field) into the column model
+ (e.g. the "Text" property of the model).
+ <p>To be overwritten in derived classes.</p>
+ @see updateFromModel
+ */
+ virtual sal_Bool commitControl( ) = 0;
+
+ /** updates the current content of the control (e.g. the text of an edit field) from the column model
+ (e.g. the "Text" property of the model).
+ <p>To be overwritten in derived classes.</p>
+ @precond
+ NULL != _rxModel
+ @precond
+ NULL != m_pWindow
+
+ @see commitControl
+ */
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel ) = 0;
+
+protected:
+// OPropertyChangeListener
+ virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
+
+private:
+ void implDoPropertyListening( const ::rtl::OUString& _rPropertyName, sal_Bool _bWarnIfNotExistent = sal_True );
+
+ /// updates the "readonly" setting on m_pWindow, according to the respective property value in the given model
+ void implAdjustReadOnly( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel,bool i_bReadOnly );
+
+ /// updates the "enabled" setting on m_pWindow, according to the respective property value in the given model
+ void implAdjustEnabled( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+};
+
+//==================================================================
+//------------------------------------------------------------------
+inline sal_Bool DbCellControl::isValuePropertyLocked() const
+{
+ return m_bAccessingValueProperty;
+}
+
+//------------------------------------------------------------------
+inline void DbCellControl::lockValueProperty()
+{
+ OSL_ENSURE( !isValuePropertyLocked(), "DbCellControl::lockValueProperty: not to be nested!" );
+ m_bAccessingValueProperty = sal_True;
+}
+
+//------------------------------------------------------------------
+inline void DbCellControl::unlockValueProperty()
+{
+ OSL_ENSURE( isValuePropertyLocked(), "DbCellControl::lockValueProperty: not locked so far!" );
+ m_bAccessingValueProperty = sal_False;
+}
+
+//==================================================================
+/** a field which is bound to a column which supports the MaxTextLen property
+*/
+class DbLimitedLengthField : public DbCellControl
+{
+public:
+ TYPEINFO();
+
+protected:
+ DbLimitedLengthField( DbGridColumn& _rColumn );
+
+protected:
+ // DbCellControl
+ virtual void implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+
+protected:
+ inline void implSetMaxTextLen( sal_Int16 _nMaxLen )
+ {
+ implSetEffectiveMaxTextLen( _nMaxLen ? _nMaxLen : EDIT_NOLIMIT );
+ }
+ virtual void implSetEffectiveMaxTextLen( sal_Int16 _nMaxLen );
+};
+
+//==================================================================
+class DbTextField : public DbLimitedLengthField
+{
+ ::svt::IEditImplementation* m_pEdit;
+ ::svt::IEditImplementation* m_pPainterImplementation;
+ sal_Int16 m_nKeyType;
+ sal_Bool m_bIsSimpleEdit;
+
+protected:
+ ~DbTextField( );
+
+public:
+ TYPEINFO();
+ DbTextField(DbGridColumn& _rColumn);
+
+ ::svt::IEditImplementation* GetEditImplementation() { return m_pEdit; }
+ sal_Bool IsSimpleEdit() const { return m_bIsSimpleEdit; }
+
+ virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+ virtual ::svt::CellControllerRef CreateController() const;
+ virtual void PaintFieldToCell( OutputDevice& _rDev, const Rectangle& _rRect,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter );
+
+protected:
+ // DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+ // DbLimitedLengthField
+ virtual void implSetEffectiveMaxTextLen( sal_Int16 _nMaxLen );
+};
+
+//==================================================================
+class DbFormattedField : public DbLimitedLengthField
+{
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier > m_xSupplier;
+ sal_Int16 m_nKeyType;
+
+
+public:
+ TYPEINFO();
+ DbFormattedField(DbGridColumn& _rColumn);
+ virtual ~DbFormattedField();
+
+
+ virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+ virtual ::svt::CellControllerRef CreateController() const;
+
+protected:
+ // DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+
+ // OPropertyChangeListener
+ virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================
+class DbCheckBox : public DbCellControl
+{
+public:
+ TYPEINFO();
+ DbCheckBox(DbGridColumn& _rColumn);
+
+ virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+ virtual ::svt::CellControllerRef CreateController() const;
+ virtual void PaintFieldToCell(OutputDevice& rDev, const Rectangle& rRect,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+
+protected:
+ // DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+};
+
+//==================================================================
+class DbComboBox : public DbCellControl
+{
+ sal_Int16 m_nKeyType;
+
+public:
+ TYPEINFO();
+ DbComboBox(DbGridColumn& _rColumn);
+
+ virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+ virtual ::svt::CellControllerRef CreateController() const;
+
+ void SetList(const ::com::sun::star::uno::Any& rItems);
+
+protected:
+ // DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+
+ virtual void implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+
+ // OPropertyChangeListener
+ virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================
+class DbListBox :public DbCellControl
+{
+ sal_Bool m_bBound : 1;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aValueList;
+
+public:
+ TYPEINFO();
+ DbListBox(DbGridColumn& _rColumn);
+
+ virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+ virtual ::svt::CellControllerRef CreateController() const;
+
+ void SetList(const ::com::sun::star::uno::Any& rItems);
+
+protected:
+ // DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+
+ virtual void implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+
+ // OPropertyChangeListener
+ virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw(::com::sun::star::uno::RuntimeException);
+};
+
+//==================================================================
+class DbPatternField : public DbCellControl
+{
+public:
+ TYPEINFO();
+ DbPatternField( DbGridColumn& _rColumn, const ::comphelper::ComponentContext& _rContext );
+ virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+ virtual ::svt::CellControllerRef CreateController() const;
+
+protected:
+ /// DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+
+ virtual void implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+
+private:
+ String impl_formatText( const String& _rText );
+
+private:
+ ::std::auto_ptr< ::dbtools::FormattedColumnValue > m_pValueFormatter;
+ ::std::auto_ptr< ::dbtools::FormattedColumnValue > m_pPaintFormatter;
+ ::comphelper::ComponentContext m_aContext;
+};
+
+//==================================================================
+class DbSpinField : public DbCellControl
+{
+private:
+ sal_Int16 m_nStandardAlign;
+
+public:
+ TYPEINFO();
+
+protected:
+ DbSpinField( DbGridColumn& _rColumn, sal_Int16 _nStandardAlign = com::sun::star::awt::TextAlign::RIGHT );
+
+public:
+ virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& _rxCursor );
+ virtual ::svt::CellControllerRef CreateController() const;
+
+protected:
+ virtual SpinField* createField(
+ Window* _pParent,
+ WinBits _nFieldStyle,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
+ ) = 0;
+};
+
+//==================================================================
+class DbDateField : public DbSpinField
+{
+public:
+ TYPEINFO();
+ DbDateField(DbGridColumn& _rColumn);
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+
+protected:
+ // DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+
+ // DbSpinField
+ virtual SpinField* createField(
+ Window* _pParent,
+ WinBits _nFieldStyle,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
+ );
+
+ /// initializes everything which relates to the properties describing the numeric behaviour
+ virtual void implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+};
+
+//==================================================================
+class DbTimeField : public DbSpinField
+{
+public:
+ TYPEINFO();
+ DbTimeField(DbGridColumn& _rColumn);
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+
+protected:
+ // DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+
+ // DbSpinField
+ virtual SpinField* createField(
+ Window* _pParent,
+ WinBits _nFieldStyle,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
+ );
+
+ /// initializes everything which relates to the properties describing the numeric behaviour
+ virtual void implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+};
+
+//==================================================================
+class DbCurrencyField : public DbSpinField
+{
+ sal_Int16 m_nScale;
+
+public:
+ TYPEINFO();
+ DbCurrencyField(DbGridColumn& _rColumn);
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+
+ double GetCurrency(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter) const;
+
+protected:
+ // DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+
+ // DbSpinField
+ virtual SpinField* createField(
+ Window* _pParent,
+ WinBits _nFieldStyle,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
+ );
+
+ /// initializes everything which relates to the properties describing the numeric behaviour
+ virtual void implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+};
+
+//==================================================================
+class DbNumericField : public DbSpinField
+{
+public:
+ TYPEINFO();
+ DbNumericField(DbGridColumn& _rColumn);
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+
+protected:
+ // DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+
+ // DbSpinField
+ virtual SpinField* createField(
+ Window* _pParent,
+ WinBits _nFieldStyle,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel
+ );
+
+ /// initializes everything which relates to the properties describing the numeric behaviour
+ void implAdjustGenericFieldSetting( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel );
+};
+
+//==================================================================
+class DbFilterField
+ :public DbCellControl
+ ,public ::svxform::OSQLParserClient
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aValueList;
+ XubString m_aText;
+ Link m_aCommitLink;
+ sal_Int16 m_nControlClass;
+ sal_Bool m_bFilterList : 1;
+ sal_Bool m_bFilterListFilled : 1;
+ sal_Bool m_bBound : 1;
+
+public:
+ TYPEINFO();
+ DbFilterField(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,DbGridColumn& _rColumn);
+ virtual ~DbFilterField();
+
+ virtual void Init( Window& rParent, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >& xCursor );
+ virtual ::svt::CellControllerRef CreateController() const;
+ virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect);
+ virtual void Update();
+ virtual XubString GetFormatText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter, Color** ppColor = NULL);
+ virtual void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField, const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+
+ const XubString& GetText() const {return m_aText;}
+ void SetText(const XubString& rText);
+
+ void SetCommitHdl( const Link& rLink ) { m_aCommitLink = rLink; }
+ const Link& GetCommitHdl() const { return m_aCommitLink; }
+
+protected:
+
+ // DbCellControl
+ virtual sal_Bool commitControl( );
+ virtual void updateFromModel( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _rxModel );
+
+protected:
+ void SetList(const ::com::sun::star::uno::Any& rItems, sal_Bool bComboBox);
+ void CreateControl(Window* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xModel);
+ DECL_LINK( OnClick, void* );
+};
+
+//==================================================================
+// Base class providing the access to a grid cell
+//==================================================================
+typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::XControl
+ , ::com::sun::star::form::XBoundControl
+ > FmXGridCell_Base;
+typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XWindow
+ > FmXGridCell_WindowBase;
+class FmXGridCell :public ::cppu::OComponentHelper
+ ,public FmXGridCell_Base
+ ,public FmXGridCell_WindowBase
+{
+protected:
+ ::osl::Mutex m_aMutex;
+ DbGridColumn* m_pColumn;
+ DbCellControl* m_pCellControl;
+
+private:
+ ::cppu::OInterfaceContainerHelper m_aWindowListeners;
+ ::cppu::OInterfaceContainerHelper m_aFocusListeners;
+ ::cppu::OInterfaceContainerHelper m_aKeyListeners;
+ ::cppu::OInterfaceContainerHelper m_aMouseListeners;
+ ::cppu::OInterfaceContainerHelper m_aMouseMotionListeners;
+
+protected:
+ virtual ~FmXGridCell();
+
+public:
+ TYPEINFO();
+ FmXGridCell( DbGridColumn* pColumn, DbCellControl* pControl );
+ void init();
+
+ DECLARE_UNO3_AGG_DEFAULTS(FmXGridCell, OComponentHelper);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
+
+ void SetTextLineColor();
+ void SetTextLineColor(const Color& _rColor);
+
+// XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException){OComponentHelper::dispose();}
+ virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener)throw(::com::sun::star::uno::RuntimeException) { OComponentHelper::addEventListener(aListener);}
+ virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener)throw(::com::sun::star::uno::RuntimeException) { OComponentHelper::removeEventListener(aListener);}
+
+// ::com::sun::star::awt::XControl
+ virtual void SAL_CALL setContext(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& /*Context*/) throw(::com::sun::star::uno::RuntimeException){}
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getContext() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL createPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& /*Toolkit*/, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& /*Parent*/) throw(::com::sun::star::uno::RuntimeException){}
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > SAL_CALL getPeer() throw (::com::sun::star::uno::RuntimeException) {return ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > ();}
+ virtual sal_Bool SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& /*Model*/) throw (::com::sun::star::uno::RuntimeException) {return sal_False;}
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > SAL_CALL getModel() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XView > SAL_CALL getView() throw (::com::sun::star::uno::RuntimeException) {return ::com::sun::star::uno::Reference< ::com::sun::star::awt::XView > ();}
+ virtual void SAL_CALL setDesignMode(sal_Bool /*bOn*/) throw (::com::sun::star::uno::RuntimeException) {}
+ virtual sal_Bool SAL_CALL isDesignMode() throw (::com::sun::star::uno::RuntimeException) {return sal_False;}
+ virtual sal_Bool SAL_CALL isTransparent() throw (::com::sun::star::uno::RuntimeException) {return sal_False;}
+
+// ::com::sun::star::form::XBoundControl
+ virtual sal_Bool SAL_CALL getLock() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLock(sal_Bool _bLock) throw(::com::sun::star::uno::RuntimeException);
+
+ // XWindow
+ virtual void SAL_CALL setPosSize( ::sal_Int32 X, ::sal_Int32 Y, ::sal_Int32 Width, ::sal_Int32 Height, ::sal_Int16 Flags ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getPosSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( ::sal_Bool Visible ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setEnable( ::sal_Bool Enable ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFocus( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ sal_Bool Commit() {return m_pCellControl->Commit();}
+ void ImplInitWindow( Window& rParent, const InitWindowFacet _eInitWhat )
+ { m_pCellControl->ImplInitWindow( rParent, _eInitWhat ); }
+
+ sal_Bool isAlignedController() const { return m_pCellControl->isAlignedController(); }
+ void AlignControl(sal_Int16 nAlignment)
+ { m_pCellControl->AlignControl(nAlignment);}
+
+protected:
+ virtual Window* getEventWindow() const;
+ virtual void onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData );
+
+ // default implementations call our focus listeners, don't forget to call them if you override this
+ virtual void onFocusGained( const ::com::sun::star::awt::FocusEvent& _rEvent );
+ virtual void onFocusLost( const ::com::sun::star::awt::FocusEvent& _rEvent );
+
+private:
+ DECL_LINK( OnWindowEvent, VclWindowEvent* );
+};
+
+//==================================================================
+class FmXDataCell : public FmXGridCell
+{
+public:
+ TYPEINFO();
+ FmXDataCell( DbGridColumn* pColumn, DbCellControl& _rControl )
+ :FmXGridCell( pColumn, &_rControl )
+ {
+ }
+
+ virtual void PaintFieldToCell(OutputDevice& rDev,
+ const Rectangle& rRect,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& xField,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+
+ void UpdateFromField(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& xField,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter)
+ { m_pCellControl->UpdateFromField(xField, xFormatter); }
+
+protected:
+ void UpdateFromColumn();
+};
+
+//==================================================================
+class FmXTextCell : public FmXDataCell
+{
+protected:
+ /** determines whether the text of this cell can be painted directly, without
+ using the painter control
+
+ If this is <TRUE/>, the <member>PaintCell</member> method will simply use the text as returned
+ by <member>GetText</member>, and draw it onto the device passed to <member>PaintFieldToCell</member>,
+ while respecting the current alignment settings.
+
+ If this is <FALSE/>, the <member>PaintFieldToCell</member> request will be forwarded to the painter
+ control (<member>m_pPainter</member>). This is more expensive, but the only option
+ if your painting involves more that a simple DrawText.
+
+ This member is <TRUE/> by default, and can be modified by derived classes.
+ */
+ sal_Bool m_bFastPaint;
+
+public:
+ TYPEINFO();
+ FmXTextCell( DbGridColumn* pColumn, DbCellControl& _rControl );
+
+ virtual void PaintFieldToCell(OutputDevice& rDev,
+ const Rectangle& rRect,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& xField,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter);
+
+ XubString GetText(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxField,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& xFormatter,
+ Color** ppColor = NULL)
+ {return m_pCellControl->GetFormatText(_rxField, xFormatter, ppColor);}
+};
+
+//==================================================================
+typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::XTextComponent
+ , ::com::sun::star::form::XChangeBroadcaster
+ > FmXEditCell_Base;
+class FmXEditCell : public FmXTextCell,
+ public FmXEditCell_Base
+{
+private:
+ ::rtl::OUString m_sValueOnEnter;
+
+protected:
+ ::cppu::OInterfaceContainerHelper m_aTextListeners;
+ ::cppu::OInterfaceContainerHelper m_aChangeListeners;
+ ::svt::IEditImplementation* m_pEditImplementation;
+ bool m_bOwnEditImplementation;
+
+ virtual ~FmXEditCell();
+public:
+ FmXEditCell( DbGridColumn* pColumn, DbCellControl& _rControl );
+
+ DECLARE_UNO3_AGG_DEFAULTS(FmXEditCell, FmXTextCell);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
+
+// XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// ::com::sun::star::awt::XTextComponent
+ virtual void SAL_CALL addTextListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener >& l) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeTextListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener >& l) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setText(const ::rtl::OUString& aText) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL insertText(const ::com::sun::star::awt::Selection& Sel, const ::rtl::OUString& Text) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getText() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSelectedText() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setSelection(const ::com::sun::star::awt::Selection& aSelection) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Selection SAL_CALL getSelection() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isEditable() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setEditable(sal_Bool bEditable) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMaxTextLen(sal_Int16 nLen) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getMaxTextLen() throw(::com::sun::star::uno::RuntimeException);
+
+ // XChangeBroadcaster
+ virtual void SAL_CALL addChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XChangeListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual void onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData );
+
+ virtual void onFocusGained( const ::com::sun::star::awt::FocusEvent& _rEvent );
+ virtual void onFocusLost( const ::com::sun::star::awt::FocusEvent& _rEvent );
+
+private:
+ void onTextChanged();
+};
+
+//==================================================================
+typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::XCheckBox
+ , ::com::sun::star::awt::XButton
+ > FmXCheckBoxCell_Base;
+class FmXCheckBoxCell : public FmXDataCell,
+ public FmXCheckBoxCell_Base
+{
+ ::cppu::OInterfaceContainerHelper m_aItemListeners;
+ ::cppu::OInterfaceContainerHelper m_aActionListeners;
+ ::rtl::OUString m_aActionCommand;
+ CheckBox* m_pBox;
+
+protected:
+ virtual ~FmXCheckBoxCell();
+
+public:
+ FmXCheckBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl );
+
+// UNO
+ DECLARE_UNO3_AGG_DEFAULTS(FmXCheckBoxCell, FmXDataCell);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// ::com::sun::star::awt::XCheckBox
+ virtual void SAL_CALL addItemListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeItemListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getState() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setState(sal_Int16 n) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLabel(const ::rtl::OUString& Label) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL enableTriState(sal_Bool b) throw(::com::sun::star::uno::RuntimeException);
+
+ // XButton
+ virtual void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l ) throw (::com::sun::star::uno::RuntimeException);
+ //virtual void SAL_CALL setLabel( const ::rtl::OUString& Label ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setActionCommand( const ::rtl::OUString& Command ) throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual Window* getEventWindow() const;
+ virtual void onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData );
+};
+
+//==================================================================
+typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XListBox
+ > FmXListBoxCell_Base;
+class FmXListBoxCell :public FmXTextCell
+ ,public FmXListBoxCell_Base
+{
+ ::cppu::OInterfaceContainerHelper m_aItemListeners,
+ m_aActionListeners;
+ ListBox* m_pBox;
+
+protected:
+ virtual ~FmXListBoxCell();
+
+public:
+ FmXListBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl );
+
+ DECLARE_UNO3_AGG_DEFAULTS(FmXListBoxCell, FmXTextCell);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// ::com::sun::star::awt::XListBox
+ virtual void SAL_CALL addItemListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeItemListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& l) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeActionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& l) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addItem(const ::rtl::OUString& aItem, sal_Int16 nPos) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addItems(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aItems, sal_Int16 nPos) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeItems(sal_Int16 nPos, sal_Int16 nCount) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getItemCount() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getItem(sal_Int16 nPos) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getItems() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getSelectedItemPos() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL getSelectedItemsPos() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSelectedItem() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSelectedItems() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL SAL_CALL selectItemPos(sal_Int16 nPos, sal_Bool bSelect) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL SAL_CALL selectItemsPos(const ::com::sun::star::uno::Sequence< sal_Int16 >& aPositions, sal_Bool bSelect) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL SAL_CALL selectItem(const ::rtl::OUString& aItem, sal_Bool bSelect) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isMutipleMode() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL SAL_CALL setMultipleMode(sal_Bool bMulti) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getDropDownLineCount() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL SAL_CALL setDropDownLineCount(sal_Int16 nLines) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL SAL_CALL makeVisible(sal_Int16 nEntry) throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual void onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData );
+
+ DECL_LINK( OnDoubleClick, void* );
+};
+
+//==================================================================
+typedef ::cppu::ImplHelper1 < ::com::sun::star::awt::XComboBox
+ > FmXComboBoxCell_Base;
+class FmXComboBoxCell :public FmXTextCell
+ ,public FmXComboBoxCell_Base
+{
+private:
+ ::cppu::OInterfaceContainerHelper m_aItemListeners,
+ m_aActionListeners;
+ ComboBox* m_pComboBox;
+
+protected:
+ virtual ~FmXComboBoxCell();
+
+public:
+ FmXComboBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl );
+
+ DECLARE_UNO3_AGG_DEFAULTS(FmXListBoxCell, FmXTextCell);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ // XComboBox
+ virtual void SAL_CALL addItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeItemListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XItemListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addItem( const ::rtl::OUString& _Item, ::sal_Int16 _Pos ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addItems( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _Items, ::sal_Int16 _Pos ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeItems( ::sal_Int16 nPos, ::sal_Int16 nCount ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getItemCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getItem( ::sal_Int16 _Pos ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getItems( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getDropDownLineCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDropDownLineCount( ::sal_Int16 _Lines ) throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual void onWindowEvent( const ULONG _nEventId, const Window& _rWindow, const void* _pEventData );
+};
+
+//==================================================================
+typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::XTextComponent
+ , ::com::sun::star::lang::XUnoTunnel
+ > FmXFilterCell_Base;
+class FmXFilterCell :public FmXGridCell
+ ,public FmXFilterCell_Base
+{
+ ::cppu::OInterfaceContainerHelper m_aTextListeners;
+protected:
+ virtual ~FmXFilterCell();
+public:
+ TYPEINFO();
+ FmXFilterCell(DbGridColumn* pColumn = NULL, DbCellControl* pControl = NULL);
+
+
+ DECLARE_UNO3_AGG_DEFAULTS(FmXFilterCell, FmXGridCell);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
+
+// XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+
+// helpers for XUnoTunnel
+ static const ::com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
+ static FmXFilterCell* getImplementation(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxObject);
+
+// painting the filter text
+ virtual void PaintCell(OutputDevice& rDev, const Rectangle& rRect);
+ void Update(){m_pCellControl->Update();}
+
+// OComponentHelper
+ virtual void SAL_CALL disposing();
+
+// ::com::sun::star::awt::XTextComponent
+ virtual void SAL_CALL addTextListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener >& l) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeTextListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextListener >& l) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setText(const ::rtl::OUString& aText) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL insertText(const ::com::sun::star::awt::Selection& Sel, const ::rtl::OUString& Text) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getText() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSelectedText() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setSelection(const ::com::sun::star::awt::Selection& aSelection) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Selection SAL_CALL getSelection() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isEditable() throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setEditable(sal_Bool bEditable) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMaxTextLen(sal_Int16 nLen) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getMaxTextLen() throw(::com::sun::star::uno::RuntimeException);
+
+protected:
+ DECL_LINK( OnCommit, void* );
+};
+
+#endif // _SVX_GRIDCELL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/gridcols.hxx b/svx/source/inc/gridcols.hxx
new file mode 100644
index 000000000000..4eafd5d0b441
--- /dev/null
+++ b/svx/source/inc/gridcols.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_GRIDCOLS_HXX
+#define _SVX_GRIDCOLS_HXX
+
+#include <sal/types.h>
+
+namespace rtl { class OUString; }
+
+#define FM_COL_TEXTFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TextField" ) )
+#define FM_COL_COMBOBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ComboBox" ) )
+#define FM_COL_CHECKBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CheckBox" ) )
+#define FM_COL_TIMEFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TimeField" ) )
+#define FM_COL_DATEFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateField" ) )
+#define FM_COL_NUMERICFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NumericField" ) )
+#define FM_COL_CURRENCYFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CurrencyField" ) )
+#define FM_COL_PATTERNFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PatternField" ) )
+#define FM_COL_LISTBOX rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ListBox" ) )
+#define FM_COL_FORMATTEDFIELD rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormattedField" ) )
+
+// column type ids
+#define TYPE_CHECKBOX 0
+#define TYPE_COMBOBOX 1
+#define TYPE_CURRENCYFIELD 2
+#define TYPE_DATEFIELD 3
+#define TYPE_FORMATTEDFIELD 4
+#define TYPE_LISTBOX 5
+#define TYPE_NUMERICFIELD 6
+#define TYPE_PATTERNFIELD 7
+#define TYPE_TEXTFIELD 8
+#define TYPE_TIMEFIELD 9
+
+//------------------------------------------------------------------------------
+sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName);
+
+
+#endif // _SVX_GRIDCOLS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/linectrl.hrc b/svx/source/inc/linectrl.hrc
new file mode 100644
index 000000000000..ecbffcb00f63
--- /dev/null
+++ b/svx/source/inc/linectrl.hrc
@@ -0,0 +1,28 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#define RID_SVXCTRL_LINECTRL 257
+
diff --git a/svx/source/inc/recoveryui.hxx b/svx/source/inc/recoveryui.hxx
new file mode 100644
index 000000000000..64a9afa28a71
--- /dev/null
+++ b/svx/source/inc/recoveryui.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _RECOVERYUI_HXX
+#define _RECOVERYUI_HXX
+
+//===============================================
+// includes
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/frame/XSynchronousDispatch.hpp>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <vcl/window.hxx>
+#include "docrecovery.hxx"
+
+//===============================================
+// namespace
+
+namespace svx
+{
+
+// Dont export this header ... Otherwise you have to remove this namespace alias!
+namespace css = ::com::sun::star;
+namespace svxdr = ::svx::DocRecovery;
+
+//===============================================
+// declarations
+
+class RecoveryUI : public ::cppu::WeakImplHelper2< css::lang::XServiceInfo ,
+ css::frame::XSynchronousDispatch > // => XDispatch!
+{
+ //-------------------------------------------
+ // const, types, etcpp.
+ private:
+
+ /** @short TODO */
+ enum EJob
+ {
+ E_JOB_UNKNOWN,
+ E_DO_EMERGENCY_SAVE,
+ E_DO_RECOVERY,
+ E_DO_CRASHREPORT
+ };
+
+ //-------------------------------------------
+ // member
+ private:
+
+ /** @short TODO */
+ css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
+
+ /** @short TODO */
+ Window* m_pParentWindow;
+
+ /** @short TODO */
+ RecoveryUI::EJob m_eJob;
+
+ /** @short TODO */
+ css::uno::Reference< css::task::XStatusIndicatorFactory > m_xProgressFactory;
+
+ //-------------------------------------------
+ // interface
+ public:
+
+ //---------------------------------------
+ /** @short TODO */
+ RecoveryUI(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
+
+ //---------------------------------------
+ /** @short TODO */
+ virtual ~RecoveryUI();
+
+ //---------------------------------------
+ // css.lang.XServiceInfo
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& sServiceName)
+ throw(css::uno::RuntimeException);
+
+ virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw(css::uno::RuntimeException);
+
+ //---------------------------------------
+ virtual com::sun::star::uno::Any SAL_CALL dispatchWithReturnValue(const css::util::URL& aURL,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments )
+ throw(css::uno::RuntimeException);
+
+ //---------------------------------------
+ // css.frame.XDispatch
+
+ virtual void SAL_CALL dispatch(const css::util::URL& aURL ,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments)
+ throw(css::uno::RuntimeException);
+
+ virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener,
+ const css::util::URL& aURL )
+ throw(css::uno::RuntimeException);
+ virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener >& xListener,
+ const css::util::URL& aURL )
+ throw(css::uno::RuntimeException);
+
+ //---------------------------------------
+ // XServiceInfo helper
+
+ static ::rtl::OUString st_getImplementationName();
+ static css::uno::Sequence< ::rtl::OUString > st_getSupportedServiceNames();
+ static css::uno::Reference< css::uno::XInterface > SAL_CALL st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
+
+ //-------------------------------------------
+ // helper
+ private:
+
+ EJob impl_classifyJob(const css::util::URL& aURL);
+
+ sal_Bool impl_doEmergencySave();
+
+ void impl_doRecovery();
+
+ void impl_showAllRecoveredDocs();
+
+ void impl_doCrashReport();
+
+};
+
+} // namespace svx
+
+#endif // _RECOVERYUI_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/sdbdatacolumn.hxx b/svx/source/inc/sdbdatacolumn.hxx
new file mode 100644
index 000000000000..1f12fc3e428f
--- /dev/null
+++ b/svx/source/inc/sdbdatacolumn.hxx
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_FORM_SDBDATACOLUMN_HXX
+#define SVX_FORM_SDBDATACOLUMN_HXX
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/sdb/XColumnUpdate.hpp>
+#include <osl/diagnose.h>
+
+//..............................................................................
+namespace svxform
+{
+//..............................................................................
+
+ //==========================================================================
+ //= DataColumn - a class wrapping an object implementing a sdb::DataColumn service
+ //==========================================================================
+ class DataColumn
+ {
+ // interfaces needed for sddb::Column
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xPropertySet;
+ // interfaces needed for sdb::DataColumn
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn> m_xColumn;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumnUpdate> m_xColumnUpdate;
+
+ public:
+ DataColumn() { };
+ DataColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxIFace);
+ // if the object behind _rxIFace doesn't fully support the DataColumn service,
+ // (which is checked via the supported interfaces) _all_ members will be set to
+ // void !, even if the object has some of the needed interfaces.
+
+ sal_Bool is() const { return m_xColumn.is(); }
+ sal_Bool Is() const { return m_xColumn.is(); }
+ sal_Bool supportsUpdate() const { return m_xColumnUpdate.is(); }
+
+ DataColumn* operator ->() { return this; }
+ operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> () const{ return m_xColumn.get(); }
+
+ // 'conversions'
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& getPropertySet() const
+ {
+ return m_xPropertySet;
+ }
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& getColumn() const
+ {
+ return m_xColumn;
+ }
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumnUpdate>& getColumnUpdate() const
+ {
+ OSL_ENSURE(m_xColumnUpdate.is() , "DataColumn::getColumnUpdate: NULL!");
+ return m_xColumnUpdate;
+ }
+
+ // das normale queryInterface
+ ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException )
+ { return m_xColumn->queryInterface(type); }
+
+ // ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> getPropertySetInfo() const throw( ::com::sun::star::uno::RuntimeException );
+ inline void setPropertyValue(const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::uno::Any getPropertyValue(const ::rtl::OUString& PropertyName) const throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
+ inline void addPropertyChangeListener(const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener>& xListener) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
+ inline void removePropertyChangeListener(const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener>& aListener) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
+ inline void addVetoableChangeListener(const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener>& aListener) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
+ inline void removeVetoableChangeListener(const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener>& aListener) throw( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::sdb::XColumn
+ inline sal_Bool wasNull() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::rtl::OUString getString() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline sal_Bool getBoolean() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline sal_Int8 getByte() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline sal_Int16 getShort() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline sal_Int32 getInt() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline sal_Int64 getLong() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline float getFloat() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline double getDouble() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::uno::Sequence< sal_Int8 > getBytes() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::util::Date getDate() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::util::Time getTime() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::util::DateTime getTimestamp() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getBinaryStream() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> getCharacterStream() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::uno::Any getObject(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& typeMap) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef> getRef() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob> getBlob() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob> getClob() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray> getArray() throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+
+ // XColumnUpdate
+ inline void updateNull(void) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateBoolean(sal_Bool x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateByte(sal_Int8 x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateShort(sal_Int16 x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateInt(sal_Int32 x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateLong(sal_Int64 x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateFloat(float x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateDouble(double x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateString(const ::rtl::OUString& x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateBytes(const ::com::sun::star::uno::Sequence< sal_Int8 >& x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateDate(const com::sun::star::util::Date& x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateTime(const ::com::sun::star::util::Time& x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateTimestamp(const ::com::sun::star::util::DateTime& x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateBinaryStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateCharacterStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, sal_Int32 length) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateObject(const ::com::sun::star::uno::Any& x) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ inline void updateNumericObject(const ::com::sun::star::uno::Any& x, sal_Int32 scale) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ };
+
+#endif // SVX_FORM_SDBDATACOLUMN_HXX
+
+//..............................................................................
+} // namespace svxform
+//..............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/sqlparserclient.hxx b/svx/source/inc/sqlparserclient.hxx
new file mode 100644
index 000000000000..946f11d6aab0
--- /dev/null
+++ b/svx/source/inc/sqlparserclient.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_SQLPARSERCLIENT_HXX
+#define SVX_SQLPARSERCLIENT_HXX
+
+#include "svx/dbtoolsclient.hxx"
+#include "ParseContext.hxx"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= OSQLParserClient
+ //====================================================================
+ class SVX_DLLPUBLIC OSQLParserClient : public ODbtoolsClient
+ ,public ::svxform::OParseContextClient
+ {
+ private:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+
+ protected:
+ mutable ::rtl::Reference< ::connectivity::simple::ISQLParser > m_xParser;
+
+ protected:
+ OSQLParserClient(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+ virtual bool ensureLoaded() const;
+
+ protected:
+ inline ::rtl::Reference< ::connectivity::simple::ISQLParseNode > predicateTree(
+ ::rtl::OUString& _rErrorMessage,
+ const ::rtl::OUString& _rStatement,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxField
+ ) const
+ {
+ ::rtl::Reference< ::connectivity::simple::ISQLParseNode > xReturn;
+ if ( ensureLoaded() )
+ xReturn = m_xParser->predicateTree(_rErrorMessage, _rStatement, _rxFormatter, _rxField);
+ return xReturn;
+ }
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_SQLPARSERCLIENT_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/stringlistresource.hxx b/svx/source/inc/stringlistresource.hxx
new file mode 100644
index 000000000000..74bc17ab9fa9
--- /dev/null
+++ b/svx/source/inc/stringlistresource.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_STRINGLISTRESOURCE_HXX
+#define SVX_STRINGLISTRESOURCE_HXX
+
+#include <tools/rc.hxx>
+
+#include <svx/svxdllapi.h>
+
+#include <memory>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ //====================================================================
+ //= StringListResource
+ //====================================================================
+ /** loads a list of strings from a resource, where the resource is of type RSC_RESOURCE,
+ and has sub resources of type string, numbered from 1 to n
+ */
+ class StringListResource : public Resource
+ {
+ public:
+ SVX_DLLPUBLIC StringListResource( const ResId& _rResId );
+ SVX_DLLPUBLIC ~StringListResource();
+
+ inline void get( ::std::vector< String >& _rStrings )
+ {
+ _rStrings = m_aStrings;
+ }
+
+
+ /** returns the String with a given local resource id
+
+ @param _nResId
+ The resource id. It will not be checked if this id exists.
+
+ @return String
+ The string.
+ */
+ String getString( USHORT _nResId )
+ {
+ return String( ResId( _nResId, *m_pResMgr ) );
+ }
+
+ size_t size() const { return m_aStrings.size(); }
+ bool empty() const { return m_aStrings.empty(); }
+
+ const String& operator[]( size_t _index ) const { return m_aStrings[ _index ]; }
+
+ private:
+ ::std::vector< String > m_aStrings;
+ };
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+#endif // SVX_STRINGLISTRESOURCE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/svdoimp.hxx b/svx/source/inc/svdoimp.hxx
new file mode 100644
index 000000000000..e28219fd811c
--- /dev/null
+++ b/svx/source/inc/svdoimp.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_SVDOIMP_HXX
+#define _SVX_SVDOIMP_HXX
+
+#include <vcl/mapmod.hxx>
+
+#include <svx/rectenum.hxx>
+
+
+class Bitmap;
+
+///////////////////////////////////////////////////////////////////////////////
+
+// #104609# Extracted from old XOutDev's ImpCalcBmpFillStartValues
+
+/** Calc offset and size for bitmap fill
+
+ This method calculates the size and the offset from the left, top
+ position of a shape in logical coordinates
+
+ @param rStartOffset
+ The offset from the left, top position of the output rectangle is returned
+
+ @param rBmpOutputSize
+ The output size of the bitmap is returned herein
+
+ @param rOutputRect
+ Specifies the output rectangle into which the bitmap should be tiled into
+
+ @param rOutputMapMode
+ Specifies the logical coordinate system the output rectangle is in
+
+ @param rFillBitmap
+ Specifies the bitmap to fill with
+
+ @param rBmpSize
+ The desired destination bitmap size. If null, size is taken from the bitmap
+
+ @param rBmpPerCent
+ Percentage of bitmap size, relative to the output rectangle
+
+ @param rBmpOffPerCent
+ Offset for bitmap tiling, in percentage relative to bitmap output size
+
+ @param bBmpLogSize
+ True when using the preferred bitmap size, False when using the percentage value
+
+ @param bBmpTile
+ True for tiling. False only paints one instance of the bitmap
+
+ @param bBmpStretch
+ True if bitmap should be stretched to output rect dimension
+
+ @param eBmpRectPoint
+ Position of the start point relative to the bitmap
+
+ */
+void ImpCalcBmpFillSizes( Size& rStartOffset,
+ Size& rBmpOutputSize,
+ const Rectangle& rOutputRect,
+ const MapMode& rOutputMapMode,
+ const Bitmap& rFillBitmap,
+ const Size& rBmpSize,
+ const Size& rBmpPerCent,
+ const Size& rBmpOffPerCent,
+ BOOL bBmpLogSize,
+ BOOL bBmpTile,
+ BOOL bBmpStretch,
+ RECT_POINT eBmpRectPoint );
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#endif // _SVX_SVDOIMP_HXX
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/svdoutlinercache.hxx b/svx/source/inc/svdoutlinercache.hxx
new file mode 100644
index 000000000000..bfa824b902be
--- /dev/null
+++ b/svx/source/inc/svdoutlinercache.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_SDROUTLINER_HXX
+#define _SVX_SDROUTLINER_HXX
+
+#include <sal/types.h>
+
+class SdrModel;
+class SdrOutliner;
+
+
+class SdrOutlinerCache
+{
+private:
+ SdrModel* mpModel;
+
+ SdrOutliner* mpModeOutline;
+ SdrOutliner* mpModeText;
+public:
+ SdrOutlinerCache( SdrModel* pModel );
+ ~SdrOutlinerCache();
+
+ SdrOutliner* createOutliner( sal_uInt16 nOutlinerMode );
+ void disposeOutliner( SdrOutliner* pOutliner );
+};
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/svxrectctaccessiblecontext.hxx b/svx/source/inc/svxrectctaccessiblecontext.hxx
new file mode 100644
index 000000000000..835967b081ef
--- /dev/null
+++ b/svx/source/inc/svxrectctaccessiblecontext.hxx
@@ -0,0 +1,566 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVXRECTACCESSIBLECONTEXT_HXX
+#define _SVXRECTACCESSIBLECONTEXT_HXX
+
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
+#include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
+#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
+#include <com/sun/star/accessibility/XAccessibleValue.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <cppuhelper/weak.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XServiceName.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <osl/mutex.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include <cppuhelper/compbase6.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <cppuhelper/implbase6.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <svx/rectenum.hxx>
+
+namespace com { namespace sun { namespace star { namespace awt {
+ struct Point;
+ struct Rectangle;
+ struct Size;
+ class XFocusListener;
+} } } }
+
+class Rectangle;
+class SvxRectCtl;
+class SvxRectCtlChildAccessibleContext;
+class Window;
+
+
+typedef ::cppu::WeakAggComponentImplHelper6<
+ ::com::sun::star::accessibility::XAccessible,
+ ::com::sun::star::accessibility::XAccessibleComponent,
+ ::com::sun::star::accessibility::XAccessibleContext,
+ ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
+ ::com::sun::star::accessibility::XAccessibleSelection,
+ ::com::sun::star::lang::XServiceInfo >
+ SvxRectCtlAccessibleContext_Base;
+
+class SvxRectCtlAccessibleContext : public ::comphelper::OBaseMutex, public SvxRectCtlAccessibleContext_Base
+{
+public:
+ //===== internal ========================================================
+ SvxRectCtlAccessibleContext(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent,
+ SvxRectCtl& rRepresentation,
+ const ::rtl::OUString* pName = NULL,
+ const ::rtl::OUString* pDescription = NULL );
+protected:
+ virtual ~SvxRectCtlAccessibleContext();
+public:
+ //===== XAccessible =====================================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
+ getAccessibleContext( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ //===== XAccessibleComponent ============================================
+
+ virtual sal_Bool SAL_CALL
+ containsPoint( const ::com::sun::star::awt::Point& rPoint ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL
+ getBounds() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::awt::Point SAL_CALL
+ getLocation() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::awt::Point SAL_CALL
+ getLocationOnScreen() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::awt::Size SAL_CALL
+ getSize() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ isShowing() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ isVisible() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ isFocusTraversable() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ addFocusListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ removeFocusListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ grabFocus() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Any SAL_CALL
+ getAccessibleKeyBinding() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Int32 SAL_CALL
+ getForeground( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL
+ getBackground( ) throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XAccessibleContext ==============================================
+
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleChild( sal_Int32 nIndex )
+ throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleParent( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int32 SAL_CALL
+ getAccessibleIndexInParent( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int16 SAL_CALL
+ getAccessibleRole( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL
+ getAccessibleDescription( void ) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL
+ getAccessibleName( void ) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL
+ getAccessibleRelationSet( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL
+ getAccessibleStateSet( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::lang::Locale SAL_CALL
+ getLocale( void )
+ throw( ::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::accessibility::IllegalAccessibleComponentStateException );
+
+ //===== XComponent =====================================================
+
+ using ::cppu::WeakAggComponentImplHelperBase::addEventListener;
+ using ::cppu::WeakAggComponentImplHelperBase::removeEventListener;
+
+ //===== XAccessibleEventBroadcaster =====================================
+
+ virtual void SAL_CALL
+ addEventListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ removeEventListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ //===== XServiceInfo ====================================================
+
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ supportsService( const ::rtl::OUString& sServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
+ getSupportedServiceNames( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ //===== XTypeProvider ===================================================
+
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ //===== XAccessibleSelection =============================================
+
+ virtual void SAL_CALL
+ selectAccessibleChild( sal_Int32 nChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ isAccessibleChildSelected( sal_Int32 nChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ clearAccessibleSelection() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ selectAllAccessibleChildren() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int32 SAL_CALL
+ getSelectedAccessibleChildCount() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+
+protected:
+ //===== internals ========================================================
+
+ void checkChildIndex( long nIndexOfChild ) throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ void checkChildIndexOnSelection( long nIndexOfChild ) throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ /** Selects a new child by index.
+
+ <p>If the child was not selected before, the state of the child will
+ be updated. If the index is invalid, the index will internaly set to NOCHILDSELECTED</p>
+
+ @param nIndexOfChild
+ Index of the new child which should be selected.
+ */
+ void selectChild( long nIndexOfChild );
+
+public:
+ /** Selects a new child by point.
+
+ <p>If the child was not selected before, the state of the child will
+ be updated. If the point is not invalid, the index will internaly set to NOCHILDSELECTED</p>
+
+ @param eButton
+ Button which belongs to the child which should be selected.
+ */
+ void selectChild( RECT_POINT ePoint );
+
+ /// Sets the name
+ void setName( const ::rtl::OUString& rName );
+
+ /// Sets the description
+ void setDescription( const ::rtl::OUString& rDescr );
+private:
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUniqueId( void );
+protected:
+
+ /// @Return the object's current bounding box relative to the desktop.
+ virtual Rectangle GetBoundingBoxOnScreen( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ /// @Return the object's current bounding box relative to the parent object.
+ virtual Rectangle GetBoundingBox( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ /// Calls all Listener to tell they the change.
+ void CommitChange( const com::sun::star::accessibility::AccessibleEventObject& rEvent );
+
+ virtual void SAL_CALL disposing();
+
+ /// @returns true if it's disposed or in disposing
+ inline sal_Bool IsAlive( void ) const;
+
+ /// @returns true if it's not disposed and no in disposing
+ inline sal_Bool IsNotAlive( void ) const;
+
+ /// throws the exception DisposedException if it's not alive
+ void ThrowExceptionIfNotAlive( void ) throw( ::com::sun::star::lang::DisposedException );
+
+private:
+ /** Description of this object. This is not a constant because it can
+ be set from the outside.
+ */
+ ::rtl::OUString msDescription;
+
+ /** Name of this object.
+ */
+ ::rtl::OUString msName;
+
+ /// Reference to the parent object.
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ mxParent;
+
+ /// pointer to internal representation
+ SvxRectCtl* mpRepr;
+
+ /// array for all possible childs
+ SvxRectCtlChildAccessibleContext** mpChilds;
+
+ /// client id in the AccessibleEventNotifier queue
+ sal_uInt32 mnClientId;
+
+ /// actual selected child
+ long mnSelectedChild;
+
+ /// mode of control (true -> 8 points, false -> 9 points)
+ sal_Bool mbAngleMode;
+};
+
+inline sal_Bool SvxRectCtlAccessibleContext::IsAlive( void ) const
+{
+ return !rBHelper.bDisposed && !rBHelper.bInDispose;
+}
+
+inline sal_Bool SvxRectCtlAccessibleContext::IsNotAlive( void ) const
+{
+ return rBHelper.bDisposed || rBHelper.bInDispose;
+}
+
+
+typedef ::cppu::WeakAggComponentImplHelper6<
+ ::com::sun::star::accessibility::XAccessible,
+ ::com::sun::star::accessibility::XAccessibleComponent,
+ ::com::sun::star::accessibility::XAccessibleContext,
+ ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
+ ::com::sun::star::accessibility::XAccessibleValue,
+ ::com::sun::star::lang::XServiceInfo >
+ SvxRectCtlChildAccessibleContext_Base;
+
+
+class SvxRectCtlChildAccessibleContext : public SvxRectCtlChildAccessibleContext_Base
+{
+public:
+ SvxRectCtlChildAccessibleContext(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent,
+ const Window& rParentWindow,
+ const ::rtl::OUString& rName, const ::rtl::OUString& rDescription,
+ const Rectangle& rBoundingBox,
+ long nIndexInParent );
+protected:
+ virtual ~SvxRectCtlChildAccessibleContext();
+public:
+ //===== XAccessible =====================================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
+ getAccessibleContext( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ //===== XAccessibleComponent ============================================
+
+ virtual sal_Bool SAL_CALL
+ containsPoint( const ::com::sun::star::awt::Point& rPoint ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL
+ getBounds() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::awt::Point SAL_CALL
+ getLocation() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::awt::Point SAL_CALL
+ getLocationOnScreen() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::awt::Size SAL_CALL
+ getSize() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ isShowing() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ isVisible() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ isFocusTraversable() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ grabFocus() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Any SAL_CALL
+ getAccessibleKeyBinding() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Int32 SAL_CALL
+ getForeground( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL
+ getBackground( ) throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XAccessibleContext ==============================================
+
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleChild( sal_Int32 nIndex )
+ throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleParent( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int32 SAL_CALL
+ getAccessibleIndexInParent( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int16 SAL_CALL
+ getAccessibleRole( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL
+ getAccessibleDescription( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL
+ getAccessibleName( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL
+ getAccessibleRelationSet( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL
+ getAccessibleStateSet( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::lang::Locale SAL_CALL
+ getLocale( void )
+ throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::accessibility::IllegalAccessibleComponentStateException );
+
+ //===== XComponent =====================================================
+
+ using ::cppu::WeakAggComponentImplHelperBase::addEventListener;
+ using ::cppu::WeakAggComponentImplHelperBase::removeEventListener;
+
+ //===== XAccessibleEventBroadcaster =====================================
+
+ virtual void SAL_CALL
+ addEventListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL
+ removeEventListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener )
+ throw( com::sun::star::uno::RuntimeException );
+
+ //===== XAccessibleValue ================================================
+
+ virtual ::com::sun::star::uno::Any SAL_CALL
+ getCurrentValue() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ setCurrentValue( const ::com::sun::star::uno::Any& aNumber ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Any SAL_CALL
+ getMaximumValue() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Any SAL_CALL
+ getMinimumValue() throw( ::com::sun::star::uno::RuntimeException );
+
+ //===== XServiceInfo ====================================================
+
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Bool SAL_CALL
+ supportsService( const ::rtl::OUString& sServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
+ getSupportedServiceNames( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+
+ //===== XTypeProvider ===================================================
+
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ //===== internal ==========================================================
+
+ /// Sets the checked status
+ void setStateChecked( sal_Bool bChecked );
+
+protected:
+ virtual Rectangle GetBoundingBoxOnScreen( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual Rectangle GetBoundingBox( void ) throw( ::com::sun::star::uno::RuntimeException );
+
+ void CommitChange( const com::sun::star::accessibility::AccessibleEventObject& rEvent );
+
+ virtual void SAL_CALL disposing();
+
+ /// @returns true if it's disposed or in disposing
+ inline sal_Bool IsAlive( void ) const;
+
+ /// @returns true if it's not disposed and no in disposing
+ inline sal_Bool IsNotAlive( void ) const;
+
+ /// throws the exception DisposedException if it's not alive
+ void ThrowExceptionIfNotAlive( void ) throw( ::com::sun::star::lang::DisposedException );
+
+ /// Mutex guarding this object.
+ ::osl::Mutex maMutex;
+
+private:
+
+ /** Description of this object. This is not a constant because it can
+ be set from the outside. Furthermore, it changes according the the
+ draw page's display mode.
+ */
+ ::rtl::OUString msDescription;
+
+ /** Name of this object. It changes according the the draw page's
+ display mode.
+ */
+ ::rtl::OUString msName;
+
+ /// Reference to the parent object.
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ mxParent;
+
+ /// Bounding box
+ Rectangle* mpBoundingBox;
+
+ /// window of parent
+ const Window& mrParentWindow;
+
+ /// client id in the AccessibleEventNotifier queue
+ sal_uInt32 mnClientId;
+
+ /// index of child in parent
+ long mnIndexInParent;
+
+ /// Indicates, if object is checked
+ sal_Bool mbIsChecked;
+};
+
+inline sal_Bool SvxRectCtlChildAccessibleContext::IsAlive( void ) const
+{
+ return !rBHelper.bDisposed && !rBHelper.bInDispose;
+}
+
+inline sal_Bool SvxRectCtlChildAccessibleContext::IsNotAlive( void ) const
+{
+ return rBHelper.bDisposed || rBHelper.bInDispose;
+}
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/tabwin.hxx b/svx/source/inc/tabwin.hxx
new file mode 100644
index 000000000000..e086854d14e1
--- /dev/null
+++ b/svx/source/inc/tabwin.hxx
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TABWIN_HXX
+#define _SVX_TABWIN_HXX
+
+#include <svtools/svtreebx.hxx>
+#include <vcl/floatwin.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/ctrlitem.hxx>
+#include <com/sun/star/form/XForm.hpp>
+
+#include <comphelper/propmultiplex.hxx>
+#include <svtools/transfer.hxx>
+#include "svx/dbtoolsclient.hxx"
+
+//==================================================================
+class FmFieldWin;
+class SAL_DLLPRIVATE FmFieldWinListBox
+ :public SvTreeListBox
+{
+ FmFieldWin* pTabWin;
+
+protected:
+// virtual void Command( const CommandEvent& rEvt );
+
+public:
+ FmFieldWinListBox( FmFieldWin* pParent );
+ virtual ~FmFieldWinListBox();
+
+ sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+protected:
+ // DragSourceHelper
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+ // SvLBox
+ virtual BOOL DoubleClickHdl();
+
+ using SvLBox::ExecuteDrop;
+};
+
+//========================================================================
+class FmFormShell;
+class SAL_DLLPRIVATE FmFieldWinData
+{
+public:
+ FmFieldWinData();
+ ~FmFieldWinData();
+};
+
+//========================================================================
+class SAL_DLLPRIVATE FmFieldWin :public SfxFloatingWindow
+ ,public SfxControllerItem
+ ,public ::comphelper::OPropertyChangeListener
+ ,public ::svxform::OStaticDataAccessTools
+{
+ ::osl::Mutex m_aMutex;
+ FmFieldWinListBox* pListBox;
+ FmFieldWinData* pData;
+ ::svxform::SharedConnection
+ m_aConnection;
+ ::rtl::OUString m_aDatabaseName,
+ m_aObjectName;
+ sal_Int32 m_nObjectType;
+
+ ::comphelper::OPropertyChangeMultiplexer* m_pChangeListener;
+
+public:
+ FmFieldWin(SfxBindings *pBindings,
+ SfxChildWindow *pMgr, Window* pParent);
+
+ virtual ~FmFieldWin();
+ virtual void Resize();
+ virtual sal_Bool Close();
+ virtual void GetFocus();
+ virtual long PreNotify( NotifyEvent& _rNEvt );
+ virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState,
+ const SfxPoolItem* pState);
+
+ FmFieldWinData* GetData() const {return pData;}
+
+ void UpdateContent(FmFormShell*);
+ void UpdateContent(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > &);
+ void FillInfo( SfxChildWinInfo& rInfo ) const;
+
+ const ::rtl::OUString& GetDatabaseName() const { return m_aDatabaseName; }
+ ::svxform::SharedConnection GetConnection() const { return m_aConnection; }
+ const ::rtl::OUString& GetObjectName() const { return m_aObjectName; }
+ sal_Int32 GetObjectType() const { return m_nObjectType; }
+
+ sal_Bool createSelectionControls( );
+
+protected:
+ // FmXChangeListener
+ virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException );
+
+protected:
+ inline SfxBindings& GetBindings() { return SfxControllerItem::GetBindings(); }
+ inline const SfxBindings& GetBindings() const { return SfxControllerItem::GetBindings(); }
+
+ using SfxFloatingWindow::StateChanged;
+};
+
+//========================================================================
+class SAL_DLLPRIVATE FmFieldWinMgr : public SfxChildWindow
+{
+public:
+ FmFieldWinMgr(Window *pParent, sal_uInt16 nId,
+ SfxBindings *pBindings, SfxChildWinInfo *pInfo);
+ SFX_DECL_CHILDWINDOW(FmFieldWinMgr);
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/tbxform.hxx b/svx/source/inc/tbxform.hxx
new file mode 100644
index 000000000000..1935fcb3663e
--- /dev/null
+++ b/svx/source/inc/tbxform.hxx
@@ -0,0 +1,166 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TBXFORM_HXX
+#define _SVX_TBXFORM_HXX
+
+#include <sfx2/tbxctrl.hxx>
+#include <vcl/field.hxx>
+#include <vcl/dialog.hxx>
+
+#include <vcl/button.hxx>
+
+//========================================================================
+class SvxFmAbsRecWin : public NumericField
+{
+ SfxToolBoxControl* m_pController;
+ // for invalidating our content whe losing the focus
+public:
+ SvxFmAbsRecWin( Window* _pParent, SfxToolBoxControl* _pController );
+ ~SvxFmAbsRecWin();
+
+ virtual void KeyInput( const KeyEvent& rKeyEvt );
+ virtual void LoseFocus();
+
+protected:
+ virtual void FirePosition( sal_Bool _bForce );
+};
+
+
+//========================================================================
+class SvxFmConfigWin : public SfxPopupWindow
+{
+private:
+ DECL_LINK( TbxSelectHdl, ToolBox* );
+
+public:
+ SvxFmConfigWin( USHORT nId, ResId aRIdWin, ResId aRIdTbx );
+ ~SvxFmConfigWin();
+
+ void Update();
+ virtual void PopupModeEnd();
+};
+
+
+//========================================================================
+class SvxFmTbxCtlConfig : public SfxToolBoxControl
+{
+private:
+ UINT16 nLastSlot;
+
+protected:
+ using SfxToolBoxControl::Select;
+
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SvxFmTbxCtlConfig( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+ ~SvxFmTbxCtlConfig() {}
+
+ virtual void Select( USHORT nModifier );
+ virtual void StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+ virtual SfxPopupWindowType GetPopupWindowType() const;
+ virtual SfxPopupWindow* CreatePopupWindow();
+};
+
+//========================================================================
+class FixedText;
+class SvxFmTbxCtlAbsRec : public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SvxFmTbxCtlAbsRec( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+ ~SvxFmTbxCtlAbsRec();
+
+ virtual Window* CreateItemWindow( Window* pParent );
+
+ virtual void StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+};
+
+//========================================================================
+class SvxFmTbxCtlRecText : public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SvxFmTbxCtlRecText( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+ ~SvxFmTbxCtlRecText();
+
+ virtual Window* CreateItemWindow( Window* pParent );
+};
+
+//========================================================================
+class SvxFmTbxCtlRecFromText : public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SvxFmTbxCtlRecFromText( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+ ~SvxFmTbxCtlRecFromText();
+
+ virtual Window* CreateItemWindow( Window* pParent );
+};
+
+//========================================================================
+class SvxFmTbxCtlRecTotal : public SfxToolBoxControl
+{
+ FixedText* pFixedText;
+
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ SvxFmTbxCtlRecTotal( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+ ~SvxFmTbxCtlRecTotal();
+
+ virtual Window* CreateItemWindow( Window* pParent );
+ virtual void StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+};
+
+//========================================================================
+class SvxFmTbxNextRec : public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+ SvxFmTbxNextRec( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+};
+
+//========================================================================
+class SvxFmTbxPrevRec : public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+ SvxFmTbxPrevRec( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/trace.hxx b/svx/source/inc/trace.hxx
new file mode 100644
index 000000000000..52991b424791
--- /dev/null
+++ b/svx/source/inc/trace.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _TRACE_HXX_
+#define _TRACE_HXX_
+
+#if defined(DBG_UTIL)
+
+#include <tools/string.hxx>
+#include <osl/thread.hxx>
+#include <osl/mutex.hxx>
+#include <comphelper/stl_types.hxx>
+
+
+class Tracer
+{
+ ByteString m_sBlockDescription;
+
+ DECLARE_STL_STDKEY_MAP( ::oslThreadIdentifier, sal_Int32, MapThreadId2Int );
+ static MapThreadId2Int s_aThreadIndents;
+
+ static ::osl::Mutex s_aMapSafety;
+
+public:
+ Tracer(const char* _pBlockDescription);
+ ~Tracer();
+
+ void TraceString(const char* _pMessage);
+ void TraceString1StringParam(const char* _pMessage, const char* _pParam);
+};
+
+
+#define TRACE_RANGE(range_description) Tracer aTrace(range_description);
+#define TRACE_RANGE_MESSAGE(message) { aTrace.TraceString(message); }
+#define TRACE_RANGE_MESSAGE1(message, param) { aTrace.TraceString1StringParam(message, param); }
+
+#else
+
+#define TRACE_RANGE(range_description) ;
+#define TRACE_RANGE_MESSAGE(message) ;
+#define TRACE_RANGE_MESSAGE1(message, param) ;
+
+#endif
+
+#endif // _TRACE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/treevisitor.hxx b/svx/source/inc/treevisitor.hxx
new file mode 100644
index 000000000000..11b10d505a3e
--- /dev/null
+++ b/svx/source/inc/treevisitor.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * 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 SVX_TREE_VISITOR_HXX
+#define SVX_TREE_VISITOR_HXX
+
+#include <stack>
+
+template< class ELEMENT, class NODEINFO, class PROCESSOR >
+class TreeVisitor
+{
+public:
+ TreeVisitor( NODEINFO _nodeInfo )
+ :m_visitedRoot( false )
+ ,m_root()
+ ,m_current()
+ ,m_nodeInfo( _nodeInfo )
+ {
+ }
+
+ void process( const ELEMENT& _root, PROCESSOR& _processor )
+ {
+ m_root = _root;
+ m_visitedRoot = false;
+
+ while ( do_step() )
+ _processor.process( m_current );
+ }
+
+private:
+ bool do_step();
+
+private:
+ bool m_visitedRoot;
+ ELEMENT m_root;
+ ELEMENT m_current;
+ const NODEINFO m_nodeInfo;
+
+ ::std::stack< size_t > m_pathToCurrent;
+ ::std::stack< ELEMENT > m_currentAncestors;
+};
+
+template< class ELEMENT, class NODEINFO, class PROCESSOR >
+bool TreeVisitor< ELEMENT, NODEINFO, PROCESSOR >::do_step()
+{
+ if ( !m_visitedRoot )
+ {
+ m_current = m_root;
+ m_visitedRoot = true;
+ return true;
+ }
+
+ // can we step down from the current node?
+ size_t childCount = m_nodeInfo.childCount( m_current );
+ if ( childCount )
+ {
+ m_currentAncestors.push( m_current );
+ m_current = m_nodeInfo.getChild( m_current, 0 );
+ m_pathToCurrent.push( 0 );
+ return true;
+ }
+
+ // is there a right sibling of the current node?
+ while ( !m_pathToCurrent.empty() )
+ {
+ const ELEMENT& currentParent = m_currentAncestors.top();
+ childCount = m_nodeInfo.childCount( currentParent );
+
+ size_t currentChildPos = m_pathToCurrent.top();
+ if ( ++currentChildPos < childCount )
+ {
+ // yes there is
+ m_pathToCurrent.top() = currentChildPos;
+ m_current = m_nodeInfo.getChild( currentParent, currentChildPos );
+ return true;
+ }
+
+ // no there isn't => step up
+ m_currentAncestors.pop();
+ m_pathToCurrent.pop();
+ }
+
+ return false;
+}
+
+#endif // SVX_TREE_VISITOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/typeconversionclient.hxx b/svx/source/inc/typeconversionclient.hxx
new file mode 100644
index 000000000000..625ceaac7aaa
--- /dev/null
+++ b/svx/source/inc/typeconversionclient.hxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_TYPECONVERSION_CLIENT_HXX
+#define SVX_TYPECONVERSION_CLIENT_HXX
+
+#include "svx/dbtoolsclient.hxx"
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= OTypeConversionClient
+ //====================================================================
+ class OTypeConversionClient : public ODbtoolsClient
+ {
+ protected:
+ mutable ::rtl::Reference< ::connectivity::simple::IDataAccessTypeConversion >
+ m_xTypeConversion;
+ virtual bool ensureLoaded() const;
+
+ public:
+ OTypeConversionClient();
+
+ // --------------------------------------------------------
+ inline ::com::sun::star::util::Date getStandardDate() const
+ {
+ ::com::sun::star::util::Date aReturn;
+ if ( ensureLoaded() )
+ aReturn = m_xTypeConversion->getStandardDate();
+ return aReturn;
+ }
+
+ // --------------------------------------------------------
+ inline double getValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn>& _rxVariant,
+ const ::com::sun::star::util::Date& _rNullDate,
+ sal_Int16 _nKeyType) const
+ {
+ double nReturn(0);
+ if ( ensureLoaded() )
+ nReturn = m_xTypeConversion->getValue(_rxVariant, _rNullDate, _nKeyType);
+ return nReturn;
+ }
+
+ // --------------------------------------------------------
+ inline ::rtl::OUString getValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter,
+ const ::com::sun::star::util::Date& _rNullDate,
+ sal_Int32 _nKey,
+ sal_Int16 _nKeyType) const
+ {
+ ::rtl::OUString sReturn;
+ if ( ensureLoaded() )
+ sReturn = m_xTypeConversion->getValue(_rxColumn, _rxFormatter, _rNullDate, _nKey, _nKeyType);
+ return sReturn;
+ }
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_TYPECONVERSION_CLIENT_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/unogalthemeprovider.hxx b/svx/source/inc/unogalthemeprovider.hxx
new file mode 100644
index 000000000000..d4764f06c6ba
--- /dev/null
+++ b/svx/source/inc/unogalthemeprovider.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_UNOGALTHEMEPROVIDER_HXX
+#define _SVX_UNOGALTHEMEPROVIDER_HXX
+
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/gallery/XGalleryThemeProvider.hpp>
+
+#include <svx/svxdllapi.h>
+
+class Gallery;
+
+namespace unogallery {
+
+// -------------------------
+// - some helper functions -
+// -------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GalleryThemeProvider_createInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) throw( ::com::sun::star::uno::Exception );
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GalleryThemeProvider_getSupportedServiceNames() throw();
+::rtl::OUString SAL_CALL GalleryThemeProvider_getImplementationName() throw();
+
+// -----------------
+// - GalleryThemes -
+// -----------------
+
+class GalleryThemeProvider : public ::cppu::WeakImplHelper2< ::com::sun::star::lang::XInitialization,
+ ::com::sun::star::gallery::XGalleryThemeProvider >
+{
+public:
+
+ GalleryThemeProvider();
+ ~GalleryThemeProvider();
+
+ SVX_DLLPUBLIC static ::rtl::OUString getImplementationName_Static() throw();
+ SVX_DLLPUBLIC static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
+
+protected:
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasElements() throw (::com::sun::star::uno::RuntimeException);
+
+ // XNameAccess
+ virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw ( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException );
+
+ // XGalleryThemeProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::gallery::XGalleryTheme > SAL_CALL insertNewByName( const ::rtl::OUString& ThemeName ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeByName( const ::rtl::OUString& ThemeName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+
+private:
+
+ Gallery* mpGallery;
+ sal_Bool mbHiddenThemes;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/unopolyhelper.hxx b/svx/source/inc/unopolyhelper.hxx
new file mode 100644
index 000000000000..c682f34f0099
--- /dev/null
+++ b/svx/source/inc/unopolyhelper.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_UNOPOLYHELPER_HXX
+#define _SVX_UNOPOLYHELPER_HXX
+
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+
+#include <svx/svxdllapi.h>
+
+namespace com { namespace sun { namespace star { namespace drawing {
+ struct PolyPolygonBezierCoords;
+} } } }
+
+namespace basegfx {
+ class B2DPolyPolygon;
+}
+
+/** convert a drawing::PolyPolygonBezierCoords to a B2DPolyPolygon
+*/
+basegfx::B2DPolyPolygon SvxConvertPolyPolygonBezierToB2DPolyPolygon( const com::sun::star::drawing::PolyPolygonBezierCoords* pSourcePolyPolygon)
+ throw( com::sun::star::lang::IllegalArgumentException );
+
+/** convert a B2DPolyPolygon to a drawing::PolyPolygonBezierCoords
+*/
+SVX_DLLPUBLIC void SvxConvertB2DPolyPolygonToPolyPolygonBezier( const basegfx::B2DPolyPolygon& rPolyPoly, com::sun::star::drawing::PolyPolygonBezierCoords& rRetval );
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/xfm_addcondition.hxx b/svx/source/inc/xfm_addcondition.hxx
new file mode 100644
index 000000000000..36ec1896e82e
--- /dev/null
+++ b/svx/source/inc/xfm_addcondition.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_SOURCE_INC_XFM_ADDCONDITION_HXX
+#define SVX_SOURCE_INC_XFM_ADDCONDITION_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/xforms/XModel.hpp>
+/** === end UNO includes === **/
+#include <svtools/genericunodialog.hxx>
+#include <comphelper/proparrhlp.hxx>
+
+//........................................................................
+namespace svxform
+{
+//........................................................................
+
+ //====================================================================
+ //= OAddConditionDialog
+ //====================================================================
+ typedef ::svt::OGenericUnoDialog OAddConditionDialogBase;
+ class OAddConditionDialog
+ :public OAddConditionDialogBase
+ ,public ::comphelper::OPropertyArrayUsageHelper< OAddConditionDialog >
+ {
+ private:
+ // <properties>
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xBinding;
+ ::rtl::OUString m_sFacetName;
+ ::rtl::OUString m_sConditionValue;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XModel >
+ m_xWorkModel;
+ // </properties>
+
+ public:
+ static ::com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
+ SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& );
+
+ protected:
+ OAddConditionDialog( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
+
+ // XTypeProvider
+ virtual com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual com::sun::star::uno::Reference<com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ virtual void executedDialog(sal_Int16 _nExecutionResult);
+ };
+
+//........................................................................
+} // namespace svxform
+//........................................................................
+
+#endif // SVX_SOURCE_INC_XFM_ADDCONDITION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/xmlxtexp.hxx b/svx/source/inc/xmlxtexp.hxx
new file mode 100644
index 000000000000..ac190aaaba2a
--- /dev/null
+++ b/svx/source/inc/xmlxtexp.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_XMLXTEXP_HXX
+#define _SVX_XMLXTEXP_HXX
+
+#include "xmloff/xmlexp.hxx"
+
+namespace rtl { class OUString; }
+namespace com { namespace sun { namespace star {
+ namespace frame { class XModel; }
+ namespace uno { template<class X> class Reference; }
+ namespace uno { class XInterface; }
+ namespace container { class XNameContainer; }
+ namespace document { class XGraphicObjectResolver; }
+ namespace xml { namespace sax { class XDocumentHandler; } }
+} } }
+
+class SvxXMLXTableExportComponent : public SvXMLExport
+{
+public:
+ // #110680#
+ SvxXMLXTableExportComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ const rtl::OUString& rFileName,
+ const com::sun::star::uno::Reference< com::sun::star::xml::sax::XDocumentHandler > & xHandler,
+ const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > & xTable,
+ com::sun::star::uno::Reference< com::sun::star::document::XGraphicObjectResolver >& xGrfResolver);
+
+ ~SvxXMLXTableExportComponent();
+
+ static sal_Bool save( const rtl::OUString& rURL, const com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xTable ) throw();
+
+ sal_Bool exportTable() throw();
+
+ // methods without content:
+ virtual void _ExportAutoStyles();
+ virtual void _ExportMasterStyles();
+ virtual void _ExportContent();
+
+private:
+ const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > & mxTable;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/xmlxtimp.hxx b/svx/source/inc/xmlxtimp.hxx
new file mode 100644
index 000000000000..c10985fabc96
--- /dev/null
+++ b/svx/source/inc/xmlxtimp.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_XMLXTIMP_HXX
+#define _SVX_XMLXTIMP_HXX
+
+#include <xmloff/xmlimp.hxx>
+
+namespace rtl { class OUString; }
+namespace com { namespace sun { namespace star {
+ namespace uno { template<class X> class Reference; }
+ namespace uno { class XInterface; }
+ namespace document { class XGraphicObjectResolver; }
+ namespace container { class XNameContainer; }
+
+} } }
+
+class SvxXMLXTableImport : public SvXMLImport
+{
+public:
+ // #110680#
+ SvxXMLXTableImport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > & rTable,
+ com::sun::star::uno::Reference< com::sun::star::document::XGraphicObjectResolver >& xGrfResolver);
+
+ virtual ~SvxXMLXTableImport() throw ();
+
+ static sal_Bool load( const rtl::OUString& rUrl, const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& xTable ) throw();
+protected:
+ virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
+ const ::rtl::OUString& rLocalName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+private:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > & mrTable;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/intro/intro_tmpl.hrc b/svx/source/intro/intro_tmpl.hrc
new file mode 100644
index 000000000000..825b28a6897f
--- /dev/null
+++ b/svx/source/intro/intro_tmpl.hrc
@@ -0,0 +1,1327 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/svxids.hrc>
+
+#define RID_IMGLIST_TREEOPT (RID_OFA_START + 174)
+#define RID_IMGLIST_TREEOPT_HC (RID_OFA_START + 175)
+
+#define OOO_CONTRIBUTOR_LIST \
+ItemList = \
+{ \
+ < "" ; > ; \
+ < "Esben Aaberg" ; > ; \
+ < "Craig A. Adams" ; > ; \
+ < "Agenda d.o.o." ; > ; \
+ < "Claus Agerskov" ; > ; \
+ < "Tesfamicael Adhanom" ; > ; \
+ < "Agile Interactions, Inc." ; > ; \
+ < "Volker Ahrendt" ; > ; \
+ < "Christian Ahrenkiel" ; > ; \
+ < "Kai Ahrens" ; > ; \
+ < "Ralph Aichinger" ; > ; \
+ < "Takamichi Akiyama" ; > ; \
+ < "Rail Aliev" ; > ; \
+ < "Florence Allizon-Juillet" ; > ; \
+ < "Benoit Altenbourger" ; > ; \
+ < "Ahmet Altin" ; > ; \
+ < "Jesus Bravo Alvarez" ; > ; \
+ < "Michal Ambroz" ; > ; \
+ < "Aryan Ameri" ; > ; \
+ < "Brian M. Ames" ; > ; \
+ < "Jost Ammon" ; > ; \
+ < "Paolo Amodio" ; > ; \
+ < "Abdullah Anar" ; > ; \
+ < "Gene Anaya" ; > ; \
+ < "Christian Andersen" ; > ; \
+ < "Frank J. Andersen" ; > ; \
+ < "Jan Moller Andersen" ; > ; \
+ < "Jorn Skifter Andersen" ; > ; \
+ < "Susanne Anderson" ; > ; \
+ < "Joost Andrae" ; > ; \
+ < "Timar Andras" ; > ; \
+ < "Michael Arbon" ; > ; \
+ < "Magosanhi Ardho" ; > ; \
+ < "Sakari Aro" ; > ; \
+ < "Magosanyi Arpad" ; > ; \
+ < "Peter Arnold" ; > ; \
+ < "Takashi Asari" ; > ; \
+ < "Travis Athougies " ; > ; \
+ < "Kosa Attila" ; > ; \
+ < "Ativiras Kodas Lietuvai (Open Source for Lithuania)" ; > ; \
+ < "Peter Babco" ; > ; \
+ < "Natalia Babkina" ; > ; \
+ < "Eric Bachard" ; > ; \
+ < "Jeffrey G. Backes" ; > ; \
+ < "Monica Badia" ; > ; \
+ < "Sanlig Badral" ; > ; \
+ < "Michele Baldessari" ; > ; \
+ < "Dwayne Bailey" ; > ; \
+ < "Ilyas Bakirov " ; > ; \
+ < "Omer Bar-or" ; > ; \
+ < "Danial Ferreira Balieiro" ; > ; \
+ < "Athur Barret" ; > ; \
+ < "Rodrigo Pedroso Barbosa" ; > ; \
+ < "Gildecio E. Barboza" ; > ; \
+ < "Joerg Barfurth" ; > ; \
+ < "Yvan Barthelemy " ; > ; \
+ < "David Bartlett" ; > ; \
+ < "Sascha Ballach" ; > ; \
+ < "Stefan Baltzer" ; > ; \
+ < "Jayant Balraj Madavi" ; > ; \
+ < "Claudio Bandaloukas" ; > ; \
+ < "Omar Bar-or" ; > ; \
+ < "Hrega Basu" ; > ; \
+ < "Mathias Bauer" ; > ; \
+ < "Martin Baulig" ; > ; \
+ < "Martin Bayer" ; > ; \
+ < "Gwenole Beauchesne" ; > ; \
+ < "Youssef Beghi" ; > ; \
+ < "Juraj Bednar" ; > ; \
+ < "Brian Behlendorf" ; > ; \
+ < "Thorsten Behrens" ; > ; \
+ < "Lars Behrmann" ; > ; \
+ < "Kyle Begol" ; > ; \
+ < "Beijing Co-Create Open Source Software Co. Ltd." ; > ; \
+ < "Beijing Redflag Chinese 2000 Software Co. Ltd." ; > ; \
+ < "Andero Belov" ; > ; \
+ < "Michael Bemmer" ; > ; \
+ < "Boldizsar Bencsath" ; > ; \
+ < "Thomas Benisch" ; > ; \
+ < "Stephan Bergmann" ; > ; \
+ < "Josh Berkus" ; > ; \
+ < "Armin Besirovic" ; > ; \
+ < "beunited.org Littleton, USA" ; > ; \
+ < "Zaheda Bhorat" ; > ; \
+ < "Andreas Bille" ; > ; \
+ < "Oliver Bietzer" ; > ; \
+ < "Eric Bischoff" ; > ; \
+ < "Marissa Bishop" ; > ; \
+ < "Torkil Bladt" ; > ; \
+ < "Martin Blapp" ; > ; \
+ < "Nick Blievers" ; > ; \
+ < "Peter Bodnar" ; > ; \
+ < "Daniel Boelzle" ; > ; \
+ < "Marco Boerries" ; > ; \
+ < "Michael Bohn" ; > ; \
+ < "Myrzaliyer Bolat" ; > ; \
+ < "Oliver Bolte" ; > ; \
+ < "Berit Bonde" ; > ; \
+ < "Alexander Bootman" ; > ; \
+ < "Csaba Borbola" ; > ; \
+ < "Gregor Bornemann" ; > ; \
+ < "Thorsten Bosbach" ; > ; \
+ < "Eric Bosdonnat" ; > ; \
+ < "Daniel Boss" ; > ; \
+ < "David Boswell" ; > ; \
+ < "Freddy Boswell" ; > ; \
+ < "J.David Boyd" ; > ; \
+ < "Oisin Boydell" ; > ; \
+ < "Rafaella Braconi" ; > ; \
+ < "Cristovad Braga" ; > ; \
+ < "Tanovic Branko" ; > ; \
+ < "Michael Brauer" ; > ; \
+ < "Oliver Braun" ; > ; \
+ < "Andreas Bregas" ; > ; \
+ < "Matthias Breuer" ; > ; \
+ < "Marek Brezina" ; > ; \
+ < "Henning Brinkmann" ; > ; \
+ < "Simon Brouwer" ; > ; \
+ < "Andrew Brown" ; > ; \
+ < "Joerg Brunsmann" ; > ; \
+ < "Joerg Budischewski" ; > ; \
+ < "Nicolae Buculei" ; > ; \
+ < "Ronny Buelund" ; > ; \
+ < "Michael Buettner" ; > ; \
+ < "Edwin Burdak" ; > ; \
+ < "Hans-Peter Burow" ; > ; \
+ < "Aidan Butler" ; > ; \
+ < "Richard Bywater" ; > ; \
+ < "Josef Cacek" ; > ; \
+ < "Guy Capra" ; > ; \
+ < "Gabriele Carcassi" ; > ; \
+ < "Anders Carlsson" ; > ; \
+ < "Brian Cameron" ; > ; \
+ < "Scott Carr" ; > ; \
+ < "Christina L. Carr" ; > ; \
+ < "Mauro Catarzi" ; > ; \
+ < "Daniel Carrera" ; > ; \
+ < "Giuseppe Castagno" ; > ; \
+ < "Centre for Development of Advanced Computing" ; > ; \
+ < "Ales Cernosek" ; > ; \
+ < "Goerkem Cetin" ; > ; \
+ < "Peter Chabada" ; > ; \
+ < "David Chan" ; > ; \
+ < "Tak-Shing Chan of Aleph One Limited" ; > ; \
+ < "Colin Charles" ; > ; \
+ < "Kimmy Chen" ; > ; \
+ < "Robert Chen" ; > ; \
+ < "Yu Aaron Cheng" ; > ; \
+ < "Jian Hong Cheng" ; > ; \
+ < "Xiuzhi Cheng" ; > ; \
+ < "Allan B. Christensen" ; > ; \
+ < "Steen Christensen" ; > ; \
+ < "Marco Ciampa" ; > ; \
+ < "Henrik R. Clausen" ; > ; \
+ < "James Cleere" ; > ; \
+ < "Justin Clift" ; > ; \
+ < "David Cobb" ; > ; \
+ < "Oliver Craemer" ; > ; \
+ < "Vicky Chan" ; > ; \
+ < "Michael J. Cole" ; > ; \
+ < "Urska Colner" ; > ; \
+ < "Alexandro Colorado" ; > ; \
+ < "Compaq Computer Corperation" ; > ; \
+ < "Karen Conatser" ; > ; \
+ < "Confucian Pro. Technology" ; > ; \
+ < "Danese Cooper" ; > ; \
+ < "Lee Corbin" ; > ; \
+ < "Dietmar Cordes" ; > ; \
+ < "Berend Cornelius" ; > ; \
+ < "Clayton Cornell" ; > ; \
+ < "Jesus Corrius" ; > ; \
+ < "Martin Coxall" ; > ; \
+ < "Joszef Csongradi" ; > ; \
+ < "Alessandro Cumin" ; > ; \
+ < "Johannes Czerwinski" ; > ; \
+ < "Michael Cziebalski" ; > ; \
+ < "Valentina Dagiene" ; > ; \
+ < "Richard Daley" ; > ; \
+ < "Viktoras Dagys" ; > ; \
+ < "Dimitrios Dalossis" ; > ; \
+ < "Martin Damboldt" ; > ; \
+ < "Johan Dahlin" ; > ; \
+ < "Goto Daichi" ; > ; \
+ < "Robert Dargaud" ; > ; \
+ < "Yuri Dario" ; > ; \
+ < "Akshay Dayal" ; > ; \
+ < "Simon Dean" ; > ; \
+ < "Denice C. Deatrich" ; > ; \
+ < "Blaise Drayer" ; > ; \
+ < "Francois Dechelle" ; > ; \
+ < "Andrea Decorte" ; > ; \
+ < "Martijn Dekkers" ; > ; \
+ < "Andrew Dent" ; > ; \
+ < "Westley Alan Dent" ; > ; \
+ < "Luiz Augusto Von Dentz" ; > ; \
+ < "Helge Delfs" ; > ; \
+ < "Naren Devaiah" ; > ; \
+ < "Frederic Juan Diaz" ; > ; \
+ < "Scott Dietrich" ; > ; \
+ < "Frederik Dietz" ; > ; \
+ < "Marcel Diki-Kidiri" ; > ; \
+ < "Marian Diklic" ; > ; \
+ < "Sebastian Docktor" ; > ; \
+ < "Vitor Domingos" ; > ; \
+ < "Jean-Francois Donikian" ; > ; \
+ < "Simford Dong" ; > ; \
+ < "Nitri Dongre" ; > ; \
+ < "Thomas Doru" ; > ; \
+ < "Willem van Dorp" ; > ; \
+ < "Radek Doulik" ; > ; \
+ < "Davide Dozza" ; > ; \
+ < "Derek Dreger" ; > ; \
+ < "Carsten Driesner" ; > ; \
+ < "Cristian Driga" ; > ; \
+ < "Petr Dudacek" ; > ; \
+ < "Herbert Duerr" ; > ; \
+ < "Marc Durdin" ; > ; \
+ < "Damien Duportal" ; > ; \
+ < "Dolores Eccles" ; > ; \
+ < "Craig Eddy" ; > ; \
+ < "Florian Effenberger" ; > ; \
+ < "Aleksander Ehrlich" ; > ; \
+ < "Bernd Eilers" ; > ; \
+ < "Terry Ellison" ; > ; \
+ < "Rene Engelhard" ; > ; \
+ < "Mina Erickson" ; > ; \
+ < "Peter Eriksen" ; > ; \
+ < "Per Eriksson" ; > ; \
+ < "Alberto Escudero-Pascual" ; > ; \
+ < "Fabalabs Software GmbH" ; > ; \
+ < "Charles Anthony Fannan" ; > ; \
+ < "Jean-Baptiste Faure" ; > ; \
+ < "Ralf-Michael Fehr" ; > ; \
+ < "Vladimir Fedak" ; > ; \
+ < "Zoltan Fekete" ; > ; \
+ < "Olaf Felka" ; > ; \
+ < "Carlos Fernando" ; > ; \
+ < "Ramon Garcia Fernandez" ; > ; \
+ < "Claudio Ferreira" ; > ; \
+ < "Raquel Fares Ferreira" ; > ; \
+ < "Marco Fiemozzi" ; > ; \
+ < "Claudio F Filho" ; > ; \
+ < "Pierre de Filippis" ; > ; \
+ < "Jan Firich" ; > ; \
+ < "Andre Fischer" ; > ; \
+ < "Helga Fischer" ; > ; \
+ < "Uwe Fischer" ; > ; \
+ < "Darin Fisher" ; > ; \
+ < "Nicole M. Follet-Dunn" ; > ; \
+ < "Kenneth Foskey" ; > ; \
+ < "Duncan Foster" ; > ; \
+ < "Tim Foster" ; > ; \
+ < "David Franser" ; > ; \
+ < "Peter Frandsen" ; > ; \
+ < "Gary Frederick" ; > ; \
+ < "Nils Fuhrmann" ; > ; \
+ < "Jan Funken" ; > ; \
+ < "Bruno Gallart" ; > ; \
+ < "Roberto Galoppini" ; > ; \
+ < "Tom Garland" ; > ; \
+ < "Wolfram Garten" ; > ; \
+ < "Martin Gallwey" ; > ; \
+ < "Pierre-Andre Galmes" ; > ; \
+ < "Roberto Galoppini" ; > ; \
+ < "Tony Galmiche" ; > ; \
+ < "Sunil Gandhi" ; > ; \
+ < "Zemin Gao" ; > ; \
+ < "Sophie Gautier" ; > ; \
+ < "Kathy Gavin" ; > ; \
+ < "Alexander Gelfenbain" ; > ; \
+ < "Genicorp" ; > ; \
+ < "Radim Gelner" ; > ; \
+ < "R.R. Gerbrands" ; > ; \
+ < "Vytautas Germanavicius" ; > ; \
+ < "Berthold Gerdes" ; > ; \
+ < "Gorken Getin" ; > ; \
+ < "Adriana Geurts" ; > ; \
+ < "Marco Giorgetti" ; > ; \
+ < "Thomas Girard" ; > ; \
+ < "Serkan Girgin" ; > ; \
+ < "Vladimir Glazounov" ; > ; \
+ < "Laurent Godard" ; > ; \
+ < "M. Godec" ; > ; \
+ < "Angelika Goeszler" ; > ; \
+ < "Xabier Arrieta Goiri" ; > ; \
+ < "Adam Golebiowski" ; > ; \
+ < "Good Day, Inc. - Seiya Maeda, CEO" ; > ; \
+ < "Ajey Y. Gore" ; > ; \
+ < "Adam Gould" ; > ; \
+ < "Brigitte Le Grand" ; > ; \
+ < "GravityZoo" ; > ; \
+ < "Paul Gress" ; > ; \
+ < "Gintautas Grigas" ; > ; \
+ < "Dirk Grobler" ; > ; \
+ < "Steffen Grund" ; > ; \
+ < "Christian Guenther" ; > ; \
+ < "Marko Gronroos" ; > ; \
+ < "Wojciech Gryc" ; > ; \
+ < "Stefano Guidetti" ; > ; \
+ < "Wilson Guo" ; > ; \
+ < "Brant Langer Gurganus" ; > ; \
+ < "Richard Guziewicz" ; > ; \
+ < "Szabo Gyoergi" ; > ; \
+ < "Bettina Haberer" ; > ; \
+ < "Thomas Hackert" ; > ; \
+ < "David Hackler" ; > ; \
+ < "Fredrik Haegg" ; > ; \
+ < "Ingrid Halama" ; > ; \
+ < "William Neil Hall" ; > ; \
+ < "Chris Halls" ; > ; \
+ < "Arne Christian Harseth" ; > ; \
+ < "Syamsul Anuar Abdul Hamid" ; > ; \
+ < "Bo Han" ; > ; \
+ < "Ove Hanebring" ; > ; \
+ < "Jens K. Hansen" ; > ; \
+ < "Martin Willemoes Hansen" ; > ; \
+ < "Rune Piil Hansen" ; > ; \
+ < "Jeff Hanson" ; > ; \
+ < "Paul Eugene Hanson" ; > ; \
+ < "Christian Hardy" ; > ; \
+ < "Alexey Harlamenkov" ; > ; \
+ < "Taska Harnischfeger" ; > ; \
+ < "Gregor Hartmann" ; > ; \
+ < "Peter Hartmann" ; > ; \
+ < "Andreas Hausmann" ; > ; \
+ < "Bustamam Harun" ; > ; \
+ < "Soren Hauberg" ; > ; \
+ < "Andreas Hausmann" ; > ; \
+ < "Mike Hayes" ; > ; \
+ < "John Heard" ; > ; \
+ < "Florian Heckl" ; > ; \
+ < "Will Heid" ; > ; \
+ < "Reimar Heider" ; > ; \
+ < "Joerg Heilig" ; > ; \
+ < "Lars Jorgen Helbo" ; > ; \
+ < "Bill Heiser" ; > ; \
+ < "Frank Heitbrock" ; > ; \
+ < "Brian Hemstedt" ; > ; \
+ < "Kevin B. Hendricks" ; > ; \
+ < "C.P. Hennessy" ; > ; \
+ < "Gregor Herrman" ; > ; \
+ < "Chris Herrnberger" ; > ; \
+ < "Sven Herzberg" ; > ; \
+ < "Uwe Heth" ; > ; \
+ < "Ariya Hidayat" ; > ; \
+ < "Bernd Hilgenberg" ; > ; \
+ < "Michelle Hills" ; > ; \
+ < "Kazunari Hirano" ; > ; \
+ < "Samual W. Hiser" ; > ; \
+ < "Ivo Hinkelmann" ; > ; \
+ < "Theresa Hinkelman" ; > ; \
+ < "Eric Hoch" ; > ; \
+ < "Lutz Hoeger" ; > ; \
+ < "Michael Hoennig" ; > ; \
+ < "Ilko Hoepping" ; > ; \
+ < "Axel Hoernke" ; > ; \
+ < "Ralf Hofmann" ; > ; \
+ < "Jakob Hojgaard" ; > ; \
+ < "Janos Holanyi" ; > ; \
+ < "Jan Holesovsky" ; > ; \
+ < "Martin Hollmichel" ; > ; \
+ < "Richard Holt" ; > ; \
+ < "Sei Honda" ; > ; \
+ < "Karl Hong" ; > ; \
+ < "Alan Horkan" ; > ; \
+ < "Alexandre Horst" ; > ; \
+ < "Horst" ; > ; \
+ < "Thomas Hosemann" ; > ; \
+ < "Chris Hoypoy" ; > ; \
+ < "Radovan Hrabak" ; > ; \
+ < "Hristo Simeonov Hristov" ; > ; \
+ < "Stanislav Huba" ; > ; \
+ < "Bert Hubert" ; > ; \
+ < "Ralf Hueskes" ; > ; \
+ < "Matthias Huetsch" ; > ; \
+ < "Marco Huggenberger" ; > ; \
+ < "Humboldt-Universitaet zu Berlin" ; > ; \
+ < "James R Hunt" ; > ; \
+ < "Jason Hunter" ; > ; \
+ < "Isabelle Hurbain" ; > ; \
+ < "Gabriel Hurley" ; > ; \
+ < "Emin Huseynov" ; > ; \
+ < "Scott Hutinger" ; > ; \
+ < "Hungarian Linux Users, Association of" ; > ; \
+ < "Thomas Hygum" ; > ; \
+ < "Andreas Hyballa" ; > ; \
+ < "Hasan Ilter" ; > ; \
+ < "Intel Corp." ; > ; \
+ < "International Business Machines" ; > ; \
+ < "Intersol SRL" ; > ; \
+ < "Michael Irion" ; > ; \
+ < "Naoyuki Ishimura" ; > ; \
+ < "Baurzhan Ismagulov" ; > ; \
+ < "Fumihiko Iwabuchi" ; > ; \
+ < "Issendis Alain Curt" ; > ; \
+ < "Pavel Janik" ; > ; \
+ < "Sunil Amitkumar Janki" ; > ; \
+ < "Sven Jacobi" ; > ; \
+ < "Yvonne Jacoby" ; > ; \
+ < "Denis Jacquerye" ; > ; \
+ < "Egle Jasutiene" ; > ; \
+ < "Joerg Jahnke" ; > ; \
+ < "Christian Jansen" ; > ; \
+ < "Ocke Janssen" ; > ; \
+ < "Amer Javaid" ; > ; \
+ < "Andrew T. Jensen" ; > ; \
+ < "Byrial Ole Jensen" ; > ; \
+ < "Ricky Hugh Jensen" ; > ; \
+ < "Tatjiana Jevsikova" ; > ; \
+ < "Berry Jia" ; > ; \
+ < "Mingfei Jia" ; > ; \
+ < "Chuang Jiang" ; > ; \
+ < "Jiao Jianhua" ; > ; \
+ < "Gary Johnston" ; > ; \
+ < "Dewi Jones" ; > ; \
+ < "Henrik Jordt" ; > ; \
+ < "Anders Colding Jorgesen" ; > ; \
+ < "Peter Junge" ; > ; \
+ < "Christian Junker" ; > ; \
+ < "Pascal Junck" ; > ; \
+ < "Henrik Just" ; > ; \
+ < "Christian Kaas" ; > ; \
+ < "Yukata Kachi" ; > ; \
+ < "Natsu Kadoya" ; > ; \
+ < "Szalai Kalman" ; > ; \
+ < "masahisa kamataki" ; > ; \
+ < "Tim Kampa" ; > ; \
+ < "Petr Kania" ; > ; \
+ < "Mick Kappenburg" ; > ; \
+ < "Etsushi Kato" ; > ; \
+ < "Yosuke Kato" ; > ; \
+ < "Hirano Kazunari" ; > ; \
+ < "Mihaela Kedikova" ; > ; \
+ < "Juergen Keil" ; > ; \
+ < "Lina Kemmel" ; > ; \
+ < "Darren Kenny" ; > ; \
+ < "Dhanajay Keskar" ; > ; \
+ < "Ilja Ketris" ; > ; \
+ < "Philipp Kewisch Ketris" ; > ; \
+ < "Ossama Khayat" ; > ; \
+ < "Volodymyr Khrystynych" ; > ; \
+ < "Ilja Ketris" ; > ; \
+ < "Hermann Kienlein" ; > ; \
+ < "Artem Khvat" ; > ; \
+ < "Aijin Kim" ; > ; \
+ < "Jeongkyu Kim" ; > ; \
+ < "Jung-uk Kim" ; > ; \
+ < "Bevis Robert Wearing King" ; > ; \
+ < "Bo Kiersgaard" ; > ; \
+ < "Robert Kinsella" ; > ; \
+ < "Lazsio Kishalmi" ; > ; \
+ < "Andre Kitzing" ; > ; \
+ < "Thomas Klarhoefer" ; > ; \
+ < "Sven Klawitter" ; > ; \
+ < "Branislav Klocok" ; > ; \
+ < "Matthias Klose" ; > ; \
+ < "Halfdan Holger Knudsen" ; > ; \
+ < "Rune Tendal Kock" ; > ; \
+ < "Magdy Samuel Abdel Koddous" ; > ; \
+ < "Charles Peter Koerner" ; > ; \
+ < "Kay Koll" ; > ; \
+ < "Masataka Kondo" ; > ; \
+ < "Soren Kongstad" ; > ; \
+ < "Dimitris Korbetis" ; > ; \
+ < "Uros Kositer" ; > ; \
+ < "Peter Kosmalla" ; > ; \
+ < "Nobuhiro Koura" ; > ; \
+ < "Lazlo Kovacs" ; > ; \
+ < "Martin Kretzchmar" ; > ; \
+ < "Ramesh Krishnamagaru" ; > ; \
+ < "Jayamohan Krishnasamy" ; > ; \
+ < "Erik Kristiansen" ; > ; \
+ < "Jesper Krogh" ; > ; \
+ < "Oliver Krapp" ; > ; \
+ < "Andrey Krutak" ; > ; \
+ < "Andreas Krause" ; > ; \
+ < "Tobias Krause" ; > ; \
+ < "Nigel Kukard" ; > ; \
+ < "Andre Kuemmel" ; > ; \
+ < "Jorma Kuha" ; > ; \
+ < "Mashrab Kuvatov" ; > ; \
+ < "Thorsten Koerner" ; > ; \
+ < "Ralf Kuhnert" ; > ; \
+ < "Gaute Hvoslef Kvalnes" ; > ; \
+ < "Kabrianis & Sia O.E." ; > ; \
+ < "William Rikard Lachance" ; > ; \
+ < "Dominic Lachoucz" ; > ; \
+ < "Sandra Lain" ; > ; \
+ < "Alexandre Lahiniriko" ; > ; \
+ < "Denis Lakcovic" ; > ; \
+ < "Dr. Swapnil Vishnu Lale" ; > ; \
+ < "Antti Lampinen/Kongo Group" ; > ; \
+ < "Massimo Lanfranconi" ; > ; \
+ < "Marcus Lange" ; > ; \
+ < "Peter Lange" ; > ; \
+ < "Thomas Lange" ; > ; \
+ < "Lars Langhans" ; > ; \
+ < "Vance Lankhaar" ; > ; \
+ < "Sébastien Lanteigne" ; > ; \
+ < "Finn Gruwier Larsen" ; > ; \
+ < "Rune S. Larsen" ; > ; \
+ < "Pavel Lastovicka" ; > ; \
+ < "Rimgaudus Laucius" ; > ; \
+ < "Jesper Laugesen" ; > ; \
+ < "David Laurent" ; > ; \
+ < "Thorsten Laux" ; > ; \
+ < "Nemeth Laszlo" ; > ; \
+ < "Hans-Joachim Lankenau (Ause)" ; > ; \
+ < "Athanasios Lefteris" ; > ; \
+ < "Ely Levy" ; > ; \
+ < "Learning and Teaching Scotland" ; > ; \
+ < "Yoann Le Bars" ; > ; \
+ < "Armin Le Grand" ; > ; \
+ < "Brigitte Le Grand" ; > ; \
+ < "Jakob Lechner" ; > ; \
+ < "Michael Leibowitz" ; > ; \
+ < "Serge Le Louarne" ; > ; \
+ < "Dong Lee" ; > ; \
+ < "Kenneth Lee" ; > ; \
+ < "Gregory Leffler" ; > ; \
+ < "Hercule Li" ; > ; \
+ < "Hui Li" ; > ; \
+ < "Jian Li" ; > ; \
+ < "Tommy C. Li" ; > ; \
+ < "Wind Li" ; > ; \
+ < "Xing Li" ; > ; \
+ < "Ping Liao" ; > ; \
+ < "Xin Liao" ; > ; \
+ < "Weike Liang" ; > ; \
+ < "Rony Liemmukda" ; > ; \
+ < "Tor Lillqvist" ; > ; \
+ < "Patranun Limudomporn" ; > ; \
+ < "Archie Lin" ; > ; \
+ < "Fong Lin" ; > ; \
+ < "Martha J. Lindeman" ; > ; \
+ < "Joachim Lingner" ; > ; \
+ < "Christian Lippka" ; > ; \
+ < "Chen Liu" ; > ; \
+ < "Jianli Liu" ; > ; \
+ < "Mindy Liu" ; > ; \
+ < "Tao Liu" ; > ; \
+ < "YiSong Liu" ; > ; \
+ < "Yu Liu" ; > ; \
+ < "Yuhua Liu" ; > ; \
+ < "ALT Linux Russia" ; > ; \
+ < "Jonathan S. Lister" ; > ; \
+ < "Vedran Ljubovic" ; > ; \
+ < "Frank Loehmann" ; > ; \
+ < "Dieter Loeschky" ; > ; \
+ < "Philipp Lohmann" ; > ; \
+ < "Christian Lohmaier" ; > ; \
+ < "Michel Loiseleur" ; > ; \
+ < "Anthony Long" ; > ; \
+ < "Roberto Loprieno" ; > ; \
+ < "Riccardo Losselli" ; > ; \
+ < "Jackson Low" ; > ; \
+ < "Patrick Luby" ; > ; \
+ < "Christoph Lukasiak" ; > ; \
+ < "Robert Ludvik" ; > ; \
+ < "Uwe Luebbers" ; > ; \
+ < "Edgardo Lugaresi" ; > ; \
+ < "Gavin Lu" ; > ; \
+ < "Morton Lund" ; > ; \
+ < "Jingrong Luo" ; > ; \
+ < "Zaoliang Luo" ; > ; \
+ < "Ian Lynch" ; > ; \
+ < "Jun Ma" ; > ; \
+ < "Thomas J.L. MacDermott" ; > ; \
+ < "Marcio A. Macendo" ; > ; \
+ < "George Machitidze" ; > ; \
+ < "Diane Mackay" ; > ; \
+ < "Prasad Madhav" ; > ; \
+ < "Jorgen Madsen" ; > ; \
+ < "Ove Madsen" ; > ; \
+ < "Martin Maher" ; > ; \
+ < "Babak Mahbod" ; > ; \
+ < "Nakata Maho " ; > ; \
+ < "Wad Mahsckoff" ; > ; \
+ < "Milena Majorosova" ; > ; \
+ < "Yonggang Mao" ; > ; \
+ < "Libor Maly" ; > ; \
+ < "Mandrake Soft S.A." ; > ; \
+ < "Libor Maly" ; > ; \
+ < "Mohammed Mamdouh" ; > ; \
+ < "Andreas Mantke" ; > ; \
+ < "Paolo Mantovani" ; > ; \
+ < "Chris Manuh" ; > ; \
+ < "Luisa Della Marina" ; > ; \
+ < "Christian Markgraf" ; > ; \
+ < "John Marmion" ; > ; \
+ < "Adam Marks" ; > ; \
+ < "Dirk Marquardt" ; > ; \
+ < "Tam Marshall" ; > ; \
+ < "Andreas Martens" ; > ; \
+ < "Thorsten Martens" ; > ; \
+ < "Bartosz Maruszewski" ; > ; \
+ < "Jordi Mas" ; > ; \
+ < "Nishida Masanori" ; > ; \
+ < "Yoshiyuki Masutomi" ; > ; \
+ < "Ivan Masar" ; > ; \
+ < "Nishida Masanori" ; > ; \
+ < "Shane M. Mathews" ; > ; \
+ < "Yoshiyuki Masutomi" ; > ; \
+ < "Akira Matsumiya" ; > ; \
+ < "Yoshihiso Matsutani" ; > ; \
+ < "Shinobu Matsuzuka" ; > ; \
+ < "Elizabeth Matthis" ; > ; \
+ < "Michael Maurier, Publishing Power, Inc." ; > ; \
+ < "Frank Mau" ; > ; \
+ < "Izumi Mazur" ; > ; \
+ < "John McCreesh" ; > ; \
+ < "Shaun McDonald" ; > ; \
+ < "Ian McDonnell" ; > ; \
+ < "Caolan McNamara" ; > ; \
+ < "Jacqueline McNally" ; > ; \
+ < "Aaron R. Meck" ; > ; \
+ < "Nirav Mehta" ; > ; \
+ < "Michael Meeks" ; > ; \
+ < "Frederico Mena-Quintero" ; > ; \
+ < "James Meng" ; > ; \
+ < "Frank Meies" ; > ; \
+ < "Antonius Tjipke Meinen" ; > ; \
+ < "Ismael Merzaq" ; > ; \
+ < "Andreas Meyer" ; > ; \
+ < "Markus Meyer" ; > ; \
+ < "Rolf Meyer" ; > ; \
+ < "Djapparova Meruert" ; > ; \
+ < "Ismael Merzaq" ; > ; \
+ < "Michael Mi" ; > ; \
+ < "Bjoern Michaelsen" ; > ; \
+ < "Boris Michelsz" ; > ; \
+ < "Bjoern Milcke" ; > ; \
+ < "Marcin Milkowski" ; > ; \
+ < "Michelle Milledge" ; > ; \
+ < "Aleksander Mikhailov-Erlich" ; > ; \
+ < "Paul A. Miller" ; > ; \
+ < "Arkadiusz Miskiewicz" ; > ; \
+ < "Petr Mladek" ; > ; \
+ < "Erica Modena" ; > ; \
+ < "Filip Molcan" ; > ; \
+ < "Tadeusz Mollun" ; > ; \
+ < "Carl De Monbrun" ; > ; \
+ < "Volker Moneke" ; > ; \
+ < "Takayuki Morisawa" ; > ; \
+ < "Jan Morgils" ; > ; \
+ < "Tim Morley" ; > ; \
+ < "Tomas Mraz" ; > ; \
+ < "Cyrille Moureaux" ; > ; \
+ < "S. Muguntharaj" ; > ; \
+ < "Matthias Mueller-Prove" ; > ; \
+ < "Inaki Larranaga Murgoitio" ; > ; \
+ < "Mark Murnane" ; > ; \
+ < "Jack Murphy" ; > ; \
+ < "Steven Michael Murphy" ; > ; \
+ < "Kris Nackaerts" ; > ; \
+ < "Hiroyuki Nakaji" ; > ; \
+ < "Takashi Nakamoto" ; > ; \
+ < "Maho Nakata" ; > ; \
+ < "National Centre for Software Technology, India" ; > ; \
+ < "Takamichi Nara" ; > ; \
+ < "Peter Naulls" ; > ; \
+ < "Jan Navratil" ; > ; \
+ < "Niklas Nebel" ; > ; \
+ < "Ales Nehyba" ; > ; \
+ < "Christoph Neumann" ; > ; \
+ < "Frank Neumann" ; > ; \
+ < "Marc Neumann" ; > ; \
+ < "Net Integration Technologies, Inc." ; > ; \
+ < "Scott Ng" ; > ; \
+ < "Nam T. Nguyen" ; > ; \
+ < "Jan Normann Nielsen" ; > ; \
+ < "Ko-haw Nieh" ; > ; \
+ < "Peter Van Nieuwenhoven" ; > ; \
+ < "Jan Nieuwenhuizen" ; > ; \
+ < "Dhiraj Nilange" ; > ; \
+ < "Sofia Nilsson" ; > ; \
+ < "Kazutoshi Nimura" ; > ; \
+ < "Jes Drost Nissen" ; > ; \
+ < "Sofia Nilsson" ; > ; \
+ < "Christoph Noack" ; > ; \
+ < "Bertram Nolte" ; > ; \
+ < "Niels Nordmann" ; > ; \
+ < "Michael Novati" ; > ; \
+ < "Novell, Inc.," ; > ; \
+ < "Rodrigo Parra Novo" ; > ; \
+ < "Peter Novodvorsky" ; > ; \
+ < "O3Spaces (C.B Hoeflake)" ; > ; \
+ < "Tomas O'Connor" ; > ; \
+ < "Munzir Taha Obeid" ; > ; \
+ < "Eivind Odegard" ; > ; \
+ < "Maximilian Odendahl" ; > ; \
+ < "Kaoru Oguru" ; > ; \
+ < "Dan Ohnesorg" ; > ; \
+ < "Akira Ohsone" ; > ; \
+ < "Takashi Ono" ; > ; \
+ < "Lars Oppermann" ; > ; \
+ < "Michael Opsahl" ; > ; \
+ < "Anmar Oueja" ; > ; \
+ < "Dana Oliver" ; > ; \
+ < "Shane Owenby" ; > ; \
+ < "Marcin Orowski" ; > ; \
+ < "Takeshi Otsuki" ; > ; \
+ < "Jan-Hendrick Palic" ; > ; \
+ < "Assis Paniago" ; > ; \
+ < "Carlos F.A. Paniago" ; > ; \
+ < "Subiaco Paola" ; > ; \
+ < "Kannada Ganaka Parishat" ; > ; \
+ < "Anna Parovel" ; > ; \
+ < "Pierre Pasteau" ; > ; \
+ < "Shripad Patki" ; > ; \
+ < "Andreas Pauley" ; > ; \
+ < "Viktorija Paulikaite" ; > ; \
+ < "Soren Thing Pedersen" ; > ; \
+ < "Pablo F. Pena IV" ; > ; \
+ < "Mattia Penati" ; > ; \
+ < "Pentaho - James Dixon - " ; > ; \
+ < "Damien Persohn" ; > ; \
+ < "Andrea Pescetti" ; > ; \
+ < "Edward Peterlin" ; > ; \
+ < "Allan Juhl Peterson" ; > ; \
+ < "Frank Peters" ; > ; \
+ < "Bryan Petty" ; > ; \
+ < "John Pfersich" ; > ; \
+ < "Wilhelm Pfluger" ; > ; \
+ < "Thomas Pfohe" ; > ; \
+ < "Yashwant Phatak" ; > ; \
+ < "Nusorn Photpipat" ; > ; \
+ < "Dao-Duy Pierre" ; > ; \
+ < "Juergen Pingel" ; > ; \
+ < "Christof Pintaske" ; > ; \
+ < "Guido Pinkernell" ; > ; \
+ < "Pedro Pinto" ; > ; \
+ < "Saso Pirnat" ; > ; \
+ < "Sebastien Plisson" ; > ; \
+ < "Aurelien Pocheville" ; > ; \
+ < "Pvabhas Pokhavel" ; > ; \
+ < "Ravi Poluri" ; > ; \
+ < "Rastislav Poruban" ; > ; \
+ < "Noel Power" ; > ; \
+ < "Ashwanth Premchandran" ; > ; \
+ < "Marco Pratesi" ; > ; \
+ < "Nikolai Pretzell" ; > ; \
+ < "Nicola Previati" ; > ; \
+ < "Rhoslyn Prys" ; > ; \
+ < "Jaroslaw Jan Pyszny" ; > ; \
+ < "Jonathan Pryor" ; > ; \
+ < "Zhang Qingbin" ; > ; \
+ < "Canghua Qu" ; > ; \
+ < "Volker Quetschke" ; > ; \
+ < "Tino Rachui" ; > ; \
+ < "Radostin Radnev" ; > ; \
+ < "Pramod Raghavendra" ; > ; \
+ < "Adam Rambousek" ; > ; \
+ < "Jacqueline Rahemipour" ; > ; \
+ < "Goran Rakic" ; > ; \
+ < "Adam Rambousek" ; > ; \
+ < "Kay Ramme" ; > ; \
+ < "Klaus Ramstock" ; > ; \
+ < "Scott Rankin" ; > ; \
+ < "Samphan Raruenrom" ; > ; \
+ < "Michael Rasch" ; > ; \
+ < "Ejnar Zacho Rath" ; > ; \
+ < "Eike Rathke" ; > ; \
+ < "Michael Rauch" ; > ; \
+ < "Jens-Heiner Rechtien" ; > ; \
+ < "Red Hat, Inc." ; > ; \
+ < "Itzchack Rehberg" ; > ; \
+ < "Frank Rehberger" ; > ; \
+ < "Michael Reichow" ; > ; \
+ < "Manfred Reiter" ; > ; \
+ < "Eric Renaud" ; > ; \
+ < "Peyronnet Remi" ; > ; \
+ < "Daniel Rentz" ; > ; \
+ < "Florian Reuter" ; > ; \
+ < "Kjell Arne Rekaa" ; > ; \
+ < "Frco. Javier Rial" ; > ; \
+ < "Nicholas Richards" ; > ; \
+ < "Georg Richter" ; > ; \
+ < "Jozef Riha" ; > ; \
+ < "Michael Lee Rilee" ; > ; \
+ < "Modestas Rimkus" ; > ; \
+ < "Jose Ariel Rios" ; > ; \
+ < "Jorge Rivas" ; > ; \
+ < "William Robinson" ; > ; \
+ < "Donald Evan Rogers" ; > ; \
+ < "Willy Sudiarto Rohorjo" ; > ; \
+ < "Hennes Rohling" ; > ; \
+ < "Richard Rolston" ; > ; \
+ < "Christian Romanini" ; > ; \
+ < "Lin Rongheng" ; > ; \
+ < "Dimitri Roschowski" ; > ; \
+ < "Eddie Roosenmaallen" ; > ; \
+ < "Dimitri Roschkowski" ; > ; \
+ < "Bernard Rosenkraenzer" ; > ; \
+ < "Cark Rosschou" ; > ; \
+ < "Thomas Roswall" ; > ; \
+ < "Werner Roth" ; > ; \
+ < "Christian Roy" ; > ; \
+ < "Doug Royer" ; > ; \
+ < "Bill Roth" ; > ; \
+ < "rPath, Inc. (Erik W. Troan)" ; > ; \
+ < "Saverio Rubini" ; > ; \
+ < "Klaus Ruehl" ; > ; \
+ < "Verena Ruff" ; > ; \
+ < "Michael Ruess" ; > ; \
+ < "Peeter Russak" ; > ; \
+ < "Stasys Rutkauskas" ; > ; \
+ < "Frederick K. Saalbach" ; > ; \
+ < "Tobias Sager" ; > ; \
+ < "Enn Saar" ; > ; \
+ < "Reshat Sabiq" ; > ; \
+ < "Amit Kumar Saha" ; > ; \
+ < "Bibek Sahu" ; > ; \
+ < "Reiko Saito" ; > ; \
+ < "Bruno Sant'Anna" ; > ; \
+ < "Roberto Figueiredo Salomon" ; > ; \
+ < "Shkumbim Saneja" ; > ; \
+ < "Janus Sandsgaard" ; > ; \
+ < "Pablo Sarataga" ; > ; \
+ < "Juraj Sarinay" ; > ; \
+ < "Nobuyuki Sasaki" ; > ; \
+ < "Eric Savary" ; > ; \
+ < "Stephan Schaefer" ; > ; \
+ < "Kathryn L. Schenk" ; > ; \
+ < "Harald Schilly" ; > ; \
+ < "Tom Schindl" ; > ; \
+ < "Andreas Schluens" ; > ; \
+ < "Ingo Schmidt-Rosbiegal" ; > ; \
+ < "Juergen Schmidt" ; > ; \
+ < "Andre Schnabel" ; > ; \
+ < "Frank Schoenheit" ; > ; \
+ < "Timon Schroeter" ; > ; \
+ < "Maik Schroeder" ; > ; \
+ < "Sabine Schroeder" ; > ; \
+ < "Admar Schoonen" ; > ; \
+ < "Svante Schubert" ; > ; \
+ < "Friedemann Schuetz" ; > ; \
+ < "Dietrich Schulten" ; > ; \
+ < "Charles Henri Schulz" ; > ; \
+ < "Christoph Schultz" ; > ; \
+ < "Thorsten Schulz" ; > ; \
+ < "Stella Schulze" ; > ; \
+ < "Martin Seelhofer" ; > ; \
+ < "Daniel Seibert" ; > ; \
+ < "Marcella Semboli" ; > ; \
+ < "Julian Seward" ; > ; \
+ < "Shanmugam Senthil" ; > ; \
+ < "Giovanni Sgnaolin" ; > ; \
+ < "Charles Sharp" ; > ; \
+ < "Syed Ahmad Shazali" ; > ; \
+ < "Darragh Sherwin" ; > ; \
+ < "Gia Shervashidze" ; > ; \
+ < "Wei Guo Shi" ; > ; \
+ < "Norikatsu Shigemura" ; > ; \
+ < "Bernhard Siaud" ; > ; \
+ < "Joerg Sievers" ; > ; \
+ < "Silicon Graphic, Inc." ; > ; \
+ < "Maria Augusta Marques da Silva" ; > ; \
+ < "Keld Jorn Simonsen" ; > ; \
+ < "Michael Sicotte" ; > ; \
+ < "Clytie Ann Siddall" ; > ; \
+ < "Raul Siddahartha" ; > ; \
+ < "SIL International (Freddy Boswell)" ; > ; \
+ < "Mukund Sivaraman" ; > ; \
+ < "Manoranjan Kr. Singh" ; > ; \
+ < "G. Roderick Singleton" ; > ; \
+ < "Joerg Skottke" ; > ; \
+ < "Sarah Smith" ; > ; \
+ < "Timothy P. Smith" ; > ; \
+ < "Colm Smyth" ; > ; \
+ < "Javier Sola" ; > ; \
+ < "Inga Solyte" ; > ; \
+ < "Peter Somlo" ; > ; \
+ < "Kai Sommerfeld" ; > ; \
+ < "Young Joo Song" ; > ; \
+ < "Claus Soerensen" ; > ; \
+ < "Sbarnea Sorin" ; > ; \
+ < "Anousak Souphavank" ; > ; \
+ < "Caio Tiago Oliveira de Sousa" ; > ; \
+ < "Oliver Specht" ; > ; \
+ < "Laure Spilker-Four" ; > ; \
+ < "Michael Stahl" ; > ; \
+ < "Irina Stamatoiu" ; > ; \
+ < "Joseph James John Stanford" ; > ; \
+ < "Frank Stecher" ; > ; \
+ < "Boris Steiner" ; > ; \
+ < "Jason Stewart" ; > ; \
+ < "Konrad Stobiecki" ; > ; \
+ < "Arthit Suriyawongkul" ; > ; \
+ < "Lili Sun" ; > ; \
+ < "Erik William Strack" ; > ; \
+ < "Daniel Strome" ; > ; \
+ < "Fridrich Strba" ; > ; \
+ < "Keith Stribley" ; > ; \
+ < "Ulf Stroehler" ; > ; \
+ < "Daniel Strome" ; > ; \
+ < "Louis Suarez-Potts" ; > ; \
+ < "Muthu Subramanian" ; > ; \
+ < "Matthias Suess" ; > ; \
+ < "Tae Hoon Suk of Intellikorea Ca., Ltd." ; > ; \
+ < "Arthit Suriyawongkul" ; > ; \
+ < "SuSE CR, s.r.o" ; > ; \
+ < "Steve Swales" ; > ; \
+ < "Ethan Baggett Swint" ; > ; \
+ < "Kaupo Suviste" ; > ; \
+ < "TK Open Systems Ltd." ; > ; \
+ < "TTC Telecom" ; > ; \
+ < "E. A. Tacao" ; > ; \
+ < "Munzir Taha" ; > ; \
+ < "Hidetoshi Tajima" ; > ; \
+ < "Kazuhiro Hatake Takabatake " ; > ; \
+ < "Taigo Takeda" ; > ; \
+ < "Christina Taliaferro" ; > ; \
+ < "Makoto Takizawa" ; > ; \
+ < "Masaki Tamakoshi" ; > ; \
+ < "Quanfa Tang" ; > ; \
+ < "Alberto Di Taranto" ; > ; \
+ < "David Tardon" ; > ; \
+ < "Uday K. Tashildar" ; > ; \
+ < "Stefan Taxhet" ; > ; \
+ < "William Terry" ; > ; \
+ < "Michal Touzin" ; > ; \
+ < "Techmaprojekt Sp. z.o.o." ; > ; \
+ < "Erwin Tenhumberg" ; > ; \
+ < "William Terry" ; > ; \
+ < "Pietro Emilio Teofilatto" ; > ; \
+ < "Falko Tesch" ; > ; \
+ < "Armin Theissen" ; > ; \
+ < "Christophe Thibierge" ; > ; \
+ < "Michael Thiessne" ; > ; \
+ < "James M. Thompson" ; > ; \
+ < "Holger Thon" ; > ; \
+ < "Alexander Thurgood" ; > ; \
+ < "Caio Tiago Oliveira" ; > ; \
+ < "Lukas Tinkl" ; > ; \
+ < "Gerhard Tonn" ; > ; \
+ < "Istvan Torda" ; > ; \
+ < "Robert J. Townley" ; > ; \
+ < "Christian Treldal" ; > ; \
+ < "Trees for Life, Inc." ; > ; \
+ < "Christian Treldal" ; > ; \
+ < "James Treleaven" ; > ; \
+ < "Tim Tretyak" ; > ; \
+ < "Andreas Treumann" ; > ; \
+ < "Claus Dieter Thoele" ; > ; \
+ < "Filippo Trianni" ; > ; \
+ < "Joshua A. Triplett" ; > ; \
+ < "John Trowbridge" ; > ; \
+ < "Dang Minh Tuan" ; > ; \
+ < "Gianluca Turconi" ; > ; \
+ < "Gunnar Timm" ; > ; \
+ < "Ruediger Timm" ; > ; \
+ < "Malte Timmermann" ; > ; \
+ < "Ralf Unger" ; > ; \
+ < "Manu Unni" ; > ; \
+ < "Iulian Ursache" ; > ; \
+ < "UITE Open Source Armenia" ; > ; \
+ < "John Vandenberg" ; > ; \
+ < "Ain Vagula" ; > ; \
+ < "Mura Valter" ; > ; \
+ < "Elanjelian Venugopal" ; > ; \
+ < "Sven Vermeulen" ; > ; \
+ < "Tom Verbeek" ; > ; \
+ < "Sven Vermeulen" ; > ; \
+ < "Tomas Vesely" ; > ; \
+ < "Kim Viktoriya" ; > ; \
+ < "Sander Vesik" ; > ; \
+ < "Aridane Vilardaga-Viera" ; > ; \
+ < "Adriano Del Vigna" ; > ; \
+ < "Dirk Voelzke" ; > ; \
+ < "Robert Vojta" ; > ; \
+ < "Daniel Vogelheim" ; > ; \
+ < "Mikhail Voitenko" ; > ; \
+ < "Vladimir Vuksan" ; > ; \
+ < "Erno Vuori" ; > ; \
+ < "Radek Vybiral" ; > ; \
+ < "Robert Don Wadley" ; > ; \
+ < "Robert Wagy" ; > ; \
+ < "Martina Waller" ; > ; \
+ < "William Wan" ; > ; \
+ < "Funda Wang" ; > ; \
+ < "Polly Wang" ; > ; \
+ < "Xu Ming Wang" ; > ; \
+ < "Yi Wang" ; > ; \
+ < "Sangay Wangchuk" ; > ; \
+ < "Matthew Wardrop" ; > ; \
+ < "Catherine Waterman" ; > ; \
+ < "Jim Watson" ; > ; \
+ < "Joerg Wartenberg" ; > ; \
+ < "Jean Hollis Weber" ; > ; \
+ < "Martin Webermann" ; > ; \
+ < "Donata Wegener" ; > ; \
+ < "Law Yee Wei" ; > ; \
+ < "Zhao Wei" ; > ; \
+ < "Michel Weimerskirch" ; > ; \
+ < "Prof. Dr. Eduard Werner" ; > ; \
+ < "Michael Wever" ; > ; \
+ < "Brendan Whelan" ; > ; \
+ < "Martin Whitaker" ; > ; \
+ < "Arnulf Wiedemann" ; > ; \
+ < "Franz Wieser" ; > ; \
+ < "Dan Williams" ; > ; \
+ < "Deirdre Williams" ; > ; \
+ < "Michelle C. Williams" ; > ; \
+ < "Miljenko Williams" ; > ; \
+ < "David Noel Wilson" ; > ; \
+ < "Jennifer Winger" ; > ; \
+ < "Oliver-Rainer Wittmann" ; > ; \
+ < "Hans Witvliet" ; > ; \
+ < "Goetz Wohlberg" ; > ; \
+ < "Luciano Miguel Wolf" ; > ; \
+ < "Eugene T.S. Wong" ; > ; \
+ < "Pui Lam Wong" ; > ; \
+ < "Minna Wu" ; > ; \
+ < "Yan Wu" ; > ; \
+ < "Stephan Wunderlich" ; > ; \
+ < "Simos Xenitellis" ; > ; \
+ < "Shun Min Serena Xiao" ; > ; \
+ < "Nat Friedman for Ximian" ; > ; \
+ < "Antonio Xu" ; > ; \
+ < "Dehua Xu" ; > ; \
+ < "Gary Yang" ; > ; \
+ < "Yukiharu Yabuki" ; > ; \
+ < "Kliment Pavlov Yanev" ; > ; \
+ < "Taniguchi Yasuaki" ; > ; \
+ < "Oleg Yegorov" ; > ; \
+ < "Steve Yin" ; > ; \
+ < "Kunihiko Yokota" ; > ; \
+ < "Kim Il Yong" ; > ; \
+ < "Kohei Yoshida" ; > ; \
+ < "Deltasoft Yu" ; > ; \
+ < "Guoqiang Yu" ; > ; \
+ < "Xiaoyang Yu" ; > ; \
+ < "Gary Yuen" ; > ; \
+ < "Christian Zagrodnick" ; > ; \
+ < "George Zahopulos" ; > ; \
+ < "Aidas Zandaris" ; > ; \
+ < "Ernedin Zajko" ; > ; \
+ < "Kurt Zenker" ; > ; \
+ < "Fuxin Zhang" ; > ; \
+ < "Joy Zhang" ; > ; \
+ < "Lei Phill Zhang" ; > ; \
+ < "Xiaofei Zhang" ; > ; \
+ < "Jianwei Zhao" ; > ; \
+ < "May Zhang" ; > ; \
+ < "Jeremy Zheng" ; > ; \
+ < "Thorsten Ziehm" ; > ; \
+ < "Stefan Ziel" ; > ; \
+ < "Jan Zitniak" ; > ; \
+ < "Stefan Zimmermann" ; > ; \
+ < "Mattia Zuliani" ; > ; \
+};
+
+
+#define DEVELOPER_LIST \
+ItemList = \
+{ \
+ < "" ; > ; \
+ < "GENERAL MANAGEMENT" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Michael Bemmer" ; > ; \
+ < "" ; > ; \
+ < "FUNCTIONAL STAFF" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Sabine Huetsch" ; > ; \
+ < "" ; > ; \
+ < "OpenOffice.org COORDINATION" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Stefan Taxhet" ; > ; \
+ < "" ; > ; \
+ < "TECHNICAL ARCHITECT" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Matthias Huetsch" ; > ; \
+ < "Kay Ramme" ; > ; \
+ < "" ; > ; \
+ < "PROGRAM MANAGEMENT" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Joost Andrae" ; > ; \
+ < "Martin Damboldt" ; > ; \
+ < "Martin Hollmichel" ; > ; \
+ < "Andre Kuemmel" ; > ; \
+ < "Marcus Lange" ; > ; \
+ < "Uwe Luebbers" ; > ; \
+ < "" ; > ; \
+ < "" ; > ; \
+ < "%PRODUCTNAME DEVELOPMENT" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Dieter Loeschky" ; > ; \
+ < "" ; > ; \
+ < "TECHNICAL ARCHITECT" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Michael Brauer" ; > ; \
+ < "Malte Timmermann" ; > ; \
+ < "" ; > ; \
+ < "ODF" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Svante Schubert" ; > ; \
+ < "" ; > ; \
+ < "DESIGN" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Stella Schulze" ; > ; \
+ < "" ; > ; \
+ < "Migration" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Michael Bohn" ; > ; \
+ < "" ; > ; \
+ < "%PRODUCTNAME WRITER & FRAMEWORK" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Mathias Bauer" ; > ; \
+ < "" ; > ; \
+ < "Henning Brinkmann" ; > ; \
+ < "Steffen Grund" ; > ; \
+ < "Hans-Peter Burow" ; > ; \
+ < "Carsten Driesner" ; > ; \
+ < "Thomas Lange" ; > ; \
+ < "Andreas Martens" ; > ; \
+ < "Frank Meies" ; > ; \
+ < "Bjoern Michaelsen" ; > ; \
+ < "Andreas Schluens" ; > ; \
+ < "Oliver Specht" ; > ; \
+ < "Oliver-Rainer Wittmann" ; > ; \
+ < "Michael Stahl" ; > ; \
+ < "Mikhail Voitenko" ; > ; \
+ < "" ; > ; \
+ < "%PRODUCTNAME IMPRESS, GRAPHICS & BASE" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Kai Ahrens" ; > ; \
+ < "" ; > ; \
+ < "Volker Ahrendt" ; > ; \
+ < "Herbert Duerr" ; > ; \
+ < "Andre Fischer" ; > ; \
+ < "Ilko Hoepping" ; > ; \
+ < "Sven Jacobi" ; > ; \
+ < "Ocke Janssen" ; > ; \
+ < "Artem Khvat" ; > ; \
+ < "Lars Langhans" ; > ; \
+ < "Armin Le Grand" ; > ; \
+ < "Christian Lippka" ; > ; \
+ < "Philipp Lohmann" ; > ; \
+ < "Frank Schoenheit" ; > ; \
+ < "" ; > ; \
+ < "%PRODUCTNAME PROGRAMMABILITY & DEPLOYMENT" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Kai Sommerfeld" ; > ; \
+ < "" ; > ; \
+ < "Stephan Bergmann" ; > ; \
+ < "Andreas Bregas" ; > ; \
+ < "Steffen Grund" ; > ; \
+ < "Mihaela Kedikova" ; > ; \
+ < "Tobias Krause" ; > ; \
+ < "Joachim Lingner" ; > ; \
+ < "Christoph Neumann" ; > ; \
+ < "Hennes Rohling" ; > ; \
+ < "Juergen Schmidt" ; > ; \
+ < "Ingo Schmidt-Rosbiegal" ; > ; \
+ < "Dirk Voelzke" ; > ; \
+ < "" ; > ; \
+ < "" ; > ; \
+ < "%PRODUCTNAME CALC" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Stephan Schaefer" ; > ; \
+ < "" ; > ; \
+ < "Thomas Benisch" ; > ; \
+ < "Daniel Boelzle" ; > ; \
+ < "Berend Cornelius" ; > ; \
+ < "Ingrid Halama" ; > ; \
+ < "Bjoern Milcke" ; > ; \
+ < "Niklas Nebel" ; > ; \
+ < "Eike Rathke" ; > ; \
+ < "Daniel Rentz" ; > ; \
+ < "" ; > ; \
+ < "" ; > ; \
+ < "USER EXPERIENCE" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Andreas Bartel" ; > ; \
+ < "Bettina Haberer" ; > ; \
+ < "Christian Jansen" ; > ; \
+ < "Frank Loehmann" ; > ; \
+ < "Elizabeth Matthis" ; > ; \
+ < "" ; > ; \
+ < "" ; > ; \
+ < "QUALITY ASSURANCE & COORDINATION" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Nils Fuhrmann" ; > ; \
+ < "" ; > ; \
+ < "" ; > ; \
+ < "RELEASE ENGINEERING " ; 8 ; > ; \
+ < "" ; > ; \
+ < "Ruediger Timm" ; > ; \
+ < "" ; > ; \
+ < "Oliver Bolte" ; > ; \
+ < "Vladimir Glazounov" ; > ; \
+ < "Ivo Hinkelmann" ; > ; \
+ < "Hans-Joachim Lankenau" ; > ; \
+ < "Jens-Heiner Rechtien" ; > ; \
+ < "Kurt Zenker" ; > ; \
+ < "" ; > ; \
+ < "DEVELOPMENT TOOLS" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Joerg Jahnke" ; > ; \
+ < "" ; > ; \
+ < "Bernd Eilers" ; > ; \
+ < "Gregor Hartmann" ; > ; \
+ < "Frank Mau" ; > ; \
+ < "Nikolai Pretzell" ; > ; \
+ < "" ; > ; \
+ < "QUALITY ASSURANCE" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Thorsten Ziehm" ; > ; \
+ < "" ; > ; \
+ < "QA %PRODUCTNAME AUTOMATION" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Thorsten Bosbach" ; > ; \
+ < "Helge Delfs" ; > ; \
+ < "Joerg Sievers" ; > ; \
+ < "" ; > ; \
+ < "QA %PRODUCTNAME WRITER" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Stefan Baltzer" ; > ; \
+ < "Hasan Ilter" ; > ; \
+ < "Michael Ruess" ; > ; \
+ < "Eric Savary" ; > ; \
+ < "Ulf Stroehler" ; > ; \
+ < "" ; > ; \
+ < "QA %PRODUCTNAME CALC" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Oliver Craemer" ; > ; \
+ < "Thomas Klarhoefer" ; > ; \
+ < "Frank Stecher" ; > ; \
+ < "" ; > ; \
+ < "QA %PRODUCTNAME IMPRESS & BASE" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Christoph Lukasiak" ; > ; \
+ < "Marc Neumann" ; > ; \
+ < "Wolfram Garten" ; > ; \
+ < "Christian Guenther" ; > ; \
+ < "" ; > ; \
+ < "QA %PRODUCTNAME INFRASTRUCTURE" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Olaf Felka" ; > ; \
+ < "Thorsten Martens" ; > ; \
+ < "Joerg W. Skottke" ; > ; \
+ < "Andreas Treumann" ; > ; \
+ < "" ; > ; \
+ < "INFORMATION TECHNOLOGY" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Dirk Marquardt" ; > ; \
+ < "Gerd Weiss" ; > ; \
+ < "" ; > ; \
+ < "" ; > ; \
+ < "MANUALS & ONLINE HELP" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Frank Peters" ; > ; \
+ < "" ; > ; \
+ < "Clayton Cornell" ; > ; \
+ < "Uwe Fischer" ; > ; \
+ < "Martina Waller" ; > ; \
+ < "" ; > ; \
+ < "" ; > ; \
+ < "GLOBALIZATION PROGRAM MANAGEMENT" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Rafaella Braconi" ; > ; \
+ < "" ; > ; \
+ < "MARKETING & OPERATIONS" ; 8 ; > ; \
+ < "" ; > ; \
+ < "PRODUCT MANAGMENT" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Goetz Wohlberg" ; > ; \
+ < "Lutz Hoeger" ; > ; \
+ < "" ; > ; \
+ < "MARKETING" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Rosana Ardila Biela" ; > ; \
+ < "Kay Koll" ; > ; \
+ < "Iyer Venkatesan" ; > ; \
+ < "" ; > ; \
+ < "OPERATIONS" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Parker Proffitt" ; > ; \
+ < "" ; > ; \
+ < "SUN SIGMA BLACK BELT" ; 8 ; > ; \
+ < "" ; > ; \
+ < "Stefan Zimmermann" ; > ; \
+ < "" ; > ; \
+};\
+
+#define TEXT_DEFAULTABOUT \
+ Text [ x-comment ] = "PB: ; PB: only %PRODUCTNAME"; \
+ Text [ en-US ] = "About %PRODUCTNAME" ; \
+
+// ******************************************************************* EOF
+
diff --git a/svx/source/intro/iso.src b/svx/source/intro/iso.src
new file mode 100644
index 000000000000..a7395f49be81
--- /dev/null
+++ b/svx/source/intro/iso.src
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * 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 _SVTOOLS_IMAGEMGR_HRC
+#include <svtools/imagemgr.hrc>
+#endif
+
+#ifndef _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+
+#include "intro.hrc"
+String RID_APPTITLE
+{
+ Text = "%PRODUCTNAME %PRODUCTVERSION %PRODUCTEXTENSION" ;
+};
+
+// der String wird fuer die Registrierung gebraucht: 01 Voll, 02 OEM, 03 Vobis
+String STR_VERSION_TYPE
+{
+ Text = "01";
+};
+
+// der String wird fuer die Registrierung gebraucht - hier steht die Version zweistellig!
+String STR_VERSION_ID
+{
+ Text = "50";
+};
+
+String RID_BUILDVERSION
+{
+ Text = UPDVER ;
+};
+
+ModalDialog RID_DEFAULTABOUT
+{
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( 245 , 260 ) ;
+ Moveable = TRUE ;
+ SVLook = TRUE ;
+ TEXT_DEFAULTABOUT
+ OKButton ABOUT_BTN_OK
+ {
+ DefButton = TRUE ;
+ Pos = MAP_APPFONT ( 174 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ FixedText ABOUT_FTXT_VERSION
+ {
+ Pos = MAP_APPFONT ( 54 , 6 ) ;
+ Size = MAP_APPFONT ( 118 , 16 ) ;
+ WordBreak = TRUE ;
+ Text = "%PRODUCTNAME %ABOUTBOXPRODUCTVERSION %PRODUCTEXTENSION" ;
+ };
+ MultiLineEdit ABOUT_FTXT_COPYRIGHT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 54 , 25 ) ;
+ Size = MAP_APPFONT ( 168 , 51 ) ;
+ IgnoreTab = TRUE ;
+ ReadOnly = TRUE ;
+ AutoVScroll = TRUE ;
+ };
+ String ABOUT_STR_COPYRIGHT
+ {
+ Text[ en-US ] = "Copyright © 1995, 2010, Oracle and/or its affiliates. All rights reserved.\n\nThis software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.\n\nThe information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.\n\nIf this software or related documentation is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable:\n\nU.S. GOVERNMENT RIGHTS\nPrograms, software, databases, and related documentation and technical data delivered to U.S. Government customers are \"commercial computer software\" or \"commercial technical data\" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms set forth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007). Oracle USA, Inc., 500 Oracle Parkway, Redwood City, CA 94065.\n\nThis software is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications which may create a risk of personal injury. If you use this software in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure the safe use of this software. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software in dangerous applications.\n\nOracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.\n\nThis software and documentation may provide access to or information on content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services.\n\nThis product is based on the OpenOffice.org project.";
+ };
+ StringArray ABOUT_STR_DEVELOPER_ARY
+ {
+ DEVELOPER_LIST
+ };
+ String ABOUT_STR_FRENCH_COPYRIGHT
+ {
+ Text = "Copyright © 1995, 2010, Oracle and/or its affiliates. All rights reserved.\n\nThis software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.\n\nThe information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.\n\nIf this software or related documentation is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable:\n\nU.S. GOVERNMENT RIGHTS\nPrograms, software, databases, and related documentation and technical data delivered to U.S. Government customers are ""commercial computer software"" or ""commercial technical data"" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms set forth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007). Oracle USA, Inc., 500 Oracle Parkway, Redwood City, CA 94065.\n\nThis software is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications which may create a risk of personal injury. If you use this software in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure the safe use of this software. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software in dangerous applications.\n\nOracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.\n\nThis software and documentation may provide access to or information on content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services.\n\nThis product is based on the OpenOffice.org project." ;
+ };
+ String ABOUT_STR_ACCEL
+ {
+ Text = "SDT" ;
+ };
+};
+
+#define MASK_COL MaskColor = Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; } ;
+#define IMGLST_IDLST \
+ IdList = { \
+ SID_GENERAL_OPTIONS; \
+ SID_LANGUAGE_OPTIONS; \
+ SID_INET_DLG; \
+ SID_SW_EDITOPTIONS; \
+ SID_SW_ONLINEOPTIONS; \
+ SID_SC_EDITOPTIONS; \
+ SID_SD_EDITOPTIONS; \
+ SID_SD_GRAPHIC_OPTIONS; \
+ SID_SM_EDITOPTIONS; \
+ SID_SCH_EDITOPTIONS; \
+ SID_SB_STARBASEOPTIONS; \
+ SID_FILTER_DLG; \
+ }; \
+ IdCount = { \
+ 12; \
+ };
+
+ImageList RID_IMGLIST_TREEOPT
+{
+ Prefix = "tr";
+ MASK_COL
+ IMGLST_IDLST
+};
+ImageList RID_IMGLIST_TREEOPT_HC
+{
+ Prefix = "trh";
+ MASK_COL
+ IMGLST_IDLST
+};
+
+#define MASK_COL2 MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; } ;
+#define X_IMAGE_LIST \
+ IdList = { \
+ IMG_IMPRESS ; \
+ IMG_CALC ; \
+ IMG_CALCTEMPLATE ; \
+ IMG_CHART ; \
+ IMG_IMPRESSTEMPLATE ; \
+ IMG_HTML ; \
+ IMG_MATH ; \
+ IMG_WRITER ; \
+ IMG_WRITERTEMPLATE ; \
+ IMG_MACROLIB ; \
+ IMG_GLOBAL_DOC ; \
+ IMG_DRAW ; \
+ IMG_DRAWTEMPLATE ; \
+ IMG_NEWFROMTEMPLATE ; \
+ IMG_DATABASE ; \
+ }; \
+ IdCount = { \
+ 15; \
+ };
+
+ImageList RID_SVTOOLS_IMAGELIST_BIG
+{
+ Prefix = "lx";
+ MASK_COL2
+ X_IMAGE_LIST
+};
+
+ImageList RID_SVTOOLS_IMAGELIST_SMALL
+{
+ Prefix = "sx";
+ MASK_COL2
+ X_IMAGE_LIST
+};
+
+ImageList RID_SVTOOLS_IMAGELIST_BIG_HIGHCONTRAST
+{
+ Prefix = "lxh";
+ MASK_COL2
+ X_IMAGE_LIST
+};
+
+ImageList RID_SVTOOLS_IMAGELIST_SMALL_HIGHCONTRAST
+{
+ Prefix = "sxh";
+ MASK_COL2
+ X_IMAGE_LIST
+};
+
+// ******************************************************************* EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/intro/makefile.mk b/svx/source/intro/makefile.mk
new file mode 100644
index 000000000000..4d0686baac04
--- /dev/null
+++ b/svx/source/intro/makefile.mk
@@ -0,0 +1,66 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+PRJ=..$/..$
+
+PRJNAME=svx
+TARGET=intro
+
+# --- Settings ------------------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+RSCLOCINC!:=$(RSCLOCINC);$(PRJ)$/RES
+
+# --- Allgemein -----------------------------------------------------------
+
+LOCALIZE_ME=intro_tmpl.hrc
+
+SRS1NAME= iso
+SRC1FILES= \
+ $(SRS1NAME).src
+
+RESLIB1NAME=$(SRS1NAME)
+RESLIB1IMAGES=$(PRJ)$/res
+RESLIB1SRSFILES= \
+ $(SRS)$/$(SRS1NAME).srs
+
+# Version "OpenOffice.org"
+SRS2NAME= ooo
+SRC2FILES= \
+ $(SRS2NAME).src
+
+RESLIB2NAME=$(SRS2NAME)
+RESLIB2IMAGES=$(PRJ)$/res
+RESLIB2SRSFILES= \
+ $(SRS)$/$(SRS2NAME).srs
+
+.INCLUDE : target.mk
+
+$(SRS)$/iso.srs: $(INCCOM)$/intro.hrc
+$(SRS)$/ooo.srs: $(INCCOM)$/intro.hrc
+
diff --git a/svx/source/intro/ooo.src b/svx/source/intro/ooo.src
new file mode 100644
index 000000000000..635789d51482
--- /dev/null
+++ b/svx/source/intro/ooo.src
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * 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 _SVTOOLS_HRC
+#include <svtools/svtools.hrc>
+#endif
+
+#ifndef _SVTOOLS_IMAGEMGR_HRC
+#include <svtools/imagemgr.hrc>
+#endif
+
+#ifndef _SFX_HRC
+#include <sfx2/sfx.hrc>
+#endif
+
+#include <svx/svxids.hrc>
+#include "intro.hrc"
+
+String RID_APPTITLE
+{
+ Text = "%PRODUCTNAME %PRODUCTVERSION %PRODUCTEXTENSION" ;
+};
+
+// der String wird fuer die Registrierung gebraucht: 01 Voll, 02 OEM, 03 Vobis
+String STR_VERSION_TYPE
+{
+ Text = "01";
+};
+
+// der String wird fuer die Registrierung gebraucht - hier steht die Version zweistellig!
+String STR_VERSION_ID
+{
+ Text = "50";
+};
+
+String RID_BUILDVERSION
+{
+ Text = UPDVER ;
+};
+
+ModalDialog RID_DEFAULTABOUT
+{
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( 245 , 280 ) ;
+ Moveable = TRUE ;
+ SVLook = TRUE ;
+ TEXT_DEFAULTABOUT
+ OKButton ABOUT_BTN_OK
+ {
+ DefButton = TRUE ;
+ Pos = MAP_APPFONT ( 174 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ MultiLineEdit ABOUT_FTXT_VERSION
+ {
+ Border = FALSE ;
+ Pos = MAP_APPFONT ( 54 , 6 ) ;
+ Size = MAP_APPFONT ( 118 , 16 ) ;
+ IgnoreTab = TRUE ;
+ ReadOnly = TRUE ;
+ AutoVScroll = TRUE ;
+ };
+ MultiLineEdit ABOUT_FTXT_COPYRIGHT
+ {
+ Border = FALSE ;
+ Pos = MAP_APPFONT ( 54 , 25 ) ;
+ Size = MAP_APPFONT ( 168 , 71 ) ;
+ IgnoreTab = TRUE ;
+ ReadOnly = TRUE ;
+ AutoVScroll = TRUE ;
+ };
+ FixedText ABOUT_FTXT_LINK
+ {
+ NoLabel = TRUE;
+ TabStop = TRUE;
+ Text [ en-US ] = "Contributor credits";
+ Pos = MAP_APPFONT ( 54 , 100 ) ;
+ Size = MAP_APPFONT ( 168 , 10 ) ;
+ };
+ String ABOUT_STR_VERSION
+ {
+ Text[ en-US ] = "%PRODUCTNAME %ABOUTBOXPRODUCTVERSION %PRODUCTEXTENSION";
+ };
+ String ABOUT_STR_COPYRIGHT
+ {
+ Text[ en-US ] = "Copyright © 2000, 2010 LibreOffice contributors and/or their affiliates. All rights reserved.\nThis product was created by %OOOVENDOR, based on OpenOffice.org, which is Copyright 2000, 2010 Oracle and/or its affiliates.\n%OOOVENDOR acknowledges all community members, please find more info at the link below:";
+ };
+ String ABOUT_STR_LINK
+ {
+ Text[ en-US ] = "http://www.libreoffice.org/credits.html";
+ };
+ StringArray ABOUT_STR_DEVELOPER_ARY
+ {
+ OOO_CONTRIBUTOR_LIST
+ };
+ String ABOUT_STR_ACCEL
+ {
+ Text = "SDT" ;
+ };
+};
+
+// imagelist with images of the "New" menu and the file open dialog
+
+#define MASK_COL2 MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; } ;
+#define X_IMAGE_LIST \
+ IdList = { \
+ IMG_IMPRESS ; \
+ IMG_CALC ; \
+ IMG_CALCTEMPLATE ; \
+ IMG_CHART ; \
+ IMG_IMPRESSTEMPLATE ; \
+ IMG_HTML ; \
+ IMG_MATH ; \
+ IMG_WRITER ; \
+ IMG_WRITERTEMPLATE ; \
+ IMG_MACROLIB ; \
+ IMG_GLOBAL_DOC ; \
+ IMG_DRAW ; \
+ IMG_DRAWTEMPLATE ; \
+ IMG_NEWFROMTEMPLATE ; \
+ IMG_DATABASE; \
+ }; \
+ IdCount = { \
+ 15; \
+ };
+
+ImageList RID_SVTOOLS_IMAGELIST_BIG
+{
+ Prefix = "lx";
+ MASK_COL2
+ X_IMAGE_LIST
+};
+
+ImageList RID_SVTOOLS_IMAGELIST_SMALL
+{
+ Prefix = "sx";
+ MASK_COL2
+ X_IMAGE_LIST
+};
+
+ImageList RID_SVTOOLS_IMAGELIST_BIG_HIGHCONTRAST
+{
+ Prefix = "lxh";
+ MASK_COL2
+ X_IMAGE_LIST
+};
+
+ImageList RID_SVTOOLS_IMAGELIST_SMALL_HIGHCONTRAST
+{
+ Prefix = "sxh";
+ MASK_COL2
+ X_IMAGE_LIST
+};
+
+#define MASK_COL MaskColor = Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; } ;
+#define IMGLST_IDLST \
+ IdList = { \
+ SID_GENERAL_OPTIONS; \
+ SID_LANGUAGE_OPTIONS; \
+ SID_INET_DLG; \
+ SID_SW_EDITOPTIONS; \
+ SID_SW_ONLINEOPTIONS; \
+ SID_SC_EDITOPTIONS; \
+ SID_SD_EDITOPTIONS; \
+ SID_SD_GRAPHIC_OPTIONS; \
+ SID_SM_EDITOPTIONS; \
+ SID_SCH_EDITOPTIONS; \
+ SID_SB_STARBASEOPTIONS; \
+ SID_FILTER_DLG; \
+ }; \
+ IdCount = { \
+ 12; \
+ };
+
+ImageList RID_IMGLIST_TREEOPT
+{
+ Prefix = "tr";
+ MASK_COL
+ IMGLST_IDLST
+};
+
+ImageList RID_IMGLIST_TREEOPT_HC
+{
+ Prefix = "trh";
+ MASK_COL
+ IMGLST_IDLST
+};
+
diff --git a/svx/source/items/SmartTagItem.cxx b/svx/source/items/SmartTagItem.cxx
new file mode 100644
index 000000000000..c16a739db4d3
--- /dev/null
+++ b/svx/source/items/SmartTagItem.cxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/SmartTagItem.hxx>
+
+#include <com/sun/star/container/XStringKeyMap.hpp>
+
+
+using namespace ::com::sun::star;
+
+TYPEINIT1(SvxSmartTagItem, SfxPoolItem);
+
+// class SvxFontItem -----------------------------------------------------
+
+SvxSmartTagItem::SvxSmartTagItem( const USHORT nId,
+ const com::sun::star::uno::Sequence < com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::smarttags::XSmartTagAction > > >& rActionComponentsSequence,
+ const com::sun::star::uno::Sequence < com::sun::star::uno::Sequence< sal_Int32 > >& rActionIndicesSequence,
+ const com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::container::XStringKeyMap > >& rStringKeyMaps,
+ const com::sun::star::uno::Reference<com::sun::star::text::XTextRange> rRange,
+ const com::sun::star::uno::Reference<com::sun::star::frame::XController> rController,
+ const com::sun::star::lang::Locale rLocale,
+ const rtl::OUString& rApplicationName,
+ const rtl::OUString& rRangeText ) :
+ SfxPoolItem( nId ),
+ maActionComponentsSequence( rActionComponentsSequence ),
+ maActionIndicesSequence( rActionIndicesSequence ),
+ maStringKeyMaps( rStringKeyMaps ),
+ mxRange( rRange ),
+ mxController( rController ),
+ maLocale( rLocale ),
+ maApplicationName( rApplicationName ),
+ maRangeText( rRangeText )
+{
+}
+
+// -----------------------------------------------------------------------
+
+// -----------------------------------------------------------------------
+
+bool SvxSmartTagItem::QueryValue( uno::Any& /* rVal */, BYTE /* nMemberId */ ) const
+{
+ return false;
+}
+// -----------------------------------------------------------------------
+bool SvxSmartTagItem::PutValue( const uno::Any& /*rVal*/, BYTE /* nMemberId */)
+{
+ return false;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxSmartTagItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
+
+ const SvxSmartTagItem& rItem = static_cast<const SvxSmartTagItem&>(rAttr);
+
+ int bRet = maActionComponentsSequence == rItem.maActionComponentsSequence &&
+ maActionIndicesSequence == rItem.maActionIndicesSequence &&
+ maStringKeyMaps == rItem.maStringKeyMaps &&
+ mxRange == rItem.mxRange &&
+ mxController == rItem.mxController &&
+ maApplicationName == rItem.maApplicationName &&
+ maRangeText == rItem.maRangeText;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxSmartTagItem::Clone( SfxItemPool * ) const
+{
+ return new SvxSmartTagItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SvxSmartTagItem::Store( SvStream& rStream, USHORT /*nItemVersion*/ ) const
+{
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxSmartTagItem::Create(SvStream& , USHORT) const
+{
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/algitem.cxx b/svx/source/items/algitem.cxx
new file mode 100644
index 000000000000..6cd41d513bdb
--- /dev/null
+++ b/svx/source/items/algitem.cxx
@@ -0,0 +1,438 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svxitems.hrc>
+
+
+#include <tools/stream.hxx>
+#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/table/ShadowLocation.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/table/ShadowFormat.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/table/CellContentType.hpp>
+#include <com/sun/star/table/TableOrientation.hpp>
+#include <com/sun/star/util/SortField.hpp>
+#include <com/sun/star/util/SortFieldType.hpp>
+#include <com/sun/star/table/CellOrientation.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+
+#include <svx/algitem.hxx>
+#include <svx/dialmgr.hxx>
+#include <editeng/itemtype.hxx>
+#include <svx/unomid.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+// Konvertierung fuer UNO
+#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
+#define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
+
+// STATIC DATA -----------------------------------------------------------
+
+//TYPEINIT1_AUTOFACTORY( SvxHorJustifyItem, SfxEnumItem );
+TYPEINIT1_FACTORY( SvxOrientationItem, SfxEnumItem, new SvxOrientationItem(SVX_ORIENTATION_STANDARD, 0) );
+TYPEINIT1_FACTORY( SvxMarginItem, SfxPoolItem, new SvxMarginItem(0) );
+
+// class SvxOrientationItem ----------------------------------------------
+
+SvxOrientationItem::SvxOrientationItem( const SvxCellOrientation eOrientation,
+ const USHORT nId):
+ SfxEnumItem( nId, (USHORT)eOrientation )
+{
+}
+
+SvxOrientationItem::SvxOrientationItem( INT32 nRotation, BOOL bStacked, const USHORT nId ) :
+ SfxEnumItem( nId )
+{
+ SetFromRotation( nRotation, bStacked );
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxOrientationItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper * ) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetValueText( GetValue() );
+ return SFX_ITEM_PRESENTATION_COMPLETE;
+ default: ; //prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//------------------------------------------------------------------------
+
+bool SvxOrientationItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ table::CellOrientation eUno = table::CellOrientation_STANDARD;
+ switch ( (SvxCellOrientation)GetValue() )
+ {
+ case SVX_ORIENTATION_STANDARD: eUno = table::CellOrientation_STANDARD; break;
+ case SVX_ORIENTATION_TOPBOTTOM: eUno = table::CellOrientation_TOPBOTTOM; break;
+ case SVX_ORIENTATION_BOTTOMTOP: eUno = table::CellOrientation_BOTTOMTOP; break;
+ case SVX_ORIENTATION_STACKED: eUno = table::CellOrientation_STACKED; break;
+ }
+ rVal <<= eUno;
+ return true;
+}
+
+bool SvxOrientationItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ table::CellOrientation eOrient;
+ if(!(rVal >>= eOrient))
+ {
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return sal_False;
+ eOrient = (table::CellOrientation)nValue;
+ }
+ SvxCellOrientation eSvx = SVX_ORIENTATION_STANDARD;
+ switch (eOrient)
+ {
+ case table::CellOrientation_STANDARD: eSvx = SVX_ORIENTATION_STANDARD; break;
+ case table::CellOrientation_TOPBOTTOM: eSvx = SVX_ORIENTATION_TOPBOTTOM; break;
+ case table::CellOrientation_BOTTOMTOP: eSvx = SVX_ORIENTATION_BOTTOMTOP; break;
+ case table::CellOrientation_STACKED: eSvx = SVX_ORIENTATION_STACKED; break;
+ default: ; //prevent warning
+ }
+ SetValue( (USHORT)eSvx );
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+XubString SvxOrientationItem::GetValueText( USHORT nVal ) const
+{
+ DBG_ASSERT( nVal <= SVX_ORIENTATION_STACKED, "enum overflow!" );
+ return SVX_RESSTR(RID_SVXITEMS_ORI_STANDARD + nVal);
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxOrientationItem::Clone( SfxItemPool* ) const
+{
+ return new SvxOrientationItem( *this );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxOrientationItem::Create( SvStream& rStream, USHORT ) const
+{
+ USHORT nVal;
+ rStream >> nVal;
+ return new SvxOrientationItem( (SvxCellOrientation)nVal, Which() );
+}
+
+//------------------------------------------------------------------------
+
+USHORT SvxOrientationItem::GetValueCount() const
+{
+ return SVX_ORIENTATION_STACKED + 1; // letzter Enum-Wert + 1
+}
+
+//------------------------------------------------------------------------
+
+BOOL SvxOrientationItem::IsStacked() const
+{
+ return static_cast< SvxCellOrientation >( GetValue() ) == SVX_ORIENTATION_STACKED;
+}
+
+INT32 SvxOrientationItem::GetRotation( INT32 nStdAngle ) const
+{
+ INT32 nAngle = nStdAngle;
+ switch( static_cast< SvxCellOrientation >( GetValue() ) )
+ {
+ case SVX_ORIENTATION_BOTTOMTOP: nAngle = 9000;
+ case SVX_ORIENTATION_TOPBOTTOM: nAngle = 27000;
+ default: ; //prevent warning
+ }
+ return nAngle;
+}
+
+void SvxOrientationItem::SetFromRotation( INT32 nRotation, BOOL bStacked )
+{
+ if( bStacked )
+ {
+ SetValue( SVX_ORIENTATION_STACKED );
+ }
+ else switch( nRotation )
+ {
+ case 9000: SetValue( SVX_ORIENTATION_BOTTOMTOP ); break;
+ case 27000: SetValue( SVX_ORIENTATION_TOPBOTTOM ); break;
+ default: SetValue( SVX_ORIENTATION_STANDARD );
+ }
+}
+
+// class SvxMarginItem ---------------------------------------------------
+
+SvxMarginItem::SvxMarginItem( const USHORT nId ) :
+
+ SfxPoolItem( nId ),
+
+ nLeftMargin ( 20 ),
+ nTopMargin ( 20 ),
+ nRightMargin ( 20 ),
+ nBottomMargin( 20 )
+{
+}
+
+//------------------------------------------------------------------------
+
+SvxMarginItem::SvxMarginItem( sal_Int16 nLeft,
+ sal_Int16 nTop,
+ sal_Int16 nRight,
+ sal_Int16 nBottom,
+ const USHORT nId ) :
+ SfxPoolItem( nId ),
+
+ nLeftMargin ( nLeft ),
+ nTopMargin ( nTop ),
+ nRightMargin ( nRight ),
+ nBottomMargin( nBottom )
+{
+}
+
+
+//------------------------------------------------------------------------
+
+SvxMarginItem::SvxMarginItem( const SvxMarginItem& rItem ) :
+
+ SfxPoolItem( rItem.Which() )
+{
+ nLeftMargin = rItem.nLeftMargin;
+ nTopMargin = rItem.nTopMargin;
+ nRightMargin = rItem.nRightMargin;
+ nBottomMargin = rItem.nBottomMargin;
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxMarginItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit ePresUnit,
+ XubString& rText, const IntlWrapper *pIntl
+) const
+{
+#ifndef SVX_LIGHT
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ {
+ rText = GetMetricText( (long)nLeftMargin, eCoreUnit, ePresUnit, pIntl );
+ rText += cpDelim;
+ rText += GetMetricText( (long)nTopMargin, eCoreUnit, ePresUnit, pIntl );
+ rText += cpDelim;
+ rText += GetMetricText( (long)nRightMargin, eCoreUnit, ePresUnit, pIntl );
+ rText += cpDelim;
+ rText += GetMetricText( (long)nBottomMargin, eCoreUnit, ePresUnit, pIntl );
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+ }
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ rText = SVX_RESSTR(RID_SVXITEMS_MARGIN_LEFT);
+ rText += GetMetricText( (long)nLeftMargin, eCoreUnit, ePresUnit, pIntl );
+ rText += SVX_RESSTR(GetMetricId(ePresUnit));
+ rText += cpDelim;
+ rText += SVX_RESSTR(RID_SVXITEMS_MARGIN_TOP);
+ rText += GetMetricText( (long)nTopMargin, eCoreUnit, ePresUnit, pIntl );
+ rText += SVX_RESSTR(GetMetricId(ePresUnit));
+ rText += cpDelim;
+ rText += SVX_RESSTR(RID_SVXITEMS_MARGIN_RIGHT);
+ rText += GetMetricText( (long)nRightMargin, eCoreUnit, ePresUnit, pIntl );
+ rText += SVX_RESSTR(GetMetricId(ePresUnit));
+ rText += cpDelim;
+ rText += SVX_RESSTR(RID_SVXITEMS_MARGIN_BOTTOM);
+ rText += GetMetricText( (long)nBottomMargin, eCoreUnit, ePresUnit, pIntl );
+ rText += SVX_RESSTR(GetMetricId(ePresUnit));
+ return SFX_ITEM_PRESENTATION_COMPLETE;
+ }
+ default: ; //prevent warning
+ }
+#endif
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//------------------------------------------------------------------------
+
+int SvxMarginItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+
+ return ( ( nLeftMargin == ( (SvxMarginItem&)rItem ).nLeftMargin ) &&
+ ( nTopMargin == ( (SvxMarginItem&)rItem ).nTopMargin ) &&
+ ( nRightMargin == ( (SvxMarginItem&)rItem ).nRightMargin ) &&
+ ( nBottomMargin == ( (SvxMarginItem&)rItem ).nBottomMargin ) );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxMarginItem::Clone( SfxItemPool* ) const
+{
+ return new SvxMarginItem(*this);
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxMarginItem::Create( SvStream& rStream, USHORT ) const
+{
+ sal_Int16 nLeft;
+ sal_Int16 nTop;
+ sal_Int16 nRight;
+ sal_Int16 nBottom;
+ rStream >> nLeft;
+ rStream >> nTop;
+ rStream >> nRight;
+ rStream >> nBottom;
+ return new SvxMarginItem( nLeft, nTop, nRight, nBottom, Which() );
+}
+
+//------------------------------------------------------------------------
+
+SvStream& SvxMarginItem::Store( SvStream &rStream, USHORT /*nItemVersion*/) const
+{
+ rStream << nLeftMargin;
+ rStream << nTopMargin;
+ rStream << nRightMargin;
+ rStream << nBottomMargin;
+ return rStream;
+}
+
+
+//------------------------------------------------------------------------
+
+bool SvxMarginItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ // jetzt alles signed
+ case MID_MARGIN_L_MARGIN:
+ rVal <<= (sal_Int32)( bConvert ? TWIP_TO_MM100(nLeftMargin) : nLeftMargin );
+ break;
+ case MID_MARGIN_R_MARGIN:
+ rVal <<= (sal_Int32)( bConvert ? TWIP_TO_MM100(nRightMargin) : nRightMargin );
+ break;
+ case MID_MARGIN_UP_MARGIN:
+ rVal <<= (sal_Int32)( bConvert ? TWIP_TO_MM100(nTopMargin) : nTopMargin );
+ break;
+ case MID_MARGIN_LO_MARGIN:
+ rVal <<= (sal_Int32)( bConvert ? TWIP_TO_MM100(nBottomMargin) : nBottomMargin );
+ break;
+ default:
+ DBG_ERROR("unknown MemberId");
+ return false;
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+bool SvxMarginItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
+{
+ sal_Bool bConvert = ( ( nMemberId & CONVERT_TWIPS ) != 0 );
+ long nMaxVal = bConvert ? TWIP_TO_MM100(SHRT_MAX) : SHRT_MAX; // Members sind sal_Int16
+ sal_Int32 nVal = 0;
+ if(!(rVal >>= nVal) || (nVal > nMaxVal))
+ return sal_False;
+
+ switch ( nMemberId & ~CONVERT_TWIPS )
+ {
+ case MID_MARGIN_L_MARGIN:
+ nLeftMargin = (sal_Int16)( bConvert ? MM100_TO_TWIP(nVal) : nVal );
+ break;
+ case MID_MARGIN_R_MARGIN:
+ nRightMargin = (sal_Int16)( bConvert ? MM100_TO_TWIP(nVal) : nVal );
+ break;
+ case MID_MARGIN_UP_MARGIN:
+ nTopMargin = (sal_Int16)( bConvert ? MM100_TO_TWIP(nVal) : nVal );
+ break;
+ case MID_MARGIN_LO_MARGIN:
+ nBottomMargin = (sal_Int16)( bConvert ? MM100_TO_TWIP(nVal) : nVal );
+ break;
+ default:
+ DBG_ERROR("unknown MemberId");
+ return false;
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+sal_Bool SvxMarginItem::SetLeftMargin( sal_Int16 nLeft )
+{
+ nLeftMargin = nLeft;
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+
+sal_Bool SvxMarginItem::SetTopMargin( sal_Int16 nTop )
+{
+ nTopMargin = nTop;
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+
+sal_Bool SvxMarginItem::SetRightMargin( sal_Int16 nRight )
+{
+ nRightMargin = nRight;
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+
+sal_Bool SvxMarginItem::SetBottomMargin( sal_Int16 nBottom )
+{
+ nBottomMargin = nBottom;
+ return sal_True;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/chrtitem.cxx b/svx/source/items/chrtitem.cxx
new file mode 100644
index 000000000000..951ecb4e1cc7
--- /dev/null
+++ b/svx/source/items/chrtitem.cxx
@@ -0,0 +1,538 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/stream.hxx>
+#include <basic/sbxvar.hxx>
+#if defined UNX && !defined LINUX
+#include <wchar.h>
+#endif
+#include <rtl/math.hxx>
+#include <unotools/intlwrapper.hxx>
+#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp>
+
+#include <stdio.h>
+#include <float.h>
+#include <rtl/math.hxx>
+
+#include "chrtitem.hxx"
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+// -----------------------------------------------------------------------
+
+TYPEINIT1_FACTORY(SvxChartStyleItem, SfxEnumItem, new SvxChartStyleItem(CHSTYLE_2D_LINE, 0));
+TYPEINIT1(SvxChartDataDescrItem, SfxEnumItem);
+TYPEINIT1(SvxChartLegendPosItem, SfxEnumItem);
+TYPEINIT1(SvxChartTextOrderItem, SfxEnumItem);
+TYPEINIT1(SvxChartTextOrientItem, SfxEnumItem);
+TYPEINIT1(SvxChartIndicateItem, SfxEnumItem);
+TYPEINIT1(SvxChartKindErrorItem, SfxEnumItem);
+TYPEINIT1(SvxChartRegressItem, SfxEnumItem);
+TYPEINIT1_FACTORY(SvxDoubleItem, SfxPoolItem, new SvxDoubleItem(0.0, 0));
+
+/*************************************************************************
+|*
+|* SvxChartStyleItem
+|*
+*************************************************************************/
+
+SvxChartStyleItem::SvxChartStyleItem(SvxChartStyle eStyle, USHORT nId) :
+ SfxEnumItem(nId, (USHORT)eStyle)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxChartStyleItem::SvxChartStyleItem(SvStream& rIn, USHORT nId) :
+ SfxEnumItem(nId, rIn)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartStyleItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SvxChartStyleItem(*this);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartStyleItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SvxChartStyleItem(rIn, Which());
+}
+
+/*************************************************************************
+|*
+|* SvxChartDataDescrItem
+|*
+*************************************************************************/
+
+SvxChartDataDescrItem::SvxChartDataDescrItem(SvxChartDataDescr eDataDescr,
+ USHORT nId) :
+ SfxEnumItem(nId, (USHORT)eDataDescr)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxChartDataDescrItem::SvxChartDataDescrItem(SvStream& rIn, USHORT nId) :
+ SfxEnumItem(nId, rIn)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartDataDescrItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SvxChartDataDescrItem(*this);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartDataDescrItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SvxChartDataDescrItem(rIn, Which());
+}
+
+/*************************************************************************
+|*
+|* SvxChartLegendPosItem
+|*
+*************************************************************************/
+
+SvxChartLegendPosItem::SvxChartLegendPosItem(SvxChartLegendPos eLegendPos,
+ USHORT nId) :
+ SfxEnumItem(nId, (USHORT)eLegendPos)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxChartLegendPosItem::SvxChartLegendPosItem(SvStream& rIn, USHORT nId) :
+ SfxEnumItem(nId, rIn)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartLegendPosItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SvxChartLegendPosItem(*this);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartLegendPosItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SvxChartLegendPosItem(rIn, Which());
+}
+
+/*************************************************************************
+|*
+|* SvxChartTextOrderItem
+|*
+*************************************************************************/
+
+SvxChartTextOrderItem::SvxChartTextOrderItem(SvxChartTextOrder eOrder,
+ USHORT nId) :
+ SfxEnumItem(nId, (USHORT)eOrder)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxChartTextOrderItem::SvxChartTextOrderItem(SvStream& rIn, USHORT nId) :
+ SfxEnumItem(nId, rIn)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartTextOrderItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SvxChartTextOrderItem(*this);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartTextOrderItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SvxChartTextOrderItem(rIn, Which());
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxChartTextOrderItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ // the order of the two enums is not equal, so a mapping is required
+ ::com::sun::star::chart::ChartAxisArrangeOrderType eAO;
+ SvxChartTextOrder eOrder( GetValue());
+
+ switch( eOrder )
+ {
+ case CHTXTORDER_SIDEBYSIDE:
+ eAO = ::com::sun::star::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE; break;
+ case CHTXTORDER_UPDOWN:
+ eAO = ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_ODD; break;
+ case CHTXTORDER_DOWNUP:
+ eAO = ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_EVEN; break;
+ case CHTXTORDER_AUTO:
+ eAO = ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO; break;
+ }
+
+ rVal <<= eAO;
+
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxChartTextOrderItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ // the order of the two enums is not equal, so a mapping is required
+ ::com::sun::star::chart::ChartAxisArrangeOrderType eAO;
+ SvxChartTextOrder eOrder;
+
+ if(!(rVal >>= eAO))
+ {
+ // also try an int (for Basic)
+ sal_Int32 nAO = 0;
+ if(!(rVal >>= nAO))
+ return false;
+ eAO = static_cast< ::com::sun::star::chart::ChartAxisArrangeOrderType >( nAO );
+ }
+
+ switch( eAO )
+ {
+ case ::com::sun::star::chart::ChartAxisArrangeOrderType_SIDE_BY_SIDE:
+ eOrder = CHTXTORDER_SIDEBYSIDE; break;
+ case ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_ODD:
+ eOrder = CHTXTORDER_UPDOWN; break;
+ case ::com::sun::star::chart::ChartAxisArrangeOrderType_STAGGER_EVEN:
+ eOrder = CHTXTORDER_DOWNUP; break;
+ case ::com::sun::star::chart::ChartAxisArrangeOrderType_AUTO:
+ eOrder = CHTXTORDER_AUTO; break;
+ default:
+ return false;
+ }
+
+ SetValue( (USHORT)eOrder );
+
+ return true;
+}
+
+/*************************************************************************
+|*
+|* SvxChartTextOrientItem
+|*
+*************************************************************************/
+
+SvxChartTextOrientItem::SvxChartTextOrientItem(SvxChartTextOrient eOrient,
+ USHORT nId) :
+ SfxEnumItem(nId, (USHORT)eOrient)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxChartTextOrientItem::SvxChartTextOrientItem(SvStream& rIn, USHORT nId) :
+ SfxEnumItem(nId, rIn)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartTextOrientItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SvxChartTextOrientItem(*this);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartTextOrientItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SvxChartTextOrientItem(rIn, Which());
+}
+
+/*************************************************************************
+|*
+|* SvxDoubleItem
+|*
+*************************************************************************/
+
+SvxDoubleItem::SvxDoubleItem(double fValue, USHORT nId) :
+ SfxPoolItem(nId),
+ fVal(fValue)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxDoubleItem::SvxDoubleItem(SvStream& rIn, USHORT nId) :
+ SfxPoolItem(nId)
+{
+ rIn >> fVal;
+}
+
+// -----------------------------------------------------------------------
+
+SvxDoubleItem::SvxDoubleItem(const SvxDoubleItem& rItem) :
+ SfxPoolItem(rItem),
+ fVal(rItem.fVal)
+{
+}
+
+// -----------------------------------------------------------------------
+
+XubString SvxDoubleItem::GetValueText() const
+{
+ rtl::OString aOStr( rtl::math::doubleToString( fVal, rtl_math_StringFormat_E, 4, '.', false ) );
+ return String( aOStr.getStr(), (sal_uInt16)aOStr.getLength() );
+}
+
+// -----------------------------------------------------------------------
+
+SfxItemPresentation SvxDoubleItem::GetPresentation
+ ( SfxItemPresentation /*ePresentation*/, SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/, XubString& rText,
+ const IntlWrapper * pIntlWrapper) const
+{
+ DBG_ASSERT( pIntlWrapper, "SvxDoubleItem::GetPresentation: no IntlWrapper" );
+ if ( pIntlWrapper )
+ {
+ rText = ::rtl::math::doubleToUString( fVal, rtl_math_StringFormat_E, 4,
+ pIntlWrapper->getLocaleData()->getNumDecimalSep().GetChar(0), true );
+ }
+ else
+ rText = GetValueText();
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxDoubleItem::operator == (const SfxPoolItem& rItem) const
+{
+ return (((SvxDoubleItem&)rItem).fVal == fVal);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxDoubleItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SvxDoubleItem(*this);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxDoubleItem::Create(SvStream& rIn, USHORT /*nVersion*/) const
+{
+ double _fVal;
+ rIn >> _fVal;
+ return new SvxDoubleItem(_fVal, Which());
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SvxDoubleItem::Store(SvStream& rOut, USHORT /*nItemVersion*/) const
+{
+ rOut << fVal;
+ return rOut;
+}
+
+// -----------------------------------------------------------------------
+
+double SvxDoubleItem::GetMin() const
+{
+ return DBL_MIN;
+}
+
+// -----------------------------------------------------------------------
+
+double SvxDoubleItem::GetMax() const
+{
+ return DBL_MAX;
+}
+
+// -----------------------------------------------------------------------
+
+SfxFieldUnit SvxDoubleItem::GetUnit() const
+{
+ return SFX_FUNIT_NONE;
+}
+
+
+
+
+// -----------------------------------------------------------------------
+bool SvxDoubleItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ rVal <<= fVal;
+ return true;
+}
+
+// -----------------------------------------------------------------------
+bool SvxDoubleItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ return rVal >>= fVal;
+}
+
+
+
+/*************************************************************************
+|*
+|* SvxChartKindErrorItem
+|*
+*************************************************************************/
+
+SvxChartKindErrorItem::SvxChartKindErrorItem(SvxChartKindError eOrient,
+ USHORT nId) :
+ SfxEnumItem(nId, (USHORT)eOrient)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxChartKindErrorItem::SvxChartKindErrorItem(SvStream& rIn, USHORT nId) :
+ SfxEnumItem(nId, rIn)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartKindErrorItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SvxChartKindErrorItem(*this);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartKindErrorItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SvxChartKindErrorItem(rIn, Which());
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SvxChartKindErrorItem::GetVersion (USHORT nFileFormatVersion) const
+{
+ return (nFileFormatVersion == SOFFICE_FILEFORMAT_31)
+ ? USHRT_MAX
+ : 0;
+}
+
+/*************************************************************************
+|*
+|* SvxChartIndicateItem
+|*
+*************************************************************************/
+
+SvxChartIndicateItem::SvxChartIndicateItem(SvxChartIndicate eOrient,
+ USHORT nId) :
+ SfxEnumItem(nId, (USHORT)eOrient)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxChartIndicateItem::SvxChartIndicateItem(SvStream& rIn, USHORT nId) :
+ SfxEnumItem(nId, rIn)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartIndicateItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SvxChartIndicateItem(*this);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartIndicateItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SvxChartIndicateItem(rIn, Which());
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SvxChartIndicateItem::GetVersion (USHORT nFileFormatVersion) const
+{
+ return (nFileFormatVersion == SOFFICE_FILEFORMAT_31)
+ ? USHRT_MAX
+ : 0;
+}
+
+/*************************************************************************
+|*
+|* SvxChartRegressItem
+|*
+*************************************************************************/
+
+SvxChartRegressItem::SvxChartRegressItem(SvxChartRegress eOrient,
+ USHORT nId) :
+ SfxEnumItem(nId, (USHORT)eOrient)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxChartRegressItem::SvxChartRegressItem(SvStream& rIn, USHORT nId) :
+ SfxEnumItem(nId, rIn)
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartRegressItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SvxChartRegressItem(*this);
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxChartRegressItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SvxChartRegressItem(rIn, Which());
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SvxChartRegressItem::GetVersion (USHORT nFileFormatVersion) const
+{
+ return (nFileFormatVersion == SOFFICE_FILEFORMAT_31)
+ ? USHRT_MAX
+ : 0;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/clipfmtitem.cxx b/svx/source/items/clipfmtitem.cxx
new file mode 100644
index 000000000000..0868a34f355e
--- /dev/null
+++ b/svx/source/items/clipfmtitem.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define _SVSTDARR_ULONGS
+#define _SVSTDARR_STRINGSDTOR
+
+#include <svl/svstdarr.hxx>
+#include <clipfmtitem.hxx>
+#include <com/sun/star/frame/status/ClipboardFormats.hpp>
+
+struct SvxClipboardFmtItem_Impl
+{
+ SvStringsDtor aFmtNms;
+ SvULongs aFmtIds;
+ static String sEmptyStr;
+
+ SvxClipboardFmtItem_Impl() : aFmtNms( 8, 8 ), aFmtIds( 8, 8 ) {}
+ SvxClipboardFmtItem_Impl( const SvxClipboardFmtItem_Impl& );
+};
+
+String SvxClipboardFmtItem_Impl::sEmptyStr;
+
+TYPEINIT1_FACTORY( SvxClipboardFmtItem, SfxPoolItem , new SvxClipboardFmtItem(0));
+
+SvxClipboardFmtItem_Impl::SvxClipboardFmtItem_Impl(
+ const SvxClipboardFmtItem_Impl& rCpy )
+{
+ aFmtIds.Insert( &rCpy.aFmtIds, 0 );
+ for( USHORT n = 0, nEnd = rCpy.aFmtNms.Count(); n < nEnd; ++n )
+ {
+ String* pStr = rCpy.aFmtNms[ n ];
+ if( pStr )
+ pStr = new String( *pStr );
+ aFmtNms.Insert( pStr, n );
+ }
+}
+
+SvxClipboardFmtItem::SvxClipboardFmtItem( USHORT nId )
+ : SfxPoolItem( nId ), pImpl( new SvxClipboardFmtItem_Impl )
+{
+}
+
+SvxClipboardFmtItem::SvxClipboardFmtItem( const SvxClipboardFmtItem& rCpy )
+ : SfxPoolItem( rCpy.Which() ),
+ pImpl( new SvxClipboardFmtItem_Impl( *rCpy.pImpl ) )
+{
+}
+
+SvxClipboardFmtItem::~SvxClipboardFmtItem()
+{
+ delete pImpl;
+}
+
+bool SvxClipboardFmtItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ USHORT nCount = Count();
+
+ ::com::sun::star::frame::status::ClipboardFormats aClipFormats;
+
+ aClipFormats.Identifiers.realloc( nCount );
+ aClipFormats.Names.realloc( nCount );
+ for ( USHORT n=0; n < nCount; n++ )
+ {
+ aClipFormats.Identifiers[n] = (sal_Int64)GetClipbrdFormatId( n );
+ aClipFormats.Names[n] = GetClipbrdFormatName( n );
+ }
+
+ rVal <<= aClipFormats;
+ return true;
+}
+
+bool SvxClipboardFmtItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ ::com::sun::star::frame::status::ClipboardFormats aClipFormats;
+ if ( rVal >>= aClipFormats )
+ {
+ USHORT nCount = USHORT( aClipFormats.Identifiers.getLength() );
+
+ pImpl->aFmtIds.Remove( 0, pImpl->aFmtIds.Count() );
+ pImpl->aFmtNms.Remove( 0, pImpl->aFmtNms.Count() );
+ for ( USHORT n=0; n < nCount; n++ )
+ AddClipbrdFormat( ULONG( aClipFormats.Identifiers[n] ), aClipFormats.Names[n], n );
+
+ return true;
+ }
+
+ return false;
+}
+
+int SvxClipboardFmtItem::operator==( const SfxPoolItem& rComp ) const
+{
+ int nRet = 0;
+ const SvxClipboardFmtItem& rCmp = (SvxClipboardFmtItem&)rComp;
+ if( rCmp.pImpl->aFmtNms.Count() == pImpl->aFmtNms.Count() )
+ {
+ nRet = 1;
+ const String* pStr1, *pStr2;
+ for( USHORT n = 0, nEnd = rCmp.pImpl->aFmtNms.Count(); n < nEnd; ++n )
+ {
+ if( pImpl->aFmtIds[ n ] != rCmp.pImpl->aFmtIds[ n ] ||
+ ( (0 == ( pStr1 = pImpl->aFmtNms[ n ] )) ^
+ (0 == ( pStr2 = rCmp.pImpl->aFmtNms[ n ] ) )) ||
+ ( pStr1 && *pStr1 != *pStr2 ))
+ {
+ nRet = 0;
+ break;
+ }
+ }
+ }
+ return nRet;
+}
+
+SfxPoolItem* SvxClipboardFmtItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SvxClipboardFmtItem( *this );
+}
+
+void SvxClipboardFmtItem::AddClipbrdFormat( ULONG nId, USHORT nPos )
+{
+ if( nPos > pImpl->aFmtNms.Count() )
+ nPos = pImpl->aFmtNms.Count();
+ String* pStr = 0;
+ pImpl->aFmtNms.Insert( pStr, nPos );
+ pImpl->aFmtIds.Insert( nId, nPos );
+}
+
+void SvxClipboardFmtItem::AddClipbrdFormat( ULONG nId, const String& rName,
+ USHORT nPos )
+{
+ if( nPos > pImpl->aFmtNms.Count() )
+ nPos = pImpl->aFmtNms.Count();
+ String* pStr = new String( rName );
+ pImpl->aFmtNms.Insert( pStr, nPos );
+ pImpl->aFmtIds.Insert( nId, nPos );
+}
+
+USHORT SvxClipboardFmtItem::Count() const
+{
+ return pImpl->aFmtIds.Count();
+}
+
+ULONG SvxClipboardFmtItem::GetClipbrdFormatId( USHORT nPos ) const
+{
+ return pImpl->aFmtIds[ nPos ];
+}
+
+const String& SvxClipboardFmtItem::GetClipbrdFormatName( USHORT nPos ) const
+{
+ const String* pS = pImpl->aFmtNms[ nPos ];
+ return pS ? *pS : SvxClipboardFmtItem_Impl::sEmptyStr;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/customshapeitem.cxx b/svx/source/items/customshapeitem.cxx
new file mode 100644
index 000000000000..d7023c2311c0
--- /dev/null
+++ b/svx/source/items/customshapeitem.cxx
@@ -0,0 +1,388 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdasitm.hxx>
+#include <svx/svdattr.hxx>
+
+using namespace ::std;
+using namespace com::sun::star;
+
+SdrCustomShapeEngineItem::SdrCustomShapeEngineItem()
+: SfxStringItem( SDRATTR_CUSTOMSHAPE_ENGINE, String() )
+{}
+SdrCustomShapeEngineItem::SdrCustomShapeEngineItem( const String& rVal )
+: SfxStringItem( SDRATTR_CUSTOMSHAPE_ENGINE, rVal )
+{}
+
+SdrCustomShapeDataItem::SdrCustomShapeDataItem()
+: SfxStringItem( SDRATTR_CUSTOMSHAPE_DATA, String() )
+{}
+SdrCustomShapeDataItem::SdrCustomShapeDataItem( const String& rVal )
+: SfxStringItem( SDRATTR_CUSTOMSHAPE_DATA, rVal )
+{}
+
+bool SdrCustomShapeGeometryItem::PropertyEq::operator()( const rtl::OUString& r1, const rtl::OUString& r2 ) const
+{
+ return r1.equals( r2 );
+}
+bool SdrCustomShapeGeometryItem::PropertyPairEq::operator()( const SdrCustomShapeGeometryItem::PropertyPair& r1, const SdrCustomShapeGeometryItem::PropertyPair& r2 ) const
+{
+ return ( r1.first.equals( r2.first ) ) && ( r1.second.equals( r2.second ) );
+}
+size_t SdrCustomShapeGeometryItem::PropertyPairHash::operator()( const SdrCustomShapeGeometryItem::PropertyPair &r1 ) const
+{
+ return (size_t)r1.first.hashCode() + r1.second.hashCode();
+};
+
+TYPEINIT1_FACTORY( SdrCustomShapeGeometryItem, SfxPoolItem , new SdrCustomShapeGeometryItem(0));
+SdrCustomShapeGeometryItem::SdrCustomShapeGeometryItem()
+: SfxPoolItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )
+{}
+SdrCustomShapeGeometryItem::SdrCustomShapeGeometryItem( const uno::Sequence< beans::PropertyValue >& rVal )
+: SfxPoolItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )
+{
+ sal_Int32 i, j;
+ aPropSeq = rVal;
+
+ // hashing property values
+// beans::PropertyValue* pPropValues = aPropSeq.getArray();
+// const rtl::OUString* pPtr = NULL;
+ for ( i = 0; i < aPropSeq.getLength(); i++ )
+ {
+ beans::PropertyValue& rPropVal = aPropSeq[ i ];
+ aPropHashMap[ rPropVal.Name ] = i;
+ if ( rPropVal.Value.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
+ {
+ uno::Sequence< beans::PropertyValue >& rPropSeq = *( uno::Sequence< beans::PropertyValue >*)rPropVal.Value.getValue();
+ for ( j = 0; j < rPropSeq.getLength(); j++ )
+ {
+ beans::PropertyValue& rPropVal2 = rPropSeq[ j ];
+ aPropPairHashMap[ PropertyPair( rPropVal.Name, rPropVal2.Name ) ] = j;
+ }
+ }
+ }
+}
+
+com::sun::star::uno::Any* SdrCustomShapeGeometryItem::GetPropertyValueByName( const rtl::OUString& rPropName )
+{
+ com::sun::star::uno::Any* pRet = NULL;
+ PropertyHashMap::iterator aHashIter( aPropHashMap.find( rPropName ) );
+ if ( aHashIter != aPropHashMap.end() )
+ pRet = &aPropSeq[ (*aHashIter).second ].Value;
+ return pRet;
+}
+
+com::sun::star::uno::Any* SdrCustomShapeGeometryItem::GetPropertyValueByName( const rtl::OUString& rSequenceName, const rtl::OUString& rPropName )
+{
+ com::sun::star::uno::Any* pRet = NULL;
+ com::sun::star::uno::Any* pSeqAny = GetPropertyValueByName( rSequenceName );
+ if ( pSeqAny )
+ {
+ if ( pSeqAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
+ {
+ PropertyPairHashMap::iterator aHashIter( aPropPairHashMap.find( PropertyPair( rSequenceName, rPropName ) ) );
+ if ( aHashIter != aPropPairHashMap.end() )
+ {
+ ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
+ *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pSeqAny->getValue());
+ pRet = &rSecSequence[ (*aHashIter).second ].Value;
+ }
+ }
+ }
+ return pRet;
+}
+
+void SdrCustomShapeGeometryItem::SetPropertyValue( const com::sun::star::beans::PropertyValue& rPropVal )
+{
+ com::sun::star::uno::Any* pAny = GetPropertyValueByName( rPropVal.Name );
+ if ( pAny )
+ { // property is already available
+ sal_Int32 i;
+ if ( pAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
+ { // old property is a sequence->each entry has to be removed from the HashPairMap
+ ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
+ *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pAny->getValue());
+ for ( i = 0; i < rSecSequence.getLength(); i++ )
+ {
+ PropertyPairHashMap::iterator aHashIter( aPropPairHashMap.find( PropertyPair( rPropVal.Name, rSecSequence[ i ].Name ) ) );
+ if ( aHashIter != aPropPairHashMap.end() )
+ aPropPairHashMap.erase( aHashIter );
+ }
+ }
+ *pAny = rPropVal.Value;
+ if ( rPropVal.Value.getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
+ { // the new property is a sequence->each entry has to be inserted into the HashPairMap
+ ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
+ *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pAny->getValue());
+ for ( i = 0; i < rSecSequence.getLength(); i++ )
+ {
+ beans::PropertyValue& rPropVal2 = rSecSequence[ i ];
+ aPropPairHashMap[ PropertyPair( rPropVal.Name, rPropVal2.Name ) ] = i;
+ }
+ }
+ }
+ else
+ { // its a new property
+ sal_uInt32 nIndex = aPropSeq.getLength();
+ aPropSeq.realloc( nIndex + 1 );
+ aPropSeq[ nIndex ] = rPropVal ;
+
+ aPropHashMap[ rPropVal.Name ] = nIndex;
+ }
+}
+
+void SdrCustomShapeGeometryItem::SetPropertyValue( const rtl::OUString& rSequenceName, const com::sun::star::beans::PropertyValue& rPropVal )
+{
+ com::sun::star::uno::Any* pAny = GetPropertyValueByName( rSequenceName, rPropVal.Name );
+ if ( pAny ) // just replacing
+ *pAny = rPropVal.Value;
+ else
+ {
+ com::sun::star::uno::Any* pSeqAny = GetPropertyValueByName( rSequenceName );
+ if( pSeqAny == NULL )
+ {
+ ::com::sun::star::uno::Sequence < beans::PropertyValue > aSeq;
+ beans::PropertyValue aValue;
+ aValue.Name = rSequenceName;
+ aValue.Value = ::com::sun::star::uno::makeAny( aSeq );
+
+ sal_uInt32 nIndex = aPropSeq.getLength();
+ aPropSeq.realloc( nIndex + 1 );
+ aPropSeq[ nIndex ] = aValue;
+ aPropHashMap[ rSequenceName ] = nIndex;
+
+ pSeqAny = &aPropSeq[ nIndex ].Value;
+ }
+
+ DBG_ASSERT( pSeqAny, "SdrCustomShapeGeometryItem::SetPropertyValue() - No Value??" );
+
+ if( pSeqAny )
+ {
+ if ( pSeqAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
+ {
+ PropertyPairHashMap::iterator aHashIter( aPropPairHashMap.find( PropertyPair( rSequenceName, rPropVal.Name ) ) );
+ if ( aHashIter != aPropPairHashMap.end() )
+ {
+ ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
+ *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pSeqAny->getValue());
+ rSecSequence[ (*aHashIter).second ].Value = rPropVal.Value;
+ }
+ else
+ {
+ ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
+ *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pSeqAny->getValue());
+
+ sal_Int32 nCount = rSecSequence.getLength();
+ rSecSequence.realloc( nCount + 1 );
+ rSecSequence[ nCount ] = rPropVal;
+
+ aPropPairHashMap[ PropertyPair( rSequenceName, rPropVal.Name ) ] = nCount;
+ }
+ }
+ }
+ }
+}
+
+void SdrCustomShapeGeometryItem::ClearPropertyValue( const rtl::OUString& rPropName )
+{
+ if ( aPropSeq.getLength() )
+ {
+ PropertyHashMap::iterator aHashIter( aPropHashMap.find( rPropName ) );
+ if ( aHashIter != aPropHashMap.end() )
+ {
+ com::sun::star::uno::Any* pSeqAny = &aPropSeq[ (*aHashIter).second ].Value;
+ if ( pSeqAny )
+ {
+ if ( pSeqAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
+ {
+ ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
+ *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pSeqAny->getValue());
+
+ sal_Int32 i;
+ for ( i = 0; i < rSecSequence.getLength(); i++ )
+ {
+ PropertyPairHashMap::iterator _aHashIter( aPropPairHashMap.find( PropertyPair( rPropName, rSecSequence[ i ].Name ) ) );
+ if ( _aHashIter != aPropPairHashMap.end() )
+ aPropPairHashMap.erase( _aHashIter ); // removing property from pair hashmap
+ }
+ }
+ }
+ sal_Int32 nLength = aPropSeq.getLength();
+ if ( nLength )
+ {
+ sal_Int32 nIndex = (*aHashIter).second;
+ if ( nIndex != ( nLength - 1 ) ) // resizing sequence
+ {
+ PropertyHashMap::iterator aHashIter2( aPropHashMap.find( aPropSeq[ nLength - 1 ].Name ) );
+ (*aHashIter2).second = nIndex;
+ aPropSeq[ (*aHashIter).second ] = aPropSeq[ aPropSeq.getLength() - 1 ];
+ }
+ aPropSeq.realloc( aPropSeq.getLength() - 1 );
+ }
+ aPropHashMap.erase( aHashIter ); // removing property from hashmap
+ }
+ }
+}
+
+void SdrCustomShapeGeometryItem::ClearPropertyValue( const rtl::OUString& rSequenceName, const rtl::OUString& rPropName )
+{
+ com::sun::star::uno::Any* pSeqAny = GetPropertyValueByName( rSequenceName );
+ if ( pSeqAny )
+ {
+ if ( pSeqAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Sequence < beans::PropertyValue >*)0) )
+ {
+ PropertyPairHashMap::iterator aHashIter( aPropPairHashMap.find( PropertyPair( rSequenceName, rPropName ) ) );
+ if ( aHashIter != aPropPairHashMap.end() )
+ {
+ ::com::sun::star::uno::Sequence < beans::PropertyValue >& rSecSequence =
+ *((::com::sun::star::uno::Sequence < beans::PropertyValue >*)pSeqAny->getValue());
+
+ sal_Int32 nLength = rSecSequence.getLength();
+ if ( nLength )
+ {
+ sal_Int32 nIndex = (*aHashIter).second;
+ if ( nIndex != ( nLength - 1 ) ) // resizing sequence
+ {
+ PropertyPairHashMap::iterator aHashIter2( aPropPairHashMap.find( PropertyPair( rSequenceName, rSecSequence[ nLength - 1 ].Name ) ) );
+ (*aHashIter2).second = nIndex;
+ rSecSequence[ nIndex ] = rSecSequence[ nLength - 1 ];
+ }
+ rSecSequence.realloc( aPropSeq.getLength() - 1 );
+ }
+ aPropPairHashMap.erase( aHashIter );
+ }
+ }
+ }
+}
+
+SdrCustomShapeGeometryItem::~SdrCustomShapeGeometryItem()
+{
+}
+SdrCustomShapeGeometryItem::SdrCustomShapeGeometryItem( SvStream& /*rIn*/, sal_uInt16 nVersion ):
+ SfxPoolItem( SDRATTR_CUSTOMSHAPE_GEOMETRY )
+{
+ if ( nVersion )
+ {
+
+ }
+}
+int __EXPORT SdrCustomShapeGeometryItem::operator==( const SfxPoolItem& rCmp ) const
+{
+ int bRet = SfxPoolItem::operator==( rCmp );
+ if ( bRet )
+ bRet = ((SdrCustomShapeGeometryItem&)rCmp).aPropSeq == aPropSeq;
+ return bRet;
+}
+
+SfxItemPresentation __EXPORT SdrCustomShapeGeometryItem::GetPresentation(
+ SfxItemPresentation ePresentation, SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/, XubString &rText, const IntlWrapper *) const
+{
+ rText += sal_Unicode( ' ' );
+ if ( ePresentation == SFX_ITEM_PRESENTATION_COMPLETE )
+ {
+ XubString aStr;
+// SdrItemPool::TakeItemName( Which(), aStr );
+ aStr += sal_Unicode( ' ' );
+ rText.Insert( aStr, 0 );
+ }
+ return ePresentation;
+}
+
+SfxPoolItem* __EXPORT SdrCustomShapeGeometryItem::Create( SvStream& rIn, sal_uInt16 nItemVersion ) const
+{
+ return new SdrCustomShapeGeometryItem( rIn, nItemVersion );
+}
+
+SvStream& __EXPORT SdrCustomShapeGeometryItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) const
+{
+ if ( nItemVersion )
+ {
+
+ }
+ return rOut;
+}
+
+SfxPoolItem* __EXPORT SdrCustomShapeGeometryItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ SdrCustomShapeGeometryItem* pItem = new SdrCustomShapeGeometryItem( GetGeometry() );
+// SdrCustomShapeGeometryItem* pItem = new SdrCustomShapeGeometryItem( *this );
+
+/*
+ for ( i = 0; i < GetCount(); i++ )
+ {
+ const SdrCustomShapeAdjustmentValue& rVal = GetValue( i );
+ pItem->SetValue( i, rVal );
+ }
+*/
+ return pItem;
+}
+
+#ifdef SDR_ISPOOLABLE
+int __EXPORT SdrCustomShapeGeometryItem::IsPoolable() const
+{
+ USHORT nId=Which();
+ return nId < SDRATTR_NOTPERSIST_FIRST || nId > SDRATTR_NOTPERSIST_LAST;
+}
+#endif
+sal_uInt16 SdrCustomShapeGeometryItem::GetVersion( sal_uInt16 /*nFileFormatVersion*/ ) const
+{
+ return 1;
+}
+bool SdrCustomShapeGeometryItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ rVal <<= aPropSeq;
+ return true;
+}
+bool SdrCustomShapeGeometryItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ if ( ! ( rVal >>= aPropSeq ) )
+ return false;
+ else
+ return true;
+}
+const uno::Sequence< beans::PropertyValue >& SdrCustomShapeGeometryItem::GetGeometry() const
+{
+ return aPropSeq;
+}
+/*
+const uno::Any* GetValueByName( const rtl::OUString& rProperty ) const
+{
+
+}
+*/
+SdrCustomShapeReplacementURLItem::SdrCustomShapeReplacementURLItem()
+: SfxStringItem( SDRATTR_CUSTOMSHAPE_REPLACEMENT_URL, String() )
+{}
+SdrCustomShapeReplacementURLItem::SdrCustomShapeReplacementURLItem( const String& rVal )
+: SfxStringItem( SDRATTR_CUSTOMSHAPE_REPLACEMENT_URL, rVal )
+{}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/drawitem.cxx b/svx/source/items/drawitem.cxx
new file mode 100644
index 000000000000..05269deeea10
--- /dev/null
+++ b/svx/source/items/drawitem.cxx
@@ -0,0 +1,560 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <svx/svxids.hrc>
+
+
+#include "drawitem.hxx"
+#include <svx/xtable.hxx>
+
+using namespace ::com::sun::star;
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_FACTORY( SvxColorTableItem, SfxPoolItem , new SvxColorTableItem);
+TYPEINIT1_FACTORY( SvxGradientListItem, SfxPoolItem , new SvxGradientListItem);
+TYPEINIT1_FACTORY( SvxHatchListItem, SfxPoolItem , new SvxHatchListItem);
+TYPEINIT1_FACTORY( SvxBitmapListItem, SfxPoolItem , new SvxBitmapListItem);
+TYPEINIT1_FACTORY( SvxDashListItem, SfxPoolItem , new SvxDashListItem);
+TYPEINIT1_FACTORY( SvxLineEndListItem, SfxPoolItem , new SvxLineEndListItem);
+
+//==================================================================
+//
+// SvxColorTableItem
+//
+//==================================================================
+
+SvxColorTableItem::SvxColorTableItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxColorTableItem::SvxColorTableItem( XColorTable* pTable, sal_uInt16 nW ) :
+ SfxPoolItem( nW ),
+ pColorTable( pTable )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxColorTableItem::SvxColorTableItem( const SvxColorTableItem& rItem ) :
+ SfxPoolItem( rItem ),
+ pColorTable( rItem.pColorTable )
+{
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxColorTableItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxColorTableItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ( ( SvxColorTableItem& ) rItem).pColorTable == pColorTable;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxColorTableItem::Clone( SfxItemPool * ) const
+{
+ return new SvxColorTableItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxColorTableItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ // Please ask CD if you want to change this.
+ sal_Int64 aValue = sal_Int64( (ULONG)pColorTable );
+ rVal = uno::makeAny( aValue );
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxColorTableItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ // Please ask CD if you want to change this.
+ sal_Int64 aValue = 0;
+ if ( rVal >>= aValue )
+ {
+ pColorTable = (XColorTable *)(ULONG)aValue;
+ return true;
+ }
+
+ return false;
+}
+
+//==================================================================
+//
+// SvxGradientListItem
+//
+//==================================================================
+
+SvxGradientListItem::SvxGradientListItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxGradientListItem::SvxGradientListItem( XGradientList* pList, sal_uInt16 nW ) :
+ SfxPoolItem( nW ),
+ pGradientList( pList )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxGradientListItem::SvxGradientListItem( const SvxGradientListItem& rItem ) :
+ SfxPoolItem( rItem ),
+ pGradientList( rItem.pGradientList )
+{
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxGradientListItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxGradientListItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ( ( SvxGradientListItem& ) rItem).pGradientList == pGradientList;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxGradientListItem::Clone( SfxItemPool * ) const
+{
+ return new SvxGradientListItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxGradientListItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ // Please ask CD if you want to change this.
+ sal_Int64 aValue = sal_Int64( (ULONG)pGradientList );
+ rVal = uno::makeAny( aValue );
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxGradientListItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ // Please ask CD if you want to change this.
+ sal_Int64 aValue = 0;
+ if ( rVal >>= aValue )
+ {
+ pGradientList = (XGradientList *)(ULONG)aValue;
+ return true;
+ }
+
+ return false;
+}
+
+//==================================================================
+//
+// SvxHatchListItem
+//
+//==================================================================
+
+SvxHatchListItem::SvxHatchListItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxHatchListItem::SvxHatchListItem( XHatchList* pList, sal_uInt16 nW ) :
+ SfxPoolItem( nW ),
+ pHatchList( pList )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxHatchListItem::SvxHatchListItem( const SvxHatchListItem& rItem ) :
+ SfxPoolItem( rItem ),
+ pHatchList( rItem.pHatchList )
+{
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxHatchListItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxHatchListItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ( ( SvxHatchListItem& ) rItem).pHatchList == pHatchList;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxHatchListItem::Clone( SfxItemPool * ) const
+{
+ return new SvxHatchListItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxHatchListItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ // Please ask CD if you want to change this.
+ sal_Int64 aValue = sal_Int64( (ULONG)pHatchList );
+ rVal = uno::makeAny( aValue );
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxHatchListItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ // Please ask CD if you want to change this.
+ sal_Int64 aValue = 0;
+ if ( rVal >>= aValue )
+ {
+ pHatchList = (XHatchList *)(ULONG)aValue;
+ return true;
+ }
+
+ return false;
+}
+
+//==================================================================
+//
+// SvxBitmapListItem
+//
+//==================================================================
+
+SvxBitmapListItem::SvxBitmapListItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxBitmapListItem::SvxBitmapListItem( XBitmapList* pList, sal_uInt16 nW ) :
+ SfxPoolItem( nW ),
+ pBitmapList( pList )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxBitmapListItem::SvxBitmapListItem( const SvxBitmapListItem& rItem ) :
+ SfxPoolItem( rItem ),
+ pBitmapList( rItem.pBitmapList )
+{
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxBitmapListItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxBitmapListItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ( ( SvxBitmapListItem& ) rItem).pBitmapList == pBitmapList;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxBitmapListItem::Clone( SfxItemPool * ) const
+{
+ return new SvxBitmapListItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxBitmapListItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ // Please ask CD if you want to change this.
+ sal_Int64 aValue = sal_Int64( (ULONG)pBitmapList );
+ rVal = uno::makeAny( aValue );
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxBitmapListItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ // Please ask CD if you want to change this.
+ sal_Int64 aValue = 0;
+ if ( rVal >>= aValue )
+ {
+ pBitmapList = (XBitmapList *)(ULONG)aValue;
+ return true;
+ }
+
+ return false;
+}
+
+
+//==================================================================
+//
+// SvxDashListItem
+//
+//==================================================================
+
+SvxDashListItem::SvxDashListItem() :
+ pDashList( 0 )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxDashListItem::SvxDashListItem( XDashList* pList, sal_uInt16 nW ) :
+ SfxPoolItem( nW ),
+ pDashList( pList )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxDashListItem::SvxDashListItem( const SvxDashListItem& rItem ) :
+ SfxPoolItem( rItem ),
+ pDashList( rItem.pDashList )
+{
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxDashListItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxDashListItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ( ( SvxDashListItem& ) rItem).pDashList == pDashList;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxDashListItem::Clone( SfxItemPool * ) const
+{
+ return new SvxDashListItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxDashListItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ sal_Int64 aValue = sal_Int64( (ULONG)pDashList );
+ rVal = uno::makeAny( aValue );
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxDashListItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ sal_Int64 aValue = 0;
+ if ( rVal >>= aValue )
+ {
+ pDashList = (XDashList *)(ULONG)aValue;
+ return true;
+ }
+
+ return false;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxDashListItem::SetDashList( XDashList* pList )
+{
+ pDashList = pList;
+}
+
+//==================================================================
+//
+// SvxLineEndListItem
+//
+//==================================================================
+
+SvxLineEndListItem::SvxLineEndListItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxLineEndListItem::SvxLineEndListItem( XLineEndList* pList, sal_uInt16 nW ) :
+ SfxPoolItem( nW ),
+ pLineEndList( pList )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxLineEndListItem::SvxLineEndListItem( const SvxLineEndListItem& rItem ) :
+ SfxPoolItem( rItem ),
+ pLineEndList( rItem.pLineEndList )
+{
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxLineEndListItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxLineEndListItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ( ( SvxLineEndListItem& ) rItem).pLineEndList == pLineEndList;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxLineEndListItem::Clone( SfxItemPool * ) const
+{
+ return new SvxLineEndListItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxLineEndListItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ sal_Int64 aValue = sal_Int64( (ULONG)pLineEndList );
+ rVal = uno::makeAny( aValue );
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxLineEndListItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ // This is only a quick helper to have UI support for these list items. Don't use
+ // this method to query for a valid UNO representation.
+ sal_Int64 aValue = 0;
+ if ( rVal >>= aValue )
+ {
+ pLineEndList = (XLineEndList *)(ULONG)aValue;
+ return true;
+ }
+
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/e3ditem.cxx b/svx/source/items/e3ditem.cxx
new file mode 100644
index 000000000000..64b6219402fc
--- /dev/null
+++ b/svx/source/items/e3ditem.cxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/drawing/Direction3D.hpp>
+#include <tools/stream.hxx>
+
+#include <svx/e3ditem.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+DBG_NAMEEX(SvxB3DVectorItem)
+DBG_NAME(SvxB3DVectorItem)
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_FACTORY(SvxB3DVectorItem, SfxPoolItem, new SvxB3DVectorItem);
+
+// -----------------------------------------------------------------------
+
+SvxB3DVectorItem::SvxB3DVectorItem()
+{
+ DBG_CTOR(SvxB3DVectorItem, 0);
+}
+
+SvxB3DVectorItem::~SvxB3DVectorItem()
+{
+ DBG_DTOR(SvxB3DVectorItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SvxB3DVectorItem::SvxB3DVectorItem( USHORT _nWhich, const basegfx::B3DVector& rVal ) :
+ SfxPoolItem( _nWhich ),
+ aVal( rVal )
+{
+ DBG_CTOR(SvxB3DVectorItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+SvxB3DVectorItem::SvxB3DVectorItem( USHORT _nWhich, SvStream& rStream ) :
+ SfxPoolItem( _nWhich )
+{
+ DBG_CTOR(SvxB3DVectorItem, 0);
+ double fValue;
+ rStream >> fValue; aVal.setX(fValue);
+ rStream >> fValue; aVal.setY(fValue);
+ rStream >> fValue; aVal.setZ(fValue);
+}
+
+// -----------------------------------------------------------------------
+
+SvxB3DVectorItem::SvxB3DVectorItem( const SvxB3DVectorItem& rItem ) :
+ SfxPoolItem( rItem ),
+ aVal( rItem.aVal )
+{
+ DBG_CTOR(SvxB3DVectorItem, 0);
+}
+
+// -----------------------------------------------------------------------
+
+int SvxB3DVectorItem::operator==( const SfxPoolItem &rItem ) const
+{
+ DBG_CHKTHIS(SvxB3DVectorItem, 0);
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
+ return ((SvxB3DVectorItem&)rItem).aVal == aVal;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxB3DVectorItem::Clone( SfxItemPool* /*pPool*/ ) const
+{
+ DBG_CHKTHIS(SvxB3DVectorItem, 0);
+ return new SvxB3DVectorItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxB3DVectorItem::Create(SvStream &rStream, USHORT /*nVersion*/) const
+{
+ DBG_CHKTHIS(SvxB3DVectorItem, 0);
+ basegfx::B3DVector aStr;
+ double fValue;
+ rStream >> fValue; aStr.setX(fValue);
+ rStream >> fValue; aStr.setY(fValue);
+ rStream >> fValue; aStr.setZ(fValue);
+ return new SvxB3DVectorItem(Which(), aStr);
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SvxB3DVectorItem::Store(SvStream &rStream, USHORT /*nItemVersion*/) const
+{
+ DBG_CHKTHIS(SvxB3DVectorItem, 0);
+
+ // ## if (nItemVersion)
+ double fValue;
+ fValue = aVal.getX(); rStream << fValue;
+ fValue = aVal.getY(); rStream << fValue;
+ fValue = aVal.getZ(); rStream << fValue;
+
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxB3DVectorItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ drawing::Direction3D aDirection;
+
+ // Werte eintragen
+ aDirection.DirectionX = aVal.getX();
+ aDirection.DirectionY = aVal.getY();
+ aDirection.DirectionZ = aVal.getZ();
+
+ rVal <<= aDirection;
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+bool SvxB3DVectorItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ drawing::Direction3D aDirection;
+ if(!(rVal >>= aDirection))
+ return false;
+
+ aVal.setX(aDirection.DirectionX);
+ aVal.setY(aDirection.DirectionY);
+ aVal.setZ(aDirection.DirectionZ);
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT SvxB3DVectorItem::GetVersion (USHORT nFileFormatVersion) const
+{
+ return (nFileFormatVersion == SOFFICE_FILEFORMAT_31) ? USHRT_MAX : 0;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/grfitem.cxx b/svx/source/items/grfitem.cxx
new file mode 100644
index 000000000000..3ac7188349dd
--- /dev/null
+++ b/svx/source/items/grfitem.cxx
@@ -0,0 +1,199 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+
+#include <tools/stream.hxx>
+#include <svx/grfcrop.hxx>
+#include <editeng/itemtype.hxx>
+#include <com/sun/star/text/GraphicCrop.hpp>
+
+using namespace ::com::sun::star;
+
+#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
+#define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
+//TYPEINIT1_FACTORY( SvxGrfCrop, SfxPoolItem , new SvxGrfCrop(0))
+
+/******************************************************************************
+ * Implementierung class SwCropGrf
+ ******************************************************************************/
+
+SvxGrfCrop::SvxGrfCrop( USHORT nItemId )
+ : SfxPoolItem( nItemId ),
+ nLeft( 0 ), nRight( 0 ), nTop( 0 ), nBottom( 0 )
+{}
+
+SvxGrfCrop::SvxGrfCrop( sal_Int32 nL, sal_Int32 nR,
+ sal_Int32 nT, sal_Int32 nB, USHORT nItemId )
+ : SfxPoolItem( nItemId ),
+ nLeft( nL ), nRight( nR ), nTop( nT ), nBottom( nB )
+{}
+
+SvxGrfCrop::~SvxGrfCrop()
+{
+}
+
+int SvxGrfCrop::operator==( const SfxPoolItem& rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rAttr ), "not equal attributes" );
+ return nLeft == ((const SvxGrfCrop&)rAttr).GetLeft() &&
+ nRight == ((const SvxGrfCrop&)rAttr).GetRight() &&
+ nTop == ((const SvxGrfCrop&)rAttr).GetTop() &&
+ nBottom == ((const SvxGrfCrop&)rAttr).GetBottom();
+}
+
+/*
+SfxPoolItem* SvxGrfCrop::Clone( SfxItemPool* ) const
+{
+ return new SvxGrfCrop( *this );
+}
+*/
+
+/*
+USHORT SvxGrfCrop::GetVersion( USHORT nFFVer ) const
+{
+ DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
+ SOFFICE_FILEFORMAT_40==nFFVer ||
+ SOFFICE_FILEFORMAT_NOW==nFFVer,
+ "SvxGrfCrop: exist a new fileformat?" );
+ return GRFCROP_VERSION_SWDEFAULT;
+}
+*/
+
+SfxPoolItem* SvxGrfCrop::Create( SvStream& rStrm, USHORT nVersion ) const
+{
+ INT32 top, left, right, bottom;
+ rStrm >> top >> left >> right >> bottom;
+
+ if( GRFCROP_VERSION_SWDEFAULT == nVersion )
+ top = -top, bottom = -bottom, left = -left, right = -right;
+
+ SvxGrfCrop* pNew = (SvxGrfCrop*)Clone();
+ pNew->SetLeft( left );
+ pNew->SetRight( right );
+ pNew->SetTop( top );
+ pNew->SetBottom( bottom );
+ return pNew;
+}
+
+
+SvStream& SvxGrfCrop::Store( SvStream& rStrm, USHORT nVersion ) const
+{
+ INT32 left = GetLeft(), right = GetRight(),
+ top = GetTop(), bottom = GetBottom();
+ if( GRFCROP_VERSION_SWDEFAULT == nVersion )
+ top = -top, bottom = -bottom, left = -left, right = -right;
+
+ rStrm << top << left << right << bottom;
+
+ return rStrm;
+}
+
+
+
+bool SvxGrfCrop::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ text::GraphicCrop aRet;
+ aRet.Left = nLeft;
+ aRet.Right = nRight;
+ aRet.Top = nTop;
+ aRet.Bottom = nBottom;
+
+ if( bConvert )
+ {
+ aRet.Right = TWIP_TO_MM100(aRet.Right );
+ aRet.Top = TWIP_TO_MM100(aRet.Top );
+ aRet.Left = TWIP_TO_MM100(aRet.Left );
+ aRet.Bottom = TWIP_TO_MM100(aRet.Bottom);
+ }
+
+
+ rVal <<= aRet;
+ return true;
+}
+
+bool SvxGrfCrop::PutValue( const uno::Any& rVal, BYTE nMemberId )
+{
+ sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ text::GraphicCrop aVal;
+
+ if(!(rVal >>= aVal))
+ return false;
+ if( bConvert )
+ {
+ aVal.Right = MM100_TO_TWIP(aVal.Right );
+ aVal.Top = MM100_TO_TWIP(aVal.Top );
+ aVal.Left = MM100_TO_TWIP(aVal.Left );
+ aVal.Bottom = MM100_TO_TWIP(aVal.Bottom);
+ }
+
+ nLeft = aVal.Left ;
+ nRight = aVal.Right ;
+ nTop = aVal.Top ;
+ nBottom = aVal.Bottom;
+ return true;
+}
+
+SfxItemPresentation SvxGrfCrop::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit eCoreUnit, SfxMapUnit /*ePresUnit*/,
+ String &rText, const IntlWrapper* pIntl ) const
+{
+ rText.Erase();
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ if( SFX_ITEM_PRESENTATION_COMPLETE == ePres )
+ {
+ ( rText.AssignAscii( "L: " )) += ::GetMetricText( GetLeft(),
+ eCoreUnit, SFX_MAPUNIT_MM, pIntl );
+ ( rText.AppendAscii( " R: " )) += ::GetMetricText( GetRight(),
+ eCoreUnit, SFX_MAPUNIT_MM, pIntl );
+ ( rText.AppendAscii( " T: " )) += ::GetMetricText( GetTop(),
+ eCoreUnit, SFX_MAPUNIT_MM, pIntl );
+ ( rText.AppendAscii( " B: " )) += ::GetMetricText( GetBottom(),
+ eCoreUnit, SFX_MAPUNIT_MM, pIntl );
+ }
+ break;
+
+ default:
+ ePres = SFX_ITEM_PRESENTATION_NONE;
+ break;
+ }
+ return ePres;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/hlnkitem.cxx b/svx/source/items/hlnkitem.cxx
new file mode 100644
index 000000000000..7b48c666c3b9
--- /dev/null
+++ b/svx/source/items/hlnkitem.cxx
@@ -0,0 +1,424 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#define _SVX_HLNKITEM_CXX
+
+#include <svx/svxids.hrc>
+#include <tools/stream.hxx>
+#include <svl/memberid.hrc>
+#include <basic/sbxvar.hxx>
+
+#include "hlnkitem.hxx"
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_FACTORY(SvxHyperlinkItem, SfxPoolItem, new SvxHyperlinkItem(0));
+
+// class SvxHyperlinkItem ------------------------------------------------
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+#define HYPERLINKFF_MARKER 0x599401FE
+
+SvStream& SvxHyperlinkItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
+{
+ // store 'simple' data
+ // UNICODE: rStrm << sName;
+ rStrm.WriteByteString(sName);
+
+ // UNICODE: rStrm << sURL;
+ rStrm.WriteByteString(sURL);
+
+ // UNICODE: rStrm << sTarget;
+ rStrm.WriteByteString(sTarget);
+
+ rStrm << (sal_uInt32) eType;
+
+ // marker for versioninfo
+ rStrm << (sal_uInt32) HYPERLINKFF_MARKER;
+
+ // new data
+ // UNICODE: rStrm << sIntName;
+ rStrm.WriteByteString(sIntName);
+
+ // macro-events
+ rStrm << nMacroEvents;
+
+ // store macros
+ sal_uInt16 nCnt = pMacroTable ? (sal_uInt16)pMacroTable->Count() : 0;
+ sal_uInt16 nMax = nCnt;
+ if( nCnt )
+ {
+ for( SvxMacro* pMac = pMacroTable->First(); pMac; pMac = pMacroTable->Next() )
+ if( STARBASIC != pMac->GetScriptType() )
+ --nCnt;
+ }
+
+ rStrm << nCnt;
+
+ if( nCnt )
+ {
+ // 1. StarBasic-Macros
+ for( SvxMacro* pMac = pMacroTable->First(); pMac; pMac = pMacroTable->Next() )
+ {
+ if( STARBASIC == pMac->GetScriptType() )
+ {
+ rStrm << (sal_uInt16)pMacroTable->GetCurKey();
+
+ // UNICODE: rStrm << pMac->GetLibName();
+ rStrm.WriteByteString(pMac->GetLibName());
+
+ // UNICODE: rStrm << pMac->GetMacName();
+ rStrm.WriteByteString(pMac->GetMacName());
+ }
+ }
+ }
+
+ nCnt = nMax - nCnt;
+ rStrm << nCnt;
+ if( nCnt )
+ {
+ // 2. ::com::sun::star::script::JavaScript-Macros
+ for( SvxMacro* pMac = pMacroTable->First(); pMac; pMac = pMacroTable->Next() )
+ {
+ if( STARBASIC != pMac->GetScriptType() )
+ {
+ rStrm << (sal_uInt16)pMacroTable->GetCurKey();
+
+ // UNICODE: rStrm << pMac->GetLibName();
+ rStrm.WriteByteString(pMac->GetLibName());
+
+ // UNICODE: rStrm << pMac->GetMacName();
+ rStrm.WriteByteString(pMac->GetMacName());
+
+ rStrm << (sal_uInt16)pMac->GetScriptType();
+ }
+ }
+ }
+
+ return rStrm;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+SfxPoolItem* SvxHyperlinkItem::Create( SvStream &rStrm, sal_uInt16 /*nItemVersion*/ ) const
+{
+ SvxHyperlinkItem* pNew = new SvxHyperlinkItem( Which() );
+ sal_uInt32 nType;
+
+ // simple data-types
+ // UNICODE: rStrm >> pNew->sName;
+ rStrm.ReadByteString(pNew->sName);
+
+ // UNICODE: rStrm >> pNew->sURL;
+ rStrm.ReadByteString(pNew->sURL);
+
+ // UNICODE: rStrm >> pNew->sTarget;
+ rStrm.ReadByteString(pNew->sTarget);
+
+ rStrm >> nType;
+ pNew->eType = (SvxLinkInsertMode) nType;
+
+ sal_uInt32 nPos = rStrm.Tell();
+ sal_uInt32 nMarker;
+ rStrm >> nMarker;
+ if ( nMarker == HYPERLINKFF_MARKER )
+ {
+ // new data
+ // UNICODE: rStrm >> pNew->sIntName;
+ rStrm.ReadByteString(pNew->sIntName);
+
+ // macro-events
+ rStrm >> pNew->nMacroEvents;
+
+ // macros
+ sal_uInt16 nCnt;
+ rStrm >> nCnt;
+ while( nCnt-- )
+ {
+ sal_uInt16 nCurKey;
+ String aLibName, aMacName;
+
+ rStrm >> nCurKey;
+ // UNICODE: rStrm >> aLibName;
+ rStrm.ReadByteString(aLibName);
+
+ // UNICODE: rStrm >> aMacName;
+ rStrm.ReadByteString(aMacName);
+
+ pNew->SetMacro( nCurKey, SvxMacro( aMacName, aLibName, STARBASIC ) );
+ }
+
+ rStrm >> nCnt;
+ while( nCnt-- )
+ {
+ sal_uInt16 nCurKey, nScriptType;
+ String aLibName, aMacName;
+
+ rStrm >> nCurKey;
+
+ // UNICODE: rStrm >> aLibName;
+ rStrm.ReadByteString(aLibName);
+
+ // UNICODE: rStrm >> aMacName;
+ rStrm.ReadByteString(aMacName);
+
+ rStrm >> nScriptType;
+
+ pNew->SetMacro( nCurKey, SvxMacro( aMacName, aLibName,
+ (ScriptType)nScriptType ) );
+ }
+ }
+ else
+ rStrm.Seek( nPos );
+
+ return pNew;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+SvxHyperlinkItem::SvxHyperlinkItem( const SvxHyperlinkItem& rHyperlinkItem ):
+ SfxPoolItem(rHyperlinkItem)
+{
+ sName = rHyperlinkItem.sName;
+ sURL = rHyperlinkItem.sURL;
+ sTarget = rHyperlinkItem.sTarget;
+ eType = rHyperlinkItem.eType;
+ sIntName = rHyperlinkItem.sIntName;
+ nMacroEvents = rHyperlinkItem.nMacroEvents;
+
+ if( rHyperlinkItem.GetMacroTbl() )
+ pMacroTable = new SvxMacroTableDtor( *rHyperlinkItem.GetMacroTbl() );
+ else
+ pMacroTable=NULL;
+
+};
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+SvxHyperlinkItem::SvxHyperlinkItem( sal_uInt16 _nWhich, String& rName, String& rURL,
+ String& rTarget, String& rIntName, SvxLinkInsertMode eTyp,
+ sal_uInt16 nEvents, SvxMacroTableDtor *pMacroTbl ):
+ SfxPoolItem (_nWhich),
+ sName (rName),
+ sURL (rURL),
+ sTarget (rTarget),
+ eType (eTyp),
+ sIntName (rIntName),
+ nMacroEvents (nEvents)
+{
+ if (pMacroTbl)
+ pMacroTable = new SvxMacroTableDtor ( *pMacroTbl );
+ else
+ pMacroTable=NULL;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+SfxPoolItem* SvxHyperlinkItem::Clone( SfxItemPool* ) const
+{
+ return new SvxHyperlinkItem( *this );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+int SvxHyperlinkItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unterschiedliche Typen" );
+
+ const SvxHyperlinkItem& rItem = (const SvxHyperlinkItem&) rAttr;
+
+ sal_Bool bRet = ( sName == rItem.sName &&
+ sURL == rItem.sURL &&
+ sTarget == rItem.sTarget &&
+ eType == rItem.eType &&
+ sIntName == rItem.sIntName &&
+ nMacroEvents == rItem.nMacroEvents);
+ if (!bRet)
+ return sal_False;
+
+ const SvxMacroTableDtor* pOther = ((SvxHyperlinkItem&)rAttr).pMacroTable;
+ if( !pMacroTable )
+ return ( !pOther || !pOther->Count() );
+ if( !pOther )
+ return 0 == pMacroTable->Count();
+
+ const SvxMacroTableDtor& rOwn = *pMacroTable;
+ const SvxMacroTableDtor& rOther = *pOther;
+
+ // Anzahl unterschiedlich => auf jeden Fall ungleich
+ if( rOwn.Count() != rOther.Count() )
+ return sal_False;
+
+ // einzeln vergleichen; wegen Performance ist die Reihenfolge wichtig
+ for( sal_uInt16 nNo = 0; nNo < rOwn.Count(); ++nNo )
+ {
+ const SvxMacro *pOwnMac = rOwn.GetObject(nNo);
+ const SvxMacro *pOtherMac = rOther.GetObject(nNo);
+ if ( rOwn.GetKey(pOwnMac) != rOther.GetKey(pOtherMac) ||
+ pOwnMac->GetLibName() != pOtherMac->GetLibName() ||
+ pOwnMac->GetMacName() != pOtherMac->GetMacName() )
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SvxHyperlinkItem::SetMacro( sal_uInt16 nEvent, const SvxMacro& rMacro )
+{
+ if( nEvent < EVENT_SFX_START )
+ {
+ switch( nEvent )
+ {
+ case HYPERDLG_EVENT_MOUSEOVER_OBJECT:
+ nEvent = SFX_EVENT_MOUSEOVER_OBJECT;
+ break;
+ case HYPERDLG_EVENT_MOUSECLICK_OBJECT:
+ nEvent = SFX_EVENT_MOUSECLICK_OBJECT;
+ break;
+ case HYPERDLG_EVENT_MOUSEOUT_OBJECT:
+ nEvent = SFX_EVENT_MOUSEOUT_OBJECT;
+ break;
+ }
+ }
+
+ if( !pMacroTable )
+ pMacroTable = new SvxMacroTableDtor;
+
+ SvxMacro *pOldMacro;
+ if( 0 != ( pOldMacro = pMacroTable->Get( nEvent )) )
+ {
+ delete pOldMacro;
+ pMacroTable->Replace( nEvent, new SvxMacro( rMacro ) );
+ }
+ else
+ pMacroTable->Insert( nEvent, new SvxMacro( rMacro ) );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung:
+ --------------------------------------------------------------------*/
+
+void SvxHyperlinkItem::SetMacroTable( const SvxMacroTableDtor& rTbl )
+{
+ if ( pMacroTable )
+ delete pMacroTable;
+
+ pMacroTable = new SvxMacroTableDtor ( rTbl );
+}
+
+bool SvxHyperlinkItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ switch(nMemberId)
+ {
+ case MID_HLINK_NAME :
+ rVal <<= ::rtl::OUString(sIntName.GetBuffer());
+ break;
+ case MID_HLINK_TEXT :
+ rVal <<= ::rtl::OUString(sName.GetBuffer());
+ break;
+ case MID_HLINK_URL:
+ rVal <<= ::rtl::OUString(sURL.GetBuffer());
+ break;
+ case MID_HLINK_TARGET:
+ rVal <<= ::rtl::OUString(sTarget.GetBuffer());
+ break;
+ case MID_HLINK_TYPE:
+ rVal <<= (sal_Int32) eType;
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+bool SvxHyperlinkItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ ::rtl::OUString aStr;
+ sal_Int32 nVal = 0;
+ switch(nMemberId)
+ {
+ case MID_HLINK_NAME :
+ if(!(rVal >>= aStr))
+ return sal_False;
+ sIntName = aStr.getStr();
+ break;
+ case MID_HLINK_TEXT :
+ if(!(rVal >>= aStr))
+ return sal_False;
+ sName = aStr.getStr();
+ break;
+ case MID_HLINK_URL:
+ if(!(rVal >>= aStr))
+ return sal_False;
+ sURL = aStr.getStr();
+ break;
+ case MID_HLINK_TARGET:
+ if(!(rVal >>= aStr))
+ return sal_False;
+ sTarget = aStr.getStr();
+ break;
+ case MID_HLINK_TYPE:
+ if(!(rVal >>= nVal))
+ return sal_False;
+ eType = (SvxLinkInsertMode) (sal_uInt16) nVal;
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/makefile.mk b/svx/source/items/makefile.mk
new file mode 100644
index 000000000000..8bd3edc036e7
--- /dev/null
+++ b/svx/source/items/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=svxpch
+PROJECTPCHSOURCE=$(PRJ)$/util$/svxpch
+#ENABLE_EXCEPTIONS=TRUE
+
+PRJNAME=svx
+TARGET=items
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=svxitems
+SRC1FILES = \
+ svxerr.src \
+ svxitems.src
+
+LIB1TARGET= $(SLB)$/$(TARGET)-core.lib
+LIB1OBJFILES= \
+ $(SLO)$/algitem.obj \
+ $(SLO)$/chrtitem.obj \
+ $(SLO)$/clipfmtitem.obj \
+ $(SLO)$/customshapeitem.obj \
+ $(SLO)$/drawitem.obj \
+ $(SLO)$/e3ditem.obj \
+ $(SLO)$/grfitem.obj
+
+LIB2TARGET= $(SLB)$/$(TARGET).lib
+LIB2OBJFILES= \
+ $(SLO)$/SmartTagItem.obj \
+ $(SLO)$/hlnkitem.obj \
+ $(SLO)$/numfmtsh.obj \
+ $(SLO)$/numinf.obj \
+ $(SLO)$/ofaitem.obj \
+ $(SLO)$/pageitem.obj \
+ $(SLO)$/postattr.obj \
+ $(SLO)$/rotmodit.obj \
+ $(SLO)$/svxempty.obj \
+ $(SLO)$/svxerr.obj \
+ $(SLO)$/viewlayoutitem.obj \
+ $(SLO)$/zoomitem.obj \
+ $(SLO)$/zoomslideritem.obj
+
+SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES)
+
+EXCEPTIONSFILES= \
+ $(SLO)$/chrtitem.obj \
+ $(SLO)$/customshapeitem.obj \
+ $(SLO)$/numfmtsh.obj
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/items/numfmtsh.cxx b/svx/source/items/numfmtsh.cxx
new file mode 100644
index 000000000000..d6a2f3a36986
--- /dev/null
+++ b/svx/source/items/numfmtsh.cxx
@@ -0,0 +1,1868 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/color.hxx>
+
+#define _SVX_NUMFMTSH_CXX
+#define _SVSTDARR_STRINGSDTOR
+#include <tools/debug.hxx>
+#include <i18npool/mslangid.hxx>
+
+#define _ZFORLIST_DECLARE_TABLE
+#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
+
+#include <svtools/langtab.hxx>
+#include <vcl/svapp.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <svx/numfmtsh.hxx>
+// class SvxNumberFormatShell --------------------------------------------
+
+const double SvxNumberFormatShell::DEFAULT_NUMVALUE = 1234.56789;
+
+SV_IMPL_PTRARR( NfShCurrencyEntries, NfCurrencyEntry* );
+
+// -----------------------------------------------------------------------
+
+
+
+SvxNumberFormatShell* SvxNumberFormatShell::Create( SvNumberFormatter* pNumFormatter,
+ sal_uInt32 nFormatKey,
+ SvxNumberValueType eNumValType,
+ const String& rNumStr )
+{
+ return new SvxNumberFormatShell(pNumFormatter,nFormatKey,
+ eNumValType,rNumStr );
+}
+
+SvxNumberFormatShell* SvxNumberFormatShell::Create( SvNumberFormatter* pNumFormatter,
+ sal_uInt32 nFormatKey,
+ SvxNumberValueType eNumValType,
+ double nNumVal,
+ const String* pNumStr )
+{
+ return new SvxNumberFormatShell(pNumFormatter,nFormatKey,
+ eNumValType,nNumVal,pNumStr );
+}
+
+// -----------------------------------------------------------------------
+
+#define _INIT \
+ pFormatter ( pNumFormatter ), \
+ pCurFmtTable ( NULL ), \
+ eValType ( eNumValType ), \
+ bUndoAddList ( sal_True ), \
+ nInitFormatKey ( nFormatKey ), \
+ nCurFormatKey ( nFormatKey ), \
+ pCurCurrencyEntry(NULL), \
+ bBankingSymbol (sal_False), \
+ nCurCurrencyEntryPos((sal_uInt16) SELPOS_NONE)
+
+// -----------------------------------------------------------------------
+
+SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter,
+ sal_uInt32 nFormatKey,
+ SvxNumberValueType eNumValType,
+ const String& rNumStr )
+ : _INIT
+{
+ nValNum = DEFAULT_NUMVALUE;
+
+ switch ( eValType )
+ {
+ case SVX_VALUE_TYPE_STRING:
+ aValStr = rNumStr;
+ break;
+ case SVX_VALUE_TYPE_NUMBER:
+ case SVX_VALUE_TYPE_UNDEFINED:
+ default:
+ aValStr.Erase();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SvxNumberFormatShell::SvxNumberFormatShell( SvNumberFormatter* pNumFormatter,
+ sal_uInt32 nFormatKey,
+ SvxNumberValueType eNumValType,
+ double nNumVal,
+ const String* pNumStr )
+ : _INIT
+{
+ // #50441# When used in Writer, the SvxNumberInfoItem contains the
+ // original string in addition to the value
+
+ if ( pNumStr )
+ aValStr = *pNumStr;
+
+ switch ( eValType )
+ {
+ case SVX_VALUE_TYPE_NUMBER:
+ nValNum = nNumVal;
+ break;
+ case SVX_VALUE_TYPE_STRING:
+ case SVX_VALUE_TYPE_UNDEFINED:
+ default:
+ nValNum = DEFAULT_NUMVALUE;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SvxNumberFormatShell::~SvxNumberFormatShell()
+{
+ /*
+ * An dieser Stelle wird abhaengig davon, ob die
+ * hinzugefuegten, benutzerdefinierten als gueltig
+ * erklaert wurden (ValidateNewEntries()), die
+ * Add-Liste wieder aus dem Zahlenformatierer entfernt.
+ *
+ * Loeschen von Formaten aus dem Formatierer passiert
+ * aus Undo-Gruenden nur in der aufrufenden Instanz.
+ */
+
+ if ( bUndoAddList )
+ {
+ // Hinzugefuegte Formate sind nicht gueltig:
+ // => wieder entfernen:
+
+ for ( sal_uInt16 i = 0; i < aAddList.Count(); ++i )
+ pFormatter->DeleteEntry( aAddList[i] );
+ }
+
+ //--------------------------------
+ // Add-/Remove-Listen leerraeumen:
+ //--------------------------------
+ aAddList.Remove( 0, aAddList.Count() );
+ aDelList.Remove( 0, aAddList.Count() );
+
+ if(aCurrencyFormatList.Count()>0)
+ aCurrencyFormatList.DeleteAndDestroy(0,aCurrencyFormatList.Count());
+}
+
+// -----------------------------------------------------------------------
+
+sal_uInt32 SvxNumberFormatShell::GetUpdateDataCount() const
+{
+ return aDelList.Count();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberFormatShell::GetUpdateData( sal_uInt32* pDelArray, const sal_uInt32 nSize )
+{
+ const sal_uInt32 nCount = aDelList.Count();
+
+ DBG_ASSERT( pDelArray && ( nSize == nCount ), "Array nicht initialisiert!" );
+
+ if ( pDelArray && ( nSize == nCount ) )
+ for ( sal_uInt16 i = 0; i < aDelList.Count(); ++i )
+ *pDelArray++ = aDelList[i];
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberFormatShell::CategoryChanged( sal_uInt16 nCatLbPos,
+ short& rFmtSelPos,
+ SvStrings& rFmtEntries )
+{
+ short nOldCategory = nCurCategory;
+ PosToCategory_Impl( nCatLbPos, nCurCategory );
+ pCurFmtTable = &( pFormatter->GetEntryTable( nCurCategory,
+ nCurFormatKey,
+ eCurLanguage ) );
+ // reinitialize currency if category newly entered
+ if ( nCurCategory == NUMBERFORMAT_CURRENCY && nOldCategory != nCurCategory )
+ pCurCurrencyEntry = NULL;
+ rFmtSelPos = FillEntryList_Impl( rFmtEntries );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberFormatShell::LanguageChanged( LanguageType eLangType,
+ short& rFmtSelPos,
+ SvStrings& rFmtEntries )
+{
+ eCurLanguage = eLangType;
+ pCurFmtTable = &(pFormatter->ChangeCL( nCurCategory,
+ nCurFormatKey,
+ eCurLanguage ) );
+ rFmtSelPos = FillEntryList_Impl( rFmtEntries );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberFormatShell::FormatChanged( sal_uInt16 nFmtLbPos,
+ String& rPreviewStr,
+ Color*& rpFontColor )
+{
+ //nCurFormatKey = pCurFmtTable->GetKey( pCurFmtTable->GetObject( nFmtLbPos ) );
+
+ if(nFmtLbPos<aCurEntryList.Count())
+ {
+ nCurFormatKey=aCurEntryList[nFmtLbPos];
+
+ if(nCurFormatKey!=NUMBERFORMAT_ENTRY_NOT_FOUND)
+ {
+ GetPreviewString_Impl( rPreviewStr, rpFontColor );
+ }
+ else if(nCurCategory==NUMBERFORMAT_CURRENCY)
+ {
+ if(nFmtLbPos<aCurrencyFormatList.Count())
+ {
+ //nCurFormatKey=nFmtLbPos;
+ MakePrevStringFromVal(*aCurrencyFormatList[nFmtLbPos],
+ rPreviewStr,rpFontColor,nValNum);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------
+
+sal_Bool SvxNumberFormatShell::AddFormat( String& rFormat, xub_StrLen& rErrPos,
+ sal_uInt16& rCatLbSelPos, short& rFmtSelPos,
+ SvStrings& rFmtEntries )
+{
+ sal_Bool bInserted = sal_False;
+ sal_uInt32 nAddKey = pFormatter->GetEntryKey( rFormat, eCurLanguage );
+
+ if ( nAddKey != NUMBERFORMAT_ENTRY_NOT_FOUND ) // bereits vorhanden?
+ {
+ if ( IsRemoved_Impl( nAddKey ) )
+ {
+ // Key suchen und loeschen
+ sal_Bool bFound = sal_False;
+ sal_uInt16 nAt = 0;
+
+ for ( sal_uInt16 i = 0; !bFound && i < aDelList.Count(); ++i )
+ {
+ if ( aDelList[i] == nAddKey )
+ {
+ bFound = sal_True;
+ nAt = i;
+ }
+ }
+ DBG_ASSERT( bFound, "Key not found" );
+ aDelList.Remove( nAt );
+ bInserted = sal_True;
+ }
+ else
+ {
+ DBG_ERROR( "Doppeltes Format!" );
+ }
+ }
+ else // neues Format
+ {
+ bInserted = pFormatter->PutEntry( rFormat, rErrPos,
+ nCurCategory, nAddKey,
+ eCurLanguage );
+ }
+
+ if ( bInserted ) // eingefuegt
+ {
+ nCurFormatKey = nAddKey;
+ DBG_ASSERT( !IsAdded_Impl( nCurFormatKey ), "Doppeltes Format!" );
+ aAddList.Insert( nCurFormatKey, aAddList.Count() );
+
+ // aktuelle Tabelle holen
+ pCurFmtTable = &(pFormatter->GetEntryTable( nCurCategory,
+ nCurFormatKey,
+ eCurLanguage ));
+ nCurCategory=pFormatter->GetType(nAddKey); //@@ ???
+ CategoryToPos_Impl( nCurCategory, rCatLbSelPos );
+ rFmtSelPos = FillEntryList_Impl( rFmtEntries );
+ }
+ else if ( rErrPos != 0 ) // Syntaxfehler
+ {
+ ;
+ }
+ else // Doppelt einfuegen nicht moeglich
+ {
+ DBG_ERROR( "Doppeltes Format!" ); // oder doch?
+ }
+
+ return bInserted;
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool SvxNumberFormatShell::RemoveFormat( const String& rFormat,
+ sal_uInt16& rCatLbSelPos,
+ short& rFmtSelPos,
+ SvStrings& rFmtEntries )
+{
+ sal_uInt32 nDelKey = pFormatter->GetEntryKey( rFormat, eCurLanguage );
+
+ DBG_ASSERT( nDelKey != NUMBERFORMAT_ENTRY_NOT_FOUND, "Eintrag nicht gefunden!" );
+ DBG_ASSERT( !IsRemoved_Impl( nDelKey ), "Eintrag bereits geloescht!" );
+
+ if ( (nDelKey != NUMBERFORMAT_ENTRY_NOT_FOUND) && !IsRemoved_Impl( nDelKey ) )
+ {
+ aDelList.Insert( nDelKey, aDelList.Count() );
+
+ if ( IsAdded_Impl( nDelKey ) )
+ {
+ // Key suchen und loeschen
+ sal_Bool bFound = sal_False;
+ sal_uInt16 nAt = 0;
+
+ for ( sal_uInt16 i = 0; !bFound && i < aAddList.Count(); ++i )
+ {
+ if ( aAddList[i] == nDelKey )
+ {
+ bFound = sal_True;
+ nAt = i;
+ }
+ }
+ DBG_ASSERT( bFound, "Key not found" );
+ aAddList.Remove( nAt );
+ }
+
+ nCurCategory=pFormatter->GetType(nDelKey); //@@ 01.10.97
+ pCurFmtTable = &(pFormatter->GetEntryTable( nCurCategory,
+ nCurFormatKey,
+ eCurLanguage ));
+
+ nCurFormatKey=pFormatter->GetStandardFormat(nCurCategory,
+ eCurLanguage );
+
+ CategoryToPos_Impl( nCurCategory, rCatLbSelPos );
+ rFmtSelPos = FillEntryList_Impl( rFmtEntries );
+ //rFmtSelPos = (short) nCurFormatKey; //@@ 01.10.97
+ }
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberFormatShell::MakeFormat( String& rFormat,
+ sal_Bool bThousand, sal_Bool bNegRed,
+ sal_uInt16 nPrecision, sal_uInt16 nLeadingZeroes,
+ sal_uInt16 nCurrencyPos)
+{
+ if(aCurrencyFormatList.Count()>nCurrencyPos)
+ {
+ xub_StrLen rErrPos=0;
+ sal_uInt16 rCatLbSelPos=0;
+ short rFmtSelPos=0;
+ SvStrings aFmtEList;
+
+ sal_uInt32 nFound = pFormatter->TestNewString( *aCurrencyFormatList[nCurrencyPos], eCurLanguage );
+
+ if ( nFound == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ {
+ AddFormat( *aCurrencyFormatList[nCurrencyPos],rErrPos,rCatLbSelPos,
+ rFmtSelPos,aFmtEList);
+ }
+
+ if(rErrPos==0)
+ {
+ pFormatter->GenerateFormat( rFormat, nCurFormatKey,
+ eCurLanguage,
+ bThousand, bNegRed,
+ nPrecision, nLeadingZeroes );
+ }
+ aFmtEList.DeleteAndDestroy(0,aFmtEList.Count());
+ }
+ else
+ {
+ pFormatter->GenerateFormat( rFormat, nCurFormatKey,
+ eCurLanguage,
+ bThousand, bNegRed,
+ nPrecision, nLeadingZeroes );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberFormatShell::GetOptions( const String& rFormat,
+ sal_Bool& rThousand,
+ sal_Bool& rNegRed,
+ sal_uInt16& rPrecision,
+ sal_uInt16& rLeadingZeroes,
+ sal_uInt16& rCatLbPos )
+{
+
+ sal_uInt32 nFmtKey = pFormatter->GetEntryKey( rFormat, eCurLanguage );
+
+ if(nFmtKey != NUMBERFORMAT_ENTRY_NOT_FOUND)
+ {
+ if ( nFmtKey != NUMBERFORMAT_ENTRY_NOT_FOUND )
+ {
+ pFormatter->GetFormatSpecialInfo( nFmtKey,
+ rThousand, rNegRed,
+ rPrecision, rLeadingZeroes );
+
+ CategoryToPos_Impl( pFormatter->GetType( nFmtKey ), rCatLbPos );
+ }
+ else
+ rCatLbPos = CAT_USERDEFINED;
+ }
+ else
+ {
+ sal_Bool bTestBanking=sal_False;
+ sal_uInt16 nPos=FindCurrencyTableEntry(rFormat, bTestBanking );
+
+ if(IsInTable(nPos,bTestBanking,rFormat) &&
+ pFormatter->GetFormatSpecialInfo( rFormat,rThousand, rNegRed,
+ rPrecision, rLeadingZeroes,eCurLanguage)==0)
+ {
+ rCatLbPos = CAT_CURRENCY;
+ }
+ else
+ rCatLbPos = CAT_USERDEFINED;
+ }
+
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberFormatShell::MakePreviewString( const String& rFormatStr,
+ String& rPreviewStr,
+ Color*& rpFontColor )
+{
+ rpFontColor = NULL;
+
+ ULONG nExistingFormat = pFormatter->GetEntryKey( rFormatStr, eCurLanguage );
+ if ( nExistingFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ {
+ // real preview - not implemented in NumberFormatter for text formats
+
+ pFormatter->GetPreviewString( rFormatStr, nValNum, rPreviewStr,
+ &rpFontColor, eCurLanguage );
+ }
+ else
+ {
+ // format exists
+
+ // #50441# if a string was set in addition to the value, use it for text formats
+ BOOL bUseText = ( eValType == SVX_VALUE_TYPE_STRING ||
+ ( aValStr.Len() && ( pFormatter->GetType(nExistingFormat) & NUMBERFORMAT_TEXT ) ) );
+ if ( bUseText )
+ pFormatter->GetOutputString( aValStr, nExistingFormat,
+ rPreviewStr, &rpFontColor );
+ else
+ pFormatter->GetOutputString( nValNum, nExistingFormat,
+ rPreviewStr, &rpFontColor );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool SvxNumberFormatShell::IsUserDefined( const String& rFmtString )
+{
+ sal_uInt32 nFound = pFormatter->GetEntryKey( rFmtString, eCurLanguage );
+
+ sal_Bool bFlag=sal_False;
+ if ( nFound != NUMBERFORMAT_ENTRY_NOT_FOUND )
+ {
+ bFlag=pFormatter->IsUserDefined( rFmtString, eCurLanguage );
+
+ if(bFlag)
+ {
+ const SvNumberformat* pNumEntry = pFormatter->GetEntry(nFound);
+
+ if(pNumEntry!=NULL && pNumEntry->HasNewCurrency())
+ {
+ sal_Bool bTestBanking;
+ sal_uInt16 nPos=FindCurrencyTableEntry(rFmtString,bTestBanking);
+ bFlag=!IsInTable(nPos,bTestBanking,rFmtString);
+ }
+ }
+ }
+ return bFlag;
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool SvxNumberFormatShell::FindEntry( const String& rFmtString, sal_uInt32* pAt /* = NULL */ )
+{
+ sal_Bool bRes=sal_False;
+ sal_uInt32 nFound = pFormatter->TestNewString( rFmtString, eCurLanguage );
+
+ if ( nFound == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ {
+ sal_Bool bTestBanking=sal_False;
+ sal_uInt16 nPos=FindCurrencyTableEntry(rFmtString, bTestBanking );
+
+ if(IsInTable(nPos,bTestBanking,rFmtString))
+ {
+ nFound=NUMBERFORMAT_ENTRY_NEW_CURRENCY;
+ bRes=sal_True;
+ }
+ }
+ else
+ {
+ bRes=!IsRemoved_Impl( nFound );
+ }
+
+ if ( pAt )
+ *pAt = nFound;
+
+ return bRes;
+}
+
+
+// -----------------------------------------------------------------------
+
+void SvxNumberFormatShell::GetInitSettings(
+ sal_uInt16& nCatLbPos,
+ LanguageType& rLangType,
+ sal_uInt16& nFmtLbSelPos,
+ SvStrings& rFmtEntries,
+ String& rPrevString,
+ Color*& rpPrevColor )
+{
+ // -------------------------------------------------------------------
+ // Vorbedingung: Zahlenformatierer gefunden
+ DBG_ASSERT( pFormatter != NULL, "Zahlenformatierer nicht gefunden!" );
+
+// sal_uInt16 nCount = 0;
+ short nSelPos = SELPOS_NONE;
+// SvNumberFormatTable* pFmtTable = NULL;
+
+ // Sonderbehandlung fuer undefiniertes Zahlenformat:
+ if ( (eValType == SVX_VALUE_TYPE_UNDEFINED) && (nCurFormatKey == 0) )
+ PosToCategory_Impl( CAT_ALL, nCurCategory ); // Kategorie = Alle
+ else
+ nCurCategory = NUMBERFORMAT_UNDEFINED; // Kategorie = Undefiniert
+
+ pCurFmtTable = &(pFormatter->GetFirstEntryTable( nCurCategory,
+ nCurFormatKey,
+ eCurLanguage ));
+
+
+
+ CategoryToPos_Impl( nCurCategory, nCatLbPos );
+ rLangType = eCurLanguage;
+
+ nSelPos = FillEntryList_Impl( rFmtEntries );
+
+ DBG_ASSERT( nSelPos != SELPOS_NONE, "Leere Formatliste!" );
+
+ nFmtLbSelPos = (nSelPos != SELPOS_NONE) ? (sal_uInt16)nSelPos : 0;
+ GetPreviewString_Impl( rPrevString, rpPrevColor );
+}
+
+// -----------------------------------------------------------------------
+
+short SvxNumberFormatShell::FillEntryList_Impl( SvStrings& rList )
+{
+ /* Erstellen einer aktuellen Liste von Format-Eintraegen.
+ * Rueckgabewert ist die Listenposition des aktuellen Formates.
+ * Ist die Liste leer oder gibt es kein aktuelles Format,
+ * so wird SELPOS_NONE geliefert.
+ */
+ short nSelPos=0;
+ aCurEntryList.Remove(nSelPos,aCurEntryList.Count());
+ sal_uInt16 nPrivCat = CAT_CURRENCY;
+ nSelPos=SELPOS_NONE;
+
+ if(nCurCategory==NUMBERFORMAT_ALL)
+ {
+ FillEListWithStd_Impl(rList,CAT_NUMBER,nSelPos);
+ FillEListWithStd_Impl(rList,CAT_PERCENT,nSelPos);
+ FillEListWithStd_Impl(rList,CAT_CURRENCY,nSelPos);
+ FillEListWithStd_Impl(rList,CAT_DATE,nSelPos);
+ FillEListWithStd_Impl(rList,CAT_TIME,nSelPos);
+ FillEListWithStd_Impl(rList,CAT_SCIENTIFIC,nSelPos);
+ FillEListWithStd_Impl(rList,CAT_FRACTION,nSelPos);
+ FillEListWithStd_Impl(rList,CAT_BOOLEAN,nSelPos);
+ FillEListWithStd_Impl(rList,CAT_TEXT,nSelPos);
+ }
+ else
+ {
+ CategoryToPos_Impl(nCurCategory, nPrivCat);
+ FillEListWithStd_Impl(rList,nPrivCat,nSelPos);
+ }
+
+ if( nPrivCat!=CAT_CURRENCY)
+ nSelPos=FillEListWithUsD_Impl(rList,nPrivCat,nSelPos);
+
+ return nSelPos;
+}
+
+void SvxNumberFormatShell::FillEListWithStd_Impl( SvStrings& rList,sal_uInt16 nPrivCat,short &nSelPos )
+{
+ /* Erstellen einer aktuellen Liste von Format-Eintraegen.
+ * Rueckgabewert ist die Listenposition des aktuellen Formates.
+ * Ist die Liste leer oder gibt es kein aktuelles Format,
+ * so wird SELPOS_NONE geliefert.
+ */
+ DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
+
+ if(aCurrencyFormatList.Count()>0)
+ aCurrencyFormatList.DeleteAndDestroy(0,aCurrencyFormatList.Count());
+
+ if(nPrivCat==CAT_CURRENCY)
+ {
+ nSelPos=FillEListWithCurrency_Impl(rList,nSelPos);
+ }
+ else
+ {
+ NfIndexTableOffset eOffsetStart;
+ NfIndexTableOffset eOffsetEnd;
+
+ switch(nPrivCat)
+ {
+ case CAT_NUMBER :eOffsetStart=NF_NUMBER_START;
+ eOffsetEnd=NF_NUMBER_END;
+ break;
+ case CAT_PERCENT :eOffsetStart=NF_PERCENT_START;
+ eOffsetEnd=NF_PERCENT_END;
+ break;
+ case CAT_CURRENCY :eOffsetStart=NF_CURRENCY_START;
+ eOffsetEnd=NF_CURRENCY_END;
+ break;
+ case CAT_DATE :eOffsetStart=NF_DATE_START;
+ eOffsetEnd=NF_DATE_END;
+ break;
+ case CAT_TIME :eOffsetStart=NF_TIME_START;
+ eOffsetEnd=NF_TIME_END;
+ break;
+ case CAT_SCIENTIFIC :eOffsetStart=NF_SCIENTIFIC_START;
+ eOffsetEnd=NF_SCIENTIFIC_END;
+ break;
+ case CAT_FRACTION :eOffsetStart=NF_FRACTION_START;
+ eOffsetEnd=NF_FRACTION_END;
+ break;
+ case CAT_BOOLEAN :eOffsetStart=NF_BOOLEAN;
+ eOffsetEnd=NF_BOOLEAN;
+ break;
+ case CAT_TEXT :eOffsetStart=NF_TEXT;
+ eOffsetEnd=NF_TEXT;
+ break;
+ default :return;
+ }
+
+ nSelPos=FillEListWithFormats_Impl(rList,nSelPos,eOffsetStart,eOffsetEnd);
+
+ if(nPrivCat==CAT_DATE || nPrivCat==CAT_TIME)
+ {
+ nSelPos=FillEListWithDateTime_Impl(rList,nSelPos);
+ //if(nSelPos!=SELPOS_NONE) nSelPos=nTmpPos;
+ }
+ }
+}
+
+short SvxNumberFormatShell::FillEListWithFormats_Impl( SvStrings& rList,short nSelPos,
+ NfIndexTableOffset eOffsetStart,
+ NfIndexTableOffset eOffsetEnd)
+{
+ /* Erstellen einer aktuellen Liste von Format-Eintraegen.
+ * Rueckgabewert ist die Listenposition des aktuellen Formates.
+ * Ist die Liste leer oder gibt es kein aktuelles Format,
+ * so wird SELPOS_NONE geliefert.
+ */
+ sal_uInt16 nMyType;
+
+ DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
+
+ const SvNumberformat* pNumEntry = pCurFmtTable->First();
+// sal_uInt16 nCount = 0;
+ sal_uInt32 nNFEntry;
+ String aStrComment;
+ String aNewFormNInfo;
+ String aPrevString;
+ String a2PrevString;
+
+ short nMyCat = SELPOS_NONE;
+// short nIq=0;
+
+ long nIndex;
+
+ for(nIndex=eOffsetStart;nIndex<=eOffsetEnd;nIndex++)
+ {
+ nNFEntry=pFormatter->GetFormatIndex((NfIndexTableOffset)nIndex,eCurLanguage);
+
+ pNumEntry = pFormatter->GetEntry(nNFEntry);
+
+ if(pNumEntry==NULL) continue;
+
+ nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
+ aStrComment=pNumEntry->GetComment();
+ CategoryToPos_Impl(nMyCat,nMyType);
+ aNewFormNInfo= pNumEntry->GetFormatstring();
+
+ const StringPtr pStr = new String(aNewFormNInfo);
+
+ if ( nNFEntry == nCurFormatKey )
+ {
+ nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.Count() : SELPOS_NONE;
+ }
+
+ rList.Insert( pStr,rList.Count());
+ aCurEntryList.Insert( nNFEntry, aCurEntryList.Count() );
+ }
+
+ return nSelPos;
+}
+
+short SvxNumberFormatShell::FillEListWithDateTime_Impl( SvStrings& rList,short nSelPos)
+{
+ sal_uInt16 nMyType;
+
+ DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
+
+ const SvNumberformat* pNumEntry = pCurFmtTable->First();
+// sal_uInt16 nCount = 0;
+ sal_uInt32 nNFEntry;
+ String aStrComment;
+ String aNewFormNInfo;
+ String aPrevString;
+ String a2PrevString;
+
+ short nMyCat = SELPOS_NONE;
+// short nIq=0;
+
+ long nIndex;
+
+ for(nIndex=NF_DATETIME_START;nIndex<=NF_DATETIME_END;nIndex++)
+ {
+ nNFEntry=pFormatter->GetFormatIndex((NfIndexTableOffset)nIndex,eCurLanguage);
+
+ pNumEntry = pFormatter->GetEntry(nNFEntry);
+ if(pNumEntry!=NULL)
+ {
+ nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
+ aStrComment=pNumEntry->GetComment();
+ CategoryToPos_Impl(nMyCat,nMyType);
+ aNewFormNInfo= pNumEntry->GetFormatstring();
+
+ const StringPtr pStr = new String(aNewFormNInfo);
+
+ if ( nNFEntry == nCurFormatKey )
+ {
+ nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.Count() : SELPOS_NONE;
+ }
+
+ rList.Insert( pStr,rList.Count());
+ aCurEntryList.Insert( nNFEntry, aCurEntryList.Count() );
+ }
+ }
+
+ return nSelPos;
+}
+
+short SvxNumberFormatShell::FillEListWithCurrency_Impl( SvStrings& rList,short nSelPos)
+{
+ /* Erstellen einer aktuellen Liste von Format-Eintraegen.
+ * Rueckgabewert ist die Listenposition des aktuellen Formates.
+ * Ist die Liste leer oder gibt es kein aktuelles Format,
+ * so wird SELPOS_NONE geliefert.
+ */
+ DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
+
+ const NfCurrencyEntry* pTmpCurrencyEntry;
+ sal_Bool bTmpBanking;
+ XubString rSymbol;
+
+ sal_Bool bFlag=pFormatter->GetNewCurrencySymbolString(nCurFormatKey,rSymbol,
+ &pTmpCurrencyEntry,&bTmpBanking);
+
+ if((!bFlag && pCurCurrencyEntry==NULL) ||
+ (bFlag && pTmpCurrencyEntry==NULL && !rSymbol.Len()) ||
+ nCurCategory==NUMBERFORMAT_ALL)
+ {
+ if ( nCurCategory == NUMBERFORMAT_ALL )
+ FillEListWithUserCurrencys(rList,nSelPos);
+ nSelPos=FillEListWithSysCurrencys(rList,nSelPos);
+ }
+ else
+ {
+ nSelPos=FillEListWithUserCurrencys(rList,nSelPos);
+ }
+
+ return nSelPos;
+}
+
+
+short SvxNumberFormatShell::FillEListWithSysCurrencys( SvStrings& rList,short nSelPos)
+{
+ /* Erstellen einer aktuellen Liste von Format-Eintraegen.
+ * Rueckgabewert ist die Listenposition des aktuellen Formates.
+ * Ist die Liste leer oder gibt es kein aktuelles Format,
+ * so wird SELPOS_NONE geliefert.
+ */
+ sal_uInt16 nMyType;
+
+ DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
+
+ const SvNumberformat* pNumEntry = pCurFmtTable->First();
+ sal_uInt16 nCount = 0;
+ sal_uInt32 nNFEntry;
+ String aStrComment;
+ String aNewFormNInfo;
+ String aPrevString;
+ String a2PrevString;
+
+ nCurCurrencyEntryPos=0;
+
+ short nMyCat = SELPOS_NONE;
+// short nIq=0;
+
+ NfIndexTableOffset eOffsetStart=NF_CURRENCY_START;
+ NfIndexTableOffset eOffsetEnd=NF_CURRENCY_END;;
+ long nIndex;
+
+ for(nIndex=eOffsetStart;nIndex<=eOffsetEnd;nIndex++)
+ {
+ nNFEntry=pFormatter->GetFormatIndex((NfIndexTableOffset)nIndex,eCurLanguage);
+
+ pNumEntry = pFormatter->GetEntry(nNFEntry);
+
+ if(pNumEntry==NULL) continue;
+
+ nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
+ aStrComment=pNumEntry->GetComment();
+ CategoryToPos_Impl(nMyCat,nMyType);
+ aNewFormNInfo= pNumEntry->GetFormatstring();
+
+ const StringPtr pStr = new String(aNewFormNInfo);
+
+ if ( nNFEntry == nCurFormatKey )
+ {
+ nSelPos = ( !IsRemoved_Impl( nNFEntry ) ) ? aCurEntryList.Count() : SELPOS_NONE;
+ }
+
+ rList.Insert( pStr,rList.Count());
+ aCurEntryList.Insert( nNFEntry, aCurEntryList.Count() );
+ }
+
+ if(nCurCategory!=NUMBERFORMAT_ALL)
+ {
+ pNumEntry = pCurFmtTable->First();
+ nCount = 0;
+ while ( pNumEntry )
+ {
+ sal_uInt32 nKey = pCurFmtTable->GetCurKey();
+
+ nCount++;
+
+ if ( !IsRemoved_Impl( nKey ))
+ {
+ sal_Bool bUserNewCurrency=sal_False;
+ if(pNumEntry->HasNewCurrency())
+ {
+ const NfCurrencyEntry* pTmpCurrencyEntry;
+ sal_Bool bTmpBanking;
+ XubString rSymbol;
+
+ pFormatter->GetNewCurrencySymbolString(nKey,rSymbol,
+ &pTmpCurrencyEntry,&bTmpBanking);
+
+ bUserNewCurrency=(pTmpCurrencyEntry!=NULL);
+ }
+
+ if(!bUserNewCurrency &&(pNumEntry->GetType() & NUMBERFORMAT_DEFINED))
+ {
+ nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
+ aStrComment=pNumEntry->GetComment();
+ CategoryToPos_Impl(nMyCat,nMyType);
+ aNewFormNInfo= pNumEntry->GetFormatstring();
+
+ const StringPtr pStr = new String(aNewFormNInfo);
+
+ if ( nKey == nCurFormatKey ) nSelPos =aCurEntryList.Count();
+ rList.Insert( pStr,rList.Count());
+ aCurEntryList.Insert( nKey, aCurEntryList.Count() );
+ }
+ }
+ pNumEntry = pCurFmtTable->Next();
+ }
+ }
+ return nSelPos;
+}
+
+short SvxNumberFormatShell::FillEListWithUserCurrencys( SvStrings& rList,short nSelPos)
+{
+ /* Erstellen einer aktuellen Liste von Format-Eintraegen.
+ * Rueckgabewert ist die Listenposition des aktuellen Formates.
+ * Ist die Liste leer oder gibt es kein aktuelles Format,
+ * so wird SELPOS_NONE geliefert.
+ */
+ sal_uInt16 nMyType;
+
+ DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
+
+ sal_uInt16 nCount = 0;
+ String aStrComment;
+ String aNewFormNInfo;
+ String aPrevString;
+ String a2PrevString;
+ short nMyCat = SELPOS_NONE;
+// short nIq=0;
+
+ const NfCurrencyEntry* pTmpCurrencyEntry;
+ sal_Bool bTmpBanking, bAdaptSelPos;
+ XubString rSymbol;
+ XubString rBankSymbol;
+
+ SvStrings aList;
+ SvULongs aKeyList;
+
+ /*sal_Bool bFlag=*/pFormatter->GetNewCurrencySymbolString(nCurFormatKey,rSymbol,
+ &pTmpCurrencyEntry,&bTmpBanking);
+
+ XubString rShortSymbol;
+
+ if(pCurCurrencyEntry==NULL)
+ {
+ // #110398# If no currency format was previously selected (we're not
+ // about to add another currency), try to select the initial currency
+ // format (nCurFormatKey) that was set in FormatChanged() after
+ // matching the format string entered in the dialog.
+ bAdaptSelPos = sal_True;
+ pCurCurrencyEntry=(NfCurrencyEntry*)pTmpCurrencyEntry;
+ bBankingSymbol=bTmpBanking;
+ nCurCurrencyEntryPos=FindCurrencyFormat(pTmpCurrencyEntry,bTmpBanking);
+ }
+ else
+ {
+ if (pTmpCurrencyEntry == pCurCurrencyEntry)
+ bAdaptSelPos = sal_True;
+ else
+ {
+ bAdaptSelPos = sal_False;
+ pTmpCurrencyEntry = pCurCurrencyEntry;
+ }
+ bTmpBanking=bBankingSymbol;
+ }
+
+ if(pTmpCurrencyEntry!=NULL)
+ {
+ pTmpCurrencyEntry->BuildSymbolString(rSymbol,sal_False);
+ pTmpCurrencyEntry->BuildSymbolString(rBankSymbol,sal_True);
+ pTmpCurrencyEntry->BuildSymbolString(rShortSymbol,bTmpBanking,sal_True);
+ }
+
+ const SvNumberformat* pNumEntry = pCurFmtTable->First();
+
+ while ( pNumEntry )
+ {
+ sal_uInt32 nKey = pCurFmtTable->GetCurKey();
+
+ nCount++;
+
+ if ( !IsRemoved_Impl( nKey ) )
+ {
+ if( pNumEntry->GetType() & NUMBERFORMAT_DEFINED ||
+ pNumEntry->IsAdditionalStandardDefined() )
+ {
+ nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
+ aStrComment=pNumEntry->GetComment();
+ CategoryToPos_Impl(nMyCat,nMyType);
+ aNewFormNInfo= pNumEntry->GetFormatstring();
+
+ sal_Bool bInsFlag=sal_False;
+ if ( pNumEntry->HasNewCurrency() )
+ bInsFlag = sal_True; // merge locale formats into currency selection
+ else if( (!bTmpBanking && aNewFormNInfo.Search(rSymbol)!=STRING_NOTFOUND) ||
+ (bTmpBanking && aNewFormNInfo.Search(rBankSymbol)!=STRING_NOTFOUND) )
+ {
+ bInsFlag=sal_True;
+ }
+ else if(aNewFormNInfo.Search(rShortSymbol)!=STRING_NOTFOUND)
+ {
+ XubString rTstSymbol;
+ const NfCurrencyEntry* pTstCurrencyEntry;
+ sal_Bool bTstBanking;
+
+ /*sal_Bool bTstFlag=*/pFormatter->GetNewCurrencySymbolString(nKey,rTstSymbol,
+ &pTstCurrencyEntry,&bTstBanking);
+
+ if(pTmpCurrencyEntry==pTstCurrencyEntry && bTstBanking==bTmpBanking)
+ {
+ bInsFlag=sal_True;
+ }
+
+ }
+
+ if(bInsFlag)
+ {
+ const StringPtr pStr = new String(aNewFormNInfo);
+
+ aList.Insert( pStr,aList.Count());
+ aKeyList.Insert( nKey, aKeyList.Count() );
+ }
+ }
+ }
+ pNumEntry = pCurFmtTable->Next();
+ }
+
+ NfWSStringsDtor aWSStringsDtor;
+ sal_uInt16 nDefault;
+ if ( pTmpCurrencyEntry && nCurCategory != NUMBERFORMAT_ALL )
+ {
+ nDefault = pFormatter->GetCurrencyFormatStrings(
+ aWSStringsDtor, *pTmpCurrencyEntry, bTmpBanking );
+ if ( !bTmpBanking )
+ pFormatter->GetCurrencyFormatStrings(
+ aWSStringsDtor, *pTmpCurrencyEntry, TRUE );
+ }
+ else
+ nDefault = 0;
+ if ( !bTmpBanking && nCurCategory != NUMBERFORMAT_ALL )
+ { // append formats for all currencies defined in the current I18N locale
+ const NfCurrencyTable& rCurrencyTable = SvNumberFormatter::GetTheCurrencyTable();
+ sal_uInt16 nCurrCount = rCurrencyTable.Count();
+ LanguageType eLang = MsLangId::getRealLanguage( eCurLanguage );
+ for ( sal_uInt16 i=0; i < nCurrCount; ++i )
+ {
+ const NfCurrencyEntry* pCurr = rCurrencyTable[i];
+ if ( pCurr->GetLanguage() == eLang && pTmpCurrencyEntry != pCurr )
+ {
+ pFormatter->GetCurrencyFormatStrings( aWSStringsDtor, *pCurr, FALSE );
+ pFormatter->GetCurrencyFormatStrings( aWSStringsDtor, *pCurr, TRUE );
+ }
+ }
+ }
+
+ sal_uInt16 i,nPos;
+ sal_uInt16 nOldListCount = rList.Count();
+ for( i=0, nPos=nOldListCount; i<aWSStringsDtor.Count(); i++)
+ {
+ sal_Bool bFlag=sal_True;
+ String aInsStr(*aWSStringsDtor[i]);
+ sal_uInt16 j;
+ for(j=0;j<aList.Count();j++)
+ {
+ const StringPtr pTestStr=aList[j];
+
+ if(*pTestStr==aInsStr)
+ {
+ bFlag=sal_False;
+ break;
+ }
+ }
+ if(bFlag)
+ {
+ rList.Insert(new String(aInsStr),nPos);
+ aCurEntryList.Insert( NUMBERFORMAT_ENTRY_NOT_FOUND, nPos++);
+ }
+ else
+ {
+ rList.Insert(aList[j],nPos);
+ aList.Remove(j);
+ aCurEntryList.Insert( aKeyList[j],nPos++);
+ aKeyList.Remove(j);
+ }
+ }
+
+ for(i=0;i<aKeyList.Count();i++)
+ {
+ if(aKeyList[i]!=NUMBERFORMAT_ENTRY_NOT_FOUND)
+ {
+ rList.Insert(aList[i],rList.Count());
+ aCurEntryList.Insert( aKeyList[i],aCurEntryList.Count());
+ }
+ }
+
+ for(i=nOldListCount;i<rList.Count();i++)
+ {
+ aCurrencyFormatList.Insert(new String(*rList[i]),aCurrencyFormatList.Count());
+
+ if ( nSelPos == SELPOS_NONE && bAdaptSelPos && aCurEntryList[i] == nCurFormatKey )
+ nSelPos = i;
+ }
+
+ if ( nSelPos == SELPOS_NONE && nCurCategory != NUMBERFORMAT_ALL )
+ nSelPos = nDefault;
+
+ return nSelPos;
+}
+
+
+short SvxNumberFormatShell::FillEListWithUsD_Impl( SvStrings& rList, sal_uInt16 nPrivCat, short nSelPos)
+{
+ /* Erstellen einer aktuellen Liste von Format-Eintraegen.
+ * Rueckgabewert ist die Listenposition des aktuellen Formates.
+ * Ist die Liste leer oder gibt es kein aktuelles Format,
+ * so wird SELPOS_NONE geliefert.
+ */
+ sal_uInt16 nMyType;
+
+ DBG_ASSERT( pCurFmtTable != NULL, "Unbekanntes Zahlenformat!" );
+
+ const SvNumberformat* pNumEntry = pCurFmtTable->First();
+ sal_uInt16 nCount = 0;
+ String aStrComment;
+ String aNewFormNInfo;
+ String aPrevString;
+ String a2PrevString;
+
+ short nMyCat = SELPOS_NONE;
+// short nIq=0;
+ sal_Bool bAdditional = (nPrivCat != CAT_USERDEFINED &&
+ nCurCategory != NUMBERFORMAT_ALL);
+
+ while ( pNumEntry )
+ {
+ sal_uInt32 nKey = pCurFmtTable->GetCurKey();
+
+ nCount++;
+
+ if ( !IsRemoved_Impl( nKey ) )
+ {
+ if( (pNumEntry->GetType() & NUMBERFORMAT_DEFINED) ||
+ (bAdditional && pNumEntry->IsAdditionalStandardDefined()) )
+ {
+ nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
+ aStrComment=pNumEntry->GetComment();
+ CategoryToPos_Impl(nMyCat,nMyType);
+ aNewFormNInfo= pNumEntry->GetFormatstring();
+
+ sal_Bool bFlag=sal_True;
+ if(pNumEntry->HasNewCurrency())
+ {
+ sal_Bool bTestBanking;
+ sal_uInt16 nPos=FindCurrencyTableEntry(aNewFormNInfo,bTestBanking);
+ bFlag=!IsInTable(nPos,bTestBanking,aNewFormNInfo);
+ }
+ if(bFlag)
+ {
+ const StringPtr pStr = new String(aNewFormNInfo);
+
+ if ( nKey == nCurFormatKey ) nSelPos =aCurEntryList.Count();
+ rList.Insert( pStr,rList.Count());
+ aCurEntryList.Insert( nKey, aCurEntryList.Count() );
+ }
+ }
+ }
+ pNumEntry = pCurFmtTable->Next();
+ }
+ return nSelPos;
+}
+
+
+// -----------------------------------------------------------------------
+
+void SvxNumberFormatShell::GetPreviewString_Impl( String& rString, Color*& rpColor )
+{
+ rpColor = NULL;
+
+ // #50441# if a string was set in addition to the value, use it for text formats
+ BOOL bUseText = ( eValType == SVX_VALUE_TYPE_STRING ||
+ ( aValStr.Len() && ( pFormatter->GetType(nCurFormatKey) & NUMBERFORMAT_TEXT ) ) );
+
+ if ( bUseText )
+ pFormatter->GetOutputString( aValStr, nCurFormatKey, rString, &rpColor );
+ else
+ pFormatter->GetOutputString( nValNum, nCurFormatKey, rString, &rpColor );
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool SvxNumberFormatShell::IsRemoved_Impl( sal_uInt32 nKey )
+{
+ sal_Bool bFound = sal_False;
+ for ( sal_uInt16 i = 0; !bFound && i < aDelList.Count(); ++i )
+ if ( aDelList[i] == nKey )
+ bFound = sal_True;
+ return bFound;
+}
+
+// -----------------------------------------------------------------------
+
+sal_Bool SvxNumberFormatShell::IsAdded_Impl( sal_uInt32 nKey )
+{
+ sal_Bool bFound = sal_False;
+ for ( sal_uInt16 i = 0; !bFound && i < aAddList.Count(); ++i )
+ if ( aAddList[i] == nKey )
+ bFound = sal_True;
+ return bFound;
+}
+
+// -----------------------------------------------------------------------
+// Konvertierungs-Routinen:
+// ------------------------
+
+void SvxNumberFormatShell::PosToCategory_Impl( sal_uInt16 nPos, short& rCategory )
+{
+ // Kategorie ::com::sun::star::form-Positionen abbilden (->Resource)
+ switch ( nPos )
+ {
+ case CAT_USERDEFINED: rCategory = NUMBERFORMAT_DEFINED; break;
+ case CAT_NUMBER: rCategory = NUMBERFORMAT_NUMBER; break;
+ case CAT_PERCENT: rCategory = NUMBERFORMAT_PERCENT; break;
+ case CAT_CURRENCY: rCategory = NUMBERFORMAT_CURRENCY; break;
+ case CAT_DATE: rCategory = NUMBERFORMAT_DATE; break;
+ case CAT_TIME: rCategory = NUMBERFORMAT_TIME; break;
+ case CAT_SCIENTIFIC: rCategory = NUMBERFORMAT_SCIENTIFIC; break;
+ case CAT_FRACTION: rCategory = NUMBERFORMAT_FRACTION; break;
+ case CAT_BOOLEAN: rCategory = NUMBERFORMAT_LOGICAL; break;
+ case CAT_TEXT: rCategory = NUMBERFORMAT_TEXT; break;
+ case CAT_ALL:
+ default: rCategory = NUMBERFORMAT_ALL; break;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberFormatShell::CategoryToPos_Impl( short nCategory, sal_uInt16& rPos )
+{
+ // Kategorie auf ::com::sun::star::form-Positionen abbilden (->Resource)
+ switch ( nCategory )
+ {
+ case NUMBERFORMAT_DEFINED: rPos = CAT_USERDEFINED; break;
+ case NUMBERFORMAT_NUMBER: rPos = CAT_NUMBER; break;
+ case NUMBERFORMAT_PERCENT: rPos = CAT_PERCENT; break;
+ case NUMBERFORMAT_CURRENCY: rPos = CAT_CURRENCY; break;
+ case NUMBERFORMAT_DATETIME:
+ case NUMBERFORMAT_DATE: rPos = CAT_DATE; break;
+ case NUMBERFORMAT_TIME: rPos = CAT_TIME; break;
+ case NUMBERFORMAT_SCIENTIFIC: rPos = CAT_SCIENTIFIC; break;
+ case NUMBERFORMAT_FRACTION: rPos = CAT_FRACTION; break;
+ case NUMBERFORMAT_LOGICAL: rPos = CAT_BOOLEAN; break;
+ case NUMBERFORMAT_TEXT: rPos = CAT_TEXT; break;
+ case NUMBERFORMAT_ALL:
+ default: rPos = CAT_ALL;
+ }
+}
+
+
+/*************************************************************************
+#* Member: MakePrevStringFromVal Datum:19.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvxNumberFormatShell
+#*
+#* Funktion: Formatiert die Zahl nValue abhaengig von rFormatStr
+#* und speichert das Ergebnis in rPreviewStr.
+#*
+#* Input: FormatString, Farbe, zu formatierende Zahl
+#*
+#* Output: Ausgabestring rPreviewStr
+#*
+#************************************************************************/
+
+void SvxNumberFormatShell::MakePrevStringFromVal(
+ const String& rFormatStr,
+ String& rPreviewStr,
+ Color*& rpFontColor,
+ double nValue)
+{
+ rpFontColor = NULL;
+ pFormatter->GetPreviewString( rFormatStr, nValue, rPreviewStr, &rpFontColor, eCurLanguage );
+}
+
+/*************************************************************************
+#* Member: GetComment4Entry Datum:30.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvxNumberFormatShell
+#*
+#* Funktion: Liefert den Kommentar fuer einen gegebenen
+#* Eintrag zurueck.
+#*
+#* Input: Nummer des Eintrags
+#*
+#* Output: Kommentar-String
+#*
+#************************************************************************/
+
+void SvxNumberFormatShell::SetComment4Entry(short nEntry,String aEntStr)
+{
+ SvNumberformat *pNumEntry;
+ if(nEntry<0) return;
+ sal_uInt32 nMyNfEntry=aCurEntryList[nEntry];
+ pNumEntry = (SvNumberformat*)pFormatter->GetEntry(nMyNfEntry);
+ if(pNumEntry!=NULL) pNumEntry->SetComment(aEntStr);
+}
+
+/*************************************************************************
+#* Member: GetComment4Entry Datum:30.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvxNumberFormatShell
+#*
+#* Funktion: Liefert den Kommentar fuer einen gegebenen
+#* Eintrag zurueck.
+#*
+#* Input: Nummer des Eintrags
+#*
+#* Output: Kommentar-String
+#*
+#************************************************************************/
+
+String SvxNumberFormatShell::GetComment4Entry(short nEntry)
+{
+ const SvNumberformat *pNumEntry;
+
+ if(nEntry < 0)
+ return String();
+
+ if(nEntry<aCurEntryList.Count())
+ {
+ sal_uInt32 nMyNfEntry=aCurEntryList[nEntry];
+ pNumEntry = pFormatter->GetEntry(nMyNfEntry);
+ if(pNumEntry!=NULL)
+ return pNumEntry->GetComment();
+ }
+
+ return String();
+}
+
+/*************************************************************************
+#* Member: GetCategory4Entry Datum:30.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvxNumberFormatShell
+#*
+#* Funktion: Liefert die Kategorie- Nummer fuer einen gegebenen
+#* Eintrag zurueck.
+#*
+#* Input: Nummer des Eintrags
+#*
+#* Output: Kategorie- Nummer
+#*
+#************************************************************************/
+
+short SvxNumberFormatShell::GetCategory4Entry(short nEntry)
+{
+ const SvNumberformat *pNumEntry;
+ if(nEntry<0) return 0;
+
+ if(nEntry<aCurEntryList.Count())
+ {
+ sal_uInt32 nMyNfEntry=aCurEntryList[nEntry];
+
+ if(nMyNfEntry!=NUMBERFORMAT_ENTRY_NOT_FOUND)
+ {
+ pNumEntry = pFormatter->GetEntry(nMyNfEntry);
+ sal_uInt16 nMyCat,nMyType;
+ if(pNumEntry!=NULL)
+ {
+ nMyCat=pNumEntry->GetType() & ~NUMBERFORMAT_DEFINED;
+ CategoryToPos_Impl(nMyCat,nMyType);
+
+ return (short) nMyType;
+ }
+ return 0;
+ }
+ else if(aCurrencyFormatList.Count()>0)
+ {
+ return CAT_CURRENCY;
+ }
+ }
+ return 0;
+
+}
+
+/*************************************************************************
+#* Member: GetUserDefined4Entry Datum:31.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvxNumberFormatShell
+#*
+#* Funktion: Liefert die Information, ob ein Eintrag
+#* benutzerspezifisch ist zurueck.
+#*
+#* Input: Nummer des Eintrags
+#*
+#* Output: Benutzerspezifisch?
+#*
+#************************************************************************/
+
+sal_Bool SvxNumberFormatShell::GetUserDefined4Entry(short nEntry)
+{
+ const SvNumberformat *pNumEntry;
+ if(nEntry<0) return 0;
+ if(nEntry<aCurEntryList.Count())
+ {
+ sal_uInt32 nMyNfEntry=aCurEntryList[nEntry];
+ pNumEntry = pFormatter->GetEntry(nMyNfEntry);
+
+ if(pNumEntry!=NULL)
+ {
+ if((pNumEntry->GetType() & NUMBERFORMAT_DEFINED)>0)
+ {
+ return sal_True;
+ }
+ }
+ }
+ return sal_False;
+}
+
+
+/*************************************************************************
+#* Member: GetFormat4Entry Datum:30.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvxNumberFormatShell
+#*
+#* Funktion: Liefert den Format- String fuer einen gegebenen
+#* Eintrag zurueck.
+#*
+#* Input: Nummer des Eintrags
+#*
+#* Output: Format- String
+#*
+#************************************************************************/
+
+String SvxNumberFormatShell::GetFormat4Entry(short nEntry)
+{
+ const SvNumberformat *pNumEntry;
+
+ if(nEntry < 0)
+ return String();
+
+ if(aCurrencyFormatList.Count()>0)
+ {
+ if(aCurrencyFormatList.Count()>nEntry)
+ return *aCurrencyFormatList[nEntry];
+ }
+ else
+ {
+ sal_uInt32 nMyNfEntry=aCurEntryList[nEntry];
+ pNumEntry = pFormatter->GetEntry(nMyNfEntry);
+
+ if(pNumEntry!=NULL)
+ return pNumEntry->GetFormatstring();
+ }
+ return String();
+}
+
+/*************************************************************************
+#* Member: GetListPos4Entry Datum:31.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: SvxNumberFormatShell
+#*
+#* Funktion: Liefert die Listen- Nummer fuer einen gegebenen
+#* Formatindex zurueck.
+#*
+#* Input: Nummer des Eintrags
+#*
+#* Output: Kategorie- Nummer
+#*
+#************************************************************************/
+
+short SvxNumberFormatShell::GetListPos4Entry(sal_uInt32 nIdx)
+{
+ short nSelP=SELPOS_NONE;
+ if( aCurEntryList.Count() <= 0x7fff )
+ {
+ for(short i=0;i<aCurEntryList.Count();i++)
+ {
+ if(aCurEntryList[i]==nIdx)
+ {
+ nSelP=i;
+ break;
+ }
+ }
+ }
+ else
+ {
+ DBG_ERROR("svx::SvxNumberFormatShell::GetListPos4Entry(), list got to large!" );
+ }
+ return nSelP;
+}
+
+short SvxNumberFormatShell::GetListPos4Entry( const String& rFmtString )
+{
+ sal_uInt32 nAt=0;
+ short nSelP=SELPOS_NONE;
+ if(FindEntry(rFmtString, &nAt))
+ {
+ if(NUMBERFORMAT_ENTRY_NOT_FOUND!=nAt && NUMBERFORMAT_ENTRY_NEW_CURRENCY!=nAt)
+ {
+ nSelP=GetListPos4Entry(nAt);
+ }
+ else
+ {
+ if(aCurrencyFormatList.Count()>0)
+ {
+ for(sal_uInt16 i=0;i<aCurrencyFormatList.Count();i++)
+ {
+ if (rFmtString==*aCurrencyFormatList[i])
+ {
+ nSelP=i;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return nSelP;
+}
+
+String SvxNumberFormatShell::GetStandardName() const
+{
+ return pFormatter->GetStandardName( eCurLanguage);
+}
+
+void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList, sal_uInt16* pPos )
+{
+
+ const NfCurrencyEntry* pTmpCurrencyEntry=SvNumberFormatter::MatchSystemCurrency();
+
+ sal_Bool bFlag=(pTmpCurrencyEntry==NULL);
+
+ GetCurrencySymbols( rList, bFlag);
+
+ if(pPos!=NULL)
+ {
+ const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
+ sal_uInt16 nTableCount=rCurrencyTable.Count();
+
+ *pPos=0;
+ sal_uInt16 nCount=aCurCurrencyList.Count();
+
+ if(bFlag)
+ {
+ *pPos=1;
+ nCurCurrencyEntryPos=1;
+ }
+ else
+ {
+ for(sal_uInt16 i=1;i<nCount;i++)
+ {
+ const sal_uInt16 j = aCurCurrencyList[i];
+ if (j != (sal_uInt16)-1 && j < nTableCount &&
+ pTmpCurrencyEntry == rCurrencyTable[j])
+ {
+ *pPos=i;
+ nCurCurrencyEntryPos=i;
+ break;
+ }
+ }
+ }
+ }
+
+}
+
+void SvxNumberFormatShell::GetCurrencySymbols( SvStringsDtor& rList, sal_Bool bFlag )
+{
+ aCurCurrencyList.Remove(0,aCurCurrencyList.Count());
+
+ const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
+ sal_uInt16 nCount=rCurrencyTable.Count();
+
+ SvtLanguageTable* pLanguageTable=new SvtLanguageTable;
+
+ sal_uInt16 nStart=1;
+ sal_uInt16 i,j;
+
+ XubString aString( ApplyLreOrRleEmbedding( rCurrencyTable[0]->GetSymbol()));
+ aString += sal_Unicode(' ');
+ aString += ApplyLreOrRleEmbedding( pLanguageTable->GetString( rCurrencyTable[0]->GetLanguage()));
+
+ WSStringPtr pStr = new XubString(aString);
+ rList.Insert( pStr,rList.Count());
+ sal_uInt16 nAuto=(sal_uInt16)-1;
+ aCurCurrencyList.Insert(nAuto,aCurCurrencyList.Count());
+
+ if(bFlag)
+ {
+ pStr = new XubString(aString);
+ rList.Insert( pStr,rList.Count());
+ aCurCurrencyList.Insert((sal_uInt16)0,aCurCurrencyList.Count());
+ ++nStart;
+ }
+
+ CollatorWrapper aCollator( ::comphelper::getProcessServiceFactory());
+ aCollator.loadDefaultCollator( Application::GetSettings().GetLocale(), 0);
+
+ const String aTwoSpace( RTL_CONSTASCII_USTRINGPARAM( " "));
+
+ for(i=1;i<nCount;i++)
+ {
+ XubString aStr( ApplyLreOrRleEmbedding( rCurrencyTable[i]->GetBankSymbol()));
+ aStr += aTwoSpace;
+ aStr += ApplyLreOrRleEmbedding( rCurrencyTable[i]->GetSymbol());
+ aStr += aTwoSpace;
+ aStr += ApplyLreOrRleEmbedding( pLanguageTable->GetString( rCurrencyTable[i]->GetLanguage()));
+
+ pStr = new XubString(aStr);
+ for(j=nStart;j<rList.Count();j++)
+ {
+ const StringPtr pTestStr=rList[j];
+ if (aCollator.compareString( *pStr, *pTestStr) < 0)
+ break; // insert before first greater than
+ }
+ rList.Insert( pStr,j);
+ aCurCurrencyList.Insert(i,j);
+ }
+
+ // Append ISO codes to symbol list.
+ // XXX If this is to be changed, various other places would had to be
+ // adapted that assume this order!
+ sal_uInt16 nCont = rList.Count();
+
+ for(i=1;i<nCount;i++)
+ {
+ bool bInsert = true;
+ pStr = new XubString( ApplyLreOrRleEmbedding( rCurrencyTable[i]->GetBankSymbol()));
+
+ for (j = nCont; j < rList.Count() && bInsert; ++j)
+ {
+ const StringPtr pTestStr=rList[j];
+
+ if(*pTestStr==*pStr)
+ bInsert = false;
+ else
+ if (aCollator.compareString( *pStr, *pTestStr) < 0)
+ break; // insert before first greater than
+ }
+ if(bInsert)
+ {
+ rList.Insert( pStr,j);
+ aCurCurrencyList.Insert(i,j);
+ }
+ }
+
+ delete pLanguageTable;
+}
+
+void SvxNumberFormatShell::GetCurrencyFormats(SvStrings& aListDtor)
+{
+ if(pCurCurrencyEntry!=NULL)
+ {
+ NfWSStringsDtor aWSStringsDtor;
+ /*sal_uInt16 nDefault = */pFormatter->GetCurrencyFormatStrings( aWSStringsDtor,
+ *pCurCurrencyEntry, bBankingSymbol );
+
+ for(sal_uInt16 i=0;i<aWSStringsDtor.Count();i++)
+ {
+ aListDtor.Insert(new String(*aWSStringsDtor[i]),aListDtor.Count());
+ }
+ }
+}
+
+sal_Bool SvxNumberFormatShell::IsBankingSymbol(sal_uInt16 nPos)
+{
+ const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
+ sal_uInt16 nCount=rCurrencyTable.Count();
+
+ return (nPos>nCount);
+}
+
+void SvxNumberFormatShell::SetCurrencySymbol(sal_uInt16 nPos)
+{
+ const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
+ sal_uInt16 nCount=rCurrencyTable.Count();
+
+ bBankingSymbol=(nPos>=nCount);
+
+ if(nPos<aCurCurrencyList.Count())
+ {
+ sal_uInt16 nCurrencyPos=aCurCurrencyList[nPos];
+ if(nCurrencyPos!=(sal_uInt16)-1)
+ {
+ pCurCurrencyEntry=rCurrencyTable[nCurrencyPos];
+ nCurCurrencyEntryPos=nPos;
+ }
+ else
+ {
+ pCurCurrencyEntry=NULL;
+ nCurCurrencyEntryPos=0;
+ nCurFormatKey=pFormatter->GetFormatIndex(
+ NF_CURRENCY_1000DEC2_RED, eCurLanguage);
+ }
+ }
+}
+
+sal_uInt32 SvxNumberFormatShell::GetCurrencySymbol()
+{
+ return nCurCurrencyEntryPos;
+}
+
+NfCurrencyEntry* SvxNumberFormatShell::GetCurCurrencyEntry()
+{
+ return pCurCurrencyEntry;
+}
+
+void SvxNumberFormatShell::SetCurCurrencyEntry(NfCurrencyEntry* pCEntry)
+{
+ pCurCurrencyEntry=pCEntry;
+}
+
+sal_Bool SvxNumberFormatShell::IsTmpCurrencyFormat( const String& rFmtString )
+{
+ sal_uInt32 nFound;
+ /*sal_Bool bRes=*/FindEntry(rFmtString, &nFound);
+
+ if(nFound==NUMBERFORMAT_ENTRY_NEW_CURRENCY)
+ {
+ return sal_True;
+ }
+ return sal_False;
+}
+
+sal_uInt16 SvxNumberFormatShell::FindCurrencyFormat( const String& rFmtString )
+{
+ const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
+ sal_uInt16 nCount=rCurrencyTable.Count();
+
+ sal_Bool bTestBanking=sal_False;
+
+ sal_uInt16 nPos=FindCurrencyTableEntry(rFmtString, bTestBanking);
+
+ sal_uInt16 nStart=0;
+
+ if(nPos!=(sal_uInt16)-1)
+ {
+ if(bTestBanking && aCurCurrencyList.Count()>nPos)
+ {
+ nStart=nCount;
+ }
+ for(sal_uInt16 j=nStart;j<aCurCurrencyList.Count();j++)
+ {
+ if(aCurCurrencyList[j]==nPos) return j;
+ }
+ }
+ return (sal_uInt16) -1;
+}
+
+sal_uInt16 SvxNumberFormatShell::FindCurrencyTableEntry( const String& rFmtString, sal_Bool &bTestBanking )
+{
+ sal_uInt16 nPos=(sal_uInt16) -1;
+
+ const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
+ sal_uInt16 nCount=rCurrencyTable.Count();
+
+ const SvNumberformat* pFormat;
+ String aSymbol, aExtension;
+ sal_uInt32 nFound = pFormatter->TestNewString( rFmtString, eCurLanguage );
+ if ( nFound != NUMBERFORMAT_ENTRY_NOT_FOUND &&
+ ((pFormat = pFormatter->GetEntry( nFound )) != 0) &&
+ pFormat->GetNewCurrencySymbol( aSymbol, aExtension ) )
+ { // eventually match with format locale
+ const NfCurrencyEntry* pTmpCurrencyEntry =
+ SvNumberFormatter::GetCurrencyEntry( bTestBanking, aSymbol, aExtension,
+ pFormat->GetLanguage() );
+ if ( pTmpCurrencyEntry )
+ {
+ for(sal_uInt16 i=0;i<nCount;i++)
+ {
+ if(pTmpCurrencyEntry==rCurrencyTable[i])
+ {
+ nPos=i;
+ break;
+ }
+ }
+ }
+ }
+ else
+ { // search symbol string only
+ for(sal_uInt16 i=0;i<nCount;i++)
+ {
+ const NfCurrencyEntry* pTmpCurrencyEntry=rCurrencyTable[i];
+ XubString _aSymbol, aBankSymbol;
+ pTmpCurrencyEntry->BuildSymbolString(_aSymbol,sal_False);
+ pTmpCurrencyEntry->BuildSymbolString(aBankSymbol,sal_True);
+
+ if(rFmtString.Search(_aSymbol)!=STRING_NOTFOUND)
+ {
+ bTestBanking=sal_False;
+ nPos=i;
+ break;
+ }
+ else if(rFmtString.Search(aBankSymbol)!=STRING_NOTFOUND)
+ {
+ bTestBanking=sal_True;
+ nPos=i;
+ break;
+ }
+ }
+ }
+
+ return nPos;
+}
+
+sal_uInt16 SvxNumberFormatShell::FindCurrencyFormat(const NfCurrencyEntry* pTmpCurrencyEntry,sal_Bool bTmpBanking)
+{
+ const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
+ sal_uInt16 nCount=rCurrencyTable.Count();
+
+// sal_Bool bTestBanking=sal_False;
+ sal_uInt16 nPos=0;
+ for(sal_uInt16 i=0;i<nCount;i++)
+ {
+ if(pTmpCurrencyEntry==rCurrencyTable[i])
+ {
+ nPos=i;
+ break;
+ }
+ }
+
+ sal_uInt16 nStart=0;
+ if(bTmpBanking && aCurCurrencyList.Count()>nPos)
+ {
+ nStart=nCount;
+ }
+ for(sal_uInt16 j=nStart;j<aCurCurrencyList.Count();j++)
+ {
+ if(aCurCurrencyList[j]==nPos) return j;
+ }
+ return (sal_uInt16) -1;
+}
+
+sal_Bool SvxNumberFormatShell::IsInTable(sal_uInt16 nPos,sal_Bool bTmpBanking,const String &rFmtString)
+{
+ sal_Bool bFlag=sal_False;
+
+ if(nPos!=(sal_uInt16)-1)
+ {
+ const NfCurrencyTable& rCurrencyTable=SvNumberFormatter::GetTheCurrencyTable();
+ sal_uInt16 nCount=rCurrencyTable.Count();
+
+ if(nPos<nCount)
+ {
+ NfWSStringsDtor aWSStringsDtor;
+ sal_uInt16 nDefault;
+
+ const NfCurrencyEntry* pTmpCurrencyEntry=rCurrencyTable[nPos];
+
+ if ( pTmpCurrencyEntry!=NULL)
+ {
+ nDefault = pFormatter->GetCurrencyFormatStrings( aWSStringsDtor,
+ *pTmpCurrencyEntry, bTmpBanking );
+
+ for(sal_uInt16 i=0;i<aWSStringsDtor.Count();i++)
+ {
+ if(*aWSStringsDtor[i]==rFmtString)
+ {
+ bFlag=sal_True;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return bFlag;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/numinf.cxx b/svx/source/items/numinf.cxx
new file mode 100644
index 000000000000..ca769b28024e
--- /dev/null
+++ b/svx/source/items/numinf.cxx
@@ -0,0 +1,252 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define _SVX_NUMINF_CXX
+
+#include <svx/numinf.hxx>
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(SvxNumberInfoItem, SfxPoolItem);
+
+// class SvxNumberInfoItem -----------------------------------------------
+
+#define INIT(pNum,eVal,nDouble,rStr) \
+ SfxPoolItem ( nId ), \
+ \
+ pFormatter ( pNum ), \
+ eValueType ( eVal ), \
+ aStringVal ( rStr ), \
+ nDoubleVal ( nDouble ), \
+ pDelFormatArr ( NULL ), \
+ nDelCount ( 0 )
+
+SvxNumberInfoItem::SvxNumberInfoItem( const sal_uInt16 nId ) :
+
+ INIT( NULL, SVX_VALUE_TYPE_UNDEFINED, 0, String() )
+
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
+ const sal_uInt16 nId ) :
+
+ INIT( pNumFormatter, SVX_VALUE_TYPE_UNDEFINED, 0, String() )
+
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
+ const String& rVal, const sal_uInt16 nId ) :
+
+ INIT( pNumFormatter, SVX_VALUE_TYPE_STRING, 0, rVal )
+
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
+ const double& rVal, const sal_uInt16 nId ) :
+
+ INIT( pNumFormatter, SVX_VALUE_TYPE_NUMBER, rVal, String() )
+
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxNumberInfoItem::SvxNumberInfoItem( SvNumberFormatter* pNumFormatter,
+ const double& rVal, const String& rValueStr,
+ const sal_uInt16 nId ) :
+
+ INIT( pNumFormatter, SVX_VALUE_TYPE_NUMBER, rVal, rValueStr )
+
+{
+}
+
+#undef INIT
+
+// -----------------------------------------------------------------------
+
+SvxNumberInfoItem::SvxNumberInfoItem( const SvxNumberInfoItem& rItem ) :
+
+ SfxPoolItem( rItem.Which() ),
+
+ pFormatter ( rItem.pFormatter ),
+ eValueType ( rItem.eValueType ),
+ aStringVal ( rItem.aStringVal ),
+ nDoubleVal ( rItem.nDoubleVal ),
+ pDelFormatArr( NULL ),
+ nDelCount ( rItem.nDelCount )
+
+{
+ if ( rItem.nDelCount > 0 )
+ {
+ pDelFormatArr = new sal_uInt32[ rItem.nDelCount ];
+
+ for ( sal_uInt16 i = 0; i < rItem.nDelCount; ++i )
+ pDelFormatArr[i] = rItem.pDelFormatArr[i];
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SvxNumberInfoItem::~SvxNumberInfoItem()
+{
+ if ( pDelFormatArr )
+ delete []pDelFormatArr;
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxNumberInfoItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ String& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxNumberInfoItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal which or type" );
+
+ SvxNumberInfoItem& rOther = (SvxNumberInfoItem&)rItem;
+
+ sal_Bool bEqual = sal_False;
+
+ if ( nDelCount == rOther.nDelCount )
+ {
+ if ( nDelCount > 0 )
+ {
+ if ( pDelFormatArr != NULL && rOther.pDelFormatArr != NULL )
+ {
+ bEqual = sal_True;
+
+ for ( sal_uInt16 i = 0; i < nDelCount && bEqual; ++i )
+ bEqual = ( pDelFormatArr[i] == rOther.pDelFormatArr[i] );
+ }
+ }
+ else if ( nDelCount == 0 )
+ bEqual = ( pDelFormatArr == NULL && rOther.pDelFormatArr == NULL );
+
+ bEqual = bEqual &&
+ pFormatter == rOther.pFormatter &&
+ eValueType == rOther.eValueType &&
+ nDoubleVal == rOther.nDoubleVal &&
+ aStringVal == rOther.aStringVal;
+ }
+ return bEqual;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxNumberInfoItem::Clone( SfxItemPool * ) const
+{
+ return new SvxNumberInfoItem( *this );
+}
+
+// Laden/Speichern wird nicht gebraucht!
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxNumberInfoItem::Create( SvStream& /*rStream*/, sal_uInt16 ) const
+{
+ return new SvxNumberInfoItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SvxNumberInfoItem::Store( SvStream &rStream, sal_uInt16 /*nItemVersion*/ ) const
+{
+ return rStream;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberInfoItem::SetNumberFormatter( SvNumberFormatter* pNumFormatter )
+{
+ pFormatter = pNumFormatter;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberInfoItem::SetStringValue( const String& rNewVal )
+{
+ aStringVal = rNewVal;
+ eValueType = SVX_VALUE_TYPE_STRING;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberInfoItem::SetDoubleValue( const double& rNewVal )
+{
+ nDoubleVal = rNewVal;
+ eValueType = SVX_VALUE_TYPE_NUMBER;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxNumberInfoItem::SetDelFormatArray( const sal_uInt32* pData,
+ const sal_uInt32 nCount )
+{
+ if ( pDelFormatArr )
+ {
+ delete []pDelFormatArr;
+ pDelFormatArr = NULL;
+ }
+
+ nDelCount = nCount;
+
+ if ( nCount > 0 )
+ {
+ pDelFormatArr = new sal_uInt32[ nCount ];
+
+ if ( pData != NULL )
+ {
+ for ( sal_uInt16 i = 0; i < nCount; ++i )
+ pDelFormatArr[i] = pData[i];
+ }
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/ofaitem.cxx b/svx/source/items/ofaitem.cxx
new file mode 100644
index 000000000000..1c021c0b8bd9
--- /dev/null
+++ b/svx/source/items/ofaitem.cxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "ofaitem.hxx"
+
+OfaPtrItem::OfaPtrItem( USHORT _nWhich, void *_pPtr )
+ : SfxPoolItem( _nWhich ), pPtr( _pPtr )
+{
+
+}
+OfaPtrItem::OfaPtrItem( const OfaPtrItem& rItem)
+ : SfxPoolItem( rItem.Which() ), pPtr( rItem.pPtr )
+{
+}
+
+int OfaPtrItem::operator==( const SfxPoolItem& rItem) const
+{
+ return ((OfaPtrItem&)rItem).pPtr == pPtr;
+}
+
+SfxPoolItem* OfaPtrItem::Clone( SfxItemPool * ) const
+{
+ return new OfaPtrItem( *this );
+}
+
+//---------------------------------------------------------------------------
+/*
+TYPEINIT1_FACTORY(DashListPtrItem, SvxDashListPtrItem, new DashListPtrItem(0));
+
+DashListPtrItem::DashListPtrItem( USHORT nWhich, SvxDashListItem* pPtr )
+ : OfaPtrItem( nWhich ), pPtr( pPtr )
+{
+}
+
+DashListPtrItem::DashListPtrItem( const DashListPtrItem& )
+ : OfaPtrItem( rItem.Which() ), pPtr( rItem.pPtr )
+{
+}
+
+int DashListPtrItem::operator==( const SfxPoolItem& rItem ) const
+{
+ return ((DashListPtrItem&)rItem).GetValue() == GetValue();
+}
+
+SfxPoolItem* DashListPtrItem::Clone( SfxItemPool *pPool ) const
+{
+ return new DashListPtrItem( *this );
+}
+
+sal_Bool DashListPtrItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 ) const
+{
+}
+
+sal_Bool DashListPtrItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId = 0 )
+{
+ sal_Int64 nHyper;
+ if ( rVal >>= nHyper )
+ {
+ SetValue( (SvxDash
+ }
+
+ return sal_False;
+}
+*/
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/pageitem.cxx b/svx/source/items/pageitem.cxx
new file mode 100644
index 000000000000..d57303465fbf
--- /dev/null
+++ b/svx/source/items/pageitem.cxx
@@ -0,0 +1,340 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/stream.hxx>
+
+
+#include <svx/pageitem.hxx>
+#include <editeng/itemtype.hxx>
+#include <svx/unomid.hxx>
+#include <com/sun/star/style/PageStyleLayout.hpp>
+#include <com/sun/star/style/BreakType.hpp>
+#include <svl/itemset.hxx>
+#include <svx/svxitems.hrc>
+#include <svx/dialmgr.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+TYPEINIT1_FACTORY( SvxPageItem, SfxPoolItem , new SvxPageItem(0));
+
+/*--------------------------------------------------------------------
+ Beschreibung: Konstruktor
+ --------------------------------------------------------------------*/
+
+SvxPageItem::SvxPageItem( const USHORT nId ) : SfxPoolItem( nId ),
+
+ eNumType ( SVX_ARABIC ),
+ bLandscape ( sal_False ),
+ eUse ( SVX_PAGE_ALL )
+{
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Copy-Konstruktor
+ --------------------------------------------------------------------*/
+
+SvxPageItem::SvxPageItem( const SvxPageItem& rItem )
+ : SfxPoolItem( rItem )
+{
+ eNumType = rItem.eNumType;
+ bLandscape = rItem.bLandscape;
+ eUse = rItem.eUse;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Clonen
+ --------------------------------------------------------------------*/
+
+SfxPoolItem* SvxPageItem::Clone( SfxItemPool * ) const
+{
+ return new SvxPageItem( *this );
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: Abfrage auf Gleichheit
+ --------------------------------------------------------------------*/
+
+int SvxPageItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
+ const SvxPageItem& rItem = (SvxPageItem&)rAttr;
+ return ( eNumType == rItem.eNumType &&
+ bLandscape == rItem.bLandscape &&
+ eUse == rItem.eUse );
+}
+
+inline XubString GetUsageText( const USHORT eU )
+{
+ if ( eU & SVX_PAGE_LEFT )
+ return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_LEFT);
+ if ( eU & SVX_PAGE_RIGHT )
+ return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_RIGHT);
+ if ( eU & SVX_PAGE_ALL )
+ return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_ALL);
+ if ( eU & SVX_PAGE_MIRROR )
+ return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_MIRROR);
+ return String();
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxPageItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ {
+ if ( aDescName.Len() )
+ {
+ rText = aDescName;
+ rText += cpDelim;
+ }
+ DBG_ASSERT( eNumType <= SVX_NUMBER_NONE, "enum overflow" );
+ rText += SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN + eNumType);
+ rText += cpDelim;
+ if ( bLandscape )
+ rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE);
+ else
+ rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE);
+ rText += GetUsageText( eUse );
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+ }
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ rText += SVX_RESSTR(RID_SVXITEMS_PAGE_COMPLETE);
+ if ( aDescName.Len() )
+ {
+ rText += aDescName;
+ rText += cpDelim;
+ }
+ DBG_ASSERT( eNumType <= SVX_NUMBER_NONE, "enum overflow" );
+ rText += SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN + eNumType);
+ rText += cpDelim;
+ if ( bLandscape )
+ rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE);
+ else
+ rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE);
+ rText += GetUsageText( eUse );
+ return SFX_ITEM_PRESENTATION_COMPLETE;
+ }
+ default: ;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+//------------------------------------------------------------------------
+bool SvxPageItem::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ switch( nMemberId )
+ {
+ case MID_PAGE_NUMTYPE:
+ {
+ //! die Konstanten sind nicht mehr in den IDLs ?!?
+ rVal <<= (sal_Int16)( eNumType );
+ }
+ break;
+ case MID_PAGE_ORIENTATION:
+ //Landscape= sal_True
+ rVal = Bool2Any(bLandscape);
+ break;
+ case MID_PAGE_LAYOUT :
+ {
+ style::PageStyleLayout eRet;
+ switch(eUse & 0x0f)
+ {
+ case SVX_PAGE_LEFT : eRet = style::PageStyleLayout_LEFT; break;
+ case SVX_PAGE_RIGHT : eRet = style::PageStyleLayout_RIGHT; break;
+ case SVX_PAGE_ALL : eRet = style::PageStyleLayout_ALL; break;
+ case SVX_PAGE_MIRROR: eRet = style::PageStyleLayout_MIRRORED; break;
+ default:
+ DBG_ERROR("was fuer ein Layout ist das?");
+ return sal_False;
+ }
+ rVal <<= eRet;
+ }
+ break;
+ }
+
+ return true;
+}
+//------------------------------------------------------------------------
+bool SvxPageItem::PutValue( const uno::Any& rVal, BYTE nMemberId )
+{
+ switch( nMemberId )
+ {
+ case MID_PAGE_NUMTYPE:
+ {
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return false;
+
+ eNumType = (SvxNumType)nValue;
+ }
+ break;
+ case MID_PAGE_ORIENTATION:
+ bLandscape = Any2Bool(rVal);
+ break;
+ case MID_PAGE_LAYOUT :
+ {
+ style::PageStyleLayout eLayout;
+ if(!(rVal >>= eLayout))
+ {
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return sal_False;
+ eLayout = (style::PageStyleLayout)nValue;
+ }
+ eUse &= 0xfff0;
+ switch( eLayout )
+ {
+ case style::PageStyleLayout_LEFT : eUse |= SVX_PAGE_LEFT ; break;
+ case style::PageStyleLayout_RIGHT : eUse |= SVX_PAGE_RIGHT; break;
+ case style::PageStyleLayout_ALL : eUse |= SVX_PAGE_ALL ; break;
+ case style::PageStyleLayout_MIRRORED: eUse |= SVX_PAGE_MIRROR;break;
+ default: ;//prevent warning
+ }
+ }
+ break;
+ }
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* SvxPageItem::Create( SvStream& rStream, USHORT ) const
+{
+ XubString sStr;
+ BYTE eType;
+ sal_Bool bLand;
+ USHORT nUse;
+
+ // UNICODE: rStream >> sStr;
+ rStream.ReadByteString( sStr );
+
+ rStream >> eType;
+ rStream >> bLand;
+ rStream >> nUse;
+
+ SvxPageItem* pPage = new SvxPageItem( Which() );
+ pPage->SetDescName( sStr );
+ pPage->SetNumType( (SvxNumType)eType );
+ pPage->SetLandscape( bLand );
+ pPage->SetPageUsage( nUse );
+ return pPage;
+}
+
+//------------------------------------------------------------------------
+
+SvStream& SvxPageItem::Store( SvStream &rStrm, USHORT /*nItemVersion*/ ) const
+{
+ // UNICODE: rStrm << aDescName;
+ rStrm.WriteByteString(aDescName);
+
+ rStrm << (BYTE)eNumType << bLandscape << eUse;
+ return rStrm;
+}
+
+/*--------------------------------------------------------------------
+ Beschreibung: HeaderFooterSet
+ --------------------------------------------------------------------*/
+
+SvxSetItem::SvxSetItem( const USHORT nId, const SfxItemSet& rSet ) :
+
+ SfxSetItem( nId, rSet )
+{
+}
+
+SvxSetItem::SvxSetItem( const SvxSetItem& rItem ) :
+
+ SfxSetItem( rItem )
+{
+}
+
+SvxSetItem::SvxSetItem( const USHORT nId, SfxItemSet* _pSet ) :
+
+ SfxSetItem( nId, _pSet )
+{
+}
+
+SfxPoolItem* SvxSetItem::Clone( SfxItemPool * ) const
+{
+ return new SvxSetItem(*this);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxSetItem::GetPresentation
+(
+ SfxItemPresentation /*ePres*/,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+SfxPoolItem* SvxSetItem::Create(SvStream &rStrm, USHORT /*nVersion*/) const
+{
+ SfxItemSet* _pSet = new SfxItemSet( *GetItemSet().GetPool(),
+ GetItemSet().GetRanges() );
+
+ _pSet->Load( rStrm );
+
+ return new SvxSetItem( Which(), *_pSet );
+}
+
+SvStream& SvxSetItem::Store(SvStream &rStrm, USHORT nItemVersion) const
+{
+ GetItemSet().Store( rStrm, nItemVersion );
+
+ return rStrm;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/postattr.cxx b/svx/source/items/postattr.cxx
new file mode 100644
index 000000000000..17d18a36ce24
--- /dev/null
+++ b/svx/source/items/postattr.cxx
@@ -0,0 +1,194 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#define _SVX_POSTATTR_CXX
+#include "postattr.hxx"
+#include <editeng/itemtype.hxx>
+#include <svx/svxitems.hrc>
+#include <svx/dialmgr.hxx>
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_FACTORY(SvxPostItAuthorItem, SfxStringItem, new SvxPostItAuthorItem(0));
+TYPEINIT1_FACTORY(SvxPostItDateItem, SfxStringItem, new SvxPostItDateItem(0));
+TYPEINIT1_FACTORY(SvxPostItTextItem, SfxStringItem, new SvxPostItTextItem(0));
+
+// class SvxPostItAuthorItem ---------------------------------------------
+
+SvxPostItAuthorItem::SvxPostItAuthorItem( sal_uInt16 _nWhich )
+{
+ SetWhich( _nWhich );
+}
+
+// -----------------------------------------------------------------------
+
+SvxPostItAuthorItem::SvxPostItAuthorItem( const XubString& rAuthor,
+ sal_uInt16 _nWhich ) :
+ SfxStringItem( _nWhich, rAuthor )
+{
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxPostItAuthorItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ rText = GetValue();
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = SVX_RESSTR(RID_SVXITEMS_AUTHOR_COMPLETE);
+ rText += GetValue();
+ return SFX_ITEM_PRESENTATION_COMPLETE;
+ default: ;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT SvxPostItAuthorItem::Clone( SfxItemPool * ) const
+{
+ return new SvxPostItAuthorItem( *this );
+}
+
+// class SvxPostItDateItem -----------------------------------------------
+
+SvxPostItDateItem::SvxPostItDateItem( sal_uInt16 _nWhich )
+{
+ SetWhich( _nWhich );
+}
+
+// -----------------------------------------------------------------------
+
+SvxPostItDateItem::SvxPostItDateItem( const XubString& rDate, sal_uInt16 _nWhich ) :
+
+ SfxStringItem( _nWhich, rDate )
+{
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxPostItDateItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ rText = GetValue();
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = SVX_RESSTR(RID_SVXITEMS_DATE_COMPLETE);
+ rText += GetValue();
+ return SFX_ITEM_PRESENTATION_COMPLETE;
+ default: ;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT SvxPostItDateItem::Clone( SfxItemPool * ) const
+{
+ return new SvxPostItDateItem( *this );
+}
+
+// class SvxPostItTextItem -----------------------------------------------
+
+SvxPostItTextItem::SvxPostItTextItem( sal_uInt16 _nWhich )
+{
+ SetWhich( _nWhich );
+}
+
+// -----------------------------------------------------------------------
+
+SvxPostItTextItem::SvxPostItTextItem( const XubString& rText, sal_uInt16 _nWhich ) :
+
+ SfxStringItem( _nWhich, rText )
+{
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation SvxPostItTextItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return SFX_ITEM_PRESENTATION_NONE;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ rText = GetValue();
+ return SFX_ITEM_PRESENTATION_NAMELESS;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = SVX_RESSTR(RID_SVXITEMS_TEXT_COMPLETE);
+ rText += GetValue();
+ return SFX_ITEM_PRESENTATION_COMPLETE;
+ default: ;//prevent warning
+ }
+ return SFX_ITEM_PRESENTATION_NONE;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT SvxPostItTextItem::Clone( SfxItemPool * ) const
+{
+ return new SvxPostItTextItem( *this );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/rotmodit.cxx b/svx/source/items/rotmodit.cxx
new file mode 100644
index 000000000000..b94b7b702e49
--- /dev/null
+++ b/svx/source/items/rotmodit.cxx
@@ -0,0 +1,174 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/stream.hxx>
+#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/table/CellVertJustify2.hpp>
+#include <com/sun/star/table/ShadowLocation.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/table/ShadowFormat.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/table/CellContentType.hpp>
+#include <com/sun/star/table/TableOrientation.hpp>
+#include <com/sun/star/util/SortField.hpp>
+#include <com/sun/star/util/SortFieldType.hpp>
+#include <com/sun/star/table/CellOrientation.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+
+#include "rotmodit.hxx"
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+TYPEINIT1_FACTORY(SvxRotateModeItem, SfxEnumItem, new SvxRotateModeItem(SVX_ROTATE_MODE_STANDARD, 0));
+
+
+//-----------------------------------------------------------------------
+// SvxRotateModeItem - Ausrichtung bei gedrehtem Text
+//-----------------------------------------------------------------------
+
+SvxRotateModeItem::SvxRotateModeItem( SvxRotateMode eMode, USHORT _nWhich )
+ : SfxEnumItem( _nWhich, (USHORT)eMode )
+{
+}
+
+SvxRotateModeItem::SvxRotateModeItem( const SvxRotateModeItem& rItem )
+ : SfxEnumItem( rItem )
+{
+}
+
+__EXPORT SvxRotateModeItem::~SvxRotateModeItem()
+{
+}
+
+SfxPoolItem* __EXPORT SvxRotateModeItem::Create( SvStream& rStream, USHORT ) const
+{
+ USHORT nVal;
+ rStream >> nVal;
+ return new SvxRotateModeItem( (SvxRotateMode) nVal,Which() );
+}
+
+SfxItemPresentation __EXPORT SvxRotateModeItem::GetPresentation(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/, SfxMapUnit /*ePresUnit*/,
+ String& rText, const IntlWrapper * ) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText.AppendAscii("...");
+ rText.AppendAscii(": ");
+// break; // DURCHFALLEN!!!
+
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ rText += UniString::CreateFromInt32( GetValue() );
+ break;
+ default: ;//prevent warning
+ }
+
+ return ePres;
+}
+
+String __EXPORT SvxRotateModeItem::GetValueText( USHORT nVal ) const
+{
+ String aText;
+
+ switch ( nVal )
+ {
+ case SVX_ROTATE_MODE_STANDARD:
+ case SVX_ROTATE_MODE_TOP:
+ case SVX_ROTATE_MODE_CENTER:
+ case SVX_ROTATE_MODE_BOTTOM:
+ aText.AppendAscii("...");
+ break;
+ default:
+ DBG_ERROR("SvxRotateModeItem: falscher enum");
+ break;
+ }
+ return aText;
+}
+
+USHORT __EXPORT SvxRotateModeItem::GetValueCount() const
+{
+ return 4; // STANDARD, TOP, CENTER, BOTTOM
+}
+
+SfxPoolItem* __EXPORT SvxRotateModeItem::Clone( SfxItemPool* ) const
+{
+ return new SvxRotateModeItem( *this );
+}
+
+USHORT __EXPORT SvxRotateModeItem::GetVersion( USHORT /*nFileVersion*/ ) const
+{
+ return 0;
+}
+
+bool SvxRotateModeItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/ ) const
+{
+ sal_Int32 nUno = table::CellVertJustify2::STANDARD;
+ switch ( (SvxRotateMode)GetValue() )
+ {
+ case SVX_ROTATE_MODE_STANDARD: nUno = table::CellVertJustify2::STANDARD; break;
+ case SVX_ROTATE_MODE_TOP: nUno = table::CellVertJustify2::TOP; break;
+ case SVX_ROTATE_MODE_CENTER: nUno = table::CellVertJustify2::CENTER; break;
+ case SVX_ROTATE_MODE_BOTTOM: nUno = table::CellVertJustify2::BOTTOM; break;
+ }
+ rVal <<= nUno;
+ return true;
+}
+
+bool SvxRotateModeItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/ )
+{
+ sal_Int32 nUno;
+ if(!(rVal >>= nUno))
+ {
+ nUno = table::CellVertJustify2::STANDARD;
+ }
+
+ SvxRotateMode eSvx = SVX_ROTATE_MODE_STANDARD;
+ switch (nUno)
+ {
+ case table::CellVertJustify2::STANDARD: eSvx = SVX_ROTATE_MODE_STANDARD; break;
+ case table::CellVertJustify2::TOP: eSvx = SVX_ROTATE_MODE_TOP; break;
+ case table::CellVertJustify2::CENTER: eSvx = SVX_ROTATE_MODE_CENTER; break;
+ case table::CellVertJustify2::BOTTOM: eSvx = SVX_ROTATE_MODE_BOTTOM; break;
+ default: ;//prevent warning
+ }
+ SetValue( (USHORT)eSvx );
+ return true;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/svxempty.cxx b/svx/source/items/svxempty.cxx
new file mode 100644
index 000000000000..8a574d2e8e6b
--- /dev/null
+++ b/svx/source/items/svxempty.cxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svxempty.hxx"
+
+// Statischer Empty-String -----------------------------------------------
+
+static XubString aImplSVXEmptyStr;
+XubString& rImplEmptyStr = aImplSVXEmptyStr;
+static String aImplSVXEmptySStr;
+String& rImplEmptySStr = aImplSVXEmptySStr;
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/svxerr.cxx b/svx/source/items/svxerr.cxx
new file mode 100644
index 000000000000..e02c30a76775
--- /dev/null
+++ b/svx/source/items/svxerr.cxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/shl.hxx>
+
+#include "svxerr.hxx"
+#include <svx/dialmgr.hxx>
+
+#include <svx/dialogs.hrc>
+
+static SvxErrorHandler* pHandler=NULL;
+
+SvxErrorHandler::SvxErrorHandler() :
+
+ SfxErrorHandler(
+ RID_SVXERRCODE, ERRCODE_AREA_SVX, ERRCODE_AREA_SVX_END, &DIALOG_MGR() )
+{
+ pHandler = this;
+}
+
+void SvxErrorHandler::Get()
+{
+ if ( !pHandler )
+ new SvxErrorHandler;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/svxerr.src b/svx/source/items/svxerr.src
new file mode 100644
index 000000000000..a55291de29f6
--- /dev/null
+++ b/svx/source/items/svxerr.src
@@ -0,0 +1,174 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#define __RSC
+#include "svxerr.hxx"
+#include <svx/dialogs.hrc>
+#include <editeng/editerr.hxx>
+
+ // pragma ----------------------------------------------------------------
+
+ // Error-Context ---------------------------------------------------------
+Resource RID_SVXERRCTX
+{
+ String ERRCTX_SVX_LINGU_THESAURUS&ERRCODE_RES_MASK
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? $(ERR) beim Ausführen des Thesaurus. : $(ERR) beim Ausf³hren des Thesaurus. */
+ /* ### ACHTUNG: Neuer Text in Resource? $(ERR) beim Ausführen des Thesaurus. : $(ERR) beim Ausf³hren des Thesaurus. */
+ Text [ en-US ] = "$(ERR) executing the thesaurus." ;
+ };
+ String ERRCTX_SVX_LINGU_SPELLING&ERRCODE_RES_MASK
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? $(ERR) bei der Ausführung der Rechtschreibprüfung. : $(ERR) bei der Ausf³hrung der Rechtschreibpr³fung. */
+ /* ### ACHTUNG: Neuer Text in Resource? $(ERR) bei der Ausführung der Rechtschreibprüfung. : $(ERR) bei der Ausf³hrung der Rechtschreibpr³fung. */
+ Text [ en-US ] = "$(ERR) executing the spellcheck." ;
+ };
+ String ERRCTX_SVX_LINGU_HYPHENATION&ERRCODE_RES_MASK
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? $(ERR) bei der Ausführung der Trennhilfe. : $(ERR) bei der Ausf³hrung der Trennhilfe. */
+ /* ### ACHTUNG: Neuer Text in Resource? $(ERR) bei der Ausführung der Trennhilfe. : $(ERR) bei der Ausf³hrung der Trennhilfe. */
+ Text [ en-US ] = "$(ERR) executing the hyphenation." ;
+ };
+ String ERRCTX_SVX_LINGU_DICTIONARY&ERRCODE_RES_MASK
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? $(ERR) beim Anlegen eines Wörterbuches. : $(ERR) beim Anlegen eines W÷rterbuches. */
+ /* ### ACHTUNG: Neuer Text in Resource? $(ERR) beim Anlegen eines Wörterbuches. : $(ERR) beim Anlegen eines W÷rterbuches. */
+ Text [ en-US ] = "$(ERR) creating a dictionary." ;
+ };
+ String ERRCTX_SVX_BACKGROUND&ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "$(ERR) setting background attribute." ;
+ };
+ String ERRCTX_SVX_IMPORT_GRAPHIC&ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "$(ERR) loading the graphics." ;
+ };
+};
+ // Error-Code ------------------------------------------------------------
+Resource RID_SVXERRCODE
+{
+ String ERRCODE_SVX_LINGU_THESAURUSNOTEXISTS&ERRCODE_RES_MASK
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Ein Thesaurus für die eingestellte Sprache ist nicht verfügbar.\nÜberprüfen Sie bitte Ihre Installation und installieren Sie gegebenenfalls die gewünschte Sprache : Ein Thesaurus f³r die eingestellte Sprache ist nicht verf³gbar.\nšberpr³fen Sie bitte Ihre Installation und installieren Sie gegebenenfalls die gew³nschte Sprache */
+ /* ### ACHTUNG: Neuer Text in Resource? Ein Thesaurus für die eingestellte Sprache ist nicht verfügbar.\nÜberprüfen Sie bitte Ihre Installation und installieren Sie gegebenenfalls die gewünschte Sprache : Ein Thesaurus f³r die eingestellte Sprache ist nicht verf³gbar.\nšberpr³fen Sie bitte Ihre Installation und installieren Sie gegebenenfalls die gew³nschte Sprache */
+ Text [ en-US ] = "No thesaurus available for the current language.\nPlease check your installation and install the desired language." ;
+ };
+ String ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS&ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "$(ARG1) is not supported by the spellcheck function or is not presently active.\nPlease check your installation and, if necessary, install the required language module\n or activate it under 'Tools - Options - Language Settings - Writing Aids'.";
+ };
+ String ERRCODE_SVX_LINGU_LINGUNOTEXISTS&ERRCODE_RES_MASK
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Die Rechtschreibprüfung ist nicht verfügbar. : Die Rechtschreibpr³fung ist nicht verf³gbar. */
+ /* ### ACHTUNG: Neuer Text in Resource? Die Rechtschreibprüfung ist nicht verfügbar. : Die Rechtschreibpr³fung ist nicht verf³gbar. */
+ Text [ en-US ] = "Spellcheck is not available." ;
+ };
+ String ERRCODE_SVX_LINGU_HYPHENNOTEXISTS&ERRCODE_RES_MASK
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Die Trennhilfe ist nicht verfügbar. : Die Trennhilfe ist nicht verf³gbar. */
+ /* ### ACHTUNG: Neuer Text in Resource? Die Trennhilfe ist nicht verfügbar. : Die Trennhilfe ist nicht verf³gbar. */
+ Text [ en-US ] = "Hyphenation not available." ;
+ };
+ String ERRCODE_SVX_LINGU_DICT_NOTREADABLE&ERRCODE_RES_MASK
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Das persönliche Wörterbuch $(ARG1) kann nicht gelesen werden. : Das pers÷nliche W÷rterbuch $(ARG1) kann nicht gelesen werden. */
+ /* ### ACHTUNG: Neuer Text in Resource? Das persönliche Wörterbuch $(ARG1) kann nicht gelesen werden. : Das pers÷nliche W÷rterbuch $(ARG1) kann nicht gelesen werden. */
+ Text [ en-US ] = "The custom dictionary $(ARG1) cannot be read." ;
+ };
+ String ERRCODE_SVX_LINGU_DICT_NOTWRITEABLE&ERRCODE_RES_MASK
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Das persönliche Wörterbuch $(ARG1) kann nicht angelegt werden. : Das pers÷nliche W÷rterbuch $(ARG1) kann nicht angelegt werden. */
+ /* ### ACHTUNG: Neuer Text in Resource? Das persönliche Wörterbuch $(ARG1) kann nicht angelegt werden. : Das pers÷nliche W÷rterbuch $(ARG1) kann nicht angelegt werden. */
+ Text [ en-US ] = "The custom dictionary $(ARG1) cannot be created." ;
+ };
+ String ERRCODE_SVX_GRAPHIC_NOTREADABLE&ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The graphic $(ARG1) could not be found." ;
+ };
+ String ERRCODE_SVX_GRAPHIC_WRONG_FILEFORMAT&ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "An unlinked graphic could not be loaded.";
+ };
+ String ERRCODE_SVX_LINGU_NOLANGUAGE&ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "A language has not been fixed for the selected term.";
+ };
+ String (ERRCODE_SVX_FORMS_NOIOSERVICES | ERRCODE_CLASS_READ) & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The form layer wasn't loaded as the required IO-services (stardiv.uno.io.*) could not be instantiated.";
+ };
+ String (ERRCODE_SVX_FORMS_NOIOSERVICES | ERRCODE_CLASS_WRITE) & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The form layer wasn't written as the required IO services (stardiv.uno.io.*) could not be instantiated.";
+ };
+ String (ERRCODE_SVX_FORMS_READWRITEFAILED | ERRCODE_CLASS_READ) & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "An error occurred while reading the form controls. The form layer has not been loaded.";
+ };
+ String (ERRCODE_SVX_FORMS_READWRITEFAILED | ERRCODE_CLASS_WRITE) & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "An error occurred while writing the form controls. The form layer has not been saved.";
+ };
+ String (ERRCODE_SVX_BULLETITEM_NOBULLET | ERRCODE_CLASS_READ) & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "An error occurred while reading one of the bullets. Not all of the bullets were loaded.";
+ };
+
+ String ERRCODE_SVX_MODIFIED_VBASIC_STORAGE & ERRCODE_RES_MASK
+ {
+// TEXT = "Der Basic-Code wurde verändert und kann somit nicht mehr als Original gespeichert werden." ;
+// TEXT [ English ] = "The Basic-Code is modified and so it can not be saved as original." ;
+ Text [ en-US ] = "All changes to the Basic Code are lost.The original VBA Macro Code is saved instead.";
+ };
+
+ String ERRCODE_SVX_VBASIC_STORAGE_EXIST & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The original VBA Basic Code contained in the document will not be saved.";
+ };
+
+ String ERRCODE_SVX_WRONGPASS & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The password is incorrect. The document cannot be opened.";
+ };
+
+ String ERRCODE_SVX_READ_FILTER_CRYPT & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The encryption method used in this document is not supported. Only Microsoft Office 97/2000 compatible password encryption is supported.";
+ };
+
+ String ERRCODE_SVX_READ_FILTER_PPOINT & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The loading of password-encrypted Microsoft PowerPoint presentations is not supported.";
+ };
+
+ String ERRCODE_SVX_EXPORT_FILTER_CRYPT & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Password protection is not supported when documents are saved in a Microsoft Office format.\nDo you want to save the document without password protection?";
+ };
+};
+ // ********************************************************************** EOF
+
diff --git a/svx/source/items/svxitems.src b/svx/source/items/svxitems.src
new file mode 100644
index 000000000000..9b15b00bf58d
--- /dev/null
+++ b/svx/source/items/svxitems.src
@@ -0,0 +1,353 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ------------------------------------------------------------------
+
+#include "svx/svxitems.hrc"
+#include "svx/svxids.hrc"
+#include <editeng/editids.hrc>
+
+StringArray RID_ATTR_NAMES
+{
+ ItemList [ en-US ] =
+ {
+ < "Scale" ; SID_ATTR_ZOOM ; > ;
+ < "Brush" ; SID_ATTR_BRUSH ; > ;
+ < "Tab stops" ; SID_ATTR_TABSTOP ; > ;
+ < "Character" ; SID_ATTR_CHAR ; > ;
+ < "Font" ; SID_ATTR_CHAR_FONT ; > ;
+ < "Font posture" ; SID_ATTR_CHAR_POSTURE ; > ;
+ < "Font weight" ; SID_ATTR_CHAR_WEIGHT ; > ;
+ < "Shadowed" ; SID_ATTR_CHAR_SHADOWED ; > ;
+ < "Individual words" ; SID_ATTR_CHAR_WORDLINEMODE ; > ;
+ < "Outline" ; SID_ATTR_CHAR_CONTOUR ; > ;
+ < "Strikethrough" ; SID_ATTR_CHAR_STRIKEOUT ; > ;
+ < "Underline" ; SID_ATTR_CHAR_UNDERLINE ; > ;
+ < "Font size" ; SID_ATTR_CHAR_FONTHEIGHT ; > ;
+ < "Rel. Font size" ; SID_ATTR_CHAR_PROPSIZE ; > ;
+ < "Font color" ; SID_ATTR_CHAR_COLOR ; > ;
+ < "Kerning" ; SID_ATTR_CHAR_KERNING ; > ;
+ < "Effects" ; SID_ATTR_CHAR_CASEMAP ; > ;
+ < "Language"; SID_ATTR_CHAR_LANGUAGE ; > ;
+ < "Position" ; SID_ATTR_CHAR_ESCAPEMENT ; > ;
+ < "Blinking" ; SID_ATTR_CHAR_AUTOKERN ; > ;
+ < "Character set color" ; SID_ATTR_CHAR_CHARSETCOLOR ; > ;
+ < "Overline" ; SID_ATTR_CHAR_OVERLINE ; > ;
+ < "Paragraph" ; SID_ATTR_PARA ; > ;
+ < "Alignment" ; SID_ATTR_PARA_ADJUST ; > ;
+ < "Line spacing" ; SID_ATTR_PARA_LINESPACE ; > ;
+ < "Page Break" ; SID_ATTR_PARA_PAGEBREAK ; > ;
+ < "Hyphenation" ; SID_ATTR_PARA_HYPHENZONE ; > ;
+ < "Do not split paragraph"; SID_ATTR_PARA_SPLIT ; > ;
+ < "Orphans" ; SID_ATTR_PARA_ORPHANS ; > ;
+ < "Widows" ; SID_ATTR_PARA_WIDOWS ; > ;
+ < "Spacing" ; SID_ATTR_PARA_ULSPACE ; > ;
+ < "Indent" ; SID_ATTR_PARA_LRSPACE ; > ;
+ < "Indent" ; SID_ATTR_LRSPACE ; > ;
+ < "Spacing" ; SID_ATTR_ULSPACE ; > ;
+ < "Page" ; SID_ATTR_PAGE ; > ;
+ < "Page Style" ; SID_ATTR_PARA_MODEL ; > ;
+ < "Keep with next paragraph"; SID_ATTR_PARA_KEEP ; > ;
+ < "Blinking" ; SID_ATTR_FLASH ; > ;
+ < "Register-true" ; SID_ATTR_PARA_REGISTER ; > ;
+ < "Character background" ; SID_ATTR_BRUSH_CHAR ; > ;
+ < "Asian font" ; SID_ATTR_CHAR_CJK_FONT ; > ;
+ < "Size of Asian font" ; SID_ATTR_CHAR_CJK_FONTHEIGHT ; > ;
+ < "Language of Asian font"; SID_ATTR_CHAR_CJK_LANGUAGE ; > ;
+ < "Posture of Asian font" ; SID_ATTR_CHAR_CJK_POSTURE ; > ;
+ < "Weight of Asian font" ; SID_ATTR_CHAR_CJK_WEIGHT ; > ;
+ < "CTL" ; SID_ATTR_CHAR_CTL_FONT ; > ;
+ < "Size of complex scripts" ; SID_ATTR_CHAR_CTL_FONTHEIGHT ; > ;
+ < "Language of complex scripts";SID_ATTR_CHAR_CTL_LANGUAGE ; > ;
+ < "Posture of complex scripts"; SID_ATTR_CHAR_CTL_POSTURE ; > ;
+ < "Weight of complex scripts"; SID_ATTR_CHAR_CTL_WEIGHT ; > ;
+ < "Double-lined" ; SID_ATTR_CHAR_TWO_LINES ; > ;
+ < "Emphasis mark" ; SID_ATTR_CHAR_EMPHASISMARK ; > ;
+ < "Text spacing" ; SID_ATTR_PARA_SCRIPTSPACE ; > ;
+ < "Hanging punctuation" ; SID_ATTR_PARA_HANGPUNCTUATION ; > ;
+ < "Forbidden characters" ; SID_ATTR_PARA_FORBIDDEN_RULES ; > ;
+ < "Rotation" ; SID_ATTR_CHAR_ROTATED ; > ;
+ < "Scale" ; SID_ATTR_CHAR_SCALEWIDTH ; > ;
+ < "Relief" ; SID_ATTR_CHAR_RELIEF ; > ;
+ < "Vertical text alignment" ; SID_PARA_VERTALIGN ; > ;
+ };
+};
+
+
+String RID_SVXITEMS_EXTRAS_CHARCOLOR
+{
+ Text [ en-US ] = "Font color" ;
+};
+ // SvxSearchItem ------------------------------------------------------------
+ // Kommando
+String RID_SVXITEMS_SEARCHCMD_FIND
+{
+ Text [ en-US ] = "Search" ;
+};
+String RID_SVXITEMS_SEARCHCMD_FIND_ALL
+{
+ Text [ en-US ] = "Find All" ;
+};
+String RID_SVXITEMS_SEARCHCMD_REPLACE
+{
+ Text [ en-US ] = "Replace" ;
+};
+String RID_SVXITEMS_SEARCHCMD_REPLACE_ALL
+{
+ Text [ en-US ] = "Replace all" ;
+};
+ // Vorlagen
+String RID_SVXITEMS_SEARCHSTYL_CHAR
+{
+ Text [ en-US ] = "Character Style" ;
+};
+String RID_SVXITEMS_SEARCHSTYL_PARA
+{
+ Text [ en-US ] = "Paragraph Style" ;
+};
+String RID_SVXITEMS_SEARCHSTYL_FRAME
+{
+ Text [ en-US ] = "Frame Style" ;
+};
+String RID_SVXITEMS_SEARCHSTYL_PAGE
+{
+ Text [ en-US ] = "Page Style" ;
+};
+ // Zellen-Typ
+String RID_SVXITEMS_SEARCHIN_FORMULA
+{
+ Text [ en-US ] = "Formula" ;
+};
+String RID_SVXITEMS_SEARCHIN_VALUE
+{
+ Text [ en-US ] = "Value" ;
+};
+String RID_SVXITEMS_SEARCHIN_NOTE
+{
+ Text [ en-US ] = "Note" ;
+};
+ // Applikation
+String RID_SVXITEMS_SEARCHAPP_WRITER
+{
+ Text = "StarWriter" ;
+};
+String RID_SVXITEMS_SEARCHAPP_CALC
+{
+ Text = "StarCalc" ;
+};
+String RID_SVXITEMS_SEARCHAPP_DRAW
+{
+ Text = "StarDraw" ;
+};
+String RID_SVXITEMS_SEARCHAPP_BASE
+{
+ Text = "StarBase" ;
+};
+ // enum BrushStyle ----------------------------------------------------------
+String RID_SVXITEMS_BRUSHSTYLE_NULL
+{
+ Text [ en-US ] = "None" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_SOLID
+{
+ Text [ en-US ] = "Solid" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_HORZ
+{
+ Text [ en-US ] = "Horizontal" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_VERT
+{
+ Text [ en-US ] = "Vertical" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_CROSS
+{
+ Text [ en-US ] = "Grid" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_DIAGCROSS
+{
+ Text [ en-US ] = "Diamond" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_UPDIAG
+{
+ Text [ en-US ] = "Diagonal up" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_DOWNDIAG
+{
+ Text [ en-US ] = "Diagonal down" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_25
+{
+ Text = "25%" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_50
+{
+ Text = "50%" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_75
+{
+ Text = "75%" ;
+};
+String RID_SVXITEMS_BRUSHSTYLE_BITMAP
+{
+ Text [ en-US ] = "Image" ;
+};
+
+String RID_SVXITEMS_ORI_STANDARD
+{
+ Text [ en-US ] = "Default orientation" ;
+};
+String RID_SVXITEMS_ORI_TOPBOTTOM
+{
+ Text [ en-US ] = "From top to bottom" ;
+};
+String RID_SVXITEMS_ORI_BOTTOMTOP
+{
+ Text [ en-US ] = "Bottom to Top" ;
+};
+String RID_SVXITEMS_ORI_STACKED
+{
+ Text [ en-US ] = "Stacked" ;
+};
+ // GetValueText von BoolItems
+String RID_SVXITEMS_BOXINF_TABLE_TRUE
+{
+ Text [ en-US ] = "Table" ;
+};
+String RID_SVXITEMS_BOXINF_TABLE_FALSE
+{
+ Text [ en-US ] = "Not Table" ;
+};
+String RID_SVXITEMS_BOXINF_DIST_TRUE
+{
+ Text [ en-US ] = "Spacing enabled" ;
+};
+String RID_SVXITEMS_BOXINF_DIST_FALSE
+{
+ Text [ en-US ] = "Spacing disabled" ;
+};
+String RID_SVXITEMS_BOXINF_MDIST_TRUE
+{
+ Text [ en-US ] = "Keep spacing interval" ;
+};
+String RID_SVXITEMS_BOXINF_MDIST_FALSE
+{
+ Text [ en-US ] = "Allowed to fall short of spacing interval" ;
+};
+String RID_SVXITEMS_MARGIN_LEFT
+{
+ Text [ en-US ] = "Left margin: " ;
+};
+String RID_SVXITEMS_MARGIN_TOP
+{
+ Text [ en-US ] = "Top margin: " ;
+};
+String RID_SVXITEMS_MARGIN_RIGHT
+{
+ Text [ en-US ] = "Right margin: " ;
+};
+String RID_SVXITEMS_MARGIN_BOTTOM
+{
+ Text [ en-US ] = "Bottom margin: " ;
+};
+String RID_SVXITEMS_PAGE_COMPLETE
+{
+ Text [ en-US ] = "Page Description: " ;
+};
+String RID_SVXITEMS_PAGE_NUM_CHR_UPPER
+{
+ Text [ en-US ] = "Capitals" ;
+};
+String RID_SVXITEMS_PAGE_NUM_CHR_LOWER
+{
+ Text [ en-US ] = "Lowercase" ;
+};
+String RID_SVXITEMS_PAGE_NUM_ROM_UPPER
+{
+ Text [ en-US ] = "Uppercase Roman" ;
+};
+String RID_SVXITEMS_PAGE_NUM_ROM_LOWER
+{
+ Text [ en-US ] = "Lowercase Roman" ;
+};
+String RID_SVXITEMS_PAGE_NUM_ARABIC
+{
+ Text [ en-US ] = "Arabic" ;
+};
+String RID_SVXITEMS_PAGE_NUM_NONE
+{
+ Text [ en-US ] = "None" ;
+};
+String RID_SVXITEMS_PAGE_LAND_TRUE
+{
+ Text [ en-US ] = "Landscape" ;
+};
+String RID_SVXITEMS_PAGE_LAND_FALSE
+{
+ Text [ en-US ] = "Portrait" ;
+};
+String RID_SVXITEMS_PAGE_USAGE_LEFT
+{
+ Text [ en-US ] = "Left" ;
+};
+String RID_SVXITEMS_PAGE_USAGE_RIGHT
+{
+ Text [ en-US ] = "Right" ;
+};
+String RID_SVXITEMS_PAGE_USAGE_ALL
+{
+ Text [ en-US ] = "All" ;
+};
+String RID_SVXITEMS_PAGE_USAGE_MIRROR
+{
+ Text [ en-US ] = "Mirrored" ;
+};
+String RID_SVXITEMS_AUTHOR_COMPLETE
+{
+ Text [ en-US ] = "Author: " ;
+};
+String RID_SVXITEMS_DATE_COMPLETE
+{
+ Text [ en-US ] = "Date: " ;
+};
+String RID_SVXITEMS_TEXT_COMPLETE
+{
+ Text [ en-US ] = "Text: " ;
+};
+String RID_SVXITEMS_BACKGROUND_COLOR
+{
+ Text [ en-US ] = "Background color: " ;
+};
+String RID_SVXITEMS_PATTERN_COLOR
+{
+ Text [ en-US ] = "Pattern color: " ;
+};
+String RID_SVXITEMS_BRUSH_CHAR
+{
+ Text [ en-US ] = "Character background";
+};
+ // ********************************************************************** EOF
+
diff --git a/svx/source/items/viewlayoutitem.cxx b/svx/source/items/viewlayoutitem.cxx
new file mode 100644
index 000000000000..42b1143c49f9
--- /dev/null
+++ b/svx/source/items/viewlayoutitem.cxx
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/stream.hxx>
+
+#include <svx/viewlayoutitem.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_FACTORY(SvxViewLayoutItem,SfxUInt16Item, new SvxViewLayoutItem);
+
+#define VIEWLAYOUT_PARAM_COLUMNS "Columns"
+#define VIEWLAYOUT_PARAM_BOOKMODE "BookMode"
+#define VIEWLAYOUT_PARAMS 2
+
+// -----------------------------------------------------------------------
+
+SvxViewLayoutItem::SvxViewLayoutItem
+(
+ USHORT nColumns,
+ bool bBookMode,
+ sal_uInt16 _nWhich
+)
+: SfxUInt16Item( _nWhich, nColumns ),
+ mbBookMode( bBookMode )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxViewLayoutItem::SvxViewLayoutItem( const SvxViewLayoutItem& rOrig )
+: SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ),
+ mbBookMode( rOrig.IsBookMode() )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxViewLayoutItem::~SvxViewLayoutItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxViewLayoutItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SvxViewLayoutItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxViewLayoutItem::Create( SvStream& /*rStrm*/, sal_uInt16 /*nVersion*/ ) const
+{
+/* sal_uInt16 nValue;
+ sal_uInt16 nValSet;
+ sal_Int8 nType;
+ rStrm >> nValue >> nValSet >> nType;
+ SvxZoomItem* pNew = new SvxZoomItem( (SvxZoomType)nType, nValue, Which() );
+ pNew->SetValueSet( nValSet );
+ return pNew;*/
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SvxViewLayoutItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
+{
+/* rStrm << (sal_uInt16)GetValue()
+ << nValueSet
+ << (sal_Int8)eType;*/
+ return rStrm;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxViewLayoutItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
+
+ SvxViewLayoutItem& rItem = (SvxViewLayoutItem&)rAttr;
+
+ return ( GetValue() == rItem.GetValue() &&
+ mbBookMode == rItem.IsBookMode() );
+}
+
+bool SvxViewLayoutItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case 0 :
+ {
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( VIEWLAYOUT_PARAMS );
+ aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VIEWLAYOUT_PARAM_COLUMNS ));
+ aSeq[0].Value <<= sal_Int32( GetValue() );
+ aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VIEWLAYOUT_PARAM_BOOKMODE ));
+ aSeq[1].Value <<= sal_Bool( mbBookMode );
+ rVal <<= aSeq;
+ }
+ break;
+
+ case MID_VIEWLAYOUT_COLUMNS : rVal <<= (sal_Int32) GetValue(); break;
+ case MID_VIEWLAYOUT_BOOKMODE: rVal <<= (sal_Bool) mbBookMode; break;
+ default:
+ DBG_ERROR("svx::SvxViewLayoutItem::QueryValue(), Wrong MemberId!");
+ return false;
+ }
+
+ return true;
+}
+
+bool SvxViewLayoutItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case 0 :
+ {
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq;
+ if (( rVal >>= aSeq ) && ( aSeq.getLength() == VIEWLAYOUT_PARAMS ))
+ {
+ sal_Int32 nColumns( 0 );
+ sal_Bool bBookMode = sal_False;
+ sal_Bool bAllConverted( sal_True );
+ sal_Int16 nConvertedCount( 0 );
+ for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
+ {
+ if ( aSeq[i].Name.equalsAscii( VIEWLAYOUT_PARAM_COLUMNS ))
+ {
+ bAllConverted &= ( aSeq[i].Value >>= nColumns );
+ ++nConvertedCount;
+ }
+ else if ( aSeq[i].Name.equalsAscii( VIEWLAYOUT_PARAM_BOOKMODE ))
+ {
+ bAllConverted &= ( aSeq[i].Value >>= bBookMode );
+ ++nConvertedCount;
+ }
+ }
+
+ if ( bAllConverted && nConvertedCount == VIEWLAYOUT_PARAMS )
+ {
+ SetValue( (UINT16)nColumns );
+ mbBookMode = bBookMode;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ case MID_VIEWLAYOUT_COLUMNS:
+ {
+ sal_Int32 nVal = 0;
+ if ( rVal >>= nVal )
+ {
+ SetValue( (UINT16)nVal );
+ return true;
+ }
+ else
+ return false;
+ }
+
+ case MID_VIEWLAYOUT_BOOKMODE:
+ {
+ sal_Bool bBookMode = sal_False;
+ if ( rVal >>= bBookMode )
+ {
+ mbBookMode = bBookMode;
+ return true;
+ }
+ else
+ return false;
+ }
+
+ default:
+ DBG_ERROR("svx::SvxViewLayoutItem::PutValue(), Wrong MemberId!");
+ return false;
+ }
+
+ return true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/zoomitem.cxx b/svx/source/items/zoomitem.cxx
new file mode 100644
index 000000000000..4ebf2df20fd9
--- /dev/null
+++ b/svx/source/items/zoomitem.cxx
@@ -0,0 +1,232 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/stream.hxx>
+#include <basic/sbxvar.hxx>
+
+#include <svx/zoomitem.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_FACTORY(SvxZoomItem,SfxUInt16Item, new SvxZoomItem);
+
+#define ZOOM_PARAM_VALUE "Value"
+#define ZOOM_PARAM_VALUESET "ValueSet"
+#define ZOOM_PARAM_TYPE "Type"
+#define ZOOM_PARAMS 3
+
+// -----------------------------------------------------------------------
+
+SvxZoomItem::SvxZoomItem
+(
+ SvxZoomType eZoomType,
+ sal_uInt16 nVal,
+ sal_uInt16 _nWhich
+)
+: SfxUInt16Item( _nWhich, nVal ),
+ nValueSet( SVX_ZOOM_ENABLE_ALL ),
+ eType( eZoomType )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxZoomItem::SvxZoomItem( const SvxZoomItem& rOrig )
+: SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ),
+ nValueSet( rOrig.GetValueSet() ),
+ eType( rOrig.GetType() )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxZoomItem::~SvxZoomItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxZoomItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SvxZoomItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxZoomItem::Create( SvStream& rStrm, sal_uInt16 /*nVersion*/ ) const
+{
+ sal_uInt16 nValue;
+ sal_uInt16 nValSet;
+ sal_Int8 nType;
+ rStrm >> nValue >> nValSet >> nType;
+ SvxZoomItem* pNew = new SvxZoomItem( (SvxZoomType)nType, nValue, Which() );
+ pNew->SetValueSet( nValSet );
+ return pNew;
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SvxZoomItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
+{
+ rStrm << (sal_uInt16)GetValue()
+ << nValueSet
+ << (sal_Int8)eType;
+ return rStrm;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxZoomItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
+
+ SvxZoomItem& rItem = (SvxZoomItem&)rAttr;
+
+ return ( GetValue() == rItem.GetValue() &&
+ nValueSet == rItem.GetValueSet() &&
+ eType == rItem.GetType() );
+}
+
+bool SvxZoomItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case 0 :
+ {
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( ZOOM_PARAMS );
+ aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_VALUE ));
+ aSeq[0].Value <<= sal_Int32( GetValue() );
+ aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_VALUESET ));
+ aSeq[1].Value <<= sal_Int16( nValueSet );
+ aSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_TYPE ));
+ aSeq[2].Value <<= sal_Int16( eType );
+ rVal <<= aSeq;
+ }
+ break;
+
+ case MID_VALUE: rVal <<= (sal_Int32) GetValue(); break;
+ case MID_VALUESET: rVal <<= (sal_Int16) nValueSet; break;
+ case MID_TYPE: rVal <<= (sal_Int16) eType; break;
+ default:
+ DBG_ERROR("svx::SvxZoomItem::QueryValue(), Wrong MemberId!");
+ return false;
+ }
+
+ return true;
+}
+
+bool SvxZoomItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case 0 :
+ {
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq;
+ if (( rVal >>= aSeq ) && ( aSeq.getLength() == ZOOM_PARAMS ))
+ {
+ sal_Int32 nValueTmp( 0 );
+ sal_Int16 nValueSetTmp( 0 );
+ sal_Int16 nTypeTmp( 0 );
+ sal_Bool bAllConverted( sal_True );
+ sal_Int16 nConvertedCount( 0 );
+ for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
+ {
+ if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_VALUE ))
+ {
+ bAllConverted &= ( aSeq[i].Value >>= nValueTmp );
+ ++nConvertedCount;
+ }
+ else if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_VALUESET ))
+ {
+ bAllConverted &= ( aSeq[i].Value >>= nValueSetTmp );
+ ++nConvertedCount;
+ }
+ else if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_TYPE ))
+ {
+ bAllConverted &= ( aSeq[i].Value >>= nTypeTmp );
+ ++nConvertedCount;
+ }
+ }
+
+ if ( bAllConverted && nConvertedCount == ZOOM_PARAMS )
+ {
+ SetValue( (UINT16)nValueTmp );
+ nValueSet = nValueSetTmp;
+ eType = SvxZoomType( nTypeTmp );
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ case MID_VALUE:
+ {
+ sal_Int32 nVal = 0;
+ if ( rVal >>= nVal )
+ {
+ SetValue( (UINT16)nVal );
+ return true;
+ }
+ else
+ return false;
+ }
+
+ case MID_VALUESET:
+ case MID_TYPE:
+ {
+ sal_Int16 nVal = sal_Int16();
+ if ( rVal >>= nVal )
+ {
+ if ( nMemberId == MID_VALUESET )
+ nValueSet = (sal_Int16) nVal;
+ else if ( nMemberId == MID_TYPE )
+ eType = SvxZoomType( (sal_Int16) nVal );
+ return true;
+ }
+ else
+ return false;
+ }
+
+ default:
+ DBG_ERROR("svx::SvxZoomItem::PutValue(), Wrong MemberId!");
+ return false;
+ }
+
+ return true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/items/zoomslideritem.cxx b/svx/source/items/zoomslideritem.cxx
new file mode 100644
index 000000000000..79fa3c79cec4
--- /dev/null
+++ b/svx/source/items/zoomslideritem.cxx
@@ -0,0 +1,282 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/stream.hxx>
+
+#include <svx/zoomslideritem.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1_FACTORY(SvxZoomSliderItem,SfxUInt16Item, new SvxZoomSliderItem);
+
+#define ZOOMSLIDER_PARAM_CURRENTZOOM "Columns"
+#define ZOOMSLIDER_PARAM_SNAPPINGPOINTS "SnappingPoints"
+#define ZOOMSLIDER_PARAM_MINZOOM "MinValue"
+#define ZOOMSLIDER_PARAM_MAXZOOM "MaxValue"
+#define ZOOMSLIDER_PARAMS 4
+
+// -----------------------------------------------------------------------
+
+SvxZoomSliderItem::SvxZoomSliderItem( USHORT nCurrentZoom, USHORT nMinZoom, USHORT nMaxZoom, USHORT _nWhich )
+: SfxUInt16Item( _nWhich, nCurrentZoom ), mnMinZoom( nMinZoom ), mnMaxZoom( nMaxZoom )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxZoomSliderItem::SvxZoomSliderItem( const SvxZoomSliderItem& rOrig )
+: SfxUInt16Item( rOrig.Which(), rOrig.GetValue() )
+, maValues( rOrig.maValues )
+, mnMinZoom( rOrig.mnMinZoom )
+, mnMaxZoom( rOrig.mnMaxZoom )
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvxZoomSliderItem::~SvxZoomSliderItem()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxZoomSliderItem::Clone( SfxItemPool * /*pPool*/ ) const
+{
+ return new SvxZoomSliderItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPoolItem* SvxZoomSliderItem::Create( SvStream& /*rStrm*/, sal_uInt16 /*nVersion*/ ) const
+{
+/* sal_uInt16 nValue;
+ sal_uInt16 nValSet;
+ sal_Int8 nType;
+ rStrm >> nValue >> nValSet >> nType;
+ SvxZoomItem* pNew = new SvxZoomItem( (SvxZoomType)nType, nValue, Which() );
+ pNew->SetValueSet( nValSet );
+ return pNew;*/
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SvStream& SvxZoomSliderItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const
+{
+/* rStrm << (sal_uInt16)GetValue()
+ << nValueSet
+ << (sal_Int8)eType;*/
+ return rStrm;
+}
+
+// -----------------------------------------------------------------------
+
+int SvxZoomSliderItem::operator==( const SfxPoolItem& rAttr ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
+
+ SvxZoomSliderItem& rItem = (SvxZoomSliderItem&)rAttr;
+
+ return ( GetValue() == rItem.GetValue() && maValues == rItem.maValues &&
+ mnMinZoom == rItem.mnMinZoom && mnMaxZoom == rItem.mnMaxZoom );
+}
+
+bool SvxZoomSliderItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case 0 :
+ {
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( ZOOMSLIDER_PARAMS );
+ aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOMSLIDER_PARAM_CURRENTZOOM ));
+ aSeq[0].Value <<= sal_Int32( GetValue() );
+ aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOMSLIDER_PARAM_SNAPPINGPOINTS ));
+ aSeq[1].Value <<= maValues;
+ aSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOMSLIDER_PARAM_MINZOOM ) );
+ aSeq[2].Value <<= mnMinZoom;
+ aSeq[3].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOMSLIDER_PARAM_MAXZOOM ) );
+ aSeq[3].Value <<= mnMaxZoom;
+ rVal <<= aSeq;
+ }
+ break;
+
+ case MID_ZOOMSLIDER_CURRENTZOOM :
+ {
+ rVal <<= (sal_Int32) GetValue();
+ }
+ break;
+ case MID_ZOOMSLIDER_SNAPPINGPOINTS:
+ {
+ rVal <<= maValues;
+ }
+ break;
+ case MID_ZOOMSLIDER_MINZOOM:
+ {
+ rVal <<= mnMinZoom;
+ }
+ break;
+ case MID_ZOOMSLIDER_MAXZOOM:
+ {
+ rVal <<= mnMaxZoom;
+ }
+ break;
+ default:
+ DBG_ERROR("svx::SvxZoomSliderItem::QueryValue(), Wrong MemberId!");
+ return false;
+ }
+
+ return true;
+}
+
+bool SvxZoomSliderItem::PutValue( const com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case 0 :
+ {
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq;
+ if (( rVal >>= aSeq ) && ( aSeq.getLength() == ZOOMSLIDER_PARAMS ))
+ {
+ sal_Int32 nCurrentZoom( 0 );
+ com::sun::star::uno::Sequence < sal_Int32 > aValues;
+
+ sal_Bool bAllConverted( sal_True );
+ sal_Int16 nConvertedCount( 0 );
+ sal_Int32 nMinZoom( 0 ), nMaxZoom( 0 );
+
+ for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ )
+ {
+ if ( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_CURRENTZOOM ))
+ {
+ bAllConverted &= ( aSeq[i].Value >>= nCurrentZoom );
+ ++nConvertedCount;
+ }
+ else if ( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_SNAPPINGPOINTS ))
+ {
+ bAllConverted &= ( aSeq[i].Value >>= aValues );
+ ++nConvertedCount;
+ }
+ else if( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_MINZOOM ) )
+ {
+ bAllConverted &= ( aSeq[i].Value >>= nMinZoom );
+ ++nConvertedCount;
+ }
+ else if( aSeq[i].Name.equalsAscii( ZOOMSLIDER_PARAM_MAXZOOM ) )
+ {
+ bAllConverted &= ( aSeq[i].Value >>= nMaxZoom );
+ ++nConvertedCount;
+ }
+ }
+
+ if ( bAllConverted && nConvertedCount == ZOOMSLIDER_PARAMS )
+ {
+ SetValue( (UINT16)nCurrentZoom );
+ maValues = aValues;
+ mnMinZoom = sal::static_int_cast< USHORT >( nMinZoom );
+ mnMaxZoom = sal::static_int_cast< USHORT >( nMaxZoom );
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ case MID_ZOOMSLIDER_CURRENTZOOM:
+ {
+ sal_Int32 nVal = 0;
+ if ( rVal >>= nVal )
+ {
+ SetValue( (UINT16)nVal );
+ return true;
+ }
+ else
+ return false;
+ }
+
+ case MID_ZOOMSLIDER_SNAPPINGPOINTS:
+ {
+ com::sun::star::uno::Sequence < sal_Int32 > aValues;
+ if ( rVal >>= aValues )
+ {
+ maValues = aValues;
+ return true;
+ }
+ else
+ return false;
+ }
+ case MID_ZOOMSLIDER_MINZOOM:
+ {
+ sal_Int32 nVal = 0;
+ if( rVal >>= nVal )
+ {
+ mnMinZoom = (UINT16)nVal;
+ return true;
+ }
+ else
+ return false;
+ }
+ case MID_ZOOMSLIDER_MAXZOOM:
+ {
+ sal_Int32 nVal = 0;
+ if( rVal >>= nVal )
+ {
+ mnMaxZoom = (UINT16)nVal;
+ return true;
+ }
+ else
+ return false;
+ }
+ default:
+ DBG_ERROR("svx::SvxZoomSliderItem::PutValue(), Wrong MemberId!");
+ return false;
+ }
+
+ return true;
+}
+
+void SvxZoomSliderItem::AddSnappingPoint( sal_Int32 nNew )
+{
+ const sal_Int32 nValues = maValues.getLength();
+ maValues.realloc( nValues + 1 );
+ sal_Int32* pValues = maValues.getArray();
+ pValues[ nValues ] = nNew;
+}
+
+const com::sun::star::uno::Sequence < sal_Int32 >& SvxZoomSliderItem::GetSnappingPoints() const
+{
+ return maValues;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/mnuctrls/SmartTagCtl.cxx b/svx/source/mnuctrls/SmartTagCtl.cxx
new file mode 100644
index 000000000000..2de37c2e2904
--- /dev/null
+++ b/svx/source/mnuctrls/SmartTagCtl.cxx
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/SmartTagCtl.hxx>
+#include <com/sun/star/smarttags/XSmartTagAction.hpp>
+#include <com/sun/star/container/XStringKeyMap.hpp>
+#include <svtools/stdmenu.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svxids.hrc>
+
+#include <svx/SmartTagItem.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+#define C2U(cChar) rtl::OUString::createFromAscii(cChar)
+
+// STATIC DATA -----------------------------------------------------------
+
+SFX_IMPL_MENU_CONTROL(SvxSmartTagsControl, SvxSmartTagItem);
+
+//--------------------------------------------------------------------
+
+SvxSmartTagsControl::SvxSmartTagsControl
+(
+ USHORT _nId,
+ Menu& rMenu,
+ SfxBindings& /*rBindings*/
+) :
+ mpMenu ( new PopupMenu ),
+ mrParent ( rMenu ),
+ mpSmartTagItem( 0 )
+{
+ rMenu.SetPopupMenu( _nId, mpMenu );
+}
+
+//--------------------------------------------------------------------
+
+const USHORT MN_ST_INSERT_START = 500;
+
+void SvxSmartTagsControl::FillMenu()
+{
+ if ( !mpSmartTagItem )
+ return;
+
+ USHORT nMenuPos = 0;
+ USHORT nSubMenuPos = 0;
+ USHORT nMenuId = 1;
+ USHORT nSubMenuId = MN_ST_INSERT_START;
+
+ const Sequence < Sequence< Reference< smarttags::XSmartTagAction > > >& rActionComponentsSequence = mpSmartTagItem->GetActionComponentsSequence();
+ const Sequence < Sequence< sal_Int32 > >& rActionIndicesSequence = mpSmartTagItem->GetActionIndicesSequence();
+ const Sequence< Reference< container::XStringKeyMap > >& rStringKeyMaps = mpSmartTagItem->GetStringKeyMaps();
+ const lang::Locale& rLocale = mpSmartTagItem->GetLocale();
+ const rtl::OUString aApplicationName = mpSmartTagItem->GetApplicationName();
+ const rtl::OUString aRangeText = mpSmartTagItem->GetRangeText();
+ const Reference<text::XTextRange>& xTextRange = mpSmartTagItem->GetTextRange();
+ const Reference<frame::XController>& xController = mpSmartTagItem->GetController();
+
+ for ( USHORT j = 0; j < rActionComponentsSequence.getLength(); ++j )
+ {
+ Reference< container::XStringKeyMap > xSmartTagProperties = rStringKeyMaps[j];
+
+ // Get all actions references associated with the current smart tag type:
+ const Sequence< Reference< smarttags::XSmartTagAction > >& rActionComponents = rActionComponentsSequence[j];
+ const Sequence< sal_Int32 >& rActionIndices = rActionIndicesSequence[j];
+
+ if ( 0 == rActionComponents.getLength() || 0 == rActionIndices.getLength() )
+ continue;
+
+ // Ask first entry for the smart tag type caption:
+ Reference< smarttags::XSmartTagAction > xAction = rActionComponents[0];
+
+ if ( !xAction.is() )
+ continue;
+
+ const sal_Int32 nSmartTagIndex = rActionIndices[0];
+ const rtl::OUString aSmartTagType = xAction->getSmartTagName( nSmartTagIndex );
+ const rtl::OUString aSmartTagCaption = xAction->getSmartTagCaption( nSmartTagIndex, rLocale );
+
+ // no sub-menues if there's only one smart tag type listed:
+ PopupMenu* pSbMenu = mpMenu;
+ if ( 1 < rActionComponentsSequence.getLength() )
+ {
+ mpMenu->InsertItem( nMenuId, aSmartTagCaption, 0, nMenuPos++);
+ pSbMenu = new PopupMenu;
+ mpMenu->SetPopupMenu( nMenuId++, pSbMenu );
+ }
+ pSbMenu->SetSelectHdl( LINK( this, SvxSmartTagsControl, MenuSelect ) );
+
+ // sub-menu starts with smart tag caption and separator
+ const rtl::OUString aSmartTagCaption2 = aSmartTagCaption + C2U(": ") + aRangeText;
+ nSubMenuPos = 0;
+ pSbMenu->InsertItem( nMenuId++, aSmartTagCaption2, MIB_NOSELECT, nSubMenuPos++ );
+ pSbMenu->InsertSeparator( nSubMenuPos++ );
+
+ // Add subitem for every action reference for the current smart tag type:
+ for ( USHORT i = 0; i < rActionComponents.getLength(); ++i )
+ {
+ xAction = rActionComponents[i];
+
+ for ( sal_Int32 k = 0; k < xAction->getActionCount( aSmartTagType, xController ); ++k )
+ {
+ const sal_uInt32 nActionID = xAction->getActionID( aSmartTagType, k, xController );
+ rtl::OUString aActionCaption = xAction->getActionCaptionFromID( nActionID,
+ aApplicationName,
+ rLocale,
+ xSmartTagProperties,
+ aRangeText,
+ rtl::OUString(),
+ xController,
+ xTextRange );
+
+ pSbMenu->InsertItem( nSubMenuId++, aActionCaption, 0, nSubMenuPos++ );
+ InvokeAction aEntry( xAction, xSmartTagProperties, nActionID );
+ maInvokeActions.push_back( aEntry );
+ }
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+
+void SvxSmartTagsControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ mrParent.EnableItem( GetId(), SFX_ITEM_DISABLED != eState );
+
+ if ( SFX_ITEM_AVAILABLE == eState )
+ {
+ const SvxSmartTagItem* pSmartTagItem = PTR_CAST( SvxSmartTagItem, pState );
+ if ( 0 != pSmartTagItem )
+ {
+ delete mpSmartTagItem;
+ mpSmartTagItem = new SvxSmartTagItem( *pSmartTagItem );
+ FillMenu();
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( SvxSmartTagsControl, MenuSelect, PopupMenu *, pMen )
+{
+ if ( !mpSmartTagItem )
+ return 0;
+
+ sal_uInt16 nMyId = pMen->GetCurItemId();
+
+ if ( nMyId < MN_ST_INSERT_START) return 0;
+ nMyId -= MN_ST_INSERT_START;
+
+ // compute smarttag lib index and action index
+ Reference< smarttags::XSmartTagAction > xSmartTagAction = maInvokeActions[ nMyId ].mxAction;
+
+ // execute action
+ if ( xSmartTagAction.is() )
+ {
+ xSmartTagAction->invokeAction( maInvokeActions[ nMyId ].mnActionID,
+ mpSmartTagItem->GetApplicationName(),
+ mpSmartTagItem->GetController(),
+ mpSmartTagItem->GetTextRange(),
+ maInvokeActions[ nMyId ].mxSmartTagProperties,
+ mpSmartTagItem->GetRangeText(),
+ rtl::OUString(),
+ mpSmartTagItem->GetLocale() );
+ }
+
+ // ohne dispatcher!!!
+ // GetBindings().Execute( GetId(), SFX_CALLMODE_RECORD,meine beiden items, 0L );*/
+ //SfxBoolItem aBool(SID_OPEN_SMARTTAGOPTIONS, TRUE);
+ //GetBindings().GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SFX_CALLMODE_ASYNCHRON, &aBool, 0L );
+
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvxSmartTagsControl, MenuSelect, PopupMenu *, pMen )
+
+//--------------------------------------------------------------------
+
+SvxSmartTagsControl::~SvxSmartTagsControl()
+{
+ delete mpSmartTagItem;
+ delete mpMenu;
+}
+
+//--------------------------------------------------------------------
+
+PopupMenu* SvxSmartTagsControl::GetPopup() const
+{
+ return mpMenu;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/mnuctrls/clipboardctl.cxx b/svx/source/mnuctrls/clipboardctl.cxx
new file mode 100644
index 000000000000..97ee9795488f
--- /dev/null
+++ b/svx/source/mnuctrls/clipboardctl.cxx
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <sfx2/app.hxx>
+#include <sfx2/tbxctrl.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <tools/gen.hxx>
+#include <svl/intitem.hxx>
+#include <sot/exchange.hxx>
+#include <svl/eitem.hxx>
+#include <vcl/toolbox.hxx>
+#include <clipboardctl.hxx>
+#include <clipfmtitem.hxx>
+
+#include <svtools/insdlg.hxx>
+#include <svx/svxids.hrc>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+
+/////////////////////////////////////////////////////////////////
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxClipBoardControl, SfxVoidItem /*SfxUInt16Item*/ );
+
+
+SvxClipBoardControl::SvxClipBoardControl(
+ USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ pClipboardFmtItem( 0 ),
+ pPopup (0),
+ nItemId (nId),
+ bDisabled( FALSE )
+{
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ClipboardFormatItems" )));
+ ToolBox& rBox = GetToolBox();
+ rBox.SetItemBits( nId, TIB_DROPDOWN | rBox.GetItemBits( nId ) );
+ rBox.Invalidate();
+}
+
+
+SvxClipBoardControl::~SvxClipBoardControl()
+{
+ DelPopup();
+ delete pClipboardFmtItem;
+}
+
+
+SfxPopupWindow* SvxClipBoardControl::CreatePopupWindow()
+{
+ const SvxClipboardFmtItem* pFmtItem = PTR_CAST( SvxClipboardFmtItem, pClipboardFmtItem );
+ if ( pFmtItem )
+ {
+ if (pPopup)
+ pPopup->Clear();
+ else
+ pPopup = new PopupMenu;
+
+ USHORT nCount = pFmtItem->Count();
+ for (USHORT i = 0; i < nCount; ++i)
+ {
+ ULONG nFmtID = pFmtItem->GetClipbrdFormatId( i );
+ String aFmtStr( pFmtItem->GetClipbrdFormatName( i ) );
+ if (!aFmtStr.Len())
+ aFmtStr = SvPasteObjectHelper::GetSotFormatUIName( nFmtID );
+ pPopup->InsertItem( (USHORT)nFmtID, aFmtStr );
+ }
+
+ ToolBox& rBox = GetToolBox();
+ USHORT nId = GetId();
+ rBox.SetItemDown( nId, TRUE );
+
+ pPopup->Execute( &rBox, rBox.GetItemRect( nId ),
+ (rBox.GetAlign() == WINDOWALIGN_TOP || rBox.GetAlign() == WINDOWALIGN_BOTTOM) ?
+ POPUPMENU_EXECUTE_DOWN : POPUPMENU_EXECUTE_RIGHT );
+
+ rBox.SetItemDown( nId, FALSE );
+
+ SfxUInt32Item aItem( SID_CLIPBOARD_FORMAT_ITEMS, pPopup->GetCurItemId() );
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SelectedFormat" ));
+ aItem.QueryValue( a );
+ aArgs[0].Value = a;
+ Dispatch( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ClipboardFormatItems" )),
+ aArgs );
+ }
+
+ GetToolBox().EndSelection();
+ DelPopup();
+ return 0;
+}
+
+
+SfxPopupWindowType SvxClipBoardControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONTIMEOUT;
+}
+
+
+void SvxClipBoardControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ if ( SID_CLIPBOARD_FORMAT_ITEMS == nSID )
+ {
+ DELETEZ( pClipboardFmtItem );
+ if ( eState >= SFX_ITEM_AVAILABLE )
+ {
+ pClipboardFmtItem = pState->Clone();
+ GetToolBox().SetItemBits( GetId(), GetToolBox().GetItemBits( GetId() ) | TIB_DROPDOWN );
+ }
+ else if ( !bDisabled )
+ GetToolBox().SetItemBits( GetId(), GetToolBox().GetItemBits( GetId() ) & ~TIB_DROPDOWN );
+ GetToolBox().Invalidate( GetToolBox().GetItemRect( GetId() ) );
+ }
+ else
+ {
+ // enable the item as a whole
+ bDisabled = (GetItemState(pState) == SFX_ITEM_DISABLED);
+ GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) );
+ }
+}
+
+
+void SvxClipBoardControl::DelPopup()
+{
+ if(pPopup)
+ {
+ delete pPopup;
+ pPopup = 0;
+ }
+}
+
+
+/////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/mnuctrls/fntctl.cxx b/svx/source/mnuctrls/fntctl.cxx
new file mode 100644
index 000000000000..34270066822b
--- /dev/null
+++ b/svx/source/mnuctrls/fntctl.cxx
@@ -0,0 +1,184 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headern
+#include <svtools/stdmenu.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <svx/fntctl.hxx> //
+#include <svx/svxids.hrc>
+#include "editeng/flstitem.hxx"
+#include "editeng/fontitem.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+SFX_IMPL_MENU_CONTROL(SvxFontMenuControl, SvxFontItem);
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Ctor; setzt den Select-Handler am Men"u und tr"agt das Men"u
+ in seinen Parent ein.
+*/
+
+SvxFontMenuControl::SvxFontMenuControl
+(
+ USHORT _nId,
+ Menu& rMenu,
+ SfxBindings& rBindings
+) :
+ pMenu ( new FontNameMenu ),
+ rParent ( rMenu )
+{
+ rMenu.SetPopupMenu( _nId, pMenu );
+ pMenu->SetSelectHdl( LINK( this, SvxFontMenuControl, MenuSelect ) );
+ StartListening( rBindings );
+ FillMenu();
+}
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ F"ullt das Men"u mit den aktuellen Fonts aus der Fontlist
+ der DocumentShell.
+*/
+
+void SvxFontMenuControl::FillMenu()
+{
+ SfxObjectShell *pDoc = SfxObjectShell::Current();
+
+ if ( pDoc )
+ {
+ const SvxFontListItem* pFonts =
+ (const SvxFontListItem*)pDoc->GetItem( SID_ATTR_CHAR_FONTLIST );
+ const FontList* pList = pFonts ? pFonts->GetFontList(): 0;
+ DBG_ASSERT( pList, "Kein Fonts gefunden" );
+ pMenu->Fill( pList );
+ }
+}
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Statusbenachrichtigung;
+ f"ullt ggf. das Men"u mit den aktuellen Fonts aus der Fontlist
+ der DocumentShell.
+ Ist die Funktionalit"at disabled, wird der entsprechende
+ Men"ueintrag im Parentmen"u disabled, andernfalls wird er enabled.
+ Der aktuelle Font wird mit einer Checkmark versehen.
+*/
+
+void SvxFontMenuControl::StateChanged(
+
+ USHORT, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ rParent.EnableItem( GetId(), SFX_ITEM_DISABLED != eState );
+
+ if ( SFX_ITEM_AVAILABLE == eState )
+ {
+ if ( !pMenu->GetItemCount() )
+ FillMenu();
+ const SvxFontItem* pFontItem = PTR_CAST( SvxFontItem, pState );
+ String aFont;
+
+ if ( pFontItem )
+ aFont = pFontItem->GetFamilyName();
+ pMenu->SetCurName( aFont );
+ }
+}
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Statusbenachrichtigung "uber Bindings; bei DOCCHANGED
+ wird das Men"u mit den aktuellen Fonts aus der Fontlist
+ der DocumentShell gef"ullt.
+*/
+
+void SvxFontMenuControl::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.Type() != TYPE(SfxSimpleHint) &&
+ ( (SfxSimpleHint&)rHint ).GetId() == SFX_HINT_DOCCHANGED )
+ FillMenu();
+}
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Select-Handler des Men"us; der Name des selektierten Fonts
+ wird in einem SvxFontItem verschickt. Das F"ullen mit den
+ weiteren Fontinformationen mu\s durch die Applikation geschehen.
+*/
+
+IMPL_LINK_INLINE_START( SvxFontMenuControl, MenuSelect, FontNameMenu *, pMen )
+{
+ SvxFontItem aItem( GetId() );
+ aItem.GetFamilyName() = pMen->GetCurName();
+ GetBindings().GetDispatcher()->Execute( GetId(), SFX_CALLMODE_RECORD, &aItem, 0L );
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvxFontMenuControl, MenuSelect, FontNameMenu *, pMen )
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Dtor; gibt das Men"u frei.
+*/
+
+SvxFontMenuControl::~SvxFontMenuControl()
+{
+ delete pMenu;
+}
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Gibt das Men"u zur"uck
+*/
+
+PopupMenu* SvxFontMenuControl::GetPopup() const
+{
+ return pMenu;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/mnuctrls/fntszctl.cxx b/svx/source/mnuctrls/fntszctl.cxx
new file mode 100644
index 000000000000..5f3a75779cde
--- /dev/null
+++ b/svx/source/mnuctrls/fntszctl.cxx
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headern
+#include <svl/itempool.hxx>
+#include <svtools/stdmenu.hxx>
+#include <svtools/ctrltool.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <svx/fntszctl.hxx> //
+#include <svx/dialogs.hrc>
+#include <editeng/fhgtitem.hxx>
+#include "editeng/fontitem.hxx"
+#include "editeng/flstitem.hxx"
+
+#include "dlgutil.hxx"
+#include <svx/dialmgr.hxx>
+
+#define LOGIC OutputDevice::LogicToLogic
+
+SFX_IMPL_MENU_CONTROL(SvxFontSizeMenuControl, SvxFontHeightItem);
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Select-Handler des Men"us; die aktuelle Fontgr"o\se
+ wird in einem SvxFontHeightItem verschickt.
+*/
+
+IMPL_LINK( SvxFontSizeMenuControl, MenuSelect, FontSizeMenu*, pMen )
+{
+ SfxViewFrame* pFrm = SfxViewFrame::Current();
+ SfxShell* pSh = pFrm ? pFrm->GetDispatcher()->GetShell( 0 ) : NULL;
+
+ if ( !pSh )
+ return 0;
+
+ const SfxItemPool& rPool = pSh->GetPool();
+ USHORT nWhich = rPool.GetWhich( SID_ATTR_CHAR_FONTHEIGHT );
+ const SfxMapUnit eUnit = rPool.GetMetric( nWhich );
+ long nH = LOGIC( pMen->GetCurHeight(), MAP_POINT, (MapUnit)eUnit ) / 10;
+ SvxFontHeightItem aItem( nH, 100, GetId() );
+ GetBindings().GetDispatcher()->Execute( GetId(), SFX_CALLMODE_RECORD, &aItem, 0L );
+ return 1;
+}
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Statusbenachrichtigung;
+ Ist die Funktionalit"at disabled, wird der entsprechende
+ Men"ueintrag im Parentmenu disabled, andernfalls wird er enabled.
+ die aktuelle Fontgr"o\se wird mit einer Checkmark versehen.
+*/
+
+void SvxFontSizeMenuControl::StateChanged(
+
+ USHORT, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ rParent.EnableItem( GetId(), SFX_ITEM_DISABLED != eState );
+
+ if ( SFX_ITEM_AVAILABLE == eState )
+ {
+ if ( pState->ISA(SvxFontHeightItem) )
+ {
+ const SvxFontHeightItem* pItem =
+ PTR_CAST( SvxFontHeightItem, pState );
+ long nVal = 0;
+
+ if ( pItem )
+ {
+ SfxViewFrame* pFrm = SfxViewFrame::Current();
+ SfxShell* pSh = pFrm ? pFrm->GetDispatcher()->GetShell( 0 )
+ : NULL;
+
+ if ( !pSh )
+ return;
+
+ const SfxItemPool& rPool = pSh->GetPool();
+ USHORT nWhich = rPool.GetWhich( SID_ATTR_CHAR_FONTHEIGHT );
+ const SfxMapUnit eUnit = rPool.GetMetric( nWhich );
+ long nH = pItem->GetHeight() * 10;
+ nVal = LOGIC( nH, (MapUnit)eUnit, MAP_POINT );
+ }
+ pMenu->SetCurHeight( nVal );
+ }
+ else if ( pState->ISA(SvxFontItem) )
+ {
+ const SvxFontItem* pItem = PTR_CAST( SvxFontItem, pState );
+
+ if ( pItem )
+ {
+ SfxObjectShell *pDoc = SfxObjectShell::Current();
+
+ if ( pDoc )
+ {
+ const SvxFontListItem* pFonts = (const SvxFontListItem*)
+ pDoc->GetItem( SID_ATTR_CHAR_FONTLIST );
+ const FontList* pList = pFonts ? pFonts->GetFontList(): 0;
+
+ if ( pList )
+ {
+ FontInfo aFntInf = pList->Get( pItem->GetFamilyName(),
+ pItem->GetStyleName() );
+ pMenu->Fill( aFntInf, pList );
+ }
+ // else manche Shells haben keine Fontliste (z.B. Image)
+ }
+ }
+ }
+ }
+ else
+ {
+ // irgendwie muss man ja das Men"u f"ullen
+ SfxObjectShell* pSh = SfxObjectShell::Current();
+
+ if ( pSh )
+ {
+ // daf"ur von der Shell eine Fontliste besorgen
+ const SvxFontListItem* pFonts =
+ (const SvxFontListItem*)pSh->GetItem( SID_ATTR_CHAR_FONTLIST );
+ const FontList* pList = pFonts ? pFonts->GetFontList(): NULL;
+ if ( pList )
+ pMenu->Fill( pList->GetFontName(0), pList );
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Ctor; setzt den Select-Handler am Men"u und tr"agt Men"u
+ in seinen Parent ein.
+*/
+
+SvxFontSizeMenuControl::SvxFontSizeMenuControl
+(
+ USHORT _nId,
+ Menu& rMenu,
+ SfxBindings& rBindings
+) :
+ SfxMenuControl( _nId, rBindings ),
+
+ pMenu ( new FontSizeMenu ),
+ rParent ( rMenu ),
+ aFontNameForwarder( SID_ATTR_CHAR_FONT, *this )
+
+{
+ rMenu.SetPopupMenu( _nId, pMenu );
+ pMenu->SetSelectHdl( LINK( this, SvxFontSizeMenuControl, MenuSelect ) );
+}
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Dtor; gibt das Men"u frei.
+*/
+
+SvxFontSizeMenuControl::~SvxFontSizeMenuControl()
+{
+ delete pMenu;
+}
+
+//--------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Gibt das Men"u zur"uck
+*/
+
+PopupMenu* SvxFontSizeMenuControl::GetPopup() const
+{
+ return pMenu;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/mnuctrls/makefile.mk b/svx/source/mnuctrls/makefile.mk
new file mode 100644
index 000000000000..9c208d9a787c
--- /dev/null
+++ b/svx/source/mnuctrls/makefile.mk
@@ -0,0 +1,71 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=svxpch
+PROJECTPCHSOURCE=$(PRJ)$/util$/svxpch
+
+ENABLE_EXCEPTIONS=TRUE
+
+PRJNAME=svx
+TARGET=mnuctrls
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ mnuctrls.src
+
+SLOFILES= \
+ $(SLO)$/clipboardctl.obj \
+ $(SLO)$/fntctl.obj \
+ $(SLO)$/fntszctl.obj \
+ $(SLO)$/SmartTagCtl.obj
+
+HXX1TARGET=mnuctrls
+HXX1EXT= hxx
+HXX1EXCL= -E:*include*
+HXX1DEPN=\
+ $(INC)$/clipboardctl.hxx \
+ $(INC)$/fntctl.hxx \
+ $(INC)$/fntszctl.hxx \
+ $(INC)$/SmartTagCtl.hxx
+
+EXCEPTIONSFILES= \
+ $(SLO)$/SmartTagCtl.obj
+
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/mnuctrls/mnuctrls.src b/svx/source/mnuctrls/mnuctrls.src
new file mode 100644
index 000000000000..8b27fa22f7b2
--- /dev/null
+++ b/svx/source/mnuctrls/mnuctrls.src
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+
+Menu RID_MN_FONTSIZE {
+ ItemList = {
+ MenuItem {
+ Text = "6";
+ Identifier = 6;
+ };
+ MenuItem {
+ Text = "8";
+ Identifier = 8;
+ };
+ MenuItem {
+ Text = "10";
+ Identifier = 10;
+ };
+ MenuItem {
+ Text = "12";
+ Identifier = 12;
+ };
+ MenuItem {
+ Text = "14";
+ Identifier = 14;
+ };
+ MenuItem {
+ Text = "18";
+ Identifier = 18;
+ };
+ MenuItem {
+ Text = "24";
+ Identifier = 24;
+ };
+ MenuItem {
+ Text = "36";
+ Identifier = 36;
+ };
+ MenuItem {
+ Text = "48";
+ Identifier = 48;
+ };
+ MenuItem {
+ Text = "60";
+ Identifier = 60;
+ };
+ MenuItem {
+ Text = "72";
+ Identifier = 72;
+ };
+ };
+};
+
+
+
+
diff --git a/svx/source/sdr/animation/animationstate.cxx b/svx/source/sdr/animation/animationstate.cxx
new file mode 100644
index 000000000000..343d8d895d59
--- /dev/null
+++ b/svx/source/sdr/animation/animationstate.cxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/animation/animationstate.hxx>
+#include <tools/debug.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/animation/objectanimator.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
+#include <drawinglayer/animation/animationtiming.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace animation
+ {
+ double PrimitiveAnimation::getSmallestNextTime(double fCurrentTime)
+ {
+ double fRetval(0.0);
+
+ if(maAnimatedPrimitives.hasElements())
+ {
+ const sal_Int32 nCount(maAnimatedPrimitives.getLength());
+
+ for(sal_Int32 a(0L); a < nCount; a++)
+ {
+ const drawinglayer::primitive2d::Primitive2DReference xRef(maAnimatedPrimitives[a]);
+ const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D* pCandidate = dynamic_cast< const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D* >(xRef.get());
+ OSL_ENSURE(pCandidate, "PrimitiveAnimation::getSmallestNextTime: wrong primitive in animated list (!)");
+
+ if(pCandidate)
+ {
+ const drawinglayer::animation::AnimationEntry& rAnimEntry = pCandidate->getAnimationEntry();
+ const double fNextTime(rAnimEntry.getNextEventTime(fCurrentTime));
+
+ if(!::basegfx::fTools::equalZero(fNextTime))
+ {
+ if(::basegfx::fTools::equalZero(fRetval))
+ {
+ fRetval = fNextTime;
+ }
+ else if(::basegfx::fTools::less(fNextTime, fRetval))
+ {
+ fRetval = fNextTime;
+ }
+ }
+ }
+ }
+ }
+
+ return fRetval;
+ }
+
+ void PrimitiveAnimation::prepareNextEvent()
+ {
+ const double fCurrentTime(mrVOContact.GetObjectContact().getPrimitiveAnimator().GetTime());
+ const double fNextTime(getSmallestNextTime(fCurrentTime));
+
+ // getSmallestNextTime will be zero when animation ended. If not zero, a next step
+ // exists
+ if(!::basegfx::fTools::equalZero(fNextTime))
+ {
+ // next time point exists, use it
+ sal_uInt32 nNextTime;
+
+ if(fNextTime >= (double)0xffffff00)
+ {
+ // take care for very late points in time, e.g. when a text animation stops
+ // in a defined AnimationEntryFixed with endless (0xffffffff) duration
+ nNextTime = GetTime() + (1000 * 60 * 60); // one hour, works with vcl timers, 0xffffff00 was too much...
+ }
+ else
+ {
+ nNextTime = (sal_uInt32)fNextTime;
+ }
+
+ // ensure step forward in integer timing, the floating step difference maybe smaller than 1.0. Use
+ // at least 25ms for next step
+ const sal_uInt32 nMinimumStepTime((sal_uInt32)fCurrentTime + 25L);
+
+ if(nNextTime <= nMinimumStepTime)
+ {
+ nNextTime = nMinimumStepTime;
+ }
+
+ // set time and reactivate by re-adding to the scheduler
+ SetTime(nNextTime);
+ mrVOContact.GetObjectContact().getPrimitiveAnimator().InsertEvent(this);
+ }
+ }
+
+ PrimitiveAnimation::PrimitiveAnimation(sdr::contact::ViewObjectContact& rVOContact, const drawinglayer::primitive2d::Primitive2DSequence& rAnimatedPrimitives)
+ : Event(0L),
+ mrVOContact(rVOContact),
+ maAnimatedPrimitives(rAnimatedPrimitives)
+ {
+ // setup initially
+ prepareNextEvent();
+ }
+
+ PrimitiveAnimation::~PrimitiveAnimation()
+ {
+ // ensure that Event member is removed from PrimitiveAnimator
+ mrVOContact.GetObjectContact().getPrimitiveAnimator().RemoveEvent(this);
+ }
+
+ // execute event, from base class Event
+ void PrimitiveAnimation::Trigger(sal_uInt32 /*nTime*/)
+ {
+ // schedule a repaint of associated object
+ mrVOContact.ActionChanged();
+
+ // re-setup
+ prepareNextEvent();
+ }
+ } // end of namespace animation
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/animation/makefile.mk b/svx/source/sdr/animation/makefile.mk
new file mode 100644
index 000000000000..a6750647f556
--- /dev/null
+++ b/svx/source/sdr/animation/makefile.mk
@@ -0,0 +1,46 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=svx
+TARGET=animation
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/animationstate.obj \
+ $(SLO)$/objectanimator.obj \
+ $(SLO)$/scheduler.obj
+
+.INCLUDE : target.mk
diff --git a/svx/source/sdr/animation/objectanimator.cxx b/svx/source/sdr/animation/objectanimator.cxx
new file mode 100644
index 000000000000..2c66eb2a006f
--- /dev/null
+++ b/svx/source/sdr/animation/objectanimator.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/animation/objectanimator.hxx>
+#include <tools/debug.hxx>
+#include <svx/sdr/animation/animationstate.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace animation
+ {
+ primitiveAnimator::primitiveAnimator()
+ : Scheduler()
+ {
+ }
+
+ primitiveAnimator::~primitiveAnimator()
+ {
+ }
+ } // end of namespace animation
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/animation/scheduler.cxx b/svx/source/sdr/animation/scheduler.cxx
new file mode 100644
index 000000000000..1b299a24becf
--- /dev/null
+++ b/svx/source/sdr/animation/scheduler.cxx
@@ -0,0 +1,318 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/animation/scheduler.hxx>
+
+#include <vector>
+
+//////////////////////////////////////////////////////////////////////////////
+// event class
+
+namespace sdr
+{
+ namespace animation
+ {
+ Event::Event(sal_uInt32 nTime)
+ : mnTime(nTime),
+ mpNext(0L)
+ {
+ }
+
+ Event::~Event()
+ {
+ }
+
+ Event* Event::GetNext() const
+ {
+ return mpNext;
+ }
+
+ void Event::SetNext(Event* pNew)
+ {
+ if(pNew != mpNext)
+ {
+ mpNext = pNew;
+ }
+ }
+
+ sal_uInt32 Event::GetTime() const
+ {
+ return mnTime;
+ }
+
+ void Event::SetTime(sal_uInt32 nNew)
+ {
+ if(mnTime != nNew)
+ {
+ mnTime = nNew;
+ }
+ }
+ } // end of namespace animation
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eventlist class
+
+namespace sdr
+{
+ namespace animation
+ {
+ EventList::EventList()
+ : mpHead(0L)
+ {
+ }
+
+ EventList::~EventList()
+ {
+ Clear();
+ }
+
+ void EventList::Insert(Event* pNew)
+ {
+ if(pNew)
+ {
+ Event* pCurrent = mpHead;
+ Event* pPrev = 0L;
+
+ while(pCurrent && pCurrent->GetTime() < pNew->GetTime())
+ {
+ pPrev = pCurrent;
+ pCurrent = pCurrent->GetNext();
+ }
+
+ if(pPrev)
+ {
+ pNew->SetNext(pPrev->GetNext());
+ pPrev->SetNext(pNew);
+ }
+ else
+ {
+ pNew->SetNext(mpHead);
+ mpHead = pNew;
+ }
+ }
+ }
+
+ void EventList::Remove(Event* pOld)
+ {
+ if(pOld && mpHead)
+ {
+ Event* pCurrent = mpHead;
+ Event* pPrev = 0L;
+
+ while(pCurrent && pCurrent != pOld)
+ {
+ pPrev = pCurrent;
+ pCurrent = pCurrent->GetNext();
+ }
+
+ if(pPrev)
+ {
+ pPrev->SetNext(pOld->GetNext());
+ }
+ else
+ {
+ mpHead = pOld->GetNext();
+ }
+
+ pOld->SetNext(0L);
+ }
+ }
+
+ void EventList::Clear()
+ {
+ while(mpHead)
+ {
+ Event* pNext = mpHead->GetNext();
+ mpHead->SetNext(0L);
+ mpHead = pNext;
+ }
+ }
+
+ Event* EventList::GetFirst()
+ {
+ return mpHead;
+ }
+ } // end of namespace animation
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// scheduler class
+
+namespace sdr
+{
+ namespace animation
+ {
+ Scheduler::Scheduler()
+ : mnTime(0L),
+ mnDeltaTime(0L),
+ mbIsPaused(false)
+ {
+ }
+
+ Scheduler::~Scheduler()
+ {
+ Stop();
+ }
+
+ void Scheduler::Timeout()
+ {
+ // stop timer and add time
+ Stop();
+ mnTime += mnDeltaTime;
+
+ // execute events
+ triggerEvents();
+
+ // re-start or stop timer according to event list
+ checkTimeout();
+ }
+
+ void Scheduler::triggerEvents()
+ {
+ Event* pNextEvent = maList.GetFirst();
+
+ if(pNextEvent)
+ {
+ // copy events which need to be executed to a vector. Remove them from
+ // the scheduler
+ ::std::vector< Event* > EventPointerVector;
+
+ while(pNextEvent && pNextEvent->GetTime() <= mnTime)
+ {
+ maList.Remove(pNextEvent);
+ EventPointerVector.push_back(pNextEvent);
+ pNextEvent = maList.GetFirst();
+ }
+
+ // execute events from the vector
+ for(::std::vector< Event* >::iterator aCandidate = EventPointerVector.begin();
+ aCandidate != EventPointerVector.end(); aCandidate++)
+ {
+ // trigger event. This may re-insert the event to the scheduler again
+ (*aCandidate)->Trigger(mnTime);
+ }
+ }
+ }
+
+ void Scheduler::checkTimeout()
+ {
+ // re-start or stop timer according to event list
+ if(!IsPaused() && maList.GetFirst())
+ {
+ mnDeltaTime = maList.GetFirst()->GetTime() - mnTime;
+
+ if(0L != mnDeltaTime)
+ {
+ SetTimeout(mnDeltaTime);
+ Start();
+ }
+ }
+ else
+ {
+ Stop();
+ }
+ }
+
+ sal_uInt32 Scheduler::GetTime()
+ {
+ return mnTime;
+ }
+
+ // #i38135#
+ void Scheduler::SetTime(sal_uInt32 nTime)
+ {
+ // reset time
+ Stop();
+ mnTime = nTime;
+
+ // get event pointer
+ Event* pEvent = maList.GetFirst();
+
+ if(pEvent)
+ {
+ // retet event time points
+ while(pEvent)
+ {
+ pEvent->SetTime(nTime);
+ pEvent = pEvent->GetNext();
+ }
+
+ if(!IsPaused())
+ {
+ // without delta time, init events by triggering them. This will invalidate
+ // painted objects and add them to the scheduler again
+ mnDeltaTime = 0L;
+ triggerEvents();
+ checkTimeout();
+ }
+ }
+ }
+
+ void Scheduler::Reset(sal_uInt32 nTime)
+ {
+ mnTime = nTime;
+ mnDeltaTime = 0L;
+ maList.Clear();
+ }
+
+ void Scheduler::InsertEvent(Event* pNew)
+ {
+ if(pNew)
+ {
+ maList.Insert(pNew);
+ checkTimeout();
+ }
+ }
+
+ void Scheduler::RemoveEvent(Event* pOld)
+ {
+ if(pOld && maList.GetFirst())
+ {
+ maList.Remove(pOld);
+ checkTimeout();
+ }
+ }
+
+ void Scheduler::SetPaused(bool bNew)
+ {
+ if(bNew != mbIsPaused)
+ {
+ mbIsPaused = bNew;
+ checkTimeout();
+ }
+ }
+ } // end of namespace animation
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/attribute/makefile.mk b/svx/source/sdr/attribute/makefile.mk
new file mode 100644
index 000000000000..177654ff1e1c
--- /dev/null
+++ b/svx/source/sdr/attribute/makefile.mk
@@ -0,0 +1,50 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=svx
+TARGET=attribute
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/sdrfilltextattribute.obj \
+ $(SLO)$/sdrlinefillshadowtextattribute.obj \
+ $(SLO)$/sdrlineshadowtextattribute.obj \
+ $(SLO)$/sdrshadowtextattribute.obj \
+ $(SLO)$/sdrtextattribute.obj \
+ $(SLO)$/sdrformtextattribute.obj \
+ $(SLO)$/sdrformtextoutlineattribute.obj
+
+.INCLUDE : target.mk
diff --git a/svx/source/sdr/attribute/sdrfilltextattribute.cxx b/svx/source/sdr/attribute/sdrfilltextattribute.cxx
new file mode 100644
index 000000000000..5010233a030c
--- /dev/null
+++ b/svx/source/sdr/attribute/sdrfilltextattribute.cxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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: sdrallattribute.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include <svx/sdr/attribute/sdrfilltextattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace attribute
+ {
+ SdrFillTextAttribute::SdrFillTextAttribute(
+ const SdrFillAttribute& rFill,
+ const FillGradientAttribute& rFillFloatTransGradient,
+ const SdrTextAttribute& rTextAttribute)
+ : maFill(rFill),
+ maFillFloatTransGradient(rFillFloatTransGradient),
+ maTextAttribute(rTextAttribute)
+ {
+ }
+
+ SdrFillTextAttribute::SdrFillTextAttribute()
+ : maFill(),
+ maFillFloatTransGradient(),
+ maTextAttribute()
+ {
+ }
+
+ SdrFillTextAttribute::SdrFillTextAttribute(const SdrFillTextAttribute& rCandidate)
+ : maFill(rCandidate.getFill()),
+ maFillFloatTransGradient(rCandidate.getFillFloatTransGradient()),
+ maTextAttribute(rCandidate.getText())
+ {
+ }
+
+ SdrFillTextAttribute& SdrFillTextAttribute::operator=(const SdrFillTextAttribute& rCandidate)
+ {
+ maFill = rCandidate.getFill();
+ maFillFloatTransGradient = rCandidate.getFillFloatTransGradient();
+ maTextAttribute = rCandidate.getText();
+
+ return *this;
+ }
+
+ bool SdrFillTextAttribute::isDefault() const
+ {
+ return(getFill().isDefault()
+ && getFillFloatTransGradient().isDefault()
+ && getText().isDefault());
+ }
+
+ bool SdrFillTextAttribute::operator==(const SdrFillTextAttribute& rCandidate) const
+ {
+ return(getFill() == rCandidate.getFill()
+ && getFillFloatTransGradient() == rCandidate.getFillFloatTransGradient()
+ && getText() == rCandidate.getText());
+ }
+ } // end of namespace attribute
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/attribute/sdrformtextattribute.cxx b/svx/source/sdr/attribute/sdrformtextattribute.cxx
new file mode 100644
index 000000000000..077455b8e81c
--- /dev/null
+++ b/svx/source/sdr/attribute/sdrformtextattribute.cxx
@@ -0,0 +1,426 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include <svx/sdr/attribute/sdrformtextattribute.hxx>
+#include <basegfx/vector/b2enums.hxx>
+#include <svl/itemset.hxx>
+#include <svx/xftdiit.hxx>
+#include <svx/xftstit.hxx>
+#include <svx/xftshxy.hxx>
+#include <svx/xftshtit.hxx>
+#include <svx/xtextit0.hxx>
+#include <svx/xftadit.hxx>
+#include <svx/xftshit.hxx>
+#include <svx/xftshcit.hxx>
+#include <svx/xftmrit.hxx>
+#include <svx/xftouit.hxx>
+#include <svx/sdshtitm.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/sdshcitm.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlinjoit.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xdash.hxx>
+#include <svx/xlndsit.hxx>
+#include <drawinglayer/attribute/lineattribute.hxx>
+#include <drawinglayer/attribute/strokeattribute.hxx>
+#include <svx/sdr/attribute/sdrformtextoutlineattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// helper to get line, stroke and transparence attributes from SfxItemSet
+
+namespace
+{
+ basegfx::B2DLineJoin impGetB2DLineJoin(XLineJoint eLineJoint)
+ {
+ switch(eLineJoint)
+ {
+ case XLINEJOINT_MIDDLE :
+ {
+ return basegfx::B2DLINEJOIN_MIDDLE;
+ }
+ case XLINEJOINT_BEVEL :
+ {
+ return basegfx::B2DLINEJOIN_BEVEL;
+ }
+ case XLINEJOINT_MITER :
+ {
+ return basegfx::B2DLINEJOIN_MITER;
+ }
+ case XLINEJOINT_ROUND :
+ {
+ return basegfx::B2DLINEJOIN_ROUND;
+ }
+ default :
+ {
+ return basegfx::B2DLINEJOIN_NONE; // XLINEJOINT_NONE
+ }
+ }
+ }
+
+ sal_uInt8 impGetStrokeTransparence(bool bShadow, const SfxItemSet& rSet)
+ {
+ sal_uInt8 nRetval;
+
+ if(bShadow)
+ {
+ nRetval = (sal_uInt8)((((SdrShadowTransparenceItem&)(rSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue() * 255) / 100);
+ }
+ else
+ {
+ nRetval = (sal_uInt8)((((XLineTransparenceItem&)(rSet.Get(XATTR_LINETRANSPARENCE))).GetValue() * 255) / 100);
+ }
+
+ return nRetval;
+ }
+
+ drawinglayer::attribute::LineAttribute impGetLineAttribute(bool bShadow, const SfxItemSet& rSet)
+ {
+ basegfx::BColor aColorAttribute;
+
+ if(bShadow)
+ {
+ const Color aShadowColor(((SdrShadowColorItem&)(rSet.Get(SDRATTR_SHADOWCOLOR))).GetColorValue());
+ aColorAttribute = aShadowColor.getBColor();
+ }
+ else
+ {
+ const Color aLineColor(((XLineColorItem&)(rSet.Get(XATTR_LINECOLOR))).GetColorValue());
+ aColorAttribute = aLineColor.getBColor();
+ }
+
+ const sal_uInt32 nLineWidth = ((const XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue();
+ const XLineJoint eLineJoint = ((const XLineJointItem&)(rSet.Get(XATTR_LINEJOINT))).GetValue();
+
+ return drawinglayer::attribute::LineAttribute(aColorAttribute, (double)nLineWidth, impGetB2DLineJoin(eLineJoint));
+ }
+
+ drawinglayer::attribute::StrokeAttribute impGetStrokeAttribute(const SfxItemSet& rSet)
+ {
+ const XLineStyle eLineStyle = ((XLineStyleItem&)(rSet.Get(XATTR_LINESTYLE))).GetValue();
+ double fFullDotDashLen(0.0);
+ ::std::vector< double > aDotDashArray;
+
+ if(XLINE_DASH == eLineStyle)
+ {
+ const XDash& rDash = ((const XLineDashItem&)(rSet.Get(XATTR_LINEDASH))).GetDashValue();
+
+ if(rDash.GetDots() || rDash.GetDashes())
+ {
+ const sal_uInt32 nLineWidth = ((const XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue();
+ fFullDotDashLen = rDash.CreateDotDashArray(aDotDashArray, (double)nLineWidth);
+ }
+ }
+
+ return drawinglayer::attribute::StrokeAttribute(aDotDashArray, fFullDotDashLen);
+ }
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace attribute
+ {
+ class ImpSdrFormTextAttribute
+ {
+ public:
+ // refcounter
+ sal_uInt32 mnRefCount;
+
+ // FormText (FontWork) Attributes
+ sal_Int32 mnFormTextDistance; // distance from line in upright direction
+ sal_Int32 mnFormTextStart; // shift from polygon start
+ sal_Int32 mnFormTextShdwXVal; // shadow distance or 10th degrees
+ sal_Int32 mnFormTextShdwYVal; // shadow distance or scaling
+ sal_uInt16 mnFormTextShdwTransp; // shadow transparence
+ XFormTextStyle meFormTextStyle; // on/off and char orientation
+ XFormTextAdjust meFormTextAdjust; // adjustment (left/right/center) and scale
+ XFormTextShadow meFormTextShadow; // shadow mode
+ Color maFormTextShdwColor; // shadow color
+
+ // outline attributes; used when getFormTextOutline() is true and (for
+ // shadow) when getFormTextShadow() != XFTSHADOW_NONE
+ SdrFormTextOutlineAttribute maOutline;
+ SdrFormTextOutlineAttribute maShadowOutline;
+
+ // bitfield
+ unsigned mbFormTextMirror : 1; // change orientation
+ unsigned mbFormTextOutline : 1; // show contour of objects
+
+ ImpSdrFormTextAttribute(const SfxItemSet& rSet)
+ : mnRefCount(0),
+ mnFormTextDistance(((const XFormTextDistanceItem&)rSet.Get(XATTR_FORMTXTDISTANCE)).GetValue()),
+ mnFormTextStart(((const XFormTextStartItem&)rSet.Get(XATTR_FORMTXTSTART)).GetValue()),
+ mnFormTextShdwXVal(((const XFormTextShadowXValItem&)rSet.Get(XATTR_FORMTXTSHDWXVAL)).GetValue()),
+ mnFormTextShdwYVal(((const XFormTextShadowYValItem&)rSet.Get(XATTR_FORMTXTSHDWYVAL)).GetValue()),
+ mnFormTextShdwTransp(((const XFormTextShadowTranspItem&)rSet.Get(XATTR_FORMTXTSHDWTRANSP)).GetValue()),
+ meFormTextStyle(((const XFormTextStyleItem&)rSet.Get(XATTR_FORMTXTSTYLE)).GetValue()),
+ meFormTextAdjust(((const XFormTextAdjustItem&)rSet.Get(XATTR_FORMTXTADJUST)).GetValue()),
+ meFormTextShadow(((const XFormTextShadowItem&)rSet.Get(XATTR_FORMTXTSHADOW)).GetValue()),
+ maFormTextShdwColor(((const XFormTextShadowColorItem&)rSet.Get(XATTR_FORMTXTSHDWCOLOR)).GetColorValue()),
+ maOutline(),
+ maShadowOutline(),
+ mbFormTextMirror(((const XFormTextMirrorItem&)rSet.Get(XATTR_FORMTXTMIRROR)).GetValue()),
+ mbFormTextOutline(((const XFormTextOutlineItem&)rSet.Get(XATTR_FORMTXTOUTLINE)).GetValue())
+ {
+ if(getFormTextOutline())
+ {
+ const StrokeAttribute aStrokeAttribute(impGetStrokeAttribute(rSet));
+
+ // also need to prepare attributes for outlines
+ {
+ const LineAttribute aLineAttribute(impGetLineAttribute(false, rSet));
+ const sal_uInt8 nTransparence(impGetStrokeTransparence(false, rSet));
+
+ maOutline = SdrFormTextOutlineAttribute(
+ aLineAttribute, aStrokeAttribute, nTransparence);
+ }
+
+ if(XFTSHADOW_NONE != getFormTextShadow())
+ {
+ // also need to prepare attributes for shadow outlines
+ const LineAttribute aLineAttribute(impGetLineAttribute(true, rSet));
+ const sal_uInt8 nTransparence(impGetStrokeTransparence(true, rSet));
+
+ maShadowOutline = SdrFormTextOutlineAttribute(
+ aLineAttribute, aStrokeAttribute, nTransparence);
+ }
+ }
+ }
+
+ ImpSdrFormTextAttribute()
+ : mnRefCount(0),
+ mnFormTextDistance(0),
+ mnFormTextStart(0),
+ mnFormTextShdwXVal(0),
+ mnFormTextShdwYVal(0),
+ mnFormTextShdwTransp(0),
+ meFormTextStyle(XFT_NONE),
+ meFormTextAdjust(XFT_CENTER),
+ meFormTextShadow(XFTSHADOW_NONE),
+ maFormTextShdwColor(),
+ maOutline(),
+ maShadowOutline(),
+ mbFormTextMirror(false),
+ mbFormTextOutline(false)
+ {
+ }
+
+ // data read access
+ sal_Int32 getFormTextDistance() const { return mnFormTextDistance; }
+ sal_Int32 getFormTextStart() const { return mnFormTextStart; }
+ sal_Int32 getFormTextShdwXVal() const { return mnFormTextShdwXVal; }
+ sal_Int32 getFormTextShdwYVal() const { return mnFormTextShdwYVal; }
+ sal_uInt16 getFormTextShdwTransp() const { return mnFormTextShdwTransp; }
+ XFormTextStyle getFormTextStyle() const { return meFormTextStyle; }
+ XFormTextAdjust getFormTextAdjust() const { return meFormTextAdjust; }
+ XFormTextShadow getFormTextShadow() const { return meFormTextShadow; }
+ Color getFormTextShdwColor() const { return maFormTextShdwColor; }
+ const SdrFormTextOutlineAttribute& getOutline() const { return maOutline; }
+ const SdrFormTextOutlineAttribute& getShadowOutline() const { return maShadowOutline; }
+ bool getFormTextMirror() const { return mbFormTextMirror; }
+ bool getFormTextOutline() const { return mbFormTextOutline; }
+
+ // compare operator
+ bool operator==(const ImpSdrFormTextAttribute& rCandidate) const
+ {
+ return (getFormTextDistance() == rCandidate.getFormTextDistance()
+ && getFormTextStart() == rCandidate.getFormTextStart()
+ && getFormTextShdwXVal() == rCandidate.getFormTextShdwXVal()
+ && getFormTextShdwYVal() == rCandidate.getFormTextShdwYVal()
+ && getFormTextShdwTransp() == rCandidate.getFormTextShdwTransp()
+ && getFormTextStyle() == rCandidate.getFormTextStyle()
+ && getFormTextAdjust() == rCandidate.getFormTextAdjust()
+ && getFormTextShadow() == rCandidate.getFormTextShadow()
+ && getFormTextShdwColor() == rCandidate.getFormTextShdwColor()
+ && getOutline() == rCandidate.getOutline()
+ && getShadowOutline() == rCandidate.getShadowOutline()
+ && getFormTextMirror() == rCandidate.getFormTextMirror()
+ && getFormTextOutline() == rCandidate.getFormTextOutline());
+ }
+
+ static ImpSdrFormTextAttribute* get_global_default()
+ {
+ static ImpSdrFormTextAttribute* pDefault = 0;
+
+ if(!pDefault)
+ {
+ pDefault = new ImpSdrFormTextAttribute();
+
+ // never delete; start with RefCount 1, not 0
+ pDefault->mnRefCount++;
+ }
+
+ return pDefault;
+ }
+ };
+
+ SdrFormTextAttribute::SdrFormTextAttribute(const SfxItemSet& rSet)
+ : mpSdrFormTextAttribute(new ImpSdrFormTextAttribute(rSet))
+ {
+ }
+
+ SdrFormTextAttribute::SdrFormTextAttribute()
+ : mpSdrFormTextAttribute(ImpSdrFormTextAttribute::get_global_default())
+ {
+ mpSdrFormTextAttribute->mnRefCount++;
+ }
+
+ SdrFormTextAttribute::SdrFormTextAttribute(const SdrFormTextAttribute& rCandidate)
+ : mpSdrFormTextAttribute(rCandidate.mpSdrFormTextAttribute)
+ {
+ mpSdrFormTextAttribute->mnRefCount++;
+ }
+
+ SdrFormTextAttribute::~SdrFormTextAttribute()
+ {
+ if(mpSdrFormTextAttribute->mnRefCount)
+ {
+ mpSdrFormTextAttribute->mnRefCount--;
+ }
+ else
+ {
+ delete mpSdrFormTextAttribute;
+ }
+ }
+
+ bool SdrFormTextAttribute::isDefault() const
+ {
+ return mpSdrFormTextAttribute == ImpSdrFormTextAttribute::get_global_default();
+ }
+
+ SdrFormTextAttribute& SdrFormTextAttribute::operator=(const SdrFormTextAttribute& rCandidate)
+ {
+ if(rCandidate.mpSdrFormTextAttribute != mpSdrFormTextAttribute)
+ {
+ if(mpSdrFormTextAttribute->mnRefCount)
+ {
+ mpSdrFormTextAttribute->mnRefCount--;
+ }
+ else
+ {
+ delete mpSdrFormTextAttribute;
+ }
+
+ mpSdrFormTextAttribute = rCandidate.mpSdrFormTextAttribute;
+ mpSdrFormTextAttribute->mnRefCount++;
+ }
+
+ return *this;
+ }
+
+ bool SdrFormTextAttribute::operator==(const SdrFormTextAttribute& rCandidate) const
+ {
+ if(rCandidate.mpSdrFormTextAttribute == mpSdrFormTextAttribute)
+ {
+ return true;
+ }
+
+ if(rCandidate.isDefault() != isDefault())
+ {
+ return false;
+ }
+
+ return (*rCandidate.mpSdrFormTextAttribute == *mpSdrFormTextAttribute);
+ }
+
+ sal_Int32 SdrFormTextAttribute::getFormTextDistance() const
+ {
+ return mpSdrFormTextAttribute->getFormTextDistance();
+ }
+
+ sal_Int32 SdrFormTextAttribute::getFormTextStart() const
+ {
+ return mpSdrFormTextAttribute->getFormTextStart();
+ }
+
+ sal_Int32 SdrFormTextAttribute::getFormTextShdwXVal() const
+ {
+ return mpSdrFormTextAttribute->getFormTextShdwXVal();
+ }
+
+ sal_Int32 SdrFormTextAttribute::getFormTextShdwYVal() const
+ {
+ return mpSdrFormTextAttribute->getFormTextShdwYVal();
+ }
+
+ sal_uInt16 SdrFormTextAttribute::getFormTextShdwTransp() const
+ {
+ return mpSdrFormTextAttribute->getFormTextShdwTransp();
+ }
+
+ XFormTextStyle SdrFormTextAttribute::getFormTextStyle() const
+ {
+ return mpSdrFormTextAttribute->getFormTextStyle();
+ }
+
+ XFormTextAdjust SdrFormTextAttribute::getFormTextAdjust() const
+ {
+ return mpSdrFormTextAttribute->getFormTextAdjust();
+ }
+
+ XFormTextShadow SdrFormTextAttribute::getFormTextShadow() const
+ {
+ return mpSdrFormTextAttribute->getFormTextShadow();
+ }
+
+ Color SdrFormTextAttribute::getFormTextShdwColor() const
+ {
+ return mpSdrFormTextAttribute->getFormTextShdwColor();
+ }
+
+ const SdrFormTextOutlineAttribute& SdrFormTextAttribute::getOutline() const
+ {
+ return mpSdrFormTextAttribute->getOutline();
+ }
+
+ const SdrFormTextOutlineAttribute& SdrFormTextAttribute::getShadowOutline() const
+ {
+ return mpSdrFormTextAttribute->getShadowOutline();
+ }
+
+ bool SdrFormTextAttribute::getFormTextMirror() const
+ {
+ return mpSdrFormTextAttribute->getFormTextMirror();
+ }
+
+ bool SdrFormTextAttribute::getFormTextOutline() const
+ {
+ return mpSdrFormTextAttribute->getFormTextOutline();
+ }
+ } // end of namespace attribute
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/attribute/sdrformtextoutlineattribute.cxx b/svx/source/sdr/attribute/sdrformtextoutlineattribute.cxx
new file mode 100644
index 000000000000..f0f79f28cd34
--- /dev/null
+++ b/svx/source/sdr/attribute/sdrformtextoutlineattribute.cxx
@@ -0,0 +1,188 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include <svx/sdr/attribute/sdrformtextoutlineattribute.hxx>
+#include <drawinglayer/attribute/lineattribute.hxx>
+#include <drawinglayer/attribute/strokeattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace attribute
+ {
+ class ImpSdrFormTextOutlineAttribute
+ {
+ public:
+ // refcounter
+ sal_uInt32 mnRefCount;
+
+ // one set of attributes for FormText (FontWork) outline visualisation
+ LineAttribute maLineAttribute;
+ StrokeAttribute maStrokeAttribute;
+ sal_uInt8 mnTransparence;
+
+ ImpSdrFormTextOutlineAttribute(
+ const LineAttribute& rLineAttribute,
+ const StrokeAttribute& rStrokeAttribute,
+ sal_uInt8 nTransparence)
+ : mnRefCount(0),
+ maLineAttribute(rLineAttribute),
+ maStrokeAttribute(rStrokeAttribute),
+ mnTransparence(nTransparence)
+ {
+ }
+
+ // data read access
+ const LineAttribute& getLineAttribute() const { return maLineAttribute; }
+ const StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; }
+ sal_uInt8 getTransparence() const { return mnTransparence; }
+
+ // compare operator
+ bool operator==(const ImpSdrFormTextOutlineAttribute& rCandidate) const
+ {
+ return (getLineAttribute() == rCandidate.getLineAttribute()
+ && getStrokeAttribute() == rCandidate.getStrokeAttribute()
+ && getTransparence() == rCandidate.getTransparence());
+ }
+
+ static ImpSdrFormTextOutlineAttribute* get_global_default()
+ {
+ static ImpSdrFormTextOutlineAttribute* pDefault = 0;
+
+ if(!pDefault)
+ {
+ pDefault = new ImpSdrFormTextOutlineAttribute(
+ LineAttribute(),
+ StrokeAttribute(),
+ 0);
+
+ // never delete; start with RefCount 1, not 0
+ pDefault->mnRefCount++;
+ }
+
+ return pDefault;
+ }
+ };
+
+ SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute(
+ const LineAttribute& rLineAttribute,
+ const StrokeAttribute& rStrokeAttribute,
+ sal_uInt8 nTransparence)
+ : mpSdrFormTextOutlineAttribute(new ImpSdrFormTextOutlineAttribute(
+ rLineAttribute, rStrokeAttribute, nTransparence))
+ {
+ }
+
+ SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute()
+ : mpSdrFormTextOutlineAttribute(ImpSdrFormTextOutlineAttribute::get_global_default())
+ {
+ mpSdrFormTextOutlineAttribute->mnRefCount++;
+ }
+
+ SdrFormTextOutlineAttribute::SdrFormTextOutlineAttribute(const SdrFormTextOutlineAttribute& rCandidate)
+ : mpSdrFormTextOutlineAttribute(rCandidate.mpSdrFormTextOutlineAttribute)
+ {
+ mpSdrFormTextOutlineAttribute->mnRefCount++;
+ }
+
+ SdrFormTextOutlineAttribute::~SdrFormTextOutlineAttribute()
+ {
+ if(mpSdrFormTextOutlineAttribute->mnRefCount)
+ {
+ mpSdrFormTextOutlineAttribute->mnRefCount--;
+ }
+ else
+ {
+ delete mpSdrFormTextOutlineAttribute;
+ }
+ }
+
+ bool SdrFormTextOutlineAttribute::isDefault() const
+ {
+ return mpSdrFormTextOutlineAttribute == ImpSdrFormTextOutlineAttribute::get_global_default();
+ }
+
+ SdrFormTextOutlineAttribute& SdrFormTextOutlineAttribute::operator=(const SdrFormTextOutlineAttribute& rCandidate)
+ {
+ if(rCandidate.mpSdrFormTextOutlineAttribute != mpSdrFormTextOutlineAttribute)
+ {
+ if(mpSdrFormTextOutlineAttribute->mnRefCount)
+ {
+ mpSdrFormTextOutlineAttribute->mnRefCount--;
+ }
+ else
+ {
+ delete mpSdrFormTextOutlineAttribute;
+ }
+
+ mpSdrFormTextOutlineAttribute = rCandidate.mpSdrFormTextOutlineAttribute;
+ mpSdrFormTextOutlineAttribute->mnRefCount++;
+ }
+
+ return *this;
+ }
+
+ bool SdrFormTextOutlineAttribute::operator==(const SdrFormTextOutlineAttribute& rCandidate) const
+ {
+ if(rCandidate.mpSdrFormTextOutlineAttribute == mpSdrFormTextOutlineAttribute)
+ {
+ return true;
+ }
+
+ if(rCandidate.isDefault() != isDefault())
+ {
+ return false;
+ }
+
+ return (*rCandidate.mpSdrFormTextOutlineAttribute == *mpSdrFormTextOutlineAttribute);
+ }
+
+ const LineAttribute& SdrFormTextOutlineAttribute::getLineAttribute() const
+ {
+ return mpSdrFormTextOutlineAttribute->getLineAttribute();
+ }
+
+ const StrokeAttribute& SdrFormTextOutlineAttribute::getStrokeAttribute() const
+ {
+ return mpSdrFormTextOutlineAttribute->getStrokeAttribute();
+ }
+
+ sal_uInt8 SdrFormTextOutlineAttribute::getTransparence() const
+ {
+ return mpSdrFormTextOutlineAttribute->getTransparence();
+ }
+ } // end of namespace attribute
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/attribute/sdrlinefillshadowtextattribute.cxx b/svx/source/sdr/attribute/sdrlinefillshadowtextattribute.cxx
new file mode 100644
index 000000000000..4eddb7c9d3a5
--- /dev/null
+++ b/svx/source/sdr/attribute/sdrlinefillshadowtextattribute.cxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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: sdrallattribute.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include <svx/sdr/attribute/sdrlinefillshadowtextattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace attribute
+ {
+ SdrLineFillShadowTextAttribute::SdrLineFillShadowTextAttribute(
+ const SdrLineAttribute& rLine,
+ const SdrFillAttribute& rFill,
+ const SdrLineStartEndAttribute& rLineStartEnd,
+ const SdrShadowAttribute& rShadow,
+ const FillGradientAttribute& rFillFloatTransGradient,
+ const SdrTextAttribute& rTextAttribute)
+ : SdrLineShadowTextAttribute(rLine, rLineStartEnd, rShadow, rTextAttribute),
+ maFill(rFill),
+ maFillFloatTransGradient(rFillFloatTransGradient)
+ {
+ }
+
+ SdrLineFillShadowTextAttribute::SdrLineFillShadowTextAttribute()
+ : SdrLineShadowTextAttribute(),
+ maFill(),
+ maFillFloatTransGradient()
+ {
+ }
+
+ SdrLineFillShadowTextAttribute::SdrLineFillShadowTextAttribute(const SdrLineFillShadowTextAttribute& rCandidate)
+ : SdrLineShadowTextAttribute(rCandidate),
+ maFill(rCandidate.getFill()),
+ maFillFloatTransGradient(rCandidate.getFillFloatTransGradient())
+ {
+ }
+
+ SdrLineFillShadowTextAttribute& SdrLineFillShadowTextAttribute::operator=(const SdrLineFillShadowTextAttribute& rCandidate)
+ {
+ SdrLineShadowTextAttribute::operator=(rCandidate);
+ maFill = rCandidate.getFill();
+ maFillFloatTransGradient = rCandidate.getFillFloatTransGradient();
+
+ return *this;
+ }
+
+ bool SdrLineFillShadowTextAttribute::isDefault() const
+ {
+ return (SdrLineShadowTextAttribute::isDefault()
+ && getFill().isDefault()
+ && getFillFloatTransGradient().isDefault());
+ }
+
+ bool SdrLineFillShadowTextAttribute::operator==(const SdrLineFillShadowTextAttribute& rCandidate) const
+ {
+ return(SdrLineShadowTextAttribute::operator==(rCandidate)
+ && getFill() == rCandidate.getFill()
+ && getFillFloatTransGradient() == rCandidate.getFillFloatTransGradient());
+ }
+ } // end of namespace attribute
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/attribute/sdrlineshadowtextattribute.cxx b/svx/source/sdr/attribute/sdrlineshadowtextattribute.cxx
new file mode 100644
index 000000000000..b3bf9273282a
--- /dev/null
+++ b/svx/source/sdr/attribute/sdrlineshadowtextattribute.cxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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: sdrallattribute.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include <svx/sdr/attribute/sdrlineshadowtextattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace attribute
+ {
+ SdrLineShadowTextAttribute::SdrLineShadowTextAttribute(
+ const SdrLineAttribute& rLine,
+ const SdrLineStartEndAttribute& rLineStartEnd,
+ const SdrShadowAttribute& rShadow,
+ const SdrTextAttribute& rTextAttribute)
+ : SdrShadowTextAttribute(rShadow, rTextAttribute),
+ maLine(rLine),
+ maLineStartEnd(rLineStartEnd)
+ {
+ }
+
+ SdrLineShadowTextAttribute::SdrLineShadowTextAttribute()
+ : SdrShadowTextAttribute(),
+ maLine(),
+ maLineStartEnd()
+ {
+ }
+
+ SdrLineShadowTextAttribute::SdrLineShadowTextAttribute(const SdrLineShadowTextAttribute& rCandidate)
+ : SdrShadowTextAttribute(rCandidate),
+ maLine(rCandidate.getLine()),
+ maLineStartEnd(rCandidate.getLineStartEnd())
+ {
+ }
+
+ SdrLineShadowTextAttribute& SdrLineShadowTextAttribute::operator=(const SdrLineShadowTextAttribute& rCandidate)
+ {
+ SdrShadowTextAttribute::operator=(rCandidate);
+ maLine = rCandidate.getLine();
+ maLineStartEnd = rCandidate.getLineStartEnd();
+
+ return *this;
+ }
+
+ bool SdrLineShadowTextAttribute::isDefault() const
+ {
+ return(SdrShadowTextAttribute::isDefault()
+ && getLine().isDefault()
+ && getLineStartEnd().isDefault());
+ }
+
+ bool SdrLineShadowTextAttribute::operator==(const SdrLineShadowTextAttribute& rCandidate) const
+ {
+ return(SdrShadowTextAttribute::operator==(rCandidate)
+ && getLine() == rCandidate.getLine()
+ && getLineStartEnd() == rCandidate.getLineStartEnd());
+ }
+ } // end of namespace attribute
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/attribute/sdrshadowtextattribute.cxx b/svx/source/sdr/attribute/sdrshadowtextattribute.cxx
new file mode 100644
index 000000000000..f6eacc606404
--- /dev/null
+++ b/svx/source/sdr/attribute/sdrshadowtextattribute.cxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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: sdrallattribute.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include <svx/sdr/attribute/sdrshadowtextattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace attribute
+ {
+ SdrShadowTextAttribute::SdrShadowTextAttribute(
+ const SdrShadowAttribute& rShadow,
+ const SdrTextAttribute& rTextAttribute)
+ : maShadow(rShadow),
+ maTextAttribute(rTextAttribute)
+ {
+ }
+
+ SdrShadowTextAttribute::SdrShadowTextAttribute()
+ : maShadow(),
+ maTextAttribute()
+ {
+ }
+
+ SdrShadowTextAttribute::SdrShadowTextAttribute(const SdrShadowTextAttribute& rCandidate)
+ : maShadow(rCandidate.getShadow()),
+ maTextAttribute(rCandidate.getText())
+ {
+ }
+
+ SdrShadowTextAttribute& SdrShadowTextAttribute::operator=(const SdrShadowTextAttribute& rCandidate)
+ {
+ maShadow = rCandidate.getShadow();
+ maTextAttribute = rCandidate.getText();
+
+ return *this;
+ }
+
+ bool SdrShadowTextAttribute::isDefault() const
+ {
+ return (getShadow().isDefault()
+ && getText().isDefault());
+ }
+
+ bool SdrShadowTextAttribute::operator==(const SdrShadowTextAttribute& rCandidate) const
+ {
+ return (getShadow() == rCandidate.getShadow()
+ && getText() == rCandidate.getText());
+ }
+ } // end of namespace attribute
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/attribute/sdrtextattribute.cxx b/svx/source/sdr/attribute/sdrtextattribute.cxx
new file mode 100644
index 000000000000..e03fe0436685
--- /dev/null
+++ b/svx/source/sdr/attribute/sdrtextattribute.cxx
@@ -0,0 +1,476 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include <svx/sdr/attribute/sdrtextattribute.hxx>
+#include <svx/sdr/attribute/sdrformtextattribute.hxx>
+#include <svx/svdotext.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/sdr/properties/properties.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace attribute
+ {
+ class ImpSdrTextAttribute
+ {
+ public:
+ // refcounter
+ sal_uInt32 mnRefCount;
+
+ // all-text attributes. The SdrText itself and a copy
+ // of te OPO
+ const SdrText* mpSdrText;
+ const OutlinerParaObject* mpOutlinerParaObject;
+
+ // Set when it's a FormText; contains all FormText attributes
+ SdrFormTextAttribute maSdrFormTextAttribute;
+
+ // text distances
+ sal_Int32 maTextLeftDistance;
+ sal_Int32 maTextUpperDistance;
+ sal_Int32 maTextRightDistance;
+ sal_Int32 maTextLowerDistance;
+
+ // #i101556# use versioning from text attributes to detect changes
+ sal_uInt32 maPropertiesVersion;
+
+ // text alignments
+ SdrTextHorzAdjust maSdrTextHorzAdjust;
+ SdrTextVertAdjust maSdrTextVertAdjust;
+
+ // bitfield
+ unsigned mbContour : 1;
+ unsigned mbFitToSize : 1;
+ unsigned mbAutoFit : 1;
+ unsigned mbHideContour : 1;
+ unsigned mbBlink : 1;
+ unsigned mbScroll : 1;
+ unsigned mbInEditMode : 1;
+ unsigned mbFixedCellHeight : 1;
+ unsigned mbWrongSpell : 1;
+
+ public:
+ ImpSdrTextAttribute(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject,
+ XFormTextStyle eFormTextStyle,
+ sal_Int32 aTextLeftDistance,
+ sal_Int32 aTextUpperDistance,
+ sal_Int32 aTextRightDistance,
+ sal_Int32 aTextLowerDistance,
+ SdrTextHorzAdjust aSdrTextHorzAdjust,
+ SdrTextVertAdjust aSdrTextVertAdjust,
+ bool bContour,
+ bool bFitToSize,
+ bool bAutoFit,
+ bool bHideContour,
+ bool bBlink,
+ bool bScroll,
+ bool bInEditMode,
+ bool bFixedCellHeight,
+ bool bWrongSpell)
+ : mnRefCount(0),
+ mpSdrText(pSdrText),
+ mpOutlinerParaObject(new OutlinerParaObject(rOutlinerParaObject)),
+ maSdrFormTextAttribute(),
+ maTextLeftDistance(aTextLeftDistance),
+ maTextUpperDistance(aTextUpperDistance),
+ maTextRightDistance(aTextRightDistance),
+ maTextLowerDistance(aTextLowerDistance),
+ maPropertiesVersion(0),
+ maSdrTextHorzAdjust(aSdrTextHorzAdjust),
+ maSdrTextVertAdjust(aSdrTextVertAdjust),
+ mbContour(bContour),
+ mbFitToSize(bFitToSize),
+ mbAutoFit(bAutoFit),
+ mbHideContour(bHideContour),
+ mbBlink(bBlink),
+ mbScroll(bScroll),
+ mbInEditMode(bInEditMode),
+ mbFixedCellHeight(bFixedCellHeight),
+ mbWrongSpell(bWrongSpell)
+ {
+ if(pSdrText)
+ {
+ if(XFT_NONE != eFormTextStyle)
+ {
+ // text on path. Create FormText attribute
+ const SfxItemSet& rSet = pSdrText->GetItemSet();
+ maSdrFormTextAttribute = SdrFormTextAttribute(rSet);
+ }
+
+ // #i101556# init with version number to detect changes of single text
+ // attribute and/or style sheets in primitive data without having to
+ // copy that data locally (which would be better from principle)
+ maPropertiesVersion = pSdrText->GetObject().GetProperties().getVersion();
+ }
+ }
+
+ ImpSdrTextAttribute()
+ : mnRefCount(0),
+ mpSdrText(0),
+ mpOutlinerParaObject(0),
+ maSdrFormTextAttribute(),
+ maTextLeftDistance(0),
+ maTextUpperDistance(0),
+ maTextRightDistance(0),
+ maTextLowerDistance(0),
+ maPropertiesVersion(0),
+ maSdrTextHorzAdjust(SDRTEXTHORZADJUST_LEFT),
+ maSdrTextVertAdjust(SDRTEXTVERTADJUST_TOP),
+ mbContour(false),
+ mbFitToSize(false),
+ mbAutoFit(false),
+ mbHideContour(false),
+ mbBlink(false),
+ mbScroll(false),
+ mbInEditMode(false),
+ mbFixedCellHeight(false),
+ mbWrongSpell(false)
+ {
+ }
+
+ ~ImpSdrTextAttribute()
+ {
+ if(mpOutlinerParaObject)
+ {
+ delete mpOutlinerParaObject;
+ }
+ }
+
+ // data read access
+ const SdrText& getSdrText() const
+ {
+ OSL_ENSURE(mpSdrText, "Access to text of default version of ImpSdrTextAttribute (!)");
+ return *mpSdrText;
+ }
+ const OutlinerParaObject& getOutlinerParaObject() const
+ {
+ OSL_ENSURE(mpOutlinerParaObject, "Access to OutlinerParaObject of default version of ImpSdrTextAttribute (!)");
+ return *mpOutlinerParaObject;
+ }
+ bool isContour() const { return mbContour; }
+ bool isFitToSize() const { return mbFitToSize; }
+ bool isAutoFit() const { return mbAutoFit; }
+ bool isHideContour() const { return mbHideContour; }
+ bool isBlink() const { return mbBlink; }
+ bool isScroll() const { return mbScroll; }
+ bool isInEditMode() const { return mbInEditMode; }
+ bool isFixedCellHeight() const { return mbFixedCellHeight; }
+ bool isWrongSpell() const { return mbWrongSpell; }
+ const SdrFormTextAttribute& getSdrFormTextAttribute() const { return maSdrFormTextAttribute; }
+ sal_Int32 getTextLeftDistance() const { return maTextLeftDistance; }
+ sal_Int32 getTextUpperDistance() const { return maTextUpperDistance; }
+ sal_Int32 getTextRightDistance() const { return maTextRightDistance; }
+ sal_Int32 getTextLowerDistance() const { return maTextLowerDistance; }
+ sal_uInt32 getPropertiesVersion() const { return maPropertiesVersion; }
+ SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; }
+ SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; }
+
+ // compare operator
+ bool operator==(const ImpSdrTextAttribute& rCandidate) const
+ {
+ if(mpOutlinerParaObject != rCandidate.mpOutlinerParaObject)
+ {
+ if(mpOutlinerParaObject && rCandidate.mpOutlinerParaObject)
+ {
+ // compares OPO and it's contents, but traditionally not the RedLining
+ // which is not seen as model, but as temporary information
+ if(!(getOutlinerParaObject() == rCandidate.getOutlinerParaObject()))
+ {
+ return false;
+ }
+
+ // #i102062# for primitive visualisation, the WrongList (SpellChecking)
+ // is important, too, so use isWrongListEqual since there is no WrongList
+ // comparison in the regular OutlinerParaObject compare (since it's
+ // not-persistent data)
+ if(!(getOutlinerParaObject().isWrongListEqual(rCandidate.getOutlinerParaObject())))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ // only one is zero; not equal
+ return false;
+ }
+ }
+
+ return (
+ getSdrFormTextAttribute() == rCandidate.getSdrFormTextAttribute()
+ && getTextLeftDistance() == rCandidate.getTextLeftDistance()
+ && getTextUpperDistance() == rCandidate.getTextUpperDistance()
+ && getTextRightDistance() == rCandidate.getTextRightDistance()
+ && getTextLowerDistance() == rCandidate.getTextLowerDistance()
+ && getPropertiesVersion() == rCandidate.getPropertiesVersion()
+
+ && getSdrTextHorzAdjust() == rCandidate.getSdrTextHorzAdjust()
+ && getSdrTextVertAdjust() == rCandidate.getSdrTextVertAdjust()
+
+ && isContour() == rCandidate.isContour()
+ && isFitToSize() == rCandidate.isFitToSize()
+ && isAutoFit() == rCandidate.isAutoFit()
+ && isHideContour() == rCandidate.isHideContour()
+ && isBlink() == rCandidate.isBlink()
+ && isScroll() == rCandidate.isScroll()
+ && isInEditMode() == rCandidate.isInEditMode()
+ && isFixedCellHeight() == rCandidate.isFixedCellHeight()
+ && isWrongSpell() == rCandidate.isWrongSpell());
+ }
+
+ static ImpSdrTextAttribute* get_global_default()
+ {
+ static ImpSdrTextAttribute* pDefault = 0;
+
+ if(!pDefault)
+ {
+ // use default constructor
+ pDefault = new ImpSdrTextAttribute();
+
+ // never delete; start with RefCount 1, not 0
+ pDefault->mnRefCount++;
+ }
+
+ return pDefault;
+ }
+ };
+
+ SdrTextAttribute::SdrTextAttribute(
+ const SdrText& rSdrText,
+ const OutlinerParaObject& rOutlinerParaObject,
+ XFormTextStyle eFormTextStyle,
+ sal_Int32 aTextLeftDistance,
+ sal_Int32 aTextUpperDistance,
+ sal_Int32 aTextRightDistance,
+ sal_Int32 aTextLowerDistance,
+ SdrTextHorzAdjust aSdrTextHorzAdjust,
+ SdrTextVertAdjust aSdrTextVertAdjust,
+ bool bContour,
+ bool bFitToSize,
+ bool bAutoFit,
+ bool bHideContour,
+ bool bBlink,
+ bool bScroll,
+ bool bInEditMode,
+ bool bFixedCellHeight,
+ bool bWrongSpell)
+ : mpSdrTextAttribute(new ImpSdrTextAttribute(
+ &rSdrText, rOutlinerParaObject, eFormTextStyle, aTextLeftDistance, aTextUpperDistance,
+ aTextRightDistance, aTextLowerDistance, aSdrTextHorzAdjust, aSdrTextVertAdjust, bContour,
+ bFitToSize, bAutoFit, bHideContour, bBlink, bScroll, bInEditMode, bFixedCellHeight, bWrongSpell))
+ {
+ }
+
+ SdrTextAttribute::SdrTextAttribute()
+ : mpSdrTextAttribute(ImpSdrTextAttribute::get_global_default())
+ {
+ mpSdrTextAttribute->mnRefCount++;
+ }
+
+ SdrTextAttribute::SdrTextAttribute(const SdrTextAttribute& rCandidate)
+ : mpSdrTextAttribute(rCandidate.mpSdrTextAttribute)
+ {
+ mpSdrTextAttribute->mnRefCount++;
+ }
+
+ SdrTextAttribute::~SdrTextAttribute()
+ {
+ if(mpSdrTextAttribute->mnRefCount)
+ {
+ mpSdrTextAttribute->mnRefCount--;
+ }
+ else
+ {
+ delete mpSdrTextAttribute;
+ }
+ }
+
+ bool SdrTextAttribute::isDefault() const
+ {
+ return mpSdrTextAttribute == ImpSdrTextAttribute::get_global_default();
+ }
+
+ SdrTextAttribute& SdrTextAttribute::operator=(const SdrTextAttribute& rCandidate)
+ {
+ if(rCandidate.mpSdrTextAttribute != mpSdrTextAttribute)
+ {
+ if(mpSdrTextAttribute->mnRefCount)
+ {
+ mpSdrTextAttribute->mnRefCount--;
+ }
+ else
+ {
+ delete mpSdrTextAttribute;
+ }
+
+ mpSdrTextAttribute = rCandidate.mpSdrTextAttribute;
+ mpSdrTextAttribute->mnRefCount++;
+ }
+
+ return *this;
+ }
+
+ bool SdrTextAttribute::operator==(const SdrTextAttribute& rCandidate) const
+ {
+ if(rCandidate.mpSdrTextAttribute == mpSdrTextAttribute)
+ {
+ return true;
+ }
+
+ if(rCandidate.isDefault() != isDefault())
+ {
+ return false;
+ }
+
+ return (*rCandidate.mpSdrTextAttribute == *mpSdrTextAttribute);
+ }
+
+ const SdrText& SdrTextAttribute::getSdrText() const
+ {
+ return mpSdrTextAttribute->getSdrText();
+ }
+
+ const OutlinerParaObject& SdrTextAttribute::getOutlinerParaObject() const
+ {
+ return mpSdrTextAttribute->getOutlinerParaObject();
+ }
+
+ bool SdrTextAttribute::isContour() const
+ {
+ return mpSdrTextAttribute->isContour();
+ }
+
+ bool SdrTextAttribute::isFitToSize() const
+ {
+ return mpSdrTextAttribute->isFitToSize();
+ }
+
+ bool SdrTextAttribute::isAutoFit() const
+ {
+ return mpSdrTextAttribute->isAutoFit();
+ }
+
+ bool SdrTextAttribute::isHideContour() const
+ {
+ return mpSdrTextAttribute->isHideContour();
+ }
+
+ bool SdrTextAttribute::isBlink() const
+ {
+ return mpSdrTextAttribute->isBlink();
+ }
+
+ bool SdrTextAttribute::isScroll() const
+ {
+ return mpSdrTextAttribute->isScroll();
+ }
+
+ bool SdrTextAttribute::isInEditMode() const
+ {
+ return mpSdrTextAttribute->isInEditMode();
+ }
+
+ bool SdrTextAttribute::isFixedCellHeight() const
+ {
+ return mpSdrTextAttribute->isFixedCellHeight();
+ }
+
+ bool SdrTextAttribute::isWrongSpell() const
+ {
+ return mpSdrTextAttribute->isWrongSpell();
+ }
+
+ const SdrFormTextAttribute& SdrTextAttribute::getSdrFormTextAttribute() const
+ {
+ return mpSdrTextAttribute->getSdrFormTextAttribute();
+ }
+
+ sal_Int32 SdrTextAttribute::getTextLeftDistance() const
+ {
+ return mpSdrTextAttribute->getTextLeftDistance();
+ }
+
+ sal_Int32 SdrTextAttribute::getTextUpperDistance() const
+ {
+ return mpSdrTextAttribute->getTextUpperDistance();
+ }
+
+ sal_Int32 SdrTextAttribute::getTextRightDistance() const
+ {
+ return mpSdrTextAttribute->getTextRightDistance();
+ }
+
+ sal_Int32 SdrTextAttribute::getTextLowerDistance() const
+ {
+ return mpSdrTextAttribute->getTextLowerDistance();
+ }
+
+ sal_uInt32 SdrTextAttribute::getPropertiesVersion() const
+ {
+ return mpSdrTextAttribute->getPropertiesVersion();
+ }
+
+ SdrTextHorzAdjust SdrTextAttribute::getSdrTextHorzAdjust() const
+ {
+ return mpSdrTextAttribute->getSdrTextHorzAdjust();
+ }
+
+ SdrTextVertAdjust SdrTextAttribute::getSdrTextVertAdjust() const
+ {
+ return mpSdrTextAttribute->getSdrTextVertAdjust();
+ }
+
+ void SdrTextAttribute::getBlinkTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList) const
+ {
+ if(isBlink())
+ {
+ getSdrText().GetObject().impGetBlinkTextTiming(rAnimList);
+ }
+ }
+
+ void SdrTextAttribute::getScrollTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList, double fFrameLength, double fTextLength) const
+ {
+ if(isScroll())
+ {
+ getSdrText().GetObject().impGetScrollTextTiming(rAnimList, fFrameLength, fTextLength);
+ }
+ }
+ } // end of namespace attribute
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/displayinfo.cxx b/svx/source/sdr/contact/displayinfo.cxx
new file mode 100644
index 000000000000..7853da15d939
--- /dev/null
+++ b/svx/source/sdr/contact/displayinfo.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/svdobj.hxx>
+#include <vcl/gdimtf.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+
+#define ALL_GHOSTED_DRAWMODES (DRAWMODE_GHOSTEDLINE|DRAWMODE_GHOSTEDFILL|DRAWMODE_GHOSTEDTEXT|DRAWMODE_GHOSTEDBITMAP|DRAWMODE_GHOSTEDGRADIENT)
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ DisplayInfo::DisplayInfo()
+ : maProcessLayers(true), // init layer info with all bits set to draw everything on default
+ maRedrawArea(),
+ mbControlLayerProcessingActive(false),
+ mbPageProcessingActive(true),
+ mbGhostedDrawModeActive(false),
+ mbSubContentActive(false)
+ {
+ }
+
+ DisplayInfo::~DisplayInfo()
+ {
+ }
+
+ // Access to LayerInfos (which layers to proccess)
+ void DisplayInfo::SetProcessLayers(const SetOfByte& rSet)
+ {
+ maProcessLayers = rSet;
+ }
+
+ // access to RedrawArea
+ void DisplayInfo::SetRedrawArea(const Region& rRegion)
+ {
+ maRedrawArea = rRegion;
+ }
+
+ void DisplayInfo::SetControlLayerProcessingActive(bool bDoProcess)
+ {
+ if((bool)mbControlLayerProcessingActive != bDoProcess)
+ {
+ mbControlLayerProcessingActive = bDoProcess;
+ }
+ }
+
+ void DisplayInfo::SetPageProcessingActive(bool bDoProcess)
+ {
+ if((bool)mbPageProcessingActive != bDoProcess)
+ {
+ mbPageProcessingActive = bDoProcess;
+ }
+ }
+
+ void DisplayInfo::ClearGhostedDrawMode()
+ {
+ mbGhostedDrawModeActive = false;
+ }
+
+ void DisplayInfo::SetGhostedDrawMode()
+ {
+ mbGhostedDrawModeActive = true;
+ }
+
+ void DisplayInfo::SetSubContentActive(bool bNew)
+ {
+ if((bool)mbSubContentActive != bNew)
+ {
+ mbSubContentActive = bNew;
+ }
+ }
+
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/makefile.mk b/svx/source/sdr/contact/makefile.mk
new file mode 100644
index 000000000000..9e4356c4aa52
--- /dev/null
+++ b/svx/source/sdr/contact/makefile.mk
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+
+PRJNAME=svx
+TARGET=contact
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES=\
+ $(SLO)$/viewobjectcontactofunocontrol.obj
+
+SLOFILES=\
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/displayinfo.obj \
+ $(SLO)$/viewcontact.obj \
+ $(SLO)$/viewcontactofe3d.obj \
+ $(SLO)$/viewcontactofsdrobj.obj \
+ $(SLO)$/viewcontactofvirtobj.obj \
+ $(SLO)$/viewcontactoftextobj.obj \
+ $(SLO)$/viewcontactofsdrrectobj.obj \
+ $(SLO)$/viewcontactofsdrpathobj.obj \
+ $(SLO)$/viewcontactofsdrole2obj.obj \
+ $(SLO)$/viewcontactofsdrcircobj.obj \
+ $(SLO)$/viewcontactofsdrcaptionobj.obj \
+ $(SLO)$/viewcontactofsdrmeasureobj.obj \
+ $(SLO)$/viewcontactofsdredgeobj.obj \
+ $(SLO)$/viewcontactofsdrpage.obj \
+ $(SLO)$/viewcontactofmasterpagedescriptor.obj \
+ $(SLO)$/viewcontactofgroup.obj \
+ $(SLO)$/viewcontactofe3dscene.obj \
+ $(SLO)$/viewcontactofe3dcube.obj \
+ $(SLO)$/viewcontactofe3dextrude.obj \
+ $(SLO)$/viewcontactofe3dlathe.obj \
+ $(SLO)$/viewcontactofe3dsphere.obj \
+ $(SLO)$/viewcontactofe3dpolygon.obj \
+ $(SLO)$/viewcontactofpageobj.obj \
+ $(SLO)$/viewcontactofgraphic.obj \
+ $(SLO)$/viewcontactofsdrobjcustomshape.obj \
+ $(SLO)$/viewcontactofsdrmediaobj.obj \
+ $(SLO)$/viewcontactofunocontrol.obj \
+ $(SLO)$/objectcontact.obj \
+ $(SLO)$/objectcontacttools.obj \
+ $(SLO)$/objectcontactofobjlistpainter.obj \
+ $(SLO)$/objectcontactofpageview.obj \
+ $(SLO)$/viewobjectcontact.obj \
+ $(SLO)$/viewobjectcontactofe3d.obj \
+ $(SLO)$/viewobjectcontactredirector.obj \
+ $(SLO)$/viewobjectcontactofsdrmediaobj.obj \
+ $(SLO)$/viewobjectcontactofgroup.obj \
+ $(SLO)$/viewobjectcontactofe3dscene.obj \
+ $(SLO)$/viewobjectcontactofsdrpage.obj \
+ $(SLO)$/viewobjectcontactofsdrobj.obj \
+ $(SLO)$/viewobjectcontactofpageobj.obj \
+ $(SLO)$/viewobjectcontactofsdrole2obj.obj \
+ $(SLO)$/viewobjectcontactofgraphic.obj \
+ $(SLO)$/viewobjectcontactofmasterpagedescriptor.obj \
+ $(SLO)$/sdrmediawindow.obj
+
+.INCLUDE : target.mk
diff --git a/svx/source/sdr/contact/objectcontact.cxx b/svx/source/sdr/contact/objectcontact.cxx
new file mode 100644
index 000000000000..3e30021c3bde
--- /dev/null
+++ b/svx/source/sdr/contact/objectcontact.cxx
@@ -0,0 +1,325 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <tools/debug.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/sdr/event/eventhandler.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/animation/objectanimator.hxx>
+#include <svx/sdr/event/eventhandler.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ObjectContact::ObjectContact()
+ : maViewObjectContactVector(),
+ maPrimitiveAnimator(),
+ mpEventHandler(0),
+ mpViewObjectContactRedirector(0),
+ maViewInformation2D(uno::Sequence< beans::PropertyValue >()),
+ mbIsPreviewRenderer(false)
+ {
+ }
+
+ ObjectContact::~ObjectContact()
+ {
+ // get rid of all registered contacts
+ // #i84257# To avoid that each 'delete pCandidate' again uses
+ // the local RemoveViewObjectContact with a search and removal in the
+ // vector, simply copy and clear local vector.
+ std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector);
+ maViewObjectContactVector.clear();
+
+ while(aLocalVOCList.size())
+ {
+ ViewObjectContact* pCandidate = aLocalVOCList.back();
+ aLocalVOCList.pop_back();
+ DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList (!)");
+
+ // ViewObjectContacts only make sense with View and Object contacts.
+ // When the contact to the SdrObject is deleted like in this case,
+ // all ViewObjectContacts can be deleted, too.
+ delete pCandidate;
+ }
+
+ // assert when there were new entries added during deletion
+ DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList (!)");
+
+ // delete the EventHandler. This will destroy all still contained events.
+ DeleteEventHandler();
+ }
+
+ // LazyInvalidate request. Default implementation directly handles
+ // this by calling back triggerLazyInvalidate() at the VOC
+ void ObjectContact::setLazyInvalidate(ViewObjectContact& rVOC)
+ {
+ rVOC.triggerLazyInvalidate();
+ }
+
+ // call this to support evtl. preparations for repaint. Default does nothing
+ void ObjectContact::PrepareProcessDisplay()
+ {
+ }
+
+ // A new ViewObjectContact was created and shall be remembered.
+ void ObjectContact::AddViewObjectContact(ViewObjectContact& rVOContact)
+ {
+ maViewObjectContactVector.push_back(&rVOContact);
+ }
+
+ // A ViewObjectContact was deleted and shall be forgotten.
+ void ObjectContact::RemoveViewObjectContact(ViewObjectContact& rVOContact)
+ {
+ std::vector< ViewObjectContact* >::iterator aFindResult = std::find(maViewObjectContactVector.begin(), maViewObjectContactVector.end(), &rVOContact);
+
+ if(aFindResult != maViewObjectContactVector.end())
+ {
+ maViewObjectContactVector.erase(aFindResult);
+ }
+ }
+
+ // Process the whole displaying
+ void ObjectContact::ProcessDisplay(DisplayInfo& /*rDisplayInfo*/)
+ {
+ // default does nothing
+ }
+
+ // test if visualizing of entered groups is switched on at all
+ bool ObjectContact::DoVisualizeEnteredGroup() const
+ {
+ // Don not do that as default
+ return false;
+ }
+
+ // get active group's (the entered group) ViewContact
+ const ViewContact* ObjectContact::getActiveViewContact() const
+ {
+ // default has no active VC
+ return 0;
+ }
+
+ // Invalidate given rectangle at the window/output which is represented by
+ // this ObjectContact.
+ void ObjectContact::InvalidatePartOfView(const basegfx::B2DRange& /*rRange*/) const
+ {
+ // nothing to do here in the default version
+ }
+
+ // Get info if given Rectangle is visible in this view
+ bool ObjectContact::IsAreaVisible(const basegfx::B2DRange& /*rRange*/) const
+ {
+ // always visible in default version
+ return true;
+ }
+
+ // Get info about the need to visualize GluePoints
+ bool ObjectContact::AreGluePointsVisible() const
+ {
+ return false;
+ }
+
+ // method to create a EventHandler. Needs to give a result.
+ sdr::event::TimerEventHandler* ObjectContact::CreateEventHandler()
+ {
+ // Create and return a new EventHandler
+ return new sdr::event::TimerEventHandler();
+ }
+
+ // method to get the primitiveAnimator
+ sdr::animation::primitiveAnimator& ObjectContact::getPrimitiveAnimator()
+ {
+ return maPrimitiveAnimator;
+ }
+
+ // method to get the EventHandler. It will
+ // return a existing one or create a new one using CreateEventHandler().
+ sdr::event::TimerEventHandler& ObjectContact::GetEventHandler() const
+ {
+ if(!HasEventHandler())
+ {
+ const_cast< ObjectContact* >(this)->mpEventHandler = const_cast< ObjectContact* >(this)->CreateEventHandler();
+ DBG_ASSERT(mpEventHandler, "ObjectContact::GetEventHandler(): Got no EventHandler (!)");
+ }
+
+ return *mpEventHandler;
+ }
+
+ // delete the EventHandler
+ void ObjectContact::DeleteEventHandler()
+ {
+ if(mpEventHandler)
+ {
+ // If there are still Events registered, something has went wrong
+ delete mpEventHandler;
+ mpEventHandler = 0L;
+ }
+ }
+
+ // test if there is an EventHandler without creating one on demand
+ bool ObjectContact::HasEventHandler() const
+ {
+ return (0L != mpEventHandler);
+ }
+
+ // check if text animation is allowed. Default is sal_true.
+ bool ObjectContact::IsTextAnimationAllowed() const
+ {
+ return true;
+ }
+
+ // check if graphic animation is allowed. Default is sal_true.
+ bool ObjectContact::IsGraphicAnimationAllowed() const
+ {
+ return true;
+ }
+
+ // check if asynchronious graphis loading is allowed. Default is false.
+ bool ObjectContact::IsAsynchronGraphicsLoadingAllowed() const
+ {
+ return false;
+ }
+
+ // access to ViewObjectContactRedirector
+ ViewObjectContactRedirector* ObjectContact::GetViewObjectContactRedirector() const
+ {
+ return mpViewObjectContactRedirector;
+ }
+
+ void ObjectContact::SetViewObjectContactRedirector(ViewObjectContactRedirector* pNew)
+ {
+ if(mpViewObjectContactRedirector != pNew)
+ {
+ mpViewObjectContactRedirector = pNew;
+ }
+ }
+
+ // check if buffering of MasterPages is allowed. Default is false.
+ bool ObjectContact::IsMasterPageBufferingAllowed() const
+ {
+ return false;
+ }
+
+ // print? Default is false
+ bool ObjectContact::isOutputToPrinter() const
+ {
+ return false;
+ }
+
+ // window? Default is true
+ bool ObjectContact::isOutputToWindow() const
+ {
+ return true;
+ }
+
+ // VirtualDevice? Default is false
+ bool ObjectContact::isOutputToVirtualDevice() const
+ {
+ return false;
+ }
+
+ // recording MetaFile? Default is false
+ bool ObjectContact::isOutputToRecordingMetaFile() const
+ {
+ return false;
+ }
+
+ // pdf export? Default is false
+ bool ObjectContact::isOutputToPDFFile() const
+ {
+ return false;
+ }
+
+ // gray display mode
+ bool ObjectContact::isDrawModeGray() const
+ {
+ return false;
+ }
+
+ // gray display mode
+ bool ObjectContact::isDrawModeBlackWhite() const
+ {
+ return false;
+ }
+
+ // high contrast display mode
+ bool ObjectContact::isDrawModeHighContrast() const
+ {
+ return false;
+ }
+
+ // access to SdrPageView. Default implementation returns NULL
+ SdrPageView* ObjectContact::TryToGetSdrPageView() const
+ {
+ return 0;
+ }
+
+ // access to OutputDevice. Default implementation returns NULL
+ OutputDevice* ObjectContact::TryToGetOutputDevice() const
+ {
+ return 0;
+ }
+
+ void ObjectContact::resetViewPort()
+ {
+ const drawinglayer::geometry::ViewInformation2D& rCurrentVI2D = getViewInformation2D();
+
+ if(!rCurrentVI2D.getViewport().isEmpty())
+ {
+ const basegfx::B2DRange aEmptyRange;
+
+ drawinglayer::geometry::ViewInformation2D aNewVI2D(
+ rCurrentVI2D.getObjectTransformation(),
+ rCurrentVI2D.getViewTransformation(),
+ aEmptyRange,
+ rCurrentVI2D.getVisualizedPage(),
+ rCurrentVI2D.getViewTime(),
+ rCurrentVI2D.getExtendedInformationSequence());
+
+ updateViewInformation2D(aNewVI2D);
+ }
+ }
+
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx b/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx
new file mode 100644
index 000000000000..283bbd4a101c
--- /dev/null
+++ b/svx/source/sdr/contact/objectcontactofobjlistpainter.cxx
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/svdmodel.hxx>
+#include <drawinglayer/processor2d/vclprocessor2d.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/contact/objectcontacttools.hxx>
+#include <unoapi.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ObjectContactPainter::ObjectContactPainter()
+ {
+ }
+
+ // The destructor.
+ ObjectContactPainter::~ObjectContactPainter()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ sal_uInt32 ObjectContactOfObjListPainter::GetPaintObjectCount() const
+ {
+ return maStartObjects.size();
+ }
+
+ ViewContact& ObjectContactOfObjListPainter::GetPaintObjectViewContact(sal_uInt32 nIndex) const
+ {
+ const SdrObject* pObj = maStartObjects[nIndex];
+ DBG_ASSERT(pObj, "ObjectContactOfObjListPainter: Corrupt SdrObjectVector (!)");
+ return pObj->GetViewContact();
+ }
+
+ ObjectContactOfObjListPainter::ObjectContactOfObjListPainter(
+ OutputDevice& rTargetDevice,
+ const SdrObjectVector& rObjects,
+ const SdrPage* pProcessedPage)
+ : ObjectContactPainter(),
+ mrTargetOutputDevice(rTargetDevice),
+ maStartObjects(rObjects),
+ mpProcessedPage(pProcessedPage)
+ {
+ }
+
+ ObjectContactOfObjListPainter::~ObjectContactOfObjListPainter()
+ {
+ }
+
+ // Process the whole displaying
+ void ObjectContactOfObjListPainter::ProcessDisplay(DisplayInfo& rDisplayInfo)
+ {
+ const sal_uInt32 nCount(GetPaintObjectCount());
+
+ if(nCount)
+ {
+ OutputDevice* pTargetDevice = TryToGetOutputDevice();
+
+ if(pTargetDevice)
+ {
+ // update current ViewInformation2D at the ObjectContact
+ const GDIMetaFile* pMetaFile = pTargetDevice->GetConnectMetaFile();
+ const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
+ basegfx::B2DRange aViewRange;
+
+ // create ViewRange
+ if(!bOutputToRecordingMetaFile)
+ {
+ // use visible pixels, but transform to world coordinates
+ const Size aOutputSizePixel(pTargetDevice->GetOutputSizePixel());
+ aViewRange = ::basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
+ aViewRange.transform(pTargetDevice->GetInverseViewTransformation());
+ }
+
+ // upate local ViewInformation2D
+ const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
+ basegfx::B2DHomMatrix(),
+ pTargetDevice->GetViewTransformation(),
+ aViewRange,
+ GetXDrawPageForSdrPage(const_cast< SdrPage* >(mpProcessedPage)),
+ 0.0,
+ 0);
+ updateViewInformation2D(aNewViewInformation2D);
+
+ // collect primitive data in a sequence; this will already use the updated ViewInformation2D
+ drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence;
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ const ViewObjectContact& rViewObjectContact = GetPaintObjectViewContact(a).GetViewObjectContact(*this);
+
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xPrimitiveSequence,
+ rViewObjectContact.getPrimitive2DSequenceHierarchy(rDisplayInfo));
+ }
+
+ // if there is something to show, use a vclProcessor to render it
+ if(xPrimitiveSequence.hasElements())
+ {
+ drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = createBaseProcessor2DFromOutputDevice(
+ *pTargetDevice, getViewInformation2D());
+
+ if(pProcessor2D)
+ {
+ pProcessor2D->process(xPrimitiveSequence);
+ delete pProcessor2D;
+ }
+ }
+ }
+ }
+ }
+
+ OutputDevice* ObjectContactOfObjListPainter::TryToGetOutputDevice() const
+ {
+ return &mrTargetOutputDevice;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ sal_uInt32 ObjectContactOfPagePainter::GetPaintObjectCount() const
+ {
+ return (GetStartPage() ? 1L : 0L);
+ }
+
+ ViewContact& ObjectContactOfPagePainter::GetPaintObjectViewContact(sal_uInt32 /*nIndex*/) const
+ {
+ DBG_ASSERT(GetStartPage(), "ObjectContactOfPagePainter::GetPaintObjectViewContact: no StartPage set (!)");
+ return GetStartPage()->GetViewContact();
+ }
+
+ ObjectContactOfPagePainter::ObjectContactOfPagePainter(
+ const SdrPage* pPage,
+ ObjectContact& rOriginalObjectContact)
+ : ObjectContactPainter(),
+ mrOriginalObjectContact(rOriginalObjectContact),
+ mxStartPage(const_cast< SdrPage* >(pPage)) // no SdrPageWeakRef available to hold a const SdrPage*
+ {
+ }
+
+ ObjectContactOfPagePainter::~ObjectContactOfPagePainter()
+ {
+ }
+
+ void ObjectContactOfPagePainter::SetStartPage(const SdrPage* pPage)
+ {
+ if(pPage != GetStartPage())
+ {
+ mxStartPage.reset(const_cast< SdrPage* >(pPage)); // no SdrPageWeakRef available to hold a const SdrPage*
+ }
+ }
+
+ OutputDevice* ObjectContactOfPagePainter::TryToGetOutputDevice() const
+ {
+ return mrOriginalObjectContact.TryToGetOutputDevice();
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/objectcontactofpageview.cxx b/svx/source/sdr/contact/objectcontactofpageview.cxx
new file mode 100644
index 000000000000..49052fbf74ca
--- /dev/null
+++ b/svx/source/sdr/contact/objectcontactofpageview.cxx
@@ -0,0 +1,488 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/objectcontactofpageview.hxx>
+#include <svx/sdr/contact/viewobjectcontactofunocontrol.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/svdview.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/sdr/animation/objectanimator.hxx>
+#include <svx/sdr/event/eventhandler.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <sdrpaintwindow.hxx>
+#include <drawinglayer/processor2d/vclprocessor2d.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <svx/sdr/contact/objectcontacttools.hxx>
+#include <com/sun/star/rendering/XSpriteCanvas.hpp>
+#include <unoapi.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ // internal access to SdrPage of SdrPageView
+ SdrPage* ObjectContactOfPageView::GetSdrPage() const
+ {
+ return GetPageWindow().GetPageView().GetPage();
+ }
+
+ ObjectContactOfPageView::ObjectContactOfPageView(SdrPageWindow& rPageWindow)
+ : ObjectContact(),
+ mrPageWindow(rPageWindow)
+ {
+ // init PreviewRenderer flag
+ setPreviewRenderer(((SdrPaintView&)rPageWindow.GetPageView().GetView()).IsPreviewRenderer());
+
+ // init timer
+ SetTimeout(1);
+ Stop();
+ }
+
+ ObjectContactOfPageView::~ObjectContactOfPageView()
+ {
+ // execute missing LazyInvalidates and stop timer
+ Timeout();
+ }
+
+ // LazyInvalidate request. Take action.
+ void ObjectContactOfPageView::setLazyInvalidate(ViewObjectContact& /*rVOC*/)
+ {
+ // do NOT call parent, but remember that something is to do by
+ // starting the LazyInvalidateTimer
+ Start();
+ }
+
+ // call this to support evtl. preparations for repaint
+ void ObjectContactOfPageView::PrepareProcessDisplay()
+ {
+ if(IsActive())
+ {
+ static bool bInvalidateDuringPaint(true);
+
+ if(bInvalidateDuringPaint)
+ {
+ // there are still non-triggered LazyInvalidate events, trigger these
+ Timeout();
+ }
+ }
+ }
+
+ // From baseclass Timer, the timeout call triggered by te LazyInvalidate mechanism
+ void ObjectContactOfPageView::Timeout()
+ {
+ // stop the timer
+ Stop();
+
+ // invalidate all LazyInvalidate VOCs new situations
+ const sal_uInt32 nVOCCount(getViewObjectContactCount());
+
+ for(sal_uInt32 a(0); a < nVOCCount; a++)
+ {
+ ViewObjectContact* pCandidate = getViewObjectContact(a);
+ pCandidate->triggerLazyInvalidate();
+ }
+ }
+
+ // Process the whole displaying
+ void ObjectContactOfPageView::ProcessDisplay(DisplayInfo& rDisplayInfo)
+ {
+ const SdrPage* pStartPage = GetSdrPage();
+
+ if(pStartPage && !rDisplayInfo.GetProcessLayers().IsEmpty())
+ {
+ const ViewContact& rDrawPageVC = pStartPage->GetViewContact();
+
+ if(rDrawPageVC.GetObjectCount())
+ {
+ DoProcessDisplay(rDisplayInfo);
+ }
+ }
+
+ // after paint take care of the evtl. scheduled asynchronious commands.
+ // Do this by resetting the timer contained there. Thus, after the paint
+ // that timer will be triggered and the events will be executed.
+ if(HasEventHandler())
+ {
+ sdr::event::TimerEventHandler& rEventHandler = GetEventHandler();
+
+ if(!rEventHandler.IsEmpty())
+ {
+ rEventHandler.Restart();
+ }
+ }
+ }
+
+ // Process the whole displaying. Only use given DsiplayInfo, do not access other
+ // OutputDevices then the given ones.
+ void ObjectContactOfPageView::DoProcessDisplay(DisplayInfo& rDisplayInfo)
+ {
+ // visualize entered group when that feature is switched on and it's not
+ // a print output. #i29129# No ghosted display for printing.
+ sal_Bool bVisualizeEnteredGroup(DoVisualizeEnteredGroup() && !isOutputToPrinter());
+
+ // Visualize entered groups: Set to ghosted as default
+ // start. Do this only for the DrawPage, not for MasterPages
+ if(bVisualizeEnteredGroup)
+ {
+ rDisplayInfo.SetGhostedDrawMode();
+ }
+
+ // #114359# save old and set clip region
+ OutputDevice* pOutDev = TryToGetOutputDevice();
+ OSL_ENSURE(0 != pOutDev, "ObjectContactOfPageView without OutDev, someone has overloaded TryToGetOutputDevice wrong (!)");
+ sal_Bool bClipRegionPushed(sal_False);
+ const Region& rRedrawArea(rDisplayInfo.GetRedrawArea());
+
+ if(!rRedrawArea.IsEmpty())
+ {
+ bClipRegionPushed = sal_True;
+ pOutDev->Push(PUSH_CLIPREGION);
+ pOutDev->IntersectClipRegion(rRedrawArea);
+ }
+
+ // Get start node and process DrawPage contents
+ const ViewObjectContact& rDrawPageVOContact = GetSdrPage()->GetViewContact().GetViewObjectContact(*this);
+
+ // update current ViewInformation2D at the ObjectContact
+ const double fCurrentTime(getPrimitiveAnimator().GetTime());
+ OutputDevice& rTargetOutDev = GetPageWindow().GetPaintWindow().GetTargetOutputDevice();
+ basegfx::B2DRange aViewRange;
+
+ // create ViewRange
+ if(isOutputToRecordingMetaFile())
+ {
+ if(isOutputToPDFFile() || isOutputToPrinter())
+ {
+ // #i98402# if it's a PDF export, set the ClipRegion as ViewRange. This is
+ // mainly because SW does not use DrawingLayer Page-Oriented and if not doing this,
+ // all existing objects will be collected as primitives and processed.
+ // OD 2009-03-05 #i99876# perform the same also for SW on printing.
+ const Rectangle aLogicClipRectangle(rDisplayInfo.GetRedrawArea().GetBoundRect());
+
+ aViewRange = basegfx::B2DRange(
+ aLogicClipRectangle.Left(), aLogicClipRectangle.Top(),
+ aLogicClipRectangle.Right(), aLogicClipRectangle.Bottom());
+ }
+ }
+ else
+ {
+ // use visible pixels, but transform to world coordinates
+ const Size aOutputSizePixel(rTargetOutDev.GetOutputSizePixel());
+ aViewRange = basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
+
+ // if a clip region is set, use it
+ if(!rDisplayInfo.GetRedrawArea().IsEmpty())
+ {
+ // get logic clip range and create discrete one
+ const Rectangle aLogicClipRectangle(rDisplayInfo.GetRedrawArea().GetBoundRect());
+ basegfx::B2DRange aLogicClipRange(
+ aLogicClipRectangle.Left(), aLogicClipRectangle.Top(),
+ aLogicClipRectangle.Right(), aLogicClipRectangle.Bottom());
+ basegfx::B2DRange aDiscreteClipRange(aLogicClipRange);
+ aDiscreteClipRange.transform(rTargetOutDev.GetViewTransformation());
+
+ // align the discrete one to discrete boundaries (pixel bounds). Also
+ // expand X and Y max by one due to Rectangle definition source
+ aDiscreteClipRange.expand(basegfx::B2DTuple(
+ floor(aDiscreteClipRange.getMinX()),
+ floor(aDiscreteClipRange.getMinY())));
+ aDiscreteClipRange.expand(basegfx::B2DTuple(
+ 1.0 + ceil(aDiscreteClipRange.getMaxX()),
+ 1.0 + ceil(aDiscreteClipRange.getMaxY())));
+
+ // intersect current ViewRange with ClipRange
+ aViewRange.intersect(aDiscreteClipRange);
+ }
+
+ // transform to world coordinates
+ aViewRange.transform(rTargetOutDev.GetInverseViewTransformation());
+ }
+
+ // update local ViewInformation2D
+ const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
+ basegfx::B2DHomMatrix(),
+ rTargetOutDev.GetViewTransformation(),
+ aViewRange,
+ GetXDrawPageForSdrPage(GetSdrPage()),
+ fCurrentTime,
+ 0);
+ updateViewInformation2D(aNewViewInformation2D);
+
+ // get whole Primitive2DSequence; this will already make use of updated ViewInformation2D
+ // and may use the MapMode from the Target OutDev in the DisplayInfo
+ drawinglayer::primitive2d::Primitive2DSequence xPrimitiveSequence(rDrawPageVOContact.getPrimitive2DSequenceHierarchy(rDisplayInfo));
+
+ // if there is something to show, use a primitive processor to render it. There
+ // is a choice between VCL and Canvas processors currently. The decision is made in
+ // createBaseProcessor2DFromOutputDevice and takes into accout things like the
+ // Target is a MetaFile, a VDev or something else. The Canvas renderer is triggered
+ // currently using the shown boolean. Canvas is not yet the default.
+ if(xPrimitiveSequence.hasElements())
+ {
+ // prepare OutputDevice (historical stuff, maybe soon removed)
+ rDisplayInfo.ClearGhostedDrawMode(); // reset, else the VCL-paint with the processor will not do the right thing
+ pOutDev->SetLayoutMode(0); // reset, default is no BiDi/RTL
+
+ // create renderer
+ drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = createBaseProcessor2DFromOutputDevice(
+ rTargetOutDev, getViewInformation2D());
+
+ if(pProcessor2D)
+ {
+ pProcessor2D->process(xPrimitiveSequence);
+ delete pProcessor2D;
+ }
+ }
+
+ // #114359# restore old ClipReghion
+ if(bClipRegionPushed)
+ {
+ pOutDev->Pop();
+ }
+
+ // Visualize entered groups: Reset to original DrawMode
+ if(bVisualizeEnteredGroup)
+ {
+ rDisplayInfo.ClearGhostedDrawMode();
+ }
+ }
+
+ // test if visualizing of entered groups is switched on at all
+ bool ObjectContactOfPageView::DoVisualizeEnteredGroup() const
+ {
+ SdrView& rView = GetPageWindow().GetPageView().GetView();
+ return rView.DoVisualizeEnteredGroup();
+ }
+
+ // get active group's (the entered group) ViewContact
+ const ViewContact* ObjectContactOfPageView::getActiveViewContact() const
+ {
+ SdrObjList* pActiveGroupList = GetPageWindow().GetPageView().GetObjList();
+
+ if(pActiveGroupList)
+ {
+ if(pActiveGroupList->ISA(SdrPage))
+ {
+ // It's a Page itself
+ return &(((SdrPage*)pActiveGroupList)->GetViewContact());
+ }
+ else if(pActiveGroupList->GetOwnerObj())
+ {
+ // Group object
+ return &(pActiveGroupList->GetOwnerObj()->GetViewContact());
+ }
+ }
+ else if(GetSdrPage())
+ {
+ // use page of associated SdrPageView
+ return &(GetSdrPage()->GetViewContact());
+ }
+
+ return 0;
+ }
+
+ // Invalidate given rectangle at the window/output which is represented by
+ // this ObjectContact.
+ void ObjectContactOfPageView::InvalidatePartOfView(const basegfx::B2DRange& rRange) const
+ {
+ // invalidate at associated PageWindow
+ GetPageWindow().InvalidatePageWindow(rRange);
+ }
+
+ // Get info if given Rectangle is visible in this view
+ bool ObjectContactOfPageView::IsAreaVisible(const basegfx::B2DRange& rRange) const
+ {
+ // compare with the visible rectangle
+ if(rRange.isEmpty())
+ {
+ // no range -> not visible
+ return false;
+ }
+ else
+ {
+ const OutputDevice& rTargetOutDev = GetPageWindow().GetPaintWindow().GetTargetOutputDevice();
+ const Size aOutputSizePixel(rTargetOutDev.GetOutputSizePixel());
+ basegfx::B2DRange aLogicViewRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
+
+ aLogicViewRange.transform(rTargetOutDev.GetInverseViewTransformation());
+
+ if(!aLogicViewRange.isEmpty() && !aLogicViewRange.overlaps(rRange))
+ {
+ return false;
+ }
+ }
+
+ // call parent
+ return ObjectContact::IsAreaVisible(rRange);
+ }
+
+ // Get info about the need to visualize GluePoints
+ bool ObjectContactOfPageView::AreGluePointsVisible() const
+ {
+ return GetPageWindow().GetPageView().GetView().ImpIsGlueVisible();
+ }
+
+ // check if text animation is allowed.
+ bool ObjectContactOfPageView::IsTextAnimationAllowed() const
+ {
+ SdrView& rView = GetPageWindow().GetPageView().GetView();
+ const SvtAccessibilityOptions& rOpt = rView.getAccessibilityOptions();
+ return rOpt.GetIsAllowAnimatedText();
+ }
+
+ // check if graphic animation is allowed.
+ bool ObjectContactOfPageView::IsGraphicAnimationAllowed() const
+ {
+ SdrView& rView = GetPageWindow().GetPageView().GetView();
+ const SvtAccessibilityOptions& rOpt = rView.getAccessibilityOptions();
+ return rOpt.GetIsAllowAnimatedGraphics();
+ }
+
+ // check if asynchronious graphis loading is allowed. Default is sal_False.
+ bool ObjectContactOfPageView::IsAsynchronGraphicsLoadingAllowed() const
+ {
+ SdrView& rView = GetPageWindow().GetPageView().GetView();
+ return rView.IsSwapAsynchron();
+ }
+
+ // check if buffering of MasterPages is allowed. Default is sal_False.
+ bool ObjectContactOfPageView::IsMasterPageBufferingAllowed() const
+ {
+ SdrView& rView = GetPageWindow().GetPageView().GetView();
+ return rView.IsMasterPagePaintCaching();
+ }
+
+ // print?
+ bool ObjectContactOfPageView::isOutputToPrinter() const
+ {
+ return (OUTDEV_PRINTER == mrPageWindow.GetPaintWindow().GetOutputDevice().GetOutDevType());
+ }
+
+ // window?
+ bool ObjectContactOfPageView::isOutputToWindow() const
+ {
+ return (OUTDEV_WINDOW == mrPageWindow.GetPaintWindow().GetOutputDevice().GetOutDevType());
+ }
+
+ // VirtualDevice?
+ bool ObjectContactOfPageView::isOutputToVirtualDevice() const
+ {
+ return (OUTDEV_VIRDEV == mrPageWindow.GetPaintWindow().GetOutputDevice().GetOutDevType());
+ }
+
+ // recording MetaFile?
+ bool ObjectContactOfPageView::isOutputToRecordingMetaFile() const
+ {
+ GDIMetaFile* pMetaFile = mrPageWindow.GetPaintWindow().GetOutputDevice().GetConnectMetaFile();
+ return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
+ }
+
+ // pdf export?
+ bool ObjectContactOfPageView::isOutputToPDFFile() const
+ {
+ return (0 != mrPageWindow.GetPaintWindow().GetOutputDevice().GetPDFWriter());
+ }
+
+ // gray display mode
+ bool ObjectContactOfPageView::isDrawModeGray() const
+ {
+ const sal_uInt32 nDrawMode(mrPageWindow.GetPaintWindow().GetOutputDevice().GetDrawMode());
+ return (nDrawMode == (DRAWMODE_GRAYLINE|DRAWMODE_GRAYFILL|DRAWMODE_BLACKTEXT|DRAWMODE_GRAYBITMAP|DRAWMODE_GRAYGRADIENT));
+ }
+
+ // gray display mode
+ bool ObjectContactOfPageView::isDrawModeBlackWhite() const
+ {
+ const sal_uInt32 nDrawMode(mrPageWindow.GetPaintWindow().GetOutputDevice().GetDrawMode());
+ return (nDrawMode == (DRAWMODE_BLACKLINE|DRAWMODE_BLACKTEXT|DRAWMODE_WHITEFILL|DRAWMODE_GRAYBITMAP|DRAWMODE_WHITEGRADIENT));
+ }
+
+ // high contrast display mode
+ bool ObjectContactOfPageView::isDrawModeHighContrast() const
+ {
+ const sal_uInt32 nDrawMode(mrPageWindow.GetPaintWindow().GetOutputDevice().GetDrawMode());
+ return (nDrawMode == (DRAWMODE_SETTINGSLINE|DRAWMODE_SETTINGSFILL|DRAWMODE_SETTINGSTEXT|DRAWMODE_SETTINGSGRADIENT));
+ }
+
+ // access to SdrPageView
+ SdrPageView* ObjectContactOfPageView::TryToGetSdrPageView() const
+ {
+ return &(mrPageWindow.GetPageView());
+ }
+
+
+ // access to OutputDevice
+ OutputDevice* ObjectContactOfPageView::TryToGetOutputDevice() const
+ {
+ SdrPreRenderDevice* pPreRenderDevice = mrPageWindow.GetPaintWindow().GetPreRenderDevice();
+
+ if(pPreRenderDevice)
+ {
+ return &(pPreRenderDevice->GetPreRenderDevice());
+ }
+ else
+ {
+ return &(mrPageWindow.GetPaintWindow().GetOutputDevice());
+ }
+ }
+
+ // set all UNO controls displayed in the view to design/alive mode
+ void ObjectContactOfPageView::SetUNOControlsDesignMode( bool _bDesignMode ) const
+ {
+ const sal_uInt32 nCount(getViewObjectContactCount());
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ const ViewObjectContact* pVOC = getViewObjectContact(a);
+ const ViewObjectContactOfUnoControl* pUnoObjectVOC = dynamic_cast< const ViewObjectContactOfUnoControl* >(pVOC);
+
+ if(pUnoObjectVOC)
+ {
+ pUnoObjectVOC->setControlDesignMode(_bDesignMode);
+ }
+ }
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/objectcontacttools.cxx b/svx/source/sdr/contact/objectcontacttools.cxx
new file mode 100644
index 000000000000..aa79df2dace6
--- /dev/null
+++ b/svx/source/sdr/contact/objectcontacttools.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/objectcontacttools.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <vcl/gdimtf.hxx>
+#include <basegfx/tools/canvastools.hxx>
+#include <drawinglayer/processor2d/vclmetafileprocessor2d.hxx>
+#include <drawinglayer/processor2d/vclpixelprocessor2d.hxx>
+#include <drawinglayer/processor2d/canvasprocessor.hxx>
+#include <vcl/window.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ drawinglayer::processor2d::BaseProcessor2D* createBaseProcessor2DFromOutputDevice(
+ OutputDevice& rTargetOutDev,
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D)
+ {
+ const GDIMetaFile* pMetaFile = rTargetOutDev.GetConnectMetaFile();
+ const bool bOutputToRecordingMetaFile(pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
+
+ if(bOutputToRecordingMetaFile)
+ {
+ // create MetaFile Vcl-Processor and process
+ return new drawinglayer::processor2d::VclMetafileProcessor2D(rViewInformation2D, rTargetOutDev);
+ }
+ else
+ {
+#ifdef WIN32
+ // for a first AA incarnation VCL-PixelRenderer will be okay since
+ // simple (and fast) GDIPlus support over VCL will be used.
+ // Leaving the code below as a hint for what to do when we will
+ // use canvas renderers in the future
+
+ //static SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+
+ //if(false && aSvtOptionsDrawinglayer.IsAntiAliasing())
+ //{
+ // // for WIN32 AA, create cairo canvas processor
+ // return new drawinglayer::processor2d::canvasProcessor2D(rViewInformation2D, rTargetOutDev);
+ //}
+ //else
+ //{
+ // create Pixel Vcl-Processor
+ return new drawinglayer::processor2d::VclPixelProcessor2D(rViewInformation2D, rTargetOutDev);
+ //}
+#else
+ static bool bTryTestCanvas(false);
+
+ if(bTryTestCanvas)
+ {
+ // create test-cancas-Processor
+ return new drawinglayer::processor2d::canvasProcessor2D(rViewInformation2D, rTargetOutDev);
+ }
+ else
+ {
+ // create Pixel Vcl-Processor
+ return new drawinglayer::processor2d::VclPixelProcessor2D(rViewInformation2D, rTargetOutDev);
+ }
+#endif
+ }
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/sdrmediawindow.cxx b/svx/source/sdr/contact/sdrmediawindow.cxx
new file mode 100644
index 000000000000..ff969c51109e
--- /dev/null
+++ b/svx/source/sdr/contact/sdrmediawindow.cxx
@@ -0,0 +1,196 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "sdrmediawindow.hxx"
+#include <svtools/transfer.hxx>
+
+#include <svx/sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
+#include <vcl/window.hxx>
+
+namespace sdr { namespace contact {
+
+// ------------------
+// - SdrMediaWindow -
+// ------------------
+
+SdrMediaWindow::SdrMediaWindow( Window* pParent, ViewObjectContactOfSdrMediaObj& rViewObjContact ) :
+ ::avmedia::MediaWindow( pParent, false ),
+ mrViewObjectContactOfSdrMediaObj( rViewObjContact )
+{
+}
+
+// ------------------------------------------------------------------------------
+
+SdrMediaWindow::~SdrMediaWindow()
+{
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
+
+ if( pWindow && getWindow() )
+ {
+ const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
+ rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
+
+ pWindow->MouseMove( aTransformedEvent );
+ setPointer( pWindow->GetPointer() );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
+
+ if( pWindow && getWindow() )
+ {
+ const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
+ rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
+
+ pWindow->MouseButtonDown( aTransformedEvent );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
+
+ if( pWindow && getWindow() )
+ {
+ const MouseEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rMEvt.GetPosPixel() ) ),
+ rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), rMEvt.GetModifier() );
+
+ pWindow->MouseButtonUp( aTransformedEvent );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
+
+ if( pWindow )
+ pWindow->KeyInput( rKEvt );
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaWindow::KeyUp( const KeyEvent& rKEvt )
+{
+ Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
+
+ if( pWindow )
+ pWindow->KeyUp( rKEvt );
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaWindow::Command( const CommandEvent& rCEvt )
+{
+ Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
+
+ if( pWindow && getWindow() )
+ {
+ const CommandEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ),
+ rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetData() );
+
+ pWindow->Command( aTransformedEvent );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Int8 SdrMediaWindow::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( pWindow )
+ {
+ DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow );
+
+ if( pDropTargetHelper )
+ {
+ nRet = pDropTargetHelper->AcceptDrop( rEvt );
+ }
+ }
+
+ return( nRet );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Int8 SdrMediaWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( pWindow )
+ {
+ DropTargetHelper* pDropTargetHelper = dynamic_cast< DropTargetHelper* >( pWindow );
+
+ if( pDropTargetHelper )
+ {
+ nRet = pDropTargetHelper->ExecuteDrop( rEvt );
+ }
+ }
+
+ return( nRet );
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaWindow::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
+{
+ Window* pWindow = mrViewObjectContactOfSdrMediaObj.getWindow();
+
+ if( pWindow )
+ {
+ DragSourceHelper* pDragSourceHelper = dynamic_cast< DragSourceHelper* >( pWindow );
+
+ if( pDragSourceHelper )
+ {
+ pDragSourceHelper->StartDrag( nAction, rPosPixel );
+ }
+ }
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/sdrmediawindow.hxx b/svx/source/sdr/contact/sdrmediawindow.hxx
new file mode 100644
index 000000000000..35b12177a769
--- /dev/null
+++ b/svx/source/sdr/contact/sdrmediawindow.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SDR_CONTACT_SDRMEDIAWIMNDOW_HXX
+
+#include <avmedia/mediawindow.hxx>
+
+namespace sdr { namespace contact {
+
+// ------------------
+// - SdrMediaWindow -
+// ------------------
+
+class ViewObjectContactOfSdrMediaObj;
+
+class SdrMediaWindow : public ::avmedia::MediaWindow
+{
+public:
+
+ SdrMediaWindow( Window* pParent, ViewObjectContactOfSdrMediaObj& rViewObjContact );
+ ~SdrMediaWindow();
+
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void KeyUp( const KeyEvent& rKEvt );
+
+ virtual void Command( const CommandEvent& rCEvt );
+
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+private:
+
+ ViewObjectContactOfSdrMediaObj& mrViewObjectContactOfSdrMediaObj;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontact.cxx b/svx/source/sdr/contact/viewcontact.cxx
new file mode 100644
index 000000000000..295249ff72cc
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontact.cxx
@@ -0,0 +1,332 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/contact/objectcontactofpageview.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ // Create a Object-Specific ViewObjectContact, set ViewContact and
+ // ObjectContact. Always needs to return something. Default is to create
+ // a standard ViewObjectContact containing the given ObjectContact and *this
+ ViewObjectContact& ViewContact::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ return *(new ViewObjectContact(rObjectContact, *this));
+ }
+
+ ViewContact::ViewContact()
+ : maViewObjectContactVector(),
+ mxViewIndependentPrimitive2DSequence()
+ {
+ }
+
+ // Methods to react on start getting viewed or stop getting
+ // viewed. This info is derived from the count of members of
+ // registered ViewObjectContacts. Default does nothing.
+ void ViewContact::StartGettingViewed()
+ {
+ }
+
+ void ViewContact::StopGettingViewed()
+ {
+ }
+
+ ViewContact::~ViewContact()
+ {
+ deleteAllVOCs();
+ }
+
+ void ViewContact::deleteAllVOCs()
+ {
+ // get rid of all VOCs
+ // #i84257# To avoid that each 'delete pCandidate' again uses
+ // the local RemoveViewObjectContact with a search and removal in the
+ // vector, simply copy and clear local vector.
+ std::vector< ViewObjectContact* > aLocalVOCList(maViewObjectContactVector);
+ maViewObjectContactVector.clear();
+
+ while(aLocalVOCList.size())
+ {
+ ViewObjectContact* pCandidate = aLocalVOCList.back();
+ aLocalVOCList.pop_back();
+ DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList in VC (!)");
+
+ // ViewObjectContacts only make sense with View and Object contacts.
+ // When the contact to the SdrObject is deleted like in this case,
+ // all ViewObjectContacts can be deleted, too.
+ delete pCandidate;
+ }
+
+ // assert when there were new entries added during deletion
+ DBG_ASSERT(maViewObjectContactVector.empty(), "Corrupted ViewObjectContactList in VC (!)");
+ }
+
+ // get a Object-specific ViewObjectContact for a specific
+ // ObjectContact (->View). Always needs to return something.
+ ViewObjectContact& ViewContact::GetViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = 0L;
+ const sal_uInt32 nCount(maViewObjectContactVector.size());
+
+ // first search if there exists a VOC for the given OC
+ for(sal_uInt32 a(0); !pRetval && a < nCount; a++)
+ {
+ ViewObjectContact* pCandidate = maViewObjectContactVector[a];
+ DBG_ASSERT(pCandidate, "Corrupted ViewObjectContactList (!)");
+
+ if(&(pCandidate->GetObjectContact()) == &rObjectContact)
+ {
+ pRetval = pCandidate;
+ }
+ }
+
+ if(!pRetval)
+ {
+ // create a new one. It's inserted to the local list from the
+ // VieObjectContact constructor via AddViewObjectContact()
+ pRetval = &CreateObjectSpecificViewObjectContact(rObjectContact);
+ }
+
+ return *pRetval;
+ }
+
+ // A new ViewObjectContact was created and shall be remembered.
+ void ViewContact::AddViewObjectContact(ViewObjectContact& rVOContact)
+ {
+ maViewObjectContactVector.push_back(&rVOContact);
+
+ if(1L == maViewObjectContactVector.size())
+ {
+ StartGettingViewed();
+ }
+ }
+
+ // A ViewObjectContact was deleted and shall be forgotten.
+ void ViewContact::RemoveViewObjectContact(ViewObjectContact& rVOContact)
+ {
+ std::vector< ViewObjectContact* >::iterator aFindResult = std::find(maViewObjectContactVector.begin(), maViewObjectContactVector.end(), &rVOContact);
+
+ if(aFindResult != maViewObjectContactVector.end())
+ {
+ maViewObjectContactVector.erase(aFindResult);
+
+ if(0 == maViewObjectContactVector.size())
+ {
+ // This may need to get asynchron later since it eventually triggers
+ // deletes of OCs where the VOC is still added.
+ StopGettingViewed();
+ }
+ }
+ }
+
+ // Test if this ViewContact has ViewObjectContacts at all. This can
+ // be used to test if this ViewContact is visualized ATM or not
+ bool ViewContact::HasViewObjectContacts(bool bExcludePreviews) const
+ {
+ const sal_uInt32 nCount(maViewObjectContactVector.size());
+
+ if(bExcludePreviews)
+ {
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ if(!maViewObjectContactVector[a]->GetObjectContact().IsPreviewRenderer())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ else
+ {
+ return (0L != nCount);
+ }
+ }
+
+ // Test if this ViewContact has ViewObjectContacts at all. This can
+ // be used to test if this ViewContact is visualized ATM or not
+ bool ViewContact::isAnimatedInAnyViewObjectContact() const
+ {
+ const sal_uInt32 nCount(maViewObjectContactVector.size());
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ if(maViewObjectContactVector[a]->isAnimated())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // Access to possible sub-hierarchy and parent. GetObjectCount() default is 0L
+ // and GetViewContact default pops up an assert since it's an error if
+ // GetObjectCount has a result != 0 and it's not overloaded.
+ sal_uInt32 ViewContact::GetObjectCount() const
+ {
+ // no sub-objects
+ return 0;
+ }
+
+ ViewContact& ViewContact::GetViewContact(sal_uInt32 /*nIndex*/) const
+ {
+ // This is the default implementation; call would be an error
+ DBG_ERROR("ViewContact::GetViewContact: This call needs to be overloaded when GetObjectCount() can return results != 0 (!)");
+ return (ViewContact&)(*this);
+ }
+
+ ViewContact* ViewContact::GetParentContact() const
+ {
+ // default has no parent
+ return 0;
+ }
+
+ void ViewContact::ActionChildInserted(ViewContact& rChild)
+ {
+ // propagate change to all exsisting visualisations which
+ // will force a VOC for the new child and invalidate it's range
+ const sal_uInt32 nCount(maViewObjectContactVector.size());
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ ViewObjectContact* pCandidate = maViewObjectContactVector[a];
+ DBG_ASSERT(pCandidate, "ViewContact::GetViewObjectContact() invalid ViewObjectContactList (!)");
+
+ // take action at all VOCs. At the VOCs ObjectContact the initial
+ // rectangle will be invalidated at the associated OutputDevice.
+ pCandidate->ActionChildInserted(rChild);
+ }
+ }
+
+ // React on changes of the object of this ViewContact
+ void ViewContact::ActionChanged()
+ {
+ // propagate change to all existing VOCs. This will invalidate
+ // all drawn visualisations in all known views
+ const sal_uInt32 nCount(maViewObjectContactVector.size());
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ ViewObjectContact* pCandidate = maViewObjectContactVector[a];
+ DBG_ASSERT(pCandidate, "ViewContact::GetViewObjectContact() invalid ViewObjectContactList (!)");
+
+ pCandidate->ActionChanged();
+ }
+ }
+
+ // access to SdrObject and/or SdrPage. May return 0L like the default
+ // implementations do. Needs to be overloaded as needed.
+ SdrObject* ViewContact::TryToGetSdrObject() const
+ {
+ return 0L;
+ }
+
+ SdrPage* ViewContact::TryToGetSdrPage() const
+ {
+ return 0L;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////
+ // primitive stuff
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContact::createViewIndependentPrimitive2DSequence() const
+ {
+ // This is the default impelemtation and should never be called (see header). If this is called,
+ // someone implemented a ViewContact (VC) visualisation object without defining the visualisation by
+ // providing a seqence of primitives -> which cannot be correct.
+ // Since we have no access to any known model data here, the default implementation creates a yellow placeholder
+ // hairline polygon with a default size of (1000, 1000, 5000, 3000)
+ DBG_ERROR("ViewContact::createViewIndependentPrimitive2DSequence(): Never call the fallback base implementation, this is always an error (!)");
+ const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(1000.0, 1000.0, 5000.0, 3000.0)));
+ const basegfx::BColor aYellow(1.0, 1.0, 0.0);
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aYellow));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContact::getViewIndependentPrimitive2DSequence() const
+ {
+ // local up-to-date checks. Create new list and compare.
+ const drawinglayer::primitive2d::Primitive2DSequence xNew(createViewIndependentPrimitive2DSequence());
+
+ if(!drawinglayer::primitive2d::arePrimitive2DSequencesEqual(mxViewIndependentPrimitive2DSequence, xNew))
+ {
+ // has changed, copy content
+ const_cast< ViewContact* >(this)->mxViewIndependentPrimitive2DSequence = xNew;
+ }
+
+ // return current Primitive2DSequence
+ return mxViewIndependentPrimitive2DSequence;
+ }
+
+ // add Gluepoints (if available)
+ drawinglayer::primitive2d::Primitive2DSequence ViewContact::createGluePointPrimitive2DSequence() const
+ {
+ // default returns empty reference
+ return drawinglayer::primitive2d::Primitive2DSequence();
+ }
+
+ void ViewContact::flushViewObjectContacts(bool bWithHierarchy)
+ {
+ if(bWithHierarchy)
+ {
+ // flush DrawingLayer hierarchy
+ const sal_uInt32 nCount(GetObjectCount());
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ ViewContact& rChild = GetViewContact(a);
+ rChild.flushViewObjectContacts(bWithHierarchy);
+ }
+ }
+
+ // delete local VOCs
+ deleteAllVOCs();
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofe3d.cxx b/svx/source/sdr/contact/viewcontactofe3d.cxx
new file mode 100644
index 000000000000..032e3cad76e6
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofe3d.cxx
@@ -0,0 +1,230 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofe3d.hxx>
+#include <svx/sdr/contact/viewobjectcontactofe3d.hxx>
+#include <svx/obj3d.hxx>
+#include <drawinglayer/primitive2d/embedded3dprimitive2d.hxx>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+#include <svx/scene3d.hxx>
+#include <drawinglayer/primitive3d/transformprimitive3d.hxx>
+#include <drawinglayer/attribute/sdrsceneattribute3d.hxx>
+#include <drawinglayer/attribute/sdrlightingattribute3d.hxx>
+#include <drawinglayer/attribute/sdrlightattribute3d.hxx>
+#include <drawinglayer/attribute/sdrlineattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace
+{
+ const sdr::contact::ViewContactOfE3dScene* tryToFindVCOfE3DScene(
+ const sdr::contact::ViewContact& rCandidate,
+ basegfx::B3DHomMatrix& o_rInBetweenObjectTransform)
+ {
+ const sdr::contact::ViewContactOfE3dScene* pSceneParent =
+ dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(rCandidate.GetParentContact());
+
+ if(pSceneParent)
+ {
+ // each 3d object (including in-between scenes) should have a scene as parent
+ const sdr::contact::ViewContactOfE3dScene* pSceneParentParent =
+ dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(pSceneParent->GetParentContact());
+
+ if(pSceneParentParent)
+ {
+ // the parent scene of rCandidate is a in-between scene, call recursively and collect
+ // the in-between scene's object transformation part in o_rInBetweenObjectTransform
+ const basegfx::B3DHomMatrix& rSceneParentTransform = pSceneParent->GetE3dScene().GetTransform();
+ o_rInBetweenObjectTransform = rSceneParentTransform * o_rInBetweenObjectTransform;
+ return tryToFindVCOfE3DScene(*pSceneParent, o_rInBetweenObjectTransform);
+ }
+ else
+ {
+ // the parent scene is the outmost scene
+ return pSceneParent;
+ }
+ }
+
+ // object hierarchy structure is incorrect; no result
+ return 0;
+ }
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3d::impCreateWithGivenPrimitive3DSequence(
+ const drawinglayer::primitive3d::Primitive3DSequence& rxContent3D) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ if(rxContent3D.hasElements())
+ {
+ // try to get the outmost ViewObjectContactOfE3dScene for this single 3d object,
+ // the ones on the way there are grouping scenes. Collect the in-between scene's
+ // transformations to build a correct object transformation for the embedded
+ // object
+ basegfx::B3DHomMatrix aInBetweenObjectTransform;
+ const ViewContactOfE3dScene* pVCOfE3DScene = tryToFindVCOfE3DScene(*this, aInBetweenObjectTransform);
+
+ if(pVCOfE3DScene)
+ {
+ basegfx::B3DVector aLightNormal;
+ const double fShadowSlant(pVCOfE3DScene->getSdrSceneAttribute().getShadowSlant());
+ const basegfx::B3DRange& rAllContentRange = pVCOfE3DScene->getAllContentRange3D();
+ drawinglayer::geometry::ViewInformation3D aViewInformation3D(pVCOfE3DScene->getViewInformation3D());
+
+ if(pVCOfE3DScene->getSdrLightingAttribute().getLightVector().size())
+ {
+ // get light normal from first light and normalize
+ aLightNormal = pVCOfE3DScene->getSdrLightingAttribute().getLightVector()[0].getDirection();
+ aLightNormal.normalize();
+ }
+
+ if(!aInBetweenObjectTransform.isIdentity())
+ {
+ // if aInBetweenObjectTransform is used, create combined ViewInformation3D which
+ // contains the correct object transformation for the embedded 3d object
+ aViewInformation3D = drawinglayer::geometry::ViewInformation3D(
+ aViewInformation3D.getObjectTransformation() * aInBetweenObjectTransform,
+ aViewInformation3D.getOrientation(),
+ aViewInformation3D.getProjection(),
+ aViewInformation3D.getDeviceToView(),
+ aViewInformation3D.getViewTime(),
+ aViewInformation3D.getExtendedInformationSequence());
+ }
+
+ // create embedded 2d primitive and add. LightNormal and ShadowSlant are needed for evtl.
+ // 3D shadow extraction for correct B2DRange calculation (shadow is part of the object)
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::Embedded3DPrimitive2D(
+ rxContent3D,
+ pVCOfE3DScene->getObjectTransformation(),
+ aViewInformation3D,
+ aLightNormal,
+ fShadowSlant,
+ rAllContentRange));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ }
+
+ return xRetval;
+ }
+
+ ViewContactOfE3d::ViewContactOfE3d(E3dObject& rSdrObject)
+ : ViewContactOfSdrObj(rSdrObject)
+ {
+ }
+
+ ViewContactOfE3d::~ViewContactOfE3d()
+ {
+ }
+
+ drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3d::getVIP3DSWithoutObjectTransform() const
+ {
+ // local up-to-date checks. Create new list and compare.
+ drawinglayer::primitive3d::Primitive3DSequence xNew(createViewIndependentPrimitive3DSequence());
+
+ if(!drawinglayer::primitive3d::arePrimitive3DSequencesEqual(mxViewIndependentPrimitive3DSequence, xNew))
+ {
+ // has changed, copy content
+ const_cast< ViewContactOfE3d* >(this)->mxViewIndependentPrimitive3DSequence = xNew;
+ }
+
+ // return current Primitive2DSequence
+ return mxViewIndependentPrimitive3DSequence;
+ }
+
+ drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3d::getViewIndependentPrimitive3DSequence() const
+ {
+ // get sequence without object transform
+ drawinglayer::primitive3d::Primitive3DSequence xRetval(getVIP3DSWithoutObjectTransform());
+
+ if(xRetval.hasElements())
+ {
+ // add object transform if it's used
+ const basegfx::B3DHomMatrix& rObjectTransform(GetE3dObject().GetTransform());
+
+ if(!rObjectTransform.isIdentity())
+ {
+ const drawinglayer::primitive3d::Primitive3DReference xReference(
+ new drawinglayer::primitive3d::TransformPrimitive3D(
+ rObjectTransform,
+ xRetval));
+
+ xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
+ }
+ }
+
+ // return current Primitive2DSequence
+ return xRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3d::createViewIndependentPrimitive2DSequence() const
+ {
+ // also need to create a 2D embedding when the view-independent part is requested,
+ // see view-dependent part in ViewObjectContactOfE3d::createPrimitive2DSequence
+ // get 3d primitive vector, isPrimitiveVisible() is done in 3d creator
+ return impCreateWithGivenPrimitive3DSequence(getViewIndependentPrimitive3DSequence());
+ }
+
+ ViewObjectContact& ViewContactOfE3d::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfE3d(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContactOfE3d::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ drawinglayer::attribute::SdrLineAttribute* ViewContactOfE3d::impCreateFallbackLineAttribute(const basegfx::BColor& rBColor) const
+ {
+ static bool bFallbackToCreateAsLineForTest(false);
+
+ if(bFallbackToCreateAsLineForTest)
+ {
+ return new drawinglayer::attribute::SdrLineAttribute(rBColor);
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofe3dcube.cxx b/svx/source/sdr/contact/viewcontactofe3dcube.cxx
new file mode 100644
index 000000000000..22be3141987a
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofe3dcube.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofe3dcube.hxx>
+#include <svx/cube3d.hxx>
+#include <drawinglayer/primitive3d/sdrcubeprimitive3d.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive3d/sdrattributecreator3d.hxx>
+#include <basegfx/range/b3drange.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfE3dCube::ViewContactOfE3dCube(E3dCubeObj& rCubeObj)
+ : ViewContactOfE3d(rCubeObj)
+ {
+ }
+
+ ViewContactOfE3dCube::~ViewContactOfE3dCube()
+ {
+ }
+
+ drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dCube::createViewIndependentPrimitive3DSequence() const
+ {
+ drawinglayer::primitive3d::Primitive3DSequence xRetval;
+ const SfxItemSet& rItemSet = GetE3dCubeObj().GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineFillShadowAttribute3D aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowAttribute(rItemSet, false));
+
+ // get cube geometry and use as traslation and scaling for unit cube
+ basegfx::B3DRange aCubeRange;
+ const basegfx::B3DVector aCubeSize(GetE3dCubeObj().GetCubeSize());
+ const basegfx::B3DPoint aCubePosition(GetE3dCubeObj().GetCubePos());
+ basegfx::B3DHomMatrix aWorldTransform;
+
+ if(GetE3dCubeObj().GetPosIsCenter())
+ {
+ const basegfx::B3DVector aHalfCubeSize(aCubeSize / 2.0);
+ aCubeRange.expand(aCubePosition - aHalfCubeSize);
+ aCubeRange.expand(aCubePosition + aHalfCubeSize);
+ }
+ else
+ {
+ aCubeRange.expand(aCubePosition);
+ aCubeRange.expand(aCubePosition + aCubeSize);
+ }
+
+ // add scale and translate to world transformation
+ const basegfx::B3DVector abjectRange(aCubeRange.getRange());
+ aWorldTransform.scale(abjectRange.getX(), abjectRange.getY(), abjectRange.getZ());
+ aWorldTransform.translate(aCubeRange.getMinX(), aCubeRange.getMinY(), aCubeRange.getMinZ());
+
+ // get 3D Object Attributes
+ drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet);
+
+ // calculate texture size to get a perfect mapping for
+ // the front/back sides
+ const basegfx::B2DVector aTextureSize(aCubeSize.getX(), aCubeSize.getY());
+
+ // create primitive and add
+ const drawinglayer::primitive3d::Primitive3DReference xReference(
+ new drawinglayer::primitive3d::SdrCubePrimitive3D(
+ aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute));
+ xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
+
+ // delete 3D Object Attributes
+ delete pSdr3DObjectAttribute;
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofe3dextrude.cxx b/svx/source/sdr/contact/viewcontactofe3dextrude.cxx
new file mode 100644
index 000000000000..20906efa0731
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofe3dextrude.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofe3dextrude.hxx>
+#include <svx/extrud3d.hxx>
+#include <drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive3d/sdrattributecreator3d.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfE3dExtrude::ViewContactOfE3dExtrude(E3dExtrudeObj& rExtrude)
+ : ViewContactOfE3d(rExtrude)
+ {
+ }
+
+ ViewContactOfE3dExtrude::~ViewContactOfE3dExtrude()
+ {
+ }
+
+ drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dExtrude::createViewIndependentPrimitive3DSequence() const
+ {
+ drawinglayer::primitive3d::Primitive3DSequence xRetval;
+ const SfxItemSet& rItemSet = GetE3dExtrudeObj().GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineFillShadowAttribute3D aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowAttribute(rItemSet, false));
+
+ // get extrude geometry
+ const basegfx::B2DPolyPolygon aPolyPolygon(GetE3dExtrudeObj().GetExtrudePolygon());
+
+ // get 3D Object Attributes
+ drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet);
+
+ // calculate texture size; use size of top/bottom cap to get a perfect mapping
+ // for the caps. The in-between geometry will get a stretched size with a
+ // relative factor size of caps to extrude depth
+ const basegfx::B2DRange aRange(basegfx::tools::getRange(aPolyPolygon));
+ const basegfx::B2DVector aTextureSize(aRange.getWidth(), aRange.getHeight());
+
+ // get more data
+ const double fDepth((double)GetE3dExtrudeObj().GetExtrudeDepth());
+ const double fDiagonal((double)GetE3dExtrudeObj().GetPercentDiagonal() / 100.0);
+ const double fBackScale((double)GetE3dExtrudeObj().GetPercentBackScale() / 100.0);
+ const bool bSmoothNormals(GetE3dExtrudeObj().GetSmoothNormals()); // Plane itself
+ const bool bSmoothLids(GetE3dExtrudeObj().GetSmoothLids()); // Front/back
+ const bool bCharacterMode(GetE3dExtrudeObj().GetCharacterMode());
+ const bool bCloseFront(GetE3dExtrudeObj().GetCloseFront());
+ const bool bCloseBack(GetE3dExtrudeObj().GetCloseBack());
+
+ // create primitive and add
+ const basegfx::B3DHomMatrix aWorldTransform;
+ const drawinglayer::primitive3d::Primitive3DReference xReference(
+ new drawinglayer::primitive3d::SdrExtrudePrimitive3D(
+ aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute,
+ aPolyPolygon, fDepth, fDiagonal, fBackScale, bSmoothNormals, true, bSmoothLids,
+ bCharacterMode, bCloseFront, bCloseBack));
+ xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
+
+ // delete 3D Object Attributes
+ delete pSdr3DObjectAttribute;
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofe3dlathe.cxx b/svx/source/sdr/contact/viewcontactofe3dlathe.cxx
new file mode 100644
index 000000000000..ca97545e504f
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofe3dlathe.cxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofe3dlathe.hxx>
+#include <svx/lathe3d.hxx>
+#include <drawinglayer/primitive3d/sdrlatheprimitive3d.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive3d/sdrattributecreator3d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfE3dLathe::ViewContactOfE3dLathe(E3dLatheObj& rLathe)
+ : ViewContactOfE3d(rLathe)
+ {
+ }
+
+ ViewContactOfE3dLathe::~ViewContactOfE3dLathe()
+ {
+ }
+
+ drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dLathe::createViewIndependentPrimitive3DSequence() const
+ {
+ drawinglayer::primitive3d::Primitive3DSequence xRetval;
+ const SfxItemSet& rItemSet = GetE3dLatheObj().GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineFillShadowAttribute3D aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowAttribute(rItemSet, false));
+
+ // get extrude geometry
+ const basegfx::B2DPolyPolygon aPolyPolygon(GetE3dLatheObj().GetPolyPoly2D());
+
+ // get 3D Object Attributes
+ drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet);
+
+ // calculate texture size. Use the polygon length of the longest polygon for
+ // height and the rotated radius for width (using polygon center) to get a good
+ // texture mapping
+ const sal_uInt32 nPolygonCount(aPolyPolygon.count());
+ double fPolygonMaxLength(0.0);
+
+ for(sal_uInt32 a(0); a < nPolygonCount; a++)
+ {
+ const basegfx::B2DPolygon aCandidate(aPolyPolygon.getB2DPolygon(a));
+ const double fPolygonLength(basegfx::tools::getLength(aCandidate));
+ fPolygonMaxLength = std::max(fPolygonMaxLength, fPolygonLength);
+ }
+
+ const basegfx::B2DRange aPolyPolygonRange(basegfx::tools::getRange(aPolyPolygon));
+ const basegfx::B2DVector aTextureSize(
+ F_PI * fabs(aPolyPolygonRange.getCenter().getX()), // PI * d
+ fPolygonMaxLength);
+
+ // get more data
+ const sal_uInt32 nHorizontalSegments(GetE3dLatheObj().GetHorizontalSegments());
+ const sal_uInt32 nVerticalSegments(GetE3dLatheObj().GetVerticalSegments());
+ const double fDiagonal((double)GetE3dLatheObj().GetPercentDiagonal() / 100.0);
+ const double fBackScale((double)GetE3dLatheObj().GetBackScale() / 100.0);
+ const double fRotation(((double)GetE3dLatheObj().GetEndAngle() / 1800.0) * F_PI);
+ const bool bSmoothNormals(GetE3dLatheObj().GetSmoothNormals()); // Plane itself
+ const bool bSmoothLids(GetE3dLatheObj().GetSmoothLids()); // Front/back
+ const bool bCharacterMode(GetE3dLatheObj().GetCharacterMode());
+ const bool bCloseFront(GetE3dLatheObj().GetCloseFront());
+ const bool bCloseBack(GetE3dLatheObj().GetCloseBack());
+
+ // create primitive and add
+ const basegfx::B3DHomMatrix aWorldTransform;
+ const drawinglayer::primitive3d::Primitive3DReference xReference(
+ new drawinglayer::primitive3d::SdrLathePrimitive3D(
+ aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute,
+ aPolyPolygon, nHorizontalSegments, nVerticalSegments,
+ fDiagonal, fBackScale, fRotation,
+ bSmoothNormals, true, bSmoothLids, bCharacterMode, bCloseFront, bCloseBack));
+ xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
+
+ // delete 3D Object Attributes
+ delete pSdr3DObjectAttribute;
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofe3dpolygon.cxx b/svx/source/sdr/contact/viewcontactofe3dpolygon.cxx
new file mode 100644
index 000000000000..33c6711c01cb
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofe3dpolygon.cxx
@@ -0,0 +1,189 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofe3dpolygon.hxx>
+#include <svx/polygn3d.hxx>
+#include <drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive3d/sdrattributecreator3d.hxx>
+#include <basegfx/polygon/b3dpolygon.hxx>
+#include <basegfx/polygon/b3dpolypolygontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfE3dPolygon::ViewContactOfE3dPolygon(E3dPolygonObj& rPolygon)
+ : ViewContactOfE3d(rPolygon)
+ {
+ }
+
+ ViewContactOfE3dPolygon::~ViewContactOfE3dPolygon()
+ {
+ }
+
+ drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dPolygon::createViewIndependentPrimitive3DSequence() const
+ {
+ drawinglayer::primitive3d::Primitive3DSequence xRetval;
+ const SfxItemSet& rItemSet = GetE3dPolygonObj().GetMergedItemSet();
+ const bool bSuppressFill(GetE3dPolygonObj().GetLineOnly());
+ const drawinglayer::attribute::SdrLineFillShadowAttribute3D aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowAttribute(rItemSet, bSuppressFill));
+
+ // get extrude geometry
+ basegfx::B3DPolyPolygon aPolyPolygon3D(GetE3dPolygonObj().GetPolyPolygon3D());
+ const basegfx::B3DPolyPolygon aPolyNormals3D(GetE3dPolygonObj().GetPolyNormals3D());
+ const basegfx::B2DPolyPolygon aPolyTexture2D(GetE3dPolygonObj().GetPolyTexture2D());
+ const bool bNormals(aPolyNormals3D.count() && aPolyNormals3D.count() == aPolyPolygon3D.count());
+ const bool bTexture(aPolyTexture2D.count() && aPolyTexture2D.count() == aPolyPolygon3D.count());
+
+ if(bNormals || bTexture)
+ {
+ for(sal_uInt32 a(0L); a < aPolyPolygon3D.count(); a++)
+ {
+ basegfx::B3DPolygon aCandidate3D(aPolyPolygon3D.getB3DPolygon(a));
+ basegfx::B3DPolygon aNormals3D;
+ basegfx::B2DPolygon aTexture2D;
+
+ if(bNormals)
+ {
+ aNormals3D = aPolyNormals3D.getB3DPolygon(a);
+ }
+
+ if(bTexture)
+ {
+ aTexture2D = aPolyTexture2D.getB2DPolygon(a);
+ }
+
+ for(sal_uInt32 b(0L); b < aCandidate3D.count(); b++)
+ {
+ if(bNormals)
+ {
+ sal_uInt32 nNormalCount = aNormals3D.count();
+ if( b < nNormalCount )
+ aCandidate3D.setNormal(b, aNormals3D.getB3DPoint(b));
+ else if( nNormalCount > 0 )
+ aCandidate3D.setNormal(b, aNormals3D.getB3DPoint(0));
+ }
+ if(bTexture)
+ {
+ sal_uInt32 nTextureCount = aTexture2D.count();
+ if( b < nTextureCount )
+ aCandidate3D.setTextureCoordinate(b, aTexture2D.getB2DPoint(b));
+ else if( nTextureCount > 0 )
+ aCandidate3D.setTextureCoordinate(b, aTexture2D.getB2DPoint(0));
+ }
+ }
+
+ aPolyPolygon3D.setB3DPolygon(a, aCandidate3D);
+ }
+ }
+
+ // get 3D Object Attributes
+ drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet);
+
+ // calculate texture size
+ basegfx::B2DVector aTextureSize(1.0, 1.0);
+
+ if(bTexture)
+ {
+ // #i98314#
+ // create texture size from object's size
+ const basegfx::B3DRange aObjectRange(basegfx::tools::getRange(aPolyPolygon3D));
+
+ double fWidth(0.0);
+ double fHeight(0.0);
+
+ // this is a polygon object, so Width/Height and/or Depth may be zero (e.g. left
+ // wall of chart). Take this into account
+ if(basegfx::fTools::equalZero(aObjectRange.getWidth()))
+ {
+ // width is zero, use height and depth
+ fWidth = aObjectRange.getHeight();
+ fHeight = aObjectRange.getDepth();
+ }
+ else if(basegfx::fTools::equalZero(aObjectRange.getHeight()))
+ {
+ // height is zero, use width and depth
+ fWidth = aObjectRange.getWidth();
+ fHeight = aObjectRange.getDepth();
+ }
+ else
+ {
+ // use width and height
+ fWidth = aObjectRange.getWidth();
+ fHeight = aObjectRange.getHeight();
+ }
+
+ if(basegfx::fTools::lessOrEqual(fWidth, 0.0) ||basegfx::fTools::lessOrEqual(fHeight, 0.0))
+ {
+ // no texture; fallback to very small size
+ aTextureSize.setX(0.01);
+ aTextureSize.setY(0.01);
+ }
+ else
+ {
+ aTextureSize.setX(fWidth);
+ aTextureSize.setY(fHeight);
+ }
+ }
+
+ // #i98295#
+ // unfortunately, this SdrObject type which allows a free 3d geometry definition was defined
+ // wrong topologically in relation to it's plane normal and 3D visibility when it was invented
+ // a long time ago. Since the API allows creation of this SDrObject type, it is not possible to
+ // simply change this definition. Only the chart should use it, and at least this object type
+ // only exists at Runtime (is not saved and/or loaded in any FileFormat). Still someone external
+ // may have used it in it's API. To not risk wrong 3D lightings, i have to switch the orientation
+ // of the polygon here
+ aPolyPolygon3D.flip();
+
+ // create primitive and add
+ const basegfx::B3DHomMatrix aWorldTransform;
+ const drawinglayer::primitive3d::Primitive3DReference xReference(
+ new drawinglayer::primitive3d::SdrPolyPolygonPrimitive3D(
+ aPolyPolygon3D, aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute));
+ xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
+
+ // delete 3D Object Attributes
+ delete pSdr3DObjectAttribute;
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofe3dscene.cxx b/svx/source/sdr/contact/viewcontactofe3dscene.cxx
new file mode 100644
index 000000000000..47999b47720f
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofe3dscene.cxx
@@ -0,0 +1,481 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+#include <svx/polysc3d.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/contact/viewobjectcontactofe3dscene.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/range/b3drange.hxx>
+#include <drawinglayer/primitive3d/baseprimitive3d.hxx>
+#include <svx/sdr/contact/viewcontactofe3d.hxx>
+#include <drawinglayer/primitive2d/sceneprimitive2d.hxx>
+#include <drawinglayer/primitive3d/transformprimitive3d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace
+{
+ // pActiveVC is only true if ghosted is still activated and maybe needs to be switched off in this path
+ void createSubPrimitive3DVector(
+ const sdr::contact::ViewContact& rCandidate,
+ drawinglayer::primitive3d::Primitive3DSequence& o_rAllTarget,
+ drawinglayer::primitive3d::Primitive3DSequence* o_pVisibleTarget,
+ const SetOfByte* pVisibleLayerSet,
+ const bool bTestSelectedVisibility)
+ {
+ const sdr::contact::ViewContactOfE3dScene* pViewContactOfE3dScene = dynamic_cast< const sdr::contact::ViewContactOfE3dScene* >(&rCandidate);
+
+ if(pViewContactOfE3dScene)
+ {
+ const sal_uInt32 nChildrenCount(rCandidate.GetObjectCount());
+
+ if(nChildrenCount)
+ {
+ // provide new collection sequences
+ drawinglayer::primitive3d::Primitive3DSequence aNewAllTarget;
+ drawinglayer::primitive3d::Primitive3DSequence aNewVisibleTarget;
+
+ // add children recursively
+ for(sal_uInt32 a(0L); a < nChildrenCount; a++)
+ {
+ createSubPrimitive3DVector(
+ rCandidate.GetViewContact(a),
+ aNewAllTarget,
+ o_pVisibleTarget ? &aNewVisibleTarget : 0,
+ pVisibleLayerSet,
+ bTestSelectedVisibility);
+ }
+
+ // create transform primitive for the created content combining content and transformtion
+ const drawinglayer::primitive3d::Primitive3DReference xReference(new drawinglayer::primitive3d::TransformPrimitive3D(
+ pViewContactOfE3dScene->GetE3dScene().GetTransform(),
+ aNewAllTarget));
+
+ // add created content to all target
+ drawinglayer::primitive3d::appendPrimitive3DReferenceToPrimitive3DSequence(o_rAllTarget, xReference);
+
+ // add created content to visibiel target if exists
+ if(o_pVisibleTarget)
+ {
+ drawinglayer::primitive3d::appendPrimitive3DReferenceToPrimitive3DSequence(*o_pVisibleTarget, xReference);
+ }
+ }
+ }
+ else
+ {
+ // access view independent representation of rCandidate
+ const sdr::contact::ViewContactOfE3d* pViewContactOfE3d = dynamic_cast< const sdr::contact::ViewContactOfE3d* >(&rCandidate);
+
+ if(pViewContactOfE3d)
+ {
+ drawinglayer::primitive3d::Primitive3DSequence xPrimitive3DSeq(pViewContactOfE3d->getViewIndependentPrimitive3DSequence());
+
+ if(xPrimitive3DSeq.hasElements())
+ {
+ // add to all target vector
+ drawinglayer::primitive3d::appendPrimitive3DSequenceToPrimitive3DSequence(o_rAllTarget, xPrimitive3DSeq);
+
+ if(o_pVisibleTarget)
+ {
+ // test visibility. Primitive is visible when both tests are true (AND)
+ bool bVisible(true);
+
+ if(pVisibleLayerSet)
+ {
+ // test layer visibility
+ const E3dObject& rE3dObject = pViewContactOfE3d->GetE3dObject();
+ const SdrLayerID aLayerID(rE3dObject.GetLayer());
+
+ bVisible = pVisibleLayerSet->IsSet(aLayerID);
+ }
+
+ if(bVisible && bTestSelectedVisibility)
+ {
+ // test selected visibility (see 3D View's DrawMarkedObj implementation)
+ const E3dObject& rE3dObject = pViewContactOfE3d->GetE3dObject();
+
+ bVisible = rE3dObject.GetSelected();
+ }
+
+ if(bVisible && o_pVisibleTarget)
+ {
+ // add to visible target vector
+ drawinglayer::primitive3d::appendPrimitive3DSequenceToPrimitive3DSequence(*o_pVisibleTarget, xPrimitive3DSeq);
+ }
+ }
+ }
+ }
+ }
+ }
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ // Create a Object-Specific ViewObjectContact, set ViewContact and
+ // ObjectContact. Always needs to return something.
+ ViewObjectContact& ViewContactOfE3dScene::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfE3dScene(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContactOfE3dScene::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ ViewContactOfE3dScene::ViewContactOfE3dScene(E3dScene& rScene)
+ : ViewContactOfSdrObj(rScene),
+ maViewInformation3D(),
+ maObjectTransformation(),
+ maSdrSceneAttribute(),
+ maSdrLightingAttribute()
+ {
+ }
+
+ void ViewContactOfE3dScene::createViewInformation3D(const basegfx::B3DRange& rContentRange)
+ {
+ basegfx::B3DHomMatrix aTransformation;
+ basegfx::B3DHomMatrix aOrientation;
+ basegfx::B3DHomMatrix aProjection;
+ basegfx::B3DHomMatrix aDeviceToView;
+
+ // create transformation (scene as group's transformation)
+ // For historical reasons, the outmost scene's transformation is handles as part of the
+ // view transformation. This means that the BoundRect of the contained 3D Objects is
+ // without that transformation and makes it necessary to NOT add the first scene to the
+ // Primitive3DSequence of contained objects.
+ {
+ aTransformation = GetE3dScene().GetTransform();
+ }
+
+ // create orientation (world to camera coordinate system)
+ {
+ // calculate orientation from VRP, VPN and VUV
+ const B3dCamera& rSceneCamera = GetE3dScene().GetCameraSet();
+ const basegfx::B3DPoint aVRP(rSceneCamera.GetVRP());
+ const basegfx::B3DVector aVPN(rSceneCamera.GetVRP());
+ const basegfx::B3DVector aVUV(rSceneCamera.GetVUV());
+
+ aOrientation.orientation(aVRP, aVPN, aVUV);
+ }
+
+ // create projection (camera coordinate system to relative 2d where X,Y and Z are [0.0 .. 1.0])
+ {
+ const basegfx::B3DHomMatrix aWorldToCamera(aOrientation * aTransformation);
+ basegfx::B3DRange aCameraRange(rContentRange);
+ aCameraRange.transform(aWorldToCamera);
+
+ // remember Z-Values, but change orientation
+ const double fMinZ(-aCameraRange.getMaxZ());
+ const double fMaxZ(-aCameraRange.getMinZ());
+
+ // construct temorary matrix from world to device. Use unit values here to measure expansion
+ basegfx::B3DHomMatrix aWorldToDevice(aWorldToCamera);
+ const drawinglayer::attribute::SdrSceneAttribute& rSdrSceneAttribute = getSdrSceneAttribute();
+
+ if(::com::sun::star::drawing::ProjectionMode_PERSPECTIVE == rSdrSceneAttribute.getProjectionMode())
+ {
+ aWorldToDevice.frustum(-1.0, 1.0, -1.0, 1.0, fMinZ, fMaxZ);
+ }
+ else
+ {
+ aWorldToDevice.ortho(-1.0, 1.0, -1.0, 1.0, fMinZ, fMaxZ);
+ }
+
+ // create B3DRange in device. This will create the real used ranges
+ // in camera space. Do not use the Z-Values, though.
+ basegfx::B3DRange aDeviceRange(rContentRange);
+ aDeviceRange.transform(aWorldToDevice);
+
+ // set projection
+ if(::com::sun::star::drawing::ProjectionMode_PERSPECTIVE == rSdrSceneAttribute.getProjectionMode())
+ {
+ aProjection.frustum(
+ aDeviceRange.getMinX(), aDeviceRange.getMaxX(),
+ aDeviceRange.getMinY(), aDeviceRange.getMaxY(),
+ fMinZ, fMaxZ);
+ }
+ else
+ {
+ aProjection.ortho(
+ aDeviceRange.getMinX(), aDeviceRange.getMaxX(),
+ aDeviceRange.getMinY(), aDeviceRange.getMaxY(),
+ fMinZ, fMaxZ);
+ }
+ }
+
+ // create device to view transform
+ {
+ // create standard deviceToView projection for geometry
+ // input is [-1.0 .. 1.0] in X,Y and Z. bring to [0.0 .. 1.0]. Also
+ // necessary to flip Y due to screen orientation
+ // Z is not needed, but will also be brought to [0.0 .. 1.0]
+ aDeviceToView.scale(0.5, -0.5, 0.5);
+ aDeviceToView.translate(0.5, 0.5, 0.5);
+ }
+
+ const uno::Sequence< beans::PropertyValue > aEmptyProperties;
+ maViewInformation3D = drawinglayer::geometry::ViewInformation3D(
+ aTransformation, aOrientation, aProjection,
+ aDeviceToView, 0.0, aEmptyProperties);
+ }
+
+ void ViewContactOfE3dScene::createObjectTransformation()
+ {
+ // create 2d Object Transformation from relative point in 2d scene to world
+ const Rectangle& rRectangle = GetE3dScene().GetSnapRect();
+
+ maObjectTransformation.set(0, 0, rRectangle.getWidth());
+ maObjectTransformation.set(1, 1, rRectangle.getHeight());
+ maObjectTransformation.set(0, 2, rRectangle.Left());
+ maObjectTransformation.set(1, 2, rRectangle.Top());
+ }
+
+ void ViewContactOfE3dScene::createSdrSceneAttribute()
+ {
+ const SfxItemSet& rItemSet = GetE3dScene().GetMergedItemSet();
+ maSdrSceneAttribute = drawinglayer::primitive2d::createNewSdrSceneAttribute(rItemSet);
+ }
+
+ void ViewContactOfE3dScene::createSdrLightingAttribute()
+ {
+ const SfxItemSet& rItemSet = GetE3dScene().GetMergedItemSet();
+ maSdrLightingAttribute = drawinglayer::primitive2d::createNewSdrLightingAttribute(rItemSet);
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3dScene::createScenePrimitive2DSequence(
+ const SetOfByte* pLayerVisibility) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const sal_uInt32 nChildrenCount(GetObjectCount());
+
+ if(nChildrenCount)
+ {
+ // create 3d scene primitive with visible content tested against rLayerVisibility
+ drawinglayer::primitive3d::Primitive3DSequence aAllSequence;
+ drawinglayer::primitive3d::Primitive3DSequence aVisibleSequence;
+ const bool bTestLayerVisibility(0 != pLayerVisibility);
+ const bool bTestSelectedVisibility(GetE3dScene().GetDrawOnlySelected());
+ const bool bTestVisibility(bTestLayerVisibility || bTestSelectedVisibility);
+
+ // add children recursively. Do NOT start with (*this), this would create
+ // a 3D transformPrimitive for the start scene. While this is theoretically not
+ // a bad thing, for historical reasons the transformation of the outmost scene
+ // is seen as part of the ViewTransformation (see text in createViewInformation3D)
+ for(sal_uInt32 a(0L); a < nChildrenCount; a++)
+ {
+ createSubPrimitive3DVector(
+ GetViewContact(a),
+ aAllSequence,
+ bTestLayerVisibility ? &aVisibleSequence : 0,
+ bTestLayerVisibility ? pLayerVisibility : 0,
+ bTestSelectedVisibility);
+ }
+
+ const sal_uInt32 nAllSize(aAllSequence.hasElements() ? aAllSequence.getLength() : 0);
+ const sal_uInt32 nVisibleSize(aVisibleSequence.hasElements() ? aVisibleSequence.getLength() : 0);
+
+ if((bTestVisibility && nVisibleSize) || nAllSize)
+ {
+ // for getting the 3D range using getB3DRangeFromPrimitive3DSequence a ViewInformation3D
+ // needs to be given for evtl. decompositions. At the same time createViewInformation3D
+ // currently is based on creating the target-ViewInformation3D using a given range. To
+ // get the true range, use a neutral ViewInformation3D here. This leaves all matrices
+ // on identity and the time on 0.0.
+ const uno::Sequence< beans::PropertyValue > aEmptyProperties;
+ const drawinglayer::geometry::ViewInformation3D aNeutralViewInformation3D(aEmptyProperties);
+ const basegfx::B3DRange aContentRange(
+ drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(aAllSequence, aNeutralViewInformation3D));
+
+ // create 2d primitive 3dscene with generated sub-list from collector
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::ScenePrimitive2D(
+ bTestVisibility ? aVisibleSequence : aAllSequence,
+ getSdrSceneAttribute(),
+ getSdrLightingAttribute(),
+ getObjectTransformation(),
+ getViewInformation3D(aContentRange)));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ }
+
+ // always append an invisible outline for the cases where no visible content exists
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
+ drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
+ false, getObjectTransformation()));
+
+ return xRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfE3dScene::createViewIndependentPrimitive2DSequence() const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ if(GetObjectCount())
+ {
+ // create a default ScenePrimitive2D (without visibility test of members)
+ xRetval = createScenePrimitive2DSequence(0);
+ }
+
+ return xRetval;
+ }
+
+ void ViewContactOfE3dScene::ActionChanged()
+ {
+ // call parent
+ ViewContactOfSdrObj::ActionChanged();
+
+ // mark locally cached values as invalid
+ maViewInformation3D = drawinglayer::geometry::ViewInformation3D();
+ maObjectTransformation.identity();
+ maSdrSceneAttribute = drawinglayer::attribute::SdrSceneAttribute();
+ maSdrLightingAttribute = drawinglayer::attribute::SdrLightingAttribute();
+ }
+
+ const drawinglayer::geometry::ViewInformation3D& ViewContactOfE3dScene::getViewInformation3D() const
+ {
+ if(maViewInformation3D.isDefault())
+ {
+ // this version will create the content range on demand locally and thus is less
+ // performant than the other one. Since the information is buffered the planned
+ // behaviour is that the version with the given range is used initially.
+ basegfx::B3DRange aContentRange(getAllContentRange3D());
+
+ if(aContentRange.isEmpty())
+ {
+ // empty scene, no 3d action should be necessary. Prepare some
+ // fallback size
+ OSL_ENSURE(false, "No need to get ViewInformation3D from an empty scene (!)");
+ aContentRange.expand(basegfx::B3DPoint(-100.0, -100.0, -100.0));
+ aContentRange.expand(basegfx::B3DPoint( 100.0, 100.0, 100.0));
+ }
+
+ const_cast < ViewContactOfE3dScene* >(this)->createViewInformation3D(aContentRange);
+ }
+
+ return maViewInformation3D;
+ }
+
+ const drawinglayer::geometry::ViewInformation3D& ViewContactOfE3dScene::getViewInformation3D(const basegfx::B3DRange& rContentRange) const
+ {
+ if(maViewInformation3D.isDefault())
+ {
+ const_cast < ViewContactOfE3dScene* >(this)->createViewInformation3D(rContentRange);
+ }
+
+ return maViewInformation3D;
+ }
+
+ const basegfx::B2DHomMatrix& ViewContactOfE3dScene::getObjectTransformation() const
+ {
+ if(maObjectTransformation.isIdentity())
+ {
+ const_cast < ViewContactOfE3dScene* >(this)->createObjectTransformation();
+ }
+
+ return maObjectTransformation;
+ }
+
+ const drawinglayer::attribute::SdrSceneAttribute& ViewContactOfE3dScene::getSdrSceneAttribute() const
+ {
+ if(maSdrSceneAttribute.isDefault())
+ {
+ const_cast < ViewContactOfE3dScene* >(this)->createSdrSceneAttribute();
+ }
+
+ return maSdrSceneAttribute;
+ }
+
+ const drawinglayer::attribute::SdrLightingAttribute& ViewContactOfE3dScene::getSdrLightingAttribute() const
+ {
+ if(maSdrLightingAttribute.isDefault())
+ {
+ const_cast < ViewContactOfE3dScene* >(this)->createSdrLightingAttribute();
+ }
+
+ return maSdrLightingAttribute;
+ }
+
+ drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dScene::getAllPrimitive3DSequence() const
+ {
+ drawinglayer::primitive3d::Primitive3DSequence aAllPrimitive3DSequence;
+ const sal_uInt32 nChildrenCount(GetObjectCount());
+
+ // add children recursively. Do NOT start with (*this), this would create
+ // a 3D transformPrimitive for the start scene. While this is theoretically not
+ // a bad thing, for historical reasons the transformation of the outmost scene
+ // is seen as part of the ViewTransformation (see text in createViewInformation3D)
+ for(sal_uInt32 a(0L); a < nChildrenCount; a++)
+ {
+ createSubPrimitive3DVector(GetViewContact(a), aAllPrimitive3DSequence, 0, 0, false);
+ }
+
+ return aAllPrimitive3DSequence;
+ }
+
+ basegfx::B3DRange ViewContactOfE3dScene::getAllContentRange3D() const
+ {
+ const drawinglayer::primitive3d::Primitive3DSequence xAllSequence(getAllPrimitive3DSequence());
+ basegfx::B3DRange aAllContentRange3D;
+
+ if(xAllSequence.hasElements())
+ {
+ // for getting the 3D range using getB3DRangeFromPrimitive3DSequence a ViewInformation3D
+ // needs to be given for evtl. decompositions. Use a neutral ViewInformation3D here. This
+ // leaves all matrices on identity and the time on 0.0.
+ const uno::Sequence< beans::PropertyValue > aEmptyProperties;
+ const drawinglayer::geometry::ViewInformation3D aNeutralViewInformation3D(aEmptyProperties);
+
+ aAllContentRange3D = drawinglayer::primitive3d::getB3DRangeFromPrimitive3DSequence(xAllSequence, aNeutralViewInformation3D);
+ }
+
+ return aAllContentRange3D;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofe3dsphere.cxx b/svx/source/sdr/contact/viewcontactofe3dsphere.cxx
new file mode 100644
index 000000000000..f08462bcd746
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofe3dsphere.cxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofe3dsphere.hxx>
+#include <svx/sphere3d.hxx>
+#include <drawinglayer/primitive3d/sdrsphereprimitive3d.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive3d/sdrattributecreator3d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfE3dSphere::ViewContactOfE3dSphere(E3dSphereObj& rSphere)
+ : ViewContactOfE3d(rSphere)
+ {
+ }
+
+ ViewContactOfE3dSphere::~ViewContactOfE3dSphere()
+ {
+ }
+
+ drawinglayer::primitive3d::Primitive3DSequence ViewContactOfE3dSphere::createViewIndependentPrimitive3DSequence() const
+ {
+ drawinglayer::primitive3d::Primitive3DSequence xRetval;
+ const SfxItemSet& rItemSet = GetE3dSphereObj().GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineFillShadowAttribute3D aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowAttribute(rItemSet, false));
+
+ // get sphere center and size for geometry
+ basegfx::B3DRange aSphereRange;
+ const basegfx::B3DPoint aSpherePosition(GetE3dSphereObj().Center());
+ const basegfx::B3DVector aSphereSize(GetE3dSphereObj().Size());
+ basegfx::B3DHomMatrix aWorldTransform;
+
+ aWorldTransform.translate(-0.5, -0.5, -0.5);
+ aWorldTransform.scale(aSphereSize.getX(), aSphereSize.getY(), aSphereSize.getZ());
+ aWorldTransform.translate(aSpherePosition.getX(), aSpherePosition.getY(), aSpherePosition.getZ());
+
+ // get 3D Object Attributes
+ drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet);
+
+ // get segment count
+ const sal_uInt32 nHorizontalSegments(GetE3dSphereObj().GetHorizontalSegments());
+ const sal_uInt32 nVerticalSegments(GetE3dSphereObj().GetVerticalSegments());
+
+ // calculate texture size, use radii for (2 * PI * r) to get a perfect
+ // mapping on the sphere
+ const basegfx::B2DVector aTextureSize(
+ F_PI * ((aSphereSize.getX() + aSphereSize.getZ()) / 2.0), // PI * d
+ F_PI2 * aSphereSize.getY()); // half outline, (PI * d)/2 -> PI/2 * d
+
+ // create primitive and add
+ const drawinglayer::primitive3d::Primitive3DReference xReference(
+ new drawinglayer::primitive3d::SdrSpherePrimitive3D(
+ aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute,
+ nHorizontalSegments, nVerticalSegments));
+ xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
+
+ // delete 3D Object Attributes
+ delete pSdr3DObjectAttribute;
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx
new file mode 100644
index 000000000000..4397b7ec48e5
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx
@@ -0,0 +1,466 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactofgraphic.hxx>
+#include <svx/sdr/contact/viewobjectcontactofgraphic.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svl/itemset.hxx>
+
+#ifndef ITEMID_GRF_CROP
+#define ITEMID_GRF_CROP 0
+#endif
+
+#include <svx/sdgcpitm.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/sdr/event/eventhandler.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/primitive2d/sdrgrafprimitive2d.hxx>
+#include "svdstr.hrc"
+#include <svdglob.hxx>
+#include <vcl/svapp.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/colritem.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ // Create a Object-Specific ViewObjectContact, set ViewContact and
+ // ObjectContact. Always needs to return something.
+ ViewObjectContact& ViewContactOfGraphic::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfGraphic(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ ViewContactOfGraphic::ViewContactOfGraphic(SdrGrafObj& rGrafObj)
+ : ViewContactOfTextObj(rGrafObj)
+ {
+ }
+
+ ViewContactOfGraphic::~ViewContactOfGraphic()
+ {
+ }
+
+ void ViewContactOfGraphic::flushGraphicObjects()
+ {
+ // #i102380# The graphic is swapped out. To let that have an effect ist is necessary to
+ // delete copies of the GraphicObject which are not swapped out and have no SwapHandler set
+ // (this is what happnes when the GraphicObject gets copied to a SdrGrafPrimitive2D). This
+ // is best achieved for the VC by clearing the local decomposition cache. It would be possible
+ // to also do this for the VOC cache, but that VOCs exist exactly expresss that the object
+ // gets visualised, so this would be wrong.
+ flushViewIndependentPrimitive2DSequence();
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createVIP2DSForPresObj(
+ const basegfx::B2DHomMatrix& rObjectMatrix,
+ const drawinglayer::attribute::SdrLineFillShadowTextAttribute& rAttribute,
+ const GraphicAttr& rLocalGrafInfo) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ GraphicObject aEmptyGraphicObject;
+ GraphicAttr aEmptyGraphicAttr;
+
+ // SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts
+ const drawinglayer::primitive2d::Primitive2DReference xReferenceA(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
+ rObjectMatrix,
+ rAttribute,
+ aEmptyGraphicObject,
+ aEmptyGraphicAttr));
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReferenceA, 1);
+
+ // SdrGrafPrimitive2D with content (which is the preview graphic) scaled to smaller size and
+ // without attributes
+ basegfx::B2DHomMatrix aSmallerMatrix;
+
+ // #i94431# for some reason, i forgot to take the PrefMapMode of the graphic
+ // into account. Since EmptyPresObj's are only used in Draw/Impress, it is
+ // safe to assume 100th mm as target.
+ Size aPrefSize(GetGrafObject().GetGrafPrefSize());
+
+ if(MAP_PIXEL == GetGrafObject().GetGrafPrefMapMode().GetMapUnit())
+ {
+ aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MAP_100TH_MM);
+ }
+ else
+ {
+ aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, GetGrafObject().GetGrafPrefMapMode(), MAP_100TH_MM);
+ }
+
+ // decompose object matrix to get single values
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ const double fOffsetX((aScale.getX() - aPrefSize.getWidth()) / 2.0);
+ const double fOffsetY((aScale.getY() - aPrefSize.getHeight()) / 2.0);
+
+ if(basegfx::fTools::moreOrEqual(fOffsetX, 0.0) && basegfx::fTools::moreOrEqual(fOffsetY, 0.0))
+ {
+ // create the EmptyPresObj fallback visualisation. The fallback graphic
+ // is already provided in rGraphicObject in this case, use it
+ aSmallerMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aPrefSize.getWidth(), aPrefSize.getHeight(), fOffsetX, fOffsetY);
+ aSmallerMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate)
+ * aSmallerMatrix;
+
+ const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false);
+ const drawinglayer::primitive2d::Primitive2DReference xReferenceB(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
+ aSmallerMatrix,
+ drawinglayer::attribute::SdrLineFillShadowTextAttribute(),
+ rGraphicObject,
+ rLocalGrafInfo));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReferenceB);
+ }
+
+ return xRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createVIP2DSForDraft(
+ const basegfx::B2DHomMatrix& rObjectMatrix,
+ const drawinglayer::attribute::SdrLineFillShadowTextAttribute& rAttribute) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ GraphicObject aEmptyGraphicObject;
+ GraphicAttr aEmptyGraphicAttr;
+
+ // SdrGrafPrimitive2D without content in original size which carries all eventual attributes and texts
+ const drawinglayer::primitive2d::Primitive2DReference xReferenceA(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
+ rObjectMatrix,
+ rAttribute,
+ aEmptyGraphicObject,
+ aEmptyGraphicAttr));
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReferenceA, 1);
+
+ if(rAttribute.getLine().isDefault())
+ {
+ // create a surrounding frame when no linestyle given
+ const Color aColor(Application::GetSettings().GetStyleSettings().GetShadowColor());
+ const basegfx::BColor aBColor(aColor.getBColor());
+ basegfx::B2DPolygon aOutline(basegfx::tools::createUnitPolygon());
+ aOutline.transform(rObjectMatrix);
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
+ drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
+ aOutline,
+ aBColor)));
+ }
+
+ // decompose object matrix to get single values
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // define a distance value, used for distance from bitmap to borders and from bitmap
+ // to text, too (2 mm)
+ const double fDistance(200.0);
+
+ // consume borders from values
+ aScale.setX(std::max(0.0, aScale.getX() - (2.0 * fDistance)));
+ aScale.setY(std::max(0.0, aScale.getY() - (2.0 * fDistance)));
+ aTranslate.setX(aTranslate.getX() + fDistance);
+ aTranslate.setY(aTranslate.getY() + fDistance);
+
+ // draw a draft bitmap
+ const Bitmap aDraftBitmap(ResId(BMAP_GrafikEi, *ImpGetResMgr()));
+
+ if(!aDraftBitmap.IsEmpty())
+ {
+ Size aPrefSize(aDraftBitmap.GetPrefSize());
+
+ if(MAP_PIXEL == aDraftBitmap.GetPrefMapMode().GetMapUnit())
+ {
+ aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aDraftBitmap.GetSizePixel(), MAP_100TH_MM);
+ }
+ else
+ {
+ aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, aDraftBitmap.GetPrefMapMode(), MAP_100TH_MM);
+ }
+
+ const double fBitmapScaling(2.0);
+ const double fWidth(aPrefSize.getWidth() * fBitmapScaling);
+ const double fHeight(aPrefSize.getHeight() * fBitmapScaling);
+
+ if(basegfx::fTools::more(fWidth, 1.0)
+ && basegfx::fTools::more(fHeight, 1.0)
+ && basegfx::fTools::lessOrEqual(fWidth, aScale.getX())
+ && basegfx::fTools::lessOrEqual(fHeight, aScale.getY()))
+ {
+ const basegfx::B2DHomMatrix aBitmapMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ fWidth, fHeight, fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
+ drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::BitmapPrimitive2D(
+ BitmapEx(aDraftBitmap),
+ aBitmapMatrix)));
+
+ // consume bitmap size in X
+ aScale.setX(std::max(0.0, aScale.getX() - (fWidth + fDistance)));
+ aTranslate.setX(aTranslate.getX() + fWidth + fDistance);
+ }
+ }
+
+ // Build the text for the draft object
+ XubString aDraftText = GetGrafObject().GetFileName();
+
+ if(!aDraftText.Len())
+ {
+ aDraftText = GetGrafObject().GetName();
+ aDraftText.AppendAscii(" ...");
+ }
+
+ if(aDraftText.Len() && GetGrafObject().GetModel())
+ {
+ // #i103255# Goal is to produce TextPrimitives which hold the given text as
+ // BlockText in the available space. It would be very tricky to do
+ // an own word wrap/line layout here.
+ // Using SdrBlockTextPrimitive2D OTOH is critical since it internally
+ // uses the SdrObject it references. To solve this, create a temp
+ // SdrObject with Attributes and Text, generate a SdrBlockTextPrimitive2D
+ // directly and immediately decompose it. After that, it is no longer
+ // needed and can be deleted.
+
+ // create temp RectObj as TextObj and set needed attributes
+ SdrRectObj aRectObj(OBJ_TEXT);
+ aRectObj.SetModel(GetGrafObject().GetModel());
+ aRectObj.NbcSetText(aDraftText);
+ aRectObj.SetMergedItem(SvxColorItem(Color(COL_LIGHTRED), EE_CHAR_COLOR));
+
+ // get SdrText and OPO
+ SdrText* pSdrText = aRectObj.getText(0);
+ OutlinerParaObject* pOPO = aRectObj.GetOutlinerParaObject();
+
+ if(pSdrText && pOPO)
+ {
+ // directly use the remaining space as TextRangeTransform
+ const basegfx::B2DHomMatrix aTextRangeTransform(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aScale, fShearX, fRotate, aTranslate));
+
+ // directly create temp SdrBlockTextPrimitive2D
+ drawinglayer::primitive2d::SdrBlockTextPrimitive2D aBlockTextPrimitive(
+ pSdrText,
+ *pOPO,
+ aTextRangeTransform,
+ SDRTEXTHORZADJUST_LEFT,
+ SDRTEXTVERTADJUST_TOP,
+ false,
+ false,
+ false,
+ false,
+ false);
+
+ // decompose immediately with neutral ViewInformation. This will
+ // layout the text to more simple TextPrimitives from drawinglayer
+ const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0);
+
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
+ xRetval,
+ aBlockTextPrimitive.get2DDecomposition(aViewInformation2D));
+ }
+ }
+
+ return xRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGraphic::createViewIndependentPrimitive2DSequence() const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const SfxItemSet& rItemSet = GetGrafObject().GetMergedItemSet();
+ drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
+ rItemSet,
+ GetGrafObject().getText(0)));
+
+ // create and fill GraphicAttr
+ GraphicAttr aLocalGrafInfo;
+ const sal_uInt16 nTrans(((SdrGrafTransparenceItem&)rItemSet.Get(SDRATTR_GRAFTRANSPARENCE)).GetValue());
+ const SdrGrafCropItem& rCrop((const SdrGrafCropItem&)rItemSet.Get(SDRATTR_GRAFCROP));
+ aLocalGrafInfo.SetLuminance(((SdrGrafLuminanceItem&)rItemSet.Get(SDRATTR_GRAFLUMINANCE)).GetValue());
+ aLocalGrafInfo.SetContrast(((SdrGrafContrastItem&)rItemSet.Get(SDRATTR_GRAFCONTRAST)).GetValue());
+ aLocalGrafInfo.SetChannelR(((SdrGrafRedItem&)rItemSet.Get(SDRATTR_GRAFRED)).GetValue());
+ aLocalGrafInfo.SetChannelG(((SdrGrafGreenItem&)rItemSet.Get(SDRATTR_GRAFGREEN)).GetValue());
+ aLocalGrafInfo.SetChannelB(((SdrGrafBlueItem&)rItemSet.Get(SDRATTR_GRAFBLUE)).GetValue());
+ aLocalGrafInfo.SetGamma(((SdrGrafGamma100Item&)rItemSet.Get(SDRATTR_GRAFGAMMA)).GetValue() * 0.01);
+ aLocalGrafInfo.SetTransparency((BYTE)::basegfx::fround(Min(nTrans, (USHORT)100) * 2.55));
+ aLocalGrafInfo.SetInvert(((SdrGrafInvertItem&)rItemSet.Get(SDRATTR_GRAFINVERT)).GetValue());
+ aLocalGrafInfo.SetDrawMode(((SdrGrafModeItem&)rItemSet.Get(SDRATTR_GRAFMODE)).GetValue());
+ aLocalGrafInfo.SetCrop(rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom());
+
+ if(aAttribute.isDefault() && 255L != aLocalGrafInfo.GetTransparency())
+ {
+ // no fill, no line, no text (invisible), but the graphic content is visible.
+ // Create evtl. shadow for content which was not created by createNewSdrLineFillShadowTextAttribute yet
+ const drawinglayer::attribute::SdrShadowAttribute aShadow(
+ drawinglayer::primitive2d::createNewSdrShadowAttribute(rItemSet));
+
+ if(!aShadow.isDefault())
+ {
+ // create new attribute set if indeed shadow is used
+ aAttribute = drawinglayer::attribute::SdrLineFillShadowTextAttribute(
+ aAttribute.getLine(),
+ aAttribute.getFill(),
+ aAttribute.getLineStartEnd(),
+ aShadow,
+ aAttribute.getFillFloatTransGradient(),
+ aAttribute.getText());
+ }
+ }
+
+ // take unrotated snap rect for position and size. Directly use model data, not getBoundRect() or getSnapRect()
+ // which will use the primitive data we just create in the near future
+ const Rectangle& rRectangle = GetGrafObject().GetGeoRect();
+ const ::basegfx::B2DRange aObjectRange(
+ rRectangle.Left(), rRectangle.Top(),
+ rRectangle.Right(), rRectangle.Bottom());
+
+ // look for mirroring
+ const GeoStat& rGeoStat(GetGrafObject().GetGeoStat());
+ const sal_Int32 nDrehWink(rGeoStat.nDrehWink);
+ const bool bRota180(18000 == nDrehWink);
+ const bool bMirrored(GetGrafObject().IsMirrored());
+ const sal_uInt16 nMirrorCase(bRota180 ? (bMirrored ? 3 : 4) : (bMirrored ? 2 : 1));
+ bool bHMirr((2 == nMirrorCase ) || (4 == nMirrorCase));
+ bool bVMirr((3 == nMirrorCase ) || (4 == nMirrorCase));
+
+ // set mirror flags at LocalGrafInfo. Take into account that the geometry in
+ // aObjectRange is already changed and rotated when bRota180 is used. To rebuild
+ // that old behaviour (as long as part of the model data), correct the H/V flags
+ // accordingly. The created bitmapPrimitive WILL use the rotation, too.
+ if(bRota180)
+ {
+ // if bRota180 which is used for vertical mirroring, the graphic will already be rotated
+ // by 180 degrees. To correct, switch off VMirror and invert HMirroring.
+ bHMirr = !bHMirr;
+ bVMirr = false;
+ }
+
+ if(bHMirr || bVMirr)
+ {
+ aLocalGrafInfo.SetMirrorFlags((bHMirr ? BMP_MIRROR_HORZ : 0)|(bVMirr ? BMP_MIRROR_VERT : 0));
+ }
+
+ // fill object matrix
+ const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
+ const double fRotate(nDrehWink ? (36000 - nDrehWink) * F_PI18000 : 0.0);
+ const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aObjectRange.getWidth(), aObjectRange.getHeight(),
+ fShearX, fRotate,
+ aObjectRange.getMinX(), aObjectRange.getMinY()));
+
+ // get the current, unchenged graphic obect from SdrGrafObj
+ const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false);
+
+ if(visualisationUsesPresObj())
+ {
+ // it's an EmptyPresObj, create the SdrGrafPrimitive2D without content and another scaled one
+ // with the content which is the placeholder graphic
+ xRetval = createVIP2DSForPresObj(aObjectMatrix, aAttribute, aLocalGrafInfo);
+ }
+ else if(visualisationUsesDraft())
+ {
+ // #i102380# The graphic is swapped out. To not force a swap-in here, there is a mechanism
+ // which shows a swapped-out-visualisation (which gets created here now) and an asynchronious
+ // visual update mechanism for swapped-out grapgics when they were loaded (see AsynchGraphicLoadingEvent
+ // and ViewObjectContactOfGraphic implementation). Not forcing the swap-in here allows faster
+ // (non-blocking) processing here and thus in the effect e.g. fast scrolling through pages
+ xRetval = createVIP2DSForDraft(aObjectMatrix, aAttribute);
+ }
+ else
+ {
+ // create primitive. Info: Calling the copy-constructor of GraphicObject in this
+ // SdrGrafPrimitive2D constructor will force a full swap-in of the graphic
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::SdrGrafPrimitive2D(
+ aObjectMatrix,
+ aAttribute,
+ rGraphicObject,
+ aLocalGrafInfo));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ // always append an invisible outline for the cases where no visible content exists
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
+ drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
+ false, aObjectMatrix));
+
+ return xRetval;
+ }
+
+ bool ViewContactOfGraphic::visualisationUsesPresObj() const
+ {
+ return GetGrafObject().IsEmptyPresObj();
+ }
+
+ bool ViewContactOfGraphic::visualisationUsesDraft() const
+ {
+ // no draft when already PresObj
+ if(visualisationUsesPresObj())
+ return false;
+
+ // draft when swapped out
+ const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false);
+ static bool bAllowReplacements(true);
+
+ if(rGraphicObject.IsSwappedOut() && bAllowReplacements)
+ return true;
+
+ // draft when no graphic
+ if(GRAPHIC_NONE == rGraphicObject.GetType() || GRAPHIC_DEFAULT == rGraphicObject.GetType())
+ return true;
+
+ return false;
+ }
+
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofgroup.cxx b/svx/source/sdr/contact/viewcontactofgroup.cxx
new file mode 100644
index 000000000000..b6a2cb846c69
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofgroup.cxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactofgroup.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/viewobjectcontactofgroup.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ // Create a Object-Specific ViewObjectContact, set ViewContact and
+ // ObjectContact. Always needs to return something.
+ ViewObjectContact& ViewContactOfGroup::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfGroup(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContactOfGroup::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ ViewContactOfGroup::ViewContactOfGroup(SdrObjGroup& rGroup)
+ : ViewContactOfSdrObj(rGroup)
+ {
+ }
+
+ ViewContactOfGroup::~ViewContactOfGroup()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGroup::createViewIndependentPrimitive2DSequence() const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const sal_uInt32 nObjectCount(GetObjectCount());
+
+ if(nObjectCount)
+ {
+ // collect all sub-primitives
+ for(sal_uInt32 a(0); a < nObjectCount; a++)
+ {
+ const ViewContact& rCandidate(GetViewContact(a));
+ const drawinglayer::primitive2d::Primitive2DSequence aCandSeq(rCandidate.getViewIndependentPrimitive2DSequence());
+
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, aCandSeq);
+ }
+ }
+ else
+ {
+ // append an invisible outline for the cases where no visible content exists
+ const Rectangle aCurrentBoundRect(GetSdrObjGroup().GetLastBoundRect());
+ const basegfx::B2DRange aCurrentRange(
+ aCurrentBoundRect.Left(), aCurrentBoundRect.Top(),
+ aCurrentBoundRect.Right(), aCurrentBoundRect.Bottom());
+
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
+ false, aCurrentRange));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx b/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx
new file mode 100644
index 000000000000..f26393811a4d
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofmasterpagedescriptor.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <vcl/timer.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <svx/sdr/contact/viewcontactofsdrpage.hxx>
+#include <svx/sdr/contact/viewobjectcontactofmasterpagedescriptor.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <svx/svdpage.hxx>
+#include <drawinglayer/attribute/sdrfillattribute.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/attribute/fillgradientattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfMasterPageDescriptor::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ return *(new ViewObjectContactOfMasterPageDescriptor(rObjectContact, *this));
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfMasterPageDescriptor::createViewIndependentPrimitive2DSequence() const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ drawinglayer::attribute::SdrFillAttribute aFill;
+ const SdrPageProperties* pCorrectProperties = GetMasterPageDescriptor().getCorrectSdrPageProperties();
+
+ if(pCorrectProperties)
+ {
+ // create page fill attributes when correct properties were identified
+ aFill = drawinglayer::primitive2d::createNewSdrFillAttribute(pCorrectProperties->GetItemSet());
+ }
+
+ if(!aFill.isDefault())
+ {
+ // direct model data is the page size, get and use it
+ const SdrPage& rOwnerPage = GetMasterPageDescriptor().GetOwnerPage();
+ const basegfx::B2DRange aInnerRange(
+ rOwnerPage.GetLftBorder(), rOwnerPage.GetUppBorder(),
+ rOwnerPage.GetWdt() - rOwnerPage.GetRgtBorder(),
+ rOwnerPage.GetHgt() - rOwnerPage.GetLwrBorder());
+ const basegfx::B2DPolygon aInnerPolgon(basegfx::tools::createPolygonFromRect(aInnerRange));
+ const basegfx::B2DHomMatrix aEmptyTransform;
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aInnerPolgon),
+ aEmptyTransform,
+ aFill,
+ drawinglayer::attribute::FillGradientAttribute()));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ return xRetval;
+ }
+
+ // basic constructor
+ ViewContactOfMasterPageDescriptor::ViewContactOfMasterPageDescriptor(sdr::MasterPageDescriptor& rDescriptor)
+ : ViewContact(),
+ mrMasterPageDescriptor(rDescriptor)
+ {
+ }
+
+ // The destructor.
+ ViewContactOfMasterPageDescriptor::~ViewContactOfMasterPageDescriptor()
+ {
+ }
+
+ sal_uInt32 ViewContactOfMasterPageDescriptor::GetObjectCount() const
+ {
+ return GetMasterPageDescriptor().GetUsedPage().GetObjCount();
+ }
+
+ ViewContact& ViewContactOfMasterPageDescriptor::GetViewContact(sal_uInt32 nIndex) const
+ {
+ return GetMasterPageDescriptor().GetUsedPage().GetObj(nIndex)->GetViewContact();
+ }
+
+ ViewContact* ViewContactOfMasterPageDescriptor::GetParentContact() const
+ {
+ return &(GetMasterPageDescriptor().GetOwnerPage().GetViewContact());
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofpageobj.cxx b/svx/source/sdr/contact/viewcontactofpageobj.cxx
new file mode 100644
index 000000000000..21d4d2a76a0c
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofpageobj.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactofpageobj.hxx>
+#include <svx/svdopage.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <vcl/outdev.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/viewobjectcontactofpageobj.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfPageObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfPageObj(rObjectContact, *this);
+ return *pRetval;
+ }
+
+ // Access to referenced page
+ const SdrPage* ViewContactOfPageObj::GetReferencedPage() const
+ {
+ return GetPageObj().GetReferencedPage();
+ }
+
+ ViewContactOfPageObj::ViewContactOfPageObj(SdrPageObj& rPageObj)
+ : ViewContactOfSdrObj(rPageObj)
+ {
+ }
+
+ ViewContactOfPageObj::~ViewContactOfPageObj()
+ {
+ }
+
+ // #i35972# React on changes of the object of this ViewContact
+ void ViewContactOfPageObj::ActionChanged()
+ {
+ static bool bIsInActionChange(false);
+
+ if(!bIsInActionChange)
+ {
+ // set recursion flag, see description in *.hxx
+ bIsInActionChange = true;
+
+ // call parent
+ ViewContactOfSdrObj::ActionChanged();
+
+ // reset recursion flag, see description in *.hxx
+ bIsInActionChange = false;
+ }
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageObj::createViewIndependentPrimitive2DSequence() const
+ {
+ // ceate graphical visualisation data. Since this is the view-independent version which should not be used,
+ // create a replacement graphic visualisation here. Use GetLastBoundRect to access the model data directly
+ // which is aOutRect for SdrPageObj.
+ const Rectangle aModelRectangle(GetPageObj().GetLastBoundRect());
+ const basegfx::B2DRange aModelRange(aModelRectangle.Left(), aModelRectangle.Top(), aModelRectangle.Right(), aModelRectangle.Bottom());
+ const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aModelRange));
+ const basegfx::BColor aYellow(1.0, 1.0, 0.0);
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aYellow));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx b/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx
new file mode 100644
index 000000000000..fb1676c08355
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofsdrcaptionobj.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// includes for special text box shadow (SC)
+
+#include <svl/itemset.hxx>
+#include <svx/xhatch.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xfltrit.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfSdrCaptionObj::ViewContactOfSdrCaptionObj(SdrCaptionObj& rCaptionObj)
+ : ViewContactOfSdrRectObj(rCaptionObj)
+ {
+ }
+
+ ViewContactOfSdrCaptionObj::~ViewContactOfSdrCaptionObj()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrCaptionObj::createViewIndependentPrimitive2DSequence() const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const SdrCaptionObj& rCaptionObj(GetCaptionObj());
+ const SfxItemSet& rItemSet = rCaptionObj.GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
+ rItemSet,
+ rCaptionObj.getText(0)));
+
+ // take unrotated snap rect (direct model data) for position and size
+ const Rectangle& rRectangle = rCaptionObj.GetGeoRect();
+ const ::basegfx::B2DRange aObjectRange(
+ rRectangle.Left(), rRectangle.Top(),
+ rRectangle.Right(), rRectangle.Bottom());
+ const GeoStat& rGeoStat(rCaptionObj.GetGeoStat());
+
+ // fill object matrix
+ basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aObjectRange.getWidth(), aObjectRange.getHeight(),
+ rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
+ rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
+ aObjectRange.getMinX(), aObjectRange.getMinY()));
+
+ // calculate corner radius
+ double fCornerRadiusX;
+ double fCornerRadiusY;
+ drawinglayer::primitive2d::calculateRelativeCornerRadius(
+ rCaptionObj.GetEckenradius(), aObjectRange, fCornerRadiusX, fCornerRadiusY);
+
+ // create primitive. Always create one (even if invisible) to let the decomposition
+ // of SdrCaptionPrimitive2D create needed invisible elements for HitTest and BoundRect
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::SdrCaptionPrimitive2D(
+ aObjectMatrix,
+ aAttribute,
+ rCaptionObj.getTailPolygon(),
+ fCornerRadiusX,
+ fCornerRadiusY));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+
+ if(!aAttribute.isDefault() && rCaptionObj.GetSpecialTextBoxShadow())
+ {
+ // for SC, the caption object may have a specialized shadow. The usual object shadow is off
+ // and a specialized shadow gets created here (see old paint)
+ const SdrShadowColorItem& rShadColItem = (SdrShadowColorItem&)(rItemSet.Get(SDRATTR_SHADOWCOLOR));
+ const sal_uInt16 nTransp(((SdrShadowTransparenceItem&)(rItemSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue());
+ const Color aShadCol(rShadColItem.GetColorValue());
+ const XFillStyle eStyle = ((XFillStyleItem&)(rItemSet.Get(XATTR_FILLSTYLE))).GetValue();
+
+ // Create own ItemSet and modify as needed
+ // Always hide lines for special calc shadow
+ SfxItemSet aSet(rItemSet);
+ aSet.Put(XLineStyleItem(XLINE_NONE));
+
+ if(XFILL_HATCH == eStyle)
+ {
+ // #41666# Hatch color is set hard to shadow color
+ XHatch aHatch = ((XFillHatchItem&)(rItemSet.Get(XATTR_FILLHATCH))).GetHatchValue();
+ aHatch.SetColor(aShadCol);
+ aSet.Put(XFillHatchItem(String(),aHatch));
+ }
+ else
+ {
+ if(XFILL_NONE != eStyle && XFILL_SOLID != eStyle)
+ {
+ // force fill to solid (for Gradient and Bitmap)
+ aSet.Put(XFillStyleItem(XFILL_SOLID));
+ }
+
+ aSet.Put(XFillColorItem(String(),aShadCol));
+ aSet.Put(XFillTransparenceItem(nTransp));
+ }
+
+ // crete FillAttribute from modified ItemSet
+ const drawinglayer::attribute::SdrFillAttribute aFill(
+ drawinglayer::primitive2d::createNewSdrFillAttribute(aSet));
+ drawinglayer::primitive2d::Primitive2DReference xSpecialShadow;
+
+ if(!aFill.isDefault() && 1.0 != aFill.getTransparence())
+ {
+ // add shadow offset to object matrix
+ const sal_uInt32 nXDist(((SdrShadowXDistItem&)(rItemSet.Get(SDRATTR_SHADOWXDIST))).GetValue());
+ const sal_uInt32 nYDist(((SdrShadowYDistItem&)(rItemSet.Get(SDRATTR_SHADOWYDIST))).GetValue());
+ aObjectMatrix.translate(nXDist, nYDist);
+
+ // create unit outline polygon as geometry (see SdrCaptionPrimitive2D::create2DDecomposition)
+ basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect(
+ basegfx::B2DRange(0.0, 0.0, 1.0, 1.0), fCornerRadiusX, fCornerRadiusY));
+
+ // create the specialized shadow primitive
+ xSpecialShadow = drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ aObjectMatrix,
+ aFill,
+ drawinglayer::attribute::FillGradientAttribute());
+ }
+
+ if(xSpecialShadow.is())
+ {
+ // if we really got a special shadow, create a two-element retval with the shadow
+ // behind the standard object's geometry
+ xRetval.realloc(2);
+
+ xRetval[0] = xSpecialShadow;
+ xRetval[1] = xReference;
+ }
+ }
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx b/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx
new file mode 100644
index 000000000000..78151a98a3e1
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofsdrcircobj.hxx>
+#include <svx/svdocirc.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive2d/sdrellipseprimitive2d.hxx>
+#include <svl/itemset.hxx>
+#include <svx/sxciaitm.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfSdrCircObj::ViewContactOfSdrCircObj(SdrCircObj& rCircObj)
+ : ViewContactOfSdrRectObj(rCircObj)
+ {
+ }
+
+ ViewContactOfSdrCircObj::~ViewContactOfSdrCircObj()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrCircObj::createViewIndependentPrimitive2DSequence() const
+ {
+ const SfxItemSet& rItemSet = GetCircObj().GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
+ rItemSet,
+ GetCircObj().getText(0)));
+
+ // take unrotated snap rect (direct model data) for position and size
+ const Rectangle& rRectangle = GetCircObj().GetGeoRect();
+ const basegfx::B2DRange aObjectRange(
+ rRectangle.Left(), rRectangle.Top(),
+ rRectangle.Right(), rRectangle.Bottom());
+ const GeoStat& rGeoStat(GetCircObj().GetGeoStat());
+
+ // fill object matrix
+ const basegfx::B2DHomMatrix aObjectMatrix(
+ basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aObjectRange.getWidth(), aObjectRange.getHeight(),
+ rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
+ rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
+ aObjectRange.getMinX(), aObjectRange.getMinY()));
+
+ // create primitive data
+ const sal_uInt16 nIdentifier(GetCircObj().GetObjIdentifier());
+
+ // always create primitives to allow the decomposition of SdrEllipsePrimitive2D
+ // or SdrEllipseSegmentPrimitive2D to create needed invisible elements for HitTest
+ // and/or BoundRect
+ if(OBJ_CIRC == nIdentifier)
+ {
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::SdrEllipsePrimitive2D(
+ aObjectMatrix,
+ aAttribute));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ else
+ {
+ const sal_Int32 nNewStart(((SdrCircStartAngleItem&)rItemSet.Get(SDRATTR_CIRCSTARTANGLE)).GetValue());
+ const sal_Int32 nNewEnd(((SdrCircEndAngleItem&)rItemSet.Get(SDRATTR_CIRCENDANGLE)).GetValue());
+ const double fStart(((36000 - nNewEnd) % 36000) * F_PI18000);
+ const double fEnd(((36000 - nNewStart) % 36000) * F_PI18000);
+ const bool bCloseSegment(OBJ_CARC != nIdentifier);
+ const bool bCloseUsingCenter(OBJ_SECT == nIdentifier);
+
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::SdrEllipseSegmentPrimitive2D(
+ aObjectMatrix,
+ aAttribute,
+ fStart,
+ fEnd,
+ bCloseSegment,
+ bCloseUsingCenter));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdredgeobj.cxx b/svx/source/sdr/contact/viewcontactofsdredgeobj.cxx
new file mode 100644
index 000000000000..059a5d94ef66
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdredgeobj.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofsdredgeobj.hxx>
+#include <svx/svdoedge.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive2d/sdrconnectorprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfSdrEdgeObj::ViewContactOfSdrEdgeObj(SdrEdgeObj& rEdgeObj)
+ : ViewContactOfTextObj(rEdgeObj)
+ {
+ }
+
+ ViewContactOfSdrEdgeObj::~ViewContactOfSdrEdgeObj()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrEdgeObj::createViewIndependentPrimitive2DSequence() const
+ {
+ const basegfx::B2DPolygon& rEdgeTrack = GetEdgeObj().getEdgeTrack();
+
+ // what to do when no EdgeTrack is provided (HitTest and selectability) ?
+ OSL_ENSURE(0 != rEdgeTrack.count(), "Connectors with no geometry are not allowed (!)");
+
+ // ckeck attributes
+ const SfxItemSet& rItemSet = GetEdgeObj().GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineShadowTextAttribute aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineShadowTextAttribute(
+ rItemSet,
+ GetEdgeObj().getText(0)));
+
+ // create primitive. Always create primitives to allow the decomposition of
+ // SdrConnectorPrimitive2D to create needed invisible elements for HitTest
+ // and/or BoundRect
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::SdrConnectorPrimitive2D(
+ aAttribute,
+ rEdgeTrack));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdrmeasureobj.cxx b/svx/source/sdr/contact/viewcontactofsdrmeasureobj.cxx
new file mode 100644
index 000000000000..61d6f1354a02
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdrmeasureobj.cxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofsdrmeasureobj.hxx>
+#include <svx/svdomeas.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svl/itemset.hxx>
+#include <svx/sxmbritm.hxx>
+#include <svx/sxmlhitm.hxx>
+#include <svx/sxmtritm.hxx>
+#include <svx/sxmtaitm.hxx>
+#include <svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx>
+#include <svx/sxmtpitm.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfSdrMeasureObj::ViewContactOfSdrMeasureObj(SdrMeasureObj& rMeasureObj)
+ : ViewContactOfTextObj(rMeasureObj)
+ {
+ }
+
+ ViewContactOfSdrMeasureObj::~ViewContactOfSdrMeasureObj()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMeasureObj::createViewIndependentPrimitive2DSequence() const
+ {
+ const SfxItemSet& rItemSet = GetMeasureObj().GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineShadowTextAttribute aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineShadowTextAttribute(
+ rItemSet,
+ GetMeasureObj().getText(0)));
+
+ // take properties which are the model data.
+ const ::basegfx::B2DPoint aStart(GetMeasureObj().GetPoint(0).X(), GetMeasureObj().GetPoint(0).Y());
+ const ::basegfx::B2DPoint aEnd(GetMeasureObj().GetPoint(1).X(), GetMeasureObj().GetPoint(1).Y());
+ const double fDistance(((SdrMeasureLineDistItem&)rItemSet.Get(SDRATTR_MEASURELINEDIST)).GetValue());
+ const double fUpperDistance(((SdrMeasureHelplineOverhangItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINEOVERHANG)).GetValue());
+ const double fLowerDistance(((SdrMeasureHelplineDistItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINEDIST)).GetValue());
+ const double fLeftDelta(((SdrMeasureHelpline1LenItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINE1LEN)).GetValue());
+ const double fRightDelta(((SdrMeasureHelpline2LenItem&)rItemSet.Get(SDRATTR_MEASUREHELPLINE2LEN)).GetValue());
+ const bool bBelow(((SdrMeasureBelowRefEdgeItem&)rItemSet.Get(SDRATTR_MEASUREBELOWREFEDGE)).GetValue());
+ const bool bTextRotation(((SdrMeasureTextRota90Item&)rItemSet.Get(SDRATTR_MEASURETEXTROTA90)).GetValue());
+ const bool bTextAutoAngle(((SdrMeasureTextAutoAngleItem&)rItemSet.Get(SDRATTR_MEASURETEXTAUTOANGLE)).GetValue());
+ drawinglayer::primitive2d::MeasureTextPosition aMTPHor(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
+ drawinglayer::primitive2d::MeasureTextPosition aMTPVer(drawinglayer::primitive2d::MEASURETEXTPOSITION_AUTOMATIC);
+
+ switch(((SdrMeasureTextHPosItem&)rItemSet.Get(SDRATTR_MEASURETEXTHPOS)).GetValue())
+ {
+ case SDRMEASURE_TEXTLEFTOUTSIDE :
+ {
+ aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
+ break;
+ }
+ case SDRMEASURE_TEXTINSIDE :
+ {
+ aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
+ break;
+ }
+ case SDRMEASURE_TEXTRIGHTOUTSIDE :
+ {
+ aMTPHor = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
+ break;
+ }
+ default : // SDRMEASURE_TEXTHAUTO
+ {
+ break;
+ }
+ }
+
+ switch(((SdrMeasureTextVPosItem&)rItemSet.Get(SDRATTR_MEASURETEXTVPOS)).GetValue())
+ {
+ case SDRMEASURE_ABOVE :
+ {
+ aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_NEGATIVE;
+ break;
+ }
+ case SDRMEASURETEXT_BREAKEDLINE :
+ case SDRMEASURETEXT_VERTICALCENTERED :
+ {
+ aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_CENTERED;
+ break;
+ }
+ case SDRMEASURE_BELOW :
+ {
+ aMTPVer = drawinglayer::primitive2d::MEASURETEXTPOSITION_POSITIVE;
+ break;
+ }
+ default : // SDRMEASURE_TEXTVAUTO
+ {
+ break;
+ }
+ }
+
+ // create primitive with the model data. Always create primitives to allow the
+ // decomposition of SdrMeasurePrimitive2D to create needed invisible elements for HitTest
+ // and/or BoundRect
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::SdrMeasurePrimitive2D(
+ aAttribute, aStart, aEnd,
+ aMTPHor, aMTPVer, fDistance,
+ fUpperDistance, fLowerDistance,
+ fLeftDelta, fRightDelta, bBelow,
+ bTextRotation, bTextAutoAngle));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx b/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx
new file mode 100644
index 000000000000..20f7d410d4d3
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdrmediaobj.cxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
+#include <drawinglayer/primitive2d/mediaprimitive2d.hxx>
+
+namespace sdr { namespace contact {
+
+// ----------------------------
+// - ViewContactOfSdrMediaObj -
+// ----------------------------
+
+ViewContactOfSdrMediaObj::ViewContactOfSdrMediaObj( SdrMediaObj& rMediaObj ) :
+ ViewContactOfSdrObj( rMediaObj )
+{
+}
+
+// ------------------------------------------------------------------------------
+
+ViewContactOfSdrMediaObj::~ViewContactOfSdrMediaObj()
+{
+}
+
+// ------------------------------------------------------------------------------
+
+ViewObjectContact& ViewContactOfSdrMediaObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+{
+ return *( new ViewObjectContactOfSdrMediaObj( rObjectContact, *this, static_cast< SdrMediaObj& >( GetSdrObject() ).getMediaProperties() ) );
+}
+
+// ------------------------------------------------------------------------------
+
+bool ViewContactOfSdrMediaObj::hasPreferredSize() const
+{
+ // #i71805# Since we may have a whole bunch of VOCs here, make a loop
+ // return true if all have their preferred size
+ const sal_uInt32 nCount(getViewObjectContactCount());
+ bool bRetval(true);
+
+ for(sal_uInt32 a(0); bRetval && a < nCount; a++)
+ {
+ ViewObjectContact* pCandidate = getViewObjectContact(a);
+
+ if(pCandidate && !static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->hasPreferredSize())
+ {
+ bRetval = false;
+ }
+ }
+
+ return bRetval;
+}
+
+// ------------------------------------------------------------------------------
+
+Size ViewContactOfSdrMediaObj::getPreferredSize() const
+{
+ // #i71805# Since we may have a whole bunch of VOCs here, make a loop
+ // return first useful size -> the size from the first which is visualized as a window
+ const sal_uInt32 nCount(getViewObjectContactCount());
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ ViewObjectContact* pCandidate = getViewObjectContact(a);
+ Size aSize(pCandidate ? static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->getPreferredSize() : Size());
+
+ if(0 != aSize.getWidth() || 0 != aSize.getHeight())
+ {
+ return aSize;
+ }
+ }
+
+ return Size();
+}
+
+// ------------------------------------------------------------------------------
+
+void ViewContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const
+{
+ // #i71805# Since we may have a whole bunch of VOCs here, make a loop
+ const sal_uInt32 nCount(getViewObjectContactCount());
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ ViewObjectContact* pCandidate = getViewObjectContact(a);
+
+ if(pCandidate)
+ {
+ static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->updateMediaItem(rItem);
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void ViewContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem )
+{
+ const sal_uInt32 nCount(getViewObjectContactCount());
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ ViewObjectContact* pCandidate = getViewObjectContact(a);
+
+ if(pCandidate)
+ {
+ static_cast< ViewObjectContactOfSdrMediaObj* >(pCandidate)->executeMediaItem(rItem);
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void ViewContactOfSdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewState )
+{
+ static_cast< SdrMediaObj& >(GetSdrObject()).mediaPropertiesChanged(rNewState);
+}
+
+}} // end of namespace sdr::contact
+
+namespace sdr
+{
+ namespace contact
+ {
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrMediaObj::createViewIndependentPrimitive2DSequence() const
+ {
+ // create range using the model data directly. This is in SdrTextObj::aRect which i will access using
+ // GetGeoRect() to not trigger any calculations. It's the unrotated geometry which is okay for MediaObjects ATM.
+ const Rectangle& rRectangle(GetSdrMediaObj().GetGeoRect());
+ const basegfx::B2DRange aRange(
+ rRectangle.Left(), rRectangle.Top(),
+ rRectangle.Right(), rRectangle.Bottom());
+
+ // create object transform
+ basegfx::B2DHomMatrix aTransform;
+ aTransform.set(0, 0, aRange.getWidth());
+ aTransform.set(1, 1, aRange.getHeight());
+ aTransform.set(0, 2, aRange.getMinX());
+ aTransform.set(1, 2, aRange.getMinY());
+
+ // create media primitive. Always create primitives to allow the
+ // decomposition of MediaPrimitive2D to create needed invisible elements for HitTest
+ // and/or BoundRect
+ const basegfx::BColor aBackgroundColor(67.0 / 255.0, 67.0 / 255.0, 67.0 / 255.0);
+ const rtl::OUString& rURL(GetSdrMediaObj().getURL());
+ const sal_uInt32 nPixelBorder(4L);
+ const drawinglayer::primitive2d::Primitive2DReference xRetval(
+ new drawinglayer::primitive2d::MediaPrimitive2D(
+ aTransform, rURL, aBackgroundColor, nPixelBorder));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdrobj.cxx b/svx/source/sdr/contact/viewcontactofsdrobj.cxx
new file mode 100644
index 000000000000..05b0f1a3d88f
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdrobj.cxx
@@ -0,0 +1,197 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactofsdrobj.hxx>
+#include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <vcl/outdev.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
+#include <svx/sdr/contact/objectcontactofpageview.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <sdrpaintwindow.hxx>
+#include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ // Create a Object-Specific ViewObjectContact, set ViewContact and
+ // ObjectContact. Always needs to return something.
+ ViewObjectContact& ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfSdrObj(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContactOfSdrObj::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ ViewContactOfSdrObj::ViewContactOfSdrObj(SdrObject& rObj)
+ : ViewContact(),
+ mrObject(rObj),
+ meRememberedAnimationKind(SDRTEXTANI_NONE)
+ {
+ // init AnimationKind
+ if(GetSdrObject().ISA(SdrTextObj))
+ {
+ SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject();
+ meRememberedAnimationKind = rTextObj.GetTextAniKind();
+ }
+ }
+
+ ViewContactOfSdrObj::~ViewContactOfSdrObj()
+ {
+ }
+
+ // Access to possible sub-hierarchy
+ sal_uInt32 ViewContactOfSdrObj::GetObjectCount() const
+ {
+ if(GetSdrObject().GetSubList())
+ {
+ return GetSdrObject().GetSubList()->GetObjCount();
+ }
+
+ return 0L;
+ }
+
+ ViewContact& ViewContactOfSdrObj::GetViewContact(sal_uInt32 nIndex) const
+ {
+ DBG_ASSERT(GetSdrObject().GetSubList(),
+ "ViewContactOfSdrObj::GetViewContact: Access to non-existent Sub-List (!)");
+ SdrObject* pObj = GetSdrObject().GetSubList()->GetObj(nIndex);
+ DBG_ASSERT(pObj, "ViewContactOfSdrObj::GetViewContact: Corrupt SdrObjList (!)");
+ return pObj->GetViewContact();
+ }
+
+ ViewContact* ViewContactOfSdrObj::GetParentContact() const
+ {
+ ViewContact* pRetval = 0L;
+ SdrObjList* pObjList = GetSdrObject().GetObjList();
+
+ if(pObjList)
+ {
+ if(pObjList->ISA(SdrPage))
+ {
+ // Is a page
+ pRetval = &(((SdrPage*)pObjList)->GetViewContact());
+ }
+ else
+ {
+ // Is a group?
+ if(pObjList->GetOwnerObj())
+ {
+ pRetval = &(pObjList->GetOwnerObj()->GetViewContact());
+ }
+ }
+ }
+
+ return pRetval;
+ }
+
+ // React on changes of the object of this ViewContact
+ void ViewContactOfSdrObj::ActionChanged()
+ {
+ // look for own changes
+ if(GetSdrObject().ISA(SdrTextObj))
+ {
+ SdrTextObj& rTextObj = (SdrTextObj&)GetSdrObject();
+
+ if(rTextObj.GetTextAniKind() != meRememberedAnimationKind)
+ {
+ // #i38135# now remember new type
+ meRememberedAnimationKind = rTextObj.GetTextAniKind();
+ }
+ }
+
+ // call parent
+ ViewContact::ActionChanged();
+ }
+
+ // overload for acessing the SdrObject
+ SdrObject* ViewContactOfSdrObj::TryToGetSdrObject() const
+ {
+ return &GetSdrObject();
+ }
+
+ //////////////////////////////////////////////////////////////////////////////
+ // primitive stuff
+
+ // add Gluepoints (if available)
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObj::createGluePointPrimitive2DSequence() const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const SdrGluePointList* pGluePointList = GetSdrObject().GetGluePointList();
+
+ if(pGluePointList)
+ {
+ const sal_uInt32 nCount(pGluePointList->GetCount());
+
+ if(nCount)
+ {
+ // prepare point vector
+ std::vector< basegfx::B2DPoint > aGluepointVector;
+
+ // create GluePoint primitives. ATM these are relative to the SnapRect
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ const SdrGluePoint& rCandidate = (*pGluePointList)[(sal_uInt16)a];
+ const Point aPosition(rCandidate.GetAbsolutePos(GetSdrObject()));
+
+ aGluepointVector.push_back(basegfx::B2DPoint(aPosition.X(), aPosition.Y()));
+ }
+
+ if(aGluepointVector.size())
+ {
+ const basegfx::BColor aBackPen(1.0, 1.0, 1.0);
+ const basegfx::BColor aRGBFrontColor(0.0, 0.0, 1.0); // COL_LIGHTBLUE
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::MarkerArrayPrimitive2D(
+ aGluepointVector,
+ drawinglayer::primitive2d::createDefaultGluepoint_7x7(aBackPen, aRGBFrontColor)));
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ }
+ }
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
new file mode 100644
index 000000000000..8d0a1d55048d
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
@@ -0,0 +1,244 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactofsdrobjcustomshape.hxx>
+#include <svx/svdoashp.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svditer.hxx>
+#include <svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <svx/obj3d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfSdrObjCustomShape::ViewContactOfSdrObjCustomShape(SdrObjCustomShape& rCustomShape)
+ : ViewContactOfTextObj(rCustomShape)
+ {
+ }
+
+ ViewContactOfSdrObjCustomShape::~ViewContactOfSdrObjCustomShape()
+ {
+ }
+
+ basegfx::B2DRange ViewContactOfSdrObjCustomShape::getCorrectedTextBoundRect() const
+ {
+ const Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect());
+ Rectangle aTextBound(aObjectBound);
+ GetCustomShapeObj().GetTextBounds(aTextBound);
+ basegfx::B2DRange aTextRange(aTextBound.Left(), aTextBound.Top(), aTextBound.Right(), aTextBound.Bottom());
+ const basegfx::B2DRange aObjectRange(aObjectBound.Left(), aObjectBound.Top(), aObjectBound.Right(), aObjectBound.Bottom());
+
+ // no need to correct if no extra text range
+ if(aTextRange != aObjectRange)
+ {
+ const GeoStat& rGeoStat(GetCustomShapeObj().GetGeoStat());
+
+ // only correct when rotation and/or shear is used
+ if(rGeoStat.nShearWink || rGeoStat.nDrehWink )
+ {
+ // text range needs to be corrected by
+ // aObjectRange.getCenter() - aRotObjectRange.getCenter() since it's
+ // defined differenly by using rotation around object center. Start
+ // with positive part
+ basegfx::B2DVector aTranslation(aObjectRange.getCenter());
+
+ // get rotated and sheared object's range
+ basegfx::B2DRange aRotObjectRange(aObjectRange);
+ basegfx::B2DHomMatrix aRotMatrix;
+
+ aRotMatrix.translate(-aObjectRange.getMinimum().getX(), -aObjectRange.getMinimum().getY());
+
+ if(rGeoStat.nShearWink)
+ {
+ aRotMatrix.shearX(tan((36000 - rGeoStat.nShearWink) * F_PI18000));
+ }
+
+ if(rGeoStat.nDrehWink)
+ {
+ aRotMatrix.rotate((36000 - rGeoStat.nDrehWink) * F_PI18000);
+ }
+
+ aRotMatrix.translate(aObjectRange.getMinimum().getX(), aObjectRange.getMinimum().getY());
+ aRotObjectRange.transform(aRotMatrix);
+
+ // add negative translation part
+ aTranslation -= aRotObjectRange.getCenter();
+
+ // create new range
+ aTextRange = basegfx::B2DRange(
+ aTextRange.getMinX() + aTranslation.getX(), aTextRange.getMinY() + aTranslation.getY(),
+ aTextRange.getMaxX() + aTranslation.getX(), aTextRange.getMaxY() + aTranslation.getY());
+ }
+ }
+
+ return aTextRange;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrObjCustomShape::createViewIndependentPrimitive2DSequence() const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const SfxItemSet& rItemSet = GetCustomShapeObj().GetMergedItemSet();
+
+ // #i98072# Get shandow and text; eventually suppress the text if it's
+ // a TextPath FontworkGallery object
+ const drawinglayer::attribute::SdrShadowTextAttribute aAttribute(
+ drawinglayer::primitive2d::createNewSdrShadowTextAttribute(
+ rItemSet,
+ GetCustomShapeObj().getText(0),
+ GetCustomShapeObj().IsTextPath()));
+ drawinglayer::primitive2d::Primitive2DSequence xGroup;
+ bool bHasText(!aAttribute.getText().isDefault());
+
+ // create Primitive2DSequence from sub-geometry
+ const SdrObject* pSdrObjRepresentation = GetCustomShapeObj().GetSdrObjectFromCustomShape();
+ bool b3DShape(false);
+
+ if(pSdrObjRepresentation)
+ {
+ SdrObjListIter aIterator(*pSdrObjRepresentation);
+
+ while(aIterator.IsMore())
+ {
+ SdrObject& rCandidate = *aIterator.Next();
+
+ if(!b3DShape && dynamic_cast< E3dObject* >(&rCandidate))
+ {
+ b3DShape = true;
+ }
+
+ const drawinglayer::primitive2d::Primitive2DSequence xNew(rCandidate.GetViewContact().getViewIndependentPrimitive2DSequence());
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xGroup, xNew);
+ }
+ }
+
+ if(bHasText || xGroup.hasElements())
+ {
+ // prepare text box geometry
+ basegfx::B2DHomMatrix aTextBoxMatrix;
+ bool bWordWrap(false);
+
+ if(bHasText)
+ {
+ // take unrotated snap rect as default, then get the
+ // unrotated text box. Rotation needs to be done centered
+ const Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect());
+ const basegfx::B2DRange aObjectRange(aObjectBound.Left(), aObjectBound.Top(), aObjectBound.Right(), aObjectBound.Bottom());
+
+ // #i101684# get the text range unrotated and absolute to the object range
+ const basegfx::B2DRange aTextRange(getCorrectedTextBoundRect());
+
+ // give text object a size
+ aTextBoxMatrix.scale(aTextRange.getWidth(), aTextRange.getHeight());
+
+ // check if we have a rotation/shear at all to take care of
+ const double fExtraTextRotation(GetCustomShapeObj().GetExtraTextRotation());
+ const GeoStat& rGeoStat(GetCustomShapeObj().GetGeoStat());
+
+ if(rGeoStat.nShearWink || rGeoStat.nDrehWink || !basegfx::fTools::equalZero(fExtraTextRotation))
+ {
+ if(aObjectRange != aTextRange)
+ {
+ // move relative to unrotated object range
+ aTextBoxMatrix.translate(
+ aTextRange.getMinX() - aObjectRange.getMinimum().getX(),
+ aTextRange.getMinY() - aObjectRange.getMinimum().getY());
+ }
+
+ if(!basegfx::fTools::equalZero(fExtraTextRotation))
+ {
+ basegfx::B2DVector aTranslation(
+ ( aTextRange.getWidth() / 2 ) + ( aTextRange.getMinX() - aObjectRange.getMinimum().getX() ),
+ ( aTextRange.getHeight() / 2 ) + ( aTextRange.getMinY() - aObjectRange.getMinimum().getY() ) );
+ aTextBoxMatrix.translate( -aTranslation.getX(), -aTranslation.getY() );
+ aTextBoxMatrix.rotate((360.0 - fExtraTextRotation) * F_PI180);
+ aTextBoxMatrix.translate( aTranslation.getX(), aTranslation.getY() );
+ }
+
+ if(rGeoStat.nShearWink)
+ {
+ aTextBoxMatrix.shearX(tan((36000 - rGeoStat.nShearWink) * F_PI18000));
+ }
+
+ if(rGeoStat.nDrehWink)
+ {
+ aTextBoxMatrix.rotate((36000 - rGeoStat.nDrehWink) * F_PI18000);
+ }
+
+ // give text it's target position
+ aTextBoxMatrix.translate(aObjectRange.getMinimum().getX(), aObjectRange.getMinimum().getY());
+ }
+ else
+ {
+ aTextBoxMatrix.translate(aTextRange.getMinX(), aTextRange.getMinY());
+ }
+
+ // check if SdrTextWordWrapItem is set
+ bWordWrap = ((SdrTextWordWrapItem&)(GetCustomShapeObj().GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue();
+ }
+
+ // create primitive
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::SdrCustomShapePrimitive2D(
+ aAttribute,
+ xGroup,
+ aTextBoxMatrix,
+ bWordWrap,
+ b3DShape,
+ false)); // #SJ# New parameter to force to clipped BlockText for SC
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ // always append an invisible outline for the cases where no visible content exists
+ const Rectangle aObjectBound(GetCustomShapeObj().GetGeoRect());
+ const basegfx::B2DRange aObjectRange(
+ aObjectBound.Left(), aObjectBound.Top(),
+ aObjectBound.Right(), aObjectBound.Bottom());
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval,
+ drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
+ false, aObjectRange));
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx b/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx
new file mode 100644
index 000000000000..dfa3214c0b43
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofsdrole2obj.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/sdr/contact/viewobjectcontactofsdrole2obj.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/primitive2d/sdrole2primitive2d.hxx>
+#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
+#include <svtools/colorcfg.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ // Create a Object-Specific ViewObjectContact, set ViewContact and
+ // ObjectContact. Always needs to return something.
+ ViewObjectContact& ViewContactOfSdrOle2Obj::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfSdrOle2Obj(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ ViewContactOfSdrOle2Obj::ViewContactOfSdrOle2Obj(SdrOle2Obj& rOle2Obj)
+ : ViewContactOfSdrRectObj(rOle2Obj)
+ {
+ }
+
+ ViewContactOfSdrOle2Obj::~ViewContactOfSdrOle2Obj()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createPrimitive2DSequenceWithParameters(
+ bool bHighContrast) const
+ {
+ // take unrotated snap rect (direct model data) for position and size
+ const Rectangle& rRectangle = GetOle2Obj().GetGeoRect();
+ const basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom());
+
+ // create object matrix
+ const GeoStat& rGeoStat(GetOle2Obj().GetGeoStat());
+ const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
+ const double fRotate(rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0);
+ const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aObjectRange.getWidth(), aObjectRange.getHeight(), fShearX, fRotate,
+ aObjectRange.getMinX(), aObjectRange.getMinY()));
+
+ // Prepare attribute settings, will be used soon anyways
+ const SfxItemSet& rItemSet = GetOle2Obj().GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
+ rItemSet,
+ GetOle2Obj().getText(0)));
+
+ // #i102063# embed OLE content in an own primitive; this will be able to decompose accessing
+ // the weak SdrOle2 reference and will also implement getB2DRange() for fast BoundRect
+ // calculations without OLE Graphic access (which may trigger e.g. chart recalculation).
+ // It will also take care of HighContrast and ScaleContent
+ const drawinglayer::primitive2d::Primitive2DReference xOleContent(
+ new drawinglayer::primitive2d::SdrOleContentPrimitive2D(
+ GetOle2Obj(),
+ aObjectMatrix,
+
+ // #i104867# add GraphicVersion number to be able to check for
+ // content change in the primitive later
+ GetOle2Obj().getEmbeddedObjectRef().getGraphicVersion(),
+
+ bHighContrast));
+
+ // create primitive. Use Ole2 primitive here. Prepare attribute settings, will
+ // be used soon anyways. Always create primitives to allow the decomposition of
+ // SdrOle2Primitive2D to create needed invisible elements for HitTest and/or BoundRect
+ const drawinglayer::primitive2d::Primitive2DSequence xOLEContent(&xOleContent, 1);
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::SdrOle2Primitive2D(
+ xOLEContent,
+ aObjectMatrix,
+ aAttribute));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrOle2Obj::createViewIndependentPrimitive2DSequence() const
+ {
+ // do as if no HC and call standard creator
+ return createPrimitive2DSequenceWithParameters(false);
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdrpage.cxx b/svx/source/sdr/contact/viewcontactofsdrpage.cxx
new file mode 100644
index 000000000000..13235d777512
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdrpage.cxx
@@ -0,0 +1,696 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactofsdrpage.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/viewobjectcontactofsdrpage.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/attribute/sdrfillattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+#define PAPER_SHADOW(SIZE) (SIZE >> 8)
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfPageSubObject::ViewContactOfPageSubObject(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
+ : mrParentViewContactOfSdrPage(rParentViewContactOfSdrPage)
+ {
+ }
+
+ ViewContactOfPageSubObject::~ViewContactOfPageSubObject()
+ {
+ }
+
+ ViewContact* ViewContactOfPageSubObject::GetParentContact() const
+ {
+ return &mrParentViewContactOfSdrPage;
+ }
+
+ const SdrPage& ViewContactOfPageSubObject::getPage() const
+ {
+ return mrParentViewContactOfSdrPage.GetSdrPage();
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfPageBackground::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfPageBackground(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageBackground::createViewIndependentPrimitive2DSequence() const
+ {
+ // We have only the page information, not the view information. Use the
+ // svtools::DOCCOLOR color for initialisation
+ const svtools::ColorConfig aColorConfig;
+ const Color aInitColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
+ const basegfx::BColor aRGBColor(aInitColor.getBColor());
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::BackgroundColorPrimitive2D(aRGBColor));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ ViewContactOfPageBackground::ViewContactOfPageBackground(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
+ : ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
+ {
+ }
+
+ ViewContactOfPageBackground::~ViewContactOfPageBackground()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfPageShadow::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfPageShadow(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageShadow::createViewIndependentPrimitive2DSequence() const
+ {
+ const SdrPage& rPage = getPage();
+ basegfx::B2DHomMatrix aPageMatrix;
+ aPageMatrix.set(0, 0, (double)rPage.GetWdt());
+ aPageMatrix.set(1, 1, (double)rPage.GetHgt());
+
+ // create page shadow polygon
+ const double fPageBorderFactor(1.0 / 256.0);
+ basegfx::B2DPolygon aPageShadowPolygon;
+ aPageShadowPolygon.append(basegfx::B2DPoint(1.0, fPageBorderFactor));
+ aPageShadowPolygon.append(basegfx::B2DPoint(1.0 + fPageBorderFactor, fPageBorderFactor));
+ aPageShadowPolygon.append(basegfx::B2DPoint(1.0 + fPageBorderFactor, 1.0 + fPageBorderFactor));
+ aPageShadowPolygon.append(basegfx::B2DPoint(fPageBorderFactor, 1.0 + fPageBorderFactor));
+ aPageShadowPolygon.append(basegfx::B2DPoint(fPageBorderFactor, 1.0));
+ aPageShadowPolygon.append(basegfx::B2DPoint(1.0, 1.0));
+ aPageShadowPolygon.setClosed(true);
+ aPageShadowPolygon.transform(aPageMatrix);
+
+ // We have only the page information, not the view information. Use the
+ // svtools::FONTCOLOR color for initialisation
+ const svtools::ColorConfig aColorConfig;
+ const Color aShadowColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
+ const basegfx::BColor aRGBShadowColor(aShadowColor.getBColor());
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPageShadowPolygon), aRGBShadowColor));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ ViewContactOfPageShadow::ViewContactOfPageShadow(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
+ : ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
+ {
+ }
+
+ ViewContactOfPageShadow::~ViewContactOfPageShadow()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfMasterPage::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfMasterPage(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfMasterPage::createViewIndependentPrimitive2DSequence() const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ // this class is used when the page is a MasterPage and is responsible to
+ // create a visualisation for the MPBGO, if exists. This needs to be suppressed
+ // when a SdrPage which uses a MasterPage creates it's output. Suppression
+ // is done in the corresponding VOC since DisplayInfo data is needed
+ const SdrPage& rPage = getPage();
+
+ if(rPage.IsMasterPage())
+ {
+ if(0 == rPage.GetPageNum())
+ {
+ // #i98063#
+ // filter MasterPage 0 since it's the HandoutPage. Thus, it's a
+ // MasterPage, but has no MPBGO, so there is nothing to do here.
+ }
+ else
+ {
+ drawinglayer::attribute::SdrFillAttribute aFill;
+
+ // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets,
+ // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all
+ // MasterPages should have a StyleSheet excactly for this reason, but historically
+ // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others).
+ if(rPage.getSdrPageProperties().GetStyleSheet())
+ {
+ // create page fill attributes with correct properties
+ aFill = drawinglayer::primitive2d::createNewSdrFillAttribute(
+ rPage.getSdrPageProperties().GetItemSet());
+ }
+
+ if(!aFill.isDefault())
+ {
+ // direct model data is the page size, get and use it
+ const basegfx::B2DRange aInnerRange(
+ rPage.GetLftBorder(), rPage.GetUppBorder(),
+ rPage.GetWdt() - rPage.GetRgtBorder(), rPage.GetHgt() - rPage.GetLwrBorder());
+ const basegfx::B2DPolygon aInnerPolgon(basegfx::tools::createPolygonFromRect(aInnerRange));
+ const basegfx::B2DHomMatrix aEmptyTransform;
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ drawinglayer::primitive2d::createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aInnerPolgon),
+ aEmptyTransform,
+ aFill,
+ drawinglayer::attribute::FillGradientAttribute()));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ }
+ }
+
+ return xRetval;
+ }
+
+ ViewContactOfMasterPage::ViewContactOfMasterPage(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
+ : ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
+ {
+ }
+
+ ViewContactOfMasterPage::~ViewContactOfMasterPage()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfPageFill::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfPageFill(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageFill::createViewIndependentPrimitive2DSequence() const
+ {
+ const SdrPage& rPage = getPage();
+ const basegfx::B2DRange aPageFillRange(0.0, 0.0, (double)rPage.GetWdt(), (double)rPage.GetHgt());
+ const basegfx::B2DPolygon aPageFillPolygon(basegfx::tools::createPolygonFromRect(aPageFillRange));
+
+ // We have only the page information, not the view information. Use the
+ // svtools::DOCCOLOR color for initialisation
+ const svtools::ColorConfig aColorConfig;
+ const Color aPageFillColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
+
+ // create and add primitive
+ const basegfx::BColor aRGBColor(aPageFillColor.getBColor());
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPageFillPolygon), aRGBColor));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ ViewContactOfPageFill::ViewContactOfPageFill(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
+ : ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
+ {
+ }
+
+ ViewContactOfPageFill::~ViewContactOfPageFill()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfOuterPageBorder::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfOuterPageBorder(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfOuterPageBorder::createViewIndependentPrimitive2DSequence() const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const SdrPage& rPage = getPage();
+ const basegfx::B2DRange aPageBorderRange(0.0, 0.0, (double)rPage.GetWdt(), (double)rPage.GetHgt());
+
+ // We have only the page information, not the view information. Use the
+ // svtools::FONTCOLOR color for initialisation
+ const svtools::ColorConfig aColorConfig;
+ const Color aBorderColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
+ const basegfx::BColor aRGBBorderColor(aBorderColor.getBColor());
+
+ if(rPage.getPageBorderOnlyLeftRight())
+ {
+ // #i93597# for Report Designer, the page border shall be only displayed right and left,
+ // but not top and bottom. Create simplified geometry.
+ basegfx::B2DPolygon aLeft, aRight;
+
+ aLeft.append(basegfx::B2DPoint(aPageBorderRange.getMinX(), aPageBorderRange.getMinY()));
+ aLeft.append(basegfx::B2DPoint(aPageBorderRange.getMinX(), aPageBorderRange.getMaxY()));
+
+ aRight.append(basegfx::B2DPoint(aPageBorderRange.getMaxX(), aPageBorderRange.getMinY()));
+ aRight.append(basegfx::B2DPoint(aPageBorderRange.getMaxX(), aPageBorderRange.getMaxY()));
+
+ xRetval.realloc(2);
+ xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aLeft, aRGBBorderColor));
+ xRetval[1] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aRight, aRGBBorderColor));
+ }
+ else
+ {
+ xRetval.realloc(1);
+ const basegfx::B2DPolygon aPageBorderPolygon(basegfx::tools::createPolygonFromRect(aPageBorderRange));
+ xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPageBorderPolygon, aRGBBorderColor));
+ }
+
+ return xRetval;
+ }
+
+ ViewContactOfOuterPageBorder::ViewContactOfOuterPageBorder(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
+ : ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
+ {
+ }
+
+ ViewContactOfOuterPageBorder::~ViewContactOfOuterPageBorder()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfInnerPageBorder::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfInnerPageBorder(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfInnerPageBorder::createViewIndependentPrimitive2DSequence() const
+ {
+ const SdrPage& rPage = getPage();
+ const basegfx::B2DRange aPageBorderRange(
+ (double)rPage.GetLftBorder(), (double)rPage.GetUppBorder(),
+ (double)(rPage.GetWdt() - rPage.GetRgtBorder()), (double)(rPage.GetHgt() - rPage.GetLwrBorder()));
+ const basegfx::B2DPolygon aPageBorderPolygon(basegfx::tools::createPolygonFromRect(aPageBorderRange));
+
+ // We have only the page information, not the view information. Use the
+ // svtools::FONTCOLOR or svtools::DOCBOUNDARIES color for initialisation
+ const svtools::ColorConfig aColorConfig;
+ Color aBorderColor;
+
+ if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ aBorderColor = aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor;
+ }
+ else
+ {
+ aBorderColor = aColorConfig.GetColorValue(svtools::DOCBOUNDARIES).nColor;
+ }
+
+ // create page outer border primitive
+ const basegfx::BColor aRGBBorderColor(aBorderColor.getBColor());
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aPageBorderPolygon, aRGBBorderColor));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+
+ ViewContactOfInnerPageBorder::ViewContactOfInnerPageBorder(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
+ : ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
+ {
+ }
+
+ ViewContactOfInnerPageBorder::~ViewContactOfInnerPageBorder()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfPageHierarchy::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfPageHierarchy(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfPageHierarchy::createViewIndependentPrimitive2DSequence() const
+ {
+ // collect sub-hierarchy
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const sal_uInt32 nObjectCount(GetObjectCount());
+
+ // collect all sub-primitives
+ for(sal_uInt32 a(0); a < nObjectCount; a++)
+ {
+ const ViewContact& rCandidate(GetViewContact(a));
+ const drawinglayer::primitive2d::Primitive2DSequence aCandSeq(rCandidate.getViewIndependentPrimitive2DSequence());
+
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, aCandSeq);
+ }
+
+ return xRetval;
+ }
+
+ ViewContactOfPageHierarchy::ViewContactOfPageHierarchy(ViewContactOfSdrPage& rParentViewContactOfSdrPage)
+ : ViewContactOfPageSubObject(rParentViewContactOfSdrPage)
+ {
+ }
+
+ ViewContactOfPageHierarchy::~ViewContactOfPageHierarchy()
+ {
+ }
+
+ sal_uInt32 ViewContactOfPageHierarchy::GetObjectCount() const
+ {
+ return getPage().GetObjCount();
+ }
+
+ ViewContact& ViewContactOfPageHierarchy::GetViewContact(sal_uInt32 nIndex) const
+ {
+ SdrObject* pObj = getPage().GetObj(nIndex);
+ DBG_ASSERT(pObj, "ViewContactOfPageHierarchy::GetViewContact: Corrupt SdrObjList (!)");
+ return pObj->GetViewContact();
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfGrid::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfPageGrid(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfGrid::createViewIndependentPrimitive2DSequence() const
+ {
+ // We have only the page information, not the view information and thus no grid settings. Create empty
+ // default. For the view-dependent implementation, see ViewObjectContactOfPageGrid::createPrimitive2DSequence
+ return drawinglayer::primitive2d::Primitive2DSequence();
+ }
+
+ ViewContactOfGrid::ViewContactOfGrid(ViewContactOfSdrPage& rParentViewContactOfSdrPage, bool bFront)
+ : ViewContactOfPageSubObject(rParentViewContactOfSdrPage),
+ mbFront(bFront)
+ {
+ }
+
+ ViewContactOfGrid::~ViewContactOfGrid()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact& ViewContactOfHelplines::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfPageHelplines(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfHelplines::createViewIndependentPrimitive2DSequence() const
+ {
+ // We have only the page information, not the view information and thus no helplines. Create empty
+ // default. For the view-dependent implementation, see ViewObjectContactOfPageHelplines::createPrimitive2DSequence
+ return drawinglayer::primitive2d::Primitive2DSequence();
+ }
+
+ ViewContactOfHelplines::ViewContactOfHelplines(ViewContactOfSdrPage& rParentViewContactOfSdrPage, bool bFront)
+ : ViewContactOfPageSubObject(rParentViewContactOfSdrPage),
+ mbFront(bFront)
+ {
+ }
+
+ ViewContactOfHelplines::~ViewContactOfHelplines()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ // Create a Object-Specific ViewObjectContact, set ViewContact and
+ // ObjectContact. Always needs to return something.
+ ViewObjectContact& ViewContactOfSdrPage::CreateObjectSpecificViewObjectContact(ObjectContact& rObjectContact)
+ {
+ ViewObjectContact* pRetval = new ViewObjectContactOfSdrPage(rObjectContact, *this);
+ DBG_ASSERT(pRetval, "ViewContact::CreateObjectSpecificViewObjectContact() failed (!)");
+
+ return *pRetval;
+ }
+
+ ViewContactOfSdrPage::ViewContactOfSdrPage(SdrPage& rPage)
+ : ViewContact(),
+ mrPage(rPage),
+ maViewContactOfPageBackground(*this),
+ maViewContactOfPageShadow(*this),
+ maViewContactOfPageFill(*this),
+ maViewContactOfMasterPage(*this),
+ maViewContactOfOuterPageBorder(*this),
+ maViewContactOfInnerPageBorder(*this),
+ maViewContactOfGridBack(*this, false),
+ maViewContactOfHelplinesBack(*this, false),
+ maViewContactOfPageHierarchy(*this),
+ maViewContactOfGridFront(*this, true),
+ maViewContactOfHelplinesFront(*this, true)
+ {
+ }
+
+ ViewContactOfSdrPage::~ViewContactOfSdrPage()
+ {
+ }
+
+ // Access to possible sub-hierarchy
+ sal_uInt32 ViewContactOfSdrPage::GetObjectCount() const
+ {
+ // Fixed count of content. It contains PageBackground (Wiese), PageShadow, PageFill,
+ // then - depending on if the page has a MasterPage - either MasterPage Hierarchy
+ // or MPBGO. Also OuterPageBorder, InnerPageBorder and two pairs of Grid and Helplines
+ // (for front and back) which internally are visible or not depending on the current
+ // front/back setting for those.
+ return 11;
+ }
+
+ ViewContact& ViewContactOfSdrPage::GetViewContact(sal_uInt32 nIndex) const
+ {
+ switch(nIndex)
+ {
+ case 0: return (ViewContact&)maViewContactOfPageBackground;
+ case 1: return (ViewContact&)maViewContactOfPageShadow;
+ case 2: return (ViewContact&)maViewContactOfPageFill;
+ case 3:
+ {
+ const SdrPage& rPage = GetSdrPage();
+
+ if(rPage.TRG_HasMasterPage())
+ {
+ return rPage.TRG_GetMasterPageDescriptorViewContact();
+ }
+ else
+ {
+ return (ViewContact&)maViewContactOfMasterPage;
+ }
+ }
+ case 4: return (ViewContact&)maViewContactOfOuterPageBorder;
+ case 5: return (ViewContact&)maViewContactOfInnerPageBorder;
+ case 6: return (ViewContact&)maViewContactOfGridBack;
+ case 7: return (ViewContact&)maViewContactOfHelplinesBack;
+ case 8: return (ViewContact&)maViewContactOfPageHierarchy;
+ case 9: return (ViewContact&)maViewContactOfGridFront;
+ default: return (ViewContact&)maViewContactOfHelplinesFront;
+ }
+ }
+
+ // React on changes of the object of this ViewContact
+ void ViewContactOfSdrPage::ActionChanged()
+ {
+ // call parent
+ ViewContact::ActionChanged();
+
+ // apply to local viewContacts, they all rely on page information. Exception
+ // is the sub hierarchy; this will not be influenced by the change
+ maViewContactOfPageBackground.ActionChanged();
+ maViewContactOfPageShadow.ActionChanged();
+ maViewContactOfPageFill.ActionChanged();
+
+ const SdrPage& rPage = GetSdrPage();
+
+ if(rPage.TRG_HasMasterPage())
+ {
+ rPage.TRG_GetMasterPageDescriptorViewContact().ActionChanged();
+ }
+ else if(rPage.IsMasterPage())
+ {
+ maViewContactOfMasterPage.ActionChanged();
+ }
+
+ maViewContactOfOuterPageBorder.ActionChanged();
+ maViewContactOfInnerPageBorder.ActionChanged();
+ maViewContactOfGridBack.ActionChanged();
+ maViewContactOfHelplinesBack.ActionChanged();
+ maViewContactOfGridFront.ActionChanged();
+ maViewContactOfHelplinesFront.ActionChanged();
+ }
+
+ // overload for acessing the SdrPage
+ SdrPage* ViewContactOfSdrPage::TryToGetSdrPage() const
+ {
+ return &GetSdrPage();
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrPage::createViewIndependentPrimitive2DSequence() const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ // collect all sub-sequences including sub hierarchy.
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageBackground.getViewIndependentPrimitive2DSequence());
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageShadow.getViewIndependentPrimitive2DSequence());
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageFill.getViewIndependentPrimitive2DSequence());
+
+ const SdrPage& rPage = GetSdrPage();
+
+ if(rPage.TRG_HasMasterPage())
+ {
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval,
+ rPage.TRG_GetMasterPageDescriptorViewContact().getViewIndependentPrimitive2DSequence());
+ }
+ else if(rPage.IsMasterPage())
+ {
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval,
+ maViewContactOfMasterPage.getViewIndependentPrimitive2DSequence());
+ }
+
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfOuterPageBorder.getViewIndependentPrimitive2DSequence());
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfInnerPageBorder.getViewIndependentPrimitive2DSequence());
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfPageHierarchy.getViewIndependentPrimitive2DSequence());
+
+ // Only add front versions of grid and helplines since no visibility test is done,
+ // so adding the back incarnations is not necessary. This makes the Front
+ // visualisation the default when no visibility tests are done.
+ //
+ // Since we have no view here, no grid and helpline definitions are available currently. The used
+ // methods at ViewContactOfHelplines and ViewContactOfGrid return only empty sequences and
+ // do not need to be called ATM. This may change later if grid or helpline info gets
+ // model data (it should not). Keeping the lines commented to hold this hint.
+ //
+ // drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfGridFront.getViewIndependentPrimitive2DSequence());
+ // drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, maViewContactOfHelplinesFront.getViewIndependentPrimitive2DSequence());
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
new file mode 100644
index 000000000000..7e70f0b46aba
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofsdrpathobj.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrpathprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfSdrPathObj::ViewContactOfSdrPathObj(SdrPathObj& rPathObj)
+ : ViewContactOfTextObj(rPathObj)
+ {
+ }
+
+ ViewContactOfSdrPathObj::~ViewContactOfSdrPathObj()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrPathObj::createViewIndependentPrimitive2DSequence() const
+ {
+ const SfxItemSet& rItemSet = GetPathObj().GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
+ rItemSet,
+ GetPathObj().getText(0)));
+ basegfx::B2DPolyPolygon aUnitPolyPolygon(GetPathObj().GetPathPoly());
+ sal_uInt32 nPolyCount(aUnitPolyPolygon.count());
+ sal_uInt32 nPointCount(0);
+
+ for(sal_uInt32 a(0); a < nPolyCount; a++)
+ {
+ nPointCount += aUnitPolyPolygon.getB2DPolygon(a).count();
+ }
+
+ if(!nPointCount)
+ {
+ OSL_ENSURE(false, "PolyPolygon object without geometry detected, this should not be created (!)");
+ basegfx::B2DPolygon aFallbackLine;
+ aFallbackLine.append(basegfx::B2DPoint(0.0, 0.0));
+ aFallbackLine.append(basegfx::B2DPoint(1000.0, 1000.0));
+ aUnitPolyPolygon = basegfx::B2DPolyPolygon(aFallbackLine);
+
+ nPolyCount = 1;
+ }
+
+ // prepare object transformation and unit polygon (direct model data)
+ basegfx::B2DHomMatrix aObjectMatrix;
+ const bool bIsLine(
+ !aUnitPolyPolygon.areControlPointsUsed()
+ && 1 == nPolyCount
+ && 2 == aUnitPolyPolygon.getB2DPolygon(0).count());
+
+ if(bIsLine)
+ {
+ // special handling for single line mode (2 points)
+ const basegfx::B2DPolygon aSubPolygon(aUnitPolyPolygon.getB2DPolygon(0));
+ const basegfx::B2DPoint aStart(aSubPolygon.getB2DPoint(0));
+ const basegfx::B2DPoint aEnd(aSubPolygon.getB2DPoint(1));
+ const basegfx::B2DVector aLine(aEnd - aStart);
+
+ // #i102548# create new unit polygon for line (horizontal)
+ basegfx::B2DPolygon aNewPolygon;
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
+ aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
+ aUnitPolyPolygon.setB2DPolygon(0, aNewPolygon);
+
+ // #i102548# fill objectMatrix with rotation and offset (no shear for lines)
+ aObjectMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aLine.getLength(), 1.0,
+ 0.0,
+ atan2(aLine.getY(), aLine.getX()),
+ aStart.getX(), aStart.getY());
+ }
+ else
+ {
+ // #i102548# create unscaled, unsheared, unrotated and untranslated polygon
+ // (unit polygon) by creating the object matrix and back-transforming the polygon
+ const basegfx::B2DRange aObjectRange(basegfx::tools::getRange(aUnitPolyPolygon));
+ const GeoStat& rGeoStat(GetPathObj().GetGeoStat());
+ const double fWidth(aObjectRange.getWidth());
+ const double fHeight(aObjectRange.getHeight());
+ const double fScaleX(basegfx::fTools::equalZero(fWidth) ? 1.0 : fWidth);
+ const double fScaleY(basegfx::fTools::equalZero(fHeight) ? 1.0 : fHeight);
+
+ aObjectMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ fScaleX, fScaleY,
+ rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
+ rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
+ aObjectRange.getMinX(), aObjectRange.getMinY());
+
+ // ceate unit polygon from object's absolute path
+ basegfx::B2DHomMatrix aInverse(aObjectMatrix);
+ aInverse.invert();
+ aUnitPolyPolygon.transform(aInverse);
+ }
+
+ // create primitive. Always create primitives to allow the decomposition of
+ // SdrPathPrimitive2D to create needed invisible elements for HitTest and/or BoundRect
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::SdrPathPrimitive2D(
+ aObjectMatrix,
+ aAttribute,
+ aUnitPolyPolygon));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx
new file mode 100644
index 000000000000..ea5448a51a66
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofsdrrectobj.hxx>
+#include <svx/svdorect.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx>
+#include <svl/itemset.hxx>
+#include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <svx/svdmodel.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfSdrRectObj::ViewContactOfSdrRectObj(SdrRectObj& rRectObj)
+ : ViewContactOfTextObj(rRectObj)
+ {
+ }
+
+ ViewContactOfSdrRectObj::~ViewContactOfSdrRectObj()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfSdrRectObj::createViewIndependentPrimitive2DSequence() const
+ {
+ const SfxItemSet& rItemSet = GetRectObj().GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineFillShadowTextAttribute aAttribute(
+ drawinglayer::primitive2d::createNewSdrLineFillShadowTextAttribute(
+ rItemSet,
+ GetRectObj().getText(0)));
+
+ // take unrotated snap rect (direct model data) for position and size
+ const Rectangle& rRectangle = GetRectObj().GetGeoRect();
+ const ::basegfx::B2DRange aObjectRange(
+ rRectangle.Left(), rRectangle.Top(),
+ rRectangle.Right(), rRectangle.Bottom());
+ const GeoStat& rGeoStat(GetRectObj().GetGeoStat());
+
+ // fill object matrix
+ basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aObjectRange.getWidth(), aObjectRange.getHeight(),
+ rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0,
+ rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0,
+ aObjectRange.getMinX(), aObjectRange.getMinY()));
+
+ // calculate corner radius
+ sal_uInt32 nCornerRadius(((SdrEckenradiusItem&)(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue());
+ double fCornerRadiusX;
+ double fCornerRadiusY;
+ drawinglayer::primitive2d::calculateRelativeCornerRadius(nCornerRadius, aObjectRange, fCornerRadiusX, fCornerRadiusY);
+
+ // #i105856# use knowledge about pickthrough from the model
+ const bool bPickThroughTransparentTextFrames(
+ GetRectObj().GetModel() && GetRectObj().GetModel()->IsPickThroughTransparentTextFrames());
+
+ // create primitive. Always create primitives to allow the decomposition of
+ // SdrRectanglePrimitive2D to create needed invisible elements for HitTest and/or BoundRect
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::SdrRectanglePrimitive2D(
+ aObjectMatrix,
+ aAttribute,
+ fCornerRadiusX,
+ fCornerRadiusY,
+ // #i105856# use fill for HitTest when TextFrame and not PickThrough
+ GetRectObj().IsTextFrame() && !bPickThroughTransparentTextFrames));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactoftextobj.cxx b/svx/source/sdr/contact/viewcontactoftextobj.cxx
new file mode 100644
index 000000000000..b36f7e2cd9a3
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactoftextobj.cxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactoftextobj.hxx>
+#include <svx/svdotext.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewContactOfTextObj::ViewContactOfTextObj(SdrTextObj& rTextObj)
+ : ViewContactOfSdrObj(rTextObj)
+ {
+ }
+
+ ViewContactOfTextObj::~ViewContactOfTextObj()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofunocontrol.cxx b/svx/source/sdr/contact/viewcontactofunocontrol.cxx
new file mode 100644
index 000000000000..ac3d10c271a4
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofunocontrol.cxx
@@ -0,0 +1,184 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewcontactofunocontrol.hxx>
+#include <svx/sdr/contact/viewobjectcontactofunocontrol.hxx>
+#include <svx/sdr/contact/objectcontactofpageview.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <svx/sdrpagewindow.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XWindow2.hpp>
+/** === end UNO includes === **/
+
+#include "sdrpaintwindow.hxx"
+#include <tools/diagnose_ex.h>
+#include <vcl/pdfextoutdevdata.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/primitive2d/controlprimitive2d.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//........................................................................
+namespace sdr { namespace contact {
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::awt::XControl;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::awt::XControlContainer;
+ using ::com::sun::star::awt::XControlModel;
+ using ::com::sun::star::awt::XWindow2;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::Exception;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= ViewContactOfUnoControl
+ //====================================================================
+ class ViewContactOfUnoControl_Impl
+ {
+ public:
+ ViewContactOfUnoControl_Impl();
+ ~ViewContactOfUnoControl_Impl();
+
+ private:
+ ViewContactOfUnoControl_Impl( const ViewContactOfUnoControl_Impl& ); // never implemented
+ ViewContactOfUnoControl_Impl& operator=( const ViewContactOfUnoControl_Impl& ); // never implemented
+ };
+
+ //--------------------------------------------------------------------
+ ViewContactOfUnoControl_Impl::ViewContactOfUnoControl_Impl()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ViewContactOfUnoControl_Impl::~ViewContactOfUnoControl_Impl()
+ {
+ }
+
+ //====================================================================
+ //= ViewContactOfUnoControl
+ //====================================================================
+ DBG_NAME( ViewContactOfUnoControl )
+ //--------------------------------------------------------------------
+ ViewContactOfUnoControl::ViewContactOfUnoControl( SdrUnoObj& _rUnoObject )
+ :ViewContactOfSdrObj( _rUnoObject )
+ ,m_pImpl( new ViewContactOfUnoControl_Impl )
+ {
+ DBG_CTOR( ViewContactOfUnoControl, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ViewContactOfUnoControl::~ViewContactOfUnoControl()
+ {
+ DBG_DTOR( ViewContactOfUnoControl, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XControl > ViewContactOfUnoControl::getTemporaryControlForWindow(
+ const Window& _rWindow, Reference< XControlContainer >& _inout_ControlContainer ) const
+ {
+ SdrUnoObj* pUnoObject = dynamic_cast< SdrUnoObj* >( TryToGetSdrObject() );
+ OSL_ENSURE( pUnoObject, "ViewContactOfUnoControl::getTemporaryControlForDevice: no SdrUnoObj!" );
+ if ( !pUnoObject )
+ return NULL;
+ return ViewObjectContactOfUnoControl::getTemporaryControlForWindow( _rWindow, _inout_ControlContainer, *pUnoObject );
+ }
+
+ //--------------------------------------------------------------------
+ ViewObjectContact& ViewContactOfUnoControl::CreateObjectSpecificViewObjectContact( ObjectContact& _rObjectContact )
+ {
+ // print or print preview requires special handling
+ const OutputDevice* pDevice = _rObjectContact.TryToGetOutputDevice();
+ bool bPrintOrPreview = ( pDevice != NULL ) && ( pDevice->GetOutDevType() == OUTDEV_PRINTER );
+
+ ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &_rObjectContact );
+ bPrintOrPreview |= ( pPageViewContact != NULL ) && pPageViewContact->GetPageWindow().GetPageView().GetView().IsPrintPreview();
+
+ if ( bPrintOrPreview )
+ return *new UnoControlPrintOrPreviewContact( *pPageViewContact, *this );
+
+ // all others are nowadays served by the same implementation
+ return *new ViewObjectContactOfUnoControl( _rObjectContact, *this );
+ }
+
+ //--------------------------------------------------------------------
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfUnoControl::createViewIndependentPrimitive2DSequence() const
+ {
+ // create range. Use model data directly, not getBoundRect()/getSnapRect; these will use
+ // the primitive data themselves in the long run. Use SdrUnoObj's (which is a SdrRectObj)
+ // call to GetGeoRect() to access SdrTextObj::aRect directly and without executing anything
+ const Rectangle& rRectangle(GetSdrUnoObj().GetGeoRect());
+ const basegfx::B2DRange aRange(
+ rRectangle.Left(), rRectangle.Top(),
+ rRectangle.Right(), rRectangle.Bottom());
+
+ // create object transform
+ basegfx::B2DHomMatrix aTransform;
+
+ aTransform.set(0, 0, aRange.getWidth());
+ aTransform.set(1, 1, aRange.getHeight());
+ aTransform.set(0, 2, aRange.getMinX());
+ aTransform.set(1, 2, aRange.getMinY());
+
+ Reference< XControlModel > xControlModel = GetSdrUnoObj().GetUnoControlModel();
+
+ if(xControlModel.is())
+ {
+ // create control primitive WITHOUT possibly existing XControl; this would be done in
+ // the VOC in createPrimitive2DSequence()
+ const drawinglayer::primitive2d::Primitive2DReference xRetval(
+ new drawinglayer::primitive2d::ControlPrimitive2D(
+ aTransform,
+ xControlModel));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
+ }
+ else
+ {
+ // always append an invisible outline for the cases where no visible content exists
+ const drawinglayer::primitive2d::Primitive2DReference xRetval(
+ drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
+ false, aTransform));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
+ }
+ }
+
+//........................................................................
+} } // namespace sdr::contact
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewcontactofvirtobj.cxx b/svx/source/sdr/contact/viewcontactofvirtobj.cxx
new file mode 100644
index 000000000000..31d1a2d9a9bd
--- /dev/null
+++ b/svx/source/sdr/contact/viewcontactofvirtobj.cxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactofvirtobj.hxx>
+#include <svx/svdovirt.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <vcl/outdev.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ SdrVirtObj& ViewContactOfVirtObj::GetVirtObj() const
+ {
+ return (SdrVirtObj&)mrObject;
+ }
+
+ ViewContactOfVirtObj::ViewContactOfVirtObj(SdrVirtObj& rObj)
+ : ViewContactOfSdrObj(rObj)
+ {
+ }
+
+ ViewContactOfVirtObj::~ViewContactOfVirtObj()
+ {
+ }
+
+ // Access to possible sub-hierarchy
+ sal_uInt32 ViewContactOfVirtObj::GetObjectCount() const
+ {
+ // Here, SdrVirtObj's need to return 0L to show that they have no
+ // sub-hierarchy, even when they are group objects. This is necessary
+ // to avoid that the same VOCs will be added to the draw hierarchy
+ // twice which leads to problems.
+ //
+ // This solution is only a first solution to get things running. Later
+ // this needs to be replaced with creating real VOCs for the objects
+ // referenced by virtual objects to avoid the 'trick' of setting the
+ // offset for painting at the destination OutputDevive.
+ //
+ // As can be seen, with primitives, the problem will be solved using
+ // a transformPrimitive, so this solution can stay with primitives.
+ return 0L;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfVirtObj::createViewIndependentPrimitive2DSequence() const
+ {
+ // create displacement transformation if we have content
+ basegfx::B2DHomMatrix aObjectMatrix;
+ Point aAnchor(GetVirtObj().GetAnchorPos());
+
+ if(aAnchor.X() || aAnchor.Y())
+ {
+ aObjectMatrix.set(0, 2, aAnchor.X());
+ aObjectMatrix.set(1, 2, aAnchor.Y());
+ }
+
+ // use method from referenced object to get the Primitive2DSequence
+ const drawinglayer::primitive2d::Primitive2DSequence xSequenceVirtual(
+ GetVirtObj().GetReferencedObj().GetViewContact().getViewIndependentPrimitive2DSequence());
+
+ if(xSequenceVirtual.hasElements())
+ {
+ // create transform primitive
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ new drawinglayer::primitive2d::TransformPrimitive2D(
+ aObjectMatrix,
+ xSequenceVirtual));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ else
+ {
+ // always append an invisible outline for the cases where no visible content exists
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
+ false, aObjectMatrix));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx b/svx/source/sdr/contact/viewobjectcontact.cxx
new file mode 100644
index 000000000000..dc562ba2b458
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontact.cxx
@@ -0,0 +1,441 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <vcl/region.hxx>
+#include <svx/sdr/animation/objectanimator.hxx>
+#include <svx/sdr/animation/animationstate.hxx>
+#include <svx/sdr/contact/viewobjectcontactredirector.hxx>
+#include <basegfx/numeric/ftools.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
+#include <basegfx/tools/canvastools.hxx>
+#include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <svx/sdr/contact/viewobjectcontactredirector.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace
+{
+ // animated extractor
+
+ // Necessary to filter a sequence of animated primitives from
+ // a sequence of primitives to find out if animated or not. The decision for
+ // what to decompose is hard-coded and only done for knowingly animated primitives
+ // to not decompose too deeply and unnecessarily. This implies that the list
+ // which is view-specific needs to be expanded by hand when new animated objects
+ // are added. This may eventually be changed to a dynamically configurable approach
+ // if necessary.
+ class AnimatedExtractingProcessor2D : public drawinglayer::processor2d::BaseProcessor2D
+ {
+ protected:
+ // the found animated primitives
+ drawinglayer::primitive2d::Primitive2DSequence maPrimitive2DSequence;
+
+ // bitfield
+ // text animation allowed?
+ unsigned mbTextAnimationAllowed : 1;
+
+ // graphic animation allowed?
+ unsigned mbGraphicAnimationAllowed : 1;
+
+ // as tooling, the process() implementation takes over API handling and calls this
+ // virtual render method when the primitive implementation is BasePrimitive2D-based.
+ virtual void processBasePrimitive2D(const drawinglayer::primitive2d::BasePrimitive2D& rCandidate);
+
+ public:
+ AnimatedExtractingProcessor2D(
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation,
+ bool bTextAnimationAllowed,
+ bool bGraphicAnimationAllowed);
+ virtual ~AnimatedExtractingProcessor2D();
+
+ // data access
+ const drawinglayer::primitive2d::Primitive2DSequence& getPrimitive2DSequence() const { return maPrimitive2DSequence; }
+ bool isTextAnimationAllowed() const { return mbTextAnimationAllowed; }
+ bool isGraphicAnimationAllowed() const { return mbGraphicAnimationAllowed; }
+ };
+
+ AnimatedExtractingProcessor2D::AnimatedExtractingProcessor2D(
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation,
+ bool bTextAnimationAllowed,
+ bool bGraphicAnimationAllowed)
+ : drawinglayer::processor2d::BaseProcessor2D(rViewInformation),
+ maPrimitive2DSequence(),
+ mbTextAnimationAllowed(bTextAnimationAllowed),
+ mbGraphicAnimationAllowed(bGraphicAnimationAllowed)
+ {
+ }
+
+ AnimatedExtractingProcessor2D::~AnimatedExtractingProcessor2D()
+ {
+ }
+
+ void AnimatedExtractingProcessor2D::processBasePrimitive2D(const drawinglayer::primitive2d::BasePrimitive2D& rCandidate)
+ {
+ // known implementation, access directly
+ switch(rCandidate.getPrimitive2DID())
+ {
+ // add and accept animated primitives directly, no need to decompose
+ case PRIMITIVE2D_ID_ANIMATEDSWITCHPRIMITIVE2D :
+ case PRIMITIVE2D_ID_ANIMATEDBLINKPRIMITIVE2D :
+ case PRIMITIVE2D_ID_ANIMATEDINTERPOLATEPRIMITIVE2D :
+ {
+ const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D& rSwitchPrimitive = static_cast< const drawinglayer::primitive2d::AnimatedSwitchPrimitive2D& >(rCandidate);
+
+ if((rSwitchPrimitive.isTextAnimation() && isTextAnimationAllowed())
+ || (rSwitchPrimitive.isGraphicAnimation() && isGraphicAnimationAllowed()))
+ {
+ const drawinglayer::primitive2d::Primitive2DReference xReference(const_cast< drawinglayer::primitive2d::BasePrimitive2D* >(&rCandidate));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(maPrimitive2DSequence, xReference);
+ }
+ break;
+ }
+
+ // decompose animated gifs where SdrGrafPrimitive2D produces a GraphicPrimitive2D
+ // which then produces the animation infos (all when used/needed)
+ case PRIMITIVE2D_ID_SDRGRAFPRIMITIVE2D :
+ case PRIMITIVE2D_ID_GRAPHICPRIMITIVE2D :
+
+ // decompose SdrObjects with evtl. animated text
+ case PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D :
+ case PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D :
+ case PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D :
+ case PRIMITIVE2D_ID_SDRELLIPSEPRIMITIVE2D :
+ case PRIMITIVE2D_ID_SDRELLIPSESEGMENTPRIMITIVE2D :
+ case PRIMITIVE2D_ID_SDRMEASUREPRIMITIVE2D :
+ case PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D :
+ case PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D :
+
+ // decompose evtl. animated text contained in MaskPrimitive2D
+ // or group rimitives
+ case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
+ case PRIMITIVE2D_ID_GROUPPRIMITIVE2D :
+ {
+ process(rCandidate.get2DDecomposition(getViewInformation2D()));
+ break;
+ }
+
+ default :
+ {
+ // nothing to do for the rest
+ break;
+ }
+ }
+ }
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContact::ViewObjectContact(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : mrObjectContact(rObjectContact),
+ mrViewContact(rViewContact),
+ maObjectRange(),
+ mxPrimitive2DSequence(),
+ mpPrimitiveAnimation(0),
+ mbLazyInvalidate(false)
+ {
+ // make the ViewContact remember me
+ mrViewContact.AddViewObjectContact(*this);
+
+ // make the ObjectContact remember me
+ mrObjectContact.AddViewObjectContact(*this);
+ }
+
+ ViewObjectContact::~ViewObjectContact()
+ {
+ // invalidate in view
+ if(!maObjectRange.isEmpty())
+ {
+ GetObjectContact().InvalidatePartOfView(maObjectRange);
+ }
+
+ // delete PrimitiveAnimation
+ if(mpPrimitiveAnimation)
+ {
+ delete mpPrimitiveAnimation;
+ mpPrimitiveAnimation = 0;
+ }
+
+ // take care of remebered ObjectContact. Remove from
+ // OC first. The VC removal (below) CAN trigger a StopGettingViewed()
+ // which (depending of it's implementation) may destroy other OCs. This
+ // can trigger the deletion of the helper OC of a page visualising object
+ // which IS the OC of this object. Eventually StopGettingViewed() needs
+ // to get asynchron later
+ GetObjectContact().RemoveViewObjectContact(*this);
+
+ // take care of remebered ViewContact
+ GetViewContact().RemoveViewObjectContact(*this);
+ }
+
+ const basegfx::B2DRange& ViewObjectContact::getObjectRange() const
+ {
+ if(maObjectRange.isEmpty())
+ {
+ // if range is not computed (new or LazyInvalidate objects), force it
+ const DisplayInfo aDisplayInfo;
+ const drawinglayer::primitive2d::Primitive2DSequence xSequence(getPrimitive2DSequence(aDisplayInfo));
+
+ if(xSequence.hasElements())
+ {
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
+ const_cast< ViewObjectContact* >(this)->maObjectRange =
+ drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xSequence, rViewInformation2D);
+ }
+ }
+
+ return maObjectRange;
+ }
+
+ void ViewObjectContact::ActionChanged()
+ {
+ if(!mbLazyInvalidate)
+ {
+ // set local flag
+ mbLazyInvalidate = true;
+
+ // force ObjectRange
+ getObjectRange();
+
+ if(!maObjectRange.isEmpty())
+ {
+ // invalidate current valid range
+ GetObjectContact().InvalidatePartOfView(maObjectRange);
+
+ // reset ObjectRange, it needs to be recalculated
+ maObjectRange.reset();
+ }
+
+ // register at OC for lazy invalidate
+ GetObjectContact().setLazyInvalidate(*this);
+ }
+ }
+
+ void ViewObjectContact::triggerLazyInvalidate()
+ {
+ if(mbLazyInvalidate)
+ {
+ // reset flag
+ mbLazyInvalidate = false;
+
+ // force ObjectRange
+ getObjectRange();
+
+ if(!maObjectRange.isEmpty())
+ {
+ // invalidate current valid range
+ GetObjectContact().InvalidatePartOfView(maObjectRange);
+ }
+ }
+ }
+
+ // Take some action when new objects are inserted
+ void ViewObjectContact::ActionChildInserted(ViewContact& rChild)
+ {
+ // force creation of the new VOC and trigger it's refresh, so it
+ // will take part in LazyInvalidate immediately
+ rChild.GetViewObjectContact(GetObjectContact()).ActionChanged();
+
+ // forward action to ObjectContact
+ // const ViewObjectContact& rChildVOC = rChild.GetViewObjectContact(GetObjectContact());
+ // GetObjectContact().InvalidatePartOfView(rChildVOC.getObjectRange());
+ }
+
+ void ViewObjectContact::checkForPrimitive2DAnimations()
+ {
+ // remove old one
+ if(mpPrimitiveAnimation)
+ {
+ delete mpPrimitiveAnimation;
+ mpPrimitiveAnimation = 0;
+ }
+
+ // check for animated primitives
+ if(mxPrimitive2DSequence.hasElements())
+ {
+ const bool bTextAnimationAllowed(GetObjectContact().IsTextAnimationAllowed());
+ const bool bGraphicAnimationAllowed(GetObjectContact().IsGraphicAnimationAllowed());
+
+ if(bTextAnimationAllowed || bGraphicAnimationAllowed)
+ {
+ AnimatedExtractingProcessor2D aAnimatedExtractor(GetObjectContact().getViewInformation2D(),
+ bTextAnimationAllowed, bGraphicAnimationAllowed);
+ aAnimatedExtractor.process(mxPrimitive2DSequence);
+
+ if(aAnimatedExtractor.getPrimitive2DSequence().hasElements())
+ {
+ // dervied primitiveList is animated, setup new PrimitiveAnimation
+ mpPrimitiveAnimation = new sdr::animation::PrimitiveAnimation(*this, aAnimatedExtractor.getPrimitive2DSequence());
+ }
+ }
+ }
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
+ {
+ // get the view-independent Primitive from the viewContact
+ drawinglayer::primitive2d::Primitive2DSequence xRetval(GetViewContact().getViewIndependentPrimitive2DSequence());
+
+ if(xRetval.hasElements())
+ {
+ // handle GluePoint
+ if(!GetObjectContact().isOutputToPrinter() && GetObjectContact().AreGluePointsVisible())
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence xGlue(GetViewContact().createGluePointPrimitive2DSequence());
+
+ if(xGlue.hasElements())
+ {
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xGlue);
+ }
+ }
+
+ // handle ghosted
+ if(isPrimitiveGhosted(rDisplayInfo))
+ {
+ const basegfx::BColor aRGBWhite(1.0, 1.0, 1.0);
+ const basegfx::BColorModifier aBColorModifier(aRGBWhite, 0.5, basegfx::BCOLORMODIFYMODE_INTERPOLATE);
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ModifiedColorPrimitive2D(xRetval, aBColorModifier));
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ }
+
+ return xRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::getPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xNewPrimitiveSequence;
+
+ // take care of redirectors and create new list
+ ViewObjectContactRedirector* pRedirector = GetObjectContact().GetViewObjectContactRedirector();
+
+ if(pRedirector)
+ {
+ xNewPrimitiveSequence = pRedirector->createRedirectedPrimitive2DSequence(*this, rDisplayInfo);
+ }
+ else
+ {
+ xNewPrimitiveSequence = createPrimitive2DSequence(rDisplayInfo);
+ }
+
+ // local up-to-date checks. New list different from local one?
+ if(!drawinglayer::primitive2d::arePrimitive2DSequencesEqual(mxPrimitive2DSequence, xNewPrimitiveSequence))
+ {
+ // has changed, copy content
+ const_cast< ViewObjectContact* >(this)->mxPrimitive2DSequence = xNewPrimitiveSequence;
+
+ // check for animated stuff
+ const_cast< ViewObjectContact* >(this)->checkForPrimitive2DAnimations();
+
+ // always update object range when PrimitiveSequence changes
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
+ const_cast< ViewObjectContact* >(this)->maObjectRange =
+ drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(mxPrimitive2DSequence, rViewInformation2D);
+ }
+
+ // return current Primitive2DSequence
+ return mxPrimitive2DSequence;
+ }
+
+ bool ViewObjectContact::isPrimitiveVisible(const DisplayInfo& /*rDisplayInfo*/) const
+ {
+ // default: always visible
+ return true;
+ }
+
+ bool ViewObjectContact::isPrimitiveGhosted(const DisplayInfo& rDisplayInfo) const
+ {
+ // default: standard check
+ return (GetObjectContact().DoVisualizeEnteredGroup() && !GetObjectContact().isOutputToPrinter() && rDisplayInfo.IsGhostedDrawModeActive());
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ // check model-view visibility
+ if(isPrimitiveVisible(rDisplayInfo))
+ {
+ xRetval = getPrimitive2DSequence(rDisplayInfo);
+
+ if(xRetval.hasElements())
+ {
+ // get ranges
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
+ const basegfx::B2DRange aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval, rViewInformation2D));
+ const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
+
+ // check geometrical visibility
+ if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
+ {
+ // not visible, release
+ xRetval.realloc(0);
+ }
+ }
+ }
+
+ return xRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContact::getPrimitive2DSequenceSubHierarchy(DisplayInfo& rDisplayInfo) const
+ {
+ const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
+ drawinglayer::primitive2d::Primitive2DSequence xSeqRetval;
+
+ for(sal_uInt32 a(0); a < nSubHierarchyCount; a++)
+ {
+ const ViewObjectContact& rCandidate(GetViewContact().GetViewContact(a).GetViewObjectContact(GetObjectContact()));
+
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xSeqRetval, rCandidate.getPrimitive2DSequenceHierarchy(rDisplayInfo));
+ }
+
+ return xSeqRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofe3d.cxx b/svx/source/sdr/contact/viewobjectcontactofe3d.cxx
new file mode 100644
index 000000000000..40c16bea602a
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofe3d.cxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewobjectcontactofe3d.hxx>
+#include <svx/sdr/contact/viewcontactofe3d.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx>
+#include <svx/sdr/contact/viewobjectcontactofe3dscene.hxx>
+#include <drawinglayer/primitive2d/embedded3dprimitive2d.hxx>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// predeclarations
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfE3d::ViewObjectContactOfE3d(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfE3d::~ViewObjectContactOfE3d()
+ {
+ }
+
+ drawinglayer::primitive3d::Primitive3DSequence ViewObjectContactOfE3d::createPrimitive3DSequence(const DisplayInfo& rDisplayInfo) const
+ {
+ // get the view-independent Primitive from the viewContact
+ const ViewContactOfE3d& rViewContactOfE3d(dynamic_cast< const ViewContactOfE3d& >(GetViewContact()));
+ drawinglayer::primitive3d::Primitive3DSequence xRetval(rViewContactOfE3d.getViewIndependentPrimitive3DSequence());
+
+ // handle ghosted
+ if(isPrimitiveGhosted(rDisplayInfo))
+ {
+ const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0);
+ const ::basegfx::BColorModifier aBColorModifier(aRGBWhite, 0.5, ::basegfx::BCOLORMODIFYMODE_INTERPOLATE);
+ const drawinglayer::primitive3d::Primitive3DReference xReference(new drawinglayer::primitive3d::ModifiedColorPrimitive3D(xRetval, aBColorModifier));
+ xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
+ }
+
+ return xRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfE3d::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
+ {
+ const ViewContactOfE3d& rViewContact = static_cast< const ViewContactOfE3d& >(GetViewContact());
+
+ // get 3d primitive vector, isPrimitiveVisible() is done in 3d creator
+ return rViewContact.impCreateWithGivenPrimitive3DSequence(getPrimitive3DSequence(rDisplayInfo));
+ }
+
+ drawinglayer::primitive3d::Primitive3DSequence ViewObjectContactOfE3d::getPrimitive3DSequence(const DisplayInfo& rDisplayInfo) const
+ {
+ drawinglayer::primitive3d::Primitive3DSequence xNewPrimitive3DSeq(createPrimitive3DSequence(rDisplayInfo));
+
+ // local up-to-date checks. New list different from local one?
+ if(!drawinglayer::primitive3d::arePrimitive3DSequencesEqual(mxPrimitive3DSequence, xNewPrimitive3DSeq))
+ {
+ // has changed, copy content
+ const_cast< ViewObjectContactOfE3d* >(this)->mxPrimitive3DSequence = xNewPrimitive3DSeq;
+ }
+
+ // return current Primitive2DSequence
+ return mxPrimitive3DSequence;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx b/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx
new file mode 100644
index 000000000000..40868bc97938
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewobjectcontactofe3dscene.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/sdr/contact/viewcontactofe3dscene.hxx>
+#include <basegfx/matrix/b3dhommatrix.hxx>
+#include <drawinglayer/primitive3d/transformprimitive3d.hxx>
+#include <basegfx/color/bcolormodifier.hxx>
+#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
+#include <svx/sdr/contact/viewobjectcontactofe3d.hxx>
+#include <basegfx/tools/canvastools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace
+{
+ // Helper method to recursively travel the DrawHierarchy for 3D objects contained in
+ // the 2D Scene. This will chreate all VOCs for the currenbt OC which are needed
+ // for ActionChanged() functionality
+ void impInternalSubHierarchyTraveller(const sdr::contact::ViewObjectContact& rVOC)
+ {
+ const sdr::contact::ViewContact& rVC = rVOC.GetViewContact();
+ const sal_uInt32 nSubHierarchyCount(rVC.GetObjectCount());
+
+ for(sal_uInt32 a(0); a < nSubHierarchyCount; a++)
+ {
+ const sdr::contact::ViewObjectContact& rCandidate(rVC.GetViewContact(a).GetViewObjectContact(rVOC.GetObjectContact()));
+ impInternalSubHierarchyTraveller(rCandidate);
+ }
+ }
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfE3dScene::ViewObjectContactOfE3dScene(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfE3dScene::~ViewObjectContactOfE3dScene()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfE3dScene::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
+ {
+ // handle ghosted, else the whole 3d group will be encapsulated to a ghosted primitive set (see below)
+ const bool bHandleGhostedDisplay(GetObjectContact().DoVisualizeEnteredGroup() && !GetObjectContact().isOutputToPrinter() && rDisplayInfo.IsGhostedDrawModeActive());
+ const bool bIsActiveVC(bHandleGhostedDisplay && GetObjectContact().getActiveViewContact() == &GetViewContact());
+
+ if(bIsActiveVC)
+ {
+ // switch off ghosted, display contents normal
+ const_cast< DisplayInfo& >(rDisplayInfo).ClearGhostedDrawMode();
+ }
+
+ // create 2d primitive with content, use layer visibility test
+ // this uses no ghosted mode, so scenes in scenes and entering them will not
+ // support ghosted for now. This is no problem currently but would need to be
+ // added when sub-groups in 3d will be added one day.
+ const ViewContactOfE3dScene& rViewContact = dynamic_cast< ViewContactOfE3dScene& >(GetViewContact());
+ const SetOfByte& rVisibleLayers = rDisplayInfo.GetProcessLayers();
+ drawinglayer::primitive2d::Primitive2DSequence xRetval(rViewContact.createScenePrimitive2DSequence(&rVisibleLayers));
+
+ if(xRetval.hasElements())
+ {
+ // handle GluePoint
+ if(!GetObjectContact().isOutputToPrinter() && GetObjectContact().AreGluePointsVisible())
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence xGlue(GetViewContact().createGluePointPrimitive2DSequence());
+
+ if(xGlue.hasElements())
+ {
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xGlue);
+ }
+ }
+
+ // handle ghosted
+ if(isPrimitiveGhosted(rDisplayInfo))
+ {
+ const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0);
+ const ::basegfx::BColorModifier aBColorModifier(aRGBWhite, 0.5, ::basegfx::BCOLORMODIFYMODE_INTERPOLATE);
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ModifiedColorPrimitive2D(xRetval, aBColorModifier));
+
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ }
+
+ if(bIsActiveVC)
+ {
+ // set back, display ghosted again
+ const_cast< DisplayInfo& >(rDisplayInfo).SetGhostedDrawMode();
+ }
+
+ return xRetval;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfE3dScene::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
+ {
+ // To get the VOCs for the contained 3D objects created to get the correct
+ // Draw hierarchy and ActionChanged() working properly, travel the DrawHierarchy
+ // using a local tooling method
+ impInternalSubHierarchyTraveller(*this);
+
+ // call parent
+ return ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo);
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
new file mode 100644
index 000000000000..cb746f531852
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofgraphic.cxx
@@ -0,0 +1,330 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewobjectcontactofgraphic.hxx>
+#include <svx/sdr/contact/viewcontactofgraphic.hxx>
+#include <svx/sdr/event/eventhandler.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace event
+ {
+ class AsynchGraphicLoadingEvent : public BaseEvent
+ {
+ // the ViewContactOfGraphic to work with
+ sdr::contact::ViewObjectContactOfGraphic& mrVOCOfGraphic;
+
+ public:
+ // basic constructor.
+ AsynchGraphicLoadingEvent(EventHandler& rEventHandler, sdr::contact::ViewObjectContactOfGraphic& rVOCOfGraphic);
+
+ // destructor
+ virtual ~AsynchGraphicLoadingEvent();
+
+ // the called method if the event is triggered
+ virtual void ExecuteEvent();
+ };
+
+ AsynchGraphicLoadingEvent::AsynchGraphicLoadingEvent(
+ EventHandler& rEventHandler, sdr::contact::ViewObjectContactOfGraphic& rVOCOfGraphic)
+ : BaseEvent(rEventHandler),
+ mrVOCOfGraphic(rVOCOfGraphic)
+ {
+ }
+
+ AsynchGraphicLoadingEvent::~AsynchGraphicLoadingEvent()
+ {
+ mrVOCOfGraphic.forgetAsynchGraphicLoadingEvent(this);
+ }
+
+ void AsynchGraphicLoadingEvent::ExecuteEvent()
+ {
+ mrVOCOfGraphic.doAsynchGraphicLoading();
+ }
+ } // end of namespace event
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ // Test graphics state and eventually trigger a SwapIn event or an Asynchronous
+ // load event. Return value gives info if SwapIn was triggered or not
+ bool ViewObjectContactOfGraphic::impPrepareGraphicWithAsynchroniousLoading()
+ {
+ bool bRetval(false);
+ SdrGrafObj& rGrafObj = getSdrGrafObj();
+
+ if(rGrafObj.IsSwappedOut())
+ {
+ if(rGrafObj.IsLinkedGraphic())
+ {
+ // update graphic link
+ rGrafObj.ImpUpdateGraphicLink();
+ }
+ else
+ {
+ // SwapIn needs to be done. Decide if it can be done asynchronious.
+ bool bSwapInAsynchronious(false);
+ ObjectContact& rObjectContact = GetObjectContact();
+
+ // only when allowed from configuration
+ if(rObjectContact.IsAsynchronGraphicsLoadingAllowed())
+ {
+ // direct output or vdev output (PageView buffering)
+ if(rObjectContact.isOutputToWindow() || rObjectContact.isOutputToVirtualDevice())
+ {
+ // only when no metafile recording
+ if(!rObjectContact.isOutputToRecordingMetaFile())
+ {
+ // allow asynchronious loading
+ bSwapInAsynchronious = true;
+ }
+ }
+ }
+
+ if(bSwapInAsynchronious)
+ {
+ // maybe it's on the way, then do nothing
+ if(!mpAsynchLoadEvent)
+ {
+ // Trigger asynchronious SwapIn.
+ sdr::event::TimerEventHandler& rEventHandler = rObjectContact.GetEventHandler();
+
+ mpAsynchLoadEvent = new sdr::event::AsynchGraphicLoadingEvent(rEventHandler, *this);
+ }
+ }
+ else
+ {
+ if(rObjectContact.isOutputToPrinter())
+ {
+ // #i76395# preview mechanism is only active if
+ // swapin is called from inside paint preparation, so mbInsidePaint
+ // has to be false to be able to print with high resolution
+ rGrafObj.ForceSwapIn();
+ }
+ else
+ {
+ // SwapIn direct
+ rGrafObj.mbInsidePaint = sal_True;
+ rGrafObj.ForceSwapIn();
+ rGrafObj.mbInsidePaint = sal_False;
+ }
+
+ bRetval = true;
+ }
+ }
+ }
+ else
+ {
+ // it is not swapped out, somehow it was loaded. In that case, forget
+ // about an existing triggered event
+ if(mpAsynchLoadEvent)
+ {
+ // just delete it, this will remove it from the EventHandler and
+ // will trigger forgetAsynchGraphicLoadingEvent from the destructor
+ delete mpAsynchLoadEvent;
+ }
+ }
+
+ return bRetval;
+ }
+
+ // Test graphics state and eventually trigger a SwapIn event. Return value
+ // gives info if SwapIn was triggered or not
+ bool ViewObjectContactOfGraphic::impPrepareGraphicWithSynchroniousLoading()
+ {
+ bool bRetval(false);
+ SdrGrafObj& rGrafObj = getSdrGrafObj();
+
+ if(rGrafObj.IsSwappedOut())
+ {
+ if(rGrafObj.IsLinkedGraphic())
+ {
+ // update graphic link
+ rGrafObj.ImpUpdateGraphicLink();
+ }
+ else
+ {
+ ObjectContact& rObjectContact = GetObjectContact();
+
+ if(rObjectContact.isOutputToPrinter())
+ {
+ // #i76395# preview mechanism is only active if
+ // swapin is called from inside paint preparation, so mbInsidePaint
+ // has to be false to be able to print with high resolution
+ rGrafObj.ForceSwapIn();
+ }
+ else
+ {
+ // SwapIn direct
+ rGrafObj.mbInsidePaint = sal_True;
+ rGrafObj.ForceSwapIn();
+ rGrafObj.mbInsidePaint = sal_False;
+ }
+
+ bRetval = true;
+ }
+ }
+
+ return bRetval;
+ }
+
+ // This is the call from the asynch graphic loading. This may only be called from
+ // AsynchGraphicLoadingEvent::ExecuteEvent(). Do load the graphics. The event will
+ // be deleted (consumed) and forgetAsynchGraphicLoadingEvent will be called.
+ void ViewObjectContactOfGraphic::doAsynchGraphicLoading()
+ {
+ DBG_ASSERT(mpAsynchLoadEvent, "ViewObjectContactOfGraphic::doAsynchGraphicLoading: I did not trigger a event, why am i called (?)");
+
+ // swap it in
+ SdrGrafObj& rGrafObj = getSdrGrafObj();
+ rGrafObj.ForceSwapIn();
+
+ // #i103720# forget event to avoid possible deletion by the following ActionChanged call
+ // which may use createPrimitive2DSequence/impPrepareGraphicWithAsynchroniousLoading again.
+ // Deletion is actally done by the scheduler who leaded to coming here
+ mpAsynchLoadEvent = 0;
+
+ // Invalidate all paint areas and check existing animation (which may have changed).
+ GetViewContact().ActionChanged();
+ }
+
+ // This is the call from the destructor of the asynch graphic loading event.
+ // No one else has to call this. It is needed to let this object forget about
+ // the event. The parameter allows checking for the correct event.
+ void ViewObjectContactOfGraphic::forgetAsynchGraphicLoadingEvent(sdr::event::AsynchGraphicLoadingEvent* pEvent)
+ {
+ (void) pEvent; // suppress warning
+
+ if(mpAsynchLoadEvent)
+ {
+ OSL_ENSURE(!pEvent || mpAsynchLoadEvent == pEvent,
+ "ViewObjectContactOfGraphic::forgetAsynchGraphicLoadingEvent: Forced to forget another event then i have scheduled (?)");
+
+ // forget event
+ mpAsynchLoadEvent = 0;
+ }
+ }
+
+ SdrGrafObj& ViewObjectContactOfGraphic::getSdrGrafObj()
+ {
+ return static_cast< ViewContactOfGraphic& >(GetViewContact()).GetGrafObject();
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfGraphic::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
+ {
+ // prepare primitive generation with evtl. loading the graphic when it's swapped out
+ SdrGrafObj& rGrafObj = const_cast< ViewObjectContactOfGraphic* >(this)->getSdrGrafObj();
+ bool bDoAsynchronGraphicLoading(rGrafObj.GetModel() && rGrafObj.GetModel()->IsSwapGraphics());
+ static bool bSuppressAsynchLoading(false);
+ bool bSwapInDone(false);
+
+ if(bDoAsynchronGraphicLoading
+ && rGrafObj.IsSwappedOut()
+ && rGrafObj.GetPage()
+ && rGrafObj.GetPage()->IsMasterPage())
+ {
+ // #i102380# force Swap-In for GraphicObjects on MasterPage to have a nicer visualisation
+ bDoAsynchronGraphicLoading = false;
+ }
+
+ if(bDoAsynchronGraphicLoading && !bSuppressAsynchLoading)
+ {
+ bSwapInDone = const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareGraphicWithAsynchroniousLoading();
+ }
+ else
+ {
+ bSwapInDone = const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareGraphicWithSynchroniousLoading();
+ }
+
+ // get return value by calling parent
+ drawinglayer::primitive2d::Primitive2DSequence xRetval = ViewObjectContactOfSdrObj::createPrimitive2DSequence(rDisplayInfo);
+
+ if(xRetval.hasElements())
+ {
+ // #i103255# suppress when graphic needs draft visualisation and output
+ // is for PDF export/Printer
+ const ViewContactOfGraphic& rVCOfGraphic = static_cast< const ViewContactOfGraphic& >(GetViewContact());
+
+ if(rVCOfGraphic.visualisationUsesDraft())
+ {
+ const ObjectContact& rObjectContact = GetObjectContact();
+
+ if(rObjectContact.isOutputToPDFFile() || rObjectContact.isOutputToPrinter())
+ {
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence();
+ }
+ }
+ }
+
+ // if swap in was forced only for printing, swap out again
+ const bool bSwapInExclusiveForPrinting(bSwapInDone && GetObjectContact().isOutputToPrinter());
+
+ if(bSwapInExclusiveForPrinting)
+ {
+ rGrafObj.ForceSwapOut();
+ }
+
+ return xRetval;
+ }
+
+ ViewObjectContactOfGraphic::ViewObjectContactOfGraphic(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfSdrObj(rObjectContact, rViewContact),
+ mpAsynchLoadEvent(0)
+ {
+ }
+
+ ViewObjectContactOfGraphic::~ViewObjectContactOfGraphic()
+ {
+ // evtl. delete the asynch loading event
+ if(mpAsynchLoadEvent)
+ {
+ // just delete it, this will remove it from the EventHandler and
+ // will trigger forgetAsynchGraphicLoadingEvent from the destructor
+ delete mpAsynchLoadEvent;
+ }
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofgroup.cxx b/svx/source/sdr/contact/viewobjectcontactofgroup.cxx
new file mode 100644
index 000000000000..6df1f2db07dc
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofgroup.cxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewobjectcontactofgroup.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <basegfx/numeric/ftools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <basegfx/tools/canvastools.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfGroup::ViewObjectContactOfGroup(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfGroup::~ViewObjectContactOfGroup()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfGroup::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ // check model-view visibility
+ if(isPrimitiveVisible(rDisplayInfo))
+ {
+ const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
+
+ if(nSubHierarchyCount)
+ {
+ const sal_Bool bDoGhostedDisplaying(
+ GetObjectContact().DoVisualizeEnteredGroup()
+ && !GetObjectContact().isOutputToPrinter()
+ && GetObjectContact().getActiveViewContact() == &GetViewContact());
+
+ if(bDoGhostedDisplaying)
+ {
+ rDisplayInfo.ClearGhostedDrawMode();
+ }
+
+ // create object hierarchy
+ xRetval = getPrimitive2DSequenceSubHierarchy(rDisplayInfo);
+
+ if(xRetval.hasElements())
+ {
+ // get ranges
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
+ const ::basegfx::B2DRange aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval, rViewInformation2D));
+ const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
+
+ // check geometrical visibility
+ if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
+ {
+ // not visible, release
+ xRetval.realloc(0);
+ }
+ }
+
+ if(bDoGhostedDisplaying)
+ {
+ rDisplayInfo.SetGhostedDrawMode();
+ }
+ }
+ else
+ {
+ // draw replacement object for group. This will use ViewContactOfGroup::createViewIndependentPrimitive2DSequence
+ // which creates the replacement primitives for an empty group
+ xRetval = ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo);
+ }
+ }
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx b/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx
new file mode 100644
index 000000000000..16e58f80ddd8
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofmasterpagedescriptor.cxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewobjectcontactofmasterpagedescriptor.hxx>
+#include <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpage.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfMasterPageDescriptor::ViewObjectContactOfMasterPageDescriptor(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContact(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfMasterPageDescriptor::~ViewObjectContactOfMasterPageDescriptor()
+ {
+ }
+
+ sdr::MasterPageDescriptor& ViewObjectContactOfMasterPageDescriptor::GetMasterPageDescriptor() const
+ {
+ return static_cast< ViewContactOfMasterPageDescriptor& >(GetViewContact()).GetMasterPageDescriptor();
+ }
+
+ bool ViewObjectContactOfMasterPageDescriptor::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ if(rDisplayInfo.GetControlLayerProcessingActive())
+ {
+ return false;
+ }
+
+ if(!rDisplayInfo.GetPageProcessingActive())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfMasterPageDescriptor::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ drawinglayer::primitive2d::Primitive2DSequence xMasterPageSequence;
+ const sdr::MasterPageDescriptor& rDescriptor = GetMasterPageDescriptor();
+
+ // used range (retval) is fixed here, it's the MasterPage fill range
+ const SdrPage& rOwnerPage = rDescriptor.GetOwnerPage();
+ const basegfx::B2DRange aPageFillRange(
+ rOwnerPage.GetLftBorder(), rOwnerPage.GetUppBorder(),
+ rOwnerPage.GetWdt() - rOwnerPage.GetRgtBorder(), rOwnerPage.GetHgt() - rOwnerPage.GetLwrBorder());
+
+ // Modify DisplayInfo for MasterPageContent collection; remember original layers and
+ // set combined LayerSet; set MasterPagePaint flag
+ const SetOfByte aRememberedLayers(rDisplayInfo.GetProcessLayers());
+ SetOfByte aPreprocessedLayers(aRememberedLayers);
+ aPreprocessedLayers &= rDescriptor.GetVisibleLayers();
+ rDisplayInfo.SetProcessLayers(aPreprocessedLayers);
+ rDisplayInfo.SetSubContentActive(true);
+
+ // check layer visibility (traditionally was member of layer 1)
+ if(aPreprocessedLayers.IsSet(1))
+ {
+ // hide PageBackground for special DrawModes; historical reasons
+ if(!GetObjectContact().isDrawModeGray() && !GetObjectContact().isDrawModeHighContrast())
+ {
+ // if visible, create the default background primitive sequence
+ xRetval = static_cast< ViewContactOfMasterPageDescriptor& >(GetViewContact()).getViewIndependentPrimitive2DSequence();
+ }
+ }
+
+ // hide MasterPage content? Test self here for hierarchy
+ if(isPrimitiveVisible(rDisplayInfo))
+ {
+ // get the VOC of the Master-SdrPage and get it's object hierarchy
+ ViewContact& rViewContactOfMasterPage(rDescriptor.GetUsedPage().GetViewContact());
+ ViewObjectContact& rVOCOfMasterPage(rViewContactOfMasterPage.GetViewObjectContact(GetObjectContact()));
+
+ xMasterPageSequence = rVOCOfMasterPage.getPrimitive2DSequenceHierarchy(rDisplayInfo);
+ }
+
+ // reset DisplayInfo changes for MasterPage paint
+ rDisplayInfo.SetProcessLayers(aRememberedLayers);
+ rDisplayInfo.SetSubContentActive(false);
+
+ if(xMasterPageSequence.hasElements())
+ {
+ // get range of MasterPage sub hierarchy
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
+ const basegfx::B2DRange aSubHierarchyRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xMasterPageSequence, rViewInformation2D));
+
+ if(aPageFillRange.isInside(aSubHierarchyRange))
+ {
+ // completely inside, just render MasterPage content. Add to target
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xMasterPageSequence);
+ }
+ else if(aPageFillRange.overlaps(aSubHierarchyRange))
+ {
+ // overlapping, compute common area
+ basegfx::B2DRange aCommonArea(aPageFillRange);
+ aCommonArea.intersect(aSubHierarchyRange);
+
+ // need to create a clip primitive, add clipped list to target
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::MaskPrimitive2D(
+ basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(aCommonArea)), xMasterPageSequence));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReference);
+ }
+ }
+
+ // return grouped primitive
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx
new file mode 100644
index 000000000000..d4622546d303
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx
@@ -0,0 +1,355 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewobjectcontactofpageobj.hxx>
+#include <svx/sdr/contact/viewcontactofpageobj.hxx>
+#include <svx/svdopage.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/svdpage.hxx>
+#include <unoapi.hxx>
+#include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ class PagePrimitiveExtractor : public ObjectContactOfPagePainter, public Timer
+ {
+ private:
+ // the ViewObjectContactOfPageObj using this painter
+ ViewObjectContactOfPageObj& mrViewObjectContactOfPageObj;
+
+ public:
+ // basic constructor/destructor
+ PagePrimitiveExtractor(ViewObjectContactOfPageObj& rVOC);
+ virtual ~PagePrimitiveExtractor();
+
+ // LazyInvalidate request. Supported here to not automatically
+ // invalidate the second interaction state all the time at the
+ // original OC
+ virtual void setLazyInvalidate(ViewObjectContact& rVOC);
+
+ // From baseclass Timer, the timeout call triggered by te LazyInvalidate mechanism
+ virtual void Timeout();
+
+ // get primitive visualization
+ drawinglayer::primitive2d::Primitive2DSequence createPrimitive2DSequenceForPage(const DisplayInfo& rDisplayInfo);
+
+ // Own reaction on changes which will be forwarded to the OC of the owner-VOC
+ virtual void InvalidatePartOfView(const basegfx::B2DRange& rRange) const;
+
+ // forward access to SdrPageView of ViewObjectContactOfPageObj
+ virtual bool isOutputToPrinter() const;
+ virtual bool isOutputToWindow() const;
+ virtual bool isOutputToVirtualDevice() const;
+ virtual bool isOutputToRecordingMetaFile() const;
+ virtual bool isOutputToPDFFile() const;
+ virtual bool isDrawModeGray() const;
+ virtual bool isDrawModeBlackWhite() const;
+ virtual bool isDrawModeHighContrast() const;
+ virtual SdrPageView* TryToGetSdrPageView() const;
+ virtual OutputDevice* TryToGetOutputDevice() const;
+ };
+
+ PagePrimitiveExtractor::PagePrimitiveExtractor(
+ ViewObjectContactOfPageObj& rVOC)
+ : ObjectContactOfPagePainter(0, rVOC.GetObjectContact()),
+ mrViewObjectContactOfPageObj(rVOC)
+ {
+ // make this renderer a preview renderer
+ setPreviewRenderer(true);
+
+ // init timer
+ SetTimeout(1);
+ Stop();
+ }
+
+ PagePrimitiveExtractor::~PagePrimitiveExtractor()
+ {
+ // execute missing LazyInvalidates and stop timer
+ Timeout();
+ }
+
+ void PagePrimitiveExtractor::setLazyInvalidate(ViewObjectContact& /*rVOC*/)
+ {
+ // do NOT call parent, but remember that something is to do by
+ // starting the LazyInvalidateTimer
+ Start();
+ }
+
+ // From baseclass Timer, the timeout call triggered by te LazyInvalidate mechanism
+ void PagePrimitiveExtractor::Timeout()
+ {
+ // stop the timer
+ Stop();
+
+ // invalidate all LazyInvalidate VOCs new situations
+ const sal_uInt32 nVOCCount(getViewObjectContactCount());
+
+ for(sal_uInt32 a(0); a < nVOCCount; a++)
+ {
+ ViewObjectContact* pCandidate = getViewObjectContact(a);
+ pCandidate->triggerLazyInvalidate();
+ }
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence PagePrimitiveExtractor::createPrimitive2DSequenceForPage(const DisplayInfo& /*rDisplayInfo*/)
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const SdrPage* pStartPage = GetStartPage();
+
+ if(pStartPage)
+ {
+ // update own ViewInformation2D for visualized page
+ const drawinglayer::geometry::ViewInformation2D& rOriginalViewInformation = mrViewObjectContactOfPageObj.GetObjectContact().getViewInformation2D();
+ const drawinglayer::geometry::ViewInformation2D aNewViewInformation2D(
+ rOriginalViewInformation.getObjectTransformation(),
+ rOriginalViewInformation.getViewTransformation(),
+
+ // #i101075# use empty range for page content here to force
+ // the content not to be physically clipped in any way. This
+ // would be possible, but would require the internal transformation
+ // which maps between the page visualisation object and the page
+ // content, including the aspect ratios (for details see in
+ // PagePreviewPrimitive2D::create2DDecomposition)
+ basegfx::B2DRange(),
+
+ GetXDrawPageForSdrPage(const_cast< SdrPage* >(pStartPage)),
+ 0.0, // no time; page previews are not animated
+ rOriginalViewInformation.getExtendedInformationSequence());
+ updateViewInformation2D(aNewViewInformation2D);
+
+ // create copy of DisplayInfo to set PagePainting
+ DisplayInfo aDisplayInfo;
+
+ // get page's VOC
+ ViewObjectContact& rDrawPageVOContact = pStartPage->GetViewContact().GetViewObjectContact(*this);
+
+ // get whole Primitive2DSequence
+ xRetval = rDrawPageVOContact.getPrimitive2DSequenceHierarchy(aDisplayInfo);
+ }
+
+ return xRetval;
+ }
+
+ void PagePrimitiveExtractor::InvalidatePartOfView(const basegfx::B2DRange& rRange) const
+ {
+ // an invalidate is called at this view, this needs to be translated to an invalidate
+ // for the using VOC. Coordinates are in page coordinate system.
+ const SdrPage* pStartPage = GetStartPage();
+
+ if(pStartPage && !rRange.isEmpty())
+ {
+ const basegfx::B2DRange aPageRange(0.0, 0.0, (double)pStartPage->GetWdt(), (double)pStartPage->GetHgt());
+
+ if(rRange.overlaps(aPageRange))
+ {
+ // if object on the page is inside or overlapping with page, create ActionChanged() for
+ // involved VOC
+ mrViewObjectContactOfPageObj.ActionChanged();
+ }
+ }
+ }
+
+ // forward access to SdrPageView to VOCOfPageObj
+ bool PagePrimitiveExtractor::isOutputToPrinter() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToPrinter(); }
+ bool PagePrimitiveExtractor::isOutputToWindow() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToWindow(); }
+ bool PagePrimitiveExtractor::isOutputToVirtualDevice() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToVirtualDevice(); }
+ bool PagePrimitiveExtractor::isOutputToRecordingMetaFile() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToRecordingMetaFile(); }
+ bool PagePrimitiveExtractor::isOutputToPDFFile() const { return mrViewObjectContactOfPageObj.GetObjectContact().isOutputToPDFFile(); }
+ bool PagePrimitiveExtractor::isDrawModeGray() const { return mrViewObjectContactOfPageObj.GetObjectContact().isDrawModeGray(); }
+ bool PagePrimitiveExtractor::isDrawModeBlackWhite() const { return mrViewObjectContactOfPageObj.GetObjectContact().isDrawModeBlackWhite(); }
+ bool PagePrimitiveExtractor::isDrawModeHighContrast() const { return mrViewObjectContactOfPageObj.GetObjectContact().isDrawModeHighContrast(); }
+ SdrPageView* PagePrimitiveExtractor::TryToGetSdrPageView() const { return mrViewObjectContactOfPageObj.GetObjectContact().TryToGetSdrPageView(); }
+ OutputDevice* PagePrimitiveExtractor::TryToGetOutputDevice() const { return mrViewObjectContactOfPageObj.GetObjectContact().TryToGetOutputDevice(); }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageObj::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const SdrPageObj& rPageObject((static_cast< ViewContactOfPageObj& >(GetViewContact())).GetPageObj());
+ const SdrPage* pPage = rPageObject.GetReferencedPage();
+ const svtools::ColorConfig aColorConfig;
+
+ // get PageObject's geometry
+ basegfx::B2DHomMatrix aPageObjectTransform;
+ {
+ const Rectangle aPageObjectModelData(rPageObject.GetLastBoundRect());
+ const basegfx::B2DRange aPageObjectBound(
+ aPageObjectModelData.Left(), aPageObjectModelData.Top(),
+ aPageObjectModelData.Right(), aPageObjectModelData.Bottom());
+
+ aPageObjectTransform.set(0, 0, aPageObjectBound.getWidth());
+ aPageObjectTransform.set(1, 1, aPageObjectBound.getHeight());
+ aPageObjectTransform.set(0, 2, aPageObjectBound.getMinX());
+ aPageObjectTransform.set(1, 2, aPageObjectBound.getMinY());
+ }
+
+ // #i102637# add gray frame also when printing and page exists (handout pages)
+ const bool bCreateGrayFrame(!GetObjectContact().isOutputToPrinter() || pPage);
+
+ // get displayed page's content. This is the uscaled page content
+ if(mpExtractor && pPage)
+ {
+ // get displayed page's geometry
+ drawinglayer::primitive2d::Primitive2DSequence xPageContent;
+ const Size aPageSize(pPage->GetSize());
+ const double fPageWidth(aPageSize.getWidth());
+ const double fPageHeight(aPageSize.getHeight());
+
+ // The case that a PageObject contains another PageObject which visualizes the
+ // same page again would lead to a recursion. Limit that recursion depth to one
+ // by using a local static bool
+ static bool bInCreatePrimitive2D(false);
+
+ if(bInCreatePrimitive2D)
+ {
+ // Recursion is possible. Create a replacement primitive
+ xPageContent.realloc(2);
+ const Color aDocColor(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
+ const Color aBorderColor(aColorConfig.GetColorValue(svtools::DOCBOUNDARIES).nColor);
+ const basegfx::B2DRange aPageBound(0.0, 0.0, fPageWidth, fPageHeight);
+ const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aPageBound));
+
+ // add replacement fill
+ xPageContent[0L] = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), aDocColor.getBColor()));
+
+ // add replacement border
+ xPageContent[1L] = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aBorderColor.getBColor()));
+ }
+ else
+ {
+ // set recursion flag
+ bInCreatePrimitive2D = true;
+
+ // init extractor, guarantee existance, set page there
+ mpExtractor->SetStartPage(pPage);
+
+ // #i105548# also need to copy the VOCRedirector for sub-content creation
+ mpExtractor->SetViewObjectContactRedirector(GetObjectContact().GetViewObjectContactRedirector());
+
+ // create page content
+ xPageContent = mpExtractor->createPrimitive2DSequenceForPage(rDisplayInfo);
+
+ // #i105548# reset VOCRedirector to not accidentially have a pointer to a
+ // temporary class, so calls to it are avoided safely
+ mpExtractor->SetViewObjectContactRedirector(0);
+
+ // reset recursion flag
+ bInCreatePrimitive2D = false;
+ }
+
+ // prepare retval
+ if(xPageContent.hasElements())
+ {
+ const uno::Reference< drawing::XDrawPage > xDrawPage(GetXDrawPageForSdrPage(const_cast< SdrPage*>(pPage)));
+ const drawinglayer::primitive2d::Primitive2DReference xPagePreview(new drawinglayer::primitive2d::PagePreviewPrimitive2D(
+ xDrawPage, aPageObjectTransform, fPageWidth, fPageHeight, xPageContent, true));
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xPagePreview, 1);
+ }
+ }
+ else if(bCreateGrayFrame)
+ {
+ // #i105146# no content, but frame display. To make hitting the page preview objects
+ // on the handout page more simple, add hidden fill geometry
+ const drawinglayer::primitive2d::Primitive2DReference xFrameHit(
+ drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
+ false,
+ aPageObjectTransform));
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xFrameHit, 1);
+ }
+
+ // add a gray outline frame, except not when printing
+ if(bCreateGrayFrame)
+ {
+ const Color aFrameColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES).nColor);
+ basegfx::B2DPolygon aOwnOutline(basegfx::tools::createUnitPolygon());
+ aOwnOutline.transform(aPageObjectTransform);
+
+ const drawinglayer::primitive2d::Primitive2DReference xGrayFrame(
+ new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOwnOutline, aFrameColor.getBColor()));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xGrayFrame);
+ }
+
+ return xRetval;
+ }
+
+ ViewObjectContactOfPageObj::ViewObjectContactOfPageObj(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfSdrObj(rObjectContact, rViewContact),
+ mpExtractor(new PagePrimitiveExtractor(*this))
+ {
+ }
+
+ ViewObjectContactOfPageObj::~ViewObjectContactOfPageObj()
+ {
+ // delete the helper OC
+ if(mpExtractor)
+ {
+ // remember candidate and reset own pointer to avoid action when createPrimitive2DSequence()
+ // would be called for any reason
+ PagePrimitiveExtractor* pCandidate = mpExtractor;
+ mpExtractor = 0;
+
+ // also reset the StartPage to avoid ActionChanged() forwardings in the
+ // PagePrimitiveExtractor::InvalidatePartOfView() implementation
+ pCandidate->SetStartPage(0);
+ delete pCandidate;
+ }
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrmediaobj.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrmediaobj.cxx
new file mode 100644
index 000000000000..af7eeeb220ec
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofsdrmediaobj.cxx
@@ -0,0 +1,179 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/objectcontactofpageview.hxx>
+#include <svx/sdr/contact/viewobjectcontactofsdrmediaobj.hxx>
+#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/svdpagv.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/window.hxx>
+#include <avmedia/mediaitem.hxx>
+#include "sdrmediawindow.hxx"
+#include <svx/sdrpagewindow.hxx>
+#include <sdrpaintwindow.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr { namespace contact {
+
+// ----------------------------------
+// - ViewObjectContactOfSdrMediaObj -
+// ----------------------------------
+
+ViewObjectContactOfSdrMediaObj::ViewObjectContactOfSdrMediaObj( ObjectContact& rObjectContact,
+ ViewContact& rViewContact,
+ const ::avmedia::MediaItem& rMediaItem ) :
+ ViewObjectContactOfSdrObj( rObjectContact, rViewContact ),
+ mpMediaWindow( NULL )
+{
+ Window* pWindow = getWindow();
+
+ if( pWindow )
+ {
+ mpMediaWindow = new SdrMediaWindow( pWindow, *this );
+ mpMediaWindow->hide();
+ executeMediaItem( rMediaItem );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+ViewObjectContactOfSdrMediaObj::~ViewObjectContactOfSdrMediaObj()
+{
+ delete mpMediaWindow;
+ mpMediaWindow = NULL;
+}
+
+// ------------------------------------------------------------------------------
+
+Window* ViewObjectContactOfSdrMediaObj::getWindow() const
+{
+ Window* pRetval = 0;
+
+ const ObjectContactOfPageView* pObjectContactOfPageView = dynamic_cast< const ObjectContactOfPageView* >(&GetObjectContact());
+
+ if(pObjectContactOfPageView)
+ {
+ const SdrPageWindow& rPageWindow = pObjectContactOfPageView->GetPageWindow();
+ const SdrPaintWindow* pPaintWindow = &rPageWindow.GetPaintWindow();
+
+ if(rPageWindow.GetOriginalPaintWindow())
+ {
+ // #i83183# prefer OriginalPaintWindow if set; this is
+ // the real target device. GetPaintWindow() may return
+ // the current buffer device instead
+ pPaintWindow = rPageWindow.GetOriginalPaintWindow();
+ }
+
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+
+ if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
+ {
+ pRetval = static_cast< Window* >(&rOutDev);
+ }
+ }
+
+ return pRetval;
+}
+
+// ------------------------------------------------------------------------------
+
+bool ViewObjectContactOfSdrMediaObj::hasPreferredSize() const
+{
+ return( mpMediaWindow != NULL && mpMediaWindow->hasPreferredSize() );
+}
+
+// ------------------------------------------------------------------------------
+
+Size ViewObjectContactOfSdrMediaObj::getPreferredSize() const
+{
+ Size aRet;
+
+ if( mpMediaWindow )
+ aRet = mpMediaWindow->getPreferredSize();
+
+ return aRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void ViewObjectContactOfSdrMediaObj::updateMediaItem( ::avmedia::MediaItem& rItem ) const
+{
+ if( mpMediaWindow )
+ {
+ mpMediaWindow->updateMediaItem( rItem );
+
+ // show/hide is now dependent of play state
+ if(avmedia::MEDIASTATE_STOP == rItem.getState())
+ {
+ mpMediaWindow->hide();
+ }
+ else
+ {
+ basegfx::B2DRange aViewRange(getObjectRange());
+ aViewRange.transform(GetObjectContact().getViewInformation2D().getViewTransformation());
+
+ const Rectangle aViewRectangle(
+ (sal_Int32)floor(aViewRange.getMinX()), (sal_Int32)floor(aViewRange.getMinY()),
+ (sal_Int32)ceil(aViewRange.getMaxX()), (sal_Int32)ceil(aViewRange.getMaxY()));
+
+ mpMediaWindow->setPosSize(aViewRectangle);
+ mpMediaWindow->show();
+ }
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void ViewObjectContactOfSdrMediaObj::executeMediaItem( const ::avmedia::MediaItem& rItem )
+{
+ if( mpMediaWindow )
+ {
+ ::avmedia::MediaItem aUpdatedItem;
+
+ mpMediaWindow->executeMediaItem( rItem );
+
+ // query new properties after trying to set the new properties
+ updateMediaItem( aUpdatedItem );
+ static_cast< ViewContactOfSdrMediaObj& >( GetViewContact() ).mediaPropertiesChanged( aUpdatedItem );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+}} // end of namespace sdr::contact
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx
new file mode 100644
index 000000000000..b469841f9a9f
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
+#include <svx/sdr/contact/viewcontactofsdrobj.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdview.hxx>
+
+#include "fmobj.hxx"
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ const SdrObject& ViewObjectContactOfSdrObj::getSdrObject() const
+ {
+ return static_cast< ViewContactOfSdrObj& >(GetViewContact()).GetSdrObject();
+ }
+
+ ViewObjectContactOfSdrObj::ViewObjectContactOfSdrObj(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContact(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfSdrObj::~ViewObjectContactOfSdrObj()
+ {
+ }
+
+ bool ViewObjectContactOfSdrObj::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ const SdrObject& rObject = getSdrObject();
+
+ // Test layer visibility
+ if(!rDisplayInfo.GetProcessLayers().IsSet(rObject.GetLayer()))
+ {
+ return false;
+ }
+
+ if(GetObjectContact().isOutputToPrinter() )
+ {
+ // Test if print output but not printable
+ if( !rObject.IsPrintable())
+ return false;
+ }
+ else
+ {
+ // test is object is not visible on screen
+ if( !rObject.IsVisible() )
+ return false;
+ }
+
+ // Test for hidden object on MasterPage
+ if(rDisplayInfo.GetSubContentActive() && rObject.IsNotVisibleAsMaster())
+ {
+ return false;
+ }
+
+ // Test for Calc object hiding (for OLE and Graphic it's extra, see there)
+ const SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
+
+ if(pSdrPageView)
+ {
+ const SdrView& rSdrView = pSdrPageView->GetView();
+ const bool bHideOle(rSdrView.getHideOle());
+ const bool bHideChart(rSdrView.getHideChart());
+ const bool bHideDraw(rSdrView.getHideDraw());
+ const bool bHideFormControl(rSdrView.getHideFormControl());
+
+ if(bHideOle || bHideChart || bHideDraw || bHideFormControl)
+ {
+ if(OBJ_OLE2 == rObject.GetObjIdentifier())
+ {
+ if(((SdrOle2Obj&)rObject).IsChart())
+ {
+ // chart
+ if(bHideChart)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ // OLE
+ if(bHideOle)
+ {
+ return false;
+ }
+ }
+ }
+ else if(OBJ_GRAF == rObject.GetObjIdentifier())
+ {
+ // graphic handled like OLE
+ if(bHideOle)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ const bool bIsFormControl = dynamic_cast< const FmFormObj * >( &rObject ) != 0;
+ if(bIsFormControl && bHideFormControl)
+ {
+ return false;
+ }
+ // any other draw object
+ if(!bIsFormControl && bHideDraw)
+ {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
new file mode 100644
index 000000000000..318f20633eaf
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofsdrole2obj.cxx
@@ -0,0 +1,246 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewobjectcontactofsdrole2obj.hxx>
+#include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
+#include <svx/sdr/contact/viewcontactofsdrole2obj.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/svdview.hxx>
+#include <drawinglayer/primitive2d/chartprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <com/sun/star/embed/EmbedMisc.hpp>
+#include <com/sun/star/embed/EmbedStates.hpp>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ const SdrOle2Obj& ViewObjectContactOfSdrOle2Obj::getSdrOle2Object() const
+ {
+ return static_cast< ViewContactOfSdrOle2Obj& >(GetViewContact()).GetOle2Obj();
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfSdrOle2Obj::createPrimitive2DSequence(
+ const DisplayInfo& /*rDisplayInfo*/) const
+ {
+ // this method is overloaded to do some things the old SdrOle2Obj::DoPaintObject did.
+ // In the future, some of these may be solved different, but ATM try to stay compatible
+ // with the old behaviour
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const SdrOle2Obj& rSdrOle2 = getSdrOle2Object();
+ sal_Int32 nState(-1);
+
+ {
+ const svt::EmbeddedObjectRef& xObjRef = rSdrOle2.getEmbeddedObjectRef();
+ if ( xObjRef.is() )
+ nState = xObjRef->getCurrentState();
+ }
+
+ const bool bIsOutplaceActive(nState == embed::EmbedStates::ACTIVE);
+ const bool bIsInplaceActive((nState == embed::EmbedStates::INPLACE_ACTIVE) || (nState == embed::EmbedStates::UI_ACTIVE));
+ const bool bIsChart(rSdrOle2.IsChart());
+ bool bDone(false);
+
+ if(!bDone && bIsInplaceActive)
+ {
+ if( !GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile() )
+ {
+ //no need to create a primitive sequence here as the OLE object does render itself
+ //in case of charts the superfluous creation of a metafile is strongly performance relevant!
+ bDone = true;
+ }
+ }
+
+ if( !bDone )
+ {
+ const Rectangle& rObjectRectangle(rSdrOle2.GetGeoRect());
+ const basegfx::B2DRange aObjectRange(rObjectRectangle.Left(), rObjectRectangle.Top(), rObjectRectangle.Right(), rObjectRectangle.Bottom());
+
+ // create object transform
+ basegfx::B2DHomMatrix aObjectTransform;
+ aObjectTransform.set(0, 0, aObjectRange.getWidth());
+ aObjectTransform.set(1, 1, aObjectRange.getHeight());
+ aObjectTransform.set(0, 2, aObjectRange.getMinX());
+ aObjectTransform.set(1, 2, aObjectRange.getMinY());
+
+ if(bIsChart)
+ {
+ //charts must be painted resolution dependent!! #i82893#, #i75867#
+
+ // for chart, to not lose the current better quality visualisation which
+ // uses a direct paint, use a primtive wrapper for that exceptional case. The renderers
+ // will then ATM paint it to an OutputDevice directly.
+ // In later versions this should be replaced by getting the Primitive2DSequnce from
+ // the chart and using it.
+ // to be able to render something in non-VCL using renderers, the wrapper is a
+ // GroupPrimitive2D which automatically decomposes to the already created Metafile
+ // content.
+ // For being completely compatible, ATM Window and VDEV PrettyPrinting is suppressed.
+ // It works in the VCL renderers, though. So for activating again with VCL primitive
+ // renderers, change conditions here.
+
+ // determine if embedding and PrettyPrinting shall be done at all
+ uno::Reference< frame::XModel > xChartModel;
+ bool bDoChartPrettyPrinting(true);
+
+ // the original ChartPrettyPainter does not do it for Window
+ if(bDoChartPrettyPrinting && GetObjectContact().isOutputToWindow())
+ {
+ bDoChartPrettyPrinting = false;
+ }
+
+ // the original ChartPrettyPainter does not do it for VDEV
+ if(bDoChartPrettyPrinting && GetObjectContact().isOutputToVirtualDevice())
+ {
+ if(GetObjectContact().isOutputToPDFFile())
+ {
+ // #i97982#
+ // For PDF files, allow PrettyPrinting
+ }
+ else
+ {
+ bDoChartPrettyPrinting = false;
+ }
+ }
+
+ // the chart model is needed. Check if it's available
+ if(bDoChartPrettyPrinting)
+ {
+ // get chart model
+ xChartModel = rSdrOle2.getXModel();
+
+ if(!xChartModel.is())
+ {
+ bDoChartPrettyPrinting = false;
+ }
+ }
+
+ if(bDoChartPrettyPrinting)
+ {
+ // embed MetaFile data in a specialized Wrapper Primitive which holds also the ChartModel needed
+ // for PrettyPrinting
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::ChartPrimitive2D(
+ xChartModel, aObjectTransform, xRetval));
+ xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ bDone = true;
+ }
+ }
+
+ if( !bDone )
+ {
+ //old stuff that should be reworked
+ {
+ //if no replacement image is available load the OLE object
+ if(!rSdrOle2.GetGraphic()) //try to fetch the metafile - this can lead to the actual creation of the metafile what can be extremely expensive (e.g. for big charts)!!! #i101925#
+ {
+ // try to create embedded object
+ rSdrOle2.GetObjRef(); //this loads the OLE object if it is not loaded already
+ }
+ const svt::EmbeddedObjectRef& xObjRef = rSdrOle2.getEmbeddedObjectRef();
+ if(xObjRef.is())
+ {
+ const sal_Int64 nMiscStatus(xObjRef->getStatus(rSdrOle2.GetAspect()));
+
+ // this hack (to change model data during PAINT argh(!)) should be reworked
+ if(!rSdrOle2.IsResizeProtect() && (nMiscStatus & embed::EmbedMisc::EMBED_NEVERRESIZE))
+ {
+ const_cast< SdrOle2Obj* >(&rSdrOle2)->SetResizeProtect(true);
+ }
+
+ SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
+ if(pPageView && (nMiscStatus & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE))
+ {
+ // connect plugin object
+ pPageView->GetView().DoConnect(const_cast< SdrOle2Obj* >(&rSdrOle2));
+ }
+ }
+ }//end old stuff to rework
+
+ // create OLE primitive stuff directly at VC with HC as parameter
+ const ViewContactOfSdrOle2Obj& rVC = static_cast< const ViewContactOfSdrOle2Obj& >(GetViewContact());
+ xRetval = rVC.createPrimitive2DSequenceWithParameters(GetObjectContact().isDrawModeHighContrast());
+ }
+
+ if(bIsOutplaceActive)
+ {
+ // do not shade when printing or PDF exporting
+ if(!GetObjectContact().isOutputToPrinter() && !GetObjectContact().isOutputToRecordingMetaFile())
+ {
+ // shade the representation if the object is activated outplace
+ basegfx::B2DPolygon aObjectOutline(basegfx::tools::createUnitPolygon());
+ aObjectOutline.transform(aObjectTransform);
+
+ // Use a FillHatchPrimitive2D with necessary attributes
+ const drawinglayer::attribute::FillHatchAttribute aFillHatch(
+ drawinglayer::attribute::HATCHSTYLE_SINGLE, // single hatch
+ 125.0, // 1.25 mm
+ 45.0 * F_PI180, // 45 degree diagonal
+ Color(COL_BLACK).getBColor(), // black color
+ false); // no filling
+
+ const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::PolyPolygonHatchPrimitive2D(
+ basegfx::B2DPolyPolygon(aObjectOutline),
+ Color(COL_BLACK).getBColor(),
+ aFillHatch));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xReference);
+ }
+ }
+
+ }
+
+ return xRetval;
+ }
+
+ ViewObjectContactOfSdrOle2Obj::ViewObjectContactOfSdrOle2Obj(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfSdrObj(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfSdrOle2Obj::~ViewObjectContactOfSdrOle2Obj()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx
new file mode 100644
index 000000000000..84ad73d2dfcc
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofsdrpage.cxx
@@ -0,0 +1,726 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewobjectcontactofsdrpage.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/viewcontactofsdrpage.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/gridprimitive2d.hxx>
+#include <drawinglayer/primitive2d/helplineprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ const SdrPage& ViewObjectContactOfPageSubObject::getPage() const
+ {
+ return static_cast< ViewContactOfPageSubObject& >(GetViewContact()).getPage();
+ }
+
+ ViewObjectContactOfPageSubObject::ViewObjectContactOfPageSubObject(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContact(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfPageSubObject::~ViewObjectContactOfPageSubObject()
+ {
+ }
+
+ bool ViewObjectContactOfPageSubObject::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ if(rDisplayInfo.GetSubContentActive())
+ {
+ return false;
+ }
+
+ if(rDisplayInfo.GetControlLayerProcessingActive())
+ {
+ return false;
+ }
+
+ if(!rDisplayInfo.GetPageProcessingActive())
+ {
+ return false;
+ }
+
+ if(GetObjectContact().isOutputToPrinter())
+ {
+ return false;
+ }
+
+ if(!GetObjectContact().TryToGetSdrPageView())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ bool ViewObjectContactOfPageSubObject::isPrimitiveGhosted(const DisplayInfo& /*rDisplayInfo*/) const
+ {
+ // suppress ghosted for page parts
+ return false;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfPageBackground::ViewObjectContactOfPageBackground(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfPageBackground::~ViewObjectContactOfPageBackground()
+ {
+ }
+
+ bool ViewObjectContactOfPageBackground::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo))
+ {
+ return false;
+ }
+
+ // no page background for preview renderers
+ if(GetObjectContact().IsPreviewRenderer())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageBackground::createPrimitive2DSequence(const DisplayInfo& /*rDisplayInfo*/) const
+ {
+ // Initialize background. Dependent of IsPageVisible, use ApplicationBackgroundColor or ApplicationDocumentColor. Most
+ // old renderers for export (html, pdf, gallery, ...) set the page to not visible (SetPageVisible(false)). They expect the
+ // given OutputDevice to be initialized with the ApplicationDocumentColor then.
+ const SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ if(pPageView)
+ {
+ const SdrView& rView = pPageView->GetView();
+ Color aInitColor;
+
+ if(rView.IsPageVisible())
+ {
+ aInitColor = pPageView->GetApplicationBackgroundColor();
+ }
+ else
+ {
+ aInitColor = pPageView->GetApplicationDocumentColor();
+
+ if(Color(COL_AUTO) == aInitColor)
+ {
+ const svtools::ColorConfig aColorConfig;
+ aInitColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor;
+ }
+ }
+
+ // init background with InitColor
+ xRetval.realloc(1);
+ const basegfx::BColor aRGBColor(aInitColor.getBColor());
+ xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::BackgroundColorPrimitive2D(aRGBColor));
+ }
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfMasterPage::ViewObjectContactOfMasterPage(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfMasterPage::~ViewObjectContactOfMasterPage()
+ {
+ }
+
+ bool ViewObjectContactOfMasterPage::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo))
+ {
+ return false;
+ }
+
+ // this object is only used for MasterPages. When not the MasterPage is
+ // displayed as a page, but another page is using it as sub-object, the
+ // geometry needs to be hidden
+ if(rDisplayInfo.GetSubContentActive())
+ {
+ return false;
+ }
+
+ return true;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfPageFill::ViewObjectContactOfPageFill(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfPageFill::~ViewObjectContactOfPageFill()
+ {
+ }
+
+ bool ViewObjectContactOfPageFill::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo))
+ {
+ return false;
+ }
+
+ SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
+
+ if(!pSdrPageView)
+ {
+ return false;
+ }
+
+ if(!pSdrPageView->GetView().IsPageVisible())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageFill::createPrimitive2DSequence(const DisplayInfo& /*rDisplayInfo*/) const
+ {
+ const SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ if(pPageView)
+ {
+ const SdrPage& rPage = getPage();
+
+ const basegfx::B2DRange aPageFillRange(0.0, 0.0, (double)rPage.GetWdt(), (double)rPage.GetHgt());
+ const basegfx::B2DPolygon aPageFillPolygon(basegfx::tools::createPolygonFromRect(aPageFillRange));
+ Color aPageFillColor;
+
+ if(pPageView->GetApplicationDocumentColor() != COL_AUTO)
+ {
+ aPageFillColor = pPageView->GetApplicationDocumentColor();
+ }
+ else
+ {
+ const svtools::ColorConfig aColorConfig;
+ aPageFillColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor;
+ }
+
+ // create and add primitive
+ xRetval.realloc(1);
+ const basegfx::BColor aRGBColor(aPageFillColor.getBColor());
+ xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPageFillPolygon), aRGBColor));
+ }
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfPageShadow::ViewObjectContactOfPageShadow(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfPageShadow::~ViewObjectContactOfPageShadow()
+ {
+ }
+
+ bool ViewObjectContactOfPageShadow::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo))
+ {
+ return false;
+ }
+
+ SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
+
+ if(!pSdrPageView)
+ {
+ return false;
+ }
+
+ if(!pSdrPageView->GetView().IsPageVisible())
+ {
+ return false;
+ }
+
+ // no page shadow for preview renderers
+ if(GetObjectContact().IsPreviewRenderer())
+ {
+ return false;
+ }
+
+ return true;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfOuterPageBorder::ViewObjectContactOfOuterPageBorder(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfOuterPageBorder::~ViewObjectContactOfOuterPageBorder()
+ {
+ }
+
+ bool ViewObjectContactOfOuterPageBorder::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo))
+ {
+ return false;
+ }
+
+ SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
+
+ if(!pSdrPageView)
+ {
+ return false;
+ }
+
+ const SdrView& rView = pSdrPageView->GetView();
+
+ if(!rView.IsPageVisible() && rView.IsPageBorderVisible())
+ {
+ return false;
+ }
+
+ return true;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfInnerPageBorder::ViewObjectContactOfInnerPageBorder(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfInnerPageBorder::~ViewObjectContactOfInnerPageBorder()
+ {
+ }
+
+ bool ViewObjectContactOfInnerPageBorder::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo))
+ {
+ return false;
+ }
+
+ SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
+
+ if(!pSdrPageView)
+ {
+ return false;
+ }
+
+ if(!pSdrPageView->GetView().IsBordVisible())
+ {
+ return false;
+ }
+
+ const SdrPage& rPage = getPage();
+
+ if(!rPage.GetLftBorder() && !rPage.GetUppBorder() && !rPage.GetRgtBorder() && !rPage.GetLwrBorder())
+ {
+ return false;
+ }
+
+ // no inner page border for preview renderers
+ if(GetObjectContact().IsPreviewRenderer())
+ {
+ return false;
+ }
+
+ return true;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfPageHierarchy::ViewObjectContactOfPageHierarchy(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfPageHierarchy::~ViewObjectContactOfPageHierarchy()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageHierarchy::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ // process local sub-hierarchy
+ const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
+
+ if(nSubHierarchyCount)
+ {
+ xRetval = getPrimitive2DSequenceSubHierarchy(rDisplayInfo);
+
+ if(xRetval.hasElements())
+ {
+ // get ranges
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
+ const basegfx::B2DRange aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval, rViewInformation2D));
+ const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
+
+ // check geometrical visibility
+ if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
+ {
+ // not visible, release
+ xRetval.realloc(0);
+ }
+ }
+ }
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfPageGrid::ViewObjectContactOfPageGrid(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfPageGrid::~ViewObjectContactOfPageGrid()
+ {
+ }
+
+ bool ViewObjectContactOfPageGrid::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo))
+ {
+ return false;
+ }
+
+ SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
+
+ if(!pSdrPageView)
+ {
+ return false;
+ }
+
+ const SdrView& rView = pSdrPageView->GetView();
+
+ if(!rView.IsGridVisible())
+ {
+ return false;
+ }
+
+ // no page grid for preview renderers
+ if(GetObjectContact().IsPreviewRenderer())
+ {
+ return false;
+ }
+
+ if(static_cast< ViewContactOfGrid& >(GetViewContact()).getFront() != (bool)rView.IsGridFront())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageGrid::createPrimitive2DSequence(const DisplayInfo& /*rDisplayInfo*/) const
+ {
+ const SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ if(pPageView)
+ {
+ const SdrView& rView = pPageView->GetView();
+ const SdrPage& rPage = getPage();
+ const Color aGridColor(rView.GetGridColor());
+ const basegfx::BColor aRGBGridColor(aGridColor.getBColor());
+
+ basegfx::B2DHomMatrix aGridMatrix;
+ aGridMatrix.set(0, 0, (double)(rPage.GetWdt() - (rPage.GetRgtBorder() + rPage.GetLftBorder())));
+ aGridMatrix.set(1, 1, (double)(rPage.GetHgt() - (rPage.GetLwrBorder() + rPage.GetUppBorder())));
+ aGridMatrix.set(0, 2, (double)rPage.GetLftBorder());
+ aGridMatrix.set(1, 2, (double)rPage.GetUppBorder());
+
+ const Size aRaw(rView.GetGridCoarse());
+ const Size aFine(rView.GetGridFine());
+ const double fWidthX(aRaw.getWidth());
+ const double fWidthY(aRaw.getHeight());
+ const sal_uInt32 nSubdivisionsX(aFine.getWidth() ? aRaw.getWidth() / aFine.getWidth() : 0L);
+ const sal_uInt32 nSubdivisionsY(aFine.getHeight() ? aRaw.getHeight() / aFine.getHeight() : 0L);
+
+ xRetval.realloc(1);
+ xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::GridPrimitive2D(
+ aGridMatrix, fWidthX, fWidthY, 10.0, 3.0, nSubdivisionsX, nSubdivisionsY, aRGBGridColor,
+ drawinglayer::primitive2d::createDefaultCross_3x3(aRGBGridColor)));
+ }
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfPageHelplines::ViewObjectContactOfPageHelplines(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfPageHelplines::~ViewObjectContactOfPageHelplines()
+ {
+ }
+
+ bool ViewObjectContactOfPageHelplines::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
+ {
+ if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo))
+ {
+ return false;
+ }
+
+ SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
+
+ if(!pSdrPageView)
+ {
+ return false;
+ }
+
+ const SdrView& rView = pSdrPageView->GetView();
+
+ if(!rView.IsHlplVisible())
+ {
+ return false;
+ }
+
+ // no helplines for preview renderers
+ if(GetObjectContact().IsPreviewRenderer())
+ {
+ return false;
+ }
+
+ if(static_cast< ViewContactOfHelplines& >(GetViewContact()).getFront() != (bool)rView.IsHlplFront())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageHelplines::createPrimitive2DSequence(const DisplayInfo& /*rDisplayInfo*/) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
+
+ if(pPageView)
+ {
+ const SdrHelpLineList& rHelpLineList = pPageView->GetHelpLines();
+ const sal_uInt32 nCount(rHelpLineList.GetCount());
+
+ if(nCount)
+ {
+ const basegfx::BColor aRGBColorA(1.0, 1.0, 1.0);
+ const basegfx::BColor aRGBColorB(0.0, 0.0, 0.0);
+ xRetval.realloc(nCount);
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ const SdrHelpLine& rHelpLine = rHelpLineList[(sal_uInt16)a];
+ const basegfx::B2DPoint aPosition((double)rHelpLine.GetPos().X(), (double)rHelpLine.GetPos().Y());
+ const double fDiscreteDashLength(4.0);
+
+ switch(rHelpLine.GetKind())
+ {
+ default : // SDRHELPLINE_POINT
+ {
+ xRetval[a] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D(
+ aPosition, basegfx::B2DVector(1.0, 0.0), drawinglayer::primitive2d::HELPLINESTYLE2D_POINT,
+ aRGBColorA, aRGBColorB, fDiscreteDashLength));
+ break;
+ }
+ case SDRHELPLINE_VERTICAL :
+ {
+ xRetval[a] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D(
+ aPosition, basegfx::B2DVector(0.0, 1.0), drawinglayer::primitive2d::HELPLINESTYLE2D_LINE,
+ aRGBColorA, aRGBColorB, fDiscreteDashLength));
+ break;
+ }
+ case SDRHELPLINE_HORIZONTAL :
+ {
+ xRetval[a] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D(
+ aPosition, basegfx::B2DVector(1.0, 0.0), drawinglayer::primitive2d::HELPLINESTYLE2D_LINE,
+ aRGBColorA, aRGBColorB, fDiscreteDashLength));
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ ViewObjectContactOfSdrPage::ViewObjectContactOfSdrPage(ObjectContact& rObjectContact, ViewContact& rViewContact)
+ : ViewObjectContact(rObjectContact, rViewContact)
+ {
+ }
+
+ ViewObjectContactOfSdrPage::~ViewObjectContactOfSdrPage()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfSdrPage::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo) const
+ {
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ // process local sub-hierarchy
+ const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
+
+ if(nSubHierarchyCount)
+ {
+ const sal_Bool bDoGhostedDisplaying(
+ GetObjectContact().DoVisualizeEnteredGroup()
+ && !GetObjectContact().isOutputToPrinter()
+ && GetObjectContact().getActiveViewContact() == &GetViewContact());
+
+ if(bDoGhostedDisplaying)
+ {
+ rDisplayInfo.ClearGhostedDrawMode();
+ }
+
+ // create object hierarchy
+ xRetval = getPrimitive2DSequenceSubHierarchy(rDisplayInfo);
+
+ if(xRetval.hasElements())
+ {
+ // get ranges
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
+ const basegfx::B2DRange aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval, rViewInformation2D));
+ const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
+
+ // check geometrical visibility
+ if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
+ {
+ // not visible, release
+ xRetval.realloc(0);
+ }
+ }
+
+ if(bDoGhostedDisplaying)
+ {
+ rDisplayInfo.SetGhostedDrawMode();
+ }
+ }
+
+ return xRetval;
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
new file mode 100644
index 000000000000..e08e934517d0
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
@@ -0,0 +1,1927 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/contact/viewobjectcontactofunocontrol.hxx>
+#include <svx/sdr/contact/viewcontactofunocontrol.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/properties/properties.hxx>
+#include <svx/sdr/contact/objectcontactofpageview.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include "sdrpaintwindow.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/awt/XView.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/awt/InvalidateStyle.hpp>
+#include <com/sun/star/util/XModeChangeListener.hpp>
+#include <com/sun/star/util/XModeChangeBroadcaster.hpp>
+#include <com/sun/star/container/XContainerListener.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+/** === end UNO includes === **/
+
+#include <toolkit/helper/formpdfexport.hxx>
+#include <vcl/pdfextoutdevdata.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/scopeguard.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/primitive2d/controlprimitive2d.hxx>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/bind.hpp>
+
+/*
+
+Form controls (more precise: UNO Controls) in the drawing layer are ... prone to breakage, since they have some
+specialities which the drawing layer currently doesn't capture too well. In particular, having a living VCL
+window as child of the document window, and coupling this Window to a drawing layer object, makes things
+difficult sometimes.
+
+Below is a list of issues which existed in the past. Whenever you change code here, you're encouraged to
+verify those issues are still fixed. (Whenever you have some additional time, you're encouraged to write
+an automatic test for one or more of those issues for which this is possible :)
+
+http://www.openoffice.org/issues/show_bug.cgi?id=105992
+zooming documents containg (alive) form controls improperly positions the controls
+
+http://www.openoffice.org/issues/show_bug.cgi?id=104362
+crash when copy a control
+
+http://www.openoffice.org/issues/show_bug.cgi?id=104544
+Gridcontrol duplicated after design view on/off
+
+http://www.openoffice.org/issues/show_bug.cgi?id=102089
+print preview shows control elements with property printable=false
+
+http://www.openoffice.org/issues/show_bug.cgi?id=102090
+problem with setVisible on TextControl
+
+http://www.openoffice.org/issues/show_bug.cgi?id=103138
+loop when insert a control in draw
+
+http://www.openoffice.org/issues/show_bug.cgi?id=101398
+initially-displaying a document with many controls is very slow
+
+http://www.openoffice.org/issues/show_bug.cgi?id=72429
+repaint error in form wizard in bugdoc database
+
+http://www.openoffice.org/issues/show_bug.cgi?id=72694
+form control artifacts when scrolling a text fast
+
+
+issues in the old (Sun-internal) bug tracking system:
+
+#110592#
+form controls being in redlining or in hidden section are visible in alive-mode
+
+*/
+
+//........................................................................
+namespace sdr { namespace contact {
+//........................................................................
+
+ /** === begin UNO using === **/
+ using namespace ::com::sun::star::awt::InvalidateStyle;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::awt::XControl;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::awt::XControlModel;
+ using ::com::sun::star::awt::XControlContainer;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::awt::XWindow2;
+ using ::com::sun::star::awt::XWindowListener;
+ using ::com::sun::star::awt::PosSize::POSSIZE;
+ using ::com::sun::star::awt::XView;
+ using ::com::sun::star::awt::XGraphics;
+ using ::com::sun::star::awt::WindowEvent;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::awt::XWindowPeer;
+ using ::com::sun::star::beans::XPropertyChangeListener;
+ using ::com::sun::star::util::XModeChangeListener;
+ using ::com::sun::star::util::XModeChangeBroadcaster;
+ using ::com::sun::star::util::ModeChangeEvent;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::container::XContainerListener;
+ using ::com::sun::star::container::XContainer;
+ using ::com::sun::star::container::ContainerEvent;
+ using ::com::sun::star::uno::Any;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= ControlHolder
+ //====================================================================
+ class ControlHolder
+ {
+ private:
+ Reference< XControl > m_xControl;
+ Reference< XWindow2 > m_xControlWindow;
+ Reference< XView > m_xControlView;
+
+ public:
+ ControlHolder()
+ :m_xControl()
+ ,m_xControlWindow()
+ ,m_xControlView()
+ {
+ }
+
+ explicit ControlHolder( const Reference< XControl >& _rxControl )
+ :m_xControl()
+ ,m_xControlWindow()
+ ,m_xControlView()
+ {
+ *this = _rxControl;
+ }
+
+ ControlHolder& operator=( const Reference< XControl >& _rxControl )
+ {
+ clear();
+
+ m_xControl = _rxControl;
+ if ( m_xControl.is() )
+ {
+ m_xControlWindow.set( m_xControl, UNO_QUERY );
+ m_xControlView.set( m_xControl, UNO_QUERY );
+ if ( !m_xControlWindow.is() || !m_xControlView.is() )
+ {
+ OSL_ENSURE( false, "ControlHolder::operator=: invalid XControl, missing required interfaces!" );
+ clear();
+ }
+ }
+
+ return *this;
+ }
+
+ public:
+ inline bool is() const { return m_xControl.is() && m_xControlWindow.is() && m_xControlView.is(); }
+ inline void clear() { m_xControl.clear(); m_xControlWindow.clear(); m_xControlView.clear(); }
+
+ // delegators for the methods of the UNO interfaces
+ // Note all those will crash if called for a NULL object.
+ inline bool isDesignMode() const { return m_xControl->isDesignMode(); }
+ inline void setDesignMode( const bool _bDesign ) const { m_xControl->setDesignMode( _bDesign ); }
+ inline bool isVisible() const { return m_xControlWindow->isVisible(); }
+ inline void setVisible( const bool _bVisible ) const { m_xControlWindow->setVisible( _bVisible ); }
+ inline Reference< XControlModel >
+ getModel() const { return m_xControl->getModel(); }
+ inline void setModel( const Reference< XControlModel >& _m ) const { m_xControl->setModel( _m ); }
+ inline bool isTransparent() const { return m_xControl->isTransparent(); }
+ inline Reference< XWindowPeer >
+ getPeer() const { return m_xControl->getPeer(); }
+
+ inline void addWindowListener( const Reference< XWindowListener >& _l ) const { m_xControlWindow->addWindowListener( _l ); }
+ inline void removeWindowListener( const Reference< XWindowListener >& _l ) const { m_xControlWindow->removeWindowListener( _l ); }
+ void setPosSize( const Rectangle& _rPosSize ) const;
+ Rectangle
+ getPosSize() const;
+ void setZoom( const ::basegfx::B2DVector& _rScale ) const;
+ ::basegfx::B2DVector
+ getZoom() const;
+
+ inline void setGraphics( const Reference< XGraphics >& _g ) const { m_xControlView->setGraphics( _g ); }
+ inline Reference< XGraphics >
+ getGraphics() const { return m_xControlView->getGraphics(); }
+ inline void draw( const Point& _rTopLeft ) const { m_xControlView->draw( _rTopLeft.X(), _rTopLeft.Y() ); }
+
+ void invalidate() const;
+
+ public:
+ inline const Reference< XControl >& getControl() const { return m_xControl; }
+ };
+
+ //--------------------------------------------------------------------
+ bool operator==( const ControlHolder& _rControl, const Reference< XInterface >& _rxCompare )
+ {
+ return _rControl.getControl() == _rxCompare;
+ }
+
+ //--------------------------------------------------------------------
+ bool operator==( const Reference< XInterface >& _rxCompare, const ControlHolder& _rControl )
+ {
+ return _rxCompare == _rControl.getControl();
+ }
+
+ //--------------------------------------------------------------------
+ bool operator==( const ControlHolder& _rControl, const Any& _rxCompare )
+ {
+ return _rControl == Reference< XInterface >( _rxCompare, UNO_QUERY );
+ }
+
+ //--------------------------------------------------------------------
+ bool operator==( const Any& _rxCompare, const ControlHolder& _rControl )
+ {
+ return Reference< XInterface >( _rxCompare, UNO_QUERY ) == _rControl;
+ }
+
+ //--------------------------------------------------------------------
+ void ControlHolder::setPosSize( const Rectangle& _rPosSize ) const
+ {
+ // no check whether we're valid, this is the responsibility of the caller
+
+ // don't call setPosSize when pos/size did not change
+ // #i104181# / 2009-08-18 / frank.schoenheit@sun.com
+ ::Rectangle aCurrentRect( getPosSize() );
+ if ( aCurrentRect != _rPosSize )
+ {
+ m_xControlWindow->setPosSize(
+ _rPosSize.Left(), _rPosSize.Top(), _rPosSize.GetWidth(), _rPosSize.GetHeight(),
+ POSSIZE
+ );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::Rectangle ControlHolder::getPosSize() const
+ {
+ // no check whether we're valid, this is the responsibility of the caller
+ return VCLUnoHelper::ConvertToVCLRect( m_xControlWindow->getPosSize() );
+ }
+
+ //--------------------------------------------------------------------
+ void ControlHolder::setZoom( const ::basegfx::B2DVector& _rScale ) const
+ {
+ // no check whether we're valid, this is the responsibility of the caller
+ m_xControlView->setZoom( (float)_rScale.getX(), (float)_rScale.getY() );
+ }
+
+ //--------------------------------------------------------------------
+ void ControlHolder::invalidate() const
+ {
+ Reference< XWindowPeer > xPeer( m_xControl->getPeer() );
+ if ( xPeer.is() )
+ {
+ Window* pWindow = VCLUnoHelper::GetWindow( xPeer );
+ OSL_ENSURE( pWindow, "ControlHolder::invalidate: no implementation access!" );
+ if ( pWindow )
+ pWindow->Invalidate();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::basegfx::B2DVector ControlHolder::getZoom() const
+ {
+ // no check whether we're valid, this is the responsibility of the caller
+
+ // Argh. Why does XView have a setZoom only, but not a getZoom?
+ Window* pWindow = VCLUnoHelper::GetWindow( m_xControl->getPeer() );
+ OSL_ENSURE( pWindow, "ControlHolder::getZoom: no implementation access!" );
+
+ ::basegfx::B2DVector aZoom( 1, 1 );
+ if ( pWindow )
+ {
+ const Fraction& rZoom( pWindow->GetZoom() );
+ aZoom.setX( (double)rZoom );
+ aZoom.setY( (double)rZoom );
+ }
+ return aZoom;
+ }
+
+ //====================================================================
+ //= UnoControlContactHelper
+ //====================================================================
+ class UnoControlContactHelper
+ {
+ public:
+ /** positions a control, and sets its zoom mode, using a given transformation and output device
+ */
+ static void adjustControlGeometry_throw(
+ const ControlHolder& _rControl,
+ const Rectangle& _rLogicBoundingRect,
+ const ::basegfx::B2DHomMatrix& _rViewTransformation,
+ const ::basegfx::B2DHomMatrix& _rZoomLevelNormalization
+ );
+
+ /** disposes the given control
+ */
+ static void disposeAndClearControl_nothrow(
+ ControlHolder& _rControl
+ );
+
+ private:
+ UnoControlContactHelper(); // never implemented
+ UnoControlContactHelper( const UnoControlContactHelper& ); // never implemented
+ UnoControlContactHelper& operator=( const UnoControlContactHelper& ); // never implemented
+ };
+
+ //--------------------------------------------------------------------
+ void UnoControlContactHelper::adjustControlGeometry_throw( const ControlHolder& _rControl, const Rectangle& _rLogicBoundingRect,
+ const basegfx::B2DHomMatrix& _rViewTransformation, const ::basegfx::B2DHomMatrix& _rZoomLevelNormalization )
+ {
+ OSL_PRECOND( _rControl.is(), "UnoControlContactHelper::adjustControlGeometry_throw: illegal control!" );
+ if ( !_rControl.is() )
+ return;
+
+ #if OSL_DEBUG_LEVEL > 0
+ ::basegfx::B2DTuple aViewScale, aViewTranslate;
+ double nViewRotate(0), nViewShearX(0);
+ _rViewTransformation.decompose( aViewScale, aViewTranslate, nViewRotate, nViewShearX );
+ #endif
+
+ // transform the logic bound rect, using the view transformation, to pixel coordinates
+ ::basegfx::B2DPoint aTopLeft( _rLogicBoundingRect.Left(), _rLogicBoundingRect.Top() );
+ aTopLeft *= _rViewTransformation;
+ ::basegfx::B2DPoint aBottomRight( _rLogicBoundingRect.Right(), _rLogicBoundingRect.Bottom() );
+ aBottomRight *= _rViewTransformation;
+
+ const Rectangle aPaintRectPixel( (long)aTopLeft.getX(), (long)aTopLeft.getY(), (long)aBottomRight.getX(), (long)aBottomRight.getY() );
+ _rControl.setPosSize( aPaintRectPixel );
+
+ // determine the scale from the current view transformation, and the normalization matrix
+ ::basegfx::B2DHomMatrix aObtainResolutionDependentScale( _rViewTransformation * _rZoomLevelNormalization );
+ ::basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ aObtainResolutionDependentScale.decompose( aScale, aTranslate, fRotate, fShearX );
+ _rControl.setZoom( aScale );
+ }
+
+ //--------------------------------------------------------------------
+ void UnoControlContactHelper::disposeAndClearControl_nothrow( ControlHolder& _rControl )
+ {
+ try
+ {
+ Reference< XComponent > xControlComp( _rControl.getControl(), UNO_QUERY );
+ if ( xControlComp.is() )
+ xControlComp->dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ _rControl.clear();
+ }
+
+ //====================================================================
+ //= IPageViewAccess
+ //====================================================================
+ /** interface encapsulating access to an SdrPageView, stripped down to the methods we really need
+ */
+ class IPageViewAccess
+ {
+ public:
+ /** determines whether the view is currently in design mode
+ */
+ virtual bool isDesignMode() const = 0;
+
+ /** retrieves the control container for a given output device
+ */
+ virtual Reference< XControlContainer >
+ getControlContainer( const OutputDevice& _rDevice ) const = 0;
+
+ /** determines whether a given layer is visible
+ */
+ virtual bool isLayerVisible( SdrLayerID _nLayerID ) const = 0;
+ };
+
+ //====================================================================
+ //= SdrPageViewAccess
+ //====================================================================
+ /** is a ->IPageViewAccess implementation based on a real ->SdrPageView instance
+ */
+ class SdrPageViewAccess : public IPageViewAccess
+ {
+ const SdrPageView& m_rPageView;
+ public:
+ SdrPageViewAccess( const SdrPageView& _rPageView ) : m_rPageView( _rPageView ) { }
+
+ virtual bool isDesignMode() const;
+ virtual Reference< XControlContainer >
+ getControlContainer( const OutputDevice& _rDevice ) const;
+ virtual bool isLayerVisible( SdrLayerID _nLayerID ) const;
+ };
+
+ //--------------------------------------------------------------------
+ bool SdrPageViewAccess::isDesignMode() const
+ {
+ return m_rPageView.GetView().IsDesignMode();
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XControlContainer > SdrPageViewAccess::getControlContainer( const OutputDevice& _rDevice ) const
+ {
+ Reference< XControlContainer > xControlContainer = m_rPageView.GetControlContainer( _rDevice );
+ DBG_ASSERT( xControlContainer.is() || NULL == m_rPageView.FindPageWindow( ( const_cast< OutputDevice& >( _rDevice ) ) ),
+ "SdrPageViewAccess::getControlContainer: the output device is known, but there is no control container for it?" );
+ return xControlContainer;
+ }
+
+ //--------------------------------------------------------------------
+ bool SdrPageViewAccess::isLayerVisible( SdrLayerID _nLayerID ) const
+ {
+ return m_rPageView.GetVisibleLayers().IsSet( _nLayerID );
+ }
+
+ //====================================================================
+ //= InvisibleControlViewAccess
+ //====================================================================
+ /** is a ->IPageViewAccess implementation which can be used to create an invisble control for
+ an arbitrary window
+ */
+ class InvisibleControlViewAccess : public IPageViewAccess
+ {
+ private:
+ Reference< XControlContainer >& m_rControlContainer;
+ public:
+ InvisibleControlViewAccess( Reference< XControlContainer >& _inout_ControlContainer )
+ :m_rControlContainer( _inout_ControlContainer )
+ {
+ }
+
+ virtual bool isDesignMode() const;
+ virtual Reference< XControlContainer >
+ getControlContainer( const OutputDevice& _rDevice ) const;
+ virtual bool isLayerVisible( SdrLayerID _nLayerID ) const;
+ };
+
+ //--------------------------------------------------------------------
+ bool InvisibleControlViewAccess::isDesignMode() const
+ {
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XControlContainer > InvisibleControlViewAccess::getControlContainer( const OutputDevice& _rDevice ) const
+ {
+ if ( !m_rControlContainer.is() )
+ {
+ const Window* pWindow = dynamic_cast< const Window* >( &_rDevice );
+ OSL_ENSURE( pWindow, "InvisibleControlViewAccess::getControlContainer: expected to be called for a window only!" );
+ if ( pWindow )
+ m_rControlContainer = VCLUnoHelper::CreateControlContainer( const_cast< Window* >( pWindow ) );
+ }
+ return m_rControlContainer;
+ }
+
+ //--------------------------------------------------------------------
+ bool InvisibleControlViewAccess::isLayerVisible( SdrLayerID /*_nLayerID*/ ) const
+ {
+ return false;
+ }
+
+ //====================================================================
+ //= DummyPageViewAccess
+ //====================================================================
+ /** is a ->IPageViewAccess implementation which can be used to create a control for an arbitrary
+ non-Window device
+
+ The implementation will report the "PageView" as being in design mode, all layers to be visible,
+ and will not return any ControlContainer, so all control container related features (notifications etc)
+ are not available.
+ */
+ class DummyPageViewAccess : public IPageViewAccess
+ {
+ public:
+ DummyPageViewAccess()
+ {
+ }
+
+ virtual bool isDesignMode() const;
+ virtual Reference< XControlContainer >
+ getControlContainer( const OutputDevice& _rDevice ) const;
+ virtual bool isLayerVisible( SdrLayerID _nLayerID ) const;
+ };
+
+ //--------------------------------------------------------------------
+ bool DummyPageViewAccess::isDesignMode() const
+ {
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XControlContainer > DummyPageViewAccess::getControlContainer( const OutputDevice& /*_rDevice*/ ) const
+ {
+ return NULL;
+ }
+
+ //--------------------------------------------------------------------
+ bool DummyPageViewAccess::isLayerVisible( SdrLayerID /*_nLayerID*/ ) const
+ {
+ return true;
+ }
+
+ //====================================================================
+ //= ViewObjectContactOfUnoControl_Impl
+ //====================================================================
+ typedef ::cppu::WeakImplHelper4 < XWindowListener
+ , XPropertyChangeListener
+ , XContainerListener
+ , XModeChangeListener
+ > ViewObjectContactOfUnoControl_Impl_Base;
+
+ class SVX_DLLPRIVATE ViewObjectContactOfUnoControl_Impl : public ViewObjectContactOfUnoControl_Impl_Base
+ {
+ private:
+ /// the instance whose IMPL we are
+ ViewObjectContactOfUnoControl* m_pAntiImpl;
+
+ /// are we currently inside impl_ensureControl_nothrow?
+ bool m_bCreatingControl;
+
+ /** thread safety
+
+ (not really. ATM only our X* implementations are guarded with this, but not
+ the object as a whole.)
+ */
+ mutable ::osl::Mutex m_aMutex;
+
+ /// the control we're responsible for
+ ControlHolder m_aControl;
+
+ /// the ControlContainer where we inserted our control
+ Reference< XContainer > m_xContainer;
+
+ /// the output device for which the control was created
+ const OutputDevice* m_pOutputDeviceForWindow;
+
+ /// flag indicating whether the control is currently visible
+ bool m_bControlIsVisible;
+
+ /// are we currently listening at a design mode control?
+ bool m_bIsDesignModeListening;
+
+ enum ViewControlMode
+ {
+ eDesign,
+ eAlive,
+ eUnknown
+ };
+ /// is the control currently in design mode?
+ mutable ViewControlMode m_eControlDesignMode;
+
+ ::basegfx::B2DHomMatrix m_aZoomLevelNormalization;
+
+ public:
+ ViewObjectContactOfUnoControl_Impl( ViewObjectContactOfUnoControl* _pAntiImpl );
+
+ /** disposes the instance, which is nonfunctional afterwards
+ */
+ void dispose();
+
+ /** determines whether the instance is disposed
+ */
+ bool isDisposed() const { return impl_isDisposed_nofail(); }
+
+ /** determines whether the instance is alive
+ */
+ bool isAlive() const { return !isDisposed(); }
+
+ /** returns the SdrUnoObject associated with the ViewContact
+
+ @precond
+ We're not disposed.
+ */
+ bool getUnoObject( SdrUnoObj*& _out_rpObject ) const;
+
+ /** ensures that we have an ->XControl
+
+ Must only be called if a control is needed when no DisplayInfo is present, yet.
+
+ For creating a control, an ->OutputDevice is needed, and an ->SdrPageView. Both will be obtained
+ from a ->ObjectContactOfPageView. So, if our (anti-impl's) object contact is not a ->ObjectContactOfPageView,
+ this method fill fail.
+
+ Failure of this method will be reported via an assertion in a non-product version.
+ */
+ bool ensureControl( const basegfx::B2DHomMatrix* _pInitialViewTransformationOrNULL );
+
+ /** returns our XControl, if it already has been created
+
+ If you want to ensure that the control exists before accessing it, use ->ensureControl
+ */
+ inline const ControlHolder&
+ getExistentControl() const { return m_aControl; }
+
+ inline bool
+ hasControl() const { return m_aControl.is(); }
+
+ /** positions our XControl according to the geometry settings in the SdrUnoObj, modified by the given
+ transformation, and sets proper zoom settings according to our device
+
+ @precond
+ ->m_pOutputDeviceForWindow and ->m_aControl are not <NULL/>
+ */
+ void positionAndZoomControl( const basegfx::B2DHomMatrix& _rViewTransformation ) const;
+
+ /** determines whether or not our control is printable
+
+ Effectively, this method returns the value of the "Printable" property
+ of the control's model. If we have no control, <FALSE/> is returned.
+ */
+ bool isPrintableControl() const;
+
+ /** sets the design mode on the control, or at least remembers the flag for the
+ time the control is created
+ */
+ void setControlDesignMode( bool _bDesignMode ) const;
+
+ /** determines whether our control is currently visible
+ @nofail
+ */
+ bool isControlVisible() const { return impl_isControlVisible_nofail(); }
+
+ /// creates an XControl for the given device and SdrUnoObj
+ static bool
+ createControlForDevice(
+ IPageViewAccess& _rPageView,
+ const OutputDevice& _rDevice,
+ const SdrUnoObj& _rUnoObject,
+ const basegfx::B2DHomMatrix& _rInitialViewTransformation,
+ const basegfx::B2DHomMatrix& _rInitialZoomNormalization,
+ ControlHolder& _out_rControl
+ );
+
+ struct GuardAccess { friend class VOCGuard; private: GuardAccess() { } };
+ ::osl::Mutex& getMutex( GuardAccess ) const { return m_aMutex; }
+
+ const ViewContactOfUnoControl&
+ getViewContact() const
+ {
+ ENSURE_OR_THROW( !impl_isDisposed_nofail(), "already disposed" );
+ return static_cast< const ViewContactOfUnoControl& >( m_pAntiImpl->GetViewContact() );
+ }
+
+ protected:
+ ~ViewObjectContactOfUnoControl_Impl();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw(RuntimeException);
+
+ // XWindowListener
+ virtual void SAL_CALL windowResized( const WindowEvent& e ) throw(RuntimeException);
+ virtual void SAL_CALL windowMoved( const WindowEvent& e ) throw(RuntimeException);
+ virtual void SAL_CALL windowShown( const EventObject& e ) throw(RuntimeException);
+ virtual void SAL_CALL windowHidden( const EventObject& e ) throw(RuntimeException);
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const PropertyChangeEvent& evt ) throw(RuntimeException);
+
+ // XModeChangeListener
+ virtual void SAL_CALL modeChanged( const ModeChangeEvent& _rSource ) throw (RuntimeException);
+
+ // XContainerListener
+ virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** retrieves the SdrPageView which our associated SdrPageViewWindow belongs to
+
+ @param out_rpPageView
+ a reference to a pointer holding, upon return, the desired SdrPageView
+
+ @return
+ <TRUE/> if and only if a ->SdrPageView could be obtained
+
+ @precond
+ We really belong to an SdrPageViewWindow. Perhaps (I'm not sure ATM :)
+ there are instance for which this might not be true, but those instances
+ should never have a need to call this method.
+
+ @precond
+ We're not disposed.
+
+ @postcond
+ The method expects success, if it returns with <FALSE/>, this will have been
+ asserted.
+
+ @nothrow
+ */
+ bool impl_getPageView_nothrow( SdrPageView*& _out_rpPageView );
+
+ /** adjusts the control visibility so it respects its layer's visibility
+
+ @param _bForce
+ set to <TRUE/> if you want to force a ->XWindow::setVisible call,
+ no matter if the control visibility is already correct
+
+ @precond
+ ->m_aControl is not <NULL/>
+
+ @precond
+ We're not disposed.
+
+ @precond
+ We really belong to an SdrPageViewWindow. There are instance for which this
+ might not be true, but those instances should never have a need to call
+ this method.
+ */
+ void impl_adjustControlVisibilityToLayerVisibility_throw( bool _bForce );
+
+ /** adjusts the control visibility so it respects its layer's visibility
+
+ The control must never be visibile if it's in design mode.
+ In alive mode, it must be visibility if and only it's on a visible layer.
+
+ @param _rxControl
+ the control whose visibility is to be adjusted
+
+ @param _rPageView
+ provides access to the attributes of the SdrPageView which the control finally belongs to
+
+ @param _rUnoObject
+ our SdrUnoObj
+
+ @param _bIsCurrentlyVisible
+ determines whether the control is currently visible. Note that this is only a shortcut for
+ querying _rxControl for the XWindow2 interface, and calling isVisible at this interface.
+ This shortcut has been chosen since the caller usually already has this information.
+ If _bForce is <TRUE/>, _bIsCurrentlyVisible is ignored.
+
+ @param _bForce
+ set to <TRUE/> if you want to force a ->XWindow::setVisible call,
+ no matter if the control visibility is already correct
+
+ @precond
+ We're not disposed.
+ */
+ static void impl_adjustControlVisibilityToLayerVisibility_throw( const ControlHolder& _rxControl, const SdrUnoObj& _rUnoObject,
+ IPageViewAccess& _rPageView, bool _bIsCurrentlyVisible, bool _bForce );
+
+ /** starts or stops listening at various aspects of our control
+
+ @precond
+ ->m_aControl is not <NULL/>
+ */
+ void impl_switchControlListening_nothrow( bool _bStart );
+
+ /** starts or stops listening at our control container
+
+ @precond
+ ->m_xContainer is not <NULL/>
+ */
+ void impl_switchContainerListening_nothrow( bool _bStart );
+
+ /** starts or stops listening at the control for design-mode relevant facets
+ */
+ void impl_switchDesignModeListening_nothrow( bool _bStart );
+
+ /** starts or stops listening for all properties at our control
+
+ @param _bStart
+ determines whether to start or to stop listening
+
+ @precond
+ ->m_aControl is not <NULL/>
+ */
+ void impl_switchPropertyListening_nothrow( bool _bStart );
+
+ /** disposes the instance
+ @param _bAlsoDisposeControl
+ determines whether the XControl should be disposed, too
+ */
+ void impl_dispose_nothrow( bool _bAlsoDisposeControl );
+
+ /** determines whether the instance is disposed
+ @nofail
+ */
+ bool impl_isDisposed_nofail() const { return m_pAntiImpl == NULL; }
+
+ /** determines whether our control is currently visible
+ @nofail
+ */
+ bool impl_isControlVisible_nofail() const { return m_bControlIsVisible; }
+
+ /** determines whether we are currently a listener at the control for desgin-mode relevant facets
+ @nofail
+ */
+ bool impl_isDesignModeListening_nofail() const { return m_bIsDesignModeListening; }
+
+ /** determines whether the control currently is in design mode
+
+ @precond
+ The design mode must already be known. It is known when we first had access to
+ an SdrPageView (which carries this flag), or somebody explicitly set it from
+ outside.
+ */
+ inline bool impl_isControlDesignMode_nothrow() const
+ {
+ DBG_ASSERT( m_eControlDesignMode != eUnknown, "ViewObjectContactOfUnoControl_Impl::impl_isControlDesignMode_nothrow: mode is still unknown!" );
+ return m_eControlDesignMode == eDesign;
+ }
+
+ /** ensures that we have a control for the given PageView/OutputDevice
+ */
+ bool impl_ensureControl_nothrow(
+ IPageViewAccess& _rPageView,
+ const OutputDevice& _rDevice,
+ const basegfx::B2DHomMatrix& _rInitialViewTransformation
+ );
+
+ /** retrieves the device which a PageView belongs to, starting from its ObjectContactOfPageView
+
+ Since #i72752#, the PaintWindow (and thus the OutputDevice) associated with a PageView is not
+ constant over its lifetime. Instead, during some paint operations, the PaintWindow/OutputDevice
+ might be temporarily patched.
+
+ This method cares for this, by retrieving the very original OutputDevice.
+ */
+ static const OutputDevice& impl_getPageViewOutputDevice_nothrow( const ObjectContactOfPageView& _rObjectContact );
+
+ const OutputDevice& impl_getOutputDevice_throw() const;
+
+ private:
+ ViewObjectContactOfUnoControl_Impl(); // never implemented
+ ViewObjectContactOfUnoControl_Impl( const ViewObjectContactOfUnoControl_Impl& ); // never implemented
+ ViewObjectContactOfUnoControl_Impl& operator=( const ViewObjectContactOfUnoControl_Impl& ); // never implemented
+ };
+
+ //====================================================================
+ //= VOCGuard
+ //====================================================================
+ /** class for guarding a ViewObjectContactOfUnoControl_Impl method
+ */
+ class VOCGuard
+ {
+ private:
+ ::osl::MutexGuard m_aMutexGuard;
+
+ public:
+ VOCGuard( const ViewObjectContactOfUnoControl_Impl& _rImpl )
+ :m_aMutexGuard( _rImpl.getMutex( ViewObjectContactOfUnoControl_Impl::GuardAccess() ) )
+ {
+ }
+ };
+
+ //====================================================================
+ //= LazyControlCreationPrimitive2D
+ //====================================================================
+ class LazyControlCreationPrimitive2D : public ::drawinglayer::primitive2d::BufferedDecompositionPrimitive2D
+ {
+ private:
+ typedef ::drawinglayer::primitive2d::BufferedDecompositionPrimitive2D BufferedDecompositionPrimitive2D;
+
+ protected:
+ virtual ::drawinglayer::primitive2d::Primitive2DSequence
+ get2DDecomposition(
+ const ::drawinglayer::geometry::ViewInformation2D& rViewInformation
+ ) const;
+
+ virtual ::drawinglayer::primitive2d::Primitive2DSequence
+ create2DDecomposition(
+ const ::drawinglayer::geometry::ViewInformation2D& rViewInformation
+ ) const;
+
+ virtual ::basegfx::B2DRange
+ getB2DRange(
+ const ::drawinglayer::geometry::ViewInformation2D& rViewInformation
+ ) const;
+
+ public:
+ LazyControlCreationPrimitive2D( const ::rtl::Reference< ViewObjectContactOfUnoControl_Impl >& _pVOCImpl )
+ :m_pVOCImpl( _pVOCImpl )
+ {
+ ENSURE_OR_THROW( m_pVOCImpl.is(), "Illegal argument." );
+ getTransformation( m_pVOCImpl->getViewContact(), m_aTransformation );
+ }
+
+ virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
+
+ // declare unique ID for this primitive class
+ DeclPrimitrive2DIDBlock()
+
+ static void getTransformation( const ViewContactOfUnoControl& _rVOC, ::basegfx::B2DHomMatrix& _out_Transformation );
+
+ private:
+ void impl_positionAndZoomControl( const ::drawinglayer::geometry::ViewInformation2D& _rViewInformation ) const
+ {
+ if ( !_rViewInformation.getViewport().isEmpty() )
+ m_pVOCImpl->positionAndZoomControl( _rViewInformation.getObjectToViewTransformation() );
+ }
+
+ private:
+ ::rtl::Reference< ViewObjectContactOfUnoControl_Impl > m_pVOCImpl;
+ /** The geometry is part of the identity of an primitive, so we cannot calculate it on demand
+ (since the data the calculation is based on might have changed then), but need to calc
+ it at construction time, and remember it.
+ */
+ ::basegfx::B2DHomMatrix m_aTransformation;
+ };
+
+ //====================================================================
+ //= ViewObjectContactOfUnoControl_Impl
+ //====================================================================
+ DBG_NAME( ViewObjectContactOfUnoControl_Impl )
+ //--------------------------------------------------------------------
+ ViewObjectContactOfUnoControl_Impl::ViewObjectContactOfUnoControl_Impl( ViewObjectContactOfUnoControl* _pAntiImpl )
+ :m_pAntiImpl( _pAntiImpl )
+ ,m_bCreatingControl( false )
+ ,m_pOutputDeviceForWindow( NULL )
+ ,m_bControlIsVisible( false )
+ ,m_bIsDesignModeListening( false )
+ ,m_eControlDesignMode( eUnknown )
+ ,m_aZoomLevelNormalization()
+ {
+ DBG_CTOR( ViewObjectContactOfUnoControl_Impl, NULL );
+ DBG_ASSERT( m_pAntiImpl, "ViewObjectContactOfUnoControl_Impl::ViewObjectContactOfUnoControl_Impl: invalid AntiImpl!" );
+
+ const OutputDevice& rPageViewDevice( impl_getOutputDevice_throw() );
+ m_aZoomLevelNormalization = rPageViewDevice.GetInverseViewTransformation();
+
+ #if OSL_DEBUG_LEVEL > 1
+ ::basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ m_aZoomLevelNormalization.decompose( aScale, aTranslate, fRotate, fShearX );
+ #endif
+
+ ::basegfx::B2DHomMatrix aScaleNormalization;
+ MapMode aCurrentDeviceMapMode( rPageViewDevice.GetMapMode() );
+ aScaleNormalization.set( 0, 0, (double)aCurrentDeviceMapMode.GetScaleX() );
+ aScaleNormalization.set( 1, 1, (double)aCurrentDeviceMapMode.GetScaleY() );
+ m_aZoomLevelNormalization *= aScaleNormalization;
+ }
+
+ //--------------------------------------------------------------------
+ ViewObjectContactOfUnoControl_Impl::~ViewObjectContactOfUnoControl_Impl()
+ {
+ if ( !impl_isDisposed_nofail() )
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR( ViewObjectContactOfUnoControl_Impl, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl_Impl::impl_dispose_nothrow( bool _bAlsoDisposeControl )
+ {
+ if ( impl_isDisposed_nofail() )
+ return;
+
+ if ( m_aControl.is() )
+ impl_switchControlListening_nothrow( false );
+
+ if ( m_xContainer.is() )
+ impl_switchContainerListening_nothrow( false );
+
+ // dispose the control
+ if ( _bAlsoDisposeControl )
+ UnoControlContactHelper::disposeAndClearControl_nothrow( m_aControl );
+
+ m_aControl.clear();
+ m_xContainer.clear();
+ m_pOutputDeviceForWindow = NULL;
+ m_bControlIsVisible = false;
+
+ m_pAntiImpl = NULL;
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl_Impl::dispose()
+ {
+ VOCGuard aGuard( *this );
+ impl_dispose_nothrow( true );
+ }
+
+ //--------------------------------------------------------------------
+ bool ViewObjectContactOfUnoControl_Impl::getUnoObject( SdrUnoObj*& _out_rpObject ) const
+ {
+ OSL_PRECOND( !impl_isDisposed_nofail(), "ViewObjectContactOfUnoControl_Impl::getUnoObject: already disposed()" );
+ if ( impl_isDisposed_nofail() )
+ _out_rpObject = NULL;
+ else
+ {
+ _out_rpObject = dynamic_cast< SdrUnoObj* >( m_pAntiImpl->GetViewContact().TryToGetSdrObject() );
+ DBG_ASSERT( _out_rpObject || !m_pAntiImpl->GetViewContact().TryToGetSdrObject(),
+ "ViewObjectContactOfUnoControl_Impl::getUnoObject: invalid SdrObject!" );
+ }
+ return ( _out_rpObject != NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl_Impl::positionAndZoomControl( const basegfx::B2DHomMatrix& _rViewTransformation ) const
+ {
+ OSL_PRECOND( m_aControl.is(), "ViewObjectContactOfUnoControl_Impl::positionAndZoomControl: no output device or no control!" );
+ if ( !m_aControl.is() )
+ return;
+
+ try
+ {
+ SdrUnoObj* pUnoObject( NULL );
+ if ( getUnoObject( pUnoObject ) )
+ {
+ UnoControlContactHelper::adjustControlGeometry_throw( m_aControl, pUnoObject->GetLogicRect(), _rViewTransformation, m_aZoomLevelNormalization );
+ }
+ else
+ OSL_ENSURE( false, "ViewObjectContactOfUnoControl_Impl::positionAndZoomControl: no SdrUnoObj!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ViewObjectContactOfUnoControl_Impl::ensureControl( const basegfx::B2DHomMatrix* _pInitialViewTransformationOrNULL )
+ {
+ OSL_PRECOND( !impl_isDisposed_nofail(), "ViewObjectContactOfUnoControl_Impl::ensureControl: already disposed()" );
+ if ( impl_isDisposed_nofail() )
+ return false;
+
+ ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &m_pAntiImpl->GetObjectContact() );
+ if ( pPageViewContact )
+ {
+ SdrPageViewAccess aPVAccess( pPageViewContact->GetPageWindow().GetPageView() );
+ const OutputDevice& rDevice( impl_getPageViewOutputDevice_nothrow( *pPageViewContact ) );
+ return impl_ensureControl_nothrow(
+ aPVAccess,
+ rDevice,
+ _pInitialViewTransformationOrNULL ? *_pInitialViewTransformationOrNULL : rDevice.GetViewTransformation()
+ );
+ }
+
+ DummyPageViewAccess aNoPageView;
+ const OutputDevice& rDevice( impl_getOutputDevice_throw() );
+ return impl_ensureControl_nothrow(
+ aNoPageView,
+ rDevice,
+ _pInitialViewTransformationOrNULL ? *_pInitialViewTransformationOrNULL : rDevice.GetViewTransformation()
+ );
+ }
+
+ //--------------------------------------------------------------------
+ const OutputDevice& ViewObjectContactOfUnoControl_Impl::impl_getOutputDevice_throw() const
+ {
+ ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &m_pAntiImpl->GetObjectContact() );
+ if ( pPageViewContact )
+ {
+ // do not use ObjectContact::TryToGetOutputDevice here, it would not care for the PageWindow's
+ // OriginalPaintWindow
+ return impl_getPageViewOutputDevice_nothrow( *pPageViewContact );
+ }
+
+ const OutputDevice* pDevice = m_pAntiImpl->GetObjectContact().TryToGetOutputDevice();
+ ENSURE_OR_THROW( pDevice, "no output device -> no control" );
+ return *pDevice;
+ }
+
+ //--------------------------------------------------------------------
+ const OutputDevice& ViewObjectContactOfUnoControl_Impl::impl_getPageViewOutputDevice_nothrow( const ObjectContactOfPageView& _rObjectContact )
+ {
+ // if the PageWindow has a patched PaintWindow, use the original PaintWindow
+ // this ensures that our control is _not_ re-created just because somebody
+ // (temporarily) changed the window to paint onto.
+ // #i72429# / 2007-02-20 / frank.schoenheit@sun.com
+ SdrPageWindow& rPageWindow( _rObjectContact.GetPageWindow() );
+ if ( rPageWindow.GetOriginalPaintWindow() )
+ return rPageWindow.GetOriginalPaintWindow()->GetOutputDevice();
+
+ return rPageWindow.GetPaintWindow().GetOutputDevice();
+ }
+
+ namespace
+ {
+ static void lcl_resetFlag( bool& rbFlag )
+ {
+ rbFlag = false;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ViewObjectContactOfUnoControl_Impl::impl_ensureControl_nothrow( IPageViewAccess& _rPageView, const OutputDevice& _rDevice,
+ const basegfx::B2DHomMatrix& _rInitialViewTransformation )
+ {
+ if ( m_bCreatingControl )
+ {
+ OSL_ENSURE( false, "ViewObjectContactOfUnoControl_Impl::impl_ensureControl_nothrow: reentrance is not really good here!" );
+ // We once had a situation where this was called reentrantly, which lead to all kind of strange effects. All
+ // those affected the grid control, which is the only control so far which is visible in design mode (and
+ // not only in alive mode).
+ // Creating the control triggered an Window::Update on some of its child windows, which triggered a
+ // Paint on parent of the grid control (e.g. the SwEditWin), which triggered a reentrant call to this method,
+ // which it is not really prepared for.
+ //
+ // /me thinks that re-entrance should be caught on a higher level, i.e. the Drawing Layer should not allow
+ // reentrant paint requests. For the moment, until /me can discuss this with AW, catch it here.
+ // 2009-08-27 / #i104544# frank.schoenheit@sun.com
+ return false;
+ }
+
+ m_bCreatingControl = true;
+ ::comphelper::ScopeGuard aGuard( ::boost::bind( lcl_resetFlag, ::boost::ref( m_bCreatingControl ) ) );
+
+ if ( m_aControl.is() )
+ {
+ if ( m_pOutputDeviceForWindow == &_rDevice )
+ return true;
+
+ // Somebody requested a control for a new device, which means either of
+ // - our PageView's paint window changed since we were last here
+ // - we don't belong to a page view, and are simply painted onto different devices
+ // The first sounds strange (doens't it?), the second means we could perhaps
+ // optimize this in the future - there is no need to re-create the control every time,
+ // is it?
+ // #i74523# / 2007-02-15 / frank.schoenheit@sun.com
+ if ( m_xContainer.is() )
+ impl_switchContainerListening_nothrow( false );
+ impl_switchControlListening_nothrow( false );
+ UnoControlContactHelper::disposeAndClearControl_nothrow( m_aControl );
+ }
+
+ SdrUnoObj* pUnoObject( NULL );
+ if ( !getUnoObject( pUnoObject ) )
+ return false;
+
+ ControlHolder aControl;
+ if ( !createControlForDevice( _rPageView, _rDevice, *pUnoObject, _rInitialViewTransformation, m_aZoomLevelNormalization, aControl ) )
+ return false;
+
+ m_pOutputDeviceForWindow = &_rDevice;
+ m_aControl = aControl;
+ m_xContainer = m_xContainer.query( _rPageView.getControlContainer( _rDevice ) );
+ DBG_ASSERT( ( m_xContainer.is() // either have a XControlContainer
+ || ( ( !_rPageView.getControlContainer( _rDevice ).is() ) // or don't have any container,
+ && ( dynamic_cast< const Window* >( &_rDevice ) == NULL ) // which is allowed for non-Window instances only
+ )
+ ),
+ "ViewObjectContactOfUnoControl_Impl::impl_ensureControl_nothrow: no XContainer at the ControlContainer!" );
+
+ try
+ {
+ m_eControlDesignMode = m_aControl.isDesignMode() ? eDesign : eAlive;
+ m_bControlIsVisible = m_aControl.isVisible();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // start listening at all aspects of the control which are interesting to us ...
+ impl_switchControlListening_nothrow( true );
+
+ // start listening at the control container, in case somebody tampers with our control
+ if ( m_xContainer.is() )
+ impl_switchContainerListening_nothrow( true );
+
+ return m_aControl.is();
+ }
+
+ //--------------------------------------------------------------------
+ bool ViewObjectContactOfUnoControl_Impl::createControlForDevice( IPageViewAccess& _rPageView,
+ const OutputDevice& _rDevice, const SdrUnoObj& _rUnoObject, const basegfx::B2DHomMatrix& _rInitialViewTransformation,
+ const basegfx::B2DHomMatrix& _rInitialZoomNormalization, ControlHolder& _out_rControl )
+ {
+ _out_rControl.clear();
+
+ Reference< XControlModel > xControlModel( _rUnoObject.GetUnoControlModel() );
+ DBG_ASSERT( xControlModel.is(), "ViewObjectContactOfUnoControl_Impl::createControlForDevice: no control model at the SdrUnoObject!?" );
+ if ( !xControlModel.is() )
+ return false;
+
+ bool bSuccess = false;
+ try
+ {
+ const ::rtl::OUString sControlServiceName( _rUnoObject.GetUnoControlTypeName() );
+
+ Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(), UNO_SET_THROW );
+ _out_rControl = Reference< XControl >( xFactory->createInstance( sControlServiceName ), UNO_QUERY_THROW );
+
+ // knit the model and the control
+ _out_rControl.setModel( xControlModel );
+
+ // proper geometry
+ UnoControlContactHelper::adjustControlGeometry_throw(
+ _out_rControl,
+ _rUnoObject.GetLogicRect(),
+ _rInitialViewTransformation,
+ _rInitialZoomNormalization
+ );
+
+ // #107049# set design mode before peer is created,
+ // this is also needed for accessibility
+ _out_rControl.setDesignMode( _rPageView.isDesignMode() );
+
+ // adjust the initial visibility according to the visibility of the layer
+ // 2003-06-03 - #110592# - fs@openoffice.org
+ impl_adjustControlVisibilityToLayerVisibility_throw( _out_rControl, _rUnoObject, _rPageView, false, true );
+
+ // add the control to the respective control container
+ // #108327# do this last
+ Reference< XControlContainer > xControlContainer( _rPageView.getControlContainer( _rDevice ) );
+ if ( xControlContainer.is() )
+ xControlContainer->addControl( sControlServiceName, _out_rControl.getControl() );
+
+ bSuccess = true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( !bSuccess )
+ {
+ // delete the control which might have been created already
+ UnoControlContactHelper::disposeAndClearControl_nothrow( _out_rControl );
+ }
+
+ return _out_rControl.is();
+ }
+
+ //--------------------------------------------------------------------
+ bool ViewObjectContactOfUnoControl_Impl::impl_getPageView_nothrow( SdrPageView*& _out_rpPageView )
+ {
+ OSL_PRECOND( !impl_isDisposed_nofail(), "ViewObjectContactOfUnoControl_Impl::impl_getPageView_nothrow: already disposed!" );
+
+ _out_rpPageView = NULL;
+ if ( impl_isDisposed_nofail() )
+ return false;
+
+ ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &m_pAntiImpl->GetObjectContact() );
+ if ( pPageViewContact )
+ _out_rpPageView = &pPageViewContact->GetPageWindow().GetPageView();
+
+ DBG_ASSERT( _out_rpPageView != NULL, "ViewObjectContactOfUnoControl_Impl::impl_getPageView_nothrow: this method is expected to always have success!" );
+ return ( _out_rpPageView != NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl_Impl::impl_adjustControlVisibilityToLayerVisibility_throw( bool _bForce )
+ {
+ OSL_PRECOND( m_aControl.is(),
+ "ViewObjectContactOfUnoControl_Impl::impl_adjustControlVisibilityToLayerVisibility_throw: only valid if we have a control!" );
+
+ SdrPageView* pPageView( NULL );
+ if ( !impl_getPageView_nothrow( pPageView ) )
+ return;
+
+ SdrUnoObj* pUnoObject( NULL );
+ if ( !getUnoObject( pUnoObject ) )
+ return;
+
+ SdrPageViewAccess aPVAccess( *pPageView );
+ impl_adjustControlVisibilityToLayerVisibility_throw( m_aControl, *pUnoObject, aPVAccess, impl_isControlVisible_nofail(), _bForce );
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl_Impl::impl_adjustControlVisibilityToLayerVisibility_throw( const ControlHolder& _rControl,
+ const SdrUnoObj& _rUnoObject, IPageViewAccess& _rPageView, bool _bIsCurrentlyVisible, bool _bForce )
+ {
+ // in design mode, there is no problem with the visibility: The XControl is hidden by
+ // default, and the Drawing Layer will simply not call our paint routine, if we're in
+ // a hidden layer. So, only alive mode matters.
+ if ( !_rControl.isDesignMode() )
+ {
+ // the layer of our object
+ SdrLayerID nObjectLayer = _rUnoObject.GetLayer();
+ // is the object we're residing in visible in this view?
+ bool bIsObjectVisible = _rUnoObject.IsVisible() && _rPageView.isLayerVisible( nObjectLayer );
+
+ if ( _bForce || ( bIsObjectVisible != _bIsCurrentlyVisible ) )
+ {
+ _rControl.setVisible( bIsObjectVisible );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl_Impl::impl_switchContainerListening_nothrow( bool _bStart )
+ {
+ OSL_PRECOND( m_xContainer.is(), "ViewObjectContactOfUnoControl_Impl::impl_switchContainerListening_nothrow: no control container!" );
+ if ( !m_xContainer.is() )
+ return;
+
+ try
+ {
+ if ( _bStart )
+ m_xContainer->addContainerListener( this );
+ else
+ m_xContainer->removeContainerListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl_Impl::impl_switchControlListening_nothrow( bool _bStart )
+ {
+ OSL_PRECOND( m_aControl.is(), "ViewObjectContactOfUnoControl_Impl::impl_switchControlListening_nothrow: invalid control!" );
+ if ( !m_aControl.is() )
+ return;
+
+ try
+ {
+ // listen for visibility changes
+ if ( _bStart )
+ m_aControl.addWindowListener( this );
+ else
+ m_aControl.removeWindowListener( this );
+
+ // in design mode, listen for some more aspects
+ impl_switchDesignModeListening_nothrow( impl_isControlDesignMode_nothrow() && _bStart );
+
+ // listen for design mode changes
+ Reference< XModeChangeBroadcaster > xDesignModeChanges( m_aControl.getControl(), UNO_QUERY_THROW );
+ if ( _bStart )
+ xDesignModeChanges->addModeChangeListener( this );
+ else
+ xDesignModeChanges->removeModeChangeListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl_Impl::impl_switchDesignModeListening_nothrow( bool _bStart )
+ {
+ if ( impl_isDesignModeListening_nofail() != _bStart )
+ {
+ m_bIsDesignModeListening = _bStart;
+ impl_switchPropertyListening_nothrow( _bStart );
+ }
+ }
+
+ //------------------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl_Impl::impl_switchPropertyListening_nothrow( bool _bStart )
+ {
+ OSL_PRECOND( m_aControl.is(), "ViewObjectContactOfUnoControl_Impl::impl_switchPropertyListening_nothrow: no control!" );
+ if ( !m_aControl.is() )
+ return;
+
+ try
+ {
+ Reference< XPropertySet > xModelProperties( m_aControl.getModel(), UNO_QUERY_THROW );
+ if ( _bStart )
+ xModelProperties->addPropertyChangeListener( ::rtl::OUString(), this );
+ else
+ xModelProperties->removePropertyChangeListener( ::rtl::OUString(), this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ViewObjectContactOfUnoControl_Impl::isPrintableControl() const
+ {
+ SdrUnoObj* pUnoObject( NULL );
+ if ( !getUnoObject( pUnoObject ) )
+ return false;
+
+ bool bIsPrintable = false;
+ try
+ {
+ Reference< XPropertySet > xModelProperties( pUnoObject->GetUnoControlModel(), UNO_QUERY_THROW );
+ static const ::rtl::OUString s_sPrintablePropertyName( RTL_CONSTASCII_USTRINGPARAM( "Printable" ) );
+ OSL_VERIFY( xModelProperties->getPropertyValue( s_sPrintablePropertyName ) >>= bIsPrintable );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bIsPrintable;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ViewObjectContactOfUnoControl_Impl::disposing( const EventObject& Source ) throw(RuntimeException)
+ {
+ SolarMutexGuard aSolarGuard;
+ // some code below - in particular our disposal - might trigger actions which require the
+ // SolarMutex. In particular, in our disposal, we remove ourself as listener from the control,
+ // which alone needs the SolarMutex. Of course this - a removeFooListener needed the SolarMutex -
+ // is the real bug. Toolkit really is infested with solar mutex usage ... :(
+ // #i82169# / 2007-11-14 / frank.schoenheit@sun.com
+ VOCGuard aGuard( *this );
+
+ if ( !m_aControl.is() )
+ return;
+
+ if ( ( m_aControl == Source.Source )
+ || ( m_aControl.getModel() == Source.Source )
+ )
+ {
+ // the model or the control is dying ... hmm, not much sense in that we ourself continue
+ // living
+ impl_dispose_nothrow( false );
+ return;
+ }
+
+ DBG_ASSERT( Source.Source == m_xContainer, "ViewObjectContactOfUnoControl_Impl::disposing: Who's this?" );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ViewObjectContactOfUnoControl_Impl::windowResized( const WindowEvent& /*e*/ ) throw(RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ViewObjectContactOfUnoControl_Impl::windowMoved( const WindowEvent& /*e*/ ) throw(RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ViewObjectContactOfUnoControl_Impl::windowShown( const EventObject& /*e*/ ) throw(RuntimeException)
+ {
+ VOCGuard aGuard( *this );
+ m_bControlIsVisible = true;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ViewObjectContactOfUnoControl_Impl::windowHidden( const EventObject& /*e*/ ) throw(RuntimeException)
+ {
+ VOCGuard aGuard( *this );
+ m_bControlIsVisible = false;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ViewObjectContactOfUnoControl_Impl::propertyChange( const PropertyChangeEvent& /*_rEvent*/ ) throw(RuntimeException)
+ {
+ SolarMutexGuard aSolarGuard;
+ // (re)painting might require VCL operations, which need the SolarMutex
+
+ OSL_PRECOND( !impl_isDisposed_nofail(), "ViewObjectContactOfUnoControl_Impl::propertyChange: already disposed()" );
+ if ( impl_isDisposed_nofail() )
+ return;
+
+ VOCGuard aGuard( *this );
+ DBG_ASSERT( m_aControl.is(), "ViewObjectContactOfUnoControl_Impl::propertyChange: " );
+ if ( !m_aControl.is() )
+ return;
+
+ // a generic property changed. If we're in design mode, we need to repaint the control
+ if ( impl_isControlDesignMode_nothrow() )
+ {
+ m_pAntiImpl->propertyChange();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ViewObjectContactOfUnoControl_Impl::modeChanged( const ModeChangeEvent& _rSource ) throw (RuntimeException)
+ {
+ VOCGuard aGuard( *this );
+
+ DBG_ASSERT( _rSource.NewMode.equalsAscii( "design" ) || _rSource.NewMode.equalsAscii( "alive" ),
+ "ViewObjectContactOfUnoControl_Impl::modeChanged: unexpected mode!" );
+
+ m_eControlDesignMode = _rSource.NewMode.equalsAscii( "design" ) ? eDesign : eAlive;
+
+ impl_switchDesignModeListening_nothrow( impl_isControlDesignMode_nothrow() );
+
+ try
+ {
+ // if the control is part of a invisible layer, we need to explicitly hide it in alive mode
+ // 2003-06-03 - #110592# - fs@openoffice.org
+ impl_adjustControlVisibilityToLayerVisibility_throw( false );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ViewObjectContactOfUnoControl_Impl::elementInserted( const ContainerEvent& /*_Event*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ViewObjectContactOfUnoControl_Impl::elementRemoved( const ContainerEvent& Event ) throw (RuntimeException)
+ {
+ SolarMutexGuard aSolarGuard;
+ // some code below - in particular our disposal - might trigger actions which require the
+ // SolarMutex. In particular, in our disposal, we remove ourself as listener from the control,
+ // which alone needs the SolarMutex. Of course this - a removeFooListener needed the SolarMutex -
+ // is the real bug. Toolkit really is infested with solar mutex usage ... :(
+ // #i82169# / 2007-11-14 / frank.schoenheit@sun.com
+ VOCGuard aGuard( *this );
+ DBG_ASSERT( Event.Source == m_xContainer, "ViewObjectContactOfUnoControl_Impl::elementRemoved: where did this come from?" );
+
+ if ( m_aControl == Event.Element )
+ impl_dispose_nothrow( false );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ViewObjectContactOfUnoControl_Impl::elementReplaced( const ContainerEvent& Event ) throw (RuntimeException)
+ {
+ VOCGuard aGuard( *this );
+ DBG_ASSERT( Event.Source == m_xContainer, "ViewObjectContactOfUnoControl_Impl::elementReplaced: where did this come from?" );
+
+ if ( ! ( m_aControl == Event.ReplacedElement ) )
+ return;
+
+ Reference< XControl > xNewControl( Event.Element, UNO_QUERY );
+ DBG_ASSERT( xNewControl.is(), "ViewObjectContactOfUnoControl_Impl::elementReplaced: invalid new control!" );
+ if ( !xNewControl.is() )
+ return;
+
+ ENSURE_OR_THROW( m_pOutputDeviceForWindow, "calling this without /me having an output device should be impossible." );
+
+ DBG_ASSERT( xNewControl->getModel() == m_aControl.getModel(), "ViewObjectContactOfUnoControl_Impl::elementReplaced: another model at the new control?" );
+ // another model should - in the drawing layer - also imply another SdrUnoObj, which
+ // should also result in new ViewContact, and thus in new ViewObjectContacts
+
+ impl_switchControlListening_nothrow( false );
+
+ ControlHolder aNewControl( xNewControl );
+ aNewControl.setZoom( m_aControl.getZoom() );
+ aNewControl.setPosSize( m_aControl.getPosSize() );
+ aNewControl.setDesignMode( impl_isControlDesignMode_nothrow() );
+
+ m_aControl = xNewControl;
+ m_bControlIsVisible = m_aControl.isVisible();
+
+ impl_switchControlListening_nothrow( true );
+
+ m_pAntiImpl->onControlChangedOrModified( ViewObjectContactOfUnoControl::ImplAccess() );
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl_Impl::setControlDesignMode( bool _bDesignMode ) const
+ {
+ if ( ( m_eControlDesignMode != eUnknown ) && ( _bDesignMode == impl_isControlDesignMode_nothrow() ) )
+ // nothing to do
+ return;
+ m_eControlDesignMode = _bDesignMode ? eDesign : eAlive;
+
+ if ( !m_aControl.is() )
+ // nothing to do, the setting will be respected as soon as the control
+ // is created
+ return;
+
+ try
+ {
+ m_aControl.setDesignMode( _bDesignMode );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //====================================================================
+ //= LazyControlCreationPrimitive2D
+ //====================================================================
+ //--------------------------------------------------------------------
+ bool LazyControlCreationPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if ( !BufferedDecompositionPrimitive2D::operator==( rPrimitive ) )
+ return false;
+
+ const LazyControlCreationPrimitive2D* pRHS = dynamic_cast< const LazyControlCreationPrimitive2D* >( &rPrimitive );
+ if ( !pRHS )
+ return false;
+
+ if ( m_pVOCImpl != pRHS->m_pVOCImpl )
+ return false;
+
+ if ( m_aTransformation != pRHS->m_aTransformation )
+ return false;
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ void LazyControlCreationPrimitive2D::getTransformation( const ViewContactOfUnoControl& _rVOC, ::basegfx::B2DHomMatrix& _out_Transformation )
+ {
+ // Do use model data directly to create the correct geometry. Do NOT
+ // use getBoundRect()/getSnapRect() here; tese will use the sequence of
+ // primitives themselves in the long run.
+ const Rectangle aSdrGeoData( _rVOC.GetSdrUnoObj().GetGeoRect() );
+ const basegfx::B2DRange aRange(
+ aSdrGeoData.Left(),
+ aSdrGeoData.Top(),
+ aSdrGeoData.Right(),
+ aSdrGeoData.Bottom()
+ );
+
+ _out_Transformation.identity();
+ _out_Transformation.set( 0, 0, aRange.getWidth() );
+ _out_Transformation.set( 1, 1, aRange.getHeight() );
+ _out_Transformation.set( 0, 2, aRange.getMinX() );
+ _out_Transformation.set( 1, 2, aRange.getMinY() );
+ }
+
+ //--------------------------------------------------------------------
+ ::basegfx::B2DRange LazyControlCreationPrimitive2D::getB2DRange( const ::drawinglayer::geometry::ViewInformation2D& /*rViewInformation*/ ) const
+ {
+ ::basegfx::B2DRange aRange( 0.0, 0.0, 1.0, 1.0 );
+ aRange.transform( m_aTransformation );
+ return aRange;
+ }
+
+ //--------------------------------------------------------------------
+ ::drawinglayer::primitive2d::Primitive2DSequence LazyControlCreationPrimitive2D::get2DDecomposition( const ::drawinglayer::geometry::ViewInformation2D& _rViewInformation ) const
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ ::basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ _rViewInformation.getObjectToViewTransformation().decompose( aScale, aTranslate, fRotate, fShearX );
+ #endif
+ if ( m_pVOCImpl->hasControl() )
+ impl_positionAndZoomControl( _rViewInformation );
+ return BufferedDecompositionPrimitive2D::get2DDecomposition( _rViewInformation );
+ }
+
+ //--------------------------------------------------------------------
+ ::drawinglayer::primitive2d::Primitive2DSequence LazyControlCreationPrimitive2D::create2DDecomposition( const ::drawinglayer::geometry::ViewInformation2D& _rViewInformation ) const
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ ::basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ _rViewInformation.getObjectToViewTransformation().decompose( aScale, aTranslate, fRotate, fShearX );
+ #endif
+ const bool bHadControl = m_pVOCImpl->getExistentControl().is();
+
+ // force control here to make it a VCL ChildWindow. Will be fetched
+ // and used below by getExistentControl()
+ m_pVOCImpl->ensureControl( &_rViewInformation.getObjectToViewTransformation() );
+ impl_positionAndZoomControl( _rViewInformation );
+
+ // get needed data
+ const ViewContactOfUnoControl& rViewContactOfUnoControl( m_pVOCImpl->getViewContact() );
+ Reference< XControlModel > xControlModel( rViewContactOfUnoControl.GetSdrUnoObj().GetUnoControlModel() );
+ const ControlHolder& rControl( m_pVOCImpl->getExistentControl() );
+
+ if ( !bHadControl && rControl.is() && rControl.isVisible() )
+ rControl.invalidate();
+
+ if ( !bHadControl && rControl.is() && rControl.isVisible() )
+ rControl.invalidate();
+
+ // check if we already have an XControl.
+ if ( !xControlModel.is() || !rControl.is() )
+ // use the default mechanism. This will create a ControlPrimitive2D without
+ // handing over a XControl. If not even a XControlModel exists, it will
+ // create the SdrObject fallback visualisation
+ return rViewContactOfUnoControl.getViewIndependentPrimitive2DSequence();
+
+ // create a primitive and hand over the existing xControl. This will
+ // allow the primitive to not need to create another one on demand.
+ const drawinglayer::primitive2d::Primitive2DReference xRetval( new ::drawinglayer::primitive2d::ControlPrimitive2D(
+ m_aTransformation, xControlModel, rControl.getControl() ) );
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xRetval, 1);
+ }
+
+ //--------------------------------------------------------------------
+ ImplPrimitrive2DIDBlock( LazyControlCreationPrimitive2D, PRIMITIVE2D_ID_SDRCONTROLPRIMITIVE2D )
+
+ //====================================================================
+ //= ViewObjectContactOfUnoControl
+ //====================================================================
+ DBG_NAME( ViewObjectContactOfUnoControl )
+ //--------------------------------------------------------------------
+ ViewObjectContactOfUnoControl::ViewObjectContactOfUnoControl( ObjectContact& _rObjectContact, ViewContactOfUnoControl& _rViewContact )
+ :ViewObjectContactOfSdrObj( _rObjectContact, _rViewContact )
+ ,m_pImpl( new ViewObjectContactOfUnoControl_Impl( this ) )
+ {
+ DBG_CTOR( ViewObjectContactOfUnoControl, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ViewObjectContactOfUnoControl::~ViewObjectContactOfUnoControl()
+ {
+ m_pImpl->dispose();
+ m_pImpl = NULL;
+
+ DBG_DTOR( ViewObjectContactOfUnoControl, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ bool ViewObjectContactOfUnoControl::isControlVisible() const
+ {
+ VOCGuard aGuard( *m_pImpl );
+ const ControlHolder& rControl( m_pImpl->getExistentControl() );
+ return rControl.is() && rControl.isVisible();
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XControl > ViewObjectContactOfUnoControl::getControl()
+ {
+ VOCGuard aGuard( *m_pImpl );
+ m_pImpl->ensureControl( NULL );
+ return m_pImpl->getExistentControl().getControl();
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XControl > ViewObjectContactOfUnoControl::getTemporaryControlForWindow(
+ const Window& _rWindow, Reference< XControlContainer >& _inout_ControlContainer, const SdrUnoObj& _rUnoObject )
+ {
+ ControlHolder aControl;
+
+ InvisibleControlViewAccess aSimulatePageView( _inout_ControlContainer );
+ OSL_VERIFY( ViewObjectContactOfUnoControl_Impl::createControlForDevice( aSimulatePageView, _rWindow, _rUnoObject,
+ _rWindow.GetViewTransformation(), _rWindow.GetInverseViewTransformation(), aControl ) );
+ return aControl.getControl();
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl::ensureControlVisibility( bool _bVisible ) const
+ {
+ VOCGuard aGuard( *m_pImpl );
+
+ try
+ {
+ const ControlHolder& rControl( m_pImpl->getExistentControl() );
+ if ( !rControl.is() )
+ return;
+
+ // only need to care for alive mode
+ if ( rControl.isDesignMode() )
+ return;
+
+ // is the visibility correct?
+ if ( m_pImpl->isControlVisible() == _bVisible )
+ return;
+
+ // no -> adjust it
+ rControl.setVisible( _bVisible );
+ DBG_ASSERT( m_pImpl->isControlVisible() == _bVisible, "ViewObjectContactOfUnoControl::ensureControlVisibility: this didn't work!" );
+ // now this would mean that either isControlVisible is not reliable,
+ // or that showing/hiding the window did not work as intended.
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl::setControlDesignMode( bool _bDesignMode ) const
+ {
+ VOCGuard aGuard( *m_pImpl );
+ m_pImpl->setControlDesignMode( _bDesignMode );
+
+ if(!_bDesignMode)
+ {
+ // when live mode is switched on, a refresh is needed. The edit mode visualisation
+ // needs to be repainted and the now used VCL-Window needs to be positioned and
+ // sized. Both is done from the repant refresh.
+ const_cast< ViewObjectContactOfUnoControl* >(this)->ActionChanged();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfUnoControl::createPrimitive2DSequence(const DisplayInfo& /*rDisplayInfo*/) const
+ {
+ if ( m_pImpl->isDisposed() )
+ // our control already died.
+ // TODO: Is it worth re-creating the control? Finally, this is a pathological situation, it means some instance
+ // disposed the control though it doesn't own it. So, /me thinks we should not bother here.
+ return drawinglayer::primitive2d::Primitive2DSequence();
+
+ // ignore existing controls which are in alive mode and manually switched to "invisible"
+ // #102090# / 2009-06-05 / frank.schoenheit@sun.com
+ const ControlHolder& rControl( m_pImpl->getExistentControl() );
+ if ( rControl.is() && !rControl.isDesignMode() && !rControl.isVisible() )
+ return drawinglayer::primitive2d::Primitive2DSequence();
+
+ ::drawinglayer::primitive2d::Primitive2DReference xPrimitive( new LazyControlCreationPrimitive2D( m_pImpl ) );
+ return ::drawinglayer::primitive2d::Primitive2DSequence( &xPrimitive, 1 );
+ }
+
+ //--------------------------------------------------------------------
+ bool ViewObjectContactOfUnoControl::isPrimitiveVisible( const DisplayInfo& _rDisplayInfo ) const
+ {
+ VOCGuard aGuard( *m_pImpl );
+
+ if ( m_pImpl->hasControl() )
+ {
+ const ::drawinglayer::geometry::ViewInformation2D& rViewInformation( GetObjectContact().getViewInformation2D() );
+ #if OSL_DEBUG_LEVEL > 1
+ ::basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rViewInformation.getObjectToViewTransformation().decompose( aScale, aTranslate, fRotate, fShearX );
+ #endif
+
+ if ( !rViewInformation.getViewport().isEmpty() )
+ m_pImpl->positionAndZoomControl( rViewInformation.getObjectToViewTransformation() );
+ }
+
+ return ViewObjectContactOfSdrObj::isPrimitiveVisible( _rDisplayInfo );
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl::propertyChange()
+ {
+ impl_onControlChangedOrModified();
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl::ActionChanged()
+ {
+ // call parent
+ ViewObjectContactOfSdrObj::ActionChanged();
+ const ControlHolder& rControl(m_pImpl->getExistentControl());
+
+ if(rControl.is() && !rControl.isDesignMode())
+ {
+ // #i93180# if layer visibility has changed and control is in live mode, it is necessary
+ // to correct visibility to make those control vanish on SdrObject LayerID changes
+ const SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
+
+ if(pSdrPageView)
+ {
+ const SdrObject& rObject = getSdrObject();
+ const bool bIsLayerVisible( rObject.IsVisible() && pSdrPageView->GetVisibleLayers().IsSet(rObject.GetLayer()));
+
+ if(rControl.isVisible() != bIsLayerVisible)
+ {
+ rControl.setVisible(bIsLayerVisible);
+ }
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ViewObjectContactOfUnoControl::impl_onControlChangedOrModified()
+ {
+ // graphical invalidate at all views
+ ActionChanged();
+
+ // #i93318# flush Primitive2DSequence to force recreation with updated XControlModel
+ // since e.g. background color has changed and existing decompositions are possibly no
+ // longer valid. Unfortunately this is not detected from ControlPrimitive2D::operator==
+ // since it only has a uno reference to the XControlModel
+ flushPrimitive2DSequence();
+ }
+
+ //====================================================================
+ //= UnoControlPrintOrPreviewContact
+ //====================================================================
+ DBG_NAME( UnoControlPrintOrPreviewContact )
+ //--------------------------------------------------------------------
+ UnoControlPrintOrPreviewContact::UnoControlPrintOrPreviewContact( ObjectContactOfPageView& _rObjectContact, ViewContactOfUnoControl& _rViewContact )
+ :ViewObjectContactOfUnoControl( _rObjectContact, _rViewContact )
+ {
+ DBG_CTOR( UnoControlPrintOrPreviewContact, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ UnoControlPrintOrPreviewContact::~UnoControlPrintOrPreviewContact()
+ {
+ DBG_DTOR( UnoControlPrintOrPreviewContact, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ drawinglayer::primitive2d::Primitive2DSequence UnoControlPrintOrPreviewContact::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo ) const
+ {
+ if ( !m_pImpl->isPrintableControl() )
+ return drawinglayer::primitive2d::Primitive2DSequence();
+ return ViewObjectContactOfUnoControl::createPrimitive2DSequence( rDisplayInfo );
+ }
+
+//........................................................................
+} } // namespace sdr::contact
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/contact/viewobjectcontactredirector.cxx b/svx/source/sdr/contact/viewobjectcontactredirector.cxx
new file mode 100644
index 000000000000..1c26d9e2e074
--- /dev/null
+++ b/svx/source/sdr/contact/viewobjectcontactredirector.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewobjectcontactredirector.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ // basic constructor.
+ ViewObjectContactRedirector::ViewObjectContactRedirector()
+ {
+ }
+
+ // The destructor.
+ ViewObjectContactRedirector::~ViewObjectContactRedirector()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
+ const sdr::contact::ViewObjectContact& rOriginal,
+ const sdr::contact::DisplayInfo& rDisplayInfo)
+ {
+ return rOriginal.createPrimitive2DSequence(rDisplayInfo);
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/event/eventhandler.cxx b/svx/source/sdr/event/eventhandler.cxx
new file mode 100644
index 000000000000..6edef73bcbba
--- /dev/null
+++ b/svx/source/sdr/event/eventhandler.cxx
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/event/eventhandler.hxx>
+
+// for SOLARIS compiler include of algorithm part of _STL is necesary to
+// get access to basic algos like ::std::find
+#include <algorithm>
+#include <tools/debug.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace event
+ {
+ BaseEvent::BaseEvent(EventHandler& rEventHandler)
+ : mrEventHandler(rEventHandler)
+ {
+ mrEventHandler.AddEvent(*this);
+ }
+
+ BaseEvent::~BaseEvent()
+ {
+ mrEventHandler.RemoveEvent(*this);
+ }
+ } // end of namespace mixer
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace event
+ {
+ void EventHandler::AddEvent(BaseEvent& rBaseEvent)
+ {
+ maVector.push_back(&rBaseEvent);
+ }
+
+ void EventHandler::RemoveEvent(BaseEvent& rBaseEvent)
+ {
+ if(maVector.back() == &rBaseEvent)
+ {
+ // the one to remove is the last, pop
+ maVector.pop_back();
+ }
+ else
+ {
+ const BaseEventVector::iterator aFindResult = ::std::find(
+ maVector.begin(), maVector.end(), &rBaseEvent);
+ DBG_ASSERT(aFindResult != maVector.end(),
+ "EventHandler::RemoveEvent: Event to be removed not found (!)");
+ maVector.erase(aFindResult);
+ }
+ }
+
+ BaseEvent* EventHandler::GetEvent()
+ {
+ if(maVector.size())
+ {
+ // get the last event, that one is fastest to be removed
+ return maVector.back();
+ }
+ else
+ {
+ return 0L;
+ }
+ }
+
+ EventHandler::EventHandler()
+ {
+ }
+
+ EventHandler::~EventHandler()
+ {
+ while(maVector.size())
+ {
+ delete GetEvent();
+ }
+ }
+
+ // Trigger and consume the events
+ void EventHandler::ExecuteEvents()
+ {
+ for(;;)
+ {
+ BaseEvent* pEvent = GetEvent();
+ if(pEvent == NULL)
+ break;
+ pEvent->ExecuteEvent();
+ delete pEvent;
+ }
+ }
+
+ // for control
+ sal_Bool EventHandler::IsEmpty() const
+ {
+ return (0L == maVector.size());
+ }
+ } // end of namespace mixer
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace event
+ {
+ TimerEventHandler::TimerEventHandler(sal_uInt32 nTimeout)
+ {
+ SetTimeout(nTimeout);
+ Stop();
+ }
+
+ TimerEventHandler::~TimerEventHandler()
+ {
+ Stop();
+ }
+
+ // The timer when it is triggered; from class Timer
+ void TimerEventHandler::Timeout()
+ {
+ ExecuteEvents();
+ }
+
+ // reset the timer
+ void TimerEventHandler::Restart()
+ {
+ Start();
+ }
+ } // end of namespace mixer
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/event/makefile.mk b/svx/source/sdr/event/makefile.mk
new file mode 100644
index 000000000000..ff379af6be2a
--- /dev/null
+++ b/svx/source/sdr/event/makefile.mk
@@ -0,0 +1,44 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=svx
+TARGET=event
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/eventhandler.obj
+
+.INCLUDE : target.mk
diff --git a/svx/source/sdr/overlay/makefile.mk b/svx/source/sdr/overlay/makefile.mk
new file mode 100644
index 000000000000..155053826f0d
--- /dev/null
+++ b/svx/source/sdr/overlay/makefile.mk
@@ -0,0 +1,59 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=svx
+TARGET=overlay
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/overlayanimatedbitmapex.obj \
+ $(SLO)$/overlaybitmapex.obj \
+ $(SLO)$/overlaycrosshair.obj \
+ $(SLO)$/overlayhatchrect.obj \
+ $(SLO)$/overlayhelpline.obj \
+ $(SLO)$/overlayline.obj \
+ $(SLO)$/overlaymanager.obj \
+ $(SLO)$/overlaymanagerbuffered.obj \
+ $(SLO)$/overlayobject.obj \
+ $(SLO)$/overlayobjectcell.obj \
+ $(SLO)$/overlayobjectlist.obj \
+ $(SLO)$/overlaypolypolygon.obj \
+ $(SLO)$/overlayprimitive2dsequenceobject.obj \
+ $(SLO)$/overlayrollingrectangle.obj \
+ $(SLO)$/overlayselection.obj \
+ $(SLO)$/overlaytools.obj \
+ $(SLO)$/overlaytriangle.obj
+
+.INCLUDE : target.mk
diff --git a/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx b/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
new file mode 100644
index 000000000000..4d6c3fe09de3
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayanimatedbitmapex.cxx
@@ -0,0 +1,220 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/outdev.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/overlay/overlaytools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ // #i53216# check blink time value range
+ void OverlayAnimatedBitmapEx::impCheckBlinkTimeValueRange()
+ {
+ if(mnBlinkTime < 25)
+ {
+ mnBlinkTime = 25;
+ }
+ else if(mnBlinkTime > 10000)
+ {
+ mnBlinkTime = 10000;
+ }
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence OverlayAnimatedBitmapEx::createOverlayObjectPrimitive2DSequence()
+ {
+ if(mbOverlayState)
+ {
+ const drawinglayer::primitive2d::Primitive2DReference aPrimitive(
+ new drawinglayer::primitive2d::OverlayBitmapExPrimitive(
+ getBitmapEx1(),
+ getBasePosition(),
+ getCenterX1(),
+ getCenterY1()));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive, 1);
+ }
+ else
+ {
+ const drawinglayer::primitive2d::Primitive2DReference aPrimitive(
+ new drawinglayer::primitive2d::OverlayBitmapExPrimitive(
+ getBitmapEx2(),
+ getBasePosition(),
+ getCenterX2(),
+ getCenterY2()));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&aPrimitive, 1);
+ }
+ }
+
+ OverlayAnimatedBitmapEx::OverlayAnimatedBitmapEx(
+ const basegfx::B2DPoint& rBasePos,
+ const BitmapEx& rBitmapEx1,
+ const BitmapEx& rBitmapEx2,
+ sal_uInt32 nBlinkTime,
+ sal_uInt16 nCenX1,
+ sal_uInt16 nCenY1,
+ sal_uInt16 nCenX2,
+ sal_uInt16 nCenY2)
+ : OverlayObjectWithBasePosition(rBasePos, Color(COL_WHITE)),
+ maBitmapEx1(rBitmapEx1),
+ maBitmapEx2(rBitmapEx2),
+ mnCenterX1(nCenX1), mnCenterY1(nCenY1),
+ mnCenterX2(nCenX2), mnCenterY2(nCenY2),
+ mnBlinkTime(nBlinkTime),
+ mbOverlayState(false)
+ {
+ // set AllowsAnimation flag to mark this object as animation capable
+ mbAllowsAnimation = true;
+
+ // #i53216# check blink time value range
+ impCheckBlinkTimeValueRange();
+ }
+
+ OverlayAnimatedBitmapEx::~OverlayAnimatedBitmapEx()
+ {
+ }
+
+ void OverlayAnimatedBitmapEx::setBitmapEx1(const BitmapEx& rNew)
+ {
+ if(rNew != maBitmapEx1)
+ {
+ // remember new Bitmap
+ maBitmapEx1 = rNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayAnimatedBitmapEx::setBitmapEx2(const BitmapEx& rNew)
+ {
+ if(rNew != maBitmapEx2)
+ {
+ // remember new Bitmap
+ maBitmapEx2 = rNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayAnimatedBitmapEx::setCenterXY1(sal_uInt16 nNewX, sal_uInt16 nNewY)
+ {
+ if(nNewX != mnCenterX1 || nNewY != mnCenterY1)
+ {
+ // remember new values
+ if(nNewX != mnCenterX1)
+ {
+ mnCenterX1 = nNewX;
+ }
+
+ if(nNewY != mnCenterY1)
+ {
+ mnCenterY1 = nNewY;
+ }
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayAnimatedBitmapEx::setCenterXY2(sal_uInt16 nNewX, sal_uInt16 nNewY)
+ {
+ if(nNewX != mnCenterX2 || nNewY != mnCenterY2)
+ {
+ // remember new values
+ if(nNewX != mnCenterX2)
+ {
+ mnCenterX2 = nNewX;
+ }
+
+ if(nNewY != mnCenterY2)
+ {
+ mnCenterY2 = nNewY;
+ }
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayAnimatedBitmapEx::setBlinkTime(sal_uInt32 nNew)
+ {
+ if(mnBlinkTime != nNew)
+ {
+ // remember new value
+ mnBlinkTime = nNew;
+
+ // #i53216# check blink time value range
+ impCheckBlinkTimeValueRange();
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayAnimatedBitmapEx::Trigger(sal_uInt32 nTime)
+ {
+ if(getOverlayManager())
+ {
+ // #i53216# produce event after nTime + x
+ SetTime(nTime + mnBlinkTime);
+
+ // switch state
+ if(mbOverlayState)
+ {
+ mbOverlayState = false;
+ }
+ else
+ {
+ mbOverlayState = true;
+ }
+
+ // re-insert me as event
+ getOverlayManager()->InsertEvent(this);
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlaybitmapex.cxx b/svx/source/sdr/overlay/overlaybitmapex.cxx
new file mode 100644
index 000000000000..813d778d378b
--- /dev/null
+++ b/svx/source/sdr/overlay/overlaybitmapex.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
+#include <svx/sdr/overlay/overlaybitmapex.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/overlay/overlaytools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ drawinglayer::primitive2d::Primitive2DSequence OverlayBitmapEx::createOverlayObjectPrimitive2DSequence()
+ {
+ drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::OverlayBitmapExPrimitive(
+ getBitmapEx(),
+ getBasePosition(),
+ getCenterX(),
+ getCenterY()));
+
+ if(basegfx::fTools::more(mfAlpha, 0.0))
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence aNewTransPrimitiveVector(&aReference, 1L);
+ aReference = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(aNewTransPrimitiveVector, mfAlpha));
+ }
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+ }
+
+ OverlayBitmapEx::OverlayBitmapEx(
+ const basegfx::B2DPoint& rBasePos,
+ const BitmapEx& rBitmapEx,
+ sal_uInt16 nCenX, sal_uInt16 nCenY, double fAlpha)
+ : OverlayObjectWithBasePosition(rBasePos, Color(COL_WHITE)),
+ maBitmapEx(rBitmapEx),
+ mnCenterX(nCenX),
+ mnCenterY(nCenY),
+ mfAlpha(fAlpha)
+ {
+ }
+
+ OverlayBitmapEx::~OverlayBitmapEx()
+ {
+ }
+
+ void OverlayBitmapEx::setBitmapEx(const BitmapEx& rNew)
+ {
+ if(rNew != maBitmapEx)
+ {
+ // remember new Bitmap
+ maBitmapEx = rNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayBitmapEx::setCenterXY(sal_uInt16 nNewX, sal_uInt16 nNewY)
+ {
+ if(nNewX != mnCenterX || nNewY != mnCenterY)
+ {
+ // remember new values
+ if(nNewX != mnCenterX)
+ {
+ mnCenterX = nNewX;
+ }
+
+ if(nNewY != mnCenterY)
+ {
+ mnCenterY = nNewY;
+ }
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlaycrosshair.cxx b/svx/source/sdr/overlay/overlaycrosshair.cxx
new file mode 100644
index 000000000000..a903996c9aed
--- /dev/null
+++ b/svx/source/sdr/overlay/overlaycrosshair.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlaycrosshair.hxx>
+#include <tools/gen.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/outdev.hxx>
+#include <svx/sdr/overlay/overlaytools.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ drawinglayer::primitive2d::Primitive2DSequence OverlayCrosshairStriped::createOverlayObjectPrimitive2DSequence()
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+
+ if(getOverlayManager())
+ {
+ const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
+ const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
+ const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel());
+
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::OverlayCrosshairPrimitive(
+ getBasePosition(),
+ aRGBColorA,
+ aRGBColorB,
+ fStripeLengthPixel));
+
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+ }
+
+ return aRetval;
+ }
+
+ void OverlayCrosshairStriped::stripeDefinitionHasChanged()
+ {
+ // react on OverlayManager's stripe definition change
+ objectChange();
+ }
+
+ OverlayCrosshairStriped::OverlayCrosshairStriped(const basegfx::B2DPoint& rBasePos)
+ : OverlayObjectWithBasePosition(rBasePos, Color(COL_BLACK))
+ {
+ }
+
+ OverlayCrosshairStriped::~OverlayCrosshairStriped()
+ {
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlayhatchrect.cxx b/svx/source/sdr/overlay/overlayhatchrect.cxx
new file mode 100644
index 000000000000..b459004e927e
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayhatchrect.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/overlay/overlayhatchrect.hxx>
+#include <vcl/hatch.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/numeric/ftools.hxx>
+#include <svx/sdr/overlay/overlaytools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ drawinglayer::primitive2d::Primitive2DSequence OverlayHatchRect::createOverlayObjectPrimitive2DSequence()
+ {
+ const basegfx::B2DRange aHatchRange(getBasePosition(), getSecondPosition());
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::OverlayHatchRectanglePrimitive(
+ aHatchRange,
+ 3.0,
+ getHatchRotation(),
+ getBaseColor().getBColor(),
+ getDiscreteGrow(),
+ getDiscreteShrink(),
+ getRotation()));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+ }
+
+ OverlayHatchRect::OverlayHatchRect(
+ const basegfx::B2DPoint& rBasePosition,
+ const basegfx::B2DPoint& rSecondPosition,
+ const Color& rHatchColor,
+ double fDiscreteGrow,
+ double fDiscreteShrink,
+ double fHatchRotation,
+ double fRotation)
+ : OverlayObjectWithBasePosition(rBasePosition, rHatchColor),
+ maSecondPosition(rSecondPosition),
+ mfDiscreteGrow(fDiscreteGrow),
+ mfDiscreteShrink(fDiscreteShrink),
+ mfHatchRotation(fHatchRotation),
+ mfRotation(fRotation)
+ {
+ }
+
+ void OverlayHatchRect::setSecondPosition(const basegfx::B2DPoint& rNew)
+ {
+ if(rNew != maSecondPosition)
+ {
+ // remember new value
+ maSecondPosition = rNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlayhelpline.cxx b/svx/source/sdr/overlay/overlayhelpline.cxx
new file mode 100644
index 000000000000..9517438405a9
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayhelpline.cxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlayhelpline.hxx>
+#include <tools/gen.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+#include <svx/sdr/overlay/overlaytools.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ drawinglayer::primitive2d::Primitive2DSequence OverlayHelplineStriped::createOverlayObjectPrimitive2DSequence()
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+
+ if(getOverlayManager())
+ {
+ const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
+ const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
+ const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel());
+ const drawinglayer::primitive2d::HelplineStyle aStyle(
+ SDRHELPLINE_POINT == getKind() ? drawinglayer::primitive2d::HELPLINESTYLE_POINT :
+ SDRHELPLINE_VERTICAL == getKind() ? drawinglayer::primitive2d::HELPLINESTYLE_VERTICAL :
+ drawinglayer::primitive2d::HELPLINESTYLE_HORIZONTAL);
+
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::OverlayHelplineStripedPrimitive(
+ getBasePosition(),
+ aStyle,
+ aRGBColorA,
+ aRGBColorB,
+ fStripeLengthPixel));
+
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+ }
+
+ return aRetval;
+ }
+
+ void OverlayHelplineStriped::stripeDefinitionHasChanged()
+ {
+ // react on OverlayManager's stripe definition change
+ objectChange();
+ }
+
+ OverlayHelplineStriped::OverlayHelplineStriped(
+ const basegfx::B2DPoint& rBasePos,
+ SdrHelpLineKind eNewKind)
+ : OverlayObjectWithBasePosition(rBasePos, Color(COL_BLACK)),
+ meKind(eNewKind)
+ {
+ }
+
+ OverlayHelplineStriped::~OverlayHelplineStriped()
+ {
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlayline.cxx b/svx/source/sdr/overlay/overlayline.cxx
new file mode 100644
index 000000000000..19dbdd084630
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayline.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlayline.hxx>
+#include <tools/gen.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ drawinglayer::primitive2d::Primitive2DSequence OverlayLineStriped::createOverlayObjectPrimitive2DSequence()
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+
+ if(getOverlayManager())
+ {
+ const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
+ const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
+ const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel());
+ basegfx::B2DPolygon aLine;
+
+ aLine.append(getBasePosition());
+ aLine.append(getSecondPosition());
+
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::PolygonMarkerPrimitive2D(
+ aLine,
+ aRGBColorA,
+ aRGBColorB,
+ fStripeLengthPixel));
+
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+ }
+
+ return aRetval;
+ }
+
+ void OverlayLineStriped::stripeDefinitionHasChanged()
+ {
+ // react on OverlayManager's stripe definition change
+ objectChange();
+ }
+
+ OverlayLineStriped::OverlayLineStriped(
+ const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPos)
+ : OverlayObjectWithBasePosition(rBasePos, Color(COL_BLACK)),
+ maSecondPosition(rSecondPos)
+ {
+ }
+
+ OverlayLineStriped::~OverlayLineStriped()
+ {
+ }
+
+ void OverlayLineStriped::setSecondPosition(const basegfx::B2DPoint& rNew)
+ {
+ if(rNew != maSecondPosition)
+ {
+ // remember new value
+ maSecondPosition = rNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlaymanager.cxx b/svx/source/sdr/overlay/overlaymanager.cxx
new file mode 100644
index 000000000000..b71c55934e5b
--- /dev/null
+++ b/svx/source/sdr/overlay/overlaymanager.cxx
@@ -0,0 +1,396 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <tools/gen.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/window.hxx>
+#include <svx/sdr/overlay/overlayobject.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+#include <svx/sdr/contact/objectcontacttools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ void OverlayManager::ImpDrawMembers(const basegfx::B2DRange& rRange, OutputDevice& rDestinationDevice) const
+ {
+ const sal_uInt32 nSize(maOverlayObjects.size());
+
+ if(nSize)
+ {
+ const sal_uInt16 nOriginalAA(rDestinationDevice.GetAntialiasing());
+ const bool bIsAntiAliasing(getDrawinglayerOpt().IsAntiAliasing());
+
+ // create processor
+ drawinglayer::processor2d::BaseProcessor2D* pProcessor = ::sdr::contact::createBaseProcessor2DFromOutputDevice(
+ rDestinationDevice,
+ getCurrentViewInformation2D());
+
+ if(pProcessor)
+ {
+ for(OverlayObjectVector::const_iterator aIter(maOverlayObjects.begin()); aIter != maOverlayObjects.end(); aIter++)
+ {
+ OSL_ENSURE(*aIter, "Corrupted OverlayObject List (!)");
+ const OverlayObject& rCandidate = **aIter;
+
+ if(rCandidate.isVisible())
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence& rSequence = rCandidate.getOverlayObjectPrimitive2DSequence();
+
+ if(rSequence.hasElements())
+ {
+ if(rRange.overlaps(rCandidate.getBaseRange()))
+ {
+ if(bIsAntiAliasing && rCandidate.allowsAntiAliase())
+ {
+ rDestinationDevice.SetAntialiasing(nOriginalAA | ANTIALIASING_ENABLE_B2DDRAW);
+ }
+ else
+ {
+ rDestinationDevice.SetAntialiasing(nOriginalAA & ~ANTIALIASING_ENABLE_B2DDRAW);
+ }
+
+ pProcessor->process(rSequence);
+ }
+ }
+ }
+ }
+
+ delete pProcessor;
+ }
+
+ // restore AA settings
+ rDestinationDevice.SetAntialiasing(nOriginalAA);
+ }
+ }
+
+ void OverlayManager::ImpStripeDefinitionChanged()
+ {
+ const sal_uInt32 nSize(maOverlayObjects.size());
+
+ if(nSize)
+ {
+ for(OverlayObjectVector::iterator aIter(maOverlayObjects.begin()); aIter != maOverlayObjects.end(); aIter++)
+ {
+ OSL_ENSURE(*aIter, "Corrupted OverlayObject List (!)");
+ OverlayObject& rCandidate = **aIter;
+ rCandidate.stripeDefinitionHasChanged();
+ }
+ }
+ }
+
+ double OverlayManager::getDiscreteOne() const
+ {
+ if(basegfx::fTools::equalZero(mfDiscreteOne))
+ {
+ const basegfx::B2DVector aDiscreteInLogic(getOutputDevice().GetInverseViewTransformation() * basegfx::B2DVector(1.0, 0.0));
+ const_cast< OverlayManager* >(this)->mfDiscreteOne = aDiscreteInLogic.getLength();
+ }
+
+ return mfDiscreteOne;
+ }
+
+ OverlayManager::OverlayManager(
+ OutputDevice& rOutputDevice,
+ OverlayManager* pOldOverlayManager)
+ : Scheduler(),
+ rmOutputDevice(rOutputDevice),
+ maOverlayObjects(),
+ maStripeColorA(Color(COL_BLACK)),
+ maStripeColorB(Color(COL_WHITE)),
+ mnStripeLengthPixel(5),
+ maDrawinglayerOpt(),
+ maViewTransformation(),
+ maViewInformation2D(0),
+ mfDiscreteOne(0.0)
+ {
+ // set Property 'ReducedDisplayQuality' to true to allow simpler interaction
+ // visualisations
+ static bool bUseReducedDisplayQualityForDrag(true);
+
+ if(bUseReducedDisplayQualityForDrag)
+ {
+ uno::Sequence< beans::PropertyValue > xProperties(1);
+ xProperties[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedDisplayQuality"));
+ xProperties[0].Value <<= true;
+ maViewInformation2D = drawinglayer::geometry::ViewInformation2D(xProperties);
+ }
+
+ if(pOldOverlayManager)
+ {
+ // take over OverlayObjects from given OverlayManager. Copy
+ // the vector of pointers
+ maOverlayObjects = pOldOverlayManager->maOverlayObjects;
+ const sal_uInt32 nSize(maOverlayObjects.size());
+
+ if(nSize)
+ {
+ for(OverlayObjectVector::iterator aIter(maOverlayObjects.begin()); aIter != maOverlayObjects.end(); aIter++)
+ {
+ OSL_ENSURE(*aIter, "Corrupted OverlayObject List (!)");
+ OverlayObject& rCandidate = **aIter;
+
+ // remove from old and add to new OverlayManager
+ pOldOverlayManager->impApplyRemoveActions(rCandidate);
+ impApplyAddActions(rCandidate);
+ }
+
+ pOldOverlayManager->maOverlayObjects.clear();
+ }
+ }
+ }
+
+ const drawinglayer::geometry::ViewInformation2D OverlayManager::getCurrentViewInformation2D() const
+ {
+ if(getOutputDevice().GetViewTransformation() != maViewTransformation)
+ {
+ basegfx::B2DRange aViewRange(maViewInformation2D.getViewport());
+
+ if(OUTDEV_WINDOW == getOutputDevice().GetOutDevType())
+ {
+ const Size aOutputSizePixel(getOutputDevice().GetOutputSizePixel());
+ aViewRange = basegfx::B2DRange(0.0, 0.0, aOutputSizePixel.getWidth(), aOutputSizePixel.getHeight());
+ aViewRange.transform(getOutputDevice().GetInverseViewTransformation());
+ }
+
+ OverlayManager* pThis = const_cast< OverlayManager* >(this);
+
+ pThis->maViewTransformation = getOutputDevice().GetViewTransformation();
+ pThis->maViewInformation2D = drawinglayer::geometry::ViewInformation2D(
+ maViewInformation2D.getObjectTransformation(),
+ maViewTransformation,
+ aViewRange,
+ maViewInformation2D.getVisualizedPage(),
+ maViewInformation2D.getViewTime(),
+ maViewInformation2D.getExtendedInformationSequence());
+ pThis->mfDiscreteOne = 0.0;
+ }
+
+ return maViewInformation2D;
+ }
+
+ void OverlayManager::impApplyRemoveActions(OverlayObject& rTarget)
+ {
+ // handle evtl. animation
+ if(rTarget.allowsAnimation())
+ {
+ // remove from event chain
+ RemoveEvent(&rTarget);
+ }
+
+ // make invisible
+ invalidateRange(rTarget.getBaseRange());
+
+ // clear manager
+ rTarget.mpOverlayManager = 0;
+ }
+
+ void OverlayManager::impApplyAddActions(OverlayObject& rTarget)
+ {
+ // set manager
+ rTarget.mpOverlayManager = this;
+
+ // make visible
+ invalidateRange(rTarget.getBaseRange());
+
+ // handle evtl. animation
+ if(rTarget.allowsAnimation())
+ {
+ // Trigger at current time to get alive. This will do the
+ // object-specific next time calculation and hand over adding
+ // again to the scheduler to the animated object, too. This works for
+ // a paused or non-paused animator.
+ rTarget.Trigger(GetTime());
+ }
+ }
+
+ OverlayManager::~OverlayManager()
+ {
+ // The OverlayManager is not the owner of the OverlayObjects
+ // and thus will not delete them, but remove them. Profit here
+ // from knowing that all will be removed
+ const sal_uInt32 nSize(maOverlayObjects.size());
+
+ if(nSize)
+ {
+ for(OverlayObjectVector::iterator aIter(maOverlayObjects.begin()); aIter != maOverlayObjects.end(); aIter++)
+ {
+ OSL_ENSURE(*aIter, "Corrupted OverlayObject List (!)");
+ OverlayObject& rCandidate = **aIter;
+ impApplyRemoveActions(rCandidate);
+ }
+
+ // erase vector
+ maOverlayObjects.clear();
+ }
+ }
+
+ void OverlayManager::completeRedraw(const Region& rRegion, OutputDevice* pPreRenderDevice) const
+ {
+ if(!rRegion.IsEmpty() && maOverlayObjects.size())
+ {
+ // check for changed MapModes. That may influence the
+ // logical size of pixel based OverlayObjects (like BitmapHandles)
+ //ImpCheckMapModeChange();
+
+ // paint members
+ const Rectangle aRegionBoundRect(rRegion.GetBoundRect());
+ const basegfx::B2DRange aRegionRange(
+ aRegionBoundRect.Left(), aRegionBoundRect.Top(),
+ aRegionBoundRect.Right(), aRegionBoundRect.Bottom());
+
+ OutputDevice& rTarget = (pPreRenderDevice) ? *pPreRenderDevice : getOutputDevice();
+ ImpDrawMembers(aRegionRange, rTarget);
+ }
+ }
+
+ void OverlayManager::flush()
+ {
+ // default has nothing to do
+ }
+
+ // #i68597# part of content gets copied, react on it
+ void OverlayManager::copyArea(const Point& /*rDestPt*/, const Point& /*rSrcPt*/, const Size& /*rSrcSize*/)
+ {
+ // unbuffered versions do nothing here
+ }
+
+ void OverlayManager::restoreBackground(const Region& /*rRegion*/) const
+ {
+ // unbuffered versions do nothing here
+ }
+
+ void OverlayManager::add(OverlayObject& rOverlayObject)
+ {
+ OSL_ENSURE(0 == rOverlayObject.mpOverlayManager, "OverlayObject is added twice to an OverlayManager (!)");
+
+ // add to the end of chain to preserve display order in paint
+ maOverlayObjects.push_back(&rOverlayObject);
+
+ // execute add actions
+ impApplyAddActions(rOverlayObject);
+ }
+
+ void OverlayManager::remove(OverlayObject& rOverlayObject)
+ {
+ OSL_ENSURE(rOverlayObject.mpOverlayManager == this, "OverlayObject is removed from wrong OverlayManager (!)");
+
+ // execute remove actions
+ impApplyRemoveActions(rOverlayObject);
+
+ // remove from vector
+ const OverlayObjectVector::iterator aFindResult = ::std::find(maOverlayObjects.begin(), maOverlayObjects.end(), &rOverlayObject);
+ const bool bFound(aFindResult != maOverlayObjects.end());
+ OSL_ENSURE(bFound, "OverlayObject NOT found at OverlayManager (!)");
+
+ if(bFound)
+ {
+ maOverlayObjects.erase(aFindResult);
+ }
+ }
+
+ void OverlayManager::invalidateRange(const basegfx::B2DRange& rRange)
+ {
+ if(OUTDEV_WINDOW == getOutputDevice().GetOutDevType())
+ {
+ if(getDrawinglayerOpt().IsAntiAliasing())
+ {
+ // assume AA needs one pixel more and invalidate one pixel more
+ const double fDiscreteOne(getDiscreteOne());
+ const Rectangle aInvalidateRectangle(
+ (sal_Int32)floor(rRange.getMinX() - fDiscreteOne),
+ (sal_Int32)floor(rRange.getMinY() - fDiscreteOne),
+ (sal_Int32)ceil(rRange.getMaxX() + fDiscreteOne),
+ (sal_Int32)ceil(rRange.getMaxY() + fDiscreteOne));
+
+ // simply invalidate
+ ((Window&)getOutputDevice()).Invalidate(aInvalidateRectangle, INVALIDATE_NOERASE);
+ }
+ else
+ {
+ // #i77674# transform to rectangle. Use floor/ceil to get all covered
+ // discrete pixels, see #i75163# and OverlayManagerBuffered::invalidateRange
+ const Rectangle aInvalidateRectangle(
+ (sal_Int32)floor(rRange.getMinX()), (sal_Int32)floor(rRange.getMinY()),
+ (sal_Int32)ceil(rRange.getMaxX()), (sal_Int32)ceil(rRange.getMaxY()));
+
+ // simply invalidate
+ ((Window&)getOutputDevice()).Invalidate(aInvalidateRectangle, INVALIDATE_NOERASE);
+ }
+ }
+ }
+
+ // stripe support ColA
+ void OverlayManager::setStripeColorA(Color aNew)
+ {
+ if(aNew != maStripeColorA)
+ {
+ maStripeColorA = aNew;
+ ImpStripeDefinitionChanged();
+ }
+ }
+
+ // stripe support ColB
+ void OverlayManager::setStripeColorB(Color aNew)
+ {
+ if(aNew != maStripeColorB)
+ {
+ maStripeColorB = aNew;
+ ImpStripeDefinitionChanged();
+ }
+ }
+
+ // stripe support StripeLengthPixel
+ void OverlayManager::setStripeLengthPixel(sal_uInt32 nNew)
+ {
+ if(nNew != mnStripeLengthPixel)
+ {
+ mnStripeLengthPixel = nNew;
+ ImpStripeDefinitionChanged();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
new file mode 100644
index 000000000000..db5060789d5e
--- /dev/null
+++ b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
@@ -0,0 +1,541 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlaymanagerbuffered.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/window.hxx>
+#include <vcl/bitmap.hxx>
+#include <tools/stream.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <vcl/cursor.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ void OverlayManagerBuffered::ImpPrepareBufferDevice()
+ {
+ // compare size of maBufferDevice with size of visible area
+ if(maBufferDevice.GetOutputSizePixel() != getOutputDevice().GetOutputSizePixel())
+ {
+ // set new buffer size, copy as much content as possible (use bool parameter for vcl).
+ // Newly uncovered regions will be repainted.
+ maBufferDevice.SetOutputSizePixel(getOutputDevice().GetOutputSizePixel(), false);
+ }
+
+ // compare the MapModes for zoom/scroll changes
+ if(maBufferDevice.GetMapMode() != getOutputDevice().GetMapMode())
+ {
+ const bool bZoomed(
+ maBufferDevice.GetMapMode().GetScaleX() != getOutputDevice().GetMapMode().GetScaleX()
+ || maBufferDevice.GetMapMode().GetScaleY() != getOutputDevice().GetMapMode().GetScaleY());
+
+ if(!bZoomed)
+ {
+ const Point& rOriginOld = maBufferDevice.GetMapMode().GetOrigin();
+ const Point& rOriginNew = getOutputDevice().GetMapMode().GetOrigin();
+ const bool bScrolled(rOriginOld != rOriginNew);
+
+ if(bScrolled)
+ {
+ // get pixel bounds
+ const Point aOriginOldPixel(maBufferDevice.LogicToPixel(rOriginOld));
+ const Point aOriginNewPixel(maBufferDevice.LogicToPixel(rOriginNew));
+ const Size aOutputSizePixel(maBufferDevice.GetOutputSizePixel());
+
+ // remember and switch off MapMode
+ const bool bMapModeWasEnabled(maBufferDevice.IsMapModeEnabled());
+ maBufferDevice.EnableMapMode(false);
+
+ // scroll internally buffered stuff
+ const Point aDestinationOffsetPixel(aOriginNewPixel - aOriginOldPixel);
+ maBufferDevice.DrawOutDev(
+ aDestinationOffsetPixel, aOutputSizePixel, // destination
+ Point(), aOutputSizePixel); // source
+
+ // restore MapMode
+ maBufferDevice.EnableMapMode(bMapModeWasEnabled);
+
+ // scroll remembered region, too.
+ if(!maBufferRememberedRangePixel.isEmpty())
+ {
+ const basegfx::B2IPoint aIPointDestinationOffsetPixel(aDestinationOffsetPixel.X(), aDestinationOffsetPixel.Y());
+ const basegfx::B2IPoint aNewMinimum(maBufferRememberedRangePixel.getMinimum() + aIPointDestinationOffsetPixel);
+ const basegfx::B2IPoint aNewMaximum(maBufferRememberedRangePixel.getMaximum() + aIPointDestinationOffsetPixel);
+ maBufferRememberedRangePixel = basegfx::B2IRange(aNewMinimum, aNewMaximum);
+ }
+ }
+ }
+
+ // copy new MapMode
+ maBufferDevice.SetMapMode(getOutputDevice().GetMapMode());
+ }
+
+ // #i29186#
+ maBufferDevice.SetDrawMode(getOutputDevice().GetDrawMode());
+ maBufferDevice.SetSettings(getOutputDevice().GetSettings());
+ maBufferDevice.SetAntialiasing(getOutputDevice().GetAntialiasing());
+ }
+
+ void OverlayManagerBuffered::ImpRestoreBackground() const
+ {
+ const Rectangle aRegionRectanglePixel(
+ maBufferRememberedRangePixel.getMinX(), maBufferRememberedRangePixel.getMinY(),
+ maBufferRememberedRangePixel.getMaxX(), maBufferRememberedRangePixel.getMaxY());
+ const Region aRegionPixel(aRegionRectanglePixel);
+
+ ImpRestoreBackground(aRegionPixel);
+ }
+
+ void OverlayManagerBuffered::ImpRestoreBackground(const Region& rRegionPixel) const
+ {
+ // local region
+ Region aRegionPixel(rRegionPixel);
+ RegionHandle aRegionHandle(aRegionPixel.BeginEnumRects());
+ Rectangle aRegionRectanglePixel;
+
+ // MapModes off
+ const bool bMapModeWasEnabledDest(getOutputDevice().IsMapModeEnabled());
+ const bool bMapModeWasEnabledSource(maBufferDevice.IsMapModeEnabled());
+ getOutputDevice().EnableMapMode(false);
+ ((OverlayManagerBuffered*)this)->maBufferDevice.EnableMapMode(false);
+
+ while(aRegionPixel.GetEnumRects(aRegionHandle, aRegionRectanglePixel))
+ {
+#ifdef DBG_UTIL
+ // #i72754# possible graphical region test only with non-pro
+ static bool bDoPaintForVisualControl(false);
+ if(bDoPaintForVisualControl)
+ {
+ getOutputDevice().SetLineColor(COL_LIGHTGREEN);
+ getOutputDevice().SetFillColor();
+ getOutputDevice().DrawRect(aRegionRectanglePixel);
+ }
+#endif
+
+ // restore the area
+ const Point aTopLeft(aRegionRectanglePixel.TopLeft());
+ const Size aSize(aRegionRectanglePixel.GetSize());
+
+ getOutputDevice().DrawOutDev(
+ aTopLeft, aSize, // destination
+ aTopLeft, aSize, // source
+ maBufferDevice);
+ }
+
+ aRegionPixel.EndEnumRects(aRegionHandle);
+
+ // restore MapModes
+ getOutputDevice().EnableMapMode(bMapModeWasEnabledDest);
+ ((OverlayManagerBuffered*)this)->maBufferDevice.EnableMapMode(bMapModeWasEnabledSource);
+ }
+
+ void OverlayManagerBuffered::ImpSaveBackground(const Region& rRegion, OutputDevice* pPreRenderDevice)
+ {
+ // prepare source
+ OutputDevice& rSource = (pPreRenderDevice) ? *pPreRenderDevice : getOutputDevice();
+
+ // Ensure buffer is valid
+ ImpPrepareBufferDevice();
+
+ // build region which needs to be copied
+ Region aRegion(rSource.LogicToPixel(rRegion));
+
+ // limit to PaintRegion if it's a window. This will be evtl. the expanded one,
+ // but always the exact redraw area
+ if(OUTDEV_WINDOW == rSource.GetOutDevType())
+ {
+ Window& rWindow = (Window&)rSource;
+ Region aPaintRegionPixel = rWindow.LogicToPixel(rWindow.GetPaintRegion());
+ aRegion.Intersect(aPaintRegionPixel);
+
+ // #i72754# Make sure content is completetly rendered, the window
+ // will be used as source of a DrawOutDev soon
+ rWindow.Flush();
+ }
+
+ // also limit to buffer size
+ const Rectangle aBufferDeviceRectanglePixel = Rectangle(Point(), maBufferDevice.GetOutputSizePixel());
+ aRegion.Intersect(aBufferDeviceRectanglePixel);
+
+ // prepare to iterate over the rectangles from the region in pixels
+ RegionHandle aRegionHandle(aRegion.BeginEnumRects());
+ Rectangle aRegionRectanglePixel;
+
+ // MapModes off
+ const bool bMapModeWasEnabledDest(rSource.IsMapModeEnabled());
+ const bool bMapModeWasEnabledSource(maBufferDevice.IsMapModeEnabled());
+ rSource.EnableMapMode(false);
+ maBufferDevice.EnableMapMode(false);
+
+ while(aRegion.GetEnumRects(aRegionHandle, aRegionRectanglePixel))
+ {
+ // for each rectangle, save the area
+ Point aTopLeft(aRegionRectanglePixel.TopLeft());
+ Size aSize(aRegionRectanglePixel.GetSize());
+
+ maBufferDevice.DrawOutDev(
+ aTopLeft, aSize, // destination
+ aTopLeft, aSize, // source
+ rSource);
+
+#ifdef DBG_UTIL
+ // #i72754# possible graphical region test only with non-pro
+ static bool bDoPaintForVisualControl(false);
+ if(bDoPaintForVisualControl)
+ {
+ const bool bMapModeWasEnabledTest(getOutputDevice().IsMapModeEnabled());
+ getOutputDevice().EnableMapMode(false);
+ getOutputDevice().SetLineColor(COL_LIGHTRED);
+ getOutputDevice().SetFillColor();
+ getOutputDevice().DrawRect(aRegionRectanglePixel);
+ getOutputDevice().EnableMapMode(bMapModeWasEnabledTest);
+ }
+
+ static bool bDoSaveForVisualControl(false);
+ if(bDoSaveForVisualControl)
+ {
+ const Bitmap aBitmap(maBufferDevice.GetBitmap(aTopLeft, aSize));
+ SvFileStream aNew((const String&)String(ByteString( "c:\\test.bmp" ), RTL_TEXTENCODING_UTF8), STREAM_WRITE|STREAM_TRUNC);
+ aNew << aBitmap;
+ }
+#endif
+ }
+
+ aRegion.EndEnumRects(aRegionHandle);
+
+ // restore MapModes
+ rSource.EnableMapMode(bMapModeWasEnabledDest);
+ maBufferDevice.EnableMapMode(bMapModeWasEnabledSource);
+ }
+
+ IMPL_LINK(OverlayManagerBuffered, ImpBufferTimerHandler, AutoTimer*, /*pTimer*/)
+ {
+ // stop timer
+ maBufferTimer.Stop();
+
+ if(!maBufferRememberedRangePixel.isEmpty())
+ {
+ // logic size for impDrawMember call
+ basegfx::B2DRange aBufferRememberedRangeLogic(
+ maBufferRememberedRangePixel.getMinX(), maBufferRememberedRangePixel.getMinY(),
+ maBufferRememberedRangePixel.getMaxX(), maBufferRememberedRangePixel.getMaxY());
+ aBufferRememberedRangeLogic.transform(getOutputDevice().GetInverseViewTransformation());
+
+ // prepare cursor handling
+ const bool bTargetIsWindow(OUTDEV_WINDOW == rmOutputDevice.GetOutDevType());
+ bool bCursorWasEnabled(false);
+
+ // #i80730# switch off VCL cursor during overlay refresh
+ if(bTargetIsWindow)
+ {
+ Window& rWindow = static_cast< Window& >(rmOutputDevice);
+ Cursor* pCursor = rWindow.GetCursor();
+
+ if(pCursor && pCursor->IsVisible())
+ {
+ pCursor->Hide();
+ bCursorWasEnabled = true;
+ }
+ }
+
+ if(DoRefreshWithPreRendering())
+ {
+ // #i73602# ensure valid and sized maOutputBufferDevice
+ const Size aDestinationSizePixel(maBufferDevice.GetOutputSizePixel());
+ const Size aOutputBufferSizePixel(maOutputBufferDevice.GetOutputSizePixel());
+
+ if(aDestinationSizePixel != aOutputBufferSizePixel)
+ {
+ maOutputBufferDevice.SetOutputSizePixel(aDestinationSizePixel);
+ }
+
+ maOutputBufferDevice.SetMapMode(getOutputDevice().GetMapMode());
+ maOutputBufferDevice.EnableMapMode(false);
+ maOutputBufferDevice.SetDrawMode(maBufferDevice.GetDrawMode());
+ maOutputBufferDevice.SetSettings(maBufferDevice.GetSettings());
+ maOutputBufferDevice.SetAntialiasing(maBufferDevice.GetAntialiasing());
+
+ // calculate sizes
+ Rectangle aRegionRectanglePixel(
+ maBufferRememberedRangePixel.getMinX(), maBufferRememberedRangePixel.getMinY(),
+ maBufferRememberedRangePixel.getMaxX(), maBufferRememberedRangePixel.getMaxY());
+
+ // truncate aRegionRectanglePixel to destination pixel size, more does
+ // not need to be prepared since destination is a buffer for a window. So,
+ // maximum size indirectly shall be limited to getOutputDevice().GetOutputSizePixel()
+ if(aRegionRectanglePixel.Left() < 0L)
+ {
+ aRegionRectanglePixel.Left() = 0L;
+ }
+
+ if(aRegionRectanglePixel.Top() < 0L)
+ {
+ aRegionRectanglePixel.Top() = 0L;
+ }
+
+ if(aRegionRectanglePixel.Right() > aDestinationSizePixel.getWidth())
+ {
+ aRegionRectanglePixel.Right() = aDestinationSizePixel.getWidth();
+ }
+
+ if(aRegionRectanglePixel.Bottom() > aDestinationSizePixel.getHeight())
+ {
+ aRegionRectanglePixel.Bottom() = aDestinationSizePixel.getHeight();
+ }
+
+ // get sizes
+ const Point aTopLeft(aRegionRectanglePixel.TopLeft());
+ const Size aSize(aRegionRectanglePixel.GetSize());
+
+ {
+ const bool bMapModeWasEnabledDest(maBufferDevice.IsMapModeEnabled());
+ maBufferDevice.EnableMapMode(false);
+
+ maOutputBufferDevice.DrawOutDev(
+ aTopLeft, aSize, // destination
+ aTopLeft, aSize, // source
+ maBufferDevice);
+
+ // restore MapModes
+ maBufferDevice.EnableMapMode(bMapModeWasEnabledDest);
+ }
+
+ // paint overlay content for remembered region, use
+ // method from base class directly
+ maOutputBufferDevice.EnableMapMode(true);
+ OverlayManager::ImpDrawMembers(aBufferRememberedRangeLogic, maOutputBufferDevice);
+ maOutputBufferDevice.EnableMapMode(false);
+
+ // copy to output
+ {
+ const bool bMapModeWasEnabledDest(getOutputDevice().IsMapModeEnabled());
+ getOutputDevice().EnableMapMode(false);
+
+ getOutputDevice().DrawOutDev(
+ aTopLeft, aSize, // destination
+ aTopLeft, aSize, // source
+ maOutputBufferDevice);
+
+ // debug
+ /*getOutputDevice().SetLineColor(COL_RED);
+ getOutputDevice().SetFillColor();
+ getOutputDevice().DrawRect(Rectangle(aTopLeft, aSize));*/
+
+ // restore MapModes
+ getOutputDevice().EnableMapMode(bMapModeWasEnabledDest);
+ }
+ }
+ else
+ {
+ // Restore all rectangles for remembered region from buffer
+ ImpRestoreBackground();
+
+ // paint overlay content for remembered region, use
+ // method from base class directly
+ OverlayManager::ImpDrawMembers(aBufferRememberedRangeLogic, getOutputDevice());
+ }
+
+ // VCL hack for transparent child windows
+ // Problem is e.g. a radiobuttion form control in life mode. The used window
+ // is a transparence vcl childwindow. This flag only allows the parent window to
+ // paint into the child windows area, but there is no mechanism which takes
+ // care for a repaint of the child window. A transparent child window is NOT
+ // a window which always keeps it's content consistent over the parent, but it's
+ // more like just a paint flag for the parent.
+ // To get the update, the windows in question are updated manulally here.
+ if(bTargetIsWindow)
+ {
+ Window& rWindow = static_cast< Window& >(rmOutputDevice);
+
+ if(rWindow.IsChildTransparentModeEnabled() && rWindow.GetChildCount())
+ {
+ const Rectangle aRegionRectanglePixel(
+ maBufferRememberedRangePixel.getMinX(), maBufferRememberedRangePixel.getMinY(),
+ maBufferRememberedRangePixel.getMaxX(), maBufferRememberedRangePixel.getMaxY());
+
+ for(sal_uInt16 a(0); a < rWindow.GetChildCount(); a++)
+ {
+ Window* pCandidate = rWindow.GetChild(a);
+
+ if(pCandidate && pCandidate->IsPaintTransparent())
+ {
+ const Rectangle aCandidatePosSizePixel(pCandidate->GetPosPixel(), pCandidate->GetSizePixel());
+
+ if(aCandidatePosSizePixel.IsOver(aRegionRectanglePixel))
+ {
+ pCandidate->Invalidate(INVALIDATE_NOTRANSPARENT|INVALIDATE_CHILDREN);
+ pCandidate->Update();
+ }
+ }
+ }
+ }
+ }
+
+ // #i80730# restore visibility of VCL cursor
+ if(bCursorWasEnabled)
+ {
+ Window& rWindow = static_cast< Window& >(rmOutputDevice);
+ Cursor* pCursor = rWindow.GetCursor();
+
+ if(pCursor)
+ {
+ // check if cursor still exists. It may have been deleted from someone
+ pCursor->Show();
+ }
+ }
+
+ // forget remembered Region
+ maBufferRememberedRangePixel.reset();
+ }
+
+ return 0;
+ }
+
+ OverlayManagerBuffered::OverlayManagerBuffered(
+ OutputDevice& rOutputDevice,
+ OverlayManager* pOldOverlayManager,
+ bool bRefreshWithPreRendering)
+ : OverlayManager(rOutputDevice, pOldOverlayManager),
+ mbRefreshWithPreRendering(bRefreshWithPreRendering)
+ {
+ // Init timer
+ maBufferTimer.SetTimeout(1);
+ maBufferTimer.SetTimeoutHdl(LINK(this, OverlayManagerBuffered, ImpBufferTimerHandler));
+ }
+
+ OverlayManagerBuffered::~OverlayManagerBuffered()
+ {
+ // Clear timer
+ maBufferTimer.Stop();
+
+ if(!maBufferRememberedRangePixel.isEmpty())
+ {
+ // Restore all rectangles for remembered region from buffer
+ ImpRestoreBackground();
+ }
+ }
+
+ void OverlayManagerBuffered::completeRedraw(const Region& rRegion, OutputDevice* pPreRenderDevice) const
+ {
+ if(!rRegion.IsEmpty())
+ {
+ // save new background
+ ((OverlayManagerBuffered*)this)->ImpSaveBackground(rRegion, pPreRenderDevice);
+ }
+
+ // call parent
+ OverlayManager::completeRedraw(rRegion, pPreRenderDevice);
+ }
+
+ void OverlayManagerBuffered::flush()
+ {
+ // call timer handler direct
+ ImpBufferTimerHandler(0);
+ }
+
+ // #i68597# part of content gets copied, react on it
+ void OverlayManagerBuffered::copyArea(const Point& rDestPt, const Point& rSrcPt, const Size& rSrcSize)
+ {
+ // scroll local buffered area
+ maBufferDevice.CopyArea(rDestPt, rSrcPt, rSrcSize);
+ }
+
+ void OverlayManagerBuffered::restoreBackground(const Region& rRegion) const
+ {
+ // restore
+ const Region aRegionPixel(getOutputDevice().LogicToPixel(rRegion));
+ ImpRestoreBackground(aRegionPixel);
+
+ // call parent
+ OverlayManager::restoreBackground(rRegion);
+ }
+
+ void OverlayManagerBuffered::invalidateRange(const basegfx::B2DRange& rRange)
+ {
+ if(!rRange.isEmpty())
+ {
+ // buffered output, do not invalidate but use the timer
+ // to trigger a timer event for refresh
+ maBufferTimer.Start();
+
+ // add the discrete range to the remembered region
+ // #i75163# use double precision and floor/ceil rounding to get overlapped pixel region, even
+ // when the given logic region has a width/height of 0.0. This does NOT work with LogicToPixel
+ // since it just transforms the top left and bottom right points equally without taking
+ // discrete pixel coverage into account. An empty B2DRange and thus empty logic Rectangle translated
+ // to an also empty discrete pixel rectangle - what is wrong.
+ basegfx::B2DRange aDiscreteRange(rRange);
+ aDiscreteRange.transform(getOutputDevice().GetViewTransformation());
+
+ if(maDrawinglayerOpt.IsAntiAliasing())
+ {
+ // assume AA needs one pixel more and invalidate one pixel more
+ const double fDiscreteOne(getDiscreteOne());
+ const basegfx::B2IPoint aTopLeft(
+ (sal_Int32)floor(aDiscreteRange.getMinX() - fDiscreteOne),
+ (sal_Int32)floor(aDiscreteRange.getMinY() - fDiscreteOne));
+ const basegfx::B2IPoint aBottomRight(
+ (sal_Int32)ceil(aDiscreteRange.getMaxX() + fDiscreteOne),
+ (sal_Int32)ceil(aDiscreteRange.getMaxY() + fDiscreteOne));
+
+ maBufferRememberedRangePixel.expand(aTopLeft);
+ maBufferRememberedRangePixel.expand(aBottomRight);
+ }
+ else
+ {
+ const basegfx::B2IPoint aTopLeft((sal_Int32)floor(aDiscreteRange.getMinX()), (sal_Int32)floor(aDiscreteRange.getMinY()));
+ const basegfx::B2IPoint aBottomRight((sal_Int32)ceil(aDiscreteRange.getMaxX()), (sal_Int32)ceil(aDiscreteRange.getMaxY()));
+
+ maBufferRememberedRangePixel.expand(aTopLeft);
+ maBufferRememberedRangePixel.expand(aBottomRight);
+ }
+ }
+ }
+
+ void OverlayManagerBuffered::SetRefreshWithPreRendering(bool bNew)
+ {
+ if((bool)mbRefreshWithPreRendering != bNew)
+ {
+ mbRefreshWithPreRendering = bNew;
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlayobject.cxx b/svx/source/sdr/overlay/overlayobject.cxx
new file mode 100644
index 000000000000..32584c264886
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayobject.cxx
@@ -0,0 +1,219 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlayobject.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <tools/debug.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/salbtype.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <svx/sdr/contact/objectcontacttools.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ void OverlayObject::objectChange()
+ {
+ const basegfx::B2DRange aPreviousRange(maBaseRange);
+ maBaseRange.reset();
+ setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DSequence());
+
+ if(getOverlayManager() && !aPreviousRange.isEmpty())
+ {
+ getOverlayManager()->invalidateRange(aPreviousRange);
+ }
+
+ const basegfx::B2DRange& rCurrentRange = getBaseRange();
+
+ if(getOverlayManager() && rCurrentRange != aPreviousRange && !rCurrentRange.isEmpty())
+ {
+ getOverlayManager()->invalidateRange(rCurrentRange);
+ }
+ }
+
+ // OverlayObject implementations.
+ drawinglayer::primitive2d::Primitive2DSequence OverlayObject::createOverlayObjectPrimitive2DSequence()
+ {
+ // Default implementation has to assert a missing implementation. It cannot
+ // be useful to have overlay object derivations which have no visualisation
+ // at all
+ OSL_ENSURE(false, "OverlayObject derivation without visualisation definition (missing createOverlayObjectPrimitive2DSequence implementation) (!)");
+ return drawinglayer::primitive2d::Primitive2DSequence();
+ }
+
+ void OverlayObject::allowAntiAliase(bool bNew)
+ {
+ if(bNew != (bool)mbAllowsAntiAliase)
+ {
+ // remember new value
+ mbAllowsAntiAliase = bNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ OverlayObject::OverlayObject(Color aBaseColor)
+ : Event(0),
+ mpOverlayManager(0),
+ maBaseColor(aBaseColor),
+ mbIsVisible(true),
+ mbIsHittable(true),
+ mbAllowsAnimation(false),
+ mbAllowsAntiAliase(true)
+ {
+ }
+
+ OverlayObject::~OverlayObject()
+ {
+ OSL_ENSURE(0 == getOverlayManager(), "OverlayObject is destructed which is still registered at OverlayManager (!)");
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence OverlayObject::getOverlayObjectPrimitive2DSequence() const
+ {
+ if(!getPrimitive2DSequence().hasElements())
+ {
+ // no existing sequence; create one
+ const_cast< OverlayObject* >(this)->setPrimitive2DSequence(
+ const_cast< OverlayObject* >(this)->createOverlayObjectPrimitive2DSequence());
+ }
+
+ return getPrimitive2DSequence();
+ }
+
+ const basegfx::B2DRange& OverlayObject::getBaseRange() const
+ {
+ if(getOverlayManager() && maBaseRange.isEmpty())
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence& rSequence = getOverlayObjectPrimitive2DSequence();
+
+ if(rSequence.hasElements())
+ {
+ const drawinglayer::geometry::ViewInformation2D aViewInformation2D(getOverlayManager()->getCurrentViewInformation2D());
+
+ const_cast< sdr::overlay::OverlayObject* >(this)->maBaseRange =
+ drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(rSequence, aViewInformation2D);
+ }
+ }
+
+ return maBaseRange;
+ }
+
+ void OverlayObject::setVisible(bool bNew)
+ {
+ if(bNew != (bool)mbIsVisible)
+ {
+ // remember new value
+ mbIsVisible = bNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayObject::setHittable(bool bNew)
+ {
+ if(bNew != (bool)mbIsHittable)
+ {
+ // remember new value
+ mbIsHittable = bNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayObject::setBaseColor(Color aNew)
+ {
+ if(aNew != maBaseColor)
+ {
+ // remember new value
+ maBaseColor = aNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayObject::Trigger(sal_uInt32 /*nTime*/)
+ {
+ // default does not register again
+ }
+
+ void OverlayObject::stripeDefinitionHasChanged()
+ {
+ // default does not need to do anything
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ OverlayObjectWithBasePosition::OverlayObjectWithBasePosition(const basegfx::B2DPoint& rBasePos, Color aBaseColor)
+ : OverlayObject(aBaseColor),
+ maBasePosition(rBasePos)
+ {
+ }
+
+ OverlayObjectWithBasePosition::~OverlayObjectWithBasePosition()
+ {
+ }
+
+ void OverlayObjectWithBasePosition::setBasePosition(const basegfx::B2DPoint& rNew)
+ {
+ if(rNew != maBasePosition)
+ {
+ // remember new value
+ maBasePosition = rNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlayobjectcell.cxx b/svx/source/sdr/overlay/overlayobjectcell.cxx
new file mode 100644
index 000000000000..79eabbcf0afa
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayobjectcell.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <basegfx/numeric/ftools.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/hatch.hxx>
+#include <svx/sdr/overlay/overlayobjectcell.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
+#include <drawinglayer/primitive2d/invertprimitive2d.hxx>
+
+using namespace ::basegfx;
+
+// #114409#
+namespace sdr
+{
+ namespace overlay
+ {
+ OverlayObjectCell::OverlayObjectCell( CellOverlayType eType, const Color& rColor, const RangeVector& rRects )
+ : OverlayObject( rColor ),
+ mePaintType( eType ),
+ maRectangles( rRects )
+ {
+ // no AA for selection overlays
+ allowAntiAliase(false);
+ }
+
+ OverlayObjectCell::~OverlayObjectCell()
+ {
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence OverlayObjectCell::createOverlayObjectPrimitive2DSequence()
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+ const sal_uInt32 nCount(maRectangles.size());
+
+ if(nCount)
+ {
+ const basegfx::BColor aRGBColor(getBaseColor().getBColor());
+ aRetval.realloc(nCount);
+
+ // create primitives for all ranges
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ const basegfx::B2DRange& rRange(maRectangles[a]);
+ const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(rRange));
+
+ aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ basegfx::B2DPolyPolygon(aPolygon),
+ aRGBColor));
+ }
+
+
+ if(mePaintType == CELL_OVERLAY_TRANSPARENT)
+ {
+ // embed in 50% transparent paint
+ const drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparence(
+ new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
+ aRetval,
+ 0.5));
+
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedTransparence, 1);
+ }
+ else // CELL_OVERLAY_INVERT
+ {
+ // embed in invert primitive
+ const drawinglayer::primitive2d::Primitive2DReference aInvert(
+ new drawinglayer::primitive2d::InvertPrimitive2D(
+ aRetval));
+
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aInvert, 1);
+ }
+ }
+
+ return aRetval;
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlayobjectlist.cxx b/svx/source/sdr/overlay/overlayobjectlist.cxx
new file mode 100644
index 000000000000..f6834726553d
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayobjectlist.cxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlayobjectlist.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <tools/debug.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+
+// for SOLARIS compiler include of algorithm part of _STL is necesary to
+// get access to basic algos like ::std::find
+#include <algorithm>
+
+#include <drawinglayer/processor2d/hittestprocessor2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ OverlayObjectList::~OverlayObjectList()
+ {
+ clear();
+ }
+
+ void OverlayObjectList::clear()
+ {
+ OverlayObjectVector::iterator aStart(maVector.begin());
+
+ for(; aStart != maVector.end(); aStart++)
+ {
+ ::sdr::overlay::OverlayObject* pCandidate = *aStart;
+
+ if(pCandidate->getOverlayManager())
+ {
+ pCandidate->getOverlayManager()->remove(*pCandidate);
+ }
+
+ delete pCandidate;
+ }
+
+ maVector.clear();
+ }
+
+ void OverlayObjectList::remove(OverlayObject& rOverlayObject)
+ {
+ const OverlayObjectVector::iterator aFindResult = ::std::find(maVector.begin(), maVector.end(), &rOverlayObject);
+ const bool bFound(aFindResult != maVector.end());
+ OSL_ENSURE(bFound, "Could not find given object in list (!)");
+
+ if(bFound)
+ {
+ maVector.erase(aFindResult);
+ }
+ }
+
+ bool OverlayObjectList::isHitLogic(const basegfx::B2DPoint& rLogicPosition, double fLogicTolerance) const
+ {
+ if(maVector.size())
+ {
+ OverlayObjectVector::const_iterator aStart(maVector.begin());
+ sdr::overlay::OverlayObject* pFirst = *aStart;
+ OSL_ENSURE(pFirst, "Corrupt OverlayObjectList (!)");
+ OverlayManager* pManager = pFirst->getOverlayManager();
+
+ if(pManager)
+ {
+ if(0.0 == fLogicTolerance)
+ {
+ const Size aSizeLogic(pManager->getOutputDevice().PixelToLogic(
+ Size(DEFAULT_VALUE_FOR_HITTEST_PIXEL, DEFAULT_VALUE_FOR_HITTEST_PIXEL)));
+ fLogicTolerance = aSizeLogic.Width();
+ }
+
+ const drawinglayer::geometry::ViewInformation2D aViewInformation2D(pManager->getCurrentViewInformation2D());
+ drawinglayer::processor2d::HitTestProcessor2D aHitTestProcessor2D(
+ aViewInformation2D,
+ rLogicPosition,
+ fLogicTolerance,
+ false);
+
+ for(; aStart != maVector.end(); aStart++)
+ {
+ sdr::overlay::OverlayObject* pCandidate = *aStart;
+ OSL_ENSURE(pCandidate, "Corrupt OverlayObjectList (!)");
+
+ if(pCandidate->isHittable())
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence& rSequence = pCandidate->getOverlayObjectPrimitive2DSequence();
+
+ if(rSequence.hasElements())
+ {
+ aHitTestProcessor2D.process(rSequence);
+
+ if(aHitTestProcessor2D.getHit())
+ {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ bool OverlayObjectList::isHitPixel(const Point& rDiscretePosition, sal_uInt32 nDiscreteTolerance) const
+ {
+ if(maVector.size())
+ {
+ OverlayObjectVector::const_iterator aStart(maVector.begin());
+ sdr::overlay::OverlayObject* pCandidate = *aStart;
+ OverlayManager* pManager = pCandidate->getOverlayManager();
+
+ if(pManager)
+ {
+ const Point aPosLogic(pManager->getOutputDevice().PixelToLogic(rDiscretePosition));
+ const basegfx::B2DPoint aPosition(aPosLogic.X(), aPosLogic.Y());
+
+ if(nDiscreteTolerance)
+ {
+ const Size aSizeLogic(pManager->getOutputDevice().PixelToLogic(Size(nDiscreteTolerance, nDiscreteTolerance)));
+ return isHitLogic(aPosition, (double)aSizeLogic.Width());
+ }
+ else
+ {
+ return isHitLogic(aPosition);
+ }
+ }
+ }
+
+ return false;
+ }
+
+ basegfx::B2DRange OverlayObjectList::getBaseRange() const
+ {
+ basegfx::B2DRange aRetval;
+
+ if(maVector.size())
+ {
+ OverlayObjectVector::const_iterator aStart(maVector.begin());
+
+ for(; aStart != maVector.end(); aStart++)
+ {
+ ::sdr::overlay::OverlayObject* pCandidate = *aStart;
+ aRetval.expand(pCandidate->getBaseRange());
+ }
+ }
+
+ return aRetval;
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlaypolypolygon.cxx b/svx/source/sdr/overlay/overlaypolypolygon.cxx
new file mode 100644
index 000000000000..8de6b9f1c667
--- /dev/null
+++ b/svx/source/sdr/overlay/overlaypolypolygon.cxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlaypolypolygon.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ drawinglayer::primitive2d::Primitive2DSequence OverlayPolyPolygonStriped::createOverlayObjectPrimitive2DSequence()
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+
+ if(getOverlayManager())
+ {
+ const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
+ const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
+ const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel());
+
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D(
+ getPolyPolygon(),
+ aRGBColorA,
+ aRGBColorB,
+ fStripeLengthPixel));
+
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+ }
+
+ return aRetval;
+ }
+
+ void OverlayPolyPolygonStriped::stripeDefinitionHasChanged()
+ {
+ // react on OverlayManager's stripe definition change
+ objectChange();
+ }
+
+ OverlayPolyPolygonStriped::OverlayPolyPolygonStriped(
+ const basegfx::B2DPolyPolygon& rPolyPolygon)
+ : OverlayObject(Color(COL_BLACK)),
+ maPolyPolygon(rPolyPolygon)
+ {
+ }
+
+ OverlayPolyPolygonStriped::~OverlayPolyPolygonStriped()
+ {
+ }
+
+ void OverlayPolyPolygonStriped::setPolyPolygon(const basegfx::B2DPolyPolygon& rNew)
+ {
+ if(rNew != maPolyPolygon)
+ {
+ // remember new value
+ maPolyPolygon = rNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlayprimitive2dsequenceobject.cxx b/svx/source/sdr/overlay/overlayprimitive2dsequenceobject.cxx
new file mode 100644
index 000000000000..b81e46a0a67d
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayprimitive2dsequenceobject.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <drawinglayer/processor2d/vclpixelprocessor2d.hxx>
+#include <svx/sdr/contact/objectcontacttools.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ drawinglayer::primitive2d::Primitive2DSequence OverlayPrimitive2DSequenceObject::createOverlayObjectPrimitive2DSequence()
+ {
+ return getSequence();
+ }
+
+ OverlayPrimitive2DSequenceObject::OverlayPrimitive2DSequenceObject(const drawinglayer::primitive2d::Primitive2DSequence& rSequence)
+ : OverlayObjectWithBasePosition(basegfx::B2DPoint(), Color(COL_BLACK)),
+ maSequence(rSequence)
+ {
+ }
+
+ OverlayPrimitive2DSequenceObject::~OverlayPrimitive2DSequenceObject()
+ {
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlayrollingrectangle.cxx b/svx/source/sdr/overlay/overlayrollingrectangle.cxx
new file mode 100644
index 000000000000..d13171d5d896
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayrollingrectangle.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlayrollingrectangle.hxx>
+#include <tools/gen.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/overlay/overlaytools.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ drawinglayer::primitive2d::Primitive2DSequence OverlayRollingRectangleStriped::createOverlayObjectPrimitive2DSequence()
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+
+ if(getOverlayManager() && (getShowBounds() || getExtendedLines()))
+ {
+ const basegfx::BColor aRGBColorA(getOverlayManager()->getStripeColorA().getBColor());
+ const basegfx::BColor aRGBColorB(getOverlayManager()->getStripeColorB().getBColor());
+ const double fStripeLengthPixel(getOverlayManager()->getStripeLengthPixel());
+ const basegfx::B2DRange aRollingRectangle(getBasePosition(), getSecondPosition());
+
+ if(getShowBounds())
+ {
+ // view-independent part, create directly
+ const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(aRollingRectangle));
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::PolygonMarkerPrimitive2D(
+ aPolygon,
+ aRGBColorA,
+ aRGBColorB,
+ fStripeLengthPixel));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aReference);
+ }
+
+ if(getExtendedLines())
+ {
+ // view-dependent part, use helper primitive
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::OverlayRollingRectanglePrimitive(
+ aRollingRectangle,
+ aRGBColorA,
+ aRGBColorB,
+ fStripeLengthPixel));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aReference);
+ }
+ }
+
+ return aRetval;
+ }
+
+ void OverlayRollingRectangleStriped::stripeDefinitionHasChanged()
+ {
+ // react on OverlayManager's stripe definition change
+ objectChange();
+ }
+
+ OverlayRollingRectangleStriped::OverlayRollingRectangleStriped(
+ const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPos,
+ bool bExtendedLines,
+ bool bShowBounds)
+ : OverlayObjectWithBasePosition(rBasePos, Color(COL_BLACK)),
+ maSecondPosition(rSecondPos),
+ mbExtendedLines(bExtendedLines),
+ mbShowBounds(bShowBounds)
+ {
+ }
+
+ OverlayRollingRectangleStriped::~OverlayRollingRectangleStriped()
+ {
+ }
+
+ void OverlayRollingRectangleStriped::setSecondPosition(const basegfx::B2DPoint& rNew)
+ {
+ if(rNew != maSecondPosition)
+ {
+ // remember new value
+ maSecondPosition = rNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayRollingRectangleStriped::setExtendedLines(bool bNew)
+ {
+ if(bNew != (bool)mbExtendedLines)
+ {
+ // remember new value
+ mbExtendedLines = bNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayRollingRectangleStriped::setShowBounds(bool bNew)
+ {
+ if(bNew != (bool)mbShowBounds)
+ {
+ // remember new value
+ mbShowBounds = bNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlayselection.cxx b/svx/source/sdr/overlay/overlayselection.cxx
new file mode 100644
index 000000000000..45ff1d0960de
--- /dev/null
+++ b/svx/source/sdr/overlay/overlayselection.cxx
@@ -0,0 +1,240 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlayselection.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <svtools/optionsdrawinglayer.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/outdev.hxx>
+#include <drawinglayer/primitive2d/invertprimitive2d.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ // combine rages geometrically to a single, ORed polygon
+ basegfx::B2DPolyPolygon impCombineRangesToPolyPolygon(const std::vector< basegfx::B2DRange >& rRanges)
+ {
+ const sal_uInt32 nCount(rRanges.size());
+ basegfx::B2DPolyPolygon aRetval;
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ const basegfx::B2DPolygon aDiscretePolygon(basegfx::tools::createPolygonFromRect(rRanges[a]));
+
+ if(0 == a)
+ {
+ aRetval.append(aDiscretePolygon);
+ }
+ else
+ {
+ aRetval = basegfx::tools::solvePolygonOperationOr(aRetval, basegfx::B2DPolyPolygon(aDiscretePolygon));
+ }
+ }
+
+ return aRetval;
+ }
+
+ // check if wanted type OVERLAY_TRANSPARENT or OVERLAY_SOLID
+ // is possible. If not, fallback to invert mode (classic mode)
+ OverlayType impCheckPossibleOverlayType(OverlayType aOverlayType)
+ {
+ if(OVERLAY_INVERT != aOverlayType)
+ {
+ const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+
+ if(!aSvtOptionsDrawinglayer.IsTransparentSelection())
+ {
+ // not possible when switched off by user
+ return OVERLAY_INVERT;
+ }
+ else
+ {
+ const OutputDevice *pOut = Application::GetDefaultDevice();
+
+ if(pOut->GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ // not possible when in high contrast mode
+ return OVERLAY_INVERT;
+ }
+
+ if(!pOut->supportsOperation(OutDevSupport_TransparentRect))
+ {
+ // not possible when no fast transparence paint is supported on the system
+ return OVERLAY_INVERT;
+ }
+ }
+ }
+
+ return aOverlayType;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence OverlaySelection::createOverlayObjectPrimitive2DSequence()
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+ const sal_uInt32 nCount(getRanges().size());
+
+ if(nCount)
+ {
+ // create range primitives
+ const bool bInvert(OVERLAY_INVERT == maLastOverlayType);
+ basegfx::BColor aRGBColor(getBaseColor().getBColor());
+ aRetval.realloc(nCount);
+
+ if(bInvert)
+ {
+ // force color to white for invert to get a full invert
+ aRGBColor = basegfx::BColor(1.0, 1.0, 1.0);
+ }
+
+ for(sal_uInt32 a(0);a < nCount; a++)
+ {
+ const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(maRanges[a]));
+ aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ basegfx::B2DPolyPolygon(aPolygon),
+ aRGBColor));
+ }
+
+ if(bInvert)
+ {
+ // embed all in invert primitive
+ const drawinglayer::primitive2d::Primitive2DReference aInvert(
+ new drawinglayer::primitive2d::InvertPrimitive2D(
+ aRetval));
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aInvert, 1);
+ }
+ else if(OVERLAY_TRANSPARENT == maLastOverlayType)
+ {
+ // embed all rectangles in transparent paint
+ const double fTransparence(mnLastTransparence / 100.0);
+ const drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparence(
+ new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
+ aRetval,
+ fTransparence));
+
+ if(getBorder())
+ {
+ const basegfx::B2DPolyPolygon aPolyPolygon(impCombineRangesToPolyPolygon(getRanges()));
+ const drawinglayer::primitive2d::Primitive2DReference aSelectionOutline(
+ new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D(
+ aPolyPolygon,
+ aRGBColor));
+
+ // add both to result
+ aRetval.realloc(2);
+ aRetval[0] = aUnifiedTransparence;
+ aRetval[1] = aSelectionOutline;
+ }
+ else
+ {
+ // just add transparent part
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedTransparence, 1);
+ }
+ }
+ }
+
+ return aRetval;
+ }
+
+ OverlaySelection::OverlaySelection(
+ OverlayType eType,
+ const Color& rColor,
+ const std::vector< basegfx::B2DRange >& rRanges,
+ bool bBorder)
+ : OverlayObject(rColor),
+ meOverlayType(eType),
+ maRanges(rRanges),
+ maLastOverlayType(eType),
+ mnLastTransparence(0),
+ mbBorder(bBorder)
+ {
+ // no AA for selection overlays
+ allowAntiAliase(false);
+ }
+
+ OverlaySelection::~OverlaySelection()
+ {
+ if(getOverlayManager())
+ {
+ getOverlayManager()->remove(*this);
+ }
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence OverlaySelection::getOverlayObjectPrimitive2DSequence() const
+ {
+ // get current values
+ const OverlayType aNewOverlayType(impCheckPossibleOverlayType(meOverlayType));
+ const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+ const sal_uInt16 nNewTransparence(aSvtOptionsDrawinglayer.GetTransparentSelectionPercent());
+
+ if(getPrimitive2DSequence().hasElements())
+ {
+ if(aNewOverlayType != maLastOverlayType
+ || nNewTransparence != mnLastTransparence)
+ {
+ // conditions of last local decomposition have changed, delete
+ const_cast< OverlaySelection* >(this)->setPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DSequence());
+ }
+ }
+
+ if(!getPrimitive2DSequence().hasElements())
+ {
+ // remember new values
+ const_cast< OverlaySelection* >(this)->maLastOverlayType = aNewOverlayType;
+ const_cast< OverlaySelection* >(this)->mnLastTransparence = nNewTransparence;
+ }
+
+ // call base implementation
+ return OverlayObject::getOverlayObjectPrimitive2DSequence();
+ }
+
+ void OverlaySelection::setRanges(const std::vector< basegfx::B2DRange >& rNew)
+ {
+ if(rNew != maRanges)
+ {
+ maRanges = rNew;
+ objectChange();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlaytools.cxx b/svx/source/sdr/overlay/overlaytools.cxx
new file mode 100644
index 000000000000..fdd28cd17310
--- /dev/null
+++ b/svx/source/sdr/overlay/overlaytools.cxx
@@ -0,0 +1,496 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/overlay/overlaytools.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ OverlayBitmapExPrimitive::OverlayBitmapExPrimitive(
+ const BitmapEx& rBitmapEx,
+ const basegfx::B2DPoint& rBasePosition,
+ sal_uInt16 nCenterX,
+ sal_uInt16 nCenterY)
+ : DiscreteMetricDependentPrimitive2D(),
+ maBitmapEx(rBitmapEx),
+ maBasePosition(rBasePosition),
+ mnCenterX(nCenterX),
+ mnCenterY(nCenterY)
+ {}
+
+ Primitive2DSequence OverlayBitmapExPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+ const Size aBitmapSize(getBitmapEx().GetSizePixel());
+
+ if(aBitmapSize.Width() && aBitmapSize.Height() && basegfx::fTools::more(getDiscreteUnit(), 0.0))
+ {
+ // calculate back from internal bitmap's extreme coordinates (the edges)
+ // to logical coordinates. Only use a unified scaling value (getDiscreteUnit(),
+ // the prepared one which expresses how many logic units form a discrete unit)
+ // for this step. This primitive is to be displayed always unscaled (in it's pixel size)
+ // and unrotated, more like a marker
+ const double fLeft(((0.0 - getCenterX()) * getDiscreteUnit()) + getBasePosition().getX());
+ const double fTop(((0.0 - getCenterY()) * getDiscreteUnit()) + getBasePosition().getY());
+ const double fRight((((aBitmapSize.getWidth() - 1.0) - getCenterX()) * getDiscreteUnit()) + getBasePosition().getX());
+ const double fBottom((((aBitmapSize.getHeight() - 1.0) - getCenterY()) * getDiscreteUnit()) + getBasePosition().getY());
+
+ // create a BitmapPrimitive2D using those positions
+ basegfx::B2DHomMatrix aTransform;
+
+ aTransform.set(0, 0, fRight - fLeft);
+ aTransform.set(1, 1, fBottom - fTop);
+ aTransform.set(0, 2, fLeft);
+ aTransform.set(1, 2, fTop);
+
+ const Primitive2DReference aPrimitive(new BitmapPrimitive2D(getBitmapEx(), aTransform));
+ aRetval = Primitive2DSequence(&aPrimitive, 1);
+ }
+
+ return aRetval;
+ }
+
+ bool OverlayBitmapExPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
+ {
+ if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
+ {
+ const OverlayBitmapExPrimitive& rCompare = static_cast< const OverlayBitmapExPrimitive& >(rPrimitive);
+
+ return (getBitmapEx() == rCompare.getBitmapEx()
+ && getBasePosition() == rCompare.getBasePosition()
+ && getCenterX() == rCompare.getCenterX()
+ && getCenterY() == rCompare.getCenterY());
+ }
+
+ return false;
+ }
+
+ ImplPrimitrive2DIDBlock(OverlayBitmapExPrimitive, PRIMITIVE2D_ID_OVERLAYBITMAPEXPRIMITIVE)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ OverlayCrosshairPrimitive::OverlayCrosshairPrimitive(
+ const basegfx::B2DPoint& rBasePosition,
+ const basegfx::BColor& rRGBColorA,
+ const basegfx::BColor& rRGBColorB,
+ double fDiscreteDashLength)
+ : ViewportDependentPrimitive2D(),
+ maBasePosition(rBasePosition),
+ maRGBColorA(rRGBColorA),
+ maRGBColorB(rRGBColorB),
+ mfDiscreteDashLength(fDiscreteDashLength)
+ {}
+
+ Primitive2DSequence OverlayCrosshairPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
+ {
+ // use the prepared Viewport information accessible using getViewport()
+ Primitive2DSequence aRetval;
+
+ if(!getViewport().isEmpty())
+ {
+ aRetval.realloc(2);
+ basegfx::B2DPolygon aPolygon;
+
+ aPolygon.append(basegfx::B2DPoint(getViewport().getMinX(), getBasePosition().getY()));
+ aPolygon.append(basegfx::B2DPoint(getViewport().getMaxX(), getBasePosition().getY()));
+
+ aRetval[0] = Primitive2DReference(
+ new PolygonMarkerPrimitive2D(
+ aPolygon,
+ getRGBColorA(),
+ getRGBColorB(),
+ getDiscreteDashLength()));
+
+ aPolygon.clear();
+ aPolygon.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMinY()));
+ aPolygon.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMaxY()));
+
+ aRetval[1] = Primitive2DReference(
+ new PolygonMarkerPrimitive2D(
+ aPolygon,
+ getRGBColorA(),
+ getRGBColorB(),
+ getDiscreteDashLength()));
+ }
+
+ return aRetval;
+ }
+
+ bool OverlayCrosshairPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
+ {
+ if(ViewportDependentPrimitive2D::operator==(rPrimitive))
+ {
+ const OverlayCrosshairPrimitive& rCompare = static_cast< const OverlayCrosshairPrimitive& >(rPrimitive);
+
+ return (getBasePosition() == rCompare.getBasePosition()
+ && getRGBColorA() == rCompare.getRGBColorA()
+ && getRGBColorB() == rCompare.getRGBColorB()
+ && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
+ }
+
+ return false;
+ }
+
+ ImplPrimitrive2DIDBlock(OverlayCrosshairPrimitive, PRIMITIVE2D_ID_OVERLAYCROSSHAIRPRIMITIVE)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ OverlayHatchRectanglePrimitive::OverlayHatchRectanglePrimitive(
+ const basegfx::B2DRange& rObjectRange,
+ double fDiscreteHatchDistance,
+ double fHatchRotation,
+ const basegfx::BColor& rHatchColor,
+ double fDiscreteGrow,
+ double fDiscreteShrink,
+ double fRotation)
+ : DiscreteMetricDependentPrimitive2D(),
+ maObjectRange(rObjectRange),
+ mfDiscreteHatchDistance(fDiscreteHatchDistance),
+ mfHatchRotation(fHatchRotation),
+ maHatchColor(rHatchColor),
+ mfDiscreteGrow(fDiscreteGrow),
+ mfDiscreteShrink(fDiscreteShrink),
+ mfRotation(fRotation)
+ {}
+
+ Primitive2DSequence OverlayHatchRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ if(basegfx::fTools::more(getDiscreteUnit(), 0.0))
+ {
+ basegfx::B2DRange aInnerRange(getObjectRange());
+ basegfx::B2DRange aOuterRange(getObjectRange());
+ basegfx::B2DPolyPolygon aHatchPolyPolygon;
+
+ aOuterRange.grow(getDiscreteUnit() * getDiscreteGrow());
+ aInnerRange.grow(getDiscreteUnit() * -getDiscreteShrink());
+
+ aHatchPolyPolygon.append(basegfx::tools::createPolygonFromRect(aOuterRange));
+
+ if(!aInnerRange.isEmpty())
+ {
+ aHatchPolyPolygon.append(basegfx::tools::createPolygonFromRect(aInnerRange));
+ }
+
+ if(!basegfx::fTools::equalZero(getRotation()))
+ {
+ const basegfx::B2DHomMatrix aTransform(basegfx::tools::createRotateAroundPoint(
+ getObjectRange().getMinX(), getObjectRange().getMinY(), getRotation()));
+
+ aHatchPolyPolygon.transform(aTransform);
+ }
+
+ const basegfx::BColor aEmptyColor(0.0, 0.0, 0.0);
+ const drawinglayer::attribute::FillHatchAttribute aFillHatchAttribute(
+ drawinglayer::attribute::HATCHSTYLE_SINGLE,
+ getDiscreteHatchDistance() * getDiscreteUnit(),
+ getHatchRotation() - getRotation(),
+ getHatchColor(),
+ false);
+ const Primitive2DReference aPrimitive(
+ new PolyPolygonHatchPrimitive2D(
+ aHatchPolyPolygon,
+ aEmptyColor,
+ aFillHatchAttribute));
+
+ aRetval = Primitive2DSequence(&aPrimitive, 1);
+ }
+
+ return aRetval;
+ }
+
+ bool OverlayHatchRectanglePrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
+ {
+ if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive))
+ {
+ const OverlayHatchRectanglePrimitive& rCompare = static_cast< const OverlayHatchRectanglePrimitive& >(rPrimitive);
+
+ return (getObjectRange() == rCompare.getObjectRange()
+ && getDiscreteHatchDistance() == rCompare.getDiscreteHatchDistance()
+ && getHatchRotation() == rCompare.getHatchRotation()
+ && getHatchColor() == rCompare.getHatchColor()
+ && getDiscreteGrow() == rCompare.getDiscreteGrow()
+ && getDiscreteShrink() == rCompare.getDiscreteShrink()
+ && getRotation() == rCompare.getRotation());
+ }
+
+ return false;
+ }
+
+ ImplPrimitrive2DIDBlock(OverlayHatchRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYHATCHRECTANGLEPRIMITIVE)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ OverlayHelplineStripedPrimitive::OverlayHelplineStripedPrimitive(
+ const basegfx::B2DPoint& rBasePosition,
+ HelplineStyle eStyle,
+ const basegfx::BColor& rRGBColorA,
+ const basegfx::BColor& rRGBColorB,
+ double fDiscreteDashLength)
+ : ViewportDependentPrimitive2D(),
+ maBasePosition(rBasePosition),
+ meStyle(eStyle),
+ maRGBColorA(rRGBColorA),
+ maRGBColorB(rRGBColorB),
+ mfDiscreteDashLength(fDiscreteDashLength)
+ {}
+
+ Primitive2DSequence OverlayHelplineStripedPrimitive::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
+ {
+ // use the prepared Viewport information accessible using getViewport()
+ Primitive2DSequence aRetval;
+
+ if(!getViewport().isEmpty())
+ {
+ switch(getStyle())
+ {
+ case HELPLINESTYLE_VERTICAL :
+ {
+ aRetval.realloc(1);
+ basegfx::B2DPolygon aLine;
+
+ aLine.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMinY()));
+ aLine.append(basegfx::B2DPoint(getBasePosition().getX(), getViewport().getMaxY()));
+
+ aRetval[0] = Primitive2DReference(
+ new PolygonMarkerPrimitive2D(
+ aLine,
+ getRGBColorA(),
+ getRGBColorB(),
+ getDiscreteDashLength()));
+ break;
+ }
+
+ case HELPLINESTYLE_HORIZONTAL :
+ {
+ aRetval.realloc(1);
+ basegfx::B2DPolygon aLine;
+
+ aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getBasePosition().getY()));
+ aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getBasePosition().getY()));
+
+ aRetval[0] = Primitive2DReference(
+ new PolygonMarkerPrimitive2D(
+ aLine,
+ getRGBColorA(),
+ getRGBColorB(),
+ getDiscreteDashLength()));
+ break;
+ }
+
+ default: // case HELPLINESTYLE_POINT :
+ {
+ const double fDiscreteUnit((rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength());
+ aRetval.realloc(2);
+ basegfx::B2DPolygon aLineA, aLineB;
+
+ aLineA.append(basegfx::B2DPoint(getBasePosition().getX(), getBasePosition().getY() - fDiscreteUnit));
+ aLineA.append(basegfx::B2DPoint(getBasePosition().getX(), getBasePosition().getY() + fDiscreteUnit));
+
+ aRetval[0] = Primitive2DReference(
+ new PolygonMarkerPrimitive2D(
+ aLineA,
+ getRGBColorA(),
+ getRGBColorB(),
+ getDiscreteDashLength()));
+
+ aLineB.append(basegfx::B2DPoint(getBasePosition().getX() - fDiscreteUnit, getBasePosition().getY()));
+ aLineB.append(basegfx::B2DPoint(getBasePosition().getX() + fDiscreteUnit, getBasePosition().getY()));
+
+ aRetval[1] = Primitive2DReference(
+ new PolygonMarkerPrimitive2D(
+ aLineB,
+ getRGBColorA(),
+ getRGBColorB(),
+ getDiscreteDashLength()));
+
+ break;
+ }
+ }
+ }
+
+ return aRetval;
+ }
+
+ bool OverlayHelplineStripedPrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
+ {
+ if(ViewportDependentPrimitive2D::operator==(rPrimitive))
+ {
+ const OverlayHelplineStripedPrimitive& rCompare = static_cast< const OverlayHelplineStripedPrimitive& >(rPrimitive);
+
+ return (getBasePosition() == rCompare.getBasePosition()
+ && getStyle() == rCompare.getStyle()
+ && getRGBColorA() == rCompare.getRGBColorA()
+ && getRGBColorB() == rCompare.getRGBColorB()
+ && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
+ }
+
+ return false;
+ }
+
+ ImplPrimitrive2DIDBlock(OverlayHelplineStripedPrimitive, PRIMITIVE2D_ID_OVERLAYHELPLINESTRIPEDPRIMITIVE)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ OverlayRollingRectanglePrimitive::OverlayRollingRectanglePrimitive(
+ const basegfx::B2DRange& aRollingRectangle,
+ const basegfx::BColor& rRGBColorA,
+ const basegfx::BColor& rRGBColorB,
+ double fDiscreteDashLength)
+ : ViewportDependentPrimitive2D(),
+ maRollingRectangle(aRollingRectangle),
+ maRGBColorA(rRGBColorA),
+ maRGBColorB(rRGBColorB),
+ mfDiscreteDashLength(fDiscreteDashLength)
+ {}
+
+ Primitive2DSequence OverlayRollingRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
+ {
+ // use the prepared Viewport information accessible using getViewport()
+ Primitive2DSequence aRetval;
+
+ if(!getViewport().isEmpty())
+ {
+ basegfx::B2DPolygon aLine;
+ aRetval.realloc(8);
+
+ // Left lines
+ aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getRollingRectangle().getMinY()));
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMinY()));
+ aRetval[0] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
+
+ aLine.clear();
+ aLine.append(basegfx::B2DPoint(getViewport().getMinX(), getRollingRectangle().getMaxY()));
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMaxY()));
+ aRetval[1] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
+
+ // Right lines
+ aLine.clear();
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMinY()));
+ aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getRollingRectangle().getMinY()));
+ aRetval[2] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
+
+ aLine.clear();
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMaxY()));
+ aLine.append(basegfx::B2DPoint(getViewport().getMaxX(), getRollingRectangle().getMaxY()));
+ aRetval[3] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
+
+ // Top lines
+ aLine.clear();
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getViewport().getMinY()));
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMinY()));
+ aRetval[4] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
+
+ aLine.clear();
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getViewport().getMinY()));
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMinY()));
+ aRetval[5] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
+
+ // Bottom lines
+ aLine.clear();
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getRollingRectangle().getMaxY()));
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMinX(), getViewport().getMaxY()));
+ aRetval[6] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
+
+ aLine.clear();
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getRollingRectangle().getMaxY()));
+ aLine.append(basegfx::B2DPoint(getRollingRectangle().getMaxX(), getViewport().getMaxY()));
+ aRetval[7] = Primitive2DReference(new PolygonMarkerPrimitive2D(aLine, getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
+ }
+
+ return aRetval;
+ }
+
+ bool OverlayRollingRectanglePrimitive::operator==( const BasePrimitive2D& rPrimitive ) const
+ {
+ if(ViewportDependentPrimitive2D::operator==(rPrimitive))
+ {
+ const OverlayRollingRectanglePrimitive& rCompare = static_cast< const OverlayRollingRectanglePrimitive& >(rPrimitive);
+
+ return (getRollingRectangle() == rCompare.getRollingRectangle()
+ && getRGBColorA() == rCompare.getRGBColorA()
+ && getRGBColorB() == rCompare.getRGBColorB()
+ && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
+ }
+
+ return false;
+ }
+
+ ImplPrimitrive2DIDBlock(OverlayRollingRectanglePrimitive, PRIMITIVE2D_ID_OVERLAYROLLINGRECTANGLEPRIMITIVE)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/overlay/overlaytriangle.cxx b/svx/source/sdr/overlay/overlaytriangle.cxx
new file mode 100644
index 000000000000..d4b1e4d1a7b6
--- /dev/null
+++ b/svx/source/sdr/overlay/overlaytriangle.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/overlay/overlaytriangle.hxx>
+#include <tools/poly.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/outdev.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace overlay
+ {
+ drawinglayer::primitive2d::Primitive2DSequence OverlayTriangle::createOverlayObjectPrimitive2DSequence()
+ {
+ basegfx::B2DPolygon aPolygon;
+
+ aPolygon.append(getBasePosition());
+ aPolygon.append(getSecondPosition());
+ aPolygon.append(getThirdPosition());
+ aPolygon.setClosed(true);
+
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
+ basegfx::B2DPolyPolygon(aPolygon),
+ getBaseColor().getBColor()));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+ }
+
+ OverlayTriangle::OverlayTriangle(
+ const basegfx::B2DPoint& rBasePos,
+ const basegfx::B2DPoint& rSecondPos,
+ const basegfx::B2DPoint& rThirdPos,
+ Color aTriangleColor)
+ : OverlayObjectWithBasePosition(rBasePos, aTriangleColor),
+ maSecondPosition(rSecondPos),
+ maThirdPosition(rThirdPos)
+ {
+ }
+
+ OverlayTriangle::~OverlayTriangle()
+ {
+ }
+
+ void OverlayTriangle::setSecondPosition(const basegfx::B2DPoint& rNew)
+ {
+ if(rNew != maSecondPosition)
+ {
+ // remember new value
+ maSecondPosition = rNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+
+ void OverlayTriangle::setThirdPosition(const basegfx::B2DPoint& rNew)
+ {
+ if(rNew != maThirdPosition)
+ {
+ // remember new value
+ maThirdPosition = rNew;
+
+ // register change (after change)
+ objectChange();
+ }
+ }
+ } // end of namespace overlay
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/makefile.mk b/svx/source/sdr/primitive2d/makefile.mk
new file mode 100644
index 000000000000..078bc4bc977e
--- /dev/null
+++ b/svx/source/sdr/primitive2d/makefile.mk
@@ -0,0 +1,57 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=svx
+TARGET=primitive2d
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/primitivefactory2d.obj \
+ $(SLO)$/sdrdecompositiontools.obj \
+ $(SLO)$/sdrattributecreator.obj \
+ $(SLO)$/sdrellipseprimitive2d.obj \
+ $(SLO)$/sdrrectangleprimitive2d.obj \
+ $(SLO)$/sdrcustomshapeprimitive2d.obj \
+ $(SLO)$/sdrcaptionprimitive2d.obj \
+ $(SLO)$/sdrgrafprimitive2d.obj \
+ $(SLO)$/sdrole2primitive2d.obj \
+ $(SLO)$/sdrolecontentprimitive2d.obj \
+ $(SLO)$/sdrpathprimitive2d.obj \
+ $(SLO)$/sdrprimitivetools.obj \
+ $(SLO)$/sdrmeasureprimitive2d.obj \
+ $(SLO)$/sdrconnectorprimitive2d.obj \
+ $(SLO)$/sdrtextprimitive2d.obj
+
+.INCLUDE : target.mk
diff --git a/svx/source/sdr/primitive2d/primitivefactory2d.cxx b/svx/source/sdr/primitive2d/primitivefactory2d.cxx
new file mode 100644
index 000000000000..8ef1f85dd913
--- /dev/null
+++ b/svx/source/sdr/primitive2d/primitivefactory2d.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/primitiveFactory2d.hxx>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpage.hxx>
+#include <unoapi.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+// UNO API helper methods
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ uno::Reference< uno::XInterface > SAL_CALL XPrimitiveFactory2DProvider_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory >& /*rSMgr*/) throw( uno::Exception )
+ {
+ return *(new PrimitiveFactory2D());
+ }
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// UNO API helper methods
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ PrimitiveFactory2D::PrimitiveFactory2D()
+ : PrimitiveFactory2DImplBase(m_aMutex)
+ {
+ }
+
+ Primitive2DSequence SAL_CALL PrimitiveFactory2D::createPrimitivesFromXShape(
+ const uno::Reference< drawing::XShape >& xShape,
+ const uno::Sequence< beans::PropertyValue >& /*aParms*/ ) throw (uno::RuntimeException)
+ {
+ Primitive2DSequence aRetval;
+
+ if(xShape.is())
+ {
+ SdrObject* pSource = GetSdrObjectFromXShape(xShape);
+
+ if(pSource)
+ {
+ const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
+ aRetval = rSource.getViewIndependentPrimitive2DSequence();
+ }
+ }
+
+ return aRetval;
+ }
+
+ Primitive2DSequence SAL_CALL PrimitiveFactory2D::createPrimitivesFromXDrawPage(
+ const uno::Reference< drawing::XDrawPage >& xDrawPage,
+ const uno::Sequence< beans::PropertyValue >& /*aParms*/ ) throw (uno::RuntimeException)
+ {
+ Primitive2DSequence aRetval;
+
+ if(xDrawPage.is())
+ {
+ SdrPage* pSource = GetSdrPageFromXDrawPage(xDrawPage);
+
+ if(pSource)
+ {
+ const sdr::contact::ViewContact& rSource(pSource->GetViewContact());
+
+ aRetval = rSource.getViewIndependentPrimitive2DSequence();
+ }
+ }
+
+ return aRetval;
+ }
+
+ rtl::OUString PrimitiveFactory2D::getImplementationName_Static()
+ {
+ static rtl::OUString aRetval(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.graphic.PrimitiveFactory2D"));
+ return aRetval;
+ }
+
+ uno::Sequence< rtl::OUString > PrimitiveFactory2D::getSupportedServiceNames_Static()
+ {
+ static uno::Sequence< rtl::OUString > aSeq;
+ osl::Mutex aMutex;
+ osl::MutexGuard aGuard( aMutex );
+
+ if(!aSeq.getLength())
+ {
+ aSeq.realloc(1L);
+ aSeq.getArray()[0L] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.PrimitiveFactory2D"));
+ }
+
+ return aSeq;
+ }
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrattributecreator.cxx b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
new file mode 100644
index 000000000000..1c788312b41c
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrattributecreator.cxx
@@ -0,0 +1,1031 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svl/itemset.hxx>
+#include <svx/xdef.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlinjoit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnstcit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xlnedcit.hxx>
+#include <svx/xdash.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/xflftrit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xgrscit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xflbckit.hxx>
+#include <svx/sdshitm.hxx>
+#include <svx/sdsxyitm.hxx>
+#include <svx/sdshcitm.hxx>
+#include <svx/sdshtitm.hxx>
+#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
+#include <basegfx/polygon/b2dlinegeometry.hxx>
+#include <svx/svdotext.hxx>
+#include <drawinglayer/attribute/fillbitmapattribute.hxx>
+#include <svx/sdr/attribute/sdrtextattribute.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svl/itempool.hxx>
+#include <vcl/svapp.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <svx/svx3ditems.hxx>
+#include <com/sun/star/drawing/ProjectionMode.hpp>
+#include <com/sun/star/drawing/ShadeMode.hpp>
+#include <drawinglayer/attribute/sdrallattribute3d.hxx>
+#include <svx/rectenum.hxx>
+#include <svx/sdtfchim.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdmodel.hxx>
+#include <editeng/editstat.hxx>
+#include <drawinglayer/attribute/fillhatchattribute.hxx>
+#include <drawinglayer/attribute/fillgradientattribute.hxx>
+#include <svx/sdr/attribute/sdrshadowtextattribute.hxx>
+#include <svx/sdr/attribute/sdrlineshadowtextattribute.hxx>
+#include <svx/sdr/attribute/sdrformtextattribute.hxx>
+#include <svx/sdr/attribute/sdrlinefillshadowtextattribute.hxx>
+#include <drawinglayer/attribute/sdrsceneattribute3d.hxx>
+#include <drawinglayer/attribute/sdrlightingattribute3d.hxx>
+#include <drawinglayer/attribute/sdrlightattribute3d.hxx>
+#include <svx/sdr/attribute/sdrfilltextattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace
+ {
+ attribute::GradientStyle XGradientStyleToGradientStyle(XGradientStyle eStyle)
+ {
+ switch(eStyle)
+ {
+ case XGRAD_LINEAR :
+ {
+ return attribute::GRADIENTSTYLE_LINEAR;
+ }
+ case XGRAD_AXIAL :
+ {
+ return attribute::GRADIENTSTYLE_AXIAL;
+ }
+ case XGRAD_RADIAL :
+ {
+ return attribute::GRADIENTSTYLE_RADIAL;
+ }
+ case XGRAD_ELLIPTICAL :
+ {
+ return attribute::GRADIENTSTYLE_ELLIPTICAL;
+ }
+ case XGRAD_SQUARE :
+ {
+ return attribute::GRADIENTSTYLE_SQUARE;
+ }
+ default :
+ {
+ return attribute::GRADIENTSTYLE_RECT; // XGRAD_RECT
+ }
+ }
+ }
+
+ attribute::HatchStyle XHatchStyleToHatchStyle(XHatchStyle eStyle)
+ {
+ switch(eStyle)
+ {
+ case XHATCH_SINGLE :
+ {
+ return attribute::HATCHSTYLE_SINGLE;
+ }
+ case XHATCH_DOUBLE :
+ {
+ return attribute::HATCHSTYLE_DOUBLE;
+ }
+ default :
+ {
+ return attribute::HATCHSTYLE_TRIPLE; // XHATCH_TRIPLE
+ }
+ }
+ }
+
+ basegfx::B2DLineJoin XLineJointtoB2DLineJoin(XLineJoint eLineJoint)
+ {
+ switch(eLineJoint)
+ {
+ case XLINEJOINT_MIDDLE :
+ {
+ return basegfx::B2DLINEJOIN_MIDDLE;
+ }
+ case XLINEJOINT_BEVEL :
+ {
+ return basegfx::B2DLINEJOIN_BEVEL;
+ }
+ case XLINEJOINT_MITER :
+ {
+ return basegfx::B2DLINEJOIN_MITER;
+ }
+ case XLINEJOINT_ROUND :
+ {
+ return basegfx::B2DLINEJOIN_ROUND;
+ }
+ default :
+ {
+ return basegfx::B2DLINEJOIN_NONE; // XLINEJOINT_NONE
+ }
+ }
+ }
+
+ basegfx::B2DVector RectPointToB2DVector(RECT_POINT eRectPoint)
+ {
+ basegfx::B2DVector aRetval(0.0, 0.0);
+
+ // position changes X
+ switch(eRectPoint)
+ {
+ case RP_LT: case RP_LM: case RP_LB:
+ {
+ aRetval.setX(-1.0);
+ break;
+ }
+
+ case RP_RT: case RP_RM: case RP_RB:
+ {
+ aRetval.setX(1.0);
+ break;
+ }
+
+ default :
+ {
+ break;
+ }
+ }
+
+ // position changes Y
+ switch(eRectPoint)
+ {
+ case RP_LT: case RP_MT: case RP_RT:
+ {
+ aRetval.setY(-1.0);
+ break;
+ }
+
+ case RP_LB: case RP_MB: case RP_RB:
+ {
+ aRetval.setY(1.0);
+ break;
+ }
+
+ default :
+ {
+ break;
+ }
+ }
+
+ return aRetval;
+ }
+ } // end of anonymous namespace
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ attribute::SdrLineAttribute createNewSdrLineAttribute(const SfxItemSet& rSet)
+ {
+ const XLineStyle eStyle(((XLineStyleItem&)(rSet.Get(XATTR_LINESTYLE))).GetValue());
+
+ if(XLINE_NONE != eStyle)
+ {
+ sal_uInt16 nTransparence(((const XLineTransparenceItem&)(rSet.Get(XATTR_LINETRANSPARENCE))).GetValue());
+
+ if(nTransparence > 100)
+ {
+ nTransparence = 100;
+ }
+
+ if(100 != nTransparence)
+ {
+ const sal_uInt32 nWidth(((const XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue());
+ const Color aColor(((const XLineColorItem&)(rSet.Get(XATTR_LINECOLOR))).GetColorValue());
+ const XLineJoint eJoint(((const XLineJointItem&)(rSet.Get(XATTR_LINEJOINT))).GetValue());
+ ::std::vector< double > aDotDashArray;
+ double fFullDotDashLen(0.0);
+
+ if(XLINE_DASH == eStyle)
+ {
+ const XDash& rDash = ((const XLineDashItem&)(rSet.Get(XATTR_LINEDASH))).GetDashValue();
+
+ if(rDash.GetDots() || rDash.GetDashes())
+ {
+ fFullDotDashLen = rDash.CreateDotDashArray(aDotDashArray, (double)nWidth);
+ }
+ }
+
+ return attribute::SdrLineAttribute(
+ XLineJointtoB2DLineJoin(eJoint),
+ (double)nWidth,
+ (double)nTransparence * 0.01,
+ aColor.getBColor(),
+ aDotDashArray,
+ fFullDotDashLen);
+ }
+ }
+
+ return attribute::SdrLineAttribute();
+ }
+
+ attribute::SdrLineStartEndAttribute createNewSdrLineStartEndAttribute(
+ const SfxItemSet& rSet,
+ double fWidth)
+ {
+ const sal_Int32 nTempStartWidth(((const XLineStartWidthItem&)(rSet.Get(XATTR_LINESTARTWIDTH))).GetValue());
+ const sal_Int32 nTempEndWidth(((const XLineEndWidthItem&)(rSet.Get(XATTR_LINEENDWIDTH))).GetValue());
+ basegfx::B2DPolyPolygon aStartPolyPolygon;
+ basegfx::B2DPolyPolygon aEndPolyPolygon;
+ double fStartWidth(0.0);
+ double fEndWidth(0.0);
+ bool bStartActive(false);
+ bool bEndActive(false);
+ bool bStartCentered(true);
+ bool bEndCentered(true);
+
+ if(nTempStartWidth)
+ {
+ if(nTempStartWidth < 0L)
+ {
+ fStartWidth = ((double)(-nTempStartWidth) * fWidth) * 0.01;
+ }
+ else
+ {
+ fStartWidth = (double)nTempStartWidth;
+ }
+
+ if(0.0 != fStartWidth)
+ {
+ aStartPolyPolygon = basegfx::B2DPolyPolygon(((const XLineStartItem&)(rSet.Get(XATTR_LINESTART))).GetLineStartValue());
+
+ if(aStartPolyPolygon.count() && aStartPolyPolygon.getB2DPolygon(0L).count())
+ {
+ bStartActive = true;
+ bStartCentered = ((const XLineStartCenterItem&)(rSet.Get(XATTR_LINESTARTCENTER))).GetValue();
+ }
+ }
+ }
+
+ if(nTempEndWidth)
+ {
+ if(nTempEndWidth < 0L)
+ {
+ fEndWidth = ((double)(-nTempEndWidth) * fWidth) * 0.01;
+ }
+ else
+ {
+ fEndWidth = (double)nTempEndWidth;
+ }
+
+ if(0.0 != fEndWidth)
+ {
+ aEndPolyPolygon = basegfx::B2DPolyPolygon(((const XLineEndItem&)(rSet.Get(XATTR_LINEEND))).GetLineEndValue());
+
+ if(aEndPolyPolygon.count() && aEndPolyPolygon.getB2DPolygon(0L).count())
+ {
+ bEndActive = true;
+ bEndCentered = ((const XLineEndCenterItem&)(rSet.Get(XATTR_LINEENDCENTER))).GetValue();
+ }
+ }
+ }
+
+ if(bStartActive || bEndActive)
+ {
+ return attribute::SdrLineStartEndAttribute(
+ aStartPolyPolygon, aEndPolyPolygon, fStartWidth, fEndWidth,
+ bStartActive, bEndActive, bStartCentered, bEndCentered);
+ }
+
+ return attribute::SdrLineStartEndAttribute();
+ }
+
+ attribute::SdrShadowAttribute createNewSdrShadowAttribute(const SfxItemSet& rSet)
+ {
+ const bool bShadow(((SdrShadowItem&)rSet.Get(SDRATTR_SHADOW)).GetValue());
+
+ if(bShadow)
+ {
+ sal_uInt16 nTransparence(((SdrShadowTransparenceItem&)(rSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue());
+
+ if(nTransparence > 100)
+ {
+ nTransparence = 100;
+ }
+
+ if(nTransparence)
+ {
+ sal_uInt16 nFillTransparence(((const XFillTransparenceItem&)(rSet.Get(XATTR_FILLTRANSPARENCE))).GetValue());
+
+ if(nFillTransparence > 100)
+ {
+ nFillTransparence = 100;
+ }
+
+ if(nTransparence == nFillTransparence)
+ {
+ // shadow does not really have an own transparence, but the application
+ // sets the shadow transparence equal to the object transparence for
+ // convenience. This is not useful for primitive creation, so take
+ // this as no shadow transparence
+ nTransparence = 0;
+ }
+ }
+
+ if(100 != nTransparence)
+ {
+ const basegfx::B2DVector aOffset(
+ (double)((SdrShadowXDistItem&)(rSet.Get(SDRATTR_SHADOWXDIST))).GetValue(),
+ (double)((SdrShadowYDistItem&)(rSet.Get(SDRATTR_SHADOWYDIST))).GetValue());
+ const Color aColor(((SdrShadowColorItem&)(rSet.Get(SDRATTR_SHADOWCOLOR))).GetColorValue());
+
+ return attribute::SdrShadowAttribute(aOffset, (double)nTransparence * 0.01, aColor.getBColor());
+ }
+ }
+
+ return attribute::SdrShadowAttribute();
+ }
+
+ attribute::SdrFillAttribute createNewSdrFillAttribute(const SfxItemSet& rSet)
+ {
+ const XFillStyle eStyle(((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue());
+
+ if(XFILL_NONE != eStyle)
+ {
+ sal_uInt16 nTransparence(((const XFillTransparenceItem&)(rSet.Get(XATTR_FILLTRANSPARENCE))).GetValue());
+
+ if(nTransparence > 100)
+ {
+ nTransparence = 100;
+ }
+
+ if(100 != nTransparence)
+ {
+ const Color aColor(((const XFillColorItem&)(rSet.Get(XATTR_FILLCOLOR))).GetColorValue());
+ attribute::FillGradientAttribute aGradient;
+ attribute::FillHatchAttribute aHatch;
+ attribute::SdrFillBitmapAttribute aBitmap;
+
+ switch(eStyle)
+ {
+ case XFILL_NONE : // for warnings
+ case XFILL_SOLID :
+ {
+ // nothing to do, color is defined
+ break;
+ }
+ case XFILL_GRADIENT :
+ {
+ XGradient aXGradient(((XFillGradientItem&)(rSet.Get(XATTR_FILLGRADIENT))).GetGradientValue());
+
+ const Color aStartColor(aXGradient.GetStartColor());
+ const sal_uInt16 nStartIntens(aXGradient.GetStartIntens());
+ basegfx::BColor aStart(aStartColor.getBColor());
+
+ if(nStartIntens != 100)
+ {
+ const basegfx::BColor aBlack;
+ aStart = interpolate(aBlack, aStart, (double)nStartIntens * 0.01);
+ }
+
+ const Color aEndColor(aXGradient.GetEndColor());
+ const sal_uInt16 nEndIntens(aXGradient.GetEndIntens());
+ basegfx::BColor aEnd(aEndColor.getBColor());
+
+ if(nEndIntens != 100)
+ {
+ const basegfx::BColor aBlack;
+ aEnd = interpolate(aBlack, aEnd, (double)nEndIntens * 0.01);
+ }
+
+ aGradient = attribute::FillGradientAttribute(
+ XGradientStyleToGradientStyle(aXGradient.GetGradientStyle()),
+ (double)aXGradient.GetBorder() * 0.01,
+ (double)aXGradient.GetXOffset() * 0.01,
+ (double)aXGradient.GetYOffset() * 0.01,
+ (double)aXGradient.GetAngle() * F_PI1800,
+ aStart,
+ aEnd,
+ ((const XGradientStepCountItem&)rSet.Get(XATTR_GRADIENTSTEPCOUNT)).GetValue());
+
+ break;
+ }
+ case XFILL_HATCH :
+ {
+ const XHatch& rHatch(((XFillHatchItem&)(rSet.Get(XATTR_FILLHATCH))).GetHatchValue());
+ const Color aColorB(rHatch.GetColor());
+
+ aHatch = attribute::FillHatchAttribute(
+ XHatchStyleToHatchStyle(rHatch.GetHatchStyle()),
+ (double)rHatch.GetDistance(),
+ (double)rHatch.GetAngle() * F_PI1800,
+ aColorB.getBColor(),
+ ((const XFillBackgroundItem&)(rSet.Get(XATTR_FILLBACKGROUND))).GetValue());
+
+ break;
+ }
+ case XFILL_BITMAP :
+ {
+ aBitmap = createNewSdrFillBitmapAttribute(rSet);
+ break;
+ }
+ }
+
+ return attribute::SdrFillAttribute(
+ (double)nTransparence * 0.01,
+ aColor.getBColor(),
+ aGradient,
+ aHatch,
+ aBitmap);
+ }
+ }
+
+ return attribute::SdrFillAttribute();
+ }
+
+ // #i101508# Support handing over given text-to-border distances
+ attribute::SdrTextAttribute createNewSdrTextAttribute(
+ const SfxItemSet& rSet,
+ const SdrText& rText,
+ const sal_Int32* pLeft,
+ const sal_Int32* pUpper,
+ const sal_Int32* pRight,
+ const sal_Int32* pLower)
+ {
+ const SdrTextObj& rTextObj = rText.GetObject();
+
+ if(rText.GetOutlinerParaObject() && rText.GetModel())
+ {
+ // added TextEdit text suppression
+ bool bInEditMode(false);
+
+ if(rText.GetObject().getTextCount() > 1)
+ {
+ bInEditMode = rTextObj.IsInEditMode() && rText.GetObject().getActiveText() == &rText;
+ }
+ else
+ {
+ bInEditMode = rTextObj.IsInEditMode();
+ }
+
+ OutlinerParaObject aOutlinerParaObject(*rText.GetOutlinerParaObject());
+
+ if(bInEditMode)
+ {
+ OutlinerParaObject* pTempObj = rTextObj.GetEditOutlinerParaObject();
+
+ if(pTempObj)
+ {
+ aOutlinerParaObject = *pTempObj;
+ delete pTempObj;
+ }
+ else
+ {
+ // #i100537#
+ // GetEditOutlinerParaObject() returning no object does not mean that
+ // text edit mode is not active. Do not reset the flag here
+ // bInEditMode = false;
+ }
+ }
+
+ const SdrTextAniKind eAniKind(rTextObj.GetTextAniKind());
+
+ // #i107346#
+ const SdrOutliner& rDrawTextOutliner = rText.GetModel()->GetDrawOutliner(&rTextObj);
+ const bool bWrongSpell(rDrawTextOutliner.GetControlWord() & EE_CNTRL_ONLINESPELLING);
+
+ return attribute::SdrTextAttribute(
+ rText,
+ aOutlinerParaObject,
+ ((const XFormTextStyleItem&)rSet.Get(XATTR_FORMTXTSTYLE)).GetValue(),
+ pLeft ? *pLeft : rTextObj.GetTextLeftDistance(),
+ pUpper ? *pUpper : rTextObj.GetTextUpperDistance(),
+ pRight ? *pRight : rTextObj.GetTextRightDistance(),
+ pLower ? *pLower : rTextObj.GetTextLowerDistance(),
+ rTextObj.GetTextHorizontalAdjust(rSet),
+ rTextObj.GetTextVerticalAdjust(rSet),
+ ((const SdrTextContourFrameItem&)rSet.Get(SDRATTR_TEXT_CONTOURFRAME)).GetValue(),
+ rTextObj.IsFitToSize(),
+ rTextObj.IsAutoFit(),
+ ((const XFormTextHideFormItem&)rSet.Get(XATTR_FORMTXTHIDEFORM)).GetValue(),
+ SDRTEXTANI_BLINK == eAniKind,
+ SDRTEXTANI_SCROLL == eAniKind || SDRTEXTANI_ALTERNATE == eAniKind || SDRTEXTANI_SLIDE == eAniKind,
+ bInEditMode,
+ ((const SdrTextFixedCellHeightItem&)rSet.Get(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue(),
+ bWrongSpell);
+ }
+
+ return attribute::SdrTextAttribute();
+ }
+
+ attribute::FillGradientAttribute createNewTransparenceGradientAttribute(const SfxItemSet& rSet)
+ {
+ const SfxPoolItem* pGradientItem;
+
+ if(SFX_ITEM_SET == rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE, TRUE, &pGradientItem)
+ && ((XFillFloatTransparenceItem*)pGradientItem)->IsEnabled())
+ {
+ // test if float transparence is completely transparent
+ const XGradient& rGradient = ((XFillFloatTransparenceItem*)pGradientItem)->GetGradientValue();
+ const sal_uInt8 nStartLuminance(rGradient.GetStartColor().GetLuminance());
+ const sal_uInt8 nEndLuminance(rGradient.GetEndColor().GetLuminance());
+ const bool bCompletelyTransparent(0xff == nStartLuminance && 0xff == nEndLuminance);
+
+ if(!bCompletelyTransparent)
+ {
+ const double fStartLum(nStartLuminance / 255.0);
+ const double fEndLum(nEndLuminance / 255.0);
+
+ return attribute::FillGradientAttribute(
+ XGradientStyleToGradientStyle(rGradient.GetGradientStyle()),
+ (double)rGradient.GetBorder() * 0.01,
+ (double)rGradient.GetXOffset() * 0.01,
+ (double)rGradient.GetYOffset() * 0.01,
+ (double)rGradient.GetAngle() * F_PI1800,
+ basegfx::BColor(fStartLum, fStartLum, fStartLum),
+ basegfx::BColor(fEndLum, fEndLum, fEndLum),
+ 0);
+ }
+ }
+
+ return attribute::FillGradientAttribute();
+ }
+
+ attribute::SdrFillBitmapAttribute createNewSdrFillBitmapAttribute(const SfxItemSet& rSet)
+ {
+ Bitmap aBitmap((((const XFillBitmapItem&)(rSet.Get(XATTR_FILLBITMAP))).GetBitmapValue()).GetBitmap());
+
+ // make sure it's not empty, use default instead
+ if(aBitmap.IsEmpty())
+ {
+ aBitmap = Bitmap(Size(4,4), 8);
+ }
+
+ // if there is no logical size, create a size from pixel size and set MapMode accordingly
+ if(0L == aBitmap.GetPrefSize().Width() || 0L == aBitmap.GetPrefSize().Height())
+ {
+ aBitmap.SetPrefSize(aBitmap.GetSizePixel());
+ aBitmap.SetPrefMapMode(MAP_PIXEL);
+ }
+
+ // convert size and MapMode to destination logical size and MapMode. The created
+ // bitmap must have a valid logical size (PrefSize)
+ const MapUnit aDestinationMapUnit((MapUnit)rSet.GetPool()->GetMetric(0));
+
+ if(aBitmap.GetPrefMapMode() != aDestinationMapUnit)
+ {
+ // #i100360# for MAP_PIXEL, LogicToLogic will not work properly,
+ // so fallback to Application::GetDefaultDevice()
+ if(MAP_PIXEL == aBitmap.GetPrefMapMode().GetMapUnit())
+ {
+ aBitmap.SetPrefSize(Application::GetDefaultDevice()->PixelToLogic(
+ aBitmap.GetPrefSize(), aDestinationMapUnit));
+ }
+ else
+ {
+ aBitmap.SetPrefSize(OutputDevice::LogicToLogic(
+ aBitmap.GetPrefSize(), aBitmap.GetPrefMapMode(), aDestinationMapUnit));
+ }
+ }
+
+ // get size
+ const basegfx::B2DVector aSize(
+ (double)((const SfxMetricItem&)(rSet.Get(XATTR_FILLBMP_SIZEX))).GetValue(),
+ (double)((const SfxMetricItem&)(rSet.Get(XATTR_FILLBMP_SIZEY))).GetValue());
+ const basegfx::B2DVector aOffset(
+ (double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_TILEOFFSETX))).GetValue(),
+ (double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_TILEOFFSETY))).GetValue());
+ const basegfx::B2DVector aOffsetPosition(
+ (double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_POSOFFSETX))).GetValue(),
+ (double)((const SfxUInt16Item&) (rSet.Get(XATTR_FILLBMP_POSOFFSETY))).GetValue());
+
+ return attribute::SdrFillBitmapAttribute(
+ aBitmap,
+ aSize,
+ aOffset,
+ aOffsetPosition,
+ RectPointToB2DVector((RECT_POINT)((const SfxEnumItem&)(rSet.Get(XATTR_FILLBMP_POS))).GetValue()),
+ ((const SfxBoolItem&) (rSet.Get(XATTR_FILLBMP_TILE))).GetValue(),
+ ((const SfxBoolItem&) (rSet.Get(XATTR_FILLBMP_STRETCH))).GetValue(),
+ ((const SfxBoolItem&) (rSet.Get(XATTR_FILLBMP_SIZELOG))).GetValue());
+ }
+
+ attribute::SdrShadowTextAttribute createNewSdrShadowTextAttribute(
+ const SfxItemSet& rSet,
+ const SdrText* pText,
+ bool bSuppressText)
+ {
+ attribute::SdrTextAttribute aText;
+
+ // #i98072# added option to suppress text
+ // look for text first
+ if(!bSuppressText && pText)
+ {
+ aText = createNewSdrTextAttribute(rSet, *pText);
+ }
+
+ // try shadow
+ const attribute::SdrShadowAttribute aShadow(createNewSdrShadowAttribute(rSet));
+
+ return attribute::SdrShadowTextAttribute(aShadow, aText);
+ }
+
+ attribute::SdrLineShadowTextAttribute createNewSdrLineShadowTextAttribute(
+ const SfxItemSet& rSet,
+ const SdrText* pText)
+ {
+ attribute::SdrLineAttribute aLine;
+ attribute::SdrLineStartEndAttribute aLineStartEnd;
+ attribute::SdrTextAttribute aText;
+ bool bFontworkHideContour(false);
+
+ // look for text first
+ if(pText)
+ {
+ aText = createNewSdrTextAttribute(rSet, *pText);
+
+ // when object has text and text is fontwork and hide contour is set for fontwork, force
+ // line and fill style to empty
+ if(!aText.isDefault()
+ && !aText.getSdrFormTextAttribute().isDefault()
+ && aText.isHideContour())
+ {
+ bFontworkHideContour = true;
+ }
+ }
+
+ // try line style
+ if(!bFontworkHideContour)
+ {
+ aLine = createNewSdrLineAttribute(rSet);
+
+ if(!aLine.isDefault())
+ {
+ // try LineStartEnd
+ aLineStartEnd = createNewSdrLineStartEndAttribute(rSet, aLine.getWidth());
+ }
+ }
+
+ if(!aLine.isDefault() || !aText.isDefault())
+ {
+ // try shadow
+ const attribute::SdrShadowAttribute aShadow(createNewSdrShadowAttribute(rSet));
+
+ return attribute::SdrLineShadowTextAttribute(aLine, aLineStartEnd, aShadow, aText);
+ }
+
+ return attribute::SdrLineShadowTextAttribute();
+ }
+
+ attribute::SdrLineFillShadowTextAttribute createNewSdrLineFillShadowTextAttribute(
+ const SfxItemSet& rSet,
+ const SdrText* pText)
+ {
+ attribute::SdrLineAttribute aLine;
+ attribute::SdrFillAttribute aFill;
+ attribute::SdrLineStartEndAttribute aLineStartEnd;
+ attribute::SdrShadowAttribute aShadow;
+ attribute::FillGradientAttribute aFillFloatTransGradient;
+ attribute::SdrTextAttribute aText;
+ bool bFontworkHideContour(false);
+
+ // look for text first
+ if(pText)
+ {
+ aText = createNewSdrTextAttribute(rSet, *pText);
+
+ // when object has text and text is fontwork and hide contour is set for fontwork, force
+ // line and fill style to empty
+ if(!aText.getSdrFormTextAttribute().isDefault() && aText.isHideContour())
+ {
+ bFontworkHideContour = true;
+ }
+ }
+
+ if(!bFontworkHideContour)
+ {
+ // try line style
+ aLine = createNewSdrLineAttribute(rSet);
+
+ if(!aLine.isDefault())
+ {
+ // try LineStartEnd
+ aLineStartEnd = createNewSdrLineStartEndAttribute(rSet, aLine.getWidth());
+ }
+
+ // try fill style
+ aFill = createNewSdrFillAttribute(rSet);
+
+ if(!aFill.isDefault())
+ {
+ // try fillfloattransparence
+ aFillFloatTransGradient = createNewTransparenceGradientAttribute(rSet);
+ }
+ }
+
+ if(!aLine.isDefault() || !aFill.isDefault() || !aText.isDefault())
+ {
+ // try shadow
+ aShadow = createNewSdrShadowAttribute(rSet);
+
+ return attribute::SdrLineFillShadowTextAttribute(
+ aLine, aFill, aLineStartEnd, aShadow, aFillFloatTransGradient, aText);
+ }
+
+ return attribute::SdrLineFillShadowTextAttribute();
+ }
+
+ attribute::SdrLineFillShadowAttribute3D createNewSdrLineFillShadowAttribute(const SfxItemSet& rSet, bool bSuppressFill)
+ {
+ attribute::SdrFillAttribute aFill;
+ attribute::SdrLineStartEndAttribute aLineStartEnd;
+ attribute::SdrShadowAttribute aShadow;
+ attribute::FillGradientAttribute aFillFloatTransGradient;
+
+ // try line style
+ const attribute::SdrLineAttribute aLine(createNewSdrLineAttribute(rSet));
+
+ if(!aLine.isDefault())
+ {
+ // try LineStartEnd
+ aLineStartEnd = createNewSdrLineStartEndAttribute(rSet, aLine.getWidth());
+ }
+
+ // try fill style
+ if(!bSuppressFill)
+ {
+ aFill = createNewSdrFillAttribute(rSet);
+
+ if(!aFill.isDefault())
+ {
+ // try fillfloattransparence
+ aFillFloatTransGradient = createNewTransparenceGradientAttribute(rSet);
+ }
+ }
+
+ if(!aLine.isDefault() || !aFill.isDefault())
+ {
+ // try shadow
+ aShadow = createNewSdrShadowAttribute(rSet);
+
+ return attribute::SdrLineFillShadowAttribute3D(
+ aLine, aFill, aLineStartEnd, aShadow, aFillFloatTransGradient);
+ }
+
+ return attribute::SdrLineFillShadowAttribute3D();
+ }
+
+ attribute::SdrSceneAttribute createNewSdrSceneAttribute(const SfxItemSet& rSet)
+ {
+ // get perspective
+ ::com::sun::star::drawing::ProjectionMode aProjectionMode(::com::sun::star::drawing::ProjectionMode_PARALLEL);
+ const sal_uInt16 nProjectionValue(((const Svx3DPerspectiveItem&)rSet.Get(SDRATTR_3DSCENE_PERSPECTIVE)).GetValue());
+
+ if(1L == nProjectionValue)
+ {
+ aProjectionMode = ::com::sun::star::drawing::ProjectionMode_PERSPECTIVE;
+ }
+
+ // get distance
+ const double fDistance(((const Svx3DDistanceItem&)rSet.Get(SDRATTR_3DSCENE_DISTANCE)).GetValue());
+
+ // get shadow slant
+ const double fShadowSlant(F_PI180 * ((const Svx3DShadowSlantItem&)rSet.Get(SDRATTR_3DSCENE_SHADOW_SLANT)).GetValue());
+
+ // get shade mode
+ ::com::sun::star::drawing::ShadeMode aShadeMode(::com::sun::star::drawing::ShadeMode_FLAT);
+ const sal_uInt16 nShadeValue(((const Svx3DShadeModeItem&)rSet.Get(SDRATTR_3DSCENE_SHADE_MODE)).GetValue());
+
+ if(1L == nShadeValue)
+ {
+ aShadeMode = ::com::sun::star::drawing::ShadeMode_PHONG;
+ }
+ else if(2L == nShadeValue)
+ {
+ aShadeMode = ::com::sun::star::drawing::ShadeMode_SMOOTH;
+ }
+ else if(3L == nShadeValue)
+ {
+ aShadeMode = ::com::sun::star::drawing::ShadeMode_DRAFT;
+ }
+
+ // get two sided lighting
+ const bool bTwoSidedLighting(((const Svx3DTwoSidedLightingItem&)rSet.Get(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING)).GetValue());
+
+ return attribute::SdrSceneAttribute(fDistance, fShadowSlant, aProjectionMode, aShadeMode, bTwoSidedLighting);
+ }
+
+ attribute::SdrLightingAttribute createNewSdrLightingAttribute(const SfxItemSet& rSet)
+ {
+ // extract lights from given SfxItemSet (from scene)
+ ::std::vector< attribute::Sdr3DLightAttribute > aLightVector;
+
+ if(((const Svx3DLightOnOff1Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor1Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection1Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, true));
+ }
+
+ if(((const Svx3DLightOnOff2Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor2Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection2Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff3Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor3Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection3Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff4Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor4Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection4Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff5Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor5Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection5Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff6Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor6Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection6Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff7Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor7Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection7Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ if(((const Svx3DLightOnOff8Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue())
+ {
+ const basegfx::BColor aColor(((const Svx3DLightcolor8Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue().getBColor());
+ const basegfx::B3DVector aDirection(((const Svx3DLightDirection8Item&)rSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue());
+ aLightVector.push_back(attribute::Sdr3DLightAttribute(aColor, aDirection, false));
+ }
+
+ // get ambient color
+ const Color aAmbientValue(((const Svx3DAmbientcolorItem&)rSet.Get(SDRATTR_3DSCENE_AMBIENTCOLOR)).GetValue());
+ const basegfx::BColor aAmbientLight(aAmbientValue.getBColor());
+
+ return attribute::SdrLightingAttribute(aAmbientLight, aLightVector);
+ }
+
+ void calculateRelativeCornerRadius(sal_Int32 nRadius, const basegfx::B2DRange& rObjectRange, double& rfCornerRadiusX, double& rfCornerRadiusY)
+ {
+ rfCornerRadiusX = rfCornerRadiusY = (double)nRadius;
+
+ if(0.0 != rfCornerRadiusX)
+ {
+ const double fHalfObjectWidth(rObjectRange.getWidth() * 0.5);
+
+ if(0.0 != fHalfObjectWidth)
+ {
+ if(rfCornerRadiusX < 0.0)
+ {
+ rfCornerRadiusX = 0.0;
+ }
+
+ if(rfCornerRadiusX > fHalfObjectWidth)
+ {
+ rfCornerRadiusX = fHalfObjectWidth;
+ }
+
+ rfCornerRadiusX /= fHalfObjectWidth;
+ }
+ else
+ {
+ rfCornerRadiusX = 0.0;
+ }
+ }
+
+ if(0.0 != rfCornerRadiusY)
+ {
+ const double fHalfObjectHeight(rObjectRange.getHeight() * 0.5);
+
+ if(0.0 != fHalfObjectHeight)
+ {
+ if(rfCornerRadiusY < 0.0)
+ {
+ rfCornerRadiusY = 0.0;
+ }
+
+ if(rfCornerRadiusY > fHalfObjectHeight)
+ {
+ rfCornerRadiusY = fHalfObjectHeight;
+ }
+
+ rfCornerRadiusY /= fHalfObjectHeight;
+ }
+ else
+ {
+ rfCornerRadiusY = 0.0;
+ }
+ }
+ }
+
+ // #i101508# Support handing over given text-to-border distances
+ attribute::SdrFillTextAttribute createNewSdrFillTextAttribute(
+ const SfxItemSet& rSet,
+ const SdrText* pText,
+ const sal_Int32* pLeft,
+ const sal_Int32* pUpper,
+ const sal_Int32* pRight,
+ const sal_Int32* pLower)
+ {
+ attribute::SdrFillAttribute aFill;
+ attribute::FillGradientAttribute aFillFloatTransGradient;
+ attribute::SdrTextAttribute aText;
+ bool bFontworkHideContour(false);
+
+ // look for text first
+ if(pText)
+ {
+ aText = createNewSdrTextAttribute(rSet, *pText, pLeft, pUpper, pRight, pLower);
+
+ // when object has text and text is fontwork and hide contour is set for fontwork, force
+ // fill style to empty
+ if(!aText.getSdrFormTextAttribute().isDefault() && aText.isHideContour())
+ {
+ bFontworkHideContour = true;
+ }
+ }
+
+ if(!bFontworkHideContour)
+ {
+ // try fill style
+ aFill = createNewSdrFillAttribute(rSet);
+
+ if(!aFill.isDefault())
+ {
+ // try fillfloattransparence
+ aFillFloatTransGradient = createNewTransparenceGradientAttribute(rSet);
+ }
+ }
+
+ if(!aFill.isDefault() || !aText.isDefault())
+ {
+ return attribute::SdrFillTextAttribute(aFill, aFillFloatTransGradient, aText);
+ }
+
+ return attribute::SdrFillTextAttribute();
+ }
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx
new file mode 100644
index 000000000000..10a78cda73bb
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx
@@ -0,0 +1,180 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrCaptionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect(
+ basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
+ getCornerRadiusX(),
+ getCornerRadiusY()));
+
+ // add fill
+ if(getSdrLFSTAttribute().getFill().isDefault())
+ {
+ // create invisible fill for HitTest
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ true,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ if(getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // create invisible line for HitTest/BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(getTail()),
+ getTransform()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ getTail(),
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ getSdrLFSTAttribute().getLineStartEnd()));
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrCaptionPrimitive2D::SdrCaptionPrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
+ const basegfx::B2DPolygon& rTail,
+ double fCornerRadiusX,
+ double fCornerRadiusY)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute),
+ maTail(rTail),
+ mfCornerRadiusX(fCornerRadiusX),
+ mfCornerRadiusY(fCornerRadiusY)
+ {
+ // transform maTail to unit polygon
+ if(getTail().count())
+ {
+ basegfx::B2DHomMatrix aInverse(getTransform());
+ aInverse.invert();
+ maTail.transform(aInverse);
+ }
+ }
+
+ bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrCaptionPrimitive2D& rCompare = (SdrCaptionPrimitive2D&)rPrimitive;
+
+ return (getCornerRadiusX() == rCompare.getCornerRadiusX()
+ && getCornerRadiusY() == rCompare.getCornerRadiusY()
+ && getTail() == rCompare.getTail()
+ && getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrCaptionPrimitive2D, PRIMITIVE2D_ID_SDRCAPTIONPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx
new file mode 100644
index 000000000000..a87473f7ceac
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrconnectorprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrConnectorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // add line
+ if(getSdrLSTAttribute().getLine().isDefault())
+ {
+ // create invisible line for HitTest/BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(getUnitPolygon())));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ getUnitPolygon(),
+ basegfx::B2DHomMatrix(),
+ getSdrLSTAttribute().getLine(),
+ getSdrLSTAttribute().getLineStartEnd()));
+ }
+
+ // add text
+ if(!getSdrLSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(getUnitPolygon()),
+ basegfx::B2DHomMatrix(),
+ getSdrLSTAttribute().getText(),
+ getSdrLSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrConnectorPrimitive2D::SdrConnectorPrimitive2D(
+ const attribute::SdrLineShadowTextAttribute& rSdrLSTAttribute,
+ const ::basegfx::B2DPolygon& rUnitPolygon)
+ : BufferedDecompositionPrimitive2D(),
+ maSdrLSTAttribute(rSdrLSTAttribute),
+ maUnitPolygon(rUnitPolygon)
+ {
+ }
+
+ bool SdrConnectorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrConnectorPrimitive2D& rCompare = (SdrConnectorPrimitive2D&)rPrimitive;
+
+ return (getUnitPolygon() == rCompare.getUnitPolygon()
+ && getSdrLSTAttribute() == rCompare.getSdrLSTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrConnectorPrimitive2D, PRIMITIVE2D_ID_SDRCONNECTORPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx
new file mode 100644
index 000000000000..25e48eb361de
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx
@@ -0,0 +1,133 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/attribute/sdrlineattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrCustomShapePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval(getSubPrimitives());
+
+ // add text
+ if(!getSdrSTAttribute().getText().isDefault())
+ {
+ const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTextBox(),
+ getSdrSTAttribute().getText(),
+ attribute::SdrLineAttribute(),
+ false,
+ getWordWrap(),
+ isForceTextClipToTextRange()));
+ }
+
+ // add shadow
+ if(aRetval.hasElements() && !getSdrSTAttribute().getShadow().isDefault())
+ {
+ // #i105323# add generic shadow only for 2D shapes. For
+ // 3D shapes shadow will be set at the individual created
+ // visualisation objects and be visualized by the 3d renderer
+ // as a single shadow.
+ //
+ // The shadow for AutoShapes could be handled uniformely by not setting any
+ // shadow items at the helper model objects and only adding shadow here for
+ // 2D and 3D (and it works, too), but this would lead to two 3D scenes for
+ // the 3D object; one for the shadow aond one for the content. The one for the
+ // shadow will be correct (using ColorModifierStack), but expensive.
+ if(!get3DShape())
+ {
+ aRetval = createEmbeddedShadowPrimitive(aRetval, getSdrSTAttribute().getShadow());
+ }
+ }
+
+ return aRetval;
+ }
+
+ SdrCustomShapePrimitive2D::SdrCustomShapePrimitive2D(
+ const attribute::SdrShadowTextAttribute& rSdrSTAttribute,
+ const Primitive2DSequence& rSubPrimitives,
+ const basegfx::B2DHomMatrix& rTextBox,
+ bool bWordWrap,
+ bool b3DShape,
+ bool bForceTextClipToTextRange)
+ : BufferedDecompositionPrimitive2D(),
+ maSdrSTAttribute(rSdrSTAttribute),
+ maSubPrimitives(rSubPrimitives),
+ maTextBox(rTextBox),
+ mbWordWrap(bWordWrap),
+ mb3DShape(b3DShape),
+ mbForceTextClipToTextRange(bForceTextClipToTextRange)
+ {
+ }
+
+ bool SdrCustomShapePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrCustomShapePrimitive2D& rCompare = (SdrCustomShapePrimitive2D&)rPrimitive;
+
+ return (getSdrSTAttribute() == rCompare.getSdrSTAttribute()
+ && getSubPrimitives() == rCompare.getSubPrimitives()
+ && getTextBox() == rCompare.getTextBox()
+ && getWordWrap() == rCompare.getWordWrap()
+ && get3DShape() == rCompare.get3DShape()
+ && isForceTextClipToTextRange() == rCompare.isForceTextClipToTextRange());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrCustomShapePrimitive2D, PRIMITIVE2D_ID_SDRCUSTOMSHAPEPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
new file mode 100644
index 000000000000..482542265531
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx
@@ -0,0 +1,494 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/baseprimitive2d.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
+#include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
+#include <drawinglayer/attribute/strokeattribute.hxx>
+#include <drawinglayer/attribute/linestartendattribute.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/primitive2d/shadowprimitive2d.hxx>
+#include <svx/sdr/attribute/sdrtextattribute.hxx>
+#include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
+#include <svx/svdotext.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <drawinglayer/primitive2d/animatedprimitive2d.hxx>
+#include <drawinglayer/animation/animationtiming.hxx>
+#include <drawinglayer/primitive2d/maskprimitive2d.hxx>
+#include <basegfx/tools/canvastools.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
+#include <drawinglayer/attribute/sdrfillattribute.hxx>
+#include <drawinglayer/attribute/sdrlineattribute.hxx>
+#include <drawinglayer/attribute/sdrlinestartendattribute.hxx>
+#include <drawinglayer/attribute/sdrshadowattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DReference createPolyPolygonFillPrimitive(
+ const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
+ const basegfx::B2DHomMatrix& rObjectTransform,
+ const attribute::SdrFillAttribute& rFill,
+ const attribute::FillGradientAttribute& rFillGradient)
+ {
+ // prepare fully scaled polygon
+ basegfx::B2DPolyPolygon aScaledPolyPolygon(rUnitPolyPolygon);
+ aScaledPolyPolygon.transform(rObjectTransform);
+ BasePrimitive2D* pNewFillPrimitive = 0;
+
+ if(!rFill.getGradient().isDefault())
+ {
+ pNewFillPrimitive = new PolyPolygonGradientPrimitive2D(aScaledPolyPolygon, rFill.getGradient());
+ }
+ else if(!rFill.getHatch().isDefault())
+ {
+ pNewFillPrimitive = new PolyPolygonHatchPrimitive2D(aScaledPolyPolygon, rFill.getColor(), rFill.getHatch());
+ }
+ else if(!rFill.getBitmap().isDefault())
+ {
+ const basegfx::B2DRange aRange(basegfx::tools::getRange(aScaledPolyPolygon));
+ pNewFillPrimitive = new PolyPolygonBitmapPrimitive2D(aScaledPolyPolygon, rFill.getBitmap().getFillBitmapAttribute(aRange));
+ }
+ else
+ {
+ pNewFillPrimitive = new PolyPolygonColorPrimitive2D(aScaledPolyPolygon, rFill.getColor());
+ }
+
+ if(0.0 != rFill.getTransparence())
+ {
+ // create simpleTransparencePrimitive, add created fill primitive
+ const Primitive2DReference xRefA(pNewFillPrimitive);
+ const Primitive2DSequence aContent(&xRefA, 1L);
+ return Primitive2DReference(new UnifiedTransparencePrimitive2D(aContent, rFill.getTransparence()));
+ }
+ else if(!rFillGradient.isDefault())
+ {
+ // create sequence with created fill primitive
+ const Primitive2DReference xRefA(pNewFillPrimitive);
+ const Primitive2DSequence aContent(&xRefA, 1L);
+
+ // create FillGradientPrimitive2D for transparence and add to new sequence
+ // fillGradientPrimitive is enough here (compared to PolyPolygonGradientPrimitive2D) since float transparence will be masked anyways
+ const basegfx::B2DRange aRange(basegfx::tools::getRange(aScaledPolyPolygon));
+ const Primitive2DReference xRefB(new FillGradientPrimitive2D(aRange, rFillGradient));
+ const Primitive2DSequence aAlpha(&xRefB, 1L);
+
+ // create TransparencePrimitive2D using alpha and content
+ return Primitive2DReference(new TransparencePrimitive2D(aContent, aAlpha));
+ }
+ else
+ {
+ // add to decomposition
+ return Primitive2DReference(pNewFillPrimitive);
+ }
+ }
+
+ Primitive2DReference createPolygonLinePrimitive(
+ const basegfx::B2DPolygon& rUnitPolygon,
+ const basegfx::B2DHomMatrix& rObjectTransform,
+ const attribute::SdrLineAttribute& rLine,
+ const attribute::SdrLineStartEndAttribute& rStroke)
+ {
+ // prepare fully scaled polygon
+ basegfx::B2DPolygon aScaledPolygon(rUnitPolygon);
+ aScaledPolygon.transform(rObjectTransform);
+
+ // create line and stroke attribute
+ const attribute::LineAttribute aLineAttribute(rLine.getColor(), rLine.getWidth(), rLine.getJoin());
+ const attribute::StrokeAttribute aStrokeAttribute(rLine.getDotDashArray(), rLine.getFullDotDashLen());
+ BasePrimitive2D* pNewLinePrimitive = 0L;
+
+ if(!rUnitPolygon.isClosed() && !rStroke.isDefault())
+ {
+ attribute::LineStartEndAttribute aStart(rStroke.getStartWidth(), rStroke.getStartPolyPolygon(), rStroke.isStartCentered());
+ attribute::LineStartEndAttribute aEnd(rStroke.getEndWidth(), rStroke.getEndPolyPolygon(), rStroke.isEndCentered());
+
+ // create data
+ pNewLinePrimitive = new PolygonStrokeArrowPrimitive2D(aScaledPolygon, aLineAttribute, aStrokeAttribute, aStart, aEnd);
+ }
+ else
+ {
+ // create data
+ pNewLinePrimitive = new PolygonStrokePrimitive2D(aScaledPolygon, aLineAttribute, aStrokeAttribute);
+ }
+
+ if(0.0 != rLine.getTransparence())
+ {
+ // create simpleTransparencePrimitive, add created fill primitive
+ const Primitive2DReference xRefA(pNewLinePrimitive);
+ const Primitive2DSequence aContent(&xRefA, 1L);
+ return Primitive2DReference(new UnifiedTransparencePrimitive2D(aContent, rLine.getTransparence()));
+ }
+ else
+ {
+ // add to decomposition
+ return Primitive2DReference(pNewLinePrimitive);
+ }
+ }
+
+ Primitive2DReference createTextPrimitive(
+ const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
+ const basegfx::B2DHomMatrix& rObjectTransform,
+ const attribute::SdrTextAttribute& rText,
+ const attribute::SdrLineAttribute& rStroke,
+ bool bCellText,
+ bool bWordWrap,
+ bool bClipOnBounds)
+ {
+ basegfx::B2DHomMatrix aAnchorTransform(rObjectTransform);
+ SdrTextPrimitive2D* pNew = 0;
+
+ if(rText.isContour())
+ {
+ // contour text
+ if(!rStroke.isDefault() && 0.0 != rStroke.getWidth())
+ {
+ // take line width into account and shrink contour polygon accordingly
+ // decompose to get scale
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // scale outline to object's size to allow growing with value relative to that size
+ // and also to keep aspect ratio
+ basegfx::B2DPolyPolygon aScaledUnitPolyPolygon(rUnitPolyPolygon);
+ aScaledUnitPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(
+ fabs(aScale.getX()), fabs(aScale.getY())));
+
+ // grow the polygon. To shrink, use negative value (half width)
+ aScaledUnitPolyPolygon = basegfx::tools::growInNormalDirection(aScaledUnitPolyPolygon, -(rStroke.getWidth() * 0.5));
+
+ // scale back to unit polygon
+ aScaledUnitPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(
+ 0.0 != aScale.getX() ? 1.0 / aScale.getX() : 1.0,
+ 0.0 != aScale.getY() ? 1.0 / aScale.getY() : 1.0));
+
+ // create with unit polygon
+ pNew = new SdrContourTextPrimitive2D(
+ &rText.getSdrText(),
+ rText.getOutlinerParaObject(),
+ aScaledUnitPolyPolygon,
+ rObjectTransform);
+ }
+ else
+ {
+ // create with unit polygon
+ pNew = new SdrContourTextPrimitive2D(
+ &rText.getSdrText(),
+ rText.getOutlinerParaObject(),
+ rUnitPolyPolygon,
+ rObjectTransform);
+ }
+ }
+ else if(!rText.getSdrFormTextAttribute().isDefault())
+ {
+ // text on path, use scaled polygon
+ basegfx::B2DPolyPolygon aScaledPolyPolygon(rUnitPolyPolygon);
+ aScaledPolyPolygon.transform(rObjectTransform);
+ pNew = new SdrPathTextPrimitive2D(
+ &rText.getSdrText(),
+ rText.getOutlinerParaObject(),
+ aScaledPolyPolygon,
+ rText.getSdrFormTextAttribute());
+ }
+ else
+ {
+ // rObjectTransform is the whole SdrObject transformation from unit rectangle
+ // to it's size and position. Decompose to allow working with single values.
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // extract mirroring
+ const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
+ const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
+ aScale = basegfx::absolute(aScale);
+
+ // Get the real size, since polygon ountline and scale
+ // from the object transformation may vary (e.g. ellipse segments)
+ basegfx::B2DHomMatrix aJustScaleTransform;
+ aJustScaleTransform.set(0, 0, aScale.getX());
+ aJustScaleTransform.set(1, 1, aScale.getY());
+ basegfx::B2DPolyPolygon aScaledUnitPolyPolygon(rUnitPolyPolygon);
+ aScaledUnitPolyPolygon.transform(aJustScaleTransform);
+ const basegfx::B2DRange aSnapRange(basegfx::tools::getRange(aScaledUnitPolyPolygon));
+
+ // create a range describing the wanted text position and size (aTextAnchorRange). This
+ // means to use the text distance values here
+ const basegfx::B2DPoint aTopLeft(aSnapRange.getMinX() + rText.getTextLeftDistance(), aSnapRange.getMinY() + rText.getTextUpperDistance());
+ const basegfx::B2DPoint aBottomRight(aSnapRange.getMaxX() - rText.getTextRightDistance(), aSnapRange.getMaxY() - rText.getTextLowerDistance());
+ basegfx::B2DRange aTextAnchorRange;
+ aTextAnchorRange.expand(aTopLeft);
+ aTextAnchorRange.expand(aBottomRight);
+
+ // now create a transformation from this basic range (aTextAnchorRange)
+ aAnchorTransform = basegfx::tools::createScaleTranslateB2DHomMatrix(
+ aTextAnchorRange.getWidth(), aTextAnchorRange.getHeight(),
+ aTextAnchorRange.getMinX(), aTextAnchorRange.getMinY());
+
+ // apply mirroring
+ aAnchorTransform.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0);
+
+ // apply object's other transforms
+ aAnchorTransform = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate)
+ * aAnchorTransform;
+
+ if(rText.isFitToSize())
+ {
+ // streched text in range
+ pNew = new SdrStretchTextPrimitive2D(
+ &rText.getSdrText(),
+ rText.getOutlinerParaObject(),
+ aAnchorTransform,
+ rText.isFixedCellHeight());
+ }
+ else if(rText.isAutoFit())
+ {
+ // isotrophically scaled text in range
+ pNew = new SdrAutoFitTextPrimitive2D(&rText.getSdrText(), rText.getOutlinerParaObject(), aAnchorTransform, bWordWrap);
+ }
+ else // text in range
+ {
+ // build new primitive
+ pNew = new SdrBlockTextPrimitive2D(
+ &rText.getSdrText(),
+ rText.getOutlinerParaObject(),
+ aAnchorTransform,
+ rText.getSdrTextHorzAdjust(),
+ rText.getSdrTextVertAdjust(),
+ rText.isFixedCellHeight(),
+ rText.isScroll(),
+ bCellText,
+ bWordWrap,
+ bClipOnBounds);
+ }
+ }
+
+ OSL_ENSURE(pNew != 0, "createTextPrimitive: no text primitive created (!)");
+
+ if(rText.isBlink())
+ {
+ // prepare animation and primitive list
+ drawinglayer::animation::AnimationEntryList aAnimationList;
+ rText.getBlinkTextTiming(aAnimationList);
+
+ if(0.0 != aAnimationList.getDuration())
+ {
+ // create content sequence
+ const Primitive2DReference xRefA(pNew);
+ const Primitive2DSequence aContent(&xRefA, 1L);
+
+ // create and add animated switch primitive
+ return Primitive2DReference(new AnimatedBlinkPrimitive2D(aAnimationList, aContent, true));
+ }
+ else
+ {
+ // add to decomposition
+ return Primitive2DReference(pNew);
+ }
+ }
+
+ if(rText.isScroll())
+ {
+ // suppress scroll when FontWork
+ if(rText.getSdrFormTextAttribute().isDefault())
+ {
+ // get scroll direction
+ const SdrTextAniDirection eDirection(rText.getSdrText().GetObject().GetTextAniDirection());
+ const bool bHorizontal(SDRTEXTANI_LEFT == eDirection || SDRTEXTANI_RIGHT == eDirection);
+
+ // decompose to get separated values for the scroll box
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ aAnchorTransform.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // build transform from scaled only to full AnchorTransform and inverse
+ const basegfx::B2DHomMatrix aSRT(basegfx::tools::createShearXRotateTranslateB2DHomMatrix(
+ fShearX, fRotate, aTranslate));
+ basegfx::B2DHomMatrix aISRT(aSRT);
+ aISRT.invert();
+
+ // bring the primitive back to scaled only and get scaled range, create new clone for this
+ SdrTextPrimitive2D* pNew2 = pNew->createTransformedClone(aISRT);
+ OSL_ENSURE(pNew2, "createTextPrimitive: Could not create transformed clone of text primitive (!)");
+ delete pNew;
+ pNew = pNew2;
+
+ // create neutral geometry::ViewInformation2D for local range and decompose calls. This is okay
+ // since the decompose is view-independent
+ const uno::Sequence< beans::PropertyValue > xViewParameters;
+ geometry::ViewInformation2D aViewInformation2D(xViewParameters);
+
+ // get range
+ const basegfx::B2DRange aScaledRange(pNew->getB2DRange(aViewInformation2D));
+
+ // create left outside and right outside transformations. Also take care
+ // of the clip rectangle
+ basegfx::B2DHomMatrix aLeft, aRight;
+ basegfx::B2DPoint aClipTopLeft(0.0, 0.0);
+ basegfx::B2DPoint aClipBottomRight(aScale.getX(), aScale.getY());
+
+ if(bHorizontal)
+ {
+ aClipTopLeft.setY(aScaledRange.getMinY());
+ aClipBottomRight.setY(aScaledRange.getMaxY());
+ aLeft.translate(-aScaledRange.getMaxX(), 0.0);
+ aRight.translate(aScale.getX() - aScaledRange.getMinX(), 0.0);
+ }
+ else
+ {
+ aClipTopLeft.setX(aScaledRange.getMinX());
+ aClipBottomRight.setX(aScaledRange.getMaxX());
+ aLeft.translate(0.0, -aScaledRange.getMaxY());
+ aRight.translate(0.0, aScale.getY() - aScaledRange.getMinY());
+ }
+
+ aLeft *= aSRT;
+ aRight *= aSRT;
+
+ // prepare animation list
+ drawinglayer::animation::AnimationEntryList aAnimationList;
+
+ if(bHorizontal)
+ {
+ rText.getScrollTextTiming(aAnimationList, aScale.getX(), aScaledRange.getWidth());
+ }
+ else
+ {
+ rText.getScrollTextTiming(aAnimationList, aScale.getY(), aScaledRange.getHeight());
+ }
+
+ if(0.0 != aAnimationList.getDuration())
+ {
+ // create a new Primitive2DSequence containing the animated text in it's scaled only state.
+ // use the decomposition to force to simple text primitives, those will no longer
+ // need the outliner for formatting (alternatively it is also possible to just add
+ // pNew to aNewPrimitiveSequence)
+ Primitive2DSequence aAnimSequence(pNew->get2DDecomposition(aViewInformation2D));
+ delete pNew;
+
+ // create a new animatedInterpolatePrimitive and add it
+ std::vector< basegfx::B2DHomMatrix > aMatrixStack;
+ aMatrixStack.push_back(aLeft);
+ aMatrixStack.push_back(aRight);
+ const Primitive2DReference xRefA(new AnimatedInterpolatePrimitive2D(aMatrixStack, aAnimationList, aAnimSequence, true));
+ const Primitive2DSequence aContent(&xRefA, 1L);
+
+ // scrolling needs an encapsulating clipping primitive
+ const basegfx::B2DRange aClipRange(aClipTopLeft, aClipBottomRight);
+ basegfx::B2DPolygon aClipPolygon(basegfx::tools::createPolygonFromRect(aClipRange));
+ aClipPolygon.transform(aSRT);
+ return Primitive2DReference(new MaskPrimitive2D(basegfx::B2DPolyPolygon(aClipPolygon), aContent));
+ }
+ else
+ {
+ // add to decomposition
+ return Primitive2DReference(pNew);
+ }
+ }
+ }
+
+ if(rText.isInEditMode())
+ {
+ // #i97628#
+ // encapsulate with TextHierarchyEditPrimitive2D to allow renderers
+ // to suppress actively edited content if needed
+ const Primitive2DReference xRefA(pNew);
+ const Primitive2DSequence aContent(&xRefA, 1L);
+
+ // create and add TextHierarchyEditPrimitive2D primitive
+ return Primitive2DReference(new TextHierarchyEditPrimitive2D(aContent));
+ }
+ else
+ {
+ // add to decomposition
+ return Primitive2DReference(pNew);
+ }
+ }
+
+ Primitive2DSequence createEmbeddedShadowPrimitive(
+ const Primitive2DSequence& rContent,
+ const attribute::SdrShadowAttribute& rShadow)
+ {
+ if(rContent.hasElements())
+ {
+ Primitive2DSequence aRetval(2);
+ basegfx::B2DHomMatrix aShadowOffset;
+
+ // prepare shadow offset
+ aShadowOffset.set(0, 2, rShadow.getOffset().getX());
+ aShadowOffset.set(1, 2, rShadow.getOffset().getY());
+
+ // create shadow primitive and add content
+ aRetval[0] = Primitive2DReference(
+ new ShadowPrimitive2D(
+ aShadowOffset,
+ rShadow.getColor(),
+ rContent));
+
+ if(0.0 != rShadow.getTransparence())
+ {
+ // create SimpleTransparencePrimitive2D
+ const Primitive2DSequence aTempContent(&aRetval[0], 1);
+
+ aRetval[0] = Primitive2DReference(
+ new UnifiedTransparencePrimitive2D(
+ aTempContent,
+ rShadow.getTransparence()));
+ }
+
+ aRetval[1] = Primitive2DReference(new GroupPrimitive2D(rContent));
+ return aRetval;
+ }
+ else
+ {
+ return rContent;
+ }
+ }
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx
new file mode 100644
index 000000000000..cce345bc3152
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx
@@ -0,0 +1,281 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrellipseprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrEllipsePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ // Do use createPolygonFromUnitCircle, but let create from first quadrant to mimic old geometry creation.
+ // This is needed to have the same look when stroke is used since the polygon start point defines the
+ // stroke start, too.
+ basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromUnitCircle(1));
+
+ // scale and move UnitEllipse to UnitObject (-1,-1 1,1) -> (0,0 1,1)
+ const basegfx::B2DHomMatrix aUnitCorrectionMatrix(
+ basegfx::tools::createScaleTranslateB2DHomMatrix(0.5, 0.5, 0.5, 0.5));
+
+ // apply to the geometry
+ aUnitOutline.transform(aUnitCorrectionMatrix);
+
+ // add fill
+ if(!getSdrLFSTAttribute().getFill().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ if(getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // create invisible line for HitTest/BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrEllipsePrimitive2D::SdrEllipsePrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute)
+ {
+ }
+
+ bool SdrEllipsePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrEllipsePrimitive2D& rCompare = (SdrEllipsePrimitive2D&)rPrimitive;
+
+ return (getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrEllipsePrimitive2D, PRIMITIVE2D_ID_SDRELLIPSEPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrEllipseSegmentPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromUnitEllipseSegment(mfStartAngle, mfEndAngle));
+
+ if(mbCloseSegment)
+ {
+ if(mbCloseUsingCenter)
+ {
+ // for compatibility, insert the center point at polygon start to get the same
+ // line stroking pattern as the old painting mechanisms.
+ aUnitOutline.insert(0L, basegfx::B2DPoint(0.0, 0.0));
+ }
+
+ aUnitOutline.setClosed(true);
+ }
+
+ // move and scale UnitEllipse to UnitObject (-1,-1 1,1) -> (0,0 1,1)
+ const basegfx::B2DHomMatrix aUnitCorrectionMatrix(
+ basegfx::tools::createScaleTranslateB2DHomMatrix(0.5, 0.5, 0.5, 0.5));
+
+ // apply to the geometry
+ aUnitOutline.transform(aUnitCorrectionMatrix);
+
+ // add fill
+ if(!getSdrLFSTAttribute().getFill().isDefault() && aUnitOutline.isClosed())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ if(getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // create invisible line for HitTest/BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ getSdrLFSTAttribute().getLineStartEnd()));
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrEllipseSegmentPrimitive2D::SdrEllipseSegmentPrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
+ double fStartAngle,
+ double fEndAngle,
+ bool bCloseSegment,
+ bool bCloseUsingCenter)
+ : SdrEllipsePrimitive2D(rTransform, rSdrLFSTAttribute),
+ mfStartAngle(fStartAngle),
+ mfEndAngle(fEndAngle),
+ mbCloseSegment(bCloseSegment),
+ mbCloseUsingCenter(bCloseUsingCenter)
+ {
+ }
+
+ bool SdrEllipseSegmentPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrEllipsePrimitive2D::operator==(rPrimitive))
+ {
+ const SdrEllipseSegmentPrimitive2D& rCompare = (SdrEllipseSegmentPrimitive2D&)rPrimitive;
+
+ if( mfStartAngle == rCompare.mfStartAngle
+ && mfEndAngle == rCompare.mfEndAngle
+ && mbCloseSegment == rCompare.mbCloseSegment
+ && mbCloseUsingCenter == rCompare.mbCloseUsingCenter)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrEllipseSegmentPrimitive2D, PRIMITIVE2D_ID_SDRELLIPSESEGMENTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx
new file mode 100644
index 000000000000..c611b4c7c966
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx
@@ -0,0 +1,180 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrgrafprimitive2d.hxx>
+#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrGrafPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
+
+ // add fill, but only when graphic ist transparent
+ if(!getSdrLFSTAttribute().getFill().isDefault() && isTransparent())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ if(!getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // if line width is given, polygon needs to be grown by half of it to make the
+ // outline to be outside of the bitmap
+ if(0.0 != getSdrLFSTAttribute().getLine().getWidth())
+ {
+ // decompose to get scale
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // create expanded range (add relative half line width to unit rectangle)
+ double fHalfLineWidth(getSdrLFSTAttribute().getLine().getWidth() * 0.5);
+ double fScaleX(0.0 != aScale.getX() ? fHalfLineWidth / fabs(aScale.getX()) : 1.0);
+ double fScaleY(0.0 != aScale.getY() ? fHalfLineWidth / fabs(aScale.getY()) : 1.0);
+ const basegfx::B2DRange aExpandedRange(-fScaleX, -fScaleY, 1.0 + fScaleX, 1.0 + fScaleY);
+ basegfx::B2DPolygon aExpandedUnitOutline(basegfx::tools::createPolygonFromRect(aExpandedRange));
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aExpandedUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline, getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+ }
+
+ // add graphic content
+ if(255L != getGraphicAttr().GetTransparency())
+ {
+ const Primitive2DReference xGraphicContentPrimitive(
+ new GraphicPrimitive2D(
+ getTransform(),
+ getGraphicObject(),
+ getGraphicAttr()));
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xGraphicContentPrimitive);
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrGrafPrimitive2D::SdrGrafPrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
+ const GraphicObject& rGraphicObject,
+ const GraphicAttr& rGraphicAttr)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute),
+ maGraphicObject(rGraphicObject),
+ maGraphicAttr(rGraphicAttr)
+ {
+ // reset some values from GraphicAttr which are part of transformation already
+ maGraphicAttr.SetRotation(0L);
+ }
+
+ bool SdrGrafPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrGrafPrimitive2D& rCompare = (SdrGrafPrimitive2D&)rPrimitive;
+
+ return (getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()
+ && getGraphicObject() == rCompare.getGraphicObject()
+ && getGraphicAttr() == rCompare.getGraphicAttr());
+ }
+
+ return false;
+ }
+
+ bool SdrGrafPrimitive2D::isTransparent() const
+ {
+ return ((0L != getGraphicAttr().GetTransparency()) || (getGraphicObject().IsTransparent()));
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrGrafPrimitive2D, PRIMITIVE2D_ID_SDRGRAFPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx
new file mode 100644
index 000000000000..0ba9a65cb35e
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx
@@ -0,0 +1,513 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
+#include <svx/sdr/attribute/sdrtextattribute.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/tools/canvastools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DReference SdrMeasurePrimitive2D::impCreatePart(
+ const attribute::SdrLineAttribute& rLineAttribute,
+ const basegfx::B2DHomMatrix& rObjectMatrix,
+ const basegfx::B2DPoint& rStart,
+ const basegfx::B2DPoint& rEnd,
+ bool bLeftActive,
+ bool bRightActive) const
+ {
+ const attribute::SdrLineStartEndAttribute& rLineStartEnd = getSdrLSTAttribute().getLineStartEnd();
+ basegfx::B2DPolygon aPolygon;
+
+ aPolygon.append(rStart);
+ aPolygon.append(rEnd);
+
+ if(rLineStartEnd.isDefault() || (!bLeftActive && !bRightActive))
+ {
+ return createPolygonLinePrimitive(
+ aPolygon,
+ rObjectMatrix,
+ rLineAttribute,
+ attribute::SdrLineStartEndAttribute());
+ }
+
+ if(bLeftActive && bRightActive)
+ {
+ return createPolygonLinePrimitive(
+ aPolygon,
+ rObjectMatrix,
+ rLineAttribute,
+ rLineStartEnd);
+ }
+
+ const basegfx::B2DPolyPolygon aEmpty;
+ const attribute::SdrLineStartEndAttribute aLineStartEnd(
+ bLeftActive ? rLineStartEnd.getStartPolyPolygon() : aEmpty, bRightActive ? rLineStartEnd.getEndPolyPolygon() : aEmpty,
+ bLeftActive ? rLineStartEnd.getStartWidth() : 0.0, bRightActive ? rLineStartEnd.getEndWidth() : 0.0,
+ bLeftActive ? rLineStartEnd.isStartActive() : false, bRightActive ? rLineStartEnd.isEndActive() : false,
+ bLeftActive ? rLineStartEnd.isStartCentered() : false, bRightActive? rLineStartEnd.isEndCentered() : false);
+
+ return createPolygonLinePrimitive(aPolygon, rObjectMatrix, rLineAttribute, aLineStartEnd);
+ }
+
+ Primitive2DSequence SdrMeasurePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ SdrBlockTextPrimitive2D* pBlockText = 0;
+ basegfx::B2DRange aTextRange;
+ double fTextX((getStart().getX() + getEnd().getX()) * 0.5);
+ double fTextY((getStart().getX() + getEnd().getX()) * 0.5);
+ const basegfx::B2DVector aLine(getEnd() - getStart());
+ const double fDistance(aLine.getLength());
+ const double fAngle(atan2(aLine.getY(), aLine.getX()));
+ bool bAutoUpsideDown(false);
+ const attribute::SdrTextAttribute rTextAttribute = getSdrLSTAttribute().getText();
+ const basegfx::B2DHomMatrix aObjectMatrix(
+ basegfx::tools::createShearXRotateTranslateB2DHomMatrix(0.0, fAngle, getStart()));
+
+ // preapare text, but do not add yet; it needs to be aligned to
+ // the line geometry
+ if(!rTextAttribute.isDefault())
+ {
+ basegfx::B2DHomMatrix aTextMatrix;
+ double fTestAngle(fAngle);
+
+ if(getTextRotation())
+ {
+ aTextMatrix.rotate(-90.0 * F_PI180);
+ fTestAngle -= (90.0 * F_PI180);
+
+ if(getTextAutoAngle() && fTestAngle < -F_PI)
+ {
+ fTestAngle += F_2PI;
+ }
+ }
+
+ if(getTextAutoAngle())
+ {
+ if(fTestAngle > (F_PI / 4.0) || fTestAngle < (-F_PI * (3.0 / 4.0)))
+ {
+ bAutoUpsideDown = true;
+ }
+ }
+
+ // create primitive and get text range
+ pBlockText = new SdrBlockTextPrimitive2D(
+ &rTextAttribute.getSdrText(),
+ rTextAttribute.getOutlinerParaObject(),
+ aTextMatrix,
+ SDRTEXTHORZADJUST_CENTER,
+ SDRTEXTVERTADJUST_CENTER,
+ rTextAttribute.isScroll(),
+ false,
+ false,
+ false,
+ false);
+
+ aTextRange = pBlockText->getB2DRange(aViewInformation);
+ }
+
+ // prepare line attribute and result
+ {
+ const attribute::SdrLineAttribute rLineAttribute(getSdrLSTAttribute().getLine());
+ bool bArrowsOutside(false);
+ bool bMainLineSplitted(false);
+ const attribute::SdrLineStartEndAttribute& rLineStartEnd = getSdrLSTAttribute().getLineStartEnd();
+ double fStartArrowW(0.0);
+ double fStartArrowH(0.0);
+ double fEndArrowW(0.0);
+ double fEndArrowH(0.0);
+
+ if(!rLineStartEnd.isDefault())
+ {
+ if(rLineStartEnd.isStartActive())
+ {
+ const basegfx::B2DRange aArrowRange(basegfx::tools::getRange(rLineStartEnd.getStartPolyPolygon()));
+ fStartArrowW = rLineStartEnd.getStartWidth();
+ fStartArrowH = aArrowRange.getHeight() * fStartArrowW / aArrowRange.getWidth();
+
+ if(rLineStartEnd.isStartCentered())
+ {
+ fStartArrowH *= 0.5;
+ }
+ }
+
+ if(rLineStartEnd.isEndActive())
+ {
+ const basegfx::B2DRange aArrowRange(basegfx::tools::getRange(rLineStartEnd.getEndPolyPolygon()));
+ fEndArrowW = rLineStartEnd.getEndWidth();
+ fEndArrowH = aArrowRange.getHeight() * fEndArrowW / aArrowRange.getWidth();
+
+ if(rLineStartEnd.isEndCentered())
+ {
+ fEndArrowH *= 0.5;
+ }
+ }
+ }
+
+ const double fSpaceNeededByArrows(fStartArrowH + fEndArrowH + ((fStartArrowW + fEndArrowW) * 0.5));
+ const double fArrowsOutsideLen((fStartArrowH + fEndArrowH + fStartArrowW + fEndArrowW) * 0.5);
+ const double fHalfLineWidth(rLineAttribute.getWidth() * 0.5);
+
+ if(fSpaceNeededByArrows > fDistance)
+ {
+ bArrowsOutside = true;
+ }
+
+ MeasureTextPosition eHorizontal(getHorizontal());
+ MeasureTextPosition eVertical(getVertical());
+
+ if(MEASURETEXTPOSITION_AUTOMATIC == eVertical)
+ {
+ eVertical = MEASURETEXTPOSITION_NEGATIVE;
+ }
+
+ if(MEASURETEXTPOSITION_CENTERED == eVertical)
+ {
+ bMainLineSplitted = true;
+ }
+
+ if(MEASURETEXTPOSITION_AUTOMATIC == eHorizontal)
+ {
+ if(aTextRange.getWidth() > fDistance)
+ {
+ eHorizontal = MEASURETEXTPOSITION_NEGATIVE;
+ }
+ else
+ {
+ eHorizontal = MEASURETEXTPOSITION_CENTERED;
+ }
+
+ if(bMainLineSplitted)
+ {
+ if(aTextRange.getWidth() + fSpaceNeededByArrows > fDistance)
+ {
+ bArrowsOutside = true;
+ }
+ }
+ else
+ {
+ const double fSmallArrowNeed(fStartArrowH + fEndArrowH + ((fStartArrowW + fEndArrowW) * 0.125));
+
+ if(aTextRange.getWidth() + fSmallArrowNeed > fDistance)
+ {
+ bArrowsOutside = true;
+ }
+ }
+ }
+
+ if(MEASURETEXTPOSITION_CENTERED != eHorizontal)
+ {
+ bArrowsOutside = true;
+ }
+
+ // switch text above/below?
+ if(getBelow() || (bAutoUpsideDown && !getTextRotation()))
+ {
+ if(MEASURETEXTPOSITION_NEGATIVE == eVertical)
+ {
+ eVertical = MEASURETEXTPOSITION_POSITIVE;
+ }
+ else if(MEASURETEXTPOSITION_POSITIVE == eVertical)
+ {
+ eVertical = MEASURETEXTPOSITION_NEGATIVE;
+ }
+ }
+
+ const double fMainLineOffset(getBelow() ? getDistance() : -getDistance());
+ const basegfx::B2DPoint aMainLeft(0.0, fMainLineOffset);
+ const basegfx::B2DPoint aMainRight(fDistance, fMainLineOffset);
+
+ // main line
+ if(bArrowsOutside)
+ {
+ double fLenLeft(fArrowsOutsideLen);
+ double fLenRight(fArrowsOutsideLen);
+
+ if(!bMainLineSplitted)
+ {
+ if(MEASURETEXTPOSITION_NEGATIVE == eHorizontal)
+ {
+ fLenLeft = fStartArrowH + aTextRange.getWidth();
+ }
+ else if(MEASURETEXTPOSITION_POSITIVE == eHorizontal)
+ {
+ fLenRight = fEndArrowH + aTextRange.getWidth();
+ }
+ }
+
+ const basegfx::B2DPoint aMainLeftLeft(aMainLeft.getX() - fLenLeft, aMainLeft.getY());
+ const basegfx::B2DPoint aMainRightRight(aMainRight.getX() + fLenRight, aMainRight.getY());
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeftLeft, aMainLeft, false, true));
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainRight, aMainRightRight, true, false));
+
+ if(!bMainLineSplitted || MEASURETEXTPOSITION_CENTERED != eHorizontal)
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainRight, false, false));
+ }
+ }
+ else
+ {
+ if(bMainLineSplitted)
+ {
+ const double fHalfLength((fDistance - (aTextRange.getWidth() + (fStartArrowH + fEndArrowH) * 0.25)) * 0.5);
+ const basegfx::B2DPoint aMainInnerLeft(aMainLeft.getX() + fHalfLength, aMainLeft.getY());
+ const basegfx::B2DPoint aMainInnerRight(aMainRight.getX() - fHalfLength, aMainRight.getY());
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainInnerLeft, true, false));
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainInnerRight, aMainRight, false, true));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aMainLeft, aMainRight, true, true));
+ }
+ }
+
+ // left/right help line value preparation
+ const double fTopEdge(getBelow() ? getUpper() + getDistance() : -getUpper() - getDistance());
+ const double fBottomLeft(getBelow() ? getLower() - getLeftDelta() : getLeftDelta() - getLower());
+ const double fBottomRight(getBelow() ? getLower() - getRightDelta() : getRightDelta() - getLower());
+
+ // left help line
+ const basegfx::B2DPoint aLeftUp(0.0, fTopEdge);
+ const basegfx::B2DPoint aLeftDown(0.0, fBottomLeft);
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aLeftDown, aLeftUp, false, false));
+
+ // right help line
+ const basegfx::B2DPoint aRightUp(fDistance, fTopEdge);
+ const basegfx::B2DPoint aRightDown(fDistance, fBottomRight);
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, impCreatePart(rLineAttribute, aObjectMatrix, aRightDown, aRightUp, false, false));
+
+ // text horizontal position
+ if(MEASURETEXTPOSITION_NEGATIVE == eHorizontal)
+ {
+ // left
+ const double fSmall(fArrowsOutsideLen * 0.18);
+ fTextX = aMainLeft.getX() - (fStartArrowH + aTextRange.getWidth() + fSmall + fHalfLineWidth);
+
+ if(bMainLineSplitted)
+ {
+ fTextX -= (fArrowsOutsideLen - fStartArrowH);
+ }
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextX -= rTextAttribute.getTextRightDistance();
+ }
+ }
+ else if(MEASURETEXTPOSITION_POSITIVE == eHorizontal)
+ {
+ // right
+ const double fSmall(fArrowsOutsideLen * 0.18);
+ fTextX = aMainRight.getX() + (fEndArrowH + fSmall + fHalfLineWidth);
+
+ if(bMainLineSplitted)
+ {
+ fTextX += (fArrowsOutsideLen - fEndArrowH);
+ }
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextX += rTextAttribute.getTextLeftDistance();
+ }
+ }
+ else // MEASURETEXTPOSITION_CENTERED
+ {
+ // centered
+ fTextX = aMainLeft.getX() + ((fDistance - aTextRange.getWidth()) * 0.5);
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextX += (rTextAttribute.getTextLeftDistance() - rTextAttribute.getTextRightDistance()) / 2L;
+ }
+ }
+
+ // text vertical position
+ if(MEASURETEXTPOSITION_NEGATIVE == eVertical)
+ {
+ // top
+ const double fSmall(fArrowsOutsideLen * 0.10);
+ fTextY = aMainLeft.getY() - (aTextRange.getHeight() + fSmall + fHalfLineWidth);
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextY -= rTextAttribute.getTextLowerDistance();
+ }
+ }
+ else if(MEASURETEXTPOSITION_POSITIVE == eVertical)
+ {
+ // bottom
+ const double fSmall(fArrowsOutsideLen * 0.10);
+ fTextY = aMainLeft.getY() + (fSmall + fHalfLineWidth);
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextY += rTextAttribute.getTextUpperDistance();
+ }
+ }
+ else // MEASURETEXTPOSITION_CENTERED
+ {
+ // centered
+ fTextY = aMainLeft.getY() - (aTextRange.getHeight() * 0.5);
+
+ if(!rTextAttribute.isDefault())
+ {
+ fTextY += (rTextAttribute.getTextUpperDistance() - rTextAttribute.getTextLowerDistance()) / 2L;
+ }
+ }
+ }
+
+ if(getSdrLSTAttribute().getLine().isDefault())
+ {
+ // embed line geometry to invisible (100% transparent) line group for HitTest
+ const Primitive2DReference xHiddenLines(new HiddenGeometryPrimitive2D(aRetval));
+
+ aRetval = Primitive2DSequence(&xHiddenLines, 1);
+ }
+
+ if(pBlockText)
+ {
+ // create transformation to text primitive end position
+ basegfx::B2DHomMatrix aChange;
+
+ // handle auto text rotation
+ if(bAutoUpsideDown)
+ {
+ aChange.rotate(F_PI);
+ }
+
+ // move from aTextRange.TopLeft to fTextX, fTextY
+ aChange.translate(fTextX - aTextRange.getMinX(), fTextY - aTextRange.getMinY());
+
+ // apply object matrix
+ aChange *= aObjectMatrix;
+
+ // apply to existing text primitive
+ SdrTextPrimitive2D* pNewBlockText = pBlockText->createTransformedClone(aChange);
+ OSL_ENSURE(pNewBlockText, "SdrMeasurePrimitive2D::create2DDecomposition: Could not create transformed clone of text primitive (!)");
+ delete pBlockText;
+
+ // add to local primitives
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, Primitive2DReference(pNewBlockText));
+ }
+
+ // add shadow
+ if(!getSdrLSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrMeasurePrimitive2D::SdrMeasurePrimitive2D(
+ const attribute::SdrLineShadowTextAttribute& rSdrLSTAttribute,
+ const basegfx::B2DPoint& rStart,
+ const basegfx::B2DPoint& rEnd,
+ MeasureTextPosition eHorizontal,
+ MeasureTextPosition eVertical,
+ double fDistance,
+ double fUpper,
+ double fLower,
+ double fLeftDelta,
+ double fRightDelta,
+ bool bBelow,
+ bool bTextRotation,
+ bool bTextAutoAngle)
+ : BufferedDecompositionPrimitive2D(),
+ maSdrLSTAttribute(rSdrLSTAttribute),
+ maStart(rStart),
+ maEnd(rEnd),
+ meHorizontal(eHorizontal),
+ meVertical(eVertical),
+ mfDistance(fDistance),
+ mfUpper(fUpper),
+ mfLower(fLower),
+ mfLeftDelta(fLeftDelta),
+ mfRightDelta(fRightDelta),
+ mbBelow(bBelow),
+ mbTextRotation(bTextRotation),
+ mbTextAutoAngle(bTextAutoAngle)
+ {
+ }
+
+ bool SdrMeasurePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrMeasurePrimitive2D& rCompare = (SdrMeasurePrimitive2D&)rPrimitive;
+
+ return (getStart() == rCompare.getStart()
+ && getEnd() == rCompare.getEnd()
+ && getHorizontal() == rCompare.getHorizontal()
+ && getVertical() == rCompare.getVertical()
+ && getDistance() == rCompare.getDistance()
+ && getUpper() == rCompare.getUpper()
+ && getLower() == rCompare.getLower()
+ && getLeftDelta() == rCompare.getLeftDelta()
+ && getRightDelta() == rCompare.getRightDelta()
+ && getBelow() == rCompare.getBelow()
+ && getTextRotation() == rCompare.getTextRotation()
+ && getTextAutoAngle() == rCompare.getTextAutoAngle()
+ && getSdrLSTAttribute() == rCompare.getSdrLSTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrMeasurePrimitive2D, PRIMITIVE2D_ID_SDRMEASUREPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrole2primitive2d.cxx b/svx/source/sdr/primitive2d/sdrole2primitive2d.cxx
new file mode 100644
index 000000000000..14c23fdcdbc7
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrole2primitive2d.cxx
@@ -0,0 +1,193 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrole2primitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ SdrOle2Primitive2D::SdrOle2Primitive2D(
+ const Primitive2DSequence& rOLEContent,
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute)
+ : BasePrimitive2D(),
+ maOLEContent(rOLEContent),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute)
+ {
+ }
+
+ bool SdrOle2Primitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BasePrimitive2D::operator==(rPrimitive))
+ {
+ const SdrOle2Primitive2D& rCompare = (SdrOle2Primitive2D&)rPrimitive;
+
+ // #i108636# The standard operator== on two UNO sequences did not work as i
+ // would have expected; it just checks the .is() states and the data type
+ // of the sequence. What i need here is detection of equality of the whole
+ // sequence content, thus i need to use the arePrimitive2DSequencesEqual helper
+ // here instead of the operator== which lead to always returning false and thus
+ // always re-decompositions of the subcontent.
+ if(arePrimitive2DSequencesEqual(getOLEContent(), rCompare.getOLEContent())
+ && getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ Primitive2DSequence SdrOle2Primitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ // to take care of getSdrLFSTAttribute() later, the same as in SdrGrafPrimitive2D::create2DDecomposition
+ // should happen. For the moment we only need the OLE itself
+ // Added complete primitive preparation using getSdrLFSTAttribute() now. To not do stuff which is not needed now, it
+ // may be supressed by using a static bool. The paint version only supported text.
+ static bool bBehaveCompatibleToPaintVersion(true);
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
+
+ // add fill
+ if(!bBehaveCompatibleToPaintVersion
+ && !getSdrLFSTAttribute().getFill().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ // #i97981# condition was inverse to purpose. When being compatible to paint version,
+ // border needs to be suppressed
+ if(!bBehaveCompatibleToPaintVersion
+ && !getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // if line width is given, polygon needs to be grown by half of it to make the
+ // outline to be outside of the bitmap
+ if(0.0 != getSdrLFSTAttribute().getLine().getWidth())
+ {
+ // decompose to get scale
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ getTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // create expanded range (add relative half line width to unit rectangle)
+ double fHalfLineWidth(getSdrLFSTAttribute().getLine().getWidth() * 0.5);
+ double fScaleX(0.0 != aScale.getX() ? fHalfLineWidth / fabs(aScale.getX()) : 1.0);
+ double fScaleY(0.0 != aScale.getY() ? fHalfLineWidth / fabs(aScale.getY()) : 1.0);
+ const basegfx::B2DRange aExpandedRange(-fScaleX, -fScaleY, 1.0 + fScaleX, 1.0 + fScaleY);
+ basegfx::B2DPolygon aExpandedUnitOutline(basegfx::tools::createPolygonFromRect(aExpandedRange));
+
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aExpandedUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+ else
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+ }
+ else
+ {
+ // if initially no line is defined, create one for HitTest and BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+
+ // add graphic content
+ appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, getOLEContent());
+
+ // add text, no need to supress to stay compatible since text was
+ // always supported by the old paints, too
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!bBehaveCompatibleToPaintVersion
+ && !getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrOle2Primitive2D, PRIMITIVE2D_ID_SDROLE2PRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx
new file mode 100644
index 000000000000..0b38a9679a5a
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx
@@ -0,0 +1,204 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <svx/svdoole2.hxx>
+#include <vcl/svapp.hxx>
+#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
+#include <svtools/colorcfg.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrOleContentPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+ const SdrOle2Obj* pSource = (mpSdrOle2Obj.is() ? static_cast< SdrOle2Obj* >(mpSdrOle2Obj.get()) : 0);
+ bool bScaleContent(false);
+ Graphic aGraphic;
+
+ if(pSource)
+ {
+ Graphic* pOLEGraphic = (getHighContrast())
+ ? pSource->getEmbeddedObjectRef().GetHCGraphic()
+ : pSource->GetGraphic();
+
+ if(pOLEGraphic)
+ {
+ aGraphic = *pOLEGraphic;
+ bScaleContent = pSource->IsEmptyPresObj();
+ }
+ }
+
+ if(GRAPHIC_NONE == aGraphic.GetType())
+ {
+ // no source, use fallback ressource emty OLE graphic
+ const Bitmap aEmptyOLEBitmap(SdrOle2Obj::GetEmtyOLEReplacementBitmap());
+ aGraphic = Graphic(aEmptyOLEBitmap);
+ bScaleContent = true;
+ }
+
+ if(GRAPHIC_NONE != aGraphic.GetType())
+ {
+ const GraphicObject aGraphicObject(aGraphic);
+ const GraphicAttr aGraphicAttr;
+ drawinglayer::primitive2d::Primitive2DSequence xOLEContent;
+
+ if(bScaleContent)
+ {
+ // get transformation atoms
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ getObjectTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // get PrefSize from the graphic in 100th mm
+ Size aPrefSize(aGraphic.GetPrefSize());
+
+ if(MAP_PIXEL == aGraphic.GetPrefMapMode().GetMapUnit())
+ {
+ aPrefSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MAP_100TH_MM);
+ }
+ else
+ {
+ aPrefSize = Application::GetDefaultDevice()->LogicToLogic(aPrefSize, aGraphic.GetPrefMapMode(), MAP_100TH_MM);
+ }
+
+ const double fOffsetX((aScale.getX() - aPrefSize.getWidth()) / 2.0);
+ const double fOffsetY((aScale.getY() - aPrefSize.getHeight()) / 2.0);
+
+ if(basegfx::fTools::moreOrEqual(fOffsetX, 0.0) && basegfx::fTools::moreOrEqual(fOffsetY, 0.0))
+ {
+ // if content fits into frame, create it
+ basegfx::B2DHomMatrix aInnerObjectMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix(
+ aPrefSize.getWidth(), aPrefSize.getHeight(), fOffsetX, fOffsetY));
+ aInnerObjectMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate)
+ * aInnerObjectMatrix;
+
+ const drawinglayer::primitive2d::Primitive2DReference aGraphicPrimitive(
+ new drawinglayer::primitive2d::GraphicPrimitive2D(
+ aInnerObjectMatrix,
+ aGraphicObject,
+ aGraphicAttr));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aGraphicPrimitive);
+ }
+ }
+ else
+ {
+ // create graphic primitive for content
+ const drawinglayer::primitive2d::Primitive2DReference aGraphicPrimitive(
+ new drawinglayer::primitive2d::GraphicPrimitive2D(
+ getObjectTransform(),
+ aGraphicObject,
+ aGraphicAttr));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aGraphicPrimitive);
+ }
+
+ // a standard gray outline is created for scaled content
+ if(bScaleContent)
+ {
+ const svtools::ColorConfig aColorConfig;
+ const svtools::ColorConfigValue aColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES));
+
+ if(aColor.bIsVisible)
+ {
+ basegfx::B2DPolygon aOutline(basegfx::tools::createUnitPolygon());
+ const Color aVclColor(aColor.nColor);
+ aOutline.transform(getObjectTransform());
+ const drawinglayer::primitive2d::Primitive2DReference xOutline(
+ new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(aOutline, aVclColor.getBColor()));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, xOutline);
+ }
+ }
+ }
+
+ // get graphic and check scale content state
+ return aRetval;
+ }
+
+ SdrOleContentPrimitive2D::SdrOleContentPrimitive2D(
+ const SdrOle2Obj& rSdrOle2Obj,
+ const basegfx::B2DHomMatrix& rObjectTransform,
+ sal_uInt32 nGraphicVersion,
+ bool bHighContrast)
+ : BufferedDecompositionPrimitive2D(),
+ mpSdrOle2Obj(const_cast< SdrOle2Obj* >(&rSdrOle2Obj)),
+ maObjectTransform(rObjectTransform),
+ mnGraphicVersion(nGraphicVersion),
+ mbHighContrast(bHighContrast)
+ {
+ }
+
+ bool SdrOleContentPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrOleContentPrimitive2D& rCompare = (SdrOleContentPrimitive2D&)rPrimitive;
+ const bool bBothNot(!mpSdrOle2Obj.is() && !rCompare.mpSdrOle2Obj.is());
+ const bool bBothAndEqual(mpSdrOle2Obj.is() && rCompare.mpSdrOle2Obj.is()
+ && mpSdrOle2Obj.get() == rCompare.mpSdrOle2Obj.get());
+
+ return ((bBothNot || bBothAndEqual)
+ && getObjectTransform() == rCompare.getObjectTransform()
+
+ // #i104867# to find out if the Graphic content of the
+ // OLE has changed, use GraphicVersion number
+ && getGraphicVersion() == rCompare.getGraphicVersion()
+
+ && getHighContrast() == rCompare.getHighContrast());
+ }
+
+ return false;
+ }
+
+ basegfx::B2DRange SdrOleContentPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
+ {
+ basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0);
+ aRange.transform(getObjectTransform());
+
+ return aRange;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrOleContentPrimitive2D, PRIMITIVE2D_ID_SDROLECONTENTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx
new file mode 100644
index 000000000000..a839d978edc3
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrpathprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrPathPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // add fill
+ if(!getSdrLFSTAttribute().getFill().isDefault()
+ && getUnitPolyPolygon().isClosed())
+ {
+ // #i108255# no need to use correctOrientations here; target is
+ // straight visualisation
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ getUnitPolyPolygon(),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+
+ // add line
+ if(getSdrLFSTAttribute().getLine().isDefault())
+ {
+ // if initially no line is defined, create one for HitTest and BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ getUnitPolyPolygon(),
+ getTransform()));
+ }
+ else
+ {
+ Primitive2DSequence aTemp(getUnitPolyPolygon().count());
+
+ for(sal_uInt32 a(0); a < getUnitPolyPolygon().count(); a++)
+ {
+ aTemp[a] = createPolygonLinePrimitive(
+ getUnitPolyPolygon().getB2DPolygon(a),
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ getSdrLFSTAttribute().getLineStartEnd());
+ }
+
+ appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, aTemp);
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ getUnitPolyPolygon(),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrPathPrimitive2D::SdrPathPrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
+ const basegfx::B2DPolyPolygon& rUnitPolyPolygon)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute),
+ maUnitPolyPolygon(rUnitPolyPolygon)
+ {
+ }
+
+ bool SdrPathPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrPathPrimitive2D& rCompare = (SdrPathPrimitive2D&)rPrimitive;
+
+ return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon()
+ && getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrPathPrimitive2D, PRIMITIVE2D_ID_SDRPATHPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx
new file mode 100644
index 000000000000..5cc4a4a2782a
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx
@@ -0,0 +1,179 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
+#include <vcl/bmpacc.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/lazydelete.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// helper methods
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ BitmapEx createDefaultCross_3x3(const basegfx::BColor& rBColor)
+ {
+ static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0);
+ static basegfx::BColor aColor;
+ ::osl::Mutex m_mutex;
+
+ if(!aRetVal.get() || rBColor != aColor)
+ {
+ // copy values
+ aColor = rBColor;
+
+ // create bitmap
+ Bitmap aContent(Size(3, 3), 24);
+ Bitmap aMask(Size(3, 3), 1);
+ BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess();
+ BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess();
+ OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)");
+ const Color aVCLColor(aColor);
+ const BitmapColor aPixColor(aVCLColor);
+ const BitmapColor aMaskColor(0x01);
+
+ // Y,X unusual order (!)
+ pWContent->SetPixel(0, 1, aPixColor);
+ pWContent->SetPixel(1, 0, aPixColor);
+ pWContent->SetPixel(1, 1, aPixColor);
+ pWContent->SetPixel(1, 2, aPixColor);
+ pWContent->SetPixel(2, 1, aPixColor);
+
+ pWMask->SetPixel(0, 0, aMaskColor);
+ pWMask->SetPixel(0, 2, aMaskColor);
+ pWMask->SetPixel(2, 0, aMaskColor);
+ pWMask->SetPixel(2, 2, aMaskColor);
+
+ aContent.ReleaseAccess(pWContent);
+ aMask.ReleaseAccess(pWMask);
+
+ // create and exchange at aRetVal
+ delete aRetVal.set(new BitmapEx(aContent, aMask));
+ }
+
+ return aRetVal.get() ? *aRetVal.get() : BitmapEx();
+ }
+
+ BitmapEx createDefaultGluepoint_7x7(const basegfx::BColor& rBColorA, const basegfx::BColor& rBColorB)
+ {
+ static vcl::DeleteOnDeinit< BitmapEx > aRetVal(0);
+ static basegfx::BColor aColorA;
+ static basegfx::BColor aColorB;
+ ::osl::Mutex m_mutex;
+
+ if(!aRetVal.get() || rBColorA != aColorA || rBColorB != aColorB)
+ {
+ // copy values
+ aColorA = rBColorA;
+ aColorB = rBColorB;
+
+ // create bitmap
+ Bitmap aContent(Size(7, 7), 24);
+ Bitmap aMask(Size(7, 7), 1);
+ BitmapWriteAccess* pWContent = aContent.AcquireWriteAccess();
+ BitmapWriteAccess* pWMask = aMask.AcquireWriteAccess();
+ OSL_ENSURE(pWContent && pWMask, "No WriteAccess to bitmap (!)");
+ const Color aColA(aColorA);
+ const Color aColB(aColorB);
+ const BitmapColor aPixColorA(aColA);
+ const BitmapColor aPixColorB(aColB);
+ const BitmapColor aMaskColor(0x01);
+
+ // Y,X unusual order (!)
+ pWContent->SetPixel(0, 1, aPixColorA);
+ pWContent->SetPixel(0, 5, aPixColorA);
+ pWContent->SetPixel(1, 0, aPixColorA);
+ pWContent->SetPixel(1, 2, aPixColorA);
+ pWContent->SetPixel(1, 4, aPixColorA);
+ pWContent->SetPixel(1, 6, aPixColorA);
+ pWContent->SetPixel(2, 1, aPixColorA);
+ pWContent->SetPixel(2, 3, aPixColorA);
+ pWContent->SetPixel(2, 5, aPixColorA);
+ pWContent->SetPixel(3, 2, aPixColorA);
+ pWContent->SetPixel(3, 4, aPixColorA);
+ pWContent->SetPixel(4, 1, aPixColorA);
+ pWContent->SetPixel(4, 3, aPixColorA);
+ pWContent->SetPixel(4, 5, aPixColorA);
+ pWContent->SetPixel(5, 0, aPixColorA);
+ pWContent->SetPixel(5, 2, aPixColorA);
+ pWContent->SetPixel(5, 4, aPixColorA);
+ pWContent->SetPixel(5, 6, aPixColorA);
+ pWContent->SetPixel(6, 1, aPixColorA);
+ pWContent->SetPixel(6, 5, aPixColorA);
+
+ pWContent->SetPixel(1, 1, aPixColorB);
+ pWContent->SetPixel(1, 5, aPixColorB);
+ pWContent->SetPixel(2, 2, aPixColorB);
+ pWContent->SetPixel(2, 4, aPixColorB);
+ pWContent->SetPixel(3, 3, aPixColorB);
+ pWContent->SetPixel(4, 2, aPixColorB);
+ pWContent->SetPixel(4, 4, aPixColorB);
+ pWContent->SetPixel(5, 1, aPixColorB);
+ pWContent->SetPixel(5, 5, aPixColorB);
+
+ pWMask->SetPixel(0, 0, aMaskColor);
+ pWMask->SetPixel(0, 2, aMaskColor);
+ pWMask->SetPixel(0, 3, aMaskColor);
+ pWMask->SetPixel(0, 4, aMaskColor);
+ pWMask->SetPixel(0, 6, aMaskColor);
+ pWMask->SetPixel(1, 3, aMaskColor);
+ pWMask->SetPixel(2, 0, aMaskColor);
+ pWMask->SetPixel(2, 6, aMaskColor);
+ pWMask->SetPixel(3, 0, aMaskColor);
+ pWMask->SetPixel(3, 1, aMaskColor);
+ pWMask->SetPixel(3, 5, aMaskColor);
+ pWMask->SetPixel(3, 6, aMaskColor);
+ pWMask->SetPixel(4, 0, aMaskColor);
+ pWMask->SetPixel(4, 6, aMaskColor);
+ pWMask->SetPixel(5, 3, aMaskColor);
+ pWMask->SetPixel(6, 0, aMaskColor);
+ pWMask->SetPixel(6, 2, aMaskColor);
+ pWMask->SetPixel(6, 3, aMaskColor);
+ pWMask->SetPixel(6, 4, aMaskColor);
+ pWMask->SetPixel(6, 6, aMaskColor);
+
+ aContent.ReleaseAccess(pWContent);
+ aMask.ReleaseAccess(pWMask);
+
+ // create and exchange at aRetVal
+ delete aRetVal.set(new BitmapEx(aContent, aMask));
+ }
+
+ return aRetVal.get() ? *aRetVal.get() : BitmapEx();
+ }
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx
new file mode 100644
index 000000000000..c6af6de417f0
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrRectanglePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence aRetval;
+
+ // create unit outline polygon
+ const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect(
+ basegfx::B2DRange(0.0, 0.0, 1.0, 1.0),
+ getCornerRadiusX(),
+ getCornerRadiusY()));
+
+ // add fill
+ if(!getSdrLFSTAttribute().getFill().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getFill(),
+ getSdrLFSTAttribute().getFillFloatTransGradient()));
+ }
+ else if(getForceFillForHitTest())
+ {
+ // if no fill and it's a text frame, create a fill for HitTest and
+ // BoundRect fallback
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ true,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+
+ // add line
+ if(!getSdrLFSTAttribute().getLine().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolygonLinePrimitive(
+ aUnitOutline,
+ getTransform(),
+ getSdrLFSTAttribute().getLine(),
+ attribute::SdrLineStartEndAttribute()));
+ }
+ else if(!getForceFillForHitTest())
+ {
+ // if initially no line is defined and it's not a text frame, create
+ // a line for HitTest and BoundRect
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ false,
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform()));
+ }
+
+ // add text
+ if(!getSdrLFSTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ basegfx::B2DPolyPolygon(aUnitOutline),
+ getTransform(),
+ getSdrLFSTAttribute().getText(),
+ getSdrLFSTAttribute().getLine(),
+ false,
+ false,
+ false));
+ }
+
+ // add shadow
+ if(!getSdrLFSTAttribute().getShadow().isDefault())
+ {
+ aRetval = createEmbeddedShadowPrimitive(
+ aRetval,
+ getSdrLFSTAttribute().getShadow());
+ }
+
+ return aRetval;
+ }
+
+ SdrRectanglePrimitive2D::SdrRectanglePrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute,
+ double fCornerRadiusX,
+ double fCornerRadiusY,
+ bool bForceFillForHitTest)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrLFSTAttribute(rSdrLFSTAttribute),
+ mfCornerRadiusX(fCornerRadiusX),
+ mfCornerRadiusY(fCornerRadiusY),
+ mbForceFillForHitTest(bForceFillForHitTest)
+ {
+ }
+
+ bool SdrRectanglePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrRectanglePrimitive2D& rCompare = (SdrRectanglePrimitive2D&)rPrimitive;
+
+ return (getCornerRadiusX() == rCompare.getCornerRadiusX()
+ && getCornerRadiusY() == rCompare.getCornerRadiusY()
+ && getTransform() == rCompare.getTransform()
+ && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()
+ && getForceFillForHitTest() == rCompare.getForceFillForHitTest());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrRectanglePrimitive2D, PRIMITIVE2D_ID_SDRRECTANGLEPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx
new file mode 100644
index 000000000000..cebb4f63e7f5
--- /dev/null
+++ b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx
@@ -0,0 +1,549 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svx.hxx"
+#include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
+#include <svx/svdotext.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/flditem.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <unoapi.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdoutl.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace
+{
+ sal_Int16 getPageNumber(const uno::Reference< drawing::XDrawPage >& rxDrawPage)
+ {
+ sal_Int16 nRetval(0);
+ uno::Reference< beans::XPropertySet > xSet(rxDrawPage, uno::UNO_QUERY);
+
+ if (xSet.is())
+ {
+ try
+ {
+ const uno::Any aNumber(xSet->getPropertyValue(::rtl::OUString::createFromAscii("Number")));
+ aNumber >>= nRetval;
+ }
+ catch(const uno::Exception&)
+ {
+ OSL_ASSERT(false);
+ }
+ }
+
+ return nRetval;
+ }
+
+ sal_Int16 getPageCount(const uno::Reference< drawing::XDrawPage >& rxDrawPage)
+ {
+ sal_Int16 nRetval(0);
+ SdrPage* pPage = GetSdrPageFromXDrawPage(rxDrawPage);
+
+ if(pPage && pPage->GetModel())
+ {
+ if( (pPage->GetPageNum() == 0) && !pPage->IsMasterPage() )
+ {
+ // handout page!
+ return pPage->GetModel()->getHandoutPageCount();
+ }
+ else
+ {
+ const sal_uInt16 nPageCount(pPage->GetModel()->GetPageCount());
+ nRetval = ((sal_Int16)nPageCount - 1) / 2;
+ }
+ }
+
+ return nRetval;
+ }
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments
+ // for slideshow. This uses TextHierarchyBlockPrimitive2D to mark a text block.
+ // ATM there is only one text block per SdrObject, this may get more in the future
+ Primitive2DSequence SdrTextPrimitive2D::encapsulateWithTextHierarchyBlockPrimitive2D(const Primitive2DSequence& rCandidate) const
+ {
+ Primitive2DReference xReference(new TextHierarchyBlockPrimitive2D(rCandidate));
+ Primitive2DSequence xRetval(&xReference, 1);
+
+ return xRetval;
+ }
+
+ SdrTextPrimitive2D::SdrTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject)
+ : BufferedDecompositionPrimitive2D(),
+ mrSdrText(const_cast< SdrText* >(pSdrText)),
+ maOutlinerParaObject(rOutlinerParaObject),
+ mxLastVisualizingPage(),
+ mnLastPageNumber(0),
+ mnLastPageCount(0),
+ maLastTextBackgroundColor(),
+ mbContainsPageField(false),
+ mbContainsPageCountField(false),
+ mbContainsOtherFields(false)
+ {
+ const EditTextObject& rETO = maOutlinerParaObject.GetTextObject();
+
+ mbContainsPageField = rETO.HasField(SvxPageField::StaticType());
+ mbContainsPageCountField = rETO.HasField(SvxPagesField::StaticType());
+ mbContainsOtherFields = rETO.HasField(SvxHeaderField::StaticType())
+ || rETO.HasField(SvxFooterField::StaticType())
+ || rETO.HasField(SvxDateTimeField::StaticType())
+ || rETO.HasField(SvxAuthorField::StaticType());
+ }
+
+ bool SdrTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrTextPrimitive2D& rCompare = (SdrTextPrimitive2D&)rPrimitive;
+
+ return (
+
+ // compare OPO and content, but not WrongList
+ getOutlinerParaObject() == rCompare.getOutlinerParaObject()
+
+ // also compare WrongList (not-persistent data, but visualized)
+ && getOutlinerParaObject().isWrongListEqual(rCompare.getOutlinerParaObject()));
+ }
+
+ return false;
+ }
+
+ Primitive2DSequence SdrTextPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
+ {
+ uno::Reference< drawing::XDrawPage > xCurrentlyVisualizingPage;
+ bool bCurrentlyVisualizingPageIsSet(false);
+ Color aNewTextBackgroundColor;
+ bool bNewTextBackgroundColorIsSet(false);
+ sal_Int16 nCurrentlyValidPageNumber(0);
+ sal_Int16 nCurrentlyValidPageCount(0);
+
+ if(getBuffered2DDecomposition().hasElements())
+ {
+ bool bDoDelete(false);
+
+ // check visualized page
+ if(mbContainsPageField || mbContainsPageCountField || mbContainsOtherFields)
+ {
+ // get visualized page and remember
+ xCurrentlyVisualizingPage = rViewInformation.getVisualizedPage();
+ bCurrentlyVisualizingPageIsSet = true;
+
+ if(xCurrentlyVisualizingPage != mxLastVisualizingPage)
+ {
+ bDoDelete = true;
+ }
+
+ // #i98870# check visualized PageNumber
+ if(!bDoDelete && mbContainsPageField)
+ {
+ nCurrentlyValidPageNumber = getPageNumber(xCurrentlyVisualizingPage);
+
+ if(nCurrentlyValidPageNumber != mnLastPageNumber)
+ {
+ bDoDelete = true;
+ }
+ }
+
+ // #i98870# check visualized PageCount, too
+ if(!bDoDelete && mbContainsPageCountField)
+ {
+ nCurrentlyValidPageCount = getPageCount(xCurrentlyVisualizingPage);
+
+ if(nCurrentlyValidPageCount != mnLastPageCount)
+ {
+ bDoDelete = true;
+ }
+ }
+ }
+
+ // #i101443# check change of TextBackgroundolor
+ if(!bDoDelete && getSdrText() && getSdrText()->GetModel())
+ {
+ SdrOutliner& rDrawOutliner = getSdrText()->GetModel()->GetDrawOutliner(0);
+ aNewTextBackgroundColor = rDrawOutliner.GetBackgroundColor();
+ bNewTextBackgroundColorIsSet = true;
+
+ if(aNewTextBackgroundColor != maLastTextBackgroundColor)
+ {
+ bDoDelete = true;
+ }
+ }
+
+ if(bDoDelete)
+ {
+ const_cast< SdrTextPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
+ }
+ }
+
+ if(!getBuffered2DDecomposition().hasElements())
+ {
+ if(!bCurrentlyVisualizingPageIsSet && mbContainsPageField)
+ {
+ xCurrentlyVisualizingPage = rViewInformation.getVisualizedPage();
+ }
+
+ if(!nCurrentlyValidPageNumber && mbContainsPageField)
+ {
+ nCurrentlyValidPageNumber = getPageNumber(xCurrentlyVisualizingPage);
+ }
+
+ if(!nCurrentlyValidPageCount && mbContainsPageCountField)
+ {
+ nCurrentlyValidPageCount = getPageCount(xCurrentlyVisualizingPage);
+ }
+
+ if(!bNewTextBackgroundColorIsSet && getSdrText() && getSdrText()->GetModel())
+ {
+ SdrOutliner& rDrawOutliner = getSdrText()->GetModel()->GetDrawOutliner(0);
+ aNewTextBackgroundColor = rDrawOutliner.GetBackgroundColor();
+ }
+
+ const_cast< SdrTextPrimitive2D* >(this)->mxLastVisualizingPage = xCurrentlyVisualizingPage;
+ const_cast< SdrTextPrimitive2D* >(this)->mnLastPageNumber = nCurrentlyValidPageNumber;
+ const_cast< SdrTextPrimitive2D* >(this)->mnLastPageCount = nCurrentlyValidPageCount;
+ const_cast< SdrTextPrimitive2D* >(this)->maLastTextBackgroundColor = aNewTextBackgroundColor;
+ }
+
+ // call parent
+ return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
+ }
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrContourTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ getSdrText()->GetObject().impDecomposeContourTextPrimitive(aRetval, *this, aViewInformation);
+
+ return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval);
+ }
+
+ SdrContourTextPrimitive2D::SdrContourTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject,
+ const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
+ const basegfx::B2DHomMatrix& rObjectTransform)
+ : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject),
+ maUnitPolyPolygon(rUnitPolyPolygon),
+ maObjectTransform(rObjectTransform)
+ {
+ }
+
+ bool SdrContourTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrTextPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrContourTextPrimitive2D& rCompare = (SdrContourTextPrimitive2D&)rPrimitive;
+
+ return (getUnitPolyPolygon() == rCompare.getUnitPolyPolygon()
+ && getObjectTransform() == rCompare.getObjectTransform());
+ }
+
+ return false;
+ }
+
+ SdrTextPrimitive2D* SdrContourTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const
+ {
+ return new SdrContourTextPrimitive2D(
+ getSdrText(),
+ getOutlinerParaObject(),
+ getUnitPolyPolygon(),
+ rTransform * getObjectTransform());
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrContourTextPrimitive2D, PRIMITIVE2D_ID_SDRCONTOURTEXTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrPathTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ getSdrText()->GetObject().impDecomposePathTextPrimitive(aRetval, *this, aViewInformation);
+
+ return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval);
+ }
+
+ SdrPathTextPrimitive2D::SdrPathTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject,
+ const basegfx::B2DPolyPolygon& rPathPolyPolygon,
+ const attribute::SdrFormTextAttribute& rSdrFormTextAttribute)
+ : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject),
+ maPathPolyPolygon(rPathPolyPolygon),
+ maSdrFormTextAttribute(rSdrFormTextAttribute)
+ {
+ }
+
+ bool SdrPathTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrTextPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrPathTextPrimitive2D& rCompare = (SdrPathTextPrimitive2D&)rPrimitive;
+
+ return (getPathPolyPolygon() == rCompare.getPathPolyPolygon()
+ && getSdrFormTextAttribute() == rCompare.getSdrFormTextAttribute());
+ }
+
+ return false;
+ }
+
+ SdrTextPrimitive2D* SdrPathTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const
+ {
+ basegfx::B2DPolyPolygon aNewPolyPolygon(getPathPolyPolygon());
+ aNewPolyPolygon.transform(rTransform);
+
+ return new SdrPathTextPrimitive2D(
+ getSdrText(),
+ getOutlinerParaObject(),
+ aNewPolyPolygon,
+ getSdrFormTextAttribute());
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrPathTextPrimitive2D, PRIMITIVE2D_ID_SDRPATHTEXTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrBlockTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ getSdrText()->GetObject().impDecomposeBlockTextPrimitive(aRetval, *this, aViewInformation);
+
+ return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval);
+ }
+
+ SdrBlockTextPrimitive2D::SdrBlockTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject,
+ const basegfx::B2DHomMatrix& rTextRangeTransform,
+ SdrTextHorzAdjust aSdrTextHorzAdjust,
+ SdrTextVertAdjust aSdrTextVertAdjust,
+ bool bFixedCellHeight,
+ bool bUnlimitedPage,
+ bool bCellText,
+ bool bWordWrap,
+ bool bClipOnBounds)
+ : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject),
+ maTextRangeTransform(rTextRangeTransform),
+ maSdrTextHorzAdjust(aSdrTextHorzAdjust),
+ maSdrTextVertAdjust(aSdrTextVertAdjust),
+ mbFixedCellHeight(bFixedCellHeight),
+ mbUnlimitedPage(bUnlimitedPage),
+ mbCellText(bCellText),
+ mbWordWrap(bWordWrap),
+ mbClipOnBounds(bClipOnBounds)
+ {
+ }
+
+ bool SdrBlockTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrTextPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrBlockTextPrimitive2D& rCompare = (SdrBlockTextPrimitive2D&)rPrimitive;
+
+ return (getTextRangeTransform() == rCompare.getTextRangeTransform()
+ && getSdrTextHorzAdjust() == rCompare.getSdrTextHorzAdjust()
+ && getSdrTextVertAdjust() == rCompare.getSdrTextVertAdjust()
+ && isFixedCellHeight() == rCompare.isFixedCellHeight()
+ && getUnlimitedPage() == rCompare.getUnlimitedPage()
+ && getCellText() == rCompare.getCellText()
+ && getWordWrap() == rCompare.getWordWrap()
+ && getClipOnBounds() == rCompare.getClipOnBounds());
+ }
+
+ return false;
+ }
+
+ SdrTextPrimitive2D* SdrBlockTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const
+ {
+ return new SdrBlockTextPrimitive2D(
+ getSdrText(),
+ getOutlinerParaObject(),
+ rTransform * getTextRangeTransform(),
+ getSdrTextHorzAdjust(),
+ getSdrTextVertAdjust(),
+ isFixedCellHeight(),
+ getUnlimitedPage(),
+ getCellText(),
+ getWordWrap(),
+ getClipOnBounds());
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrBlockTextPrimitive2D, PRIMITIVE2D_ID_SDRBLOCKTEXTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrAutoFitTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ getSdrText()->GetObject().impDecomposeAutoFitTextPrimitive(aRetval, *this, aViewInformation);
+
+ return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval);
+ }
+
+ SdrAutoFitTextPrimitive2D::SdrAutoFitTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rParaObj,
+ const ::basegfx::B2DHomMatrix& rTextRangeTransform,
+ bool bWordWrap)
+ : SdrTextPrimitive2D(pSdrText, rParaObj),
+ maTextRangeTransform(rTextRangeTransform),
+ mbWordWrap(bWordWrap)
+ {
+ }
+
+ bool SdrAutoFitTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrTextPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrBlockTextPrimitive2D& rCompare = (SdrBlockTextPrimitive2D&)rPrimitive;
+
+ return (getTextRangeTransform() == rCompare.getTextRangeTransform()
+ && getWordWrap() == rCompare.getWordWrap());
+ }
+
+ return false;
+ }
+
+ SdrTextPrimitive2D* SdrAutoFitTextPrimitive2D::createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const
+ {
+ return new SdrAutoFitTextPrimitive2D(getSdrText(), getOutlinerParaObject(), rTransform * getTextRangeTransform(), getWordWrap());
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrAutoFitTextPrimitive2D, PRIMITIVE2D_ID_SDRAUTOFITTEXTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+ } // end of namespace drawinglayer
+
+ //////////////////////////////////////////////////////////////////////////////
+
+ namespace drawinglayer
+ {
+ namespace primitive2d
+ {
+ Primitive2DSequence SdrStretchTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
+ {
+ Primitive2DSequence aRetval;
+ getSdrText()->GetObject().impDecomposeStretchTextPrimitive(aRetval, *this, aViewInformation);
+
+ return encapsulateWithTextHierarchyBlockPrimitive2D(aRetval);
+ }
+
+ SdrStretchTextPrimitive2D::SdrStretchTextPrimitive2D(
+ const SdrText* pSdrText,
+ const OutlinerParaObject& rOutlinerParaObject,
+ const basegfx::B2DHomMatrix& rTextRangeTransform,
+ bool bFixedCellHeight)
+ : SdrTextPrimitive2D(pSdrText, rOutlinerParaObject),
+ maTextRangeTransform(rTextRangeTransform),
+ mbFixedCellHeight(bFixedCellHeight)
+ {
+ }
+
+ bool SdrStretchTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(SdrTextPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrStretchTextPrimitive2D& rCompare = (SdrStretchTextPrimitive2D&)rPrimitive;
+
+ return (getTextRangeTransform() == rCompare.getTextRangeTransform()
+ && isFixedCellHeight() == rCompare.isFixedCellHeight());
+ }
+
+ return false;
+ }
+
+ SdrTextPrimitive2D* SdrStretchTextPrimitive2D::createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const
+ {
+ return new SdrStretchTextPrimitive2D(
+ getSdrText(),
+ getOutlinerParaObject(),
+ rTransform * getTextRangeTransform(),
+ isFixedCellHeight());
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrStretchTextPrimitive2D, PRIMITIVE2D_ID_SDRSTRETCHTEXTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/primitive3d/makefile.mk b/svx/source/sdr/primitive3d/makefile.mk
new file mode 100644
index 000000000000..c845cadc90a4
--- /dev/null
+++ b/svx/source/sdr/primitive3d/makefile.mk
@@ -0,0 +1,42 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=svx
+TARGET=primitive3d
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/sdrattributecreator3d.obj
+
+.INCLUDE : target.mk
diff --git a/svx/source/sdr/primitive3d/sdrattributecreator3d.cxx b/svx/source/sdr/primitive3d/sdrattributecreator3d.cxx
new file mode 100644
index 000000000000..f8f28dc936d7
--- /dev/null
+++ b/svx/source/sdr/primitive3d/sdrattributecreator3d.cxx
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/sdr/primitive3d/sdrattributecreator3d.hxx>
+#include <svx/svx3ditems.hxx>
+#include <svl/itemset.hxx>
+#include <com/sun/star/drawing/NormalsKind.hpp>
+#include <com/sun/star/drawing/TextureProjectionMode.hpp>
+#include <com/sun/star/drawing/TextureKind2.hpp>
+#include <com/sun/star/drawing/TextureMode.hpp>
+#include <svx/xflclit.hxx>
+#include <drawinglayer/attribute/materialattribute3d.hxx>
+#include <drawinglayer/attribute/sdrobjectattribute3d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ attribute::Sdr3DObjectAttribute* createNewSdr3DObjectAttribute(const SfxItemSet& rSet)
+ {
+ // get NormalsKind
+ ::com::sun::star::drawing::NormalsKind aNormalsKind(::com::sun::star::drawing::NormalsKind_SPECIFIC);
+ const sal_uInt16 nNormalsValue(((const Svx3DNormalsKindItem&)rSet.Get(SDRATTR_3DOBJ_NORMALS_KIND)).GetValue());
+
+ if(1L == nNormalsValue)
+ {
+ aNormalsKind = ::com::sun::star::drawing::NormalsKind_FLAT;
+ }
+ else if(2L == nNormalsValue)
+ {
+ aNormalsKind = ::com::sun::star::drawing::NormalsKind_SPHERE;
+ }
+
+ // get NoermalsInvert flag
+ const bool bInvertNormals(((const Svx3DNormalsInvertItem&)rSet.Get(SDRATTR_3DOBJ_NORMALS_INVERT)).GetValue());
+
+ // get TextureProjectionX
+ ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionX(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC);
+ const sal_uInt16 nTextureValueX(((const Svx3DTextureProjectionXItem&)rSet.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_X)).GetValue());
+
+ if(1L == nTextureValueX)
+ {
+ aTextureProjectionX = ::com::sun::star::drawing::TextureProjectionMode_PARALLEL;
+ }
+ else if(2L == nTextureValueX)
+ {
+ aTextureProjectionX = ::com::sun::star::drawing::TextureProjectionMode_SPHERE;
+ }
+
+ // get TextureProjectionY
+ ::com::sun::star::drawing::TextureProjectionMode aTextureProjectionY(::com::sun::star::drawing::TextureProjectionMode_OBJECTSPECIFIC);
+ const sal_uInt16 nTextureValueY(((const Svx3DTextureProjectionYItem&)rSet.Get(SDRATTR_3DOBJ_TEXTURE_PROJ_Y)).GetValue());
+
+ if(1L == nTextureValueY)
+ {
+ aTextureProjectionY = ::com::sun::star::drawing::TextureProjectionMode_PARALLEL;
+ }
+ else if(2L == nTextureValueY)
+ {
+ aTextureProjectionY = ::com::sun::star::drawing::TextureProjectionMode_SPHERE;
+ }
+
+ // get DoubleSided flag
+ const bool bDoubleSided(((const Svx3DDoubleSidedItem&)rSet.Get(SDRATTR_3DOBJ_DOUBLE_SIDED)).GetValue());
+
+ // get Shadow3D flag
+ const bool bShadow3D(((const Svx3DShadow3DItem&)rSet.Get(SDRATTR_3DOBJ_SHADOW_3D)).GetValue());
+
+ // get TextureFilter flag
+ const bool bTextureFilter(((const Svx3DTextureFilterItem&)rSet.Get(SDRATTR_3DOBJ_TEXTURE_FILTER)).GetValue());
+
+ // get texture kind
+ // TextureKind: 1 == Base3DTextureLuminance, 2 == Base3DTextureIntensity, 3 == Base3DTextureColor
+ ::com::sun::star::drawing::TextureKind2 aTextureKind(::com::sun::star::drawing::TextureKind2_LUMINANCE);
+ const sal_uInt16 nTextureKind(((const Svx3DTextureKindItem&)rSet.Get(SDRATTR_3DOBJ_TEXTURE_KIND)).GetValue());
+
+ if(2 == nTextureKind)
+ {
+ aTextureKind = ::com::sun::star::drawing::TextureKind2_INTENSITY;
+ }
+ else if(3 == nTextureKind)
+ {
+ aTextureKind = ::com::sun::star::drawing::TextureKind2_COLOR;
+ }
+
+ // get texture mode
+ // TextureMode: 1 == Base3DTextureReplace, 2 == Base3DTextureModulate, 3 == Base3DTextureBlend
+ ::com::sun::star::drawing::TextureMode aTextureMode(::com::sun::star::drawing::TextureMode_REPLACE);
+ const sal_uInt16 nTextureMode(((const Svx3DTextureModeItem&)rSet.Get(SDRATTR_3DOBJ_TEXTURE_MODE)).GetValue());
+
+ if(2 == nTextureMode)
+ {
+ aTextureMode = ::com::sun::star::drawing::TextureMode_MODULATE;
+ }
+ else if(3 == nTextureMode)
+ {
+ aTextureMode = ::com::sun::star::drawing::TextureMode_BLEND;
+ }
+
+ // get object color
+ const ::basegfx::BColor aObjectColor(((const XFillColorItem&)rSet.Get(XATTR_FILLCOLOR)).GetColorValue().getBColor());
+
+ // get specular color
+ const ::basegfx::BColor aSpecular(((const Svx3DMaterialSpecularItem&)rSet.Get(SDRATTR_3DOBJ_MAT_SPECULAR)).GetValue().getBColor());
+
+ // get emissive color
+ const ::basegfx::BColor aEmission(((const Svx3DMaterialEmissionItem&)rSet.Get(SDRATTR_3DOBJ_MAT_EMISSION)).GetValue().getBColor());
+
+ // get specular intensity
+ sal_uInt16 nSpecularIntensity(((const Svx3DMaterialSpecularIntensityItem&)rSet.Get(SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY)).GetValue());
+
+ if(nSpecularIntensity > 128)
+ {
+ nSpecularIntensity = 128;
+ }
+
+ // get reduced line geometry
+ const bool bReducedLineGeometry(((const Svx3DReducedLineGeometryItem&)rSet.Get(SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY)).GetValue());
+
+ // prepare material
+ attribute::MaterialAttribute3D aMaterial(aObjectColor, aSpecular, aEmission, nSpecularIntensity);
+
+ return new attribute::Sdr3DObjectAttribute(
+ aNormalsKind, aTextureProjectionX, aTextureProjectionY,
+ aTextureKind, aTextureMode, aMaterial,
+ bInvertNormals, bDoubleSided, bShadow3D, bTextureFilter, bReducedLineGeometry);
+ }
+ } // end of namespace primitive2d
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx
new file mode 100644
index 000000000000..81ef0063a1a6
--- /dev/null
+++ b/svx/source/sdr/properties/attributeproperties.cxx
@@ -0,0 +1,631 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/attributeproperties.hxx>
+#include <svx/sdr/properties/itemsettools.hxx>
+#include <tools/debug.hxx>
+#include <svl/itemset.hxx>
+#include <svl/style.hxx>
+#include <svl/whiter.hxx>
+#include <svl/poolitem.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svddef.hxx>
+#include <svx/xit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/xflftrit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xlnasit.hxx>
+#include <svx/xflasit.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdpage.hxx>
+
+// #114265#
+#include <svl/smplhint.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ void AttributeProperties::ImpAddStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ // test if old StyleSheet is cleared, else it would be lost
+ // after this method -> memory leak (!)
+ DBG_ASSERT(!mpStyleSheet, "Old style sheet not deleted before setting new one (!)");
+
+ if(pNewStyleSheet)
+ {
+ mpStyleSheet = pNewStyleSheet;
+
+ // local ItemSet is needed here, force it
+ GetObjectItemSet();
+
+ // register as listener
+ StartListening(pNewStyleSheet->GetPool());
+ StartListening(*pNewStyleSheet);
+
+ // Delete hard attributes where items are set in the style sheet
+ if(!bDontRemoveHardAttr)
+ {
+ const SfxItemSet& rStyle = pNewStyleSheet->GetItemSet();
+ SfxWhichIter aIter(rStyle);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while(nWhich)
+ {
+ if(SFX_ITEM_SET == rStyle.GetItemState(nWhich))
+ {
+ mpItemSet->ClearItem(nWhich);
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+
+ // set new stylesheet as parent
+ mpItemSet->SetParent(&pNewStyleSheet->GetItemSet());
+ }
+ }
+
+ void AttributeProperties::ImpRemoveStyleSheet()
+ {
+ // Check type since it is destroyed when the type is deleted
+ if(GetStyleSheet() && HAS_BASE(SfxStyleSheet, mpStyleSheet))
+ {
+ EndListening(*mpStyleSheet);
+ EndListening(mpStyleSheet->GetPool());
+
+ // reset parent of ItemSet
+ if(mpItemSet)
+ {
+ mpItemSet->SetParent(0L);
+ }
+
+ SdrObject& rObj = GetSdrObject();
+ rObj.SetBoundRectDirty();
+ rObj.SetRectsDirty(sal_True);
+ }
+
+ mpStyleSheet = 0L;
+ }
+
+ // create a new itemset
+ SfxItemSet& AttributeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ return *(new SfxItemSet(rPool,
+
+ // ranges from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // end
+ 0, 0));
+ }
+
+ AttributeProperties::AttributeProperties(SdrObject& rObj)
+ : DefaultProperties(rObj),
+ mpStyleSheet(0L)
+ {
+ }
+
+ AttributeProperties::AttributeProperties(const AttributeProperties& rProps, SdrObject& rObj)
+ : DefaultProperties(rProps, rObj),
+ mpStyleSheet(0L)
+ {
+ if(rProps.GetStyleSheet())
+ {
+ ImpAddStyleSheet(rProps.GetStyleSheet(), sal_True);
+ }
+ }
+
+ AttributeProperties::~AttributeProperties()
+ {
+ ImpRemoveStyleSheet();
+ }
+
+ BaseProperties& AttributeProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new AttributeProperties(*this, rObj));
+ }
+
+ void AttributeProperties::ItemSetChanged(const SfxItemSet& /*rSet*/)
+ {
+ // own modifications
+ SdrObject& rObj = GetSdrObject();
+
+ rObj.SetBoundRectDirty();
+ rObj.SetRectsDirty(sal_True);
+ rObj.SetChanged();
+ }
+
+ void AttributeProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
+ {
+ if(pNewItem)
+ {
+ const SfxPoolItem* pItem = pNewItem;
+ SdrModel* pModel = GetSdrObject().GetModel();
+
+ switch( nWhich )
+ {
+ case XATTR_FILLBITMAP:
+ {
+ pItem = ((XFillBitmapItem*)pItem)->checkForUniqueItem( pModel );
+ break;
+ }
+ case XATTR_LINEDASH:
+ {
+ pItem = ((XLineDashItem*)pItem)->checkForUniqueItem( pModel );
+ break;
+ }
+ case XATTR_LINESTART:
+ {
+ pItem = ((XLineStartItem*)pItem)->checkForUniqueItem( pModel );
+ break;
+ }
+ case XATTR_LINEEND:
+ {
+ pItem = ((XLineEndItem*)pItem)->checkForUniqueItem( pModel );
+ break;
+ }
+ case XATTR_FILLGRADIENT:
+ {
+ pItem = ((XFillGradientItem*)pItem)->checkForUniqueItem( pModel );
+ break;
+ }
+ case XATTR_FILLFLOATTRANSPARENCE:
+ {
+ // #85953# allow all kinds of XFillFloatTransparenceItem to be set
+ pItem = ((XFillFloatTransparenceItem*)pItem)->checkForUniqueItem( pModel );
+ break;
+ }
+ case XATTR_FILLHATCH:
+ {
+ pItem = ((XFillHatchItem*)pItem)->checkForUniqueItem( pModel );
+ break;
+ }
+ }
+
+ // set item
+ if(pItem)
+ {
+ // force ItemSet
+ GetObjectItemSet();
+ mpItemSet->Put(*pItem);
+
+ // delete item if it was a generated one
+ if(pItem != pNewItem)
+ {
+ delete (SfxPoolItem*)pItem;
+ }
+ }
+ }
+ else
+ {
+ // clear item if ItemSet exists
+ if(mpItemSet)
+ {
+ mpItemSet->ClearItem(nWhich);
+ }
+ }
+ }
+
+ void AttributeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ ImpRemoveStyleSheet();
+ ImpAddStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+
+ SdrObject& rObj = GetSdrObject();
+ rObj.SetBoundRectDirty();
+ rObj.SetRectsDirty(sal_True);
+ }
+
+ SfxStyleSheet* AttributeProperties::GetStyleSheet() const
+ {
+ return mpStyleSheet;
+ }
+
+ void AttributeProperties::MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
+ {
+ OSL_ASSERT(pNewModel!=NULL);
+
+ if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
+ {
+ if(mpItemSet)
+ {
+ // migrate ItemSet to new pool. Scaling is NOT necessary
+ // because this functionality is used by UNDO only. Thus
+ // objects and ItemSets would be moved back to their original
+ // pool before usage.
+ SfxItemSet* pOldSet = mpItemSet;
+ SfxStyleSheet* pStySheet = GetStyleSheet();
+
+ if(pStySheet)
+ {
+ ImpRemoveStyleSheet();
+ }
+
+ mpItemSet = mpItemSet->Clone(FALSE, pDestPool);
+ GetSdrObject().GetModel()->MigrateItemSet(pOldSet, mpItemSet, pNewModel);
+
+ // set stylesheet (if used)
+ if(pStySheet)
+ {
+ // #i109515#
+ SfxItemPool* pStyleSheetPool = &pStySheet->GetPool().GetPool();
+
+ if(pStyleSheetPool == pDestPool)
+ {
+ // just re-set stylesheet
+ ImpAddStyleSheet(pStySheet, sal_True);
+ }
+ else
+ {
+ // StyleSheet is NOT from the correct pool.
+ // Look one up in the right pool with the same
+ // name or use the default.
+
+ // Look up the style in the new document.
+ OSL_ASSERT(pNewModel->GetStyleSheetPool() != NULL);
+ SfxStyleSheet* pNewStyleSheet = dynamic_cast<SfxStyleSheet*>(
+ pNewModel->GetStyleSheetPool()->Find(
+ pStySheet->GetName(),
+ SFX_STYLE_FAMILY_ALL));
+ if (pNewStyleSheet == NULL
+ || &pNewStyleSheet->GetPool().GetPool() != pDestPool)
+ {
+ // There is no copy of the style in the new
+ // document. Use the default as a fallback.
+ pNewStyleSheet = pNewModel->GetDefaultStyleSheet();
+ }
+ ImpAddStyleSheet(pNewStyleSheet, sal_True);
+ }
+ }
+
+ delete pOldSet;
+ }
+ }
+ }
+
+ void AttributeProperties::SetModel(SdrModel* pOldModel, SdrModel* pNewModel)
+ {
+ if(pOldModel != pNewModel && pNewModel && !pNewModel->IsLoading())
+ {
+ // For a living model move the items from one pool to the other
+ if(pOldModel)
+ {
+ // If metric has changed, scale items.
+ MapUnit aOldUnit(pOldModel->GetScaleUnit());
+ MapUnit aNewUnit(pNewModel->GetScaleUnit());
+ sal_Bool bScaleUnitChanged(aNewUnit != aOldUnit);
+ Fraction aMetricFactor;
+
+ if(bScaleUnitChanged)
+ {
+ aMetricFactor = GetMapFactor(aOldUnit, aNewUnit).X();
+ Scale(aMetricFactor);
+ }
+
+ // Move all styles which are used by the object to the new
+ // StyleSheet pool
+ SfxStyleSheet* pOldStyleSheet = GetStyleSheet();
+
+ if(pOldStyleSheet)
+ {
+ SfxStyleSheetBase* pSheet = pOldStyleSheet;
+ SfxStyleSheetBasePool* pOldPool = pOldModel->GetStyleSheetPool();
+ SfxStyleSheetBasePool* pNewPool = pNewModel->GetStyleSheetPool();
+ DBG_ASSERT(pOldPool, "Properties::SetModel(): Object has StyleSheet but no StyleSheetPool (!)");
+
+ if(pOldPool && pNewPool)
+ {
+ // build a list of to-be-copied Styles
+ List aList;
+ SfxStyleSheetBase* pAnchor = 0L;
+
+ while(pSheet)
+ {
+ pAnchor = pNewPool->Find(pSheet->GetName(), pSheet->GetFamily());
+
+ if(!pAnchor)
+ {
+ aList.Insert(pSheet, LIST_APPEND);
+ pSheet = pOldPool->Find(pSheet->GetParent(), pSheet->GetFamily());
+ }
+ else
+ {
+ // the style does exist
+ pSheet = 0L;
+ }
+ }
+
+ // copy and set the parents
+ pSheet = (SfxStyleSheetBase*)aList.First();
+ SfxStyleSheetBase* pNewSheet = 0L;
+ SfxStyleSheetBase* pLastSheet = 0L;
+ SfxStyleSheetBase* pForThisObject = 0L;
+
+ while(pSheet)
+ {
+ pNewSheet = &pNewPool->Make(pSheet->GetName(), pSheet->GetFamily(), pSheet->GetMask());
+ pNewSheet->GetItemSet().Put(pSheet->GetItemSet(), FALSE);
+
+ if(bScaleUnitChanged)
+ {
+ sdr::properties::ScaleItemSet(pNewSheet->GetItemSet(), aMetricFactor);
+ }
+
+ if(pLastSheet)
+ {
+ pLastSheet->SetParent(pNewSheet->GetName());
+ }
+
+ if(!pForThisObject)
+ {
+ pForThisObject = pNewSheet;
+ }
+
+ pLastSheet = pNewSheet;
+ pSheet = (SfxStyleSheetBase*)aList.Next();
+ }
+
+ // Set link to the Style found in the Pool
+ if(pAnchor && pLastSheet)
+ {
+ pLastSheet->SetParent(pAnchor->GetName());
+ }
+
+ // if list was empty (all Styles exist in destination pool)
+ // pForThisObject is not yet set
+ if(!pForThisObject && pAnchor)
+ {
+ pForThisObject = pAnchor;
+ }
+
+ // De-register at old and register at new Style
+ if(GetStyleSheet() != pForThisObject)
+ {
+ ImpRemoveStyleSheet();
+ ImpAddStyleSheet((SfxStyleSheet*)pForThisObject, sal_True);
+ }
+ }
+ else
+ {
+ // there is no StyleSheetPool in the new model, thus set
+ // all items as hard items in the object
+ List aList;
+ const SfxItemSet* pItemSet = &pOldStyleSheet->GetItemSet();
+
+ while(pItemSet)
+ {
+ aList.Insert((void*)pItemSet, CONTAINER_APPEND);
+ pItemSet = pItemSet->GetParent();
+ }
+
+ SfxItemSet* pNewSet = &CreateObjectSpecificItemSet(pNewModel->GetItemPool());
+ pItemSet = (SfxItemSet*)aList.Last();
+
+ while(pItemSet)
+ {
+ pNewSet->Put(*pItemSet);
+ pItemSet = (SfxItemSet*)aList.Prev();
+ }
+
+ // Items which were hard attributes before need to stay
+ if(mpItemSet)
+ {
+ SfxWhichIter aIter(*mpItemSet);
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while(nWhich)
+ {
+ if(mpItemSet->GetItemState(nWhich, FALSE) == SFX_ITEM_SET)
+ {
+ pNewSet->Put(mpItemSet->Get(nWhich));
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+
+ if(bScaleUnitChanged)
+ {
+ ScaleItemSet(*pNewSet, aMetricFactor);
+ }
+
+ if(mpItemSet)
+ {
+ if(GetStyleSheet())
+ {
+ ImpRemoveStyleSheet();
+ }
+
+ delete mpItemSet;
+ mpItemSet = 0L;
+ }
+
+ mpItemSet = pNewSet;
+ }
+ }
+ }
+
+ // each object gets the default Style if there is none set yet.
+ if(mpItemSet && !GetStyleSheet() && pNewModel && !pNewModel->IsLoading())
+ {
+ SetStyleSheet(pNewModel->GetDefaultStyleSheet(), sal_True);
+ }
+ }
+ }
+
+ void AttributeProperties::ForceStyleToHardAttributes()
+ {
+ if(GetStyleSheet() && HAS_BASE(SfxStyleSheet, mpStyleSheet))
+ {
+ // prepare copied, new itemset, but WITHOUT parent
+ GetObjectItemSet();
+ SfxItemSet* pDestItemSet = new SfxItemSet(*mpItemSet);
+ pDestItemSet->SetParent(0L);
+
+ // pepare forgetting the current stylesheet like in RemoveStyleSheet()
+ EndListening(*mpStyleSheet);
+ EndListening(mpStyleSheet->GetPool());
+
+ // prepare the iter; use the mpObjectItemSet which may have less
+ // WhichIDs than the style.
+ SfxWhichIter aIter(*pDestItemSet);
+ sal_uInt16 nWhich(aIter.FirstWhich());
+ const SfxPoolItem *pItem = NULL;
+
+ // now set all hard attributes of the current at the new itemset
+ while(nWhich)
+ {
+ // #i61284# use mpItemSet with parents, makes things easier and reduces to
+ // one loop
+ if(SFX_ITEM_SET == mpItemSet->GetItemState(nWhich, true, &pItem))
+ {
+ pDestItemSet->Put(*pItem);
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+
+ // replace itemsets
+ delete mpItemSet;
+ mpItemSet = pDestItemSet;
+
+ // set necessary changes like in RemoveStyleSheet()
+ GetSdrObject().SetBoundRectDirty();
+ GetSdrObject().SetRectsDirty(sal_True);
+
+ mpStyleSheet = NULL;
+ }
+ }
+
+ void AttributeProperties::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+ {
+ sal_Bool bHintUsed(sal_False);
+
+ SfxStyleSheetHint *pStyleHint = PTR_CAST(SfxStyleSheetHint, &rHint);
+
+ if(pStyleHint && pStyleHint->GetStyleSheet() == GetStyleSheet())
+ {
+ SdrObject& rObj = GetSdrObject();
+ //SdrPage* pPage = rObj.GetPage();
+
+ switch(pStyleHint->GetHint())
+ {
+ case SFX_STYLESHEET_CREATED :
+ {
+ // cannot happen, nothing to do
+ break;
+ }
+ case SFX_STYLESHEET_MODIFIED :
+ case SFX_STYLESHEET_CHANGED :
+ {
+ // notify change
+ break;
+ }
+ case SFX_STYLESHEET_ERASED :
+ case SFX_STYLESHEET_INDESTRUCTION :
+ {
+ // Style needs to be exchanged
+ SfxStyleSheet* pNewStSh = 0L;
+ SdrModel* pModel = rObj.GetModel();
+
+ // #111111#
+ // Do nothing if object is in destruction, else a StyleSheet may be found from
+ // a StyleSheetPool which is just being deleted itself. and thus it would be fatal
+ // to register as listener to that new StyleSheet.
+ if(pModel && !rObj.IsInDestruction())
+ {
+ if(HAS_BASE(SfxStyleSheet, GetStyleSheet()))
+ {
+ pNewStSh = (SfxStyleSheet*)pModel->GetStyleSheetPool()->Find(
+ GetStyleSheet()->GetParent(), GetStyleSheet()->GetFamily());
+ }
+
+ if(!pNewStSh)
+ {
+ pNewStSh = pModel->GetDefaultStyleSheet();
+ }
+ }
+
+ // remove used style, it's erased or in destruction
+ ImpRemoveStyleSheet();
+
+ if(pNewStSh)
+ {
+ ImpAddStyleSheet(pNewStSh, sal_True);
+ }
+
+ break;
+ }
+ }
+
+ // Get old BoundRect. Do this after the style change is handled
+ // in the ItemSet parts because GetBoundRect() may calculate a new
+ Rectangle aBoundRect = rObj.GetLastBoundRect();
+
+ rObj.SetRectsDirty(sal_True);
+
+ // tell the object about the change
+ rObj.SetChanged();
+ rObj.BroadcastObjectChange();
+
+ //if(pPage && pPage->IsInserted())
+ //{
+ // rObj.BroadcastObjectChange();
+ //}
+
+ rObj.SendUserCall(SDRUSERCALL_CHGATTR, aBoundRect);
+
+ bHintUsed = sal_True;
+ }
+
+ if(!bHintUsed)
+ {
+ // forward to SdrObject ATM. Not sure if this will be necessary
+ // in the future.
+ GetSdrObject().Notify(rBC, rHint);
+ }
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/captionproperties.cxx b/svx/source/sdr/properties/captionproperties.cxx
new file mode 100644
index 000000000000..15c480d5364e
--- /dev/null
+++ b/svx/source/sdr/properties/captionproperties.cxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/captionproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svl/style.hxx>
+#include <svx/svddef.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/svdocapt.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ // create a new itemset
+ SfxItemSet& CaptionProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ return *(new SfxItemSet(rPool,
+
+ // range from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // range from SdrCaptionObj
+ SDRATTR_CAPTION_FIRST, SDRATTR_CAPTION_LAST,
+
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+
+ // end
+ 0, 0));
+ }
+
+ CaptionProperties::CaptionProperties(SdrObject& rObj)
+ : RectangleProperties(rObj)
+ {
+ }
+
+ CaptionProperties::CaptionProperties(const CaptionProperties& rProps, SdrObject& rObj)
+ : RectangleProperties(rProps, rObj)
+ {
+ }
+
+ CaptionProperties::~CaptionProperties()
+ {
+ }
+
+ BaseProperties& CaptionProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new CaptionProperties(*this, rObj));
+ }
+
+ void CaptionProperties::ItemSetChanged(const SfxItemSet& rSet)
+ {
+ SdrCaptionObj& rObj = (SdrCaptionObj&)GetSdrObject();
+
+ // local changes
+ rObj.ImpRecalcTail();
+
+ // call parent
+ RectangleProperties::ItemSetChanged(rSet);
+ }
+
+ void CaptionProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ SdrCaptionObj& rObj = (SdrCaptionObj&)GetSdrObject();
+
+ // call parent
+ RectangleProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+
+ // local changes
+ rObj.ImpRecalcTail();
+ }
+
+ void CaptionProperties::ForceDefaultAttributes()
+ {
+ // call parent
+ RectangleProperties::ForceDefaultAttributes();
+
+ // force ItemSet
+ GetObjectItemSet();
+
+ // this was set by TextProperties::ForceDefaultAttributes(),
+ // retet to default
+ mpItemSet->ClearItem(XATTR_LINESTYLE);
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/circleproperties.cxx b/svx/source/sdr/properties/circleproperties.cxx
new file mode 100644
index 000000000000..4cc3e7fcf262
--- /dev/null
+++ b/svx/source/sdr/properties/circleproperties.cxx
@@ -0,0 +1,160 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/circleproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svl/style.hxx>
+#include <svx/svddef.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/svdocirc.hxx>
+#include <svx/sxcikitm.hxx>
+#include <svx/sxciaitm.hxx>
+#include <svx/sxciaitm.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ // create a new itemset
+ SfxItemSet& CircleProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ return *(new SfxItemSet(rPool,
+
+ // range from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // range from SdrCircObj
+ SDRATTR_CIRC_FIRST, SDRATTR_CIRC_LAST,
+
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+
+ // end
+ 0, 0));
+ }
+
+ CircleProperties::CircleProperties(SdrObject& rObj)
+ : RectangleProperties(rObj)
+ {
+ }
+
+ CircleProperties::CircleProperties(const CircleProperties& rProps, SdrObject& rObj)
+ : RectangleProperties(rProps, rObj)
+ {
+ }
+
+ CircleProperties::~CircleProperties()
+ {
+ }
+
+ BaseProperties& CircleProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new CircleProperties(*this, rObj));
+ }
+
+ void CircleProperties::ItemSetChanged(const SfxItemSet& rSet)
+ {
+ SdrCircObj& rObj = (SdrCircObj&)GetSdrObject();
+
+ // call parent
+ RectangleProperties::ItemSetChanged(rSet);
+
+ // local changes
+ rObj.ImpSetAttrToCircInfo();
+ }
+
+ void CircleProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ SdrCircObj& rObj = (SdrCircObj&)GetSdrObject();
+
+ // local changes
+ rObj.SetXPolyDirty();
+
+ // call parent
+ RectangleProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+
+ // local changes
+ rObj.ImpSetAttrToCircInfo();
+ }
+
+ void CircleProperties::ForceDefaultAttributes()
+ {
+ SdrCircObj& rObj = (SdrCircObj&)GetSdrObject();
+ SdrCircKind eKindA = SDRCIRC_FULL;
+ SdrObjKind eKind = rObj.GetCircleKind();
+
+ if(eKind == OBJ_SECT)
+ {
+ eKindA = SDRCIRC_SECT;
+ }
+ else if(eKind == OBJ_CARC)
+ {
+ eKindA = SDRCIRC_ARC;
+ }
+ else if(eKind == OBJ_CCUT)
+ {
+ eKindA = SDRCIRC_CUT;
+ }
+
+ if(eKindA != SDRCIRC_FULL)
+ {
+ // force ItemSet
+ GetObjectItemSet();
+
+ mpItemSet->Put(SdrCircKindItem(eKindA));
+
+ if(rObj.GetStartWink())
+ {
+ mpItemSet->Put(SdrCircStartAngleItem(rObj.GetStartWink()));
+ }
+
+ if(rObj.GetEndWink() != 36000)
+ {
+ mpItemSet->Put(SdrCircEndAngleItem(rObj.GetEndWink()));
+ }
+ }
+
+ // call parent after SetObjectItem(SdrCircKindItem())
+ // because ForceDefaultAttr() will call
+ // ImpSetAttrToCircInfo() which needs a correct
+ // SdrCircKindItem
+ RectangleProperties::ForceDefaultAttributes();
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/connectorproperties.cxx b/svx/source/sdr/properties/connectorproperties.cxx
new file mode 100644
index 000000000000..f0a9f83e29c8
--- /dev/null
+++ b/svx/source/sdr/properties/connectorproperties.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/connectorproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svl/style.hxx>
+#include <svx/svddef.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/svdoedge.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ // create a new itemset
+ SfxItemSet& ConnectorProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ return *(new SfxItemSet(rPool,
+
+ // range from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // range from SdrEdgeObj
+ SDRATTR_EDGE_FIRST, SDRATTR_EDGE_LAST,
+
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+
+ // end
+ 0, 0));
+ }
+
+ ConnectorProperties::ConnectorProperties(SdrObject& rObj)
+ : TextProperties(rObj)
+ {
+ }
+
+ ConnectorProperties::ConnectorProperties(const ConnectorProperties& rProps, SdrObject& rObj)
+ : TextProperties(rProps, rObj)
+ {
+ }
+
+ ConnectorProperties::~ConnectorProperties()
+ {
+ }
+
+ BaseProperties& ConnectorProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new ConnectorProperties(*this, rObj));
+ }
+
+ void ConnectorProperties::ItemSetChanged(const SfxItemSet& rSet)
+ {
+ SdrEdgeObj& rObj = (SdrEdgeObj&)GetSdrObject();
+
+ // call parent
+ TextProperties::ItemSetChanged(rSet);
+
+ // local changes
+ rObj.ImpSetAttrToEdgeInfo();
+ }
+
+ void ConnectorProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ SdrEdgeObj& rObj = (SdrEdgeObj&)GetSdrObject();
+
+ // call parent
+ TextProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+
+ // local changes
+ rObj.ImpSetAttrToEdgeInfo();
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/customshapeproperties.cxx b/svx/source/sdr/properties/customshapeproperties.cxx
new file mode 100644
index 000000000000..3abce475f1b8
--- /dev/null
+++ b/svx/source/sdr/properties/customshapeproperties.cxx
@@ -0,0 +1,242 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/customshapeproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svl/style.hxx>
+#include <svx/svdoashp.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/sdtagitm.hxx>
+#include <svl/whiter.hxx>
+#include <svl/itemset.hxx>
+#include <svl/smplhint.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ void CustomShapeProperties::UpdateTextFrameStatus()
+ {
+ SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
+ SdrTextAutoGrowHeightItem& rAutoGrowHeightItem =
+ (SdrTextAutoGrowHeightItem&)rObj.GetMergedItem( SDRATTR_TEXT_AUTOGROWHEIGHT );
+ rObj.bTextFrame = rAutoGrowHeightItem.GetValue() != 0;
+
+ if ( rObj.bTextFrame )
+ rObj.NbcAdjustTextFrameWidthAndHeight();
+ }
+
+ SfxItemSet& CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ return *(new SfxItemSet(rPool,
+
+ // ranges from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // Graphic Attributes
+ SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
+
+ // 3d Properties
+ SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
+
+ // CustomShape properties
+ SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
+
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+
+ // end
+ 0, 0));
+ }
+ sal_Bool CustomShapeProperties::AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem ) const
+ {
+ sal_Bool bAllowItemChange = sal_True;
+ if ( !pNewItem )
+ {
+ if ( ( nWhich >= SDRATTR_CUSTOMSHAPE_FIRST ) && ( nWhich <= SDRATTR_CUSTOMSHAPE_LAST ) )
+ bAllowItemChange = sal_False;
+ }
+ if ( bAllowItemChange )
+ bAllowItemChange = TextProperties::AllowItemChange( nWhich, pNewItem );
+ return bAllowItemChange;
+ }
+ void CustomShapeProperties::ClearObjectItem(const sal_uInt16 nWhich)
+ {
+ if ( !nWhich )
+ {
+ SfxWhichIter aIter( *mpItemSet );
+ sal_uInt16 nWhich2 = aIter.FirstWhich();
+ while( nWhich2 )
+ {
+ TextProperties::ClearObjectItemDirect( nWhich2 );
+ nWhich2 = aIter.NextWhich();
+ }
+ SfxItemSet aSet((SfxItemPool&)(*GetSdrObject().GetObjectItemPool()));
+ ItemSetChanged(aSet);
+ }
+ else
+ TextProperties::ClearObjectItem( nWhich );
+ }
+ void CustomShapeProperties::ClearObjectItemDirect(const sal_uInt16 nWhich)
+ {
+ if ( !nWhich )
+ {
+ SfxWhichIter aIter( *mpItemSet );
+ sal_uInt16 nWhich2 = aIter.FirstWhich();
+ while( nWhich2 )
+ {
+ TextProperties::ClearObjectItemDirect( nWhich2 );
+ nWhich2 = aIter.NextWhich();
+ }
+ }
+ else
+ TextProperties::ClearObjectItemDirect( nWhich );
+ }
+ void CustomShapeProperties::ItemSetChanged(const SfxItemSet& rSet)
+ {
+ SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject();
+
+ if( SFX_ITEM_SET == rSet.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) )
+ {
+ rObj.bTextFrame = ((SdrTextAutoGrowHeightItem&)rSet.Get( SDRATTR_TEXT_AUTOGROWHEIGHT )).GetValue() != 0;
+ }
+
+ // call parent
+ TextProperties::ItemSetChanged(rSet);
+
+ // local changes, removing cached objects
+ rObj.InvalidateRenderGeometry();
+ }
+ void CustomShapeProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
+ {
+ SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject();
+ //OutlinerParaObject* pParaObj = rObj.GetOutlinerParaObject();
+
+ if( pNewItem && ( SDRATTR_TEXT_AUTOGROWHEIGHT == nWhich ) )
+ {
+ rObj.bTextFrame = ((SdrTextAutoGrowHeightItem*)pNewItem)->GetValue() != 0;
+ }
+ // call parent
+ TextProperties::ItemChange( nWhich, pNewItem );
+
+ rObj.InvalidateRenderGeometry();
+ }
+ void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr );
+ UpdateTextFrameStatus();
+ }
+ void CustomShapeProperties::ForceDefaultAttributes()
+ {
+ UpdateTextFrameStatus();
+
+/* SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml
+
+ SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
+ sal_Bool bTextFrame(rObj.IsTextFrame());
+
+ // force ItemSet
+ GetObjectItemSet();
+
+ if(bTextFrame)
+ {
+ mpItemSet->Put(XLineStyleItem(XLINE_NONE));
+ mpItemSet->Put(XFillColorItem(String(), Color(COL_WHITE)));
+ mpItemSet->Put(XFillStyleItem(XFILL_NONE));
+ }
+ else
+ {
+ mpItemSet->Put(SvxAdjustItem(SVX_ADJUST_CENTER));
+ mpItemSet->Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER));
+ mpItemSet->Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
+ }
+*/
+ }
+ CustomShapeProperties::CustomShapeProperties(SdrObject& rObj)
+ : TextProperties(rObj)
+ {
+ }
+
+ CustomShapeProperties::CustomShapeProperties(const CustomShapeProperties& rProps, SdrObject& rObj)
+ : TextProperties(rProps, rObj)
+ {
+ }
+
+ CustomShapeProperties::~CustomShapeProperties()
+ {
+ }
+
+ BaseProperties& CustomShapeProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new CustomShapeProperties(*this, rObj));
+ }
+ void CustomShapeProperties::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+ {
+ TextProperties::Notify( rBC, rHint );
+
+ sal_Bool bRemoveRenderGeometry = sal_False;
+
+ const SfxStyleSheetHint *pStyleHint = PTR_CAST( SfxStyleSheetHint, &rHint );
+ const SfxSimpleHint *pSimpleHint = PTR_CAST( SfxSimpleHint, &rHint );
+ if ( pStyleHint && pStyleHint->GetStyleSheet() == GetStyleSheet() )
+ {
+ switch( pStyleHint->GetHint() )
+ {
+ case SFX_STYLESHEET_MODIFIED :
+ case SFX_STYLESHEET_CHANGED :
+ bRemoveRenderGeometry = sal_True;
+ break;
+ };
+ }
+ else if ( pSimpleHint && pSimpleHint->GetId() == SFX_HINT_DATACHANGED )
+ {
+ bRemoveRenderGeometry = sal_True;
+ }
+ if ( bRemoveRenderGeometry )
+ {
+ UpdateTextFrameStatus();
+
+ // local changes, removing cached objects
+ SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject();
+ rObj.InvalidateRenderGeometry();
+ }
+
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/defaultproperties.cxx b/svx/source/sdr/properties/defaultproperties.cxx
new file mode 100644
index 000000000000..e19e2fccce31
--- /dev/null
+++ b/svx/source/sdr/properties/defaultproperties.cxx
@@ -0,0 +1,240 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/defaultproperties.hxx>
+#include <svx/sdr/properties/itemsettools.hxx>
+#include <svl/itemset.hxx>
+#include <svl/whiter.hxx>
+
+#include <vector>
+#include <svx/svdobj.hxx>
+#include <svx/svddef.hxx>
+#include <svx/svdpool.hxx>
+#include <editeng/eeitem.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ SfxItemSet& DefaultProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ // Basic implementation; Basic object has NO attributes
+ return *(new SfxItemSet(rPool));
+ }
+
+ DefaultProperties::DefaultProperties(SdrObject& rObj)
+ : BaseProperties(rObj),
+ mpItemSet(0L)
+ {
+ }
+
+ DefaultProperties::DefaultProperties(const DefaultProperties& rProps, SdrObject& rObj)
+ : BaseProperties(rObj),
+ mpItemSet(0L)
+ {
+ if(rProps.mpItemSet)
+ {
+ mpItemSet = rProps.mpItemSet->Clone(TRUE);
+
+ // do not keep parent info, this may be changed by later construrtors.
+ // This class just copies the ItemSet, ignore parent.
+ if(mpItemSet && mpItemSet->GetParent())
+ {
+ mpItemSet->SetParent(0L);
+ }
+ }
+ }
+
+ BaseProperties& DefaultProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new DefaultProperties(*this, rObj));
+ }
+
+ DefaultProperties::~DefaultProperties()
+ {
+ if(mpItemSet)
+ {
+ delete mpItemSet;
+ mpItemSet = 0L;
+ }
+ }
+
+ const SfxItemSet& DefaultProperties::GetObjectItemSet() const
+ {
+ if(!mpItemSet)
+ {
+ ((DefaultProperties*)this)->mpItemSet = &(((DefaultProperties*)this)->CreateObjectSpecificItemSet(*GetSdrObject().GetObjectItemPool()));
+ ((DefaultProperties*)this)->ForceDefaultAttributes();
+ }
+
+ DBG_ASSERT(mpItemSet, "Could not create an SfxItemSet(!)");
+
+ return *mpItemSet;
+ }
+
+ void DefaultProperties::SetObjectItem(const SfxPoolItem& rItem)
+ {
+ const sal_uInt16 nWhichID(rItem.Which());
+
+ if(AllowItemChange(nWhichID, &rItem))
+ {
+ ItemChange(nWhichID, &rItem);
+ PostItemChange(nWhichID);
+
+ SfxItemSet aSet(*GetSdrObject().GetObjectItemPool(), nWhichID, nWhichID);
+ aSet.Put(rItem);
+ ItemSetChanged(aSet);
+ }
+ }
+
+ void DefaultProperties::SetObjectItemDirect(const SfxPoolItem& rItem)
+ {
+ const sal_uInt16 nWhichID(rItem.Which());
+
+ if(AllowItemChange(nWhichID, &rItem))
+ {
+ ItemChange(nWhichID, &rItem);
+ }
+ }
+
+ void DefaultProperties::ClearObjectItem(const sal_uInt16 nWhich)
+ {
+ if(AllowItemChange(nWhich))
+ {
+ ItemChange(nWhich);
+ PostItemChange(nWhich);
+
+ if(nWhich)
+ {
+ SfxItemSet aSet(*GetSdrObject().GetObjectItemPool(), nWhich, nWhich, 0, 0);
+ ItemSetChanged(aSet);
+ }
+ }
+ }
+
+ void DefaultProperties::ClearObjectItemDirect(const sal_uInt16 nWhich)
+ {
+ if(AllowItemChange(nWhich))
+ {
+ ItemChange(nWhich);
+ }
+ }
+
+ void DefaultProperties::SetObjectItemSet(const SfxItemSet& rSet)
+ {
+ SfxWhichIter aWhichIter(rSet);
+ sal_uInt16 nWhich(aWhichIter.FirstWhich());
+ const SfxPoolItem *pPoolItem;
+ std::vector< sal_uInt16 > aPostItemChangeList;
+ sal_Bool bDidChange(sal_False);
+ SfxItemSet aSet(*GetSdrObject().GetObjectItemPool(), SDRATTR_START, EE_ITEMS_END, 0, 0);
+
+ // give a hint to STL_Vector
+ aPostItemChangeList.reserve(rSet.Count());
+
+ while(nWhich)
+ {
+ if(SFX_ITEM_SET == rSet.GetItemState(nWhich, FALSE, &pPoolItem))
+ {
+ if(AllowItemChange(nWhich, pPoolItem))
+ {
+ bDidChange = sal_True;
+ ItemChange(nWhich, pPoolItem);
+ aPostItemChangeList.push_back( nWhich );
+ aSet.Put(*pPoolItem);
+ }
+ }
+
+ nWhich = aWhichIter.NextWhich();
+ }
+
+ if(bDidChange)
+ {
+ std::vector< sal_uInt16 >::iterator aIter = aPostItemChangeList.begin();
+ const std::vector< sal_uInt16 >::iterator aEnd = aPostItemChangeList.end();
+
+ while(aIter != aEnd)
+ {
+ PostItemChange(*aIter);
+ aIter++;
+ }
+
+ ItemSetChanged(aSet);
+ }
+ }
+
+ void DefaultProperties::ItemSetChanged(const SfxItemSet& /*rSet*/)
+ {
+ }
+
+ sal_Bool DefaultProperties::AllowItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) const
+ {
+ return sal_True;
+ }
+
+ void DefaultProperties::ItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/)
+ {
+ }
+
+ void DefaultProperties::PostItemChange(const sal_uInt16 /*nWhich*/)
+ {
+ }
+
+ void DefaultProperties::SetStyleSheet(SfxStyleSheet* /*pNewStyleSheet*/, sal_Bool /*bDontRemoveHardAttr*/)
+ {
+ // no StyleSheet in DefaultProperties
+ }
+
+ SfxStyleSheet* DefaultProperties::GetStyleSheet() const
+ {
+ // no StyleSheet in DefaultProperties
+ return 0L;
+ }
+
+ void DefaultProperties::ForceDefaultAttributes()
+ {
+ }
+
+ void DefaultProperties::Scale(const Fraction& rScale)
+ {
+ if(mpItemSet)
+ {
+ ScaleItemSet(*mpItemSet, rScale);
+ }
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/e3dcompoundproperties.cxx b/svx/source/sdr/properties/e3dcompoundproperties.cxx
new file mode 100644
index 000000000000..39a6fe42c6ae
--- /dev/null
+++ b/svx/source/sdr/properties/e3dcompoundproperties.cxx
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/e3dcompoundproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/scene3d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ E3dCompoundProperties::E3dCompoundProperties(SdrObject& rObj)
+ : E3dProperties(rObj)
+ {
+ }
+
+ E3dCompoundProperties::E3dCompoundProperties(const E3dCompoundProperties& rProps, SdrObject& rObj)
+ : E3dProperties(rProps, rObj)
+ {
+ }
+
+ E3dCompoundProperties::~E3dCompoundProperties()
+ {
+ }
+
+ BaseProperties& E3dCompoundProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new E3dCompoundProperties(*this, rObj));
+ }
+
+ const SfxItemSet& E3dCompoundProperties::GetObjectItemSet() const
+ {
+ //DBG_ASSERT(sal_False, "E3dCompoundProperties::GetObjectItemSet() maybe the wrong call (!)");
+ return E3dProperties::GetObjectItemSet();
+ }
+
+ const SfxItemSet& E3dCompoundProperties::GetMergedItemSet() const
+ {
+ // include Items of scene this object belongs to
+ E3dCompoundObject& rObj = (E3dCompoundObject&)GetSdrObject();
+ E3dScene* pScene = rObj.GetScene();
+
+ if(pScene)
+ {
+ // force ItemSet
+ GetObjectItemSet();
+
+ // add filtered scene properties (SDRATTR_3DSCENE_) to local itemset
+ SfxItemSet aSet(*mpItemSet->GetPool(), SDRATTR_3DSCENE_FIRST, SDRATTR_3DSCENE_LAST);
+ aSet.Put(pScene->GetProperties().GetObjectItemSet());
+ mpItemSet->Put(aSet);
+ }
+
+ // call parent
+ return E3dProperties::GetMergedItemSet();
+ }
+
+ void E3dCompoundProperties::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems)
+ {
+ // Set scene specific items at scene
+ E3dCompoundObject& rObj = (E3dCompoundObject&)GetSdrObject();
+ E3dScene* pScene = rObj.GetScene();
+
+ if(pScene)
+ {
+ // force ItemSet
+ GetObjectItemSet();
+
+ // Generate filtered scene properties (SDRATTR_3DSCENE_) itemset
+ SfxItemSet aSet(*mpItemSet->GetPool(), SDRATTR_3DSCENE_FIRST, SDRATTR_3DSCENE_LAST);
+ aSet.Put(rSet);
+
+ if(bClearAllItems)
+ {
+ pScene->GetProperties().ClearObjectItem();
+ }
+
+ if(aSet.Count())
+ {
+ pScene->GetProperties().SetObjectItemSet(aSet);
+ }
+ }
+
+ // call parent. This will set items on local object, too.
+ E3dProperties::SetMergedItemSet(rSet, bClearAllItems);
+ }
+
+ void E3dCompoundProperties::PostItemChange(const sal_uInt16 nWhich)
+ {
+ // call parent
+ E3dProperties::PostItemChange(nWhich);
+
+ // handle value change
+ E3dCompoundObject& rObj = (E3dCompoundObject&)GetSdrObject();
+
+ switch(nWhich)
+ {
+ // #i28528#
+ // Added extra Item (Bool) for chart2 to be able to show reduced line geometry
+ case SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_DOUBLE_SIDED:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_NORMALS_KIND:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_NORMALS_INVERT:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_TEXTURE_PROJ_X:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_TEXTURE_PROJ_Y:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ }
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/e3dextrudeproperties.cxx b/svx/source/sdr/properties/e3dextrudeproperties.cxx
new file mode 100644
index 000000000000..a86addb11e43
--- /dev/null
+++ b/svx/source/sdr/properties/e3dextrudeproperties.cxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/e3dextrudeproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svx/extrud3d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ E3dExtrudeProperties::E3dExtrudeProperties(SdrObject& rObj)
+ : E3dCompoundProperties(rObj)
+ {
+ }
+
+ E3dExtrudeProperties::E3dExtrudeProperties(const E3dExtrudeProperties& rProps, SdrObject& rObj)
+ : E3dCompoundProperties(rProps, rObj)
+ {
+ }
+
+ E3dExtrudeProperties::~E3dExtrudeProperties()
+ {
+ }
+
+ BaseProperties& E3dExtrudeProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new E3dExtrudeProperties(*this, rObj));
+ }
+
+ void E3dExtrudeProperties::PostItemChange(const sal_uInt16 nWhich)
+ {
+ // call parent
+ E3dCompoundProperties::PostItemChange(nWhich);
+
+ // handle value change
+ E3dExtrudeObj& rObj = (E3dExtrudeObj&)GetSdrObject();
+
+ switch(nWhich)
+ {
+ case SDRATTR_3DOBJ_PERCENT_DIAGONAL:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_BACKSCALE:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_DEPTH:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ }
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/e3dlatheproperties.cxx b/svx/source/sdr/properties/e3dlatheproperties.cxx
new file mode 100644
index 000000000000..662070fad549
--- /dev/null
+++ b/svx/source/sdr/properties/e3dlatheproperties.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/e3dlatheproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svx/lathe3d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ E3dLatheProperties::E3dLatheProperties(SdrObject& rObj)
+ : E3dCompoundProperties(rObj)
+ {
+ }
+
+ E3dLatheProperties::E3dLatheProperties(const E3dLatheProperties& rProps, SdrObject& rObj)
+ : E3dCompoundProperties(rProps, rObj)
+ {
+ }
+
+ E3dLatheProperties::~E3dLatheProperties()
+ {
+ }
+
+ BaseProperties& E3dLatheProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new E3dLatheProperties(*this, rObj));
+ }
+
+ void E3dLatheProperties::PostItemChange(const sal_uInt16 nWhich)
+ {
+ // call parent
+ E3dCompoundProperties::PostItemChange(nWhich);
+
+ // handle value change
+ E3dLatheObj& rObj = (E3dLatheObj&)GetSdrObject();
+
+ switch(nWhich)
+ {
+ case SDRATTR_3DOBJ_HORZ_SEGS:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_VERT_SEGS:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_PERCENT_DIAGONAL:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_BACKSCALE:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_END_ANGLE:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ }
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/e3dproperties.cxx b/svx/source/sdr/properties/e3dproperties.cxx
new file mode 100644
index 000000000000..85fe364ca3f8
--- /dev/null
+++ b/svx/source/sdr/properties/e3dproperties.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/e3dproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svx/svddef.hxx>
+#include <svx/obj3d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ // create a new itemset
+ SfxItemSet& E3dProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ return *(new SfxItemSet(rPool,
+
+ // ranges from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // ranges from E3dObject, contains object and scene because of GetMergedItemSet()
+ SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
+
+ // end
+ 0, 0));
+ }
+
+ E3dProperties::E3dProperties(SdrObject& rObj)
+ : AttributeProperties(rObj)
+ {
+ }
+
+ E3dProperties::E3dProperties(const E3dProperties& rProps, SdrObject& rObj)
+ : AttributeProperties(rProps, rObj)
+ {
+ }
+
+ E3dProperties::~E3dProperties()
+ {
+ }
+
+ BaseProperties& E3dProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new E3dProperties(*this, rObj));
+ }
+
+ void E3dProperties::ItemSetChanged(const SfxItemSet& rSet)
+ {
+ E3dObject& rObj = (E3dObject&)GetSdrObject();
+
+ // call parent
+ AttributeProperties::ItemSetChanged(rSet);
+
+ // local changes
+ rObj.StructureChanged();
+ }
+
+ void E3dProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ // call parent
+ AttributeProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+
+ // propagate call to contained objects
+ const SdrObjList* pSub = ((const E3dObject&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ pSub->GetObj(a)->GetProperties().SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+ }
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/e3dsceneproperties.cxx b/svx/source/sdr/properties/e3dsceneproperties.cxx
new file mode 100644
index 000000000000..2c981128cbc3
--- /dev/null
+++ b/svx/source/sdr/properties/e3dsceneproperties.cxx
@@ -0,0 +1,337 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/e3dsceneproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svl/whiter.hxx>
+#include <svx/svddef.hxx>
+#include <svx/scene3d.hxx>
+#include <svditer.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ E3dSceneProperties::E3dSceneProperties(SdrObject& rObj)
+ : E3dProperties(rObj)
+ {
+ }
+
+ E3dSceneProperties::E3dSceneProperties(const E3dSceneProperties& rProps, SdrObject& rObj)
+ : E3dProperties(rProps, rObj)
+ {
+ }
+
+ E3dSceneProperties::~E3dSceneProperties()
+ {
+ }
+
+ BaseProperties& E3dSceneProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new E3dSceneProperties(*this, rObj));
+ }
+
+ const SfxItemSet& E3dSceneProperties::GetObjectItemSet() const
+ {
+ //DBG_ASSERT(sal_False, "E3dSceneProperties::GetObjectItemSet() maybe the wrong call (!)");
+ return E3dProperties::GetObjectItemSet();
+ }
+
+ const SfxItemSet& E3dSceneProperties::GetMergedItemSet() const
+ {
+ // prepare ItemSet
+ if(mpItemSet)
+ {
+ // filter for SDRATTR_3DSCENE_ items, only keep those items
+ SfxItemSet aNew(*mpItemSet->GetPool(), SDRATTR_3DSCENE_FIRST, SDRATTR_3DSCENE_LAST);
+ aNew.Put(*mpItemSet);
+ mpItemSet->ClearItem();
+ mpItemSet->Put(aNew);
+ }
+ else
+ {
+ // No ItemSet yet, force local ItemSet
+ GetObjectItemSet();
+ }
+
+ // collect all ItemSets of contained 3d objects
+ const SdrObjList* pSub = ((const E3dScene&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ SdrObject* pObj = pSub->GetObj(a);
+
+ if(pObj && pObj->ISA(E3dCompoundObject))
+ {
+ const SfxItemSet& rSet = pObj->GetMergedItemSet();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich(aIter.FirstWhich());
+
+ while(nWhich)
+ {
+ // Leave out the SDRATTR_3DSCENE_ range, this would only be double
+ // and always equal.
+ if(nWhich <= SDRATTR_3DSCENE_FIRST || nWhich >= SDRATTR_3DSCENE_LAST)
+ {
+ if(SFX_ITEM_DONTCARE == rSet.GetItemState(nWhich, FALSE))
+ {
+ mpItemSet->InvalidateItem(nWhich);
+ }
+ else
+ {
+ mpItemSet->MergeValue(rSet.Get(nWhich), TRUE);
+ }
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+ }
+
+ // call parent
+ return E3dProperties::GetMergedItemSet();
+ }
+
+ void E3dSceneProperties::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems)
+ {
+ // Set SDRATTR_3DOBJ_ range at contained objects.
+ const SdrObjList* pSub = ((const E3dScene&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ if(nCount)
+ {
+ // Generate filtered ItemSet which contains all but the SDRATTR_3DSCENE items.
+ // #i50808# Leak fix, Clone produces a new instance and we get ownership here
+ SfxItemSet* pNewSet = rSet.Clone(TRUE);
+ DBG_ASSERT(pNewSet, "E3dSceneProperties::SetMergedItemSet(): Could not clone ItemSet (!)");
+
+ for(sal_uInt16 b(SDRATTR_3DSCENE_FIRST); b <= SDRATTR_3DSCENE_LAST; b++)
+ {
+ pNewSet->ClearItem(b);
+ }
+
+ if(pNewSet->Count())
+ {
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ SdrObject* pObj = pSub->GetObj(a);
+
+ if(pObj && pObj->ISA(E3dCompoundObject))
+ {
+ // set merged ItemSet at contained 3d object.
+ pObj->SetMergedItemSet(*pNewSet, bClearAllItems);
+ }
+ }
+ }
+
+ delete pNewSet;
+ }
+
+ // call parent. This will set items on local object, too.
+ E3dProperties::SetMergedItemSet(rSet, bClearAllItems);
+ }
+
+ void E3dSceneProperties::SetMergedItem(const SfxPoolItem& rItem)
+ {
+ const SdrObjList* pSub = ((const E3dScene&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ pSub->GetObj(a)->SetMergedItem(rItem);
+ }
+
+ // #i43809# call parent. This will set items on local object, too.
+ E3dProperties::SetMergedItem(rItem);
+ }
+
+ void E3dSceneProperties::ClearMergedItem(const sal_uInt16 nWhich)
+ {
+ const SdrObjList* pSub = ((const E3dScene&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ pSub->GetObj(a)->ClearMergedItem(nWhich);
+ }
+
+ // #i43809# call parent. This will clear items on local object, too.
+ E3dProperties::ClearMergedItem(nWhich);
+ }
+
+ void E3dSceneProperties::PostItemChange(const sal_uInt16 nWhich)
+ {
+ // call parent
+ E3dProperties::PostItemChange(nWhich);
+
+ // local changes
+ E3dScene& rObj = (E3dScene&)GetSdrObject();
+ rObj.StructureChanged();
+
+ switch(nWhich)
+ {
+ case SDRATTR_3DSCENE_PERSPECTIVE :
+ case SDRATTR_3DSCENE_DISTANCE :
+ case SDRATTR_3DSCENE_FOCAL_LENGTH :
+ {
+ // #83387#, #83391#
+ // one common function for the camera attributes
+ // since SetCamera() sets all three back to the ItemSet
+ Camera3D aSceneCam(rObj.GetCamera());
+ sal_Bool bChange(sal_False);
+
+ // for SDRATTR_3DSCENE_PERSPECTIVE:
+ if(aSceneCam.GetProjection() != rObj.GetPerspective())
+ {
+ aSceneCam.SetProjection(rObj.GetPerspective());
+ bChange = sal_True;
+ }
+
+ // for SDRATTR_3DSCENE_DISTANCE:
+ basegfx::B3DPoint aActualPosition(aSceneCam.GetPosition());
+ double fNew = rObj.GetDistance();
+
+ if(fNew != aActualPosition.getZ())
+ {
+ aSceneCam.SetPosition(basegfx::B3DPoint(aActualPosition.getX(), aActualPosition.getY(), fNew));
+ bChange = sal_True;
+ }
+
+ // for SDRATTR_3DSCENE_FOCAL_LENGTH:
+ fNew = rObj.GetFocalLength() / 100.0;
+
+ if(aSceneCam.GetFocalLength() != fNew)
+ {
+ aSceneCam.SetFocalLength(fNew);
+ bChange = sal_True;
+ }
+
+ // for all
+ if(bChange)
+ {
+ rObj.SetCamera(aSceneCam);
+ }
+
+ break;
+ }
+ }
+ }
+
+ void E3dSceneProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ const SdrObjList* pSub = ((const E3dScene&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ pSub->GetObj(a)->SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+ }
+ }
+
+ SfxStyleSheet* E3dSceneProperties::GetStyleSheet() const
+ {
+ SfxStyleSheet* pRetval = 0L;
+
+ const SdrObjList* pSub = ((const E3dScene&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ SfxStyleSheet* pCandidate = pSub->GetObj(a)->GetStyleSheet();
+
+ if(pRetval)
+ {
+ if(pCandidate != pRetval)
+ {
+ // different StyleSheelts, return none
+ return 0L;
+ }
+ }
+ else
+ {
+ pRetval = pCandidate;
+ }
+ }
+
+ return pRetval;
+ }
+
+ void E3dSceneProperties::MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
+ {
+ if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
+ {
+ // call parent
+ E3dProperties::MoveToItemPool(pSrcPool, pDestPool, pNewModel);
+
+ // own reaction, but only with outmost scene
+ E3dScene& rObj = (E3dScene&)GetSdrObject();
+ const SdrObjList* pSubList = rObj.GetSubList();
+
+ if(pSubList && rObj.GetScene() == &rObj)
+ {
+ SdrObjListIter a3DIterator(*pSubList, IM_DEEPWITHGROUPS);
+
+ while(a3DIterator.IsMore())
+ {
+ E3dObject* pObj = (E3dObject*)a3DIterator.Next();
+ DBG_ASSERT(pObj->ISA(E3dObject), "In scenes there are only 3D objects allowed (!)");
+ pObj->GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
+ }
+ }
+ }
+ }
+
+ void E3dSceneProperties::SetSceneItemsFromCamera()
+ {
+ // force ItemSet
+ GetObjectItemSet();
+
+ E3dScene& rObj = (E3dScene&)GetSdrObject();
+ Camera3D aSceneCam(rObj.GetCamera());
+
+ // ProjectionType
+ mpItemSet->Put(Svx3DPerspectiveItem((UINT16)aSceneCam.GetProjection()));
+
+ // CamPos
+ mpItemSet->Put(Svx3DDistanceItem((UINT32)(aSceneCam.GetPosition().getZ() + 0.5)));
+
+ // FocalLength
+ mpItemSet->Put(Svx3DFocalLengthItem((UINT32)((aSceneCam.GetFocalLength() * 100.0) + 0.5)));
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/e3dsphereproperties.cxx b/svx/source/sdr/properties/e3dsphereproperties.cxx
new file mode 100644
index 000000000000..de636eac0b88
--- /dev/null
+++ b/svx/source/sdr/properties/e3dsphereproperties.cxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/e3dsphereproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svx/sphere3d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ E3dSphereProperties::E3dSphereProperties(SdrObject& rObj)
+ : E3dCompoundProperties(rObj)
+ {
+ }
+
+ E3dSphereProperties::E3dSphereProperties(const E3dSphereProperties& rProps, SdrObject& rObj)
+ : E3dCompoundProperties(rProps, rObj)
+ {
+ }
+
+ E3dSphereProperties::~E3dSphereProperties()
+ {
+ }
+
+ BaseProperties& E3dSphereProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new E3dSphereProperties(*this, rObj));
+ }
+
+ void E3dSphereProperties::PostItemChange(const sal_uInt16 nWhich)
+ {
+ // call parent
+ E3dCompoundProperties::PostItemChange(nWhich);
+
+ // handle value change
+ E3dSphereObj& rObj = (E3dSphereObj&)GetSdrObject();
+
+ switch(nWhich)
+ {
+ case SDRATTR_3DOBJ_HORZ_SEGS:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ case SDRATTR_3DOBJ_VERT_SEGS:
+ {
+ rObj.ActionChanged();
+ break;
+ }
+ }
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/emptyproperties.cxx b/svx/source/sdr/properties/emptyproperties.cxx
new file mode 100644
index 000000000000..cd247b5b1c69
--- /dev/null
+++ b/svx/source/sdr/properties/emptyproperties.cxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/emptyproperties.hxx>
+#include <tools/debug.hxx>
+#include <svl/itemset.hxx>
+#include <svx/svddef.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpool.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ // create a new itemset
+ SfxItemSet& EmptyProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ // Basic implementation; Basic object has NO attributes
+ DBG_ASSERT(sal_False, "EmptyProperties::CreateObjectSpecificItemSet() should never be called");
+ return *(new SfxItemSet(rPool));
+ }
+
+ EmptyProperties::EmptyProperties(SdrObject& rObj)
+ : BaseProperties(rObj),
+ mpEmptyItemSet(0L)
+ {
+ }
+
+ EmptyProperties::EmptyProperties(const EmptyProperties& rProps, SdrObject& rObj)
+ : BaseProperties(rProps, rObj),
+ mpEmptyItemSet(0L)
+ {
+ // #115593#
+ // do not gererate an assert, else derivations like PageProperties will generate an assert
+ // using the Clone() operator path.
+ }
+
+ EmptyProperties::~EmptyProperties()
+ {
+ if(mpEmptyItemSet)
+ {
+ delete mpEmptyItemSet;
+ mpEmptyItemSet = 0L;
+ }
+ }
+
+ BaseProperties& EmptyProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new EmptyProperties(*this, rObj));
+ }
+
+ const SfxItemSet& EmptyProperties::GetObjectItemSet() const
+ {
+ if(!mpEmptyItemSet)
+ {
+ ((EmptyProperties*)this)->mpEmptyItemSet = &(((EmptyProperties*)this)->CreateObjectSpecificItemSet(*GetSdrObject().GetObjectItemPool()));
+ }
+
+ DBG_ASSERT(mpEmptyItemSet, "Could not create an SfxItemSet(!)");
+ DBG_ASSERT(sal_False, "EmptyProperties::GetObjectItemSet() should never be called (!)");
+
+ return *mpEmptyItemSet;
+ }
+
+ void EmptyProperties::SetObjectItem(const SfxPoolItem& /*rItem*/)
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::SetObjectItem() should never be called (!)");
+ }
+
+ void EmptyProperties::SetObjectItemDirect(const SfxPoolItem& /*rItem*/)
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::SetObjectItemDirect() should never be called (!)");
+ }
+
+ void EmptyProperties::ClearObjectItem(const sal_uInt16 /*nWhich*/)
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::ClearObjectItem() should never be called (!)");
+ }
+
+ void EmptyProperties::ClearObjectItemDirect(const sal_uInt16 /*nWhich*/)
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::ClearObjectItemDirect() should never be called (!)");
+ }
+
+ void EmptyProperties::SetObjectItemSet(const SfxItemSet& /*rSet*/)
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::SetObjectItemSet() should never be called (!)");
+ }
+
+ void EmptyProperties::ItemSetChanged(const SfxItemSet& /*rSet*/)
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::ItemSetChanged() should never be called (!)");
+ }
+
+ sal_Bool EmptyProperties::AllowItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) const
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::AllowItemChange() should never be called (!)");
+ return sal_True;
+ }
+
+ void EmptyProperties::ItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/)
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::ItemChange() should never be called (!)");
+ }
+
+ void EmptyProperties::PostItemChange(const sal_uInt16 /*nWhich*/)
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::PostItemChange() should never be called (!)");
+ }
+
+ void EmptyProperties::SetStyleSheet(SfxStyleSheet* /*pNewStyleSheet*/, sal_Bool /*bDontRemoveHardAttr*/)
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::SetStyleSheet() should never be called (!)");
+ }
+
+ SfxStyleSheet* EmptyProperties::GetStyleSheet() const
+ {
+ DBG_ASSERT(sal_False, "EmptyProperties::GetStyleSheet() should never be called (!)");
+ return 0L;
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/graphicproperties.cxx b/svx/source/sdr/properties/graphicproperties.cxx
new file mode 100644
index 000000000000..e2c478831a2a
--- /dev/null
+++ b/svx/source/sdr/properties/graphicproperties.cxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/graphicproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svl/style.hxx>
+#include <svx/svddef.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/sdgcpitm.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ // create a new itemset
+ SfxItemSet& GraphicProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ return *(new SfxItemSet(rPool,
+
+ // range from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // range from SdrGrafObj
+ SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
+
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+
+ // end
+ 0, 0));
+ }
+
+ GraphicProperties::GraphicProperties(SdrObject& rObj)
+ : RectangleProperties(rObj)
+ {
+ }
+
+ GraphicProperties::GraphicProperties(const GraphicProperties& rProps, SdrObject& rObj)
+ : RectangleProperties(rProps, rObj)
+ {
+ }
+
+ GraphicProperties::~GraphicProperties()
+ {
+ }
+
+ BaseProperties& GraphicProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new GraphicProperties(*this, rObj));
+ }
+
+ void GraphicProperties::ItemSetChanged(const SfxItemSet& rSet)
+ {
+ SdrGrafObj& rObj = (SdrGrafObj&)GetSdrObject();
+
+ // local changes
+ rObj.SetXPolyDirty();
+
+ // #i29367# Update GraphicAttr, too. This was formerly
+ // triggered by SdrGrafObj::Notify, which is no longer
+ // called nowadays. BTW: strictly speaking, the whole
+ // ImpSetAttrToGrafInfo/ImpSetGrafInfoToAttr stuff could
+ // be dumped, when SdrGrafObj::aGrafInfo is removed and
+ // always created on the fly for repaint.
+ rObj.ImpSetAttrToGrafInfo();
+
+ // call parent
+ RectangleProperties::ItemSetChanged(rSet);
+ }
+
+ void GraphicProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ SdrGrafObj& rObj = (SdrGrafObj&)GetSdrObject();
+
+ // local changes
+ rObj.SetXPolyDirty();
+
+ // call parent
+ RectangleProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+
+ // local changes
+ rObj.ImpSetAttrToGrafInfo();
+ }
+
+ void GraphicProperties::ForceDefaultAttributes()
+ {
+ // call parent
+ RectangleProperties::ForceDefaultAttributes();
+
+ // force ItemSet
+ GetObjectItemSet();
+
+ mpItemSet->Put( SdrGrafLuminanceItem( 0 ) );
+ mpItemSet->Put( SdrGrafContrastItem( 0 ) );
+ mpItemSet->Put( SdrGrafRedItem( 0 ) );
+ mpItemSet->Put( SdrGrafGreenItem( 0 ) );
+ mpItemSet->Put( SdrGrafBlueItem( 0 ) );
+ mpItemSet->Put( SdrGrafGamma100Item( 100 ) );
+ mpItemSet->Put( SdrGrafTransparenceItem( 0 ) );
+ mpItemSet->Put( SdrGrafInvertItem( FALSE ) );
+ mpItemSet->Put( SdrGrafModeItem( GRAPHICDRAWMODE_STANDARD ) );
+ mpItemSet->Put( SdrGrafCropItem( 0, 0, 0, 0 ) );
+
+ // #i25616#
+ mpItemSet->Put( XFillStyleItem(XFILL_NONE) );
+ mpItemSet->Put( XLineStyleItem(XLINE_NONE) );
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/groupproperties.cxx b/svx/source/sdr/properties/groupproperties.cxx
new file mode 100644
index 000000000000..3bffbff83833
--- /dev/null
+++ b/svx/source/sdr/properties/groupproperties.cxx
@@ -0,0 +1,301 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/groupproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svl/whiter.hxx>
+#include <svx/svddef.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdpage.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ // create a new itemset
+ SfxItemSet& GroupProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ // Groups have in principle no ItemSet. To support methods like
+ // GetMergedItemSet() the local one is used. Thus, all items in the pool
+ // may be used and a pool itemset is created.
+ return *(new SfxItemSet(rPool));
+ }
+
+ GroupProperties::GroupProperties(SdrObject& rObj)
+ : DefaultProperties(rObj)
+ {
+ }
+
+ GroupProperties::GroupProperties(const GroupProperties& rProps, SdrObject& rObj)
+ : DefaultProperties(rProps, rObj)
+ {
+ }
+
+ GroupProperties::~GroupProperties()
+ {
+ }
+
+ BaseProperties& GroupProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new GroupProperties(*this, rObj));
+ }
+
+ const SfxItemSet& GroupProperties::GetObjectItemSet() const
+ {
+ DBG_ASSERT(sal_False, "GroupProperties::GetObjectItemSet() should never be called (!)");
+ return DefaultProperties::GetObjectItemSet();
+ }
+
+ const SfxItemSet& GroupProperties::GetMergedItemSet() const
+ {
+ // prepare ItemSet
+ if(mpItemSet)
+ {
+ // clear local itemset for merge
+ mpItemSet->ClearItem();
+ }
+ else
+ {
+ // force local itemset
+ DefaultProperties::GetObjectItemSet();
+ }
+
+ // collect all ItemSets in mpItemSet
+ const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ const SfxItemSet& rSet = pSub->GetObj(a)->GetMergedItemSet();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich(aIter.FirstWhich());
+
+ while(nWhich)
+ {
+ if(SFX_ITEM_DONTCARE == rSet.GetItemState(nWhich, FALSE))
+ {
+ mpItemSet->InvalidateItem(nWhich);
+ }
+ else
+ {
+ mpItemSet->MergeValue(rSet.Get(nWhich), TRUE);
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+
+ // For group proerties, do not call parent since groups do
+ // not have local ItemSets.
+ return *mpItemSet;
+ }
+
+ void GroupProperties::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems)
+ {
+ // iterate over contained SdrObjects
+ const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ SdrObject* pObj = pSub->GetObj(a);
+
+ if(pObj)
+ {
+ // Set merged ItemSet at contained object
+ pObj->SetMergedItemSet(rSet, bClearAllItems);
+ }
+ }
+
+ // Do not call parent here. Group objects do not have local ItemSets
+ // where items need to be set.
+ // DefaultProperties::SetMergedItemSet(rSet, bClearAllItems);
+ }
+
+ void GroupProperties::SetObjectItem(const SfxPoolItem& /*rItem*/)
+ {
+ DBG_ASSERT(sal_False, "GroupProperties::SetObjectItem() should never be called (!)");
+ }
+
+ void GroupProperties::SetObjectItemDirect(const SfxPoolItem& /*rItem*/)
+ {
+ DBG_ASSERT(sal_False, "GroupProperties::SetObjectItemDirect() should never be called (!)");
+ }
+
+ void GroupProperties::ClearObjectItem(const sal_uInt16 /*nWhich*/)
+ {
+ DBG_ASSERT(sal_False, "GroupProperties::ClearObjectItem() should never be called (!)");
+ }
+
+ void GroupProperties::ClearObjectItemDirect(const sal_uInt16 /*nWhich*/)
+ {
+ DBG_ASSERT(sal_False, "GroupProperties::ClearObjectItemDirect() should never be called (!)");
+ }
+
+ void GroupProperties::SetMergedItem(const SfxPoolItem& rItem)
+ {
+ const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ pSub->GetObj(a)->GetProperties().SetMergedItem(rItem);
+ }
+ }
+
+ void GroupProperties::ClearMergedItem(const sal_uInt16 nWhich)
+ {
+ const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ pSub->GetObj(a)->GetProperties().ClearMergedItem(nWhich);
+ }
+ }
+
+ void GroupProperties::SetObjectItemSet(const SfxItemSet& /*rSet*/)
+ {
+ DBG_ASSERT(sal_False, "GroupProperties::SetObjectItemSet() should never be called (!)");
+ }
+
+ void GroupProperties::ItemSetChanged(const SfxItemSet& /*rSet*/)
+ {
+ DBG_ASSERT(sal_False, "GroupProperties::ItemSetChanged() should never be called (!)");
+ }
+
+ sal_Bool GroupProperties::AllowItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) const
+ {
+ DBG_ASSERT(sal_False, "GroupProperties::AllowItemChange() should never be called (!)");
+ return sal_False;
+ }
+
+ void GroupProperties::ItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/)
+ {
+ DBG_ASSERT(sal_False, "GroupProperties::ItemChange() should never be called (!)");
+ }
+
+ void GroupProperties::PostItemChange(const sal_uInt16 /*nWhich*/)
+ {
+ DBG_ASSERT(sal_False, "GroupProperties::PostItemChange() should never be called (!)");
+ }
+
+ SfxStyleSheet* GroupProperties::GetStyleSheet() const
+ {
+ SfxStyleSheet* pRetval = 0L;
+
+ const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ SfxStyleSheet* pCandidate = pSub->GetObj(a)->GetStyleSheet();
+
+ if(pRetval)
+ {
+ if(pCandidate != pRetval)
+ {
+ // different StyleSheelts, return none
+ return 0L;
+ }
+ }
+ else
+ {
+ pRetval = pCandidate;
+ }
+ }
+
+ return pRetval;
+ }
+
+ void GroupProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ pSub->GetObj(a)->SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+ }
+ }
+
+ void GroupProperties::ForceDefaultAttributes()
+ {
+ // nothing to do here, groups have no items and thus no default items, too.
+ }
+
+ void GroupProperties::MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
+ {
+ if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
+ {
+ const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ pSub->GetObj(a)->GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
+ }
+
+ // also clear local ItemSet, it's only temporary for group objects anyways.
+ if(mpItemSet)
+ {
+ // #121905#
+ // copy/paste is still using clone operators and MoveToItemPool functionality.
+ // Since SfxItemSet contains a pool pointer, ClearItem is not enough here.
+ // The ItemSet for merge is constructed on demand, so it's enough here to
+ // just delete it and set to 0L.
+ // mpItemSet->ClearItem();
+ delete mpItemSet;
+ mpItemSet = 0L;
+ }
+ }
+ }
+
+ void GroupProperties::ForceStyleToHardAttributes()
+ {
+ const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
+ const sal_uInt32 nCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ pSub->GetObj(a)->GetProperties().ForceStyleToHardAttributes();
+ }
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/itemsettools.cxx b/svx/source/sdr/properties/itemsettools.cxx
new file mode 100644
index 000000000000..a60661a8aa3e
--- /dev/null
+++ b/svx/source/sdr/properties/itemsettools.cxx
@@ -0,0 +1,149 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/itemsettools.hxx>
+#include <tools/debug.hxx>
+#include <svl/itemset.hxx>
+#include <svl/whiter.hxx>
+
+#include <vector>
+#include <svx/svdogrp.hxx>
+#include <svditer.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// class to remember broadcast start positions
+
+namespace sdr
+{
+ namespace properties
+ {
+ // helper vector to remember rectangles
+ typedef ::std::vector< Rectangle > RectangleVector;
+
+ ItemChangeBroadcaster::ItemChangeBroadcaster(const SdrObject& rObj)
+ {
+ if(rObj.ISA(SdrObjGroup))
+ {
+ SdrObjListIter aIter((const SdrObjGroup&)rObj, IM_DEEPNOGROUPS);
+ mpData = new RectangleVector;
+ DBG_ASSERT(mpData, "ItemChangeBroadcaster: No memory (!)");
+ ((RectangleVector*)mpData)->reserve(aIter.Count());
+
+ while(aIter.IsMore())
+ {
+ SdrObject* pObj = aIter.Next();
+
+ if(pObj)
+ {
+ ((RectangleVector*)mpData)->push_back(pObj->GetLastBoundRect());
+ }
+ }
+
+ mnCount = ((RectangleVector*)mpData)->size();
+ }
+ else
+ {
+ mpData = new Rectangle(rObj.GetLastBoundRect());
+ mnCount = 1L;
+ }
+ }
+
+ ItemChangeBroadcaster::~ItemChangeBroadcaster()
+ {
+ if(mnCount > 1)
+ {
+ delete ((RectangleVector*)mpData);
+ }
+ else
+ {
+ delete ((Rectangle*)mpData);
+ }
+ }
+
+ sal_uInt32 ItemChangeBroadcaster::GetRectangleCount() const
+ {
+ return mnCount;
+ }
+
+ const Rectangle& ItemChangeBroadcaster::GetRectangle(sal_uInt32 nIndex) const
+ {
+ if(mnCount > 1)
+ {
+ return (*((RectangleVector*)mpData))[nIndex];
+ }
+ else
+ {
+ return *((Rectangle*)mpData);
+ }
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ void ScaleItemSet(SfxItemSet& rSet, const Fraction& rScale)
+ {
+ sal_Int32 nMul(rScale.GetNumerator());
+ sal_Int32 nDiv(rScale.GetDenominator());
+
+ if(!rScale.IsValid() || !nDiv)
+ {
+ return;
+ }
+
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich(aIter.FirstWhich());
+ const SfxPoolItem *pItem = NULL;
+
+ while(nWhich)
+ {
+ if(SFX_ITEM_SET == rSet.GetItemState(nWhich, FALSE, &pItem))
+ {
+ if(pItem->HasMetrics())
+ {
+ SfxPoolItem* pNewItem = pItem->Clone();
+ pNewItem->ScaleMetrics(nMul, nDiv);
+ rSet.Put(*pNewItem);
+ }
+ }
+ nWhich = aIter.NextWhich();
+ }
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/makefile.mk b/svx/source/sdr/properties/makefile.mk
new file mode 100644
index 000000000000..5296765769b1
--- /dev/null
+++ b/svx/source/sdr/properties/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=svx
+TARGET=properties
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/properties.obj \
+ $(SLO)$/emptyproperties.obj \
+ $(SLO)$/pageproperties.obj \
+ $(SLO)$/defaultproperties.obj \
+ $(SLO)$/attributeproperties.obj \
+ $(SLO)$/textproperties.obj \
+ $(SLO)$/customshapeproperties.obj \
+ $(SLO)$/rectangleproperties.obj \
+ $(SLO)$/oleproperties.obj \
+ $(SLO)$/captionproperties.obj \
+ $(SLO)$/circleproperties.obj \
+ $(SLO)$/connectorproperties.obj \
+ $(SLO)$/e3dproperties.obj \
+ $(SLO)$/e3dcompoundproperties.obj \
+ $(SLO)$/e3dextrudeproperties.obj \
+ $(SLO)$/e3dlatheproperties.obj \
+ $(SLO)$/e3dsceneproperties.obj \
+ $(SLO)$/e3dsphereproperties.obj \
+ $(SLO)$/graphicproperties.obj \
+ $(SLO)$/groupproperties.obj \
+ $(SLO)$/measureproperties.obj \
+ $(SLO)$/itemsettools.obj
+
+.INCLUDE : target.mk
diff --git a/svx/source/sdr/properties/measureproperties.cxx b/svx/source/sdr/properties/measureproperties.cxx
new file mode 100644
index 000000000000..971b4de127f3
--- /dev/null
+++ b/svx/source/sdr/properties/measureproperties.cxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/measureproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svl/style.hxx>
+#include <svx/svddef.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/svdomeas.hxx>
+#include <svx/sxmsuitm.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ // create a new itemset
+ SfxItemSet& MeasureProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ return *(new SfxItemSet(rPool,
+
+ // range from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // range from SdrMeasureObj
+ SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST,
+
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+
+ // end
+ 0, 0));
+ }
+
+ MeasureProperties::MeasureProperties(SdrObject& rObj)
+ : TextProperties(rObj)
+ {
+ }
+
+ MeasureProperties::MeasureProperties(const MeasureProperties& rProps, SdrObject& rObj)
+ : TextProperties(rProps, rObj)
+ {
+ }
+
+ MeasureProperties::~MeasureProperties()
+ {
+ }
+
+ BaseProperties& MeasureProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new MeasureProperties(*this, rObj));
+ }
+
+ void MeasureProperties::ItemSetChanged(const SfxItemSet& rSet)
+ {
+ SdrMeasureObj& rObj = (SdrMeasureObj&)GetSdrObject();
+
+ // call parent
+ TextProperties::ItemSetChanged(rSet);
+
+ // local changes
+ rObj.SetTextDirty();
+ }
+
+ void MeasureProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ SdrMeasureObj& rObj = (SdrMeasureObj&)GetSdrObject();
+
+ // local changes
+ rObj.SetTextDirty();
+
+ // call parent
+ TextProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+ }
+
+ void MeasureProperties::ForceDefaultAttributes()
+ {
+ // call parent
+ TextProperties::ForceDefaultAttributes();
+
+ // force ItemSet
+ GetObjectItemSet();
+
+ //#71958# by default, the show units Bool-Item is set as hard
+ // attribute to TRUE to aviod confusion when copying SdrMeasureObj's
+ // from one application to another
+ mpItemSet->Put(SdrMeasureShowUnitItem(TRUE));
+
+ basegfx::B2DPolygon aNewPolygon;
+ aNewPolygon.append(basegfx::B2DPoint(100.0, 0.0));
+ aNewPolygon.append(basegfx::B2DPoint(200.0, 400.0));
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 400.0));
+ aNewPolygon.setClosed(true);
+
+ mpItemSet->Put(XLineStartItem(String(), basegfx::B2DPolyPolygon(aNewPolygon)));
+ mpItemSet->Put(XLineStartWidthItem(200));
+ mpItemSet->Put(XLineEndItem(String(), basegfx::B2DPolyPolygon(aNewPolygon)));
+ mpItemSet->Put(XLineEndWidthItem(200));
+ mpItemSet->Put(XLineStyleItem(XLINE_SOLID));
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/oleproperties.cxx b/svx/source/sdr/properties/oleproperties.cxx
new file mode 100644
index 000000000000..5e9c07c157b6
--- /dev/null
+++ b/svx/source/sdr/properties/oleproperties.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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: graphicproperties.cxx,v $
+ * $Revision: 1.12.76.1 $
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdr/properties/oleproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xlineit0.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ OleProperties::OleProperties(SdrObject& rObj)
+ : RectangleProperties(rObj)
+ {
+ }
+
+ OleProperties::OleProperties(const OleProperties& rProps, SdrObject& rObj)
+ : RectangleProperties(rProps, rObj)
+ {
+ }
+
+ OleProperties::~OleProperties()
+ {
+ }
+
+ BaseProperties& OleProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new OleProperties(*this, rObj));
+ }
+
+ void OleProperties::ForceDefaultAttributes()
+ {
+ // call parent
+ RectangleProperties::ForceDefaultAttributes();
+
+ // force ItemSet
+ GetObjectItemSet();
+
+ // #i108221#
+ mpItemSet->Put( XFillStyleItem(XFILL_NONE) );
+ mpItemSet->Put( XLineStyleItem(XLINE_NONE) );
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/pageproperties.cxx b/svx/source/sdr/properties/pageproperties.cxx
new file mode 100644
index 000000000000..75b66a80727c
--- /dev/null
+++ b/svx/source/sdr/properties/pageproperties.cxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/pageproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpool.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ // create a new itemset
+ SfxItemSet& PageProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ // overloaded to legally return a valid ItemSet
+ return *(new SfxItemSet(rPool));
+ }
+
+ PageProperties::PageProperties(SdrObject& rObj)
+ : EmptyProperties(rObj)
+ {
+ }
+
+ PageProperties::PageProperties(const PageProperties& rProps, SdrObject& rObj)
+ : EmptyProperties(rProps, rObj)
+ {
+ }
+
+ PageProperties::~PageProperties()
+ {
+ }
+
+ BaseProperties& PageProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new PageProperties(*this, rObj));
+ }
+
+ // get itemset. Overloaded here to allow creating the empty itemset
+ // without asserting
+ const SfxItemSet& PageProperties::GetObjectItemSet() const
+ {
+ if(!mpEmptyItemSet)
+ {
+ ((PageProperties*)this)->mpEmptyItemSet = &(((PageProperties*)this)->CreateObjectSpecificItemSet(*GetSdrObject().GetObjectItemPool()));
+ }
+
+ DBG_ASSERT(mpEmptyItemSet, "Could not create an SfxItemSet(!)");
+
+ return *mpEmptyItemSet;
+ }
+
+ void PageProperties::ItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/)
+ {
+ // #86481# simply ignore item setting on page objects
+ }
+
+ SfxStyleSheet* PageProperties::GetStyleSheet() const
+ {
+ // overloaded to legally return a 0L pointer here
+ return 0L;
+ }
+
+ void PageProperties::ClearObjectItem(const sal_uInt16 /*nWhich*/)
+ {
+ // simply ignore item clearing on page objects
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/properties.cxx b/svx/source/sdr/properties/properties.cxx
new file mode 100644
index 000000000000..80c5035e0e7b
--- /dev/null
+++ b/svx/source/sdr/properties/properties.cxx
@@ -0,0 +1,192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/properties.hxx>
+#include <svx/sdr/properties/itemsettools.hxx>
+#include <svl/itemset.hxx>
+#include <svx/svdogrp.hxx>
+#include <svditer.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ BaseProperties::BaseProperties(SdrObject& rObj)
+ : mrObject(rObj)
+ {
+ }
+
+ BaseProperties::BaseProperties(const BaseProperties& /*rProps*/, SdrObject& rObj)
+ : mrObject(rObj)
+ {
+ }
+
+ BaseProperties::~BaseProperties()
+ {
+ }
+
+ const SfxItemSet& BaseProperties::GetMergedItemSet() const
+ {
+ // default implementation falls back to GetObjectItemSet()
+ return GetObjectItemSet();
+ }
+
+ void BaseProperties::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems)
+ {
+ // clear items if requested
+ if(bClearAllItems)
+ {
+ ClearObjectItem();
+ }
+
+ // default implementation falls back to SetObjectItemSet()
+ SetObjectItemSet(rSet);
+ }
+
+ void BaseProperties::SetMergedItem(const SfxPoolItem& rItem)
+ {
+ // default implementation falls back to SetObjectItem()
+ SetObjectItem(rItem);
+ }
+
+ void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich)
+ {
+ // default implementation falls back to ClearObjectItem()
+ ClearObjectItem(nWhich);
+ }
+
+ void BaseProperties::Scale(const Fraction& /*rScale*/)
+ {
+ // default implementation does nothing; overload where
+ // an ItemSet is implemented.
+ }
+
+ void BaseProperties::MoveToItemPool(SfxItemPool* /*pSrcPool*/, SfxItemPool* /*pDestPool*/, SdrModel* /*pNewModel*/)
+ {
+ // Move properties to a new ItemPool. Default implementation does nothing.
+ // Overload where an ItemSet is implemented.
+ }
+
+ void BaseProperties::SetModel(SdrModel* /*pOldModel*/, SdrModel* /*pNewModel*/)
+ {
+ // Set new model. Default implementation does nothing.
+ // Overload where an ItemSet is implemented.
+ }
+
+ void BaseProperties::ForceStyleToHardAttributes()
+ {
+ // force all attributes which come from styles to hard attributes
+ // to be able to live without the style. Default implementation does nothing.
+ // Overload where an ItemSet is implemented.
+ }
+
+ //void BaseProperties::SetItemAndBroadcast(const SfxPoolItem& rItem)
+ //{
+ // ItemChangeBroadcaster aC(GetSdrObject());
+ // SetObjectItem(rItem);
+ // BroadcastItemChange(aC);
+ //}
+
+ //void BaseProperties::ClearItemAndBroadcast(const sal_uInt16 nWhich)
+ //{
+ // ItemChangeBroadcaster aC(GetSdrObject());
+ // ClearObjectItem(nWhich);
+ // BroadcastItemChange(aC);
+ //}
+
+ void BaseProperties::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems)
+ {
+ ItemChangeBroadcaster aC(GetSdrObject());
+
+ if(bClearAllItems)
+ {
+ ClearObjectItem();
+ }
+
+ SetMergedItemSet(rSet);
+ BroadcastItemChange(aC);
+ }
+
+ const SfxPoolItem& BaseProperties::GetItem(const sal_uInt16 nWhich) const
+ {
+ return GetObjectItemSet().Get(nWhich);
+ }
+
+ void BaseProperties::BroadcastItemChange(const ItemChangeBroadcaster& rChange)
+ {
+ const sal_uInt32 nCount(rChange.GetRectangleCount());
+
+ // #110094#-14 Reduce to do only second change
+ //// invalidate all remembered rectangles
+ //for(sal_uInt32 a(0); a < nCount; a++)
+ //{
+ // GetSdrObject().BroadcastObjectChange(rChange.GetRectangle(a));
+ //}
+
+ // invalidate all new rectangles
+ if(GetSdrObject().ISA(SdrObjGroup))
+ {
+ SdrObjListIter aIter((SdrObjGroup&)GetSdrObject(), IM_DEEPNOGROUPS);
+
+ while(aIter.IsMore())
+ {
+ SdrObject* pObj = aIter.Next();
+ // This is done with ItemSetChanged
+ // pObj->SetChanged();
+ pObj->BroadcastObjectChange();
+ }
+ }
+ else
+ {
+ // This is done with ItemSetChanged
+ // GetSdrObject().SetChanged();
+ GetSdrObject().BroadcastObjectChange();
+ }
+
+ // also send the user calls
+ for(sal_uInt32 a(0L); a < nCount; a++)
+ {
+ GetSdrObject().SendUserCall(SDRUSERCALL_CHGATTR, rChange.GetRectangle(a));
+ }
+ }
+
+ sal_uInt32 BaseProperties::getVersion() const
+ {
+ return 0;
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/rectangleproperties.cxx b/svx/source/sdr/properties/rectangleproperties.cxx
new file mode 100644
index 000000000000..e68660146655
--- /dev/null
+++ b/svx/source/sdr/properties/rectangleproperties.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/rectangleproperties.hxx>
+#include <svx/svdorect.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ RectangleProperties::RectangleProperties(SdrObject& rObj)
+ : TextProperties(rObj)
+ {
+ }
+
+ RectangleProperties::RectangleProperties(const RectangleProperties& rProps, SdrObject& rObj)
+ : TextProperties(rProps, rObj)
+ {
+ }
+
+ RectangleProperties::~RectangleProperties()
+ {
+ }
+
+ BaseProperties& RectangleProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new RectangleProperties(*this, rObj));
+ }
+
+ void RectangleProperties::ItemSetChanged(const SfxItemSet& rSet)
+ {
+ SdrRectObj& rObj = (SdrRectObj&)GetSdrObject();
+
+ // call parent
+ TextProperties::ItemSetChanged(rSet);
+
+ // local changes
+ rObj.SetXPolyDirty();
+ }
+
+ // set a new StyleSheet and broadcast
+ void RectangleProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ SdrRectObj& rObj = (SdrRectObj&)GetSdrObject();
+
+ // call parent
+ TextProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+
+ // local changes
+ rObj.SetXPolyDirty();
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx
new file mode 100644
index 000000000000..99eca410012d
--- /dev/null
+++ b/svx/source/sdr/properties/textproperties.cxx
@@ -0,0 +1,641 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/properties/textproperties.hxx>
+#include <svl/itemset.hxx>
+#include <svl/style.hxx>
+#include <svl/itemiter.hxx>
+#include <svl/smplhint.hxx>
+#include <svx/svddef.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdoutl.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <svx/svdmodel.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/xflclit.hxx>
+#include <editeng/adjitem.hxx>
+#include <svx/svdetc.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/svdpool.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace properties
+ {
+ SfxItemSet& TextProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ return *(new SfxItemSet(rPool,
+
+ // range from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+
+ // end
+ 0, 0));
+ }
+
+ TextProperties::TextProperties(SdrObject& rObj)
+ : AttributeProperties(rObj),
+ maVersion(0)
+ {
+ }
+
+ TextProperties::TextProperties(const TextProperties& rProps, SdrObject& rObj)
+ : AttributeProperties(rProps, rObj),
+ maVersion(rProps.getVersion())
+ {
+ }
+
+ TextProperties::~TextProperties()
+ {
+ }
+
+ BaseProperties& TextProperties::Clone(SdrObject& rObj) const
+ {
+ return *(new TextProperties(*this, rObj));
+ }
+
+ void TextProperties::ItemSetChanged(const SfxItemSet& rSet)
+ {
+ SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
+ sal_Int32 nText = rObj.getTextCount();
+
+ // #i101556# ItemSet has changed -> new version
+ maVersion++;
+
+ while( --nText >= 0 )
+ {
+ SdrText* pText = rObj.getText( nText );
+
+ OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0;
+
+ if(pParaObj)
+ {
+ const bool bTextEdit = rObj.IsTextEditActive() && (rObj.getActiveText() == pText);
+
+ // handle outliner attributes
+ GetObjectItemSet();
+ Outliner* pOutliner = rObj.GetTextEditOutliner();
+
+ if(!bTextEdit)
+ {
+ pOutliner = &rObj.ImpGetDrawOutliner();
+ pOutliner->SetText(*pParaObj);
+ }
+
+ sal_uInt32 nParaCount(pOutliner->GetParagraphCount());
+
+ for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
+ {
+ SfxItemSet aSet(pOutliner->GetParaAttribs(nPara));
+ aSet.Put(rSet);
+ pOutliner->SetParaAttribs(nPara, aSet);
+ }
+
+ if(!bTextEdit)
+ {
+ if(nParaCount)
+ {
+ // force ItemSet
+ GetObjectItemSet();
+
+ SfxItemSet aNewSet(pOutliner->GetParaAttribs(0L));
+ mpItemSet->Put(aNewSet);
+ }
+
+ OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount);
+ pOutliner->Clear();
+
+ rObj.NbcSetOutlinerParaObjectForText(pTemp,pText);
+ }
+ }
+ }
+
+ // Extra-Repaint for radical layout changes (#43139#)
+ if(SFX_ITEM_SET == rSet.GetItemState(SDRATTR_TEXT_CONTOURFRAME))
+ {
+ // Here only repaint wanted
+ rObj.ActionChanged();
+ //rObj.BroadcastObjectChange();
+ }
+
+ // call parent
+ AttributeProperties::ItemSetChanged(rSet);
+ }
+
+ void TextProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
+ {
+ SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
+
+ // #i25616#
+ sal_Int32 nOldLineWidth(0L);
+
+ if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange())
+ {
+ nOldLineWidth = ((const XLineWidthItem&)GetItem(XATTR_LINEWIDTH)).GetValue();
+ }
+
+ if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich))
+ {
+ sal_Bool bVertical(com::sun::star::text::WritingMode_TB_RL == ((SvxWritingModeItem*)pNewItem)->GetValue());
+ rObj.SetVerticalWriting(bVertical);
+ }
+
+ // #95501# reset to default
+ if(!pNewItem && !nWhich && rObj.HasText() )
+ {
+ SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner();
+
+ sal_Int32 nCount = rObj.getTextCount();
+ while( nCount-- )
+ {
+ SdrText* pText = rObj.getText( nCount );
+ OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject();
+ if( pParaObj )
+ {
+ rOutliner.SetText(*pParaObj);
+ sal_uInt32 nParaCount(rOutliner.GetParagraphCount());
+
+ if(nParaCount)
+ {
+ ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL);
+ rOutliner.RemoveAttribs(aSelection, sal_True, 0);
+
+ OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount);
+ rOutliner.Clear();
+
+ rObj.NbcSetOutlinerParaObjectForText( pTemp, pText );
+ }
+ }
+ }
+ }
+
+ // call parent
+ AttributeProperties::ItemChange( nWhich, pNewItem );
+
+ // #i25616#
+ if(XATTR_LINEWIDTH == nWhich && rObj.DoesSupportTextIndentingOnLineWidthChange())
+ {
+ const sal_Int32 nNewLineWidth(((const XLineWidthItem&)GetItem(XATTR_LINEWIDTH)).GetValue());
+ const sal_Int32 nDifference((nNewLineWidth - nOldLineWidth) / 2);
+
+ if(nDifference)
+ {
+ const sal_Bool bLineVisible(XLINE_NONE != ((const XLineStyleItem&)(GetItem(XATTR_LINESTYLE))).GetValue());
+
+ if(bLineVisible)
+ {
+ const sal_Int32 nLeftDist(((const SdrTextLeftDistItem&)GetItem(SDRATTR_TEXT_LEFTDIST)).GetValue());
+ const sal_Int32 nRightDist(((const SdrTextRightDistItem&)GetItem(SDRATTR_TEXT_RIGHTDIST)).GetValue());
+ const sal_Int32 nUpperDist(((const SdrTextUpperDistItem&)GetItem(SDRATTR_TEXT_UPPERDIST)).GetValue());
+ const sal_Int32 nLowerDist(((const SdrTextLowerDistItem&)GetItem(SDRATTR_TEXT_LOWERDIST)).GetValue());
+
+ SetObjectItemDirect(SdrTextLeftDistItem(nLeftDist + nDifference));
+ SetObjectItemDirect(SdrTextRightDistItem(nRightDist + nDifference));
+ SetObjectItemDirect(SdrTextUpperDistItem(nUpperDist + nDifference));
+ SetObjectItemDirect(SdrTextLowerDistItem(nLowerDist + nDifference));
+ }
+ }
+ }
+ }
+
+ void TextProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
+
+ // call parent
+ AttributeProperties::SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+
+ // #i101556# StyleSheet has changed -> new version
+ maVersion++;
+
+ if( rObj.GetModel() /*&& !rObj.IsTextEditActive()*/ && !rObj.IsLinkedText() )
+ {
+ SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner();
+
+ sal_Int32 nText = rObj.getTextCount();
+
+ while( --nText >= 0 )
+ {
+ SdrText* pText = rObj.getText( nText );
+
+ OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0;
+ if( !pParaObj )
+ continue;
+
+ // apply StyleSheet to all paragraphs
+ rOutliner.SetText(*pParaObj);
+ sal_uInt32 nParaCount(rOutliner.GetParagraphCount());
+
+ if(nParaCount)
+ {
+ for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
+ {
+ SfxItemSet* pTempSet = 0L;
+
+ // since setting the stylesheet removes all para attributes
+ if(bDontRemoveHardAttr)
+ {
+ // we need to remember them if we want to keep them
+ pTempSet = new SfxItemSet(rOutliner.GetParaAttribs(nPara));
+ }
+
+ if(GetStyleSheet())
+ {
+ if((OBJ_OUTLINETEXT == rObj.GetTextKind()) && (SdrInventor == rObj.GetObjInventor()))
+ {
+ String aNewStyleSheetName(GetStyleSheet()->GetName());
+ aNewStyleSheetName.Erase(aNewStyleSheetName.Len() - 1, 1);
+ sal_Int16 nDepth = rOutliner.GetDepth((sal_uInt16)nPara);
+ aNewStyleSheetName += String::CreateFromInt32( nDepth <= 0 ? 1 : nDepth + 1);
+
+ SdrModel* pModel = rObj.GetModel();
+ SfxStyleSheetBasePool* pStylePool = (pModel != NULL) ? pModel->GetStyleSheetPool() : 0L;
+ SfxStyleSheet* pNewStyle = (SfxStyleSheet*)pStylePool->Find(aNewStyleSheetName, GetStyleSheet()->GetFamily());
+ DBG_ASSERT( pNewStyle, "AutoStyleSheetName - Style not found!" );
+
+ if(pNewStyle)
+ {
+ rOutliner.SetStyleSheet(nPara, pNewStyle);
+ }
+ }
+ else
+ {
+ rOutliner.SetStyleSheet(nPara, GetStyleSheet());
+ }
+ }
+ else
+ {
+ // remove StyleSheet
+ rOutliner.SetStyleSheet(nPara, 0L);
+ }
+
+ if(bDontRemoveHardAttr)
+ {
+ if(pTempSet)
+ {
+ // restore para attributes
+ rOutliner.SetParaAttribs(nPara, *pTempSet);
+ }
+ }
+ else
+ {
+ if(pNewStyleSheet)
+ {
+ // remove all hard paragraph attributes
+ // which occur in StyleSheet, take care of
+ // parents (!)
+ SfxItemIter aIter(pNewStyleSheet->GetItemSet());
+ const SfxPoolItem* pItem = aIter.FirstItem();
+
+ while(pItem)
+ {
+ if(!IsInvalidItem(pItem))
+ {
+ sal_uInt16 nW(pItem->Which());
+
+ if(nW >= EE_ITEMS_START && nW <= EE_ITEMS_END)
+ {
+ rOutliner.QuickRemoveCharAttribs((sal_uInt16)nPara, nW);
+ }
+ }
+ pItem = aIter.NextItem();
+ }
+ }
+ }
+
+ if(pTempSet)
+ {
+ delete pTempSet;
+ }
+ }
+
+ OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount);
+ rOutliner.Clear();
+ rObj.NbcSetOutlinerParaObjectForText(pTemp, pText);
+ }
+ }
+ }
+
+ if(rObj.IsTextFrame())
+ {
+ rObj.NbcAdjustTextFrameWidthAndHeight();
+ }
+ }
+
+ void TextProperties::ForceDefaultAttributes()
+ {
+ SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
+
+ if( rObj.GetObjInventor() == SdrInventor )
+ {
+ const sal_uInt16 nSdrObjKind = rObj.GetObjIdentifier();
+
+ if( nSdrObjKind == OBJ_TITLETEXT || nSdrObjKind == OBJ_OUTLINETEXT )
+ return; // no defaults for presentation objects
+ }
+
+ bool bTextFrame(rObj.IsTextFrame());
+
+ // force ItemSet
+ GetObjectItemSet();
+
+ if(bTextFrame)
+ {
+ mpItemSet->Put(XLineStyleItem(XLINE_NONE));
+ mpItemSet->Put(XFillColorItem(String(), Color(COL_WHITE)));
+ mpItemSet->Put(XFillStyleItem(XFILL_NONE));
+ }
+ else
+ {
+ mpItemSet->Put(SvxAdjustItem(SVX_ADJUST_CENTER, EE_PARA_JUST));
+ mpItemSet->Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER));
+ mpItemSet->Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
+ }
+ }
+
+ void TextProperties::ForceStyleToHardAttributes()
+ {
+ // #i61284# call parent first to get the hard ObjectItemSet
+ AttributeProperties::ForceStyleToHardAttributes();
+
+ // #i61284# push hard ObjectItemSet to OutlinerParaObject attributes
+ // using existing functionality
+ GetObjectItemSet(); // force ItemSet
+ ItemSetChanged(*mpItemSet);
+
+ // now the standard TextProperties stuff
+ SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
+
+ if(rObj.GetModel()
+ && !rObj.IsTextEditActive()
+ && !rObj.IsLinkedText())
+ {
+ Outliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_OUTLINEOBJECT, rObj.GetModel());
+ sal_Int32 nText = rObj.getTextCount();
+
+ while( --nText >= 0 )
+ {
+ SdrText* pText = rObj.getText( nText );
+
+ OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0;
+ if( !pParaObj )
+ continue;
+
+ pOutliner->SetText(*pParaObj);
+
+ sal_uInt32 nParaCount(pOutliner->GetParagraphCount());
+
+ if(nParaCount)
+ {
+ sal_Bool bBurnIn(sal_False);
+
+ for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
+ {
+ SfxStyleSheet* pSheet = pOutliner->GetStyleSheet(nPara);
+
+ if(pSheet)
+ {
+ SfxItemSet aParaSet(pOutliner->GetParaAttribs(nPara));
+ SfxItemSet aSet(*aParaSet.GetPool());
+ aSet.Put(pSheet->GetItemSet());
+
+ /** the next code handles a special case for paragraphs that contain a
+ url field. The color for URL fields is either the system color for
+ urls or the char color attribute that formats the portion in which the
+ url field is contained.
+ When we set a char color attribute to the paragraphs item set from the
+ styles item set, we would have this char color attribute as an attribute
+ that is spanned over the complete paragraph after xml import due to some
+ problems in the xml import (using a XCursor on import so it does not know
+ the paragraphs and can't set char attributes to paragraphs ).
+
+ To avoid this, as soon as we try to set a char color attribute from the style
+ we
+ 1. check if we have at least one url field in this paragraph
+ 2. if we found at least one url field, we span the char color attribute over
+ all portions that are not url fields and remove the char color attribute
+ from the paragraphs item set
+ */
+
+ sal_Bool bHasURL(sal_False);
+
+ if(aSet.GetItemState(EE_CHAR_COLOR) == SFX_ITEM_SET)
+ {
+ EditEngine* pEditEngine = const_cast<EditEngine*>(&(pOutliner->GetEditEngine()));
+ EECharAttribArray aAttribs;
+ pEditEngine->GetCharAttribs((sal_uInt16)nPara, aAttribs);
+ sal_uInt16 nAttrib;
+
+ for(nAttrib = 0; nAttrib < aAttribs.Count(); nAttrib++)
+ {
+ struct EECharAttrib aAttrib(aAttribs.GetObject(nAttrib));
+
+ if(EE_FEATURE_FIELD == aAttrib.pAttr->Which())
+ {
+ if(aAttrib.pAttr)
+ {
+ SvxFieldItem* pFieldItem = (SvxFieldItem*)aAttrib.pAttr;
+
+ if(pFieldItem)
+ {
+ const SvxFieldData* pData = pFieldItem->GetField();
+
+ if(pData && pData->ISA(SvxURLField))
+ {
+ bHasURL = sal_True;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if(bHasURL)
+ {
+ SfxItemSet aColorSet(*aSet.GetPool(), EE_CHAR_COLOR, EE_CHAR_COLOR );
+ aColorSet.Put(aSet, FALSE);
+
+ ESelection aSel((sal_uInt16)nPara, 0);
+
+ for(nAttrib = 0; nAttrib < aAttribs.Count(); nAttrib++)
+ {
+ struct EECharAttrib aAttrib(aAttribs.GetObject(nAttrib));
+
+ if(EE_FEATURE_FIELD == aAttrib.pAttr->Which())
+ {
+ aSel.nEndPos = aAttrib.nStart;
+
+ if(aSel.nStartPos != aSel.nEndPos)
+ {
+ pEditEngine->QuickSetAttribs(aColorSet, aSel);
+ }
+
+ aSel.nStartPos = aAttrib.nEnd;
+ }
+ }
+
+ aSel.nEndPos = pEditEngine->GetTextLen((sal_uInt16)nPara);
+
+ if(aSel.nStartPos != aSel.nEndPos)
+ {
+ pEditEngine->QuickSetAttribs( aColorSet, aSel );
+ }
+ }
+
+ }
+
+ aSet.Put(aParaSet, FALSE);
+
+ if(bHasURL)
+ {
+ aSet.ClearItem(EE_CHAR_COLOR);
+ }
+
+ pOutliner->SetParaAttribs(nPara, aSet);
+ bBurnIn = sal_True; // #i51163# Flag was set wrong
+ }
+ }
+
+ if(bBurnIn)
+ {
+ OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount);
+ rObj.NbcSetOutlinerParaObjectForText(pTemp,pText);
+ }
+ }
+
+ pOutliner->Clear();
+ }
+ delete pOutliner;
+ }
+ }
+
+ void TextProperties::SetObjectItemNoBroadcast(const SfxPoolItem& rItem)
+ {
+ GetObjectItemSet();
+ mpItemSet->Put(rItem);
+ }
+
+
+ void TextProperties::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+ {
+ // call parent
+ AttributeProperties::Notify(rBC, rHint);
+
+ SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
+ if(rObj.HasText())
+ {
+ if(HAS_BASE(SfxStyleSheet, &rBC))
+ {
+ SfxSimpleHint* pSimple = PTR_CAST(SfxSimpleHint, &rHint);
+ sal_uInt32 nId(pSimple ? pSimple->GetId() : 0L);
+
+ if(SFX_HINT_DATACHANGED == nId)
+ {
+ rObj.SetPortionInfoChecked(sal_False);
+
+ sal_Int32 nText = rObj.getTextCount();
+ while( --nText > 0 )
+ {
+ OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject();
+ if( pParaObj )
+ pParaObj->ClearPortionInfo();
+ }
+ rObj.SetTextSizeDirty();
+
+ if(rObj.IsTextFrame() && rObj.NbcAdjustTextFrameWidthAndHeight())
+ {
+ // here only repaint wanted
+ rObj.ActionChanged();
+ //rObj.BroadcastObjectChange();
+ }
+
+ // #i101556# content of StyleSheet has changed -> new version
+ maVersion++;
+ }
+
+ if(SFX_HINT_DYING == nId)
+ {
+ rObj.SetPortionInfoChecked(sal_False);
+ sal_Int32 nText = rObj.getTextCount();
+ while( --nText > 0 )
+ {
+ OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject();
+ if( pParaObj )
+ pParaObj->ClearPortionInfo();
+ }
+ }
+ }
+ else if(HAS_BASE(SfxStyleSheetBasePool, &rBC))
+ {
+ SfxStyleSheetHintExtended* pExtendedHint = PTR_CAST(SfxStyleSheetHintExtended, &rHint);
+
+ if(pExtendedHint
+ && SFX_STYLESHEET_MODIFIED == pExtendedHint->GetHint())
+ {
+ String aOldName(pExtendedHint->GetOldName());
+ String aNewName(pExtendedHint->GetStyleSheet()->GetName());
+ SfxStyleFamily eFamily = pExtendedHint->GetStyleSheet()->GetFamily();
+
+ if(!aOldName.Equals(aNewName))
+ {
+ sal_Int32 nText = rObj.getTextCount();
+ while( --nText > 0 )
+ {
+ OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject();
+ if( pParaObj )
+ pParaObj->ChangeStyleSheetName(eFamily, aOldName, aNewName);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // #i101556# Handout version information
+ sal_uInt32 TextProperties::getVersion() const
+ {
+ return maVersion;
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/smarttags/SmartTagMgr.cxx b/svx/source/smarttags/SmartTagMgr.cxx
new file mode 100644
index 000000000000..8b309a0d39cc
--- /dev/null
+++ b/svx/source/smarttags/SmartTagMgr.cxx
@@ -0,0 +1,554 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// SMARTTAGS
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_svx.hxx"
+#include <svx/SmartTagMgr.hxx>
+
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <com/sun/star/smarttags/XSmartTagRecognizer.hpp>
+#include <com/sun/star/smarttags/XSmartTagAction.hpp>
+#include <com/sun/star/deployment/ExtensionManager.hpp>
+#include <com/sun/star/text/XTextMarkup.hpp>
+#include <com/sun/star/smarttags/SmartTagRecognizerMode.hpp>
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/lang/EventObject.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <com/sun/star/util/XChangesNotifier.hpp>
+#include <comphelper/processfactory.hxx>
+#include <rtl/ustring.hxx>
+#include <tools/string.hxx>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+#define C2U(cChar) rtl::OUString::createFromAscii(cChar)
+
+
+SmartTagMgr::SmartTagMgr( const rtl::OUString& rApplicationName )
+ : maApplicationName( rApplicationName ),
+ maRecognizerList(),
+ maActionList(),
+ maDisabledSmartTagTypes(),
+ maSmartTagMap(),
+ mxMSF( ::comphelper::getProcessServiceFactory() ),
+ mbLabelTextWithSmartTags(true)
+{
+}
+
+SmartTagMgr::~SmartTagMgr()
+{
+}
+
+void SmartTagMgr::Init( const rtl::OUString& rConfigurationGroupName )
+{
+ // get component context to pass to components:
+ if ( mxMSF.is() )
+ {
+ Reference< beans::XPropertySet > xPropSet = Reference< beans::XPropertySet>( mxMSF, UNO_QUERY);
+ const Any aAny = xPropSet->getPropertyValue( C2U("DefaultContext"));
+ aAny >>= mxContext;
+
+ if ( mxContext.is() )
+ {
+ PrepareConfiguration( rConfigurationGroupName );
+ ReadConfiguration( true, true );
+ RegisterListener();
+ LoadLibraries();
+ }
+ }
+}
+void SmartTagMgr::CreateBreakIterator() const
+{
+ if ( !mxBreakIter.is() && mxMSF.is() && mxContext.is() )
+ {
+ // get the break iterator
+ mxBreakIter.set(mxMSF->createInstance( C2U( "com.sun.star.i18n.BreakIterator" ) ), UNO_QUERY);
+ }
+}
+
+/** Dispatches the recognize call to all installed smart tag recognizers
+*/
+void SmartTagMgr::Recognize( const rtl::OUString& rText,
+ const Reference< text::XTextMarkup > xMarkup,
+ const Reference< frame::XController > xController,
+ const lang::Locale& rLocale,
+ sal_uInt32 nStart, sal_uInt32 nLen ) const
+{
+ for ( sal_uInt32 i = 0; i < maRecognizerList.size(); i++ )
+ {
+ Reference < smarttags::XSmartTagRecognizer > xRecognizer = maRecognizerList[i];
+
+ // if all smart tag types supported by this recognizer have been
+ // disabled, we do not have to call the recognizer:
+ bool bCallRecognizer = false;
+ const sal_uInt32 nSmartTagCount = xRecognizer->getSmartTagCount();
+ for ( sal_uInt32 j = 0; j < nSmartTagCount && !bCallRecognizer; ++j )
+ {
+ const rtl::OUString aSmartTagName = xRecognizer->getSmartTagName(j);
+ if ( IsSmartTagTypeEnabled( aSmartTagName ) )
+ bCallRecognizer = true;
+ }
+
+ if ( bCallRecognizer )
+ {
+ CreateBreakIterator();
+ maRecognizerList[i]->recognize( rText, nStart, nLen,
+ smarttags::SmartTagRecognizerMode_PARAGRAPH,
+ rLocale, xMarkup, maApplicationName, xController,
+ mxBreakIter );
+ }
+ }
+}
+
+typedef std::multimap < rtl::OUString, ActionReference >::const_iterator SmartTagMapIter;
+
+void SmartTagMgr::GetActionSequences( Sequence < rtl::OUString >& rSmartTagTypes,
+ Sequence < Sequence< Reference< smarttags::XSmartTagAction > > >& rActionComponentsSequence,
+ Sequence < Sequence< sal_Int32 > >& rActionIndicesSequence ) const
+{
+ rActionComponentsSequence.realloc( rSmartTagTypes.getLength() );
+ rActionIndicesSequence.realloc( rSmartTagTypes.getLength() );
+
+ for ( USHORT j = 0; j < rSmartTagTypes.getLength(); ++j )
+ {
+ const rtl::OUString& rSmartTagType = rSmartTagTypes[j];
+
+ const sal_Int32 nNumberOfActionRefs = maSmartTagMap.count( rSmartTagType );
+
+ Sequence< Reference< smarttags::XSmartTagAction > > aActions( nNumberOfActionRefs );
+ Sequence< sal_Int32 > aIndices( nNumberOfActionRefs );
+
+ USHORT i = 0;
+ SmartTagMapIter aActionsIter;
+ SmartTagMapIter aEnd = maSmartTagMap.upper_bound( rSmartTagType );
+
+ for ( aActionsIter = maSmartTagMap.lower_bound( rSmartTagType ); aActionsIter != aEnd; ++aActionsIter )
+ {
+ aActions[ i ] = (*aActionsIter).second.mxSmartTagAction;
+ aIndices[ i++ ] = (*aActionsIter).second.mnSmartTagIndex;
+ }
+
+ rActionComponentsSequence[ j ] = aActions;
+ rActionIndicesSequence[ j ] = aIndices;
+ }
+}
+
+/** Returns the caption for a smart tag type.
+*/
+rtl::OUString SmartTagMgr::GetSmartTagCaption( const rtl::OUString& rSmartTagType, const com::sun::star::lang::Locale& rLocale ) const
+{
+ rtl::OUString aRet;
+
+ SmartTagMapIter aLower = maSmartTagMap.lower_bound( rSmartTagType );
+
+ if ( aLower != maSmartTagMap.end() )
+ {
+ const ActionReference& rActionRef = (*aLower).second;
+ Reference< smarttags::XSmartTagAction > xAction = rActionRef.mxSmartTagAction;
+
+ if ( xAction.is() )
+ {
+ const sal_Int32 nSmartTagIndex = rActionRef.mnSmartTagIndex;
+ aRet = xAction->getSmartTagCaption( nSmartTagIndex, rLocale );
+ }
+ }
+
+ return aRet;
+}
+
+
+/** Returns true if the given smart tag type is enabled.
+*/
+bool SmartTagMgr::IsSmartTagTypeEnabled( const rtl::OUString& rSmartTagType ) const
+{
+ return maDisabledSmartTagTypes.end() == maDisabledSmartTagTypes.find( rSmartTagType );
+}
+
+/** Writes currently disabled smart tag types to configuration.
+*/
+void SmartTagMgr::WriteConfiguration( const bool* pIsLabelTextWithSmartTags,
+ const std::vector< rtl::OUString >* pDisabledTypes ) const
+{
+ if ( mxConfigurationSettings.is() )
+ {
+ bool bCommit = false;
+
+ if ( pIsLabelTextWithSmartTags )
+ {
+ const Any aEnabled = makeAny( *pIsLabelTextWithSmartTags );
+
+ try
+ {
+ mxConfigurationSettings->setPropertyValue( C2U("RecognizeSmartTags"), aEnabled );
+ bCommit = true;
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ }
+ }
+
+ if ( pDisabledTypes )
+ {
+ const sal_Int32 nNumberOfDisabledSmartTagTypes = pDisabledTypes->size();
+ Sequence< rtl::OUString > aTypes( nNumberOfDisabledSmartTagTypes );
+
+ std::vector< rtl::OUString >::const_iterator aIter;
+ sal_Int32 nCount = 0;
+ for ( aIter = pDisabledTypes->begin(); aIter != pDisabledTypes->end(); ++aIter )
+ aTypes[ nCount++ ] = *aIter;
+
+ const Any aNewTypes = makeAny( aTypes );
+
+ try
+ {
+ mxConfigurationSettings->setPropertyValue( C2U("ExcludedSmartTagTypes"), aNewTypes );
+ bCommit = true;
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ }
+ }
+
+ if ( bCommit )
+ {
+ try
+ {
+ Reference< util::XChangesBatch >( mxConfigurationSettings, UNO_QUERY_THROW )->commitChanges();
+ }
+ catch ( ::com::sun::star::uno::Exception& )
+ {
+ }
+ }
+ }
+}
+
+// ::com::sun::star::util::XModifyListener
+void SmartTagMgr::modified( const lang::EventObject& ) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ maRecognizerList.clear();
+ maActionList.clear();
+ maSmartTagMap.clear();
+
+ LoadLibraries();
+}
+
+// ::com::sun::star::lang::XEventListener
+void SmartTagMgr::disposing( const lang::EventObject& rEvent ) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference< frame::XModel > xModel( rEvent.Source, uno::UNO_QUERY );
+ uno::Reference< util::XModifyBroadcaster > xMB(xModel, uno::UNO_QUERY);
+ uno::Reference< util::XChangesNotifier > xCN(xModel, uno::UNO_QUERY);
+
+ try
+ {
+ if( xMB.is() )
+ {
+ uno::Reference< util::XModifyListener > xListener( this );
+ xMB->removeModifyListener( xListener );
+ }
+ else if ( xCN.is() )
+ {
+ uno::Reference< util::XChangesListener > xListener( this );
+ xCN->removeChangesListener( xListener );
+ }
+ }
+ catch(Exception& )
+ {
+ }
+}
+
+// ::com::sun::star::util::XChangesListener
+void SmartTagMgr::changesOccurred( const util::ChangesEvent& rEvent ) throw( RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const util::ElementChange* pElementChanges = rEvent.Changes.getConstArray();
+ const sal_Int32 nNumberOfChanges = rEvent.Changes.getLength();
+ bool bExcludedTypes = false;
+ bool bRecognize = false;
+
+ for( sal_Int32 i = 0; i < nNumberOfChanges; ++i)
+ {
+ rtl::OUString sTemp;
+ pElementChanges[i].Accessor >>= sTemp;
+
+ if ( sTemp == C2U( "ExcludedSmartTagTypes" ) )
+ bExcludedTypes = true;
+ else if ( sTemp == C2U( "RecognizeSmartTags" ) )
+ bRecognize = true;
+ }
+
+ ReadConfiguration( bExcludedTypes, bRecognize );
+}
+
+//------------- PRIVATE -----------------------------------------------
+
+/**
+*/
+void SmartTagMgr::LoadLibraries()
+{
+ Reference< container::XContentEnumerationAccess > rContent( mxMSF , UNO_QUERY );
+ if ( !rContent.is() )
+ return;
+
+ // load recognizers: No recognizers -> nothing to do.
+ Reference < container::XEnumeration > rEnum = rContent->createContentEnumeration( C2U("com.sun.star.smarttags.SmartTagRecognizer"));
+ if ( !rEnum.is() || !rEnum->hasMoreElements() )
+ return;
+
+ // iterate over all implementations of the smart tag recognizer service:
+ while( rEnum->hasMoreElements())
+ {
+ const Any a = rEnum->nextElement();
+ Reference< lang::XSingleComponentFactory > xSCF;
+ Reference< lang::XServiceInfo > xsInfo;
+
+ if (a >>= xsInfo)
+ xSCF = Reference< lang::XSingleComponentFactory >(xsInfo, UNO_QUERY);
+ else
+ continue;
+
+ Reference< smarttags::XSmartTagRecognizer > xLib ( xSCF->
+ createInstanceWithContext(mxContext), UNO_QUERY );
+
+ if (!xLib.is())
+ continue;
+
+ xLib->initialize( Sequence< Any >() );
+ maRecognizerList.push_back(xLib);
+ }
+
+ // load actions: No actions -> nothing to do.
+ rEnum = rContent->createContentEnumeration( C2U("com.sun.star.smarttags.SmartTagAction"));
+ if ( !rEnum.is() )
+ return;
+
+ // iterate over all implementations of the smart tag action service:
+ while( rEnum->hasMoreElements())
+ {
+ const Any a = rEnum->nextElement();
+ Reference< lang::XServiceInfo > xsInfo;
+ Reference< lang::XSingleComponentFactory > xSCF;
+
+ if (a >>= xsInfo)
+ xSCF = Reference< lang::XSingleComponentFactory >(xsInfo, UNO_QUERY);
+ else
+ continue;
+
+ Reference< smarttags::XSmartTagAction > xLib ( xSCF->
+ createInstanceWithContext(mxContext), UNO_QUERY );
+
+ if (!xLib.is())
+ continue;
+
+ xLib->initialize( Sequence< Any >() );
+ maActionList.push_back(xLib);
+ }
+
+ AssociateActionsWithRecognizers();
+
+}
+
+/**
+*/
+void SmartTagMgr::PrepareConfiguration( const rtl::OUString& rConfigurationGroupName )
+{
+ Any aAny = makeAny( C2U( "/org.openoffice.Office.Common/SmartTags/" ) + rConfigurationGroupName );
+ beans::PropertyValue aPathArgument;
+ aPathArgument.Name = C2U( "nodepath" );
+ aPathArgument.Value = aAny;
+ Sequence< Any > aArguments( 1 );
+ aArguments[ 0 ] <<= aPathArgument;
+ Reference< lang::XMultiServiceFactory > xConfProv( mxMSF->createInstance(C2U ("com.sun.star.configuration.ConfigurationProvider")), UNO_QUERY );
+
+ if ( !xConfProv.is() )
+ return;
+
+ // try to get read-write access to configuration:
+ Reference< XInterface > xConfigurationAccess;
+ try
+ {
+ xConfigurationAccess = xConfProv->createInstanceWithArguments(
+ C2U("com.sun.star.configuration.ConfigurationUpdateAccess" ), aArguments );
+ }
+ catch ( uno::Exception& )
+ {
+ }
+
+ // fallback: try read-only access to configuration:
+ if ( !xConfigurationAccess.is() )
+ {
+ try
+ {
+ xConfigurationAccess = xConfProv->createInstanceWithArguments(
+ C2U("com.sun.star.configuration.ConfigurationAccess" ), aArguments );
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+
+ if ( xConfigurationAccess.is() )
+ {
+ mxConfigurationSettings = Reference< beans::XPropertySet >( xConfigurationAccess, UNO_QUERY );
+ }
+}
+
+
+void SmartTagMgr::ReadConfiguration( bool bExcludedTypes, bool bRecognize )
+{
+ if ( mxConfigurationSettings.is() )
+ {
+ if ( bExcludedTypes )
+ {
+ maDisabledSmartTagTypes.clear();
+
+ Any aAny = mxConfigurationSettings->getPropertyValue( C2U("ExcludedSmartTagTypes") );
+ Sequence< rtl::OUString > aValues;
+ aAny >>= aValues;
+
+ const sal_Int32 nValues = aValues.getLength();
+
+ for ( sal_Int32 nI = 0; nI < nValues; ++nI )
+ maDisabledSmartTagTypes.insert( aValues[nI] );
+ }
+
+ if ( bRecognize )
+ {
+ Any aAny = mxConfigurationSettings->getPropertyValue( C2U("RecognizeSmartTags") );
+ sal_Bool bValue = sal_True;
+ aAny >>= bValue;
+
+ mbLabelTextWithSmartTags = bValue;
+ }
+ }
+}
+
+/**
+*/
+void SmartTagMgr::RegisterListener()
+{
+ // register as listener at package manager
+ try
+ {
+ Reference<deployment::XExtensionManager> xExtensionManager(
+ deployment::ExtensionManager::get( mxContext ) );
+ Reference< util::XModifyBroadcaster > xMB ( xExtensionManager, UNO_QUERY_THROW );
+
+ Reference< util::XModifyListener > xListener( this );
+ xMB->addModifyListener( xListener );
+ }
+ catch ( uno::Exception& )
+ {
+ }
+
+ // register as listener at configuration
+ try
+ {
+ Reference<util::XChangesNotifier> xCN( mxConfigurationSettings, UNO_QUERY_THROW );
+ Reference< util::XChangesListener > xListener( this );
+ xCN->addChangesListener( xListener );
+ }
+ catch ( uno::Exception& )
+ {
+ }
+}
+
+typedef std::pair < const rtl::OUString, ActionReference > SmartTagMapElement;
+
+/** Sets up a map that maps smart tag type names to actions references.
+*/
+void SmartTagMgr::AssociateActionsWithRecognizers()
+{
+ const sal_uInt32 nActionLibCount = maActionList.size();
+ const sal_uInt32 nRecognizerCount = maRecognizerList.size();
+
+ for ( sal_uInt32 i = 0; i < nRecognizerCount; ++i )
+ {
+ Reference < smarttags::XSmartTagRecognizer > xRecognizer = maRecognizerList[i];
+ const sal_uInt32 nSmartTagCount = xRecognizer->getSmartTagCount();
+ for ( sal_uInt32 j = 0; j < nSmartTagCount; ++j )
+ {
+ const rtl::OUString aSmartTagName = xRecognizer->getSmartTagName(j);
+
+ // check if smart tag type has already been processed:
+ if ( maSmartTagMap.find( aSmartTagName ) != maSmartTagMap.end() )
+ continue;
+
+ bool bFound = false;
+ for ( sal_uInt32 k = 0; k < nActionLibCount; ++k )
+ {
+ Reference< smarttags::XSmartTagAction > xActionLib = maActionList[k];
+ const sal_uInt32 nSmartTagCountInActionLib = xActionLib->getSmartTagCount();
+ for ( sal_uInt32 l = 0; l < nSmartTagCountInActionLib; ++l )
+ {
+ const rtl::OUString aSmartTagNameInActionLib = xActionLib->getSmartTagName(l);
+ if ( aSmartTagName.equals( aSmartTagNameInActionLib ) )
+ {
+ // found actions and recognizer for same smarttag
+ ActionReference aActionRef( xActionLib, l );
+
+ // add recognizer/action pair to map
+ maSmartTagMap.insert( SmartTagMapElement( aSmartTagName, aActionRef ));
+
+ bFound = true;
+ }
+ }
+ }
+
+ if ( !bFound )
+ {
+ // insert 'empty' action reference if there is no action associated with
+ // the current smart tag type:
+ Reference< smarttags::XSmartTagAction > xActionLib;
+ ActionReference aActionRef( xActionLib, 0 );
+
+ // add recognizer/action pair to map
+ maSmartTagMap.insert( SmartTagMapElement( aSmartTagName, aActionRef ));
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/smarttags/makefile.mk b/svx/source/smarttags/makefile.mk
new file mode 100644
index 000000000000..e92a4c0a6b0a
--- /dev/null
+++ b/svx/source/smarttags/makefile.mk
@@ -0,0 +1,48 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=svx
+TARGET=smarttags
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/SmartTagMgr.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/svx/source/src/app.hrc b/svx/source/src/app.hrc
new file mode 100644
index 000000000000..5fb1bfce28b8
--- /dev/null
+++ b/svx/source/src/app.hrc
@@ -0,0 +1,447 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+//========================================================================
+// Resource-Id's f"ur die OFA
+//
+// (C) 1998 - 2000 StarOffice Software Entw. GmbH, Hamburg, Germany
+// $Author: rt $ $Date: 2008-04-11 02:44:40 $ $Revision: 1.5 $
+// $Logfile: T:/offmgr/inc/app.hrv $ $Workfile: APP.HRC $
+//------------------------------------------------------------------------
+#ifndef _OFF_APP_HRC
+#define _OFF_APP_HRC
+
+// include ---------------------------------------------------------------
+
+#include <svl/solar.hrc>
+#include <sfx2/sfxsids.hrc>
+
+// Ranges ----------------------------------------------------------------
+
+// PB: Vorsicht diesen Bereich hier im app.hrc nicht mehr benutzen!
+#define RID_OFA_LDAP_START (RID_OFA_START + 300)
+#define RID_OFA_LDAP_END (RID_OFA_START + 349)
+
+// defines ---------------------------------------------------------------
+
+#define RID_QRY_SELECTMAILADDR (RID_OFA_START + 0)
+#define RID_QRY_NEWMAILADDR (RID_OFA_START + 1)
+#define RID_QRY_SELECTBRWADDR (RID_OFA_START + 2)
+#define RID_QRY_NEWBRWADDR (RID_OFA_START + 3)
+#define RID_QRY_NO_URL (RID_OFA_START + 4)
+#define RID_QRY_NO_MAILADDR (RID_OFA_START + 5)
+#define RID_QRY_NO_NAME (RID_OFA_START + 6)
+#define RID_QRY_INVALID_URL (RID_OFA_START + 7)
+#define RID_QRY_DEL_MAIL (RID_OFA_START + 8)
+#define RID_QRY_ADDRESSBOOK (RID_OFA_START + 9)
+#define RID_QRY_NO_ADDR (RID_OFA_START + 10)
+
+ // String und ToolBox
+#define RID_MAILTOOLBOX (RID_OFA_START + 112)
+#define RID_QRY_SELECTADDR (RID_OFA_START + 13)
+
+#define RID_ICO_MSGVIEW (RID_OFA_START + 20)
+#define RID_WIN_MAILHEADER (RID_OFA_START + 21)
+#define RID_WIN_MAILATTACH (RID_OFA_START + 22)
+#define RID_IMG_MAILTEXT (RID_OFA_START + 23)
+#define RID_MSGDOC_MENU (RID_OFA_START + 24)
+#define RID_ATTACH_MENU (RID_OFA_START + 25)
+#define RID_HEADER_MENU (RID_OFA_START + 26)
+#define RID_CALENDAR_WIN (RID_OFA_START + 27)
+#define RID_STA_NEWSWIN_TITEL (RID_OFA_START + 28)
+#define RID_SEND_MENU (RID_OFA_START + 29)
+
+
+// Icons and Images ------------------------------------------------------
+
+#define RID_ICO_TABLES (RID_OFA_START + 30)
+#define RID_ICO_QUERIES (RID_OFA_START + 31)
+#define RID_ICO_FORMS (RID_OFA_START + 32)
+#define RID_ICO_REPORTS (RID_OFA_START + 33)
+#define RID_ICO_DATABASE (RID_OFA_START + 34)
+#define RID_IMG_ALTFOLDER_CLOSE (RID_OFA_START + 35)
+#define RID_IMG_ALTFOLDER_OPEN (RID_OFA_START + 36)
+#define RID_IMG_ALTFOLDER_PLUS (RID_OFA_START + 37)
+#define RID_IMG_ALTFOLDER_MINUS (RID_OFA_START + 38)
+#define RID_IMGLIST_PGP (RID_OFA_START + 39)
+#define RID_IMGLIST_LARGE_PGP (RID_OFA_START + 40)
+
+// Errors ----------------------------------------------------------------
+
+#define RID_ERR_OUTBOX (RID_OFA_START + 50)
+#define RID_ERR_DB_OPENPROPERTIES (RID_OFA_START + 51)
+#define RID_ERR_NO_EMAILADDRESS (RID_OFA_START + 52)
+#define RID_QBOX_NOSUBJECT (RID_OFA_START + 53)
+#define RID_ERRBOX_NORECIPIENTS (RID_OFA_START + 54)
+#define RID_ERRBOX_NOSETTINGS (RID_OFA_START + 55)
+#define RID_QBOX_ADDADDRESS (RID_OFA_START + 56)
+#define RID_ERR_NO_DD_FOR_ADDRESSBOOK (RID_OFA_START + 57)
+#define RID_QBOX_NORCPTS (RID_OFA_START + 58)
+#define RID_QBOX_FORMATS (RID_OFA_START + 59)
+#define RID_ERRBOX_NOVALIDRCPTS (RID_OFA_START + 60)
+#define RID_QBOX_SAVEMAIL (RID_OFA_START + 61)
+#define RID_WARNBOX_LOCKEDFILE (RID_OFA_START + 62)
+#define RID_QBOX_COMPRESS (RID_OFA_START + 63)
+#define RID_ERRBOX_APPENDADDRESS (RID_OFA_START + 64)
+#define RID_QBOX_DELETEATTACHMENT (RID_OFA_START + 65)
+#define RID_ERRBOX_NO_OUTBOX (RID_OFA_START + 66)
+#define RID_WARNDLG_ONLY_ASCII (RID_OFA_START + 67)
+#define RID_ERR_TABLE_LOCKED (RID_OFA_START + 68)
+#define RID_ERR_OBJECT_LOCKED (RID_OFA_START + 69)
+#define RID_ERR_NAME_INVALID (RID_OFA_START + 70)
+#define RID_INFO_TABLE_NO_SELECT (RID_OFA_START + 71)
+#define RID_ERRBOX_MODULENOTINSTALLED (RID_OFA_START + 72)
+
+// Dialoge ---------------------------------------------------------------
+
+#define RID_OFAPAGE_HTMLOPT (RID_OFA_START + 100)
+#define RID_OFA_AUTOCORR_DLG (RID_OFA_START + 101)
+#define RID_OFAPAGE_AUTOCORR_OPTIONS (RID_OFA_START + 102)
+#define RID_OFAPAGE_AUTOCORR_REPLACE (RID_OFA_START + 103)
+#define RID_OFAPAGE_AUTOCORR_EXCEPT (RID_OFA_START + 104)
+#define RID_OFA_GENERAL_OPTIONS_DLG (RID_OFA_START + 105)
+#define RID_OFADLG_INTERNET (RID_OFA_START + 106)
+#define RID_OFA_TABNEW_DLG (RID_OFA_START + 107)
+#define RID_OFADLG_BROWSER (RID_OFA_START + 108)
+#define RID_OFAPAGE_AUTOCORR_QUOTE (RID_OFA_START + 109)
+#define RID_OFAPAGE_AUTOFMT_APPLY (RID_OFA_START + 110)
+#define RID_OFADLG_PRCNT_SET (RID_OFA_START + 111)
+#define RID_OFA_FORMNEW_DLG (RID_OFA_START + 112)
+#define RID_OFA_TABPROPERTIES (RID_OFA_START + 113)
+#define RID_OFADLG_REGISTRATION (RID_OFA_START + 114)
+#define RID_OFADLG_OPTIONS_TREE (RID_OFA_START + 115)
+#define RID_OFADLG_OPTIONS_TREE_PAGES (RID_OFA_START + 116)
+#define RID_OFADLG_AWCP_VALUES (RID_OFA_START + 117)
+#define RID_OFAPAGE_AUTOCOMPLETE_OPTIONS (RID_OFA_START + 119)
+#define RID_OFAPAGE_MSFILTEROPT (RID_OFA_START + 120)
+#define RID_OFAPAGE_MSFILTEROPT2 (RID_OFA_START + 121)
+#define RID_OFAPAGE_CONNPOOLOPTIONS (RID_OFA_START + 122)
+
+// TabPages --------------------------------------------------------------
+
+#define OFA_TP_MISC (RID_OFA_START + 200)
+
+#define OFA_TP_VIEW (RID_OFA_START + 202)
+#define OFA_TP_APPEARANCE (RID_OFA_START + 203)
+#define OFA_TP_TABPROPERTIES_GENERAL (RID_OFA_START + 204)
+#define OFA_TP_LANGUAGES (RID_OFA_START + 205)
+
+//die RID_??_TP_* stehen nochmal im offids.hrc
+#define RID_SW_TP_CONTENT_OPT (RID_OFA_START + 206)
+#define RID_SW_TP_LAYOUT_OPT (RID_OFA_START + 207)
+#define RID_SW_TP_STD_FONT (RID_OFA_START + 208)
+#define RID_SW_TP_OPTPRINT_PAGE (RID_OFA_START + 209)
+#define RID_SW_TP_OPTTABLE_PAGE (RID_OFA_START + 210)
+#define RID_SW_TP_OPTSHDWCRSR (RID_OFA_START + 211)
+#define RID_SW_TP_REDLINE_OPT (RID_OFA_START + 212)
+#define RID_SW_TP_OPTINSERT_PAGE (RID_OFA_START + 213)
+#define RID_SW_TP_OPTLOAD_PAGE (RID_OFA_START + 214)
+#define RID_SW_TP_OPTTEST_PAGE (RID_OFA_START + 215)
+#define RID_SW_TP_OPTSRCVIEW (RID_OFA_START + 216)
+#define RID_SW_TP_BACKGROUND (RID_OFA_START + 217)
+#define SID_SC_TP_LAYOUT (RID_OFA_START + 218)
+#define SID_SC_TP_CONTENT (RID_OFA_START + 219)
+#define SID_SC_TP_INPUT (RID_OFA_START + 220)
+#define SID_SC_TP_GRID (RID_OFA_START + 221)
+#define SID_SC_TP_USERLISTS (RID_OFA_START + 222)
+#define SID_SC_TP_CALC (RID_OFA_START + 223)
+#define SID_SC_TP_CHANGES (RID_OFA_START + 224)
+#define SID_SD_TP_CONTENTS (RID_OFA_START + 225)
+#define SID_SD_TP_LAYOUT (RID_OFA_START + 226)
+#define SID_SD_TP_SNAP (RID_OFA_START + 227)
+#define SID_SD_TP_SCALE (RID_OFA_START + 228)
+#define SID_SD_TP_GRID (RID_OFA_START + 229)
+#define SID_SD_TP_PRINT (RID_OFA_START + 220)
+#define SID_SD_TP_MISC (RID_OFA_START + 231)
+#define SID_SI_TP_CONTENTS (RID_OFA_START + 232)
+#define SID_SI_TP_LAYOUT (RID_OFA_START + 233)
+#define SID_SI_TP_SNAP (RID_OFA_START + 234)
+#define SID_SI_TP_GRID (RID_OFA_START + 235)
+#define SID_SI_TP_PRINT (RID_OFA_START + 236)
+#define SID_SI_TP_MISC (RID_OFA_START + 237)
+#define RID_SW_TP_OPTINSERT_HTML_PAGE (RID_OFA_START + 238)
+#define SID_SC_TP_MISC (RID_OFA_START + 239)
+#define RID_SW_TP_HTML_CONTENT_OPT (RID_OFA_START + 240)
+#define RID_SW_TP_HTML_LAYOUT_OPT (RID_OFA_START + 241)
+#define RID_SW_TP_HTML_OPTPRINT_PAGE (RID_OFA_START + 242)
+#define RID_SW_TP_HTML_OPTTABLE_PAGE (RID_OFA_START + 243)
+#define RID_SW_TP_HTML_OPTGRID_PAGE (RID_OFA_START + 244)
+#define OFA_TP_TABPROPERTIES_TEXT (RID_OFA_START + 245)
+#define RID_SW_TP_HTML_OPTSHDWCRSR (RID_OFA_START + 246)
+#define RID_SW_TP_STD_FONT_CJK (RID_OFA_START + 247)
+#define RID_SC_TP_PRINT (RID_OFA_START + 248)
+#define OFA_TP_HELPERPROG (RID_OFA_START + 249)
+#define OFA_TP_MEMORY (RID_OFA_START + 250)
+#define RID_SW_TP_STD_FONT_CTL (RID_OFA_START + 251)
+#define RID_OFA_TP_INTERNATIONAL (RID_OFA_START + 252) // 4 SC & ID 4 resource
+#define RID_OFA_TP_INTERNATIONAL_SD (RID_OFA_START + 253) // 4 SD
+#define RID_OFA_TP_INTERNATIONAL_IMPR (RID_OFA_START + 254) // 4 impress
+#define RID_SW_TP_OPTCOMPATIBILITY_PAGE (RID_OFA_START + 255)
+#define RID_SW_TP_OPTCAPTION_PAGE (RID_OFA_START + 256)
+#define SID_SC_TP_FORMULA (RID_OFA_START + 257)
+#define SID_SC_TP_COMPATIBILITY (RID_OFA_START + 258)
+
+// Strings ------------------------------------------
+
+#define RID_STR_ROLE_TO (RID_OFA_START + 0)
+#define RID_STR_ROLE_CC (RID_OFA_START + 1)
+#define RID_STR_ROLE_BCC (RID_OFA_START + 2)
+#define RID_STR_NEWMAIL (RID_OFA_START + 3)
+#define RID_STR_MAIL (RID_OFA_START + 4)
+#define RID_STR_DETACH (RID_OFA_START + 5)
+#define RID_STR_SUBJECT (RID_OFA_START + 6)
+#define RID_STR_AUTHOR (RID_OFA_START + 7)
+#define RID_STR_DATE (RID_OFA_START + 108)
+#define RID_DESKTOP (RID_OFA_START + 109)
+#define RID_STR_ROLE_VIM (RID_OFA_START + 110)
+
+#define RID_RIDER_SLL_SITE (RID_OFA_START + 100)
+#define RID_RIDER_SLL_PERSONAL (RID_OFA_START + 101)
+
+// Bitmaps ---------------------------------------------------------------
+
+#define RID_BMP_DB_DATABASE_S (RID_OFA_START + 150)
+#define RID_BMP_DB_DATABASE_L (RID_OFA_START + 151)
+#define RID_BMP_DB_TABLEFOLDER_S (RID_OFA_START + 152)
+#define RID_BMP_DB_TABLEFOLDER_L (RID_OFA_START + 153)
+#define RID_BMP_DB_TABLE_S (RID_OFA_START + 154)
+#define RID_BMP_DB_TABLE_L (RID_OFA_START + 155)
+#define RID_BMP_DB_QUERYFOLDER_S (RID_OFA_START + 156)
+#define RID_BMP_DB_QUERYFOLDER_L (RID_OFA_START + 157)
+#define RID_BMP_DB_QUERY_S (RID_OFA_START + 158)
+#define RID_BMP_DB_QUERY_L (RID_OFA_START + 159)
+#define RID_BMP_DB_FORMFOLDER_S (RID_OFA_START + 160)
+#define RID_BMP_DB_FORMFOLDER_L (RID_OFA_START + 161)
+#define RID_BMP_DB_FORM_S (RID_OFA_START + 162)
+#define RID_BMP_DB_FORM_L (RID_OFA_START + 163)
+#define RID_BMP_DB_REPORTFOLDER_S (RID_OFA_START + 164)
+#define RID_BMP_DB_REPORTFOLDER_L (RID_OFA_START + 165)
+#define RID_BMP_DB_REPORT_S (RID_OFA_START + 166)
+#define RID_BMP_DB_REPORT_L (RID_OFA_START + 167)
+#define RID_BMP_DB_STATEMENT_S (RID_OFA_START + 168)
+#define RID_BMP_DB_STATEMENT_L (RID_OFA_START + 169)
+#define RID_BMP_DB_VIEW_S (RID_OFA_START + 170)
+#define RID_BMP_DB_VIEW_L (RID_OFA_START + 171)
+#define RID_BMP_DB_RELATIONS_S (RID_OFA_START + 172)
+#define RID_BMP_DB_RELATIONS_L (RID_OFA_START + 173)
+#define RID_IMGLIST_TREEOPT (RID_OFA_START + 174)
+#define RID_IMGLIST_TREEOPT_HC (RID_OFA_START + 175)
+
+ // 12 und 13 nicht benutzen!!!
+// ..._BEGIN kann nochmal benutzt werden, nur zum Iterieren
+#define RID_STR_PRIO_BEGIN (RID_OFA_START + 17)
+#define RID_STR_PRIO_HIGHEST (RID_OFA_START + 18)
+#define RID_STR_PRIO_HIGH (RID_OFA_START + 19)
+#define RID_STR_PRIO_NORMAL (RID_OFA_START + 20)
+#define RID_STR_PRIO_LOW (RID_OFA_START + 21)
+#define RID_STR_PRIO_LOWEST (RID_OFA_START + 22)
+
+// Datenbank / Explorer
+
+#define RID_STR_NAME_DATABASE (RID_OFA_START + 23)
+#define RID_STR_NAME_TABLES (RID_OFA_START + 24)
+#define RID_STR_NAME_TABLE (RID_OFA_START + 25)
+#define RID_STR_NAME_QUERIES (RID_OFA_START + 26)
+#define RID_STR_NAME_QUERIE (RID_OFA_START + 27)
+#define RID_STR_NAME_ADDRESSBOOK (RID_OFA_START + 28)
+#define RID_STR_QRY_DESIGNVIEW (RID_OFA_START + 29)
+#define RID_STR_QRY_SQLVIEW (RID_OFA_START + 30)
+#define RID_STR_NAME_DATABASECONTENT (RID_OFA_START + 31)
+#define RID_STR_TBL_DESIGNVIEW (RID_OFA_START + 32)
+#define RID_STR_NAME_FORMS (RID_OFA_START + 33)
+#define RID_STR_NAME_FORM (RID_OFA_START + 34)
+#define RID_STR_NAME_REPORTS (RID_OFA_START + 35)
+#define RID_STR_NAME_REPORT (RID_OFA_START + 36)
+#define RID_STR_RPT_DESIGNVIEW (RID_OFA_START + 37)
+#define RID_STR_FRM_DESIGNVIEW (RID_OFA_START + 38)
+#define RID_STR_TBL_COMPRESS (RID_OFA_START + 39)
+#define RID_STR_NAME_VIEW (RID_OFA_START + 40)
+#define RID_STR_NAME_RELATIONS (RID_OFA_START + 41)
+#define RID_STR_NAME_MANUAL_SQL (RID_OFA_START + 42)
+#define RID_STR_ACTUALIZE (RID_OFA_START + 43)
+#define RID_STR_NEW (RID_OFA_START + 44)
+#define RID_STR_WIZARD (RID_OFA_START + 45)
+#define RID_STR_IMPORTVCARD (RID_OFA_START + 46)
+#define RID_STR_EXPORTVCARD (RID_OFA_START + 47)
+#define RID_STR_ASK_COPY_REMAINING (RID_OFA_START + 48)
+#define RID_STR_ASK_MOVE_REMAINING (RID_OFA_START + 49)
+#define RID_STR_FRM_NEW_TEXTDOC (RID_OFA_START + 50)
+#define RID_STR_FRM_NEW_CALCDOC (RID_OFA_START + 51)
+#define RID_STR_FRM_NEW_IMPRESSDOC (RID_OFA_START + 52)
+#define RID_STR_FRM_NEW_AUTODOC (RID_OFA_START + 53)
+#define RID_STR_DB_REORGANIZE (RID_OFA_START + 54)
+#define RID_STR_FRM_NEW_TEMPLATE (RID_OFA_START + 55)
+
+#define RID_STR_NEWSGROUP (RID_OFA_START + 61)
+
+
+#define RID_STR_MESSAGE (RID_OFA_START + 64)
+#define RID_STR_PRINTMSG_DOC (RID_OFA_START + 66)
+#define RID_STR_PRINTMSG_SUBJECT (RID_OFA_START + 67)
+#define RID_STR_PRINTMSG_DATE (RID_OFA_START + 68)
+#define RID_STR_PRINTMSG_FROM (RID_OFA_START + 69)
+#define RID_STR_PRINTMSG_TO (RID_OFA_START + 70)
+#define RID_ERR_OPENNEWSSERVER (RID_OFA_START + 71)
+#define RID_ERR_SENDNEWS (RID_OFA_START + 72)
+#define RID_ERR_SENDMAIL (RID_OFA_START + 73)
+#define RID_ERR_NOPRINTDOC (RID_OFA_START + 74)
+#define RID_STR_ROLE_REPLY_TO (RID_OFA_START + 75)
+#define RID_STR_ROLE_FOLLOWUP_TO (RID_OFA_START + 76)
+#define RID_STR_BUTTON_SEND (RID_OFA_START + 77)
+#define RID_STR_BUTTON_SAVE (RID_OFA_START + 78)
+#define RID_STR_BUTTON_REJECT (RID_OFA_START + 79)
+#define RID_STR_CLOSE_MESSAGE (RID_OFA_START + 80)
+#define RID_STR_BUTTON_BACKTOMSG (RID_OFA_START + 81)
+#define RID_STR_CLOSE_TITLE (RID_OFA_START + 82)
+#define RID_STR_ASCII_FORMAT (RID_OFA_START + 83)
+
+// The following eight RIDs replace the message in RID_ERRBOX_NOSETTINGS:
+#define RID_ERRSTR_SMTP_NO_SERVER (RID_OFA_START + 84)
+#define RID_ERRSTR_NNTP_NO_SERVER (RID_OFA_START + 85)
+#define RID_ERRSTR_VIM_PRIV_NO_USER (RID_OFA_START + 86)
+#define RID_ERRSTR_VIM_PRIV_NO_USER_PWD (RID_OFA_START + 87)
+#define RID_ERRSTR_VIM_PUB_NO_USER (RID_OFA_START + 88)
+#define RID_ERRSTR_VIM_PUB_NO_USER_PWD (RID_OFA_START + 89)
+#define RID_ERRSTR_CREATE_OUTBOX (RID_OFA_START + 90)
+#define RID_ERRSTR_EDIT_OUTBOX (RID_OFA_START + 91)
+#define RID_ERRSTR_EDIT_ACCOUNT_PRIV (RID_OFA_START + 92)
+#define RID_ERRSTR_EDIT_ACCOUNT_PUB (RID_OFA_START + 93)
+
+#define RID_STR_NAME_USER_SETTINGS (RID_OFA_START + 94)
+#define RID_STR_FRMORREP_NAMETOLONG (RID_OFA_START + 95)
+#define RID_STR_TBL_CREATE_BACKUP (RID_OFA_START + 96)
+#define RID_STR_DB_SWITCH_FAVORITE (RID_OFA_START + 97)
+#define RID_STR_DB_FAVORITE_TTILE (RID_OFA_START + 98)
+
+
+// unnamed resources ----------------------------------------------------
+#define OFA_RES_UNNAMED_START (RID_OFA_START + 200)
+
+#define RID_RES_SBACHAOS_ERR_CONTEXTS (OFA_RES_UNNAMED_START + 1)
+
+// HelpIds ---------------------------------------------------------------
+/*
+#define HID_AUTOCORR_DLG (HID_OFA_START + 0)
+#define HID_OFAPAGE_AUTOCORR_OPTIONS (HID_OFA_START + 1)
+#define HID_OFAPAGE_AUTOCORR_REPLACE (HID_OFA_START + 2)
+#define HID_OFAPAGE_AUTOCORR_EXCEPT (HID_OFA_START + 3)
+#define HID_OFACTL_AUTOCORR_REPLACE (HID_OFA_START + 4)
+#define HID_OFAWIN_MAIL_HEADER (HID_OFA_START + 5)
+#define HID_OFAWIN_MAIL_ATTACH (HID_OFA_START + 6)
+#define HID_OFACTL_MAIL_ATTACH (HID_OFA_START + 7)
+#define HID_OFA_TP_MISC (HID_OFA_START + 8)
+#define HID_OFA_HYPERLINK (HID_OFA_START + 10)
+#define HID_OFA_DLGTABNEW (HID_OFA_START + 11)
+#define HID_OFA_HYPERLINK_DLG (HID_OFA_START + 12)
+#define HID_OFA_MAILHEAD_ROLE_LB (HID_OFA_START + 13)
+#define HID_OFA_MAILHEAD_RCPT_ED (HID_OFA_START + 14)
+#define HID_OFA_MAILHEAD_RCPT_LB (HID_OFA_START + 15)
+#define HID_OFA_MAILHEAD_SUBJECT_ED (HID_OFA_START + 16)
+#define HID_OFA_MAILHEAD_RECEIPT_CB (HID_OFA_START + 17)
+#define HID_OFA_MAILHEAD_PRIORITY_LB (HID_OFA_START + 18)
+#define HID_OFA_MAILHEAD_HEAD_WIN (HID_OFA_START + 19)
+#define HID_OFA_MAILATTACH_ATTACH_LB (HID_OFA_START + 20)
+#define HID_OFA_MAILATTACH_ASCII_CB (HID_OFA_START + 21)
+#define HID_OFA_MAILATTACH_HTML_CB (HID_OFA_START + 22)
+#define HID_OFA_MAILATTACH_RTF_CB (HID_OFA_START + 23)
+#define HID_OFA_MAILATTACH_OFFICE_CB (HID_OFA_START + 24)
+#define HID_OFA_HYPERLINK_TARGET (HID_OFA_START + 25)
+#define HID_OFA_HYPERLINK_SEARCH (HID_OFA_START + 26)
+#define HID_OFA_MAILTOOLBOX (HID_OFA_START + 27)
+#define HID_OFAPAGE_AUTOCORR_QUOTE (HID_OFA_START + 28)
+#define HID_OFA_TP_VIEW (HID_OFA_START + 29)
+#define HID_OFA_MAILMENU_OPEN (HID_OFA_START + 30)
+#define HID_OFA_MAILMENU_DELETE (HID_OFA_START + 31)
+#define HID_OFA_MAILMENU_RENAME (HID_OFA_START + 32)
+#define HID_OFA_MAILMENU_SAVEAS (HID_OFA_START + 33)
+#define HID_OFA_MAILMENU_ADDADDRESS (HID_OFA_START + 34)
+#define HID_OFA_MAILMENU_COPYLINK (HID_OFA_START + 35)
+#define HID_OFA_MAILMENU_SIG1 (HID_OFA_START + 36)
+#define HID_OFA_MAILMENU_SIG2 (HID_OFA_START + 37)
+#define HID_OFA_MAILMENU_SIG3 (HID_OFA_START + 38)
+#define HID_OFA_MAILMENU_SIG4 (HID_OFA_START + 39)
+#define HID_OFA_MAILHEAD_PROTOCOL_LB (HID_OFA_START + 42)
+#define HID_OFA_MAILATTACH_RECEIPT_CB (HID_OFA_START + 43)
+#define HID_OFA_MAILATTACH_PRIORITY_LB (HID_OFA_START + 44)
+#define HID_OFA_MAILATTACH_TABBAR (HID_OFA_START + 45)
+#define HID_OFAPAGE_AUTOCORR_CLB (HID_OFA_START + 46)
+#define HID_OFAPAGE_AUTOFORMAT_CLB (HID_OFA_START + 47)
+#define HID_OFAPAGE_AUTOFMT_OPTIONS (HID_OFA_START + 48)
+#define HID_OFA_DLGFORMNEW (HID_OFA_START + 49)
+#define HID_OFA_TP_APPEARANCE (HID_OFA_START + 50)
+#define HID_OFA_HYPERLINK_NAME (HID_OFA_START + 51)
+#define HID_OFA_HYPERLINK_URL_TXT (HID_OFA_START + 52)
+#define HID_OFA_HYPERLINK_URL (HID_OFA_START + 53)
+#define HID_OFA_MAILMENU_FILE (HID_OFA_START + 54)
+#define HID_OFA_FONT_SUBSTITUTION (HID_OFA_START + 55)
+#define HID_OFA_FONT_SUBST_CLB (HID_OFA_START + 56)
+#define HID_OFA_SUBST_APPLY (HID_OFA_START + 57)
+#define HID_OFA_SUBST_DELETE (HID_OFA_START + 58)
+#define HID_OFADLG_REGISTRATION (HID_OFA_START + 59)
+#define HID_OFA_TP_DESKTOP (HID_OFA_START + 60)
+#define HID_REGISTRATION_REGISTER (HID_OFA_START + 61)
+#define HID_REGISTRATION_ENABLE_KEY (HID_OFA_START + 62)
+#define HID_AUTOCORR_LANGUAGE (HID_OFA_START + 63)
+#define HID_OFA_MAILHEAD_RCPT_CB (HID_OFA_START + 64)
+#define HID_OFA_SENDMENU_PLAIN (HID_OFA_START + 65)
+#define HID_OFA_SENDMENU_ENCRYPT (HID_OFA_START + 66)
+#define HID_OFA_SENDMENU_SIGN (HID_OFA_START + 67)
+#define HID_OFA_SENDMENU_SIGNANDENCRYPT (HID_OFA_START + 68)
+#define HID_OFADLG_OPTIONS_TREE (HID_OFA_START + 69)
+#define HID_OFADLG_TREELISTBOX (HID_OFA_START + 70)
+#define HID_OFADLG_TREE_GENERAL (HID_OFA_START + 71)
+#define HID_OFADLG_TREE_INTERNET (HID_OFA_START + 72)
+#define HID_OFADLG_TREE_BROWSER (HID_OFA_START + 73)
+#define HID_OFADLG_TREE_TEXT (HID_OFA_START + 74)
+#define HID_OFADLG_TREE_HTML (HID_OFA_START + 75)
+#define HID_OFADLG_TREE_CALC (HID_OFA_START + 76)
+#define HID_OFADLG_TREE_PRESENTATION (HID_OFA_START + 77)
+#define HID_OFADLG_TREE_DRAWING (HID_OFA_START + 78)
+#define HID_OFADLG_TREE_IMAGE (HID_OFA_START + 79)
+#define HID_OFADLG_TREE_FORMULA (HID_OFA_START + 80)
+#define HID_OFAPAGE_AUTOCOMPLETE_OPTIONS (HID_OFA_START + 113)
+#define HID_OFADLG_TREE_CHART (HID_OFA_START + 115)
+#define HID_OFADLG_TREE_BASE (HID_OFA_START + 116)
+#define HID_OFADLG_TREE_FILTER (HID_OFA_START + 117)
+#define HID_OFAPAGE_MSFLTR2_CLB (HID_OFA_START + 118)
+#define HID_OFA_TP_LANGUAGES (HID_OFA_START + 119)
+#define HID_OFADLG_TREE_LANGUAGE (HID_OFA_START + 120)
+#define HID_OFA_CONNPOOL_DRIVERLIST (HID_OFA_START + 121)
+#define UID_OFA_CONNPOOL_DRIVERLIST_BACK (HID_OFA_START + 122)
+#define HID_OFA_TP_HELPERPROG (HID_OFA_START + 123)
+#define HID_OFA_TP_MEMORY (HID_OFA_START + 124)
+*/
+// "Uberlaufkontrolle der HID's
+#define ACT_HID_END HID_OFA_TP_MEMORY
+#if ACT_HID_END > HID_OFA_END
+#error Resource-Ueberlauf bei den HIDs der OFA
+#endif
+
+#define STR_SD_STAROFFICE_XML_DRAW (RID_OFA_START + 245)
+#define STR_SD_STAROFFICE_XML_IMPRESS (RID_OFA_START + 246)
+
+#endif
+
diff --git a/svx/source/src/app.src b/svx/source/src/app.src
new file mode 100644
index 000000000000..f0a78914654d
--- /dev/null
+++ b/svx/source/src/app.src
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/svxids.hrc>
+#include "app.hrc"
+
+ //----------------------------------------------------------------------------
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; };
+
+ErrorBox RID_ERRBOX_MODULENOTINSTALLED
+{
+ Buttons = WB_OK ;
+ Message [ en-US ] = "The action could not be executed. The %PRODUCTNAME program module needed for this action is currently not installed.";
+};
+
+#define IMAGE_ID_LIST\
+ IdList = {\
+ SID_HLINKBAR_LINK; \
+ SID_HLINKBAR_SEARCH; \
+ SID_HLINKBAR_TARGET; \
+ SID_HYPERLINK_DIALOG; \
+ };\
+ IdCount = {\
+ 4;\
+ };
+
+ImageList RID_DEFAULTIMAGELIST_SC
+{
+ Prefix = "sc";
+ MASKCOLOR
+ IMAGE_ID_LIST
+};
+
+ImageList RID_DEFAULTIMAGELIST_LC
+{
+ Prefix = "lc";
+ MASKCOLOR
+ IMAGE_ID_LIST
+};
+
+ImageList RID_DEFAULTIMAGELIST_SCH
+{
+ Prefix = "sch";
+ MASKCOLOR
+ IMAGE_ID_LIST
+};
+
+ImageList RID_DEFAULTIMAGELIST_LCH
+{
+ Prefix = "lch";
+ MASKCOLOR
+ IMAGE_ID_LIST
+};
+
+// Strings ---------------------------------------------------------------
+
+String RID_DESKTOP
+{
+ Text = "%PRODUCTNAME" ;
+};
+
diff --git a/svx/source/src/hidgen.hrc b/svx/source/src/hidgen.hrc
new file mode 100644
index 000000000000..afed9a787862
--- /dev/null
+++ b/svx/source/src/hidgen.hrc
@@ -0,0 +1,33 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#define MN_EDIT 20
+#define MN_VIEW 21
+#define MN_EXTRA 22
+#define MN_WIN 30
+#define MN_HELP 31
+
diff --git a/svx/source/src/makefile.mk b/svx/source/src/makefile.mk
new file mode 100644
index 000000000000..fb96866ca0f7
--- /dev/null
+++ b/svx/source/src/makefile.mk
@@ -0,0 +1,57 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+
+
+PRJ=..$/..$
+
+PRJNAME=svx
+TARGET=ofa
+
+# --- Settings ------------------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+RES1FILELIST=\
+ $(SRS)$/app.srs \
+ $(SOLARCOMMONRESDIR)$/svtools.srs \
+ $(SOLARCOMMONRESDIR)$/sfx.srs \
+ $(SOLARCOMMONRESDIR)$/basic.srs
+
+RESLIB1NAME=$(TARGET)
+RESLIB1IMAGES=$(PRJ)$/res $(PRJ)$/source/src
+RESLIB1SRSFILES=$(RES1FILELIST)
+
+# --- Allgemein -----------------------------------------------------------
+
+SRS1NAME= app
+SRC1FILES= \
+ app.src
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/stbctrls/insctrl.cxx b/svx/source/stbctrls/insctrl.cxx
new file mode 100644
index 000000000000..95175b8163ab
--- /dev/null
+++ b/svx/source/stbctrls/insctrl.cxx
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/shl.hxx>
+#include <vcl/status.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+
+#define _SVX_INSCTRL_CXX
+
+#include <svx/dialogs.hrc>
+
+#include "insctrl.hxx"
+#include <svx/dialmgr.hxx>
+
+#define PAINT_OFFSET 5
+
+SFX_IMPL_STATUSBAR_CONTROL(SvxInsertStatusBarControl, SfxBoolItem);
+
+// class SvxInsertStatusBarControl ---------------------------------------
+
+SvxInsertStatusBarControl::SvxInsertStatusBarControl( USHORT _nSlotId,
+ USHORT _nId,
+ StatusBar& rStb ) :
+
+ SfxStatusBarControl( _nSlotId, _nId, rStb ),
+ bInsert( TRUE )
+{
+ rStb.SetHelpId( _nId, _nSlotId );
+}
+
+// -----------------------------------------------------------------------
+
+SvxInsertStatusBarControl::~SvxInsertStatusBarControl()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxInsertStatusBarControl::StateChanged( USHORT , SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ if ( SFX_ITEM_AVAILABLE != eState )
+ GetStatusBar().SetItemText( GetId(), String() );
+ else
+ {
+ DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
+ SfxBoolItem* pItem = (SfxBoolItem*)pState;
+ bInsert = pItem->GetValue();
+ DrawItemText_Impl();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxInsertStatusBarControl::Click()
+{
+ if ( !GetStatusBar().GetItemText( GetId() ).Len() )
+ return;
+ bInsert = !bInsert;
+ SfxBoolItem aIns( GetSlotId(), bInsert );
+
+ ::com::sun::star::uno::Any a;
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InsertMode" ));
+ aIns.QueryValue( a );
+ aArgs[0].Value = a;
+
+ execute( aArgs );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxInsertStatusBarControl::Paint( const UserDrawEvent& )
+{
+ DrawItemText_Impl();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxInsertStatusBarControl::DrawItemText_Impl()
+{
+ USHORT _nId = RID_SVXSTR_OVERWRITE_TEXT;
+
+ if ( bInsert )
+ _nId = RID_SVXSTR_INSERT_TEXT;
+ GetStatusBar().SetItemText( GetId(), SVX_RESSTR( _nId ) );
+}
+
+ULONG SvxInsertStatusBarControl::GetDefItemWidth(const StatusBar& rStb)
+{
+ long nWidth1 = rStb.GetTextWidth(SVX_RESSTR(RID_SVXSTR_OVERWRITE_TEXT));
+ long nWidth2 = rStb.GetTextWidth(SVX_RESSTR(RID_SVXSTR_INSERT_TEXT));
+
+ if(nWidth1<nWidth2)
+ nWidth1=nWidth2;
+
+ return nWidth1+PAINT_OFFSET;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/stbctrls/makefile.mk b/svx/source/stbctrls/makefile.mk
new file mode 100644
index 000000000000..ac9445d982bb
--- /dev/null
+++ b/svx/source/stbctrls/makefile.mk
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=svxpch
+PROJECTPCHSOURCE=$(PRJ)$/util$/svxpch
+
+PRJNAME=svx
+TARGET=stbctrls
+AUTOSEG=true
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ stbctrls.src
+
+SLOFILES= \
+ $(EXCEPTIONSFILES)
+
+EXCEPTIONSFILES= \
+ $(SLO)$/insctrl.obj \
+ $(SLO)$/modctrl.obj \
+ $(SLO)$/pszctrl.obj \
+ $(SLO)$/selctrl.obj \
+ $(SLO)$/xmlsecctrl.obj \
+ $(SLO)$/zoomctrl.obj \
+ $(SLO)$/zoomsliderctrl.obj
+
+HXX1TARGET=stbctrls
+HXX1EXT= hxx
+HXX1EXCL= -E:*include*
+HXX1DEPN=\
+ $(INC)$/insctrl.hxx \
+ $(INC)$/zoomctrl.hxx \
+ $(INC)$/pszctrl.hxx \
+ $(INC)$/selctrl.hxx \
+ $(INC)$/modctrl.hxx \
+ $(INC)$/xmlsecctrl.hxx \
+ $(INC)$/zoomsliderctrl.hxx \
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/stbctrls/modctrl.cxx b/svx/source/stbctrls/modctrl.cxx
new file mode 100644
index 000000000000..b3d165aa1305
--- /dev/null
+++ b/svx/source/stbctrls/modctrl.cxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include "modctrl.hxx"
+
+#include <vcl/status.hxx>
+#include <vcl/image.hxx>
+#include <svl/eitem.hxx>
+#include <sfx2/app.hxx>
+
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::PropertyValue;
+using ::rtl::OUString;
+
+SFX_IMPL_STATUSBAR_CONTROL(SvxModifyControl, SfxBoolItem);
+
+// class SvxModifyControl ------------------------------------------------
+
+struct SvxModifyControl::ImplData
+{
+ Image maModifiedButton;
+ Image maNonModifiedButton;
+
+ bool mbModified;
+
+ ImplData() :
+ maModifiedButton( SVX_RES(RID_SVXBMP_DOC_MODIFIED_YES) ),
+ maNonModifiedButton( SVX_RES(RID_SVXBMP_DOC_MODIFIED_NO) ),
+ mbModified(false)
+ {
+ }
+};
+
+SvxModifyControl::SvxModifyControl( USHORT _nSlotId,
+ USHORT _nId,
+ StatusBar& rStb ) :
+
+ SfxStatusBarControl( _nSlotId, _nId, rStb ),
+ mpImpl(new ImplData)
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxModifyControl::StateChanged( USHORT, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ if ( SFX_ITEM_AVAILABLE != eState )
+ return;
+
+ DBG_ASSERT( pState->ISA( SfxBoolItem ), "invalid item type" );
+ SfxBoolItem* pItem = (SfxBoolItem*)pState;
+ mpImpl->mbModified = pItem->GetValue();
+
+ if ( GetStatusBar().AreItemsVisible() )
+ GetStatusBar().SetItemData( GetId(), 0 ); // force repaint
+
+ int nResId = mpImpl->mbModified ? RID_SVXSTR_DOC_MODIFIED_YES : RID_SVXSTR_DOC_MODIFIED_NO;
+ GetStatusBar().SetQuickHelpText(GetId(), SVX_RESSTR(nResId));
+}
+
+// -----------------------------------------------------------------------
+
+namespace {
+
+/**
+ * Given a bounding rectangle and an image, determine the top-left position
+ * of the image so that the image would look centered both horizontally and
+ * vertically.
+ *
+ * @param rBoundingRect bounding rectangle
+ * @param rImg image
+ *
+ * @return Point top-left corner of the centered image position
+ */
+Point centerImage(const Rectangle& rBoundingRect, const Image& rImg)
+{
+ Size aImgSize = rImg.GetSizePixel();
+ Size aRectSize = rBoundingRect.GetSize();
+ long nXOffset = (aRectSize.getWidth() - aImgSize.getWidth())/2;
+ long nYOffset = (aRectSize.getHeight() - aImgSize.getHeight())/2;
+ Point aPt = rBoundingRect.TopLeft();
+ aPt += Point(nXOffset, nYOffset);
+ return aPt;
+}
+
+}
+void SvxModifyControl::Paint( const UserDrawEvent& rUsrEvt )
+{
+ const Rectangle aControlRect = getControlRect();
+ OutputDevice* pDev = rUsrEvt.GetDevice();
+ Rectangle aRect = rUsrEvt.GetRect();
+
+ if (mpImpl->mbModified)
+ {
+ Point aPt = centerImage(aRect, mpImpl->maModifiedButton);
+ pDev->DrawImage(aPt, mpImpl->maModifiedButton);
+ }
+ else
+ {
+ Point aPt = centerImage(aRect, mpImpl->maNonModifiedButton);
+ pDev->DrawImage(aPt, mpImpl->maNonModifiedButton);
+ }
+}
+
+void SvxModifyControl::DoubleClick()
+{
+ if (!mpImpl->mbModified)
+ // document not modified. nothing to do here.
+ return;
+
+ Sequence<PropertyValue> aArgs;
+ execute(OUString::createFromAscii(".uno:Save"), aArgs);
+}
+
+ULONG SvxModifyControl::GetDefItemWidth(const StatusBar& rStb)
+{
+ return rStb.GetTextWidth(String::CreateFromAscii("XX"));
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx
new file mode 100644
index 000000000000..6c6171534a6f
--- /dev/null
+++ b/svx/source/stbctrls/pszctrl.cxx
@@ -0,0 +1,436 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <limits.h>
+#include <tools/shl.hxx>
+#include <vcl/status.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/image.hxx>
+#include <svl/stritem.hxx>
+#include <svl/ptitem.hxx>
+#include <svl/itempool.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/module.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <svl/intitem.hxx>
+#define _SVX_PSZCTRL_CXX
+
+#include "pszctrl.hxx"
+
+#define PAINT_OFFSET 5
+
+#include <editeng/sizeitem.hxx>
+#include <svx/dialmgr.hxx>
+#include "dlgutil.hxx"
+#include "stbctrls.h"
+#include "sfx2/module.hxx"
+
+#include <svx/dialogs.hrc>
+#include <unotools/localedatawrapper.hxx>
+#include <comphelper/processfactory.hxx>
+
+// -----------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Funktion, mit der ein metrischer Wert in textueller Darstellung
+ umgewandelt wird.
+
+ nVal ist hier der metrische Wert in der Einheit eUnit.
+
+ [Querverweise]
+
+ <SvxPosSizeStatusBarControl::Paint(const UserDrawEvent&)>
+*/
+
+String SvxPosSizeStatusBarControl::GetMetricStr_Impl( long nVal )
+{
+ // Applikations-Metrik besorgen und setzen
+ FieldUnit eOutUnit = SfxModule::GetCurrentFieldUnit();
+ FieldUnit eInUnit = FUNIT_100TH_MM;
+
+ String sMetric;
+ const sal_Unicode cSep = Application::GetSettings().GetLocaleDataWrapper().getNumDecimalSep().GetChar(0);
+ sal_Int64 nConvVal = MetricField::ConvertValue( nVal * 100, 0L, 0, eInUnit, eOutUnit );
+
+ if ( nConvVal < 0 && ( nConvVal / 100 == 0 ) )
+ sMetric += '-';
+ sMetric += String::CreateFromInt64( nConvVal / 100 );
+
+ if( FUNIT_NONE != eOutUnit )
+ {
+ sMetric += cSep;
+ sal_Int64 nFract = nConvVal % 100;
+
+ if ( nFract < 0 )
+ nFract *= -1;
+ if ( nFract < 10 )
+ sMetric += '0';
+ sMetric += String::CreateFromInt64( nFract );
+ }
+
+ return sMetric;
+}
+
+// -----------------------------------------------------------------------
+
+SFX_IMPL_STATUSBAR_CONTROL(SvxPosSizeStatusBarControl, SvxSizeItem);
+
+// class FunctionPopup_Impl ----------------------------------------------
+
+class FunctionPopup_Impl : public PopupMenu
+{
+public:
+ FunctionPopup_Impl( USHORT nCheck );
+
+ USHORT GetSelected() const { return nSelected; }
+
+private:
+ USHORT nSelected;
+
+ virtual void Select();
+};
+
+// -----------------------------------------------------------------------
+
+FunctionPopup_Impl::FunctionPopup_Impl( USHORT nCheck ) :
+ PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ),
+ nSelected( 0 )
+{
+ if (nCheck)
+ CheckItem( nCheck );
+}
+
+// -----------------------------------------------------------------------
+
+void FunctionPopup_Impl::Select()
+{
+ nSelected = GetCurItemId();
+}
+
+// struct SvxPosSizeStatusBarControl_Impl --------------------------------
+
+struct SvxPosSizeStatusBarControl_Impl
+
+/* [Beschreibung]
+
+ Diese Implementations-Struktur der Klasse SvxPosSizeStatusBarControl
+ dient der Entkopplung von "Anderungen vom exportierten Interface sowie
+ der Verringerung von extern sichtbaren Symbolen.
+
+ Eine Instanz exisitiert pro SvxPosSizeStatusBarControl-Instanz
+ f"ur deren Laufzeit.
+*/
+
+{
+ Point aPos; // g"ultig, wenn eine Position angezeigt wird
+ Size aSize; // g"ultig, wenn eine Gr"o/se angezeigt wird
+ String aStr; // g"ultig, wenn ein Text angezeigt wird
+ BOOL bPos; // show position
+ BOOL bSize; // Gr"o/se anzeigen?
+ BOOL bTable; // Tabellenindex anzeigen?
+ BOOL bHasMenu; // StarCalc Popup-Menue anzeigen?
+ USHORT nFunction; // selektierte StarCalc Funktion
+ Image aPosImage; // Image f"ur die Positionsanzeige
+ Image aSizeImage; // Image f"ur die Gr"o/senanzeige
+};
+
+// class SvxPosSizeStatusBarControl ------------------------------------------
+
+/* [Beschreibung]
+
+ Ctor():
+ Anlegen einer Impl-Klassen-Instanz, Default die Zeitanzeige enablen,
+ Images fu"r die Position und Gro"sse laden.
+*/
+
+SvxPosSizeStatusBarControl::SvxPosSizeStatusBarControl( USHORT _nSlotId,
+ USHORT _nId,
+ StatusBar& rStb ) :
+ SfxStatusBarControl( _nSlotId, _nId, rStb ),
+ pImp( new SvxPosSizeStatusBarControl_Impl )
+{
+ pImp->bPos = FALSE;
+ pImp->bSize = FALSE;
+ pImp->bTable = FALSE;
+ pImp->bHasMenu = FALSE;
+ pImp->nFunction = 0;
+ pImp->aPosImage = Image( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) );
+ pImp->aSizeImage = Image( ResId( RID_SVXBMP_SIZE, DIALOG_MGR() ) );
+
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Position" )));
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StateTableCell" )));
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StatusBarFunc" )));
+}
+
+// -----------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Dtor():
+ Pointer auf die Impl-Klasse lo"schen, damit der Timer gestoppt wird.
+*/
+
+SvxPosSizeStatusBarControl::~SvxPosSizeStatusBarControl()
+{
+ delete pImp;
+}
+
+// -----------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ SID_PSZ_FUNCTION aktiviert das Popup-Menue fuer Calc, ansonsten:
+
+ Statusbenachrichtigung;
+ Je nach Item-Typ wird eine bestimmte Anzeige enabled, die anderen disabled.
+
+ NULL/Void SfxPointItem SvxSizeItem SfxStringItem
+ ------------------------------------------------------------------------
+ Zeit TRUE FALSE FALSE FALSE
+ Position FALSE FALSE
+ Gro"sse FALSE TRUE FALSE
+ Text FALSE FALSE TRUE
+
+ Ein anderes Item bewirkt einen Assert, die Zeitanzeige wird enabled.
+*/
+
+void SvxPosSizeStatusBarControl::StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ // da Kombi-Controller, immer die aktuelle Id als HelpId setzen
+ // gecachten HelpText vorher l"oschen
+ GetStatusBar().SetHelpText( GetId(), String() );
+ GetStatusBar().SetHelpId( GetId(), nSID );
+
+ if ( nSID == SID_PSZ_FUNCTION )
+ {
+ if ( eState == SFX_ITEM_AVAILABLE )
+ {
+ pImp->bHasMenu = TRUE;
+ if ( pState && pState->ISA(SfxUInt16Item) )
+ pImp->nFunction = ((const SfxUInt16Item*)pState)->GetValue();
+ }
+ else
+ pImp->bHasMenu = FALSE;
+ }
+ else if ( SFX_ITEM_AVAILABLE != eState )
+ {
+ // #i34458# don't switch to empty display before an empty state was
+ // notified for all display types
+
+ if ( nSID == SID_TABLE_CELL )
+ pImp->bTable = FALSE;
+ else if ( nSID == SID_ATTR_POSITION )
+ pImp->bPos = FALSE;
+ else if ( nSID == GetSlotId() ) // controller is registered for SID_ATTR_SIZE
+ pImp->bSize = FALSE;
+ else
+ {
+ DBG_ERRORFILE("unknown slot id");
+ }
+ }
+ else if ( pState->ISA( SfxPointItem ) )
+ {
+ // Position anzeigen
+ pImp->aPos = ( (SfxPointItem*)pState )->GetValue();
+ pImp->bPos = TRUE;
+ pImp->bTable = FALSE;
+ }
+ else if ( pState->ISA( SvxSizeItem ) )
+ {
+ // Groesse anzeigen
+ pImp->aSize = ( (SvxSizeItem*)pState )->GetSize();
+ pImp->bSize = TRUE;
+ pImp->bTable = FALSE;
+ }
+ else if ( pState->ISA( SfxStringItem ) )
+ {
+ // String anzeigen (Tabellen-Zelle oder anderes)
+ pImp->aStr = ( (SfxStringItem*)pState )->GetValue();
+ pImp->bTable = TRUE;
+ pImp->bPos = FALSE;
+ pImp->bSize = FALSE;
+ }
+ else
+ {
+ DBG_ERRORFILE( "invalid item type" );
+ // trotzdem Datum und Zeit anzeigen
+ pImp->bPos = FALSE;
+ pImp->bSize = FALSE;
+ pImp->bTable = FALSE;
+ }
+
+ if ( GetStatusBar().AreItemsVisible() )
+ GetStatusBar().SetItemData( GetId(), 0 );
+
+ // nur Strings auch als Text an der StatusBar setzen, damit Tip-Hilfe
+ // funktioniert, wenn der Text zu lang ist.
+ String aText;
+ if ( pImp->bTable )
+ aText = pImp->aStr;
+ GetStatusBar().SetItemText( GetId(), aText );
+}
+
+// -----------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Popup-Menue ausfuehren, wenn per Status enabled
+*/
+
+void SvxPosSizeStatusBarControl::Command( const CommandEvent& rCEvt )
+{
+ if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && pImp->bHasMenu )
+ {
+ USHORT nSelect = pImp->nFunction;
+ if (!nSelect)
+ nSelect = PSZ_FUNC_NONE;
+ FunctionPopup_Impl aMenu( nSelect );
+ if ( aMenu.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel() ) )
+ {
+ nSelect = aMenu.GetSelected();
+ if (nSelect)
+ {
+ if (nSelect == PSZ_FUNC_NONE)
+ nSelect = 0;
+
+ ::com::sun::star::uno::Any a;
+ SfxUInt16Item aItem( SID_PSZ_FUNCTION, nSelect );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusBarFunc" ));
+ aItem.QueryValue( a );
+ aArgs[0].Value = a;
+
+ execute( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StatusBarFunc" )), aArgs );
+// GetBindings().GetDispatcher()->Execute( SID_PSZ_FUNCTION, SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+ }
+ }
+ else
+ SfxStatusBarControl::Command( rCEvt );
+}
+
+// -----------------------------------------------------------------------
+
+/* [Beschreibung]
+
+ Je nach enableden Anzeigentyp, wird der Wert angezeigt. Vorher wird
+ das Rectangle u"bermalt (gelo"scht).
+*/
+
+void SvxPosSizeStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
+{
+ OutputDevice* pDev = rUsrEvt.GetDevice();
+ DBG_ASSERT( pDev, "no OutputDevice on UserDrawEvent" );
+ const Rectangle& rRect = rUsrEvt.GetRect();
+ StatusBar& rBar = GetStatusBar();
+ Point aItemPos = rBar.GetItemTextPos( GetId() );
+ Color aOldLineColor = pDev->GetLineColor();
+ Color aOldFillColor = pDev->GetFillColor();
+ pDev->SetLineColor();
+ pDev->SetFillColor( pDev->GetBackground().GetColor() );
+
+ if ( pImp->bPos || pImp->bSize )
+ {
+ // Position fuer Size-Anzeige berechnen
+ long nSizePosX =
+ rRect.Left() + rRect.GetWidth() / 2 + PAINT_OFFSET;
+ // Position zeichnen
+ Point aPnt = rRect.TopLeft();
+ aPnt.Y() = aItemPos.Y();
+ aPnt.X() += PAINT_OFFSET;
+ pDev->DrawImage( aPnt, pImp->aPosImage );
+ aPnt.X() += pImp->aPosImage.GetSizePixel().Width();
+ aPnt.X() += PAINT_OFFSET;
+ String aStr = GetMetricStr_Impl( pImp->aPos.X());
+ aStr.AppendAscii(" / ");
+ aStr += GetMetricStr_Impl( pImp->aPos.Y());
+ pDev->DrawRect(
+ Rectangle( aPnt, Point( nSizePosX, rRect.Bottom() ) ) );
+ pDev->DrawText( aPnt, aStr );
+
+ // falls verf"ugbar, Gr"osse zeichnen
+ aPnt.X() = nSizePosX;
+
+ if ( pImp->bSize )
+ {
+ pDev->DrawImage( aPnt, pImp->aSizeImage );
+ aPnt.X() += pImp->aSizeImage.GetSizePixel().Width();
+ Point aDrwPnt = aPnt;
+ aPnt.X() += PAINT_OFFSET;
+ aStr = GetMetricStr_Impl( pImp->aSize.Width() );
+ aStr.AppendAscii(" x ");
+ aStr += GetMetricStr_Impl( pImp->aSize.Height() );
+ pDev->DrawRect( Rectangle( aDrwPnt, rRect.BottomRight() ) );
+ pDev->DrawText( aPnt, aStr );
+ }
+ else
+ pDev->DrawRect( Rectangle( aPnt, rRect.BottomRight() ) );
+ }
+ else if ( pImp->bTable )
+ {
+ pDev->DrawRect( rRect );
+ pDev->DrawText( Point(
+ rRect.Left() + rRect.GetWidth() / 2 - pDev->GetTextWidth( pImp->aStr ) / 2,
+ aItemPos.Y() ), pImp->aStr );
+ }
+ else
+ {
+ // Empty display if neither size nor table position are available.
+ // Date/Time are no longer used (#65302#).
+ pDev->DrawRect( rRect );
+ }
+
+ pDev->SetLineColor( aOldLineColor );
+ pDev->SetFillColor( aOldFillColor );
+}
+
+// -----------------------------------------------------------------------
+
+ULONG SvxPosSizeStatusBarControl::GetDefItemWidth(const StatusBar& rStb)
+{
+ Image aTmpPosImage( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) );
+ Image aTmpSizeImage( ResId( RID_SVXBMP_SIZE, DIALOG_MGR() ) );
+
+ ULONG nWidth=PAINT_OFFSET+aTmpPosImage.GetSizePixel().Width();
+ nWidth+=PAINT_OFFSET+aTmpSizeImage.GetSizePixel().Width();
+ nWidth+=2*(PAINT_OFFSET+rStb.GetTextWidth(String::CreateFromAscii("XXXX,XX / XXXX,XX")));
+
+ return nWidth;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/stbctrls/selctrl.cxx b/svx/source/stbctrls/selctrl.cxx
new file mode 100644
index 000000000000..0b7e1851fb25
--- /dev/null
+++ b/svx/source/stbctrls/selctrl.cxx
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/shl.hxx>
+#include <vcl/status.hxx>
+#include <svl/intitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <tools/urlobj.hxx>
+
+#define _SVX_SELCTRL_CXX
+
+#include "selctrl.hxx"
+#include <svx/dialmgr.hxx>
+
+#include <svx/dialogs.hrc>
+
+#define PAINT_OFFSET 5
+
+SFX_IMPL_STATUSBAR_CONTROL(SvxSelectionModeControl, SfxUInt16Item);
+
+// class SvxSelectionModeControl -----------------------------------------
+
+SvxSelectionModeControl::SvxSelectionModeControl( USHORT _nSlotId,
+ USHORT _nId,
+ StatusBar& rStb ) :
+ SfxStatusBarControl( _nSlotId, _nId, rStb ),
+ nState( 0 )
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSelectionModeControl::StateChanged( USHORT, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ if ( SFX_ITEM_AVAILABLE != eState )
+ GetStatusBar().SetItemText( GetId(), String() );
+ else
+ {
+ DBG_ASSERT( pState->ISA( SfxUInt16Item ), "invalid item type" );
+ SfxUInt16Item* pItem = (SfxUInt16Item*)pState;
+ nState = pItem->GetValue();
+ DrawItemText_Impl();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSelectionModeControl::Click()
+{
+ if ( !GetStatusBar().GetItemText( GetId() ).Len() )
+ return;
+ nState++;
+ if ( nState > 3 )
+ nState = 0;
+
+ ::com::sun::star::uno::Any a;
+ SfxUInt16Item aState( GetSlotId(), nState );
+ INetURLObject aObj( m_aCommandURL );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = aObj.GetURLPath();
+ aState.QueryValue( a );
+ aArgs[0].Value = a;
+
+ execute( aArgs );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSelectionModeControl::Paint( const UserDrawEvent& )
+{
+ DrawItemText_Impl();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSelectionModeControl::DrawItemText_Impl()
+{
+ String sTxt;
+ USHORT _nId = 0;
+
+ switch ( nState )
+ {
+ case 0:
+ _nId = RID_SVXSTR_SELMODE_STD;
+ break;
+ case 1:
+ _nId = RID_SVXSTR_SELMODE_ER;
+ break;
+ case 2:
+ _nId = RID_SVXSTR_SELMODE_ERG;
+ break;
+ case 3:
+ _nId = RID_SVXSTR_SELMODE_BLK;
+ break;
+ default: DBG_ERROR( "invalid selection mode!" );
+ }
+
+ if ( _nId )
+ sTxt = SVX_RESSTR( _nId );
+ GetStatusBar().SetItemText( GetId(), sTxt );
+}
+
+ULONG SvxSelectionModeControl::GetDefItemWidth(const StatusBar& rStb)
+{
+ long nWidth1 = rStb.GetTextWidth(SVX_RESSTR(RID_SVXSTR_SELMODE_STD));
+ long nWidth2 = rStb.GetTextWidth(SVX_RESSTR(RID_SVXSTR_SELMODE_ER));
+ long nWidth3 = rStb.GetTextWidth(SVX_RESSTR(RID_SVXSTR_SELMODE_ERG));
+ long nWidth4 = rStb.GetTextWidth(SVX_RESSTR(RID_SVXSTR_SELMODE_BLK));
+
+ if(nWidth1<nWidth2)
+ nWidth1=nWidth2;
+
+ if(nWidth1<nWidth3)
+ nWidth1=nWidth3;
+
+ if(nWidth1<nWidth4)
+ nWidth1=nWidth4;
+
+ return nWidth1+PAINT_OFFSET;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/stbctrls/stbctrls.h b/svx/source/stbctrls/stbctrls.h
new file mode 100644
index 000000000000..23eb8b0e3a66
--- /dev/null
+++ b/svx/source/stbctrls/stbctrls.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_STBCTRLS_H
+#define _SVX_STBCTRLS_H
+
+// defines ------------------------------------------------------------------
+
+#define ZOOM_200 1
+#define ZOOM_150 2
+#define ZOOM_100 3
+#define ZOOM_75 4
+#define ZOOM_50 5
+
+#define ZOOM_OPTIMAL 6
+#define ZOOM_PAGE_WIDTH 7
+#define ZOOM_WHOLE_PAGE 8
+
+// IDs wie SUBTOTAL_FUNC im Calc
+
+#define PSZ_FUNC_AVG 1
+#define PSZ_FUNC_COUNT2 3
+#define PSZ_FUNC_COUNT 2
+#define PSZ_FUNC_MAX 4
+#define PSZ_FUNC_MIN 5
+#define PSZ_FUNC_SUM 9
+#define PSZ_FUNC_NONE 16
+
+#define XMLSEC_CALL 1
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/stbctrls/stbctrls.src b/svx/source/stbctrls/stbctrls.src
new file mode 100644
index 000000000000..80f150a61599
--- /dev/null
+++ b/svx/source/stbctrls/stbctrls.src
@@ -0,0 +1,353 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include <svx/dialogs.hrc>
+#include "helpid.hrc"
+#include "stbctrls.h"
+ // pragma ----------------------------------------------------------------
+
+ // Strings ---------------------------------------------------------------
+String RID_SVXSTR_INSERT_TEXT
+{
+ // 'Einf"ugen' bzw. 'Insert' abgek"urzt auf h"ochstens 5 Zeichen
+ Text [ en-US ] = "INSRT" ;
+};
+String RID_SVXSTR_OVERWRITE_TEXT
+{
+ // '"Uberschreiben' bzw. 'Overwrite' abgek"urzt auf h"ochstens 5 Zeichen
+ Text [ en-US ] = "OVER" ;
+};
+String RID_SVXSTR_SELMODE_STD
+{
+ // 'Standard' abgek"urzt auf h"ochstens 3 Zeichen
+ Text [ en-US ] = "STD" ;
+};
+String RID_SVXSTR_SELMODE_ER
+{
+ // 'Erweitert' bzw. 'Extended' abgek"urzt auf h"ochstens 3 Zeichen
+ Text [ en-US ] = "EXT" ;
+};
+String RID_SVXSTR_SELMODE_ERG
+{
+ // 'Erg"anzend' bzw. 'Added' abgek"urzt auf h"ochstens 3 Zeichen
+ Text [ en-US ] = "ADD" ;
+};
+
+String RID_SVXSTR_SELMODE_BLK
+{
+ // 'Block' shortened to max. 3 chararcters
+ Text [ en-US ] = "BLK" ;
+ Text [ x-comment ] = " ";
+};
+
+String RID_SVXSTR_XMLSEC_SIG_OK
+{
+ Text [ en-US ] = "Digital Signature: The document signature is OK.";
+};
+
+String RID_SVXSTR_XMLSEC_SIG_OK_NO_VERIFY
+{
+ Text [ en-US ] = "Digital Signature: The document signature is OK, but the certificates could not be validated.";
+};
+
+String RID_SVXSTR_XMLSEC_SIG_NOT_OK
+{
+ Text [ en-US ] = "Digital Signature: The document signature does not match the document content. We strongly recommend you to do not trust this document.";
+};
+
+String RID_SVXSTR_XMLSEC_NO_SIG
+{
+ Text [ en-US ] = "Digital Signature: The document is not signed.";
+};
+
+String RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG
+{
+ Text [ en-US ] = "Digital Signature: The document signature and the certificate are OK, but not all parts of the document are signed.";
+};
+
+String RID_SVXSTR_DOC_MODIFIED_YES
+{
+ Text [ en-US ] = "The document has been modified. Double-click to save the document.";
+};
+
+String RID_SVXSTR_DOC_MODIFIED_NO
+{
+ Text [ en-US ] = "The document has not been modified since the last save.";
+};
+
+ // PopupMenu -------------------------------------------------------------
+Menu RID_SVXMNU_ZOOM
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = ZOOM_200 ;
+ HelpId = HID_MNU_ZOOM_200 ;
+ Text = "200%" ;
+ };
+ MenuItem
+ {
+ Identifier = ZOOM_150 ;
+ HelpId = HID_MNU_ZOOM_150 ;
+ Text = "150%" ;
+ };
+ MenuItem
+ {
+ Identifier = ZOOM_100 ;
+ HelpId = HID_MNU_ZOOM_100 ;
+ Text = "100%" ;
+ };
+ MenuItem
+ {
+ Identifier = ZOOM_75 ;
+ HelpId = HID_MNU_ZOOM_75 ;
+ Text = "75%" ;
+ };
+ MenuItem
+ {
+ Identifier = ZOOM_50 ;
+ HelpId = HID_MNU_ZOOM_50 ;
+ Text = "50%" ;
+ };
+ MenuItem
+ {
+ Identifier = ZOOM_OPTIMAL ;
+ HelpId = HID_MNU_ZOOM_OPTIMAL ;
+ Text [ en-US ] = "Optimal" ;
+ };
+ MenuItem
+ {
+ Identifier = ZOOM_PAGE_WIDTH ;
+ HelpId = HID_MNU_ZOOM_PAGE_WIDTH ;
+ Text [ en-US ] = "Page Width" ;
+ };
+ MenuItem
+ {
+ Identifier = ZOOM_WHOLE_PAGE ;
+ HelpId = HID_MNU_ZOOM_WHOLE_PAGE ;
+ Text [ en-US ] = "Entire Page" ;
+ };
+ };
+};
+ // Funktionsauswahl auf dem SvxPosSizeStatusBarControl fuer Calc
+Menu RID_SVXMNU_PSZ_FUNC
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = PSZ_FUNC_AVG ;
+ HelpId = HID_MNU_FUNC_AVG ;
+ Text [ en-US ] = "Average" ;
+ };
+ MenuItem
+ {
+ Identifier = PSZ_FUNC_COUNT2 ;
+ HelpId = HID_MNU_FUNC_COUNT2 ;
+ Text [ en-US ] = "CountA" ;
+ };
+ MenuItem
+ {
+ Identifier = PSZ_FUNC_COUNT ;
+ HelpId = HID_MNU_FUNC_COUNT ;
+ Text [ en-US ] = "Count" ;
+ };
+ MenuItem
+ {
+ Identifier = PSZ_FUNC_MAX ;
+ HelpId = HID_MNU_FUNC_MAX ;
+ Text [ en-US ] = "Maximum" ;
+ };
+ MenuItem
+ {
+ Identifier = PSZ_FUNC_MIN ;
+ HelpId = HID_MNU_FUNC_MIN ;
+ Text [ en-US ] = "Minimum" ;
+ };
+ MenuItem
+ {
+ Identifier = PSZ_FUNC_SUM ;
+ HelpId = HID_MNU_FUNC_SUM ;
+ Text [ en-US ] = "Sum" ;
+ };
+ MenuItem
+ {
+ Identifier = PSZ_FUNC_NONE ;
+ HelpId = HID_MNU_FUNC_NONE ;
+ Text [ en-US ] = "None" ;
+ };
+ };
+};
+Menu RID_SVXMNU_XMLSECSTATBAR
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = XMLSEC_CALL ;
+ HelpId = HID_XMLSEC_CALL ;
+ Text [ en-US ] = "Digital Signatures..." ;
+ };
+ };
+};
+
+// Images ----------------------------------------------------------------
+
+#define STD_MASKCOLOR Color{Red=0xffff;Green=0x0000;Blue=0xffff;}
+
+Image RID_SVXBMP_POSITION
+{
+ ImageBitmap = Bitmap
+ {
+ File = "sc10223.bmp" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SIZE
+{
+ ImageBitmap = Bitmap
+ {
+ File = "sc10224.bmp" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SIGNET
+{
+ ImageBitmap = Bitmap
+ {
+ File = "signet_11x16.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SIGNET_BROKEN
+{
+ ImageBitmap = Bitmap
+ {
+ File = "caution_11x16.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SIGNET_NOTVALIDATED
+{
+ ImageBitmap = Bitmap
+ {
+ File = "notcertificate_16.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SIGNET_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "signet_11x16_h.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SIGNET_BROKEN_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "caution_11x16_h.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SIGNET_NOTVALIDATED_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "notcertificate_16_h.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+
+
+Image RID_SVXBMP_SLIDERBUTTON
+{
+ ImageBitmap = Bitmap
+ {
+ File = "navigationball_10.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SLIDERDECREASE
+{
+ ImageBitmap = Bitmap
+ {
+ File = "slidezoomout_11.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SLIDERINCREASE
+{
+ ImageBitmap = Bitmap
+ {
+ File = "slidezoomin_11.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SLIDERBUTTON_HC
+{
+ ImageBitmap = Bitmap
+ {
+ File = "navigationball_10_h.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SLIDERDECREASE_HC
+{
+ ImageBitmap = Bitmap
+ {
+ File = "slidezoomout_11_h.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_SLIDERINCREASE_HC
+{
+ ImageBitmap = Bitmap
+ {
+ File = "slidezoomin_11_h.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+
+Image RID_SVXBMP_DOC_MODIFIED_YES
+{
+ ImageBitmap = Bitmap
+ {
+ File = "doc_modified_yes_14.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+Image RID_SVXBMP_DOC_MODIFIED_NO
+{
+ ImageBitmap = Bitmap
+ {
+ File = "doc_modified_no_14.png" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+};
diff --git a/svx/source/stbctrls/xmlsecctrl.cxx b/svx/source/stbctrls/xmlsecctrl.cxx
new file mode 100644
index 000000000000..402a589c853d
--- /dev/null
+++ b/svx/source/stbctrls/xmlsecctrl.cxx
@@ -0,0 +1,191 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <tools/shl.hxx>
+#include <vcl/status.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/image.hxx>
+#include <sfx2/signaturestate.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/module.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/sfxsids.hrc>
+
+#include <svl/intitem.hxx>
+
+#include <svl/eitem.hxx>
+
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include "xmlsecctrl.hxx"
+#include <tools/urlobj.hxx>
+
+#define PAINT_OFFSET 5
+
+
+SFX_IMPL_STATUSBAR_CONTROL( XmlSecStatusBarControl, SfxUInt16Item );
+
+struct XmlSecStatusBarControl::XmlSecStatusBarControl_Impl
+{
+ Point maPos;
+ Size maSize;
+ UINT16 mnState;
+ Image maImage;
+ Image maImageBroken;
+ Image maImageNotValidated;
+};
+
+
+XmlSecStatusBarControl::XmlSecStatusBarControl( USHORT _nSlotId, USHORT _nId, StatusBar& _rStb )
+ :SfxStatusBarControl( _nSlotId, _nId, _rStb )
+
+ ,mpImpl( new XmlSecStatusBarControl_Impl )
+{
+ mpImpl->mnState = (UINT16)SIGNATURESTATE_UNKNOWN;
+
+ sal_Bool bHC = GetStatusBar().GetSettings().GetStyleSettings().GetHighContrastMode();
+ mpImpl->maImage = Image( SVX_RES( bHC ? RID_SVXBMP_SIGNET_H : RID_SVXBMP_SIGNET ) );
+ mpImpl->maImageBroken =
+ Image( SVX_RES( bHC ? RID_SVXBMP_SIGNET_BROKEN_H : RID_SVXBMP_SIGNET_BROKEN ) );
+ mpImpl->maImageNotValidated =
+ Image( SVX_RES( bHC ? RID_SVXBMP_SIGNET_NOTVALIDATED_H : RID_SVXBMP_SIGNET_NOTVALIDATED ) );
+}
+
+XmlSecStatusBarControl::~XmlSecStatusBarControl()
+{
+ delete mpImpl;
+}
+
+void XmlSecStatusBarControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ GetStatusBar().SetHelpText( GetId(), String() );// necessary ?
+
+ GetStatusBar().SetHelpId( GetId(), nSID ); // necessary ?
+
+ if( SFX_ITEM_AVAILABLE != eState )
+ {
+ mpImpl->mnState = (UINT16)SIGNATURESTATE_UNKNOWN;
+ }
+ else if( pState->ISA( SfxUInt16Item ) )
+ {
+// mpImpl->mbSigned = ( ( SfxUInt16Item* ) pState )->GetValue() == 1 /* SIGNED*/ ;
+ mpImpl->mnState = ( ( SfxUInt16Item* ) pState )->GetValue();
+ }
+ else
+ {
+ DBG_ERRORFILE( "+XmlSecStatusBarControl::StateChanged(): invalid item type" );
+ mpImpl->mnState = (UINT16)SIGNATURESTATE_UNKNOWN;
+ }
+
+ if( GetStatusBar().AreItemsVisible() ) // necessary ?
+ GetStatusBar().SetItemData( GetId(), 0 );
+
+ GetStatusBar().SetItemText( GetId(), String() ); // necessary ?
+
+ USHORT nResId = RID_SVXSTR_XMLSEC_NO_SIG;
+ if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK )
+ nResId = RID_SVXSTR_XMLSEC_SIG_OK;
+ else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN )
+ nResId = RID_SVXSTR_XMLSEC_SIG_NOT_OK;
+ else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED )
+ nResId = RID_SVXSTR_XMLSEC_SIG_OK_NO_VERIFY;
+ else if ( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK )
+ nResId = RID_SVXSTR_XMLSEC_SIG_CERT_OK_PARTIAL_SIG;
+
+ GetStatusBar().SetQuickHelpText( GetId(), SVX_RESSTR( nResId ) );
+}
+
+void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt )
+{
+ if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
+ {
+ PopupMenu aPopupMenu( ResId( RID_SVXMNU_XMLSECSTATBAR, DIALOG_MGR() ) );
+ if( aPopupMenu.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel() ) )
+ {
+ ::com::sun::star::uno::Any a;
+ SfxUInt16Item aState( GetSlotId(), 0 );
+ INetURLObject aObj( m_aCommandURL );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = aObj.GetURLPath();
+ aState.QueryValue( a );
+ aArgs[0].Value = a;
+
+ execute( aArgs );
+ }
+ }
+ else
+ SfxStatusBarControl::Command( rCEvt );
+}
+
+void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
+{
+ OutputDevice* pDev = rUsrEvt.GetDevice();
+ DBG_ASSERT( pDev, "-XmlSecStatusBarControl::Paint(): no Output Device... this will lead to nirvana..." );
+ Rectangle aRect = rUsrEvt.GetRect();
+ StatusBar& rBar = GetStatusBar();
+ Point aItemPos = rBar.GetItemTextPos( GetId() );
+ Color aOldLineColor = pDev->GetLineColor();
+ Color aOldFillColor = pDev->GetFillColor();
+
+ pDev->SetLineColor();
+ pDev->SetFillColor( pDev->GetBackground().GetColor() );
+
+ if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_OK )
+ {
+ ++aRect.Top();
+ pDev->DrawImage( aRect.TopLeft(), mpImpl->maImage );
+ }
+ else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_BROKEN )
+ {
+ ++aRect.Top();
+ pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageBroken );
+ }
+ else if( mpImpl->mnState == SIGNATURESTATE_SIGNATURES_NOTVALIDATED
+ || mpImpl->mnState == SIGNATURESTATE_SIGNATURES_PARTIAL_OK)
+ {
+ ++aRect.Top();
+ pDev->DrawImage( aRect.TopLeft(), mpImpl->maImageNotValidated );
+ }
+ else
+ pDev->DrawRect( aRect );
+
+ pDev->SetLineColor( aOldLineColor );
+ pDev->SetFillColor( aOldFillColor );
+}
+
+long XmlSecStatusBarControl::GetDefItemWidth( StatusBar& )
+{
+ return 16;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/stbctrls/zoomctrl.cxx b/svx/source/stbctrls/zoomctrl.cxx
new file mode 100644
index 000000000000..32a58746ec15
--- /dev/null
+++ b/svx/source/stbctrls/zoomctrl.cxx
@@ -0,0 +1,220 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/shl.hxx>
+#include <vcl/status.hxx>
+#include <vcl/menu.hxx>
+#include <sfx2/dispatch.hxx>
+#include <tools/urlobj.hxx>
+
+#include <svx/dialogs.hrc>
+
+#include "zoomctrl.hxx"
+#include <svx/zoomitem.hxx>
+#include "stbctrls.h"
+#include <svx/dialmgr.hxx>
+
+SFX_IMPL_STATUSBAR_CONTROL(SvxZoomStatusBarControl,SvxZoomItem);
+
+// class ZoomPopup_Impl --------------------------------------------------
+
+class ZoomPopup_Impl : public PopupMenu
+{
+public:
+ ZoomPopup_Impl( USHORT nZ, USHORT nValueSet );
+
+ USHORT GetZoom() const { return nZoom; }
+ USHORT GetCurId() const { return nCurId; }
+
+private:
+ USHORT nZoom;
+ USHORT nCurId;
+
+ virtual void Select();
+};
+
+// -----------------------------------------------------------------------
+
+ZoomPopup_Impl::ZoomPopup_Impl( USHORT nZ, USHORT nValueSet )
+
+: PopupMenu( ResId( RID_SVXMNU_ZOOM, DIALOG_MGR() ) ),
+
+ nZoom( nZ )
+{
+ static USHORT aTable[] =
+ {
+ SVX_ZOOM_ENABLE_50, ZOOM_50,
+ SVX_ZOOM_ENABLE_100, ZOOM_100,
+ SVX_ZOOM_ENABLE_150, ZOOM_150,
+ SVX_ZOOM_ENABLE_200, ZOOM_200,
+ SVX_ZOOM_ENABLE_OPTIMAL, ZOOM_OPTIMAL,
+ SVX_ZOOM_ENABLE_WHOLEPAGE, ZOOM_WHOLE_PAGE,
+ SVX_ZOOM_ENABLE_PAGEWIDTH, ZOOM_PAGE_WIDTH
+ };
+
+ for ( USHORT nPos = 0; nPos < sizeof(aTable) / sizeof(USHORT); nPos += 2 )
+ if ( ( aTable[nPos] != ( aTable[nPos] & nValueSet ) ) )
+ EnableItem( aTable[nPos+1], FALSE );
+}
+
+// -----------------------------------------------------------------------
+
+void ZoomPopup_Impl::Select()
+{
+ nCurId = GetCurItemId();
+
+ switch ( nCurId )
+ {
+ case ZOOM_200: nZoom = 200; break;
+ case ZOOM_150: nZoom = 150; break;
+ case ZOOM_100: nZoom = 100; break;
+ case ZOOM_75: nZoom = 75; break;
+ case ZOOM_50: nZoom = 50; break;
+
+ case ZOOM_OPTIMAL:
+ case ZOOM_PAGE_WIDTH:
+ case ZOOM_WHOLE_PAGE: nZoom = 0; break;
+
+ }
+}
+
+// class SvxZoomStatusBarControl ------------------------------------------
+
+SvxZoomStatusBarControl::SvxZoomStatusBarControl( USHORT _nSlotId,
+ USHORT _nId,
+ StatusBar& rStb ) :
+
+ SfxStatusBarControl( _nSlotId, _nId, rStb ),
+ nZoom( 100 ),
+ nValueSet( SVX_ZOOM_ENABLE_ALL )
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxZoomStatusBarControl::StateChanged( USHORT, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ if( SFX_ITEM_AVAILABLE != eState )
+ {
+ GetStatusBar().SetItemText( GetId(), String() );
+ nValueSet = 0;
+ }
+ else if ( pState->ISA( SfxUInt16Item) )
+ {
+ const SfxUInt16Item* pItem = (const SfxUInt16Item*)pState;
+ nZoom = pItem->GetValue();
+ String aStr( String::CreateFromInt32(nZoom) );
+ aStr += '%';
+ GetStatusBar().SetItemText( GetId(), aStr );
+
+ if ( pState->ISA(SvxZoomItem) )
+ {
+ nValueSet = ((const SvxZoomItem*)pState)->GetValueSet();
+/*!!!
+ SvxZoomType eType = ((const SvxZoomItem*)pState)->GetType();
+
+ switch ( eType )
+ {
+ case SVX_ZOOM_OPTIMAL:
+ GetStatusBar().SetItemText( GetId(), "Opt." );
+ break;
+ case SVX_ZOOM_WHOLEPAGE:
+ GetStatusBar().SetItemText( GetId(), "Page" );
+ break;
+ case SVX_ZOOM_PAGEWIDTH:
+ GetStatusBar().SetItemText( GetId(), "Width" );
+ break;
+ }
+*/
+ }
+ else
+ {
+ DBG_WARNING( "use SfxZoomItem for SID_ATTR_ZOOM" );
+ nValueSet = SVX_ZOOM_ENABLE_ALL;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxZoomStatusBarControl::Paint( const UserDrawEvent& )
+{
+ String aStr( String::CreateFromInt32( nZoom ));
+ aStr += '%';
+ GetStatusBar().SetItemText( GetId(), aStr );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxZoomStatusBarControl::Command( const CommandEvent& rCEvt )
+{
+ if ( COMMAND_CONTEXTMENU & rCEvt.GetCommand() && 0 != nValueSet )
+ {
+ CaptureMouse();
+ ZoomPopup_Impl aPop( nZoom, nValueSet );
+ StatusBar& rStatusbar = GetStatusBar();
+
+ if ( aPop.Execute( &rStatusbar, rCEvt.GetMousePosPixel() ) && ( nZoom != aPop.GetZoom() || !nZoom ) )
+ {
+ nZoom = aPop.GetZoom();
+ SvxZoomItem aZoom( SVX_ZOOM_PERCENT, nZoom, GetId() );
+
+ switch( aPop.GetCurId() )
+ {
+ case ZOOM_OPTIMAL: aZoom.SetType( SVX_ZOOM_OPTIMAL ); break;
+ case ZOOM_PAGE_WIDTH: aZoom.SetType( SVX_ZOOM_PAGEWIDTH ); break;
+ case ZOOM_WHOLE_PAGE: aZoom.SetType( SVX_ZOOM_WHOLEPAGE ); break;
+ }
+
+ ::com::sun::star::uno::Any a;
+ INetURLObject aObj( m_aCommandURL );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = aObj.GetURLPath();
+ aZoom.QueryValue( a );
+ aArgs[0].Value = a;
+
+ execute( aArgs );
+ }
+ ReleaseMouse();
+ }
+ else
+ SfxStatusBarControl::Command( rCEvt );
+}
+
+ULONG SvxZoomStatusBarControl::GetDefItemWidth(const StatusBar& rStb)
+{
+ long nWidth1 = rStb.GetTextWidth(String::CreateFromAscii("XXXXX%"));
+ return nWidth1;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/stbctrls/zoomsliderctrl.cxx b/svx/source/stbctrls/zoomsliderctrl.cxx
new file mode 100644
index 000000000000..bf1e93046b25
--- /dev/null
+++ b/svx/source/stbctrls/zoomsliderctrl.cxx
@@ -0,0 +1,447 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <svx/zoomsliderctrl.hxx>
+#include <vcl/status.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/image.hxx>
+#include <svx/zoomslideritem.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+
+#include <set>
+
+// -----------------------------------------------------------------------
+
+SFX_IMPL_STATUSBAR_CONTROL( SvxZoomSliderControl, SvxZoomSliderItem );
+
+// -----------------------------------------------------------------------
+
+struct SvxZoomSliderControl::SvxZoomSliderControl_Impl
+{
+ USHORT mnCurrentZoom;
+ USHORT mnMinZoom;
+ USHORT mnMaxZoom;
+ USHORT mnSliderCenter;
+ std::vector< long > maSnappingPointOffsets;
+ std::vector< USHORT > maSnappingPointZooms;
+ Image maSliderButton;
+ Image maIncreaseButton;
+ Image maDecreaseButton;
+ bool mbValuesSet;
+ bool mbOmitPaint;
+
+ SvxZoomSliderControl_Impl() :
+ mnCurrentZoom( 0 ),
+ mnMinZoom( 0 ),
+ mnMaxZoom( 0 ),
+ mnSliderCenter( 0 ),
+ maSnappingPointOffsets(),
+ maSnappingPointZooms(),
+ maSliderButton(),
+ maIncreaseButton(),
+ maDecreaseButton(),
+ mbValuesSet( false ),
+ mbOmitPaint( false ) {}
+};
+
+// -----------------------------------------------------------------------
+
+const long nButtonWidth = 10;
+const long nButtonHeight = 10;
+const long nIncDecWidth = 11;
+const long nIncDecHeight = 11;
+const long nSliderHeight = 2;
+const long nSnappingHeight = 4;
+const long nSliderXOffset = 20;
+const long nSnappingEpsilon = 5; // snapping epsilon in pixels
+const long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance of two adjacent snapping points
+
+// -----------------------------------------------------------------------
+
+// nOffset referes to the origin of the control:
+// + ----------- -
+USHORT SvxZoomSliderControl::Offset2Zoom( long nOffset ) const
+{
+ const long nControlWidth = getControlRect().GetWidth();
+ USHORT nRet = 0;
+
+ if ( nOffset < nSliderXOffset )
+ return mpImpl->mnMinZoom;;
+
+ if ( nOffset > nControlWidth - nSliderXOffset )
+ return mpImpl->mnMaxZoom;
+
+ // check for snapping points:
+ USHORT nCount = 0;
+ std::vector< long >::iterator aSnappingPointIter;
+ for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin();
+ aSnappingPointIter != mpImpl->maSnappingPointOffsets.end();
+ ++aSnappingPointIter )
+ {
+ const long nCurrent = *aSnappingPointIter;
+ if ( Abs(nCurrent - nOffset) < nSnappingEpsilon )
+ {
+ nOffset = nCurrent;
+ nRet = mpImpl->maSnappingPointZooms[ nCount ];
+ break;
+ }
+ ++nCount;
+ }
+
+ if ( 0 == nRet )
+ {
+ if ( nOffset < nControlWidth / 2 )
+ {
+ // first half of slider
+ const long nFirstHalfRange = mpImpl->mnSliderCenter - mpImpl->mnMinZoom;
+ const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
+ const long nZoomPerSliderPixel = (1000 * nFirstHalfRange) / nHalfSliderWidth;
+ const long nOffsetToSliderLeft = nOffset - nSliderXOffset;
+ nRet = mpImpl->mnMinZoom + USHORT( nOffsetToSliderLeft * nZoomPerSliderPixel / 1000 );
+ }
+ else
+ {
+ // second half of slider
+ const long nSecondHalfRange = mpImpl->mnMaxZoom - mpImpl->mnSliderCenter;
+ const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
+ const long nZoomPerSliderPixel = 1000 * nSecondHalfRange / nHalfSliderWidth;
+ const long nOffsetToSliderCenter = nOffset - nControlWidth/2;
+ nRet = mpImpl->mnSliderCenter + USHORT( nOffsetToSliderCenter * nZoomPerSliderPixel / 1000 );
+ }
+ }
+
+ if ( nRet < mpImpl->mnMinZoom )
+ nRet = mpImpl->mnMinZoom;
+ else if ( nRet > mpImpl->mnMaxZoom )
+ nRet = mpImpl->mnMaxZoom;
+
+ return nRet;
+}
+
+// returns the offset to the left control border
+long SvxZoomSliderControl::Zoom2Offset( USHORT nCurrentZoom ) const
+{
+ const long nControlWidth = getControlRect().GetWidth();
+ long nRet = nSliderXOffset;
+
+ const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
+
+ if ( nCurrentZoom <= mpImpl->mnSliderCenter )
+ {
+ nCurrentZoom = nCurrentZoom - mpImpl->mnMinZoom;
+ const long nFirstHalfRange = mpImpl->mnSliderCenter - mpImpl->mnMinZoom;
+ const long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nFirstHalfRange;
+ const long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
+ nRet += nOffset;
+ }
+ else
+ {
+ nCurrentZoom = nCurrentZoom - mpImpl->mnSliderCenter;
+ const long nSecondHalfRange = mpImpl->mnMaxZoom - mpImpl->mnSliderCenter;
+ const long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nSecondHalfRange;
+ const long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
+ nRet += nHalfSliderWidth + nOffset;
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+SvxZoomSliderControl::SvxZoomSliderControl( USHORT _nSlotId, USHORT _nId, StatusBar& _rStb ) :
+ SfxStatusBarControl( _nSlotId, _nId, _rStb ),
+ mpImpl( new SvxZoomSliderControl_Impl )
+{
+ const sal_Bool bHC = GetStatusBar().GetSettings().GetStyleSettings().GetHighContrastMode();
+ mpImpl->maSliderButton = Image( SVX_RES( bHC ? RID_SVXBMP_SLIDERBUTTON_HC : RID_SVXBMP_SLIDERBUTTON ) );
+ mpImpl->maIncreaseButton = Image( SVX_RES( bHC ? RID_SVXBMP_SLIDERINCREASE_HC : RID_SVXBMP_SLIDERINCREASE ) );
+ mpImpl->maDecreaseButton = Image( SVX_RES( bHC ? RID_SVXBMP_SLIDERDECREASE_HC : RID_SVXBMP_SLIDERDECREASE ) );
+}
+
+// -----------------------------------------------------------------------
+
+SvxZoomSliderControl::~SvxZoomSliderControl()
+{
+ delete mpImpl;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxZoomSliderControl::StateChanged( USHORT /*nSID*/, SfxItemState eState, const SfxPoolItem* pState )
+{
+ if ( (SFX_ITEM_AVAILABLE != eState) || pState->ISA( SfxVoidItem ) )
+ {
+ GetStatusBar().SetItemText( GetId(), String() );
+ mpImpl->mbValuesSet = false;
+ }
+ else
+ {
+ OSL_ENSURE( pState->ISA( SvxZoomSliderItem ), "invalid item type: should be a SvxZoomSliderItem" );
+ mpImpl->mnCurrentZoom = static_cast<const SvxZoomSliderItem*>( pState )->GetValue();
+ mpImpl->mnMinZoom = static_cast<const SvxZoomSliderItem*>( pState )->GetMinZoom();
+ mpImpl->mnMaxZoom = static_cast<const SvxZoomSliderItem*>( pState )->GetMaxZoom();
+ mpImpl->mnSliderCenter= 100;
+ mpImpl->mbValuesSet = true;
+
+ if ( mpImpl->mnSliderCenter == mpImpl->mnMaxZoom )
+ mpImpl->mnSliderCenter = mpImpl->mnMinZoom + (USHORT)((mpImpl->mnMaxZoom - mpImpl->mnMinZoom) * 0.5);
+
+
+ DBG_ASSERT( mpImpl->mnMinZoom <= mpImpl->mnCurrentZoom &&
+ mpImpl->mnMinZoom < mpImpl->mnSliderCenter &&
+ mpImpl->mnMaxZoom >= mpImpl->mnCurrentZoom &&
+ mpImpl->mnMaxZoom > mpImpl->mnSliderCenter,
+ "Looks like the zoom slider item is corrupted" );
+
+ const com::sun::star::uno::Sequence < sal_Int32 > rSnappingPoints = static_cast<const SvxZoomSliderItem*>( pState )->GetSnappingPoints();
+ mpImpl->maSnappingPointOffsets.clear();
+ mpImpl->maSnappingPointZooms.clear();
+
+ // get all snapping points:
+ std::set< USHORT > aTmpSnappingPoints;
+ for ( USHORT j = 0; j < rSnappingPoints.getLength(); ++j )
+ {
+ const sal_Int32 nSnappingPoint = rSnappingPoints[j];
+ aTmpSnappingPoints.insert( (USHORT)nSnappingPoint );
+ }
+
+ // remove snapping points that are to close to each other:
+ std::set< USHORT >::iterator aSnappingPointIter;
+ long nLastOffset = 0;
+
+ for ( aSnappingPointIter = aTmpSnappingPoints.begin(); aSnappingPointIter != aTmpSnappingPoints.end(); ++aSnappingPointIter )
+ {
+ const USHORT nCurrent = *aSnappingPointIter;
+ const long nCurrentOffset = Zoom2Offset( nCurrent );
+
+ if ( nCurrentOffset - nLastOffset >= nSnappingPointsMinDist )
+ {
+ mpImpl->maSnappingPointOffsets.push_back( nCurrentOffset );
+ mpImpl->maSnappingPointZooms.push_back( nCurrent );
+ nLastOffset = nCurrentOffset;
+ }
+ }
+ }
+
+ if ( !mpImpl->mbOmitPaint && GetStatusBar().AreItemsVisible() )
+ GetStatusBar().SetItemData( GetId(), 0 ); // force repaint
+}
+
+// -----------------------------------------------------------------------
+
+void SvxZoomSliderControl::Paint( const UserDrawEvent& rUsrEvt )
+{
+ if ( !mpImpl->mbValuesSet || mpImpl->mbOmitPaint )
+ return;
+
+ const Rectangle aControlRect = getControlRect();
+ OutputDevice* pDev = rUsrEvt.GetDevice();
+ Rectangle aRect = rUsrEvt.GetRect();
+ Rectangle aSlider = aRect;
+
+ aSlider.Top() += (aControlRect.GetHeight() - nSliderHeight)/2 - 1;
+ aSlider.Bottom() = aSlider.Top() + nSliderHeight;
+ aSlider.Left() += nSliderXOffset;
+ aSlider.Right() -= nSliderXOffset;
+
+ Color aOldLineColor = pDev->GetLineColor();
+ Color aOldFillColor = pDev->GetFillColor();
+
+ pDev->SetLineColor( Color( COL_GRAY ) );
+ pDev->SetFillColor( Color( COL_GRAY ) );
+
+ // draw snapping points:
+ std::vector< long >::iterator aSnappingPointIter;
+ for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin();
+ aSnappingPointIter != mpImpl->maSnappingPointOffsets.end();
+ ++aSnappingPointIter )
+ {
+ Rectangle aSnapping( aRect );
+ aSnapping.Bottom() = aSlider.Top();
+ aSnapping.Top() = aSnapping.Bottom() - nSnappingHeight;
+ aSnapping.Left() += *aSnappingPointIter;
+ aSnapping.Right() = aSnapping.Left();
+ pDev->DrawRect( aSnapping );
+
+ aSnapping.Top() += nSnappingHeight + nSliderHeight;
+ aSnapping.Bottom() += nSnappingHeight + nSliderHeight;
+ pDev->DrawRect( aSnapping );
+ }
+
+ // draw slider
+ Rectangle aFirstLine( aSlider );
+ aFirstLine.Bottom() = aFirstLine.Top();
+
+ Rectangle aSecondLine( aSlider );
+ aSecondLine.Top() = aSecondLine.Bottom();
+
+ Rectangle aLeft( aSlider );
+ aLeft.Right() = aLeft.Left();
+
+ Rectangle aRight( aSlider );
+ aRight.Left() = aRight.Right();
+
+ pDev->SetLineColor( Color ( COL_WHITE ) );
+ pDev->SetFillColor( Color ( COL_WHITE ) );
+ pDev->DrawRect( aSecondLine );
+ pDev->DrawRect( aRight );
+
+ pDev->SetLineColor( Color( COL_GRAY ) );
+ pDev->SetFillColor( Color( COL_GRAY ) );
+ pDev->DrawRect( aFirstLine );
+ pDev->DrawRect( aLeft );
+
+ // draw slider button
+ Point aImagePoint = aRect.TopLeft();
+ aImagePoint.X() += Zoom2Offset( mpImpl->mnCurrentZoom );
+ aImagePoint.X() -= nButtonWidth/2;
+ aImagePoint.Y() += (aControlRect.GetHeight() - nButtonHeight)/2;
+ pDev->DrawImage( aImagePoint, mpImpl->maSliderButton );
+
+ // draw decrease button
+ aImagePoint = aRect.TopLeft();
+ aImagePoint.X() += (nSliderXOffset - nIncDecWidth)/2;
+ aImagePoint.Y() += (aControlRect.GetHeight() - nIncDecHeight)/2;
+ pDev->DrawImage( aImagePoint, mpImpl->maDecreaseButton );
+
+ // draw increase button
+ aImagePoint.X() = aRect.TopLeft().X() + aControlRect.GetWidth() - nIncDecWidth - (nSliderXOffset - nIncDecWidth)/2;
+ pDev->DrawImage( aImagePoint, mpImpl->maIncreaseButton );
+
+ pDev->SetLineColor( aOldLineColor );
+ pDev->SetFillColor( aOldFillColor );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SvxZoomSliderControl::MouseButtonDown( const MouseEvent & rEvt )
+{
+ if ( !mpImpl->mbValuesSet )
+ return TRUE;;
+
+ const Rectangle aControlRect = getControlRect();
+ const Point aPoint = rEvt.GetPosPixel();
+ const sal_Int32 nXDiff = aPoint.X() - aControlRect.Left();
+
+ const long nButtonLeftOffset = (nSliderXOffset - nIncDecWidth)/2;
+ const long nButtonRightOffset = (nSliderXOffset + nIncDecWidth)/2;
+
+ const long nOldZoom = mpImpl->mnCurrentZoom;
+
+ // click to - button
+ if ( nXDiff >= nButtonLeftOffset && nXDiff <= nButtonRightOffset )
+ mpImpl->mnCurrentZoom = mpImpl->mnCurrentZoom - 5;
+ // click to + button
+ else if ( nXDiff >= aControlRect.GetWidth() - nSliderXOffset + nButtonLeftOffset &&
+ nXDiff <= aControlRect.GetWidth() - nSliderXOffset + nButtonRightOffset )
+ mpImpl->mnCurrentZoom = mpImpl->mnCurrentZoom + 5;
+ // click to slider
+ else if( nXDiff >= nSliderXOffset && nXDiff <= aControlRect.GetWidth() - nSliderXOffset )
+ mpImpl->mnCurrentZoom = Offset2Zoom( nXDiff );
+
+ if ( mpImpl->mnCurrentZoom < mpImpl->mnMinZoom )
+ mpImpl->mnCurrentZoom = mpImpl->mnMinZoom;
+ else if ( mpImpl->mnCurrentZoom > mpImpl->mnMaxZoom )
+ mpImpl->mnCurrentZoom = mpImpl->mnMaxZoom;
+
+ if ( nOldZoom == mpImpl->mnCurrentZoom )
+ return TRUE;
+
+ if ( GetStatusBar().AreItemsVisible() )
+ GetStatusBar().SetItemData( GetId(), 0 ); // force repaint
+
+ mpImpl->mbOmitPaint = true; // optimization: paint before executing command,
+ // then omit painting which is triggered by the execute function
+
+ SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom );
+
+ ::com::sun::star::uno::Any a;
+ aZoomSliderItem.QueryValue( a );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ZoomSlider" ));
+ aArgs[0].Value = a;
+
+ execute( aArgs );
+
+ mpImpl->mbOmitPaint = false;
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SvxZoomSliderControl::MouseMove( const MouseEvent & rEvt )
+{
+ if ( !mpImpl->mbValuesSet )
+ return TRUE;;
+
+ const short nButtons = rEvt.GetButtons();
+
+ // check mouse move with button pressed
+ if ( 1 == nButtons )
+ {
+ const Rectangle aControlRect = getControlRect();
+ const Point aPoint = rEvt.GetPosPixel();
+ const sal_Int32 nXDiff = aPoint.X() - aControlRect.Left();
+
+ if ( nXDiff >= nSliderXOffset && nXDiff <= aControlRect.GetWidth() - nSliderXOffset )
+ {
+ mpImpl->mnCurrentZoom = Offset2Zoom( nXDiff );
+
+ if ( GetStatusBar().AreItemsVisible() )
+ GetStatusBar().SetItemData( GetId(), 0 ); // force repaint
+
+ mpImpl->mbOmitPaint = true; // optimization: paint before executing command,
+ // then omit painting which is triggered by the execute function
+
+ // commit state change
+ SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom );
+
+ ::com::sun::star::uno::Any a;
+ aZoomSliderItem.QueryValue( a );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ZoomSlider" ));
+ aArgs[0].Value = a;
+
+ execute( aArgs );
+
+ mpImpl->mbOmitPaint = false;
+ }
+ }
+
+ return TRUE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/ActionDescriptionProvider.cxx b/svx/source/svdraw/ActionDescriptionProvider.cxx
new file mode 100644
index 000000000000..91a79d0123f7
--- /dev/null
+++ b/svx/source/svdraw/ActionDescriptionProvider.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "ActionDescriptionProvider.hxx"
+#include "svdglob.hxx"
+#include "svdstr.hrc"
+
+::rtl::OUString ActionDescriptionProvider::createDescription( ActionType eActionType
+ , const ::rtl::OUString& rObjectName )
+{
+ USHORT nResID=0;
+ switch( eActionType )
+ {
+ case INSERT:
+ nResID=STR_UndoInsertObj;
+ break;
+ case DELETE:
+ nResID= STR_EditDelete;
+ break;
+ case CUT:
+ nResID= STR_ExchangeClpCut;
+ break;
+ case MOVE:
+ nResID= STR_EditMove;
+ break;
+ case RESIZE:
+ nResID= STR_EditResize;
+ break;
+ case ROTATE:
+ nResID= STR_EditRotate;
+ break;
+ case TRANSFORM:
+ nResID= STR_EditTransform;
+ break;
+ case FORMAT:
+ nResID= STR_EditSetAttributes;
+ break;
+ case MOVE_TOTOP:
+ nResID= STR_EditMovToTop;
+ break;
+ case MOVE_TOBOTTOM:
+ nResID= STR_EditMovToBtm;
+ break;
+ case POS_SIZE:
+ nResID = STR_EditPosSize;
+ break;
+ }
+ if(!nResID)
+ return rtl::OUString();
+
+ XubString aStr(ImpGetResStr(nResID));
+ XubString aName(rObjectName);
+ aStr.SearchAndReplaceAscii("%1", aName);
+ return rtl::OUString(aStr);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/clonelist.cxx b/svx/source/svdraw/clonelist.cxx
new file mode 100644
index 000000000000..9a323630a105
--- /dev/null
+++ b/svx/source/svdraw/clonelist.cxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// #i13033#
+// New mechanism to hold a ist of all original and cloned objects for later
+// re-creating the connections for contained connectors
+#include <clonelist.hxx>
+#include <svx/svdoedge.hxx>
+#include <svx/scene3d.hxx>
+
+CloneList::CloneList()
+{
+}
+
+CloneList::~CloneList()
+{
+}
+
+void CloneList::AddPair(const SdrObject* pOriginal, SdrObject* pClone)
+{
+ maOriginalList.Insert((SdrObject*)pOriginal, LIST_APPEND);
+ maCloneList.Insert(pClone, LIST_APPEND);
+
+ // look for subobjects, too.
+ sal_Bool bOriginalIsGroup(pOriginal->IsGroupObject());
+ sal_Bool bCloneIsGroup(pClone->IsGroupObject());
+
+ if(bOriginalIsGroup && pOriginal->ISA(E3dObject) && !pOriginal->ISA(E3dScene))
+ bOriginalIsGroup = sal_False;
+
+ if(bCloneIsGroup && pClone->ISA(E3dObject) && !pClone->ISA(E3dScene))
+ bCloneIsGroup = sal_False;
+
+ if(bOriginalIsGroup && bCloneIsGroup)
+ {
+ const SdrObjList* pOriginalList = pOriginal->GetSubList();
+ SdrObjList* pCloneList = pClone->GetSubList();
+
+ if(pOriginalList && pCloneList
+ && pOriginalList->GetObjCount() == pCloneList->GetObjCount())
+ {
+ for(sal_uInt32 a(0); a < pOriginalList->GetObjCount(); a++)
+ {
+ // recursive call
+ AddPair(pOriginalList->GetObj(a), pCloneList->GetObj(a));
+ }
+ }
+ }
+}
+
+sal_uInt32 CloneList::Count() const
+{
+ return maOriginalList.Count();
+}
+
+const SdrObject* CloneList::GetOriginal(sal_uInt32 nIndex) const
+{
+ return (SdrObject*)maOriginalList.GetObject(nIndex);
+}
+
+SdrObject* CloneList::GetClone(sal_uInt32 nIndex) const
+{
+ return (SdrObject*)maCloneList.GetObject(nIndex);
+}
+
+void CloneList::CopyConnections() const
+{
+ for(sal_uInt32 a(0); a < maOriginalList.Count(); a++)
+ {
+ const SdrEdgeObj* pOriginalEdge = PTR_CAST(SdrEdgeObj, GetOriginal(a));
+ SdrEdgeObj* pCloneEdge = PTR_CAST(SdrEdgeObj, GetClone(a));
+
+ if(pOriginalEdge && pCloneEdge)
+ {
+ SdrObject* pOriginalNode1 = pOriginalEdge->GetConnectedNode(sal_True);
+ SdrObject* pOriginalNode2 = pOriginalEdge->GetConnectedNode(sal_False);
+
+ if(pOriginalNode1)
+ {
+ ULONG nPos(maOriginalList.GetPos(pOriginalNode1));
+
+ if(LIST_ENTRY_NOTFOUND != nPos)
+ {
+ if(pOriginalEdge->GetConnectedNode(sal_True) != GetClone(nPos))
+ {
+ pCloneEdge->ConnectToNode(sal_True, GetClone(nPos));
+ }
+ }
+ }
+
+ if(pOriginalNode2)
+ {
+ ULONG nPos(maOriginalList.GetPos(pOriginalNode2));
+
+ if(LIST_ENTRY_NOTFOUND != nPos)
+ {
+ if(pOriginalEdge->GetConnectedNode(sal_False) != GetClone(nPos))
+ {
+ pCloneEdge->ConnectToNode(sal_False, GetClone(nPos));
+ }
+ }
+ }
+ }
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/gradtrns.cxx b/svx/source/svdraw/gradtrns.cxx
new file mode 100644
index 000000000000..6b33979da3c9
--- /dev/null
+++ b/svx/source/svdraw/gradtrns.cxx
@@ -0,0 +1,541 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "gradtrns.hxx"
+#include <svx/svdobj.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <vcl/salbtype.hxx> // FRound
+
+//////////////////////////////////////////////////////////////////////////////
+
+void GradTransformer::GradToVec(GradTransGradient& rG, GradTransVector& rV, const SdrObject* pObj)
+{
+ // handle start color
+ rV.aCol1 = rG.aGradient.GetStartColor();
+ if(100 != rG.aGradient.GetStartIntens())
+ {
+ const double fFact((double)rG.aGradient.GetStartIntens() / 100.0);
+ rV.aCol1 = Color(rV.aCol1.getBColor() * fFact);
+ }
+
+ // handle end color
+ rV.aCol2 = rG.aGradient.GetEndColor();
+ if(100 != rG.aGradient.GetEndIntens())
+ {
+ const double fFact((double)rG.aGradient.GetEndIntens() / 100.0);
+ rV.aCol2 = Color(rV.aCol2.getBColor() * fFact);
+ }
+
+ // calc the basic positions
+ const Rectangle aObjectSnapRectangle(pObj->GetSnapRect());
+ const basegfx::B2DRange aRange(aObjectSnapRectangle.Left(), aObjectSnapRectangle.Top(), aObjectSnapRectangle.Right(), aObjectSnapRectangle.Bottom());
+ const basegfx::B2DPoint aCenter(aRange.getCenter());
+ basegfx::B2DPoint aStartPos, aEndPos;
+
+ switch(rG.aGradient.GetGradientStyle())
+ {
+ case XGRAD_LINEAR :
+ {
+ aStartPos = basegfx::B2DPoint(aCenter.getX(), aRange.getMinY());
+ aEndPos = basegfx::B2DPoint(aCenter.getX(), aRange.getMaximum().getY());
+
+ if(rG.aGradient.GetBorder())
+ {
+ basegfx::B2DVector aFullVec(aStartPos - aEndPos);
+ const double fLen = (aFullVec.getLength() * (100.0 - (double)rG.aGradient.GetBorder())) / 100.0;
+ aFullVec.normalize();
+ aStartPos = aEndPos + (aFullVec * fLen);
+ }
+
+ if(rG.aGradient.GetAngle())
+ {
+ const double fAngle = (double)rG.aGradient.GetAngle() * (F_PI180 / 10.0);
+ const basegfx::B2DHomMatrix aTransformation(basegfx::tools::createRotateAroundPoint(aCenter, -fAngle));
+
+ aStartPos *= aTransformation;
+ aEndPos *= aTransformation;
+ }
+ break;
+ }
+ case XGRAD_AXIAL :
+ {
+ aStartPos = aCenter;
+ aEndPos = basegfx::B2DPoint(aCenter.getX(), aRange.getMaximum().getY());
+
+ if(rG.aGradient.GetBorder())
+ {
+ basegfx::B2DVector aFullVec(aEndPos - aStartPos);
+ const double fLen = (aFullVec.getLength() * (100.0 - (double)rG.aGradient.GetBorder())) / 100.0;
+ aFullVec.normalize();
+ aEndPos = aStartPos + (aFullVec * fLen);
+ }
+
+ if(rG.aGradient.GetAngle())
+ {
+ const double fAngle = (double)rG.aGradient.GetAngle() * (F_PI180 / 10.0);
+ const basegfx::B2DHomMatrix aTransformation(basegfx::tools::createRotateAroundPoint(aCenter, -fAngle));
+
+ aStartPos *= aTransformation;
+ aEndPos *= aTransformation;
+ }
+ break;
+ }
+ case XGRAD_RADIAL :
+ case XGRAD_SQUARE :
+ {
+ aStartPos = basegfx::B2DPoint(aRange.getMinX(), aRange.getMaximum().getY());
+ aEndPos = basegfx::B2DPoint(aRange.getMinX(), aRange.getMinY());
+
+ if(rG.aGradient.GetBorder())
+ {
+ basegfx::B2DVector aFullVec(aStartPos - aEndPos);
+ const double fLen = (aFullVec.getLength() * (100.0 - (double)rG.aGradient.GetBorder())) / 100.0;
+ aFullVec.normalize();
+ aStartPos = aEndPos + (aFullVec * fLen);
+ }
+
+ if(rG.aGradient.GetAngle())
+ {
+ const double fAngle = (double)rG.aGradient.GetAngle() * (F_PI180 / 10.0);
+ const basegfx::B2DHomMatrix aTransformation(basegfx::tools::createRotateAroundPoint(aEndPos, -fAngle));
+
+ aStartPos *= aTransformation;
+ aEndPos *= aTransformation;
+ }
+
+ if(rG.aGradient.GetXOffset() || rG.aGradient.GetYOffset())
+ {
+ basegfx::B2DPoint aOffset(
+ (aRange.getWidth() * rG.aGradient.GetXOffset()) / 100.0,
+ (aRange.getHeight() * rG.aGradient.GetYOffset()) / 100.0);
+
+ aStartPos += aOffset;
+ aEndPos += aOffset;
+ }
+
+ break;
+ }
+ case XGRAD_ELLIPTICAL :
+ case XGRAD_RECT :
+ {
+ aStartPos = basegfx::B2DPoint(aRange.getMinX(), aCenter.getY());
+ aEndPos = basegfx::B2DPoint(aRange.getMinX(), aRange.getMinY());
+
+ if(rG.aGradient.GetBorder())
+ {
+ basegfx::B2DVector aFullVec(aStartPos - aEndPos);
+ const double fLen = (aFullVec.getLength() * (100.0 - (double)rG.aGradient.GetBorder())) / 100.0;
+ aFullVec.normalize();
+ aStartPos = aEndPos + (aFullVec * fLen);
+ }
+
+ if(rG.aGradient.GetAngle())
+ {
+ const double fAngle = (double)rG.aGradient.GetAngle() * (F_PI180 / 10.0);
+ const basegfx::B2DHomMatrix aTransformation(basegfx::tools::createRotateAroundPoint(aEndPos, -fAngle));
+
+ aStartPos *= aTransformation;
+ aEndPos *= aTransformation;
+ }
+
+ if(rG.aGradient.GetXOffset() || rG.aGradient.GetYOffset())
+ {
+ basegfx::B2DPoint aOffset(
+ (aRange.getWidth() * rG.aGradient.GetXOffset()) / 100.0,
+ (aRange.getHeight() * rG.aGradient.GetYOffset()) / 100.0);
+
+ aStartPos += aOffset;
+ aEndPos += aOffset;
+ }
+
+ break;
+ }
+ }
+
+ // set values for vector positions now
+ rV.maPositionA = aStartPos;
+ rV.maPositionB = aEndPos;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void GradTransformer::VecToGrad(GradTransVector& rV, GradTransGradient& rG, GradTransGradient& rGOld, const SdrObject* pObj,
+ sal_Bool bMoveSingle, sal_Bool bMoveFirst)
+{
+ // fill old gradient to new gradient to have a base
+ rG = rGOld;
+
+ // handle color changes
+ if(rV.aCol1 != rGOld.aGradient.GetStartColor())
+ {
+ rG.aGradient.SetStartColor(rV.aCol1);
+ rG.aGradient.SetStartIntens(100);
+ }
+ if(rV.aCol2 != rGOld.aGradient.GetEndColor())
+ {
+ rG.aGradient.SetEndColor(rV.aCol2);
+ rG.aGradient.SetEndIntens(100);
+ }
+
+ // calc the basic positions
+ const Rectangle aObjectSnapRectangle(pObj->GetSnapRect());
+ const basegfx::B2DRange aRange(aObjectSnapRectangle.Left(), aObjectSnapRectangle.Top(), aObjectSnapRectangle.Right(), aObjectSnapRectangle.Bottom());
+ const basegfx::B2DPoint aCenter(aRange.getCenter());
+ basegfx::B2DPoint aStartPos(rV.maPositionA);
+ basegfx::B2DPoint aEndPos(rV.maPositionB);
+
+ switch(rG.aGradient.GetGradientStyle())
+ {
+ case XGRAD_LINEAR :
+ {
+ if(!bMoveSingle || (bMoveSingle && !bMoveFirst))
+ {
+ basegfx::B2DVector aFullVec(aEndPos - aStartPos);
+
+ if(bMoveSingle)
+ {
+ aFullVec = aEndPos - aCenter;
+ }
+
+ aFullVec.normalize();
+
+ double fNewFullAngle(atan2(aFullVec.getY(), aFullVec.getX()));
+ fNewFullAngle /= F_PI180;
+ fNewFullAngle *= -10.0;
+ fNewFullAngle += 900.0;
+
+ // clip
+ while(fNewFullAngle < 0.0)
+ {
+ fNewFullAngle += 3600.0;
+ }
+
+ while(fNewFullAngle >= 3600.0)
+ {
+ fNewFullAngle -= 3600.0;
+ }
+
+ // to int and set
+ sal_Int32 nNewAngle = FRound(fNewFullAngle);
+
+ if(nNewAngle != rGOld.aGradient.GetAngle())
+ {
+ rG.aGradient.SetAngle(nNewAngle);
+ }
+ }
+
+ if(!bMoveSingle || (bMoveSingle && bMoveFirst))
+ {
+ const basegfx::B2DVector aFullVec(aEndPos - aStartPos);
+ const basegfx::B2DPoint aBottomLeft(aRange.getMinX(), aRange.getMaximum().getY());
+ const basegfx::B2DPoint aTopLeft(aRange.getMinX(), aRange.getMinY());
+ const basegfx::B2DVector aOldVec(aBottomLeft - aTopLeft);
+ const double fFullLen(aFullVec.getLength());
+ const double fOldLen(aOldVec.getLength());
+ const double fNewBorder((fFullLen * 100.0) / fOldLen);
+ sal_Int32 nNewBorder(100L - FRound(fNewBorder));
+
+ // clip
+ if(nNewBorder < 0L)
+ {
+ nNewBorder = 0L;
+ }
+
+ if(nNewBorder > 100L)
+ {
+ nNewBorder = 100L;
+ }
+
+ // set
+ if(nNewBorder != rG.aGradient.GetBorder())
+ {
+ rG.aGradient.SetBorder((sal_uInt16)nNewBorder);
+ }
+ }
+
+ break;
+ }
+ case XGRAD_AXIAL :
+ {
+ if(!bMoveSingle || (bMoveSingle && !bMoveFirst))
+ {
+ basegfx::B2DVector aFullVec(aEndPos - aCenter);
+ const basegfx::B2DVector aOldVec(basegfx::B2DPoint(aCenter.getX(), aRange.getMaximum().getY()) - aCenter);
+ const double fFullLen(aFullVec.getLength());
+ const double fOldLen(aOldVec.getLength());
+ const double fNewBorder((fFullLen * 100.0) / fOldLen);
+ sal_Int32 nNewBorder = 100 - FRound(fNewBorder);
+
+ // clip
+ if(nNewBorder < 0L)
+ {
+ nNewBorder = 0L;
+ }
+
+ if(nNewBorder > 100L)
+ {
+ nNewBorder = 100L;
+ }
+
+ // set
+ if(nNewBorder != rG.aGradient.GetBorder())
+ {
+ rG.aGradient.SetBorder((sal_uInt16)nNewBorder);
+ }
+
+ aFullVec.normalize();
+ double fNewFullAngle(atan2(aFullVec.getY(), aFullVec.getX()));
+ fNewFullAngle /= F_PI180;
+ fNewFullAngle *= -10.0;
+ fNewFullAngle += 900.0;
+
+ // clip
+ while(fNewFullAngle < 0.0)
+ {
+ fNewFullAngle += 3600.0;
+ }
+
+ while(fNewFullAngle >= 3600.0)
+ {
+ fNewFullAngle -= 3600.0;
+ }
+
+ // to int and set
+ const sal_Int32 nNewAngle(FRound(fNewFullAngle));
+
+ if(nNewAngle != rGOld.aGradient.GetAngle())
+ {
+ rG.aGradient.SetAngle(nNewAngle);
+ }
+ }
+
+ break;
+ }
+ case XGRAD_RADIAL :
+ case XGRAD_SQUARE :
+ {
+ if(!bMoveSingle || (bMoveSingle && !bMoveFirst))
+ {
+ const basegfx::B2DPoint aTopLeft(aRange.getMinX(), aRange.getMinY());
+ const basegfx::B2DPoint aOffset(aEndPos - aTopLeft);
+ sal_Int32 nNewXOffset(FRound((aOffset.getX() * 100.0) / aRange.getWidth()));
+ sal_Int32 nNewYOffset(FRound((aOffset.getY() * 100.0) / aRange.getHeight()));
+
+ // clip
+ if(nNewXOffset < 0L)
+ {
+ nNewXOffset = 0L;
+ }
+
+ if(nNewXOffset > 100L)
+ {
+ nNewXOffset = 100L;
+ }
+
+ if(nNewYOffset < 0L)
+ {
+ nNewYOffset = 0L;
+ }
+
+ if(nNewYOffset > 100L)
+ {
+ nNewYOffset = 100L;
+ }
+
+ rG.aGradient.SetXOffset((sal_uInt16)nNewXOffset);
+ rG.aGradient.SetYOffset((sal_uInt16)nNewYOffset);
+
+ aStartPos -= aOffset;
+ aEndPos -= aOffset;
+ }
+
+ if(!bMoveSingle || (bMoveSingle && bMoveFirst))
+ {
+ basegfx::B2DVector aFullVec(aStartPos - aEndPos);
+ const basegfx::B2DPoint aBottomLeft(aRange.getMinX(), aRange.getMaximum().getY());
+ const basegfx::B2DPoint aTopLeft(aRange.getMinX(), aRange.getMinY());
+ const basegfx::B2DVector aOldVec(aBottomLeft - aTopLeft);
+ const double fFullLen(aFullVec.getLength());
+ const double fOldLen(aOldVec.getLength());
+ const double fNewBorder((fFullLen * 100.0) / fOldLen);
+ sal_Int32 nNewBorder(100L - FRound(fNewBorder));
+
+ // clip
+ if(nNewBorder < 0L)
+ {
+ nNewBorder = 0L;
+ }
+
+ if(nNewBorder > 100L)
+ {
+ nNewBorder = 100L;
+ }
+
+ // set
+ if(nNewBorder != rG.aGradient.GetBorder())
+ {
+ rG.aGradient.SetBorder((sal_uInt16)nNewBorder);
+ }
+
+ // angle is not definitely necessary for these modes, but it makes
+ // controlling more fun for the user
+ aFullVec.normalize();
+ double fNewFullAngle(atan2(aFullVec.getY(), aFullVec.getX()));
+ fNewFullAngle /= F_PI180;
+ fNewFullAngle *= -10.0;
+ fNewFullAngle += 900.0;
+
+ // clip
+ while(fNewFullAngle < 0.0)
+ {
+ fNewFullAngle += 3600.0;
+ }
+
+ while(fNewFullAngle >= 3600.0)
+ {
+ fNewFullAngle -= 3600.0;
+ }
+
+ // to int and set
+ const sal_Int32 nNewAngle(FRound(fNewFullAngle));
+
+ if(nNewAngle != rGOld.aGradient.GetAngle())
+ {
+ rG.aGradient.SetAngle(nNewAngle);
+ }
+ }
+
+ break;
+ }
+ case XGRAD_ELLIPTICAL :
+ case XGRAD_RECT :
+ {
+ if(!bMoveSingle || (bMoveSingle && !bMoveFirst))
+ {
+ const basegfx::B2DPoint aTopLeft(aRange.getMinX(), aRange.getMinY());
+ const basegfx::B2DPoint aOffset(aEndPos - aTopLeft);
+ sal_Int32 nNewXOffset(FRound((aOffset.getX() * 100.0) / aRange.getWidth()));
+ sal_Int32 nNewYOffset(FRound((aOffset.getY() * 100.0) / aRange.getHeight()));
+
+ // clip
+ if(nNewXOffset < 0L)
+ {
+ nNewXOffset = 0L;
+ }
+
+ if(nNewXOffset > 100L)
+ {
+ nNewXOffset = 100L;
+ }
+
+ if(nNewYOffset < 0L)
+ {
+ nNewYOffset = 0L;
+ }
+
+ if(nNewYOffset > 100L)
+ {
+ nNewYOffset = 100L;
+ }
+
+ rG.aGradient.SetXOffset((sal_uInt16)nNewXOffset);
+ rG.aGradient.SetYOffset((sal_uInt16)nNewYOffset);
+
+ aStartPos -= aOffset;
+ aEndPos -= aOffset;
+ }
+
+ if(!bMoveSingle || (bMoveSingle && bMoveFirst))
+ {
+ basegfx::B2DVector aFullVec(aStartPos - aEndPos);
+ const basegfx::B2DPoint aTopLeft(aRange.getMinX(), aRange.getMinY());
+ const basegfx::B2DPoint aCenterLeft(aRange.getMinX(), aRange.getHeight());
+ const basegfx::B2DVector aOldVec(aCenterLeft - aTopLeft);
+ const double fFullLen(aFullVec.getLength());
+ const double fOldLen(aOldVec.getLength());
+ const double fNewBorder((fFullLen * 100.0) / fOldLen);
+ sal_Int32 nNewBorder(100L - FRound(fNewBorder));
+
+ // clip
+ if(nNewBorder < 0L)
+ {
+ nNewBorder = 0L;
+ }
+
+ if(nNewBorder > 100L)
+ {
+ nNewBorder = 100L;
+ }
+
+ // set
+ if(nNewBorder != rG.aGradient.GetBorder())
+ {
+ rG.aGradient.SetBorder((sal_uInt16)nNewBorder);
+ }
+
+ // angle is not definitely necessary for these modes, but it makes
+ // controlling more fun for the user
+ aFullVec.normalize();
+ double fNewFullAngle(atan2(aFullVec.getY(), aFullVec.getX()));
+ fNewFullAngle /= F_PI180;
+ fNewFullAngle *= -10.0;
+ fNewFullAngle += 900.0;
+
+ // clip
+ while(fNewFullAngle < 0.0)
+ {
+ fNewFullAngle += 3600.0;
+ }
+
+ while(fNewFullAngle >= 3600.0)
+ {
+ fNewFullAngle -= 3600.0;
+ }
+
+ // to int and set
+ const sal_Int32 nNewAngle(FRound(fNewFullAngle));
+
+ if(nNewAngle != rGOld.aGradient.GetAngle())
+ {
+ rG.aGradient.SetAngle(nNewAngle);
+ }
+ }
+
+ break;
+ }
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/gradtrns.hxx b/svx/source/svdraw/gradtrns.hxx
new file mode 100644
index 000000000000..ce0f6ee23607
--- /dev/null
+++ b/svx/source/svdraw/gradtrns.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _GRADTRANS_HXX
+#define _GRADTRANS_HXX
+
+#include <svx/xgrad.hxx>
+#include <tools/gen.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+
+class SdrObject;
+
+class GradTransVector
+{
+public:
+ basegfx::B2DPoint maPositionA;
+ basegfx::B2DPoint maPositionB;
+ Color aCol1;
+ Color aCol2;
+};
+
+class GradTransGradient
+{
+public:
+ XGradient aGradient;
+};
+
+class GradTransformer
+{
+public:
+ GradTransformer() {}
+
+ void GradToVec(GradTransGradient& rG, GradTransVector& rV,
+ const SdrObject* pObj);
+ void VecToGrad(GradTransVector& rV, GradTransGradient& rG,
+ GradTransGradient& rGOld, const SdrObject* pObj, sal_Bool bMoveSingle, sal_Bool bMoveFirst);
+};
+
+#endif // _GRADTRANS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/impgrfll.cxx b/svx/source/svdraw/impgrfll.cxx
new file mode 100644
index 000000000000..f8332089c433
--- /dev/null
+++ b/svx/source/svdraw/impgrfll.cxx
@@ -0,0 +1,258 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/rectenum.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/bitmap.hxx>
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ImpCalcBmpFillSizes( Size& rStartOffset,
+ Size& rBmpOutputSize,
+ const Rectangle& rOutputRect,
+ const MapMode& rOutputMapMode,
+ const Bitmap& rFillBitmap,
+ const Size& rBmpSize,
+ const Size& rBmpPerCent,
+ const Size& rBmpOffPerCent,
+ BOOL bBmpLogSize,
+ BOOL bBmpTile,
+ BOOL bBmpStretch,
+ RECT_POINT eBmpRectPoint )
+{
+ BOOL bOriginalSize = FALSE, bScaleSize = FALSE;
+
+ // Falls keine Groessen gegeben sind ( z.B. alte Dokumente )
+ // berechnen wir uns die Groesse selber aus der Bitmap
+ // ==> altes Verhalten;
+ // wenn nur eine Groesse gegeben ist, wird die andere
+ // Groesse angepasst berechnet
+ if( bBmpLogSize )
+ {
+ if( !rBmpSize.Width() && !rBmpSize.Height() )
+ bOriginalSize = TRUE;
+ else if( !rBmpSize.Width() || !rBmpSize.Height() )
+ bScaleSize = TRUE;
+ }
+ else
+ {
+ if( !rBmpPerCent.Width() && !rBmpPerCent.Height() )
+ bOriginalSize = TRUE;
+ else if( !rBmpPerCent.Width() || !rBmpPerCent.Height() )
+ bScaleSize = TRUE;
+ }
+
+ // entweder Originalgroesse oder angepasste Groesse
+ if( bOriginalSize || bScaleSize )
+ {
+ MapMode aBmpPrefMapMode( rFillBitmap.GetPrefMapMode() );
+ Size aBmpPrefSize( rFillBitmap.GetPrefSize() );
+
+ // Falls keine gesetzt ist, nehmen wir Pixel
+ if( !aBmpPrefSize.Width() || !aBmpPrefSize.Height() )
+ {
+ aBmpPrefSize = rFillBitmap.GetSizePixel();
+ aBmpPrefMapMode = MAP_PIXEL;
+ }
+
+ if( bOriginalSize )
+ {
+ if( MAP_PIXEL == aBmpPrefMapMode.GetMapUnit() )
+ rBmpOutputSize = Application::GetDefaultDevice()->PixelToLogic( aBmpPrefSize, rOutputMapMode );
+ else
+ rBmpOutputSize = OutputDevice::LogicToLogic( aBmpPrefSize, aBmpPrefMapMode, rOutputMapMode );
+ }
+ else
+ {
+ if( bBmpLogSize )
+ {
+ rBmpOutputSize = rBmpSize;
+
+ if( !rBmpSize.Width() )
+ rBmpOutputSize.Width() = basegfx::fround( (double) rBmpSize.Height() * aBmpPrefSize.Width() / aBmpPrefSize.Height() );
+ else
+ rBmpOutputSize.Height() = basegfx::fround( (double) rBmpSize.Width() * aBmpPrefSize.Height() / aBmpPrefSize.Width() );
+ }
+ else
+ {
+ if( !rBmpPerCent.Width() )
+ {
+ rBmpOutputSize.Height() = basegfx::fround( (double) rOutputRect.GetHeight() * rBmpPerCent.Height() / 100. );
+ rBmpOutputSize.Width() = basegfx::fround( (double) rBmpOutputSize.Height() * aBmpPrefSize.Width() / aBmpPrefSize.Height() );
+ }
+ else
+ {
+ rBmpOutputSize.Width() = basegfx::fround( (double) rOutputRect.GetWidth() * rBmpPerCent.Width() / 100. );
+ rBmpOutputSize.Height() = basegfx::fround( (double) rBmpOutputSize.Width() * aBmpPrefSize.Height() / aBmpPrefSize.Width() );
+ }
+ }
+ }
+ }
+ // ansonsten koennen wir die Groesse leicht selber berechnen
+ else
+ {
+ if( bBmpLogSize )
+ rBmpOutputSize = rBmpSize;
+ else
+ {
+ rBmpOutputSize.Width() = basegfx::fround( (double) rOutputRect.GetWidth() * rBmpPerCent.Width() / 100. );
+ rBmpOutputSize.Height() = basegfx::fround( (double) rOutputRect.GetHeight() * rBmpPerCent.Height() / 100. );
+ }
+ }
+
+ // nur bei Kachelung die anderen Positionen berechnen
+ if( bBmpTile )
+ {
+ Point aStartPoint;
+
+ // Grundposition der ersten Kachel berechen;
+ // Diese Position wird spaeter zur Berechnung der absoluten
+ // Startposition links oberhalb des Objektes benutzt
+ switch( eBmpRectPoint )
+ {
+ case( RP_MT ):
+ {
+ aStartPoint.X() = rOutputRect.Left() + ( ( rOutputRect.GetWidth() - rBmpOutputSize.Width() ) >> 1 );
+ aStartPoint.Y() = rOutputRect.Top();
+ }
+ break;
+
+ case( RP_RT ):
+ {
+ aStartPoint.X() = rOutputRect.Right() - rBmpOutputSize.Width();
+ aStartPoint.Y() = rOutputRect.Top();
+ }
+ break;
+
+ case( RP_LM ):
+ {
+ aStartPoint.X() = rOutputRect.Left();
+ aStartPoint.Y() = rOutputRect.Top() + ( ( rOutputRect.GetHeight() - rBmpOutputSize.Height() ) >> 1 );
+ }
+ break;
+
+ case( RP_MM ):
+ {
+ aStartPoint.X() = rOutputRect.Left() + ( ( rOutputRect.GetWidth() - rBmpOutputSize.Width() ) >> 1 );
+ aStartPoint.Y() = rOutputRect.Top() + ( ( rOutputRect.GetHeight() - rBmpOutputSize.Height() ) >> 1 );
+ }
+ break;
+
+ case( RP_RM ):
+ {
+ aStartPoint.X() = rOutputRect.Right() - rBmpOutputSize.Width();
+ aStartPoint.Y() = rOutputRect.Top() + ( ( rOutputRect.GetHeight() - rBmpOutputSize.Height() ) >> 1 );
+ }
+ break;
+
+ case( RP_LB ):
+ {
+ aStartPoint.X() = rOutputRect.Left();
+ aStartPoint.Y() = rOutputRect.Bottom() - rBmpOutputSize.Height();
+ }
+ break;
+
+ case( RP_MB ):
+ {
+ aStartPoint.X() = rOutputRect.Left() + ( ( rOutputRect.GetWidth() - rBmpOutputSize.Width() ) >> 1 );
+ aStartPoint.Y() = rOutputRect.Bottom() - rBmpOutputSize.Height();
+ }
+ break;
+
+ case( RP_RB ):
+ {
+ aStartPoint.X() = rOutputRect.Right() - rBmpOutputSize.Width();
+ aStartPoint.Y() = rOutputRect.Bottom() - rBmpOutputSize.Height();
+ }
+ break;
+
+ // default linke obere Ecke
+ default:
+ aStartPoint = rOutputRect.TopLeft();
+ break;
+ }
+
+ // X- oder Y-Positionsoffset beruecksichtigen
+ if( rBmpOffPerCent.Width() )
+ aStartPoint.X() += ( rBmpOutputSize.Width() * rBmpOffPerCent.Width() / 100 );
+
+ if( rBmpOffPerCent.Height() )
+ aStartPoint.Y() += ( rBmpOutputSize.Height() * rBmpOffPerCent.Height() / 100 );
+
+ // echten Startpunkt berechnen ( links oben )
+ if( rBmpOutputSize.Width() && rBmpOutputSize.Height() )
+ {
+ const long nDiffX = aStartPoint.X() - rOutputRect.Left();
+ const long nDiffY = aStartPoint.Y() - rOutputRect.Top();
+
+ if ( nDiffX )
+ {
+ long nCount = nDiffX / rBmpOutputSize.Width() + 1;
+
+ if ( rBmpOffPerCent.Height() && ( nCount & 1L ) )
+ nCount++;
+
+ aStartPoint.X() -= ( nCount * rBmpOutputSize.Width() );
+ }
+
+ if ( nDiffY )
+ {
+ long nCount = nDiffY / rBmpOutputSize.Height() + 1;
+
+ if ( rBmpOffPerCent.Width() && ( nCount & 1L ) )
+ nCount++;
+
+ aStartPoint.Y() -= ( nCount * rBmpOutputSize.Height() );
+ }
+ }
+
+ rStartOffset = Size( aStartPoint.X() - rOutputRect.Left(),
+ aStartPoint.Y() - rOutputRect.Top() );
+ }
+ else
+ {
+ if( bBmpStretch )
+ {
+ rStartOffset = Size(0, 0);
+ rBmpOutputSize = rOutputRect.GetSize();
+ }
+ else
+ {
+ rStartOffset = Size( ( rOutputRect.GetWidth() - rBmpOutputSize.Width() ) >> 1,
+ ( rOutputRect.GetHeight() - rBmpOutputSize.Height() ) >> 1 );
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/makefile.mk b/svx/source/svdraw/makefile.mk
new file mode 100644
index 000000000000..514c5b6d2cbc
--- /dev/null
+++ b/svx/source/svdraw/makefile.mk
@@ -0,0 +1,124 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+TARGET=svdraw
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+LIB1TARGET= $(SLB)$/$(TARGET)-core.lib
+LIB1OBJFILES= \
+ $(SLO)$/svdxcgv.obj \
+ $(SLO)$/svdmodel.obj \
+ $(SLO)$/svdpage.obj \
+ $(SLO)$/svdobj.obj \
+ $(SLO)$/svdedtv1.obj \
+ $(SLO)$/svdcrtv.obj \
+ $(SLO)$/svdograf.obj \
+ $(SLO)$/svdoole2.obj \
+ $(SLO)$/svdhdl.obj \
+ $(SLO)$/svdmrkv.obj \
+ $(SLO)$/svdogrp.obj \
+ $(SLO)$/svdotxln.obj \
+ $(SLO)$/svdotextdecomposition.obj \
+ $(SLO)$/svdotextpathdecomposition.obj \
+ $(SLO)$/svdouno.obj \
+ $(SLO)$/svdpagv.obj \
+ $(SLO)$/svddrgmt.obj \
+ $(SLO)$/svdpntv.obj \
+ $(SLO)$/svdsnpv.obj \
+ $(SLO)$/svdview.obj \
+ $(SLO)$/svdtext.obj \
+ $(SLO)$/svdoashp.obj \
+ $(SLO)$/svdoattr.obj \
+ $(SLO)$/svdotext.obj \
+ $(SLO)$/svdotxat.obj \
+ $(SLO)$/svdotxdr.obj \
+ $(SLO)$/svdotxed.obj \
+ $(SLO)$/svdotxfl.obj \
+ $(SLO)$/svdotxtr.obj \
+ $(SLO)$/svdorect.obj \
+ $(SLO)$/svdoedge.obj \
+ $(SLO)$/svdomeas.obj \
+ $(SLO)$/svdopath.obj \
+ $(SLO)$/svdocapt.obj \
+ $(SLO)$/svdocirc.obj \
+ $(SLO)$/svdopage.obj \
+ $(SLO)$/svdoutl.obj \
+ $(SLO)$/svdovirt.obj \
+ $(SLO)$/svdoutlinercache.obj \
+ $(SLO)$/gradtrns.obj \
+ $(SLO)$/svdattr.obj \
+ $(SLO)$/svddrag.obj \
+ $(SLO)$/svddrgv.obj \
+ $(SLO)$/svdedtv2.obj \
+ $(SLO)$/svdedxv.obj \
+ $(SLO)$/svdetc.obj \
+ $(SLO)$/sdrhittesthelper.obj \
+ $(SLO)$/svdfmtf.obj \
+ $(SLO)$/svdglev.obj \
+ $(SLO)$/svdglue.obj \
+ $(SLO)$/svdhlpln.obj \
+ $(SLO)$/svditer.obj \
+ $(SLO)$/svdlayer.obj \
+ $(SLO)$/svdmark.obj \
+ $(SLO)$/svdmrkv1.obj \
+ $(SLO)$/sdrcomment.obj \
+ $(SLO)$/sdrmasterpagedescriptor.obj \
+ $(SLO)$/sdrpagewindow.obj \
+ $(SLO)$/sdrpaintwindow.obj \
+ $(SLO)$/svdpoev.obj \
+ $(SLO)$/svdtrans.obj \
+ $(SLO)$/svdundo.obj \
+ $(SLO)$/svdviter.obj \
+ $(SLO)$/clonelist.obj \
+ $(SLO)$/svdedtv.obj \
+ $(SLO)$/selectioncontroller.obj \
+ $(SLO)$/polypolygoneditor.obj \
+ $(SLO)$/svdibrow.obj \
+ $(SLO)$/svdomedia.obj
+
+LIB2TARGET= $(SLB)$/$(TARGET).lib
+LIB2OBJFILES= \
+ $(SLO)$/ActionDescriptionProvider.obj \
+ $(SLO)$/impgrfll.obj
+
+SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES)
+
+SRS1NAME=svdstr
+SRC1FILES= svdstr.src
+
+.INCLUDE : target.mk
diff --git a/svx/source/svdraw/polypolygoneditor.cxx b/svx/source/svdraw/polypolygoneditor.cxx
new file mode 100644
index 000000000000..039608f72785
--- /dev/null
+++ b/svx/source/svdraw/polypolygoneditor.cxx
@@ -0,0 +1,193 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+#include "svx/polypolygoneditor.hxx"
+
+namespace sdr {
+
+PolyPolygonEditor::PolyPolygonEditor( const basegfx::B2DPolyPolygon& rPolyPolygon, bool bClosed )
+: maPolyPolygon( rPolyPolygon )
+, mbIsClosed( bClosed )
+{
+}
+
+bool PolyPolygonEditor::DeletePoints( const std::set< sal_uInt16 >& rAbsPoints )
+{
+ bool bPolyPolyChanged = false;
+
+ std::set< sal_uInt16 >::const_reverse_iterator aIter;( rAbsPoints.rbegin() );
+ for( aIter = rAbsPoints.rbegin(); aIter != rAbsPoints.rend(); aIter++ )
+ {
+ sal_uInt32 nPoly, nPnt;
+ if( GetRelativePolyPoint(maPolyPolygon,(*aIter), nPoly, nPnt) )
+ {
+ // remove point
+ basegfx::B2DPolygon aCandidate(maPolyPolygon.getB2DPolygon(nPoly));
+
+ aCandidate.remove(nPnt);
+
+ if( ( mbIsClosed && aCandidate.count() < 3L) || (aCandidate.count() < 2L) )
+ {
+ maPolyPolygon.remove(nPoly);
+ }
+ else
+ {
+ maPolyPolygon.setB2DPolygon(nPoly, aCandidate);
+ }
+
+ bPolyPolyChanged = true;
+ }
+ }
+
+ return bPolyPolyChanged;
+}
+
+bool PolyPolygonEditor::SetSegmentsKind(SdrPathSegmentKind eKind, const std::set< sal_uInt16 >& rAbsPoints )
+{
+ bool bPolyPolyChanged = false;
+
+ std::set< sal_uInt16 >::const_reverse_iterator aIter;( rAbsPoints.rbegin() );
+ for( aIter = rAbsPoints.rbegin(); aIter != rAbsPoints.rend(); aIter++ )
+ {
+ sal_uInt32 nPolyNum, nPntNum;
+
+ if(PolyPolygonEditor::GetRelativePolyPoint(maPolyPolygon, (*aIter), nPolyNum, nPntNum))
+ {
+ // do change at aNewPolyPolygon. Take a look at edge.
+ basegfx::B2DPolygon aCandidate(maPolyPolygon.getB2DPolygon(nPolyNum));
+ bool bCandidateChanged(false);
+ const sal_uInt32 nCount(aCandidate.count());
+
+ if(nCount && (nPntNum + 1 < nCount || aCandidate.isClosed()))
+ {
+ // it's a valid edge, check control point usage
+ const sal_uInt32 nNextIndex((nPntNum + 1) % nCount);
+ const bool bContolUsed(aCandidate.areControlPointsUsed()
+ && (aCandidate.isNextControlPointUsed(nPntNum) || aCandidate.isPrevControlPointUsed(nNextIndex)));
+
+ if(bContolUsed)
+ {
+ if(SDRPATHSEGMENT_TOGGLE == eKind || SDRPATHSEGMENT_LINE == eKind)
+ {
+ // remove control
+ aCandidate.resetNextControlPoint(nPntNum);
+ aCandidate.resetPrevControlPoint(nNextIndex);
+ bCandidateChanged = true;
+ }
+ }
+ else
+ {
+ if(SDRPATHSEGMENT_TOGGLE == eKind || SDRPATHSEGMENT_CURVE == eKind)
+ {
+ // add control
+ const basegfx::B2DPoint aStart(aCandidate.getB2DPoint(nPntNum));
+ const basegfx::B2DPoint aEnd(aCandidate.getB2DPoint(nNextIndex));
+
+ aCandidate.setNextControlPoint(nPntNum, interpolate(aStart, aEnd, (1.0 / 3.0)));
+ aCandidate.setPrevControlPoint(nNextIndex, interpolate(aStart, aEnd, (2.0 / 3.0)));
+ bCandidateChanged = true;
+ }
+ }
+
+ if(bCandidateChanged)
+ {
+ maPolyPolygon.setB2DPolygon(nPolyNum, aCandidate);
+ bPolyPolyChanged = true;
+ }
+ }
+ }
+ }
+
+ return bPolyPolyChanged;
+}
+
+bool PolyPolygonEditor::SetPointsSmooth( basegfx::B2VectorContinuity eFlags, const std::set< sal_uInt16 >& rAbsPoints)
+{
+ bool bPolyPolygonChanged(false);
+
+ std::set< sal_uInt16 >::const_reverse_iterator aIter;( rAbsPoints.rbegin() );
+ for( aIter = rAbsPoints.rbegin(); aIter != rAbsPoints.rend(); aIter++ )
+ {
+ sal_uInt32 nPolyNum, nPntNum;
+
+ if(PolyPolygonEditor::GetRelativePolyPoint(maPolyPolygon, (*aIter), nPolyNum, nPntNum))
+ {
+ // do change at aNewPolyPolygon...
+ basegfx::B2DPolygon aCandidate(maPolyPolygon.getB2DPolygon(nPolyNum));
+
+ // set continuity in point, make sure there is a curve
+ bool bPolygonChanged(false);
+ bPolygonChanged = basegfx::tools::expandToCurveInPoint(aCandidate, nPntNum);
+ bPolygonChanged |= basegfx::tools::setContinuityInPoint(aCandidate, nPntNum, eFlags);
+
+ if(bPolygonChanged)
+ {
+ maPolyPolygon.setB2DPolygon(nPolyNum, aCandidate);
+ bPolyPolygonChanged = true;
+ }
+ }
+ }
+
+ return bPolyPolygonChanged;
+}
+
+bool PolyPolygonEditor::GetRelativePolyPoint( const basegfx::B2DPolyPolygon& rPoly, sal_uInt32 nAbsPnt, sal_uInt32& rPolyNum, sal_uInt32& rPointNum )
+{
+ const sal_uInt32 nPolyCount(rPoly.count());
+ sal_uInt32 nPolyNum(0L);
+
+ while(nPolyNum < nPolyCount)
+ {
+ const sal_uInt32 nPointCount(rPoly.getB2DPolygon(nPolyNum).count());
+
+ if(nAbsPnt < nPointCount)
+ {
+ rPolyNum = nPolyNum;
+ rPointNum = nAbsPnt;
+
+ return true;
+ }
+ else
+ {
+ nPolyNum++;
+ nAbsPnt -= nPointCount;
+ }
+ }
+
+ return false;
+}
+
+} // end of namespace sdr
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/sdrcomment.cxx b/svx/source/svdraw/sdrcomment.cxx
new file mode 100644
index 000000000000..ae6011d6b083
--- /dev/null
+++ b/svx/source/svdraw/sdrcomment.cxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdrcomment.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ Comment::Comment(
+ sal_uInt32 nID,
+ Date aCreationDate,
+ const ::rtl::OUString& rUserName,
+ const ::rtl::OUString& rText,
+ const basegfx::B2DPoint& rPosition)
+ : mnID(nID),
+ maCreationDate(aCreationDate),
+ maUserName(rUserName),
+ maText(rText),
+ maPosition(rPosition)
+ {
+ }
+
+ Comment::~Comment()
+ {
+ }
+
+ sal_Bool Comment::operator==(const Comment& rCandidate) const
+ {
+ return (
+ mnID == rCandidate.mnID
+ && maCreationDate == rCandidate.maCreationDate
+ && maUserName == rCandidate.maUserName
+ && maText == rCandidate.maText
+ && maPosition == rCandidate.maPosition);
+ }
+
+ void Comment::SetCreationDate(Date aNewDate)
+ {
+ if(aNewDate != maCreationDate)
+ {
+ maCreationDate = aNewDate;
+ }
+ }
+
+ void Comment::SetUserName(const ::rtl::OUString& rNewName)
+ {
+ if(rNewName != maUserName)
+ {
+ maUserName = rNewName;
+ }
+ }
+
+ void Comment::SetText(const ::rtl::OUString& rNewText)
+ {
+ if(rNewText != maText)
+ {
+ maText = rNewText;
+ }
+ }
+
+ void Comment::SetPosition(const basegfx::B2DPoint& rNewPos)
+ {
+ if(rNewPos != maPosition)
+ {
+ maPosition = rNewPos;
+ }
+ }
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/sdrhittesthelper.cxx b/svx/source/svdraw/sdrhittesthelper.cxx
new file mode 100644
index 000000000000..5b51232cbd8b
--- /dev/null
+++ b/svx/source/svdraw/sdrhittesthelper.cxx
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/sdrhittesthelper.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/helperhittest3d.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <drawinglayer/processor2d/hittestprocessor2d.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #i101872# new Object HitTest as View-tooling
+
+SdrObject* SdrObjectPrimitiveHit(
+ const SdrObject& rObject,
+ const Point& rPnt,
+ sal_uInt16 nTol,
+ const SdrPageView& rSdrPageView,
+ const SetOfByte* pVisiLayer,
+ bool bTextOnly)
+{
+ SdrObject* pResult = 0;
+
+ if(rObject.GetSubList() && rObject.GetSubList()->GetObjCount())
+ {
+ // group or scene with content. Single 3D objects also have a
+ // true == rObject.GetSubList(), but no content
+ pResult = SdrObjListPrimitiveHit(*rObject.GetSubList(), rPnt, nTol, rSdrPageView, pVisiLayer, bTextOnly);
+ }
+ else
+ {
+ if( rObject.IsVisible() && (!pVisiLayer || pVisiLayer->IsSet(rObject.GetLayer())))
+ {
+ // single object, 3d object, empty scene or empty group. Check if
+ // it's a single 3D object
+ const E3dCompoundObject* pE3dCompoundObject = dynamic_cast< const E3dCompoundObject* >(&rObject);
+
+ if(pE3dCompoundObject)
+ {
+ const basegfx::B2DPoint aHitPosition(rPnt.X(), rPnt.Y());
+
+ if(checkHitSingle3DObject(aHitPosition, *pE3dCompoundObject))
+ {
+ pResult = const_cast< E3dCompoundObject* >(pE3dCompoundObject);
+ }
+ }
+ else
+ {
+ // not a single 3D object; Check in first PageWindow using prmitives (only SC
+ // with split views uses multiple PageWindows nowadays)
+ if(rSdrPageView.PageWindowCount())
+ {
+ const double fLogicTolerance(nTol);
+ const basegfx::B2DPoint aHitPosition(rPnt.X(), rPnt.Y());
+ const sdr::contact::ViewObjectContact& rVOC = rObject.GetViewContact().GetViewObjectContact(
+ rSdrPageView.GetPageWindow(0)->GetObjectContact());
+
+ if(ViewObjectContactPrimitiveHit(rVOC, aHitPosition, fLogicTolerance, bTextOnly))
+ {
+ pResult = const_cast< SdrObject* >(&rObject);
+ }
+ }
+ }
+ }
+ }
+
+ return pResult;
+}
+
+/////////////////////////////////////////////////////////////////////
+
+SdrObject* SdrObjListPrimitiveHit(
+ const SdrObjList& rList,
+ const Point& rPnt,
+ sal_uInt16 nTol,
+ const SdrPageView& rSdrPageView,
+ const SetOfByte* pVisiLayer,
+ bool bTextOnly)
+{
+ sal_uInt32 nObjNum(rList.GetObjCount());
+ SdrObject* pRetval = 0;
+
+ while(!pRetval && nObjNum > 0)
+ {
+ nObjNum--;
+ SdrObject* pObj = rList.GetObj(nObjNum);
+
+ pRetval = SdrObjectPrimitiveHit(*pObj, rPnt, nTol, rSdrPageView, pVisiLayer, bTextOnly);
+ }
+
+ return pRetval;
+}
+
+/////////////////////////////////////////////////////////////////////
+
+bool ViewObjectContactPrimitiveHit(
+ const sdr::contact::ViewObjectContact& rVOC,
+ const basegfx::B2DPoint& rHitPosition,
+ double fLogicHitTolerance,
+ bool bTextOnly)
+{
+ basegfx::B2DRange aObjectRange(rVOC.getObjectRange());
+
+ if(!aObjectRange.isEmpty())
+ {
+ // first do a rough B2DRange based HitTest; do not forget to
+ // include the HitTolerance if given
+ if(basegfx::fTools::more(fLogicHitTolerance, 0.0))
+ {
+ aObjectRange.grow(fLogicHitTolerance);
+ }
+
+ if(aObjectRange.isInside(rHitPosition))
+ {
+ // get primitive sequence
+ sdr::contact::DisplayInfo aDisplayInfo;
+ const drawinglayer::primitive2d::Primitive2DSequence& rSequence(rVOC.getPrimitive2DSequence(aDisplayInfo));
+
+ if(rSequence.hasElements())
+ {
+ // create a HitTest processor
+ const drawinglayer::geometry::ViewInformation2D& rViewInformation2D = rVOC.GetObjectContact().getViewInformation2D();
+ drawinglayer::processor2d::HitTestProcessor2D aHitTestProcessor2D(
+ rViewInformation2D,
+ rHitPosition,
+ fLogicHitTolerance,
+ bTextOnly);
+
+ // feed it with the primitives
+ aHitTestProcessor2D.process(rSequence);
+
+ // deliver result
+ return aHitTestProcessor2D.getHit();
+ }
+ }
+ }
+
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/sdrmasterpagedescriptor.cxx b/svx/source/svdraw/sdrmasterpagedescriptor.cxx
new file mode 100644
index 000000000000..5f55e4d1d242
--- /dev/null
+++ b/svx/source/svdraw/sdrmasterpagedescriptor.cxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdrmasterpagedescriptor.hxx>
+#include <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
+#include <svx/svdpage.hxx>
+
+// #i42075#
+#include <svx/svdobj.hxx>
+#include <svx/xfillit0.hxx>
+#include <svl/itemset.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ // ViewContact part
+ sdr::contact::ViewContact* MasterPageDescriptor::CreateObjectSpecificViewContact()
+ {
+ return new sdr::contact::ViewContactOfMasterPageDescriptor(*this);
+ }
+
+ MasterPageDescriptor::MasterPageDescriptor(SdrPage& aOwnerPage, SdrPage& aUsedPage)
+ : maOwnerPage(aOwnerPage),
+ maUsedPage(aUsedPage),
+ mpViewContact(0L)
+ {
+ // all layers visible
+ maVisibleLayers.SetAll();
+
+ // register at used page
+ maUsedPage.AddPageUser(*this);
+ }
+
+ MasterPageDescriptor::~MasterPageDescriptor()
+ {
+ // de-register at used page
+ maUsedPage.RemovePageUser(*this);
+
+ if(mpViewContact)
+ {
+ delete mpViewContact;
+ mpViewContact = 0L;
+ }
+ }
+
+ // ViewContact part
+ sdr::contact::ViewContact& MasterPageDescriptor::GetViewContact() const
+ {
+ if(!mpViewContact)
+ {
+ const_cast< MasterPageDescriptor* >(this)->mpViewContact =
+ const_cast< MasterPageDescriptor* >(this)->CreateObjectSpecificViewContact();
+ }
+
+ return *mpViewContact;
+ }
+
+ // this method is called form the destructor of the referenced page.
+ // do all necessary action to forget the page. It is not necessary to call
+ // RemovePageUser(), that is done form the destructor.
+ void MasterPageDescriptor::PageInDestruction(const SdrPage& /*rPage*/)
+ {
+ maOwnerPage.TRG_ClearMasterPage();
+ }
+
+ void MasterPageDescriptor::SetVisibleLayers(const SetOfByte& rNew)
+ {
+ if(rNew != maVisibleLayers)
+ {
+ maVisibleLayers = rNew;
+ GetViewContact().ActionChanged();
+ }
+ }
+
+ // operators
+ sal_Bool MasterPageDescriptor::operator==(const MasterPageDescriptor& rCandidate) const
+ {
+ return (&maOwnerPage == &rCandidate.maOwnerPage
+ && &maUsedPage == &rCandidate.maUsedPage
+ && maVisibleLayers == rCandidate.maVisibleLayers);
+ }
+
+ sal_Bool MasterPageDescriptor::operator!=(const MasterPageDescriptor& rCandidate) const
+ {
+ return (&maOwnerPage != &rCandidate.maOwnerPage
+ || &maUsedPage != &rCandidate.maUsedPage
+ || maVisibleLayers != rCandidate.maVisibleLayers);
+ }
+
+ const SdrPageProperties* MasterPageDescriptor::getCorrectSdrPageProperties() const
+ {
+ const SdrPage* pCorrectPage = &GetOwnerPage();
+ const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties();
+
+ if(XFILL_NONE == ((const XFillStyleItem&)pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
+ {
+ pCorrectPage = &GetUsedPage();
+ pCorrectProperties = &pCorrectPage->getSdrPageProperties();
+ }
+
+ if(pCorrectPage->IsMasterPage() && !pCorrectProperties->GetStyleSheet())
+ {
+ // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets,
+ // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all
+ // MasterPages should have a StyleSheet excactly for this reason, but historically
+ // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others).
+ pCorrectProperties = 0;
+ }
+
+ return pCorrectProperties;
+ }
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/sdrpagewindow.cxx b/svx/source/svdraw/sdrpagewindow.cxx
new file mode 100644
index 000000000000..c3f8a2e2bd1e
--- /dev/null
+++ b/svx/source/svdraw/sdrpagewindow.cxx
@@ -0,0 +1,467 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdrpagewindow.hxx>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/util/XModeChangeBroadcaster.hpp>
+#include <comphelper/processfactory.hxx>
+#include <vcl/svapp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpagv.hxx>
+#include <sdrpaintwindow.hxx>
+#include <svx/sdr/contact/objectcontactofpageview.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <osl/mutex.hxx>
+#include <svx/fmview.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SdrPageWindow::GetControlContainer( bool _bCreateIfNecessary ) const
+{
+ if ( !mxControlContainer.is() && _bCreateIfNecessary )
+ {
+ SdrView& rView = GetPageView().GetView();
+
+ const SdrPaintWindow& rPaintWindow( GetOriginalPaintWindow() ? *GetOriginalPaintWindow() : GetPaintWindow() );
+ if ( rPaintWindow.OutputToWindow() && !rView.IsPrintPreview() )
+ {
+ Window& rWindow = dynamic_cast< Window& >( rPaintWindow.GetOutputDevice() );
+ const_cast< SdrPageWindow* >( this )->mxControlContainer = VCLUnoHelper::CreateControlContainer( &rWindow );
+
+ // #100394# xC->setVisible triggers window->Show() and this has
+ // problems when the view is not completely constructed which may
+ // happen when loading. This leads to accessibility broadcasts which
+ // throw asserts due to the not finished view. All this chan be avoided
+ // since xC->setVisible is here called only for the side effect in
+ // UnoControlContainer::setVisible(...) which calls createPeer(...).
+ // This will now be called directly from here.
+
+ // UnoContainerModel erzeugen
+ // uno::Reference< awt::XWindow > xC(mxControlContainer, uno::UNO_QUERY);
+ // CreateControlContainer() is only used from
+ // , thus it seems not necessary to make
+ // it visible her at all.
+ // #58917# Das Show darf nicht am VCL-Fenster landen, weil dann Assertion vom SFX
+ // BOOL bVis = pWindow->IsVisible();
+ // xC->setVisible(TRUE);
+ // if ( !bVis )
+ // pWindow->Hide();
+ // if( !mxContext.is() && bVisible )
+ // // Es ist ein TopWindow, also automatisch anzeigen
+ // createPeer( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > (), ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > () );
+
+ uno::Reference< awt::XControl > xControl(mxControlContainer, uno::UNO_QUERY);
+ if(xControl.is())
+ {
+ uno::Reference< uno::XInterface > xContext = xControl->getContext();
+ if(!xContext.is())
+ {
+ xControl->createPeer( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > (),
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > () );
+ }
+ }
+ }
+ else
+ {
+ // Printer und VirtualDevice, bzw. kein OutDev
+ uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+ if( xFactory.is() )
+ {
+ const_cast< SdrPageWindow* >( this )->mxControlContainer = uno::Reference< awt::XControlContainer >(xFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlContainer")), uno::UNO_QUERY);
+ uno::Reference< awt::XControlModel > xModel(xFactory->createInstance(rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlContainerModel")), uno::UNO_QUERY);
+ uno::Reference< awt::XControl > xControl(mxControlContainer, uno::UNO_QUERY);
+ if (xControl.is())
+ xControl->setModel(xModel);
+
+ OutputDevice& rOutDev = rPaintWindow.GetOutputDevice();
+ Point aPosPix = rOutDev.GetMapMode().GetOrigin();
+ Size aSizePix = rOutDev.GetOutputSizePixel();
+
+ uno::Reference< awt::XWindow > xContComp(mxControlContainer, uno::UNO_QUERY);
+ if( xContComp.is() )
+ xContComp->setPosSize(aPosPix.X(), aPosPix.Y(), aSizePix.Width(), aSizePix.Height(), awt::PosSize::POSSIZE);
+ }
+ }
+
+ FmFormView* pViewAsFormView = dynamic_cast< FmFormView* >( &rView );
+ if ( pViewAsFormView )
+ pViewAsFormView->InsertControlContainer(mxControlContainer);
+ }
+ return mxControlContainer;
+}
+
+SdrPageWindow::SdrPageWindow(SdrPageView& rPageView, SdrPaintWindow& rPaintWindow)
+: mpObjectContact(0L),
+ mrPageView(rPageView),
+ mpPaintWindow(&rPaintWindow),
+ mpOriginalPaintWindow(NULL)
+{
+}
+
+SdrPageWindow::~SdrPageWindow()
+{
+ // #110094#, #i26631#
+ ResetObjectContact();
+
+ if (mxControlContainer.is())
+ {
+ SdrView& rView = GetPageView().GetView();
+
+ // notify derived views
+ FmFormView* pViewAsFormView = dynamic_cast< FmFormView* >( &rView );
+ if ( pViewAsFormView )
+ pViewAsFormView->RemoveControlContainer(mxControlContainer);
+
+ // dispose the control container
+ uno::Reference< lang::XComponent > xComponent(mxControlContainer, uno::UNO_QUERY);
+ xComponent->dispose();
+ }
+}
+
+// #110094# ObjectContact section
+sdr::contact::ObjectContact* SdrPageWindow::CreateViewSpecificObjectContact()
+{
+ return new sdr::contact::ObjectContactOfPageView(*this);
+}
+
+// OVERLAYMANAGER
+::sdr::overlay::OverlayManager* SdrPageWindow::GetOverlayManager() const
+{
+ return GetPaintWindow().GetOverlayManager();
+}
+
+void SdrPageWindow::patchPaintWindow(SdrPaintWindow& rPaintWindow)
+{
+ mpOriginalPaintWindow = mpPaintWindow;
+ mpPaintWindow = &rPaintWindow;
+}
+
+void SdrPageWindow::unpatchPaintWindow()
+{
+ DBG_ASSERT(mpOriginalPaintWindow, "SdrPageWindow::unpatchPaintWindow: paint window not patched!" );
+ if ( mpOriginalPaintWindow )
+ {
+ mpPaintWindow = mpOriginalPaintWindow;
+ mpOriginalPaintWindow = NULL;
+ }
+}
+
+void SdrPageWindow::PrePaint()
+{
+ // give OC the chance to do ProcessDisplay preparations
+ if(HasObjectContact())
+ {
+ GetObjectContact().PrepareProcessDisplay();
+ }
+}
+
+void SdrPageWindow::PrepareRedraw(const Region& rReg)
+{
+ // evtl. give OC the chance to do ProcessDisplay preparations
+ if(HasObjectContact())
+ {
+ GetObjectContact().PrepareProcessDisplay();
+ }
+
+ // remember eventually changed RedrawArea at PaintWindow for usage with
+ // overlay and PreRenderDevice stuff
+ GetPaintWindow().SetRedrawRegion(rReg);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// clip test
+#ifdef CLIPPER_TEST
+#include <svx/svdopath.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include <basegfx/polygon/b2dpolygoncutandtouch.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygonclipper.hxx>
+
+// for ::std::sort
+#include <algorithm>
+
+namespace
+{
+ void impPaintStrokePolygon(const basegfx::B2DPolygon& rCandidate, OutputDevice& rOutDev, Color aColor)
+ {
+ basegfx::B2DPolygon aCandidate(rCandidate);
+
+ if(aCandidate.areControlPointsUsed())
+ {
+ aCandidate = basegfx::tools::adaptiveSubdivideByAngle(rCandidate);
+ }
+
+ if(aCandidate.count())
+ {
+ const sal_uInt32 nLoopCount(aCandidate.isClosed() ? aCandidate.count() : aCandidate.count() - 1L);
+ rOutDev.SetFillColor();
+ rOutDev.SetLineColor(aColor);
+
+ for(sal_uInt32 a(0L); a < nLoopCount; a++)
+ {
+ const basegfx::B2DPoint aBStart(aCandidate.getB2DPoint(a));
+ const basegfx::B2DPoint aBEnd(aCandidate.getB2DPoint((a + 1) % aCandidate.count()));
+ const Point aStart(FRound(aBStart.getX()), FRound(aBStart.getY()));
+ const Point aEnd(FRound(aBEnd.getX()), FRound(aBEnd.getY()));
+ rOutDev.DrawLine(aStart, aEnd);
+ }
+ }
+ }
+
+ void impTryTest(const SdrPageView& rPageView, OutputDevice& rOutDev)
+ {
+ if(rPageView.GetPage() && rPageView.GetPage()->GetObjCount() >= 2L)
+ {
+ SdrPage* pPage = rPageView.GetPage();
+ SdrObject* pObjA = pPage->GetObj(0L);
+
+ if(pObjA && pObjA->ISA(SdrPathObj))
+ {
+ basegfx::B2DPolyPolygon aPolyA(((SdrPathObj*)pObjA)->GetPathPoly());
+ aPolyA = basegfx::tools::correctOrientations(aPolyA);
+
+ basegfx::B2DPolyPolygon aPolyB;
+
+ for(sal_uInt32 a(1L); a < rPageView.GetPage()->GetObjCount(); a++)
+ {
+ SdrObject* pObjB = pPage->GetObj(a);
+
+ if(pObjB && pObjB->ISA(SdrPathObj))
+ {
+ basegfx::B2DPolyPolygon aCandidate(((SdrPathObj*)pObjB)->GetPathPoly());
+ aCandidate = basegfx::tools::correctOrientations(aCandidate);
+ aPolyB.append(aCandidate);
+ }
+ }
+
+ if(aPolyA.count() && aPolyA.isClosed() && aPolyB.count())
+ {
+ // poly A is the clipregion, clip poly b against it. Algo depends on
+ // poly b being closed.
+ basegfx::B2DPolyPolygon aResult(basegfx::tools::clipPolyPolygonOnPolyPolygon(aPolyB, aPolyA));
+
+ for(sal_uInt32 a(0L); a < aResult.count(); a++)
+ {
+ Color aColor(rand()%255, rand()%255, rand()%255);
+ impPaintStrokePolygon(aResult.getB2DPolygon(a), rOutDev, aColor);
+ }
+
+ bool bBla = true;
+ }
+ }
+ }
+ }
+} // end of anonymous namespace
+#endif // CLIPPER_TEST
+
+//////////////////////////////////////////////////////////////////////////////
+
+void SdrPageWindow::RedrawAll(sdr::contact::ViewObjectContactRedirector* pRedirector) const
+{
+ // set Redirector
+ GetObjectContact().SetViewObjectContactRedirector(pRedirector);
+
+ // set PaintingPageView
+ const SdrView& rView = mrPageView.GetView();
+ SdrModel& rModel = *((SdrModel*)rView.GetModel());
+
+ // get to be processed layers
+ const sal_Bool bPrinter(GetPaintWindow().OutputToPrinter());
+ SetOfByte aProcessLayers = bPrinter ? mrPageView.GetPrintableLayers() : mrPageView.GetVisibleLayers();
+
+ // create PaintInfoRec, #114359# use Rectangle only temporarily
+ const Region& rRegion = GetPaintWindow().GetRedrawRegion();
+
+ // create processing data
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ // Draw all layers. do NOT draw form layer from CompleteRedraw, this is done separate
+ // as a single layer paint
+ const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin();
+ const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName(), sal_False);
+ aProcessLayers.Clear(nControlLayerId);
+
+ // still something to paint?
+ if(!aProcessLayers.IsEmpty())
+ {
+ aDisplayInfo.SetProcessLayers(aProcessLayers);
+
+ // Set region as redraw area
+ aDisplayInfo.SetRedrawArea(rRegion);
+
+ // Draw/Impress
+ aDisplayInfo.SetPageProcessingActive(rView.IsPagePaintingAllowed()); // #i72889#
+
+ // paint page
+ GetObjectContact().ProcessDisplay(aDisplayInfo);
+ }
+
+ // reset redirector
+ GetObjectContact().SetViewObjectContactRedirector(0L);
+
+ // LineClip test
+#ifdef CLIPPER_TEST
+ if(true)
+ {
+ impTryTest(GetPageView(), GetPaintWindow().GetOutputDevice());
+ }
+#endif // CLIPPER_TEST
+}
+
+void SdrPageWindow::RedrawLayer(const SdrLayerID* pId, sdr::contact::ViewObjectContactRedirector* pRedirector) const
+{
+ // set redirector
+ GetObjectContact().SetViewObjectContactRedirector(pRedirector);
+
+ // set PaintingPageView
+ const SdrView& rView = mrPageView.GetView();
+ SdrModel& rModel = *((SdrModel*)rView.GetModel());
+
+ // get the layers to process
+ const sal_Bool bPrinter(GetPaintWindow().OutputToPrinter());
+ SetOfByte aProcessLayers = bPrinter ? mrPageView.GetPrintableLayers() : mrPageView.GetVisibleLayers();
+
+ // is the given layer visible at all?
+ if(aProcessLayers.IsSet(*pId))
+ {
+ // find out if we are painting the ControlLayer
+ const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin();
+ const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName(), sal_False);
+ const sal_Bool bControlLayerProcessingActive(pId && nControlLayerId == *pId);
+
+ // create PaintInfoRec, use Rectangle only temporarily
+ const Region& rRegion = GetPaintWindow().GetRedrawRegion();
+
+ // create processing data
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ // is it the control layer? If Yes, set flag
+ aDisplayInfo.SetControlLayerProcessingActive(bControlLayerProcessingActive);
+
+ // Draw just the one given layer
+ aProcessLayers.ClearAll();
+ aProcessLayers.Set(*pId);
+
+ aDisplayInfo.SetProcessLayers(aProcessLayers);
+
+ // Set region as redraw area
+ aDisplayInfo.SetRedrawArea(rRegion);
+
+ // Writer or calc, coming from original RedrawOneLayer.
+ // #i72889# no page painting for layer painting
+ aDisplayInfo.SetPageProcessingActive(false);
+
+ // paint page
+ GetObjectContact().ProcessDisplay(aDisplayInfo);
+ }
+
+ // reset redirector
+ GetObjectContact().SetViewObjectContactRedirector(0L);
+}
+
+// Invalidate call, used from ObjectContact(OfPageView) in InvalidatePartOfView(...)
+void SdrPageWindow::InvalidatePageWindow(const basegfx::B2DRange& rRange)
+{
+ if(GetPageView().IsVisible() && GetPaintWindow().OutputToWindow())
+ {
+ const SvtOptionsDrawinglayer aDrawinglayerOpt;
+ Window& rWindow(static_cast< Window& >(GetPaintWindow().GetOutputDevice()));
+ basegfx::B2DRange aDiscreteRange(rRange);
+ aDiscreteRange.transform(rWindow.GetViewTransformation());
+
+ if(aDrawinglayerOpt.IsAntiAliasing())
+ {
+ // invalidate one discrete unit more under the assumption that AA
+ // needs one pixel more
+ aDiscreteRange.grow(1.0);
+ }
+
+ const Rectangle aVCLDiscreteRectangle(
+ (sal_Int32)floor(aDiscreteRange.getMinX()), (sal_Int32)floor(aDiscreteRange.getMinY()),
+ (sal_Int32)ceil(aDiscreteRange.getMaxX()), (sal_Int32)ceil(aDiscreteRange.getMaxY()));
+ const bool bWasMapModeEnabled(rWindow.IsMapModeEnabled());
+
+ rWindow.EnableMapMode(false);
+ rWindow.Invalidate(aVCLDiscreteRectangle, INVALIDATE_NOERASE);
+ rWindow.EnableMapMode(bWasMapModeEnabled);
+ }
+}
+
+// #110094# ObjectContact section
+sdr::contact::ObjectContact& SdrPageWindow::GetObjectContact() const
+{
+ if(!mpObjectContact)
+ {
+ ((SdrPageWindow*)this)->mpObjectContact = ((SdrPageWindow*)this)->CreateViewSpecificObjectContact();
+ }
+
+ return *mpObjectContact;
+}
+
+bool SdrPageWindow::HasObjectContact() const
+{
+ return ( mpObjectContact != NULL );
+}
+
+// #i26631#
+void SdrPageWindow::ResetObjectContact()
+{
+ if(mpObjectContact)
+ {
+ delete mpObjectContact;
+ mpObjectContact = 0L;
+ }
+}
+
+void SdrPageWindow::SetDesignMode( bool _bDesignMode ) const
+{
+ const ::sdr::contact::ObjectContactOfPageView* pOC = dynamic_cast< const ::sdr::contact::ObjectContactOfPageView* >( &GetObjectContact() );
+ DBG_ASSERT( pOC, "SdrPageWindow::SetDesignMode: invalid object contact!" );
+ if ( pOC )
+ pOC->SetUNOControlsDesignMode( _bDesignMode );
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/sdrpaintwindow.cxx b/svx/source/svdraw/sdrpaintwindow.cxx
new file mode 100644
index 000000000000..ba77883b38ab
--- /dev/null
+++ b/svx/source/svdraw/sdrpaintwindow.cxx
@@ -0,0 +1,315 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <sdrpaintwindow.hxx>
+#include <svx/sdr/overlay/overlaymanagerbuffered.hxx>
+#include <svx/svdpntv.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/svapp.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrPreRenderDevice::SdrPreRenderDevice(OutputDevice& rOriginal)
+: mrOutputDevice(rOriginal)
+{
+}
+
+SdrPreRenderDevice::~SdrPreRenderDevice()
+{
+}
+
+void SdrPreRenderDevice::PreparePreRenderDevice()
+{
+ // compare size of maPreRenderDevice with size of visible area
+ if(maPreRenderDevice.GetOutputSizePixel() != mrOutputDevice.GetOutputSizePixel())
+ {
+ maPreRenderDevice.SetOutputSizePixel(mrOutputDevice.GetOutputSizePixel());
+ }
+
+ // Also compare the MapModes for zoom/scroll changes
+ if(maPreRenderDevice.GetMapMode() != mrOutputDevice.GetMapMode())
+ {
+ maPreRenderDevice.SetMapMode(mrOutputDevice.GetMapMode());
+ }
+
+ // #i29186#
+ maPreRenderDevice.SetDrawMode(mrOutputDevice.GetDrawMode());
+ maPreRenderDevice.SetSettings(mrOutputDevice.GetSettings());
+}
+
+void SdrPreRenderDevice::OutputPreRenderDevice(const Region& rExpandedRegion)
+{
+ // region to pixels
+ Region aRegionPixel(mrOutputDevice.LogicToPixel(rExpandedRegion));
+ RegionHandle aRegionHandle(aRegionPixel.BeginEnumRects());
+ Rectangle aRegionRectanglePixel;
+
+ // MapModes off
+ sal_Bool bMapModeWasEnabledDest(mrOutputDevice.IsMapModeEnabled());
+ sal_Bool bMapModeWasEnabledSource(maPreRenderDevice.IsMapModeEnabled());
+ mrOutputDevice.EnableMapMode(sal_False);
+ maPreRenderDevice.EnableMapMode(sal_False);
+
+ while(aRegionPixel.GetEnumRects(aRegionHandle, aRegionRectanglePixel))
+ {
+ // for each rectangle, copy the area
+ const Point aTopLeft(aRegionRectanglePixel.TopLeft());
+ const Size aSize(aRegionRectanglePixel.GetSize());
+
+ mrOutputDevice.DrawOutDev(
+ aTopLeft, aSize,
+ aTopLeft, aSize,
+ maPreRenderDevice);
+
+#ifdef DBG_UTIL
+ // #i74769#
+ static bool bDoPaintForVisualControlRegion(false);
+ if(bDoPaintForVisualControlRegion)
+ {
+ Color aColor((((((rand()&0x7f)|0x80)<<8L)|((rand()&0x7f)|0x80))<<8L)|((rand()&0x7f)|0x80));
+ mrOutputDevice.SetLineColor(aColor);
+ mrOutputDevice.SetFillColor();
+ mrOutputDevice.DrawRect(aRegionRectanglePixel);
+ }
+#endif
+ }
+
+ aRegionPixel.EndEnumRects(aRegionHandle);
+
+ mrOutputDevice.EnableMapMode(bMapModeWasEnabledDest);
+ maPreRenderDevice.EnableMapMode(bMapModeWasEnabledSource);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrPaintWindow::impCreateOverlayManager(const bool bUseBuffer)
+{
+ // When the buffer usage has changed then we have to create a new
+ // overlay manager. Save the current one so that later we can move its
+ // overlay objects to the new one.
+ sdr::overlay::OverlayManager* pOldOverlayManager = NULL;
+
+ if(mbUseBuffer != bUseBuffer)
+ {
+ mbUseBuffer = bUseBuffer;
+ pOldOverlayManager = mpOverlayManager;
+ mpOverlayManager = NULL;
+ }
+
+ // not yet one created?
+ if(!mpOverlayManager)
+ {
+ // is it a window?
+ if(OUTDEV_WINDOW == GetOutputDevice().GetOutDevType())
+ {
+ // decide which OverlayManager to use
+ if(GetPaintView().IsBufferedOverlayAllowed() && mbUseBuffer)
+ {
+ // buffered OverlayManager, buffers it's background and refreshes from there
+ // for pure overlay changes (no system redraw). The 3rd parameter specifies
+ // if that refresh itself will use a 2nd vdev to avoid flickering.
+ // Also hand over the evtl. existing old OverlayManager; this means to take over
+ // the registered OverlayObjects from it
+ mpOverlayManager = new ::sdr::overlay::OverlayManagerBuffered(GetOutputDevice(), pOldOverlayManager, true);
+ }
+ else
+ {
+ // unbuffered OverlayManager, just invalidates places where changes
+ // take place
+ // Also hand over the evtl. existing old OverlayManager; this means to take over
+ // the registered OverlayObjects from it
+ mpOverlayManager = new ::sdr::overlay::OverlayManager(GetOutputDevice(), pOldOverlayManager);
+ }
+
+ OSL_ENSURE(mpOverlayManager, "SdrPaintWindow::SdrPaintWindow: Could not allocate an overlayManager (!)");
+
+ // Request a repaint so that the buffered overlay manager fills
+ // its buffer properly. This is a workaround for missing buffer
+ // updates.
+ Window* pWindow = dynamic_cast<Window*>(&GetOutputDevice());
+ if (pWindow != NULL)
+ pWindow->Invalidate();
+
+ Color aColA(GetPaintView().getOptionsDrawinglayer().GetStripeColorA());
+ Color aColB(GetPaintView().getOptionsDrawinglayer().GetStripeColorB());
+
+ if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ aColA = aColB = Application::GetSettings().GetStyleSettings().GetHighlightColor();
+ aColB.Invert();
+ }
+
+ mpOverlayManager->setStripeColorA(aColA);
+ mpOverlayManager->setStripeColorB(aColB);
+ mpOverlayManager->setStripeLengthPixel(GetPaintView().getOptionsDrawinglayer().GetStripeLength());
+ }
+ }
+
+ // OverlayObjects are transfered for the evtl. newly created OverlayManager by handing over
+ // at construction time
+ if(pOldOverlayManager)
+ {
+ // The old overlay manager is not used anymore and can be (has to be) deleted.
+ delete pOldOverlayManager;
+ }
+}
+
+SdrPaintWindow::SdrPaintWindow(SdrPaintView& rNewPaintView, OutputDevice& rOut)
+: mrOutputDevice(rOut),
+ mrPaintView(rNewPaintView),
+ mpOverlayManager(0L),
+ mpPreRenderDevice(0L),
+ mbTemporaryTarget(false), // #i72889#
+ mbUseBuffer(true)
+{
+}
+
+SdrPaintWindow::~SdrPaintWindow()
+{
+ if(mpOverlayManager)
+ {
+ delete mpOverlayManager;
+ mpOverlayManager = 0L;
+ }
+
+ DestroyPreRenderDevice();
+}
+
+::sdr::overlay::OverlayManager* SdrPaintWindow::GetOverlayManager() const
+{
+ if(!mpOverlayManager)
+ {
+ // Create buffered overlay manager by default.
+ const_cast< SdrPaintWindow* >(this)->impCreateOverlayManager(true);
+ }
+
+ return mpOverlayManager;
+}
+
+Rectangle SdrPaintWindow::GetVisibleArea() const
+{
+ Size aVisSizePixel(GetOutputDevice().GetOutputSizePixel());
+ return Rectangle(GetOutputDevice().PixelToLogic(Rectangle(Point(0,0), aVisSizePixel)));
+}
+
+sal_Bool SdrPaintWindow::OutputToRecordingMetaFile() const
+{
+ GDIMetaFile* pMetaFile = mrOutputDevice.GetConnectMetaFile();
+ return (pMetaFile && pMetaFile->IsRecord() && !pMetaFile->IsPause());
+}
+
+void SdrPaintWindow::PreparePreRenderDevice()
+{
+ const sal_Bool bPrepareBufferedOutput(
+ mrPaintView.IsBufferedOutputAllowed()
+ && !OutputToPrinter()
+ && !OutputToVirtualDevice()
+ && !OutputToRecordingMetaFile());
+
+ if(bPrepareBufferedOutput)
+ {
+ if(!mpPreRenderDevice)
+ {
+ mpPreRenderDevice = new SdrPreRenderDevice(mrOutputDevice);
+ }
+ }
+ else
+ {
+ DestroyPreRenderDevice();
+ }
+
+ if(mpPreRenderDevice)
+ {
+ mpPreRenderDevice->PreparePreRenderDevice();
+ }
+}
+
+void SdrPaintWindow::DestroyPreRenderDevice()
+{
+ if(mpPreRenderDevice)
+ {
+ delete mpPreRenderDevice;
+ mpPreRenderDevice = 0L;
+ }
+}
+
+void SdrPaintWindow::OutputPreRenderDevice(const Region& rExpandedRegion)
+{
+ if(mpPreRenderDevice)
+ {
+ mpPreRenderDevice->OutputPreRenderDevice(rExpandedRegion);
+ }
+}
+
+// #i73602# add flag if buffer shall be used
+void SdrPaintWindow::DrawOverlay(const Region& rRegion, bool bUseBuffer)
+{
+ // ## force creation of OverlayManager since the first repaint needs to
+ // save the background to get a controlled start into overlay mechanism
+ impCreateOverlayManager(bUseBuffer);
+
+ if(mpOverlayManager && !OutputToPrinter())
+ {
+ if(mpPreRenderDevice && bUseBuffer)
+ {
+ mpOverlayManager->completeRedraw(rRegion, &mpPreRenderDevice->GetPreRenderDevice());
+ }
+ else
+ {
+ mpOverlayManager->completeRedraw(rRegion);
+ }
+ }
+}
+
+void SdrPaintWindow::HideOverlay(const Region& rRegion)
+{
+ if(mpOverlayManager && !OutputToPrinter())
+ {
+ if(!mpPreRenderDevice)
+ {
+ mpOverlayManager->restoreBackground(rRegion);
+ }
+ }
+}
+
+const Region& SdrPaintWindow::GetRedrawRegion() const
+{
+ return maRedrawRegion;
+}
+
+void SdrPaintWindow::SetRedrawRegion(const Region& rNew)
+{
+ maRedrawRegion = rNew;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/selectioncontroller.cxx b/svx/source/svdraw/selectioncontroller.cxx
new file mode 100644
index 000000000000..375f9bfcb999
--- /dev/null
+++ b/svx/source/svdraw/selectioncontroller.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <tools/debug.hxx>
+#include <svx/selectioncontroller.hxx>
+
+namespace sdr
+{
+
+bool SelectionController::onKeyInput(const KeyEvent& /*rKEvt*/, Window* /*pWin*/)
+{
+ return false;
+}
+
+bool SelectionController::onMouseButtonDown(const MouseEvent& /*rMEvt*/, Window* /*pWin*/)
+{
+ return false;
+}
+
+bool SelectionController::onMouseButtonUp(const MouseEvent& /*rMEvt*/, Window* /*pWin*/)
+{
+ return false;
+}
+
+bool SelectionController::onMouseMove(const MouseEvent& /*rMEvt*/, Window* /*pWin*/)
+{
+ return false;
+}
+
+void SelectionController::onSelectionHasChanged()
+{
+}
+
+void SelectionController::GetState( SfxItemSet& /*rSet*/ )
+{
+}
+
+void SelectionController::Execute( SfxRequest& /*rReq*/ )
+{
+}
+
+bool SelectionController::DeleteMarked()
+{
+ return false;
+}
+
+bool SelectionController::GetAttributes(SfxItemSet& /*rTargetSet*/, bool /*bOnlyHardAttr*/) const
+{
+ return false;
+}
+
+bool SelectionController::SetAttributes(const SfxItemSet& /*rSet*/, bool /*bReplaceAll*/)
+{
+ return false;
+}
+
+bool SelectionController::GetStyleSheet( SfxStyleSheet* &/*rpStyleSheet*/ ) const
+{
+ return false;
+}
+
+bool SelectionController::SetStyleSheet( SfxStyleSheet* /*pStyleSheet*/, bool /*bDontRemoveHardAttr*/ )
+{
+ return false;
+}
+
+bool SelectionController::GetMarkedObjModel( SdrPage* /*pNewPage*/ )
+{
+ return false;
+}
+
+bool SelectionController::PasteObjModel( const SdrModel& /*rModel*/ )
+{
+ return false;
+}
+
+bool SelectionController::TakeFormatPaintBrush( boost::shared_ptr< SfxItemSet >& /*rFormatSet*/ )
+{
+ return false;
+}
+
+bool SelectionController::ApplyFormatPaintBrush( SfxItemSet& /*rFormatSet*/, bool /*bNoCharacterFormats*/, bool /*bNoParagraphFormats*/ )
+{
+ return false;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
new file mode 100644
index 000000000000..6b0253b1e1d2
--- /dev/null
+++ b/svx/source/svdraw/svdattr.cxx
@@ -0,0 +1,2432 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+
+#include <com/sun/star/drawing/TextFitToSizeType.hpp>
+#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+#include <com/sun/star/drawing/TextAnimationKind.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/drawing/TextAnimationDirection.hpp>
+#include <com/sun/star/drawing/ConnectorType.hpp>
+#include <com/sun/star/drawing/MeasureKind.hpp>
+#include <com/sun/star/drawing/MeasureTextHorzPos.hpp>
+#include <com/sun/star/drawing/MeasureTextVertPos.hpp>
+#include <com/sun/star/drawing/CircleKind.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <unotools/intlwrapper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/svdattr.hxx>
+#include <svx/svdattrx.hxx>
+#include <svx/svdpool.hxx>
+
+#include <svl/solar.hrc>
+#include "editeng/xmlcnitm.hxx"
+
+#include <svx/svxids.hrc>
+#include <svx/xtable.hxx> // fuer RGB_Color()
+#include "svditext.hxx"
+#include <svx/svdmodel.hxx> // fuer DEGREE_CHAR
+#include <svx/svdtrans.hxx>
+#include "svdglob.hxx" // Stringcache
+#include "svdstr.hrc"
+#include <svx/sdgcpitm.hxx>
+#include <editeng/adjitem.hxx>
+#include <svx/sdtfchim.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <tools/bigint.hxx>
+#include <tools/stream.hxx>
+
+#include <svx/xfillit0.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/svx3ditems.hxx>
+
+#define ITEMID_BOX SDRATTR_TABLE_BORDER
+#define ITEMID_BOXINFO SDRATTR_TABLE_BORDER_INNER
+#include "editeng/boxitem.hxx"
+
+#define ITEMID_SHADOW SDRATTR_TABLE_BORDER_SHADOW
+#include "editeng/shaditem.hxx"
+
+#define ITEMID_LINE 0
+#include "editeng/bolnitem.hxx"
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+SdrItemPool::SdrItemPool(
+ SfxItemPool* _pMaster,
+ sal_Bool bLoadRefCounts)
+: XOutdevItemPool(_pMaster, SDRATTR_START, SDRATTR_END, bLoadRefCounts)
+{
+ // preapare some constants
+ const Color aNullCol(RGB_Color(COL_BLACK));
+ const XubString aEmptyStr;
+ const sal_Int32 nDefEdgeDist(500L); // Erstmal hart defaulted fuer Draw (100TH_MM). hier muss noch der MapMode beruecksichtigt werden.
+
+ // init the non-persistent items
+ for(sal_uInt16 i(SDRATTR_NOTPERSIST_FIRST); i <= SDRATTR_NOTPERSIST_LAST; i++)
+ {
+ mpLocalItemInfos[i - SDRATTR_START]._nFlags=0;
+ }
+
+ // init own PoolDefaults
+ mppLocalPoolDefaults[SDRATTR_SHADOW -SDRATTR_START]=new SdrShadowItem;
+ mppLocalPoolDefaults[SDRATTR_SHADOWCOLOR -SDRATTR_START]=new SdrShadowColorItem(aEmptyStr,aNullCol);
+ mppLocalPoolDefaults[SDRATTR_SHADOWXDIST -SDRATTR_START]=new SdrShadowXDistItem;
+ mppLocalPoolDefaults[SDRATTR_SHADOWYDIST -SDRATTR_START]=new SdrShadowYDistItem;
+ mppLocalPoolDefaults[SDRATTR_SHADOWTRANSPARENCE-SDRATTR_START]=new SdrShadowTransparenceItem;
+ mppLocalPoolDefaults[SDRATTR_SHADOW3D -SDRATTR_START]=new SfxVoidItem(SDRATTR_SHADOW3D );
+ mppLocalPoolDefaults[SDRATTR_SHADOWPERSP -SDRATTR_START]=new SfxVoidItem(SDRATTR_SHADOWPERSP );
+ mppLocalPoolDefaults[SDRATTR_CAPTIONTYPE -SDRATTR_START]=new SdrCaptionTypeItem ;
+ mppLocalPoolDefaults[SDRATTR_CAPTIONFIXEDANGLE-SDRATTR_START]=new SdrCaptionFixedAngleItem;
+ mppLocalPoolDefaults[SDRATTR_CAPTIONANGLE -SDRATTR_START]=new SdrCaptionAngleItem ;
+ mppLocalPoolDefaults[SDRATTR_CAPTIONGAP -SDRATTR_START]=new SdrCaptionGapItem ;
+ mppLocalPoolDefaults[SDRATTR_CAPTIONESCDIR -SDRATTR_START]=new SdrCaptionEscDirItem ;
+ mppLocalPoolDefaults[SDRATTR_CAPTIONESCISREL -SDRATTR_START]=new SdrCaptionEscIsRelItem ;
+ mppLocalPoolDefaults[SDRATTR_CAPTIONESCREL -SDRATTR_START]=new SdrCaptionEscRelItem ;
+ mppLocalPoolDefaults[SDRATTR_CAPTIONESCABS -SDRATTR_START]=new SdrCaptionEscAbsItem ;
+ mppLocalPoolDefaults[SDRATTR_CAPTIONLINELEN -SDRATTR_START]=new SdrCaptionLineLenItem ;
+ mppLocalPoolDefaults[SDRATTR_CAPTIONFITLINELEN-SDRATTR_START]=new SdrCaptionFitLineLenItem;
+ mppLocalPoolDefaults[SDRATTR_ECKENRADIUS -SDRATTR_START]=new SdrEckenradiusItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_MINFRAMEHEIGHT -SDRATTR_START]=new SdrTextMinFrameHeightItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_AUTOGROWHEIGHT -SDRATTR_START]=new SdrTextAutoGrowHeightItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_FITTOSIZE -SDRATTR_START]=new SdrTextFitToSizeTypeItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_LEFTDIST -SDRATTR_START]=new SdrTextLeftDistItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_RIGHTDIST -SDRATTR_START]=new SdrTextRightDistItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_UPPERDIST -SDRATTR_START]=new SdrTextUpperDistItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_LOWERDIST -SDRATTR_START]=new SdrTextLowerDistItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_VERTADJUST -SDRATTR_START]=new SdrTextVertAdjustItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_MAXFRAMEHEIGHT -SDRATTR_START]=new SdrTextMaxFrameHeightItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_MINFRAMEWIDTH -SDRATTR_START]=new SdrTextMinFrameWidthItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_MAXFRAMEWIDTH -SDRATTR_START]=new SdrTextMaxFrameWidthItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_AUTOGROWWIDTH -SDRATTR_START]=new SdrTextAutoGrowWidthItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_HORZADJUST -SDRATTR_START]=new SdrTextHorzAdjustItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_ANIKIND -SDRATTR_START]=new SdrTextAniKindItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_ANIDIRECTION -SDRATTR_START]=new SdrTextAniDirectionItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_ANISTARTINSIDE -SDRATTR_START]=new SdrTextAniStartInsideItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_ANISTOPINSIDE -SDRATTR_START]=new SdrTextAniStopInsideItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_ANICOUNT -SDRATTR_START]=new SdrTextAniCountItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_ANIDELAY -SDRATTR_START]=new SdrTextAniDelayItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_ANIAMOUNT -SDRATTR_START]=new SdrTextAniAmountItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_CONTOURFRAME -SDRATTR_START]=new SdrTextContourFrameItem;
+ mppLocalPoolDefaults[SDRATTR_CUSTOMSHAPE_ADJUSTMENT -SDRATTR_START]=new SdrCustomShapeAdjustmentItem;
+ mppLocalPoolDefaults[SDRATTR_XMLATTRIBUTES -SDRATTR_START]=new SvXMLAttrContainerItem( SDRATTR_XMLATTRIBUTES );
+ mppLocalPoolDefaults[SDRATTR_TEXT_USEFIXEDCELLHEIGHT -SDRATTR_START]=new SdrTextFixedCellHeightItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_WORDWRAP -SDRATTR_START]=new SdrTextWordWrapItem;
+ mppLocalPoolDefaults[SDRATTR_TEXT_AUTOGROWSIZE -SDRATTR_START]=new SdrTextAutoGrowSizeItem;
+ mppLocalPoolDefaults[SDRATTR_EDGEKIND -SDRATTR_START]=new SdrEdgeKindItem;
+ mppLocalPoolDefaults[SDRATTR_EDGENODE1HORZDIST-SDRATTR_START]=new SdrEdgeNode1HorzDistItem(nDefEdgeDist);
+ mppLocalPoolDefaults[SDRATTR_EDGENODE1VERTDIST-SDRATTR_START]=new SdrEdgeNode1VertDistItem(nDefEdgeDist);
+ mppLocalPoolDefaults[SDRATTR_EDGENODE2HORZDIST-SDRATTR_START]=new SdrEdgeNode2HorzDistItem(nDefEdgeDist);
+ mppLocalPoolDefaults[SDRATTR_EDGENODE2VERTDIST-SDRATTR_START]=new SdrEdgeNode2VertDistItem(nDefEdgeDist);
+ mppLocalPoolDefaults[SDRATTR_EDGENODE1GLUEDIST-SDRATTR_START]=new SdrEdgeNode1GlueDistItem;
+ mppLocalPoolDefaults[SDRATTR_EDGENODE2GLUEDIST-SDRATTR_START]=new SdrEdgeNode2GlueDistItem;
+ mppLocalPoolDefaults[SDRATTR_EDGELINEDELTAANZ -SDRATTR_START]=new SdrEdgeLineDeltaAnzItem;
+ mppLocalPoolDefaults[SDRATTR_EDGELINE1DELTA -SDRATTR_START]=new SdrEdgeLine1DeltaItem;
+ mppLocalPoolDefaults[SDRATTR_EDGELINE2DELTA -SDRATTR_START]=new SdrEdgeLine2DeltaItem;
+ mppLocalPoolDefaults[SDRATTR_EDGELINE3DELTA -SDRATTR_START]=new SdrEdgeLine3DeltaItem;
+ mppLocalPoolDefaults[SDRATTR_MEASUREKIND -SDRATTR_START]=new SdrMeasureKindItem;
+ mppLocalPoolDefaults[SDRATTR_MEASURETEXTHPOS -SDRATTR_START]=new SdrMeasureTextHPosItem;
+ mppLocalPoolDefaults[SDRATTR_MEASURETEXTVPOS -SDRATTR_START]=new SdrMeasureTextVPosItem;
+ mppLocalPoolDefaults[SDRATTR_MEASURELINEDIST -SDRATTR_START]=new SdrMeasureLineDistItem(800);
+ mppLocalPoolDefaults[SDRATTR_MEASUREHELPLINEOVERHANG -SDRATTR_START]=new SdrMeasureHelplineOverhangItem(200);
+ mppLocalPoolDefaults[SDRATTR_MEASUREHELPLINEDIST -SDRATTR_START]=new SdrMeasureHelplineDistItem(100);
+ mppLocalPoolDefaults[SDRATTR_MEASUREHELPLINE1LEN -SDRATTR_START]=new SdrMeasureHelpline1LenItem;
+ mppLocalPoolDefaults[SDRATTR_MEASUREHELPLINE2LEN -SDRATTR_START]=new SdrMeasureHelpline2LenItem;
+ mppLocalPoolDefaults[SDRATTR_MEASUREBELOWREFEDGE -SDRATTR_START]=new SdrMeasureBelowRefEdgeItem;
+ mppLocalPoolDefaults[SDRATTR_MEASURETEXTROTA90 -SDRATTR_START]=new SdrMeasureTextRota90Item;
+ mppLocalPoolDefaults[SDRATTR_MEASURETEXTUPSIDEDOWN -SDRATTR_START]=new SdrMeasureTextUpsideDownItem;
+ mppLocalPoolDefaults[SDRATTR_MEASUREOVERHANG -SDRATTR_START]=new SdrMeasureOverhangItem(600);
+ mppLocalPoolDefaults[SDRATTR_MEASUREUNIT -SDRATTR_START]=new SdrMeasureUnitItem;
+ mppLocalPoolDefaults[SDRATTR_MEASURESCALE -SDRATTR_START]=new SdrMeasureScaleItem;
+ mppLocalPoolDefaults[SDRATTR_MEASURESHOWUNIT -SDRATTR_START]=new SdrMeasureShowUnitItem;
+ mppLocalPoolDefaults[SDRATTR_MEASUREFORMATSTRING -SDRATTR_START]=new SdrMeasureFormatStringItem();
+ mppLocalPoolDefaults[SDRATTR_MEASURETEXTAUTOANGLE -SDRATTR_START]=new SdrMeasureTextAutoAngleItem();
+ mppLocalPoolDefaults[SDRATTR_MEASURETEXTAUTOANGLEVIEW-SDRATTR_START]=new SdrMeasureTextAutoAngleViewItem();
+ mppLocalPoolDefaults[SDRATTR_MEASURETEXTISFIXEDANGLE -SDRATTR_START]=new SdrMeasureTextIsFixedAngleItem();
+ mppLocalPoolDefaults[SDRATTR_MEASURETEXTFIXEDANGLE -SDRATTR_START]=new SdrMeasureTextFixedAngleItem();
+ mppLocalPoolDefaults[SDRATTR_MEASUREDECIMALPLACES -SDRATTR_START]=new SdrMeasureDecimalPlacesItem();
+ mppLocalPoolDefaults[SDRATTR_CIRCKIND -SDRATTR_START]=new SdrCircKindItem;
+ mppLocalPoolDefaults[SDRATTR_CIRCSTARTANGLE-SDRATTR_START]=new SdrCircStartAngleItem;
+ mppLocalPoolDefaults[SDRATTR_CIRCENDANGLE -SDRATTR_START]=new SdrCircEndAngleItem;
+ mppLocalPoolDefaults[SDRATTR_OBJMOVEPROTECT -SDRATTR_START]=new SdrObjMoveProtectItem;
+ mppLocalPoolDefaults[SDRATTR_OBJSIZEPROTECT -SDRATTR_START]=new SdrObjSizeProtectItem;
+ mppLocalPoolDefaults[SDRATTR_OBJPRINTABLE -SDRATTR_START]=new SdrObjPrintableItem;
+ mppLocalPoolDefaults[SDRATTR_OBJVISIBLE -SDRATTR_START]=new SdrObjVisibleItem;
+ mppLocalPoolDefaults[SDRATTR_LAYERID -SDRATTR_START]=new SdrLayerIdItem;
+ mppLocalPoolDefaults[SDRATTR_LAYERNAME -SDRATTR_START]=new SdrLayerNameItem;
+ mppLocalPoolDefaults[SDRATTR_OBJECTNAME -SDRATTR_START]=new SdrObjectNameItem;
+ mppLocalPoolDefaults[SDRATTR_ALLPOSITIONX -SDRATTR_START]=new SdrAllPositionXItem;
+ mppLocalPoolDefaults[SDRATTR_ALLPOSITIONY -SDRATTR_START]=new SdrAllPositionYItem;
+ mppLocalPoolDefaults[SDRATTR_ALLSIZEWIDTH -SDRATTR_START]=new SdrAllSizeWidthItem;
+ mppLocalPoolDefaults[SDRATTR_ALLSIZEHEIGHT -SDRATTR_START]=new SdrAllSizeHeightItem;
+ mppLocalPoolDefaults[SDRATTR_ONEPOSITIONX -SDRATTR_START]=new SdrOnePositionXItem;
+ mppLocalPoolDefaults[SDRATTR_ONEPOSITIONY -SDRATTR_START]=new SdrOnePositionYItem;
+ mppLocalPoolDefaults[SDRATTR_ONESIZEWIDTH -SDRATTR_START]=new SdrOneSizeWidthItem;
+ mppLocalPoolDefaults[SDRATTR_ONESIZEHEIGHT -SDRATTR_START]=new SdrOneSizeHeightItem;
+ mppLocalPoolDefaults[SDRATTR_LOGICSIZEWIDTH -SDRATTR_START]=new SdrLogicSizeWidthItem;
+ mppLocalPoolDefaults[SDRATTR_LOGICSIZEHEIGHT-SDRATTR_START]=new SdrLogicSizeHeightItem;
+ mppLocalPoolDefaults[SDRATTR_ROTATEANGLE -SDRATTR_START]=new SdrRotateAngleItem;
+ mppLocalPoolDefaults[SDRATTR_SHEARANGLE -SDRATTR_START]=new SdrShearAngleItem;
+ mppLocalPoolDefaults[SDRATTR_MOVEX -SDRATTR_START]=new SdrMoveXItem;
+ mppLocalPoolDefaults[SDRATTR_MOVEY -SDRATTR_START]=new SdrMoveYItem;
+ mppLocalPoolDefaults[SDRATTR_RESIZEXONE -SDRATTR_START]=new SdrResizeXOneItem;
+ mppLocalPoolDefaults[SDRATTR_RESIZEYONE -SDRATTR_START]=new SdrResizeYOneItem;
+ mppLocalPoolDefaults[SDRATTR_ROTATEONE -SDRATTR_START]=new SdrRotateOneItem;
+ mppLocalPoolDefaults[SDRATTR_HORZSHEARONE -SDRATTR_START]=new SdrHorzShearOneItem;
+ mppLocalPoolDefaults[SDRATTR_VERTSHEARONE -SDRATTR_START]=new SdrVertShearOneItem;
+ mppLocalPoolDefaults[SDRATTR_RESIZEXALL -SDRATTR_START]=new SdrResizeXAllItem;
+ mppLocalPoolDefaults[SDRATTR_RESIZEYALL -SDRATTR_START]=new SdrResizeYAllItem;
+ mppLocalPoolDefaults[SDRATTR_ROTATEALL -SDRATTR_START]=new SdrRotateAllItem;
+ mppLocalPoolDefaults[SDRATTR_HORZSHEARALL -SDRATTR_START]=new SdrHorzShearAllItem;
+ mppLocalPoolDefaults[SDRATTR_VERTSHEARALL -SDRATTR_START]=new SdrVertShearAllItem;
+ mppLocalPoolDefaults[SDRATTR_TRANSFORMREF1X -SDRATTR_START]=new SdrTransformRef1XItem;
+ mppLocalPoolDefaults[SDRATTR_TRANSFORMREF1Y -SDRATTR_START]=new SdrTransformRef1YItem;
+ mppLocalPoolDefaults[SDRATTR_TRANSFORMREF2X -SDRATTR_START]=new SdrTransformRef2XItem;
+ mppLocalPoolDefaults[SDRATTR_TRANSFORMREF2Y -SDRATTR_START]=new SdrTransformRef2YItem;
+ mppLocalPoolDefaults[SDRATTR_TEXTDIRECTION -SDRATTR_START]=new SvxWritingModeItem(com::sun::star::text::WritingMode_LR_TB, SDRATTR_TEXTDIRECTION);
+ mppLocalPoolDefaults[ SDRATTR_GRAFRED - SDRATTR_START] = new SdrGrafRedItem;
+ mppLocalPoolDefaults[ SDRATTR_GRAFGREEN - SDRATTR_START] = new SdrGrafGreenItem;
+ mppLocalPoolDefaults[ SDRATTR_GRAFBLUE - SDRATTR_START] = new SdrGrafBlueItem;
+ mppLocalPoolDefaults[ SDRATTR_GRAFLUMINANCE - SDRATTR_START] = new SdrGrafLuminanceItem;
+ mppLocalPoolDefaults[ SDRATTR_GRAFCONTRAST - SDRATTR_START] = new SdrGrafContrastItem;
+ mppLocalPoolDefaults[ SDRATTR_GRAFGAMMA - SDRATTR_START] = new SdrGrafGamma100Item;
+ mppLocalPoolDefaults[ SDRATTR_GRAFTRANSPARENCE - SDRATTR_START] = new SdrGrafTransparenceItem;
+ mppLocalPoolDefaults[ SDRATTR_GRAFINVERT - SDRATTR_START] = new SdrGrafInvertItem;
+ mppLocalPoolDefaults[ SDRATTR_GRAFMODE - SDRATTR_START] = new SdrGrafModeItem;
+ mppLocalPoolDefaults[ SDRATTR_GRAFCROP - SDRATTR_START] = new SdrGrafCropItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_PERCENT_DIAGONAL - SDRATTR_START ] = new Svx3DPercentDiagonalItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_BACKSCALE - SDRATTR_START ] = new Svx3DBackscaleItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_DEPTH - SDRATTR_START ] = new Svx3DDepthItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_HORZ_SEGS - SDRATTR_START ] = new Svx3DHorizontalSegmentsItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_VERT_SEGS - SDRATTR_START ] = new Svx3DVerticalSegmentsItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_END_ANGLE - SDRATTR_START ] = new Svx3DEndAngleItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_DOUBLE_SIDED - SDRATTR_START ] = new Svx3DDoubleSidedItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_NORMALS_KIND - SDRATTR_START ] = new Svx3DNormalsKindItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_NORMALS_INVERT - SDRATTR_START ] = new Svx3DNormalsInvertItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_TEXTURE_PROJ_X - SDRATTR_START ] = new Svx3DTextureProjectionXItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_TEXTURE_PROJ_Y - SDRATTR_START ] = new Svx3DTextureProjectionYItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_SHADOW_3D - SDRATTR_START ] = new Svx3DShadow3DItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_MAT_COLOR - SDRATTR_START ] = new Svx3DMaterialColorItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_MAT_EMISSION - SDRATTR_START ] = new Svx3DMaterialEmissionItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_MAT_SPECULAR - SDRATTR_START ] = new Svx3DMaterialSpecularItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_MAT_SPECULAR_INTENSITY - SDRATTR_START ] = new Svx3DMaterialSpecularIntensityItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_TEXTURE_KIND - SDRATTR_START ] = new Svx3DTextureKindItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_TEXTURE_MODE - SDRATTR_START ] = new Svx3DTextureModeItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_TEXTURE_FILTER - SDRATTR_START ] = new Svx3DTextureFilterItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_SMOOTH_NORMALS - SDRATTR_START ] = new Svx3DSmoothNormalsItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_SMOOTH_LIDS - SDRATTR_START ] = new Svx3DSmoothLidsItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_CHARACTER_MODE - SDRATTR_START ] = new Svx3DCharacterModeItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_CLOSE_FRONT - SDRATTR_START ] = new Svx3DCloseFrontItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_CLOSE_BACK - SDRATTR_START ] = new Svx3DCloseBackItem;
+ mppLocalPoolDefaults[ SDRATTR_3DOBJ_REDUCED_LINE_GEOMETRY - SDRATTR_START ] = new Svx3DReducedLineGeometryItem;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_PERSPECTIVE - SDRATTR_START ] = new Svx3DPerspectiveItem;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_DISTANCE - SDRATTR_START ] = new Svx3DDistanceItem;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_FOCAL_LENGTH - SDRATTR_START ] = new Svx3DFocalLengthItem;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_TWO_SIDED_LIGHTING - SDRATTR_START ] = new Svx3DTwoSidedLightingItem;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_1 - SDRATTR_START ] = new Svx3DLightcolor1Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_2 - SDRATTR_START ] = new Svx3DLightcolor2Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_3 - SDRATTR_START ] = new Svx3DLightcolor3Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_4 - SDRATTR_START ] = new Svx3DLightcolor4Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_5 - SDRATTR_START ] = new Svx3DLightcolor5Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_6 - SDRATTR_START ] = new Svx3DLightcolor6Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_7 - SDRATTR_START ] = new Svx3DLightcolor7Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_8 - SDRATTR_START ] = new Svx3DLightcolor8Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_AMBIENTCOLOR - SDRATTR_START ] = new Svx3DAmbientcolorItem;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTON_1 - SDRATTR_START ] = new Svx3DLightOnOff1Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTON_2 - SDRATTR_START ] = new Svx3DLightOnOff2Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTON_3 - SDRATTR_START ] = new Svx3DLightOnOff3Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTON_4 - SDRATTR_START ] = new Svx3DLightOnOff4Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTON_5 - SDRATTR_START ] = new Svx3DLightOnOff5Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTON_6 - SDRATTR_START ] = new Svx3DLightOnOff6Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTON_7 - SDRATTR_START ] = new Svx3DLightOnOff7Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTON_8 - SDRATTR_START ] = new Svx3DLightOnOff8Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTDIRECTION_1 - SDRATTR_START ] = new Svx3DLightDirection1Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTDIRECTION_2 - SDRATTR_START ] = new Svx3DLightDirection2Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTDIRECTION_3 - SDRATTR_START ] = new Svx3DLightDirection3Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTDIRECTION_4 - SDRATTR_START ] = new Svx3DLightDirection4Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTDIRECTION_5 - SDRATTR_START ] = new Svx3DLightDirection5Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTDIRECTION_6 - SDRATTR_START ] = new Svx3DLightDirection6Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTDIRECTION_7 - SDRATTR_START ] = new Svx3DLightDirection7Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_LIGHTDIRECTION_8 - SDRATTR_START ] = new Svx3DLightDirection8Item;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_SHADOW_SLANT - SDRATTR_START ] = new Svx3DShadowSlantItem;
+ mppLocalPoolDefaults[ SDRATTR_3DSCENE_SHADE_MODE - SDRATTR_START ] = new Svx3DShadeModeItem;
+ mppLocalPoolDefaults[ SDRATTR_CUSTOMSHAPE_ENGINE - SDRATTR_START ] = new SdrCustomShapeEngineItem;
+ mppLocalPoolDefaults[ SDRATTR_CUSTOMSHAPE_DATA - SDRATTR_START ] = new SdrCustomShapeDataItem;
+ mppLocalPoolDefaults[ SDRATTR_CUSTOMSHAPE_GEOMETRY - SDRATTR_START ] = new SdrCustomShapeGeometryItem;
+ mppLocalPoolDefaults[ SDRATTR_CUSTOMSHAPE_REPLACEMENT_URL - SDRATTR_START ] = new SdrCustomShapeReplacementURLItem;
+
+ SvxBoxItem* pboxItem = new SvxBoxItem( SDRATTR_TABLE_BORDER );
+ pboxItem->SetDistance( 100 );
+ mppLocalPoolDefaults[ SDRATTR_TABLE_BORDER - SDRATTR_START ] = pboxItem;
+
+ SvxBoxInfoItem* pBoxInfoItem = new SvxBoxInfoItem( SDRATTR_TABLE_BORDER_INNER );
+
+ pBoxInfoItem->SetTable( TRUE );
+ pBoxInfoItem->SetDist( TRUE); // Abstandsfeld immer anzeigen
+// pBoxInfoItem->SetMinDist( TRUE );// Minimalgroesse in Tabellen und Absaetzen setzen
+// pBoxInfoItem->SetDefDist( MIN_BORDER_DIST );// Default-Abstand immer setzen
+ pBoxInfoItem->SetValid( VALID_DISABLE, TRUE ); // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
+
+ mppLocalPoolDefaults[ SDRATTR_TABLE_BORDER_INNER - SDRATTR_START ] = pBoxInfoItem;
+// mppLocalPoolDefaults[ SDRATTR_TABLE_BORDER_SHADOW - SDRATTR_START ] = new SvxShadowItem( SDRATTR_TABLE_BORDER_SHADOW );
+ mppLocalPoolDefaults[ SDRATTR_TABLE_BORDER_TLBR - SDRATTR_START ] = new SvxLineItem( SDRATTR_TABLE_BORDER_TLBR );
+ mppLocalPoolDefaults[ SDRATTR_TABLE_BORDER_BLTR - SDRATTR_START ] = new SvxLineItem( SDRATTR_TABLE_BORDER_BLTR );
+
+ // set own ItemInfos
+ mpLocalItemInfos[SDRATTR_SHADOW-SDRATTR_START]._nSID=SID_ATTR_FILL_SHADOW;
+ mpLocalItemInfos[SDRATTR_TEXT_FITTOSIZE-SDRATTR_START]._nSID=SID_ATTR_TEXT_FITTOSIZE;
+ mpLocalItemInfos[SDRATTR_GRAFCROP-SDRATTR_START]._nSID=SID_ATTR_GRAF_CROP;
+
+ mpLocalItemInfos[SDRATTR_TABLE_BORDER - SDRATTR_START ]._nSID = SID_ATTR_BORDER_OUTER;
+ mpLocalItemInfos[SDRATTR_TABLE_BORDER_INNER - SDRATTR_START ]._nSID = SID_ATTR_BORDER_INNER;
+// mpLocalItemInfos[SDRATTR_TABLE_BORDER_SHADOW - SDRATTR_START ]._nSID = SID_ATTR_BORDER_SHADOW;
+ mpLocalItemInfos[SDRATTR_TABLE_BORDER_TLBR - SDRATTR_START ]._nSID = SID_ATTR_BORDER_DIAG_TLBR;
+ mpLocalItemInfos[SDRATTR_TABLE_BORDER_BLTR - SDRATTR_START ]._nSID = SID_ATTR_BORDER_DIAG_BLTR;
+
+ // it's my own creation level, set Defaults and ItemInfos
+ SetDefaults(mppLocalPoolDefaults);
+ SetItemInfos(mpLocalItemInfos);
+}
+
+/*************************************************************************
+|*
+|* copy ctor, sorgt dafuer, dass die static defaults gecloned werden
+|* (Parameter 2 = TRUE)
+|*
+\************************************************************************/
+
+SdrItemPool::SdrItemPool(const SdrItemPool& rPool)
+: XOutdevItemPool(rPool)
+{
+}
+
+/*************************************************************************
+|*
+|* Clone()
+|*
+\************************************************************************/
+
+SfxItemPool* __EXPORT SdrItemPool::Clone() const
+{
+ return new SdrItemPool(*this);
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+SdrItemPool::~SdrItemPool()
+{
+ // dtor of SfxItemPool
+ Delete();
+
+ // clear own static Defaults
+ if(mppLocalPoolDefaults)
+ {
+ const sal_uInt16 nBeg(SDRATTR_SHADOW_FIRST - SDRATTR_START);
+ const sal_uInt16 nEnd2(SDRATTR_END - SDRATTR_START);
+
+ for(sal_uInt16 i(nBeg); i <= nEnd2; i++)
+ {
+ SetRefCount(*mppLocalPoolDefaults[i],0);
+ delete mppLocalPoolDefaults[i];
+ mppLocalPoolDefaults[i] = 0L;
+ }
+ }
+
+ // split pools before detroying
+ SetSecondaryPool(NULL);
+}
+
+SfxItemPresentation __EXPORT SdrItemPool::GetPresentation(
+ const SfxPoolItem& rItem, SfxItemPresentation ePresentation,
+ SfxMapUnit ePresentationMetric, XubString& rText,
+ const IntlWrapper * pIntlWrapper) const
+{
+ if (!IsInvalidItem(&rItem)) {
+ USHORT nWhich=rItem.Which();
+ if (nWhich>=SDRATTR_SHADOW_FIRST && nWhich<=SDRATTR_END) {
+ rItem.GetPresentation(SFX_ITEM_PRESENTATION_NAMELESS,
+ GetMetric(nWhich),ePresentationMetric,rText,
+ pIntlWrapper);
+ String aStr;
+
+ TakeItemName(nWhich, aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+
+ return ePresentation;
+ }
+ }
+ return XOutdevItemPool::GetPresentation(rItem,ePresentation,ePresentationMetric,rText,pIntlWrapper);
+}
+
+void SdrItemPool::TakeItemName(sal_uInt16 nWhich, String& rItemName)
+{
+ ResMgr* pResMgr = ImpGetResMgr();
+ USHORT nResId = SIP_UNKNOWN_ATTR;
+
+ switch (nWhich)
+ {
+ case XATTR_LINESTYLE : nResId = SIP_XA_LINESTYLE;break;
+ case XATTR_LINEDASH : nResId = SIP_XA_LINEDASH;break;
+ case XATTR_LINEWIDTH : nResId = SIP_XA_LINEWIDTH;break;
+ case XATTR_LINECOLOR : nResId = SIP_XA_LINECOLOR;break;
+ case XATTR_LINESTART : nResId = SIP_XA_LINESTART;break;
+ case XATTR_LINEEND : nResId = SIP_XA_LINEEND;break;
+ case XATTR_LINESTARTWIDTH : nResId = SIP_XA_LINESTARTWIDTH;break;
+ case XATTR_LINEENDWIDTH : nResId = SIP_XA_LINEENDWIDTH;break;
+ case XATTR_LINESTARTCENTER : nResId = SIP_XA_LINESTARTCENTER;break;
+ case XATTR_LINEENDCENTER : nResId = SIP_XA_LINEENDCENTER;break;
+ case XATTR_LINETRANSPARENCE : nResId = SIP_XA_LINETRANSPARENCE;break;
+ case XATTR_LINEJOINT : nResId = SIP_XA_LINEJOINT;break;
+ case XATTRSET_LINE : nResId = SIP_XATTRSET_LINE;break;
+
+ case XATTR_FILLSTYLE : nResId = SIP_XA_FILLSTYLE;break;
+ case XATTR_FILLCOLOR : nResId = SIP_XA_FILLCOLOR;break;
+ case XATTR_FILLGRADIENT : nResId = SIP_XA_FILLGRADIENT;break;
+ case XATTR_FILLHATCH : nResId = SIP_XA_FILLHATCH;break;
+ case XATTR_FILLBITMAP : nResId = SIP_XA_FILLBITMAP;break;
+ case XATTR_FILLTRANSPARENCE : nResId = SIP_XA_FILLTRANSPARENCE;break;
+ case XATTR_GRADIENTSTEPCOUNT : nResId = SIP_XA_GRADIENTSTEPCOUNT;break;
+ case XATTR_FILLBMP_TILE : nResId = SIP_XA_FILLBMP_TILE;break;
+ case XATTR_FILLBMP_POS : nResId = SIP_XA_FILLBMP_POS;break;
+ case XATTR_FILLBMP_SIZEX : nResId = SIP_XA_FILLBMP_SIZEX;break;
+ case XATTR_FILLBMP_SIZEY : nResId = SIP_XA_FILLBMP_SIZEY;break;
+ case XATTR_FILLFLOATTRANSPARENCE: nResId = SIP_XA_FILLFLOATTRANSPARENCE;break;
+ case XATTR_SECONDARYFILLCOLOR : nResId = SIP_XA_SECONDARYFILLCOLOR;break;
+ case XATTR_FILLBMP_SIZELOG : nResId = SIP_XA_FILLBMP_SIZELOG;break;
+ case XATTR_FILLBMP_TILEOFFSETX : nResId = SIP_XA_FILLBMP_TILEOFFSETX;break;
+ case XATTR_FILLBMP_TILEOFFSETY : nResId = SIP_XA_FILLBMP_TILEOFFSETY;break;
+ case XATTR_FILLBMP_STRETCH : nResId = SIP_XA_FILLBMP_STRETCH;break;
+ case XATTR_FILLBMP_POSOFFSETX : nResId = SIP_XA_FILLBMP_POSOFFSETX;break;
+ case XATTR_FILLBMP_POSOFFSETY : nResId = SIP_XA_FILLBMP_POSOFFSETY;break;
+ case XATTR_FILLBACKGROUND : nResId = SIP_XA_FILLBACKGROUND;break;
+
+ case XATTRSET_FILL : nResId = SIP_XATTRSET_FILL;break;
+
+ case XATTR_FORMTXTSTYLE : nResId = SIP_XA_FORMTXTSTYLE;break;
+ case XATTR_FORMTXTADJUST : nResId = SIP_XA_FORMTXTADJUST;break;
+ case XATTR_FORMTXTDISTANCE : nResId = SIP_XA_FORMTXTDISTANCE;break;
+ case XATTR_FORMTXTSTART : nResId = SIP_XA_FORMTXTSTART;break;
+ case XATTR_FORMTXTMIRROR : nResId = SIP_XA_FORMTXTMIRROR;break;
+ case XATTR_FORMTXTOUTLINE : nResId = SIP_XA_FORMTXTOUTLINE;break;
+ case XATTR_FORMTXTSHADOW : nResId = SIP_XA_FORMTXTSHADOW;break;
+ case XATTR_FORMTXTSHDWCOLOR : nResId = SIP_XA_FORMTXTSHDWCOLOR;break;
+ case XATTR_FORMTXTSHDWXVAL : nResId = SIP_XA_FORMTXTSHDWXVAL;break;
+ case XATTR_FORMTXTSHDWYVAL : nResId = SIP_XA_FORMTXTSHDWYVAL;break;
+ case XATTR_FORMTXTSTDFORM : nResId = SIP_XA_FORMTXTSTDFORM;break;
+ case XATTR_FORMTXTHIDEFORM : nResId = SIP_XA_FORMTXTHIDEFORM;break;
+ case XATTR_FORMTXTSHDWTRANSP: nResId = SIP_XA_FORMTXTSHDWTRANSP;break;
+
+ case SDRATTR_SHADOW : nResId = SIP_SA_SHADOW;break;
+ case SDRATTR_SHADOWCOLOR : nResId = SIP_SA_SHADOWCOLOR;break;
+ case SDRATTR_SHADOWXDIST : nResId = SIP_SA_SHADOWXDIST;break;
+ case SDRATTR_SHADOWYDIST : nResId = SIP_SA_SHADOWYDIST;break;
+ case SDRATTR_SHADOWTRANSPARENCE: nResId = SIP_SA_SHADOWTRANSPARENCE;break;
+ case SDRATTR_SHADOW3D : nResId = SIP_SA_SHADOW3D;break;
+ case SDRATTR_SHADOWPERSP : nResId = SIP_SA_SHADOWPERSP;break;
+
+ case SDRATTR_CAPTIONTYPE : nResId = SIP_SA_CAPTIONTYPE;break;
+ case SDRATTR_CAPTIONFIXEDANGLE: nResId = SIP_SA_CAPTIONFIXEDANGLE;break;
+ case SDRATTR_CAPTIONANGLE : nResId = SIP_SA_CAPTIONANGLE;break;
+ case SDRATTR_CAPTIONGAP : nResId = SIP_SA_CAPTIONGAP;break;
+ case SDRATTR_CAPTIONESCDIR : nResId = SIP_SA_CAPTIONESCDIR;break;
+ case SDRATTR_CAPTIONESCISREL : nResId = SIP_SA_CAPTIONESCISREL;break;
+ case SDRATTR_CAPTIONESCREL : nResId = SIP_SA_CAPTIONESCREL;break;
+ case SDRATTR_CAPTIONESCABS : nResId = SIP_SA_CAPTIONESCABS;break;
+ case SDRATTR_CAPTIONLINELEN : nResId = SIP_SA_CAPTIONLINELEN;break;
+ case SDRATTR_CAPTIONFITLINELEN: nResId = SIP_SA_CAPTIONFITLINELEN;break;
+
+ case SDRATTR_ECKENRADIUS : nResId = SIP_SA_ECKENRADIUS;break;
+ case SDRATTR_TEXT_MINFRAMEHEIGHT : nResId = SIP_SA_TEXT_MINFRAMEHEIGHT;break;
+ case SDRATTR_TEXT_AUTOGROWHEIGHT : nResId = SIP_SA_TEXT_AUTOGROWHEIGHT;break;
+ case SDRATTR_TEXT_FITTOSIZE : nResId = SIP_SA_TEXT_FITTOSIZE;break;
+ case SDRATTR_TEXT_LEFTDIST : nResId = SIP_SA_TEXT_LEFTDIST;break;
+ case SDRATTR_TEXT_RIGHTDIST : nResId = SIP_SA_TEXT_RIGHTDIST;break;
+ case SDRATTR_TEXT_UPPERDIST : nResId = SIP_SA_TEXT_UPPERDIST;break;
+ case SDRATTR_TEXT_LOWERDIST : nResId = SIP_SA_TEXT_LOWERDIST;break;
+ case SDRATTR_TEXT_VERTADJUST : nResId = SIP_SA_TEXT_VERTADJUST;break;
+ case SDRATTR_TEXT_MAXFRAMEHEIGHT : nResId = SIP_SA_TEXT_MAXFRAMEHEIGHT;break;
+ case SDRATTR_TEXT_MINFRAMEWIDTH : nResId = SIP_SA_TEXT_MINFRAMEWIDTH;break;
+ case SDRATTR_TEXT_MAXFRAMEWIDTH : nResId = SIP_SA_TEXT_MAXFRAMEWIDTH;break;
+ case SDRATTR_TEXT_AUTOGROWWIDTH : nResId = SIP_SA_TEXT_AUTOGROWWIDTH;break;
+ case SDRATTR_TEXT_HORZADJUST : nResId = SIP_SA_TEXT_HORZADJUST;break;
+ case SDRATTR_TEXT_ANIKIND : nResId = SIP_SA_TEXT_ANIKIND;break;
+ case SDRATTR_TEXT_ANIDIRECTION : nResId = SIP_SA_TEXT_ANIDIRECTION;break;
+ case SDRATTR_TEXT_ANISTARTINSIDE : nResId = SIP_SA_TEXT_ANISTARTINSIDE;break;
+ case SDRATTR_TEXT_ANISTOPINSIDE : nResId = SIP_SA_TEXT_ANISTOPINSIDE;break;
+ case SDRATTR_TEXT_ANICOUNT : nResId = SIP_SA_TEXT_ANICOUNT;break;
+ case SDRATTR_TEXT_ANIDELAY : nResId = SIP_SA_TEXT_ANIDELAY;break;
+ case SDRATTR_TEXT_ANIAMOUNT : nResId = SIP_SA_TEXT_ANIAMOUNT;break;
+ case SDRATTR_TEXT_CONTOURFRAME : nResId = SIP_SA_TEXT_CONTOURFRAME;break;
+ case SDRATTR_CUSTOMSHAPE_ADJUSTMENT : nResId = SIP_SA_CUSTOMSHAPE_ADJUSTMENT;break;
+ case SDRATTR_XMLATTRIBUTES : nResId = SIP_SA_XMLATTRIBUTES;break;
+ case SDRATTR_TEXT_USEFIXEDCELLHEIGHT: nResId = SIP_SA_TEXT_USEFIXEDCELLHEIGHT;break;
+ case SDRATTR_TEXT_WORDWRAP : nResId = SIP_SA_WORDWRAP;break;
+ case SDRATTR_TEXT_AUTOGROWSIZE : nResId = SIP_SA_AUTOGROWSIZE;break;
+
+ case SDRATTR_EDGEKIND : nResId = SIP_SA_EDGEKIND;break;
+ case SDRATTR_EDGENODE1HORZDIST : nResId = SIP_SA_EDGENODE1HORZDIST;break;
+ case SDRATTR_EDGENODE1VERTDIST : nResId = SIP_SA_EDGENODE1VERTDIST;break;
+ case SDRATTR_EDGENODE2HORZDIST : nResId = SIP_SA_EDGENODE2HORZDIST;break;
+ case SDRATTR_EDGENODE2VERTDIST : nResId = SIP_SA_EDGENODE2VERTDIST;break;
+ case SDRATTR_EDGENODE1GLUEDIST : nResId = SIP_SA_EDGENODE1GLUEDIST;break;
+ case SDRATTR_EDGENODE2GLUEDIST : nResId = SIP_SA_EDGENODE2GLUEDIST;break;
+ case SDRATTR_EDGELINEDELTAANZ : nResId = SIP_SA_EDGELINEDELTAANZ;break;
+ case SDRATTR_EDGELINE1DELTA : nResId = SIP_SA_EDGELINE1DELTA;break;
+ case SDRATTR_EDGELINE2DELTA : nResId = SIP_SA_EDGELINE2DELTA;break;
+ case SDRATTR_EDGELINE3DELTA : nResId = SIP_SA_EDGELINE3DELTA;break;
+
+ case SDRATTR_MEASUREKIND : nResId = SIP_SA_MEASUREKIND;break;
+ case SDRATTR_MEASURETEXTHPOS : nResId = SIP_SA_MEASURETEXTHPOS;break;
+ case SDRATTR_MEASURETEXTVPOS : nResId = SIP_SA_MEASURETEXTVPOS;break;
+ case SDRATTR_MEASURELINEDIST : nResId = SIP_SA_MEASURELINEDIST;break;
+ case SDRATTR_MEASUREHELPLINEOVERHANG : nResId = SIP_SA_MEASUREHELPLINEOVERHANG;break;
+ case SDRATTR_MEASUREHELPLINEDIST : nResId = SIP_SA_MEASUREHELPLINEDIST;break;
+ case SDRATTR_MEASUREHELPLINE1LEN : nResId = SIP_SA_MEASUREHELPLINE1LEN;break;
+ case SDRATTR_MEASUREHELPLINE2LEN : nResId = SIP_SA_MEASUREHELPLINE2LEN;break;
+ case SDRATTR_MEASUREBELOWREFEDGE : nResId = SIP_SA_MEASUREBELOWREFEDGE;break;
+ case SDRATTR_MEASURETEXTROTA90 : nResId = SIP_SA_MEASURETEXTROTA90;break;
+ case SDRATTR_MEASURETEXTUPSIDEDOWN : nResId = SIP_SA_MEASURETEXTUPSIDEDOWN;break;
+ case SDRATTR_MEASUREOVERHANG : nResId = SIP_SA_MEASUREOVERHANG;break;
+ case SDRATTR_MEASUREUNIT : nResId = SIP_SA_MEASUREUNIT;break;
+ case SDRATTR_MEASURESCALE : nResId = SIP_SA_MEASURESCALE;break;
+ case SDRATTR_MEASURESHOWUNIT : nResId = SIP_SA_MEASURESHOWUNIT;break;
+ case SDRATTR_MEASUREFORMATSTRING : nResId = SIP_SA_MEASUREFORMATSTRING;break;
+ case SDRATTR_MEASURETEXTAUTOANGLE : nResId = SIP_SA_MEASURETEXTAUTOANGLE;break;
+ case SDRATTR_MEASURETEXTAUTOANGLEVIEW: nResId = SIP_SA_MEASURETEXTAUTOANGLEVIEW;break;
+ case SDRATTR_MEASURETEXTISFIXEDANGLE : nResId = SIP_SA_MEASURETEXTISFIXEDANGLE;break;
+ case SDRATTR_MEASURETEXTFIXEDANGLE : nResId = SIP_SA_MEASURETEXTFIXEDANGLE;break;
+ case SDRATTR_MEASUREDECIMALPLACES : nResId = SIP_SA_MEASUREDECIMALPLACES;break;
+
+ case SDRATTR_CIRCKIND : nResId = SIP_SA_CIRCKIND;break;
+ case SDRATTR_CIRCSTARTANGLE: nResId = SIP_SA_CIRCSTARTANGLE;break;
+ case SDRATTR_CIRCENDANGLE : nResId = SIP_SA_CIRCENDANGLE;break;
+
+ case SDRATTR_OBJMOVEPROTECT : nResId = SIP_SA_OBJMOVEPROTECT;break;
+ case SDRATTR_OBJSIZEPROTECT : nResId = SIP_SA_OBJSIZEPROTECT;break;
+ case SDRATTR_OBJPRINTABLE : nResId = SIP_SA_OBJPRINTABLE;break;
+ case SDRATTR_OBJVISIBLE : nResId = SIP_SA_OBJVISIBLE;break;
+ case SDRATTR_LAYERID : nResId = SIP_SA_LAYERID;break;
+ case SDRATTR_LAYERNAME : nResId = SIP_SA_LAYERNAME;break;
+ case SDRATTR_OBJECTNAME : nResId = SIP_SA_OBJECTNAME;break;
+ case SDRATTR_ALLPOSITIONX : nResId = SIP_SA_ALLPOSITIONX;break;
+ case SDRATTR_ALLPOSITIONY : nResId = SIP_SA_ALLPOSITIONY;break;
+ case SDRATTR_ALLSIZEWIDTH : nResId = SIP_SA_ALLSIZEWIDTH;break;
+ case SDRATTR_ALLSIZEHEIGHT : nResId = SIP_SA_ALLSIZEHEIGHT;break;
+ case SDRATTR_ONEPOSITIONX : nResId = SIP_SA_ONEPOSITIONX;break;
+ case SDRATTR_ONEPOSITIONY : nResId = SIP_SA_ONEPOSITIONY;break;
+ case SDRATTR_ONESIZEWIDTH : nResId = SIP_SA_ONESIZEWIDTH;break;
+ case SDRATTR_ONESIZEHEIGHT : nResId = SIP_SA_ONESIZEHEIGHT;break;
+ case SDRATTR_LOGICSIZEWIDTH : nResId = SIP_SA_LOGICSIZEWIDTH;break;
+ case SDRATTR_LOGICSIZEHEIGHT: nResId = SIP_SA_LOGICSIZEHEIGHT;break;
+ case SDRATTR_ROTATEANGLE : nResId = SIP_SA_ROTATEANGLE;break;
+ case SDRATTR_SHEARANGLE : nResId = SIP_SA_SHEARANGLE;break;
+ case SDRATTR_MOVEX : nResId = SIP_SA_MOVEX;break;
+ case SDRATTR_MOVEY : nResId = SIP_SA_MOVEY;break;
+ case SDRATTR_RESIZEXONE : nResId = SIP_SA_RESIZEXONE;break;
+ case SDRATTR_RESIZEYONE : nResId = SIP_SA_RESIZEYONE;break;
+ case SDRATTR_ROTATEONE : nResId = SIP_SA_ROTATEONE;break;
+ case SDRATTR_HORZSHEARONE : nResId = SIP_SA_HORZSHEARONE;break;
+ case SDRATTR_VERTSHEARONE : nResId = SIP_SA_VERTSHEARONE;break;
+ case SDRATTR_RESIZEXALL : nResId = SIP_SA_RESIZEXALL;break;
+ case SDRATTR_RESIZEYALL : nResId = SIP_SA_RESIZEYALL;break;
+ case SDRATTR_ROTATEALL : nResId = SIP_SA_ROTATEALL;break;
+ case SDRATTR_HORZSHEARALL : nResId = SIP_SA_HORZSHEARALL;break;
+ case SDRATTR_VERTSHEARALL : nResId = SIP_SA_VERTSHEARALL;break;
+ case SDRATTR_TRANSFORMREF1X : nResId = SIP_SA_TRANSFORMREF1X;break;
+ case SDRATTR_TRANSFORMREF1Y : nResId = SIP_SA_TRANSFORMREF1Y;break;
+ case SDRATTR_TRANSFORMREF2X : nResId = SIP_SA_TRANSFORMREF2X;break;
+ case SDRATTR_TRANSFORMREF2Y : nResId = SIP_SA_TRANSFORMREF2Y;break;
+
+ case SDRATTR_GRAFRED : nResId = SIP_SA_GRAFRED;break;
+ case SDRATTR_GRAFGREEN : nResId = SIP_SA_GRAFGREEN;break;
+ case SDRATTR_GRAFBLUE : nResId = SIP_SA_GRAFBLUE;break;
+ case SDRATTR_GRAFLUMINANCE : nResId = SIP_SA_GRAFLUMINANCE;break;
+ case SDRATTR_GRAFCONTRAST : nResId = SIP_SA_GRAFCONTRAST;break;
+ case SDRATTR_GRAFGAMMA : nResId = SIP_SA_GRAFGAMMA;break;
+ case SDRATTR_GRAFTRANSPARENCE : nResId = SIP_SA_GRAFTRANSPARENCE;break;
+ case SDRATTR_GRAFINVERT : nResId = SIP_SA_GRAFINVERT;break;
+ case SDRATTR_GRAFMODE : nResId = SIP_SA_GRAFMODE;break;
+ case SDRATTR_GRAFCROP : nResId = SIP_SA_GRAFCROP;break;
+
+ case EE_PARA_HYPHENATE : nResId = SIP_EE_PARA_HYPHENATE;break;
+ case EE_PARA_BULLETSTATE: nResId = SIP_EE_PARA_BULLETSTATE;break;
+ case EE_PARA_OUTLLRSPACE: nResId = SIP_EE_PARA_OUTLLRSPACE;break;
+ case EE_PARA_OUTLLEVEL : nResId = SIP_EE_PARA_OUTLLEVEL;break;
+ case EE_PARA_BULLET : nResId = SIP_EE_PARA_BULLET;break;
+ case EE_PARA_LRSPACE : nResId = SIP_EE_PARA_LRSPACE;break;
+ case EE_PARA_ULSPACE : nResId = SIP_EE_PARA_ULSPACE;break;
+ case EE_PARA_SBL : nResId = SIP_EE_PARA_SBL;break;
+ case EE_PARA_JUST : nResId = SIP_EE_PARA_JUST;break;
+ case EE_PARA_TABS : nResId = SIP_EE_PARA_TABS;break;
+
+ case EE_CHAR_COLOR : nResId = SIP_EE_CHAR_COLOR;break;
+ case EE_CHAR_FONTINFO : nResId = SIP_EE_CHAR_FONTINFO;break;
+ case EE_CHAR_FONTHEIGHT : nResId = SIP_EE_CHAR_FONTHEIGHT;break;
+ case EE_CHAR_FONTWIDTH : nResId = SIP_EE_CHAR_FONTWIDTH;break;
+ case EE_CHAR_WEIGHT : nResId = SIP_EE_CHAR_WEIGHT;break;
+ case EE_CHAR_UNDERLINE : nResId = SIP_EE_CHAR_UNDERLINE;break;
+ case EE_CHAR_OVERLINE : nResId = SIP_EE_CHAR_OVERLINE;break;
+ case EE_CHAR_STRIKEOUT : nResId = SIP_EE_CHAR_STRIKEOUT;break;
+ case EE_CHAR_ITALIC : nResId = SIP_EE_CHAR_ITALIC;break;
+ case EE_CHAR_OUTLINE : nResId = SIP_EE_CHAR_OUTLINE;break;
+ case EE_CHAR_SHADOW : nResId = SIP_EE_CHAR_SHADOW;break;
+ case EE_CHAR_ESCAPEMENT : nResId = SIP_EE_CHAR_ESCAPEMENT;break;
+ case EE_CHAR_PAIRKERNING: nResId = SIP_EE_CHAR_PAIRKERNING;break;
+ case EE_CHAR_KERNING : nResId = SIP_EE_CHAR_KERNING;break;
+ case EE_CHAR_WLM : nResId = SIP_EE_CHAR_WLM;break;
+ case EE_FEATURE_TAB : nResId = SIP_EE_FEATURE_TAB;break;
+ case EE_FEATURE_LINEBR : nResId = SIP_EE_FEATURE_LINEBR;break;
+ case EE_FEATURE_NOTCONV : nResId = SIP_EE_FEATURE_NOTCONV;break;
+ case EE_FEATURE_FIELD : nResId = SIP_EE_FEATURE_FIELD;break;
+ } // switch
+
+ rItemName = String( ResId( nResId, *pResMgr ) );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// FractionItem
+////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1_AUTOFACTORY(SdrFractionItem,SfxPoolItem);
+
+SdrFractionItem::SdrFractionItem(USHORT nId, SvStream& rIn):
+ SfxPoolItem(nId)
+{
+ INT32 nMul,nDiv;
+ rIn>>nMul;
+ rIn>>nDiv;
+ nValue=Fraction(nMul,nDiv);
+}
+
+int __EXPORT SdrFractionItem::operator==(const SfxPoolItem& rCmp) const
+{
+ return SfxPoolItem::operator==(rCmp) &&
+ ((SdrFractionItem&)rCmp).GetValue()==nValue;
+}
+
+SfxItemPresentation __EXPORT SdrFractionItem::GetPresentation(
+ SfxItemPresentation ePresentation, SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/, XubString &rText, const IntlWrapper *) const
+{
+ if(nValue.IsValid())
+ {
+ INT32 nDiv = nValue.GetDenominator();
+ rText = UniString::CreateFromInt32(nValue.GetNumerator());
+
+ if(nDiv != 1)
+ {
+ rText += sal_Unicode('/');
+ rText += UniString::CreateFromInt32(nDiv);
+ }
+ }
+ else
+ {
+ rText = UniString();
+ rText += sal_Unicode('?');
+ }
+
+ if(ePresentation == SFX_ITEM_PRESENTATION_COMPLETE)
+ {
+ XubString aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+
+ return ePresentation;
+}
+
+SfxPoolItem* __EXPORT SdrFractionItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrFractionItem(Which(),rIn);
+}
+
+SvStream& __EXPORT SdrFractionItem::Store(SvStream& rOut, USHORT /*nItemVers*/) const
+{
+ rOut<<INT32(nValue.GetNumerator());
+ rOut<<INT32(nValue.GetDenominator());
+ return rOut;
+}
+
+SfxPoolItem* __EXPORT SdrFractionItem::Clone(SfxItemPool * /*pPool*/) const
+{
+ return new SdrFractionItem(Which(),GetValue());
+}
+
+#ifdef SDR_ISPOOLABLE
+int __EXPORT SdrFractionItem::IsPoolable() const
+{
+ USHORT nId=Which();
+ return nId<SDRATTR_NOTPERSIST_FIRST || nId>SDRATTR_NOTPERSIST_LAST;
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// ScaleItem
+////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1_AUTOFACTORY(SdrScaleItem,SdrFractionItem);
+
+SfxItemPresentation __EXPORT SdrScaleItem::GetPresentation(
+ SfxItemPresentation ePresentation, SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/, XubString &rText, const IntlWrapper *) const
+{
+ if(GetValue().IsValid())
+ {
+ INT32 nDiv = GetValue().GetDenominator();
+
+ rText = UniString::CreateFromInt32(GetValue().GetNumerator());
+ rText += sal_Unicode(':');
+ rText += UniString::CreateFromInt32(nDiv);
+ }
+ else
+ {
+ rText = UniString();
+ rText += sal_Unicode('?');
+ }
+
+ if(ePresentation == SFX_ITEM_PRESENTATION_COMPLETE)
+ {
+ XubString aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+
+ return ePresentation;
+}
+
+SfxPoolItem* __EXPORT SdrScaleItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrScaleItem(Which(),rIn);
+}
+
+SfxPoolItem* __EXPORT SdrScaleItem::Clone(SfxItemPool * /*pPool*/) const
+{
+ return new SdrScaleItem(Which(),GetValue());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// OnOffItem
+////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1_AUTOFACTORY(SdrOnOffItem,SfxBoolItem);
+
+SfxPoolItem* __EXPORT SdrOnOffItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SdrOnOffItem(Which(),GetValue());
+}
+
+SfxPoolItem* __EXPORT SdrOnOffItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrOnOffItem(Which(),rIn);
+}
+
+XubString __EXPORT SdrOnOffItem::GetValueTextByVal(BOOL bVal) const
+{
+ if (bVal) return ImpGetResStr(STR_ItemValON);
+ else return ImpGetResStr(STR_ItemValOFF);
+}
+
+SfxItemPresentation __EXPORT SdrOnOffItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByVal(GetValue());
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+#ifdef SDR_ISPOOLABLE
+int __EXPORT SdrOnOffItem::IsPoolable() const
+{
+ USHORT nId=Which();
+ return nId<SDRATTR_NOTPERSIST_FIRST || nId>SDRATTR_NOTPERSIST_LAST;
+}
+#endif
+
+TYPEINIT1_AUTOFACTORY(SdrYesNoItem,SfxBoolItem);
+
+SfxPoolItem* __EXPORT SdrYesNoItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SdrYesNoItem(Which(),GetValue());
+}
+
+SfxPoolItem* __EXPORT SdrYesNoItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrYesNoItem(Which(),rIn);
+}
+
+XubString __EXPORT SdrYesNoItem::GetValueTextByVal(BOOL bVal) const
+{
+ if (bVal) return ImpGetResStr(STR_ItemValYES);
+ else return ImpGetResStr(STR_ItemValNO);
+}
+
+SfxItemPresentation __EXPORT SdrYesNoItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByVal(GetValue());
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+#ifdef SDR_ISPOOLABLE
+int __EXPORT SdrYesNoItem::IsPoolable() const
+{
+ USHORT nId=Which();
+ return nId<SDRATTR_NOTPERSIST_FIRST || nId>SDRATTR_NOTPERSIST_LAST;
+}
+#endif
+
+//------------------------------------------------------------
+// class SdrPercentItem
+//------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SdrPercentItem,SfxUInt16Item);
+
+SfxPoolItem* __EXPORT SdrPercentItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SdrPercentItem(Which(),GetValue());
+}
+
+SfxPoolItem* __EXPORT SdrPercentItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrPercentItem(Which(),rIn);
+}
+
+SfxItemPresentation __EXPORT SdrPercentItem::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText = UniString::CreateFromInt32(GetValue());
+ rText += sal_Unicode('%');
+
+ if(ePres == SFX_ITEM_PRESENTATION_COMPLETE)
+ {
+ XubString aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+
+ return ePres;
+}
+
+#ifdef SDR_ISPOOLABLE
+int __EXPORT SdrPercentItem::IsPoolable() const
+{
+ USHORT nId=Which();
+ return nId<SDRATTR_NOTPERSIST_FIRST || nId>SDRATTR_NOTPERSIST_LAST;
+}
+#endif
+
+//------------------------------------------------------------
+// class SdrAngleItem
+//------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SdrAngleItem,SfxInt32Item);
+
+SfxPoolItem* __EXPORT SdrAngleItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SdrAngleItem(Which(),GetValue());
+}
+
+SfxPoolItem* __EXPORT SdrAngleItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrAngleItem(Which(),rIn);
+}
+
+SfxItemPresentation __EXPORT SdrAngleItem::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
+ XubString& rText, const IntlWrapper * pIntlWrapper) const
+{
+ INT32 nValue(GetValue());
+ BOOL bNeg(nValue < 0);
+
+ if(bNeg)
+ nValue = -nValue;
+
+ rText = UniString::CreateFromInt32(nValue);
+
+ if(nValue)
+ {
+ sal_Unicode aUnicodeNull('0');
+ xub_StrLen nAnz(2);
+
+ const IntlWrapper* pMyIntlWrapper = NULL;
+// DBG_ASSERT( pIntlWrapper, "SdrAngleItem::GetPresentation: using default App-IntlWrapper" );
+ if(!pIntlWrapper)
+ pIntlWrapper = pMyIntlWrapper = new IntlWrapper(
+ ::comphelper::getProcessServiceFactory(),
+ Application::GetSettings().GetLanguage() );
+
+ if(pIntlWrapper->getLocaleData()->isNumLeadingZero())
+ nAnz++;
+
+ while(rText.Len() < nAnz)
+ rText.Insert(aUnicodeNull, 0);
+
+ xub_StrLen nLen = rText.Len();
+ BOOL bNull1(rText.GetChar(nLen-1) == aUnicodeNull);
+ BOOL bNull2(bNull1 && rText.GetChar(nLen-2) == aUnicodeNull);
+
+ if(bNull2)
+ {
+ // keine Nachkommastellen
+ rText.Erase(nLen-2);
+ }
+ else
+ {
+ sal_Unicode cDec =
+ pIntlWrapper->getLocaleData()->getNumDecimalSep().GetChar(0);
+ rText.Insert(cDec, nLen-2);
+
+ if(bNull1)
+ rText.Erase(nLen);
+ }
+
+ if(bNeg)
+ rText.Insert(sal_Unicode('-'), 0);
+
+ if ( pMyIntlWrapper )
+ {
+ delete pMyIntlWrapper;
+ pIntlWrapper = NULL;
+ }
+ }
+
+ rText += sal_Unicode(DEGREE_CHAR);
+
+ if(ePres == SFX_ITEM_PRESENTATION_COMPLETE)
+ {
+ XubString aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+
+ return ePres;
+}
+
+#ifdef SDR_ISPOOLABLE
+int __EXPORT SdrAngleItem::IsPoolable() const
+{
+ USHORT nId=Which();
+ return nId<SDRATTR_NOTPERSIST_FIRST || nId>SDRATTR_NOTPERSIST_LAST;
+}
+#endif
+
+//------------------------------------------------------------
+// class SdrMetricItem
+//------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY(SdrMetricItem,SfxInt32Item);
+
+SfxPoolItem* __EXPORT SdrMetricItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SdrMetricItem(Which(),GetValue());
+}
+
+SfxPoolItem* __EXPORT SdrMetricItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrMetricItem(Which(),rIn);
+}
+
+bool __EXPORT SdrMetricItem::HasMetrics() const
+{
+ return TRUE;
+}
+
+bool __EXPORT SdrMetricItem::ScaleMetrics(long nMul, long nDiv)
+{
+ if (GetValue()!=0) {
+ BigInt aVal(GetValue());
+ aVal*=nMul;
+ aVal+=nDiv/2; // fuer korrektes Runden
+ aVal/=nDiv;
+ SetValue(long(aVal));
+ }
+ return TRUE;
+}
+
+SfxItemPresentation __EXPORT SdrMetricItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit eCoreMetric, SfxMapUnit ePresMetric, XubString& rText, const IntlWrapper *) const
+{
+ long nValue=GetValue();
+ SdrFormatter aFmt((MapUnit)eCoreMetric,(MapUnit)ePresMetric);
+ aFmt.TakeStr(nValue,rText);
+ String aStr;
+ aFmt.TakeUnitStr((MapUnit)ePresMetric,aStr);
+ rText+=aStr;
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr2;
+
+ SdrItemPool::TakeItemName(Which(), aStr2);
+ aStr2 += sal_Unicode(' ');
+ rText.Insert(aStr2, 0);
+ }
+ return ePres;
+}
+
+#ifdef SDR_ISPOOLABLE
+int __EXPORT SdrMetricItem::IsPoolable() const
+{
+ USHORT nId=Which();
+ return nId<SDRATTR_NOTPERSIST_FIRST || nId>SDRATTR_NOTPERSIST_LAST;
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// Items des Legendenobjekts
+////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1_AUTOFACTORY(SdrCaptionTypeItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrCaptionTypeItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrCaptionTypeItem(*this); }
+
+SfxPoolItem* __EXPORT SdrCaptionTypeItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrCaptionTypeItem(rIn); }
+
+USHORT __EXPORT SdrCaptionTypeItem::GetValueCount() const { return 4; }
+
+XubString __EXPORT SdrCaptionTypeItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValCAPTIONTYPE1+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrCaptionTypeItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+TYPEINIT1_AUTOFACTORY(SdrCaptionEscDirItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrCaptionEscDirItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrCaptionEscDirItem(*this); }
+
+SfxPoolItem* __EXPORT SdrCaptionEscDirItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrCaptionEscDirItem(rIn); }
+
+USHORT __EXPORT SdrCaptionEscDirItem::GetValueCount() const { return 3; }
+
+XubString __EXPORT SdrCaptionEscDirItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValCAPTIONESCHORI+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrCaptionEscDirItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// MiscItems
+////////////////////////////////////////////////////////////////////////////////
+
+// FitToSize
+TYPEINIT1_AUTOFACTORY(SdrTextFitToSizeTypeItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrTextFitToSizeTypeItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrTextFitToSizeTypeItem(*this); }
+
+SfxPoolItem* __EXPORT SdrTextFitToSizeTypeItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrTextFitToSizeTypeItem(rIn); }
+
+USHORT __EXPORT SdrTextFitToSizeTypeItem::GetValueCount() const { return 4; }
+
+XubString __EXPORT SdrTextFitToSizeTypeItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValFITTOSIZENONE+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrTextFitToSizeTypeItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+int __EXPORT SdrTextFitToSizeTypeItem::HasBoolValue() const { return TRUE; }
+
+BOOL __EXPORT SdrTextFitToSizeTypeItem::GetBoolValue() const { return GetValue()!=SDRTEXTFIT_NONE; }
+
+void __EXPORT SdrTextFitToSizeTypeItem::SetBoolValue(BOOL bVal) { SetValue(sal::static_int_cast< USHORT >(bVal ? SDRTEXTFIT_PROPORTIONAL : SDRTEXTFIT_NONE)); }
+
+bool SdrTextFitToSizeTypeItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ drawing::TextFitToSizeType eFS = (drawing::TextFitToSizeType)GetValue();
+ rVal <<= eFS;
+
+ return true;
+}
+
+bool SdrTextFitToSizeTypeItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::TextFitToSizeType eFS;
+ if(!(rVal >>= eFS))
+ {
+ sal_Int32 nEnum = 0;
+ if(!(rVal >>= nEnum))
+ return false;
+
+ eFS = (drawing::TextFitToSizeType) nEnum;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( (SdrFitToSizeType)eFS ) );
+
+ return true;
+}
+
+TYPEINIT1_AUTOFACTORY(SdrTextVertAdjustItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrTextVertAdjustItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrTextVertAdjustItem(*this); }
+
+SfxPoolItem* __EXPORT SdrTextVertAdjustItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrTextVertAdjustItem(rIn); }
+
+USHORT __EXPORT SdrTextVertAdjustItem::GetValueCount() const { return 5; }
+
+XubString __EXPORT SdrTextVertAdjustItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValTEXTVADJTOP+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrTextVertAdjustItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+bool SdrTextVertAdjustItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::TextVerticalAdjust)GetValue();
+ return true;
+}
+
+bool SdrTextVertAdjustItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::TextVerticalAdjust eAdj;
+ if(!(rVal >>= eAdj))
+ {
+ sal_Int32 nEnum = 0;
+ if(!(rVal >>= nEnum))
+ return false;
+
+ eAdj = (drawing::TextVerticalAdjust)nEnum;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( (SdrTextVertAdjust)eAdj ) );
+
+ return true;
+}
+
+TYPEINIT1_AUTOFACTORY(SdrTextHorzAdjustItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrTextHorzAdjustItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrTextHorzAdjustItem(*this); }
+
+SfxPoolItem* __EXPORT SdrTextHorzAdjustItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrTextHorzAdjustItem(rIn); }
+
+USHORT __EXPORT SdrTextHorzAdjustItem::GetValueCount() const { return 5; }
+
+XubString __EXPORT SdrTextHorzAdjustItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValTEXTHADJLEFT+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrTextHorzAdjustItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+bool SdrTextHorzAdjustItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::TextHorizontalAdjust)GetValue();
+ return true;
+}
+
+bool SdrTextHorzAdjustItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::TextHorizontalAdjust eAdj;
+ if(!(rVal >>= eAdj))
+ {
+ sal_Int32 nEnum = 0;
+ if(!(rVal >>= nEnum))
+ return false;
+
+ eAdj = (drawing::TextHorizontalAdjust)nEnum;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( (SdrTextHorzAdjust)eAdj ) );
+
+ return true;
+}
+
+TYPEINIT1_AUTOFACTORY(SdrTextAniKindItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrTextAniKindItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrTextAniKindItem(*this); }
+
+SfxPoolItem* __EXPORT SdrTextAniKindItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrTextAniKindItem(rIn); }
+
+USHORT __EXPORT SdrTextAniKindItem::GetValueCount() const { return 5; }
+
+XubString __EXPORT SdrTextAniKindItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValTEXTANI_NONE+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrTextAniKindItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+bool SdrTextAniKindItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::TextAnimationKind)GetValue();
+ return true;
+}
+
+bool SdrTextAniKindItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::TextAnimationKind eKind;
+ if(!(rVal >>= eKind))
+ {
+ sal_Int32 nEnum = 0;
+ if(!(rVal >>= nEnum))
+ return false;
+ eKind = (drawing::TextAnimationKind)nEnum;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( (SdrTextAniKind)eKind ) );
+
+ return true;
+}
+
+TYPEINIT1_AUTOFACTORY(SdrTextAniDirectionItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrTextAniDirectionItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrTextAniDirectionItem(*this); }
+
+SfxPoolItem* __EXPORT SdrTextAniDirectionItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrTextAniDirectionItem(rIn); }
+
+USHORT __EXPORT SdrTextAniDirectionItem::GetValueCount() const { return 4; }
+
+XubString __EXPORT SdrTextAniDirectionItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValTEXTANI_LEFT+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrTextAniDirectionItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+bool SdrTextAniDirectionItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::TextAnimationDirection)GetValue();
+ return true;
+}
+
+bool SdrTextAniDirectionItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::TextAnimationDirection eDir;
+ if(!(rVal >>= eDir))
+ {
+ sal_Int32 nEnum = 0;
+ if(!(rVal >>= nEnum))
+ return false;
+
+ eDir = (drawing::TextAnimationDirection)nEnum;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( (SdrTextAniDirection)eDir ) );
+
+ return true;
+}
+
+TYPEINIT1_AUTOFACTORY(SdrTextAniDelayItem,SfxUInt16Item);
+
+SfxPoolItem* __EXPORT SdrTextAniDelayItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrTextAniDelayItem(*this); }
+
+SfxPoolItem* __EXPORT SdrTextAniDelayItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrTextAniDelayItem(rIn); }
+
+SfxItemPresentation __EXPORT SdrTextAniDelayItem::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
+ XubString& rText, const IntlWrapper *) const
+{
+ rText = UniString::CreateFromInt32(GetValue());
+ rText += sal_Unicode('m');
+ rText += sal_Unicode('s');
+
+ if(ePres == SFX_ITEM_PRESENTATION_COMPLETE)
+ {
+ XubString aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+
+ return ePres;
+}
+
+TYPEINIT1_AUTOFACTORY(SdrTextAniAmountItem,SfxInt16Item);
+
+SfxPoolItem* __EXPORT SdrTextAniAmountItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrTextAniAmountItem(*this); }
+
+SfxPoolItem* __EXPORT SdrTextAniAmountItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrTextAniAmountItem(rIn); }
+
+bool __EXPORT SdrTextAniAmountItem::HasMetrics() const
+{
+ return GetValue()>0;
+}
+
+bool __EXPORT SdrTextAniAmountItem::ScaleMetrics(long nMul, long nDiv)
+{
+ if (GetValue()>0) {
+ BigInt aVal(GetValue());
+ aVal*=nMul;
+ aVal+=nDiv/2; // fuer korrektes Runden
+ aVal/=nDiv;
+ SetValue(short(aVal));
+ return TRUE;
+ } else return FALSE;
+}
+
+SfxItemPresentation __EXPORT SdrTextAniAmountItem::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit eCoreMetric, SfxMapUnit ePresMetric,
+ XubString& rText, const IntlWrapper *) const
+{
+ INT32 nValue(GetValue());
+
+ if(!nValue)
+ nValue = -1L;
+
+ if(nValue < 0)
+ {
+ sal_Char aText[] = "pixel";
+
+ rText = UniString::CreateFromInt32(-nValue);
+ rText += UniString(aText, sizeof(aText-1));
+ }
+ else
+ {
+ SdrFormatter aFmt((MapUnit)eCoreMetric, (MapUnit)ePresMetric);
+ XubString aStr;
+
+ aFmt.TakeStr(nValue, rText);
+ aFmt.TakeUnitStr((MapUnit)ePresMetric, aStr);
+ rText += aStr;
+ }
+
+ if(ePres == SFX_ITEM_PRESENTATION_COMPLETE)
+ {
+ XubString aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+
+ return ePres;
+}
+
+TYPEINIT1_AUTOFACTORY( SdrTextFixedCellHeightItem, SfxBoolItem );
+SdrTextFixedCellHeightItem::SdrTextFixedCellHeightItem( BOOL bUseFixedCellHeight )
+ : SfxBoolItem( SDRATTR_TEXT_USEFIXEDCELLHEIGHT, bUseFixedCellHeight )
+{
+}
+SdrTextFixedCellHeightItem::SdrTextFixedCellHeightItem( SvStream & rStream, sal_uInt16 nVersion )
+ : SfxBoolItem( SDRATTR_TEXT_USEFIXEDCELLHEIGHT, FALSE )
+{
+ if ( nVersion )
+ {
+ sal_Bool bValue;
+ rStream >> bValue;
+ SetValue( bValue );
+ }
+}
+SfxItemPresentation __EXPORT SdrTextFixedCellHeightItem::GetPresentation( SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresentationMetric*/,
+ String &rText, const IntlWrapper * ) const
+{
+ rText = GetValueTextByVal( GetValue() );
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE)
+ {
+ String aStr;
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+SfxPoolItem* __EXPORT SdrTextFixedCellHeightItem::Create( SvStream& rIn, sal_uInt16 nItemVersion ) const
+{
+ return new SdrTextFixedCellHeightItem( rIn, nItemVersion );
+}
+SvStream& __EXPORT SdrTextFixedCellHeightItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) const
+{
+ if ( nItemVersion )
+ {
+ sal_Bool bValue = (sal_Bool)GetValue();
+ rOut << bValue;
+ }
+ return rOut;
+}
+SfxPoolItem* __EXPORT SdrTextFixedCellHeightItem::Clone( SfxItemPool * /*pPool*/) const
+{
+ return new SdrTextFixedCellHeightItem( GetValue() );
+}
+sal_uInt16 SdrTextFixedCellHeightItem::GetVersion( sal_uInt16 /*nFileFormatVersion*/) const
+{
+ return 1;
+}
+bool SdrTextFixedCellHeightItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ sal_Bool bValue = (sal_Bool)GetValue();
+ rVal <<= bValue;
+ return true;
+}
+bool SdrTextFixedCellHeightItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Bool bValue = sal_Bool();
+ if( !( rVal >>= bValue ) )
+ return false;
+ SetValue( bValue );
+ return true;
+}
+#ifdef SDR_ISPOOLABLE
+int __EXPORT SdrTextFixedCellHeightItem::IsPoolable() const
+{
+ USHORT nId=Which();
+ return nId < SDRATTR_NOTPERSIST_FIRST || nId > SDRATTR_NOTPERSIST_LAST;
+}
+#endif
+
+TYPEINIT1_AUTOFACTORY( SdrCustomShapeAdjustmentItem, SfxPoolItem );
+
+SdrCustomShapeAdjustmentItem::SdrCustomShapeAdjustmentItem() : SfxPoolItem( SDRATTR_CUSTOMSHAPE_ADJUSTMENT )
+{
+}
+
+SdrCustomShapeAdjustmentItem::SdrCustomShapeAdjustmentItem( SvStream& rIn, sal_uInt16 nVersion ):
+ SfxPoolItem( SDRATTR_CUSTOMSHAPE_ADJUSTMENT )
+{
+ if ( nVersion )
+ {
+ SdrCustomShapeAdjustmentValue aVal;
+ sal_uInt32 i, nCount;
+ rIn >> nCount;
+ for ( i = 0; i < nCount; i++ )
+ {
+ rIn >> aVal.nValue;
+ SetValue( i, aVal );
+ }
+ }
+}
+
+SdrCustomShapeAdjustmentItem::~SdrCustomShapeAdjustmentItem()
+{
+ void* pPtr;
+ for ( pPtr = aAdjustmentValueList.First(); pPtr; pPtr = aAdjustmentValueList.Next() )
+ delete (SdrCustomShapeAdjustmentValue*)pPtr;
+}
+
+int __EXPORT SdrCustomShapeAdjustmentItem::operator==( const SfxPoolItem& rCmp ) const
+{
+ int bRet = SfxPoolItem::operator==( rCmp );
+ if ( bRet )
+ {
+ bRet = ((SdrCustomShapeAdjustmentItem&)rCmp).GetCount() == GetCount();
+ if ( bRet )
+ {
+ sal_uInt32 i;
+ for ( i = 0; i < GetCount(); i++ )
+ {
+ if ( ((SdrCustomShapeAdjustmentItem&)rCmp).GetValue( i ).nValue != GetValue( i ).nValue )
+ {
+ bRet = 0;
+ break;
+ }
+ }
+ }
+ }
+ return bRet;
+}
+
+SfxItemPresentation __EXPORT SdrCustomShapeAdjustmentItem::GetPresentation(
+ SfxItemPresentation ePresentation, SfxMapUnit /*eCoreMetric*/,
+ SfxMapUnit /*ePresentationMetric*/, XubString &rText, const IntlWrapper *) const
+{
+ sal_uInt32 i, nCount = GetCount();
+ rText.Append( UniString::CreateFromInt32( nCount ) );
+ for ( i = 0; i < nCount; i++ )
+ {
+ rText += sal_Unicode( ' ' );
+ rText.Append( UniString::CreateFromInt32( GetValue( i ).nValue ) );
+ }
+ if ( ePresentation == SFX_ITEM_PRESENTATION_COMPLETE )
+ {
+ XubString aStr;
+
+ SdrItemPool::TakeItemName( Which(), aStr );
+ aStr += sal_Unicode( ' ' );
+ rText.Insert( aStr, 0 );
+ }
+ return ePresentation;
+}
+
+SfxPoolItem* __EXPORT SdrCustomShapeAdjustmentItem::Create( SvStream& rIn, sal_uInt16 nItemVersion ) const
+{
+ return new SdrCustomShapeAdjustmentItem( rIn, nItemVersion );
+}
+
+SvStream& __EXPORT SdrCustomShapeAdjustmentItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) const
+{
+ if ( nItemVersion )
+ {
+ sal_uInt32 i, nCount = GetCount();
+ rOut << nCount;
+ for ( i = 0; i < nCount; i++ )
+ rOut << GetValue( i ).nValue;
+ }
+ return rOut;
+}
+
+SfxPoolItem* __EXPORT SdrCustomShapeAdjustmentItem::Clone( SfxItemPool * /*pPool*/) const
+{
+ sal_uInt32 i;
+ SdrCustomShapeAdjustmentItem* pItem = new SdrCustomShapeAdjustmentItem;
+ for ( i = 0; i < GetCount(); i++ )
+ {
+ const SdrCustomShapeAdjustmentValue& rVal = GetValue( i );
+ pItem->SetValue( i, rVal );
+ }
+ return pItem;
+}
+
+#ifdef SDR_ISPOOLABLE
+int __EXPORT SdrCustomShapeAdjustmentItem::IsPoolable() const
+{
+ USHORT nId=Which();
+ return nId < SDRATTR_NOTPERSIST_FIRST || nId > SDRATTR_NOTPERSIST_LAST;
+}
+#endif
+
+const SdrCustomShapeAdjustmentValue& SdrCustomShapeAdjustmentItem::GetValue( sal_uInt32 nIndex ) const
+{
+#ifdef DBG_UTIL
+ if ( aAdjustmentValueList.Count() <= nIndex )
+ DBG_ERROR( "SdrCustomShapeAdjustemntItem::GetValue - nIndex out of range (SJ)" );
+#endif
+ return *(SdrCustomShapeAdjustmentValue*)aAdjustmentValueList.GetObject( nIndex );
+}
+
+void SdrCustomShapeAdjustmentItem::SetValue( sal_uInt32 nIndex, const SdrCustomShapeAdjustmentValue& rVal )
+{
+ sal_uInt32 i;
+ for ( i = GetCount(); i <= nIndex; i++ )
+ {
+ SdrCustomShapeAdjustmentValue* pItem = new SdrCustomShapeAdjustmentValue;
+ aAdjustmentValueList.Insert( pItem, LIST_APPEND );
+ }
+ SdrCustomShapeAdjustmentValue& rValue = *(SdrCustomShapeAdjustmentValue*)aAdjustmentValueList.GetObject( nIndex );
+ rValue.nValue = rVal.nValue;
+}
+
+sal_uInt16 SdrCustomShapeAdjustmentItem::GetVersion( sal_uInt16 /*nFileFormatVersion*/) const
+{
+ return 1;
+}
+
+bool SdrCustomShapeAdjustmentItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ sal_uInt32 i, nCount = GetCount();
+ uno::Sequence< sal_Int32 > aSequence( nCount );
+ if ( nCount )
+ {
+ sal_Int32* pPtr = aSequence.getArray();
+ for ( i = 0; i < nCount; i++ )
+ *pPtr++ = GetValue( i ).nValue;
+ }
+ rVal <<= aSequence;
+ return true;
+}
+
+bool SdrCustomShapeAdjustmentItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ uno::Sequence< sal_Int32 > aSequence;
+ if( !( rVal >>= aSequence ) )
+ return false;
+
+ void* pPtr;
+ for ( pPtr = aAdjustmentValueList.First(); pPtr; pPtr = aAdjustmentValueList.Next() )
+ delete (SdrCustomShapeAdjustmentValue*)pPtr;
+
+ sal_uInt32 i, nCount = aSequence.getLength();
+ if ( nCount )
+ {
+ const sal_Int32* pPtr2 = aSequence.getConstArray();
+ for ( i = 0; i < nCount; i++ )
+ {
+ SdrCustomShapeAdjustmentValue* pItem = new SdrCustomShapeAdjustmentValue;
+ pItem->nValue = *pPtr2++;
+ aAdjustmentValueList.Insert( pItem, LIST_APPEND );
+ }
+ }
+ return true;
+}
+
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Edge
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+// EdgeKind
+TYPEINIT1_AUTOFACTORY(SdrEdgeKindItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrEdgeKindItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrEdgeKindItem(*this); }
+
+SfxPoolItem* __EXPORT SdrEdgeKindItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrEdgeKindItem(rIn); }
+
+USHORT __EXPORT SdrEdgeKindItem::GetValueCount() const { return 4; }
+
+XubString __EXPORT SdrEdgeKindItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValEDGE_ORTHOLINES+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrEdgeKindItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+bool SdrEdgeKindItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ drawing::ConnectorType eCT = drawing::ConnectorType_STANDARD;
+
+ switch( GetValue() )
+ {
+ case SDREDGE_ORTHOLINES : eCT = drawing::ConnectorType_STANDARD; break;
+ case SDREDGE_THREELINES : eCT = drawing::ConnectorType_LINES; break;
+ case SDREDGE_ONELINE : eCT = drawing::ConnectorType_LINE; break;
+ case SDREDGE_BEZIER : eCT = drawing::ConnectorType_CURVE; break;
+ case SDREDGE_ARC : eCT = drawing::ConnectorType_CURVE; break;
+ default:
+ DBG_ERROR( "SdrEdgeKindItem::QueryValue : unknown enum" );
+ }
+
+ rVal <<= eCT;
+
+ return true;
+}
+
+bool SdrEdgeKindItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::ConnectorType eCT;
+ if(!(rVal >>= eCT))
+ {
+ sal_Int32 nEnum = 0;
+ if(!(rVal >>= nEnum))
+ return false;
+
+ eCT = (drawing::ConnectorType)nEnum;
+ }
+
+ SdrEdgeKind eEK = SDREDGE_ORTHOLINES;
+ switch( eCT )
+ {
+ case drawing::ConnectorType_STANDARD : eEK = SDREDGE_ORTHOLINES; break;
+ case drawing::ConnectorType_CURVE : eEK = SDREDGE_BEZIER; break;
+ case drawing::ConnectorType_LINE : eEK = SDREDGE_ONELINE; break;
+ case drawing::ConnectorType_LINES : eEK = SDREDGE_THREELINES; break;
+ default:
+ DBG_ERROR( "SdrEdgeKindItem::PuValue : unknown enum" );
+ }
+ SetValue( sal::static_int_cast< USHORT >( eEK ) );
+
+ return true;
+}
+
+bool SdrEdgeNode1HorzDistItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+bool SdrEdgeNode1HorzDistItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return false;
+
+ SetValue( nValue );
+ return true;
+}
+
+bool SdrEdgeNode1VertDistItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+bool SdrEdgeNode1VertDistItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return false;
+
+ SetValue( nValue );
+ return true;
+}
+
+bool SdrEdgeNode2HorzDistItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+bool SdrEdgeNode2HorzDistItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return false;
+
+ SetValue( nValue );
+ return true;
+}
+
+bool SdrEdgeNode2VertDistItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+bool SdrEdgeNode2VertDistItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return false;
+
+ SetValue( nValue );
+ return true;
+}
+
+bool SdrEdgeLine1DeltaItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+bool SdrEdgeLine1DeltaItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return false;
+
+ SetValue( nValue );
+ return true;
+}
+
+bool SdrEdgeLine2DeltaItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+bool SdrEdgeLine2DeltaItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return false;
+
+ SetValue( nValue );
+ return true;
+}
+
+bool SdrEdgeLine3DeltaItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+bool SdrEdgeLine3DeltaItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return false;
+
+ SetValue( nValue );
+ return true;
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Measure
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+// MeasureKind
+TYPEINIT1_AUTOFACTORY(SdrMeasureKindItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrMeasureKindItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrMeasureKindItem(*this); }
+
+SfxPoolItem* __EXPORT SdrMeasureKindItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrMeasureKindItem(rIn); }
+
+USHORT __EXPORT SdrMeasureKindItem::GetValueCount() const { return 2; }
+
+XubString __EXPORT SdrMeasureKindItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValMEASURE_STD+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrMeasureKindItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+bool SdrMeasureKindItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::MeasureKind)GetValue();
+ return true;
+}
+
+bool SdrMeasureKindItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::MeasureKind eKind;
+ if(!(rVal >>= eKind))
+ {
+ sal_Int32 nEnum = 0;
+ if(!(rVal >>= nEnum))
+ return false;
+
+ eKind = (drawing::MeasureKind)nEnum;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( (SdrMeasureKind)eKind ) );
+ return true;
+}
+
+TYPEINIT1_AUTOFACTORY(SdrMeasureTextHPosItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrMeasureTextHPosItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrMeasureTextHPosItem(*this); }
+
+SfxPoolItem* __EXPORT SdrMeasureTextHPosItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrMeasureTextHPosItem(rIn); }
+
+USHORT __EXPORT SdrMeasureTextHPosItem::GetValueCount() const { return 4; }
+
+XubString __EXPORT SdrMeasureTextHPosItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValMEASURE_TEXTHAUTO+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrMeasureTextHPosItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+bool SdrMeasureTextHPosItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::MeasureTextHorzPos)GetValue();
+ return true;
+}
+
+bool SdrMeasureTextHPosItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::MeasureTextHorzPos ePos;
+ if(!(rVal >>= ePos))
+ {
+ sal_Int32 nEnum = 0;
+ if(!(rVal >>= nEnum))
+ return false;
+
+ ePos = (drawing::MeasureTextHorzPos)nEnum;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( (SdrMeasureTextHPos)ePos ) );
+ return true;
+}
+
+TYPEINIT1_AUTOFACTORY(SdrMeasureTextVPosItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrMeasureTextVPosItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrMeasureTextVPosItem(*this); }
+
+SfxPoolItem* __EXPORT SdrMeasureTextVPosItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrMeasureTextVPosItem(rIn); }
+
+USHORT __EXPORT SdrMeasureTextVPosItem::GetValueCount() const { return 5; }
+
+XubString __EXPORT SdrMeasureTextVPosItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValMEASURE_TEXTVAUTO+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrMeasureTextVPosItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+bool SdrMeasureTextVPosItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::MeasureTextVertPos)GetValue();
+ return true;
+}
+
+bool SdrMeasureTextVPosItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::MeasureTextVertPos ePos;
+ if(!(rVal >>= ePos))
+ {
+ sal_Int32 nEnum = 0;
+ if(!(rVal >>= nEnum))
+ return false;
+
+ ePos = (drawing::MeasureTextVertPos)nEnum;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( (SdrMeasureTextHPos)ePos ) );
+ return true;
+}
+
+TYPEINIT1_AUTOFACTORY(SdrMeasureUnitItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrMeasureUnitItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrMeasureUnitItem(*this); }
+
+SfxPoolItem* __EXPORT SdrMeasureUnitItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrMeasureUnitItem(rIn); }
+
+USHORT __EXPORT SdrMeasureUnitItem::GetValueCount() const { return 14; }
+
+XubString __EXPORT SdrMeasureUnitItem::GetValueTextByPos(USHORT nPos) const
+{
+ XubString aRetval;
+
+ if((FieldUnit)nPos == FUNIT_NONE)
+ {
+ sal_Char aText[] = "default";
+ aRetval += UniString(aText, sizeof(aText-1));
+ }
+ else
+ {
+ SdrFormatter::TakeUnitStr((FieldUnit)nPos, aRetval);
+ }
+
+ return aRetval;
+}
+
+SfxItemPresentation __EXPORT SdrMeasureUnitItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+bool SdrMeasureUnitItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+bool SdrMeasureUnitItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nMeasure = 0;
+ if(!(rVal >>= nMeasure))
+ return false;
+
+ SetValue( sal::static_int_cast< USHORT >( (FieldUnit)nMeasure ) );
+ return true;
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Circ
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+// CircKind
+TYPEINIT1_AUTOFACTORY(SdrCircKindItem,SfxEnumItem);
+
+SfxPoolItem* __EXPORT SdrCircKindItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrCircKindItem(*this); }
+
+SfxPoolItem* __EXPORT SdrCircKindItem::Create(SvStream& rIn, USHORT /*nVer*/) const { return new SdrCircKindItem(rIn); }
+
+USHORT __EXPORT SdrCircKindItem::GetValueCount() const { return 4; }
+
+XubString __EXPORT SdrCircKindItem::GetValueTextByPos(USHORT nPos) const
+{
+ return ImpGetResStr(STR_ItemValCIRC_FULL+nPos);
+}
+
+SfxItemPresentation __EXPORT SdrCircKindItem::GetPresentation(SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/, XubString& rText, const IntlWrapper *) const
+{
+ rText=GetValueTextByPos(sal::static_int_cast< USHORT >(GetValue()));
+ if (ePres==SFX_ITEM_PRESENTATION_COMPLETE) {
+ String aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+ return ePres;
+}
+
+bool SdrCircKindItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (drawing::CircleKind)GetValue();
+ return true;
+}
+
+bool SdrCircKindItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ drawing::CircleKind eKind;
+ if(!(rVal >>= eKind))
+ {
+ sal_Int32 nEnum = 0;
+ if(!(rVal >>= nEnum))
+ return false;
+
+ eKind = (drawing::CircleKind)nEnum;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( (SdrCircKind)eKind ) );
+ return true;
+}
+
+//------------------------------------------------------------
+// class SdrSignedPercentItem
+//------------------------------------------------------------
+
+TYPEINIT1_AUTOFACTORY( SdrSignedPercentItem, SfxInt16Item );
+
+
+SfxPoolItem* __EXPORT SdrSignedPercentItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SdrSignedPercentItem( Which(), GetValue() );
+}
+
+SfxPoolItem* __EXPORT SdrSignedPercentItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrSignedPercentItem( Which(), rIn );
+}
+
+SfxItemPresentation __EXPORT SdrSignedPercentItem::GetPresentation(
+ SfxItemPresentation ePres, SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
+ XubString& rText, const IntlWrapper *) const
+{
+ rText = UniString::CreateFromInt32(GetValue());
+ rText += sal_Unicode('%');
+
+ if(ePres == SFX_ITEM_PRESENTATION_COMPLETE)
+ {
+ XubString aStr;
+
+ SdrItemPool::TakeItemName(Which(), aStr);
+ aStr += sal_Unicode(' ');
+ rText.Insert(aStr, 0);
+ }
+
+ return ePres;
+}
+
+#ifdef SDR_ISPOOLABLE
+
+int __EXPORT SdrSignedPercentItem::IsPoolable() const
+{
+ USHORT nId=Which();
+ return nId < SDRATTR_NOTPERSIST_FIRST || nId > SDRATTR_NOTPERSIST_LAST;
+}
+#endif
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SdrGrafRedItem
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1( SdrGrafRedItem, SdrSignedPercentItem );
+
+SfxPoolItem* __EXPORT SdrGrafRedItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new SdrGrafRedItem( *this );
+}
+
+SfxPoolItem* __EXPORT SdrGrafRedItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrGrafRedItem( rIn );
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SdrGrafGreenItem
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1( SdrGrafGreenItem, SdrSignedPercentItem );
+
+SfxPoolItem* __EXPORT SdrGrafGreenItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new SdrGrafGreenItem( *this );
+}
+
+SfxPoolItem* __EXPORT SdrGrafGreenItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrGrafGreenItem( rIn );
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SdrGrafBlueItem
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1( SdrGrafBlueItem, SdrSignedPercentItem );
+
+SfxPoolItem* __EXPORT SdrGrafBlueItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new SdrGrafBlueItem( *this );
+}
+
+SfxPoolItem* __EXPORT SdrGrafBlueItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrGrafBlueItem( rIn );
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SdrGrafLuminanceItem
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1( SdrGrafLuminanceItem, SdrSignedPercentItem );
+
+SfxPoolItem* __EXPORT SdrGrafLuminanceItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new SdrGrafLuminanceItem( *this );
+}
+
+SfxPoolItem* __EXPORT SdrGrafLuminanceItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrGrafLuminanceItem( rIn );
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SdrGrafContrastItem
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1( SdrGrafContrastItem, SdrSignedPercentItem );
+
+SfxPoolItem* __EXPORT SdrGrafContrastItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new SdrGrafContrastItem( *this );
+}
+
+SfxPoolItem* __EXPORT SdrGrafContrastItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrGrafContrastItem( rIn );
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SdrGrafGamma100Item
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1( SdrGrafGamma100Item, SfxUInt32Item );
+
+SfxPoolItem* __EXPORT SdrGrafGamma100Item::Clone( SfxItemPool* /*pPool */) const
+{
+ return new SdrGrafGamma100Item( *this );
+}
+
+SfxPoolItem* __EXPORT SdrGrafGamma100Item::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrGrafGamma100Item( rIn );
+}
+
+bool SdrGrafGamma100Item::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= ((double)GetValue()) / 100.0;
+ return true;
+}
+
+bool SdrGrafGamma100Item::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ double nGamma = 0;
+ if(!(rVal >>= nGamma))
+ return false;
+
+ SetValue( (UINT32)(nGamma * 100.0 ) );
+ return true;
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SdrGrafInvertItem
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1( SdrGrafInvertItem, SdrOnOffItem );
+
+SfxPoolItem* __EXPORT SdrGrafInvertItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new SdrGrafInvertItem( *this );
+}
+
+SfxPoolItem* __EXPORT SdrGrafInvertItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrGrafInvertItem( rIn );
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SdrGrafTransparenceItem
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1( SdrGrafTransparenceItem, SdrPercentItem );
+
+SfxPoolItem* __EXPORT SdrGrafTransparenceItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new SdrGrafTransparenceItem( *this );
+}
+
+SfxPoolItem* __EXPORT SdrGrafTransparenceItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrGrafTransparenceItem( rIn );
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SdrGrafModeItem
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1( SdrGrafModeItem, SfxEnumItem );
+
+SfxPoolItem* __EXPORT SdrGrafModeItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new SdrGrafModeItem( *this );
+}
+
+SfxPoolItem* __EXPORT SdrGrafModeItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new SdrGrafModeItem( rIn );
+}
+
+USHORT __EXPORT SdrGrafModeItem::GetValueCount() const
+{
+ return 4;
+}
+
+XubString __EXPORT SdrGrafModeItem::GetValueTextByPos(UINT16 nPos) const
+{
+ XubString aStr;
+
+ switch(nPos)
+ {
+ case 1:
+ {
+ sal_Char aTextGreys[] = "Greys";
+ aStr += UniString(aTextGreys, sizeof(aTextGreys-1));
+ break;
+ }
+ case 2:
+ {
+ sal_Char aTextBlackWhite[] = "Black/White";
+ aStr += UniString(aTextBlackWhite, sizeof(aTextBlackWhite-1));
+ break;
+ }
+ case 3:
+ {
+ sal_Char aTextWatermark[] = "Watermark";
+ aStr += UniString(aTextWatermark, sizeof(aTextWatermark-1));
+ break;
+ }
+ default:
+ {
+ sal_Char aTextStandard[] = "Standard";
+ aStr += UniString(aTextStandard, sizeof(aTextStandard-1));
+ break;
+ }
+ }
+
+ return aStr;
+}
+
+SfxItemPresentation __EXPORT SdrGrafModeItem::GetPresentation( SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreMetric*/, SfxMapUnit /*ePresMetric*/,
+ XubString& rText, const IntlWrapper *) const
+{
+ rText = GetValueTextByPos( sal::static_int_cast< USHORT >( GetValue() ) );
+
+ if( ePres == SFX_ITEM_PRESENTATION_COMPLETE )
+ {
+ String aStr;
+
+ SdrItemPool::TakeItemName( Which(), aStr );
+ aStr += sal_Unicode(' ');
+ rText.Insert( aStr, 0 );
+ }
+
+ return ePres;
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SdrGrafCropItem
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1( SdrGrafCropItem, SvxGrfCrop );
+
+SfxPoolItem* SdrGrafCropItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new SdrGrafCropItem( *this );
+}
+
+SfxPoolItem* SdrGrafCropItem::Create( SvStream& rIn, USHORT nVer ) const
+{
+ return( ( 0 == nVer ) ? Clone( NULL ) : SvxGrfCrop::Create( rIn, nVer ) );
+}
+
+USHORT SdrGrafCropItem::GetVersion( USHORT /*nFileVersion*/) const
+{
+ // GRFCROP_VERSION_MOVETOSVX is 1
+ return GRFCROP_VERSION_MOVETOSVX;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdcrtv.cxx b/svx/source/svdraw/svdcrtv.cxx
new file mode 100644
index 000000000000..eb4be6e1e00f
--- /dev/null
+++ b/svx/source/svdraw/svdcrtv.cxx
@@ -0,0 +1,966 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdcrtv.hxx>
+#include "xattr.hxx"
+#include <svx/svdundo.hxx>
+#include <svx/svdocapt.hxx> // Spezialbehandlung: Nach dem Create transparente Fuellung
+#include <svx/svdoedge.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/scene3d.hxx>
+#include <svx/view3d.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/svdouno.hxx>
+#define XOR_CREATE_PEN PEN_SOLID
+#include <svx/svdopath.hxx>
+#include <svx/sdr/overlay/overlaypolypolygon.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <sdrpaintwindow.hxx>
+#include "fmobj.hxx"
+#include <svx/svdocirc.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ImplConnectMarkerOverlay
+{
+ // The OverlayObjects
+ ::sdr::overlay::OverlayObjectList maObjects;
+
+ // The remembered target object
+ const SdrObject& mrObject;
+
+public:
+ ImplConnectMarkerOverlay(const SdrCreateView& rView, SdrObject& rObject);
+ ~ImplConnectMarkerOverlay();
+
+ const SdrObject& GetTargetObject() const { return mrObject; }
+};
+
+ImplConnectMarkerOverlay::ImplConnectMarkerOverlay(const SdrCreateView& rView, SdrObject& rObject)
+: mrObject(rObject)
+{
+ basegfx::B2DPolyPolygon aB2DPolyPolygon(rObject.TakeXorPoly());
+
+ for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
+ ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
+
+ if(pTargetOverlay)
+ {
+ Size aHalfLogicSize(pTargetOverlay->getOutputDevice().PixelToLogic(Size(4, 4)));
+
+ // object
+ ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aB2DPolyPolygon);
+ pTargetOverlay->add(*pNew);
+ maObjects.append(*pNew);
+
+ // gluepoints
+ if(rView.IsAutoVertexConnectors())
+ {
+ for(sal_uInt16 i(0); i < 4; i++)
+ {
+ SdrGluePoint aGluePoint(rObject.GetVertexGluePoint(i));
+ const Point& rPosition = aGluePoint.GetAbsolutePos(rObject);
+
+ basegfx::B2DPoint aTopLeft(rPosition.X() - aHalfLogicSize.Width(), rPosition.Y() - aHalfLogicSize.Height());
+ basegfx::B2DPoint aBottomRight(rPosition.X() + aHalfLogicSize.Width(), rPosition.Y() + aHalfLogicSize.Height());
+
+ basegfx::B2DPolygon aTempPoly;
+ aTempPoly.append(aTopLeft);
+ aTempPoly.append(basegfx::B2DPoint(aBottomRight.getX(), aTopLeft.getY()));
+ aTempPoly.append(aBottomRight);
+ aTempPoly.append(basegfx::B2DPoint(aTopLeft.getX(), aBottomRight.getY()));
+ aTempPoly.setClosed(true);
+
+ basegfx::B2DPolyPolygon aTempPolyPoly;
+ aTempPolyPoly.append(aTempPoly);
+
+ pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aTempPolyPoly);
+ pTargetOverlay->add(*pNew);
+ maObjects.append(*pNew);
+ }
+ }
+ }
+ }
+}
+
+ImplConnectMarkerOverlay::~ImplConnectMarkerOverlay()
+{
+ // The OverlayObjects are cleared using the destructor of OverlayObjectList.
+ // That destructor calls clear() at the list which removes all objects from the
+ // OverlayManager and deletes them.
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ImpSdrCreateViewExtraData
+{
+ // The OverlayObjects for XOR replacement
+ ::sdr::overlay::OverlayObjectList maObjects;
+
+public:
+ ImpSdrCreateViewExtraData();
+ ~ImpSdrCreateViewExtraData();
+
+ void CreateAndShowOverlay(const SdrCreateView& rView, const SdrObject* pObject, const basegfx::B2DPolyPolygon& rPolyPoly);
+ void HideOverlay();
+};
+
+ImpSdrCreateViewExtraData::ImpSdrCreateViewExtraData()
+{
+}
+
+ImpSdrCreateViewExtraData::~ImpSdrCreateViewExtraData()
+{
+ HideOverlay();
+}
+
+void ImpSdrCreateViewExtraData::CreateAndShowOverlay(const SdrCreateView& rView, const SdrObject* pObject, const basegfx::B2DPolyPolygon& rPolyPoly)
+{
+ for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
+ ::sdr::overlay::OverlayManager* pOverlayManager = pCandidate->GetOverlayManager();
+
+ if(pOverlayManager)
+ {
+ if(pObject)
+ {
+ const sdr::contact::ViewContact& rVC = pObject->GetViewContact();
+ const drawinglayer::primitive2d::Primitive2DSequence aSequence = rVC.getViewIndependentPrimitive2DSequence();
+ sdr::overlay::OverlayObject* pNew = new sdr::overlay::OverlayPrimitive2DSequenceObject(aSequence);
+
+ pOverlayManager->add(*pNew);
+ maObjects.append(*pNew);
+ }
+
+ if(rPolyPoly.count())
+ {
+ ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(rPolyPoly);
+ pOverlayManager->add(*pNew);
+ maObjects.append(*pNew);
+ }
+ }
+ }
+}
+
+void ImpSdrCreateViewExtraData::HideOverlay()
+{
+ // the clear() call at the list removes all objects from the
+ // OverlayManager and deletes them.
+ maObjects.clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@ @@@@@ @@@@@ @@@@ @@@@@@ @@@@@ @@ @@ @@ @@@@@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
+// @@ @@@@@ @@@@ @@@@@@ @@ @@@@ @@@@@ @@ @@@@ @@@@@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@@@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
+// @@@@ @@ @@ @@@@@ @@ @@ @@ @@@@@ @ @@ @@@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrCreateView::ImpClearConnectMarker()
+{
+ if(mpCoMaOverlay)
+ {
+ delete mpCoMaOverlay;
+ mpCoMaOverlay = 0L;
+ }
+}
+
+void SdrCreateView::ImpClearVars()
+{
+ nAktInvent=SdrInventor;
+ nAktIdent=OBJ_NONE;
+ pAktCreate=NULL;
+ pCreatePV=NULL;
+ bAutoTextEdit=FALSE;
+ b1stPointAsCenter=FALSE;
+ aAktCreatePointer=Pointer(POINTER_CROSS);
+ bUseIncompatiblePathCreateInterface=FALSE;
+ bAutoClosePolys=TRUE;
+ nAutoCloseDistPix=5;
+ nFreeHandMinDistPix=10;
+
+ ImpClearConnectMarker();
+}
+
+void SdrCreateView::ImpMakeCreateAttr()
+{
+}
+
+SdrCreateView::SdrCreateView(SdrModel* pModel1, OutputDevice* pOut)
+: SdrDragView(pModel1,pOut),
+ mpCoMaOverlay(0L),
+ mpCreateViewExtraData(new ImpSdrCreateViewExtraData())
+{
+ ImpClearVars();
+ ImpMakeCreateAttr();
+}
+
+SdrCreateView::~SdrCreateView()
+{
+ ImpClearConnectMarker();
+ delete mpCreateViewExtraData;
+ SdrObject::Free( pAktCreate );
+}
+
+void SdrCreateView::ImpDelCreateAttr()
+{
+}
+
+BOOL SdrCreateView::IsAction() const
+{
+ return SdrDragView::IsAction() || pAktCreate!=NULL;
+}
+
+void SdrCreateView::MovAction(const Point& rPnt)
+{
+ SdrDragView::MovAction(rPnt);
+ if (pAktCreate!=NULL) {
+ MovCreateObj(rPnt);
+ }
+}
+
+void SdrCreateView::EndAction()
+{
+ if (pAktCreate!=NULL) EndCreateObj(SDRCREATE_FORCEEND);
+ SdrDragView::EndAction();
+}
+
+void SdrCreateView::BckAction()
+{
+ if (pAktCreate!=NULL) BckCreateObj();
+ SdrDragView::BckAction();
+}
+
+void SdrCreateView::BrkAction()
+{
+ SdrDragView::BrkAction();
+ BrkCreateObj();
+}
+
+void SdrCreateView::TakeActionRect(Rectangle& rRect) const
+{
+ if (pAktCreate!=NULL)
+ {
+ rRect=aDragStat.GetActionRect();
+ if (rRect.IsEmpty())
+ {
+ rRect=Rectangle(aDragStat.GetPrev(),aDragStat.GetNow());
+ }
+ }
+ else
+ {
+ SdrDragView::TakeActionRect(rRect);
+ }
+}
+
+BOOL SdrCreateView::CheckEdgeMode()
+{
+ UINT32 nInv=nAktInvent;
+ UINT16 nIdn=nAktIdent;
+ if (pAktCreate!=NULL)
+ {
+ nInv=pAktCreate->GetObjInventor();
+ nIdn=pAktCreate->GetObjIdentifier();
+ // wird vom EdgeObj gemanaged
+ if (nAktInvent==SdrInventor && nAktIdent==OBJ_EDGE) return FALSE;
+ }
+
+ if (!IsCreateMode() || nAktInvent!=SdrInventor || nAktIdent!=OBJ_EDGE)
+ {
+ ImpClearConnectMarker();
+ return FALSE;
+ }
+ else
+ {
+ // TRUE heisst: MouseMove soll Connect checken
+ return !IsAction();
+ }
+}
+
+void SdrCreateView::SetConnectMarker(const SdrObjConnection& rCon, const SdrPageView& /*rPV*/)
+{
+ SdrObject* pTargetObject = rCon.pObj;
+
+ if(pTargetObject)
+ {
+ // if target object changes, throw away overlay object to make room for changes
+ if(mpCoMaOverlay && pTargetObject != &mpCoMaOverlay->GetTargetObject())
+ {
+ ImpClearConnectMarker();
+ }
+
+ if(!mpCoMaOverlay)
+ {
+ mpCoMaOverlay = new ImplConnectMarkerOverlay(*this, *pTargetObject);
+ }
+ }
+ else
+ {
+ ImpClearConnectMarker();
+ }
+}
+
+void SdrCreateView::HideConnectMarker()
+{
+ ImpClearConnectMarker();
+}
+
+BOOL SdrCreateView::MouseMove(const MouseEvent& rMEvt, Window* pWin)
+{
+ if(CheckEdgeMode() && pWin)
+ {
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ // Defaultete Hit-Toleranz bei IsMarkedHit() mal aendern !!!!
+ Point aPos(pWin->PixelToLogic(rMEvt.GetPosPixel()));
+ BOOL bMarkHit=PickHandle(aPos)!=NULL || IsMarkedObjHit(aPos);
+ SdrObjConnection aCon;
+ if (!bMarkHit) SdrEdgeObj::ImpFindConnector(aPos,*pPV,aCon,NULL,pWin);
+ SetConnectMarker(aCon,*pPV);
+ }
+ }
+ return SdrDragView::MouseMove(rMEvt,pWin);
+}
+
+BOOL SdrCreateView::IsTextTool() const
+{
+ return eEditMode==SDREDITMODE_CREATE && nAktInvent==SdrInventor && (nAktIdent==OBJ_TEXT || nAktIdent==OBJ_TEXTEXT || nAktIdent==OBJ_TITLETEXT || nAktIdent==OBJ_OUTLINETEXT);
+}
+
+BOOL SdrCreateView::IsEdgeTool() const
+{
+ return eEditMode==SDREDITMODE_CREATE && nAktInvent==SdrInventor && (nAktIdent==OBJ_EDGE);
+}
+
+BOOL SdrCreateView::IsMeasureTool() const
+{
+ return eEditMode==SDREDITMODE_CREATE && nAktInvent==SdrInventor && (nAktIdent==OBJ_MEASURE);
+}
+
+void SdrCreateView::SetCurrentObj(UINT16 nIdent, UINT32 nInvent)
+{
+ if (nAktInvent!=nInvent || nAktIdent!=nIdent)
+ {
+ nAktInvent=nInvent;
+ nAktIdent=nIdent;
+ SdrObject* pObj = SdrObjFactory::MakeNewObject(nInvent,nIdent,NULL,NULL);
+
+ if(pObj)
+ {
+ // Auf pers. Wunsch von Marco:
+ // Mauszeiger bei Textwerkzeug immer I-Beam. Fadenkreuz
+ // mit kleinem I-Beam erst bai MouseButtonDown
+ if(IsTextTool())
+ {
+ // #81944# AW: Here the correct pointer needs to be used
+ // if the default is set to vertical writing
+ aAktCreatePointer = POINTER_TEXT;
+ }
+ else
+ aAktCreatePointer = pObj->GetCreatePointer();
+
+ SdrObject::Free( pObj );
+ }
+ else
+ {
+ aAktCreatePointer = Pointer(POINTER_CROSS);
+ }
+ }
+
+ CheckEdgeMode();
+ ImpSetGlueVisible3(IsEdgeTool());
+}
+
+BOOL SdrCreateView::ImpBegCreateObj(UINT32 nInvent, UINT16 nIdent, const Point& rPnt, OutputDevice* pOut,
+ short nMinMov, SdrPageView* pPV, const Rectangle& rLogRect, SdrObject* pPreparedFactoryObject)
+{
+ BOOL bRet=FALSE;
+ UnmarkAllObj();
+ BrkAction();
+
+ ImpClearConnectMarker();
+
+ if (pPV!=NULL)
+ {
+ pCreatePV=pPV;
+ }
+ else
+ {
+ pCreatePV = GetSdrPageView();
+ }
+ if (pCreatePV!=NULL)
+ { // ansonsten keine Seite angemeldet!
+ String aLay(aAktLayer);
+
+ if(nInvent == SdrInventor && nIdent == OBJ_MEASURE && aMeasureLayer.Len())
+ {
+ aLay = aMeasureLayer;
+ }
+
+ SdrLayerID nLayer=pCreatePV->GetPage()->GetLayerAdmin().GetLayerID(aLay,TRUE);
+ if (nLayer==SDRLAYER_NOTFOUND) nLayer=0;
+ if (!pCreatePV->GetLockedLayers().IsSet(nLayer) && pCreatePV->GetVisibleLayers().IsSet(nLayer))
+ {
+ if(pPreparedFactoryObject)
+ {
+ pAktCreate = pPreparedFactoryObject;
+
+ if(pCreatePV->GetPage())
+ {
+ pAktCreate->SetPage(pCreatePV->GetPage());
+ }
+ else if (pMod)
+ {
+ pAktCreate->SetModel(pMod);
+ }
+ }
+ else
+ {
+ pAktCreate = SdrObjFactory::MakeNewObject(nInvent, nIdent, pCreatePV->GetPage(), pMod);
+ }
+
+ Point aPnt(rPnt);
+ if (nAktInvent!=SdrInventor || (nAktIdent!=USHORT(OBJ_EDGE) &&
+ nAktIdent!=USHORT(OBJ_FREELINE) &&
+ nAktIdent!=USHORT(OBJ_FREEFILL) )) { // Kein Fang fuer Edge und Freihand!
+ aPnt=GetSnapPos(aPnt,pCreatePV);
+ }
+ if (pAktCreate!=NULL)
+ {
+ BOOL bStartEdit=FALSE; // nach Ende von Create automatisch TextEdit starten
+ if (pDefaultStyleSheet!=NULL) pAktCreate->NbcSetStyleSheet(pDefaultStyleSheet, sal_False);
+
+ // #101618# SW uses a naked SdrObject for frame construction. Normally, such an
+ // object should not be created. Since it is possible to use it as a helper
+ // object (e.g. in letting the user define an area with the interactive
+ // construction) at least no items should be set at that object.
+ if(nInvent != SdrInventor || nIdent != OBJ_NONE)
+ {
+ pAktCreate->SetMergedItemSet(aDefaultAttr);
+ }
+
+ if (HAS_BASE(SdrCaptionObj,pAktCreate))
+ {
+ SfxItemSet aSet(pMod->GetItemPool());
+ aSet.Put(XFillColorItem(String(),Color(COL_WHITE))); // Falls einer auf Solid umschaltet
+ aSet.Put(XFillStyleItem(XFILL_NONE));
+
+ pAktCreate->SetMergedItemSet(aSet);
+
+ bStartEdit=TRUE;
+ }
+ if (nInvent==SdrInventor && (nIdent==OBJ_TEXT || nIdent==OBJ_TEXTEXT ||
+ nIdent==OBJ_TITLETEXT || nIdent==OBJ_OUTLINETEXT))
+ {
+ // Fuer alle Textrahmen default keinen Hintergrund und keine Umrandung
+ SfxItemSet aSet(pMod->GetItemPool());
+ aSet.Put(XFillColorItem(String(),Color(COL_WHITE))); // Falls einer auf Solid umschaltet
+ aSet.Put(XFillStyleItem(XFILL_NONE));
+ aSet.Put(XLineColorItem(String(),Color(COL_BLACK))); // Falls einer auf Solid umschaltet
+ aSet.Put(XLineStyleItem(XLINE_NONE));
+
+ pAktCreate->SetMergedItemSet(aSet);
+
+ bStartEdit=TRUE;
+ }
+ if (!rLogRect.IsEmpty()) pAktCreate->NbcSetLogicRect(rLogRect);
+
+ // #90129# make sure drag start point is inside WorkArea
+ const Rectangle& rWorkArea = ((SdrDragView*)this)->GetWorkArea();
+
+ if(!rWorkArea.IsEmpty())
+ {
+ if(aPnt.X() < rWorkArea.Left())
+ {
+ aPnt.X() = rWorkArea.Left();
+ }
+
+ if(aPnt.X() > rWorkArea.Right())
+ {
+ aPnt.X() = rWorkArea.Right();
+ }
+
+ if(aPnt.Y() < rWorkArea.Top())
+ {
+ aPnt.Y() = rWorkArea.Top();
+ }
+
+ if(aPnt.Y() > rWorkArea.Bottom())
+ {
+ aPnt.Y() = rWorkArea.Bottom();
+ }
+ }
+
+ aDragStat.Reset(aPnt);
+ aDragStat.SetView((SdrView*)this);
+ aDragStat.SetPageView(pCreatePV);
+ aDragStat.SetMinMove(ImpGetMinMovLogic(nMinMov,pOut));
+ pDragWin=pOut;
+ if (pAktCreate->BegCreate(aDragStat))
+ {
+ ShowCreateObj(/*pOut,TRUE*/);
+ bRet=TRUE;
+ }
+ else
+ {
+ SdrObject::Free( pAktCreate );
+ pAktCreate=NULL;
+ pCreatePV=NULL;
+ }
+ }
+ }
+ }
+ return bRet;
+}
+
+BOOL SdrCreateView::BegCreateObj(const Point& rPnt, OutputDevice* pOut, short nMinMov, SdrPageView* pPV)
+{
+ return ImpBegCreateObj(nAktInvent,nAktIdent,rPnt,pOut,nMinMov,pPV,Rectangle(), 0L);
+}
+
+sal_Bool SdrCreateView::BegCreatePreparedObject(const Point& rPnt, sal_Int16 nMinMov, SdrObject* pPreparedFactoryObject)
+{
+ sal_uInt32 nInvent(nAktInvent);
+ sal_uInt16 nIdent(nAktIdent);
+
+ if(pPreparedFactoryObject)
+ {
+ nInvent = pPreparedFactoryObject->GetObjInventor();
+ nIdent = pPreparedFactoryObject->GetObjIdentifier();
+ }
+
+ return ImpBegCreateObj(nInvent, nIdent, rPnt, 0L, nMinMov, 0L, Rectangle(), pPreparedFactoryObject);
+}
+
+BOOL SdrCreateView::BegCreateCaptionObj(const Point& rPnt, const Size& rObjSiz,
+ OutputDevice* pOut, short nMinMov, SdrPageView* pPV)
+{
+ return ImpBegCreateObj(SdrInventor,OBJ_CAPTION,rPnt,pOut,nMinMov,pPV,
+ Rectangle(rPnt,Size(rObjSiz.Width()+1,rObjSiz.Height()+1)), 0L);
+}
+
+void SdrCreateView::MovCreateObj(const Point& rPnt)
+{
+ if (pAktCreate!=NULL) {
+ Point aPnt(rPnt);
+ if (!aDragStat.IsNoSnap())
+ {
+ aPnt=GetSnapPos(aPnt,pCreatePV);
+ }
+ if (IsOrtho())
+ {
+ if (aDragStat.IsOrtho8Possible()) OrthoDistance8(aDragStat.GetPrev(),aPnt,IsBigOrtho());
+ else if (aDragStat.IsOrtho4Possible()) OrthoDistance4(aDragStat.GetPrev(),aPnt,IsBigOrtho());
+ }
+
+ // #77734# If the drag point was limited and Ortho is active, do
+ // the small ortho correction (reduction) -> last parameter to FALSE.
+ sal_Bool bDidLimit(ImpLimitToWorkArea(aPnt));
+ if(bDidLimit && IsOrtho())
+ {
+ if(aDragStat.IsOrtho8Possible())
+ OrthoDistance8(aDragStat.GetPrev(), aPnt, FALSE);
+ else if(aDragStat.IsOrtho4Possible())
+ OrthoDistance4(aDragStat.GetPrev(), aPnt, FALSE);
+ }
+
+ if (aPnt==aDragStat.GetNow()) return;
+ bool bMerk(aDragStat.IsMinMoved());
+ if (aDragStat.CheckMinMoved(aPnt))
+ {
+ Rectangle aBound;
+ if (!bMerk) aDragStat.NextPoint();
+ aDragStat.NextMove(aPnt);
+ pAktCreate->MovCreate(aDragStat);
+
+ // MovCreate changes the object, so use ActionChanged() on it
+ pAktCreate->ActionChanged();
+
+ // replace for DrawCreateObjDiff
+ HideCreateObj();
+ ShowCreateObj();
+ }
+ }
+}
+
+BOOL SdrCreateView::EndCreateObj(SdrCreateCmd eCmd)
+{
+ BOOL bRet=FALSE;
+ SdrObject* pObjMerk=pAktCreate;
+ SdrPageView* pPVMerk=pCreatePV;
+
+ if (pAktCreate!=NULL)
+ {
+ ULONG nAnz=aDragStat.GetPointAnz();
+
+ if (nAnz<=1 && eCmd==SDRCREATE_FORCEEND)
+ {
+ BrkCreateObj(); // Objekte mit nur einem Punkt gibt's nicht (zumindest noch nicht)
+ return FALSE; // FALSE=Event nicht ausgewertet
+ }
+
+ BOOL bPntsEq=nAnz>1;
+ ULONG i=1;
+ Point aP0=aDragStat.GetPoint(0);
+ while (bPntsEq && i<nAnz) { bPntsEq=aP0==aDragStat.GetPoint(i); i++; }
+
+ if (pAktCreate->EndCreate(aDragStat,eCmd))
+ {
+ HideCreateObj();
+
+ if (!bPntsEq)
+ {
+ // sonst Brk, weil alle Punkte gleich sind.
+ SdrObject* pObj=pAktCreate;
+ pAktCreate=NULL;
+
+ const SdrLayerAdmin& rAd = pCreatePV->GetPage()->GetLayerAdmin();
+ SdrLayerID nLayer(0);
+
+ // #i72535#
+ if(pObj->ISA(FmFormObj))
+ {
+ // for FormControls, force to form layer
+ nLayer = rAd.GetLayerID(rAd.GetControlLayerName(), true);
+ }
+ else
+ {
+ nLayer = rAd.GetLayerID(aAktLayer, TRUE);
+ }
+
+ if(SDRLAYER_NOTFOUND == nLayer)
+ {
+ nLayer=0;
+ }
+
+ pObj->SetLayer(nLayer);
+
+ // #83403# recognize creation of a new 3D object inside a 3D scene
+ BOOL bSceneIntoScene(FALSE);
+
+ if(pObjMerk
+ && pObjMerk->ISA(E3dScene)
+ && pCreatePV
+ && pCreatePV->GetAktGroup()
+ && pCreatePV->GetAktGroup()->ISA(E3dScene))
+ {
+ BOOL bDidInsert = ((E3dView*)this)->ImpCloneAll3DObjectsToDestScene(
+ (E3dScene*)pObjMerk, (E3dScene*)pCreatePV->GetAktGroup(), Point(0, 0));
+
+ if(bDidInsert)
+ {
+ // delete object, it's content is cloned and inserted
+ SdrObject::Free( pObjMerk );
+ pObjMerk = 0L;
+ bRet = FALSE;
+ bSceneIntoScene = TRUE;
+ }
+ }
+
+ if(!bSceneIntoScene)
+ {
+ // do the same as before
+ InsertObjectAtView(pObj, *pCreatePV);
+ }
+
+ pCreatePV=NULL;
+ bRet=TRUE; // TRUE=Event ausgewertet
+ }
+ else
+ {
+ BrkCreateObj();
+ }
+ }
+ else
+ { // Mehr Punkte
+ if (eCmd==SDRCREATE_FORCEEND || // nix da, Ende erzwungen
+ nAnz==0 || // keine Punkte da (kann eigentlich nicht vorkommen)
+ (nAnz<=1 && !aDragStat.IsMinMoved())) { // MinMove nicht erfuellt
+ BrkCreateObj();
+ }
+ else
+ {
+ // replace for DrawCreateObjDiff
+ HideCreateObj();
+ ShowCreateObj();
+ aDragStat.ResetMinMoved(); // NextPoint gibt's bei MovCreateObj()
+ bRet=TRUE;
+ }
+ }
+ if (bRet && pObjMerk!=NULL && IsTextEditAfterCreate())
+ {
+ SdrTextObj* pText=PTR_CAST(SdrTextObj,pObjMerk);
+ if (pText!=NULL && pText->IsTextFrame())
+ {
+ SdrBeginTextEdit(pText, pPVMerk, (Window*)0L, sal_True, (SdrOutliner*)0L, (OutlinerView*)0L);
+ }
+ }
+ }
+ return bRet;
+}
+
+void SdrCreateView::BckCreateObj()
+{
+ if (pAktCreate!=NULL)
+ {
+ if (aDragStat.GetPointAnz()<=2 )
+ {
+ BrkCreateObj();
+ }
+ else
+ {
+ HideCreateObj();
+ aDragStat.PrevPoint();
+ if (pAktCreate->BckCreate(aDragStat))
+ {
+ ShowCreateObj();
+ }
+ else
+ {
+ BrkCreateObj();
+ }
+ }
+ }
+}
+
+void SdrCreateView::BrkCreateObj()
+{
+ if (pAktCreate!=NULL)
+ {
+ HideCreateObj();
+ pAktCreate->BrkCreate(aDragStat);
+ SdrObject::Free( pAktCreate );
+ pAktCreate=NULL;
+ pCreatePV=NULL;
+ }
+}
+
+void SdrCreateView::ShowCreateObj(/*OutputDevice* pOut, BOOL bFull*/)
+{
+ if(IsCreateObj() && !aDragStat.IsShown())
+ {
+ if(pAktCreate)
+ {
+ // for migration from XOR, replace DrawDragObj here to create
+ // overlay objects instead.
+ sal_Bool bUseSolidDragging(IsSolidDragging());
+
+ // #i101648# check if dragged object is a naked SdrObject (no
+ // derivation of). This is e.g. used in SW Frame construction
+ // as placeholder. Do not use SolidDragging for naked SDrObjects,
+ // they cannot have a valid optical representation
+ if(bUseSolidDragging && OBJ_NONE == pAktCreate->GetObjIdentifier())
+ {
+ bUseSolidDragging = false;
+ }
+
+ // check for objects with no fill and no line
+ if(bUseSolidDragging)
+ {
+ const SfxItemSet& rSet = pAktCreate->GetMergedItemSet();
+ const XFillStyle eFill(((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue());
+ const XLineStyle eLine(((XLineStyleItem&)(rSet.Get(XATTR_LINESTYLE))).GetValue());
+
+ if(XLINE_NONE == eLine && XFILL_NONE == eFill)
+ {
+ bUseSolidDragging = sal_False;
+ }
+ }
+
+ // check for form controls
+ if(bUseSolidDragging)
+ {
+ if(pAktCreate->ISA(SdrUnoObj))
+ {
+ bUseSolidDragging = sal_False;
+ }
+ }
+
+ // #i101781# force to non-solid dragging when not creating a full circle
+ if(bUseSolidDragging)
+ {
+ SdrCircObj* pCircObj = dynamic_cast< SdrCircObj* >(pAktCreate);
+
+ if(pCircObj && OBJ_CIRC != pCircObj->GetObjIdentifier())
+ {
+ // #i103058# Allow SolidDragging with four points
+ if(aDragStat.GetPointAnz() < 4)
+ {
+ bUseSolidDragging = false;
+ }
+ }
+ }
+
+ if(bUseSolidDragging)
+ {
+ basegfx::B2DPolyPolygon aDragPolyPolygon;
+
+ if(pAktCreate->ISA(SdrRectObj))
+ {
+ // ensure object has some size, necessary for SdrTextObj because
+ // there are still untested divisions by that sizes
+ Rectangle aCurrentSnapRect(pAktCreate->GetSnapRect());
+
+ if(!(aCurrentSnapRect.GetWidth() > 1 && aCurrentSnapRect.GetHeight() > 1))
+ {
+ Rectangle aNewRect(aDragStat.GetStart(), aDragStat.GetStart() + Point(2, 2));
+ pAktCreate->NbcSetSnapRect(aNewRect);
+ }
+ }
+
+ if(pAktCreate->ISA(SdrPathObj))
+ {
+ // The up-to-now created path needs to be set at the object to have something
+ // that can be visualized
+ SdrPathObj& rPathObj((SdrPathObj&)(*pAktCreate));
+ const basegfx::B2DPolyPolygon aCurrentPolyPolygon(rPathObj.getObjectPolyPolygon(aDragStat));
+
+ if(aCurrentPolyPolygon.count())
+ {
+ rPathObj.NbcSetPathPoly(aCurrentPolyPolygon);
+ }
+
+ aDragPolyPolygon = rPathObj.getDragPolyPolygon(aDragStat);
+ }
+
+ // use directly the SdrObject for overlay
+ mpCreateViewExtraData->CreateAndShowOverlay(*this, pAktCreate, aDragPolyPolygon);
+ }
+ else
+ {
+ mpCreateViewExtraData->CreateAndShowOverlay(*this, 0, pAktCreate->TakeCreatePoly(aDragStat));
+ }
+
+ // #i101679# Force changed overlay to be shown
+ for(sal_uInt32 a(0); a < PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = GetPaintWindow(a);
+ sdr::overlay::OverlayManager* pOverlayManager = pCandidate->GetOverlayManager();
+
+ if(pOverlayManager)
+ {
+ pOverlayManager->flush();
+ }
+ }
+ }
+
+ aDragStat.SetShown(TRUE);
+ }
+}
+
+void SdrCreateView::HideCreateObj()
+{
+ if(IsCreateObj() && aDragStat.IsShown())
+ {
+ // for migration from XOR, replace DrawDragObj here to create
+ // overlay objects instead.
+ mpCreateViewExtraData->HideOverlay();
+
+ //DrawCreateObj(pOut,bFull);
+ aDragStat.SetShown(FALSE);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/* new interface src537 */
+BOOL SdrCreateView::GetAttributes(SfxItemSet& rTargetSet, BOOL bOnlyHardAttr) const
+{
+ if(pAktCreate)
+ {
+ rTargetSet.Put(pAktCreate->GetMergedItemSet());
+ return TRUE;
+ }
+ else
+ {
+ return SdrDragView::GetAttributes(rTargetSet, bOnlyHardAttr);
+ }
+}
+
+BOOL SdrCreateView::SetAttributes(const SfxItemSet& rSet, BOOL bReplaceAll)
+{
+ if(pAktCreate)
+ {
+ pAktCreate->SetMergedItemSetAndBroadcast(rSet, bReplaceAll);
+
+ return TRUE;
+ }
+ else
+ {
+ return SdrDragView::SetAttributes(rSet,bReplaceAll);
+ }
+}
+
+SfxStyleSheet* SdrCreateView::GetStyleSheet() const // SfxStyleSheet* SdrCreateView::GetStyleSheet(BOOL& rOk) const
+{
+ if (pAktCreate!=NULL)
+ {
+ //rOk=TRUE;
+ return pAktCreate->GetStyleSheet();
+ }
+ else
+ {
+ return SdrDragView::GetStyleSheet(); // SdrDragView::GetStyleSheet(rOk);
+ }
+}
+
+BOOL SdrCreateView::SetStyleSheet(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr)
+{
+ if (pAktCreate!=NULL)
+ {
+ pAktCreate->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
+ return TRUE;
+ }
+ else
+ {
+ return SdrDragView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svddrag.cxx b/svx/source/svdraw/svddrag.cxx
new file mode 100644
index 000000000000..c64891bdf5d0
--- /dev/null
+++ b/svx/source/svdraw/svddrag.cxx
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/svdview.hxx>
+#include <svx/svddrag.hxx>
+
+void SdrDragStat::Clear(bool bLeaveOne)
+{
+ void* pP=aPnts.First();
+ while (pP!=NULL) {
+ delete (Point*)pP;
+ pP=aPnts.Next();
+ }
+ if (pUser!=NULL) delete pUser;
+ pUser=NULL;
+ aPnts.Clear();
+ if (bLeaveOne) {
+ aPnts.Insert(new Point,CONTAINER_APPEND);
+ }
+}
+
+void SdrDragStat::Reset()
+{
+ pView=NULL;
+ pPageView=NULL;
+ bShown=FALSE;
+ nMinMov=1;
+ bMinMoved=FALSE;
+ bHorFixed=FALSE;
+ bVerFixed=FALSE;
+ bWantNoSnap=FALSE;
+ pHdl=NULL;
+ bOrtho4=FALSE;
+ bOrtho8=FALSE;
+ pDragMethod=NULL;
+ bEndDragChangesAttributes=FALSE;
+ bEndDragChangesGeoAndAttributes=FALSE;
+ bMouseIsUp=FALSE;
+ Clear(TRUE);
+ aActionRect=Rectangle();
+}
+
+void SdrDragStat::Reset(const Point& rPnt)
+{
+ Reset();
+ Start()=rPnt;
+ aPos0=rPnt;
+ aRealPos0=rPnt;
+ RealNow()=rPnt;
+}
+
+void SdrDragStat::NextMove(const Point& rPnt)
+{
+ aRealPos0=GetRealNow();
+ aPos0=GetNow();
+ RealNow()=rPnt;
+ Point aBla=KorregPos(GetRealNow(),GetPrev());
+ Now()=aBla;
+}
+
+void SdrDragStat::NextPoint(bool bSaveReal)
+{
+ Point aPnt(GetNow());
+ if (bSaveReal) aPnt=aRealNow;
+ aPnts.Insert(new Point(KorregPos(GetRealNow(),aPnt)),CONTAINER_APPEND);
+ Prev()=aPnt;
+}
+
+void SdrDragStat::PrevPoint()
+{
+ if (aPnts.Count()>=2) { // einer muss immer da bleiben
+ Point* pPnt=(Point*)(aPnts.GetObject(aPnts.Count()-2));
+ aPnts.Remove(aPnts.Count()-2);
+ delete pPnt;
+ Now()=KorregPos(GetRealNow(),GetPrev());
+ }
+}
+
+Point SdrDragStat::KorregPos(const Point& rNow, const Point& /*rPrev*/) const
+{
+ Point aRet(rNow);
+ return aRet;
+}
+
+bool SdrDragStat::CheckMinMoved(const Point& rPnt)
+{
+ if (!bMinMoved) {
+ long dx=rPnt.X()-GetPrev().X(); if (dx<0) dx=-dx;
+ long dy=rPnt.Y()-GetPrev().Y(); if (dy<0) dy=-dy;
+ if (dx>=long(nMinMov) || dy>=long(nMinMov))
+ bMinMoved=TRUE;
+ }
+ return bMinMoved;
+}
+
+Fraction SdrDragStat::GetXFact() const
+{
+ long nMul=GetNow().X()-aRef1.X();
+ long nDiv=GetPrev().X()-aRef1.X();
+ if (nDiv==0) nDiv=1;
+ if (bHorFixed) { nMul=1; nDiv=1; }
+ return Fraction(nMul,nDiv);
+}
+
+Fraction SdrDragStat::GetYFact() const
+{
+ long nMul=GetNow().Y()-aRef1.Y();
+ long nDiv=GetPrev().Y()-aRef1.Y();
+ if (nDiv==0) nDiv=1;
+ if (bVerFixed) { nMul=1; nDiv=1; }
+ return Fraction(nMul,nDiv);
+}
+
+void SdrDragStat::TakeCreateRect(Rectangle& rRect) const
+{
+ rRect=Rectangle(GetStart(),GetNow());
+ if (GetPointAnz()>=2) {
+ Point aBtmRgt(GetPoint(1));
+ rRect.Right()=aBtmRgt.X();
+ rRect.Bottom()=aBtmRgt.Y();
+ }
+ if (pView!=NULL && pView->IsCreate1stPointAsCenter()) {
+ rRect.Top()+=rRect.Top()-rRect.Bottom();
+ rRect.Left()+=rRect.Left()-rRect.Right();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svddrgm1.hxx b/svx/source/svdraw/svddrgm1.hxx
new file mode 100644
index 000000000000..f0d2ea7790f0
--- /dev/null
+++ b/svx/source/svdraw/svddrgm1.hxx
@@ -0,0 +1,280 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVDDRGM1_HXX
+#define _SVDDRGM1_HXX
+
+#include <svx/xpoly.hxx>
+#include <svx/svdhdl.hxx>
+#include <svx/svddrgv.hxx>
+#include <svx/svddrgmt.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// predeclarations
+
+class SdrDragView;
+class SdrDragStat;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SdrDragMovHdl
+
+class SdrDragMovHdl : public SdrDragMethod
+{
+private:
+ bool bMirrObjShown;
+
+protected:
+ // define nothing, overload to do so
+ virtual void createSdrDragEntries();
+
+public:
+ TYPEINFO();
+ SdrDragMovHdl(SdrDragView& rNewView);
+
+ virtual void TakeSdrDragComment(String& rStr) const;
+ virtual bool BeginSdrDrag();
+ virtual void MoveSdrDrag(const Point& rPnt);
+ virtual bool EndSdrDrag(bool bCopy);
+ virtual void CancelSdrDrag();
+ virtual Pointer GetSdrDragPointer() const;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SdrDragRotate
+
+class SdrDragRotate : public SdrDragMethod
+{
+private:
+ double nSin;
+ double nCos;
+ long nWink0;
+ long nWink;
+ bool bRight;
+
+public:
+ TYPEINFO();
+ SdrDragRotate(SdrDragView& rNewView);
+
+ virtual void TakeSdrDragComment(String& rStr) const;
+ virtual bool BeginSdrDrag();
+ virtual void MoveSdrDrag(const Point& rPnt);
+ virtual bool EndSdrDrag(bool bCopy);
+ virtual Pointer GetSdrDragPointer() const;
+
+ virtual basegfx::B2DHomMatrix getCurrentTransformation();
+ virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SdrDragShear
+
+class SdrDragShear : public SdrDragMethod
+{
+private:
+ Fraction aFact;
+ long nWink0;
+ long nWink;
+ double nTan;
+ bool bVertical; // Vertikales verzerren
+ bool bResize; // Shear mit Resize
+ bool bUpSideDown; // Beim Shear/Slant gespiegelt
+ bool bSlant;
+
+public:
+ TYPEINFO();
+ SdrDragShear(SdrDragView& rNewView,bool bSlant1);
+
+ virtual void TakeSdrDragComment(String& rStr) const;
+ virtual bool BeginSdrDrag();
+ virtual void MoveSdrDrag(const Point& rPnt);
+ virtual bool EndSdrDrag(bool bCopy);
+ virtual Pointer GetSdrDragPointer() const;
+
+ virtual basegfx::B2DHomMatrix getCurrentTransformation();
+ virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SdrDragMirror
+
+class SdrDragMirror : public SdrDragMethod
+{
+private:
+ Point aDif;
+ long nWink;
+ bool bMirrored;
+ bool bSide0;
+
+ bool ImpCheckSide(const Point& rPnt) const;
+
+public:
+ TYPEINFO();
+ SdrDragMirror(SdrDragView& rNewView);
+
+ virtual void TakeSdrDragComment(String& rStr) const;
+ virtual bool BeginSdrDrag();
+ virtual void MoveSdrDrag(const Point& rPnt);
+ virtual bool EndSdrDrag(bool bCopy);
+ virtual Pointer GetSdrDragPointer() const;
+
+ virtual basegfx::B2DHomMatrix getCurrentTransformation();
+ virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SdrDragGradient
+
+class SdrDragGradient : public SdrDragMethod
+{
+private:
+ // Handles to work on
+ SdrHdlGradient* pIAOHandle;
+
+ // is this for gradient (or for transparence) ?
+ unsigned bIsGradient : 1;
+
+public:
+ TYPEINFO();
+ SdrDragGradient(SdrDragView& rNewView, bool bGrad = true);
+
+ bool IsGradient() const { return bIsGradient; }
+
+ virtual void TakeSdrDragComment(String& rStr) const;
+ virtual bool BeginSdrDrag();
+ virtual void MoveSdrDrag(const Point& rPnt);
+ virtual bool EndSdrDrag(bool bCopy);
+ virtual Pointer GetSdrDragPointer() const;
+ virtual void CancelSdrDrag();
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SdrDragCrook
+
+class SdrDragCrook : public SdrDragMethod
+{
+private:
+ Rectangle aMarkRect;
+ Point aMarkCenter;
+ Point aCenter;
+ Point aStart;
+ Fraction aFact;
+ Point aRad;
+ bool bContortionAllowed;
+ bool bNoContortionAllowed;
+ bool bContortion;
+ bool bResizeAllowed;
+ bool bResize;
+ bool bRotateAllowed;
+ bool bRotate;
+ bool bVertical;
+ bool bValid;
+ bool bLft;
+ bool bRgt;
+ bool bUpr;
+ bool bLwr;
+ bool bAtCenter;
+ long nWink;
+ long nMarkSize;
+ SdrCrookMode eMode;
+
+ // helpers for applyCurrentTransformationToPolyPolygon
+ void _MovAllPoints(basegfx::B2DPolyPolygon& rTarget);
+ void _MovCrookPoint(Point& rPnt, Point* pC1, Point* pC2);
+
+protected:
+ // needs to add drag geometry to the default
+ virtual void createSdrDragEntries();
+
+public:
+ TYPEINFO();
+ SdrDragCrook(SdrDragView& rNewView);
+
+ virtual void TakeSdrDragComment(String& rStr) const;
+ virtual bool BeginSdrDrag();
+ virtual void MoveSdrDrag(const Point& rPnt);
+ virtual bool EndSdrDrag(bool bCopy);
+ virtual Pointer GetSdrDragPointer() const;
+
+ virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
+ virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SdrDragDistort
+
+class SdrDragDistort : public SdrDragMethod
+{
+private:
+ Rectangle aMarkRect;
+ XPolygon aDistortedRect;
+ sal_uInt16 nPolyPt;
+ bool bContortionAllowed;
+ bool bNoContortionAllowed;
+ bool bContortion;
+
+ // helper for applyCurrentTransformationToPolyPolygon
+ void _MovAllPoints(basegfx::B2DPolyPolygon& rTarget);
+
+protected:
+ // needs to add drag geometry to the default
+ virtual void createSdrDragEntries();
+
+public:
+ TYPEINFO();
+ SdrDragDistort(SdrDragView& rNewView);
+
+ virtual void TakeSdrDragComment(String& rStr) const;
+ virtual bool BeginSdrDrag();
+ virtual void MoveSdrDrag(const Point& rPnt);
+ virtual bool EndSdrDrag(bool bCopy);
+ virtual Pointer GetSdrDragPointer() const;
+
+ virtual void applyCurrentTransformationToSdrObject(SdrObject& rTarget);
+ virtual void applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget);
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SdrDragCrop
+
+class SdrDragCrop : public SdrDragResize
+{
+public:
+ TYPEINFO();
+ SdrDragCrop(SdrDragView& rNewView);
+
+ virtual void TakeSdrDragComment(String& rStr) const;
+ virtual bool EndSdrDrag(bool bCopy);
+ virtual Pointer GetSdrDragPointer() const;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#endif //_SVDDRGM1_HXX
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
new file mode 100644
index 000000000000..ba6a22523823
--- /dev/null
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -0,0 +1,3655 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svddrgm1.hxx"
+#include <math.h>
+
+#ifndef _MATH_H
+#define _MATH_H
+#endif
+#include <tools/bigint.hxx>
+#include <vcl/svapp.hxx>
+
+#include "xattr.hxx"
+#include <svx/xpoly.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdmark.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdpagv.hxx>
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+#include <svx/svddrgv.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <svx/sdgcpitm.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/overlay/overlaypolypolygon.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <svx/sdr/overlay/overlayrollingrectangle.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <sdrpaintwindow.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include "svditer.hxx"
+#include <svx/svdopath.hxx>
+#include <svx/polypolygoneditor.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
+#include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdovirt.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <drawinglayer/attribute/sdrlineattribute.hxx>
+#include <drawinglayer/attribute/sdrlinestartendattribute.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrDragEntry::SdrDragEntry()
+: mbAddToTransparent(false)
+{
+}
+
+SdrDragEntry::~SdrDragEntry()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrDragEntryPolyPolygon::SdrDragEntryPolyPolygon(const basegfx::B2DPolyPolygon& rOriginalPolyPolygon)
+: SdrDragEntry(),
+ maOriginalPolyPolygon(rOriginalPolyPolygon)
+{
+}
+
+SdrDragEntryPolyPolygon::~SdrDragEntryPolyPolygon()
+{
+}
+
+drawinglayer::primitive2d::Primitive2DSequence SdrDragEntryPolyPolygon::createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod)
+{
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+
+ if(maOriginalPolyPolygon.count())
+ {
+ basegfx::B2DPolyPolygon aCopy(maOriginalPolyPolygon);
+ const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+
+ rDragMethod.applyCurrentTransformationToPolyPolygon(aCopy);
+ basegfx::BColor aColA(aSvtOptionsDrawinglayer.GetStripeColorA().getBColor());
+ basegfx::BColor aColB(aSvtOptionsDrawinglayer.GetStripeColorB().getBColor());
+ const double fStripeLength(aSvtOptionsDrawinglayer.GetStripeLength());
+
+ if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ aColA = aColB = Application::GetSettings().GetStyleSettings().GetHighlightColor().getBColor();
+ aColB.invert();
+ }
+
+ drawinglayer::primitive2d::Primitive2DReference aPolyPolygonMarkerPrimitive2D(
+ new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D(aCopy, aColA, aColB, fStripeLength));
+
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aPolyPolygonMarkerPrimitive2D, 1);
+ }
+
+ return aRetval;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrDragEntrySdrObject::SdrDragEntrySdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify)
+: SdrDragEntry(),
+ maOriginal(rOriginal),
+ mpClone(0),
+ mrObjectContact(rObjectContact),
+ mbModify(bModify)
+{
+ // add SdrObject parts to transparent overlay stuff
+ setAddToTransparent(true);
+}
+
+SdrDragEntrySdrObject::~SdrDragEntrySdrObject()
+{
+ if(mpClone)
+ {
+ SdrObject::Free(mpClone);
+ }
+}
+
+drawinglayer::primitive2d::Primitive2DSequence SdrDragEntrySdrObject::createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod)
+{
+ // for the moment, i need to re-create the clone in all cases. I need to figure
+ // out when clone and original have the same class, so that i can use operator=
+ // in those cases
+
+ // // copy all other needed stuff
+ // basegfx::B2DHomMatrix aMatrix;
+ // basegfx::B2DPolyPolygon aPolyPolygon;
+ // pOleObject->TRGetBaseGeometry(aMatrix, aPolyPolygon);
+ // pClone->TRSetBaseGeometry(aMatrix, aPolyPolygon);
+
+ const SdrObject* pSource = &maOriginal;
+
+ if(mpClone)
+ {
+ SdrObject::Free(mpClone);
+ mpClone = 0;
+ }
+
+ if(mbModify)
+ {
+ if(!mpClone)
+ {
+ mpClone = maOriginal.getFullDragClone();
+ }
+
+ // apply original transformation, implemented at the DragMethods
+ rDragMethod.applyCurrentTransformationToSdrObject(*mpClone);
+
+ // choose source for geometry data
+ pSource = mpClone;
+ }
+
+ // get VOC and Primitive2DSequence
+ sdr::contact::ViewContact& rVC = pSource->GetViewContact();
+ sdr::contact::ViewObjectContact& rVOC = rVC.GetViewObjectContact(mrObjectContact);
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ // Do not use the last ViewPort set at the OC from the last ProcessDisplay(),
+ // here we want the complete primitive sequence without visibility clippings
+ mrObjectContact.resetViewPort();
+
+ return rVOC.getPrimitive2DSequenceHierarchy(aDisplayInfo);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrDragEntryPrimitive2DSequence::SdrDragEntryPrimitive2DSequence(
+ const drawinglayer::primitive2d::Primitive2DSequence& rSequence,
+ bool bAddToTransparent)
+: SdrDragEntry(),
+ maPrimitive2DSequence(rSequence)
+{
+ // add parts to transparent overlay stuff eventually
+ setAddToTransparent(bAddToTransparent);
+}
+
+SdrDragEntryPrimitive2DSequence::~SdrDragEntryPrimitive2DSequence()
+{
+}
+
+drawinglayer::primitive2d::Primitive2DSequence SdrDragEntryPrimitive2DSequence::createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod)
+{
+ drawinglayer::primitive2d::Primitive2DReference aTransformPrimitive2D(
+ new drawinglayer::primitive2d::TransformPrimitive2D(
+ rDragMethod.getCurrentTransformation(),
+ maPrimitive2DSequence));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&aTransformPrimitive2D, 1);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrDragEntryPointGlueDrag::SdrDragEntryPointGlueDrag(const std::vector< basegfx::B2DPoint >& rPositions, bool bIsPointDrag)
+: maPositions(rPositions),
+ mbIsPointDrag(bIsPointDrag)
+{
+ // add SdrObject parts to transparent overlay stuff
+ setAddToTransparent(true);
+}
+
+SdrDragEntryPointGlueDrag::~SdrDragEntryPointGlueDrag()
+{
+}
+
+drawinglayer::primitive2d::Primitive2DSequence SdrDragEntryPointGlueDrag::createPrimitive2DSequenceInCurrentState(SdrDragMethod& rDragMethod)
+{
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+
+ if(maPositions.size())
+ {
+ basegfx::B2DPolygon aPolygon;
+ sal_uInt32 a(0);
+
+ for(a = 0; a < maPositions.size(); a++)
+ {
+ aPolygon.append(maPositions[a]);
+ }
+
+ basegfx::B2DPolyPolygon aPolyPolygon(aPolygon);
+
+ rDragMethod.applyCurrentTransformationToPolyPolygon(aPolyPolygon);
+
+ const basegfx::B2DPolygon aTransformed(aPolyPolygon.getB2DPolygon(0));
+ std::vector< basegfx::B2DPoint > aTransformedPositions;
+
+ aTransformedPositions.reserve(aTransformed.count());
+
+ for(a = 0; a < aTransformed.count(); a++)
+ {
+ aTransformedPositions.push_back(aTransformed.getB2DPoint(a));
+ }
+
+ if(mbIsPointDrag)
+ {
+ const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+ basegfx::BColor aColor(aSvtOptionsDrawinglayer.GetStripeColorA().getBColor());
+
+ if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ aColor = Application::GetSettings().GetStyleSettings().GetHighlightColor().getBColor();
+ }
+
+ drawinglayer::primitive2d::Primitive2DReference aMarkerArrayPrimitive2D(
+ new drawinglayer::primitive2d::MarkerArrayPrimitive2D(aTransformedPositions,
+ drawinglayer::primitive2d::createDefaultCross_3x3(aColor)));
+
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aMarkerArrayPrimitive2D, 1);
+ }
+ else
+ {
+ const basegfx::BColor aBackPen(1.0, 1.0, 1.0);
+ const basegfx::BColor aRGBFrontColor(0.0, 0.0, 1.0); // COL_LIGHTBLUE
+ drawinglayer::primitive2d::Primitive2DReference aMarkerArrayPrimitive2D(
+ new drawinglayer::primitive2d::MarkerArrayPrimitive2D(aTransformedPositions,
+ drawinglayer::primitive2d::createDefaultGluepoint_7x7(aBackPen, aRGBFrontColor)));
+
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aMarkerArrayPrimitive2D, 1);
+ }
+ }
+
+ return aRetval;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT0(SdrDragMethod);
+
+void SdrDragMethod::resetSdrDragEntries()
+{
+ // clear entries; creation is on demand
+ clearSdrDragEntries();
+}
+
+basegfx::B2DRange SdrDragMethod::getCurrentRange() const
+{
+ return getB2DRangeFromOverlayObjectList();
+}
+
+void SdrDragMethod::createSdrDragEntries()
+{
+ if(getSdrDragView().GetSdrPageView() && getSdrDragView().GetSdrPageView()->HasMarkedObjPageView())
+ {
+ if(getSdrDragView().IsDraggingPoints())
+ {
+ createSdrDragEntries_PointDrag();
+ }
+ else if(getSdrDragView().IsDraggingGluePoints())
+ {
+ createSdrDragEntries_GlueDrag();
+ }
+ else
+ {
+ if(getSolidDraggingActive())
+ {
+ createSdrDragEntries_SolidDrag();
+ }
+ else
+ {
+ createSdrDragEntries_PolygonDrag();
+ }
+ }
+ }
+}
+
+void SdrDragMethod::createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool bModify)
+{
+ // add full obejct drag; Clone() at the object has to work
+ // for this
+ addSdrDragEntry(new SdrDragEntrySdrObject(rOriginal, rObjectContact, bModify));
+}
+
+void SdrDragMethod::createSdrDragEntries_SolidDrag()
+{
+ const sal_uInt32 nMarkAnz(getSdrDragView().GetMarkedObjectCount());
+ SdrPageView* pPV = getSdrDragView().GetSdrPageView();
+
+ if(pPV)
+ {
+ for(sal_uInt32 a(0); a < nMarkAnz; a++)
+ {
+ SdrMark* pM = getSdrDragView().GetSdrMarkByIndex(a);
+
+ if(pM->GetPageView() == pPV)
+ {
+ const SdrObject* pObject = pM->GetMarkedSdrObj();
+
+ if(pObject)
+ {
+ if(pPV->PageWindowCount())
+ {
+ sdr::contact::ObjectContact& rOC = pPV->GetPageWindow(0)->GetObjectContact();
+ SdrObjListIter aIter(*pObject);
+
+ while(aIter.IsMore())
+ {
+ SdrObject* pCandidate = aIter.Next();
+
+ if(pCandidate)
+ {
+ const bool bSuppressFullDrag(!pCandidate->supportsFullDrag());
+ bool bAddWireframe(bSuppressFullDrag);
+
+ if(!bAddWireframe && !pCandidate->HasLineStyle())
+ {
+ // add wireframe for objects without outline
+ bAddWireframe = true;
+ }
+
+ if(!bSuppressFullDrag)
+ {
+ // add full obejct drag; Clone() at the object has to work
+ // for this
+ createSdrDragEntryForSdrObject(*pCandidate, rOC, true);
+ }
+
+ if(bAddWireframe)
+ {
+ // when dragging a 50% transparent copy of a filled or not filled object without
+ // outline, this is normally hard to see. Add extra wireframe in that case. This
+ // works nice e.g. with thext frames etc.
+ addSdrDragEntry(new SdrDragEntryPolyPolygon(pCandidate->TakeXorPoly()));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void SdrDragMethod::createSdrDragEntries_PolygonDrag()
+{
+ const sal_uInt32 nMarkAnz(getSdrDragView().GetMarkedObjectCount());
+ bool bNoPolygons(getSdrDragView().IsNoDragXorPolys() || nMarkAnz > getSdrDragView().GetDragXorPolyLimit());
+ basegfx::B2DPolyPolygon aResult;
+ sal_uInt32 nPointCount(0);
+
+ for(sal_uInt32 a(0); !bNoPolygons && a < nMarkAnz; a++)
+ {
+ SdrMark* pM = getSdrDragView().GetSdrMarkByIndex(a);
+
+ if(pM->GetPageView() == getSdrDragView().GetSdrPageView())
+ {
+ const basegfx::B2DPolyPolygon aNewPolyPolygon(pM->GetMarkedSdrObj()->TakeXorPoly());
+
+ for(sal_uInt32 b(0); b < aNewPolyPolygon.count(); b++)
+ {
+ nPointCount += aNewPolyPolygon.getB2DPolygon(b).count();
+ }
+
+ if(nPointCount > getSdrDragView().GetDragXorPointLimit())
+ {
+ bNoPolygons = true;
+ }
+
+ if(!bNoPolygons)
+ {
+ aResult.append(aNewPolyPolygon);
+ }
+ }
+ }
+
+ if(bNoPolygons)
+ {
+ const Rectangle aR(getSdrDragView().GetSdrPageView()->MarkSnap());
+ const basegfx::B2DRange aNewRectangle(aR.Left(), aR.Top(), aR.Right(), aR.Bottom());
+ basegfx::B2DPolygon aNewPolygon(basegfx::tools::createPolygonFromRect(aNewRectangle));
+
+ aResult = basegfx::B2DPolyPolygon(basegfx::tools::expandToCurve(aNewPolygon));
+ }
+
+ if(aResult.count())
+ {
+ addSdrDragEntry(new SdrDragEntryPolyPolygon(aResult));
+ }
+}
+
+void SdrDragMethod::createSdrDragEntries_PointDrag()
+{
+ const sal_uInt32 nMarkAnz(getSdrDragView().GetMarkedObjectCount());
+ std::vector< basegfx::B2DPoint > aPositions;
+
+ for(sal_uInt32 nm(0); nm < nMarkAnz; nm++)
+ {
+ SdrMark* pM = getSdrDragView().GetSdrMarkByIndex(nm);
+
+ if(pM->GetPageView() == getSdrDragView().GetSdrPageView())
+ {
+ const SdrUShortCont* pPts = pM->GetMarkedPoints();
+
+ if(pPts && pPts->GetCount())
+ {
+ const SdrObject* pObj = pM->GetMarkedSdrObj();
+ const SdrPathObj* pPath = dynamic_cast< const SdrPathObj* >(pObj);
+
+ if(pPath)
+ {
+ const basegfx::B2DPolyPolygon aPathXPP = pPath->GetPathPoly();
+
+ if(aPathXPP.count())
+ {
+ const sal_uInt32 nPtAnz(pPts->GetCount());
+
+ for(sal_uInt32 nPtNum(0); nPtNum < nPtAnz; nPtNum++)
+ {
+ sal_uInt32 nPolyNum, nPointNum;
+ const sal_uInt16 nObjPt(pPts->GetObject(nPtNum));
+
+ if(sdr::PolyPolygonEditor::GetRelativePolyPoint(aPathXPP, nObjPt, nPolyNum, nPointNum))
+ {
+ aPositions.push_back(aPathXPP.getB2DPolygon(nPolyNum).getB2DPoint(nPointNum));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(aPositions.size())
+ {
+ addSdrDragEntry(new SdrDragEntryPointGlueDrag(aPositions, true));
+ }
+}
+
+void SdrDragMethod::createSdrDragEntries_GlueDrag()
+{
+ const sal_uInt32 nMarkAnz(getSdrDragView().GetMarkedObjectCount());
+ std::vector< basegfx::B2DPoint > aPositions;
+
+ for(sal_uInt32 nm(0); nm < nMarkAnz; nm++)
+ {
+ SdrMark* pM = getSdrDragView().GetSdrMarkByIndex(nm);
+
+ if(pM->GetPageView() == getSdrDragView().GetSdrPageView())
+ {
+ const SdrUShortCont* pPts = pM->GetMarkedGluePoints();
+
+ if(pPts && pPts->GetCount())
+ {
+ const SdrObject* pObj = pM->GetMarkedSdrObj();
+ const SdrGluePointList* pGPL = pObj->GetGluePointList();
+
+ if(pGPL)
+ {
+ const sal_uInt32 nPtAnz(pPts->GetCount());
+
+ for(sal_uInt32 nPtNum(0); nPtNum < nPtAnz; nPtNum++)
+ {
+ const sal_uInt16 nObjPt(pPts->GetObject(nPtNum));
+ const sal_uInt16 nGlueNum(pGPL->FindGluePoint(nObjPt));
+
+ if(SDRGLUEPOINT_NOTFOUND != nGlueNum)
+ {
+ const Point aPoint((*pGPL)[nGlueNum].GetAbsolutePos(*pObj));
+ aPositions.push_back(basegfx::B2DPoint(aPoint.X(), aPoint.Y()));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(aPositions.size())
+ {
+ addSdrDragEntry(new SdrDragEntryPointGlueDrag(aPositions, false));
+ }
+}
+
+void SdrDragMethod::ImpTakeDescriptionStr(sal_uInt16 nStrCacheID, XubString& rStr, sal_uInt16 nVal) const
+{
+ sal_uInt16 nOpt=0;
+ if (IsDraggingPoints()) {
+ nOpt=IMPSDR_POINTSDESCRIPTION;
+ } else if (IsDraggingGluePoints()) {
+ nOpt=IMPSDR_GLUEPOINTSDESCRIPTION;
+ }
+ getSdrDragView().ImpTakeDescriptionStr(nStrCacheID,rStr,nVal,nOpt);
+}
+
+SdrObject* SdrDragMethod::GetDragObj() const
+{
+ SdrObject* pObj=NULL;
+ if (getSdrDragView().pDragHdl!=NULL) pObj=getSdrDragView().pDragHdl->GetObj();
+ if (pObj==NULL) pObj=getSdrDragView().pMarkedObj;
+ return pObj;
+}
+
+SdrPageView* SdrDragMethod::GetDragPV() const
+{
+ SdrPageView* pPV=NULL;
+ if (getSdrDragView().pDragHdl!=NULL) pPV=getSdrDragView().pDragHdl->GetPageView();
+ if (pPV==NULL) pPV=getSdrDragView().pMarkedPV;
+ return pPV;
+}
+
+void SdrDragMethod::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
+{
+ // the original applies the transformation using TRGetBaseGeometry/TRSetBaseGeometry.
+ // Later this should be the only needed one for linear transforms (not for SdrDragCrook and
+ // SdrDragDistort, those are NOT linear). Currently, this can not yet be used since the
+ // special handling of rotate/mirror due to the not-being-able to handle it in the old
+ // drawinglayer stuff. Text would currently not correctly be mirrored in the preview.
+ basegfx::B2DHomMatrix aObjectTransform;
+ basegfx::B2DPolyPolygon aObjectPolyPolygon;
+ bool bPolyUsed(rTarget.TRGetBaseGeometry(aObjectTransform, aObjectPolyPolygon));
+
+ // apply transform to object transform
+ aObjectTransform *= getCurrentTransformation();
+
+ if(bPolyUsed)
+ {
+ // do something special since the object size is in the polygon
+ // break up matrix to get the scale
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate, fShearX;
+ aObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // get polygon's pos and size
+ const basegfx::B2DRange aPolyRange(aObjectPolyPolygon.getB2DRange());
+
+ // get the scaling factors (do not mirror, this is in the object transformation)
+ const double fScaleX(fabs(aScale.getX()) / (basegfx::fTools::equalZero(aPolyRange.getWidth()) ? 1.0 : aPolyRange.getWidth()));
+ const double fScaleY(fabs(aScale.getY()) / (basegfx::fTools::equalZero(aPolyRange.getHeight()) ? 1.0 : aPolyRange.getHeight()));
+
+ // prepare transform matrix for polygon
+ basegfx::B2DHomMatrix aPolyTransform(basegfx::tools::createTranslateB2DHomMatrix(
+ -aPolyRange.getMinX(), -aPolyRange.getMinY()));
+ aPolyTransform.scale(fScaleX, fScaleY);
+
+ // normally the poly should be moved back, but the translation is in the object
+ // transformation and thus does not need to be done
+ // aPolyTransform.translate(-aPolyRange.getMinX(), -aPolyRange.getMinY());
+
+ // transform the polygon
+ aObjectPolyPolygon.transform(aPolyTransform);
+ }
+
+ rTarget.TRSetBaseGeometry(getCurrentTransformation() * aObjectTransform, aObjectPolyPolygon);
+}
+
+void SdrDragMethod::applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget)
+{
+ // original uses CurrentTransformation
+ rTarget.transform(getCurrentTransformation());
+}
+
+SdrDragMethod::SdrDragMethod(SdrDragView& rNewView)
+: maSdrDragEntries(),
+ maOverlayObjectList(),
+ mrSdrDragView(rNewView),
+ mbMoveOnly(false),
+ mbSolidDraggingActive(getSdrDragView().IsSolidDragging())
+{
+ if(mbSolidDraggingActive && Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ // fallback to wireframe when high contrast is used
+ mbSolidDraggingActive = false;
+ }
+}
+
+SdrDragMethod::~SdrDragMethod()
+{
+ clearSdrDragEntries();
+}
+
+void SdrDragMethod::Show()
+{
+ getSdrDragView().ShowDragObj();
+}
+
+void SdrDragMethod::Hide()
+{
+ getSdrDragView().HideDragObj();
+}
+
+basegfx::B2DHomMatrix SdrDragMethod::getCurrentTransformation()
+{
+ return basegfx::B2DHomMatrix();
+}
+
+void SdrDragMethod::CancelSdrDrag()
+{
+ Hide();
+}
+
+void SdrDragMethod::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager)
+{
+ // create SdrDragEntries on demand
+ if(!maSdrDragEntries.size())
+ {
+ createSdrDragEntries();
+ }
+
+ // if there are entries, derive OverlayObjects from the entries, including
+ // modification from current interactive state
+ if(maSdrDragEntries.size())
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aResult;
+ drawinglayer::primitive2d::Primitive2DSequence aResultTransparent;
+
+ for(sal_uInt32 a(0); a < maSdrDragEntries.size(); a++)
+ {
+ SdrDragEntry* pCandidate = maSdrDragEntries[a];
+
+ if(pCandidate)
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence aCandidateResult(pCandidate->createPrimitive2DSequenceInCurrentState(*this));
+
+ if(aCandidateResult.hasElements())
+ {
+ if(pCandidate->getAddToTransparent())
+ {
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aResultTransparent, aCandidateResult);
+ }
+ else
+ {
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aResult, aCandidateResult);
+ }
+ }
+ }
+ }
+
+ if(DoAddConnectorOverlays())
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence aConnectorOverlays(AddConnectorOverlays());
+
+ if(aConnectorOverlays.hasElements())
+ {
+ // add connector overlays to transparent part
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aResultTransparent, aConnectorOverlays);
+ }
+ }
+
+ if(aResult.hasElements())
+ {
+ sdr::overlay::OverlayObject* pNewOverlayObject = new sdr::overlay::OverlayPrimitive2DSequenceObject(aResult);
+ rOverlayManager.add(*pNewOverlayObject);
+ addToOverlayObjectList(*pNewOverlayObject);
+ }
+
+ if(aResultTransparent.hasElements())
+ {
+ drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparencePrimitive2D(new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(aResultTransparent, 0.5));
+ aResultTransparent = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedTransparencePrimitive2D, 1);
+
+ sdr::overlay::OverlayObject* pNewOverlayObject = new sdr::overlay::OverlayPrimitive2DSequenceObject(aResultTransparent);
+ rOverlayManager.add(*pNewOverlayObject);
+ addToOverlayObjectList(*pNewOverlayObject);
+ }
+ }
+
+ // evtl add DragStripes (help lines cross the page when dragging)
+ if(getSdrDragView().IsDragStripes())
+ {
+ Rectangle aActionRectangle;
+ getSdrDragView().TakeActionRect(aActionRectangle);
+
+ const basegfx::B2DPoint aTopLeft(aActionRectangle.Left(), aActionRectangle.Top());
+ const basegfx::B2DPoint aBottomRight(aActionRectangle.Right(), aActionRectangle.Bottom());
+ sdr::overlay::OverlayRollingRectangleStriped* pNew = new sdr::overlay::OverlayRollingRectangleStriped(
+ aTopLeft, aBottomRight, true, false);
+
+ rOverlayManager.add(*pNew);
+ addToOverlayObjectList(*pNew);
+ }
+}
+
+void SdrDragMethod::destroyOverlayGeometry()
+{
+ clearOverlayObjectList();
+}
+
+bool SdrDragMethod::DoAddConnectorOverlays()
+{
+ // these conditions are translated from SdrDragView::ImpDrawEdgeXor
+ const SdrMarkList& rMarkedNodes = getSdrDragView().GetEdgesOfMarkedNodes();
+
+ if(!rMarkedNodes.GetMarkCount())
+ {
+ return false;
+ }
+
+ if(!getSdrDragView().IsRubberEdgeDragging() && !getSdrDragView().IsDetailedEdgeDragging())
+ {
+ return false;
+ }
+
+ if(getSdrDragView().IsDraggingPoints() || getSdrDragView().IsDraggingGluePoints())
+ {
+ return false;
+ }
+
+ if(!getMoveOnly() && !(
+ IS_TYPE(SdrDragMove, this) || IS_TYPE(SdrDragResize, this) ||
+ IS_TYPE(SdrDragRotate,this) || IS_TYPE(SdrDragMirror,this)))
+ {
+ return false;
+ }
+
+ const bool bDetail(getSdrDragView().IsDetailedEdgeDragging() && getMoveOnly());
+
+ if(!bDetail && !getSdrDragView().IsRubberEdgeDragging())
+ {
+ return false;
+ }
+
+ // one more migrated from SdrEdgeObj::NspToggleEdgeXor
+ if(IS_TYPE(SdrDragObjOwn, this) || IS_TYPE(SdrDragMovHdl, this))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+drawinglayer::primitive2d::Primitive2DSequence SdrDragMethod::AddConnectorOverlays()
+{
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+ const bool bDetail(getSdrDragView().IsDetailedEdgeDragging() && getMoveOnly());
+ const SdrMarkList& rMarkedNodes = getSdrDragView().GetEdgesOfMarkedNodes();
+
+ for(sal_uInt16 a(0); a < rMarkedNodes.GetMarkCount(); a++)
+ {
+ SdrMark* pEM = rMarkedNodes.GetMark(a);
+
+ if(pEM && pEM->GetMarkedSdrObj())
+ {
+ SdrEdgeObj* pEdge = dynamic_cast< SdrEdgeObj* >(pEM->GetMarkedSdrObj());
+
+ if(pEdge)
+ {
+ const basegfx::B2DPolygon aEdgePolygon(pEdge->ImplAddConnectorOverlay(*this, pEM->IsCon1(), pEM->IsCon2(), bDetail));
+
+ if(aEdgePolygon.count())
+ {
+ // this polygon is a temporary calculated connector path, so it is not possible to fetch
+ // the needed primitives directly from the pEdge object which does not get changed. If full
+ // drag is on, use the SdrObjects ItemSet to create a adequate representation
+ bool bUseSolidDragging(getSolidDraggingActive());
+
+ if(bUseSolidDragging)
+ {
+ // switch off solid dragging if connector is not visible
+ if(!pEdge->HasLineStyle())
+ {
+ bUseSolidDragging = false;
+ }
+ }
+
+ if(bUseSolidDragging)
+ {
+ const SfxItemSet& rItemSet = pEdge->GetMergedItemSet();
+ const drawinglayer::attribute::SdrLineAttribute aLine(
+ drawinglayer::primitive2d::createNewSdrLineAttribute(rItemSet));
+
+ if(!aLine.isDefault())
+ {
+ const drawinglayer::attribute::SdrLineStartEndAttribute aLineStartEnd(
+ drawinglayer::primitive2d::createNewSdrLineStartEndAttribute(
+ rItemSet,
+ aLine.getWidth()));
+
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(
+ aRetval, drawinglayer::primitive2d::createPolygonLinePrimitive(
+ aEdgePolygon,
+ basegfx::B2DHomMatrix(),
+ aLine,
+ aLineStartEnd));
+ }
+ }
+ else
+ {
+ const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+ basegfx::BColor aColA(aSvtOptionsDrawinglayer.GetStripeColorA().getBColor());
+ basegfx::BColor aColB(aSvtOptionsDrawinglayer.GetStripeColorB().getBColor());
+ const double fStripeLength(aSvtOptionsDrawinglayer.GetStripeLength());
+
+ if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ aColA = aColB = Application::GetSettings().GetStyleSettings().GetHighlightColor().getBColor();
+ aColB.invert();
+ }
+
+ drawinglayer::primitive2d::Primitive2DReference aPolyPolygonMarkerPrimitive2D(
+ new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D(
+ basegfx::B2DPolyPolygon(aEdgePolygon), aColA, aColB, fStripeLength));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, aPolyPolygonMarkerPrimitive2D);
+ }
+ }
+ }
+ }
+ }
+
+ return aRetval;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragMovHdl,SdrDragMethod);
+
+SdrDragMovHdl::SdrDragMovHdl(SdrDragView& rNewView)
+: SdrDragMethod(rNewView),
+ bMirrObjShown(false)
+{
+}
+
+void SdrDragMovHdl::createSdrDragEntries()
+{
+ // SdrDragMovHdl does not use the default drags,
+ // but creates nothing
+}
+
+void SdrDragMovHdl::TakeSdrDragComment(XubString& rStr) const
+{
+ rStr=ImpGetResStr(STR_DragMethMovHdl);
+ if (getSdrDragView().IsDragWithCopy()) rStr+=ImpGetResStr(STR_EditWithCopy);
+}
+
+bool SdrDragMovHdl::BeginSdrDrag()
+{
+ DragStat().Ref1()=GetDragHdl()->GetPos();
+ DragStat().SetShown(!DragStat().IsShown());
+ SdrHdlKind eKind=GetDragHdl()->GetKind();
+ SdrHdl* pH1=GetHdlList().GetHdl(HDL_REF1);
+ SdrHdl* pH2=GetHdlList().GetHdl(HDL_REF2);
+
+ if (eKind==HDL_MIRX)
+ {
+ if (pH1==NULL || pH2==NULL)
+ {
+ DBG_ERROR("SdrDragMovHdl::BeginSdrDrag(): Verschieben der Spiegelachse: Referenzhandles nicht gefunden");
+ return false;
+ }
+
+ DragStat().SetActionRect(Rectangle(pH1->GetPos(),pH2->GetPos()));
+ }
+ else
+ {
+ Point aPt(GetDragHdl()->GetPos());
+ DragStat().SetActionRect(Rectangle(aPt,aPt));
+ }
+
+ return true;
+}
+
+void SdrDragMovHdl::MoveSdrDrag(const Point& rNoSnapPnt)
+{
+ Point aPnt(rNoSnapPnt);
+
+ if (DragStat().CheckMinMoved(rNoSnapPnt))
+ {
+ if (GetDragHdl()->GetKind()==HDL_MIRX)
+ {
+ SdrHdl* pH1=GetHdlList().GetHdl(HDL_REF1);
+ SdrHdl* pH2=GetHdlList().GetHdl(HDL_REF2);
+
+ if (pH1==NULL || pH2==NULL)
+ return;
+
+ if (!DragStat().IsNoSnap())
+ {
+ long nBestXSnap=0;
+ long nBestYSnap=0;
+ bool bXSnapped=false;
+ bool bYSnapped=false;
+ Point aDif(aPnt-DragStat().GetStart());
+ getSdrDragView().CheckSnap(Ref1()+aDif,NULL,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
+ getSdrDragView().CheckSnap(Ref2()+aDif,NULL,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
+ aPnt.X()+=nBestXSnap;
+ aPnt.Y()+=nBestYSnap;
+ }
+
+ if (aPnt!=DragStat().GetNow())
+ {
+ Hide();
+ DragStat().NextMove(aPnt);
+ Point aDif(DragStat().GetNow()-DragStat().GetStart());
+ pH1->SetPos(Ref1()+aDif);
+ pH2->SetPos(Ref2()+aDif);
+
+ SdrHdl* pHM = GetHdlList().GetHdl(HDL_MIRX);
+
+ if(pHM)
+ pHM->Touch();
+
+ Show();
+ DragStat().SetActionRect(Rectangle(pH1->GetPos(),pH2->GetPos()));
+ }
+ }
+ else
+ {
+ if (!DragStat().IsNoSnap()) SnapPos(aPnt);
+ long nSA=0;
+
+ if (getSdrDragView().IsAngleSnapEnabled())
+ nSA=getSdrDragView().GetSnapAngle();
+
+ if (getSdrDragView().IsMirrorAllowed(true,true))
+ { // eingeschraenkt
+ if (!getSdrDragView().IsMirrorAllowed(false,false)) nSA=4500;
+ if (!getSdrDragView().IsMirrorAllowed(true,false)) nSA=9000;
+ }
+
+ if (getSdrDragView().IsOrtho() && nSA!=9000)
+ nSA=4500;
+
+ if (nSA!=0)
+ { // Winkelfang
+ SdrHdlKind eRef=HDL_REF1;
+
+ if (GetDragHdl()->GetKind()==HDL_REF1)
+ eRef=HDL_REF2;
+
+ SdrHdl* pH=GetHdlList().GetHdl(eRef);
+
+ if (pH!=NULL)
+ {
+ Point aRef(pH->GetPos());
+ long nWink=NormAngle360(GetAngle(aPnt-aRef));
+ long nNeuWink=nWink;
+ nNeuWink+=nSA/2;
+ nNeuWink/=nSA;
+ nNeuWink*=nSA;
+ nNeuWink=NormAngle360(nNeuWink);
+ double a=(nNeuWink-nWink)*nPi180;
+ double nSin=sin(a);
+ double nCos=cos(a);
+ RotatePoint(aPnt,aRef,nSin,nCos);
+
+ // Bei bestimmten Werten Rundungsfehler ausschliessen:
+ if (nSA==9000)
+ {
+ if (nNeuWink==0 || nNeuWink==18000) aPnt.Y()=aRef.Y();
+ if (nNeuWink==9000 || nNeuWink==27000) aPnt.X()=aRef.X();
+ }
+
+ if (nSA==4500)
+ OrthoDistance8(aRef,aPnt,true);
+ }
+ }
+
+ if (aPnt!=DragStat().GetNow())
+ {
+ Hide();
+ DragStat().NextMove(aPnt);
+ GetDragHdl()->SetPos(DragStat().GetNow());
+ SdrHdl* pHM = GetHdlList().GetHdl(HDL_MIRX);
+
+ if(pHM)
+ pHM->Touch();
+
+ Show();
+ DragStat().SetActionRect(Rectangle(aPnt,aPnt));
+ }
+ }
+ }
+}
+
+bool SdrDragMovHdl::EndSdrDrag(bool /*bCopy*/)
+{
+ switch (GetDragHdl()->GetKind())
+ {
+ case HDL_REF1:
+ Ref1()=DragStat().GetNow();
+ break;
+
+ case HDL_REF2:
+ Ref2()=DragStat().GetNow();
+ break;
+
+ case HDL_MIRX:
+ Ref1()+=DragStat().GetNow()-DragStat().GetStart();
+ Ref2()+=DragStat().GetNow()-DragStat().GetStart();
+ break;
+
+ default: break;
+ }
+
+ return true;
+}
+
+void SdrDragMovHdl::CancelSdrDrag()
+{
+ Hide();
+ GetDragHdl()->SetPos(DragStat().GetRef1());
+ SdrHdl* pHM = GetHdlList().GetHdl(HDL_MIRX);
+
+ if(pHM)
+ pHM->Touch();
+}
+
+Pointer SdrDragMovHdl::GetSdrDragPointer() const
+{
+ const SdrHdl* pHdl = GetDragHdl();
+
+ if (pHdl!=NULL)
+ {
+ return pHdl->GetPointer();
+ }
+
+ return Pointer(POINTER_REFHAND);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragObjOwn,SdrDragMethod);
+
+SdrDragObjOwn::SdrDragObjOwn(SdrDragView& rNewView)
+: SdrDragMethod(rNewView),
+ mpClone(0)
+{
+ const SdrObject* pObj = GetDragObj();
+
+ if(pObj)
+ {
+ // suppress full drag for some object types
+ setSolidDraggingActive(pObj->supportsFullDrag());
+ }
+}
+
+SdrDragObjOwn::~SdrDragObjOwn()
+{
+ if(mpClone)
+ {
+ SdrObject::Free(mpClone);
+ }
+}
+
+void SdrDragObjOwn::createSdrDragEntries()
+{
+ if(mpClone)
+ {
+ basegfx::B2DPolyPolygon aDragPolyPolygon;
+ bool bAddWireframe(true);
+
+ if(getSolidDraggingActive())
+ {
+ SdrPageView* pPV = getSdrDragView().GetSdrPageView();
+
+ if(pPV && pPV->PageWindowCount())
+ {
+ sdr::contact::ObjectContact& rOC = pPV->GetPageWindow(0)->GetObjectContact();
+ addSdrDragEntry(new SdrDragEntrySdrObject(*mpClone, rOC, false));
+
+ // potentially no wireframe needed, full drag works
+ bAddWireframe = false;
+ }
+ }
+
+ if(!bAddWireframe)
+ {
+ // check for extra conditions for wireframe, e.g. no border at
+ // objects
+ if(!mpClone->HasLineStyle())
+ {
+ bAddWireframe = true;
+ }
+ }
+
+ if(bAddWireframe)
+ {
+ // use wireframe poly when full drag is off or did not work
+ aDragPolyPolygon = mpClone->TakeXorPoly();
+ }
+
+ // add evtl. extra DragPolyPolygon
+ const basegfx::B2DPolyPolygon aSpecialDragPolyPolygon(mpClone->getSpecialDragPoly(DragStat()));
+
+ if(aSpecialDragPolyPolygon.count())
+ {
+ aDragPolyPolygon.append(aSpecialDragPolyPolygon);
+ }
+
+ if(aDragPolyPolygon.count())
+ {
+ addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragPolyPolygon));
+ }
+ }
+}
+
+void SdrDragObjOwn::TakeSdrDragComment(XubString& rStr) const
+{
+ // #i103058# get info string from the clone preferred, the original will
+ // not be changed. For security, use original as fallback
+ if(mpClone)
+ {
+ rStr = mpClone->getSpecialDragComment(DragStat());
+ }
+ else
+ {
+ const SdrObject* pObj = GetDragObj();
+
+ if(pObj)
+ {
+ rStr = pObj->getSpecialDragComment(DragStat());
+ }
+ }
+}
+
+bool SdrDragObjOwn::BeginSdrDrag()
+{
+ if(!mpClone)
+ {
+ const SdrObject* pObj = GetDragObj();
+
+ if(pObj && !pObj->IsResizeProtect())
+ {
+ if(pObj->beginSpecialDrag(DragStat()))
+ {
+ // create nitial clone to have a start visualisation
+ mpClone = pObj->getFullDragClone();
+ mpClone->applySpecialDrag(DragStat());
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+void SdrDragObjOwn::MoveSdrDrag(const Point& rNoSnapPnt)
+{
+ const SdrObject* pObj = GetDragObj();
+
+ if(pObj)
+ {
+ Point aPnt(rNoSnapPnt);
+ SdrPageView* pPV = GetDragPV();
+
+ if(pPV)
+ {
+ if(!DragStat().IsNoSnap())
+ {
+ SnapPos(aPnt);
+ }
+
+ if(getSdrDragView().IsOrtho())
+ {
+ if (DragStat().IsOrtho8Possible())
+ {
+ OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho());
+ }
+ else if (DragStat().IsOrtho4Possible())
+ {
+ OrthoDistance4(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho());
+ }
+ }
+
+ if(DragStat().CheckMinMoved(rNoSnapPnt))
+ {
+ if(aPnt != DragStat().GetNow())
+ {
+ Hide();
+ DragStat().NextMove(aPnt);
+
+ // since SdrDragObjOwn currently supports no transformation of
+ // existing SdrDragEntries but only their recreation, a recreation
+ // after every move is needed in this mode. Delete existing
+ // SdrDragEntries here to force their recreation in the following Show().
+ clearSdrDragEntries();
+
+ // delete current clone (after the last reference to it is deleted above)
+ if(mpClone)
+ {
+ SdrObject::Free(mpClone);
+ mpClone = 0;
+ }
+
+ // create a new clone and modify to current drag state
+ if(!mpClone)
+ {
+ mpClone = pObj->getFullDragClone();
+ mpClone->applySpecialDrag(DragStat());
+ }
+
+ Show();
+ }
+ }
+ }
+ }
+}
+
+bool SdrDragObjOwn::EndSdrDrag(bool /*bCopy*/)
+{
+ Hide();
+ SdrUndoAction* pUndo = NULL;
+ SdrUndoAction* pUndo2 = NULL;
+ std::vector< SdrUndoAction* > vConnectorUndoActions;
+ bool bRet = false;
+ SdrObject* pObj = GetDragObj();
+
+ if(pObj)
+ {
+ const bool bUndo = getSdrDragView().IsUndoEnabled();
+
+ if( bUndo )
+ {
+ if(!getSdrDragView().IsInsObjPoint() && pObj->IsInserted() )
+ {
+ if (DragStat().IsEndDragChangesAttributes())
+ {
+ pUndo=getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj);
+
+ if (DragStat().IsEndDragChangesGeoAndAttributes())
+ {
+ vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj );
+ pUndo2 = getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj);
+ }
+ }
+ else
+ {
+ vConnectorUndoActions = getSdrDragView().CreateConnectorUndo( *pObj );
+ pUndo= getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj);
+ }
+ }
+
+ if( pUndo )
+ {
+ getSdrDragView().BegUndo( pUndo->GetComment() );
+ }
+ else
+ {
+ getSdrDragView().BegUndo();
+ }
+ }
+
+ // evtl. use opertator= for setting changed object data (do not change selection in
+ // view, this will destroy the interactor). This is possible since a clone is now
+ // directly modified by the modifiers. Only SdrTableObj is adding own UNDOs
+ // in it's SdrTableObj::endSpecialDrag, so currently not possible. OTOH it uses
+ // a CreateUndoGeoObject() so maybe setting SetEndDragChangesAttributes is okay. I
+ // will test this now
+ Rectangle aBoundRect0;
+
+ if(pObj->GetUserCall())
+ {
+ aBoundRect0 = pObj->GetLastBoundRect();
+ }
+
+ bRet = pObj->applySpecialDrag(DragStat());
+
+ if(bRet)
+ {
+ pObj->SetChanged();
+ pObj->BroadcastObjectChange();
+ pObj->SendUserCall( SDRUSERCALL_RESIZE, aBoundRect0 );
+ }
+
+ if(bRet)
+ {
+ if( bUndo )
+ {
+ getSdrDragView().AddUndoActions( vConnectorUndoActions );
+
+ if ( pUndo )
+ {
+ getSdrDragView().AddUndo(pUndo);
+ }
+
+ if ( pUndo2 )
+ {
+ getSdrDragView().AddUndo(pUndo2);
+ }
+ }
+ }
+ else
+ {
+ if( bUndo )
+ {
+ std::vector< SdrUndoAction* >::iterator vConnectorUndoIter( vConnectorUndoActions.begin() );
+
+ while( vConnectorUndoIter != vConnectorUndoActions.end() )
+ {
+ delete *vConnectorUndoIter++;
+ }
+
+ delete pUndo;
+ delete pUndo2;
+ }
+ }
+
+ if( bUndo )
+ getSdrDragView().EndUndo();
+ }
+
+ return bRet;
+}
+
+Pointer SdrDragObjOwn::GetSdrDragPointer() const
+{
+ const SdrHdl* pHdl=GetDragHdl();
+
+ if (pHdl)
+ {
+ return pHdl->GetPointer();
+ }
+
+ return Pointer(POINTER_MOVE);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragMove,SdrDragMethod);
+
+void SdrDragMove::createSdrDragEntryForSdrObject(const SdrObject& rOriginal, sdr::contact::ObjectContact& rObjectContact, bool /*bModify*/)
+{
+ // for SdrDragMove, use current Primitive2DSequence of SdrObject visualisation
+ // in given ObjectContact directly
+ sdr::contact::ViewContact& rVC = rOriginal.GetViewContact();
+ sdr::contact::ViewObjectContact& rVOC = rVC.GetViewObjectContact(rObjectContact);
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ // Do not use the last ViewPort set at the OC from the last ProcessDisplay(),
+ // here we want the complete primitive sequence without visibility clippings
+ rObjectContact.resetViewPort();
+
+ addSdrDragEntry(new SdrDragEntryPrimitive2DSequence(rVOC.getPrimitive2DSequenceHierarchy(aDisplayInfo), true));
+}
+
+void SdrDragMove::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
+{
+ rTarget.Move(Size(DragStat().GetDX(), DragStat().GetDY()));
+}
+
+SdrDragMove::SdrDragMove(SdrDragView& rNewView)
+: SdrDragMethod(rNewView)
+{
+ setMoveOnly(true);
+}
+
+void SdrDragMove::TakeSdrDragComment(XubString& rStr) const
+{
+ XubString aStr;
+
+ ImpTakeDescriptionStr(STR_DragMethMove, rStr);
+ rStr.AppendAscii(" (x=");
+ getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDX(), aStr);
+ rStr += aStr;
+ rStr.AppendAscii(" y=");
+ getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr);
+ rStr += aStr;
+ rStr += sal_Unicode(')');
+
+ if(getSdrDragView().IsDragWithCopy())
+ {
+ if(!getSdrDragView().IsInsObjPoint() && !getSdrDragView().IsInsGluePoint())
+ {
+ rStr += ImpGetResStr(STR_EditWithCopy);
+ }
+ }
+}
+
+bool SdrDragMove::BeginSdrDrag()
+{
+ DragStat().SetActionRect(GetMarkedRect());
+ Show();
+
+ return true;
+}
+
+basegfx::B2DHomMatrix SdrDragMove::getCurrentTransformation()
+{
+ return basegfx::tools::createTranslateB2DHomMatrix(DragStat().GetDX(), DragStat().GetDY());
+}
+
+void SdrDragMove::ImpCheckSnap(const Point& rPt)
+{
+ Point aPt(rPt);
+ sal_uInt16 nRet=SnapPos(aPt);
+ aPt-=rPt;
+
+ if ((nRet & SDRSNAP_XSNAPPED) !=0)
+ {
+ if (bXSnapped)
+ {
+ if (Abs(aPt.X())<Abs(nBestXSnap))
+ {
+ nBestXSnap=aPt.X();
+ }
+ }
+ else
+ {
+ nBestXSnap=aPt.X();
+ bXSnapped=true;
+ }
+ }
+
+ if ((nRet & SDRSNAP_YSNAPPED) !=0)
+ {
+ if (bYSnapped)
+ {
+ if (Abs(aPt.Y())<Abs(nBestYSnap))
+ {
+ nBestYSnap=aPt.Y();
+ }
+ }
+ else
+ {
+ nBestYSnap=aPt.Y();
+ bYSnapped=true;
+ }
+ }
+}
+
+void SdrDragMove::MoveSdrDrag(const Point& rNoSnapPnt_)
+{
+ nBestXSnap=0;
+ nBestYSnap=0;
+ bXSnapped=false;
+ bYSnapped=false;
+ Point aNoSnapPnt(rNoSnapPnt_);
+ const Rectangle& aSR=GetMarkedRect();
+ long nMovedx=aNoSnapPnt.X()-DragStat().GetStart().X();
+ long nMovedy=aNoSnapPnt.Y()-DragStat().GetStart().Y();
+ Point aLO(aSR.TopLeft()); aLO.X()+=nMovedx; aLO.Y()+=nMovedy;
+ Point aRU(aSR.BottomRight()); aRU.X()+=nMovedx; aRU.Y()+=nMovedy;
+ Point aLU(aLO.X(),aRU.Y());
+ Point aRO(aRU.X(),aLO.Y());
+ ImpCheckSnap(aLO);
+
+ if (!getSdrDragView().IsMoveSnapOnlyTopLeft())
+ {
+ ImpCheckSnap(aRO);
+ ImpCheckSnap(aLU);
+ ImpCheckSnap(aRU);
+ }
+
+ Point aPnt(aNoSnapPnt.X()+nBestXSnap,aNoSnapPnt.Y()+nBestYSnap);
+ bool bOrtho=getSdrDragView().IsOrtho();
+
+ if (bOrtho)
+ OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho());
+
+ if (DragStat().CheckMinMoved(aNoSnapPnt))
+ {
+ Point aPt1(aPnt);
+ Rectangle aLR(getSdrDragView().GetWorkArea());
+ bool bWorkArea=!aLR.IsEmpty();
+ bool bDragLimit=IsDragLimit();
+
+ if (bDragLimit || bWorkArea)
+ {
+ Rectangle aSR2(GetMarkedRect());
+ Point aD(aPt1-DragStat().GetStart());
+
+ if (bDragLimit)
+ {
+ Rectangle aR2(GetDragLimitRect());
+
+ if (bWorkArea)
+ aLR.Intersection(aR2);
+ else
+ aLR=aR2;
+ }
+
+ if (aSR2.Left()>aLR.Left() || aSR2.Right()<aLR.Right())
+ { // ist ueberhaupt Platz zum verschieben?
+ aSR2.Move(aD.X(),0);
+
+ if (aSR2.Left()<aLR.Left())
+ {
+ aPt1.X()-=aSR2.Left()-aLR.Left();
+ }
+ else if (aSR2.Right()>aLR.Right())
+ {
+ aPt1.X()-=aSR2.Right()-aLR.Right();
+ }
+ }
+ else
+ aPt1.X()=DragStat().GetStart().X(); // kein Platz zum verschieben
+
+ if (aSR2.Top()>aLR.Top() || aSR2.Bottom()<aLR.Bottom())
+ { // ist ueberhaupt Platz zum verschieben?
+ aSR2.Move(0,aD.Y());
+
+ if (aSR2.Top()<aLR.Top())
+ {
+ aPt1.Y()-=aSR2.Top()-aLR.Top();
+ }
+ else if (aSR2.Bottom()>aLR.Bottom())
+ {
+ aPt1.Y()-=aSR2.Bottom()-aLR.Bottom();
+ }
+ }
+ else
+ aPt1.Y()=DragStat().GetStart().Y(); // kein Platz zum verschieben
+ }
+
+ if (getSdrDragView().IsDraggingGluePoints())
+ { // Klebepunkte aufs BoundRect des Obj limitieren
+ aPt1-=DragStat().GetStart();
+ const SdrMarkList& rML=GetMarkedObjectList();
+ ULONG nMarkAnz=rML.GetMarkCount();
+
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++)
+ {
+ const SdrMark* pM=rML.GetMark(nMarkNum);
+ const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
+ ULONG nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+
+ if (nPtAnz!=0)
+ {
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ const SdrGluePointList* pGPL=pObj->GetGluePointList();
+ Rectangle aBound(pObj->GetCurrentBoundRect());
+
+ for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++)
+ {
+ sal_uInt16 nId=pPts->GetObject(nPtNum);
+ sal_uInt16 nGlueNum=pGPL->FindGluePoint(nId);
+
+ if (nGlueNum!=SDRGLUEPOINT_NOTFOUND)
+ {
+ Point aPt((*pGPL)[nGlueNum].GetAbsolutePos(*pObj));
+ aPt+=aPt1; // soviel soll verschoben werden
+ if (aPt.X()<aBound.Left() ) aPt1.X()-=aPt.X()-aBound.Left() ;
+ if (aPt.X()>aBound.Right() ) aPt1.X()-=aPt.X()-aBound.Right() ;
+ if (aPt.Y()<aBound.Top() ) aPt1.Y()-=aPt.Y()-aBound.Top() ;
+ if (aPt.Y()>aBound.Bottom()) aPt1.Y()-=aPt.Y()-aBound.Bottom();
+ }
+ }
+ }
+ }
+
+ aPt1+=DragStat().GetStart();
+ }
+
+ if (bOrtho)
+ OrthoDistance8(DragStat().GetStart(),aPt1,false);
+
+ if (aPt1!=DragStat().GetNow())
+ {
+ Hide();
+ DragStat().NextMove(aPt1);
+ Rectangle aAction(GetMarkedRect());
+ aAction.Move(DragStat().GetDX(),DragStat().GetDY());
+ DragStat().SetActionRect(aAction);
+ Show();
+ }
+ }
+}
+
+bool SdrDragMove::EndSdrDrag(bool bCopy)
+{
+ Hide();
+
+ if (getSdrDragView().IsInsObjPoint() || getSdrDragView().IsInsGluePoint())
+ bCopy=false;
+
+ if (IsDraggingPoints())
+ {
+ getSdrDragView().MoveMarkedPoints(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy);
+ }
+ else if (IsDraggingGluePoints())
+ {
+ getSdrDragView().MoveMarkedGluePoints(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy);
+ }
+ else
+ {
+ getSdrDragView().MoveMarkedObj(Size(DragStat().GetDX(),DragStat().GetDY()),bCopy);
+ }
+
+ return true;
+}
+
+Pointer SdrDragMove::GetSdrDragPointer() const
+{
+ if (IsDraggingPoints() || IsDraggingGluePoints())
+ {
+ return Pointer(POINTER_MOVEPOINT);
+ }
+ else
+ {
+ return Pointer(POINTER_MOVE);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragResize,SdrDragMethod);
+
+SdrDragResize::SdrDragResize(SdrDragView& rNewView)
+: SdrDragMethod(rNewView),
+ aXFact(1,1),
+ aYFact(1,1)
+{
+}
+
+void SdrDragResize::TakeSdrDragComment(XubString& rStr) const
+{
+ ImpTakeDescriptionStr(STR_DragMethResize, rStr);
+ bool bEqual(aXFact == aYFact);
+ Fraction aFact1(1,1);
+ Point aStart(DragStat().GetStart());
+ Point aRef(DragStat().GetRef1());
+ INT32 nXDiv(aStart.X() - aRef.X());
+
+ if(!nXDiv)
+ nXDiv = 1;
+
+ INT32 nYDiv(aStart.Y() - aRef.Y());
+
+ if(!nYDiv)
+ nYDiv = 1;
+
+ bool bX(aXFact != aFact1 && Abs(nXDiv) > 1);
+ bool bY(aYFact != aFact1 && Abs(nYDiv) > 1);
+
+ if(bX || bY)
+ {
+ XubString aStr;
+
+ rStr.AppendAscii(" (");
+
+ if(bX)
+ {
+ if(!bEqual)
+ rStr.AppendAscii("x=");
+
+ getSdrDragView().GetModel()->TakePercentStr(aXFact, aStr);
+ rStr += aStr;
+ }
+
+ if(bY && !bEqual)
+ {
+ if(bX)
+ rStr += sal_Unicode(' ');
+
+ rStr.AppendAscii("y=");
+ getSdrDragView().GetModel()->TakePercentStr(aYFact, aStr);
+ rStr += aStr;
+ }
+
+ rStr += sal_Unicode(')');
+ }
+
+ if(getSdrDragView().IsDragWithCopy())
+ rStr += ImpGetResStr(STR_EditWithCopy);
+}
+
+bool SdrDragResize::BeginSdrDrag()
+{
+ SdrHdlKind eRefHdl=HDL_MOVE;
+ SdrHdl* pRefHdl=NULL;
+
+ switch (GetDragHdlKind())
+ {
+ case HDL_UPLFT: eRefHdl=HDL_LWRGT; break;
+ case HDL_UPPER: eRefHdl=HDL_LOWER; DragStat().SetHorFixed(true); break;
+ case HDL_UPRGT: eRefHdl=HDL_LWLFT; break;
+ case HDL_LEFT : eRefHdl=HDL_RIGHT; DragStat().SetVerFixed(true); break;
+ case HDL_RIGHT: eRefHdl=HDL_LEFT ; DragStat().SetVerFixed(true); break;
+ case HDL_LWLFT: eRefHdl=HDL_UPRGT; break;
+ case HDL_LOWER: eRefHdl=HDL_UPPER; DragStat().SetHorFixed(true); break;
+ case HDL_LWRGT: eRefHdl=HDL_UPLFT; break;
+ default: break;
+ }
+
+ if (eRefHdl!=HDL_MOVE)
+ pRefHdl=GetHdlList().GetHdl(eRefHdl);
+
+ if (pRefHdl!=NULL && !getSdrDragView().IsResizeAtCenter())
+ {
+ DragStat().Ref1()=pRefHdl->GetPos();
+ }
+ else
+ {
+ SdrHdl* pRef1=GetHdlList().GetHdl(HDL_UPLFT);
+ SdrHdl* pRef2=GetHdlList().GetHdl(HDL_LWRGT);
+
+ if (pRef1!=NULL && pRef2!=NULL)
+ {
+ DragStat().Ref1()=Rectangle(pRef1->GetPos(),pRef2->GetPos()).Center();
+ }
+ else
+ {
+ DragStat().Ref1()=GetMarkedRect().Center();
+ }
+ }
+
+ Show();
+
+ return true;
+}
+
+basegfx::B2DHomMatrix SdrDragResize::getCurrentTransformation()
+{
+ basegfx::B2DHomMatrix aRetval(basegfx::tools::createTranslateB2DHomMatrix(
+ -DragStat().Ref1().X(), -DragStat().Ref1().Y()));
+ aRetval.scale(aXFact, aYFact);
+ aRetval.translate(DragStat().Ref1().X(), DragStat().Ref1().Y());
+
+ return aRetval;
+}
+
+void SdrDragResize::MoveSdrDrag(const Point& rNoSnapPnt)
+{
+ Point aPnt(GetSnapPos(rNoSnapPnt));
+ Point aStart(DragStat().GetStart());
+ Point aRef(DragStat().GetRef1());
+ Fraction aMaxFact(0x7FFFFFFF,1);
+ Rectangle aLR(getSdrDragView().GetWorkArea());
+ bool bWorkArea=!aLR.IsEmpty();
+ bool bDragLimit=IsDragLimit();
+
+ if (bDragLimit || bWorkArea)
+ {
+ Rectangle aSR(GetMarkedRect());
+
+ if (bDragLimit)
+ {
+ Rectangle aR2(GetDragLimitRect());
+
+ if (bWorkArea)
+ aLR.Intersection(aR2);
+ else
+ aLR=aR2;
+ }
+
+ if (aPnt.X()<aLR.Left())
+ aPnt.X()=aLR.Left();
+ else if (aPnt.X()>aLR.Right())
+ aPnt.X()=aLR.Right();
+
+ if (aPnt.Y()<aLR.Top())
+ aPnt.Y()=aLR.Top();
+ else if (aPnt.Y()>aLR.Bottom())
+ aPnt.Y()=aLR.Bottom();
+
+ if (aRef.X()>aSR.Left())
+ {
+ Fraction aMax(aRef.X()-aLR.Left(),aRef.X()-aSR.Left());
+
+ if (aMax<aMaxFact)
+ aMaxFact=aMax;
+ }
+
+ if (aRef.X()<aSR.Right())
+ {
+ Fraction aMax(aLR.Right()-aRef.X(),aSR.Right()-aRef.X());
+
+ if (aMax<aMaxFact)
+ aMaxFact=aMax;
+ }
+
+ if (aRef.Y()>aSR.Top())
+ {
+ Fraction aMax(aRef.Y()-aLR.Top(),aRef.Y()-aSR.Top());
+
+ if (aMax<aMaxFact)
+ aMaxFact=aMax;
+ }
+
+ if (aRef.Y()<aSR.Bottom())
+ {
+ Fraction aMax(aLR.Bottom()-aRef.Y(),aSR.Bottom()-aRef.Y());
+
+ if (aMax<aMaxFact)
+ aMaxFact=aMax;
+ }
+ }
+
+ long nXDiv=aStart.X()-aRef.X(); if (nXDiv==0) nXDiv=1;
+ long nYDiv=aStart.Y()-aRef.Y(); if (nYDiv==0) nYDiv=1;
+ long nXMul=aPnt.X()-aRef.X();
+ long nYMul=aPnt.Y()-aRef.Y();
+
+ if (nXDiv<0)
+ {
+ nXDiv=-nXDiv;
+ nXMul=-nXMul;
+ }
+
+ if (nYDiv<0)
+ {
+ nYDiv=-nYDiv;
+ nYMul=-nYMul;
+ }
+
+ bool bXNeg=nXMul<0; if (bXNeg) nXMul=-nXMul;
+ bool bYNeg=nYMul<0; if (bYNeg) nYMul=-nYMul;
+ bool bOrtho=getSdrDragView().IsOrtho() || !getSdrDragView().IsResizeAllowed(false);
+
+ if (!DragStat().IsHorFixed() && !DragStat().IsVerFixed())
+ {
+ if (Abs(nXDiv)<=1 || Abs(nYDiv)<=1)
+ bOrtho=false;
+
+ if (bOrtho)
+ {
+ if ((Fraction(nXMul,nXDiv)>Fraction(nYMul,nYDiv)) !=getSdrDragView().IsBigOrtho())
+ {
+ nXMul=nYMul;
+ nXDiv=nYDiv;
+ }
+ else
+ {
+ nYMul=nXMul;
+ nYDiv=nXDiv;
+ }
+ }
+ }
+ else
+ {
+ if (bOrtho)
+ {
+ if (DragStat().IsHorFixed())
+ {
+ bXNeg=false;
+ nXMul=nYMul;
+ nXDiv=nYDiv;
+ }
+
+ if (DragStat().IsVerFixed())
+ {
+ bYNeg=false;
+ nYMul=nXMul;
+ nYDiv=nXDiv;
+ }
+ }
+ else
+ {
+ if (DragStat().IsHorFixed())
+ {
+ bXNeg=false;
+ nXMul=1;
+ nXDiv=1;
+ }
+
+ if (DragStat().IsVerFixed())
+ {
+ bYNeg=false;
+ nYMul=1;
+ nYDiv=1;
+ }
+ }
+ }
+
+ Fraction aNeuXFact(nXMul,nXDiv);
+ Fraction aNeuYFact(nYMul,nYDiv);
+
+ if (bOrtho)
+ {
+ if (aNeuXFact>aMaxFact)
+ {
+ aNeuXFact=aMaxFact;
+ aNeuYFact=aMaxFact;
+ }
+
+ if (aNeuYFact>aMaxFact)
+ {
+ aNeuXFact=aMaxFact;
+ aNeuYFact=aMaxFact;
+ }
+ }
+
+ if (bXNeg)
+ aNeuXFact=Fraction(-aNeuXFact.GetNumerator(),aNeuXFact.GetDenominator());
+
+ if (bYNeg)
+ aNeuYFact=Fraction(-aNeuYFact.GetNumerator(),aNeuYFact.GetDenominator());
+
+ if (DragStat().CheckMinMoved(aPnt))
+ {
+ if ((!DragStat().IsHorFixed() && aPnt.X()!=DragStat().GetNow().X()) ||
+ (!DragStat().IsVerFixed() && aPnt.Y()!=DragStat().GetNow().Y()))
+ {
+ Hide();
+ DragStat().NextMove(aPnt);
+ aXFact=aNeuXFact;
+ aYFact=aNeuYFact;
+ Show();
+ }
+ }
+}
+
+void SdrDragResize::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
+{
+ rTarget.Resize(DragStat().Ref1(),aXFact,aYFact);
+}
+
+bool SdrDragResize::EndSdrDrag(bool bCopy)
+{
+ Hide();
+
+ if (IsDraggingPoints())
+ {
+ getSdrDragView().ResizeMarkedPoints(DragStat().Ref1(),aXFact,aYFact,bCopy);
+ }
+ else if (IsDraggingGluePoints())
+ {
+ getSdrDragView().ResizeMarkedGluePoints(DragStat().Ref1(),aXFact,aYFact,bCopy);
+ }
+ else
+ {
+ getSdrDragView().ResizeMarkedObj(DragStat().Ref1(),aXFact,aYFact,bCopy);
+ }
+
+ return true;
+}
+
+Pointer SdrDragResize::GetSdrDragPointer() const
+{
+ const SdrHdl* pHdl=GetDragHdl();
+
+ if (pHdl!=NULL)
+ {
+ return pHdl->GetPointer();
+ }
+
+ return Pointer(POINTER_MOVE);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragRotate,SdrDragMethod);
+
+void SdrDragRotate::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
+{
+ rTarget.Rotate(DragStat().GetRef1(), nWink, sin(nWink*nPi180), cos(nWink*nPi180));
+}
+
+SdrDragRotate::SdrDragRotate(SdrDragView& rNewView)
+: SdrDragMethod(rNewView),
+ nSin(0.0),
+ nCos(1.0),
+ nWink0(0),
+ nWink(0),
+ bRight(false)
+{
+}
+
+void SdrDragRotate::TakeSdrDragComment(XubString& rStr) const
+{
+ ImpTakeDescriptionStr(STR_DragMethRotate, rStr);
+ rStr.AppendAscii(" (");
+ XubString aStr;
+ INT32 nTmpWink(NormAngle360(nWink));
+
+ if(bRight && nWink)
+ {
+ nTmpWink -= 36000;
+ }
+
+ getSdrDragView().GetModel()->TakeWinkStr(nTmpWink, aStr);
+ rStr += aStr;
+ rStr += sal_Unicode(')');
+
+ if(getSdrDragView().IsDragWithCopy())
+ rStr += ImpGetResStr(STR_EditWithCopy);
+}
+
+bool SdrDragRotate::BeginSdrDrag()
+{
+ SdrHdl* pH=GetHdlList().GetHdl(HDL_REF1);
+
+ if (pH!=NULL)
+ {
+ Show();
+ DragStat().Ref1()=pH->GetPos();
+ nWink0=GetAngle(DragStat().GetStart()-DragStat().GetRef1());
+ return true;
+ }
+ else
+ {
+ DBG_ERROR("SdrDragRotate::BeginSdrDrag(): Kein Referenzpunkt-Handle gefunden");
+ return false;
+ }
+}
+
+basegfx::B2DHomMatrix SdrDragRotate::getCurrentTransformation()
+{
+ return basegfx::tools::createRotateAroundPoint(
+ DragStat().GetRef1().X(), DragStat().GetRef1().Y(),
+ -atan2(nSin, nCos));
+}
+
+void SdrDragRotate::MoveSdrDrag(const Point& rPnt_)
+{
+ Point aPnt(rPnt_);
+ if (DragStat().CheckMinMoved(aPnt))
+ {
+ long nNeuWink=NormAngle360(GetAngle(aPnt-DragStat().GetRef1())-nWink0);
+ long nSA=0;
+
+ if (getSdrDragView().IsAngleSnapEnabled())
+ nSA=getSdrDragView().GetSnapAngle();
+
+ if (!getSdrDragView().IsRotateAllowed(false))
+ nSA=9000;
+
+ if (nSA!=0)
+ { // Winkelfang
+ nNeuWink+=nSA/2;
+ nNeuWink/=nSA;
+ nNeuWink*=nSA;
+ }
+
+ nNeuWink=NormAngle180(nNeuWink);
+
+ if (nWink!=nNeuWink)
+ {
+ sal_uInt16 nSekt0=GetAngleSector(nWink);
+ sal_uInt16 nSekt1=GetAngleSector(nNeuWink);
+
+ if (nSekt0==0 && nSekt1==3)
+ bRight=true;
+
+ if (nSekt0==3 && nSekt1==0)
+ bRight=false;
+
+ nWink=nNeuWink;
+ double a=nWink*nPi180;
+ double nSin1=sin(a); // schonmal berechnen, damit mgl. wenig Zeit
+ double nCos1=cos(a); // zwischen Hide() und Show() vergeht
+ Hide();
+ nSin=nSin1;
+ nCos=nCos1;
+ DragStat().NextMove(aPnt);
+ Show();
+ }
+ }
+}
+
+bool SdrDragRotate::EndSdrDrag(bool bCopy)
+{
+ Hide();
+
+ if (nWink!=0)
+ {
+ if (IsDraggingPoints())
+ {
+ getSdrDragView().RotateMarkedPoints(DragStat().GetRef1(),nWink,bCopy);
+ }
+ else if (IsDraggingGluePoints())
+ {
+ getSdrDragView().RotateMarkedGluePoints(DragStat().GetRef1(),nWink,bCopy);
+ }
+ else
+ {
+ getSdrDragView().RotateMarkedObj(DragStat().GetRef1(),nWink,bCopy);
+ }
+ }
+ return true;
+}
+
+Pointer SdrDragRotate::GetSdrDragPointer() const
+{
+ return Pointer(POINTER_ROTATE);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragShear,SdrDragMethod);
+
+SdrDragShear::SdrDragShear(SdrDragView& rNewView, bool bSlant1)
+: SdrDragMethod(rNewView),
+ aFact(1,1),
+ nWink0(0),
+ nWink(0),
+ nTan(0.0),
+ bVertical(false),
+ bResize(false),
+ bUpSideDown(false),
+ bSlant(bSlant1)
+{
+}
+
+void SdrDragShear::TakeSdrDragComment(XubString& rStr) const
+{
+ ImpTakeDescriptionStr(STR_DragMethShear, rStr);
+ rStr.AppendAscii(" (");
+
+ INT32 nTmpWink(nWink);
+
+ if(bUpSideDown)
+ nTmpWink += 18000;
+
+ nTmpWink = NormAngle180(nTmpWink);
+
+ XubString aStr;
+
+ getSdrDragView().GetModel()->TakeWinkStr(nTmpWink, aStr);
+ rStr += aStr;
+ rStr += sal_Unicode(')');
+
+ if(getSdrDragView().IsDragWithCopy())
+ rStr += ImpGetResStr(STR_EditWithCopy);
+}
+
+bool SdrDragShear::BeginSdrDrag()
+{
+ SdrHdlKind eRefHdl=HDL_MOVE;
+ SdrHdl* pRefHdl=NULL;
+
+ switch (GetDragHdlKind())
+ {
+ case HDL_UPPER: eRefHdl=HDL_LOWER; break;
+ case HDL_LOWER: eRefHdl=HDL_UPPER; break;
+ case HDL_LEFT : eRefHdl=HDL_RIGHT; bVertical=true; break;
+ case HDL_RIGHT: eRefHdl=HDL_LEFT ; bVertical=true; break;
+ default: break;
+ }
+
+ if (eRefHdl!=HDL_MOVE)
+ pRefHdl=GetHdlList().GetHdl(eRefHdl);
+
+ if (pRefHdl!=NULL)
+ {
+ DragStat().Ref1()=pRefHdl->GetPos();
+ nWink0=GetAngle(DragStat().GetStart()-DragStat().GetRef1());
+ }
+ else
+ {
+ DBG_ERROR("SdrDragShear::BeginSdrDrag(): Kein Referenzpunkt-Handle fuer Shear gefunden");
+ return false;
+ }
+
+ Show();
+ return true;
+}
+
+basegfx::B2DHomMatrix SdrDragShear::getCurrentTransformation()
+{
+ basegfx::B2DHomMatrix aRetval(basegfx::tools::createTranslateB2DHomMatrix(
+ -DragStat().GetRef1().X(), -DragStat().GetRef1().Y()));
+
+ if (bResize)
+ {
+ if (bVertical)
+ {
+ aRetval.scale(aFact, 1.0);
+ aRetval.shearY(-nTan);
+ }
+ else
+ {
+ aRetval.scale(1.0, aFact);
+ aRetval.shearX(-nTan);
+ }
+ }
+
+ aRetval.translate(DragStat().GetRef1().X(), DragStat().GetRef1().Y());
+
+ return aRetval;
+}
+
+void SdrDragShear::MoveSdrDrag(const Point& rPnt)
+{
+ if (DragStat().CheckMinMoved(rPnt))
+ {
+ bResize=!getSdrDragView().IsOrtho();
+ long nSA=0;
+
+ if (getSdrDragView().IsAngleSnapEnabled())
+ nSA=getSdrDragView().GetSnapAngle();
+
+ Point aP0(DragStat().GetStart());
+ Point aPnt(rPnt);
+ Fraction aNeuFact(1,1);
+
+ // Wenn kein Winkelfang, dann ggf. Rasterfang (ausser bei Slant)
+ if (nSA==0 && !bSlant)
+ aPnt=GetSnapPos(aPnt);
+
+ if (!bSlant && !bResize)
+ { // Shear ohne Resize
+ if (bVertical)
+ aPnt.X()=aP0.X();
+ else
+ aPnt.Y()=aP0.Y();
+ }
+
+ Point aRef(DragStat().GetRef1());
+ Point aDif(aPnt-aRef);
+
+ long nNeuWink=0;
+
+ if (bSlant)
+ {
+ nNeuWink=NormAngle180(-(GetAngle(aDif)-nWink0));
+
+ if (bVertical)
+ nNeuWink=NormAngle180(-nNeuWink);
+ }
+ else
+ {
+ if (bVertical)
+ nNeuWink=NormAngle180(GetAngle(aDif));
+ else
+ nNeuWink=NormAngle180(-(GetAngle(aDif)-9000));
+
+ if (nNeuWink<-9000 || nNeuWink>9000)
+ nNeuWink=NormAngle180(nNeuWink+18000);
+
+ if (bResize)
+ {
+ Point aPt2(aPnt);
+
+ if (nSA!=0)
+ aPt2=GetSnapPos(aPnt); // den also in jedem Falle fangen
+
+ if (bVertical)
+ {
+ aNeuFact=Fraction(aPt2.X()-aRef.X(),aP0.X()-aRef.X());
+ }
+ else
+ {
+ aNeuFact=Fraction(aPt2.Y()-aRef.Y(),aP0.Y()-aRef.Y());
+ }
+ }
+ }
+
+ bool bNeg=nNeuWink<0;
+
+ if (bNeg)
+ nNeuWink=-nNeuWink;
+
+ if (nSA!=0)
+ { // Winkelfang
+ nNeuWink+=nSA/2;
+ nNeuWink/=nSA;
+ nNeuWink*=nSA;
+ }
+
+ nNeuWink=NormAngle360(nNeuWink);
+ bUpSideDown=nNeuWink>9000 && nNeuWink<27000;
+
+ if (bSlant)
+ { // Resize fuer Slant berechnen
+ // Mit Winkelfang jedoch ohne 89deg Begrenzung
+ long nTmpWink=nNeuWink;
+ if (bUpSideDown) nNeuWink-=18000;
+ if (bNeg) nTmpWink=-nTmpWink;
+ bResize=true;
+ double nCos=cos(nTmpWink*nPi180);
+ aNeuFact=nCos;
+ Kuerzen(aFact,10); // 3 Dezimalstellen sollten reichen
+ }
+
+ if (nNeuWink>8900)
+ nNeuWink=8900;
+
+ if (bNeg)
+ nNeuWink=-nNeuWink;
+
+ if (nWink!=nNeuWink || aFact!=aNeuFact)
+ {
+ nWink=nNeuWink;
+ aFact=aNeuFact;
+ double a=nWink*nPi180;
+ double nTan1=0.0;
+ nTan1=tan(a); // schonmal berechnen, damit mgl. wenig Zeit zwischen Hide() und Show() vergeht
+ Hide();
+ nTan=nTan1;
+ DragStat().NextMove(rPnt);
+ Show();
+ }
+ }
+}
+
+void SdrDragShear::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
+{
+ if (bResize)
+ {
+ if (bVertical)
+ {
+ rTarget.Resize(DragStat().GetRef1(),aFact,Fraction(1,1));
+ }
+ else
+ {
+ rTarget.Resize(DragStat().GetRef1(),Fraction(1,1),aFact);
+ }
+ }
+
+ if (nWink!=0)
+ {
+ rTarget.Shear(DragStat().GetRef1(),nWink,tan(nWink*nPi180),bVertical);
+ }
+}
+
+bool SdrDragShear::EndSdrDrag(bool bCopy)
+{
+ Hide();
+
+ if (bResize && aFact==Fraction(1,1))
+ bResize=false;
+
+ if (nWink!=0 || bResize)
+ {
+ if (nWink!=0 && bResize)
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditShear,aStr);
+
+ if (bCopy)
+ aStr+=ImpGetResStr(STR_EditWithCopy);
+
+ getSdrDragView().BegUndo(aStr);
+ }
+
+ if (bResize)
+ {
+ if (bVertical)
+ {
+ getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),aFact,Fraction(1,1),bCopy);
+ }
+ else
+ {
+ getSdrDragView().ResizeMarkedObj(DragStat().GetRef1(),Fraction(1,1),aFact,bCopy);
+ }
+
+ bCopy=false;
+ }
+
+ if (nWink!=0)
+ {
+ getSdrDragView().ShearMarkedObj(DragStat().GetRef1(),nWink,bVertical,bCopy);
+ }
+
+ if (nWink!=0 && bResize)
+ getSdrDragView().EndUndo();
+
+ return true;
+ }
+
+ return false;
+}
+
+Pointer SdrDragShear::GetSdrDragPointer() const
+{
+ if (bVertical)
+ return Pointer(POINTER_VSHEAR);
+ else
+ return Pointer(POINTER_HSHEAR);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragMirror,SdrDragMethod);
+
+void SdrDragMirror::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
+{
+ if(bMirrored)
+ {
+ rTarget.Mirror(DragStat().GetRef1(), DragStat().GetRef2());
+ }
+}
+
+SdrDragMirror::SdrDragMirror(SdrDragView& rNewView)
+: SdrDragMethod(rNewView),
+ nWink(0),
+ bMirrored(false),
+ bSide0(false)
+{
+}
+
+bool SdrDragMirror::ImpCheckSide(const Point& rPnt) const
+{
+ long nWink1=GetAngle(rPnt-DragStat().GetRef1());
+ nWink1-=nWink;
+ nWink1=NormAngle360(nWink1);
+
+ return nWink1<18000;
+}
+
+void SdrDragMirror::TakeSdrDragComment(XubString& rStr) const
+{
+ if (aDif.X()==0)
+ ImpTakeDescriptionStr(STR_DragMethMirrorHori,rStr);
+ else if (aDif.Y()==0)
+ ImpTakeDescriptionStr(STR_DragMethMirrorVert,rStr);
+ else if (Abs(aDif.X())==Abs(aDif.Y()))
+ ImpTakeDescriptionStr(STR_DragMethMirrorDiag,rStr);
+ else
+ ImpTakeDescriptionStr(STR_DragMethMirrorFree,rStr);
+
+ if (getSdrDragView().IsDragWithCopy())
+ rStr+=ImpGetResStr(STR_EditWithCopy);
+}
+
+bool SdrDragMirror::BeginSdrDrag()
+{
+ SdrHdl* pH1=GetHdlList().GetHdl(HDL_REF1);
+ SdrHdl* pH2=GetHdlList().GetHdl(HDL_REF2);
+
+ if (pH1!=NULL && pH2!=NULL)
+ {
+ DragStat().Ref1()=pH1->GetPos();
+ DragStat().Ref2()=pH2->GetPos();
+ Ref1()=pH1->GetPos();
+ Ref2()=pH2->GetPos();
+ aDif=pH2->GetPos()-pH1->GetPos();
+ bool b90=(aDif.X()==0) || aDif.Y()==0;
+ bool b45=b90 || (Abs(aDif.X())==Abs(aDif.Y()));
+ nWink=NormAngle360(GetAngle(aDif));
+
+ if (!getSdrDragView().IsMirrorAllowed(false,false) && !b45)
+ return false; // freier Achsenwinkel nicht erlaubt
+
+ if (!getSdrDragView().IsMirrorAllowed(true,false) && !b90)
+ return false; // 45deg auch nicht erlaubt
+
+ bSide0=ImpCheckSide(DragStat().GetStart());
+ Show();
+ return true;
+ }
+ else
+ {
+ DBG_ERROR("SdrDragMirror::BeginSdrDrag(): Spiegelachse nicht gefunden");
+ return false;
+ }
+}
+
+basegfx::B2DHomMatrix SdrDragMirror::getCurrentTransformation()
+{
+ basegfx::B2DHomMatrix aRetval;
+
+ if (bMirrored)
+ {
+ const double fDeltaX(DragStat().GetRef2().X() - DragStat().GetRef1().X());
+ const double fDeltaY(DragStat().GetRef2().Y() - DragStat().GetRef1().Y());
+ const double fRotation(atan2(fDeltaY, fDeltaX));
+
+ aRetval = basegfx::tools::createTranslateB2DHomMatrix(-DragStat().GetRef1().X(), -DragStat().GetRef1().Y());
+ aRetval.rotate(-fRotation);
+ aRetval.scale(1.0, -1.0);
+ aRetval.rotate(fRotation);
+ aRetval.translate(DragStat().GetRef1().X(), DragStat().GetRef1().Y());
+ }
+
+ return aRetval;
+}
+
+void SdrDragMirror::MoveSdrDrag(const Point& rPnt)
+{
+ if (DragStat().CheckMinMoved(rPnt))
+ {
+ bool bNeuSide=ImpCheckSide(rPnt);
+ bool bNeuMirr=bSide0!=bNeuSide;
+
+ if (bMirrored!=bNeuMirr)
+ {
+ Hide();
+ bMirrored=bNeuMirr;
+ DragStat().NextMove(rPnt);
+ Show();
+ }
+ }
+}
+
+bool SdrDragMirror::EndSdrDrag(bool bCopy)
+{
+ Hide();
+
+ if (bMirrored)
+ {
+ getSdrDragView().MirrorMarkedObj(DragStat().GetRef1(),DragStat().GetRef2(),bCopy);
+ }
+
+ return true;
+}
+
+Pointer SdrDragMirror::GetSdrDragPointer() const
+{
+ return Pointer(POINTER_MIRROR);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragGradient, SdrDragMethod);
+
+SdrDragGradient::SdrDragGradient(SdrDragView& rNewView, bool bGrad)
+: SdrDragMethod(rNewView),
+ pIAOHandle(NULL),
+ bIsGradient(bGrad)
+{
+}
+
+void SdrDragGradient::TakeSdrDragComment(XubString& rStr) const
+{
+ if(IsGradient())
+ ImpTakeDescriptionStr(STR_DragMethGradient, rStr);
+ else
+ ImpTakeDescriptionStr(STR_DragMethTransparence, rStr);
+}
+
+bool SdrDragGradient::BeginSdrDrag()
+{
+ bool bRetval(false);
+
+ pIAOHandle = (SdrHdlGradient*)GetHdlList().GetHdl(IsGradient() ? HDL_GRAD : HDL_TRNS);
+
+ if(pIAOHandle)
+ {
+ // save old values
+ DragStat().Ref1() = pIAOHandle->GetPos();
+ DragStat().Ref2() = pIAOHandle->Get2ndPos();
+
+ // what was hit?
+ bool bHit(false);
+ SdrHdlColor* pColHdl = pIAOHandle->GetColorHdl1();
+
+ // init handling flags
+ pIAOHandle->SetMoveSingleHandle(false);
+ pIAOHandle->SetMoveFirstHandle(false);
+
+ // test first color handle
+ if(pColHdl)
+ {
+ basegfx::B2DPoint aPosition(DragStat().GetStart().X(), DragStat().GetStart().Y());
+
+ if(pColHdl->getOverlayObjectList().isHitLogic(aPosition))
+ {
+ bHit = true;
+ pIAOHandle->SetMoveSingleHandle(true);
+ pIAOHandle->SetMoveFirstHandle(true);
+ }
+ }
+
+ // test second color handle
+ pColHdl = pIAOHandle->GetColorHdl2();
+
+ if(!bHit && pColHdl)
+ {
+ basegfx::B2DPoint aPosition(DragStat().GetStart().X(), DragStat().GetStart().Y());
+
+ if(pColHdl->getOverlayObjectList().isHitLogic(aPosition))
+ {
+ bHit = true;
+ pIAOHandle->SetMoveSingleHandle(true);
+ }
+ }
+
+ // test gradient handle itself
+ if(!bHit)
+ {
+ basegfx::B2DPoint aPosition(DragStat().GetStart().X(), DragStat().GetStart().Y());
+
+ if(pIAOHandle->getOverlayObjectList().isHitLogic(aPosition))
+ {
+ bHit = true;
+ }
+ }
+
+ // everything up and running :o}
+ bRetval = bHit;
+ }
+ else
+ {
+ DBG_ERROR("SdrDragGradient::BeginSdrDrag(): IAOGradient nicht gefunden");
+ }
+
+ return bRetval;
+}
+
+void SdrDragGradient::MoveSdrDrag(const Point& rPnt)
+{
+ if(pIAOHandle && DragStat().CheckMinMoved(rPnt))
+ {
+ DragStat().NextMove(rPnt);
+
+ // Do the Move here!!! DragStat().GetStart()
+ Point aMoveDiff = rPnt - DragStat().GetStart();
+
+ if(pIAOHandle->IsMoveSingleHandle())
+ {
+ if(pIAOHandle->IsMoveFirstHandle())
+ {
+ pIAOHandle->SetPos(DragStat().Ref1() + aMoveDiff);
+ if(pIAOHandle->GetColorHdl1())
+ pIAOHandle->GetColorHdl1()->SetPos(DragStat().Ref1() + aMoveDiff);
+ }
+ else
+ {
+ pIAOHandle->Set2ndPos(DragStat().Ref2() + aMoveDiff);
+ if(pIAOHandle->GetColorHdl2())
+ pIAOHandle->GetColorHdl2()->SetPos(DragStat().Ref2() + aMoveDiff);
+ }
+ }
+ else
+ {
+ pIAOHandle->SetPos(DragStat().Ref1() + aMoveDiff);
+ pIAOHandle->Set2ndPos(DragStat().Ref2() + aMoveDiff);
+
+ if(pIAOHandle->GetColorHdl1())
+ pIAOHandle->GetColorHdl1()->SetPos(DragStat().Ref1() + aMoveDiff);
+
+ if(pIAOHandle->GetColorHdl2())
+ pIAOHandle->GetColorHdl2()->SetPos(DragStat().Ref2() + aMoveDiff);
+ }
+
+ // new state
+ pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), false, false);
+ }
+}
+
+bool SdrDragGradient::EndSdrDrag(bool /*bCopy*/)
+{
+ // here the result is clear, do something with the values
+ Ref1() = pIAOHandle->GetPos();
+ Ref2() = pIAOHandle->Get2ndPos();
+
+ // new state
+ pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), true, true);
+
+ return true;
+}
+
+void SdrDragGradient::CancelSdrDrag()
+{
+ // restore old values
+ pIAOHandle->SetPos(DragStat().Ref1());
+ pIAOHandle->Set2ndPos(DragStat().Ref2());
+
+ if(pIAOHandle->GetColorHdl1())
+ pIAOHandle->GetColorHdl1()->SetPos(DragStat().Ref1());
+
+ if(pIAOHandle->GetColorHdl2())
+ pIAOHandle->GetColorHdl2()->SetPos(DragStat().Ref2());
+
+ // new state
+ pIAOHandle->FromIAOToItem(getSdrDragView().GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj(), true, false);
+}
+
+Pointer SdrDragGradient::GetSdrDragPointer() const
+{
+ return Pointer(POINTER_REFHAND);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragCrook,SdrDragMethod);
+
+SdrDragCrook::SdrDragCrook(SdrDragView& rNewView)
+: SdrDragMethod(rNewView),
+ aFact(1,1),
+ bContortionAllowed(false),
+ bNoContortionAllowed(false),
+ bContortion(false),
+ bResizeAllowed(false),
+ bResize(false),
+ bRotateAllowed(false),
+ bRotate(false),
+ bVertical(false),
+ bValid(false),
+ bLft(false),
+ bRgt(false),
+ bUpr(false),
+ bLwr(false),
+ bAtCenter(false),
+ nWink(0),
+ nMarkSize(0),
+ eMode(SDRCROOK_ROTATE)
+{
+}
+
+void SdrDragCrook::TakeSdrDragComment(XubString& rStr) const
+{
+ ImpTakeDescriptionStr(!bContortion ? STR_DragMethCrook : STR_DragMethCrookContortion, rStr);
+
+ if(bValid)
+ {
+ rStr.AppendAscii(" (");
+
+ XubString aStr;
+ INT32 nVal(nWink);
+
+ if(bAtCenter)
+ nVal *= 2;
+
+ nVal = Abs(nVal);
+ getSdrDragView().GetModel()->TakeWinkStr(nVal, aStr);
+ rStr += aStr;
+ rStr += sal_Unicode(')');
+ }
+
+ if(getSdrDragView().IsDragWithCopy())
+ rStr += ImpGetResStr(STR_EditWithCopy);
+}
+
+// #96920# These defines parametrise the created raster
+// for interactions
+#define DRAG_CROOK_RASTER_MINIMUM (4)
+#define DRAG_CROOK_RASTER_MAXIMUM (15)
+#define DRAG_CROOK_RASTER_DISTANCE (30)
+
+basegfx::B2DPolyPolygon impCreateDragRaster(SdrPageView& rPageView, const Rectangle& rMarkRect)
+{
+ basegfx::B2DPolyPolygon aRetval;
+
+ if(rPageView.PageWindowCount())
+ {
+ OutputDevice& rOut = (rPageView.GetPageWindow(0)->GetPaintWindow().GetOutputDevice());
+ Rectangle aPixelSize = rOut.LogicToPixel(rMarkRect);
+ sal_uInt32 nHorDiv(aPixelSize.GetWidth() / DRAG_CROOK_RASTER_DISTANCE);
+ sal_uInt32 nVerDiv(aPixelSize.GetHeight() / DRAG_CROOK_RASTER_DISTANCE);
+
+ if(nHorDiv > DRAG_CROOK_RASTER_MAXIMUM)
+ nHorDiv = DRAG_CROOK_RASTER_MAXIMUM;
+ if(nHorDiv < DRAG_CROOK_RASTER_MINIMUM)
+ nHorDiv = DRAG_CROOK_RASTER_MINIMUM;
+
+ if(nVerDiv > DRAG_CROOK_RASTER_MAXIMUM)
+ nVerDiv = DRAG_CROOK_RASTER_MAXIMUM;
+ if(nVerDiv < DRAG_CROOK_RASTER_MINIMUM)
+ nVerDiv = DRAG_CROOK_RASTER_MINIMUM;
+
+ const double fXLen(rMarkRect.GetWidth() / (double)nHorDiv);
+ const double fYLen(rMarkRect.GetHeight() / (double)nVerDiv);
+ double fYPos(rMarkRect.Top());
+ sal_uInt32 a, b;
+
+ for(a = 0; a <= nVerDiv; a++)
+ {
+ // hor lines
+ for(b = 0; b < nHorDiv; b++)
+ {
+ basegfx::B2DPolygon aHorLineSegment;
+
+ const double fNewX(rMarkRect.Left() + (b * fXLen));
+ aHorLineSegment.append(basegfx::B2DPoint(fNewX, fYPos));
+ aHorLineSegment.appendBezierSegment(
+ basegfx::B2DPoint(fNewX + (fXLen * (1.0 / 3.0)), fYPos),
+ basegfx::B2DPoint(fNewX + (fXLen * (2.0 / 3.0)), fYPos),
+ basegfx::B2DPoint(fNewX + fXLen, fYPos));
+ aRetval.append(aHorLineSegment);
+ }
+
+ // increments
+ fYPos += fYLen;
+ }
+
+ double fXPos(rMarkRect.Left());
+
+ for(a = 0; a <= nHorDiv; a++)
+ {
+ // ver lines
+ for(b = 0; b < nVerDiv; b++)
+ {
+ basegfx::B2DPolygon aVerLineSegment;
+
+ const double fNewY(rMarkRect.Top() + (b * fYLen));
+ aVerLineSegment.append(basegfx::B2DPoint(fXPos, fNewY));
+ aVerLineSegment.appendBezierSegment(
+ basegfx::B2DPoint(fXPos, fNewY + (fYLen * (1.0 / 3.0))),
+ basegfx::B2DPoint(fXPos, fNewY + (fYLen * (2.0 / 3.0))),
+ basegfx::B2DPoint(fXPos, fNewY + fYLen));
+ aRetval.append(aVerLineSegment);
+ }
+
+ // increments
+ fXPos += fXLen;
+ }
+ }
+
+ return aRetval;
+}
+
+void SdrDragCrook::createSdrDragEntries()
+{
+ // Add extended frame raster first, so it will be behind objects
+ if(getSdrDragView().GetSdrPageView())
+ {
+ const basegfx::B2DPolyPolygon aDragRaster(impCreateDragRaster(*getSdrDragView().GetSdrPageView(), GetMarkedRect()));
+
+ if(aDragRaster.count())
+ {
+ addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragRaster));
+ }
+ }
+
+ // call parent
+ SdrDragMethod::createSdrDragEntries();
+}
+
+bool SdrDragCrook::BeginSdrDrag()
+{
+ bContortionAllowed=getSdrDragView().IsCrookAllowed(false);
+ bNoContortionAllowed=getSdrDragView().IsCrookAllowed(true);
+ bResizeAllowed=getSdrDragView().IsResizeAllowed(false);
+ bRotateAllowed=getSdrDragView().IsRotateAllowed(false);
+
+ if (bContortionAllowed || bNoContortionAllowed)
+ {
+ bVertical=(GetDragHdlKind()==HDL_LOWER || GetDragHdlKind()==HDL_UPPER);
+ aMarkRect=GetMarkedRect();
+ aMarkCenter=aMarkRect.Center();
+ nMarkSize=bVertical ? (aMarkRect.GetHeight()-1) : (aMarkRect.GetWidth()-1);
+ aCenter=aMarkCenter;
+ aStart=DragStat().GetStart();
+ Show();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+void SdrDragCrook::_MovAllPoints(basegfx::B2DPolyPolygon& rTarget)
+{
+ SdrPageView* pPV = getSdrDragView().GetSdrPageView();
+
+ if(pPV)
+ {
+ XPolyPolygon aTempPolyPoly(rTarget);
+
+ if (pPV->HasMarkedObjPageView())
+ {
+ sal_uInt16 nPolyAnz=aTempPolyPoly.Count();
+
+ if (!bContortion && !getSdrDragView().IsNoDragXorPolys())
+ {
+ sal_uInt16 n1st=0,nLast=0;
+ Point aC(aCenter);
+
+ while (n1st<nPolyAnz)
+ {
+ nLast=n1st;
+ while (nLast<nPolyAnz && aTempPolyPoly[nLast].GetPointCount()!=0) nLast++;
+ Rectangle aBound(aTempPolyPoly[n1st].GetBoundRect());
+ sal_uInt16 i;
+
+ for (i=n1st+1; i<nLast; i++)
+ {
+ aBound.Union(aTempPolyPoly[n1st].GetBoundRect());
+ }
+
+ Point aCtr0(aBound.Center());
+ Point aCtr1(aCtr0);
+
+ if (bResize)
+ {
+ Fraction aFact1(1,1);
+
+ if (bVertical)
+ {
+ ResizePoint(aCtr1,aC,aFact1,aFact);
+ }
+ else
+ {
+ ResizePoint(aCtr1,aC,aFact,aFact1);
+ }
+ }
+
+ bool bRotOk=false;
+ double nSin=0,nCos=0;
+
+ if (aRad.X()!=0 && aRad.Y()!=0)
+ {
+ bRotOk=bRotate;
+
+ switch (eMode)
+ {
+ case SDRCROOK_ROTATE : CrookRotateXPoint (aCtr1,NULL,NULL,aC,aRad,nSin,nCos,bVertical); break;
+ case SDRCROOK_SLANT : CrookSlantXPoint (aCtr1,NULL,NULL,aC,aRad,nSin,nCos,bVertical); break;
+ case SDRCROOK_STRETCH: CrookStretchXPoint(aCtr1,NULL,NULL,aC,aRad,nSin,nCos,bVertical,aMarkRect); break;
+ } // switch
+ }
+
+ aCtr1-=aCtr0;
+
+ for (i=n1st; i<nLast; i++)
+ {
+ if (bRotOk)
+ {
+ RotateXPoly(aTempPolyPoly[i],aCtr0,nSin,nCos);
+ }
+
+ aTempPolyPoly[i].Move(aCtr1.X(),aCtr1.Y());
+ }
+
+ n1st=nLast+1;
+ }
+ }
+ else
+ {
+ sal_uInt16 i,j;
+
+ for (j=0; j<nPolyAnz; j++)
+ {
+ XPolygon& aPol=aTempPolyPoly[j];
+ sal_uInt16 nPtAnz=aPol.GetPointCount();
+ i=0;
+
+ while (i<nPtAnz)
+ {
+ Point* pPnt=&aPol[i];
+ Point* pC1=NULL;
+ Point* pC2=NULL;
+
+ if (i+1<nPtAnz && aPol.IsControl(i))
+ { // Kontrollpunkt links
+ pC1=pPnt;
+ i++;
+ pPnt=&aPol[i];
+ }
+
+ i++;
+
+ if (i<nPtAnz && aPol.IsControl(i))
+ { // Kontrollpunkt rechts
+ pC2=&aPol[i];
+ i++;
+ }
+
+ _MovCrookPoint(*pPnt,pC1,pC2);
+ }
+ }
+ }
+ }
+
+ rTarget = aTempPolyPoly.getB2DPolyPolygon();
+ }
+}
+
+void SdrDragCrook::_MovCrookPoint(Point& rPnt, Point* pC1, Point* pC2)
+{
+ bool bVert=bVertical;
+ bool bC1=pC1!=NULL;
+ bool bC2=pC2!=NULL;
+ Point aC(aCenter);
+
+ if (bResize)
+ {
+ Fraction aFact1(1,1);
+
+ if (bVert)
+ {
+ ResizePoint(rPnt,aC,aFact1,aFact);
+
+ if (bC1)
+ ResizePoint(*pC1,aC,aFact1,aFact);
+
+ if (bC2)
+ ResizePoint(*pC2,aC,aFact1,aFact);
+ }
+ else
+ {
+ ResizePoint(rPnt,aC,aFact,aFact1);
+
+ if (bC1)
+ ResizePoint(*pC1,aC,aFact,aFact1);
+
+ if (bC2)
+ ResizePoint(*pC2,aC,aFact,aFact1);
+ }
+ }
+
+ if (aRad.X()!=0 && aRad.Y()!=0)
+ {
+ double nSin,nCos;
+
+ switch (eMode)
+ {
+ case SDRCROOK_ROTATE : CrookRotateXPoint (rPnt,pC1,pC2,aC,aRad,nSin,nCos,bVert); break;
+ case SDRCROOK_SLANT : CrookSlantXPoint (rPnt,pC1,pC2,aC,aRad,nSin,nCos,bVert); break;
+ case SDRCROOK_STRETCH: CrookStretchXPoint(rPnt,pC1,pC2,aC,aRad,nSin,nCos,bVert,aMarkRect); break;
+ } // switch
+ }
+}
+
+void SdrDragCrook::MoveSdrDrag(const Point& rPnt)
+{
+ if (DragStat().CheckMinMoved(rPnt))
+ {
+ Point aPnt(rPnt);
+ bool bNeuMoveOnly=getSdrDragView().IsMoveOnlyDragging();
+ bAtCenter=false;
+ SdrCrookMode eNeuMode=getSdrDragView().GetCrookMode();
+ bool bNeuContortion=!bNeuMoveOnly && ((bContortionAllowed && !getSdrDragView().IsCrookNoContortion()) || !bNoContortionAllowed);
+ bResize=!getSdrDragView().IsOrtho() && bResizeAllowed && !bNeuMoveOnly;
+ bool bNeuRotate=bRotateAllowed && !bNeuContortion && !bNeuMoveOnly && eNeuMode==SDRCROOK_ROTATE;
+ long nSA=0;
+
+ if (nSA==0)
+ aPnt=GetSnapPos(aPnt);
+
+ Point aNeuCenter(aMarkCenter.X(),aStart.Y());
+
+ if (bVertical)
+ {
+ aNeuCenter.X()=aStart.X();
+ aNeuCenter.Y()=aMarkCenter.Y();
+ }
+
+ if (!getSdrDragView().IsCrookAtCenter())
+ {
+ switch (GetDragHdlKind())
+ {
+ case HDL_UPLFT: aNeuCenter.X()=aMarkRect.Right(); bLft=true; break;
+ case HDL_UPPER: aNeuCenter.Y()=aMarkRect.Bottom(); bUpr=true; break;
+ case HDL_UPRGT: aNeuCenter.X()=aMarkRect.Left(); bRgt=true; break;
+ case HDL_LEFT : aNeuCenter.X()=aMarkRect.Right(); bLft=true; break;
+ case HDL_RIGHT: aNeuCenter.X()=aMarkRect.Left(); bRgt=true; break;
+ case HDL_LWLFT: aNeuCenter.X()=aMarkRect.Right(); bLft=true; break;
+ case HDL_LOWER: aNeuCenter.Y()=aMarkRect.Top(); bLwr=true; break;
+ case HDL_LWRGT: aNeuCenter.X()=aMarkRect.Left(); bRgt=true; break;
+ default: bAtCenter=true;
+ }
+ }
+ else
+ bAtCenter=true;
+
+ Fraction aNeuFact(1,1);
+ long dx1=aPnt.X()-aNeuCenter.X();
+ long dy1=aPnt.Y()-aNeuCenter.Y();
+ bValid=bVertical ? dx1!=0 : dy1!=0;
+
+ if (bValid)
+ {
+ if (bVertical)
+ bValid=Abs(dx1)*100>Abs(dy1);
+ else
+ bValid=Abs(dy1)*100>Abs(dx1);
+ }
+
+ long nNeuRad=0;
+ nWink=0;
+
+ if (bValid)
+ {
+ double a=0; // Steigung des Radius
+ long nPntWink=0;
+
+ if (bVertical)
+ {
+ a=((double)dy1)/((double)dx1); // Steigung des Radius
+ nNeuRad=((long)(dy1*a)+dx1) /2;
+ aNeuCenter.X()+=nNeuRad;
+ nPntWink=GetAngle(aPnt-aNeuCenter);
+ }
+ else
+ {
+ a=((double)dx1)/((double)dy1); // Steigung des Radius
+ nNeuRad=((long)(dx1*a)+dy1) /2;
+ aNeuCenter.Y()+=nNeuRad;
+ nPntWink=GetAngle(aPnt-aNeuCenter)-9000;
+ }
+
+ if (!bAtCenter)
+ {
+ if (nNeuRad<0)
+ {
+ if (bRgt) nPntWink+=18000;
+ if (bLft) nPntWink=18000-nPntWink;
+ if (bLwr) nPntWink=-nPntWink;
+ }
+ else
+ {
+ if (bRgt) nPntWink=-nPntWink;
+ if (bUpr) nPntWink=18000-nPntWink;
+ if (bLwr) nPntWink+=18000;
+ }
+
+ nPntWink=NormAngle360(nPntWink);
+ }
+ else
+ {
+ if (nNeuRad<0) nPntWink+=18000;
+ if (bVertical) nPntWink=18000-nPntWink;
+ nPntWink=NormAngle180(nPntWink);
+ nPntWink=Abs(nPntWink);
+ }
+
+ double nUmfang=2*Abs(nNeuRad)*nPi;
+
+ if (bResize)
+ {
+ if (nSA!=0)
+ { // Winkelfang
+ long nWink0=nPntWink;
+ nPntWink+=nSA/2;
+ nPntWink/=nSA;
+ nPntWink*=nSA;
+ BigInt a2(nNeuRad);
+ a2*=BigInt(nWink);
+ a2/=BigInt(nWink0);
+ nNeuRad=long(a2);
+
+ if (bVertical)
+ aNeuCenter.X()=aStart.X()+nNeuRad;
+ else
+ aNeuCenter.Y()=aStart.Y()+nNeuRad;
+ }
+
+ long nMul=(long)(nUmfang*NormAngle360(nPntWink)/36000);
+
+ if (bAtCenter)
+ nMul*=2;
+
+ aNeuFact=Fraction(nMul,nMarkSize);
+ nWink=nPntWink;
+ }
+ else
+ {
+ nWink=(long)((nMarkSize*360/nUmfang)*100)/2;
+
+ if (nWink==0)
+ bValid=false;
+
+ if (bValid && nSA!=0)
+ { // Winkelfang
+ long nWink0=nWink;
+ nWink+=nSA/2;
+ nWink/=nSA;
+ nWink*=nSA;
+ BigInt a2(nNeuRad);
+ a2*=BigInt(nWink);
+ a2/=BigInt(nWink0);
+ nNeuRad=long(a2);
+
+ if (bVertical)
+ aNeuCenter.X()=aStart.X()+nNeuRad;
+ else
+ aNeuCenter.Y()=aStart.Y()+nNeuRad;
+ }
+ }
+ }
+
+ if (nWink==0 || nNeuRad==0)
+ bValid=false;
+
+ if (!bValid)
+ nNeuRad=0;
+
+ if (!bValid && bResize)
+ {
+ long nMul=bVertical ? dy1 : dx1;
+
+ if (bLft || bUpr)
+ nMul=-nMul;
+
+ long nDiv=nMarkSize;
+
+ if (bAtCenter)
+ {
+ nMul*=2;
+ nMul=Abs(nMul);
+ }
+
+ aNeuFact=Fraction(nMul,nDiv);
+ }
+
+ if (aNeuCenter!=aCenter || bNeuContortion!=bContortion || aNeuFact!=aFact ||
+ bNeuMoveOnly != getMoveOnly() || bNeuRotate!=bRotate || eNeuMode!=eMode)
+ {
+ Hide();
+ setMoveOnly(bNeuMoveOnly);
+ bRotate=bNeuRotate;
+ eMode=eNeuMode;
+ bContortion=bNeuContortion;
+ aCenter=aNeuCenter;
+ aFact=aNeuFact;
+ aRad=Point(nNeuRad,nNeuRad);
+ bResize=aFact!=Fraction(1,1) && aFact.GetDenominator()!=0 && aFact.IsValid();
+ DragStat().NextMove(aPnt);
+ Show();
+ }
+ }
+}
+
+void SdrDragCrook::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
+{
+ const bool bDoResize(aFact!=Fraction(1,1));
+ const bool bDoCrook(aCenter!=aMarkCenter && aRad.X()!=0 && aRad.Y()!=0);
+
+ if (bDoCrook || bDoResize)
+ {
+ if (bDoResize)
+ {
+ Fraction aFact1(1,1);
+
+ if (bContortion)
+ {
+ if (bVertical)
+ {
+ rTarget.Resize(aCenter,aFact1,aFact);
+ }
+ else
+ {
+ rTarget.Resize(aCenter,aFact,aFact1);
+ }
+ }
+ else
+ {
+ Point aCtr0(rTarget.GetSnapRect().Center());
+ Point aCtr1(aCtr0);
+
+ if (bVertical)
+ {
+ ResizePoint(aCtr1,aCenter,aFact1,aFact);
+ }
+ else
+ {
+ ResizePoint(aCtr1,aCenter,aFact,aFact1);
+ }
+
+ Size aSiz(aCtr1.X()-aCtr0.X(),aCtr1.Y()-aCtr0.Y());
+
+ rTarget.Move(aSiz);
+ }
+ }
+
+ if (bDoCrook)
+ {
+ const Rectangle aLocalMarkRect(getSdrDragView().GetMarkedObjRect());
+ const bool bLocalRotate(!bContortion && eMode == SDRCROOK_ROTATE && getSdrDragView().IsRotateAllowed(false));
+
+ getSdrDragView().ImpCrookObj(&rTarget,aCenter,aRad,eMode,bVertical,!bContortion,bLocalRotate,aLocalMarkRect);
+ }
+ }
+}
+
+void SdrDragCrook::applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget)
+{
+ // use helper derived from old stuff
+ _MovAllPoints(rTarget);
+}
+
+bool SdrDragCrook::EndSdrDrag(bool bCopy)
+{
+ Hide();
+
+ if (bResize && aFact==Fraction(1,1))
+ bResize=false;
+
+ const bool bUndo = getSdrDragView().IsUndoEnabled();
+
+ bool bDoCrook=aCenter!=aMarkCenter && aRad.X()!=0 && aRad.Y()!=0;
+
+ if (bDoCrook || bResize)
+ {
+ if (bResize && bUndo)
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(!bContortion?STR_EditCrook:STR_EditCrookContortion,aStr);
+
+ if (bCopy)
+ aStr+=ImpGetResStr(STR_EditWithCopy);
+
+ getSdrDragView().BegUndo(aStr);
+ }
+
+ if (bResize)
+ {
+ Fraction aFact1(1,1);
+
+ if (bContortion)
+ {
+ if (bVertical)
+ getSdrDragView().ResizeMarkedObj(aCenter,aFact1,aFact,bCopy);
+ else
+ getSdrDragView().ResizeMarkedObj(aCenter,aFact,aFact1,bCopy);
+ }
+ else
+ {
+ if (bCopy)
+ getSdrDragView().CopyMarkedObj();
+
+ ULONG nMarkAnz=getSdrDragView().GetMarkedObjectList().GetMarkCount();
+
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=getSdrDragView().GetMarkedObjectList().GetMark(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ Point aCtr0(pO->GetSnapRect().Center());
+ Point aCtr1(aCtr0);
+
+ if (bVertical)
+ ResizePoint(aCtr1,aCenter,aFact1,aFact);
+ else
+ ResizePoint(aCtr1,aCenter,aFact,aFact1);
+
+ Size aSiz(aCtr1.X()-aCtr0.X(),aCtr1.Y()-aCtr0.Y());
+ if( bUndo )
+ AddUndo(getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,aSiz));
+ pO->Move(aSiz);
+ }
+ }
+
+ bCopy=false;
+ }
+
+ if (bDoCrook)
+ {
+ getSdrDragView().CrookMarkedObj(aCenter,aRad,eMode,bVertical,!bContortion,bCopy);
+ getSdrDragView().SetLastCrookCenter(aCenter);
+ }
+
+ if (bResize && bUndo)
+ getSdrDragView().EndUndo();
+
+ return true;
+ }
+
+ return false;
+}
+
+Pointer SdrDragCrook::GetSdrDragPointer() const
+{
+ return Pointer(POINTER_CROOK);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragDistort,SdrDragMethod);
+
+SdrDragDistort::SdrDragDistort(SdrDragView& rNewView)
+: SdrDragMethod(rNewView),
+ nPolyPt(0),
+ bContortionAllowed(false),
+ bNoContortionAllowed(false),
+ bContortion(false)
+{
+}
+
+void SdrDragDistort::TakeSdrDragComment(XubString& rStr) const
+{
+ ImpTakeDescriptionStr(STR_DragMethDistort, rStr);
+
+ XubString aStr;
+
+ rStr.AppendAscii(" (x=");
+ getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDX(), aStr);
+ rStr += aStr;
+ rStr.AppendAscii(" y=");
+ getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr);
+ rStr += aStr;
+ rStr += sal_Unicode(')');
+
+ if(getSdrDragView().IsDragWithCopy())
+ rStr += ImpGetResStr(STR_EditWithCopy);
+}
+
+void SdrDragDistort::createSdrDragEntries()
+{
+ // Add extended frame raster first, so it will be behind objects
+ if(getSdrDragView().GetSdrPageView())
+ {
+ const basegfx::B2DPolyPolygon aDragRaster(impCreateDragRaster(*getSdrDragView().GetSdrPageView(), GetMarkedRect()));
+
+ if(aDragRaster.count())
+ {
+ addSdrDragEntry(new SdrDragEntryPolyPolygon(aDragRaster));
+ }
+ }
+
+ // call parent
+ SdrDragMethod::createSdrDragEntries();
+}
+
+bool SdrDragDistort::BeginSdrDrag()
+{
+ bContortionAllowed=getSdrDragView().IsDistortAllowed(false);
+ bNoContortionAllowed=getSdrDragView().IsDistortAllowed(true);
+
+ if (bContortionAllowed || bNoContortionAllowed)
+ {
+ SdrHdlKind eKind=GetDragHdlKind();
+ nPolyPt=0xFFFF;
+
+ if (eKind==HDL_UPLFT) nPolyPt=0;
+ if (eKind==HDL_UPRGT) nPolyPt=1;
+ if (eKind==HDL_LWRGT) nPolyPt=2;
+ if (eKind==HDL_LWLFT) nPolyPt=3;
+ if (nPolyPt>3) return false;
+
+ aMarkRect=GetMarkedRect();
+ aDistortedRect=XPolygon(aMarkRect);
+ Show();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+void SdrDragDistort::_MovAllPoints(basegfx::B2DPolyPolygon& rTarget)
+{
+ if (bContortion)
+ {
+ SdrPageView* pPV = getSdrDragView().GetSdrPageView();
+
+ if(pPV)
+ {
+ if (pPV->HasMarkedObjPageView())
+ {
+ basegfx::B2DPolyPolygon aDragPolygon(rTarget);
+ const basegfx::B2DRange aOriginalRange(aMarkRect.Left(), aMarkRect.Top(), aMarkRect.Right(), aMarkRect.Bottom());
+ const basegfx::B2DPoint aTopLeft(aDistortedRect[0].X(), aDistortedRect[0].Y());
+ const basegfx::B2DPoint aTopRight(aDistortedRect[1].X(), aDistortedRect[1].Y());
+ const basegfx::B2DPoint aBottomLeft(aDistortedRect[3].X(), aDistortedRect[3].Y());
+ const basegfx::B2DPoint aBottomRight(aDistortedRect[2].X(), aDistortedRect[2].Y());
+
+ aDragPolygon = basegfx::tools::distort(aDragPolygon, aOriginalRange, aTopLeft, aTopRight, aBottomLeft, aBottomRight);
+ rTarget = aDragPolygon;
+ }
+ }
+ }
+}
+
+void SdrDragDistort::MoveSdrDrag(const Point& rPnt)
+{
+ if (DragStat().CheckMinMoved(rPnt))
+ {
+ Point aPnt(GetSnapPos(rPnt));
+
+ if (getSdrDragView().IsOrtho())
+ OrthoDistance8(DragStat().GetStart(),aPnt,getSdrDragView().IsBigOrtho());
+
+ bool bNeuContortion=(bContortionAllowed && !getSdrDragView().IsCrookNoContortion()) || !bNoContortionAllowed;
+
+ if (bNeuContortion!=bContortion || aDistortedRect[nPolyPt]!=aPnt)
+ {
+ Hide();
+ aDistortedRect[nPolyPt]=aPnt;
+ bContortion=bNeuContortion;
+ DragStat().NextMove(aPnt);
+ Show();
+ }
+ }
+}
+
+bool SdrDragDistort::EndSdrDrag(bool bCopy)
+{
+ Hide();
+ bool bDoDistort=DragStat().GetDX()!=0 || DragStat().GetDY()!=0;
+
+ if (bDoDistort)
+ {
+ getSdrDragView().DistortMarkedObj(aMarkRect,aDistortedRect,!bContortion,bCopy);
+ return true;
+ }
+
+ return false;
+}
+
+Pointer SdrDragDistort::GetSdrDragPointer() const
+{
+ return Pointer(POINTER_REFHAND);
+}
+
+void SdrDragDistort::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
+{
+ const bool bDoDistort(DragStat().GetDX()!=0 || DragStat().GetDY()!=0);
+
+ if (bDoDistort)
+ {
+ getSdrDragView().ImpDistortObj(&rTarget, aMarkRect, aDistortedRect, !bContortion);
+ }
+}
+
+void SdrDragDistort::applyCurrentTransformationToPolyPolygon(basegfx::B2DPolyPolygon& rTarget)
+{
+ // use helper derived from old stuff
+ _MovAllPoints(rTarget);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrDragCrop,SdrDragResize);
+
+SdrDragCrop::SdrDragCrop(SdrDragView& rNewView)
+: SdrDragResize(rNewView)
+{
+ // switch off solid dragging for crop; it just makes no sense since showing
+ // a 50% transparent object above the original will not be visible
+ setSolidDraggingActive(false);
+}
+
+void SdrDragCrop::TakeSdrDragComment(XubString& rStr) const
+{
+ ImpTakeDescriptionStr(STR_DragMethCrop, rStr);
+
+ XubString aStr;
+
+ rStr.AppendAscii(" (x=");
+ getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDX(), aStr);
+ rStr += aStr;
+ rStr.AppendAscii(" y=");
+ getSdrDragView().GetModel()->TakeMetricStr(DragStat().GetDY(), aStr);
+ rStr += aStr;
+ rStr += sal_Unicode(')');
+
+ if(getSdrDragView().IsDragWithCopy())
+ rStr += ImpGetResStr(STR_EditWithCopy);
+}
+
+bool SdrDragCrop::EndSdrDrag(bool bCopy)
+{
+ Hide();
+
+ if( DragStat().GetDX()==0 && DragStat().GetDY()==0 )
+ return false;
+
+ const SdrMarkList& rMarkList = getSdrDragView().GetMarkedObjectList();
+
+ if( rMarkList.GetMarkCount() != 1 )
+ return false;
+
+ SdrGrafObj* pObj = dynamic_cast<SdrGrafObj*>( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
+
+ if( !pObj || (pObj->GetGraphicType() == GRAPHIC_NONE) || (pObj->GetGraphicType() == GRAPHIC_DEFAULT) )
+ return false;
+
+ const GraphicObject& rGraphicObject = pObj->GetGraphicObject();
+ const MapMode aMapMode100thmm(MAP_100TH_MM);
+ Size aGraphicSize(rGraphicObject.GetPrefSize());
+
+ if( MAP_PIXEL == rGraphicObject.GetPrefMapMode().GetMapUnit() )
+ aGraphicSize = Application::GetDefaultDevice()->PixelToLogic( aGraphicSize, aMapMode100thmm );
+ else
+ aGraphicSize = Application::GetDefaultDevice()->LogicToLogic( aGraphicSize, rGraphicObject.GetPrefMapMode(), aMapMode100thmm);
+
+ if( aGraphicSize.nA == 0 || aGraphicSize.nB == 0 )
+ return false;
+
+ const SdrGrafCropItem& rOldCrop = (const SdrGrafCropItem&)pObj->GetMergedItem(SDRATTR_GRAFCROP);
+
+ const bool bUndo = getSdrDragView().IsUndoEnabled();
+
+ if( bUndo )
+ {
+ String aUndoStr;
+ ImpTakeDescriptionStr(STR_DragMethCrop, aUndoStr);
+
+ getSdrDragView().BegUndo( aUndoStr );
+ getSdrDragView().AddUndo( getSdrDragView().GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
+ }
+
+ Rectangle aOldRect( pObj->GetLogicRect() );
+ getSdrDragView().ResizeMarkedObj(DragStat().Ref1(),aXFact,aYFact,bCopy);
+ Rectangle aNewRect( pObj->GetLogicRect() );
+
+ double fScaleX = ( aGraphicSize.Width() - rOldCrop.GetLeft() - rOldCrop.GetRight() ) / (double)aOldRect.GetWidth();
+ double fScaleY = ( aGraphicSize.Height() - rOldCrop.GetTop() - rOldCrop.GetBottom() ) / (double)aOldRect.GetHeight();
+
+ sal_Int32 nDiffLeft = aNewRect.nLeft - aOldRect.nLeft;
+ sal_Int32 nDiffTop = aNewRect.nTop - aOldRect.nTop;
+ sal_Int32 nDiffRight = aNewRect.nRight - aOldRect.nRight;
+ sal_Int32 nDiffBottom = aNewRect.nBottom - aOldRect.nBottom;
+
+ sal_Int32 nLeftCrop = static_cast<sal_Int32>( rOldCrop.GetLeft() + nDiffLeft * fScaleX );
+ sal_Int32 nTopCrop = static_cast<sal_Int32>( rOldCrop.GetTop() + nDiffTop * fScaleY );
+ sal_Int32 nRightCrop = static_cast<sal_Int32>( rOldCrop.GetRight() - nDiffRight * fScaleX );
+ sal_Int32 nBottomCrop = static_cast<sal_Int32>( rOldCrop.GetBottom() - nDiffBottom * fScaleY );
+
+ SfxItemPool& rPool = getSdrDragView().GetModel()->GetItemPool();
+ SfxItemSet aSet( rPool, SDRATTR_GRAFCROP, SDRATTR_GRAFCROP );
+ aSet.Put( SdrGrafCropItem( nLeftCrop, nTopCrop, nRightCrop, nBottomCrop ) );
+ getSdrDragView().SetAttributes( aSet, false );
+
+ if( bUndo )
+ getSdrDragView().EndUndo();
+
+ return true;
+}
+
+Pointer SdrDragCrop::GetSdrDragPointer() const
+{
+ return Pointer(POINTER_CROP);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svddrgv.cxx b/svx/source/svdraw/svddrgv.cxx
new file mode 100644
index 000000000000..e3efdcaa664d
--- /dev/null
+++ b/svx/source/svdraw/svddrgv.cxx
@@ -0,0 +1,1009 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svddrgv.hxx>
+#include "xattr.hxx"
+#include <svx/xpoly.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdoedge.hxx>
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+#include "svddrgm1.hxx"
+#include <svx/obj3d.hxx>
+#include <svx/svdoashp.hxx>
+#include <sdrpaintwindow.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/polypolygoneditor.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+
+using namespace sdr;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@ @@@@@ @@@@ @@@@ @@ @@ @@ @@@@@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
+// @@ @@ @@@@@ @@@@@@ @@ @@@ @@@@@ @@ @@@@ @@@@@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@@@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
+// @@@@@ @@ @@ @@ @@ @@@@@ @ @@ @@@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrDragView::ImpClearVars()
+{
+ bFramDrag=FALSE;
+ eDragMode=SDRDRAG_MOVE;
+ bDragLimit=FALSE;
+ bMarkedHitMovesAlways=FALSE;
+ eDragHdl=HDL_MOVE;
+ pDragHdl=NULL;
+ bDragHdl=FALSE;
+ bDragSpecial=FALSE;
+ mpCurrentSdrDragMethod=NULL;
+ bDragStripes=FALSE;
+ bMirrRefDragObj=TRUE;
+ bDragWithCopy=FALSE;
+ pInsPointUndo=NULL;
+ bInsGluePoint=FALSE;
+ bInsObjPointMode=FALSE;
+ bInsGluePointMode=FALSE;
+ nDragXorPolyLimit=100;
+ nDragXorPointLimit=500;
+ bNoDragXorPolys=FALSE;
+ bAutoVertexCon=TRUE;
+ bAutoCornerCon=FALSE;
+ bRubberEdgeDragging=TRUE;
+ nRubberEdgeDraggingLimit=100;
+ bDetailedEdgeDragging=TRUE;
+ nDetailedEdgeDraggingLimit=10;
+ bResizeAtCenter=FALSE;
+ bCrookAtCenter=FALSE;
+ bMouseHideWhileDraggingPoints=FALSE;
+
+ // init using default
+ mbSolidDragging = getOptionsDrawinglayer().IsSolidDragCreate();
+}
+
+void SdrDragView::ImpMakeDragAttr()
+{
+ ImpDelDragAttr();
+}
+
+SdrDragView::SdrDragView(SdrModel* pModel1, OutputDevice* pOut)
+: SdrExchangeView(pModel1,pOut)
+{
+ ImpClearVars();
+ ImpMakeDragAttr();
+}
+
+SdrDragView::~SdrDragView()
+{
+ ImpDelDragAttr();
+}
+
+void SdrDragView::ImpDelDragAttr()
+{
+}
+
+BOOL SdrDragView::IsAction() const
+{
+ return (mpCurrentSdrDragMethod || SdrExchangeView::IsAction());
+}
+
+void SdrDragView::MovAction(const Point& rPnt)
+{
+ SdrExchangeView::MovAction(rPnt);
+ if (mpCurrentSdrDragMethod)
+ {
+ MovDragObj(rPnt);
+ }
+}
+
+void SdrDragView::EndAction()
+{
+ if (mpCurrentSdrDragMethod)
+ {
+ EndDragObj(FALSE);
+ }
+ SdrExchangeView::EndAction();
+}
+
+void SdrDragView::BckAction()
+{
+ SdrExchangeView::BckAction();
+ BrkDragObj();
+}
+
+void SdrDragView::BrkAction()
+{
+ SdrExchangeView::BrkAction();
+ BrkDragObj();
+}
+
+void SdrDragView::TakeActionRect(Rectangle& rRect) const
+{
+ if (mpCurrentSdrDragMethod)
+ {
+ rRect=aDragStat.GetActionRect();
+ if (rRect.IsEmpty())
+ {
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV&& pPV->HasMarkedObjPageView())
+ {
+ // #i95646# is this used..?
+ const basegfx::B2DRange aBoundRange(mpCurrentSdrDragMethod->getCurrentRange());
+ rRect = Rectangle(
+ basegfx::fround(aBoundRange.getMinX()), basegfx::fround(aBoundRange.getMinY()),
+ basegfx::fround(aBoundRange.getMaxX()), basegfx::fround(aBoundRange.getMaxY()));
+ }
+ }
+ if (rRect.IsEmpty())
+ {
+ rRect=Rectangle(aDragStat.GetNow(),aDragStat.GetNow());
+ }
+ }
+ else
+ {
+ SdrExchangeView::TakeActionRect(rRect);
+ }
+}
+
+BOOL SdrDragView::TakeDragObjAnchorPos(Point& rPos, BOOL bTR ) const
+{
+ Rectangle aR;
+ TakeActionRect(aR);
+ rPos = bTR ? aR.TopRight() : aR.TopLeft();
+ if (GetMarkedObjectCount()==1 && IsDragObj() && // nur bei Einzelselektion
+ !IsDraggingPoints() && !IsDraggingGluePoints() && // nicht beim Punkteschieben
+ !mpCurrentSdrDragMethod->ISA(SdrDragMovHdl)) // nicht beim Handlesschieben
+ {
+ SdrObject* pObj=GetMarkedObjectByIndex(0);
+ if (pObj->ISA(SdrCaptionObj))
+ {
+ Point aPt(((SdrCaptionObj*)pObj)->GetTailPos());
+ BOOL bTail=eDragHdl==HDL_POLY; // Schwanz wird gedraggt (nicht so ganz feine Abfrage hier)
+ BOOL bOwn=mpCurrentSdrDragMethod->ISA(SdrDragObjOwn); // Objektspeziefisch
+ if (!bTail)
+ { // bei bTail liefert TakeActionRect schon das richtige
+ if (bOwn)
+ { // bOwn kann sein MoveTextFrame, ResizeTextFrame aber eben nicht mehr DragTail
+ rPos=aPt;
+ }
+ else
+ {
+ // drag the whole Object (Move, Resize, ...)
+ const basegfx::B2DPoint aTransformed(mpCurrentSdrDragMethod->getCurrentTransformation() * basegfx::B2DPoint(aPt.X(), aPt.Y()));
+ rPos.X() = basegfx::fround(aTransformed.getX());
+ rPos.Y() = basegfx::fround(aTransformed.getY());
+ }
+ }
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrDragView::TakeDragLimit(SdrDragMode /*eMode*/, Rectangle& /*rRect*/) const
+{
+ return FALSE;
+}
+
+BOOL SdrDragView::BegDragObj(const Point& rPnt, OutputDevice* pOut, SdrHdl* pHdl, short nMinMov, SdrDragMethod* pForcedMeth)
+{
+ BrkAction();
+
+ bool bRet=false;
+ {
+ SetDragWithCopy(FALSE);
+ //ForceEdgesOfMarkedNodes();
+ //TODO: aAni.Reset();
+ mpCurrentSdrDragMethod=NULL;
+ bDragSpecial=FALSE;
+ bDragLimit=FALSE;
+ SdrDragMode eTmpMode=eDragMode;
+ if (eTmpMode==SDRDRAG_MOVE && pHdl!=NULL && pHdl->GetKind()!=HDL_MOVE) {
+ eTmpMode=SDRDRAG_RESIZE;
+ }
+ bDragLimit=TakeDragLimit(eTmpMode,aDragLimit);
+ bFramDrag=ImpIsFrameHandles();
+ if (!bFramDrag &&
+ (pMarkedObj==NULL || !pMarkedObj->hasSpecialDrag()) &&
+ (pHdl==NULL || pHdl->GetObj()==NULL)) {
+ bFramDrag=TRUE;
+ }
+
+ Point aPnt(rPnt);
+ if(pHdl == NULL
+ || pHdl->GetKind() == HDL_MOVE
+ || pHdl->GetKind() == HDL_MIRX
+ || pHdl->GetKind() == HDL_TRNS
+ || pHdl->GetKind() == HDL_GRAD)
+ {
+ aDragStat.Reset(aPnt);
+ }
+ else
+ {
+ aDragStat.Reset(pHdl->GetPos());
+ }
+
+ aDragStat.SetView((SdrView*)this);
+ aDragStat.SetPageView(pMarkedPV); // <<-- hier muss die DragPV rein!!!
+ aDragStat.SetMinMove(ImpGetMinMovLogic(nMinMov,pOut));
+ aDragStat.SetHdl(pHdl);
+ aDragStat.NextPoint();
+ pDragWin=pOut;
+ pDragHdl=pHdl;
+ eDragHdl= pHdl==NULL ? HDL_MOVE : pHdl->GetKind();
+ bDragHdl=eDragHdl==HDL_REF1 || eDragHdl==HDL_REF2 || eDragHdl==HDL_MIRX;
+
+ // #103894# Expand test for HDL_ANCHOR_TR
+ BOOL bNotDraggable = (HDL_ANCHOR == eDragHdl || HDL_ANCHOR_TR == eDragHdl);
+
+ if(pHdl && (pHdl->GetKind() == HDL_SMARTTAG) && pForcedMeth )
+ {
+ // just use the forced method for smart tags
+ }
+ else if(bDragHdl)
+ {
+ mpCurrentSdrDragMethod = new SdrDragMovHdl(*this);
+ }
+ else if(!bNotDraggable)
+ {
+ switch (eDragMode)
+ {
+ case SDRDRAG_ROTATE: case SDRDRAG_SHEAR: case SDRDRAG_DISTORT:
+ {
+ switch (eDragHdl)
+ {
+ case HDL_LEFT: case HDL_RIGHT:
+ case HDL_UPPER: case HDL_LOWER:
+ {
+ // Sind 3D-Objekte selektiert?
+ BOOL b3DObjSelected = FALSE;
+ for(UINT32 a=0;!b3DObjSelected && a<GetMarkedObjectCount();a++)
+ {
+ SdrObject* pObj = GetMarkedObjectByIndex(a);
+ if(pObj && pObj->ISA(E3dObject))
+ b3DObjSelected = TRUE;
+ }
+ // Falls ja, Shear auch bei !IsShearAllowed zulassen,
+ // da es sich bei 3D-Objekten um eingeschraenkte
+ // Rotationen handelt
+ if (!b3DObjSelected && !IsShearAllowed())
+ return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragShear(*this,eDragMode==SDRDRAG_ROTATE);
+ } break;
+ case HDL_UPLFT: case HDL_UPRGT:
+ case HDL_LWLFT: case HDL_LWRGT:
+ {
+ if (eDragMode==SDRDRAG_SHEAR || eDragMode==SDRDRAG_DISTORT)
+ {
+ if (!IsDistortAllowed(TRUE) && !IsDistortAllowed(FALSE)) return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragDistort(*this);
+ }
+ else
+ {
+ if (!IsRotateAllowed(TRUE)) return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragRotate(*this);
+ }
+ } break;
+ default:
+ {
+ if (IsMarkedHitMovesAlways() && eDragHdl==HDL_MOVE)
+ { // HDL_MOVE ist auch wenn Obj direkt getroffen
+ if (!IsMoveAllowed()) return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragMove(*this);
+ }
+ else
+ {
+ if (!IsRotateAllowed(TRUE)) return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragRotate(*this);
+ }
+ }
+ }
+ } break;
+ case SDRDRAG_MIRROR:
+ {
+ if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
+ {
+ if (!IsMoveAllowed()) return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragMove(*this);
+ }
+ else
+ {
+ if (!IsMirrorAllowed(TRUE,TRUE)) return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragMirror(*this);
+ }
+ } break;
+
+ case SDRDRAG_CROP:
+ {
+ if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
+ {
+ if (!IsMoveAllowed())
+ return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragMove(*this);
+ }
+ else
+ {
+ if (!IsCrookAllowed(TRUE) && !IsCrookAllowed(FALSE))
+ return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragCrop(*this);
+ }
+ }
+ break;
+
+ case SDRDRAG_TRANSPARENCE:
+ {
+ if(eDragHdl == HDL_MOVE && IsMarkedHitMovesAlways())
+ {
+ if(!IsMoveAllowed())
+ return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragMove(*this);
+ }
+ else
+ {
+ if(!IsTransparenceAllowed())
+ return FALSE;
+
+ mpCurrentSdrDragMethod = new SdrDragGradient(*this, FALSE);
+ }
+ break;
+ }
+ case SDRDRAG_GRADIENT:
+ {
+ if(eDragHdl == HDL_MOVE && IsMarkedHitMovesAlways())
+ {
+ if(!IsMoveAllowed())
+ return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragMove(*this);
+ }
+ else
+ {
+ if(!IsGradientAllowed())
+ return FALSE;
+
+ mpCurrentSdrDragMethod = new SdrDragGradient(*this);
+ }
+ break;
+ }
+
+ case SDRDRAG_CROOK :
+ {
+ if (eDragHdl==HDL_MOVE && IsMarkedHitMovesAlways())
+ {
+ if (!IsMoveAllowed()) return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragMove(*this);
+ }
+ else
+ {
+ if (!IsCrookAllowed(TRUE) && !IsCrookAllowed(FALSE)) return FALSE;
+ mpCurrentSdrDragMethod = new SdrDragCrook(*this);
+ }
+ } break;
+
+ default:
+ {
+ // SDRDRAG_MOVE
+ if((eDragHdl == HDL_MOVE) && !IsMoveAllowed())
+ {
+ return FALSE;
+ }
+ else if(eDragHdl == HDL_GLUE)
+ {
+ mpCurrentSdrDragMethod = new SdrDragMove(*this);
+ }
+ else
+ {
+ if(bFramDrag)
+ {
+ if(eDragHdl == HDL_MOVE)
+ {
+ mpCurrentSdrDragMethod = new SdrDragMove(*this);
+ }
+ else
+ {
+ if(!IsResizeAllowed(TRUE))
+ {
+ return FALSE;
+ }
+
+ sal_Bool bSingleTextObjMark = sal_False; // SJ: #i100490#
+ if ( GetMarkedObjectCount() == 1 )
+ {
+ pMarkedObj=GetMarkedObjectByIndex(0);
+ if ( pMarkedObj &&
+ pMarkedObj->ISA( SdrTextObj ) &&
+ static_cast<SdrTextObj*>(pMarkedObj)->IsTextFrame() )
+ bSingleTextObjMark = sal_True;
+ }
+ if ( bSingleTextObjMark )
+ mpCurrentSdrDragMethod = new SdrDragObjOwn(*this);
+ else
+ mpCurrentSdrDragMethod = new SdrDragResize(*this);
+ }
+ }
+ else
+ {
+ if(HDL_MOVE == eDragHdl)
+ {
+ const bool bCustomShapeSelected(1 == GetMarkedObjectCount() && GetMarkedObjectByIndex(0)->ISA(SdrObjCustomShape));
+
+ if(bCustomShapeSelected)
+ {
+ mpCurrentSdrDragMethod = new SdrDragMove( *this );
+ }
+ }
+ else if(HDL_POLY == eDragHdl)
+ {
+ const bool bConnectorSelected(1 == GetMarkedObjectCount() && GetMarkedObjectByIndex(0)->ISA(SdrEdgeObj));
+
+ if(bConnectorSelected)
+ {
+ // #i97784#
+ // fallback to old behaviour for connectors (see
+ // text in task description for more details)
+ }
+ else if(!IsMoveAllowed() || !IsResizeAllowed())
+ {
+ // #i77187#
+ // do not allow move of polygon points if object is move or size protected
+ return FALSE;
+ }
+ }
+
+ if(!mpCurrentSdrDragMethod)
+ {
+ // fallback to DragSpecial if no interaction defined
+ bDragSpecial = TRUE;
+ mpCurrentSdrDragMethod = new SdrDragObjOwn(*this);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (pForcedMeth!=NULL)
+ {
+ delete mpCurrentSdrDragMethod;
+ mpCurrentSdrDragMethod = pForcedMeth;
+ }
+ aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
+ if (mpCurrentSdrDragMethod)
+ {
+ bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
+ if (!bRet)
+ {
+ if (pHdl==NULL && IS_TYPE(SdrDragObjOwn,mpCurrentSdrDragMethod))
+ {
+ // Aha, Obj kann nicht Move SpecialDrag, also MoveFrameDrag versuchen
+ delete mpCurrentSdrDragMethod;
+ mpCurrentSdrDragMethod = 0;
+ bDragSpecial=FALSE;
+
+ if (!IsMoveAllowed())
+ return FALSE;
+
+ bFramDrag=TRUE;
+ mpCurrentSdrDragMethod = new SdrDragMove(*this);
+ aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
+ bRet = mpCurrentSdrDragMethod->BeginSdrDrag();
+ }
+ }
+ if (!bRet)
+ {
+ delete mpCurrentSdrDragMethod;
+ mpCurrentSdrDragMethod = 0;
+ aDragStat.SetDragMethod(mpCurrentSdrDragMethod);
+ }
+ }
+ }
+
+ return bRet;
+}
+
+void SdrDragView::MovDragObj(const Point& rPnt)
+{
+ if (mpCurrentSdrDragMethod)
+ {
+ Point aPnt(rPnt);
+ ImpLimitToWorkArea(aPnt);
+ mpCurrentSdrDragMethod->MoveSdrDrag(aPnt); // this call already makes a Hide()/Show combination
+ }
+}
+
+BOOL SdrDragView::EndDragObj(BOOL bCopy)
+{
+ bool bRet(false);
+
+ // #i73341# If insert GluePoint, do not insist on last points being different
+ if(mpCurrentSdrDragMethod && aDragStat.IsMinMoved() && (IsInsertGluePoint() || aDragStat.GetNow() != aDragStat.GetPrev()))
+ {
+ ULONG nHdlAnzMerk=0;
+
+ if (bEliminatePolyPoints)
+ { // IBM Special
+ nHdlAnzMerk=GetMarkablePointCount();
+ }
+
+ const bool bUndo = IsUndoEnabled();
+ if (IsInsertGluePoint() && bUndo)
+ {
+ BegUndo(aInsPointUndoStr);
+ AddUndo(pInsPointUndo);
+ }
+
+ bRet = mpCurrentSdrDragMethod->EndSdrDrag(bCopy);
+
+ if( IsInsertGluePoint() && bUndo)
+ EndUndo();
+
+ delete mpCurrentSdrDragMethod;
+ mpCurrentSdrDragMethod = 0;
+
+ if (bEliminatePolyPoints)
+ { // IBM Special
+ if (nHdlAnzMerk!=GetMarkablePointCount())
+ {
+ UnmarkAllPoints();
+ }
+ }
+
+ if (bInsPolyPoint)
+ {
+ SetMarkHandles();
+ bInsPolyPoint=FALSE;
+ if( bUndo )
+ {
+ BegUndo(aInsPointUndoStr);
+ AddUndo(pInsPointUndo);
+ EndUndo();
+ }
+ }
+
+ eDragHdl=HDL_MOVE;
+ pDragHdl=NULL;
+
+ if (!bSomeObjChgdFlag)
+ {
+ // Aha, Obj hat nicht gebroadcastet (z.B. Writer FlyFrames)
+ if(!bDragHdl)
+ {
+ AdjustMarkHdl();
+ }
+ }
+ }
+ else
+ {
+ BrkDragObj();
+ }
+
+ bInsPolyPoint=FALSE;
+ SetInsertGluePoint(FALSE);
+
+ return bRet;
+}
+
+void SdrDragView::BrkDragObj()
+{
+ if (mpCurrentSdrDragMethod)
+ {
+ mpCurrentSdrDragMethod->CancelSdrDrag();
+
+ delete mpCurrentSdrDragMethod;
+ mpCurrentSdrDragMethod = 0;
+
+ if (bInsPolyPoint)
+ {
+ pInsPointUndo->Undo(); // Den eingefuegten Punkt wieder raus
+ delete pInsPointUndo;
+ pInsPointUndo=NULL;
+ SetMarkHandles();
+ bInsPolyPoint=FALSE;
+ }
+
+ if (IsInsertGluePoint())
+ {
+ pInsPointUndo->Undo(); // Den eingefuegten Klebepunkt wieder raus
+ delete pInsPointUndo;
+ pInsPointUndo=NULL;
+ SetInsertGluePoint(FALSE);
+ }
+
+ eDragHdl=HDL_MOVE;
+ pDragHdl=NULL;
+ }
+}
+
+BOOL SdrDragView::IsInsObjPointPossible() const
+{
+ return pMarkedObj!=NULL && pMarkedObj->IsPolyObj();
+}
+
+sal_Bool SdrDragView::ImpBegInsObjPoint(sal_Bool bIdxZwang, sal_uInt32 nIdx, const Point& rPnt, sal_Bool bNewObj, OutputDevice* pOut)
+{
+ sal_Bool bRet(sal_False);
+
+ if(pMarkedObj && pMarkedObj->ISA(SdrPathObj))
+ {
+ SdrPathObj* pMarkedPath = (SdrPathObj*)pMarkedObj;
+ BrkAction();
+ pInsPointUndo = dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pMarkedObj) );
+ DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
+
+ XubString aStr(ImpGetResStr(STR_DragInsertPoint));
+ XubString aName;
+ pMarkedObj->TakeObjNameSingul(aName);
+ xub_StrLen nPos(aStr.SearchAscii("%1"));
+
+ if(STRING_NOTFOUND != nPos)
+ {
+ aStr.Erase(nPos, 2);
+ aStr.Insert(aName, nPos);
+ }
+
+ aInsPointUndoStr = aStr;
+ Point aPt(rPnt);
+
+ if(bNewObj)
+ aPt = GetSnapPos(aPt,pMarkedPV);
+
+ sal_Bool bClosed0(pMarkedPath->IsClosedObj());
+
+ if(bIdxZwang)
+ {
+ mnInsPointNum = pMarkedPath->NbcInsPoint(nIdx, aPt, bNewObj, sal_True);
+ }
+ else
+ {
+ mnInsPointNum = pMarkedPath->NbcInsPointOld(aPt, bNewObj, sal_True);
+ }
+
+ if(bClosed0 != pMarkedPath->IsClosedObj())
+ {
+ // Obj was closed implicit
+ // object changed
+ pMarkedPath->SetChanged();
+ pMarkedPath->BroadcastObjectChange();
+ }
+
+ if(0xffffffff != mnInsPointNum)
+ {
+ bInsPolyPoint = sal_True;
+ UnmarkAllPoints();
+ AdjustMarkHdl();
+
+ bRet = BegDragObj(rPnt, pOut, aHdl.GetHdl(mnInsPointNum), 0);
+
+ if (bRet)
+ {
+ aDragStat.SetMinMoved();
+ MovDragObj(rPnt);
+ }
+ }
+ else
+ {
+ delete pInsPointUndo;
+ pInsPointUndo = NULL;
+ }
+ }
+
+ return bRet;
+}
+
+BOOL SdrDragView::EndInsObjPoint(SdrCreateCmd eCmd)
+{
+ if(IsInsObjPoint())
+ {
+ sal_uInt32 nNextPnt(mnInsPointNum);
+ Point aPnt(aDragStat.GetNow());
+ BOOL bOk=EndDragObj(FALSE);
+ if (bOk==TRUE && eCmd!=SDRCREATE_FORCEEND)
+ {
+ // Ret=True bedeutet: Action ist vorbei.
+ bOk=!(ImpBegInsObjPoint(sal_True, nNextPnt, aPnt, eCmd == SDRCREATE_NEXTOBJECT, pDragWin));
+ }
+
+ return bOk;
+ } else return FALSE;
+}
+
+BOOL SdrDragView::IsInsGluePointPossible() const
+{
+ BOOL bRet=FALSE;
+ if (IsInsGluePointMode() && AreObjectsMarked())
+ {
+ if (GetMarkedObjectCount()==1)
+ {
+ // FALSE liefern, wenn 1 Objekt und dieses ein Verbinder ist.
+ const SdrObject* pObj=GetMarkedObjectByIndex(0);
+ if (!HAS_BASE(SdrEdgeObj,pObj))
+ {
+ bRet=TRUE;
+ }
+ }
+ else
+ {
+ bRet=TRUE;
+ }
+ }
+ return bRet;
+}
+
+BOOL SdrDragView::BegInsGluePoint(const Point& rPnt)
+{
+ BOOL bRet=FALSE;
+ SdrObject* pObj;
+ SdrPageView* pPV;
+ ULONG nMarkNum;
+ if (PickMarkedObj(rPnt,pObj,pPV,&nMarkNum,SDRSEARCH_PASS2BOUND))
+ {
+ BrkAction();
+ UnmarkAllGluePoints();
+ pInsPointUndo= dynamic_cast< SdrUndoGeoObj* >( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj) );
+ DBG_ASSERT( pInsPointUndo, "svx::SdrDragView::BegInsObjPoint(), could not create correct undo object!" );
+ XubString aStr(ImpGetResStr(STR_DragInsertGluePoint));
+ XubString aName; pObj->TakeObjNameSingul(aName);
+
+ aStr.SearchAndReplaceAscii("%1", aName);
+
+ aInsPointUndoStr=aStr;
+ SdrGluePointList* pGPL=pObj->ForceGluePointList();
+ if (pGPL!=NULL)
+ {
+ USHORT nGlueIdx=pGPL->Insert(SdrGluePoint());
+ SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
+ USHORT nGlueId=rGP.GetId();
+ rGP.SetAbsolutePos(rPnt,*pObj);
+
+ SdrHdl* pHdl=NULL;
+ if (MarkGluePoint(pObj,nGlueId,pPV))
+ {
+ pHdl=GetGluePointHdl(pObj,nGlueId);
+ }
+ if (pHdl!=NULL && pHdl->GetKind()==HDL_GLUE && pHdl->GetObj()==pObj && pHdl->GetObjHdlNum()==nGlueId)
+ {
+ SetInsertGluePoint(TRUE);
+ bRet=BegDragObj(rPnt,NULL,pHdl,0);
+ if (bRet)
+ {
+ aDragStat.SetMinMoved();
+ MovDragObj(rPnt);
+ }
+ else
+ {
+ SetInsertGluePoint(FALSE);
+ delete pInsPointUndo;
+ pInsPointUndo=NULL;
+ }
+ }
+ else
+ {
+ DBG_ERROR("BegInsGluePoint(): GluePoint-Handle nicht gefunden");
+ }
+ }
+ else
+ {
+ // Keine Klebepunkte moeglich bei diesem Objekt (z.B. Edge)
+ SetInsertGluePoint(FALSE);
+ delete pInsPointUndo;
+ pInsPointUndo=NULL;
+ }
+ }
+
+ return bRet;
+}
+
+void SdrDragView::ShowDragObj()
+{
+ if(mpCurrentSdrDragMethod && !aDragStat.IsShown())
+ {
+ for(sal_uInt32 a(0); a < PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = GetPaintWindow(a);
+ sdr::overlay::OverlayManager* pOverlayManager = pCandidate->GetOverlayManager();
+
+ if(pOverlayManager)
+ {
+ mpCurrentSdrDragMethod->CreateOverlayGeometry(*pOverlayManager);
+
+ // #i101679# Force changed overlay to be shown
+ pOverlayManager->flush();
+ }
+ }
+
+ aDragStat.SetShown(TRUE);
+ }
+}
+
+void SdrDragView::HideDragObj()
+{
+ if(mpCurrentSdrDragMethod && aDragStat.IsShown())
+ {
+ mpCurrentSdrDragMethod->destroyOverlayGeometry();
+ aDragStat.SetShown(FALSE);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrDragView::SetNoDragXorPolys(BOOL bOn)
+{
+ if (IsNoDragXorPolys()!=bOn)
+ {
+ const bool bDragging(mpCurrentSdrDragMethod);
+ const bool bShown(bDragging && aDragStat.IsShown());
+
+ if(bShown)
+ {
+ HideDragObj();
+ }
+
+ bNoDragXorPolys = bOn;
+
+ if(bDragging)
+ {
+ // force recreation of drag content
+ mpCurrentSdrDragMethod->resetSdrDragEntries();
+ }
+
+ if(bShown)
+ {
+ ShowDragObj();
+ }
+ }
+}
+
+void SdrDragView::SetDragStripes(BOOL bOn)
+{
+ if (mpCurrentSdrDragMethod && aDragStat.IsShown())
+ {
+ HideDragObj();
+ bDragStripes=bOn;
+ ShowDragObj();
+ }
+ else
+ {
+ bDragStripes=bOn;
+ }
+}
+
+BOOL SdrDragView::IsOrthoDesired() const
+{
+ if(mpCurrentSdrDragMethod && (IS_TYPE(SdrDragObjOwn, mpCurrentSdrDragMethod) || IS_TYPE(SdrDragResize, mpCurrentSdrDragMethod)))
+ {
+ return bOrthoDesiredOnMarked;
+ }
+
+ return FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrDragView::SetRubberEdgeDragging(BOOL bOn)
+{
+ if (bOn!=IsRubberEdgeDragging())
+ {
+ ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
+ BOOL bShowHide=nAnz!=0 && IsDragObj() &&
+ (nRubberEdgeDraggingLimit>=nAnz);
+ if (bShowHide)
+ HideDragObj();
+ bRubberEdgeDragging=bOn;
+ if (bShowHide)
+ ShowDragObj();
+ }
+}
+
+void SdrDragView::SetRubberEdgeDraggingLimit(USHORT nEdgeObjAnz)
+{
+ if (nEdgeObjAnz!=nRubberEdgeDraggingLimit)
+ {
+ ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
+ BOOL bShowHide=IsRubberEdgeDragging() && nAnz!=0 && IsDragObj() &&
+ (nEdgeObjAnz>=nAnz)!=(nRubberEdgeDraggingLimit>=nAnz);
+ if (bShowHide)
+ HideDragObj();
+ nRubberEdgeDraggingLimit=nEdgeObjAnz;
+ if (bShowHide)
+ ShowDragObj();
+ }
+}
+
+void SdrDragView::SetDetailedEdgeDragging(BOOL bOn)
+{
+ if (bOn!=IsDetailedEdgeDragging())
+ {
+ ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
+ BOOL bShowHide=nAnz!=0 && IsDragObj() &&
+ (nDetailedEdgeDraggingLimit>=nAnz);
+ if (bShowHide)
+ HideDragObj();
+ bDetailedEdgeDragging=bOn;
+ if (bShowHide)
+ ShowDragObj();
+ }
+}
+
+void SdrDragView::SetDetailedEdgeDraggingLimit(USHORT nEdgeObjAnz)
+{
+ if (nEdgeObjAnz!=nDetailedEdgeDraggingLimit)
+ {
+ ULONG nAnz = GetEdgesOfMarkedNodes().GetMarkCount();
+ BOOL bShowHide=IsDetailedEdgeDragging() && nAnz!=0 && IsDragObj() &&
+ (nEdgeObjAnz>=nAnz)!=(nDetailedEdgeDraggingLimit>=nAnz);
+ if (bShowHide)
+ HideDragObj();
+ nDetailedEdgeDraggingLimit=nEdgeObjAnz;
+ if (bShowHide)
+ ShowDragObj();
+ }
+}
+
+void SdrDragView::SetMarkHandles()
+{
+ if( pDragHdl )
+ pDragHdl = 0;
+
+ SdrExchangeView::SetMarkHandles();
+}
+
+void SdrDragView::SetSolidDragging(bool bOn)
+{
+ if((bool)mbSolidDragging != bOn)
+ {
+ mbSolidDragging = bOn;
+ }
+}
+
+bool SdrDragView::IsSolidDragging() const
+{
+ // allow each user to disable by having a local setting, but using AND for
+ // checking allowance
+ return mbSolidDragging && getOptionsDrawinglayer().IsSolidDragCreate();
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
new file mode 100644
index 000000000000..693f933e5e7b
--- /dev/null
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -0,0 +1,1088 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <vcl/metaact.hxx>
+#include <svx/svdedtv.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdograf.hxx> // fuer Possibilities
+#include <svx/svdopath.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdopage.hxx>
+#include <svx/svdoedge.hxx>
+#include <svx/svdlayer.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdpoev.hxx> // fuer die PolyPossiblities
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+#include <svx/e3dsceneupdater.hxx>
+
+// #i13033#
+#include <clonelist.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@ @@@@@ @@ @@@@@@ @@ @@ @@ @@@@@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
+// @@@@ @@ @@ @@ @@ @@@@@ @@ @@@@ @@@@@@@
+// @@ @@ @@ @@ @@ @@@ @@ @@ @@@@@@@
+// @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
+// @@@@@ @@@@@ @@ @@ @ @@ @@@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::ImpResetPossibilityFlags()
+{
+ bReadOnly =FALSE;
+
+ bGroupPossible =FALSE;
+ bUnGroupPossible =FALSE;
+ bGrpEnterPossible =FALSE;
+ bDeletePossible =FALSE;
+ bToTopPossible =FALSE;
+ bToBtmPossible =FALSE;
+ bReverseOrderPossible =FALSE;
+
+ bImportMtfPossible =FALSE;
+ bCombinePossible =FALSE;
+ bDismantlePossible =FALSE;
+ bCombineNoPolyPolyPossible =FALSE;
+ bDismantleMakeLinesPossible=FALSE;
+ bOrthoDesiredOnMarked =FALSE;
+
+ bMoreThanOneNotMovable =FALSE;
+ bOneOrMoreMovable =FALSE;
+ bMoreThanOneNoMovRot =FALSE;
+ bContortionPossible =FALSE;
+ bAllPolys =FALSE;
+ bOneOrMorePolys =FALSE;
+ bMoveAllowed =FALSE;
+ bResizeFreeAllowed =FALSE;
+ bResizePropAllowed =FALSE;
+ bRotateFreeAllowed =FALSE;
+ bRotate90Allowed =FALSE;
+ bMirrorFreeAllowed =FALSE;
+ bMirror45Allowed =FALSE;
+ bMirror90Allowed =FALSE;
+ bTransparenceAllowed =FALSE;
+ bGradientAllowed =FALSE;
+ bShearAllowed =FALSE;
+ bEdgeRadiusAllowed =FALSE;
+ bCanConvToPath =FALSE;
+ bCanConvToPoly =FALSE;
+ bCanConvToContour =FALSE;
+ bCanConvToPathLineToArea=FALSE;
+ bCanConvToPolyLineToArea=FALSE;
+ bMoveProtect =FALSE;
+ bResizeProtect =FALSE;
+}
+
+void SdrEditView::ImpClearVars()
+{
+ ImpResetPossibilityFlags();
+ bPossibilitiesDirty=TRUE; // << war von Purify angemeckert
+ bBundleVirtObj=FALSE;
+}
+
+SdrEditView::SdrEditView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrMarkView(pModel1,pOut)
+{
+ ImpClearVars();
+}
+
+SdrEditView::~SdrEditView()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrLayer* SdrEditView::InsertNewLayer(const XubString& rName, USHORT nPos)
+{
+ SdrLayerAdmin& rLA=pMod->GetLayerAdmin();
+ USHORT nMax=rLA.GetLayerCount();
+ if (nPos>nMax) nPos=nMax;
+ SdrLayer* pNewLayer=rLA.NewLayer(rName,nPos);
+
+ if( GetModel()->IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewLayer(nPos,rLA,*pMod));
+
+ pMod->SetChanged();
+ return pNewLayer;
+}
+
+#include <svx/svdogrp.hxx>
+#include <svx/scene3d.hxx>
+
+BOOL SdrEditView::ImpDelLayerCheck(SdrObjList* pOL, SdrLayerID nDelID) const
+{
+ sal_Bool bDelAll(sal_True);
+ sal_uInt32 nObjAnz(pOL->GetObjCount());
+
+ for(sal_uInt32 nObjNum(nObjAnz); nObjNum > 0 && bDelAll;)
+ {
+ nObjNum--;
+ SdrObject* pObj = pOL->GetObj(nObjNum);
+ SdrObjList* pSubOL = pObj->GetSubList();
+
+ // #104809# Test explicitely for group objects and 3d scenes
+ if(pSubOL && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dScene)))
+ {
+ if(!ImpDelLayerCheck(pSubOL, nDelID))
+ {
+ // Rekursion
+ bDelAll = sal_False;
+ }
+ }
+ else
+ {
+ if(pObj->GetLayer() != nDelID)
+ {
+ bDelAll = sal_False;
+ }
+ }
+ }
+
+ return bDelAll;
+}
+
+void SdrEditView::ImpDelLayerDelObjs(SdrObjList* pOL, SdrLayerID nDelID)
+{
+ sal_uInt32 nObjAnz(pOL->GetObjCount());
+ // make sure OrdNums are correct
+ pOL->GetObj(0)->GetOrdNum();
+
+ const bool bUndo = GetModel()->IsUndoEnabled();
+
+ for(sal_uInt32 nObjNum(nObjAnz); nObjNum > 0;)
+ {
+ nObjNum--;
+ SdrObject* pObj = pOL->GetObj(nObjNum);
+ SdrObjList* pSubOL = pObj->GetSubList();
+
+
+ // #104809# Test explicitely for group objects and 3d scenes
+ if(pSubOL && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dScene)))
+ {
+ if(ImpDelLayerCheck(pSubOL, nDelID))
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
+ pOL->RemoveObject(nObjNum);
+
+ if( !bUndo )
+ SdrObject::Free( pObj );
+ }
+ else
+ {
+ ImpDelLayerDelObjs(pSubOL, nDelID);
+ }
+ }
+ else
+ {
+ if(pObj->GetLayer() == nDelID)
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
+ pOL->RemoveObject(nObjNum);
+ if( !bUndo )
+ SdrObject::Free( pObj );
+ }
+ }
+ }
+}
+
+void SdrEditView::DeleteLayer(const XubString& rName)
+{
+ SdrLayerAdmin& rLA = pMod->GetLayerAdmin();
+ SdrLayer* pLayer = rLA.GetLayer(rName, TRUE);
+ sal_uInt16 nLayerNum(rLA.GetLayerPos(pLayer));
+
+ if(SDRLAYER_NOTFOUND != nLayerNum)
+ {
+
+ SdrLayerID nDelID = pLayer->GetID();
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_UndoDelLayer));
+
+ sal_Bool bMaPg(sal_True);
+
+ for(sal_uInt16 nPageKind(0); nPageKind < 2; nPageKind++)
+ {
+ // MasterPages and DrawPages
+ sal_uInt16 nPgAnz(bMaPg ? pMod->GetMasterPageCount() : pMod->GetPageCount());
+
+ for(sal_uInt16 nPgNum(0); nPgNum < nPgAnz; nPgNum++)
+ {
+ // over all pages
+ SdrPage* pPage = (bMaPg) ? pMod->GetMasterPage(nPgNum) : pMod->GetPage(nPgNum);
+ sal_uInt32 nObjAnz(pPage->GetObjCount());
+
+ // make sure OrdNums are correct
+ if(nObjAnz)
+ pPage->GetObj(0)->GetOrdNum();
+
+ for(sal_uInt32 nObjNum(nObjAnz); nObjNum > 0;)
+ {
+ nObjNum--;
+ SdrObject* pObj = pPage->GetObj(nObjNum);
+ SdrObjList* pSubOL = pObj->GetSubList();
+
+ // #104809# Test explicitely for group objects and 3d scenes
+ if(pSubOL && (pObj->ISA(SdrObjGroup) || pObj->ISA(E3dScene)))
+ {
+ if(ImpDelLayerCheck(pSubOL, nDelID))
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
+ pPage->RemoveObject(nObjNum);
+ if( !bUndo )
+ SdrObject::Free(pObj);
+ }
+ else
+ {
+ ImpDelLayerDelObjs(pSubOL, nDelID);
+ }
+ }
+ else
+ {
+ if(pObj->GetLayer() == nDelID)
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj, true));
+ pPage->RemoveObject(nObjNum);
+ if( !bUndo )
+ SdrObject::Free(pObj);
+ }
+ }
+ }
+ }
+ bMaPg = sal_False;
+ }
+
+ if( bUndo )
+ {
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteLayer(nLayerNum, rLA, *pMod));
+ rLA.RemoveLayer(nLayerNum);
+ EndUndo();
+ }
+ else
+ {
+ delete rLA.RemoveLayer(nLayerNum);
+ }
+
+ pMod->SetChanged();
+ }
+}
+
+void SdrEditView::MoveLayer(const XubString& rName, USHORT nNewPos)
+{
+ SdrLayerAdmin& rLA=pMod->GetLayerAdmin();
+ SdrLayer* pLayer=rLA.GetLayer(rName,TRUE);
+ USHORT nLayerNum=rLA.GetLayerPos(pLayer);
+ if (nLayerNum!=SDRLAYER_NOTFOUND)
+ {
+ if( IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveLayer(nLayerNum,rLA,*pMod,nNewPos));
+ rLA.MoveLayer(nLayerNum,nNewPos);
+ pMod->SetChanged();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::EndUndo()
+{
+ // #i13033#
+ // Comparison changed to 1L since EndUndo() is called later now
+ // and EndUndo WILL change count to count-1
+ if(1L == pMod->GetUndoBracketLevel())
+ {
+ ImpBroadcastEdgesOfMarkedNodes();
+ }
+
+ // #i13033#
+ // moved to bottom to still have access to UNDOs inside of
+ // ImpBroadcastEdgesOfMarkedNodes()
+ pMod->EndUndo();
+}
+
+void SdrEditView::ImpBroadcastEdgesOfMarkedNodes()
+{
+ const List& rAllMarkedObjects = GetTransitiveHullOfMarkedObjects();
+
+ // #i13033#
+ // New mechanism to search for necessary disconnections for
+ // changed connectors inside the transitive hull of all at
+ // the beginning of UNDO selected objects
+ for(sal_uInt32 a(0L); a < rAllMarkedObjects.Count(); a++)
+ {
+ SdrEdgeObj* pEdge = PTR_CAST(SdrEdgeObj, (SdrObject*)rAllMarkedObjects.GetObject(a));
+
+ if(pEdge)
+ {
+ SdrObject* pObj1 = pEdge->GetConnectedNode(sal_False);
+ SdrObject* pObj2 = pEdge->GetConnectedNode(sal_True);
+
+ if(pObj1
+ && LIST_ENTRY_NOTFOUND == rAllMarkedObjects.GetPos(pObj1)
+ && !pEdge->CheckNodeConnection(sal_False))
+ {
+ if( IsUndoEnabled() )
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge));
+ pEdge->DisconnectFromNode(sal_False);
+ }
+
+ if(pObj2
+ && LIST_ENTRY_NOTFOUND == rAllMarkedObjects.GetPos(pObj2)
+ && !pEdge->CheckNodeConnection(sal_True))
+ {
+ if( IsUndoEnabled() )
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pEdge));
+ pEdge->DisconnectFromNode(sal_True);
+ }
+ }
+ }
+
+ ULONG nMarkedEdgeAnz = GetMarkedEdgesOfMarkedNodes().GetMarkCount();
+ USHORT i;
+
+ for (i=0; i<nMarkedEdgeAnz; i++) {
+ SdrMark* pEM = GetMarkedEdgesOfMarkedNodes().GetMark(i);
+ SdrObject* pEdgeTmp=pEM->GetMarkedSdrObj();
+ SdrEdgeObj* pEdge=PTR_CAST(SdrEdgeObj,pEdgeTmp);
+ if (pEdge!=NULL) {
+ pEdge->SetEdgeTrackDirty();
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// #### ### #### #### # #### # # # ##### # ##### ####
+// # # # # # # # # # # # # # # # #
+// #### # # ### ### # #### # # # # # #### ###
+// # # # # # # # # # # # # # # #
+// # ### #### #### # #### # #### # # # ##### ####
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::MarkListHasChanged()
+{
+ SdrMarkView::MarkListHasChanged();
+ bPossibilitiesDirty=TRUE;
+}
+
+void SdrEditView::ModelHasChanged()
+{
+ SdrMarkView::ModelHasChanged();
+ bPossibilitiesDirty=TRUE;
+}
+
+BOOL SdrEditView::IsResizeAllowed(BOOL bProp) const
+{
+ ForcePossibilities();
+ if (bResizeProtect) return FALSE;
+ if (bProp) return bResizePropAllowed;
+ return bResizeFreeAllowed;
+}
+
+BOOL SdrEditView::IsRotateAllowed(BOOL b90Deg) const
+{
+ ForcePossibilities();
+ if (bMoveProtect) return FALSE;
+ if (b90Deg) return bRotate90Allowed;
+ return bRotateFreeAllowed;
+}
+
+BOOL SdrEditView::IsMirrorAllowed(BOOL b45Deg, BOOL b90Deg) const
+{
+ ForcePossibilities();
+ if (bMoveProtect) return FALSE;
+ if (b90Deg) return bMirror90Allowed;
+ if (b45Deg) return bMirror45Allowed;
+ return bMirrorFreeAllowed && !bMoveProtect;
+}
+
+BOOL SdrEditView::IsTransparenceAllowed() const
+{
+ ForcePossibilities();
+ return bTransparenceAllowed;
+}
+
+BOOL SdrEditView::IsGradientAllowed() const
+{
+ ForcePossibilities();
+ return bGradientAllowed;
+}
+
+BOOL SdrEditView::IsShearAllowed() const
+{
+ ForcePossibilities();
+ if (bResizeProtect) return FALSE;
+ return bShearAllowed;
+}
+
+BOOL SdrEditView::IsEdgeRadiusAllowed() const
+{
+ ForcePossibilities();
+ return bEdgeRadiusAllowed;
+}
+
+BOOL SdrEditView::IsCrookAllowed(BOOL bNoContortion) const
+{
+ // CrookMode fehlt hier (weil kein Rotate bei Shear ...)
+ ForcePossibilities();
+ if (bNoContortion) {
+ if (!bRotateFreeAllowed) return FALSE; // Crook is nich
+ return !bMoveProtect && bMoveAllowed;
+ } else {
+ return !bResizeProtect && bContortionPossible;
+ }
+}
+
+BOOL SdrEditView::IsDistortAllowed(BOOL bNoContortion) const
+{
+ ForcePossibilities();
+ if (bNoContortion) {
+ return FALSE;
+ } else {
+ return !bResizeProtect && bContortionPossible;
+ }
+}
+
+BOOL SdrEditView::IsCombinePossible(BOOL bNoPolyPoly) const
+{
+ ForcePossibilities();
+ if (bNoPolyPoly) return bCombineNoPolyPolyPossible;
+ else return bCombinePossible;
+}
+
+BOOL SdrEditView::IsDismantlePossible(BOOL bMakeLines) const
+{
+ ForcePossibilities();
+ if (bMakeLines) return bDismantleMakeLinesPossible;
+ else return bDismantlePossible;
+}
+
+void SdrEditView::CheckPossibilities()
+{
+ if (bSomeObjChgdFlag) bPossibilitiesDirty=TRUE;
+
+ if(bSomeObjChgdFlag)
+ {
+ // This call IS necessary to correct the MarkList, in which
+ // no longer to the model belonging objects still can reside.
+ // These ones nned to be removed.
+ CheckMarked();
+ }
+
+ if (bPossibilitiesDirty) {
+ ImpResetPossibilityFlags();
+ SortMarkedObjects();
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ if (nMarkAnz!=0) {
+ bReverseOrderPossible=nMarkAnz>=2;
+
+ ULONG nMovableCount=0;
+ bGroupPossible=nMarkAnz>=2;
+ bCombinePossible=nMarkAnz>=2;
+ if (nMarkAnz==1) {
+ // bCombinePossible gruendlicher checken
+ // fehlt noch ...
+ const SdrObject* pObj=GetMarkedObjectByIndex(0);
+ //const SdrPathObj* pPath=PTR_CAST(SdrPathObj,pObj);
+ BOOL bGroup=pObj->GetSubList()!=NULL;
+ BOOL bHasText=pObj->GetOutlinerParaObject()!=NULL;
+ if (bGroup || bHasText) {
+ bCombinePossible=TRUE;
+ }
+ }
+ bCombineNoPolyPolyPossible=bCombinePossible;
+ bDeletePossible=TRUE;
+ // Zu den Transformationen erstmal ja sagen
+ bMoveAllowed =TRUE;
+ bResizeFreeAllowed=TRUE;
+ bResizePropAllowed=TRUE;
+ bRotateFreeAllowed=TRUE;
+ bRotate90Allowed =TRUE;
+ bMirrorFreeAllowed=TRUE;
+ bMirror45Allowed =TRUE;
+ bMirror90Allowed =TRUE;
+ bShearAllowed =TRUE;
+ bEdgeRadiusAllowed=FALSE;
+ bContortionPossible=TRUE;
+ bCanConvToContour = TRUE;
+
+ // these ones are only allowed when single object is selected
+ bTransparenceAllowed = (nMarkAnz == 1);
+ bGradientAllowed = (nMarkAnz == 1);
+ if(bGradientAllowed)
+ {
+ // gradient depends on fillstyle
+ const SdrMark* pM = GetSdrMarkByIndex(0);
+ const SdrObject* pObj = pM->GetMarkedSdrObj();
+
+ // maybe group object, so get merged ItemSet
+ const SfxItemSet& rSet = pObj->GetMergedItemSet();
+ SfxItemState eState = rSet.GetItemState(XATTR_FILLSTYLE, FALSE);
+
+ if(SFX_ITEM_DONTCARE != eState)
+ {
+ // If state is not DONTCARE, test the item
+ XFillStyle eFillStyle = ((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue();
+
+ if(eFillStyle != XFILL_GRADIENT)
+ {
+ bGradientAllowed = FALSE;
+ }
+ }
+ }
+
+ BOOL bNoMovRotFound=FALSE;
+ const SdrPageView* pPV0=NULL;
+
+ for (ULONG nm=0; nm<nMarkAnz; nm++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nm);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ const SdrPageView* pPV=pM->GetPageView();
+ if (pPV!=pPV0) {
+ if (pPV->IsReadOnly()) bReadOnly=TRUE;
+ pPV0=pPV;
+ }
+
+ SdrObjTransformInfoRec aInfo;
+ pObj->TakeObjInfo(aInfo);
+ BOOL bMovPrt=pObj->IsMoveProtect();
+ BOOL bSizPrt=pObj->IsResizeProtect();
+ if (!bMovPrt && aInfo.bMoveAllowed) nMovableCount++; // Menge der MovableObjs zaehlen
+ if (bMovPrt) bMoveProtect=TRUE;
+ if (bSizPrt) bResizeProtect=TRUE;
+
+ // not allowed when not allowed at one object
+ if(!aInfo.bTransparenceAllowed)
+ bTransparenceAllowed = FALSE;
+
+ // Wenn einer was nicht kann, duerfen's alle nicht
+ if (!aInfo.bMoveAllowed ) bMoveAllowed =FALSE;
+ if (!aInfo.bResizeFreeAllowed) bResizeFreeAllowed=FALSE;
+ if (!aInfo.bResizePropAllowed) bResizePropAllowed=FALSE;
+ if (!aInfo.bRotateFreeAllowed) bRotateFreeAllowed=FALSE;
+ if (!aInfo.bRotate90Allowed ) bRotate90Allowed =FALSE;
+ if (!aInfo.bMirrorFreeAllowed) bMirrorFreeAllowed=FALSE;
+ if (!aInfo.bMirror45Allowed ) bMirror45Allowed =FALSE;
+ if (!aInfo.bMirror90Allowed ) bMirror90Allowed =FALSE;
+ if (!aInfo.bShearAllowed ) bShearAllowed =FALSE;
+ if (aInfo.bEdgeRadiusAllowed) bEdgeRadiusAllowed=TRUE;
+ if (aInfo.bNoContortion ) bContortionPossible=FALSE;
+ // Fuer Crook mit Contortion: Alle Objekte muessen
+ // Movable und Rotatable sein, ausser maximal 1
+ if (!bMoreThanOneNoMovRot) {
+ if (!aInfo.bMoveAllowed || !aInfo.bResizeFreeAllowed) {
+ bMoreThanOneNoMovRot=bNoMovRotFound;
+ bNoMovRotFound=TRUE;
+ }
+ }
+
+ // when one member cannot be converted, no conversion is possible
+ if(!aInfo.bCanConvToContour)
+ bCanConvToContour = FALSE;
+
+ // Ungroup
+ if (!bUnGroupPossible) bUnGroupPossible=pObj->GetSubList()!=NULL;
+ // ConvertToCurve: Wenn mind. einer konvertiert werden kann ist das ok.
+ if (aInfo.bCanConvToPath ) bCanConvToPath =TRUE;
+ if (aInfo.bCanConvToPoly ) bCanConvToPoly =TRUE;
+ if (aInfo.bCanConvToPathLineToArea) bCanConvToPathLineToArea=TRUE;
+ if (aInfo.bCanConvToPolyLineToArea) bCanConvToPolyLineToArea=TRUE;
+
+ // Combine/Dismantle
+ if(bCombinePossible)
+ {
+ bCombinePossible = ImpCanConvertForCombine(pObj);
+ bCombineNoPolyPolyPossible = bCombinePossible;
+ }
+
+ if (!bDismantlePossible) bDismantlePossible = ImpCanDismantle(pObj, sal_False);
+ if (!bDismantleMakeLinesPossible) bDismantleMakeLinesPossible = ImpCanDismantle(pObj, sal_True);
+ // OrthoDesiredOnMarked checken
+ if (!bOrthoDesiredOnMarked && !aInfo.bNoOrthoDesired) bOrthoDesiredOnMarked=TRUE;
+ // ImportMtf checken
+
+ if (!bImportMtfPossible) {
+ BOOL bGraf=HAS_BASE(SdrGrafObj,pObj);
+ BOOL bOle2=HAS_BASE(SdrOle2Obj,pObj);
+
+ if( bGraf && ((SdrGrafObj*)pObj)->HasGDIMetaFile() && !((SdrGrafObj*)pObj)->IsEPS() )
+ bImportMtfPossible = TRUE;
+
+ if (bOle2)
+ bImportMtfPossible=((SdrOle2Obj*)pObj)->GetObjRef().is();
+ }
+ }
+
+ bMoreThanOneNotMovable=nMovableCount<nMarkAnz-1;
+ bOneOrMoreMovable=nMovableCount!=0;
+ bGrpEnterPossible=bUnGroupPossible;
+ }
+ ImpCheckToTopBtmPossible();
+ ((SdrPolyEditView*)this)->ImpCheckPolyPossibilities();
+ bPossibilitiesDirty=FALSE;
+
+ if (bReadOnly) {
+ BOOL bMerker1=bGrpEnterPossible;
+ ImpResetPossibilityFlags();
+ bReadOnly=TRUE;
+ bGrpEnterPossible=bMerker1;
+ }
+ if (bMoveAllowed) {
+ // Verschieben von angeklebten Verbindern unterbinden
+ // Derzeit nur fuer Einfachselektion implementiert.
+ if (nMarkAnz==1) {
+ SdrObject* pObj=GetMarkedObjectByIndex(0);
+ SdrEdgeObj* pEdge=PTR_CAST(SdrEdgeObj,pObj);
+ if (pEdge!=NULL) {
+ SdrObject* pNode1=pEdge->GetConnectedNode(TRUE);
+ SdrObject* pNode2=pEdge->GetConnectedNode(FALSE);
+ if (pNode1!=NULL || pNode2!=NULL) bMoveAllowed=FALSE;
+ }
+ }
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::ForceMarkedObjToAnotherPage()
+{
+ BOOL bFlg=FALSE;
+ for (ULONG nm=0; nm<GetMarkedObjectCount(); nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ Rectangle aObjRect(pObj->GetCurrentBoundRect());
+ Rectangle aPgRect(pM->GetPageView()->GetPageRect());
+ if (!aObjRect.IsOver(aPgRect)) {
+ BOOL bFnd=FALSE;
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ bFnd = aObjRect.IsOver(pPV->GetPageRect());
+ }
+
+ if(bFnd)
+ {
+ pM->GetPageView()->GetObjList()->RemoveObject(pObj->GetOrdNum());
+ SdrInsertReason aReason(SDRREASON_VIEWCALL);
+ pPV->GetObjList()->InsertObject(pObj,CONTAINER_APPEND,&aReason);
+ pM->SetPageView(pPV);
+ InvalidateAllWin(aObjRect);
+ bFlg=TRUE;
+ }
+ }
+ }
+ if (bFlg) {
+ MarkListHasChanged();
+ }
+}
+
+void SdrEditView::DeleteMarkedList(const SdrMarkList& rMark)
+{
+ if (rMark.GetMarkCount()!=0)
+ {
+ rMark.ForceSort();
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo();
+ const sal_uInt32 nMarkAnz(rMark.GetMarkCount());
+
+ if(nMarkAnz)
+ {
+ sal_uInt32 nm(0);
+ std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
+
+ if( bUndo )
+ {
+ for(nm = nMarkAnz; nm > 0;)
+ {
+ nm--;
+ SdrMark* pM = rMark.GetMark(nm);
+ SdrObject* pObj = pM->GetMarkedSdrObj();
+
+ // extra undo actions for changed connector which now may hold it's layouted path (SJ)
+ std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pObj ) );
+ AddUndoActions( vConnectorUndoActions );
+
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
+ }
+ }
+
+ // Sicherstellen, dass die OrderNums stimmen:
+ rMark.GetMark(0)->GetMarkedSdrObj()->GetOrdNum();
+
+ std::vector< SdrObject* > aRemoved3DObjects;
+
+ for(nm = nMarkAnz; nm > 0;)
+ {
+ nm--;
+ SdrMark* pM = rMark.GetMark(nm);
+ SdrObject* pObj = pM->GetMarkedSdrObj();
+ SdrObjList* pOL = pObj->GetObjList(); //#52680#
+ const sal_uInt32 nOrdNum(pObj->GetOrdNumDirect());
+
+ bool bIs3D = dynamic_cast< E3dObject* >(pObj);
+ // set up a scene updater if object is a 3d object
+ if(bIs3D)
+ {
+ aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pObj));
+ }
+
+ pOL->RemoveObject(nOrdNum);
+
+ if( !bUndo )
+ {
+ if( bIs3D )
+ aRemoved3DObjects.push_back( pObj ); // may be needed later
+ else
+ SdrObject::Free(pObj);
+ }
+ }
+
+ // fire scene updaters
+ while(aUpdaters.size())
+ {
+ delete aUpdaters.back();
+ aUpdaters.pop_back();
+ }
+
+ if( !bUndo )
+ {
+ // now delete removed scene objects
+ while(aRemoved3DObjects.size())
+ {
+ SdrObject::Free( aRemoved3DObjects.back() );
+ aRemoved3DObjects.pop_back();
+ }
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+ }
+}
+
+void SdrEditView::DeleteMarkedObj()
+{
+ // #i110981# return when nothing is to be done at all
+ if(!GetMarkedObjectCount())
+ {
+ return;
+ }
+
+ // moved breaking action and undo start outside loop
+ BrkAction();
+ BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_DELETE);
+
+ // remove as long as something is selected. This allows to schedule objects for
+ // removal for a next run as needed
+ while(GetMarkedObjectCount())
+ {
+ // vector to remember the parents which may be empty after object removal
+ std::vector< SdrObject* > aParents;
+
+ {
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ const sal_uInt32 nCount(rMarkList.GetMarkCount());
+ sal_uInt32 a(0);
+
+ for(a = 0; a < nCount; a++)
+ {
+ // in the first run, add all found parents, but only once
+ SdrMark* pMark = rMarkList.GetMark(a);
+ SdrObject* pObject = pMark->GetMarkedSdrObj();
+ SdrObject* pParent = pObject->GetObjList()->GetOwnerObj();
+
+ if(pParent)
+ {
+ if(aParents.size())
+ {
+ std::vector< SdrObject* >::iterator aFindResult =
+ std::find(aParents.begin(), aParents.end(), pParent);
+
+ if(aFindResult == aParents.end())
+ {
+ aParents.push_back(pParent);
+ }
+ }
+ else
+ {
+ aParents.push_back(pParent);
+ }
+ }
+ }
+
+ if(aParents.size())
+ {
+ // in a 2nd run, remove all objects which may already be scheduled for
+ // removal. I am not sure if this can happen, but theoretically
+ // a to-be-removed object may already be the group/3DScene itself
+ for(a = 0; a < nCount; a++)
+ {
+ SdrMark* pMark = rMarkList.GetMark(a);
+ SdrObject* pObject = pMark->GetMarkedSdrObj();
+
+ std::vector< SdrObject* >::iterator aFindResult =
+ std::find(aParents.begin(), aParents.end(), pObject);
+
+ if(aFindResult != aParents.end())
+ {
+ aParents.erase(aFindResult);
+ }
+ }
+ }
+ }
+
+ // original stuff: remove selected objects. Handle clear will
+ // do something only once
+ DeleteMarkedList(GetMarkedObjectList());
+ GetMarkedObjectListWriteAccess().Clear();
+ aHdl.Clear();
+
+ while(aParents.size() && !GetMarkedObjectCount())
+ {
+ // iterate over remembered parents
+ SdrObject* pParent = aParents.back();
+ aParents.pop_back();
+
+ if(pParent->GetSubList() && 0 == pParent->GetSubList()->GetObjCount())
+ {
+ // we detected an empty parent, a candidate to leave group/3DScene
+ // if entered
+ if(GetSdrPageView()->GetAktGroup()
+ && GetSdrPageView()->GetAktGroup() == pParent)
+ {
+ GetSdrPageView()->LeaveOneGroup();
+ }
+
+ // schedule empty parent for removal
+ GetMarkedObjectListWriteAccess().InsertEntry(
+ SdrMark(pParent, GetSdrPageView()));
+ }
+ }
+ }
+
+ // end undo and change messaging moved at the end
+ EndUndo();
+ MarkListHasChanged();
+}
+
+void SdrEditView::CopyMarkedObj()
+{
+ SortMarkedObjects();
+
+ SdrMarkList aSourceObjectsForCopy(GetMarkedObjectList());
+ // Folgende Schleife Anstatt MarkList::Merge(), damit
+ // ich jeweils mein Flag an die MarkEntries setzen kann.
+ ULONG nEdgeAnz = GetEdgesOfMarkedNodes().GetMarkCount();
+ for (ULONG nEdgeNum=0; nEdgeNum<nEdgeAnz; nEdgeNum++) {
+ SdrMark aM(*GetEdgesOfMarkedNodes().GetMark(nEdgeNum));
+ aM.SetUser(1);
+ aSourceObjectsForCopy.InsertEntry(aM);
+ }
+ aSourceObjectsForCopy.ForceSort();
+
+ // #i13033#
+ // New mechanism to re-create the connections of cloned connectors
+ CloneList aCloneList;
+
+ const bool bUndo = IsUndoEnabled();
+
+ GetMarkedObjectListWriteAccess().Clear();
+ ULONG nCloneErrCnt=0;
+ ULONG nMarkAnz=aSourceObjectsForCopy.GetMarkCount();
+ ULONG nm;
+ for (nm=0; nm<nMarkAnz; nm++) {
+ SdrMark* pM=aSourceObjectsForCopy.GetMark(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj()->Clone();
+ if (pO!=NULL) {
+ SdrInsertReason aReason(SDRREASON_VIEWCALL);
+ pM->GetPageView()->GetObjList()->InsertObject(pO,CONTAINER_APPEND,&aReason);
+
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoCopyObject(*pO));
+
+ SdrMark aME(*pM);
+ aME.SetMarkedSdrObj(pO);
+ aCloneList.AddPair(pM->GetMarkedSdrObj(), pO);
+
+ if (pM->GetUser()==0)
+ {
+ // Sonst war's nur eine mitzukierende Edge
+ GetMarkedObjectListWriteAccess().InsertEntry(aME);
+ }
+ } else {
+ nCloneErrCnt++;
+ }
+ }
+
+ // #i13033#
+ // New mechanism to re-create the connections of cloned connectors
+ aCloneList.CopyConnections();
+
+ if(0L != nCloneErrCnt)
+ {
+#ifdef DBG_UTIL
+ ByteString aStr("SdrEditView::CopyMarkedObj(): Fehler beim Clonen ");
+
+ if(nCloneErrCnt == 1)
+ {
+ aStr += "eines Zeichenobjekts.";
+ }
+ else
+ {
+ aStr += "von ";
+ aStr += ByteString::CreateFromInt32( nCloneErrCnt );
+ aStr += " Zeichenobjekten.";
+ }
+
+ aStr += " Objektverbindungen werden nicht mitkopiert.";
+ DBG_ERROR(aStr.GetBuffer());
+#endif
+ }
+ MarkListHasChanged();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, ULONG nOptions)
+{
+ if ((nOptions & SDRINSERT_SETDEFLAYER)!=0) {
+ SdrLayerID nLayer=rPV.GetPage()->GetLayerAdmin().GetLayerID(aAktLayer,TRUE);
+ if (nLayer==SDRLAYER_NOTFOUND) nLayer=0;
+ if (rPV.GetLockedLayers().IsSet(nLayer) || !rPV.GetVisibleLayers().IsSet(nLayer)) {
+ SdrObject::Free( pObj ); // Layer gesperrt oder nicht sichtbar
+ return FALSE;
+ }
+ pObj->NbcSetLayer(nLayer);
+ }
+ if ((nOptions & SDRINSERT_SETDEFATTR)!=0) {
+ if (pDefaultStyleSheet!=NULL) pObj->NbcSetStyleSheet(pDefaultStyleSheet, sal_False);
+ pObj->SetMergedItemSet(aDefaultAttr);
+ }
+ if (!pObj->IsInserted()) {
+ SdrInsertReason aReason(SDRREASON_VIEWCALL);
+ if ((nOptions & SDRINSERT_NOBROADCAST)!=0) {
+ rPV.GetObjList()->NbcInsertObject(pObj,CONTAINER_APPEND,&aReason);
+ } else {
+ rPV.GetObjList()->InsertObject(pObj,CONTAINER_APPEND,&aReason);
+ }
+ }
+ if( IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
+
+ if ((nOptions & SDRINSERT_DONTMARK)==0) {
+ if ((nOptions & SDRINSERT_ADDMARK)==0) UnmarkAllObj();
+ MarkObj(pObj,&rPV);
+ }
+ return TRUE;
+}
+
+void SdrEditView::ReplaceObjectAtView(SdrObject* pOldObj, SdrPageView& rPV, SdrObject* pNewObj, BOOL bMark)
+{
+ SdrObjList* pOL=pOldObj->GetObjList();
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pOldObj,*pNewObj));
+
+ if( IsObjMarked( pOldObj ) )
+ MarkObj( pOldObj, &rPV, TRUE /*unmark!*/ );
+
+ pOL->ReplaceObject(pNewObj,pOldObj->GetOrdNum());
+
+ if( !bUndo )
+ SdrObject::Free( pOldObj );
+
+ if (bMark) MarkObj(pNewObj,&rPV);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef WIN
+void SdrEditView::BegUndo() // Undo-Klammerung auf
+{
+ pMod->BegUndo();
+}
+
+void SdrEditView::BegUndo(const String& rComment) // Undo-Klammerung auf
+{
+ pMod->BegUndo(rComment);
+}
+
+void SdrEditView::BegUndo(const String& rComment, const String& rObjDescr,
+ SdrRepeatFunc eFunc) // Undo-Klammerung auf
+{
+ pMod->BegUndo(rComment,rObjDescr,eFunc);
+}
+
+void SdrEditView::BegUndo(SdrUndoGroup* pUndoGrp) // Undo-Klammerung auf
+{
+ pMod->BegUndo(pUndoGrp);
+}
+
+void SdrEditView::AddUndo(SdrUndoAction* pUndo) // Action hinzufuegen
+{
+ pMod->AddUndo(pUndo);
+}
+ // nur nach dem 1. BegUndo oder vor dem letzten EndUndo:
+void SdrEditView::SetUndoComment(const String& rComment)
+{
+ pMod->SetUndoComment(rComment);
+}
+
+
+void SdrEditView::SetUndoComment(const String& rComment,
+ const String& rObjDescr)
+{
+ pMod->SetUndoComment(rComment,rObjDescr);
+}
+#endif
+
+bool SdrEditView::IsUndoEnabled() const
+{
+ return pMod->IsUndoEnabled();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
new file mode 100644
index 000000000000..c545c3c4c6e8
--- /dev/null
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -0,0 +1,1772 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdedtv.hxx>
+#include <math.h>
+
+#ifndef _MATH_H
+#define _MATH_H
+#endif
+#include <tools/bigint.hxx>
+#include <svl/itemiter.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/rectenum.hxx>
+#include <svx/svxids.hrc> // fuer SID_ATTR_TRANSFORM_...
+#include <svx/svdattr.hxx> // fuer Get/SetGeoAttr
+#include "svditext.hxx"
+#include "svditer.hxx"
+#include <svx/svdtrans.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdlayer.hxx> // fuer MergeNotPersistAttr
+#include <svx/svdattrx.hxx> // fuer MergeNotPersistAttr
+#include <svx/svdetc.hxx> // fuer SearchOutlinerItems
+#include <svx/svdopath.hxx> // fuer Crook
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+#include <editeng/eeitem.hxx>
+#include <svl/aeitem.hxx>
+#include <svl/whiter.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/e3dsceneupdater.hxx>
+#include <svx/obj3d.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@ @@@@@ @@ @@@@@@ @@ @@ @@ @@@@@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
+// @@@@ @@ @@ @@ @@ @@@@@ @@ @@@@ @@@@@@@
+// @@ @@ @@ @@ @@ @@@ @@ @@ @@@@@@@
+// @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
+// @@@@@ @@@@@ @@ @@ @ @@ @@@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::SetMarkedObjRect(const Rectangle& rRect, BOOL bCopy)
+{
+ DBG_ASSERT(!rRect.IsEmpty(),"SetMarkedObjRect() mit leerem Rect mach keinen Sinn");
+ if (rRect.IsEmpty()) return;
+ ULONG nAnz=GetMarkedObjectCount();
+ if (nAnz==0) return;
+ Rectangle aR0(GetMarkedObjRect());
+ DBG_ASSERT(!aR0.IsEmpty(),"SetMarkedObjRect(): GetMarkedObjRect() ist leer");
+ if (aR0.IsEmpty()) return;
+ long x0=aR0.Left();
+ long y0=aR0.Top();
+ long w0=aR0.Right()-x0;
+ long h0=aR0.Bottom()-y0;
+ long x1=rRect.Left();
+ long y1=rRect.Top();
+ long w1=rRect.Right()-x1;
+ long h1=rRect.Bottom()-y1;
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditPosSize,aStr);
+ if (bCopy)
+ aStr+=ImpGetResStr(STR_EditWithCopy);
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo(aStr);
+
+ if (bCopy)
+ CopyMarkedObj();
+
+ for (ULONG nm=0; nm<nAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ if( bUndo )
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
+
+ Rectangle aR1(pO->GetSnapRect());
+ if (!aR1.IsEmpty())
+ {
+ if (aR1==aR0)
+ {
+ aR1=rRect;
+ }
+ else
+ { // aR1 von aR0 nach rRect transformieren
+ aR1.Move(-x0,-y0);
+ BigInt l(aR1.Left());
+ BigInt r(aR1.Right());
+ BigInt t(aR1.Top());
+ BigInt b(aR1.Bottom());
+ if (w0!=0) {
+ l*=w1; l/=w0;
+ r*=w1; r/=w0;
+ } else {
+ l=0; r=w1;
+ }
+ if (h0!=0) {
+ t*=h1; t/=h0;
+ b*=h1; b/=h0;
+ } else {
+ t=0; b=h1;
+ }
+ aR1.Left ()=long(l);
+ aR1.Right ()=long(r);
+ aR1.Top ()=long(t);
+ aR1.Bottom()=long(b);
+ aR1.Move(x1,y1);
+ }
+ pO->SetSnapRect(aR1);
+ } else {
+ DBG_ERROR("SetMarkedObjRect(): pObj->GetSnapRect() liefert leeres Rect");
+ }
+ }
+ if( bUndo )
+ EndUndo();
+}
+
+std::vector< SdrUndoAction* > SdrEditView::CreateConnectorUndo( SdrObject& rO )
+{
+ std::vector< SdrUndoAction* > vUndoActions;
+
+ if ( rO.GetBroadcaster() )
+ {
+ const SdrPage* pPage = rO.GetPage();
+ if ( pPage )
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
+ while( aIter.IsMore() )
+ {
+ SdrObject* pPartObj = aIter.Next();
+ if ( pPartObj->ISA( SdrEdgeObj ) )
+ {
+ if ( ( pPartObj->GetConnectedNode( sal_False ) == &rO ) ||
+ ( pPartObj->GetConnectedNode( sal_True ) == &rO ) )
+ {
+ vUndoActions.push_back( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pPartObj ) );
+ }
+ }
+ }
+ }
+ }
+ return vUndoActions;
+}
+
+void SdrEditView::AddUndoActions( std::vector< SdrUndoAction* >& rUndoActions )
+{
+ std::vector< SdrUndoAction* >::iterator aUndoActionIter( rUndoActions.begin() );
+ while( aUndoActionIter != rUndoActions.end() )
+ AddUndo( *aUndoActionIter++ );
+}
+
+void SdrEditView::MoveMarkedObj(const Size& rSiz, bool bCopy)
+{
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString aStr(ImpGetResStr(STR_EditMove));
+ if (bCopy)
+ aStr+=ImpGetResStr(STR_EditWithCopy);
+ // benoetigt eigene UndoGroup wegen Parameter
+ BegUndo(aStr,GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVE);
+ }
+
+ if (bCopy)
+ CopyMarkedObj();
+
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ if( bUndo )
+ {
+ std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
+ AddUndoActions( vConnectorUndoActions );
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pO,rSiz));
+ }
+ pO->Move(rSiz);
+ }
+
+ if( bUndo )
+ EndUndo();
+}
+
+void SdrEditView::ResizeMarkedObj(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy)
+{
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditResize,aStr);
+ if (bCopy)
+ aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr);
+ }
+
+ if (bCopy)
+ CopyMarkedObj();
+
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ if( bUndo )
+ {
+ std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
+ AddUndoActions( vConnectorUndoActions );
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
+ }
+ pO->Resize(rRef,xFact,yFact);
+ }
+
+ if( bUndo )
+ EndUndo();
+}
+
+long SdrEditView::GetMarkedObjRotate() const
+{
+ BOOL b1st=TRUE;
+ BOOL bOk=TRUE;
+ long nWink=0;
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz && bOk; nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ long nWink2=pO->GetRotateAngle();
+ if (b1st) nWink=nWink2;
+ else if (nWink2!=nWink) bOk=FALSE;
+ b1st=FALSE;
+ }
+ if (!bOk) nWink=0;
+ return nWink;
+}
+
+void SdrEditView::RotateMarkedObj(const Point& rRef, long nWink, bool bCopy)
+{
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditRotate,aStr);
+ if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr);
+ }
+
+ if (bCopy)
+ CopyMarkedObj();
+
+ double nSin=sin(nWink*nPi180);
+ double nCos=cos(nWink*nPi180);
+ const sal_uInt32 nMarkAnz(GetMarkedObjectCount());
+
+ if(nMarkAnz)
+ {
+ std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
+
+ for(sal_uInt32 nm(0); nm < nMarkAnz; nm++)
+ {
+ SdrMark* pM = GetSdrMarkByIndex(nm);
+ SdrObject* pO = pM->GetMarkedSdrObj();
+
+ if( bUndo )
+ {
+ // extra undo actions for changed connector which now may hold it's layouted path (SJ)
+ std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
+ AddUndoActions( vConnectorUndoActions );
+
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
+ }
+
+ // set up a scene updater if object is a 3d object
+ if(dynamic_cast< E3dObject* >(pO))
+ {
+ aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pO));
+ }
+
+ pO->Rotate(rRef,nWink,nSin,nCos);
+ }
+
+ // fire scene updaters
+ while(aUpdaters.size())
+ {
+ delete aUpdaters.back();
+ aUpdaters.pop_back();
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+}
+
+void SdrEditView::MirrorMarkedObj(const Point& rRef1, const Point& rRef2, bool bCopy)
+{
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString aStr;
+ Point aDif(rRef2-rRef1);
+ if (aDif.X()==0) ImpTakeDescriptionStr(STR_EditMirrorHori,aStr);
+ else if (aDif.Y()==0) ImpTakeDescriptionStr(STR_EditMirrorVert,aStr);
+ else if (Abs(aDif.X())==Abs(aDif.Y())) ImpTakeDescriptionStr(STR_EditMirrorDiag,aStr);
+ else ImpTakeDescriptionStr(STR_EditMirrorFree,aStr);
+ if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr);
+ }
+
+ if (bCopy)
+ CopyMarkedObj();
+
+ const sal_uInt32 nMarkAnz(GetMarkedObjectCount());
+
+ if(nMarkAnz)
+ {
+ std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
+
+ for(sal_uInt32 nm(0); nm < nMarkAnz; nm++)
+ {
+ SdrMark* pM = GetSdrMarkByIndex(nm);
+ SdrObject* pO = pM->GetMarkedSdrObj();
+
+ if( bUndo )
+ {
+ // extra undo actions for changed connector which now may hold it's layouted path (SJ)
+ std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
+ AddUndoActions( vConnectorUndoActions );
+
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
+ }
+
+ // set up a scene updater if object is a 3d object
+ if(dynamic_cast< E3dObject* >(pO))
+ {
+ aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pO));
+ }
+
+ pO->Mirror(rRef1,rRef2);
+ }
+
+ // fire scene updaters
+ while(aUpdaters.size())
+ {
+ delete aUpdaters.back();
+ aUpdaters.pop_back();
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+}
+
+void SdrEditView::MirrorMarkedObjHorizontal(BOOL bCopy)
+{
+ Point aCenter(GetMarkedObjRect().Center());
+ Point aPt2(aCenter);
+ aPt2.Y()++;
+ MirrorMarkedObj(aCenter,aPt2,bCopy);
+}
+
+void SdrEditView::MirrorMarkedObjVertical(BOOL bCopy)
+{
+ Point aCenter(GetMarkedObjRect().Center());
+ Point aPt2(aCenter);
+ aPt2.X()++;
+ MirrorMarkedObj(aCenter,aPt2,bCopy);
+}
+
+long SdrEditView::GetMarkedObjShear() const
+{
+ BOOL b1st=TRUE;
+ BOOL bOk=TRUE;
+ long nWink=0;
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz && bOk; nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ long nWink2=pO->GetShearAngle();
+ if (b1st) nWink=nWink2;
+ else if (nWink2!=nWink) bOk=FALSE;
+ b1st=FALSE;
+ }
+ if (nWink>SDRMAXSHEAR) nWink=SDRMAXSHEAR;
+ if (nWink<-SDRMAXSHEAR) nWink=-SDRMAXSHEAR;
+ if (!bOk) nWink=0;
+ return nWink;
+}
+
+void SdrEditView::ShearMarkedObj(const Point& rRef, long nWink, bool bVShear, bool bCopy)
+{
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditShear,aStr);
+ if (bCopy)
+ aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr);
+ }
+
+ if (bCopy)
+ CopyMarkedObj();
+
+ double nTan=tan(nWink*nPi180);
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ if( bUndo )
+ {
+ std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pO ) );
+ AddUndoActions( vConnectorUndoActions );
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
+ }
+ pO->Shear(rRef,nWink,nTan,bVShear);
+ }
+
+ if( bUndo )
+ EndUndo();
+}
+
+void SdrEditView::ImpCrookObj(SdrObject* pO, const Point& rRef, const Point& rRad,
+ SdrCrookMode eMode, BOOL bVertical, BOOL bNoContortion, BOOL bRotate, const Rectangle& rMarkRect)
+{
+ SdrPathObj* pPath=PTR_CAST(SdrPathObj,pO);
+ BOOL bDone = FALSE;
+
+ if(pPath!=NULL && !bNoContortion)
+ {
+ XPolyPolygon aXPP(pPath->GetPathPoly());
+ switch (eMode) {
+ case SDRCROOK_ROTATE : CrookRotatePoly (aXPP,rRef,rRad,bVertical); break;
+ case SDRCROOK_SLANT : CrookSlantPoly (aXPP,rRef,rRad,bVertical); break;
+ case SDRCROOK_STRETCH: CrookStretchPoly(aXPP,rRef,rRad,bVertical,rMarkRect); break;
+ } // switch
+ pPath->SetPathPoly(aXPP.getB2DPolyPolygon());
+ bDone = TRUE;
+ }
+
+ if(!bDone && !pPath && pO->IsPolyObj() && 0L != pO->GetPointCount())
+ {
+ // FuerPolyObj's, aber NICHT fuer SdrPathObj's, z.B. fuer's Bemassungsobjekt
+ sal_uInt32 nPtAnz(pO->GetPointCount());
+ XPolygon aXP((sal_uInt16)nPtAnz);
+ sal_uInt32 nPtNum;
+
+ for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
+ {
+ Point aPt(pO->GetPoint(nPtNum));
+ aXP[(sal_uInt16)nPtNum]=aPt;
+ }
+
+ switch (eMode)
+ {
+ case SDRCROOK_ROTATE : CrookRotatePoly (aXP,rRef,rRad,bVertical); break;
+ case SDRCROOK_SLANT : CrookSlantPoly (aXP,rRef,rRad,bVertical); break;
+ case SDRCROOK_STRETCH: CrookStretchPoly(aXP,rRef,rRad,bVertical,rMarkRect); break;
+ }
+
+ for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
+ {
+ // hier koennte man vieleicht auch mal das Broadcasting optimieren
+ // ist aber z.Zt. bei den 2 Punkten des Bemassungsobjekts noch nicht so tragisch
+ pO->SetPoint(aXP[(sal_uInt16)nPtNum],nPtNum);
+ }
+
+ bDone = TRUE;
+ }
+
+ if(!bDone)
+ {
+ // Fuer alle anderen oder wenn bNoContortion
+ Point aCtr0(pO->GetSnapRect().Center());
+ Point aCtr1(aCtr0);
+ sal_Bool bRotOk(sal_False);
+ double nSin(0.0), nCos(1.0);
+ double nWink(0.0);
+
+ if(0 != rRad.X() && 0 != rRad.Y())
+ {
+ bRotOk = bRotate;
+
+ switch (eMode)
+ {
+ case SDRCROOK_ROTATE : nWink=CrookRotateXPoint (aCtr1,NULL,NULL,rRef,rRad,nSin,nCos,bVertical); bRotOk=bRotate; break;
+ case SDRCROOK_SLANT : nWink=CrookSlantXPoint (aCtr1,NULL,NULL,rRef,rRad,nSin,nCos,bVertical); break;
+ case SDRCROOK_STRETCH: nWink=CrookStretchXPoint(aCtr1,NULL,NULL,rRef,rRad,nSin,nCos,bVertical,rMarkRect); break;
+ }
+ }
+
+ aCtr1 -= aCtr0;
+
+ if(bRotOk)
+ pO->Rotate(aCtr0, Round(nWink/nPi180), nSin, nCos);
+
+ pO->Move(Size(aCtr1.X(),aCtr1.Y()));
+ }
+}
+
+void SdrEditView::CrookMarkedObj(const Point& rRef, const Point& rRad, SdrCrookMode eMode,
+ bool bVertical, bool bNoContortion, bool bCopy)
+{
+ Rectangle aMarkRect(GetMarkedObjRect());
+ const bool bUndo = IsUndoEnabled();
+
+ bool bRotate=bNoContortion && eMode==SDRCROOK_ROTATE && IsRotateAllowed(FALSE);
+
+ if( bUndo )
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(bNoContortion?STR_EditCrook:STR_EditCrookContortion,aStr);
+ if (bCopy)
+ aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr);
+ }
+
+ if (bCopy)
+ CopyMarkedObj();
+
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ if( bUndo )
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
+
+ const SdrObjList* pOL=pO->GetSubList();
+ if (bNoContortion || pOL==NULL) {
+ ImpCrookObj(pO,rRef,rRad,eMode,bVertical,bNoContortion,bRotate,aMarkRect);
+ } else {
+ SdrObjListIter aIter(*pOL,IM_DEEPNOGROUPS);
+ while (aIter.IsMore()) {
+ SdrObject* pO1=aIter.Next();
+ ImpCrookObj(pO1,rRef,rRad,eMode,bVertical,bNoContortion,bRotate,aMarkRect);
+ }
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+}
+
+void SdrEditView::ImpDistortObj(SdrObject* pO, const Rectangle& rRef, const XPolygon& rDistortedRect, BOOL bNoContortion)
+{
+ SdrPathObj* pPath = PTR_CAST(SdrPathObj, pO);
+
+ if(!bNoContortion && pPath)
+ {
+ XPolyPolygon aXPP(pPath->GetPathPoly());
+ aXPP.Distort(rRef, rDistortedRect);
+ pPath->SetPathPoly(aXPP.getB2DPolyPolygon());
+ }
+ else if(pO->IsPolyObj())
+ {
+ // z.B. fuer's Bemassungsobjekt
+ sal_uInt32 nPtAnz(pO->GetPointCount());
+ XPolygon aXP((sal_uInt16)nPtAnz);
+ sal_uInt32 nPtNum;
+
+ for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
+ {
+ Point aPt(pO->GetPoint(nPtNum));
+ aXP[(sal_uInt16)nPtNum]=aPt;
+ }
+
+ aXP.Distort(rRef, rDistortedRect);
+
+ for(nPtNum = 0L; nPtNum < nPtAnz; nPtNum++)
+ {
+ // hier koennte man vieleicht auch mal das Broadcasting optimieren
+ // ist aber z.Zt. bei den 2 Punkten des Bemassungsobjekts noch nicht so tragisch
+ pO->SetPoint(aXP[(sal_uInt16)nPtNum],nPtNum);
+ }
+ }
+}
+
+void SdrEditView::DistortMarkedObj(const Rectangle& rRef, const XPolygon& rDistortedRect, bool bNoContortion, bool bCopy)
+{
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditDistort,aStr);
+ if (bCopy)
+ aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr);
+ }
+
+ if (bCopy)
+ CopyMarkedObj();
+
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ if( bUndo )
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
+
+ Rectangle aRefRect(rRef);
+ XPolygon aRefPoly(rDistortedRect);
+ const SdrObjList* pOL=pO->GetSubList();
+ if (bNoContortion || pOL==NULL) {
+ ImpDistortObj(pO,aRefRect,aRefPoly,bNoContortion);
+ } else {
+ SdrObjListIter aIter(*pOL,IM_DEEPNOGROUPS);
+ while (aIter.IsMore()) {
+ SdrObject* pO1=aIter.Next();
+ ImpDistortObj(pO1,aRefRect,aRefPoly,bNoContortion);
+ }
+ }
+ }
+ if( bUndo )
+ EndUndo();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::SetNotPersistAttrToMarked(const SfxItemSet& rAttr, BOOL /*bReplaceAll*/)
+{
+ // bReplaceAll hat hier keinerlei Wirkung
+ Rectangle aAllSnapRect(GetMarkedObjRect());
+ const SfxPoolItem *pPoolItem=NULL;
+ if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1X,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrTransformRef1XItem*)pPoolItem)->GetValue();
+ SetRef1(Point(n,GetRef1().Y()));
+ }
+ if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1Y,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrTransformRef1YItem*)pPoolItem)->GetValue();
+ SetRef1(Point(GetRef1().X(),n));
+ }
+ if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2X,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrTransformRef2XItem*)pPoolItem)->GetValue();
+ SetRef2(Point(n,GetRef2().Y()));
+ }
+ if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2Y,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrTransformRef2YItem*)pPoolItem)->GetValue();
+ SetRef2(Point(GetRef2().X(),n));
+ }
+ long nAllPosX=0; BOOL bAllPosX=FALSE;
+ long nAllPosY=0; BOOL bAllPosY=FALSE;
+ long nAllWdt=0; BOOL bAllWdt=FALSE;
+ long nAllHgt=0; BOOL bAllHgt=FALSE;
+ BOOL bDoIt=FALSE;
+ if (rAttr.GetItemState(SDRATTR_ALLPOSITIONX,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ nAllPosX=((const SdrAllPositionXItem*)pPoolItem)->GetValue();
+ bAllPosX=TRUE; bDoIt=TRUE;
+ }
+ if (rAttr.GetItemState(SDRATTR_ALLPOSITIONY,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ nAllPosY=((const SdrAllPositionYItem*)pPoolItem)->GetValue();
+ bAllPosY=TRUE; bDoIt=TRUE;
+ }
+ if (rAttr.GetItemState(SDRATTR_ALLSIZEWIDTH,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ nAllWdt=((const SdrAllSizeWidthItem*)pPoolItem)->GetValue();
+ bAllWdt=TRUE; bDoIt=TRUE;
+ }
+ if (rAttr.GetItemState(SDRATTR_ALLSIZEHEIGHT,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ nAllHgt=((const SdrAllSizeHeightItem*)pPoolItem)->GetValue();
+ bAllHgt=TRUE; bDoIt=TRUE;
+ }
+ if (bDoIt) {
+ Rectangle aRect(aAllSnapRect); // !!! fuer PolyPt's und GluePt's aber bitte noch aendern !!!
+ if (bAllPosX) aRect.Move(nAllPosX-aRect.Left(),0);
+ if (bAllPosY) aRect.Move(0,nAllPosY-aRect.Top());
+ if (bAllWdt) aRect.Right()=aAllSnapRect.Left()+nAllWdt;
+ if (bAllHgt) aRect.Bottom()=aAllSnapRect.Top()+nAllHgt;
+ SetMarkedObjRect(aRect);
+ }
+ if (rAttr.GetItemState(SDRATTR_RESIZEXALL,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ Fraction aXFact=((const SdrResizeXAllItem*)pPoolItem)->GetValue();
+ ResizeMarkedObj(aAllSnapRect.TopLeft(),aXFact,Fraction(1,1));
+ }
+ if (rAttr.GetItemState(SDRATTR_RESIZEYALL,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ Fraction aYFact=((const SdrResizeYAllItem*)pPoolItem)->GetValue();
+ ResizeMarkedObj(aAllSnapRect.TopLeft(),Fraction(1,1),aYFact);
+ }
+ if (rAttr.GetItemState(SDRATTR_ROTATEALL,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long nAngle=((const SdrRotateAllItem*)pPoolItem)->GetValue();
+ RotateMarkedObj(aAllSnapRect.Center(),nAngle);
+ }
+ if (rAttr.GetItemState(SDRATTR_HORZSHEARALL,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long nAngle=((const SdrHorzShearAllItem*)pPoolItem)->GetValue();
+ ShearMarkedObj(aAllSnapRect.Center(),nAngle,FALSE);
+ }
+ if (rAttr.GetItemState(SDRATTR_VERTSHEARALL,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long nAngle=((const SdrVertShearAllItem*)pPoolItem)->GetValue();
+ ShearMarkedObj(aAllSnapRect.Center(),nAngle,TRUE);
+ }
+
+ const bool bUndo = IsUndoEnabled();
+
+ // Todo: WhichRange nach Notwendigkeit ueberpruefen.
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ const SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ //const SdrPageView* pPV=pM->GetPageView();
+ if( bUndo )
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
+
+ pObj->ApplyNotPersistAttr(rAttr);
+ }
+}
+
+void SdrEditView::MergeNotPersistAttrFromMarked(SfxItemSet& rAttr, BOOL /*bOnlyHardAttr*/) const
+{
+ // bOnlyHardAttr hat hier keinerlei Wirkung
+ // Hier muss ausserdem noch der Nullpunkt und
+ // die PvPos berueksichtigt werden.
+ Rectangle aAllSnapRect(GetMarkedObjRect()); // !!! fuer PolyPt's und GluePt's aber bitte noch aendern !!!
+ long nAllSnapPosX=aAllSnapRect.Left();
+ long nAllSnapPosY=aAllSnapRect.Top();
+ long nAllSnapWdt=aAllSnapRect.GetWidth()-1;
+ long nAllSnapHgt=aAllSnapRect.GetHeight()-1;
+ // koennte mal zu CheckPossibilities mit rein
+ BOOL bMovProtect=FALSE,bMovProtectDC=FALSE;
+ BOOL bSizProtect=FALSE,bSizProtectDC=FALSE;
+ BOOL bPrintable =TRUE ,bPrintableDC=FALSE;
+ BOOL bVisible = TRUE, bVisibleDC=FALSE;
+ SdrLayerID nLayerId=0; BOOL bLayerDC=FALSE;
+ XubString aObjName; BOOL bObjNameDC=FALSE,bObjNameSet=FALSE;
+ long nSnapPosX=0; BOOL bSnapPosXDC=FALSE;
+ long nSnapPosY=0; BOOL bSnapPosYDC=FALSE;
+ long nSnapWdt=0; BOOL bSnapWdtDC=FALSE;
+ long nSnapHgt=0; BOOL bSnapHgtDC=FALSE;
+ long nLogicWdt=0; BOOL bLogicWdtDC=FALSE,bLogicWdtDiff=FALSE;
+ long nLogicHgt=0; BOOL bLogicHgtDC=FALSE,bLogicHgtDiff=FALSE;
+ long nRotAngle=0; BOOL bRotAngleDC=FALSE;
+ long nShrAngle=0; BOOL bShrAngleDC=FALSE;
+ Rectangle aSnapRect;
+ Rectangle aLogicRect;
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nm);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ if (nm==0) {
+ nLayerId=pObj->GetLayer();
+ bMovProtect=pObj->IsMoveProtect();
+ bSizProtect=pObj->IsResizeProtect();
+ bPrintable =pObj->IsPrintable();
+ bVisible = pObj->IsVisible();
+ Rectangle aSnapRect2(pObj->GetSnapRect());
+ Rectangle aLogicRect2(pObj->GetLogicRect());
+ nSnapPosX=aSnapRect2.Left();
+ nSnapPosY=aSnapRect2.Top();
+ nSnapWdt=aSnapRect2.GetWidth()-1;
+ nSnapHgt=aSnapRect2.GetHeight()-1;
+ nLogicWdt=aLogicRect2.GetWidth()-1;
+ nLogicHgt=aLogicRect2.GetHeight()-1;
+ bLogicWdtDiff=nLogicWdt!=nSnapWdt;
+ bLogicHgtDiff=nLogicHgt!=nSnapHgt;
+ nRotAngle=pObj->GetRotateAngle();
+ nShrAngle=pObj->GetShearAngle();
+ } else {
+ if (!bLayerDC && nLayerId !=pObj->GetLayer()) bLayerDC=TRUE;
+ if (!bMovProtectDC && bMovProtect!=pObj->IsMoveProtect()) bMovProtectDC=TRUE;
+ if (!bSizProtectDC && bSizProtect!=pObj->IsResizeProtect()) bSizProtectDC=TRUE;
+ if (!bPrintableDC && bPrintable !=pObj->IsPrintable()) bPrintableDC=TRUE;
+ if (!bVisibleDC && bVisible !=pObj->IsVisible()) bVisibleDC=TRUE;
+ if (!bRotAngleDC && nRotAngle !=pObj->GetRotateAngle()) bRotAngleDC=TRUE;
+ if (!bShrAngleDC && nShrAngle !=pObj->GetShearAngle()) bShrAngleDC=TRUE;
+ if (!bSnapWdtDC || !bSnapHgtDC || !bSnapPosXDC || !bSnapPosYDC || !bLogicWdtDiff || !bLogicHgtDiff) {
+ aSnapRect=pObj->GetSnapRect();
+ if (nSnapPosX!=aSnapRect.Left()) bSnapPosXDC=TRUE;
+ if (nSnapPosY!=aSnapRect.Top()) bSnapPosYDC=TRUE;
+ if (nSnapWdt!=aSnapRect.GetWidth()-1) bSnapWdtDC=TRUE;
+ if (nSnapHgt!=aSnapRect.GetHeight()-1) bSnapHgtDC=TRUE;
+ }
+ if (!bLogicWdtDC || !bLogicHgtDC || !bLogicWdtDiff || !bLogicHgtDiff) {
+ aLogicRect=pObj->GetLogicRect();
+ if (nLogicWdt!=aLogicRect.GetWidth()-1) bLogicWdtDC=TRUE;
+ if (nLogicHgt!=aLogicRect.GetHeight()-1) bLogicHgtDC=TRUE;
+ if (!bLogicWdtDiff && aSnapRect.GetWidth()!=aLogicRect.GetWidth()) bLogicWdtDiff=TRUE;
+ if (!bLogicHgtDiff && aSnapRect.GetHeight()!=aLogicRect.GetHeight()) bLogicHgtDiff=TRUE;
+ }
+ }
+ if (!bObjNameDC ) {
+ if (!bObjNameSet) {
+ aObjName=pObj->GetName();
+ } else {
+ if (aObjName!=pObj->GetName()) bObjNameDC=TRUE;
+ }
+ }
+ }
+
+ if (bSnapPosXDC || nAllSnapPosX!=nSnapPosX) rAttr.Put(SdrAllPositionXItem(nAllSnapPosX));
+ if (bSnapPosYDC || nAllSnapPosY!=nSnapPosY) rAttr.Put(SdrAllPositionYItem(nAllSnapPosY));
+ if (bSnapWdtDC || nAllSnapWdt !=nSnapWdt ) rAttr.Put(SdrAllSizeWidthItem(nAllSnapWdt));
+ if (bSnapHgtDC || nAllSnapHgt !=nSnapHgt ) rAttr.Put(SdrAllSizeHeightItem(nAllSnapHgt));
+
+ // Items fuer reine Transformationen
+ rAttr.Put(SdrMoveXItem());
+ rAttr.Put(SdrMoveYItem());
+ rAttr.Put(SdrResizeXOneItem());
+ rAttr.Put(SdrResizeYOneItem());
+ rAttr.Put(SdrRotateOneItem());
+ rAttr.Put(SdrHorzShearOneItem());
+ rAttr.Put(SdrVertShearOneItem());
+
+ if (nMarkAnz>1) {
+ rAttr.Put(SdrResizeXAllItem());
+ rAttr.Put(SdrResizeYAllItem());
+ rAttr.Put(SdrRotateAllItem());
+ rAttr.Put(SdrHorzShearAllItem());
+ rAttr.Put(SdrVertShearAllItem());
+ }
+
+ if(eDragMode == SDRDRAG_ROTATE || eDragMode == SDRDRAG_MIRROR)
+ {
+ rAttr.Put(SdrTransformRef1XItem(GetRef1().X()));
+ rAttr.Put(SdrTransformRef1YItem(GetRef1().Y()));
+ }
+
+ if(eDragMode == SDRDRAG_MIRROR)
+ {
+ rAttr.Put(SdrTransformRef2XItem(GetRef2().X()));
+ rAttr.Put(SdrTransformRef2YItem(GetRef2().Y()));
+ }
+}
+
+SfxItemSet SdrEditView::GetAttrFromMarked(BOOL bOnlyHardAttr) const
+{
+ SfxItemSet aSet(pMod->GetItemPool());
+ MergeAttrFromMarked(aSet,bOnlyHardAttr);
+ //the EE_FEATURE items should not be set with SetAttrToMarked (see error message there)
+ //so we do not set them here
+ // #i32448#
+ // Do not disable, but clear the items.
+ aSet.ClearItem(EE_FEATURE_TAB);
+ aSet.ClearItem(EE_FEATURE_LINEBR);
+ aSet.ClearItem(EE_FEATURE_NOTCONV);
+ aSet.ClearItem(EE_FEATURE_FIELD);
+ return aSet;
+}
+
+void SdrEditView::MergeAttrFromMarked(SfxItemSet& rAttr, BOOL bOnlyHardAttr) const
+{
+ sal_uInt32 nMarkAnz(GetMarkedObjectCount());
+
+ for(sal_uInt32 a(0); a < nMarkAnz; a++)
+ {
+ // #80277# merging was done wrong in the prev version
+ //const SfxItemSet& rSet = GetMarkedObjectByIndex()->GetItemSet();
+ const SfxItemSet& rSet = GetMarkedObjectByIndex(a)->GetMergedItemSet();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich(aIter.FirstWhich());
+
+ while(nWhich)
+ {
+ if(!bOnlyHardAttr)
+ {
+ if(SFX_ITEM_DONTCARE == rSet.GetItemState(nWhich, FALSE))
+ rAttr.InvalidateItem(nWhich);
+ else
+ rAttr.MergeValue(rSet.Get(nWhich), TRUE);
+ }
+ else if(SFX_ITEM_SET == rSet.GetItemState(nWhich, FALSE))
+ {
+ const SfxPoolItem& rItem = rSet.Get(nWhich);
+ rAttr.MergeValue(rItem, TRUE);
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+}
+
+void SdrEditView::SetAttrToMarked(const SfxItemSet& rAttr, BOOL bReplaceAll)
+{
+ if (AreObjectsMarked())
+ {
+#ifdef DBG_UTIL
+ {
+ BOOL bHasEEFeatureItems=FALSE;
+ SfxItemIter aIter(rAttr);
+ const SfxPoolItem* pItem=aIter.FirstItem();
+ while (!bHasEEFeatureItems && pItem!=NULL) {
+ if (!IsInvalidItem(pItem)) {
+ USHORT nW=pItem->Which();
+ if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) bHasEEFeatureItems=TRUE;
+ }
+ pItem=aIter.NextItem();
+ }
+ if(bHasEEFeatureItems)
+ {
+ String aMessage;
+ aMessage.AppendAscii("SdrEditView::SetAttrToMarked(): Das setzen von EE_FEATURE-Items an der SdrView macht keinen Sinn! Es fuehrt nur zu Overhead und nicht mehr lesbaren Dokumenten.");
+ InfoBox(NULL, aMessage).Execute();
+ }
+ }
+#endif
+
+ // #103836# if the user thets character attributes to the complete shape,
+ // we want to remove all hard set character attributes with same
+ // which ids from the text. We do that later but here we remember
+ // all character attribute which id's that are set.
+ std::vector<sal_uInt16> aCharWhichIds;
+ {
+ SfxItemIter aIter(rAttr);
+ const SfxPoolItem* pItem=aIter.FirstItem();
+ while( pItem!=NULL )
+ {
+ if (!IsInvalidItem(pItem))
+ {
+ sal_uInt16 nWhich = pItem->Which();
+ if (nWhich>=EE_CHAR_START && nWhich<=EE_CHAR_END)
+ aCharWhichIds.push_back( nWhich );
+ }
+ pItem=aIter.NextItem();
+ }
+ }
+
+ // Joe, 2.7.98: Damit Undo nach Format.Standard auch die Textattribute korrekt restauriert
+ BOOL bHasEEItems=SearchOutlinerItems(rAttr,bReplaceAll);
+
+ // AW 030100: save additional geom info when para or char attributes
+ // are changed and the geom form of the text object might be changed
+ BOOL bPossibleGeomChange(FALSE);
+ SfxWhichIter aIter(rAttr);
+ UINT16 nWhich = aIter.FirstWhich();
+ while(!bPossibleGeomChange && nWhich)
+ {
+ SfxItemState eState = rAttr.GetItemState(nWhich);
+ if(eState == SFX_ITEM_SET)
+ {
+ if((nWhich >= SDRATTR_TEXT_MINFRAMEHEIGHT && nWhich <= SDRATTR_TEXT_CONTOURFRAME)
+ || nWhich == SDRATTR_3DOBJ_PERCENT_DIAGONAL
+ || nWhich == SDRATTR_3DOBJ_BACKSCALE
+ || nWhich == SDRATTR_3DOBJ_DEPTH
+ || nWhich == SDRATTR_3DOBJ_END_ANGLE
+ || nWhich == SDRATTR_3DSCENE_DISTANCE)
+ {
+ bPossibleGeomChange = TRUE;
+ }
+ }
+ nWhich = aIter.NextWhich();
+ }
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
+ BegUndo(aStr);
+ }
+
+ const sal_uInt32 nMarkAnz(GetMarkedObjectCount());
+ std::vector< E3DModifySceneSnapRectUpdater* > aUpdaters;
+
+ // create ItemSet without SFX_ITEM_DONTCARE. Put()
+ // uses it's second parameter (bInvalidAsDefault) to
+ // remove all such items to set them to default.
+ SfxItemSet aAttr(*rAttr.GetPool(), rAttr.GetRanges());
+ aAttr.Put(rAttr, TRUE);
+
+ // #i38135#
+ bool bResetAnimationTimer(false);
+
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj = pM->GetMarkedSdrObj();
+
+ if( bUndo )
+ {
+ std::vector< SdrUndoAction* > vConnectorUndoActions;
+ SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >( pObj );
+ if ( pEdgeObj )
+ bPossibleGeomChange = TRUE;
+ else if( bUndo )
+ vConnectorUndoActions = CreateConnectorUndo( *pObj );
+
+ AddUndoActions( vConnectorUndoActions );
+ }
+
+ // new geometry undo
+ if(bPossibleGeomChange && bUndo)
+ {
+ // save position and size of obect, too
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
+ }
+
+ if( bUndo )
+ {
+ // #i8508#
+ // If this is a text object also rescue the OutlinerParaObject since
+ // applying attributes to the object may change text layout when
+ // multiple portions exist with multiple formats. If a OutlinerParaObject
+ // really exists and needs to be rescued is evaluated in the undo
+ // implementation itself.
+ const bool bRescueText = dynamic_cast< SdrTextObj* >(pObj) != 0;
+
+ // add attribute undo
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj,FALSE,bHasEEItems || bPossibleGeomChange || bRescueText));
+ }
+
+ // set up a scxene updater if object is a 3d object
+ if(dynamic_cast< E3dObject* >(pObj))
+ {
+ aUpdaters.push_back(new E3DModifySceneSnapRectUpdater(pObj));
+ }
+
+ // set attributes at object
+ pObj->SetMergedItemSetAndBroadcast(aAttr, bReplaceAll);
+
+ if(pObj->ISA(SdrTextObj))
+ {
+ SdrTextObj* pTextObj = ((SdrTextObj*)pObj);
+
+ if(0 != aCharWhichIds.size())
+ {
+ Rectangle aOldBoundRect = pTextObj->GetLastBoundRect();
+
+ // #110094#-14 pTextObj->SendRepaintBroadcast(pTextObj->GetBoundRect());
+ pTextObj->RemoveOutlinerCharacterAttribs( aCharWhichIds );
+
+ // object has changed, should be called form
+ // RemoveOutlinerCharacterAttribs. This will change when the text
+ // object implementation changes.
+ pTextObj->SetChanged();
+
+ pTextObj->BroadcastObjectChange();
+ pTextObj->SendUserCall(SDRUSERCALL_CHGATTR, aOldBoundRect);
+ }
+ }
+
+ // #i38495#
+ if(!bResetAnimationTimer)
+ {
+ if(pObj->GetViewContact().isAnimatedInAnyViewObjectContact())
+ {
+ bResetAnimationTimer = true;
+ }
+ }
+ }
+
+ // fire scene updaters
+ while(aUpdaters.size())
+ {
+ delete aUpdaters.back();
+ aUpdaters.pop_back();
+ }
+
+ // #i38135#
+ if(bResetAnimationTimer)
+ {
+ SetAnimationTimer(0L);
+ }
+
+ // besser vorher checken, was gemacht werden soll:
+ // pObj->SetAttr() oder SetNotPersistAttr()
+ // !!! fehlende Implementation !!!
+ SetNotPersistAttrToMarked(rAttr,bReplaceAll);
+
+ if( bUndo )
+ EndUndo();
+ }
+}
+
+SfxStyleSheet* SdrEditView::GetStyleSheetFromMarked() const
+{
+ SfxStyleSheet* pRet=NULL;
+ BOOL b1st=TRUE;
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SfxStyleSheet* pSS=pM->GetMarkedSdrObj()->GetStyleSheet();
+ if (b1st) pRet=pSS;
+ else if (pRet!=pSS) return NULL; // verschiedene StyleSheets
+ b1st=FALSE;
+ }
+ return pRet;
+}
+
+void SdrEditView::SetStyleSheetToMarked(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr)
+{
+ if (AreObjectsMarked())
+ {
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ {
+ XubString aStr;
+ if (pStyleSheet!=NULL)
+ ImpTakeDescriptionStr(STR_EditSetStylesheet,aStr);
+ else
+ ImpTakeDescriptionStr(STR_EditDelStylesheet,aStr);
+ BegUndo(aStr);
+ }
+
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ if( bUndo )
+ {
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pM->GetMarkedSdrObj()));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pM->GetMarkedSdrObj(),true,true));
+ }
+ pM->GetMarkedSdrObj()->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
+ }
+
+ if( bUndo )
+ EndUndo();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/* new interface src537 */
+BOOL SdrEditView::GetAttributes(SfxItemSet& rTargetSet, BOOL bOnlyHardAttr) const
+{
+ if(GetMarkedObjectCount())
+ {
+ rTargetSet.Put(GetAttrFromMarked(bOnlyHardAttr), FALSE);
+ return TRUE;
+ }
+ else
+ {
+ return SdrMarkView::GetAttributes(rTargetSet, bOnlyHardAttr);
+ }
+}
+
+BOOL SdrEditView::SetAttributes(const SfxItemSet& rSet, BOOL bReplaceAll)
+{
+ if (GetMarkedObjectCount()!=0) {
+ SetAttrToMarked(rSet,bReplaceAll);
+ return TRUE;
+ } else {
+ return SdrMarkView::SetAttributes(rSet,bReplaceAll);
+ }
+}
+
+SfxStyleSheet* SdrEditView::GetStyleSheet() const // SfxStyleSheet* SdrEditView::GetStyleSheet(BOOL& rOk) const
+{
+ if (GetMarkedObjectCount()!=0) {
+ //rOk=TRUE;
+ return GetStyleSheetFromMarked();
+ } else {
+ return SdrMarkView::GetStyleSheet(); // SdrMarkView::GetStyleSheet(rOk);
+ }
+}
+
+BOOL SdrEditView::SetStyleSheet(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr)
+{
+ if (GetMarkedObjectCount()!=0) {
+ SetStyleSheetToMarked(pStyleSheet,bDontRemoveHardAttr);
+ return TRUE;
+ } else {
+ return SdrMarkView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SfxItemSet SdrEditView::GetGeoAttrFromMarked() const
+{
+ SfxItemSet aRetSet(pMod->GetItemPool(), // SID_ATTR_TRANSFORM_... aus s:svxids.hrc
+ SID_ATTR_TRANSFORM_POS_X,SID_ATTR_TRANSFORM_ANGLE,
+ SID_ATTR_TRANSFORM_PROTECT_POS,SID_ATTR_TRANSFORM_AUTOHEIGHT,
+ SDRATTR_ECKENRADIUS,SDRATTR_ECKENRADIUS,
+ 0);
+ if (AreObjectsMarked()) {
+ SfxItemSet aMarkAttr(GetAttrFromMarked(FALSE)); // wg. AutoGrowHeight und Eckenradius
+ Rectangle aRect(GetMarkedObjRect());
+
+ if(GetSdrPageView())
+ {
+ GetSdrPageView()->LogicToPagePos(aRect);
+ }
+
+ // Position
+ aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_X,aRect.Left()));
+ aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_Y,aRect.Top()));
+
+ // Groesse
+ long nResizeRefX=aRect.Left();
+ long nResizeRefY=aRect.Top();
+ if (eDragMode==SDRDRAG_ROTATE) { // Drehachse auch als Referenz fuer Resize
+ nResizeRefX=aRef1.X();
+ nResizeRefY=aRef1.Y();
+ }
+ aRetSet.Put(SfxUInt32Item(SID_ATTR_TRANSFORM_WIDTH,aRect.Right()-aRect.Left()));
+ aRetSet.Put(SfxUInt32Item(SID_ATTR_TRANSFORM_HEIGHT,aRect.Bottom()-aRect.Top()));
+ aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_RESIZE_REF_X,nResizeRefX));
+ aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_RESIZE_REF_Y,nResizeRefY));
+
+ Point aRotateAxe(aRef1);
+
+ if(GetSdrPageView())
+ {
+ GetSdrPageView()->LogicToPagePos(aRotateAxe);
+ }
+
+ // Drehung
+ long nRotateRefX=aRect.Center().X();
+ long nRotateRefY=aRect.Center().Y();
+ if (eDragMode==SDRDRAG_ROTATE) {
+ nRotateRefX=aRotateAxe.X();
+ nRotateRefY=aRotateAxe.Y();
+ }
+ aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_ANGLE,GetMarkedObjRotate()));
+ aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_ROT_X,nRotateRefX));
+ aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_ROT_Y,nRotateRefY));
+
+ // Shear
+ long nShearRefX=aRect.Left();
+ long nShearRefY=aRect.Bottom();
+ if (eDragMode==SDRDRAG_ROTATE) { // Drehachse auch als Referenz fuer Shear
+ nShearRefX=aRotateAxe.X();
+ nShearRefY=aRotateAxe.Y();
+ }
+ aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR,GetMarkedObjShear()));
+ aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_X,nShearRefX));
+ aRetSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_SHEAR_Y,nShearRefY));
+
+ // Pruefen der einzelnen Objekte, ob Objekte geschuetzt sind
+ const SdrMarkList& rMarkList=GetMarkedObjectList();
+ ULONG nMarkCount=rMarkList.GetMarkCount();
+ SdrObject* pObj=rMarkList.GetMark(0)->GetMarkedSdrObj();
+ BOOL bPosProt=pObj->IsMoveProtect();
+ BOOL bSizProt=pObj->IsResizeProtect();
+ BOOL bPosProtDontCare=FALSE;
+ BOOL bSizProtDontCare=FALSE;
+ for (ULONG i=1; i<nMarkCount && (!bPosProtDontCare || !bSizProtDontCare); i++) {
+ pObj=rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if (bPosProt!=pObj->IsMoveProtect()) bPosProtDontCare=TRUE;
+ if (bSizProt!=pObj->IsResizeProtect()) bSizProtDontCare=TRUE;
+ }
+
+ // InvalidateItem setzt das Item auf DONT_CARE
+ if (bPosProtDontCare) {
+ aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_PROTECT_POS);
+ } else {
+ aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_PROTECT_POS,bPosProt));
+ }
+ if (bSizProtDontCare) {
+ aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_PROTECT_SIZE);
+ } else {
+ aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_PROTECT_SIZE,bSizProt));
+ }
+
+ SfxItemState eState=aMarkAttr.GetItemState(SDRATTR_TEXT_AUTOGROWWIDTH);
+ BOOL bAutoGrow=((SdrTextAutoGrowWidthItem&)(aMarkAttr.Get(SDRATTR_TEXT_AUTOGROWWIDTH))).GetValue();
+ if (eState==SFX_ITEM_DONTCARE) {
+ aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_AUTOWIDTH);
+ } else if (eState==SFX_ITEM_SET) {
+ aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_AUTOWIDTH,bAutoGrow));
+ }
+
+ eState=aMarkAttr.GetItemState(SDRATTR_TEXT_AUTOGROWHEIGHT);
+ bAutoGrow=((SdrTextAutoGrowHeightItem&)(aMarkAttr.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
+ if (eState==SFX_ITEM_DONTCARE) {
+ aRetSet.InvalidateItem(SID_ATTR_TRANSFORM_AUTOHEIGHT);
+ } else if (eState==SFX_ITEM_SET) {
+ aRetSet.Put(SfxBoolItem(SID_ATTR_TRANSFORM_AUTOHEIGHT,bAutoGrow));
+ }
+
+ eState=aMarkAttr.GetItemState(SDRATTR_ECKENRADIUS);
+ long nRadius=((SdrEckenradiusItem&)(aMarkAttr.Get(SDRATTR_ECKENRADIUS))).GetValue();
+ if (eState==SFX_ITEM_DONTCARE) {
+ aRetSet.InvalidateItem(SDRATTR_ECKENRADIUS);
+ } else if (eState==SFX_ITEM_SET) {
+ aRetSet.Put(SdrEckenradiusItem(nRadius));
+ }
+
+ }
+ return aRetSet;
+}
+
+Point ImpGetPoint(Rectangle aRect, RECT_POINT eRP)
+{
+ switch(eRP) {
+ case RP_LT: return aRect.TopLeft();
+ case RP_MT: return aRect.TopCenter();
+ case RP_RT: return aRect.TopRight();
+ case RP_LM: return aRect.LeftCenter();
+ case RP_MM: return aRect.Center();
+ case RP_RM: return aRect.RightCenter();
+ case RP_LB: return aRect.BottomLeft();
+ case RP_MB: return aRect.BottomCenter();
+ case RP_RB: return aRect.BottomRight();
+ }
+ return Point(); // Sollte nicht vorkommen !
+}
+
+void SdrEditView::SetGeoAttrToMarked(const SfxItemSet& rAttr)
+{
+ Rectangle aRect(GetMarkedObjRect());
+
+ if(GetSdrPageView())
+ {
+ GetSdrPageView()->LogicToPagePos(aRect);
+ }
+
+ long nOldRotateAngle=GetMarkedObjRotate();
+ long nOldShearAngle=GetMarkedObjShear();
+ const SdrMarkList& rMarkList=GetMarkedObjectList();
+ ULONG nMarkCount=rMarkList.GetMarkCount();
+ SdrObject* pObj=NULL;
+
+ RECT_POINT eSizePoint=RP_MM;
+ long nPosDX=0;
+ long nPosDY=0;
+ long nSizX=0;
+ long nSizY=0;
+ long nRotateAngle=0;
+
+ // #86909#
+ sal_Bool bModeIsRotate(eDragMode == SDRDRAG_ROTATE);
+ long nRotateX(0);
+ long nRotateY(0);
+ long nOldRotateX(0);
+ long nOldRotateY(0);
+ if(bModeIsRotate)
+ {
+ Point aRotateAxe(aRef1);
+
+ if(GetSdrPageView())
+ {
+ GetSdrPageView()->LogicToPagePos(aRotateAxe);
+ }
+
+ nRotateX = nOldRotateX = aRotateAxe.X();
+ nRotateY = nOldRotateY = aRotateAxe.Y();
+ }
+
+ long nNewShearAngle=0;
+ long nShearAngle=0;
+ long nShearX=0;
+ long nShearY=0;
+ BOOL bShearVert=FALSE;
+
+ BOOL bChgPos=FALSE;
+ BOOL bChgSiz=FALSE;
+ BOOL bChgHgt=FALSE;
+ BOOL bRotate=FALSE;
+ BOOL bShear =FALSE;
+
+ BOOL bSetAttr=FALSE;
+ SfxItemSet aSetAttr(pMod->GetItemPool());
+
+ const SfxPoolItem* pPoolItem=NULL;
+
+ // Position
+ if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_POS_X,TRUE,&pPoolItem)) {
+ nPosDX=((const SfxInt32Item*)pPoolItem)->GetValue()-aRect.Left();
+ bChgPos=TRUE;
+ }
+ if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_POS_Y,TRUE,&pPoolItem)){
+ nPosDY=((const SfxInt32Item*)pPoolItem)->GetValue()-aRect.Top();
+ bChgPos=TRUE;
+ }
+ // Groesse
+ if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_WIDTH,TRUE,&pPoolItem)) {
+ nSizX=((const SfxUInt32Item*)pPoolItem)->GetValue();
+ bChgSiz=TRUE;
+ }
+ if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,TRUE,&pPoolItem)) {
+ nSizY=((const SfxUInt32Item*)pPoolItem)->GetValue();
+ bChgSiz=TRUE;
+ bChgHgt=TRUE;
+ }
+ if (bChgSiz) {
+ eSizePoint=(RECT_POINT)((const SfxAllEnumItem&)rAttr.Get(SID_ATTR_TRANSFORM_SIZE_POINT)).GetValue();
+ }
+
+ // Rotation
+ if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_ANGLE,TRUE,&pPoolItem)) {
+ nRotateAngle=((const SfxInt32Item*)pPoolItem)->GetValue()-nOldRotateAngle;
+ bRotate = (nRotateAngle != 0);
+ }
+
+ // #86909# pos rot point x
+ if(bRotate || SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_ROT_X, TRUE ,&pPoolItem))
+ nRotateX = ((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_ROT_X)).GetValue();
+
+ // #86909# pos rot point y
+ if(bRotate || SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_ROT_Y, TRUE ,&pPoolItem))
+ nRotateY = ((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_ROT_Y)).GetValue();
+
+ // Shear
+ if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_SHEAR,TRUE,&pPoolItem)) {
+ nNewShearAngle=((const SfxInt32Item*)pPoolItem)->GetValue();
+ if (nNewShearAngle>SDRMAXSHEAR) nNewShearAngle=SDRMAXSHEAR;
+ if (nNewShearAngle<-SDRMAXSHEAR) nNewShearAngle=-SDRMAXSHEAR;
+ if (nNewShearAngle!=nOldShearAngle) {
+ bShearVert=((const SfxBoolItem&)rAttr.Get(SID_ATTR_TRANSFORM_SHEAR_VERTICAL)).GetValue();
+ if (bShearVert) {
+ nShearAngle=nNewShearAngle;
+ } else {
+ if (nNewShearAngle!=0 && nOldShearAngle!=0) {
+ // Bugfix #25714#.
+ double nOld=tan((double)nOldShearAngle*nPi180);
+ double nNew=tan((double)nNewShearAngle*nPi180);
+ nNew-=nOld;
+ nNew=atan(nNew)/nPi180;
+ nShearAngle=Round(nNew);
+ } else {
+ nShearAngle=nNewShearAngle-nOldShearAngle;
+ }
+ }
+ bShear=nShearAngle!=0;
+ if (bShear) {
+ nShearX=((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_SHEAR_X)).GetValue();
+ nShearY=((const SfxInt32Item&)rAttr.Get(SID_ATTR_TRANSFORM_SHEAR_Y)).GetValue();
+ }
+ }
+ }
+
+ // AutoGrow
+ if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_AUTOWIDTH,TRUE,&pPoolItem)) {
+ BOOL bAutoGrow=((const SfxBoolItem*)pPoolItem)->GetValue();
+ aSetAttr.Put(SdrTextAutoGrowWidthItem(bAutoGrow));
+ bSetAttr=TRUE;
+ }
+
+ if (SFX_ITEM_SET==rAttr.GetItemState(SID_ATTR_TRANSFORM_AUTOHEIGHT,TRUE,&pPoolItem)) {
+ BOOL bAutoGrow=((const SfxBoolItem*)pPoolItem)->GetValue();
+ aSetAttr.Put(SdrTextAutoGrowHeightItem(bAutoGrow));
+ bSetAttr=TRUE;
+ }
+
+ // Eckenradius
+ if (bEdgeRadiusAllowed && SFX_ITEM_SET==rAttr.GetItemState(SDRATTR_ECKENRADIUS,TRUE,&pPoolItem)) {
+ long nRadius=((SdrEckenradiusItem*)pPoolItem)->GetValue();
+ aSetAttr.Put(SdrEckenradiusItem(nRadius));
+ bSetAttr=TRUE;
+ }
+
+ ForcePossibilities();
+
+ BegUndo(ImpGetResStr(STR_EditTransform),GetDescriptionOfMarkedObjects());
+
+ if (bSetAttr) {
+ SetAttrToMarked(aSetAttr,FALSE);
+ }
+
+ // Groesse und Hoehe aendern
+ if (bChgSiz && (bResizeFreeAllowed || bResizePropAllowed)) {
+ Fraction aWdt(nSizX,aRect.Right()-aRect.Left());
+ Fraction aHgt(nSizY,aRect.Bottom()-aRect.Top());
+ Point aRef(ImpGetPoint(aRect,eSizePoint));
+
+ if(GetSdrPageView())
+ {
+ GetSdrPageView()->PagePosToLogic(aRef);
+ }
+
+ ResizeMarkedObj(aRef,aWdt,aHgt);
+ }
+
+ // Rotieren
+ if (bRotate && (bRotateFreeAllowed || bRotate90Allowed)) {
+ Point aRef(nRotateX,nRotateY);
+
+ if(GetSdrPageView())
+ {
+ GetSdrPageView()->PagePosToLogic(aRef);
+ }
+
+ RotateMarkedObj(aRef,nRotateAngle);
+ }
+
+ // #86909# set rotation point position
+ if(bModeIsRotate && (nRotateX != nOldRotateX || nRotateY != nOldRotateY))
+ {
+ Point aNewRef1(nRotateX, nRotateY);
+
+ if(GetSdrPageView())
+ {
+ GetSdrPageView()->PagePosToLogic(aNewRef1);
+ }
+
+ SetRef1(aNewRef1);
+ }
+
+ // Shear
+ if (bShear && bShearAllowed) {
+ Point aRef(nShearX,nShearY);
+
+ if(GetSdrPageView())
+ {
+ GetSdrPageView()->PagePosToLogic(aRef);
+ }
+
+ ShearMarkedObj(aRef,nShearAngle,bShearVert);
+
+ // #i74358#
+ // ShearMarkedObj creates a linear combination of the existing transformation and
+ // the new shear to apply. If the object is already transformed (e.g. rotated) the
+ // linear combination will not decompose to the same start values again, but to a
+ // new combination. Thus it makes no sense to check if the wanted shear is reached
+ // or not. Taking out.
+ }
+
+ // Position aendern
+ if (bChgPos && bMoveAllowed) {
+ MoveMarkedObj(Size(nPosDX,nPosDY));
+ }
+
+ // protect position
+ if(SFX_ITEM_SET == rAttr.GetItemState(SID_ATTR_TRANSFORM_PROTECT_POS, TRUE, &pPoolItem))
+ {
+ const sal_Bool bProtPos(((const SfxBoolItem*)pPoolItem)->GetValue());
+ bool bChanged(false);
+
+ for(sal_uInt32 i(0); i < nMarkCount; i++)
+ {
+ pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+
+ if(pObj->IsMoveProtect() != bProtPos)
+ {
+ bChanged = true;
+ pObj->SetMoveProtect(bProtPos);
+
+ if(bProtPos)
+ {
+ pObj->SetResizeProtect(true);
+ }
+ }
+ }
+
+ if(bChanged)
+ {
+ bMoveProtect = bProtPos;
+
+ if(bProtPos)
+ {
+ bResizeProtect = true;
+ }
+
+ // #i77187# there is no simple method to get the toolbars updated
+ // in the application. The App is listening to selection change and i
+ // will use it here (even if not true). It's acceptable since changing
+ // this model data is pretty rare and only possible using the F4 dialog
+ MarkListHasChanged();
+ }
+ }
+
+ if(!bMoveProtect)
+ {
+ // protect size
+ if(SFX_ITEM_SET == rAttr.GetItemState(SID_ATTR_TRANSFORM_PROTECT_SIZE, TRUE, &pPoolItem))
+ {
+ const sal_Bool bProtSize(((const SfxBoolItem*)pPoolItem)->GetValue());
+ bool bChanged(false);
+
+ for(sal_uInt32 i(0); i < nMarkCount; i++)
+ {
+ pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+
+ if(pObj->IsResizeProtect() != bProtSize)
+ {
+ bChanged = true;
+ pObj->SetResizeProtect(bProtSize);
+ }
+ }
+
+ if(bChanged)
+ {
+ bResizeProtect = bProtSize;
+
+ // #i77187# see above
+ MarkListHasChanged();
+ }
+ }
+ }
+
+ EndUndo();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrEditView::IsAlignPossible() const
+{ // Mindestens 2 markierte Objekte, davon mind. 1 beweglich
+ ForcePossibilities();
+ ULONG nAnz=GetMarkedObjectCount();
+ if (nAnz==0) return FALSE; // Nix markiert!
+ if (nAnz==1) return bMoveAllowed; // einzelnes Obj an der Seite ausrichten
+ return bOneOrMoreMovable; // ansonsten ist MarkCount>=2
+}
+
+void SdrEditView::AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert, BOOL bBoundRects)
+{
+ if (eHor==SDRHALIGN_NONE && eVert==SDRVALIGN_NONE)
+ return;
+
+ SortMarkedObjects();
+ if (GetMarkedObjectCount()<1)
+ return;
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ {
+ XubString aStr(GetDescriptionOfMarkedObjects());
+ if (eHor==SDRHALIGN_NONE)
+ {
+ switch (eVert)
+ {
+ case SDRVALIGN_TOP : ImpTakeDescriptionStr(STR_EditAlignVTop ,aStr); break;
+ case SDRVALIGN_BOTTOM: ImpTakeDescriptionStr(STR_EditAlignVBottom,aStr); break;
+ case SDRVALIGN_CENTER: ImpTakeDescriptionStr(STR_EditAlignVCenter,aStr); break;
+ default: break;
+ }
+ }
+ else if (eVert==SDRVALIGN_NONE)
+ {
+ switch (eHor)
+ {
+ case SDRHALIGN_LEFT : ImpTakeDescriptionStr(STR_EditAlignHLeft ,aStr); break;
+ case SDRHALIGN_RIGHT : ImpTakeDescriptionStr(STR_EditAlignHRight ,aStr); break;
+ case SDRHALIGN_CENTER: ImpTakeDescriptionStr(STR_EditAlignHCenter,aStr); break;
+ default: break;
+ }
+ }
+ else if (eHor==SDRHALIGN_CENTER && eVert==SDRVALIGN_CENTER)
+ {
+ ImpTakeDescriptionStr(STR_EditAlignCenter,aStr);
+ }
+ else
+ {
+ ImpTakeDescriptionStr(STR_EditAlign,aStr);
+ }
+ BegUndo(aStr);
+ }
+
+ Rectangle aBound;
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ ULONG nm;
+ BOOL bHasFixed=FALSE;
+ for (nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrObjTransformInfoRec aInfo;
+ pObj->TakeObjInfo(aInfo);
+ if (!aInfo.bMoveAllowed || pObj->IsMoveProtect())
+ {
+ Rectangle aObjRect(bBoundRects?pObj->GetCurrentBoundRect():pObj->GetSnapRect());
+ aBound.Union(aObjRect);
+ bHasFixed=TRUE;
+ }
+ }
+ if (!bHasFixed)
+ {
+ if (nMarkAnz==1)
+ { // einzelnes Obj an der Seite ausrichten
+ const SdrObject* pObj=GetMarkedObjectByIndex(0L);
+ const SdrPage* pPage=pObj->GetPage();
+ const SdrPageGridFrameList* pGFL=pPage->GetGridFrameList(GetSdrPageViewOfMarkedByIndex(0),&(pObj->GetSnapRect()));
+ const SdrPageGridFrame* pFrame=NULL;
+ if (pGFL!=NULL && pGFL->GetCount()!=0)
+ { // Writer
+ pFrame=&((*pGFL)[0]);
+ }
+
+ if (pFrame!=NULL)
+ { // Writer
+ aBound=pFrame->GetUserArea();
+ }
+ else
+ {
+ aBound=Rectangle(pPage->GetLftBorder(),pPage->GetUppBorder(),
+ pPage->GetWdt()-pPage->GetRgtBorder(),
+ pPage->GetHgt()-pPage->GetLwrBorder());
+ }
+ }
+ else
+ {
+ if (bBoundRects)
+ aBound=GetMarkedObjBoundRect();
+ else
+ aBound=GetMarkedObjRect();
+ }
+ }
+ Point aCenter(aBound.Center());
+ for (nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrObjTransformInfoRec aInfo;
+ pObj->TakeObjInfo(aInfo);
+ if (aInfo.bMoveAllowed && !pObj->IsMoveProtect())
+ {
+ // SdrPageView* pPV=pM->GetPageView();
+ long nXMov=0;
+ long nYMov=0;
+ Rectangle aObjRect(bBoundRects?pObj->GetCurrentBoundRect():pObj->GetSnapRect());
+ switch (eVert)
+ {
+ case SDRVALIGN_TOP : nYMov=aBound.Top() -aObjRect.Top() ; break;
+ case SDRVALIGN_BOTTOM: nYMov=aBound.Bottom()-aObjRect.Bottom() ; break;
+ case SDRVALIGN_CENTER: nYMov=aCenter.Y() -aObjRect.Center().Y(); break;
+ default: break;
+ }
+ switch (eHor)
+ {
+ case SDRHALIGN_LEFT : nXMov=aBound.Left() -aObjRect.Left() ; break;
+ case SDRHALIGN_RIGHT : nXMov=aBound.Right() -aObjRect.Right() ; break;
+ case SDRHALIGN_CENTER: nXMov=aCenter.X() -aObjRect.Center().X(); break;
+ default: break;
+ }
+ if (nXMov!=0 || nYMov!=0)
+ {
+ // #104104# SdrEdgeObj needs an extra SdrUndoGeoObj since the
+ // connections may need to be saved
+ if( bUndo )
+ {
+ if( dynamic_cast<SdrEdgeObj*>(pObj) )
+ {
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
+ }
+
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoMoveObject(*pObj,Size(nXMov,nYMov)));
+ }
+
+ pObj->Move(Size(nXMov,nYMov));
+ }
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
new file mode 100644
index 000000000000..eeb7349f5f28
--- /dev/null
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -0,0 +1,2141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdedtv.hxx>
+#include <editeng/outliner.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdogrp.hxx> // fuer's Gruppieren
+#include <svx/svdovirt.hxx> // fuer VirtualObject-Bundling (Writer)
+#include <svx/svdopath.hxx> // fuer CombineObjects
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include "svditer.hxx"
+#include <svx/svdograf.hxx> // fuer Possibilities
+#include <svx/svdoole2.hxx> // und Mtf-Import
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+#include "svdfmtf.hxx"
+#include <svx/svdetc.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <vcl/msgbox.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/eeitem.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+
+// #i37011#
+#include <svx/svdoashp.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@ @@@@@ @@ @@@@@@ @@ @@ @@ @@@@@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
+// @@@@ @@ @@ @@ @@ @@@@@ @@ @@@@ @@@@@@@
+// @@ @@ @@ @@ @@ @@@ @@ @@ @@@@@@@
+// @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
+// @@@@@ @@@@@ @@ @@ @ @@ @@@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::ImpBundleVirtObjOfMarkList()
+{
+ // ... fehlende Implementation
+}
+
+SdrObject* SdrEditView::GetMaxToTopObj(SdrObject* /*pObj*/) const
+{
+ return NULL;
+}
+
+SdrObject* SdrEditView::GetMaxToBtmObj(SdrObject* /*pObj*/) const
+{
+ return NULL;
+}
+
+void SdrEditView::ObjOrderChanged(SdrObject* /*pObj*/, ULONG /*nOldPos*/, ULONG /*nNewPos*/)
+{
+}
+
+void SdrEditView::MovMarkedToTop()
+{
+ ULONG nAnz=GetMarkedObjectCount();
+ if (nAnz!=0)
+ {
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_EditMovToTop),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVTOTOP);
+
+ SortMarkedObjects();
+ ULONG nm;
+ for (nm=0; nm<nAnz; nm++)
+ { // Ordnums muessen alle stimmen!
+ GetMarkedObjectByIndex(nm)->GetOrdNum();
+ }
+ BOOL bChg=FALSE;
+ SdrObjList* pOL0=NULL;
+ ULONG nNewPos=0;
+ for (nm=nAnz; nm>0;)
+ {
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrObjList* pOL=pObj->GetObjList();
+ if (pOL!=pOL0)
+ {
+ nNewPos=ULONG(pOL->GetObjCount()-1);
+ pOL0=pOL;
+ }
+ ULONG nNowPos=pObj->GetOrdNumDirect();
+ const Rectangle& rBR=pObj->GetCurrentBoundRect();
+ ULONG nCmpPos=nNowPos+1;
+ SdrObject* pMaxObj=GetMaxToTopObj(pObj);
+ if (pMaxObj!=NULL)
+ {
+ ULONG nMaxPos=pMaxObj->GetOrdNum();
+ if (nMaxPos!=0)
+ nMaxPos--;
+ if (nNewPos>nMaxPos)
+ nNewPos=nMaxPos; // diesen nicht ueberholen.
+ if (nNewPos<nNowPos)
+ nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
+ }
+ BOOL bEnd=FALSE;
+ while (nCmpPos<nNewPos && !bEnd)
+ {
+ SdrObject* pCmpObj=pOL->GetObj(nCmpPos);
+ if (pCmpObj==NULL)
+ {
+ DBG_ERROR("MovMarkedToTop(): Vergleichsobjekt nicht gefunden");
+ bEnd=TRUE;
+ }
+ else if (pCmpObj==pMaxObj)
+ {
+ nNewPos=nCmpPos;
+ nNewPos--;
+ bEnd=TRUE;
+ }
+ else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect()))
+ {
+ nNewPos=nCmpPos;
+ bEnd=TRUE;
+ }
+ else
+ {
+ nCmpPos++;
+ }
+ }
+ if (nNowPos!=nNewPos)
+ {
+ bChg=TRUE;
+ pOL->SetObjectOrdNum(nNowPos,nNewPos);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos));
+ ObjOrderChanged(pObj,nNowPos,nNewPos);
+ }
+ nNewPos--;
+ }
+
+ if( bUndo )
+ EndUndo();
+
+ if (bChg)
+ MarkListHasChanged();
+ }
+}
+
+void SdrEditView::MovMarkedToBtm()
+{
+ ULONG nAnz=GetMarkedObjectCount();
+ if (nAnz!=0)
+ {
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_EditMovToBtm),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_MOVTOBTM);
+
+ SortMarkedObjects();
+ ULONG nm;
+ for (nm=0; nm<nAnz; nm++)
+ { // Ordnums muessen alle stimmen!
+ GetMarkedObjectByIndex(nm)->GetOrdNum();
+ }
+
+ BOOL bChg=FALSE;
+ SdrObjList* pOL0=NULL;
+ ULONG nNewPos=0;
+ for (nm=0; nm<nAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrObjList* pOL=pObj->GetObjList();
+ if (pOL!=pOL0)
+ {
+ nNewPos=0;
+ pOL0=pOL;
+ }
+ ULONG nNowPos=pObj->GetOrdNumDirect();
+ const Rectangle& rBR=pObj->GetCurrentBoundRect();
+ ULONG nCmpPos=nNowPos; if (nCmpPos>0) nCmpPos--;
+ SdrObject* pMaxObj=GetMaxToBtmObj(pObj);
+ if (pMaxObj!=NULL)
+ {
+ ULONG nMinPos=pMaxObj->GetOrdNum()+1;
+ if (nNewPos<nMinPos)
+ nNewPos=nMinPos; // diesen nicht ueberholen.
+ if (nNewPos>nNowPos)
+ nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
+ }
+ BOOL bEnd=FALSE;
+ // nNewPos ist an dieser Stelle noch die maximale Position,
+ // an der das Obj hinruecken darf, ohne seinen Vorgaenger
+ // (Mehrfachselektion) zu ueberholen.
+ while (nCmpPos>nNewPos && !bEnd)
+ {
+ SdrObject* pCmpObj=pOL->GetObj(nCmpPos);
+ if (pCmpObj==NULL)
+ {
+ DBG_ERROR("MovMarkedToBtm(): Vergleichsobjekt nicht gefunden");
+ bEnd=TRUE;
+ }
+ else if (pCmpObj==pMaxObj)
+ {
+ nNewPos=nCmpPos;
+ nNewPos++;
+ bEnd=TRUE;
+ }
+ else if (rBR.IsOver(pCmpObj->GetCurrentBoundRect()))
+ {
+ nNewPos=nCmpPos;
+ bEnd=TRUE;
+ }
+ else
+ {
+ nCmpPos--;
+ }
+ }
+ if (nNowPos!=nNewPos)
+ {
+ bChg=TRUE;
+ pOL->SetObjectOrdNum(nNowPos,nNewPos);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos));
+ ObjOrderChanged(pObj,nNowPos,nNewPos);
+ }
+ nNewPos++;
+ }
+
+ if(bUndo)
+ EndUndo();
+
+ if(bChg)
+ MarkListHasChanged();
+ }
+}
+
+void SdrEditView::PutMarkedToTop()
+{
+ PutMarkedInFrontOfObj(NULL);
+}
+
+void SdrEditView::PutMarkedInFrontOfObj(const SdrObject* pRefObj)
+{
+ ULONG nAnz=GetMarkedObjectCount();
+ if (nAnz!=0)
+ {
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_EditPutToTop),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_PUTTOTOP);
+
+ SortMarkedObjects();
+
+ if (pRefObj!=NULL)
+ {
+ // Damit "Vor das Objekt" auch funktioniert wenn die
+ // markierten Objekte bereits vor dem Objekt stehen
+ ULONG nRefMark=TryToFindMarkedObject(pRefObj);
+ SdrMark aRefMark;
+ if (nRefMark!=CONTAINER_ENTRY_NOTFOUND)
+ {
+ aRefMark=*GetSdrMarkByIndex(nRefMark);
+ GetMarkedObjectListWriteAccess().DeleteMark(nRefMark);
+ }
+ PutMarkedToBtm();
+ if (nRefMark!=CONTAINER_ENTRY_NOTFOUND)
+ {
+ GetMarkedObjectListWriteAccess().InsertEntry(aRefMark);
+ SortMarkedObjects();
+ }
+ }
+ ULONG nm;
+ for (nm=0; nm<nAnz; nm++)
+ { // Ordnums muessen alle stimmen!
+ GetMarkedObjectByIndex(nm)->GetOrdNum();
+ }
+ BOOL bChg=FALSE;
+ SdrObjList* pOL0=NULL;
+ ULONG nNewPos=0;
+ for (nm=nAnz; nm>0;)
+ {
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ if (pObj!=pRefObj)
+ {
+ SdrObjList* pOL=pObj->GetObjList();
+ if (pOL!=pOL0)
+ {
+ nNewPos=ULONG(pOL->GetObjCount()-1);
+ pOL0=pOL;
+ }
+ ULONG nNowPos=pObj->GetOrdNumDirect();
+ SdrObject* pMaxObj=GetMaxToTopObj(pObj);
+ if (pMaxObj!=NULL)
+ {
+ ULONG nMaxOrd=pMaxObj->GetOrdNum(); // geht leider nicht anders
+ if (nMaxOrd>0)
+ nMaxOrd--;
+ if (nNewPos>nMaxOrd)
+ nNewPos=nMaxOrd; // nicht ueberholen.
+ if (nNewPos<nNowPos)
+ nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
+ }
+ if (pRefObj!=NULL)
+ {
+ if (pRefObj->GetObjList()==pObj->GetObjList())
+ {
+ ULONG nMaxOrd=pRefObj->GetOrdNum(); // geht leider nicht anders
+ if (nNewPos>nMaxOrd)
+ nNewPos=nMaxOrd; // nicht ueberholen.
+ if (nNewPos<nNowPos)
+ nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
+ }
+ else
+ {
+ nNewPos=nNowPos; // andere PageView, also nicht veraendern
+ }
+ }
+ if (nNowPos!=nNewPos)
+ {
+ bChg=TRUE;
+ pOL->SetObjectOrdNum(nNowPos,nNewPos);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos));
+ ObjOrderChanged(pObj,nNowPos,nNewPos);
+ }
+ nNewPos--;
+ } // if (pObj!=pRefObj)
+ } // for-Schleife ueber alle Markierten Objekte
+
+ if( bUndo )
+ EndUndo();
+
+ if(bChg)
+ MarkListHasChanged();
+ }
+}
+
+void SdrEditView::PutMarkedToBtm()
+{
+ PutMarkedBehindObj(NULL);
+}
+
+void SdrEditView::PutMarkedBehindObj(const SdrObject* pRefObj)
+{
+ ULONG nAnz=GetMarkedObjectCount();
+ if (nAnz!=0)
+ {
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_EditPutToBtm),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_PUTTOBTM);
+
+ SortMarkedObjects();
+ if (pRefObj!=NULL)
+ {
+ // Damit "Hinter das Objekt" auch funktioniert wenn die
+ // markierten Objekte bereits hinter dem Objekt stehen
+ ULONG nRefMark=TryToFindMarkedObject(pRefObj);
+ SdrMark aRefMark;
+ if (nRefMark!=CONTAINER_ENTRY_NOTFOUND)
+ {
+ aRefMark=*GetSdrMarkByIndex(nRefMark);
+ GetMarkedObjectListWriteAccess().DeleteMark(nRefMark);
+ }
+ PutMarkedToTop();
+ if (nRefMark!=CONTAINER_ENTRY_NOTFOUND)
+ {
+ GetMarkedObjectListWriteAccess().InsertEntry(aRefMark);
+ SortMarkedObjects();
+ }
+ }
+ ULONG nm;
+ for (nm=0; nm<nAnz; nm++) { // Ordnums muessen alle stimmen!
+ GetMarkedObjectByIndex(nm)->GetOrdNum();
+ }
+ BOOL bChg=FALSE;
+ SdrObjList* pOL0=NULL;
+ ULONG nNewPos=0;
+ for (nm=0; nm<nAnz; nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ if (pObj!=pRefObj) {
+ SdrObjList* pOL=pObj->GetObjList();
+ if (pOL!=pOL0) {
+ nNewPos=0;
+ pOL0=pOL;
+ }
+ ULONG nNowPos=pObj->GetOrdNumDirect();
+ SdrObject* pMinObj=GetMaxToBtmObj(pObj);
+ if (pMinObj!=NULL) {
+ ULONG nMinOrd=pMinObj->GetOrdNum()+1; // geht leider nicht anders
+ if (nNewPos<nMinOrd) nNewPos=nMinOrd; // nicht ueberholen.
+ if (nNewPos>nNowPos) nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
+ }
+ if (pRefObj!=NULL) {
+ if (pRefObj->GetObjList()==pObj->GetObjList()) {
+ ULONG nMinOrd=pRefObj->GetOrdNum(); // geht leider nicht anders
+ if (nNewPos<nMinOrd) nNewPos=nMinOrd; // nicht ueberholen.
+ if (nNewPos>nNowPos) nNewPos=nNowPos; // aber dabei auch nicht in die falsche Richtung schieben
+ } else {
+ nNewPos=nNowPos; // andere PageView, also nicht veraendern
+ }
+ }
+ if (nNowPos!=nNewPos) {
+ bChg=TRUE;
+ pOL->SetObjectOrdNum(nNowPos,nNewPos);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj,nNowPos,nNewPos));
+ ObjOrderChanged(pObj,nNowPos,nNewPos);
+ }
+ nNewPos++;
+ } // if (pObj!=pRefObj)
+ } // for-Schleife ueber alle markierten Objekte
+
+ if(bUndo)
+ EndUndo();
+
+ if(bChg)
+ MarkListHasChanged();
+ }
+}
+
+void SdrEditView::ReverseOrderOfMarked()
+{
+ SortMarkedObjects();
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ if (nMarkAnz>0)
+ {
+ //BOOL bNeedBundle=FALSE;
+ BOOL bChg=FALSE;
+
+ bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_EditRevOrder),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_REVORDER);
+
+ ULONG a=0;
+ do {
+ // Markierung ueber mehrere PageViews berueksichtigen
+ ULONG b=a+1;
+ while (b<nMarkAnz && GetSdrPageViewOfMarkedByIndex(b) == GetSdrPageViewOfMarkedByIndex(a)) b++;
+ b--;
+ SdrObjList* pOL=GetSdrPageViewOfMarkedByIndex(a)->GetObjList();
+ ULONG c=b;
+ if (a<c) { // Sicherstellen, dass die OrdNums nicht Dirty sind
+ GetMarkedObjectByIndex(a)->GetOrdNum();
+ }
+ while (a<c) {
+ SdrObject* pObj1=GetMarkedObjectByIndex(a);
+ SdrObject* pObj2=GetMarkedObjectByIndex(c);
+ ULONG nOrd1=pObj1->GetOrdNumDirect();
+ ULONG nOrd2=pObj2->GetOrdNumDirect();
+ if( bUndo )
+ {
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj1,nOrd1,nOrd2));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectOrdNum(*pObj2,nOrd2-1,nOrd1));
+ }
+ pOL->SetObjectOrdNum(nOrd1,nOrd2);
+ // Obj 2 ist um eine Position nach vorn gerutscht, deshalb nun nOrd2-1
+ pOL->SetObjectOrdNum(nOrd2-1,nOrd1);
+ // Verwendung von Replace statt SetOrdNum wg. Performance (Neuberechnung der Ordnums)
+ a++; c--;
+ bChg=TRUE;
+ }
+ a=b+1;
+ } while (a<nMarkAnz);
+
+ if(bUndo)
+ EndUndo();
+
+ if(bChg)
+ MarkListHasChanged();
+ }
+}
+
+void SdrEditView::ImpCheckToTopBtmPossible()
+{
+ ULONG nAnz=GetMarkedObjectCount();
+ if (nAnz==0)
+ return;
+ if (nAnz==1)
+ { // Sonderbehandlung fuer Einzelmarkierung
+ SdrObject* pObj=GetMarkedObjectByIndex(0);
+ SdrObjList* pOL=pObj->GetObjList();
+ ULONG nMax=pOL->GetObjCount();
+ ULONG nMin=0;
+ ULONG nObjNum=pObj->GetOrdNum();
+ SdrObject* pRestrict=GetMaxToTopObj(pObj);
+ if (pRestrict!=NULL) {
+ ULONG nRestrict=pRestrict->GetOrdNum();
+ if (nRestrict<nMax) nMax=nRestrict;
+ }
+ pRestrict=GetMaxToBtmObj(pObj);
+ if (pRestrict!=NULL) {
+ ULONG nRestrict=pRestrict->GetOrdNum();
+ if (nRestrict>nMin) nMin=nRestrict;
+ }
+ bToTopPossible=nObjNum<ULONG(nMax-1);
+ bToBtmPossible=nObjNum>nMin;
+ } else { // Mehrfachselektion
+ ULONG nm=0;
+ SdrObjList* pOL0=NULL;
+ long nPos0=-1;
+ while (!bToBtmPossible && nm<nAnz) { // 'nach hinten' checken
+ SdrObject* pObj=GetMarkedObjectByIndex(nm);
+ SdrObjList* pOL=pObj->GetObjList();
+ if (pOL!=pOL0) {
+ nPos0=-1;
+ pOL0=pOL;
+ }
+ ULONG nPos=pObj->GetOrdNum();
+ bToBtmPossible=nPos>ULONG(nPos0+1);
+ nPos0=long(nPos);
+ nm++;
+ }
+ nm=nAnz;
+ pOL0=NULL;
+ nPos0=0x7FFFFFFF;
+ while (!bToTopPossible && nm>0) { // 'nach vorn' checken
+ nm--;
+ SdrObject* pObj=GetMarkedObjectByIndex(nm);
+ SdrObjList* pOL=pObj->GetObjList();
+ if (pOL!=pOL0) {
+ nPos0=pOL->GetObjCount();
+ pOL0=pOL;
+ }
+ ULONG nPos=pObj->GetOrdNum();
+ bToTopPossible=nPos+1<ULONG(nPos0);
+ nPos0=nPos;
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@ @@@@ @@ @@ @@@@@ @@ @@ @@ @@@@@
+// @@ @@ @@ @@ @@@ @@@ @@ @@ @@ @@@ @@ @@
+// @@ @@ @@ @@@@@@@ @@ @@ @@ @@@@@@ @@
+// @@ @@ @@ @@@@@@@ @@@@@ @@ @@@@@@ @@@@
+// @@ @@ @@ @@ @ @@ @@ @@ @@ @@ @@@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@ @@@@ @@ @@ @@@@@ @@ @@ @@ @@@@@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::ImpCopyAttributes(const SdrObject* pSource, SdrObject* pDest) const
+{
+ if (pSource!=NULL) {
+ SdrObjList* pOL=pSource->GetSubList();
+ if (pOL!=NULL && !pSource->Is3DObj()) { // erstes Nichtgruppenobjekt aus der Gruppe holen
+ SdrObjListIter aIter(*pOL,IM_DEEPNOGROUPS);
+ pSource=aIter.Next();
+ }
+ }
+
+ if(pSource && pDest)
+ {
+ SfxItemSet aSet(pMod->GetItemPool(),
+ SDRATTR_START, SDRATTR_NOTPERSIST_FIRST-1,
+ SDRATTR_NOTPERSIST_LAST+1, SDRATTR_END,
+ EE_ITEMS_START, EE_ITEMS_END,
+ 0, 0); // #52757#, #52762#
+
+ aSet.Put(pSource->GetMergedItemSet());
+
+ pDest->ClearMergedItem();
+ pDest->SetMergedItemSet(aSet);
+
+ pDest->NbcSetLayer(pSource->GetLayer());
+ pDest->NbcSetStyleSheet(pSource->GetStyleSheet(), sal_True);
+ }
+}
+
+sal_Bool SdrEditView::ImpCanConvertForCombine1(const SdrObject* pObj) const
+{
+ // #69711 : new condition IsLine() to be able to combine simple Lines
+ sal_Bool bIsLine(sal_False);
+
+ const SdrPathObj* pPath = PTR_CAST(SdrPathObj,pObj);
+
+ if(pPath)
+ {
+ bIsLine = pPath->IsLine();
+ }
+
+ SdrObjTransformInfoRec aInfo;
+ pObj->TakeObjInfo(aInfo);
+
+ return (aInfo.bCanConvToPath || aInfo.bCanConvToPoly || bIsLine);
+}
+
+sal_Bool SdrEditView::ImpCanConvertForCombine(const SdrObject* pObj) const
+{
+ SdrObjList* pOL = pObj->GetSubList();
+
+ if(pOL && !pObj->Is3DObj())
+ {
+ SdrObjListIter aIter(*pOL, IM_DEEPNOGROUPS);
+
+ while(aIter.IsMore())
+ {
+ SdrObject* pObj1 = aIter.Next();
+
+ // Es muessen alle Member einer Gruppe konvertierbar sein
+ if(!ImpCanConvertForCombine1(pObj1))
+ {
+ return sal_False;
+ }
+ }
+ }
+ else
+ {
+ if(!ImpCanConvertForCombine1(pObj))
+ {
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+basegfx::B2DPolyPolygon SdrEditView::ImpGetPolyPolygon1(const SdrObject* pObj, sal_Bool bCombine) const
+{
+ basegfx::B2DPolyPolygon aRetval;
+ SdrPathObj* pPath = PTR_CAST(SdrPathObj, pObj);
+
+ if(bCombine && pPath && !pObj->GetOutlinerParaObject())
+ {
+ aRetval = pPath->GetPathPoly();
+ }
+ else
+ {
+ SdrObject* pConvObj = pObj->ConvertToPolyObj(bCombine, sal_False);
+
+ if(pConvObj)
+ {
+ SdrObjList* pOL = pConvObj->GetSubList();
+
+ if(pOL)
+ {
+ SdrObjListIter aIter(*pOL, IM_DEEPNOGROUPS);
+
+ while(aIter.IsMore())
+ {
+ SdrObject* pObj1 = aIter.Next();
+ pPath = PTR_CAST(SdrPathObj, pObj1);
+
+ if(pPath)
+ {
+ aRetval.append(pPath->GetPathPoly());
+ }
+ }
+ }
+ else
+ {
+ pPath = PTR_CAST(SdrPathObj, pConvObj);
+
+ if(pPath)
+ {
+ aRetval = pPath->GetPathPoly();
+ }
+ }
+
+ SdrObject::Free( pConvObj );
+ }
+ }
+
+ return aRetval;
+}
+
+basegfx::B2DPolyPolygon SdrEditView::ImpGetPolyPolygon(const SdrObject* pObj, sal_Bool bCombine) const
+{
+ SdrObjList* pOL = pObj->GetSubList();
+
+ if(pOL && !pObj->Is3DObj())
+ {
+ basegfx::B2DPolyPolygon aRetval;
+ SdrObjListIter aIter(*pOL, IM_DEEPNOGROUPS);
+
+ while(aIter.IsMore())
+ {
+ SdrObject* pObj1 = aIter.Next();
+ aRetval.append(ImpGetPolyPolygon1(pObj1, bCombine));
+ }
+
+ return aRetval;
+ }
+ else
+ {
+ return ImpGetPolyPolygon1(pObj, bCombine);
+ }
+}
+
+basegfx::B2DPolygon SdrEditView::ImpCombineToSinglePolygon(const basegfx::B2DPolyPolygon& rPolyPolygon) const
+{
+ const sal_uInt32 nPolyCount(rPolyPolygon.count());
+
+ if(0L == nPolyCount)
+ {
+ return basegfx::B2DPolygon();
+ }
+ else if(1L == nPolyCount)
+ {
+ return rPolyPolygon.getB2DPolygon(0L);
+ }
+ else
+ {
+ basegfx::B2DPolygon aRetval(rPolyPolygon.getB2DPolygon(0L));
+
+ for(sal_uInt32 a(1L); a < nPolyCount; a++)
+ {
+ basegfx::B2DPolygon aCandidate(rPolyPolygon.getB2DPolygon(a));
+
+ if(aRetval.count())
+ {
+ if(aCandidate.count())
+ {
+ const basegfx::B2DPoint aCA(aCandidate.getB2DPoint(0L));
+ const basegfx::B2DPoint aCB(aCandidate.getB2DPoint(aCandidate.count() - 1L));
+ const basegfx::B2DPoint aRA(aRetval.getB2DPoint(0L));
+ const basegfx::B2DPoint aRB(aRetval.getB2DPoint(aRetval.count() - 1L));
+
+ const double fRACA(basegfx::B2DVector(aCA - aRA).getLength());
+ const double fRACB(basegfx::B2DVector(aCB - aRA).getLength());
+ const double fRBCA(basegfx::B2DVector(aCA - aRB).getLength());
+ const double fRBCB(basegfx::B2DVector(aCB - aRB).getLength());
+
+ const double fSmallestRA(fRACA < fRACB ? fRACA : fRACB);
+ const double fSmallestRB(fRBCA < fRBCB ? fRBCA : fRBCB);
+
+ if(fSmallestRA < fSmallestRB)
+ {
+ // flip result
+ aRetval.flip();
+ }
+
+ const double fSmallestCA(fRACA < fRBCA ? fRACA : fRBCA);
+ const double fSmallestCB(fRACB < fRBCB ? fRACB : fRBCB);
+
+ if(fSmallestCB < fSmallestCA)
+ {
+ // flip candidate
+ aCandidate.flip();
+ }
+
+ // append candidate to retval
+ aRetval.append(aCandidate);
+ }
+ }
+ else
+ {
+ aRetval = aCandidate;
+ }
+ }
+
+ return aRetval;
+ }
+}
+
+// for distribution dialog function
+struct ImpDistributeEntry
+{
+ SdrObject* mpObj;
+ INT32 mnPos;
+ INT32 mnLength;
+};
+
+DECLARE_LIST(ImpDistributeEntryList, ImpDistributeEntry*)
+
+void SdrEditView::DistributeMarkedObjects()
+{
+ UINT32 nMark(GetMarkedObjectCount());
+
+ if(nMark > 2)
+ {
+ SfxItemSet aNewAttr(pMod->GetItemPool());
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractSvxDistributeDialog *pDlg = pFact->CreateSvxDistributeDialog(NULL, aNewAttr);
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+
+ UINT16 nResult = pDlg->Execute();
+
+ if(nResult == RET_OK)
+ {
+ SvxDistributeHorizontal eHor = pDlg->GetDistributeHor();
+ SvxDistributeVertical eVer = pDlg->GetDistributeVer();
+ ImpDistributeEntryList aEntryList;
+ UINT32 a, nInsPos, nFullLength;
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo();
+
+ if(eHor != SvxDistributeHorizontalNone)
+ {
+ // build sorted entry list
+ nFullLength = 0L;
+
+ for(a=0;a<nMark;a++)
+ {
+ SdrMark* pMark = GetSdrMarkByIndex(a);
+ ImpDistributeEntry* pNew = new ImpDistributeEntry;
+
+ pNew->mpObj = pMark->GetMarkedSdrObj();
+ nInsPos = 0;
+
+ switch(eHor)
+ {
+ case SvxDistributeHorizontalLeft:
+ {
+ pNew->mnPos = pNew->mpObj->GetSnapRect().Left();
+ break;
+ }
+ case SvxDistributeHorizontalCenter:
+ {
+ pNew->mnPos = (pNew->mpObj->GetSnapRect().Right() + pNew->mpObj->GetSnapRect().Left()) / 2;
+ break;
+ }
+ case SvxDistributeHorizontalDistance:
+ {
+ pNew->mnLength = pNew->mpObj->GetSnapRect().GetWidth() + 1;
+ nFullLength += pNew->mnLength;
+ pNew->mnPos = (pNew->mpObj->GetSnapRect().Right() + pNew->mpObj->GetSnapRect().Left()) / 2;
+ break;
+ }
+ case SvxDistributeHorizontalRight:
+ {
+ pNew->mnPos = pNew->mpObj->GetSnapRect().Right();
+ break;
+ }
+ default: break;
+ }
+
+ while(nInsPos < aEntryList.Count() && aEntryList.GetObject(nInsPos)->mnPos < pNew->mnPos)
+ nInsPos++;
+
+ aEntryList.Insert(pNew, nInsPos);
+ }
+
+ if(eHor == SvxDistributeHorizontalDistance)
+ {
+ // calc room in-between
+ INT32 nWidth = GetAllMarkedBoundRect().GetWidth() + 1;
+ double fStepWidth = ((double)nWidth - (double)nFullLength) / (double)(aEntryList.Count() - 1);
+ double fStepStart = (double)aEntryList.GetObject(0)->mnPos;
+ fStepStart += fStepWidth + (double)((aEntryList.GetObject(0)->mnLength + aEntryList.GetObject(1)->mnLength) / 2);
+
+ // move entries 1..n-1
+ for(a=1;a<aEntryList.Count()-1;a++)
+ {
+ ImpDistributeEntry* pCurr = aEntryList.GetObject(a);
+ ImpDistributeEntry* pNext = aEntryList.GetObject(a+1);
+ INT32 nDelta = (INT32)(fStepStart + 0.5) - pCurr->mnPos;
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj));
+ pCurr->mpObj->Move(Size(nDelta, 0));
+ fStepStart += fStepWidth + (double)((pCurr->mnLength + pNext->mnLength) / 2);
+ }
+ }
+ else
+ {
+ // calc distances
+ INT32 nWidth = aEntryList.GetObject(aEntryList.Count() - 1)->mnPos - aEntryList.GetObject(0)->mnPos;
+ double fStepWidth = (double)nWidth / (double)(aEntryList.Count() - 1);
+ double fStepStart = (double)aEntryList.GetObject(0)->mnPos;
+ fStepStart += fStepWidth;
+
+ // move entries 1..n-1
+ for(a=1;a<aEntryList.Count()-1;a++)
+ {
+ ImpDistributeEntry* pCurr = aEntryList.GetObject(a);
+ INT32 nDelta = (INT32)(fStepStart + 0.5) - pCurr->mnPos;
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj));
+ pCurr->mpObj->Move(Size(nDelta, 0));
+ fStepStart += fStepWidth;
+ }
+ }
+
+ // clear list
+ while(aEntryList.Count())
+ delete aEntryList.Remove((ULONG)0L);
+ }
+
+ if(eVer != SvxDistributeVerticalNone)
+ {
+ // build sorted entry list
+ nFullLength = 0L;
+
+ for(a=0;a<nMark;a++)
+ {
+ SdrMark* pMark = GetSdrMarkByIndex(a);
+ ImpDistributeEntry* pNew = new ImpDistributeEntry;
+
+ pNew->mpObj = pMark->GetMarkedSdrObj();
+ nInsPos = 0;
+
+ switch(eVer)
+ {
+ case SvxDistributeVerticalTop:
+ {
+ pNew->mnPos = pNew->mpObj->GetSnapRect().Top();
+ break;
+ }
+ case SvxDistributeVerticalCenter:
+ {
+ pNew->mnPos = (pNew->mpObj->GetSnapRect().Bottom() + pNew->mpObj->GetSnapRect().Top()) / 2;
+ break;
+ }
+ case SvxDistributeVerticalDistance:
+ {
+ pNew->mnLength = pNew->mpObj->GetSnapRect().GetHeight() + 1;
+ nFullLength += pNew->mnLength;
+ pNew->mnPos = (pNew->mpObj->GetSnapRect().Bottom() + pNew->mpObj->GetSnapRect().Top()) / 2;
+ break;
+ }
+ case SvxDistributeVerticalBottom:
+ {
+ pNew->mnPos = pNew->mpObj->GetSnapRect().Bottom();
+ break;
+ }
+ default: break;
+ }
+
+ while(nInsPos < aEntryList.Count() && aEntryList.GetObject(nInsPos)->mnPos < pNew->mnPos)
+ nInsPos++;
+
+ aEntryList.Insert(pNew, nInsPos);
+ }
+
+ if(eVer == SvxDistributeVerticalDistance)
+ {
+ // calc room in-between
+ INT32 nHeight = GetAllMarkedBoundRect().GetHeight() + 1;
+ double fStepWidth = ((double)nHeight - (double)nFullLength) / (double)(aEntryList.Count() - 1);
+ double fStepStart = (double)aEntryList.GetObject(0)->mnPos;
+ fStepStart += fStepWidth + (double)((aEntryList.GetObject(0)->mnLength + aEntryList.GetObject(1)->mnLength) / 2);
+
+ // move entries 1..n-1
+ for(a=1;a<aEntryList.Count()-1;a++)
+ {
+ ImpDistributeEntry* pCurr = aEntryList.GetObject(a);
+ ImpDistributeEntry* pNext = aEntryList.GetObject(a+1);
+ INT32 nDelta = (INT32)(fStepStart + 0.5) - pCurr->mnPos;
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj));
+ pCurr->mpObj->Move(Size(0, nDelta));
+ fStepStart += fStepWidth + (double)((pCurr->mnLength + pNext->mnLength) / 2);
+ }
+ }
+ else
+ {
+ // calc distances
+ INT32 nHeight = aEntryList.GetObject(aEntryList.Count() - 1)->mnPos - aEntryList.GetObject(0)->mnPos;
+ double fStepWidth = (double)nHeight / (double)(aEntryList.Count() - 1);
+ double fStepStart = (double)aEntryList.GetObject(0)->mnPos;
+ fStepStart += fStepWidth;
+
+ // move entries 1..n-1
+ for(a=1;a<aEntryList.Count()-1;a++)
+ {
+ ImpDistributeEntry* pCurr = aEntryList.GetObject(a);
+ INT32 nDelta = (INT32)(fStepStart + 0.5) - pCurr->mnPos;
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pCurr->mpObj));
+ pCurr->mpObj->Move(Size(0, nDelta));
+ fStepStart += fStepWidth;
+ }
+ }
+
+ // clear list
+ while(aEntryList.Count())
+ delete aEntryList.Remove((ULONG)0L);
+ }
+
+ // UNDO-Comment and end of UNDO
+ SetUndoComment(ImpGetResStr(STR_DistributeMarkedObjects));
+
+ if( bUndo )
+ EndUndo();
+ }
+
+ delete(pDlg);
+ }
+ }
+}
+
+void SdrEditView::MergeMarkedObjects(SdrMergeMode eMode)
+{
+ // #i73441# check content
+ if(AreObjectsMarked())
+ {
+ SdrMarkList aRemove;
+ SortMarkedObjects();
+
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ BegUndo();
+
+ UINT32 nInsPos=0xFFFFFFFF;
+ const SdrObject* pAttrObj = NULL;
+ basegfx::B2DPolyPolygon aMergePolyPolygonA;
+ basegfx::B2DPolyPolygon aMergePolyPolygonB;
+
+ SdrObjList* pInsOL = NULL;
+ SdrPageView* pInsPV = NULL;
+ BOOL bFirstObjectComplete(FALSE);
+
+ // make sure selected objects are contour objects
+ // since now basegfx::tools::adaptiveSubdivide() is used, it is no longer
+ // necessary to use ConvertMarkedToPolyObj which will subdivide curves using the old
+ // mechanisms. In a next step the polygon clipper will even be able to clip curves...
+ // ConvertMarkedToPolyObj(TRUE);
+ ConvertMarkedToPathObj(sal_True);
+ OSL_ENSURE(AreObjectsMarked(), "no more objects selected after preparations (!)");
+
+ for(UINT32 a=0;a<GetMarkedObjectCount();a++)
+ {
+ SdrMark* pM = GetSdrMarkByIndex(a);
+ SdrObject* pObj = pM->GetMarkedSdrObj();
+
+ if(ImpCanConvertForCombine(pObj))
+ {
+ if(!pAttrObj)
+ pAttrObj = pObj;
+
+ nInsPos = pObj->GetOrdNum() + 1;
+ pInsPV = pM->GetPageView();
+ pInsOL = pObj->GetObjList();
+
+ // #i76891# use single iter from SJ here whcih works on SdrObjects and takes
+ // groups into account by itself
+ SdrObjListIter aIter(*pObj, IM_DEEPWITHGROUPS);
+
+ while(aIter.IsMore())
+ {
+ SdrObject* pCandidate = aIter.Next();
+ SdrPathObj* pPathObj = PTR_CAST(SdrPathObj, pCandidate);
+ if(pPathObj)
+ {
+ basegfx::B2DPolyPolygon aTmpPoly(pPathObj->GetPathPoly());
+
+ // #i76891# unfortunately ConvertMarkedToPathObj has converted all
+ // involved polygon data to curve segments, even if not necessary.
+ // It is better to try to reduce to more simple polygons.
+ aTmpPoly = basegfx::tools::simplifyCurveSegments(aTmpPoly);
+
+ // for each part polygon as preparation, remove self-intersections
+ // correct orientations and get rid of evtl. neutral polygons.
+ aTmpPoly = basegfx::tools::prepareForPolygonOperation(aTmpPoly);
+
+ if(!bFirstObjectComplete)
+ {
+ // #i111987# Also need to collect ORed source shape when more than
+ // a single polygon is involved
+ if(aMergePolyPolygonA.count())
+ {
+ aMergePolyPolygonA = basegfx::tools::solvePolygonOperationOr(aMergePolyPolygonA, aTmpPoly);
+ }
+ else
+ {
+ aMergePolyPolygonA = aTmpPoly;
+ }
+ }
+ else
+ {
+ if(aMergePolyPolygonB.count())
+ {
+ // to topologically correctly collect the 2nd polygon
+ // group it is necessary to OR the parts (each is seen as
+ // XOR-FillRule polygon and they are drawn over each-other)
+ aMergePolyPolygonB = basegfx::tools::solvePolygonOperationOr(aMergePolyPolygonB, aTmpPoly);
+ }
+ else
+ {
+ aMergePolyPolygonB = aTmpPoly;
+ }
+ }
+ }
+ }
+
+ // was there something added to the first poly?
+ if(!bFirstObjectComplete && aMergePolyPolygonA.count())
+ {
+ bFirstObjectComplete = TRUE;
+ }
+
+ // move object to temporary delete list
+ aRemove.InsertEntry(SdrMark(pObj, pM->GetPageView()));
+ }
+ }
+
+ switch(eMode)
+ {
+ case SDR_MERGE_MERGE:
+ {
+ // merge all contained parts (OR)
+ static bool bTestXOR(false);
+ if(bTestXOR)
+ {
+ aMergePolyPolygonA = basegfx::tools::solvePolygonOperationXor(aMergePolyPolygonA, aMergePolyPolygonB);
+ }
+ else
+ {
+ aMergePolyPolygonA = basegfx::tools::solvePolygonOperationOr(aMergePolyPolygonA, aMergePolyPolygonB);
+ }
+ break;
+ }
+ case SDR_MERGE_SUBSTRACT:
+ {
+ // Substract B from A
+ aMergePolyPolygonA = basegfx::tools::solvePolygonOperationDiff(aMergePolyPolygonA, aMergePolyPolygonB);
+ break;
+ }
+ case SDR_MERGE_INTERSECT:
+ {
+ // AND B and A
+ aMergePolyPolygonA = basegfx::tools::solvePolygonOperationAnd(aMergePolyPolygonA, aMergePolyPolygonB);
+ break;
+ }
+ }
+
+ // #i73441# check insert list before taking actions
+ if(pInsOL)
+ {
+ SdrPathObj* pPath = new SdrPathObj(OBJ_PATHFILL, aMergePolyPolygonA);
+ ImpCopyAttributes(pAttrObj, pPath);
+ SdrInsertReason aReason(SDRREASON_VIEWCALL, pAttrObj);
+ pInsOL->InsertObject(pPath, nInsPos, &aReason);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath));
+ MarkObj(pPath, pInsPV, FALSE, TRUE);
+ }
+
+ aRemove.ForceSort();
+ switch(eMode)
+ {
+ case SDR_MERGE_MERGE:
+ {
+ SetUndoComment(
+ ImpGetResStr(STR_EditMergeMergePoly),
+ aRemove.GetMarkDescription());
+ break;
+ }
+ case SDR_MERGE_SUBSTRACT:
+ {
+ SetUndoComment(
+ ImpGetResStr(STR_EditMergeSubstractPoly),
+ aRemove.GetMarkDescription());
+ break;
+ }
+ case SDR_MERGE_INTERSECT:
+ {
+ SetUndoComment(
+ ImpGetResStr(STR_EditMergeIntersectPoly),
+ aRemove.GetMarkDescription());
+ break;
+ }
+ }
+ DeleteMarkedList(aRemove);
+
+ if( bUndo )
+ EndUndo();
+ }
+}
+
+void SdrEditView::CombineMarkedObjects(sal_Bool bNoPolyPoly)
+{
+ // #105899# Start of Combine-Undo put to front, else ConvertMarkedToPolyObj would
+ // create a 2nd Undo-action and Undo-Comment.
+
+ bool bUndo = IsUndoEnabled();
+
+ // Undo-String will be set later
+ if( bUndo )
+ BegUndo(String(), String(), bNoPolyPoly ? SDRREPFUNC_OBJ_COMBINE_ONEPOLY : SDRREPFUNC_OBJ_COMBINE_POLYPOLY);
+
+ // #105899# First, guarantee that all objects are converted to polyobjects,
+ // especially for SdrGrafObj with bitmap filling this is necessary to not
+ // loose the bitmap filling.
+
+ // #i12392#
+ // ConvertMarkedToPolyObj was too strong here, it will loose quality and
+ // information when curve objects are combined. This can be replaced by
+ // using ConvertMarkedToPathObj without changing the previous fix.
+
+ // #i21250#
+ // Instead of simply passing sal_True as LineToArea, use bNoPolyPoly as info
+ // if this command is a 'Combine' or a 'Connect' command. On Connect it's sal_True.
+ // To not concert line segments with a set line width to polygons in that case,
+ // use this info. Do not convert LineToArea on Connect commands.
+ // ConvertMarkedToPathObj(!bNoPolyPoly);
+
+ // #114310#
+ // This is used for Combine and Connect. In no case it is necessary to force
+ // the content to curve, but it is also not good to force to polygons. Thus,
+ // curve is the less information loosing one. Remember: This place is not
+ // used for merge.
+ // LineToArea is never necessary, both commands are able to take over the
+ // set line style and to display it correctly. Thus, i will use a
+ // ConvertMarkedToPathObj with a sal_False in any case. Only drawback is that
+ // simple polygons will be changed to curves, but with no information loss.
+ ConvertMarkedToPathObj(sal_False /* bLineToArea */);
+
+ // continue as before
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ SdrObjList* pAktOL = 0L;
+ SdrMarkList aRemoveMerker;
+
+ SortMarkedObjects();
+ sal_uInt32 nInsPos(0xFFFFFFFF);
+ SdrObjList* pInsOL = 0L;
+ SdrPageView* pInsPV = 0L;
+ const sal_uInt32 nAnz(GetMarkedObjectCount());
+ const SdrObject* pAttrObj = 0L;
+
+ for(sal_uInt32 a(nAnz); a > 0L; )
+ {
+ a--;
+ SdrMark* pM = GetSdrMarkByIndex(a);
+ SdrObject* pObj = pM->GetMarkedSdrObj();
+ SdrObjList* pThisOL = pObj->GetObjList();
+
+ if(pAktOL != pThisOL)
+ {
+ pAktOL = pThisOL;
+ }
+
+ if(ImpCanConvertForCombine(pObj))
+ {
+ // Obj merken fuer Attribute kopieren
+ pAttrObj = pObj;
+
+ // unfortunately ConvertMarkedToPathObj has converted all
+ // involved polygon data to curve segments, even if not necessary.
+ // It is better to try to reduce to more simple polygons.
+ basegfx::B2DPolyPolygon aTmpPoly(basegfx::tools::simplifyCurveSegments(ImpGetPolyPolygon(pObj, sal_True)));
+ aPolyPolygon.insert(0L, aTmpPoly);
+
+ if(!pInsOL)
+ {
+ nInsPos = pObj->GetOrdNum() + 1L;
+ pInsPV = pM->GetPageView();
+ pInsOL = pObj->GetObjList();
+ }
+
+ aRemoveMerker.InsertEntry(SdrMark(pObj, pM->GetPageView()));
+ }
+ }
+
+ if(bNoPolyPoly)
+ {
+ basegfx::B2DPolygon aCombinedPolygon(ImpCombineToSinglePolygon(aPolyPolygon));
+ aPolyPolygon.clear();
+ aPolyPolygon.append(aCombinedPolygon);
+ }
+
+ const sal_uInt32 nPolyCount(aPolyPolygon.count());
+
+ if(nPolyCount)
+ {
+ SdrObjKind eKind = OBJ_PATHFILL;
+
+ if(nPolyCount > 1L)
+ {
+ aPolyPolygon.setClosed(true);
+ }
+ else
+ {
+ // auf Polyline Checken
+ const basegfx::B2DPolygon aPolygon(aPolyPolygon.getB2DPolygon(0L));
+ const sal_uInt32 nPointCount(aPolygon.count());
+
+ if(nPointCount <= 2L)
+ {
+ eKind = OBJ_PATHLINE;
+ }
+ else
+ {
+ if(!aPolygon.isClosed())
+ {
+ const basegfx::B2DPoint aPointA(aPolygon.getB2DPoint(0L));
+ const basegfx::B2DPoint aPointB(aPolygon.getB2DPoint(nPointCount - 1L));
+ const double fDistance(basegfx::B2DVector(aPointB - aPointA).getLength());
+ const double fJoinTolerance(10.0);
+
+ if(fDistance < fJoinTolerance)
+ {
+ aPolyPolygon.setClosed(true);
+ }
+ else
+ {
+ eKind = OBJ_PATHLINE;
+ }
+ }
+ }
+ }
+
+ SdrPathObj* pPath = new SdrPathObj(eKind,aPolyPolygon);
+
+ // Attribute des untersten Objekts
+ ImpCopyAttributes(pAttrObj, pPath);
+
+ // #100408# If LineStyle of pAttrObj is XLINE_NONE force to XLINE_SOLID to make visible.
+ const XLineStyle eLineStyle = ((const XLineStyleItem&)pAttrObj->GetMergedItem(XATTR_LINESTYLE)).GetValue();
+ const XFillStyle eFillStyle = ((const XFillStyleItem&)pAttrObj->GetMergedItem(XATTR_FILLSTYLE)).GetValue();
+
+ // #110635#
+ // Take fill style/closed state of pAttrObj in account when deciding to change the line style
+ sal_Bool bIsClosedPathObj(pAttrObj->ISA(SdrPathObj) && ((SdrPathObj*)pAttrObj)->IsClosed());
+
+ if(XLINE_NONE == eLineStyle && (XFILL_NONE == eFillStyle || !bIsClosedPathObj))
+ {
+ pPath->SetMergedItem(XLineStyleItem(XLINE_SOLID));
+ }
+
+ SdrInsertReason aReason(SDRREASON_VIEWCALL,pAttrObj);
+ pInsOL->InsertObject(pPath,nInsPos,&aReason);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath));
+
+ // #111111#
+ // Here was a severe error: Without UnmarkAllObj, the new object was marked
+ // additionally to the two ones which are deleted below. As long as those are
+ // in the UNDO there is no problem, but as soon as they get deleted, the
+ // MarkList will contain deleted objects -> GPF.
+ UnmarkAllObj(pInsPV);
+ MarkObj(pPath, pInsPV, FALSE, TRUE);
+ }
+
+ // UndoComment aus den tatsaechlich verwendeten Objekten zusammenbauen
+ aRemoveMerker.ForceSort(); // wichtig fuer Remove (s.u.)
+ if( bUndo )
+ SetUndoComment(ImpGetResStr(bNoPolyPoly?STR_EditCombine_OnePoly:STR_EditCombine_PolyPoly),aRemoveMerker.GetMarkDescription());
+
+ // die tatsaechlich verwendeten Objekten aus der Liste entfernen
+ DeleteMarkedList(aRemoveMerker);
+ if( bUndo )
+ EndUndo();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@ @@ @@@@ @@ @@ @@@@ @@ @@ @@@@@@ @@ @@@@@
+// @@ @@ @@ @@ @@ @@@ @@@ @@ @@ @@@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@@@@@@ @@ @@ @@@@@@ @@ @@ @@
+// @@ @@ @@ @@@@ @@@@@@@ @@@@@@ @@@@@@ @@ @@ @@@@
+// @@ @@ @@ @@ @@ @ @@ @@ @@ @@ @@@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@@ @@ @@@@ @@ @@ @@ @@ @@ @@ @@ @@@@@ @@@@@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_Bool SdrEditView::ImpCanDismantle(const basegfx::B2DPolyPolygon& rPpolyPolygon, sal_Bool bMakeLines) const
+{
+ sal_Bool bCan(sal_False);
+ const sal_uInt32 nPolygonCount(rPpolyPolygon.count());
+
+ if(nPolygonCount >= 2L)
+ {
+ // #i69172# dismantle makes sense with 2 or more polygons in a polyPolygon
+ bCan = sal_True;
+ }
+ else if(bMakeLines && 1L == nPolygonCount)
+ {
+ // #i69172# ..or with at least 2 edges (curves or lines)
+ const basegfx::B2DPolygon aPolygon(rPpolyPolygon.getB2DPolygon(0L));
+ const sal_uInt32 nPointCount(aPolygon.count());
+
+ if(nPointCount > 2L)
+ {
+ bCan = sal_True;
+ }
+ }
+
+ return bCan;
+}
+
+sal_Bool SdrEditView::ImpCanDismantle(const SdrObject* pObj, sal_Bool bMakeLines) const
+{
+ sal_Bool bOtherObjs(sal_False); // TRUE=andere Objekte ausser PathObj's vorhanden
+ sal_Bool bMin1PolyPoly(sal_False); // TRUE=mind. 1 PolyPolygon mit mehr als ein Polygon vorhanden
+ SdrObjList* pOL = pObj->GetSubList();
+
+ if(pOL)
+ {
+ // Aha, Gruppenobjekt. Also alle Member ansehen.
+ // Alle muessen PathObjs sein !
+ SdrObjListIter aIter(*pOL, IM_DEEPNOGROUPS);
+
+ while(aIter.IsMore() && !bOtherObjs)
+ {
+ const SdrObject* pObj1 = aIter.Next();
+ const SdrPathObj* pPath = PTR_CAST(SdrPathObj, pObj1);
+
+ if(pPath)
+ {
+ if(ImpCanDismantle(pPath->GetPathPoly(), bMakeLines))
+ {
+ bMin1PolyPoly = sal_True;
+ }
+
+ SdrObjTransformInfoRec aInfo;
+ pObj1->TakeObjInfo(aInfo);
+
+ if(!aInfo.bCanConvToPath)
+ {
+ // Passiert z.B. im Falle Fontwork (Joe, 28-11-95)
+ bOtherObjs = sal_True;
+ }
+ }
+ else
+ {
+ bOtherObjs = sal_True;
+ }
+ }
+ }
+ else
+ {
+ const SdrPathObj* pPath = PTR_CAST(SdrPathObj, pObj);
+ const SdrObjCustomShape* pCustomShape = PTR_CAST(SdrObjCustomShape, pObj);
+
+ // #i37011#
+ if(pPath)
+ {
+ if(ImpCanDismantle(pPath->GetPathPoly(),bMakeLines))
+ {
+ bMin1PolyPoly = sal_True;
+ }
+
+ SdrObjTransformInfoRec aInfo;
+ pObj->TakeObjInfo(aInfo);
+
+ // #69711 : new condition IsLine() to be able to break simple Lines
+ if(!(aInfo.bCanConvToPath || aInfo.bCanConvToPoly) && !pPath->IsLine())
+ {
+ // Passiert z.B. im Falle Fontwork (Joe, 28-11-95)
+ bOtherObjs = sal_True;
+ }
+ }
+ else if(pCustomShape)
+ {
+ if(bMakeLines)
+ {
+ // allow break command
+ bMin1PolyPoly = sal_True;
+ }
+ }
+ else
+ {
+ bOtherObjs = sal_True;
+ }
+ }
+ return bMin1PolyPoly && !bOtherObjs;
+}
+
+void SdrEditView::ImpDismantleOneObject(const SdrObject* pObj, SdrObjList& rOL, ULONG& rPos, SdrPageView* pPV, BOOL bMakeLines)
+{
+ const SdrPathObj* pSrcPath = PTR_CAST(SdrPathObj, pObj);
+ const SdrObjCustomShape* pCustomShape = PTR_CAST(SdrObjCustomShape, pObj);
+
+ const bool bUndo = IsUndoEnabled();
+
+ if(pSrcPath)
+ {
+ // #i74631# redesigned due to XpolyPolygon removal and explicit constructors
+ SdrObject* pLast = 0; // fuer die Zuweisung des OutlinerParaObject
+ const basegfx::B2DPolyPolygon& rPolyPolygon(pSrcPath->GetPathPoly());
+ const sal_uInt32 nPolyCount(rPolyPolygon.count());
+
+ for(sal_uInt32 a(0); a < nPolyCount; a++)
+ {
+ const basegfx::B2DPolygon& rCandidate(rPolyPolygon.getB2DPolygon(a));
+ const sal_uInt32 nPointCount(rCandidate.count());
+
+ if(!bMakeLines || nPointCount < 2)
+ {
+ SdrPathObj* pPath = new SdrPathObj((SdrObjKind)pSrcPath->GetObjIdentifier(), basegfx::B2DPolyPolygon(rCandidate));
+ ImpCopyAttributes(pSrcPath, pPath);
+ pLast = pPath;
+ SdrInsertReason aReason(SDRREASON_VIEWCALL, pSrcPath);
+ rOL.InsertObject(pPath, rPos, &aReason);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath, TRUE));
+ MarkObj(pPath, pPV, FALSE, TRUE);
+ rPos++;
+ }
+ else
+ {
+ const sal_uInt32 nLoopCount(rCandidate.isClosed() ? nPointCount : nPointCount - 1);
+
+ for(sal_uInt32 b(0); b < nLoopCount; b++)
+ {
+ SdrObjKind eKind(OBJ_PLIN);
+ basegfx::B2DPolygon aNewPolygon;
+ const sal_uInt32 nNextIndex((b + 1) % nPointCount);
+
+ aNewPolygon.append(rCandidate.getB2DPoint(b));
+
+ if(rCandidate.areControlPointsUsed())
+ {
+ aNewPolygon.appendBezierSegment(
+ rCandidate.getNextControlPoint(b),
+ rCandidate.getPrevControlPoint(nNextIndex),
+ rCandidate.getB2DPoint(nNextIndex));
+ eKind = OBJ_PATHLINE;
+ }
+ else
+ {
+ aNewPolygon.append(rCandidate.getB2DPoint(nNextIndex));
+ }
+
+ SdrPathObj* pPath = new SdrPathObj(eKind, basegfx::B2DPolyPolygon(aNewPolygon));
+ ImpCopyAttributes(pSrcPath, pPath);
+ pLast = pPath;
+ SdrInsertReason aReason(SDRREASON_VIEWCALL, pSrcPath);
+ rOL.InsertObject(pPath, rPos, &aReason);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pPath, TRUE));
+ MarkObj(pPath, pPV, FALSE, TRUE);
+ rPos++;
+ }
+ }
+ }
+
+ if(pLast && pSrcPath->GetOutlinerParaObject())
+ {
+ pLast->SetOutlinerParaObject(new OutlinerParaObject(*pSrcPath->GetOutlinerParaObject()));
+ }
+ }
+ else if(pCustomShape)
+ {
+ if(bMakeLines)
+ {
+ // break up custom shape
+ const SdrObject* pReplacement = pCustomShape->GetSdrObjectFromCustomShape();
+
+ if(pReplacement)
+ {
+ SdrObject* pCandidate = pReplacement->Clone();
+ DBG_ASSERT(pCandidate, "SdrEditView::ImpDismantleOneObject: Could not clone SdrObject (!)");
+ pCandidate->SetModel(pCustomShape->GetModel());
+
+ if(((SdrShadowItem&)pCustomShape->GetMergedItem(SDRATTR_SHADOW)).GetValue())
+ {
+ if(pReplacement->ISA(SdrObjGroup))
+ {
+ pCandidate->SetMergedItem(SdrShadowItem(sal_True));
+ }
+ }
+
+ SdrInsertReason aReason(SDRREASON_VIEWCALL, pCustomShape);
+ rOL.InsertObject(pCandidate, rPos, &aReason);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pCandidate, true));
+ MarkObj(pCandidate, pPV, FALSE, TRUE);
+
+ if(pCustomShape->HasText() && !pCustomShape->IsTextPath())
+ {
+ // #i37011# also create a text object and add at rPos + 1
+ SdrTextObj* pTextObj = (SdrTextObj*)SdrObjFactory::MakeNewObject(
+ pCustomShape->GetObjInventor(), OBJ_TEXT, 0L, pCustomShape->GetModel());
+
+ // Copy text content
+ OutlinerParaObject* pParaObj = pCustomShape->GetOutlinerParaObject();
+ if(pParaObj)
+ {
+ pTextObj->NbcSetOutlinerParaObject(new OutlinerParaObject(*pParaObj));
+ }
+
+ // copy all attributes
+ SfxItemSet aTargetItemSet(pCustomShape->GetMergedItemSet());
+
+ // clear fill and line style
+ aTargetItemSet.Put(XLineStyleItem(XLINE_NONE));
+ aTargetItemSet.Put(XFillStyleItem(XFILL_NONE));
+
+ // get the text bounds and set at text object
+ Rectangle aTextBounds = pCustomShape->GetSnapRect();
+ if(pCustomShape->GetTextBounds(aTextBounds))
+ {
+ pTextObj->SetSnapRect(aTextBounds);
+ }
+
+ // if rotated, copy GeoStat, too.
+ const GeoStat& rSourceGeo = pCustomShape->GetGeoStat();
+ if(rSourceGeo.nDrehWink)
+ {
+ pTextObj->NbcRotate(
+ pCustomShape->GetSnapRect().Center(), rSourceGeo.nDrehWink,
+ rSourceGeo.nSin, rSourceGeo.nCos);
+ }
+
+ // set modified ItemSet at text object
+ pTextObj->SetMergedItemSet(aTargetItemSet);
+
+ // insert object
+ rOL.InsertObject(pTextObj, rPos + 1, &aReason);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pTextObj, true));
+ MarkObj(pTextObj, pPV, FALSE, TRUE);
+ }
+ }
+ }
+ }
+}
+
+void SdrEditView::DismantleMarkedObjects(BOOL bMakeLines)
+{
+ //UINT32 nCnt(0);
+ // Temporaere Marklist
+ SdrMarkList aRemoveMerker;
+
+ SortMarkedObjects();
+
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ {
+ // Der Comment wird spaeter zusammengebaut
+ BegUndo(String(), String(),
+ bMakeLines ? SDRREPFUNC_OBJ_DISMANTLE_LINES : SDRREPFUNC_OBJ_DISMANTLE_POLYS);
+ }
+
+ ULONG nm;
+ ULONG nAnz=GetMarkedObjectCount();
+ SdrObjList* pOL0=NULL;
+ for (nm=nAnz; nm>0;) {
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrPageView* pPV=pM->GetPageView();
+ SdrObjList* pOL=pObj->GetObjList();
+ if (pOL!=pOL0) { pOL0=pOL; pObj->GetOrdNum(); } // sicherstellen, dass OrdNums stimmen!
+ if (ImpCanDismantle(pObj,bMakeLines)) {
+ aRemoveMerker.InsertEntry(SdrMark(pObj,pM->GetPageView()));
+ ULONG nPos0=pObj->GetOrdNumDirect();
+ ULONG nPos=nPos0+1;
+ SdrObjList* pSubList=pObj->GetSubList();
+ if (pSubList!=NULL && !pObj->Is3DObj()) {
+ SdrObjListIter aIter(*pSubList,IM_DEEPNOGROUPS);
+ while (aIter.IsMore()) {
+ const SdrObject* pObj1=aIter.Next();
+ ImpDismantleOneObject(pObj1,*pOL,nPos,pPV,bMakeLines);
+ }
+ } else {
+ ImpDismantleOneObject(pObj,*pOL,nPos,pPV,bMakeLines);
+ }
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj,TRUE));
+ pOL->RemoveObject(nPos0);
+
+ if( !bUndo )
+ SdrObject::Free(pObj);
+ }
+ }
+
+ if( bUndo )
+ {
+ // UndoComment aus den tatsaechlich verwendeten Objekten zusammenbauen
+ SetUndoComment(ImpGetResStr(bMakeLines?STR_EditDismantle_Lines:STR_EditDismantle_Polys),aRemoveMerker.GetMarkDescription());
+ // die tatsaechlich verwendeten Objekten aus der Liste entfernen
+ EndUndo();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// #### #### ### # # ####
+// # # # # # # # # #
+// # ## #### # # # # ####
+// # # # # # # # # #
+// #### # # ### ### #
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::GroupMarked(const SdrObject* pUserGrp)
+{
+ if (AreObjectsMarked())
+ {
+ SortMarkedObjects();
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ {
+ BegUndo(ImpGetResStr(STR_EditGroup),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_GROUP);
+
+ const ULONG nAnz = GetMarkedObjectCount();
+ for(ULONG nm = nAnz; nm>0; )
+ {
+ // UndoActions fuer alle betroffenen Objekte anlegen
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj = pM->GetMarkedSdrObj();
+ std::vector< SdrUndoAction* > vConnectorUndoActions( CreateConnectorUndo( *pObj ) );
+ AddUndoActions( vConnectorUndoActions );
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject( *pObj ));
+ }
+ }
+
+ SdrMarkList aNewMark;
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ SdrObjList* pAktLst=pPV->GetObjList();
+ SdrObjList* pSrcLst=pAktLst;
+ SdrObjList* pSrcLst0=pSrcLst;
+ SdrPage* pPage=pPV->GetPage();
+ // sicherstellen, dass die OrdNums stimmen
+ if (pSrcLst->IsObjOrdNumsDirty())
+ pSrcLst->RecalcObjOrdNums();
+ SdrObject* pGrp=NULL;
+ SdrObject* pRefObj=NULL; // Referenz fuer InsertReason (-> rumankern im Writer)
+ SdrObject* pRefObj1=NULL; // Referenz fuer InsertReason (-> rumankern im Writer)
+ SdrObjList* pDstLst=NULL;
+ // Falls alle markierten Objekte aus Fremden Obj-Listen
+ // kommen, kommt das Gruppenobjekt an das Ende der Liste.
+ ULONG nInsPos=pSrcLst->GetObjCount();
+ BOOL bNeedInsPos=TRUE;
+ for (ULONG nm=GetMarkedObjectCount(); nm>0;)
+ {
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ if (pM->GetPageView()==pPV)
+ {
+ if (pGrp==NULL)
+ {
+ if (pUserGrp!=NULL)
+ pGrp=pUserGrp->Clone();
+ if (pGrp==NULL)
+ pGrp=new SdrObjGroup;
+ pDstLst=pGrp->GetSubList();
+ DBG_ASSERT(pDstLst!=NULL,"Angebliches Gruppenobjekt liefert keine Objektliste");
+ }
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ pSrcLst=pObj->GetObjList();
+ if (pSrcLst!=pSrcLst0)
+ {
+ if (pSrcLst->IsObjOrdNumsDirty())
+ pSrcLst->RecalcObjOrdNums();
+ }
+ BOOL bForeignList=pSrcLst!=pAktLst;
+ BOOL bGrouped=pSrcLst!=pPage;
+ if (!bForeignList && bNeedInsPos)
+ {
+ nInsPos=pObj->GetOrdNum(); // ua, damit sind alle ObjOrdNum der Page gesetzt
+ nInsPos++;
+ bNeedInsPos=FALSE;
+ }
+ pSrcLst->RemoveObject(pObj->GetOrdNumDirect());
+ if (!bForeignList)
+ nInsPos--; // InsertPos korregieren
+ SdrInsertReason aReason(SDRREASON_VIEWCALL);
+ pDstLst->InsertObject(pObj,0,&aReason);
+ GetMarkedObjectListWriteAccess().DeleteMark(nm);
+ if (pRefObj1==NULL)
+ pRefObj1=pObj; // Das oberste sichtbare Objekt
+ if (!bGrouped)
+ {
+ if (pRefObj==NULL)
+ pRefObj=pObj; // Das oberste sichtbare nicht gruppierte Objekt
+ }
+ pSrcLst0=pSrcLst;
+ }
+ }
+ if (pRefObj==NULL)
+ pRefObj=pRefObj1;
+ if (pGrp!=NULL)
+ {
+ aNewMark.InsertEntry(SdrMark(pGrp,pPV));
+ ULONG nAnz=pDstLst->GetObjCount();
+ SdrInsertReason aReason(SDRREASON_VIEWCALL,pRefObj);
+ pAktLst->InsertObject(pGrp,nInsPos,&aReason);
+ if( bUndo )
+ {
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pGrp,true)); // Kein Recalc!
+ for (ULONG no=0; no<nAnz; no++)
+ {
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoInsertObject(*pDstLst->GetObj(no)));
+ }
+ }
+ }
+ }
+ GetMarkedObjectListWriteAccess().Merge(aNewMark);
+ MarkListHasChanged();
+
+ if( bUndo )
+ EndUndo();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// # # # # #### #### ### # # ####
+// # # ## # # # # # # # # # #
+// # # # # # # ## #### # # # # ####
+// # # # ## # # # # # # # # #
+// ### # # #### # # ### ### #
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::UnGroupMarked()
+{
+ SdrMarkList aNewMark;
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo(String(), String(), SDRREPFUNC_OBJ_UNGROUP);
+
+ ULONG nCount=0;
+ XubString aName1;
+ XubString aName;
+ BOOL bNameOk=FALSE;
+ for (ULONG nm=GetMarkedObjectCount(); nm>0;) {
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pGrp=pM->GetMarkedSdrObj();
+ SdrObjList* pSrcLst=pGrp->GetSubList();
+ if (pSrcLst!=NULL) {
+ nCount++;
+ if (nCount==1) {
+ pGrp->TakeObjNameSingul(aName); // Bezeichnung der Gruppe holen
+ pGrp->TakeObjNamePlural(aName1); // Bezeichnung der Gruppe holen
+ bNameOk=TRUE;
+ } else {
+ if (nCount==2) aName=aName1; // Pluralname setzen
+ if (bNameOk) {
+ XubString aStr;
+ pGrp->TakeObjNamePlural(aStr); // Bezeichnung der Gruppe holen
+
+ if(!aStr.Equals(aName))
+ bNameOk = FALSE;
+ }
+ }
+ ULONG nDstCnt=pGrp->GetOrdNum();
+ SdrObjList* pDstLst=pM->GetPageView()->GetObjList();
+
+ // FIRST move contained objects to parent of group, so that
+ // the contained objects are NOT migrated to the UNDO-ItemPool
+ // when AddUndo(new SdrUndoDelObj(*pGrp)) is called.
+ ULONG nAnz=pSrcLst->GetObjCount();
+ ULONG no;
+
+ if( bUndo )
+ {
+ for (no=nAnz; no>0;)
+ {
+ no--;
+ SdrObject* pObj=pSrcLst->GetObj(no);
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoRemoveObject(*pObj));
+ }
+ }
+ for (no=0; no<nAnz; no++)
+ {
+ SdrObject* pObj=pSrcLst->RemoveObject(0);
+ SdrInsertReason aReason(SDRREASON_VIEWCALL,pGrp);
+ pDstLst->InsertObject(pObj,nDstCnt,&aReason);
+ if( bUndo )
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoInsertObject(*pObj,true));
+ nDstCnt++;
+ // Kein SortCheck beim einfuegen in die MarkList, denn das
+ // wuerde wg. pObj->GetOrdNum() jedesmal ein RecalcOrdNums()
+ // provozieren:
+ aNewMark.InsertEntry(SdrMark(pObj,pM->GetPageView()),FALSE);
+ }
+
+ if( bUndo )
+ {
+ // Now it is safe to add the delete-UNDO which trigers the
+ // MigrateItemPool now only for itself, not for the subobjects.
+ // nDstCnt is right, because previous inserts move group
+ // object deeper and increase nDstCnt.
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pGrp));
+ }
+ pDstLst->RemoveObject(nDstCnt);
+
+ if( !bUndo )
+ SdrObject::Free(pGrp);
+
+ GetMarkedObjectListWriteAccess().DeleteMark(nm);
+ }
+ }
+ if (nCount!=0)
+ {
+ if (!bNameOk)
+ aName=ImpGetResStr(STR_ObjNamePluralGRUP); // Oberbegriff Gruppenobjekte verwenden, wenn verschiedene Objekte.
+ SetUndoComment(ImpGetResStr(STR_EditUngroup),aName);
+ }
+
+ if( bUndo )
+ EndUndo();
+
+ if (nCount!=0)
+ {
+ GetMarkedObjectListWriteAccess().Merge(aNewMark,TRUE); // Durch das obige Einsortieren ist aNewMark genau verkehrtherum
+ MarkListHasChanged();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// ### ### # # # # ##### #### ##### ##### ### #### ### # # #
+// # # # # ## # # # # # # # # # # # # # # # # #
+// # # # # # # # # #### #### # # # # #### # # # #
+// # # # # # ## # # # # # # # # # # # # # #
+// ### ### # # # ##### # # # # ### # ### #### #
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrObject* SdrEditView::ImpConvertOneObj(SdrObject* pObj, BOOL bPath, BOOL bLineToArea)
+{
+ SdrObject* pNewObj = pObj->ConvertToPolyObj(bPath, bLineToArea);
+ if (pNewObj!=NULL)
+ {
+ SdrObjList* pOL=pObj->GetObjList();
+ DBG_ASSERT(pOL!=NULL,"ConvertTo: Obj liefert keine ObjList");
+ if (pOL!=NULL)
+ {
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoReplaceObject(*pObj,*pNewObj));
+
+ pOL->ReplaceObject(pNewObj,pObj->GetOrdNum());
+
+ if( !bUndo )
+ SdrObject::Free(pObj);
+ }
+ }
+ return pNewObj;
+}
+
+void SdrEditView::ImpConvertTo(BOOL bPath, BOOL bLineToArea)
+{
+ BOOL bMrkChg=FALSE;
+ BOOL bModChg=FALSE;
+ if (AreObjectsMarked()) {
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ USHORT nDscrID=0;
+ if(bLineToArea)
+ {
+ if(nMarkAnz == 1)
+ nDscrID = STR_EditConvToContour;
+ else
+ nDscrID = STR_EditConvToContours;
+
+ BegUndo(ImpGetResStr(nDscrID), GetDescriptionOfMarkedObjects());
+ }
+ else
+ {
+ if (bPath) {
+ if (nMarkAnz==1) nDscrID=STR_EditConvToCurve;
+ else nDscrID=STR_EditConvToCurves;
+ BegUndo(ImpGetResStr(nDscrID),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_CONVERTTOPATH);
+ } else {
+ if (nMarkAnz==1) nDscrID=STR_EditConvToPoly;
+ else nDscrID=STR_EditConvToPolys;
+ BegUndo(ImpGetResStr(nDscrID),GetDescriptionOfMarkedObjects(),SDRREPFUNC_OBJ_CONVERTTOPOLY);
+ }
+ }
+ for (ULONG nm=nMarkAnz; nm>0;) {
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrPageView* pPV=pM->GetPageView();
+ if (pObj->IsGroupObject() && !pObj->Is3DObj()) {
+ SdrObject* pGrp=pObj;
+ SdrObjListIter aIter(*pGrp,IM_DEEPNOGROUPS);
+ while (aIter.IsMore()) {
+ pObj=aIter.Next();
+ if (ImpConvertOneObj(pObj,bPath,bLineToArea)) bModChg=TRUE;
+ }
+ } else {
+ SdrObject* pNewObj=ImpConvertOneObj(pObj,bPath,bLineToArea);
+ if (pNewObj!=NULL) {
+ bModChg=TRUE;
+ bMrkChg=TRUE;
+ GetMarkedObjectListWriteAccess().ReplaceMark(SdrMark(pNewObj,pPV),nm);
+ }
+ }
+ }
+ EndUndo();
+ if (bMrkChg) AdjustMarkHdl();
+ if (bMrkChg) MarkListHasChanged();
+ }
+}
+
+void SdrEditView::ConvertMarkedToPathObj(BOOL bLineToArea)
+{
+ ImpConvertTo(TRUE, bLineToArea);
+}
+
+void SdrEditView::ConvertMarkedToPolyObj(BOOL bLineToArea)
+{
+ ImpConvertTo(FALSE, bLineToArea);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// # # ##### ##### ### ##### # # ##### # # # #### ### #### #####
+// ## ## # # # # # # # # # ## ## # # # # # # #
+// # # # #### # ##### ### # # #### ### # # # # #### # # #### #
+// # # # # # # # # # # # # # # # # # # #
+// # # ##### # # # # # #### ##### # # # # ### # # #
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEditView::DoImportMarkedMtf(SvdProgressInfo *pProgrInfo)
+{
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ BegUndo(String(), String(), SDRREPFUNC_OBJ_IMPORTMTF);
+
+ SortMarkedObjects();
+ SdrMarkList aForTheDescription;
+ SdrMarkList aNewMarked;
+ ULONG nAnz=GetMarkedObjectCount();
+
+ for (ULONG nm=nAnz; nm>0;)
+ { // Undo Objekte fuer alle neuen Objekte erzeugen
+ // zwischen den Metafiles auf Abbruch testen
+ if( pProgrInfo != NULL )
+ {
+ pProgrInfo->SetNextObject();
+ if(!pProgrInfo->ReportActions(0))
+ break;
+ }
+
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrPageView* pPV=pM->GetPageView();
+ SdrObjList* pOL=pObj->GetObjList();
+ ULONG nInsPos=pObj->GetOrdNum()+1;
+ SdrGrafObj* pGraf=PTR_CAST(SdrGrafObj,pObj);
+ SdrOle2Obj* pOle2=PTR_CAST(SdrOle2Obj,pObj);
+ ULONG nInsAnz=0;
+ if (pGraf!=NULL && pGraf->HasGDIMetaFile())
+ {
+ ImpSdrGDIMetaFileImport aFilter(*pMod);
+ aFilter.SetScaleRect(pGraf->GetSnapRect());
+ aFilter.SetLayer(pObj->GetLayer());
+ nInsAnz=aFilter.DoImport(pGraf->GetTransformedGraphic().GetGDIMetaFile(),*pOL,nInsPos,pProgrInfo);
+ }
+ if ( pOle2!=NULL && pOle2->GetGraphic() )
+ {
+ //const GDIMetaFile* pMtf=pOle2->GetGDIMetaFile();
+ ImpSdrGDIMetaFileImport aFilter(*pMod);
+ aFilter.SetScaleRect(pOle2->GetLogicRect());
+ aFilter.SetLayer(pObj->GetLayer());
+ nInsAnz=aFilter.DoImport(pOle2->GetGraphic()->GetGDIMetaFile(),*pOL,nInsPos,pProgrInfo);
+ }
+ if (nInsAnz!=0)
+ {
+ ULONG nObj=nInsPos;
+ for (ULONG i=0; i<nInsAnz; i++)
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pOL->GetObj(nObj)));
+
+ // Neue MarkList pflegen
+ SdrMark aNewMark(pOL->GetObj(nObj), pPV);
+ aNewMarked.InsertEntry(aNewMark);
+
+ nObj++;
+ }
+ aForTheDescription.InsertEntry(*pM);
+
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
+
+ // Objekt aus selektion loesen und loeschen
+ GetMarkedObjectListWriteAccess().DeleteMark(TryToFindMarkedObject(pObj));
+ pOL->RemoveObject(nInsPos-1);
+
+ if( !bUndo )
+ SdrObject::Free(pObj);
+ }
+ }
+
+ // MarkObj... fehlt... jetzt nicht mehr (AW)
+ if(aNewMarked.GetMarkCount())
+ {
+ // Neue Selektion bilden
+ for(ULONG a(0); a < aNewMarked.GetMarkCount(); a++)
+ {
+ GetMarkedObjectListWriteAccess().InsertEntry(*aNewMarked.GetMark(a));
+ }
+
+ SortMarkedObjects();
+ }
+
+ if( bUndo )
+ {
+ SetUndoComment(ImpGetResStr(STR_EditImportMtf),aForTheDescription.GetMarkDescription());
+ EndUndo();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
new file mode 100644
index 000000000000..2be2f0f452a9
--- /dev/null
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -0,0 +1,2146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/i18n/WordType.hpp>
+
+#include <svtools/accessibilityoptions.hxx>
+
+#include <svx/svdedxv.hxx>
+#include <svl/solar.hrc>
+
+#include <svl/itemiter.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/hatch.hxx>
+#include <svl/whiter.hxx>
+#include <svl/style.hxx>
+#include <editeng/editstat.hxx>
+#include <tools/config.hxx>
+#include <vcl/cursor.hxx>
+#include <editeng/unotext.hxx>
+
+#include <editeng/editeng.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include "svditext.hxx"
+#include <svx/svdoutl.hxx>
+#include <svx/sdtfchim.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdundo.hxx>
+#include "svditer.hxx"
+#include "svx/svdpagv.hxx"
+#include "svx/svdpage.hxx"
+#include "svx/svdetc.hxx" // fuer GetDraftFillColor
+#include "svx/svdotable.hxx"
+#include <svx/selectioncontroller.hxx>
+#ifdef DBG_UTIL
+#include <svdibrow.hxx>
+#endif
+
+#include <svx/svdoutl.hxx>
+#include <svx/svddrgv.hxx> // fuer SetSolidDragging()
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+#include "globl3d.hxx"
+#include <editeng/outliner.hxx>
+#include <editeng/adjitem.hxx>
+
+// #98988#
+#include <svtools/colorcfg.hxx>
+#include <vcl/svapp.hxx> //add CHINA001
+#include <sdrpaintwindow.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrObjEditView::ImpClearVars()
+{
+ bQuickTextEditMode=TRUE;
+ bMacroMode=TRUE;
+ pTextEditOutliner=NULL;
+ pTextEditOutlinerView=NULL;
+ pTextEditPV=NULL;
+ pTextEditWin=NULL;
+ pTextEditCursorMerker=NULL;
+ pEditPara=NULL;
+ bTextEditNewObj=FALSE;
+ bMacroDown=FALSE;
+ pMacroObj=NULL;
+ pMacroPV=NULL;
+ pMacroWin=NULL;
+ nMacroTol=0;
+ bTextEditDontDelete=FALSE;
+ bTextEditOnlyOneView=FALSE;
+}
+
+SdrObjEditView::SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrGlueEditView(pModel1,pOut)
+{
+ ImpClearVars();
+}
+
+SdrObjEditView::~SdrObjEditView()
+{
+ pTextEditWin = NULL; // Damit es in SdrEndTextEdit kein ShowCursor gibt
+ if (IsTextEdit()) SdrEndTextEdit();
+ if (pTextEditOutliner!=NULL) {
+ delete pTextEditOutliner;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrObjEditView::IsAction() const
+{
+ return IsMacroObj() || SdrGlueEditView::IsAction();
+}
+
+void SdrObjEditView::MovAction(const Point& rPnt)
+{
+ if (IsMacroObj()) MovMacroObj(rPnt);
+ SdrGlueEditView::MovAction(rPnt);
+}
+
+void SdrObjEditView::EndAction()
+{
+ if (IsMacroObj()) EndMacroObj();
+ SdrGlueEditView::EndAction();
+}
+
+void SdrObjEditView::BckAction()
+{
+ BrkMacroObj();
+ SdrGlueEditView::BckAction();
+}
+
+void SdrObjEditView::BrkAction()
+{
+ BrkMacroObj();
+ SdrGlueEditView::BrkAction();
+}
+
+void SdrObjEditView::TakeActionRect(Rectangle& rRect) const
+{
+ if (IsMacroObj()) {
+ rRect=pMacroObj->GetCurrentBoundRect();
+ } else {
+ SdrGlueEditView::TakeActionRect(rRect);
+ }
+}
+
+void __EXPORT SdrObjEditView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+{
+ SdrGlueEditView::Notify(rBC,rHint);
+ // Printerwechsel waerend des Editierens
+ SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint);
+ if (pSdrHint!=NULL && pTextEditOutliner!=NULL) {
+ SdrHintKind eKind=pSdrHint->GetKind();
+ if (eKind==HINT_REFDEVICECHG) {
+ pTextEditOutliner->SetRefDevice(pMod->GetRefDevice());
+ }
+ if (eKind==HINT_DEFAULTTABCHG) {
+ pTextEditOutliner->SetDefTab(pMod->GetDefaultTabulator());
+ }
+ if (eKind==HINT_DEFFONTHGTCHG) {
+ // ...
+ }
+ if (eKind==HINT_MODELSAVED) { // #43095#
+ pTextEditOutliner->ClearModifyFlag();
+ }
+ }
+}
+
+void SdrObjEditView::ModelHasChanged()
+{
+ SdrGlueEditView::ModelHasChanged();
+ if (mxTextEditObj.is() && !mxTextEditObj->IsInserted()) SdrEndTextEdit(); // Objekt geloescht
+ // TextEditObj geaendert?
+ if (IsTextEdit()) {
+ SdrTextObj* pTextObj=dynamic_cast<SdrTextObj*>( mxTextEditObj.get() );
+ if (pTextObj!=NULL) {
+ ULONG nOutlViewAnz=pTextEditOutliner->GetViewCount();
+ BOOL bAreaChg=FALSE;
+ BOOL bAnchorChg=FALSE;
+ BOOL bColorChg=FALSE;
+ bool bContourFrame=pTextObj->IsContourTextFrame();
+ EVAnchorMode eNewAnchor(ANCHOR_VCENTER_HCENTER);
+ Rectangle aOldArea(aMinTextEditArea);
+ aOldArea.Union(aTextEditArea);
+ Color aNewColor;
+ { // Area Checken
+ Size aPaperMin1;
+ Size aPaperMax1;
+ Rectangle aEditArea1;
+ Rectangle aMinArea1;
+ pTextObj->TakeTextEditArea(&aPaperMin1,&aPaperMax1,&aEditArea1,&aMinArea1);
+
+ // #108784#
+ Point aPvOfs(pTextObj->GetTextEditOffset());
+
+ aEditArea1.Move(aPvOfs.X(),aPvOfs.Y());
+ aMinArea1.Move(aPvOfs.X(),aPvOfs.Y());
+ Rectangle aNewArea(aMinArea1);
+ aNewArea.Union(aEditArea1);
+ if (aNewArea!=aOldArea || aEditArea1!=aTextEditArea || aMinArea1!=aMinTextEditArea ||
+ pTextEditOutliner->GetMinAutoPaperSize()!=aPaperMin1 || pTextEditOutliner->GetMaxAutoPaperSize()!=aPaperMax1) {
+ aTextEditArea=aEditArea1;
+ aMinTextEditArea=aMinArea1;
+ pTextEditOutliner->SetUpdateMode(FALSE);
+ pTextEditOutliner->SetMinAutoPaperSize(aPaperMin1);
+ pTextEditOutliner->SetMaxAutoPaperSize(aPaperMax1);
+ pTextEditOutliner->SetPaperSize(Size(0,0)); // Damit der Outliner neu formatiert
+ if (!bContourFrame) {
+ pTextEditOutliner->ClearPolygon();
+ ULONG nStat=pTextEditOutliner->GetControlWord();
+ nStat|=EE_CNTRL_AUTOPAGESIZE;
+ pTextEditOutliner->SetControlWord(nStat);
+ } else {
+ ULONG nStat=pTextEditOutliner->GetControlWord();
+ nStat&=~EE_CNTRL_AUTOPAGESIZE;
+ pTextEditOutliner->SetControlWord(nStat);
+ Rectangle aAnchorRect;
+ pTextObj->TakeTextAnchorRect(aAnchorRect);
+ pTextObj->ImpSetContourPolygon(*pTextEditOutliner,aAnchorRect, TRUE);
+ }
+ for (ULONG nOV=0; nOV<nOutlViewAnz; nOV++) {
+ OutlinerView* pOLV=pTextEditOutliner->GetView(nOV);
+ ULONG nStat0=pOLV->GetControlWord();
+ ULONG nStat=nStat0;
+ // AutoViewSize nur wenn nicht KontourFrame.
+ if (!bContourFrame) nStat|=EV_CNTRL_AUTOSIZE;
+ else nStat&=~EV_CNTRL_AUTOSIZE;
+ if (nStat!=nStat0) pOLV->SetControlWord(nStat);
+ }
+ pTextEditOutliner->SetUpdateMode(TRUE);
+ bAreaChg=TRUE;
+ }
+ }
+ if (pTextEditOutlinerView!=NULL) { // Fuellfarbe und Anker checken
+ EVAnchorMode eOldAnchor=pTextEditOutlinerView->GetAnchorMode();
+ eNewAnchor=(EVAnchorMode)pTextObj->GetOutlinerViewAnchorMode();
+ bAnchorChg=eOldAnchor!=eNewAnchor;
+ Color aOldColor(pTextEditOutlinerView->GetBackgroundColor());
+ aNewColor = GetTextEditBackgroundColor(*this);
+ bColorChg=aOldColor!=aNewColor;
+ }
+ // #104082# refresh always when it's a contour frame. That
+ // refresh is necessary since it triggers the repaint
+ // which makes the Handles visible. Changes at TakeTextRect()
+ // seem to have resulted in a case where no refresh is executed.
+ // Before that, a refresh must have been always executed
+ // (else this error would have happend earlier), thus i
+ // even think here a refresh should be done always.
+ // Since follow-up problems cannot even be guessed I only
+ // add this one more case to the if below.
+ // BTW: It's VERY bad style that here, inside ModelHasChanged()
+ // the outliner is again massively changed for the text object
+ // in text edit mode. Normally, all necessary data should be
+ // set at SdrBeginTextEdit(). Some changes and value assigns in
+ // SdrBeginTextEdit() are completely useless since they are set here
+ // again on ModelHasChanged().
+ if (bContourFrame || bAreaChg || bAnchorChg || bColorChg)
+ {
+ for (ULONG nOV=0; nOV<nOutlViewAnz; nOV++)
+ {
+ OutlinerView* pOLV=pTextEditOutliner->GetView(nOV);
+ { // Alten OutlinerView-Bereich invalidieren
+ Window* pWin=pOLV->GetWindow();
+ Rectangle aTmpRect(aOldArea);
+ USHORT nPixSiz=pOLV->GetInvalidateMore()+1;
+ Size aMore(pWin->PixelToLogic(Size(nPixSiz,nPixSiz)));
+ aTmpRect.Left()-=aMore.Width();
+ aTmpRect.Right()+=aMore.Width();
+ aTmpRect.Top()-=aMore.Height();
+ aTmpRect.Bottom()+=aMore.Height();
+ InvalidateOneWin(*pWin,aTmpRect);
+ }
+ if (bAnchorChg)
+ pOLV->SetAnchorMode(eNewAnchor);
+ if (bColorChg)
+ pOLV->SetBackgroundColor( aNewColor );
+
+ pOLV->SetOutputArea(aTextEditArea); // weil sonst scheinbar nicht richtig umgeankert wird
+ ImpInvalidateOutlinerView(*pOLV);
+ }
+ pTextEditOutlinerView->ShowCursor();
+ }
+ }
+ ImpMakeTextCursorAreaVisible();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@@ @@@@@ @@ @@@@@@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@@@ @@@ @@ @@@@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
+// @@ @@@@@ @@ @@ @@ @@@@@ @@@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrObjEditView::ImpPaintOutlinerView(OutlinerView& rOutlView, const Rectangle& rRect) const
+{
+ Window* pWin = rOutlView.GetWindow();
+
+ if(pWin)
+ {
+ const SdrTextObj* pText = PTR_CAST(SdrTextObj,GetTextEditObject());
+ bool bTextFrame(pText && pText->IsTextFrame());
+ bool bFitToSize(pText && pText->IsFitToSize());
+ bool bModifyMerk(pTextEditOutliner->IsModified()); // #43095#
+ Rectangle aBlankRect(rOutlView.GetOutputArea());
+ aBlankRect.Union(aMinTextEditArea);
+ Rectangle aPixRect(pWin->LogicToPixel(aBlankRect));
+ aBlankRect.Intersection(rRect);
+ rOutlView.GetOutliner()->SetUpdateMode(TRUE); // Bugfix #22596#
+ rOutlView.Paint(aBlankRect);
+
+ if(!bModifyMerk)
+ {
+ // #43095#
+ pTextEditOutliner->ClearModifyFlag();
+ }
+
+ if(bTextFrame && !bFitToSize)
+ {
+ aPixRect.Left()--;
+ aPixRect.Top()--;
+ aPixRect.Right()++;
+ aPixRect.Bottom()++;
+ sal_uInt16 nPixSiz(rOutlView.GetInvalidateMore() - 1);
+
+ {
+ // xPixRect Begrenzen, wegen Treiberproblem bei zu weit hinausragenden Pixelkoordinaten
+ Size aMaxXY(pWin->GetOutputSizePixel());
+ long a(2 * nPixSiz);
+ long nMaxX(aMaxXY.Width() + a);
+ long nMaxY(aMaxXY.Height() + a);
+
+ if (aPixRect.Left ()<-a) aPixRect.Left()=-a;
+ if (aPixRect.Top ()<-a) aPixRect.Top ()=-a;
+ if (aPixRect.Right ()>nMaxX) aPixRect.Right ()=nMaxX;
+ if (aPixRect.Bottom()>nMaxY) aPixRect.Bottom()=nMaxY;
+ }
+
+ Rectangle aOuterPix(aPixRect);
+ aOuterPix.Left()-=nPixSiz;
+ aOuterPix.Top()-=nPixSiz;
+ aOuterPix.Right()+=nPixSiz;
+ aOuterPix.Bottom()+=nPixSiz;
+
+ bool bMerk(pWin->IsMapModeEnabled());
+ pWin->EnableMapMode(FALSE);
+ PolyPolygon aPolyPoly( 2 );
+
+ svtools::ColorConfig aColorConfig;
+ Color aHatchCol( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
+ const Hatch aHatch( HATCH_SINGLE, aHatchCol, 3, 450 );
+
+ aPolyPoly.Insert( aOuterPix );
+ aPolyPoly.Insert( aPixRect );
+ pWin->DrawHatch( aPolyPoly, aHatch );
+
+ pWin->EnableMapMode(bMerk);
+ }
+
+ rOutlView.ShowCursor();
+ }
+}
+
+void SdrObjEditView::ImpInvalidateOutlinerView(OutlinerView& rOutlView) const
+{
+ Window* pWin = rOutlView.GetWindow();
+
+ if(pWin)
+ {
+ const SdrTextObj* pText = PTR_CAST(SdrTextObj,GetTextEditObject());
+ bool bTextFrame(pText && pText->IsTextFrame());
+ bool bFitToSize(pText && pText->IsFitToSize());
+
+ if(bTextFrame && !bFitToSize)
+ {
+ Rectangle aBlankRect(rOutlView.GetOutputArea());
+ aBlankRect.Union(aMinTextEditArea);
+ Rectangle aPixRect(pWin->LogicToPixel(aBlankRect));
+ sal_uInt16 nPixSiz(rOutlView.GetInvalidateMore() - 1);
+
+ aPixRect.Left()--;
+ aPixRect.Top()--;
+ aPixRect.Right()++;
+ aPixRect.Bottom()++;
+
+ {
+ // xPixRect Begrenzen, wegen Treiberproblem bei zu weit hinausragenden Pixelkoordinaten
+ Size aMaxXY(pWin->GetOutputSizePixel());
+ long a(2 * nPixSiz);
+ long nMaxX(aMaxXY.Width() + a);
+ long nMaxY(aMaxXY.Height() + a);
+
+ if (aPixRect.Left ()<-a) aPixRect.Left()=-a;
+ if (aPixRect.Top ()<-a) aPixRect.Top ()=-a;
+ if (aPixRect.Right ()>nMaxX) aPixRect.Right ()=nMaxX;
+ if (aPixRect.Bottom()>nMaxY) aPixRect.Bottom()=nMaxY;
+ }
+
+ Rectangle aOuterPix(aPixRect);
+ aOuterPix.Left()-=nPixSiz;
+ aOuterPix.Top()-=nPixSiz;
+ aOuterPix.Right()+=nPixSiz;
+ aOuterPix.Bottom()+=nPixSiz;
+
+ bool bMerk(pWin->IsMapModeEnabled());
+ pWin->EnableMapMode(FALSE);
+ pWin->Invalidate(aOuterPix);
+ pWin->EnableMapMode(bMerk);
+ }
+ }
+}
+
+OutlinerView* SdrObjEditView::ImpMakeOutlinerView(Window* pWin, BOOL /*bNoPaint*/, OutlinerView* pGivenView) const
+{
+ // Hintergrund
+ Color aBackground(GetTextEditBackgroundColor(*this));
+ SdrTextObj* pText = dynamic_cast< SdrTextObj * >( mxTextEditObj.get() );
+ BOOL bTextFrame=pText!=NULL && pText->IsTextFrame();
+ BOOL bContourFrame=pText!=NULL && pText->IsContourTextFrame();
+ // OutlinerView erzeugen
+ OutlinerView* pOutlView=pGivenView;
+ pTextEditOutliner->SetUpdateMode(FALSE);
+ if (pOutlView==NULL) pOutlView=new OutlinerView(pTextEditOutliner,pWin);
+ else pOutlView->SetWindow(pWin);
+ // Scrollen verbieten
+ ULONG nStat=pOutlView->GetControlWord();
+ nStat&=~EV_CNTRL_AUTOSCROLL;
+ // AutoViewSize nur wenn nicht KontourFrame.
+ if (!bContourFrame) nStat|=EV_CNTRL_AUTOSIZE;
+ if (bTextFrame) {
+ USHORT nPixSiz=aHdl.GetHdlSize()*2+1;
+ nStat|=EV_CNTRL_INVONEMORE;
+ pOutlView->SetInvalidateMore(nPixSiz);
+ }
+ pOutlView->SetControlWord(nStat);
+ pOutlView->SetBackgroundColor( aBackground );
+ if (pText!=NULL)
+ {
+ pOutlView->SetAnchorMode((EVAnchorMode)(pText->GetOutlinerViewAnchorMode()));
+ pTextEditOutliner->SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)pText->GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
+ }
+ pOutlView->SetOutputArea(aTextEditArea);
+ pTextEditOutliner->SetUpdateMode(TRUE);
+ ImpInvalidateOutlinerView(*pOutlView);
+ return pOutlView;
+}
+
+BOOL SdrObjEditView::IsTextEditFrame() const
+{
+ SdrTextObj* pText = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() );
+ return pText!=NULL && pText->IsTextFrame();
+}
+
+IMPL_LINK(SdrObjEditView,ImpOutlinerStatusEventHdl,EditStatus*,pEditStat)
+{
+ if(pTextEditOutliner )
+ {
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj * >( mxTextEditObj.get() );
+ if( pTextObj )
+ {
+ pTextObj->onEditOutlinerStatusEvent( pEditStat );
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK(SdrObjEditView,ImpOutlinerCalcFieldValueHdl,EditFieldInfo*,pFI)
+{
+ bool bOk=false;
+ String& rStr=pFI->GetRepresentation();
+ rStr.Erase();
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() );
+ if (pTextObj!=NULL) {
+ Color* pTxtCol=NULL;
+ Color* pFldCol=NULL;
+ bOk=pTextObj->CalcFieldValue(pFI->GetField(),pFI->GetPara(),pFI->GetPos(),TRUE,pTxtCol,pFldCol,rStr);
+ if (bOk) {
+ if (pTxtCol!=NULL) {
+ pFI->SetTxtColor(*pTxtCol);
+ delete pTxtCol;
+ }
+ if (pFldCol!=NULL) {
+ pFI->SetFldColor(*pFldCol);
+ delete pFldCol;
+ } else {
+ pFI->SetFldColor(Color(COL_LIGHTGRAY)); // kann spaeter (357) raus
+ }
+ }
+ }
+ Outliner& rDrawOutl=pMod->GetDrawOutliner(pTextObj);
+ Link aDrawOutlLink=rDrawOutl.GetCalcFieldValueHdl();
+ if (!bOk && aDrawOutlLink.IsSet()) {
+ aDrawOutlLink.Call(pFI);
+ bOk = (BOOL)rStr.Len();
+ }
+ if (!bOk && aOldCalcFieldValueLink.IsSet()) {
+ return aOldCalcFieldValueLink.Call(pFI);
+ }
+ return 0;
+}
+
+sal_Bool SdrObjEditView::SdrBeginTextEdit(
+ SdrObject* pObj, SdrPageView* pPV, Window* pWin,
+ sal_Bool bIsNewObj, SdrOutliner* pGivenOutliner,
+ OutlinerView* pGivenOutlinerView,
+ sal_Bool bDontDeleteOutliner, sal_Bool bOnlyOneView,
+ sal_Bool bGrabFocus)
+{
+ SdrEndTextEdit();
+
+ if( dynamic_cast< SdrTextObj* >( pObj ) == 0 )
+ return FALSE; // currently only possible with text objects
+
+ if(bGrabFocus && pWin)
+ {
+ // attetion, this call may cause an EndTextEdit() call to this view
+ pWin->GrabFocus(); // to force the cursor into the edit view
+ }
+
+ bTextEditDontDelete=bDontDeleteOutliner && pGivenOutliner!=NULL;
+ bTextEditOnlyOneView=bOnlyOneView;
+ bTextEditNewObj=bIsNewObj;
+ const sal_uInt32 nWinAnz(PaintWindowCount());
+ sal_uInt32 i;
+ sal_Bool bBrk(sal_False);
+ // Abbruch, wenn kein Objekt angegeben.
+
+ if(!pObj)
+ {
+ bBrk = sal_True;
+ }
+
+ if(!bBrk && !pWin)
+ {
+ for(i = 0L; i < nWinAnz && !pWin; i++)
+ {
+ SdrPaintWindow* pPaintWindow = GetPaintWindow(i);
+
+ if(OUTDEV_WINDOW == pPaintWindow->GetOutputDevice().GetOutDevType())
+ {
+ pWin = (Window*)(&pPaintWindow->GetOutputDevice());
+ }
+ }
+
+ // Abbruch, wenn kein Window da.
+ if(!pWin)
+ {
+ bBrk = sal_True;
+ }
+ }
+
+ if(!bBrk && !pPV)
+ {
+ pPV = GetSdrPageView();
+
+ // Abbruch, wenn keine PageView zu dem Objekt vorhanden.
+ if(!pPV)
+ {
+ bBrk = sal_True;
+ }
+ }
+
+ if(pObj && pPV)
+ {
+ // Kein TextEdit an Objekten im gesperrten Layer
+ if(pPV->GetLockedLayers().IsSet(pObj->GetLayer()))
+ {
+ bBrk = sal_True;
+ }
+ }
+
+ if(pTextEditOutliner)
+ {
+ DBG_ERROR("SdrObjEditView::SdrBeginTextEdit() da stand noch ein alter Outliner rum");
+ delete pTextEditOutliner;
+ pTextEditOutliner = 0L;
+ }
+
+ if(!bBrk)
+ {
+ pTextEditWin=pWin;
+ pTextEditPV=pPV;
+ mxTextEditObj.reset( pObj );
+ pTextEditOutliner=pGivenOutliner;
+ if (pTextEditOutliner==NULL)
+ pTextEditOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, mxTextEditObj->GetModel() );
+
+ {
+ SvtAccessibilityOptions aOptions;
+ pTextEditOutliner->ForceAutoColor( aOptions.GetIsAutomaticFontColor() );
+ }
+
+ BOOL bEmpty = mxTextEditObj->GetOutlinerParaObject()==NULL;
+
+ aOldCalcFieldValueLink=pTextEditOutliner->GetCalcFieldValueHdl();
+ // Der FieldHdl muss von SdrBeginTextEdit gesetzt sein, da dor ein UpdateFields gerufen wird.
+ pTextEditOutliner->SetCalcFieldValueHdl(LINK(this,SdrObjEditView,ImpOutlinerCalcFieldValueHdl));
+ pTextEditOutliner->SetBeginPasteOrDropHdl(LINK(this,SdrObjEditView,BeginPasteOrDropHdl));
+ pTextEditOutliner->SetEndPasteOrDropHdl(LINK(this,SdrObjEditView, EndPasteOrDropHdl));
+
+ // It is just necessary to make the visualized page known. Set it.
+ pTextEditOutliner->setVisualizedPage(pPV ? pPV->GetPage() : 0);
+
+ pTextEditOutliner->SetTextObjNoInit( dynamic_cast< SdrTextObj* >( mxTextEditObj.get() ) );
+
+ if(mxTextEditObj->BegTextEdit(*pTextEditOutliner))
+ {
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() );
+ DBG_ASSERT( pTextObj, "svx::SdrObjEditView::BegTextEdit(), no text object?" );
+ if( !pTextObj )
+ return FALSE;
+
+ // #111096# Switch off evtl. running TextAnimation
+ pTextObj->SetTextAnimationAllowed(sal_False);
+
+ // alten Cursor merken
+ if (pTextEditOutliner->GetViewCount()!=0)
+ {
+ OutlinerView* pTmpOLV=pTextEditOutliner->RemoveView(ULONG(0));
+ if(pTmpOLV!=NULL && pTmpOLV!=pGivenOutlinerView)
+ delete pTmpOLV;
+ }
+
+ // EditArea ueberTakeTextEditArea bestimmen
+ // Das koennte eigentlich entfallen, da TakeTextRect() die Berechnung der aTextEditArea vornimmt
+ // Die aMinTextEditArea muss jedoch wohl auch erfolgen (darum bleibt es voerst drinnen)
+ pTextObj->TakeTextEditArea(NULL,NULL,&aTextEditArea,&aMinTextEditArea);
+
+ Rectangle aTextRect;
+ Rectangle aAnchorRect;
+ pTextObj->TakeTextRect(*pTextEditOutliner, aTextRect, TRUE,
+ &aAnchorRect /* #97097# Give TRUE here, not FALSE */);
+
+ if ( !pTextObj->IsContourTextFrame() )
+ {
+ // FitToSize erstmal nicht mit ContourFrame
+ if (pTextObj->IsFitToSize())
+ aTextRect = aAnchorRect;
+ }
+
+ aTextEditArea = aTextRect;
+
+ // #108784#
+ Point aPvOfs(pTextObj->GetTextEditOffset());
+
+ aTextEditArea.Move(aPvOfs.X(),aPvOfs.Y());
+ aMinTextEditArea.Move(aPvOfs.X(),aPvOfs.Y());
+ pTextEditCursorMerker=pWin->GetCursor();
+
+ aHdl.SetMoveOutside(TRUE);
+
+ // #i72757#
+ // Since IsMarkHdlWhenTextEdit() is ignored, it is necessary
+ // to call AdjustMarkHdl() always.
+ AdjustMarkHdl();
+
+ pTextEditOutlinerView=ImpMakeOutlinerView(pWin,!bEmpty,pGivenOutlinerView);
+
+ // check if this view is already inserted
+ ULONG i2,nCount = pTextEditOutliner->GetViewCount();
+ for( i2 = 0; i2 < nCount; i2++ )
+ {
+ if( pTextEditOutliner->GetView(i2) == pTextEditOutlinerView )
+ break;
+ }
+
+ if( i2 == nCount )
+ pTextEditOutliner->InsertView(pTextEditOutlinerView,0);
+
+ aHdl.SetMoveOutside(FALSE);
+ aHdl.SetMoveOutside(TRUE);
+ //OLMRefreshAllIAOManagers();
+
+ // alle Wins als OutlinerView beim Outliner anmelden
+ if(!bOnlyOneView)
+ {
+ for(i = 0L; i < nWinAnz; i++)
+ {
+ SdrPaintWindow* pPaintWindow = GetPaintWindow(i);
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+
+ if(&rOutDev != pWin && OUTDEV_WINDOW == rOutDev.GetOutDevType())
+ {
+ OutlinerView* pOutlView = ImpMakeOutlinerView((Window*)(&rOutDev), !bEmpty, 0L);
+ pTextEditOutliner->InsertView(pOutlView, (sal_uInt16)i);
+ }
+ }
+ }
+
+ pTextEditOutlinerView->ShowCursor();
+ pTextEditOutliner->SetStatusEventHdl(LINK(this,SdrObjEditView,ImpOutlinerStatusEventHdl));
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ pTextEditOutliner->ClearModifyFlag();
+
+ // #71519#, #91453#
+ if(pWin)
+ {
+ sal_Bool bExtraInvalidate(sal_False);
+
+ // #71519#
+ if(!bExtraInvalidate)
+ {
+ if(pTextObj->IsFitToSize())
+ bExtraInvalidate = sal_True;
+ }
+
+ if(bExtraInvalidate)
+ {
+ pWin->Invalidate(aTextEditArea);
+ }
+ }
+
+ // send HINT_BEGEDIT #99840#
+ if( GetModel() )
+ {
+ SdrHint aHint(*pTextObj);
+ aHint.SetKind(HINT_BEGEDIT);
+ GetModel()->Broadcast(aHint);
+ }
+
+ pTextEditOutliner->setVisualizedPage(0);
+
+ if( mxSelectionController.is() )
+ mxSelectionController->onSelectionHasChanged();
+
+ return sal_True; // Gut gelaufen, TextEdit laeuft nun
+ }
+ else
+ {
+ bBrk = sal_True;
+ pTextEditOutliner->SetCalcFieldValueHdl(aOldCalcFieldValueLink);
+ pTextEditOutliner->SetBeginPasteOrDropHdl(Link());
+ pTextEditOutliner->SetEndPasteOrDropHdl(Link());
+
+ }
+ }
+ if (pTextEditOutliner != NULL)
+ {
+ pTextEditOutliner->setVisualizedPage(0);
+ }
+
+ // wenn hier angekommen, dann ist irgendwas schief gelaufen
+ if(!bDontDeleteOutliner)
+ {
+ if(pGivenOutliner!=NULL)
+ {
+ delete pGivenOutliner;
+ pTextEditOutliner = NULL;
+ }
+ if(pGivenOutlinerView!=NULL)
+ {
+ delete pGivenOutlinerView;
+ pGivenOutlinerView = NULL;
+ }
+ }
+ if( pTextEditOutliner!=NULL )
+ {
+ delete pTextEditOutliner;
+ }
+
+ pTextEditOutliner=NULL;
+ pTextEditOutlinerView=NULL;
+ mxTextEditObj.reset(0);
+ pTextEditPV=NULL;
+ pTextEditWin=NULL;
+ //HMHif (bMarkHdlWhenTextEdit) {
+ //HMH HideMarkHdl();
+ //HMH}
+ aHdl.SetMoveOutside(FALSE);
+ //HMHShowMarkHdl();
+
+ return sal_False;
+}
+
+SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(sal_Bool bDontDeleteReally)
+{
+ SdrEndTextEditKind eRet=SDRENDTEXTEDIT_UNCHANGED;
+ SdrTextObj* pTEObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() );
+ Window* pTEWin =pTextEditWin;
+ SdrOutliner* pTEOutliner =pTextEditOutliner;
+ OutlinerView* pTEOutlinerView=pTextEditOutlinerView;
+ Cursor* pTECursorMerker=pTextEditCursorMerker;
+
+ // send HINT_ENDEDIT #99840#
+ if( GetModel() && mxTextEditObj.is() )
+ {
+ SdrHint aHint(*mxTextEditObj.get());
+ aHint.SetKind(HINT_ENDEDIT);
+ GetModel()->Broadcast(aHint);
+ }
+
+ mxTextEditObj.reset(0);
+ pTextEditPV=NULL;
+ pTextEditWin=NULL;
+ pTextEditOutliner=NULL;
+ pTextEditOutlinerView=NULL;
+ pTextEditCursorMerker=NULL;
+ aTextEditArea=Rectangle();
+
+ if (pTEOutliner!=NULL)
+ {
+ BOOL bModified=pTEOutliner->IsModified();
+ if (pTEOutlinerView!=NULL)
+ {
+ pTEOutlinerView->HideCursor();
+ }
+ if (pTEObj!=NULL)
+ {
+ pTEOutliner->CompleteOnlineSpelling();
+
+ SdrUndoObjSetText* pTxtUndo = 0;
+
+ if( bModified )
+ {
+ sal_Int32 nText;
+ for( nText = 0; nText < pTEObj->getTextCount(); ++nText )
+ if( pTEObj->getText( nText ) == pTEObj->getActiveText() )
+ break;
+
+ pTxtUndo = dynamic_cast< SdrUndoObjSetText* >( GetModel()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTEObj, nText ) );
+ }
+ DBG_ASSERT( !bModified || pTxtUndo, "svx::SdrObjEditView::EndTextEdit(), could not create undo action!" );
+ // Den alten CalcFieldValue-Handler wieder setzen
+ // Muss vor Obj::EndTextEdit() geschehen, da dort ein UpdateFields() gemacht wird.
+ pTEOutliner->SetCalcFieldValueHdl(aOldCalcFieldValueLink);
+ pTEOutliner->SetBeginPasteOrDropHdl(Link());
+ pTEOutliner->SetEndPasteOrDropHdl(Link());
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ {
+ XubString aObjName;
+ pTEObj->TakeObjNameSingul(aObjName);
+ BegUndo(ImpGetResStr(STR_UndoObjSetText),aObjName);
+ }
+
+ pTEObj->EndTextEdit(*pTEOutliner);
+
+ if( (pTEObj->GetRotateAngle() != 0) || (pTEObj && pTEObj->ISA(SdrTextObj) && ((SdrTextObj*)pTEObj)->IsFontwork()) )
+ {
+ // obviously a repaint
+ pTEObj->ActionChanged();
+ }
+
+ if (pTxtUndo!=NULL)
+ {
+ pTxtUndo->AfterSetText();
+ if (!pTxtUndo->IsDifferent())
+ {
+ delete pTxtUndo;
+ pTxtUndo=NULL;
+ }
+ }
+ // Loeschung des gesamten TextObj checken
+ SdrUndoAction* pDelUndo=NULL;
+ BOOL bDelObj=FALSE;
+ SdrTextObj* pTextObj=PTR_CAST(SdrTextObj,pTEObj);
+ if (pTextObj!=NULL && bTextEditNewObj)
+ {
+ bDelObj=pTextObj->IsTextFrame() &&
+ !pTextObj->HasText() &&
+ !pTextObj->IsEmptyPresObj() &&
+ !pTextObj->HasFill() &&
+ !pTextObj->HasLine();
+
+ if(pTEObj->IsInserted() && bDelObj && pTextObj->GetObjInventor()==SdrInventor && !bDontDeleteReally)
+ {
+ SdrObjKind eIdent=(SdrObjKind)pTextObj->GetObjIdentifier();
+ if(eIdent==OBJ_TEXT || eIdent==OBJ_TEXTEXT)
+ {
+ pDelUndo= GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pTEObj);
+ }
+ }
+ }
+ if (pTxtUndo!=NULL)
+ {
+ if( bUndo )
+ AddUndo(pTxtUndo);
+ eRet=SDRENDTEXTEDIT_CHANGED;
+ }
+ if (pDelUndo!=NULL)
+ {
+ if( bUndo )
+ {
+ AddUndo(pDelUndo);
+ }
+ else
+ {
+ delete pDelUndo;
+ }
+ eRet=SDRENDTEXTEDIT_DELETED;
+ DBG_ASSERT(pTEObj->GetObjList()!=NULL,"SdrObjEditView::SdrEndTextEdit(): Fatal: Editiertes Objekt hat keine ObjList!");
+ if (pTEObj->GetObjList()!=NULL)
+ {
+ pTEObj->GetObjList()->RemoveObject(pTEObj->GetOrdNum());
+ CheckMarked(); // und gleich die Maekierung entfernen...
+ }
+ }
+ else if (bDelObj)
+ { // Fuer den Writer: Loeschen muss die App nachholen.
+ eRet=SDRENDTEXTEDIT_SHOULDBEDELETED;
+ }
+
+ if( bUndo )
+ EndUndo(); // EndUndo hinter Remove, falls der UndoStack gleich weggehaun' wird
+
+ // #111096#
+ // Switch on evtl. TextAnimation again after TextEdit
+ if(pTEObj->ISA(SdrTextObj))
+ {
+ ((SdrTextObj*)pTEObj)->SetTextAnimationAllowed(sal_True);
+ }
+
+ // #i72757#
+ // Since IsMarkHdlWhenTextEdit() is ignored, it is necessary
+ // to call AdjustMarkHdl() always.
+ AdjustMarkHdl();
+ }
+ // alle OutlinerViews loeschen
+ for (ULONG i=pTEOutliner->GetViewCount(); i>0;)
+ {
+ i--;
+ OutlinerView* pOLV=pTEOutliner->GetView(i);
+ USHORT nMorePix=pOLV->GetInvalidateMore() + 10; // solaris aw033 test #i#
+ Window* pWin=pOLV->GetWindow();
+ Rectangle aRect(pOLV->GetOutputArea());
+ pTEOutliner->RemoveView(i);
+ if (!bTextEditDontDelete || i!=0)
+ {
+ // die nullte gehoert mir u.U. nicht.
+ delete pOLV;
+ }
+ aRect.Union(aTextEditArea);
+ aRect.Union(aMinTextEditArea);
+ aRect=pWin->LogicToPixel(aRect);
+ aRect.Left()-=nMorePix;
+ aRect.Top()-=nMorePix;
+ aRect.Right()+=nMorePix;
+ aRect.Bottom()+=nMorePix;
+ aRect=pWin->PixelToLogic(aRect);
+ InvalidateOneWin(*pWin,aRect);
+// pWin->Invalidate(INVALIDATE_UPDATE);
+
+// pWin->Update();
+// pWin->Flush();
+ pWin->SetFillColor();
+ pWin->SetLineColor(COL_BLACK);
+ pWin->DrawPixel(aRect.TopLeft());
+ pWin->DrawPixel(aRect.TopRight());
+ pWin->DrawPixel(aRect.BottomLeft());
+ pWin->DrawPixel(aRect.BottomRight());
+ //pWin->DrawRect(aRect);
+ }
+ // und auch den Outliner selbst
+ if (!bTextEditDontDelete) delete pTEOutliner;
+ else pTEOutliner->Clear();
+ if (pTEWin!=NULL) {
+ pTEWin->SetCursor(pTECursorMerker);
+ }
+//HMH if (bMarkHdlWhenTextEdit) {
+//HMH HideMarkHdl();
+//HMH }
+ aHdl.SetMoveOutside(FALSE);
+ if (eRet!=SDRENDTEXTEDIT_UNCHANGED)
+//HMH {
+//HMH ShowMarkHdl(); // Handles kommen ansonsten via Broadcast
+//HMH }
+//HMH else
+ {
+ GetMarkedObjectListWriteAccess().SetNameDirty();
+ }
+#ifdef DBG_UTIL
+ if (pItemBrowser)
+ {
+ GetMarkedObjectListWriteAccess().SetNameDirty();
+ pItemBrowser->SetDirty();
+ }
+#endif
+ }
+
+ // #108784#
+ if( pTEObj &&
+ pTEObj->GetModel() &&
+ !pTEObj->GetModel()->isLocked() &&
+ pTEObj->GetBroadcaster())
+ {
+ SdrHint aHint(HINT_ENDEDIT);
+ aHint.SetObject(pTEObj);
+ ((SfxBroadcaster*)pTEObj->GetBroadcaster())->Broadcast(aHint);
+ }
+
+ return eRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// info about TextEdit. Default is sal_False.
+bool SdrObjEditView::IsTextEdit() const
+{
+ return mxTextEditObj.is();
+}
+
+// info about TextEditPageView. Default is 0L.
+SdrPageView* SdrObjEditView::GetTextEditPageView() const
+{
+ return pTextEditPV;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+OutlinerView* SdrObjEditView::ImpFindOutlinerView(Window* pWin) const
+{
+ if (pWin==NULL) return NULL;
+ if (pTextEditOutliner==NULL) return NULL;
+ OutlinerView* pNewView=NULL;
+ ULONG nWinAnz=pTextEditOutliner->GetViewCount();
+ for (ULONG i=0; i<nWinAnz && pNewView==NULL; i++) {
+ OutlinerView* pView=pTextEditOutliner->GetView(i);
+ if (pView->GetWindow()==pWin) pNewView=pView;
+ }
+ return pNewView;
+}
+
+void SdrObjEditView::SetTextEditWin(Window* pWin)
+{
+ if(mxTextEditObj.is() && pWin!=NULL && pWin!=pTextEditWin)
+ {
+ OutlinerView* pNewView=ImpFindOutlinerView(pWin);
+ if (pNewView!=NULL && pNewView!=pTextEditOutlinerView)
+ {
+ if (pTextEditOutlinerView!=NULL)
+ {
+ pTextEditOutlinerView->HideCursor();
+ }
+ pTextEditOutlinerView=pNewView;
+ pTextEditWin=pWin;
+ pWin->GrabFocus(); // Damit der Cursor hier auch blinkt
+ pNewView->ShowCursor();
+ ImpMakeTextCursorAreaVisible();
+ }
+ }
+}
+
+BOOL SdrObjEditView::IsTextEditHit(const Point& rHit, short nTol) const
+{
+ BOOL bOk=FALSE;
+ if(mxTextEditObj.is())
+ {
+ nTol=ImpGetHitTolLogic(nTol,NULL);
+ // nur drittel Toleranz hier, damit die Handles
+ // noch vernuenftig getroffen werden koennen
+ nTol=nTol/3;
+ nTol=0; // Joe am 6.3.1997: Keine Hittoleranz mehr hier
+ if (!bOk)
+ {
+ Rectangle aEditArea;
+ OutlinerView* pOLV=pTextEditOutliner->GetView(0);
+ if (pOLV!=NULL)
+ {
+ aEditArea.Union(pOLV->GetOutputArea());
+ }
+ aEditArea.Left()-=nTol;
+ aEditArea.Top()-=nTol;
+ aEditArea.Right()+=nTol;
+ aEditArea.Bottom()+=nTol;
+ bOk=aEditArea.IsInside(rHit);
+ if (bOk)
+ { // Nun noch checken, ob auch wirklich Buchstaben getroffen wurden
+ Point aPnt(rHit); aPnt-=aEditArea.TopLeft();
+ long nHitTol = 2000;
+ OutputDevice* pRef = pTextEditOutliner->GetRefDevice();
+ if( pRef )
+ nHitTol = pRef->LogicToLogic( nHitTol, MAP_100TH_MM, pRef->GetMapMode().GetMapUnit() );
+
+ bOk = pTextEditOutliner->IsTextPos( aPnt, (sal_uInt16)nHitTol );
+ }
+ }
+ }
+ return bOk;
+}
+
+BOOL SdrObjEditView::IsTextEditFrameHit(const Point& rHit) const
+{
+ BOOL bOk=FALSE;
+ if(mxTextEditObj.is())
+ {
+ SdrTextObj* pText= dynamic_cast<SdrTextObj*>(mxTextEditObj.get());
+ OutlinerView* pOLV=pTextEditOutliner->GetView(0);
+ if( pOLV )
+ {
+ Window* pWin=pOLV->GetWindow();
+ if (pText!=NULL && pText->IsTextFrame() && pOLV!=NULL && pWin!=NULL) {
+ USHORT nPixSiz=pOLV->GetInvalidateMore();
+ Rectangle aEditArea(aMinTextEditArea);
+ aEditArea.Union(pOLV->GetOutputArea());
+ if (!aEditArea.IsInside(rHit)) {
+ Size aSiz(pWin->PixelToLogic(Size(nPixSiz,nPixSiz)));
+ aEditArea.Left()-=aSiz.Width();
+ aEditArea.Top()-=aSiz.Height();
+ aEditArea.Right()+=aSiz.Width();
+ aEditArea.Bottom()+=aSiz.Height();
+ bOk=aEditArea.IsInside(rHit);
+ }
+ }
+ }
+ }
+ return bOk;
+}
+
+void SdrObjEditView::AddTextEditOfs(MouseEvent& rMEvt) const
+{
+ if(mxTextEditObj.is())
+ {
+ Point aPvOfs;
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mxTextEditObj.get() );
+
+ if( pTextObj )
+ {
+ // #108784#
+ aPvOfs += pTextObj->GetTextEditOffset();
+ }
+
+ Point aObjOfs(mxTextEditObj->GetLogicRect().TopLeft());
+ (Point&)(rMEvt.GetPosPixel())+=aPvOfs+aObjOfs;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrObjEditView::KeyInput(const KeyEvent& rKEvt, Window* pWin)
+{
+ if(pTextEditOutlinerView)
+ {
+#ifdef DBG_UTIL
+ if(rKEvt.GetKeyCode().GetCode() == KEY_RETURN && pTextEditOutliner->GetParagraphCount() == 1)
+ {
+ ByteString aLine(
+ pTextEditOutliner->GetText(pTextEditOutliner->GetParagraph( 0 ), 1),
+ gsl_getSystemTextEncoding());
+ aLine = aLine.ToUpperAscii();
+
+ if(aLine == "HELLO JOE, PLEASE SHOW THE ITEMBROWSER")
+ ShowItemBrowser();
+ }
+#endif
+ if (pTextEditOutlinerView->PostKeyEvent(rKEvt, pWin))
+ {
+ if( pMod /* && !pMod->IsChanged() */ )
+ {
+ if( pTextEditOutliner && pTextEditOutliner->IsModified() )
+ pMod->SetChanged( sal_True );
+ }
+
+ if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ ImpMakeTextCursorAreaVisible();
+ return TRUE;
+ }
+ }
+ return SdrGlueEditView::KeyInput(rKEvt,pWin);
+}
+
+BOOL SdrObjEditView::MouseButtonDown(const MouseEvent& rMEvt, Window* pWin)
+{
+ if (pTextEditOutlinerView!=NULL) {
+ BOOL bPostIt=pTextEditOutliner->IsInSelectionMode();
+ if (!bPostIt) {
+ Point aPt(rMEvt.GetPosPixel());
+ if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt);
+ else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt);
+ bPostIt=IsTextEditHit(aPt,nHitTolLog);
+ }
+ if (bPostIt) {
+ Point aPixPos(rMEvt.GetPosPixel());
+ Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea()));
+ if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left ();
+ if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right ();
+ if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top ();
+ if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom();
+ MouseEvent aMEvt(aPixPos,rMEvt.GetClicks(),rMEvt.GetMode(),
+ rMEvt.GetButtons(),rMEvt.GetModifier());
+ if (pTextEditOutlinerView->MouseButtonDown(aMEvt)) {
+ if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ ImpMakeTextCursorAreaVisible();
+ return TRUE;
+ }
+ }
+ }
+ return SdrGlueEditView::MouseButtonDown(rMEvt,pWin);
+}
+
+BOOL SdrObjEditView::MouseButtonUp(const MouseEvent& rMEvt, Window* pWin)
+{
+ if (pTextEditOutlinerView!=NULL) {
+ BOOL bPostIt=pTextEditOutliner->IsInSelectionMode();
+ if (!bPostIt) {
+ Point aPt(rMEvt.GetPosPixel());
+ if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt);
+ else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt);
+ bPostIt=IsTextEditHit(aPt,nHitTolLog);
+ }
+ if (bPostIt) {
+ Point aPixPos(rMEvt.GetPosPixel());
+ Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea()));
+ if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left ();
+ if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right ();
+ if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top ();
+ if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom();
+ MouseEvent aMEvt(aPixPos,rMEvt.GetClicks(),rMEvt.GetMode(),
+ rMEvt.GetButtons(),rMEvt.GetModifier());
+ if (pTextEditOutlinerView->MouseButtonUp(aMEvt)) {
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ ImpMakeTextCursorAreaVisible();
+ return TRUE;
+ }
+ }
+ }
+ return SdrGlueEditView::MouseButtonUp(rMEvt,pWin);
+}
+
+BOOL SdrObjEditView::MouseMove(const MouseEvent& rMEvt, Window* pWin)
+{
+ if (pTextEditOutlinerView!=NULL) {
+ BOOL bSelMode=pTextEditOutliner->IsInSelectionMode();
+ BOOL bPostIt=bSelMode;
+ if (!bPostIt) {
+ Point aPt(rMEvt.GetPosPixel());
+ if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt);
+ else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt);
+ bPostIt=IsTextEditHit(aPt,nHitTolLog);
+ }
+ if (bPostIt) {
+ Point aPixPos(rMEvt.GetPosPixel());
+ Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea()));
+ if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left ();
+ if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right ();
+ if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top ();
+ if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom();
+ MouseEvent aMEvt(aPixPos,rMEvt.GetClicks(),rMEvt.GetMode(),
+ rMEvt.GetButtons(),rMEvt.GetModifier());
+ if (pTextEditOutlinerView->MouseMove(aMEvt) && bSelMode) {
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ ImpMakeTextCursorAreaVisible();
+ return TRUE;
+ }
+ }
+ }
+ return SdrGlueEditView::MouseMove(rMEvt,pWin);
+}
+
+BOOL SdrObjEditView::Command(const CommandEvent& rCEvt, Window* pWin)
+{
+ // solange bis die OutlinerView einen BOOL zurueckliefert
+ // bekommt sie nur COMMAND_STARTDRAG
+ if (pTextEditOutlinerView!=NULL)
+ {
+ if (rCEvt.GetCommand()==COMMAND_STARTDRAG) {
+ BOOL bPostIt=pTextEditOutliner->IsInSelectionMode() || !rCEvt.IsMouseEvent();
+ if (!bPostIt && rCEvt.IsMouseEvent()) {
+ Point aPt(rCEvt.GetMousePosPixel());
+ if (pWin!=NULL) aPt=pWin->PixelToLogic(aPt);
+ else if (pTextEditWin!=NULL) aPt=pTextEditWin->PixelToLogic(aPt);
+ bPostIt=IsTextEditHit(aPt,nHitTolLog);
+ }
+ if (bPostIt) {
+ Point aPixPos(rCEvt.GetMousePosPixel());
+ if (rCEvt.IsMouseEvent()) {
+ Rectangle aR(pWin->LogicToPixel(pTextEditOutlinerView->GetOutputArea()));
+ if (aPixPos.X()<aR.Left ()) aPixPos.X()=aR.Left ();
+ if (aPixPos.X()>aR.Right ()) aPixPos.X()=aR.Right ();
+ if (aPixPos.Y()<aR.Top ()) aPixPos.Y()=aR.Top ();
+ if (aPixPos.Y()>aR.Bottom()) aPixPos.Y()=aR.Bottom();
+ }
+ CommandEvent aCEvt(aPixPos,rCEvt.GetCommand(),rCEvt.IsMouseEvent());
+ // Command ist an der OutlinerView leider void
+ pTextEditOutlinerView->Command(aCEvt);
+ if (pWin!=NULL && pWin!=pTextEditWin) SetTextEditWin(pWin);
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ ImpMakeTextCursorAreaVisible();
+ return TRUE;
+ }
+ }
+ else // if (rCEvt.GetCommand() == COMMAND_VOICE )
+ {
+ pTextEditOutlinerView->Command(rCEvt);
+ return TRUE;
+ }
+ }
+ return SdrGlueEditView::Command(rCEvt,pWin);
+}
+
+BOOL SdrObjEditView::Cut(ULONG nFormat)
+{
+ if (pTextEditOutliner!=NULL) {
+ pTextEditOutlinerView->Cut();
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ ImpMakeTextCursorAreaVisible();
+ return TRUE;
+ } else {
+ return SdrGlueEditView::Cut(nFormat);
+ }
+}
+
+BOOL SdrObjEditView::Yank(ULONG nFormat)
+{
+ if (pTextEditOutliner!=NULL) {
+ pTextEditOutlinerView->Copy();
+ return TRUE;
+ } else {
+ return SdrGlueEditView::Yank(nFormat);
+ }
+}
+
+BOOL SdrObjEditView::Paste(Window* pWin, ULONG nFormat)
+{
+ if (pTextEditOutliner!=NULL) {
+ if (pWin!=NULL) {
+ OutlinerView* pNewView=ImpFindOutlinerView(pWin);
+ if (pNewView!=NULL) {
+ pNewView->Paste();
+ }
+ } else {
+ pTextEditOutlinerView->Paste();
+ }
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ ImpMakeTextCursorAreaVisible();
+ return TRUE;
+ } else {
+ return SdrGlueEditView::Paste(pWin,nFormat);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrObjEditView::ImpIsTextEditAllSelected() const
+{
+ BOOL bRet=FALSE;
+ if (pTextEditOutliner!=NULL && pTextEditOutlinerView!=NULL)
+ {
+ if(SdrTextObj::HasTextImpl( pTextEditOutliner ) )
+ {
+ const sal_uInt32 nParaAnz=pTextEditOutliner->GetParagraphCount();
+ Paragraph* pLastPara=pTextEditOutliner->GetParagraph( nParaAnz > 1 ? nParaAnz - 1 : 0 );
+
+ ESelection aESel(pTextEditOutlinerView->GetSelection());
+ if (aESel.nStartPara==0 && aESel.nStartPos==0 && aESel.nEndPara==USHORT(nParaAnz-1))
+ {
+ XubString aStr(pTextEditOutliner->GetText(pLastPara));
+
+ if(aStr.Len() == aESel.nEndPos)
+ bRet = TRUE;
+ }
+ // und nun auch noch fuer den Fall, das rueckwaerts selektiert wurde
+ if (!bRet && aESel.nEndPara==0 && aESel.nEndPos==0 && aESel.nStartPara==USHORT(nParaAnz-1))
+ {
+ XubString aStr(pTextEditOutliner->GetText(pLastPara));
+
+ if(aStr.Len() == aESel.nStartPos)
+ bRet = TRUE;
+ }
+ }
+ else
+ {
+ bRet=TRUE;
+ }
+ }
+ return bRet;
+}
+
+void SdrObjEditView::ImpMakeTextCursorAreaVisible()
+{
+ if (pTextEditOutlinerView!=NULL && pTextEditWin!=NULL) {
+ Cursor* pCsr=pTextEditWin->GetCursor();
+ if (pCsr!=NULL) {
+ Size aSiz(pCsr->GetSize());
+ if (aSiz.Width()!=0 && aSiz.Height()!=0) { // #38450#
+ MakeVisible(Rectangle(pCsr->GetPos(),aSiz),*pTextEditWin);
+ }
+ }
+ }
+}
+
+USHORT SdrObjEditView::GetScriptType() const
+{
+ USHORT nScriptType = 0;
+
+ if( IsTextEdit() )
+ {
+ if( mxTextEditObj->GetOutlinerParaObject() )
+ nScriptType = mxTextEditObj->GetOutlinerParaObject()->GetTextObject().GetScriptType();
+
+ if( pTextEditOutlinerView )
+ nScriptType = pTextEditOutlinerView->GetSelectedScriptType();
+ }
+ else
+ {
+ sal_uInt32 nMarkCount( GetMarkedObjectCount() );
+
+ for( sal_uInt32 i = 0; i < nMarkCount; i++ )
+ {
+ OutlinerParaObject* pParaObj = GetMarkedObjectByIndex( i )->GetOutlinerParaObject();
+
+ if( pParaObj )
+ {
+ nScriptType |= pParaObj->GetTextObject().GetScriptType();
+ }
+ }
+ }
+
+ if( nScriptType == 0 )
+ nScriptType = SCRIPTTYPE_LATIN;
+
+ return nScriptType;
+}
+
+/* new interface src537 */
+BOOL SdrObjEditView::GetAttributes(SfxItemSet& rTargetSet, BOOL bOnlyHardAttr) const
+{
+ if( mxSelectionController.is() )
+ if( mxSelectionController->GetAttributes( rTargetSet, bOnlyHardAttr ) )
+ return TRUE;
+
+ if(IsTextEdit())
+ {
+ DBG_ASSERT(pTextEditOutlinerView!=NULL,"SdrObjEditView::GetAttributes(): pTextEditOutlinerView=NULL");
+ DBG_ASSERT(pTextEditOutliner!=NULL,"SdrObjEditView::GetAttributes(): pTextEditOutliner=NULL");
+
+ // #92389# take care of bOnlyHardAttr(!)
+ if(!bOnlyHardAttr && mxTextEditObj->GetStyleSheet())
+ rTargetSet.Put(mxTextEditObj->GetStyleSheet()->GetItemSet());
+
+ // add object attributes
+ rTargetSet.Put( mxTextEditObj->GetMergedItemSet() );
+
+ if( mxTextEditObj->GetOutlinerParaObject() )
+ rTargetSet.Put( SvxScriptTypeItem( mxTextEditObj->GetOutlinerParaObject()->GetTextObject().GetScriptType() ) );
+
+ if(pTextEditOutlinerView)
+ {
+ // FALSE= InvalidItems nicht al Default, sondern als "Loecher" betrachten
+ rTargetSet.Put(pTextEditOutlinerView->GetAttribs(), FALSE);
+ rTargetSet.Put( SvxScriptTypeItem( pTextEditOutlinerView->GetSelectedScriptType() ), FALSE );
+ }
+
+ if(GetMarkedObjectCount()==1 && GetMarkedObjectByIndex(0)==mxTextEditObj.get())
+ {
+ MergeNotPersistAttrFromMarked(rTargetSet, bOnlyHardAttr);
+ }
+
+ return TRUE;
+ }
+ else
+ {
+ return SdrGlueEditView::GetAttributes(rTargetSet, bOnlyHardAttr);
+ }
+}
+
+BOOL SdrObjEditView::SetAttributes(const SfxItemSet& rSet, BOOL bReplaceAll)
+{
+ BOOL bRet=FALSE;
+ BOOL bTextEdit=pTextEditOutlinerView!=NULL && mxTextEditObj.is();
+ BOOL bAllTextSelected=ImpIsTextEditAllSelected();
+ SfxItemSet* pModifiedSet=NULL;
+ const SfxItemSet* pSet=&rSet;
+ //const SvxAdjustItem* pParaJust=NULL;
+
+ if (!bTextEdit)
+ {
+ // Kein TextEdit aktiv -> alle Items ans Zeichenobjekt
+ if( mxSelectionController.is() )
+ bRet=mxSelectionController->SetAttributes(*pSet,bReplaceAll );
+
+ if( !bRet )
+ {
+ bRet=SdrGlueEditView::SetAttributes(*pSet,bReplaceAll);
+ }
+ }
+ else
+ {
+#ifdef DBG_UTIL
+ {
+ BOOL bHasEEFeatureItems=FALSE;
+ SfxItemIter aIter(rSet);
+ const SfxPoolItem* pItem=aIter.FirstItem();
+ while (!bHasEEFeatureItems && pItem!=NULL)
+ {
+ if (!IsInvalidItem(pItem))
+ {
+ USHORT nW=pItem->Which();
+ if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END)
+ bHasEEFeatureItems=TRUE;
+ }
+
+ pItem=aIter.NextItem();
+ }
+
+ if(bHasEEFeatureItems)
+ {
+ String aMessage;
+ aMessage.AppendAscii("SdrObjEditView::SetAttributes(): Das setzen von EE_FEATURE-Items an der SdrView macht keinen Sinn! Es fuehrt nur zu Overhead und nicht mehr lesbaren Dokumenten.");
+ InfoBox(NULL, aMessage).Execute();
+ }
+ }
+#endif
+
+ BOOL bOnlyEEItems;
+ BOOL bNoEEItems=!SearchOutlinerItems(*pSet,bReplaceAll,&bOnlyEEItems);
+ // alles selektiert? -> Attrs auch an den Rahmen
+ // und falls keine EEItems, dann Attrs nur an den Rahmen
+ if (bAllTextSelected || bNoEEItems)
+ {
+ if( mxSelectionController.is() )
+ bRet=mxSelectionController->SetAttributes(*pSet,bReplaceAll );
+
+ if( !bRet )
+ {
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ {
+ String aStr;
+ ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
+ BegUndo(aStr);
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get()));
+
+ // #i43537#
+ // If this is a text object also rescue the OutlinerParaObject since
+ // applying attributes to the object may change text layout when
+ // multiple portions exist with multiple formats. If a OutlinerParaObject
+ // really exists and needs to be rescued is evaluated in the undo
+ // implementation itself.
+ bool bRescueText = dynamic_cast< SdrTextObj* >(mxTextEditObj.get());
+
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get(),false,!bNoEEItems || bRescueText));
+ EndUndo();
+ }
+
+ mxTextEditObj->SetMergedItemSetAndBroadcast(*pSet, bReplaceAll);
+
+ FlushComeBackTimer(); // Damit ModeHasChanged sofort kommt
+ bRet=TRUE;
+ }
+ }
+ else if (!bOnlyEEItems)
+ {
+ // sonst Set ggf. splitten
+ // Es wird nun ein ItemSet aSet gemacht, in den die EE_Items von
+ // *pSet nicht enhalten ist (ansonsten ist es eine Kopie).
+ USHORT* pNewWhichTable=RemoveWhichRange(pSet->GetRanges(),EE_ITEMS_START,EE_ITEMS_END);
+ SfxItemSet aSet(pMod->GetItemPool(),pNewWhichTable);
+ /*90353*/ delete[] pNewWhichTable;
+ SfxWhichIter aIter(aSet);
+ USHORT nWhich=aIter.FirstWhich();
+ while (nWhich!=0)
+ {
+ const SfxPoolItem* pItem;
+ SfxItemState eState=pSet->GetItemState(nWhich,FALSE,&pItem);
+ if (eState==SFX_ITEM_SET) aSet.Put(*pItem);
+ nWhich=aIter.NextWhich();
+ }
+
+
+ if( mxSelectionController.is() )
+ bRet=mxSelectionController->SetAttributes(aSet,bReplaceAll );
+
+ if( !bRet )
+ {
+ if( IsUndoEnabled() )
+ {
+ String aStr;
+ ImpTakeDescriptionStr(STR_EditSetAttributes,aStr);
+ BegUndo(aStr);
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*mxTextEditObj.get()));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*mxTextEditObj.get(),false,false));
+ EndUndo();
+ }
+
+ mxTextEditObj->SetMergedItemSetAndBroadcast(aSet, bReplaceAll);
+
+ if (GetMarkedObjectCount()==1 && GetMarkedObjectByIndex(0)==mxTextEditObj.get())
+ {
+ SetNotPersistAttrToMarked(aSet,bReplaceAll);
+ }
+ }
+ FlushComeBackTimer();
+ bRet=TRUE;
+ }
+ if(!bNoEEItems)
+ {
+ // und nun die Attribute auch noch an die EditEngine
+ if (bReplaceAll) {
+ // Am Outliner kann man leider nur alle Attribute platthauen
+ pTextEditOutlinerView->RemoveAttribs( TRUE );
+ }
+ pTextEditOutlinerView->SetAttribs(rSet);
+
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL)
+ pItemBrowser->SetDirty();
+#endif
+
+ ImpMakeTextCursorAreaVisible();
+ }
+ bRet=TRUE;
+ }
+ if (pModifiedSet!=NULL)
+ delete pModifiedSet;
+ return bRet;
+}
+
+SfxStyleSheet* SdrObjEditView::GetStyleSheet() const
+{
+ SfxStyleSheet* pSheet = 0;
+
+ if( mxSelectionController.is() )
+ {
+ if( mxSelectionController->GetStyleSheet( pSheet ) )
+ return pSheet;
+ }
+
+ if ( pTextEditOutlinerView )
+ {
+ pSheet = pTextEditOutlinerView->GetStyleSheet();
+ }
+ else
+ {
+ pSheet = SdrGlueEditView::GetStyleSheet();
+ }
+ return pSheet;
+}
+
+BOOL SdrObjEditView::SetStyleSheet(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr)
+{
+ if( mxSelectionController.is() )
+ {
+ if( mxSelectionController->SetStyleSheet( pStyleSheet, bDontRemoveHardAttr ) )
+ return TRUE;
+ }
+
+ // if we are currently in edit mode we must also set the stylesheet
+ // on all paragraphs in the Outliner for the edit view
+ // #92191#
+ if( NULL != pTextEditOutlinerView )
+ {
+ Outliner* pOutliner = pTextEditOutlinerView->GetOutliner();
+
+ const ULONG nParaCount = pOutliner->GetParagraphCount();
+ ULONG nPara;
+ for( nPara = 0; nPara < nParaCount; nPara++ )
+ {
+ pOutliner->SetStyleSheet( nPara, pStyleSheet );
+ }
+ }
+
+ return SdrGlueEditView::SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrObjEditView::AddWindowToPaintView(OutputDevice* pNewWin)
+{
+ SdrGlueEditView::AddWindowToPaintView(pNewWin);
+
+ if(mxTextEditObj.is() && !bTextEditOnlyOneView && pNewWin->GetOutDevType()==OUTDEV_WINDOW)
+ {
+ OutlinerView* pOutlView=ImpMakeOutlinerView((Window*)pNewWin,FALSE,NULL);
+ pTextEditOutliner->InsertView(pOutlView);
+ }
+}
+
+void SdrObjEditView::DeleteWindowFromPaintView(OutputDevice* pOldWin)
+{
+ SdrGlueEditView::DeleteWindowFromPaintView(pOldWin);
+
+ if(mxTextEditObj.is() && !bTextEditOnlyOneView && pOldWin->GetOutDevType()==OUTDEV_WINDOW)
+ {
+ for (ULONG i=pTextEditOutliner->GetViewCount(); i>0;) {
+ i--;
+ OutlinerView* pOLV=pTextEditOutliner->GetView(i);
+ if (pOLV && pOLV->GetWindow()==(Window*)pOldWin) {
+ delete pTextEditOutliner->RemoveView(i);
+ }
+ }
+ }
+}
+
+BOOL SdrObjEditView::IsTextEditInSelectionMode() const
+{
+ return pTextEditOutliner!=NULL && pTextEditOutliner->IsInSelectionMode();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@ @@ @@@@ @@@@ @@@@@ @@@@ @@ @@ @@@@ @@@@@ @@@@@
+// @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@@ @@ @@ @@ @@ @@
+// @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@
+// @@@@@@@ @@@@@@ @@ @@@@@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@@@
+// @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@@@ @@ @@ @@@@ @@ @@ @@@@ @@@@@ @@@@@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrObjEditView::BegMacroObj(const Point& rPnt, short nTol, SdrObject* pObj, SdrPageView* pPV, Window* pWin)
+{
+ BOOL bRet=FALSE;
+ BrkMacroObj();
+ if (pObj!=NULL && pPV!=NULL && pWin!=NULL && pObj->HasMacro()) {
+ nTol=ImpGetHitTolLogic(nTol,NULL);
+ pMacroObj=pObj;
+ pMacroPV=pPV;
+ pMacroWin=pWin;
+ bMacroDown=FALSE;
+ nMacroTol=USHORT(nTol);
+ aMacroDownPos=rPnt;
+ MovMacroObj(rPnt);
+ }
+ return bRet;
+}
+
+void SdrObjEditView::ImpMacroUp(const Point& rUpPos)
+{
+ if (pMacroObj!=NULL && bMacroDown)
+ {
+ SdrObjMacroHitRec aHitRec;
+ aHitRec.aPos=rUpPos;
+ aHitRec.aDownPos=aMacroDownPos;
+ aHitRec.nTol=nMacroTol;
+ aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
+ aHitRec.pPageView=pMacroPV;
+ aHitRec.pOut=pMacroWin;
+ pMacroObj->PaintMacro(*pMacroWin,Rectangle(),aHitRec);
+ bMacroDown=FALSE;
+ }
+}
+
+void SdrObjEditView::ImpMacroDown(const Point& rDownPos)
+{
+ if (pMacroObj!=NULL && !bMacroDown)
+ {
+ SdrObjMacroHitRec aHitRec;
+ aHitRec.aPos=rDownPos;
+ aHitRec.aDownPos=aMacroDownPos;
+ aHitRec.nTol=nMacroTol;
+ aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
+ aHitRec.pPageView=pMacroPV;
+ aHitRec.bDown=TRUE;
+ aHitRec.pOut=pMacroWin;
+ pMacroObj->PaintMacro(*pMacroWin,Rectangle(),aHitRec);
+ bMacroDown=TRUE;
+ }
+}
+
+void SdrObjEditView::MovMacroObj(const Point& rPnt)
+{
+ if (pMacroObj!=NULL) {
+ SdrObjMacroHitRec aHitRec;
+ aHitRec.aPos=rPnt;
+ aHitRec.aDownPos=aMacroDownPos;
+ aHitRec.nTol=nMacroTol;
+ aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
+ aHitRec.pPageView=pMacroPV;
+ aHitRec.bDown=bMacroDown;
+ aHitRec.pOut=pMacroWin;
+ BOOL bDown=pMacroObj->IsMacroHit(aHitRec);
+ if (bDown) ImpMacroDown(rPnt);
+ else ImpMacroUp(rPnt);
+ }
+}
+
+void SdrObjEditView::BrkMacroObj()
+{
+ if (pMacroObj!=NULL) {
+ ImpMacroUp(aMacroDownPos);
+ pMacroObj=NULL;
+ pMacroPV=NULL;
+ pMacroWin=NULL;
+ }
+}
+
+BOOL SdrObjEditView::EndMacroObj()
+{
+ if (pMacroObj!=NULL && bMacroDown) {
+ ImpMacroUp(aMacroDownPos);
+ SdrObjMacroHitRec aHitRec;
+ aHitRec.aPos=aMacroDownPos;
+ aHitRec.aDownPos=aMacroDownPos;
+ aHitRec.nTol=nMacroTol;
+ aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
+ aHitRec.pPageView=pMacroPV;
+ aHitRec.bDown=TRUE;
+ aHitRec.pOut=pMacroWin;
+ bool bRet=pMacroObj->DoMacro(aHitRec);
+ pMacroObj=NULL;
+ pMacroPV=NULL;
+ pMacroWin=NULL;
+ return bRet;
+ } else {
+ BrkMacroObj();
+ return FALSE;
+ }
+}
+
+/** fills the given any with a XTextCursor for the current text selection.
+ Leaves the any untouched if there currently is no text selected */
+void SdrObjEditView::getTextSelection( ::com::sun::star::uno::Any& rSelection )
+{
+ if( IsTextEdit() )
+ {
+ OutlinerView* pOutlinerView = GetTextEditOutlinerView();
+ if( pOutlinerView && pOutlinerView->HasSelection() )
+ {
+ SdrObject* pObj = GetTextEditObject();
+
+ if( pObj )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xText( pObj->getUnoShape(), ::com::sun::star::uno::UNO_QUERY );
+ if( xText.is() )
+ {
+ SvxUnoTextBase* pRange = SvxUnoTextBase::getImplementation( xText );
+ if( pRange )
+ {
+ rSelection <<= pRange->createTextCursorBySelection( pOutlinerView->GetSelection() );
+ }
+ }
+ }
+ }
+ }
+}
+
+namespace sdr { namespace table {
+extern rtl::Reference< sdr::SelectionController > CreateTableController( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController );
+} }
+
+/* check if we have a single selection and that single object likes
+ to handle the mouse and keyboard events itself
+
+ @todo: the selection controller should be queried from the
+ object specific view contact. Currently this method only
+ works for tables.
+*/
+void SdrObjEditView::MarkListHasChanged()
+{
+ SdrGlueEditView::MarkListHasChanged();
+
+ if( mxSelectionController.is() )
+ {
+ mxLastSelectionController = mxSelectionController;
+ mxSelectionController->onSelectionHasChanged();
+ }
+
+ mxSelectionController.clear();
+
+ const SdrMarkList& rMarkList=GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ const SdrObject* pObj= rMarkList.GetMark(0)->GetMarkedSdrObj();
+ // check for table
+ if( pObj && (pObj->GetObjInventor() == SdrInventor ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
+ {
+ mxSelectionController = sdr::table::CreateTableController( this, pObj, mxLastSelectionController );
+ if( mxSelectionController.is() )
+ {
+ mxLastSelectionController.clear();
+ mxSelectionController->onSelectionHasChanged();
+ }
+ }
+ }
+}
+
+IMPL_LINK( SdrObjEditView, EndPasteOrDropHdl, PasteOrDropInfos*, pInfos )
+{
+ OnEndPasteOrDrop( pInfos );
+ return 0;
+}
+
+IMPL_LINK( SdrObjEditView, BeginPasteOrDropHdl, PasteOrDropInfos*, pInfos )
+{
+ OnBeginPasteOrDrop( pInfos );
+ return 0;
+}
+
+void SdrObjEditView::OnBeginPasteOrDrop( PasteOrDropInfos* )
+{
+ // applications can derive from these virtual methods to do something before a drop or paste operation
+}
+
+void SdrObjEditView::OnEndPasteOrDrop( PasteOrDropInfos* )
+{
+ // applications can derive from these virtual methods to do something before a drop or paste operation
+}
+
+bool SdrObjEditView::SupportsFormatPaintbrush( UINT32 nObjectInventor, UINT16 nObjectIdentifier ) const
+{
+ if( nObjectInventor != SdrInventor && nObjectInventor != E3dInventor )
+ return false;
+ switch(nObjectIdentifier)
+ {
+ case OBJ_NONE:
+ case OBJ_GRUP:
+ return false;
+ case OBJ_LINE:
+ case OBJ_RECT:
+ case OBJ_CIRC:
+ case OBJ_SECT:
+ case OBJ_CARC:
+ case OBJ_CCUT:
+ case OBJ_POLY:
+ case OBJ_PLIN:
+ case OBJ_PATHLINE:
+ case OBJ_PATHFILL:
+ case OBJ_FREELINE:
+ case OBJ_FREEFILL:
+ case OBJ_SPLNLINE:
+ case OBJ_SPLNFILL:
+ case OBJ_TEXT:
+ case OBJ_TEXTEXT:
+ case OBJ_TITLETEXT:
+ case OBJ_OUTLINETEXT:
+ case OBJ_GRAF:
+ case OBJ_OLE2:
+ case OBJ_TABLE:
+ return true;
+ case OBJ_EDGE:
+ case OBJ_CAPTION:
+ return false;
+ case OBJ_PATHPOLY:
+ case OBJ_PATHPLIN:
+ return true;
+ case OBJ_PAGE:
+ case OBJ_MEASURE:
+ case OBJ_DUMMY:
+ case OBJ_FRAME:
+ case OBJ_UNO:
+ return false;
+ case OBJ_CUSTOMSHAPE:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static const USHORT* GetFormatRangeImpl( bool bTextOnly )
+{
+ static const USHORT gRanges[] = {
+ SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,
+ SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
+ SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
+ XATTR_LINE_FIRST, XATTR_LINE_LAST,
+ XATTR_FILL_FIRST, XATTRSET_FILL,
+ EE_PARA_START, EE_PARA_END,
+ EE_CHAR_START, EE_CHAR_END,
+ 0,0
+ };
+ return &gRanges[ bTextOnly ? 10 : 0];
+}
+
+bool SdrObjEditView::TakeFormatPaintBrush( boost::shared_ptr< SfxItemSet >& rFormatSet )
+{
+ if( mxSelectionController.is() && mxSelectionController->TakeFormatPaintBrush(rFormatSet) )
+ return true;
+
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() >= 1 )
+ {
+ OutlinerView* pOLV = GetTextEditOutlinerView();
+
+ rFormatSet.reset( new SfxItemSet( GetModel()->GetItemPool(), GetFormatRangeImpl( pOLV != NULL ) ) );
+ if( pOLV )
+ {
+ rFormatSet->Put( pOLV->GetAttribs() );
+ }
+ else
+ {
+ const BOOL bOnlyHardAttr = FALSE;
+ rFormatSet->Put( GetAttrFromMarked(bOnlyHardAttr) );
+ }
+ return true;
+ }
+
+ return false;
+}
+
+static SfxItemSet CreatePaintSet( const USHORT *pRanges, SfxItemPool& rPool, const SfxItemSet& rSourceSet, const SfxItemSet& rTargetSet, bool bNoCharacterFormats, bool bNoParagraphFormats )
+{
+ SfxItemSet aPaintSet( rPool, pRanges );
+
+ while( *pRanges )
+ {
+ USHORT nWhich = *pRanges++;
+ const USHORT nLastWhich = *pRanges++;
+
+ if( bNoCharacterFormats && (nWhich == EE_CHAR_START) )
+ continue;
+
+ if( bNoParagraphFormats && (nWhich == EE_PARA_START ) )
+ continue;
+
+ for( ; nWhich < nLastWhich; nWhich++ )
+ {
+ const SfxPoolItem* pSourceItem = rSourceSet.GetItem( nWhich );
+ const SfxPoolItem* pTargetItem = rTargetSet.GetItem( nWhich );
+
+ if( (pSourceItem && !pTargetItem) || (pSourceItem && pTargetItem && !((*pSourceItem) == (*pTargetItem)) ) )
+ {
+ aPaintSet.Put( *pSourceItem );
+ }
+ }
+ }
+ return aPaintSet;
+}
+
+void SdrObjEditView::ApplyFormatPaintBrushToText( SfxItemSet& rFormatSet, SdrTextObj& rTextObj, SdrText* pText, bool bNoCharacterFormats, bool bNoParagraphFormats )
+{
+ OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0;
+ if(pParaObj)
+ {
+ SdrOutliner& rOutliner = rTextObj.ImpGetDrawOutliner();
+ rOutliner.SetText(*pParaObj);
+
+ sal_uInt32 nParaCount(rOutliner.GetParagraphCount());
+
+ if(nParaCount)
+ {
+ for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
+ {
+ if( !bNoCharacterFormats )
+ rOutliner.QuickRemoveCharAttribs( nPara, /* remove all */0 );
+
+ SfxItemSet aSet(rOutliner.GetParaAttribs(nPara));
+ aSet.Put(CreatePaintSet( GetFormatRangeImpl(true), *aSet.GetPool(), rFormatSet, aSet, bNoCharacterFormats, bNoParagraphFormats ) );
+ rOutliner.SetParaAttribs(nPara, aSet);
+ }
+
+ OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount);
+ rOutliner.Clear();
+
+ rTextObj.NbcSetOutlinerParaObjectForText(pTemp,pText);
+ }
+ }
+}
+
+void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats )
+{
+ if( !mxSelectionController.is() || !mxSelectionController->ApplyFormatPaintBrush( rFormatSet, bNoCharacterFormats, bNoParagraphFormats ) )
+ {
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ OutlinerView* pOLV = GetTextEditOutlinerView();
+
+ const SfxItemSet& rShapeSet = pObj->GetMergedItemSet();
+
+ if( !pOLV )
+ {
+ // if not in text edit mode (aka the user selected text or clicked on a word)
+ // apply formating attributes to selected shape
+ // All formating items (see ranges above) that are unequal in selected shape and
+ // the format paintbrush are hard set on the selected shape.
+
+ const USHORT* pRanges = rFormatSet.GetRanges();
+ bool bTextOnly = true;
+
+ while( *pRanges )
+ {
+ if( (*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START) )
+ {
+ bTextOnly = false;
+ break;
+ }
+ pRanges += 2;
+ }
+
+ if( !bTextOnly )
+ {
+ SfxItemSet aPaintSet( CreatePaintSet( GetFormatRangeImpl(false), *rShapeSet.GetPool(), rFormatSet, rShapeSet, bNoCharacterFormats, bNoParagraphFormats ) );
+ const BOOL bReplaceAll = FALSE;
+ SetAttrToMarked(aPaintSet, bReplaceAll);
+ }
+
+ // now apply character and paragraph formating to text, if the shape has any
+ SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj);
+ if( pTextObj )
+ {
+ sal_Int32 nText = pTextObj->getTextCount();
+
+ while( --nText >= 0 )
+ {
+ SdrText* pText = pTextObj->getText( nText );
+ ApplyFormatPaintBrushToText( rFormatSet, *pTextObj, pText, bNoCharacterFormats, bNoParagraphFormats );
+ }
+ }
+ }
+ else
+ {
+ ::Outliner* pOutliner = pOLV->GetOutliner();
+ if( pOutliner )
+ {
+ const EditEngine& rEditEngine = pOutliner->GetEditEngine();
+
+ ESelection aSel( pOLV->GetSelection() );
+ if( !aSel.HasRange() )
+ pOLV->SetSelection( rEditEngine.GetWord( aSel, com::sun::star::i18n::WordType::DICTIONARY_WORD ) );
+
+ const BOOL bRemoveParaAttribs = !bNoParagraphFormats;
+ pOLV->RemoveAttribsKeepLanguages( bRemoveParaAttribs );
+ SfxItemSet aSet( pOLV->GetAttribs() );
+ SfxItemSet aPaintSet( CreatePaintSet(GetFormatRangeImpl(true), *aSet.GetPool(), rFormatSet, aSet, bNoCharacterFormats, bNoParagraphFormats ) );
+ pOLV->SetAttribs( aPaintSet );
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
new file mode 100644
index 000000000000..5acd912a3d9a
--- /dev/null
+++ b/svx/source/svdraw/svdetc.cxx
@@ -0,0 +1,1121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "editeng/forbiddencharacterstable.hxx"
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <com/sun/star/embed/EmbedStates.hpp>
+#include <svx/svdetc.hxx>
+#include "svditext.hxx"
+#include <svx/svdmodel.hxx>
+#include <svx/svdtrans.hxx>
+#include "svdglob.hxx"
+#include "svdstr.hrc"
+#include "svdviter.hxx"
+#include <svx/svdview.hxx>
+#include <svx/svdoutl.hxx>
+#include <vcl/bmpacc.hxx>
+#include <editeng/eeitem.hxx>
+#include <svl/itemset.hxx>
+#include <tools/config.hxx>
+#include <unotools/cacheoptions.hxx>
+#include <svl/whiter.hxx>
+#include <tools/bigint.hxx>
+#include "editeng/fontitem.hxx"
+#include <editeng/colritem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <svx/xgrad.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/svdoole2.hxx>
+#include <svl/itempool.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <com/sun/star/lang/Locale.hpp>
+#include <comphelper/processfactory.hxx>
+#include <i18npool/lang.h>
+#include <unotools/charclass.hxx>
+#include <unotools/syslocale.hxx>
+#include <svx/xflbckit.hxx>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdotable.hxx>
+#include <svx/sdrhittesthelper.hxx>
+
+using namespace ::com::sun::star;
+
+/******************************************************************************
+* Globale Daten der DrawingEngine
+******************************************************************************/
+
+SdrGlobalData::SdrGlobalData() :
+ pSysLocale(NULL),
+ pCharClass(NULL),
+ pLocaleData(NULL),
+ pOutliner(NULL),
+ pDefaults(NULL),
+ pResMgr(NULL),
+ nExchangeFormat(0)
+{
+ //pSysLocale = new SvtSysLocale;
+ //pCharClass = pSysLocale->GetCharClassPtr();
+ //pLocaleData = pSysLocale->GetLocaleDataPtr();
+
+ svx::ExtrusionBar::RegisterInterface();
+ svx::FontworkBar::RegisterInterface();
+}
+
+SdrGlobalData::~SdrGlobalData()
+{
+ delete pOutliner;
+ delete pDefaults;
+ delete pResMgr;
+ //! do NOT delete pCharClass and pLocaleData
+ delete pSysLocale;
+}
+const SvtSysLocale* SdrGlobalData::GetSysLocale()
+{
+ if ( !pSysLocale )
+ pSysLocale = new SvtSysLocale;
+ return pSysLocale;
+}
+const CharClass* SdrGlobalData::GetCharClass()
+{
+ if ( !pCharClass )
+ pCharClass = GetSysLocale()->GetCharClassPtr();
+ return pCharClass;
+}
+const LocaleDataWrapper* SdrGlobalData::GetLocaleData()
+{
+ if ( !pLocaleData )
+ pLocaleData = GetSysLocale()->GetLocaleDataPtr();
+ return pLocaleData;
+}
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+OLEObjCache::OLEObjCache()
+: Container( 0 )
+{
+ SvtCacheOptions aCacheOptions;
+
+ nSize = aCacheOptions.GetDrawingEngineOLE_Objects();
+ pTimer = new AutoTimer();
+ Link aLink = LINK(this, OLEObjCache, UnloadCheckHdl);
+
+ pTimer->SetTimeoutHdl(aLink);
+ pTimer->SetTimeout(20000);
+ pTimer->Start();
+
+ aLink.Call(pTimer);
+}
+
+OLEObjCache::~OLEObjCache()
+{
+ pTimer->Stop();
+ delete pTimer;
+}
+
+void OLEObjCache::UnloadOnDemand()
+{
+ if ( nSize < Count() )
+ {
+ // more objects than configured cache size try to remove objects
+ // of course not the freshly inserted one at nIndex=0
+ ULONG nCount2 = Count();
+ ULONG nIndex = nCount2-1;
+ while( nIndex && nCount2 > nSize )
+ {
+ SdrOle2Obj* pUnloadObj = (SdrOle2Obj*) GetObject(nIndex--);
+ if ( pUnloadObj )
+ {
+ try
+ {
+ // it is important to get object without reinitialization to avoid reentrance
+ uno::Reference< embed::XEmbeddedObject > xUnloadObj = pUnloadObj->GetObjRef_NoInit();
+
+ sal_Bool bUnload = SdrOle2Obj::CanUnloadRunningObj( xUnloadObj, pUnloadObj->GetAspect() );
+
+ // check whether the object can be unloaded before looking for the parent objects
+ if ( xUnloadObj.is() && bUnload )
+ {
+ uno::Reference< frame::XModel > xUnloadModel( xUnloadObj->getComponent(), uno::UNO_QUERY );
+ if ( xUnloadModel.is() )
+ {
+ for ( ULONG nCheckInd = 0; nCheckInd < Count(); nCheckInd++ )
+ {
+ SdrOle2Obj* pCacheObj = (SdrOle2Obj*) GetObject(nCheckInd);
+ if ( pCacheObj && pCacheObj != pUnloadObj )
+ {
+ uno::Reference< frame::XModel > xParentModel = pCacheObj->GetParentXModel();
+ if ( xUnloadModel == xParentModel )
+ bUnload = sal_False; // the object has running embedded objects
+ }
+ }
+ }
+ }
+
+ if ( bUnload && UnloadObj(pUnloadObj) )
+ // object was successfully unloaded
+ nCount2--;
+ }
+ catch( uno::Exception& )
+ {}
+ }
+ }
+ }
+}
+
+void OLEObjCache::SetSize(ULONG nNewSize)
+{
+ nSize = nNewSize;
+}
+
+void OLEObjCache::InsertObj(SdrOle2Obj* pObj)
+{
+ if ( Count() )
+ {
+ SdrOle2Obj* pExistingObj = (SdrOle2Obj*)GetObject( 0 );
+ if ( pObj == pExistingObj )
+ // the object is already on the top, nothing has to be changed
+ return;
+ }
+
+ // get the old position of the object to know whether it is already in container
+ ULONG nOldPos = GetPos( pObj );
+
+ // insert object into first position
+ Remove( nOldPos );
+ Insert(pObj, (ULONG) 0L);
+
+ if ( nOldPos == CONTAINER_ENTRY_NOTFOUND )
+ {
+ // a new object was inserted, recalculate the cache
+ UnloadOnDemand();
+ }
+}
+
+void OLEObjCache::RemoveObj(SdrOle2Obj* pObj)
+{
+ Remove(pObj);
+}
+
+BOOL OLEObjCache::UnloadObj(SdrOle2Obj* pObj)
+{
+ BOOL bUnloaded = FALSE;
+ if (pObj)
+ {
+ //#i80528# The old mechanism is completely useless, only taking into account if
+ // in all views the GrafDraft feature is used. This will nearly never have been the
+ // case since no one ever used this option.
+ //
+ // A much better (and working) criteria would be the VOC contact count.
+ // The quesion is what will happen whe i make it work now suddenly? I
+ // will try it for 2.4.
+ const sdr::contact::ViewContact& rViewContact = pObj->GetViewContact();
+ const bool bVisible(rViewContact.HasViewObjectContacts(true));
+
+ if(!bVisible)
+ {
+ bUnloaded = pObj->Unload();
+ }
+ }
+
+ return bUnloaded;
+}
+
+IMPL_LINK(OLEObjCache, UnloadCheckHdl, AutoTimer*, /*pTim*/)
+{
+ UnloadOnDemand();
+ return 0;
+}
+
+void ContainerSorter::DoSort(ULONG a, ULONG b) const
+{
+ ULONG nAnz=rCont.Count();
+ if (b>nAnz) b=nAnz;
+ if (b>0) b--;
+ if (a<b) ImpSubSort(a,b);
+}
+
+void ContainerSorter::Is1stLessThan2nd(const void* /*pElem1*/, const void* /*pElem2*/) const
+{
+}
+
+void ContainerSorter::ImpSubSort(long nL, long nR) const
+{
+ long i,j;
+ const void* pX;
+ void* pI;
+ void* pJ;
+ i=nL;
+ j=nR;
+ pX=rCont.GetObject((nL+nR)/2);
+ do {
+ pI=rCont.Seek(i);
+ while (pI!=pX && Compare(pI,pX)<0) { i++; pI=rCont.Next(); }
+ pJ=rCont.Seek(j);
+ while (pJ!=pX && Compare(pX,pJ)<0) { j--; pJ=rCont.Prev(); }
+ if (i<=j) {
+ rCont.Replace(pJ,i);
+ rCont.Replace(pI,j);
+ i++;
+ j--;
+ }
+ } while (i<=j);
+ if (nL<j) ImpSubSort(nL,j);
+ if (i<nR) ImpSubSort(i,nR);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ImpUShortContainerSorter: public ContainerSorter {
+public:
+ ImpUShortContainerSorter(Container& rNewCont): ContainerSorter(rNewCont) {}
+ virtual int Compare(const void* pElem1, const void* pElem2) const;
+};
+
+int ImpUShortContainerSorter::Compare(const void* pElem1, const void* pElem2) const
+{
+ USHORT n1=USHORT(ULONG(pElem1));
+ USHORT n2=USHORT(ULONG(pElem2));
+ return n1<n2 ? -1 : n1>n2 ? 1 : 0;
+}
+
+void UShortCont::Sort()
+{
+ ImpUShortContainerSorter aSorter(aArr);
+ aSorter.DoSort();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ImpClipMerk {
+ Region aClip;
+ bool bClip;
+public:
+ ImpClipMerk(const OutputDevice& rOut): aClip(rOut.GetClipRegion()),bClip(rOut.IsClipRegion()) {}
+ void Restore(OutputDevice& rOut)
+ {
+ // Kein Clipping in die Metafileaufzeichnung
+ GDIMetaFile* pMtf=rOut.GetConnectMetaFile();
+ if (pMtf!=NULL && (!pMtf->IsRecord() || pMtf->IsPause())) pMtf=NULL;
+ if (pMtf!=NULL) pMtf->Pause(TRUE);
+ if (bClip) rOut.SetClipRegion(aClip);
+ else rOut.SetClipRegion();
+ if (pMtf!=NULL) pMtf->Pause(FALSE);
+ }
+};
+
+class ImpColorMerk {
+ Color aLineColor;
+ Color aFillColor;
+ Color aBckgrdColor;
+ Font aFont;
+public:
+ ImpColorMerk(const OutputDevice& rOut):
+ aLineColor( rOut.GetLineColor() ),
+ aFillColor( rOut.GetFillColor() ),
+ aBckgrdColor( rOut.GetBackground().GetColor() ),
+ aFont (rOut.GetFont()) {}
+
+ ImpColorMerk(const OutputDevice& rOut, USHORT nMode)
+ {
+ if ( (nMode & SDRHDC_SAVEPEN) == SDRHDC_SAVEPEN )
+ aLineColor = rOut.GetLineColor();
+
+ if ( (nMode & SDRHDC_SAVEBRUSH) == SDRHDC_SAVEBRUSH)
+ {
+ aFillColor = rOut.GetFillColor();
+ aBckgrdColor = rOut.GetBackground().GetColor();
+ }
+
+ if ( (nMode & SDRHDC_SAVEFONT) == SDRHDC_SAVEFONT)
+ aFont=rOut.GetFont();
+ }
+
+ void Restore(OutputDevice& rOut, USHORT nMode=SDRHDC_SAVEPENANDBRUSHANDFONT)
+ {
+ if ( (nMode & SDRHDC_SAVEPEN) == SDRHDC_SAVEPEN)
+ rOut.SetLineColor( aLineColor );
+
+ if ( (nMode & SDRHDC_SAVEBRUSH) == SDRHDC_SAVEBRUSH)
+ {
+ rOut.SetFillColor( aFillColor );
+ rOut.SetBackground( Wallpaper( aBckgrdColor ) );
+ }
+ if ((nMode & SDRHDC_SAVEFONT) ==SDRHDC_SAVEFONT)
+ {
+ if (!rOut.GetFont().IsSameInstance(aFont))
+ {
+ rOut.SetFont(aFont);
+ }
+ }
+ }
+
+ const Color& GetLineColor() const { return aLineColor; }
+};
+
+ImpSdrHdcMerk::ImpSdrHdcMerk(const OutputDevice& rOut, USHORT nNewMode, bool bAutoMerk):
+ pFarbMerk(NULL),
+ pClipMerk(NULL),
+ pLineColorMerk(NULL),
+ nMode(nNewMode)
+{
+ if (bAutoMerk) Save(rOut);
+}
+
+ImpSdrHdcMerk::~ImpSdrHdcMerk()
+{
+ if (pFarbMerk!=NULL) delete pFarbMerk;
+ if (pClipMerk!=NULL) delete pClipMerk;
+ if (pLineColorMerk !=NULL) delete pLineColorMerk;
+}
+
+void ImpSdrHdcMerk::Save(const OutputDevice& rOut)
+{
+ if (pFarbMerk!=NULL)
+ {
+ delete pFarbMerk;
+ pFarbMerk=NULL;
+ }
+ if (pClipMerk!=NULL)
+ {
+ delete pClipMerk;
+ pClipMerk=NULL;
+ }
+ if (pLineColorMerk !=NULL)
+ {
+ delete pLineColorMerk ;
+ pLineColorMerk =NULL;
+ }
+ if ((nMode & SDRHDC_SAVECLIPPING) ==SDRHDC_SAVECLIPPING)
+ pClipMerk=new ImpClipMerk(rOut);
+
+ USHORT nCol=nMode & SDRHDC_SAVEPENANDBRUSHANDFONT;
+
+ if (nCol==SDRHDC_SAVEPEN)
+ pLineColorMerk=new Color( rOut.GetLineColor() );
+ else if (nCol==SDRHDC_SAVEPENANDBRUSHANDFONT)
+ pFarbMerk=new ImpColorMerk(rOut);
+ else if (nCol!=0)
+ pFarbMerk=new ImpColorMerk(rOut,nCol);
+}
+
+void ImpSdrHdcMerk::Restore(OutputDevice& rOut, USHORT nMask) const
+{
+ nMask&=nMode; // nur restaurieren, was auch gesichert wurde
+
+ if ((nMask & SDRHDC_SAVECLIPPING) ==SDRHDC_SAVECLIPPING && pClipMerk!=NULL)
+ pClipMerk->Restore(rOut);
+
+ USHORT nCol=nMask & SDRHDC_SAVEPENANDBRUSHANDFONT;
+
+ if (nCol==SDRHDC_SAVEPEN)
+ {
+ if (pLineColorMerk!=NULL)
+ rOut.SetLineColor(*pLineColorMerk);
+ else if (pFarbMerk!=NULL)
+ rOut.SetLineColor( pFarbMerk->GetLineColor() );
+ } else if (nCol!=0 && pFarbMerk!=NULL)
+ pFarbMerk->Restore(rOut,nCol);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrLinkList::Clear()
+{
+ unsigned nAnz=GetLinkCount();
+ for (unsigned i=0; i<nAnz; i++) {
+ delete (Link*)aList.GetObject(i);
+ }
+ aList.Clear();
+}
+
+unsigned SdrLinkList::FindEntry(const Link& rLink) const
+{
+ unsigned nAnz=GetLinkCount();
+ for (unsigned i=0; i<nAnz; i++) {
+ if (GetLink(i)==rLink) return i;
+ }
+ return 0xFFFF;
+}
+
+void SdrLinkList::InsertLink(const Link& rLink, unsigned nPos)
+{
+ unsigned nFnd=FindEntry(rLink);
+ if (nFnd==0xFFFF) {
+ if (rLink.IsSet()) {
+ aList.Insert(new Link(rLink),nPos);
+ } else {
+ DBG_ERROR("SdrLinkList::InsertLink(): Versuch, einen nicht gesetzten Link einzufuegen");
+ }
+ } else {
+ DBG_ERROR("SdrLinkList::InsertLink(): Link schon vorhanden");
+ }
+}
+
+void SdrLinkList::RemoveLink(const Link& rLink)
+{
+ unsigned nFnd=FindEntry(rLink);
+ if (nFnd!=0xFFFF) {
+ Link* pLink=(Link*)aList.Remove(nFnd);
+ delete pLink;
+ } else {
+ DBG_ERROR("SdrLinkList::RemoveLink(): Link nicht gefunden");
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #98988# Re-implement GetDraftFillColor(...)
+
+bool GetDraftFillColor(const SfxItemSet& rSet, Color& rCol)
+{
+ XFillStyle eFill=((XFillStyleItem&)rSet.Get(XATTR_FILLSTYLE)).GetValue();
+ bool bRetval = false;
+
+ switch(eFill)
+ {
+ case XFILL_SOLID:
+ {
+ rCol = ((XFillColorItem&)rSet.Get(XATTR_FILLCOLOR)).GetColorValue();
+ bRetval = true;
+
+ break;
+ }
+ case XFILL_HATCH:
+ {
+ Color aCol1(((XFillHatchItem&)rSet.Get(XATTR_FILLHATCH)).GetHatchValue().GetColor());
+ Color aCol2(COL_WHITE);
+
+ // #97870# when hatch background is activated, use object fill color as hatch color
+ sal_Bool bFillHatchBackground = ((const XFillBackgroundItem&)(rSet.Get(XATTR_FILLBACKGROUND))).GetValue();
+ if(bFillHatchBackground)
+ {
+ aCol2 = ((const XFillColorItem&)(rSet.Get(XATTR_FILLCOLOR))).GetColorValue();
+ }
+
+ const basegfx::BColor aAverageColor(basegfx::average(aCol1.getBColor(), aCol2.getBColor()));
+ rCol = Color(aAverageColor);
+ bRetval = true;
+
+ break;
+ }
+ case XFILL_GRADIENT: {
+ const XGradient& rGrad=((XFillGradientItem&)rSet.Get(XATTR_FILLGRADIENT)).GetGradientValue();
+ Color aCol1(rGrad.GetStartColor());
+ Color aCol2(rGrad.GetEndColor());
+ const basegfx::BColor aAverageColor(basegfx::average(aCol1.getBColor(), aCol2.getBColor()));
+ rCol = Color(aAverageColor);
+ bRetval = true;
+
+ break;
+ }
+ case XFILL_BITMAP:
+ {
+ const Bitmap& rBitmap = ((XFillBitmapItem&)rSet.Get(XATTR_FILLBITMAP)).GetBitmapValue().GetBitmap();
+ const Size aSize(rBitmap.GetSizePixel());
+ const sal_uInt32 nWidth = aSize.Width();
+ const sal_uInt32 nHeight = aSize.Height();
+ Bitmap aBitmap(rBitmap);
+ BitmapReadAccess* pAccess = aBitmap.AcquireReadAccess();
+
+ if(pAccess && nWidth > 0 && nHeight > 0)
+ {
+ sal_uInt32 nRt(0L);
+ sal_uInt32 nGn(0L);
+ sal_uInt32 nBl(0L);
+ const sal_uInt32 nMaxSteps(8L);
+ const sal_uInt32 nXStep((nWidth > nMaxSteps) ? nWidth / nMaxSteps : 1L);
+ const sal_uInt32 nYStep((nHeight > nMaxSteps) ? nHeight / nMaxSteps : 1L);
+ sal_uInt32 nAnz(0L);
+
+ for(sal_uInt32 nY(0L); nY < nHeight; nY += nYStep)
+ {
+ for(sal_uInt32 nX(0L); nX < nWidth; nX += nXStep)
+ {
+ const BitmapColor& rCol2 = (pAccess->HasPalette())
+ ? pAccess->GetPaletteColor((BYTE)pAccess->GetPixel(nY, nX))
+ : pAccess->GetPixel(nY, nX);
+
+ nRt += rCol2.GetRed();
+ nGn += rCol2.GetGreen();
+ nBl += rCol2.GetBlue();
+ nAnz++;
+ }
+ }
+
+ nRt /= nAnz;
+ nGn /= nAnz;
+ nBl /= nAnz;
+
+ rCol = Color(UINT8(nRt), UINT8(nGn), UINT8(nBl));
+
+ bRetval = true;
+ }
+
+ if(pAccess)
+ {
+ aBitmap.ReleaseAccess(pAccess);
+ }
+
+ break;
+ }
+ default: break;
+ }
+
+ return bRetval;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrEngineDefaults::SdrEngineDefaults():
+ aFontName( OutputDevice::GetDefaultFont( DEFAULTFONT_SERIF, LANGUAGE_SYSTEM, DEFAULTFONT_FLAGS_ONLYONE ).GetName() ),
+ eFontFamily(FAMILY_ROMAN),
+ aFontColor(COL_AUTO),
+ nFontHeight(847), // 847/100mm = ca. 24 Point
+ eMapUnit(MAP_100TH_MM),
+ aMapFraction(1,1)
+{
+}
+
+SdrEngineDefaults& SdrEngineDefaults::GetDefaults()
+{
+ SdrGlobalData& rGlobalData=GetSdrGlobalData();
+ if (rGlobalData.pDefaults==NULL) {
+ rGlobalData.pDefaults=new SdrEngineDefaults;
+ }
+ return *rGlobalData.pDefaults;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrEngineDefaults::LanguageHasChanged()
+{
+ SdrGlobalData& rGlobalData=GetSdrGlobalData();
+ if (rGlobalData.pResMgr!=NULL) {
+ delete rGlobalData.pResMgr;
+ rGlobalData.pResMgr=NULL;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrOutliner* SdrMakeOutliner( USHORT nOutlinerMode, SdrModel* pModel )
+{
+ //SdrEngineDefaults& rDefaults = SdrEngineDefaults::GetDefaults();
+
+ SfxItemPool* pPool = &pModel->GetItemPool();
+ SdrOutliner* pOutl = new SdrOutliner( pPool, nOutlinerMode );
+ pOutl->SetEditTextObjectPool( pPool );
+ pOutl->SetStyleSheetPool( (SfxStyleSheetPool*) pModel->GetStyleSheetPool() );
+ pOutl->SetDefTab( pModel->GetDefaultTabulator() );
+ pOutl->SetForbiddenCharsTable( pModel->GetForbiddenCharsTable() );
+ pOutl->SetAsianCompressionMode( pModel->GetCharCompressType() );
+ pOutl->SetKernAsianPunctuation( pModel->IsKernAsianPunctuation() );
+ pOutl->SetAddExtLeading( pModel->IsAddExtLeading() );
+
+ return pOutl;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+SdrLinkList& ImpGetUserMakeObjHdl()
+{
+ SdrGlobalData& rGlobalData=GetSdrGlobalData();
+ return rGlobalData.aUserMakeObjHdl;
+}
+
+SdrLinkList& ImpGetUserMakeObjUserDataHdl()
+{
+ SdrGlobalData& rGlobalData=GetSdrGlobalData();
+ return rGlobalData.aUserMakeObjUserDataHdl;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ResMgr* ImpGetResMgr()
+{
+ SdrGlobalData& rGlobalData = GetSdrGlobalData();
+
+ if(!rGlobalData.pResMgr)
+ {
+ ByteString aName("svx");
+ rGlobalData.pResMgr =
+ ResMgr::CreateResMgr( aName.GetBuffer(), Application::GetSettings().GetUILocale() );
+ }
+
+ return rGlobalData.pResMgr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+String ImpGetResStr(sal_uInt16 nResID)
+{
+ return String(ResId(nResID, *ImpGetResMgr()));
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+String GetResourceString(sal_uInt16 nResID)
+{
+ return ImpGetResStr( nResID );
+}
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SearchOutlinerItems(const SfxItemSet& rSet, BOOL bInklDefaults, BOOL* pbOnlyEE)
+{
+ BOOL bHas=FALSE;
+ BOOL bOnly=TRUE;
+ BOOL bLookOnly=pbOnlyEE!=NULL;
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich=aIter.FirstWhich();
+ while (((bLookOnly && bOnly) || !bHas) && nWhich!=0) {
+ // bei bInklDefaults ist der gesamte Which-Range
+ // ausschlaggebend, ansonsten nur die gesetzten Items
+ // Disabled und DontCare wird als Loch im Which-Range betrachtet
+ SfxItemState eState=rSet.GetItemState(nWhich);
+ if ((eState==SFX_ITEM_DEFAULT && bInklDefaults) || eState==SFX_ITEM_SET) {
+ if (nWhich<EE_ITEMS_START || nWhich>EE_ITEMS_END) bOnly=FALSE;
+ else bHas=TRUE;
+ }
+ nWhich=aIter.NextWhich();
+ }
+ if (!bHas) bOnly=FALSE;
+ if (pbOnlyEE!=NULL) *pbOnlyEE=bOnly;
+ return bHas;
+}
+
+USHORT* RemoveWhichRange(const USHORT* pOldWhichTable, USHORT nRangeBeg, USHORT nRangeEnd)
+{
+ // insgesamt sind 6 Faelle moeglich (je Range):
+ // [Beg..End] zu entfernender Range
+ // [b..e] [b..e] [b..e] Fall 1,3,2: egal, ganz weg, egal + Ranges
+ // [b........e] [b........e] Fall 4,5 : Bereich verkleinern | in
+ // [b......................e] Fall 6 : Splitting + pOldWhichTable
+ USHORT nAnz=0;
+ while (pOldWhichTable[nAnz]!=0) nAnz++;
+ nAnz++; // nAnz muesste nun in jedem Fall eine ungerade Zahl sein (0 am Ende des Arrays)
+ DBG_ASSERT((nAnz&1)==1,"Joe: RemoveWhichRange: WhichTable hat keine ungerade Anzahl von Eintraegen");
+ USHORT nAlloc=nAnz;
+ // benoetigte Groesse des neuen Arrays ermitteln
+ USHORT nNum=nAnz-1;
+ while (nNum!=0) {
+ nNum-=2;
+ USHORT nBeg=pOldWhichTable[nNum];
+ USHORT nEnd=pOldWhichTable[nNum+1];
+ if (nEnd<nRangeBeg) /*nCase=1*/ ;
+ else if (nBeg>nRangeEnd) /* nCase=2 */ ;
+ else if (nBeg>=nRangeBeg && nEnd<=nRangeEnd) /* nCase=3 */ nAlloc-=2;
+ else if (nEnd<=nRangeEnd) /* nCase=4 */;
+ else if (nBeg>=nRangeBeg) /* nCase=5*/ ;
+ else /* nCase=6 */ nAlloc+=2;
+ }
+
+ USHORT* pNewWhichTable=new USHORT[nAlloc];
+ memcpy(pNewWhichTable,pOldWhichTable,nAlloc*sizeof(USHORT));
+ pNewWhichTable[nAlloc-1]=0; // im Falle 3 fehlt die 0 am Ende
+ // nun die unerwuenschten Ranges entfernen
+ nNum=nAlloc-1;
+ while (nNum!=0) {
+ nNum-=2;
+ USHORT nBeg=pNewWhichTable[nNum];
+ USHORT nEnd=pNewWhichTable[nNum+1];
+ unsigned nCase=0;
+ if (nEnd<nRangeBeg) nCase=1;
+ else if (nBeg>nRangeEnd) nCase=2;
+ else if (nBeg>=nRangeBeg && nEnd<=nRangeEnd) nCase=3;
+ else if (nEnd<=nRangeEnd) nCase=4;
+ else if (nBeg>=nRangeBeg) nCase=5;
+ else nCase=6;
+ switch (nCase) {
+ case 3: {
+ unsigned nTailBytes=(nAnz-(nNum+2))*sizeof(USHORT);
+ memcpy(&pNewWhichTable[nNum],&pNewWhichTable[nNum+2],nTailBytes);
+ nAnz-=2; // Merken: Array hat sich verkleinert
+ } break;
+ case 4: pNewWhichTable[nNum+1]=nRangeBeg-1; break;
+ case 5: pNewWhichTable[nNum]=nRangeEnd+1; break;
+ case 6: {
+ unsigned nTailBytes=(nAnz-(nNum+2))*sizeof(USHORT);
+ memcpy(&pNewWhichTable[nNum+4],&pNewWhichTable[nNum+2],nTailBytes);
+ nAnz+=2; // Merken: Array hat sich vergroessert
+ pNewWhichTable[nNum+2]=nRangeEnd+1;
+ pNewWhichTable[nNum+3]=pNewWhichTable[nNum+1];
+ pNewWhichTable[nNum+1]=nRangeBeg-1;
+ } break;
+ } // switch
+ }
+ return pNewWhichTable;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SvdProgressInfo::SvdProgressInfo( Link *_pLink )
+{
+ DBG_ASSERT(_pLink!=NULL,"SvdProgressInfo(): Kein Link angegeben!!");
+
+ pLink = _pLink;
+ nSumActionCount = 0;
+ nSumCurAction = 0;
+
+ nObjCount = 0;
+ nCurObj = 0;
+
+ nActionCount = 0;
+ nCurAction = 0;
+
+ nInsertCount = 0;
+ nCurInsert = 0;
+}
+
+void SvdProgressInfo::Init( ULONG _nSumActionCount, ULONG _nObjCount )
+{
+ nSumActionCount = _nSumActionCount;
+ nObjCount = _nObjCount;
+}
+
+BOOL SvdProgressInfo::ReportActions( ULONG nAnzActions )
+{
+ nSumCurAction += nAnzActions;
+ nCurAction += nAnzActions;
+ if(nCurAction > nActionCount)
+ nCurAction = nActionCount;
+
+ return pLink->Call(NULL) == 1L;
+}
+
+BOOL SvdProgressInfo::ReportInserts( ULONG nAnzInserts )
+{
+ nSumCurAction += nAnzInserts;
+ nCurInsert += nAnzInserts;
+
+ return pLink->Call(NULL) == 1L;
+}
+
+BOOL SvdProgressInfo::ReportRescales( ULONG nAnzRescales )
+{
+ nSumCurAction += nAnzRescales;
+ return pLink->Call(NULL) == 1L;
+}
+
+void SvdProgressInfo::SetActionCount( ULONG _nActionCount )
+{
+ nActionCount = _nActionCount;
+}
+
+void SvdProgressInfo::SetInsertCount( ULONG _nInsertCount )
+{
+ nInsertCount = _nInsertCount;
+}
+
+BOOL SvdProgressInfo::SetNextObject()
+{
+ nActionCount = 0;
+ nCurAction = 0;
+
+ nInsertCount = 0;
+ nCurInsert = 0;
+
+ nCurObj++;
+ return ReportActions(0);
+}
+
+void SvdProgressInfo::ReportError()
+{
+ pLink->Call((void *)1L);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #i101872# isolate GetTextEditBackgroundColor to tooling; it woll anyways only be used as long
+// as text edit is not running on overlay
+
+namespace
+{
+ bool impGetSdrObjListFillColor(
+ const SdrObjList& rList,
+ const Point& rPnt,
+ const SdrPageView& rTextEditPV,
+ const SetOfByte& rVisLayers,
+ Color& rCol)
+ {
+ if(!rList.GetModel())
+ return false;
+
+ bool bRet(false);
+ bool bMaster(rList.GetPage() ? rList.GetPage()->IsMasterPage() : false);
+
+ for(ULONG no(rList.GetObjCount()); !bRet && no > 0; )
+ {
+ no--;
+ SdrObject* pObj = rList.GetObj(no);
+ SdrObjList* pOL = pObj->GetSubList();
+
+ if(pOL)
+ {
+ // group object
+ bRet = impGetSdrObjListFillColor(*pOL, rPnt, rTextEditPV, rVisLayers, rCol);
+ }
+ else
+ {
+ SdrTextObj* pText = dynamic_cast< SdrTextObj * >(pObj);
+
+ // #108867# Exclude zero master page object (i.e. background shape) from color query
+ if(pText
+ && pObj->IsClosedObj()
+ && (!bMaster || (!pObj->IsNotVisibleAsMaster() && 0 != no))
+ && pObj->GetCurrentBoundRect().IsInside(rPnt)
+ && !pText->IsHideContour()
+ && SdrObjectPrimitiveHit(*pObj, rPnt, 0, rTextEditPV, &rVisLayers, false))
+ {
+ bRet = GetDraftFillColor(pObj->GetMergedItemSet(), rCol);
+ }
+ }
+ }
+
+ return bRet;
+ }
+
+ bool impGetSdrPageFillColor(
+ const SdrPage& rPage,
+ const Point& rPnt,
+ const SdrPageView& rTextEditPV,
+ const SetOfByte& rVisLayers,
+ Color& rCol,
+ bool bSkipBackgroundShape)
+ {
+ if(!rPage.GetModel())
+ return false;
+
+ bool bRet(impGetSdrObjListFillColor(rPage, rPnt, rTextEditPV, rVisLayers, rCol));
+
+ if(!bRet && !rPage.IsMasterPage())
+ {
+ if(rPage.TRG_HasMasterPage())
+ {
+ SetOfByte aSet(rVisLayers);
+ aSet &= rPage.TRG_GetMasterPageVisibleLayers();
+ SdrPage& rMasterPage = rPage.TRG_GetMasterPage();
+
+ // #108867# Don't fall back to background shape on
+ // master pages. This is later handled by
+ // GetBackgroundColor, and is necessary to cater for
+ // the silly ordering: 1. shapes, 2. master page
+ // shapes, 3. page background, 4. master page
+ // background.
+ bRet = impGetSdrPageFillColor(rMasterPage, rPnt, rTextEditPV, aSet, rCol, true);
+ }
+ }
+
+ // #108867# Only now determine background color from background shapes
+ if(!bRet && !bSkipBackgroundShape)
+ {
+ rCol = rPage.GetPageBackgroundColor();
+ return true;
+ }
+
+ return bRet;
+ }
+
+ Color impCalcBackgroundColor(
+ const Rectangle& rArea,
+ const SdrPageView& rTextEditPV,
+ const SdrPage& rPage)
+ {
+ svtools::ColorConfig aColorConfig;
+ Color aBackground(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ if(!rStyleSettings.GetHighContrastMode())
+ {
+ // search in page
+ const USHORT SPOTCOUNT(5);
+ Point aSpotPos[SPOTCOUNT];
+ Color aSpotColor[SPOTCOUNT];
+ ULONG nHeight( rArea.GetSize().Height() );
+ ULONG nWidth( rArea.GetSize().Width() );
+ ULONG nWidth14 = nWidth / 4;
+ ULONG nHeight14 = nHeight / 4;
+ ULONG nWidth34 = ( 3 * nWidth ) / 4;
+ ULONG nHeight34 = ( 3 * nHeight ) / 4;
+
+ USHORT i;
+ for ( i = 0; i < SPOTCOUNT; i++ )
+ {
+ // five spots are used
+ switch ( i )
+ {
+ case 0 :
+ {
+ // Center-Spot
+ aSpotPos[i] = rArea.Center();
+ }
+ break;
+
+ case 1 :
+ {
+ // TopLeft-Spot
+ aSpotPos[i] = rArea.TopLeft();
+ aSpotPos[i].X() += nWidth14;
+ aSpotPos[i].Y() += nHeight14;
+ }
+ break;
+
+ case 2 :
+ {
+ // TopRight-Spot
+ aSpotPos[i] = rArea.TopLeft();
+ aSpotPos[i].X() += nWidth34;
+ aSpotPos[i].Y() += nHeight14;
+ }
+ break;
+
+ case 3 :
+ {
+ // BottomLeft-Spot
+ aSpotPos[i] = rArea.TopLeft();
+ aSpotPos[i].X() += nWidth14;
+ aSpotPos[i].Y() += nHeight34;
+ }
+ break;
+
+ case 4 :
+ {
+ // BottomRight-Spot
+ aSpotPos[i] = rArea.TopLeft();
+ aSpotPos[i].X() += nWidth34;
+ aSpotPos[i].Y() += nHeight34;
+ }
+ break;
+
+ }
+
+ aSpotColor[i] = Color( COL_WHITE );
+ impGetSdrPageFillColor(rPage, aSpotPos[i], rTextEditPV, rTextEditPV.GetVisibleLayers(), aSpotColor[i], false);
+ }
+
+ USHORT aMatch[SPOTCOUNT];
+
+ for ( i = 0; i < SPOTCOUNT; i++ )
+ {
+ // were same spot colors found?
+ aMatch[i] = 0;
+
+ for ( USHORT j = 0; j < SPOTCOUNT; j++ )
+ {
+ if( j != i )
+ {
+ if( aSpotColor[i] == aSpotColor[j] )
+ {
+ aMatch[i]++;
+ }
+ }
+ }
+ }
+
+ // highest weight to center spot
+ aBackground = aSpotColor[0];
+
+ for ( USHORT nMatchCount = SPOTCOUNT - 1; nMatchCount > 1; nMatchCount-- )
+ {
+ // which spot color was found most?
+ for ( i = 0; i < SPOTCOUNT; i++ )
+ {
+ if( aMatch[i] == nMatchCount )
+ {
+ aBackground = aSpotColor[i];
+ nMatchCount = 1; // break outer for-loop
+ break;
+ }
+ }
+ }
+ }
+
+ return aBackground;
+ }
+} // end of anonymous namespace
+
+Color GetTextEditBackgroundColor(const SdrObjEditView& rView)
+{
+ svtools::ColorConfig aColorConfig;
+ Color aBackground(aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor);
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ if(!rStyleSettings.GetHighContrastMode())
+ {
+ bool bFound(false);
+ SdrTextObj* pText = dynamic_cast< SdrTextObj * >(rView.GetTextEditObject());
+
+ if(pText && pText->IsClosedObj())
+ {
+ ::sdr::table::SdrTableObj* pTable = dynamic_cast< ::sdr::table::SdrTableObj * >( pText );
+
+ if( pTable )
+ bFound = GetDraftFillColor(pTable->GetActiveCellItemSet(), aBackground );
+
+ if( !bFound )
+ bFound=GetDraftFillColor(pText->GetMergedItemSet(), aBackground);
+ }
+
+ if(!bFound && pText)
+ {
+ SdrPageView* pTextEditPV = rView.GetTextEditPageView();
+
+ if(pTextEditPV)
+ {
+ Point aPvOfs(pText->GetTextEditOffset());
+ const SdrPage* pPg = pTextEditPV->GetPage();
+
+ if(pPg)
+ {
+ Rectangle aSnapRect( pText->GetSnapRect() );
+ aSnapRect.Move(aPvOfs.X(), aPvOfs.Y());
+
+ return impCalcBackgroundColor(aSnapRect, *pTextEditPV, *pPg);
+ }
+ }
+ }
+ }
+
+ return aBackground;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx
new file mode 100644
index 000000000000..229ecea6c76f
--- /dev/null
+++ b/svx/source/svdraw/svdfmtf.cxx
@@ -0,0 +1,1031 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svdfmtf.hxx"
+#include <editeng/editdata.hxx>
+#include <math.h>
+#include <svx/xpoly.hxx>
+#include <vcl/svapp.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/shdditem.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xgrad.hxx>
+#include <svx/xflgrit.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/akrnitem.hxx>
+#include <editeng/wrlmitem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/colritem.hxx>
+#include <vcl/metric.hxx>
+#include <editeng/charscaleitem.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/svdattr.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdobj.hxx>
+#include "svditext.hxx"
+#include <svx/svdotext.hxx>
+#include <svx/svdorect.hxx>
+#include <svx/svdocirc.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdetc.hxx>
+#include <svl/itemset.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <svx/xlinjoit.hxx>
+#include <svx/xlndsit.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(SdrModel& rModel):
+ nMapScalingOfs(0),
+ pLineAttr(NULL),pFillAttr(NULL),pTextAttr(NULL),
+ pPage(NULL),pModel(NULL),nLayer(0),
+ nLineWidth(0),
+ maLineJoin(basegfx::B2DLINEJOIN_NONE),
+ maDash(XDASH_RECT, 0, 0, 0, 0, 0),
+ bFntDirty(TRUE),
+ bLastObjWasPolyWithoutLine(FALSE),bNoLine(FALSE),bNoFill(FALSE),bLastObjWasLine(FALSE)
+{
+ aVD.EnableOutput(FALSE);
+
+ // #i111954# init to no fill and no line initially
+ aVD.SetLineColor();
+ aVD.SetFillColor();
+
+ aOldLineColor.SetRed( aVD.GetLineColor().GetRed() + 1 ); // invalidate old line color
+ pLineAttr=new SfxItemSet(rModel.GetItemPool(),XATTR_LINE_FIRST,XATTR_LINE_LAST);
+ pFillAttr=new SfxItemSet(rModel.GetItemPool(),XATTR_FILL_FIRST,XATTR_FILL_LAST);
+ pTextAttr=new SfxItemSet(rModel.GetItemPool(),EE_ITEMS_START,EE_ITEMS_END);
+ pModel=&rModel;
+}
+
+ImpSdrGDIMetaFileImport::~ImpSdrGDIMetaFileImport()
+{
+ delete pLineAttr;
+ delete pFillAttr;
+ delete pTextAttr;
+}
+
+ULONG ImpSdrGDIMetaFileImport::DoImport(const GDIMetaFile& rMtf,
+ SdrObjList& rOL,
+ ULONG nInsPos,
+ SvdProgressInfo *pProgrInfo)
+{
+ pPage = rOL.GetPage();
+ GDIMetaFile* pTmpMtf=NULL;
+ GDIMetaFile* pMtf = (GDIMetaFile*) &rMtf;
+ ULONG nActionAnz=pMtf->GetActionCount();
+ sal_Bool bError = sal_False;
+
+
+ // setup some global scale parameter
+ // fScaleX, fScaleY, aScaleX, aScaleY, bMov, bSize
+ fScaleX = fScaleY = 1.0;
+ Size aMtfSize( pMtf->GetPrefSize() );
+ if ( aMtfSize.Width() & aMtfSize.Height() && ( aScaleRect.IsEmpty() == sal_False ) )
+ {
+ aOfs = aScaleRect.TopLeft();
+ if ( aMtfSize.Width() != ( aScaleRect.GetWidth() - 1 ) )
+ fScaleX = (double)( aScaleRect.GetWidth() - 1 ) / (double)aMtfSize.Width();
+ if ( aMtfSize.Height() != ( aScaleRect.GetHeight() - 1 ) )
+ fScaleY = (double)( aScaleRect.GetHeight() - 1 ) / (double)aMtfSize.Height();
+ }
+
+ bMov = aOfs.X()!=0 || aOfs.Y()!=0;
+ bSize = sal_False;
+
+ aScaleX = Fraction( 1, 1 );
+ aScaleY = Fraction( 1, 1 );
+ if ( aMtfSize.Width() != ( aScaleRect.GetWidth() - 1 ) )
+ {
+ aScaleX = Fraction( aScaleRect.GetWidth() - 1, aMtfSize.Width() );
+ bSize = sal_True;
+ }
+ if ( aMtfSize.Height() != ( aScaleRect.GetHeight() - 1 ) )
+ {
+ aScaleY = Fraction( aScaleRect.GetHeight() - 1, aMtfSize.Height() );
+ bSize = sal_True;
+ }
+
+ if(65000 < nActionAnz)
+ {
+ nActionAnz = 65000;
+ bError = TRUE;
+ }
+
+ if(pProgrInfo)
+ pProgrInfo->SetActionCount(nActionAnz);
+
+ ULONG nActionsToReport = 0;
+
+ for( MetaAction* pAct = pMtf->FirstAction(); pAct; pAct = pMtf->NextAction() )
+ {
+ switch (pAct->GetType())
+ {
+ case META_PIXEL_ACTION : DoAction((MetaPixelAction &)*pAct); break;
+ case META_POINT_ACTION : DoAction((MetaPointAction &)*pAct); break;
+ case META_LINE_ACTION : DoAction((MetaLineAction &)*pAct); break;
+ case META_RECT_ACTION : DoAction((MetaRectAction &)*pAct); break;
+ case META_ROUNDRECT_ACTION : DoAction((MetaRoundRectAction &)*pAct); break;
+ case META_ELLIPSE_ACTION : DoAction((MetaEllipseAction &)*pAct); break;
+ case META_ARC_ACTION : DoAction((MetaArcAction &)*pAct); break;
+ case META_PIE_ACTION : DoAction((MetaPieAction &)*pAct); break;
+ case META_CHORD_ACTION : DoAction((MetaChordAction &)*pAct); break;
+ case META_POLYLINE_ACTION : DoAction((MetaPolyLineAction &)*pAct); break;
+ case META_POLYGON_ACTION : DoAction((MetaPolygonAction &)*pAct); break;
+ case META_POLYPOLYGON_ACTION : DoAction((MetaPolyPolygonAction &)*pAct); break;
+ case META_TEXT_ACTION : DoAction((MetaTextAction &)*pAct); break;
+ case META_TEXTARRAY_ACTION : DoAction((MetaTextArrayAction &)*pAct); break;
+ case META_STRETCHTEXT_ACTION : DoAction((MetaStretchTextAction &)*pAct); break;
+ case META_BMP_ACTION : DoAction((MetaBmpAction &)*pAct); break;
+ case META_BMPSCALE_ACTION : DoAction((MetaBmpScaleAction &)*pAct); break;
+ case META_BMPEX_ACTION : DoAction((MetaBmpExAction &)*pAct); break;
+ case META_BMPEXSCALE_ACTION : DoAction((MetaBmpExScaleAction &)*pAct); break;
+ case META_LINECOLOR_ACTION : DoAction((MetaLineColorAction &)*pAct); break;
+ case META_FILLCOLOR_ACTION : DoAction((MetaFillColorAction &)*pAct); break;
+ case META_TEXTCOLOR_ACTION : DoAction((MetaTextColorAction &)*pAct); break;
+ case META_TEXTFILLCOLOR_ACTION : DoAction((MetaTextFillColorAction &)*pAct); break;
+ case META_FONT_ACTION : DoAction((MetaFontAction &)*pAct); break;
+ case META_TEXTALIGN_ACTION : DoAction((MetaTextAlignAction &)*pAct); break;
+ case META_MAPMODE_ACTION : DoAction((MetaMapModeAction &)*pAct); break;
+ case META_CLIPREGION_ACTION : DoAction((MetaClipRegionAction &)*pAct); break;
+ case META_MOVECLIPREGION_ACTION : DoAction((MetaMoveClipRegionAction &)*pAct); break;
+ case META_ISECTRECTCLIPREGION_ACTION: DoAction((MetaISectRectClipRegionAction&)*pAct); break;
+ case META_ISECTREGIONCLIPREGION_ACTION: DoAction((MetaISectRegionClipRegionAction&)*pAct); break;
+ case META_RASTEROP_ACTION : DoAction((MetaRasterOpAction &)*pAct); break;
+ case META_PUSH_ACTION : DoAction((MetaPushAction &)*pAct); break;
+ case META_POP_ACTION : DoAction((MetaPopAction &)*pAct); break;
+ case META_HATCH_ACTION : DoAction((MetaHatchAction &)*pAct); break;
+ case META_COMMENT_ACTION : DoAction((MetaCommentAction &)*pAct, pMtf); break;
+
+ }
+
+ if(pProgrInfo != NULL)
+ {
+ nActionsToReport++;
+ if(nActionsToReport >= 16) // Alle 16 Action updaten
+ {
+ if(!pProgrInfo->ReportActions(nActionsToReport))
+ break;
+ nActionsToReport = 0;
+ }
+ }
+ }
+
+ if(pProgrInfo != NULL)
+ {
+ pProgrInfo->ReportActions(nActionsToReport);
+ nActionsToReport = 0;
+ }
+
+ // MapMode-Scaling vornehmen
+ MapScaling();
+ // Objekte in vorgegebenes Rechteck hineinskalieren
+ ULONG nAnz=aTmpList.GetObjCount();
+
+ // Beim berechnen der Fortschrittsanzeige wird GetActionCount()*3 benutzt.
+ // Da in aTmpList allerdings weniger eintraege als GetActionCount()
+ // existieren koennen, muessen hier die zuviel vermuteten Actionen wieder
+ // hinzugefuegt werden.
+ nActionsToReport = (pMtf->GetActionCount() - nAnz)*2;
+
+
+ // Alle noch nicht gemeldeten Rescales melden
+ if(pProgrInfo)
+ {
+ pProgrInfo->ReportRescales(nActionsToReport);
+ pProgrInfo->SetInsertCount(nAnz);
+ }
+ nActionsToReport = 0;
+
+ // alle in aTmpList zwischengespeicherten Objekte nun in rOL ab der Position nInsPos einfuegen
+ if (nInsPos>rOL.GetObjCount()) nInsPos=rOL.GetObjCount();
+ SdrInsertReason aReason(SDRREASON_VIEWCALL);
+ for (ULONG i=0; i<nAnz; i++)
+ {
+ SdrObject* pObj=aTmpList.GetObj(i);
+ rOL.NbcInsertObject(pObj,nInsPos,&aReason);
+ nInsPos++;
+
+ if(pProgrInfo != NULL)
+ {
+ nActionsToReport++;
+ if(nActionsToReport >= 32) // Alle 32 Action updaten
+ {
+ pProgrInfo->ReportInserts(nActionsToReport);
+ nActionsToReport = 0;
+ }
+ }
+ }
+ if (pTmpMtf!=NULL) delete pTmpMtf;
+
+ // ein letztesmal alle verbliebennen Inserts reporten
+ if(pProgrInfo != NULL)
+ {
+ pProgrInfo->ReportInserts(nActionsToReport);
+ if(bError)
+ pProgrInfo->ReportError();
+ }
+
+ return aTmpList.GetObjCount();
+}
+
+void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, bool bForceTextAttr)
+{
+ bNoLine = FALSE; bNoFill = FALSE;
+ bool bLine = !bForceTextAttr;
+ bool bFill = (pObj==NULL) || (pObj->IsClosedObj() && !bForceTextAttr);
+ bool bText = bForceTextAttr || (pObj!=NULL && pObj->GetOutlinerParaObject()!=NULL);
+
+ if ( bLine )
+ {
+ if ( nLineWidth )
+ pLineAttr->Put( XLineWidthItem( nLineWidth ) );
+ else
+ pLineAttr->Put( XLineWidthItem( 0 ) );
+
+ aOldLineColor = aVD.GetLineColor();
+ if( aVD.IsLineColor() )
+ {
+ pLineAttr->Put(XLineStyleItem(XLINE_SOLID));
+ pLineAttr->Put(XLineColorItem(String(), aVD.GetLineColor()));
+ }
+ else
+ pLineAttr->Put(XLineStyleItem(XLINE_NONE));
+
+ switch(maLineJoin)
+ {
+ default : // basegfx::B2DLINEJOIN_NONE
+ pLineAttr->Put(XLineJointItem(XLINEJOINT_NONE));
+ break;
+ case basegfx::B2DLINEJOIN_MIDDLE:
+ pLineAttr->Put(XLineJointItem(XLINEJOINT_MIDDLE));
+ break;
+ case basegfx::B2DLINEJOIN_BEVEL:
+ pLineAttr->Put(XLineJointItem(XLINEJOINT_BEVEL));
+ break;
+ case basegfx::B2DLINEJOIN_MITER:
+ pLineAttr->Put(XLineJointItem(XLINEJOINT_MITER));
+ break;
+ case basegfx::B2DLINEJOIN_ROUND:
+ pLineAttr->Put(XLineJointItem(XLINEJOINT_ROUND));
+ break;
+ }
+
+ if(((maDash.GetDots() && maDash.GetDotLen()) || (maDash.GetDashes() && maDash.GetDashLen())) && maDash.GetDistance())
+ {
+ pLineAttr->Put(XLineDashItem(String(), maDash));
+ }
+ else
+ {
+ pLineAttr->Put(XLineDashItem(String(), XDash(XDASH_RECT)));
+ }
+ }
+ else
+ bNoLine = TRUE;
+
+ if ( bFill )
+ {
+ if( aVD.IsFillColor() )
+ {
+ pFillAttr->Put(XFillStyleItem(XFILL_SOLID));
+ pFillAttr->Put(XFillColorItem(String(), aVD.GetFillColor()));
+ }
+ else
+ pFillAttr->Put(XFillStyleItem(XFILL_NONE));
+ }
+ else
+ bNoFill = TRUE;
+
+ if ( bText && bFntDirty )
+ {
+ Font aFnt(aVD.GetFont());
+ pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
+ aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO ) );
+ pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
+ aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CJK ) );
+ pTextAttr->Put( SvxFontItem( aFnt.GetFamily(), aFnt.GetName(), aFnt.GetStyleName(),
+ aFnt.GetPitch(), aFnt.GetCharSet(), EE_CHAR_FONTINFO_CTL ) );
+ pTextAttr->Put(SvxPostureItem(aFnt.GetItalic(), EE_CHAR_ITALIC));
+ pTextAttr->Put(SvxWeightItem(aFnt.GetWeight(), EE_CHAR_WEIGHT));
+ sal_uInt32 nHeight = FRound(aFnt.GetSize().Height() * fScaleY);
+ pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
+ pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
+ pTextAttr->Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
+ pTextAttr->Put(SvxCharScaleWidthItem(100, EE_CHAR_FONTWIDTH));
+ pTextAttr->Put(SvxUnderlineItem(aFnt.GetUnderline(), EE_CHAR_UNDERLINE));
+ pTextAttr->Put(SvxOverlineItem(aFnt.GetOverline(), EE_CHAR_OVERLINE));
+ pTextAttr->Put(SvxCrossedOutItem(aFnt.GetStrikeout(), EE_CHAR_STRIKEOUT));
+ pTextAttr->Put(SvxShadowedItem(aFnt.IsShadow(), EE_CHAR_SHADOW));
+ pTextAttr->Put(SvxAutoKernItem(aFnt.IsKerning(), EE_CHAR_KERNING));
+ pTextAttr->Put(SvxWordLineModeItem(aFnt.IsWordLineMode(), EE_CHAR_WLM));
+ pTextAttr->Put(SvxContourItem(aFnt.IsOutline(), EE_CHAR_OUTLINE));
+ pTextAttr->Put(SvxColorItem(aFnt.GetColor(), EE_CHAR_COLOR));
+ //... svxfont textitem svditext
+ bFntDirty=FALSE;
+ }
+ if (pObj!=NULL)
+ {
+ pObj->SetLayer(nLayer);
+ if (bLine) pObj->SetMergedItemSet(*pLineAttr);
+ if (bFill) pObj->SetMergedItemSet(*pFillAttr);
+ if (bText)
+ {
+ pObj->SetMergedItemSet(*pTextAttr);
+ pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_LEFT ) );
+ }
+ }
+}
+
+void ImpSdrGDIMetaFileImport::InsertObj( SdrObject* pObj, sal_Bool bScale )
+{
+ if ( bScale && !aScaleRect.IsEmpty() )
+ {
+ if ( bSize )
+ pObj->NbcResize( Point(), aScaleX, aScaleY );
+ if ( bMov )
+ pObj->NbcMove( Size( aOfs.X(), aOfs.Y() ) );
+ }
+
+ // #i111954# check object for visibility
+ // used are SdrPathObj, SdrRectObj, SdrCircObj, SdrGrafObj
+ bool bVisible(false);
+
+ if(pObj->HasLineStyle())
+ {
+ bVisible = true;
+ }
+
+ if(!bVisible && pObj->HasFillStyle())
+ {
+ bVisible = true;
+ }
+
+ if(!bVisible)
+ {
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(pObj);
+
+ if(pTextObj && pTextObj->HasText())
+ {
+ bVisible = true;
+ }
+ }
+
+ if(!bVisible)
+ {
+ SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >(pObj);
+
+ if(pGrafObj)
+ {
+ // this may be refined to check if the graphic really is visible. It
+ // is here to ensure that graphic objects without fill, line and text
+ // get created
+ bVisible = true;
+ }
+ }
+
+ if(!bVisible)
+ {
+ SdrObject::Free(pObj);
+ }
+ else
+ {
+ aTmpList.InsertObject( pObj );
+ if ( HAS_BASE( SdrPathObj, pObj ) )
+ {
+ bool bClosed=pObj->IsClosedObj();
+ bLastObjWasPolyWithoutLine=bNoLine && bClosed;
+ bLastObjWasLine=!bClosed;
+ }
+ else
+ {
+ bLastObjWasPolyWithoutLine = FALSE;
+ bLastObjWasLine = FALSE;
+ }
+ }
+}
+
+/**************************************************************************************************/
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaPixelAction& /*rAct*/)
+{
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaPointAction& /*rAct*/)
+{
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct)
+{
+ // #i73407# reformulation to use new B2DPolygon classes
+ const basegfx::B2DPoint aStart(rAct.GetStartPoint().X(), rAct.GetStartPoint().Y());
+ const basegfx::B2DPoint aEnd(rAct.GetEndPoint().X(), rAct.GetEndPoint().Y());
+
+ if(!aStart.equal(aEnd))
+ {
+ basegfx::B2DPolygon aLine;
+ const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
+
+ aLine.append(aStart);
+ aLine.append(aEnd);
+ aLine.transform(aTransform);
+
+ const LineInfo& rLineInfo = rAct.GetLineInfo();
+ const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
+ bool bCreateLineObject(true);
+
+ if(bLastObjWasLine && (nNewLineWidth == nLineWidth) && CheckLastLineMerge(aLine))
+ {
+ bCreateLineObject = false;
+ }
+
+ if(bCreateLineObject)
+ {
+ SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine));
+ nLineWidth = nNewLineWidth;
+ maLineJoin = rLineInfo.GetLineJoin();
+ maDash = XDash(XDASH_RECT,
+ rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
+ rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
+ rLineInfo.GetDistance());
+ SetAttributes(pPath);
+ nLineWidth = 0;
+ maLineJoin = basegfx::B2DLINEJOIN_NONE;
+ maDash = XDash();
+ InsertObj(pPath, false);
+ }
+ }
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaRectAction& rAct)
+{
+ SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
+ SetAttributes(pRect);
+ InsertObj(pRect);
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaRoundRectAction& rAct)
+{
+ SdrRectObj* pRect=new SdrRectObj(rAct.GetRect());
+ SetAttributes(pRect);
+ long nRad=(rAct.GetHorzRound()+rAct.GetVertRound())/2;
+ if (nRad!=0) {
+ SfxItemSet aSet(*pLineAttr->GetPool(),SDRATTR_ECKENRADIUS,SDRATTR_ECKENRADIUS);
+ aSet.Put(SdrEckenradiusItem(nRad));
+ pRect->SetMergedItemSet(aSet);
+ }
+ InsertObj(pRect);
+}
+
+/**************************************************************************************************/
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaEllipseAction& rAct)
+{
+ SdrCircObj* pCirc=new SdrCircObj(OBJ_CIRC,rAct.GetRect());
+ SetAttributes(pCirc);
+ InsertObj(pCirc);
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaArcAction& rAct)
+{
+ Point aCenter(rAct.GetRect().Center());
+ long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
+ long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
+ SdrCircObj* pCirc=new SdrCircObj(OBJ_CARC,rAct.GetRect(),nStart,nEnd);
+ SetAttributes(pCirc);
+ InsertObj(pCirc);
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaPieAction& rAct)
+{
+ Point aCenter(rAct.GetRect().Center());
+ long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
+ long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
+ SdrCircObj* pCirc=new SdrCircObj(OBJ_SECT,rAct.GetRect(),nStart,nEnd);
+ SetAttributes(pCirc);
+ InsertObj(pCirc);
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaChordAction& rAct)
+{
+ Point aCenter(rAct.GetRect().Center());
+ long nStart=GetAngle(rAct.GetStartPoint()-aCenter);
+ long nEnd=GetAngle(rAct.GetEndPoint()-aCenter);
+ SdrCircObj* pCirc=new SdrCircObj(OBJ_CCUT,rAct.GetRect(),nStart,nEnd);
+ SetAttributes(pCirc);
+ InsertObj(pCirc);
+}
+
+/**************************************************************************************************/
+
+bool ImpSdrGDIMetaFileImport::CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly)
+{
+ // #i102706# Do not merge closed polygons
+ if(rSrcPoly.isClosed())
+ {
+ return false;
+ }
+
+ // #i73407# reformulation to use new B2DPolygon classes
+ if(bLastObjWasLine && (aOldLineColor == aVD.GetLineColor()) && rSrcPoly.count())
+ {
+ SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1);
+ SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj);
+
+ if(pLastPoly)
+ {
+ if(1L == pLastPoly->GetPathPoly().count())
+ {
+ bool bOk(false);
+ basegfx::B2DPolygon aDstPoly(pLastPoly->GetPathPoly().getB2DPolygon(0L));
+
+ // #i102706# Do not merge closed polygons
+ if(aDstPoly.isClosed())
+ {
+ return false;
+ }
+
+ if(aDstPoly.count())
+ {
+ const sal_uInt32 nMaxDstPnt(aDstPoly.count() - 1L);
+ const sal_uInt32 nMaxSrcPnt(rSrcPoly.count() - 1L);
+
+ if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(0L))
+ {
+ aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
+ bOk = true;
+ }
+ else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
+ {
+ basegfx::B2DPolygon aNew(rSrcPoly);
+ aNew.append(aDstPoly, 1L, aDstPoly.count() - 1L);
+ aDstPoly = aNew;
+ bOk = true;
+ }
+ else if(aDstPoly.getB2DPoint(0L) == rSrcPoly.getB2DPoint(0L))
+ {
+ aDstPoly.flip();
+ aDstPoly.append(rSrcPoly, 1L, rSrcPoly.count() - 1L);
+ bOk = true;
+ }
+ else if(aDstPoly.getB2DPoint(nMaxDstPnt) == rSrcPoly.getB2DPoint(nMaxSrcPnt))
+ {
+ basegfx::B2DPolygon aNew(rSrcPoly);
+ aNew.flip();
+ aDstPoly.append(aNew, 1L, aNew.count() - 1L);
+ bOk = true;
+ }
+ }
+
+ if(bOk)
+ {
+ pLastPoly->NbcSetPathPoly(basegfx::B2DPolyPolygon(aDstPoly));
+ }
+
+ return bOk;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool ImpSdrGDIMetaFileImport::CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon & rPolyPolygon)
+{
+ // #i73407# reformulation to use new B2DPolygon classes
+ if(bLastObjWasPolyWithoutLine)
+ {
+ SdrObject* pTmpObj = aTmpList.GetObj(aTmpList.GetObjCount() - 1);
+ SdrPathObj* pLastPoly = PTR_CAST(SdrPathObj, pTmpObj);
+
+ if(pLastPoly)
+ {
+ if(pLastPoly->GetPathPoly() == rPolyPolygon)
+ {
+ SetAttributes(NULL);
+
+ if(!bNoLine && bNoFill)
+ {
+ pLastPoly->SetMergedItemSet(*pLineAttr);
+
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+
+void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct )
+{
+ // #i73407# reformulation to use new B2DPolygon classes
+ basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
+
+ if(aSource.count())
+ {
+ const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
+ aSource.transform(aTransform);
+ }
+
+ const LineInfo& rLineInfo = rAct.GetLineInfo();
+ const sal_Int32 nNewLineWidth(rLineInfo.GetWidth());
+ bool bCreateLineObject(true);
+
+ if(bLastObjWasLine && (nNewLineWidth == nLineWidth) && CheckLastLineMerge(aSource))
+ {
+ bCreateLineObject = false;
+ }
+ else if(bLastObjWasPolyWithoutLine && CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
+ {
+ bCreateLineObject = false;
+ }
+
+ if(bCreateLineObject)
+ {
+ SdrPathObj* pPath = new SdrPathObj(
+ aSource.isClosed() ? OBJ_POLY : OBJ_PLIN,
+ basegfx::B2DPolyPolygon(aSource));
+ nLineWidth = nNewLineWidth;
+ maLineJoin = rLineInfo.GetLineJoin();
+ maDash = XDash(XDASH_RECT,
+ rLineInfo.GetDotCount(), rLineInfo.GetDotLen(),
+ rLineInfo.GetDashCount(), rLineInfo.GetDashLen(),
+ rLineInfo.GetDistance());
+ SetAttributes(pPath);
+ nLineWidth = 0;
+ maLineJoin = basegfx::B2DLINEJOIN_NONE;
+ maDash = XDash();
+ InsertObj(pPath, false);
+ }
+}
+
+void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction& rAct )
+{
+ // #i73407# reformulation to use new B2DPolygon classes
+ basegfx::B2DPolygon aSource(rAct.GetPolygon().getB2DPolygon());
+
+ if(aSource.count())
+ {
+ const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
+ aSource.transform(aTransform);
+
+ if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource)))
+ {
+ // #i73407# make sure polygon is closed, it's a filled primitive
+ aSource.setClosed(true);
+
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, basegfx::B2DPolyPolygon(aSource));
+ SetAttributes(pPath);
+ InsertObj(pPath, false);
+ }
+ }
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction& rAct)
+{
+ // #i73407# reformulation to use new B2DPolygon classes
+ basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
+
+ if(aSource.count())
+ {
+ const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
+ aSource.transform(aTransform);
+
+ if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
+ {
+ // #i73407# make sure polygon is closed, it's a filled primitive
+ aSource.setClosed(true);
+
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
+ SetAttributes(pPath);
+ InsertObj(pPath, false);
+ }
+ }
+}
+
+/**************************************************************************************************/
+
+void ImpSdrGDIMetaFileImport::ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct )
+{
+ // calc text box size, add 5% to make it fit safely
+
+ FontMetric aFontMetric( aVD.GetFontMetric() );
+ Font aFnt( aVD.GetFont() );
+ FontAlign eAlg( aFnt.GetAlign() );
+
+ sal_Int32 nTextWidth = (sal_Int32)( aVD.GetTextWidth( rStr ) * fScaleX );
+ sal_Int32 nTextHeight = (sal_Int32)( aVD.GetTextHeight() * fScaleY );
+ //sal_Int32 nDxWidth = 0;
+ //sal_Int32 nLen = rStr.Len();
+
+ Point aPos( FRound(rPos.X() * fScaleX + aOfs.X()), FRound(rPos.Y() * fScaleY + aOfs.Y()) );
+ Size aSize( nTextWidth, nTextHeight );
+
+ if ( eAlg == ALIGN_BASELINE )
+ aPos.Y() -= FRound(aFontMetric.GetAscent() * fScaleY);
+ else if ( eAlg == ALIGN_BOTTOM )
+ aPos.Y() -= nTextHeight;
+
+ Rectangle aTextRect( aPos, aSize );
+ SdrRectObj* pText =new SdrRectObj( OBJ_TEXT, aTextRect );
+
+ if ( aFnt.GetWidth() || ( rAct.GetType() == META_STRETCHTEXT_ACTION ) )
+ {
+ pText->ClearMergedItem( SDRATTR_TEXT_AUTOGROWWIDTH );
+ pText->SetMergedItem( SdrTextAutoGrowHeightItem( FALSE ) );
+ // don't let the margins eat the space needed for the text
+ pText->SetMergedItem ( SdrTextUpperDistItem (0));
+ pText->SetMergedItem ( SdrTextLowerDistItem (0));
+ pText->SetMergedItem ( SdrTextRightDistItem (0));
+ pText->SetMergedItem ( SdrTextLeftDistItem (0));
+ pText->SetMergedItem( SdrTextFitToSizeTypeItem( SDRTEXTFIT_ALLLINES ) );
+ }
+ else
+ pText->SetMergedItem( SdrTextAutoGrowWidthItem( sal_True ) );
+
+ pText->SetModel( pModel );
+ pText->SetLayer( nLayer );
+ pText->NbcSetText( rStr );
+ SetAttributes( pText, TRUE );
+ pText->SetSnapRect( aTextRect );
+
+ if (!aFnt.IsTransparent())
+ {
+ SfxItemSet aAttr(*pFillAttr->GetPool(),XATTR_FILL_FIRST,XATTR_FILL_LAST);
+ aAttr.Put(XFillStyleItem(XFILL_SOLID));
+ aAttr.Put(XFillColorItem(String(), aFnt.GetFillColor()));
+ pText->SetMergedItemSet(aAttr);
+ }
+ sal_uInt32 nWink = aFnt.GetOrientation();
+ if ( nWink )
+ {
+ nWink*=10;
+ double a=nWink*nPi180;
+ double nSin=sin(a);
+ double nCos=cos(a);
+ pText->NbcRotate(aPos,nWink,nSin,nCos);
+ }
+ InsertObj( pText, sal_False );
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaTextAction& rAct)
+{
+ XubString aStr(rAct.GetText());
+ aStr.Erase(0,rAct.GetIndex());
+ aStr.Erase(rAct.GetLen());
+ ImportText( rAct.GetPoint(), aStr, rAct );
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaTextArrayAction& rAct)
+{
+ XubString aStr(rAct.GetText());
+ aStr.Erase(0,rAct.GetIndex());
+ aStr.Erase(rAct.GetLen());
+ ImportText( rAct.GetPoint(), aStr, rAct );
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaStretchTextAction& rAct)
+{
+ XubString aStr(rAct.GetText());
+ aStr.Erase(0,rAct.GetIndex());
+ aStr.Erase(rAct.GetLen());
+ ImportText( rAct.GetPoint(), aStr, rAct );
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaBmpAction& rAct)
+{
+ Rectangle aRect(rAct.GetPoint(),rAct.GetBitmap().GetSizePixel());
+ aRect.Right()++; aRect.Bottom()++;
+ SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
+ InsertObj(pGraf);
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaBmpScaleAction& rAct)
+{
+ Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
+ aRect.Right()++; aRect.Bottom()++;
+ SdrGrafObj* pGraf=new SdrGrafObj(Graphic(rAct.GetBitmap()),aRect);
+ InsertObj(pGraf);
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExAction& rAct)
+{
+ Rectangle aRect(rAct.GetPoint(),rAct.GetBitmapEx().GetSizePixel());
+ aRect.Right()++; aRect.Bottom()++;
+ SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
+ InsertObj(pGraf);
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaBmpExScaleAction& rAct)
+{
+ Rectangle aRect(rAct.GetPoint(),rAct.GetSize());
+ aRect.Right()++; aRect.Bottom()++;
+ SdrGrafObj* pGraf=new SdrGrafObj( rAct.GetBitmapEx(), aRect );
+ InsertObj(pGraf);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct )
+{
+ // #i73407# reformulation to use new B2DPolygon classes
+ basegfx::B2DPolyPolygon aSource(rAct.GetPolyPolygon().getB2DPolyPolygon());
+
+ if(aSource.count())
+ {
+ const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y()));
+ aSource.transform(aTransform);
+
+ if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
+ {
+ const Hatch& rHatch = rAct.GetHatch();
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
+ SfxItemSet aHatchAttr(pModel->GetItemPool(),
+ XATTR_FILLSTYLE, XATTR_FILLSTYLE,
+ XATTR_FILLHATCH, XATTR_FILLHATCH, 0, 0 );
+ XHatchStyle eStyle;
+
+ switch(rHatch.GetStyle())
+ {
+ case(HATCH_TRIPLE) :
+ {
+ eStyle = XHATCH_TRIPLE;
+ break;
+ }
+
+ case(HATCH_DOUBLE) :
+ {
+ eStyle = XHATCH_DOUBLE;
+ break;
+ }
+
+ default:
+ {
+ eStyle = XHATCH_SINGLE;
+ break;
+ }
+ }
+
+ SetAttributes(pPath);
+ aHatchAttr.Put(XFillStyleItem(XFILL_HATCH));
+ aHatchAttr.Put(XFillHatchItem(&pModel->GetItemPool(), XHatch(rHatch.GetColor(), eStyle, rHatch.GetDistance(), rHatch.GetAngle())));
+ pPath->SetMergedItemSet(aHatchAttr);
+
+ InsertObj(pPath, false);
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaLineColorAction& rAct)
+{
+ rAct.Execute(&aVD);
+}
+
+void ImpSdrGDIMetaFileImport::DoAction(MetaMapModeAction& rAct)
+{
+ MapScaling();
+ rAct.Execute(&aVD);
+ bLastObjWasPolyWithoutLine=FALSE;
+ bLastObjWasLine=FALSE;
+}
+
+void ImpSdrGDIMetaFileImport::MapScaling()
+{
+ sal_uInt32 i, nAnz = aTmpList.GetObjCount();
+ const MapMode& rMap = aVD.GetMapMode();
+ Point aMapOrg( rMap.GetOrigin() );
+ sal_Bool bMov2 = aMapOrg.X() != 0 || aMapOrg.Y() != 0;
+ if ( bMov2 )
+ {
+ for ( i = nMapScalingOfs; i < nAnz; i++ )
+ {
+ SdrObject* pObj = aTmpList.GetObj(i);
+ if ( bMov2 )
+ pObj->NbcMove( Size( aMapOrg.X(), aMapOrg.Y() ) );
+ }
+ }
+ nMapScalingOfs = nAnz;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pMtf )
+{
+ ByteString aSkipComment;
+
+ if( rAct.GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
+ {
+ MetaGradientExAction* pAct = (MetaGradientExAction*) pMtf->NextAction();
+
+ if( pAct && pAct->GetType() == META_GRADIENTEX_ACTION )
+ {
+ // #i73407# reformulation to use new B2DPolygon classes
+ basegfx::B2DPolyPolygon aSource(pAct->GetPolyPolygon().getB2DPolyPolygon());
+
+ if(aSource.count())
+ {
+ if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource))
+ {
+ const Gradient& rGrad = pAct->GetGradient();
+ SdrPathObj* pPath = new SdrPathObj(OBJ_POLY, aSource);
+ SfxItemSet aGradAttr(pModel->GetItemPool(),
+ XATTR_FILLSTYLE, XATTR_FILLSTYLE,
+ XATTR_FILLGRADIENT, XATTR_FILLGRADIENT, 0, 0 );
+ XGradient aXGradient;
+
+ aXGradient.SetGradientStyle((XGradientStyle)rGrad.GetStyle());
+ aXGradient.SetStartColor(rGrad.GetStartColor());
+ aXGradient.SetEndColor(rGrad.GetEndColor());
+ aXGradient.SetAngle((USHORT)rGrad.GetAngle());
+ aXGradient.SetBorder(rGrad.GetBorder());
+ aXGradient.SetXOffset(rGrad.GetOfsX());
+ aXGradient.SetYOffset(rGrad.GetOfsY());
+ aXGradient.SetStartIntens(rGrad.GetStartIntensity());
+ aXGradient.SetEndIntens(rGrad.GetEndIntensity());
+ aXGradient.SetSteps(rGrad.GetSteps());
+
+ if(aVD.IsLineColor())
+ {
+ // switch line off; when there was one there will be a
+ // META_POLYLINE_ACTION following creating another object
+ const Color aLineColor(aVD.GetLineColor());
+ aVD.SetLineColor();
+ SetAttributes(pPath);
+ aVD.SetLineColor(aLineColor);
+ }
+ else
+ {
+ SetAttributes(pPath);
+ }
+
+ aGradAttr.Put(XFillStyleItem(XFILL_GRADIENT));
+ aGradAttr.Put(XFillGradientItem(&pModel->GetItemPool(), aXGradient));
+ pPath->SetMergedItemSet(aGradAttr);
+
+ InsertObj(pPath);
+ }
+ }
+
+ aSkipComment = "XGRAD_SEQ_END";
+ }
+ }
+
+ if(aSkipComment.Len())
+ {
+ MetaAction* pSkipAct = pMtf->NextAction();
+
+ while( pSkipAct
+ && ((pSkipAct->GetType() != META_COMMENT_ACTION )
+ || (((MetaCommentAction*)pSkipAct)->GetComment().CompareIgnoreCaseToAscii(aSkipComment.GetBuffer()) != COMPARE_EQUAL)))
+ {
+ pSkipAct = pMtf->NextAction();
+ }
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx
new file mode 100644
index 000000000000..6ba95c667ab1
--- /dev/null
+++ b/svx/source/svdraw/svdfmtf.hxx
@@ -0,0 +1,169 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVDFMTF_HXX
+#define _SVDFMTF_HXX
+
+#include <vcl/metaact.hxx>
+#include <vcl/virdev.hxx>
+#include <svx/svdobj.hxx>
+
+//************************************************************
+// Vorausdeklarationen
+//************************************************************
+
+class SfxItemSet;
+class SdrObjList;
+class SdrModel;
+class SdrPage;
+class SdrObject;
+class SvdProgressInfo;
+
+//************************************************************
+// Hilfsklasse SdrObjRefList
+//************************************************************
+
+class SdrObjRefList
+{
+ Container aList;
+public:
+
+ SdrObjRefList()
+ : aList(1024,64,64)
+ {}
+
+ void Clear() { aList.Clear(); }
+ ULONG GetObjCount() const { return aList.Count(); }
+ SdrObject* GetObj(ULONG nNum) const { return (SdrObject*)aList.GetObject(nNum); }
+ SdrObject* operator[](ULONG nNum) const { return (SdrObject*)aList.GetObject(nNum); }
+ void InsertObject(SdrObject* pObj, ULONG nPos=CONTAINER_APPEND) { aList.Insert(pObj,nPos); }
+ void RemoveObject(ULONG nPos) { aList.Remove(nPos); }
+};
+
+//************************************************************
+// Hilfsklasse ImpSdrGDIMetaFileImport
+//************************************************************
+
+class ImpSdrGDIMetaFileImport
+{
+protected:
+ SdrObjRefList aTmpList;
+ VirtualDevice aVD;
+ Rectangle aScaleRect;
+ ULONG nMapScalingOfs; // ab hier nocht nicht mit MapScaling bearbeitet
+ SfxItemSet* pLineAttr;
+ SfxItemSet* pFillAttr;
+ SfxItemSet* pTextAttr;
+ SdrPage* pPage;
+ SdrModel* pModel;
+ SdrLayerID nLayer;
+ Color aOldLineColor;
+ sal_Int32 nLineWidth;
+ basegfx::B2DLineJoin maLineJoin;
+ XDash maDash;
+
+ sal_Bool bMov;
+ sal_Bool bSize;
+ Point aOfs;
+ double fScaleX;
+ double fScaleY;
+ Fraction aScaleX;
+ Fraction aScaleY;
+
+ sal_Bool bFntDirty;
+
+ // fuer Optimierung von (PenNULL,Brush,DrawPoly),(Pen,BrushNULL,DrawPoly) -> aus 2 mach ein
+ sal_Bool bLastObjWasPolyWithoutLine;
+ sal_Bool bNoLine;
+ sal_Bool bNoFill;
+
+ // fuer Optimierung mehrerer Linien zu einer Polyline
+ sal_Bool bLastObjWasLine;
+
+protected:
+ void DoAction(MetaPixelAction & rAct);
+ void DoAction(MetaPointAction & rAct);
+ void DoAction(MetaLineAction & rAct);
+ void DoAction(MetaRectAction & rAct);
+ void DoAction(MetaRoundRectAction & rAct);
+ void DoAction(MetaEllipseAction & rAct);
+ void DoAction(MetaArcAction & rAct);
+ void DoAction(MetaPieAction & rAct);
+ void DoAction(MetaChordAction & rAct);
+ void DoAction(MetaPolyLineAction & rAct);
+ void DoAction(MetaPolygonAction & rAct);
+ void DoAction(MetaPolyPolygonAction & rAct);
+ void DoAction(MetaTextAction & rAct);
+ void DoAction(MetaTextArrayAction & rAct);
+ void DoAction(MetaStretchTextAction & rAct);
+ void DoAction(MetaBmpAction & rAct);
+ void DoAction(MetaBmpScaleAction & rAct);
+ void DoAction(MetaBmpExAction & rAct);
+ void DoAction(MetaBmpExScaleAction & rAct);
+ void DoAction(MetaHatchAction & rAct);
+ void DoAction(MetaLineColorAction & rAct);
+ void DoAction(MetaMapModeAction & rAct);
+ void DoAction(MetaFillColorAction & rAct) { rAct.Execute(&aVD); }
+ void DoAction(MetaTextColorAction & rAct) { rAct.Execute(&aVD); }
+ void DoAction(MetaTextFillColorAction & rAct) { rAct.Execute(&aVD); }
+ void DoAction(MetaFontAction & rAct) { rAct.Execute(&aVD); bFntDirty=TRUE; }
+ void DoAction(MetaTextAlignAction & rAct) { rAct.Execute(&aVD); bFntDirty=TRUE; }
+ void DoAction(MetaClipRegionAction & rAct) { rAct.Execute(&aVD); }
+ void DoAction(MetaRasterOpAction & rAct) { rAct.Execute(&aVD); }
+ void DoAction(MetaPushAction & rAct) { rAct.Execute(&aVD); }
+ void DoAction(MetaPopAction & rAct) { rAct.Execute(&aVD); bFntDirty=TRUE; }
+ void DoAction(MetaMoveClipRegionAction & rAct) { rAct.Execute(&aVD); }
+ void DoAction(MetaISectRectClipRegionAction& rAct) { rAct.Execute(&aVD); }
+ void DoAction(MetaISectRegionClipRegionAction& rAct) { rAct.Execute(&aVD); }
+ void DoAction(MetaCommentAction& rAct, GDIMetaFile* pMtf);
+
+ void ImportText( const Point& rPos, const XubString& rStr, const MetaAction& rAct );
+ void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);
+ void InsertObj( SdrObject* pObj, sal_Bool bScale = sal_True );
+ void MapScaling();
+
+ // #i73407# reformulation to use new B2DPolygon classes
+ bool CheckLastLineMerge(const basegfx::B2DPolygon& rSrcPoly);
+ bool CheckLastPolyLineAndFillMerge(const basegfx::B2DPolyPolygon& rPolyPolygon);
+
+public:
+ ImpSdrGDIMetaFileImport(SdrModel& rModel);
+ ~ImpSdrGDIMetaFileImport();
+ ULONG DoImport(const GDIMetaFile& rMtf, SdrObjList& rDestList, ULONG nInsPos=CONTAINER_APPEND, SvdProgressInfo *pProgrInfo = NULL);
+ void SetLayer(SdrLayerID nLay) { nLayer=nLay; }
+ SdrLayerID GetLayer() const { return nLayer; }
+ void SetScaleRect(const Rectangle& rRect) { aScaleRect=rRect; }
+ const Rectangle& GetScaleRect() const { return aScaleRect; }
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#endif //_SVDFMTF_HXX
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdglev.cxx b/svx/source/svdraw/svdglev.cxx
new file mode 100644
index 000000000000..368ff3db6199
--- /dev/null
+++ b/svx/source/svdraw/svdglev.cxx
@@ -0,0 +1,424 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdglev.hxx>
+#include <math.h>
+
+#include <svx/svdundo.hxx>
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+#include <svx/svdpagv.hxx>
+#include <svx/svdglue.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdobj.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrGlueEditView::ImpClearVars()
+{
+}
+
+SdrGlueEditView::SdrGlueEditView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrPolyEditView(pModel1,pOut)
+{
+ ImpClearVars();
+}
+
+SdrGlueEditView::~SdrGlueEditView()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrGlueEditView::ImpDoMarkedGluePoints(PGlueDoFunc pDoFunc, BOOL bConst, const void* p1, const void* p2, const void* p3, const void* p4, const void* p5)
+{
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
+ ULONG nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ if (nPtAnz!=0) {
+ SdrGluePointList* pGPL=NULL;
+ if (bConst) {
+ const SdrGluePointList* pConstGPL=pObj->GetGluePointList();
+ pGPL=(SdrGluePointList*)pConstGPL;
+ } else {
+ pGPL=pObj->ForceGluePointList();
+ }
+ if (pGPL!=NULL)
+ {
+ if(!bConst && IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
+
+ for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++)
+ {
+ USHORT nPtId=pPts->GetObject(nPtNum);
+ USHORT nGlueIdx=pGPL->FindGluePoint(nPtId);
+ if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND)
+ {
+ SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
+ (*pDoFunc)(rGP,pObj,p1,p2,p3,p4,p5);
+ }
+ }
+ if (!bConst)
+ {
+ pObj->SetChanged();
+ pObj->BroadcastObjectChange();
+ }
+ }
+ }
+ }
+ if (!bConst && nMarkAnz!=0) pMod->SetChanged();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ImpGetEscDir(SdrGluePoint& rGP, const SdrObject* /*pObj*/, const void* pbFirst, const void* pnThisEsc, const void* pnRet, const void*, const void*)
+{
+ USHORT& nRet=*(USHORT*)pnRet;
+ BOOL& bFirst=*(BOOL*)pbFirst;
+ if (nRet!=FUZZY) {
+ USHORT nEsc=rGP.GetEscDir();
+ BOOL bOn=(nEsc & *(USHORT*)pnThisEsc)!=0;
+ if (bFirst) { nRet=bOn; bFirst=FALSE; }
+ else if (nRet!=bOn) nRet=FUZZY;
+ }
+}
+
+TRISTATE SdrGlueEditView::IsMarkedGluePointsEscDir(USHORT nThisEsc) const
+{
+ ForceUndirtyMrkPnt();
+ BOOL bFirst=TRUE;
+ USHORT nRet=FALSE;
+ ((SdrGlueEditView*)this)->ImpDoMarkedGluePoints(ImpGetEscDir,TRUE,&bFirst,&nThisEsc,&nRet);
+ return (TRISTATE)nRet;
+}
+
+static void ImpSetEscDir(SdrGluePoint& rGP, const SdrObject* /*pObj*/, const void* pnThisEsc, const void* pbOn, const void*, const void*, const void*)
+{
+ USHORT nEsc=rGP.GetEscDir();
+ if (*(BOOL*)pbOn) nEsc|=*(USHORT*)pnThisEsc;
+ else nEsc&=~*(USHORT*)pnThisEsc;
+ rGP.SetEscDir(nEsc);
+}
+
+void SdrGlueEditView::SetMarkedGluePointsEscDir(USHORT nThisEsc, BOOL bOn)
+{
+ ForceUndirtyMrkPnt();
+ BegUndo(ImpGetResStr(STR_EditSetGlueEscDir),GetDescriptionOfMarkedGluePoints());
+ ImpDoMarkedGluePoints(ImpSetEscDir,FALSE,&nThisEsc,&bOn);
+ EndUndo();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ImpGetPercent(SdrGluePoint& rGP, const SdrObject* /*pObj*/, const void* pbFirst, const void* pnRet, const void*, const void*, const void*)
+{
+ USHORT& nRet=*(USHORT*)pnRet;
+ BOOL& bFirst=*(BOOL*)pbFirst;
+ if (nRet!=FUZZY) {
+ bool bOn=rGP.IsPercent();
+ if (bFirst) { nRet=bOn; bFirst=FALSE; }
+ else if ((nRet!=0)!=bOn) nRet=FUZZY;
+ }
+}
+
+TRISTATE SdrGlueEditView::IsMarkedGluePointsPercent() const
+{
+ ForceUndirtyMrkPnt();
+ BOOL bFirst=TRUE;
+ USHORT nRet=TRUE;
+ ((SdrGlueEditView*)this)->ImpDoMarkedGluePoints(ImpGetPercent,TRUE,&bFirst,&nRet);
+ return (TRISTATE)nRet;
+}
+
+static void ImpSetPercent(SdrGluePoint& rGP, const SdrObject* pObj, const void* pbOn, const void*, const void*, const void*, const void*)
+{
+ Point aPos(rGP.GetAbsolutePos(*pObj));
+ rGP.SetPercent(*(BOOL*)pbOn);
+ rGP.SetAbsolutePos(aPos,*pObj);
+}
+
+void SdrGlueEditView::SetMarkedGluePointsPercent(BOOL bOn)
+{
+ ForceUndirtyMrkPnt();
+ BegUndo(ImpGetResStr(STR_EditSetGluePercent),GetDescriptionOfMarkedGluePoints());
+ ImpDoMarkedGluePoints(ImpSetPercent,FALSE,&bOn);
+ EndUndo();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ImpGetAlign(SdrGluePoint& rGP, const SdrObject* /*pObj*/, const void* pbFirst, const void* pbDontCare, const void* pbVert, const void* pnRet, const void*)
+{
+ USHORT& nRet=*(USHORT*)pnRet;
+ BOOL& bFirst=*(BOOL*)pbFirst;
+ BOOL& bDontCare=*(BOOL*)pbDontCare;
+ BOOL bVert=*(BOOL*)pbVert;
+ if (!bDontCare) {
+ USHORT nAlg=0;
+ if (bVert) {
+ nAlg=rGP.GetVertAlign();
+ } else {
+ nAlg=rGP.GetHorzAlign();
+ }
+ if (bFirst) { nRet=nAlg; bFirst=FALSE; }
+ else if (nRet!=nAlg) {
+ if (bVert) {
+ nRet=SDRVERTALIGN_DONTCARE;
+ } else {
+ nRet=SDRHORZALIGN_DONTCARE;
+ }
+ bDontCare=TRUE;
+ }
+ }
+}
+
+USHORT SdrGlueEditView::GetMarkedGluePointsAlign(BOOL bVert) const
+{
+ ForceUndirtyMrkPnt();
+ BOOL bFirst=TRUE;
+ BOOL bDontCare=FALSE;
+ USHORT nRet=0;
+ ((SdrGlueEditView*)this)->ImpDoMarkedGluePoints(ImpGetAlign,TRUE,&bFirst,&bDontCare,&bVert,&nRet);
+ return nRet;
+}
+
+static void ImpSetAlign(SdrGluePoint& rGP, const SdrObject* pObj, const void* pbVert, const void* pnAlign, const void*, const void*, const void*)
+{
+ Point aPos(rGP.GetAbsolutePos(*pObj));
+ if (*(BOOL*)pbVert) { // bVert?
+ rGP.SetVertAlign(*(USHORT*)pnAlign);
+ } else {
+ rGP.SetHorzAlign(*(USHORT*)pnAlign);
+ }
+ rGP.SetAbsolutePos(aPos,*pObj);
+}
+
+void SdrGlueEditView::SetMarkedGluePointsAlign(BOOL bVert, USHORT nAlign)
+{
+ ForceUndirtyMrkPnt();
+ BegUndo(ImpGetResStr(STR_EditSetGlueAlign),GetDescriptionOfMarkedGluePoints());
+ ImpDoMarkedGluePoints(ImpSetAlign,FALSE,&bVert,&nAlign);
+ EndUndo();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrGlueEditView::IsDeleteMarkedGluePointsPossible() const
+{
+ return HasMarkedGluePoints();
+}
+
+void SdrGlueEditView::DeleteMarkedGluePoints()
+{
+ BrkAction();
+ ForceUndirtyMrkPnt();
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedGluePoints(),SDRREPFUNC_OBJ_DELETE);
+
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
+ ULONG nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ if (nPtAnz!=0)
+ {
+ SdrGluePointList* pGPL=pObj->ForceGluePointList();
+ if (pGPL!=NULL)
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
+
+ for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++)
+ {
+ USHORT nPtId=pPts->GetObject(nPtNum);
+ USHORT nGlueIdx=pGPL->FindGluePoint(nPtId);
+ if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND)
+ {
+ pGPL->Delete(nGlueIdx);
+ }
+ }
+ pObj->SetChanged();
+ pObj->BroadcastObjectChange();
+ }
+ }
+ }
+ if( bUndo )
+ EndUndo();
+ UnmarkAllGluePoints();
+ if (nMarkAnz!=0)
+ pMod->SetChanged();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrGlueEditView::ImpCopyMarkedGluePoints()
+{
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ BegUndo();
+
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrUShortCont* pPts=pM->GetMarkedGluePoints();
+ SdrGluePointList* pGPL=pObj->ForceGluePointList();
+ ULONG nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ if (nPtAnz!=0 && pGPL!=NULL)
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
+
+ for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++)
+ {
+ USHORT nPtId=pPts->GetObject(nPtNum);
+ USHORT nGlueIdx=pGPL->FindGluePoint(nPtId);
+ if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND)
+ {
+ SdrGluePoint aNewGP((*pGPL)[nGlueIdx]); // GluePoint klonen
+ USHORT nNewIdx=pGPL->Insert(aNewGP); // und einfuegen
+ USHORT nNewId=(*pGPL)[nNewIdx].GetId(); // Id des neuen GluePoints ermitteln
+ pPts->Replace(nNewId,nPtNum); // und diesen markieren (anstelle des alten)
+ }
+ }
+ }
+ }
+ if( bUndo )
+ EndUndo();
+
+ if (nMarkAnz!=0)
+ pMod->SetChanged();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrGlueEditView::ImpTransformMarkedGluePoints(PGlueTrFunc pTrFunc, const void* p1, const void* p2, const void* p3, const void* p4, const void* p5)
+{
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
+ ULONG nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ if (nPtAnz!=0) {
+ SdrGluePointList* pGPL=pObj->ForceGluePointList();
+ if (pGPL!=NULL)
+ {
+ if( IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
+
+ for (ULONG nPtNum=0; nPtNum<nPtAnz; nPtNum++) {
+ USHORT nPtId=pPts->GetObject(nPtNum);
+ USHORT nGlueIdx=pGPL->FindGluePoint(nPtId);
+ if (nGlueIdx!=SDRGLUEPOINT_NOTFOUND) {
+ SdrGluePoint& rGP=(*pGPL)[nGlueIdx];
+ Point aPos(rGP.GetAbsolutePos(*pObj));
+ (*pTrFunc)(aPos,p1,p2,p3,p4,p5);
+ rGP.SetAbsolutePos(aPos,*pObj);
+ }
+ }
+ pObj->SetChanged();
+ pObj->BroadcastObjectChange();
+ }
+ }
+ }
+ if (nMarkAnz!=0) pMod->SetChanged();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ImpMove(Point& rPt, const void* p1, const void* /*p2*/, const void* /*p3*/, const void* /*p4*/, const void* /*p5*/)
+{
+ rPt.X()+=((const Size*)p1)->Width();
+ rPt.Y()+=((const Size*)p1)->Height();
+}
+
+void SdrGlueEditView::MoveMarkedGluePoints(const Size& rSiz, bool bCopy)
+{
+ ForceUndirtyMrkPnt();
+ XubString aStr(ImpGetResStr(STR_EditMove));
+ if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr,GetDescriptionOfMarkedGluePoints(),SDRREPFUNC_OBJ_MOVE);
+ if (bCopy) ImpCopyMarkedGluePoints();
+ ImpTransformMarkedGluePoints(ImpMove,&rSiz);
+ EndUndo();
+ AdjustMarkHdl();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ImpResize(Point& rPt, const void* p1, const void* p2, const void* p3, const void* /*p4*/, const void* /*p5*/)
+{
+ ResizePoint(rPt,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3);
+}
+
+void SdrGlueEditView::ResizeMarkedGluePoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy)
+{
+ ForceUndirtyMrkPnt();
+ XubString aStr(ImpGetResStr(STR_EditResize));
+ if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr,GetDescriptionOfMarkedGluePoints(),SDRREPFUNC_OBJ_RESIZE);
+ if (bCopy) ImpCopyMarkedGluePoints();
+ ImpTransformMarkedGluePoints(ImpResize,&rRef,&xFact,&yFact);
+ EndUndo();
+ AdjustMarkHdl();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ImpRotate(Point& rPt, const void* p1, const void* /*p2*/, const void* p3, const void* p4, const void* /*p5*/)
+{
+ RotatePoint(rPt,*(const Point*)p1,*(const double*)p3,*(const double*)p4);
+}
+
+void SdrGlueEditView::RotateMarkedGluePoints(const Point& rRef, long nWink, bool bCopy)
+{
+ ForceUndirtyMrkPnt();
+ XubString aStr(ImpGetResStr(STR_EditRotate));
+ if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr,GetDescriptionOfMarkedGluePoints(),SDRREPFUNC_OBJ_ROTATE);
+ if (bCopy) ImpCopyMarkedGluePoints();
+ double nSin=sin(nWink*nPi180);
+ double nCos=cos(nWink*nPi180);
+ ImpTransformMarkedGluePoints(ImpRotate,&rRef,&nWink,&nSin,&nCos);
+ EndUndo();
+ AdjustMarkHdl();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdglue.cxx b/svx/source/svdraw/svdglue.cxx
new file mode 100644
index 000000000000..e43faf9d0cf1
--- /dev/null
+++ b/svx/source/svdraw/svdglue.cxx
@@ -0,0 +1,453 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/debug.hxx>
+
+#include <svx/svdglue.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdtrans.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrGluePoint::SetReallyAbsolute(bool bOn, const SdrObject& rObj)
+{
+ if ( bReallyAbsolute != bOn )
+ {
+ if ( bOn )
+ {
+ aPos=GetAbsolutePos(rObj);
+ bReallyAbsolute=bOn;
+ }
+ else
+ {
+ bReallyAbsolute=bOn;
+ Point aPt(aPos);
+ SetAbsolutePos(aPt,rObj);
+ }
+ }
+}
+
+Point SdrGluePoint::GetAbsolutePos(const SdrObject& rObj) const
+{
+ if (bReallyAbsolute) return aPos;
+ Rectangle aSnap(rObj.GetSnapRect());
+ Rectangle aBound(rObj.GetSnapRect());
+ Point aPt(aPos);
+
+ Point aOfs(aSnap.Center());
+ switch (GetHorzAlign()) {
+ case SDRHORZALIGN_LEFT : aOfs.X()=aSnap.Left(); break;
+ case SDRHORZALIGN_RIGHT : aOfs.X()=aSnap.Right(); break;
+ }
+ switch (GetVertAlign()) {
+ case SDRVERTALIGN_TOP : aOfs.Y()=aSnap.Top(); break;
+ case SDRVERTALIGN_BOTTOM: aOfs.Y()=aSnap.Bottom(); break;
+ }
+ if (!bNoPercent) {
+ long nXMul=aSnap.Right()-aSnap.Left();
+ long nYMul=aSnap.Bottom()-aSnap.Top();
+ long nXDiv=10000;
+ long nYDiv=10000;
+ if (nXMul!=nXDiv) {
+ aPt.X()*=nXMul;
+ aPt.X()/=nXDiv;
+ }
+ if (nYMul!=nYDiv) {
+ aPt.Y()*=nYMul;
+ aPt.Y()/=nYDiv;
+ }
+ }
+ aPt+=aOfs;
+ // Und nun auf's BoundRect des Objekts begrenzen
+ if (aPt.X()<aBound.Left ()) aPt.X()=aBound.Left ();
+ if (aPt.X()>aBound.Right ()) aPt.X()=aBound.Right ();
+ if (aPt.Y()<aBound.Top ()) aPt.Y()=aBound.Top ();
+ if (aPt.Y()>aBound.Bottom()) aPt.Y()=aBound.Bottom();
+ return aPt;
+}
+
+void SdrGluePoint::SetAbsolutePos(const Point& rNewPos, const SdrObject& rObj)
+{
+ if (bReallyAbsolute) {
+ aPos=rNewPos;
+ return;
+ }
+ Rectangle aSnap(rObj.GetSnapRect());
+ Point aPt(rNewPos);
+
+ Point aOfs(aSnap.Center());
+ switch (GetHorzAlign()) {
+ case SDRHORZALIGN_LEFT : aOfs.X()=aSnap.Left(); break;
+ case SDRHORZALIGN_RIGHT : aOfs.X()=aSnap.Right(); break;
+ }
+ switch (GetVertAlign()) {
+ case SDRVERTALIGN_TOP : aOfs.Y()=aSnap.Top(); break;
+ case SDRVERTALIGN_BOTTOM: aOfs.Y()=aSnap.Bottom(); break;
+ }
+ aPt-=aOfs;
+ if (!bNoPercent) {
+ long nXMul=aSnap.Right()-aSnap.Left();
+ long nYMul=aSnap.Bottom()-aSnap.Top();
+ if (nXMul==0) nXMul=1;
+ if (nYMul==0) nYMul=1;
+ long nXDiv=10000;
+ long nYDiv=10000;
+ if (nXMul!=nXDiv) {
+ aPt.X()*=nXDiv;
+ aPt.X()/=nXMul;
+ }
+ if (nYMul!=nYDiv) {
+ aPt.Y()*=nYDiv;
+ aPt.Y()/=nYMul;
+ }
+ }
+ aPos=aPt;
+}
+
+long SdrGluePoint::GetAlignAngle() const
+{
+ switch (nAlign) {
+ case SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER: return 0; // Invalid!
+ case SDRHORZALIGN_RIGHT |SDRVERTALIGN_CENTER: return 0;
+ case SDRHORZALIGN_RIGHT |SDRVERTALIGN_TOP : return 4500;
+ case SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP : return 9000;
+ case SDRHORZALIGN_LEFT |SDRVERTALIGN_TOP : return 13500;
+ case SDRHORZALIGN_LEFT |SDRVERTALIGN_CENTER: return 18000;
+ case SDRHORZALIGN_LEFT |SDRVERTALIGN_BOTTOM: return 22500;
+ case SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM: return 27000;
+ case SDRHORZALIGN_RIGHT |SDRVERTALIGN_BOTTOM: return 31500;
+ } // switch
+ return 0;
+}
+
+void SdrGluePoint::SetAlignAngle(long nWink)
+{
+ nWink=NormAngle360(nWink);
+ if (nWink>=33750 || nWink<2250) nAlign=SDRHORZALIGN_RIGHT |SDRVERTALIGN_CENTER;
+ else if (nWink< 6750) nAlign=SDRHORZALIGN_RIGHT |SDRVERTALIGN_TOP ;
+ else if (nWink<11250) nAlign=SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP ;
+ else if (nWink<15750) nAlign=SDRHORZALIGN_LEFT |SDRVERTALIGN_TOP ;
+ else if (nWink<20250) nAlign=SDRHORZALIGN_LEFT |SDRVERTALIGN_CENTER;
+ else if (nWink<24750) nAlign=SDRHORZALIGN_LEFT |SDRVERTALIGN_BOTTOM;
+ else if (nWink<29250) nAlign=SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM;
+ else if (nWink<33750) nAlign=SDRHORZALIGN_RIGHT |SDRVERTALIGN_BOTTOM;
+}
+
+long SdrGluePoint::EscDirToAngle(USHORT nEsc) const
+{
+ switch (nEsc) {
+ case SDRESC_RIGHT : return 0;
+ case SDRESC_TOP : return 9000;
+ case SDRESC_LEFT : return 18000;
+ case SDRESC_BOTTOM: return 27000;
+ } // switch
+ return 0;
+}
+
+USHORT SdrGluePoint::EscAngleToDir(long nWink) const
+{
+ nWink=NormAngle360(nWink);
+ if (nWink>=31500 || nWink<4500) return SDRESC_RIGHT;
+ if (nWink<13500) return SDRESC_TOP;
+ if (nWink<22500) return SDRESC_LEFT;
+ if (nWink<31500) return SDRESC_BOTTOM;
+ return 0;
+}
+
+void SdrGluePoint::Rotate(const Point& rRef, long nWink, double sn, double cs, const SdrObject* pObj)
+{
+ Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos());
+ RotatePoint(aPt,rRef,sn,cs);
+ // Bezugskante drehen
+ if(nAlign != (SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER))
+ {
+ SetAlignAngle(GetAlignAngle()+nWink);
+ }
+ // Austrittsrichtungen drehen
+ USHORT nEscDir0=nEscDir;
+ USHORT nEscDir1=0;
+ if ((nEscDir0&SDRESC_LEFT )!=0) nEscDir1|=EscAngleToDir(EscDirToAngle(SDRESC_LEFT )+nWink);
+ if ((nEscDir0&SDRESC_TOP )!=0) nEscDir1|=EscAngleToDir(EscDirToAngle(SDRESC_TOP )+nWink);
+ if ((nEscDir0&SDRESC_RIGHT )!=0) nEscDir1|=EscAngleToDir(EscDirToAngle(SDRESC_RIGHT )+nWink);
+ if ((nEscDir0&SDRESC_BOTTOM)!=0) nEscDir1|=EscAngleToDir(EscDirToAngle(SDRESC_BOTTOM)+nWink);
+ nEscDir=nEscDir1;
+ if (pObj!=NULL) SetAbsolutePos(aPt,*pObj); else SetPos(aPt);
+}
+
+void SdrGluePoint::Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj)
+{
+ Point aPt(rRef2); aPt-=rRef1;
+ long nWink=GetAngle(aPt);
+ Mirror(rRef1,rRef2,nWink,pObj);
+}
+
+void SdrGluePoint::Mirror(const Point& rRef1, const Point& rRef2, long nWink, const SdrObject* pObj)
+{
+ Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos());
+ MirrorPoint(aPt,rRef1,rRef2);
+ // Bezugskante spiegeln
+ if(nAlign != (SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER))
+ {
+ long nAW=GetAlignAngle();
+ nAW+=2*(nWink-nAW);
+ SetAlignAngle(nAW);
+ }
+ // Austrittsrichtungen spiegeln
+ USHORT nEscDir0=nEscDir;
+ USHORT nEscDir1=0;
+ if ((nEscDir0&SDRESC_LEFT)!=0) {
+ long nEW=EscDirToAngle(SDRESC_LEFT);
+ nEW+=2*(nWink-nEW);
+ nEscDir1|=EscAngleToDir(nEW);
+ }
+ if ((nEscDir0&SDRESC_TOP)!=0) {
+ long nEW=EscDirToAngle(SDRESC_TOP);
+ nEW+=2*(nWink-nEW);
+ nEscDir1|=EscAngleToDir(nEW);
+ }
+ if ((nEscDir0&SDRESC_RIGHT)!=0) {
+ long nEW=EscDirToAngle(SDRESC_RIGHT);
+ nEW+=2*(nWink-nEW);
+ nEscDir1|=EscAngleToDir(nEW);
+ }
+ if ((nEscDir0&SDRESC_BOTTOM)!=0) {
+ long nEW=EscDirToAngle(SDRESC_BOTTOM);
+ nEW+=2*(nWink-nEW);
+ nEscDir1|=EscAngleToDir(nEW);
+ }
+ nEscDir=nEscDir1;
+ if (pObj!=NULL) SetAbsolutePos(aPt,*pObj); else SetPos(aPt);
+}
+
+void SdrGluePoint::Shear(const Point& rRef, long /*nWink*/, double tn, bool bVShear, const SdrObject* pObj)
+{
+ Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos());
+ ShearPoint(aPt,rRef,tn,bVShear);
+ if (pObj!=NULL) SetAbsolutePos(aPt,*pObj); else SetPos(aPt);
+}
+
+void SdrGluePoint::Draw(OutputDevice& rOut, const SdrObject* pObj) const
+{
+ Color aBackPenColor(COL_WHITE);
+ Color aForePenColor(COL_LIGHTBLUE);
+
+ bool bMapMerk=rOut.IsMapModeEnabled();
+ Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos());
+ aPt=rOut.LogicToPixel(aPt);
+ rOut.EnableMapMode(FALSE);
+ long x=aPt.X(),y=aPt.Y(); // Groesse erstmal fest auf 7 Pixel
+
+ rOut.SetLineColor( aBackPenColor );
+ rOut.DrawLine(Point(x-2,y-3),Point(x+3,y+2));
+ rOut.DrawLine(Point(x-3,y-2),Point(x+2,y+3));
+ rOut.DrawLine(Point(x-3,y+2),Point(x+2,y-3));
+ rOut.DrawLine(Point(x-2,y+3),Point(x+3,y-2));
+
+ if (bNoPercent)
+ {
+ switch (GetHorzAlign())
+ {
+ case SDRHORZALIGN_LEFT : rOut.DrawLine(Point(x-3,y-1),Point(x-3,y+1)); break;
+ case SDRHORZALIGN_RIGHT : rOut.DrawLine(Point(x+3,y-1),Point(x+3,y+1)); break;
+ }
+
+ switch (GetVertAlign())
+ {
+ case SDRVERTALIGN_TOP : rOut.DrawLine(Point(x-1,y-3),Point(x+1,y-3)); break;
+ case SDRVERTALIGN_BOTTOM: rOut.DrawLine(Point(x-1,y+3),Point(x+1,y+3)); break;
+ }
+ }
+
+ rOut.SetLineColor( aForePenColor );
+ rOut.DrawLine(Point(x-2,y-2),Point(x+2,y+2));
+ rOut.DrawLine(Point(x-2,y+2),Point(x+2,y-2));
+ rOut.EnableMapMode(bMapMerk);
+}
+
+void SdrGluePoint::Invalidate(Window& rWin, const SdrObject* pObj) const
+{
+ bool bMapMerk=rWin.IsMapModeEnabled();
+ Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos());
+ aPt=rWin.LogicToPixel(aPt);
+ rWin.EnableMapMode(FALSE);
+ long x=aPt.X(),y=aPt.Y(); // Groesse erstmal fest auf 7 Pixel
+
+ // #111096#
+ // do not erase background, that causes flicker (!)
+ rWin.Invalidate(Rectangle(Point(x-3,y-3),Point(x+3,y+3)), INVALIDATE_NOERASE);
+
+ rWin.EnableMapMode(bMapMerk);
+}
+
+bool SdrGluePoint::IsHit(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj) const
+{
+ Point aPt(pObj!=NULL ? GetAbsolutePos(*pObj) : GetPos());
+ Size aSiz=rOut.PixelToLogic(Size(3,3));
+ Rectangle aRect(aPt.X()-aSiz.Width(),aPt.Y()-aSiz.Height(),aPt.X()+aSiz.Width(),aPt.Y()+aSiz.Height());
+ return aRect.IsInside(rPnt);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrGluePointList::Clear()
+{
+ USHORT nAnz=GetCount();
+ for (USHORT i=0; i<nAnz; i++) {
+ delete GetObject(i);
+ }
+ aList.Clear();
+}
+
+void SdrGluePointList::operator=(const SdrGluePointList& rSrcList)
+{
+ if (GetCount()!=0) Clear();
+ USHORT nAnz=rSrcList.GetCount();
+ for (USHORT i=0; i<nAnz; i++) {
+ Insert(rSrcList[i]);
+ }
+}
+
+// Die Id's der Klebepunkte in der Liste sind stets streng monoton steigend!
+// Ggf. wird dem neuen Klebepunkt eine neue Id zugewiesen (wenn diese bereits
+// vergeben ist). Die Id 0 ist reserviert.
+USHORT SdrGluePointList::Insert(const SdrGluePoint& rGP)
+{
+ SdrGluePoint* pGP=new SdrGluePoint(rGP);
+ USHORT nId=pGP->GetId();
+ USHORT nAnz=GetCount();
+ USHORT nInsPos=nAnz;
+ USHORT nLastId=nAnz!=0 ? GetObject(nAnz-1)->GetId() : 0;
+ DBG_ASSERT(nLastId>=nAnz,"SdrGluePointList::Insert(): nLastId<nAnz");
+ bool bHole = nLastId>nAnz;
+ if (nId<=nLastId) {
+ if (!bHole || nId==0) {
+ nId=nLastId+1;
+ } else {
+ bool bBrk = false;
+ for (USHORT nNum=0; nNum<nAnz && !bBrk; nNum++) {
+ const SdrGluePoint* pGP2=GetObject(nNum);
+ USHORT nTmpId=pGP2->GetId();
+ if (nTmpId==nId) {
+ nId=nLastId+1; // bereits vorhanden
+ bBrk = true;
+ }
+ if (nTmpId>nId) {
+ nInsPos=nNum; // Hier einfuegen (einsortieren)
+ bBrk = true;
+ }
+ }
+ }
+ pGP->SetId(nId);
+ }
+ aList.Insert(pGP,nInsPos);
+ return nInsPos;
+}
+
+void SdrGluePointList::Invalidate(Window& rWin, const SdrObject* pObj) const
+{
+ USHORT nAnz=GetCount();
+ for (USHORT nNum=0; nNum<nAnz; nNum++) {
+ GetObject(nNum)->Invalidate(rWin,pObj);
+ }
+}
+
+USHORT SdrGluePointList::FindGluePoint(USHORT nId) const
+{
+ // Hier noch einen optimaleren Suchalgorithmus implementieren.
+ // Die Liste sollte stets sortiert sein!!!!
+ USHORT nAnz=GetCount();
+ USHORT nRet=SDRGLUEPOINT_NOTFOUND;
+ for (USHORT nNum=0; nNum<nAnz && nRet==SDRGLUEPOINT_NOTFOUND; nNum++) {
+ const SdrGluePoint* pGP=GetObject(nNum);
+ if (pGP->GetId()==nId) nRet=nNum;
+ }
+ return nRet;
+}
+
+USHORT SdrGluePointList::HitTest(const Point& rPnt, const OutputDevice& rOut, const SdrObject* pObj, bool bBack, bool bNext, USHORT nId0) const
+{
+ USHORT nAnz=GetCount();
+ USHORT nRet=SDRGLUEPOINT_NOTFOUND;
+ USHORT nNum=bBack ? 0 : nAnz;
+ while ((bBack ? nNum<nAnz : nNum>0) && nRet==SDRGLUEPOINT_NOTFOUND) {
+ if (!bBack) nNum--;
+ const SdrGluePoint* pGP=GetObject(nNum);
+ if (bNext) {
+ if (pGP->GetId()==nId0) bNext=FALSE;
+ } else {
+ if (pGP->IsHit(rPnt,rOut,pObj)) nRet=nNum;
+ }
+ if (bBack) nNum++;
+ }
+ return nRet;
+}
+
+void SdrGluePointList::SetReallyAbsolute(bool bOn, const SdrObject& rObj)
+{
+ USHORT nAnz=GetCount();
+ for (USHORT nNum=0; nNum<nAnz; nNum++) {
+ GetObject(nNum)->SetReallyAbsolute(bOn,rObj);
+ }
+}
+
+void SdrGluePointList::Rotate(const Point& rRef, long nWink, double sn, double cs, const SdrObject* pObj)
+{
+ USHORT nAnz=GetCount();
+ for (USHORT nNum=0; nNum<nAnz; nNum++) {
+ GetObject(nNum)->Rotate(rRef,nWink,sn,cs,pObj);
+ }
+}
+
+void SdrGluePointList::Mirror(const Point& rRef1, const Point& rRef2, const SdrObject* pObj)
+{
+ Point aPt(rRef2); aPt-=rRef1;
+ long nWink=GetAngle(aPt);
+ Mirror(rRef1,rRef2,nWink,pObj);
+}
+
+void SdrGluePointList::Mirror(const Point& rRef1, const Point& rRef2, long nWink, const SdrObject* pObj)
+{
+ USHORT nAnz=GetCount();
+ for (USHORT nNum=0; nNum<nAnz; nNum++) {
+ GetObject(nNum)->Mirror(rRef1,rRef2,nWink,pObj);
+ }
+}
+
+void SdrGluePointList::Shear(const Point& rRef, long nWink, double tn, bool bVShear, const SdrObject* pObj)
+{
+ USHORT nAnz=GetCount();
+ for (USHORT nNum=0; nNum<nAnz; nNum++) {
+ GetObject(nNum)->Shear(rRef,nWink,tn,bVShear,pObj);
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
new file mode 100644
index 000000000000..6165d5ba2c2b
--- /dev/null
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -0,0 +1,2420 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <algorithm>
+
+#include <svx/svdhdl.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdmrkv.hxx>
+#include <vcl/window.hxx>
+
+#include <vcl/virdev.hxx>
+#include <tools/poly.hxx>
+#include <vcl/bmpacc.hxx>
+
+#include <svx/sxekitm.hxx>
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+
+#include <svx/svdmodel.hxx>
+#include "gradtrns.hxx"
+#include <svx/xflgrit.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/xflftrit.hxx>
+
+// #105678#
+#include <svx/svdopath.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
+#include <svx/sdr/overlay/overlaybitmapex.hxx>
+#include <svx/sdr/overlay/overlayline.hxx>
+#include <svx/sdr/overlay/overlaytriangle.hxx>
+#include <svx/sdr/overlay/overlayhatchrect.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <sdrpaintwindow.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/sdr/overlay/overlaypolypolygon.hxx>
+#include <vcl/lazydelete.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #i15222#
+// Due to the ressource problems in Win95/98 with bitmap ressources i
+// will change this handle bitmap provinging class. Old version was splitting
+// and preparing all small handle bitmaps in device bitmap format, now this will
+// be done on the fly. Thus, tehre is only the one big bitmap remembered. With
+// three source bitmaps, this will be 3 system bitmap ressources instead of hundreds.
+// The price for that needs to be evaluated. Maybe we will need another change here
+// if this is too expensive.
+class SdrHdlBitmapSet
+{
+ // the bitmap holding all infos
+ BitmapEx maMarkersBitmap;
+
+ // the cropped Bitmaps for reusage
+ ::std::vector< BitmapEx > maRealMarkers;
+
+ // elpers
+ BitmapEx& impGetOrCreateTargetBitmap(sal_uInt16 nIndex, const Rectangle& rRectangle);
+
+public:
+ SdrHdlBitmapSet(UINT16 nResId);
+ ~SdrHdlBitmapSet();
+
+ const BitmapEx& GetBitmapEx(BitmapMarkerKind eKindOfMarker, UINT16 nInd=0);
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#define KIND_COUNT (14)
+#define INDEX_COUNT (6)
+#define INDIVIDUAL_COUNT (4)
+
+SdrHdlBitmapSet::SdrHdlBitmapSet(UINT16 nResId)
+: maMarkersBitmap(),
+ // 14 kinds (BitmapMarkerKind) use index [0..5], 4 extra
+ maRealMarkers((KIND_COUNT * INDEX_COUNT) + INDIVIDUAL_COUNT)
+{
+ // #101928# change color used for transparent parts to 0x00ff00ff (ImageList standard)
+ const Color aColTransparent(0x00ff00ff);
+ const Bitmap aBitmap(ResId(nResId, *ImpGetResMgr()));
+ const Bitmap aMask(aBitmap.CreateMask(aColTransparent));
+
+ // create a real BitmapEx with an AlphaMask
+ maMarkersBitmap = BitmapEx(aBitmap, aMask);
+ // maMarkersBitmap = BitmapEx(aBitmap, aColTransparent);
+}
+
+SdrHdlBitmapSet::~SdrHdlBitmapSet()
+{
+}
+
+BitmapEx& SdrHdlBitmapSet::impGetOrCreateTargetBitmap(sal_uInt16 nIndex, const Rectangle& rRectangle)
+{
+ BitmapEx& rTargetBitmap = maRealMarkers[nIndex];
+
+ if(rTargetBitmap.IsEmpty())
+ {
+ rTargetBitmap = maMarkersBitmap;
+ rTargetBitmap.Crop(rRectangle);
+ }
+
+ return rTargetBitmap;
+}
+
+// change getting of bitmap to use the big ressource bitmap
+const BitmapEx& SdrHdlBitmapSet::GetBitmapEx(BitmapMarkerKind eKindOfMarker, UINT16 nInd)
+{
+ // fill in size and source position in maMarkersBitmap
+ const sal_uInt16 nYPos(nInd * 11);
+
+ switch(eKindOfMarker)
+ {
+ default:
+ {
+ DBG_ERROR( "unknown kind of marker" );
+ // no break here, return Rect_7x7 as default
+ }
+ case Rect_7x7:
+ {
+ return impGetOrCreateTargetBitmap((0 * INDEX_COUNT) + nInd, Rectangle(Point(0, nYPos), Size(7, 7)));
+ }
+
+ case Rect_9x9:
+ {
+ return impGetOrCreateTargetBitmap((1 * INDEX_COUNT) + nInd, Rectangle(Point(7, nYPos), Size(9, 9)));
+ }
+
+ case Rect_11x11:
+ {
+ return impGetOrCreateTargetBitmap((2 * INDEX_COUNT) + nInd, Rectangle(Point(16, nYPos), Size(11, 11)));
+ }
+
+ case Rect_13x13:
+ {
+ const sal_uInt16 nIndex((3 * INDEX_COUNT) + nInd);
+
+ switch(nInd)
+ {
+ case 0:
+ {
+ return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(72, 66), Size(13, 13)));
+ }
+ case 1:
+ {
+ return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(85, 66), Size(13, 13)));
+ }
+ case 2:
+ {
+ return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(72, 78), Size(13, 13)));
+ }
+ case 3:
+ {
+ return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(85, 78), Size(13, 13)));
+ }
+ case 4:
+ {
+ return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(98, 78), Size(13, 13)));
+ }
+ default: // case 5:
+ {
+ return impGetOrCreateTargetBitmap(nIndex, Rectangle(Point(98, 66), Size(13, 13)));
+ }
+ }
+ }
+
+ case Circ_7x7:
+ {
+ return impGetOrCreateTargetBitmap((4 * INDEX_COUNT) + nInd, Rectangle(Point(27, nYPos), Size(7, 7)));
+ }
+
+ case Circ_9x9:
+ case Customshape1:
+ {
+ return impGetOrCreateTargetBitmap((5 * INDEX_COUNT) + nInd, Rectangle(Point(34, nYPos), Size(9, 9)));
+ }
+
+ case Circ_11x11:
+ {
+ return impGetOrCreateTargetBitmap((6 * INDEX_COUNT) + nInd, Rectangle(Point(43, nYPos), Size(11, 11)));
+ }
+
+ case Elli_7x9:
+ {
+ return impGetOrCreateTargetBitmap((7 * INDEX_COUNT) + nInd, Rectangle(Point(54, nYPos), Size(7, 9)));
+ }
+
+ case Elli_9x11:
+ {
+ return impGetOrCreateTargetBitmap((8 * INDEX_COUNT) + nInd, Rectangle(Point(61, nYPos), Size(9, 11)));
+ }
+
+ case Elli_9x7:
+ {
+ return impGetOrCreateTargetBitmap((9 * INDEX_COUNT) + nInd, Rectangle(Point(70, nYPos), Size(9, 7)));
+ }
+
+ case Elli_11x9:
+ {
+ return impGetOrCreateTargetBitmap((10 * INDEX_COUNT) + nInd, Rectangle(Point(79, nYPos), Size(11, 9)));
+ }
+
+ case RectPlus_7x7:
+ {
+ return impGetOrCreateTargetBitmap((11 * INDEX_COUNT) + nInd, Rectangle(Point(90, nYPos), Size(7, 7)));
+ }
+
+ case RectPlus_9x9:
+ {
+ return impGetOrCreateTargetBitmap((12 * INDEX_COUNT) + nInd, Rectangle(Point(97, nYPos), Size(9, 9)));
+ }
+
+ case RectPlus_11x11:
+ {
+ return impGetOrCreateTargetBitmap((13 * INDEX_COUNT) + nInd, Rectangle(Point(106, nYPos), Size(11, 11)));
+ }
+
+ case Crosshair:
+ {
+ return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 0, Rectangle(Point(0, 68), Size(15, 15)));
+ }
+
+ case Glue:
+ {
+ return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 1, Rectangle(Point(15, 74), Size(9, 9)));
+ }
+
+ case Anchor: // #101688# AnchorTR for SW
+ case AnchorTR:
+ {
+ return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 2, Rectangle(Point(24, 68), Size(24, 23)));
+ }
+
+ // #98388# add AnchorPressed to be able to aninate anchor control
+ case AnchorPressed:
+ case AnchorPressedTR:
+ {
+ return impGetOrCreateTargetBitmap((KIND_COUNT * INDEX_COUNT) + 3, Rectangle(Point(48, 68), Size(24, 23)));
+ }
+ }
+
+ // cannot happen since all pathes return something; return Rect_7x7 as default (see switch)
+ return maRealMarkers[0];
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrHdlBitmapSet& getSimpleSet()
+{
+ static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aSimpleSet(new SdrHdlBitmapSet(SIP_SA_MARKERS));
+ return *aSimpleSet.get();
+}
+
+SdrHdlBitmapSet& getModernSet()
+{
+ static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aModernSet(new SdrHdlBitmapSet(SIP_SA_FINE_MARKERS));
+ return *aModernSet.get();
+}
+
+SdrHdlBitmapSet& getHighContrastSet()
+{
+ static vcl::DeleteOnDeinit< SdrHdlBitmapSet > aHighContrastSet(new SdrHdlBitmapSet(SIP_SA_ACCESSIBILITY_MARKERS));
+ return *aHighContrastSet.get();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrHdl::SdrHdl():
+ pObj(NULL),
+ pPV(NULL),
+ pHdlList(NULL),
+ eKind(HDL_MOVE),
+ nDrehWink(0),
+ nObjHdlNum(0),
+ nPolyNum(0),
+ nPPntNum(0),
+ nSourceHdlNum(0),
+ bSelect(FALSE),
+ b1PixMore(FALSE),
+ bPlusHdl(FALSE),
+ mbMoveOutside(false),
+ mbMouseOver(false)
+{
+}
+
+SdrHdl::SdrHdl(const Point& rPnt, SdrHdlKind eNewKind):
+ pObj(NULL),
+ pPV(NULL),
+ pHdlList(NULL),
+ aPos(rPnt),
+ eKind(eNewKind),
+ nDrehWink(0),
+ nObjHdlNum(0),
+ nPolyNum(0),
+ nPPntNum(0),
+ nSourceHdlNum(0),
+ bSelect(FALSE),
+ b1PixMore(FALSE),
+ bPlusHdl(FALSE),
+ mbMoveOutside(false),
+ mbMouseOver(false)
+{
+}
+
+SdrHdl::~SdrHdl()
+{
+ GetRidOfIAObject();
+}
+
+void SdrHdl::Set1PixMore(BOOL bJa)
+{
+ if(b1PixMore != bJa)
+ {
+ b1PixMore = bJa;
+
+ // create new display
+ Touch();
+ }
+}
+
+void SdrHdl::SetMoveOutside( bool bMoveOutside )
+{
+ if(mbMoveOutside != bMoveOutside)
+ {
+ mbMoveOutside = bMoveOutside;
+
+ // create new display
+ Touch();
+ }
+}
+
+void SdrHdl::SetDrehWink(long n)
+{
+ if(nDrehWink != n)
+ {
+ nDrehWink = n;
+
+ // create new display
+ Touch();
+ }
+}
+
+void SdrHdl::SetPos(const Point& rPnt)
+{
+ if(aPos != rPnt)
+ {
+ // remember new position
+ aPos = rPnt;
+
+ // create new display
+ Touch();
+ }
+}
+
+void SdrHdl::SetSelected(BOOL bJa)
+{
+ if(bSelect != bJa)
+ {
+ // remember new value
+ bSelect = bJa;
+
+ // create new display
+ Touch();
+ }
+}
+
+void SdrHdl::SetHdlList(SdrHdlList* pList)
+{
+ if(pHdlList != pList)
+ {
+ // rememver list
+ pHdlList = pList;
+
+ // now its possible to create graphic representation
+ Touch();
+ }
+}
+
+void SdrHdl::SetObj(SdrObject* pNewObj)
+{
+ if(pObj != pNewObj)
+ {
+ // remember new object
+ pObj = pNewObj;
+
+ // graphic representation may have changed
+ Touch();
+ }
+}
+
+void SdrHdl::Touch()
+{
+ // force update of graphic representation
+ CreateB2dIAObject();
+}
+
+void SdrHdl::GetRidOfIAObject()
+{
+ //OLMaIAOGroup.Delete();
+
+ // OVERLAYMANAGER
+ maOverlayGroup.clear();
+}
+
+void SdrHdl::CreateB2dIAObject()
+{
+ // first throw away old one
+ GetRidOfIAObject();
+
+ if(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden())
+ {
+ BitmapColorIndex eColIndex = LightGreen;
+ BitmapMarkerKind eKindOfMarker = Rect_7x7;
+
+ BOOL bRot = pHdlList->IsRotateShear();
+ if(pObj)
+ eColIndex = (bSelect) ? Cyan : LightCyan;
+ if(bRot)
+ {
+ // Drehhandles in Rot
+ if(pObj && bSelect)
+ eColIndex = Red;
+ else
+ eColIndex = LightRed;
+ }
+
+ switch(eKind)
+ {
+ case HDL_MOVE:
+ {
+ eKindOfMarker = (b1PixMore) ? Rect_9x9 : Rect_7x7;
+ break;
+ }
+ case HDL_UPLFT:
+ case HDL_UPRGT:
+ case HDL_LWLFT:
+ case HDL_LWRGT:
+ {
+ // corner handles
+ if(bRot)
+ {
+ eKindOfMarker = Circ_7x7;
+ }
+ else
+ {
+ eKindOfMarker = Rect_7x7;
+ }
+ break;
+ }
+ case HDL_UPPER:
+ case HDL_LOWER:
+ {
+ // Upper/Lower handles
+ if(bRot)
+ {
+ eKindOfMarker = Elli_9x7;
+ }
+ else
+ {
+ eKindOfMarker = Rect_7x7;
+ }
+ break;
+ }
+ case HDL_LEFT:
+ case HDL_RIGHT:
+ {
+ // Left/Right handles
+ if(bRot)
+ {
+ eKindOfMarker = Elli_7x9;
+ }
+ else
+ {
+ eKindOfMarker = Rect_7x7;
+ }
+ break;
+ }
+ case HDL_POLY:
+ {
+ if(bRot)
+ {
+ eKindOfMarker = (b1PixMore) ? Circ_9x9 : Circ_7x7;
+ }
+ else
+ {
+ eKindOfMarker = (b1PixMore) ? Rect_9x9 : Rect_7x7;
+ }
+ break;
+ }
+ case HDL_BWGT: // weight at poly
+ {
+ eKindOfMarker = Circ_7x7;
+ break;
+ }
+ case HDL_CIRC:
+ {
+ eKindOfMarker = Rect_11x11;
+ break;
+ }
+ case HDL_REF1:
+ case HDL_REF2:
+ {
+ eKindOfMarker = Crosshair;
+ break;
+ }
+ case HDL_GLUE:
+ {
+ eKindOfMarker = Glue;
+ break;
+ }
+ case HDL_ANCHOR:
+ {
+ eKindOfMarker = Anchor;
+ break;
+ }
+ case HDL_USER:
+ {
+ break;
+ }
+ // #101688# top right anchor for SW
+ case HDL_ANCHOR_TR:
+ {
+ eKindOfMarker = AnchorTR;
+ break;
+ }
+
+ // for SJ and the CustomShapeHandles:
+ case HDL_CUSTOMSHAPE1:
+ {
+ eKindOfMarker = Customshape1;
+ eColIndex = Yellow;
+ break;
+ }
+ default:
+ break;
+ }
+
+ SdrMarkView* pView = pHdlList->GetView();
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
+ {
+ // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ Point aMoveOutsideOffset(0, 0);
+
+ // add offset if necessary
+ if(pHdlList->IsMoveOutside() || mbMoveOutside)
+ {
+ OutputDevice& rOutDev = rPageWindow.GetPaintWindow().GetOutputDevice();
+ Size aOffset = rOutDev.PixelToLogic(Size(4, 4));
+
+ if(eKind == HDL_UPLFT || eKind == HDL_UPPER || eKind == HDL_UPRGT)
+ aMoveOutsideOffset.Y() -= aOffset.Width();
+ if(eKind == HDL_LWLFT || eKind == HDL_LOWER || eKind == HDL_LWRGT)
+ aMoveOutsideOffset.Y() += aOffset.Height();
+ if(eKind == HDL_UPLFT || eKind == HDL_LEFT || eKind == HDL_LWLFT)
+ aMoveOutsideOffset.X() -= aOffset.Width();
+ if(eKind == HDL_UPRGT || eKind == HDL_RIGHT || eKind == HDL_LWRGT)
+ aMoveOutsideOffset.X() += aOffset.Height();
+ }
+
+ if(rPageWindow.GetOverlayManager())
+ {
+ basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
+ ::sdr::overlay::OverlayObject* pNewOverlayObject = CreateOverlayObject(
+ aPosition,
+ eColIndex,
+ eKindOfMarker,
+ aMoveOutsideOffset);
+
+ // OVERLAYMANAGER
+ if(pNewOverlayObject)
+ {
+ rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
+ maOverlayGroup.append(*pNewOverlayObject);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+BitmapMarkerKind SdrHdl::GetNextBigger(BitmapMarkerKind eKnd) const
+{
+ BitmapMarkerKind eRetval(eKnd);
+
+ switch(eKnd)
+ {
+ case Rect_7x7: eRetval = Rect_9x9; break;
+ case Rect_9x9: eRetval = Rect_11x11; break;
+ case Rect_11x11: eRetval = Rect_13x13; break;
+ //case Rect_13x13: eRetval = ; break;
+
+ case Circ_7x7: eRetval = Circ_9x9; break;
+ case Circ_9x9: eRetval = Circ_11x11; break;
+ //case Circ_11x11: eRetval = ; break;
+
+ case Elli_7x9: eRetval = Elli_9x11; break;
+ //case Elli_9x11: eRetval = ; break;
+
+ case Elli_9x7: eRetval = Elli_11x9; break;
+ //case Elli_11x9: eRetval = ; break;
+
+ case RectPlus_7x7: eRetval = RectPlus_9x9; break;
+ case RectPlus_9x9: eRetval = RectPlus_11x11; break;
+ //case RectPlus_11x11: eRetval = ; break;
+
+ //case Crosshair: eRetval = ; break;
+ //case Glue: eRetval = ; break;
+
+ // #98388# let anchor blink with it's pressed state
+ case Anchor: eRetval = AnchorPressed; break;
+
+ // #101688# same for AnchorTR
+ case AnchorTR: eRetval = AnchorPressedTR; break;
+ default:
+ break;
+ }
+
+ return eRetval;
+}
+
+// #101928#
+BitmapEx SdrHdl::ImpGetBitmapEx(BitmapMarkerKind eKindOfMarker, sal_uInt16 nInd, sal_Bool bFine, sal_Bool bIsHighContrast)
+{
+ if(bIsHighContrast)
+ {
+ return getHighContrastSet().GetBitmapEx(eKindOfMarker, nInd);
+ }
+ else
+ {
+ if(bFine)
+ {
+ return getModernSet().GetBitmapEx(eKindOfMarker, nInd);
+ }
+ else
+ {
+ return getSimpleSet().GetBitmapEx(eKindOfMarker, nInd);
+ }
+ }
+}
+
+::sdr::overlay::OverlayObject* SdrHdl::CreateOverlayObject(
+ const basegfx::B2DPoint& rPos,
+ BitmapColorIndex eColIndex, BitmapMarkerKind eKindOfMarker, Point aMoveOutsideOffset)
+{
+ ::sdr::overlay::OverlayObject* pRetval = 0L;
+ sal_Bool bIsFineHdl(pHdlList->IsFineHdl());
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ sal_Bool bIsHighContrast(rStyleSettings.GetHighContrastMode());
+
+ // support bigger sizes
+ sal_Bool bForceBiggerSize(sal_False);
+
+ if(pHdlList->GetHdlSize() > 3)
+ {
+ bForceBiggerSize = sal_True;
+ }
+
+ // #101928# ...for high contrast, too.
+ if(!bForceBiggerSize && bIsHighContrast)
+ {
+ // #107925#
+ // ...but not for anchors, else they will not blink when activated
+ if(Anchor != eKindOfMarker && AnchorTR != eKindOfMarker)
+ {
+ bForceBiggerSize = sal_True;
+ }
+ }
+
+ if(bForceBiggerSize)
+ {
+ eKindOfMarker = GetNextBigger(eKindOfMarker);
+ }
+
+ // #97016# II This handle has the focus, visualize it
+ if(IsFocusHdl() && pHdlList && pHdlList->GetFocusHdl() == this)
+ {
+ // create animated handle
+ BitmapMarkerKind eNextBigger = GetNextBigger(eKindOfMarker);
+
+ if(eNextBigger == eKindOfMarker)
+ {
+ // this may happen for the not supported getting-bigger types.
+ // Choose an alternative here
+ switch(eKindOfMarker)
+ {
+ case Rect_13x13: eNextBigger = Rect_11x11; break;
+ case Circ_11x11: eNextBigger = Elli_11x9; break;
+ case Elli_9x11: eNextBigger = Elli_11x9; break;
+ case Elli_11x9: eNextBigger = Elli_9x11; break;
+ case RectPlus_11x11: eNextBigger = Rect_13x13; break;
+
+ case Crosshair:
+ eNextBigger = Glue;
+ break;
+
+ case Glue:
+ eNextBigger = Crosshair;
+ break;
+ default:
+ break;
+ }
+ }
+
+ // create animated hdl
+ // #101928# use ImpGetBitmapEx(...) now
+ BitmapEx aBmpEx1 = ImpGetBitmapEx(eKindOfMarker, (sal_uInt16)eColIndex, bIsFineHdl, bIsHighContrast);
+ BitmapEx aBmpEx2 = ImpGetBitmapEx(eNextBigger, (sal_uInt16)eColIndex, bIsFineHdl, bIsHighContrast);
+
+ // #i53216# Use system cursor blink time. Use the unsigned value.
+ const sal_uInt32 nBlinkTime((sal_uInt32)Application::GetSettings().GetStyleSettings().GetCursorBlinkTime());
+
+ if(eKindOfMarker == Anchor || eKindOfMarker == AnchorPressed)
+ {
+ // #98388# when anchor is used take upper left as reference point inside the handle
+ pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime);
+ }
+ else if(eKindOfMarker == AnchorTR || eKindOfMarker == AnchorPressedTR)
+ {
+ // #101688# AnchorTR for SW, take top right as (0,0)
+ pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime,
+ (UINT16)(aBmpEx1.GetSizePixel().Width() - 1), 0,
+ (UINT16)(aBmpEx2.GetSizePixel().Width() - 1), 0);
+ }
+ else
+ {
+ // create centered handle as default
+ pRetval = new ::sdr::overlay::OverlayAnimatedBitmapEx(rPos, aBmpEx1, aBmpEx2, nBlinkTime,
+ (UINT16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
+ (UINT16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1,
+ (UINT16)(aBmpEx2.GetSizePixel().Width() - 1) >> 1,
+ (UINT16)(aBmpEx2.GetSizePixel().Height() - 1) >> 1);
+ }
+ }
+ else
+ {
+ // create normal handle
+ // #101928# use ImpGetBitmapEx(...) now
+ BitmapEx aBmpEx = ImpGetBitmapEx(eKindOfMarker, (sal_uInt16)eColIndex, bIsFineHdl, bIsHighContrast);
+
+ if(eKindOfMarker == Anchor || eKindOfMarker == AnchorPressed)
+ {
+ // #98388# upper left as reference point inside the handle for AnchorPressed, too
+ pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx);
+ }
+ else if(eKindOfMarker == AnchorTR || eKindOfMarker == AnchorPressedTR)
+ {
+ // #101688# AnchorTR for SW, take top right as (0,0)
+ pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx,
+ (UINT16)(aBmpEx.GetSizePixel().Width() - 1), 0);
+ }
+ else
+ {
+ sal_uInt16 nCenX((sal_uInt16)(aBmpEx.GetSizePixel().Width() - 1L) >> 1);
+ sal_uInt16 nCenY((sal_uInt16)(aBmpEx.GetSizePixel().Height() - 1L) >> 1);
+
+ if(aMoveOutsideOffset.X() > 0)
+ {
+ nCenX = 0;
+ }
+ else if(aMoveOutsideOffset.X() < 0)
+ {
+ nCenX = (sal_uInt16)(aBmpEx.GetSizePixel().Width() - 1);
+ }
+
+ if(aMoveOutsideOffset.Y() > 0)
+ {
+ nCenY = 0;
+ }
+ else if(aMoveOutsideOffset.Y() < 0)
+ {
+ nCenY = (sal_uInt16)(aBmpEx.GetSizePixel().Height() - 1);
+ }
+
+ // create centered handle as default
+ pRetval = new ::sdr::overlay::OverlayBitmapEx(rPos, aBmpEx, nCenX, nCenY);
+ }
+ }
+
+ return pRetval;
+}
+
+bool SdrHdl::IsHdlHit(const Point& rPnt) const
+{
+ // OVERLAYMANAGER
+ basegfx::B2DPoint aPosition(rPnt.X(), rPnt.Y());
+ return maOverlayGroup.isHitLogic(aPosition);
+}
+
+Pointer SdrHdl::GetPointer() const
+{
+ PointerStyle ePtr=POINTER_MOVE;
+ const BOOL bSize=eKind>=HDL_UPLFT && eKind<=HDL_LWRGT;
+ const BOOL bRot=pHdlList!=NULL && pHdlList->IsRotateShear();
+ const BOOL bDis=pHdlList!=NULL && pHdlList->IsDistortShear();
+ if (bSize && pHdlList!=NULL && (bRot || bDis)) {
+ switch (eKind) {
+ case HDL_UPLFT: case HDL_UPRGT:
+ case HDL_LWLFT: case HDL_LWRGT: ePtr=bRot ? POINTER_ROTATE : POINTER_REFHAND; break;
+ case HDL_LEFT : case HDL_RIGHT: ePtr=POINTER_VSHEAR; break;
+ case HDL_UPPER: case HDL_LOWER: ePtr=POINTER_HSHEAR; break;
+ default:
+ break;
+ }
+ } else {
+ // Fuer Resize von gedrehten Rechtecken die Mauszeiger etwas mitdrehen
+ if (bSize && nDrehWink!=0) {
+ long nHdlWink=0;
+ switch (eKind) {
+ case HDL_LWRGT: nHdlWink=31500; break;
+ case HDL_LOWER: nHdlWink=27000; break;
+ case HDL_LWLFT: nHdlWink=22500; break;
+ case HDL_LEFT : nHdlWink=18000; break;
+ case HDL_UPLFT: nHdlWink=13500; break;
+ case HDL_UPPER: nHdlWink=9000; break;
+ case HDL_UPRGT: nHdlWink=4500; break;
+ case HDL_RIGHT: nHdlWink=0; break;
+ default:
+ break;
+ }
+ nHdlWink+=nDrehWink+2249; // und etwas drauf (zum runden)
+ while (nHdlWink<0) nHdlWink+=36000;
+ while (nHdlWink>=36000) nHdlWink-=36000;
+ nHdlWink/=4500;
+ switch ((BYTE)nHdlWink) {
+ case 0: ePtr=POINTER_ESIZE; break;
+ case 1: ePtr=POINTER_NESIZE; break;
+ case 2: ePtr=POINTER_NSIZE; break;
+ case 3: ePtr=POINTER_NWSIZE; break;
+ case 4: ePtr=POINTER_WSIZE; break;
+ case 5: ePtr=POINTER_SWSIZE; break;
+ case 6: ePtr=POINTER_SSIZE; break;
+ case 7: ePtr=POINTER_SESIZE; break;
+ } // switch
+ } else {
+ switch (eKind) {
+ case HDL_UPLFT: ePtr=POINTER_NWSIZE; break;
+ case HDL_UPPER: ePtr=POINTER_NSIZE; break;
+ case HDL_UPRGT: ePtr=POINTER_NESIZE; break;
+ case HDL_LEFT : ePtr=POINTER_WSIZE; break;
+ case HDL_RIGHT: ePtr=POINTER_ESIZE; break;
+ case HDL_LWLFT: ePtr=POINTER_SWSIZE; break;
+ case HDL_LOWER: ePtr=POINTER_SSIZE; break;
+ case HDL_LWRGT: ePtr=POINTER_SESIZE; break;
+ case HDL_POLY : ePtr=POINTER_MOVEPOINT; break;
+ case HDL_CIRC : ePtr=POINTER_HAND; break;
+ case HDL_REF1 : ePtr=POINTER_REFHAND; break;
+ case HDL_REF2 : ePtr=POINTER_REFHAND; break;
+ case HDL_BWGT : ePtr=POINTER_MOVEBEZIERWEIGHT; break;
+ case HDL_GLUE : ePtr=POINTER_MOVEPOINT; break;
+ case HDL_CUSTOMSHAPE1 : ePtr=POINTER_HAND; break;
+ default:
+ break;
+ }
+ }
+ }
+ return Pointer(ePtr);
+}
+
+// #97016# II
+BOOL SdrHdl::IsFocusHdl() const
+{
+ switch(eKind)
+ {
+ case HDL_UPLFT: // Oben links
+ case HDL_UPPER: // Oben
+ case HDL_UPRGT: // Oben rechts
+ case HDL_LEFT: // Links
+ case HDL_RIGHT: // Rechts
+ case HDL_LWLFT: // Unten links
+ case HDL_LOWER: // Unten
+ case HDL_LWRGT: // Unten rechts
+ {
+ // if it's a activated TextEdit, it's moved to extended points
+ if(pHdlList && pHdlList->IsMoveOutside())
+ return FALSE;
+ else
+ return TRUE;
+ }
+
+ case HDL_MOVE: // Handle zum Verschieben des Objekts
+ case HDL_POLY: // Punktselektion an Polygon oder Bezierkurve
+ case HDL_BWGT: // Gewicht an einer Bezierkurve
+ case HDL_CIRC: // Winkel an Kreissegmenten, Eckenradius am Rect
+ case HDL_REF1: // Referenzpunkt 1, z.B. Rotationsmitte
+ case HDL_REF2: // Referenzpunkt 2, z.B. Endpunkt der Spiegelachse
+ //case HDL_MIRX: // Die Spiegelachse selbst
+ case HDL_GLUE: // GluePoint
+
+ // #98388# do NOT activate here, let SW implement their own SdrHdl and
+ // overload IsFocusHdl() there to make the anchor accessible
+ //case HDL_ANCHOR: // anchor symbol (SD, SW)
+ // #101688# same for AnchorTR
+ //case HDL_ANCHOR_TR: // anchor symbol (SD, SW)
+
+ //case HDL_TRNS: // interactive transparence
+ //case HDL_GRAD: // interactive gradient
+ //case HDL_COLR: // interactive color
+
+ // for SJ and the CustomShapeHandles:
+ case HDL_CUSTOMSHAPE1:
+
+ case HDL_USER:
+ {
+ return TRUE;
+ }
+
+ default:
+ {
+ return FALSE;
+ }
+ }
+}
+
+void SdrHdl::onMouseEnter(const MouseEvent& /*rMEvt*/)
+{
+}
+
+void SdrHdl::onMouseLeave()
+{
+}
+
+bool SdrHdl::isMouseOver() const
+{
+ return mbMouseOver;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// class SdrHdlColor
+
+SdrHdlColor::SdrHdlColor(const Point& rRef, Color aCol, const Size& rSize, BOOL bLum)
+: SdrHdl(rRef, HDL_COLR),
+ aMarkerSize(rSize),
+ bUseLuminance(bLum)
+{
+ if(IsUseLuminance())
+ aCol = GetLuminance(aCol);
+
+ // remember color
+ aMarkerColor = aCol;
+}
+
+SdrHdlColor::~SdrHdlColor()
+{
+}
+
+void SdrHdlColor::CreateB2dIAObject()
+{
+ // first throw away old one
+ GetRidOfIAObject();
+
+ if(pHdlList)
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+
+ if(pView && !pView->areMarkHandlesHidden())
+ {
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
+ {
+ // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager())
+ {
+ Bitmap aBmpCol(CreateColorDropper(aMarkerColor));
+ basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
+ ::sdr::overlay::OverlayObject* pNewOverlayObject = new
+ ::sdr::overlay::OverlayBitmapEx(
+ aPosition,
+ BitmapEx(aBmpCol),
+ (UINT16)(aBmpCol.GetSizePixel().Width() - 1) >> 1,
+ (UINT16)(aBmpCol.GetSizePixel().Height() - 1) >> 1
+ );
+ DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
+
+ // OVERLAYMANAGER
+ if(pNewOverlayObject)
+ {
+ rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
+ maOverlayGroup.append(*pNewOverlayObject);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+Bitmap SdrHdlColor::CreateColorDropper(Color aCol)
+{
+ // get the Bitmap
+ Bitmap aRetval(aMarkerSize, 24);
+ aRetval.Erase(aCol);
+
+ // get write access
+ BitmapWriteAccess* pWrite = aRetval.AcquireWriteAccess();
+ DBG_ASSERT(pWrite, "Got NO write access to a new Bitmap !!!");
+
+ if(pWrite)
+ {
+ // draw outer border
+ INT32 nWidth = aMarkerSize.Width();
+ INT32 nHeight = aMarkerSize.Height();
+
+ pWrite->SetLineColor(Color(COL_LIGHTGRAY));
+ pWrite->DrawLine(Point(0, 0), Point(0, nHeight - 1));
+ pWrite->DrawLine(Point(1, 0), Point(nWidth - 1, 0));
+ pWrite->SetLineColor(Color(COL_GRAY));
+ pWrite->DrawLine(Point(1, nHeight - 1), Point(nWidth - 1, nHeight - 1));
+ pWrite->DrawLine(Point(nWidth - 1, 1), Point(nWidth - 1, nHeight - 2));
+
+ // draw lighter UpperLeft
+ const Color aLightColor(
+ (sal_uInt8)(::std::min((sal_Int16)((sal_Int16)aCol.GetRed() + (sal_Int16)0x0040), (sal_Int16)0x00ff)),
+ (sal_uInt8)(::std::min((sal_Int16)((sal_Int16)aCol.GetGreen() + (sal_Int16)0x0040), (sal_Int16)0x00ff)),
+ (sal_uInt8)(::std::min((sal_Int16)((sal_Int16)aCol.GetBlue() + (sal_Int16)0x0040), (sal_Int16)0x00ff)));
+ pWrite->SetLineColor(aLightColor);
+ pWrite->DrawLine(Point(1, 1), Point(1, nHeight - 2));
+ pWrite->DrawLine(Point(2, 1), Point(nWidth - 2, 1));
+
+ // draw darker LowerRight
+ const Color aDarkColor(
+ (sal_uInt8)(::std::max((sal_Int16)((sal_Int16)aCol.GetRed() - (sal_Int16)0x0040), (sal_Int16)0x0000)),
+ (sal_uInt8)(::std::max((sal_Int16)((sal_Int16)aCol.GetGreen() - (sal_Int16)0x0040), (sal_Int16)0x0000)),
+ (sal_uInt8)(::std::max((sal_Int16)((sal_Int16)aCol.GetBlue() - (sal_Int16)0x0040), (sal_Int16)0x0000)));
+ pWrite->SetLineColor(aDarkColor);
+ pWrite->DrawLine(Point(2, nHeight - 2), Point(nWidth - 2, nHeight - 2));
+ pWrite->DrawLine(Point(nWidth - 2, 2), Point(nWidth - 2, nHeight - 3));
+
+ // get rid of write access
+ delete pWrite;
+ }
+
+ return aRetval;
+}
+
+Color SdrHdlColor::GetLuminance(const Color& rCol)
+{
+ UINT8 aLum = rCol.GetLuminance();
+ Color aRetval(aLum, aLum, aLum);
+ return aRetval;
+}
+
+void SdrHdlColor::CallColorChangeLink()
+{
+ aColorChangeHdl.Call(this);
+}
+
+void SdrHdlColor::SetColor(Color aNew, BOOL bCallLink)
+{
+ if(IsUseLuminance())
+ aNew = GetLuminance(aNew);
+
+ if(aMarkerColor != aNew)
+ {
+ // remember new color
+ aMarkerColor = aNew;
+
+ // create new display
+ Touch();
+
+ // tell about change
+ if(bCallLink)
+ CallColorChangeLink();
+ }
+}
+
+void SdrHdlColor::SetSize(const Size& rNew)
+{
+ if(rNew != aMarkerSize)
+ {
+ // remember new size
+ aMarkerSize = rNew;
+
+ // create new display
+ Touch();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// class SdrHdlGradient
+
+SdrHdlGradient::SdrHdlGradient(const Point& rRef1, const Point& rRef2, BOOL bGrad)
+: SdrHdl(rRef1, bGrad ? HDL_GRAD : HDL_TRNS),
+ pColHdl1(NULL),
+ pColHdl2(NULL),
+ a2ndPos(rRef2),
+ bGradient(bGrad)
+{
+}
+
+SdrHdlGradient::~SdrHdlGradient()
+{
+}
+
+void SdrHdlGradient::Set2ndPos(const Point& rPnt)
+{
+ if(a2ndPos != rPnt)
+ {
+ // remember new position
+ a2ndPos = rPnt;
+
+ // create new display
+ Touch();
+ }
+}
+
+void SdrHdlGradient::CreateB2dIAObject()
+{
+ // first throw away old one
+ GetRidOfIAObject();
+
+ if(pHdlList)
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+
+ if(pView && !pView->areMarkHandlesHidden())
+ {
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager())
+ {
+ // striped line in between
+ basegfx::B2DVector aVec(a2ndPos.X() - aPos.X(), a2ndPos.Y() - aPos.Y());
+ double fVecLen = aVec.getLength();
+ double fLongPercentArrow = (1.0 - 0.05) * fVecLen;
+ double fHalfArrowWidth = (0.05 * 0.5) * fVecLen;
+ aVec.normalize();
+ basegfx::B2DVector aPerpend(-aVec.getY(), aVec.getX());
+ INT32 nMidX = (INT32)(aPos.X() + aVec.getX() * fLongPercentArrow);
+ INT32 nMidY = (INT32)(aPos.Y() + aVec.getY() * fLongPercentArrow);
+ Point aMidPoint(nMidX, nMidY);
+
+ basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
+ basegfx::B2DPoint aMidPos(aMidPoint.X(), aMidPoint.Y());
+
+ ::sdr::overlay::OverlayObject* pNewOverlayObject = new
+ ::sdr::overlay::OverlayLineStriped(
+ aPosition, aMidPos
+ );
+ DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
+
+ pNewOverlayObject->setBaseColor(IsGradient() ? Color(COL_BLACK) : Color(COL_BLUE));
+ rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
+ maOverlayGroup.append(*pNewOverlayObject);
+
+ // arrowhead
+ Point aLeft(aMidPoint.X() + (INT32)(aPerpend.getX() * fHalfArrowWidth),
+ aMidPoint.Y() + (INT32)(aPerpend.getY() * fHalfArrowWidth));
+ Point aRight(aMidPoint.X() - (INT32)(aPerpend.getX() * fHalfArrowWidth),
+ aMidPoint.Y() - (INT32)(aPerpend.getY() * fHalfArrowWidth));
+
+ basegfx::B2DPoint aPositionLeft(aLeft.X(), aLeft.Y());
+ basegfx::B2DPoint aPositionRight(aRight.X(), aRight.Y());
+ basegfx::B2DPoint aPosition2(a2ndPos.X(), a2ndPos.Y());
+
+ pNewOverlayObject = new
+ ::sdr::overlay::OverlayTriangle(
+ aPositionLeft,
+ aPosition2,
+ aPositionRight,
+ IsGradient() ? Color(COL_BLACK) : Color(COL_BLUE)
+ );
+ DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
+
+ rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
+ maOverlayGroup.append(*pNewOverlayObject);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+IMPL_LINK(SdrHdlGradient, ColorChangeHdl, SdrHdl*, /*pHdl*/)
+{
+ if(GetObj())
+ FromIAOToItem(GetObj(), TRUE, TRUE);
+ return 0;
+}
+
+void SdrHdlGradient::FromIAOToItem(SdrObject* _pObj, BOOL bSetItemOnObject, BOOL bUndo)
+{
+ // from IAO positions and colors to gradient
+ const SfxItemSet& rSet = _pObj->GetMergedItemSet();
+
+ GradTransformer aGradTransformer;
+ GradTransGradient aOldGradTransGradient;
+ GradTransGradient aGradTransGradient;
+ GradTransVector aGradTransVector;
+
+ String aString;
+
+ aGradTransVector.maPositionA = basegfx::B2DPoint(GetPos().X(), GetPos().Y());
+ aGradTransVector.maPositionB = basegfx::B2DPoint(Get2ndPos().X(), Get2ndPos().Y());
+ if(pColHdl1)
+ aGradTransVector.aCol1 = pColHdl1->GetColor();
+ if(pColHdl2)
+ aGradTransVector.aCol2 = pColHdl2->GetColor();
+
+ if(IsGradient())
+ aOldGradTransGradient.aGradient = ((XFillGradientItem&)rSet.Get(XATTR_FILLGRADIENT)).GetGradientValue();
+ else
+ aOldGradTransGradient.aGradient = ((XFillFloatTransparenceItem&)rSet.Get(XATTR_FILLFLOATTRANSPARENCE)).GetGradientValue();
+
+ // transform vector data to gradient
+ aGradTransformer.VecToGrad(aGradTransVector, aGradTransGradient, aOldGradTransGradient, _pObj, bMoveSingleHandle, bMoveFirstHandle);
+
+ if(bSetItemOnObject)
+ {
+ SdrModel* pModel = _pObj->GetModel();
+ SfxItemSet aNewSet(pModel->GetItemPool());
+
+ if(IsGradient())
+ {
+ aString = String();
+ XFillGradientItem aNewGradItem(aString, aGradTransGradient.aGradient);
+ aNewSet.Put(aNewGradItem);
+ }
+ else
+ {
+ aString = String();
+ XFillFloatTransparenceItem aNewTransItem(aString, aGradTransGradient.aGradient);
+ aNewSet.Put(aNewTransItem);
+ }
+
+ if(bUndo && pModel->IsUndoEnabled())
+ {
+ pModel->BegUndo(SVX_RESSTR(IsGradient() ? SIP_XA_FILLGRADIENT : SIP_XA_FILLTRANSPARENCE));
+ pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*_pObj));
+ pModel->EndUndo();
+ }
+
+ pObj->SetMergedItemSetAndBroadcast(aNewSet);
+ }
+
+ // back transformation, set values on pIAOHandle
+ aGradTransformer.GradToVec(aGradTransGradient, aGradTransVector, _pObj);
+
+ SetPos(Point(FRound(aGradTransVector.maPositionA.getX()), FRound(aGradTransVector.maPositionA.getY())));
+ Set2ndPos(Point(FRound(aGradTransVector.maPositionB.getX()), FRound(aGradTransVector.maPositionB.getY())));
+ if(pColHdl1)
+ {
+ pColHdl1->SetPos(Point(FRound(aGradTransVector.maPositionA.getX()), FRound(aGradTransVector.maPositionA.getY())));
+ pColHdl1->SetColor(aGradTransVector.aCol1);
+ }
+ if(pColHdl2)
+ {
+ pColHdl2->SetPos(Point(FRound(aGradTransVector.maPositionB.getX()), FRound(aGradTransVector.maPositionB.getY())));
+ pColHdl2->SetColor(aGradTransVector.aCol2);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrHdlLine::~SdrHdlLine() {}
+
+void SdrHdlLine::CreateB2dIAObject()
+{
+ // first throw away old one
+ GetRidOfIAObject();
+
+ if(pHdlList)
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+
+ if(pView && !pView->areMarkHandlesHidden() && pHdl1 && pHdl2)
+ {
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager())
+ {
+ basegfx::B2DPoint aPosition1(pHdl1->GetPos().X(), pHdl1->GetPos().Y());
+ basegfx::B2DPoint aPosition2(pHdl2->GetPos().X(), pHdl2->GetPos().Y());
+
+ ::sdr::overlay::OverlayObject* pNewOverlayObject = new
+ ::sdr::overlay::OverlayLineStriped(
+ aPosition1,
+ aPosition2
+ );
+ DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
+
+ // OVERLAYMANAGER
+ if(pNewOverlayObject)
+ {
+ // color(?)
+ pNewOverlayObject->setBaseColor(Color(COL_LIGHTRED));
+
+ rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
+ maOverlayGroup.append(*pNewOverlayObject);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+Pointer SdrHdlLine::GetPointer() const
+{
+ return Pointer(POINTER_REFHAND);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrHdlBezWgt::~SdrHdlBezWgt() {}
+
+void SdrHdlBezWgt::CreateB2dIAObject()
+{
+ // call parent
+ SdrHdl::CreateB2dIAObject();
+
+ // create lines
+ if(pHdlList)
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+
+ if(pView && !pView->areMarkHandlesHidden())
+ {
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager())
+ {
+ basegfx::B2DPoint aPosition1(pHdl1->GetPos().X(), pHdl1->GetPos().Y());
+ basegfx::B2DPoint aPosition2(aPos.X(), aPos.Y());
+
+ if(!aPosition1.equal(aPosition2))
+ {
+ ::sdr::overlay::OverlayObject* pNewOverlayObject = new
+ ::sdr::overlay::OverlayLineStriped(
+ aPosition1,
+ aPosition2
+ );
+ DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
+
+ // OVERLAYMANAGER
+ if(pNewOverlayObject)
+ {
+ // line part is not hittable
+ pNewOverlayObject->setHittable(sal_False);
+
+ // color(?)
+ pNewOverlayObject->setBaseColor(Color(COL_LIGHTBLUE));
+
+ rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
+ maOverlayGroup.append(*pNewOverlayObject);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+E3dVolumeMarker::E3dVolumeMarker(const basegfx::B2DPolyPolygon& rWireframePoly)
+{
+ aWireframePoly = rWireframePoly;
+}
+
+void E3dVolumeMarker::CreateB2dIAObject()
+{
+ // create lines
+ if(pHdlList)
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+
+ if(pView && !pView->areMarkHandlesHidden())
+ {
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager() && aWireframePoly.count())
+ {
+ ::sdr::overlay::OverlayObject* pNewOverlayObject = new
+ ::sdr::overlay::OverlayPolyPolygonStriped(aWireframePoly);
+ DBG_ASSERT(pNewOverlayObject, "Got NO new IAO!");
+
+ // OVERLAYMANAGER
+ if(pNewOverlayObject)
+ {
+ pNewOverlayObject->setBaseColor(Color(COL_BLACK));
+
+ rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
+ maOverlayGroup.append(*pNewOverlayObject);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ImpEdgeHdl::~ImpEdgeHdl()
+{
+}
+
+void ImpEdgeHdl::CreateB2dIAObject()
+{
+ if(nObjHdlNum <= 1 && pObj)
+ {
+ // first throw away old one
+ GetRidOfIAObject();
+
+ BitmapColorIndex eColIndex = LightCyan;
+ BitmapMarkerKind eKindOfMarker = Rect_7x7;
+
+ if(pHdlList)
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+
+ if(pView && !pView->areMarkHandlesHidden())
+ {
+ const SdrEdgeObj* pEdge = (SdrEdgeObj*)pObj;
+
+ if(pEdge->GetConnectedNode(nObjHdlNum == 0) != NULL)
+ eColIndex = LightRed;
+
+ if(nPPntNum < 2)
+ {
+ // Handle with plus sign inside
+ eKindOfMarker = Circ_7x7;
+ }
+
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b(0); b < pPageView->PageWindowCount(); b++)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager())
+ {
+ basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
+
+ ::sdr::overlay::OverlayObject* pNewOverlayObject = CreateOverlayObject(
+ aPosition,
+ eColIndex,
+ eKindOfMarker);
+
+ // OVERLAYMANAGER
+ if(pNewOverlayObject)
+ {
+ rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
+ maOverlayGroup.append(*pNewOverlayObject);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ // call parent
+ SdrHdl::CreateB2dIAObject();
+ }
+}
+
+void ImpEdgeHdl::SetLineCode(SdrEdgeLineCode eCode)
+{
+ if(eLineCode != eCode)
+ {
+ // remember new value
+ eLineCode = eCode;
+
+ // create new display
+ Touch();
+ }
+}
+
+Pointer ImpEdgeHdl::GetPointer() const
+{
+ SdrEdgeObj* pEdge=PTR_CAST(SdrEdgeObj,pObj);
+ if (pEdge==NULL)
+ return SdrHdl::GetPointer();
+ if (nObjHdlNum<=1)
+ return Pointer(POINTER_MOVEPOINT); //Pointer(POINTER_DRAW_CONNECT);
+ if (IsHorzDrag())
+ return Pointer(POINTER_ESIZE);
+ else
+ return Pointer(POINTER_SSIZE);
+}
+
+BOOL ImpEdgeHdl::IsHorzDrag() const
+{
+ SdrEdgeObj* pEdge=PTR_CAST(SdrEdgeObj,pObj);
+ if (pEdge==NULL)
+ return FALSE;
+ if (nObjHdlNum<=1)
+ return FALSE;
+
+ SdrEdgeKind eEdgeKind = ((SdrEdgeKindItem&)(pEdge->GetObjectItem(SDRATTR_EDGEKIND))).GetValue();
+
+ const SdrEdgeInfoRec& rInfo=pEdge->aEdgeInfo;
+ if (eEdgeKind==SDREDGE_ORTHOLINES || eEdgeKind==SDREDGE_BEZIER)
+ {
+ return !rInfo.ImpIsHorzLine(eLineCode,*pEdge->pEdgeTrack);
+ }
+ else if (eEdgeKind==SDREDGE_THREELINES)
+ {
+ long nWink=nObjHdlNum==2 ? rInfo.nAngle1 : rInfo.nAngle2;
+ if (nWink==0 || nWink==18000)
+ return TRUE;
+ else
+ return FALSE;
+ }
+ return FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ImpMeasureHdl::~ImpMeasureHdl()
+{
+}
+
+void ImpMeasureHdl::CreateB2dIAObject()
+{
+ // first throw away old one
+ GetRidOfIAObject();
+
+ if(pHdlList)
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+
+ if(pView && !pView->areMarkHandlesHidden())
+ {
+ BitmapColorIndex eColIndex = LightCyan;
+ BitmapMarkerKind eKindOfMarker = Rect_9x9;
+
+ if(nObjHdlNum > 1)
+ {
+ eKindOfMarker = Rect_7x7;
+ }
+
+ if(bSelect)
+ {
+ eColIndex = Cyan;
+ }
+
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager())
+ {
+ basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
+
+ ::sdr::overlay::OverlayObject* pNewOverlayObject = CreateOverlayObject(
+ aPosition,
+ eColIndex,
+ eKindOfMarker);
+
+ // OVERLAYMANAGER
+ if(pNewOverlayObject)
+ {
+ rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
+ maOverlayGroup.append(*pNewOverlayObject);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+Pointer ImpMeasureHdl::GetPointer() const
+{
+ switch (nObjHdlNum)
+ {
+ case 0: case 1: return Pointer(POINTER_HAND);
+ case 2: case 3: return Pointer(POINTER_MOVEPOINT);
+ case 4: case 5: return SdrHdl::GetPointer(); // wird dann entsprechend gedreht
+ } // switch
+ return Pointer(POINTER_NOTALLOWED);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ImpTextframeHdl::ImpTextframeHdl(const Rectangle& rRect) :
+ SdrHdl(rRect.TopLeft(),HDL_MOVE),
+ maRect(rRect)
+{
+}
+
+void ImpTextframeHdl::CreateB2dIAObject()
+{
+ // first throw away old one
+ GetRidOfIAObject();
+
+ if(pHdlList)
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+
+ if(pView && !pView->areMarkHandlesHidden())
+ {
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager())
+ {
+ const basegfx::B2DPoint aTopLeft(maRect.Left(), maRect.Top());
+ const basegfx::B2DPoint aBottomRight(maRect.Right(), maRect.Bottom());
+ const svtools::ColorConfig aColorConfig;
+ const Color aHatchCol( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
+
+ ::sdr::overlay::OverlayHatchRect* pNewOverlayObject = new ::sdr::overlay::OverlayHatchRect(
+ aTopLeft,
+ aBottomRight,
+ aHatchCol,
+ 3.0,
+ 3.0,
+ 45 * F_PI180,
+ nDrehWink * -F_PI18000);
+ pNewOverlayObject->setHittable(false);
+
+ // OVERLAYMANAGER
+ if(pNewOverlayObject)
+ {
+ rPageWindow.GetOverlayManager()->add(*pNewOverlayObject);
+ maOverlayGroup.append(*pNewOverlayObject);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ImpSdrHdlListSorter: public ContainerSorter {
+public:
+ ImpSdrHdlListSorter(Container& rNewCont): ContainerSorter(rNewCont) {}
+ virtual int Compare(const void* pElem1, const void* pElem2) const;
+};
+
+int ImpSdrHdlListSorter::Compare(const void* pElem1, const void* pElem2) const
+{
+ SdrHdlKind eKind1=((SdrHdl*)pElem1)->GetKind();
+ SdrHdlKind eKind2=((SdrHdl*)pElem2)->GetKind();
+ // Level 1: Erst normale Handles, dann Glue, dann User, dann Plushandles, dann Retpunkt-Handles
+ unsigned n1=1;
+ unsigned n2=1;
+ if (eKind1!=eKind2)
+ {
+ if (eKind1==HDL_REF1 || eKind1==HDL_REF2 || eKind1==HDL_MIRX) n1=5;
+ else if (eKind1==HDL_GLUE) n1=2;
+ else if (eKind1==HDL_USER) n1=3;
+ else if (eKind1==HDL_SMARTTAG) n1=0;
+ if (eKind2==HDL_REF1 || eKind2==HDL_REF2 || eKind2==HDL_MIRX) n2=5;
+ else if (eKind2==HDL_GLUE) n2=2;
+ else if (eKind2==HDL_USER) n2=3;
+ else if (eKind2==HDL_SMARTTAG) n2=0;
+ }
+ if (((SdrHdl*)pElem1)->IsPlusHdl()) n1=4;
+ if (((SdrHdl*)pElem2)->IsPlusHdl()) n2=4;
+ if (n1==n2)
+ {
+ // Level 2: PageView (Pointer)
+ SdrPageView* pPV1=((SdrHdl*)pElem1)->GetPageView();
+ SdrPageView* pPV2=((SdrHdl*)pElem2)->GetPageView();
+ if (pPV1==pPV2)
+ {
+ // Level 3: Position (x+y)
+ SdrObject* pObj1=((SdrHdl*)pElem1)->GetObj();
+ SdrObject* pObj2=((SdrHdl*)pElem2)->GetObj();
+ if (pObj1==pObj2)
+ {
+ sal_uInt32 nNum1=((SdrHdl*)pElem1)->GetObjHdlNum();
+ sal_uInt32 nNum2=((SdrHdl*)pElem2)->GetObjHdlNum();
+ if (nNum1==nNum2)
+ { // #48763#
+ if (eKind1==eKind2)
+ return (long)pElem1<(long)pElem2 ? -1 : 1; // Notloesung, um immer die gleiche Sortierung zu haben
+ return (USHORT)eKind1<(USHORT)eKind2 ? -1 : 1;
+ }
+ else
+ return nNum1<nNum2 ? -1 : 1;
+ }
+ else
+ {
+ return (long)pObj1<(long)pObj2 ? -1 : 1;
+ }
+ }
+ else
+ {
+ return (long)pPV1<(long)pPV2 ? -1 : 1;
+ }
+ }
+ else
+ {
+ return n1<n2 ? -1 : 1;
+ }
+}
+
+SdrMarkView* SdrHdlList::GetView() const
+{
+ return pView;
+}
+
+// #105678# Help struct for re-sorting handles
+struct ImplHdlAndIndex
+{
+ SdrHdl* mpHdl;
+ sal_uInt32 mnIndex;
+};
+
+// #105678# Help method for sorting handles taking care of OrdNums, keeping order in
+// single objects and re-sorting polygon handles intuitively
+extern "C" int __LOADONCALLAPI ImplSortHdlFunc( const void* pVoid1, const void* pVoid2 )
+{
+ const ImplHdlAndIndex* p1 = (ImplHdlAndIndex*)pVoid1;
+ const ImplHdlAndIndex* p2 = (ImplHdlAndIndex*)pVoid2;
+
+ if(p1->mpHdl->GetObj() == p2->mpHdl->GetObj())
+ {
+ if(p1->mpHdl->GetObj() && p1->mpHdl->GetObj()->ISA(SdrPathObj))
+ {
+ // same object and a path object
+ if((p1->mpHdl->GetKind() == HDL_POLY || p1->mpHdl->GetKind() == HDL_BWGT)
+ && (p2->mpHdl->GetKind() == HDL_POLY || p2->mpHdl->GetKind() == HDL_BWGT))
+ {
+ // both handles are point or control handles
+ if(p1->mpHdl->GetPolyNum() == p2->mpHdl->GetPolyNum())
+ {
+ if(p1->mpHdl->GetPointNum() < p2->mpHdl->GetPointNum())
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ else if(p1->mpHdl->GetPolyNum() < p2->mpHdl->GetPolyNum())
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ }
+ }
+ else
+ {
+ if(!p1->mpHdl->GetObj())
+ {
+ return -1;
+ }
+ else if(!p2->mpHdl->GetObj())
+ {
+ return 1;
+ }
+ else
+ {
+ // different objects, use OrdNum for sort
+ const sal_uInt32 nOrdNum1 = p1->mpHdl->GetObj()->GetOrdNum();
+ const sal_uInt32 nOrdNum2 = p2->mpHdl->GetObj()->GetOrdNum();
+
+ if(nOrdNum1 < nOrdNum2)
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ }
+
+ // fallback to indices
+ if(p1->mnIndex < p2->mnIndex)
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #97016# II
+
+void SdrHdlList::TravelFocusHdl(sal_Bool bForward)
+{
+ // security correction
+ if(mnFocusIndex != CONTAINER_ENTRY_NOTFOUND && mnFocusIndex >= GetHdlCount())
+ mnFocusIndex = CONTAINER_ENTRY_NOTFOUND;
+
+ if(aList.Count())
+ {
+ // take care of old handle
+ const ULONG nOldHdlNum(mnFocusIndex);
+ SdrHdl* pOld = GetHdl(nOldHdlNum);
+ //SDOsal_Bool bRefresh(sal_False);
+
+ if(pOld)
+ {
+ // switch off old handle
+ mnFocusIndex = CONTAINER_ENTRY_NOTFOUND;
+ pOld->Touch();
+ //SDObRefresh = sal_True;
+ }
+
+ // #105678# Alloc pointer array for sorted handle list
+ ImplHdlAndIndex* pHdlAndIndex = new ImplHdlAndIndex[aList.Count()];
+
+ // #105678# build sorted handle list
+ sal_uInt32 a;
+ for( a = 0; a < aList.Count(); a++)
+ {
+ pHdlAndIndex[a].mpHdl = (SdrHdl*)aList.GetObject(a);
+ pHdlAndIndex[a].mnIndex = a;
+ }
+
+ // #105678# qsort all entries
+ qsort(pHdlAndIndex, aList.Count(), sizeof(ImplHdlAndIndex), ImplSortHdlFunc);
+
+ // #105678# look for old num in sorted array
+ ULONG nOldHdl(nOldHdlNum);
+
+ if(nOldHdlNum != CONTAINER_ENTRY_NOTFOUND)
+ {
+ for(a = 0; a < aList.Count(); a++)
+ {
+ if(pHdlAndIndex[a].mpHdl == pOld)
+ {
+ nOldHdl = a;
+ break;
+ }
+ }
+ }
+
+ // #105678# build new HdlNum
+ ULONG nNewHdl(nOldHdl);
+
+ // #105678# do the focus travel
+ if(bForward)
+ {
+ if(nOldHdl != CONTAINER_ENTRY_NOTFOUND)
+ {
+ if(nOldHdl == aList.Count() - 1)
+ {
+ // end forward run
+ nNewHdl = CONTAINER_ENTRY_NOTFOUND;
+ }
+ else
+ {
+ // simply the next handle
+ nNewHdl++;
+ }
+ }
+ else
+ {
+ // start forward run at first entry
+ nNewHdl = 0;
+ }
+ }
+ else
+ {
+ if(nOldHdl == CONTAINER_ENTRY_NOTFOUND)
+ {
+ // start backward run at last entry
+ nNewHdl = aList.Count() - 1;
+
+ }
+ else
+ {
+ if(nOldHdl == 0)
+ {
+ // end backward run
+ nNewHdl = CONTAINER_ENTRY_NOTFOUND;
+ }
+ else
+ {
+ // simply the previous handle
+ nNewHdl--;
+ }
+ }
+ }
+
+ // #105678# build new HdlNum
+ sal_uInt32 nNewHdlNum(nNewHdl);
+
+ // look for old num in sorted array
+ if(nNewHdl != CONTAINER_ENTRY_NOTFOUND)
+ {
+ SdrHdl* pNew = pHdlAndIndex[nNewHdl].mpHdl;
+
+ for(a = 0; a < aList.Count(); a++)
+ {
+ if((SdrHdl*)aList.GetObject(a) == pNew)
+ {
+ nNewHdlNum = a;
+ break;
+ }
+ }
+ }
+
+ // take care of next handle
+ if(nOldHdlNum != nNewHdlNum)
+ {
+ mnFocusIndex = nNewHdlNum;
+ SdrHdl* pNew = GetHdl(mnFocusIndex);
+
+ if(pNew)
+ {
+ pNew->Touch();
+ //SDObRefresh = sal_True;
+ }
+ }
+
+ // #105678# free mem again
+ delete [] pHdlAndIndex;
+ }
+}
+
+SdrHdl* SdrHdlList::GetFocusHdl() const
+{
+ if(mnFocusIndex != CONTAINER_ENTRY_NOTFOUND && mnFocusIndex < GetHdlCount())
+ return GetHdl(mnFocusIndex);
+ else
+ return 0L;
+}
+
+void SdrHdlList::SetFocusHdl(SdrHdl* pNew)
+{
+ if(pNew)
+ {
+ SdrHdl* pActual = GetFocusHdl();
+
+ if(!pActual || pActual != pNew)
+ {
+ ULONG nNewHdlNum = GetHdlNum(pNew);
+
+ if(nNewHdlNum != CONTAINER_ENTRY_NOTFOUND)
+ {
+ //SDOsal_Bool bRefresh(sal_False);
+ mnFocusIndex = nNewHdlNum;
+
+ if(pActual)
+ {
+ pActual->Touch();
+ //SDObRefresh = sal_True;
+ }
+
+ if(pNew)
+ {
+ pNew->Touch();
+ //SDObRefresh = sal_True;
+ }
+
+ //OLMif(bRefresh)
+ //OLM{
+ //OLM if(pView)
+ //OLM pView->RefreshAllIAOManagers();
+ //OLM}
+ }
+ }
+ }
+}
+
+void SdrHdlList::ResetFocusHdl()
+{
+ SdrHdl* pHdl = GetFocusHdl();
+
+ mnFocusIndex = CONTAINER_ENTRY_NOTFOUND;
+
+ if(pHdl)
+ {
+ pHdl->Touch();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrHdlList::SdrHdlList(SdrMarkView* pV)
+: mnFocusIndex(CONTAINER_ENTRY_NOTFOUND),
+ pView(pV),
+ aList(1024,32,32)
+{
+ nHdlSize = 3;
+ bRotateShear = FALSE;
+ bMoveOutside = FALSE;
+ bDistortShear = FALSE;
+ bFineHandles = FALSE;
+}
+
+SdrHdlList::~SdrHdlList()
+{
+ Clear();
+}
+
+void SdrHdlList::SetHdlSize(USHORT nSiz)
+{
+ if(nHdlSize != nSiz)
+ {
+ // remember new value
+ nHdlSize = nSiz;
+
+ // propagate change to IAOs
+ for(UINT32 i=0; i<GetHdlCount(); i++)
+ {
+ SdrHdl* pHdl = GetHdl(i);
+ pHdl->Touch();
+ }
+ }
+}
+
+void SdrHdlList::SetMoveOutside(BOOL bOn)
+{
+ if(bMoveOutside != bOn)
+ {
+ // remember new value
+ bMoveOutside = bOn;
+
+ // propagate change to IAOs
+ for(UINT32 i=0; i<GetHdlCount(); i++)
+ {
+ SdrHdl* pHdl = GetHdl(i);
+ pHdl->Touch();
+ }
+ }
+}
+
+void SdrHdlList::SetRotateShear(BOOL bOn)
+{
+ bRotateShear = bOn;
+}
+
+void SdrHdlList::SetDistortShear(BOOL bOn)
+{
+ bDistortShear = bOn;
+}
+
+void SdrHdlList::SetFineHdl(BOOL bOn)
+{
+ if(bFineHandles != bOn)
+ {
+ // remember new state
+ bFineHandles = bOn;
+
+ // propagate change to IAOs
+ for(UINT32 i=0; i<GetHdlCount(); i++)
+ {
+ SdrHdl* pHdl = GetHdl(i);
+ pHdl->Touch();
+ }
+ }
+}
+
+SdrHdl* SdrHdlList::RemoveHdl(ULONG nNum)
+{
+ SdrHdl* pRetval = (SdrHdl*)aList.Remove(nNum);
+
+ return pRetval;
+}
+
+void SdrHdlList::Clear()
+{
+ for (ULONG i=0; i<GetHdlCount(); i++)
+ {
+ SdrHdl* pHdl=GetHdl(i);
+ delete pHdl;
+ }
+ aList.Clear();
+
+ bRotateShear=FALSE;
+ bDistortShear=FALSE;
+}
+
+void SdrHdlList::Sort()
+{
+ // #97016# II: remember current focused handle
+ SdrHdl* pPrev = GetFocusHdl();
+
+ ImpSdrHdlListSorter aSort(aList);
+ aSort.DoSort();
+
+ // #97016# II: get now and compare
+ SdrHdl* pNow = GetFocusHdl();
+
+ if(pPrev != pNow)
+ {
+ //SDOsal_Bool bRefresh(sal_False);
+
+ if(pPrev)
+ {
+ pPrev->Touch();
+ //SDObRefresh = sal_True;
+ }
+
+ if(pNow)
+ {
+ pNow->Touch();
+ //SDObRefresh = sal_True;
+ }
+ }
+}
+
+ULONG SdrHdlList::GetHdlNum(const SdrHdl* pHdl) const
+{
+ if (pHdl==NULL)
+ return CONTAINER_ENTRY_NOTFOUND;
+ ULONG nPos=aList.GetPos(pHdl);
+ return nPos;
+}
+
+void SdrHdlList::AddHdl(SdrHdl* pHdl, BOOL bAtBegin)
+{
+ if (pHdl!=NULL)
+ {
+ if (bAtBegin)
+ {
+ aList.Insert(pHdl,ULONG(0));
+ }
+ else
+ {
+ aList.Insert(pHdl,CONTAINER_APPEND);
+ }
+ pHdl->SetHdlList(this);
+ }
+}
+
+SdrHdl* SdrHdlList::IsHdlListHit(const Point& rPnt, BOOL bBack, BOOL bNext, SdrHdl* pHdl0) const
+{
+ SdrHdl* pRet=NULL;
+ ULONG nAnz=GetHdlCount();
+ ULONG nNum=bBack ? 0 : nAnz;
+ while ((bBack ? nNum<nAnz : nNum>0) && pRet==NULL)
+ {
+ if (!bBack)
+ nNum--;
+ SdrHdl* pHdl=GetHdl(nNum);
+ if (bNext)
+ {
+ if (pHdl==pHdl0)
+ bNext=FALSE;
+ }
+ else
+ {
+ if (pHdl->IsHdlHit(rPnt))
+ pRet=pHdl;
+ }
+ if (bBack)
+ nNum++;
+ }
+ return pRet;
+}
+
+SdrHdl* SdrHdlList::GetHdl(SdrHdlKind eKind1) const
+{
+ SdrHdl* pRet=NULL;
+ for (ULONG i=0; i<GetHdlCount() && pRet==NULL; i++)
+ {
+ SdrHdl* pHdl=GetHdl(i);
+ if (pHdl->GetKind()==eKind1)
+ pRet=pHdl;
+ }
+ return pRet;
+}
+
+// --------------------------------------------------------------------
+// SdrCropHdl
+// --------------------------------------------------------------------
+
+SdrCropHdl::SdrCropHdl(const Point& rPnt, SdrHdlKind eNewKind)
+: SdrHdl( rPnt, eNewKind )
+{
+}
+
+// --------------------------------------------------------------------
+
+BitmapEx SdrCropHdl::GetHandlesBitmap( bool bIsFineHdl, bool bIsHighContrast )
+{
+ if( bIsHighContrast )
+ {
+ static BitmapEx* pHighContrastBitmap = 0;
+ if( pHighContrastBitmap == 0 )
+ pHighContrastBitmap = new BitmapEx(ResId(SIP_SA_ACCESSIBILITY_CROP_MARKERS, *ImpGetResMgr()));
+ return *pHighContrastBitmap;
+ }
+ else if( bIsFineHdl )
+ {
+ static BitmapEx* pModernBitmap = 0;
+ if( pModernBitmap == 0 )
+ pModernBitmap = new BitmapEx(ResId(SIP_SA_CROP_FINE_MARKERS, *ImpGetResMgr()));
+ return *pModernBitmap;
+ }
+ else
+ {
+ static BitmapEx* pSimpleBitmap = 0;
+ if( pSimpleBitmap == 0 )
+ pSimpleBitmap = new BitmapEx(ResId(SIP_SA_CROP_MARKERS, *ImpGetResMgr()));
+ return *pSimpleBitmap;
+ }
+}
+
+// --------------------------------------------------------------------
+
+BitmapEx SdrCropHdl::GetBitmapForHandle( const BitmapEx& rBitmap, int nSize )
+{
+ int nPixelSize = 0, nX = 0, nY = 0, nOffset = 0;
+
+ if( nSize <= 3 )
+ {
+ nPixelSize = 13;
+ nOffset = 0;
+ }
+ else if( nSize <=4 )
+ {
+ nPixelSize = 17;
+ nOffset = 36;
+ }
+ else
+ {
+ nPixelSize = 21;
+ nOffset = 84;
+ }
+
+ switch( eKind )
+ {
+ case HDL_UPLFT: nX = 0; nY = 0; break;
+ case HDL_UPPER: nX = 1; nY = 0; break;
+ case HDL_UPRGT: nX = 2; nY = 0; break;
+ case HDL_LEFT: nX = 0; nY = 1; break;
+ case HDL_RIGHT: nX = 2; nY = 1; break;
+ case HDL_LWLFT: nX = 0; nY = 2; break;
+ case HDL_LOWER: nX = 1; nY = 2; break;
+ case HDL_LWRGT: nX = 2; nY = 2; break;
+ default: break;
+ }
+
+ Rectangle aSourceRect( Point( nX * (nPixelSize-1) + nOffset, nY * (nPixelSize-1)), Size(nPixelSize, nPixelSize) );
+
+ BitmapEx aRetval(rBitmap);
+ aRetval.Crop(aSourceRect);
+ return aRetval;
+}
+
+// --------------------------------------------------------------------
+
+void SdrCropHdl::CreateB2dIAObject()
+{
+ // first throw away old one
+ GetRidOfIAObject();
+
+ SdrMarkView* pView = pHdlList ? pHdlList->GetView() : 0;
+ SdrPageView* pPageView = pView ? pView->GetSdrPageView() : 0;
+
+ if( pPageView && !pView->areMarkHandlesHidden() )
+ {
+ sal_Bool bIsFineHdl(pHdlList->IsFineHdl());
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ sal_Bool bIsHighContrast(rStyleSettings.GetHighContrastMode());
+ int nHdlSize = pHdlList->GetHdlSize();
+ if( bIsHighContrast )
+ nHdlSize = 4;
+
+ const BitmapEx aHandlesBitmap( GetHandlesBitmap( bIsFineHdl, bIsHighContrast ) );
+ BitmapEx aBmpEx1( GetBitmapForHandle( aHandlesBitmap, nHdlSize ) );
+
+ for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
+ {
+ // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager())
+ {
+ basegfx::B2DPoint aPosition(aPos.X(), aPos.Y());
+
+ ::sdr::overlay::OverlayObject* pOverlayObject = 0L;
+
+ // animate focused handles
+ if(IsFocusHdl() && (pHdlList->GetFocusHdl() == this))
+ {
+ if( nHdlSize >= 2 )
+ nHdlSize = 1;
+
+ BitmapEx aBmpEx2( GetBitmapForHandle( aHandlesBitmap, nHdlSize + 1 ) );
+
+ const sal_uInt32 nBlinkTime = sal::static_int_cast<sal_uInt32>(rStyleSettings.GetCursorBlinkTime());
+
+ pOverlayObject = new ::sdr::overlay::OverlayAnimatedBitmapEx(aPosition, aBmpEx1, aBmpEx2, nBlinkTime,
+ (UINT16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
+ (UINT16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1,
+ (UINT16)(aBmpEx2.GetSizePixel().Width() - 1) >> 1,
+ (UINT16)(aBmpEx2.GetSizePixel().Height() - 1) >> 1);
+ }
+ else
+ {
+ // create centered handle as default
+ pOverlayObject = new ::sdr::overlay::OverlayBitmapEx(aPosition, aBmpEx1,
+ (UINT16)(aBmpEx1.GetSizePixel().Width() - 1) >> 1,
+ (UINT16)(aBmpEx1.GetSizePixel().Height() - 1) >> 1);
+ }
+
+ // OVERLAYMANAGER
+ if(pOverlayObject)
+ {
+ rPageWindow.GetOverlayManager()->add(*pOverlayObject);
+ maOverlayGroup.append(*pOverlayObject);
+ }
+ }
+ }
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdhlpln.cxx b/svx/source/svdraw/svdhlpln.cxx
new file mode 100644
index 000000000000..dc03845e529f
--- /dev/null
+++ b/svx/source/svdraw/svdhlpln.cxx
@@ -0,0 +1,152 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdhlpln.hxx>
+#include <tools/color.hxx>
+
+#include <vcl/outdev.hxx>
+#include <vcl/window.hxx>
+#include <tools/poly.hxx>
+#include <vcl/lineinfo.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Pointer SdrHelpLine::GetPointer() const
+{
+ switch (eKind) {
+ case SDRHELPLINE_VERTICAL : return Pointer(POINTER_ESIZE);
+ case SDRHELPLINE_HORIZONTAL: return Pointer(POINTER_SSIZE);
+ default : return Pointer(POINTER_MOVE);
+ } // switch
+}
+
+bool SdrHelpLine::IsHit(const Point& rPnt, USHORT nTolLog, const OutputDevice& rOut) const
+{
+ Size a1Pix(rOut.PixelToLogic(Size(1,1)));
+ bool bXHit=rPnt.X()>=aPos.X()-nTolLog && rPnt.X()<=aPos.X()+nTolLog+a1Pix.Width();
+ bool bYHit=rPnt.Y()>=aPos.Y()-nTolLog && rPnt.Y()<=aPos.Y()+nTolLog+a1Pix.Height();
+ switch (eKind) {
+ case SDRHELPLINE_VERTICAL : return bXHit;
+ case SDRHELPLINE_HORIZONTAL: return bYHit;
+ case SDRHELPLINE_POINT: {
+ if (bXHit || bYHit) {
+ Size aRad(rOut.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE,SDRHELPLINE_POINT_PIXELSIZE)));
+ return rPnt.X()>=aPos.X()-aRad.Width() && rPnt.X()<=aPos.X()+aRad.Width()+a1Pix.Width() &&
+ rPnt.Y()>=aPos.Y()-aRad.Height() && rPnt.Y()<=aPos.Y()+aRad.Height()+a1Pix.Height();
+ }
+ } break;
+ } // switch
+ return FALSE;
+}
+
+Rectangle SdrHelpLine::GetBoundRect(const OutputDevice& rOut) const
+{
+ Rectangle aRet(aPos,aPos);
+ Point aOfs(rOut.GetMapMode().GetOrigin());
+ Size aSiz(rOut.GetOutputSize());
+ switch (eKind) {
+ case SDRHELPLINE_VERTICAL : aRet.Top()=-aOfs.Y(); aRet.Bottom()=-aOfs.Y()+aSiz.Height(); break;
+ case SDRHELPLINE_HORIZONTAL: aRet.Left()=-aOfs.X(); aRet.Right()=-aOfs.X()+aSiz.Width(); break;
+ case SDRHELPLINE_POINT : {
+ Size aRad(rOut.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE,SDRHELPLINE_POINT_PIXELSIZE)));
+ aRet.Left() -=aRad.Width();
+ aRet.Right() +=aRad.Width();
+ aRet.Top() -=aRad.Height();
+ aRet.Bottom()+=aRad.Height();
+ } break;
+ } // switch
+ return aRet;
+}
+
+bool SdrHelpLine::IsVisibleEqual( const SdrHelpLine& rHelpLine, const OutputDevice& rOut ) const
+{
+ if( eKind == rHelpLine.eKind)
+ {
+ Point aPt1(rOut.LogicToPixel(aPos)), aPt2(rOut.LogicToPixel(rHelpLine.aPos));
+ switch( eKind )
+ {
+ case SDRHELPLINE_POINT:
+ return aPt1 == aPt2;
+ case SDRHELPLINE_VERTICAL:
+ return aPt1.X() == aPt2.X();
+ case SDRHELPLINE_HORIZONTAL:
+ return aPt1.Y() == aPt2.Y();
+ }
+ }
+ return false;
+}
+
+void SdrHelpLineList::Clear()
+{
+ USHORT nAnz=GetCount();
+ for (USHORT i=0; i<nAnz; i++) {
+ delete GetObject(i);
+ }
+ aList.Clear();
+}
+
+void SdrHelpLineList::operator=(const SdrHelpLineList& rSrcList)
+{
+ Clear();
+ USHORT nAnz=rSrcList.GetCount();
+ for (USHORT i=0; i<nAnz; i++) {
+ Insert(rSrcList[i]);
+ }
+}
+
+bool SdrHelpLineList::operator==(const SdrHelpLineList& rSrcList) const
+{
+ bool bEqual = false;
+ USHORT nAnz=GetCount();
+ if (nAnz==rSrcList.GetCount()) {
+ bEqual = true;
+ for (USHORT i=0; i<nAnz && bEqual; i++) {
+ if (*GetObject(i)!=*rSrcList.GetObject(i)) {
+ bEqual = false;
+ }
+ }
+ }
+ return bEqual;
+}
+
+USHORT SdrHelpLineList::HitTest(const Point& rPnt, USHORT nTolLog, const OutputDevice& rOut) const
+{
+ USHORT nAnz=GetCount();
+ for (USHORT i=nAnz; i>0;) {
+ i--;
+ if (GetObject(i)->IsHit(rPnt,nTolLog,rOut)) return i;
+ }
+ return SDRHELPLINE_NOTFOUND;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdibrow.cxx b/svx/source/svdraw/svdibrow.cxx
new file mode 100644
index 000000000000..8abca702b076
--- /dev/null
+++ b/svx/source/svdraw/svdibrow.cxx
@@ -0,0 +1,1301 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <editeng/eeitem.hxx>
+
+#include "svdibrow.hxx"
+
+#ifndef _STDLIB_H
+#include <stdlib.h>
+#define _STDLIB_H
+#endif
+
+#include "svditext.hxx"
+#include <editeng/flditem.hxx>
+#include <editeng/editdata.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdattr.hxx>
+#include <svx/svdattrx.hxx>
+#include <svx/svdview.hxx>
+#include <svx/xenum.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflbmtit.hxx>
+#include <svx/xtextit0.hxx>
+#include <svx/xflbstit.hxx>
+#include <svx/xflbtoxy.hxx>
+#include <svx/xftshit.hxx>
+#include <editeng/colritem.hxx>
+
+
+#include "editeng/fontitem.hxx"
+#include <editeng/fhgtitem.hxx>
+
+#include <editeng/charscaleitem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/flagitem.hxx>
+#include <svl/ptitem.hxx>
+#include <svl/rectitem.hxx>
+
+#include <svl/rngitem.hxx>
+#include <sdrpaintwindow.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#define ITEMBROWSER_WHICHCOL_ID 1
+#define ITEMBROWSER_STATECOL_ID 2
+#define ITEMBROWSER_TYPECOL_ID 3
+#define ITEMBROWSER_NAMECOL_ID 4
+#define ITEMBROWSER_VALUECOL_ID 5
+
+enum ItemType {
+ ITEM_DONTKNOW, ITEM_BYTE, ITEM_INT16, ITEM_UINT16, ITEM_INT32, ITEM_UINT32,
+ ITEM_ENUM, ITEM_BOOL, ITEM_FLAG, ITEM_STRING, ITEM_POINT, ITEM_RECT, ITEM_RANGE, ITEM_LRANGE,
+ ITEM_FRACTION,
+ ITEM_XCOLOR,
+ ITEM_COLOR,
+ ITEM_FONT, ITEM_FONTHEIGHT, ITEM_FONTWIDTH, ITEM_FIELD
+};
+
+class ImpItemListRow
+{
+public:
+ XubString aName;
+ XubString aValue;
+ SfxItemState eState;
+ UINT16 nWhichId;
+
+ TypeId pType;
+ ItemType eItemType;
+
+ INT32 nVal;
+ INT32 nMin;
+ INT32 nMax;
+
+ BOOL bComment;
+ BOOL bIsNum;
+ BOOL bCanNum;
+
+public:
+ ImpItemListRow()
+ : eState(SFX_ITEM_UNKNOWN),
+ nWhichId(0),
+ pType(NULL),
+ eItemType(ITEM_DONTKNOW),
+ nVal(0),
+ nMin(0),
+ nMax(0),
+ bComment(FALSE),
+ bIsNum(FALSE),
+ bCanNum(FALSE)
+ {}
+
+ XubString GetItemTypeStr() const;
+ BOOL operator==(const ImpItemListRow& rEntry) const;
+ BOOL operator!=(const ImpItemListRow& rEntry) const { return !operator==(rEntry); }
+};
+
+XubString ImpItemListRow::GetItemTypeStr() const
+{
+ XubString aStr;
+
+ switch(eItemType)
+ {
+ case ITEM_BYTE : aStr.AppendAscii("Byte"); break;
+ case ITEM_INT16 : aStr.AppendAscii("Int16"); break;
+ case ITEM_UINT16 : aStr.AppendAscii("UInt16"); break;
+ case ITEM_INT32 : aStr.AppendAscii("Int32"); break;
+ case ITEM_UINT32 : aStr.AppendAscii("UInt32"); break;
+ case ITEM_ENUM : aStr.AppendAscii("Enum"); break;
+ case ITEM_BOOL : aStr.AppendAscii("Bool"); break;
+ case ITEM_FLAG : aStr.AppendAscii("Flag"); break;
+ case ITEM_STRING : aStr.AppendAscii("String"); break;
+ case ITEM_POINT : aStr.AppendAscii("Point"); break;
+ case ITEM_RECT : aStr.AppendAscii("Rectangle");break;
+ case ITEM_RANGE : aStr.AppendAscii("Range"); break;
+ case ITEM_LRANGE : aStr.AppendAscii("LRange"); break;
+ case ITEM_FRACTION : aStr.AppendAscii("Fraction"); break;
+ case ITEM_XCOLOR : aStr.AppendAscii("XColor"); break;
+ case ITEM_COLOR : aStr.AppendAscii("Color"); break;
+ case ITEM_FONT : aStr.AppendAscii("Font"); break;
+ case ITEM_FONTHEIGHT:aStr.AppendAscii("FontHeight");break;
+ case ITEM_FONTWIDTH :aStr.AppendAscii("FontWidth"); break;
+ case ITEM_FIELD :aStr.AppendAscii("Field"); break;
+ default: break;
+ }
+
+ return aStr;
+}
+
+BOOL ImpItemListRow::operator==(const ImpItemListRow& rEntry) const
+{
+ return (aName.Equals(rEntry.aName)
+ && aValue.Equals(rEntry.aValue)
+ && eState==rEntry.eState
+ && nWhichId==rEntry.nWhichId
+ && bComment==rEntry.bComment
+ && bIsNum==rEntry.bIsNum
+ && bCanNum==rEntry.bCanNum
+ && pType==rEntry.pType
+ && eItemType==rEntry.eItemType
+ && nVal==rEntry.nVal
+ && nMin==rEntry.nMin
+ && nMax==rEntry.nMax);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ImpItemEdit: public Edit
+{
+ _SdrItemBrowserControl* pBrowse;
+
+public:
+ ImpItemEdit(Window* pParent, _SdrItemBrowserControl* pBrowse_, WinBits nBits=0)
+ : Edit(pParent, nBits),
+ pBrowse(pBrowse_)
+ {}
+
+ virtual ~ImpItemEdit();
+ virtual void KeyInput(const KeyEvent& rEvt);
+};
+
+__EXPORT ImpItemEdit::~ImpItemEdit()
+{
+}
+
+void __EXPORT ImpItemEdit::KeyInput(const KeyEvent& rKEvt)
+{
+ _SdrItemBrowserControl* pBrowseMerk = pBrowse;
+
+ UINT16 nKeyCode(rKEvt.GetKeyCode().GetCode() + rKEvt.GetKeyCode().GetModifier());
+
+ if(nKeyCode == KEY_RETURN)
+ {
+ pBrowseMerk->EndChangeEntry();
+ pBrowseMerk->GrabFocus();
+ }
+ else if(nKeyCode == KEY_ESCAPE)
+ {
+ pBrowseMerk->BrkChangeEntry();
+ pBrowseMerk->GrabFocus();
+ }
+ else if(nKeyCode == KEY_UP || nKeyCode == KEY_DOWN)
+ {
+ pBrowseMerk->EndChangeEntry();
+ pBrowseMerk->GrabFocus();
+ pBrowseMerk->KeyInput(rKEvt);
+ }
+ else
+ Edit::KeyInput(rKEvt);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#define MYBROWSEMODE (BROWSER_THUMBDRAGGING|BROWSER_KEEPHIGHLIGHT|BROWSER_NO_HSCROLL|BROWSER_HIDECURSOR)
+
+_SdrItemBrowserControl::_SdrItemBrowserControl(Window* pParent, WinBits nBits):
+ BrowseBox(pParent,nBits,MYBROWSEMODE),
+ aList(1024,16,16)
+{
+ ImpCtor();
+}
+
+__EXPORT _SdrItemBrowserControl::~_SdrItemBrowserControl()
+{
+ if(pEditControl)
+ delete pEditControl;
+
+ if(pAktChangeEntry)
+ delete pAktChangeEntry;
+
+ Clear();
+}
+
+void _SdrItemBrowserControl::ImpCtor()
+{
+ pEditControl = NULL;
+ pAktChangeEntry = NULL;
+ nLastWhichOfs = 0;
+ nLastWhich = 0;
+ nLastWhichOben = 0; // not implemented yet
+ nLastWhichUnten = 0; // not implemented yet
+ bWhichesButNames = FALSE;
+ bDontHideIneffectiveItems = FALSE;
+ bDontSortItems = FALSE;
+ bShowWhichIds = FALSE;
+ bShowRealValues = FALSE;
+ bShowWhichIds = TRUE; // not implemented yet
+ bShowRealValues = TRUE; // not implemented yet
+
+ rtl_TextEncoding aTextEncoding = gsl_getSystemTextEncoding();
+
+ InsertDataColumn(
+ ITEMBROWSER_WHICHCOL_ID,
+ String("Which", aTextEncoding),
+ GetTextWidth(String(" Which ", aTextEncoding)) + 2);
+ InsertDataColumn(
+ ITEMBROWSER_STATECOL_ID,
+ String("State", aTextEncoding),
+ Max(GetTextWidth(String(" State ", aTextEncoding)) + 2 ,
+ GetTextWidth(String("DontCare", aTextEncoding)) + 2));
+ InsertDataColumn(
+ ITEMBROWSER_TYPECOL_ID ,
+ String("Type", aTextEncoding),
+ GetTextWidth(String(" Type_ ", aTextEncoding)) + 2);
+ InsertDataColumn(
+ ITEMBROWSER_NAMECOL_ID ,
+ String("Name", aTextEncoding),
+ 150);
+ InsertDataColumn(
+ ITEMBROWSER_VALUECOL_ID,
+ String("Value", aTextEncoding),
+ GetTextWidth(String("12345678901234567890", aTextEncoding)));
+ SetDataRowHeight(
+ GetTextHeight());
+
+ long nWdt=GetColumnWidth(ITEMBROWSER_WHICHCOL_ID)+
+ GetColumnWidth(ITEMBROWSER_STATECOL_ID)+
+ GetColumnWidth(ITEMBROWSER_TYPECOL_ID )+
+ GetColumnWidth(ITEMBROWSER_NAMECOL_ID )+
+ GetColumnWidth(ITEMBROWSER_VALUECOL_ID);
+
+ long nHgt=GetTitleHeight()+16*GetDataRowHeight();
+
+ SetOutputSizePixel(Size(nWdt,nHgt));
+}
+
+void _SdrItemBrowserControl::Clear()
+{
+ ULONG nAnz=aList.Count();
+ for (ULONG nNum=0; nNum<nAnz; nNum++) {
+ delete ImpGetEntry(nNum);
+ }
+ aList.Clear();
+ BrowseBox::Clear();
+}
+
+long __EXPORT _SdrItemBrowserControl::GetRowCount() const
+{
+ return aList.Count();
+}
+
+BOOL __EXPORT _SdrItemBrowserControl::SeekRow(long nRow)
+{
+ nAktPaintRow=nRow;
+ return TRUE;
+}
+
+String _SdrItemBrowserControl::GetCellText(long _nRow, USHORT _nColId) const
+{
+ String sRet;
+ if ( _nRow >= 0 && _nRow < (sal_Int32)aList.Count() )
+ {
+ ImpItemListRow* pEntry = ImpGetEntry(_nRow);
+ if ( pEntry )
+ {
+ if ( pEntry->bComment )
+ {
+ if (_nColId == ITEMBROWSER_NAMECOL_ID)
+ sRet = pEntry->aName;
+ }
+ else
+ {
+ rtl_TextEncoding aTextEncoding = gsl_getSystemTextEncoding();
+
+ sRet = XubString("???", aTextEncoding);
+ switch (_nColId)
+ {
+ case ITEMBROWSER_WHICHCOL_ID:
+ sRet = UniString::CreateFromInt32(pEntry->nWhichId); break;
+ case ITEMBROWSER_STATECOL_ID:
+ {
+ switch (pEntry->eState)
+ {
+ case SFX_ITEM_UNKNOWN : sRet=String("Uknown", aTextEncoding); break;
+ case SFX_ITEM_DISABLED: sRet=String("Disabled", aTextEncoding); break;
+ case SFX_ITEM_DONTCARE: sRet=String("DontCare", aTextEncoding); break;
+ case SFX_ITEM_SET : sRet=String("Set", aTextEncoding); break;
+ case SFX_ITEM_DEFAULT : sRet=String("Default", aTextEncoding); break;
+ } // switch
+ } break;
+ case ITEMBROWSER_TYPECOL_ID: sRet = pEntry->GetItemTypeStr(); break;
+ case ITEMBROWSER_NAMECOL_ID: sRet = pEntry->aName; break;
+ case ITEMBROWSER_VALUECOL_ID: sRet = pEntry->aValue; break;
+ } // switch
+ }
+ }
+ }
+ return sRet;
+}
+
+void __EXPORT _SdrItemBrowserControl::PaintField(OutputDevice& rDev, const Rectangle& rRect, USHORT nColumnId) const
+{
+ if (nAktPaintRow<0 || (ULONG)nAktPaintRow>=aList.Count()) {
+ return;
+ }
+ Rectangle aR(rRect);
+ aR.Bottom()++;
+ ImpItemListRow* pEntry=ImpGetEntry(nAktPaintRow);
+ if (pEntry->bComment)
+ {
+ if (nColumnId==ITEMBROWSER_NAMECOL_ID)
+ {
+ rDev.SetLineColor();
+ rDev.SetFillColor( Color( COL_LIGHTGRAY ) );
+ aR.Left()=0;
+ aR.Right()=rDev.GetOutputSize().Width();
+ rDev.DrawRect(aR);
+ rDev.DrawText(rRect.TopLeft(),pEntry->aName);
+ }
+ } else {
+ rDev.SetClipRegion(aR);
+ rDev.DrawText(aR.TopLeft(),GetCellText(nAktPaintRow,nColumnId));
+ rDev.SetClipRegion();
+ }
+}
+
+ULONG _SdrItemBrowserControl::GetCurrentPos() const
+{
+ ULONG nRet=CONTAINER_ENTRY_NOTFOUND;
+ if (GetSelectRowCount()==1) {
+ long nPos=((BrowseBox*)this)->FirstSelectedRow();
+ if (nPos>=0 && (ULONG)nPos<aList.Count()) {
+ nRet=(ULONG)nPos;
+ }
+ }
+ return nRet;
+}
+
+USHORT _SdrItemBrowserControl::GetCurrentWhich() const
+{
+ USHORT nRet=0;
+ ULONG nPos=GetCurrentPos();
+ if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
+ nRet=ImpGetEntry(nPos)->nWhichId;
+ }
+ return nRet;
+}
+
+void __EXPORT _SdrItemBrowserControl::DoubleClick(const BrowserMouseEvent&)
+{
+ ULONG nPos=GetCurrentPos();
+ if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
+ BegChangeEntry(nPos);
+ }
+}
+
+void __EXPORT _SdrItemBrowserControl::KeyInput(const KeyEvent& rKEvt)
+{
+ USHORT nKeyCode=rKEvt.GetKeyCode().GetCode()+rKEvt.GetKeyCode().GetModifier();
+ bool bAusgewertet = false;
+ ULONG nPos=GetCurrentPos();
+ if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
+ if (nKeyCode==KEY_RETURN) {
+ if (BegChangeEntry(nPos)) bAusgewertet = true;
+ } else if (nKeyCode==KEY_ESCAPE) {
+ // ...
+ } else if (rKEvt.GetKeyCode().GetModifier()==KEY_SHIFT+KEY_MOD1+KEY_MOD2) { // Strg
+ if (nKeyCode==KEY_SHIFT+KEY_MOD1+KEY_MOD2+KEY_W) {
+ bWhichesButNames=!bWhichesButNames;
+ SetDirty();
+ }
+ if (nKeyCode==KEY_SHIFT+KEY_MOD1+KEY_MOD2+KEY_I) {
+ bDontHideIneffectiveItems=!bDontHideIneffectiveItems;
+ SetDirty();
+ }
+ if (nKeyCode==KEY_SHIFT+KEY_MOD1+KEY_MOD2+KEY_S) {
+ bDontSortItems=!bDontSortItems;
+ SetDirty();
+ }
+ }
+ }
+ if (!bAusgewertet) BrowseBox::KeyInput(rKEvt);
+}
+
+void _SdrItemBrowserControl::SetDirty()
+{
+ aSetDirtyHdl.Call(this);
+}
+
+Rectangle _SdrItemBrowserControl::GetFieldCharacterBounds(sal_Int32 /*_nRow*/,sal_Int32 /*_nColumnPos*/,sal_Int32 /*nIndex*/)
+{
+ // no accessibility implementation required
+ return Rectangle();
+}
+
+sal_Int32 _SdrItemBrowserControl::GetFieldIndexAtPoint(sal_Int32 /*_nRow*/,sal_Int32 /*_nColumnPos*/,const Point& /*_rPoint*/)
+{
+ // no accessibility implementation required
+ return -1;
+}
+
+void __EXPORT _SdrItemBrowserControl::Select()
+{
+ EndChangeEntry();
+ BrowseBox::Select();
+ ImpSaveWhich();
+}
+
+void _SdrItemBrowserControl::ImpSaveWhich()
+{
+ USHORT nWh=GetCurrentWhich();
+ if (nWh!=0) {
+ long nPos=GetCurrentPos();
+ long nTop=GetTopRow();
+ long nBtm=GetTopRow()+GetVisibleRows()+1;
+ nLastWhich=nWh;
+ nLastWhichOfs=nPos-nTop;
+ if (nTop<0) nTop=0;
+ if (nBtm>=(long)aList.Count()) nBtm=aList.Count()-1;
+ nLastWhichOben=ImpGetEntry(nTop)->nWhichId;
+ nLastWhichUnten=ImpGetEntry(nBtm)->nWhichId;
+ }
+}
+
+void _SdrItemBrowserControl::ImpRestoreWhich()
+{
+ if (nLastWhich!=0) {
+ bool bFnd = false;
+ USHORT nBestMinWh=0,nBestMaxWh=0xFFFF; // not implemented yet
+ ULONG nBestMinPos=0,nBestMaxPos=0xFFFFFFFF; // not implemented yet
+ ULONG nAnz=aList.Count();
+ ULONG nNum;
+ for (nNum=0; nNum<nAnz && !bFnd; nNum++) {
+ ImpItemListRow* pEntry=ImpGetEntry(nNum);
+ if (!pEntry->bComment) {
+ USHORT nWh=pEntry->nWhichId;
+ if (nWh==nLastWhich) bFnd = true;
+ else if (nWh<nLastWhich && nWh>nBestMinWh) nBestMinPos=nNum;
+ else if (nWh>nLastWhich && nWh<nBestMaxWh) nBestMaxPos=nNum;
+ }
+ }
+ if (bFnd) {
+ long nPos=nNum-1;
+ long nWhichOfs=nPos-GetTopRow();
+ if (nWhichOfs!=nLastWhichOfs) {
+ ScrollRows(nWhichOfs-nLastWhichOfs);
+ }
+ GoToRow(nPos);
+ }
+ }
+}
+
+bool _SdrItemBrowserControl::BegChangeEntry(ULONG nPos)
+{
+ BrkChangeEntry();
+ bool bRet = false;
+ ImpItemListRow* pEntry=ImpGetEntry(nPos);
+ if (pEntry!=NULL && !pEntry->bComment) {
+ SetMode(MYBROWSEMODE & ~BROWSER_KEEPHIGHLIGHT);
+ pEditControl=new ImpItemEdit(&GetDataWindow(),this,0/*|WB_BORDER|WB_3DLOOK*/);
+ Rectangle aRect(GetFieldRectPixel(nPos,ITEMBROWSER_VALUECOL_ID,FALSE));
+ aRect.Left()+=2; // Kleiner Offset fuer's Edit, damit's pixelgenau stimmt
+ aRect.Right()--;
+ pEditControl->SetPosSizePixel(aRect.TopLeft(),aRect.GetSize());
+ pEditControl->SetText(pEntry->aValue);
+ pEditControl->SetBackground( Wallpaper(Color(COL_LIGHTGRAY)));
+ Font aFont(pEditControl->GetFont());
+ aFont.SetFillColor(Color(COL_LIGHTGRAY));
+ pEditControl->SetFont(aFont);
+ pEditControl->Show();
+ pEditControl->GrabFocus();
+ pEditControl->SetSelection(Selection(SELECTION_MIN,SELECTION_MAX));
+ Window* pParent=GetParent();
+ aWNamMerk=pParent->GetText();
+ XubString aNeuNam(aWNamMerk);
+ aNeuNam += sal_Unicode(' ');
+ aNeuNam += pEntry->GetItemTypeStr();
+ if (pEntry->bCanNum) {
+ aNeuNam.AppendAscii(": ");
+ aNeuNam += UniString::CreateFromInt32(pEntry->nMin);
+ aNeuNam.AppendAscii("..");
+ aNeuNam += UniString::CreateFromInt32(pEntry->nMax);
+ }
+ aNeuNam.AppendAscii(" - Type 'del' to reset to default.");
+ pParent->SetText(aNeuNam);
+ pAktChangeEntry=new ImpItemListRow(*pEntry);
+ bRet = true;
+ }
+ return bRet;
+}
+
+bool _SdrItemBrowserControl::EndChangeEntry()
+{
+ bool bRet = false;
+ if (pEditControl!=NULL) {
+ aEntryChangedHdl.Call(this);
+ delete pEditControl;
+ pEditControl=NULL;
+ delete pAktChangeEntry;
+ pAktChangeEntry=NULL;
+ Window* pParent=GetParent();
+ pParent->SetText(aWNamMerk);
+ SetMode(MYBROWSEMODE);
+ bRet = true;
+ }
+ return bRet;
+}
+
+void _SdrItemBrowserControl::BrkChangeEntry()
+{
+ if (pEditControl!=NULL) {
+ delete pEditControl;
+ pEditControl=NULL;
+ delete pAktChangeEntry;
+ pAktChangeEntry=NULL;
+ Window* pParent=GetParent();
+ pParent->SetText(aWNamMerk);
+ SetMode(MYBROWSEMODE);
+ }
+}
+
+void _SdrItemBrowserControl::ImpSetEntry(const ImpItemListRow& rEntry, ULONG nEntryNum)
+{
+ ImpItemListRow* pAktEntry=ImpGetEntry(nEntryNum);
+ if (pAktEntry==NULL) {
+ aList.Insert(new ImpItemListRow(rEntry),CONTAINER_APPEND);
+ RowInserted(nEntryNum);
+ } else if (*pAktEntry!=rEntry) {
+ bool bStateDiff=rEntry.eState!=pAktEntry->eState;
+ bool bValueDiff=!rEntry.aValue.Equals(pAktEntry->aValue);
+ bool bAllDiff = true;
+ if (bStateDiff || bValueDiff) {
+ // Checken, ob nur State und/oder Value geaendert
+ ImpItemListRow aTest(rEntry);
+ aTest.eState=pAktEntry->eState;
+ aTest.aValue=pAktEntry->aValue;
+ if (aTest==*pAktEntry) bAllDiff = false;
+ }
+ *pAktEntry=rEntry;
+ if (bAllDiff) {
+ RowModified(nEntryNum);
+ } else {
+ if (bStateDiff) RowModified(nEntryNum,ITEMBROWSER_STATECOL_ID);
+ if (bValueDiff) RowModified(nEntryNum,ITEMBROWSER_VALUECOL_ID);
+ }
+ }
+}
+
+bool ImpGetItem(const SfxItemSet& rSet, USHORT nWhich, const SfxPoolItem*& rpItem)
+{
+ SfxItemState eState=rSet.GetItemState(nWhich,TRUE,&rpItem);
+ if (eState==SFX_ITEM_DEFAULT) {
+ rpItem=&rSet.Get(nWhich);
+ }
+ return (eState==SFX_ITEM_DEFAULT || eState==SFX_ITEM_SET) && rpItem!=NULL;
+}
+
+bool IsItemIneffective(USHORT nWhich, const SfxItemSet* pSet, USHORT& rIndent)
+{
+ rIndent=0;
+ if (pSet==NULL) return FALSE;
+ const SfxPoolItem* pItem=NULL;
+ bool bRet = false;
+ switch (nWhich) {
+ case XATTR_LINEDASH :
+ case XATTR_LINEWIDTH :
+ case XATTR_LINECOLOR :
+ case XATTR_LINESTART :
+ case XATTR_LINEEND :
+ case XATTR_LINESTARTWIDTH :
+ case XATTR_LINEENDWIDTH :
+ case XATTR_LINESTARTCENTER :
+ case XATTR_LINEENDCENTER :
+ case XATTR_LINETRANSPARENCE : {
+ rIndent=1;
+ if (ImpGetItem(*pSet,XATTR_LINESTYLE,pItem)) {
+ XLineStyle eLineStyle=((const XLineStyleItem*)pItem)->GetValue();
+ if (eLineStyle==XLINE_NONE) return TRUE;
+ if (eLineStyle!=XLINE_DASH && nWhich==XATTR_LINEDASH) return TRUE;
+ }
+ if (nWhich==XATTR_LINESTART || nWhich==XATTR_LINESTARTCENTER) {
+ rIndent=2;
+ if (ImpGetItem(*pSet,XATTR_LINESTARTWIDTH,pItem)) {
+ INT32 nWdt=((const XLineStartWidthItem*)pItem)->GetValue();
+ if (nWdt==0) return TRUE;
+ }
+ }
+ if (nWhich==XATTR_LINEEND || nWhich==XATTR_LINEENDCENTER) {
+ rIndent=2;
+ if (ImpGetItem(*pSet,XATTR_LINEENDWIDTH,pItem)) {
+ INT32 nWdt=((const XLineEndWidthItem*)pItem)->GetValue();
+ if (nWdt==0) return TRUE;
+ }
+ }
+ } break;
+ case XATTR_FILLCOLOR : /*nur bei Style=Color*/
+ case XATTR_FILLGRADIENT : /*nur bei Style=Gradient*/
+ case XATTR_FILLHATCH : /*nur bei Style=Hatch*/
+ case XATTR_FILLTRANSPARENCE : /*nur bei Style=Color*/
+ case XATTR_GRADIENTSTEPCOUNT : /*nur bei Style=Gradient*/
+ case XATTR_FILLBACKGROUND : /*nur bei Style=Hatch*/
+ {
+ rIndent=1;
+ if (ImpGetItem(*pSet,XATTR_FILLSTYLE,pItem)) {
+ XFillStyle eFillStyle=((const XFillStyleItem*)pItem)->GetValue();
+ if (eFillStyle==XFILL_NONE) return TRUE;
+ // Transparenz z.Zt. nur fuer SolidFill
+ if (eFillStyle!=XFILL_SOLID && (nWhich==XATTR_FILLCOLOR || nWhich==XATTR_FILLTRANSPARENCE)) return TRUE;
+ if (eFillStyle!=XFILL_GRADIENT && (nWhich==XATTR_FILLGRADIENT || nWhich==XATTR_GRADIENTSTEPCOUNT)) return TRUE;
+ if (eFillStyle!=XFILL_HATCH && (nWhich==XATTR_FILLHATCH || nWhich==XATTR_FILLBACKGROUND)) return TRUE;
+ }
+ } break;
+ case XATTR_FILLBITMAP :
+ case XATTR_FILLBMP_TILE :
+ case XATTR_FILLBMP_POS : /* z.Zt. nur wenn TILE=TRUE */
+ case XATTR_FILLBMP_SIZEX : /* nur wenn nicht Stretch */
+ case XATTR_FILLBMP_SIZEY : /* nur wenn nicht Stretch */
+ case XATTR_FILLBMP_SIZELOG : /* nur wenn SIZELOG=FALSE zum ruecksetzen auf TRUE (alt) -> doch noch in Gebrauch */
+ case XATTR_FILLBMP_TILEOFFSETX : /* nur wenn TILE=TRUE */
+ case XATTR_FILLBMP_TILEOFFSETY : /* nur wenn TILE=TRUE */
+ case XATTR_FILLBMP_STRETCH : /* nur wenn TILE=FALSE */
+ case XATTR_FILLBMP_POSOFFSETX : /* nur wenn TILE=TRUE*/
+ case XATTR_FILLBMP_POSOFFSETY : { /* nur wenn TILE=TRUE*/
+ rIndent=1;
+ if (ImpGetItem(*pSet,XATTR_FILLSTYLE,pItem)) {
+ XFillStyle eFillStyle=((const XFillStyleItem*)pItem)->GetValue();
+ if (eFillStyle!=XFILL_BITMAP) return TRUE;
+ }
+ if (nWhich==XATTR_FILLBITMAP || nWhich==XATTR_FILLBMP_TILE) {
+ return FALSE; // immer anwaehlbar
+ }
+ bool bTileTRUE = false;
+ bool bTileFALSE = false;
+ bool bStretchTRUE = false;
+ bool bStretchFALSE = false;
+ if (ImpGetItem(*pSet,XATTR_FILLBMP_TILE,pItem)) {
+ bTileTRUE=((const XFillBmpTileItem*)pItem)->GetValue();
+ bTileFALSE=!bTileTRUE;
+ }
+ if (ImpGetItem(*pSet,XATTR_FILLBMP_STRETCH,pItem)) {
+ bStretchTRUE=((const XFillBmpStretchItem*)pItem)->GetValue();
+ bStretchFALSE=!bStretchTRUE;
+ }
+ // Stretch nicht anwaehlbar, wenn Tile=TRUE
+ if (nWhich==XATTR_FILLBMP_STRETCH) return bTileTRUE;
+ // und uebrig bleiben 7+1 Item (Unterattribute)
+ rIndent=2;
+ // Pos (enum) nicht anwaehlbar, wenn Tile=FALSE
+ if (nWhich==XATTR_FILLBMP_POS) return bTileFALSE;
+ // SizeXY nicht anwaehlbar bei Stretch=TRUE
+ if (nWhich==XATTR_FILLBMP_SIZEX || nWhich==XATTR_FILLBMP_SIZEY) {
+ return bTileFALSE && bStretchTRUE;
+ }
+ // 2 Items speziell fuer Tile
+ if (nWhich==XATTR_FILLBMP_POSOFFSETX || nWhich==XATTR_FILLBMP_POSOFFSETY) {
+ return bTileFALSE;
+ }
+ // Noch 2 Items speziell fuer Tile die sich jedoch gegenseitig ausschliessen
+ if (nWhich==XATTR_FILLBMP_TILEOFFSETX || nWhich==XATTR_FILLBMP_TILEOFFSETY) {
+ if (bTileFALSE) return TRUE;
+ USHORT nX=0,nY=0;
+ bool bX = false,bY = false;
+ if (ImpGetItem(*pSet,XATTR_FILLBMP_TILEOFFSETX,pItem)) {
+ nX=((const XFillBmpTileOffsetXItem*)pItem)->GetValue();
+ bX = true;
+ }
+ if (ImpGetItem(*pSet,XATTR_FILLBMP_TILEOFFSETY,pItem)) {
+ nY=((const XFillBmpTileOffsetYItem*)pItem)->GetValue();
+ bY = true;
+ }
+ if (nWhich==XATTR_FILLBMP_TILEOFFSETX) {
+ if (nX!=0 || !bX) return FALSE;
+ if (nY!=0) return TRUE;
+ } else {
+ if (nY!=0 || !bY) return FALSE;
+ if (nX!=0) return TRUE;
+ }
+ }
+ // SizeLog nicht anwaehlbar bei Stretch=TRUE
+ // und sonst auch nur wenn es auf SizeLog=FALSE gesetzt ist.
+ // -> wohl doch noch in Gebrauch
+ // (TRUE ist der statische PoolDefault)
+ if (nWhich==XATTR_FILLBMP_SIZELOG) {
+ if (bTileFALSE && bStretchTRUE) return TRUE;
+ }
+ } break;
+
+ case XATTR_FORMTXTADJUST :
+ case XATTR_FORMTXTDISTANCE :
+ case XATTR_FORMTXTSTART :
+ case XATTR_FORMTXTMIRROR :
+ case XATTR_FORMTXTOUTLINE :
+ case XATTR_FORMTXTSHADOW :
+ case XATTR_FORMTXTSHDWCOLOR :
+ case XATTR_FORMTXTSHDWXVAL :
+ case XATTR_FORMTXTSHDWYVAL :
+ case XATTR_FORMTXTSTDFORM :
+ case XATTR_FORMTXTHIDEFORM :
+ case XATTR_FORMTXTSHDWTRANSP: {
+ rIndent=1;
+ if (ImpGetItem(*pSet,XATTR_FORMTXTSTYLE,pItem)) {
+ XFormTextStyle eStyle=((const XFormTextStyleItem*)pItem)->GetValue();
+ if (eStyle==XFT_NONE) return TRUE;
+ }
+ if ((nWhich>=XATTR_FORMTXTSHDWCOLOR && nWhich<=XATTR_FORMTXTSHDWYVAL) || nWhich>=XATTR_FORMTXTSHDWTRANSP) {
+ rIndent=2;
+ if (ImpGetItem(*pSet,XATTR_FORMTXTSHADOW,pItem)) {
+ XFormTextShadow eShadow=((const XFormTextShadowItem*)pItem)->GetValue();
+ if (eShadow==XFTSHADOW_NONE) return TRUE;
+ }
+ }
+ } break;
+
+ case SDRATTR_SHADOWCOLOR :
+ case SDRATTR_SHADOWXDIST :
+ case SDRATTR_SHADOWYDIST :
+ case SDRATTR_SHADOWTRANSPARENCE:
+ case SDRATTR_SHADOW3D :
+ case SDRATTR_SHADOWPERSP : {
+ rIndent=1;
+ if (ImpGetItem(*pSet,SDRATTR_SHADOW,pItem)) {
+ bool bShadow=((const SdrShadowItem*)pItem)->GetValue();
+ if (!bShadow) return TRUE;
+ }
+ } break;
+
+ case SDRATTR_CAPTIONANGLE: {
+ rIndent=1;
+ if (ImpGetItem(*pSet,SDRATTR_CAPTIONFIXEDANGLE,pItem)) {
+ bool bFixed=((const SdrCaptionFixedAngleItem*)pItem)->GetValue();
+ if (!bFixed) return TRUE;
+ }
+ } break;
+ case SDRATTR_CAPTIONESCREL:
+ case SDRATTR_CAPTIONESCABS: {
+ rIndent=1;
+ if (ImpGetItem(*pSet,SDRATTR_CAPTIONESCISREL,pItem)) {
+ bool bRel=((const SdrCaptionEscIsRelItem*)pItem)->GetValue();
+ if (bRel && nWhich==SDRATTR_CAPTIONESCABS) return TRUE;
+ if (!bRel && nWhich==SDRATTR_CAPTIONESCREL) return TRUE;
+ }
+ } break;
+ case SDRATTR_CAPTIONLINELEN: {
+ rIndent=1;
+ if (ImpGetItem(*pSet,SDRATTR_CAPTIONFITLINELEN,pItem)) {
+ bool bFit=((const SdrCaptionFitLineLenItem*)pItem)->GetValue();
+ if (bFit) return TRUE;
+ }
+ } break;
+
+ case SDRATTR_TEXT_MINFRAMEHEIGHT:
+ case SDRATTR_TEXT_MAXFRAMEHEIGHT: {
+ rIndent=1;
+ if (ImpGetItem(*pSet,SDRATTR_TEXT_AUTOGROWHEIGHT,pItem)) {
+ bool bAutoGrow=((const SdrTextAutoGrowHeightItem*)pItem)->GetValue();
+ if (!bAutoGrow) return TRUE;
+ }
+ } break;
+ case SDRATTR_TEXT_MINFRAMEWIDTH:
+ case SDRATTR_TEXT_MAXFRAMEWIDTH: {
+ rIndent=1;
+ if (ImpGetItem(*pSet,SDRATTR_TEXT_AUTOGROWWIDTH,pItem)) {
+ bool bAutoGrow=((const SdrTextAutoGrowWidthItem*)pItem)->GetValue();
+ if (!bAutoGrow) return TRUE;
+ }
+ } break;
+ case SDRATTR_TEXT_VERTADJUST:
+ case SDRATTR_TEXT_HORZADJUST: {
+ if (ImpGetItem(*pSet,SDRATTR_TEXT_FITTOSIZE,pItem)) {
+ SdrFitToSizeType eFit=((const SdrTextFitToSizeTypeItem*)pItem)->GetValue();
+ if (eFit!=SDRTEXTFIT_NONE) return TRUE;
+ }
+ } break;
+
+ case SDRATTR_TEXT_ANIDIRECTION :
+ case SDRATTR_TEXT_ANISTARTINSIDE:
+ case SDRATTR_TEXT_ANISTOPINSIDE :
+ case SDRATTR_TEXT_ANICOUNT :
+ case SDRATTR_TEXT_ANIDELAY :
+ case SDRATTR_TEXT_ANIAMOUNT : {
+ rIndent=1;
+ if (ImpGetItem(*pSet,SDRATTR_TEXT_ANIKIND,pItem)) {
+ SdrTextAniKind eAniKind=((const SdrTextAniKindItem*)pItem)->GetValue();
+ if (eAniKind==SDRTEXTANI_NONE) return TRUE;
+ if (eAniKind==SDRTEXTANI_BLINK && (nWhich==SDRATTR_TEXT_ANIDIRECTION || nWhich==SDRATTR_TEXT_ANIAMOUNT)) return TRUE;
+ if (eAniKind==SDRTEXTANI_SLIDE && (nWhich==SDRATTR_TEXT_ANISTARTINSIDE || nWhich==SDRATTR_TEXT_ANISTOPINSIDE)) return TRUE;
+ }
+ } break;
+
+ case SDRATTR_EDGELINEDELTAANZ: return TRUE;
+ case SDRATTR_EDGELINE1DELTA:
+ case SDRATTR_EDGELINE2DELTA:
+ case SDRATTR_EDGELINE3DELTA: {
+ if (ImpGetItem(*pSet,SDRATTR_EDGEKIND,pItem)) {
+ SdrEdgeKind eKind=((const SdrEdgeKindItem*)pItem)->GetValue();
+ if (eKind==SDREDGE_THREELINES) {
+ if (nWhich>SDRATTR_EDGELINE2DELTA) return TRUE;
+ else return FALSE;
+ }
+ if (eKind!=SDREDGE_ORTHOLINES && eKind!=SDREDGE_BEZIER) return TRUE;
+ }
+ if (ImpGetItem(*pSet,SDRATTR_EDGELINEDELTAANZ,pItem)) {
+ UINT16 nAnz=((const SdrEdgeLineDeltaAnzItem*)pItem)->GetValue();
+ if (nAnz==0) return TRUE;
+ if (nAnz==1 && nWhich>SDRATTR_EDGELINE1DELTA) return TRUE;
+ if (nAnz==2 && nWhich>SDRATTR_EDGELINE2DELTA) return TRUE;
+ if (nAnz==3 && nWhich>SDRATTR_EDGELINE3DELTA) return TRUE;
+ }
+ } break;
+
+ case SDRATTR_CIRCSTARTANGLE:
+ case SDRATTR_CIRCENDANGLE : {
+ rIndent=1;
+ if (ImpGetItem(*pSet,SDRATTR_CIRCKIND,pItem)) {
+ SdrCircKind eKind=((const SdrCircKindItem*)pItem)->GetValue();
+ if (eKind==SDRCIRC_FULL) return TRUE;
+ }
+ } break;
+ } // switch
+ return bRet;
+}
+
+USHORT ImpSortWhich(USHORT nWhich)
+{
+ switch (nWhich) {
+ // Line
+ case XATTR_LINESTART : nWhich=XATTR_LINETRANSPARENCE ; break;
+ case XATTR_LINEEND : nWhich=XATTR_LINESTARTWIDTH ; break;
+ case XATTR_LINESTARTWIDTH : nWhich=XATTR_LINESTART ; break;
+ case XATTR_LINEENDWIDTH : nWhich=XATTR_LINESTARTCENTER ; break;
+ case XATTR_LINESTARTCENTER : nWhich=XATTR_LINEENDWIDTH ; break;
+ case XATTR_LINEENDCENTER : nWhich=XATTR_LINEEND ; break;
+ case XATTR_LINETRANSPARENCE : nWhich=XATTR_LINEENDCENTER ; break;
+
+ // Fill
+ case XATTR_FILLBMP_POS : nWhich=XATTR_FILLBMP_STRETCH ; break;
+ case XATTR_FILLBMP_SIZEX : nWhich=XATTR_FILLBMP_POS ; break;
+ case XATTR_FILLBMP_SIZEY : nWhich=XATTR_FILLBMP_SIZEX ; break;
+ case XATTR_FILLBMP_SIZELOG : nWhich=XATTR_FILLBMP_SIZEY ; break;
+ case XATTR_FILLBMP_TILEOFFSETX : nWhich=XATTR_FILLBMP_SIZELOG ; break;
+ case XATTR_FILLBMP_TILEOFFSETY : nWhich=XATTR_FILLBMP_TILEOFFSETX ; break;
+ case XATTR_FILLBMP_STRETCH : nWhich=XATTR_FILLBMP_TILEOFFSETY ; break;
+
+ // Fontwork
+ case XATTR_FORMTXTSHADOW : nWhich=XATTR_FORMTXTSTDFORM ; break;
+ case XATTR_FORMTXTSHDWCOLOR : nWhich=XATTR_FORMTXTHIDEFORM ; break;
+ case XATTR_FORMTXTSHDWXVAL : nWhich=XATTR_FORMTXTSHADOW ; break;
+ case XATTR_FORMTXTSHDWYVAL : nWhich=XATTR_FORMTXTSHDWCOLOR ; break;
+ case XATTR_FORMTXTSTDFORM : nWhich=XATTR_FORMTXTSHDWXVAL ; break;
+ case XATTR_FORMTXTHIDEFORM : nWhich=XATTR_FORMTXTSHDWYVAL ; break;
+
+ // Misc
+ case SDRATTR_TEXT_MINFRAMEHEIGHT: nWhich=SDRATTR_TEXT_FITTOSIZE ; break;
+ case SDRATTR_TEXT_AUTOGROWHEIGHT: nWhich=SDRATTR_TEXT_LEFTDIST ; break;
+ case SDRATTR_TEXT_FITTOSIZE : nWhich=SDRATTR_TEXT_RIGHTDIST ; break;
+ case SDRATTR_TEXT_LEFTDIST : nWhich=SDRATTR_TEXT_UPPERDIST ; break;
+ case SDRATTR_TEXT_RIGHTDIST : nWhich=SDRATTR_TEXT_LOWERDIST ; break;
+ case SDRATTR_TEXT_UPPERDIST : nWhich=SDRATTR_TEXT_AUTOGROWWIDTH ; break;
+ case SDRATTR_TEXT_LOWERDIST : nWhich=SDRATTR_TEXT_MINFRAMEWIDTH ; break;
+ case SDRATTR_TEXT_VERTADJUST : nWhich=SDRATTR_TEXT_MAXFRAMEWIDTH ; break;
+ case SDRATTR_TEXT_MAXFRAMEHEIGHT: nWhich=SDRATTR_TEXT_AUTOGROWHEIGHT; break;
+ case SDRATTR_TEXT_MINFRAMEWIDTH : nWhich=SDRATTR_TEXT_MINFRAMEHEIGHT; break;
+ case SDRATTR_TEXT_MAXFRAMEWIDTH : nWhich=SDRATTR_TEXT_MAXFRAMEHEIGHT; break;
+ case SDRATTR_TEXT_AUTOGROWWIDTH : nWhich=SDRATTR_TEXT_HORZADJUST ; break;
+ case SDRATTR_TEXT_HORZADJUST : nWhich=SDRATTR_TEXT_VERTADJUST ; break;
+ } // switch
+ return nWhich;
+}
+
+#define INSERTCOMMENT(nStartId,nEndId,aStr) \
+ { if (nWhich0<nStartId && nWhich>=nStartId && nWhich<=nEndId) aCommentStr=aStr; }
+
+void _SdrItemBrowserControl::SetAttributes(const SfxItemSet* pSet, const SfxItemSet* p2ndSet)
+{
+ SetMode(MYBROWSEMODE & ~BROWSER_KEEPHIGHLIGHT);
+ if (pSet!=NULL) {
+ rtl_TextEncoding aTextEncoding = gsl_getSystemTextEncoding();
+ USHORT nEntryNum=0;
+ SfxWhichIter aIter(*pSet);
+ const SfxItemPool* pPool=pSet->GetPool();
+ USHORT nWhich0=0;
+ USHORT nWhich=aIter.FirstWhich();
+ while (nWhich!=0) {
+ // Nun erstmal etwas umsortieren
+ // Geht nur, solange keine InvalidItems, d.h. keine Luecken
+ // an dieser Stelle im Set sind
+ if (!bDontSortItems) nWhich=ImpSortWhich(nWhich);
+ SfxItemState eState=pSet->GetItemState(nWhich);
+ if (p2ndSet!=NULL) {
+ SfxItemState e2ndState=p2ndSet->GetItemState(nWhich);
+ if (eState==SFX_ITEM_DEFAULT) eState=SFX_ITEM_DISABLED;
+ else if (e2ndState==SFX_ITEM_DEFAULT) eState=SFX_ITEM_DEFAULT;
+ }
+ if (eState!=SFX_ITEM_DISABLED) {
+ const SfxPoolItem& rItem=pSet->Get(nWhich);
+ USHORT nIndent=0;
+ if (!HAS_BASE(SfxVoidItem,&rItem) && !HAS_BASE(SfxSetItem,&rItem) && (!IsItemIneffective(nWhich,pSet,nIndent) || bDontHideIneffectiveItems)) {
+ XubString aCommentStr;
+
+ INSERTCOMMENT(XATTR_LINE_FIRST,XATTR_LINE_LAST,String("L I N I E", aTextEncoding));
+ INSERTCOMMENT(XATTR_FILL_FIRST,XATTR_FILL_LAST,String("F L Ä C H E", aTextEncoding));
+ INSERTCOMMENT(XATTR_TEXT_FIRST,XATTR_TEXT_LAST,String("F O N T W O R K", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_SHADOW_FIRST,SDRATTR_SHADOW_LAST,String("S C H A T T E N", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_CAPTION_FIRST,SDRATTR_CAPTION_LAST,String("L E G E N D E", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_MISC_FIRST,SDRATTR_MISC_LAST,String("V E R S C H I E D E N E S", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_EDGE_FIRST,SDRATTR_EDGE_LAST,String("V E R B I N D E R", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_MEASURE_FIRST,SDRATTR_MEASURE_LAST,String("B E M A S S U N G", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_CIRC_FIRST,SDRATTR_CIRC_LAST,String("K R E I S", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_NOTPERSIST_FIRST,SDRATTR_NOTPERSIST_LAST,String("N O T P E R S I S T", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_MOVEX,SDRATTR_VERTSHEARONE,String("Transformationen auf alle Objekte einzeln", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_RESIZEXALL,SDRATTR_VERTSHEARALL,String("Transformationen auf alle Objekte gemeinsam", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_TRANSFORMREF1X,SDRATTR_TRANSFORMREF2Y,String("View-Referenzpunkte", aTextEncoding));
+ INSERTCOMMENT(SDRATTR_GRAF_FIRST,SDRATTR_GRAF_LAST,String("G R A F I K", aTextEncoding));
+ INSERTCOMMENT(EE_ITEMS_START,EE_ITEMS_END,String("E D I T E N G I N E", aTextEncoding));
+ INSERTCOMMENT(EE_ITEMS_END+1,EE_ITEMS_END+1,String("... by Joe Merten, JME Engineering Berlin ...", aTextEncoding));
+
+ if(aCommentStr.Len())
+ {
+ ImpItemListRow aEntry;
+ aEntry.bComment = true;
+ aEntry.aName=aCommentStr;
+ ImpSetEntry(aEntry,nEntryNum);
+ nEntryNum++;
+ }
+ nWhich0=nWhich;
+ ImpItemListRow aEntry;
+ SdrItemPool::TakeItemName(nWhich, aEntry.aName);
+ nIndent*=2;
+
+ while(nIndent > 0)
+ {
+ aEntry.aName.Insert(sal_Unicode(' '), 0);
+ nIndent--;
+ }
+
+ aEntry.eState=eState;
+ aEntry.nWhichId=nWhich;
+ if (!IsInvalidItem(&rItem)) {
+ aEntry.pType=rItem.Type();
+ aEntry.nMax=0x7FFFFFFF;
+ aEntry.nMin=-aEntry.nMax;
+ aEntry.nVal=-4711;
+ if (HAS_BASE(SfxByteItem ,&rItem)) aEntry.eItemType=ITEM_BYTE;
+ else if (HAS_BASE(SfxInt16Item ,&rItem)) aEntry.eItemType=ITEM_INT16;
+ else if (HAS_BASE(SfxUInt16Item ,&rItem)) aEntry.eItemType=ITEM_UINT16;
+ else if (HAS_BASE(SfxInt32Item ,&rItem)) aEntry.eItemType=ITEM_INT32;
+ else if (HAS_BASE(SfxUInt32Item ,&rItem)) aEntry.eItemType=ITEM_UINT32;
+ else if (HAS_BASE(SfxEnumItemInterface,&rItem)) aEntry.eItemType=ITEM_ENUM;
+ else if (HAS_BASE(SfxBoolItem ,&rItem)) aEntry.eItemType=ITEM_BOOL;
+ else if (HAS_BASE(SfxFlagItem ,&rItem)) aEntry.eItemType=ITEM_FLAG;
+ else if (HAS_BASE(XColorItem ,&rItem)) aEntry.eItemType=ITEM_XCOLOR;
+ else if (HAS_BASE(SfxStringItem ,&rItem)) aEntry.eItemType=ITEM_STRING;
+ else if (HAS_BASE(SfxPointItem ,&rItem)) aEntry.eItemType=ITEM_POINT;
+ else if (HAS_BASE(SfxRectangleItem,&rItem)) aEntry.eItemType=ITEM_RECT;
+ else if (HAS_BASE(SfxRangeItem ,&rItem)) aEntry.eItemType=ITEM_RANGE;
+ else if (HAS_BASE(SdrFractionItem ,&rItem)) aEntry.eItemType=ITEM_FRACTION;
+ else if (HAS_BASE(SvxColorItem ,&rItem)) aEntry.eItemType=ITEM_COLOR;
+ else if (HAS_BASE(SvxFontItem ,&rItem)) aEntry.eItemType=ITEM_FONT;
+ else if (HAS_BASE(SvxFontHeightItem,&rItem))aEntry.eItemType=ITEM_FONTHEIGHT;
+ else if (HAS_BASE(SvxCharScaleWidthItem,&rItem)) aEntry.eItemType=ITEM_FONTWIDTH;
+ else if (HAS_BASE(SvxFieldItem ,&rItem)) aEntry.eItemType=ITEM_FIELD;
+ switch (aEntry.eItemType) {
+ case ITEM_BYTE : aEntry.bIsNum = true; aEntry.nVal=((SfxByteItem &)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=255; break;
+ case ITEM_INT16 : aEntry.bIsNum = true; aEntry.nVal=((SfxInt16Item &)rItem).GetValue(); aEntry.nMin=-32767; aEntry.nMax=32767; break;
+ case ITEM_UINT16 : aEntry.bIsNum = true; aEntry.nVal=((SfxUInt16Item&)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=65535; break;
+ case ITEM_INT32 : aEntry.bIsNum = true; aEntry.nVal=((SfxInt32Item &)rItem).GetValue(); break;
+ case ITEM_UINT32 : aEntry.bIsNum = true; aEntry.nVal=((SfxUInt32Item&)rItem).GetValue(); aEntry.nMin=0; /*aEntry.nMax=0xFF...*/;break;
+ case ITEM_ENUM : aEntry.bCanNum = true; aEntry.nVal=((SfxEnumItemInterface&)rItem).GetEnumValue(); aEntry.nMin=0; aEntry.nMax=((SfxEnumItemInterface&)rItem).GetValueCount()-1; break;
+ case ITEM_BOOL : aEntry.bCanNum = true; aEntry.nVal=((SfxBoolItem &)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=1; break;
+ case ITEM_FLAG : aEntry.bCanNum = true; aEntry.nVal=((SfxFlagItem &)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=0xFFFF; break;
+ case ITEM_FONTHEIGHT: aEntry.bCanNum = true; aEntry.nVal=((SvxFontHeightItem&)rItem).GetHeight(); aEntry.nMin=0; break;
+ case ITEM_FONTWIDTH : aEntry.bCanNum = true; aEntry.nVal=((SvxCharScaleWidthItem&)rItem).GetValue(); aEntry.nMin=0; aEntry.nMax=0xFFFF;break;
+ default: break;
+ } // switch
+ if (aEntry.bIsNum) aEntry.bCanNum = true;
+ bool bGetPres = true;
+ if (bGetPres) {
+ rItem.GetPresentation(SFX_ITEM_PRESENTATION_NAMELESS,
+ pPool->GetMetric(nWhich),
+ SFX_MAPUNIT_MM,aEntry.aValue);
+ if (aEntry.bCanNum) {
+ aEntry.aValue.InsertAscii(": ",0);
+ aEntry.aValue.Insert(UniString::CreateFromInt32(aEntry.nVal),0);
+ }
+ } else {
+ if (aEntry.eItemType==ITEM_BOOL) aEntry.aValue.AppendAscii(aEntry.nVal!=0 ? "True" : "False");
+ else if (aEntry.bCanNum) aEntry.aValue = UniString::CreateFromInt32(aEntry.nVal);
+ else if (aEntry.eItemType==ITEM_STRING) aEntry.aValue=((SfxStringItem&)rItem).GetValue();
+ else if (aEntry.eItemType==ITEM_ENUM && nWhich!=EE_CHAR_WEIGHT) aEntry.aValue=((SfxEnumItemInterface&)rItem).GetValueTextByPos((BOOL)aEntry.nVal);
+ else aEntry.aValue = String("GPF", aTextEncoding);
+ }
+ } else {
+ aEntry.aValue = String("InvalidItem", aTextEncoding);
+ }
+ ImpSetEntry(aEntry,nEntryNum);
+ nEntryNum++;
+ }
+ }
+ nWhich=aIter.NextWhich();
+ } // while
+
+ if (aList.Count()>nEntryNum) { // evtl. noch zuviele Eintraege
+ ULONG nTooMuch=aList.Count()-nEntryNum;
+ for (ULONG nNum=0; nNum<nTooMuch; nNum++) {
+ delete ImpGetEntry(nEntryNum);
+ aList.Remove(nEntryNum);
+ }
+ RowRemoved(nEntryNum,nTooMuch);
+ }
+ } else {
+ Clear(); // wenn pSet==NULL
+ }
+ ImpRestoreWhich();
+ SetMode(MYBROWSEMODE);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+_SdrItemBrowserWindow::_SdrItemBrowserWindow(Window* pParent, WinBits nBits):
+ FloatingWindow(pParent,nBits),
+ aBrowse(this)
+{
+ SetOutputSizePixel(aBrowse.GetSizePixel());
+ SetText(String("Joe's ItemBrowser", gsl_getSystemTextEncoding()));
+ aBrowse.Show();
+}
+
+__EXPORT _SdrItemBrowserWindow::~_SdrItemBrowserWindow()
+{
+}
+
+void __EXPORT _SdrItemBrowserWindow::Resize()
+{
+ aBrowse.SetSizePixel(GetOutputSizePixel());
+}
+
+void __EXPORT _SdrItemBrowserWindow::GetFocus()
+{
+ aBrowse.GrabFocus();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrItemBrowser::SdrItemBrowser(SdrView& rView):
+ _SdrItemBrowserWindow(ImpGetViewWin(rView)),
+ pView(&rView),
+ bDirty(FALSE)
+{
+ aIdleTimer.SetTimeoutHdl(LINK(this,SdrItemBrowser,IdleHdl));
+ GetBrowserControl().SetEntryChangedHdl(LINK(this,SdrItemBrowser,ChangedHdl));
+ GetBrowserControl().SetSetDirtyHdl(LINK(this,SdrItemBrowser,SetDirtyHdl));
+ SetDirty();
+}
+
+Window* SdrItemBrowser::ImpGetViewWin(SdrView& rView)
+{
+ const sal_uInt32 nWinCount(rView.PaintWindowCount());
+
+ for(sal_uInt32 a(0L); a < nWinCount; a++)
+ {
+ SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
+
+ if(OUTDEV_WINDOW == pCandidate->GetOutputDevice().GetOutDevType())
+ {
+ return (Window*)(&pCandidate->GetOutputDevice());
+ }
+ }
+
+ return 0L;
+}
+
+void SdrItemBrowser::ForceParent()
+{
+ Window* pWin=ImpGetViewWin(*pView);
+ if (pWin!=NULL) SetParent(pWin);
+}
+
+void SdrItemBrowser::SetDirty()
+{
+ if (!bDirty) {
+ bDirty = true;
+ aIdleTimer.SetTimeout(1);
+ aIdleTimer.Start();
+ }
+}
+
+void SdrItemBrowser::Undirty()
+{
+ aIdleTimer.Stop();
+ bDirty = FALSE;
+
+// SfxItemSet aSet(pView->GetAttributes());
+ SfxItemSet aSet(pView->GetModel()->GetItemPool());
+ pView->GetAttributes(aSet);
+
+ if(pView->AreObjectsMarked())
+ {
+ // SfxItemSet a2ndSet(pView->GetAttributes(TRUE));
+ SfxItemSet a2ndSet(pView->GetModel()->GetItemPool());
+ pView->GetAttributes(a2ndSet, TRUE);
+
+ SetAttributes(&aSet,&a2ndSet);
+ }
+ else
+ {
+ SetAttributes(&aSet);
+ }
+}
+
+IMPL_LINK(SdrItemBrowser,IdleHdl,Timer*,EMPTYARG)
+{
+ Undirty();
+ return 0;
+}
+
+IMPL_LINK(SdrItemBrowser,ChangedHdl,_SdrItemBrowserControl*,pBrowse)
+{
+ const ImpItemListRow* pEntry=pBrowse->GetAktChangeEntry();
+ if (pEntry!=NULL)
+ {
+// SfxItemSet aSet(pView->GetAttributes());
+ SfxItemSet aSet(pView->GetModel()->GetItemPool());
+ pView->GetAttributes(aSet);
+
+ SfxItemSet aNewSet(*aSet.GetPool(),pEntry->nWhichId,pEntry->nWhichId);
+ XubString aNewText(pBrowse->GetNewEntryValue());
+ BOOL bDel( aNewText.EqualsAscii("del")
+ || aNewText.EqualsAscii("Del")
+ || aNewText.EqualsAscii("DEL")
+ || aNewText.EqualsAscii("default")
+ || aNewText.EqualsAscii("Default")
+ || aNewText.EqualsAscii("DEFAULT"));
+
+ if (!bDel) {
+ SfxPoolItem* pNewItem=aSet.Get(pEntry->nWhichId).Clone();
+ long nLongVal=0;
+ nLongVal = aNewText.ToInt32();
+ if (pEntry->bCanNum) {
+ if (nLongVal>pEntry->nMax) nLongVal=pEntry->nMax;
+ if (nLongVal<pEntry->nMin) nLongVal=pEntry->nMin;
+ }
+ bool bPair = false;
+ bool bPairX = true;
+ bool bPairY = false;
+ USHORT nSepLen=1;
+ long nLongX = aNewText.ToInt32();
+ long nLongY=0;
+ xub_StrLen nPos = aNewText.Search(sal_Unicode('/'));
+ if (nPos==STRING_NOTFOUND) nPos=aNewText.Search(sal_Unicode(':'));
+ if (nPos==STRING_NOTFOUND) nPos=aNewText.Search(sal_Unicode(' '));
+ if (nPos==STRING_NOTFOUND) { nPos=aNewText.SearchAscii(".."); if (nPos!=STRING_NOTFOUND) nSepLen=2; }
+ if (nPos!=STRING_NOTFOUND) {
+ bPair = true;
+ bPairX=nPos>0;
+ XubString s(aNewText);
+ s.Erase(0,nPos+nSepLen);
+ bPairY = (BOOL)aNewText.Len();
+ nLongY = s.ToInt32();
+ }
+ switch (pEntry->eItemType) {
+ case ITEM_BYTE : ((SfxByteItem *)pNewItem)->SetValue((BYTE )nLongVal); break;
+ case ITEM_INT16 : ((SfxInt16Item *)pNewItem)->SetValue((INT16 )nLongVal); break;
+ case ITEM_UINT16: ((SfxUInt16Item*)pNewItem)->SetValue((UINT16)nLongVal); break;
+ case ITEM_INT32: {
+ if(HAS_BASE(SdrAngleItem, pNewItem))
+ {
+ aNewText.SearchAndReplace(sal_Unicode(','), sal_Unicode('.'));
+ double nVal = aNewText.ToFloat();
+ nLongVal = (long)(nVal * 100 + 0.5);
+ }
+ ((SfxInt32Item *)pNewItem)->SetValue((INT32)nLongVal);
+ } break;
+ case ITEM_UINT32: ((SfxUInt32Item*)pNewItem)->SetValue(aNewText.ToInt32()); break;
+ case ITEM_ENUM : ((SfxEnumItemInterface*)pNewItem)->SetEnumValue((USHORT)nLongVal); break;
+ case ITEM_BOOL: {
+ aNewText.ToUpperAscii();
+ if (aNewText.EqualsAscii("TRUE")) nLongVal=1;
+ if (aNewText.EqualsAscii("JA")) nLongVal=1;
+ if (aNewText.EqualsAscii("AN")) nLongVal=1;
+ if (aNewText.EqualsAscii("EIN")) nLongVal=1;
+ if (aNewText.EqualsAscii("ON")) nLongVal=1;
+ if (aNewText.EqualsAscii("YES")) nLongVal=1;
+ ((SfxBoolItem*)pNewItem)->SetValue((BOOL)nLongVal);
+ } break;
+ case ITEM_FLAG : ((SfxFlagItem *)pNewItem)->SetValue((USHORT)nLongVal); break;
+ case ITEM_STRING: ((SfxStringItem*)pNewItem)->SetValue(aNewText); break;
+ case ITEM_POINT : ((SfxPointItem*)pNewItem)->SetValue(Point(nLongX,nLongY)); break;
+ case ITEM_RECT : break;
+ case ITEM_RANGE : {
+ ((SfxRangeItem*)pNewItem)->From()=(USHORT)nLongX;
+ ((SfxRangeItem*)pNewItem)->From()=(USHORT)nLongY;
+ } break;
+ case ITEM_LRANGE : {
+ } break;
+ case ITEM_FRACTION: {
+ if (!bPairX) nLongX=1;
+ if (!bPairY) nLongY=1;
+ ((SdrFractionItem*)pNewItem)->SetValue(Fraction(nLongX,nLongY));
+ } break;
+ case ITEM_XCOLOR: break;
+ case ITEM_COLOR: break;
+ case ITEM_FONT: {
+ ((SvxFontItem*)pNewItem)->GetFamily()=FAMILY_DONTKNOW;
+ ((SvxFontItem*)pNewItem)->GetFamilyName()=aNewText;
+ ((SvxFontItem*)pNewItem)->GetStyleName().Erase();
+ } break;
+ case ITEM_FONTHEIGHT: {
+ ULONG nHgt=0;
+ USHORT nProp=100;
+ if (aNewText.Search(sal_Unicode('%'))!=STRING_NOTFOUND) {
+ nProp=(USHORT)nLongVal;
+ } else {
+ nHgt=nLongVal;
+ }
+ ((SvxFontHeightItem*)pNewItem)->SetHeight(nHgt,nProp);
+ } break;
+ case ITEM_FONTWIDTH: {
+ USHORT nProp=100;
+ if (aNewText.Search(sal_Unicode('%'))!=STRING_NOTFOUND) {
+ nProp=(USHORT)nLongVal;
+ }
+ ((SvxCharScaleWidthItem*)pNewItem)->SetValue(nProp);
+ } break;
+ case ITEM_FIELD: break;
+ default: break;
+ } // switch
+ aNewSet.Put(*pNewItem);
+ delete pNewItem;
+ }
+ pView->SetAttributes(aNewSet,bDel);
+ }
+ return 0;
+}
+
+IMPL_LINK(SdrItemBrowser,SetDirtyHdl,_SdrItemBrowserControl*,EMPTYARG)
+{
+ SetDirty();
+ return 0;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svditer.cxx b/svx/source/svdraw/svditer.cxx
new file mode 100644
index 000000000000..5b1baa75ecfe
--- /dev/null
+++ b/svx/source/svdraw/svditer.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "svditer.hxx"
+#include <svx/svdpage.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdmark.hxx>
+
+// #99190#
+#include <svx/scene3d.hxx>
+
+SdrObjListIter::SdrObjListIter(const SdrObjList& rObjList, SdrIterMode eMode, BOOL bReverse)
+: maObjList(1024, 64, 64),
+ mnIndex(0L),
+ mbReverse(bReverse)
+{
+ ImpProcessObjectList(rObjList, eMode, TRUE);
+ Reset();
+}
+
+SdrObjListIter::SdrObjListIter(const SdrObjList& rObjList, BOOL bUseZOrder, SdrIterMode eMode, BOOL bReverse)
+: maObjList(1024, 64, 64),
+ mnIndex(0L),
+ mbReverse(bReverse)
+{
+ ImpProcessObjectList(rObjList, eMode, bUseZOrder);
+ Reset();
+}
+
+SdrObjListIter::SdrObjListIter( const SdrObject& rObj, SdrIterMode eMode, BOOL bReverse )
+: maObjList(1024, 64, 64),
+ mnIndex(0L),
+ mbReverse(bReverse)
+{
+ if ( rObj.ISA( SdrObjGroup ) )
+ ImpProcessObjectList(*rObj.GetSubList(), eMode, TRUE);
+ else
+ maObjList.Insert( (void*)&rObj, LIST_APPEND );
+ Reset();
+}
+
+SdrObjListIter::SdrObjListIter( const SdrMarkList& rMarkList, SdrIterMode eMode, BOOL bReverse )
+: maObjList(1024, 64, 64),
+ mnIndex(0L),
+ mbReverse(bReverse)
+{
+ ImpProcessMarkList(rMarkList, eMode);
+ Reset();
+}
+
+void SdrObjListIter::ImpProcessObjectList(const SdrObjList& rObjList, SdrIterMode eMode, BOOL bUseZOrder)
+{
+ for( ULONG nIdx = 0, nCount = rObjList.GetObjCount(); nIdx < nCount; ++nIdx )
+ {
+ SdrObject* pObj = bUseZOrder ?
+ rObjList.GetObj( nIdx ) : rObjList.GetObjectForNavigationPosition( nIdx );
+ OSL_ASSERT( pObj != 0 );
+ if( pObj )
+ ImpProcessObj( pObj, eMode, bUseZOrder );
+ }
+}
+
+void SdrObjListIter::ImpProcessMarkList( const SdrMarkList& rMarkList, SdrIterMode eMode )
+{
+ for( ULONG nIdx = 0, nCount = rMarkList.GetMarkCount(); nIdx < nCount; ++nIdx )
+ if( SdrObject* pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj() )
+ ImpProcessObj( pObj, eMode, FALSE );
+}
+
+void SdrObjListIter::ImpProcessObj(SdrObject* pObj, SdrIterMode eMode, BOOL bUseZOrder)
+{
+ bool bIsGroup = pObj->IsGroupObject();
+ // #99190# 3D objects are no group objects, IsGroupObject()
+ // only tests if pSub is not null ptr :-(
+ if( bIsGroup && pObj->ISA( E3dObject ) && !pObj->ISA( E3dScene ) )
+ bIsGroup = false;
+
+ if( !bIsGroup || (eMode != IM_DEEPNOGROUPS) )
+ maObjList.Insert( pObj, LIST_APPEND );
+
+ if( bIsGroup && (eMode != IM_FLAT) )
+ ImpProcessObjectList( *pObj->GetSubList(), eMode, bUseZOrder );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svditext.hxx b/svx/source/svdraw/svditext.hxx
new file mode 100644
index 000000000000..a2d3169aeb3c
--- /dev/null
+++ b/svx/source/svdraw/svditext.hxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVDITEXT_HXX
+#define _SVDITEXT_HXX
+
+// SvxItem-Mapping. Wird benoetigt um die SvxItem-Header erfolgreich zu includen
+
+#include <editeng/editdata.hxx>
+
+
+#endif // _SVDITEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdlayer.cxx b/svx/source/svdraw/svdlayer.cxx
new file mode 100644
index 000000000000..e7a2802586ad
--- /dev/null
+++ b/svx/source/svdraw/svdlayer.cxx
@@ -0,0 +1,460 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <svx/svdlayer.hxx>
+#include <svx/svdmodel.hxx> // fuer Broadcasting
+#include "svdglob.hxx" // StringCache
+#include "svdstr.hrc" // Namen aus der Resource
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SetOfByte
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_Bool SetOfByte::IsEmpty() const
+{
+ for(sal_uInt16 i(0); i < 32; i++)
+ {
+ if(aData[i] != 0)
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+sal_Bool SetOfByte::IsFull() const
+{
+ for(sal_uInt16 i(0); i < 32; i++)
+ {
+ if(aData[i] != 0xFF)
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+sal_uInt16 SetOfByte::GetSetCount() const
+{
+ sal_uInt16 nRet(0);
+
+ for(sal_uInt16 i(0); i < 32; i++)
+ {
+ sal_uInt8 a(aData[i]);
+
+ if(a != 0)
+ {
+ if(a & 0x80) nRet++;
+ if(a & 0x40) nRet++;
+ if(a & 0x20) nRet++;
+ if(a & 0x10) nRet++;
+ if(a & 0x08) nRet++;
+ if(a & 0x04) nRet++;
+ if(a & 0x02) nRet++;
+ if(a & 0x01) nRet++;
+ }
+ }
+
+ return nRet;
+}
+
+sal_uInt8 SetOfByte::GetSetBit(sal_uInt16 nNum) const
+{
+ nNum++;
+ sal_uInt16 i(0), j(0);
+ sal_uInt16 nRet(0);
+
+ while(j < nNum && i < 256)
+ {
+ if(IsSet(sal_uInt8(i)))
+ j++;
+ i++;
+ }
+
+ if(j == nNum)
+ nRet = i - 1;
+
+ return sal_uInt8(nRet);
+}
+
+sal_uInt16 SetOfByte::GetClearCount() const
+{
+ return sal_uInt16(256 - GetSetCount());
+}
+
+sal_uInt8 SetOfByte::GetClearBit(sal_uInt16 nNum) const
+{
+ nNum++;
+ sal_uInt16 i(0), j(0);
+ sal_uInt16 nRet(0);
+
+ while(j < nNum && i < 256)
+ {
+ if(!IsSet(sal_uInt8(i)))
+ j++;
+ i++;
+ }
+
+ if(j == nNum)
+ nRet = i - 1;
+
+ return sal_uInt8(nRet);
+}
+
+void SetOfByte::operator&=(const SetOfByte& r2ndSet)
+{
+ for(sal_uInt16 i(0); i < 32; i++)
+ {
+ aData[i] &= r2ndSet.aData[i];
+ }
+}
+
+void SetOfByte::operator|=(const SetOfByte& r2ndSet)
+{
+ for(sal_uInt16 i(0); i < 32; i++)
+ {
+ aData[i] |= r2ndSet.aData[i];
+ }
+}
+
+/** initialize this set with a uno sequence of sal_Int8
+*/
+void SetOfByte::PutValue( const com::sun::star::uno::Any & rAny )
+{
+ com::sun::star::uno::Sequence< sal_Int8 > aSeq;
+ if( rAny >>= aSeq )
+ {
+ sal_Int16 nCount = (sal_Int16)aSeq.getLength();
+ if( nCount > 32 )
+ nCount = 32;
+
+ sal_Int16 nIndex;
+ for( nIndex = 0; nIndex < nCount; nIndex++ )
+ {
+ aData[nIndex] = static_cast<BYTE>(aSeq[nIndex]);
+ }
+
+ for( ; nIndex < 32; nIndex++ )
+ {
+ aData[nIndex] = 0;
+ }
+ }
+}
+
+/** returns a uno sequence of sal_Int8
+*/
+void SetOfByte::QueryValue( com::sun::star::uno::Any & rAny ) const
+{
+ sal_Int16 nNumBytesSet = 0;
+ sal_Int16 nIndex;
+ for( nIndex = 31; nIndex >= 00; nIndex-- )
+ {
+ if( 0 != aData[nIndex] )
+ {
+ nNumBytesSet = nIndex + 1;
+ break;
+ }
+ }
+
+ com::sun::star::uno::Sequence< sal_Int8 > aSeq( nNumBytesSet );
+
+ for( nIndex = 0; nIndex < nNumBytesSet; nIndex++ )
+ {
+ aSeq[nIndex] = static_cast<sal_Int8>(aData[nIndex]);
+ }
+
+ rAny <<= aSeq;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SdrLayer
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrLayer::SetStandardLayer(bool bStd)
+{
+ nType=(UINT16)bStd;
+ if (bStd) {
+ aName=ImpGetResStr(STR_StandardLayerName);
+ }
+ if (pModel!=NULL) {
+ SdrHint aHint(HINT_LAYERCHG);
+ pModel->Broadcast(aHint);
+ pModel->SetChanged();
+ }
+}
+
+void SdrLayer::SetName(const XubString& rNewName)
+{
+ if(!rNewName.Equals(aName))
+ {
+ aName = rNewName;
+ nType = 0; // Userdefined
+
+ if(pModel)
+ {
+ SdrHint aHint(HINT_LAYERCHG);
+
+ pModel->Broadcast(aHint);
+ pModel->SetChanged();
+ }
+ }
+}
+
+bool SdrLayer::operator==(const SdrLayer& rCmpLayer) const
+{
+ return (nID == rCmpLayer.nID
+ && nType == rCmpLayer.nType
+ && aName.Equals(rCmpLayer.aName));
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// SdrLayerAdmin
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrLayerAdmin::SdrLayerAdmin(SdrLayerAdmin* pNewParent):
+ aLayer(1024,16,16),
+ aLSets(1024,16,16),
+ pModel(NULL)
+{
+ sal_Char aTextControls[] = "Controls";
+ aControlLayerName = String(aTextControls, sizeof(aTextControls-1));
+ pParent=pNewParent;
+}
+
+SdrLayerAdmin::SdrLayerAdmin(const SdrLayerAdmin& rSrcLayerAdmin):
+ aLayer(1024,16,16),
+ aLSets(1024,16,16),
+ pParent(NULL),
+ pModel(NULL)
+{
+ sal_Char aTextControls[] = "Controls";
+ aControlLayerName = String(aTextControls, sizeof(aTextControls-1));
+ *this = rSrcLayerAdmin;
+}
+
+SdrLayerAdmin::~SdrLayerAdmin()
+{
+ ClearLayer();
+}
+
+void SdrLayerAdmin::ClearLayer()
+{
+ SdrLayer* pL;
+ pL=(SdrLayer*)aLayer.First();
+ while (pL!=NULL) {
+ delete pL;
+ pL=(SdrLayer*)aLayer.Next();
+ }
+ aLayer.Clear();
+}
+
+const SdrLayerAdmin& SdrLayerAdmin::operator=(const SdrLayerAdmin& rSrcLayerAdmin)
+{
+ ClearLayer();
+ pParent=rSrcLayerAdmin.pParent;
+ USHORT i;
+ USHORT nAnz=rSrcLayerAdmin.GetLayerCount();
+ for (i=0; i<nAnz; i++) {
+ aLayer.Insert(new SdrLayer(*rSrcLayerAdmin.GetLayer(i)),CONTAINER_APPEND);
+ }
+ return *this;
+}
+
+bool SdrLayerAdmin::operator==(const SdrLayerAdmin& rCmpLayerAdmin) const
+{
+ if (pParent!=rCmpLayerAdmin.pParent ||
+ aLayer.Count()!=rCmpLayerAdmin.aLayer.Count() ||
+ aLSets.Count()!=rCmpLayerAdmin.aLSets.Count()) return FALSE;
+ bool bOk = true;
+ USHORT nAnz=GetLayerCount();
+ USHORT i=0;
+ while (bOk && i<nAnz) {
+ bOk=*GetLayer(i)==*rCmpLayerAdmin.GetLayer(i);
+ i++;
+ }
+ return bOk;
+}
+
+void SdrLayerAdmin::SetModel(SdrModel* pNewModel)
+{
+ if (pNewModel!=pModel) {
+ pModel=pNewModel;
+ USHORT nAnz=GetLayerCount();
+ USHORT i;
+ for (i=0; i<nAnz; i++) {
+ GetLayer(i)->SetModel(pNewModel);
+ }
+ }
+}
+
+void SdrLayerAdmin::Broadcast() const
+{
+ if (pModel!=NULL) {
+ SdrHint aHint(HINT_LAYERORDERCHG);
+ pModel->Broadcast(aHint);
+ pModel->SetChanged();
+ }
+}
+
+SdrLayer* SdrLayerAdmin::RemoveLayer(USHORT nPos)
+{
+ SdrLayer* pRetLayer=(SdrLayer*)(aLayer.Remove(nPos));
+ Broadcast();
+ return pRetLayer;
+}
+
+SdrLayer* SdrLayerAdmin::NewLayer(const XubString& rName, USHORT nPos)
+{
+ SdrLayerID nID=GetUniqueLayerID();
+ SdrLayer* pLay=new SdrLayer(nID,rName);
+ pLay->SetModel(pModel);
+ aLayer.Insert(pLay,nPos);
+ Broadcast();
+ return pLay;
+}
+
+SdrLayer* SdrLayerAdmin::NewStandardLayer(USHORT nPos)
+{
+ SdrLayerID nID=GetUniqueLayerID();
+ SdrLayer* pLay=new SdrLayer(nID,String());
+ pLay->SetStandardLayer();
+ pLay->SetModel(pModel);
+ aLayer.Insert(pLay,nPos);
+ Broadcast();
+ return pLay;
+}
+
+SdrLayer* SdrLayerAdmin::MoveLayer(USHORT nPos, USHORT nNewPos)
+{
+ SdrLayer* pLayer=(SdrLayer*)(aLayer.Remove(nPos));
+ if (pLayer!=NULL) {
+ aLayer.Insert(pLayer,nNewPos);
+ }
+
+ Broadcast();
+ return pLayer;
+}
+
+void SdrLayerAdmin::MoveLayer(SdrLayer* pLayer, USHORT nNewPos)
+{
+ ULONG nPos=aLayer.GetPos(pLayer);
+ if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
+ aLayer.Remove(nPos);
+ aLayer.Insert(pLayer,nNewPos);
+ Broadcast();
+ }
+}
+
+USHORT SdrLayerAdmin::GetLayerPos(SdrLayer* pLayer) const
+{
+ ULONG nRet=SDRLAYER_NOTFOUND;
+ if (pLayer!=NULL) {
+ nRet=aLayer.GetPos(pLayer);
+ if (nRet==CONTAINER_ENTRY_NOTFOUND) {
+ nRet=SDRLAYER_NOTFOUND;
+ }
+ }
+ return USHORT(nRet);
+}
+
+const SdrLayer* SdrLayerAdmin::GetLayer(const XubString& rName, bool /*bInherited*/) const
+{
+ UINT16 i(0);
+ const SdrLayer* pLay = NULL;
+
+ while(i < GetLayerCount() && !pLay)
+ {
+ if(rName.Equals(GetLayer(i)->GetName()))
+ pLay = GetLayer(i);
+ else
+ i++;
+ }
+
+ if(!pLay && pParent)
+ {
+ pLay = pParent->GetLayer(rName, TRUE);
+ }
+
+ return pLay;
+}
+
+SdrLayerID SdrLayerAdmin::GetLayerID(const XubString& rName, bool bInherited) const
+{
+ SdrLayerID nRet=SDRLAYER_NOTFOUND;
+ const SdrLayer* pLay=GetLayer(rName,bInherited);
+ if (pLay!=NULL) nRet=pLay->GetID();
+ return nRet;
+}
+
+const SdrLayer* SdrLayerAdmin::GetLayerPerID(USHORT nID) const
+{
+ USHORT i=0;
+ const SdrLayer* pLay=NULL;
+ while (i<GetLayerCount() && pLay==NULL) {
+ if (nID==GetLayer(i)->GetID()) pLay=GetLayer(i);
+ else i++;
+ }
+ return pLay;
+}
+
+// Globale LayerID's beginnen mit 0 aufsteigend.
+// Lokale LayerID's beginnen mit 254 absteigend.
+// 255 ist reserviert fuer SDRLAYER_NOTFOUND
+
+SdrLayerID SdrLayerAdmin::GetUniqueLayerID() const
+{
+ SetOfByte aSet;
+ sal_Bool bDown = (pParent == NULL);
+ USHORT j;
+ for (j=0; j<GetLayerCount(); j++)
+ {
+ aSet.Set(GetLayer((sal_uInt16)j)->GetID());
+ }
+ SdrLayerID i;
+ if (!bDown)
+ {
+ i=254;
+ while (i && aSet.IsSet(BYTE(i)))
+ --i;
+ if (i == 0)
+ i=254;
+ }
+ else
+ {
+ i=0;
+ while (i<=254 && aSet.IsSet(BYTE(i)))
+ i++;
+ if (i>254)
+ i=0;
+ }
+ return i;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdmark.cxx b/svx/source/svdraw/svdmark.cxx
new file mode 100644
index 000000000000..5b60131ed027
--- /dev/null
+++ b/svx/source/svdraw/svdmark.cxx
@@ -0,0 +1,1043 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include <svx/svdmark.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpage.hxx>
+#include "svditer.hxx"
+#include <svx/svdpagv.hxx>
+#include <svx/svdopath.hxx> // zur Abschaltung
+#include <svx/svdogrp.hxx> // des Cache bei
+#include <svx/svdorect.hxx> // GetMarkDescription
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#include <svx/obj3d.hxx>
+#include <svx/scene3d.hxx>
+#include <svl/brdcst.hxx>
+#include <svx/svdoedge.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ImpSdrUShortContSorter: public ContainerSorter
+{
+public:
+ ImpSdrUShortContSorter(Container& rNewCont)
+ : ContainerSorter(rNewCont)
+ {}
+
+ virtual int Compare(const void* pElem1, const void* pElem2) const;
+};
+
+int ImpSdrUShortContSorter::Compare(const void* pElem1, const void* pElem2) const
+{
+ sal_uInt16 n1((sal_uInt16)((sal_uIntPtr)pElem1));
+ sal_uInt16 n2((sal_uInt16)((sal_uIntPtr)pElem2));
+
+ return ((n1 < n2) ? (-1) : (n1 > n2) ? (1) : (0));
+}
+
+void SdrUShortCont::Sort() const
+{
+ ImpSdrUShortContSorter aSort(*((Container*)(&maArray)));
+ aSort.DoSort();
+ ((SdrUShortCont*)this)->mbSorted = sal_True;
+
+ ULONG nNum(GetCount());
+
+ if(nNum > 1)
+ {
+ nNum--;
+ sal_uInt16 nVal0 = GetObject(nNum);
+
+ while(nNum > 0)
+ {
+ nNum--;
+ sal_uInt16 nVal1 = GetObject(nNum);
+
+ if(nVal1 == nVal0)
+ {
+ ((SdrUShortCont*)this)->Remove(nNum);
+ }
+
+ nVal0 = nVal1;
+ }
+ }
+}
+
+void SdrUShortCont::CheckSort(ULONG nPos)
+{
+ ULONG nAnz(maArray.Count());
+
+ if(nPos > nAnz)
+ nPos = nAnz;
+
+ sal_uInt16 nAktVal = GetObject(nPos);
+
+ if(nPos > 0)
+ {
+ sal_uInt16 nPrevVal = GetObject(nPos - 1);
+
+ if(nPrevVal >= nAktVal)
+ mbSorted = sal_False;
+ }
+
+ if(nPos < nAnz - 1)
+ {
+ sal_uInt16 nNextVal = GetObject(nPos + 1);
+
+ if(nNextVal <= nAktVal)
+ mbSorted = sal_False;
+ }
+}
+
+std::set< sal_uInt16 > SdrUShortCont::getContainer()
+{
+ std::set< sal_uInt16 > aSet;
+
+ sal_uInt32 nAnz = maArray.Count();
+ while(nAnz)
+ aSet.insert( GetObject(--nAnz) );
+
+ return aSet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrMark::SdrMark(SdrObject* pNewObj, SdrPageView* pNewPageView)
+: mpSelectedSdrObject(pNewObj),
+ mpPageView(pNewPageView),
+ mpPoints(0L),
+ mpLines(0L),
+ mpGluePoints(0L),
+ mbCon1(sal_False),
+ mbCon2(sal_False),
+ mnUser(0)
+{
+ if(mpSelectedSdrObject)
+ {
+ mpSelectedSdrObject->AddObjectUser( *this );
+ }
+}
+
+SdrMark::SdrMark(const SdrMark& rMark)
+: ObjectUser(),
+ mpSelectedSdrObject(0L),
+ mpPageView(0L),
+ mpPoints(0L),
+ mpLines(0L),
+ mpGluePoints(0L),
+ mbCon1(sal_False),
+ mbCon2(sal_False),
+ mnUser(0)
+{
+ *this = rMark;
+}
+
+SdrMark::~SdrMark()
+{
+ if(mpSelectedSdrObject)
+ {
+ mpSelectedSdrObject->RemoveObjectUser( *this );
+ }
+
+ if(mpPoints)
+ {
+ delete mpPoints;
+ }
+
+ if(mpLines)
+ {
+ delete mpLines;
+ }
+
+ if(mpGluePoints)
+ {
+ delete mpGluePoints;
+ }
+}
+
+void SdrMark::ObjectInDestruction(const SdrObject& rObject)
+{
+ (void) rObject; // avoid warnings
+ OSL_ENSURE(mpSelectedSdrObject && mpSelectedSdrObject == &rObject, "SdrMark::ObjectInDestruction: called form object different from hosted one (!)");
+ OSL_ENSURE(mpSelectedSdrObject, "SdrMark::ObjectInDestruction: still seleceted SdrObject is deleted, deselect first (!)");
+ mpSelectedSdrObject = 0L;
+}
+
+void SdrMark::SetMarkedSdrObj(SdrObject* pNewObj)
+{
+ if(mpSelectedSdrObject)
+ {
+ mpSelectedSdrObject->RemoveObjectUser( *this );
+ }
+
+ mpSelectedSdrObject = pNewObj;
+
+ if(mpSelectedSdrObject)
+ {
+ mpSelectedSdrObject->AddObjectUser( *this );
+ }
+}
+
+SdrObject* SdrMark::GetMarkedSdrObj() const
+{
+ return mpSelectedSdrObject;
+}
+
+SdrMark& SdrMark::operator=(const SdrMark& rMark)
+{
+ SetMarkedSdrObj(rMark.mpSelectedSdrObject);
+ mpPageView = rMark.mpPageView;
+ mbCon1 = rMark.mbCon1;
+ mbCon2 = rMark.mbCon2;
+ mnUser = rMark.mnUser;
+
+ if(!rMark.mpPoints)
+ {
+ if(mpPoints)
+ {
+ delete mpPoints;
+ mpPoints = 0L;
+ }
+ }
+ else
+ {
+ if(!mpPoints)
+ {
+ mpPoints = new SdrUShortCont(*rMark.mpPoints);
+ }
+ else
+ {
+ *mpPoints = *rMark.mpPoints;
+ }
+ }
+
+ if(!rMark.mpLines)
+ {
+ if(mpLines)
+ {
+ delete mpLines;
+ mpLines = 0L;
+ }
+ }
+ else
+ {
+ if(!mpLines)
+ {
+ mpLines = new SdrUShortCont(*rMark.mpLines);
+ }
+ else
+ {
+ *mpLines = *rMark.mpLines;
+ }
+ }
+
+ if(!rMark.mpGluePoints)
+ {
+ if(mpGluePoints)
+ {
+ delete mpGluePoints;
+ mpGluePoints = 0L;
+ }
+ }
+ else
+ {
+ if(!mpGluePoints)
+ {
+ mpGluePoints = new SdrUShortCont(*rMark.mpGluePoints);
+ }
+ else
+ {
+ *mpGluePoints = *rMark.mpGluePoints;
+ }
+ }
+
+ return *this;
+}
+
+sal_Bool SdrMark::operator==(const SdrMark& rMark) const
+{
+ sal_Bool bRet(mpSelectedSdrObject == rMark.mpSelectedSdrObject && mpPageView == rMark.mpPageView && mbCon1 == rMark.mbCon1 && mbCon2 == rMark.mbCon2 && mnUser == rMark.mnUser);
+
+ if((mpPoints != 0L) != (rMark.mpPoints != 0L))
+ bRet = sal_False;
+
+ if((mpLines != 0L) != (rMark.mpLines != 0L))
+ bRet = sal_False;
+
+ if((mpGluePoints != 0L) != (rMark.mpGluePoints != 0L))
+ bRet = sal_False;
+
+ if(bRet && mpPoints && *mpPoints != *rMark.mpPoints)
+ bRet = sal_False;
+
+ if(bRet && mpLines && *mpLines != *rMark.mpLines)
+ bRet = sal_False;
+
+ if(bRet && mpGluePoints && *mpGluePoints != *rMark.mpGluePoints)
+ bRet = sal_False;
+
+ return bRet;
+}
+
+SdrPage* SdrMark::GetPage() const
+{
+ return (mpSelectedSdrObject ? mpSelectedSdrObject->GetPage() : 0);
+}
+
+SdrObjList* SdrMark::GetObjList() const
+{
+ return (mpSelectedSdrObject ? mpSelectedSdrObject->GetObjList() : 0);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ImpSdrMarkListSorter: public ContainerSorter
+{
+public:
+ ImpSdrMarkListSorter(Container& rNewCont)
+ : ContainerSorter(rNewCont)
+ {}
+
+ virtual int Compare(const void* pElem1, const void* pElem2) const;
+};
+
+int ImpSdrMarkListSorter::Compare(const void* pElem1, const void* pElem2) const
+{
+ SdrObject* pObj1 = ((SdrMark*)pElem1)->GetMarkedSdrObj();
+ SdrObject* pObj2 = ((SdrMark*)pElem2)->GetMarkedSdrObj();
+ SdrObjList* pOL1 = (pObj1) ? pObj1->GetObjList() : 0L;
+ SdrObjList* pOL2 = (pObj2) ? pObj2->GetObjList() : 0L;
+
+ if (pOL1 == pOL2)
+ {
+ // AF: Note that I reverted a change from sal_uInt32 to ULONG (made
+ // for 64bit compliance, #i78198#) because internally in SdrObject
+ // both nOrdNum and mnNavigationPosition are stored as sal_uInt32.
+ sal_uInt32 nObjOrd1((pObj1) ? pObj1->GetNavigationPosition() : 0);
+ sal_uInt32 nObjOrd2((pObj2) ? pObj2->GetNavigationPosition() : 0);
+
+ return (nObjOrd1 < nObjOrd2 ? -1 : 1);
+ }
+ else
+ {
+ return ((long)pOL1 < (long)pOL2) ? -1 : 1;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrMarkList::ForceSort() const
+{
+ if(!mbSorted)
+ {
+ ((SdrMarkList*)this)->ImpForceSort();
+ }
+}
+
+void SdrMarkList::ImpForceSort()
+{
+ if(!mbSorted)
+ {
+ mbSorted = sal_True;
+ ULONG nAnz = maList.Count();
+
+ // remove invalid
+ if(nAnz > 0 )
+ {
+ SdrMark* pAkt = (SdrMark*)maList.First();
+ while( pAkt )
+ {
+ if(pAkt->GetMarkedSdrObj() == 0)
+ {
+ maList.Remove();
+ delete pAkt;
+ }
+ pAkt= (SdrMark*)maList.Next();
+ }
+ nAnz = maList.Count();
+ }
+
+ if(nAnz > 1)
+ {
+ ImpSdrMarkListSorter aSort(maList);
+ aSort.DoSort();
+
+ // remove duplicates
+ if(maList.Count() > 1)
+ {
+ SdrMark* pAkt = (SdrMark*)maList.Last();
+ SdrMark* pCmp = (SdrMark*)maList.Prev();
+
+ while(pCmp)
+ {
+ if(pAkt->GetMarkedSdrObj() == pCmp->GetMarkedSdrObj() && pAkt->GetMarkedSdrObj())
+ {
+ // Con1/Con2 Merging
+ if(pCmp->IsCon1())
+ pAkt->SetCon1(sal_True);
+
+ if(pCmp->IsCon2())
+ pAkt->SetCon2(sal_True);
+
+ // pCmp loeschen.
+ maList.Remove();
+
+ delete pCmp;
+ }
+ else
+ {
+ pAkt = pCmp;
+ }
+
+ pCmp = (SdrMark*)maList.Prev();
+ }
+ }
+ }
+ }
+}
+
+void SdrMarkList::Clear()
+{
+ for(ULONG i(0L); i < GetMarkCount(); i++)
+ {
+ SdrMark* pMark = GetMark(i);
+ delete pMark;
+ }
+
+ maList.Clear();
+ SetNameDirty();
+}
+
+void SdrMarkList::operator=(const SdrMarkList& rLst)
+{
+ Clear();
+
+ for(ULONG i(0L); i < rLst.GetMarkCount(); i++)
+ {
+ SdrMark* pMark = rLst.GetMark(i);
+ SdrMark* pNeuMark = new SdrMark(*pMark);
+ maList.Insert(pNeuMark, CONTAINER_APPEND);
+ }
+
+ maMarkName = rLst.maMarkName;
+ mbNameOk = rLst.mbNameOk;
+ maPointName = rLst.maPointName;
+ mbPointNameOk = rLst.mbPointNameOk;
+ maGluePointName = rLst.maGluePointName;
+ mbGluePointNameOk = rLst.mbGluePointNameOk;
+ mbSorted = rLst.mbSorted;
+}
+
+ULONG SdrMarkList::FindObject(const SdrObject* pObj) const
+{
+ // #109658#
+ //
+ // Since relying on OrdNums is not allowed for the selection because objects in the
+ // selection may not be inserted in a list if they are e.g. modified ATM, i changed
+ // this loop to just look if the object pointer is in the selection.
+ //
+ // Problem is that GetOrdNum() which is const, internally casts to non-const and
+ // hardly sets the OrdNum member of the object (nOrdNum) to 0 (ZERO) if the object
+ // is not inserted in a object list.
+ // Since this may be by purpose and necessary somewhere else i decided that it is
+ // less dangerous to change this method then changing SdrObject::GetOrdNum().
+ if(pObj && maList.Count())
+ {
+ for(ULONG a(0L); a < maList.Count(); a++)
+ {
+ if(((SdrMark*)(maList.GetObject(a)))->GetMarkedSdrObj() == pObj)
+ {
+ return a;
+ }
+ }
+ }
+
+ return CONTAINER_ENTRY_NOTFOUND;
+}
+
+void SdrMarkList::InsertEntry(const SdrMark& rMark, sal_Bool bChkSort)
+{
+ SetNameDirty();
+ ULONG nAnz(maList.Count());
+
+ if(!bChkSort || !mbSorted || nAnz == 0)
+ {
+ if(!bChkSort)
+ mbSorted = sal_False;
+
+ maList.Insert(new SdrMark(rMark), CONTAINER_APPEND);
+ }
+ else
+ {
+ SdrMark* pLast = GetMark(ULONG(nAnz - 1));
+ const SdrObject* pLastObj = pLast->GetMarkedSdrObj();
+ const SdrObject* pNeuObj = rMark.GetMarkedSdrObj();
+
+ if(pLastObj == pNeuObj)
+ {
+ // Aha, den gibt's schon
+ // Con1/Con2 Merging
+ if(rMark.IsCon1())
+ pLast->SetCon1(sal_True);
+
+ if(rMark.IsCon2())
+ pLast->SetCon2(sal_True);
+ }
+ else
+ {
+ SdrMark* pKopie = new SdrMark(rMark);
+ maList.Insert(pKopie, CONTAINER_APPEND);
+
+ // und nun checken, ob die Sortierung noch ok ist
+ const SdrObjList* pLastOL = pLastObj!=0L ? pLastObj->GetObjList() : 0L;
+ const SdrObjList* pNeuOL = pNeuObj !=0L ? pNeuObj ->GetObjList() : 0L;
+
+ if(pLastOL == pNeuOL)
+ {
+ const ULONG nLastNum(pLastObj!=0L ? pLastObj->GetOrdNum() : 0);
+ const ULONG nNeuNum(pNeuObj !=0L ? pNeuObj ->GetOrdNum() : 0);
+
+ if(nNeuNum < nLastNum)
+ {
+ // irgendwann muss mal sortiert werden
+ mbSorted = sal_False;
+ }
+ }
+ else
+ {
+ // irgendwann muss mal sortiert werden
+ mbSorted = sal_False;
+ }
+ }
+ }
+
+ return;
+}
+
+void SdrMarkList::DeleteMark(ULONG nNum)
+{
+ SdrMark* pMark = GetMark(nNum);
+ DBG_ASSERT(pMark!=0L,"DeleteMark: MarkEntry nicht gefunden");
+
+ if(pMark)
+ {
+ maList.Remove(nNum);
+ delete pMark;
+ SetNameDirty();
+ }
+}
+
+void SdrMarkList::ReplaceMark(const SdrMark& rNewMark, ULONG nNum)
+{
+ SdrMark* pMark = GetMark(nNum);
+ DBG_ASSERT(pMark!=0L,"ReplaceMark: MarkEntry nicht gefunden");
+
+ if(pMark)
+ {
+ delete pMark;
+ SetNameDirty();
+ SdrMark* pKopie = new SdrMark(rNewMark);
+ maList.Replace(pKopie, nNum);
+ mbSorted = sal_False;
+ }
+}
+
+void SdrMarkList::Merge(const SdrMarkList& rSrcList, sal_Bool bReverse)
+{
+ ULONG nAnz(rSrcList.maList.Count());
+
+ if(rSrcList.mbSorted)
+ {
+ // Merging ohne ein Sort bei rSrcList zu erzwingen
+ bReverse = sal_False;
+ }
+
+ if(!bReverse)
+ {
+ for(ULONG i(0L); i < nAnz; i++)
+ {
+ SdrMark* pM = (SdrMark*)(rSrcList.maList.GetObject(i));
+ InsertEntry(*pM);
+ }
+ }
+ else
+ {
+ for(ULONG i(nAnz); i > 0;)
+ {
+ i--;
+ SdrMark* pM = (SdrMark*)(rSrcList.maList.GetObject(i));
+ InsertEntry(*pM);
+ }
+ }
+}
+
+sal_Bool SdrMarkList::DeletePageView(const SdrPageView& rPV)
+{
+ sal_Bool bChgd(sal_False);
+
+ for(ULONG i(GetMarkCount()); i > 0; )
+ {
+ i--;
+ SdrMark* pMark = GetMark(i);
+
+ if(pMark->GetPageView()==&rPV)
+ {
+ maList.Remove(i);
+ delete pMark;
+ SetNameDirty();
+ bChgd = sal_True;
+ }
+ }
+
+ return bChgd;
+}
+
+sal_Bool SdrMarkList::InsertPageView(const SdrPageView& rPV)
+{
+ sal_Bool bChgd(sal_False);
+ DeletePageView(rPV); // erstmal alle raus, dann die ganze Seite hinten dran
+ SdrObject* pObj;
+ const SdrObjList* pOL = rPV.GetObjList();
+ ULONG nObjAnz(pOL->GetObjCount());
+
+ for(ULONG nO(0L); nO < nObjAnz; nO++)
+ {
+ pObj = pOL->GetObj(nO);
+ sal_Bool bDoIt(rPV.IsObjMarkable(pObj));
+
+ if(bDoIt)
+ {
+ SdrMark* pM = new SdrMark(pObj, (SdrPageView*)&rPV);
+ maList.Insert(pM, CONTAINER_APPEND);
+ SetNameDirty();
+ bChgd = sal_True;
+ }
+ }
+
+ return bChgd;
+}
+
+const XubString& SdrMarkList::GetMarkDescription() const
+{
+ ULONG nAnz(GetMarkCount());
+
+ if(mbNameOk && 1L == nAnz)
+ {
+ // Bei Einfachselektion nur Textrahmen cachen
+ const SdrObject* pObj = GetMark(0)->GetMarkedSdrObj();
+ const SdrTextObj* pTextObj = PTR_CAST(SdrTextObj, pObj);
+
+ if(!pTextObj || !pTextObj->IsTextFrame())
+ {
+ ((SdrMarkList*)(this))->mbNameOk = sal_False;
+ }
+ }
+
+ if(!mbNameOk)
+ {
+ SdrMark* pMark = GetMark(0);
+ XubString aNam;
+
+ if(!nAnz)
+ {
+ ((SdrMarkList*)(this))->maMarkName = ImpGetResStr(STR_ObjNameNoObj);
+ }
+ else if(1L == nAnz)
+ {
+ if(pMark->GetMarkedSdrObj())
+ {
+ pMark->GetMarkedSdrObj()->TakeObjNameSingul(aNam);
+ }
+ }
+ else
+ {
+ if(pMark->GetMarkedSdrObj())
+ {
+ pMark->GetMarkedSdrObj()->TakeObjNamePlural(aNam);
+ XubString aStr1;
+ sal_Bool bEq(sal_True);
+
+ for(ULONG i = 1; i < GetMarkCount() && bEq; i++)
+ {
+ SdrMark* pMark2 = GetMark(i);
+ pMark2->GetMarkedSdrObj()->TakeObjNamePlural(aStr1);
+ bEq = aNam.Equals(aStr1);
+ }
+
+ if(!bEq)
+ {
+ aNam = ImpGetResStr(STR_ObjNamePlural);
+ }
+ }
+
+ aNam.Insert(sal_Unicode(' '), 0);
+ aNam.Insert(UniString::CreateFromInt32(nAnz), 0);
+ }
+
+ ((SdrMarkList*)(this))->maMarkName = aNam;
+ ((SdrMarkList*)(this))->mbNameOk = sal_True;
+ }
+
+ return maMarkName;
+}
+
+const XubString& SdrMarkList::GetPointMarkDescription(sal_Bool bGlue) const
+{
+ sal_Bool& rNameOk = (sal_Bool&)(bGlue ? mbGluePointNameOk : mbPointNameOk);
+ XubString& rName = (XubString&)(bGlue ? maGluePointName : maPointName);
+ ULONG nMarkAnz(GetMarkCount());
+ ULONG nMarkPtAnz(0L);
+ ULONG nMarkPtObjAnz(0L);
+ ULONG n1stMarkNum(ULONG_MAX);
+
+ for(ULONG nMarkNum(0L); nMarkNum < nMarkAnz; nMarkNum++)
+ {
+ const SdrMark* pMark = GetMark(nMarkNum);
+ const SdrUShortCont* pPts = bGlue ? pMark->GetMarkedGluePoints() : pMark->GetMarkedPoints();
+ ULONG nAnz(pPts ? pPts->GetCount() : 0);
+
+ if(nAnz)
+ {
+ if(n1stMarkNum == ULONG_MAX)
+ {
+ n1stMarkNum = nMarkNum;
+ }
+
+ nMarkPtAnz += nAnz;
+ nMarkPtObjAnz++;
+ }
+
+ if(nMarkPtObjAnz > 1 && rNameOk)
+ {
+ // vorzeitige Entscheidung
+ return rName;
+ }
+ }
+
+ if(rNameOk && 1L == nMarkPtObjAnz)
+ {
+ // Bei Einfachselektion nur Textrahmen cachen
+ const SdrObject* pObj = GetMark(0)->GetMarkedSdrObj();
+ const SdrTextObj* pTextObj = PTR_CAST(SdrTextObj,pObj);
+
+ if(!pTextObj || !pTextObj->IsTextFrame())
+ {
+ rNameOk = sal_False;
+ }
+ }
+
+ if(!nMarkPtObjAnz)
+ {
+ rName.Erase();
+ rNameOk = sal_True;
+ }
+ else if(!rNameOk)
+ {
+ const SdrMark* pMark = GetMark(n1stMarkNum);
+ XubString aNam;
+
+ if(1L == nMarkPtObjAnz)
+ {
+ if(pMark->GetMarkedSdrObj())
+ {
+ pMark->GetMarkedSdrObj()->TakeObjNameSingul(aNam);
+ }
+ }
+ else
+ {
+ if(pMark->GetMarkedSdrObj())
+ {
+ pMark->GetMarkedSdrObj()->TakeObjNamePlural(aNam);
+ }
+
+ XubString aStr1;
+ sal_Bool bEq(sal_True);
+
+ for(ULONG i(n1stMarkNum + 1L); i < GetMarkCount() && bEq; i++)
+ {
+ const SdrMark* pMark2 = GetMark(i);
+ const SdrUShortCont* pPts = bGlue ? pMark2->GetMarkedGluePoints() : pMark2->GetMarkedPoints();
+
+ if(pPts && pPts->GetCount() && pMark2->GetMarkedSdrObj())
+ {
+ pMark2->GetMarkedSdrObj()->TakeObjNamePlural(aStr1);
+ bEq = aNam.Equals(aStr1);
+ }
+ }
+
+ if(!bEq)
+ {
+ aNam = ImpGetResStr(STR_ObjNamePlural);
+ }
+
+ aNam.Insert(sal_Unicode(' '), 0);
+ aNam.Insert(UniString::CreateFromInt32(nMarkPtObjAnz), 0);
+ }
+
+ XubString aStr1;
+
+ if(1L == nMarkPtAnz)
+ {
+ aStr1 = (ImpGetResStr(bGlue ? STR_ViewMarkedGluePoint : STR_ViewMarkedPoint));
+ }
+ else
+ {
+ aStr1 = (ImpGetResStr(bGlue ? STR_ViewMarkedGluePoints : STR_ViewMarkedPoints));
+ aStr1.SearchAndReplaceAscii("%2", UniString::CreateFromInt32(nMarkPtAnz));
+ }
+
+ aStr1.SearchAndReplaceAscii("%1", aNam);
+ rName = aStr1;
+ rNameOk = sal_True;
+ }
+
+ return rName;
+}
+
+sal_Bool SdrMarkList::TakeBoundRect(SdrPageView* pPV, Rectangle& rRect) const
+{
+ sal_Bool bFnd(sal_False);
+ Rectangle aR;
+
+ for(ULONG i(0L); i < GetMarkCount(); i++)
+ {
+ SdrMark* pMark = GetMark(i);
+
+ if(!pPV || pMark->GetPageView() == pPV)
+ {
+ if(pMark->GetMarkedSdrObj())
+ {
+ aR = pMark->GetMarkedSdrObj()->GetCurrentBoundRect();
+
+ if(bFnd)
+ {
+ rRect.Union(aR);
+ }
+ else
+ {
+ rRect = aR;
+ bFnd = sal_True;
+ }
+ }
+ }
+ }
+
+ return bFnd;
+}
+
+sal_Bool SdrMarkList::TakeSnapRect(SdrPageView* pPV, Rectangle& rRect) const
+{
+ sal_Bool bFnd(sal_False);
+
+ for(ULONG i(0L); i < GetMarkCount(); i++)
+ {
+ SdrMark* pMark = GetMark(i);
+
+ if(!pPV || pMark->GetPageView() == pPV)
+ {
+ if(pMark->GetMarkedSdrObj())
+ {
+ Rectangle aR(pMark->GetMarkedSdrObj()->GetSnapRect());
+
+ if(bFnd)
+ {
+ rRect.Union(aR);
+ }
+ else
+ {
+ rRect = aR;
+ bFnd = sal_True;
+ }
+ }
+ }
+ }
+
+ return bFnd;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ ViewSelection::ViewSelection()
+ : mbEdgesOfMarkedNodesDirty(sal_False)
+ {
+ }
+
+ void ViewSelection::SetEdgesOfMarkedNodesDirty()
+ {
+ if(!mbEdgesOfMarkedNodesDirty)
+ {
+ mbEdgesOfMarkedNodesDirty = sal_True;
+ maEdgesOfMarkedNodes.Clear();
+ maMarkedEdgesOfMarkedNodes.Clear();
+ maAllMarkedObjects.Clear();
+ }
+ }
+
+ const SdrMarkList& ViewSelection::GetEdgesOfMarkedNodes() const
+ {
+ if(mbEdgesOfMarkedNodesDirty)
+ {
+ ((ViewSelection*)this)->ImpForceEdgesOfMarkedNodes();
+ }
+
+ return maEdgesOfMarkedNodes;
+ }
+
+ const SdrMarkList& ViewSelection::GetMarkedEdgesOfMarkedNodes() const
+ {
+ if(mbEdgesOfMarkedNodesDirty)
+ {
+ ((ViewSelection*)this)->ImpForceEdgesOfMarkedNodes();
+ }
+
+ return maMarkedEdgesOfMarkedNodes;
+ }
+
+ const List& ViewSelection::GetAllMarkedObjects() const
+ {
+ if(mbEdgesOfMarkedNodesDirty)
+ {
+ ((ViewSelection*)this)->ImpForceEdgesOfMarkedNodes();
+ }
+
+ return maAllMarkedObjects;
+ }
+
+ void ViewSelection::ImplCollectCompleteSelection(SdrObject* pObj)
+ {
+ if(pObj)
+ {
+ sal_Bool bIsGroup(pObj->IsGroupObject());
+
+ if(bIsGroup && pObj->ISA(E3dObject) && !pObj->ISA(E3dScene))
+ {
+ bIsGroup = sal_False;
+ }
+
+ if(bIsGroup)
+ {
+ SdrObjList* pList = pObj->GetSubList();
+
+ for(ULONG a(0L); a < pList->GetObjCount(); a++)
+ {
+ SdrObject* pObj2 = pList->GetObj(a);
+ ImplCollectCompleteSelection(pObj2);
+ }
+ }
+
+ maAllMarkedObjects.Insert(pObj, LIST_APPEND);
+ }
+ }
+
+ void ViewSelection::ImpForceEdgesOfMarkedNodes()
+ {
+ if(mbEdgesOfMarkedNodesDirty)
+ {
+ mbEdgesOfMarkedNodesDirty = sal_False;
+ maMarkedObjectList.ForceSort();
+ maEdgesOfMarkedNodes.Clear();
+ maMarkedEdgesOfMarkedNodes.Clear();
+ maAllMarkedObjects.Clear();
+
+ // #126320# GetMarkCount after ForceSort
+ const ULONG nMarkAnz(maMarkedObjectList.GetMarkCount());
+
+ for(ULONG a(0L); a < nMarkAnz; a++)
+ {
+ SdrObject* pCandidate = maMarkedObjectList.GetMark(a)->GetMarkedSdrObj();
+
+ if(pCandidate)
+ {
+ // build transitive hull
+ ImplCollectCompleteSelection(pCandidate);
+
+ if(pCandidate->IsNode())
+ {
+ // travel over broadcaster/listener to access edges connected to the selected object
+ const SfxBroadcaster* pBC = pCandidate->GetBroadcaster();
+
+ if(pBC)
+ {
+ sal_uInt16 nLstAnz(pBC->GetListenerCount());
+
+ for(sal_uInt16 nl(0); nl < nLstAnz; nl++)
+ {
+ SfxListener* pLst = pBC->GetListener(nl);
+ SdrEdgeObj* pEdge = PTR_CAST(SdrEdgeObj, pLst);
+
+ if(pEdge && pEdge->IsInserted() && pEdge->GetPage() == pCandidate->GetPage())
+ {
+ SdrMark aM(pEdge, maMarkedObjectList.GetMark(a)->GetPageView());
+
+ if(pEdge->GetConnectedNode(sal_True) == pCandidate)
+ {
+ aM.SetCon1(sal_True);
+ }
+
+ if(pEdge->GetConnectedNode(sal_False) == pCandidate)
+ {
+ aM.SetCon2(sal_True);
+ }
+
+ if(CONTAINER_ENTRY_NOTFOUND == maMarkedObjectList.FindObject(pEdge))
+ {
+ // nachsehen, ob er selbst markiert ist
+ maEdgesOfMarkedNodes.InsertEntry(aM);
+ }
+ else
+ {
+ maMarkedEdgesOfMarkedNodes.InsertEntry(aM);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ maEdgesOfMarkedNodes.ForceSort();
+ maMarkedEdgesOfMarkedNodes.ForceSort();
+ }
+ }
+} // end of namespace sdr
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
new file mode 100644
index 000000000000..07028eb4f6eb
--- /dev/null
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -0,0 +1,2257 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdmodel.hxx>
+
+#include <rtl/uuid.h>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <osl/endian.h>
+#include <rtl/logfile.hxx>
+#include <math.h>
+#include <tools/urlobj.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+
+#include <tools/string.hxx>
+#include <svl/whiter.hxx>
+#include <svx/xit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/xflftrit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xlnstit.hxx>
+
+#include "svditext.hxx"
+#include <editeng/editeng.hxx> // Fuer EditEngine::CreatePool()
+
+#include <svx/xtable.hxx>
+
+#include "svditer.hxx"
+#include <svx/svdtrans.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdlayer.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdotext.hxx> // fuer ReformatAllTextObjects und CalcFieldValue
+#include <svx/svdetc.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdoole2.hxx>
+#include "svdglob.hxx" // Stringcache
+#include "svdstr.hrc" // Objektname
+#include "svdoutlinercache.hxx"
+
+
+#include <svl/asiancfg.hxx>
+#include "editeng/fontitem.hxx"
+#include <editeng/colritem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <svl/style.hxx>
+#include <tools/bigint.hxx>
+#include <editeng/numitem.hxx>
+#include <editeng/bulitem.hxx>
+#include <editeng/outlobj.hxx>
+#include "editeng/forbiddencharacterstable.hxx"
+#include <svl/zforlist.hxx>
+#include <comphelper/processfactory.hxx>
+
+// #90477#
+#include <tools/tenccvt.hxx>
+#include <unotools/syslocale.hxx>
+
+// #95114#
+#include <vcl/svapp.hxx>
+#include <svx/sdr/properties/properties.hxx>
+#include <editeng/eeitem.hxx>
+#include <svl/itemset.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+struct SdrModelImpl
+{
+ SfxUndoManager* mpUndoManager;
+ SdrUndoFactory* mpUndoFactory;
+ bool mbAllowShapePropertyChangeListener;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+DBG_NAME(SdrModel)
+TYPEINIT1(SdrModel,SfxBroadcaster);
+void SdrModel::ImpCtor(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* _pEmbeddedHelper,
+ bool bUseExtColorTable, bool bLoadRefCounts)
+{
+ mpImpl = new SdrModelImpl;
+ mpImpl->mpUndoManager=0;
+ mpImpl->mpUndoFactory=0;
+ mpImpl->mbAllowShapePropertyChangeListener = false;
+ mbInDestruction = false;
+ aObjUnit=SdrEngineDefaults::GetMapFraction();
+ eObjUnit=SdrEngineDefaults::GetMapUnit();
+ eUIUnit=FUNIT_MM;
+ aUIScale=Fraction(1,1);
+ nUIUnitKomma=0;
+ bUIOnlyKomma=FALSE;
+ pLayerAdmin=NULL;
+ pItemPool=pPool;
+ bMyPool=FALSE;
+ m_pEmbeddedHelper=_pEmbeddedHelper;
+ pDrawOutliner=NULL;
+ pHitTestOutliner=NULL;
+ pRefOutDev=NULL;
+ nProgressAkt=0;
+ nProgressMax=0;
+ nProgressOfs=0;
+ pDefaultStyleSheet=NULL;
+ pLinkManager=NULL;
+ pUndoStack=NULL;
+ pRedoStack=NULL;
+ nMaxUndoCount=16;
+ pAktUndoGroup=NULL;
+ nUndoLevel=0;
+ mbUndoEnabled=true;
+ nProgressPercent=0;
+ nLoadVersion=0;
+ bExtColorTable=FALSE;
+ mbChanged = sal_False;
+ bInfoChanged=FALSE;
+ bPagNumsDirty=FALSE;
+ bMPgNumsDirty=FALSE;
+ bPageNotValid=FALSE;
+ bSavePortable=FALSE;
+ bSaveCompressed=FALSE;
+ bSaveNative=FALSE;
+ bSwapGraphics=FALSE;
+ nSwapGraphicsMode=SDR_SWAPGRAPHICSMODE_DEFAULT;
+ bSaveOLEPreview=FALSE;
+ bPasteResize=FALSE;
+ bNoBitmapCaching=FALSE;
+ bReadOnly=FALSE;
+ nStreamCompressMode=COMPRESSMODE_NONE;
+ nStreamNumberFormat=NUMBERFORMAT_INT_BIGENDIAN;
+ nDefaultTabulator=0;
+ pColorTable=NULL;
+ pDashList=NULL;
+ pLineEndList=NULL;
+ pHatchList=NULL;
+ pGradientList=NULL;
+ pBitmapList=NULL;
+ mpNumberFormatter = NULL;
+ bTransparentTextFrames=FALSE;
+ bStarDrawPreviewMode = FALSE;
+ nStarDrawPreviewMasterPageNum = SDRPAGE_NOTFOUND;
+ pModelStorage = NULL;
+ mpForbiddenCharactersTable = NULL;
+ mbModelLocked = FALSE;
+ mpOutlinerCache = NULL;
+ mbKernAsianPunctuation = sal_False;
+ mbAddExtLeading = sal_False;
+ mnHandoutPageCount = 0;
+
+ SvxAsianConfig aAsian;
+ mnCharCompressType = aAsian.GetCharDistanceCompression();
+
+#ifdef OSL_LITENDIAN
+ nStreamNumberFormat=NUMBERFORMAT_INT_LITTLEENDIAN;
+#endif
+ bExtColorTable=bUseExtColorTable;
+
+ if ( pPool == NULL )
+ {
+ pItemPool=new SdrItemPool(0L, bLoadRefCounts);
+ // Der Outliner hat keinen eigenen Pool, deshalb den der EditEngine
+ SfxItemPool* pOutlPool=EditEngine::CreatePool( bLoadRefCounts );
+ // OutlinerPool als SecondaryPool des SdrPool
+ pItemPool->SetSecondaryPool(pOutlPool);
+ // Merken, dass ich mir die beiden Pools selbst gemacht habe
+ bMyPool=TRUE;
+ }
+ pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
+
+// SJ: #95129# using static SdrEngineDefaults only if default SvxFontHeight item is not available
+ const SfxPoolItem* pPoolItem = pItemPool->GetPoolDefaultItem( EE_CHAR_FONTHEIGHT );
+ if ( pPoolItem )
+ nDefTextHgt = ((SvxFontHeightItem*)pPoolItem)->GetHeight();
+ else
+ nDefTextHgt = SdrEngineDefaults::GetFontHeight();
+
+ SetTextDefaults();
+ pLayerAdmin=new SdrLayerAdmin;
+ pLayerAdmin->SetModel(this);
+ ImpSetUIUnit();
+
+ // den DrawOutliner OnDemand erzeugen geht noch nicht, weil ich den Pool
+ // sonst nicht kriege (erst ab 302!)
+ pDrawOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this );
+ ImpSetOutlinerDefaults(pDrawOutliner, TRUE);
+
+ pHitTestOutliner = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this );
+ ImpSetOutlinerDefaults(pHitTestOutliner, TRUE);
+
+ ImpCreateTables();
+}
+
+SdrModel::SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, sal_Bool bLoadRefCounts):
+ maMaPag(1024,32,32),
+ maPages(1024,32,32)
+{
+#ifdef TIMELOG
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
+#endif
+
+ DBG_CTOR(SdrModel,NULL);
+ ImpCtor(pPool,pPers,FALSE, (bool)bLoadRefCounts);
+}
+
+SdrModel::SdrModel(const String& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, sal_Bool bLoadRefCounts):
+ maMaPag(1024,32,32),
+ maPages(1024,32,32),
+ aTablePath(rPath)
+{
+#ifdef TIMELOG
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
+#endif
+
+ DBG_CTOR(SdrModel,NULL);
+ ImpCtor(pPool,pPers,FALSE, (bool)bLoadRefCounts);
+}
+
+SdrModel::SdrModel(SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, bool bUseExtColorTable, sal_Bool bLoadRefCounts):
+ maMaPag(1024,32,32),
+ maPages(1024,32,32)
+{
+#ifdef TIMELOG
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
+#endif
+
+ DBG_CTOR(SdrModel,NULL);
+ ImpCtor(pPool,pPers,bUseExtColorTable, (bool)bLoadRefCounts);
+}
+
+SdrModel::SdrModel(const String& rPath, SfxItemPool* pPool, ::comphelper::IEmbeddedHelper* pPers, bool bUseExtColorTable, sal_Bool bLoadRefCounts):
+ maMaPag(1024,32,32),
+ maPages(1024,32,32),
+ aTablePath(rPath)
+{
+#ifdef TIMELOG
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
+#endif
+
+ DBG_CTOR(SdrModel,NULL);
+ ImpCtor(pPool,pPers,bUseExtColorTable, (bool)bLoadRefCounts);
+}
+
+SdrModel::SdrModel(const SdrModel& /*rSrcModel*/):
+ SfxBroadcaster(),
+ tools::WeakBase< SdrModel >(),
+ maMaPag(1024,32,32),
+ maPages(1024,32,32)
+{
+#ifdef TIMELOG
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::SdrModel(...)" );
+#endif
+
+ // noch nicht implementiert
+ DBG_ERROR("SdrModel::CopyCtor() ist noch nicht implementiert");
+}
+
+SdrModel::~SdrModel()
+{
+#ifdef TIMELOG
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "svx", "aw93748", "SdrModel::~SdrModel(...)" );
+#endif
+
+ DBG_DTOR(SdrModel,NULL);
+
+ mbInDestruction = true;
+
+ Broadcast(SdrHint(HINT_MODELCLEARED));
+
+ delete mpOutlinerCache;
+
+ ClearUndoBuffer();
+#ifdef DBG_UTIL
+ if(pAktUndoGroup)
+ {
+ ByteString aStr("Im Dtor des SdrModel steht noch ein offenes Undo rum: \"");
+
+ aStr += ByteString(pAktUndoGroup->GetComment(), gsl_getSystemTextEncoding());
+ aStr += '\"';
+
+ DBG_ERROR(aStr.GetBuffer());
+ }
+#endif
+ if (pAktUndoGroup!=NULL)
+ delete pAktUndoGroup;
+
+ // #116168#
+ ClearModel(sal_True);
+
+ delete pLayerAdmin;
+
+ // Den DrawOutliner erst nach dem ItemPool loeschen, da
+ // der ItemPool Items des DrawOutliners referenziert !!! (<- das war mal)
+ // Wg. Problem bei Malte Reihenfolge wieder umgestellt.
+ // Loeschen des Outliners vor dem loeschen des ItemPools
+ delete pHitTestOutliner;
+ delete pDrawOutliner;
+
+ // delete StyleSheetPool, derived classes should not do this since
+ // the DrawingEngine may need it in its destrctor (SB)
+ if( mxStyleSheetPool.is() )
+ {
+ Reference< XComponent > xComponent( dynamic_cast< cppu::OWeakObject* >( mxStyleSheetPool.get() ), UNO_QUERY );
+ if( xComponent.is() ) try
+ {
+ xComponent->dispose();
+ }
+ catch( RuntimeException& )
+ {
+ }
+ mxStyleSheetPool.clear();
+ }
+
+ if (bMyPool)
+ {
+ // Pools loeschen, falls es meine sind
+ SfxItemPool* pOutlPool=pItemPool->GetSecondaryPool();
+ SfxItemPool::Free(pItemPool);
+ // Der OutlinerPool muss nach dem ItemPool plattgemacht werden, da der
+ // ItemPool SetItems enthaelt die ihrerseits Items des OutlinerPools
+ // referenzieren (Joe)
+ SfxItemPool::Free(pOutlPool);
+ }
+
+ if( mpForbiddenCharactersTable )
+ mpForbiddenCharactersTable->release();
+
+ // Tabellen, Listen und Paletten loeschen
+ if (!bExtColorTable)
+ delete pColorTable;
+ delete pDashList;
+ delete pLineEndList;
+ delete pHatchList;
+ delete pGradientList;
+ delete pBitmapList;
+
+ if(mpNumberFormatter)
+ delete mpNumberFormatter;
+
+ delete mpImpl->mpUndoFactory;
+ delete mpImpl;
+}
+
+bool SdrModel::IsInDestruction() const
+{
+ return mbInDestruction;
+}
+
+const SvNumberFormatter& SdrModel::GetNumberFormatter() const
+{
+ if(!mpNumberFormatter)
+ {
+ // use cast here since from outside view this IS a const method
+ ((SdrModel*)this)->mpNumberFormatter = new SvNumberFormatter(
+ ::comphelper::getProcessServiceFactory(), LANGUAGE_SYSTEM);
+ }
+
+ return *mpNumberFormatter;
+}
+
+// noch nicht implementiert:
+void SdrModel::operator=(const SdrModel& /*rSrcModel*/)
+{
+ DBG_ERROR("SdrModel::operator=() ist noch nicht implementiert");
+}
+
+bool SdrModel::operator==(const SdrModel& /*rCmpModel*/) const
+{
+ DBG_ERROR("SdrModel::operator==() ist noch nicht implementiert");
+ return FALSE;
+}
+
+void SdrModel::SetSwapGraphics( bool bSwap )
+{
+ bSwapGraphics = bSwap;
+}
+
+bool SdrModel::IsReadOnly() const
+{
+ return bReadOnly;
+}
+
+void SdrModel::SetReadOnly(bool bYes)
+{
+ bReadOnly=bYes;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrModel::SetMaxUndoActionCount(ULONG nAnz)
+{
+ if (nAnz<1) nAnz=1;
+ nMaxUndoCount=nAnz;
+ if (pUndoStack!=NULL) {
+ while (pUndoStack->Count()>nMaxUndoCount) {
+ delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count());
+ }
+ }
+}
+
+void SdrModel::ClearUndoBuffer()
+{
+ if (pUndoStack!=NULL) {
+ while (pUndoStack->Count()!=0) {
+ delete (SfxUndoAction*) pUndoStack->Remove(pUndoStack->Count()-1);
+ }
+ delete pUndoStack;
+ pUndoStack=NULL;
+ }
+ if (pRedoStack!=NULL) {
+ while (pRedoStack->Count()!=0) {
+ delete (SfxUndoAction*) pRedoStack->Remove(pRedoStack->Count()-1);
+ }
+ delete pRedoStack;
+ pRedoStack=NULL;
+ }
+}
+
+bool SdrModel::Undo()
+{
+ bool bRet = false;
+ if( mpImpl->mpUndoManager )
+ {
+ DBG_ERROR("svx::SdrModel::Undo(), method not supported with application undo manager!");
+ }
+ else
+ {
+ SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0);
+ if(pDo!=NULL)
+ {
+ const bool bWasUndoEnabled = mbUndoEnabled;
+ mbUndoEnabled = false;
+ pDo->Undo();
+ if(pRedoStack==NULL)
+ pRedoStack=new Container(1024,16,16);
+ pRedoStack->Insert(pUndoStack->Remove((ULONG)0),(ULONG)0);
+ mbUndoEnabled = bWasUndoEnabled;
+ }
+ }
+ return bRet;
+}
+
+bool SdrModel::Redo()
+{
+ bool bRet=FALSE;
+ if( mpImpl->mpUndoManager )
+ {
+ DBG_ERROR("svx::SdrModel::Redo(), method not supported with application undo manager!");
+ }
+ else
+ {
+ SfxUndoAction* pDo=(SfxUndoAction*)GetRedoAction(0);
+ if(pDo!=NULL)
+ {
+ const bool bWasUndoEnabled = mbUndoEnabled;
+ mbUndoEnabled = false;
+ pDo->Redo();
+ if(pUndoStack==NULL)
+ pUndoStack=new Container(1024,16,16);
+ pUndoStack->Insert(pRedoStack->Remove((ULONG)0),(ULONG)0);
+ mbUndoEnabled = bWasUndoEnabled;
+ }
+ }
+ return bRet;
+}
+
+bool SdrModel::Repeat(SfxRepeatTarget& rView)
+{
+ bool bRet = false;
+ if( mpImpl->mpUndoManager )
+ {
+ DBG_ERROR("svx::SdrModel::Redo(), method not supported with application undo manager!");
+ }
+ else
+ {
+ SfxUndoAction* pDo=(SfxUndoAction*)GetUndoAction(0);
+ if(pDo!=NULL)
+ {
+ if(pDo->CanRepeat(rView))
+ {
+ pDo->Repeat(rView);
+ bRet = true;
+ }
+ }
+ }
+ return bRet;
+}
+
+void SdrModel::ImpPostUndoAction(SdrUndoAction* pUndo)
+{
+ DBG_ASSERT( mpImpl->mpUndoManager == 0, "svx::SdrModel::ImpPostUndoAction(), method not supported with application undo manager!" );
+ if( IsUndoEnabled() )
+ {
+ if (aUndoLink.IsSet())
+ {
+ aUndoLink.Call(pUndo);
+ }
+ else
+ {
+ if (pUndoStack==NULL)
+ pUndoStack=new Container(1024,16,16);
+ pUndoStack->Insert(pUndo,(ULONG)0);
+ while (pUndoStack->Count()>nMaxUndoCount)
+ {
+ delete (SfxUndoAction*)pUndoStack->Remove(pUndoStack->Count()-1);
+ }
+ if (pRedoStack!=NULL)
+ pRedoStack->Clear();
+ }
+ }
+ else
+ {
+ delete pUndo;
+ }
+}
+
+void SdrModel::BegUndo()
+{
+ if( mpImpl->mpUndoManager )
+ {
+ const String aEmpty;
+ mpImpl->mpUndoManager->EnterListAction(aEmpty,aEmpty);
+ nUndoLevel++;
+ }
+ else if( IsUndoEnabled() )
+ {
+ if(pAktUndoGroup==NULL)
+ {
+ pAktUndoGroup = new SdrUndoGroup(*this);
+ nUndoLevel=1;
+ }
+ else
+ {
+ nUndoLevel++;
+ }
+ }
+}
+
+void SdrModel::BegUndo(const XubString& rComment)
+{
+ if( mpImpl->mpUndoManager )
+ {
+ const String aEmpty;
+ mpImpl->mpUndoManager->EnterListAction( rComment, aEmpty );
+ nUndoLevel++;
+ }
+ else if( IsUndoEnabled() )
+ {
+ BegUndo();
+ if (nUndoLevel==1)
+ {
+ pAktUndoGroup->SetComment(rComment);
+ }
+ }
+}
+
+void SdrModel::BegUndo(const XubString& rComment, const XubString& rObjDescr, SdrRepeatFunc eFunc)
+{
+ if( mpImpl->mpUndoManager )
+ {
+ String aComment(rComment);
+ if( aComment.Len() && rObjDescr.Len() )
+ {
+ String aSearchString(RTL_CONSTASCII_USTRINGPARAM("%1"));
+ aComment.SearchAndReplace(aSearchString, rObjDescr);
+ }
+ const String aEmpty;
+ mpImpl->mpUndoManager->EnterListAction( aComment,aEmpty );
+ nUndoLevel++;
+ }
+ else if( IsUndoEnabled() )
+ {
+ BegUndo();
+ if (nUndoLevel==1)
+ {
+ pAktUndoGroup->SetComment(rComment);
+ pAktUndoGroup->SetObjDescription(rObjDescr);
+ pAktUndoGroup->SetRepeatFunction(eFunc);
+ }
+ }
+}
+
+void SdrModel::BegUndo(SdrUndoGroup* pUndoGrp)
+{
+ if( mpImpl->mpUndoManager )
+ {
+ DBG_ERROR("svx::SdrModel::BegUndo(), method not supported with application undo manager!" );
+ nUndoLevel++;
+ }
+ else if( IsUndoEnabled() )
+ {
+ if (pAktUndoGroup==NULL)
+ {
+ pAktUndoGroup=pUndoGrp;
+ nUndoLevel=1;
+ }
+ else
+ {
+ delete pUndoGrp;
+ nUndoLevel++;
+ }
+ }
+ else
+ {
+ delete pUndoGrp;
+ }
+}
+
+void SdrModel::EndUndo()
+{
+ DBG_ASSERT(nUndoLevel!=0,"SdrModel::EndUndo(): UndoLevel is already 0!");
+ if( mpImpl->mpUndoManager )
+ {
+ if( nUndoLevel )
+ {
+ nUndoLevel--;
+ mpImpl->mpUndoManager->LeaveListAction();
+ }
+ }
+ else
+ {
+ if(pAktUndoGroup!=NULL && IsUndoEnabled())
+ {
+ nUndoLevel--;
+ if(nUndoLevel==0)
+ {
+ if(pAktUndoGroup->GetActionCount()!=0)
+ {
+ SdrUndoAction* pUndo=pAktUndoGroup;
+ pAktUndoGroup=NULL;
+ ImpPostUndoAction(pUndo);
+ }
+ else
+ {
+ // was empty
+ delete pAktUndoGroup;
+ pAktUndoGroup=NULL;
+ }
+ }
+ }
+ }
+}
+
+void SdrModel::SetUndoComment(const XubString& rComment)
+{
+ DBG_ASSERT(nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is on level 0!");
+
+ if( mpImpl->mpUndoManager )
+ {
+ DBG_ERROR("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" );
+ }
+ else if( IsUndoEnabled() )
+ {
+ if(nUndoLevel==1)
+ {
+ pAktUndoGroup->SetComment(rComment);
+ }
+ }
+}
+
+void SdrModel::SetUndoComment(const XubString& rComment, const XubString& rObjDescr)
+{
+ DBG_ASSERT(nUndoLevel!=0,"SdrModel::SetUndoComment(): UndoLevel is 0!");
+ if( mpImpl->mpUndoManager )
+ {
+ DBG_ERROR("svx::SdrModel::SetUndoComment(), method not supported with application undo manager!" );
+ }
+ else
+ {
+ if (nUndoLevel==1)
+ {
+ pAktUndoGroup->SetComment(rComment);
+ pAktUndoGroup->SetObjDescription(rObjDescr);
+ }
+ }
+}
+
+void SdrModel::AddUndo(SdrUndoAction* pUndo)
+{
+ if( mpImpl->mpUndoManager )
+ {
+ mpImpl->mpUndoManager->AddUndoAction( pUndo );
+ }
+ else if( !IsUndoEnabled() )
+ {
+ delete pUndo;
+ }
+ else
+ {
+ if (pAktUndoGroup!=NULL)
+ {
+ pAktUndoGroup->AddAction(pUndo);
+ }
+ else
+ {
+ ImpPostUndoAction(pUndo);
+ }
+ }
+}
+
+void SdrModel::EnableUndo( bool bEnable )
+{
+ if( mpImpl->mpUndoManager )
+ {
+ mpImpl->mpUndoManager->EnableUndo( bEnable );
+ }
+ else
+ {
+ mbUndoEnabled = bEnable;
+ }
+}
+
+bool SdrModel::IsUndoEnabled() const
+{
+ if( mpImpl->mpUndoManager )
+ {
+ return mpImpl->mpUndoManager->IsUndoEnabled();
+ }
+ else
+ {
+ return mbUndoEnabled;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrModel::ImpCreateTables()
+{
+ // der Writer hat seinen eigenen ColorTable
+ if (!bExtColorTable) pColorTable=new XColorTable(aTablePath,(XOutdevItemPool*)pItemPool);
+ pDashList =new XDashList (aTablePath,(XOutdevItemPool*)pItemPool);
+ pLineEndList =new XLineEndList (aTablePath,(XOutdevItemPool*)pItemPool);
+ pHatchList =new XHatchList (aTablePath,(XOutdevItemPool*)pItemPool);
+ pGradientList=new XGradientList(aTablePath,(XOutdevItemPool*)pItemPool);
+ pBitmapList =new XBitmapList (aTablePath,(XOutdevItemPool*)pItemPool);
+}
+
+// #116168#
+void SdrModel::ClearModel(sal_Bool bCalledFromDestructor)
+{
+ if(bCalledFromDestructor)
+ {
+ mbInDestruction = true;
+ }
+
+ sal_Int32 i;
+ // delete all drawing pages
+ sal_Int32 nAnz=GetPageCount();
+ for (i=nAnz-1; i>=0; i--)
+ {
+ DeletePage( (USHORT)i );
+ }
+ maPages.Clear();
+ // #109538#
+ PageListChanged();
+
+ // delete all Masterpages
+ nAnz=GetMasterPageCount();
+ for(i=nAnz-1; i>=0; i--)
+ {
+ DeleteMasterPage( (USHORT)i );
+ }
+ maMaPag.Clear();
+ // #109538#
+ MasterPageListChanged();
+
+ pLayerAdmin->ClearLayer();
+}
+
+SdrModel* SdrModel::AllocModel() const
+{
+ SdrModel* pModel=new SdrModel;
+ pModel->SetScaleUnit(eObjUnit,aObjUnit);
+ return pModel;
+}
+
+SdrPage* SdrModel::AllocPage(bool bMasterPage)
+{
+ return new SdrPage(*this,bMasterPage);
+}
+
+void SdrModel::SetTextDefaults() const
+{
+ SetTextDefaults( pItemPool, nDefTextHgt );
+}
+
+void ImpGetDefaultFontsLanguage( SvxFontItem& rLatin, SvxFontItem& rAsian, SvxFontItem& rComplex)
+{
+ const USHORT nItemCnt = 3;
+ static struct {
+ USHORT nFntType, nLanguage;
+ } aOutTypeArr[ nItemCnt ] = {
+ { DEFAULTFONT_LATIN_TEXT, LANGUAGE_ENGLISH_US },
+ { DEFAULTFONT_CJK_TEXT, LANGUAGE_ENGLISH_US },
+ { DEFAULTFONT_CTL_TEXT, LANGUAGE_ARABIC_SAUDI_ARABIA }
+ };
+ SvxFontItem* aItemArr[ nItemCnt ] = { &rLatin, &rAsian, &rComplex };
+
+ for( USHORT n = 0; n < nItemCnt; ++n )
+ {
+ Font aFnt( OutputDevice::GetDefaultFont(
+ aOutTypeArr[ n ].nFntType, aOutTypeArr[ n ].nLanguage,
+ DEFAULTFONT_FLAGS_ONLYONE, 0 ));
+ SvxFontItem* pI = aItemArr[ n ];
+ pI->GetFamily() = aFnt.GetFamily();
+ pI->GetFamilyName() = aFnt.GetName();
+ pI->GetStyleName().Erase();
+ pI->GetPitch() = aFnt.GetPitch();
+ pI->GetCharSet() = aFnt.GetCharSet();
+ }
+}
+
+void SdrModel::SetTextDefaults( SfxItemPool* pItemPool, ULONG nDefTextHgt )
+{
+ // #95114# set application-language specific dynamic pool language defaults
+ SvxFontItem aSvxFontItem( EE_CHAR_FONTINFO) ;
+ SvxFontItem aSvxFontItemCJK(EE_CHAR_FONTINFO_CJK);
+ SvxFontItem aSvxFontItemCTL(EE_CHAR_FONTINFO_CTL);
+ sal_uInt16 nLanguage(Application::GetSettings().GetLanguage());
+
+ // get DEFAULTFONT_LATIN_TEXT and set at pool as dynamic default
+ Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_LATIN_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
+ aSvxFontItem.GetFamily() = aFont.GetFamily();
+ aSvxFontItem.GetFamilyName() = aFont.GetName();
+ aSvxFontItem.GetStyleName().Erase();
+ aSvxFontItem.GetPitch() = aFont.GetPitch();
+ aSvxFontItem.GetCharSet() = aFont.GetCharSet();
+ pItemPool->SetPoolDefaultItem(aSvxFontItem);
+
+ // get DEFAULTFONT_CJK_TEXT and set at pool as dynamic default
+ Font aFontCJK(OutputDevice::GetDefaultFont(DEFAULTFONT_CJK_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
+ aSvxFontItemCJK.GetFamily() = aFontCJK.GetFamily();
+ aSvxFontItemCJK.GetFamilyName() = aFontCJK.GetName();
+ aSvxFontItemCJK.GetStyleName().Erase();
+ aSvxFontItemCJK.GetPitch() = aFontCJK.GetPitch();
+ aSvxFontItemCJK.GetCharSet() = aFontCJK.GetCharSet();
+ pItemPool->SetPoolDefaultItem(aSvxFontItemCJK);
+
+ // get DEFAULTFONT_CTL_TEXT and set at pool as dynamic default
+ Font aFontCTL(OutputDevice::GetDefaultFont(DEFAULTFONT_CTL_TEXT, nLanguage, DEFAULTFONT_FLAGS_ONLYONE, 0));
+ aSvxFontItemCTL.GetFamily() = aFontCTL.GetFamily();
+ aSvxFontItemCTL.GetFamilyName() = aFontCTL.GetName();
+ aSvxFontItemCTL.GetStyleName().Erase();
+ aSvxFontItemCTL.GetPitch() = aFontCTL.GetPitch();
+ aSvxFontItemCTL.GetCharSet() = aFontCTL.GetCharSet();
+ pItemPool->SetPoolDefaultItem(aSvxFontItemCTL);
+
+ // set dynamic FontHeight defaults
+ pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT ) );
+ pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CJK ) );
+ pItemPool->SetPoolDefaultItem( SvxFontHeightItem(nDefTextHgt, 100, EE_CHAR_FONTHEIGHT_CTL ) );
+
+ // set FontColor defaults
+ pItemPool->SetPoolDefaultItem( SvxColorItem(SdrEngineDefaults::GetFontColor(), EE_CHAR_COLOR) );
+}
+
+SdrOutliner& SdrModel::GetDrawOutliner(const SdrTextObj* pObj) const
+{
+ pDrawOutliner->SetTextObj(pObj);
+ return *pDrawOutliner;
+}
+
+boost::shared_ptr< SdrOutliner > SdrModel::CreateDrawOutliner(const SdrTextObj* pObj)
+{
+ boost::shared_ptr< SdrOutliner > xDrawOutliner( SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, this ) );
+ ImpSetOutlinerDefaults(xDrawOutliner.get(), TRUE);
+ xDrawOutliner->SetTextObj(pObj);
+ return xDrawOutliner;
+}
+
+const SdrTextObj* SdrModel::GetFormattingTextObj() const
+{
+ if (pDrawOutliner!=NULL) {
+ return pDrawOutliner->GetTextObj();
+ }
+ return NULL;
+}
+
+void SdrModel::ImpSetOutlinerDefaults( SdrOutliner* pOutliner, BOOL bInit )
+{
+ /**************************************************************************
+ * Initialisierung der Outliner fuer Textausgabe und HitTest
+ **************************************************************************/
+ if( bInit )
+ {
+ pOutliner->EraseVirtualDevice();
+ pOutliner->SetUpdateMode(FALSE);
+ pOutliner->SetEditTextObjectPool(pItemPool);
+ pOutliner->SetDefTab(nDefaultTabulator);
+ }
+
+ pOutliner->SetRefDevice(GetRefDevice());
+ pOutliner->SetForbiddenCharsTable(GetForbiddenCharsTable());
+ pOutliner->SetAsianCompressionMode( mnCharCompressType );
+ pOutliner->SetKernAsianPunctuation( IsKernAsianPunctuation() );
+ pOutliner->SetAddExtLeading( IsAddExtLeading() );
+
+ if ( !GetRefDevice() )
+ {
+ MapMode aMapMode(eObjUnit, Point(0,0), aObjUnit, aObjUnit);
+ pOutliner->SetRefMapMode(aMapMode);
+ }
+}
+
+void SdrModel::SetRefDevice(OutputDevice* pDev)
+{
+ pRefOutDev=pDev;
+ ImpSetOutlinerDefaults( pDrawOutliner );
+ ImpSetOutlinerDefaults( pHitTestOutliner );
+ RefDeviceChanged();
+}
+
+void SdrModel::ImpReformatAllTextObjects()
+{
+ if( isLocked() )
+ return;
+
+ USHORT nAnz=GetMasterPageCount();
+ USHORT nNum;
+ for (nNum=0; nNum<nAnz; nNum++) {
+ GetMasterPage(nNum)->ReformatAllTextObjects();
+ }
+ nAnz=GetPageCount();
+ for (nNum=0; nNum<nAnz; nNum++) {
+ GetPage(nNum)->ReformatAllTextObjects();
+ }
+}
+
+/** #103122#
+ steps over all available pages and sends notify messages to
+ all edge objects that are connected to other objects so that
+ they may reposition itselfs
+*/
+void SdrModel::ImpReformatAllEdgeObjects()
+{
+ if( isLocked() )
+ return;
+
+ sal_uInt16 nAnz=GetMasterPageCount();
+ sal_uInt16 nNum;
+ for (nNum=0; nNum<nAnz; nNum++)
+ {
+ GetMasterPage(nNum)->ReformatAllEdgeObjects();
+ }
+ nAnz=GetPageCount();
+ for (nNum=0; nNum<nAnz; nNum++)
+ {
+ GetPage(nNum)->ReformatAllEdgeObjects();
+ }
+}
+
+SvStream* SdrModel::GetDocumentStream(SdrDocumentStreamInfo& /*rStreamInfo*/) const
+{
+ return NULL;
+}
+
+// Die Vorlagenattribute der Zeichenobjekte in harte Attribute verwandeln.
+void SdrModel::BurnInStyleSheetAttributes()
+{
+ USHORT nAnz=GetMasterPageCount();
+ USHORT nNum;
+ for (nNum=0; nNum<nAnz; nNum++) {
+ GetMasterPage(nNum)->BurnInStyleSheetAttributes();
+ }
+ nAnz=GetPageCount();
+ for (nNum=0; nNum<nAnz; nNum++) {
+ GetPage(nNum)->BurnInStyleSheetAttributes();
+ }
+}
+
+void SdrModel::RefDeviceChanged()
+{
+ Broadcast(SdrHint(HINT_REFDEVICECHG));
+ ImpReformatAllTextObjects();
+}
+
+void SdrModel::SetDefaultFontHeight(ULONG nVal)
+{
+ if (nVal!=nDefTextHgt) {
+ nDefTextHgt=nVal;
+ Broadcast(SdrHint(HINT_DEFFONTHGTCHG));
+ ImpReformatAllTextObjects();
+ }
+}
+
+void SdrModel::SetDefaultTabulator(USHORT nVal)
+{
+ if (nDefaultTabulator!=nVal) {
+ nDefaultTabulator=nVal;
+ Outliner& rOutliner=GetDrawOutliner();
+ rOutliner.SetDefTab(nVal);
+ Broadcast(SdrHint(HINT_DEFAULTTABCHG));
+ ImpReformatAllTextObjects();
+ }
+}
+
+void SdrModel::ImpSetUIUnit()
+{
+ if(0 == aUIScale.GetNumerator() || 0 == aUIScale.GetDenominator())
+ {
+ aUIScale = Fraction(1,1);
+ }
+
+ // set start values
+ nUIUnitKomma = 0;
+ sal_Int64 nMul(1);
+ sal_Int64 nDiv(1);
+
+ // normalize on meters resp. inch
+ switch (eObjUnit)
+ {
+ case MAP_100TH_MM : nUIUnitKomma+=5; break;
+ case MAP_10TH_MM : nUIUnitKomma+=4; break;
+ case MAP_MM : nUIUnitKomma+=3; break;
+ case MAP_CM : nUIUnitKomma+=2; break;
+ case MAP_1000TH_INCH: nUIUnitKomma+=3; break;
+ case MAP_100TH_INCH : nUIUnitKomma+=2; break;
+ case MAP_10TH_INCH : nUIUnitKomma+=1; break;
+ case MAP_INCH : nUIUnitKomma+=0; break;
+ case MAP_POINT : nDiv=72; break; // 1Pt = 1/72"
+ case MAP_TWIP : nDiv=144; nUIUnitKomma++; break; // 1Twip = 1/1440"
+ case MAP_PIXEL : break;
+ case MAP_SYSFONT : break;
+ case MAP_APPFONT : break;
+ case MAP_RELATIVE : break;
+ default: break;
+ } // switch
+
+ // 1 mile = 8 furlong = 63.360" = 1.609.344,0mm
+ // 1 furlong = 10 chains = 7.920" = 201.168,0mm
+ // 1 chain = 4 poles = 792" = 20.116,8mm
+ // 1 pole = 5 1/2 yd = 198" = 5.029,2mm
+ // 1 yd = 3 ft = 36" = 914,4mm
+ // 1 ft = 12 " = 1" = 304,8mm
+ switch (eUIUnit)
+ {
+ case FUNIT_NONE : break;
+ // Metrisch
+ case FUNIT_100TH_MM: nUIUnitKomma-=5; break;
+ case FUNIT_MM : nUIUnitKomma-=3; break;
+ case FUNIT_CM : nUIUnitKomma-=2; break;
+ case FUNIT_M : nUIUnitKomma+=0; break;
+ case FUNIT_KM : nUIUnitKomma+=3; break;
+ // Inch
+ case FUNIT_TWIP : nMul=144; nUIUnitKomma--; break; // 1Twip = 1/1440"
+ case FUNIT_POINT : nMul=72; break; // 1Pt = 1/72"
+ case FUNIT_PICA : nMul=6; break; // 1Pica = 1/6" ?
+ case FUNIT_INCH : break; // 1" = 1"
+ case FUNIT_FOOT : nDiv*=12; break; // 1Ft = 12"
+ case FUNIT_MILE : nDiv*=6336; nUIUnitKomma++; break; // 1mile = 63360"
+ // sonstiges
+ case FUNIT_CUSTOM : break;
+ case FUNIT_PERCENT: nUIUnitKomma+=2; break;
+ // TODO: Add code to handle the following if needed (added to removed warning)
+ case FUNIT_CHAR : break;
+ case FUNIT_LINE : break;
+ } // switch
+
+ // check if mapping is from metric to inch and adapt
+ const bool bMapInch(IsInch(eObjUnit));
+ const bool bUIMetr(IsMetric(eUIUnit));
+
+ if (bMapInch && bUIMetr)
+ {
+ nUIUnitKomma += 4;
+ nMul *= 254;
+ }
+
+ // check if mapping is from inch to metric and adapt
+ const bool bMapMetr(IsMetric(eObjUnit));
+ const bool bUIInch(IsInch(eUIUnit));
+
+ if (bMapMetr && bUIInch)
+ {
+ nUIUnitKomma -= 4;
+ nDiv *= 254;
+ }
+
+ // use temporary fraction for reduction (fallback to 32bit here),
+ // may need to be changed in the future, too
+ if(1 != nMul || 1 != nDiv)
+ {
+ const Fraction aTemp(static_cast< long >(nMul), static_cast< long >(nDiv));
+ nMul = aTemp.GetNumerator();
+ nDiv = aTemp.GetDenominator();
+ }
+
+ // #i89872# take Unit of Measurement into account
+ if(1 != aUIScale.GetDenominator() || 1 != aUIScale.GetNumerator())
+ {
+ // divide by UIScale
+ nMul *= aUIScale.GetDenominator();
+ nDiv *= aUIScale.GetNumerator();
+ }
+
+ // shorten trailing zeroes for dividend
+ while(0 == (nMul % 10))
+ {
+ nUIUnitKomma--;
+ nMul /= 10;
+ }
+
+ // shorten trailing zeroes for divisor
+ while(0 == (nDiv % 10))
+ {
+ nUIUnitKomma++;
+ nDiv /= 10;
+ }
+
+ // end preparations, set member values
+ aUIUnitFact = Fraction(sal_Int32(nMul), sal_Int32(nDiv));
+ bUIOnlyKomma = (nMul == nDiv);
+ TakeUnitStr(eUIUnit, aUIUnitStr);
+}
+
+void SdrModel::SetScaleUnit(MapUnit eMap, const Fraction& rFrac)
+{
+ if (eObjUnit!=eMap || aObjUnit!=rFrac) {
+ eObjUnit=eMap;
+ aObjUnit=rFrac;
+ pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
+ ImpSetUIUnit();
+ ImpSetOutlinerDefaults( pDrawOutliner );
+ ImpSetOutlinerDefaults( pHitTestOutliner );
+ ImpReformatAllTextObjects(); // #40424#
+ }
+}
+
+void SdrModel::SetScaleUnit(MapUnit eMap)
+{
+ if (eObjUnit!=eMap) {
+ eObjUnit=eMap;
+ pItemPool->SetDefaultMetric((SfxMapUnit)eObjUnit);
+ ImpSetUIUnit();
+ ImpSetOutlinerDefaults( pDrawOutliner );
+ ImpSetOutlinerDefaults( pHitTestOutliner );
+ ImpReformatAllTextObjects(); // #40424#
+ }
+}
+
+void SdrModel::SetScaleFraction(const Fraction& rFrac)
+{
+ if (aObjUnit!=rFrac) {
+ aObjUnit=rFrac;
+ ImpSetUIUnit();
+ ImpSetOutlinerDefaults( pDrawOutliner );
+ ImpSetOutlinerDefaults( pHitTestOutliner );
+ ImpReformatAllTextObjects(); // #40424#
+ }
+}
+
+void SdrModel::SetUIUnit(FieldUnit eUnit)
+{
+ if (eUIUnit!=eUnit) {
+ eUIUnit=eUnit;
+ ImpSetUIUnit();
+ ImpReformatAllTextObjects(); // #40424#
+ }
+}
+
+void SdrModel::SetUIScale(const Fraction& rScale)
+{
+ if (aUIScale!=rScale) {
+ aUIScale=rScale;
+ ImpSetUIUnit();
+ ImpReformatAllTextObjects(); // #40424#
+ }
+}
+
+void SdrModel::SetUIUnit(FieldUnit eUnit, const Fraction& rScale)
+{
+ if (eUIUnit!=eUnit || aUIScale!=rScale) {
+ eUIUnit=eUnit;
+ aUIScale=rScale;
+ ImpSetUIUnit();
+ ImpReformatAllTextObjects(); // #40424#
+ }
+}
+
+void SdrModel::TakeUnitStr(FieldUnit eUnit, XubString& rStr)
+{
+ switch(eUnit)
+ {
+ default:
+ case FUNIT_NONE :
+ case FUNIT_CUSTOM :
+ {
+ rStr = String();
+ break;
+ }
+ case FUNIT_100TH_MM:
+ {
+ sal_Char aText[] = "/100mm";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_MM :
+ {
+ sal_Char aText[] = "mm";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_CM :
+ {
+ sal_Char aText[] = "cm";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_M :
+ {
+ rStr = String();
+ rStr += sal_Unicode('m');
+ break;
+ }
+ case FUNIT_KM :
+ {
+ sal_Char aText[] = "km";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_TWIP :
+ {
+ sal_Char aText[] = "twip";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_POINT :
+ {
+ sal_Char aText[] = "pt";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_PICA :
+ {
+ sal_Char aText[] = "pica";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_INCH :
+ {
+ rStr = String();
+ rStr += sal_Unicode('"');
+ break;
+ }
+ case FUNIT_FOOT :
+ {
+ sal_Char aText[] = "ft";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_MILE :
+ {
+ sal_Char aText[] = "mile(s)";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_PERCENT:
+ {
+ rStr = String();
+ rStr += sal_Unicode('%');
+ break;
+ }
+ }
+}
+
+void SdrModel::TakeMetricStr(long nVal, XubString& rStr, bool bNoUnitChars, sal_Int32 nNumDigits) const
+{
+ // #i22167#
+ // change to double precision usage to not loose decimal places after comma
+ const bool bNegative(nVal < 0L);
+ SvtSysLocale aSysLoc;
+ const LocaleDataWrapper& rLoc(aSysLoc.GetLocaleData());
+ double fLocalValue(double(nVal) * double(aUIUnitFact));
+
+ if(bNegative)
+ {
+ fLocalValue = -fLocalValue;
+ }
+
+ if( -1 == nNumDigits )
+ {
+ nNumDigits = rLoc.getNumDigits();
+ }
+
+ sal_Int32 nKomma(nUIUnitKomma);
+
+ if(nKomma > nNumDigits)
+ {
+ const sal_Int32 nDiff(nKomma - nNumDigits);
+ const double fFactor(pow(10.0, static_cast<const int>(nDiff)));
+
+ fLocalValue /= fFactor;
+ nKomma = nNumDigits;
+ }
+ else if(nKomma < nNumDigits)
+ {
+ const sal_Int32 nDiff(nNumDigits - nKomma);
+ const double fFactor(pow(10.0, static_cast<const int>(nDiff)));
+
+ fLocalValue *= fFactor;
+ nKomma = nNumDigits;
+ }
+
+ rStr = UniString::CreateFromInt32(static_cast<sal_Int32>(fLocalValue + 0.5));
+
+ if(nKomma < 0)
+ {
+ // Negatives Komma bedeutet: Nullen dran
+ sal_Int32 nAnz(-nKomma);
+
+ for(sal_Int32 i=0; i<nAnz; i++)
+ rStr += sal_Unicode('0');
+
+ nKomma = 0;
+ }
+
+ // #83257# the second condition needs to be <= since inside this loop
+ // also the leading zero is inserted.
+ if(nKomma > 0 && rStr.Len() <= nKomma)
+ {
+ // Fuer Komma evtl. vorne Nullen dran
+ sal_Int32 nAnz(nKomma - rStr.Len());
+
+ if(nAnz >= 0 && rLoc.isNumLeadingZero())
+ nAnz++;
+
+ for(sal_Int32 i=0; i<nAnz; i++)
+ rStr.Insert(sal_Unicode('0'), 0);
+ }
+
+ sal_Unicode cDec( rLoc.getNumDecimalSep().GetChar(0) );
+
+ // KommaChar einfuegen
+ sal_Int32 nVorKomma(rStr.Len() - nKomma);
+
+ if(nKomma > 0)
+ rStr.Insert(cDec, (xub_StrLen) nVorKomma);
+
+ if(!rLoc.isNumTrailingZeros())
+ {
+ while(rStr.Len() && rStr.GetChar(rStr.Len() - 1) == sal_Unicode('0'))
+ rStr.Erase(rStr.Len() - 1);
+
+ if(rStr.Len() && rStr.GetChar(rStr.Len() - 1) == cDec)
+ rStr.Erase(rStr.Len() - 1);
+ }
+
+ // ggf. Trennpunkte bei jedem Tausender einfuegen
+ if( nVorKomma > 3 )
+ {
+ String aThoSep( rLoc.getNumThousandSep() );
+ if ( aThoSep.Len() > 0 )
+ {
+ sal_Unicode cTho( aThoSep.GetChar(0) );
+ sal_Int32 i(nVorKomma - 3);
+
+ while(i > 0) // #78311#
+ {
+ rStr.Insert(cTho, (xub_StrLen)i);
+ i -= 3;
+ }
+ }
+ }
+
+ if(!rStr.Len())
+ {
+ rStr = String();
+ rStr += sal_Unicode('0');
+ }
+
+ if(bNegative)
+ {
+ rStr.Insert(sal_Unicode('-'), 0);
+ }
+
+ if(!bNoUnitChars)
+ rStr += aUIUnitStr;
+}
+
+void SdrModel::TakeWinkStr(long nWink, XubString& rStr, bool bNoDegChar) const
+{
+ BOOL bNeg(nWink < 0);
+
+ if(bNeg)
+ nWink = -nWink;
+
+ rStr = UniString::CreateFromInt32(nWink);
+
+ SvtSysLocale aSysLoc;
+ const LocaleDataWrapper& rLoc = aSysLoc.GetLocaleData();
+ xub_StrLen nAnz(2);
+
+ if(rLoc.isNumLeadingZero())
+ nAnz++;
+
+ while(rStr.Len() < nAnz)
+ rStr.Insert(sal_Unicode('0'), 0);
+
+ rStr.Insert(rLoc.getNumDecimalSep().GetChar(0), rStr.Len() - 2);
+
+ if(bNeg)
+ rStr.Insert(sal_Unicode('-'), 0);
+
+ if(!bNoDegChar)
+ rStr += DEGREE_CHAR;
+}
+
+void SdrModel::TakePercentStr(const Fraction& rVal, XubString& rStr, bool bNoPercentChar) const
+{
+ INT32 nMul(rVal.GetNumerator());
+ INT32 nDiv(rVal.GetDenominator());
+ BOOL bNeg(nMul < 0);
+
+ if(nDiv < 0)
+ bNeg = !bNeg;
+
+ if(nMul < 0)
+ nMul = -nMul;
+
+ if(nDiv < 0)
+ nDiv = -nDiv;
+
+ nMul *= 100;
+ nMul += nDiv/2;
+ nMul /= nDiv;
+
+ rStr = UniString::CreateFromInt32(nMul);
+
+ if(bNeg)
+ rStr.Insert(sal_Unicode('-'), 0);
+
+ if(!bNoPercentChar)
+ rStr += sal_Unicode('%');
+}
+
+void SdrModel::SetChanged(sal_Bool bFlg)
+{
+ mbChanged = bFlg;
+}
+
+void SdrModel::RecalcPageNums(bool bMaster)
+{
+ Container& rPL=*(bMaster ? &maMaPag : &maPages);
+ USHORT nAnz=USHORT(rPL.Count());
+ USHORT i;
+ for (i=0; i<nAnz; i++) {
+ SdrPage* pPg=(SdrPage*)(rPL.GetObject(i));
+ pPg->SetPageNum(i);
+ }
+ if (bMaster) bMPgNumsDirty=FALSE;
+ else bPagNumsDirty=FALSE;
+}
+
+void SdrModel::InsertPage(SdrPage* pPage, USHORT nPos)
+{
+ USHORT nAnz=GetPageCount();
+ if (nPos>nAnz) nPos=nAnz;
+ maPages.Insert(pPage,nPos);
+ // #109538#
+ PageListChanged();
+ pPage->SetInserted(TRUE);
+ pPage->SetPageNum(nPos);
+ pPage->SetModel(this);
+ if (nPos<nAnz) bPagNumsDirty=TRUE;
+ SetChanged();
+ SdrHint aHint(HINT_PAGEORDERCHG);
+ aHint.SetPage(pPage);
+ Broadcast(aHint);
+}
+
+void SdrModel::DeletePage(USHORT nPgNum)
+{
+ SdrPage* pPg=RemovePage(nPgNum);
+ delete pPg;
+}
+
+SdrPage* SdrModel::RemovePage(USHORT nPgNum)
+{
+ SdrPage* pPg=(SdrPage*)maPages.Remove(nPgNum);
+ // #109538#
+ PageListChanged();
+ if (pPg!=NULL) {
+ pPg->SetInserted(FALSE);
+ }
+ bPagNumsDirty=TRUE;
+ SetChanged();
+ SdrHint aHint(HINT_PAGEORDERCHG);
+ aHint.SetPage(pPg);
+ Broadcast(aHint);
+ return pPg;
+}
+
+void SdrModel::MovePage(USHORT nPgNum, USHORT nNewPos)
+{
+ SdrPage* pPg=(SdrPage*)maPages.Remove(nPgNum);
+ // #109538#
+ PageListChanged();
+ if (pPg!=NULL) {
+ pPg->SetInserted(FALSE);
+ InsertPage(pPg,nNewPos);
+ }
+}
+
+void SdrModel::InsertMasterPage(SdrPage* pPage, USHORT nPos)
+{
+ USHORT nAnz=GetMasterPageCount();
+ if (nPos>nAnz) nPos=nAnz;
+ maMaPag.Insert(pPage,nPos);
+ // #109538#
+ MasterPageListChanged();
+ pPage->SetInserted(TRUE);
+ pPage->SetPageNum(nPos);
+ pPage->SetModel(this);
+ if (nPos<nAnz) {
+ bMPgNumsDirty=TRUE;
+ }
+ SetChanged();
+ SdrHint aHint(HINT_PAGEORDERCHG);
+ aHint.SetPage(pPage);
+ Broadcast(aHint);
+}
+
+void SdrModel::DeleteMasterPage(USHORT nPgNum)
+{
+ SdrPage* pPg=RemoveMasterPage(nPgNum);
+ if (pPg!=NULL) delete pPg;
+}
+
+SdrPage* SdrModel::RemoveMasterPage(USHORT nPgNum)
+{
+ SdrPage* pRetPg=(SdrPage*)maMaPag.Remove(nPgNum);
+ // #109538#
+ MasterPageListChanged();
+
+ if(pRetPg)
+ {
+ // Nun die Verweise der normalen Zeichenseiten auf die entfernte MasterPage loeschen
+ sal_uInt16 nPageAnz(GetPageCount());
+
+ for(sal_uInt16 np(0); np < nPageAnz; np++)
+ {
+ GetPage(np)->TRG_ImpMasterPageRemoved(*pRetPg);
+ }
+
+ pRetPg->SetInserted(FALSE);
+ }
+
+ bMPgNumsDirty=TRUE;
+ SetChanged();
+ SdrHint aHint(HINT_PAGEORDERCHG);
+ aHint.SetPage(pRetPg);
+ Broadcast(aHint);
+ return pRetPg;
+}
+
+void SdrModel::MoveMasterPage(USHORT nPgNum, USHORT nNewPos)
+{
+ SdrPage* pPg=(SdrPage*)maMaPag.Remove(nPgNum);
+ // #109538#
+ MasterPageListChanged();
+ if (pPg!=NULL) {
+ pPg->SetInserted(FALSE);
+ maMaPag.Insert(pPg,nNewPos);
+ // #109538#
+ MasterPageListChanged();
+ }
+ bMPgNumsDirty=TRUE;
+ SetChanged();
+ SdrHint aHint(HINT_PAGEORDERCHG);
+ aHint.SetPage(pPg);
+ Broadcast(aHint);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrModel::CheckConsistence() const
+{
+ bool bRet = true;
+#ifdef DBG_UTIL
+ DBG_CHKTHIS(SdrModel,NULL);
+#endif
+ return bRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// #48289#
+void SdrModel::CopyPages(USHORT nFirstPageNum, USHORT nLastPageNum,
+ USHORT nDestPos,
+ bool bUndo, bool bMoveNoCopy)
+{
+ if( bUndo && !IsUndoEnabled() )
+ bUndo = false;
+
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_UndoMergeModel));
+
+ USHORT nPageAnz=GetPageCount();
+ USHORT nMaxPage=nPageAnz;
+
+ if (nMaxPage!=0)
+ nMaxPage--;
+ if (nFirstPageNum>nMaxPage)
+ nFirstPageNum=nMaxPage;
+ if (nLastPageNum>nMaxPage)
+ nLastPageNum =nMaxPage;
+ bool bReverse=nLastPageNum<nFirstPageNum;
+ if (nDestPos>nPageAnz)
+ nDestPos=nPageAnz;
+
+ // Zunaechst die Zeiger der betroffenen Seiten in einem Array sichern
+ USHORT nPageNum=nFirstPageNum;
+ USHORT nCopyAnz=((!bReverse)?(nLastPageNum-nFirstPageNum):(nFirstPageNum-nLastPageNum))+1;
+ SdrPage** pPagePtrs=new SdrPage*[nCopyAnz];
+ USHORT nCopyNum;
+ for(nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++)
+ {
+ pPagePtrs[nCopyNum]=GetPage(nPageNum);
+ if (bReverse)
+ nPageNum--;
+ else
+ nPageNum++;
+ }
+
+ // Jetzt die Seiten kopieren
+ USHORT nDestNum=nDestPos;
+ for (nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++)
+ {
+ SdrPage* pPg=pPagePtrs[nCopyNum];
+ USHORT nPageNum2=pPg->GetPageNum();
+ if (!bMoveNoCopy)
+ {
+ const SdrPage* pPg1=GetPage(nPageNum2);
+ pPg=pPg1->Clone();
+ InsertPage(pPg,nDestNum);
+ if (bUndo)
+ AddUndo(GetSdrUndoFactory().CreateUndoCopyPage(*pPg));
+ nDestNum++;
+ }
+ else
+ {
+ // Move ist nicht getestet!
+ if (nDestNum>nPageNum2)
+ nDestNum--;
+
+ if(bUndo)
+ AddUndo(GetSdrUndoFactory().CreateUndoSetPageNum(*GetPage(nPageNum2),nPageNum2,nDestNum));
+
+ pPg=RemovePage(nPageNum2);
+ InsertPage(pPg,nDestNum);
+ nDestNum++;
+ }
+
+ if(bReverse)
+ nPageNum2--;
+ else
+ nPageNum2++;
+ }
+
+ delete[] pPagePtrs;
+ if(bUndo)
+ EndUndo();
+}
+
+void SdrModel::Merge(SdrModel& rSourceModel,
+ USHORT nFirstPageNum, USHORT nLastPageNum,
+ USHORT nDestPos,
+ bool bMergeMasterPages, bool bAllMasterPages,
+ bool bUndo, bool bTreadSourceAsConst)
+{
+ if (&rSourceModel==this)
+ { // #48289#
+ CopyPages(nFirstPageNum,nLastPageNum,nDestPos,bUndo,!bTreadSourceAsConst);
+ return;
+ }
+
+ if( bUndo && !IsUndoEnabled() )
+ bUndo = false;
+
+ if (bUndo)
+ BegUndo(ImpGetResStr(STR_UndoMergeModel));
+
+ USHORT nSrcPageAnz=rSourceModel.GetPageCount();
+ USHORT nSrcMasterPageAnz=rSourceModel.GetMasterPageCount();
+ USHORT nDstMasterPageAnz=GetMasterPageCount();
+ bool bInsPages=(nFirstPageNum<nSrcPageAnz || nLastPageNum<nSrcPageAnz);
+ USHORT nMaxSrcPage=nSrcPageAnz; if (nMaxSrcPage!=0) nMaxSrcPage--;
+ if (nFirstPageNum>nMaxSrcPage) nFirstPageNum=nMaxSrcPage;
+ if (nLastPageNum>nMaxSrcPage) nLastPageNum =nMaxSrcPage;
+ bool bReverse=nLastPageNum<nFirstPageNum;
+
+ USHORT* pMasterMap=NULL;
+ bool* pMasterNeed=NULL;
+ USHORT nMasterNeed=0;
+ if (bMergeMasterPages && nSrcMasterPageAnz!=0) {
+ // Feststellen, welche MasterPages aus rSrcModel benoetigt werden
+ pMasterMap=new USHORT[nSrcMasterPageAnz];
+ pMasterNeed=new bool[nSrcMasterPageAnz];
+ memset(pMasterMap,0xFF,nSrcMasterPageAnz*sizeof(USHORT));
+ if (bAllMasterPages) {
+ memset(pMasterNeed, true, nSrcMasterPageAnz * sizeof(bool));
+ } else {
+ memset(pMasterNeed, false, nSrcMasterPageAnz * sizeof(bool));
+ USHORT nAnf= bReverse ? nLastPageNum : nFirstPageNum;
+ USHORT nEnd= bReverse ? nFirstPageNum : nLastPageNum;
+ for (USHORT i=nAnf; i<=nEnd; i++) {
+ const SdrPage* pPg=rSourceModel.GetPage(i);
+ if(pPg->TRG_HasMasterPage())
+ {
+ SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
+ sal_uInt16 nMPgNum(rMasterPage.GetPageNum());
+
+ if(nMPgNum < nSrcMasterPageAnz)
+ {
+ pMasterNeed[nMPgNum] = true;
+ }
+ }
+ }
+ }
+ // Nun das Mapping der MasterPages bestimmen
+ USHORT nAktMaPagNum=nDstMasterPageAnz;
+ for (USHORT i=0; i<nSrcMasterPageAnz; i++) {
+ if (pMasterNeed[i]) {
+ pMasterMap[i]=nAktMaPagNum;
+ nAktMaPagNum++;
+ nMasterNeed++;
+ }
+ }
+ }
+
+ // rueberholen der Masterpages
+ if (pMasterMap!=NULL && pMasterNeed!=NULL && nMasterNeed!=0) {
+ for (USHORT i=nSrcMasterPageAnz; i>0;) {
+ i--;
+ if (pMasterNeed[i]) {
+ SdrPage* pPg=NULL;
+ if (bTreadSourceAsConst) {
+ const SdrPage* pPg1=rSourceModel.GetMasterPage(i);
+ pPg=pPg1->Clone();
+ } else {
+ pPg=rSourceModel.RemoveMasterPage(i);
+ }
+ if (pPg!=NULL) {
+ // und alle ans einstige Ende des DstModel reinschieben.
+ // nicht InsertMasterPage() verwenden da die Sache
+ // inkonsistent ist bis alle drin sind
+ maMaPag.Insert(pPg,nDstMasterPageAnz);
+ // #109538#
+ MasterPageListChanged();
+ pPg->SetInserted(TRUE);
+ pPg->SetModel(this);
+ bMPgNumsDirty=TRUE;
+ if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
+ } else {
+ DBG_ERROR("SdrModel::Merge(): MasterPage im SourceModel nicht gefunden");
+ }
+ }
+ }
+ }
+
+ // rueberholen der Zeichenseiten
+ if (bInsPages) {
+ USHORT nSourcePos=nFirstPageNum;
+ USHORT nMergeCount=USHORT(Abs((long)((long)nFirstPageNum-nLastPageNum))+1);
+ if (nDestPos>GetPageCount()) nDestPos=GetPageCount();
+ while (nMergeCount>0) {
+ SdrPage* pPg=NULL;
+ if (bTreadSourceAsConst) {
+ const SdrPage* pPg1=rSourceModel.GetPage(nSourcePos);
+ pPg=pPg1->Clone();
+ } else {
+ pPg=rSourceModel.RemovePage(nSourcePos);
+ }
+ if (pPg!=NULL) {
+ InsertPage(pPg,nDestPos);
+ if (bUndo) AddUndo(GetSdrUndoFactory().CreateUndoNewPage(*pPg));
+ // und nun zu den MasterPageDescriptoren
+
+ if(pPg->TRG_HasMasterPage())
+ {
+ SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
+ sal_uInt16 nMaPgNum(rMasterPage.GetPageNum());
+
+ if (bMergeMasterPages)
+ {
+ sal_uInt16 nNeuNum(0xFFFF);
+
+ if(pMasterMap)
+ {
+ nNeuNum = pMasterMap[nMaPgNum];
+ }
+
+ if(nNeuNum != 0xFFFF)
+ {
+ if(bUndo)
+ {
+ AddUndo(GetSdrUndoFactory().CreateUndoPageChangeMasterPage(*pPg));
+ }
+
+ pPg->TRG_SetMasterPage(*GetMasterPage(nNeuNum));
+ }
+ DBG_ASSERT(nNeuNum!=0xFFFF,"SdrModel::Merge(): Irgendwas ist krumm beim Mappen der MasterPages");
+ } else {
+ if (nMaPgNum>=nDstMasterPageAnz) {
+ // Aha, die ist ausserbalb des urspruenglichen Bereichs der Masterpages des DstModel
+ pPg->TRG_ClearMasterPage();
+ }
+ }
+ }
+
+ } else {
+ DBG_ERROR("SdrModel::Merge(): Zeichenseite im SourceModel nicht gefunden");
+ }
+ nDestPos++;
+ if (bReverse) nSourcePos--;
+ else if (bTreadSourceAsConst) nSourcePos++;
+ nMergeCount--;
+ }
+ }
+
+ delete [] pMasterMap;
+ delete [] pMasterNeed;
+
+ bMPgNumsDirty=TRUE;
+ bPagNumsDirty=TRUE;
+
+ SetChanged();
+ // Fehlt: Mergen und Mapping der Layer
+ // an den Objekten sowie an den MasterPageDescriptoren
+ if (bUndo) EndUndo();
+}
+
+void SdrModel::SetStarDrawPreviewMode(BOOL bPreview)
+{
+ if (!bPreview && bStarDrawPreviewMode && GetPageCount())
+ {
+ // Das Zuruecksetzen ist nicht erlaubt, da das Model ev. nicht vollstaendig geladen wurde
+ DBG_ASSERT(FALSE,"SdrModel::SetStarDrawPreviewMode(): Zuruecksetzen nicht erlaubt, da Model ev. nicht vollstaendig");
+ }
+ else
+ {
+ bStarDrawPreviewMode = bPreview;
+ }
+}
+
+uno::Reference< uno::XInterface > SdrModel::getUnoModel()
+{
+ if( !mxUnoModel.is() )
+ mxUnoModel = createUnoModel();
+
+ return mxUnoModel;
+}
+
+void SdrModel::setUnoModel( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xModel )
+{
+ mxUnoModel = xModel;
+}
+
+uno::Reference< uno::XInterface > SdrModel::createUnoModel()
+{
+ DBG_ERROR( "SdrModel::createUnoModel() - base implementation should not be called!" );
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInt;
+ return xInt;
+}
+
+void SdrModel::setLock( BOOL bLock )
+{
+ if( mbModelLocked != bLock )
+ {
+ if( sal_False == bLock )
+ {
+ // ReformatAllTextObjects(); #103122# due to a typo in the above if, this code was never
+ // executed, so I remove it until we discover that we need it here
+ ImpReformatAllEdgeObjects(); // #103122#
+ }
+ mbModelLocked = bLock;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrModel::MigrateItemSet( const SfxItemSet* pSourceSet, SfxItemSet* pDestSet, SdrModel* pNewModel )
+{
+ if( pSourceSet && pDestSet && (pSourceSet != pDestSet ) )
+ {
+ if( pNewModel == NULL )
+ pNewModel = this;
+
+ SfxWhichIter aWhichIter(*pSourceSet);
+ sal_uInt16 nWhich(aWhichIter.FirstWhich());
+ const SfxPoolItem *pPoolItem;
+
+ while(nWhich)
+ {
+ if(SFX_ITEM_SET == pSourceSet->GetItemState(nWhich, FALSE, &pPoolItem))
+ {
+ const SfxPoolItem* pItem = pPoolItem;
+
+ switch( nWhich )
+ {
+ case XATTR_FILLBITMAP:
+ pItem = ((XFillBitmapItem*)pItem)->checkForUniqueItem( pNewModel );
+ break;
+ case XATTR_LINEDASH:
+ pItem = ((XLineDashItem*)pItem)->checkForUniqueItem( pNewModel );
+ break;
+ case XATTR_LINESTART:
+ pItem = ((XLineStartItem*)pItem)->checkForUniqueItem( pNewModel );
+ break;
+ case XATTR_LINEEND:
+ pItem = ((XLineEndItem*)pItem)->checkForUniqueItem( pNewModel );
+ break;
+ case XATTR_FILLGRADIENT:
+ pItem = ((XFillGradientItem*)pItem)->checkForUniqueItem( pNewModel );
+ break;
+ case XATTR_FILLFLOATTRANSPARENCE:
+ // #85953# allow all kinds of XFillFloatTransparenceItem to be set
+ pItem = ((XFillFloatTransparenceItem*)pItem)->checkForUniqueItem( pNewModel );
+ break;
+ case XATTR_FILLHATCH:
+ pItem = ((XFillHatchItem*)pItem)->checkForUniqueItem( pNewModel );
+ break;
+ }
+
+ // set item
+ if( pItem )
+ {
+ pDestSet->Put(*pItem);
+
+ // delete item if it was a generated one
+ if( pItem != pPoolItem)
+ delete (SfxPoolItem*)pItem;
+ }
+ }
+ nWhich = aWhichIter.NextWhich();
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrModel::SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars )
+{
+ if( mpForbiddenCharactersTable )
+ mpForbiddenCharactersTable->release();
+
+ mpForbiddenCharactersTable = xForbiddenChars.get();
+
+ if( mpForbiddenCharactersTable )
+ mpForbiddenCharactersTable->acquire();
+
+ ImpSetOutlinerDefaults( pDrawOutliner );
+ ImpSetOutlinerDefaults( pHitTestOutliner );
+}
+
+rtl::Reference<SvxForbiddenCharactersTable> SdrModel::GetForbiddenCharsTable() const
+{
+ return mpForbiddenCharactersTable;
+}
+
+void SdrModel::SetCharCompressType( UINT16 nType )
+{
+ if( nType != mnCharCompressType )
+ {
+ mnCharCompressType = nType;
+ ImpSetOutlinerDefaults( pDrawOutliner );
+ ImpSetOutlinerDefaults( pHitTestOutliner );
+ }
+}
+
+void SdrModel::SetKernAsianPunctuation( sal_Bool bEnabled )
+{
+ if( mbKernAsianPunctuation != bEnabled )
+ {
+ mbKernAsianPunctuation = bEnabled;
+ ImpSetOutlinerDefaults( pDrawOutliner );
+ ImpSetOutlinerDefaults( pHitTestOutliner );
+ }
+}
+
+void SdrModel::SetAddExtLeading( sal_Bool bEnabled )
+{
+ if( mbAddExtLeading != bEnabled )
+ {
+ mbAddExtLeading = bEnabled;
+ ImpSetOutlinerDefaults( pDrawOutliner );
+ ImpSetOutlinerDefaults( pHitTestOutliner );
+ }
+}
+
+void SdrModel::ReformatAllTextObjects()
+{
+ ImpReformatAllTextObjects();
+}
+
+bool SdrModel::HasTransparentObjects( BOOL bCheckForAlphaChannel ) const
+{
+ bool bRet = false;
+ USHORT n, nCount;
+
+ for( n = 0, nCount = GetMasterPageCount(); ( n < nCount ) && !bRet; n++ )
+ if( GetMasterPage( n )->HasTransparentObjects( bCheckForAlphaChannel ) )
+ bRet = true;
+
+ if( !bRet )
+ {
+ for( n = 0, nCount = GetPageCount(); ( n < nCount ) && !bRet; n++ )
+ if( GetPage( n )->HasTransparentObjects( bCheckForAlphaChannel ) )
+ bRet = true;
+ }
+
+ return bRet;
+}
+
+SdrOutliner* SdrModel::createOutliner( USHORT nOutlinerMode )
+{
+ if( NULL == mpOutlinerCache )
+ mpOutlinerCache = new SdrOutlinerCache(this);
+
+ return mpOutlinerCache->createOutliner( nOutlinerMode );
+}
+
+void SdrModel::disposeOutliner( SdrOutliner* pOutliner )
+{
+ if( mpOutlinerCache )
+ {
+ mpOutlinerCache->disposeOutliner( pOutliner );
+ }
+ else
+ {
+ delete pOutliner;
+ }
+}
+
+SvxNumType SdrModel::GetPageNumType() const
+{
+ return SVX_ARABIC;
+}
+
+const SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum) const
+{
+ DBG_ASSERT(nPgNum < maPages.Count(), "SdrModel::GetPage: Access out of range (!)");
+ return (SdrPage*)(maPages.GetObject(nPgNum));
+}
+
+SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum)
+{
+ DBG_ASSERT(nPgNum < maPages.Count(), "SdrModel::GetPage: Access out of range (!)");
+ return (SdrPage*)(maPages.GetObject(nPgNum));
+}
+
+sal_uInt16 SdrModel::GetPageCount() const
+{
+ return sal_uInt16(maPages.Count());
+}
+
+void SdrModel::PageListChanged()
+{
+}
+
+const SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum) const
+{
+ DBG_ASSERT(nPgNum < maMaPag.Count(), "SdrModel::GetMasterPage: Access out of range (!)");
+ return (SdrPage*)(maMaPag.GetObject(nPgNum));
+}
+
+SdrPage* SdrModel::GetMasterPage(sal_uInt16 nPgNum)
+{
+ DBG_ASSERT(nPgNum < maMaPag.Count(), "SdrModel::GetMasterPage: Access out of range (!)");
+ return (SdrPage*)(maMaPag.GetObject(nPgNum));
+}
+
+sal_uInt16 SdrModel::GetMasterPageCount() const
+{
+ return sal_uInt16(maMaPag.Count());
+}
+
+void SdrModel::MasterPageListChanged()
+{
+}
+
+void SdrModel::SetSdrUndoManager( SfxUndoManager* pUndoManager )
+{
+ mpImpl->mpUndoManager = pUndoManager;
+}
+
+SdrUndoFactory& SdrModel::GetSdrUndoFactory() const
+{
+ if( !mpImpl->mpUndoFactory )
+ mpImpl->mpUndoFactory = new SdrUndoFactory;
+ return *mpImpl->mpUndoFactory;
+}
+
+void SdrModel::SetSdrUndoFactory( SdrUndoFactory* pUndoFactory )
+{
+ if( pUndoFactory && (pUndoFactory != mpImpl->mpUndoFactory) )
+ {
+ delete mpImpl->mpUndoFactory;
+ mpImpl->mpUndoFactory = pUndoFactory;
+ }
+}
+
+/** cl: added this for OJ to complete his reporting engine, does not work
+ correctly so only enable it for his model */
+bool SdrModel::IsAllowShapePropertyChangeListener() const
+{
+ return mpImpl && mpImpl->mbAllowShapePropertyChangeListener;
+}
+
+void SdrModel::SetAllowShapePropertyChangeListener( bool bAllow )
+{
+ if( mpImpl )
+ {
+ mpImpl->mbAllowShapePropertyChangeListener = bAllow;
+ }
+}
+
+const ::com::sun::star::uno::Sequence< sal_Int8 >& SdrModel::getUnoTunnelImplementationId()
+{
+ static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0;
+ if( !pSeq )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrHint,SfxHint);
+
+SdrHint::SdrHint()
+: mpPage(0L),
+ mpObj(0L),
+ mpObjList(0L),
+ meHint(HINT_UNKNOWN)
+{
+}
+
+SdrHint::SdrHint(SdrHintKind eNewHint)
+: mpPage(0L),
+ mpObj(0L),
+ mpObjList(0L),
+ meHint(eNewHint)
+{
+}
+
+SdrHint::SdrHint(const SdrObject& rNewObj)
+: mpPage(rNewObj.GetPage()),
+ mpObj(&rNewObj),
+ mpObjList(rNewObj.GetObjList()),
+ meHint(HINT_OBJCHG)
+{
+ maRectangle = rNewObj.GetLastBoundRect();
+}
+
+SdrHint::SdrHint(const SdrObject& rNewObj, const Rectangle& rRect)
+: mpPage(rNewObj.GetPage()),
+ mpObj(&rNewObj),
+ mpObjList(rNewObj.GetObjList()),
+ meHint(HINT_OBJCHG)
+{
+ maRectangle = rRect;
+}
+
+void SdrHint::SetPage(const SdrPage* pNewPage)
+{
+ mpPage = pNewPage;
+}
+
+void SdrHint::SetObjList(const SdrObjList* pNewOL)
+{
+ mpObjList = pNewOL;
+}
+
+void SdrHint::SetObject(const SdrObject* pNewObj)
+{
+ mpObj = pNewObj;
+}
+
+void SdrHint::SetKind(SdrHintKind eNewKind)
+{
+ meHint = eNewKind;
+}
+
+void SdrHint::SetRect(const Rectangle& rNewRect)
+{
+ maRectangle = rNewRect;
+}
+
+const SdrPage* SdrHint::GetPage() const
+{
+ return mpPage;
+}
+
+const SdrObjList* SdrHint::GetObjList() const
+{
+ return mpObjList;
+}
+
+const SdrObject* SdrHint::GetObject() const
+{
+ return mpObj;
+}
+
+SdrHintKind SdrHint::GetKind() const
+{
+ return meHint;
+}
+
+const Rectangle& SdrHint::GetRect() const
+{
+ return maRectangle;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
new file mode 100644
index 000000000000..a40350cf34d9
--- /dev/null
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -0,0 +1,2179 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdmrkv.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdoedge.hxx>
+#include "svdglob.hxx"
+#include "svditext.hxx"
+#include <svx/svdview.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdpage.hxx>
+#include "svddrgm1.hxx"
+
+#ifdef DBG_UTIL
+#include <svdibrow.hxx>
+#endif
+
+#include <svx/svdoole2.hxx>
+#include <svx/xgrad.hxx>
+#include <svx/xflgrit.hxx>
+#include "gradtrns.hxx"
+#include <svx/xflftrit.hxx>
+#include <svx/dialmgr.hxx>
+#include "svdstr.hrc"
+#include <svx/svdundo.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/scene3d.hxx>
+#include <svx/svdovirt.hxx>
+#include <svx/sdr/overlay/overlayrollingrectangle.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <sdrpaintwindow.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <svx/sdrhittesthelper.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// predefines
+
+class SdrUnoControlList;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #114409#-3 Migrate Marking of Objects, Points and GluePoints
+
+class ImplMarkingOverlay
+{
+ // The OverlayObjects
+ ::sdr::overlay::OverlayObjectList maObjects;
+
+ // The remembered second position in logical coodinates
+ basegfx::B2DPoint maSecondPosition;
+
+ // bitfield
+ // A flag to remember if the action is for unmarking.
+ unsigned mbUnmarking : 1;
+
+public:
+ ImplMarkingOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos, sal_Bool bUnmarking = sal_False);
+ ~ImplMarkingOverlay();
+
+ void SetSecondPosition(const basegfx::B2DPoint& rNewPosition);
+ sal_Bool IsUnmarking() const { return mbUnmarking; }
+};
+
+ImplMarkingOverlay::ImplMarkingOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos, sal_Bool bUnmarking)
+: maSecondPosition(rStartPos),
+ mbUnmarking(bUnmarking)
+{
+ for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
+ ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
+
+ if(pTargetOverlay)
+ {
+ ::sdr::overlay::OverlayRollingRectangleStriped* pNew = new ::sdr::overlay::OverlayRollingRectangleStriped(
+ rStartPos, rStartPos, false);
+ pTargetOverlay->add(*pNew);
+ maObjects.append(*pNew);
+ }
+ }
+}
+
+ImplMarkingOverlay::~ImplMarkingOverlay()
+{
+ // The OverlayObjects are cleared using the destructor of OverlayObjectList.
+ // That destructor calls clear() at the list which removes all objects from the
+ // OverlayManager and deletes them.
+}
+
+void ImplMarkingOverlay::SetSecondPosition(const basegfx::B2DPoint& rNewPosition)
+{
+ if(rNewPosition != maSecondPosition)
+ {
+ // apply to OverlayObjects
+ for(sal_uInt32 a(0L); a < maObjects.count(); a++)
+ {
+ ::sdr::overlay::OverlayRollingRectangleStriped& rCandidate = (::sdr::overlay::OverlayRollingRectangleStriped&)maObjects.getOverlayObject(a);
+ rCandidate.setSecondPosition(rNewPosition);
+ }
+
+ // remember new position
+ maSecondPosition = rNewPosition;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@ @@ @@@@ @@@@@ @@ @@ @@ @@ @@ @@@@@ @@ @@
+// @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
+// @@@@@@@ @@@@@@ @@@@@ @@@@ @@@@@ @@ @@@@ @@@@@@@
+// @@ @ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@@@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @ @@ @@@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrMarkView::ImpClearVars()
+{
+ eDragMode=SDRDRAG_MOVE;
+ //HMHbHdlShown=FALSE;
+ bRefHdlShownOnly=FALSE;
+ eEditMode=SDREDITMODE_EDIT;
+ eEditMode0=SDREDITMODE_EDIT;
+ bDesignMode=FALSE;
+ pMarkedObj=NULL;
+ pMarkedPV=NULL;
+ bForceFrameHandles=FALSE;
+ bPlusHdlAlways=FALSE;
+ nFrameHandlesLimit=50;
+ bInsPolyPoint=FALSE;
+ mnInsPointNum = 0L;
+ bMarkedObjRectDirty=FALSE;
+ bMarkedPointsRectsDirty=FALSE;
+ mbMarkHandlesHidden = false;
+ bMrkPntDirty=FALSE;
+ bMarkHdlWhenTextEdit=FALSE;
+ bMarkableObjCountDirty=FALSE; // noch nicht implementiert
+ nMarkableObjCount=0; // noch nicht implementiert
+
+ // #114409#-3 Migrate selections
+ BrkMarkObj();
+ BrkMarkPoints();
+ BrkMarkGluePoints();
+}
+
+SdrMarkView::SdrMarkView(SdrModel* pModel1, OutputDevice* pOut)
+: SdrSnapView(pModel1,pOut),
+ mpMarkObjOverlay(0L),
+ mpMarkPointsOverlay(0L),
+ mpMarkGluePointsOverlay(0L),
+ aHdl(this),
+ mpSdrViewSelection(new sdr::ViewSelection())
+{
+ ImpClearVars();
+ StartListening(*pModel1);
+}
+
+SdrMarkView::~SdrMarkView()
+{
+ // #114409#-3 Migrate selections
+ BrkMarkObj();
+ BrkMarkPoints();
+ BrkMarkGluePoints();
+ delete mpSdrViewSelection;
+}
+
+void __EXPORT SdrMarkView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+{
+ SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint);
+ if (pSdrHint!=NULL)
+ {
+ SdrHintKind eKind=pSdrHint->GetKind();
+
+ if (eKind==HINT_OBJCHG || eKind==HINT_OBJINSERTED || eKind==HINT_OBJREMOVED)
+ {
+ bMarkedObjRectDirty=TRUE;
+ bMarkedPointsRectsDirty=TRUE;
+ }
+/* removed for now since this breaks existing code who iterates over the mark list and sequentially replaces objects
+ if( eKind==HINT_OBJREMOVED && IsObjMarked( const_cast<SdrObject*>(pSdrHint->GetObject()) ) )
+ {
+ MarkObj( const_cast<SdrObject*>(pSdrHint->GetObject()), GetSdrPageView(), TRUE );
+ }
+*/
+ }
+ SdrSnapView::Notify(rBC,rHint);
+}
+
+void SdrMarkView::ModelHasChanged()
+{
+ SdrPaintView::ModelHasChanged();
+ GetMarkedObjectListWriteAccess().SetNameDirty();
+ bMarkedObjRectDirty=TRUE;
+ bMarkedPointsRectsDirty=TRUE;
+ // Es sind beispielsweise Obj markiert und maMarkedObjectListist Sorted.
+ // In einer anderen View 2 wird die ObjOrder veraendert
+ // (z.B. MovToTop()). Dann ist Neusortieren der MarkList erforderlich.
+ GetMarkedObjectListWriteAccess().SetUnsorted();
+ SortMarkedObjects();
+ bMrkPntDirty=TRUE;
+ UndirtyMrkPnt();
+ SdrView* pV=(SdrView*)this;
+ if (pV!=NULL && !pV->IsDragObj() && !pV->IsInsObjPoint()) { // an dieser Stelle habe ich ein ziemliches Problem !!!
+ AdjustMarkHdl();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrMarkView::IsAction() const
+{
+ return SdrSnapView::IsAction() || IsMarkObj() || IsMarkPoints() || IsMarkGluePoints();
+}
+
+void SdrMarkView::MovAction(const Point& rPnt)
+{
+ SdrSnapView::MovAction(rPnt);
+
+ if(IsMarkObj())
+ {
+ MovMarkObj(rPnt);
+ }
+ else if(IsMarkPoints())
+ {
+ MovMarkPoints(rPnt);
+ }
+ else if(IsMarkGluePoints())
+ {
+ MovMarkGluePoints(rPnt);
+ }
+}
+
+void SdrMarkView::EndAction()
+{
+ if(IsMarkObj())
+ {
+ EndMarkObj();
+ }
+ else if(IsMarkPoints())
+ {
+ EndMarkPoints();
+ }
+ else if(IsMarkGluePoints())
+ {
+ EndMarkGluePoints();
+ }
+
+ SdrSnapView::EndAction();
+}
+
+void SdrMarkView::BckAction()
+{
+ SdrSnapView::BckAction();
+ BrkMarkObj();
+ BrkMarkPoints();
+ BrkMarkGluePoints();
+}
+
+void SdrMarkView::BrkAction()
+{
+ SdrSnapView::BrkAction();
+ BrkMarkObj();
+ BrkMarkPoints();
+ BrkMarkGluePoints();
+}
+
+void SdrMarkView::TakeActionRect(Rectangle& rRect) const
+{
+ if(IsMarkObj() || IsMarkPoints() || IsMarkGluePoints())
+ {
+ rRect = Rectangle(aDragStat.GetStart(), aDragStat.GetNow());
+ }
+ else
+ {
+ SdrSnapView::TakeActionRect(rRect);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrMarkView::ClearPageView()
+{
+ UnmarkAllObj();
+ SdrSnapView::ClearPageView();
+}
+
+void SdrMarkView::HideSdrPage()
+{
+ bool bMrkChg(false);
+ //HMHbool bVis(false);
+
+ if(mpPageView)
+ {
+ // break all creation actions when hiding page (#75081#)
+ BrkAction();
+ //HMHbVis = IsMarkHdlShown();
+
+ //HMHif(bVis)
+ //HMH{
+ //HMH HideMarkHdl();
+ //HMH}
+
+ // Alle Markierungen dieser Seite verwerfen
+ bMrkChg = GetMarkedObjectListWriteAccess().DeletePageView(*mpPageView);
+ }
+
+ SdrSnapView::HideSdrPage();
+
+ if(bMrkChg)
+ {
+ MarkListHasChanged();
+ AdjustMarkHdl();
+ }
+
+ //HMHif(bVis)
+ //HMH{
+ //HMH ShowMarkHdl();
+ //HMH}
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_Bool SdrMarkView::BegMarkObj(const Point& rPnt, sal_Bool bUnmark)
+{
+ BrkAction();
+
+ DBG_ASSERT(0L == mpMarkObjOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkObjOverlay (!)");
+ basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
+ mpMarkObjOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
+
+ aDragStat.Reset(rPnt);
+ aDragStat.NextPoint();
+ aDragStat.SetMinMove(nMinMovLog);
+
+ return sal_True;
+}
+
+void SdrMarkView::MovMarkObj(const Point& rPnt)
+{
+ if(IsMarkObj() && aDragStat.CheckMinMoved(rPnt))
+ {
+ aDragStat.NextMove(rPnt);
+ DBG_ASSERT(mpMarkObjOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
+ basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y());
+ mpMarkObjOverlay->SetSecondPosition(aNewPos);
+ }
+}
+
+sal_Bool SdrMarkView::EndMarkObj()
+{
+ sal_Bool bRetval(sal_False);
+
+ if(IsMarkObj())
+ {
+ if(aDragStat.IsMinMoved())
+ {
+ Rectangle aRect(aDragStat.GetStart(), aDragStat.GetNow());
+ aRect.Justify();
+ MarkObj(aRect, mpMarkObjOverlay->IsUnmarking());
+ bRetval = sal_True;
+ }
+
+ // cleanup
+ BrkMarkObj();
+ }
+
+ return bRetval;
+}
+
+void SdrMarkView::BrkMarkObj()
+{
+ if(IsMarkObj())
+ {
+ DBG_ASSERT(mpMarkObjOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
+ delete mpMarkObjOverlay;
+ mpMarkObjOverlay = 0L;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_Bool SdrMarkView::BegMarkPoints(const Point& rPnt, sal_Bool bUnmark)
+{
+ if(HasMarkablePoints())
+ {
+ BrkAction();
+
+ DBG_ASSERT(0L == mpMarkPointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkPointsOverlay (!)");
+ basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
+ mpMarkPointsOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
+
+ aDragStat.Reset(rPnt);
+ aDragStat.NextPoint();
+ aDragStat.SetMinMove(nMinMovLog);
+
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+void SdrMarkView::MovMarkPoints(const Point& rPnt)
+{
+ if(IsMarkPoints() && aDragStat.CheckMinMoved(rPnt))
+ {
+ aDragStat.NextMove(rPnt);
+
+ DBG_ASSERT(mpMarkPointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
+ basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y());
+ mpMarkPointsOverlay->SetSecondPosition(aNewPos);
+ }
+}
+
+sal_Bool SdrMarkView::EndMarkPoints()
+{
+ sal_Bool bRetval(sal_False);
+
+ if(IsMarkPoints())
+ {
+ if(aDragStat.IsMinMoved())
+ {
+ Rectangle aRect(aDragStat.GetStart(), aDragStat.GetNow());
+ aRect.Justify();
+ MarkPoints(aRect, mpMarkPointsOverlay->IsUnmarking());
+
+ bRetval = sal_True;
+ }
+
+ // cleanup
+ BrkMarkPoints();
+ }
+
+ return bRetval;
+}
+
+void SdrMarkView::BrkMarkPoints()
+{
+ if(IsMarkPoints())
+ {
+ DBG_ASSERT(mpMarkPointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
+ delete mpMarkPointsOverlay;
+ mpMarkPointsOverlay = 0L;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_Bool SdrMarkView::BegMarkGluePoints(const Point& rPnt, sal_Bool bUnmark)
+{
+ if(HasMarkableGluePoints())
+ {
+ BrkAction();
+
+ DBG_ASSERT(0L == mpMarkGluePointsOverlay, "SdrMarkView::BegMarkObj: There exists a mpMarkGluePointsOverlay (!)");
+ basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
+ mpMarkGluePointsOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
+
+ aDragStat.Reset(rPnt);
+ aDragStat.NextPoint();
+ aDragStat.SetMinMove(nMinMovLog);
+
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+void SdrMarkView::MovMarkGluePoints(const Point& rPnt)
+{
+ if(IsMarkGluePoints() && aDragStat.CheckMinMoved(rPnt))
+ {
+ aDragStat.NextMove(rPnt);
+
+ DBG_ASSERT(mpMarkGluePointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
+ basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y());
+ mpMarkGluePointsOverlay->SetSecondPosition(aNewPos);
+ }
+}
+
+sal_Bool SdrMarkView::EndMarkGluePoints()
+{
+ sal_Bool bRetval(sal_False);
+
+ if(IsMarkGluePoints())
+ {
+ if(aDragStat.IsMinMoved())
+ {
+ Rectangle aRect(aDragStat.GetStart(),aDragStat.GetNow());
+ aRect.Justify();
+ MarkGluePoints(&aRect, mpMarkGluePointsOverlay->IsUnmarking());
+
+ bRetval = sal_True;
+ }
+
+ // cleanup
+ BrkMarkGluePoints();
+ }
+
+ return bRetval;
+}
+
+void SdrMarkView::BrkMarkGluePoints()
+{
+ if(IsMarkGluePoints())
+ {
+ DBG_ASSERT(mpMarkGluePointsOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
+ delete mpMarkGluePointsOverlay;
+ mpMarkGluePointsOverlay = 0L;
+ }
+}
+
+BOOL SdrMarkView::HasMarkableObj() const
+{
+ ULONG nCount=0;
+
+ SdrPageView* pPV = GetSdrPageView();
+ if(pPV)
+ {
+ SdrObjList* pOL=pPV->GetObjList();
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG nObjNum=0; nObjNum<nObjAnz && nCount==0; nObjNum++) {
+ SdrObject* pObj=pOL->GetObj(nObjNum);
+ if (IsObjMarkable(pObj,pPV)) {
+ nCount++;
+ }
+ }
+ }
+ return nCount!=0;
+}
+
+ULONG SdrMarkView::GetMarkableObjCount() const
+{
+ ULONG nCount=0;
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ SdrObjList* pOL=pPV->GetObjList();
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
+ SdrObject* pObj=pOL->GetObj(nObjNum);
+ if (IsObjMarkable(pObj,pPV)) {
+ nCount++;
+ }
+ }
+ }
+ return nCount;
+}
+
+//HMHvoid SdrMarkView::ImpShowMarkHdl(bool /*bNoRefHdl*/)
+//HMH{
+//HMH bNoRefHdl=FALSE; // geht leider erstmal nicht anders
+//HMH if (!bHdlShown) {
+//HMH bRefHdlShownOnly=FALSE;
+//HMH bHdlShown=TRUE;
+//HMH }
+//HMH}
+
+//HMHvoid SdrMarkView::ShowMarkHdl(bool /*bNoRefHdl*/)
+//HMH{
+//HMH bNoRefHdl=FALSE; // geht leider erstmal nicht anders
+//HMH ImpShowMarkHdl(bNoRefHdl);
+//HMH}
+
+
+//HMHvoid SdrMarkView::HideMarkHdl(bool /*bNoRefHdl*/)
+//HMH{
+//HMH bNoRefHdl=FALSE; // geht leider erstmal nicht anders
+//HMH if (bHdlShown) {
+//HMH bRefHdlShownOnly=bNoRefHdl;
+//HMH bHdlShown=FALSE;
+//HMH }
+//HMH}
+
+void SdrMarkView::hideMarkHandles()
+{
+ if(!mbMarkHandlesHidden)
+ {
+ mbMarkHandlesHidden = true;
+ AdjustMarkHdl();
+ }
+}
+
+void SdrMarkView::showMarkHandles()
+{
+ if(mbMarkHandlesHidden)
+ {
+ mbMarkHandlesHidden = false;
+ AdjustMarkHdl();
+ }
+}
+
+BOOL SdrMarkView::ImpIsFrameHandles() const
+{
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ BOOL bFrmHdl=nMarkAnz>nFrameHandlesLimit || bForceFrameHandles;
+ BOOL bStdDrag=eDragMode==SDRDRAG_MOVE;
+ if (nMarkAnz==1 && bStdDrag && bFrmHdl)
+ {
+ const SdrObject* pObj=GetMarkedObjectByIndex(0);
+ if (pObj->GetObjInventor()==SdrInventor)
+ {
+ UINT16 nIdent=pObj->GetObjIdentifier();
+ if (nIdent==OBJ_LINE || nIdent==OBJ_EDGE || nIdent==OBJ_CAPTION || nIdent==OBJ_MEASURE || nIdent==OBJ_CUSTOMSHAPE || nIdent==OBJ_TABLE )
+ {
+ bFrmHdl=FALSE;
+ }
+ }
+ }
+ if (!bStdDrag && !bFrmHdl) {
+ // Grundsaetzlich erstmal alle anderen Dragmodi nur mit FrameHandles
+ bFrmHdl=TRUE;
+ if (eDragMode==SDRDRAG_ROTATE) {
+ // bei Rotate ObjOwn-Drag, wenn mind. 1 PolyObj
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && bFrmHdl; nMarkNum++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ bFrmHdl=!pObj->IsPolyObj();
+ }
+ }
+ }
+ if (!bFrmHdl) {
+ // FrameHandles, wenn wenigstens 1 Obj kein SpecialDrag kann
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bFrmHdl; nMarkNum++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ bFrmHdl=!pObj->hasSpecialDrag();
+ }
+ }
+ return bFrmHdl;
+}
+
+void SdrMarkView::SetMarkHandles()
+{
+ // #105722# remember old focus handle values to search for it again
+ const SdrHdl* pSaveOldFocusHdl = aHdl.GetFocusHdl();
+ sal_Bool bSaveOldFocus(sal_False);
+ sal_uInt32 nSavePolyNum(0L), nSavePointNum(0L);
+ SdrHdlKind eSaveKind(HDL_MOVE);
+ SdrObject* pSaveObj = NULL;
+
+ if(pSaveOldFocusHdl
+ && pSaveOldFocusHdl->GetObj()
+ && pSaveOldFocusHdl->GetObj()->ISA(SdrPathObj)
+ && (pSaveOldFocusHdl->GetKind() == HDL_POLY || pSaveOldFocusHdl->GetKind() == HDL_BWGT))
+ {
+ bSaveOldFocus = sal_True;
+ nSavePolyNum = pSaveOldFocusHdl->GetPolyNum();
+ nSavePointNum = pSaveOldFocusHdl->GetPointNum();
+ pSaveObj = pSaveOldFocusHdl->GetObj();
+ eSaveKind = pSaveOldFocusHdl->GetKind();
+ }
+
+ // delete/clear all handles. This will always be done, even with areMarkHandlesHidden()
+ aHdl.Clear();
+ aHdl.SetRotateShear(eDragMode==SDRDRAG_ROTATE);
+ aHdl.SetDistortShear(eDragMode==SDRDRAG_SHEAR);
+ pMarkedObj=NULL;
+ pMarkedPV=NULL;
+
+ // are handles enabled at all? Create only then
+ if(!areMarkHandlesHidden())
+ {
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ BOOL bStdDrag=eDragMode==SDRDRAG_MOVE;
+ BOOL bSingleTextObjMark=FALSE;
+
+ if (nMarkAnz==1)
+ {
+ pMarkedObj=GetMarkedObjectByIndex(0);
+ bSingleTextObjMark =
+ pMarkedObj &&
+ pMarkedObj->ISA(SdrTextObj) &&
+ static_cast<SdrTextObj*>(pMarkedObj)->IsTextFrame();
+ }
+
+ BOOL bFrmHdl=ImpIsFrameHandles();
+
+ if (nMarkAnz>0)
+ {
+ pMarkedPV=GetSdrPageViewOfMarkedByIndex(0);
+
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && (pMarkedPV!=NULL || !bFrmHdl); nMarkNum++)
+ {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+
+ if (pMarkedPV!=pM->GetPageView())
+ {
+ pMarkedPV=NULL;
+ }
+ }
+ }
+
+ if (bFrmHdl)
+ {
+ Rectangle aRect(GetMarkedObjRect());
+
+ // #i33755#
+ const sal_Bool bHideHandlesWhenInTextEdit(
+ ((SdrView*)this)->IsTextEdit()
+ && pMarkedObj
+ && pMarkedObj->ISA(SdrTextObj)
+ && ((SdrTextObj*)pMarkedObj)->IsInEditMode());
+
+ if(!aRect.IsEmpty() && !bHideHandlesWhenInTextEdit)
+ { // sonst nix gefunden
+ if( bSingleTextObjMark )
+ {
+ const ULONG nSiz0=aHdl.GetHdlCount();
+ pMarkedObj->AddToHdlList(aHdl);
+ const ULONG nSiz1=aHdl.GetHdlCount();
+ for (ULONG i=nSiz0; i<nSiz1; i++)
+ {
+ SdrHdl* pHdl=aHdl.GetHdl(i);
+ pHdl->SetObj(pMarkedObj);
+ pHdl->SetPageView(pMarkedPV);
+ pHdl->SetObjHdlNum(USHORT(i-nSiz0));
+ }
+ }
+ else if( eDragMode==SDRDRAG_CROP )
+ {
+ aHdl.AddHdl(new SdrCropHdl(aRect.TopLeft() ,HDL_UPLFT));
+ aHdl.AddHdl(new SdrCropHdl(aRect.TopCenter() ,HDL_UPPER));
+ aHdl.AddHdl(new SdrCropHdl(aRect.TopRight() ,HDL_UPRGT));
+ aHdl.AddHdl(new SdrCropHdl(aRect.LeftCenter() ,HDL_LEFT ));
+ aHdl.AddHdl(new SdrCropHdl(aRect.RightCenter() ,HDL_RIGHT));
+ aHdl.AddHdl(new SdrCropHdl(aRect.BottomLeft() ,HDL_LWLFT));
+ aHdl.AddHdl(new SdrCropHdl(aRect.BottomCenter(),HDL_LOWER));
+ aHdl.AddHdl(new SdrCropHdl(aRect.BottomRight() ,HDL_LWRGT));
+ }
+ else
+ {
+ BOOL bWdt0=aRect.Left()==aRect.Right();
+ BOOL bHgt0=aRect.Top()==aRect.Bottom();
+ if (bWdt0 && bHgt0)
+ {
+ aHdl.AddHdl(new SdrHdl(aRect.TopLeft(),HDL_UPLFT));
+ }
+ else if (!bStdDrag && (bWdt0 || bHgt0))
+ {
+ aHdl.AddHdl(new SdrHdl(aRect.TopLeft() ,HDL_UPLFT));
+ aHdl.AddHdl(new SdrHdl(aRect.BottomRight(),HDL_LWRGT));
+ }
+ else
+ {
+ if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.TopLeft() ,HDL_UPLFT));
+ if ( !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.TopCenter() ,HDL_UPPER));
+ if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.TopRight() ,HDL_UPRGT));
+ if (!bWdt0 ) aHdl.AddHdl(new SdrHdl(aRect.LeftCenter() ,HDL_LEFT ));
+ if (!bWdt0 ) aHdl.AddHdl(new SdrHdl(aRect.RightCenter() ,HDL_RIGHT));
+ if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.BottomLeft() ,HDL_LWLFT));
+ if ( !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.BottomCenter(),HDL_LOWER));
+ if (!bWdt0 && !bHgt0) aHdl.AddHdl(new SdrHdl(aRect.BottomRight() ,HDL_LWRGT));
+ }
+ }
+ }
+ }
+ else
+ {
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++)
+ {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrPageView* pPV=pM->GetPageView();
+ const ULONG nSiz0=aHdl.GetHdlCount();
+ pObj->AddToHdlList(aHdl);
+ const ULONG nSiz1=aHdl.GetHdlCount();
+ bool bPoly=pObj->IsPolyObj();
+ const SdrUShortCont* pMrkPnts=pM->GetMarkedPoints();
+ for (ULONG i=nSiz0; i<nSiz1; i++)
+ {
+ SdrHdl* pHdl=aHdl.GetHdl(i);
+ pHdl->SetObj(pObj);
+ pHdl->SetPageView(pPV);
+ pHdl->SetObjHdlNum(USHORT(i-nSiz0));
+ if (bPoly)
+ {
+ BOOL bSelected=pMrkPnts!=NULL && pMrkPnts->Exist(USHORT(i-nSiz0));
+ pHdl->SetSelected(bSelected);
+ //BOOL bPlus=bPlusHdlAlways;
+ if (bPlusHdlAlways || bSelected)
+ {
+ sal_uInt32 nPlusAnz=pObj->GetPlusHdlCount(*pHdl);
+ for (sal_uInt32 nPlusNum=0; nPlusNum<nPlusAnz; nPlusNum++)
+ {
+ SdrHdl* pPlusHdl=pObj->GetPlusHdl(*pHdl,nPlusNum);
+ if (pPlusHdl!=NULL)
+ {
+ pPlusHdl->SetObj(pObj);
+ pPlusHdl->SetPageView(pPV);
+ pPlusHdl->SetPlusHdl(TRUE);
+ aHdl.AddHdl(pPlusHdl);
+ }
+ }
+ }
+ }
+ }
+ } // for nMarkNum
+ } // if bFrmHdl else
+
+ // GluePoint-Handles
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++)
+ {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrPageView* pPV=pM->GetPageView();
+ const SdrUShortCont* pMrkGlue=pM->GetMarkedGluePoints();
+ if (pMrkGlue!=NULL)
+ {
+ const SdrGluePointList* pGPL=pObj->GetGluePointList();
+ if (pGPL!=NULL)
+ {
+ //USHORT nGlueAnz=pGPL->GetCount();
+ USHORT nAnz=(USHORT)pMrkGlue->GetCount();
+ for (USHORT nNum=0; nNum<nAnz; nNum++)
+ {
+ USHORT nId=pMrkGlue->GetObject(nNum);
+ //nNum changed to nNumGP because already used in for loop
+ USHORT nNumGP=pGPL->FindGluePoint(nId);
+ if (nNumGP!=SDRGLUEPOINT_NOTFOUND)
+ {
+ const SdrGluePoint& rGP=(*pGPL)[nNumGP];
+ Point aPos(rGP.GetAbsolutePos(*pObj));
+ SdrHdl* pGlueHdl=new SdrHdl(aPos,HDL_GLUE);
+ pGlueHdl->SetObj(pObj);
+ pGlueHdl->SetPageView(pPV);
+ pGlueHdl->SetObjHdlNum(nId);
+ aHdl.AddHdl(pGlueHdl);
+ }
+ }
+ }
+ }
+ }
+
+ // Drehpunkt/Spiegelachse
+ AddDragModeHdl(eDragMode);
+
+ // add custom handles (used by other apps, e.g. AnchorPos)
+ AddCustomHdl();
+
+ // sort handles
+ aHdl.Sort();
+
+ // #105722# try to restore focus handle index from remembered values
+ if(bSaveOldFocus)
+ {
+ for(sal_uInt32 a(0); a < aHdl.GetHdlCount(); a++)
+ {
+ SdrHdl* pCandidate = aHdl.GetHdl(a);
+
+ if(pCandidate->GetObj()
+ && pCandidate->GetObj() == pSaveObj
+ && pCandidate->GetKind() == eSaveKind
+ && pCandidate->GetPolyNum() == nSavePolyNum
+ && pCandidate->GetPointNum() == nSavePointNum)
+ {
+ aHdl.SetFocusHdl(pCandidate);
+ break;
+ }
+ }
+ }
+ }
+}
+
+void SdrMarkView::AddCustomHdl()
+{
+ // add custom handles (used by other apps, e.g. AnchorPos)
+}
+
+void SdrMarkView::SetDragMode(SdrDragMode eMode)
+{
+ SdrDragMode eMode0=eDragMode;
+ eDragMode=eMode;
+ if (eDragMode==SDRDRAG_RESIZE) eDragMode=SDRDRAG_MOVE;
+ if (eDragMode!=eMode0) {
+ //HMHBOOL bVis=IsMarkHdlShown();
+ //HMHif (bVis) HideMarkHdl();
+ ForceRefToMarked();
+ SetMarkHandles();
+ //HMHif (bVis) ShowMarkHdl();
+ {
+ if (AreObjectsMarked()) MarkListHasChanged();
+ }
+ }
+}
+
+void SdrMarkView::AddDragModeHdl(SdrDragMode eMode)
+{
+ switch(eMode)
+ {
+ case SDRDRAG_ROTATE:
+ {
+ // add rotation center
+ SdrHdl* pHdl = new SdrHdl(aRef1, HDL_REF1);
+
+ aHdl.AddHdl(pHdl);
+
+ break;
+ }
+ case SDRDRAG_MIRROR:
+ {
+ // add mirror axis
+ SdrHdl* pHdl3 = new SdrHdl(aRef2, HDL_REF2);
+ SdrHdl* pHdl2 = new SdrHdl(aRef1, HDL_REF1);
+ SdrHdl* pHdl1 = new SdrHdlLine(*pHdl2, *pHdl3, HDL_MIRX);
+
+ pHdl1->SetObjHdlNum(1); // fuer Sortierung
+ pHdl2->SetObjHdlNum(2); // fuer Sortierung
+ pHdl3->SetObjHdlNum(3); // fuer Sortierung
+
+ aHdl.AddHdl(pHdl1); // Linie als erstes, damit als letztes im HitTest
+ aHdl.AddHdl(pHdl2);
+ aHdl.AddHdl(pHdl3);
+
+ break;
+ }
+ case SDRDRAG_TRANSPARENCE:
+ {
+ // add interactive transparence handle
+ ULONG nMarkAnz = GetMarkedObjectCount();
+ if(nMarkAnz == 1)
+ {
+ SdrObject* pObj = GetMarkedObjectByIndex(0);
+ SdrModel* pModel = GetModel();
+ const SfxItemSet& rSet = pObj->GetMergedItemSet();
+
+ if(SFX_ITEM_SET != rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE, FALSE))
+ {
+ // add this item, it's not yet there
+ XFillFloatTransparenceItem aNewItem(
+ (const XFillFloatTransparenceItem&)rSet.Get(XATTR_FILLFLOATTRANSPARENCE));
+ XGradient aGrad = aNewItem.GetGradientValue();
+
+ aNewItem.SetEnabled(TRUE);
+ aGrad.SetStartIntens(100);
+ aGrad.SetEndIntens(100);
+ aNewItem.SetGradientValue(aGrad);
+
+ // add undo to allow user to take back this step
+ if( pModel->IsUndoEnabled() )
+ {
+ pModel->BegUndo(SVX_RESSTR(SIP_XA_FILLTRANSPARENCE));
+ pModel->AddUndo(pModel->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
+ pModel->EndUndo();
+ }
+
+ //pObj->SetItemAndBroadcast(aNewItem);
+ SfxItemSet aNewSet(pModel->GetItemPool());
+ aNewSet.Put(aNewItem);
+ pObj->SetMergedItemSetAndBroadcast(aNewSet);
+ }
+
+ // set values and transform to vector set
+ GradTransformer aGradTransformer;
+ GradTransVector aGradTransVector;
+ GradTransGradient aGradTransGradient;
+
+ aGradTransGradient.aGradient = ((XFillFloatTransparenceItem&)rSet.Get(XATTR_FILLFLOATTRANSPARENCE)).GetGradientValue();
+ aGradTransformer.GradToVec(aGradTransGradient, aGradTransVector, pObj);
+
+ // build handles
+ const Point aTmpPos1(basegfx::fround(aGradTransVector.maPositionA.getX()), basegfx::fround(aGradTransVector.maPositionA.getY()));
+ const Point aTmpPos2(basegfx::fround(aGradTransVector.maPositionB.getX()), basegfx::fround(aGradTransVector.maPositionB.getY()));
+ SdrHdlColor* pColHdl1 = new SdrHdlColor(aTmpPos1, aGradTransVector.aCol1, SDR_HANDLE_COLOR_SIZE_NORMAL, TRUE);
+ SdrHdlColor* pColHdl2 = new SdrHdlColor(aTmpPos2, aGradTransVector.aCol2, SDR_HANDLE_COLOR_SIZE_NORMAL, TRUE);
+ SdrHdlGradient* pGradHdl = new SdrHdlGradient(aTmpPos1, aTmpPos2, FALSE);
+ DBG_ASSERT(pColHdl1 && pColHdl2 && pGradHdl, "Got not all necessary handles!!");
+
+ // link them
+ pGradHdl->SetColorHandles(pColHdl1, pColHdl2);
+ pGradHdl->SetObj(pObj);
+ pColHdl1->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
+ pColHdl2->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
+
+ // insert them
+ aHdl.AddHdl(pColHdl1);
+ aHdl.AddHdl(pColHdl2);
+ aHdl.AddHdl(pGradHdl);
+ }
+ break;
+ }
+ case SDRDRAG_GRADIENT:
+ {
+ // add interactive gradient handle
+ ULONG nMarkAnz = GetMarkedObjectCount();
+ if(nMarkAnz == 1)
+ {
+ SdrObject* pObj = GetMarkedObjectByIndex(0);
+ const SfxItemSet& rSet = pObj->GetMergedItemSet();
+ XFillStyle eFillStyle = ((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue();
+
+ if(eFillStyle == XFILL_GRADIENT)
+ {
+ // set values and transform to vector set
+ GradTransformer aGradTransformer;
+ GradTransVector aGradTransVector;
+ GradTransGradient aGradTransGradient;
+ Size aHdlSize(15, 15);
+
+ aGradTransGradient.aGradient = ((XFillGradientItem&)rSet.Get(XATTR_FILLGRADIENT)).GetGradientValue();
+ aGradTransformer.GradToVec(aGradTransGradient, aGradTransVector, pObj);
+
+ // build handles
+ const Point aTmpPos1(basegfx::fround(aGradTransVector.maPositionA.getX()), basegfx::fround(aGradTransVector.maPositionA.getY()));
+ const Point aTmpPos2(basegfx::fround(aGradTransVector.maPositionB.getX()), basegfx::fround(aGradTransVector.maPositionB.getY()));
+ SdrHdlColor* pColHdl1 = new SdrHdlColor(aTmpPos1, aGradTransVector.aCol1, aHdlSize, FALSE);
+ SdrHdlColor* pColHdl2 = new SdrHdlColor(aTmpPos2, aGradTransVector.aCol2, aHdlSize, FALSE);
+ SdrHdlGradient* pGradHdl = new SdrHdlGradient(aTmpPos1, aTmpPos2, TRUE);
+ DBG_ASSERT(pColHdl1 && pColHdl2 && pGradHdl, "Got not all necessary handles!!");
+
+ // link them
+ pGradHdl->SetColorHandles(pColHdl1, pColHdl2);
+ pGradHdl->SetObj(pObj);
+ pColHdl1->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
+ pColHdl2->SetColorChangeHdl(LINK(pGradHdl, SdrHdlGradient, ColorChangeHdl));
+
+ // insert them
+ aHdl.AddHdl(pColHdl1);
+ aHdl.AddHdl(pColHdl2);
+ aHdl.AddHdl(pGradHdl);
+ }
+ }
+ break;
+ }
+ case SDRDRAG_CROP:
+ {
+ // todo
+ break;
+ }
+ default: break;
+ }
+}
+
+/** handle mouse over effects for handles */
+BOOL SdrMarkView::MouseMove(const MouseEvent& rMEvt, Window* pWin)
+{
+ if(aHdl.GetHdlCount())
+ {
+ SdrHdl* pMouseOverHdl = 0;
+ if( !rMEvt.IsLeaveWindow() && pWin )
+ {
+ Point aMDPos( pWin->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pMouseOverHdl = PickHandle(aMDPos);
+ }
+
+ // notify last mouse over handle that he lost the mouse
+ const ULONG nHdlCount = aHdl.GetHdlCount();
+
+ for(ULONG nHdl = 0; nHdl < nHdlCount; nHdl++ )
+ {
+ SdrHdl* pCurrentHdl = GetHdl(nHdl);
+ if( pCurrentHdl->mbMouseOver )
+ {
+ if( pCurrentHdl != pMouseOverHdl )
+ {
+ pCurrentHdl->mbMouseOver = false;
+ pCurrentHdl->onMouseLeave();
+ }
+ break;
+ }
+ }
+
+ // notify current mouse over handle
+ if( pMouseOverHdl /* && !pMouseOverHdl->mbMouseOver */ )
+ {
+ pMouseOverHdl->mbMouseOver = true;
+ pMouseOverHdl->onMouseEnter(rMEvt);
+ }
+ }
+ return SdrSnapView::MouseMove(rMEvt, pWin);
+}
+
+void SdrMarkView::ForceRefToMarked()
+{
+ switch(eDragMode)
+ {
+ case SDRDRAG_ROTATE:
+ {
+ Rectangle aR(GetMarkedObjRect());
+ aRef1 = aR.Center();
+
+ break;
+ }
+
+ case SDRDRAG_MIRROR:
+ {
+ // Erstmal die laenge der Spiegelachsenlinie berechnen
+ long nOutMin=0;
+ long nOutMax=0;
+ long nMinLen=0;
+ long nObjDst=0;
+ long nOutHgt=0;
+ OutputDevice* pOut=GetFirstOutputDevice();
+ //OutputDevice* pOut=GetWin(0);
+ if (pOut!=NULL) {
+ // Mindestlaenge 50 Pixel
+ nMinLen=pOut->PixelToLogic(Size(0,50)).Height();
+ // 20 Pixel fuer RefPt-Abstand vom Obj
+ nObjDst=pOut->PixelToLogic(Size(0,20)).Height();
+ // MinY/MaxY
+ // Abstand zum Rand = Mindestlaenge = 10 Pixel
+ long nDst=pOut->PixelToLogic(Size(0,10)).Height();
+ nOutMin=-pOut->GetMapMode().GetOrigin().Y();
+ nOutMax=pOut->GetOutputSize().Height()-1+nOutMin;
+ nOutMin+=nDst;
+ nOutMax-=nDst;
+ // Absolute Mindestlaenge jedoch 10 Pixel
+ if (nOutMax-nOutMin<nDst) {
+ nOutMin+=nOutMax+1;
+ nOutMin/=2;
+ nOutMin-=(nDst+1)/2;
+ nOutMax=nOutMin+nDst;
+ }
+ nOutHgt=nOutMax-nOutMin;
+ // Sonst Mindestlaenge = 1/4 OutHgt
+ long nTemp=nOutHgt/4;
+ if (nTemp>nMinLen) nMinLen=nTemp;
+ }
+
+ Rectangle aR(GetMarkedObjBoundRect());
+ Point aCenter(aR.Center());
+ long nMarkHgt=aR.GetHeight()-1;
+ long nHgt=nMarkHgt+nObjDst*2; // 20 Pixel obej und unten ueberstehend
+ if (nHgt<nMinLen) nHgt=nMinLen; // Mindestlaenge 50 Pixel bzw. 1/4 OutHgt
+
+ long nY1=aCenter.Y()-(nHgt+1)/2;
+ long nY2=nY1+nHgt;
+
+ if (pOut!=NULL && nMinLen>nOutHgt) nMinLen=nOutHgt; // evtl. noch etwas verkuerzen
+
+ if (pOut!=NULL) { // nun vollstaendig in den sichtbaren Bereich schieben
+ if (nY1<nOutMin) {
+ nY1=nOutMin;
+ if (nY2<nY1+nMinLen) nY2=nY1+nMinLen;
+ }
+ if (nY2>nOutMax) {
+ nY2=nOutMax;
+ if (nY1>nY2-nMinLen) nY1=nY2-nMinLen;
+ }
+ }
+
+ aRef1.X()=aCenter.X();
+ aRef1.Y()=nY1;
+ aRef2.X()=aCenter.X();
+ aRef2.Y()=nY2;
+
+ break;
+ }
+
+ case SDRDRAG_TRANSPARENCE:
+ case SDRDRAG_GRADIENT:
+ case SDRDRAG_CROP:
+ {
+ Rectangle aRect(GetMarkedObjBoundRect());
+ aRef1 = aRect.TopLeft();
+ aRef2 = aRect.BottomRight();
+ break;
+ }
+ default: break;
+ }
+}
+
+void SdrMarkView::SetRef1(const Point& rPt)
+{
+ if(eDragMode == SDRDRAG_ROTATE || eDragMode == SDRDRAG_MIRROR)
+ {
+ aRef1 = rPt;
+ SdrHdl* pH = aHdl.GetHdl(HDL_REF1);
+ if(pH)
+ pH->SetPos(rPt);
+ //HMHShowMarkHdl();
+ }
+}
+
+void SdrMarkView::SetRef2(const Point& rPt)
+{
+ if(eDragMode == SDRDRAG_MIRROR)
+ {
+ aRef2 = rPt;
+ SdrHdl* pH = aHdl.GetHdl(HDL_REF2);
+ if(pH)
+ pH->SetPos(rPt);
+ //HMHShowMarkHdl();
+ }
+}
+
+void SdrMarkView::CheckMarked()
+{
+ for (ULONG nm=GetMarkedObjectCount(); nm>0;) {
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrPageView* pPV=pM->GetPageView();
+ SdrLayerID nLay=pObj->GetLayer();
+ BOOL bRaus=!pObj->IsInserted(); // Obj geloescht?
+ if (!pObj->Is3DObj()) {
+ bRaus=bRaus || pObj->GetPage()!=pPV->GetPage(); // Obj ploetzlich in anderer Page oder Group
+ }
+ bRaus=bRaus || pPV->GetLockedLayers().IsSet(nLay) || // Layer gesperrt?
+ !pPV->GetVisibleLayers().IsSet(nLay); // Layer nicht sichtbar?
+
+ if( !bRaus )
+ bRaus = !pObj->IsVisible(); // not visible objects can not be marked
+
+ if (!bRaus) {
+ // Joe am 9.3.1997: Gruppierte Objekten koennen nun auch
+ // markiert werden. Nach EnterGroup muessen aber die Objekte
+ // der hoeheren Ebene deselektiert werden.
+ const SdrObjList* pOOL=pObj->GetObjList();
+ const SdrObjList* pVOL=pPV->GetObjList();
+ while (pOOL!=NULL && pOOL!=pVOL) {
+ pOOL=pOOL->GetUpList();
+ }
+ bRaus=pOOL!=pVOL;
+ }
+
+ if (bRaus)
+ {
+ GetMarkedObjectListWriteAccess().DeleteMark(nm);
+ }
+ else
+ {
+ if (!IsGluePointEditMode()) { // Markierte GluePoints nur im GlueEditMode
+ SdrUShortCont* pPts=pM->GetMarkedGluePoints();
+ if (pPts!=NULL && pPts->GetCount()!=0) {
+ pPts->Clear();
+ }
+ }
+ }
+ }
+
+ // #97995# at least reset the remembered BoundRect to prevent handle
+ // generation if bForceFrameHandles is TRUE.
+ bMarkedObjRectDirty = TRUE;
+}
+
+void SdrMarkView::SetMarkRects()
+{
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ pPV->SetHasMarkedObj(GetSnapRectFromMarkedObjects(pPV, pPV->MarkSnap()));
+ GetBoundRectFromMarkedObjects(pPV, pPV->MarkBound());
+ }
+}
+
+void SdrMarkView::SetFrameHandles(BOOL bOn)
+{
+ if (bOn!=bForceFrameHandles) {
+ BOOL bOld=ImpIsFrameHandles();
+ bForceFrameHandles=bOn;
+ BOOL bNew=ImpIsFrameHandles();
+ if (bNew!=bOld) {
+ AdjustMarkHdl(); //HMHTRUE);
+ MarkListHasChanged();
+ }
+ }
+}
+
+void SdrMarkView::SetEditMode(SdrViewEditMode eMode)
+{
+ if (eMode!=eEditMode) {
+ BOOL bGlue0=eEditMode==SDREDITMODE_GLUEPOINTEDIT;
+ BOOL bEdge0=((SdrCreateView*)this)->IsEdgeTool();
+ eEditMode0=eEditMode;
+ eEditMode=eMode;
+ BOOL bGlue1=eEditMode==SDREDITMODE_GLUEPOINTEDIT;
+ BOOL bEdge1=((SdrCreateView*)this)->IsEdgeTool();
+ // etwas Aufwand um Flackern zu verhindern beim Umschalten
+ // zwischen GlueEdit und EdgeTool
+ if (bGlue1 && !bGlue0) ImpSetGlueVisible2(bGlue1);
+ if (bEdge1!=bEdge0) ImpSetGlueVisible3(bEdge1);
+ if (!bGlue1 && bGlue0) ImpSetGlueVisible2(bGlue1);
+ if (bGlue0 && !bGlue1) UnmarkAllGluePoints();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrMarkView::IsObjMarkable(SdrObject* pObj, SdrPageView* pPV) const
+{
+ if (pObj)
+ {
+ if (pObj->IsMarkProtect() ||
+ (!bDesignMode && pObj->IsUnoObj()))
+ {
+ // Objekt nicht selektierbar oder
+ // SdrUnoObj nicht im DesignMode
+ return FALSE;
+ }
+ }
+ return pPV!=NULL ? pPV->IsObjMarkable(pObj) : TRUE;
+}
+
+BOOL SdrMarkView::IsMarkedObjHit(const Point& rPnt, short nTol) const
+{
+ BOOL bRet=FALSE;
+ nTol=ImpGetHitTolLogic(nTol,NULL);
+ Point aPt(rPnt);
+ for (ULONG nm=0; nm<GetMarkedObjectCount() && !bRet; nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ bRet = 0 != CheckSingleSdrObjectHit(aPt,USHORT(nTol),pM->GetMarkedSdrObj(),pM->GetPageView(),0,0);
+ }
+ return bRet;
+}
+
+SdrHdl* SdrMarkView::PickHandle(const Point& rPnt, ULONG nOptions, SdrHdl* pHdl0) const
+{
+ if (bSomeObjChgdFlag) { // ggf. Handles neu berechnen lassen!
+ FlushComeBackTimer();
+ }
+ BOOL bBack=(nOptions & SDRSEARCH_BACKWARD) !=0;
+ BOOL bNext=(nOptions & SDRSEARCH_NEXT) !=0;
+ Point aPt(rPnt);
+ return aHdl.IsHdlListHit(aPt,bBack,bNext,pHdl0);
+}
+
+BOOL SdrMarkView::MarkObj(const Point& rPnt, short nTol, BOOL bToggle, BOOL bDeep)
+{
+ SdrObject* pObj;
+ SdrPageView* pPV;
+ nTol=ImpGetHitTolLogic(nTol,NULL);
+ ULONG nOptions=SDRSEARCH_PICKMARKABLE;
+ if (bDeep) nOptions=nOptions|SDRSEARCH_DEEP;
+ BOOL bRet=PickObj(rPnt,(USHORT)nTol,pObj,pPV,nOptions);
+ if (bRet) {
+ BOOL bUnmark=bToggle && IsObjMarked(pObj);
+ MarkObj(pObj,pPV,bUnmark);
+ }
+ return bRet;
+}
+
+BOOL SdrMarkView::MarkNextObj(BOOL bPrev)
+{
+ SdrPageView* pPageView = GetSdrPageView();
+
+ if(!pPageView)
+ {
+ return FALSE;
+ }
+
+ SortMarkedObjects();
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ ULONG nChgMarkNum = ULONG_MAX; // Nummer des zu ersetzenden MarkEntries
+ ULONG nSearchObjNum = bPrev ? 0 : ULONG_MAX;
+ if (nMarkAnz!=0) {
+ nChgMarkNum=bPrev ? 0 : ULONG(nMarkAnz-1);
+ SdrMark* pM=GetSdrMarkByIndex(nChgMarkNum);
+ OSL_ASSERT(pM!=NULL);
+ if (pM->GetMarkedSdrObj() != NULL)
+ nSearchObjNum = pM->GetMarkedSdrObj()->GetNavigationPosition();
+ }
+
+ SdrObject* pMarkObj=NULL;
+ SdrObjList* pSearchObjList=pPageView->GetObjList();
+ ULONG nObjAnz=pSearchObjList->GetObjCount();
+ if (nObjAnz!=0) {
+ if (nSearchObjNum>nObjAnz) nSearchObjNum=nObjAnz;
+ while (pMarkObj==NULL && ((!bPrev && nSearchObjNum>0) || (bPrev && nSearchObjNum<nObjAnz)))
+ {
+ if (!bPrev)
+ nSearchObjNum--;
+ SdrObject* pSearchObj = pSearchObjList->GetObjectForNavigationPosition(nSearchObjNum);
+ if (IsObjMarkable(pSearchObj,pPageView))
+ {
+ if (TryToFindMarkedObject(pSearchObj)==CONTAINER_ENTRY_NOTFOUND)
+ {
+ pMarkObj=pSearchObj;
+ }
+ }
+ if (bPrev) nSearchObjNum++;
+ }
+ }
+
+ if(!pMarkObj)
+ {
+ return FALSE;
+ }
+
+ if (nChgMarkNum!=ULONG_MAX)
+ {
+ GetMarkedObjectListWriteAccess().DeleteMark(nChgMarkNum);
+ }
+ MarkObj(pMarkObj,pPageView); // ruft auch MarkListHasChanged(), AdjustMarkHdl()
+ return TRUE;
+}
+
+BOOL SdrMarkView::MarkNextObj(const Point& rPnt, short nTol, BOOL bPrev)
+{
+ SortMarkedObjects();
+ nTol=ImpGetHitTolLogic(nTol,NULL);
+ Point aPt(rPnt);
+ SdrMark* pTopMarkHit=NULL;
+ SdrMark* pBtmMarkHit=NULL;
+ ULONG nTopMarkHit=0;
+ ULONG nBtmMarkHit=0;
+ // oberstes der markierten Objekte suchen, das von rPnt getroffen wird
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ ULONG nm=0;
+ for (nm=nMarkAnz; nm>0 && pTopMarkHit==NULL;) {
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ if(CheckSingleSdrObjectHit(aPt,USHORT(nTol),pM->GetMarkedSdrObj(),pM->GetPageView(),0,0))
+ {
+ pTopMarkHit=pM;
+ nTopMarkHit=nm;
+ }
+ }
+ // Nichts gefunden, dann ganz normal ein Obj markieren.
+ if (pTopMarkHit==NULL) return MarkObj(rPnt,USHORT(nTol),FALSE);
+
+ SdrObject* pTopObjHit=pTopMarkHit->GetMarkedSdrObj();
+ SdrObjList* pObjList=pTopObjHit->GetObjList();
+ SdrPageView* pPV=pTopMarkHit->GetPageView();
+ // unterstes der markierten Objekte suchen, das von rPnt getroffen wird
+ // und auf der gleichen PageView liegt wie pTopMarkHit
+ for (nm=0; nm<nMarkAnz && pBtmMarkHit==NULL; nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrPageView* pPV2=pM->GetPageView();
+ if (pPV2==pPV && CheckSingleSdrObjectHit(aPt,USHORT(nTol),pM->GetMarkedSdrObj(),pPV2,0,0))
+ {
+ pBtmMarkHit=pM;
+ nBtmMarkHit=nm;
+ }
+ }
+ if (pBtmMarkHit==NULL) { pBtmMarkHit=pTopMarkHit; nBtmMarkHit=nTopMarkHit; }
+ SdrObject* pBtmObjHit=pBtmMarkHit->GetMarkedSdrObj();
+ ULONG nObjAnz=pObjList->GetObjCount();
+
+ // #110988#
+ //ULONG nSearchBeg=bPrev ? pBtmObjHit->GetOrdNum()+1 : pTopObjHit->GetOrdNum();
+ sal_uInt32 nSearchBeg;
+ E3dScene* pScene = NULL;
+ SdrObject* pObjHit = (bPrev) ? pBtmObjHit : pTopObjHit;
+ sal_Bool bRemap = pObjHit->ISA(E3dCompoundObject)
+ ? ((E3dCompoundObject*)pObjHit)->IsAOrdNumRemapCandidate(pScene)
+ : sal_False;
+
+ if(bPrev)
+ {
+ sal_uInt32 nOrdNumBtm(pBtmObjHit->GetOrdNum());
+
+ if(bRemap)
+ {
+ nOrdNumBtm = pScene->RemapOrdNum(nOrdNumBtm);
+ }
+
+ nSearchBeg = nOrdNumBtm + 1;
+ }
+ else
+ {
+ sal_uInt32 nOrdNumTop(pTopObjHit->GetOrdNum());
+
+ if(bRemap)
+ {
+ nOrdNumTop = pScene->RemapOrdNum(nOrdNumTop);
+ }
+
+ nSearchBeg = nOrdNumTop;
+ }
+
+ ULONG no=nSearchBeg;
+ SdrObject* pFndObj=NULL;
+ //SdrObject* pAktObj=NULL;
+ while (pFndObj==NULL && ((!bPrev && no>0) || (bPrev && no<nObjAnz))) {
+ if (!bPrev) no--;
+ SdrObject* pObj;
+
+ if(bRemap)
+ {
+ pObj = pObjList->GetObj(pScene->RemapOrdNum(no));
+ }
+ else
+ {
+ pObj = pObjList->GetObj(no);
+ }
+
+ if (CheckSingleSdrObjectHit(aPt,USHORT(nTol),pObj,pPV,SDRSEARCH_TESTMARKABLE,0))
+ {
+ if (TryToFindMarkedObject(pObj)==CONTAINER_ENTRY_NOTFOUND) {
+ pFndObj=pObj;
+ } else {
+ // hier wg. Performance ggf. noch no auf Top bzw. auf Btm stellen
+ }
+ }
+ if (bPrev) no++;
+ }
+ if (pFndObj!=NULL)
+ {
+ GetMarkedObjectListWriteAccess().DeleteMark(bPrev?nBtmMarkHit:nTopMarkHit);
+ GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pFndObj,pPV));
+ MarkListHasChanged();
+ AdjustMarkHdl(); //HMHTRUE);
+ }
+ return pFndObj!=NULL;
+}
+
+BOOL SdrMarkView::MarkObj(const Rectangle& rRect, BOOL bUnmark)
+{
+ BOOL bFnd=FALSE;
+ Rectangle aR(rRect);
+ SdrObject* pObj;
+ SdrObjList* pObjList;
+ BrkAction();
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ pObjList=pPV->GetObjList();
+ Rectangle aFrm1(aR);
+ ULONG nObjAnz=pObjList->GetObjCount();
+ for (ULONG nO=0; nO<nObjAnz; nO++) {
+ pObj=pObjList->GetObj(nO);
+ Rectangle aRect(pObj->GetCurrentBoundRect());
+ if (aFrm1.IsInside(aRect)) {
+ if (!bUnmark) {
+ if (IsObjMarkable(pObj,pPV))
+ {
+ GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pObj,pPV));
+ bFnd=TRUE;
+ }
+ } else {
+ ULONG nPos=TryToFindMarkedObject(pObj);
+ if (nPos!=CONTAINER_ENTRY_NOTFOUND)
+ {
+ GetMarkedObjectListWriteAccess().DeleteMark(nPos);
+ bFnd=TRUE;
+ }
+ }
+ }
+ }
+ }
+ if (bFnd) {
+ SortMarkedObjects();
+ MarkListHasChanged();
+ AdjustMarkHdl(); //HMHTRUE);
+ //HMHShowMarkHdl();
+ }
+ return bFnd;
+}
+
+void SdrMarkView::MarkObj(SdrObject* pObj, SdrPageView* pPV, BOOL bUnmark, BOOL bImpNoSetMarkHdl)
+{
+ if (pObj!=NULL && pPV!=NULL && IsObjMarkable(pObj, pPV)) {
+ BrkAction();
+ if (!bUnmark)
+ {
+ GetMarkedObjectListWriteAccess().InsertEntry(SdrMark(pObj,pPV));
+ }
+ else
+ {
+ ULONG nPos=TryToFindMarkedObject(pObj);
+ if (nPos!=CONTAINER_ENTRY_NOTFOUND)
+ {
+ GetMarkedObjectListWriteAccess().DeleteMark(nPos);
+ }
+ }
+ if (!bImpNoSetMarkHdl) {
+ MarkListHasChanged();
+ AdjustMarkHdl(); //HMHTRUE);
+ //HMHif (!bSomeObjChgdFlag) {
+ // ShowMarkHdl kommt sonst mit dem AfterPaintTimer
+ //HMHShowMarkHdl();
+ //HMH}
+ }
+ }
+}
+
+BOOL SdrMarkView::IsObjMarked(SdrObject* pObj) const
+{
+ // nicht so ganz die feine Art: Da FindObject() nicht const ist
+ // muss ich mich hier auf non-const casten.
+ ULONG nPos=((SdrMarkView*)this)->TryToFindMarkedObject(pObj);
+ return nPos!=CONTAINER_ENTRY_NOTFOUND;
+}
+
+USHORT SdrMarkView::GetMarkHdlSizePixel() const
+{
+ return aHdl.GetHdlSize()*2+1;
+}
+
+void SdrMarkView::SetSolidMarkHdl(BOOL bOn)
+{
+ if (bOn!=aHdl.IsFineHdl()) {
+ //HMHBOOL bMerk=IsMarkHdlShown();
+ //HMHif (bMerk) HideMarkHdl();
+ aHdl.SetFineHdl(bOn);
+ //HMHif (bMerk) ShowMarkHdl();
+ }
+}
+
+void SdrMarkView::SetMarkHdlSizePixel(USHORT nSiz)
+{
+ if (nSiz<3) nSiz=3;
+ nSiz/=2;
+ if (nSiz!=aHdl.GetHdlSize()) {
+ //HMHBOOL bMerk=IsMarkHdlShown();
+ //HMHif (bMerk) HideMarkHdl();
+ aHdl.SetHdlSize(nSiz);
+ //HMHif (bMerk) ShowMarkHdl();
+ }
+}
+
+#define SDRSEARCH_IMPISMASTER 0x80000000 /* MasterPage wird gerade durchsucht */
+SdrObject* SdrMarkView::CheckSingleSdrObjectHit(const Point& rPnt, USHORT nTol, SdrObject* pObj, SdrPageView* pPV, ULONG nOptions, const SetOfByte* pMVisLay) const
+{
+ if(((nOptions & SDRSEARCH_IMPISMASTER) && pObj->IsNotVisibleAsMaster()) || (!pObj->IsVisible()))
+ {
+ return NULL;
+ }
+
+ const bool bCheckIfMarkable(nOptions & SDRSEARCH_TESTMARKABLE);
+ const bool bDeep(nOptions & SDRSEARCH_DEEP);
+ const bool bOLE(pObj->ISA(SdrOle2Obj));
+ const bool bTXT(pObj->ISA(SdrTextObj) && ((SdrTextObj*)pObj)->IsTextFrame());
+ SdrObject* pRet=NULL;
+ Rectangle aRect(pObj->GetCurrentBoundRect());
+ USHORT nTol2(nTol);
+
+ // double tolerance for OLE, text frames and objects in
+ // active text edit
+ if(bOLE || bTXT || pObj==((SdrObjEditView*)this)->GetTextEditObject())
+ {
+ nTol2*=2;
+ }
+
+ aRect.Left ()-=nTol2; // Einmal Toleranz drauf fuer alle Objekte
+ aRect.Top ()-=nTol2;
+ aRect.Right ()+=nTol2;
+ aRect.Bottom()+=nTol2;
+
+ if (aRect.IsInside(rPnt))
+ {
+ if ((!bCheckIfMarkable || IsObjMarkable(pObj,pPV)))
+ {
+ SdrObjList* pOL=pObj->GetSubList();
+
+ if (pOL!=NULL && pOL->GetObjCount()!=0)
+ {
+ SdrObject* pTmpObj;
+ // OD 30.06.2003 #108784# - adjustment hit point for virtual
+ // objects.
+ Point aPnt( rPnt );
+
+ if ( pObj->ISA(SdrVirtObj) )
+ {
+ Point aOffset = static_cast<SdrVirtObj*>(pObj)->GetOffset();
+ aPnt.Move( -aOffset.X(), -aOffset.Y() );
+ }
+
+ pRet=CheckSingleSdrObjectHit(aPnt,nTol,pOL,pPV,nOptions,pMVisLay,pTmpObj);
+ }
+ else
+ {
+ if(!pMVisLay || pMVisLay->IsSet(pObj->GetLayer()))
+ {
+ pRet = SdrObjectPrimitiveHit(*pObj, rPnt, nTol2, *pPV, &pPV->GetVisibleLayers(), false);
+ }
+ }
+ }
+ }
+
+ if (!bDeep && pRet!=NULL)
+ {
+ pRet=pObj;
+ }
+
+ return pRet;
+}
+
+SdrObject* SdrMarkView::CheckSingleSdrObjectHit(const Point& rPnt, USHORT nTol, SdrObjList* pOL, SdrPageView* pPV, ULONG nOptions, const SetOfByte* pMVisLay, SdrObject*& rpRootObj) const
+{
+ BOOL bBack=(nOptions & SDRSEARCH_BACKWARD)!=0;
+ SdrObject* pRet=NULL;
+ rpRootObj=NULL;
+ if (pOL!=NULL)
+ {
+ // #110988#
+ sal_Bool bRemap(pOL->GetOwnerObj() && pOL->GetOwnerObj()->ISA(E3dScene));
+ E3dScene* pRemapScene = (bRemap ? (E3dScene*)pOL->GetOwnerObj() : 0L);
+
+ ULONG nObjAnz=pOL->GetObjCount();
+ ULONG nObjNum=bBack ? 0 : nObjAnz;
+ while (pRet==NULL && (bBack ? nObjNum<nObjAnz : nObjNum>0)) {
+ if (!bBack) nObjNum--;
+ SdrObject* pObj;
+
+ // #110988#
+ if(bRemap)
+ {
+ pObj = pOL->GetObj(pRemapScene->RemapOrdNum(nObjNum));
+ }
+ else
+ {
+ pObj = pOL->GetObj(nObjNum);
+ }
+
+ pRet=CheckSingleSdrObjectHit(rPnt,nTol,pObj,pPV,nOptions,pMVisLay);
+ if (pRet!=NULL) rpRootObj=pObj;
+ if (bBack) nObjNum++;
+ }
+ }
+ return pRet;
+}
+
+BOOL SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG nOptions) const
+{
+ return PickObj(rPnt,nTol,rpObj,rpPV,nOptions,NULL,NULL,NULL);
+}
+
+BOOL SdrMarkView::PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG nOptions, SdrObject** ppRootObj, ULONG* pnMarkNum, USHORT* pnPassNum) const
+{ // Fehlt noch Pass2,Pass3
+ SortMarkedObjects();
+ if (ppRootObj!=NULL) *ppRootObj=NULL;
+ if (pnMarkNum!=NULL) *pnMarkNum=CONTAINER_ENTRY_NOTFOUND;
+ if (pnPassNum!=NULL) *pnPassNum=0;
+ rpObj=NULL;
+ rpPV=NULL;
+ BOOL bWholePage=(nOptions & SDRSEARCH_WHOLEPAGE) !=0;
+ BOOL bMarked=(nOptions & SDRSEARCH_MARKED) !=0;
+ BOOL bMasters=!bMarked && (nOptions & SDRSEARCH_ALSOONMASTER) !=0;
+ BOOL bBack=(nOptions & SDRSEARCH_BACKWARD) !=0;
+#if OSL_DEBUG_LEVEL > 0
+ BOOL bNext=(nOptions & SDRSEARCH_NEXT) !=0; (void)bNext; // n.i.
+ BOOL bBoundCheckOn2ndPass=(nOptions & SDRSEARCH_PASS2BOUND) !=0; (void)bBoundCheckOn2ndPass;// n.i.
+ BOOL bCheckNearestOn3rdPass=(nOptions & SDRSEARCH_PASS3NEAREST) !=0; (void)bCheckNearestOn3rdPass;// n.i.
+#endif
+ if (nTol<0) nTol=ImpGetHitTolLogic(nTol,NULL);
+ Point aPt(rPnt);
+ SdrObject* pObj=NULL;
+ SdrObject* pHitObj=NULL;
+ SdrPageView* pPV=NULL;
+ if (!bBack && ((SdrObjEditView*)this)->IsTextEditFrameHit(rPnt)) {
+ pObj=((SdrObjEditView*)this)->GetTextEditObject();
+ pHitObj=pObj;
+ pPV=((SdrObjEditView*)this)->GetTextEditPageView();
+ }
+ if (bMarked) {
+ ULONG nMrkAnz=GetMarkedObjectCount();
+ ULONG nMrkNum=bBack ? 0 : nMrkAnz;
+ while (pHitObj==NULL && (bBack ? nMrkNum<nMrkAnz : nMrkNum>0)) {
+ if (!bBack) nMrkNum--;
+ SdrMark* pM=GetSdrMarkByIndex(nMrkNum);
+ pObj=pM->GetMarkedSdrObj();
+ pPV=pM->GetPageView();
+ pHitObj=CheckSingleSdrObjectHit(aPt,nTol,pObj,pPV,nOptions,NULL);
+ if (bBack) nMrkNum++;
+ }
+ }
+ else
+ {
+ pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ SdrPage* pPage=pPV->GetPage();
+ USHORT nPgAnz=1;
+
+ if(bMasters && pPage->TRG_HasMasterPage())
+ {
+ nPgAnz++;
+ }
+
+ BOOL bExtraPassForWholePage=bWholePage && pPage!=pPV->GetObjList();
+ if (bExtraPassForWholePage) nPgAnz++; // Suche erst in AktObjList, dann auf der gesamten Page
+ USHORT nPgNum=bBack ? 0 : nPgAnz;
+ while (pHitObj==NULL && (bBack ? nPgNum<nPgAnz : nPgNum>0)) {
+ ULONG nTmpOptions=nOptions;
+ if (!bBack) nPgNum--;
+ const SetOfByte* pMVisLay=NULL;
+ SdrObjList* pObjList=NULL;
+ if (pnPassNum!=NULL) *pnPassNum&=~(SDRSEARCHPASS_MASTERPAGE|SDRSEARCHPASS_INACTIVELIST);
+ if (nPgNum>=nPgAnz-1 || (bExtraPassForWholePage && nPgNum>=nPgAnz-2))
+ {
+ pObjList=pPV->GetObjList();
+ if (bExtraPassForWholePage && nPgNum==nPgAnz-2) {
+ pObjList=pPage;
+ if (pnPassNum!=NULL) *pnPassNum|=SDRSEARCHPASS_INACTIVELIST;
+ }
+ }
+ else
+ {
+ // sonst MasterPage
+ SdrPage& rMasterPage = pPage->TRG_GetMasterPage();
+ pMVisLay = &pPage->TRG_GetMasterPageVisibleLayers();
+ pObjList = &rMasterPage;
+
+ if (pnPassNum!=NULL) *pnPassNum|=SDRSEARCHPASS_MASTERPAGE;
+ nTmpOptions=nTmpOptions | SDRSEARCH_IMPISMASTER;
+ }
+ pHitObj=CheckSingleSdrObjectHit(aPt,nTol,pObjList,pPV,nTmpOptions,pMVisLay,pObj);
+ if (bBack) nPgNum++;
+ }
+ }
+ }
+ if (pHitObj!=NULL) {
+ if (ppRootObj!=NULL) *ppRootObj=pObj;
+ if ((nOptions & SDRSEARCH_DEEP) !=0) pObj=pHitObj;
+ if ((nOptions & SDRSEARCH_TESTTEXTEDIT) !=0) {
+ if (!pObj->HasTextEdit() || pPV->GetLockedLayers().IsSet(pObj->GetLayer())) {
+ pObj=NULL;
+ }
+ }
+ if (pObj!=NULL && (nOptions & SDRSEARCH_TESTMACRO) !=0) {
+ SdrObjMacroHitRec aHitRec;
+ aHitRec.aPos=aPt;
+ aHitRec.aDownPos=aPt;
+ aHitRec.nTol=nTol;
+ aHitRec.pVisiLayer=&pPV->GetVisibleLayers();
+ aHitRec.pPageView=pPV;
+ if (!pObj->HasMacro() || !pObj->IsMacroHit(aHitRec)) pObj=NULL;
+ }
+ if (pObj!=NULL && (nOptions & SDRSEARCH_WITHTEXT) !=0 && pObj->GetOutlinerParaObject()==NULL) pObj=NULL;
+ if (pObj!=NULL && (nOptions & SDRSEARCH_TESTTEXTAREA) !=0)
+ {
+ if(!SdrObjectPrimitiveHit(*pObj, aPt, 0, *pPV, 0, true))
+ {
+ pObj = 0;
+ }
+ }
+ if (pObj!=NULL) {
+ rpObj=pObj;
+ rpPV=pPV;
+ if (pnPassNum!=NULL) *pnPassNum|=SDRSEARCHPASS_DIRECT;
+ }
+ }
+ return rpObj!=NULL;
+}
+
+BOOL SdrMarkView::PickMarkedObj(const Point& rPnt, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG* pnMarkNum, ULONG nOptions) const
+{
+ SortMarkedObjects();
+ BOOL bBoundCheckOn2ndPass=(nOptions & SDRSEARCH_PASS2BOUND) !=0;
+ BOOL bCheckNearestOn3rdPass=(nOptions & SDRSEARCH_PASS3NEAREST) !=0;
+ rpObj=NULL;
+ rpPV=NULL;
+ if (pnMarkNum!=NULL) *pnMarkNum=CONTAINER_ENTRY_NOTFOUND;
+ Point aPt(rPnt);
+ USHORT nTol=(USHORT)nHitTolLog;
+ BOOL bFnd=FALSE;
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ ULONG nMarkNum;
+ for (nMarkNum=nMarkAnz; nMarkNum>0 && !bFnd;) {
+ nMarkNum--;
+ SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ SdrPageView* pPV=pM->GetPageView();
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ bFnd = 0 != CheckSingleSdrObjectHit(aPt,nTol,pObj,pPV,SDRSEARCH_TESTMARKABLE,0);
+ if (bFnd) {
+ rpObj=pObj;
+ rpPV=pPV;
+ if (pnMarkNum!=NULL) *pnMarkNum=nMarkNum;
+ }
+ }
+ if ((bBoundCheckOn2ndPass || bCheckNearestOn3rdPass) && !bFnd) {
+ SdrObject* pBestObj=NULL;
+ SdrPageView* pBestPV=NULL;
+ ULONG nBestMarkNum=0;
+ ULONG nBestDist=ULONG_MAX;
+ for (nMarkNum=nMarkAnz; nMarkNum>0 && !bFnd;) {
+ nMarkNum--;
+ SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ SdrPageView* pPV=pM->GetPageView();
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ Rectangle aRect(pObj->GetCurrentBoundRect());
+ aRect.Left ()-=nTol;
+ aRect.Top ()-=nTol;
+ aRect.Right ()+=nTol;
+ aRect.Bottom()+=nTol;
+ if (aRect.IsInside(aPt)) {
+ bFnd=TRUE;
+ rpObj=pObj;
+ rpPV=pPV;
+ if (pnMarkNum!=NULL) *pnMarkNum=nMarkNum;
+ } else if (bCheckNearestOn3rdPass) {
+ ULONG nDist=0;
+ if (aPt.X()<aRect.Left()) nDist+=aRect.Left()-aPt.X();
+ if (aPt.X()>aRect.Right()) nDist+=aPt.X()-aRect.Right();
+ if (aPt.Y()<aRect.Top()) nDist+=aRect.Top()-aPt.Y();
+ if (aPt.Y()>aRect.Bottom()) nDist+=aPt.Y()-aRect.Bottom();
+ if (nDist<nBestDist) {
+ pBestObj=pObj;
+ pBestPV=pPV;
+ nBestMarkNum=nMarkNum;
+ }
+ }
+ }
+ if (bCheckNearestOn3rdPass && !bFnd) {
+ rpObj=pBestObj;
+ rpPV=pBestPV;
+ if (pnMarkNum!=NULL) *pnMarkNum=nBestMarkNum;
+ bFnd=pBestObj!=NULL;
+ }
+ }
+ return bFnd;
+}
+
+SdrHitKind SdrMarkView::PickSomething(const Point& rPnt, short nTol) const
+{
+ nTol=ImpGetHitTolLogic(nTol,NULL);
+ SdrHitKind eRet=SDRHIT_NONE;
+ Point aPt(rPnt);
+ SdrObject* pObj=NULL;
+ SdrPageView* pPV=NULL;
+ if (eRet==SDRHIT_NONE && PickObj(rPnt,USHORT(nTol),pObj,pPV,SDRSEARCH_PICKMARKABLE)) {
+ Rectangle aRct1(aPt-Point(nTol,nTol),aPt+Point(nTol,nTol)); // HitRect fuer Toleranz
+ Rectangle aBR(pObj->GetCurrentBoundRect());
+ if (aRct1.IsInside(aBR.TopLeft())) eRet=SDRHIT_BOUNDTL;
+ else if (aRct1.IsInside(aBR.TopCenter())) eRet=SDRHIT_BOUNDTC;
+ else if (aRct1.IsInside(aBR.TopRight())) eRet=SDRHIT_BOUNDTR;
+ else if (aRct1.IsInside(aBR.LeftCenter())) eRet=SDRHIT_BOUNDCL;
+ else if (aRct1.IsInside(aBR.RightCenter())) eRet=SDRHIT_BOUNDCR;
+ else if (aRct1.IsInside(aBR.BottomLeft())) eRet=SDRHIT_BOUNDBL;
+ else if (aRct1.IsInside(aBR.BottomCenter())) eRet=SDRHIT_BOUNDBC;
+ else if (aRct1.IsInside(aBR.BottomRight())) eRet=SDRHIT_BOUNDBR;
+ else eRet=SDRHIT_OBJECT;
+ }
+ return eRet;
+}
+
+void SdrMarkView::UnmarkAllObj(SdrPageView* pPV)
+{
+ if (GetMarkedObjectCount()!=0) {
+ BrkAction();
+ //HMHBOOL bVis=bHdlShown;
+ //HMHif (bVis) HideMarkHdl();
+ if (pPV!=NULL)
+ {
+ GetMarkedObjectListWriteAccess().DeletePageView(*pPV);
+ }
+ else
+ {
+ GetMarkedObjectListWriteAccess().Clear();
+ }
+ pMarkedObj=NULL;
+ pMarkedPV=NULL;
+ MarkListHasChanged();
+ AdjustMarkHdl(); //HMHTRUE);
+ //HMHif (bVis) ShowMarkHdl(); // ggf. fuer die RefPoints
+ }
+}
+
+void SdrMarkView::MarkAllObj(SdrPageView* _pPV)
+{
+ BrkAction();
+ //HMHHideMarkHdl();
+
+ if(!_pPV)
+ {
+ _pPV = GetSdrPageView();
+ }
+
+ // #i69171# _pPV may still be NULL if there is no SDrPageView (!), e.g. when inserting
+ // other files
+ if(_pPV)
+ {
+ const bool bMarkChg(GetMarkedObjectListWriteAccess().InsertPageView(*_pPV));
+
+ if(bMarkChg)
+ {
+ MarkListHasChanged();
+ }
+ }
+
+ if(GetMarkedObjectCount())
+ {
+ AdjustMarkHdl(); //HMHTRUE);
+ //HMHShowMarkHdl();
+ }
+}
+
+void SdrMarkView::AdjustMarkHdl() //HMHBOOL bRestraintPaint)
+{
+ //HMHBOOL bVis=bHdlShown;
+ //HMHif (bVis) HideMarkHdl();
+ CheckMarked();
+ SetMarkRects();
+ SetMarkHandles();
+ //HMHif(bRestraintPaint && bVis)
+ //HMH{
+ //HMH ShowMarkHdl();
+ //HMH}
+}
+
+Rectangle SdrMarkView::GetMarkedObjBoundRect() const
+{
+ Rectangle aRect;
+ for (ULONG nm=0; nm<GetMarkedObjectCount(); nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ Rectangle aR1(pO->GetCurrentBoundRect());
+ if (aRect.IsEmpty()) aRect=aR1;
+ else aRect.Union(aR1);
+ }
+ return aRect;
+}
+
+const Rectangle& SdrMarkView::GetMarkedObjRect() const
+{
+ if (bMarkedObjRectDirty) {
+ ((SdrMarkView*)this)->bMarkedObjRectDirty=FALSE;
+ Rectangle aRect;
+ for (ULONG nm=0; nm<GetMarkedObjectCount(); nm++) {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ Rectangle aR1(pO->GetSnapRect());
+ if (aRect.IsEmpty()) aRect=aR1;
+ else aRect.Union(aR1);
+ }
+ ((SdrMarkView*)this)->aMarkedObjRect=aRect;
+ }
+ return aMarkedObjRect;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrMarkView::ImpTakeDescriptionStr(USHORT nStrCacheID, XubString& rStr, USHORT nVal, USHORT nOpt) const
+{
+ rStr = ImpGetResStr(nStrCacheID);
+ xub_StrLen nPos = rStr.SearchAscii("%1");
+
+ if(nPos != STRING_NOTFOUND)
+ {
+ rStr.Erase(nPos, 2);
+
+ if(nOpt == IMPSDR_POINTSDESCRIPTION)
+ {
+ rStr.Insert(GetDescriptionOfMarkedPoints(), nPos);
+ }
+ else if(nOpt == IMPSDR_GLUEPOINTSDESCRIPTION)
+ {
+ rStr.Insert(GetDescriptionOfMarkedGluePoints(), nPos);
+ }
+ else
+ {
+ rStr.Insert(GetDescriptionOfMarkedObjects(), nPos);
+ }
+ }
+
+ nPos = rStr.SearchAscii("%2");
+
+ if(nPos != STRING_NOTFOUND)
+ {
+ rStr.Erase(nPos, 2);
+ rStr.Insert(UniString::CreateFromInt32(nVal), nPos);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrMarkView::EnterMarkedGroup()
+{
+ BOOL bRet=FALSE;
+ // Es wird nur die erste gefundene Gruppe (also nur in einer PageView) geentert
+ // Weil PageView::EnterGroup ein AdjustMarkHdl ruft.
+ // Das muss ich per Flag mal unterbinden vvvvvvvv
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ BOOL bEnter=FALSE;
+ for (sal_uInt32 nm(GetMarkedObjectCount()); nm > 0 && !bEnter;)
+ {
+ nm--;
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ if (pM->GetPageView()==pPV) {
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ if (pObj->IsGroupObject()) {
+ if (pPV->EnterGroup(pObj)) {
+ bRet=TRUE;
+ bEnter=TRUE;
+ }
+ }
+ }
+ }
+ }
+ return bRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrMarkView::MarkListHasChanged()
+{
+ GetMarkedObjectListWriteAccess().SetNameDirty();
+ SetEdgesOfMarkedNodesDirty(); // bEdgesOfMarkedNodesDirty=TRUE;
+
+ bMarkedObjRectDirty=TRUE;
+ bMarkedPointsRectsDirty=TRUE;
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ BOOL bOneEdgeMarked=FALSE;
+ if (GetMarkedObjectCount()==1) {
+ const SdrObject* pObj=GetMarkedObjectByIndex(0);
+ if (pObj->GetObjInventor()==SdrInventor) {
+ UINT16 nIdent=pObj->GetObjIdentifier();
+ bOneEdgeMarked=nIdent==OBJ_EDGE;
+ }
+ }
+ ImpSetGlueVisible4(bOneEdgeMarked);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrMarkView::SetMoveOutside(BOOL bOn)
+{
+ aHdl.SetMoveOutside(bOn);
+}
+
+BOOL SdrMarkView::IsMoveOutside() const
+{
+ return aHdl.IsMoveOutside();
+}
+
+void SdrMarkView::SetDesignMode( BOOL _bOn )
+{
+ if ( bDesignMode != _bOn )
+ {
+ bDesignMode = _bOn;
+ SdrPageView* pPageView = GetSdrPageView();
+ if ( pPageView )
+ pPageView->SetDesignMode( _bOn );
+ }
+}
+
+// MarkHandles Objektaenderung:
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// - Bei Notify mit HINT_OBJCHG (oder so) werden die Handles erstmal versteckt
+// (wenn nicht schon wegen Dragging versteckt).
+// - XorHdl: Bei ModelHasChanged() werden sie dann wieder angezeigt.
+// - PaintEvents kommen nun durch.
+// - Die XorHandles werden z.T. wieder uebermalt.
+// - Xor: Nach dem Painten werden die Handles im (vom PaintHandler gerufenen)
+// CompleteRedraw per ToggleShownXor bei gesetzter ClipRegion nochmal gemalt
+// und damit ist alles in Butter.
+// - ToggleShownXor macht bei SolidHdl nix weil bHdlShown=FALSE
+// - Der AfterPaintTimer wird gestartet.
+// - SolidHdl: Im AfterPaintHandler wird ShowMarkHdl gerufen.
+// Da die Handles zu diesem Zeitpunkt nicht angezeigt sind wird:
+// - SaveBackground durchgefuehrt.
+// - DrawMarkHdl gerufen und bHdlShown gesetzt.
+//
+// MarkHandles bei sonstigem Invalidate:
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// In diesem Fall bekomme ich kein Notify und beim Aufruf des
+// PaintHandlers->CompleteRedraw() sind auch die SolidHandles sichtbar.
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdmrkv1.cxx b/svx/source/svdraw/svdmrkv1.cxx
new file mode 100644
index 000000000000..a038801e15dd
--- /dev/null
+++ b/svx/source/svdraw/svdmrkv1.cxx
@@ -0,0 +1,726 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdmrkv.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdoedge.hxx>
+#include "svdglob.hxx"
+#include <svx/svdpagv.hxx>
+#include <svx/svdpage.hxx>
+#include "svddrgm1.hxx"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@ @@ @@ @@ @@ @@ @@ @@@@@@ @@ @@ @@@@ @@@@@ @@ @@ @@ @@@@@ @@@@@ @@ @@ @@ @@ @@@@
+// @@ @@ @@ @@ @@@ @@ @@ @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@
+// @@ @@ @@ @@ @@@@@@ @@ @@ @@ @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@@@@ @@
+// @@@@@ @@ @@ @@@@@@ @@@@ @@ @@@@@@@ @@@@@@ @@@@@ @@@@ @@ @@@@ @@@@@ @@ @@ @@@@@@ @@ @@@
+// @@ @@ @@ @@ @@@ @@ @@ @@ @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@@@@ @@ @@ @@@@ @@ @@ @@@@@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrMarkView::HasMarkablePoints() const
+{
+ ForceUndirtyMrkPnt();
+ bool bRet=false;
+ if (!ImpIsFrameHandles()) {
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ if (nMarkAnz<=nFrameHandlesLimit) {
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ bRet=pObj->IsPolyObj();
+ }
+ }
+ }
+ return bRet;
+}
+
+ULONG SdrMarkView::GetMarkablePointCount() const
+{
+ ForceUndirtyMrkPnt();
+ ULONG nAnz=0;
+ if (!ImpIsFrameHandles()) {
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ if (nMarkAnz<=nFrameHandlesLimit) {
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ if (pObj->IsPolyObj()) {
+ nAnz+=pObj->GetPointCount();
+ }
+ }
+ }
+ }
+ return nAnz;
+}
+
+BOOL SdrMarkView::HasMarkedPoints() const
+{
+ ForceUndirtyMrkPnt();
+ BOOL bRet=FALSE;
+ if (!ImpIsFrameHandles()) {
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ if (nMarkAnz<=nFrameHandlesLimit) {
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrUShortCont* pPts=pM->GetMarkedPoints();
+ bRet=pPts!=NULL && pPts->GetCount()!=0;
+ }
+ }
+ }
+ return bRet;
+}
+
+ULONG SdrMarkView::GetMarkedPointCount() const
+{
+ ForceUndirtyMrkPnt();
+ ULONG nAnz=0;
+ if (!ImpIsFrameHandles()) {
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ if (nMarkAnz<=nFrameHandlesLimit) {
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrUShortCont* pPts=pM->GetMarkedPoints();
+ if (pPts!=NULL) nAnz+=pPts->GetCount();
+ }
+ }
+ }
+ return nAnz;
+}
+
+BOOL SdrMarkView::IsPointMarkable(const SdrHdl& rHdl) const
+{
+ return !ImpIsFrameHandles() && &rHdl!=NULL && !rHdl.IsPlusHdl() && rHdl.GetKind()!=HDL_GLUE && rHdl.GetKind()!=HDL_SMARTTAG && rHdl.GetObj()!=NULL && rHdl.GetObj()->IsPolyObj();
+}
+
+BOOL SdrMarkView::MarkPointHelper(SdrHdl* pHdl, SdrMark* pMark, BOOL bUnmark)
+{
+ return ImpMarkPoint( pHdl, pMark, bUnmark );
+}
+
+BOOL SdrMarkView::ImpMarkPoint(SdrHdl* pHdl, SdrMark* pMark, BOOL bUnmark)
+{
+ if (pHdl==NULL || pHdl->IsPlusHdl() || pHdl->GetKind()==HDL_GLUE)
+ return FALSE;
+
+ if (pHdl->IsSelected() != bUnmark)
+ return FALSE;
+
+ SdrObject* pObj=pHdl->GetObj();
+ if (pObj==NULL || !pObj->IsPolyObj())
+ return FALSE;
+
+ if (pMark==NULL)
+ {
+ ULONG nMarkNum=TryToFindMarkedObject(pObj);
+ if (nMarkNum==CONTAINER_ENTRY_NOTFOUND)
+ return FALSE;
+ pMark=GetSdrMarkByIndex(nMarkNum);
+ }
+ const sal_uInt32 nHdlNum(pHdl->GetObjHdlNum());
+ SdrUShortCont* pPts=pMark->ForceMarkedPoints();
+ if (!bUnmark)
+ {
+ pPts->Insert((sal_uInt16)nHdlNum);
+ }
+ else
+ {
+ ULONG nBla=pPts->GetPos((sal_uInt16)nHdlNum);
+ if (nBla!=CONTAINER_ENTRY_NOTFOUND)
+ {
+ pPts->Remove(nBla);
+ }
+ else
+ {
+ return FALSE; // Fehlerfall!
+ }
+ }
+
+ pHdl->SetSelected(!bUnmark);
+ if (!bPlusHdlAlways)
+ {
+ if (!bUnmark)
+ {
+ sal_uInt32 nAnz(pObj->GetPlusHdlCount(*pHdl));
+ for (sal_uInt32 i=0; i<nAnz; i++)
+ {
+ SdrHdl* pPlusHdl=pObj->GetPlusHdl(*pHdl,i);
+ if (pPlusHdl!=NULL)
+ {
+ pPlusHdl->SetObj(pObj);
+ pPlusHdl->SetPageView(pMark->GetPageView());
+ pPlusHdl->SetPlusHdl(TRUE);
+ aHdl.AddHdl(pPlusHdl);
+ }
+ }
+ }
+ else
+ {
+ for (ULONG i = aHdl.GetHdlCount(); i>0;)
+ {
+ i--;
+ SdrHdl* pPlusHdl=aHdl.GetHdl(i);
+ if (pPlusHdl->IsPlusHdl() && pPlusHdl->GetSourceHdlNum()==nHdlNum)
+ {
+ aHdl.RemoveHdl(i);
+ delete pPlusHdl;
+ }
+ }
+ }
+ }
+
+ // #97016# II: Sort handles. This was missing in ImpMarkPoint all the time.
+ aHdl.Sort();
+
+ return TRUE;
+}
+
+
+BOOL SdrMarkView::MarkPoint(SdrHdl& rHdl, BOOL bUnmark)
+{
+ if (&rHdl==NULL) return FALSE;
+ ForceUndirtyMrkPnt();
+ BOOL bRet=FALSE;
+ const SdrObject* pObj=rHdl.GetObj();
+ if (IsPointMarkable(rHdl) && rHdl.IsSelected()==bUnmark) {
+ ULONG nMarkNum=TryToFindMarkedObject(pObj);
+ if (nMarkNum!=CONTAINER_ENTRY_NOTFOUND) {
+ SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ SdrUShortCont* pPts=pM->ForceMarkedPoints();
+ pPts->ForceSort();
+ if (ImpMarkPoint(&rHdl,pM,bUnmark)) {
+ pPts->ForceSort();
+ MarkListHasChanged();
+ bRet=TRUE;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+BOOL SdrMarkView::MarkPoints(const Rectangle* pRect, BOOL bUnmark)
+{
+ ForceUndirtyMrkPnt();
+ BOOL bChgd=FALSE;
+ SortMarkedObjects();
+ const SdrObject* pObj0=NULL;
+ const SdrPageView* pPV0=NULL;
+ SdrMark* pM=NULL;
+ aHdl.Sort();
+ //HMHBOOL bHideHdl=IsMarkHdlShown() && IsSolidMarkHdl() && !bPlusHdlAlways;
+ ULONG nHdlAnz=aHdl.GetHdlCount();
+ for (ULONG nHdlNum=nHdlAnz; nHdlNum>0;) {
+ nHdlNum--;
+ SdrHdl* pHdl=aHdl.GetHdl(nHdlNum);
+ if (IsPointMarkable(*pHdl) && pHdl->IsSelected()==bUnmark) {
+ const SdrObject* pObj=pHdl->GetObj();
+ const SdrPageView* pPV=pHdl->GetPageView();
+ if (pObj!=pObj0 || pPV!=pPV0 || pM==NULL) { // Dieser Abschnitt dient zur Optimierung,
+ if (pM!=NULL) {
+ SdrUShortCont* pPts=pM->GetMarkedPoints();
+ if (pPts!=NULL) pPts->ForceSort();
+ }
+ ULONG nMarkNum=TryToFindMarkedObject(pObj); // damit ImpMarkPoint() nicht staendig das
+ if (nMarkNum!=CONTAINER_ENTRY_NOTFOUND) { // Objekt in der MarkList suchen muss.
+ pM=GetSdrMarkByIndex(nMarkNum);
+ pObj0=pObj;
+ pPV0=pPV;
+ SdrUShortCont* pPts=pM->ForceMarkedPoints();
+ pPts->ForceSort();
+ } else {
+#ifdef DBG_UTIL
+ if (pObj->IsInserted()) {
+ DBG_ERROR("SdrMarkView::MarkPoints(const Rectangle* pRect): Markiertes Objekt nicht gefunden");
+ }
+#endif
+ pM=NULL;
+ }
+ }
+ Point aPos(pHdl->GetPos());
+ if (pM!=NULL && (pRect==NULL || pRect->IsInside(aPos))) {
+ //HMHif (bHideHdl && IsMarkHdlShown() && pHdl->GetObj()!=NULL) {
+ //HMHsal_uInt32 nAnz=pHdl->GetObj()->GetPlusHdlCount(*pHdl);
+ //HMHif (nAnz!=0L) HideMarkHdl(); // #36987#
+ //HMH}
+ if (ImpMarkPoint(pHdl,pM,bUnmark)) bChgd=TRUE;
+ }
+ }
+ }
+ if (pM!=NULL) { // Den zuletzt geaenderten MarkEntry ggf. noch aufraeumen
+ SdrUShortCont* pPts=pM->GetMarkedPoints();
+ if (pPts!=NULL) pPts->ForceSort();
+ }
+ //HMHif (bHideHdl) ShowMarkHdl(); // #36987#
+ if (bChgd) {
+ MarkListHasChanged();
+ }
+
+ return bChgd;
+}
+
+BOOL SdrMarkView::MarkNextPoint(BOOL /*bPrev*/)
+{
+ ForceUndirtyMrkPnt();
+ BOOL bChgd=FALSE;
+ SortMarkedObjects();
+ // ...
+ if (bChgd) {
+ MarkListHasChanged();
+ }
+ return bChgd;
+}
+
+BOOL SdrMarkView::MarkNextPoint(const Point& /*rPnt*/, BOOL /*bPrev*/)
+{
+ ForceUndirtyMrkPnt();
+ BOOL bChgd=FALSE;
+ SortMarkedObjects();
+ // ...
+ if (bChgd) {
+ MarkListHasChanged();
+ }
+ return bChgd;
+}
+
+const Rectangle& SdrMarkView::GetMarkedPointsRect() const
+{
+ ForceUndirtyMrkPnt();
+ if (bMarkedPointsRectsDirty) ImpSetPointsRects();
+ return aMarkedPointsRect;
+}
+
+void SdrMarkView::SetPlusHandlesAlwaysVisible(BOOL bOn)
+{ // HandlePaint optimieren !!!!!!!
+ ForceUndirtyMrkPnt();
+ if (bOn!=bPlusHdlAlways) {
+ //HMHBOOL bVis=IsMarkHdlShown();
+ //HMHif (bVis) HideMarkHdl();
+ bPlusHdlAlways=bOn;
+ SetMarkHandles();
+ //HMHif (bVis) ShowMarkHdl();
+ MarkListHasChanged();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// ImpSetPointsRects() ist fuer PolyPoints und GluePoints!
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrMarkView::ImpSetPointsRects() const
+{
+ Rectangle aPnts;
+ Rectangle aGlue;
+ ULONG nHdlAnz=aHdl.GetHdlCount();
+ for (ULONG nHdlNum=0; nHdlNum<nHdlAnz; nHdlNum++) {
+ const SdrHdl* pHdl=aHdl.GetHdl(nHdlNum);
+ SdrHdlKind eKind=pHdl->GetKind();
+ if ((eKind==HDL_POLY && pHdl->IsSelected()) || eKind==HDL_GLUE) {
+ Point aPt(pHdl->GetPos());
+ Rectangle& rR=eKind==HDL_GLUE ? aGlue : aPnts;
+ if (rR.IsEmpty()) {
+ rR=Rectangle(aPt,aPt);
+ } else {
+ if (aPt.X()<rR.Left ()) rR.Left ()=aPt.X();
+ if (aPt.X()>rR.Right ()) rR.Right ()=aPt.X();
+ if (aPt.Y()<rR.Top ()) rR.Top ()=aPt.Y();
+ if (aPt.Y()>rR.Bottom()) rR.Bottom()=aPt.Y();
+ }
+ }
+ }
+ ((SdrMarkView*)this)->aMarkedPointsRect=aPnts;
+ ((SdrMarkView*)this)->aMarkedGluePointsRect=aGlue;
+ ((SdrMarkView*)this)->bMarkedPointsRectsDirty=FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// UndirtyMrkPnt() ist fuer PolyPoints und GluePoints!
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrMarkView::UndirtyMrkPnt() const
+{
+ BOOL bChg=FALSE;
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
+ SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ // PolyPoints
+ SdrUShortCont* pPts=pM->GetMarkedPoints();
+ if (pPts!=NULL) {
+ if (pObj->IsPolyObj()) {
+ // Ungueltig markierte Punkte entfernen, also alle
+ // Eintraege die groesser sind als die Punktanzahl des Objekts
+ sal_uInt32 nMax(pObj->GetPointCount());
+ sal_uInt32 nPtNum(0xffffffff);
+
+ pPts->ForceSort();
+
+ for (sal_uInt32 nIndex(pPts->GetCount()); nIndex > 0L && nPtNum >= nMax;)
+ {
+ nIndex--;
+ nPtNum = pPts->GetObject(nIndex);
+
+ if(nPtNum >= nMax)
+ {
+ pPts->Remove(nIndex);
+ bChg = TRUE;
+ }
+ }
+ }
+ else
+ {
+ DBG_ERROR("SdrMarkView::UndirtyMrkPnt(): Markierte Punkte an einem Objekt, dass kein PolyObj ist!");
+ if(pPts && pPts->GetCount())
+ {
+ pPts->Clear();
+ bChg = TRUE;
+ }
+ }
+ }
+
+ // GluePoints
+ pPts=pM->GetMarkedGluePoints();
+ const SdrGluePointList* pGPL=pObj->GetGluePointList();
+ if (pPts!=NULL) {
+ if (pGPL!=NULL) {
+ // Ungueltig markierte Klebepunkte entfernen, also alle
+ // Eintraege (Id's) die nicht in der GluePointList des
+ // Objekts enthalten sind
+ pPts->ForceSort();
+ for (ULONG nIndex=pPts->GetCount(); nIndex>0;) {
+ nIndex--;
+ USHORT nId=pPts->GetObject(nIndex);
+ if (pGPL->FindGluePoint(nId)==SDRGLUEPOINT_NOTFOUND) {
+ pPts->Remove(nIndex);
+ bChg=TRUE;
+ }
+ }
+ } else {
+ if (pPts!=NULL && pPts->GetCount()!=0) {
+ pPts->Clear(); // Objekt hat keine Klebepunkte (mehr)
+ bChg=TRUE;
+ }
+ }
+ }
+ }
+ if (bChg) ((SdrMarkView*)this)->bMarkedPointsRectsDirty=TRUE;
+ ((SdrMarkView*)this)->bMrkPntDirty=FALSE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrMarkView::HasMarkableGluePoints() const
+{
+ BOOL bRet=FALSE;
+ if (IsGluePointEditMode()) {
+ ForceUndirtyMrkPnt();
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ const SdrGluePointList* pGPL=pObj->GetGluePointList();
+
+ // #i38892#
+ if(pGPL && pGPL->GetCount())
+ {
+ for(sal_uInt16 a(0); !bRet && a < pGPL->GetCount(); a++)
+ {
+ if((*pGPL)[a].IsUserDefined())
+ {
+ bRet = TRUE;
+ }
+ }
+ }
+ }
+ }
+ return bRet;
+}
+
+ULONG SdrMarkView::GetMarkableGluePointCount() const
+{
+ ULONG nAnz=0;
+ if (IsGluePointEditMode()) {
+ ForceUndirtyMrkPnt();
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ const SdrGluePointList* pGPL=pObj->GetGluePointList();
+
+ // #i38892#
+ if(pGPL && pGPL->GetCount())
+ {
+ for(sal_uInt16 a(0); a < pGPL->GetCount(); a++)
+ {
+ if((*pGPL)[a].IsUserDefined())
+ {
+ nAnz++;
+ }
+ }
+ }
+ }
+ }
+ return nAnz;
+}
+
+BOOL SdrMarkView::HasMarkedGluePoints() const
+{
+ ForceUndirtyMrkPnt();
+ BOOL bRet=FALSE;
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz && !bRet; nMarkNum++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
+ bRet=pPts!=NULL && pPts->GetCount()!=0;
+ }
+ return bRet;
+}
+
+ULONG SdrMarkView::GetMarkedGluePointCount() const
+{
+ ForceUndirtyMrkPnt();
+ ULONG nAnz=0;
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
+ if (pPts!=NULL) nAnz+=pPts->GetCount();
+ }
+ return nAnz;
+}
+
+BOOL SdrMarkView::MarkGluePoints(const Rectangle* pRect, BOOL bUnmark)
+{
+ if (!IsGluePointEditMode() && !bUnmark) return FALSE;
+ ForceUndirtyMrkPnt();
+ BOOL bChgd=FALSE;
+ SortMarkedObjects();
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nMarkNum=0; nMarkNum<nMarkAnz; nMarkNum++) {
+ SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+ const SdrGluePointList* pGPL=pObj->GetGluePointList();
+ SdrUShortCont* pPts=pM->GetMarkedGluePoints();
+ if (bUnmark && pRect==NULL) { // UnmarkAll
+ if (pPts!=NULL && pPts->GetCount()!=0) {
+ pPts->Clear();
+ bChgd=TRUE;
+ }
+ } else {
+ if (pGPL!=NULL && (pPts!=NULL || !bUnmark)) {
+ USHORT nGPAnz=pGPL->GetCount();
+ for (USHORT nGPNum=0; nGPNum<nGPAnz; nGPNum++) {
+ const SdrGluePoint& rGP=(*pGPL)[nGPNum];
+
+ // #i38892#
+ if(rGP.IsUserDefined())
+ {
+ Point aPos(rGP.GetAbsolutePos(*pObj));
+ if (pRect==NULL || pRect->IsInside(aPos)) {
+ if (pPts==NULL) pPts=pM->ForceMarkedGluePoints();
+ else pPts->ForceSort();
+ ULONG nPos=pPts->GetPos(rGP.GetId());
+ if (!bUnmark && nPos==CONTAINER_ENTRY_NOTFOUND) {
+ bChgd=TRUE;
+ pPts->Insert(rGP.GetId());
+ }
+ if (bUnmark && nPos!=CONTAINER_ENTRY_NOTFOUND) {
+ bChgd=TRUE;
+ pPts->Remove(nPos);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (bChgd) {
+ AdjustMarkHdl();
+ MarkListHasChanged();
+ }
+ return bChgd;
+}
+
+BOOL SdrMarkView::PickGluePoint(const Point& rPnt, SdrObject*& rpObj, USHORT& rnId, SdrPageView*& rpPV, ULONG nOptions) const
+{
+ SdrObject* pObj0=rpObj;
+ //SdrPageView* pPV0=rpPV;
+ USHORT nId0=rnId;
+ rpObj=NULL; rpPV=NULL; rnId=0;
+ if (!IsGluePointEditMode()) return FALSE;
+ BOOL bBack=(nOptions & SDRSEARCH_BACKWARD) !=0;
+ BOOL bNext=(nOptions & SDRSEARCH_NEXT) !=0;
+ OutputDevice* pOut=(OutputDevice*)pActualOutDev;
+ if (pOut==NULL) pOut=GetFirstOutputDevice(); //GetWin(0);
+ if (pOut==NULL) return FALSE;
+ SortMarkedObjects();
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ ULONG nMarkNum=bBack ? 0 : nMarkAnz;
+ if (bNext) {
+ nMarkNum=((SdrMarkView*)this)->TryToFindMarkedObject(pObj0);
+ if (nMarkNum==CONTAINER_ENTRY_NOTFOUND) return FALSE;
+ if (!bBack) nMarkNum++;
+ }
+ while (bBack ? nMarkNum<nMarkAnz : nMarkNum>0) {
+ if (!bBack) nMarkNum--;
+ const SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrPageView* pPV=pM->GetPageView();
+ const SdrGluePointList* pGPL=pObj->GetGluePointList();
+ if (pGPL!=NULL) {
+ USHORT nNum=pGPL->HitTest(rPnt,*pOut,pObj,bBack,bNext,nId0);
+ if (nNum!=SDRGLUEPOINT_NOTFOUND)
+ {
+ // #i38892#
+ const SdrGluePoint& rCandidate = (*pGPL)[nNum];
+
+ if(rCandidate.IsUserDefined())
+ {
+ rpObj=pObj;
+ rnId=(*pGPL)[nNum].GetId();
+ rpPV=pPV;
+ return TRUE;
+ }
+ }
+ }
+ bNext=FALSE; // HitNextGluePoint nur beim ersten Obj
+ if (bBack) nMarkNum++;
+ }
+ return FALSE;
+}
+
+BOOL SdrMarkView::MarkGluePoint(const SdrObject* pObj, USHORT nId, const SdrPageView* /*pPV*/, BOOL bUnmark)
+{
+ if (!IsGluePointEditMode()) return FALSE;
+ ForceUndirtyMrkPnt();
+ BOOL bChgd=FALSE;
+ if (pObj!=NULL) {
+ ULONG nMarkPos=TryToFindMarkedObject(pObj);
+ if (nMarkPos!=CONTAINER_ENTRY_NOTFOUND) {
+ SdrMark* pM=GetSdrMarkByIndex(nMarkPos);
+ SdrUShortCont* pPts=bUnmark ? pM->GetMarkedGluePoints() : pM->ForceMarkedGluePoints();
+ if (pPts!=NULL) {
+ ULONG nPointPos=pPts->GetPos(nId);
+ if (!bUnmark && nPointPos==CONTAINER_ENTRY_NOTFOUND) {
+ bChgd=TRUE;
+ pPts->Insert(nId);
+ }
+ if (bUnmark && nPointPos!=CONTAINER_ENTRY_NOTFOUND) {
+ bChgd=TRUE;
+ pPts->Remove(nPointPos);
+ }
+ }
+ } else {
+ // Objekt implizit markieren ...
+ // ... fehlende Implementation
+ }
+ }
+ if (bChgd) {
+ AdjustMarkHdl();
+ MarkListHasChanged();
+ }
+ return bChgd;
+}
+
+BOOL SdrMarkView::IsGluePointMarked(const SdrObject* pObj, USHORT nId) const
+{
+ ForceUndirtyMrkPnt();
+ BOOL bRet=FALSE;
+ ULONG nPos=((SdrMarkView*)this)->TryToFindMarkedObject(pObj); // casting auf NonConst
+ if (nPos!=CONTAINER_ENTRY_NOTFOUND) {
+ const SdrMark* pM=GetSdrMarkByIndex(nPos);
+ const SdrUShortCont* pPts=pM->GetMarkedGluePoints();
+ if (pPts!=NULL) {
+ bRet=pPts->Exist(nId);
+ }
+ }
+ return bRet;
+}
+
+BOOL SdrMarkView::UnmarkGluePoint(const SdrHdl& rHdl)
+{
+ if (&rHdl!=NULL && rHdl.GetKind()==HDL_GLUE && rHdl.GetObj()!=NULL) {
+ return MarkGluePoint(rHdl.GetObj(),(sal_uInt16)rHdl.GetObjHdlNum(),rHdl.GetPageView(),TRUE);
+ } else return FALSE;
+}
+
+SdrHdl* SdrMarkView::GetGluePointHdl(const SdrObject* pObj, USHORT nId) const
+{
+ ForceUndirtyMrkPnt();
+ ULONG nHdlAnz=aHdl.GetHdlCount();
+ for (ULONG nHdlNum=0; nHdlNum<nHdlAnz; nHdlNum++) {
+ SdrHdl* pHdl=aHdl.GetHdl(nHdlNum);
+ if (pHdl->GetObj()==pObj &&
+ pHdl->GetKind()==HDL_GLUE &&
+ pHdl->GetObjHdlNum()==nId ) return pHdl;
+ }
+ return NULL;
+}
+
+BOOL SdrMarkView::MarkNextGluePoint(BOOL /*bPrev*/)
+{
+ ForceUndirtyMrkPnt();
+ BOOL bChgd=FALSE;
+ SortMarkedObjects();
+ // ...
+ if (bChgd) {
+ MarkListHasChanged();
+ }
+ return bChgd;
+}
+
+BOOL SdrMarkView::MarkNextGluePoint(const Point& /*rPnt*/, BOOL /*bPrev*/)
+{
+ ForceUndirtyMrkPnt();
+ BOOL bChgd=FALSE;
+ SortMarkedObjects();
+ // ...
+ if (bChgd) {
+ MarkListHasChanged();
+ }
+ return bChgd;
+}
+
+const Rectangle& SdrMarkView::GetMarkedGluePointsRect() const
+{
+ ForceUndirtyMrkPnt();
+ if (bMarkedPointsRectsDirty) ImpSetPointsRects();
+ return aMarkedGluePointsRect;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
new file mode 100644
index 000000000000..ea74bd387e89
--- /dev/null
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -0,0 +1,3507 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/svdoashp.hxx>
+#include "unoapi.hxx"
+#include <svx/unoshape.hxx>
+#include <ucbhelper/content.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <unotools/datetime.hxx>
+#include <sfx2/lnkbase.hxx>
+#include <tools/urlobj.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/XCustomShapeEngine.hpp>
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include "unopolyhelper.hxx"
+#include <comphelper/processfactory.hxx>
+#include <svl/urihelper.hxx>
+#include <com/sun/star/uno/Sequence.h>
+#include <svx/svdogrp.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include <svx/svddrag.hxx>
+#include <svx/xpool.hxx>
+#include <svx/xpoly.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include "svditer.hxx"
+#include <svx/svdobj.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdattrx.hxx> // NotPersistItems
+#include <svx/svdoedge.hxx> // #32383# Die Verbinder nach Move nochmal anbroadcasten
+#include "svdglob.hxx" // StringCache
+#include "svdstr.hrc" // Objektname
+#include <editeng/eeitem.hxx>
+#include "editeng/editstat.hxx"
+#include <svx/svdoutl.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/sdtfchim.hxx>
+#include "../customshapes/EnhancedCustomShapeGeometry.hxx"
+#include "../customshapes/EnhancedCustomShapeTypeNames.hxx"
+#include "../customshapes/EnhancedCustomShape2d.hxx"
+#include <com/sun/star/beans/PropertyValues.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeTextFrame.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
+#include <editeng/writingmodeitem.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/svxids.hrc>
+#include <svl/whiter.hxx>
+#include <svx/sdr/properties/customshapeproperties.hxx>
+#include <svx/sdr/contact/viewcontactofsdrobjcustomshape.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svx/svdview.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+// #104018# replace macros above with type-safe methods
+inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
+inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::drawing;
+
+static MSO_SPT ImpGetCustomShapeType( const SdrObjCustomShape& rCustoShape )
+{
+ MSO_SPT eRetValue = mso_sptNil;
+
+ rtl::OUString aEngine( ( (SdrCustomShapeEngineItem&)rCustoShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_ENGINE ) ).GetValue() );
+ if ( !aEngine.getLength() || aEngine.equalsAscii( "com.sun.star.drawing.EnhancedCustomShapeEngine" ) )
+ {
+ rtl::OUString sShapeType;
+ const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
+ SdrCustomShapeGeometryItem& rGeometryItem( (SdrCustomShapeGeometryItem&)rCustoShape.GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ Any* pAny = rGeometryItem.GetPropertyValueByName( sType );
+ if ( pAny && ( *pAny >>= sShapeType ) )
+ eRetValue = EnhancedCustomShapeTypeNames::Get( sShapeType );
+ }
+ return eRetValue;
+};
+
+static sal_Bool ImpVerticalSwitch( const SdrObjCustomShape& rCustoShape )
+{
+ sal_Bool bRet = sal_False;
+ MSO_SPT eShapeType( ImpGetCustomShapeType( rCustoShape ) );
+ switch( eShapeType )
+ {
+ case mso_sptAccentBorderCallout90 : // 2 ortho
+ case mso_sptBorderCallout1 : // 2 diag
+ case mso_sptBorderCallout2 : // 3
+ {
+ bRet = sal_True;
+ }
+ break;
+/*
+ case mso_sptCallout1 :
+ case mso_sptAccentCallout1 :
+ case mso_sptAccentBorderCallout1 :
+ case mso_sptBorderCallout90 :
+ case mso_sptCallout90 :
+ case mso_sptAccentCallout90 :
+ case mso_sptCallout2 :
+ case mso_sptCallout3 :
+ case mso_sptAccentCallout2 :
+ case mso_sptAccentCallout3 :
+ case mso_sptBorderCallout3 :
+ case mso_sptAccentBorderCallout2 :
+ case mso_sptAccentBorderCallout3 :
+*/
+ default: break;
+ }
+ return bRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #i37011# create a clone with all attributes changed to shadow attributes
+// and translation executed, too.
+SdrObject* ImpCreateShadowObjectClone(const SdrObject& rOriginal, const SfxItemSet& rOriginalSet)
+{
+ SdrObject* pRetval = 0L;
+ const sal_Bool bShadow(((SdrShadowItem&)rOriginalSet.Get(SDRATTR_SHADOW)).GetValue());
+
+ if(bShadow)
+ {
+ // create a shadow representing object
+ const sal_Int32 nXDist(((SdrShadowXDistItem&)(rOriginalSet.Get(SDRATTR_SHADOWXDIST))).GetValue());
+ const sal_Int32 nYDist(((SdrShadowYDistItem&)(rOriginalSet.Get(SDRATTR_SHADOWYDIST))).GetValue());
+ const ::Color aShadowColor(((SdrShadowColorItem&)(rOriginalSet.Get(SDRATTR_SHADOWCOLOR))).GetColorValue());
+ const sal_uInt16 nShadowTransparence(((SdrShadowTransparenceItem&)(rOriginalSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue());
+ pRetval = rOriginal.Clone();
+ DBG_ASSERT(pRetval, "ImpCreateShadowObjectClone: Could not clone object (!)");
+
+ // look for used stuff
+ SdrObjListIter aIterator(rOriginal);
+ sal_Bool bLineUsed(sal_False);
+ sal_Bool bAllFillUsed(sal_False);
+ sal_Bool bSolidFillUsed(sal_False);
+ sal_Bool bGradientFillUsed(sal_False);
+ sal_Bool bHatchFillUsed(sal_False);
+ sal_Bool bBitmapFillUsed(sal_False);
+
+ while(aIterator.IsMore())
+ {
+ SdrObject* pObj = aIterator.Next();
+ XFillStyle eFillStyle = ((XFillStyleItem&)(pObj->GetMergedItem(XATTR_FILLSTYLE))).GetValue();
+
+ if(!bLineUsed)
+ {
+ XLineStyle eLineStyle = ((XLineStyleItem&)(pObj->GetMergedItem(XATTR_LINESTYLE))).GetValue();
+
+ if(XLINE_NONE != eLineStyle)
+ {
+ bLineUsed = sal_True;
+ }
+ }
+
+ if(!bAllFillUsed)
+ {
+ if(!bSolidFillUsed && XFILL_SOLID == eFillStyle)
+ {
+ bSolidFillUsed = sal_True;
+ bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed);
+ }
+ if(!bGradientFillUsed && XFILL_GRADIENT == eFillStyle)
+ {
+ bGradientFillUsed = sal_True;
+ bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed);
+ }
+ if(!bHatchFillUsed && XFILL_HATCH == eFillStyle)
+ {
+ bHatchFillUsed = sal_True;
+ bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed);
+ }
+ if(!bBitmapFillUsed && XFILL_BITMAP == eFillStyle)
+ {
+ bBitmapFillUsed = sal_True;
+ bAllFillUsed = (bSolidFillUsed || bGradientFillUsed || bHatchFillUsed || bBitmapFillUsed);
+ }
+ }
+ }
+
+ // translate to shadow coordinates
+ pRetval->NbcMove(Size(nXDist, nYDist));
+
+ // set items as needed
+ SfxItemSet aTempSet(rOriginalSet);
+
+ // SJ: #40108# :-( if a SvxWritingModeItem (Top->Bottom) is set the text object
+ // is creating a paraobject, but paraobjects can not be created without model. So
+ // we are preventing the crash by setting the writing mode always left to right,
+ // this is not bad since our shadow geometry does not contain text.
+ aTempSet.Put( SvxWritingModeItem( com::sun::star::text::WritingMode_LR_TB, SDRATTR_TEXTDIRECTION ) );
+
+ // no shadow
+ aTempSet.Put(SdrShadowItem(sal_False));
+ aTempSet.Put(SdrShadowXDistItem(0L));
+ aTempSet.Put(SdrShadowYDistItem(0L));
+
+ // line color and transparence like shadow
+ if(bLineUsed)
+ {
+ aTempSet.Put(XLineColorItem(String(), aShadowColor));
+ aTempSet.Put(XLineTransparenceItem(nShadowTransparence));
+ }
+
+ // fill color and transparence like shadow
+ if(bSolidFillUsed)
+ {
+ aTempSet.Put(XFillColorItem(String(), aShadowColor));
+ aTempSet.Put(XFillTransparenceItem(nShadowTransparence));
+ }
+
+ // gradient and transparence like shadow
+ if(bGradientFillUsed)
+ {
+ XGradient aGradient(((XFillGradientItem&)(rOriginalSet.Get(XATTR_FILLGRADIENT))).GetGradientValue());
+ sal_uInt8 nStartLuminance(aGradient.GetStartColor().GetLuminance());
+ sal_uInt8 nEndLuminance(aGradient.GetEndColor().GetLuminance());
+
+ if(aGradient.GetStartIntens() != 100)
+ {
+ nStartLuminance = (sal_uInt8)(nStartLuminance * ((double)aGradient.GetStartIntens() / 100.0));
+ }
+
+ if(aGradient.GetEndIntens() != 100)
+ {
+ nEndLuminance = (sal_uInt8)(nEndLuminance * ((double)aGradient.GetEndIntens() / 100.0));
+ }
+
+ ::Color aStartColor(
+ (sal_uInt8)((nStartLuminance * aShadowColor.GetRed()) / 256),
+ (sal_uInt8)((nStartLuminance * aShadowColor.GetGreen()) / 256),
+ (sal_uInt8)((nStartLuminance * aShadowColor.GetBlue()) / 256));
+
+ ::Color aEndColor(
+ (sal_uInt8)((nEndLuminance * aShadowColor.GetRed()) / 256),
+ (sal_uInt8)((nEndLuminance * aShadowColor.GetGreen()) / 256),
+ (sal_uInt8)((nEndLuminance * aShadowColor.GetBlue()) / 256));
+
+ aGradient.SetStartColor(aStartColor);
+ aGradient.SetEndColor(aEndColor);
+ aTempSet.Put(XFillGradientItem(aTempSet.GetPool(), aGradient));
+ aTempSet.Put(XFillTransparenceItem(nShadowTransparence));
+ }
+
+ // hatch and transparence like shadow
+ if(bHatchFillUsed)
+ {
+ XHatch aHatch(((XFillHatchItem&)(rOriginalSet.Get(XATTR_FILLHATCH))).GetHatchValue());
+ aHatch.SetColor(aShadowColor);
+ aTempSet.Put(XFillHatchItem(aTempSet.GetPool(), aHatch));
+ aTempSet.Put(XFillTransparenceItem(nShadowTransparence));
+ }
+
+ // bitmap and transparence like shadow
+ if(bBitmapFillUsed)
+ {
+ XOBitmap aFillBitmap(((XFillBitmapItem&)(rOriginalSet.Get(XATTR_FILLBITMAP))).GetBitmapValue());
+ Bitmap aSourceBitmap(aFillBitmap.GetBitmap());
+ BitmapReadAccess* pReadAccess = aSourceBitmap.AcquireReadAccess();
+
+ if(!aSourceBitmap.IsEmpty())
+ {
+ if(pReadAccess)
+ {
+ Bitmap aDestBitmap(aSourceBitmap.GetSizePixel(), 24L);
+ BitmapWriteAccess* pWriteAccess = aDestBitmap.AcquireWriteAccess();
+
+ if(pWriteAccess)
+ {
+ for(sal_Int32 y(0L); y < pReadAccess->Height(); y++)
+ {
+ for(sal_Int32 x(0L); x < pReadAccess->Width(); x++)
+ {
+ sal_uInt16 nLuminance((sal_uInt16)pReadAccess->GetLuminance(y, x) + 1);
+ const BitmapColor aDestColor(
+ (sal_uInt8)((nLuminance * (sal_uInt16)aShadowColor.GetRed()) >> 8L),
+ (sal_uInt8)((nLuminance * (sal_uInt16)aShadowColor.GetGreen()) >> 8L),
+ (sal_uInt8)((nLuminance * (sal_uInt16)aShadowColor.GetBlue()) >> 8L));
+ pWriteAccess->SetPixel(y, x, aDestColor);
+ }
+ }
+
+ aDestBitmap.ReleaseAccess(pWriteAccess);
+ aFillBitmap.SetBitmap(aDestBitmap);
+ }
+
+ aSourceBitmap.ReleaseAccess(pReadAccess);
+ }
+ }
+
+ aTempSet.Put(XFillBitmapItem(aTempSet.GetPool(), aFillBitmap));
+ aTempSet.Put(XFillTransparenceItem(nShadowTransparence));
+ }
+
+ // set attributes and paint shadow object
+ pRetval->SetMergedItemSet( aTempSet );
+ }
+ return pRetval;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Reference< XCustomShapeEngine > SdrObjCustomShape::GetCustomShapeEngine( const SdrObjCustomShape* pCustomShape )
+{
+ Reference< XCustomShapeEngine > xCustomShapeEngine;
+ String aEngine(((SdrCustomShapeEngineItem&)pCustomShape->GetMergedItem( SDRATTR_CUSTOMSHAPE_ENGINE )).GetValue());
+ if ( !aEngine.Len() )
+ aEngine = String( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.drawing.EnhancedCustomShapeEngine" ) );
+
+ Reference< XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+
+ Reference< XShape > aXShape = GetXShapeForSdrObject( (SdrObjCustomShape*)pCustomShape );
+ if ( aXShape.is() )
+ {
+ if ( aEngine.Len() && xFactory.is() )
+ {
+ Sequence< Any > aArgument( 1 );
+ Sequence< PropertyValue > aPropValues( 1 );
+ aPropValues[ 0 ].Name = rtl::OUString::createFromAscii( "CustomShape" );
+ aPropValues[ 0 ].Value <<= aXShape;
+ aArgument[ 0 ] <<= aPropValues;
+ Reference< XInterface > xInterface( xFactory->createInstanceWithArguments( aEngine, aArgument ) );
+ if ( xInterface.is() )
+ xCustomShapeEngine = Reference< XCustomShapeEngine >( xInterface, UNO_QUERY );
+ }
+ }
+ return xCustomShapeEngine;
+}
+const SdrObject* SdrObjCustomShape::GetSdrObjectFromCustomShape() const
+{
+ if ( !mXRenderedCustomShape.is() )
+ {
+ Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( this ) );
+ if ( xCustomShapeEngine.is() )
+ ((SdrObjCustomShape*)this)->mXRenderedCustomShape = xCustomShapeEngine->render();
+ }
+ SdrObject* pRenderedCustomShape = mXRenderedCustomShape.is()
+ ? GetSdrObjectFromXShape( mXRenderedCustomShape )
+ : NULL;
+ return pRenderedCustomShape;
+}
+
+// #i37011# Shadow geometry creation
+const SdrObject* SdrObjCustomShape::GetSdrObjectShadowFromCustomShape() const
+{
+ if(!mpLastShadowGeometry)
+ {
+ const SdrObject* pSdrObject = GetSdrObjectFromCustomShape();
+ if(pSdrObject)
+ {
+ const SfxItemSet& rOriginalSet = GetObjectItemSet();
+ const sal_Bool bShadow(((SdrShadowItem&)rOriginalSet.Get( SDRATTR_SHADOW )).GetValue());
+
+ if(bShadow)
+ {
+ // create a clone with all attributes changed to shadow attributes
+ // and translation executed, too.
+ ((SdrObjCustomShape*)this)->mpLastShadowGeometry = ImpCreateShadowObjectClone(*pSdrObject, rOriginalSet);
+ }
+ }
+ }
+
+ return mpLastShadowGeometry;
+}
+
+sal_Bool SdrObjCustomShape::IsTextPath() const
+{
+ const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
+ sal_Bool bTextPathOn = sal_False;
+ SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sTextPath );
+ if ( pAny )
+ *pAny >>= bTextPathOn;
+ return bTextPathOn;
+}
+
+sal_Bool SdrObjCustomShape::UseNoFillStyle() const
+{
+ sal_Bool bRet = sal_False;
+ rtl::OUString sShapeType;
+ const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
+ SdrCustomShapeGeometryItem& rGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ Any* pAny = rGeometryItem.GetPropertyValueByName( sType );
+ if ( pAny )
+ *pAny >>= sShapeType;
+ bRet = IsCustomShapeFilledByDefault( EnhancedCustomShapeTypeNames::Get( sType ) ) == 0;
+
+ return bRet;
+}
+
+sal_Bool SdrObjCustomShape::IsMirroredX() const
+{
+ sal_Bool bMirroredX = sal_False;
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
+ com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredX );
+ if ( pAny )
+ *pAny >>= bMirroredX;
+ return bMirroredX;
+}
+sal_Bool SdrObjCustomShape::IsMirroredY() const
+{
+ sal_Bool bMirroredY = sal_False;
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
+ com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredY );
+ if ( pAny )
+ *pAny >>= bMirroredY;
+ return bMirroredY;
+}
+void SdrObjCustomShape::SetMirroredX( const sal_Bool bMirrorX )
+{
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
+ //com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredX );
+ PropertyValue aPropVal;
+ aPropVal.Name = sMirroredX;
+ aPropVal.Value <<= bMirrorX;
+ aGeometryItem.SetPropertyValue( aPropVal );
+ SetMergedItem( aGeometryItem );
+}
+void SdrObjCustomShape::SetMirroredY( const sal_Bool bMirrorY )
+{
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
+ //com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredY );
+ PropertyValue aPropVal;
+ aPropVal.Name = sMirroredY;
+ aPropVal.Value <<= bMirrorY;
+ aGeometryItem.SetPropertyValue( aPropVal );
+ SetMergedItem( aGeometryItem );
+}
+
+double SdrObjCustomShape::GetObjectRotation() const
+{
+ return fObjectRotation;
+}
+
+double SdrObjCustomShape::GetExtraTextRotation() const
+{
+ const com::sun::star::uno::Any* pAny;
+ SdrCustomShapeGeometryItem& rGeometryItem = (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ const rtl::OUString sTextRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "TextRotateAngle" ) );
+ pAny = rGeometryItem.GetPropertyValueByName( sTextRotateAngle );
+ double fExtraTextRotateAngle = 0.0;
+ if ( pAny )
+ *pAny >>= fExtraTextRotateAngle;
+ return fExtraTextRotateAngle;
+}
+sal_Bool SdrObjCustomShape::GetTextBounds( Rectangle& rTextBound ) const
+{
+ sal_Bool bRet = sal_False;
+ Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( this ) ); // a candidate for being cached
+ if ( xCustomShapeEngine.is() )
+ {
+ awt::Rectangle aR( xCustomShapeEngine->getTextBounds() );
+ if ( aR.Width || aR.Height )
+ {
+ rTextBound = Rectangle( Point( aR.X, aR.Y ), Size( aR.Width, aR.Height ) );
+ bRet = sal_True;
+ }
+ }
+ return bRet;
+}
+basegfx::B2DPolyPolygon SdrObjCustomShape::GetLineGeometry( const SdrObjCustomShape* pCustomShape, const sal_Bool bBezierAllowed )
+{
+ basegfx::B2DPolyPolygon aRetval;
+ sal_Bool bRet = sal_False;
+ Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( pCustomShape ) );
+ if ( xCustomShapeEngine.is() )
+ {
+ com::sun::star::drawing::PolyPolygonBezierCoords aBezierCoords = xCustomShapeEngine->getLineGeometry();
+ try
+ {
+ aRetval = SvxConvertPolyPolygonBezierToB2DPolyPolygon( &aBezierCoords );
+ if ( !bBezierAllowed && aRetval.areControlPointsUsed())
+ {
+ aRetval = basegfx::tools::adaptiveSubdivideByAngle(aRetval);
+ }
+ bRet = sal_True;
+ }
+ catch ( const com::sun::star::lang::IllegalArgumentException )
+ {
+ }
+ }
+ return aRetval;
+}
+
+std::vector< SdrCustomShapeInteraction > SdrObjCustomShape::GetInteractionHandles( const SdrObjCustomShape* pCustomShape ) const
+{
+ std::vector< SdrCustomShapeInteraction > xRet;
+ try
+ {
+ Reference< XCustomShapeEngine > xCustomShapeEngine( GetCustomShapeEngine( pCustomShape ) );
+ if ( xCustomShapeEngine.is() )
+ {
+ int i;
+ Sequence< Reference< XCustomShapeHandle > > xInteractionHandles( xCustomShapeEngine->getInteraction() );
+ for ( i = 0; i < xInteractionHandles.getLength(); i++ )
+ {
+ if ( xInteractionHandles[ i ].is() )
+ {
+ SdrCustomShapeInteraction aSdrCustomShapeInteraction;
+ aSdrCustomShapeInteraction.xInteraction = xInteractionHandles[ i ];
+ aSdrCustomShapeInteraction.aPosition = xInteractionHandles[ i ]->getPosition();
+
+ sal_Int32 nMode = 0;
+ switch( ImpGetCustomShapeType( *this ) )
+ {
+ case mso_sptAccentBorderCallout90 : // 2 ortho
+ {
+ if ( !i )
+ nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED;
+ else if ( i == 1)
+ nMode |= CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X | CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y | CUSTOMSHAPE_HANDLE_MOVE_SHAPE | CUSTOMSHAPE_HANDLE_ORTHO4;
+ }
+ break;
+
+ case mso_sptWedgeRectCallout :
+ case mso_sptWedgeRRectCallout :
+ case mso_sptCloudCallout :
+ case mso_sptWedgeEllipseCallout :
+ {
+ if ( !i )
+ nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED;
+ }
+ break;
+
+ case mso_sptBorderCallout1 : // 2 diag
+ {
+ if ( !i )
+ nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED;
+ else if ( i == 1 )
+ nMode |= CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X | CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y | CUSTOMSHAPE_HANDLE_MOVE_SHAPE;
+ }
+ break;
+ case mso_sptBorderCallout2 : // 3
+ {
+ if ( !i )
+ nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED;
+ else if ( i == 2 )
+ nMode |= CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X | CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y | CUSTOMSHAPE_HANDLE_MOVE_SHAPE;
+ }
+ break;
+ case mso_sptCallout90 :
+ case mso_sptAccentCallout90 :
+ case mso_sptBorderCallout90 :
+ case mso_sptCallout1 :
+ case mso_sptCallout2 :
+ case mso_sptCallout3 :
+ case mso_sptAccentCallout1 :
+ case mso_sptAccentCallout2 :
+ case mso_sptAccentCallout3 :
+ case mso_sptBorderCallout3 :
+ case mso_sptAccentBorderCallout1 :
+ case mso_sptAccentBorderCallout2 :
+ case mso_sptAccentBorderCallout3 :
+ {
+ if ( !i )
+ nMode |= CUSTOMSHAPE_HANDLE_RESIZE_FIXED | CUSTOMSHAPE_HANDLE_CREATE_FIXED;
+ }
+ break;
+ default: break;
+ }
+ aSdrCustomShapeInteraction.nMode = nMode;
+ xRet.push_back( aSdrCustomShapeInteraction );
+ }
+ }
+ }
+ }
+ catch( const uno::RuntimeException& )
+ {
+ }
+ return xRet;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+#define DEFAULT_MINIMUM_SIGNED_COMPARE ((sal_Int32)0x80000000)
+#define DEFAULT_MAXIMUM_SIGNED_COMPARE ((sal_Int32)0x7fffffff)
+
+sdr::properties::BaseProperties* SdrObjCustomShape::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::CustomShapeProperties(*this);
+}
+
+TYPEINIT1(SdrObjCustomShape,SdrTextObj);
+SdrObjCustomShape::SdrObjCustomShape() :
+ SdrTextObj(),
+ fObjectRotation( 0.0 ),
+ mpLastShadowGeometry(0L)
+{
+ bTextFrame = TRUE;
+}
+
+SdrObjCustomShape::~SdrObjCustomShape()
+{
+ // delete buffered display geometry
+ InvalidateRenderGeometry();
+}
+
+void SdrObjCustomShape::MergeDefaultAttributes( const rtl::OUString* pType )
+{
+ PropertyValue aPropVal;
+ rtl::OUString sShapeType;
+ const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ if ( pType && pType->getLength() )
+ {
+ sal_Int32 nType = pType->toInt32();
+ if ( nType )
+ sShapeType = EnhancedCustomShapeTypeNames::Get( static_cast< MSO_SPT >( nType ) );
+ else
+ sShapeType = *pType;
+
+ aPropVal.Name = sType;
+ aPropVal.Value <<= sShapeType;
+ aGeometryItem.SetPropertyValue( aPropVal );
+ }
+ else
+ {
+ Any *pAny = aGeometryItem.GetPropertyValueByName( sType );
+ if ( pAny )
+ *pAny >>= sShapeType;
+ }
+ MSO_SPT eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
+
+ const sal_Int32* pDefData = NULL;
+ const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
+ if ( pDefCustomShape )
+ pDefData = pDefCustomShape->pDefData;
+
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeAdjustmentValue > seqAdjustmentValues;
+
+ //////////////////////
+ // AdjustmentValues //
+ //////////////////////
+ const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
+ const Any* pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sAdjustmentValues );
+ if ( pAny )
+ *pAny >>= seqAdjustmentValues;
+ if ( pDefCustomShape && pDefData ) // now check if we have to default some adjustment values
+ {
+ // first check if there are adjustment values are to be appended
+ sal_Int32 i, nAdjustmentValues = seqAdjustmentValues.getLength();
+ sal_Int32 nAdjustmentDefaults = *pDefData++;
+ if ( nAdjustmentDefaults > nAdjustmentValues )
+ {
+ seqAdjustmentValues.realloc( nAdjustmentDefaults );
+ for ( i = nAdjustmentValues; i < nAdjustmentDefaults; i++ )
+ {
+ seqAdjustmentValues[ i ].Value <<= pDefData[ i ];
+ seqAdjustmentValues[ i ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; // com::sun::star::beans::PropertyState_DEFAULT_VALUE;
+ }
+ }
+ // check if there are defaulted adjustment values that should be filled the hard coded defaults (pDefValue)
+ sal_Int32 nCount = nAdjustmentValues > nAdjustmentDefaults ? nAdjustmentDefaults : nAdjustmentValues;
+ for ( i = 0; i < nCount; i++ )
+ {
+ if ( seqAdjustmentValues[ i ].State != com::sun::star::beans::PropertyState_DIRECT_VALUE )
+ {
+ seqAdjustmentValues[ i ].Value <<= pDefData[ i ];
+ seqAdjustmentValues[ i ].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
+ }
+ }
+ }
+ aPropVal.Name = sAdjustmentValues;
+ aPropVal.Value <<= seqAdjustmentValues;
+ aGeometryItem.SetPropertyValue( aPropVal );
+
+ ///////////////
+ // Coordsize //
+ ///////////////
+ const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
+ const Any* pViewBox = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sViewBox );
+ com::sun::star::awt::Rectangle aViewBox;
+ if ( !pViewBox || !(*pViewBox >>= aViewBox ) )
+ {
+ if ( pDefCustomShape )
+ {
+ aViewBox.X = 0;
+ aViewBox.Y = 0;
+ aViewBox.Width = pDefCustomShape->nCoordWidth;
+ aViewBox.Height= pDefCustomShape->nCoordHeight;
+ aPropVal.Name = sViewBox;
+ aPropVal.Value <<= aViewBox;
+ aGeometryItem.SetPropertyValue( aPropVal );
+ }
+ }
+
+ const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
+
+ //////////////////////
+ // Path/Coordinates //
+ //////////////////////
+ const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
+ if ( !pAny && pDefCustomShape && pDefCustomShape->nVertices && pDefCustomShape->pVertices )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates;
+
+ sal_Int32 i, nCount = pDefCustomShape->nVertices;
+ seqCoordinates.realloc( nCount );
+ for ( i = 0; i < nCount; i++ )
+ {
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates[ i ].First, pDefCustomShape->pVertices[ i ].nValA );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates[ i ].Second, pDefCustomShape->pVertices[ i ].nValB );
+ }
+ aPropVal.Name = sCoordinates;
+ aPropVal.Value <<= seqCoordinates;
+ aGeometryItem.SetPropertyValue( sPath, aPropVal );
+ }
+
+ /////////////////////
+ // Path/GluePoints //
+ /////////////////////
+ const rtl::OUString sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sGluePoints );
+ if ( !pAny && pDefCustomShape && pDefCustomShape->nGluePoints && pDefCustomShape->pGluePoints )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints;
+ sal_Int32 i, nCount = pDefCustomShape->nGluePoints;
+ seqGluePoints.realloc( nCount );
+ for ( i = 0; i < nCount; i++ )
+ {
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints[ i ].First, pDefCustomShape->pGluePoints[ i ].nValA );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints[ i ].Second, pDefCustomShape->pGluePoints[ i ].nValB );
+ }
+ aPropVal.Name = sGluePoints;
+ aPropVal.Value <<= seqGluePoints;
+ aGeometryItem.SetPropertyValue( sPath, aPropVal );
+ }
+
+ ///////////////////
+ // Path/Segments //
+ ///////////////////
+ const rtl::OUString sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sSegments );
+ if ( !pAny && pDefCustomShape && pDefCustomShape->nElements && pDefCustomShape->pElements )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments;
+
+ sal_Int32 i, nCount = pDefCustomShape->nElements;
+ seqSegments.realloc( nCount );
+ for ( i = 0; i < nCount; i++ )
+ {
+ EnhancedCustomShapeSegment& rSegInfo = seqSegments[ i ];
+ sal_uInt16 nSDat = pDefCustomShape->pElements[ i ];
+ switch( nSDat >> 8 )
+ {
+ case 0x00 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::LINETO;
+ rSegInfo.Count = nSDat & 0xff;
+ if ( !rSegInfo.Count )
+ rSegInfo.Count = 1;
+ }
+ break;
+ case 0x20 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
+ rSegInfo.Count = nSDat & 0xff;
+ if ( !rSegInfo.Count )
+ rSegInfo.Count = 1;
+ }
+ break;
+ case 0x40 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
+ rSegInfo.Count = nSDat & 0xff;
+ if ( !rSegInfo.Count )
+ rSegInfo.Count = 1;
+ }
+ break;
+ case 0x60 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
+ rSegInfo.Count = 0;
+ }
+ break;
+ case 0x80 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
+ rSegInfo.Count = 0;
+ }
+ break;
+ case 0xa1 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO;
+ rSegInfo.Count = ( nSDat & 0xff ) / 3;
+ }
+ break;
+ case 0xa2 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE;
+ rSegInfo.Count = ( nSDat & 0xff ) / 3;
+ }
+ break;
+ case 0xa3 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARCTO;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa4 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa5 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa6 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa7 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX;
+ rSegInfo.Count = nSDat & 0xff;
+ }
+ break;
+ case 0xa8 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY;
+ rSegInfo.Count = nSDat & 0xff;
+ }
+ break;
+ case 0xaa :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
+ rSegInfo.Count = 0;
+ }
+ break;
+ case 0xab :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE;
+ rSegInfo.Count = 0;
+ }
+ break;
+ default:
+ case 0xf8 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::UNKNOWN;
+ rSegInfo.Count = nSDat;
+ }
+ break;
+ }
+ }
+ aPropVal.Name = sSegments;
+ aPropVal.Value <<= seqSegments;
+ aGeometryItem.SetPropertyValue( sPath, aPropVal );
+ }
+
+ ///////////////////
+ // Path/StretchX //
+ ///////////////////
+ const rtl::OUString sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchX );
+ if ( !pAny && pDefCustomShape )
+ {
+ sal_Int32 nXRef = pDefCustomShape->nXRef;
+ if ( ( nXRef != DEFAULT_MINIMUM_SIGNED_COMPARE ) )
+ {
+ aPropVal.Name = sStretchX;
+ aPropVal.Value <<= nXRef;
+ aGeometryItem.SetPropertyValue( sPath, aPropVal );
+ }
+ }
+
+ ///////////////////
+ // Path/StretchY //
+ ///////////////////
+ const rtl::OUString sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchY );
+ if ( !pAny && pDefCustomShape )
+ {
+ sal_Int32 nYRef = pDefCustomShape->nYRef;
+ if ( ( nYRef != DEFAULT_MINIMUM_SIGNED_COMPARE ) )
+ {
+ aPropVal.Name = sStretchY;
+ aPropVal.Value <<= nYRef;
+ aGeometryItem.SetPropertyValue( sPath, aPropVal );
+ }
+ }
+
+ /////////////////////
+ // Path/TextFrames //
+ /////////////////////
+ const rtl::OUString sTextFrames( RTL_CONSTASCII_USTRINGPARAM ( "TextFrames" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sTextFrames );
+ if ( !pAny && pDefCustomShape && pDefCustomShape->nTextRect && pDefCustomShape->pTextRect )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames;
+
+ sal_Int32 i, nCount = pDefCustomShape->nTextRect;
+ seqTextFrames.realloc( nCount );
+ const SvxMSDffTextRectangles* pRectangles = pDefCustomShape->pTextRect;
+ for ( i = 0; i < nCount; i++, pRectangles++ )
+ {
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].TopLeft.First, pRectangles->nPairA.nValA );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].TopLeft.Second, pRectangles->nPairA.nValB );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].BottomRight.First, pRectangles->nPairB.nValA );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames[ i ].BottomRight.Second, pRectangles->nPairB.nValB );
+ }
+ aPropVal.Name = sTextFrames;
+ aPropVal.Value <<= seqTextFrames;
+ aGeometryItem.SetPropertyValue( sPath, aPropVal );
+ }
+
+ ///////////////
+ // Equations //
+ ///////////////
+ const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sEquations );
+ if ( !pAny && pDefCustomShape && pDefCustomShape->nCalculation && pDefCustomShape->pCalculation )
+ {
+ com::sun::star::uno::Sequence< rtl::OUString > seqEquations;
+
+ sal_Int32 i, nCount = pDefCustomShape->nCalculation;
+ seqEquations.realloc( nCount );
+ const SvxMSDffCalculationData* pData = pDefCustomShape->pCalculation;
+ for ( i = 0; i < nCount; i++, pData++ )
+ seqEquations[ i ] = EnhancedCustomShape2d::GetEquation( pData->nFlags, pData->nVal[ 0 ], pData->nVal[ 1 ], pData->nVal[ 2 ] );
+ aPropVal.Name = sEquations;
+ aPropVal.Value <<= seqEquations;
+ aGeometryItem.SetPropertyValue( aPropVal );
+ }
+
+ /////////////
+ // Handles //
+ /////////////
+ const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sHandles );
+ if ( !pAny && pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles;
+
+ sal_Int32 i, n, nCount = pDefCustomShape->nHandles;
+ const SvxMSDffHandle* pData = pDefCustomShape->pHandles;
+ seqHandles.realloc( nCount );
+ for ( i = 0; i < nCount; i++, pData++ )
+ {
+ sal_Int32 nPropertiesNeeded = 1; // position is always needed
+ sal_Int32 nFlags = pData->nFlags;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
+ {
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
+ {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ }
+ }
+ else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
+ {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ }
+
+ n = 0;
+ com::sun::star::beans::PropertyValues& rPropValues = seqHandles[ i ];
+ rPropValues.realloc( nPropertiesNeeded );
+
+ // POSITION
+ {
+ const rtl::OUString sPosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First, pData->nPositionX, sal_True, sal_True );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second, pData->nPositionY, sal_True, sal_False );
+ rPropValues[ n ].Name = sPosition;
+ rPropValues[ n++ ].Value <<= aPosition;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
+ {
+ const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
+ sal_Bool bMirroredX = sal_True;
+ rPropValues[ n ].Name = sMirroredX;
+ rPropValues[ n++ ].Value <<= bMirroredX;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
+ {
+ const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
+ sal_Bool bMirroredY = sal_True;
+ rPropValues[ n ].Name = sMirroredY;
+ rPropValues[ n++ ].Value <<= bMirroredY;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
+ {
+ const rtl::OUString sSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) );
+ sal_Bool bSwitched = sal_True;
+ rPropValues[ n ].Name = sSwitched;
+ rPropValues[ n++ ].Value <<= bSwitched;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
+ {
+ const rtl::OUString sPolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.First, pData->nCenterX,
+ ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.Second, pData->nCenterY,
+ ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0, sal_False );
+ rPropValues[ n ].Name = sPolar;
+ rPropValues[ n++ ].Value <<= aCenter;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
+ {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMinimum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMinimum, pData->nRangeXMin,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True );
+ rPropValues[ n ].Name = sRadiusRangeMinimum;
+ rPropValues[ n++ ].Value <<= aRadiusRangeMinimum;
+ }
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMaximum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMaximum, pData->nRangeXMax,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
+ rPropValues[ n ].Name = sRadiusRangeMaximum;
+ rPropValues[ n++ ].Value <<= aRadiusRangeMaximum;
+ }
+ }
+ }
+ else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
+ {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMinimum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMinimum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum, pData->nRangeXMin,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True );
+ rPropValues[ n ].Name = sRangeXMinimum;
+ rPropValues[ n++ ].Value <<= aRangeXMinimum;
+ }
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMaximum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMaximum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum, pData->nRangeXMax,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
+ rPropValues[ n ].Name = sRangeXMaximum;
+ rPropValues[ n++ ].Value <<= aRangeXMaximum;
+ }
+ if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMinimum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMinimum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum, pData->nRangeYMin,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True );
+ rPropValues[ n ].Name = sRangeYMinimum;
+ rPropValues[ n++ ].Value <<= aRangeYMinimum;
+ }
+ if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMaximum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMaximum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum, pData->nRangeYMax,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0, sal_False );
+ rPropValues[ n ].Name = sRangeYMaximum;
+ rPropValues[ n++ ].Value <<= aRangeYMaximum;
+ }
+ }
+ }
+ aPropVal.Name = sHandles;
+ aPropVal.Value <<= seqHandles;
+ aGeometryItem.SetPropertyValue( aPropVal );
+ }
+ SetMergedItem( aGeometryItem );
+}
+
+sal_Bool SdrObjCustomShape::IsDefaultGeometry( const DefaultType eDefaultType ) const
+{
+ sal_Bool bIsDefaultGeometry = sal_False;
+
+ PropertyValue aPropVal;
+ rtl::OUString sShapeType;
+ const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+
+ Any *pAny = aGeometryItem.GetPropertyValueByName( sType );
+ if ( pAny )
+ *pAny >>= sShapeType;
+
+ MSO_SPT eSpType = EnhancedCustomShapeTypeNames::Get( sShapeType );
+
+ const mso_CustomShape* pDefCustomShape = GetCustomShapeContent( eSpType );
+ const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
+ switch( eDefaultType )
+ {
+ case DEFAULT_VIEWBOX :
+ {
+ const rtl::OUString sViewBox( RTL_CONSTASCII_USTRINGPARAM ( "ViewBox" ) );
+ const Any* pViewBox = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sViewBox );
+ com::sun::star::awt::Rectangle aViewBox;
+ if ( pViewBox && ( *pViewBox >>= aViewBox ) )
+ {
+ if ( ( aViewBox.Width == pDefCustomShape->nCoordWidth )
+ && ( aViewBox.Height == pDefCustomShape->nCoordHeight ) )
+ bIsDefaultGeometry = sal_True;
+ }
+ }
+ break;
+
+ case DEFAULT_PATH :
+ {
+ const rtl::OUString sCoordinates( RTL_CONSTASCII_USTRINGPARAM ( "Coordinates" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sCoordinates );
+ if ( pAny && pDefCustomShape && pDefCustomShape->nVertices && pDefCustomShape->pVertices )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqCoordinates1, seqCoordinates2;
+ if ( *pAny >>= seqCoordinates1 )
+ {
+ sal_Int32 i, nCount = pDefCustomShape->nVertices;
+ seqCoordinates2.realloc( nCount );
+ for ( i = 0; i < nCount; i++ )
+ {
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ i ].First, pDefCustomShape->pVertices[ i ].nValA );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqCoordinates2[ i ].Second, pDefCustomShape->pVertices[ i ].nValB );
+ }
+ if ( seqCoordinates1 == seqCoordinates2 )
+ bIsDefaultGeometry = sal_True;
+ }
+ }
+ else if ( pDefCustomShape && ( ( pDefCustomShape->nVertices == 0 ) || ( pDefCustomShape->pVertices == 0 ) ) )
+ bIsDefaultGeometry = sal_True;
+ }
+ break;
+
+ case DEFAULT_GLUEPOINTS :
+ {
+ const rtl::OUString sGluePoints( RTL_CONSTASCII_USTRINGPARAM ( "GluePoints" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sGluePoints );
+ if ( pAny && pDefCustomShape && pDefCustomShape->nGluePoints && pDefCustomShape->pGluePoints )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeParameterPair> seqGluePoints1, seqGluePoints2;
+ if ( *pAny >>= seqGluePoints1 )
+ {
+ sal_Int32 i, nCount = pDefCustomShape->nGluePoints;
+ seqGluePoints2.realloc( nCount );
+ for ( i = 0; i < nCount; i++ )
+ {
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints2[ i ].First, pDefCustomShape->pGluePoints[ i ].nValA );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqGluePoints2[ i ].Second, pDefCustomShape->pGluePoints[ i ].nValB );
+ }
+ if ( seqGluePoints1 == seqGluePoints2 )
+ bIsDefaultGeometry = sal_True;
+ }
+ }
+ else if ( pDefCustomShape && ( pDefCustomShape->nGluePoints == 0 ) )
+ bIsDefaultGeometry = sal_True;
+ }
+ break;
+
+ case DEFAULT_SEGMENTS :
+ {
+ ///////////////////
+ // Path/Segments //
+ ///////////////////
+ const rtl::OUString sSegments( RTL_CONSTASCII_USTRINGPARAM ( "Segments" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sSegments );
+ if ( pAny )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeSegment > seqSegments1, seqSegments2;
+ if ( *pAny >>= seqSegments1 )
+ {
+ if ( pDefCustomShape && pDefCustomShape->nElements && pDefCustomShape->pElements )
+ {
+ sal_Int32 i, nCount = pDefCustomShape->nElements;
+ if ( nCount )
+ {
+ seqSegments2.realloc( nCount );
+ for ( i = 0; i < nCount; i++ )
+ {
+ EnhancedCustomShapeSegment& rSegInfo = seqSegments2[ i ];
+ sal_uInt16 nSDat = pDefCustomShape->pElements[ i ];
+ switch( nSDat >> 8 )
+ {
+ case 0x00 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::LINETO;
+ rSegInfo.Count = nSDat & 0xff;
+ if ( !rSegInfo.Count )
+ rSegInfo.Count = 1;
+ }
+ break;
+ case 0x20 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CURVETO;
+ rSegInfo.Count = nSDat & 0xff;
+ if ( !rSegInfo.Count )
+ rSegInfo.Count = 1;
+ }
+ break;
+ case 0x40 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::MOVETO;
+ rSegInfo.Count = nSDat & 0xff;
+ if ( !rSegInfo.Count )
+ rSegInfo.Count = 1;
+ }
+ break;
+ case 0x60 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOSESUBPATH;
+ rSegInfo.Count = 0;
+ }
+ break;
+ case 0x80 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ENDSUBPATH;
+ rSegInfo.Count = 0;
+ }
+ break;
+ case 0xa1 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSETO;
+ rSegInfo.Count = ( nSDat & 0xff ) / 3;
+ }
+ break;
+ case 0xa2 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ANGLEELLIPSE;
+ rSegInfo.Count = ( nSDat & 0xff ) / 3;
+ }
+ break;
+ case 0xa3 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARCTO;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa4 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ARC;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa5 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARCTO;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa6 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::CLOCKWISEARC;
+ rSegInfo.Count = ( nSDat & 0xff ) >> 2;
+ }
+ break;
+ case 0xa7 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTX;
+ rSegInfo.Count = nSDat & 0xff;
+ }
+ break;
+ case 0xa8 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::ELLIPTICALQUADRANTY;
+ rSegInfo.Count = nSDat & 0xff;
+ }
+ break;
+ case 0xaa :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOFILL;
+ rSegInfo.Count = 0;
+ }
+ break;
+ case 0xab :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::NOSTROKE;
+ rSegInfo.Count = 0;
+ }
+ break;
+ default:
+ case 0xf8 :
+ {
+ rSegInfo.Command = EnhancedCustomShapeSegmentCommand::UNKNOWN;
+ rSegInfo.Count = nSDat;
+ }
+ break;
+ }
+ }
+ if ( seqSegments1 == seqSegments2 )
+ bIsDefaultGeometry = sal_True;
+ }
+ }
+ else
+ {
+ // check if its the default segment description ( M L Z N )
+ if ( seqSegments1.getLength() == 4 )
+ {
+ if ( ( seqSegments1[ 0 ].Command == EnhancedCustomShapeSegmentCommand::MOVETO )
+ && ( seqSegments1[ 1 ].Command == EnhancedCustomShapeSegmentCommand::LINETO )
+ && ( seqSegments1[ 2 ].Command == EnhancedCustomShapeSegmentCommand::CLOSESUBPATH )
+ && ( seqSegments1[ 3 ].Command == EnhancedCustomShapeSegmentCommand::ENDSUBPATH ) )
+ bIsDefaultGeometry = sal_True;
+ }
+ }
+ }
+ }
+ else if ( pDefCustomShape && ( ( pDefCustomShape->nElements == 0 ) || ( pDefCustomShape->pElements == 0 ) ) )
+ bIsDefaultGeometry = sal_True;
+ }
+ break;
+
+ case DEFAULT_STRETCHX :
+ {
+ const rtl::OUString sStretchX( RTL_CONSTASCII_USTRINGPARAM ( "StretchX" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchX );
+ if ( pAny && pDefCustomShape )
+ {
+ sal_Int32 nStretchX = 0;
+ if ( *pAny >>= nStretchX )
+ {
+ if ( pDefCustomShape->nXRef == nStretchX )
+ bIsDefaultGeometry = sal_True;
+ }
+ }
+ else if ( pDefCustomShape && ( pDefCustomShape->nXRef == DEFAULT_MINIMUM_SIGNED_COMPARE ) )
+ bIsDefaultGeometry = sal_True;
+ }
+ break;
+
+ case DEFAULT_STRETCHY :
+ {
+ const rtl::OUString sStretchY( RTL_CONSTASCII_USTRINGPARAM ( "StretchY" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sStretchY );
+ if ( pAny && pDefCustomShape )
+ {
+ sal_Int32 nStretchY = 0;
+ if ( *pAny >>= nStretchY )
+ {
+ if ( pDefCustomShape->nYRef == nStretchY )
+ bIsDefaultGeometry = sal_True;
+ }
+ }
+ else if ( pDefCustomShape && ( pDefCustomShape->nYRef == DEFAULT_MINIMUM_SIGNED_COMPARE ) )
+ bIsDefaultGeometry = sal_True;
+ }
+ break;
+
+ case DEFAULT_EQUATIONS :
+ {
+ const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM( "Equations" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sEquations );
+ if ( pAny && pDefCustomShape && pDefCustomShape->nCalculation && pDefCustomShape->pCalculation )
+ {
+ com::sun::star::uno::Sequence< rtl::OUString > seqEquations1, seqEquations2;
+ if ( *pAny >>= seqEquations1 )
+ {
+ sal_Int32 i, nCount = pDefCustomShape->nCalculation;
+ seqEquations2.realloc( nCount );
+
+ const SvxMSDffCalculationData* pData = pDefCustomShape->pCalculation;
+ for ( i = 0; i < nCount; i++, pData++ )
+ seqEquations2[ i ] = EnhancedCustomShape2d::GetEquation( pData->nFlags, pData->nVal[ 0 ], pData->nVal[ 1 ], pData->nVal[ 2 ] );
+
+ if ( seqEquations1 == seqEquations2 )
+ bIsDefaultGeometry = sal_True;
+ }
+ }
+ else if ( pDefCustomShape && ( ( pDefCustomShape->nCalculation == 0 ) || ( pDefCustomShape->pCalculation == 0 ) ) )
+ bIsDefaultGeometry = sal_True;
+ }
+ break;
+
+ case DEFAULT_TEXTFRAMES :
+ {
+ const rtl::OUString sTextFrames( RTL_CONSTASCII_USTRINGPARAM( "TextFrames" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sPath, sTextFrames );
+ if ( pAny && pDefCustomShape && pDefCustomShape->nTextRect && pDefCustomShape->pTextRect )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::drawing::EnhancedCustomShapeTextFrame > seqTextFrames1, seqTextFrames2;
+ if ( *pAny >>= seqTextFrames1 )
+ {
+ sal_Int32 i, nCount = pDefCustomShape->nTextRect;
+ seqTextFrames2.realloc( nCount );
+ const SvxMSDffTextRectangles* pRectangles = pDefCustomShape->pTextRect;
+ for ( i = 0; i < nCount; i++, pRectangles++ )
+ {
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].TopLeft.First, pRectangles->nPairA.nValA );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].TopLeft.Second, pRectangles->nPairA.nValB );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].BottomRight.First, pRectangles->nPairB.nValA );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeParameter( seqTextFrames2[ i ].BottomRight.Second, pRectangles->nPairB.nValB );
+ }
+ if ( seqTextFrames1 == seqTextFrames2 )
+ bIsDefaultGeometry = sal_True;
+ }
+ }
+ else if ( pDefCustomShape && ( ( pDefCustomShape->nTextRect == 0 ) || ( pDefCustomShape->pTextRect == 0 ) ) )
+ bIsDefaultGeometry = sal_True;
+ }
+ break;
+
+ case DEFAULT_HANDLES :
+ {
+ const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM( "Handles" ) );
+ pAny = ((SdrCustomShapeGeometryItem&)aGeometryItem).GetPropertyValueByName( sHandles );
+ if ( pAny && pDefCustomShape && pDefCustomShape->nHandles && pDefCustomShape->pHandles )
+ {
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValues > seqHandles1, seqHandles2;
+ if ( *pAny >>= seqHandles1 )
+ {
+ sal_Int32 i, n, nCount = pDefCustomShape->nHandles;
+ const SvxMSDffHandle* pData = pDefCustomShape->pHandles;
+ seqHandles2.realloc( nCount );
+ for ( i = 0; i < nCount; i++, pData++ )
+ {
+ sal_Int32 nPropertiesNeeded = 1; // position is always needed
+ sal_Int32 nFlags = pData->nFlags;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
+ {
+ nPropertiesNeeded++;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
+ {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ }
+ }
+ else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
+ {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ nPropertiesNeeded++;
+ }
+
+ n = 0;
+ com::sun::star::beans::PropertyValues& rPropValues = seqHandles2[ i ];
+ rPropValues.realloc( nPropertiesNeeded );
+
+ // POSITION
+ {
+ const rtl::OUString sPosition( RTL_CONSTASCII_USTRINGPARAM ( "Position" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aPosition;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.First, pData->nPositionX, sal_True, sal_True );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aPosition.Second, pData->nPositionY, sal_True, sal_False );
+ rPropValues[ n ].Name = sPosition;
+ rPropValues[ n++ ].Value <<= aPosition;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_X )
+ {
+ const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
+ sal_Bool bMirroredX = sal_True;
+ rPropValues[ n ].Name = sMirroredX;
+ rPropValues[ n++ ].Value <<= bMirroredX;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_MIRRORED_Y )
+ {
+ const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
+ sal_Bool bMirroredY = sal_True;
+ rPropValues[ n ].Name = sMirroredY;
+ rPropValues[ n++ ].Value <<= bMirroredY;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_SWITCHED )
+ {
+ const rtl::OUString sSwitched( RTL_CONSTASCII_USTRINGPARAM ( "Switched" ) );
+ sal_Bool bSwitched = sal_True;
+ rPropValues[ n ].Name = sSwitched;
+ rPropValues[ n++ ].Value <<= bSwitched;
+ }
+ if ( nFlags & MSDFF_HANDLE_FLAGS_POLAR )
+ {
+ const rtl::OUString sPolar( RTL_CONSTASCII_USTRINGPARAM ( "Polar" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameterPair aCenter;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.First, pData->nCenterX,
+ ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_X_IS_SPECIAL ) != 0, sal_True );
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aCenter.Second, pData->nCenterY,
+ ( nFlags & MSDFF_HANDLE_FLAGS_CENTER_Y_IS_SPECIAL ) != 0, sal_False );
+ rPropValues[ n ].Name = sPolar;
+ rPropValues[ n++ ].Value <<= aCenter;
+ if ( nFlags & MSDFF_HANDLE_FLAGS_RADIUS_RANGE )
+ {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRadiusRangeMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMinimum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMinimum, pData->nRangeXMin,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True );
+ rPropValues[ n ].Name = sRadiusRangeMinimum;
+ rPropValues[ n++ ].Value <<= aRadiusRangeMinimum;
+ }
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRadiusRangeMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RadiusRangeMaximum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRadiusRangeMaximum, pData->nRangeXMax,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
+ rPropValues[ n ].Name = sRadiusRangeMaximum;
+ rPropValues[ n++ ].Value <<= aRadiusRangeMaximum;
+ }
+ }
+ }
+ else if ( nFlags & MSDFF_HANDLE_FLAGS_RANGE )
+ {
+ if ( pData->nRangeXMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRangeXMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMinimum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMinimum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMinimum, pData->nRangeXMin,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MIN_IS_SPECIAL ) != 0, sal_True );
+ rPropValues[ n ].Name = sRangeXMinimum;
+ rPropValues[ n++ ].Value <<= aRangeXMinimum;
+ }
+ if ( pData->nRangeXMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRangeXMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeXMaximum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeXMaximum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeXMaximum, pData->nRangeXMax,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_X_MAX_IS_SPECIAL ) != 0, sal_False );
+ rPropValues[ n ].Name = sRangeXMaximum;
+ rPropValues[ n++ ].Value <<= aRangeXMaximum;
+ }
+ if ( pData->nRangeYMin != DEFAULT_MINIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRangeYMinimum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMinimum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMinimum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMinimum, pData->nRangeYMin,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MIN_IS_SPECIAL ) != 0, sal_True );
+ rPropValues[ n ].Name = sRangeYMinimum;
+ rPropValues[ n++ ].Value <<= aRangeYMinimum;
+ }
+ if ( pData->nRangeYMax != DEFAULT_MAXIMUM_SIGNED_COMPARE )
+ {
+ const rtl::OUString sRangeYMaximum( RTL_CONSTASCII_USTRINGPARAM ( "RangeYMaximum" ) );
+ ::com::sun::star::drawing::EnhancedCustomShapeParameter aRangeYMaximum;
+ EnhancedCustomShape2d::SetEnhancedCustomShapeHandleParameter( aRangeYMaximum, pData->nRangeYMax,
+ ( nFlags & MSDFF_HANDLE_FLAGS_RANGE_Y_MAX_IS_SPECIAL ) != 0, sal_False );
+ rPropValues[ n ].Name = sRangeYMaximum;
+ rPropValues[ n++ ].Value <<= aRangeYMaximum;
+ }
+ }
+ }
+ if ( seqHandles1 == seqHandles2 )
+ bIsDefaultGeometry = sal_True;
+ }
+ }
+ else if ( pDefCustomShape && ( ( pDefCustomShape->nHandles == 0 ) || ( pDefCustomShape->pHandles == 0 ) ) )
+ bIsDefaultGeometry = sal_True;
+ }
+ break;
+ }
+ return bIsDefaultGeometry;
+}
+
+void SdrObjCustomShape::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bResizeFreeAllowed=fObjectRotation == 0.0;
+ rInfo.bResizePropAllowed=TRUE;
+ rInfo.bRotateFreeAllowed=TRUE;
+ rInfo.bRotate90Allowed =TRUE;
+ rInfo.bMirrorFreeAllowed=TRUE;
+ rInfo.bMirror45Allowed =TRUE;
+ rInfo.bMirror90Allowed =TRUE;
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ rInfo.bShearAllowed =TRUE;
+ rInfo.bEdgeRadiusAllowed=FALSE;
+ rInfo.bNoContortion =TRUE;
+
+ // #i37011#
+ if ( mXRenderedCustomShape.is() )
+ {
+ const SdrObject* pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape );
+ if ( pRenderedCustomShape )
+ {
+ // #i37262#
+ // Iterate self over the contained objects, since there are combinations of
+ // polygon and curve objects. In that case, aInfo.bCanConvToPath and
+ // aInfo.bCanConvToPoly would be false. What is needed here is an or, not an and.
+ SdrObjListIter aIterator(*pRenderedCustomShape);
+ while(aIterator.IsMore())
+ {
+ SdrObject* pCandidate = aIterator.Next();
+ SdrObjTransformInfoRec aInfo;
+ pCandidate->TakeObjInfo(aInfo);
+
+ // set path and poly conversion if one is possible since
+ // this object will first be broken
+ const sal_Bool bCanConvToPathOrPoly(aInfo.bCanConvToPath || aInfo.bCanConvToPoly);
+ if(rInfo.bCanConvToPath != bCanConvToPathOrPoly)
+ {
+ rInfo.bCanConvToPath = bCanConvToPathOrPoly;
+ }
+
+ if(rInfo.bCanConvToPoly != bCanConvToPathOrPoly)
+ {
+ rInfo.bCanConvToPoly = bCanConvToPathOrPoly;
+ }
+
+ if(rInfo.bCanConvToContour != aInfo.bCanConvToContour)
+ {
+ rInfo.bCanConvToContour = aInfo.bCanConvToContour;
+ }
+ }
+ }
+ }
+}
+
+void SdrObjCustomShape::SetModel(SdrModel* pNewModel)
+{
+ SdrTextObj::SetModel(pNewModel);
+ mXRenderedCustomShape.clear();
+}
+
+UINT16 SdrObjCustomShape::GetObjIdentifier() const
+{
+ return UINT16(OBJ_CUSTOMSHAPE);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrObjCustomShape::RecalcSnapRect()
+{
+ SdrTextObj::RecalcSnapRect();
+}
+const Rectangle& SdrObjCustomShape::GetSnapRect() const
+{
+ return SdrTextObj::GetSnapRect();
+}
+const Rectangle& SdrObjCustomShape::GetCurrentBoundRect() const
+{
+ return SdrTextObj::GetCurrentBoundRect();
+}
+const Rectangle& SdrObjCustomShape::GetLogicRect() const
+{
+ return SdrTextObj::GetLogicRect();
+}
+void SdrObjCustomShape::NbcSetSnapRect( const Rectangle& rRect )
+{
+ aRect=rRect;
+ ImpJustifyRect(aRect);
+ InvalidateRenderGeometry();
+ Rectangle aTextBound( aRect );
+ if ( GetTextBounds( aTextBound ) )
+ {
+ if ( pModel==NULL || !pModel->IsPasteResize() )
+ {
+ long nHDist=GetTextLeftDistance()+GetTextRightDistance();
+ long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
+ long nTWdt=aTextBound.GetWidth ()-1-nHDist; if (nTWdt<0) nTWdt=0;
+ long nTHgt=aTextBound.GetHeight()-1-nVDist; if (nTHgt<0) nTHgt=0;
+ if ( IsAutoGrowWidth() )
+ NbcSetMinTextFrameWidth( nTWdt );
+ if ( IsAutoGrowHeight() )
+ NbcSetMinTextFrameHeight( nTHgt );
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ }
+ ImpCheckShear();
+ SetRectsDirty();
+ SetChanged();
+}
+void SdrObjCustomShape::SetSnapRect( const Rectangle& rRect )
+{
+ Rectangle aBoundRect0;
+ if ( pUserCall )
+ aBoundRect0 = GetLastBoundRect();
+ NbcSetSnapRect( rRect );
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+void SdrObjCustomShape::NbcSetLogicRect( const Rectangle& rRect )
+{
+ aRect = rRect;
+ ImpJustifyRect( aRect );
+ InvalidateRenderGeometry();
+ Rectangle aTextBound( aRect );
+ if ( GetTextBounds( aTextBound ) )
+ {
+ long nHDist=GetTextLeftDistance()+GetTextRightDistance();
+ long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
+
+ long nTWdt=aTextBound.GetWidth()-1-nHDist; if (nTWdt<0) nTWdt=0;
+ long nTHgt=aTextBound.GetHeight()-1-nVDist; if (nTHgt<0) nTHgt=0;
+ if ( IsAutoGrowWidth() )
+ NbcSetMinTextFrameWidth( nTWdt );
+ if ( IsAutoGrowHeight() )
+ NbcSetMinTextFrameHeight( nTHgt );
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ SetRectsDirty();
+ SetChanged();
+}
+void SdrObjCustomShape::SetLogicRect( const Rectangle& rRect )
+{
+ Rectangle aBoundRect0;
+ if ( pUserCall )
+ aBoundRect0 = GetLastBoundRect();
+ NbcSetLogicRect(rRect);
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+void SdrObjCustomShape::Move( const Size& rSiz )
+{
+ if ( rSiz.Width() || rSiz.Height() )
+ {
+ Rectangle aBoundRect0;
+ if ( pUserCall )
+ aBoundRect0 = GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcMove(rSiz);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
+ }
+}
+void SdrObjCustomShape::NbcMove( const Size& rSiz )
+{
+ SdrTextObj::NbcMove( rSiz );
+ if ( mXRenderedCustomShape.is() )
+ {
+ SdrObject* pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape );
+ if ( pRenderedCustomShape )
+ {
+ // #i97149# the visualisation shape needs to be informed
+ // about change, too
+ pRenderedCustomShape->ActionChanged();
+ pRenderedCustomShape->NbcMove( rSiz );
+ }
+ }
+
+ // #i37011# adapt geometry shadow
+ if(mpLastShadowGeometry)
+ {
+ mpLastShadowGeometry->NbcMove( rSiz );
+ }
+}
+void SdrObjCustomShape::Resize( const Point& rRef, const Fraction& xFact, const Fraction& yFact )
+{
+ SdrTextObj::Resize( rRef, xFact, yFact );
+}
+
+void SdrObjCustomShape::NbcResize( const Point& rRef, const Fraction& rxFact, const Fraction& ryFact )
+{
+ Fraction xFact( rxFact );
+ Fraction yFact( ryFact );
+
+ // taking care of handles that should not been changed
+ Rectangle aOld( aRect );
+ std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
+
+ SdrTextObj::NbcResize( rRef, xFact, yFact );
+
+ if ( ( xFact.GetNumerator() != xFact.GetDenominator() )
+ || ( yFact.GetNumerator()!= yFact.GetDenominator() ) )
+ {
+ if ( ( ( xFact.GetNumerator() < 0 ) && ( xFact.GetDenominator() > 0 ) ) ||
+ ( ( xFact.GetNumerator() > 0 ) && ( xFact.GetDenominator() < 0 ) ) )
+ {
+ SetMirroredX( IsMirroredX() == sal_False );
+ }
+ if ( ( ( yFact.GetNumerator() < 0 ) && ( yFact.GetDenominator() > 0 ) ) ||
+ ( ( yFact.GetNumerator() > 0 ) && ( yFact.GetDenominator() < 0 ) ) )
+ {
+ SetMirroredY( IsMirroredY() == sal_False );
+ }
+ }
+
+ std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
+ while ( aIter != aInteractionHandles.end() )
+ {
+ try
+ {
+ if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
+ aIter->xInteraction->setControllerPosition( aIter->aPosition );
+ if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X )
+ {
+ sal_Int32 nX = ( aIter->aPosition.X - aOld.Left() ) + aRect.Left();
+ aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( nX, aIter->xInteraction->getPosition().Y ) );
+ }
+ if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y )
+ {
+ sal_Int32 nY = ( aIter->aPosition.Y - aOld.Top() ) + aRect.Top();
+ aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( aIter->xInteraction->getPosition().X, nY ) );
+ }
+ }
+ catch ( const uno::RuntimeException& )
+ {
+ }
+ aIter++;
+ }
+ InvalidateRenderGeometry();
+}
+void SdrObjCustomShape::NbcRotate( const Point& rRef, long nWink, double sn, double cs )
+{
+ sal_Bool bMirroredX = IsMirroredX();
+ sal_Bool bMirroredY = IsMirroredY();
+
+ fObjectRotation = fmod( fObjectRotation, 360.0 );
+ if ( fObjectRotation < 0 )
+ fObjectRotation = 360 + fObjectRotation;
+
+ // the rotation angle for ashapes is stored in fObjectRotation, this rotation
+ // has to be applied to the text object (which is internally using aGeo.nWink).
+ SdrTextObj::NbcRotate( aRect.TopLeft(), -aGeo.nDrehWink, // retrieving the unrotated text object
+ sin( (-aGeo.nDrehWink) * F_PI18000 ),
+ cos( (-aGeo.nDrehWink) * F_PI18000 ) );
+ aGeo.nDrehWink = 0; // resetting aGeo data
+ aGeo.RecalcSinCos();
+
+ long nW = (long)( fObjectRotation * 100 ); // applying our object rotation
+ if ( bMirroredX )
+ nW = 36000 - nW;
+ if ( bMirroredY )
+ nW = 18000 - nW;
+ nW = nW % 36000;
+ if ( nW < 0 )
+ nW = 36000 + nW;
+ SdrTextObj::NbcRotate( aRect.TopLeft(), nW, // applying text rotation
+ sin( nW * F_PI18000 ),
+ cos( nW * F_PI18000 ) );
+
+ int nSwap = 0;
+ if ( bMirroredX )
+ nSwap ^= 1;
+ if ( bMirroredY )
+ nSwap ^= 1;
+
+ double fWink = nWink; // updating to our new object rotation
+ fWink /= 100.0;
+ fObjectRotation = fmod( nSwap ? fObjectRotation - fWink : fObjectRotation + fWink, 360.0 );
+ if ( fObjectRotation < 0 )
+ fObjectRotation = 360 + fObjectRotation;
+
+ SdrTextObj::NbcRotate( rRef, nWink, sn, cs ); // applying text rotation
+ InvalidateRenderGeometry();
+}
+
+void SdrObjCustomShape::NbcMirror( const Point& rRef1, const Point& rRef2 )
+{
+ // storing horizontal and vertical flipping without modifying the rotate angle
+
+ sal_Bool bHorz = sal_False;
+ sal_Bool bVert = sal_False;
+ if ( rRef1.X() == rRef2.X() )
+ bHorz = sal_True;
+ if ( rRef1.Y() == rRef2.Y() )
+ bVert = sal_True;
+ if ( !bHorz && !bVert )
+ bHorz = bVert = sal_True;
+
+ if ( bHorz || bVert )
+ {
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+
+ /////////////////
+ // "MirroredX" //
+ /////////////////
+ if ( bHorz )
+ {
+ const rtl::OUString sMirroredX( RTL_CONSTASCII_USTRINGPARAM ( "MirroredX" ) );
+ com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredX );
+ if ( pAny )
+ {
+ sal_Bool bFlip = sal_Bool();
+ if ( *pAny >>= bFlip )
+ {
+ if ( bFlip )
+ bHorz = sal_False;
+ }
+ }
+ PropertyValue aPropVal;
+ aPropVal.Name = sMirroredX;
+ aPropVal.Value <<= bHorz;
+ aGeometryItem.SetPropertyValue( aPropVal );
+ }
+
+ /////////////////
+ // "MirroredY" //
+ /////////////////
+ if ( bVert )
+ {
+ const rtl::OUString sMirroredY( RTL_CONSTASCII_USTRINGPARAM ( "MirroredY" ) );
+ com::sun::star::uno::Any* pAny = aGeometryItem.GetPropertyValueByName( sMirroredY );
+ if ( pAny )
+ {
+ sal_Bool bFlip = sal_Bool();
+ if ( *pAny >>= bFlip )
+ {
+ if ( bFlip )
+ bVert = sal_False;
+ }
+ }
+ PropertyValue aPropVal;
+ aPropVal.Name = sMirroredY;
+ aPropVal.Value <<= bVert;
+ aGeometryItem.SetPropertyValue( aPropVal );
+ }
+ SetMergedItem( aGeometryItem );
+ }
+ SdrTextObj::NbcMirror( rRef1, rRef2 );
+ InvalidateRenderGeometry();
+}
+
+void SdrObjCustomShape::Shear( const Point& rRef, long nWink, double tn, bool bVShear )
+{
+ SdrTextObj::Shear( rRef, nWink, tn, bVShear );
+ InvalidateRenderGeometry();
+}
+void SdrObjCustomShape::NbcShear( const Point& rRef, long nWink, double tn, bool bVShear )
+{
+ long nDrehWink = aGeo.nDrehWink;
+ if ( nDrehWink )
+ {
+ aGeo.nDrehWink = -nDrehWink;
+ aGeo.RecalcSinCos();
+ NbcRotate( rRef, aGeo.nDrehWink, aGeo.nSin, aGeo.nCos );
+ }
+ SdrTextObj::NbcShear(rRef,nWink,tn,bVShear);
+ if ( nDrehWink )
+ {
+ aGeo.nDrehWink = nDrehWink;
+ aGeo.RecalcSinCos();
+ Rotate( rRef, aGeo.nDrehWink, aGeo.nSin, aGeo.nCos );
+ }
+ InvalidateRenderGeometry();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrGluePoint SdrObjCustomShape::GetVertexGluePoint(USHORT nPosNum) const
+{
+ INT32 nWdt = ImpGetLineWdt(); // #i25616# ((XLineWidthItem&)(GetObjectItem(XATTR_LINEWIDTH))).GetValue();
+
+ // #i25616#
+ if(!LineIsOutsideGeometry())
+ {
+ nWdt++;
+ nWdt /= 2;
+ }
+
+ Point aPt;
+ switch (nPosNum) {
+ case 0: aPt=aRect.TopCenter(); aPt.Y()-=nWdt; break;
+ case 1: aPt=aRect.RightCenter(); aPt.X()+=nWdt; break;
+ case 2: aPt=aRect.BottomCenter(); aPt.Y()+=nWdt; break;
+ case 3: aPt=aRect.LeftCenter(); aPt.X()-=nWdt; break;
+ }
+ if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),aGeo.nTan);
+ if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ aPt-=GetSnapRect().Center();
+ SdrGluePoint aGP(aPt);
+ aGP.SetPercent(FALSE);
+ return aGP;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// #i38892#
+void SdrObjCustomShape::ImpCheckCustomGluePointsAreAdded()
+{
+ const SdrObject* pSdrObject = GetSdrObjectFromCustomShape();
+
+ if(pSdrObject)
+ {
+ const SdrGluePointList* pSource = pSdrObject->GetGluePointList();
+
+ if(pSource && pSource->GetCount())
+ {
+ if(!SdrTextObj::GetGluePointList())
+ {
+ SdrTextObj::ForceGluePointList();
+ }
+
+ const SdrGluePointList* pList = SdrTextObj::GetGluePointList();
+
+ if(pList)
+ {
+ SdrGluePointList aNewList;
+ sal_uInt16 a;
+
+ for(a = 0; a < pSource->GetCount(); a++)
+ {
+ SdrGluePoint aCopy((*pSource)[a]);
+ aCopy.SetUserDefined(FALSE);
+ aNewList.Insert(aCopy);
+ }
+
+ sal_Bool bMirroredX = IsMirroredX();
+ sal_Bool bMirroredY = IsMirroredY();
+
+ long nShearWink = aGeo.nShearWink;
+ double fTan = aGeo.nTan;
+
+ if ( aGeo.nDrehWink || nShearWink || bMirroredX || bMirroredY )
+ {
+ Polygon aPoly( aRect );
+ if( nShearWink )
+ {
+ USHORT nPointCount=aPoly.GetSize();
+ for (USHORT i=0; i<nPointCount; i++)
+ ShearPoint(aPoly[i],aRect.Center(), fTan, FALSE );
+ }
+ if ( aGeo.nDrehWink )
+ aPoly.Rotate( aRect.Center(), aGeo.nDrehWink / 10 );
+
+ Rectangle aBoundRect( aPoly.GetBoundRect() );
+ sal_Int32 nXDiff = aBoundRect.Left() - aRect.Left();
+ sal_Int32 nYDiff = aBoundRect.Top() - aRect.Top();
+
+ if (nShearWink&&((bMirroredX&&!bMirroredY)||(bMirroredY&&!bMirroredX)))
+ {
+ nShearWink = -nShearWink;
+ fTan = -fTan;
+ }
+
+ Point aRef( aRect.GetWidth() / 2, aRect.GetHeight() / 2 );
+ for ( a = 0; a < aNewList.GetCount(); a++ )
+ {
+ SdrGluePoint& rPoint = aNewList[ a ];
+ Point aGlue( rPoint.GetPos() );
+ if ( nShearWink )
+ ShearPoint( aGlue, aRef, fTan );
+
+ RotatePoint( aGlue, aRef, sin( fObjectRotation * F_PI180 ), cos( fObjectRotation * F_PI180 ) );
+ if ( bMirroredX )
+ aGlue.X() = aRect.GetWidth() - aGlue.X();
+ if ( bMirroredY )
+ aGlue.Y() = aRect.GetHeight() - aGlue.Y();
+ aGlue.X() -= nXDiff;
+ aGlue.Y() -= nYDiff;
+ rPoint.SetPos( aGlue );
+ }
+ }
+
+ for(a = 0; a < pList->GetCount(); a++)
+ {
+ const SdrGluePoint& rCandidate = (*pList)[a];
+
+ if(rCandidate.IsUserDefined())
+ {
+ aNewList.Insert(rCandidate);
+ }
+ }
+
+ // copy new list to local. This is NOT very convenient behaviour, the local
+ // GluePointList should not be set, but be delivered by using GetGluePointList(),
+ // maybe on demand. Since the local object is changed here, this is assumed to
+ // be a result of GetGluePointList and thus the list is copied
+ if(pPlusData)
+ {
+ *pPlusData->pGluePoints = aNewList;
+ }
+ }
+ }
+ }
+}
+
+// #i38892#
+const SdrGluePointList* SdrObjCustomShape::GetGluePointList() const
+{
+ ((SdrObjCustomShape*)this)->ImpCheckCustomGluePointsAreAdded();
+ return SdrTextObj::GetGluePointList();
+}
+
+// #i38892#
+//SdrGluePointList* SdrObjCustomShape::GetGluePointList()
+//{
+// ImpCheckCustomGluePointsAreAdded();
+// return SdrTextObj::GetGluePointList();
+//}
+
+// #i38892#
+SdrGluePointList* SdrObjCustomShape::ForceGluePointList()
+{
+ if(SdrTextObj::ForceGluePointList())
+ {
+ ImpCheckCustomGluePointsAreAdded();
+ return SdrTextObj::ForceGluePointList();
+ }
+ else
+ {
+ return 0L;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_uInt32 SdrObjCustomShape::GetHdlCount() const
+{
+ const sal_uInt32 nBasicHdlCount(SdrTextObj::GetHdlCount());
+ std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
+ return ( aInteractionHandles.size() + nBasicHdlCount );
+}
+
+SdrHdl* SdrObjCustomShape::GetHdl( sal_uInt32 nHdlNum ) const
+{
+ SdrHdl* pH = NULL;
+ const sal_uInt32 nBasicHdlCount(SdrTextObj::GetHdlCount());
+
+ if ( nHdlNum < nBasicHdlCount )
+ pH = SdrTextObj::GetHdl( nHdlNum );
+ else
+ {
+ std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
+ const sal_uInt32 nCustomShapeHdlNum(nHdlNum - nBasicHdlCount);
+
+ if ( nCustomShapeHdlNum < aInteractionHandles.size() )
+ {
+ if ( aInteractionHandles[ nCustomShapeHdlNum ].xInteraction.is() )
+ {
+ try
+ {
+ com::sun::star::awt::Point aPosition( aInteractionHandles[ nCustomShapeHdlNum ].xInteraction->getPosition() );
+ pH = new SdrHdl( Point( aPosition.X, aPosition.Y ), HDL_CUSTOMSHAPE1 );
+ pH->SetPointNum( nCustomShapeHdlNum );
+ pH->SetObj( (SdrObject*)this );
+ }
+ catch ( const uno::RuntimeException& )
+ {
+ }
+ }
+ }
+ }
+ return pH;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrObjCustomShape::hasSpecialDrag() const
+{
+ return true;
+}
+
+bool SdrObjCustomShape::beginSpecialDrag(SdrDragStat& rDrag) const
+{
+ const SdrHdl* pHdl = rDrag.GetHdl();
+
+ if(pHdl && HDL_CUSTOMSHAPE1 == pHdl->GetKind())
+ {
+ rDrag.SetEndDragChangesAttributes(true);
+ rDrag.SetNoSnap(true);
+ }
+ else
+ {
+ const SdrHdl* pHdl2 = rDrag.GetHdl();
+ const SdrHdlKind eHdl((pHdl2 == NULL) ? HDL_MOVE : pHdl2->GetKind());
+
+ switch( eHdl )
+ {
+ case HDL_UPLFT :
+ case HDL_UPPER :
+ case HDL_UPRGT :
+ case HDL_LEFT :
+ case HDL_RIGHT :
+ case HDL_LWLFT :
+ case HDL_LOWER :
+ case HDL_LWRGT :
+ case HDL_MOVE :
+ {
+ break;
+ }
+ default:
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+void SdrObjCustomShape::DragResizeCustomShape( const Rectangle& rNewRect, SdrObjCustomShape* pObj ) const
+{
+ Rectangle aOld( pObj->aRect );
+ sal_Bool bOldMirroredX( pObj->IsMirroredX() );
+ sal_Bool bOldMirroredY( pObj->IsMirroredY() );
+
+ Rectangle aNewRect( rNewRect );
+ aNewRect.Justify();
+
+ std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( pObj ) );
+
+ GeoStat aGeoStat( pObj->GetGeoStat() );
+ if ( aNewRect.TopLeft()!= pObj->aRect.TopLeft() &&
+ ( pObj->aGeo.nDrehWink || pObj->aGeo.nShearWink ) )
+ {
+ Point aNewPos( aNewRect.TopLeft() );
+ if ( pObj->aGeo.nShearWink ) ShearPoint( aNewPos, aOld.TopLeft(), aGeoStat.nTan );
+ if ( pObj->aGeo.nDrehWink ) RotatePoint(aNewPos, aOld.TopLeft(), aGeoStat.nSin, aGeoStat.nCos );
+ aNewRect.SetPos( aNewPos );
+ }
+ if ( aNewRect != pObj->aRect )
+ {
+ pObj->SetLogicRect( aNewRect );
+ pObj->InvalidateRenderGeometry();
+
+ if ( rNewRect.Left() > rNewRect.Right() )
+ {
+ Point aTop( ( pObj->GetSnapRect().Left() + pObj->GetSnapRect().Right() ) >> 1, pObj->GetSnapRect().Top() );
+ Point aBottom( aTop.X(), aTop.Y() + 1000 );
+ pObj->NbcMirror( aTop, aBottom );
+ }
+ if ( rNewRect.Top() > rNewRect.Bottom() )
+ {
+ Point aLeft( pObj->GetSnapRect().Left(), ( pObj->GetSnapRect().Top() + pObj->GetSnapRect().Bottom() ) >> 1 );
+ Point aRight( aLeft.X() + 1000, aLeft.Y() );
+ pObj->NbcMirror( aLeft, aRight );
+ }
+
+ std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
+ while ( aIter != aInteractionHandles.end() )
+ {
+ try
+ {
+ if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
+ aIter->xInteraction->setControllerPosition( aIter->aPosition );
+ if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_X )
+ {
+ sal_Int32 nX;
+ if ( bOldMirroredX )
+ {
+ nX = ( aIter->aPosition.X - aOld.Right() );
+ if ( rNewRect.Left() > rNewRect.Right() )
+ nX = pObj->aRect.Left() - nX;
+ else
+ nX += pObj->aRect.Right();
+ }
+ else
+ {
+ nX = ( aIter->aPosition.X - aOld.Left() );
+ if ( rNewRect.Left() > rNewRect.Right() )
+ nX = pObj->aRect.Right() - nX;
+ else
+ nX += pObj->aRect.Left();
+ }
+ aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( nX, aIter->xInteraction->getPosition().Y ) );
+ }
+ if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_ABSOLUTE_Y )
+ {
+ sal_Int32 nY;
+ if ( bOldMirroredY )
+ {
+ nY = ( aIter->aPosition.Y - aOld.Bottom() );
+ if ( rNewRect.Top() > rNewRect.Bottom() )
+ nY = pObj->aRect.Top() - nY;
+ else
+ nY += pObj->aRect.Bottom();
+ }
+ else
+ {
+ nY = ( aIter->aPosition.Y - aOld.Top() );
+ if ( rNewRect.Top() > rNewRect.Bottom() )
+ nY = pObj->aRect.Bottom() - nY;
+ else
+ nY += pObj->aRect.Top();
+ }
+ aIter->xInteraction->setControllerPosition( com::sun::star::awt::Point( aIter->xInteraction->getPosition().X, nY ) );
+ }
+ }
+ catch ( const uno::RuntimeException& )
+ {
+ }
+ aIter++;
+ }
+ }
+}
+
+void SdrObjCustomShape::DragMoveCustomShapeHdl( const Point aDestination, const sal_uInt16 nCustomShapeHdlNum, SdrObjCustomShape* pObj ) const
+{
+ std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( pObj ) );
+ if ( nCustomShapeHdlNum < aInteractionHandles.size() )
+ {
+ SdrCustomShapeInteraction aInteractionHandle( aInteractionHandles[ nCustomShapeHdlNum ] );
+ if ( aInteractionHandle.xInteraction.is() )
+ {
+ try
+ {
+ com::sun::star::awt::Point aPt( aDestination.X(), aDestination.Y() );
+ if ( aInteractionHandle.nMode & CUSTOMSHAPE_HANDLE_MOVE_SHAPE )
+ {
+ sal_Int32 nXDiff = aPt.X - aInteractionHandle.aPosition.X;
+ sal_Int32 nYDiff = aPt.Y - aInteractionHandle.aPosition.Y;
+
+ pObj->aRect.Move( nXDiff, nYDiff );
+ pObj->aOutRect.Move( nXDiff, nYDiff );
+ pObj->maSnapRect.Move( nXDiff, nYDiff );
+ pObj->SetRectsDirty(sal_True);
+ pObj->InvalidateRenderGeometry();
+
+ std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
+ while ( aIter != aInteractionHandles.end() )
+ {
+ if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
+ {
+ if ( aIter->xInteraction.is() )
+ aIter->xInteraction->setControllerPosition( aIter->aPosition );
+ }
+ aIter++;
+ }
+ }
+ aInteractionHandle.xInteraction->setControllerPosition( aPt );
+ }
+ catch ( const uno::RuntimeException& )
+ {
+ }
+ }
+ }
+}
+
+bool SdrObjCustomShape::applySpecialDrag(SdrDragStat& rDrag)
+{
+ const SdrHdl* pHdl = rDrag.GetHdl();
+ const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind());
+
+ switch(eHdl)
+ {
+ case HDL_CUSTOMSHAPE1 :
+ {
+ rDrag.SetEndDragChangesGeoAndAttributes(true);
+ DragMoveCustomShapeHdl( rDrag.GetNow(), (sal_uInt16)pHdl->GetPointNum(), this );
+ SetRectsDirty();
+ InvalidateRenderGeometry();
+ SetChanged();
+ break;
+ }
+
+ case HDL_UPLFT :
+ case HDL_UPPER :
+ case HDL_UPRGT :
+ case HDL_LEFT :
+ case HDL_RIGHT :
+ case HDL_LWLFT :
+ case HDL_LOWER :
+ case HDL_LWRGT :
+ {
+ DragResizeCustomShape(ImpDragCalcRect(rDrag), this);
+ break;
+ }
+ case HDL_MOVE :
+ {
+ Move(Size(rDrag.GetDX(), rDrag.GetDY()));
+ break;
+ }
+ default: break;
+ }
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrObjCustomShape::DragCreateObject( SdrDragStat& rStat )
+{
+ Rectangle aRect1;
+ rStat.TakeCreateRect( aRect1 );
+
+ std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
+
+ sal_uInt32 nDefaultObjectSizeWidth = 3000; // default width from SDOptions ?
+ sal_uInt32 nDefaultObjectSizeHeight= 3000;
+
+ if ( ImpVerticalSwitch( *this ) )
+ {
+ SetMirroredX( aRect1.Left() > aRect1.Right() );
+
+ aRect1 = Rectangle( rStat.GetNow(), Size( nDefaultObjectSizeWidth, nDefaultObjectSizeHeight ) );
+ // subtracting the horizontal difference of the latest handle from shape position
+ if ( aInteractionHandles.size() )
+ {
+ sal_Int32 nHandlePos = aInteractionHandles[ aInteractionHandles.size() - 1 ].xInteraction->getPosition().X;
+ aRect1.Move( aRect.Left() - nHandlePos, 0 );
+ }
+ }
+ ImpJustifyRect( aRect1 );
+ rStat.SetActionRect( aRect1 );
+ aRect = aRect1;
+ SetRectsDirty();
+
+ std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
+ while ( aIter != aInteractionHandles.end() )
+ {
+ try
+ {
+ if ( aIter->nMode & CUSTOMSHAPE_HANDLE_CREATE_FIXED )
+ aIter->xInteraction->setControllerPosition( awt::Point( rStat.GetStart().X(), rStat.GetStart().Y() ) );
+ }
+ catch ( const uno::RuntimeException& )
+ {
+ }
+ aIter++;
+ }
+
+ SetBoundRectDirty();
+ bSnapRectDirty=TRUE;
+}
+
+bool SdrObjCustomShape::BegCreate( SdrDragStat& rDrag )
+{
+ return SdrTextObj::BegCreate( rDrag );
+}
+
+bool SdrObjCustomShape::MovCreate(SdrDragStat& rStat)
+{
+ SdrView* pView = rStat.GetView(); // #i37448#
+ if( pView && pView->IsSolidDragging() )
+ {
+ InvalidateRenderGeometry();
+ }
+ DragCreateObject( rStat );
+ SetRectsDirty();
+ return TRUE;
+}
+
+bool SdrObjCustomShape::EndCreate( SdrDragStat& rStat, SdrCreateCmd eCmd )
+{
+ DragCreateObject( rStat );
+
+ if ( bTextFrame )
+ {
+ if ( IsAutoGrowHeight() )
+ {
+ // MinTextHeight
+ long nHgt=aRect.GetHeight()-1;
+ if (nHgt==1) nHgt=0;
+ NbcSetMinTextFrameHeight( nHgt );
+ }
+ if ( IsAutoGrowWidth() )
+ {
+ // MinTextWidth
+ long nWdt=aRect.GetWidth()-1;
+ if (nWdt==1) nWdt=0;
+ NbcSetMinTextFrameWidth( nWdt );
+ }
+ // Textrahmen neu berechnen
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ SetRectsDirty();
+ return ( eCmd == SDRCREATE_FORCEEND || rStat.GetPointAnz() >= 2 );
+}
+
+basegfx::B2DPolyPolygon SdrObjCustomShape::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
+{
+ return GetLineGeometry( this, sal_False );
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// in context with the SdrObjCustomShape the SdrTextAutoGrowHeightItem == true -> Resize Shape to fit text,
+// the SdrTextAutoGrowWidthItem == true -> Word wrap text in Shape
+bool SdrObjCustomShape::IsAutoGrowHeight() const
+{
+ const SfxItemSet& rSet = GetMergedItemSet();
+ bool bIsAutoGrowHeight = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
+ if ( bIsAutoGrowHeight && IsVerticalWriting() )
+ bIsAutoGrowHeight = ((SdrTextWordWrapItem&)(rSet.Get(SDRATTR_TEXT_WORDWRAP))).GetValue() == FALSE;
+ return bIsAutoGrowHeight;
+}
+bool SdrObjCustomShape::IsAutoGrowWidth() const
+{
+ const SfxItemSet& rSet = GetMergedItemSet();
+ bool bIsAutoGrowWidth = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
+ if ( bIsAutoGrowWidth && !IsVerticalWriting() )
+ bIsAutoGrowWidth = ((SdrTextWordWrapItem&)(rSet.Get(SDRATTR_TEXT_WORDWRAP))).GetValue() == FALSE;
+ return bIsAutoGrowWidth;
+}
+
+/* The following method is identical to the SdrTextObj::SetVerticalWriting method, the only difference
+ is that the SdrAutoGrowWidthItem and SdrAutoGrowHeightItem are not exchanged if the vertical writing
+ mode has been changed */
+
+void SdrObjCustomShape::SetVerticalWriting( sal_Bool bVertical )
+{
+ ForceOutlinerParaObject();
+
+ OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+
+ DBG_ASSERT( pOutlinerParaObject, "SdrTextObj::SetVerticalWriting() without OutlinerParaObject!" );
+
+ if( pOutlinerParaObject )
+ {
+ if(pOutlinerParaObject->IsVertical() != (bool)bVertical)
+ {
+ // get item settings
+ const SfxItemSet& rSet = GetObjectItemSet();
+
+ // #103516# Also exchange hor/ver adjust items
+ SdrTextHorzAdjust eHorz = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
+ SdrTextVertAdjust eVert = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
+
+ // rescue object size
+ Rectangle aObjectRect = GetSnapRect();
+
+ // prepare ItemSet to set exchanged width and height items
+ SfxItemSet aNewSet(*rSet.GetPool(),
+ SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT,
+ // #103516# Expanded item ranges to also support hor and ver adjust.
+ SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST,
+ SDRATTR_TEXT_AUTOGROWWIDTH, SDRATTR_TEXT_HORZADJUST,
+ 0, 0);
+
+ aNewSet.Put(rSet);
+
+ // #103516# Exchange horz and vert adjusts
+ switch(eVert)
+ {
+ case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break;
+ case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break;
+ case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break;
+ case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break;
+ }
+ switch(eHorz)
+ {
+ case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break;
+ case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break;
+ case SDRTEXTHORZADJUST_RIGHT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); break;
+ case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break;
+ }
+
+ SetObjectItemSet( aNewSet );
+ pOutlinerParaObject = GetOutlinerParaObject();
+ if ( pOutlinerParaObject )
+ pOutlinerParaObject->SetVertical(bVertical);
+
+ // restore object size
+ SetSnapRect(aObjectRect);
+ }
+ }
+}
+bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt, bool bWdt) const
+{
+ if ( pModel && HasText() && !rR.IsEmpty() )
+ {
+ bool bWdtGrow=bWdt && IsAutoGrowWidth();
+ bool bHgtGrow=bHgt && IsAutoGrowHeight();
+ if ( bWdtGrow || bHgtGrow )
+ {
+ Rectangle aR0(rR);
+ long nHgt=0,nMinHgt=0,nMaxHgt=0;
+ long nWdt=0,nMinWdt=0,nMaxWdt=0;
+ Size aSiz(rR.GetSize()); aSiz.Width()--; aSiz.Height()--;
+ Size aMaxSiz(100000,100000);
+ Size aTmpSiz(pModel->GetMaxObjSize());
+ if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width();
+ if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height();
+ if (bWdtGrow)
+ {
+ nMinWdt=GetMinTextFrameWidth();
+ nMaxWdt=GetMaxTextFrameWidth();
+ if (nMaxWdt==0 || nMaxWdt>aMaxSiz.Width()) nMaxWdt=aMaxSiz.Width();
+ if (nMinWdt<=0) nMinWdt=1;
+ aSiz.Width()=nMaxWdt;
+ }
+ if (bHgtGrow)
+ {
+ nMinHgt=GetMinTextFrameHeight();
+ nMaxHgt=GetMaxTextFrameHeight();
+ if (nMaxHgt==0 || nMaxHgt>aMaxSiz.Height()) nMaxHgt=aMaxSiz.Height();
+ if (nMinHgt<=0) nMinHgt=1;
+ aSiz.Height()=nMaxHgt;
+ }
+ long nHDist=GetTextLeftDistance()+GetTextRightDistance();
+ long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
+ aSiz.Width()-=nHDist;
+ aSiz.Height()-=nVDist;
+ if ( aSiz.Width() < 2 )
+ aSiz.Width() = 2; // Mindestgroesse 2
+ if ( aSiz.Height() < 2 )
+ aSiz.Height() = 2; // Mindestgroesse 2
+
+ if(pEdtOutl)
+ {
+ pEdtOutl->SetMaxAutoPaperSize( aSiz );
+ if (bWdtGrow)
+ {
+ Size aSiz2(pEdtOutl->CalcTextSize());
+ nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz
+ if (bHgtGrow) nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz
+ } else
+ {
+ nHgt=pEdtOutl->GetTextHeight()+1; // lieber etwas Tolleranz
+ }
+ }
+ else
+ {
+ Outliner& rOutliner=ImpGetDrawOutliner();
+ rOutliner.SetPaperSize(aSiz);
+ rOutliner.SetUpdateMode(TRUE);
+ // !!! hier sollte ich wohl auch noch mal die Optimierung mit
+ // bPortionInfoChecked usw einbauen
+ OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+ if( pOutlinerParaObject != NULL )
+ {
+ rOutliner.SetText(*pOutlinerParaObject);
+ rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
+ }
+ if ( bWdtGrow )
+ {
+ Size aSiz2(rOutliner.CalcTextSize());
+ nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz
+ if ( bHgtGrow )
+ nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz
+ }
+ else
+ nHgt = rOutliner.GetTextHeight()+1; // lieber etwas Tolleranz
+ rOutliner.Clear();
+ }
+ if ( nWdt < nMinWdt )
+ nWdt = nMinWdt;
+ if ( nWdt > nMaxWdt )
+ nWdt = nMaxWdt;
+ nWdt += nHDist;
+ if ( nWdt < 1 )
+ nWdt = 1; // nHDist kann auch negativ sein
+ if ( nHgt < nMinHgt )
+ nHgt = nMinHgt;
+ if ( nHgt > nMaxHgt )
+ nHgt = nMaxHgt;
+ nHgt+=nVDist;
+ if ( nHgt < 1 )
+ nHgt = 1; // nVDist kann auch negativ sein
+ long nWdtGrow = nWdt-(rR.Right()-rR.Left());
+ long nHgtGrow = nHgt-(rR.Bottom()-rR.Top());
+ if ( nWdtGrow == 0 )
+ bWdtGrow = FALSE;
+ if ( nHgtGrow == 0 )
+ bHgtGrow=FALSE;
+ if ( bWdtGrow || bHgtGrow )
+ {
+ if ( bWdtGrow )
+ {
+ SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust();
+ if ( eHAdj == SDRTEXTHORZADJUST_LEFT )
+ rR.Right()+=nWdtGrow;
+ else if ( eHAdj == SDRTEXTHORZADJUST_RIGHT )
+ rR.Left()-=nWdtGrow;
+ else
+ {
+ long nWdtGrow2=nWdtGrow/2;
+ rR.Left()-=nWdtGrow2;
+ rR.Right()=rR.Left()+nWdt;
+ }
+ }
+ if ( bHgtGrow )
+ {
+ SdrTextVertAdjust eVAdj=GetTextVerticalAdjust();
+ if ( eVAdj == SDRTEXTVERTADJUST_TOP )
+ rR.Bottom()+=nHgtGrow;
+ else if ( eVAdj == SDRTEXTVERTADJUST_BOTTOM )
+ rR.Top()-=nHgtGrow;
+ else
+ {
+ long nHgtGrow2=nHgtGrow/2;
+ rR.Top()-=nHgtGrow2;
+ rR.Bottom()=rR.Top()+nHgt;
+ }
+ }
+ if ( aGeo.nDrehWink )
+ {
+ Point aD1(rR.TopLeft());
+ aD1-=aR0.TopLeft();
+ Point aD2(aD1);
+ RotatePoint(aD2,Point(),aGeo.nSin,aGeo.nCos);
+ aD2-=aD1;
+ rR.Move(aD2.X(),aD2.Y());
+ }
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+Rectangle SdrObjCustomShape::ImpCalculateTextFrame( const bool bHgt, const bool bWdt )
+{
+ Rectangle aReturnValue;
+
+ Rectangle aOldTextRect( aRect ); // <- initial text rectangle
+
+ Rectangle aNewTextRect( aRect ); // <- new text rectangle returned from the custom shape renderer,
+ GetTextBounds( aNewTextRect ); // it depends to the current logical shape size
+
+ Rectangle aAdjustedTextRect( aNewTextRect ); // <- new text rectangle is being tested by AdjustTextFrameWidthAndHeight to ensure
+ if ( AdjustTextFrameWidthAndHeight( aAdjustedTextRect, bHgt, bWdt ) ) // that the new text rectangle is matching the current text size from the outliner
+ {
+ if ( ( aAdjustedTextRect != aNewTextRect ) && ( aOldTextRect != aAdjustedTextRect ) )
+ {
+ aReturnValue = aRect;
+ double fXScale = (double)aOldTextRect.GetWidth() / (double)aNewTextRect.GetWidth();
+ double fYScale = (double)aOldTextRect.GetHeight() / (double)aNewTextRect.GetHeight();
+ double fRightDiff = (double)( aAdjustedTextRect.Right() - aNewTextRect.Right() ) * fXScale;
+ double fLeftDiff = (double)( aAdjustedTextRect.Left() - aNewTextRect.Left() ) * fXScale;
+ double fTopDiff = (double)( aAdjustedTextRect.Top() - aNewTextRect.Top() ) * fYScale;
+ double fBottomDiff= (double)( aAdjustedTextRect.Bottom()- aNewTextRect.Bottom()) * fYScale;
+ aReturnValue.Left() += (sal_Int32)fLeftDiff;
+ aReturnValue.Right() += (sal_Int32)fRightDiff;
+ aReturnValue.Top() += (sal_Int32)fTopDiff;
+ aReturnValue.Bottom() += (sal_Int32)fBottomDiff;
+ }
+ }
+ return aReturnValue;
+}
+
+bool SdrObjCustomShape::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt)
+{
+ Rectangle aNewTextRect = ImpCalculateTextFrame( bHgt, bWdt );
+ sal_Bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != aRect );
+ if ( bRet )
+ {
+ // taking care of handles that should not been changed
+ std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
+
+ aRect = aNewTextRect;
+ SetRectsDirty();
+ SetChanged();
+
+ std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
+ while ( aIter != aInteractionHandles.end() )
+ {
+ try
+ {
+ if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
+ aIter->xInteraction->setControllerPosition( aIter->aPosition );
+ }
+ catch ( const uno::RuntimeException& )
+ {
+ }
+ aIter++;
+ }
+ InvalidateRenderGeometry();
+ }
+ return bRet;
+}
+bool SdrObjCustomShape::AdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt)
+{
+ Rectangle aNewTextRect = ImpCalculateTextFrame( bHgt, bWdt );
+ sal_Bool bRet = !aNewTextRect.IsEmpty() && ( aNewTextRect != aRect );
+ if ( bRet )
+ {
+ Rectangle aBoundRect0;
+ if ( pUserCall )
+ aBoundRect0 = GetCurrentBoundRect();
+
+ // taking care of handles that should not been changed
+ std::vector< SdrCustomShapeInteraction > aInteractionHandles( GetInteractionHandles( this ) );
+
+// SendRepaintBroadcast();
+ aRect = aNewTextRect;
+ SetRectsDirty();
+
+ std::vector< SdrCustomShapeInteraction >::iterator aIter( aInteractionHandles.begin() );
+ while ( aIter != aInteractionHandles.end() )
+ {
+ try
+ {
+ if ( aIter->nMode & CUSTOMSHAPE_HANDLE_RESIZE_FIXED )
+ aIter->xInteraction->setControllerPosition( aIter->aPosition );
+ }
+ catch ( const uno::RuntimeException& )
+ {
+ }
+ aIter++;
+ }
+
+ InvalidateRenderGeometry();
+ SetChanged();
+// SendRepaintBroadcast();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+ return bRet;
+}
+sal_Bool SdrObjCustomShape::BegTextEdit( SdrOutliner& rOutl )
+{
+ return SdrTextObj::BegTextEdit( rOutl );
+}
+void SdrObjCustomShape::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const
+{
+ Size aPaperMin,aPaperMax;
+ Rectangle aViewInit;
+ TakeTextAnchorRect( aViewInit );
+ if ( aGeo.nDrehWink )
+ {
+ Point aCenter(aViewInit.Center());
+ aCenter-=aViewInit.TopLeft();
+ Point aCenter0(aCenter);
+ RotatePoint(aCenter,Point(),aGeo.nSin,aGeo.nCos);
+ aCenter-=aCenter0;
+ aViewInit.Move(aCenter.X(),aCenter.Y());
+ }
+ Size aAnkSiz(aViewInit.GetSize());
+ aAnkSiz.Width()--; aAnkSiz.Height()--; // weil GetSize() ein draufaddiert
+ Size aMaxSiz(1000000,1000000);
+ if (pModel!=NULL) {
+ Size aTmpSiz(pModel->GetMaxObjSize());
+ if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width();
+ if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height();
+ }
+ SdrTextHorzAdjust eHAdj(GetTextHorizontalAdjust());
+ SdrTextVertAdjust eVAdj(GetTextVerticalAdjust());
+
+ long nMinWdt = GetMinTextFrameWidth();
+ long nMinHgt = GetMinTextFrameHeight();
+ long nMaxWdt = GetMaxTextFrameWidth();
+ long nMaxHgt = GetMaxTextFrameHeight();
+ if (nMinWdt<1) nMinWdt=1;
+ if (nMinHgt<1) nMinHgt=1;
+ if ( nMaxWdt == 0 || nMaxWdt > aMaxSiz.Width() )
+ nMaxWdt = aMaxSiz.Width();
+ if ( nMaxHgt == 0 || nMaxHgt > aMaxSiz.Height() )
+ nMaxHgt=aMaxSiz.Height();
+
+ if (((SdrTextWordWrapItem&)(GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue())
+ {
+ if ( IsVerticalWriting() )
+ {
+ nMaxHgt = aAnkSiz.Height();
+ nMinHgt = nMaxHgt;
+ }
+ else
+ {
+ nMaxWdt = aAnkSiz.Width();
+ nMinWdt = nMaxWdt;
+ }
+ }
+ aPaperMax.Width()=nMaxWdt;
+ aPaperMax.Height()=nMaxHgt;
+
+ aPaperMin.Width()=nMinWdt;
+ aPaperMin.Height()=nMinHgt;
+
+ if ( pViewMin )
+ {
+ *pViewMin = aViewInit;
+
+ long nXFree = aAnkSiz.Width() - aPaperMin.Width();
+ if ( eHAdj == SDRTEXTHORZADJUST_LEFT )
+ pViewMin->Right() -= nXFree;
+ else if ( eHAdj == SDRTEXTHORZADJUST_RIGHT )
+ pViewMin->Left() += nXFree;
+ else { pViewMin->Left() += nXFree / 2; pViewMin->Right() = pViewMin->Left() + aPaperMin.Width(); }
+
+ long nYFree = aAnkSiz.Height() - aPaperMin.Height();
+ if ( eVAdj == SDRTEXTVERTADJUST_TOP )
+ pViewMin->Bottom() -= nYFree;
+ else if ( eVAdj == SDRTEXTVERTADJUST_BOTTOM )
+ pViewMin->Top() += nYFree;
+ else { pViewMin->Top() += nYFree / 2; pViewMin->Bottom() = pViewMin->Top() + aPaperMin.Height(); }
+ }
+
+ if( IsVerticalWriting() )
+ aPaperMin.Width() = 0;
+ else
+ aPaperMin.Height() = 0; // #33102#
+
+ if( eHAdj != SDRTEXTHORZADJUST_BLOCK )
+ aPaperMin.Width()=0;
+
+ // #103516# For complete ver adjust support, set paper min height to 0, here.
+ if(SDRTEXTVERTADJUST_BLOCK != eVAdj )
+ aPaperMin.Height() = 0;
+
+ if (pPaperMin!=NULL) *pPaperMin=aPaperMin;
+ if (pPaperMax!=NULL) *pPaperMax=aPaperMax;
+ if (pViewInit!=NULL) *pViewInit=aViewInit;
+}
+void SdrObjCustomShape::EndTextEdit( SdrOutliner& rOutl )
+{
+ SdrTextObj::EndTextEdit( rOutl );
+ InvalidateRenderGeometry();
+}
+void SdrObjCustomShape::TakeTextAnchorRect( Rectangle& rAnchorRect ) const
+{
+ if ( GetTextBounds( rAnchorRect ) )
+ {
+ Point aRotateRef( maSnapRect.Center() );
+ rAnchorRect.Left() += GetTextLeftDistance();
+ rAnchorRect.Top() += GetTextUpperDistance();
+ rAnchorRect.Right() -= GetTextRightDistance();
+ rAnchorRect.Bottom() -= GetTextLowerDistance();
+ ImpJustifyRect( rAnchorRect );
+
+ if ( rAnchorRect.GetWidth() < 2 )
+ rAnchorRect.Right() = rAnchorRect.Left() + 1; // minimal width is 2
+ if ( rAnchorRect.GetHeight() < 2 )
+ rAnchorRect.Bottom() = rAnchorRect.Top() + 1; // minimal height is 2
+ if ( aGeo.nDrehWink )
+ {
+ Point aP( rAnchorRect.TopLeft() );
+ RotatePoint( aP, aRotateRef, aGeo.nSin, aGeo. nCos );
+ rAnchorRect.SetPos( aP );
+ }
+ }
+ else
+ SdrTextObj::TakeTextAnchorRect( rAnchorRect );
+}
+void SdrObjCustomShape::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText,
+ Rectangle* pAnchorRect, BOOL /*bLineWidth*/) const
+{
+ Rectangle aAnkRect; // Rect innerhalb dem geankert wird
+ TakeTextAnchorRect(aAnkRect);
+ SdrTextVertAdjust eVAdj=GetTextVerticalAdjust();
+ SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust();
+ ULONG nStat0=rOutliner.GetControlWord();
+ Size aNullSize;
+
+ rOutliner.SetControlWord(nStat0|EE_CNTRL_AUTOPAGESIZE);
+ rOutliner.SetMinAutoPaperSize(aNullSize);
+ sal_Int32 nMaxAutoPaperWidth = 1000000;
+ sal_Int32 nMaxAutoPaperHeight= 1000000;
+
+ long nAnkWdt=aAnkRect.GetWidth();
+ long nAnkHgt=aAnkRect.GetHeight();
+
+ if (((SdrTextWordWrapItem&)(GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue())
+ {
+ if ( IsVerticalWriting() )
+ nMaxAutoPaperHeight = nAnkHgt;
+ else
+ nMaxAutoPaperWidth = nAnkWdt;
+ }
+ if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
+ {
+ rOutliner.SetMinAutoPaperSize(Size(nAnkWdt, 0));
+ }
+
+ if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting())
+ {
+ rOutliner.SetMinAutoPaperSize(Size(0, nAnkHgt));
+ }
+ rOutliner.SetMaxAutoPaperSize( Size( nMaxAutoPaperWidth, nMaxAutoPaperHeight ) );
+ rOutliner.SetPaperSize( aNullSize );
+
+ // Text in den Outliner stecken - ggf. den aus dem EditOutliner
+ OutlinerParaObject* pPara= GetOutlinerParaObject();
+ if (pEdtOutl && !bNoEditText)
+ pPara=pEdtOutl->CreateParaObject();
+
+ if (pPara)
+ {
+ BOOL bHitTest = FALSE;
+ if( pModel )
+ bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
+
+ const SdrTextObj* pTestObj = rOutliner.GetTextObj();
+ if( !pTestObj || !bHitTest || pTestObj != this ||
+ pTestObj->GetOutlinerParaObject() != GetOutlinerParaObject() )
+ {
+ if( bHitTest )
+ rOutliner.SetTextObj( this );
+
+ rOutliner.SetUpdateMode(TRUE);
+ rOutliner.SetText(*pPara);
+ }
+ }
+ else
+ {
+ rOutliner.SetTextObj( NULL );
+ }
+ if (pEdtOutl && !bNoEditText && pPara)
+ delete pPara;
+
+ rOutliner.SetUpdateMode(TRUE);
+ rOutliner.SetControlWord(nStat0);
+
+ SdrText* pText = getActiveText();
+ if( pText )
+ pText->CheckPortionInfo( rOutliner );
+
+ Point aTextPos(aAnkRect.TopLeft());
+ Size aTextSiz(rOutliner.GetPaperSize()); // GetPaperSize() hat etwas Toleranz drauf, oder?
+
+ // #106653#
+ // For draw objects containing text correct hor/ver alignment if text is bigger
+ // than the object itself. Without that correction, the text would always be
+ // formatted to the left edge (or top edge when vertical) of the draw object.
+
+ if( !IsTextFrame() )
+ {
+ if(aAnkRect.GetWidth() < aTextSiz.Width() && !IsVerticalWriting())
+ {
+ // #110129#
+ // Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK,
+ // else the alignment is wanted.
+ if(SDRTEXTHORZADJUST_BLOCK == eHAdj)
+ {
+ eHAdj = SDRTEXTHORZADJUST_CENTER;
+ }
+ }
+
+ if(aAnkRect.GetHeight() < aTextSiz.Height() && IsVerticalWriting())
+ {
+ // #110129#
+ // Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK,
+ // else the alignment is wanted.
+ if(SDRTEXTVERTADJUST_BLOCK == eVAdj)
+ {
+ eVAdj = SDRTEXTVERTADJUST_CENTER;
+ }
+ }
+ }
+
+ if (eHAdj==SDRTEXTHORZADJUST_CENTER || eHAdj==SDRTEXTHORZADJUST_RIGHT)
+ {
+ long nFreeWdt=aAnkRect.GetWidth()-aTextSiz.Width();
+ if (eHAdj==SDRTEXTHORZADJUST_CENTER)
+ aTextPos.X()+=nFreeWdt/2;
+ if (eHAdj==SDRTEXTHORZADJUST_RIGHT)
+ aTextPos.X()+=nFreeWdt;
+ }
+ if (eVAdj==SDRTEXTVERTADJUST_CENTER || eVAdj==SDRTEXTVERTADJUST_BOTTOM)
+ {
+ long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height();
+ if (eVAdj==SDRTEXTVERTADJUST_CENTER)
+ aTextPos.Y()+=nFreeHgt/2;
+ if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
+ aTextPos.Y()+=nFreeHgt;
+ }
+ if (aGeo.nDrehWink!=0)
+ RotatePoint(aTextPos,aAnkRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+
+ if (pAnchorRect)
+ *pAnchorRect=aAnkRect;
+
+ // rTextRect ist bei ContourFrame in einigen Faellen nicht korrekt
+ rTextRect=Rectangle(aTextPos,aTextSiz);
+}
+
+void SdrObjCustomShape::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject)
+{
+ SdrTextObj::NbcSetOutlinerParaObject( pTextObject );
+ SetBoundRectDirty();
+ SetRectsDirty(TRUE);
+ InvalidateRenderGeometry();
+}
+
+void SdrObjCustomShape::operator=(const SdrObject& rObj)
+{
+ SdrTextObj::operator=( rObj );
+ aName =((SdrObjCustomShape&)rObj).aName;
+ fObjectRotation = ((SdrObjCustomShape&)rObj).fObjectRotation;
+ InvalidateRenderGeometry();
+}
+
+
+void SdrObjCustomShape::TakeObjNameSingul(XubString& rName) const
+{
+ rName = ImpGetResStr(STR_ObjNameSingulCUSTOMSHAPE);
+ String aNm( GetName() );
+ if( aNm.Len() )
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aNm;
+ rName += sal_Unicode('\'');
+ }
+}
+
+void SdrObjCustomShape::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralCUSTOMSHAPE);
+}
+
+basegfx::B2DPolyPolygon SdrObjCustomShape::TakeXorPoly() const
+{
+ return GetLineGeometry( (SdrObjCustomShape*)this, sal_False );
+}
+
+basegfx::B2DPolyPolygon SdrObjCustomShape::TakeContour() const
+{
+ const SdrObject* pSdrObject = GetSdrObjectFromCustomShape();
+ if ( pSdrObject )
+ return pSdrObject->TakeContour();
+ return basegfx::B2DPolyPolygon();
+}
+
+SdrObject* SdrObjCustomShape::DoConvertToPolyObj(BOOL bBezier) const
+{
+ // #i37011#
+ SdrObject* pRetval = 0L;
+ SdrObject* pRenderedCustomShape = 0L;
+
+ if ( !mXRenderedCustomShape.is() )
+ {
+ // force CustomShape
+ ((SdrObjCustomShape*)this)->GetSdrObjectFromCustomShape();
+ }
+
+ if ( mXRenderedCustomShape.is() )
+ {
+ pRenderedCustomShape = GetSdrObjectFromXShape( mXRenderedCustomShape );
+ }
+
+ if ( pRenderedCustomShape )
+ {
+ SdrObject* pCandidate = pRenderedCustomShape->Clone();
+ DBG_ASSERT(pCandidate, "SdrObjCustomShape::DoConvertToPolyObj: Could not clone SdrObject (!)");
+ pCandidate->SetModel(GetModel());
+ pRetval = pCandidate->DoConvertToPolyObj(bBezier);
+ SdrObject::Free( pCandidate );
+
+ if(pRetval)
+ {
+ const sal_Bool bShadow(((SdrShadowItem&)GetMergedItem(SDRATTR_SHADOW)).GetValue());
+ if(bShadow)
+ {
+ pRetval->SetMergedItem(SdrShadowItem(sal_True));
+ }
+ }
+
+ if(HasText() && !IsTextPath())
+ {
+ pRetval = ImpConvertAddText(pRetval, bBezier);
+ }
+ }
+
+ return pRetval;
+}
+
+void SdrObjCustomShape::NbcSetStyleSheet( SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr )
+{
+ // #i40944#
+ InvalidateRenderGeometry();
+ SdrObject::NbcSetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr );
+}
+
+void SdrObjCustomShape::SetPage( SdrPage* pNewPage )
+{
+ SdrTextObj::SetPage( pNewPage );
+
+ if( pNewPage )
+ {
+ // invalidating rectangles by SetRectsDirty is not sufficient,
+ // AdjustTextFrameWidthAndHeight() also has to be made, both
+ // actions are done by NbcSetSnapRect
+ Rectangle aTmp( aRect ); //creating temporary rectangle #i61108#
+ NbcSetSnapRect( aTmp );
+ }
+}
+
+SdrObjGeoData* SdrObjCustomShape::NewGeoData() const
+{
+ return new SdrAShapeObjGeoData;
+}
+
+void SdrObjCustomShape::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ SdrTextObj::SaveGeoData( rGeo );
+ SdrAShapeObjGeoData& rAGeo=(SdrAShapeObjGeoData&)rGeo;
+ rAGeo.fObjectRotation = fObjectRotation;
+ rAGeo.bMirroredX = IsMirroredX();
+ rAGeo.bMirroredY = IsMirroredY();
+
+ const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
+ Any* pAny( ( (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) ).GetPropertyValueByName( sAdjustmentValues ) );
+ if ( pAny )
+ *pAny >>= rAGeo.aAdjustmentSeq;
+}
+
+void SdrObjCustomShape::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ SdrTextObj::RestGeoData( rGeo );
+ SdrAShapeObjGeoData& rAGeo=(SdrAShapeObjGeoData&)rGeo;
+ fObjectRotation = rAGeo.fObjectRotation;
+ SetMirroredX( rAGeo.bMirroredX );
+ SetMirroredY( rAGeo.bMirroredY );
+
+ SdrCustomShapeGeometryItem rGeometryItem = (SdrCustomShapeGeometryItem&)GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
+ PropertyValue aPropVal;
+ aPropVal.Name = sAdjustmentValues;
+ aPropVal.Value <<= rAGeo.aAdjustmentSeq;
+ rGeometryItem.SetPropertyValue( aPropVal );
+ SetMergedItem( rGeometryItem );
+
+ InvalidateRenderGeometry();
+}
+
+void SdrObjCustomShape::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
+{
+ // break up matrix
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate, fShearX;
+ rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
+ // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
+ if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
+ {
+ aScale.setX(fabs(aScale.getX()));
+ aScale.setY(fabs(aScale.getY()));
+ fRotate = fmod(fRotate + F_PI, F_2PI);
+ }
+
+ // reset object shear and rotations
+ aGeo.nDrehWink = 0;
+ aGeo.RecalcSinCos();
+ aGeo.nShearWink = 0;
+ aGeo.RecalcTan();
+
+ // force metric to pool metric
+ SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // position
+ aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
+ aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplMMToTwips(aScale.getX()));
+ aScale.setY(ImplMMToTwips(aScale.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
+ }
+ }
+ }
+
+ // if anchor is used, make position relative to it
+ if( pModel && pModel->IsWriter() )
+ {
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
+ }
+ }
+
+ // build and set BaseRect (use scale)
+ Point aPoint = Point();
+ Size aSize(FRound(aScale.getX()), FRound(aScale.getY()));
+ Rectangle aBaseRect(aPoint, aSize);
+ SetSnapRect(aBaseRect);
+
+ // shear?
+ if(!basegfx::fTools::equalZero(fShearX))
+ {
+ GeoStat aGeoStat;
+ aGeoStat.nShearWink = FRound((atan(fShearX) / F_PI180) * 100.0);
+ aGeoStat.RecalcTan();
+ Shear(Point(), aGeoStat.nShearWink, aGeoStat.nTan, FALSE);
+ }
+
+ // rotation?
+ if(!basegfx::fTools::equalZero(fRotate))
+ {
+ GeoStat aGeoStat;
+
+ // #i78696#
+ // fRotate is mathematically correct, but aGeoStat.nDrehWink is
+ // mirrored -> mirror value here
+ aGeoStat.nDrehWink = NormAngle360(FRound(-fRotate / F_PI18000));
+ aGeoStat.RecalcSinCos();
+ Rotate(Point(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos);
+ }
+
+ // translate?
+ if(!aTranslate.equalZero())
+ {
+ Move(Size(FRound(aTranslate.getX()), FRound(aTranslate.getY())));
+ }
+}
+
+// taking fObjectRotation instead of aGeo.nWink
+sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
+{
+ // get turn and shear
+// double fRotate = (aGeo.nDrehWink / 100.0) * F_PI180;
+ double fRotate = fObjectRotation * F_PI180;
+ double fShearX = (aGeo.nShearWink / 100.0) * F_PI180;
+
+ // get aRect, this is the unrotated snaprect
+ Rectangle aRectangle(aRect);
+
+ sal_Bool bMirroredX = IsMirroredX();
+ sal_Bool bMirroredY = IsMirroredY();
+ if ( bMirroredX || bMirroredY )
+ { // we have to retrieve the unmirrored rect
+
+ GeoStat aNewGeo( aGeo );
+
+ if ( bMirroredX )
+ {
+ Polygon aPol( Rect2Poly( aRect, aNewGeo ) );
+ Rectangle aBoundRect( aPol.GetBoundRect() );
+
+ Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() );
+ Point aRef2( aRef1.X(), aRef1.Y() + 1000 );
+ USHORT i;
+ USHORT nPntAnz=aPol.GetSize();
+ for (i=0; i<nPntAnz; i++)
+ {
+ MirrorPoint(aPol[i],aRef1,aRef2);
+ }
+ // Polygon wenden und etwas schieben
+ Polygon aPol0(aPol);
+ aPol[0]=aPol0[1];
+ aPol[1]=aPol0[0];
+ aPol[2]=aPol0[3];
+ aPol[3]=aPol0[2];
+ aPol[4]=aPol0[1];
+ Poly2Rect(aPol,aRectangle,aNewGeo);
+ }
+ if ( bMirroredY )
+ {
+ Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) );
+ Rectangle aBoundRect( aPol.GetBoundRect() );
+
+ Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 );
+ Point aRef2( aRef1.X() + 1000, aRef1.Y() );
+ USHORT i;
+ USHORT nPntAnz=aPol.GetSize();
+ for (i=0; i<nPntAnz; i++)
+ {
+ MirrorPoint(aPol[i],aRef1,aRef2);
+ }
+ // Polygon wenden und etwas schieben
+ Polygon aPol0(aPol);
+ aPol[0]=aPol0[1];
+ aPol[1]=aPol0[0];
+ aPol[2]=aPol0[3];
+ aPol[3]=aPol0[2];
+ aPol[4]=aPol0[1];
+ Poly2Rect(aPol,aRectangle,aNewGeo);
+ }
+ }
+
+ // fill other values
+ basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
+ basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
+
+ // position maybe relative to anchorpos, convert
+ if( pModel && pModel->IsWriter() )
+ {
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
+ }
+ }
+
+ // force MapUnit to 100th mm
+ SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // postion
+ aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
+ aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplTwipsToMM(aScale.getX()));
+ aScale.setY(ImplTwipsToMM(aScale.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
+ }
+ }
+ }
+
+ // build matrix
+ rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aScale,
+ basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX),
+ basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate,
+ aTranslate);
+
+ return sal_False;
+}
+
+sdr::contact::ViewContact* SdrObjCustomShape::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfSdrObjCustomShape(*this);
+}
+
+// #i33136#
+bool SdrObjCustomShape::doConstructOrthogonal(const ::rtl::OUString& rName)
+{
+ bool bRetval(false);
+ static ::rtl::OUString Imps_sNameASOrtho_quadrat( RTL_CONSTASCII_USTRINGPARAM( "quadrat" ) );
+ static ::rtl::OUString Imps_sNameASOrtho_round_quadrat( RTL_CONSTASCII_USTRINGPARAM( "round-quadrat" ) );
+ static ::rtl::OUString Imps_sNameASOrtho_circle( RTL_CONSTASCII_USTRINGPARAM( "circle" ) );
+ static ::rtl::OUString Imps_sNameASOrtho_circle_pie( RTL_CONSTASCII_USTRINGPARAM( "circle-pie" ) );
+ static ::rtl::OUString Imps_sNameASOrtho_ring( RTL_CONSTASCII_USTRINGPARAM( "ring" ) );
+
+ if(Imps_sNameASOrtho_quadrat.equalsIgnoreAsciiCase(rName))
+ {
+ bRetval = true;
+ }
+ else if(Imps_sNameASOrtho_round_quadrat.equalsIgnoreAsciiCase(rName))
+ {
+ bRetval = true;
+ }
+ else if(Imps_sNameASOrtho_circle.equalsIgnoreAsciiCase(rName))
+ {
+ bRetval = true;
+ }
+ else if(Imps_sNameASOrtho_circle_pie.equalsIgnoreAsciiCase(rName))
+ {
+ bRetval = true;
+ }
+ else if(Imps_sNameASOrtho_ring.equalsIgnoreAsciiCase(rName))
+ {
+ bRetval = true;
+ }
+
+ return bRetval;
+}
+
+// #i37011# centralize throw-away of render geometry
+void SdrObjCustomShape::InvalidateRenderGeometry()
+{
+ mXRenderedCustomShape = 0L;
+ SdrObject::Free( mpLastShadowGeometry );
+ mpLastShadowGeometry = 0L;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdoattr.cxx b/svx/source/svdraw/svdoattr.cxx
new file mode 100644
index 000000000000..ce8378a0c496
--- /dev/null
+++ b/svx/source/svdraw/svdoattr.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdoattr.hxx>
+#include <svx/xpool.hxx>
+#include "svditext.hxx"
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdattr.hxx>
+#include <svx/svdattrx.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdorect.hxx>
+#include <svx/svdocirc.hxx>
+#include <svx/svdomeas.hxx>
+#include <svl/smplhint.hxx>
+#include <svl/itemiter.hxx>
+#include <svx/xenum.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflbmtit.hxx>
+#include <svx/xtextit0.hxx>
+#include <svx/xflbstit.hxx>
+#include <svx/xflbtoxy.hxx>
+#include <svx/xftshit.hxx>
+
+
+#include <editeng/colritem.hxx>
+#include "editeng/fontitem.hxx"
+#include <editeng/fhgtitem.hxx>
+
+#include <svx/xlnstcit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svl/style.hxx>
+#include <svl/style.hxx>
+#include <svl/whiter.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/xlnedcit.hxx>
+#include <editeng/adjitem.hxx>
+#include <svx/xflbckit.hxx>
+#include <svx/xtable.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/xflftrit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/sdr/properties/attributeproperties.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include "svx/xlinjoit.hxx"
+#include <svdoimp.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+sdr::properties::BaseProperties* SdrAttrObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::AttributeProperties(*this);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrAttrObj,SdrObject);
+
+SdrAttrObj::SdrAttrObj()
+{
+}
+
+SdrAttrObj::~SdrAttrObj()
+{
+}
+
+const Rectangle& SdrAttrObj::GetSnapRect() const
+{
+ if(bSnapRectDirty)
+ {
+ ((SdrAttrObj*)this)->RecalcSnapRect();
+ ((SdrAttrObj*)this)->bSnapRectDirty = false;
+ }
+
+ return maSnapRect;
+}
+
+void SdrAttrObj::SetModel(SdrModel* pNewModel)
+{
+ SdrModel* pOldModel = pModel;
+
+ // test for correct pool in ItemSet; move to new pool if necessary
+ if(pNewModel && GetObjectItemPool() && GetObjectItemPool() != &pNewModel->GetItemPool())
+ {
+ MigrateItemPool(GetObjectItemPool(), &pNewModel->GetItemPool(), pNewModel);
+ }
+
+ // call parent
+ SdrObject::SetModel(pNewModel);
+
+ // modify properties
+ GetProperties().SetModel(pOldModel, pNewModel);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// syntactical sugar for ItemSet accesses
+
+void __EXPORT SdrAttrObj::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
+{
+ SfxSimpleHint *pSimple = PTR_CAST(SfxSimpleHint, &rHint);
+ BOOL bDataChg(pSimple && SFX_HINT_DATACHANGED == pSimple->GetId());
+
+ if(bDataChg)
+ {
+ Rectangle aBoundRect = GetLastBoundRect();
+ SetBoundRectDirty();
+ SetRectsDirty(sal_True);
+
+ // This may have lead to object change
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_CHGATTR, aBoundRect);
+ }
+}
+
+sal_Int32 SdrAttrObj::ImpGetLineWdt() const
+{
+ sal_Int32 nRetval(0);
+
+ if(XLINE_NONE != ((XLineStyleItem&)(GetObjectItem(XATTR_LINESTYLE))).GetValue())
+ {
+ nRetval = ((XLineWidthItem&)(GetObjectItem(XATTR_LINEWIDTH))).GetValue();
+ }
+
+ return nRetval;
+}
+
+BOOL SdrAttrObj::HasFill() const
+{
+ return bClosedObj && ((XFillStyleItem&)(GetProperties().GetObjectItemSet().Get(XATTR_FILLSTYLE))).GetValue()!=XFILL_NONE;
+}
+
+BOOL SdrAttrObj::HasLine() const
+{
+ return ((XLineStyleItem&)(GetProperties().GetObjectItemSet().Get(XATTR_LINESTYLE))).GetValue()!=XLINE_NONE;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
new file mode 100644
index 000000000000..1285c886fff4
--- /dev/null
+++ b/svx/source/svdraw/svdobj.cxx
@@ -0,0 +1,3313 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/lang/XComponent.hpp>
+
+#define _USE_MATH_DEFINES
+#include <math.h>
+#include <vcl/metaact.hxx> // fuer TakeContour
+#include <vcl/cvtsvm.hxx>
+#include <tools/line.hxx>
+#include <tools/bigint.hxx>
+#include <tools/diagnose_ex.h>
+#include <vector>
+#include <svx/svdobj.hxx>
+#include <svx/xpoly.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdhdl.hxx>
+#include <svx/svddrag.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdovirt.hxx> // Fuer Add/Del Ref
+#include <svx/svdview.hxx> // fuer Dragging (Ortho abfragen)
+#include "svdglob.hxx" // StringCache
+#include "svdstr.hrc" // Objektname
+#include <svx/svdogrp.hxx> // Factory
+#include <svx/svdopath.hxx> // Factory
+#include <svx/svdoedge.hxx> // Factory
+#include <svx/svdorect.hxx> // Factory
+#include <svx/svdocirc.hxx> // Factory
+#include <svx/svdotext.hxx> // Factory
+#include <svx/svdomeas.hxx> // Factory
+#include <svx/svdograf.hxx> // Factory
+#include <svx/svdoole2.hxx> // Factory
+#include <svx/svdocapt.hxx> // Factory
+#include <svx/svdopage.hxx> // Factory
+#include <svx/svdouno.hxx> // Factory
+#include <svx/svdattrx.hxx> // NotPersistItems
+#include <svx/svdoashp.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xlnstcit.hxx>
+#include <svx/xlnedcit.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xflclit.hxx>
+#include "svditer.hxx"
+#include <svx/xlntrit.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/xfltrit.hxx>
+#include <svx/xflftrit.hxx>
+#include "svx/xlinjoit.hxx"
+#include <svx/unopage.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/xenum.hxx>
+#include <svx/xgrad.hxx>
+#include <svx/xhatch.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/svdpool.hxx>
+#include <editeng/editeng.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include <svl/whiter.hxx>
+
+// #97849#
+#include <svx/fmmodel.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/objface.hxx>
+#include "svdoimp.hxx"
+#include <vcl/graphictools.hxx>
+#include <svtools/colorcfg.hxx>
+#include <svx/sdr/properties/emptyproperties.hxx>
+#include <svx/sdr/contact/viewcontactofsdrobj.hxx>
+#include <svx/sdr/contact/viewcontactofgraphic.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <svx/unoshape.hxx>
+#include <vcl/virdev.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#include <drawinglayer/processor2d/contourextractor2d.hxx>
+#include <drawinglayer/processor2d/linegeometryextractor2d.hxx>
+#include <svx/polysc3d.hxx>
+#include "svx/svdotable.hxx"
+#include "svx/shapepropertynotifier.hxx"
+#include <svx/sdrhittesthelper.hxx>
+#include <svx/svdundo.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <svx/sdrobjectfilter.hxx>
+
+using namespace ::com::sun::star;
+
+// #104018# replace macros above with type-detecting methods
+inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
+inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT0(SdrObjUserCall);
+
+SdrObjUserCall::~SdrObjUserCall()
+{
+}
+
+void SdrObjUserCall::Changed(const SdrObject& /*rObj*/, SdrUserCallType /*eType*/, const Rectangle& /*rOldBoundRect*/)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT0(SdrObjUserData);
+
+void SdrObjUserData::operator=(const SdrObjUserData& /*rData*/) // nicht implementiert
+{
+}
+
+sal_Bool SdrObjUserData::operator==(const SdrObjUserData& /*rData*/) const // nicht implementiert
+{
+ return FALSE;
+}
+
+sal_Bool SdrObjUserData::operator!=(const SdrObjUserData& /*rData*/) const // nicht implementiert
+{
+ return FALSE;
+}
+
+SdrObjUserData::~SdrObjUserData()
+{
+}
+
+bool SdrObjUserData::HasMacro(const SdrObject* /*pObj*/) const
+{
+ return FALSE;
+}
+
+SdrObject* SdrObjUserData::CheckMacroHit(const SdrObjMacroHitRec& rRec, const SdrObject* pObj) const
+{
+ if(pObj)
+ {
+ if(rRec.pPageView)
+ {
+ return SdrObjectPrimitiveHit(*pObj, rRec.aPos, rRec.nTol, *rRec.pPageView, rRec.pVisiLayer, false);
+ }
+ }
+
+ return 0;
+}
+
+Pointer SdrObjUserData::GetMacroPointer(const SdrObjMacroHitRec& /*rRec*/, const SdrObject* /*pObj*/) const
+{
+ return Pointer(POINTER_REFHAND);
+}
+
+void SdrObjUserData::PaintMacro(OutputDevice& rOut, const Rectangle& /*rDirtyRect*/, const SdrObjMacroHitRec& /*rRec*/, const SdrObject* pObj) const
+{
+ if(!pObj)
+ return;
+
+ const RasterOp eRop(rOut.GetRasterOp());
+ const basegfx::B2DPolyPolygon aPolyPolygon(pObj->TakeXorPoly());
+ const sal_uInt32 nCount(aPolyPolygon.count());
+
+ rOut.SetLineColor(COL_BLACK);
+ rOut.SetFillColor();
+ rOut.SetRasterOp(ROP_INVERT);
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ rOut.DrawPolyLine(aPolyPolygon.getB2DPolygon(a));
+ }
+
+ rOut.SetRasterOp(eRop);
+}
+
+bool SdrObjUserData::DoMacro(const SdrObjMacroHitRec& /*rRec*/, SdrObject* /*pObj*/)
+{
+ return FALSE;
+}
+
+XubString SdrObjUserData::GetMacroPopupComment(const SdrObjMacroHitRec& /*rRec*/, const SdrObject* /*pObj*/) const
+{
+ return String();
+}
+
+void SdrObjUserDataList::Clear()
+{
+ USHORT nAnz=GetUserDataCount();
+ for (USHORT i=0; i<nAnz; i++) {
+ delete GetUserData(i);
+ }
+ aList.Clear();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+DBG_NAME(SdrObjGeoData);
+
+SdrObjGeoData::SdrObjGeoData():
+ pGPL(NULL),
+ bMovProt(FALSE),
+ bSizProt(FALSE),
+ bNoPrint(FALSE),
+ bClosedObj(FALSE),
+ mbVisible(true),
+ mnLayerID(0)
+{
+ DBG_CTOR(SdrObjGeoData,NULL);
+}
+
+SdrObjGeoData::~SdrObjGeoData()
+{
+ DBG_DTOR(SdrObjGeoData,NULL);
+ delete pGPL;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT0(SdrObjPlusData);
+
+SdrObjPlusData::SdrObjPlusData():
+ pBroadcast(NULL),
+ pUserDataList(NULL),
+ pGluePoints(NULL),
+ pAutoTimer(NULL)
+{
+}
+
+SdrObjPlusData::~SdrObjPlusData()
+{
+ if (pBroadcast !=NULL) delete pBroadcast;
+ if (pUserDataList!=NULL) delete pUserDataList;
+ if (pGluePoints !=NULL) delete pGluePoints;
+ if (pAutoTimer !=NULL) delete pAutoTimer;
+}
+
+SdrObjPlusData* SdrObjPlusData::Clone(SdrObject* pObj1) const
+{
+ SdrObjPlusData* pNeuPlusData=new SdrObjPlusData;
+ if (pUserDataList!=NULL) {
+ USHORT nAnz=pUserDataList->GetUserDataCount();
+ if (nAnz!=0) {
+ pNeuPlusData->pUserDataList=new SdrObjUserDataList;
+ for (USHORT i=0; i<nAnz; i++) {
+ SdrObjUserData* pNeuUserData=pUserDataList->GetUserData(i)->Clone(pObj1);
+ if (pNeuUserData!=NULL) {
+ pNeuPlusData->pUserDataList->InsertUserData(pNeuUserData);
+ } else {
+ DBG_ERROR("SdrObjPlusData::Clone(): UserData.Clone() liefert NULL");
+ }
+ }
+ }
+ }
+ if (pGluePoints!=NULL) pNeuPlusData->pGluePoints=new SdrGluePointList(*pGluePoints);
+ // MtfAnimator wird auch nicht mitkopiert
+
+ // #i68101#
+ // copy object name, title and description
+ pNeuPlusData->aObjName = aObjName;
+ pNeuPlusData->aObjTitle = aObjTitle;
+ pNeuPlusData->aObjDescription = aObjDescription;
+
+ if (pAutoTimer!=NULL) {
+ pNeuPlusData->pAutoTimer=new AutoTimer;
+ // Handler, etc. nicht mitkopieren!
+ }
+
+ // For HTMLName: Do not clone, leave uninitialized (empty string)
+
+ return pNeuPlusData;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@ @@@@@ @@@@@@ @@@@@ @@@@ @@@@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@@@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@ @@@@@ @@@@ @@@@@ @@@@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrObject::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::EmptyProperties(*this);
+}
+
+sdr::properties::BaseProperties& SdrObject::GetProperties() const
+{
+ if(!mpProperties)
+ {
+ const_cast< SdrObject* >(this)->mpProperties =
+ const_cast< SdrObject* >(this)->CreateObjectSpecificProperties();
+ }
+
+ return *mpProperties;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ObjectUser section
+
+void SdrObject::AddObjectUser(sdr::ObjectUser& rNewUser)
+{
+ maObjectUsers.push_back(&rNewUser);
+}
+
+void SdrObject::RemoveObjectUser(sdr::ObjectUser& rOldUser)
+{
+ const ::sdr::ObjectUserVector::iterator aFindResult = ::std::find(maObjectUsers.begin(), maObjectUsers.end(), &rOldUser);
+ if(aFindResult != maObjectUsers.end())
+ {
+ maObjectUsers.erase(aFindResult);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// #110094# DrawContact section
+
+sdr::contact::ViewContact* SdrObject::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfSdrObj(*this);
+}
+
+sdr::contact::ViewContact& SdrObject::GetViewContact() const
+{
+ if(!mpViewContact)
+ {
+ const_cast< SdrObject* >(this)->mpViewContact =
+ const_cast< SdrObject* >(this)->CreateObjectSpecificViewContact();
+ }
+
+ return *mpViewContact;
+}
+
+// DrawContact support: Methods for handling Object changes
+void SdrObject::ActionChanged() const
+{
+ // Do necessary ViewContact actions
+ GetViewContact().ActionChanged();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void SdrObject::SetBoundRectDirty()
+{
+ aOutRect = Rectangle();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+DBG_NAME(SdrObject);
+TYPEINIT1(SdrObject,SfxListener);
+
+SdrObject::SdrObject()
+ :mpProperties(0L)
+ ,mpViewContact(0L)
+ ,pObjList(NULL)
+ ,pPage(NULL)
+ ,pModel(NULL)
+ ,pUserCall(NULL)
+ ,pPlusData(NULL)
+ ,nOrdNum(0)
+ ,mnNavigationPosition(SAL_MAX_UINT32)
+ ,mnLayerID(0)
+ ,mpSvxShape( NULL )
+ ,maWeakUnoShape()
+{
+ DBG_CTOR(SdrObject,NULL);
+ bVirtObj =FALSE;
+ bSnapRectDirty =TRUE;
+ bNetLock =FALSE;
+ bInserted =FALSE;
+ bGrouped =FALSE;
+ bMovProt =FALSE;
+ bSizProt =FALSE;
+ bNoPrint =FALSE;
+ bEmptyPresObj =FALSE;
+ bNotVisibleAsMaster=FALSE;
+ bClosedObj =FALSE;
+ mbVisible = true;
+
+ // #i25616#
+ mbLineIsOutsideGeometry = sal_False;
+
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_False;
+
+ //#110094#-1
+ //bWriterFlyFrame =FALSE;
+
+ bNotMasterCachable=FALSE;
+ bIsEdge=FALSE;
+ bIs3DObj=FALSE;
+ bMarkProt=FALSE;
+ bIsUnoObj=FALSE;
+}
+
+SdrObject::~SdrObject()
+{
+ // tell all the registered ObjectUsers that the page is in destruction
+ ::sdr::ObjectUserVector aListCopy(maObjectUsers.begin(), maObjectUsers.end());
+ for(::sdr::ObjectUserVector::iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); aIterator++)
+ {
+ sdr::ObjectUser* pObjectUser = *aIterator;
+ DBG_ASSERT(pObjectUser, "SdrObject::~SdrObject: corrupt ObjectUser list (!)");
+ pObjectUser->ObjectInDestruction(*this);
+ }
+
+ // Clear the vector. This means that user do not need to call RemoveObjectUser()
+ // when they get called from ObjectInDestruction().
+ maObjectUsers.clear();
+
+ try
+ {
+ SvxShape* pSvxShape = getSvxShape();
+ if ( pSvxShape )
+ {
+ OSL_ENSURE(!pSvxShape->HasSdrObjectOwnership(),"Please check where this call come from and replace it with SdrObject::Free");
+ pSvxShape->InvalidateSdrObject();
+ uno::Reference< lang::XComponent > xShapeComp( getWeakUnoShape(), uno::UNO_QUERY_THROW );
+ xShapeComp->dispose();
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ DBG_DTOR(SdrObject,NULL);
+ SendUserCall(SDRUSERCALL_DELETE, GetLastBoundRect());
+ if (pPlusData!=NULL) delete pPlusData;
+
+ if(mpProperties)
+ {
+ delete mpProperties;
+ mpProperties = 0L;
+ }
+
+ // #110094#
+ if(mpViewContact)
+ {
+ delete mpViewContact;
+ mpViewContact = 0L;
+ }
+}
+
+void SdrObject::Free( SdrObject*& _rpObject )
+{
+ SdrObject* pObject = _rpObject; _rpObject = NULL;
+ if ( pObject == NULL )
+ // nothing to do
+ return;
+
+ SvxShape* pShape = pObject->getSvxShape();
+ if ( pShape && pShape->HasSdrObjectOwnership() )
+ // only the shape is allowed to delete me, and will reset the ownership before doing so
+ return;
+
+ delete pObject;
+}
+
+SdrObjPlusData* SdrObject::NewPlusData() const
+{
+ return new SdrObjPlusData;
+}
+
+void SdrObject::SetRectsDirty(sal_Bool bNotMyself)
+{
+ if (!bNotMyself) {
+ SetBoundRectDirty();
+ bSnapRectDirty=TRUE;
+ }
+ if (pObjList!=NULL) {
+ pObjList->SetRectsDirty();
+ }
+}
+
+void SdrObject::SetModel(SdrModel* pNewModel)
+{
+ if(pNewModel && pPage)
+ {
+ if(pPage->GetModel() != pNewModel)
+ {
+ pPage = NULL;
+ }
+ }
+
+ // update listeners at possible api wrapper object
+ if( pModel != pNewModel )
+ {
+ SvxShape* pShape = getSvxShape();
+ if( pShape )
+ pShape->ChangeModel( pNewModel );
+ }
+
+ pModel = pNewModel;
+}
+
+void SdrObject::SetObjList(SdrObjList* pNewObjList)
+{
+ pObjList=pNewObjList;
+}
+
+void SdrObject::SetPage(SdrPage* pNewPage)
+{
+ pPage=pNewPage;
+ if (pPage!=NULL) {
+ SdrModel* pMod=pPage->GetModel();
+ if (pMod!=pModel && pMod!=NULL) {
+ SetModel(pMod);
+ }}
+}
+
+// init global static itempool
+SdrItemPool* SdrObject::mpGlobalItemPool = NULL;
+
+SdrItemPool& SdrObject::GetGlobalDrawObjectItemPool()
+{
+ if(!mpGlobalItemPool)
+ {
+ mpGlobalItemPool = new SdrItemPool();
+ SfxItemPool* pGlobalOutlPool = EditEngine::CreatePool();
+ mpGlobalItemPool->SetSecondaryPool(pGlobalOutlPool);
+ mpGlobalItemPool->SetDefaultMetric((SfxMapUnit)SdrEngineDefaults::GetMapUnit());
+ mpGlobalItemPool->FreezeIdRanges();
+ }
+
+ return *mpGlobalItemPool;
+}
+
+void SdrObject::FreeGlobalDrawObjectItemPool()
+{
+ // code for deletion of GlobalItemPool
+ if(mpGlobalItemPool)
+ {
+ SfxItemPool* pGlobalOutlPool = mpGlobalItemPool->GetSecondaryPool();
+ SfxItemPool::Free(mpGlobalItemPool);
+ SfxItemPool::Free(pGlobalOutlPool);
+ }
+}
+
+SdrItemPool* SdrObject::GetObjectItemPool() const
+{
+ if(pModel)
+ return (SdrItemPool*)(&pModel->GetItemPool());
+
+ // use a static global default pool
+ return &SdrObject::GetGlobalDrawObjectItemPool();
+}
+
+UINT32 SdrObject::GetObjInventor() const
+{
+ return SdrInventor;
+}
+
+UINT16 SdrObject::GetObjIdentifier() const
+{
+ return UINT16(OBJ_NONE);
+}
+
+void SdrObject::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bRotateFreeAllowed=FALSE;
+ rInfo.bMirrorFreeAllowed=FALSE;
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ rInfo.bShearAllowed =FALSE;
+ rInfo.bEdgeRadiusAllowed=FALSE;
+ rInfo.bCanConvToPath =FALSE;
+ rInfo.bCanConvToPoly =FALSE;
+ rInfo.bCanConvToContour = FALSE;
+ rInfo.bCanConvToPathLineToArea=FALSE;
+ rInfo.bCanConvToPolyLineToArea=FALSE;
+}
+
+SdrLayerID SdrObject::GetLayer() const
+{
+ return mnLayerID;
+}
+
+void SdrObject::getMergedHierarchyLayerSet(SetOfByte& rSet) const
+{
+ rSet.Set(GetLayer());
+ SdrObjList* pOL=GetSubList();
+ if (pOL!=NULL) {
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
+ pOL->GetObj(nObjNum)->getMergedHierarchyLayerSet(rSet);
+ }
+ }
+}
+
+void SdrObject::NbcSetLayer(SdrLayerID nLayer)
+{
+ if(GetLayer() != nLayer)
+ {
+ mnLayerID = nLayer;
+ }
+}
+
+void SdrObject::SetLayer(SdrLayerID nLayer)
+{
+ NbcSetLayer(nLayer);
+ SetChanged();
+ BroadcastObjectChange();
+}
+
+void SdrObject::AddListener(SfxListener& rListener)
+{
+ ImpForcePlusData();
+ if (pPlusData->pBroadcast==NULL) pPlusData->pBroadcast=new SfxBroadcaster;
+ rListener.StartListening(*pPlusData->pBroadcast);
+}
+
+void SdrObject::RemoveListener(SfxListener& rListener)
+{
+ if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) {
+ rListener.EndListening(*pPlusData->pBroadcast);
+ if (!pPlusData->pBroadcast->HasListeners()) {
+ delete pPlusData->pBroadcast;
+ pPlusData->pBroadcast=NULL;
+ }
+ }
+}
+
+void SdrObject::AddReference(SdrVirtObj& rVrtObj)
+{
+ AddListener(rVrtObj);
+}
+
+void SdrObject::DelReference(SdrVirtObj& rVrtObj)
+{
+ RemoveListener(rVrtObj);
+}
+
+AutoTimer* SdrObject::ForceAutoTimer()
+{
+ ImpForcePlusData();
+ if (pPlusData->pAutoTimer==NULL) pPlusData->pAutoTimer=new AutoTimer;
+ return pPlusData->pAutoTimer;
+}
+
+bool SdrObject::HasRefPoint() const
+{
+ return FALSE;
+}
+
+Point SdrObject::GetRefPoint() const
+{
+ return GetCurrentBoundRect().Center();
+}
+
+void SdrObject::SetRefPoint(const Point& /*rPnt*/)
+{
+}
+
+SdrObjList* SdrObject::GetSubList() const
+{
+ return NULL;
+}
+
+SdrObject* SdrObject::GetUpGroup() const
+{
+ return pObjList!=NULL ? pObjList->GetOwnerObj() : NULL;
+}
+
+void SdrObject::SetName(const String& rStr)
+{
+ if(rStr.Len() && !pPlusData)
+ {
+ ImpForcePlusData();
+ }
+
+ if(pPlusData && pPlusData->aObjName != rStr)
+ {
+ // --> OD 2009-07-09 #i73249#
+ // Undo/Redo for setting object's name
+ bool bUndo( false );
+ if ( GetModel() && GetModel()->IsUndoEnabled() )
+ {
+ bUndo = true;
+ SdrUndoAction* pUndoAction =
+ GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
+ *this,
+ SdrUndoObjStrAttr::OBJ_NAME,
+ GetName(),
+ rStr );
+ GetModel()->BegUndo( pUndoAction->GetComment() );
+ GetModel()->AddUndo( pUndoAction );
+ }
+ // <--
+ pPlusData->aObjName = rStr;
+ // --> OD 2009-07-09 #i73249#
+ if ( bUndo )
+ {
+ GetModel()->EndUndo();
+ }
+ // <--
+ SetChanged();
+ BroadcastObjectChange();
+ }
+}
+
+String SdrObject::GetName() const
+{
+ if(pPlusData)
+ {
+ return pPlusData->aObjName;
+ }
+
+ return String();
+}
+
+void SdrObject::SetTitle(const String& rStr)
+{
+ if(rStr.Len() && !pPlusData)
+ {
+ ImpForcePlusData();
+ }
+
+ if(pPlusData && pPlusData->aObjTitle != rStr)
+ {
+ // --> OD 2009-07-13 #i73249#
+ // Undo/Redo for setting object's title
+ bool bUndo( false );
+ if ( GetModel() && GetModel()->IsUndoEnabled() )
+ {
+ bUndo = true;
+ SdrUndoAction* pUndoAction =
+ GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
+ *this,
+ SdrUndoObjStrAttr::OBJ_TITLE,
+ GetTitle(),
+ rStr );
+ GetModel()->BegUndo( pUndoAction->GetComment() );
+ GetModel()->AddUndo( pUndoAction );
+ }
+ // <--
+ pPlusData->aObjTitle = rStr;
+ // --> OD 2009-07-13 #i73249#
+ if ( bUndo )
+ {
+ GetModel()->EndUndo();
+ }
+ // <--
+ SetChanged();
+ BroadcastObjectChange();
+ }
+}
+
+String SdrObject::GetTitle() const
+{
+ if(pPlusData)
+ {
+ return pPlusData->aObjTitle;
+ }
+
+ return String();
+}
+
+void SdrObject::SetDescription(const String& rStr)
+{
+ if(rStr.Len() && !pPlusData)
+ {
+ ImpForcePlusData();
+ }
+
+ if(pPlusData && pPlusData->aObjDescription != rStr)
+ {
+ // --> OD 2009-07-13 #i73249#
+ // Undo/Redo for setting object's description
+ bool bUndo( false );
+ if ( GetModel() && GetModel()->IsUndoEnabled() )
+ {
+ bUndo = true;
+ SdrUndoAction* pUndoAction =
+ GetModel()->GetSdrUndoFactory().CreateUndoObjectStrAttr(
+ *this,
+ SdrUndoObjStrAttr::OBJ_DESCRIPTION,
+ GetDescription(),
+ rStr );
+ GetModel()->BegUndo( pUndoAction->GetComment() );
+ GetModel()->AddUndo( pUndoAction );
+ }
+ // <--
+ pPlusData->aObjDescription = rStr;
+ // --> OD 2009-07-13 #i73249#
+ if ( bUndo )
+ {
+ GetModel()->EndUndo();
+ }
+ // <--
+ SetChanged();
+ BroadcastObjectChange();
+ }
+}
+
+String SdrObject::GetDescription() const
+{
+ if(pPlusData)
+ {
+ return pPlusData->aObjDescription;
+ }
+
+ return String();
+}
+
+void SdrObject::SetHTMLName(const String& rStr)
+{
+ if(rStr.Len() && !pPlusData)
+ {
+ ImpForcePlusData();
+ }
+
+ if(pPlusData && pPlusData->aObjName != rStr)
+ {
+ pPlusData->aHTMLName = rStr;
+ SetChanged();
+ }
+}
+
+String SdrObject::GetHTMLName() const
+{
+ if(pPlusData)
+ {
+ return pPlusData->aHTMLName;
+ }
+
+ return String();
+}
+
+UINT32 SdrObject::GetOrdNum() const
+{
+ if (pObjList!=NULL) {
+ if (pObjList->IsObjOrdNumsDirty()) {
+ pObjList->RecalcObjOrdNums();
+ }
+ } else ((SdrObject*)this)->nOrdNum=0;
+ return nOrdNum;
+}
+
+
+
+
+sal_uInt32 SdrObject::GetNavigationPosition (void)
+{
+ if (pObjList!=NULL && pObjList->RecalcNavigationPositions())
+ {
+ return mnNavigationPosition;
+ }
+ else
+ return GetOrdNum();
+}
+
+
+
+
+void SdrObject::SetNavigationPosition (const sal_uInt32 nNewPosition)
+{
+ mnNavigationPosition = nNewPosition;
+}
+
+
+
+
+// #111111#
+// To make clearer that this method may trigger RecalcBoundRect and thus may be
+// expensive and somtimes problematic (inside a bigger object change You will get
+// non-useful BoundRects sometimes) i rename that method from GetBoundRect() to
+// GetCurrentBoundRect().
+const Rectangle& SdrObject::GetCurrentBoundRect() const
+{
+ if(aOutRect.IsEmpty())
+ {
+ const_cast< SdrObject* >(this)->RecalcBoundRect();
+ }
+
+ return aOutRect;
+}
+
+// #111111#
+// To have a possibility to get the last calculated BoundRect e.g for producing
+// the first rectangle for repaints (old and new need to be used) without forcing
+// a RecalcBoundRect (which may be problematical and expensive sometimes) i add here
+// a new method for accessing the last BoundRect.
+const Rectangle& SdrObject::GetLastBoundRect() const
+{
+ return aOutRect;
+}
+
+void SdrObject::RecalcBoundRect()
+{
+ // #i101680# suppress BoundRect calculations on import(s)
+ if(pModel && pModel->isLocked() )
+ return;
+
+ // central new method which will calculate the BoundRect using primitive geometry
+ if(aOutRect.IsEmpty())
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence xPrimitives(GetViewContact().getViewIndependentPrimitive2DSequence());
+
+ if(xPrimitives.hasElements())
+ {
+ // use neutral ViewInformation and get the range of the primitives
+ const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0);
+ const basegfx::B2DRange aRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xPrimitives, aViewInformation2D));
+
+ if(!aRange.isEmpty())
+ {
+ aOutRect = Rectangle(
+ (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()),
+ (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY()));
+ return;
+ }
+ }
+ }
+}
+
+void SdrObject::BroadcastObjectChange() const
+{
+ if( pModel && pModel->isLocked() )
+ return;
+
+ sal_Bool bPlusDataBroadcast(pPlusData && pPlusData->pBroadcast);
+ sal_Bool bObjectChange(IsInserted() && pModel);
+
+ if(bPlusDataBroadcast || bObjectChange)
+ {
+ SdrHint aHint(*this);
+
+ if(bPlusDataBroadcast)
+ {
+ pPlusData->pBroadcast->Broadcast(aHint);
+ }
+
+ if(bObjectChange)
+ {
+ pModel->Broadcast(aHint);
+ }
+ }
+}
+
+void SdrObject::SetChanged()
+{
+ // #110094#-11
+ // For test purposes, use the new ViewContact for change
+ // notification now.
+ ActionChanged();
+
+ if(IsInserted() && pModel)
+ {
+ pModel->SetChanged();
+ }
+}
+
+// Tooling for painting a single object to a OutputDevice.
+sal_Bool SdrObject::SingleObjectPainter(OutputDevice& rOut) const
+{
+ sdr::contact::SdrObjectVector aObjectVector;
+ aObjectVector.push_back(const_cast< SdrObject* >(this));
+
+ sdr::contact::ObjectContactOfObjListPainter aPainter(rOut, aObjectVector, GetPage());
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ // do processing
+ aPainter.ProcessDisplay(aDisplayInfo);
+
+ return sal_True;
+}
+
+BOOL SdrObject::LineGeometryUsageIsNecessary() const
+{
+ XLineStyle eXLS = (XLineStyle)((const XLineStyleItem&)GetMergedItem(XATTR_LINESTYLE)).GetValue();
+ return (eXLS != XLINE_NONE);
+}
+
+SdrObject* SdrObject::Clone() const
+{
+ SdrObject* pObj=SdrObjFactory::MakeNewObject(GetObjInventor(),GetObjIdentifier(),NULL);
+ if (pObj!=NULL) {
+ pObj->pModel=pModel;
+ pObj->pPage=pPage;
+ *pObj=*this;
+ }
+ return pObj;
+}
+
+void SdrObject::operator=(const SdrObject& rObj)
+{
+ if(mpProperties)
+ {
+ delete mpProperties;
+ mpProperties = 0L;
+ }
+
+ // #110094#
+ if(mpViewContact)
+ {
+ delete mpViewContact;
+ mpViewContact = 0L;
+ }
+
+ // The Clone() method uses the local copy constructor from the individual
+ // sdr::properties::BaseProperties class. Since the target class maybe for another
+ // draw object a SdrObject needs to be provided, as in the nromal constructor.
+ mpProperties = &rObj.GetProperties().Clone(*this);
+
+ pModel =rObj.pModel;
+ aOutRect=rObj.aOutRect;
+ mnLayerID = rObj.mnLayerID;
+ aAnchor =rObj.aAnchor;
+ bVirtObj=rObj.bVirtObj;
+ bSizProt=rObj.bSizProt;
+ bMovProt=rObj.bMovProt;
+ bNoPrint=rObj.bNoPrint;
+ mbVisible=rObj.mbVisible;
+ bMarkProt=rObj.bMarkProt;
+ //EmptyPresObj wird nicht kopiert: nun doch! (25-07-1995, Joe)
+ bEmptyPresObj =rObj.bEmptyPresObj;
+ //NotVisibleAsMaster wird nicht kopiert: nun doch! (25-07-1995, Joe)
+ bNotVisibleAsMaster=rObj.bNotVisibleAsMaster;
+ bSnapRectDirty=TRUE; //rObj.bSnapRectDirty;
+ bNotMasterCachable=rObj.bNotMasterCachable;
+ if (pPlusData!=NULL) { delete pPlusData; pPlusData=NULL; }
+ if (rObj.pPlusData!=NULL) {
+ pPlusData=rObj.pPlusData->Clone(this);
+ }
+ if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) {
+ delete pPlusData->pBroadcast; // der Broadcaster wird nicht mitkopiert
+ pPlusData->pBroadcast=NULL;
+ }
+}
+
+void SdrObject::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulNONE);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+void SdrObject::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralNONE);
+}
+
+void SdrObject::ImpTakeDescriptionStr(USHORT nStrCacheID, XubString& rStr, USHORT nVal) const
+{
+ rStr = ImpGetResStr(nStrCacheID);
+
+ sal_Char aSearchText1[] = "%1";
+ sal_Char aSearchText2[] = "%2";
+ xub_StrLen nPos = rStr.SearchAscii(aSearchText1);
+
+ if(nPos != STRING_NOTFOUND)
+ {
+ rStr.Erase(nPos, 2);
+
+ XubString aObjName;
+
+ TakeObjNameSingul(aObjName);
+ rStr.Insert(aObjName, nPos);
+ }
+
+ nPos = rStr.SearchAscii(aSearchText2);
+
+ if(nPos != STRING_NOTFOUND)
+ {
+ rStr.Erase(nPos, 2);
+ rStr.Insert(UniString::CreateFromInt32(nVal), nPos);
+ }
+}
+
+XubString SdrObject::GetWinkStr(long nWink, bool bNoDegChar) const
+{
+ XubString aStr;
+ if (pModel!=NULL) {
+ pModel->TakeWinkStr(nWink,aStr,bNoDegChar);
+ }
+ return aStr;
+}
+
+XubString SdrObject::GetMetrStr(long nVal, MapUnit /*eWantMap*/, bool bNoUnitChars) const
+{
+ XubString aStr;
+ if (pModel!=NULL) {
+ pModel->TakeMetricStr(nVal,aStr,bNoUnitChars);
+ }
+ return aStr;
+}
+
+basegfx::B2DPolyPolygon SdrObject::TakeXorPoly() const
+{
+ basegfx::B2DPolyPolygon aRetval;
+ const Rectangle aR(GetCurrentBoundRect());
+ const basegfx::B2DRange aRange(aR.Left(), aR.Top(), aR.Right(), aR.Bottom());
+ aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
+
+ return aRetval;
+}
+
+basegfx::B2DPolyPolygon SdrObject::TakeContour() const
+{
+ basegfx::B2DPolyPolygon aRetval;
+
+ // create cloned object without text, but with XLINE_SOLID,
+ // COL_BLACK as line color and XFILL_NONE
+ SdrObject* pClone = Clone();
+
+ if(pClone)
+ {
+ const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(this);
+
+ if(pTextObj)
+ {
+ // no text and no text animation
+ pClone->SetMergedItem(SdrTextAniKindItem(SDRTEXTANI_NONE));
+ pClone->SetOutlinerParaObject(0);
+ }
+
+ const SdrEdgeObj* pEdgeObj = dynamic_cast< const SdrEdgeObj* >(this);
+
+ if(pEdgeObj)
+ {
+ // create connections if connector, will be cleaned up when
+ // deleting the connector again
+ SdrObject* pLeft = pEdgeObj->GetConnectedNode(TRUE);
+ SdrObject* pRight = pEdgeObj->GetConnectedNode(FALSE);
+
+ if(pLeft)
+ {
+ pClone->ConnectToNode(TRUE, pLeft);
+ }
+
+ if(pRight)
+ {
+ pClone->ConnectToNode(FALSE, pRight);
+ }
+ }
+
+ SfxItemSet aNewSet(*GetObjectItemPool());
+
+ // #i101980# ignore LineWidth; that's what the old implementation
+ // did. With linewidth, the result may be huge due to fat/thick
+ // line decompositions
+ aNewSet.Put(XLineWidthItem(0));
+
+ // solid black lines and no fill
+ aNewSet.Put(XLineStyleItem(XLINE_SOLID));
+ aNewSet.Put(XLineColorItem(String(), Color(COL_BLACK)));
+ aNewSet.Put(XFillStyleItem(XFILL_NONE));
+ pClone->SetMergedItemSet(aNewSet);
+
+ // get sequence from clone
+ const sdr::contact::ViewContact& rVC(pClone->GetViewContact());
+ const drawinglayer::primitive2d::Primitive2DSequence xSequence(rVC.getViewIndependentPrimitive2DSequence());
+
+ if(xSequence.hasElements())
+ {
+ // use neutral ViewInformation
+ const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0);
+
+ // create extractor, process and get result
+ drawinglayer::processor2d::ContourExtractor2D aExtractor(aViewInformation2D);
+ aExtractor.process(xSequence);
+ const std::vector< basegfx::B2DPolyPolygon >& rResult(aExtractor.getExtractedContour());
+ const sal_uInt32 nSize(rResult.size());
+
+ // when count is one, it is implied that the object has only it's normal
+ // contour anyways and TakeCountour() is to return an empty PolyPolygon
+ // (see old implementation for historical reasons)
+ if(nSize > 1)
+ {
+ // the topology for contour is correctly a vector of PolyPolygons; for
+ // historical reasons cut it back to a single PolyPolygon here
+ for(sal_uInt32 a(0); a < nSize; a++)
+ {
+ aRetval.append(rResult[a]);
+ }
+ }
+ }
+
+ delete pClone;
+ }
+
+ return aRetval;
+}
+
+sal_uInt32 SdrObject::GetHdlCount() const
+{
+ return 8L;
+}
+
+SdrHdl* SdrObject::GetHdl(sal_uInt32 nHdlNum) const
+{
+ SdrHdl* pH=NULL;
+ const Rectangle& rR=GetSnapRect();
+ switch (nHdlNum) {
+ case 0: pH=new SdrHdl(rR.TopLeft(), HDL_UPLFT); break; // Oben links
+ case 1: pH=new SdrHdl(rR.TopCenter(), HDL_UPPER); break; // Oben
+ case 2: pH=new SdrHdl(rR.TopRight(), HDL_UPRGT); break; // Oben rechts
+ case 3: pH=new SdrHdl(rR.LeftCenter(), HDL_LEFT ); break; // Links
+ case 4: pH=new SdrHdl(rR.RightCenter(), HDL_RIGHT); break; // Rechts
+ case 5: pH=new SdrHdl(rR.BottomLeft(), HDL_LWLFT); break; // Unten links
+ case 6: pH=new SdrHdl(rR.BottomCenter(),HDL_LOWER); break; // Unten
+ case 7: pH=new SdrHdl(rR.BottomRight(), HDL_LWRGT); break; // Unten rechts
+ }
+ return pH;
+}
+
+sal_uInt32 SdrObject::GetPlusHdlCount(const SdrHdl& /*rHdl*/) const
+{
+ return 0L;
+}
+
+SdrHdl* SdrObject::GetPlusHdl(const SdrHdl& /*rHdl*/, sal_uInt32 /*nPlNum*/) const
+{
+ return 0L;
+}
+
+void SdrObject::AddToHdlList(SdrHdlList& rHdlList) const
+{
+ sal_uInt32 nAnz=GetHdlCount();
+ for (sal_uInt32 i=0L; i<nAnz; i++) {
+ SdrHdl* pHdl=GetHdl(i);
+ if (pHdl!=NULL) {
+ rHdlList.AddHdl(pHdl);
+ }
+ }
+}
+
+Rectangle SdrObject::ImpDragCalcRect(const SdrDragStat& rDrag) const
+{
+ Rectangle aTmpRect(GetSnapRect());
+ Rectangle aRect(aTmpRect);
+ const SdrHdl* pHdl=rDrag.GetHdl();
+ SdrHdlKind eHdl=pHdl==NULL ? HDL_MOVE : pHdl->GetKind();
+ bool bEcke=(eHdl==HDL_UPLFT || eHdl==HDL_UPRGT || eHdl==HDL_LWLFT || eHdl==HDL_LWRGT);
+ bool bOrtho=rDrag.GetView()!=NULL && rDrag.GetView()->IsOrtho();
+ bool bBigOrtho=bEcke && bOrtho && rDrag.GetView()->IsBigOrtho();
+ Point aPos(rDrag.GetNow());
+ bool bLft=(eHdl==HDL_UPLFT || eHdl==HDL_LEFT || eHdl==HDL_LWLFT);
+ bool bRgt=(eHdl==HDL_UPRGT || eHdl==HDL_RIGHT || eHdl==HDL_LWRGT);
+ bool bTop=(eHdl==HDL_UPRGT || eHdl==HDL_UPPER || eHdl==HDL_UPLFT);
+ bool bBtm=(eHdl==HDL_LWRGT || eHdl==HDL_LOWER || eHdl==HDL_LWLFT);
+ if (bLft) aTmpRect.Left() =aPos.X();
+ if (bRgt) aTmpRect.Right() =aPos.X();
+ if (bTop) aTmpRect.Top() =aPos.Y();
+ if (bBtm) aTmpRect.Bottom()=aPos.Y();
+ if (bOrtho) { // Ortho
+ long nWdt0=aRect.Right() -aRect.Left();
+ long nHgt0=aRect.Bottom()-aRect.Top();
+ long nXMul=aTmpRect.Right() -aTmpRect.Left();
+ long nYMul=aTmpRect.Bottom()-aTmpRect.Top();
+ long nXDiv=nWdt0;
+ long nYDiv=nHgt0;
+ bool bXNeg=(nXMul<0)!=(nXDiv<0);
+ bool bYNeg=(nYMul<0)!=(nYDiv<0);
+ nXMul=Abs(nXMul);
+ nYMul=Abs(nYMul);
+ nXDiv=Abs(nXDiv);
+ nYDiv=Abs(nYDiv);
+ Fraction aXFact(nXMul,nXDiv); // Fractions zum kuerzen
+ Fraction aYFact(nYMul,nYDiv); // und zum vergleichen
+ nXMul=aXFact.GetNumerator();
+ nYMul=aYFact.GetNumerator();
+ nXDiv=aXFact.GetDenominator();
+ nYDiv=aYFact.GetDenominator();
+ if (bEcke) { // Eckpunkthandles
+ bool bUseX=(aXFact<aYFact) != bBigOrtho;
+ if (bUseX) {
+ long nNeed=long(BigInt(nHgt0)*BigInt(nXMul)/BigInt(nXDiv));
+ if (bYNeg) nNeed=-nNeed;
+ if (bTop) aTmpRect.Top()=aTmpRect.Bottom()-nNeed;
+ if (bBtm) aTmpRect.Bottom()=aTmpRect.Top()+nNeed;
+ } else {
+ long nNeed=long(BigInt(nWdt0)*BigInt(nYMul)/BigInt(nYDiv));
+ if (bXNeg) nNeed=-nNeed;
+ if (bLft) aTmpRect.Left()=aTmpRect.Right()-nNeed;
+ if (bRgt) aTmpRect.Right()=aTmpRect.Left()+nNeed;
+ }
+ } else { // Scheitelpunkthandles
+ if ((bLft || bRgt) && nXDiv!=0) {
+ long nHgt0b=aRect.Bottom()-aRect.Top();
+ long nNeed=long(BigInt(nHgt0b)*BigInt(nXMul)/BigInt(nXDiv));
+ aTmpRect.Top()-=(nNeed-nHgt0b)/2;
+ aTmpRect.Bottom()=aTmpRect.Top()+nNeed;
+ }
+ if ((bTop || bBtm) && nYDiv!=0) {
+ long nWdt0b=aRect.Right()-aRect.Left();
+ long nNeed=long(BigInt(nWdt0b)*BigInt(nYMul)/BigInt(nYDiv));
+ aTmpRect.Left()-=(nNeed-nWdt0b)/2;
+ aTmpRect.Right()=aTmpRect.Left()+nNeed;
+ }
+ }
+ }
+ aTmpRect.Justify();
+ return aTmpRect;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrObject::hasSpecialDrag() const
+{
+ return false;
+}
+
+bool SdrObject::supportsFullDrag() const
+{
+ return true;
+}
+
+SdrObject* SdrObject::getFullDragClone() const
+{
+ // default uses simple clone
+ return Clone();
+}
+
+bool SdrObject::beginSpecialDrag(SdrDragStat& rDrag) const
+{
+ const SdrHdl* pHdl = rDrag.GetHdl();
+
+ SdrHdlKind eHdl = (pHdl == NULL) ? HDL_MOVE : pHdl->GetKind();
+
+ if(eHdl==HDL_UPLFT || eHdl==HDL_UPPER || eHdl==HDL_UPRGT ||
+ eHdl==HDL_LEFT || eHdl==HDL_RIGHT || eHdl==HDL_LWLFT ||
+ eHdl==HDL_LOWER || eHdl==HDL_LWRGT)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool SdrObject::applySpecialDrag(SdrDragStat& rDrag)
+{
+ Rectangle aNewRect(ImpDragCalcRect(rDrag));
+
+ if(aNewRect != GetSnapRect())
+ {
+ NbcSetSnapRect(aNewRect);
+ }
+
+ return true;
+}
+
+String SdrObject::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const
+{
+ return String();
+}
+
+basegfx::B2DPolyPolygon SdrObject::getSpecialDragPoly(const SdrDragStat& /*rDrag*/) const
+{
+ // default has nothing to add
+ return basegfx::B2DPolyPolygon();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Create
+bool SdrObject::BegCreate(SdrDragStat& rStat)
+{
+ rStat.SetOrtho4Possible();
+ Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
+ aRect1.Justify();
+ rStat.SetActionRect(aRect1);
+ aOutRect = aRect1;
+ return TRUE;
+}
+
+bool SdrObject::MovCreate(SdrDragStat& rStat)
+{
+ rStat.TakeCreateRect(aOutRect);
+ rStat.SetActionRect(aOutRect);
+ aOutRect.Justify();
+
+ // #i101648# for naked (non-derived) SdrObjects, do not invalidate aOutRect
+ // by calling SetBoundRectDirty(); aOutRect IS the geometry for such objects.
+ // No derivation implementation calls the parent implementation, so this will
+ // cause no further prolems
+ //
+ // SetBoundRectDirty();
+ // bSnapRectDirty=TRUE;
+
+ return TRUE;
+}
+
+bool SdrObject::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ rStat.TakeCreateRect(aOutRect);
+ aOutRect.Justify();
+
+ // #i101648# see description at MovCreate
+ //
+ // SetRectsDirty();
+
+ return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
+}
+
+void SdrObject::BrkCreate(SdrDragStat& /*rStat*/)
+{
+}
+
+bool SdrObject::BckCreate(SdrDragStat& /*rStat*/)
+{
+ return FALSE;
+}
+
+basegfx::B2DPolyPolygon SdrObject::TakeCreatePoly(const SdrDragStat& rDrag) const
+{
+ Rectangle aRect1;
+ rDrag.TakeCreateRect(aRect1);
+ aRect1.Justify();
+
+ basegfx::B2DPolyPolygon aRetval;
+ const basegfx::B2DRange aRange(aRect1.Left(), aRect1.Top(), aRect1.Right(), aRect1.Bottom());
+ aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
+ return aRetval;
+}
+
+Pointer SdrObject::GetCreatePointer() const
+{
+ return Pointer(POINTER_CROSS);
+}
+
+// Transformationen
+void SdrObject::NbcMove(const Size& rSiz)
+{
+ MoveRect(aOutRect,rSiz);
+ SetRectsDirty();
+}
+
+void SdrObject::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
+ bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
+ if (bXMirr || bYMirr) {
+ Point aRef1(GetSnapRect().Center());
+ if (bXMirr) {
+ Point aRef2(aRef1);
+ aRef2.Y()++;
+ NbcMirrorGluePoints(aRef1,aRef2);
+ }
+ if (bYMirr) {
+ Point aRef2(aRef1);
+ aRef2.X()++;
+ NbcMirrorGluePoints(aRef1,aRef2);
+ }
+ }
+ ResizeRect(aOutRect,rRef,xFact,yFact);
+ SetRectsDirty();
+}
+
+void SdrObject::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ SetGlueReallyAbsolute(TRUE);
+ aOutRect.Move(-rRef.X(),-rRef.Y());
+ Rectangle R(aOutRect);
+ if (sn==1.0 && cs==0.0) { // 90deg
+ aOutRect.Left() =-R.Bottom();
+ aOutRect.Right() =-R.Top();
+ aOutRect.Top() =R.Left();
+ aOutRect.Bottom()=R.Right();
+ } else if (sn==0.0 && cs==-1.0) { // 180deg
+ aOutRect.Left() =-R.Right();
+ aOutRect.Right() =-R.Left();
+ aOutRect.Top() =-R.Bottom();
+ aOutRect.Bottom()=-R.Top();
+ } else if (sn==-1.0 && cs==0.0) { // 270deg
+ aOutRect.Left() =R.Top();
+ aOutRect.Right() =R.Bottom();
+ aOutRect.Top() =-R.Right();
+ aOutRect.Bottom()=-R.Left();
+ }
+ aOutRect.Move(rRef.X(),rRef.Y());
+ aOutRect.Justify(); // Sicherheitshalber
+ SetRectsDirty();
+ NbcRotateGluePoints(rRef,nWink,sn,cs);
+ SetGlueReallyAbsolute(FALSE);
+}
+
+void SdrObject::NbcMirror(const Point& rRef1, const Point& rRef2)
+{
+ SetGlueReallyAbsolute(TRUE);
+ aOutRect.Move(-rRef1.X(),-rRef1.Y());
+ Rectangle R(aOutRect);
+ long dx=rRef2.X()-rRef1.X();
+ long dy=rRef2.Y()-rRef1.Y();
+ if (dx==0) { // Vertikale Achse
+ aOutRect.Left() =-R.Right();
+ aOutRect.Right()=-R.Left();
+ } else if (dy==0) { // Horizontale Achse
+ aOutRect.Top() =-R.Bottom();
+ aOutRect.Bottom()=-R.Top();
+ } else if (dx==dy) { /* 45 Grad Achse \ */
+ aOutRect.Left() =R.Top();
+ aOutRect.Right() =R.Bottom();
+ aOutRect.Top() =R.Left();
+ aOutRect.Bottom()=R.Right();
+ } else if (dx==-dy) { // 45 Grad Achse /
+ aOutRect.Left() =-R.Bottom();
+ aOutRect.Right() =-R.Top();
+ aOutRect.Top() =-R.Right();
+ aOutRect.Bottom()=-R.Left();
+ }
+ aOutRect.Move(rRef1.X(),rRef1.Y());
+ aOutRect.Justify(); // Sicherheitshalber
+ SetRectsDirty();
+ NbcMirrorGluePoints(rRef1,rRef2);
+ SetGlueReallyAbsolute(FALSE);
+}
+
+void SdrObject::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ SetGlueReallyAbsolute(TRUE);
+ NbcShearGluePoints(rRef,nWink,tn,bVShear);
+ SetGlueReallyAbsolute(FALSE);
+}
+
+void SdrObject::Move(const Size& rSiz)
+{
+ if (rSiz.Width()!=0 || rSiz.Height()!=0) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcMove(rSiz);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
+ }
+}
+
+void SdrObject::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcResize(rRef,xFact,yFact);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+void SdrObject::Rotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ if (nWink!=0) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcRotate(rRef,nWink,sn,cs);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+void SdrObject::Mirror(const Point& rRef1, const Point& rRef2)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcMirror(rRef1,rRef2);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+void SdrObject::Shear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ if (nWink!=0) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcShear(rRef,nWink,tn,bVShear);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+void SdrObject::NbcSetRelativePos(const Point& rPnt)
+{
+ Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
+ Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
+ NbcMove(aSiz); // Der ruft auch das SetRectsDirty()
+}
+
+void SdrObject::SetRelativePos(const Point& rPnt)
+{
+ if (rPnt!=GetRelativePos()) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetRelativePos(rPnt);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
+ }
+}
+
+Point SdrObject::GetRelativePos() const
+{
+ return GetSnapRect().TopLeft()-aAnchor;
+}
+
+void SdrObject::NbcSetAnchorPos(const Point& rPnt)
+{
+ Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
+ aAnchor=rPnt;
+ NbcMove(aSiz); // Der ruft auch das SetRectsDirty()
+}
+
+void SdrObject::SetAnchorPos(const Point& rPnt)
+{
+ if (rPnt!=aAnchor) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetAnchorPos(rPnt);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
+ }
+}
+
+const Point& SdrObject::GetAnchorPos() const
+{
+ return aAnchor;
+}
+
+void SdrObject::RecalcSnapRect()
+{
+}
+
+const Rectangle& SdrObject::GetSnapRect() const
+{
+ return aOutRect;
+}
+
+void SdrObject::NbcSetSnapRect(const Rectangle& rRect)
+{
+ aOutRect=rRect;
+}
+
+const Rectangle& SdrObject::GetLogicRect() const
+{
+ return GetSnapRect();
+}
+
+void SdrObject::NbcSetLogicRect(const Rectangle& rRect)
+{
+ NbcSetSnapRect(rRect);
+}
+
+void SdrObject::AdjustToMaxRect( const Rectangle& rMaxRect, bool /* bShrinkOnly = false */ )
+{
+ SetLogicRect( rMaxRect );
+}
+
+void SdrObject::SetSnapRect(const Rectangle& rRect)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetSnapRect(rRect);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+void SdrObject::SetLogicRect(const Rectangle& rRect)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetLogicRect(rRect);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+long SdrObject::GetRotateAngle() const
+{
+ return 0;
+}
+
+long SdrObject::GetShearAngle(bool /*bVertical*/) const
+{
+ return 0;
+}
+
+sal_uInt32 SdrObject::GetSnapPointCount() const
+{
+ return GetPointCount();
+}
+
+Point SdrObject::GetSnapPoint(sal_uInt32 i) const
+{
+ return GetPoint(i);
+}
+
+sal_Bool SdrObject::IsPolyObj() const
+{
+ return sal_False;
+}
+
+sal_uInt32 SdrObject::GetPointCount() const
+{
+ return 0L;
+}
+
+Point SdrObject::GetPoint(sal_uInt32 /*i*/) const
+{
+ return Point();
+}
+
+void SdrObject::SetPoint(const Point& rPnt, sal_uInt32 i)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetPoint(rPnt, i);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+void SdrObject::NbcSetPoint(const Point& /*rPnt*/, sal_uInt32 /*i*/)
+{
+}
+
+bool SdrObject::HasTextEdit() const
+{
+ return FALSE;
+}
+
+sal_Bool SdrObject::BegTextEdit(SdrOutliner& /*rOutl*/)
+{
+ return FALSE;
+}
+
+void SdrObject::EndTextEdit(SdrOutliner& /*rOutl*/)
+{
+}
+
+void SdrObject::SetOutlinerParaObject(OutlinerParaObject* pTextObject)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetOutlinerParaObject(pTextObject);
+ SetChanged();
+ BroadcastObjectChange();
+ if (GetCurrentBoundRect()!=aBoundRect0) {
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+void SdrObject::NbcSetOutlinerParaObject(OutlinerParaObject* /*pTextObject*/)
+{
+}
+
+OutlinerParaObject* SdrObject::GetOutlinerParaObject() const
+{
+ return NULL;
+}
+
+void SdrObject::NbcReformatText()
+{
+}
+
+void SdrObject::ReformatText()
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ NbcReformatText();
+ SetChanged();
+ BroadcastObjectChange();
+ if (GetCurrentBoundRect()!=aBoundRect0) {
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+void SdrObject::BurnInStyleSheetAttributes()
+{
+ GetProperties().ForceStyleToHardAttributes();
+}
+
+#define Imp2ndKennung (0x434F4D43)
+SdrObjUserData* SdrObject::ImpGetMacroUserData() const
+{
+ SdrObjUserData* pData=NULL;
+ USHORT nAnz=GetUserDataCount();
+ for (USHORT nNum=nAnz; nNum>0 && pData==NULL;) {
+ nNum--;
+ pData=GetUserData(nNum);
+ if (!pData->HasMacro(this)) pData=NULL;
+ }
+ return pData;
+}
+
+bool SdrObject::HasMacro() const
+{
+ SdrObjUserData* pData=ImpGetMacroUserData();
+ return pData!=NULL ? pData->HasMacro(this) : FALSE;
+}
+
+SdrObject* SdrObject::CheckMacroHit(const SdrObjMacroHitRec& rRec) const
+{
+ SdrObjUserData* pData = ImpGetMacroUserData();
+
+ if(pData)
+ {
+ return pData->CheckMacroHit(rRec, this);
+ }
+
+ if(rRec.pPageView)
+ {
+ return SdrObjectPrimitiveHit(*this, rRec.aPos, rRec.nTol, *rRec.pPageView, rRec.pVisiLayer, false);
+ }
+
+ return 0;
+}
+
+Pointer SdrObject::GetMacroPointer(const SdrObjMacroHitRec& rRec) const
+{
+ SdrObjUserData* pData=ImpGetMacroUserData();
+ if (pData!=NULL) {
+ return pData->GetMacroPointer(rRec,this);
+ }
+ return Pointer(POINTER_REFHAND);
+}
+
+void SdrObject::PaintMacro(OutputDevice& rOut, const Rectangle& rDirtyRect, const SdrObjMacroHitRec& rRec) const
+{
+ SdrObjUserData* pData=ImpGetMacroUserData();
+
+ if(pData)
+ {
+ pData->PaintMacro(rOut,rDirtyRect,rRec,this);
+ }
+ else
+ {
+ const RasterOp eRop(rOut.GetRasterOp());
+ const basegfx::B2DPolyPolygon aPolyPolygon(TakeXorPoly());
+ const sal_uInt32 nCount(aPolyPolygon.count());
+
+ rOut.SetLineColor(COL_BLACK);
+ rOut.SetFillColor();
+ rOut.SetRasterOp(ROP_INVERT);
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ rOut.DrawPolyLine(aPolyPolygon.getB2DPolygon(a));
+ }
+
+ rOut.SetRasterOp(eRop);
+ }
+}
+
+bool SdrObject::DoMacro(const SdrObjMacroHitRec& rRec)
+{
+ SdrObjUserData* pData=ImpGetMacroUserData();
+ if (pData!=NULL) {
+ return pData->DoMacro(rRec,this);
+ }
+ return FALSE;
+}
+
+XubString SdrObject::GetMacroPopupComment(const SdrObjMacroHitRec& rRec) const
+{
+ SdrObjUserData* pData=ImpGetMacroUserData();
+ if (pData!=NULL) {
+ return pData->GetMacroPopupComment(rRec,this);
+ }
+ return String();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrObjGeoData* SdrObject::NewGeoData() const
+{
+ return new SdrObjGeoData;
+}
+
+void SdrObject::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ rGeo.aBoundRect =GetCurrentBoundRect();
+ rGeo.aAnchor =aAnchor ;
+ rGeo.bMovProt =bMovProt ;
+ rGeo.bSizProt =bSizProt ;
+ rGeo.bNoPrint =bNoPrint ;
+ rGeo.mbVisible =mbVisible ;
+ rGeo.bClosedObj =bClosedObj ;
+ rGeo.mnLayerID = mnLayerID;
+
+ // Benutzerdefinierte Klebepunkte
+ if (pPlusData!=NULL && pPlusData->pGluePoints!=NULL) {
+ if (rGeo.pGPL!=NULL) {
+ *rGeo.pGPL=*pPlusData->pGluePoints;
+ } else {
+ rGeo.pGPL=new SdrGluePointList(*pPlusData->pGluePoints);
+ }
+ } else {
+ if (rGeo.pGPL!=NULL) {
+ delete rGeo.pGPL;
+ rGeo.pGPL=NULL;
+ }
+ }
+}
+
+void SdrObject::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ SetRectsDirty();
+ aOutRect =rGeo.aBoundRect ;
+ aAnchor =rGeo.aAnchor ;
+ bMovProt =rGeo.bMovProt ;
+ bSizProt =rGeo.bSizProt ;
+ bNoPrint =rGeo.bNoPrint ;
+ mbVisible =rGeo.mbVisible ;
+ bClosedObj =rGeo.bClosedObj ;
+ mnLayerID = rGeo.mnLayerID;
+
+ // Benutzerdefinierte Klebepunkte
+ if (rGeo.pGPL!=NULL) {
+ ImpForcePlusData();
+ if (pPlusData->pGluePoints!=NULL) {
+ *pPlusData->pGluePoints=*rGeo.pGPL;
+ } else {
+ pPlusData->pGluePoints=new SdrGluePointList(*rGeo.pGPL);
+ }
+ } else {
+ if (pPlusData!=NULL && pPlusData->pGluePoints!=NULL) {
+ delete pPlusData->pGluePoints;
+ pPlusData->pGluePoints=NULL;
+ }
+ }
+}
+
+SdrObjGeoData* SdrObject::GetGeoData() const
+{
+ SdrObjGeoData* pGeo=NewGeoData();
+ SaveGeoData(*pGeo);
+ return pGeo;
+}
+
+void SdrObject::SetGeoData(const SdrObjGeoData& rGeo)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ RestGeoData(rGeo);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// ItemSet access
+
+const SfxItemSet& SdrObject::GetObjectItemSet() const
+{
+ return GetProperties().GetObjectItemSet();
+}
+
+const SfxItemSet& SdrObject::GetMergedItemSet() const
+{
+ return GetProperties().GetMergedItemSet();
+}
+
+void SdrObject::SetObjectItem(const SfxPoolItem& rItem)
+{
+ GetProperties().SetObjectItem(rItem);
+}
+
+void SdrObject::SetMergedItem(const SfxPoolItem& rItem)
+{
+ GetProperties().SetMergedItem(rItem);
+}
+
+void SdrObject::ClearObjectItem(const sal_uInt16 nWhich)
+{
+ GetProperties().ClearObjectItem(nWhich);
+}
+
+void SdrObject::ClearMergedItem(const sal_uInt16 nWhich)
+{
+ GetProperties().ClearMergedItem(nWhich);
+}
+
+void SdrObject::SetObjectItemSet(const SfxItemSet& rSet)
+{
+ GetProperties().SetObjectItemSet(rSet);
+}
+
+void SdrObject::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems)
+{
+ GetProperties().SetMergedItemSet(rSet, bClearAllItems);
+}
+
+const SfxPoolItem& SdrObject::GetObjectItem(const sal_uInt16 nWhich) const
+{
+ return GetObjectItemSet().Get(nWhich);
+}
+
+const SfxPoolItem& SdrObject::GetMergedItem(const sal_uInt16 nWhich) const
+{
+ return GetMergedItemSet().Get(nWhich);
+}
+
+void SdrObject::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems)
+{
+ GetProperties().SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
+}
+
+void SdrObject::ApplyNotPersistAttr(const SfxItemSet& rAttr)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ NbcApplyNotPersistAttr(rAttr);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+void SdrObject::NbcApplyNotPersistAttr(const SfxItemSet& rAttr)
+{
+ const Rectangle& rSnap=GetSnapRect();
+ const Rectangle& rLogic=GetLogicRect();
+ Point aRef1(rSnap.Center());
+ Point aRef2(aRef1); aRef2.Y()++;
+ const SfxPoolItem *pPoolItem=NULL;
+ if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1X,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ aRef1.X()=((const SdrTransformRef1XItem*)pPoolItem)->GetValue();
+ }
+ if (rAttr.GetItemState(SDRATTR_TRANSFORMREF1Y,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ aRef1.Y()=((const SdrTransformRef1YItem*)pPoolItem)->GetValue();
+ }
+ if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2X,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ aRef2.X()=((const SdrTransformRef2XItem*)pPoolItem)->GetValue();
+ }
+ if (rAttr.GetItemState(SDRATTR_TRANSFORMREF2Y,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ aRef2.Y()=((const SdrTransformRef2YItem*)pPoolItem)->GetValue();
+ }
+
+ Rectangle aNewSnap(rSnap);
+ if (rAttr.GetItemState(SDRATTR_MOVEX,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrMoveXItem*)pPoolItem)->GetValue();
+ aNewSnap.Move(n,0);
+ }
+ if (rAttr.GetItemState(SDRATTR_MOVEY,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrMoveYItem*)pPoolItem)->GetValue();
+ aNewSnap.Move(0,n);
+ }
+ if (rAttr.GetItemState(SDRATTR_ONEPOSITIONX,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrOnePositionXItem*)pPoolItem)->GetValue();
+ aNewSnap.Move(n-aNewSnap.Left(),0);
+ }
+ if (rAttr.GetItemState(SDRATTR_ONEPOSITIONY,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrOnePositionYItem*)pPoolItem)->GetValue();
+ aNewSnap.Move(0,n-aNewSnap.Top());
+ }
+ if (rAttr.GetItemState(SDRATTR_ONESIZEWIDTH,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrOneSizeWidthItem*)pPoolItem)->GetValue();
+ aNewSnap.Right()=aNewSnap.Left()+n;
+ }
+ if (rAttr.GetItemState(SDRATTR_ONESIZEHEIGHT,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrOneSizeHeightItem*)pPoolItem)->GetValue();
+ aNewSnap.Bottom()=aNewSnap.Top()+n;
+ }
+ if (aNewSnap!=rSnap) {
+ if (aNewSnap.GetSize()==rSnap.GetSize()) {
+ NbcMove(Size(aNewSnap.Left()-rSnap.Left(),aNewSnap.Top()-rSnap.Top()));
+ } else {
+ NbcSetSnapRect(aNewSnap);
+ }
+ }
+
+ if (rAttr.GetItemState(SDRATTR_SHEARANGLE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrShearAngleItem*)pPoolItem)->GetValue();
+ n-=GetShearAngle();
+ if (n!=0) {
+ double nTan=tan(n*nPi180);
+ NbcShear(aRef1,n,nTan,FALSE);
+ }
+ }
+ if (rAttr.GetItemState(SDRATTR_ROTATEANGLE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrRotateAngleItem*)pPoolItem)->GetValue();
+ n-=GetRotateAngle();
+ if (n!=0) {
+ double nSin=sin(n*nPi180);
+ double nCos=cos(n*nPi180);
+ NbcRotate(aRef1,n,nSin,nCos);
+ }
+ }
+ if (rAttr.GetItemState(SDRATTR_ROTATEONE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrRotateOneItem*)pPoolItem)->GetValue();
+ double nSin=sin(n*nPi180);
+ double nCos=cos(n*nPi180);
+ NbcRotate(aRef1,n,nSin,nCos);
+ }
+ if (rAttr.GetItemState(SDRATTR_HORZSHEARONE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrHorzShearOneItem*)pPoolItem)->GetValue();
+ double nTan=tan(n*nPi180);
+ NbcShear(aRef1,n,nTan,FALSE);
+ }
+ if (rAttr.GetItemState(SDRATTR_VERTSHEARONE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrVertShearOneItem*)pPoolItem)->GetValue();
+ double nTan=tan(n*nPi180);
+ NbcShear(aRef1,n,nTan,TRUE);
+ }
+
+ if (rAttr.GetItemState(SDRATTR_OBJMOVEPROTECT,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ bool b=((const SdrObjMoveProtectItem*)pPoolItem)->GetValue();
+ SetMoveProtect(b);
+ }
+ if (rAttr.GetItemState(SDRATTR_OBJSIZEPROTECT,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ bool b=((const SdrObjSizeProtectItem*)pPoolItem)->GetValue();
+ SetResizeProtect(b);
+ }
+
+ /* #67368# move protect always sets size protect */
+ if( IsMoveProtect() )
+ SetResizeProtect( true );
+
+ if (rAttr.GetItemState(SDRATTR_OBJPRINTABLE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ bool b=((const SdrObjPrintableItem*)pPoolItem)->GetValue();
+ SetPrintable(b);
+ }
+
+ if (rAttr.GetItemState(SDRATTR_OBJVISIBLE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ bool b=((const SdrObjVisibleItem*)pPoolItem)->GetValue();
+ SetVisible(b);
+ }
+
+ SdrLayerID nLayer=SDRLAYER_NOTFOUND;
+ if (rAttr.GetItemState(SDRATTR_LAYERID,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ nLayer=((const SdrLayerIdItem*)pPoolItem)->GetValue();
+ }
+ if (rAttr.GetItemState(SDRATTR_LAYERNAME,TRUE,&pPoolItem)==SFX_ITEM_SET && pModel!=NULL) {
+ XubString aLayerName=((const SdrLayerNameItem*)pPoolItem)->GetValue();
+ const SdrLayerAdmin* pLayAd=pPage!=NULL ? &pPage->GetLayerAdmin() : pModel!=NULL ? &pModel->GetLayerAdmin() : NULL;
+ if (pLayAd!=NULL) {
+ const SdrLayer* pLayer=pLayAd->GetLayer(aLayerName, TRUE);
+ if (pLayer!=NULL) {
+ nLayer=pLayer->GetID();
+ }
+ }
+
+ }
+ if (nLayer!=SDRLAYER_NOTFOUND) {
+ NbcSetLayer(nLayer);
+ }
+
+ if (rAttr.GetItemState(SDRATTR_OBJECTNAME,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ XubString aName=((const SdrObjectNameItem*)pPoolItem)->GetValue();
+ SetName(aName);
+ }
+ Rectangle aNewLogic(rLogic);
+ if (rAttr.GetItemState(SDRATTR_LOGICSIZEWIDTH,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrLogicSizeWidthItem*)pPoolItem)->GetValue();
+ aNewLogic.Right()=aNewLogic.Left()+n;
+ }
+ if (rAttr.GetItemState(SDRATTR_LOGICSIZEHEIGHT,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ long n=((const SdrLogicSizeHeightItem*)pPoolItem)->GetValue();
+ aNewLogic.Bottom()=aNewLogic.Top()+n;
+ }
+ if (aNewLogic!=rLogic) {
+ NbcSetLogicRect(aNewLogic);
+ }
+ Fraction aResizeX(1,1);
+ Fraction aResizeY(1,1);
+ if (rAttr.GetItemState(SDRATTR_RESIZEXONE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ aResizeX*=((const SdrResizeXOneItem*)pPoolItem)->GetValue();
+ }
+ if (rAttr.GetItemState(SDRATTR_RESIZEYONE,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ aResizeY*=((const SdrResizeYOneItem*)pPoolItem)->GetValue();
+ }
+ if (aResizeX!=Fraction(1,1) || aResizeY!=Fraction(1,1)) {
+ NbcResize(aRef1,aResizeX,aResizeY);
+ }
+}
+
+void lcl_SetItem(SfxItemSet& rAttr, bool bMerge, const SfxPoolItem& rItem)
+{
+ if (bMerge) rAttr.MergeValue(rItem,TRUE);
+ else rAttr.Put(rItem);
+}
+
+void SdrObject::TakeNotPersistAttr(SfxItemSet& rAttr, bool bMerge) const
+{
+ const Rectangle& rSnap=GetSnapRect();
+ const Rectangle& rLogic=GetLogicRect();
+ lcl_SetItem(rAttr,bMerge,SdrObjMoveProtectItem(IsMoveProtect()));
+ lcl_SetItem(rAttr,bMerge,SdrObjSizeProtectItem(IsResizeProtect()));
+ lcl_SetItem(rAttr,bMerge,SdrObjPrintableItem(IsPrintable()));
+ lcl_SetItem(rAttr,bMerge,SdrObjVisibleItem(IsVisible()));
+ lcl_SetItem(rAttr,bMerge,SdrRotateAngleItem(GetRotateAngle()));
+ lcl_SetItem(rAttr,bMerge,SdrShearAngleItem(GetShearAngle()));
+ lcl_SetItem(rAttr,bMerge,SdrOneSizeWidthItem(rSnap.GetWidth()-1));
+ lcl_SetItem(rAttr,bMerge,SdrOneSizeHeightItem(rSnap.GetHeight()-1));
+ lcl_SetItem(rAttr,bMerge,SdrOnePositionXItem(rSnap.Left()));
+ lcl_SetItem(rAttr,bMerge,SdrOnePositionYItem(rSnap.Top()));
+ if (rLogic.GetWidth()!=rSnap.GetWidth()) {
+ lcl_SetItem(rAttr,bMerge,SdrLogicSizeWidthItem(rLogic.GetWidth()-1));
+ }
+ if (rLogic.GetHeight()!=rSnap.GetHeight()) {
+ lcl_SetItem(rAttr,bMerge,SdrLogicSizeHeightItem(rLogic.GetHeight()-1));
+ }
+ XubString aName(GetName());
+
+ if(aName.Len())
+ {
+ lcl_SetItem(rAttr, bMerge, SdrObjectNameItem(aName));
+ }
+
+ lcl_SetItem(rAttr,bMerge,SdrLayerIdItem(GetLayer()));
+ const SdrLayerAdmin* pLayAd=pPage!=NULL ? &pPage->GetLayerAdmin() : pModel!=NULL ? &pModel->GetLayerAdmin() : NULL;
+ if (pLayAd!=NULL) {
+ const SdrLayer* pLayer=pLayAd->GetLayerPerID(GetLayer());
+ if (pLayer!=NULL) {
+ lcl_SetItem(rAttr,bMerge,SdrLayerNameItem(pLayer->GetName()));
+ }
+ }
+ Point aRef1(rSnap.Center());
+ Point aRef2(aRef1); aRef2.Y()++;
+ lcl_SetItem(rAttr,bMerge,SdrTransformRef1XItem(aRef1.X()));
+ lcl_SetItem(rAttr,bMerge,SdrTransformRef1YItem(aRef1.Y()));
+ lcl_SetItem(rAttr,bMerge,SdrTransformRef2XItem(aRef2.X()));
+ lcl_SetItem(rAttr,bMerge,SdrTransformRef2YItem(aRef2.Y()));
+}
+
+SfxStyleSheet* SdrObject::GetStyleSheet() const
+{
+ return GetProperties().GetStyleSheet();
+}
+
+void SdrObject::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+{
+ Rectangle aBoundRect0;
+
+ if(pUserCall)
+ aBoundRect0 = GetLastBoundRect();
+
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_CHGATTR, aBoundRect0);
+}
+
+void SdrObject::NbcSetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+{
+ // only allow graphic and presentation styles for shapes
+ if( pNewStyleSheet && (pNewStyleSheet->GetFamily() == SFX_STYLE_FAMILY_PARA) && (pNewStyleSheet->GetFamily() == SFX_STYLE_FAMILY_PAGE) )
+ return;
+
+ GetProperties().SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
+}
+
+// Das Broadcasting beim Setzen der Attribute wird vom AttrObj gemanagt
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrObject::IsNode() const
+{
+ return true;
+}
+
+SdrGluePoint SdrObject::GetVertexGluePoint(USHORT nPosNum) const
+{
+ // #i41936# Use SnapRect for default GluePoints
+ const Rectangle aR(GetSnapRect());
+ Point aPt;
+
+ switch(nPosNum)
+ {
+ case 0 : aPt = aR.TopCenter(); break;
+ case 1 : aPt = aR.RightCenter(); break;
+ case 2 : aPt = aR.BottomCenter(); break;
+ case 3 : aPt = aR.LeftCenter(); break;
+ }
+
+ aPt -= aR.Center();
+ SdrGluePoint aGP(aPt);
+ aGP.SetPercent(FALSE);
+
+ return aGP;
+}
+
+SdrGluePoint SdrObject::GetCornerGluePoint(USHORT nPosNum) const
+{
+ Rectangle aR(GetCurrentBoundRect());
+ Point aPt;
+ switch (nPosNum) {
+ case 0 : aPt=aR.TopLeft(); break;
+ case 1 : aPt=aR.TopRight(); break;
+ case 2 : aPt=aR.BottomRight(); break;
+ case 3 : aPt=aR.BottomLeft(); break;
+ }
+ aPt-=GetSnapRect().Center();
+ SdrGluePoint aGP(aPt);
+ aGP.SetPercent(FALSE);
+ return aGP;
+}
+
+const SdrGluePointList* SdrObject::GetGluePointList() const
+{
+ if (pPlusData!=NULL) return pPlusData->pGluePoints;
+ return NULL;
+}
+
+//SdrGluePointList* SdrObject::GetGluePointList()
+//{
+// if (pPlusData!=NULL) return pPlusData->pGluePoints;
+// return NULL;
+//}
+
+SdrGluePointList* SdrObject::ForceGluePointList()
+{
+ ImpForcePlusData();
+ if (pPlusData->pGluePoints==NULL) {
+ pPlusData->pGluePoints=new SdrGluePointList;
+ }
+ return pPlusData->pGluePoints;
+}
+
+void SdrObject::SetGlueReallyAbsolute(bool bOn)
+{
+ // erst Const-Aufruf um zu sehen, ob
+ // ueberhaupt Klebepunkte da sind
+ // const-Aufruf erzwingen!
+ if (GetGluePointList()!=NULL) {
+ SdrGluePointList* pGPL=ForceGluePointList();
+ pGPL->SetReallyAbsolute(bOn,*this);
+ }
+}
+
+void SdrObject::NbcRotateGluePoints(const Point& rRef, long nWink, double sn, double cs)
+{
+ // erst Const-Aufruf um zu sehen, ob
+ // ueberhaupt Klebepunkte da sind
+ // const-Aufruf erzwingen!
+ if (GetGluePointList()!=NULL) {
+ SdrGluePointList* pGPL=ForceGluePointList();
+ pGPL->Rotate(rRef,nWink,sn,cs,this);
+ }
+}
+
+void SdrObject::NbcMirrorGluePoints(const Point& rRef1, const Point& rRef2)
+{
+ // erst Const-Aufruf um zu sehen, ob
+ // ueberhaupt Klebepunkte da sind
+ // const-Aufruf erzwingen!
+ if (GetGluePointList()!=NULL) {
+ SdrGluePointList* pGPL=ForceGluePointList();
+ pGPL->Mirror(rRef1,rRef2,this);
+ }
+}
+
+void SdrObject::NbcShearGluePoints(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ // erst Const-Aufruf um zu sehen, ob
+ // ueberhaupt Klebepunkte da sind
+ // const-Aufruf erzwingen!
+ if (GetGluePointList()!=NULL) {
+ SdrGluePointList* pGPL=ForceGluePointList();
+ pGPL->Shear(rRef,nWink,tn,bVShear,this);
+ }
+}
+
+bool SdrObject::IsEdge() const
+{
+ return false;
+}
+
+void SdrObject::ConnectToNode(bool /*bTail1*/, SdrObject* /*pObj*/)
+{
+}
+
+void SdrObject::DisconnectFromNode(bool /*bTail1*/)
+{
+}
+
+SdrObject* SdrObject::GetConnectedNode(bool /*bTail1*/) const
+{
+ return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrObject* SdrObject::ImpConvertToContourObj(SdrObject* pRet, BOOL bForceLineDash) const
+{
+ bool bNoChange(true);
+
+ if(pRet->LineGeometryUsageIsNecessary())
+ {
+ basegfx::B2DPolyPolygon aMergedLineFillPolyPolygon;
+ basegfx::B2DPolyPolygon aMergedHairlinePolyPolygon;
+ const drawinglayer::primitive2d::Primitive2DSequence xSequence(pRet->GetViewContact().getViewIndependentPrimitive2DSequence());
+
+ if(xSequence.hasElements())
+ {
+ // use neutral ViewInformation
+ const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0);
+
+ // create extractor, process and get result
+ drawinglayer::processor2d::LineGeometryExtractor2D aExtractor(aViewInformation2D);
+ aExtractor.process(xSequence);
+
+ // #i102241# check for line results
+ const std::vector< basegfx::B2DPolygon >& rHairlineVector = aExtractor.getExtractedHairlines();
+
+ if(rHairlineVector.size())
+ {
+ // for SdrObject creation, just copy all to a single Hairline-PolyPolygon
+ for(sal_uInt32 a(0); a < rHairlineVector.size(); a++)
+ {
+ aMergedHairlinePolyPolygon.append(rHairlineVector[a]);
+ }
+ }
+
+ // #i102241# check for fill rsults
+ const std::vector< basegfx::B2DPolyPolygon >& rLineFillVector(aExtractor.getExtractedLineFills());
+
+ if(rLineFillVector.size())
+ {
+ // merge to a single PolyPolygon (OR)
+ aMergedLineFillPolyPolygon = basegfx::tools::mergeToSinglePolyPolygon(rLineFillVector);
+ }
+ }
+
+ // || aMergedHairlinePolyPolygon.Count() removed; the conversion is ONLY
+ // useful when new closed filled polygons are created
+ if(aMergedLineFillPolyPolygon.count() || (bForceLineDash && aMergedHairlinePolyPolygon.count()))
+ {
+ SfxItemSet aSet(pRet->GetMergedItemSet());
+ XFillStyle eOldFillStyle = ((const XFillStyleItem&)(aSet.Get(XATTR_FILLSTYLE))).GetValue();
+ SdrPathObj* aLinePolygonPart = NULL;
+ SdrPathObj* aLineHairlinePart = NULL;
+ bool bBuildGroup(false);
+
+ if(aMergedLineFillPolyPolygon.count())
+ {
+ // create SdrObject for filled line geometry
+ aLinePolygonPart = new SdrPathObj(OBJ_PATHFILL, aMergedLineFillPolyPolygon);
+ aLinePolygonPart->SetModel(pRet->GetModel());
+
+ // correct item properties
+ aSet.Put(XLineWidthItem(0L));
+ aSet.Put(XLineStyleItem(XLINE_NONE));
+ Color aColorLine = ((const XLineColorItem&)(aSet.Get(XATTR_LINECOLOR))).GetColorValue();
+ UINT16 nTransLine = ((const XLineTransparenceItem&)(aSet.Get(XATTR_LINETRANSPARENCE))).GetValue();
+ aSet.Put(XFillColorItem(XubString(), aColorLine));
+ aSet.Put(XFillStyleItem(XFILL_SOLID));
+ aSet.Put(XFillTransparenceItem(nTransLine));
+
+ aLinePolygonPart->SetMergedItemSet(aSet);
+ }
+
+ if(aMergedHairlinePolyPolygon.count())
+ {
+ // create SdrObject for hairline geometry
+ // OBJ_PATHLINE is necessary here, not OBJ_PATHFILL. This is intended
+ // to get a non-filled object. If the poly is closed, the PathObj takes care for
+ // the correct closed state.
+ aLineHairlinePart = new SdrPathObj(OBJ_PATHLINE, aMergedHairlinePolyPolygon);
+ aLineHairlinePart->SetModel(pRet->GetModel());
+
+ aSet.Put(XLineWidthItem(0L));
+ aSet.Put(XFillStyleItem(XFILL_NONE));
+ aSet.Put(XLineStyleItem(XLINE_SOLID));
+
+ // it is also necessary to switch off line start and ends here
+ aSet.Put(XLineStartWidthItem(0));
+ aSet.Put(XLineEndWidthItem(0));
+
+ aLineHairlinePart->SetMergedItemSet(aSet);
+
+ if(aLinePolygonPart)
+ {
+ bBuildGroup = true;
+ }
+ }
+
+ // check if original geometry should be added (e.g. filled and closed)
+ bool bAddOriginalGeometry(false);
+ SdrPathObj* pPath = PTR_CAST(SdrPathObj, pRet);
+
+ if(pPath && pPath->IsClosed())
+ {
+ if(eOldFillStyle != XFILL_NONE)
+ {
+ // #107600# use new boolean here
+ bAddOriginalGeometry = true;
+ }
+ }
+
+ // do we need a group?
+ if(bBuildGroup || bAddOriginalGeometry)
+ {
+ SdrObject* pGroup = new SdrObjGroup;
+ pGroup->SetModel(pRet->GetModel());
+
+ if(bAddOriginalGeometry)
+ {
+ // Add a clone of the original geometry.
+ aSet.ClearItem();
+ aSet.Put(pRet->GetMergedItemSet());
+ aSet.Put(XLineStyleItem(XLINE_NONE));
+ aSet.Put(XLineWidthItem(0L));
+
+ SdrObject* pClone = pRet->Clone();
+
+ pClone->SetModel(pRet->GetModel());
+ pClone->SetMergedItemSet(aSet);
+
+ pGroup->GetSubList()->NbcInsertObject(pClone);
+ }
+
+ if(aLinePolygonPart)
+ {
+ pGroup->GetSubList()->NbcInsertObject(aLinePolygonPart);
+ }
+
+ if(aLineHairlinePart)
+ {
+ pGroup->GetSubList()->NbcInsertObject(aLineHairlinePart);
+ }
+
+ pRet = pGroup;
+
+ // be more careful with the state describing bool
+ bNoChange = false;
+ }
+ else
+ {
+ if(aLinePolygonPart)
+ {
+ pRet = aLinePolygonPart;
+ // be more careful with the state describing bool
+ bNoChange = false;
+ }
+ else if(aLineHairlinePart)
+ {
+ pRet = aLineHairlinePart;
+ // be more careful with the state describing bool
+ bNoChange = false;
+ }
+ }
+ }
+ }
+
+ if(bNoChange)
+ {
+ // due to current method usage, create and return a clone when nothing has changed
+ SdrObject* pClone = pRet->Clone();
+ pClone->SetModel(pRet->GetModel());
+ pRet = pClone;
+ }
+
+ return pRet;
+}
+
+// convert this path object to contour object, even when it is a group
+SdrObject* SdrObject::ConvertToContourObj(SdrObject* pRet, BOOL bForceLineDash) const
+{
+ if(pRet->ISA(SdrObjGroup))
+ {
+ SdrObjList* pObjList2 = pRet->GetSubList();
+ SdrObject* pGroup = new SdrObjGroup;
+ pGroup->SetModel(pRet->GetModel());
+
+ for(UINT32 a=0;a<pObjList2->GetObjCount();a++)
+ {
+ SdrObject* pIterObj = pObjList2->GetObj(a);
+ pGroup->GetSubList()->NbcInsertObject(ConvertToContourObj(pIterObj, bForceLineDash));
+ }
+
+ pRet = pGroup;
+ }
+ else
+ {
+ if(pRet && pRet->ISA(SdrPathObj))
+ {
+ SdrPathObj* pPathObj = (SdrPathObj*)pRet;
+
+ // bezier geometry got created, even for straight edges since the given
+ // object is a result of DoConvertToPolyObj. For conversion to contour
+ // this is not really needed and can be reduced again AFAP
+ pPathObj->SetPathPoly(basegfx::tools::simplifyCurveSegments(pPathObj->GetPathPoly()));
+ }
+
+ pRet = ImpConvertToContourObj(pRet, bForceLineDash);
+ }
+
+ // #i73441# preserve LayerID
+ if(pRet && pRet->GetLayer() != GetLayer())
+ {
+ pRet->SetLayer(GetLayer());
+ }
+
+ return pRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrObject* SdrObject::ConvertToPolyObj(BOOL bBezier, BOOL bLineToArea) const
+{
+ SdrObject* pRet = DoConvertToPolyObj(bBezier);
+
+ if(pRet && bLineToArea)
+ {
+ SdrObject* pNewRet = ConvertToContourObj(pRet);
+ delete pRet;
+ pRet = pNewRet;
+ }
+
+ // #i73441# preserve LayerID
+ if(pRet && pRet->GetLayer() != GetLayer())
+ {
+ pRet->SetLayer(GetLayer());
+ }
+
+ return pRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrObject* SdrObject::DoConvertToPolyObj(BOOL /*bBezier*/) const
+{
+ return NULL;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrObject::SetInserted(sal_Bool bIns)
+{
+ if (bIns!=IsInserted()) {
+ bInserted=bIns;
+ Rectangle aBoundRect0(GetLastBoundRect());
+ if (bIns) SendUserCall(SDRUSERCALL_INSERTED,aBoundRect0);
+ else SendUserCall(SDRUSERCALL_REMOVED,aBoundRect0);
+
+ if (pPlusData!=NULL && pPlusData->pBroadcast!=NULL) { // #42522#
+ SdrHint aHint(*this);
+ aHint.SetKind(bIns?HINT_OBJINSERTED:HINT_OBJREMOVED);
+ pPlusData->pBroadcast->Broadcast(aHint);
+ }
+ }
+}
+
+void SdrObject::SetMoveProtect(sal_Bool bProt)
+{
+ if(IsMoveProtect() != bProt)
+ {
+ // #i77187# secured and simplified
+ bMovProt = bProt;
+ SetChanged();
+ BroadcastObjectChange();
+ }
+}
+
+void SdrObject::SetResizeProtect(sal_Bool bProt)
+{
+ if(IsResizeProtect() != bProt)
+ {
+ // #i77187# secured and simplified
+ bSizProt = bProt;
+ SetChanged();
+ BroadcastObjectChange();
+ }
+}
+
+void SdrObject::SetPrintable(sal_Bool bPrn)
+{
+ if( bPrn == bNoPrint )
+ {
+ bNoPrint=!bPrn;
+ SetChanged();
+ if (IsInserted() && pModel!=NULL)
+ {
+ SdrHint aHint(*this);
+ pModel->Broadcast(aHint);
+ }
+ }
+}
+
+void SdrObject::SetVisible(sal_Bool bVisible)
+{
+ if( bVisible != mbVisible )
+ {
+ mbVisible = bVisible;
+ SetChanged();
+ if (IsInserted() && pModel!=NULL)
+ {
+ SdrHint aHint(*this);
+ pModel->Broadcast(aHint);
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+USHORT SdrObject::GetUserDataCount() const
+{
+ if (pPlusData==NULL || pPlusData->pUserDataList==NULL) return 0;
+ return pPlusData->pUserDataList->GetUserDataCount();
+}
+
+SdrObjUserData* SdrObject::GetUserData(USHORT nNum) const
+{
+ if (pPlusData==NULL || pPlusData->pUserDataList==NULL) return NULL;
+ return pPlusData->pUserDataList->GetUserData(nNum);
+}
+
+void SdrObject::InsertUserData(SdrObjUserData* pData, USHORT nPos)
+{
+ if (pData!=NULL) {
+ ImpForcePlusData();
+ if (pPlusData->pUserDataList==NULL) pPlusData->pUserDataList=new SdrObjUserDataList;
+ pPlusData->pUserDataList->InsertUserData(pData,nPos);
+ } else {
+ DBG_ERROR("SdrObject::InsertUserData(): pData ist NULL-Pointer");
+ }
+}
+
+void SdrObject::DeleteUserData(USHORT nNum)
+{
+ USHORT nAnz=GetUserDataCount();
+ if (nNum<nAnz) {
+ pPlusData->pUserDataList->DeleteUserData(nNum);
+ if (nAnz==1) {
+ delete pPlusData->pUserDataList;
+ pPlusData->pUserDataList=NULL;
+ }
+ } else {
+ DBG_ERROR("SdrObject::DeleteUserData(): ungueltiger Index");
+ }
+}
+
+void SdrObject::SendUserCall(SdrUserCallType eUserCall, const Rectangle& rBoundRect) const
+{
+ SdrObjGroup* pGroup = NULL;
+
+ if( pObjList && pObjList->GetListKind() == SDROBJLIST_GROUPOBJ )
+ pGroup = (SdrObjGroup*) pObjList->GetOwnerObj();
+
+ if ( pUserCall )
+ {
+ // UserCall ausfuehren
+ pUserCall->Changed( *this, eUserCall, rBoundRect );
+ }
+
+ while( pGroup )
+ {
+ // Gruppe benachrichtigen
+ if( pGroup->GetUserCall() )
+ {
+ SdrUserCallType eChildUserType = SDRUSERCALL_CHILD_CHGATTR;
+
+ switch( eUserCall )
+ {
+ case SDRUSERCALL_MOVEONLY:
+ eChildUserType = SDRUSERCALL_CHILD_MOVEONLY;
+ break;
+
+ case SDRUSERCALL_RESIZE:
+ eChildUserType = SDRUSERCALL_CHILD_RESIZE;
+ break;
+
+ case SDRUSERCALL_CHGATTR:
+ eChildUserType = SDRUSERCALL_CHILD_CHGATTR;
+ break;
+
+ case SDRUSERCALL_DELETE:
+ eChildUserType = SDRUSERCALL_CHILD_DELETE;
+ break;
+
+ case SDRUSERCALL_COPY:
+ eChildUserType = SDRUSERCALL_CHILD_COPY;
+ break;
+
+ case SDRUSERCALL_INSERTED:
+ eChildUserType = SDRUSERCALL_CHILD_INSERTED;
+ break;
+
+ case SDRUSERCALL_REMOVED:
+ eChildUserType = SDRUSERCALL_CHILD_REMOVED;
+ break;
+
+ default: break;
+ }
+
+ pGroup->GetUserCall()->Changed( *this, eChildUserType, rBoundRect );
+ }
+
+ if( pGroup->GetObjList() &&
+ pGroup->GetObjList()->GetListKind() == SDROBJLIST_GROUPOBJ &&
+ pGroup != (SdrObjGroup*) pObjList->GetOwnerObj() )
+ pGroup = (SdrObjGroup*) pObjList->GetOwnerObj();
+ else
+ pGroup = NULL;
+ }
+
+ // notify our UNO shape listeners
+ switch ( eUserCall )
+ {
+ case SDRUSERCALL_RESIZE:
+ notifyShapePropertyChange( ::svx::eShapeSize );
+ // fall through - RESIZE might also imply a change of the position
+ case SDRUSERCALL_MOVEONLY:
+ notifyShapePropertyChange( ::svx::eShapePosition );
+ break;
+ default:
+ // not interested in
+ break;
+ }
+}
+
+// ItemPool fuer dieses Objekt wechseln
+void SdrObject::MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
+{
+ if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
+ {
+ GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
+ }
+}
+
+sal_Bool SdrObject::IsTransparent( BOOL /*bCheckForAlphaChannel*/) const
+{
+ bool bRet = false;
+
+ if( IsGroupObject() )
+ {
+ SdrObjListIter aIter( *GetSubList(), IM_DEEPNOGROUPS );
+
+ for( SdrObject* pO = aIter.Next(); pO && !bRet; pO = aIter.Next() )
+ {
+ const SfxItemSet& rAttr = pO->GetMergedItemSet();
+
+ if( ( ( (const XFillTransparenceItem&) rAttr.Get( XATTR_FILLTRANSPARENCE ) ).GetValue() ||
+ ( (const XLineTransparenceItem&) rAttr.Get( XATTR_LINETRANSPARENCE ) ).GetValue() ) ||
+ ( ( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET ) &&
+ ( (const XFillFloatTransparenceItem&) rAttr.Get( XATTR_FILLFLOATTRANSPARENCE ) ).IsEnabled() ) )
+ {
+ bRet = TRUE;
+ }
+ else if( pO->ISA( SdrGrafObj ) )
+ {
+ SdrGrafObj* pGrafObj = (SdrGrafObj*) pO;
+ if( ( (const SdrGrafTransparenceItem&) rAttr.Get( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ||
+ ( pGrafObj->GetGraphicType() == GRAPHIC_BITMAP && pGrafObj->GetGraphic().GetBitmapEx().IsAlpha() ) )
+ {
+ bRet = TRUE;
+ }
+ }
+ }
+ }
+ else
+ {
+ const SfxItemSet& rAttr = GetMergedItemSet();
+
+ if( ( ( (const XFillTransparenceItem&) rAttr.Get( XATTR_FILLTRANSPARENCE ) ).GetValue() ||
+ ( (const XLineTransparenceItem&) rAttr.Get( XATTR_LINETRANSPARENCE ) ).GetValue() ) ||
+ ( ( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) == SFX_ITEM_SET ) &&
+ ( (const XFillFloatTransparenceItem&) rAttr.Get( XATTR_FILLFLOATTRANSPARENCE ) ).IsEnabled() ) )
+ {
+ bRet = TRUE;
+ }
+ else if( ISA( SdrGrafObj ) )
+ {
+ SdrGrafObj* pGrafObj = (SdrGrafObj*) this;
+
+ // #i25616#
+ bRet = pGrafObj->IsObjectTransparent();
+ }
+ }
+
+ return bRet;
+}
+
+void SdrObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& _rxUnoShape )
+{
+ maWeakUnoShape = _rxUnoShape;
+ mpSvxShape = SvxShape::getImplementation( _rxUnoShape );
+// OSL_ENSURE( mpSvxShape || !_rxUnoShape.is(),
+// "SdrObject::setUnoShape: not sure it's a good idea to have an XShape which is not implemented by SvxShape ..." );
+}
+
+/** only for internal use! */
+SvxShape* SdrObject::getSvxShape() const
+{
+ DBG_TESTSOLARMUTEX();
+ // retrieving the impl pointer and subsequently using it is not thread-safe, of course, so it needs to be
+ // guarded by the SolarMutex
+
+#if OSL_DEBUG_LEVE > 0
+ uno::Reference< uno::XInterface > xShape( maWeakUnoShape );
+ OSL_ENSURE( !( !xShapeGuard.is() && mpSvxShape ),
+ "SdrObject::getSvxShape: still having IMPL-Pointer to dead object!" );
+#endif
+
+ return mpSvxShape;
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SdrObject::getUnoShape()
+{
+ // try weak reference first
+ uno::Reference< uno::XInterface > xShape( getWeakUnoShape() );
+ if( !xShape.is() )
+ {
+ OSL_ENSURE( mpSvxShape == NULL, "SdrObject::getUnoShape: XShape already dead, but still an IMPL pointer!" );
+ if ( pPage )
+ {
+ uno::Reference< uno::XInterface > xPage( pPage->getUnoPage() );
+ if( xPage.is() )
+ {
+ SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation(xPage);
+ if( pDrawPage )
+ {
+ // create one
+ xShape = pDrawPage->_CreateShape( this );
+ impl_setUnoShape( xShape );
+ }
+ }
+ }
+ else
+ {
+ mpSvxShape = SvxDrawPage::CreateShapeByTypeAndInventor( GetObjIdentifier(), GetObjInventor(), this, NULL );
+ maWeakUnoShape = xShape = static_cast< ::cppu::OWeakObject* >( mpSvxShape );
+ }
+ }
+
+ return xShape;
+}
+
+::svx::PropertyChangeNotifier& SdrObject::getShapePropertyChangeNotifier()
+{
+ DBG_TESTSOLARMUTEX();
+
+ SvxShape* pSvxShape = getSvxShape();
+ ENSURE_OR_THROW( pSvxShape, "no SvxShape, yet!" );
+ return pSvxShape->getShapePropertyChangeNotifier();
+}
+
+void SdrObject::notifyShapePropertyChange( const ::svx::ShapeProperty _eProperty ) const
+{
+ DBG_TESTSOLARMUTEX();
+
+ SvxShape* pSvxShape = const_cast< SdrObject* >( this )->getSvxShape();
+ if ( pSvxShape )
+ return pSvxShape->getShapePropertyChangeNotifier().notifyPropertyChange( _eProperty );
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// transformation interface for StarOfficeAPI. This implements support for
+// homogen 3x3 matrices containing the transformation of the SdrObject. At the
+// moment it contains a shearX, rotation and translation, but for setting all linear
+// transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
+// with the base geometry and returns TRUE. Otherwise it returns FALSE.
+sal_Bool SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
+{
+ // any kind of SdrObject, just use SnapRect
+ Rectangle aRectangle(GetSnapRect());
+
+ // convert to transformation values
+ basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
+ basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
+
+ // position maybe relative to anchorpos, convert
+ if( pModel && pModel->IsWriter() )
+ {
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
+ }
+ }
+
+ // force MapUnit to 100th mm
+ SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // postion
+ aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
+ aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplTwipsToMM(aScale.getX()));
+ aScale.setY(ImplTwipsToMM(aScale.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
+ }
+ }
+ }
+
+ // build matrix
+ rMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aScale, aTranslate);
+
+ return sal_False;
+}
+
+// sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
+// If it's an SdrPathObj it will use the provided geometry information. The Polygon has
+// to use (0,0) as upper left and will be scaled to the given size in the matrix.
+void SdrObject::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
+{
+ // break up matrix
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate, fShearX;
+ rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
+ // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
+ if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
+ {
+ aScale.setX(fabs(aScale.getX()));
+ aScale.setY(fabs(aScale.getY()));
+ fRotate = fmod(fRotate + F_PI, F_2PI);
+ }
+
+ // force metric to pool metric
+ SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // position
+ aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
+ aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplMMToTwips(aScale.getX()));
+ aScale.setY(ImplMMToTwips(aScale.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
+ }
+ }
+ }
+
+ // if anchor is used, make position relative to it
+ if( pModel && pModel->IsWriter() )
+ {
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
+ }
+ }
+
+ // build BaseRect
+ Point aPoint(FRound(aTranslate.getX()), FRound(aTranslate.getY()));
+ Rectangle aBaseRect(aPoint, Size(FRound(aScale.getX()), FRound(aScale.getY())));
+
+ // set BaseRect
+ SetSnapRect(aBaseRect);
+}
+
+// #116168#
+// Give info if object is in destruction
+sal_Bool SdrObject::IsInDestruction() const
+{
+ if(pModel)
+ return pModel->IsInDestruction();
+ return sal_False;
+}
+
+// return if fill is != XFILL_NONE
+bool SdrObject::HasFillStyle() const
+{
+ return (((const XFillStyleItem&)GetObjectItem(XATTR_FILLSTYLE)).GetValue() != XFILL_NONE);
+}
+
+bool SdrObject::HasLineStyle() const
+{
+ return (((const XLineStyleItem&)GetObjectItem(XATTR_LINESTYLE)).GetValue() != XLINE_NONE);
+}
+
+
+// #i52224#
+// on import of OLE object from MS documents the BLIP size might be retrieved,
+// the following four methods are used to control it;
+// usually this data makes no sence after the import is finished, since the object
+// might be resized
+
+Rectangle SdrObject::GetBLIPSizeRectangle() const
+{
+ return maBLIPSizeRectangle;
+}
+
+void SdrObject::SetBLIPSizeRectangle( const Rectangle& aRect )
+{
+ maBLIPSizeRectangle = aRect;
+}
+
+void SdrObject::SetContextWritingMode( const sal_Int16 /*_nContextWritingMode*/ )
+{
+ // this base class does not support different writing modes, so ignore the call
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@ @@@@@ @@@@@@ @@@@@ @@@@ @@@@ @@@@@@ @@@@ @@@@@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@@@ @@@@@@ @@ @@ @@ @@ @@@@@ @@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@ @@@@@ @@@@ @@ @@ @@ @@@@ @@ @@@@ @@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrObjFactory::SdrObjFactory(UINT32 nInvent, UINT16 nIdent, SdrPage* pNewPage, SdrModel* pNewModel)
+{
+ nInventor=nInvent;
+ nIdentifier=nIdent;
+ pNewObj=NULL;
+ pPage=pNewPage;
+ pModel=pNewModel;
+ pObj=NULL;
+ pNewData=NULL;
+}
+
+SdrObjFactory::SdrObjFactory(UINT32 nInvent, UINT16 nIdent, SdrObject* pObj1)
+{
+ nInventor=nInvent;
+ nIdentifier=nIdent;
+ pNewObj=NULL;
+ pPage=NULL;
+ pModel=NULL;
+ pObj=pObj1;
+ pNewData=NULL;
+}
+
+SdrObject* SdrObjFactory::MakeNewObject(UINT32 nInvent, UINT16 nIdent, SdrPage* pPage, SdrModel* pModel)
+{
+ if(pModel == NULL && pPage != NULL)
+ pModel = pPage->GetModel();
+ SdrObject* pObj = NULL;
+
+ if(nInvent == SdrInventor)
+ {
+ switch (nIdent)
+ {
+ case USHORT(OBJ_NONE ): pObj=new SdrObject; break;
+ case USHORT(OBJ_GRUP ): pObj=new SdrObjGroup; break;
+ case USHORT(OBJ_LINE ): pObj=new SdrPathObj(OBJ_LINE ); break;
+ case USHORT(OBJ_POLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
+ case USHORT(OBJ_PLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
+ case USHORT(OBJ_PATHLINE ): pObj=new SdrPathObj(OBJ_PATHLINE ); break;
+ case USHORT(OBJ_PATHFILL ): pObj=new SdrPathObj(OBJ_PATHFILL ); break;
+ case USHORT(OBJ_FREELINE ): pObj=new SdrPathObj(OBJ_FREELINE ); break;
+ case USHORT(OBJ_FREEFILL ): pObj=new SdrPathObj(OBJ_FREEFILL ); break;
+ case USHORT(OBJ_PATHPOLY ): pObj=new SdrPathObj(OBJ_POLY ); break;
+ case USHORT(OBJ_PATHPLIN ): pObj=new SdrPathObj(OBJ_PLIN ); break;
+ case USHORT(OBJ_EDGE ): pObj=new SdrEdgeObj; break;
+ case USHORT(OBJ_RECT ): pObj=new SdrRectObj; break;
+ case USHORT(OBJ_CIRC ): pObj=new SdrCircObj(OBJ_CIRC ); break;
+ case USHORT(OBJ_SECT ): pObj=new SdrCircObj(OBJ_SECT ); break;
+ case USHORT(OBJ_CARC ): pObj=new SdrCircObj(OBJ_CARC ); break;
+ case USHORT(OBJ_CCUT ): pObj=new SdrCircObj(OBJ_CCUT ); break;
+ case USHORT(OBJ_TEXT ): pObj=new SdrRectObj(OBJ_TEXT ); break;
+ case USHORT(OBJ_TEXTEXT ): pObj=new SdrRectObj(OBJ_TEXTEXT ); break;
+ case USHORT(OBJ_TITLETEXT ): pObj=new SdrRectObj(OBJ_TITLETEXT ); break;
+ case USHORT(OBJ_OUTLINETEXT): pObj=new SdrRectObj(OBJ_OUTLINETEXT); break;
+ case USHORT(OBJ_MEASURE ): pObj=new SdrMeasureObj; break;
+ case USHORT(OBJ_GRAF ): pObj=new SdrGrafObj; break;
+ case USHORT(OBJ_OLE2 ): pObj=new SdrOle2Obj; break;
+ case USHORT(OBJ_FRAME ): pObj=new SdrOle2Obj(TRUE); break;
+ case USHORT(OBJ_CAPTION ): pObj=new SdrCaptionObj; break;
+ case USHORT(OBJ_PAGE ): pObj=new SdrPageObj; break;
+ case USHORT(OBJ_UNO ): pObj=new SdrUnoObj(String()); break;
+ case USHORT(OBJ_CUSTOMSHAPE ): pObj=new SdrObjCustomShape(); break;
+ case USHORT(OBJ_MEDIA ): pObj=new SdrMediaObj(); break;
+ case USHORT(OBJ_TABLE ): pObj=new ::sdr::table::SdrTableObj(pModel); break;
+ }
+ }
+
+ if(pObj == NULL)
+ {
+ SdrObjFactory* pFact=new SdrObjFactory(nInvent,nIdent,pPage,pModel);
+ SdrLinkList& rLL=ImpGetUserMakeObjHdl();
+ unsigned nAnz=rLL.GetLinkCount();
+ unsigned i=0;
+ while (i<nAnz && pObj==NULL) {
+ rLL.GetLink(i).Call((void*)pFact);
+ pObj=pFact->pNewObj;
+ i++;
+ }
+ delete pFact;
+ }
+
+ if(pObj == NULL)
+ {
+ // Na wenn's denn keiner will ...
+ }
+
+ if(pObj != NULL)
+ {
+ if(pPage != NULL)
+ pObj->SetPage(pPage);
+ else if(pModel != NULL)
+ pObj->SetModel(pModel);
+ }
+
+ return pObj;
+}
+
+SdrObjUserData* SdrObjFactory::MakeNewObjUserData(UINT32 nInvent, UINT16 nIdent, SdrObject* pObj1)
+{
+ SdrObjUserData* pData=NULL;
+ if (nInvent==SdrInventor) {
+ switch (nIdent)
+ {
+ case USHORT(SDRUSERDATA_OBJTEXTLINK) : pData=new ImpSdrObjTextLinkUserData((SdrTextObj*)pObj1); break;
+ }
+ }
+ if (pData==NULL) {
+ SdrObjFactory aFact(nInvent,nIdent,pObj1);
+ SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
+ unsigned nAnz=rLL.GetLinkCount();
+ unsigned i=0;
+ while (i<nAnz && pData==NULL) {
+ rLL.GetLink(i).Call((void*)&aFact);
+ pData=aFact.pNewData;
+ i++;
+ }
+ }
+ return pData;
+}
+
+void SdrObjFactory::InsertMakeObjectHdl(const Link& rLink)
+{
+ SdrLinkList& rLL=ImpGetUserMakeObjHdl();
+ rLL.InsertLink(rLink);
+}
+
+void SdrObjFactory::RemoveMakeObjectHdl(const Link& rLink)
+{
+ SdrLinkList& rLL=ImpGetUserMakeObjHdl();
+ rLL.RemoveLink(rLink);
+}
+
+void SdrObjFactory::InsertMakeUserDataHdl(const Link& rLink)
+{
+ SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
+ rLL.InsertLink(rLink);
+}
+
+void SdrObjFactory::RemoveMakeUserDataHdl(const Link& rLink)
+{
+ SdrLinkList& rLL=ImpGetUserMakeObjUserDataHdl();
+ rLL.RemoveLink(rLink);
+}
+
+namespace svx
+{
+ ISdrObjectFilter::~ISdrObjectFilter()
+ {
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx
new file mode 100644
index 000000000000..9045a8bec9d1
--- /dev/null
+++ b/svx/source/svdraw/svdocapt.cxx
@@ -0,0 +1,854 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/bigint.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svl/style.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/xpool.hxx>
+#include <svx/xpoly.hxx>
+#include <svx/svdattrx.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdhdl.hxx>
+#include <svx/svddrag.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdview.hxx> // fuer RectSnap
+#include "svdglob.hxx" // StringCache
+#include "svdstr.hrc" // Objektname
+#include <svx/svdogrp.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xfltrit.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/sdr/properties/captionproperties.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include <svx/sdr/contact/viewcontactofsdrcaptionobj.hxx>
+#include <basegfx/tuple/b2dtuple.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdrhittesthelper.hxx>
+
+// #i32599#
+inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
+inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+enum EscDir {LKS,RTS,OBN,UNT};
+
+class ImpCaptParams
+{
+public:
+ SdrCaptionType eType;
+ long nAngle;
+ long nGap;
+ long nEscRel;
+ long nEscAbs;
+ long nLineLen;
+ SdrCaptionEscDir eEscDir;
+ bool bFitLineLen;
+ bool bEscRel;
+ bool bFixedAngle;
+
+public:
+ ImpCaptParams()
+ {
+ eType =SDRCAPT_TYPE3;
+ bFixedAngle=FALSE;
+ nAngle =4500;
+ nGap =0;
+ eEscDir =SDRCAPT_ESCHORIZONTAL;
+ bEscRel =TRUE;
+ nEscRel =5000;
+ nEscAbs =0;
+ nLineLen =0;
+ bFitLineLen=TRUE;
+ }
+ void CalcEscPos(const Point& rTail, const Rectangle& rRect, Point& rPt, EscDir& rDir) const;
+};
+
+void ImpCaptParams::CalcEscPos(const Point& rTailPt, const Rectangle& rRect, Point& rPt, EscDir& rDir) const
+{
+ Point aTl(rTailPt); // lokal kopieren wg. Performance
+ long nX,nY;
+ if (bEscRel) {
+ nX=rRect.Right()-rRect.Left();
+ nX=BigMulDiv(nX,nEscRel,10000);
+ nY=rRect.Bottom()-rRect.Top();
+ nY=BigMulDiv(nY,nEscRel,10000);
+ } else {
+ nX=nEscAbs;
+ nY=nEscAbs;
+ }
+ nX+=rRect.Left();
+ nY+=rRect.Top();
+ Point aBestPt;
+ EscDir eBestDir=LKS;
+ bool bTryH=eEscDir==SDRCAPT_ESCBESTFIT;
+ if (!bTryH) {
+ if (eType!=SDRCAPT_TYPE1) {
+ bTryH=eEscDir==SDRCAPT_ESCHORIZONTAL;
+ } else {
+ bTryH=eEscDir==SDRCAPT_ESCVERTICAL;
+ }
+ }
+ bool bTryV=eEscDir==SDRCAPT_ESCBESTFIT;
+ if (!bTryV) {
+ if (eType!=SDRCAPT_TYPE1) {
+ bTryV=eEscDir==SDRCAPT_ESCVERTICAL;
+ } else {
+ bTryV=eEscDir==SDRCAPT_ESCHORIZONTAL;
+ }
+ }
+
+ if (bTryH) {
+ Point aLft(rRect.Left()-nGap,nY);
+ Point aRgt(rRect.Right()+nGap,nY);
+ bool bLft=(aTl.X()-aLft.X()<aRgt.X()-aTl.X());
+ if (bLft) {
+ eBestDir=LKS;
+ aBestPt=aLft;
+ } else {
+ eBestDir=RTS;
+ aBestPt=aRgt;
+ }
+ }
+ if (bTryV) {
+ Point aTop(nX,rRect.Top()-nGap);
+ Point aBtm(nX,rRect.Bottom()+nGap);
+ bool bTop=(aTl.Y()-aTop.Y()<aBtm.Y()-aTl.Y());
+ Point aBest2;
+ EscDir eBest2;
+ if (bTop) {
+ eBest2=OBN;
+ aBest2=aTop;
+ } else {
+ eBest2=UNT;
+ aBest2=aBtm;
+ }
+ bool bTakeIt=eEscDir!=SDRCAPT_ESCBESTFIT;
+ if (!bTakeIt) {
+ BigInt aHorX(aBestPt.X()-aTl.X()); aHorX*=aHorX;
+ BigInt aHorY(aBestPt.Y()-aTl.Y()); aHorY*=aHorY;
+ BigInt aVerX(aBest2.X()-aTl.X()); aVerX*=aVerX;
+ BigInt aVerY(aBest2.Y()-aTl.Y()); aVerY*=aVerY;
+ if (eType!=SDRCAPT_TYPE1) {
+ bTakeIt=aVerX+aVerY<aHorX+aHorY;
+ } else {
+ bTakeIt=aVerX+aVerY>=aHorX+aHorY;
+ }
+ }
+ if (bTakeIt) {
+ aBestPt=aBest2;
+ eBestDir=eBest2;
+ }
+ }
+ rPt=aBestPt;
+ rDir=eBestDir;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrCaptionObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::CaptionProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// DrawContact section
+
+sdr::contact::ViewContact* SdrCaptionObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfSdrCaptionObj(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrCaptionObj,SdrRectObj);
+
+SdrCaptionObj::SdrCaptionObj():
+ SdrRectObj(OBJ_TEXT),
+ aTailPoly(3), // Default Groesse: 3 Punkte = 2 Linien
+ mbSpecialTextBoxShadow(FALSE),
+ mbFixedTail(FALSE)
+{
+}
+
+SdrCaptionObj::SdrCaptionObj(const Rectangle& rRect):
+ SdrRectObj(OBJ_TEXT,rRect),
+ aTailPoly(3), // Default Groesse: 3 Punkte = 2 Linien
+ mbSpecialTextBoxShadow(FALSE),
+ mbFixedTail(FALSE)
+{
+}
+
+SdrCaptionObj::SdrCaptionObj(const Rectangle& rRect, const Point& rTail):
+ SdrRectObj(OBJ_TEXT,rRect),
+ aTailPoly(3), // Default Groesse: 3 Punkte = 2 Linien
+ mbSpecialTextBoxShadow(FALSE),
+ mbFixedTail(FALSE)
+{
+ aTailPoly[0]=maFixedTailPos=rTail;
+}
+
+SdrCaptionObj::~SdrCaptionObj()
+{
+}
+
+void SdrCaptionObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bRotateFreeAllowed=FALSE;
+ rInfo.bRotate90Allowed =FALSE;
+ rInfo.bMirrorFreeAllowed=FALSE;
+ rInfo.bMirror45Allowed =FALSE;
+ rInfo.bMirror90Allowed =FALSE;
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ rInfo.bShearAllowed =FALSE;
+ rInfo.bEdgeRadiusAllowed=FALSE;
+ rInfo.bCanConvToPath =TRUE;
+ rInfo.bCanConvToPoly =TRUE;
+ rInfo.bCanConvToPathLineToArea=FALSE;
+ rInfo.bCanConvToPolyLineToArea=FALSE;
+ rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
+}
+
+UINT16 SdrCaptionObj::GetObjIdentifier() const
+{
+ return UINT16(OBJ_CAPTION);
+}
+
+void SdrCaptionObj::operator=(const SdrObject& rObj)
+{
+ SdrRectObj::operator=(rObj);
+ aTailPoly=((SdrCaptionObj&)rObj).aTailPoly;
+}
+
+void SdrCaptionObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulCAPTION);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+void SdrCaptionObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralCAPTION);
+}
+
+basegfx::B2DPolyPolygon SdrCaptionObj::TakeXorPoly() const
+{
+ basegfx::B2DPolyPolygon aPolyPoly(SdrRectObj::TakeXorPoly());
+ aPolyPoly.append(aTailPoly.getB2DPolygon());
+
+ return aPolyPoly;
+}
+
+sal_uInt32 SdrCaptionObj::GetHdlCount() const
+{
+ sal_uInt32 nAnz1(SdrRectObj::GetHdlCount());
+ // sal_uInt32 nAnz2(aTailPoly.GetSize());
+ // Derzeit ist nur das Draggen des Schwanzendes implementiert
+ return nAnz1 + 1L;
+}
+
+SdrHdl* SdrCaptionObj::GetHdl(sal_uInt32 nHdlNum) const
+{
+ const sal_uInt32 nRectHdlAnz(SdrRectObj::GetHdlCount());
+
+ if(nHdlNum < nRectHdlAnz)
+ {
+ return SdrRectObj::GetHdl(nHdlNum);
+ }
+ else
+ {
+ sal_uInt32 nPntNum(nHdlNum);
+ nPntNum -= nRectHdlAnz;
+
+ if(nPntNum < aTailPoly.GetSize())
+ {
+ SdrHdl* pHdl = new SdrHdl(aTailPoly.GetPoint((sal_uInt16)nPntNum), HDL_POLY);
+ pHdl->SetPolyNum(1L);
+ pHdl->SetPointNum(nPntNum);
+ return pHdl;
+ }
+ else
+ {
+ return 0L;
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrCaptionObj::hasSpecialDrag() const
+{
+ return true;
+}
+
+bool SdrCaptionObj::beginSpecialDrag(SdrDragStat& rDrag) const
+{
+ const SdrHdl* pHdl = rDrag.GetHdl();
+ rDrag.SetEndDragChangesAttributes(true);
+ rDrag.SetEndDragChangesGeoAndAttributes(true);
+
+ if(pHdl && 0 == pHdl->GetPolyNum())
+ {
+ return SdrRectObj::beginSpecialDrag(rDrag);
+ }
+ else
+ {
+ rDrag.SetOrtho8Possible(true);
+
+ if(!pHdl)
+ {
+ if (bMovProt)
+ return 0;
+
+ rDrag.SetNoSnap(true);
+ rDrag.SetActionRect(aRect);
+
+ Point aHit(rDrag.GetStart());
+
+ if(rDrag.GetPageView() && SdrObjectPrimitiveHit(*this, aHit, 0, *rDrag.GetPageView(), 0, false))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if((1 == pHdl->GetPolyNum()) && (0 == pHdl->GetPointNum()))
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool SdrCaptionObj::applySpecialDrag(SdrDragStat& rDrag)
+{
+ const SdrHdl* pHdl = rDrag.GetHdl();
+
+ if(pHdl && 0 == pHdl->GetPolyNum())
+ {
+ const bool bRet(SdrRectObj::applySpecialDrag(rDrag));
+ ImpRecalcTail();
+ ActionChanged();
+
+ return bRet;
+ }
+ else
+ {
+ Point aDelt(rDrag.GetNow()-rDrag.GetStart());
+
+ if(!pHdl)
+ {
+ aRect.Move(aDelt.X(),aDelt.Y());
+ }
+ else
+ {
+ aTailPoly[0] += aDelt;
+ }
+
+ ImpRecalcTail();
+ ActionChanged();
+
+ return true;
+ }
+}
+
+String SdrCaptionObj::getSpecialDragComment(const SdrDragStat& rDrag) const
+{
+ const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj());
+
+ if(bCreateComment)
+ {
+ return String();
+ }
+ else
+ {
+ const SdrHdl* pHdl = rDrag.GetHdl();
+
+ if(pHdl && 0 == pHdl->GetPolyNum())
+ {
+ return SdrRectObj::getSpecialDragComment(rDrag);
+ }
+ else
+ {
+ XubString aStr;
+
+ if(!pHdl)
+ {
+ ImpTakeDescriptionStr(STR_DragCaptFram, aStr);
+ }
+ else
+ {
+ ImpTakeDescriptionStr(STR_DragCaptTail, aStr);
+ }
+
+ return aStr;
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrCaptionObj::ImpGetCaptParams(ImpCaptParams& rPara) const
+{
+ const SfxItemSet& rSet = GetObjectItemSet();
+ rPara.eType =((SdrCaptionTypeItem&) (rSet.Get(SDRATTR_CAPTIONTYPE ))).GetValue();
+ rPara.bFixedAngle=((SdrCaptionFixedAngleItem&)(rSet.Get(SDRATTR_CAPTIONANGLE ))).GetValue();
+ rPara.nAngle =((SdrCaptionAngleItem&) (rSet.Get(SDRATTR_CAPTIONFIXEDANGLE))).GetValue();
+ rPara.nGap =((SdrCaptionGapItem&) (rSet.Get(SDRATTR_CAPTIONGAP ))).GetValue();
+ rPara.eEscDir =((SdrCaptionEscDirItem&) (rSet.Get(SDRATTR_CAPTIONESCDIR ))).GetValue();
+ rPara.bEscRel =((SdrCaptionEscIsRelItem&) (rSet.Get(SDRATTR_CAPTIONESCISREL ))).GetValue();
+ rPara.nEscRel =((SdrCaptionEscRelItem&) (rSet.Get(SDRATTR_CAPTIONESCREL ))).GetValue();
+ rPara.nEscAbs =((SdrCaptionEscAbsItem&) (rSet.Get(SDRATTR_CAPTIONESCABS ))).GetValue();
+ rPara.nLineLen =((SdrCaptionLineLenItem&) (rSet.Get(SDRATTR_CAPTIONLINELEN ))).GetValue();
+ rPara.bFitLineLen=((SdrCaptionFitLineLenItem&)(rSet.Get(SDRATTR_CAPTIONFITLINELEN))).GetValue();
+}
+
+void SdrCaptionObj::ImpRecalcTail()
+{
+ ImpCaptParams aPara;
+ ImpGetCaptParams(aPara);
+ ImpCalcTail(aPara,aTailPoly,aRect);
+ SetRectsDirty();
+ SetXPolyDirty();
+}
+
+// #i35971#
+// SdrCaptionObj::ImpCalcTail1 does move the object(!). What a hack.
+// I really wonder why this had not triggered problems before. I am
+// sure there are some places where SetTailPos() is called at least
+// twice or SetSnapRect after it again just to work around this.
+// Changed this method to not do that.
+// Also found why this has been done: For interactive dragging of the
+// tail end pos for SDRCAPT_TYPE1. This sure was the simplest method
+// to achieve this, for the cost to make a whole group of const methods
+// of this object implicitly chainging the object's position.
+void SdrCaptionObj::ImpCalcTail1(const ImpCaptParams& rPara, Polygon& rPoly, Rectangle& rRect) const
+{
+ Polygon aPol(2);
+ Point aTl(rPoly[0]);
+
+ aPol[0] = aTl;
+ aPol[1] = aTl;
+
+ EscDir eEscDir;
+ Point aEscPos;
+
+ rPara.CalcEscPos(aTl, rRect, aEscPos, eEscDir);
+ aPol[1] = aEscPos;
+
+ if(eEscDir==LKS || eEscDir==RTS)
+ {
+ aPol[0].X() = aEscPos.X();
+ }
+ else
+ {
+ aPol[0].Y() = aEscPos.Y();
+ }
+
+ rPoly = aPol;
+}
+
+void SdrCaptionObj::ImpCalcTail2(const ImpCaptParams& rPara, Polygon& rPoly, Rectangle& rRect) const
+{ // Gap/EscDir/EscPos/Angle
+ Polygon aPol(2);
+ Point aTl(rPoly[0]);
+ aPol[0]=aTl;
+
+ EscDir eEscDir;
+ Point aEscPos;
+ rPara.CalcEscPos(aTl,rRect,aEscPos,eEscDir);
+ aPol[1]=aEscPos;
+
+ if (!rPara.bFixedAngle) {
+ // fehlende Implementation
+ }
+ rPoly=aPol;
+}
+
+void SdrCaptionObj::ImpCalcTail3(const ImpCaptParams& rPara, Polygon& rPoly, Rectangle& rRect) const
+{ // Gap/EscDir/EscPos/Angle/LineLen
+ Polygon aPol(3);
+ Point aTl(rPoly[0]);
+ aPol[0]=aTl;
+
+ EscDir eEscDir;
+ Point aEscPos;
+ rPara.CalcEscPos(aTl,rRect,aEscPos,eEscDir);
+ aPol[1]=aEscPos;
+ aPol[2]=aEscPos;
+
+ if (eEscDir==LKS || eEscDir==RTS) {
+ if (rPara.bFitLineLen) {
+ aPol[1].X()=(aTl.X()+aEscPos.X())/2;
+ } else {
+ if (eEscDir==LKS) aPol[1].X()-=rPara.nLineLen;
+ else aPol[1].X()+=rPara.nLineLen;
+ }
+ } else {
+ if (rPara.bFitLineLen) {
+ aPol[1].Y()=(aTl.Y()+aEscPos.Y())/2;
+ } else {
+ if (eEscDir==OBN) aPol[1].Y()-=rPara.nLineLen;
+ else aPol[1].Y()+=rPara.nLineLen;
+ }
+ }
+ if (!rPara.bFixedAngle) {
+ // fehlende Implementation
+ }
+ rPoly=aPol;
+}
+
+void SdrCaptionObj::ImpCalcTail4(const ImpCaptParams& rPara, Polygon& rPoly, Rectangle& rRect) const
+{
+ ImpCalcTail3(rPara,rPoly,rRect);
+}
+
+void SdrCaptionObj::ImpCalcTail(const ImpCaptParams& rPara, Polygon& rPoly, Rectangle& rRect) const
+{
+ switch (rPara.eType) {
+ case SDRCAPT_TYPE1: ImpCalcTail1(rPara,rPoly,rRect); break;
+ case SDRCAPT_TYPE2: ImpCalcTail2(rPara,rPoly,rRect); break;
+ case SDRCAPT_TYPE3: ImpCalcTail3(rPara,rPoly,rRect); break;
+ case SDRCAPT_TYPE4: ImpCalcTail4(rPara,rPoly,rRect); break;
+ }
+}
+
+bool SdrCaptionObj::BegCreate(SdrDragStat& rStat)
+{
+ if (aRect.IsEmpty()) return FALSE; // Create z.Zt. nur mit vorgegebenen Rect
+
+ ImpCaptParams aPara;
+ ImpGetCaptParams(aPara);
+ aRect.SetPos(rStat.GetNow());
+ aTailPoly[0]=rStat.GetStart();
+ ImpCalcTail(aPara,aTailPoly,aRect);
+ rStat.SetActionRect(aRect);
+ return TRUE;
+}
+
+bool SdrCaptionObj::MovCreate(SdrDragStat& rStat)
+{
+ ImpCaptParams aPara;
+ ImpGetCaptParams(aPara);
+ aRect.SetPos(rStat.GetNow());
+ ImpCalcTail(aPara,aTailPoly,aRect);
+ rStat.SetActionRect(aRect);
+ SetBoundRectDirty();
+ bSnapRectDirty=TRUE;
+ return TRUE;
+}
+
+bool SdrCaptionObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ ImpCaptParams aPara;
+ ImpGetCaptParams(aPara);
+ aRect.SetPos(rStat.GetNow());
+ ImpCalcTail(aPara,aTailPoly,aRect);
+ SetRectsDirty();
+ return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
+}
+
+bool SdrCaptionObj::BckCreate(SdrDragStat& /*rStat*/)
+{
+ return FALSE;
+}
+
+void SdrCaptionObj::BrkCreate(SdrDragStat& /*rStat*/)
+{
+}
+
+basegfx::B2DPolyPolygon SdrCaptionObj::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
+{
+ basegfx::B2DPolyPolygon aRetval;
+ const basegfx::B2DRange aRange(aRect.Left(), aRect.Top(), aRect.Right(), aRect.Bottom());
+ aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
+ aRetval.append(aTailPoly.getB2DPolygon());
+ return aRetval;
+}
+
+Pointer SdrCaptionObj::GetCreatePointer() const
+{
+ return Pointer(POINTER_DRAW_CAPTION);
+}
+
+void SdrCaptionObj::NbcMove(const Size& rSiz)
+{
+ SdrRectObj::NbcMove(rSiz);
+ MovePoly(aTailPoly,rSiz);
+ if(mbFixedTail)
+ SetTailPos(GetFixedTailPos());
+}
+
+void SdrCaptionObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ SdrRectObj::NbcResize(rRef,xFact,yFact);
+ ResizePoly(aTailPoly,rRef,xFact,yFact);
+ ImpRecalcTail();
+ if(mbFixedTail)
+ SetTailPos(GetFixedTailPos());
+}
+
+void SdrCaptionObj::NbcSetRelativePos(const Point& rPnt)
+{
+ Point aRelPos0(aTailPoly.GetPoint(0)-aAnchor);
+ Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
+ NbcMove(aSiz); // Der ruft auch das SetRectsDirty()
+}
+
+Point SdrCaptionObj::GetRelativePos() const
+{
+ return aTailPoly.GetPoint(0)-aAnchor;
+}
+
+void SdrCaptionObj::NbcSetAnchorPos(const Point& rPnt)
+{
+ SdrRectObj::NbcSetAnchorPos(rPnt);
+ // !!!!! fehlende Impl.
+}
+
+const Point& SdrCaptionObj::GetAnchorPos() const
+{
+ // !!!!! fehlende Impl.
+ return SdrRectObj::GetAnchorPos();
+}
+
+void SdrCaptionObj::RecalcSnapRect()
+{
+ SdrRectObj::RecalcSnapRect();
+ // #i32599#
+ // maSnapRect.Union(aTailPoly.GetBoundRect());
+ // !!!!! fehlende Impl.
+}
+
+const Rectangle& SdrCaptionObj::GetSnapRect() const
+{
+ return SdrRectObj::GetSnapRect();
+}
+
+void SdrCaptionObj::NbcSetSnapRect(const Rectangle& rRect)
+{
+ // #i32599#
+ // Move back to see the rectangle of the underlying SdrRectObj
+ // as the SnapRect, without the TailPos. That simplifies SnapRect
+ // handling again, if not allows it at all...
+ SdrRectObj::NbcSetSnapRect(rRect);
+}
+
+const Rectangle& SdrCaptionObj::GetLogicRect() const
+{
+ return aRect;
+}
+
+void SdrCaptionObj::NbcSetLogicRect(const Rectangle& rRect)
+{
+ SdrRectObj::NbcSetLogicRect(rRect);
+ ImpRecalcTail();
+}
+
+const Point& SdrCaptionObj::GetTailPos() const
+{
+ return aTailPoly[0];
+}
+
+void SdrCaptionObj::SetTailPos(const Point& rPos)
+{
+ if (aTailPoly.GetSize()==0 || aTailPoly[0]!=rPos) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetTailPos(rPos);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+void SdrCaptionObj::NbcSetTailPos(const Point& rPos)
+{
+ aTailPoly[0]=rPos;
+ ImpRecalcTail();
+}
+
+sal_uInt32 SdrCaptionObj::GetSnapPointCount() const
+{
+ // !!!!! fehlende Impl.
+ return 0L;
+}
+
+Point SdrCaptionObj::GetSnapPoint(sal_uInt32 /*i*/) const
+{
+ // !!!!! fehlende Impl.
+ return Point(0,0);
+}
+
+void SdrCaptionObj::SetModel(SdrModel* pNewModel)
+{
+ SdrRectObj::SetModel(pNewModel);
+ ImpRecalcTail();
+}
+
+void SdrCaptionObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+{
+ SdrRectObj::Notify(rBC,rHint);
+ ImpRecalcTail();
+}
+
+SdrObjGeoData* SdrCaptionObj::NewGeoData() const
+{
+ return new SdrCaptObjGeoData;
+}
+
+void SdrCaptionObj::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ SdrRectObj::SaveGeoData(rGeo);
+ SdrCaptObjGeoData& rCGeo=(SdrCaptObjGeoData&)rGeo;
+ rCGeo.aTailPoly=aTailPoly;
+}
+
+void SdrCaptionObj::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ SdrRectObj::RestGeoData(rGeo);
+ SdrCaptObjGeoData& rCGeo=(SdrCaptObjGeoData&)rGeo;
+ aTailPoly=rCGeo.aTailPoly;
+}
+
+SdrObject* SdrCaptionObj::DoConvertToPolyObj(BOOL bBezier) const
+{ // #42334# - Convert implementiert
+ SdrObject* pRect=SdrRectObj::DoConvertToPolyObj(bBezier);
+ SdrObject* pTail = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aTailPoly.getB2DPolygon()), sal_False, bBezier);
+ SdrObject* pRet=(pTail!=NULL) ? pTail : pRect;
+ if (pTail!=NULL && pRect!=NULL) {
+ bool bInsRect = true;
+ bool bInsTail = true;
+ SdrObjList* pOL=pTail->GetSubList();
+ if (pOL!=NULL) { pRet=pRect; bInsTail = false; }
+ if (pOL==NULL) pOL=pRect->GetSubList();
+ if (pOL!=NULL) { pRet=pRect; bInsRect = false; }
+ if (pOL==NULL) {
+ SdrObjGroup* pGrp=new SdrObjGroup;
+ pOL=pGrp->GetSubList();
+ pRet=pGrp;
+ }
+ if (bInsRect) pOL->NbcInsertObject(pRect);
+ if (bInsTail) pOL->NbcInsertObject(pTail,0);
+ }
+ return pRet;
+}
+
+// #i32599#
+// Add own implementation for TRSetBaseGeometry to handle TailPos over changes.
+void SdrCaptionObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
+{
+ // break up matrix
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate, fShearX;
+ rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
+ // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
+ if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
+ {
+ aScale.setX(fabs(aScale.getX()));
+ aScale.setY(fabs(aScale.getY()));
+ fRotate = fmod(fRotate + F_PI, F_2PI);
+ }
+
+ // force metric to pool metric
+ SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // position
+ aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
+ aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplMMToTwips(aScale.getX()));
+ aScale.setY(ImplMMToTwips(aScale.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
+ }
+ }
+ }
+
+ // if anchor is used, make position relative to it
+ if( pModel->IsWriter() )
+ {
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
+ }
+ }
+
+ // build BaseRect
+ Point aPoint(FRound(aTranslate.getX()), FRound(aTranslate.getY()));
+ Rectangle aBaseRect(aPoint, Size(FRound(aScale.getX()), FRound(aScale.getY())));
+
+ // set BaseRect, but rescue TailPos over this call
+ const Point aTailPoint = GetTailPos();
+ SetSnapRect(aBaseRect);
+ SetTailPos(aTailPoint);
+ ImpRecalcTail();
+}
+
+// geometry access
+basegfx::B2DPolygon SdrCaptionObj::getTailPolygon() const
+{
+ return aTailPoly.getB2DPolygon();
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
new file mode 100644
index 000000000000..c219e9781ac2
--- /dev/null
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -0,0 +1,1174 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svl/style.hxx>
+#include <tools/bigint.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/svdocirc.hxx>
+#include <math.h>
+#include <svx/xpool.hxx>
+#include <svx/svdattr.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdattrx.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svddrag.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdopath.hxx> // fuer die Objektkonvertierung
+#include <svx/svdview.hxx> // Zum Draggen (Ortho)
+#include "svdglob.hxx" // StringCache
+#include "svdstr.hrc" // Objektname
+#include <editeng/eeitem.hxx>
+#include "svdoimp.hxx"
+#include <svx/sdr/properties/circleproperties.hxx>
+#include <svx/sdr/contact/viewcontactofsdrcircobj.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+Point GetWinkPnt(const Rectangle& rR, long nWink)
+{
+ Point aCenter(rR.Center());
+ long nWdt=rR.Right()-rR.Left();
+ long nHgt=rR.Bottom()-rR.Top();
+ long nMaxRad=((nWdt>nHgt ? nWdt : nHgt)+1) /2;
+ double a;
+ a=nWink*nPi180;
+ Point aRetval(Round(cos(a)*nMaxRad),-Round(sin(a)*nMaxRad));
+ if (nWdt==0) aRetval.X()=0;
+ if (nHgt==0) aRetval.Y()=0;
+ if (nWdt!=nHgt) {
+ if (nWdt>nHgt) {
+ if (nWdt!=0) {
+ // eventuelle Ueberlaeufe bei sehr grossen Objekten abfangen (Bug 23384)
+ if (Abs(nHgt)>32767 || Abs(aRetval.Y())>32767) {
+ aRetval.Y()=BigMulDiv(aRetval.Y(),nHgt,nWdt);
+ } else {
+ aRetval.Y()=aRetval.Y()*nHgt/nWdt;
+ }
+ }
+ } else {
+ if (nHgt!=0) {
+ // eventuelle Ueberlaeufe bei sehr grossen Objekten abfangen (Bug 23384)
+ if (Abs(nWdt)>32767 || Abs(aRetval.X())>32767) {
+ aRetval.X()=BigMulDiv(aRetval.X(),nWdt,nHgt);
+ } else {
+ aRetval.X()=aRetval.X()*nWdt/nHgt;
+ }
+ }
+ }
+ }
+ aRetval+=aCenter;
+ return aRetval;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrCircObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::CircleProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// DrawContact section
+
+sdr::contact::ViewContact* SdrCircObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfSdrCircObj(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrCircObj,SdrRectObj);
+
+SdrCircObj::SdrCircObj(SdrObjKind eNewKind)
+{
+ nStartWink=0;
+ nEndWink=36000;
+ meCircleKind=eNewKind;
+ bClosedObj=eNewKind!=OBJ_CARC;
+}
+
+SdrCircObj::SdrCircObj(SdrObjKind eNewKind, const Rectangle& rRect):
+ SdrRectObj(rRect)
+{
+ nStartWink=0;
+ nEndWink=36000;
+ meCircleKind=eNewKind;
+ bClosedObj=eNewKind!=OBJ_CARC;
+}
+
+SdrCircObj::SdrCircObj(SdrObjKind eNewKind, const Rectangle& rRect, long nNewStartWink, long nNewEndWink):
+ SdrRectObj(rRect)
+{
+ long nWinkDif=nNewEndWink-nNewStartWink;
+ nStartWink=NormAngle360(nNewStartWink);
+ nEndWink=NormAngle360(nNewEndWink);
+ if (nWinkDif==36000) nEndWink+=nWinkDif; // Vollkreis
+ meCircleKind=eNewKind;
+ bClosedObj=eNewKind!=OBJ_CARC;
+}
+
+SdrCircObj::~SdrCircObj()
+{
+}
+
+void SdrCircObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ bool bCanConv=!HasText() || ImpCanConvTextToCurve();
+ rInfo.bEdgeRadiusAllowed = FALSE;
+ rInfo.bCanConvToPath=bCanConv;
+ rInfo.bCanConvToPoly=bCanConv;
+ rInfo.bCanConvToContour = !IsFontwork() && (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
+}
+
+UINT16 SdrCircObj::GetObjIdentifier() const
+{
+ return UINT16(meCircleKind);
+}
+
+bool SdrCircObj::PaintNeedsXPolyCirc() const
+{
+ // XPoly ist notwendig fuer alle gedrehten Ellipsenobjekte,
+ // fuer alle Kreis- und Ellipsenabschnitte
+ // und wenn nicht WIN dann (erstmal) auch fuer Kreis-/Ellipsenausschnitte
+ // und Kreis-/Ellipsenboegen (wg. Genauigkeit)
+ bool bNeed=aGeo.nDrehWink!=0 || aGeo.nShearWink!=0 || meCircleKind==OBJ_CCUT;
+#ifndef WIN
+ // Wenn nicht Win, dann fuer alle ausser Vollkreis (erstmal!!!)
+ if (meCircleKind!=OBJ_CIRC) bNeed = true;
+#endif
+
+ const SfxItemSet& rSet = GetObjectItemSet();
+ if(!bNeed)
+ {
+ // XPoly ist notwendig fuer alles was nicht LineSolid oder LineNone ist
+ XLineStyle eLine = ((XLineStyleItem&)(rSet.Get(XATTR_LINESTYLE))).GetValue();
+ bNeed = eLine != XLINE_NONE && eLine != XLINE_SOLID;
+
+ // XPoly ist notwendig fuer dicke Linien
+ if(!bNeed && eLine != XLINE_NONE)
+ bNeed = ((XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue() != 0;
+
+ // XPoly ist notwendig fuer Kreisboegen mit Linienenden
+ if(!bNeed && meCircleKind == OBJ_CARC)
+ {
+ // Linienanfang ist da, wenn StartPolygon und StartWidth!=0
+ bNeed=((XLineStartItem&)(rSet.Get(XATTR_LINESTART))).GetLineStartValue().count() != 0L &&
+ ((XLineStartWidthItem&)(rSet.Get(XATTR_LINESTARTWIDTH))).GetValue() != 0;
+
+ if(!bNeed)
+ {
+ // Linienende ist da, wenn EndPolygon und EndWidth!=0
+ bNeed = ((XLineEndItem&)(rSet.Get(XATTR_LINEEND))).GetLineEndValue().count() != 0L &&
+ ((XLineEndWidthItem&)(rSet.Get(XATTR_LINEENDWIDTH))).GetValue() != 0;
+ }
+ }
+ }
+
+ // XPoly ist notwendig, wenn Fill !=None und !=Solid
+ if(!bNeed && meCircleKind != OBJ_CARC)
+ {
+ XFillStyle eFill=((XFillStyleItem&)(rSet.Get(XATTR_FILLSTYLE))).GetValue();
+ bNeed = eFill != XFILL_NONE && eFill != XFILL_SOLID;
+ }
+
+ if(!bNeed && meCircleKind != OBJ_CIRC && nStartWink == nEndWink)
+ bNeed = true; // Weil sonst Vollkreis gemalt wird
+
+ return bNeed;
+}
+
+basegfx::B2DPolygon SdrCircObj::ImpCalcXPolyCirc(const SdrObjKind eCicrleKind, const Rectangle& rRect1, long nStart, long nEnd) const
+{
+ const basegfx::B2DRange aRange(rRect1.Left(), rRect1.Top(), rRect1.Right(), rRect1.Bottom());
+ basegfx::B2DPolygon aCircPolygon;
+
+ if(OBJ_CIRC == eCicrleKind)
+ {
+ // create full circle. Do not use createPolygonFromEllipse; it's necessary
+ // to get the start point to the bottom of the circle to keep compatible to
+ // old geometry creation
+ aCircPolygon = basegfx::tools::createPolygonFromUnitCircle(1);
+
+ // needs own scaling and translation from unit circle to target size (same as
+ // would be in createPolygonFromEllipse)
+ const basegfx::B2DPoint aCenter(aRange.getCenter());
+ const basegfx::B2DHomMatrix aMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix(
+ aRange.getWidth() / 2.0, aRange.getHeight() / 2.0,
+ aCenter.getX(), aCenter.getY()));
+ aCircPolygon.transform(aMatrix);
+ }
+ else
+ {
+ // mirror start, end for geometry creation since model coordinate system is mirrored in Y
+ // #i111715# increase numerical correctness by first dividing and not using F_PI1800
+ const double fStart((((36000 - nEnd) % 36000) / 18000.0) * F_PI);
+ const double fEnd((((36000 - nStart) % 36000) / 18000.0) * F_PI);
+
+ // create circle segment. This is not closed by default
+ aCircPolygon = basegfx::tools::createPolygonFromEllipseSegment(
+ aRange.getCenter(), aRange.getWidth() / 2.0, aRange.getHeight() / 2.0,
+ fStart, fEnd);
+
+ // check closing states
+ const bool bCloseSegment(OBJ_CARC != eCicrleKind);
+ const bool bCloseUsingCenter(OBJ_SECT == eCicrleKind);
+
+ if(bCloseSegment)
+ {
+ if(bCloseUsingCenter)
+ {
+ // add center point at start (for historical reasons)
+ basegfx::B2DPolygon aSector;
+ aSector.append(aRange.getCenter());
+ aSector.append(aCircPolygon);
+ aCircPolygon = aSector;
+ }
+
+ // close
+ aCircPolygon.setClosed(true);
+ }
+ }
+
+ // #i76950#
+ if(aGeo.nShearWink || aGeo.nDrehWink)
+ {
+ // translate top left to (0,0)
+ const basegfx::B2DPoint aTopLeft(aRange.getMinimum());
+ basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix(
+ -aTopLeft.getX(), -aTopLeft.getY()));
+
+ // shear, rotate and back to top left (if needed)
+ aMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(
+ aGeo.nShearWink ? tan((36000 - aGeo.nShearWink) * F_PI18000) : 0.0,
+ aGeo.nDrehWink ? (36000 - aGeo.nDrehWink) * F_PI18000 : 0.0,
+ aTopLeft) * aMatrix;
+
+ // apply transformation
+ aCircPolygon.transform(aMatrix);
+ }
+
+ return aCircPolygon;
+}
+
+void SdrCircObj::RecalcXPoly()
+{
+ const basegfx::B2DPolygon aPolyCirc(ImpCalcXPolyCirc(meCircleKind, aRect, nStartWink, nEndWink));
+ mpXPoly = new XPolygon(aPolyCirc);
+}
+
+void SdrCircObj::TakeObjNameSingul(XubString& rName) const
+{
+ USHORT nID=STR_ObjNameSingulCIRC;
+ if (aRect.GetWidth()==aRect.GetHeight() && aGeo.nShearWink==0) {
+ switch (meCircleKind) {
+ case OBJ_CIRC: nID=STR_ObjNameSingulCIRC; break;
+ case OBJ_SECT: nID=STR_ObjNameSingulSECT; break;
+ case OBJ_CARC: nID=STR_ObjNameSingulCARC; break;
+ case OBJ_CCUT: nID=STR_ObjNameSingulCCUT; break;
+ default: break;
+ }
+ } else {
+ switch (meCircleKind) {
+ case OBJ_CIRC: nID=STR_ObjNameSingulCIRCE; break;
+ case OBJ_SECT: nID=STR_ObjNameSingulSECTE; break;
+ case OBJ_CARC: nID=STR_ObjNameSingulCARCE; break;
+ case OBJ_CCUT: nID=STR_ObjNameSingulCCUTE; break;
+ default: break;
+ }
+ }
+ rName=ImpGetResStr(nID);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+void SdrCircObj::TakeObjNamePlural(XubString& rName) const
+{
+ USHORT nID=STR_ObjNamePluralCIRC;
+ if (aRect.GetWidth()==aRect.GetHeight() && aGeo.nShearWink==0) {
+ switch (meCircleKind) {
+ case OBJ_CIRC: nID=STR_ObjNamePluralCIRC; break;
+ case OBJ_SECT: nID=STR_ObjNamePluralSECT; break;
+ case OBJ_CARC: nID=STR_ObjNamePluralCARC; break;
+ case OBJ_CCUT: nID=STR_ObjNamePluralCCUT; break;
+ default: break;
+ }
+ } else {
+ switch (meCircleKind) {
+ case OBJ_CIRC: nID=STR_ObjNamePluralCIRCE; break;
+ case OBJ_SECT: nID=STR_ObjNamePluralSECTE; break;
+ case OBJ_CARC: nID=STR_ObjNamePluralCARCE; break;
+ case OBJ_CCUT: nID=STR_ObjNamePluralCCUTE; break;
+ default: break;
+ }
+ }
+ rName=ImpGetResStr(nID);
+}
+
+void SdrCircObj::operator=(const SdrObject& rObj)
+{
+ SdrRectObj::operator=(rObj);
+
+ nStartWink = ((SdrCircObj&)rObj).nStartWink;
+ nEndWink = ((SdrCircObj&)rObj).nEndWink;
+}
+
+basegfx::B2DPolyPolygon SdrCircObj::TakeXorPoly() const
+{
+ const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, aRect, nStartWink, nEndWink));
+ return basegfx::B2DPolyPolygon(aCircPolygon);
+}
+
+struct ImpCircUser : public SdrDragStatUserData
+{
+ Rectangle aR;
+ Point aCenter;
+ Point aRadius;
+ Point aP1;
+ Point aP2;
+ long nMaxRad;
+ long nHgt;
+ long nWdt;
+ long nStart;
+ long nEnd;
+ long nWink;
+ bool bRight; // noch nicht implementiert
+
+public:
+ ImpCircUser()
+ : nMaxRad(0),
+ nHgt(0),
+ nWdt(0),
+ nStart(0),
+ nEnd(0),
+ bRight(FALSE)
+ {}
+ void SetCreateParams(SdrDragStat& rStat);
+};
+
+sal_uInt32 SdrCircObj::GetHdlCount() const
+{
+ if(OBJ_CIRC != meCircleKind)
+ {
+ return 10L;
+ }
+ else
+ {
+ return 8L;
+ }
+}
+
+SdrHdl* SdrCircObj::GetHdl(sal_uInt32 nHdlNum) const
+{
+ if (meCircleKind==OBJ_CIRC)
+ {
+ nHdlNum += 2L;
+ }
+
+ SdrHdl* pH = NULL;
+ Point aPnt;
+ SdrHdlKind eLocalKind(HDL_MOVE);
+ sal_uInt32 nPNum(0);
+
+ switch (nHdlNum)
+ {
+ case 0:
+ aPnt = GetWinkPnt(aRect,nStartWink);
+ eLocalKind = HDL_CIRC;
+ nPNum = 1;
+ break;
+ case 1:
+ aPnt = GetWinkPnt(aRect,nEndWink);
+ eLocalKind = HDL_CIRC;
+ nPNum = 2L;
+ break;
+ case 2:
+ aPnt = aRect.TopLeft();
+ eLocalKind = HDL_UPLFT;
+ break;
+ case 3:
+ aPnt = aRect.TopCenter();
+ eLocalKind = HDL_UPPER;
+ break;
+ case 4:
+ aPnt = aRect.TopRight();
+ eLocalKind = HDL_UPRGT;
+ break;
+ case 5:
+ aPnt = aRect.LeftCenter();
+ eLocalKind = HDL_LEFT;
+ break;
+ case 6:
+ aPnt = aRect.RightCenter();
+ eLocalKind = HDL_RIGHT;
+ break;
+ case 7:
+ aPnt = aRect.BottomLeft();
+ eLocalKind = HDL_LWLFT;
+ break;
+ case 8:
+ aPnt = aRect.BottomCenter();
+ eLocalKind = HDL_LOWER;
+ break;
+ case 9:
+ aPnt = aRect.BottomRight();
+ eLocalKind = HDL_LWRGT;
+ break;
+ }
+
+ if (aGeo.nShearWink)
+ {
+ ShearPoint(aPnt,aRect.TopLeft(),aGeo.nTan);
+ }
+
+ if (aGeo.nDrehWink)
+ {
+ RotatePoint(aPnt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ }
+
+ if (eLocalKind != HDL_MOVE)
+ {
+ pH = new SdrHdl(aPnt,eLocalKind);
+ pH->SetPointNum(nPNum);
+ pH->SetObj((SdrObject*)this);
+ pH->SetDrehWink(aGeo.nDrehWink);
+ }
+
+ return pH;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrCircObj::hasSpecialDrag() const
+{
+ return true;
+}
+
+bool SdrCircObj::beginSpecialDrag(SdrDragStat& rDrag) const
+{
+ const bool bWink(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind());
+
+ if(bWink)
+ {
+ if(1 == rDrag.GetHdl()->GetPointNum() || 2 == rDrag.GetHdl()->GetPointNum())
+ {
+ rDrag.SetNoSnap(true);
+ }
+
+ return true;
+ }
+
+ return SdrTextObj::beginSpecialDrag(rDrag);
+}
+
+bool SdrCircObj::applySpecialDrag(SdrDragStat& rDrag)
+{
+ const bool bWink(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind());
+
+ if(bWink)
+ {
+ Point aPt(rDrag.GetNow());
+
+ if (aGeo.nDrehWink!=0)
+ RotatePoint(aPt,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos);
+
+ if (aGeo.nShearWink!=0)
+ ShearPoint(aPt,aRect.TopLeft(),-aGeo.nTan);
+
+ aPt-=aRect.Center();
+
+ long nWdt=aRect.Right()-aRect.Left();
+ long nHgt=aRect.Bottom()-aRect.Top();
+
+ if(nWdt>=nHgt)
+ {
+ aPt.Y()=BigMulDiv(aPt.Y(),nWdt,nHgt);
+ }
+ else
+ {
+ aPt.X()=BigMulDiv(aPt.X(),nHgt,nWdt);
+ }
+
+ long nWink=NormAngle360(GetAngle(aPt));
+
+ if (rDrag.GetView() && rDrag.GetView()->IsAngleSnapEnabled())
+ {
+ long nSA=rDrag.GetView()->GetSnapAngle();
+
+ if (nSA!=0)
+ {
+ nWink+=nSA/2;
+ nWink/=nSA;
+ nWink*=nSA;
+ nWink=NormAngle360(nWink);
+ }
+ }
+
+ if(1 == rDrag.GetHdl()->GetPointNum())
+ {
+ nStartWink = nWink;
+ }
+ else if(2 == rDrag.GetHdl()->GetPointNum())
+ {
+ nEndWink = nWink;
+ }
+
+ SetRectsDirty();
+ SetXPolyDirty();
+ ImpSetCircInfoToAttr();
+ SetChanged();
+
+ return true;
+ }
+ else
+ {
+ return SdrTextObj::applySpecialDrag(rDrag);
+ }
+}
+
+String SdrCircObj::getSpecialDragComment(const SdrDragStat& rDrag) const
+{
+ const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj());
+
+ if(bCreateComment)
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_ViewCreateObj, aStr);
+ const sal_uInt32 nPntAnz(rDrag.GetPointAnz());
+
+ if(OBJ_CIRC != meCircleKind && nPntAnz > 2)
+ {
+ ImpCircUser* pU = (ImpCircUser*)rDrag.GetUser();
+ sal_Int32 nWink;
+
+ aStr.AppendAscii(" (");
+
+ if(3 == nPntAnz)
+ {
+ nWink = pU->nStart;
+ }
+ else
+ {
+ nWink = pU->nEnd;
+ }
+
+ aStr += GetWinkStr(nWink,FALSE);
+ aStr += sal_Unicode(')');
+ }
+
+ return aStr;
+ }
+ else
+ {
+ const bool bWink(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind());
+
+ if(bWink)
+ {
+ XubString aStr;
+ const sal_Int32 nWink(1 == rDrag.GetHdl()->GetPointNum() ? nStartWink : nEndWink);
+
+ ImpTakeDescriptionStr(STR_DragCircAngle, aStr);
+ aStr.AppendAscii(" (");
+ aStr += GetWinkStr(nWink,FALSE);
+ aStr += sal_Unicode(')');
+
+ return aStr;
+ }
+ else
+ {
+ return SdrTextObj::getSpecialDragComment(rDrag);
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ImpCircUser::SetCreateParams(SdrDragStat& rStat)
+{
+ rStat.TakeCreateRect(aR);
+ aR.Justify();
+ aCenter=aR.Center();
+ nWdt=aR.Right()-aR.Left();
+ nHgt=aR.Bottom()-aR.Top();
+ nMaxRad=((nWdt>nHgt ? nWdt : nHgt)+1) /2;
+ nStart=0;
+ nEnd=36000;
+ if (rStat.GetPointAnz()>2) {
+ Point aP(rStat.GetPoint(2)-aCenter);
+ if (nWdt==0) aP.X()=0;
+ if (nHgt==0) aP.Y()=0;
+ if (nWdt>=nHgt) {
+ if (nHgt!=0) aP.Y()=aP.Y()*nWdt/nHgt;
+ } else {
+ if (nWdt!=0) aP.X()=aP.X()*nHgt/nWdt;
+ }
+ nStart=NormAngle360(GetAngle(aP));
+ if (rStat.GetView()!=NULL && rStat.GetView()->IsAngleSnapEnabled()) {
+ long nSA=rStat.GetView()->GetSnapAngle();
+ if (nSA!=0) { // Winkelfang
+ nStart+=nSA/2;
+ nStart/=nSA;
+ nStart*=nSA;
+ nStart=NormAngle360(nStart);
+ }
+ }
+ aP1 = GetWinkPnt(aR,nStart);
+ nEnd=nStart;
+ aP2=aP1;
+ } else aP1=aCenter;
+ if (rStat.GetPointAnz()>3) {
+ Point aP(rStat.GetPoint(3)-aCenter);
+ if (nWdt>=nHgt) {
+ aP.Y()=BigMulDiv(aP.Y(),nWdt,nHgt);
+ } else {
+ aP.X()=BigMulDiv(aP.X(),nHgt,nWdt);
+ }
+ nEnd=NormAngle360(GetAngle(aP));
+ if (rStat.GetView()!=NULL && rStat.GetView()->IsAngleSnapEnabled()) {
+ long nSA=rStat.GetView()->GetSnapAngle();
+ if (nSA!=0) { // Winkelfang
+ nEnd+=nSA/2;
+ nEnd/=nSA;
+ nEnd*=nSA;
+ nEnd=NormAngle360(nEnd);
+ }
+ }
+ aP2 = GetWinkPnt(aR,nEnd);
+ } else aP2=aCenter;
+}
+
+void SdrCircObj::ImpSetCreateParams(SdrDragStat& rStat) const
+{
+ ImpCircUser* pU=(ImpCircUser*)rStat.GetUser();
+ if (pU==NULL) {
+ pU=new ImpCircUser;
+ rStat.SetUser(pU);
+ }
+ pU->SetCreateParams(rStat);
+}
+
+bool SdrCircObj::BegCreate(SdrDragStat& rStat)
+{
+ rStat.SetOrtho4Possible();
+ Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
+ aRect1.Justify();
+ rStat.SetActionRect(aRect1);
+ aRect = aRect1;
+ ImpSetCreateParams(rStat);
+ return TRUE;
+}
+
+bool SdrCircObj::MovCreate(SdrDragStat& rStat)
+{
+ ImpSetCreateParams(rStat);
+ ImpCircUser* pU=(ImpCircUser*)rStat.GetUser();
+ rStat.SetActionRect(pU->aR);
+ aRect=pU->aR; // fuer ObjName
+ ImpJustifyRect(aRect);
+ nStartWink=pU->nStart;
+ nEndWink=pU->nEnd;
+ SetBoundRectDirty();
+ bSnapRectDirty=TRUE;
+ SetXPolyDirty();
+
+ // #i103058# push current angle settings to ItemSet to
+ // allow FullDrag visualisation
+ if(rStat.GetPointAnz() >= 4)
+ {
+ ImpSetCircInfoToAttr();
+ }
+
+ return TRUE;
+}
+
+bool SdrCircObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ ImpSetCreateParams(rStat);
+ ImpCircUser* pU=(ImpCircUser*)rStat.GetUser();
+ bool bRet = false;
+ if (eCmd==SDRCREATE_FORCEEND && rStat.GetPointAnz()<4) meCircleKind=OBJ_CIRC;
+ if (meCircleKind==OBJ_CIRC) {
+ bRet=rStat.GetPointAnz()>=2;
+ if (bRet) {
+ aRect=pU->aR;
+ ImpJustifyRect(aRect);
+ }
+ } else {
+ rStat.SetNoSnap(rStat.GetPointAnz()>=2);
+ rStat.SetOrtho4Possible(rStat.GetPointAnz()<2);
+ bRet=rStat.GetPointAnz()>=4;
+ if (bRet) {
+ aRect=pU->aR;
+ ImpJustifyRect(aRect);
+ nStartWink=pU->nStart;
+ nEndWink=pU->nEnd;
+ }
+ }
+ bClosedObj=meCircleKind!=OBJ_CARC;
+ SetRectsDirty();
+ SetXPolyDirty();
+ ImpSetCircInfoToAttr();
+ if (bRet) {
+ delete pU;
+ rStat.SetUser(NULL);
+ }
+ return bRet;
+}
+
+void SdrCircObj::BrkCreate(SdrDragStat& rStat)
+{
+ ImpCircUser* pU=(ImpCircUser*)rStat.GetUser();
+ delete pU;
+ rStat.SetUser(NULL);
+}
+
+bool SdrCircObj::BckCreate(SdrDragStat& rStat)
+{
+ rStat.SetNoSnap(rStat.GetPointAnz()>=3);
+ rStat.SetOrtho4Possible(rStat.GetPointAnz()<3);
+ return meCircleKind!=OBJ_CIRC;
+}
+
+basegfx::B2DPolyPolygon SdrCircObj::TakeCreatePoly(const SdrDragStat& rDrag) const
+{
+ ImpCircUser* pU = (ImpCircUser*)rDrag.GetUser();
+
+ if(rDrag.GetPointAnz() < 4L)
+ {
+ // force to OBJ_CIRC to get full visualisation
+ basegfx::B2DPolyPolygon aRetval(ImpCalcXPolyCirc(OBJ_CIRC, pU->aR, pU->nStart, pU->nEnd));
+
+ if(3L == rDrag.GetPointAnz())
+ {
+ // add edge to first point on ellipse
+ basegfx::B2DPolygon aNew;
+
+ aNew.append(basegfx::B2DPoint(pU->aCenter.X(), pU->aCenter.Y()));
+ aNew.append(basegfx::B2DPoint(pU->aP1.X(), pU->aP1.Y()));
+ aRetval.append(aNew);
+ }
+
+ return aRetval;
+ }
+ else
+ {
+ return basegfx::B2DPolyPolygon(ImpCalcXPolyCirc(meCircleKind, pU->aR, pU->nStart, pU->nEnd));
+ }
+}
+
+Pointer SdrCircObj::GetCreatePointer() const
+{
+ switch (meCircleKind) {
+ case OBJ_CIRC: return Pointer(POINTER_DRAW_ELLIPSE);
+ case OBJ_SECT: return Pointer(POINTER_DRAW_PIE);
+ case OBJ_CARC: return Pointer(POINTER_DRAW_ARC);
+ case OBJ_CCUT: return Pointer(POINTER_DRAW_CIRCLECUT);
+ default: break;
+ } // switch
+ return Pointer(POINTER_CROSS);
+}
+
+void SdrCircObj::NbcMove(const Size& aSiz)
+{
+ MoveRect(aRect,aSiz);
+ MoveRect(aOutRect,aSiz);
+ MoveRect(maSnapRect,aSiz);
+ SetXPolyDirty();
+ SetRectsDirty(sal_True);
+}
+
+void SdrCircObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ long nWink0=aGeo.nDrehWink;
+ bool bNoShearRota=(aGeo.nDrehWink==0 && aGeo.nShearWink==0);
+ SdrTextObj::NbcResize(rRef,xFact,yFact);
+ bNoShearRota|=(aGeo.nDrehWink==0 && aGeo.nShearWink==0);
+ if (meCircleKind!=OBJ_CIRC) {
+ bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
+ bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
+ if (bXMirr || bYMirr) {
+ // bei bXMirr!=bYMirr muessten eigentlich noch die beiden
+ // Linienende vertauscht werden. Das ist jedoch mal wieder
+ // schlecht (wg. zwangslaeufiger harter Formatierung).
+ // Alternativ koennte ein bMirrored-Flag eingefuehrt werden
+ // (Vielleicht ja mal grundsaetzlich, auch fuer gepiegelten Text, ...).
+ long nS0=nStartWink;
+ long nE0=nEndWink;
+ if (bNoShearRota) {
+ // Das RectObj spiegelt bei VMirror bereits durch durch 180deg Drehung.
+ if (! (bXMirr && bYMirr)) {
+ long nTmp=nS0;
+ nS0=18000-nE0;
+ nE0=18000-nTmp;
+ }
+ } else { // Spiegeln fuer verzerrte Ellipsen
+ if (bXMirr!=bYMirr) {
+ nS0+=nWink0;
+ nE0+=nWink0;
+ if (bXMirr) {
+ long nTmp=nS0;
+ nS0=18000-nE0;
+ nE0=18000-nTmp;
+ }
+ if (bYMirr) {
+ long nTmp=nS0;
+ nS0=-nE0;
+ nE0=-nTmp;
+ }
+ nS0-=aGeo.nDrehWink;
+ nE0-=aGeo.nDrehWink;
+ }
+ }
+ long nWinkDif=nE0-nS0;
+ nStartWink=NormAngle360(nS0);
+ nEndWink =NormAngle360(nE0);
+ if (nWinkDif==36000) nEndWink+=nWinkDif; // Vollkreis
+ }
+ }
+ SetXPolyDirty();
+ ImpSetCircInfoToAttr();
+}
+
+void SdrCircObj::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ SdrTextObj::NbcShear(rRef,nWink,tn,bVShear);
+ SetXPolyDirty();
+ ImpSetCircInfoToAttr();
+}
+
+void SdrCircObj::NbcMirror(const Point& rRef1, const Point& rRef2)
+{
+ //long nWink0=aGeo.nDrehWink;
+ bool bFreeMirr=meCircleKind!=OBJ_CIRC;
+ Point aTmpPt1;
+ Point aTmpPt2;
+ if (bFreeMirr) { // bei freier Spiegelachse einige Vorbereitungen Treffen
+ Point aCenter(aRect.Center());
+ long nWdt=aRect.GetWidth()-1;
+ long nHgt=aRect.GetHeight()-1;
+ long nMaxRad=((nWdt>nHgt ? nWdt : nHgt)+1) /2;
+ double a;
+ // Startpunkt
+ a=nStartWink*nPi180;
+ aTmpPt1=Point(Round(cos(a)*nMaxRad),-Round(sin(a)*nMaxRad));
+ if (nWdt==0) aTmpPt1.X()=0;
+ if (nHgt==0) aTmpPt1.Y()=0;
+ aTmpPt1+=aCenter;
+ // Endpunkt
+ a=nEndWink*nPi180;
+ aTmpPt2=Point(Round(cos(a)*nMaxRad),-Round(sin(a)*nMaxRad));
+ if (nWdt==0) aTmpPt2.X()=0;
+ if (nHgt==0) aTmpPt2.Y()=0;
+ aTmpPt2+=aCenter;
+ if (aGeo.nDrehWink!=0) {
+ RotatePoint(aTmpPt1,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ RotatePoint(aTmpPt2,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ }
+ if (aGeo.nShearWink!=0) {
+ ShearPoint(aTmpPt1,aRect.TopLeft(),aGeo.nTan);
+ ShearPoint(aTmpPt2,aRect.TopLeft(),aGeo.nTan);
+ }
+ }
+ SdrTextObj::NbcMirror(rRef1,rRef2);
+ if (meCircleKind!=OBJ_CIRC) { // Anpassung von Start- und Endwinkel
+ MirrorPoint(aTmpPt1,rRef1,rRef2);
+ MirrorPoint(aTmpPt2,rRef1,rRef2);
+ // Unrotate:
+ if (aGeo.nDrehWink!=0) {
+ RotatePoint(aTmpPt1,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos); // -sin fuer Umkehrung
+ RotatePoint(aTmpPt2,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos); // -sin fuer Umkehrung
+ }
+ // Unshear:
+ if (aGeo.nShearWink!=0) {
+ ShearPoint(aTmpPt1,aRect.TopLeft(),-aGeo.nTan); // -tan fuer Umkehrung
+ ShearPoint(aTmpPt2,aRect.TopLeft(),-aGeo.nTan); // -tan fuer Umkehrung
+ }
+ Point aCenter(aRect.Center());
+ aTmpPt1-=aCenter;
+ aTmpPt2-=aCenter;
+ // Weil gespiegelt sind die Winkel nun auch noch vertauscht
+ nStartWink=GetAngle(aTmpPt2);
+ nEndWink =GetAngle(aTmpPt1);
+ long nWinkDif=nEndWink-nStartWink;
+ nStartWink=NormAngle360(nStartWink);
+ nEndWink =NormAngle360(nEndWink);
+ if (nWinkDif==36000) nEndWink+=nWinkDif; // Vollkreis
+ }
+ SetXPolyDirty();
+ ImpSetCircInfoToAttr();
+}
+
+SdrObjGeoData* SdrCircObj::NewGeoData() const
+{
+ return new SdrCircObjGeoData;
+}
+
+void SdrCircObj::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ SdrRectObj::SaveGeoData(rGeo);
+ SdrCircObjGeoData& rCGeo=(SdrCircObjGeoData&)rGeo;
+ rCGeo.nStartWink=nStartWink;
+ rCGeo.nEndWink =nEndWink;
+}
+
+void SdrCircObj::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ SdrRectObj::RestGeoData(rGeo);
+ SdrCircObjGeoData& rCGeo=(SdrCircObjGeoData&)rGeo;
+ nStartWink=rCGeo.nStartWink;
+ nEndWink =rCGeo.nEndWink;
+ SetXPolyDirty();
+ ImpSetCircInfoToAttr();
+}
+
+void Union(Rectangle& rR, const Point& rP)
+{
+ if (rP.X()<rR.Left ()) rR.Left ()=rP.X();
+ if (rP.X()>rR.Right ()) rR.Right ()=rP.X();
+ if (rP.Y()<rR.Top ()) rR.Top ()=rP.Y();
+ if (rP.Y()>rR.Bottom()) rR.Bottom()=rP.Y();
+}
+
+void SdrCircObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
+{
+ rRect=aRect;
+ if (meCircleKind!=OBJ_CIRC) {
+ const Point aPntStart(GetWinkPnt(aRect,nStartWink));
+ const Point aPntEnd(GetWinkPnt(aRect,nEndWink));
+ long a=nStartWink;
+ long e=nEndWink;
+ rRect.Left ()=aRect.Right();
+ rRect.Right ()=aRect.Left();
+ rRect.Top ()=aRect.Bottom();
+ rRect.Bottom()=aRect.Top();
+ Union(rRect,aPntStart);
+ Union(rRect,aPntEnd);
+ if ((a<=18000 && e>=18000) || (a>e && (a<=18000 || e>=18000))) {
+ Union(rRect,aRect.LeftCenter());
+ }
+ if ((a<=27000 && e>=27000) || (a>e && (a<=27000 || e>=27000))) {
+ Union(rRect,aRect.BottomCenter());
+ }
+ if (a>e) {
+ Union(rRect,aRect.RightCenter());
+ }
+ if ((a<=9000 && e>=9000) || (a>e && (a<=9000 || e>=9000))) {
+ Union(rRect,aRect.TopCenter());
+ }
+ if (meCircleKind==OBJ_SECT) {
+ Union(rRect,aRect.Center());
+ }
+ if (aGeo.nDrehWink!=0) {
+ Point aDst(rRect.TopLeft());
+ aDst-=aRect.TopLeft();
+ Point aDst0(aDst);
+ RotatePoint(aDst,Point(),aGeo.nSin,aGeo.nCos);
+ aDst-=aDst0;
+ rRect.Move(aDst.X(),aDst.Y());
+ }
+ }
+ if (aGeo.nShearWink!=0) {
+ long nDst=Round((rRect.Bottom()-rRect.Top())*aGeo.nTan);
+ if (aGeo.nShearWink>0) {
+ Point aRef(rRect.TopLeft());
+ rRect.Left()-=nDst;
+ Point aTmpPt(rRect.TopLeft());
+ RotatePoint(aTmpPt,aRef,aGeo.nSin,aGeo.nCos);
+ aTmpPt-=rRect.TopLeft();
+ rRect.Move(aTmpPt.X(),aTmpPt.Y());
+ } else {
+ rRect.Right()-=nDst;
+ }
+ }
+}
+
+void SdrCircObj::RecalcSnapRect()
+{
+ if (PaintNeedsXPolyCirc()) {
+ maSnapRect=GetXPoly().GetBoundRect();
+ } else {
+ TakeUnrotatedSnapRect(maSnapRect);
+ }
+}
+
+void SdrCircObj::NbcSetSnapRect(const Rectangle& rRect)
+{
+ if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0 || meCircleKind!=OBJ_CIRC) {
+ Rectangle aSR0(GetSnapRect());
+ long nWdt0=aSR0.Right()-aSR0.Left();
+ long nHgt0=aSR0.Bottom()-aSR0.Top();
+ long nWdt1=rRect.Right()-rRect.Left();
+ long nHgt1=rRect.Bottom()-rRect.Top();
+ NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0));
+ NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top()));
+ } else {
+ aRect=rRect;
+ ImpJustifyRect(aRect);
+ }
+ SetRectsDirty();
+ SetXPolyDirty();
+ ImpSetCircInfoToAttr();
+}
+
+sal_uInt32 SdrCircObj::GetSnapPointCount() const
+{
+ if (meCircleKind==OBJ_CIRC) {
+ return 1L;
+ } else {
+ return 3L;
+ }
+}
+
+Point SdrCircObj::GetSnapPoint(sal_uInt32 i) const
+{
+ switch (i) {
+ case 1 : return GetWinkPnt(aRect,nStartWink);
+ case 2 : return GetWinkPnt(aRect,nEndWink);
+ default: return aRect.Center();
+ }
+}
+
+void __EXPORT SdrCircObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+{
+ SetXPolyDirty();
+ SdrRectObj::Notify(rBC,rHint);
+ ImpSetAttrToCircInfo();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrCircObj::ImpSetAttrToCircInfo()
+{
+ const SfxItemSet& rSet = GetObjectItemSet();
+ SdrCircKind eNewKindA = ((SdrCircKindItem&)rSet.Get(SDRATTR_CIRCKIND)).GetValue();
+ SdrObjKind eNewKind = meCircleKind;
+
+ if(eNewKindA == SDRCIRC_FULL)
+ eNewKind = OBJ_CIRC;
+ else if(eNewKindA == SDRCIRC_SECT)
+ eNewKind = OBJ_SECT;
+ else if(eNewKindA == SDRCIRC_ARC)
+ eNewKind = OBJ_CARC;
+ else if(eNewKindA == SDRCIRC_CUT)
+ eNewKind = OBJ_CCUT;
+
+ sal_Int32 nNewStart = ((SdrCircStartAngleItem&)rSet.Get(SDRATTR_CIRCSTARTANGLE)).GetValue();
+ sal_Int32 nNewEnd = ((SdrCircEndAngleItem&)rSet.Get(SDRATTR_CIRCENDANGLE)).GetValue();
+
+ BOOL bKindChg = meCircleKind != eNewKind;
+ BOOL bWinkChg = nNewStart != nStartWink || nNewEnd != nEndWink;
+
+ if(bKindChg || bWinkChg)
+ {
+ meCircleKind = eNewKind;
+ nStartWink = nNewStart;
+ nEndWink = nNewEnd;
+
+ if(bKindChg || (meCircleKind != OBJ_CIRC && bWinkChg))
+ {
+ SetXPolyDirty();
+ SetRectsDirty();
+ }
+ }
+}
+
+void SdrCircObj::ImpSetCircInfoToAttr()
+{
+ SdrCircKind eNewKindA = SDRCIRC_FULL;
+ const SfxItemSet& rSet = GetObjectItemSet();
+
+ if(meCircleKind == OBJ_SECT)
+ eNewKindA = SDRCIRC_SECT;
+ else if(meCircleKind == OBJ_CARC)
+ eNewKindA = SDRCIRC_ARC;
+ else if(meCircleKind == OBJ_CCUT)
+ eNewKindA = SDRCIRC_CUT;
+
+ SdrCircKind eOldKindA = ((SdrCircKindItem&)rSet.Get(SDRATTR_CIRCKIND)).GetValue();
+ sal_Int32 nOldStartWink = ((SdrCircStartAngleItem&)rSet.Get(SDRATTR_CIRCSTARTANGLE)).GetValue();
+ sal_Int32 nOldEndWink = ((SdrCircEndAngleItem&)rSet.Get(SDRATTR_CIRCENDANGLE)).GetValue();
+
+ if(eNewKindA != eOldKindA || nStartWink != nOldStartWink || nEndWink != nOldEndWink)
+ {
+ // #81921# since SetItem() implicitly calls ImpSetAttrToCircInfo()
+ // setting the item directly is necessary here.
+ if(eNewKindA != eOldKindA)
+ {
+ GetProperties().SetObjectItemDirect(SdrCircKindItem(eNewKindA));
+ }
+
+ if(nStartWink != nOldStartWink)
+ {
+ GetProperties().SetObjectItemDirect(SdrCircStartAngleItem(nStartWink));
+ }
+
+ if(nEndWink != nOldEndWink)
+ {
+ GetProperties().SetObjectItemDirect(SdrCircEndAngleItem(nEndWink));
+ }
+
+ SetXPolyDirty();
+ ImpSetAttrToCircInfo();
+ }
+}
+
+SdrObject* SdrCircObj::DoConvertToPolyObj(BOOL bBezier) const
+{
+ const sal_Bool bFill(OBJ_CARC == meCircleKind ? sal_False : sal_True);
+ const basegfx::B2DPolygon aCircPolygon(ImpCalcXPolyCirc(meCircleKind, aRect, nStartWink, nEndWink));
+ SdrObject* pRet = ImpConvertMakeObj(basegfx::B2DPolyPolygon(aCircPolygon), bFill, bBezier);
+ pRet = ImpConvertAddText(pRet, bBezier);
+
+ return pRet;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx
new file mode 100644
index 000000000000..f31be538c147
--- /dev/null
+++ b/svx/source/svdraw/svdoedge.cxx
@@ -0,0 +1,2497 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdoedge.hxx>
+#include <svx/xpool.hxx>
+#include <svx/xpoly.hxx>
+#include <svx/svdattrx.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svddrag.hxx>
+#include <svx/svddrgv.hxx>
+#include "svddrgm1.hxx"
+#include <svx/svdhdl.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdetc.hxx>
+#include "svdglob.hxx" // StringCache
+#include "svdstr.hrc" // Objektname
+#include <svl/style.hxx>
+#include <svl/smplhint.hxx>
+#include <editeng/eeitem.hxx>
+#include "svdoimp.hxx"
+#include <svx/sdr/properties/connectorproperties.hxx>
+#include <svx/sdr/contact/viewcontactofsdredgeobj.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdrhittesthelper.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrObjConnection::~SdrObjConnection()
+{
+}
+
+void SdrObjConnection::ResetVars()
+{
+ pObj=NULL;
+ nConId=0;
+ nXDist=0;
+ nYDist=0;
+ bBestConn=TRUE;
+ bBestVertex=TRUE;
+ bXDistOvr=FALSE;
+ bYDistOvr=FALSE;
+ bAutoVertex=FALSE;
+ bAutoCorner=FALSE;
+}
+
+bool SdrObjConnection::TakeGluePoint(SdrGluePoint& rGP, bool bSetAbsPos) const
+{
+ bool bRet = false;
+ if (pObj!=NULL) { // Ein Obj muss schon angedockt sein!
+ if (bAutoVertex) {
+ rGP=pObj->GetVertexGluePoint(nConId);
+ bRet = true;
+ } else if (bAutoCorner) {
+ rGP=pObj->GetCornerGluePoint(nConId);
+ bRet = true;
+ } else {
+ const SdrGluePointList* pGPL=pObj->GetGluePointList();
+ if (pGPL!=NULL) {
+ USHORT nNum=pGPL->FindGluePoint(nConId);
+ if (nNum!=SDRGLUEPOINT_NOTFOUND) {
+ rGP=(*pGPL)[nNum];
+ bRet = true;
+ }
+ }
+ }
+ }
+ if (bRet && bSetAbsPos) {
+ Point aPt(rGP.GetAbsolutePos(*pObj));
+ aPt+=aObjOfs;
+ rGP.SetPos(aPt);
+ }
+ return bRet;
+}
+
+Point& SdrEdgeInfoRec::ImpGetLineVersatzPoint(SdrEdgeLineCode eLineCode)
+{
+ switch (eLineCode) {
+ case OBJ1LINE2 : return aObj1Line2;
+ case OBJ1LINE3 : return aObj1Line3;
+ case OBJ2LINE2 : return aObj2Line2;
+ case OBJ2LINE3 : return aObj2Line3;
+ case MIDDLELINE: return aMiddleLine;
+ } // switch
+ return aMiddleLine;
+}
+
+USHORT SdrEdgeInfoRec::ImpGetPolyIdx(SdrEdgeLineCode eLineCode, const XPolygon& rXP) const
+{
+ switch (eLineCode) {
+ case OBJ1LINE2 : return 1;
+ case OBJ1LINE3 : return 2;
+ case OBJ2LINE2 : return rXP.GetPointCount()-3;
+ case OBJ2LINE3 : return rXP.GetPointCount()-4;
+ case MIDDLELINE: return nMiddleLine;
+ } // switch
+ return 0;
+}
+
+bool SdrEdgeInfoRec::ImpIsHorzLine(SdrEdgeLineCode eLineCode, const XPolygon& rXP) const
+{
+ USHORT nIdx=ImpGetPolyIdx(eLineCode,rXP);
+ bool bHorz=nAngle1==0 || nAngle1==18000;
+ if (eLineCode==OBJ2LINE2 || eLineCode==OBJ2LINE3) {
+ nIdx=rXP.GetPointCount()-nIdx; // #36314#
+ bHorz=nAngle2==0 || nAngle2==18000; // #52000#
+ }
+ if ((nIdx & 1)==1) bHorz=!bHorz;
+ return bHorz;
+}
+
+void SdrEdgeInfoRec::ImpSetLineVersatz(SdrEdgeLineCode eLineCode, const XPolygon& rXP, long nVal)
+{
+ Point& rPt=ImpGetLineVersatzPoint(eLineCode);
+ if (ImpIsHorzLine(eLineCode,rXP)) rPt.Y()=nVal;
+ else rPt.X()=nVal;
+}
+
+long SdrEdgeInfoRec::ImpGetLineVersatz(SdrEdgeLineCode eLineCode, const XPolygon& rXP) const
+{
+ const Point& rPt=ImpGetLineVersatzPoint(eLineCode);
+ if (ImpIsHorzLine(eLineCode,rXP)) return rPt.Y();
+ else return rPt.X();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrEdgeObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::ConnectorProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// DrawContact section
+
+sdr::contact::ViewContact* SdrEdgeObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfSdrEdgeObj(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrEdgeObj,SdrTextObj);
+
+SdrEdgeObj::SdrEdgeObj()
+: SdrTextObj(),
+ nNotifyingCount(0),
+ bEdgeTrackDirty(sal_False),
+ bEdgeTrackUserDefined(sal_False),
+ // #109007# Default is to allow default connects
+ mbSuppressDefaultConnect(sal_False),
+ // #110649#
+ mbBoundRectCalculationRunning(sal_False)
+{
+ bClosedObj=FALSE;
+ bIsEdge=TRUE;
+ pEdgeTrack=new XPolygon;
+
+}
+
+SdrEdgeObj::~SdrEdgeObj()
+{
+ DisconnectFromNode(TRUE);
+ DisconnectFromNode(FALSE);
+ delete pEdgeTrack;
+}
+
+void SdrEdgeObj::ImpSetAttrToEdgeInfo()
+{
+ const SfxItemSet& rSet = GetObjectItemSet();
+ SdrEdgeKind eKind = ((SdrEdgeKindItem&)(rSet.Get(SDRATTR_EDGEKIND))).GetValue();
+ sal_Int32 nVal1 = ((SdrEdgeLine1DeltaItem&)rSet.Get(SDRATTR_EDGELINE1DELTA)).GetValue();
+ sal_Int32 nVal2 = ((SdrEdgeLine2DeltaItem&)rSet.Get(SDRATTR_EDGELINE2DELTA)).GetValue();
+ sal_Int32 nVal3 = ((SdrEdgeLine3DeltaItem&)rSet.Get(SDRATTR_EDGELINE3DELTA)).GetValue();
+
+ if(eKind == SDREDGE_ORTHOLINES || eKind == SDREDGE_BEZIER)
+ {
+ sal_Int32 nVals[3] = { nVal1, nVal2, nVal3 };
+ sal_uInt16 n = 0;
+
+ if(aEdgeInfo.nObj1Lines >= 2 && n < 3)
+ {
+ aEdgeInfo.ImpSetLineVersatz(OBJ1LINE2, *pEdgeTrack, nVals[n]);
+ n++;
+ }
+
+ if(aEdgeInfo.nObj1Lines >= 3 && n < 3)
+ {
+ aEdgeInfo.ImpSetLineVersatz(OBJ1LINE3, *pEdgeTrack, nVals[n]);
+ n++;
+ }
+
+ if(aEdgeInfo.nMiddleLine != 0xFFFF && n < 3)
+ {
+ aEdgeInfo.ImpSetLineVersatz(MIDDLELINE, *pEdgeTrack, nVals[n]);
+ n++;
+ }
+
+ if(aEdgeInfo.nObj2Lines >= 3 && n < 3)
+ {
+ aEdgeInfo.ImpSetLineVersatz(OBJ2LINE3, *pEdgeTrack, nVals[n]);
+ n++;
+ }
+
+ if(aEdgeInfo.nObj2Lines >= 2 && n < 3)
+ {
+ aEdgeInfo.ImpSetLineVersatz(OBJ2LINE2, *pEdgeTrack, nVals[n]);
+ n++;
+ }
+ }
+ else if(eKind == SDREDGE_THREELINES)
+ {
+ BOOL bHor1 = aEdgeInfo.nAngle1 == 0 || aEdgeInfo.nAngle1 == 18000;
+ BOOL bHor2 = aEdgeInfo.nAngle2 == 0 || aEdgeInfo.nAngle2 == 18000;
+
+ if(bHor1)
+ {
+ aEdgeInfo.aObj1Line2.X() = nVal1;
+ }
+ else
+ {
+ aEdgeInfo.aObj1Line2.Y() = nVal1;
+ }
+
+ if(bHor2)
+ {
+ aEdgeInfo.aObj2Line2.X() = nVal2;
+ }
+ else
+ {
+ aEdgeInfo.aObj2Line2.Y() = nVal2;
+ }
+ }
+
+ // #84649#
+ ImpDirtyEdgeTrack();
+}
+
+void SdrEdgeObj::ImpSetEdgeInfoToAttr()
+{
+ const SfxItemSet& rSet = GetObjectItemSet();
+ SdrEdgeKind eKind = ((SdrEdgeKindItem&)(rSet.Get(SDRATTR_EDGEKIND))).GetValue();
+ sal_Int32 nValAnz = ((SdrEdgeLineDeltaAnzItem&)rSet.Get(SDRATTR_EDGELINEDELTAANZ)).GetValue();
+ sal_Int32 nVal1 = ((SdrEdgeLine1DeltaItem&)rSet.Get(SDRATTR_EDGELINE1DELTA)).GetValue();
+ sal_Int32 nVal2 = ((SdrEdgeLine2DeltaItem&)rSet.Get(SDRATTR_EDGELINE2DELTA)).GetValue();
+ sal_Int32 nVal3 = ((SdrEdgeLine3DeltaItem&)rSet.Get(SDRATTR_EDGELINE3DELTA)).GetValue();
+ sal_Int32 nVals[3] = { nVal1, nVal2, nVal3 };
+ sal_uInt16 n = 0;
+
+ if(eKind == SDREDGE_ORTHOLINES || eKind == SDREDGE_BEZIER)
+ {
+ if(aEdgeInfo.nObj1Lines >= 2 && n < 3)
+ {
+ nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ1LINE2, *pEdgeTrack);
+ n++;
+ }
+
+ if(aEdgeInfo.nObj1Lines >= 3 && n < 3)
+ {
+ nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ1LINE3, *pEdgeTrack);
+ n++;
+ }
+
+ if(aEdgeInfo.nMiddleLine != 0xFFFF && n < 3)
+ {
+ nVals[n] = aEdgeInfo.ImpGetLineVersatz(MIDDLELINE, *pEdgeTrack);
+ n++;
+ }
+
+ if(aEdgeInfo.nObj2Lines >= 3 && n < 3)
+ {
+ nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ2LINE3, *pEdgeTrack);
+ n++;
+ }
+
+ if(aEdgeInfo.nObj2Lines >= 2 && n < 3)
+ {
+ nVals[n] = aEdgeInfo.ImpGetLineVersatz(OBJ2LINE2, *pEdgeTrack);
+ n++;
+ }
+ }
+ else if(eKind == SDREDGE_THREELINES)
+ {
+ BOOL bHor1 = aEdgeInfo.nAngle1 == 0 || aEdgeInfo.nAngle1 == 18000;
+ BOOL bHor2 = aEdgeInfo.nAngle2 == 0 || aEdgeInfo.nAngle2 == 18000;
+
+ n = 2;
+ nVals[0] = bHor1 ? aEdgeInfo.aObj1Line2.X() : aEdgeInfo.aObj1Line2.Y();
+ nVals[1] = bHor2 ? aEdgeInfo.aObj2Line2.X() : aEdgeInfo.aObj2Line2.Y();
+ }
+
+ if(n != nValAnz || nVals[0] != nVal1 || nVals[1] != nVal2 || nVals[2] != nVal3)
+ {
+ // #75371# Here no more notifying is necessary, just local changes are OK.
+ if(n != nValAnz)
+ {
+ GetProperties().SetObjectItemDirect(SdrEdgeLineDeltaAnzItem(n));
+ }
+
+ if(nVals[0] != nVal1)
+ {
+ GetProperties().SetObjectItemDirect(SdrEdgeLine1DeltaItem(nVals[0]));
+ }
+
+ if(nVals[1] != nVal2)
+ {
+ GetProperties().SetObjectItemDirect(SdrEdgeLine2DeltaItem(nVals[1]));
+ }
+
+ if(nVals[2] != nVal3)
+ {
+ GetProperties().SetObjectItemDirect(SdrEdgeLine3DeltaItem(nVals[2]));
+ }
+
+ if(n < 3)
+ {
+ GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE3DELTA);
+ }
+
+ if(n < 2)
+ {
+ GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE2DELTA);
+ }
+
+ if(n < 1)
+ {
+ GetProperties().ClearObjectItemDirect(SDRATTR_EDGELINE1DELTA);
+ }
+ }
+}
+
+void SdrEdgeObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bRotateFreeAllowed=FALSE;
+ rInfo.bRotate90Allowed =FALSE;
+ rInfo.bMirrorFreeAllowed=FALSE;
+ rInfo.bMirror45Allowed =FALSE;
+ rInfo.bMirror90Allowed =FALSE;
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ rInfo.bShearAllowed =FALSE;
+ rInfo.bEdgeRadiusAllowed=FALSE;
+ bool bCanConv=!HasText() || ImpCanConvTextToCurve();
+ rInfo.bCanConvToPath=bCanConv;
+ rInfo.bCanConvToPoly=bCanConv;
+ rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
+}
+
+UINT16 SdrEdgeObj::GetObjIdentifier() const
+{
+ return UINT16(OBJ_EDGE);
+}
+
+const Rectangle& SdrEdgeObj::GetCurrentBoundRect() const
+{
+ if(bEdgeTrackDirty)
+ {
+ ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack();
+ }
+
+ return SdrTextObj::GetCurrentBoundRect();
+}
+
+const Rectangle& SdrEdgeObj::GetSnapRect() const
+{
+ if(bEdgeTrackDirty)
+ {
+ ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack();
+ }
+
+ return SdrTextObj::GetSnapRect();
+}
+
+void SdrEdgeObj::RecalcSnapRect()
+{
+ maSnapRect=pEdgeTrack->GetBoundRect();
+}
+
+void SdrEdgeObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
+{
+ rRect=GetSnapRect();
+}
+
+bool SdrEdgeObj::IsNode() const
+{
+ return true;
+}
+
+SdrGluePoint SdrEdgeObj::GetVertexGluePoint(USHORT nNum) const
+{
+ Point aPt;
+ USHORT nPntAnz=pEdgeTrack->GetPointCount();
+ if (nPntAnz>0)
+ {
+ Point aOfs = GetSnapRect().Center();
+ if (nNum==2 && GetConnectedNode(TRUE)==NULL) aPt=(*pEdgeTrack)[0];
+ else if (nNum==3 && GetConnectedNode(FALSE)==NULL) aPt=(*pEdgeTrack)[nPntAnz-1];
+ else {
+ if ((nPntAnz & 1) ==1) {
+ aPt=(*pEdgeTrack)[nPntAnz/2];
+ } else {
+ Point aPt1((*pEdgeTrack)[nPntAnz/2-1]);
+ Point aPt2((*pEdgeTrack)[nPntAnz/2]);
+ aPt1+=aPt2;
+ aPt1.X()/=2;
+ aPt1.Y()/=2;
+ aPt=aPt1;
+ }
+ }
+ aPt-=aOfs;
+ }
+ SdrGluePoint aGP(aPt);
+ aGP.SetPercent(FALSE);
+ return aGP;
+}
+
+SdrGluePoint SdrEdgeObj::GetCornerGluePoint(USHORT nNum) const
+{
+ return GetVertexGluePoint(nNum);
+}
+
+const SdrGluePointList* SdrEdgeObj::GetGluePointList() const
+{
+ return NULL; // Keine benutzerdefinierten Klebepunkte fuer Verbinder #31671#
+}
+
+SdrGluePointList* SdrEdgeObj::ForceGluePointList()
+{
+ return NULL; // Keine benutzerdefinierten Klebepunkte fuer Verbinder #31671#
+}
+
+bool SdrEdgeObj::IsEdge() const
+{
+ return true;
+}
+
+void SdrEdgeObj::ConnectToNode(bool bTail1, SdrObject* pObj)
+{
+ SdrObjConnection& rCon=GetConnection(bTail1);
+ DisconnectFromNode(bTail1);
+ if (pObj!=NULL) {
+ pObj->AddListener(*this);
+ rCon.pObj=pObj;
+ ImpDirtyEdgeTrack();
+ }
+}
+
+void SdrEdgeObj::DisconnectFromNode(bool bTail1)
+{
+ SdrObjConnection& rCon=GetConnection(bTail1);
+ if (rCon.pObj!=NULL) {
+ rCon.pObj->RemoveListener(*this);
+ rCon.pObj=NULL;
+ }
+}
+
+SdrObject* SdrEdgeObj::GetConnectedNode(bool bTail1) const
+{
+ SdrObject* pObj=GetConnection(bTail1).pObj;
+ if (pObj!=NULL && (pObj->GetPage()!=pPage || !pObj->IsInserted())) pObj=NULL;
+ return pObj;
+}
+
+bool SdrEdgeObj::CheckNodeConnection(bool bTail1) const
+{
+ bool bRet = false;
+ const SdrObjConnection& rCon=GetConnection(bTail1);
+ USHORT nPtAnz=pEdgeTrack->GetPointCount();
+ if (rCon.pObj!=NULL && rCon.pObj->GetPage()==pPage && nPtAnz!=0) {
+ const SdrGluePointList* pGPL=rCon.pObj->GetGluePointList();
+ USHORT nConAnz=pGPL==NULL ? 0 : pGPL->GetCount();
+ USHORT nGesAnz=nConAnz+8;
+ Point aTail(bTail1 ? (*pEdgeTrack)[0] : (*pEdgeTrack)[USHORT(nPtAnz-1)]);
+ for (USHORT i=0; i<nGesAnz && !bRet; i++) {
+ if (i<nConAnz) { // UserDefined
+ bRet=aTail==(*pGPL)[i].GetAbsolutePos(*rCon.pObj);
+ } else if (i<nConAnz+4) { // Vertex
+ SdrGluePoint aPt(rCon.pObj->GetVertexGluePoint(i-nConAnz));
+ bRet=aTail==aPt.GetAbsolutePos(*rCon.pObj);
+ } else { // Corner
+ SdrGluePoint aPt(rCon.pObj->GetCornerGluePoint(i-nConAnz-4));
+ bRet=aTail==aPt.GetAbsolutePos(*rCon.pObj);
+ }
+ }
+ }
+ return bRet;
+}
+
+void SdrEdgeObj::ImpSetTailPoint(bool bTail1, const Point& rPt)
+{
+ USHORT nPtAnz=pEdgeTrack->GetPointCount();
+ if (nPtAnz==0) {
+ (*pEdgeTrack)[0]=rPt;
+ (*pEdgeTrack)[1]=rPt;
+ } else if (nPtAnz==1) {
+ if (!bTail1) (*pEdgeTrack)[1]=rPt;
+ else { (*pEdgeTrack)[1]=(*pEdgeTrack)[0]; (*pEdgeTrack)[0]=rPt; }
+ } else {
+ if (!bTail1) (*pEdgeTrack)[USHORT(nPtAnz-1)]=rPt;
+ else (*pEdgeTrack)[0]=rPt;
+ }
+ ImpRecalcEdgeTrack();
+ SetRectsDirty();
+}
+
+void SdrEdgeObj::ImpDirtyEdgeTrack()
+{
+ if ( !bEdgeTrackUserDefined || !(GetModel() && GetModel()->isLocked()) )
+ bEdgeTrackDirty = sal_True;
+}
+
+void SdrEdgeObj::ImpUndirtyEdgeTrack()
+{
+ if (bEdgeTrackDirty && (GetModel() && GetModel()->isLocked()) ) {
+ ImpRecalcEdgeTrack();
+ }
+}
+
+void SdrEdgeObj::ImpRecalcEdgeTrack()
+{
+ if ( bEdgeTrackUserDefined && (GetModel() && GetModel()->isLocked()) )
+ return;
+
+ // #110649#
+ if(IsBoundRectCalculationRunning())
+ {
+ // this object is involved into another ImpRecalcEdgeTrack() call
+ // from another SdrEdgeObj. Do not calculate again to avoid loop.
+ // Also, do not change bEdgeTrackDirty so that it gets recalculated
+ // later at the first non-looping call.
+ }
+ // #i43068#
+ else if(GetModel() && GetModel()->isLocked())
+ {
+ // avoid re-layout during imports/API call sequences
+ // #i45294# but calc EdgeTrack and secure properties there
+ ((SdrEdgeObj*)this)->mbBoundRectCalculationRunning = sal_True;
+ *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo);
+ ImpSetAttrToEdgeInfo();
+ bEdgeTrackDirty=sal_False;
+ ((SdrEdgeObj*)this)->mbBoundRectCalculationRunning = sal_False;
+ }
+ else
+ {
+ // To not run in a depth loop, use a coloring algorythm on
+ // SdrEdgeObj BoundRect calculations
+ ((SdrEdgeObj*)this)->mbBoundRectCalculationRunning = sal_True;
+
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ SetRectsDirty();
+ // #110094#-14 if (!bEdgeTrackDirty) SendRepaintBroadcast();
+ *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo);
+ ImpSetEdgeInfoToAttr(); // Die Werte aus aEdgeInfo in den Pool kopieren
+ bEdgeTrackDirty=sal_False;
+
+ // Only redraw here, no object change
+ ActionChanged();
+ // BroadcastObjectChange();
+
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+
+ // #110649#
+ ((SdrEdgeObj*)this)->mbBoundRectCalculationRunning = sal_False;
+ }
+}
+
+USHORT SdrEdgeObj::ImpCalcEscAngle(SdrObject* pObj, const Point& rPt) const
+{
+ if (pObj==NULL) return SDRESC_ALL;
+ Rectangle aR(pObj->GetSnapRect());
+ long dxl=rPt.X()-aR.Left();
+ long dyo=rPt.Y()-aR.Top();
+ long dxr=aR.Right()-rPt.X();
+ long dyu=aR.Bottom()-rPt.Y();
+ bool bxMitt=Abs(dxl-dxr)<2;
+ bool byMitt=Abs(dyo-dyu)<2;
+ long dx=Min(dxl,dxr);
+ long dy=Min(dyo,dyu);
+ bool bDiag=Abs(dx-dy)<2;
+ if (bxMitt && byMitt) return SDRESC_ALL; // In der Mitte
+ if (bDiag) { // diagonal
+ USHORT nRet=0;
+ if (byMitt) nRet|=SDRESC_VERT;
+ if (bxMitt) nRet|=SDRESC_HORZ;
+ if (dxl<dxr) { // Links
+ if (dyo<dyu) nRet|=SDRESC_LEFT | SDRESC_TOP;
+ else nRet|=SDRESC_LEFT | SDRESC_BOTTOM;
+ } else { // Rechts
+ if (dyo<dyu) nRet|=SDRESC_RIGHT | SDRESC_TOP;
+ else nRet|=SDRESC_RIGHT | SDRESC_BOTTOM;
+ }
+ return nRet;
+ }
+ if (dx<dy) { // waagerecht
+ if (bxMitt) return SDRESC_HORZ;
+ if (dxl<dxr) return SDRESC_LEFT;
+ else return SDRESC_RIGHT;
+ } else { // senkrecht
+ if (byMitt) return SDRESC_VERT;
+ if (dyo<dyu) return SDRESC_TOP;
+ else return SDRESC_BOTTOM;
+ }
+}
+
+bool SdrEdgeObj::ImpStripPolyPoints(XPolygon& /*rXP*/) const
+{
+ // fehlende Implementation !!!
+ return FALSE;
+}
+
+XPolygon SdrEdgeObj::ImpCalcObjToCenter(const Point& rStPt, long nEscAngle, const Rectangle& rRect, const Point& rMeeting) const
+{
+ XPolygon aXP;
+ aXP.Insert(XPOLY_APPEND,rStPt,XPOLY_NORMAL);
+ bool bRts=nEscAngle==0;
+ bool bObn=nEscAngle==9000;
+ bool bLks=nEscAngle==18000;
+ bool bUnt=nEscAngle==27000;
+
+ Point aP1(rStPt); // erstmal den Pflichtabstand
+ if (bLks) aP1.X()=rRect.Left();
+ if (bRts) aP1.X()=rRect.Right();
+ if (bObn) aP1.Y()=rRect.Top();
+ if (bUnt) aP1.Y()=rRect.Bottom();
+
+ Point aP2(aP1); // Und nun den Pflichtabstand ggf. bis auf Meetinghoehe erweitern
+ if (bLks && rMeeting.X()<=aP2.X()) aP2.X()=rMeeting.X();
+ if (bRts && rMeeting.X()>=aP2.X()) aP2.X()=rMeeting.X();
+ if (bObn && rMeeting.Y()<=aP2.Y()) aP2.Y()=rMeeting.Y();
+ if (bUnt && rMeeting.Y()>=aP2.Y()) aP2.Y()=rMeeting.Y();
+ aXP.Insert(XPOLY_APPEND,aP2,XPOLY_NORMAL);
+
+ Point aP3(aP2);
+ if ((bLks && rMeeting.X()>aP2.X()) || (bRts && rMeeting.X()<aP2.X())) { // Aussenrum
+ if (rMeeting.Y()<aP2.Y()) {
+ aP3.Y()=rRect.Top();
+ if (rMeeting.Y()<aP3.Y()) aP3.Y()=rMeeting.Y();
+ } else {
+ aP3.Y()=rRect.Bottom();
+ if (rMeeting.Y()>aP3.Y()) aP3.Y()=rMeeting.Y();
+ }
+ aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL);
+ if (aP3.Y()!=rMeeting.Y()) {
+ aP3.X()=rMeeting.X();
+ aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL);
+ }
+ }
+ if ((bObn && rMeeting.Y()>aP2.Y()) || (bUnt && rMeeting.Y()<aP2.Y())) { // Aussenrum
+ if (rMeeting.X()<aP2.X()) {
+ aP3.X()=rRect.Left();
+ if (rMeeting.X()<aP3.X()) aP3.X()=rMeeting.X();
+ } else {
+ aP3.X()=rRect.Right();
+ if (rMeeting.X()>aP3.X()) aP3.X()=rMeeting.X();
+ }
+ aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL);
+ if (aP3.X()!=rMeeting.X()) {
+ aP3.Y()=rMeeting.Y();
+ aXP.Insert(XPOLY_APPEND,aP3,XPOLY_NORMAL);
+ }
+ }
+#ifdef DBG_UTIL
+ if (aXP.GetPointCount()>4) {
+ DBG_ERROR("SdrEdgeObj::ImpCalcObjToCenter(): Polygon hat mehr als 4 Punkte!");
+ }
+#endif
+ return aXP;
+}
+
+XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const XPolygon& rTrack0, SdrObjConnection& rCon1, SdrObjConnection& rCon2, SdrEdgeInfoRec* pInfo) const
+{
+ Point aPt1,aPt2;
+ SdrGluePoint aGP1,aGP2;
+ USHORT nEsc1=SDRESC_ALL,nEsc2=SDRESC_ALL;
+ Rectangle aBoundRect1;
+ Rectangle aBoundRect2;
+ Rectangle aBewareRect1;
+ Rectangle aBewareRect2;
+ // Erstmal die alten Endpunkte wiederholen
+ if (rTrack0.GetPointCount()!=0) {
+ aPt1=rTrack0[0];
+ USHORT nSiz=rTrack0.GetPointCount();
+ nSiz--;
+ aPt2=rTrack0[nSiz];
+ } else {
+ if (!aOutRect.IsEmpty()) {
+ aPt1=aOutRect.TopLeft();
+ aPt2=aOutRect.BottomRight();
+ }
+ }
+ bool bCon1=rCon1.pObj!=NULL && rCon1.pObj->GetPage()==pPage && rCon1.pObj->IsInserted();
+ bool bCon2=rCon2.pObj!=NULL && rCon2.pObj->GetPage()==pPage && rCon2.pObj->IsInserted();
+ const SfxItemSet& rSet = GetObjectItemSet();
+
+ if (bCon1) {
+ if (rCon1.pObj==(SdrObject*)this)
+ {
+ // sicherheitshalber Abfragen #44515#
+ aBoundRect1=aOutRect;
+ }
+ else
+ {
+ aBoundRect1 = rCon1.pObj->GetCurrentBoundRect();
+ }
+ aBoundRect1.Move(rCon1.aObjOfs.X(),rCon1.aObjOfs.Y());
+ aBewareRect1=aBoundRect1;
+
+ sal_Int32 nH = ((SdrEdgeNode1HorzDistItem&)rSet.Get(SDRATTR_EDGENODE1HORZDIST)).GetValue();
+ sal_Int32 nV = ((SdrEdgeNode1VertDistItem&)rSet.Get(SDRATTR_EDGENODE1VERTDIST)).GetValue();
+
+ aBewareRect1.Left()-=nH;
+ aBewareRect1.Right()+=nH;
+ aBewareRect1.Top()-=nV;
+ aBewareRect1.Bottom()+=nV;
+ } else {
+ aBoundRect1=Rectangle(aPt1,aPt1);
+ aBoundRect1.Move(rCon1.aObjOfs.X(),rCon1.aObjOfs.Y());
+ aBewareRect1=aBoundRect1;
+ }
+ if (bCon2) {
+ if (rCon2.pObj==(SdrObject*)this) { // sicherheitshalber Abfragen #44515#
+ aBoundRect2=aOutRect;
+ }
+ else
+ {
+ aBoundRect2 = rCon2.pObj->GetCurrentBoundRect();
+ }
+ aBoundRect2.Move(rCon2.aObjOfs.X(),rCon2.aObjOfs.Y());
+ aBewareRect2=aBoundRect2;
+
+ sal_Int32 nH = ((SdrEdgeNode2HorzDistItem&)rSet.Get(SDRATTR_EDGENODE2HORZDIST)).GetValue();
+ sal_Int32 nV = ((SdrEdgeNode2VertDistItem&)rSet.Get(SDRATTR_EDGENODE2VERTDIST)).GetValue();
+
+ aBewareRect2.Left()-=nH;
+ aBewareRect2.Right()+=nH;
+ aBewareRect2.Top()-=nV;
+ aBewareRect2.Bottom()+=nV;
+ } else {
+ aBoundRect2=Rectangle(aPt2,aPt2);
+ aBoundRect2.Move(rCon2.aObjOfs.X(),rCon2.aObjOfs.Y());
+ aBewareRect2=aBoundRect2;
+ }
+ XPolygon aBestXP;
+ ULONG nBestQual=0xFFFFFFFF;
+ SdrEdgeInfoRec aBestInfo;
+ bool bAuto1=bCon1 && rCon1.bBestVertex;
+ bool bAuto2=bCon2 && rCon2.bBestVertex;
+ if (bAuto1) rCon1.bAutoVertex=TRUE;
+ if (bAuto2) rCon2.bAutoVertex=TRUE;
+ USHORT nBestAuto1=0;
+ USHORT nBestAuto2=0;
+ USHORT nAnz1=bAuto1 ? 4 : 1;
+ USHORT nAnz2=bAuto2 ? 4 : 1;
+ for (USHORT nNum1=0; nNum1<nAnz1; nNum1++) {
+ if (bAuto1) rCon1.nConId=nNum1;
+ if (bCon1 && rCon1.TakeGluePoint(aGP1,TRUE)) {
+ aPt1=aGP1.GetPos();
+ nEsc1=aGP1.GetEscDir();
+ if (nEsc1==SDRESC_SMART) nEsc1=ImpCalcEscAngle(rCon1.pObj,aPt1-rCon1.aObjOfs);
+ }
+ for (USHORT nNum2=0; nNum2<nAnz2; nNum2++) {
+ if (bAuto2) rCon2.nConId=nNum2;
+ if (bCon2 && rCon2.TakeGluePoint(aGP2,TRUE)) {
+ aPt2=aGP2.GetPos();
+ nEsc2=aGP2.GetEscDir();
+ if (nEsc2==SDRESC_SMART) nEsc2=ImpCalcEscAngle(rCon2.pObj,aPt2-rCon2.aObjOfs);
+ }
+ for (long nA1=0; nA1<36000; nA1+=9000) {
+ USHORT nE1=nA1==0 ? SDRESC_RIGHT : nA1==9000 ? SDRESC_TOP : nA1==18000 ? SDRESC_LEFT : nA1==27000 ? SDRESC_BOTTOM : 0;
+ for (long nA2=0; nA2<36000; nA2+=9000) {
+ USHORT nE2=nA2==0 ? SDRESC_RIGHT : nA2==9000 ? SDRESC_TOP : nA2==18000 ? SDRESC_LEFT : nA2==27000 ? SDRESC_BOTTOM : 0;
+ if ((nEsc1&nE1)!=0 && (nEsc2&nE2)!=0) {
+ ULONG nQual=0;
+ SdrEdgeInfoRec aInfo;
+ if (pInfo!=NULL) aInfo=*pInfo;
+ XPolygon aXP(ImpCalcEdgeTrack(aPt1,nA1,aBoundRect1,aBewareRect1,aPt2,nA2,aBoundRect2,aBewareRect2,&nQual,&aInfo));
+ if (nQual<nBestQual) {
+ aBestXP=aXP;
+ nBestQual=nQual;
+ aBestInfo=aInfo;
+ nBestAuto1=nNum1;
+ nBestAuto2=nNum2;
+ }
+ }
+ }
+ }
+ }
+ }
+ if (bAuto1) rCon1.nConId=nBestAuto1;
+ if (bAuto2) rCon2.nConId=nBestAuto2;
+ if (pInfo!=NULL) *pInfo=aBestInfo;
+ return aBestXP;
+}
+
+XPolygon SdrEdgeObj::ImpCalcEdgeTrack(const Point& rPt1, long nAngle1, const Rectangle& rBoundRect1, const Rectangle& rBewareRect1,
+ const Point& rPt2, long nAngle2, const Rectangle& rBoundRect2, const Rectangle& rBewareRect2,
+ ULONG* pnQuality, SdrEdgeInfoRec* pInfo) const
+{
+ SdrEdgeKind eKind=((SdrEdgeKindItem&)(GetObjectItem(SDRATTR_EDGEKIND))).GetValue();
+ bool bRts1=nAngle1==0;
+ bool bObn1=nAngle1==9000;
+ bool bLks1=nAngle1==18000;
+ bool bUnt1=nAngle1==27000;
+ bool bHor1=bLks1 || bRts1;
+ bool bVer1=bObn1 || bUnt1;
+ bool bRts2=nAngle2==0;
+ bool bObn2=nAngle2==9000;
+ bool bLks2=nAngle2==18000;
+ bool bUnt2=nAngle2==27000;
+ bool bHor2=bLks2 || bRts2;
+ bool bVer2=bObn2 || bUnt2;
+ bool bInfo=pInfo!=NULL;
+ if (bInfo) {
+ pInfo->cOrthoForm=0;
+ pInfo->nAngle1=nAngle1;
+ pInfo->nAngle2=nAngle2;
+ pInfo->nObj1Lines=1;
+ pInfo->nObj2Lines=1;
+ pInfo->nMiddleLine=0xFFFF;
+ }
+ Point aPt1(rPt1);
+ Point aPt2(rPt2);
+ Rectangle aBoundRect1 (rBoundRect1 );
+ Rectangle aBoundRect2 (rBoundRect2 );
+ Rectangle aBewareRect1(rBewareRect1);
+ Rectangle aBewareRect2(rBewareRect2);
+ Point aMeeting((aPt1.X()+aPt2.X()+1)/2,(aPt1.Y()+aPt2.Y()+1)/2);
+ bool bMeetingXMid = true;
+ bool bMeetingYMid = true;
+ if (eKind==SDREDGE_ONELINE) {
+ XPolygon aXP(2);
+ aXP[0]=rPt1;
+ aXP[1]=rPt2;
+ if (pnQuality!=NULL) {
+ *pnQuality=Abs(rPt1.X()-rPt2.X())+Abs(rPt1.Y()-rPt2.Y());
+ }
+ return aXP;
+ } else if (eKind==SDREDGE_THREELINES) {
+ XPolygon aXP(4);
+ aXP[0]=rPt1;
+ aXP[1]=rPt1;
+ aXP[2]=rPt2;
+ aXP[3]=rPt2;
+ if (bRts1) aXP[1].X()=aBewareRect1.Right(); //+=500;
+ if (bObn1) aXP[1].Y()=aBewareRect1.Top(); //-=500;
+ if (bLks1) aXP[1].X()=aBewareRect1.Left(); //-=500;
+ if (bUnt1) aXP[1].Y()=aBewareRect1.Bottom(); //+=500;
+ if (bRts2) aXP[2].X()=aBewareRect2.Right(); //+=500;
+ if (bObn2) aXP[2].Y()=aBewareRect2.Top(); //-=500;
+ if (bLks2) aXP[2].X()=aBewareRect2.Left(); //-=500;
+ if (bUnt2) aXP[2].Y()=aBewareRect2.Bottom(); //+=500;
+ if (pnQuality!=NULL) {
+ long nQ=Abs(aXP[1].X()-aXP[0].X())+Abs(aXP[1].Y()-aXP[0].Y());
+ nQ+=Abs(aXP[2].X()-aXP[1].X())+Abs(aXP[2].Y()-aXP[1].Y());
+ nQ+=Abs(aXP[3].X()-aXP[2].X())+Abs(aXP[3].Y()-aXP[2].Y());
+ *pnQuality=nQ;
+ }
+ if (bInfo) {
+ pInfo->nObj1Lines=2;
+ pInfo->nObj2Lines=2;
+ if (bHor1) {
+ aXP[1].X()+=pInfo->aObj1Line2.X();
+ } else {
+ aXP[1].Y()+=pInfo->aObj1Line2.Y();
+ }
+ if (bHor2) {
+ aXP[2].X()+=pInfo->aObj2Line2.X();
+ } else {
+ aXP[2].Y()+=pInfo->aObj2Line2.Y();
+ }
+ }
+ return aXP;
+ }
+ USHORT nIntersections=0;
+ bool bForceMeeting = false; // Muss die Linie durch den MeetingPoint laufen?
+ {
+ Point aC1(aBewareRect1.Center());
+ Point aC2(aBewareRect2.Center());
+ if (aBewareRect1.Left()<=aBewareRect2.Right() && aBewareRect1.Right()>=aBewareRect2.Left()) {
+ // Ueberschneidung auf der X-Achse
+ long n1=Max(aBewareRect1.Left(),aBewareRect2.Left());
+ long n2=Min(aBewareRect1.Right(),aBewareRect2.Right());
+ aMeeting.X()=(n1+n2+1)/2;
+ } else {
+ // Ansonsten den Mittelpunkt des Freiraums
+ if (aC1.X()<aC2.X()) {
+ aMeeting.X()=(aBewareRect1.Right()+aBewareRect2.Left()+1)/2;
+ } else {
+ aMeeting.X()=(aBewareRect1.Left()+aBewareRect2.Right()+1)/2;
+ }
+ }
+ if (aBewareRect1.Top()<=aBewareRect2.Bottom() && aBewareRect1.Bottom()>=aBewareRect2.Top()) {
+ // Ueberschneidung auf der Y-Achse
+ long n1=Max(aBewareRect1.Top(),aBewareRect2.Top());
+ long n2=Min(aBewareRect1.Bottom(),aBewareRect2.Bottom());
+ aMeeting.Y()=(n1+n2+1)/2;
+ } else {
+ // Ansonsten den Mittelpunkt des Freiraums
+ if (aC1.Y()<aC2.Y()) {
+ aMeeting.Y()=(aBewareRect1.Bottom()+aBewareRect2.Top()+1)/2;
+ } else {
+ aMeeting.Y()=(aBewareRect1.Top()+aBewareRect2.Bottom()+1)/2;
+ }
+ }
+ // Im Prinzip gibt es 3 zu unterscheidene Faelle:
+ // 1. Beide in die selbe Richtung
+ // 2. Beide in genau entgegengesetzte Richtungen
+ // 3. Einer waagerecht und der andere senkrecht
+ long nXMin=Min(aBewareRect1.Left(),aBewareRect2.Left());
+ long nXMax=Max(aBewareRect1.Right(),aBewareRect2.Right());
+ long nYMin=Min(aBewareRect1.Top(),aBewareRect2.Top());
+ long nYMax=Max(aBewareRect1.Bottom(),aBewareRect2.Bottom());
+ //bool bBoundOverlap=aBoundRect1.Right()>aBoundRect2.Left() && aBoundRect1.Left()<aBoundRect2.Right() &&
+ // aBoundRect1.Bottom()>aBoundRect2.Top() && aBoundRect1.Top()<aBoundRect2.Bottom();
+ bool bBewareOverlap=aBewareRect1.Right()>aBewareRect2.Left() && aBewareRect1.Left()<aBewareRect2.Right() &&
+ aBewareRect1.Bottom()>aBewareRect2.Top() && aBewareRect1.Top()<aBewareRect2.Bottom();
+ unsigned nMainCase=3;
+ if (nAngle1==nAngle2) nMainCase=1;
+ else if ((bHor1 && bHor2) || (bVer1 && bVer2)) nMainCase=2;
+ if (nMainCase==1) { // Fall 1: Beide in eine Richtung moeglich.
+ if (bVer1) aMeeting.X()=(aPt1.X()+aPt2.X()+1)/2; // ist hier besser, als der
+ if (bHor1) aMeeting.Y()=(aPt1.Y()+aPt2.Y()+1)/2; // Mittelpunkt des Freiraums
+ // bX1Ok bedeutet, dass die Vertikale, die aus Obj1 austritt, keinen Konflikt mit Obj2 bildet, ...
+ bool bX1Ok=aPt1.X()<=aBewareRect2.Left() || aPt1.X()>=aBewareRect2.Right();
+ bool bX2Ok=aPt2.X()<=aBewareRect1.Left() || aPt2.X()>=aBewareRect1.Right();
+ bool bY1Ok=aPt1.Y()<=aBewareRect2.Top() || aPt1.Y()>=aBewareRect2.Bottom();
+ bool bY2Ok=aPt2.Y()<=aBewareRect1.Top() || aPt2.Y()>=aBewareRect1.Bottom();
+ if (bLks1 && (bY1Ok || aBewareRect1.Left()<aBewareRect2.Right()) && (bY2Ok || aBewareRect2.Left()<aBewareRect1.Right())) {
+ aMeeting.X()=nXMin;
+ bMeetingXMid = false;
+ }
+ if (bRts1 && (bY1Ok || aBewareRect1.Right()>aBewareRect2.Left()) && (bY2Ok || aBewareRect2.Right()>aBewareRect1.Left())) {
+ aMeeting.X()=nXMax;
+ bMeetingXMid = false;
+ }
+ if (bObn1 && (bX1Ok || aBewareRect1.Top()<aBewareRect2.Bottom()) && (bX2Ok || aBewareRect2.Top()<aBewareRect1.Bottom())) {
+ aMeeting.Y()=nYMin;
+ bMeetingYMid = false;
+ }
+ if (bUnt1 && (bX1Ok || aBewareRect1.Bottom()>aBewareRect2.Top()) && (bX2Ok || aBewareRect2.Bottom()>aBewareRect1.Top())) {
+ aMeeting.Y()=nYMax;
+ bMeetingYMid = false;
+ }
+ } else if (nMainCase==2) {
+ // Fall 2:
+ bForceMeeting = true;
+ if (bHor1) { // beide waagerecht
+ /* 9 Moeglichkeiten: ù ù ù */
+ /* 2.1 Gegenueber, Ueberschneidung à ´ ù */
+ /* nur auf der Y-Achse ù ù ù */
+ /* 2.2, 2.3 Gegenueber, vertikal versetzt. Ã ù ù ù ù ù */
+ /* Ueberschneidung weder auf der ù ´ ù ù ´ ù */
+ /* X- noch auf der Y-Achse ù ù ù Ã ù ù */
+ /* 2.4, 2.5 Untereinander, ù Ã ù ù ù ù */
+ /* Ueberschneidung ù ´ ù ù ´ ù */
+ /* nur auf X-Achse ù ù ù ù Ã ù */
+ /* 2.6, 2.7 Gegeneinander, vertikal versetzt. ù ù Ã ù ù ù */
+ /* Ueberschneidung weder auf der ù ´ ù ù ´ ù */
+ /* X- noch auf der Y-Achse. ù ù ù ù ù Ã */
+ /* 2.8 Gegeneinander. ù ù ù */
+ /* Ueberschneidung nur ù ´ Ã */
+ /* auf der Y-Achse. ù ù ù */
+ /* 2.9 Die BewareRects der Objekte ueberschneiden */
+ /* sich auf X- und Y-Achse. */
+ /* Die Faelle gelten entsprechend umgesetzt auch fuer */
+ /* senkrechte Linienaustritte. */
+ /* Die Faelle 2.1-2.7 werden mit dem Default-Meeting ausreichend*/
+ /* gut behandelt. Spezielle MeetingPoints werden hier also nur */
+ /* fuer 2.8 und 2.9 bestimmt. */
+
+ // Normalisierung. aR1 soll der nach rechts und
+ // aR2 der nach links austretende sein.
+ Rectangle aBewR1(bRts1 ? aBewareRect1 : aBewareRect2);
+ Rectangle aBewR2(bRts1 ? aBewareRect2 : aBewareRect1);
+ Rectangle aBndR1(bRts1 ? aBoundRect1 : aBoundRect2);
+ Rectangle aBndR2(bRts1 ? aBoundRect2 : aBoundRect1);
+ if (aBewR1.Bottom()>aBewR2.Top() && aBewR1.Top()<aBewR2.Bottom()) {
+ // Ueberschneidung auf der Y-Achse. Faelle 2.1, 2.8, 2.9
+ if (aBewR1.Right()>aBewR2.Left()) {
+ // Faelle 2.8, 2.9
+ // Fall 2.8 ist immer Aussenrumlauf (bDirect=FALSE).
+ // Fall 2.9 kann auch Direktverbindung sein (bei geringer
+ // Ueberschneidung der BewareRects ohne Ueberschneidung der
+ // Boundrects wenn die Linienaustritte sonst das BewareRect
+ // des jeweils anderen Objekts verletzen wuerden.
+ bool bCase29Direct = false;
+ bool bCase29=aBewR1.Right()>aBewR2.Left();
+ if (aBndR1.Right()<=aBndR2.Left()) { // Fall 2.9 und keine Boundrectueberschneidung
+ if ((aPt1.Y()>aBewareRect2.Top() && aPt1.Y()<aBewareRect2.Bottom()) ||
+ (aPt2.Y()>aBewareRect1.Top() && aPt2.Y()<aBewareRect1.Bottom())) {
+ bCase29Direct = true;
+ }
+ }
+ if (!bCase29Direct) {
+ bool bObenLang=Abs(nYMin-aMeeting.Y())<=Abs(nYMax-aMeeting.Y());
+ if (bObenLang) {
+ aMeeting.Y()=nYMin;
+ } else {
+ aMeeting.Y()=nYMax;
+ }
+ bMeetingYMid = false;
+ if (bCase29) {
+ // und nun noch dafuer sorgen, dass das
+ // umzingelte Obj nicht durchquert wird
+ if ((aBewR1.Center().Y()<aBewR2.Center().Y()) != bObenLang) {
+ aMeeting.X()=aBewR2.Right();
+ } else {
+ aMeeting.X()=aBewR1.Left();
+ }
+ bMeetingXMid = false;
+ }
+ } else {
+ // Direkte Verbindung (3-Linien Z-Verbindung), da
+ // Verletzung der BewareRects unvermeidlich ist.
+ // Via Dreisatz werden die BewareRects nun verkleinert.
+ long nWant1=aBewR1.Right()-aBndR1.Right(); // Abstand bei Obj1
+ long nWant2=aBndR2.Left()-aBewR2.Left(); // Abstand bei Obj2
+ long nSpace=aBndR2.Left()-aBndR1.Right(); // verfuegbarer Platz
+ long nGet1=BigMulDiv(nWant1,nSpace,nWant1+nWant2);
+ long nGet2=nSpace-nGet1;
+ if (bRts1) { // Normalisierung zurueckwandeln
+ aBewareRect1.Right()+=nGet1-nWant1;
+ aBewareRect2.Left()-=nGet2-nWant2;
+ } else {
+ aBewareRect2.Right()+=nGet1-nWant1;
+ aBewareRect1.Left()-=nGet2-nWant2;
+ }
+ nIntersections++; // Qualitaet herabsetzen
+ }
+ }
+ }
+ } else if (bVer1) { // beide senkrecht
+ Rectangle aBewR1(bUnt1 ? aBewareRect1 : aBewareRect2);
+ Rectangle aBewR2(bUnt1 ? aBewareRect2 : aBewareRect1);
+ Rectangle aBndR1(bUnt1 ? aBoundRect1 : aBoundRect2);
+ Rectangle aBndR2(bUnt1 ? aBoundRect2 : aBoundRect1);
+ if (aBewR1.Right()>aBewR2.Left() && aBewR1.Left()<aBewR2.Right()) {
+ // Ueberschneidung auf der Y-Achse. Faelle 2.1, 2.8, 2.9
+ if (aBewR1.Bottom()>aBewR2.Top()) {
+ // Faelle 2.8, 2.9
+ // Fall 2.8 ist immer Aussenrumlauf (bDirect=FALSE).
+ // Fall 2.9 kann auch Direktverbindung sein (bei geringer
+ // Ueberschneidung der BewareRects ohne Ueberschneidung der
+ // Boundrects wenn die Linienaustritte sonst das BewareRect
+ // des jeweils anderen Objekts verletzen wuerden.
+ bool bCase29Direct = false;
+ bool bCase29=aBewR1.Bottom()>aBewR2.Top();
+ if (aBndR1.Bottom()<=aBndR2.Top()) { // Fall 2.9 und keine Boundrectueberschneidung
+ if ((aPt1.X()>aBewareRect2.Left() && aPt1.X()<aBewareRect2.Right()) ||
+ (aPt2.X()>aBewareRect1.Left() && aPt2.X()<aBewareRect1.Right())) {
+ bCase29Direct = true;
+ }
+ }
+ if (!bCase29Direct) {
+ bool bLinksLang=Abs(nXMin-aMeeting.X())<=Abs(nXMax-aMeeting.X());
+ if (bLinksLang) {
+ aMeeting.X()=nXMin;
+ } else {
+ aMeeting.X()=nXMax;
+ }
+ bMeetingXMid = false;
+ if (bCase29) {
+ // und nun noch dafuer sorgen, dass das
+ // umzingelte Obj nicht durchquert wird
+ if ((aBewR1.Center().X()<aBewR2.Center().X()) != bLinksLang) {
+ aMeeting.Y()=aBewR2.Bottom();
+ } else {
+ aMeeting.Y()=aBewR1.Top();
+ }
+ bMeetingYMid = false;
+ }
+ } else {
+ // Direkte Verbindung (3-Linien Z-Verbindung), da
+ // Verletzung der BewareRects unvermeidlich ist.
+ // Via Dreisatz werden die BewareRects nun verkleinert.
+ long nWant1=aBewR1.Bottom()-aBndR1.Bottom(); // Abstand bei Obj1
+ long nWant2=aBndR2.Top()-aBewR2.Top(); // Abstand bei Obj2
+ long nSpace=aBndR2.Top()-aBndR1.Bottom(); // verfuegbarer Platz
+ long nGet1=BigMulDiv(nWant1,nSpace,nWant1+nWant2);
+ long nGet2=nSpace-nGet1;
+ if (bUnt1) { // Normalisierung zurueckwandeln
+ aBewareRect1.Bottom()+=nGet1-nWant1;
+ aBewareRect2.Top()-=nGet2-nWant2;
+ } else {
+ aBewareRect2.Bottom()+=nGet1-nWant1;
+ aBewareRect1.Top()-=nGet2-nWant2;
+ }
+ nIntersections++; // Qualitaet herabsetzen
+ }
+ }
+ }
+ }
+ } else if (nMainCase==3) { // Fall 3: Einer waagerecht und der andere senkrecht. Sehr viele Fallunterscheidungen
+ /* Kleine Legende: ù ú ù ú ù -> Ohne Ueberschneidung, maximal Beruehrung. */
+ /* ú ú ú ú ú -> Ueberschneidung */
+ /* ù ú Ã ú ù -> Selbe Hoehe */
+ /* ú ú ú ú ú -> Ueberschneidung */
+ /* ù ú ù ú ù -> Ohne Ueberschneidung, maximal Beruehrung. */
+ /* Linienaustritte links ´, rechts Ã, oben Á und unten Â. */
+ /* Insgesamt sind 96 Konstellationen moeglich, wobei einige nicht einmal */
+ /* eindeutig einem Fall und damit einer Behandlungsmethode zugeordnet werden */
+ /* koennen. */
+ /* 3.1: Hierzu moegen alle Konstellationen zaehlen, die durch den */
+ /* Default-MeetingPoint zufriedenstellend abgedeckt sind (20+12). */
+ /* Â Â Â ú Á Á ú Â Â Â Diese 12 ù ú ù Â ù ù ú ù ú ù ù Â ù ú ù ù ú ù ú ù */
+ /* ú ú ú ú Á Á ú ú ú ú Konstel. ú ú ú ú ú ú ú ú ú Â ú ú ú ú ú Â ú ú ú ú */
+ /* ù ú Ã ú ù ù ú ´ ú ù jedoch ù ú Ã ú Á ù ú Ã ú Â Á ú ´ ú ù Â ú ´ ú ù */
+ /* ú ú ú ú Â Â ú ú ú ú nur zum ú ú ú ú Á ú ú ú ú ú Á ú ú ú ú ú ú ú ú ú */
+ /* Á Á Á ú Â Â ú Á Á Á Teil: ù ú ù Á ù ù ú ù ú ù ù Á ù ú ù ù ú ù ú ù */
+ /* Letztere 16 Faelle scheiden aus, sobald sich die Objekte offen */
+ /* gegenueberstehen (siehe Fall 3.2). */
+ /* 3.2: Die Objekte stehen sich offen gegenueber und somit ist eine */
+ /* Verbindung mit lediglich 2 Linien moeglich (4+20). */
+ /* Dieser Fall hat 1. Prioritaet. */
+ /* ù ú ù ú Â Â ú ù ú ù Diese 20 ù ú ù Â ù ù Â ù ú ù ù ú ù ú ù ù ú ù ú ù */
+ /* ú ú ú ú ú ú ú ú ú ú Konstel. ú ú ú Â Â Â Â ú ú ú ú ú ú ú ú ú ú ú ú ú */
+ /* ù ú Ã ú ù ù ú ´ ú ù jedoch ù ú Ã Á Á Á Á ´ ú ù ù ú Ã Â Â Â Â ´ ú ù */
+ /* ú ú ú ú ú ú ú ú ú ú nur zum ú ú ú Á Á Á Á ú ú ú ú ú ú ú ú ú ú ú ú ú */
+ /* ù ú ù ú Á Á ú ù ú ù Teil: ù ú ù Á ù ù Á ù ú ù ù ú ù ú ù ù ú ù ú ù */
+ /* 3.3: Die Linienaustritte zeigen vom anderen Objekt weg bzw. hinter */
+ /* dessen Ruecken vorbei (52+4). */
+ /* Á Á Á Á ù ù Á Á Á Á ù ú ú ú ù ù ú ù ú ù Diese 4 ù ú ù ú ù ù ú ù ú ù */
+ /* Á Á Á Á ú ú Á Á Á Á Â Â Â ú ú ú ú Â Â Â Konstel. ú ú ú Â ú ú Â ú ú ú */
+ /* Á Á Ã ú ù ù ú ´ Á Á Â Â Ã ú ù ù ú ´ Â Â jedoch ù ú Ã ú ù ù ú ´ ú ù */
+ /* Á Á Á ú ú ú ú Á Á Á Â Â Â Â ú ú Â Â Â Â nur zum ú ú ú Á ú ú Á ú ú ú */
+ /* ù ú ù ú ù ù ú ù ú ù Â Â Â Â ù ù Â Â Â Â Teil: ù ú ù ú ù ù ú ù ú ù */
+
+ // Fall 3.2
+ Rectangle aTmpR1(aBewareRect1);
+ Rectangle aTmpR2(aBewareRect2);
+ if (bBewareOverlap) {
+ // Ueberschneidung der BewareRects: BoundRects fuer Check auf Fall 3.2 verwenden.
+ aTmpR1=aBoundRect1;
+ aTmpR2=aBoundRect2;
+ }
+ if ((((bRts1 && aTmpR1.Right ()<=aPt2.X()) || (bLks1 && aTmpR1.Left()>=aPt2.X())) &&
+ ((bUnt2 && aTmpR2.Bottom()<=aPt1.Y()) || (bObn2 && aTmpR2.Top ()>=aPt1.Y()))) ||
+ (((bRts2 && aTmpR2.Right ()<=aPt1.X()) || (bLks2 && aTmpR2.Left()>=aPt1.X())) &&
+ ((bUnt1 && aTmpR1.Bottom()<=aPt2.Y()) || (bObn1 && aTmpR1.Top ()>=aPt2.Y())))) {
+ // Fall 3.2 trifft zu: Verbindung mit lediglich 2 Linien
+ bForceMeeting = true;
+ bMeetingXMid = false;
+ bMeetingYMid = false;
+ if (bHor1) {
+ aMeeting.X()=aPt2.X();
+ aMeeting.Y()=aPt1.Y();
+ } else {
+ aMeeting.X()=aPt1.X();
+ aMeeting.Y()=aPt2.Y();
+ }
+ // Falls Ueberschneidung der BewareRects:
+ aBewareRect1=aTmpR1;
+ aBewareRect2=aTmpR2;
+ } else if ((((bRts1 && aBewareRect1.Right ()>aBewareRect2.Left ()) ||
+ (bLks1 && aBewareRect1.Left ()<aBewareRect2.Right ())) &&
+ ((bUnt2 && aBewareRect2.Bottom()>aBewareRect1.Top ()) ||
+ (bObn2 && aBewareRect2.Top ()<aBewareRect1.Bottom()))) ||
+ (((bRts2 && aBewareRect2.Right ()>aBewareRect1.Left ()) ||
+ (bLks2 && aBewareRect2.Left ()<aBewareRect1.Right ())) &&
+ ((bUnt1 && aBewareRect1.Bottom()>aBewareRect2.Top ()) ||
+ (bObn1 && aBewareRect1.Top ()<aBewareRect2.Bottom())))) {
+ // Fall 3.3
+ bForceMeeting = true;
+ if (bRts1 || bRts2) { aMeeting.X()=nXMax; bMeetingXMid = false; }
+ if (bLks1 || bLks2) { aMeeting.X()=nXMin; bMeetingXMid = false; }
+ if (bUnt1 || bUnt2) { aMeeting.Y()=nYMax; bMeetingYMid = false; }
+ if (bObn1 || bObn2) { aMeeting.Y()=nYMin; bMeetingYMid = false; }
+ }
+ }
+ }
+
+ XPolygon aXP1(ImpCalcObjToCenter(aPt1,nAngle1,aBewareRect1,aMeeting));
+ XPolygon aXP2(ImpCalcObjToCenter(aPt2,nAngle2,aBewareRect2,aMeeting));
+ USHORT nXP1Anz=aXP1.GetPointCount();
+ USHORT nXP2Anz=aXP2.GetPointCount();
+ if (bInfo) {
+ pInfo->nObj1Lines=nXP1Anz; if (nXP1Anz>1) pInfo->nObj1Lines--;
+ pInfo->nObj2Lines=nXP2Anz; if (nXP2Anz>1) pInfo->nObj2Lines--;
+ }
+ Point aEP1(aXP1[nXP1Anz-1]);
+ Point aEP2(aXP2[nXP2Anz-1]);
+ bool bInsMeetingPoint=aEP1.X()!=aEP2.X() && aEP1.Y()!=aEP2.Y();
+ bool bHorzE1=aEP1.Y()==aXP1[nXP1Anz-2].Y(); // letzte Linie von XP1 horizontal?
+ bool bHorzE2=aEP2.Y()==aXP2[nXP2Anz-2].Y(); // letzte Linie von XP2 horizontal?
+ if (aEP1==aEP2 && ((bHorzE1 && bHorzE2 && aEP1.Y()==aEP2.Y()) || (!bHorzE1 && !bHorzE2 && aEP1.X()==aEP2.X()))) {
+ // Sonderbehandlung fuer 'I'-Verbinder
+ nXP1Anz--; aXP1.Remove(nXP1Anz,1);
+ nXP2Anz--; aXP2.Remove(nXP2Anz,1);
+ bMeetingXMid = false;
+ bMeetingYMid = false;
+ }
+ if (bInsMeetingPoint) {
+ aXP1.Insert(XPOLY_APPEND,aMeeting,XPOLY_NORMAL);
+ if (bInfo) {
+ // Durch einfuegen des MeetingPoints kommen 2 weitere Linie hinzu.
+ // Evtl. wird eine von diesen die Mittellinie.
+ if (pInfo->nObj1Lines==pInfo->nObj2Lines) {
+ pInfo->nObj1Lines++;
+ pInfo->nObj2Lines++;
+ } else {
+ if (pInfo->nObj1Lines>pInfo->nObj2Lines) {
+ pInfo->nObj2Lines++;
+ pInfo->nMiddleLine=nXP1Anz-1;
+ } else {
+ pInfo->nObj1Lines++;
+ pInfo->nMiddleLine=nXP1Anz;
+ }
+ }
+ }
+ } else if (bInfo && aEP1!=aEP2 && nXP1Anz+nXP2Anz>=4) {
+ // Durch Verbinden der beiden Enden kommt eine weitere Linie hinzu.
+ // Dies wird die Mittellinie.
+ pInfo->nMiddleLine=nXP1Anz-1;
+ }
+ USHORT nNum=aXP2.GetPointCount();
+ if (aXP1[nXP1Anz-1]==aXP2[nXP2Anz-1] && nXP1Anz>1 && nXP2Anz>1) nNum--;
+ while (nNum>0) {
+ nNum--;
+ aXP1.Insert(XPOLY_APPEND,aXP2[nNum],XPOLY_NORMAL);
+ }
+ USHORT nPntAnz=aXP1.GetPointCount();
+ char cForm=0;
+ if (bInfo || pnQuality!=NULL) {
+ cForm='?';
+ if (nPntAnz==2) cForm='I';
+ else if (nPntAnz==3) cForm='L';
+ else if (nPntAnz==4) { // Z oder U
+ if (nAngle1==nAngle2) cForm='U';
+ else cForm='Z';
+ } else if (nPntAnz==4) { /* Ú-¿ Ú-¿ */
+ /* ... -Ù -Ù */
+ } else if (nPntAnz==6) { // S oder C oder ...
+ if (nAngle1!=nAngle2) {
+ // Fuer Typ S hat Linie2 dieselbe Richtung wie Linie4.
+ // Bei Typ C sind die beiden genau entgegengesetzt.
+ Point aP1(aXP1[1]);
+ Point aP2(aXP1[2]);
+ Point aP3(aXP1[3]);
+ Point aP4(aXP1[4]);
+ if (aP1.Y()==aP2.Y()) { // beide Linien Horz
+ if ((aP1.X()<aP2.X())==(aP3.X()<aP4.X())) cForm='S';
+ else cForm='C';
+ } else { // sonst beide Linien Vert
+ if ((aP1.Y()<aP2.Y())==(aP3.Y()<aP4.Y())) cForm='S';
+ else cForm='C';
+ }
+ } else cForm='4'; // sonst der 3. Fall mit 5 Linien
+ } else cForm='?'; //
+ // Weitere Formen:
+ if (bInfo) {
+ pInfo->cOrthoForm=cForm;
+ if (cForm=='I' || cForm=='L' || cForm=='Z' || cForm=='U') {
+ pInfo->nObj1Lines=1;
+ pInfo->nObj2Lines=1;
+ if (cForm=='Z' || cForm=='U') {
+ pInfo->nMiddleLine=1;
+ } else {
+ pInfo->nMiddleLine=0xFFFF;
+ }
+ } else if (cForm=='S' || cForm=='C') {
+ pInfo->nObj1Lines=2;
+ pInfo->nObj2Lines=2;
+ pInfo->nMiddleLine=2;
+ }
+ }
+ }
+ if (pnQuality!=NULL) {
+ ULONG nQual=0;
+ ULONG nQual0=nQual; // Ueberlaeufe vorbeugen
+ bool bOverflow = false;
+ Point aPt0(aXP1[0]);
+ for (USHORT nPntNum=1; nPntNum<nPntAnz; nPntNum++) {
+ Point aPt1b(aXP1[nPntNum]);
+ nQual+=Abs(aPt1b.X()-aPt0.X())+Abs(aPt1b.Y()-aPt0.Y());
+ if (nQual<nQual0) bOverflow = true;
+ nQual0=nQual;
+ aPt0=aPt1b;
+ }
+
+ USHORT nTmp=nPntAnz;
+ if (cForm=='Z') {
+ nTmp=2; // Z-Form hat gute Qualitaet (nTmp=2 statt 4)
+ ULONG n1=Abs(aXP1[1].X()-aXP1[0].X())+Abs(aXP1[1].Y()-aXP1[0].Y());
+ ULONG n2=Abs(aXP1[2].X()-aXP1[1].X())+Abs(aXP1[2].Y()-aXP1[1].Y());
+ ULONG n3=Abs(aXP1[3].X()-aXP1[2].X())+Abs(aXP1[3].Y()-aXP1[2].Y());
+ // fuer moeglichst gleichlange Linien sorgen
+ ULONG nBesser=0;
+ n1+=n3;
+ n3=n2/4;
+ if (n1>=n2) nBesser=6;
+ else if (n1>=3*n3) nBesser=4;
+ else if (n1>=2*n3) nBesser=2;
+ if (aXP1[0].Y()!=aXP1[1].Y()) nBesser++; // Senkrechte Startlinie kriegt auch noch einen Pluspunkt (fuer H/V-Prio)
+ if (nQual>nBesser) nQual-=nBesser; else nQual=0;
+ }
+ if (nTmp>=3) {
+ nQual0=nQual;
+ nQual+=(ULONG)nTmp*0x01000000;
+ if (nQual<nQual0 || nTmp>15) bOverflow = true;
+ }
+ if (nPntAnz>=2) { // Austrittswinkel nochmal pruefen
+ Point aP1(aXP1[1]); aP1-=aXP1[0];
+ Point aP2(aXP1[nPntAnz-2]); aP2-=aXP1[nPntAnz-1];
+ long nAng1=0; if (aP1.X()<0) nAng1=18000; if (aP1.Y()>0) nAng1=27000;
+ if (aP1.Y()<0) nAng1=9000; if (aP1.X()!=0 && aP1.Y()!=0) nAng1=1; // Schraeg!?!
+ long nAng2=0; if (aP2.X()<0) nAng2=18000; if (aP2.Y()>0) nAng2=27000;
+ if (aP2.Y()<0) nAng2=9000; if (aP2.X()!=0 && aP2.Y()!=0) nAng2=1; // Schraeg!?!
+ if (nAng1!=nAngle1) nIntersections++;
+ if (nAng2!=nAngle2) nIntersections++;
+ }
+
+ // Fuer den Qualitaetscheck wieder die Original-Rects verwenden und
+ // gleichzeitig checken, ob eins fuer die Edge-Berechnung verkleinert
+ // wurde (z.B. Fall 2.9)
+ aBewareRect1=rBewareRect1;
+ aBewareRect2=rBewareRect2;
+
+ for (USHORT i=0; i<nPntAnz; i++) {
+ Point aPt1b(aXP1[i]);
+ bool b1=aPt1b.X()>aBewareRect1.Left() && aPt1b.X()<aBewareRect1.Right() &&
+ aPt1b.Y()>aBewareRect1.Top() && aPt1b.Y()<aBewareRect1.Bottom();
+ bool b2=aPt1b.X()>aBewareRect2.Left() && aPt1b.X()<aBewareRect2.Right() &&
+ aPt1b.Y()>aBewareRect2.Top() && aPt1b.Y()<aBewareRect2.Bottom();
+ USHORT nInt0=nIntersections;
+ if (i==0 || i==nPntAnz-1) {
+ if (b1 && b2) nIntersections++;
+ } else {
+ if (b1) nIntersections++;
+ if (b2) nIntersections++;
+ }
+ // und nun noch auf Ueberschneidungen checken
+ if (i>0 && nInt0==nIntersections) {
+ if (aPt0.Y()==aPt1b.Y()) { // Horizontale Linie
+ if (aPt0.Y()>aBewareRect1.Top() && aPt0.Y()<aBewareRect1.Bottom() &&
+ ((aPt0.X()<=aBewareRect1.Left() && aPt1b.X()>=aBewareRect1.Right()) ||
+ (aPt1b.X()<=aBewareRect1.Left() && aPt0.X()>=aBewareRect1.Right()))) nIntersections++;
+ if (aPt0.Y()>aBewareRect2.Top() && aPt0.Y()<aBewareRect2.Bottom() &&
+ ((aPt0.X()<=aBewareRect2.Left() && aPt1b.X()>=aBewareRect2.Right()) ||
+ (aPt1b.X()<=aBewareRect2.Left() && aPt0.X()>=aBewareRect2.Right()))) nIntersections++;
+ } else { // Vertikale Linie
+ if (aPt0.X()>aBewareRect1.Left() && aPt0.X()<aBewareRect1.Right() &&
+ ((aPt0.Y()<=aBewareRect1.Top() && aPt1b.Y()>=aBewareRect1.Bottom()) ||
+ (aPt1b.Y()<=aBewareRect1.Top() && aPt0.Y()>=aBewareRect1.Bottom()))) nIntersections++;
+ if (aPt0.X()>aBewareRect2.Left() && aPt0.X()<aBewareRect2.Right() &&
+ ((aPt0.Y()<=aBewareRect2.Top() && aPt1b.Y()>=aBewareRect2.Bottom()) ||
+ (aPt1b.Y()<=aBewareRect2.Top() && aPt0.Y()>=aBewareRect2.Bottom()))) nIntersections++;
+ }
+ }
+ aPt0=aPt1b;
+ }
+ if (nPntAnz<=1) nIntersections++;
+ nQual0=nQual;
+ nQual+=(ULONG)nIntersections*0x10000000;
+ if (nQual<nQual0 || nIntersections>15) bOverflow = true;
+
+ if (bOverflow || nQual==0xFFFFFFFF) nQual=0xFFFFFFFE;
+ *pnQuality=nQual;
+ }
+ if (bInfo) { // nun die Linienversaetze auf aXP1 anwenden
+ if (pInfo->nMiddleLine!=0xFFFF) {
+ USHORT nIdx=pInfo->ImpGetPolyIdx(MIDDLELINE,aXP1);
+ if (pInfo->ImpIsHorzLine(MIDDLELINE,aXP1)) {
+ aXP1[nIdx].Y()+=pInfo->aMiddleLine.Y();
+ aXP1[nIdx+1].Y()+=pInfo->aMiddleLine.Y();
+ } else {
+ aXP1[nIdx].X()+=pInfo->aMiddleLine.X();
+ aXP1[nIdx+1].X()+=pInfo->aMiddleLine.X();
+ }
+ }
+ if (pInfo->nObj1Lines>=2) {
+ USHORT nIdx=pInfo->ImpGetPolyIdx(OBJ1LINE2,aXP1);
+ if (pInfo->ImpIsHorzLine(OBJ1LINE2,aXP1)) {
+ aXP1[nIdx].Y()+=pInfo->aObj1Line2.Y();
+ aXP1[nIdx+1].Y()+=pInfo->aObj1Line2.Y();
+ } else {
+ aXP1[nIdx].X()+=pInfo->aObj1Line2.X();
+ aXP1[nIdx+1].X()+=pInfo->aObj1Line2.X();
+ }
+ }
+ if (pInfo->nObj1Lines>=3) {
+ USHORT nIdx=pInfo->ImpGetPolyIdx(OBJ1LINE3,aXP1);
+ if (pInfo->ImpIsHorzLine(OBJ1LINE3,aXP1)) {
+ aXP1[nIdx].Y()+=pInfo->aObj1Line3.Y();
+ aXP1[nIdx+1].Y()+=pInfo->aObj1Line3.Y();
+ } else {
+ aXP1[nIdx].X()+=pInfo->aObj1Line3.X();
+ aXP1[nIdx+1].X()+=pInfo->aObj1Line3.X();
+ }
+ }
+ if (pInfo->nObj2Lines>=2) {
+ USHORT nIdx=pInfo->ImpGetPolyIdx(OBJ2LINE2,aXP1);
+ if (pInfo->ImpIsHorzLine(OBJ2LINE2,aXP1)) {
+ aXP1[nIdx].Y()+=pInfo->aObj2Line2.Y();
+ aXP1[nIdx+1].Y()+=pInfo->aObj2Line2.Y();
+ } else {
+ aXP1[nIdx].X()+=pInfo->aObj2Line2.X();
+ aXP1[nIdx+1].X()+=pInfo->aObj2Line2.X();
+ }
+ }
+ if (pInfo->nObj2Lines>=3) {
+ USHORT nIdx=pInfo->ImpGetPolyIdx(OBJ2LINE3,aXP1);
+ if (pInfo->ImpIsHorzLine(OBJ2LINE3,aXP1)) {
+ aXP1[nIdx].Y()+=pInfo->aObj2Line3.Y();
+ aXP1[nIdx+1].Y()+=pInfo->aObj2Line3.Y();
+ } else {
+ aXP1[nIdx].X()+=pInfo->aObj2Line3.X();
+ aXP1[nIdx+1].X()+=pInfo->aObj2Line3.X();
+ }
+ }
+ }
+ // Nun mache ich ggf. aus dem Verbinder eine Bezierkurve
+ if (eKind==SDREDGE_BEZIER && nPntAnz>2) {
+ Point* pPt1=&aXP1[0];
+ Point* pPt2=&aXP1[1];
+ Point* pPt3=&aXP1[nPntAnz-2];
+ Point* pPt4=&aXP1[nPntAnz-1];
+ long dx1=pPt2->X()-pPt1->X();
+ long dy1=pPt2->Y()-pPt1->Y();
+ long dx2=pPt3->X()-pPt4->X();
+ long dy2=pPt3->Y()-pPt4->Y();
+ if (cForm=='L') { // nPntAnz==3
+ aXP1.SetFlags(1,XPOLY_CONTROL);
+ Point aPt3(*pPt2);
+ aXP1.Insert(2,aPt3,XPOLY_CONTROL);
+ nPntAnz=aXP1.GetPointCount();
+ pPt1=&aXP1[0];
+ pPt2=&aXP1[1];
+ pPt3=&aXP1[nPntAnz-2];
+ pPt4=&aXP1[nPntAnz-1];
+ pPt2->X()-=dx1/3;
+ pPt2->Y()-=dy1/3;
+ pPt3->X()-=dx2/3;
+ pPt3->Y()-=dy2/3;
+ } else if (nPntAnz>=4 && nPntAnz<=6) { // Z oder U oder ...
+ // fuer Alle Anderen werden die Endpunkte der Ausgangslinien
+ // erstmal zu Kontrollpunkten. Bei nPntAnz>4 ist also noch
+ // Nacharbeit erforderlich!
+ aXP1.SetFlags(1,XPOLY_CONTROL);
+ aXP1.SetFlags(nPntAnz-2,XPOLY_CONTROL);
+ // Distanz x1.5
+ pPt2->X()+=dx1/2;
+ pPt2->Y()+=dy1/2;
+ pPt3->X()+=dx2/2;
+ pPt3->Y()+=dy2/2;
+ if (nPntAnz==5) {
+ // Vor und hinter dem Mittelpunkt jeweils
+ // noch einen Kontrollpunkt einfuegen
+ Point aCenter(aXP1[2]);
+ long dx1b=aCenter.X()-aXP1[1].X();
+ long dy1b=aCenter.Y()-aXP1[1].Y();
+ long dx2b=aCenter.X()-aXP1[3].X();
+ long dy2b=aCenter.Y()-aXP1[3].Y();
+ aXP1.Insert(2,aCenter,XPOLY_CONTROL);
+ aXP1.SetFlags(3,XPOLY_SYMMTR);
+ aXP1.Insert(4,aCenter,XPOLY_CONTROL);
+ aXP1[2].X()-=dx1b/2;
+ aXP1[2].Y()-=dy1b/2;
+ aXP1[3].X()-=(dx1b+dx2b)/4;
+ aXP1[3].Y()-=(dy1b+dy2b)/4;
+ aXP1[4].X()-=dx2b/2;
+ aXP1[4].Y()-=dy2b/2;
+ }
+ if (nPntAnz==6) {
+ Point aPt1b(aXP1[2]);
+ Point aPt2b(aXP1[3]);
+ aXP1.Insert(2,aPt1b,XPOLY_CONTROL);
+ aXP1.Insert(5,aPt2b,XPOLY_CONTROL);
+ long dx=aPt1b.X()-aPt2b.X();
+ long dy=aPt1b.Y()-aPt2b.Y();
+ aXP1[3].X()-=dx/2;
+ aXP1[3].Y()-=dy/2;
+ aXP1.SetFlags(3,XPOLY_SYMMTR);
+ //aXP1[4].X()+=dx/2;
+ //aXP1[4].Y()+=dy/2;
+ aXP1.Remove(4,1); // weil identisch mit aXP1[3]
+ }
+ }
+ }
+ return aXP1;
+}
+
+/*
+Nach einer einfachen Rechnung koennte es max. 64 unterschiedliche Verlaeufe mit
+5 Linien, 32 mit 4 Linien, 16 mit 3, 8 mit 2 Linien und 4 mit 1 Linie geben=124.
+Normalisiert auf 1. Austrittswinkel nach rechts bleiben dann noch 31.
+Dann noch eine vertikale Spiegelung wegnormalisiert bleiben noch 16
+characteristische Verlaufszuege mit 1-5 Linien:
+Mit 1 Linie (Typ 'I'): --
+Mit 2 Linien (Typ 'L'): -Ù
+Mit 3 Linien (Typ 'U'): -¿ (Typ 'Z'): Ú-
+ -Ù -Ù
+Mit 4 Linien: 1 ist nicht plausibel, 3 ist=2 (90deg Drehung). Verbleibt 2,4
+ Ú-Ù Ú¿ À¿ Ú¿ Ú¿ Ú-¿
+ -Ù -Ù -Ù -Ù -Ù -Ù
+Mit 5 Linien: nicht plausibel sind 1,2,4,5. 7 ist identisch mit 3 (Richtungsumkehr)
+ Bleibt also 3,6 und 8. '4' 'S' 'C'
+ ¿ Ú -¿ Ú- Ú-¿ Ú-
+ Ú-Ù Ú-Ù Ú-¿ Ú-¿ À¿ À¿ -Ù ³ Ú-¿ Ú-¿ À¿ Ú-¿
+ -Ù -Ù -Ù Ù -Ù À- -Ù -Ù --Ù À Ù -Ù Ù -Ù À Ù
+Insgesamt sind also 9 Grundtypen zu unterscheiden die den 400 Konstellationen
+aus Objektposition und Austrittswinkeln zuzuordnen sind.
+4 der 9 Grundtypen haben eine 'Mittellinie'. Die Anzahl der zu Objektabstaende
+je Objekt variiert von 0-3:
+ Mi O1 O2 Anmerkung
+'I': n 0 0
+'L': n 0 0
+'U': n 0-1 0-1
+'Z': j 0 0
+4.1: j 0 1 = U+1 bzw. 1+U
+4.2: n 0-2 0-2 = Z+1
+'4': j 0 2 = Z+2
+'S': j 1 1 = 1+Z+1
+'C': n 0-3 0-3 = 1+U+1
+*/
+
+void __EXPORT SdrEdgeObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+{
+ SfxSimpleHint* pSimple=PTR_CAST(SfxSimpleHint,&rHint);
+ ULONG nId=pSimple==0 ? 0 : pSimple->GetId();
+ bool bDataChg=nId==SFX_HINT_DATACHANGED;
+ bool bDying=nId==SFX_HINT_DYING;
+ bool bObj1=aCon1.pObj!=NULL && aCon1.pObj->GetBroadcaster()==&rBC;
+ bool bObj2=aCon2.pObj!=NULL && aCon2.pObj->GetBroadcaster()==&rBC;
+ if (bDying && (bObj1 || bObj2)) {
+ // #35605# Dying vorher abfangen, damit AttrObj nicht
+ // wg. vermeintlicher Vorlagenaenderung rumbroadcastet
+ if (bObj1) aCon1.pObj=NULL;
+ if (bObj2) aCon2.pObj=NULL;
+ return; // Und mehr braucht hier nicht getan werden.
+ }
+ if ( bObj1 || bObj2 )
+ {
+ bEdgeTrackUserDefined = sal_False;
+ }
+ SdrTextObj::Notify(rBC,rHint);
+ if (nNotifyingCount==0) { // Hier nun auch ein VerriegelungsFlag
+ ((SdrEdgeObj*)this)->nNotifyingCount++;
+ SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint);
+ if (bDataChg) { // StyleSheet geaendert
+ ImpSetAttrToEdgeInfo(); // Werte bei Vorlagenaenderung vom Pool nach aEdgeInfo kopieren
+ }
+ if (bDataChg ||
+ (bObj1 && aCon1.pObj->GetPage()==pPage) ||
+ (bObj2 && aCon2.pObj->GetPage()==pPage) ||
+ (pSdrHint && pSdrHint->GetKind()==HINT_OBJREMOVED))
+ {
+ // Broadcasting nur, wenn auf der selben Page
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 if (!bEdgeTrackDirty) SendRepaintBroadcast();
+ ImpDirtyEdgeTrack();
+
+ // only redraw here, no objectchange
+ ActionChanged();
+ // BroadcastObjectChange();
+
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+ ((SdrEdgeObj*)this)->nNotifyingCount--;
+ }
+}
+
+/** updates edges that are connected to the edges of this object
+ as if the connected objects send a repaint broadcast
+ #103122#
+*/
+void SdrEdgeObj::Reformat()
+{
+ if( NULL != aCon1.pObj )
+ {
+ SfxSimpleHint aHint( SFX_HINT_DATACHANGED );
+ Notify( *const_cast<SfxBroadcaster*>(aCon1.pObj->GetBroadcaster()), aHint );
+ }
+
+ if( NULL != aCon2.pObj )
+ {
+ SfxSimpleHint aHint( SFX_HINT_DATACHANGED );
+ Notify( *const_cast<SfxBroadcaster*>(aCon2.pObj->GetBroadcaster()), aHint );
+ }
+}
+
+void SdrEdgeObj::operator=(const SdrObject& rObj)
+{
+ SdrTextObj::operator=(rObj);
+ *pEdgeTrack =*((SdrEdgeObj&)rObj).pEdgeTrack;
+ bEdgeTrackDirty=((SdrEdgeObj&)rObj).bEdgeTrackDirty;
+ aCon1 =((SdrEdgeObj&)rObj).aCon1;
+ aCon2 =((SdrEdgeObj&)rObj).aCon2;
+ aCon1.pObj=NULL;
+ aCon2.pObj=NULL;
+ aEdgeInfo=((SdrEdgeObj&)rObj).aEdgeInfo;
+}
+
+void SdrEdgeObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulEDGE);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+void SdrEdgeObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralEDGE);
+}
+
+basegfx::B2DPolyPolygon SdrEdgeObj::TakeXorPoly() const
+{
+ basegfx::B2DPolyPolygon aPolyPolygon;
+
+ if (bEdgeTrackDirty)
+ {
+ ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack();
+ }
+
+ if(pEdgeTrack)
+ {
+ aPolyPolygon.append(pEdgeTrack->getB2DPolygon());
+ }
+
+ return aPolyPolygon;
+}
+
+void SdrEdgeObj::SetEdgeTrackPath( const basegfx::B2DPolyPolygon& rPoly )
+{
+ if ( !rPoly.count() )
+ {
+ bEdgeTrackDirty = sal_True;
+ bEdgeTrackUserDefined = sal_False;
+ }
+ else
+ {
+ *pEdgeTrack = XPolygon( rPoly.getB2DPolygon( 0 ) );
+ bEdgeTrackDirty = sal_False;
+ bEdgeTrackUserDefined = sal_True;
+
+ // #i110629# also set aRect and maSnapeRect dependent from pEdgeTrack
+ const Rectangle aPolygonBounds(pEdgeTrack->GetBoundRect());
+ aRect = aPolygonBounds;
+ maSnapRect = aPolygonBounds;
+ }
+}
+
+basegfx::B2DPolyPolygon SdrEdgeObj::GetEdgeTrackPath() const
+{
+ basegfx::B2DPolyPolygon aPolyPolygon;
+
+ if (bEdgeTrackDirty)
+ ((SdrEdgeObj*)this)->ImpRecalcEdgeTrack();
+
+ aPolyPolygon.append( pEdgeTrack->getB2DPolygon() );
+
+ return aPolyPolygon;
+}
+
+sal_uInt32 SdrEdgeObj::GetHdlCount() const
+{
+ SdrEdgeKind eKind=((SdrEdgeKindItem&)(GetObjectItem(SDRATTR_EDGEKIND))).GetValue();
+ sal_uInt32 nHdlAnz(0L);
+ sal_uInt32 nPntAnz(pEdgeTrack->GetPointCount());
+
+ if(nPntAnz)
+ {
+ nHdlAnz = 2L;
+
+ if ((eKind==SDREDGE_ORTHOLINES || eKind==SDREDGE_BEZIER) && nPntAnz >= 4L)
+ {
+ sal_uInt32 nO1(aEdgeInfo.nObj1Lines > 0L ? aEdgeInfo.nObj1Lines - 1L : 0L);
+ sal_uInt32 nO2(aEdgeInfo.nObj2Lines > 0L ? aEdgeInfo.nObj2Lines - 1L : 0L);
+ sal_uInt32 nM(aEdgeInfo.nMiddleLine != 0xFFFF ? 1L : 0L);
+ nHdlAnz += nO1 + nO2 + nM;
+ }
+ else if (eKind==SDREDGE_THREELINES && nPntAnz == 4L)
+ {
+ if(GetConnectedNode(TRUE))
+ nHdlAnz++;
+
+ if(GetConnectedNode(FALSE))
+ nHdlAnz++;
+ }
+ }
+
+ return nHdlAnz;
+}
+
+SdrHdl* SdrEdgeObj::GetHdl(sal_uInt32 nHdlNum) const
+{
+ SdrHdl* pHdl=NULL;
+ sal_uInt32 nPntAnz(pEdgeTrack->GetPointCount());
+ if (nPntAnz!=0) {
+ if (nHdlNum==0) {
+ pHdl=new ImpEdgeHdl((*pEdgeTrack)[0],HDL_POLY);
+ if (aCon1.pObj!=NULL && aCon1.bBestVertex) pHdl->Set1PixMore(TRUE);
+ } else if (nHdlNum==1) {
+ pHdl=new ImpEdgeHdl((*pEdgeTrack)[USHORT(nPntAnz-1)],HDL_POLY);
+ if (aCon2.pObj!=NULL && aCon2.bBestVertex) pHdl->Set1PixMore(TRUE);
+ } else {
+ SdrEdgeKind eKind=((SdrEdgeKindItem&)(GetObjectItem(SDRATTR_EDGEKIND))).GetValue();
+ if (eKind==SDREDGE_ORTHOLINES || eKind==SDREDGE_BEZIER) {
+ sal_uInt32 nO1(aEdgeInfo.nObj1Lines > 0L ? aEdgeInfo.nObj1Lines - 1L : 0L);
+ sal_uInt32 nO2(aEdgeInfo.nObj2Lines > 0L ? aEdgeInfo.nObj2Lines - 1L : 0L);
+ sal_uInt32 nM(aEdgeInfo.nMiddleLine != 0xFFFF ? 1L : 0L);
+ sal_uInt32 nNum(nHdlNum - 2L);
+ sal_Int32 nPt(0L);
+ pHdl=new ImpEdgeHdl(Point(),HDL_POLY);
+ if (nNum<nO1) {
+ nPt=nNum+1L;
+ if (nNum==0) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ1LINE2);
+ if (nNum==1) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ1LINE3);
+ } else {
+ nNum=nNum-nO1;
+ if (nNum<nO2) {
+ nPt=nPntAnz-3-nNum;
+ if (nNum==0) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ2LINE2);
+ if (nNum==1) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ2LINE3);
+ } else {
+ nNum=nNum-nO2;
+ if (nNum<nM) {
+ nPt=aEdgeInfo.nMiddleLine;
+ ((ImpEdgeHdl*)pHdl)->SetLineCode(MIDDLELINE);
+ }
+ }
+ }
+ if (nPt>0) {
+ Point aPos((*pEdgeTrack)[(sal_uInt16)nPt]);
+ aPos+=(*pEdgeTrack)[(sal_uInt16)nPt+1];
+ aPos.X()/=2;
+ aPos.Y()/=2;
+ pHdl->SetPos(aPos);
+ } else {
+ delete pHdl;
+ pHdl=NULL;
+ }
+ } else if (eKind==SDREDGE_THREELINES) {
+ sal_uInt32 nNum(nHdlNum);
+ if (GetConnectedNode(TRUE)==NULL) nNum++;
+ Point aPos((*pEdgeTrack)[(sal_uInt16)nNum-1]);
+ pHdl=new ImpEdgeHdl(aPos,HDL_POLY);
+ if (nNum==2) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ1LINE2);
+ if (nNum==3) ((ImpEdgeHdl*)pHdl)->SetLineCode(OBJ2LINE2);
+ }
+ }
+ if (pHdl!=NULL) {
+ pHdl->SetPointNum(nHdlNum);
+ }
+ }
+ return pHdl;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrEdgeObj::hasSpecialDrag() const
+{
+ return true;
+}
+
+SdrObject* SdrEdgeObj::getFullDragClone() const
+{
+ // use Clone operator
+ SdrEdgeObj* pRetval = (SdrEdgeObj*)Clone();
+
+ // copy connections for clone, SdrEdgeObj::operator= does not do this
+ pRetval->ConnectToNode(true, GetConnectedNode(true));
+ pRetval->ConnectToNode(false, GetConnectedNode(false));
+
+ return pRetval;
+}
+
+bool SdrEdgeObj::beginSpecialDrag(SdrDragStat& rDrag) const
+{
+ if(!rDrag.GetHdl())
+ return false;
+
+ rDrag.SetEndDragChangesAttributes(true);
+
+ if(rDrag.GetHdl()->GetPointNum() < 2)
+ {
+ rDrag.SetNoSnap(true);
+ }
+
+ return true;
+}
+
+bool SdrEdgeObj::applySpecialDrag(SdrDragStat& rDragStat)
+{
+ SdrEdgeObj* pOriginalEdge = dynamic_cast< SdrEdgeObj* >(rDragStat.GetHdl()->GetObj());
+ const bool bOriginalEdgeModified(pOriginalEdge == this);
+
+ if(!bOriginalEdgeModified && pOriginalEdge)
+ {
+ // copy connections when clone is modified. This is needed because
+ // as preparation to this modification the data from the original object
+ // was copied to the clone using the operator=. As can be seen there,
+ // that operator does not copy the connections (for good reason)
+ ConnectToNode(true, pOriginalEdge->GetConnection(true).GetObject());
+ ConnectToNode(false, pOriginalEdge->GetConnection(false).GetObject());
+ }
+
+ if(rDragStat.GetHdl()->GetPointNum() < 2)
+ {
+ // start or end point connector drag
+ const bool bDragA(0 == rDragStat.GetHdl()->GetPointNum());
+ const Point aPointNow(rDragStat.GetNow());
+
+ if(rDragStat.GetPageView())
+ {
+ SdrObjConnection* pDraggedOne(bDragA ? &aCon1 : &aCon2);
+
+ // clear connection
+ DisconnectFromNode(bDragA);
+
+ // look for new connection
+ ImpFindConnector(aPointNow, *rDragStat.GetPageView(), *pDraggedOne, pOriginalEdge);
+
+ if(pDraggedOne->pObj)
+ {
+ // if found, officially connect to it; ImpFindConnector only
+ // sets pObj hard
+ SdrObject* pNewConnection = pDraggedOne->pObj;
+ pDraggedOne->pObj = 0;
+ ConnectToNode(bDragA, pNewConnection);
+ }
+
+ if(rDragStat.GetView() && !bOriginalEdgeModified)
+ {
+ // show IA helper, but only do this during IA, so not when the original
+ // Edge gets modified in the last call
+ rDragStat.GetView()->SetConnectMarker(*pDraggedOne, *rDragStat.GetPageView());
+ }
+ }
+
+ if(pEdgeTrack)
+ {
+ // change pEdgeTrack to modified position
+ if(bDragA)
+ {
+ (*pEdgeTrack)[0] = aPointNow;
+ }
+ else
+ {
+ (*pEdgeTrack)[sal_uInt16(pEdgeTrack->GetPointCount()-1)] = aPointNow;
+ }
+ }
+
+ // reset edge info's offsets, this is a end point drag
+ aEdgeInfo.aObj1Line2 = Point();
+ aEdgeInfo.aObj1Line3 = Point();
+ aEdgeInfo.aObj2Line2 = Point();
+ aEdgeInfo.aObj2Line3 = Point();
+ aEdgeInfo.aMiddleLine = Point();
+ }
+ else
+ {
+ // control point connector drag
+ const ImpEdgeHdl* pEdgeHdl = (ImpEdgeHdl*)rDragStat.GetHdl();
+ const SdrEdgeLineCode eLineCode = pEdgeHdl->GetLineCode();
+ const Point aDist(rDragStat.GetNow() - rDragStat.GetStart());
+ sal_Int32 nDist(pEdgeHdl->IsHorzDrag() ? aDist.X() : aDist.Y());
+
+ nDist += aEdgeInfo.ImpGetLineVersatz(eLineCode, *pEdgeTrack);
+ aEdgeInfo.ImpSetLineVersatz(eLineCode, *pEdgeTrack, nDist);
+ }
+
+ // force recalc EdgeTrack
+ *pEdgeTrack = ImpCalcEdgeTrack(*pEdgeTrack, aCon1, aCon2, &aEdgeInfo);
+ bEdgeTrackDirty=FALSE;
+
+ // save EdgeInfos and mark object as user modified
+ ImpSetEdgeInfoToAttr();
+ bEdgeTrackUserDefined = false;
+ //SetRectsDirty();
+ //SetChanged();
+
+ if(bOriginalEdgeModified && rDragStat.GetView())
+ {
+ // hide connect marker helper again when original gets changed.
+ // This happens at the end of the interaction
+ rDragStat.GetView()->HideConnectMarker();
+ }
+
+ return true;
+}
+
+String SdrEdgeObj::getSpecialDragComment(const SdrDragStat& rDrag) const
+{
+ const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj());
+
+ if(bCreateComment)
+ {
+ return String();
+ }
+ else
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_DragEdgeTail, aStr);
+
+ return aStr;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+basegfx::B2DPolygon SdrEdgeObj::ImplAddConnectorOverlay(SdrDragMethod& rDragMethod, bool bTail1, bool bTail2, bool bDetail) const
+{
+ basegfx::B2DPolygon aResult;
+
+ if(bDetail)
+ {
+ SdrObjConnection aMyCon1(aCon1);
+ SdrObjConnection aMyCon2(aCon2);
+
+ if (bTail1)
+ {
+ const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aMyCon1.aObjOfs.X(), aMyCon1.aObjOfs.Y()));
+ aMyCon1.aObjOfs.X() = basegfx::fround(aTemp.getX());
+ aMyCon1.aObjOfs.Y() = basegfx::fround(aTemp.getY());
+ }
+
+ if (bTail2)
+ {
+ const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aMyCon2.aObjOfs.X(), aMyCon2.aObjOfs.Y()));
+ aMyCon2.aObjOfs.X() = basegfx::fround(aTemp.getX());
+ aMyCon2.aObjOfs.Y() = basegfx::fround(aTemp.getY());
+ }
+
+ SdrEdgeInfoRec aInfo(aEdgeInfo);
+ XPolygon aXP(ImpCalcEdgeTrack(*pEdgeTrack, aMyCon1, aMyCon2, &aInfo));
+
+ if(aXP.GetPointCount())
+ {
+ aResult = aXP.getB2DPolygon();
+ }
+ }
+ else
+ {
+ Point aPt1((*pEdgeTrack)[0]);
+ Point aPt2((*pEdgeTrack)[sal_uInt16(pEdgeTrack->GetPointCount() - 1)]);
+
+ if (aCon1.pObj && (aCon1.bBestConn || aCon1.bBestVertex))
+ aPt1 = aCon1.pObj->GetSnapRect().Center();
+
+ if (aCon2.pObj && (aCon2.bBestConn || aCon2.bBestVertex))
+ aPt2 = aCon2.pObj->GetSnapRect().Center();
+
+ if (bTail1)
+ {
+ const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aPt1.X(), aPt1.Y()));
+ aPt1.X() = basegfx::fround(aTemp.getX());
+ aPt1.Y() = basegfx::fround(aTemp.getY());
+ }
+
+ if (bTail2)
+ {
+ const basegfx::B2DPoint aTemp(rDragMethod.getCurrentTransformation() * basegfx::B2DPoint(aPt2.X(), aPt2.Y()));
+ aPt2.X() = basegfx::fround(aTemp.getX());
+ aPt2.Y() = basegfx::fround(aTemp.getY());
+ }
+
+ aResult.append(basegfx::B2DPoint(aPt1.X(), aPt1.Y()));
+ aResult.append(basegfx::B2DPoint(aPt2.X(), aPt2.Y()));
+ }
+
+ return aResult;
+}
+
+bool SdrEdgeObj::BegCreate(SdrDragStat& rDragStat)
+{
+ rDragStat.SetNoSnap(TRUE);
+ pEdgeTrack->SetPointCount(2);
+ (*pEdgeTrack)[0]=rDragStat.GetStart();
+ (*pEdgeTrack)[1]=rDragStat.GetNow();
+ if (rDragStat.GetPageView()!=NULL) {
+ ImpFindConnector(rDragStat.GetStart(),*rDragStat.GetPageView(),aCon1,this);
+ ConnectToNode(TRUE,aCon1.pObj);
+ }
+ *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo);
+ return TRUE;
+}
+
+bool SdrEdgeObj::MovCreate(SdrDragStat& rDragStat)
+{
+ USHORT nMax=pEdgeTrack->GetPointCount();
+ (*pEdgeTrack)[nMax-1]=rDragStat.GetNow();
+ if (rDragStat.GetPageView()!=NULL) {
+ ImpFindConnector(rDragStat.GetNow(),*rDragStat.GetPageView(),aCon2,this);
+ rDragStat.GetView()->SetConnectMarker(aCon2,*rDragStat.GetPageView());
+ }
+ SetBoundRectDirty();
+ bSnapRectDirty=TRUE;
+ ConnectToNode(FALSE,aCon2.pObj);
+ *pEdgeTrack=ImpCalcEdgeTrack(*pEdgeTrack,aCon1,aCon2,&aEdgeInfo);
+ bEdgeTrackDirty=FALSE;
+ return TRUE;
+}
+
+bool SdrEdgeObj::EndCreate(SdrDragStat& rDragStat, SdrCreateCmd eCmd)
+{
+ bool bOk=(eCmd==SDRCREATE_FORCEEND || rDragStat.GetPointAnz()>=2);
+ if (bOk) {
+ ConnectToNode(TRUE,aCon1.pObj);
+ ConnectToNode(FALSE,aCon2.pObj);
+ if (rDragStat.GetView()!=NULL) {
+ rDragStat.GetView()->HideConnectMarker();
+ }
+ ImpSetEdgeInfoToAttr(); // Die Werte aus aEdgeInfo in den Pool kopieren
+ }
+ SetRectsDirty();
+ return bOk;
+}
+
+bool SdrEdgeObj::BckCreate(SdrDragStat& rDragStat)
+{
+ if (rDragStat.GetView()!=NULL) {
+ rDragStat.GetView()->HideConnectMarker();
+ }
+ return FALSE;
+}
+
+void SdrEdgeObj::BrkCreate(SdrDragStat& rDragStat)
+{
+ if (rDragStat.GetView()!=NULL) {
+ rDragStat.GetView()->HideConnectMarker();
+ }
+}
+
+basegfx::B2DPolyPolygon SdrEdgeObj::TakeCreatePoly(const SdrDragStat& /*rStatDrag*/) const
+{
+ basegfx::B2DPolyPolygon aRetval;
+ aRetval.append(pEdgeTrack->getB2DPolygon());
+ return aRetval;
+}
+
+Pointer SdrEdgeObj::GetCreatePointer() const
+{
+ return Pointer(POINTER_DRAW_CONNECT);
+}
+
+bool SdrEdgeObj::ImpFindConnector(const Point& rPt, const SdrPageView& rPV, SdrObjConnection& rCon, const SdrEdgeObj* pThis, OutputDevice* pOut)
+{
+ rCon.ResetVars();
+ if (pOut==NULL) pOut=rPV.GetView().GetFirstOutputDevice(); // GetWin(0);
+ if (pOut==NULL) return FALSE;
+ SdrObjList* pOL=rPV.GetObjList();
+ const SetOfByte& rVisLayer=rPV.GetVisibleLayers();
+ // Sensitiver Bereich der Konnektoren ist doppelt so gross wie die Handles:
+ USHORT nMarkHdSiz=rPV.GetView().GetMarkHdlSizePixel();
+ Size aHalfConSiz(nMarkHdSiz,nMarkHdSiz);
+ aHalfConSiz=pOut->PixelToLogic(aHalfConSiz);
+ Size aHalfCenterSiz(2*aHalfConSiz.Width(),2*aHalfConSiz.Height());
+ Rectangle aMouseRect(rPt,rPt);
+ aMouseRect.Left() -=aHalfConSiz.Width();
+ aMouseRect.Top() -=aHalfConSiz.Height();
+ aMouseRect.Right() +=aHalfConSiz.Width();
+ aMouseRect.Bottom()+=aHalfConSiz.Height();
+ USHORT nBoundHitTol=(USHORT)aHalfConSiz.Width()/2; if (nBoundHitTol==0) nBoundHitTol=1;
+ ULONG no=pOL->GetObjCount();
+ bool bFnd = false;
+ SdrObjConnection aTestCon;
+ SdrObjConnection aBestCon;
+ bool bTestBoundHit = false;
+ //bool bBestBoundHit=FALSE;
+
+ while (no>0 && !bFnd) {
+ // Problem: Gruppenobjekt mit verschiedenen Layern liefert LayerID 0 !!!!
+ no--;
+ SdrObject* pObj=pOL->GetObj(no);
+ if (rVisLayer.IsSet(pObj->GetLayer()) && pObj->IsVisible() && // only visible objects
+ (pThis==NULL || pObj!=(SdrObject*)pThis) && // nicht an mich selbst connecten
+ pObj->IsNode())
+ {
+ Rectangle aObjBound(pObj->GetCurrentBoundRect());
+ if (aObjBound.IsOver(aMouseRect)) {
+ aTestCon.ResetVars();
+ bTestBoundHit = false;
+ bool bEdge=HAS_BASE(SdrEdgeObj,pObj); // kein BestCon fuer Edge
+ // Die Userdefined Konnektoren haben absolute Prioritaet.
+ // Danach kommt Vertex, Corner und Mitte(Best) gleich priorisiert.
+ // Zum Schluss kommt noch ein HitTest aufs Obj.
+ const SdrGluePointList* pGPL=pObj->GetGluePointList();
+ USHORT nConAnz=pGPL==NULL ? 0 : pGPL->GetCount();
+ USHORT nGesAnz=nConAnz+9;
+ bool bUserFnd = false;
+ ULONG nBestDist=0xFFFFFFFF;
+ for (USHORT i=0; i<nGesAnz; i++)
+ {
+ bool bUser=i<nConAnz;
+ bool bVertex=i>=nConAnz+0 && i<nConAnz+4;
+ bool bCorner=i>=nConAnz+4 && i<nConAnz+8;
+ bool bCenter=i==nConAnz+8;
+ bool bOk = false;
+ Point aConPos;
+ USHORT nConNum=i;
+ if (bUser) {
+ const SdrGluePoint& rGP=(*pGPL)[nConNum];
+ aConPos=rGP.GetAbsolutePos(*pObj);
+ nConNum=rGP.GetId();
+ bOk = true;
+ } else if (bVertex && !bUserFnd) {
+ nConNum=nConNum-nConAnz;
+ if (rPV.GetView().IsAutoVertexConnectors()) {
+ SdrGluePoint aPt(pObj->GetVertexGluePoint(nConNum));
+ aConPos=aPt.GetAbsolutePos(*pObj);
+ bOk = true;
+ } else i+=3;
+ } else if (bCorner && !bUserFnd) {
+ nConNum-=nConAnz+4;
+ if (rPV.GetView().IsAutoCornerConnectors()) {
+ SdrGluePoint aPt(pObj->GetCornerGluePoint(nConNum));
+ aConPos=aPt.GetAbsolutePos(*pObj);
+ bOk = true;
+ } else i+=3;
+ }
+ else if (bCenter && !bUserFnd && !bEdge)
+ {
+ // #109007#
+ // Suppress default connect at object center
+ if(!pThis || !pThis->GetSuppressDefaultConnect())
+ {
+ // Edges nicht!
+ nConNum=0;
+ aConPos=aObjBound.Center();
+ bOk = true;
+ }
+ }
+ if (bOk && aMouseRect.IsInside(aConPos)) {
+ if (bUser) bUserFnd = true;
+ bFnd = true;
+ ULONG nDist=(ULONG)Abs(aConPos.X()-rPt.X())+(ULONG)Abs(aConPos.Y()-rPt.Y());
+ if (nDist<nBestDist) {
+ nBestDist=nDist;
+ aTestCon.pObj=pObj;
+ aTestCon.nConId=nConNum;
+ aTestCon.bAutoCorner=bCorner;
+ aTestCon.bAutoVertex=bVertex;
+ aTestCon.bBestConn=FALSE; // bCenter;
+ aTestCon.bBestVertex=bCenter;
+ }
+ }
+ }
+ // Falls kein Konnektor getroffen wird nochmal
+ // HitTest versucht fuer BestConnector (=bCenter)
+ if(!bFnd &&
+ !bEdge &&
+ SdrObjectPrimitiveHit(*pObj, rPt, nBoundHitTol, rPV, &rVisLayer, false))
+ {
+ // #109007#
+ // Suppress default connect at object inside bound
+ if(!pThis || !pThis->GetSuppressDefaultConnect())
+ {
+ bFnd = true;
+ aTestCon.pObj=pObj;
+ aTestCon.bBestConn=TRUE;
+ }
+ }
+ if (bFnd) {
+ Rectangle aMouseRect2(rPt,rPt);
+ aMouseRect.Left() -=nBoundHitTol;
+ aMouseRect.Top() -=nBoundHitTol;
+ aMouseRect.Right() +=nBoundHitTol;
+ aMouseRect.Bottom()+=nBoundHitTol;
+ bTestBoundHit=aObjBound.IsOver(aMouseRect2);
+ }
+
+ }
+ }
+ }
+ rCon=aTestCon;
+ return bFnd;
+}
+
+void SdrEdgeObj::NbcSetSnapRect(const Rectangle& rRect)
+{
+ const Rectangle aOld(GetSnapRect());
+
+ if(aOld != rRect)
+ {
+ if(aRect.IsEmpty() && 0 == pEdgeTrack->GetPointCount())
+ {
+ // #i110629# When initializing, do not scale on empty Rectangle; this
+ // will mirror the underlying text object (!)
+ aRect = rRect;
+ maSnapRect = rRect;
+ }
+ else
+ {
+ long nMulX = rRect.Right() - rRect.Left();
+ long nDivX = aOld.Right() - aOld.Left();
+ long nMulY = rRect.Bottom() - rRect.Top();
+ long nDivY = aOld.Bottom() - aOld.Top();
+ if ( nDivX == 0 ) { nMulX = 1; nDivX = 1; }
+ if ( nDivY == 0 ) { nMulY = 1; nDivY = 1; }
+ Fraction aX(nMulX, nDivX);
+ Fraction aY(nMulY, nDivY);
+ NbcResize(aOld.TopLeft(), aX, aY);
+ NbcMove(Size(rRect.Left() - aOld.Left(), rRect.Top() - aOld.Top()));
+ }
+ }
+}
+
+void SdrEdgeObj::NbcMove(const Size& rSiz)
+{
+ SdrTextObj::NbcMove(rSiz);
+ MoveXPoly(*pEdgeTrack,rSiz);
+}
+
+void SdrEdgeObj::NbcResize(const Point& rRefPnt, const Fraction& aXFact, const Fraction& aYFact)
+{
+ SdrTextObj::NbcResize(rRefPnt,aXFact,aXFact);
+ ResizeXPoly(*pEdgeTrack,rRefPnt,aXFact,aYFact);
+
+ // #75371# if resize is not from paste, forget user distances
+ if(!GetModel()->IsPasteResize())
+ {
+ // #75735#
+ aEdgeInfo.aObj1Line2 = Point();
+ aEdgeInfo.aObj1Line3 = Point();
+ aEdgeInfo.aObj2Line2 = Point();
+ aEdgeInfo.aObj2Line3 = Point();
+ aEdgeInfo.aMiddleLine = Point();
+ }
+}
+
+SdrObject* SdrEdgeObj::DoConvertToPolyObj(BOOL bBezier) const
+{
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ aPolyPolygon.append(pEdgeTrack->getB2DPolygon());
+ SdrObject* pRet = ImpConvertMakeObj(aPolyPolygon, sal_False, bBezier);
+ pRet = ImpConvertAddText(pRet, bBezier);
+
+ return pRet;
+}
+
+sal_uInt32 SdrEdgeObj::GetSnapPointCount() const
+{
+ return 2L;
+}
+
+Point SdrEdgeObj::GetSnapPoint(sal_uInt32 i) const
+{
+ ((SdrEdgeObj*)this)->ImpUndirtyEdgeTrack();
+ USHORT nAnz=pEdgeTrack->GetPointCount();
+ if (i==0) return (*pEdgeTrack)[0];
+ else return (*pEdgeTrack)[nAnz-1];
+}
+
+sal_Bool SdrEdgeObj::IsPolyObj() const
+{
+ return sal_False;
+}
+
+sal_uInt32 SdrEdgeObj::GetPointCount() const
+{
+ return 0L;
+}
+
+Point SdrEdgeObj::GetPoint(sal_uInt32 i) const
+{
+ ((SdrEdgeObj*)this)->ImpUndirtyEdgeTrack();
+ USHORT nAnz=pEdgeTrack->GetPointCount();
+ if (0L == i)
+ return (*pEdgeTrack)[0];
+ else
+ return (*pEdgeTrack)[nAnz-1];
+}
+
+void SdrEdgeObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)
+{
+ // ToDo: Umconnekten fehlt noch
+ ImpUndirtyEdgeTrack();
+ USHORT nAnz=pEdgeTrack->GetPointCount();
+ if (0L == i)
+ (*pEdgeTrack)[0]=rPnt;
+ if (1L == i)
+ (*pEdgeTrack)[nAnz-1]=rPnt;
+ SetEdgeTrackDirty();
+ SetRectsDirty();
+}
+
+SdrEdgeObjGeoData::SdrEdgeObjGeoData()
+{
+ pEdgeTrack=new XPolygon;
+}
+
+SdrEdgeObjGeoData::~SdrEdgeObjGeoData()
+{
+ delete pEdgeTrack;
+}
+
+SdrObjGeoData* SdrEdgeObj::NewGeoData() const
+{
+ return new SdrEdgeObjGeoData;
+}
+
+void SdrEdgeObj::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ SdrTextObj::SaveGeoData(rGeo);
+ SdrEdgeObjGeoData& rEGeo=(SdrEdgeObjGeoData&)rGeo;
+ rEGeo.aCon1 =aCon1;
+ rEGeo.aCon2 =aCon2;
+ *rEGeo.pEdgeTrack =*pEdgeTrack;
+ rEGeo.bEdgeTrackDirty=bEdgeTrackDirty;
+ rEGeo.bEdgeTrackUserDefined=bEdgeTrackUserDefined;
+ rEGeo.aEdgeInfo =aEdgeInfo;
+}
+
+void SdrEdgeObj::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ SdrTextObj::RestGeoData(rGeo);
+ SdrEdgeObjGeoData& rEGeo=(SdrEdgeObjGeoData&)rGeo;
+ if (aCon1.pObj!=rEGeo.aCon1.pObj) {
+ if (aCon1.pObj!=NULL) aCon1.pObj->RemoveListener(*this);
+ aCon1=rEGeo.aCon1;
+ if (aCon1.pObj!=NULL) aCon1.pObj->AddListener(*this);
+ }
+ if (aCon2.pObj!=rEGeo.aCon2.pObj) {
+ if (aCon2.pObj!=NULL) aCon2.pObj->RemoveListener(*this);
+ aCon2=rEGeo.aCon2;
+ if (aCon2.pObj!=NULL) aCon2.pObj->AddListener(*this);
+ }
+ *pEdgeTrack =*rEGeo.pEdgeTrack;
+ bEdgeTrackDirty=rEGeo.bEdgeTrackDirty;
+ bEdgeTrackUserDefined=rEGeo.bEdgeTrackUserDefined;
+ aEdgeInfo =rEGeo.aEdgeInfo;
+}
+
+Point SdrEdgeObj::GetTailPoint( BOOL bTail ) const
+{
+ if( pEdgeTrack && pEdgeTrack->GetPointCount()!=0)
+ {
+ const XPolygon& rTrack0 = *pEdgeTrack;
+ if(bTail)
+ {
+ return rTrack0[0];
+ }
+ else
+ {
+ const USHORT nSiz = rTrack0.GetPointCount() - 1;
+ return rTrack0[nSiz];
+ }
+ }
+ else
+ {
+ if(bTail)
+ return aOutRect.TopLeft();
+ else
+ return aOutRect.BottomRight();
+ }
+
+}
+
+void SdrEdgeObj::SetTailPoint( BOOL bTail, const Point& rPt )
+{
+ ImpSetTailPoint( bTail, rPt );
+ SetChanged();
+}
+
+/** this method is used by the api to set a glue point for a connection
+ nId == -1 : The best default point is automaticly choosen
+ 0 <= nId <= 3 : One of the default points is choosen
+ nId >= 4 : A user defined glue point is choosen
+*/
+void SdrEdgeObj::setGluePointIndex( sal_Bool bTail, sal_Int32 nIndex /* = -1 */ )
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetCurrentBoundRect();
+ // #110094#-14 BroadcastObjectChange();
+
+ SdrObjConnection& rConn1 = GetConnection( bTail );
+
+ rConn1.SetAutoVertex( nIndex >= 0 && nIndex <= 3 );
+ rConn1.SetBestConnection( nIndex < 0 );
+ rConn1.SetBestVertex( nIndex < 0 );
+
+ if( nIndex > 3 )
+ {
+// nIndex -= 4;
+ nIndex -= 3; // SJ: the start api index is 0, whereas the implementation in svx starts from 1
+
+ // for user defined glue points we have
+ // to get the id for this index first
+ const SdrGluePointList* pList = rConn1.GetObject() ? rConn1.GetObject()->GetGluePointList() : NULL;
+ if( pList == NULL || SDRGLUEPOINT_NOTFOUND == pList->FindGluePoint((sal_uInt16)nIndex) )
+ return;
+ }
+ else if( nIndex < 0 )
+ {
+ nIndex = 0;
+ }
+
+ rConn1.SetConnectorId( (USHORT)nIndex );
+
+ SetChanged();
+ SetRectsDirty();
+ ImpRecalcEdgeTrack();
+ // bEdgeTrackDirty=TRUE;
+}
+
+/** this method is used by the api to return a glue point id for a connection.
+ See setGluePointId for possible return values */
+sal_Int32 SdrEdgeObj::getGluePointIndex( sal_Bool bTail )
+{
+ SdrObjConnection& rConn1 = GetConnection( bTail );
+ sal_Int32 nId = -1;
+ if( !rConn1.IsBestConnection() )
+ {
+ nId = rConn1.GetConnectorId();
+ if( !rConn1.IsAutoVertex() )
+// nId += 4;
+ nId += 3; // SJ: the start api index is 0, whereas the implementation in svx starts from 1
+ }
+ return nId;
+}
+
+// #102344# Implementation was missing; edge track needs to be invalidated additionally.
+void SdrEdgeObj::NbcSetAnchorPos(const Point& rPnt)
+{
+ // call parent functionality
+ SdrTextObj::NbcSetAnchorPos(rPnt);
+
+ // Additionally, invalidate edge track
+ ImpDirtyEdgeTrack();
+}
+
+sal_Bool SdrEdgeObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const
+{
+ // use base method from SdrObject, it's not rotatable and
+ // a call to GetSnapRect() is used. That's what we need for Connector.
+ return SdrObject::TRGetBaseGeometry(rMatrix, rPolyPolygon);
+}
+
+void SdrEdgeObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon)
+{
+ // evtl. take care for existing connections. For now, just use the
+ // implementation from SdrObject.
+ SdrObject::TRSetBaseGeometry(rMatrix, rPolyPolygon);
+}
+
+// for geometry access
+::basegfx::B2DPolygon SdrEdgeObj::getEdgeTrack() const
+{
+ if(bEdgeTrackDirty)
+ {
+ const_cast< SdrEdgeObj* >(this)->ImpRecalcEdgeTrack();
+ }
+
+ if(pEdgeTrack)
+ {
+ return pEdgeTrack->getB2DPolygon();
+ }
+ else
+ {
+ return ::basegfx::B2DPolygon();
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
new file mode 100644
index 000000000000..5718a9c1e5ec
--- /dev/null
+++ b/svx/source/svdraw/svdograf.cxx
@@ -0,0 +1,1285 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define _ANIMATION
+#include <unotools/streamwrap.hxx>
+
+#include <sfx2/lnkbase.hxx>
+#include <math.h>
+#include <vcl/salbtype.hxx>
+#include <sot/formats.hxx>
+#include <sot/storage.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <svl/style.hxx>
+#include <svtools/filter.hxx>
+#include <svl/urihelper.hxx>
+#include <svtools/grfmgr.hxx>
+#include <vcl/svapp.hxx>
+
+#include <sfx2/linkmgr.hxx>
+#include <svx/svdetc.hxx>
+#include "svdglob.hxx"
+#include "svdstr.hrc"
+#include <svx/svdpool.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdmrkv.hxx>
+#include <svx/svdpagv.hxx>
+#include "svdviter.hxx"
+#include <svx/svdview.hxx>
+#include "svtools/filter.hxx"
+#include <svx/svdograf.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/xbitmap.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xflbmtit.hxx>
+#include <svx/svdundo.hxx>
+#include "svdfmtf.hxx"
+#include <svx/sdgcpitm.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/sdr/properties/graphicproperties.hxx>
+#include <svx/sdr/contact/viewcontactofgraphic.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+
+// -----------
+// - Defines -
+// -----------
+
+#define GRAFSTREAMPOS_INVALID 0xffffffff
+#define SWAPGRAPHIC_TIMEOUT 5000
+
+// ------------------
+// - SdrGraphicLink -
+// ------------------
+
+class SdrGraphicLink : public sfx2::SvBaseLink
+{
+ SdrGrafObj* pGrafObj;
+
+public:
+ SdrGraphicLink(SdrGrafObj* pObj);
+ virtual ~SdrGraphicLink();
+
+ virtual void Closed();
+ virtual void DataChanged( const String& rMimeType,
+ const ::com::sun::star::uno::Any & rValue );
+
+ BOOL Connect() { return 0 != GetRealObject(); }
+ void UpdateSynchron();
+};
+
+// -----------------------------------------------------------------------------
+
+SdrGraphicLink::SdrGraphicLink(SdrGrafObj* pObj):
+ ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, SOT_FORMATSTR_ID_SVXB ),
+ pGrafObj(pObj)
+{
+ SetSynchron( FALSE );
+}
+
+// -----------------------------------------------------------------------------
+
+SdrGraphicLink::~SdrGraphicLink()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGraphicLink::DataChanged( const String& rMimeType,
+ const ::com::sun::star::uno::Any & rValue )
+{
+ SdrModel* pModel = pGrafObj ? pGrafObj->GetModel() : 0;
+ sfx2::LinkManager* pLinkManager= pModel ? pModel->GetLinkManager() : 0;
+
+ if( pLinkManager && rValue.hasValue() )
+ {
+ pLinkManager->GetDisplayNames( this, 0, &pGrafObj->aFileName, 0, &pGrafObj->aFilterName );
+
+ Graphic aGraphic;
+ if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGraphic ))
+ {
+ pGrafObj->NbcSetGraphic( aGraphic );
+ pGrafObj->ActionChanged();
+ }
+ else if( SotExchange::GetFormatIdFromMimeType( rMimeType ) != sfx2::LinkManager::RegisterStatusInfoId() )
+ {
+ // only repaint, no objectchange
+ pGrafObj->ActionChanged();
+ // pGrafObj->BroadcastObjectChange();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGraphicLink::Closed()
+{
+ // Die Verbindung wird aufgehoben; pLink des Objekts auf NULL setzen, da die Link-Instanz ja gerade destruiert wird.
+ pGrafObj->ForceSwapIn();
+ pGrafObj->pGraphicLink=NULL;
+ pGrafObj->ReleaseGraphicLink();
+ SvBaseLink::Closed();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGraphicLink::UpdateSynchron()
+{
+ if( GetObj() )
+ {
+ String aMimeType( SotExchange::GetFormatMimeType( GetContentType() ));
+ ::com::sun::star::uno::Any aValue;
+ GetObj()->GetData( aValue, aMimeType, TRUE );
+ DataChanged( aMimeType, aValue );
+ }
+}
+
+// --------------
+// - SdrGrafObj -
+// --------------
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrGrafObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::GraphicProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// DrawContact section
+
+sdr::contact::ViewContact* SdrGrafObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfGraphic(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrGrafObj,SdrRectObj);
+
+// -----------------------------------------------------------------------------
+
+SdrGrafObj::SdrGrafObj()
+: SdrRectObj(),
+ pGraphicLink ( NULL ),
+ bMirrored ( FALSE )
+{
+ pGraphic = new GraphicObject;
+ pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
+ bNoShear = TRUE;
+
+ // #111096#
+ mbGrafAnimationAllowed = sal_True;
+
+ // #i25616#
+ mbLineIsOutsideGeometry = sal_True;
+ mbInsidePaint = sal_False;
+ mbIsPreview = sal_False;
+
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+SdrGrafObj::SdrGrafObj(const Graphic& rGrf, const Rectangle& rRect)
+: SdrRectObj ( rRect ),
+ pGraphicLink ( NULL ),
+ bMirrored ( FALSE )
+{
+ pGraphic = new GraphicObject( rGrf );
+ pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
+ bNoShear = TRUE;
+
+ // #111096#
+ mbGrafAnimationAllowed = sal_True;
+
+ // #i25616#
+ mbLineIsOutsideGeometry = sal_True;
+ mbInsidePaint = sal_False;
+ mbIsPreview = sal_False;
+
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+SdrGrafObj::SdrGrafObj( const Graphic& rGrf )
+: SdrRectObj(),
+ pGraphicLink ( NULL ),
+ bMirrored ( FALSE )
+{
+ pGraphic = new GraphicObject( rGrf );
+ pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
+ bNoShear = TRUE;
+
+ // #111096#
+ mbGrafAnimationAllowed = sal_True;
+
+ // #i25616#
+ mbLineIsOutsideGeometry = sal_True;
+ mbInsidePaint = sal_False;
+ mbIsPreview = sal_False;
+
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+SdrGrafObj::~SdrGrafObj()
+{
+ delete pGraphic;
+ ImpLinkAbmeldung();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::SetGraphicObject( const GraphicObject& rGrfObj )
+{
+ *pGraphic = rGrfObj;
+ pGraphic->SetSwapStreamHdl( LINK( this, SdrGrafObj, ImpSwapHdl ), SWAPGRAPHIC_TIMEOUT );
+ pGraphic->SetUserData();
+ mbIsPreview = sal_False;
+ SetChanged();
+ BroadcastObjectChange();
+}
+
+// -----------------------------------------------------------------------------
+
+const GraphicObject& SdrGrafObj::GetGraphicObject(bool bForceSwapIn) const
+{
+ if(bForceSwapIn)
+ {
+ ForceSwapIn();
+ }
+
+ return *pGraphic;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::NbcSetGraphic( const Graphic& rGrf )
+{
+ pGraphic->SetGraphic( rGrf );
+ pGraphic->SetUserData();
+ mbIsPreview = sal_False;
+}
+
+void SdrGrafObj::SetGraphic( const Graphic& rGrf )
+{
+ NbcSetGraphic(rGrf);
+ SetChanged();
+ BroadcastObjectChange();
+}
+
+// -----------------------------------------------------------------------------
+
+const Graphic& SdrGrafObj::GetGraphic() const
+{
+ ForceSwapIn();
+ return pGraphic->GetGraphic();
+}
+
+// -----------------------------------------------------------------------------
+
+Graphic SdrGrafObj::GetTransformedGraphic( ULONG nTransformFlags ) const
+{
+ // #107947# Refactored most of the code to GraphicObject, where
+ // everybody can use e.g. the cropping functionality
+
+ GraphicType eType = GetGraphicType();
+ MapMode aDestMap( pModel->GetScaleUnit(), Point(), pModel->GetScaleFraction(), pModel->GetScaleFraction() );
+ const Size aDestSize( GetLogicRect().GetSize() );
+ const BOOL bMirror = ( nTransformFlags & SDRGRAFOBJ_TRANSFORMATTR_MIRROR ) != 0;
+ const BOOL bRotate = ( ( nTransformFlags & SDRGRAFOBJ_TRANSFORMATTR_ROTATE ) != 0 ) &&
+ ( aGeo.nDrehWink && aGeo.nDrehWink != 18000 ) && ( GRAPHIC_NONE != eType );
+
+ // #104115# Need cropping info earlier
+ ( (SdrGrafObj*) this )->ImpSetAttrToGrafInfo();
+ GraphicAttr aActAttr;
+
+ if( SDRGRAFOBJ_TRANSFORMATTR_NONE != nTransformFlags &&
+ GRAPHIC_NONE != eType )
+ {
+ // actually transform the graphic only in this case. On the
+ // other hand, cropping will always happen
+ aActAttr = aGrafInfo;
+
+ if( bMirror )
+ {
+ USHORT nMirrorCase = ( aGeo.nDrehWink == 18000 ) ? ( bMirrored ? 3 : 4 ) : ( bMirrored ? 2 : 1 );
+ bool bHMirr = nMirrorCase == 2 || nMirrorCase == 4;
+ bool bVMirr = nMirrorCase == 3 || nMirrorCase == 4;
+
+ aActAttr.SetMirrorFlags( ( bHMirr ? BMP_MIRROR_HORZ : 0 ) | ( bVMirr ? BMP_MIRROR_VERT : 0 ) );
+ }
+
+ if( bRotate )
+ aActAttr.SetRotation( sal_uInt16(aGeo.nDrehWink / 10) );
+ }
+
+ // #107947# Delegate to moved code in GraphicObject
+ return GetGraphicObject().GetTransformedGraphic( aDestSize, aDestMap, aActAttr );
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicType SdrGrafObj::GetGraphicType() const
+{
+ return pGraphic->GetType();
+}
+
+sal_Bool SdrGrafObj::IsAnimated() const
+{
+ return pGraphic->IsAnimated();
+}
+
+sal_Bool SdrGrafObj::IsEPS() const
+{
+ return pGraphic->IsEPS();
+}
+
+sal_Bool SdrGrafObj::IsSwappedOut() const
+{
+ return mbIsPreview ? sal_True : pGraphic->IsSwappedOut();
+}
+
+const MapMode& SdrGrafObj::GetGrafPrefMapMode() const
+{
+ return pGraphic->GetPrefMapMode();
+}
+
+const Size& SdrGrafObj::GetGrafPrefSize() const
+{
+ return pGraphic->GetPrefSize();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::SetGrafStreamURL( const String& rGraphicStreamURL )
+{
+ mbIsPreview = sal_False;
+ if( !rGraphicStreamURL.Len() )
+ {
+ pGraphic->SetUserData();
+ }
+ else if( pModel->IsSwapGraphics() )
+ {
+ pGraphic->SetUserData( rGraphicStreamURL );
+
+ // set state of graphic object to 'swapped out'
+ if( pGraphic->GetType() == GRAPHIC_NONE )
+ pGraphic->SetSwapState();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+String SdrGrafObj::GetGrafStreamURL() const
+{
+ return pGraphic->GetUserData();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::SetFileName(const String& rFileName)
+{
+ aFileName = rFileName;
+ SetChanged();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::SetFilterName(const String& rFilterName)
+{
+ aFilterName = rFilterName;
+ SetChanged();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::ForceSwapIn() const
+{
+ if( mbIsPreview )
+ {
+ // removing preview graphic
+ const String aUserData( pGraphic->GetUserData() );
+
+ Graphic aEmpty;
+ pGraphic->SetGraphic( aEmpty );
+ pGraphic->SetUserData( aUserData );
+ pGraphic->SetSwapState();
+
+ const_cast< SdrGrafObj* >( this )->mbIsPreview = sal_False;
+ }
+
+ pGraphic->FireSwapInRequest();
+
+ if( pGraphic->IsSwappedOut() ||
+ ( pGraphic->GetType() == GRAPHIC_NONE ) ||
+ ( pGraphic->GetType() == GRAPHIC_DEFAULT ) )
+ {
+ Graphic aDefaultGraphic;
+ aDefaultGraphic.SetDefaultType();
+ pGraphic->SetGraphic( aDefaultGraphic );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::ForceSwapOut() const
+{
+ pGraphic->FireSwapOutRequest();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::ImpLinkAnmeldung()
+{
+ sfx2::LinkManager* pLinkManager = pModel != NULL ? pModel->GetLinkManager() : NULL;
+
+ if( pLinkManager != NULL && pGraphicLink == NULL )
+ {
+ if( aFileName.Len() )
+ {
+ pGraphicLink = new SdrGraphicLink( this );
+ pLinkManager->InsertFileLink( *pGraphicLink, OBJECT_CLIENT_GRF, aFileName, ( aFilterName.Len() ? &aFilterName : NULL ), NULL );
+ pGraphicLink->Connect();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::ImpLinkAbmeldung()
+{
+ sfx2::LinkManager* pLinkManager = pModel != NULL ? pModel->GetLinkManager() : NULL;
+
+ if( pLinkManager != NULL && pGraphicLink!=NULL)
+ {
+ // Bei Remove wird *pGraphicLink implizit deleted
+ pLinkManager->Remove( pGraphicLink );
+ pGraphicLink=NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::SetGraphicLink( const String& rFileName, const String& rFilterName )
+{
+ ImpLinkAbmeldung();
+ aFileName = rFileName;
+ aFilterName = rFilterName;
+ ImpLinkAnmeldung();
+ pGraphic->SetUserData();
+
+ // #92205# A linked graphic is per definition swapped out (has to be loaded)
+ pGraphic->SetSwapState();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::ReleaseGraphicLink()
+{
+ ImpLinkAbmeldung();
+ aFileName = String();
+ aFilterName = String();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ bool bAnim = pGraphic->IsAnimated();
+ bool bNoPresGrf = ( pGraphic->GetType() != GRAPHIC_NONE ) && !bEmptyPresObj;
+
+ rInfo.bResizeFreeAllowed = aGeo.nDrehWink % 9000 == 0 ||
+ aGeo.nDrehWink % 18000 == 0 ||
+ aGeo.nDrehWink % 27000 == 0;
+
+ rInfo.bResizePropAllowed = TRUE;
+ rInfo.bRotateFreeAllowed = bNoPresGrf && !bAnim;
+ rInfo.bRotate90Allowed = bNoPresGrf && !bAnim;
+ rInfo.bMirrorFreeAllowed = bNoPresGrf && !bAnim;
+ rInfo.bMirror45Allowed = bNoPresGrf && !bAnim;
+ rInfo.bMirror90Allowed = !bEmptyPresObj;
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ rInfo.bShearAllowed = FALSE;
+ rInfo.bEdgeRadiusAllowed=FALSE;
+ rInfo.bCanConvToPath = FALSE;
+ rInfo.bCanConvToPathLineToArea = FALSE;
+ rInfo.bCanConvToPolyLineToArea = FALSE;
+ rInfo.bCanConvToPoly = !IsEPS();
+ rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
+}
+
+// -----------------------------------------------------------------------------
+
+UINT16 SdrGrafObj::GetObjIdentifier() const
+{
+ return UINT16( OBJ_GRAF );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SdrGrafObj::ImpUpdateGraphicLink() const
+{
+ sal_Bool bRet = sal_False;
+
+ if( pGraphicLink )
+ {
+ const sal_Bool bIsChanged = pModel->IsChanged();
+ pGraphicLink->UpdateSynchron();
+ pModel->SetChanged( bIsChanged );
+
+ bRet = sal_True;
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::TakeObjNameSingul(XubString& rName) const
+{
+ switch( pGraphic->GetType() )
+ {
+ case GRAPHIC_BITMAP:
+ {
+ const USHORT nId = ( ( pGraphic->IsTransparent() || ( (const SdrGrafTransparenceItem&) GetObjectItem( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ) ?
+ ( IsLinkedGraphic() ? STR_ObjNameSingulGRAFBMPTRANSLNK : STR_ObjNameSingulGRAFBMPTRANS ) :
+ ( IsLinkedGraphic() ? STR_ObjNameSingulGRAFBMPLNK : STR_ObjNameSingulGRAFBMP ) );
+
+ rName=ImpGetResStr( nId );
+ }
+ break;
+
+ case GRAPHIC_GDIMETAFILE:
+ rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNameSingulGRAFMTFLNK : STR_ObjNameSingulGRAFMTF );
+ break;
+
+ case GRAPHIC_NONE:
+ rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNameSingulGRAFNONELNK : STR_ObjNameSingulGRAFNONE );
+ break;
+
+ default:
+ rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNameSingulGRAFLNK : STR_ObjNameSingulGRAF );
+ break;
+ }
+
+ const String aName(GetName());
+
+ if( aName.Len() )
+ {
+ rName.AppendAscii( " '" );
+ rName += aName;
+ rName += sal_Unicode( '\'' );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::TakeObjNamePlural( XubString& rName ) const
+{
+ switch( pGraphic->GetType() )
+ {
+ case GRAPHIC_BITMAP:
+ {
+ const USHORT nId = ( ( pGraphic->IsTransparent() || ( (const SdrGrafTransparenceItem&) GetObjectItem( SDRATTR_GRAFTRANSPARENCE ) ).GetValue() ) ?
+ ( IsLinkedGraphic() ? STR_ObjNamePluralGRAFBMPTRANSLNK : STR_ObjNamePluralGRAFBMPTRANS ) :
+ ( IsLinkedGraphic() ? STR_ObjNamePluralGRAFBMPLNK : STR_ObjNamePluralGRAFBMP ) );
+
+ rName=ImpGetResStr( nId );
+ }
+ break;
+
+ case GRAPHIC_GDIMETAFILE:
+ rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNamePluralGRAFMTFLNK : STR_ObjNamePluralGRAFMTF );
+ break;
+
+ case GRAPHIC_NONE:
+ rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNamePluralGRAFNONELNK : STR_ObjNamePluralGRAFNONE );
+ break;
+
+ default:
+ rName=ImpGetResStr( IsLinkedGraphic() ? STR_ObjNamePluralGRAFLNK : STR_ObjNamePluralGRAF );
+ break;
+ }
+
+ const String aName(GetName());
+
+ if( aName.Len() )
+ {
+ rName.AppendAscii( " '" );
+ rName += aName;
+ rName += sal_Unicode( '\'' );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+SdrObject* SdrGrafObj::getFullDragClone() const
+{
+ // call parent
+ SdrGrafObj* pRetval = static_cast< SdrGrafObj* >(SdrRectObj::getFullDragClone());
+
+ // #i103116# the full drag clone leads to problems
+ // with linked graphics, so reset the link in this
+ // temporary interaction object and load graphic
+ if(pRetval && IsLinkedGraphic())
+ {
+ pRetval->ForceSwapIn();
+ pRetval->ReleaseGraphicLink();
+ }
+
+ return pRetval;
+}
+
+void SdrGrafObj::operator=( const SdrObject& rObj )
+{
+ SdrRectObj::operator=( rObj );
+
+ const SdrGrafObj& rGraf = (SdrGrafObj&) rObj;
+
+ pGraphic->SetGraphic( rGraf.GetGraphic(), &rGraf.GetGraphicObject() );
+ aCropRect = rGraf.aCropRect;
+ aFileName = rGraf.aFileName;
+ aFilterName = rGraf.aFilterName;
+ bMirrored = rGraf.bMirrored;
+
+ if( rGraf.pGraphicLink != NULL)
+ {
+ SetGraphicLink( aFileName, aFilterName );
+ }
+
+ ImpSetAttrToGrafInfo();
+}
+
+// -----------------------------------------------------------------------------
+// #i25616#
+
+basegfx::B2DPolyPolygon SdrGrafObj::TakeXorPoly() const
+{
+ if(mbInsidePaint)
+ {
+ basegfx::B2DPolyPolygon aRetval;
+
+ // take grown rectangle
+ const sal_Int32 nHalfLineWidth(ImpGetLineWdt() / 2);
+ const Rectangle aGrownRect(
+ aRect.Left() - nHalfLineWidth,
+ aRect.Top() - nHalfLineWidth,
+ aRect.Right() + nHalfLineWidth,
+ aRect.Bottom() + nHalfLineWidth);
+
+ XPolygon aXPoly(ImpCalcXPoly(aGrownRect, GetEckenradius()));
+ aRetval.append(aXPoly.getB2DPolygon());
+
+ return aRetval;
+ }
+ else
+ {
+ // call parent
+ return SdrRectObj::TakeXorPoly();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_uInt32 SdrGrafObj::GetHdlCount() const
+{
+ return 8L;
+}
+
+// -----------------------------------------------------------------------------
+
+SdrHdl* SdrGrafObj::GetHdl(sal_uInt32 nHdlNum) const
+{
+ return SdrRectObj::GetHdl( nHdlNum + 1L );
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ SdrRectObj::NbcResize( rRef, xFact, yFact );
+
+ bool bMirrX = xFact.GetNumerator() < 0;
+ bool bMirrY = yFact.GetNumerator() < 0;
+
+ if( bMirrX != bMirrY )
+ bMirrored = !bMirrored;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ SdrRectObj::NbcRotate(rRef,nWink,sn,cs);
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::NbcMirror(const Point& rRef1, const Point& rRef2)
+{
+ SdrRectObj::NbcMirror(rRef1,rRef2);
+ bMirrored = !bMirrored;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ SdrRectObj::NbcRotate( rRef, nWink, tn, bVShear );
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::NbcSetSnapRect(const Rectangle& rRect)
+{
+ SdrRectObj::NbcSetSnapRect(rRect);
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::NbcSetLogicRect( const Rectangle& rRect)
+{
+ //bool bChg=rRect.GetSize()!=aRect.GetSize();
+ SdrRectObj::NbcSetLogicRect(rRect);
+}
+
+// -----------------------------------------------------------------------------
+
+SdrObjGeoData* SdrGrafObj::NewGeoData() const
+{
+ return new SdrGrafObjGeoData;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ SdrRectObj::SaveGeoData(rGeo);
+ SdrGrafObjGeoData& rGGeo=(SdrGrafObjGeoData&)rGeo;
+ rGGeo.bMirrored=bMirrored;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ //long nDrehMerk = aGeo.nDrehWink;
+ //long nShearMerk = aGeo.nShearWink;
+ //bool bMirrMerk = bMirrored;
+ Size aSizMerk( aRect.GetSize() );
+
+ SdrRectObj::RestGeoData(rGeo);
+ SdrGrafObjGeoData& rGGeo=(SdrGrafObjGeoData&)rGeo;
+ bMirrored=rGGeo.bMirrored;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::SetPage( SdrPage* pNewPage )
+{
+ bool bRemove = pNewPage == NULL && pPage != NULL;
+ bool bInsert = pNewPage != NULL && pPage == NULL;
+
+ if( bRemove )
+ {
+ // hier kein SwapIn noetig, weil wenn nicht geladen, dann auch nicht animiert.
+ if( pGraphic->IsAnimated())
+ pGraphic->StopAnimation();
+
+ if( pGraphicLink != NULL )
+ ImpLinkAbmeldung();
+ }
+
+ SdrRectObj::SetPage( pNewPage );
+
+ if(aFileName.Len() && bInsert)
+ ImpLinkAnmeldung();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::SetModel( SdrModel* pNewModel )
+{
+ bool bChg = pNewModel != pModel;
+
+ if( bChg )
+ {
+ if( pGraphic->HasUserData() )
+ {
+ ForceSwapIn();
+ pGraphic->SetUserData();
+ }
+
+ if( pGraphicLink != NULL )
+ ImpLinkAbmeldung();
+ }
+
+ // Model umsetzen
+ SdrRectObj::SetModel(pNewModel);
+
+ if( bChg && aFileName.Len() )
+ ImpLinkAnmeldung();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::StartAnimation( OutputDevice* /*pOutDev*/, const Point& /*rPoint*/, const Size& /*rSize*/, long /*nExtraData*/)
+{
+ // #111096#
+ // use new graf animation
+ SetGrafAnimationAllowed(sal_True);
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::StopAnimation(OutputDevice* /*pOutDev*/, long /*nExtraData*/)
+{
+ // #111096#
+ // use new graf animation
+ SetGrafAnimationAllowed(sal_False);
+}
+
+// -----------------------------------------------------------------------------
+
+bool SdrGrafObj::HasGDIMetaFile() const
+{
+ return( pGraphic->GetType() == GRAPHIC_GDIMETAFILE );
+}
+
+// -----------------------------------------------------------------------------
+
+const GDIMetaFile* SdrGrafObj::GetGDIMetaFile() const
+{
+ DBG_ERROR( "Invalid return value! Don't use it! (KA)" );
+ return &GetGraphic().GetGDIMetaFile();
+}
+
+// -----------------------------------------------------------------------------
+
+SdrObject* SdrGrafObj::DoConvertToPolyObj(BOOL bBezier) const
+{
+ SdrObject* pRetval = NULL;
+
+ switch( GetGraphicType() )
+ {
+ case GRAPHIC_GDIMETAFILE:
+ {
+ // NUR die aus dem MetaFile erzeugbaren Objekte in eine Gruppe packen und zurueckliefern
+ SdrObjGroup* pGrp = new SdrObjGroup();
+ ImpSdrGDIMetaFileImport aFilter(*GetModel());
+ Point aOutPos( aRect.TopLeft() );
+ const Size aOutSiz( aRect.GetSize() );
+
+ aFilter.SetScaleRect(GetSnapRect());
+ aFilter.SetLayer(GetLayer());
+
+ UINT32 nInsAnz = aFilter.DoImport(GetTransformedGraphic().GetGDIMetaFile(), *pGrp->GetSubList(), 0);
+ if(nInsAnz)
+ {
+ pRetval = pGrp;
+ pGrp->NbcSetLayer(GetLayer());
+ pGrp->SetModel(GetModel());
+ pRetval = ImpConvertAddText(pRetval, bBezier);
+
+ // convert all children
+ if( pRetval )
+ {
+ SdrObject* pHalfDone = pRetval;
+ pRetval = pHalfDone->DoConvertToPolyObj(bBezier);
+ SdrObject::Free( pHalfDone ); // resulting object is newly created
+
+ if( pRetval )
+ {
+ // flatten subgroups. As we call
+ // DoConvertToPolyObj() on the resulting group
+ // objects, subgroups can exist (e.g. text is
+ // a group object for every line).
+ SdrObjList* pList = pRetval->GetSubList();
+ if( pList )
+ pList->FlattenGroups();
+ }
+ }
+ }
+ else
+ delete pGrp;
+ break;
+ }
+ case GRAPHIC_BITMAP:
+ {
+ // Grundobjekt kreieren und Fuellung ergaenzen
+ pRetval = SdrRectObj::DoConvertToPolyObj(bBezier);
+
+ // Bitmap als Attribut retten
+ if(pRetval)
+ {
+ // Bitmap als Fuellung holen
+ SfxItemSet aSet(GetObjectItemSet());
+
+ aSet.Put(XFillStyleItem(XFILL_BITMAP));
+ Bitmap aBitmap( GetTransformedGraphic().GetBitmap() );
+ XOBitmap aXBmp(aBitmap, XBITMAP_STRETCH);
+ aSet.Put(XFillBitmapItem(String(), aXBmp));
+ aSet.Put(XFillBmpTileItem(FALSE));
+
+ pRetval->SetMergedItemSet(aSet);
+ }
+ break;
+ }
+ case GRAPHIC_NONE:
+ case GRAPHIC_DEFAULT:
+ {
+ pRetval = SdrRectObj::DoConvertToPolyObj(bBezier);
+ break;
+ }
+ }
+
+ return pRetval;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ SetXPolyDirty();
+ SdrRectObj::Notify( rBC, rHint );
+ ImpSetAttrToGrafInfo();
+}
+
+void SdrGrafObj::ImpSetAttrToGrafInfo()
+{
+ const SfxItemSet& rSet = GetObjectItemSet();
+ const sal_uInt16 nTrans = ( (SdrGrafTransparenceItem&) rSet.Get( SDRATTR_GRAFTRANSPARENCE ) ).GetValue();
+ const SdrGrafCropItem& rCrop = (const SdrGrafCropItem&) rSet.Get( SDRATTR_GRAFCROP );
+
+ aGrafInfo.SetLuminance( ( (SdrGrafLuminanceItem&) rSet.Get( SDRATTR_GRAFLUMINANCE ) ).GetValue() );
+ aGrafInfo.SetContrast( ( (SdrGrafContrastItem&) rSet.Get( SDRATTR_GRAFCONTRAST ) ).GetValue() );
+ aGrafInfo.SetChannelR( ( (SdrGrafRedItem&) rSet.Get( SDRATTR_GRAFRED ) ).GetValue() );
+ aGrafInfo.SetChannelG( ( (SdrGrafGreenItem&) rSet.Get( SDRATTR_GRAFGREEN ) ).GetValue() );
+ aGrafInfo.SetChannelB( ( (SdrGrafBlueItem&) rSet.Get( SDRATTR_GRAFBLUE ) ).GetValue() );
+ aGrafInfo.SetGamma( ( (SdrGrafGamma100Item&) rSet.Get( SDRATTR_GRAFGAMMA ) ).GetValue() * 0.01 );
+ aGrafInfo.SetTransparency( (BYTE) FRound( Min( nTrans, (USHORT) 100 ) * 2.55 ) );
+ aGrafInfo.SetInvert( ( (SdrGrafInvertItem&) rSet.Get( SDRATTR_GRAFINVERT ) ).GetValue() );
+ aGrafInfo.SetDrawMode( ( (SdrGrafModeItem&) rSet.Get( SDRATTR_GRAFMODE ) ).GetValue() );
+ aGrafInfo.SetCrop( rCrop.GetLeft(), rCrop.GetTop(), rCrop.GetRight(), rCrop.GetBottom() );
+
+ SetXPolyDirty();
+ SetRectsDirty();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::ImpSetGrafInfoToAttr()
+{
+ SetObjectItem( SdrGrafLuminanceItem( aGrafInfo.GetLuminance() ) );
+ SetObjectItem( SdrGrafContrastItem( aGrafInfo.GetContrast() ) );
+ SetObjectItem( SdrGrafRedItem( aGrafInfo.GetChannelR() ) );
+ SetObjectItem( SdrGrafGreenItem( aGrafInfo.GetChannelG() ) );
+ SetObjectItem( SdrGrafBlueItem( aGrafInfo.GetChannelB() ) );
+ SetObjectItem( SdrGrafGamma100Item( FRound( aGrafInfo.GetGamma() * 100.0 ) ) );
+ SetObjectItem( SdrGrafTransparenceItem( (USHORT) FRound( aGrafInfo.GetTransparency() / 2.55 ) ) );
+ SetObjectItem( SdrGrafInvertItem( aGrafInfo.IsInvert() ) );
+ SetObjectItem( SdrGrafModeItem( aGrafInfo.GetDrawMode() ) );
+ SetObjectItem( SdrGrafCropItem( aGrafInfo.GetLeftCrop(), aGrafInfo.GetTopCrop(), aGrafInfo.GetRightCrop(), aGrafInfo.GetBottomCrop() ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrGrafObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly )
+{
+ Size aSize;
+ Size aMaxSize( rMaxRect.GetSize() );
+ if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
+ aSize = Application::GetDefaultDevice()->PixelToLogic( pGraphic->GetPrefSize(), MAP_100TH_MM );
+ else
+ aSize = OutputDevice::LogicToLogic( pGraphic->GetPrefSize(),
+ pGraphic->GetPrefMapMode(),
+ MapMode( MAP_100TH_MM ) );
+
+ if( aSize.Height() != 0 && aSize.Width() != 0 )
+ {
+ Point aPos( rMaxRect.TopLeft() );
+
+ // Falls Grafik zu gross, wird die Grafik
+ // in die Seite eingepasst
+ if ( (!bShrinkOnly ||
+ ( aSize.Height() > aMaxSize.Height() ) ||
+ ( aSize.Width() > aMaxSize.Width() ) )&&
+ aSize.Height() && aMaxSize.Height() )
+ {
+ float fGrfWH = (float)aSize.Width() /
+ (float)aSize.Height();
+ float fWinWH = (float)aMaxSize.Width() /
+ (float)aMaxSize.Height();
+
+ // Grafik an Pagesize anpassen (skaliert)
+ if ( fGrfWH < fWinWH )
+ {
+ aSize.Width() = (long)(aMaxSize.Height() * fGrfWH);
+ aSize.Height()= aMaxSize.Height();
+ }
+ else if ( fGrfWH > 0.F )
+ {
+ aSize.Width() = aMaxSize.Width();
+ aSize.Height()= (long)(aMaxSize.Width() / fGrfWH);
+ }
+
+ aPos = rMaxRect.Center();
+ }
+
+ if( bShrinkOnly )
+ aPos = aRect.TopLeft();
+
+ aPos.X() -= aSize.Width() / 2;
+ aPos.Y() -= aSize.Height() / 2;
+ SetLogicRect( Rectangle( aPos, aSize ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
+{
+ SvStream* pRet = GRFMGR_AUTOSWAPSTREAM_NONE;
+
+ if( pO->IsInSwapOut() )
+ {
+ if( pModel && !mbIsPreview && pModel->IsSwapGraphics() && pGraphic->GetSizeBytes() > 20480 )
+ {
+ // test if this object is visualized from someone
+ // ## test only if there are VOCs other than the preview renderer
+ if(!GetViewContact().HasViewObjectContacts(true))
+ {
+ const ULONG nSwapMode = pModel->GetSwapGraphicsMode();
+
+ if( ( pGraphic->HasUserData() || pGraphicLink ) &&
+ ( nSwapMode & SDR_SWAPGRAPHICSMODE_PURGE ) )
+ {
+ pRet = NULL;
+ }
+ else if( nSwapMode & SDR_SWAPGRAPHICSMODE_TEMP )
+ {
+ pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
+ pGraphic->SetUserData();
+ }
+
+ // #i102380#
+ sdr::contact::ViewContactOfGraphic* pVC = dynamic_cast< sdr::contact::ViewContactOfGraphic* >(&GetViewContact());
+
+ if(pVC)
+ {
+ pVC->flushGraphicObjects();
+ }
+ }
+ }
+ }
+ else if( pO->IsInSwapIn() )
+ {
+ // kann aus dem original Doc-Stream nachgeladen werden...
+ if( pModel != NULL )
+ {
+ if( pGraphic->HasUserData() )
+ {
+ SdrDocumentStreamInfo aStreamInfo;
+
+ aStreamInfo.mbDeleteAfterUse = FALSE;
+ aStreamInfo.maUserData = pGraphic->GetUserData();
+
+ SvStream* pStream = pModel->GetDocumentStream( aStreamInfo );
+
+ if( pStream != NULL )
+ {
+ Graphic aGraphic;
+
+ com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData = NULL;
+
+ if(mbInsidePaint && !GetViewContact().HasViewObjectContacts(true))
+ {
+// Rectangle aSnapRect(GetSnapRect());
+// const Rectangle aSnapRectPixel(pOutDev->LogicToPixel(aSnapRect));
+
+ pFilterData = new com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >( 3 );
+
+ com::sun::star::awt::Size aPreviewSizeHint( 64, 64 );
+ sal_Bool bAllowPartialStreamRead = sal_True;
+ sal_Bool bCreateNativeLink = sal_False;
+ (*pFilterData)[ 0 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "PreviewSizeHint" ) );
+ (*pFilterData)[ 0 ].Value <<= aPreviewSizeHint;
+ (*pFilterData)[ 1 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "AllowPartialStreamRead" ) );
+ (*pFilterData)[ 1 ].Value <<= bAllowPartialStreamRead;
+ (*pFilterData)[ 2 ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "CreateNativeLink" ) );
+ (*pFilterData)[ 2 ].Value <<= bCreateNativeLink;
+
+ mbIsPreview = sal_True;
+ }
+
+ if( !GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, String(), *pStream,
+ GRFILTER_FORMAT_DONTKNOW, NULL, 0, pFilterData ) )
+ {
+ const String aUserData( pGraphic->GetUserData() );
+
+ pGraphic->SetGraphic( aGraphic );
+ pGraphic->SetUserData( aUserData );
+
+ // #142146# Graphic successfully swapped in.
+ pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
+ }
+ delete pFilterData;
+
+ pStream->ResetError();
+
+ if( aStreamInfo.mbDeleteAfterUse || aStreamInfo.mxStorageRef.is() )
+ {
+ if ( aStreamInfo.mxStorageRef.is() )
+ {
+ aStreamInfo.mxStorageRef->dispose();
+ aStreamInfo.mxStorageRef = 0;
+ }
+
+ delete pStream;
+ }
+ }
+ }
+ else if( !ImpUpdateGraphicLink() )
+ {
+ pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
+ }
+ else
+ {
+ pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
+ }
+ }
+ else
+ pRet = GRFMGR_AUTOSWAPSTREAM_TEMP;
+ }
+
+ return (long)(void*) pRet;
+}
+
+// -----------------------------------------------------------------------------
+
+// #111096#
+// Access to GrafAnimationAllowed flag
+sal_Bool SdrGrafObj::IsGrafAnimationAllowed() const
+{
+ return mbGrafAnimationAllowed;
+}
+
+void SdrGrafObj::SetGrafAnimationAllowed(sal_Bool bNew)
+{
+ if(mbGrafAnimationAllowed != bNew)
+ {
+ mbGrafAnimationAllowed = bNew;
+ ActionChanged();
+ }
+}
+
+// #i25616#
+sal_Bool SdrGrafObj::IsObjectTransparent() const
+{
+ if(((const SdrGrafTransparenceItem&)GetObjectItem(SDRATTR_GRAFTRANSPARENCE)).GetValue()
+ || pGraphic->IsTransparent())
+ {
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+Reference< XInputStream > SdrGrafObj::getInputStream()
+{
+ Reference< XInputStream > xStream;
+
+ if( pModel )
+ {
+// if( !pGraphic->HasUserData() )
+// pGraphic->SwapOut();
+
+ // kann aus dem original Doc-Stream nachgeladen werden...
+ if( pGraphic->HasUserData() )
+ {
+ SdrDocumentStreamInfo aStreamInfo;
+
+ aStreamInfo.mbDeleteAfterUse = FALSE;
+ aStreamInfo.maUserData = pGraphic->GetUserData();
+
+ SvStream* pStream = pModel->GetDocumentStream( aStreamInfo );
+
+ if( pStream )
+ xStream.set( new utl::OInputStreamWrapper( pStream, sal_True ) );
+ }
+ else if( pGraphic && GetGraphic().IsLink() )
+ {
+ Graphic aGraphic( GetGraphic() );
+ GfxLink aLink( aGraphic.GetLink() );
+ sal_uInt32 nSize = aLink.GetDataSize();
+ const void* pSourceData = (const void*)aLink.GetData();
+ if( nSize && pSourceData )
+ {
+ sal_uInt8 * pBuffer = new sal_uInt8[ nSize ];
+ if( pBuffer )
+ {
+ memcpy( pBuffer, pSourceData, nSize );
+
+ SvMemoryStream* pStream = new SvMemoryStream( (void*)pBuffer, (sal_Size)nSize, STREAM_READ );
+ pStream->ObjectOwnsMemory( sal_True );
+ xStream.set( new utl::OInputStreamWrapper( pStream, sal_True ) );
+ }
+ }
+ }
+
+ if( !xStream.is() && aFileName.Len() )
+ {
+ SvFileStream* pStream = new SvFileStream( aFileName, STREAM_READ );
+ if( pStream )
+ xStream.set( new utl::OInputStreamWrapper( pStream ) );
+ }
+ }
+
+ return xStream;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx
new file mode 100644
index 000000000000..0ca0919fda86
--- /dev/null
+++ b/svx/source/svdraw/svdogrp.cxx
@@ -0,0 +1,804 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <sfx2/linkmgr.hxx>
+
+#include <ucbhelper/content.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <unotools/datetime.hxx>
+
+#include <svx/svdogrp.hxx>
+
+#include <sfx2/lnkbase.hxx>
+#include <tools/urlobj.hxx>
+
+#include <svl/urihelper.hxx>
+
+#include <svx/xpool.hxx>
+#include <svx/xpoly.hxx>
+
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include "svditer.hxx"
+#include <svx/svdobj.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdattrx.hxx> // NotPersistItems
+#include <svx/svdoedge.hxx> // #32383# Die Verbinder nach Move nochmal anbroadcasten
+#include "svdglob.hxx" // StringCache
+#include "svdstr.hrc" // Objektname
+
+#include <svx/svxids.hrc>
+#include <svl/whiter.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/sdr/properties/groupproperties.hxx>
+
+// #110094#
+#include <svx/sdr/contact/viewcontactofgroup.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@ @@@@@ @@@@@@ @@@@ @@@@@ @@@@ @@ @@ @@@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@ @@@ @@@@@ @@ @@ @@ @@ @@@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@ @@@@@ @@@@ @@@@@ @@ @@ @@@@ @@@@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrObjGroup::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::GroupProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// #110094# DrawContact section
+
+sdr::contact::ViewContact* SdrObjGroup::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfGroup(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrObjGroup,SdrObject);
+
+SdrObjGroup::SdrObjGroup()
+{
+ pSub=new SdrObjList(NULL,NULL);
+ pSub->SetOwnerObj(this);
+ pSub->SetListKind(SDROBJLIST_GROUPOBJ);
+ bRefPoint=FALSE;
+ nDrehWink=0;
+ nShearWink=0;
+ bClosedObj=FALSE;
+}
+
+
+SdrObjGroup::~SdrObjGroup()
+{
+ delete pSub;
+}
+
+void SdrObjGroup::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bNoContortion=FALSE;
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ SdrObjTransformInfoRec aInfo;
+ pObj->TakeObjInfo(aInfo);
+ if (!aInfo.bMoveAllowed ) rInfo.bMoveAllowed =FALSE;
+ if (!aInfo.bResizeFreeAllowed ) rInfo.bResizeFreeAllowed =FALSE;
+ if (!aInfo.bResizePropAllowed ) rInfo.bResizePropAllowed =FALSE;
+ if (!aInfo.bRotateFreeAllowed ) rInfo.bRotateFreeAllowed =FALSE;
+ if (!aInfo.bRotate90Allowed ) rInfo.bRotate90Allowed =FALSE;
+ if (!aInfo.bMirrorFreeAllowed ) rInfo.bMirrorFreeAllowed =FALSE;
+ if (!aInfo.bMirror45Allowed ) rInfo.bMirror45Allowed =FALSE;
+ if (!aInfo.bMirror90Allowed ) rInfo.bMirror90Allowed =FALSE;
+ if (!aInfo.bShearAllowed ) rInfo.bShearAllowed =FALSE;
+ if (!aInfo.bEdgeRadiusAllowed ) rInfo.bEdgeRadiusAllowed =FALSE;
+ if (!aInfo.bNoOrthoDesired ) rInfo.bNoOrthoDesired =FALSE;
+ if (aInfo.bNoContortion ) rInfo.bNoContortion =TRUE;
+ if (!aInfo.bCanConvToPath ) rInfo.bCanConvToPath =FALSE;
+
+ if(!aInfo.bCanConvToContour)
+ rInfo.bCanConvToContour = FALSE;
+
+ if (!aInfo.bCanConvToPoly ) rInfo.bCanConvToPoly =FALSE;
+ if (!aInfo.bCanConvToPathLineToArea) rInfo.bCanConvToPathLineToArea=FALSE;
+ if (!aInfo.bCanConvToPolyLineToArea) rInfo.bCanConvToPolyLineToArea=FALSE;
+ }
+ if (nObjAnz==0) {
+ rInfo.bRotateFreeAllowed=FALSE;
+ rInfo.bRotate90Allowed =FALSE;
+ rInfo.bMirrorFreeAllowed=FALSE;
+ rInfo.bMirror45Allowed =FALSE;
+ rInfo.bMirror90Allowed =FALSE;
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ rInfo.bShearAllowed =FALSE;
+ rInfo.bEdgeRadiusAllowed=FALSE;
+ rInfo.bNoContortion =TRUE;
+ }
+ if(nObjAnz != 1)
+ {
+ // only allowed if single object selected
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ }
+}
+
+
+void SdrObjGroup::SetBoundRectDirty()
+{
+ // avoid resetting aOutRect which in case of this object is model data,
+ // not re-creatable view data
+}
+
+UINT16 SdrObjGroup::GetObjIdentifier() const
+{
+ return UINT16(OBJ_GRUP);
+}
+
+
+SdrLayerID SdrObjGroup::GetLayer() const
+{
+ bool b1st = true;
+ SdrLayerID nLay=SdrLayerID(SdrObject::GetLayer());
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG i=0; i<nObjAnz; i++) {
+ SdrLayerID nLay1=pOL->GetObj(i)->GetLayer();
+ if (b1st) { nLay=nLay1; b1st = false; }
+ else if (nLay1!=nLay) return 0;
+ }
+ return nLay;
+}
+
+
+void SdrObjGroup::NbcSetLayer(SdrLayerID nLayer)
+{
+ SdrObject::NbcSetLayer(nLayer);
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG i=0; i<nObjAnz; i++) {
+ pOL->GetObj(i)->NbcSetLayer(nLayer);
+ }
+}
+
+
+void SdrObjGroup::SetObjList(SdrObjList* pNewObjList)
+{
+ SdrObject::SetObjList(pNewObjList);
+ pSub->SetUpList(pNewObjList);
+}
+
+
+void SdrObjGroup::SetPage(SdrPage* pNewPage)
+{
+ SdrObject::SetPage(pNewPage);
+ pSub->SetPage(pNewPage);
+}
+
+
+void SdrObjGroup::SetModel(SdrModel* pNewModel)
+{
+ if(pNewModel!=pModel)
+ {
+ // #i30648#
+ // This method also needs to migrate the used ItemSet
+ // when the destination model uses a different pool
+ // than the current one. Else it is possible to create
+ // SdrObjGroups which reference the old pool which might
+ // be destroyed (as the bug shows).
+ SdrModel* pOldModel = pModel;
+
+ // test for correct pool in ItemSet; move to new pool if necessary
+ if(pNewModel && GetObjectItemPool() && GetObjectItemPool() != &pNewModel->GetItemPool())
+ {
+ MigrateItemPool(GetObjectItemPool(), &pNewModel->GetItemPool(), pNewModel);
+ }
+
+ // call parent
+ SdrObject::SetModel(pNewModel);
+
+ // set new model at content
+ pSub->SetModel(pNewModel);
+
+ // modify properties
+ GetProperties().SetModel(pOldModel, pNewModel);
+ }
+}
+
+
+bool SdrObjGroup::HasRefPoint() const
+{
+ return bRefPoint;
+}
+
+
+Point SdrObjGroup::GetRefPoint() const
+{
+ return aRefPoint;
+}
+
+
+void SdrObjGroup::SetRefPoint(const Point& rPnt)
+{
+ bRefPoint=TRUE;
+ aRefPoint=rPnt;
+}
+
+
+SdrObjList* SdrObjGroup::GetSubList() const
+{
+ return pSub;
+}
+
+const Rectangle& SdrObjGroup::GetCurrentBoundRect() const
+{
+ // --> OD 2007-02-01 #144962#
+ // <aOutRect> has to contain the bounding rectangle
+ if ( pSub->GetObjCount()!=0 )
+ {
+ const_cast<SdrObjGroup*>(this)->aOutRect = pSub->GetAllObjBoundRect();
+ }
+
+ return aOutRect;
+ // <--
+}
+
+
+const Rectangle& SdrObjGroup::GetSnapRect() const
+{
+ // --> OD 2007-02-01 #144962#
+ // <aOutRect> has to contain the bounding rectangle
+ if ( pSub->GetObjCount()!=0 )
+ {
+ return pSub->GetAllObjSnapRect();
+ }
+ else
+ {
+ return aOutRect;
+ }
+ // <--
+}
+
+void SdrObjGroup::operator=(const SdrObject& rObj)
+{
+ if(rObj.IsGroupObject())
+ {
+ // copy SdrObject stuff
+ SdrObject::operator=(rObj);
+
+ // #i36404#
+ // copy SubList, init model and page first
+ SdrObjList& rSourceSubList = *rObj.GetSubList();
+ pSub->SetPage(rSourceSubList.GetPage());
+ pSub->SetModel(rSourceSubList.GetModel());
+ pSub->CopyObjects(*rObj.GetSubList());
+
+ // copy local paremeters
+ nDrehWink =((SdrObjGroup&)rObj).nDrehWink;
+ nShearWink =((SdrObjGroup&)rObj).nShearWink;
+ aRefPoint =((SdrObjGroup&)rObj).aRefPoint;
+ bRefPoint =((SdrObjGroup&)rObj).bRefPoint;
+ }
+}
+
+
+void SdrObjGroup::TakeObjNameSingul(XubString& rName) const
+{
+ if(!pSub->GetObjCount())
+ {
+ rName = ImpGetResStr(STR_ObjNameSingulGRUPEMPTY);
+ }
+ else
+ {
+ rName = ImpGetResStr(STR_ObjNameSingulGRUP);
+ }
+
+ const String aName(GetName());
+
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+
+void SdrObjGroup::TakeObjNamePlural(XubString& rName) const
+{
+ if (pSub->GetObjCount()==0) {
+ rName=ImpGetResStr(STR_ObjNamePluralGRUPEMPTY);
+ } else {
+ rName=ImpGetResStr(STR_ObjNamePluralGRUP);
+ }
+}
+
+
+void SdrObjGroup::RecalcSnapRect()
+{
+ // nicht erforderlich, da die Rects von der SubList verwendet werden.
+}
+
+basegfx::B2DPolyPolygon SdrObjGroup::TakeXorPoly() const
+{
+ basegfx::B2DPolyPolygon aRetval;
+ const sal_uInt32 nObjCount(pSub->GetObjCount());
+
+ for(sal_uInt32 a(0L); a < nObjCount; a++)
+ {
+ SdrObject* pObj = pSub->GetObj(a);
+ aRetval.append(pObj->TakeXorPoly());
+ }
+
+ if(!aRetval.count())
+ {
+ const basegfx::B2DRange aRange(aOutRect.Left(), aOutRect.Top(), aOutRect.Right(), aOutRect.Bottom());
+ aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
+ }
+
+ return aRetval;
+}
+
+bool SdrObjGroup::beginSpecialDrag(SdrDragStat& /*rDrag*/) const
+{
+ return false;
+}
+
+
+bool SdrObjGroup::BegCreate(SdrDragStat& /*rStat*/)
+{
+ return FALSE;
+}
+
+
+long SdrObjGroup::GetRotateAngle() const
+{
+ return nDrehWink;
+}
+
+
+long SdrObjGroup::GetShearAngle(bool /*bVertical*/) const
+{
+ return nShearWink;
+}
+
+
+void SdrObjGroup::NbcSetSnapRect(const Rectangle& rRect)
+{
+ Rectangle aOld(GetSnapRect());
+ long nMulX=rRect.Right()-rRect.Left();
+ long nDivX=aOld.Right()-aOld.Left();
+ long nMulY=rRect.Bottom()-rRect.Top();
+ long nDivY=aOld.Bottom()-aOld.Top();
+ if (nDivX==0) { nMulX=1; nDivX=1; }
+ if (nDivY==0) { nMulY=1; nDivY=1; }
+ if (nMulX!=nDivX || nMulY!=nDivY) {
+ Fraction aX(nMulX,nDivX);
+ Fraction aY(nMulY,nDivY);
+ NbcResize(aOld.TopLeft(),aX,aY);
+ }
+ if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) {
+ NbcMove(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top()));
+ }
+}
+
+
+void SdrObjGroup::NbcSetLogicRect(const Rectangle& rRect)
+{
+ NbcSetSnapRect(rRect);
+}
+
+
+void SdrObjGroup::NbcMove(const Size& rSiz)
+{
+ MovePoint(aRefPoint,rSiz);
+ if (pSub->GetObjCount()!=0) {
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ pObj->NbcMove(rSiz);
+ }
+ } else {
+ MoveRect(aOutRect,rSiz);
+ SetRectsDirty();
+ }
+}
+
+
+void SdrObjGroup::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
+ bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
+ if (bXMirr || bYMirr) {
+ Point aRef1(GetSnapRect().Center());
+ if (bXMirr) {
+ Point aRef2(aRef1);
+ aRef2.Y()++;
+ NbcMirrorGluePoints(aRef1,aRef2);
+ }
+ if (bYMirr) {
+ Point aRef2(aRef1);
+ aRef2.X()++;
+ NbcMirrorGluePoints(aRef1,aRef2);
+ }
+ }
+ ResizePoint(aRefPoint,rRef,xFact,yFact);
+ if (pSub->GetObjCount()!=0) {
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ pObj->NbcResize(rRef,xFact,yFact);
+ }
+ } else {
+ ResizeRect(aOutRect,rRef,xFact,yFact);
+ SetRectsDirty();
+ }
+}
+
+
+void SdrObjGroup::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ SetGlueReallyAbsolute(TRUE);
+ nDrehWink=NormAngle360(nDrehWink+nWink);
+ RotatePoint(aRefPoint,rRef,sn,cs);
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ pObj->NbcRotate(rRef,nWink,sn,cs);
+ }
+ NbcRotateGluePoints(rRef,nWink,sn,cs);
+ SetGlueReallyAbsolute(FALSE);
+}
+
+
+void SdrObjGroup::NbcMirror(const Point& rRef1, const Point& rRef2)
+{
+ SetGlueReallyAbsolute(TRUE);
+ MirrorPoint(aRefPoint,rRef1,rRef2); // fehlende Implementation in SvdEtc !!!
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ pObj->NbcMirror(rRef1,rRef2);
+ }
+ NbcMirrorGluePoints(rRef1,rRef2);
+ SetGlueReallyAbsolute(FALSE);
+}
+
+
+void SdrObjGroup::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ SetGlueReallyAbsolute(TRUE);
+ nShearWink+=nWink;
+ ShearPoint(aRefPoint,rRef,tn);
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ pObj->NbcShear(rRef,nWink,tn,bVShear);
+ }
+ NbcShearGluePoints(rRef,nWink,tn,bVShear);
+ SetGlueReallyAbsolute(FALSE);
+}
+
+
+void SdrObjGroup::NbcSetAnchorPos(const Point& rPnt)
+{
+ aAnchor=rPnt;
+ Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
+ MovePoint(aRefPoint,aSiz);
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ pObj->NbcSetAnchorPos(rPnt);
+ }
+}
+
+
+void SdrObjGroup::SetSnapRect(const Rectangle& rRect)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ Rectangle aOld(GetSnapRect());
+ long nMulX=rRect.Right()-rRect.Left();
+ long nDivX=aOld.Right()-aOld.Left();
+ long nMulY=rRect.Bottom()-rRect.Top();
+ long nDivY=aOld.Bottom()-aOld.Top();
+ if (nDivX==0) { nMulX=1; nDivX=1; }
+ if (nDivY==0) { nMulY=1; nDivY=1; }
+ if (nMulX!=nDivX || nMulY!=nDivY) {
+ Fraction aX(nMulX,nDivX);
+ Fraction aY(nMulY,nDivY);
+ Resize(aOld.TopLeft(),aX,aY);
+ }
+ if (rRect.Left()!=aOld.Left() || rRect.Top()!=aOld.Top()) {
+ Move(Size(rRect.Left()-aOld.Left(),rRect.Top()-aOld.Top()));
+ }
+
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+
+void SdrObjGroup::SetLogicRect(const Rectangle& rRect)
+{
+ SetSnapRect(rRect);
+}
+
+
+void SdrObjGroup::Move(const Size& rSiz)
+{
+ if (rSiz.Width()!=0 || rSiz.Height()!=0) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ MovePoint(aRefPoint,rSiz);
+ if (pSub->GetObjCount()!=0) {
+ // #32383# Erst die Verbinder verschieben, dann den Rest
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ ULONG i;
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (pObj->IsEdgeObj()) pObj->Move(rSiz);
+ }
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (!pObj->IsEdgeObj()) pObj->Move(rSiz);
+ }
+ } else {
+ // #110094#-14 SendRepaintBroadcast();
+ MoveRect(aOutRect,rSiz);
+ SetRectsDirty();
+ }
+
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
+ }
+}
+
+
+void SdrObjGroup::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) {
+ bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
+ bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
+ if (bXMirr || bYMirr) {
+ Point aRef1(GetSnapRect().Center());
+ if (bXMirr) {
+ Point aRef2(aRef1);
+ aRef2.Y()++;
+ NbcMirrorGluePoints(aRef1,aRef2);
+ }
+ if (bYMirr) {
+ Point aRef2(aRef1);
+ aRef2.X()++;
+ NbcMirrorGluePoints(aRef1,aRef2);
+ }
+ }
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ ResizePoint(aRefPoint,rRef,xFact,yFact);
+ if (pSub->GetObjCount()!=0) {
+ // #32383# Erst die Verbinder verschieben, dann den Rest
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ ULONG i;
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact);
+ }
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (!pObj->IsEdgeObj()) pObj->Resize(rRef,xFact,yFact);
+ }
+ } else {
+ // #110094#-14 SendRepaintBroadcast();
+ ResizeRect(aOutRect,rRef,xFact,yFact);
+ SetRectsDirty();
+ }
+
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+
+void SdrObjGroup::Rotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ if (nWink!=0) {
+ SetGlueReallyAbsolute(TRUE);
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ nDrehWink=NormAngle360(nDrehWink+nWink);
+ RotatePoint(aRefPoint,rRef,sn,cs);
+ // #32383# Erst die Verbinder verschieben, dann den Rest
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ ULONG i;
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (pObj->IsEdgeObj()) pObj->Rotate(rRef,nWink,sn,cs);
+ }
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (!pObj->IsEdgeObj()) pObj->Rotate(rRef,nWink,sn,cs);
+ }
+ NbcRotateGluePoints(rRef,nWink,sn,cs);
+ SetGlueReallyAbsolute(FALSE);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+
+void SdrObjGroup::Mirror(const Point& rRef1, const Point& rRef2)
+{
+ SetGlueReallyAbsolute(TRUE);
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ MirrorPoint(aRefPoint,rRef1,rRef2); // fehlende Implementation in SvdEtc !!!
+ // #32383# Erst die Verbinder verschieben, dann den Rest
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ ULONG i;
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (pObj->IsEdgeObj()) pObj->Mirror(rRef1,rRef2);
+ }
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (!pObj->IsEdgeObj()) pObj->Mirror(rRef1,rRef2);
+ }
+ NbcMirrorGluePoints(rRef1,rRef2);
+ SetGlueReallyAbsolute(FALSE);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+
+void SdrObjGroup::Shear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ if (nWink!=0) {
+ SetGlueReallyAbsolute(TRUE);
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ nShearWink+=nWink;
+ ShearPoint(aRefPoint,rRef,tn);
+ // #32383# Erst die Verbinder verschieben, dann den Rest
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ ULONG i;
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (pObj->IsEdgeObj()) pObj->Shear(rRef,nWink,tn,bVShear);
+ }
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (!pObj->IsEdgeObj()) pObj->Shear(rRef,nWink,tn,bVShear);
+ }
+ NbcShearGluePoints(rRef,nWink,tn,bVShear);
+ SetGlueReallyAbsolute(FALSE);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+
+void SdrObjGroup::SetAnchorPos(const Point& rPnt)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ bool bChg=aAnchor!=rPnt;
+ aAnchor=rPnt;
+ Size aSiz(rPnt.X()-aAnchor.X(),rPnt.Y()-aAnchor.Y());
+ MovePoint(aRefPoint,aSiz);
+ // #32383# Erst die Verbinder verschieben, dann den Rest
+ SdrObjList* pOL=pSub;
+ ULONG nObjAnz=pOL->GetObjCount();
+ ULONG i;
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (pObj->IsEdgeObj()) pObj->SetAnchorPos(rPnt);
+ }
+ for (i=0; i<nObjAnz; i++) {
+ SdrObject* pObj=pOL->GetObj(i);
+ if (!pObj->IsEdgeObj()) pObj->SetAnchorPos(rPnt);
+ }
+ if (bChg) {
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
+ }
+}
+
+
+
+void SdrObjGroup::NbcSetRelativePos(const Point& rPnt)
+{
+ Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
+ Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
+ NbcMove(aSiz); // Der ruft auch das SetRectsDirty()
+}
+
+void SdrObjGroup::SetRelativePos(const Point& rPnt)
+{
+ Point aRelPos0(GetSnapRect().TopLeft()-aAnchor);
+ Size aSiz(rPnt.X()-aRelPos0.X(),rPnt.Y()-aRelPos0.Y());
+ if (aSiz.Width()!=0 || aSiz.Height()!=0) Move(aSiz); // Der ruft auch das SetRectsDirty() und Broadcast, ...
+}
+
+void SdrObjGroup::NbcReformatText()
+{
+ pSub->NbcReformatAllTextObjects();
+}
+
+void SdrObjGroup::ReformatText()
+{
+ pSub->ReformatAllTextObjects();
+}
+
+SdrObject* SdrObjGroup::DoConvertToPolyObj(BOOL bBezier) const
+{
+ SdrObject* pGroup = new SdrObjGroup;
+ pGroup->SetModel(GetModel());
+
+ for(UINT32 a=0;a<pSub->GetObjCount();a++)
+ {
+ SdrObject* pIterObj = pSub->GetObj(a);
+ SdrObject* pResult = pIterObj->DoConvertToPolyObj(bBezier);
+
+ // pResult can be NULL e.g. for empty objects
+ if( pResult )
+ pGroup->GetSubList()->NbcInsertObject(pResult);
+ }
+
+ return pGroup;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
new file mode 100644
index 000000000000..8934c2f47044
--- /dev/null
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -0,0 +1,1497 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdomeas.hxx>
+#include <math.h>
+#include "svditext.hxx" //
+#include <svx/xpoly.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdhdl.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svddrag.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdattrx.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdview.hxx>
+#include "svdglob.hxx" // StringCache
+#include "svdstr.hrc" // Objektname
+#include <svl/style.hxx>
+#include <svl/smplhint.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xlnstcit.hxx>
+#include <svx/xlnedcit.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/measfld.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdpage.hxx>
+#include <unotools/syslocale.hxx>
+#include "svdoimp.hxx"
+#include <svx/sdr/properties/measureproperties.hxx>
+#include <svx/sdr/contact/viewcontactofsdrmeasureobj.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrMeasureObjGeoData::SdrMeasureObjGeoData() {}
+SdrMeasureObjGeoData::~SdrMeasureObjGeoData() {}
+
+void SdrMeasureObj::TakeRepresentation( XubString& rStr, SdrMeasureFieldKind eMeasureFieldKind ) const
+{
+ rStr.Erase();
+ Fraction aMeasureScale(1, 1);
+ BOOL bTextRota90(FALSE);
+ BOOL bShowUnit(FALSE);
+ FieldUnit eMeasureUnit(FUNIT_NONE);
+ FieldUnit eModUIUnit(FUNIT_NONE);
+
+ const SfxItemSet& rSet = GetMergedItemSet();
+ bTextRota90 = ((SdrMeasureTextRota90Item&)rSet.Get(SDRATTR_MEASURETEXTROTA90)).GetValue();
+ eMeasureUnit = ((SdrMeasureUnitItem&)rSet.Get(SDRATTR_MEASUREUNIT)).GetValue();
+ aMeasureScale = ((SdrMeasureScaleItem&)rSet.Get(SDRATTR_MEASURESCALE)).GetValue();
+ bShowUnit = ((SdrMeasureShowUnitItem&)rSet.Get(SDRATTR_MEASURESHOWUNIT)).GetValue();
+ sal_Int16 nNumDigits = ((SdrMeasureDecimalPlacesItem&)rSet.Get(SDRATTR_MEASUREDECIMALPLACES)).GetValue();
+
+ //SdrModel* pModel = rObj.pModel;
+
+ switch(eMeasureFieldKind)
+ {
+ case SDRMEASUREFIELD_VALUE:
+ {
+ if(pModel)
+ {
+ eModUIUnit = pModel->GetUIUnit();
+
+ if(eMeasureUnit == FUNIT_NONE)
+ eMeasureUnit = eModUIUnit;
+
+ INT32 nLen(GetLen(aPt2 - aPt1));
+ Fraction aFact(1,1);
+
+ if(eMeasureUnit != eModUIUnit)
+ {
+ // Zur Umrechnung der Einheiten
+ aFact *= GetMapFactor(eModUIUnit, eMeasureUnit).X();
+ }
+
+ if(aMeasureScale.GetNumerator() != aMeasureScale.GetDenominator())
+ {
+ aFact *= aMeasureScale;
+ }
+
+ if(aFact.GetNumerator() != aFact.GetDenominator())
+ {
+ // Scaling ueber BigInt, um Ueberlaeufe zu vermeiden
+ nLen = BigMulDiv(nLen, aFact.GetNumerator(), aFact.GetDenominator());
+ }
+
+ pModel->TakeMetricStr(nLen, rStr, TRUE, nNumDigits);
+
+ if(!aFact.IsValid())
+ {
+ rStr = String();
+ rStr += sal_Unicode('?');
+ }
+
+ sal_Unicode cDec(SvtSysLocale().GetLocaleData().getNumDecimalSep().GetChar(0));
+
+ if(rStr.Search(cDec) != STRING_NOTFOUND)
+ {
+ xub_StrLen nLen2(rStr.Len() - 1);
+
+ while(rStr.GetChar(nLen2) == sal_Unicode('0'))
+ {
+ rStr.Erase(nLen2);
+ nLen2--;
+ }
+
+ if(rStr.GetChar(nLen2) == cDec)
+ {
+ rStr.Erase(nLen2);
+ nLen2--;
+ }
+
+ if(!rStr.Len())
+ rStr += sal_Unicode('0');
+ }
+ }
+ else
+ {
+ // falls kein Model da ... (z.B. Preview im Dialog)
+ rStr = String();
+ rStr.AppendAscii("4711");
+ }
+
+ break;
+ }
+ case SDRMEASUREFIELD_UNIT:
+ {
+ if(bShowUnit)
+ {
+ if(pModel)
+ {
+ eModUIUnit = pModel->GetUIUnit();
+
+ if(eMeasureUnit == FUNIT_NONE)
+ eMeasureUnit = eModUIUnit;
+
+ if(bShowUnit)
+ pModel->TakeUnitStr(eMeasureUnit, rStr);
+ }
+ }
+
+ break;
+ }
+ case SDRMEASUREFIELD_ROTA90BLANCS:
+ {
+ if(bTextRota90)
+ {
+ rStr = String();
+ rStr += sal_Unicode(' ');
+ }
+
+ break;
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrMeasureObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::MeasureProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// DrawContact section
+
+sdr::contact::ViewContact* SdrMeasureObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfSdrMeasureObj(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrMeasureObj,SdrTextObj);
+
+SdrMeasureObj::SdrMeasureObj():
+ bTextDirty(FALSE)
+{
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_False;
+}
+
+SdrMeasureObj::SdrMeasureObj(const Point& rPt1, const Point& rPt2):
+ aPt1(rPt1),
+ aPt2(rPt2),
+ bTextDirty(FALSE)
+{
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_False;
+}
+
+SdrMeasureObj::~SdrMeasureObj()
+{
+}
+
+void SdrMeasureObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bSelectAllowed =TRUE;
+ rInfo.bMoveAllowed =TRUE;
+ rInfo.bResizeFreeAllowed=TRUE;
+ rInfo.bResizePropAllowed=TRUE;
+ rInfo.bRotateFreeAllowed=TRUE;
+ rInfo.bRotate90Allowed =TRUE;
+ rInfo.bMirrorFreeAllowed=TRUE;
+ rInfo.bMirror45Allowed =TRUE;
+ rInfo.bMirror90Allowed =TRUE;
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ rInfo.bShearAllowed =TRUE;
+ rInfo.bEdgeRadiusAllowed=FALSE;
+ rInfo.bNoOrthoDesired =TRUE;
+ rInfo.bNoContortion =FALSE;
+ rInfo.bCanConvToPath =FALSE;
+ rInfo.bCanConvToPoly =TRUE;
+ rInfo.bCanConvToPathLineToArea=FALSE;
+ rInfo.bCanConvToPolyLineToArea=FALSE;
+ rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
+}
+
+UINT16 SdrMeasureObj::GetObjIdentifier() const
+{
+ return (UINT16)OBJ_MEASURE;
+}
+
+struct ImpMeasureRec : public SdrDragStatUserData
+{
+ Point aPt1;
+ Point aPt2;
+ SdrMeasureKind eKind;
+ SdrMeasureTextHPos eWantTextHPos;
+ SdrMeasureTextVPos eWantTextVPos;
+ long nLineDist;
+ long nHelplineOverhang;
+ long nHelplineDist;
+ long nHelpline1Len;
+ long nHelpline2Len;
+ bool bBelowRefEdge;
+ bool bTextRota90;
+ bool bTextUpsideDown;
+ long nMeasureOverhang;
+ FieldUnit eMeasureUnit;
+ Fraction aMeasureScale;
+ bool bShowUnit;
+ String aFormatString;
+ bool bTextAutoAngle;
+ long nTextAutoAngleView;
+ bool bTextIsFixedAngle;
+ long nTextFixedAngle;
+};
+
+struct ImpLineRec
+{
+ Point aP1;
+ Point aP2;
+};
+
+struct ImpMeasurePoly
+{
+ ImpLineRec aMainline1; // die mit dem 1. Pfeil
+ ImpLineRec aMainline2; // die mit dem 2. Pfeil
+ ImpLineRec aMainline3; // die dazwischen
+ ImpLineRec aHelpline1;
+ ImpLineRec aHelpline2;
+ Rectangle aTextRect;
+ Size aTextSize;
+ long nLineLen;
+ long nLineWink;
+ long nTextWink;
+ long nHlpWink;
+ double nLineSin;
+ double nLineCos;
+ double nHlpSin;
+ double nHlpCos;
+ USHORT nMainlineAnz;
+ SdrMeasureTextHPos eUsedTextHPos;
+ SdrMeasureTextVPos eUsedTextVPos;
+ long nLineWdt2; // Halbe Strichstaerke
+ long nArrow1Len; // Laenge des 1. Pfeils. Bei Center nur die Haelfte
+ long nArrow2Len; // Laenge des 2. Pfeils. Bei Center nur die Haelfte
+ long nArrow1Wdt; // Breite des 1. Pfeils
+ long nArrow2Wdt; // Breite des 2. Pfeils
+ long nShortLineLen; // Linienlaenge, wenn PfeileAussen
+ bool bArrow1Center; // Pfeil 1 zentriert?
+ bool bArrow2Center; // Pfeil 2 zentriert?
+ bool bAutoUpsideDown; // UpsideDown durch Automatik
+ bool bPfeileAussen;
+ bool bBreakedLine;
+};
+
+void SdrMeasureObj::ImpTakeAttr(ImpMeasureRec& rRec) const
+{
+ rRec.aPt1 = aPt1;
+ rRec.aPt2 = aPt2;
+
+ const SfxItemSet& rSet = GetObjectItemSet();
+ rRec.eKind =((SdrMeasureKindItem& )rSet.Get(SDRATTR_MEASUREKIND )).GetValue();
+ rRec.eWantTextHPos =((SdrMeasureTextHPosItem& )rSet.Get(SDRATTR_MEASURETEXTHPOS )).GetValue();
+ rRec.eWantTextVPos =((SdrMeasureTextVPosItem& )rSet.Get(SDRATTR_MEASURETEXTVPOS )).GetValue();
+ rRec.nLineDist =((SdrMeasureLineDistItem& )rSet.Get(SDRATTR_MEASURELINEDIST )).GetValue();
+ rRec.nHelplineOverhang=((SdrMeasureHelplineOverhangItem&)rSet.Get(SDRATTR_MEASUREHELPLINEOVERHANG)).GetValue();
+ rRec.nHelplineDist =((SdrMeasureHelplineDistItem& )rSet.Get(SDRATTR_MEASUREHELPLINEDIST )).GetValue();
+ rRec.nHelpline1Len =((SdrMeasureHelpline1LenItem& )rSet.Get(SDRATTR_MEASUREHELPLINE1LEN )).GetValue();
+ rRec.nHelpline2Len =((SdrMeasureHelpline2LenItem& )rSet.Get(SDRATTR_MEASUREHELPLINE2LEN )).GetValue();
+ rRec.bBelowRefEdge =((SdrMeasureBelowRefEdgeItem& )rSet.Get(SDRATTR_MEASUREBELOWREFEDGE )).GetValue();
+ rRec.bTextRota90 =((SdrMeasureTextRota90Item& )rSet.Get(SDRATTR_MEASURETEXTROTA90 )).GetValue();
+ rRec.bTextUpsideDown =((SdrMeasureTextUpsideDownItem& )rSet.Get(SDRATTR_MEASURETEXTUPSIDEDOWN )).GetValue();
+ rRec.nMeasureOverhang =((SdrMeasureOverhangItem& )rSet.Get(SDRATTR_MEASUREOVERHANG )).GetValue();
+ rRec.eMeasureUnit =((SdrMeasureUnitItem& )rSet.Get(SDRATTR_MEASUREUNIT )).GetValue();
+ rRec.aMeasureScale =((SdrMeasureScaleItem& )rSet.Get(SDRATTR_MEASURESCALE )).GetValue();
+ rRec.bShowUnit =((SdrMeasureShowUnitItem& )rSet.Get(SDRATTR_MEASURESHOWUNIT )).GetValue();
+ rRec.aFormatString =((SdrMeasureFormatStringItem& )rSet.Get(SDRATTR_MEASUREFORMATSTRING )).GetValue();
+ rRec.bTextAutoAngle =((SdrMeasureTextAutoAngleItem& )rSet.Get(SDRATTR_MEASURETEXTAUTOANGLE )).GetValue();
+ rRec.nTextAutoAngleView=((SdrMeasureTextAutoAngleViewItem&)rSet.Get(SDRATTR_MEASURETEXTAUTOANGLEVIEW)).GetValue();
+ rRec.bTextIsFixedAngle =((SdrMeasureTextIsFixedAngleItem& )rSet.Get(SDRATTR_MEASURETEXTISFIXEDANGLE )).GetValue();
+ rRec.nTextFixedAngle =((SdrMeasureTextFixedAngleItem& )rSet.Get(SDRATTR_MEASURETEXTFIXEDANGLE )).GetValue();
+}
+
+long impGetLineStartEndDistance(const basegfx::B2DPolyPolygon& rPolyPolygon, long nNewWidth, bool bCenter)
+{
+ const basegfx::B2DRange aPolygonRange(rPolyPolygon.getB2DRange());
+ const double fOldWidth(aPolygonRange.getWidth() > 1.0 ? aPolygonRange.getWidth() : 1.0);
+ const double fScale((double)nNewWidth / fOldWidth);
+ long nHeight(basegfx::fround(aPolygonRange.getHeight() * fScale));
+
+ if(bCenter)
+ {
+ nHeight /= 2L;
+ }
+
+ return nHeight;
+}
+
+void SdrMeasureObj::ImpCalcGeometrics(const ImpMeasureRec& rRec, ImpMeasurePoly& rPol) const
+{
+ Point aP1(rRec.aPt1);
+ Point aP2(rRec.aPt2);
+ Point aDelt(aP2); aDelt-=aP1;
+
+ rPol.aTextSize=GetTextSize();
+ rPol.nLineLen=GetLen(aDelt);
+
+ rPol.nLineWdt2=0;
+ long nArrow1Len=0; bool bArrow1Center=false;
+ long nArrow2Len=0; bool bArrow2Center=false;
+ long nArrow1Wdt=0;
+ long nArrow2Wdt=0;
+ rPol.nArrow1Wdt=0;
+ rPol.nArrow2Wdt=0;
+ long nArrowNeed=0;
+ long nShortLen=0;
+ bool bPfeileAussen = false;
+
+ const SfxItemSet& rSet = GetObjectItemSet();
+ sal_Int32 nLineWdt = ((XLineWidthItem&)(rSet.Get(XATTR_LINEWIDTH))).GetValue(); // Strichstaerke
+ rPol.nLineWdt2 = (nLineWdt + 1) / 2;
+
+ nArrow1Wdt = ((const XLineStartWidthItem&)(rSet.Get(XATTR_LINESTARTWIDTH))).GetValue();
+ if(nArrow1Wdt < 0)
+ nArrow1Wdt = -nLineWdt * nArrow1Wdt / 100; // <0 = relativ
+
+ nArrow2Wdt = ((const XLineEndWidthItem&)(rSet.Get(XATTR_LINEENDWIDTH))).GetValue();
+ if(nArrow2Wdt < 0)
+ nArrow2Wdt = -nLineWdt * nArrow2Wdt / 100; // <0 = relativ
+
+ basegfx::B2DPolyPolygon aPol1(((const XLineStartItem&)(rSet.Get(XATTR_LINESTART))).GetLineStartValue());
+ basegfx::B2DPolyPolygon aPol2(((const XLineEndItem&)(rSet.Get(XATTR_LINEEND))).GetLineEndValue());
+ bArrow1Center = ((const XLineStartCenterItem&)(rSet.Get(XATTR_LINESTARTCENTER))).GetValue();
+ bArrow2Center = ((const XLineEndCenterItem&)(rSet.Get(XATTR_LINEENDCENTER))).GetValue();
+ nArrow1Len = impGetLineStartEndDistance(aPol1, nArrow1Wdt, bArrow1Center) - 1;
+ nArrow2Len = impGetLineStartEndDistance(aPol2, nArrow2Wdt, bArrow2Center) - 1;
+
+ // nArrowLen ist bei bCenter bereits halbiert
+ // Bei 2 Pfeilen a 4mm ist unter 10mm Schluss.
+ nArrowNeed=nArrow1Len+nArrow2Len+(nArrow1Wdt+nArrow2Wdt)/2;
+ if (rPol.nLineLen<nArrowNeed) bPfeileAussen = true;
+ nShortLen=(nArrow1Len+nArrow1Wdt + nArrow2Len+nArrow2Wdt) /2;
+
+ rPol.eUsedTextHPos=rRec.eWantTextHPos;
+ rPol.eUsedTextVPos=rRec.eWantTextVPos;
+ if (rPol.eUsedTextVPos==SDRMEASURE_TEXTVAUTO) rPol.eUsedTextVPos=SDRMEASURE_ABOVE;
+ bool bBrkLine=rPol.eUsedTextVPos==SDRMEASURETEXT_BREAKEDLINE;
+ if (rPol.eUsedTextVPos==SDRMEASURETEXT_VERTICALCENTERED)
+ {
+ OutlinerParaObject* pOutlinerParaObject = SdrTextObj::GetOutlinerParaObject();
+ if (pOutlinerParaObject!=NULL && pOutlinerParaObject->GetTextObject().GetParagraphCount()==1)
+ {
+ bBrkLine=TRUE; // Unterbrochene Linie, wenn nur 1 Absatz.
+ }
+ }
+ rPol.bBreakedLine=bBrkLine;
+ if (rPol.eUsedTextHPos==SDRMEASURE_TEXTHAUTO) { // bei zu breitem Text diesen eventuell nach aussen schieben
+ bool bOutside = false;
+ long nNeedSiz=!rRec.bTextRota90 ? rPol.aTextSize.Width() : rPol.aTextSize.Height();
+ if (nNeedSiz>rPol.nLineLen) bOutside = true; // Text passt nicht in die Mitte
+ if (bBrkLine) {
+ if (nNeedSiz+nArrowNeed>rPol.nLineLen) bPfeileAussen = true; // Text passt in die Mitte, wenn die Pfeile nach aussen kommen
+ } else {
+ long nSmallNeed=nArrow1Len+nArrow2Len+(nArrow1Wdt+nArrow2Wdt)/2/4;
+ if (nNeedSiz+nSmallNeed>rPol.nLineLen) bPfeileAussen = true; // Text passt in die Mitte, wenn die Pfeile nach aussen kommen
+ }
+ rPol.eUsedTextHPos=bOutside ? SDRMEASURE_TEXTLEFTOUTSIDE : SDRMEASURE_TEXTINSIDE;
+ }
+ if (rPol.eUsedTextHPos!=SDRMEASURE_TEXTINSIDE) bPfeileAussen = true;
+ rPol.nArrow1Wdt=nArrow1Wdt;
+ rPol.nArrow2Wdt=nArrow2Wdt;
+ rPol.nShortLineLen=nShortLen;
+ rPol.bPfeileAussen=bPfeileAussen;
+ rPol.nArrow1Len=nArrow1Len;
+ rPol.bArrow1Center=bArrow1Center;
+ rPol.nArrow2Len=nArrow2Len;
+ rPol.bArrow2Center=bArrow2Center;
+
+ rPol.nLineWink=GetAngle(aDelt);
+ double a=rPol.nLineWink*nPi180;
+ double nLineSin=sin(a);
+ double nLineCos=cos(a);
+ rPol.nLineSin=nLineSin;
+ rPol.nLineCos=nLineCos;
+
+ rPol.nTextWink=rPol.nLineWink;
+ if (rRec.bTextRota90) rPol.nTextWink+=9000;
+
+ rPol.bAutoUpsideDown=FALSE;
+ if (rRec.bTextAutoAngle) {
+ long nTmpWink=NormAngle360(rPol.nTextWink-rRec.nTextAutoAngleView);
+ if (nTmpWink>=18000) {
+ rPol.nTextWink+=18000;
+ rPol.bAutoUpsideDown=TRUE;
+ }
+ }
+
+ if (rRec.bTextUpsideDown) rPol.nTextWink+=18000;
+ rPol.nTextWink=NormAngle360(rPol.nTextWink);
+ rPol.nHlpWink=rPol.nLineWink+9000;
+ if (rRec.bBelowRefEdge) rPol.nHlpWink+=18000;
+ rPol.nHlpWink=NormAngle360(rPol.nHlpWink);
+ double nHlpSin=nLineCos;
+ double nHlpCos=-nLineSin;
+ if (rRec.bBelowRefEdge) {
+ nHlpSin=-nHlpSin;
+ nHlpCos=-nHlpCos;
+ }
+ rPol.nHlpSin=nHlpSin;
+ rPol.nHlpCos=nHlpCos;
+
+ long nLineDist=rRec.nLineDist;
+ long nOverhang=rRec.nHelplineOverhang;
+ long nHelplineDist=rRec.nHelplineDist;
+
+ long dx= Round(nLineDist*nHlpCos);
+ long dy=-Round(nLineDist*nHlpSin);
+ long dxh1a= Round((nHelplineDist-rRec.nHelpline1Len)*nHlpCos);
+ long dyh1a=-Round((nHelplineDist-rRec.nHelpline1Len)*nHlpSin);
+ long dxh1b= Round((nHelplineDist-rRec.nHelpline2Len)*nHlpCos);
+ long dyh1b=-Round((nHelplineDist-rRec.nHelpline2Len)*nHlpSin);
+ long dxh2= Round((nLineDist+nOverhang)*nHlpCos);
+ long dyh2=-Round((nLineDist+nOverhang)*nHlpSin);
+
+ // Masshilfslinie 1
+ rPol.aHelpline1.aP1=Point(aP1.X()+dxh1a,aP1.Y()+dyh1a);
+ rPol.aHelpline1.aP2=Point(aP1.X()+dxh2,aP1.Y()+dyh2);
+
+ // Masshilfslinie 2
+ rPol.aHelpline2.aP1=Point(aP2.X()+dxh1b,aP2.Y()+dyh1b);
+ rPol.aHelpline2.aP2=Point(aP2.X()+dxh2,aP2.Y()+dyh2);
+
+ // Masslinie(n)
+ Point aMainlinePt1(aP1.X()+dx,aP1.Y()+dy);
+ Point aMainlinePt2(aP2.X()+dx,aP2.Y()+dy);
+ if (!bPfeileAussen) {
+ rPol.aMainline1.aP1=aMainlinePt1;
+ rPol.aMainline1.aP2=aMainlinePt2;
+ rPol.aMainline2=rPol.aMainline1;
+ rPol.aMainline3=rPol.aMainline1;
+ rPol.nMainlineAnz=1;
+ if (bBrkLine) {
+ long nNeedSiz=!rRec.bTextRota90 ? rPol.aTextSize.Width() : rPol.aTextSize.Height();
+ long nHalfLen=(rPol.nLineLen-nNeedSiz-nArrow1Wdt/4-nArrow2Wdt/4) /2;
+ rPol.nMainlineAnz=2;
+ rPol.aMainline1.aP2=aMainlinePt1;
+ rPol.aMainline1.aP2.X()+=nHalfLen;
+ RotatePoint(rPol.aMainline1.aP2,rPol.aMainline1.aP1,nLineSin,nLineCos);
+ rPol.aMainline2.aP1=aMainlinePt2;
+ rPol.aMainline2.aP1.X()-=nHalfLen;
+ RotatePoint(rPol.aMainline2.aP1,rPol.aMainline2.aP2,nLineSin,nLineCos);
+ }
+ } else {
+ long nLen1=nShortLen; // Pfeilbreite als Linienlaenge ausserhalb des Pfeils
+ long nLen2=nShortLen;
+ long nTextWdt=rRec.bTextRota90 ? rPol.aTextSize.Height() : rPol.aTextSize.Width();
+ if (!bBrkLine) {
+ if (rPol.eUsedTextHPos==SDRMEASURE_TEXTLEFTOUTSIDE) nLen1=nArrow1Len+nTextWdt;
+ if (rPol.eUsedTextHPos==SDRMEASURE_TEXTRIGHTOUTSIDE) nLen2=nArrow2Len+nTextWdt;
+ }
+ rPol.aMainline1.aP1=aMainlinePt1;
+ rPol.aMainline1.aP2=aMainlinePt1; rPol.aMainline1.aP2.X()-=nLen1; RotatePoint(rPol.aMainline1.aP2,aMainlinePt1,nLineSin,nLineCos);
+ rPol.aMainline2.aP1=aMainlinePt2; rPol.aMainline2.aP1.X()+=nLen2; RotatePoint(rPol.aMainline2.aP1,aMainlinePt2,nLineSin,nLineCos);
+ rPol.aMainline2.aP2=aMainlinePt2;
+ rPol.aMainline3.aP1=aMainlinePt1;
+ rPol.aMainline3.aP2=aMainlinePt2;
+ rPol.nMainlineAnz=3;
+ if (bBrkLine && rPol.eUsedTextHPos==SDRMEASURE_TEXTINSIDE) rPol.nMainlineAnz=2;
+ }
+}
+
+basegfx::B2DPolyPolygon SdrMeasureObj::ImpCalcXPoly(const ImpMeasurePoly& rPol) const
+{
+ basegfx::B2DPolyPolygon aRetval;
+ basegfx::B2DPolygon aPartPolyA;
+ aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline1.aP1.X(), rPol.aMainline1.aP1.Y()));
+ aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline1.aP2.X(), rPol.aMainline1.aP2.Y()));
+ aRetval.append(aPartPolyA);
+
+ if(rPol.nMainlineAnz > 1)
+ {
+ aPartPolyA.clear();
+ aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline2.aP1.X(), rPol.aMainline2.aP1.Y()));
+ aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline2.aP2.X(), rPol.aMainline2.aP2.Y()));
+ aRetval.append(aPartPolyA);
+ }
+
+ if(rPol.nMainlineAnz > 2)
+ {
+ aPartPolyA.clear();
+ aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline3.aP1.X(), rPol.aMainline3.aP1.Y()));
+ aPartPolyA.append(basegfx::B2DPoint(rPol.aMainline3.aP2.X(), rPol.aMainline3.aP2.Y()));
+ aRetval.append(aPartPolyA);
+ }
+
+ aPartPolyA.clear();
+ aPartPolyA.append(basegfx::B2DPoint(rPol.aHelpline1.aP1.X(), rPol.aHelpline1.aP1.Y()));
+ aPartPolyA.append(basegfx::B2DPoint(rPol.aHelpline1.aP2.X(), rPol.aHelpline1.aP2.Y()));
+ aRetval.append(aPartPolyA);
+
+ aPartPolyA.clear();
+ aPartPolyA.append(basegfx::B2DPoint(rPol.aHelpline2.aP1.X(), rPol.aHelpline2.aP1.Y()));
+ aPartPolyA.append(basegfx::B2DPoint(rPol.aHelpline2.aP2.X(), rPol.aHelpline2.aP2.Y()));
+ aRetval.append(aPartPolyA);
+
+ return aRetval;
+}
+
+bool SdrMeasureObj::CalcFieldValue(const SvxFieldItem& rField, USHORT nPara, USHORT nPos,
+ bool bEdit,
+ Color*& rpTxtColor, Color*& rpFldColor, XubString& rRet) const
+{
+ const SvxFieldData* pField=rField.GetField();
+ SdrMeasureField* pMeasureField=PTR_CAST(SdrMeasureField,pField);
+ if (pMeasureField!=NULL) {
+ TakeRepresentation(rRet, pMeasureField->GetMeasureFieldKind());
+ if (rpFldColor!=NULL) {
+ if (!bEdit)
+ {
+ delete rpFldColor;
+ rpFldColor=NULL;
+ }
+ }
+ return TRUE;
+ } else {
+ return SdrTextObj::CalcFieldValue(rField,nPara,nPos,bEdit,rpTxtColor,rpFldColor,rRet);
+ }
+}
+
+void SdrMeasureObj::UndirtyText() const
+{
+ if (bTextDirty)
+ {
+ SdrOutliner& rOutliner=ImpGetDrawOutliner();
+ OutlinerParaObject* pOutlinerParaObject = SdrTextObj::GetOutlinerParaObject();
+ if(pOutlinerParaObject==NULL)
+ {
+ rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SDRMEASUREFIELD_ROTA90BLANCS), EE_FEATURE_FIELD), ESelection(0,0));
+ rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SDRMEASUREFIELD_VALUE), EE_FEATURE_FIELD),ESelection(0,1));
+ rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SDRMEASUREFIELD_UNIT), EE_FEATURE_FIELD),ESelection(0,2));
+ rOutliner.QuickInsertField(SvxFieldItem(SdrMeasureField(SDRMEASUREFIELD_ROTA90BLANCS), EE_FEATURE_FIELD),ESelection(0,3));
+
+ if(GetStyleSheet())
+ rOutliner.SetStyleSheet(0, GetStyleSheet());
+
+ rOutliner.SetParaAttribs(0, GetObjectItemSet());
+
+ // casting auf nonconst
+ const_cast<SdrMeasureObj*>(this)->NbcSetOutlinerParaObject( rOutliner.CreateParaObject() );
+ }
+ else
+ {
+ rOutliner.SetText(*pOutlinerParaObject);
+ }
+
+ rOutliner.SetUpdateMode(TRUE);
+ rOutliner.UpdateFields();
+ Size aSiz(rOutliner.CalcTextSize());
+ rOutliner.Clear();
+ // 3x casting auf nonconst
+ ((SdrMeasureObj*)this)->aTextSize=aSiz;
+ ((SdrMeasureObj*)this)->bTextSizeDirty=FALSE;
+ ((SdrMeasureObj*)this)->bTextDirty=FALSE;
+ }
+}
+
+void SdrMeasureObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
+{
+ if (bTextDirty) UndirtyText();
+ ImpMeasureRec aRec;
+ ImpMeasurePoly aMPol;
+ ImpTakeAttr(aRec);
+ ImpCalcGeometrics(aRec,aMPol);
+
+ // TextSize ermitteln inkl. Textrahmenabstaende
+ Size aTextSize2(aMPol.aTextSize);
+ if (aTextSize2.Width()<1) aTextSize2.Width()=1;
+ if (aTextSize2.Height()<1) aTextSize2.Height()=1;
+ aTextSize2.Width()+=GetTextLeftDistance()+GetTextRightDistance();
+ aTextSize2.Height()+=GetTextUpperDistance()+GetTextLowerDistance();
+
+ Point aPt1b(aMPol.aMainline1.aP1);
+ long nLen=aMPol.nLineLen;
+ long nLWdt=aMPol.nLineWdt2;
+ long nArr1Len=aMPol.nArrow1Len;
+ long nArr2Len=aMPol.nArrow2Len;
+ if (aMPol.bBreakedLine) {
+ // Bei Unterbrochener Linie und Outside muss der Text nicht neben den
+ // Pfeil sondern neben die Linie an dem Pfeil plaziert werden
+ nArr1Len=aMPol.nShortLineLen+aMPol.nArrow1Wdt/4;
+ nArr2Len=aMPol.nShortLineLen+aMPol.nArrow2Wdt/4;
+ }
+
+ Point aTextPos;
+ bool bRota90=aRec.bTextRota90;
+ bool bUpsideDown=aRec.bTextUpsideDown!=aMPol.bAutoUpsideDown;
+ bool bBelowRefEdge=aRec.bBelowRefEdge;
+ SdrMeasureTextHPos eMH=aMPol.eUsedTextHPos;
+ SdrMeasureTextVPos eMV=aMPol.eUsedTextVPos;
+ if (!bRota90) {
+ switch (eMH) {
+ case SDRMEASURE_TEXTLEFTOUTSIDE: aTextPos.X()=aPt1b.X()-aTextSize2.Width()-nArr1Len-nLWdt; break;
+ case SDRMEASURE_TEXTRIGHTOUTSIDE: aTextPos.X()=aPt1b.X()+nLen+nArr2Len+nLWdt; break;
+ default: aTextPos.X()=aPt1b.X(); aTextSize2.Width()=nLen;
+ }
+ switch (eMV) {
+ case SDRMEASURETEXT_VERTICALCENTERED:
+ case SDRMEASURETEXT_BREAKEDLINE: aTextPos.Y()=aPt1b.Y()-aTextSize2.Height()/2; break;
+ case SDRMEASURE_BELOW: {
+ if (!bUpsideDown) aTextPos.Y()=aPt1b.Y()+nLWdt;
+ else aTextPos.Y()=aPt1b.Y()-aTextSize2.Height()-nLWdt;
+ } break;
+ default: {
+ if (!bUpsideDown) aTextPos.Y()=aPt1b.Y()-aTextSize2.Height()-nLWdt;
+ else aTextPos.Y()=aPt1b.Y()+nLWdt;
+ }
+ }
+ if (bUpsideDown) {
+ aTextPos.X()+=aTextSize2.Width();
+ aTextPos.Y()+=aTextSize2.Height();
+ }
+ } else { // also wenn bTextRota90==TRUE
+ switch (eMH) {
+ case SDRMEASURE_TEXTLEFTOUTSIDE: aTextPos.X()=aPt1b.X()-aTextSize2.Height()-nArr1Len; break;
+ case SDRMEASURE_TEXTRIGHTOUTSIDE: aTextPos.X()=aPt1b.X()+nLen+nArr2Len; break;
+ default: aTextPos.X()=aPt1b.X(); aTextSize2.Height()=nLen;
+ }
+ switch (eMV) {
+ case SDRMEASURETEXT_VERTICALCENTERED:
+ case SDRMEASURETEXT_BREAKEDLINE: aTextPos.Y()=aPt1b.Y()+aTextSize2.Width()/2; break;
+ case SDRMEASURE_BELOW: {
+ if (!bBelowRefEdge) aTextPos.Y()=aPt1b.Y()+aTextSize2.Width()+nLWdt;
+ else aTextPos.Y()=aPt1b.Y()-nLWdt;
+ } break;
+ default: {
+ if (!bBelowRefEdge) aTextPos.Y()=aPt1b.Y()-nLWdt;
+ else aTextPos.Y()=aPt1b.Y()+aTextSize2.Width()+nLWdt;
+ }
+ }
+ if (bUpsideDown) {
+ aTextPos.X()+=aTextSize2.Height();
+ aTextPos.Y()-=aTextSize2.Width();
+ }
+ }
+ if (aMPol.nTextWink!=aGeo.nDrehWink) {
+ ((SdrMeasureObj*)this)->aGeo.nDrehWink=aMPol.nTextWink;
+ ((SdrMeasureObj*)this)->aGeo.RecalcSinCos();
+ }
+ RotatePoint(aTextPos,aPt1b,aMPol.nLineSin,aMPol.nLineCos);
+ aTextSize2.Width()++; aTextSize2.Height()++; // wg. des komischen Verhaltens beim Rect-Ctor
+ rRect=Rectangle(aTextPos,aTextSize2);
+ rRect.Justify();
+ ((SdrMeasureObj*)this)->aRect=rRect;
+
+ if (aMPol.nTextWink!=aGeo.nDrehWink) {
+ ((SdrMeasureObj*)this)->aGeo.nDrehWink=aMPol.nTextWink;
+ ((SdrMeasureObj*)this)->aGeo.RecalcSinCos();
+ }
+}
+
+void SdrMeasureObj::operator=(const SdrObject& rObj)
+{
+ SdrTextObj::operator=(rObj);
+ aPt1=((SdrMeasureObj&)rObj).aPt1;
+ aPt2=((SdrMeasureObj&)rObj).aPt2;
+ bTextDirty=((SdrMeasureObj&)rObj).bTextDirty;
+}
+
+void SdrMeasureObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulMEASURE);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+void SdrMeasureObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralMEASURE);
+}
+
+basegfx::B2DPolyPolygon SdrMeasureObj::TakeXorPoly() const
+{
+ ImpMeasureRec aRec;
+ ImpMeasurePoly aMPol;
+ ImpTakeAttr(aRec);
+ ImpCalcGeometrics(aRec,aMPol);
+ return ImpCalcXPoly(aMPol);
+}
+
+sal_uInt32 SdrMeasureObj::GetHdlCount() const
+{
+ return 6L;
+}
+
+SdrHdl* SdrMeasureObj::GetHdl(sal_uInt32 nHdlNum) const
+{
+ ImpMeasureRec aRec;
+ ImpMeasurePoly aMPol;
+ ImpTakeAttr(aRec);
+ aRec.nHelplineDist=0;
+ ImpCalcGeometrics(aRec,aMPol);
+ Point aPt;
+ //SdrHdlKind eHdl=HDL_POLY;
+ switch (nHdlNum) {
+ case 0: aPt=aMPol.aHelpline1.aP1; break;
+ case 1: aPt=aMPol.aHelpline2.aP1; break;
+ case 2: aPt=aPt1; break;
+ case 3: aPt=aPt2; break;
+ case 4: aPt=aMPol.aHelpline1.aP2; break;
+ case 5: aPt=aMPol.aHelpline2.aP2; break;
+ } // switch
+ SdrHdl* pHdl=new ImpMeasureHdl(aPt,HDL_USER);
+ pHdl->SetObjHdlNum(nHdlNum);
+ pHdl->SetDrehWink(aMPol.nLineWink);
+ return pHdl;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrMeasureObj::hasSpecialDrag() const
+{
+ return true;
+}
+
+bool SdrMeasureObj::beginSpecialDrag(SdrDragStat& rDrag) const
+{
+ const SdrHdl* pHdl = rDrag.GetHdl();
+
+ if(pHdl)
+ {
+ const sal_uInt32 nHdlNum(pHdl->GetObjHdlNum());
+
+ if(nHdlNum != 2 && nHdlNum != 3)
+ {
+ rDrag.SetEndDragChangesAttributes(true);
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+bool SdrMeasureObj::applySpecialDrag(SdrDragStat& rDrag)
+{
+ ImpMeasureRec aMeasureRec;
+ const SdrHdl* pHdl = rDrag.GetHdl();
+ const sal_uInt32 nHdlNum(pHdl->GetObjHdlNum());
+
+ ImpTakeAttr(aMeasureRec);
+ ImpEvalDrag(aMeasureRec, rDrag);
+
+ switch (nHdlNum)
+ {
+ case 2:
+ {
+ aPt1 = aMeasureRec.aPt1;
+ SetTextDirty();
+ break;
+ }
+ case 3:
+ {
+ aPt2 = aMeasureRec.aPt2;
+ SetTextDirty();
+ break;
+ }
+ default:
+ {
+ switch(nHdlNum)
+ {
+ case 0:
+ case 1:
+ {
+ ImpMeasureRec aOrigMeasureRec;
+ ImpTakeAttr(aOrigMeasureRec);
+
+ if(aMeasureRec.nHelpline1Len != aOrigMeasureRec.nHelpline1Len)
+ {
+ SetObjectItem(SdrMeasureHelpline1LenItem(aMeasureRec.nHelpline1Len));
+ }
+
+ if(aMeasureRec.nHelpline2Len != aOrigMeasureRec.nHelpline2Len)
+ {
+ SetObjectItem(SdrMeasureHelpline2LenItem(aMeasureRec.nHelpline2Len));
+ }
+
+ break;
+ }
+
+ case 4:
+ case 5:
+ {
+ ImpMeasureRec aOrigMeasureRec;
+ ImpTakeAttr(aOrigMeasureRec);
+
+ if(aMeasureRec.nLineDist != aOrigMeasureRec.nLineDist)
+ {
+ SetObjectItem(SdrMeasureLineDistItem(aMeasureRec.nLineDist));
+ }
+
+ if(aMeasureRec.bBelowRefEdge != aOrigMeasureRec.bBelowRefEdge)
+ {
+ SetObjectItem(SdrMeasureBelowRefEdgeItem(aMeasureRec.bBelowRefEdge));
+ }
+ }
+ }
+ }
+ } // switch
+
+ SetRectsDirty();
+ SetChanged();
+
+ return true;
+}
+
+String SdrMeasureObj::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const
+{
+ XubString aStr;
+ return aStr;
+}
+
+void SdrMeasureObj::ImpEvalDrag(ImpMeasureRec& rRec, const SdrDragStat& rDrag) const
+{
+ long nLineWink=GetAngle(rRec.aPt2-rRec.aPt1);
+ double a=nLineWink*nPi180;
+ double nSin=sin(a);
+ double nCos=cos(a);
+
+ const SdrHdl* pHdl=rDrag.GetHdl();
+ sal_uInt32 nHdlNum(pHdl->GetObjHdlNum());
+ bool bOrtho=rDrag.GetView()!=NULL && rDrag.GetView()->IsOrtho();
+ bool bBigOrtho=bOrtho && rDrag.GetView()->IsBigOrtho();
+ bool bBelow=rRec.bBelowRefEdge;
+ Point aPt(rDrag.GetNow());
+
+ switch (nHdlNum) {
+ case 0: {
+ RotatePoint(aPt,aPt1,nSin,-nCos);
+ rRec.nHelpline1Len=aPt1.Y()-aPt.Y();
+ if (bBelow) rRec.nHelpline1Len=-rRec.nHelpline1Len;
+ if (bOrtho) rRec.nHelpline2Len=rRec.nHelpline1Len;
+ } break;
+ case 1: {
+ RotatePoint(aPt,aPt2,nSin,-nCos);
+ rRec.nHelpline2Len=aPt2.Y()-aPt.Y();
+ if (bBelow) rRec.nHelpline2Len=-rRec.nHelpline2Len;
+ if (bOrtho) rRec.nHelpline1Len=rRec.nHelpline2Len;
+ } break;
+ case 2: case 3: {
+ bool bAnf=nHdlNum==2;
+ Point& rMov=bAnf ? rRec.aPt1 : rRec.aPt2;
+ Point aMov(rMov);
+ Point aFix(bAnf ? rRec.aPt2 : rRec.aPt1);
+ if (bOrtho) {
+ long ndx0=aMov.X()-aFix.X();
+ long ndy0=aMov.Y()-aFix.Y();
+ bool bHLin=ndy0==0;
+ bool bVLin=ndx0==0;
+ if (!bHLin || !bVLin) { // sonst ist aPt1==aPt2
+ long ndx=aPt.X()-aFix.X();
+ long ndy=aPt.Y()-aFix.Y();
+ double nXFact=0; if (!bVLin) nXFact=(double)ndx/(double)ndx0;
+ double nYFact=0; if (!bHLin) nYFact=(double)ndy/(double)ndy0;
+ bool bHor=bHLin || (!bVLin && (nXFact>nYFact) ==bBigOrtho);
+ bool bVer=bVLin || (!bHLin && (nXFact<=nYFact)==bBigOrtho);
+ if (bHor) ndy=long(ndy0*nXFact);
+ if (bVer) ndx=long(ndx0*nYFact);
+ aPt=aFix;
+ aPt.X()+=ndx;
+ aPt.Y()+=ndy;
+ } // else Ortho8
+ }
+ rMov=aPt;
+ } break;
+ case 4: case 5: {
+ long nVal0=rRec.nLineDist;
+ RotatePoint(aPt,(nHdlNum==4 ? aPt1 : aPt2),nSin,-nCos);
+ rRec.nLineDist=aPt.Y()- (nHdlNum==4 ? aPt1.Y() : aPt2.Y());
+ if (bBelow) rRec.nLineDist=-rRec.nLineDist;
+ if (rRec.nLineDist<0) {
+ rRec.nLineDist=-rRec.nLineDist;
+ rRec.bBelowRefEdge=!bBelow;
+ }
+ rRec.nLineDist-=rRec.nHelplineOverhang;
+ if (bOrtho) rRec.nLineDist=nVal0;
+ } break;
+ } // switch
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrMeasureObj::BegCreate(SdrDragStat& rStat)
+{
+ rStat.SetOrtho8Possible();
+ aPt1=rStat.GetStart();
+ aPt2=rStat.GetNow();
+ SetTextDirty();
+ return TRUE;
+}
+
+bool SdrMeasureObj::MovCreate(SdrDragStat& rStat)
+{
+ SdrView* pView=rStat.GetView();
+ aPt1=rStat.GetStart();
+ aPt2=rStat.GetNow();
+ if (pView!=NULL && pView->IsCreate1stPointAsCenter()) {
+ aPt1+=aPt1;
+ aPt1-=rStat.Now();
+ }
+ SetTextDirty();
+ SetBoundRectDirty();
+ bSnapRectDirty=TRUE;
+ return TRUE;
+}
+
+bool SdrMeasureObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ SetTextDirty();
+ SetRectsDirty();
+ return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
+}
+
+bool SdrMeasureObj::BckCreate(SdrDragStat& /*rStat*/)
+{
+ return false;
+}
+
+void SdrMeasureObj::BrkCreate(SdrDragStat& /*rStat*/)
+{
+}
+
+basegfx::B2DPolyPolygon SdrMeasureObj::TakeCreatePoly(const SdrDragStat& /*rDrag*/) const
+{
+ ImpMeasureRec aRec;
+ ImpMeasurePoly aMPol;
+
+ ImpTakeAttr(aRec);
+ ImpCalcGeometrics(aRec, aMPol);
+
+ return ImpCalcXPoly(aMPol);
+}
+
+Pointer SdrMeasureObj::GetCreatePointer() const
+{
+ return Pointer(POINTER_CROSS);
+}
+
+void SdrMeasureObj::NbcMove(const Size& rSiz)
+{
+ SdrTextObj::NbcMove(rSiz);
+ MovePoint(aPt1,rSiz);
+ MovePoint(aPt2,rSiz);
+}
+
+void SdrMeasureObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ SdrTextObj::NbcResize(rRef,xFact,yFact);
+ ResizePoint(aPt1,rRef,xFact,yFact);
+ ResizePoint(aPt2,rRef,xFact,yFact);
+ SetTextDirty();
+}
+
+void SdrMeasureObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ SdrTextObj::NbcRotate(rRef,nWink,sn,cs);
+ long nLen0=GetLen(aPt2-aPt1);
+ RotatePoint(aPt1,rRef,sn,cs);
+ RotatePoint(aPt2,rRef,sn,cs);
+ long nLen1=GetLen(aPt2-aPt1);
+ if (nLen1!=nLen0) { // Aha, Rundungsfehler
+ long dx=aPt2.X()-aPt1.X();
+ long dy=aPt2.Y()-aPt1.Y();
+ dx=BigMulDiv(dx,nLen0,nLen1);
+ dy=BigMulDiv(dy,nLen0,nLen1);
+ if (rRef==aPt2) {
+ aPt1.X()=aPt2.X()-dx;
+ aPt1.Y()=aPt2.Y()-dy;
+ } else {
+ aPt2.X()=aPt1.X()+dx;
+ aPt2.Y()=aPt1.Y()+dy;
+ }
+ }
+ SetRectsDirty();
+}
+
+void SdrMeasureObj::NbcMirror(const Point& rRef1, const Point& rRef2)
+{
+ SdrTextObj::NbcMirror(rRef1,rRef2);
+ MirrorPoint(aPt1,rRef1,rRef2);
+ MirrorPoint(aPt2,rRef1,rRef2);
+ SetRectsDirty();
+}
+
+void SdrMeasureObj::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ SdrTextObj::NbcShear(rRef,nWink,tn,bVShear);
+ ShearPoint(aPt1,rRef,tn,bVShear);
+ ShearPoint(aPt2,rRef,tn,bVShear);
+ SetRectsDirty();
+ SetTextDirty();
+}
+
+long SdrMeasureObj::GetRotateAngle() const
+{
+ return GetAngle(aPt2-aPt1);
+}
+
+void SdrMeasureObj::RecalcSnapRect()
+{
+ // #94520# Added correct implementation here.
+ ImpMeasureRec aRec;
+ ImpMeasurePoly aMPol;
+ XPolyPolygon aXPP;
+
+ ImpTakeAttr(aRec);
+ ImpCalcGeometrics(aRec, aMPol);
+ aXPP = XPolyPolygon(ImpCalcXPoly(aMPol));
+ maSnapRect = aXPP.GetBoundRect();
+}
+
+sal_uInt32 SdrMeasureObj::GetSnapPointCount() const
+{
+ return 2L;
+}
+
+Point SdrMeasureObj::GetSnapPoint(sal_uInt32 i) const
+{
+ if (i==0) return aPt1;
+ else return aPt2;
+}
+
+sal_Bool SdrMeasureObj::IsPolyObj() const
+{
+ return sal_True;
+}
+
+sal_uInt32 SdrMeasureObj::GetPointCount() const
+{
+ return 2L;
+}
+
+Point SdrMeasureObj::GetPoint(sal_uInt32 i) const
+{
+ return (0L == i) ? aPt1 : aPt2;
+}
+
+void SdrMeasureObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)
+{
+ if (0L == i)
+ aPt1=rPnt;
+ if (1L == i)
+ aPt2=rPnt;
+ SetRectsDirty();
+ SetTextDirty();
+}
+
+SdrObjGeoData* SdrMeasureObj::NewGeoData() const
+{
+ return new SdrMeasureObjGeoData;
+}
+
+void SdrMeasureObj::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ SdrTextObj::SaveGeoData(rGeo);
+ SdrMeasureObjGeoData& rMGeo=(SdrMeasureObjGeoData&)rGeo;
+ rMGeo.aPt1=aPt1;
+ rMGeo.aPt2=aPt2;
+}
+
+void SdrMeasureObj::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ SdrTextObj::RestGeoData(rGeo);
+ SdrMeasureObjGeoData& rMGeo=(SdrMeasureObjGeoData&)rGeo;
+ aPt1=rMGeo.aPt1;
+ aPt2=rMGeo.aPt2;
+ SetTextDirty();
+}
+
+SdrObject* SdrMeasureObj::DoConvertToPolyObj(BOOL bBezier) const
+{
+ // get XOR Poly as base
+ XPolyPolygon aTmpPolyPolygon(TakeXorPoly());
+
+ // get local ItemSet and StyleSheet
+ SfxItemSet aSet(GetObjectItemSet());
+ SfxStyleSheet* pStyleSheet = GetStyleSheet();
+
+ // prepare group
+ SdrObjGroup* pGroup = new SdrObjGroup;
+ pGroup->SetModel(GetModel());
+
+ // prepare parameters
+ basegfx::B2DPolyPolygon aPolyPoly;
+ SdrPathObj* pPath;
+ UINT16 nCount(aTmpPolyPolygon.Count());
+ UINT16 nLoopStart(0);
+
+ if(nCount == 3)
+ {
+ // three lines, first one is the middle one
+ aPolyPoly.clear();
+ aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
+
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
+ pPath->SetMergedItemSet(aSet);
+ pPath->SetStyleSheet(pStyleSheet, true);
+ pGroup->GetSubList()->NbcInsertObject(pPath);
+ aSet.Put(XLineStartWidthItem(0L));
+ aSet.Put(XLineEndWidthItem(0L));
+ nLoopStart = 1;
+ }
+ else if(nCount == 4)
+ {
+ // four lines, middle line with gap, so there are two lines used
+ // which have one arrow each
+ //INT32 nStartWidth = ((const XLineStartWidthItem&)(aSet.Get(XATTR_LINESTARTWIDTH))).GetValue();
+ INT32 nEndWidth = ((const XLineEndWidthItem&)(aSet.Get(XATTR_LINEENDWIDTH))).GetValue();
+ aSet.Put(XLineEndWidthItem(0L));
+
+ aPolyPoly.clear();
+ aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
+ pPath->SetMergedItemSet(aSet);
+ pPath->SetStyleSheet(pStyleSheet, true);
+
+ pGroup->GetSubList()->NbcInsertObject(pPath);
+
+ aSet.Put(XLineEndWidthItem(nEndWidth));
+ aSet.Put(XLineStartWidthItem(0L));
+
+ aPolyPoly.clear();
+ aPolyPoly.append(aTmpPolyPolygon[1].getB2DPolygon());
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
+ pPath->SetMergedItemSet(aSet);
+ pPath->SetStyleSheet(pStyleSheet, true);
+
+ pGroup->GetSubList()->NbcInsertObject(pPath);
+
+ aSet.Put(XLineEndWidthItem(0L));
+ nLoopStart = 2;
+ }
+ else if(nCount == 5)
+ {
+ // five lines, first two are the outer ones
+ //INT32 nStartWidth = ((const XLineStartWidthItem&)(aSet.Get(XATTR_LINESTARTWIDTH))).GetValue();
+ INT32 nEndWidth = ((const XLineEndWidthItem&)(aSet.Get(XATTR_LINEENDWIDTH))).GetValue();
+
+ aSet.Put(XLineEndWidthItem(0L));
+
+ aPolyPoly.clear();
+ aPolyPoly.append(aTmpPolyPolygon[0].getB2DPolygon());
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
+ pPath->SetMergedItemSet(aSet);
+ pPath->SetStyleSheet(pStyleSheet, true);
+
+ pGroup->GetSubList()->NbcInsertObject(pPath);
+
+ aSet.Put(XLineEndWidthItem(nEndWidth));
+ aSet.Put(XLineStartWidthItem(0L));
+
+ aPolyPoly.clear();
+ aPolyPoly.append(aTmpPolyPolygon[1].getB2DPolygon());
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
+ pPath->SetMergedItemSet(aSet);
+ pPath->SetStyleSheet(pStyleSheet, true);
+
+ pGroup->GetSubList()->NbcInsertObject(pPath);
+
+ aSet.Put(XLineEndWidthItem(0L));
+ nLoopStart = 2;
+ }
+
+ for(;nLoopStart<nCount;nLoopStart++)
+ {
+ aPolyPoly.clear();
+ aPolyPoly.append(aTmpPolyPolygon[nLoopStart].getB2DPolygon());
+ pPath = new SdrPathObj(OBJ_PATHLINE, aPolyPoly);
+ pPath->SetModel(GetModel());
+ pPath->SetMergedItemSet(aSet);
+ pPath->SetStyleSheet(pStyleSheet, true);
+
+ pGroup->GetSubList()->NbcInsertObject(pPath);
+ }
+
+ return ImpConvertAddText(pGroup, bBezier);
+}
+
+sal_Bool SdrMeasureObj::BegTextEdit(SdrOutliner& rOutl)
+{
+ UndirtyText();
+ return SdrTextObj::BegTextEdit(rOutl);
+}
+
+const Size& SdrMeasureObj::GetTextSize() const
+{
+ if (bTextDirty) UndirtyText();
+ return SdrTextObj::GetTextSize();
+}
+
+OutlinerParaObject* SdrMeasureObj::GetOutlinerParaObject() const
+{
+ if(bTextDirty)
+ UndirtyText();
+ return SdrTextObj::GetOutlinerParaObject();
+}
+
+void SdrMeasureObj::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject)
+{
+ SdrTextObj::NbcSetOutlinerParaObject(pTextObject);
+ if(SdrTextObj::GetOutlinerParaObject())
+ SetTextDirty(); // Text neu berechnen!
+}
+
+void SdrMeasureObj::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText,
+ Rectangle* pAnchorRect, BOOL bLineWidth ) const
+{
+ if (bTextDirty) UndirtyText();
+ SdrTextObj::TakeTextRect( rOutliner, rTextRect, bNoEditText, pAnchorRect, bLineWidth );
+}
+
+void SdrMeasureObj::TakeTextAnchorRect(Rectangle& rAnchorRect) const
+{
+ if (bTextDirty) UndirtyText();
+ SdrTextObj::TakeTextAnchorRect(rAnchorRect);
+}
+
+void SdrMeasureObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const
+{
+ if (bTextDirty) UndirtyText();
+ SdrTextObj::TakeTextEditArea(pPaperMin,pPaperMax,pViewInit,pViewMin);
+}
+
+USHORT SdrMeasureObj::GetOutlinerViewAnchorMode() const
+{
+ if (bTextDirty) UndirtyText();
+ ImpMeasureRec aRec;
+ ImpMeasurePoly aMPol;
+ ImpTakeAttr(aRec);
+ ImpCalcGeometrics(aRec,aMPol);
+
+ SdrTextHorzAdjust eTH=GetTextHorizontalAdjust();
+ SdrTextVertAdjust eTV=GetTextVerticalAdjust();
+ SdrMeasureTextHPos eMH=aMPol.eUsedTextHPos;
+ SdrMeasureTextVPos eMV=aMPol.eUsedTextVPos;
+ bool bTextRota90=aRec.bTextRota90;
+ //bool bTextUpsideDown=aRec.bTextUpsideDown;
+ bool bBelowRefEdge=aRec.bBelowRefEdge;
+
+ // bTextUpsideDown muss hier noch ausgewertet werden!!!!
+ if (!bTextRota90) {
+ if (eMH==SDRMEASURE_TEXTLEFTOUTSIDE) eTH=SDRTEXTHORZADJUST_RIGHT;
+ if (eMH==SDRMEASURE_TEXTRIGHTOUTSIDE) eTH=SDRTEXTHORZADJUST_LEFT;
+ // bei eMH==SDRMEASURE_TEXTINSIDE kann horizontal geankert werden.
+ if (eMV==SDRMEASURE_ABOVE) eTV=SDRTEXTVERTADJUST_BOTTOM;
+ if (eMV==SDRMEASURE_BELOW) eTV=SDRTEXTVERTADJUST_TOP;
+ if (eMV==SDRMEASURETEXT_BREAKEDLINE || eMV==SDRMEASURETEXT_VERTICALCENTERED) eTV=SDRTEXTVERTADJUST_CENTER;
+ } else {
+ if (eMH==SDRMEASURE_TEXTLEFTOUTSIDE) eTV=SDRTEXTVERTADJUST_BOTTOM;
+ if (eMH==SDRMEASURE_TEXTRIGHTOUTSIDE) eTV=SDRTEXTVERTADJUST_TOP;
+ // bei eMH==SDRMEASURE_TEXTINSIDE kann vertikal geankert werden.
+ if (!bBelowRefEdge) {
+ if (eMV==SDRMEASURE_ABOVE) eTH=SDRTEXTHORZADJUST_LEFT;
+ if (eMV==SDRMEASURE_BELOW) eTH=SDRTEXTHORZADJUST_RIGHT;
+ } else {
+ if (eMV==SDRMEASURE_ABOVE) eTH=SDRTEXTHORZADJUST_RIGHT;
+ if (eMV==SDRMEASURE_BELOW) eTH=SDRTEXTHORZADJUST_LEFT;
+ }
+ if (eMV==SDRMEASURETEXT_BREAKEDLINE || eMV==SDRMEASURETEXT_VERTICALCENTERED) eTH=SDRTEXTHORZADJUST_CENTER;
+ }
+
+ EVAnchorMode eRet=ANCHOR_BOTTOM_HCENTER;
+ if (eTH==SDRTEXTHORZADJUST_LEFT) {
+ if (eTV==SDRTEXTVERTADJUST_TOP) eRet=ANCHOR_TOP_LEFT;
+ else if (eTV==SDRTEXTVERTADJUST_BOTTOM) eRet=ANCHOR_BOTTOM_LEFT;
+ else eRet=ANCHOR_VCENTER_LEFT;
+ } else if (eTH==SDRTEXTHORZADJUST_RIGHT) {
+ if (eTV==SDRTEXTVERTADJUST_TOP) eRet=ANCHOR_TOP_RIGHT;
+ else if (eTV==SDRTEXTVERTADJUST_BOTTOM) eRet=ANCHOR_BOTTOM_RIGHT;
+ else eRet=ANCHOR_VCENTER_RIGHT;
+ } else {
+ if (eTV==SDRTEXTVERTADJUST_TOP) eRet=ANCHOR_TOP_HCENTER;
+ else if (eTV==SDRTEXTVERTADJUST_BOTTOM) eRet=ANCHOR_BOTTOM_HCENTER;
+ else eRet=ANCHOR_VCENTER_HCENTER;
+ }
+ return (USHORT)eRet;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// #i97878#
+// TRGetBaseGeometry/TRSetBaseGeometry needs to be based on two positions,
+// same as line geometry in SdrPathObj. Thus needs to be overloaded and
+// implemented since currently it is derived from SdrTextObj which uses
+// a functionality based on SnapRect which is not useful here
+
+inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
+inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
+
+sal_Bool SdrMeasureObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
+{
+ // handle the same as a simple line since the definition is based on two points
+ const basegfx::B2DRange aRange(aPt1.X(), aPt1.Y(), aPt2.X(), aPt2.Y());
+ basegfx::B2DTuple aScale(aRange.getRange());
+ basegfx::B2DTuple aTranslate(aRange.getMinimum());
+
+ // position maybe relative to anchorpos, convert
+ if( pModel->IsWriter() )
+ {
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
+ }
+ }
+
+ // force MapUnit to 100th mm
+ SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // postion
+ aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
+ aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplTwipsToMM(aScale.getX()));
+ aScale.setY(ImplTwipsToMM(aScale.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
+ }
+ }
+ }
+
+ // build return value matrix
+ rMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aScale, aTranslate);
+
+ return sal_True;
+}
+
+void SdrMeasureObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
+{
+ // use given transformation to derive the two defining points from unit line
+ basegfx::B2DPoint aPosA(rMatrix * basegfx::B2DPoint(0.0, 0.0));
+ basegfx::B2DPoint aPosB(rMatrix * basegfx::B2DPoint(1.0, 0.0));
+
+ // force metric to pool metric
+ SfxMapUnit eMapUnit = pModel->GetItemPool().GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // position
+ aPosA.setX(ImplMMToTwips(aPosA.getX()));
+ aPosA.setY(ImplMMToTwips(aPosA.getY()));
+ aPosB.setX(ImplMMToTwips(aPosB.getX()));
+ aPosB.setY(ImplMMToTwips(aPosB.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
+ }
+ }
+ }
+
+ if( pModel->IsWriter() )
+ {
+ // if anchor is used, make position relative to it
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ const basegfx::B2DVector aAnchorOffset(GetAnchorPos().X(), GetAnchorPos().Y());
+
+ aPosA += aAnchorOffset;
+ aPosB += aAnchorOffset;
+ }
+ }
+
+ // derive new model data
+ const Point aNewPt1(basegfx::fround(aPosA.getX()), basegfx::fround(aPosA.getY()));
+ const Point aNewPt2(basegfx::fround(aPosB.getX()), basegfx::fround(aPosB.getY()));
+
+ if(aNewPt1 != aPt1 || aNewPt2 != aPt2)
+ {
+ // set model values and broadcast
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+
+ aPt1 = aNewPt1;
+ aPt2 = aNewPt2;
+
+ SetTextDirty();
+ ActionChanged();
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
new file mode 100644
index 000000000000..a7f3e5bff9f3
--- /dev/null
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -0,0 +1,288 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <vcl/svapp.hxx>
+
+#include <svx/svdomedia.hxx>
+#include "svdglob.hxx"
+#include "svdstr.hrc"
+#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
+#include <avmedia/mediawindow.hxx>
+
+// ---------------
+// - SdrMediaObj -
+// ---------------
+
+TYPEINIT1( SdrMediaObj, SdrRectObj );
+
+// ------------------------------------------------------------------------------
+
+SdrMediaObj::SdrMediaObj()
+{
+}
+
+// ------------------------------------------------------------------------------
+
+SdrMediaObj::SdrMediaObj( const Rectangle& rRect ) :
+ SdrRectObj( rRect )
+{
+}
+
+// ------------------------------------------------------------------------------
+
+SdrMediaObj::~SdrMediaObj()
+{
+}
+
+// ------------------------------------------------------------------------------
+
+bool SdrMediaObj::HasTextEdit() const
+{
+ return false;
+}
+
+// ------------------------------------------------------------------------------
+
+sdr::contact::ViewContact* SdrMediaObj::CreateObjectSpecificViewContact()
+{
+ return new ::sdr::contact::ViewContactOfSdrMediaObj( *this );
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaObj::TakeObjInfo( SdrObjTransformInfoRec& rInfo ) const
+{
+ rInfo.bSelectAllowed = true;
+ rInfo.bMoveAllowed = true;
+ rInfo.bResizeFreeAllowed = true;
+ rInfo.bResizePropAllowed = true;
+ rInfo.bRotateFreeAllowed = false;
+ rInfo.bRotate90Allowed = false;
+ rInfo.bMirrorFreeAllowed = false;
+ rInfo.bMirror45Allowed = false;
+ rInfo.bMirror90Allowed = false;
+ rInfo.bTransparenceAllowed = false;
+ rInfo.bGradientAllowed = false;
+ rInfo.bShearAllowed = false;
+ rInfo.bEdgeRadiusAllowed = false;
+ rInfo.bNoOrthoDesired = false;
+ rInfo.bNoContortion = false;
+ rInfo.bCanConvToPath = false;
+ rInfo.bCanConvToPoly = false;
+ rInfo.bCanConvToContour = false;
+ rInfo.bCanConvToPathLineToArea = false;
+ rInfo.bCanConvToPolyLineToArea = false;
+}
+
+// ------------------------------------------------------------------------------
+
+UINT16 SdrMediaObj::GetObjIdentifier() const
+{
+ return UINT16( OBJ_MEDIA );
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulMEDIA);
+
+ String aName( GetName() );
+
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralMEDIA);
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaObj::operator=(const SdrObject& rObj)
+{
+ SdrRectObj::operator=( rObj );
+
+ if( rObj.ISA( SdrMediaObj ) )
+ {
+ const SdrMediaObj& rMediaObj = static_cast< const SdrMediaObj& >( rObj );
+
+ setMediaProperties( rMediaObj.getMediaProperties() );
+ setGraphic( rMediaObj.mapGraphic.get() );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool bShrinkOnly /* = false */ )
+{
+ Size aSize( Application::GetDefaultDevice()->PixelToLogic( getPreferredSize(), MAP_100TH_MM ) );
+ Size aMaxSize( rMaxRect.GetSize() );
+
+ if( aSize.Height() != 0 && aSize.Width() != 0 )
+ {
+ Point aPos( rMaxRect.TopLeft() );
+
+ // Falls Grafik zu gross, wird die Grafik
+ // in die Seite eingepasst
+ if ( (!bShrinkOnly ||
+ ( aSize.Height() > aMaxSize.Height() ) ||
+ ( aSize.Width() > aMaxSize.Width() ) )&&
+ aSize.Height() && aMaxSize.Height() )
+ {
+ float fGrfWH = (float)aSize.Width() /
+ (float)aSize.Height();
+ float fWinWH = (float)aMaxSize.Width() /
+ (float)aMaxSize.Height();
+
+ // Grafik an Pagesize anpassen (skaliert)
+ if ( fGrfWH < fWinWH )
+ {
+ aSize.Width() = (long)(aMaxSize.Height() * fGrfWH);
+ aSize.Height()= aMaxSize.Height();
+ }
+ else if ( fGrfWH > 0.F )
+ {
+ aSize.Width() = aMaxSize.Width();
+ aSize.Height()= (long)(aMaxSize.Width() / fGrfWH);
+ }
+
+ aPos = rMaxRect.Center();
+ }
+
+ if( bShrinkOnly )
+ aPos = aRect.TopLeft();
+
+ aPos.X() -= aSize.Width() / 2;
+ aPos.Y() -= aSize.Height() / 2;
+ SetLogicRect( Rectangle( aPos, aSize ) );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaObj::setURL( const ::rtl::OUString& rURL )
+{
+ ::avmedia::MediaItem aURLItem;
+
+ aURLItem.setURL( rURL );
+ setMediaProperties( aURLItem );
+}
+
+// ------------------------------------------------------------------------------
+
+const ::rtl::OUString& SdrMediaObj::getURL() const
+{
+ return getMediaProperties().getURL();
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaObj::setMediaProperties( const ::avmedia::MediaItem& rState )
+{
+ mediaPropertiesChanged( rState );
+ static_cast< ::sdr::contact::ViewContactOfSdrMediaObj& >( GetViewContact() ).executeMediaItem( getMediaProperties() );
+}
+
+// ------------------------------------------------------------------------------
+
+const ::avmedia::MediaItem& SdrMediaObj::getMediaProperties() const
+{
+ return maMediaProperties;
+}
+
+// ------------------------------------------------------------------------------
+
+bool SdrMediaObj::hasPreferredSize() const
+{
+ return static_cast< ::sdr::contact::ViewContactOfSdrMediaObj& >( GetViewContact() ).hasPreferredSize();
+}
+
+// ------------------------------------------------------------------------------
+
+Size SdrMediaObj::getPreferredSize() const
+{
+ return static_cast< ::sdr::contact::ViewContactOfSdrMediaObj& >( GetViewContact() ).getPreferredSize();
+}
+
+// ------------------------------------------------------------------------------
+
+const Graphic& SdrMediaObj::getGraphic() const
+{
+ if( !mapGraphic.get() )
+ const_cast< SdrMediaObj* >( this )->mapGraphic.reset( new Graphic( ::avmedia::MediaWindow::grabFrame( getURL(), true ) ) );
+
+ return *mapGraphic;
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaObj::setGraphic( const Graphic* pGraphic )
+{
+ mapGraphic.reset( pGraphic ? new Graphic( *pGraphic ) : NULL );
+}
+
+// ------------------------------------------------------------------------------
+
+void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProperties )
+{
+ const sal_uInt32 nMaskSet = rNewProperties.getMaskSet();
+
+ // use only a subset of MediaItem properties for own own properties
+ if( ( AVMEDIA_SETMASK_URL & nMaskSet ) &&
+ ( rNewProperties.getURL() != getURL() ) )
+ {
+ setGraphic();
+ maMediaProperties.setURL( rNewProperties.getURL() );
+ }
+
+ if( AVMEDIA_SETMASK_LOOP & nMaskSet )
+ maMediaProperties.setLoop( rNewProperties.isLoop() );
+
+ if( AVMEDIA_SETMASK_MUTE & nMaskSet )
+ maMediaProperties.setMute( rNewProperties.isMute() );
+
+ if( AVMEDIA_SETMASK_VOLUMEDB & nMaskSet )
+ maMediaProperties.setVolumeDB( rNewProperties.getVolumeDB() );
+
+ if( AVMEDIA_SETMASK_ZOOM & nMaskSet )
+ maMediaProperties.setZoom( rNewProperties.getZoom() );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx
new file mode 100644
index 000000000000..a048ab53e797
--- /dev/null
+++ b/svx/source/svdraw/svdoole2.cxx
@@ -0,0 +1,2245 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdoole2.hxx>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/embed/EmbedStates.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/EmbedMisc.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/embed/XInplaceClient.hpp>
+#include <com/sun/star/embed/XInplaceObject.hpp>
+#include <com/sun/star/embed/XLinkageSupport.hpp>
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/embed/XWindowSupplier.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include "com/sun/star/document/XStorageBasedDocument.hpp"
+
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/helper/convert.hxx>
+
+#include <svtools/filter.hxx>
+#include <svtools/embedhlp.hxx>
+
+#include <sfx2/objsh.hxx>
+#include <sfx2/ipclient.hxx>
+#include <sfx2/lnkbase.hxx>
+#include <tools/stream.hxx>
+#include <comphelper/anytostring.hxx>
+#include <svx/svdpagv.hxx>
+#include <tools/globname.hxx>
+#include <vcl/jobset.hxx>
+#include <sot/clsids.hxx>
+
+#include <sot/formats.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <svtools/transfer.hxx>
+#include <cppuhelper/implbase5.hxx>
+
+#include <svl/solar.hrc>
+#include <svl/urihelper.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#include <svx/svdpagv.hxx>
+#include <svx/svdmodel.hxx>
+#include "svdglob.hxx" // Stringcache
+#include "svdstr.hrc" // Objektname
+#include <svx/svdetc.hxx>
+#include <svx/svdview.hxx>
+#include "unomlstr.hxx"
+#include <svtools/chartprettypainter.hxx>
+#include <svx/sdr/contact/viewcontactofsdrole2obj.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/sdr/properties/oleproperties.hxx>
+
+// #i100710#
+#include <svx/xlnclit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xflbmtit.hxx>
+#include <svx/xflbstit.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+uno::Reference < beans::XPropertySet > lcl_getFrame_throw(const SdrOle2Obj* _pObject)
+{
+ uno::Reference < beans::XPropertySet > xFrame;
+ if ( _pObject )
+ {
+ uno::Reference< frame::XController> xController = _pObject->GetParentXModel()->getCurrentController();
+ if ( xController.is() )
+ {
+ xFrame.set( xController->getFrame(),uno::UNO_QUERY_THROW);
+ }
+ } // if ( _pObject )
+ return xFrame;
+}
+
+class SdrLightEmbeddedClient_Impl : public ::cppu::WeakImplHelper5
+ < embed::XStateChangeListener
+ , document::XEventListener
+ , embed::XInplaceClient
+ , embed::XEmbeddedClient
+ , embed::XWindowSupplier
+ >
+{
+ uno::Reference< awt::XWindow > m_xWindow;
+ SdrOle2Obj* mpObj;
+
+ Fraction m_aScaleWidth;
+ Fraction m_aScaleHeight;
+
+
+public:
+ SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj );
+ void Release();
+
+ void SetSizeScale( const Fraction& aScaleWidth, const Fraction& aScaleHeight )
+ {
+ m_aScaleWidth = aScaleWidth;
+ m_aScaleHeight = aScaleHeight;
+ }
+
+ Fraction GetScaleWidth() const { return m_aScaleWidth; }
+ Fraction GetScaleHeight() const { return m_aScaleHeight; }
+
+ void setWindow(const uno::Reference< awt::XWindow >& _xWindow);
+
+private:
+ Rectangle impl_getScaledRect_nothrow() const;
+ // XStateChangeListener
+ virtual void SAL_CALL changingState( const ::com::sun::star::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL stateChanged( const ::com::sun::star::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ // document::XEventListener
+ virtual void SAL_CALL notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException );
+
+ // XEmbeddedClient
+ virtual void SAL_CALL saveObject() throw ( embed::ObjectSaveVetoException, uno::Exception, uno::RuntimeException );
+ virtual void SAL_CALL visibilityChanged( sal_Bool bVisible ) throw ( embed::WrongStateException, uno::RuntimeException );
+
+ // XComponentSupplier
+ virtual uno::Reference< util::XCloseable > SAL_CALL getComponent() throw ( uno::RuntimeException );
+
+ // XInplaceClient
+ virtual sal_Bool SAL_CALL canInplaceActivate() throw ( uno::RuntimeException );
+ virtual void SAL_CALL activatingInplace() throw ( embed::WrongStateException, uno::RuntimeException );
+ virtual void SAL_CALL activatingUI() throw ( embed::WrongStateException, uno::RuntimeException );
+ virtual void SAL_CALL deactivatedInplace() throw ( embed::WrongStateException, uno::RuntimeException );
+ virtual void SAL_CALL deactivatedUI() throw ( embed::WrongStateException, uno::RuntimeException );
+ virtual uno::Reference< ::com::sun::star::frame::XLayoutManager > SAL_CALL getLayoutManager() throw ( embed::WrongStateException, uno::RuntimeException );
+ virtual uno::Reference< frame::XDispatchProvider > SAL_CALL getInplaceDispatchProvider() throw ( embed::WrongStateException, uno::RuntimeException );
+ virtual awt::Rectangle SAL_CALL getPlacement() throw ( embed::WrongStateException, uno::RuntimeException );
+ virtual awt::Rectangle SAL_CALL getClipRectangle() throw ( embed::WrongStateException, uno::RuntimeException );
+ virtual void SAL_CALL translateAccelerators( const uno::Sequence< awt::KeyEvent >& aKeys ) throw ( embed::WrongStateException, uno::RuntimeException );
+ virtual void SAL_CALL scrollObject( const awt::Size& aOffset ) throw ( embed::WrongStateException, uno::RuntimeException );
+ virtual void SAL_CALL changedPlacement( const awt::Rectangle& aPosRect ) throw ( embed::WrongStateException, uno::Exception, uno::RuntimeException );
+
+ // XWindowSupplier
+ virtual uno::Reference< awt::XWindow > SAL_CALL getWindow() throw ( uno::RuntimeException );
+};
+
+//--------------------------------------------------------------------
+SdrLightEmbeddedClient_Impl::SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj )
+: mpObj( pObj )
+{
+}
+Rectangle SdrLightEmbeddedClient_Impl::impl_getScaledRect_nothrow() const
+{
+ MapUnit aContainerMapUnit( MAP_100TH_MM );
+ uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
+ if ( xParentVis.is() )
+ aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
+ Rectangle aLogicRect( mpObj->GetLogicRect() );
+ // apply scaling to object area and convert to pixels
+ aLogicRect.SetSize( Size( Fraction( aLogicRect.GetWidth() ) * m_aScaleWidth,
+ Fraction( aLogicRect.GetHeight() ) * m_aScaleHeight ) );
+ return aLogicRect;
+}
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::changingState( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 /*nOldState*/, ::sal_Int32 /*nNewState*/ ) throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException)
+{
+}
+
+//--------------------------------------------------------------------
+void SdrLightEmbeddedClient_Impl::Release()
+{
+ {
+ SolarMutexGuard aGuard;
+ mpObj = NULL;
+ }
+
+ release();
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::stateChanged( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( mpObj && nOldState == embed::EmbedStates::LOADED && nNewState == embed::EmbedStates::RUNNING )
+ {
+ mpObj->ObjectLoaded();
+ GetSdrGlobalData().GetOLEObjCache().InsertObj(mpObj);
+ }
+ else if ( mpObj && nNewState == embed::EmbedStates::LOADED && nOldState == embed::EmbedStates::RUNNING )
+ {
+ GetSdrGlobalData().GetOLEObjCache().RemoveObj(mpObj);
+ }
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::disposing( const ::com::sun::star::lang::EventObject& /*aEvent*/ ) throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ GetSdrGlobalData().GetOLEObjCache().RemoveObj(mpObj);
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException )
+{
+ // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
+
+ SolarMutexGuard aGuard;
+
+ // the code currently makes sence only in case there is no other client
+ if ( mpObj && mpObj->GetAspect() != embed::Aspects::MSOLE_ICON && aEvent.EventName.equalsAscii("OnVisAreaChanged")
+ && mpObj->GetObjRef().is() && mpObj->GetObjRef()->getClientSite() == uno::Reference< embed::XEmbeddedClient >( this ) )
+ {
+ try
+ {
+ MapUnit aContainerMapUnit( MAP_100TH_MM );
+ uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
+ if ( xParentVis.is() )
+ aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
+
+ MapUnit aObjMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpObj->GetObjRef()->getMapUnit( mpObj->GetAspect() ) );
+
+ Rectangle aVisArea;
+ awt::Size aSz;
+ try
+ {
+ aSz = mpObj->GetObjRef()->getVisualAreaSize( mpObj->GetAspect() );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {
+ OSL_ENSURE( sal_False, "No visual area size!\n" );
+ aSz.Width = 5000;
+ aSz.Height = 5000;
+ }
+ catch( uno::Exception& )
+ {
+ OSL_ENSURE( sal_False, "Unexpected exception!\n" );
+ aSz.Width = 5000;
+ aSz.Height = 5000;
+ }
+
+ aVisArea.SetSize( Size( aSz.Width, aSz.Height ) );
+ aVisArea = OutputDevice::LogicToLogic( aVisArea, aObjMapUnit, aContainerMapUnit );
+ Size aScaledSize( static_cast< long >( m_aScaleWidth * Fraction( aVisArea.GetWidth() ) ),
+ static_cast< long >( m_aScaleHeight * Fraction( aVisArea.GetHeight() ) ) );
+ Rectangle aLogicRect( mpObj->GetLogicRect() );
+
+ // react to the change if the difference is bigger than one pixel
+ Size aPixelDiff =
+ Application::GetDefaultDevice()->LogicToPixel(
+ Size( aLogicRect.GetWidth() - aScaledSize.Width(),
+ aLogicRect.GetHeight() - aScaledSize.Height() ),
+ aContainerMapUnit );
+ if( aPixelDiff.Width() || aPixelDiff.Height() )
+ {
+ mpObj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aScaledSize ) );
+ mpObj->BroadcastObjectChange();
+ }
+ else
+ mpObj->ActionChanged();
+ }
+ catch( uno::Exception& )
+ {
+ OSL_ENSURE( sal_False, "Unexpected exception!\n" );
+ }
+ }
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::saveObject()
+ throw ( embed::ObjectSaveVetoException,
+ uno::Exception,
+ uno::RuntimeException )
+{
+ // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
+ uno::Reference< embed::XCommonEmbedPersist > xPersist;
+ uno::Reference< util::XModifiable > xModifiable;
+
+ {
+ SolarMutexGuard aGuard;
+
+ if ( !mpObj )
+ throw embed::ObjectSaveVetoException();
+
+ // the common persistance is supported by objects and links
+ xPersist = uno::Reference< embed::XCommonEmbedPersist >( mpObj->GetObjRef(), uno::UNO_QUERY_THROW );
+ xModifiable = uno::Reference< util::XModifiable >( mpObj->GetParentXModel(), uno::UNO_QUERY );
+ }
+
+ xPersist->storeOwn();
+
+ if ( xModifiable.is() )
+ xModifiable->setModified( sal_True );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::visibilityChanged( sal_Bool /*bVisible*/ )
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+ // nothing to do currently
+ // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
+ if ( mpObj )
+ {
+ Rectangle aLogicRect( mpObj->GetLogicRect() );
+ Size aLogicSize( aLogicRect.GetWidth(), aLogicRect.GetHeight() );
+
+ if( mpObj->IsChart() )
+ {
+ //charts never should be stretched see #i84323# for example
+ mpObj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aLogicSize ) );
+ mpObj->BroadcastObjectChange();
+ } // if( mpObj->IsChart() )
+ }
+}
+
+//--------------------------------------------------------------------
+uno::Reference< util::XCloseable > SAL_CALL SdrLightEmbeddedClient_Impl::getComponent()
+ throw ( uno::RuntimeException )
+{
+ uno::Reference< util::XCloseable > xResult;
+
+ SolarMutexGuard aGuard;
+ if ( mpObj )
+ xResult = uno::Reference< util::XCloseable >( mpObj->GetParentXModel(), uno::UNO_QUERY );
+
+ return xResult;
+}
+// XInplaceClient
+//--------------------------------------------------------------------
+sal_Bool SAL_CALL SdrLightEmbeddedClient_Impl::canInplaceActivate()
+ throw ( uno::RuntimeException )
+{
+ sal_Bool bRet = sal_False;
+ SolarMutexGuard aGuard;
+ if ( mpObj )
+ {
+ uno::Reference< embed::XEmbeddedObject > xObject = mpObj->GetObjRef();
+ if ( !xObject.is() )
+ throw uno::RuntimeException();
+ // we don't want to switch directly from outplace to inplace mode
+ bRet = !( xObject->getCurrentState() == embed::EmbedStates::ACTIVE || mpObj->GetAspect() == embed::Aspects::MSOLE_ICON );
+ } // if ( mpObj )
+ return bRet;
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::activatingInplace()
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::activatingUI()
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference < beans::XPropertySet > xFrame( lcl_getFrame_throw(mpObj));
+ uno::Reference < frame::XFrame > xOwnFrame( xFrame,uno::UNO_QUERY);
+ uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY );
+ if ( xParentFrame.is() )
+ xParentFrame->setActiveFrame( xOwnFrame );
+
+ OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache();
+ const ULONG nCount = rObjCache.Count();
+ for(sal_Int32 i = nCount-1 ; i >= 0;--i)
+ {
+ SdrOle2Obj* pObj = reinterpret_cast<SdrOle2Obj*>(rObjCache.GetObject(i));
+ if ( pObj != mpObj )
+ {
+ // only deactivate ole objects which belongs to the same frame
+ if ( xFrame == lcl_getFrame_throw(pObj) )
+ {
+ uno::Reference< embed::XEmbeddedObject > xObject = pObj->GetObjRef();
+ try
+ {
+ if ( xObject->getStatus( pObj->GetAspect() ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE )
+ xObject->changeState( embed::EmbedStates::INPLACE_ACTIVE );
+ else
+ {
+ // the links should not stay in running state for long time because of locking
+ uno::Reference< embed::XLinkageSupport > xLink( xObject, uno::UNO_QUERY );
+ if ( xLink.is() && xLink->isLink() )
+ xObject->changeState( embed::EmbedStates::LOADED );
+ else
+ xObject->changeState( embed::EmbedStates::RUNNING );
+ }
+ }
+ catch (com::sun::star::uno::Exception& )
+ {}
+ }
+ }
+ } // for(sal_Int32 i = nCount-1 ; i >= 0;--i)
+
+ //m_pClient->GetViewShell()->UIActivating( m_pClient );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::deactivatedInplace()
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::deactivatedUI()
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager(getLayoutManager());
+ if ( xLayoutManager.is() )
+ {
+ const static rtl::OUString aMenuBarURL( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" ));
+ if ( !xLayoutManager->isElementVisible( aMenuBarURL ) )
+ xLayoutManager->createElement( aMenuBarURL );
+ }
+}
+
+//--------------------------------------------------------------------
+uno::Reference< ::com::sun::star::frame::XLayoutManager > SAL_CALL SdrLightEmbeddedClient_Impl::getLayoutManager()
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+ uno::Reference< ::com::sun::star::frame::XLayoutManager > xMan;
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertySet > xFrame( lcl_getFrame_throw(mpObj));
+ try
+ {
+ xMan.set(xFrame->getPropertyValue( ::rtl::OUString::createFromAscii("LayoutManager") ),uno::UNO_QUERY);
+ }
+ catch ( uno::Exception& )
+ {
+ throw uno::RuntimeException();
+ }
+
+ return xMan;
+}
+
+//--------------------------------------------------------------------
+uno::Reference< frame::XDispatchProvider > SAL_CALL SdrLightEmbeddedClient_Impl::getInplaceDispatchProvider()
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ return uno::Reference < frame::XDispatchProvider >( lcl_getFrame_throw(mpObj), uno::UNO_QUERY_THROW );
+}
+
+//--------------------------------------------------------------------
+awt::Rectangle SAL_CALL SdrLightEmbeddedClient_Impl::getPlacement()
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if ( !mpObj )
+ throw uno::RuntimeException();
+
+ Rectangle aLogicRect = impl_getScaledRect_nothrow();
+ MapUnit aContainerMapUnit( MAP_100TH_MM );
+ uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
+ if ( xParentVis.is() )
+ aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
+
+ aLogicRect = Application::GetDefaultDevice()->LogicToPixel(aLogicRect,aContainerMapUnit);
+ return AWTRectangle( aLogicRect );
+}
+
+//--------------------------------------------------------------------
+awt::Rectangle SAL_CALL SdrLightEmbeddedClient_Impl::getClipRectangle()
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+ return getPlacement();
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::translateAccelerators( const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::scrollObject( const awt::Size& /*aOffset*/ )
+ throw ( embed::WrongStateException,
+ uno::RuntimeException )
+{
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL SdrLightEmbeddedClient_Impl::changedPlacement( const awt::Rectangle& aPosRect )
+ throw ( embed::WrongStateException,
+ uno::Exception,
+ uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if ( !mpObj )
+ throw uno::RuntimeException();
+
+ uno::Reference< embed::XInplaceObject > xInplace( mpObj->GetObjRef(), uno::UNO_QUERY );
+ if ( !xInplace.is() )
+ throw uno::RuntimeException();
+
+ // check if the change is at least one pixel in size
+ awt::Rectangle aOldRect = getPlacement();
+ Rectangle aNewPixelRect = VCLRectangle( aPosRect );
+ Rectangle aOldPixelRect = VCLRectangle( aOldRect );
+ if ( aOldPixelRect == aNewPixelRect )
+ // nothing has changed
+ return;
+
+ // new scaled object area
+ MapUnit aContainerMapUnit( MAP_100TH_MM );
+ uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
+ if ( xParentVis.is() )
+ aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
+
+ Rectangle aNewLogicRect = Application::GetDefaultDevice()->PixelToLogic(aNewPixelRect,aContainerMapUnit);
+ Rectangle aLogicRect = impl_getScaledRect_nothrow();
+
+ if ( aNewLogicRect != aLogicRect )
+ {
+ // the calculation of the object area has not changed the object size
+ // it should be done here then
+ //SfxBooleanFlagGuard aGuard( m_bResizeNoScale, sal_True );
+
+ // new size of the object area without scaling
+ Size aNewObjSize( Fraction( aNewLogicRect.GetWidth() ) / m_aScaleWidth,
+ Fraction( aNewLogicRect.GetHeight() ) / m_aScaleHeight );
+
+ // now remove scaling from new placement and keep this a the new object area
+ aNewLogicRect.SetSize( aNewObjSize );
+ // react to the change if the difference is bigger than one pixel
+ Size aPixelDiff =
+ Application::GetDefaultDevice()->LogicToPixel(
+ Size( aLogicRect.GetWidth() - aNewObjSize.Width(),
+ aLogicRect.GetHeight() - aNewObjSize.Height() ),
+ aContainerMapUnit );
+ if( aPixelDiff.Width() || aPixelDiff.Height() )
+ {
+ mpObj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aNewObjSize ) );
+ mpObj->BroadcastObjectChange();
+ }
+ else
+ mpObj->ActionChanged();
+
+ // let the window size be recalculated
+ //SizeHasChanged(); // TODO: OJ
+ }
+}
+// XWindowSupplier
+//--------------------------------------------------------------------
+uno::Reference< awt::XWindow > SAL_CALL SdrLightEmbeddedClient_Impl::getWindow()
+ throw ( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< awt::XWindow > xCurrent = m_xWindow;
+ if ( !xCurrent.is() )
+ {
+ if ( !mpObj )
+ throw uno::RuntimeException();
+ uno::Reference< frame::XFrame> xFrame(lcl_getFrame_throw(mpObj),uno::UNO_QUERY_THROW);
+ xCurrent = xFrame->getComponentWindow();
+ } // if ( !xCurrent.is() )
+ return xCurrent;
+}
+void SdrLightEmbeddedClient_Impl::setWindow(const uno::Reference< awt::XWindow >& _xWindow)
+{
+ m_xWindow = _xWindow;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class SdrEmbedObjectLink : public sfx2::SvBaseLink
+{
+ SdrOle2Obj* pObj;
+
+public:
+ SdrEmbedObjectLink(SdrOle2Obj* pObj);
+ virtual ~SdrEmbedObjectLink();
+
+ virtual void Closed();
+ virtual void DataChanged( const String& rMimeType,
+ const ::com::sun::star::uno::Any & rValue );
+
+ sal_Bool Connect() { return GetRealObject() != NULL; }
+};
+
+// -----------------------------------------------------------------------------
+
+SdrEmbedObjectLink::SdrEmbedObjectLink(SdrOle2Obj* pObject):
+ ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, SOT_FORMATSTR_ID_SVXB ),
+ pObj(pObject)
+{
+ SetSynchron( FALSE );
+}
+
+// -----------------------------------------------------------------------------
+
+SdrEmbedObjectLink::~SdrEmbedObjectLink()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrEmbedObjectLink::DataChanged( const String& /*rMimeType*/,
+ const ::com::sun::star::uno::Any & /*rValue*/ )
+{
+ if ( !pObj->UpdateLinkURL_Impl() )
+ {
+ // the link URL was not changed
+ uno::Reference< embed::XEmbeddedObject > xObject = pObj->GetObjRef();
+ OSL_ENSURE( xObject.is(), "The object must exist always!\n" );
+ if ( xObject.is() )
+ {
+ // let the object reload the link
+ // TODO/LATER: reload call could be used for this case
+
+ try
+ {
+ sal_Int32 nState = xObject->getCurrentState();
+ if ( nState != embed::EmbedStates::LOADED )
+ {
+ // in some cases the linked file probably is not locked so it could be changed
+ xObject->changeState( embed::EmbedStates::LOADED );
+ xObject->changeState( nState );
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+ }
+
+ pObj->GetNewReplacement();
+ pObj->SetChanged();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrEmbedObjectLink::Closed()
+{
+ pObj->BreakFileLink_Impl();
+ SvBaseLink::Closed();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class SdrOle2ObjImpl
+{
+public:
+ // TODO/LATER: do we really need this pointer?
+ GraphicObject* pGraphicObject;
+ String aPersistName; // name of object in persist
+ SdrLightEmbeddedClient_Impl* pLightClient; // must be registered as client only using AddOwnLightClient() call
+
+ // #107645#
+ // New local var to avoid repeated loading if load of OLE2 fails
+ sal_Bool mbLoadingOLEObjectFailed;
+ sal_Bool mbConnected;
+
+ SdrEmbedObjectLink* mpObjectLink;
+ String maLinkURL;
+
+ SdrOle2ObjImpl()
+ : pGraphicObject( NULL )
+ // #107645#
+ // init to start situation, loading did not fail
+ , mbLoadingOLEObjectFailed( sal_False )
+ , mbConnected( sal_False )
+ , mpObjectLink( NULL )
+ {
+ }
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// Predicate determining whether the given OLE is an internal math
+// object
+static bool ImplIsMathObj( const uno::Reference < embed::XEmbeddedObject >& rObjRef )
+{
+ if ( !rObjRef.is() )
+ return false;
+
+ SvGlobalName aClassName( rObjRef->getClassID() );
+ if( aClassName == SvGlobalName(SO3_SM_CLASSID_30) ||
+ aClassName == SvGlobalName(SO3_SM_CLASSID_40) ||
+ aClassName == SvGlobalName(SO3_SM_CLASSID_50) ||
+ aClassName == SvGlobalName(SO3_SM_CLASSID_60) ||
+ aClassName == SvGlobalName(SO3_SM_CLASSID) )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrOle2Obj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::OleProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// DrawContact section
+
+sdr::contact::ViewContact* SdrOle2Obj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfSdrOle2Obj(*this);
+}
+
+// -----------------------------------------------------------------------------
+
+TYPEINIT1(SdrOle2Obj,SdrRectObj);
+DBG_NAME(SdrOle2Obj)
+SdrOle2Obj::SdrOle2Obj(bool bFrame_) : m_bTypeAsked(false)
+,m_bChart(false)
+{
+ DBG_CTOR( SdrOle2Obj,NULL);
+ bInDestruction = FALSE;
+ Init();
+ bFrame=bFrame_;
+}
+
+// -----------------------------------------------------------------------------
+SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, bool bFrame_)
+ : xObjRef( rNewObjRef )
+ , m_bTypeAsked(false)
+ , m_bChart(false)
+{
+ DBG_CTOR( SdrOle2Obj,NULL);
+ bInDestruction = FALSE;
+ Init();
+
+ bFrame=bFrame_;
+
+ if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
+ SetResizeProtect(TRUE);
+
+ // #108759# For math objects, set closed state to transparent
+ if( ImplIsMathObj( xObjRef.GetObject() ) )
+ SetClosedObj( false );
+}
+
+// -----------------------------------------------------------------------------
+
+SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, const XubString& rNewObjName, bool bFrame_)
+ : xObjRef( rNewObjRef )
+ , m_bTypeAsked(false)
+ , m_bChart(false)
+{
+ DBG_CTOR( SdrOle2Obj,NULL);
+ bInDestruction = FALSE;
+ Init();
+
+ mpImpl->aPersistName = rNewObjName;
+ bFrame=bFrame_;
+
+ if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
+ SetResizeProtect(TRUE);
+
+ // #108759# For math objects, set closed state to transparent
+ if( ImplIsMathObj( xObjRef.GetObject() ) )
+ SetClosedObj( false );
+}
+
+// -----------------------------------------------------------------------------
+
+SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, const XubString& rNewObjName, const Rectangle& rNewRect, bool bFrame_)
+ : SdrRectObj(rNewRect)
+ , xObjRef( rNewObjRef )
+ , m_bTypeAsked(false)
+ , m_bChart(false)
+{
+ DBG_CTOR( SdrOle2Obj,NULL);
+ bInDestruction = FALSE;
+ Init();
+
+ mpImpl->aPersistName = rNewObjName;
+ bFrame=bFrame_;
+
+ if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
+ SetResizeProtect(TRUE);
+
+ // #108759# For math objects, set closed state to transparent
+ if( ImplIsMathObj( xObjRef.GetObject() ) )
+ SetClosedObj( false );
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::Init()
+{
+ mpImpl = new SdrOle2ObjImpl;
+ pModifyListener = NULL;
+ pGraphic=NULL;
+ mpImpl->pGraphicObject=NULL;
+ mpImpl->pLightClient = 0;
+
+ xObjRef.Lock( TRUE );
+}
+
+// -----------------------------------------------------------------------------
+
+SdrOle2Obj::~SdrOle2Obj()
+{
+ DBG_DTOR( SdrOle2Obj,NULL);
+ bInDestruction = TRUE;
+
+ if ( mpImpl->mbConnected )
+ Disconnect();
+
+ if( pGraphic!=NULL )
+ delete pGraphic;
+
+ if(mpImpl->pGraphicObject!=NULL)
+ delete mpImpl->pGraphicObject;
+
+ if(pModifyListener)
+ {
+ pModifyListener->invalidate();
+ pModifyListener->release();
+ }
+
+ DisconnectFileLink_Impl();
+
+ if ( mpImpl->pLightClient )
+ {
+ mpImpl->pLightClient->Release();
+ mpImpl->pLightClient = NULL;
+ }
+
+ delete mpImpl;
+}
+
+// -----------------------------------------------------------------------------
+void SdrOle2Obj::SetAspect( sal_Int64 nAspect )
+{
+ xObjRef.SetViewAspect( nAspect );
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::SetGraphic_Impl(const Graphic* pGrf)
+{
+ if ( pGraphic )
+ {
+ delete pGraphic;
+ pGraphic = NULL;
+ delete mpImpl->pGraphicObject;
+ mpImpl->pGraphicObject = NULL;
+ }
+
+ if (pGrf!=NULL)
+ {
+ pGraphic = new Graphic(*pGrf);
+ mpImpl->pGraphicObject = new GraphicObject( *pGraphic );
+ }
+
+ SetChanged();
+ BroadcastObjectChange();
+
+ //if ( ppObjRef->Is() && pGrf )
+ // BroadcastObjectChange();
+}
+
+void SdrOle2Obj::SetGraphic(const Graphic* pGrf)
+{
+ // only for setting a preview graphic
+ SetGraphic_Impl( pGrf );
+}
+
+// -----------------------------------------------------------------------------
+
+bool SdrOle2Obj::IsEmpty() const
+{
+ return !(xObjRef.is());
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::Connect()
+{
+ if( IsEmptyPresObj() )
+ return;
+
+ if( mpImpl->mbConnected )
+ {
+ // mba: currently there are situations where it seems to be unavoidable to have multiple connects
+ // changing this would need a larger code rewrite, so for now I remove the assertion
+ // DBG_ERROR("Connect() called on connected object!");
+ return;
+ }
+
+ Connect_Impl();
+ AddListeners_Impl();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SdrOle2Obj::UpdateLinkURL_Impl()
+{
+ sal_Bool bResult = sal_False;
+
+ if ( mpImpl->mpObjectLink )
+ {
+ sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : NULL;
+ if ( pLinkManager )
+ {
+ String aNewLinkURL;
+ pLinkManager->GetDisplayNames( mpImpl->mpObjectLink, 0, &aNewLinkURL, 0, 0 );
+ if ( !aNewLinkURL.EqualsIgnoreCaseAscii( mpImpl->maLinkURL ) )
+ {
+ const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
+ uno::Reference< embed::XCommonEmbedPersist > xPersObj( xObjRef.GetObject(), uno::UNO_QUERY );
+ OSL_ENSURE( xPersObj.is(), "The object must exist!\n" );
+ if ( xPersObj.is() )
+ {
+ try
+ {
+ sal_Int32 nCurState = xObjRef->getCurrentState();
+ if ( nCurState != embed::EmbedStates::LOADED )
+ xObjRef->changeState( embed::EmbedStates::LOADED );
+
+ // TODO/LATER: there should be possible to get current mediadescriptor settings from the object
+ uno::Sequence< beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
+ aArgs[0].Value <<= ::rtl::OUString( aNewLinkURL );
+ xPersObj->reload( aArgs, uno::Sequence< beans::PropertyValue >() );
+
+ mpImpl->maLinkURL = aNewLinkURL;
+ bResult = sal_True;
+
+ if ( nCurState != embed::EmbedStates::LOADED )
+ xObjRef->changeState( nCurState );
+ }
+ catch( ::com::sun::star::uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR(
+ (OString("SdrOle2Obj::UpdateLinkURL_Impl(), "
+ "exception caught: ") +
+ rtl::OUStringToOString(
+ comphelper::anyToString( cppu::getCaughtException() ),
+ RTL_TEXTENCODING_UTF8 )).getStr() );
+ }
+ }
+
+ if ( !bResult )
+ {
+ // TODO/LATER: return the old name to the link manager, is it possible?
+ }
+ }
+ }
+ }
+
+ return bResult;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::BreakFileLink_Impl()
+{
+ uno::Reference<document::XStorageBasedDocument> xDoc;
+ if ( pModel )
+ xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
+
+ if ( xDoc.is() )
+ {
+ uno::Reference< embed::XStorage > xStorage = xDoc->getDocumentStorage();
+ if ( xStorage.is() )
+ {
+ try
+ {
+ uno::Reference< embed::XLinkageSupport > xLinkSupport( xObjRef.GetObject(), uno::UNO_QUERY_THROW );
+ xLinkSupport->breakLink( xStorage, mpImpl->aPersistName );
+ DisconnectFileLink_Impl();
+ mpImpl->maLinkURL = String();
+ }
+ catch( ::com::sun::star::uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR(
+ (OString("SdrOle2Obj::BreakFileLink_Impl(), "
+ "exception caught: ") +
+ rtl::OUStringToOString(
+ comphelper::anyToString( cppu::getCaughtException() ),
+ RTL_TEXTENCODING_UTF8 )).getStr() );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::DisconnectFileLink_Impl()
+{
+ sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : NULL;
+ if ( pLinkManager && mpImpl->mpObjectLink )
+ {
+ pLinkManager->Remove( mpImpl->mpObjectLink );
+ mpImpl->mpObjectLink = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::CheckFileLink_Impl()
+{
+ if ( pModel && xObjRef.GetObject().is() && !mpImpl->mpObjectLink )
+ {
+ try
+ {
+ uno::Reference< embed::XLinkageSupport > xLinkSupport( xObjRef.GetObject(), uno::UNO_QUERY );
+ if ( xLinkSupport.is() && xLinkSupport->isLink() )
+ {
+ String aLinkURL = xLinkSupport->getLinkURL();
+ if ( aLinkURL.Len() )
+ {
+ // this is a file link so the model link manager should handle it
+ sfx2::LinkManager* pLinkManager = pModel->GetLinkManager();
+ if ( pLinkManager )
+ {
+ mpImpl->mpObjectLink = new SdrEmbedObjectLink( this );
+ mpImpl->maLinkURL = aLinkURL;
+ pLinkManager->InsertFileLink( *mpImpl->mpObjectLink, OBJECT_CLIENT_OLE, aLinkURL, NULL, NULL );
+ mpImpl->mpObjectLink->Connect();
+ }
+ }
+ }
+ }
+ catch( ::com::sun::star::uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR(
+ (OString("SdrOle2Obj::CheckFileLink_Impl(), "
+ "exception caught: ") +
+ rtl::OUStringToOString(
+ comphelper::anyToString( cppu::getCaughtException() ),
+ RTL_TEXTENCODING_UTF8 )).getStr() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::Reconnect_Impl()
+{
+ DBG_ASSERT( mpImpl->mbConnected, "Assigned unconnected object?!" );
+ Connect_Impl();
+}
+
+void SdrOle2Obj::Connect_Impl()
+{
+ if( pModel && mpImpl->aPersistName.Len() )
+ {
+ try
+ {
+ ::comphelper::IEmbeddedHelper* pPers = pModel->GetPersist();
+ if ( pPers )
+ {
+ comphelper::EmbeddedObjectContainer& rContainer = pPers->getEmbeddedObjectContainer();
+ if ( !rContainer.HasEmbeddedObject( mpImpl->aPersistName )
+ || ( xObjRef.is() && !rContainer.HasEmbeddedObject( xObjRef.GetObject() ) ) )
+ {
+ // object not known to container document
+ // No object -> disaster!
+ DBG_ASSERT( xObjRef.is(), "No object in connect!");
+ if ( xObjRef.is() )
+ {
+ // object came from the outside, now add it to the container
+ ::rtl::OUString aTmp;
+ rContainer.InsertEmbeddedObject( xObjRef.GetObject(), aTmp );
+ mpImpl->aPersistName = aTmp;
+ }
+ }
+ else if ( !xObjRef.is() )
+ {
+ xObjRef.Assign( rContainer.GetEmbeddedObject( mpImpl->aPersistName ), xObjRef.GetViewAspect() );
+ m_bTypeAsked = false;
+ }
+
+ if ( xObjRef.GetObject().is() )
+ {
+ xObjRef.AssignToContainer( &rContainer, mpImpl->aPersistName );
+ mpImpl->mbConnected = true;
+ xObjRef.Lock( TRUE );
+ }
+ }
+
+ if ( xObjRef.is() )
+ {
+ if ( !mpImpl->pLightClient )
+ {
+ mpImpl->pLightClient = new SdrLightEmbeddedClient_Impl( this );
+ mpImpl->pLightClient->acquire();
+ }
+
+ xObjRef->addStateChangeListener( mpImpl->pLightClient );
+ xObjRef->addEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
+
+ if ( xObjRef->getCurrentState() != embed::EmbedStates::LOADED )
+ GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
+
+ CheckFileLink_Impl();
+
+ uno::Reference< container::XChild > xChild( xObjRef.GetObject(), uno::UNO_QUERY );
+ if( xChild.is() )
+ {
+ uno::Reference< uno::XInterface > xParent( pModel->getUnoModel());
+ if( xParent.is())
+ xChild->setParent( pModel->getUnoModel() );
+ }
+
+ }
+ }
+ catch( ::com::sun::star::uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR(
+ (OString("SdrOle2Obj::Connect_Impl(), "
+ "exception caught: ") +
+ rtl::OUStringToOString(
+ comphelper::anyToString( cppu::getCaughtException() ),
+ RTL_TEXTENCODING_UTF8 )).getStr() );
+ }
+ }
+
+ //TODO/LATER: wait for definition of MiscStatus RESIZEONPRINTERCHANGE
+ //if ( xObjRef.is() && (*ppObjRef)->GetMiscStatus() & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE )
+ {
+ //TODO/LATER: needs a new handling for OnPrinterChanged
+ /*
+ if (pModel && pModel->GetRefDevice() &&
+ pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
+ {
+ // Kein RefDevice oder RefDevice kein Printer
+ BOOL bModified = (*ppObjRef)->IsModified();
+ Printer* pPrinter = (Printer*) pModel->GetRefDevice();
+ (*ppObjRef)->OnDocumentPrinterChanged( pPrinter );
+ (*ppObjRef)->SetModified( bModified );
+ }*/
+ }
+}
+
+void SdrOle2Obj::ObjectLoaded()
+{
+ AddListeners_Impl();
+}
+
+void SdrOle2Obj::AddListeners_Impl()
+{
+ if( xObjRef.is() && xObjRef->getCurrentState() != embed::EmbedStates::LOADED )
+ {
+ // register modify listener
+ if( !pModifyListener )
+ {
+ ((SdrOle2Obj*)this)->pModifyListener = new SvxUnoShapeModifyListener( (SdrOle2Obj*)this );
+ pModifyListener->acquire();
+ }
+
+ uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
+ if( xBC.is() && pModifyListener )
+ {
+ uno::Reference< util::XModifyListener > xListener( pModifyListener );
+ xBC->addModifyListener( xListener );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::Disconnect()
+{
+ if( IsEmptyPresObj() )
+ return;
+
+ if( !mpImpl->mbConnected )
+ {
+ DBG_ERROR("Disconnect() called on disconnected object!");
+ return;
+ }
+
+ RemoveListeners_Impl();
+ Disconnect_Impl();
+}
+
+void SdrOle2Obj::RemoveListeners_Impl()
+{
+ if( xObjRef.is() && mpImpl->aPersistName.Len() )
+ {
+ try
+ {
+ sal_Int32 nState = xObjRef->getCurrentState();
+ if ( nState != embed::EmbedStates::LOADED )
+ {
+ uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
+ if( xBC.is() && pModifyListener )
+ {
+ uno::Reference< util::XModifyListener > xListener( pModifyListener );
+ xBC->removeModifyListener( xListener );
+ }
+ }
+ }
+ catch( ::com::sun::star::uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR(
+ (OString("SdrOle2Obj::RemoveListeners_Impl(), "
+ "exception caught: ") +
+ rtl::OUStringToOString(
+ comphelper::anyToString( cppu::getCaughtException() ),
+ RTL_TEXTENCODING_UTF8 )).getStr() );
+ }
+ }
+}
+
+void SdrOle2Obj::Disconnect_Impl()
+{
+ try
+ {
+ if ( pModel && mpImpl->aPersistName.Len() )
+ {
+ if( pModel->IsInDestruction() )
+ {
+ // TODO/LATER: here we must assume that the destruction of the model is enough to make clear that we will not
+ // remove the object from the container, even if the DrawingObject itself is not destroyed (unfortunately this
+ // There is no real need to do the following removing of the object from the container
+ // in case the model has correct persistance, but in case of problems such a removing
+ // would make the behaviour of the office more stable
+
+ comphelper::EmbeddedObjectContainer* pContainer = xObjRef.GetContainer();
+ if ( pContainer )
+ {
+ pContainer->CloseEmbeddedObject( xObjRef.GetObject() );
+ xObjRef.AssignToContainer( NULL, mpImpl->aPersistName );
+ }
+
+ // happens later than the destruction of the model, so we can't assert that).
+ //DBG_ASSERT( bInDestruction, "Model is destroyed, but not me?!" );
+ //TODO/LATER: should be make sure that the ObjectShell also forgets the object, because we will close it soon?
+ /*
+ uno::Reference < util::XCloseable > xClose( xObjRef, uno::UNO_QUERY );
+ if ( xClose.is() )
+ {
+ try
+ {
+ xClose->close( sal_True );
+ }
+ catch ( util::CloseVetoException& )
+ {
+ // there's still someone who needs the object!
+ }
+ }
+
+ xObjRef = NULL;*/
+ }
+ else if ( xObjRef.is() )
+ {
+ if ( pModel->getUnoModel().is() )
+ {
+ // remove object, but don't close it (that's up to someone else)
+ comphelper::EmbeddedObjectContainer* pContainer = xObjRef.GetContainer();
+ if ( pContainer )
+ {
+ pContainer->RemoveEmbeddedObject( xObjRef.GetObject(), sal_False);
+
+ // TODO/LATER: mpImpl->aPersistName contains outdated information, to have it uptodate
+ // it should be returned from RemoveEmbeddedObject call. Currently it is no problem,
+ // since no container is adjusted, actually the empty string could be provided as a name here
+ xObjRef.AssignToContainer( NULL, mpImpl->aPersistName );
+ }
+
+ DisconnectFileLink_Impl();
+ }
+ }
+ }
+
+ if ( xObjRef.is() && mpImpl->pLightClient )
+ {
+ xObjRef->removeStateChangeListener ( mpImpl->pLightClient );
+ xObjRef->removeEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
+ xObjRef->setClientSite( NULL );
+
+ GetSdrGlobalData().GetOLEObjCache().RemoveObj(this);
+ }
+ }
+ catch( ::com::sun::star::uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR(
+ (OString("SdrOle2Obj::Disconnect_Impl(), "
+ "exception caught: ") +
+ rtl::OUStringToOString(
+ comphelper::anyToString( cppu::getCaughtException() ),
+ RTL_TEXTENCODING_UTF8 )).getStr() );
+ }
+
+ mpImpl->mbConnected = false;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::SetModel(SdrModel* pNewModel)
+{
+ ::comphelper::IEmbeddedHelper* pDestPers = pNewModel ? pNewModel->GetPersist() : 0;
+ ::comphelper::IEmbeddedHelper* pSrcPers = pModel ? pModel->GetPersist() : 0;
+
+ if ( pNewModel == pModel )
+ {
+ // don't know if this is necessary or if it will ever happen, but who know?!
+ SdrRectObj::SetModel( pNewModel );
+ return;
+ }
+
+ // assignment to model has changed
+ DBG_ASSERT( pSrcPers || !mpImpl->mbConnected, "Connected object without a model?!" );
+
+ DBG_ASSERT( pDestPers, "The destination model must have a persistence! Please submit an issue!" );
+ DBG_ASSERT( pDestPers != pSrcPers, "The source and the destination models should have different persistences! Problems are possible!" );
+
+ // this is a bug if the target model has no persistence
+ // no error handling is possible so just do nothing in this method
+ if ( !pDestPers )
+ return;
+
+ RemoveListeners_Impl();
+
+ if( pDestPers && pSrcPers && !IsEmptyPresObj() )
+ {
+ try
+ {
+ // move the objects' storage; ObjectRef remains the same, but PersistName may change
+ ::rtl::OUString aTmp;
+ comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
+ uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
+ DBG_ASSERT( !xObjRef.is() || xObjRef.GetObject() == xObj, "Wrong object identity!" );
+ if ( xObj.is() )
+ {
+ pDestPers->getEmbeddedObjectContainer().MoveEmbeddedObject( rContainer, xObj, aTmp );
+ mpImpl->aPersistName = aTmp;
+ xObjRef.AssignToContainer( &pDestPers->getEmbeddedObjectContainer(), aTmp );
+ }
+ DBG_ASSERT( aTmp.getLength(), "Copying embedded object failed!" );
+ }
+ catch( ::com::sun::star::uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR(
+ (OString("SdrOle2Obj::SetModel(), "
+ "exception caught: ") +
+ rtl::OUStringToOString(
+ comphelper::anyToString( cppu::getCaughtException() ),
+ RTL_TEXTENCODING_UTF8 )).getStr() );
+ }
+ }
+
+ SdrRectObj::SetModel( pNewModel );
+
+ // #i43086#
+ // #i85304 redo the change for charts for the above bugfix, as #i43086# does not ocur anymore
+ //so maybe the ImpSetVisAreaSize call can be removed here completely
+ //Nevertheless I leave it in for other objects as I am not sure about the side effects when removing now
+ if( pModel && !pModel->isLocked() && !IsChart() )
+ ImpSetVisAreaSize();
+
+ if( pDestPers && !IsEmptyPresObj() )
+ {
+ if ( !pSrcPers || IsEmptyPresObj() )
+ // object wasn't connected, now it should
+ Connect_Impl();
+ else
+ Reconnect_Impl();
+ }
+
+ AddListeners_Impl();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::SetPage(SdrPage* pNewPage)
+{
+ bool bRemove=pNewPage==NULL && pPage!=NULL;
+ bool bInsert=pNewPage!=NULL && pPage==NULL;
+
+ if (bRemove && mpImpl->mbConnected )
+ Disconnect();
+
+ SdrRectObj::SetPage(pNewPage);
+
+ if (bInsert && !mpImpl->mbConnected )
+ Connect();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::SetObjRef( const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >& rNewObjRef )
+{
+ DBG_ASSERT( !rNewObjRef.is() || !xObjRef.GetObject().is(), "SetObjRef called on already initialized object!");
+ if( rNewObjRef == xObjRef.GetObject() )
+ return;
+
+ // MBA: the caller of the method is responsible to control the old object, it will not be closed here
+ // Otherwise WW8 import crashes because it tranfers control to OLENode by this method
+ if ( xObjRef.GetObject().is() )
+ xObjRef.Lock( FALSE );
+
+ // MBA: avoid removal of object in Disconnect! It is definitely a HACK to call SetObjRef(0)!
+ // This call will try to close the objects; so if anybody else wants to keep it, it must be locked by a CloseListener
+ xObjRef.Clear();
+
+ if ( mpImpl->mbConnected )
+ Disconnect();
+
+ xObjRef.Assign( rNewObjRef, GetAspect() );
+ m_bTypeAsked = false;
+
+ if ( xObjRef.is() )
+ {
+ DELETEZ( pGraphic );
+
+ if ( (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
+ SetResizeProtect(TRUE);
+
+ // #108759# For math objects, set closed state to transparent
+ if( ImplIsMathObj( rNewObjRef ) )
+ SetClosedObj( false );
+
+ Connect();
+ }
+
+ SetChanged();
+ BroadcastObjectChange();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::SetClosedObj( bool bIsClosed )
+{
+ // TODO/LATER: do we still need this hack?
+ // #108759# Allow changes to the closed state of OLE objects
+ bClosedObj = bIsClosed;
+}
+
+// -----------------------------------------------------------------------------
+
+SdrObject* SdrOle2Obj::getFullDragClone() const
+{
+ // special handling for OLE. The default handling works, but is too
+ // slow when the whole OLE needs to be cloned. Get the Metafile and
+ // create a graphic object with it
+ Graphic* pOLEGraphic = GetGraphic();
+ SdrObject* pClone = 0;
+
+ if(Application::GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ pOLEGraphic = getEmbeddedObjectRef().GetHCGraphic();
+ }
+
+ if(pOLEGraphic)
+ {
+ pClone = new SdrGrafObj(*pOLEGraphic, GetSnapRect());
+
+ // this would be the place where to copy all attributes
+ // when OLE will support fill and line style
+ // pClone->SetMergedItem(pOleObject->GetMergedItemSet());
+ }
+ else
+ {
+ // #i100710# pOLEGraphic may be zero (no visualisation available),
+ // so we need to use the OLE replacement graphic
+ pClone = new SdrRectObj(GetSnapRect());
+
+ // gray outline
+ pClone->SetMergedItem(XLineStyleItem(XLINE_SOLID));
+ const svtools::ColorConfig aColorConfig;
+ const svtools::ColorConfigValue aColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES));
+ pClone->SetMergedItem(XLineColorItem(String(), aColor.nColor));
+
+ // bitmap fill
+ pClone->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
+ pClone->SetMergedItem(XFillBitmapItem(String(), GetEmtyOLEReplacementBitmap()));
+ pClone->SetMergedItem(XFillBmpTileItem(false));
+ pClone->SetMergedItem(XFillBmpStretchItem(false));
+ }
+
+ return pClone;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::SetPersistName( const String& rPersistName )
+{
+ DBG_ASSERT( !mpImpl->aPersistName.Len(), "Persist name changed!");
+
+ mpImpl->aPersistName = rPersistName;
+ mpImpl->mbLoadingOLEObjectFailed = false;
+
+ Connect();
+ SetChanged();
+}
+
+void SdrOle2Obj::AbandonObject()
+{
+ mpImpl->aPersistName.Erase();
+ mpImpl->mbLoadingOLEObjectFailed = false;
+ SetObjRef(0);
+}
+
+// -----------------------------------------------------------------------------
+
+String SdrOle2Obj::GetPersistName() const
+{
+ return mpImpl->aPersistName;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bRotateFreeAllowed=FALSE;
+ rInfo.bRotate90Allowed =FALSE;
+ rInfo.bMirrorFreeAllowed=FALSE;
+ rInfo.bMirror45Allowed =FALSE;
+ rInfo.bMirror90Allowed =FALSE;
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ rInfo.bShearAllowed =FALSE;
+ rInfo.bEdgeRadiusAllowed=FALSE;
+ rInfo.bNoOrthoDesired =FALSE;
+ rInfo.bCanConvToPath =FALSE;
+ rInfo.bCanConvToPoly =FALSE;
+ rInfo.bCanConvToPathLineToArea=FALSE;
+ rInfo.bCanConvToPolyLineToArea=FALSE;
+ rInfo.bCanConvToContour = FALSE;
+}
+
+// -----------------------------------------------------------------------------
+
+UINT16 SdrOle2Obj::GetObjIdentifier() const
+{
+ return bFrame ? UINT16(OBJ_FRAME) : UINT16(OBJ_OLE2);
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::TakeObjNameSingul(XubString& rName) const
+{
+ rName = ImpGetResStr(bFrame ? STR_ObjNameSingulFrame : STR_ObjNameSingulOLE2);
+
+ const String aName(GetName());
+
+ if( aName.Len() )
+ {
+ rName.AppendAscii(" '");
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(bFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::operator=(const SdrObject& rObj)
+{
+ //TODO/LATER: who takes over control of my old object?!
+ if( &rObj != this )
+ {
+ // #116235#
+ // ImpAssign( rObj );
+ const SdrOle2Obj& rOle2Obj = static_cast< const SdrOle2Obj& >( rObj );
+
+ uno::Reference < util::XCloseable > xClose( xObjRef.GetObject(), uno::UNO_QUERY );
+
+ if( pModel && mpImpl->mbConnected )
+ Disconnect();
+
+ SdrRectObj::operator=( rObj );
+
+ // #108867# Manually copying bClosedObj attribute
+ SetClosedObj( rObj.IsClosedObj() );
+
+ mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName;
+ aProgName = rOle2Obj.aProgName;
+ bFrame = rOle2Obj.bFrame;
+
+ if( rOle2Obj.pGraphic )
+ {
+ if( pGraphic )
+ {
+ delete pGraphic;
+ delete mpImpl->pGraphicObject;
+ }
+
+ pGraphic = new Graphic( *rOle2Obj.pGraphic );
+ mpImpl->pGraphicObject = new GraphicObject( *pGraphic );
+ }
+
+ if( pModel && rObj.GetModel() && !IsEmptyPresObj() )
+ {
+ ::comphelper::IEmbeddedHelper* pDestPers = pModel->GetPersist();
+ ::comphelper::IEmbeddedHelper* pSrcPers = rObj.GetModel()->GetPersist();
+ if( pDestPers && pSrcPers )
+ {
+ DBG_ASSERT( !xObjRef.is(), "Object already existing!" );
+ comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
+ uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
+ if ( xObj.is() )
+ {
+ ::rtl::OUString aTmp;
+ xObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject( rContainer, xObj, aTmp ), rOle2Obj.GetAspect() );
+ m_bTypeAsked = false;
+ mpImpl->aPersistName = aTmp;
+ CheckFileLink_Impl();
+ }
+
+ Connect();
+
+ /* only needed for MSOLE-Objects, now handled inside implementation of Object
+ if ( xObjRef.is() && rOle2Obj.xObjRef.is() && rOle2Obj.GetAspect() != embed::Aspects::MSOLE_ICON )
+ {
+ try
+ {
+ awt::Size aVisSize = rOle2Obj.xObjRef->getVisualAreaSize( rOle2Obj.GetAspect() );
+ if( rOle2Obj.xObjRef->getMapUnit( rOle2Obj.GetAspect() ) == xObjRef->getMapUnit( GetAspect() ) )
+ xObjRef->setVisualAreaSize( GetAspect(), aVisSize );
+ }
+ catch ( embed::WrongStateException& )
+ {
+ // setting of VisArea not necessary for objects that don't cache it in loaded state
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {
+ // objects my not have visual areas
+ }
+ catch( uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR( "SdrOle2Obj::operator=(), unexcpected exception caught!" );
+ }
+ } */
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::ImpSetVisAreaSize()
+{
+ // currently there is no need to recalculate scaling for iconified objects
+ // TODO/LATER: it might be needed in future when it is possible to change the icon
+ if ( GetAspect() == embed::Aspects::MSOLE_ICON )
+ return;
+
+ // the object area of an embedded object was changed, e.g. by user interaction an a selected object
+ GetObjRef();
+ if ( xObjRef.is() )
+ {
+ OSL_ASSERT( pModel );
+ sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
+
+ // the client is required to get access to scaling
+ SfxInPlaceClient* pClient = SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), xObjRef.GetObject() );
+ sal_Bool bHasOwnClient =
+ ( mpImpl->pLightClient
+ && xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) );
+
+ if ( pClient || bHasOwnClient )
+ {
+ // TODO/LATER: IMHO we need to do similar things when object is UIActive or OutplaceActive?! (MBA)
+ if ( ((nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
+ svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() ))
+ || xObjRef->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE
+ )
+ {
+ Fraction aScaleWidth;
+ Fraction aScaleHeight;
+ if ( pClient )
+ {
+ aScaleWidth = pClient->GetScaleWidth();
+ aScaleHeight = pClient->GetScaleHeight();
+ }
+ else
+ {
+ aScaleWidth = mpImpl->pLightClient->GetScaleWidth();
+ aScaleHeight = mpImpl->pLightClient->GetScaleHeight();
+ }
+
+ // The object wants to resize itself (f.e. Chart wants to recalculate the layout)
+ // or object is inplace active and so has a window that must be resized also
+ // In these cases the change in the object area size will be reflected in a change of the
+ // objects' visual area. The scaling will not change, but it might exist already and must
+ // be used in calculations
+ MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
+ Size aVisSize( (long)( Fraction( aRect.GetWidth() ) / aScaleWidth ),
+ (long)( Fraction( aRect.GetHeight() ) / aScaleHeight ) );
+
+ aVisSize = OutputDevice::LogicToLogic( aVisSize, pModel->GetScaleUnit(), aMapUnit);
+ awt::Size aSz;
+ aSz.Width = aVisSize.Width();
+ aSz.Height = aVisSize.Height();
+ xObjRef->setVisualAreaSize( GetAspect(), aSz );
+
+ try
+ {
+ aSz = xObjRef->getVisualAreaSize( GetAspect() );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {}
+
+ Rectangle aAcceptedVisArea;
+ aAcceptedVisArea.SetSize( Size( (long)( Fraction( long( aSz.Width ) ) * aScaleWidth ),
+ (long)( Fraction( long( aSz.Height ) ) * aScaleHeight ) ) );
+ if (aVisSize != aAcceptedVisArea.GetSize())
+ {
+ // server changed VisArea to its liking and the VisArea is different than the suggested one
+ // store the new value as given by the object
+ MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
+ aRect.SetSize(OutputDevice::LogicToLogic( aAcceptedVisArea.GetSize(), aNewMapUnit, pModel->GetScaleUnit()));
+ }
+
+ // make the new object area known to the client
+ // compared to the "else" branch aRect might have been changed by the object and no additional scaling was applied
+ // OJ: WHY this -> OSL_ASSERT( pClient );
+ if( pClient )
+ pClient->SetObjArea(aRect);
+
+ // we need a new replacement image as the object has resized itself
+
+ //#i79578# don't request a new replacement image for charts to often
+ //a chart sends a modified call to the framework if it was changed
+ //thus the replacement update is already handled there
+ if( !IsChart() )
+ xObjRef.UpdateReplacement();
+ }
+ else
+ {
+ // The object isn't active and does not want to resize itself so the changed object area size
+ // will be reflected in a changed object scaling
+ Fraction aScaleWidth;
+ Fraction aScaleHeight;
+ Size aObjAreaSize;
+ if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
+ {
+ if ( pClient )
+ {
+ Rectangle aScaleRect(aRect.TopLeft(), aObjAreaSize);
+ pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight);
+ }
+ else
+ {
+ mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
+ }
+ }
+ }
+ }
+ else if( (nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
+ svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() ) )
+ {
+ //also handle not sfx based ole objects e.g. charts
+ //#i83860# resizing charts in impress distorts fonts
+ uno::Reference< embed::XVisualObject > xVisualObject( this->getXModel(), uno::UNO_QUERY );
+ if( xVisualObject.is() )
+ {
+ MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
+ Point aTL( aRect.TopLeft() );
+ Point aBR( aRect.BottomRight() );
+ Point aTL2( OutputDevice::LogicToLogic( aTL, pModel->GetScaleUnit(), aMapUnit) );
+ Point aBR2( OutputDevice::LogicToLogic( aBR, pModel->GetScaleUnit(), aMapUnit) );
+ Rectangle aNewRect( aTL2, aBR2 );
+ xVisualObject->setVisualAreaSize( GetAspect(), awt::Size( aNewRect.GetWidth(), aNewRect.GetHeight() ) );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ if( pModel && !pModel->isLocked() )
+ {
+ GetObjRef();
+ if ( xObjRef.is() && ( xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
+ {
+ // if the object needs recompose on resize
+ // the client site should be created before the resize will take place
+ // check whether there is no client site and create it if necessary
+ AddOwnLightClient();
+ }
+ }
+
+ SdrRectObj::NbcResize(rRef,xFact,yFact);
+ if (aGeo.nShearWink!=0 || aGeo.nDrehWink!=0) { // kleine Korrekturen
+ if (aGeo.nDrehWink>=9000 && aGeo.nDrehWink<27000) {
+ aRect.Move(aRect.Left()-aRect.Right(),aRect.Top()-aRect.Bottom());
+ }
+ aGeo.nDrehWink=0;
+ aGeo.nShearWink=0;
+ aGeo.nSin=0.0;
+ aGeo.nCos=1.0;
+ aGeo.nTan=0.0;
+ SetRectsDirty();
+ }
+ if( pModel && !pModel->isLocked() )
+ ImpSetVisAreaSize();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::SetGeoData(const SdrObjGeoData& rGeo)
+{
+ SdrRectObj::SetGeoData(rGeo);
+ if( pModel && !pModel->isLocked() )
+ ImpSetVisAreaSize();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::NbcSetSnapRect(const Rectangle& rRect)
+{
+ SdrRectObj::NbcSetSnapRect(rRect);
+ if( pModel && !pModel->isLocked() )
+ ImpSetVisAreaSize();
+
+ if ( xObjRef.is() && IsChart() )
+ {
+ //#i103460# charts do not necessaryly have an own size within ODF files,
+ //for this case they need to use the size settings from the surrounding frame,
+ //which is made available with this method as there is no other way
+ xObjRef.SetDefaultSizeForChart( Size( rRect.GetWidth(), rRect.GetHeight() ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::NbcSetLogicRect(const Rectangle& rRect)
+{
+ SdrRectObj::NbcSetLogicRect(rRect);
+ if( pModel && !pModel->isLocked() )
+ ImpSetVisAreaSize();
+}
+
+Graphic* SdrOle2Obj::GetGraphic() const
+{
+ if ( xObjRef.is() )
+ return xObjRef.GetGraphic();
+ return pGraphic;
+}
+
+void SdrOle2Obj::GetNewReplacement()
+{
+ if ( xObjRef.is() )
+ xObjRef.UpdateReplacement();
+}
+
+// -----------------------------------------------------------------------------
+
+Size SdrOle2Obj::GetOrigObjSize( MapMode* pTargetMapMode ) const
+{
+ return xObjRef.GetSize( pTargetMapMode );
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::NbcMove(const Size& rSize)
+{
+ SdrRectObj::NbcMove(rSize);
+ if( pModel && !pModel->isLocked() )
+ ImpSetVisAreaSize();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SdrOle2Obj::CanUnloadRunningObj( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
+{
+ sal_Bool bResult = sal_False;
+
+ sal_Int32 nState = xObj->getCurrentState();
+ if ( nState == embed::EmbedStates::LOADED )
+ {
+ // the object is already unloaded
+ bResult = sal_True;
+ }
+ else
+ {
+ uno::Reference < util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
+ if ( !xModifiable.is() )
+ bResult = sal_True;
+ else
+ {
+ sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
+
+ if ( embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
+ embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) &&
+ !( xModifiable.is() && xModifiable->isModified() ) &&
+ !( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::ACTIVE ) )
+ {
+ bResult = sal_True;
+ }
+ }
+ }
+
+ return bResult;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SdrOle2Obj::Unload( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
+{
+ sal_Bool bResult = sal_False;
+
+ if ( CanUnloadRunningObj( xObj, nAspect ) )
+ {
+ try
+ {
+ xObj->changeState( embed::EmbedStates::LOADED );
+ bResult = sal_True;
+ }
+ catch( ::com::sun::star::uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR(
+ (OString("SdrOle2Obj::Unload=(), "
+ "exception caught: ") +
+ rtl::OUStringToOString(
+ comphelper::anyToString( cppu::getCaughtException() ),
+ RTL_TEXTENCODING_UTF8 )).getStr() );
+ }
+ }
+
+ return bResult;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL SdrOle2Obj::Unload()
+{
+ BOOL bUnloaded = FALSE;
+
+ if( xObjRef.is() )
+ {
+ //TODO/LATER: no refcounting tricks anymore!
+ //"customers" must register as state change listeners
+ //Nicht notwendig im Doc DTor (MM)
+ //ULONG nRefCount = (*ppObjRef)->GetRefCount();
+ // prevent Unload if there are external references
+ //if( nRefCount > 2 )
+ // return FALSE;
+ //DBG_ASSERT( nRefCount == 2, "Wrong RefCount for unload" );
+ }
+ else
+ bUnloaded = TRUE;
+
+ if ( pModel && xObjRef.is() )
+ {
+ bUnloaded = Unload( xObjRef.GetObject(), GetAspect() );
+ }
+
+ return bUnloaded;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrOle2Obj::GetObjRef_Impl()
+{
+ if ( !xObjRef.is() && mpImpl->aPersistName.Len() && pModel && pModel->GetPersist() )
+ {
+ // #107645#
+ // Only try loading if it did not went wrong up to now
+ if(!mpImpl->mbLoadingOLEObjectFailed)
+ {
+ xObjRef.Assign( pModel->GetPersist()->getEmbeddedObjectContainer().GetEmbeddedObject( mpImpl->aPersistName ), GetAspect() );
+ m_bTypeAsked = false;
+ CheckFileLink_Impl();
+
+ // #107645#
+ // If loading of OLE object failed, remember that to not invoke a endless
+ // loop trying to load it again and again.
+ if( xObjRef.is() )
+ {
+ mpImpl->mbLoadingOLEObjectFailed = sal_True;
+ }
+
+ // #108759# For math objects, set closed state to transparent
+ if( ImplIsMathObj( xObjRef.GetObject() ) )
+ SetClosedObj( false );
+ }
+
+ if ( xObjRef.is() )
+ {
+ if( !IsEmptyPresObj() )
+ {
+ // #75637# remember modified status of model
+ const sal_Bool bWasChanged(pModel ? pModel->IsChanged() : sal_False);
+
+ // perhaps preview not valid anymore
+ // #75637# This line changes the modified state of the model
+ SetGraphic_Impl( NULL );
+
+ // #75637# if status was not set before, force it back
+ // to not set, so that SetGraphic(0L) above does not
+ // set the modified state of the model.
+ if(!bWasChanged && pModel && pModel->IsChanged())
+ {
+ pModel->SetChanged( sal_False );
+ }
+ }
+
+ sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
+ (void)nMiscStatus;
+ //TODO/LATER: wait until ResizeOnPrinterChange is defined
+ //if ( nMiscStatus & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE )
+ {
+ if (pModel && pModel->GetRefDevice() &&
+ pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
+ {
+ if(!bInDestruction)
+ {
+ //TODO/LATER: printerchange notification
+ /*
+ // prevent SetModified (don't want no update here)
+ sal_Bool bWasEnabled = (*ppObjRef)->IsEnableSetModified();
+ if ( bWasEnabled )
+ (*ppObjRef)->EnableSetModified( sal_False );
+
+ // Kein RefDevice oder RefDevice kein Printer
+ Printer* pPrinter = (Printer*) pModel->GetRefDevice();
+ (*ppObjRef)->OnDocumentPrinterChanged( pPrinter );
+
+ // reset state
+ (*ppObjRef)->EnableSetModified( bWasEnabled );*/
+ }
+ }
+ }
+ }
+
+ if ( xObjRef.is() )
+ Connect();
+ }
+
+ if ( mpImpl->mbConnected )
+ // move object to first position in cache
+ GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
+}
+
+uno::Reference < embed::XEmbeddedObject > SdrOle2Obj::GetObjRef() const
+{
+ const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
+ return xObjRef.GetObject();
+}
+
+uno::Reference < embed::XEmbeddedObject > SdrOle2Obj::GetObjRef_NoInit() const
+{
+ return xObjRef.GetObject();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< frame::XModel > SdrOle2Obj::getXModel() const
+{
+ GetObjRef();
+ if ( svt::EmbeddedObjectRef::TryRunningState(xObjRef.GetObject()) )
+ return uno::Reference< frame::XModel >( xObjRef->getComponent(), uno::UNO_QUERY );
+ else
+ return uno::Reference< frame::XModel >();
+}
+
+// -----------------------------------------------------------------------------
+
+// #109985#
+sal_Bool SdrOle2Obj::IsChart() const
+{
+ if ( !m_bTypeAsked )
+ {
+ m_bChart = ChartPrettyPainter::IsChart(xObjRef);
+ m_bTypeAsked = true;
+ }
+ return m_bChart;
+}
+
+// -----------------------------------------------------------------------------
+void SdrOle2Obj::SetGraphicToObj( const Graphic& aGraphic, const ::rtl::OUString& aMediaType )
+{
+ xObjRef.SetGraphic( aGraphic, aMediaType );
+}
+
+// -----------------------------------------------------------------------------
+void SdrOle2Obj::SetGraphicToObj( const uno::Reference< io::XInputStream >& xGrStream, const ::rtl::OUString& aMediaType )
+{
+ xObjRef.SetGraphicStream( xGrStream, aMediaType );
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SdrOle2Obj::IsCalc() const
+{
+ if ( !xObjRef.is() )
+ return false;
+
+ SvGlobalName aObjClsId( xObjRef->getClassID() );
+ if( SvGlobalName(SO3_SC_CLASSID_30) == aObjClsId
+ || SvGlobalName(SO3_SC_CLASSID_40) == aObjClsId
+ || SvGlobalName(SO3_SC_CLASSID_50) == aObjClsId
+ || SvGlobalName(SO3_SC_CLASSID_60) == aObjClsId
+ || SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_60) == aObjClsId
+ || SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_8) == aObjClsId
+ || SvGlobalName(SO3_SC_CLASSID) == aObjClsId )
+ {
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel() const
+{
+ uno::Reference< frame::XModel > xDoc;
+ if ( pModel )
+ xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
+ return xDoc;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize )
+{
+ // TODO/LEAN: to avoid rounding errors scaling always uses the VisArea.
+ // If we don't cache it for own objects also we must load the object here
+ if ( !xObjRef.is() || !pModel )
+ return sal_False;
+
+ MapMode aMapMode( pModel->GetScaleUnit() );
+ aObjAreaSize = xObjRef.GetSize( &aMapMode );
+
+ Size aSize = aRect.GetSize();
+ aScaleWidth = Fraction(aSize.Width(), aObjAreaSize.Width() );
+ aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() );
+
+ // reduce to 10 binary digits
+ Kuerzen(aScaleHeight, 10);
+ Kuerzen(aScaleWidth, 10);
+
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+sal_Bool SdrOle2Obj::AddOwnLightClient()
+{
+ // The Own Light Client must be registered in object only using this method!
+ if ( !SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), xObjRef.GetObject() )
+ && !( mpImpl->pLightClient && xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) ) )
+ {
+ Connect();
+
+ if ( xObjRef.is() && mpImpl->pLightClient )
+ {
+ Fraction aScaleWidth;
+ Fraction aScaleHeight;
+ Size aObjAreaSize;
+ if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
+ {
+ mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
+ try {
+ xObjRef->setClientSite( mpImpl->pLightClient );
+ return sal_True;
+ } catch( uno::Exception& )
+ {}
+ }
+
+ }
+
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+Bitmap SdrOle2Obj::GetEmtyOLEReplacementBitmap()
+{
+ return Bitmap(ResId(BMP_SVXOLEOBJ, *ImpGetResMgr()));
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+void SdrOle2Obj::SetWindow(const com::sun::star::uno::Reference < com::sun::star::awt::XWindow >& _xWindow)
+{
+ if ( xObjRef.is() && mpImpl->pLightClient )
+ {
+ mpImpl->pLightClient->setWindow(_xWindow);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx
new file mode 100644
index 000000000000..81ffba500fe4
--- /dev/null
+++ b/svx/source/svdraw/svdopage.cxx
@@ -0,0 +1,198 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdopage.hxx>
+#include "svdglob.hxx" // Stringcache
+#include "svdstr.hrc" // Objektname
+#include <svx/svdtrans.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdoutl.hxx>
+#include <svtools/colorcfg.hxx>
+#include <svl/itemset.hxx>
+#include <svx/sdr/properties/pageproperties.hxx>
+
+// #111111#
+#include <svx/sdr/contact/viewcontactofpageobj.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrPageObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::PageProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// DrawContact section
+
+sdr::contact::ViewContact* SdrPageObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfPageObj(*this);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// this method is called form the destructor of the referenced page.
+// do all necessary action to forget the page. It is not necessary to call
+// RemovePageUser(), that is done form the destructor.
+void SdrPageObj::PageInDestruction(const SdrPage& rPage)
+{
+ if(mpShownPage && mpShownPage == &rPage)
+ {
+ // #i58769# Do not call ActionChanged() here, because that would
+ // lead to the construction of a view contact object for a page that
+ // is being destroyed.
+
+ mpShownPage = 0L;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrPageObj,SdrObject);
+
+SdrPageObj::SdrPageObj(SdrPage* pNewPage)
+: mpShownPage(pNewPage)
+{
+ if(mpShownPage)
+ {
+ mpShownPage->AddPageUser(*this);
+ }
+}
+
+SdrPageObj::SdrPageObj(const Rectangle& rRect, SdrPage* pNewPage)
+: mpShownPage(pNewPage)
+{
+ if(mpShownPage)
+ {
+ mpShownPage->AddPageUser(*this);
+ }
+
+ aOutRect = rRect;
+}
+
+SdrPageObj::~SdrPageObj()
+{
+ // #111111#
+ if(mpShownPage)
+ {
+ mpShownPage->RemovePageUser(*this);
+ }
+}
+
+// #111111#
+SdrPage* SdrPageObj::GetReferencedPage() const
+{
+ return mpShownPage;
+}
+
+// #111111#
+void SdrPageObj::SetReferencedPage(SdrPage* pNewPage)
+{
+ if(mpShownPage != pNewPage)
+ {
+ if(mpShownPage)
+ {
+ mpShownPage->RemovePageUser(*this);
+ }
+
+ mpShownPage = pNewPage;
+
+ if(mpShownPage)
+ {
+ mpShownPage->AddPageUser(*this);
+ }
+
+ SetChanged();
+ BroadcastObjectChange();
+ }
+}
+
+// #i96598#
+void SdrPageObj::SetBoundRectDirty()
+{
+ // avoid resetting aOutRect which in case of this object is model data,
+ // not re-creatable view data
+}
+
+UINT16 SdrPageObj::GetObjIdentifier() const
+{
+ return UINT16(OBJ_PAGE);
+}
+
+void SdrPageObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bRotateFreeAllowed=FALSE;
+ rInfo.bRotate90Allowed =FALSE;
+ rInfo.bMirrorFreeAllowed=FALSE;
+ rInfo.bMirror45Allowed =FALSE;
+ rInfo.bMirror90Allowed =FALSE;
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ rInfo.bShearAllowed =FALSE;
+ rInfo.bEdgeRadiusAllowed=FALSE;
+ rInfo.bNoOrthoDesired =FALSE;
+ rInfo.bCanConvToPath =FALSE;
+ rInfo.bCanConvToPoly =FALSE;
+ rInfo.bCanConvToPathLineToArea=FALSE;
+ rInfo.bCanConvToPolyLineToArea=FALSE;
+}
+
+void SdrPageObj::operator=(const SdrObject& rObj)
+{
+ SdrObject::operator=(rObj);
+ SetReferencedPage(((const SdrPageObj&)rObj).GetReferencedPage());
+}
+
+void SdrPageObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNameSingulPAGE);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+void SdrPageObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName=ImpGetResStr(STR_ObjNamePluralPAGE);
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
new file mode 100644
index 000000000000..23e408487747
--- /dev/null
+++ b/svx/source/svdraw/svdopath.cxx
@@ -0,0 +1,3121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <tools/bigint.hxx>
+#include <svx/svdopath.hxx>
+#include <math.h>
+#include <svx/xpool.hxx>
+#include <svx/xpoly.hxx>
+#include <svx/svdattr.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svddrag.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdhdl.hxx>
+#include <svx/svdview.hxx> // fuer MovCreate bei Freihandlinien
+#include "svdglob.hxx" // Stringcache
+#include "svdstr.hrc" // Objektname
+
+#ifdef _MSC_VER
+#pragma optimize ("",off)
+#pragma warning(disable: 4748) // "... because optimizations are disabled ..."
+#endif
+
+#include <svx/xlnwtit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/polypolygoneditor.hxx>
+#include <svx/xlntrit.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include "svdoimp.hxx"
+#include <svx/sdr/contact/viewcontactofsdrpathobj.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+
+// #104018# replace macros above with type-safe methods
+inline sal_Int32 ImplTwipsToMM(sal_Int32 nVal) { return ((nVal * 127 + 36) / 72); }
+inline sal_Int32 ImplMMToTwips(sal_Int32 nVal) { return ((nVal * 72 + 63) / 127); }
+inline sal_Int64 ImplTwipsToMM(sal_Int64 nVal) { return ((nVal * 127 + 36) / 72); }
+inline sal_Int64 ImplMMToTwips(sal_Int64 nVal) { return ((nVal * 72 + 63) / 127); }
+inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
+inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/curve/b2dcubicbezier.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/attribute/sdrtextattribute.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <svx/sdr/attribute/sdrformtextattribute.hxx>
+
+using namespace sdr;
+
+inline USHORT GetPrevPnt(USHORT nPnt, USHORT nPntMax, bool bClosed)
+{
+ if (nPnt>0) {
+ nPnt--;
+ } else {
+ nPnt=nPntMax;
+ if (bClosed) nPnt--;
+ }
+ return nPnt;
+}
+
+inline USHORT GetNextPnt(USHORT nPnt, USHORT nPntMax, bool bClosed)
+{
+ nPnt++;
+ if (nPnt>nPntMax || (bClosed && nPnt>=nPntMax)) nPnt=0;
+ return nPnt;
+}
+
+struct ImpSdrPathDragData : public SdrDragStatUserData
+{
+ XPolygon aXP; // Ausschnitt aud dem Originalpolygon
+ bool bValid; // FALSE = zu wenig Punkte
+ bool bClosed; // geschlossenes Objekt?
+ USHORT nPoly; // Nummer des Polygons im PolyPolygon
+ USHORT nPnt; // Punktnummer innerhalb des obigen Polygons
+ USHORT nPntAnz; // Punktanzahl des Polygons
+ USHORT nPntMax; // Maximaler Index
+ bool bBegPnt; // Gedraggter Punkt ist der Anfangspunkt einer Polyline
+ bool bEndPnt; // Gedraggter Punkt ist der Endpunkt einer Polyline
+ USHORT nPrevPnt; // Index des vorherigen Punkts
+ USHORT nNextPnt; // Index des naechsten Punkts
+ bool bPrevIsBegPnt; // Vorheriger Punkt ist Anfangspunkt einer Polyline
+ bool bNextIsEndPnt; // Folgepunkt ist Endpunkt einer Polyline
+ USHORT nPrevPrevPnt; // Index des vorvorherigen Punkts
+ USHORT nNextNextPnt; // Index des uebernaechsten Punkts
+ bool bControl; // Punkt ist ein Kontrollpunkt
+ bool bIsPrevControl; // Punkt ist Kontrollpunkt vor einem Stuetzpunkt
+ bool bIsNextControl; // Punkt ist Kontrollpunkt hinter einem Stuetzpunkt
+ bool bPrevIsControl; // Falls nPnt ein StPnt: Davor ist ein Kontrollpunkt
+ bool bNextIsControl; // Falls nPnt ein StPnt: Dahinter ist ein Kontrollpunkt
+ USHORT nPrevPrevPnt0;
+ USHORT nPrevPnt0;
+ USHORT nPnt0;
+ USHORT nNextPnt0;
+ USHORT nNextNextPnt0;
+ bool bEliminate; // Punkt loeschen? (wird von MovDrag gesetzt)
+
+ // ##
+ BOOL mbMultiPointDrag;
+ const XPolyPolygon maOrig;
+ XPolyPolygon maMove;
+ Container maHandles;
+
+public:
+ ImpSdrPathDragData(const SdrPathObj& rPO, const SdrHdl& rHdl, BOOL bMuPoDr, const SdrDragStat& rDrag);
+ void ResetPoly(const SdrPathObj& rPO);
+ BOOL IsMultiPointDrag() const { return mbMultiPointDrag; }
+};
+
+ImpSdrPathDragData::ImpSdrPathDragData(const SdrPathObj& rPO, const SdrHdl& rHdl, BOOL bMuPoDr, const SdrDragStat& rDrag)
+: aXP(5),
+ mbMultiPointDrag(bMuPoDr),
+ maOrig(rPO.GetPathPoly()),
+ maHandles(0)
+{
+ if(mbMultiPointDrag)
+ {
+ const SdrMarkView& rMarkView = *rDrag.GetView();
+ const SdrHdlList& rHdlList = rMarkView.GetHdlList();
+ const sal_uInt32 nHdlCount = rHdlList.GetHdlCount();
+ const SdrObject* pInteractionObject(nHdlCount && rHdlList.GetHdl(0) ? rHdlList.GetHdl(0)->GetObj() : 0);
+
+ for(sal_uInt32 a(0); a < nHdlCount; a++)
+ {
+ SdrHdl* pTestHdl = rHdlList.GetHdl(a);
+
+ if(pTestHdl && pTestHdl->IsSelected() && pTestHdl->GetObj() == pInteractionObject)
+ {
+ maHandles.Insert(pTestHdl, CONTAINER_APPEND);
+ }
+ }
+
+ maMove = maOrig;
+ bValid = TRUE;
+ }
+ else
+ {
+ bValid=FALSE;
+ bClosed=rPO.IsClosed(); // geschlossenes Objekt?
+ nPoly=(sal_uInt16)rHdl.GetPolyNum(); // Nummer des Polygons im PolyPolygon
+ nPnt=(sal_uInt16)rHdl.GetPointNum(); // Punktnummer innerhalb des obigen Polygons
+ const XPolygon aTmpXP(rPO.GetPathPoly().getB2DPolygon(nPoly));
+ nPntAnz=aTmpXP.GetPointCount(); // Punktanzahl des Polygons
+ if (nPntAnz==0 || (bClosed && nPntAnz==1)) return; // min. 1Pt bei Line, min. 2 bei Polygon
+ nPntMax=nPntAnz-1; // Maximaler Index
+ bBegPnt=!bClosed && nPnt==0; // Gedraggter Punkt ist der Anfangspunkt einer Polyline
+ bEndPnt=!bClosed && nPnt==nPntMax; // Gedraggter Punkt ist der Endpunkt einer Polyline
+ if (bClosed && nPntAnz<=3) { // Falls Polygon auch nur eine Linie ist
+ bBegPnt=(nPntAnz<3) || nPnt==0;
+ bEndPnt=(nPntAnz<3) || nPnt==nPntMax-1;
+ }
+ nPrevPnt=nPnt; // Index des vorherigen Punkts
+ nNextPnt=nPnt; // Index des naechsten Punkts
+ if (!bBegPnt) nPrevPnt=GetPrevPnt(nPnt,nPntMax,bClosed);
+ if (!bEndPnt) nNextPnt=GetNextPnt(nPnt,nPntMax,bClosed);
+ bPrevIsBegPnt=bBegPnt || (!bClosed && nPrevPnt==0);
+ bNextIsEndPnt=bEndPnt || (!bClosed && nNextPnt==nPntMax);
+ nPrevPrevPnt=nPnt; // Index des vorvorherigen Punkts
+ nNextNextPnt=nPnt; // Index des uebernaechsten Punkts
+ if (!bPrevIsBegPnt) nPrevPrevPnt=GetPrevPnt(nPrevPnt,nPntMax,bClosed);
+ if (!bNextIsEndPnt) nNextNextPnt=GetNextPnt(nNextPnt,nPntMax,bClosed);
+ bControl=rHdl.IsPlusHdl(); // Punkt ist ein Kontrollpunkt
+ bIsPrevControl=FALSE; // Punkt ist Kontrollpunkt vor einem Stuetzpunkt
+ bIsNextControl=FALSE; // Punkt ist Kontrollpunkt hinter einem Stuetzpunkt
+ bPrevIsControl=FALSE; // Falls nPnt ein StPnt: Davor ist ein Kontrollpunkt
+ bNextIsControl=FALSE; // Falls nPnt ein StPnt: Dahinter ist ein Kontrollpunkt
+ if (bControl) {
+ bIsPrevControl=aTmpXP.IsControl(nPrevPnt);
+ bIsNextControl=!bIsPrevControl;
+ } else {
+ bPrevIsControl=!bBegPnt && !bPrevIsBegPnt && aTmpXP.GetFlags(nPrevPnt)==XPOLY_CONTROL;
+ bNextIsControl=!bEndPnt && !bNextIsEndPnt && aTmpXP.GetFlags(nNextPnt)==XPOLY_CONTROL;
+ }
+ nPrevPrevPnt0=nPrevPrevPnt;
+ nPrevPnt0 =nPrevPnt;
+ nPnt0 =nPnt;
+ nNextPnt0 =nNextPnt;
+ nNextNextPnt0=nNextNextPnt;
+ nPrevPrevPnt=0;
+ nPrevPnt=1;
+ nPnt=2;
+ nNextPnt=3;
+ nNextNextPnt=4;
+ bEliminate=FALSE;
+ ResetPoly(rPO);
+ bValid=TRUE;
+ }
+}
+
+void ImpSdrPathDragData::ResetPoly(const SdrPathObj& rPO)
+{
+ const XPolygon aTmpXP(rPO.GetPathPoly().getB2DPolygon(nPoly));
+ aXP[0]=aTmpXP[nPrevPrevPnt0]; aXP.SetFlags(0,aTmpXP.GetFlags(nPrevPrevPnt0));
+ aXP[1]=aTmpXP[nPrevPnt0]; aXP.SetFlags(1,aTmpXP.GetFlags(nPrevPnt0));
+ aXP[2]=aTmpXP[nPnt0]; aXP.SetFlags(2,aTmpXP.GetFlags(nPnt0));
+ aXP[3]=aTmpXP[nNextPnt0]; aXP.SetFlags(3,aTmpXP.GetFlags(nNextPnt0));
+ aXP[4]=aTmpXP[nNextNextPnt0]; aXP.SetFlags(4,aTmpXP.GetFlags(nNextNextPnt0));
+}
+
+/*************************************************************************/
+
+struct ImpPathCreateUser : public SdrDragStatUserData
+{
+ Point aBezControl0;
+ Point aBezStart;
+ Point aBezCtrl1;
+ Point aBezCtrl2;
+ Point aBezEnd;
+ Point aCircStart;
+ Point aCircEnd;
+ Point aCircCenter;
+ Point aLineStart;
+ Point aLineEnd;
+ Point aRectP1;
+ Point aRectP2;
+ Point aRectP3;
+ long nCircRadius;
+ long nCircStWink;
+ long nCircRelWink;
+ bool bBezier;
+ bool bBezHasCtrl0;
+ bool bCurve;
+ bool bCircle;
+ bool bAngleSnap;
+ bool bLine;
+ bool bLine90;
+ bool bRect;
+ bool bMixedCreate;
+ USHORT nBezierStartPoint;
+ SdrObjKind eStartKind;
+ SdrObjKind eAktKind;
+
+public:
+ ImpPathCreateUser(): nCircRadius(0),nCircStWink(0),nCircRelWink(0),
+ bBezier(FALSE),bBezHasCtrl0(FALSE),bCurve(FALSE),bCircle(FALSE),bAngleSnap(FALSE),bLine(FALSE),bLine90(FALSE),bRect(FALSE),
+ bMixedCreate(FALSE),nBezierStartPoint(0),eStartKind(OBJ_NONE),eAktKind(OBJ_NONE) { }
+
+ void ResetFormFlags() { bBezier=FALSE; bCurve=FALSE; bCircle=FALSE; bLine=FALSE; bRect=FALSE; }
+ bool IsFormFlag() const { return bBezier || bCurve || bCircle || bLine || bRect; }
+ XPolygon GetFormPoly() const;
+ bool CalcBezier(const Point& rP1, const Point& rP2, const Point& rDir, bool bMouseDown);
+ XPolygon GetBezierPoly() const;
+ //bool CalcCurve(const Point& rP1, const Point& rP2, const Point& rDir, SdrView* pView) { return FALSE; }
+ XPolygon GetCurvePoly() const { return XPolygon(); }
+ bool CalcCircle(const Point& rP1, const Point& rP2, const Point& rDir, SdrView* pView);
+ XPolygon GetCirclePoly() const;
+ bool CalcLine(const Point& rP1, const Point& rP2, const Point& rDir, SdrView* pView);
+ Point CalcLine(const Point& rCsr, long nDirX, long nDirY, SdrView* pView) const;
+ XPolygon GetLinePoly() const;
+ bool CalcRect(const Point& rP1, const Point& rP2, const Point& rDir, SdrView* pView);
+ XPolygon GetRectPoly() const;
+};
+
+XPolygon ImpPathCreateUser::GetFormPoly() const
+{
+ if (bBezier) return GetBezierPoly();
+ if (bCurve) return GetCurvePoly();
+ if (bCircle) return GetCirclePoly();
+ if (bLine) return GetLinePoly();
+ if (bRect) return GetRectPoly();
+ return XPolygon();
+}
+
+bool ImpPathCreateUser::CalcBezier(const Point& rP1, const Point& rP2, const Point& rDir, bool bMouseDown)
+{
+ bool bRet = true;
+ aBezStart=rP1;
+ aBezCtrl1=rP1+rDir;
+ aBezCtrl2=rP2;
+
+ // #i21479#
+ // Also copy the end point when no end point is set yet
+ if (!bMouseDown || (0L == aBezEnd.X() && 0L == aBezEnd.Y())) aBezEnd=rP2;
+
+ bBezier=bRet;
+ return bRet;
+}
+
+XPolygon ImpPathCreateUser::GetBezierPoly() const
+{
+ XPolygon aXP(4);
+ aXP[0]=aBezStart; aXP.SetFlags(0,XPOLY_SMOOTH);
+ aXP[1]=aBezCtrl1; aXP.SetFlags(1,XPOLY_CONTROL);
+ aXP[2]=aBezCtrl2; aXP.SetFlags(2,XPOLY_CONTROL);
+ aXP[3]=aBezEnd;
+ return aXP;
+}
+
+bool ImpPathCreateUser::CalcCircle(const Point& rP1, const Point& rP2, const Point& rDir, SdrView* pView)
+{
+ long nTangAngle=GetAngle(rDir);
+ aCircStart=rP1;
+ aCircEnd=rP2;
+ aCircCenter=rP1;
+ long dx=rP2.X()-rP1.X();
+ long dy=rP2.Y()-rP1.Y();
+ long dAngle=GetAngle(Point(dx,dy))-nTangAngle;
+ dAngle=NormAngle360(dAngle);
+ long nTmpAngle=NormAngle360(9000-dAngle);
+ bool bRet=nTmpAngle!=9000 && nTmpAngle!=27000;
+ long nRad=0;
+ if (bRet) {
+ double cs=cos(nTmpAngle*nPi180);
+ double nR=(double)GetLen(Point(dx,dy))/cs/2;
+ nRad=Abs(Round(nR));
+ }
+ if (dAngle<18000) {
+ nCircStWink=NormAngle360(nTangAngle-9000);
+ nCircRelWink=NormAngle360(2*dAngle);
+ aCircCenter.X()+=Round(nRad*cos((nTangAngle+9000)*nPi180));
+ aCircCenter.Y()-=Round(nRad*sin((nTangAngle+9000)*nPi180));
+ } else {
+ nCircStWink=NormAngle360(nTangAngle+9000);
+ nCircRelWink=-NormAngle360(36000-2*dAngle);
+ aCircCenter.X()+=Round(nRad*cos((nTangAngle-9000)*nPi180));
+ aCircCenter.Y()-=Round(nRad*sin((nTangAngle-9000)*nPi180));
+ }
+ bAngleSnap=pView!=NULL && pView->IsAngleSnapEnabled();
+ if (bAngleSnap) {
+ long nSA=pView->GetSnapAngle();
+ if (nSA!=0) { // Winkelfang
+ bool bNeg=nCircRelWink<0;
+ if (bNeg) nCircRelWink=-nCircRelWink;
+ nCircRelWink+=nSA/2;
+ nCircRelWink/=nSA;
+ nCircRelWink*=nSA;
+ nCircRelWink=NormAngle360(nCircRelWink);
+ if (bNeg) nCircRelWink=-nCircRelWink;
+ }
+ }
+ nCircRadius=nRad;
+ if (nRad==0 || Abs(nCircRelWink)<5) bRet=FALSE;
+ bCircle=bRet;
+ return bRet;
+}
+
+XPolygon ImpPathCreateUser::GetCirclePoly() const
+{
+ if (nCircRelWink>=0) {
+ XPolygon aXP(aCircCenter,nCircRadius,nCircRadius,
+ USHORT((nCircStWink+5)/10),USHORT((nCircStWink+nCircRelWink+5)/10),FALSE);
+ aXP[0]=aCircStart; aXP.SetFlags(0,XPOLY_SMOOTH);
+ if (!bAngleSnap) aXP[aXP.GetPointCount()-1]=aCircEnd;
+ return aXP;
+ } else {
+ XPolygon aXP(aCircCenter,nCircRadius,nCircRadius,
+ USHORT(NormAngle360(nCircStWink+nCircRelWink+5)/10),USHORT((nCircStWink+5)/10),FALSE);
+ USHORT nAnz=aXP.GetPointCount();
+ for (USHORT nNum=nAnz/2; nNum>0;) {
+ nNum--; // XPoly Punktreihenfolge umkehren
+ USHORT n2=nAnz-nNum-1;
+ Point aPt(aXP[nNum]);
+ aXP[nNum]=aXP[n2];
+ aXP[n2]=aPt;
+ }
+ aXP[0]=aCircStart; aXP.SetFlags(0,XPOLY_SMOOTH);
+ if (!bAngleSnap) aXP[aXP.GetPointCount()-1]=aCircEnd;
+ return aXP;
+ }
+}
+
+Point ImpPathCreateUser::CalcLine(const Point& aCsr, long nDirX, long nDirY, SdrView* pView) const
+{
+ long x=aCsr.X(),x1=x,x2=x;
+ long y=aCsr.Y(),y1=y,y2=y;
+ bool bHLin=nDirY==0;
+ bool bVLin=nDirX==0;
+ if (bHLin) y=0;
+ else if (bVLin) x=0;
+ else {
+ x1=BigMulDiv(y,nDirX,nDirY);
+ y2=BigMulDiv(x,nDirY,nDirX);
+ long l1=Abs(x1)+Abs(y1);
+ long l2=Abs(x2)+Abs(y2);
+ if ((l1<=l2) != (pView!=NULL && pView->IsBigOrtho())) {
+ x=x1; y=y1;
+ } else {
+ x=x2; y=y2;
+ }
+ }
+ return Point(x,y);
+}
+
+bool ImpPathCreateUser::CalcLine(const Point& rP1, const Point& rP2, const Point& rDir, SdrView* pView)
+{
+ aLineStart=rP1;
+ aLineEnd=rP2;
+ bLine90=FALSE;
+ if (rP1==rP2 || (rDir.X()==0 && rDir.Y()==0)) { bLine=FALSE; return FALSE; }
+ Point aTmpPt(rP2-rP1);
+ long nDirX=rDir.X();
+ long nDirY=rDir.Y();
+ Point aP1(CalcLine(aTmpPt, nDirX, nDirY,pView)); aP1-=aTmpPt; long nQ1=Abs(aP1.X())+Abs(aP1.Y());
+ Point aP2(CalcLine(aTmpPt, nDirY,-nDirX,pView)); aP2-=aTmpPt; long nQ2=Abs(aP2.X())+Abs(aP2.Y());
+ if (pView!=NULL && pView->IsOrtho()) nQ1=0; // Ortho schaltet rechtwinklig aus
+ bLine90=nQ1>2*nQ2;
+ if (!bLine90) { // glatter Uebergang
+ aLineEnd+=aP1;
+ } else { // rechtwinkliger Uebergang
+ aLineEnd+=aP2;
+ }
+ bLine=TRUE;
+ return TRUE;
+}
+
+XPolygon ImpPathCreateUser::GetLinePoly() const
+{
+ XPolygon aXP(2);
+ aXP[0]=aLineStart; if (!bLine90) aXP.SetFlags(0,XPOLY_SMOOTH);
+ aXP[1]=aLineEnd;
+ return aXP;
+}
+
+bool ImpPathCreateUser::CalcRect(const Point& rP1, const Point& rP2, const Point& rDir, SdrView* pView)
+{
+ aRectP1=rP1;
+ aRectP2=rP1;
+ aRectP3=rP2;
+ if (rP1==rP2 || (rDir.X()==0 && rDir.Y()==0)) { bRect=FALSE; return FALSE; }
+ Point aTmpPt(rP2-rP1);
+ long nDirX=rDir.X();
+ long nDirY=rDir.Y();
+ long x=aTmpPt.X();
+ long y=aTmpPt.Y();
+ bool bHLin=nDirY==0;
+ bool bVLin=nDirX==0;
+ if (bHLin) y=0;
+ else if (bVLin) x=0;
+ else {
+ y=BigMulDiv(x,nDirY,nDirX);
+ long nHypLen=aTmpPt.Y()-y;
+ long nTangAngle=-GetAngle(rDir);
+ // sin=g/h, g=h*sin
+ double a=nTangAngle*nPi180;
+ double sn=sin(a);
+ double cs=cos(a);
+ double nGKathLen=nHypLen*sn;
+ y+=Round(nGKathLen*sn);
+ x+=Round(nGKathLen*cs);
+ }
+ aRectP2.X()+=x;
+ aRectP2.Y()+=y;
+ if (pView!=NULL && pView->IsOrtho()) {
+ long dx1=aRectP2.X()-aRectP1.X(); long dx1a=Abs(dx1);
+ long dy1=aRectP2.Y()-aRectP1.Y(); long dy1a=Abs(dy1);
+ long dx2=aRectP3.X()-aRectP2.X(); long dx2a=Abs(dx2);
+ long dy2=aRectP3.Y()-aRectP2.Y(); long dy2a=Abs(dy2);
+ bool b1MoreThan2=dx1a+dy1a>dx2a+dy2a;
+ if (b1MoreThan2 != pView->IsBigOrtho()) {
+ long xtemp=dy2a-dx1a; if (dx1<0) xtemp=-xtemp;
+ long ytemp=dx2a-dy1a; if (dy1<0) ytemp=-ytemp;
+ aRectP2.X()+=xtemp;
+ aRectP2.Y()+=ytemp;
+ aRectP3.X()+=xtemp;
+ aRectP3.Y()+=ytemp;
+ } else {
+ long xtemp=dy1a-dx2a; if (dx2<0) xtemp=-xtemp;
+ long ytemp=dx1a-dy2a; if (dy2<0) ytemp=-ytemp;
+ aRectP3.X()+=xtemp;
+ aRectP3.Y()+=ytemp;
+ }
+ }
+ bRect=TRUE;
+ return TRUE;
+}
+
+XPolygon ImpPathCreateUser::GetRectPoly() const
+{
+ XPolygon aXP(3);
+ aXP[0]=aRectP1; aXP.SetFlags(0,XPOLY_SMOOTH);
+ aXP[1]=aRectP2;
+ if (aRectP3!=aRectP2) aXP[2]=aRectP3;
+ return aXP;
+}
+
+/*************************************************************************/
+
+class ImpPathForDragAndCreate
+{
+ SdrPathObj& mrSdrPathObject;
+ XPolyPolygon aPathPolygon;
+ SdrObjKind meObjectKind;
+ ImpSdrPathDragData* mpSdrPathDragData;
+ bool mbCreating;
+
+public:
+ ImpPathForDragAndCreate(SdrPathObj& rSdrPathObject);
+ ~ImpPathForDragAndCreate();
+
+ // drag stuff
+ bool beginPathDrag( SdrDragStat& rDrag ) const;
+ bool movePathDrag( SdrDragStat& rDrag ) const;
+ bool endPathDrag( SdrDragStat& rDrag );
+ //void cancelSpecialDrag( SdrDragStat& rDrag ) const;
+ String getSpecialDragComment(const SdrDragStat& rDrag) const;
+ basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const;
+
+ // create stuff
+ bool BegCreate(SdrDragStat& rStat);
+ bool MovCreate(SdrDragStat& rStat);
+ bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
+ bool BckCreate(SdrDragStat& rStat);
+ void BrkCreate(SdrDragStat& rStat);
+ Pointer GetCreatePointer() const;
+
+ // helping stuff
+ bool IsClosed(SdrObjKind eKind) const { return eKind==OBJ_POLY || eKind==OBJ_PATHPOLY || eKind==OBJ_PATHFILL || eKind==OBJ_FREEFILL || eKind==OBJ_SPLNFILL; }
+ bool IsFreeHand(SdrObjKind eKind) const { return eKind==OBJ_FREELINE || eKind==OBJ_FREEFILL; }
+ bool IsBezier(SdrObjKind eKind) const { return eKind==OBJ_PATHLINE || eKind==OBJ_PATHFILL; }
+ bool IsCreating() const { return mbCreating; }
+
+ // get the polygon
+ basegfx::B2DPolyPolygon TakeObjectPolyPolygon(const SdrDragStat& rDrag) const;
+ basegfx::B2DPolyPolygon TakeDragPolyPolygon(const SdrDragStat& rDrag) const;
+ basegfx::B2DPolyPolygon getModifiedPolyPolygon() const { return aPathPolygon.getB2DPolyPolygon(); }
+};
+
+ImpPathForDragAndCreate::ImpPathForDragAndCreate(SdrPathObj& rSdrPathObject)
+: mrSdrPathObject(rSdrPathObject),
+ aPathPolygon(rSdrPathObject.GetPathPoly()),
+ meObjectKind(mrSdrPathObject.meKind),
+ mpSdrPathDragData(0),
+ mbCreating(false)
+{
+}
+
+ImpPathForDragAndCreate::~ImpPathForDragAndCreate()
+{
+ if(mpSdrPathDragData)
+ {
+ delete mpSdrPathDragData;
+ }
+}
+
+bool ImpPathForDragAndCreate::beginPathDrag( SdrDragStat& rDrag ) const
+{
+ const SdrHdl* pHdl=rDrag.GetHdl();
+ if(!pHdl)
+ return FALSE;
+
+ BOOL bMultiPointDrag(TRUE);
+
+ if(aPathPolygon[(sal_uInt16)pHdl->GetPolyNum()].IsControl((sal_uInt16)pHdl->GetPointNum()))
+ bMultiPointDrag = FALSE;
+
+ if(bMultiPointDrag)
+ {
+ const SdrMarkView& rMarkView = *rDrag.GetView();
+ const SdrHdlList& rHdlList = rMarkView.GetHdlList();
+ const sal_uInt32 nHdlCount = rHdlList.GetHdlCount();
+ const SdrObject* pInteractionObject(nHdlCount && rHdlList.GetHdl(0) ? rHdlList.GetHdl(0)->GetObj() : 0);
+ sal_uInt32 nSelectedPoints(0);
+
+ for(sal_uInt32 a(0); a < nHdlCount; a++)
+ {
+ SdrHdl* pTestHdl = rHdlList.GetHdl(a);
+
+ if(pTestHdl && pTestHdl->IsSelected() && pTestHdl->GetObj() == pInteractionObject)
+ {
+ nSelectedPoints++;
+ }
+ }
+
+ if(nSelectedPoints <= 1)
+ bMultiPointDrag = FALSE;
+ }
+
+ ((ImpPathForDragAndCreate*)this)->mpSdrPathDragData = new ImpSdrPathDragData(mrSdrPathObject,*pHdl,bMultiPointDrag,rDrag);
+
+ if(!mpSdrPathDragData || !mpSdrPathDragData->bValid)
+ {
+ DBG_ERROR("ImpPathForDragAndCreate::BegDrag(): ImpSdrPathDragData ist ungueltig");
+ delete mpSdrPathDragData;
+ ((ImpPathForDragAndCreate*)this)->mpSdrPathDragData = 0;
+ return false;
+ }
+
+ return true;
+}
+
+bool ImpPathForDragAndCreate::movePathDrag( SdrDragStat& rDrag ) const
+{
+ if(!mpSdrPathDragData || !mpSdrPathDragData->bValid)
+ {
+ DBG_ERROR("ImpPathForDragAndCreate::MovDrag(): ImpSdrPathDragData ist ungueltig");
+ return false;
+ }
+
+ if(mpSdrPathDragData->IsMultiPointDrag())
+ {
+ Point aDelta(rDrag.GetNow() - rDrag.GetStart());
+
+ if(aDelta.X() || aDelta.Y())
+ {
+ for(sal_uInt32 a(0); a < mpSdrPathDragData->maHandles.Count(); a++)
+ {
+ SdrHdl* pHandle = (SdrHdl*)mpSdrPathDragData->maHandles.GetObject(a);
+ const sal_uInt16 nPolyIndex((sal_uInt16)pHandle->GetPolyNum());
+ const sal_uInt16 nPointIndex((sal_uInt16)pHandle->GetPointNum());
+ const XPolygon& rOrig = mpSdrPathDragData->maOrig[nPolyIndex];
+ XPolygon& rMove = mpSdrPathDragData->maMove[nPolyIndex];
+ const sal_uInt16 nPointCount(rOrig.GetPointCount());
+ BOOL bClosed(rOrig[0] == rOrig[nPointCount-1]);
+
+ // move point itself
+ rMove[nPointIndex] = rOrig[nPointIndex] + aDelta;
+
+ // when point is first and poly closed, move close point, too.
+ if(nPointCount > 0 && !nPointIndex && bClosed)
+ {
+ rMove[nPointCount - 1] = rOrig[nPointCount - 1] + aDelta;
+
+ // when moving the last point it may be necessary to move the
+ // control point in front of this one, too.
+ if(nPointCount > 1 && rOrig.IsControl(nPointCount - 2))
+ rMove[nPointCount - 2] = rOrig[nPointCount - 2] + aDelta;
+ }
+
+ // is a control point before this?
+ if(nPointIndex > 0 && rOrig.IsControl(nPointIndex - 1))
+ {
+ // Yes, move it, too
+ rMove[nPointIndex - 1] = rOrig[nPointIndex - 1] + aDelta;
+ }
+
+ // is a control point after this?
+ if(nPointIndex + 1 < nPointCount && rOrig.IsControl(nPointIndex + 1))
+ {
+ // Yes, move it, too
+ rMove[nPointIndex + 1] = rOrig[nPointIndex + 1] + aDelta;
+ }
+ }
+ }
+ }
+ else
+ {
+ mpSdrPathDragData->ResetPoly(mrSdrPathObject);
+
+ // Div. Daten lokal Kopieren fuer weniger Code und schnelleren Zugriff
+ bool bClosed =mpSdrPathDragData->bClosed ; // geschlossenes Objekt?
+ USHORT nPnt =mpSdrPathDragData->nPnt ; // Punktnummer innerhalb des obigen Polygons
+ bool bBegPnt =mpSdrPathDragData->bBegPnt ; // Gedraggter Punkt ist der Anfangspunkt einer Polyline
+ bool bEndPnt =mpSdrPathDragData->bEndPnt ; // Gedraggter Punkt ist der Endpunkt einer Polyline
+ USHORT nPrevPnt =mpSdrPathDragData->nPrevPnt ; // Index des vorherigen Punkts
+ USHORT nNextPnt =mpSdrPathDragData->nNextPnt ; // Index des naechsten Punkts
+ bool bPrevIsBegPnt =mpSdrPathDragData->bPrevIsBegPnt ; // Vorheriger Punkt ist Anfangspunkt einer Polyline
+ bool bNextIsEndPnt =mpSdrPathDragData->bNextIsEndPnt ; // Folgepunkt ist Endpunkt einer Polyline
+ USHORT nPrevPrevPnt =mpSdrPathDragData->nPrevPrevPnt ; // Index des vorvorherigen Punkts
+ USHORT nNextNextPnt =mpSdrPathDragData->nNextNextPnt ; // Index des uebernaechsten Punkts
+ bool bControl =mpSdrPathDragData->bControl ; // Punkt ist ein Kontrollpunkt
+ //bool bIsPrevControl=mpSdrPathDragData->bIsPrevControl; // Punkt ist Kontrollpunkt vor einem Stuetzpunkt
+ bool bIsNextControl =mpSdrPathDragData->bIsNextControl; // Punkt ist Kontrollpunkt hinter einem Stuetzpunkt
+ bool bPrevIsControl =mpSdrPathDragData->bPrevIsControl; // Falls nPnt ein StPnt: Davor ist ein Kontrollpunkt
+ bool bNextIsControl =mpSdrPathDragData->bNextIsControl; // Falls nPnt ein StPnt: Dahinter ist ein Kontrollpunkt
+
+ // Ortho bei Linien/Polygonen = Winkel beibehalten
+ if (!bControl && rDrag.GetView()!=NULL && rDrag.GetView()->IsOrtho()) {
+ bool bBigOrtho=rDrag.GetView()->IsBigOrtho();
+ Point aPos(rDrag.GetNow()); // die aktuelle Position
+ Point aPnt(mpSdrPathDragData->aXP[nPnt]); // der gedraggte Punkt
+ USHORT nPnt1=0xFFFF,nPnt2=0xFFFF; // seine Nachbarpunkte
+ Point aNeuPos1,aNeuPos2; // die neuen Alternativen fuer aPos
+ bool bPnt1 = false, bPnt2 = false; // die neuen Alternativen gueltig?
+ if (!bClosed && mpSdrPathDragData->nPntAnz>=2) { // Mind. 2 Pt bei Linien
+ if (!bBegPnt) nPnt1=nPrevPnt;
+ if (!bEndPnt) nPnt2=nNextPnt;
+ }
+ if (bClosed && mpSdrPathDragData->nPntAnz>=3) { // Mind. 3 Pt bei Polygon
+ nPnt1=nPrevPnt;
+ nPnt2=nNextPnt;
+ }
+ if (nPnt1!=0xFFFF && !bPrevIsControl) {
+ Point aPnt1=mpSdrPathDragData->aXP[nPnt1];
+ long ndx0=aPnt.X()-aPnt1.X();
+ long ndy0=aPnt.Y()-aPnt1.Y();
+ bool bHLin=ndy0==0;
+ bool bVLin=ndx0==0;
+ if (!bHLin || !bVLin) {
+ long ndx=aPos.X()-aPnt1.X();
+ long ndy=aPos.Y()-aPnt1.Y();
+ bPnt1=TRUE;
+ double nXFact=0; if (!bVLin) nXFact=(double)ndx/(double)ndx0;
+ double nYFact=0; if (!bHLin) nYFact=(double)ndy/(double)ndy0;
+ bool bHor=bHLin || (!bVLin && (nXFact>nYFact) ==bBigOrtho);
+ bool bVer=bVLin || (!bHLin && (nXFact<=nYFact)==bBigOrtho);
+ if (bHor) ndy=long(ndy0*nXFact);
+ if (bVer) ndx=long(ndx0*nYFact);
+ aNeuPos1=aPnt1;
+ aNeuPos1.X()+=ndx;
+ aNeuPos1.Y()+=ndy;
+ }
+ }
+ if (nPnt2!=0xFFFF && !bNextIsControl) {
+ Point aPnt2=mpSdrPathDragData->aXP[nPnt2];
+ long ndx0=aPnt.X()-aPnt2.X();
+ long ndy0=aPnt.Y()-aPnt2.Y();
+ bool bHLin=ndy0==0;
+ bool bVLin=ndx0==0;
+ if (!bHLin || !bVLin) {
+ long ndx=aPos.X()-aPnt2.X();
+ long ndy=aPos.Y()-aPnt2.Y();
+ bPnt2=TRUE;
+ double nXFact=0; if (!bVLin) nXFact=(double)ndx/(double)ndx0;
+ double nYFact=0; if (!bHLin) nYFact=(double)ndy/(double)ndy0;
+ bool bHor=bHLin || (!bVLin && (nXFact>nYFact) ==bBigOrtho);
+ bool bVer=bVLin || (!bHLin && (nXFact<=nYFact)==bBigOrtho);
+ if (bHor) ndy=long(ndy0*nXFact);
+ if (bVer) ndx=long(ndx0*nYFact);
+ aNeuPos2=aPnt2;
+ aNeuPos2.X()+=ndx;
+ aNeuPos2.Y()+=ndy;
+ }
+ }
+ if (bPnt1 && bPnt2) { // beide Alternativen vorhanden (Konkurenz)
+ BigInt nX1(aNeuPos1.X()-aPos.X()); nX1*=nX1;
+ BigInt nY1(aNeuPos1.Y()-aPos.Y()); nY1*=nY1;
+ BigInt nX2(aNeuPos2.X()-aPos.X()); nX2*=nX2;
+ BigInt nY2(aNeuPos2.Y()-aPos.Y()); nY2*=nY2;
+ nX1+=nY1; // Korrekturabstand zum Quadrat
+ nX2+=nY2; // Korrekturabstand zum Quadrat
+ // Die Alternative mit dem geringeren Korrekturbedarf gewinnt
+ if (nX1<nX2) bPnt2=FALSE; else bPnt1=FALSE;
+ }
+ if (bPnt1) rDrag.Now()=aNeuPos1;
+ if (bPnt2) rDrag.Now()=aNeuPos2;
+ }
+ rDrag.SetActionRect(Rectangle(rDrag.GetNow(),rDrag.GetNow()));
+
+ // IBM Special: Punkte eliminieren, wenn die beiden angrenzenden
+ // Linien eh' fast 180 deg sind.
+ if (!bControl && rDrag.GetView()!=NULL && rDrag.GetView()->IsEliminatePolyPoints() &&
+ !bBegPnt && !bEndPnt && !bPrevIsControl && !bNextIsControl)
+ {
+ Point aPt(mpSdrPathDragData->aXP[nNextPnt]);
+ aPt-=rDrag.GetNow();
+ long nWink1=GetAngle(aPt);
+ aPt=rDrag.GetNow();
+ aPt-=mpSdrPathDragData->aXP[nPrevPnt];
+ long nWink2=GetAngle(aPt);
+ long nDiff=nWink1-nWink2;
+ nDiff=Abs(nDiff);
+ mpSdrPathDragData->bEliminate=nDiff<=rDrag.GetView()->GetEliminatePolyPointLimitAngle();
+ if (mpSdrPathDragData->bEliminate) { // Position anpassen, damit Smooth an den Enden stimmt
+ aPt=mpSdrPathDragData->aXP[nNextPnt];
+ aPt+=mpSdrPathDragData->aXP[nPrevPnt];
+ aPt/=2;
+ rDrag.Now()=aPt;
+ }
+ }
+
+ // Um diese Entfernung wurde insgesamt gedraggd
+ Point aDiff(rDrag.GetNow()); aDiff-=mpSdrPathDragData->aXP[nPnt];
+
+ // Insgesamt sind 8 Faelle moeglich:
+ // X 1. Weder rechts noch links Ctrl.
+ // o--X--o 2. Rechts und links Ctrl, gedraggd wird St.
+ // o--X 3. Nur links Ctrl, gedraggd wird St.
+ // X--o 4. Nur rechts Ctrl, gedraggd wird St.
+ // x--O--o 5. Rechts und links Ctrl, gedraggd wird links.
+ // x--O 6. Nur links Ctrl, gedraggd wird links.
+ // o--O--x 7. Rechts und links Ctrl, gedraggd wird rechts.
+ // O--x 8. Nur rechts Ctrl, gedraggd wird rechts.
+ // Zusaetzlich ist zu beachten, dass das Veraendern einer Linie (keine Kurve)
+ // eine evtl. Kurve am anderen Ende der Linie bewirkt, falls dort Smooth
+ // gesetzt ist (Kontrollpunktausrichtung an Gerade).
+
+ mpSdrPathDragData->aXP[nPnt]+=aDiff;
+
+ // Nun symmetrische PlusHandles etc. checken
+ if (bControl) { // Faelle 5,6,7,8
+ USHORT nSt=nPnt; // der zugehoerige Stuetzpunkt
+ USHORT nFix=nPnt; // der gegenueberliegende Kontrollpunkt
+ if (bIsNextControl) { // Wenn der naechste ein Kontrollpunkt ist, muss der vorh. der Stuetzpunkt sein
+ nSt=nPrevPnt;
+ nFix=nPrevPrevPnt;
+ } else {
+ nSt=nNextPnt;
+ nFix=nNextNextPnt;
+ }
+ if (mpSdrPathDragData->aXP.IsSmooth(nSt)) {
+ mpSdrPathDragData->aXP.CalcSmoothJoin(nSt,nPnt,nFix);
+ }
+ }
+
+ if (!bControl) { // Faelle 1,2,3,4 wobei bei 1 nix passiert und bei 3+4 unten noch mehr folgt
+ // die beiden Kontrollpunkte mit verschieben
+ if (bPrevIsControl) mpSdrPathDragData->aXP[nPrevPnt]+=aDiff;
+ if (bNextIsControl) mpSdrPathDragData->aXP[nNextPnt]+=aDiff;
+ // Kontrollpunkt ggf. an Gerade ausrichten
+ if (mpSdrPathDragData->aXP.IsSmooth(nPnt)) {
+ if (bPrevIsControl && !bNextIsControl && !bEndPnt) { // Fall 3
+ mpSdrPathDragData->aXP.CalcSmoothJoin(nPnt,nNextPnt,nPrevPnt);
+ }
+ if (bNextIsControl && !bPrevIsControl && !bBegPnt) { // Fall 4
+ mpSdrPathDragData->aXP.CalcSmoothJoin(nPnt,nPrevPnt,nNextPnt);
+ }
+ }
+ // Und nun noch die anderen Enden der Strecken ueberpruefen (nPnt+-1).
+ // Ist dort eine Kurve (IsControl(nPnt+-2)) mit SmoothJoin (nPnt+-1),
+ // so muss der entsprechende Kontrollpunkt (nPnt+-2) angepasst werden.
+ if (!bBegPnt && !bPrevIsControl && !bPrevIsBegPnt && mpSdrPathDragData->aXP.IsSmooth(nPrevPnt)) {
+ if (mpSdrPathDragData->aXP.IsControl(nPrevPrevPnt)) {
+ mpSdrPathDragData->aXP.CalcSmoothJoin(nPrevPnt,nPnt,nPrevPrevPnt);
+ }
+ }
+ if (!bEndPnt && !bNextIsControl && !bNextIsEndPnt && mpSdrPathDragData->aXP.IsSmooth(nNextPnt)) {
+ if (mpSdrPathDragData->aXP.IsControl(nNextNextPnt)) {
+ mpSdrPathDragData->aXP.CalcSmoothJoin(nNextPnt,nPnt,nNextNextPnt);
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+bool ImpPathForDragAndCreate::endPathDrag(SdrDragStat& rDrag)
+{
+ Point aLinePt1;
+ Point aLinePt2;
+ bool bLineGlueMirror(OBJ_LINE == meObjectKind);
+ if (bLineGlueMirror) { // #40549#
+ XPolygon& rXP=aPathPolygon[0];
+ aLinePt1=rXP[0];
+ aLinePt2=rXP[1];
+ }
+
+ if(!mpSdrPathDragData || !mpSdrPathDragData->bValid)
+ {
+ DBG_ERROR("ImpPathForDragAndCreate::MovDrag(): ImpSdrPathDragData ist ungueltig");
+ return false;
+ }
+
+ if(mpSdrPathDragData->IsMultiPointDrag())
+ {
+ aPathPolygon = mpSdrPathDragData->maMove;
+ }
+ else
+ {
+ const SdrHdl* pHdl=rDrag.GetHdl();
+
+ // Referenz auf das Polygon
+ XPolygon& rXP=aPathPolygon[(sal_uInt16)pHdl->GetPolyNum()];
+
+ // Die 5 Punkte die sich evtl. geaendert haben
+ if (!mpSdrPathDragData->bPrevIsBegPnt) rXP[mpSdrPathDragData->nPrevPrevPnt0]=mpSdrPathDragData->aXP[mpSdrPathDragData->nPrevPrevPnt];
+ if (!mpSdrPathDragData->bNextIsEndPnt) rXP[mpSdrPathDragData->nNextNextPnt0]=mpSdrPathDragData->aXP[mpSdrPathDragData->nNextNextPnt];
+ if (!mpSdrPathDragData->bBegPnt) rXP[mpSdrPathDragData->nPrevPnt0] =mpSdrPathDragData->aXP[mpSdrPathDragData->nPrevPnt];
+ if (!mpSdrPathDragData->bEndPnt) rXP[mpSdrPathDragData->nNextPnt0] =mpSdrPathDragData->aXP[mpSdrPathDragData->nNextPnt];
+ rXP[mpSdrPathDragData->nPnt0] =mpSdrPathDragData->aXP[mpSdrPathDragData->nPnt];
+
+ // Letzter Punkt muss beim Geschlossenen immer gleich dem Ersten sein
+ if (mpSdrPathDragData->bClosed) rXP[rXP.GetPointCount()-1]=rXP[0];
+
+ if (mpSdrPathDragData->bEliminate)
+ {
+ basegfx::B2DPolyPolygon aTempPolyPolygon(aPathPolygon.getB2DPolyPolygon());
+ sal_uInt32 nPoly,nPnt;
+
+ if(PolyPolygonEditor::GetRelativePolyPoint(aTempPolyPolygon, rDrag.GetHdl()->GetSourceHdlNum(), nPoly, nPnt))
+ {
+ basegfx::B2DPolygon aCandidate(aTempPolyPolygon.getB2DPolygon(nPoly));
+ aCandidate.remove(nPnt);
+
+ if((IsClosed(meObjectKind) && aCandidate.count() < 3L) || aCandidate.count() < 2L)
+ {
+ aTempPolyPolygon.remove(nPoly);
+ }
+ else
+ {
+ aTempPolyPolygon.setB2DPolygon(nPoly, aCandidate);
+ }
+ }
+
+ aPathPolygon = XPolyPolygon(aTempPolyPolygon);
+ }
+
+ // Winkel anpassen fuer Text an einfacher Linie
+ if (bLineGlueMirror)
+ { // #40549#
+ Point aLinePt1_(aPathPolygon[0][0]);
+ Point aLinePt2_(aPathPolygon[0][1]);
+ bool bXMirr=(aLinePt1_.X()>aLinePt2_.X())!=(aLinePt1.X()>aLinePt2.X());
+ bool bYMirr=(aLinePt1_.Y()>aLinePt2_.Y())!=(aLinePt1.Y()>aLinePt2.Y());
+ if (bXMirr || bYMirr) {
+ Point aRef1(mrSdrPathObject.GetSnapRect().Center());
+ if (bXMirr) {
+ Point aRef2(aRef1);
+ aRef2.Y()++;
+ mrSdrPathObject.NbcMirrorGluePoints(aRef1,aRef2);
+ }
+ if (bYMirr) {
+ Point aRef2(aRef1);
+ aRef2.X()++;
+ mrSdrPathObject.NbcMirrorGluePoints(aRef1,aRef2);
+ }
+ }
+ }
+ }
+
+ delete mpSdrPathDragData;
+ mpSdrPathDragData = 0;
+
+ return true;
+}
+
+/*void ImpPathForDragAndCreate::cancelSpecialDrag( SdrDragStat& rDrag ) const
+{
+ ImpSdrPathDragData* pID=(ImpSdrPathDragData*)rDrag.GetUser();
+ if (pID!=NULL) {
+ delete pID;
+ rDrag.SetUser(NULL);
+ }
+}*/
+
+String ImpPathForDragAndCreate::getSpecialDragComment(const SdrDragStat& rDrag) const
+{
+ XubString aStr;
+ const SdrHdl* pHdl = rDrag.GetHdl();
+ const bool bCreateComment(rDrag.GetView() && &mrSdrPathObject == rDrag.GetView()->GetCreateObj());
+
+ if(bCreateComment && rDrag.GetUser())
+ {
+ // #i103058# re-add old creation comment mode
+ ImpPathCreateUser* pU = (ImpPathCreateUser*)rDrag.GetUser();
+ const SdrObjKind eKindMerk(meObjectKind);
+ mrSdrPathObject.meKind = pU->eAktKind;
+ mrSdrPathObject.ImpTakeDescriptionStr(STR_ViewCreateObj, aStr);
+ mrSdrPathObject.meKind = eKindMerk;
+
+ Point aPrev(rDrag.GetPrev());
+ Point aNow(rDrag.GetNow());
+
+ if(pU->bLine)
+ aNow = pU->aLineEnd;
+
+ aNow -= aPrev;
+ aStr.AppendAscii(" (");
+
+ XubString aMetr;
+
+ if(pU->bCircle)
+ {
+ mrSdrPathObject.GetModel()->TakeWinkStr(Abs(pU->nCircRelWink), aMetr);
+ aStr += aMetr;
+ aStr.AppendAscii(" r=");
+ mrSdrPathObject.GetModel()->TakeMetricStr(pU->nCircRadius, aMetr, TRUE);
+ aStr += aMetr;
+ }
+
+ aStr.AppendAscii("dx=");
+ mrSdrPathObject.GetModel()->TakeMetricStr(aNow.X(), aMetr, TRUE);
+ aStr += aMetr;
+
+ aStr.AppendAscii(" dy=");
+ mrSdrPathObject.GetModel()->TakeMetricStr(aNow.Y(), aMetr, TRUE);
+ aStr += aMetr;
+
+ if(!IsFreeHand(meObjectKind))
+ {
+ INT32 nLen(GetLen(aNow));
+ aStr.AppendAscii(" l=");
+ mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE);
+ aStr += aMetr;
+
+ INT32 nWink(GetAngle(aNow));
+ aStr += sal_Unicode(' ');
+ mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr);
+ aStr += aMetr;
+ }
+
+ aStr += sal_Unicode(')');
+ }
+ else if(!mrSdrPathObject.GetModel() || !pHdl)
+ {
+ // #i103058# fallback when no model and/or Handle, both needed
+ // for else-path
+ mrSdrPathObject.ImpTakeDescriptionStr(STR_DragPathObj, aStr);
+ }
+ else
+ {
+ // #i103058# standard for modification; model and handle needed
+ ImpSdrPathDragData* pDragData = mpSdrPathDragData;
+
+ if(!pDragData)
+ {
+ // getSpecialDragComment is also used from create, so fallback to GetUser()
+ // when mpSdrPathDragData is not set
+ pDragData = (ImpSdrPathDragData*)rDrag.GetUser();
+ }
+
+ if(!pDragData)
+ {
+ DBG_ERROR("ImpPathForDragAndCreate::MovDrag(): ImpSdrPathDragData ist ungueltig");
+ return String();
+ }
+
+ if(!pDragData->IsMultiPointDrag() && pDragData->bEliminate)
+ {
+ // Punkt von ...
+ mrSdrPathObject.ImpTakeDescriptionStr(STR_ViewMarkedPoint, aStr);
+
+ // %O loeschen
+ XubString aStr2(ImpGetResStr(STR_EditDelete));
+
+ // UNICODE: Punkt von ... loeschen
+ aStr2.SearchAndReplaceAscii("%1", aStr);
+
+ return aStr2;
+ }
+
+ // dx=0.00 dy=0.00 // Beide Seiten Bezier
+ // dx=0.00 dy=0.00 l=0.00 0.00ø // Anfang oder Ende oder eine Seite Bezier bzw. Hebel
+ // dx=0.00 dy=0.00 l=0.00 0.00ø / l=0.00 0.00ø // Mittendrin
+ XubString aMetr;
+ Point aBeg(rDrag.GetStart());
+ Point aNow(rDrag.GetNow());
+
+ aStr = String();
+ aStr.AppendAscii("dx=");
+ mrSdrPathObject.GetModel()->TakeMetricStr(aNow.X() - aBeg.X(), aMetr, TRUE);
+ aStr += aMetr;
+
+ aStr.AppendAscii(" dy=");
+ mrSdrPathObject.GetModel()->TakeMetricStr(aNow.Y() - aBeg.Y(), aMetr, TRUE);
+ aStr += aMetr;
+
+ if(!pDragData->IsMultiPointDrag())
+ {
+ UINT16 nPntNum((sal_uInt16)pHdl->GetPointNum());
+ const XPolygon& rXPoly = aPathPolygon[(sal_uInt16)rDrag.GetHdl()->GetPolyNum()];
+ UINT16 nPntAnz((sal_uInt16)rXPoly.GetPointCount());
+ BOOL bClose(IsClosed(meObjectKind));
+
+ if(bClose)
+ nPntAnz--;
+
+ if(pHdl->IsPlusHdl())
+ {
+ // Hebel
+ UINT16 nRef(nPntNum);
+
+ if(rXPoly.IsControl(nPntNum + 1))
+ nRef--;
+ else
+ nRef++;
+
+ aNow -= rXPoly[nRef];
+
+ INT32 nLen(GetLen(aNow));
+ aStr.AppendAscii(" l=");
+ mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE);
+ aStr += aMetr;
+
+ INT32 nWink(GetAngle(aNow));
+ aStr += sal_Unicode(' ');
+ mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr);
+ aStr += aMetr;
+ }
+ else if(nPntAnz > 1)
+ {
+ UINT16 nPntMax(nPntAnz - 1);
+ Point aPt1,aPt2;
+ BOOL bIsClosed(IsClosed(meObjectKind));
+ BOOL bPt1(nPntNum > 0);
+ BOOL bPt2(nPntNum < nPntMax);
+
+ if(bIsClosed && nPntAnz > 2)
+ {
+ bPt1 = TRUE;
+ bPt2 = TRUE;
+ }
+
+ UINT16 nPt1,nPt2;
+
+ if(nPntNum > 0)
+ nPt1 = nPntNum - 1;
+ else
+ nPt1 = nPntMax;
+
+ if(nPntNum < nPntMax)
+ nPt2 = nPntNum + 1;
+ else
+ nPt2 = 0;
+
+ if(bPt1 && rXPoly.IsControl(nPt1))
+ bPt1 = FALSE; // Keine Anzeige
+
+ if(bPt2 && rXPoly.IsControl(nPt2))
+ bPt2 = FALSE; // von Bezierdaten
+
+ if(bPt1)
+ {
+ Point aPt(aNow);
+ aPt -= rXPoly[nPt1];
+
+ INT32 nLen(GetLen(aPt));
+ aStr.AppendAscii(" l=");
+ mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE);
+ aStr += aMetr;
+
+ INT32 nWink(GetAngle(aPt));
+ aStr += sal_Unicode(' ');
+ mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr);
+ aStr += aMetr;
+ }
+
+ if(bPt2)
+ {
+ if(bPt1)
+ aStr.AppendAscii(" / ");
+ else
+ aStr.AppendAscii(" ");
+
+ Point aPt(aNow);
+ aPt -= rXPoly[nPt2];
+
+ INT32 nLen(GetLen(aPt));
+ aStr.AppendAscii("l=");
+ mrSdrPathObject.GetModel()->TakeMetricStr(nLen, aMetr, TRUE);
+ aStr += aMetr;
+
+ INT32 nWink(GetAngle(aPt));
+ aStr += sal_Unicode(' ');
+ mrSdrPathObject.GetModel()->TakeWinkStr(nWink, aMetr);
+ aStr += aMetr;
+ }
+ }
+ }
+ }
+
+ return aStr;
+}
+
+basegfx::B2DPolyPolygon ImpPathForDragAndCreate::getSpecialDragPoly(const SdrDragStat& rDrag) const
+{
+ if(!mpSdrPathDragData || !mpSdrPathDragData->bValid)
+ {
+ DBG_ERROR("ImpPathForDragAndCreate::MovDrag(): ImpSdrPathDragData ist ungueltig");
+ return basegfx::B2DPolyPolygon();
+ }
+
+ XPolyPolygon aRetval;
+
+ if(mpSdrPathDragData->IsMultiPointDrag())
+ {
+ aRetval.Insert(mpSdrPathDragData->maMove);
+ }
+ else
+ {
+ const XPolygon& rXP=aPathPolygon[(sal_uInt16)rDrag.GetHdl()->GetPolyNum()];
+ if (rXP.GetPointCount()<=2) { //|| rXPoly.GetFlags(1)==XPOLY_CONTROL && rXPoly.GetPointCount()<=4
+ XPolygon aXPoly(rXP);
+ aXPoly[(sal_uInt16)rDrag.GetHdl()->GetPointNum()]=rDrag.GetNow();
+ aRetval.Insert(aXPoly);
+ return aRetval.getB2DPolyPolygon();
+ }
+ // Div. Daten lokal Kopieren fuer weniger Code und schnelleren Zugriff
+ bool bClosed =mpSdrPathDragData->bClosed ; // geschlossenes Objekt?
+ USHORT nPntAnz =mpSdrPathDragData->nPntAnz ; // Punktanzahl
+ USHORT nPnt =mpSdrPathDragData->nPnt ; // Punktnummer innerhalb des Polygons
+ bool bBegPnt =mpSdrPathDragData->bBegPnt ; // Gedraggter Punkt ist der Anfangspunkt einer Polyline
+ bool bEndPnt =mpSdrPathDragData->bEndPnt ; // Gedraggter Punkt ist der Endpunkt einer Polyline
+ USHORT nPrevPnt =mpSdrPathDragData->nPrevPnt ; // Index des vorherigen Punkts
+ USHORT nNextPnt =mpSdrPathDragData->nNextPnt ; // Index des naechsten Punkts
+ bool bPrevIsBegPnt =mpSdrPathDragData->bPrevIsBegPnt ; // Vorheriger Punkt ist Anfangspunkt einer Polyline
+ bool bNextIsEndPnt =mpSdrPathDragData->bNextIsEndPnt ; // Folgepunkt ist Endpunkt einer Polyline
+ USHORT nPrevPrevPnt =mpSdrPathDragData->nPrevPrevPnt ; // Index des vorvorherigen Punkts
+ USHORT nNextNextPnt =mpSdrPathDragData->nNextNextPnt ; // Index des uebernaechsten Punkts
+ bool bControl =mpSdrPathDragData->bControl ; // Punkt ist ein Kontrollpunkt
+ //bool bIsPrevControl=mpSdrPathDragData->bIsPrevControl; // Punkt ist Kontrollpunkt vor einem Stuetzpunkt
+ bool bIsNextControl =mpSdrPathDragData->bIsNextControl; // Punkt ist Kontrollpunkt hinter einem Stuetzpunkt
+ bool bPrevIsControl =mpSdrPathDragData->bPrevIsControl; // Falls nPnt ein StPnt: Davor ist ein Kontrollpunkt
+ bool bNextIsControl =mpSdrPathDragData->bNextIsControl; // Falls nPnt ein StPnt: Dahinter ist ein Kontrollpunkt
+ XPolygon aXPoly(mpSdrPathDragData->aXP);
+ XPolygon aLine1(2);
+ XPolygon aLine2(2);
+ XPolygon aLine3(2);
+ XPolygon aLine4(2);
+ if (bControl) {
+ aLine1[1]=mpSdrPathDragData->aXP[nPnt];
+ if (bIsNextControl) { // bin ich Kontrollpunkt hinter der Stuetzstelle?
+ aLine1[0]=mpSdrPathDragData->aXP[nPrevPnt];
+ aLine2[0]=mpSdrPathDragData->aXP[nNextNextPnt];
+ aLine2[1]=mpSdrPathDragData->aXP[nNextPnt];
+ if (mpSdrPathDragData->aXP.IsSmooth(nPrevPnt) && !bPrevIsBegPnt && mpSdrPathDragData->aXP.IsControl(nPrevPrevPnt)) {
+ aXPoly.Insert(0,rXP[mpSdrPathDragData->nPrevPrevPnt0-1],XPOLY_CONTROL);
+ aXPoly.Insert(0,rXP[mpSdrPathDragData->nPrevPrevPnt0-2],XPOLY_NORMAL);
+ // Hebellienien fuer das gegenueberliegende Kurvensegment
+ aLine3[0]=mpSdrPathDragData->aXP[nPrevPnt];
+ aLine3[1]=mpSdrPathDragData->aXP[nPrevPrevPnt];
+ aLine4[0]=rXP[mpSdrPathDragData->nPrevPrevPnt0-2];
+ aLine4[1]=rXP[mpSdrPathDragData->nPrevPrevPnt0-1];
+ } else {
+ aXPoly.Remove(0,1);
+ }
+ } else { // ansonsten bin ich Kontrollpunkt vor der Stuetzstelle
+ aLine1[0]=mpSdrPathDragData->aXP[nNextPnt];
+ aLine2[0]=mpSdrPathDragData->aXP[nPrevPrevPnt];
+ aLine2[1]=mpSdrPathDragData->aXP[nPrevPnt];
+ if (mpSdrPathDragData->aXP.IsSmooth(nNextPnt) && !bNextIsEndPnt && mpSdrPathDragData->aXP.IsControl(nNextNextPnt)) {
+ aXPoly.Insert(XPOLY_APPEND,rXP[mpSdrPathDragData->nNextNextPnt0+1],XPOLY_CONTROL);
+ aXPoly.Insert(XPOLY_APPEND,rXP[mpSdrPathDragData->nNextNextPnt0+2],XPOLY_NORMAL);
+ // Hebellinien fuer das gegenueberliegende Kurvensegment
+ aLine3[0]=mpSdrPathDragData->aXP[nNextPnt];
+ aLine3[1]=mpSdrPathDragData->aXP[nNextNextPnt];
+ aLine4[0]=rXP[mpSdrPathDragData->nNextNextPnt0+2];
+ aLine4[1]=rXP[mpSdrPathDragData->nNextNextPnt0+1];
+ } else {
+ aXPoly.Remove(aXPoly.GetPointCount()-1,1);
+ }
+ }
+ } else { // ansonsten kein Kontrollpunkt
+ if (mpSdrPathDragData->bEliminate) {
+ aXPoly.Remove(2,1);
+ }
+ if (bPrevIsControl) aXPoly.Insert(0,rXP[mpSdrPathDragData->nPrevPrevPnt0-1],XPOLY_NORMAL);
+ else if (!bBegPnt && !bPrevIsBegPnt && mpSdrPathDragData->aXP.IsControl(nPrevPrevPnt)) {
+ aXPoly.Insert(0,rXP[mpSdrPathDragData->nPrevPrevPnt0-1],XPOLY_CONTROL);
+ aXPoly.Insert(0,rXP[mpSdrPathDragData->nPrevPrevPnt0-2],XPOLY_NORMAL);
+ } else {
+ aXPoly.Remove(0,1);
+ if (bBegPnt) aXPoly.Remove(0,1);
+ }
+ if (bNextIsControl) aXPoly.Insert(XPOLY_APPEND,rXP[mpSdrPathDragData->nNextNextPnt0+1],XPOLY_NORMAL);
+ else if (!bEndPnt && !bNextIsEndPnt && mpSdrPathDragData->aXP.IsControl(nNextNextPnt)) {
+ aXPoly.Insert(XPOLY_APPEND,rXP[mpSdrPathDragData->nNextNextPnt0+1],XPOLY_CONTROL);
+ aXPoly.Insert(XPOLY_APPEND,rXP[mpSdrPathDragData->nNextNextPnt0+2],XPOLY_NORMAL);
+ } else {
+ aXPoly.Remove(aXPoly.GetPointCount()-1,1);
+ if (bEndPnt) aXPoly.Remove(aXPoly.GetPointCount()-1,1);
+ }
+ if (bClosed) { // "Birnenproblem": 2 Linien, 1 Kurve, alles Smooth, Punkt zw. beiden Linien wird gedraggt
+ if (aXPoly.GetPointCount()>nPntAnz && aXPoly.IsControl(1)) {
+ USHORT a=aXPoly.GetPointCount();
+ aXPoly[a-2]=aXPoly[2]; aXPoly.SetFlags(a-2,aXPoly.GetFlags(2));
+ aXPoly[a-1]=aXPoly[3]; aXPoly.SetFlags(a-1,aXPoly.GetFlags(3));
+ aXPoly.Remove(0,3);
+ }
+ }
+ }
+ aRetval.Insert(aXPoly);
+ if (aLine1.GetPointCount()>1) aRetval.Insert(aLine1);
+ if (aLine2.GetPointCount()>1) aRetval.Insert(aLine2);
+ if (aLine3.GetPointCount()>1) aRetval.Insert(aLine3);
+ if (aLine4.GetPointCount()>1) aRetval.Insert(aLine4);
+ }
+
+ return aRetval.getB2DPolyPolygon();
+}
+
+bool ImpPathForDragAndCreate::BegCreate(SdrDragStat& rStat)
+{
+ bool bFreeHand(IsFreeHand(meObjectKind));
+ rStat.SetNoSnap(bFreeHand);
+ rStat.SetOrtho8Possible();
+ aPathPolygon.Clear();
+ mbCreating=TRUE;
+ bool bMakeStartPoint = true;
+ SdrView* pView=rStat.GetView();
+ if (pView!=NULL && pView->IsUseIncompatiblePathCreateInterface() &&
+ (meObjectKind==OBJ_POLY || meObjectKind==OBJ_PLIN || meObjectKind==OBJ_PATHLINE || meObjectKind==OBJ_PATHFILL)) {
+ bMakeStartPoint = false;
+ }
+ aPathPolygon.Insert(XPolygon());
+ aPathPolygon[0][0]=rStat.GetStart();
+ if (bMakeStartPoint) {
+ aPathPolygon[0][1]=rStat.GetNow();
+ }
+ ImpPathCreateUser* pU=new ImpPathCreateUser;
+ pU->eStartKind=meObjectKind;
+ pU->eAktKind=meObjectKind;
+ rStat.SetUser(pU);
+ return true;
+}
+
+bool ImpPathForDragAndCreate::MovCreate(SdrDragStat& rStat)
+{
+ ImpPathCreateUser* pU=(ImpPathCreateUser*)rStat.GetUser();
+ SdrView* pView=rStat.GetView();
+ XPolygon& rXPoly=aPathPolygon[aPathPolygon.Count()-1];
+ if (pView!=NULL && pView->IsCreateMode()) {
+ // ggf. auf anderes CreateTool umschalten
+ UINT16 nIdent;
+ UINT32 nInvent;
+ pView->TakeCurrentObj(nIdent,nInvent);
+ if (nInvent==SdrInventor && pU->eAktKind!=(SdrObjKind)nIdent) {
+ SdrObjKind eNewKind=(SdrObjKind)nIdent;
+ switch (eNewKind) {
+ case OBJ_CARC: case OBJ_CIRC: case OBJ_CCUT: case OBJ_SECT: eNewKind=OBJ_CARC;
+ case OBJ_RECT:
+ case OBJ_LINE: case OBJ_PLIN: case OBJ_POLY:
+ case OBJ_PATHLINE: case OBJ_PATHFILL:
+ case OBJ_FREELINE: case OBJ_FREEFILL:
+ case OBJ_SPLNLINE: case OBJ_SPLNFILL: {
+ pU->eAktKind=eNewKind;
+ pU->bMixedCreate=TRUE;
+ pU->nBezierStartPoint=rXPoly.GetPointCount();
+ if (pU->nBezierStartPoint>0) pU->nBezierStartPoint--;
+ } break;
+ default: break;
+ } // switch
+ }
+ }
+ USHORT nActPoint=rXPoly.GetPointCount();
+ if (aPathPolygon.Count()>1 && rStat.IsMouseDown() && nActPoint<2) {
+ rXPoly[0]=rStat.GetPos0();
+ rXPoly[1]=rStat.GetNow();
+ nActPoint=2;
+ }
+ if (nActPoint==0) {
+ rXPoly[0]=rStat.GetPos0();
+ } else nActPoint--;
+ bool bFreeHand=IsFreeHand(pU->eAktKind);
+ rStat.SetNoSnap(bFreeHand /*|| (pU->bMixed && pU->eAktKind==OBJ_LINE)*/);
+ rStat.SetOrtho8Possible(pU->eAktKind!=OBJ_CARC && pU->eAktKind!=OBJ_RECT && (!pU->bMixedCreate || pU->eAktKind!=OBJ_LINE));
+ Point aActMerk(rXPoly[nActPoint]);
+ rXPoly[nActPoint]=rStat.Now();
+ if (!pU->bMixedCreate && pU->eStartKind==OBJ_LINE && rXPoly.GetPointCount()>=1) {
+ Point aPt(rStat.Start());
+ if (pView!=NULL && pView->IsCreate1stPointAsCenter()) {
+ aPt+=aPt;
+ aPt-=rStat.Now();
+ }
+ rXPoly[0]=aPt;
+ }
+ OutputDevice* pOut=pView==NULL ? NULL : pView->GetFirstOutputDevice(); // GetWin(0);
+ if (bFreeHand) {
+ if (pU->nBezierStartPoint>nActPoint) pU->nBezierStartPoint=nActPoint;
+ if (rStat.IsMouseDown() && nActPoint>0) {
+ // keine aufeinanderfolgenden Punkte an zu Nahe gelegenen Positionen zulassen
+ long nMinDist=1;
+ if (pView!=NULL) nMinDist=pView->GetFreeHandMinDistPix();
+ if (pOut!=NULL) nMinDist=pOut->PixelToLogic(Size(nMinDist,0)).Width();
+ if (nMinDist<1) nMinDist=1;
+
+ Point aPt0(rXPoly[nActPoint-1]);
+ Point aPt1(rStat.Now());
+ long dx=aPt0.X()-aPt1.X(); if (dx<0) dx=-dx;
+ long dy=aPt0.Y()-aPt1.Y(); if (dy<0) dy=-dy;
+ if (dx<nMinDist && dy<nMinDist) return FALSE;
+
+ // folgendes ist aus EndCreate kopiert (nur kleine Modifikationen)
+ // und sollte dann mal in eine Methode zusammengefasst werden:
+
+ if (nActPoint-pU->nBezierStartPoint>=3 && ((nActPoint-pU->nBezierStartPoint)%3)==0) {
+ rXPoly.PointsToBezier(nActPoint-3);
+ rXPoly.SetFlags(nActPoint-1,XPOLY_CONTROL);
+ rXPoly.SetFlags(nActPoint-2,XPOLY_CONTROL);
+
+ if (nActPoint>=6 && rXPoly.IsControl(nActPoint-4)) {
+ rXPoly.CalcTangent(nActPoint-3,nActPoint-4,nActPoint-2);
+ rXPoly.SetFlags(nActPoint-3,XPOLY_SMOOTH);
+ }
+ }
+ rXPoly[nActPoint+1]=rStat.Now();
+ rStat.NextPoint();
+ } else {
+ pU->nBezierStartPoint=nActPoint;
+ }
+ }
+
+ pU->ResetFormFlags();
+ if (IsBezier(pU->eAktKind)) {
+ if (nActPoint>=2) {
+ pU->CalcBezier(rXPoly[nActPoint-1],rXPoly[nActPoint],rXPoly[nActPoint-1]-rXPoly[nActPoint-2],rStat.IsMouseDown());
+ } else if (pU->bBezHasCtrl0) {
+ pU->CalcBezier(rXPoly[nActPoint-1],rXPoly[nActPoint],pU->aBezControl0-rXPoly[nActPoint-1],rStat.IsMouseDown());
+ }
+ }
+ if (pU->eAktKind==OBJ_CARC && nActPoint>=2) {
+ pU->CalcCircle(rXPoly[nActPoint-1],rXPoly[nActPoint],rXPoly[nActPoint-1]-rXPoly[nActPoint-2],pView);
+ }
+ if (pU->eAktKind==OBJ_LINE && nActPoint>=2) {
+ pU->CalcLine(rXPoly[nActPoint-1],rXPoly[nActPoint],rXPoly[nActPoint-1]-rXPoly[nActPoint-2],pView);
+ }
+ if (pU->eAktKind==OBJ_RECT && nActPoint>=2) {
+ pU->CalcRect(rXPoly[nActPoint-1],rXPoly[nActPoint],rXPoly[nActPoint-1]-rXPoly[nActPoint-2],pView);
+ }
+
+ return true;
+}
+
+bool ImpPathForDragAndCreate::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ ImpPathCreateUser* pU=(ImpPathCreateUser*)rStat.GetUser();
+ bool bRet = false;
+ SdrView* pView=rStat.GetView();
+ bool bIncomp=pView!=NULL && pView->IsUseIncompatiblePathCreateInterface();
+ XPolygon& rXPoly=aPathPolygon[aPathPolygon.Count()-1];
+ USHORT nActPoint=rXPoly.GetPointCount()-1;
+ Point aAktMerk(rXPoly[nActPoint]);
+ rXPoly[nActPoint]=rStat.Now();
+ if (!pU->bMixedCreate && pU->eStartKind==OBJ_LINE) {
+ if (rStat.GetPointAnz()>=2) eCmd=SDRCREATE_FORCEEND;
+ bRet = eCmd==SDRCREATE_FORCEEND;
+ if (bRet) {
+ mbCreating = FALSE;
+ delete pU;
+ rStat.SetUser(NULL);
+ }
+ return bRet;
+ }
+
+ if (!pU->bMixedCreate && IsFreeHand(pU->eStartKind)) {
+ if (rStat.GetPointAnz()>=2) eCmd=SDRCREATE_FORCEEND;
+ bRet=eCmd==SDRCREATE_FORCEEND;
+ if (bRet) {
+ mbCreating=FALSE;
+ delete pU;
+ rStat.SetUser(NULL);
+ }
+ return bRet;
+ }
+ if (eCmd==SDRCREATE_NEXTPOINT || eCmd==SDRCREATE_NEXTOBJECT) {
+ // keine aufeinanderfolgenden Punkte an identischer Position zulassen
+ if (nActPoint==0 || rStat.Now()!=rXPoly[nActPoint-1]) {
+ if (bIncomp) {
+ if (pU->nBezierStartPoint>nActPoint) pU->nBezierStartPoint=nActPoint;
+ if (IsBezier(pU->eAktKind) && nActPoint-pU->nBezierStartPoint>=3 && ((nActPoint-pU->nBezierStartPoint)%3)==0) {
+ rXPoly.PointsToBezier(nActPoint-3);
+ rXPoly.SetFlags(nActPoint-1,XPOLY_CONTROL);
+ rXPoly.SetFlags(nActPoint-2,XPOLY_CONTROL);
+
+ if (nActPoint>=6 && rXPoly.IsControl(nActPoint-4)) {
+ rXPoly.CalcTangent(nActPoint-3,nActPoint-4,nActPoint-2);
+ rXPoly.SetFlags(nActPoint-3,XPOLY_SMOOTH);
+ }
+ }
+ } else {
+ if (nActPoint==1 && IsBezier(pU->eAktKind) && !pU->bBezHasCtrl0) {
+ pU->aBezControl0=rStat.GetNow();;
+ pU->bBezHasCtrl0=TRUE;
+ nActPoint--;
+ }
+ if (pU->IsFormFlag()) {
+ USHORT nPtAnz0=rXPoly.GetPointCount();
+ rXPoly.Remove(nActPoint-1,2); // die letzten beiden Punkte entfernen und durch die Form ersetzen
+ rXPoly.Insert(XPOLY_APPEND,pU->GetFormPoly());
+ USHORT nPtAnz1=rXPoly.GetPointCount();
+ for (USHORT i=nPtAnz0+1; i<nPtAnz1-1; i++) { // Damit BckAction richtig funktioniert
+ if (!rXPoly.IsControl(i)) rStat.NextPoint();
+ }
+ nActPoint=rXPoly.GetPointCount()-1;
+ }
+ }
+ nActPoint++;
+ rXPoly[nActPoint]=rStat.GetNow();
+ }
+ if (eCmd==SDRCREATE_NEXTOBJECT) {
+ if (rXPoly.GetPointCount()>=2) {
+ pU->bBezHasCtrl0=FALSE;
+ // nur einzelnes Polygon kann offen sein, deshalb schliessen
+ rXPoly[nActPoint]=rXPoly[0];
+ XPolygon aXP;
+ aXP[0]=rStat.GetNow();
+ aPathPolygon.Insert(aXP);
+ }
+ }
+ }
+
+ USHORT nPolyAnz=aPathPolygon.Count();
+ if (nPolyAnz!=0) {
+ // den letzten Punkt ggf. wieder loeschen
+ if (eCmd==SDRCREATE_FORCEEND) {
+ XPolygon& rXP=aPathPolygon[nPolyAnz-1];
+ USHORT nPtAnz=rXP.GetPointCount();
+ if (nPtAnz>=2) {
+ if (!rXP.IsControl(nPtAnz-2)) {
+ if (rXP[nPtAnz-1]==rXP[nPtAnz-2]) {
+ rXP.Remove(nPtAnz-1,1);
+ }
+ } else {
+ if (rXP[nPtAnz-3]==rXP[nPtAnz-2]) {
+ rXP.Remove(nPtAnz-3,3);
+ }
+ }
+ }
+ }
+ for (USHORT nPolyNum=nPolyAnz; nPolyNum>0;) {
+ nPolyNum--;
+ XPolygon& rXP=aPathPolygon[nPolyNum];
+ USHORT nPtAnz=rXP.GetPointCount();
+ // Polygone mit zu wenig Punkten werden geloescht
+ if (nPolyNum<nPolyAnz-1 || eCmd==SDRCREATE_FORCEEND) {
+ if (nPtAnz<2) aPathPolygon.Remove(nPolyNum);
+ }
+ }
+ }
+ pU->ResetFormFlags();
+ bRet=eCmd==SDRCREATE_FORCEEND;
+ if (bRet) {
+ mbCreating=FALSE;
+ delete pU;
+ rStat.SetUser(NULL);
+ }
+ return bRet;
+}
+
+bool ImpPathForDragAndCreate::BckCreate(SdrDragStat& rStat)
+{
+ ImpPathCreateUser* pU=(ImpPathCreateUser*)rStat.GetUser();
+ if (aPathPolygon.Count()>0) {
+ XPolygon& rXPoly=aPathPolygon[aPathPolygon.Count()-1];
+ USHORT nActPoint=rXPoly.GetPointCount();
+ if (nActPoint>0) {
+ nActPoint--;
+ // Das letzte Stueck einer Bezierkurve wird erstmal zu 'ner Linie
+ rXPoly.Remove(nActPoint,1);
+ if (nActPoint>=3 && rXPoly.IsControl(nActPoint-1)) {
+ // Beziersegment am Ende sollte zwar nicht vorkommen, aber falls doch ...
+ rXPoly.Remove(nActPoint-1,1);
+ if (rXPoly.IsControl(nActPoint-2)) rXPoly.Remove(nActPoint-2,1);
+ }
+ }
+ nActPoint=rXPoly.GetPointCount();
+ if (nActPoint>=4) { // Kein Beziersegment am Ende
+ nActPoint--;
+ if (rXPoly.IsControl(nActPoint-1)) {
+ rXPoly.Remove(nActPoint-1,1);
+ if (rXPoly.IsControl(nActPoint-2)) rXPoly.Remove(nActPoint-2,1);
+ }
+ }
+ if (rXPoly.GetPointCount()<2) {
+ aPathPolygon.Remove(aPathPolygon.Count()-1);
+ }
+ if (aPathPolygon.Count()>0) {
+ XPolygon& rLocalXPoly=aPathPolygon[aPathPolygon.Count()-1];
+ USHORT nLocalActPoint=rLocalXPoly.GetPointCount();
+ if (nLocalActPoint>0) {
+ nLocalActPoint--;
+ rLocalXPoly[nLocalActPoint]=rStat.Now();
+ }
+ }
+ }
+ pU->ResetFormFlags();
+ return aPathPolygon.Count()!=0;
+}
+
+void ImpPathForDragAndCreate::BrkCreate(SdrDragStat& rStat)
+{
+ ImpPathCreateUser* pU=(ImpPathCreateUser*)rStat.GetUser();
+ aPathPolygon.Clear();
+ mbCreating=FALSE;
+ delete pU;
+ rStat.SetUser(NULL);
+}
+
+basegfx::B2DPolyPolygon ImpPathForDragAndCreate::TakeObjectPolyPolygon(const SdrDragStat& rDrag) const
+{
+ basegfx::B2DPolyPolygon aRetval(aPathPolygon.getB2DPolyPolygon());
+ SdrView* pView = rDrag.GetView();
+
+ if(pView && pView->IsUseIncompatiblePathCreateInterface())
+ return aRetval;
+
+ ImpPathCreateUser* pU = (ImpPathCreateUser*)rDrag.GetUser();
+ basegfx::B2DPolygon aNewPolygon(aRetval.count() ? aRetval.getB2DPolygon(aRetval.count() - 1L) : basegfx::B2DPolygon());
+
+ if(pU->IsFormFlag() && aNewPolygon.count() > 1L)
+ {
+ // remove last segment and replace with current
+ // do not forget to rescue the previous control point which will be lost when
+ // the point it's associated with is removed
+ const sal_uInt32 nChangeIndex(aNewPolygon.count() - 2);
+ const basegfx::B2DPoint aSavedPrevCtrlPoint(aNewPolygon.getPrevControlPoint(nChangeIndex));
+
+ aNewPolygon.remove(nChangeIndex, 2L);
+ aNewPolygon.append(pU->GetFormPoly().getB2DPolygon());
+
+ if(nChangeIndex < aNewPolygon.count())
+ {
+ // if really something was added, set the saved prev control point at the
+ // point where it belongs
+ aNewPolygon.setPrevControlPoint(nChangeIndex, aSavedPrevCtrlPoint);
+ }
+ }
+
+ if(aRetval.count())
+ {
+ aRetval.setB2DPolygon(aRetval.count() - 1L, aNewPolygon);
+ }
+ else
+ {
+ aRetval.append(aNewPolygon);
+ }
+
+ return aRetval;
+}
+
+basegfx::B2DPolyPolygon ImpPathForDragAndCreate::TakeDragPolyPolygon(const SdrDragStat& rDrag) const
+{
+ basegfx::B2DPolyPolygon aRetval;
+ SdrView* pView = rDrag.GetView();
+
+ if(pView && pView->IsUseIncompatiblePathCreateInterface())
+ return aRetval;
+
+ ImpPathCreateUser* pU = (ImpPathCreateUser*)rDrag.GetUser();
+
+ if(pU && pU->bBezier && rDrag.IsMouseDown())
+ {
+ // no more XOR, no need for complicated helplines
+ basegfx::B2DPolygon aHelpline;
+ aHelpline.append(basegfx::B2DPoint(pU->aBezCtrl2.X(), pU->aBezCtrl2.Y()));
+ aHelpline.append(basegfx::B2DPoint(pU->aBezEnd.X(), pU->aBezEnd.Y()));
+ aRetval.append(aHelpline);
+ }
+
+ return aRetval;
+}
+
+Pointer ImpPathForDragAndCreate::GetCreatePointer() const
+{
+ switch (meObjectKind) {
+ case OBJ_LINE : return Pointer(POINTER_DRAW_LINE);
+ case OBJ_POLY : return Pointer(POINTER_DRAW_POLYGON);
+ case OBJ_PLIN : return Pointer(POINTER_DRAW_POLYGON);
+ case OBJ_PATHLINE: return Pointer(POINTER_DRAW_BEZIER);
+ case OBJ_PATHFILL: return Pointer(POINTER_DRAW_BEZIER);
+ case OBJ_FREELINE: return Pointer(POINTER_DRAW_FREEHAND);
+ case OBJ_FREEFILL: return Pointer(POINTER_DRAW_FREEHAND);
+ case OBJ_SPLNLINE: return Pointer(POINTER_DRAW_FREEHAND);
+ case OBJ_SPLNFILL: return Pointer(POINTER_DRAW_FREEHAND);
+ case OBJ_PATHPOLY: return Pointer(POINTER_DRAW_POLYGON);
+ case OBJ_PATHPLIN: return Pointer(POINTER_DRAW_POLYGON);
+ default: break;
+ } // switch
+ return Pointer(POINTER_CROSS);
+}
+
+/*************************************************************************/
+
+SdrPathObjGeoData::SdrPathObjGeoData()
+{
+}
+
+SdrPathObjGeoData::~SdrPathObjGeoData()
+{
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// DrawContact section
+
+sdr::contact::ViewContact* SdrPathObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfSdrPathObj(*this);
+}
+
+/*************************************************************************/
+
+TYPEINIT1(SdrPathObj,SdrTextObj);
+
+SdrPathObj::SdrPathObj(SdrObjKind eNewKind)
+: meKind(eNewKind),
+ mpDAC(0L)
+{
+ bClosedObj = IsClosed();
+}
+
+SdrPathObj::SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly)
+: maPathPolygon(rPathPoly),
+ meKind(eNewKind),
+ mpDAC(0L)
+{
+ bClosedObj = IsClosed();
+ ImpForceKind();
+}
+
+SdrPathObj::~SdrPathObj()
+{
+ impDeleteDAC();
+}
+
+sal_Bool ImpIsLine(const basegfx::B2DPolyPolygon& rPolyPolygon)
+{
+ return (1L == rPolyPolygon.count() && 2L == rPolyPolygon.getB2DPolygon(0L).count());
+}
+
+Rectangle ImpGetBoundRect(const basegfx::B2DPolyPolygon& rPolyPolygon)
+{
+ basegfx::B2DRange aRange(basegfx::tools::getRange(rPolyPolygon));
+
+ return Rectangle(
+ FRound(aRange.getMinX()), FRound(aRange.getMinY()),
+ FRound(aRange.getMaxX()), FRound(aRange.getMaxY()));
+}
+
+void SdrPathObj::ImpForceLineWink()
+{
+ if(OBJ_LINE == meKind && ImpIsLine(GetPathPoly()))
+ {
+ const basegfx::B2DPolygon aPoly(GetPathPoly().getB2DPolygon(0L));
+ const basegfx::B2DPoint aB2DPoint0(aPoly.getB2DPoint(0L));
+ const basegfx::B2DPoint aB2DPoint1(aPoly.getB2DPoint(1L));
+ const Point aPoint0(FRound(aB2DPoint0.getX()), FRound(aB2DPoint0.getY()));
+ const Point aPoint1(FRound(aB2DPoint1.getX()), FRound(aB2DPoint1.getY()));
+ const Point aDelt(aPoint1 - aPoint0);
+
+ aGeo.nDrehWink=GetAngle(aDelt);
+ aGeo.nShearWink=0;
+ aGeo.RecalcSinCos();
+ aGeo.RecalcTan();
+
+ // #101412# for SdrTextObj, keep aRect up to date
+ aRect = Rectangle(aPoint0, aPoint1);
+ aRect.Justify();
+ }
+}
+
+void SdrPathObj::ImpForceKind()
+{
+ if (meKind==OBJ_PATHPLIN) meKind=OBJ_PLIN;
+ if (meKind==OBJ_PATHPOLY) meKind=OBJ_POLY;
+
+ if(GetPathPoly().areControlPointsUsed())
+ {
+ switch (meKind)
+ {
+ case OBJ_LINE: meKind=OBJ_PATHLINE; break;
+ case OBJ_PLIN: meKind=OBJ_PATHLINE; break;
+ case OBJ_POLY: meKind=OBJ_PATHFILL; break;
+ default: break;
+ }
+ }
+ else
+ {
+ switch (meKind)
+ {
+ case OBJ_PATHLINE: meKind=OBJ_PLIN; break;
+ case OBJ_FREELINE: meKind=OBJ_PLIN; break;
+ case OBJ_PATHFILL: meKind=OBJ_POLY; break;
+ case OBJ_FREEFILL: meKind=OBJ_POLY; break;
+ default: break;
+ }
+ }
+
+ if (meKind==OBJ_LINE && !ImpIsLine(GetPathPoly())) meKind=OBJ_PLIN;
+ if (meKind==OBJ_PLIN && ImpIsLine(GetPathPoly())) meKind=OBJ_LINE;
+
+ bClosedObj=IsClosed();
+
+ if (meKind==OBJ_LINE)
+ {
+ ImpForceLineWink();
+ }
+ else
+ {
+ // #i10659#, similar to #101412# but for polys with more than 2 points.
+ //
+ // Here i again need to fix something, because when Path-Polys are Copy-Pasted
+ // between Apps with different measurements (e.g. 100TH_MM and TWIPS) there is
+ // a scaling loop started from SdrExchangeView::Paste. This is principally nothing
+ // wrong, but aRect is wrong here and not even updated by RecalcSnapRect(). If
+ // this is the case, some size needs to be set here in aRect to avoid that the cyclus
+ // through Rect2Poly - Poly2Rect does something badly wrong since that cycle is
+ // BASED on aRect. That cycle is triggered in SdrTextObj::NbcResize() which is called
+ // from the local Resize() implementation.
+ //
+ // Basic problem is that the member aRect in SdrTextObj basically is a unrotated
+ // text rectangle for the text object itself and methods at SdrTextObj do handle it
+ // in that way. Many draw objects derived from SdrTextObj 'abuse' aRect as SnapRect
+ // which is basically wrong. To make the SdrText methods which deal with aRect directly
+ // work it is necessary to always keep aRect updated. This e.g. not done after a Clone()
+ // command for SdrPathObj. Since adding this update mechanism with #101412# to
+ // ImpForceLineWink() for lines was very successful, i add it to where ImpForceLineWink()
+ // was called, once here below and once on a 2nd place below.
+
+ // #i10659# for SdrTextObj, keep aRect up to date
+ if(GetPathPoly().count())
+ {
+ aRect = ImpGetBoundRect(GetPathPoly());
+ }
+ }
+
+ // #i75974# adapt polygon state to object type. This may include a reinterpretation
+ // of a closed geometry as open one, but with identical first and last point
+ for(sal_uInt32 a(0); a < maPathPolygon.count(); a++)
+ {
+ basegfx::B2DPolygon aCandidate(maPathPolygon.getB2DPolygon(a));
+
+ if((bool)IsClosed() != aCandidate.isClosed())
+ {
+ // #i80213# really change polygon geometry; else e.g. the last point which
+ // needs to be identical with the first one will be missing when opening
+ // due to OBJ_PATH type
+ if(aCandidate.isClosed())
+ {
+ basegfx::tools::openWithGeometryChange(aCandidate);
+ }
+ else
+ {
+ basegfx::tools::closeWithGeometryChange(aCandidate);
+ }
+
+ maPathPolygon.setB2DPolygon(a, aCandidate);
+ }
+ }
+}
+
+void SdrPathObj::ImpSetClosed(sal_Bool bClose)
+{
+ if(bClose)
+ {
+ switch (meKind)
+ {
+ case OBJ_LINE : meKind=OBJ_POLY; break;
+ case OBJ_PLIN : meKind=OBJ_POLY; break;
+ case OBJ_PATHLINE: meKind=OBJ_PATHFILL; break;
+ case OBJ_FREELINE: meKind=OBJ_FREEFILL; break;
+ case OBJ_SPLNLINE: meKind=OBJ_SPLNFILL; break;
+ default: break;
+ }
+
+ bClosedObj = TRUE;
+ }
+ else
+ {
+ switch (meKind)
+ {
+ case OBJ_POLY : meKind=OBJ_PLIN; break;
+ case OBJ_PATHFILL: meKind=OBJ_PATHLINE; break;
+ case OBJ_FREEFILL: meKind=OBJ_FREELINE; break;
+ case OBJ_SPLNFILL: meKind=OBJ_SPLNLINE; break;
+ default: break;
+ }
+
+ bClosedObj = FALSE;
+ }
+
+ ImpForceKind();
+}
+
+void SdrPathObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bNoContortion=FALSE;
+
+ bool bCanConv = !HasText() || ImpCanConvTextToCurve();
+ bool bIsPath = IsBezier() || IsSpline();
+
+ rInfo.bEdgeRadiusAllowed = FALSE;
+ rInfo.bCanConvToPath = bCanConv && !bIsPath;
+ rInfo.bCanConvToPoly = bCanConv && bIsPath;
+ rInfo.bCanConvToContour = !IsFontwork() && (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
+}
+
+UINT16 SdrPathObj::GetObjIdentifier() const
+{
+ return USHORT(meKind);
+}
+
+void SdrPathObj::operator=(const SdrObject& rObj)
+{
+ SdrTextObj::operator=(rObj);
+ SdrPathObj& rPath=(SdrPathObj&)rObj;
+ maPathPolygon=rPath.GetPathPoly();
+}
+
+void SdrPathObj::TakeObjNameSingul(XubString& rName) const
+{
+ if(OBJ_LINE == meKind)
+ {
+ sal_uInt16 nId(STR_ObjNameSingulLINE);
+
+ if(ImpIsLine(GetPathPoly()))
+ {
+ const basegfx::B2DPolygon aPoly(GetPathPoly().getB2DPolygon(0L));
+ const basegfx::B2DPoint aB2DPoint0(aPoly.getB2DPoint(0L));
+ const basegfx::B2DPoint aB2DPoint1(aPoly.getB2DPoint(1L));
+ const Point aPoint0(FRound(aB2DPoint0.getX()), FRound(aB2DPoint0.getY()));
+ const Point aPoint1(FRound(aB2DPoint0.getX()), FRound(aB2DPoint0.getY()));
+
+ if(aB2DPoint0 != aB2DPoint1)
+ {
+ if(aB2DPoint0.getY() == aB2DPoint1.getY())
+ {
+ nId = STR_ObjNameSingulLINE_Hori;
+ }
+ else if(aB2DPoint0.getX() == aB2DPoint1.getX())
+ {
+ nId = STR_ObjNameSingulLINE_Vert;
+ }
+ else
+ {
+ const double fDx(fabs(aB2DPoint0.getX() - aB2DPoint1.getX()));
+ const double fDy(fabs(aB2DPoint0.getY() - aB2DPoint1.getY()));
+
+ if(fDx == fDy)
+ {
+ nId = STR_ObjNameSingulLINE_Diag;
+ }
+ }
+ }
+ }
+
+ rName = ImpGetResStr(nId);
+ }
+ else if(OBJ_PLIN == meKind || OBJ_POLY == meKind)
+ {
+ const sal_Bool bClosed(OBJ_POLY == meKind);
+ sal_uInt16 nId(0);
+
+ if(mpDAC && mpDAC->IsCreating())
+ {
+ if(bClosed)
+ {
+ nId = STR_ObjNameSingulPOLY;
+ }
+ else
+ {
+ nId = STR_ObjNameSingulPLIN;
+ }
+
+ rName = ImpGetResStr(nId);
+ }
+ else
+ {
+ // get point count
+ sal_uInt32 nPointCount(0L);
+ const sal_uInt32 nPolyCount(GetPathPoly().count());
+
+ for(sal_uInt32 a(0L); a < nPolyCount; a++)
+ {
+ nPointCount += GetPathPoly().getB2DPolygon(a).count();
+ }
+
+ if(bClosed)
+ {
+ nId = STR_ObjNameSingulPOLY_PntAnz;
+ }
+ else
+ {
+ nId = STR_ObjNameSingulPLIN_PntAnz;
+ }
+
+ rName = ImpGetResStr(nId);
+ sal_uInt16 nPos(rName.SearchAscii("%2")); // #i96537#
+
+ if(STRING_NOTFOUND != nPos)
+ {
+ rName.Erase(nPos, 2);
+ rName.Insert(UniString::CreateFromInt32(nPointCount), nPos);
+ }
+ }
+ }
+ else
+ {
+ switch (meKind)
+ {
+ case OBJ_PATHLINE: rName=ImpGetResStr(STR_ObjNameSingulPATHLINE); break;
+ case OBJ_FREELINE: rName=ImpGetResStr(STR_ObjNameSingulFREELINE); break;
+ case OBJ_SPLNLINE: rName=ImpGetResStr(STR_ObjNameSingulNATSPLN); break;
+ case OBJ_PATHFILL: rName=ImpGetResStr(STR_ObjNameSingulPATHFILL); break;
+ case OBJ_FREEFILL: rName=ImpGetResStr(STR_ObjNameSingulFREEFILL); break;
+ case OBJ_SPLNFILL: rName=ImpGetResStr(STR_ObjNameSingulPERSPLN); break;
+ default: break;
+ }
+ }
+
+ String aName(GetName());
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+void SdrPathObj::TakeObjNamePlural(XubString& rName) const
+{
+ switch(meKind)
+ {
+ case OBJ_LINE : rName=ImpGetResStr(STR_ObjNamePluralLINE ); break;
+ case OBJ_PLIN : rName=ImpGetResStr(STR_ObjNamePluralPLIN ); break;
+ case OBJ_POLY : rName=ImpGetResStr(STR_ObjNamePluralPOLY ); break;
+ case OBJ_PATHLINE: rName=ImpGetResStr(STR_ObjNamePluralPATHLINE); break;
+ case OBJ_FREELINE: rName=ImpGetResStr(STR_ObjNamePluralFREELINE); break;
+ case OBJ_SPLNLINE: rName=ImpGetResStr(STR_ObjNamePluralNATSPLN); break;
+ case OBJ_PATHFILL: rName=ImpGetResStr(STR_ObjNamePluralPATHFILL); break;
+ case OBJ_FREEFILL: rName=ImpGetResStr(STR_ObjNamePluralFREEFILL); break;
+ case OBJ_SPLNFILL: rName=ImpGetResStr(STR_ObjNamePluralPERSPLN); break;
+ default: break;
+ }
+}
+
+basegfx::B2DPolyPolygon SdrPathObj::TakeXorPoly() const
+{
+ return GetPathPoly();
+}
+
+sal_uInt32 SdrPathObj::GetHdlCount() const
+{
+ sal_uInt32 nRetval(0L);
+ const sal_uInt32 nPolyCount(GetPathPoly().count());
+
+ for(sal_uInt32 a(0L); a < nPolyCount; a++)
+ {
+ nRetval += GetPathPoly().getB2DPolygon(a).count();
+ }
+
+ return nRetval;
+}
+
+SdrHdl* SdrPathObj::GetHdl(sal_uInt32 nHdlNum) const
+{
+ // #i73248#
+ // Warn the user that this is ineffective and show alternatives. Should not be used at all.
+ OSL_ENSURE(false, "SdrPathObj::GetHdl(): ineffective, use AddToHdlList instead (!)");
+
+ // to have an alternative, get single handle using the ineffective way
+ SdrHdl* pRetval = 0;
+ SdrHdlList aLocalList(0);
+ AddToHdlList(aLocalList);
+ const sal_uInt32 nHdlCount(aLocalList.GetHdlCount());
+
+ if(nHdlCount && nHdlNum < nHdlCount)
+ {
+ // remove and remember. The other created handles will be deleted again with the
+ // destruction of the local list
+ pRetval = aLocalList.RemoveHdl(nHdlNum);
+ }
+
+ return pRetval;
+}
+
+void SdrPathObj::AddToHdlList(SdrHdlList& rHdlList) const
+{
+ // keep old stuff to be able to keep old SdrHdl stuff, too
+ const XPolyPolygon aOldPathPolygon(GetPathPoly());
+ USHORT nPolyCnt=aOldPathPolygon.Count();
+ bool bClosed=IsClosed();
+ USHORT nIdx=0;
+
+ for (USHORT i=0; i<nPolyCnt; i++) {
+ const XPolygon& rXPoly=aOldPathPolygon.GetObject(i);
+ USHORT nPntCnt=rXPoly.GetPointCount();
+ if (bClosed && nPntCnt>1) nPntCnt--;
+
+ for (USHORT j=0; j<nPntCnt; j++) {
+ if (rXPoly.GetFlags(j)!=XPOLY_CONTROL) {
+ const Point& rPnt=rXPoly[j];
+ SdrHdl* pHdl=new SdrHdl(rPnt,HDL_POLY);
+ pHdl->SetPolyNum(i);
+ pHdl->SetPointNum(j);
+ pHdl->Set1PixMore(j==0);
+ pHdl->SetSourceHdlNum(nIdx);
+ nIdx++;
+ rHdlList.AddHdl(pHdl);
+ }
+ }
+ }
+}
+
+sal_uInt32 SdrPathObj::GetPlusHdlCount(const SdrHdl& rHdl) const
+{
+ // keep old stuff to be able to keep old SdrHdl stuff, too
+ const XPolyPolygon aOldPathPolygon(GetPathPoly());
+ sal_uInt16 nCnt = 0;
+ sal_uInt16 nPnt = (sal_uInt16)rHdl.GetPointNum();
+ sal_uInt16 nPolyNum = (sal_uInt16)rHdl.GetPolyNum();
+
+ if(nPolyNum < aOldPathPolygon.Count())
+ {
+ const XPolygon& rXPoly = aOldPathPolygon[nPolyNum];
+ sal_uInt16 nPntMax = rXPoly.GetPointCount();
+ if (nPntMax>0)
+ {
+ nPntMax--;
+ if (nPnt<=nPntMax)
+ {
+ if (rXPoly.GetFlags(nPnt)!=XPOLY_CONTROL)
+ {
+ if (nPnt==0 && IsClosed()) nPnt=nPntMax;
+ if (nPnt>0 && rXPoly.GetFlags(nPnt-1)==XPOLY_CONTROL) nCnt++;
+ if (nPnt==nPntMax && IsClosed()) nPnt=0;
+ if (nPnt<nPntMax && rXPoly.GetFlags(nPnt+1)==XPOLY_CONTROL) nCnt++;
+ }
+ }
+ }
+ }
+
+ return nCnt;
+}
+
+SdrHdl* SdrPathObj::GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlusNum) const
+{
+ // keep old stuff to be able to keep old SdrHdl stuff, too
+ const XPolyPolygon aOldPathPolygon(GetPathPoly());
+ SdrHdl* pHdl = 0L;
+ sal_uInt16 nPnt = (sal_uInt16)rHdl.GetPointNum();
+ sal_uInt16 nPolyNum = (sal_uInt16)rHdl.GetPolyNum();
+
+ if (nPolyNum<aOldPathPolygon.Count())
+ {
+ const XPolygon& rXPoly = aOldPathPolygon[nPolyNum];
+ sal_uInt16 nPntMax = rXPoly.GetPointCount();
+
+ if (nPntMax>0)
+ {
+ nPntMax--;
+ if (nPnt<=nPntMax)
+ {
+ pHdl=new SdrHdlBezWgt(&rHdl);
+ pHdl->SetPolyNum(rHdl.GetPolyNum());
+
+ if (nPnt==0 && IsClosed()) nPnt=nPntMax;
+ if (nPnt>0 && rXPoly.GetFlags(nPnt-1)==XPOLY_CONTROL && nPlusNum==0)
+ {
+ pHdl->SetPos(rXPoly[nPnt-1]);
+ pHdl->SetPointNum(nPnt-1);
+ }
+ else
+ {
+ if (nPnt==nPntMax && IsClosed()) nPnt=0;
+ if (nPnt<rXPoly.GetPointCount()-1 && rXPoly.GetFlags(nPnt+1)==XPOLY_CONTROL)
+ {
+ pHdl->SetPos(rXPoly[nPnt+1]);
+ pHdl->SetPointNum(nPnt+1);
+ }
+ }
+
+ pHdl->SetSourceHdlNum(rHdl.GetSourceHdlNum());
+ pHdl->SetPlusHdl(TRUE);
+ }
+ }
+ }
+ return pHdl;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrPathObj::hasSpecialDrag() const
+{
+ return true;
+}
+
+bool SdrPathObj::beginSpecialDrag(SdrDragStat& rDrag) const
+{
+ ImpPathForDragAndCreate aDragAndCreate(*((SdrPathObj*)this));
+
+ return aDragAndCreate.beginPathDrag(rDrag);
+}
+
+bool SdrPathObj::applySpecialDrag(SdrDragStat& rDrag)
+{
+ ImpPathForDragAndCreate aDragAndCreate(*this);
+ bool bRetval(aDragAndCreate.beginPathDrag(rDrag));
+
+ if(bRetval)
+ {
+ bRetval = aDragAndCreate.movePathDrag(rDrag);
+ }
+
+ if(bRetval)
+ {
+ bRetval = aDragAndCreate.endPathDrag(rDrag);
+ }
+
+ if(bRetval)
+ {
+ NbcSetPathPoly(aDragAndCreate.getModifiedPolyPolygon());
+ }
+
+ return bRetval;
+}
+
+String SdrPathObj::getSpecialDragComment(const SdrDragStat& rDrag) const
+{
+ String aRetval;
+
+ if(mpDAC)
+ {
+ // #i103058# also get a comment when in creation
+ const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj());
+
+ if(bCreateComment)
+ {
+ aRetval = mpDAC->getSpecialDragComment(rDrag);
+ }
+ }
+ else
+ {
+ ImpPathForDragAndCreate aDragAndCreate(*((SdrPathObj*)this));
+ bool bDidWork(aDragAndCreate.beginPathDrag((SdrDragStat&)rDrag));
+
+ if(bDidWork)
+ {
+ aRetval = aDragAndCreate.getSpecialDragComment(rDrag);
+ }
+ }
+
+ return aRetval;
+}
+
+basegfx::B2DPolyPolygon SdrPathObj::getSpecialDragPoly(const SdrDragStat& rDrag) const
+{
+ basegfx::B2DPolyPolygon aRetval;
+ ImpPathForDragAndCreate aDragAndCreate(*((SdrPathObj*)this));
+ bool bDidWork(aDragAndCreate.beginPathDrag((SdrDragStat&)rDrag));
+
+ if(bDidWork)
+ {
+ aRetval = aDragAndCreate.getSpecialDragPoly(rDrag);
+ }
+
+ return aRetval;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrPathObj::BegCreate(SdrDragStat& rStat)
+{
+ impDeleteDAC();
+ return impGetDAC().BegCreate(rStat);
+}
+
+bool SdrPathObj::MovCreate(SdrDragStat& rStat)
+{
+ return impGetDAC().MovCreate(rStat);
+}
+
+bool SdrPathObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ bool bRetval(impGetDAC().EndCreate(rStat, eCmd));
+
+ if(bRetval && mpDAC)
+ {
+ SetPathPoly(mpDAC->getModifiedPolyPolygon());
+
+ // #i75974# Check for AutoClose feature. Moved here from ImpPathForDragAndCreate::EndCreate
+ // to be able to use the type-changing ImpSetClosed method
+ if(!IsClosedObj())
+ {
+ SdrView* pView = rStat.GetView();
+
+ if(pView && pView->IsAutoClosePolys() && !pView->IsUseIncompatiblePathCreateInterface())
+ {
+ OutputDevice* pOut = pView->GetFirstOutputDevice();
+
+ if(pOut)
+ {
+ if(GetPathPoly().count())
+ {
+ const basegfx::B2DPolygon aCandidate(GetPathPoly().getB2DPolygon(0));
+
+ if(aCandidate.count() > 2)
+ {
+ // check distance of first and last point
+ const sal_Int32 nCloseDist(pOut->PixelToLogic(Size(pView->GetAutoCloseDistPix(), 0)).Width());
+ const basegfx::B2DVector aDistVector(aCandidate.getB2DPoint(aCandidate.count() - 1) - aCandidate.getB2DPoint(0));
+
+ if(aDistVector.getLength() <= (double)nCloseDist)
+ {
+ // close it
+ ImpSetClosed(true);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ impDeleteDAC();
+ }
+
+ return bRetval;
+}
+
+bool SdrPathObj::BckCreate(SdrDragStat& rStat)
+{
+ return impGetDAC().BckCreate(rStat);
+}
+
+void SdrPathObj::BrkCreate(SdrDragStat& rStat)
+{
+ impGetDAC().BrkCreate(rStat);
+ impDeleteDAC();
+}
+
+basegfx::B2DPolyPolygon SdrPathObj::TakeCreatePoly(const SdrDragStat& rDrag) const
+{
+ basegfx::B2DPolyPolygon aRetval;
+
+ if(mpDAC)
+ {
+ aRetval = mpDAC->TakeObjectPolyPolygon(rDrag);
+ aRetval.append(mpDAC->TakeDragPolyPolygon(rDrag));
+ }
+
+ return aRetval;
+}
+
+// during drag or create, allow accessing the so-far created/modified polyPolygon
+basegfx::B2DPolyPolygon SdrPathObj::getObjectPolyPolygon(const SdrDragStat& rDrag) const
+{
+ basegfx::B2DPolyPolygon aRetval;
+
+ if(mpDAC)
+ {
+ aRetval = mpDAC->TakeObjectPolyPolygon(rDrag);
+ }
+
+ return aRetval;
+}
+
+basegfx::B2DPolyPolygon SdrPathObj::getDragPolyPolygon(const SdrDragStat& rDrag) const
+{
+ basegfx::B2DPolyPolygon aRetval;
+
+ if(mpDAC)
+ {
+ aRetval = mpDAC->TakeDragPolyPolygon(rDrag);
+ }
+
+ return aRetval;
+}
+
+Pointer SdrPathObj::GetCreatePointer() const
+{
+ return impGetDAC().GetCreatePointer();
+}
+
+void SdrPathObj::NbcMove(const Size& rSiz)
+{
+ maPathPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(rSiz.Width(), rSiz.Height()));
+
+ // #i19871# first modify locally, then call parent (to get correct SnapRect with GluePoints)
+ SdrTextObj::NbcMove(rSiz);
+}
+
+void SdrPathObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-rRef.X(), -rRef.Y()));
+ aTrans = basegfx::tools::createScaleTranslateB2DHomMatrix(
+ double(xFact), double(yFact), rRef.X(), rRef.Y()) * aTrans;
+ maPathPolygon.transform(aTrans);
+
+ // #i19871# first modify locally, then call parent (to get correct SnapRect with GluePoints)
+ SdrTextObj::NbcResize(rRef,xFact,yFact);
+}
+
+void SdrPathObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ // Thank JOE, the angles are defined mirrored to the mathematical meanings
+ const basegfx::B2DHomMatrix aTrans(basegfx::tools::createRotateAroundPoint(rRef.X(), rRef.Y(), -nWink * nPi180));
+ maPathPolygon.transform(aTrans);
+
+ // #i19871# first modify locally, then call parent (to get correct SnapRect with GluePoints)
+ SdrTextObj::NbcRotate(rRef,nWink,sn,cs);
+}
+
+void SdrPathObj::NbcShear(const Point& rRefPnt, long nAngle, double fTan, bool bVShear)
+{
+ basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-rRefPnt.X(), -rRefPnt.Y()));
+
+ if(bVShear)
+ {
+ // Thank JOE, the angles are defined mirrored to the mathematical meanings
+ aTrans.shearY(-fTan);
+ }
+ else
+ {
+ aTrans.shearX(-fTan);
+ }
+
+ aTrans.translate(rRefPnt.X(), rRefPnt.Y());
+ maPathPolygon.transform(aTrans);
+
+ // #i19871# first modify locally, then call parent (to get correct SnapRect with GluePoints)
+ SdrTextObj::NbcShear(rRefPnt,nAngle,fTan,bVShear);
+}
+
+void SdrPathObj::NbcMirror(const Point& rRefPnt1, const Point& rRefPnt2)
+{
+ const double fDiffX(rRefPnt2.X() - rRefPnt1.X());
+ const double fDiffY(rRefPnt2.Y() - rRefPnt1.Y());
+ const double fRot(atan2(fDiffY, fDiffX));
+ basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-rRefPnt1.X(), -rRefPnt1.Y()));
+ aTrans.rotate(-fRot);
+ aTrans.scale(1.0, -1.0);
+ aTrans.rotate(fRot);
+ aTrans.translate(rRefPnt1.X(), rRefPnt1.Y());
+ maPathPolygon.transform(aTrans);
+
+ // #97538# Do Joe's special handling for lines when mirroring, too
+ ImpForceKind();
+
+ // #i19871# first modify locally, then call parent (to get correct SnapRect with GluePoints)
+ SdrTextObj::NbcMirror(rRefPnt1,rRefPnt2);
+}
+
+void SdrPathObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
+{
+ if(!aGeo.nDrehWink)
+ {
+ rRect = GetSnapRect();
+ }
+ else
+ {
+ XPolyPolygon aXPP(GetPathPoly());
+ RotateXPoly(aXPP,Point(),-aGeo.nSin,aGeo.nCos);
+ rRect=aXPP.GetBoundRect();
+ Point aTmp(rRect.TopLeft());
+ RotatePoint(aTmp,Point(),aGeo.nSin,aGeo.nCos);
+ aTmp-=rRect.TopLeft();
+ rRect.Move(aTmp.X(),aTmp.Y());
+ }
+}
+
+void SdrPathObj::RecalcSnapRect()
+{
+ if(GetPathPoly().count())
+ {
+ maSnapRect = ImpGetBoundRect(GetPathPoly());
+ }
+}
+
+void SdrPathObj::NbcSetSnapRect(const Rectangle& rRect)
+{
+ Rectangle aOld(GetSnapRect());
+
+ // #95736# Take RECT_EMPTY into account when calculating scale factors
+ long nMulX = (RECT_EMPTY == rRect.Right()) ? 0 : rRect.Right() - rRect.Left();
+
+ long nDivX = aOld.Right() - aOld.Left();
+
+ // #95736# Take RECT_EMPTY into account when calculating scale factors
+ long nMulY = (RECT_EMPTY == rRect.Bottom()) ? 0 : rRect.Bottom() - rRect.Top();
+
+ long nDivY = aOld.Bottom() - aOld.Top();
+ if ( nDivX == 0 ) { nMulX = 1; nDivX = 1; }
+ if ( nDivY == 0 ) { nMulY = 1; nDivY = 1; }
+ Fraction aX(nMulX,nDivX);
+ Fraction aY(nMulY,nDivY);
+ NbcResize(aOld.TopLeft(), aX, aY);
+ NbcMove(Size(rRect.Left() - aOld.Left(), rRect.Top() - aOld.Top()));
+}
+
+sal_uInt32 SdrPathObj::GetSnapPointCount() const
+{
+ return GetHdlCount();
+}
+
+Point SdrPathObj::GetSnapPoint(sal_uInt32 nSnapPnt) const
+{
+ sal_uInt32 nPoly,nPnt;
+ if(!PolyPolygonEditor::GetRelativePolyPoint(GetPathPoly(), nSnapPnt, nPoly, nPnt))
+ {
+ DBG_ASSERT(FALSE,"SdrPathObj::GetSnapPoint: Punkt nSnapPnt nicht vorhanden!");
+ }
+
+ const basegfx::B2DPoint aB2DPoint(GetPathPoly().getB2DPolygon(nPoly).getB2DPoint(nPnt));
+ return Point(FRound(aB2DPoint.getX()), FRound(aB2DPoint.getY()));
+}
+
+sal_Bool SdrPathObj::IsPolyObj() const
+{
+ return sal_True;
+}
+
+sal_uInt32 SdrPathObj::GetPointCount() const
+{
+ const sal_uInt32 nPolyCount(GetPathPoly().count());
+ sal_uInt32 nRetval(0L);
+
+ for(sal_uInt32 a(0L); a < nPolyCount; a++)
+ {
+ nRetval += GetPathPoly().getB2DPolygon(a).count();
+ }
+
+ return nRetval;
+}
+
+Point SdrPathObj::GetPoint(sal_uInt32 nHdlNum) const
+{
+ Point aRetval;
+ sal_uInt32 nPoly,nPnt;
+
+ if(PolyPolygonEditor::GetRelativePolyPoint(GetPathPoly(), nHdlNum, nPoly, nPnt))
+ {
+ const basegfx::B2DPolygon aPoly(GetPathPoly().getB2DPolygon(nPoly));
+ const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(nPnt));
+ aRetval = Point(FRound(aPoint.getX()), FRound(aPoint.getY()));
+ }
+
+ return aRetval;
+}
+
+void SdrPathObj::NbcSetPoint(const Point& rPnt, sal_uInt32 nHdlNum)
+{
+ sal_uInt32 nPoly,nPnt;
+
+ if(PolyPolygonEditor::GetRelativePolyPoint(GetPathPoly(), nHdlNum, nPoly, nPnt))
+ {
+ basegfx::B2DPolygon aNewPolygon(GetPathPoly().getB2DPolygon(nPoly));
+ aNewPolygon.setB2DPoint(nPnt, basegfx::B2DPoint(rPnt.X(), rPnt.Y()));
+ maPathPolygon.setB2DPolygon(nPoly, aNewPolygon);
+
+ if(meKind==OBJ_LINE)
+ {
+ ImpForceLineWink();
+ }
+ else
+ {
+ if(GetPathPoly().count())
+ {
+ // #i10659# for SdrTextObj, keep aRect up to date
+ aRect = ImpGetBoundRect(GetPathPoly()); // fuer SdrTextObj#
+ }
+ }
+
+ SetRectsDirty();
+ }
+}
+
+sal_uInt32 SdrPathObj::NbcInsPointOld(const Point& rPos, sal_Bool bNewObj, sal_Bool bHideHim)
+{
+ sal_uInt32 nNewHdl;
+
+ if(bNewObj)
+ {
+ nNewHdl = NbcInsPoint(0L, rPos, sal_True, bHideHim);
+ }
+ else
+ {
+ // look for smallest distance data
+ const basegfx::B2DPoint aTestPoint(rPos.X(), rPos.Y());
+ sal_uInt32 nSmallestPolyIndex(0L);
+ sal_uInt32 nSmallestEdgeIndex(0L);
+ double fSmallestCut;
+ basegfx::tools::getSmallestDistancePointToPolyPolygon(GetPathPoly(), aTestPoint, nSmallestPolyIndex, nSmallestEdgeIndex, fSmallestCut);
+
+ // create old polygon index from it
+ sal_uInt32 nPolyIndex(nSmallestEdgeIndex);
+
+ for(sal_uInt32 a(0L); a < nSmallestPolyIndex; a++)
+ {
+ nPolyIndex += GetPathPoly().getB2DPolygon(a).count();
+ }
+
+ nNewHdl = NbcInsPoint(nPolyIndex, rPos, sal_False, bHideHim);
+ }
+
+ ImpForceKind();
+ return nNewHdl;
+}
+
+sal_uInt32 SdrPathObj::NbcInsPoint(sal_uInt32 /*nHdlNum*/, const Point& rPos, sal_Bool bNewObj, sal_Bool /*bHideHim*/)
+{
+ sal_uInt32 nNewHdl;
+
+ if(bNewObj)
+ {
+ basegfx::B2DPolygon aNewPoly;
+ const basegfx::B2DPoint aPoint(rPos.X(), rPos.Y());
+ aNewPoly.append(aPoint);
+ aNewPoly.setClosed(IsClosed());
+ maPathPolygon.append(aNewPoly);
+ SetRectsDirty();
+ nNewHdl = GetHdlCount();
+ }
+ else
+ {
+ // look for smallest distance data
+ const basegfx::B2DPoint aTestPoint(rPos.X(), rPos.Y());
+ sal_uInt32 nSmallestPolyIndex(0L);
+ sal_uInt32 nSmallestEdgeIndex(0L);
+ double fSmallestCut;
+ basegfx::tools::getSmallestDistancePointToPolyPolygon(GetPathPoly(), aTestPoint, nSmallestPolyIndex, nSmallestEdgeIndex, fSmallestCut);
+ basegfx::B2DPolygon aCandidate(GetPathPoly().getB2DPolygon(nSmallestPolyIndex));
+ const bool bBefore(!aCandidate.isClosed() && 0L == nSmallestEdgeIndex && 0.0 == fSmallestCut);
+ const bool bAfter(!aCandidate.isClosed() && aCandidate.count() == nSmallestEdgeIndex + 2L && 1.0 == fSmallestCut);
+
+ if(bBefore)
+ {
+ // before first point
+ aCandidate.insert(0L, aTestPoint);
+
+ if(aCandidate.areControlPointsUsed())
+ {
+ if(aCandidate.isNextControlPointUsed(1))
+ {
+ aCandidate.setNextControlPoint(0, interpolate(aTestPoint, aCandidate.getB2DPoint(1), (1.0 / 3.0)));
+ aCandidate.setPrevControlPoint(1, interpolate(aTestPoint, aCandidate.getB2DPoint(1), (2.0 / 3.0)));
+ }
+ }
+
+ nNewHdl = 0L;
+ }
+ else if(bAfter)
+ {
+ // after last point
+ aCandidate.append(aTestPoint);
+
+ if(aCandidate.areControlPointsUsed())
+ {
+ if(aCandidate.isPrevControlPointUsed(aCandidate.count() - 2))
+ {
+ aCandidate.setNextControlPoint(aCandidate.count() - 2, interpolate(aCandidate.getB2DPoint(aCandidate.count() - 2), aTestPoint, (1.0 / 3.0)));
+ aCandidate.setPrevControlPoint(aCandidate.count() - 1, interpolate(aCandidate.getB2DPoint(aCandidate.count() - 2), aTestPoint, (2.0 / 3.0)));
+ }
+ }
+
+ nNewHdl = aCandidate.count() - 1L;
+ }
+ else
+ {
+ // in between
+ bool bSegmentSplit(false);
+ const sal_uInt32 nNextIndex((nSmallestEdgeIndex + 1) % aCandidate.count());
+
+ if(aCandidate.areControlPointsUsed())
+ {
+ if(aCandidate.isNextControlPointUsed(nSmallestEdgeIndex) || aCandidate.isPrevControlPointUsed(nNextIndex))
+ {
+ bSegmentSplit = true;
+ }
+ }
+
+ if(bSegmentSplit)
+ {
+ // rebuild original segment to get the split data
+ basegfx::B2DCubicBezier aBezierA, aBezierB;
+ const basegfx::B2DCubicBezier aBezier(
+ aCandidate.getB2DPoint(nSmallestEdgeIndex),
+ aCandidate.getNextControlPoint(nSmallestEdgeIndex),
+ aCandidate.getPrevControlPoint(nNextIndex),
+ aCandidate.getB2DPoint(nNextIndex));
+
+ // split and insert hit point
+ aBezier.split(fSmallestCut, &aBezierA, &aBezierB);
+ aCandidate.insert(nSmallestEdgeIndex + 1, aTestPoint);
+
+ // since we inserted hit point and not split point, we need to add an offset
+ // to the control points to get the C1 continuity we want to achieve
+ const basegfx::B2DVector aOffset(aTestPoint - aBezierA.getEndPoint());
+ aCandidate.setNextControlPoint(nSmallestEdgeIndex, aBezierA.getControlPointA() + aOffset);
+ aCandidate.setPrevControlPoint(nSmallestEdgeIndex + 1, aBezierA.getControlPointB() + aOffset);
+ aCandidate.setNextControlPoint(nSmallestEdgeIndex + 1, aBezierB.getControlPointA() + aOffset);
+ aCandidate.setPrevControlPoint((nSmallestEdgeIndex + 2) % aCandidate.count(), aBezierB.getControlPointB() + aOffset);
+ }
+ else
+ {
+ aCandidate.insert(nSmallestEdgeIndex + 1L, aTestPoint);
+ }
+
+ nNewHdl = nSmallestEdgeIndex + 1L;
+ }
+
+ maPathPolygon.setB2DPolygon(nSmallestPolyIndex, aCandidate);
+
+ // create old polygon index from it
+ for(sal_uInt32 a(0L); a < nSmallestPolyIndex; a++)
+ {
+ nNewHdl += GetPathPoly().getB2DPolygon(a).count();
+ }
+ }
+
+ ImpForceKind();
+ return nNewHdl;
+}
+
+SdrObject* SdrPathObj::RipPoint(sal_uInt32 nHdlNum, sal_uInt32& rNewPt0Index)
+{
+ SdrPathObj* pNewObj = 0L;
+ const basegfx::B2DPolyPolygon aLocalPolyPolygon(GetPathPoly());
+ sal_uInt32 nPoly, nPnt;
+
+ if(PolyPolygonEditor::GetRelativePolyPoint(aLocalPolyPolygon, nHdlNum, nPoly, nPnt))
+ {
+ if(0L == nPoly)
+ {
+ const basegfx::B2DPolygon aCandidate(aLocalPolyPolygon.getB2DPolygon(nPoly));
+ const sal_uInt32 nPointCount(aCandidate.count());
+
+ if(nPointCount)
+ {
+ if(IsClosed())
+ {
+ // when closed, RipPoint means to open the polygon at the selected point. To
+ // be able to do that, it is necessary to make the selected point the first one
+ basegfx::B2DPolygon aNewPolygon(basegfx::tools::makeStartPoint(aCandidate, nPnt));
+ SetPathPoly(basegfx::B2DPolyPolygon(aNewPolygon));
+ ToggleClosed();
+
+ // give back new position of old start point (historical reasons)
+ rNewPt0Index = (nPointCount - nPnt) % nPointCount;
+ }
+ else
+ {
+ if(nPointCount >= 3L && nPnt != 0L && nPnt + 1L < nPointCount)
+ {
+ // split in two objects at point nPnt
+ basegfx::B2DPolygon aSplitPolyA(aCandidate, 0L, nPnt + 1L);
+ SetPathPoly(basegfx::B2DPolyPolygon(aSplitPolyA));
+
+ pNewObj = (SdrPathObj*)Clone();
+ basegfx::B2DPolygon aSplitPolyB(aCandidate, nPnt, nPointCount - nPnt);
+ pNewObj->SetPathPoly(basegfx::B2DPolyPolygon(aSplitPolyB));
+ }
+ }
+ }
+ }
+ }
+
+ return pNewObj;
+}
+
+SdrObject* SdrPathObj::DoConvertToPolyObj(BOOL bBezier) const
+{
+ // #i89784# check for FontWork with activated HideContour
+ const drawinglayer::attribute::SdrTextAttribute aText(
+ drawinglayer::primitive2d::createNewSdrTextAttribute(GetObjectItemSet(), *getText(0)));
+ const bool bHideContour(
+ !aText.isDefault() && !aText.getSdrFormTextAttribute().isDefault() && aText.isHideContour());
+
+ SdrObject* pRet = bHideContour ?
+ 0 :
+ ImpConvertMakeObj(GetPathPoly(), IsClosed(), bBezier);
+
+ SdrPathObj* pPath = PTR_CAST(SdrPathObj, pRet);
+
+ if(pPath)
+ {
+ if(pPath->GetPathPoly().areControlPointsUsed())
+ {
+ if(!bBezier)
+ {
+ // reduce all bezier curves
+ pPath->SetPathPoly(basegfx::tools::adaptiveSubdivideByAngle(pPath->GetPathPoly()));
+ }
+ }
+ else
+ {
+ if(bBezier)
+ {
+ // create bezier curves
+ pPath->SetPathPoly(basegfx::tools::expandToCurve(pPath->GetPathPoly()));
+ }
+ }
+ }
+
+ pRet = ImpConvertAddText(pRet, bBezier);
+
+ return pRet;
+}
+
+SdrObjGeoData* SdrPathObj::NewGeoData() const
+{
+ return new SdrPathObjGeoData;
+}
+
+void SdrPathObj::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ SdrTextObj::SaveGeoData(rGeo);
+ SdrPathObjGeoData& rPGeo = (SdrPathObjGeoData&) rGeo;
+ rPGeo.maPathPolygon=GetPathPoly();
+ rPGeo.meKind=meKind;
+}
+
+void SdrPathObj::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ SdrTextObj::RestGeoData(rGeo);
+ SdrPathObjGeoData& rPGeo=(SdrPathObjGeoData&)rGeo;
+ maPathPolygon=rPGeo.maPathPolygon;
+ meKind=rPGeo.meKind;
+ ImpForceKind(); // damit u.a. bClosed gesetzt wird
+}
+
+void SdrPathObj::NbcSetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly)
+{
+ if(GetPathPoly() != rPathPoly)
+ {
+ maPathPolygon=rPathPoly;
+ ImpForceKind();
+ SetRectsDirty();
+ }
+}
+
+void SdrPathObj::SetPathPoly(const basegfx::B2DPolyPolygon& rPathPoly)
+{
+ if(GetPathPoly() != rPathPoly)
+ {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ NbcSetPathPoly(rPathPoly);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+void SdrPathObj::ToggleClosed() // long nOpenDistance)
+{
+ Rectangle aBoundRect0;
+ if(pUserCall != NULL)
+ aBoundRect0 = GetLastBoundRect();
+ ImpSetClosed(!IsClosed()); // neuen ObjKind setzen
+ ImpForceKind(); // wg. Line->Poly->PolyLine statt Line->Poly->Line
+ SetRectsDirty();
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE, aBoundRect0);
+}
+
+// fuer friend class SdrPolyEditView auf einigen Compilern:
+void SdrPathObj::SetRectsDirty(sal_Bool bNotMyself)
+{
+ SdrTextObj::SetRectsDirty(bNotMyself);
+}
+
+ImpPathForDragAndCreate& SdrPathObj::impGetDAC() const
+{
+ if(!mpDAC)
+ {
+ ((SdrPathObj*)this)->mpDAC = new ImpPathForDragAndCreate(*((SdrPathObj*)this));
+ }
+
+ return *mpDAC;
+}
+
+void SdrPathObj::impDeleteDAC() const
+{
+ if(mpDAC)
+ {
+ delete mpDAC;
+ ((SdrPathObj*)this)->mpDAC = 0L;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// transformation interface for StarOfficeAPI. This implements support for
+// homogen 3x3 matrices containing the transformation of the SdrObject. At the
+// moment it contains a shearX, rotation and translation, but for setting all linear
+// transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
+// with the base geometry and returns TRUE. Otherwise it returns FALSE.
+sal_Bool SdrPathObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon) const
+{
+ double fRotate(0.0);
+ double fShearX(0.0);
+ basegfx::B2DTuple aScale(1.0, 1.0);
+ basegfx::B2DTuple aTranslate(0.0, 0.0);
+
+ if(GetPathPoly().count())
+ {
+ // copy geometry
+ basegfx::B2DHomMatrix aMoveToZeroMatrix;
+ rPolyPolygon = GetPathPoly();
+
+ if(OBJ_LINE == meKind)
+ {
+ // ignore shear and rotate, just use scale and translate
+ OSL_ENSURE(GetPathPoly().count() > 0L && GetPathPoly().getB2DPolygon(0L).count() > 1L, "OBJ_LINE with too less polygons (!)");
+ // #i72287# use polygon without control points for range calculation. Do not change rPolyPolygon
+ // itself, else this method will no longer return the full polygon information (curve will
+ // be lost)
+ const basegfx::B2DRange aPolyRangeNoCurve(basegfx::tools::getRange(rPolyPolygon));
+ aScale = aPolyRangeNoCurve.getRange();
+ aTranslate = aPolyRangeNoCurve.getMinimum();
+
+ // define matrix for move polygon to zero point
+ aMoveToZeroMatrix.translate(-aTranslate.getX(), -aTranslate.getY());
+ }
+ else
+ {
+ if(aGeo.nShearWink || aGeo.nDrehWink)
+ {
+ // get rotate and shear in drawingLayer notation
+ fRotate = aGeo.nDrehWink * F_PI18000;
+ fShearX = aGeo.nShearWink * F_PI18000;
+
+ // build mathematically correct (negative shear and rotate) object transform
+ // containing shear and rotate to extract unsheared, unrotated polygon
+ basegfx::B2DHomMatrix aObjectMatrix;
+ aObjectMatrix.shearX(tan((36000 - aGeo.nShearWink) * F_PI18000));
+ aObjectMatrix.rotate((36000 - aGeo.nDrehWink) * F_PI18000);
+
+ // create inverse from it and back-transform polygon
+ basegfx::B2DHomMatrix aInvObjectMatrix(aObjectMatrix);
+ aInvObjectMatrix.invert();
+ rPolyPolygon.transform(aInvObjectMatrix);
+
+ // get range from unsheared, unrotated polygon and extract scale and translate.
+ // transform topLeft from it back to transformed state to get original
+ // topLeft (rotation center)
+ // #i72287# use polygon without control points for range calculation. Do not change rPolyPolygon
+ // itself, else this method will no longer return the full polygon information (curve will
+ // be lost)
+ const basegfx::B2DRange aCorrectedRangeNoCurve(basegfx::tools::getRange(rPolyPolygon));
+ aTranslate = aObjectMatrix * aCorrectedRangeNoCurve.getMinimum();
+ aScale = aCorrectedRangeNoCurve.getRange();
+
+ // define matrix for move polygon to zero point
+ // #i112280# Added missing minus for Y-Translation
+ aMoveToZeroMatrix.translate(-aCorrectedRangeNoCurve.getMinX(), -aCorrectedRangeNoCurve.getMinY());
+ }
+ else
+ {
+ // get scale and translate from unsheared, unrotated polygon
+ // #i72287# use polygon without control points for range calculation. Do not change rPolyPolygon
+ // itself, else this method will no longer return the full polygon information (curve will
+ // be lost)
+ const basegfx::B2DRange aPolyRangeNoCurve(basegfx::tools::getRange(rPolyPolygon));
+ aScale = aPolyRangeNoCurve.getRange();
+ aTranslate = aPolyRangeNoCurve.getMinimum();
+
+ // define matrix for move polygon to zero point
+ aMoveToZeroMatrix.translate(-aTranslate.getX(), -aTranslate.getY());
+ }
+ }
+
+ // move polygon to zero point with pre-defined matrix
+ rPolyPolygon.transform(aMoveToZeroMatrix);
+ }
+
+ // position maybe relative to anchorpos, convert
+ if( pModel && pModel->IsWriter() )
+ {
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
+ }
+ }
+
+ // force MapUnit to 100th mm
+ SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // postion
+ aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
+ aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplTwipsToMM(aScale.getX()));
+ aScale.setY(ImplTwipsToMM(aScale.getY()));
+
+ // polygon
+ basegfx::B2DHomMatrix aTwipsToMM;
+ const double fFactorTwipsToMM(127.0 / 72.0);
+ aTwipsToMM.scale(fFactorTwipsToMM, fFactorTwipsToMM);
+ rPolyPolygon.transform(aTwipsToMM);
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
+ }
+ }
+ }
+
+ // build return value matrix
+ rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aScale,
+ basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX),
+ basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate,
+ aTranslate);
+
+ return sal_True;
+}
+
+// sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
+// If it's an SdrPathObj it will use the provided geometry information. The Polygon has
+// to use (0,0) as upper left and will be scaled to the given size in the matrix.
+void SdrPathObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon)
+{
+ // break up matrix
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate, fShearX;
+ rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
+ // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
+ if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
+ {
+ aScale.setX(fabs(aScale.getX()));
+ aScale.setY(fabs(aScale.getY()));
+ fRotate = fmod(fRotate + F_PI, F_2PI);
+ }
+
+ // copy poly
+ basegfx::B2DPolyPolygon aNewPolyPolygon(rPolyPolygon);
+
+ // reset object shear and rotations
+ aGeo.nDrehWink = 0;
+ aGeo.RecalcSinCos();
+ aGeo.nShearWink = 0;
+ aGeo.RecalcTan();
+
+ // force metric to pool metric
+ SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // position
+ aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
+ aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplMMToTwips(aScale.getX()));
+ aScale.setY(ImplMMToTwips(aScale.getY()));
+
+ // polygon
+ basegfx::B2DHomMatrix aMMToTwips;
+ const double fFactorMMToTwips(72.0 / 127.0);
+ aMMToTwips.scale(fFactorMMToTwips, fFactorMMToTwips);
+ aNewPolyPolygon.transform(aMMToTwips);
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
+ }
+ }
+ }
+
+ if( pModel && pModel->IsWriter() )
+ {
+ // if anchor is used, make position relative to it
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
+ }
+ }
+
+ // create transformation for polygon, set values at aGeo direct
+ basegfx::B2DHomMatrix aTransform;
+
+ // #i75086#
+ // Given polygon is already scaled (for historical reasons), but not mirrored yet.
+ // Thus, when scale is negative in X or Y, apply the needed mirroring accordingly.
+ if(basegfx::fTools::less(aScale.getX(), 0.0) || basegfx::fTools::less(aScale.getY(), 0.0))
+ {
+ aTransform.scale(
+ basegfx::fTools::less(aScale.getX(), 0.0) ? -1.0 : 1.0,
+ basegfx::fTools::less(aScale.getY(), 0.0) ? -1.0 : 1.0);
+ }
+
+ if(!basegfx::fTools::equalZero(fShearX))
+ {
+ aTransform.shearX(tan(-atan(fShearX)));
+ aGeo.nShearWink = FRound(atan(fShearX) / F_PI18000);
+ aGeo.RecalcTan();
+ }
+
+ if(!basegfx::fTools::equalZero(fRotate))
+ {
+ // #i78696#
+ // fRotate is matematically correct for linear transformations, so it's
+ // the one to use for the geometry change
+ aTransform.rotate(fRotate);
+
+ // #i78696#
+ // fRotate is matematically correct, but aGeoStat.nDrehWink is
+ // mirrored -> mirror value here
+ aGeo.nDrehWink = NormAngle360(FRound(-fRotate / F_PI18000));
+ aGeo.RecalcSinCos();
+ }
+
+ if(!aTranslate.equalZero())
+ {
+ // #i39529# absolute positioning, so get current position (without control points (!))
+ const basegfx::B2DRange aCurrentRange(basegfx::tools::getRange(aNewPolyPolygon));
+ aTransform.translate(aTranslate.getX() - aCurrentRange.getMinX(), aTranslate.getY() - aCurrentRange.getMinY());
+ }
+
+ // transform polygon and trigger change
+ aNewPolyPolygon.transform(aTransform);
+ SetPathPoly(aNewPolyPolygon);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx
new file mode 100644
index 000000000000..cdce36085801
--- /dev/null
+++ b/svx/source/svdraw/svdorect.cxx
@@ -0,0 +1,623 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdorect.hxx>
+#include <math.h>
+#include <stdlib.h>
+#include <svx/xpool.hxx>
+#include <svx/xpoly.hxx>
+#include <svx/svdattr.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svddrag.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdocapt.hxx> // fuer Import von SdrFileVersion 2
+#include <svx/svdpagv.hxx> // fuer
+#include <svx/svdview.hxx> // das
+#include <svx/svdundo.hxx> // Macro-Beispiel
+#include <svx/svdopath.hxx>
+#include "svdglob.hxx" // Stringcache
+#include "svdstr.hrc" // Objektname
+#include <svx/xflclit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlnwtit.hxx>
+#include "svdoimp.hxx"
+#include <svx/sdr/properties/rectangleproperties.hxx>
+#include <svx/sdr/contact/viewcontactofsdrrectobj.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrRectObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::RectangleProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// DrawContact section
+
+sdr::contact::ViewContact* SdrRectObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfSdrRectObj(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrRectObj,SdrTextObj);
+
+SdrRectObj::SdrRectObj()
+: mpXPoly(0L)
+{
+ bClosedObj=TRUE;
+}
+
+SdrRectObj::SdrRectObj(const Rectangle& rRect)
+: SdrTextObj(rRect),
+ mpXPoly(NULL)
+{
+ bClosedObj=TRUE;
+}
+
+SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind)
+: SdrTextObj(eNewTextKind),
+ mpXPoly(NULL)
+{
+ DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT ||
+ eTextKind==OBJ_OUTLINETEXT || eTextKind==OBJ_TITLETEXT,
+ "SdrRectObj::SdrRectObj(SdrObjKind) ist nur fuer Textrahmen gedacht");
+ bClosedObj=TRUE;
+}
+
+SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind, const Rectangle& rRect)
+: SdrTextObj(eNewTextKind,rRect),
+ mpXPoly(NULL)
+{
+ DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT ||
+ eTextKind==OBJ_OUTLINETEXT || eTextKind==OBJ_TITLETEXT,
+ "SdrRectObj::SdrRectObj(SdrObjKind,...) ist nur fuer Textrahmen gedacht");
+ bClosedObj=TRUE;
+}
+
+SdrRectObj::SdrRectObj(SdrObjKind eNewTextKind, const Rectangle& rNewRect, SvStream& rInput, const String& rBaseURL, USHORT eFormat)
+: SdrTextObj(eNewTextKind,rNewRect,rInput,rBaseURL,eFormat),
+ mpXPoly(NULL)
+{
+ DBG_ASSERT(eTextKind==OBJ_TEXT || eTextKind==OBJ_TEXTEXT ||
+ eTextKind==OBJ_OUTLINETEXT || eTextKind==OBJ_TITLETEXT,
+ "SdrRectObj::SdrRectObj(SdrObjKind,...) ist nur fuer Textrahmen gedacht");
+ bClosedObj=TRUE;
+}
+
+SdrRectObj::~SdrRectObj()
+{
+ if(mpXPoly)
+ {
+ delete mpXPoly;
+ }
+}
+
+void SdrRectObj::SetXPolyDirty()
+{
+ if(mpXPoly)
+ {
+ delete mpXPoly;
+ mpXPoly = 0L;
+ }
+}
+
+bool SdrRectObj::PaintNeedsXPoly(long nEckRad) const
+{
+ bool bNeed=aGeo.nDrehWink!=0 || aGeo.nShearWink!=0 || nEckRad!=0;
+ return bNeed;
+}
+
+XPolygon SdrRectObj::ImpCalcXPoly(const Rectangle& rRect1, long nRad1) const
+{
+ XPolygon aXPoly(rRect1,nRad1,nRad1);
+ const sal_uInt16 nPointAnz(aXPoly.GetPointCount());
+ XPolygon aNeuPoly(nPointAnz+1);
+ sal_uInt16 nShift=nPointAnz-2;
+ if (nRad1!=0) nShift=nPointAnz-5;
+ sal_uInt16 j=nShift;
+ for (sal_uInt16 i=1; i<nPointAnz; i++) {
+ aNeuPoly[i]=aXPoly[j];
+ aNeuPoly.SetFlags(i,aXPoly.GetFlags(j));
+ j++;
+ if (j>=nPointAnz) j=1;
+ }
+ aNeuPoly[0]=rRect1.BottomCenter();
+ aNeuPoly[nPointAnz]=aNeuPoly[0];
+ aXPoly=aNeuPoly;
+
+ // Die Winkelangaben beziehen sich immer auf die linke obere Ecke von !aRect!
+ if (aGeo.nShearWink!=0) ShearXPoly(aXPoly,aRect.TopLeft(),aGeo.nTan);
+ if (aGeo.nDrehWink!=0) RotateXPoly(aXPoly,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ return aXPoly;
+}
+
+void SdrRectObj::RecalcXPoly()
+{
+ mpXPoly = new XPolygon(ImpCalcXPoly(aRect,GetEckenradius()));
+}
+
+const XPolygon& SdrRectObj::GetXPoly() const
+{
+ if(!mpXPoly)
+ {
+ ((SdrRectObj*)this)->RecalcXPoly();
+ }
+
+ return *mpXPoly;
+}
+
+void SdrRectObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ bool bNoTextFrame=!IsTextFrame();
+ rInfo.bResizeFreeAllowed=bNoTextFrame || aGeo.nDrehWink%9000==0;
+ rInfo.bResizePropAllowed=TRUE;
+ rInfo.bRotateFreeAllowed=TRUE;
+ rInfo.bRotate90Allowed =TRUE;
+ rInfo.bMirrorFreeAllowed=bNoTextFrame;
+ rInfo.bMirror45Allowed =bNoTextFrame;
+ rInfo.bMirror90Allowed =bNoTextFrame;
+
+ // allow transparence
+ rInfo.bTransparenceAllowed = TRUE;
+
+ // gradient depends on fillstyle
+ XFillStyle eFillStyle = ((XFillStyleItem&)(GetObjectItem(XATTR_FILLSTYLE))).GetValue();
+ rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT);
+
+ rInfo.bShearAllowed =bNoTextFrame;
+ rInfo.bEdgeRadiusAllowed=TRUE;
+
+ bool bCanConv=!HasText() || ImpCanConvTextToCurve();
+ if (bCanConv && !bNoTextFrame && !HasText()) {
+ bCanConv=HasFill() || HasLine();
+ }
+ rInfo.bCanConvToPath =bCanConv;
+ rInfo.bCanConvToPoly =bCanConv;
+ rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
+}
+
+UINT16 SdrRectObj::GetObjIdentifier() const
+{
+ if (IsTextFrame()) return UINT16(eTextKind);
+ else return UINT16(OBJ_RECT);
+}
+
+void SdrRectObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
+{
+ rRect=aRect;
+ if (aGeo.nShearWink!=0) {
+ long nDst=Round((aRect.Bottom()-aRect.Top())*aGeo.nTan);
+ if (aGeo.nShearWink>0) {
+ Point aRef(rRect.TopLeft());
+ rRect.Left()-=nDst;
+ Point aTmpPt(rRect.TopLeft());
+ RotatePoint(aTmpPt,aRef,aGeo.nSin,aGeo.nCos);
+ aTmpPt-=rRect.TopLeft();
+ rRect.Move(aTmpPt.X(),aTmpPt.Y());
+ } else {
+ rRect.Right()-=nDst;
+ }
+ }
+}
+
+void SdrRectObj::TakeObjNameSingul(XubString& rName) const
+{
+ if (IsTextFrame())
+ {
+ SdrTextObj::TakeObjNameSingul(rName);
+ }
+ else
+ {
+ USHORT nResId=STR_ObjNameSingulRECT;
+ if (aGeo.nShearWink!=0) {
+ nResId+=4; // Parallelogramm oder Raute
+ // Raute ist nicht, weil Shear die vertikalen Kanten verlaengert!
+ // Wenn Zeit ist, werde ich das mal berechnen.
+ } else {
+ if (aRect.GetWidth()==aRect.GetHeight()) nResId+=2; // Quadrat
+ }
+ if (GetEckenradius()!=0) nResId+=8; // abgerundet
+ rName=ImpGetResStr(nResId);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+ }
+}
+
+void SdrRectObj::TakeObjNamePlural(XubString& rName) const
+{
+ if (IsTextFrame()) SdrTextObj::TakeObjNamePlural(rName);
+ else {
+ USHORT nResId=STR_ObjNamePluralRECT;
+ if (aGeo.nShearWink!=0) {
+ nResId+=4; // Parallelogramm oder Raute
+ } else {
+ if (aRect.GetWidth()==aRect.GetHeight()) nResId+=2; // Quadrat
+ }
+ if (GetEckenradius()!=0) nResId+=8; // abgerundet
+ rName=ImpGetResStr(nResId);
+ }
+}
+
+void SdrRectObj::operator=(const SdrObject& rObj)
+{
+ SdrTextObj::operator=(rObj);
+}
+
+basegfx::B2DPolyPolygon SdrRectObj::TakeXorPoly() const
+{
+ XPolyPolygon aXPP;
+ aXPP.Insert(ImpCalcXPoly(aRect,GetEckenradius()));
+ return aXPP.getB2DPolyPolygon();
+}
+
+void SdrRectObj::RecalcSnapRect()
+{
+ long nEckRad=GetEckenradius();
+ if ((aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) && nEckRad!=0) {
+ maSnapRect=GetXPoly().GetBoundRect();
+ } else {
+ SdrTextObj::RecalcSnapRect();
+ }
+}
+
+void SdrRectObj::NbcSetSnapRect(const Rectangle& rRect)
+{
+ SdrTextObj::NbcSetSnapRect(rRect);
+ SetXPolyDirty();
+}
+
+void SdrRectObj::NbcSetLogicRect(const Rectangle& rRect)
+{
+ SdrTextObj::NbcSetLogicRect(rRect);
+ SetXPolyDirty();
+}
+
+sal_uInt32 SdrRectObj::GetHdlCount() const
+{
+ return IsTextFrame() ? 10 : 9;
+}
+
+SdrHdl* SdrRectObj::GetHdl(sal_uInt32 nHdlNum) const
+{
+ SdrHdl* pH = NULL;
+ Point aPnt;
+ SdrHdlKind eKind = HDL_MOVE;
+
+ if(!IsTextFrame())
+ {
+ nHdlNum++;
+ }
+
+ switch(nHdlNum)
+ {
+ case 0:
+ {
+ pH = new ImpTextframeHdl(aRect);
+ pH->SetObj((SdrObject*)this);
+ pH->SetDrehWink(aGeo.nDrehWink);
+ break;
+ }
+ case 1:
+ {
+ long a = GetEckenradius();
+ long b = Max(aRect.GetWidth(),aRect.GetHeight())/2; // Wird aufgerundet, da GetWidth() eins draufaddiert
+ if (a>b) a=b;
+ if (a<0) a=0;
+ aPnt=aRect.TopLeft();
+ aPnt.X()+=a;
+ eKind = HDL_CIRC;
+ break;
+ }
+ case 2: aPnt=aRect.TopLeft(); eKind = HDL_UPLFT; break; // Oben links
+ case 3: aPnt=aRect.TopCenter(); eKind = HDL_UPPER; break; // Oben
+ case 4: aPnt=aRect.TopRight(); eKind = HDL_UPRGT; break; // Oben rechts
+ case 5: aPnt=aRect.LeftCenter(); eKind = HDL_LEFT ; break; // Links
+ case 6: aPnt=aRect.RightCenter(); eKind = HDL_RIGHT; break; // Rechts
+ case 7: aPnt=aRect.BottomLeft(); eKind = HDL_LWLFT; break; // Unten links
+ case 8: aPnt=aRect.BottomCenter(); eKind = HDL_LOWER; break; // Unten
+ case 9: aPnt=aRect.BottomRight(); eKind = HDL_LWRGT; break; // Unten rechts
+ }
+
+ if(!pH)
+ {
+ if(aGeo.nShearWink)
+ {
+ ShearPoint(aPnt,aRect.TopLeft(),aGeo.nTan);
+ }
+
+ if(aGeo.nDrehWink)
+ {
+ RotatePoint(aPnt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ }
+
+ pH = new SdrHdl(aPnt,eKind);
+ pH->SetObj((SdrObject*)this);
+ pH->SetDrehWink(aGeo.nDrehWink);
+ }
+
+ return pH;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrRectObj::hasSpecialDrag() const
+{
+ return true;
+}
+
+bool SdrRectObj::beginSpecialDrag(SdrDragStat& rDrag) const
+{
+ const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind());
+
+ if(bRad)
+ {
+ rDrag.SetEndDragChangesAttributes(true);
+
+ return true;
+ }
+
+ return SdrTextObj::beginSpecialDrag(rDrag);
+}
+
+bool SdrRectObj::applySpecialDrag(SdrDragStat& rDrag)
+{
+ const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind());
+
+ if (bRad)
+ {
+ Rectangle aBoundRect0;
+ Point aPt(rDrag.GetNow());
+
+ if(aGeo.nDrehWink)
+ RotatePoint(aPt,aRect.TopLeft(),-aGeo.nSin,aGeo.nCos);
+
+ sal_Int32 nRad(aPt.X() - aRect.Left());
+
+ if (nRad < 0)
+ nRad = 0;
+
+ if(nRad != GetEckenradius())
+ {
+ NbcSetEckenradius(nRad);
+ }
+
+ return true;
+ }
+ else
+ {
+ return SdrTextObj::applySpecialDrag(rDrag);
+ }
+}
+
+String SdrRectObj::getSpecialDragComment(const SdrDragStat& rDrag) const
+{
+ const bool bCreateComment(rDrag.GetView() && this == rDrag.GetView()->GetCreateObj());
+
+ if(bCreateComment)
+ {
+ return String();
+ }
+ else
+ {
+ const bool bRad(rDrag.GetHdl() && HDL_CIRC == rDrag.GetHdl()->GetKind());
+
+ if(bRad)
+ {
+ Point aPt(rDrag.GetNow());
+
+ // -sin fuer Umkehrung
+ if(aGeo.nDrehWink)
+ RotatePoint(aPt, aRect.TopLeft(), -aGeo.nSin, aGeo.nCos);
+
+ sal_Int32 nRad(aPt.X() - aRect.Left());
+
+ if(nRad < 0)
+ nRad = 0;
+
+ XubString aStr;
+
+ ImpTakeDescriptionStr(STR_DragRectEckRad, aStr);
+ aStr.AppendAscii(" (");
+ aStr += GetMetrStr(nRad);
+ aStr += sal_Unicode(')');
+
+ return aStr;
+ }
+ else
+ {
+ return SdrTextObj::getSpecialDragComment(rDrag);
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+basegfx::B2DPolyPolygon SdrRectObj::TakeCreatePoly(const SdrDragStat& rDrag) const
+{
+ Rectangle aRect1;
+ rDrag.TakeCreateRect(aRect1);
+ aRect1.Justify();
+
+ basegfx::B2DPolyPolygon aRetval;
+ aRetval.append(ImpCalcXPoly(aRect1,GetEckenradius()).getB2DPolygon());
+ return aRetval;
+}
+
+Pointer SdrRectObj::GetCreatePointer() const
+{
+ if (IsTextFrame()) return Pointer(POINTER_DRAW_TEXT);
+ return Pointer(POINTER_DRAW_RECT);
+}
+
+void SdrRectObj::NbcMove(const Size& rSiz)
+{
+ SdrTextObj::NbcMove(rSiz);
+ SetXPolyDirty();
+}
+
+void SdrRectObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ SdrTextObj::NbcResize(rRef,xFact,yFact);
+ SetXPolyDirty();
+}
+
+void SdrRectObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ SdrTextObj::NbcRotate(rRef,nWink,sn,cs);
+ SetXPolyDirty();
+}
+
+void SdrRectObj::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ SdrTextObj::NbcShear(rRef,nWink,tn,bVShear);
+ SetXPolyDirty();
+}
+
+void SdrRectObj::NbcMirror(const Point& rRef1, const Point& rRef2)
+{
+ SdrTextObj::NbcMirror(rRef1,rRef2);
+ SetXPolyDirty();
+}
+
+bool SdrRectObj::DoMacro(const SdrObjMacroHitRec& rRec)
+{
+ return SdrTextObj::DoMacro(rRec);
+}
+
+XubString SdrRectObj::GetMacroPopupComment(const SdrObjMacroHitRec& rRec) const
+{
+ return SdrTextObj::GetMacroPopupComment(rRec);
+}
+
+SdrGluePoint SdrRectObj::GetVertexGluePoint(USHORT nPosNum) const
+{
+ INT32 nWdt = ImpGetLineWdt(); // #i25616# ((XLineWidthItem&)(GetObjectItem(XATTR_LINEWIDTH))).GetValue();
+
+ // #i25616#
+ if(!LineIsOutsideGeometry())
+ {
+ nWdt++;
+ nWdt /= 2;
+ }
+
+ Point aPt;
+ switch (nPosNum) {
+ case 0: aPt=aRect.TopCenter(); aPt.Y()-=nWdt; break;
+ case 1: aPt=aRect.RightCenter(); aPt.X()+=nWdt; break;
+ case 2: aPt=aRect.BottomCenter(); aPt.Y()+=nWdt; break;
+ case 3: aPt=aRect.LeftCenter(); aPt.X()-=nWdt; break;
+ }
+ if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),aGeo.nTan);
+ if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ aPt-=GetSnapRect().Center();
+ SdrGluePoint aGP(aPt);
+ aGP.SetPercent(FALSE);
+ return aGP;
+}
+
+SdrGluePoint SdrRectObj::GetCornerGluePoint(USHORT nPosNum) const
+{
+ INT32 nWdt = ImpGetLineWdt(); // #i25616# ((XLineWidthItem&)(GetObjectItem(XATTR_LINEWIDTH))).GetValue();
+
+ // #i25616#
+ if(!LineIsOutsideGeometry())
+ {
+ nWdt++;
+ nWdt /= 2;
+ }
+
+ Point aPt;
+ switch (nPosNum) {
+ case 0: aPt=aRect.TopLeft(); aPt.X()-=nWdt; aPt.Y()-=nWdt; break;
+ case 1: aPt=aRect.TopRight(); aPt.X()+=nWdt; aPt.Y()-=nWdt; break;
+ case 2: aPt=aRect.BottomRight(); aPt.X()+=nWdt; aPt.Y()+=nWdt; break;
+ case 3: aPt=aRect.BottomLeft(); aPt.X()-=nWdt; aPt.Y()+=nWdt; break;
+ }
+ if (aGeo.nShearWink!=0) ShearPoint(aPt,aRect.TopLeft(),aGeo.nTan);
+ if (aGeo.nDrehWink!=0) RotatePoint(aPt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ aPt-=GetSnapRect().Center();
+ SdrGluePoint aGP(aPt);
+ aGP.SetPercent(FALSE);
+ return aGP;
+}
+
+SdrObject* SdrRectObj::DoConvertToPolyObj(BOOL bBezier) const
+{
+ XPolygon aXP(ImpCalcXPoly(aRect,GetEckenradius()));
+ { // #40608# Nur Uebergangsweise bis zum neuen TakeContour()
+ aXP.Remove(0,1);
+ aXP[aXP.GetPointCount()-1]=aXP[0];
+ }
+
+ basegfx::B2DPolyPolygon aPolyPolygon(aXP.getB2DPolygon());
+ aPolyPolygon.removeDoublePoints();
+ SdrObject* pRet = 0L;
+
+ if(!IsTextFrame() || HasFill() || HasLine())
+ {
+ pRet = ImpConvertMakeObj(aPolyPolygon, sal_True, bBezier);
+ }
+
+ pRet = ImpConvertAddText(pRet, bBezier);
+
+ return pRet;
+}
+
+void SdrRectObj::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+{
+ SdrTextObj::Notify(rBC,rHint);
+ SetXPolyDirty(); // wg. Eckenradius
+}
+
+void SdrRectObj::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ SdrTextObj::RestGeoData(rGeo);
+ SetXPolyDirty();
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
new file mode 100644
index 000000000000..2585c70d01c4
--- /dev/null
+++ b/svx/source/svdraw/svdotext.cxx
@@ -0,0 +1,2215 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdotext.hxx>
+#include "svditext.hxx"
+#include <svx/svdpagv.hxx> // fuer Abfrage im Paint, ob das
+#include <svx/svdview.hxx> // Objekt gerade editiert wird
+#include <svx/svdpage.hxx> // und fuer AnimationHandler (Laufschrift)
+#include <svx/svdetc.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdmodel.hxx> // OutlinerDefaults
+#include "svdglob.hxx" // Stringcache
+#include "svdstr.hrc" // Objektname
+#include <editeng/writingmodeitem.hxx>
+#include <svx/sdtfchim.hxx>
+#include <svtools/colorcfg.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <svl/itempool.hxx>
+#include <editeng/adjitem.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/xftouit.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include <svx/xflgrit.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/xflclit.hxx>
+#include <svl/style.hxx>
+#include <editeng/editeng.hxx>
+#include <svl/itemiter.hxx>
+#include <svx/sdr/properties/textproperties.hxx>
+#include <vcl/metaact.hxx>
+#include <svx/sdr/contact/viewcontactoftextobj.hxx>
+#include <basegfx/tuple/b2dtuple.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <vcl/virdev.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+// #104018# replace macros above with type-safe methods
+inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); }
+inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); }
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@@@ @@@ @@ @@ @@ @@@@@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+//////////////////////////////////////////////////////////////////////////////
+// BaseProperties section
+
+sdr::properties::BaseProperties* SdrTextObj::CreateObjectSpecificProperties()
+{
+ return new sdr::properties::TextProperties(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// DrawContact section
+
+sdr::contact::ViewContact* SdrTextObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfTextObj(*this);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrTextObj,SdrAttrObj);
+
+SdrTextObj::SdrTextObj()
+: SdrAttrObj(),
+ mpText(NULL),
+ pEdtOutl(NULL),
+ pFormTextBoundRect(NULL),
+ eTextKind(OBJ_TEXT)
+{
+ bTextSizeDirty=FALSE;
+ bTextFrame=FALSE;
+ bNoShear=FALSE;
+ bNoRotate=FALSE;
+ bNoMirror=FALSE;
+ bDisableAutoWidthOnDragging=FALSE;
+
+ // #101684#
+ mbInEditMode = FALSE;
+
+ // #111096#
+ mbTextHidden = sal_False;
+
+ // #111096#
+ mbTextAnimationAllowed = sal_True;
+
+ // #108784#
+ maTextEditOffset = Point(0, 0);
+
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_True;
+ mbInDownScale = sal_False;
+}
+
+SdrTextObj::SdrTextObj(const Rectangle& rNewRect)
+: SdrAttrObj(),
+ aRect(rNewRect),
+ mpText(NULL),
+ pEdtOutl(NULL),
+ pFormTextBoundRect(NULL)
+{
+ bTextSizeDirty=FALSE;
+ bTextFrame=FALSE;
+ bNoShear=FALSE;
+ bNoRotate=FALSE;
+ bNoMirror=FALSE;
+ bDisableAutoWidthOnDragging=FALSE;
+ ImpJustifyRect(aRect);
+
+ // #101684#
+ mbInEditMode = FALSE;
+
+ // #111096#
+ mbTextHidden = sal_False;
+
+ // #111096#
+ mbTextAnimationAllowed = sal_True;
+ mbInDownScale = sal_False;
+
+ // #108784#
+ maTextEditOffset = Point(0, 0);
+
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_True;
+}
+
+SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind)
+: SdrAttrObj(),
+ mpText(NULL),
+ pEdtOutl(NULL),
+ pFormTextBoundRect(NULL),
+ eTextKind(eNewTextKind)
+{
+ bTextSizeDirty=FALSE;
+ bTextFrame=TRUE;
+ bNoShear=TRUE;
+ bNoRotate=FALSE;
+ bNoMirror=TRUE;
+ bDisableAutoWidthOnDragging=FALSE;
+
+ // #101684#
+ mbInEditMode = FALSE;
+
+ // #111096#
+ mbTextHidden = sal_False;
+
+ // #111096#
+ mbTextAnimationAllowed = sal_True;
+ mbInDownScale = sal_False;
+
+ // #108784#
+ maTextEditOffset = Point(0, 0);
+
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_True;
+}
+
+SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const Rectangle& rNewRect)
+: SdrAttrObj(),
+ aRect(rNewRect),
+ mpText(NULL),
+ pEdtOutl(NULL),
+ pFormTextBoundRect(NULL),
+ eTextKind(eNewTextKind)
+{
+ bTextSizeDirty=FALSE;
+ bTextFrame=TRUE;
+ bNoShear=TRUE;
+ bNoRotate=FALSE;
+ bNoMirror=TRUE;
+ bDisableAutoWidthOnDragging=FALSE;
+ ImpJustifyRect(aRect);
+
+ // #101684#
+ mbInEditMode = FALSE;
+
+ // #111096#
+ mbTextHidden = sal_False;
+
+ // #111096#
+ mbTextAnimationAllowed = sal_True;
+ mbInDownScale = sal_False;
+
+ // #108784#
+ maTextEditOffset = Point(0, 0);
+
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_True;
+}
+
+SdrTextObj::SdrTextObj(SdrObjKind eNewTextKind, const Rectangle& rNewRect, SvStream& rInput, const String& rBaseURL, USHORT eFormat)
+: SdrAttrObj(),
+ aRect(rNewRect),
+ mpText(NULL),
+ pEdtOutl(NULL),
+ pFormTextBoundRect(NULL),
+ eTextKind(eNewTextKind)
+{
+ bTextSizeDirty=FALSE;
+ bTextFrame=TRUE;
+ bNoShear=TRUE;
+ bNoRotate=FALSE;
+ bNoMirror=TRUE;
+ bDisableAutoWidthOnDragging=FALSE;
+ ImpJustifyRect(aRect);
+
+ NbcSetText(rInput, rBaseURL, eFormat);
+
+ // #101684#
+ mbInEditMode = FALSE;
+
+ // #111096#
+ mbTextHidden = sal_False;
+
+ // #111096#
+ mbTextAnimationAllowed = sal_True;
+ mbInDownScale = sal_False;
+
+ // #108784#
+ maTextEditOffset = Point(0, 0);
+
+ // #i25616#
+ mbSupportTextIndentingOnLineWidthChange = sal_True;
+}
+
+SdrTextObj::~SdrTextObj()
+{
+ if( pModel )
+ {
+ SdrOutliner& rOutl = pModel->GetHitTestOutliner();
+ if( rOutl.GetTextObj() == this )
+ rOutl.SetTextObj( NULL );
+ }
+
+ if(mpText!=NULL)
+ delete mpText;
+
+ if (pFormTextBoundRect!=NULL)
+ delete pFormTextBoundRect;
+
+ ImpLinkAbmeldung();
+}
+
+void SdrTextObj::FitFrameToTextSize()
+{
+ DBG_ASSERT(pModel!=NULL,"SdrTextObj::FitFrameToTextSize(): pModel=NULL!");
+ ImpJustifyRect(aRect);
+
+ SdrText* pText = getActiveText();
+ if( pText!=NULL && pText->GetOutlinerParaObject() && pModel!=NULL)
+ {
+ SdrOutliner& rOutliner=ImpGetDrawOutliner();
+ rOutliner.SetPaperSize(Size(aRect.Right()-aRect.Left(),aRect.Bottom()-aRect.Top()));
+ rOutliner.SetUpdateMode(TRUE);
+ rOutliner.SetText(*pText->GetOutlinerParaObject());
+ Rectangle aTextRect;
+ Size aNewSize(rOutliner.CalcTextSize());
+ rOutliner.Clear();
+ aNewSize.Width()++; // wegen evtl. Rundungsfehler
+ aNewSize.Width()+=GetTextLeftDistance()+GetTextRightDistance();
+ aNewSize.Height()+=GetTextUpperDistance()+GetTextLowerDistance();
+ Rectangle aNewRect(aRect);
+ aNewRect.SetSize(aNewSize);
+ ImpJustifyRect(aNewRect);
+ if (aNewRect!=aRect) {
+ SetLogicRect(aNewRect);
+ }
+ }
+}
+
+void SdrTextObj::NbcSetText(const XubString& rStr)
+{
+ SdrOutliner& rOutliner=ImpGetDrawOutliner();
+ rOutliner.SetStyleSheet( 0, GetStyleSheet());
+ //OutputDevice* pRef1=rOutliner.GetRefDevice();
+ rOutliner.SetUpdateMode(TRUE);
+ rOutliner.SetText(rStr,rOutliner.GetParagraph( 0 ));
+ OutlinerParaObject* pNewText=rOutliner.CreateParaObject();
+ Size aSiz(rOutliner.CalcTextSize());
+ //OutputDevice* pRef2=rOutliner.GetRefDevice();
+ rOutliner.Clear();
+ NbcSetOutlinerParaObject(pNewText);
+ aTextSize=aSiz;
+ bTextSizeDirty=FALSE;
+}
+
+void SdrTextObj::SetText(const XubString& rStr)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetText(rStr);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ //if (GetBoundRect()!=aBoundRect0) {
+ // SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ //}
+}
+
+void SdrTextObj::NbcSetText(SvStream& rInput, const String& rBaseURL, USHORT eFormat)
+{
+ SdrOutliner& rOutliner=ImpGetDrawOutliner();
+ rOutliner.SetStyleSheet( 0, GetStyleSheet());
+ rOutliner.Read(rInput,rBaseURL,eFormat);
+ OutlinerParaObject* pNewText=rOutliner.CreateParaObject();
+ rOutliner.SetUpdateMode(TRUE);
+ Size aSiz(rOutliner.CalcTextSize());
+ rOutliner.Clear();
+ NbcSetOutlinerParaObject(pNewText);
+ aTextSize=aSiz;
+ bTextSizeDirty=FALSE;
+}
+
+void SdrTextObj::SetText(SvStream& rInput, const String& rBaseURL, USHORT eFormat)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcSetText(rInput,rBaseURL,eFormat);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+const Size& SdrTextObj::GetTextSize() const
+{
+ if (bTextSizeDirty)
+ {
+ Size aSiz;
+ SdrText* pText = getActiveText();
+ if( pText && pText->GetOutlinerParaObject ())
+ {
+ SdrOutliner& rOutliner=ImpGetDrawOutliner();
+ rOutliner.SetText(*pText->GetOutlinerParaObject());
+ rOutliner.SetUpdateMode(TRUE);
+ aSiz=rOutliner.CalcTextSize();
+ rOutliner.Clear();
+ }
+ // 2x casting auf nonconst
+ ((SdrTextObj*)this)->aTextSize=aSiz;
+ ((SdrTextObj*)this)->bTextSizeDirty=FALSE;
+ }
+ return aTextSize;
+}
+
+bool SdrTextObj::IsAutoGrowHeight() const
+{
+ if(!bTextFrame)
+ return FALSE; // AutoGrow nur bei TextFrames
+
+ const SfxItemSet& rSet = GetObjectItemSet();
+ BOOL bRet = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT))).GetValue();
+
+ if(bRet)
+ {
+ SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
+
+ if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
+ {
+ SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
+
+ if(eDirection == SDRTEXTANI_UP || eDirection == SDRTEXTANI_DOWN)
+ {
+ bRet = FALSE;
+ }
+ }
+ }
+ return bRet;
+}
+
+bool SdrTextObj::IsAutoGrowWidth() const
+{
+ if(!bTextFrame)
+ return FALSE; // AutoGrow nur bei TextFrames
+
+ const SfxItemSet& rSet = GetObjectItemSet();
+ BOOL bRet = ((SdrTextAutoGrowHeightItem&)(rSet.Get(SDRATTR_TEXT_AUTOGROWWIDTH))).GetValue();
+
+ // #101684#
+ BOOL bInEditMOde = IsInEditMode();
+
+ if(!bInEditMOde && bRet)
+ {
+ SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
+
+ if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
+ {
+ SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
+
+ if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT)
+ {
+ bRet = FALSE;
+ }
+ }
+ }
+ return bRet;
+}
+
+SdrTextHorzAdjust SdrTextObj::GetTextHorizontalAdjust() const
+{
+ return GetTextHorizontalAdjust(GetObjectItemSet());
+}
+
+SdrTextHorzAdjust SdrTextObj::GetTextHorizontalAdjust(const SfxItemSet& rSet) const
+{
+ if(IsContourTextFrame())
+ return SDRTEXTHORZADJUST_BLOCK;
+
+ SdrTextHorzAdjust eRet = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
+
+ // #101684#
+ BOOL bInEditMode = IsInEditMode();
+
+ if(!bInEditMode && eRet == SDRTEXTHORZADJUST_BLOCK)
+ {
+ SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
+
+ if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
+ {
+ SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
+
+ if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT)
+ {
+ eRet = SDRTEXTHORZADJUST_LEFT;
+ }
+ }
+ }
+
+ return eRet;
+} // defaults: BLOCK fuer Textrahmen, CENTER fuer beschriftete Grafikobjekte
+
+SdrTextVertAdjust SdrTextObj::GetTextVerticalAdjust() const
+{
+ return GetTextVerticalAdjust(GetObjectItemSet());
+}
+
+SdrTextVertAdjust SdrTextObj::GetTextVerticalAdjust(const SfxItemSet& rSet) const
+{
+ if(IsContourTextFrame())
+ return SDRTEXTVERTADJUST_TOP;
+
+ // #103516# Take care for vertical text animation here
+ SdrTextVertAdjust eRet = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
+ BOOL bInEditMode = IsInEditMode();
+
+ // #103516# Take care for vertical text animation here
+ if(!bInEditMode && eRet == SDRTEXTVERTADJUST_BLOCK)
+ {
+ SdrTextAniKind eAniKind = ((SdrTextAniKindItem&)(rSet.Get(SDRATTR_TEXT_ANIKIND))).GetValue();
+
+ if(eAniKind == SDRTEXTANI_SCROLL || eAniKind == SDRTEXTANI_ALTERNATE || eAniKind == SDRTEXTANI_SLIDE)
+ {
+ SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
+
+ if(eDirection == SDRTEXTANI_LEFT || eDirection == SDRTEXTANI_RIGHT)
+ {
+ eRet = SDRTEXTVERTADJUST_TOP;
+ }
+ }
+ }
+
+ return eRet;
+} // defaults: TOP fuer Textrahmen, CENTER fuer beschriftete Grafikobjekte
+
+void SdrTextObj::ImpJustifyRect(Rectangle& rRect) const
+{
+ if (!rRect.IsEmpty()) {
+ rRect.Justify();
+ if (rRect.Left()==rRect.Right()) rRect.Right()++;
+ if (rRect.Top()==rRect.Bottom()) rRect.Bottom()++;
+ }
+}
+
+void SdrTextObj::ImpCheckShear()
+{
+ if (bNoShear && aGeo.nShearWink!=0) {
+ aGeo.nShearWink=0;
+ aGeo.nTan=0;
+ }
+}
+
+void SdrTextObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ bool bNoTextFrame=!IsTextFrame();
+ rInfo.bResizeFreeAllowed=bNoTextFrame || aGeo.nDrehWink%9000==0;
+ rInfo.bResizePropAllowed=TRUE;
+ rInfo.bRotateFreeAllowed=TRUE;
+ rInfo.bRotate90Allowed =TRUE;
+ rInfo.bMirrorFreeAllowed=bNoTextFrame;
+ rInfo.bMirror45Allowed =bNoTextFrame;
+ rInfo.bMirror90Allowed =bNoTextFrame;
+
+ // allow transparence
+ rInfo.bTransparenceAllowed = TRUE;
+
+ // gradient depends on fillstyle
+ XFillStyle eFillStyle = ((XFillStyleItem&)(GetObjectItem(XATTR_FILLSTYLE))).GetValue();
+ rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT);
+ rInfo.bShearAllowed =bNoTextFrame;
+ rInfo.bEdgeRadiusAllowed=TRUE;
+ bool bCanConv=ImpCanConvTextToCurve();
+ rInfo.bCanConvToPath =bCanConv;
+ rInfo.bCanConvToPoly =bCanConv;
+ rInfo.bCanConvToPathLineToArea=bCanConv;
+ rInfo.bCanConvToPolyLineToArea=bCanConv;
+ rInfo.bCanConvToContour = (rInfo.bCanConvToPoly || LineGeometryUsageIsNecessary());
+}
+
+UINT16 SdrTextObj::GetObjIdentifier() const
+{
+ return USHORT(eTextKind);
+}
+
+bool SdrTextObj::HasTextImpl( SdrOutliner* pOutliner )
+{
+ bool bRet=false;
+ if(pOutliner)
+ {
+ Paragraph* p1stPara=pOutliner->GetParagraph( 0 );
+ ULONG nParaAnz=pOutliner->GetParagraphCount();
+ if(p1stPara==NULL)
+ nParaAnz=0;
+
+ if(nParaAnz==1)
+ {
+ // if it is only one paragraph, check if that paragraph is empty
+ XubString aStr(pOutliner->GetText(p1stPara));
+
+ if(!aStr.Len())
+ nParaAnz = 0;
+ }
+
+ bRet= nParaAnz!=0;
+ }
+ return bRet;
+}
+
+bool SdrTextObj::HasEditText() const
+{
+ return HasTextImpl( pEdtOutl );
+}
+
+void SdrTextObj::SetPage(SdrPage* pNewPage)
+{
+ bool bRemove=pNewPage==NULL && pPage!=NULL;
+ bool bInsert=pNewPage!=NULL && pPage==NULL;
+ bool bLinked=IsLinkedText();
+
+ if (bLinked && bRemove) {
+ ImpLinkAbmeldung();
+ }
+
+ SdrAttrObj::SetPage(pNewPage);
+
+ if (bLinked && bInsert) {
+ ImpLinkAnmeldung();
+ }
+}
+
+void SdrTextObj::SetModel(SdrModel* pNewModel)
+{
+ SdrModel* pOldModel=pModel;
+ bool bLinked=IsLinkedText();
+ bool bChg=pNewModel!=pModel;
+
+ if (bLinked && bChg)
+ {
+ ImpLinkAbmeldung();
+ }
+
+ SdrAttrObj::SetModel(pNewModel);
+
+ if( bChg )
+ {
+ if( pNewModel != 0 && pOldModel != 0 )
+ SetTextSizeDirty();
+
+ sal_Int32 nCount = getTextCount();
+ for( sal_Int32 nText = 0; nText < nCount; nText++ )
+ {
+ SdrText* pText = getText( nText );
+ if( pText )
+ pText->SetModel( pNewModel );
+ }
+ }
+
+ if (bLinked && bChg)
+ {
+ ImpLinkAnmeldung();
+ }
+}
+
+bool SdrTextObj::NbcSetEckenradius(long nRad)
+{
+ SetObjectItem(SdrEckenradiusItem(nRad));
+ return true;
+}
+
+bool SdrTextObj::NbcSetAutoGrowHeight(bool bAuto)
+{
+ if(bTextFrame)
+ {
+ SetObjectItem(SdrTextAutoGrowHeightItem(bAuto));
+ return true;
+ }
+ return false;
+}
+
+bool SdrTextObj::NbcSetMinTextFrameHeight(long nHgt)
+{
+ if( bTextFrame && ( !pModel || !pModel->isLocked() ) ) // SJ: #i44922#
+ {
+ SetObjectItem(SdrTextMinFrameHeightItem(nHgt));
+
+ // #84974# use bDisableAutoWidthOnDragging as
+ // bDisableAutoHeightOnDragging if vertical.
+ if(IsVerticalWriting() && bDisableAutoWidthOnDragging)
+ {
+ bDisableAutoWidthOnDragging = FALSE;
+ SetObjectItem(SdrTextAutoGrowHeightItem(FALSE));
+ }
+
+ return true;
+ }
+ return false;
+}
+
+bool SdrTextObj::NbcSetMaxTextFrameHeight(long nHgt)
+{
+ if(bTextFrame)
+ {
+ SetObjectItem(SdrTextMaxFrameHeightItem(nHgt));
+ return true;
+ }
+ return false;
+}
+
+bool SdrTextObj::NbcSetAutoGrowWidth(bool bAuto)
+{
+ if(bTextFrame)
+ {
+ SetObjectItem(SdrTextAutoGrowWidthItem(bAuto));
+ return true;
+ }
+ return false;
+}
+
+bool SdrTextObj::NbcSetMinTextFrameWidth(long nWdt)
+{
+ if( bTextFrame && ( !pModel || !pModel->isLocked() ) ) // SJ: #i44922#
+ {
+ SetObjectItem(SdrTextMinFrameWidthItem(nWdt));
+
+ // #84974# use bDisableAutoWidthOnDragging only
+ // when not vertical.
+ if(!IsVerticalWriting() && bDisableAutoWidthOnDragging)
+ {
+ bDisableAutoWidthOnDragging = FALSE;
+ SetObjectItem(SdrTextAutoGrowWidthItem(FALSE));
+ }
+
+ return true;
+ }
+ return false;
+}
+
+bool SdrTextObj::NbcSetMaxTextFrameWidth(long nWdt)
+{
+ if(bTextFrame)
+ {
+ SetObjectItem(SdrTextMaxFrameWidthItem(nWdt));
+ return true;
+ }
+ return false;
+}
+
+bool SdrTextObj::NbcSetFitToSize(SdrFitToSizeType eFit)
+{
+ if(bTextFrame)
+ {
+ SetObjectItem(SdrTextFitToSizeTypeItem(eFit));
+ return true;
+ }
+ return false;
+}
+
+void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, Rectangle& rAnchorRect, BOOL bLineWidth ) const
+{
+ basegfx::B2DPolyPolygon aXorPolyPolygon(TakeXorPoly());
+ basegfx::B2DPolyPolygon* pContourPolyPolygon = 0L;
+ basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix(
+ -rAnchorRect.Left(), -rAnchorRect.Top()));
+
+ if(aGeo.nDrehWink)
+ {
+ // Unrotate!
+ aMatrix.rotate(-aGeo.nDrehWink * nPi180);
+ }
+
+ aXorPolyPolygon.transform(aMatrix);
+
+ if( bLineWidth )
+ {
+ // Strichstaerke beruecksichtigen
+ // Beim Hittest muss das unterbleiben (Performance!)
+ pContourPolyPolygon = new basegfx::B2DPolyPolygon();
+
+ // #86258# test if shadow needs to be avoided for TakeContour()
+ const SfxItemSet& rSet = GetObjectItemSet();
+ sal_Bool bShadowOn = ((SdrShadowItem&)(rSet.Get(SDRATTR_SHADOW))).GetValue();
+
+ // #i33696#
+ // Remember TextObject currently set at the DrawOutliner, it WILL be
+ // replaced during calculating the outline since it uses an own paint
+ // and that one uses the DrawOutliner, too.
+ const SdrTextObj* pLastTextObject = rOutliner.GetTextObj();
+
+ if(bShadowOn)
+ {
+ // #86258# force shadow off
+ SdrObject* pCopy = Clone();
+ pCopy->SetMergedItem(SdrShadowItem(FALSE));
+ *pContourPolyPolygon = pCopy->TakeContour();
+ SdrObject::Free( pCopy );
+ }
+ else
+ {
+ *pContourPolyPolygon = TakeContour();
+ }
+
+ // #i33696#
+ // restore remembered text object
+ if(pLastTextObject != rOutliner.GetTextObj())
+ {
+ rOutliner.SetTextObj(pLastTextObject);
+ }
+
+ pContourPolyPolygon->transform(aMatrix);
+ }
+
+ rOutliner.SetPolygon(aXorPolyPolygon, pContourPolyPolygon);
+}
+
+void SdrTextObj::TakeUnrotatedSnapRect(Rectangle& rRect) const
+{
+ rRect=aRect;
+}
+
+void SdrTextObj::TakeTextAnchorRect(Rectangle& rAnchorRect) const
+{
+ long nLeftDist=GetTextLeftDistance();
+ long nRightDist=GetTextRightDistance();
+ long nUpperDist=GetTextUpperDistance();
+ long nLowerDist=GetTextLowerDistance();
+ Rectangle aAnkRect(aRect); // Rect innerhalb dem geankert wird
+ bool bFrame=IsTextFrame();
+ if (!bFrame) {
+ TakeUnrotatedSnapRect(aAnkRect);
+ }
+ Point aRotateRef(aAnkRect.TopLeft());
+ aAnkRect.Left()+=nLeftDist;
+ aAnkRect.Top()+=nUpperDist;
+ aAnkRect.Right()-=nRightDist;
+ aAnkRect.Bottom()-=nLowerDist;
+
+ // #108816#
+ // Since sizes may be bigger than the object bounds it is necessary to
+ // justify the rect now.
+ ImpJustifyRect(aAnkRect);
+
+ if (bFrame) {
+ // !!! hier noch etwas verfeinern !!!
+ if (aAnkRect.GetWidth()<2) aAnkRect.Right()=aAnkRect.Left()+1; // Mindestgroesse 2
+ if (aAnkRect.GetHeight()<2) aAnkRect.Bottom()=aAnkRect.Top()+1; // Mindestgroesse 2
+ }
+ if (aGeo.nDrehWink!=0) {
+ Point aTmpPt(aAnkRect.TopLeft());
+ RotatePoint(aTmpPt,aRotateRef,aGeo.nSin,aGeo.nCos);
+ aTmpPt-=aAnkRect.TopLeft();
+ aAnkRect.Move(aTmpPt.X(),aTmpPt.Y());
+ }
+ rAnchorRect=aAnkRect;
+}
+
+void SdrTextObj::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText,
+ Rectangle* pAnchorRect, BOOL bLineWidth ) const
+{
+ Rectangle aAnkRect; // Rect innerhalb dem geankert wird
+ TakeTextAnchorRect(aAnkRect);
+ SdrTextVertAdjust eVAdj=GetTextVerticalAdjust();
+ SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust();
+ SdrTextAniKind eAniKind=GetTextAniKind();
+ SdrTextAniDirection eAniDirection=GetTextAniDirection();
+
+ bool bFitToSize(IsFitToSize());
+ bool bContourFrame=IsContourTextFrame();
+
+ bool bFrame=IsTextFrame();
+ ULONG nStat0=rOutliner.GetControlWord();
+ Size aNullSize;
+ if (!bContourFrame)
+ {
+ rOutliner.SetControlWord(nStat0|EE_CNTRL_AUTOPAGESIZE);
+ rOutliner.SetMinAutoPaperSize(aNullSize);
+ rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
+ }
+
+ if (!bFitToSize && !bContourFrame)
+ {
+ long nAnkWdt=aAnkRect.GetWidth();
+ long nAnkHgt=aAnkRect.GetHeight();
+ if (bFrame)
+ {
+ long nWdt=nAnkWdt;
+ long nHgt=nAnkHgt;
+
+ // #101684#
+ BOOL bInEditMode = IsInEditMode();
+
+ if (!bInEditMode && (eAniKind==SDRTEXTANI_SCROLL || eAniKind==SDRTEXTANI_ALTERNATE || eAniKind==SDRTEXTANI_SLIDE))
+ {
+ // Grenzenlose Papiergroesse fuer Laufschrift
+ if (eAniDirection==SDRTEXTANI_LEFT || eAniDirection==SDRTEXTANI_RIGHT) nWdt=1000000;
+ if (eAniDirection==SDRTEXTANI_UP || eAniDirection==SDRTEXTANI_DOWN) nHgt=1000000;
+ }
+ rOutliner.SetMaxAutoPaperSize(Size(nWdt,nHgt));
+ }
+
+ // #103516# New try with _BLOCK for hor and ver after completely
+ // supporting full width for vertical text.
+ if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
+ {
+ rOutliner.SetMinAutoPaperSize(Size(nAnkWdt, 0));
+ }
+
+ if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting())
+ {
+ rOutliner.SetMinAutoPaperSize(Size(0, nAnkHgt));
+ }
+ }
+
+ rOutliner.SetPaperSize(aNullSize);
+ if (bContourFrame)
+ ImpSetContourPolygon( rOutliner, aAnkRect, bLineWidth );
+
+ // put text into the outliner, if available from the edit outliner
+ SdrText* pText = getActiveText();
+ OutlinerParaObject* pOutlinerParaObject = pText ? pText->GetOutlinerParaObject() : 0;
+ OutlinerParaObject* pPara = (pEdtOutl && !bNoEditText) ? pEdtOutl->CreateParaObject() : pOutlinerParaObject;
+
+ if (pPara)
+ {
+ BOOL bHitTest = FALSE;
+ if( pModel )
+ bHitTest = &pModel->GetHitTestOutliner() == &rOutliner;
+
+ const SdrTextObj* pTestObj = rOutliner.GetTextObj();
+ if( !pTestObj || !bHitTest || pTestObj != this ||
+ pTestObj->GetOutlinerParaObject() != pOutlinerParaObject )
+ {
+ if( bHitTest ) // #i33696# take back fix #i27510#
+ {
+ rOutliner.SetTextObj( this );
+ rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
+ }
+
+ rOutliner.SetUpdateMode(TRUE);
+ rOutliner.SetText(*pPara);
+ }
+ }
+ else
+ {
+ rOutliner.SetTextObj( NULL );
+ }
+
+ if (pEdtOutl && !bNoEditText && pPara)
+ delete pPara;
+
+ rOutliner.SetUpdateMode(TRUE);
+ rOutliner.SetControlWord(nStat0);
+
+ if( pText )
+ pText->CheckPortionInfo(rOutliner);
+
+ Point aTextPos(aAnkRect.TopLeft());
+ Size aTextSiz(rOutliner.GetPaperSize()); // GetPaperSize() hat etwas Toleranz drauf, oder?
+
+ // #106653#
+ // For draw objects containing text correct hor/ver alignment if text is bigger
+ // than the object itself. Without that correction, the text would always be
+ // formatted to the left edge (or top edge when vertical) of the draw object.
+ if(!IsTextFrame())
+ {
+ if(aAnkRect.GetWidth() < aTextSiz.Width() && !IsVerticalWriting())
+ {
+ // #110129#
+ // Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK,
+ // else the alignment is wanted.
+ if(SDRTEXTHORZADJUST_BLOCK == eHAdj)
+ {
+ eHAdj = SDRTEXTHORZADJUST_CENTER;
+ }
+ }
+
+ if(aAnkRect.GetHeight() < aTextSiz.Height() && IsVerticalWriting())
+ {
+ // #110129#
+ // Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK,
+ // else the alignment is wanted.
+ if(SDRTEXTVERTADJUST_BLOCK == eVAdj)
+ {
+ eVAdj = SDRTEXTVERTADJUST_CENTER;
+ }
+ }
+ }
+
+ if (eHAdj==SDRTEXTHORZADJUST_CENTER || eHAdj==SDRTEXTHORZADJUST_RIGHT)
+ {
+ long nFreeWdt=aAnkRect.GetWidth()-aTextSiz.Width();
+ if (eHAdj==SDRTEXTHORZADJUST_CENTER)
+ aTextPos.X()+=nFreeWdt/2;
+ if (eHAdj==SDRTEXTHORZADJUST_RIGHT)
+ aTextPos.X()+=nFreeWdt;
+ }
+ if (eVAdj==SDRTEXTVERTADJUST_CENTER || eVAdj==SDRTEXTVERTADJUST_BOTTOM)
+ {
+ long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height();
+ if (eVAdj==SDRTEXTVERTADJUST_CENTER)
+ aTextPos.Y()+=nFreeHgt/2;
+ if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
+ aTextPos.Y()+=nFreeHgt;
+ }
+ if (aGeo.nDrehWink!=0)
+ RotatePoint(aTextPos,aAnkRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+
+ if (pAnchorRect)
+ *pAnchorRect=aAnkRect;
+
+ // rTextRect ist bei ContourFrame in einigen Faellen nicht korrekt
+ rTextRect=Rectangle(aTextPos,aTextSiz);
+ if (bContourFrame)
+ rTextRect=aAnkRect;
+}
+
+OutlinerParaObject* SdrTextObj::GetEditOutlinerParaObject() const
+{
+ OutlinerParaObject* pPara=NULL;
+ if( HasTextImpl( pEdtOutl ) )
+ {
+ sal_uInt16 nParaAnz = static_cast< sal_uInt16 >( pEdtOutl->GetParagraphCount() );
+ pPara = pEdtOutl->CreateParaObject(0, nParaAnz);
+ }
+ return pPara;
+}
+
+void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size& rTextSize, const Size& rShapeSize, Fraction& rFitXKorreg) const
+{
+ OutputDevice* pOut = rOutliner.GetRefDevice();
+ BOOL bNoStretching(FALSE);
+
+ if(pOut && pOut->GetOutDevType() == OUTDEV_PRINTER)
+ {
+ // #35762#: Checken ob CharStretching ueberhaupt moeglich
+ GDIMetaFile* pMtf = pOut->GetConnectMetaFile();
+ UniString aTestString(sal_Unicode('J'));
+
+ if(pMtf && (!pMtf->IsRecord() || pMtf->IsPause()))
+ pMtf = NULL;
+
+ if(pMtf)
+ pMtf->Pause(TRUE);
+
+ Font aFontMerk(pOut->GetFont());
+ Font aTmpFont( OutputDevice::GetDefaultFont( DEFAULTFONT_SERIF, LANGUAGE_SYSTEM, DEFAULTFONT_FLAGS_ONLYONE ) );
+
+ aTmpFont.SetSize(Size(0,100));
+ pOut->SetFont(aTmpFont);
+ Size aSize1(pOut->GetTextWidth(aTestString), pOut->GetTextHeight());
+ aTmpFont.SetSize(Size(800,100));
+ pOut->SetFont(aTmpFont);
+ Size aSize2(pOut->GetTextWidth(aTestString), pOut->GetTextHeight());
+ pOut->SetFont(aFontMerk);
+
+ if(pMtf)
+ pMtf->Pause(FALSE);
+
+ bNoStretching = (aSize1 == aSize2);
+
+#ifdef WNT
+ // #35762# Windows vergroessert bei Size(100,500) den Font proportional
+ // Und das finden wir nicht so schoen.
+ if(aSize2.Height() >= aSize1.Height() * 2)
+ {
+ bNoStretching = TRUE;
+ }
+#endif
+ }
+ unsigned nLoopCount=0;
+ bool bNoMoreLoop = false;
+ long nXDiff0=0x7FFFFFFF;
+ long nWantWdt=rShapeSize.Width();
+ long nIsWdt=rTextSize.Width();
+ if (nIsWdt==0) nIsWdt=1;
+
+ long nWantHgt=rShapeSize.Height();
+ long nIsHgt=rTextSize.Height();
+ if (nIsHgt==0) nIsHgt=1;
+
+ long nXTolPl=nWantWdt/100; // Toleranz +1%
+ long nXTolMi=nWantWdt/25; // Toleranz -4%
+ long nXKorr =nWantWdt/20; // Korrekturmasstab 5%
+
+ long nX=(nWantWdt*100) /nIsWdt; // X-Stretching berechnen
+ long nY=(nWantHgt*100) /nIsHgt; // Y-Stretching berechnen
+ bool bChkX = true;
+ bool bChkY = true;
+ if (bNoStretching) { // #35762# evtl. nur proportional moeglich
+ if (nX>nY) { nX=nY; bChkX=FALSE; }
+ else { nY=nX; bChkY=FALSE; }
+ }
+
+ while (nLoopCount<5 && !bNoMoreLoop) {
+ if (nX<0) nX=-nX;
+ if (nX<1) { nX=1; bNoMoreLoop = true; }
+ if (nX>65535) { nX=65535; bNoMoreLoop = true; }
+
+ if (nY<0) nY=-nY;
+ if (nY<1) { nY=1; bNoMoreLoop = true; }
+ if (nY>65535) { nY=65535; bNoMoreLoop = true; }
+
+ // exception, there is no text yet (horizontal case)
+ if(nIsWdt <= 1)
+ {
+ nX = nY;
+ bNoMoreLoop = true;
+ }
+
+ // #87877# exception, there is no text yet (vertical case)
+ if(nIsHgt <= 1)
+ {
+ nY = nX;
+ bNoMoreLoop = true;
+ }
+
+ rOutliner.SetGlobalCharStretching((USHORT)nX,(USHORT)nY);
+ nLoopCount++;
+ Size aSiz(rOutliner.CalcTextSize());
+ long nXDiff=aSiz.Width()-nWantWdt;
+ rFitXKorreg=Fraction(nWantWdt,aSiz.Width());
+ if (((nXDiff>=nXTolMi || !bChkX) && nXDiff<=nXTolPl) || nXDiff==nXDiff0/*&& Abs(nYDiff)<=nYTol*/) {
+ bNoMoreLoop = true;
+ } else {
+ // Stretchingfaktoren korregieren
+ long nMul=nWantWdt;
+ long nDiv=aSiz.Width();
+ if (Abs(nXDiff)<=2*nXKorr) {
+ if (nMul>nDiv) nDiv+=(nMul-nDiv)/2; // und zwar nur um die haelfte des berechneten
+ else nMul+=(nDiv-nMul)/2; // weil die EE ja eh wieder falsch rechnet
+ }
+ nX=nX*nMul/nDiv;
+ if (bNoStretching) nY=nX;
+ }
+ nXDiff0=nXDiff;
+ }
+}
+
+void SdrTextObj::StartTextAnimation(OutputDevice* /*pOutDev*/, const Point& /*rOffset*/, long /*nExtraData*/)
+{
+ // #111096#
+ // use new text animation
+ SetTextAnimationAllowed(sal_True);
+}
+
+void SdrTextObj::StopTextAnimation(OutputDevice* /*pOutDev*/, long /*nExtraData*/)
+{
+ // #111096#
+ // use new text animation
+ SetTextAnimationAllowed(sal_False);
+}
+
+void SdrTextObj::TakeObjNameSingul(XubString& rName) const
+{
+ XubString aStr;
+
+ switch(eTextKind)
+ {
+ case OBJ_OUTLINETEXT:
+ {
+ aStr = ImpGetResStr(STR_ObjNameSingulOUTLINETEXT);
+ break;
+ }
+
+ case OBJ_TITLETEXT :
+ {
+ aStr = ImpGetResStr(STR_ObjNameSingulTITLETEXT);
+ break;
+ }
+
+ default:
+ {
+ if(IsLinkedText())
+ aStr = ImpGetResStr(STR_ObjNameSingulTEXTLNK);
+ else
+ aStr = ImpGetResStr(STR_ObjNameSingulTEXT);
+ break;
+ }
+ }
+
+ OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+ if(pOutlinerParaObject && eTextKind != OBJ_OUTLINETEXT)
+ {
+ // Macht bei OUTLINETEXT wohl derzeit noch etwas Probleme
+ XubString aStr2(pOutlinerParaObject->GetTextObject().GetText(0));
+ aStr2.EraseLeadingChars();
+
+ // #69446# avoid non expanded text portions in object name
+ // (second condition is new)
+ if(aStr2.Len() && aStr2.Search(sal_Unicode(255)) == STRING_NOTFOUND)
+ {
+ // #76681# space between ResStr and content text
+ aStr += sal_Unicode(' ');
+
+ aStr += sal_Unicode('\'');
+
+ if(aStr2.Len() > 10)
+ {
+ aStr2.Erase(8);
+ aStr2.AppendAscii("...", 3);
+ }
+
+ aStr += aStr2;
+ aStr += sal_Unicode('\'');
+ }
+ }
+
+ rName = aStr;
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+
+}
+
+void SdrTextObj::TakeObjNamePlural(XubString& rName) const
+{
+ switch (eTextKind) {
+ case OBJ_OUTLINETEXT: rName=ImpGetResStr(STR_ObjNamePluralOUTLINETEXT); break;
+ case OBJ_TITLETEXT : rName=ImpGetResStr(STR_ObjNamePluralTITLETEXT); break;
+ default: {
+ if (IsLinkedText()) {
+ rName=ImpGetResStr(STR_ObjNamePluralTEXTLNK);
+ } else {
+ rName=ImpGetResStr(STR_ObjNamePluralTEXT);
+ }
+ } break;
+ } // switch
+}
+
+void SdrTextObj::operator=(const SdrObject& rObj)
+{
+ // call parent
+ SdrObject::operator=(rObj);
+
+ const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >( &rObj );
+ if (pTextObj!=NULL)
+ {
+ aRect =pTextObj->aRect;
+ aGeo =pTextObj->aGeo;
+ eTextKind =pTextObj->eTextKind;
+ bTextFrame=pTextObj->bTextFrame;
+ aTextSize=pTextObj->aTextSize;
+ bTextSizeDirty=pTextObj->bTextSizeDirty;
+
+ // #101776# Not all of the necessary parameters were copied yet.
+ bNoShear = pTextObj->bNoShear;
+ bNoRotate = pTextObj->bNoRotate;
+ bNoMirror = pTextObj->bNoMirror;
+ bDisableAutoWidthOnDragging = pTextObj->bDisableAutoWidthOnDragging;
+
+ OutlinerParaObject* pNewOutlinerParaObject = 0;
+
+ SdrText* pText = getActiveText();
+
+ if( pText && pTextObj->HasText() )
+ {
+ const Outliner* pEO=pTextObj->pEdtOutl;
+ if (pEO!=NULL)
+ {
+ pNewOutlinerParaObject = pEO->CreateParaObject();
+ }
+ else
+ {
+ pNewOutlinerParaObject = new OutlinerParaObject(*pTextObj->getActiveText()->GetOutlinerParaObject());
+ }
+ }
+
+ mpText->SetOutlinerParaObject( pNewOutlinerParaObject );
+ ImpSetTextStyleSheetListeners();
+ }
+}
+
+basegfx::B2DPolyPolygon SdrTextObj::TakeXorPoly() const
+{
+ Polygon aPol(aRect);
+ if (aGeo.nShearWink!=0) ShearPoly(aPol,aRect.TopLeft(),aGeo.nTan);
+ if (aGeo.nDrehWink!=0) RotatePoly(aPol,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+
+ basegfx::B2DPolyPolygon aRetval;
+ aRetval.append(aPol.getB2DPolygon());
+ return aRetval;
+}
+
+basegfx::B2DPolyPolygon SdrTextObj::TakeContour() const
+{
+ basegfx::B2DPolyPolygon aRetval(SdrAttrObj::TakeContour());
+
+ // und nun noch ggf. das BoundRect des Textes dazu
+ if ( pModel && GetOutlinerParaObject() && !IsFontwork() && !IsContourTextFrame() )
+ {
+ // #80328# using Clone()-Paint() strategy inside TakeContour() leaves a destroyed
+ // SdrObject as pointer in DrawOutliner. Set *this again in fetching the outliner
+ // in every case
+ SdrOutliner& rOutliner=ImpGetDrawOutliner();
+
+ Rectangle aAnchor2;
+ Rectangle aR;
+ TakeTextRect(rOutliner,aR,FALSE,&aAnchor2);
+ rOutliner.Clear();
+ bool bFitToSize(IsFitToSize());
+ if (bFitToSize) aR=aAnchor2;
+ Polygon aPol(aR);
+ if (aGeo.nDrehWink!=0) RotatePoly(aPol,aR.TopLeft(),aGeo.nSin,aGeo.nCos);
+
+ aRetval.append(aPol.getB2DPolygon());
+ }
+
+ return aRetval;
+}
+
+void SdrTextObj::RecalcSnapRect()
+{
+ if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) {
+ Polygon aPol(aRect);
+ if (aGeo.nShearWink!=0) ShearPoly(aPol,aRect.TopLeft(),aGeo.nTan);
+ if (aGeo.nDrehWink!=0) RotatePoly(aPol,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ maSnapRect=aPol.GetBoundRect();
+ } else {
+ maSnapRect=aRect;
+ }
+}
+
+sal_uInt32 SdrTextObj::GetSnapPointCount() const
+{
+ return 4L;
+}
+
+Point SdrTextObj::GetSnapPoint(sal_uInt32 i) const
+{
+ Point aP;
+ switch (i) {
+ case 0: aP=aRect.TopLeft(); break;
+ case 1: aP=aRect.TopRight(); break;
+ case 2: aP=aRect.BottomLeft(); break;
+ case 3: aP=aRect.BottomRight(); break;
+ default: aP=aRect.Center(); break;
+ }
+ if (aGeo.nShearWink!=0) ShearPoint(aP,aRect.TopLeft(),aGeo.nTan);
+ if (aGeo.nDrehWink!=0) RotatePoint(aP,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ return aP;
+}
+
+void SdrTextObj::ImpCheckMasterCachable()
+{
+ bNotMasterCachable=FALSE;
+
+ OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+
+ if(!bNotVisibleAsMaster && pOutlinerParaObject && pOutlinerParaObject->IsEditDoc() )
+ {
+ const EditTextObject& rText= pOutlinerParaObject->GetTextObject();
+ bNotMasterCachable=rText.HasField(SvxPageField::StaticType());
+ if( !bNotMasterCachable )
+ {
+ bNotMasterCachable=rText.HasField(SvxHeaderField::StaticType());
+ if( !bNotMasterCachable )
+ {
+ bNotMasterCachable=rText.HasField(SvxFooterField::StaticType());
+ if( !bNotMasterCachable )
+ {
+ bNotMasterCachable=rText.HasField(SvxDateTimeField::StaticType());
+ }
+ }
+ }
+ }
+}
+
+// #101029#: Extracted from ImpGetDrawOutliner()
+void SdrTextObj::ImpInitDrawOutliner( SdrOutliner& rOutl ) const
+{
+ rOutl.SetUpdateMode(FALSE);
+ USHORT nOutlinerMode = OUTLINERMODE_OUTLINEOBJECT;
+ if ( !IsOutlText() )
+ nOutlinerMode = OUTLINERMODE_TEXTOBJECT;
+ rOutl.Init( nOutlinerMode );
+
+ rOutl.SetGlobalCharStretching(100,100);
+ ULONG nStat=rOutl.GetControlWord();
+ nStat&=~(EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE);
+ rOutl.SetControlWord(nStat);
+ Size aNullSize;
+ Size aMaxSize(100000,100000);
+ rOutl.SetMinAutoPaperSize(aNullSize);
+ rOutl.SetMaxAutoPaperSize(aMaxSize);
+ rOutl.SetPaperSize(aMaxSize);
+ rOutl.ClearPolygon();
+}
+
+SdrOutliner& SdrTextObj::ImpGetDrawOutliner() const
+{
+ SdrOutliner& rOutl=pModel->GetDrawOutliner(this);
+
+ // #101029#: Code extracted to ImpInitDrawOutliner()
+ ImpInitDrawOutliner( rOutl );
+
+ return rOutl;
+}
+
+boost::shared_ptr< SdrOutliner > SdrTextObj::CreateDrawOutliner()
+{
+ boost::shared_ptr< SdrOutliner > xDrawOutliner( pModel->CreateDrawOutliner(this) );
+ ImpInitDrawOutliner( *(xDrawOutliner.get()) );
+ return xDrawOutliner;
+}
+
+// #101029#: Extracted from Paint()
+void SdrTextObj::ImpSetupDrawOutlinerForPaint( bool bContourFrame,
+ SdrOutliner& rOutliner,
+ Rectangle& rTextRect,
+ Rectangle& rAnchorRect,
+ Rectangle& rPaintRect,
+ Fraction& rFitXKorreg ) const
+{
+ if (!bContourFrame)
+ {
+ // FitToSize erstmal nicht mit ContourFrame
+ if (IsFitToSize() || IsAutoFit())
+ {
+ ULONG nStat=rOutliner.GetControlWord();
+ nStat|=EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE;
+ rOutliner.SetControlWord(nStat);
+ }
+ }
+ rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
+ TakeTextRect(rOutliner, rTextRect, FALSE, &rAnchorRect);
+ rPaintRect = rTextRect;
+
+ if (!bContourFrame)
+ {
+ // FitToSize erstmal nicht mit ContourFrame
+ if (IsFitToSize())
+ {
+ ImpSetCharStretching(rOutliner,rTextRect.GetSize(),rAnchorRect.GetSize(),rFitXKorreg);
+ rPaintRect=rAnchorRect;
+ }
+ else if (IsAutoFit())
+ {
+ ImpAutoFitText(rOutliner);
+ }
+ }
+}
+
+void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner ) const
+{
+ const Size aShapeSize=GetSnapRect().GetSize();
+ ImpAutoFitText( rOutliner,
+ Size(aShapeSize.Width()-GetTextLeftDistance()-GetTextRightDistance(),
+ aShapeSize.Height()-GetTextUpperDistance()-GetTextLowerDistance()),
+ IsVerticalWriting() );
+}
+
+void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner, const Size& rTextSize, bool bIsVerticalWriting )
+{
+ // EditEngine formatting is unstable enough for
+ // line-breaking text that we need some more samples
+
+ // loop early-exits if we detect an already attained value
+ USHORT nMinStretchX=0, nMinStretchY=0;
+ USHORT aOldStretchXVals[]={0,0,0,0,0,0,0,0,0,0};
+ const size_t aStretchArySize=sizeof(aOldStretchXVals)/sizeof(*aOldStretchXVals);
+ for(unsigned int i=0; i<aStretchArySize; ++i)
+ {
+ const Size aCurrTextSize = rOutliner.CalcTextSize();
+ double fFactor(1.0);
+ if( bIsVerticalWriting )
+ fFactor = double(rTextSize.Width())/aCurrTextSize.Width();
+ else
+ fFactor = double(rTextSize.Height())/aCurrTextSize.Height();
+
+ USHORT nCurrStretchX, nCurrStretchY;
+ rOutliner.GetGlobalCharStretching(nCurrStretchX, nCurrStretchY);
+
+ if (fFactor >= 1.0 )
+ {
+ // resulting text area fits into available shape rect -
+ // err on the larger streching, to optimally fill area
+ nMinStretchX = std::max(nMinStretchX,nCurrStretchX);
+ nMinStretchY = std::max(nMinStretchY,nCurrStretchY);
+ }
+
+ aOldStretchXVals[i] = nCurrStretchX;
+ if( std::find(aOldStretchXVals, aOldStretchXVals+i, nCurrStretchX) != aOldStretchXVals+i )
+ break; // same value already attained once; algo is looping, exit
+
+ if (fFactor < 1.0 || (fFactor >= 1.0 && nCurrStretchX != 100))
+ {
+ nCurrStretchX = sal::static_int_cast<USHORT>(nCurrStretchX*fFactor);
+ nCurrStretchY = sal::static_int_cast<USHORT>(nCurrStretchY*fFactor);
+ rOutliner.SetGlobalCharStretching(std::min(USHORT(100),nCurrStretchX),
+ std::min(USHORT(100),nCurrStretchY));
+ OSL_TRACE("SdrTextObj::onEditOutlinerStatusEvent(): zoom is %d", nCurrStretchX);
+ }
+ }
+
+ OSL_TRACE("---- SdrTextObj::onEditOutlinerStatusEvent(): final zoom is %d ----", nMinStretchX);
+ rOutliner.SetGlobalCharStretching(std::min(USHORT(100),nMinStretchX),
+ std::min(USHORT(100),nMinStretchY));
+}
+
+void SdrTextObj::SetupOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaintRect ) const
+{
+ ImpInitDrawOutliner( rOutl );
+ UpdateOutlinerFormatting( rOutl, rPaintRect );
+}
+
+void SdrTextObj::UpdateOutlinerFormatting( SdrOutliner& rOutl, Rectangle& rPaintRect ) const
+{
+ Rectangle aTextRect;
+ Rectangle aAnchorRect;
+ Fraction aFitXKorreg(1,1);
+
+ bool bContourFrame=IsContourTextFrame();
+
+ ImpSetupDrawOutlinerForPaint( bContourFrame, rOutl, aTextRect, aAnchorRect, rPaintRect, aFitXKorreg );
+
+ if( GetModel() )
+ {
+ MapMode aMapMode(GetModel()->GetScaleUnit(), Point(0,0),
+ GetModel()->GetScaleFraction(),
+ GetModel()->GetScaleFraction());
+ rOutl.SetRefMapMode(aMapMode);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+OutlinerParaObject* SdrTextObj::GetOutlinerParaObject() const
+{
+ SdrText* pText = getActiveText();
+ if( pText )
+ return pText->GetOutlinerParaObject();
+ else
+ return 0;
+}
+
+bool SdrTextObj::HasOutlinerParaObject() const
+{
+ SdrText* pText = getActiveText();
+ if( pText && pText->GetOutlinerParaObject() )
+ return true;
+ return false;
+}
+
+void SdrTextObj::NbcSetOutlinerParaObject(OutlinerParaObject* pTextObject)
+{
+ NbcSetOutlinerParaObjectForText( pTextObject, getActiveText() );
+}
+
+void SdrTextObj::NbcSetOutlinerParaObjectForText( OutlinerParaObject* pTextObject, SdrText* pText )
+{
+ if( pText )
+ pText->SetOutlinerParaObject( pTextObject );
+
+ if( pText->GetOutlinerParaObject() )
+ {
+ SvxWritingModeItem aWritingMode(pText->GetOutlinerParaObject()->IsVertical()
+ ? com::sun::star::text::WritingMode_TB_RL
+ : com::sun::star::text::WritingMode_LR_TB,
+ SDRATTR_TEXTDIRECTION);
+ GetProperties().SetObjectItemDirect(aWritingMode);
+ }
+
+ SetTextSizeDirty();
+ if (IsTextFrame() && (IsAutoGrowHeight() || IsAutoGrowWidth()))
+ { // Textrahmen anpassen!
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ if (!IsTextFrame())
+ {
+ // Das SnapRect behaelt seine Groesse bei
+ SetRectsDirty(sal_True);
+ }
+
+ // always invalidate BoundRect on change
+ SetBoundRectDirty();
+ ActionChanged();
+
+ ImpSetTextStyleSheetListeners();
+ ImpCheckMasterCachable();
+}
+
+void SdrTextObj::NbcReformatText()
+{
+ SdrText* pText = getActiveText();
+ if( pText && pText->GetOutlinerParaObject() )
+ {
+ pText->ReformatText();
+ if (bTextFrame)
+ {
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ else
+ {
+ // Das SnapRect behaelt seine Groesse bei
+ SetBoundRectDirty();
+ SetRectsDirty(sal_True);
+ }
+ SetTextSizeDirty();
+ ActionChanged();
+ // FME, AW: i22396
+ // Necessary here since we have no compare operator at the outliner
+ // para object which may detect changes regarding the combination
+ // of outliner para data and configuration (e.g., change of
+ // formatting of text numerals)
+ GetViewContact().flushViewObjectContacts(false);
+ }
+}
+
+void SdrTextObj::ReformatText()
+{
+ if(GetOutlinerParaObject())
+ {
+ Rectangle aBoundRect0;
+ if (pUserCall!=NULL)
+ aBoundRect0=GetLastBoundRect();
+
+ // #110094#-14 SendRepaintBroadcast();
+ NbcReformatText();
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+SdrObjGeoData* SdrTextObj::NewGeoData() const
+{
+ return new SdrTextObjGeoData;
+}
+
+void SdrTextObj::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ SdrAttrObj::SaveGeoData(rGeo);
+ SdrTextObjGeoData& rTGeo=(SdrTextObjGeoData&)rGeo;
+ rTGeo.aRect =aRect;
+ rTGeo.aGeo =aGeo;
+}
+
+void SdrTextObj::RestGeoData(const SdrObjGeoData& rGeo)
+{ // RectsDirty wird von SdrObject gerufen
+ SdrAttrObj::RestGeoData(rGeo);
+ SdrTextObjGeoData& rTGeo=(SdrTextObjGeoData&)rGeo;
+ aRect =rTGeo.aRect;
+ aGeo =rTGeo.aGeo;
+ SetTextSizeDirty();
+}
+
+SdrFitToSizeType SdrTextObj::GetFitToSize() const
+{
+ SdrFitToSizeType eType = SDRTEXTFIT_NONE;
+
+ if(!IsAutoGrowWidth())
+ eType = ((SdrTextFitToSizeTypeItem&)(GetObjectItem(SDRATTR_TEXT_FITTOSIZE))).GetValue();
+
+ return eType;
+}
+
+void SdrTextObj::ForceOutlinerParaObject()
+{
+ SdrText* pText = getActiveText();
+ if( pText && (pText->GetOutlinerParaObject() == 0) )
+ {
+ USHORT nOutlMode = OUTLINERMODE_TEXTOBJECT;
+ if( IsTextFrame() && eTextKind == OBJ_OUTLINETEXT )
+ nOutlMode = OUTLINERMODE_OUTLINEOBJECT;
+
+ pText->ForceOutlinerParaObject( nOutlMode );
+ }
+}
+
+sal_Bool SdrTextObj::IsVerticalWriting() const
+{
+ // #89459#
+ if(pEdtOutl)
+ {
+ return pEdtOutl->IsVertical();
+ }
+
+ OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+ if(pOutlinerParaObject)
+ {
+ return pOutlinerParaObject->IsVertical();
+ }
+
+ return sal_False;
+}
+
+void SdrTextObj::SetVerticalWriting(sal_Bool bVertical)
+{
+ OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+ if( !pOutlinerParaObject && bVertical )
+ {
+ // we only need to force a outliner para object if the default of
+ // horizontal text is changed
+ ForceOutlinerParaObject();
+ pOutlinerParaObject = GetOutlinerParaObject();
+ }
+
+ if( pOutlinerParaObject && (pOutlinerParaObject->IsVertical() != (bool)bVertical) )
+ {
+ // get item settings
+ const SfxItemSet& rSet = GetObjectItemSet();
+ sal_Bool bAutoGrowWidth = ((SdrTextAutoGrowWidthItem&)rSet.Get(SDRATTR_TEXT_AUTOGROWWIDTH)).GetValue();
+ sal_Bool bAutoGrowHeight = ((SdrTextAutoGrowHeightItem&)rSet.Get(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue();
+
+ // #103516# Also exchange hor/ver adjust items
+ SdrTextHorzAdjust eHorz = ((SdrTextHorzAdjustItem&)(rSet.Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
+ SdrTextVertAdjust eVert = ((SdrTextVertAdjustItem&)(rSet.Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
+
+ // rescue object size
+ Rectangle aObjectRect = GetSnapRect();
+
+ // prepare ItemSet to set exchanged width and height items
+ SfxItemSet aNewSet(*rSet.GetPool(),
+ SDRATTR_TEXT_AUTOGROWHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT,
+ // #103516# Expanded item ranges to also support hor and ver adjust.
+ SDRATTR_TEXT_VERTADJUST, SDRATTR_TEXT_VERTADJUST,
+ SDRATTR_TEXT_AUTOGROWWIDTH, SDRATTR_TEXT_HORZADJUST,
+ 0, 0);
+
+ aNewSet.Put(rSet);
+ aNewSet.Put(SdrTextAutoGrowWidthItem(bAutoGrowHeight));
+ aNewSet.Put(SdrTextAutoGrowHeightItem(bAutoGrowWidth));
+
+ // #103516# Exchange horz and vert adjusts
+ switch(eVert)
+ {
+ case SDRTEXTVERTADJUST_TOP: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); break;
+ case SDRTEXTVERTADJUST_CENTER: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); break;
+ case SDRTEXTVERTADJUST_BOTTOM: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_LEFT)); break;
+ case SDRTEXTVERTADJUST_BLOCK: aNewSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_BLOCK)); break;
+ }
+ switch(eHorz)
+ {
+ case SDRTEXTHORZADJUST_LEFT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BOTTOM)); break;
+ case SDRTEXTHORZADJUST_CENTER: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); break;
+ case SDRTEXTHORZADJUST_RIGHT: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); break;
+ case SDRTEXTHORZADJUST_BLOCK: aNewSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_BLOCK)); break;
+ }
+
+ SetObjectItemSet(aNewSet);
+
+ pOutlinerParaObject = GetOutlinerParaObject();
+ if( pOutlinerParaObject )
+ {
+ // set ParaObject orientation accordingly
+ pOutlinerParaObject->SetVertical(bVertical);
+ }
+
+ // restore object size
+ SetSnapRect(aObjectRect);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// transformation interface for StarOfficeAPI. This implements support for
+// homogen 3x3 matrices containing the transformation of the SdrObject. At the
+// moment it contains a shearX, rotation and translation, but for setting all linear
+// transforms like Scale, ShearX, ShearY, Rotate and Translate are supported.
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
+// with the base geometry and returns TRUE. Otherwise it returns FALSE.
+sal_Bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& /*rPolyPolygon*/) const
+{
+ // get turn and shear
+ double fRotate = (aGeo.nDrehWink / 100.0) * F_PI180;
+ double fShearX = (aGeo.nShearWink / 100.0) * F_PI180;
+
+ // get aRect, this is the unrotated snaprect
+ Rectangle aRectangle(aRect);
+
+ // fill other values
+ basegfx::B2DTuple aScale(aRectangle.GetWidth(), aRectangle.GetHeight());
+ basegfx::B2DTuple aTranslate(aRectangle.Left(), aRectangle.Top());
+
+ // position maybe relative to anchorpos, convert
+ if( pModel && pModel->IsWriter() )
+ {
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate -= basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
+ }
+ }
+
+ // force MapUnit to 100th mm
+ SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // postion
+ aTranslate.setX(ImplTwipsToMM(aTranslate.getX()));
+ aTranslate.setY(ImplTwipsToMM(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplTwipsToMM(aScale.getX()));
+ aScale.setY(ImplTwipsToMM(aScale.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRGetBaseGeometry: Missing unit translation to 100th mm!");
+ }
+ }
+ }
+
+ // build matrix
+ rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aScale,
+ basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX),
+ basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate,
+ aTranslate);
+
+ return sal_False;
+}
+
+// sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
+// If it's an SdrPathObj it will use the provided geometry information. The Polygon has
+// to use (0,0) as upper left and will be scaled to the given size in the matrix.
+void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& /*rPolyPolygon*/)
+{
+ // break up matrix
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate(0.0);
+ double fShearX(0.0);
+ rMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings
+ // in X and Y which equal a 180 degree rotation. Recognize it and react accordingly
+ if(basegfx::fTools::less(aScale.getX(), 0.0) && basegfx::fTools::less(aScale.getY(), 0.0))
+ {
+ aScale.setX(fabs(aScale.getX()));
+ aScale.setY(fabs(aScale.getY()));
+ fRotate = fmod(fRotate + F_PI, F_2PI);
+ }
+
+ // reset object shear and rotations
+ aGeo.nDrehWink = 0;
+ aGeo.RecalcSinCos();
+ aGeo.nShearWink = 0;
+ aGeo.RecalcTan();
+
+ // force metric to pool metric
+ SfxMapUnit eMapUnit = GetObjectItemSet().GetPool()->GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ // position
+ aTranslate.setX(ImplMMToTwips(aTranslate.getX()));
+ aTranslate.setY(ImplMMToTwips(aTranslate.getY()));
+
+ // size
+ aScale.setX(ImplMMToTwips(aScale.getX()));
+ aScale.setY(ImplMMToTwips(aScale.getY()));
+
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("TRSetBaseGeometry: Missing unit translation to PoolMetric!");
+ }
+ }
+ }
+
+ // if anchor is used, make position relative to it
+ if( pModel && pModel->IsWriter() )
+ {
+ if(GetAnchorPos().X() || GetAnchorPos().Y())
+ {
+ aTranslate += basegfx::B2DTuple(GetAnchorPos().X(), GetAnchorPos().Y());
+ }
+ }
+
+ // build and set BaseRect (use scale)
+ Point aPoint = Point();
+ Size aSize(FRound(aScale.getX()), FRound(aScale.getY()));
+ Rectangle aBaseRect(aPoint, aSize);
+ SetSnapRect(aBaseRect);
+
+ // shear?
+ if(!basegfx::fTools::equalZero(fShearX))
+ {
+ GeoStat aGeoStat;
+ aGeoStat.nShearWink = FRound((atan(fShearX) / F_PI180) * 100.0);
+ aGeoStat.RecalcTan();
+ Shear(Point(), aGeoStat.nShearWink, aGeoStat.nTan, FALSE);
+ }
+
+ // rotation?
+ if(!basegfx::fTools::equalZero(fRotate))
+ {
+ GeoStat aGeoStat;
+
+ // #i78696#
+ // fRotate is matematically correct, but aGeoStat.nDrehWink is
+ // mirrored -> mirror value here
+ aGeoStat.nDrehWink = NormAngle360(FRound(-fRotate / F_PI18000));
+ aGeoStat.RecalcSinCos();
+ Rotate(Point(), aGeoStat.nDrehWink, aGeoStat.nSin, aGeoStat.nCos);
+ }
+
+ // translate?
+ if(!aTranslate.equalZero())
+ {
+ Move(Size(FRound(aTranslate.getX()), FRound(aTranslate.getY())));
+ }
+}
+
+bool SdrTextObj::IsRealyEdited() const
+{
+ return pEdtOutl && pEdtOutl->IsModified();
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////
+// moved inlines here form hxx
+
+long SdrTextObj::GetEckenradius() const
+{
+ return ((SdrEckenradiusItem&)(GetObjectItemSet().Get(SDRATTR_ECKENRADIUS))).GetValue();
+}
+
+long SdrTextObj::GetMinTextFrameHeight() const
+{
+ return ((SdrTextMinFrameHeightItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MINFRAMEHEIGHT))).GetValue();
+}
+
+long SdrTextObj::GetMaxTextFrameHeight() const
+{
+ return ((SdrTextMaxFrameHeightItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MAXFRAMEHEIGHT))).GetValue();
+}
+
+long SdrTextObj::GetMinTextFrameWidth() const
+{
+ return ((SdrTextMinFrameWidthItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MINFRAMEWIDTH))).GetValue();
+}
+
+long SdrTextObj::GetMaxTextFrameWidth() const
+{
+ return ((SdrTextMaxFrameWidthItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_MAXFRAMEWIDTH))).GetValue();
+}
+
+bool SdrTextObj::IsFontwork() const
+{
+ return (bTextFrame) ? false // Default ist FALSE
+ : ((XFormTextStyleItem&)(GetObjectItemSet().Get(XATTR_FORMTXTSTYLE))).GetValue()!=XFT_NONE;
+}
+
+bool SdrTextObj::IsHideContour() const
+{
+ return (bTextFrame) ? false // Default ist: Nein, kein HideContour; HideContour nicht bei TextFrames
+ : ((XFormTextHideFormItem&)(GetObjectItemSet().Get(XATTR_FORMTXTHIDEFORM))).GetValue();
+}
+
+bool SdrTextObj::IsContourTextFrame() const
+{
+ return (bTextFrame) ? false // ContourFrame nicht bei normalen TextFrames
+ : ((SdrTextContourFrameItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_CONTOURFRAME))).GetValue();
+}
+
+long SdrTextObj::GetTextLeftDistance() const
+{
+ return ((SdrTextLeftDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_LEFTDIST))).GetValue();
+}
+
+long SdrTextObj::GetTextRightDistance() const
+{
+ return ((SdrTextRightDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_RIGHTDIST))).GetValue();
+}
+
+long SdrTextObj::GetTextUpperDistance() const
+{
+ return ((SdrTextUpperDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_UPPERDIST))).GetValue();
+}
+
+long SdrTextObj::GetTextLowerDistance() const
+{
+ return ((SdrTextLowerDistItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_LOWERDIST))).GetValue();
+}
+
+SdrTextAniKind SdrTextObj::GetTextAniKind() const
+{
+ return ((SdrTextAniKindItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_ANIKIND))).GetValue();
+}
+
+SdrTextAniDirection SdrTextObj::GetTextAniDirection() const
+{
+ return ((SdrTextAniDirectionItem&)(GetObjectItemSet().Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
+}
+
+// #111096#
+// Access to thext hidden flag
+sal_Bool SdrTextObj::GetTextHidden() const
+{
+ return mbTextHidden;
+}
+
+void SdrTextObj::NbcSetTextHidden(sal_Bool bNew)
+{
+ if(bNew != mbTextHidden)
+ {
+ mbTextHidden = bNew;
+ }
+}
+
+// #111096#
+// Get necessary data for text scroll animation. ATM base it on a Text-Metafile and a
+// painting rectangle. Rotation is excluded from the returned values.
+GDIMetaFile* SdrTextObj::GetTextScrollMetaFileAndRectangle(
+ Rectangle& rScrollRectangle, Rectangle& rPaintRectangle)
+{
+ GDIMetaFile* pRetval = 0L;
+ SdrOutliner& rOutliner = ImpGetDrawOutliner();
+ Rectangle aTextRect;
+ Rectangle aAnchorRect;
+ Rectangle aPaintRect;
+ Fraction aFitXKorreg(1,1);
+ bool bContourFrame(IsContourTextFrame());
+
+ // get outliner set up. To avoid getting a somehow rotated MetaFile,
+ // temporarily disable object rotation.
+ sal_Int32 nAngle(aGeo.nDrehWink);
+ aGeo.nDrehWink = 0L;
+ ImpSetupDrawOutlinerForPaint( bContourFrame, rOutliner, aTextRect, aAnchorRect, aPaintRect, aFitXKorreg );
+ aGeo.nDrehWink = nAngle;
+
+ Rectangle aScrollFrameRect(aPaintRect);
+ const SfxItemSet& rSet = GetObjectItemSet();
+ SdrTextAniDirection eDirection = ((SdrTextAniDirectionItem&)(rSet.Get(SDRATTR_TEXT_ANIDIRECTION))).GetValue();
+
+ if(SDRTEXTANI_LEFT == eDirection || SDRTEXTANI_RIGHT == eDirection)
+ {
+ aScrollFrameRect.Left() = aAnchorRect.Left();
+ aScrollFrameRect.Right() = aAnchorRect.Right();
+ }
+
+ if(SDRTEXTANI_UP == eDirection || SDRTEXTANI_DOWN == eDirection)
+ {
+ aScrollFrameRect.Top() = aAnchorRect.Top();
+ aScrollFrameRect.Bottom() = aAnchorRect.Bottom();
+ }
+
+ // create the MetaFile
+ pRetval = new GDIMetaFile;
+ VirtualDevice aBlackHole;
+ aBlackHole.EnableOutput(sal_False);
+ pRetval->Record(&aBlackHole);
+ Point aPaintPos = aPaintRect.TopLeft();
+
+ rOutliner.Draw(&aBlackHole, aPaintPos);
+
+ pRetval->Stop();
+ pRetval->WindStart();
+
+ // return PaintRectanglePixel and pRetval;
+ rScrollRectangle = aScrollFrameRect;
+ rPaintRectangle = aPaintRect;
+
+ return pRetval;
+}
+
+// #111096#
+// Access to TextAnimationAllowed flag
+bool SdrTextObj::IsTextAnimationAllowed() const
+{
+ return mbTextAnimationAllowed;
+}
+
+bool SdrTextObj::IsAutoFit() const
+{
+ return GetFitToSize()==SDRTEXTFIT_AUTOFIT;
+}
+
+bool SdrTextObj::IsFitToSize() const
+{
+ const SdrFitToSizeType eFit=GetFitToSize();
+ return (eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES);
+}
+
+void SdrTextObj::SetTextAnimationAllowed(sal_Bool bNew)
+{
+ if(mbTextAnimationAllowed != bNew)
+ {
+ mbTextAnimationAllowed = bNew;
+ ActionChanged();
+ }
+}
+
+/** called from the SdrObjEditView during text edit when the status of the edit outliner changes */
+void SdrTextObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
+{
+ const sal_uInt32 nStat = pEditStatus->GetStatusWord();
+ const bool bGrowX=(nStat & EE_STAT_TEXTWIDTHCHANGED) !=0;
+ const bool bGrowY=(nStat & EE_STAT_TEXTHEIGHTCHANGED) !=0;
+ if(bTextFrame && (bGrowX || bGrowY))
+ {
+ if ((bGrowX && IsAutoGrowWidth()) || (bGrowY && IsAutoGrowHeight()))
+ {
+ AdjustTextFrameWidthAndHeight();
+ }
+ else if (IsAutoFit() && !mbInDownScale)
+ {
+ OSL_ASSERT(pEdtOutl);
+ mbInDownScale = sal_True;
+
+ // sucks that we cannot disable paints via
+ // pEdtOutl->SetUpdateMode(FALSE) - but EditEngine skips
+ // formatting as well, then.
+ ImpAutoFitText(*pEdtOutl);
+ mbInDownScale = sal_False;
+ }
+ }
+}
+
+/** returns the currently active text. */
+SdrText* SdrTextObj::getActiveText() const
+{
+ if( !mpText )
+ return getText( 0 );
+ else
+ return mpText;
+}
+
+/** returns the nth available text. */
+SdrText* SdrTextObj::getText( sal_Int32 nIndex ) const
+{
+ if( nIndex == 0 )
+ {
+ if( mpText == 0 )
+ const_cast< SdrTextObj* >(this)->mpText = new SdrText( *(const_cast< SdrTextObj* >(this)) );
+ return mpText;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+/** returns the number of texts available for this object. */
+sal_Int32 SdrTextObj::getTextCount() const
+{
+ return 1;
+}
+
+/** changes the current active text */
+void SdrTextObj::setActiveText( sal_Int32 /*nIndex*/ )
+{
+}
+
+/** returns the index of the text that contains the given point or -1 */
+sal_Int32 SdrTextObj::CheckTextHit(const Point& /*rPnt*/) const
+{
+ return 0;
+}
+
+void SdrTextObj::SetObjectItemNoBroadcast(const SfxPoolItem& rItem)
+{
+ static_cast< sdr::properties::TextProperties& >(GetProperties()).SetObjectItemNoBroadcast(rItem);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Konzept des TextObjekts:
+// ~~~~~~~~~~~~~~~~~~~~~~~~
+// Attribute/Varianten:
+// - BOOL Textrahmen / beschriftetes Zeichenobjekt
+// - BOOL FontWork (wenn nicht Textrahmen und nicht ContourTextFrame)
+// - BOOL ContourTextFrame (wenn nicht Textrahmen und nicht Fontwork)
+// - long Drehwinkel (wenn nicht FontWork)
+// - long Textrahmenabstaende (wenn nicht FontWork)
+// - BOOL FitToSize (wenn nicht FontWork)
+// - BOOL AutoGrowingWidth/Height (wenn nicht FitToSize und nicht FontWork)
+// - long Min/MaxFrameWidth/Height (wenn AutoGrowingWidth/Height)
+// - enum Horizontale Textverankerung Links,Mitte,Rechts,Block,Stretch(ni)
+// - enum Vertikale Textverankerung Oben,Mitte,Unten,Block,Stretch(ni)
+// - enum Laufschrift (wenn nicht FontWork)
+//
+// Jedes abgeleitete Objekt ist entweder ein Textrahmen (bTextFrame=TRUE)
+// oder ein beschriftetes Zeichenobjekt (bTextFrame=FALSE).
+//
+// Defaultverankerung von Textrahmen:
+// SDRTEXTHORZADJUST_BLOCK, SDRTEXTVERTADJUST_TOP
+// = statische Pooldefaults
+// Defaultverankerung von beschrifteten Zeichenobjekten:
+// SDRTEXTHORZADJUST_CENTER, SDRTEXTVERTADJUST_CENTER
+// durch harte Attributierung von SdrAttrObj
+//
+// Jedes vom SdrTextObj abgeleitete Objekt muss ein "UnrotatedSnapRect"
+// (->TakeUnrotatedSnapRect()) liefern (Drehreferenz ist TopLeft dieses
+// Rechtecks (aGeo.nDrehWink)), welches die Grundlage der Textverankerung
+// bildet. Von diesem werden dann ringsum die Textrahmenabstaende abgezogen;
+// das Ergebnis ist der Ankerbereich (->TakeTextAnchorRect()). Innerhalb
+// dieses Bereichs wird dann in Abhaengigkeit von der horizontalen und
+// vertikalen Ausrichtung (SdrTextVertAdjust,SdrTextHorzAdjust) der Ankerpunkt
+// sowie der Ausgabebereich bestimmt. Bei beschrifteten Grafikobjekten kann
+// der Ausgabebereich durchaus groesser als der Ankerbereich werden, bei
+// Textrahmen ist er stets kleiner oder gleich (ausser bei negativen Textrahmen-
+// abstaenden).
+//
+// FitToSize hat Prioritaet vor Textverankerung und AutoGrowHeight/Width. Der
+// Ausgabebereich ist bei FitToSize immer genau der Ankerbereich. Weiterhin
+// gibt es bei FitToSize keinen automatischen Zeilenumbruch.
+//
+// ContourTextFrame:
+// - long Drehwinkel
+// - long Textrahmenabstaende spaeter vielleicht
+// - BOOL FitToSize spaeter vielleicht
+// - BOOL AutoGrowingWidth/Height viel spaeter vielleicht
+// - long Min/MaxFrameWidth/Height viel spaeter vielleicht
+// - enum Horizontale Textverankerung spaeter vielleicht, erstmal Links, Absatz zentr.
+// - enum Vertikale Textverankerung spaeter vielleicht, erstmal oben
+// - enum Laufschrift spaeter vielleicht (evtl. sogar mit korrektem Clipping)
+//
+// Bei Aenderungen zu beachten:
+// - Paint
+// - HitTest
+// - ConvertToPoly
+// - Edit
+// - Drucken,Speichern, Paint in Nachbarview waerend Edit
+// - ModelChanged (z.B. durch NachbarView oder Lineale) waerend Edit
+// - FillColorChanged waerend Edit
+// - uvm...
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx
new file mode 100644
index 000000000000..60a6903517a2
--- /dev/null
+++ b/svx/source/svdraw/svdotextdecomposition.cxx
@@ -0,0 +1,1397 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdotext.hxx>
+#include <svx/svdoutl.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+#include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <editeng/editstat.hxx>
+#include <vcl/salbtype.hxx>
+#include <svx/sdtfchim.hxx>
+#include <svl/itemset.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/animation/animationtiming.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <vcl/svapp.hxx>
+#include <editeng/eeitemid.hxx>
+#include <editeng/escpitem.hxx>
+#include <editeng/svxenum.hxx>
+#include <editeng/flditem.hxx>
+#include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
+#include <vcl/metaact.hxx>
+#include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
+#include <drawinglayer/primitive2d/graphicprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
+#include <unoapi.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <editeng/outlobj.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// helpers
+
+namespace
+{
+ drawinglayer::primitive2d::Primitive2DSequence impConvertVectorToPrimitive2DSequence(const std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rPrimitiveVector)
+ {
+ const sal_Int32 nCount(rPrimitiveVector.size());
+ drawinglayer::primitive2d::Primitive2DSequence aRetval(nCount);
+
+ for(sal_Int32 a(0L); a < nCount; a++)
+ {
+ aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(rPrimitiveVector[a]);
+ }
+
+ return aRetval;
+ }
+
+ class impTextBreakupHandler
+ {
+ private:
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* > maTextPortionPrimitives;
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* > maLinePrimitives;
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* > maParagraphPrimitives;
+
+ SdrOutliner& mrOutliner;
+ basegfx::B2DHomMatrix maNewTransformA;
+ basegfx::B2DHomMatrix maNewTransformB;
+
+ // the visible area for contour text decomposition
+ basegfx::B2DVector maScale;
+
+ // #SJ# ClipRange for BlockText decomposition; only text portions completely
+ // inside are to be accepted, so this is different from geometric clipping
+ // (which would allow e.g. upper parts of portions to remain). Only used for
+ // BlockText (see there)
+ basegfx::B2DRange maClipRange;
+
+ DECL_LINK(decomposeContourTextPrimitive, DrawPortionInfo* );
+ DECL_LINK(decomposeBlockTextPrimitive, DrawPortionInfo* );
+ DECL_LINK(decomposeStretchTextPrimitive, DrawPortionInfo* );
+
+ DECL_LINK(decomposeContourBulletPrimitive, DrawBulletInfo* );
+ DECL_LINK(decomposeBlockBulletPrimitive, DrawBulletInfo* );
+ DECL_LINK(decomposeStretchBulletPrimitive, DrawBulletInfo* );
+
+ bool impIsUnderlineAbove(const Font& rFont) const;
+ void impCreateTextPortionPrimitive(const DrawPortionInfo& rInfo);
+ drawinglayer::primitive2d::BasePrimitive2D* impCheckFieldPrimitive(drawinglayer::primitive2d::BasePrimitive2D* pPrimitive, const DrawPortionInfo& rInfo) const;
+ void impFlushTextPortionPrimitivesToLinePrimitives();
+ void impFlushLinePrimitivesToParagraphPrimitives();
+ void impHandleDrawPortionInfo(const DrawPortionInfo& rInfo);
+ void impHandleDrawBulletInfo(const DrawBulletInfo& rInfo);
+
+ public:
+ impTextBreakupHandler(SdrOutliner& rOutliner)
+ : maTextPortionPrimitives(),
+ maLinePrimitives(),
+ maParagraphPrimitives(),
+ mrOutliner(rOutliner),
+ maNewTransformA(),
+ maNewTransformB(),
+ maScale(),
+ maClipRange()
+ {
+ }
+
+ void decomposeContourTextPrimitive(const basegfx::B2DHomMatrix& rNewTransformA, const basegfx::B2DHomMatrix& rNewTransformB, const basegfx::B2DVector& rScale)
+ {
+ maScale = rScale;
+ maNewTransformA = rNewTransformA;
+ maNewTransformB = rNewTransformB;
+ mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decomposeContourTextPrimitive));
+ mrOutliner.SetDrawBulletHdl(LINK(this, impTextBreakupHandler, decomposeContourBulletPrimitive));
+ mrOutliner.StripPortions();
+ mrOutliner.SetDrawPortionHdl(Link());
+ mrOutliner.SetDrawBulletHdl(Link());
+ }
+
+ void decomposeBlockTextPrimitive(
+ const basegfx::B2DHomMatrix& rNewTransformA,
+ const basegfx::B2DHomMatrix& rNewTransformB,
+ const basegfx::B2DRange& rClipRange)
+ {
+ maNewTransformA = rNewTransformA;
+ maNewTransformB = rNewTransformB;
+ maClipRange = rClipRange;
+ mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decomposeBlockTextPrimitive));
+ mrOutliner.SetDrawBulletHdl(LINK(this, impTextBreakupHandler, decomposeBlockBulletPrimitive));
+ mrOutliner.StripPortions();
+ mrOutliner.SetDrawPortionHdl(Link());
+ mrOutliner.SetDrawBulletHdl(Link());
+ }
+
+ void decomposeStretchTextPrimitive(const basegfx::B2DHomMatrix& rNewTransformA, const basegfx::B2DHomMatrix& rNewTransformB)
+ {
+ maNewTransformA = rNewTransformA;
+ maNewTransformB = rNewTransformB;
+ mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decomposeStretchTextPrimitive));
+ mrOutliner.SetDrawBulletHdl(LINK(this, impTextBreakupHandler, decomposeStretchBulletPrimitive));
+ mrOutliner.StripPortions();
+ mrOutliner.SetDrawPortionHdl(Link());
+ mrOutliner.SetDrawBulletHdl(Link());
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence getPrimitive2DSequence();
+ };
+
+ bool impTextBreakupHandler::impIsUnderlineAbove(const Font& rFont) const
+ {
+ if(!rFont.IsVertical())
+ {
+ return false;
+ }
+
+ if((LANGUAGE_JAPANESE == rFont.GetLanguage()) || (LANGUAGE_JAPANESE == rFont.GetCJKContextLanguage()))
+ {
+ // the underline is right for Japanese only
+ return true;
+ }
+
+ return false;
+ }
+
+ void impTextBreakupHandler::impCreateTextPortionPrimitive(const DrawPortionInfo& rInfo)
+ {
+ if(rInfo.mrText.Len() && rInfo.mnTextLen)
+ {
+ basegfx::B2DVector aFontScaling;
+ drawinglayer::attribute::FontAttribute aFontAttribute(
+ drawinglayer::primitive2d::getFontAttributeFromVclFont(
+ aFontScaling,
+ rInfo.mrFont,
+ rInfo.IsRTL(),
+ false));
+ basegfx::B2DHomMatrix aNewTransform;
+
+ // add font scale to new transform
+ aNewTransform.scale(aFontScaling.getX(), aFontScaling.getY());
+
+ // look for proportional font scaling, evtl scale accordingly
+ if(100 != rInfo.mrFont.GetPropr())
+ {
+ const double fFactor(rInfo.mrFont.GetPropr() / 100.0);
+ aNewTransform.scale(fFactor, fFactor);
+ }
+
+ // apply font rotate
+ if(rInfo.mrFont.GetOrientation())
+ {
+ aNewTransform.rotate(-rInfo.mrFont.GetOrientation() * F_PI1800);
+ }
+
+ // look for escapement, evtl translate accordingly
+ if(rInfo.mrFont.GetEscapement())
+ {
+ sal_Int16 nEsc(rInfo.mrFont.GetEscapement());
+
+ if(DFLT_ESC_AUTO_SUPER == nEsc)
+ {
+ nEsc = 33;
+ }
+ else if(DFLT_ESC_AUTO_SUB == nEsc)
+ {
+ nEsc = -20;
+ }
+
+ if(nEsc > 100)
+ {
+ nEsc = 100;
+ }
+ else if(nEsc < -100)
+ {
+ nEsc = -100;
+ }
+
+ const double fEscapement(nEsc / -100.0);
+ aNewTransform.translate(0.0, fEscapement * aFontScaling.getY());
+ }
+
+ // apply transformA
+ aNewTransform *= maNewTransformA;
+
+ // apply local offset
+ aNewTransform.translate(rInfo.mrStartPos.X(), rInfo.mrStartPos.Y());
+
+ // also apply embedding object's transform
+ aNewTransform *= maNewTransformB;
+
+ // prepare DXArray content. To make it independent from font size (and such from
+ // the text transformation), scale it to unit coordinates
+ ::std::vector< double > aDXArray;
+ static bool bDisableTextArray(false);
+
+ if(!bDisableTextArray && rInfo.mpDXArray && rInfo.mnTextLen)
+ {
+ aDXArray.reserve(rInfo.mnTextLen);
+
+ for(xub_StrLen a(0); a < rInfo.mnTextLen; a++)
+ {
+ aDXArray.push_back((double)rInfo.mpDXArray[a]);
+ }
+ }
+
+ // create complex text primitive and append
+ const Color aFontColor(rInfo.mrFont.GetColor());
+ const basegfx::BColor aBFontColor(aFontColor.getBColor());
+
+ // prepare wordLineMode (for underline and strikeout)
+ // NOT for bullet texts. It is set (this may be an error by itself), but needs to be suppressed to hinder e.g. '1)'
+ // to be splitted which would not look like the original
+ const bool bWordLineMode(rInfo.mrFont.IsWordLineMode() && !rInfo.mbEndOfBullet);
+
+ // prepare new primitive
+ drawinglayer::primitive2d::BasePrimitive2D* pNewPrimitive = 0;
+ const bool bDecoratedIsNeeded(
+ UNDERLINE_NONE != rInfo.mrFont.GetOverline()
+ || UNDERLINE_NONE != rInfo.mrFont.GetUnderline()
+ || STRIKEOUT_NONE != rInfo.mrFont.GetStrikeout()
+ || EMPHASISMARK_NONE != (rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_STYLE)
+ || RELIEF_NONE != rInfo.mrFont.GetRelief()
+ || rInfo.mrFont.IsShadow()
+ || bWordLineMode);
+
+ if(bDecoratedIsNeeded)
+ {
+ // TextDecoratedPortionPrimitive2D needed, prepare some more data
+ // get overline and underline color. If it's on automatic (0xffffffff) use FontColor instead
+ const Color aUnderlineColor(rInfo.maTextLineColor);
+ const basegfx::BColor aBUnderlineColor((0xffffffff == aUnderlineColor.GetColor()) ? aBFontColor : aUnderlineColor.getBColor());
+ const Color aOverlineColor(rInfo.maOverlineColor);
+ const basegfx::BColor aBOverlineColor((0xffffffff == aOverlineColor.GetColor()) ? aBFontColor : aOverlineColor.getBColor());
+
+ // prepare overline and underline data
+ const drawinglayer::primitive2d::TextLine eFontOverline(
+ drawinglayer::primitive2d::mapFontUnderlineToTextLine(rInfo.mrFont.GetOverline()));
+ const drawinglayer::primitive2d::TextLine eFontUnderline(
+ drawinglayer::primitive2d::mapFontUnderlineToTextLine(rInfo.mrFont.GetUnderline()));
+
+ // check UndelineAbove
+ const bool bUnderlineAbove(
+ drawinglayer::primitive2d::TEXT_LINE_NONE != eFontUnderline && impIsUnderlineAbove(rInfo.mrFont));
+
+ // prepare strikeout data
+ const drawinglayer::primitive2d::TextStrikeout eTextStrikeout(
+ drawinglayer::primitive2d::mapFontStrikeoutToTextStrikeout(rInfo.mrFont.GetStrikeout()));
+
+ // prepare emphasis mark data
+ drawinglayer::primitive2d::TextEmphasisMark eTextEmphasisMark(drawinglayer::primitive2d::TEXT_EMPHASISMARK_NONE);
+
+ switch(rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_STYLE)
+ {
+ case EMPHASISMARK_DOT : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_DOT; break;
+ case EMPHASISMARK_CIRCLE : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_CIRCLE; break;
+ case EMPHASISMARK_DISC : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_DISC; break;
+ case EMPHASISMARK_ACCENT : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_ACCENT; break;
+ }
+
+ const bool bEmphasisMarkAbove(rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_POS_ABOVE);
+ const bool bEmphasisMarkBelow(rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_POS_BELOW);
+
+ // prepare font relief data
+ drawinglayer::primitive2d::TextRelief eTextRelief(drawinglayer::primitive2d::TEXT_RELIEF_NONE);
+
+ switch(rInfo.mrFont.GetRelief())
+ {
+ case RELIEF_EMBOSSED : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_EMBOSSED; break;
+ case RELIEF_ENGRAVED : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_ENGRAVED; break;
+ default : break; // RELIEF_NONE, FontRelief_FORCE_EQUAL_SIZE
+ }
+
+ // prepare shadow/outline data
+ const bool bShadow(rInfo.mrFont.IsShadow());
+
+ // TextDecoratedPortionPrimitive2D is needed, create one
+ pNewPrimitive = new drawinglayer::primitive2d::TextDecoratedPortionPrimitive2D(
+
+ // attributes for TextSimplePortionPrimitive2D
+ aNewTransform,
+ rInfo.mrText,
+ rInfo.mnTextStart,
+ rInfo.mnTextLen,
+ aDXArray,
+ aFontAttribute,
+ rInfo.mpLocale ? *rInfo.mpLocale : ::com::sun::star::lang::Locale(),
+ aBFontColor,
+
+ // attributes for TextDecoratedPortionPrimitive2D
+ aBOverlineColor,
+ aBUnderlineColor,
+ eFontOverline,
+ eFontUnderline,
+ bUnderlineAbove,
+ eTextStrikeout,
+ bWordLineMode,
+ eTextEmphasisMark,
+ bEmphasisMarkAbove,
+ bEmphasisMarkBelow,
+ eTextRelief,
+ bShadow);
+ }
+ else
+ {
+ // TextSimplePortionPrimitive2D is enough
+ pNewPrimitive = new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
+ aNewTransform,
+ rInfo.mrText,
+ rInfo.mnTextStart,
+ rInfo.mnTextLen,
+ aDXArray,
+ aFontAttribute,
+ rInfo.mpLocale ? *rInfo.mpLocale : ::com::sun::star::lang::Locale(),
+ aBFontColor,
+ rInfo.mbFilled,
+ rInfo.mnWidthToFill);
+ }
+
+ if(rInfo.mbEndOfBullet)
+ {
+ // embed in TextHierarchyBulletPrimitive2D
+ const drawinglayer::primitive2d::Primitive2DReference aNewReference(pNewPrimitive);
+ const drawinglayer::primitive2d::Primitive2DSequence aNewSequence(&aNewReference, 1);
+ pNewPrimitive = new drawinglayer::primitive2d::TextHierarchyBulletPrimitive2D(aNewSequence);
+ }
+
+ if(rInfo.mpFieldData)
+ {
+ pNewPrimitive = impCheckFieldPrimitive(pNewPrimitive, rInfo);
+ }
+
+ maTextPortionPrimitives.push_back(pNewPrimitive);
+
+ // support for WrongSpellVector. Create WrongSpellPrimitives as needed
+ if(rInfo.mpWrongSpellVector && !aDXArray.empty())
+ {
+ const sal_uInt32 nSize(rInfo.mpWrongSpellVector->size());
+ const sal_uInt32 nDXCount(aDXArray.size());
+ const basegfx::BColor aSpellColor(1.0, 0.0, 0.0); // red, hard coded
+
+ for(sal_uInt32 a(0); a < nSize; a++)
+ {
+ const EEngineData::WrongSpellClass& rCandidate = (*rInfo.mpWrongSpellVector)[a];
+
+ if(rCandidate.nStart >= rInfo.mnTextStart && rCandidate.nEnd >= rInfo.mnTextStart && rCandidate.nEnd > rCandidate.nStart)
+ {
+ const sal_uInt32 nStart(rCandidate.nStart - rInfo.mnTextStart);
+ const sal_uInt32 nEnd(rCandidate.nEnd - rInfo.mnTextStart);
+ double fStart(0.0);
+ double fEnd(0.0);
+
+ if(nStart > 0 && nStart - 1 < nDXCount)
+ {
+ fStart = aDXArray[nStart - 1];
+ }
+
+ if(nEnd > 0 && nEnd - 1 < nDXCount)
+ {
+ fEnd = aDXArray[nEnd - 1];
+ }
+
+ if(!basegfx::fTools::equal(fStart, fEnd))
+ {
+ if(rInfo.IsRTL())
+ {
+ // #i98523#
+ // When the portion is RTL, mirror the redlining using the
+ // full portion width
+ const double fTextWidth(aDXArray[aDXArray.size() - 1]);
+
+ fStart = fTextWidth - fStart;
+ fEnd = fTextWidth - fEnd;
+ }
+
+ // need to take FontScaling out of values; it's already part of
+ // aNewTransform and would be double applied
+ const double fFontScaleX(aFontScaling.getX());
+
+ if(!basegfx::fTools::equal(fFontScaleX, 1.0)
+ && !basegfx::fTools::equalZero(fFontScaleX))
+ {
+ fStart /= fFontScaleX;
+ fEnd /= fFontScaleX;
+ }
+
+ maTextPortionPrimitives.push_back(new drawinglayer::primitive2d::WrongSpellPrimitive2D(
+ aNewTransform,
+ fStart,
+ fEnd,
+ aSpellColor));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ drawinglayer::primitive2d::BasePrimitive2D* impTextBreakupHandler::impCheckFieldPrimitive(drawinglayer::primitive2d::BasePrimitive2D* pPrimitive, const DrawPortionInfo& rInfo) const
+ {
+ if(rInfo.mpFieldData)
+ {
+ // Support for FIELD_SEQ_BEGIN, FIELD_SEQ_END. If used, create a TextHierarchyFieldPrimitive2D
+ // which holds the field type and evtl. the URL
+ const SvxURLField* pURLField = dynamic_cast< const SvxURLField* >(rInfo.mpFieldData);
+ const SvxPageField* pPageField = dynamic_cast< const SvxPageField* >(rInfo.mpFieldData);
+
+ // embed current primitive to a sequence
+ drawinglayer::primitive2d::Primitive2DSequence aSequence;
+
+ if(pPrimitive)
+ {
+ aSequence.realloc(1);
+ aSequence[0] = drawinglayer::primitive2d::Primitive2DReference(pPrimitive);
+ }
+
+ if(pURLField)
+ {
+ pPrimitive = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_URL, pURLField->GetURL());
+ }
+ else if(pPageField)
+ {
+ pPrimitive = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_PAGE, String());
+ }
+ else
+ {
+ pPrimitive = new drawinglayer::primitive2d::TextHierarchyFieldPrimitive2D(aSequence, drawinglayer::primitive2d::FIELD_TYPE_COMMON, String());
+ }
+ }
+
+ return pPrimitive;
+ }
+
+ void impTextBreakupHandler::impFlushTextPortionPrimitivesToLinePrimitives()
+ {
+ // only create a line primitive when we had content; there is no need for
+ // empty line primitives (contrary to paragraphs, see below).
+ if(maTextPortionPrimitives.size())
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aLineSequence(impConvertVectorToPrimitive2DSequence(maTextPortionPrimitives));
+ maTextPortionPrimitives.clear();
+ maLinePrimitives.push_back(new drawinglayer::primitive2d::TextHierarchyLinePrimitive2D(aLineSequence));
+ }
+ }
+
+ void impTextBreakupHandler::impFlushLinePrimitivesToParagraphPrimitives()
+ {
+ // ALWAYS create a paragraph primitive, even when no content was added. This is done to
+ // have the correct paragraph count even with empty paragraphs. Those paragraphs will
+ // have an empty sub-PrimitiveSequence.
+ drawinglayer::primitive2d::Primitive2DSequence aParagraphSequence(impConvertVectorToPrimitive2DSequence(maLinePrimitives));
+ maLinePrimitives.clear();
+ maParagraphPrimitives.push_back(new drawinglayer::primitive2d::TextHierarchyParagraphPrimitive2D(aParagraphSequence));
+ }
+
+ void impTextBreakupHandler::impHandleDrawPortionInfo(const DrawPortionInfo& rInfo)
+ {
+ impCreateTextPortionPrimitive(rInfo);
+
+ if(rInfo.mbEndOfLine || rInfo.mbEndOfParagraph)
+ {
+ impFlushTextPortionPrimitivesToLinePrimitives();
+ }
+
+ if(rInfo.mbEndOfParagraph)
+ {
+ impFlushLinePrimitivesToParagraphPrimitives();
+ }
+ }
+
+ void impTextBreakupHandler::impHandleDrawBulletInfo(const DrawBulletInfo& rInfo)
+ {
+ basegfx::B2DHomMatrix aNewTransform;
+
+ // add size to new transform
+ aNewTransform.scale(rInfo.maBulletSize.getWidth(), rInfo.maBulletSize.getHeight());
+
+ // apply transformA
+ aNewTransform *= maNewTransformA;
+
+ // apply local offset
+ aNewTransform.translate(rInfo.maBulletPosition.X(), rInfo.maBulletPosition.Y());
+
+ // also apply embedding object's transform
+ aNewTransform *= maNewTransformB;
+
+ // prepare empty GraphicAttr
+ const GraphicAttr aGraphicAttr;
+
+ // create GraphicPrimitive2D
+ const drawinglayer::primitive2d::Primitive2DReference aNewReference(new drawinglayer::primitive2d::GraphicPrimitive2D(
+ aNewTransform,
+ rInfo.maBulletGraphicObject,
+ aGraphicAttr));
+
+ // embed in TextHierarchyBulletPrimitive2D
+ const drawinglayer::primitive2d::Primitive2DSequence aNewSequence(&aNewReference, 1);
+ drawinglayer::primitive2d::BasePrimitive2D* pNewPrimitive = new drawinglayer::primitive2d::TextHierarchyBulletPrimitive2D(aNewSequence);
+
+ // add to output
+ maTextPortionPrimitives.push_back(pNewPrimitive);
+ }
+
+ IMPL_LINK(impTextBreakupHandler, decomposeContourTextPrimitive, DrawPortionInfo*, pInfo)
+ {
+ // for contour text, ignore (clip away) all portions which are below
+ // the visible area given by maScale
+ if(pInfo && (double)pInfo->mrStartPos.Y() < maScale.getY())
+ {
+ impHandleDrawPortionInfo(*pInfo);
+ }
+
+ return 0;
+ }
+
+ IMPL_LINK(impTextBreakupHandler, decomposeBlockTextPrimitive, DrawPortionInfo*, pInfo)
+ {
+ if(pInfo)
+ {
+ // #SJ# Is clipping wanted? This is text clipping; only accept a portion
+ // if it's completely in the range
+ if(!maClipRange.isEmpty())
+ {
+ // Test start position first; this allows to not get the text range at
+ // all if text is far outside
+ const basegfx::B2DPoint aStartPosition(pInfo->mrStartPos.X(), pInfo->mrStartPos.Y());
+
+ if(!maClipRange.isInside(aStartPosition))
+ {
+ return 0;
+ }
+
+ // Start position is inside. Get TextBoundRect and TopLeft next
+ drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice;
+ aTextLayouterDevice.setFont(pInfo->mrFont);
+
+ const basegfx::B2DRange aTextBoundRect(
+ aTextLayouterDevice.getTextBoundRect(
+ pInfo->mrText, pInfo->mnTextStart, pInfo->mnTextLen));
+ const basegfx::B2DPoint aTopLeft(aTextBoundRect.getMinimum() + aStartPosition);
+
+ if(!maClipRange.isInside(aTopLeft))
+ {
+ return 0;
+ }
+
+ // TopLeft is inside. Get BottomRight and check
+ const basegfx::B2DPoint aBottomRight(aTextBoundRect.getMaximum() + aStartPosition);
+
+ if(!maClipRange.isInside(aBottomRight))
+ {
+ return 0;
+ }
+
+ // all inside, clip was successful
+ }
+ impHandleDrawPortionInfo(*pInfo);
+ }
+
+ return 0;
+ }
+
+ IMPL_LINK(impTextBreakupHandler, decomposeStretchTextPrimitive, DrawPortionInfo*, pInfo)
+ {
+ if(pInfo)
+ {
+ impHandleDrawPortionInfo(*pInfo);
+ }
+
+ return 0;
+ }
+
+ IMPL_LINK(impTextBreakupHandler, decomposeContourBulletPrimitive, DrawBulletInfo*, pInfo)
+ {
+ if(pInfo)
+ {
+ impHandleDrawBulletInfo(*pInfo);
+ }
+
+ return 0;
+ }
+
+ IMPL_LINK(impTextBreakupHandler, decomposeBlockBulletPrimitive, DrawBulletInfo*, pInfo)
+ {
+ if(pInfo)
+ {
+ impHandleDrawBulletInfo(*pInfo);
+ }
+
+ return 0;
+ }
+
+ IMPL_LINK(impTextBreakupHandler, decomposeStretchBulletPrimitive, DrawBulletInfo*, pInfo)
+ {
+ if(pInfo)
+ {
+ impHandleDrawBulletInfo(*pInfo);
+ }
+
+ return 0;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence impTextBreakupHandler::getPrimitive2DSequence()
+ {
+ if(maTextPortionPrimitives.size())
+ {
+ // collect non-closed lines
+ impFlushTextPortionPrimitivesToLinePrimitives();
+ }
+
+ if(maLinePrimitives.size())
+ {
+ // collect non-closed paragraphs
+ impFlushLinePrimitivesToParagraphPrimitives();
+ }
+
+ return impConvertVectorToPrimitive2DSequence(maParagraphPrimitives);
+ }
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+// primitive decompositions
+
+void SdrTextObj::impDecomposeContourTextPrimitive(
+ drawinglayer::primitive2d::Primitive2DSequence& rTarget,
+ const drawinglayer::primitive2d::SdrContourTextPrimitive2D& rSdrContourTextPrimitive,
+ const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
+{
+ // decompose matrix to have position and size of text
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rSdrContourTextPrimitive.getObjectTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // prepare contour polygon, force to non-mirrored for layouting
+ basegfx::B2DPolyPolygon aPolyPolygon(rSdrContourTextPrimitive.getUnitPolyPolygon());
+ aPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(fabs(aScale.getX()), fabs(aScale.getY())));
+
+ // prepare outliner
+ SdrOutliner& rOutliner = ImpGetDrawOutliner();
+ const Size aNullSize;
+ rOutliner.SetPaperSize(aNullSize);
+ rOutliner.SetPolygon(aPolyPolygon);
+ rOutliner.SetUpdateMode(true);
+ rOutliner.SetText(rSdrContourTextPrimitive.getOutlinerParaObject());
+
+ // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
+ rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
+
+ // prepare matrices to apply to newly created primitives
+ basegfx::B2DHomMatrix aNewTransformA;
+
+ // mirroring. We are now in the polygon sizes. When mirroring in X and Y,
+ // move the null point which was top left to bottom right.
+ const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
+ const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
+
+ // in-between the translations of the single primitives will take place. Afterwards,
+ // the object's transformations need to be applied
+ const basegfx::B2DHomMatrix aNewTransformB(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
+ fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
+
+ // now break up text primitives.
+ impTextBreakupHandler aConverter(rOutliner);
+ aConverter.decomposeContourTextPrimitive(aNewTransformA, aNewTransformB, aScale);
+
+ // cleanup outliner
+ rOutliner.Clear();
+ rOutliner.setVisualizedPage(0);
+
+ rTarget = aConverter.getPrimitive2DSequence();
+}
+
+void SdrTextObj::impDecomposeAutoFitTextPrimitive(
+ drawinglayer::primitive2d::Primitive2DSequence& rTarget,
+ const drawinglayer::primitive2d::SdrAutoFitTextPrimitive2D& rSdrAutofitTextPrimitive,
+ const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
+{
+ // decompose matrix to have position and size of text
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rSdrAutofitTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // use B2DRange aAnchorTextRange for calculations
+ basegfx::B2DRange aAnchorTextRange(aTranslate);
+ aAnchorTextRange.expand(aTranslate + aScale);
+
+ // prepare outliner
+ const SfxItemSet& rTextItemSet = rSdrAutofitTextPrimitive.getSdrText()->GetItemSet();
+ SdrOutliner& rOutliner = ImpGetDrawOutliner();
+ SdrTextVertAdjust eVAdj = GetTextVerticalAdjust(rTextItemSet);
+ SdrTextHorzAdjust eHAdj = GetTextHorizontalAdjust(rTextItemSet);
+ const sal_uInt32 nOriginalControlWord(rOutliner.GetControlWord());
+ const Size aNullSize;
+
+ // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
+ rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
+
+ rOutliner.SetControlWord(nOriginalControlWord|EE_CNTRL_AUTOPAGESIZE|EE_CNTRL_STRETCHING);
+ rOutliner.SetMinAutoPaperSize(aNullSize);
+ rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
+
+ // add one to rage sizes to get back to the old Rectangle and outliner measurements
+ const sal_uInt32 nAnchorTextWidth(FRound(aAnchorTextRange.getWidth() + 1L));
+ const sal_uInt32 nAnchorTextHeight(FRound(aAnchorTextRange.getHeight() + 1L));
+ const OutlinerParaObject* pOutlinerParaObject = rSdrAutofitTextPrimitive.getSdrText()->GetOutlinerParaObject();
+ OSL_ENSURE(pOutlinerParaObject, "impDecomposeBlockTextPrimitive used with no OutlinerParaObject (!)");
+ const bool bVerticalWritintg(pOutlinerParaObject->IsVertical());
+ const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
+
+ if((rSdrAutofitTextPrimitive.getWordWrap() || IsTextFrame()))
+ {
+ rOutliner.SetMaxAutoPaperSize(aAnchorTextSize);
+ }
+
+ if(SDRTEXTHORZADJUST_BLOCK == eHAdj && !bVerticalWritintg)
+ {
+ rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0));
+ }
+
+ if(SDRTEXTVERTADJUST_BLOCK == eVAdj && bVerticalWritintg)
+ {
+ rOutliner.SetMinAutoPaperSize(Size(0, nAnchorTextHeight));
+ }
+
+ rOutliner.SetPaperSize(aNullSize);
+ rOutliner.SetUpdateMode(true);
+ rOutliner.SetText(*pOutlinerParaObject);
+ ImpAutoFitText(rOutliner,aAnchorTextSize,bVerticalWritintg);
+
+ // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
+ rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
+
+ // now get back the layouted text size from outliner
+ const Size aOutlinerTextSiz(rOutliner.GetPaperSize());
+ const basegfx::B2DVector aOutlinerScale(aOutlinerTextSiz.Width(), aOutlinerTextSiz.Height());
+ basegfx::B2DVector aAdjustTranslate(0.0, 0.0);
+
+ // correct horizontal translation using the now known text size
+ if(SDRTEXTHORZADJUST_CENTER == eHAdj || SDRTEXTHORZADJUST_RIGHT == eHAdj)
+ {
+ const double fFree(aAnchorTextRange.getWidth() - aOutlinerScale.getX());
+
+ if(SDRTEXTHORZADJUST_CENTER == eHAdj)
+ {
+ aAdjustTranslate.setX(fFree / 2.0);
+ }
+
+ if(SDRTEXTHORZADJUST_RIGHT == eHAdj)
+ {
+ aAdjustTranslate.setX(fFree);
+ }
+ }
+
+ // correct vertical translation using the now known text size
+ if(SDRTEXTVERTADJUST_CENTER == eVAdj || SDRTEXTVERTADJUST_BOTTOM == eVAdj)
+ {
+ const double fFree(aAnchorTextRange.getHeight() - aOutlinerScale.getY());
+
+ if(SDRTEXTVERTADJUST_CENTER == eVAdj)
+ {
+ aAdjustTranslate.setY(fFree / 2.0);
+ }
+
+ if(SDRTEXTVERTADJUST_BOTTOM == eVAdj)
+ {
+ aAdjustTranslate.setY(fFree);
+ }
+ }
+
+ // prepare matrices to apply to newly created primitives. aNewTransformA
+ // will get coordinates in aOutlinerScale size and positive in X, Y.
+ basegfx::B2DHomMatrix aNewTransformA;
+ basegfx::B2DHomMatrix aNewTransformB;
+
+ // translate relative to given primitive to get same rotation and shear
+ // as the master shape we are working on. For vertical, use the top-right
+ // corner
+ const double fStartInX(bVerticalWritintg ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
+ aNewTransformA.translate(fStartInX, aAdjustTranslate.getY());
+
+ // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
+ // move the null point which was top left to bottom right.
+ const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
+ const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
+ aNewTransformB.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0);
+
+ // in-between the translations of the single primitives will take place. Afterwards,
+ // the object's transformations need to be applied
+ aNewTransformB.shearX(fShearX);
+ aNewTransformB.rotate(fRotate);
+ aNewTransformB.translate(aTranslate.getX(), aTranslate.getY());
+
+ basegfx::B2DRange aClipRange;
+
+ // now break up text primitives.
+ impTextBreakupHandler aConverter(rOutliner);
+ aConverter.decomposeBlockTextPrimitive(aNewTransformA, aNewTransformB, aClipRange);
+
+ // cleanup outliner
+ rOutliner.Clear();
+ rOutliner.setVisualizedPage(0);
+ rOutliner.SetControlWord(nOriginalControlWord);
+
+ rTarget = aConverter.getPrimitive2DSequence();
+}
+
+void SdrTextObj::impDecomposeBlockTextPrimitive(
+ drawinglayer::primitive2d::Primitive2DSequence& rTarget,
+ const drawinglayer::primitive2d::SdrBlockTextPrimitive2D& rSdrBlockTextPrimitive,
+ const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
+{
+ // decompose matrix to have position and size of text
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rSdrBlockTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // use B2DRange aAnchorTextRange for calculations
+ basegfx::B2DRange aAnchorTextRange(aTranslate);
+ aAnchorTextRange.expand(aTranslate + aScale);
+
+ // prepare outliner
+ const bool bIsCell(rSdrBlockTextPrimitive.getCellText());
+ SdrOutliner& rOutliner = ImpGetDrawOutliner();
+ SdrTextHorzAdjust eHAdj = rSdrBlockTextPrimitive.getSdrTextHorzAdjust();
+ SdrTextVertAdjust eVAdj = rSdrBlockTextPrimitive.getSdrTextVertAdjust();
+ const sal_uInt32 nOriginalControlWord(rOutliner.GetControlWord());
+ const Size aNullSize;
+
+ // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
+ rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
+ rOutliner.SetFixedCellHeight(rSdrBlockTextPrimitive.isFixedCellHeight());
+ rOutliner.SetControlWord(nOriginalControlWord|EE_CNTRL_AUTOPAGESIZE);
+ rOutliner.SetMinAutoPaperSize(aNullSize);
+ rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
+
+ // add one to rage sizes to get back to the old Rectangle and outliner measurements
+ const sal_uInt32 nAnchorTextWidth(FRound(aAnchorTextRange.getWidth() + 1L));
+ const sal_uInt32 nAnchorTextHeight(FRound(aAnchorTextRange.getHeight() + 1L));
+ const bool bVerticalWritintg(rSdrBlockTextPrimitive.getOutlinerParaObject().IsVertical());
+ const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight));
+
+ if(bIsCell)
+ {
+ // cell text is formated neither like a text object nor like a object
+ // text, so use a special setup here
+ rOutliner.SetMaxAutoPaperSize(aAnchorTextSize);
+
+ // #i106214# To work with an unchangeable PaperSize (CellSize in
+ // this case) Set(Min|Max)AutoPaperSize and SetPaperSize have to be used.
+ // #i106214# This was not completely correct; to still measure the real
+ // text height to allow vertical adjust (and vice versa for VerticalWritintg)
+ // only one aspect has to be set, but the other one to zero
+ if(bVerticalWritintg)
+ {
+ // measure the horizontal text size
+ rOutliner.SetMinAutoPaperSize(Size(0, aAnchorTextSize.Height()));
+ }
+ else
+ {
+ // measure the vertical text size
+ rOutliner.SetMinAutoPaperSize(Size(aAnchorTextSize.Width(), 0));
+ }
+
+ rOutliner.SetPaperSize(aAnchorTextSize);
+ rOutliner.SetUpdateMode(true);
+ rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject());
+ }
+ else
+ {
+ // check if block text is used (only one of them can be true)
+ const bool bHorizontalIsBlock(SDRTEXTHORZADJUST_BLOCK == eHAdj && !bVerticalWritintg);
+ const bool bVerticalIsBlock(SDRTEXTVERTADJUST_BLOCK == eVAdj && bVerticalWritintg);
+
+ // set minimal paper size hor/ver if needed
+ if(bHorizontalIsBlock)
+ {
+ rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0));
+ }
+ else if(bVerticalIsBlock)
+ {
+ rOutliner.SetMinAutoPaperSize(Size(0, nAnchorTextHeight));
+ }
+
+ if((rSdrBlockTextPrimitive.getWordWrap() || IsTextFrame()) && !rSdrBlockTextPrimitive.getUnlimitedPage())
+ {
+ // #i103454# maximal paper size hor/ver needs to be limited to text
+ // frame size. If it's block text, still allow the 'other' direction
+ // to grow to get a correct real text size when using GetPaperSize().
+ // When just using aAnchorTextSize as maximum, GetPaperSize()
+ // would just return aAnchorTextSize again: this means, the wanted
+ // 'measurement' of the real size of block text would not work
+ Size aMaxAutoPaperSize(aAnchorTextSize);
+
+ if(bHorizontalIsBlock)
+ {
+ // allow to grow vertical for horizontal blocks
+ aMaxAutoPaperSize.setHeight(1000000);
+ }
+ else if(bVerticalIsBlock)
+ {
+ // allow to grow horizontal for vertical blocks
+ aMaxAutoPaperSize.setWidth(1000000);
+ }
+
+ rOutliner.SetMaxAutoPaperSize(aMaxAutoPaperSize);
+ }
+
+ rOutliner.SetPaperSize(aNullSize);
+ rOutliner.SetUpdateMode(true);
+ rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject());
+ }
+
+ rOutliner.SetControlWord(nOriginalControlWord);
+
+ // now get back the layouted text size from outliner
+ const Size aOutlinerTextSiz(rOutliner.GetPaperSize());
+ const basegfx::B2DVector aOutlinerScale(aOutlinerTextSiz.Width(), aOutlinerTextSiz.Height());
+ basegfx::B2DVector aAdjustTranslate(0.0, 0.0);
+
+ // For draw objects containing text correct hor/ver alignment if text is bigger
+ // than the object itself. Without that correction, the text would always be
+ // formatted to the left edge (or top edge when vertical) of the draw object.
+ if(!IsTextFrame() && !bIsCell)
+ {
+ if(aAnchorTextRange.getWidth() < aOutlinerScale.getX() && !bVerticalWritintg)
+ {
+ // Horizontal case here. Correct only if eHAdj == SDRTEXTHORZADJUST_BLOCK,
+ // else the alignment is wanted.
+ if(SDRTEXTHORZADJUST_BLOCK == eHAdj)
+ {
+ eHAdj = SDRTEXTHORZADJUST_CENTER;
+ }
+ }
+
+ if(aAnchorTextRange.getHeight() < aOutlinerScale.getY() && bVerticalWritintg)
+ {
+ // Vertical case here. Correct only if eHAdj == SDRTEXTVERTADJUST_BLOCK,
+ // else the alignment is wanted.
+ if(SDRTEXTVERTADJUST_BLOCK == eVAdj)
+ {
+ eVAdj = SDRTEXTVERTADJUST_CENTER;
+ }
+ }
+ }
+
+ // correct horizontal translation using the now known text size
+ if(SDRTEXTHORZADJUST_CENTER == eHAdj || SDRTEXTHORZADJUST_RIGHT == eHAdj)
+ {
+ const double fFree(aAnchorTextRange.getWidth() - aOutlinerScale.getX());
+
+ if(SDRTEXTHORZADJUST_CENTER == eHAdj)
+ {
+ aAdjustTranslate.setX(fFree / 2.0);
+ }
+
+ if(SDRTEXTHORZADJUST_RIGHT == eHAdj)
+ {
+ aAdjustTranslate.setX(fFree);
+ }
+ }
+
+ // correct vertical translation using the now known text size
+ if(SDRTEXTVERTADJUST_CENTER == eVAdj || SDRTEXTVERTADJUST_BOTTOM == eVAdj)
+ {
+ const double fFree(aAnchorTextRange.getHeight() - aOutlinerScale.getY());
+
+ if(SDRTEXTVERTADJUST_CENTER == eVAdj)
+ {
+ aAdjustTranslate.setY(fFree / 2.0);
+ }
+
+ if(SDRTEXTVERTADJUST_BOTTOM == eVAdj)
+ {
+ aAdjustTranslate.setY(fFree);
+ }
+ }
+
+ // prepare matrices to apply to newly created primitives. aNewTransformA
+ // will get coordinates in aOutlinerScale size and positive in X, Y.
+ // Translate relative to given primitive to get same rotation and shear
+ // as the master shape we are working on. For vertical, use the top-right
+ // corner
+ const double fStartInX(bVerticalWritintg ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX());
+ const basegfx::B2DTuple aAdjOffset(fStartInX, aAdjustTranslate.getY());
+ basegfx::B2DHomMatrix aNewTransformA(basegfx::tools::createTranslateB2DHomMatrix(aAdjOffset.getX(), aAdjOffset.getY()));
+
+ // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
+ // move the null point which was top left to bottom right.
+ const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
+ const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
+
+ // in-between the translations of the single primitives will take place. Afterwards,
+ // the object's transformations need to be applied
+ const basegfx::B2DHomMatrix aNewTransformB(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
+ fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
+
+ // #SJ# create ClipRange (if needed)
+ basegfx::B2DRange aClipRange;
+
+ if(rSdrBlockTextPrimitive.getClipOnBounds())
+ {
+ aClipRange.expand(-aAdjOffset);
+ aClipRange.expand(basegfx::B2DTuple(aAnchorTextSize.Width(), aAnchorTextSize.Height()) - aAdjOffset);
+ }
+
+ // now break up text primitives.
+ impTextBreakupHandler aConverter(rOutliner);
+ aConverter.decomposeBlockTextPrimitive(aNewTransformA, aNewTransformB, aClipRange);
+
+ // cleanup outliner
+ rOutliner.Clear();
+ rOutliner.setVisualizedPage(0);
+
+ rTarget = aConverter.getPrimitive2DSequence();
+}
+
+void SdrTextObj::impDecomposeStretchTextPrimitive(
+ drawinglayer::primitive2d::Primitive2DSequence& rTarget,
+ const drawinglayer::primitive2d::SdrStretchTextPrimitive2D& rSdrStretchTextPrimitive,
+ const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
+{
+ // decompose matrix to have position and size of text
+ basegfx::B2DVector aScale, aTranslate;
+ double fRotate, fShearX;
+ rSdrStretchTextPrimitive.getTextRangeTransform().decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // use non-mirrored B2DRange aAnchorTextRange for calculations
+ basegfx::B2DRange aAnchorTextRange(aTranslate);
+ aAnchorTextRange.expand(aTranslate + aScale);
+
+ // prepare outliner
+ SdrOutliner& rOutliner = ImpGetDrawOutliner();
+ const sal_uInt32 nOriginalControlWord(rOutliner.GetControlWord());
+ const Size aNullSize;
+
+ rOutliner.SetControlWord(nOriginalControlWord|EE_CNTRL_STRETCHING|EE_CNTRL_AUTOPAGESIZE);
+ rOutliner.SetFixedCellHeight(rSdrStretchTextPrimitive.isFixedCellHeight());
+ rOutliner.SetMinAutoPaperSize(aNullSize);
+ rOutliner.SetMaxAutoPaperSize(Size(1000000,1000000));
+ rOutliner.SetPaperSize(aNullSize);
+ rOutliner.SetUpdateMode(true);
+ rOutliner.SetText(rSdrStretchTextPrimitive.getOutlinerParaObject());
+
+ // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
+ rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
+
+ // now get back the layouted text size from outliner
+ const Size aOutlinerTextSiz(rOutliner.CalcTextSize());
+ const basegfx::B2DVector aOutlinerScale(
+ basegfx::fTools::equalZero(aOutlinerTextSiz.Width()) ? 1.0 : aOutlinerTextSiz.Width(),
+ basegfx::fTools::equalZero(aOutlinerTextSiz.Height()) ? 1.0 : aOutlinerTextSiz.Height());
+
+ // prepare matrices to apply to newly created primitives
+ basegfx::B2DHomMatrix aNewTransformA;
+
+ // #i101957# Check for vertical text. If used, aNewTransformA
+ // needs to translate the text initially around object width to orient
+ // it relative to the topper right instead of the topper left
+ const bool bVertical(rSdrStretchTextPrimitive.getOutlinerParaObject().IsVertical());
+
+ if(bVertical)
+ {
+ aNewTransformA.translate(aScale.getX(), 0.0);
+ }
+
+ // calculate global char stretching scale parameters. Use non-mirrored sizes
+ // to layout without mirroring
+ const double fScaleX(fabs(aScale.getX()) / aOutlinerScale.getX());
+ const double fScaleY(fabs(aScale.getY()) / aOutlinerScale.getY());
+ rOutliner.SetGlobalCharStretching((sal_Int16)FRound(fScaleX * 100.0), (sal_Int16)FRound(fScaleY * 100.0));
+
+ // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y,
+ // move the null point which was top left to bottom right.
+ const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0));
+ const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0));
+
+ // in-between the translations of the single primitives will take place. Afterwards,
+ // the object's transformations need to be applied
+ const basegfx::B2DHomMatrix aNewTransformB(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0,
+ fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
+
+ // now break up text primitives.
+ impTextBreakupHandler aConverter(rOutliner);
+ aConverter.decomposeStretchTextPrimitive(aNewTransformA, aNewTransformB);
+
+ // cleanup outliner
+ rOutliner.SetControlWord(nOriginalControlWord);
+ rOutliner.Clear();
+ rOutliner.setVisualizedPage(0);
+
+ rTarget = aConverter.getPrimitive2DSequence();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// timing generators
+#define ENDLESS_LOOP (0xffffffff)
+#define ENDLESS_TIME ((double)0xffffffff)
+#define PIXEL_DPI (96.0)
+
+void SdrTextObj::impGetBlinkTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList) const
+{
+ if(SDRTEXTANI_BLINK == GetTextAniKind())
+ {
+ // get values
+ const SfxItemSet& rSet = GetObjectItemSet();
+ const sal_uInt32 nRepeat((sal_uInt32)((SdrTextAniCountItem&)rSet.Get(SDRATTR_TEXT_ANICOUNT)).GetValue());
+ bool bVisisbleWhenStopped(((SdrTextAniStopInsideItem&)rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE)).GetValue());
+ double fDelay((double)((SdrTextAniDelayItem&)rSet.Get(SDRATTR_TEXT_ANIDELAY)).GetValue());
+
+ if(0.0 == fDelay)
+ {
+ // use default
+ fDelay = 250.0;
+ }
+
+ // prepare loop and add
+ drawinglayer::animation::AnimationEntryLoop aLoop(nRepeat ? nRepeat : ENDLESS_LOOP);
+ drawinglayer::animation::AnimationEntryFixed aStart(fDelay, 0.0);
+ aLoop.append(aStart);
+ drawinglayer::animation::AnimationEntryFixed aEnd(fDelay, 1.0);
+ aLoop.append(aEnd);
+ rAnimList.append(aLoop);
+
+ // add stopped state if loop is not endless
+ if(0L != nRepeat)
+ {
+ drawinglayer::animation::AnimationEntryFixed aStop(ENDLESS_TIME, bVisisbleWhenStopped ? 0.0 : 1.0);
+ rAnimList.append(aStop);
+ }
+ }
+}
+
+void impCreateScrollTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, bool bForward, double fTimeFullPath, double fFrequency)
+{
+ bool bVisisbleWhenStopped(((SdrTextAniStopInsideItem&)rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE)).GetValue());
+ bool bVisisbleWhenStarted(((SdrTextAniStartInsideItem&)rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE )).GetValue());
+ const sal_uInt32 nRepeat(((SdrTextAniCountItem&)rSet.Get(SDRATTR_TEXT_ANICOUNT)).GetValue());
+
+ if(bVisisbleWhenStarted)
+ {
+ // move from center to outside
+ drawinglayer::animation::AnimationEntryLinear aInOut(fTimeFullPath * 0.5, fFrequency, 0.5, bForward ? 1.0 : 0.0);
+ rAnimList.append(aInOut);
+ }
+
+ // loop. In loop, move through
+ if(nRepeat || 0L == nRepeat)
+ {
+ drawinglayer::animation::AnimationEntryLoop aLoop(nRepeat ? nRepeat : ENDLESS_LOOP);
+ drawinglayer::animation::AnimationEntryLinear aThrough(fTimeFullPath, fFrequency, bForward ? 0.0 : 1.0, bForward ? 1.0 : 0.0);
+ aLoop.append(aThrough);
+ rAnimList.append(aLoop);
+ }
+
+ if(0L != nRepeat && bVisisbleWhenStopped)
+ {
+ // move from outside to center
+ drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, bForward ? 0.0 : 1.0, 0.5);
+ rAnimList.append(aOutIn);
+
+ // add timing for staying at the end
+ drawinglayer::animation::AnimationEntryFixed aEnd(ENDLESS_TIME, 0.5);
+ rAnimList.append(aEnd);
+ }
+}
+
+void impCreateAlternateTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, double fRelativeTextLength, bool bForward, double fTimeFullPath, double fFrequency)
+{
+ if(basegfx::fTools::more(fRelativeTextLength, 0.5))
+ {
+ // this is the case when fTextLength > fFrameLength, text is bigger than animation frame.
+ // In that case, correct direction
+ bForward = !bForward;
+ }
+
+ const double fStartPosition(bForward ? fRelativeTextLength : 1.0 - fRelativeTextLength);
+ const double fEndPosition(bForward ? 1.0 - fRelativeTextLength : fRelativeTextLength);
+ bool bVisisbleWhenStopped(((SdrTextAniStopInsideItem&)rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE)).GetValue());
+ bool bVisisbleWhenStarted(((SdrTextAniStartInsideItem&)rSet.Get(SDRATTR_TEXT_ANISTOPINSIDE )).GetValue());
+ const sal_uInt32 nRepeat(((SdrTextAniCountItem&)rSet.Get(SDRATTR_TEXT_ANICOUNT)).GetValue());
+
+ if(!bVisisbleWhenStarted)
+ {
+ // move from outside to center
+ drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, bForward ? 0.0 : 1.0, 0.5);
+ rAnimList.append(aOutIn);
+ }
+
+ // loop. In loop, move out and in again. fInnerMovePath may be negative when text is bigger then frame,
+ // so use absolute value
+ const double fInnerMovePath(fabs(1.0 - (fRelativeTextLength * 2.0)));
+ const double fTimeForInnerPath(fTimeFullPath * fInnerMovePath);
+ const double fHalfInnerPath(fTimeForInnerPath * 0.5);
+ const sal_uInt32 nDoubleRepeat(nRepeat / 2L);
+
+ if(nDoubleRepeat || 0L == nRepeat)
+ {
+ // double forth and back loop
+ drawinglayer::animation::AnimationEntryLoop aLoop(nDoubleRepeat ? nDoubleRepeat : ENDLESS_LOOP);
+ drawinglayer::animation::AnimationEntryLinear aTime0(fHalfInnerPath, fFrequency, 0.5, fEndPosition);
+ aLoop.append(aTime0);
+ drawinglayer::animation::AnimationEntryLinear aTime1(fTimeForInnerPath, fFrequency, fEndPosition, fStartPosition);
+ aLoop.append(aTime1);
+ drawinglayer::animation::AnimationEntryLinear aTime2(fHalfInnerPath, fFrequency, fStartPosition, 0.5);
+ aLoop.append(aTime2);
+ rAnimList.append(aLoop);
+ }
+
+ if(nRepeat % 2L)
+ {
+ // repeat is uneven, so we need one more forth and back to center
+ drawinglayer::animation::AnimationEntryLinear aTime0(fHalfInnerPath, fFrequency, 0.5, fEndPosition);
+ rAnimList.append(aTime0);
+ drawinglayer::animation::AnimationEntryLinear aTime1(fHalfInnerPath, fFrequency, fEndPosition, 0.5);
+ rAnimList.append(aTime1);
+ }
+
+ if(0L != nRepeat)
+ {
+ if(bVisisbleWhenStopped)
+ {
+ // add timing for staying at the end
+ drawinglayer::animation::AnimationEntryFixed aEnd(ENDLESS_TIME, 0.5);
+ rAnimList.append(aEnd);
+ }
+ else
+ {
+ // move from center to outside
+ drawinglayer::animation::AnimationEntryLinear aInOut(fTimeFullPath * 0.5, fFrequency, 0.5, bForward ? 1.0 : 0.0);
+ rAnimList.append(aInOut);
+ }
+ }
+}
+
+void impCreateSlideTiming(const SfxItemSet& rSet, drawinglayer::animation::AnimationEntryList& rAnimList, bool bForward, double fTimeFullPath, double fFrequency)
+{
+ // move in from outside, start outside
+ const double fStartPosition(bForward ? 0.0 : 1.0);
+ const sal_uInt32 nRepeat(((SdrTextAniCountItem&)rSet.Get(SDRATTR_TEXT_ANICOUNT)).GetValue());
+
+ // move from outside to center
+ drawinglayer::animation::AnimationEntryLinear aOutIn(fTimeFullPath * 0.5, fFrequency, fStartPosition, 0.5);
+ rAnimList.append(aOutIn);
+
+ // loop. In loop, move out and in again
+ if(nRepeat > 1L || 0L == nRepeat)
+ {
+ drawinglayer::animation::AnimationEntryLoop aLoop(nRepeat ? nRepeat - 1L : ENDLESS_LOOP);
+ drawinglayer::animation::AnimationEntryLinear aTime0(fTimeFullPath * 0.5, fFrequency, 0.5, fStartPosition);
+ aLoop.append(aTime0);
+ drawinglayer::animation::AnimationEntryLinear aTime1(fTimeFullPath * 0.5, fFrequency, fStartPosition, 0.5);
+ aLoop.append(aTime1);
+ rAnimList.append(aLoop);
+ }
+
+ // always visible when stopped, so add timing for staying at the end when not endless
+ if(0L != nRepeat)
+ {
+ drawinglayer::animation::AnimationEntryFixed aEnd(ENDLESS_TIME, 0.5);
+ rAnimList.append(aEnd);
+ }
+}
+
+void SdrTextObj::impGetScrollTextTiming(drawinglayer::animation::AnimationEntryList& rAnimList, double fFrameLength, double fTextLength) const
+{
+ const SdrTextAniKind eAniKind(GetTextAniKind());
+
+ if(SDRTEXTANI_SCROLL == eAniKind || SDRTEXTANI_ALTERNATE == eAniKind || SDRTEXTANI_SLIDE == eAniKind)
+ {
+ // get data. Goal is to calculate fTimeFullPath which is the time needed to
+ // move animation from (0.0) to (1.0) state
+ const SfxItemSet& rSet = GetObjectItemSet();
+ double fAnimationDelay((double)((SdrTextAniDelayItem&)rSet.Get(SDRATTR_TEXT_ANIDELAY)).GetValue());
+ double fSingleStepWidth((double)((SdrTextAniAmountItem&)rSet.Get(SDRATTR_TEXT_ANIAMOUNT)).GetValue());
+ const SdrTextAniDirection eDirection(GetTextAniDirection());
+ const bool bForward(SDRTEXTANI_RIGHT == eDirection || SDRTEXTANI_DOWN == eDirection);
+
+ if(basegfx::fTools::equalZero(fAnimationDelay))
+ {
+ // default to 1/20 second
+ fAnimationDelay = 50.0;
+ }
+
+ if(basegfx::fTools::less(fSingleStepWidth, 0.0))
+ {
+ // data is in pixels, convert to logic. Imply PIXEL_DPI dpi.
+ // It makes no sense to keep the view-transformation centered
+ // definitions, so get rid of them here.
+ fSingleStepWidth = (-fSingleStepWidth * (2540.0 / PIXEL_DPI));
+ }
+
+ if(basegfx::fTools::equalZero(fSingleStepWidth))
+ {
+ // default to 1 milimeter
+ fSingleStepWidth = 100.0;
+ }
+
+ // use the length of the full animation path and the number of steps
+ // to get the full path time
+ const double fFullPathLength(fFrameLength + fTextLength);
+ const double fNumberOfSteps(fFullPathLength / fSingleStepWidth);
+ double fTimeFullPath(fNumberOfSteps * fAnimationDelay);
+
+ if(fTimeFullPath < fAnimationDelay)
+ {
+ fTimeFullPath = fAnimationDelay;
+ }
+
+ switch(eAniKind)
+ {
+ case SDRTEXTANI_SCROLL :
+ {
+ impCreateScrollTiming(rSet, rAnimList, bForward, fTimeFullPath, fAnimationDelay);
+ break;
+ }
+ case SDRTEXTANI_ALTERNATE :
+ {
+ double fRelativeTextLength(fTextLength / (fFrameLength + fTextLength));
+ impCreateAlternateTiming(rSet, rAnimList, fRelativeTextLength, bForward, fTimeFullPath, fAnimationDelay);
+ break;
+ }
+ case SDRTEXTANI_SLIDE :
+ {
+ impCreateSlideTiming(rSet, rAnimList, bForward, fTimeFullPath, fAnimationDelay);
+ break;
+ }
+ default : break; // SDRTEXTANI_NONE, SDRTEXTANI_BLINK
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotextpathdecomposition.cxx b/svx/source/svdraw/svdotextpathdecomposition.cxx
new file mode 100644
index 000000000000..9eb2f0121a03
--- /dev/null
+++ b/svx/source/svdraw/svdotextpathdecomposition.cxx
@@ -0,0 +1,827 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdotext.hxx>
+#include <svx/svdoutl.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+#include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <vcl/salbtype.hxx>
+#include <svl/itemset.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <algorithm>
+#include <svx/xtextit.hxx>
+#include <svx/xftshtit.hxx>
+#include <vcl/virdev.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/i18n/ScriptType.hdl>
+#include <com/sun/star/i18n/XBreakIterator.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/i18n/CharacterIteratorMode.hdl>
+#include <editeng/unolingu.hxx>
+#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
+#include <drawinglayer/primitive2d/textprimitive2d.hxx>
+#include <basegfx/color/bcolor.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// primitive decomposition helpers
+
+#include <basegfx/polygon/b2dlinegeometry.hxx>
+#include <drawinglayer/attribute/strokeattribute.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlinjoit.hxx>
+#include <svx/xlndsit.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
+#include <editeng/editstat.hxx>
+#include <unoapi.hxx>
+#include <drawinglayer/geometry/viewinformation2d.hxx>
+#include <svx/sdr/attribute/sdrformtextoutlineattribute.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::i18n;
+
+//////////////////////////////////////////////////////////////////////////////
+// PathTextPortion helper
+
+namespace
+{
+ class impPathTextPortion
+ {
+ basegfx::B2DVector maOffset;
+ String maText;
+ xub_StrLen mnTextStart;
+ xub_StrLen mnTextLength;
+ sal_uInt16 mnParagraph;
+ xub_StrLen mnIndex;
+ SvxFont maFont;
+ ::std::vector< double > maDblDXArray; // double DXArray, font size independent -> unit coordinate system
+ ::com::sun::star::lang::Locale maLocale;
+
+ // bitfield
+ unsigned mbRTL : 1;
+
+ public:
+ impPathTextPortion(DrawPortionInfo& rInfo)
+ : maOffset(rInfo.mrStartPos.X(), rInfo.mrStartPos.Y()),
+ maText(rInfo.mrText),
+ mnTextStart(rInfo.mnTextStart),
+ mnTextLength(rInfo.mnTextLen),
+ mnParagraph(rInfo.mnPara),
+ mnIndex(rInfo.mnIndex),
+ maFont(rInfo.mrFont),
+ maDblDXArray(),
+ maLocale(rInfo.mpLocale ? *rInfo.mpLocale : ::com::sun::star::lang::Locale()),
+ mbRTL(rInfo.mrFont.IsVertical() ? false : rInfo.IsRTL())
+ {
+ if(mnTextLength && rInfo.mpDXArray)
+ {
+ maDblDXArray.reserve(mnTextLength);
+
+ for(xub_StrLen a(0); a < mnTextLength; a++)
+ {
+ maDblDXArray.push_back((double)rInfo.mpDXArray[a]);
+ }
+ }
+ }
+
+ // for ::std::sort
+ bool operator<(const impPathTextPortion& rComp) const
+ {
+ if(mnParagraph < rComp.mnParagraph)
+ {
+ return true;
+ }
+
+ if(maOffset.getX() < rComp.maOffset.getX())
+ {
+ return true;
+ }
+
+ return (maOffset.getY() < rComp.maOffset.getY());
+ }
+
+ const basegfx::B2DVector& getOffset() const { return maOffset; }
+ const String& getText() const { return maText; }
+ xub_StrLen getTextStart() const { return mnTextStart; }
+ xub_StrLen getTextLength() const { return mnTextLength; }
+ sal_uInt16 getParagraph() const { return mnParagraph; }
+ xub_StrLen getIndex() const { return mnIndex; }
+ const SvxFont& getFont() const { return maFont; }
+ bool isRTL() const { return mbRTL; }
+ const ::std::vector< double >& getDoubleDXArray() const { return maDblDXArray; }
+ const ::com::sun::star::lang::Locale& getLocale() const { return maLocale; }
+
+ xub_StrLen getPortionIndex(xub_StrLen nIndex, xub_StrLen nLength) const
+ {
+ if(mbRTL)
+ {
+ return (mnTextStart + (mnTextLength - (nIndex + nLength)));
+ }
+ else
+ {
+ return (mnTextStart + nIndex);
+ }
+ }
+
+ double getDisplayLength(xub_StrLen nIndex, xub_StrLen nLength) const
+ {
+ drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
+ double fRetval(0.0);
+
+ if(maFont.IsVertical())
+ {
+ fRetval = aTextLayouter.getTextHeight() * (double)nLength;
+ }
+ else
+ {
+ fRetval = aTextLayouter.getTextWidth(maText, getPortionIndex(nIndex, nLength), nLength);
+ }
+
+ return fRetval;
+ }
+ };
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+// TextBreakup helper
+
+namespace
+{
+ class impTextBreakupHandler
+ {
+ SdrOutliner& mrOutliner;
+ ::std::vector< impPathTextPortion > maPathTextPortions;
+
+ DECL_LINK(decompositionPathTextPrimitive, DrawPortionInfo* );
+
+ public:
+ impTextBreakupHandler(SdrOutliner& rOutliner)
+ : mrOutliner(rOutliner)
+ {
+ }
+
+ const ::std::vector< impPathTextPortion >& decompositionPathTextPrimitive()
+ {
+ // strip portions to maPathTextPortions
+ mrOutliner.SetDrawPortionHdl(LINK(this, impTextBreakupHandler, decompositionPathTextPrimitive));
+ mrOutliner.StripPortions();
+
+ if(maPathTextPortions.size())
+ {
+ // sort portions by paragraph, x and y
+ ::std::sort(maPathTextPortions.begin(), maPathTextPortions.end());
+ }
+
+ return maPathTextPortions;
+ }
+ };
+
+ IMPL_LINK(impTextBreakupHandler, decompositionPathTextPrimitive, DrawPortionInfo*, pInfo)
+ {
+ maPathTextPortions.push_back(impPathTextPortion(*pInfo));
+ return 0;
+ }
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+// TextBreakup one poly and one paragraph helper
+
+namespace
+{
+ class impPolygonParagraphHandler
+ {
+ const drawinglayer::attribute::SdrFormTextAttribute maSdrFormTextAttribute; // FormText parameters
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& mrDecomposition; // destination primitive list
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& mrShadowDecomposition; // destination primitive list for shadow
+ Reference < com::sun::star::i18n::XBreakIterator > mxBreak; // break iterator
+
+ double getParagraphTextLength(const ::std::vector< const impPathTextPortion* >& rTextPortions)
+ {
+ drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
+ double fRetval(0.0);
+
+ for(sal_uInt32 a(0L); a < rTextPortions.size(); a++)
+ {
+ const impPathTextPortion* pCandidate = rTextPortions[a];
+
+ if(pCandidate && pCandidate->getTextLength())
+ {
+ aTextLayouter.setFont(pCandidate->getFont());
+ fRetval += pCandidate->getDisplayLength(0L, pCandidate->getTextLength());
+ }
+ }
+
+ return fRetval;
+ }
+
+ xub_StrLen getNextGlyphLen(const impPathTextPortion* pCandidate, xub_StrLen nPosition, const ::com::sun::star::lang::Locale& rFontLocale)
+ {
+ xub_StrLen nNextGlyphLen(1);
+
+ if(mxBreak.is())
+ {
+ sal_Int32 nDone(0L);
+ nNextGlyphLen = (xub_StrLen)mxBreak->nextCharacters(pCandidate->getText(), nPosition,
+ rFontLocale, CharacterIteratorMode::SKIPCELL, 1, nDone) - nPosition;
+ }
+
+ return nNextGlyphLen;
+ }
+
+ public:
+ impPolygonParagraphHandler(
+ const drawinglayer::attribute::SdrFormTextAttribute& rSdrFormTextAttribute,
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rDecomposition,
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rShadowDecomposition)
+ : maSdrFormTextAttribute(rSdrFormTextAttribute),
+ mrDecomposition(rDecomposition),
+ mrShadowDecomposition(rShadowDecomposition)
+ {
+ // prepare BreakIterator
+ Reference < XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
+ Reference < XInterface > xInterface = xMSF->createInstance(::rtl::OUString::createFromAscii("com.sun.star.i18n.BreakIterator"));
+
+ if(xInterface.is())
+ {
+ Any x = xInterface->queryInterface(::getCppuType((const Reference< XBreakIterator >*)0));
+ x >>= mxBreak;
+ }
+ }
+
+ void HandlePair(const basegfx::B2DPolygon rPolygonCandidate, const ::std::vector< const impPathTextPortion* >& rTextPortions)
+ {
+ // prepare polygon geometry, take into account as many parameters as possible
+ basegfx::B2DPolygon aPolygonCandidate(rPolygonCandidate);
+ const double fPolyLength(basegfx::tools::getLength(aPolygonCandidate));
+ double fPolyEnd(fPolyLength);
+ double fPolyStart(0.0);
+ double fAutosizeScaleFactor(1.0);
+ bool bAutosizeScale(false);
+
+ if(maSdrFormTextAttribute.getFormTextMirror())
+ {
+ aPolygonCandidate.flip();
+ }
+
+ if(maSdrFormTextAttribute.getFormTextStart()
+ && (XFT_LEFT == maSdrFormTextAttribute.getFormTextAdjust()
+ || XFT_RIGHT == maSdrFormTextAttribute.getFormTextAdjust()))
+ {
+ if(XFT_LEFT == maSdrFormTextAttribute.getFormTextAdjust())
+ {
+ fPolyStart += maSdrFormTextAttribute.getFormTextStart();
+
+ if(fPolyStart > fPolyEnd)
+ {
+ fPolyStart = fPolyEnd;
+ }
+ }
+ else
+ {
+ fPolyEnd -= maSdrFormTextAttribute.getFormTextStart();
+
+ if(fPolyEnd < fPolyStart)
+ {
+ fPolyEnd = fPolyStart;
+ }
+ }
+ }
+
+ if(XFT_LEFT != maSdrFormTextAttribute.getFormTextAdjust())
+ {
+ // calculate total text length of this paragraph, some layout needs to be done
+ const double fParagraphTextLength(getParagraphTextLength(rTextPortions));
+
+ // check if text is too long for paragraph. If yes, handle as if left aligned (default),
+ // but still take care of XFT_AUTOSIZE in that case
+ const bool bTextTooLong(fParagraphTextLength > (fPolyEnd - fPolyStart));
+
+ if(XFT_RIGHT == maSdrFormTextAttribute.getFormTextAdjust())
+ {
+ if(!bTextTooLong)
+ {
+ // if right aligned, add difference to polygon start
+ fPolyStart += ((fPolyEnd - fPolyStart) - fParagraphTextLength);
+ }
+ }
+ else if(XFT_CENTER == maSdrFormTextAttribute.getFormTextAdjust())
+ {
+ if(!bTextTooLong)
+ {
+ // if centered, add half of difference to polygon start
+ fPolyStart += ((fPolyEnd - fPolyStart) - fParagraphTextLength) / 2.0;
+ }
+ }
+ else if(XFT_AUTOSIZE == maSdrFormTextAttribute.getFormTextAdjust())
+ {
+ // if scale, prepare scale factor between curve length and text length
+ if(0.0 != fParagraphTextLength)
+ {
+ fAutosizeScaleFactor = (fPolyEnd - fPolyStart) / fParagraphTextLength;
+ bAutosizeScale = true;
+ }
+ }
+ }
+
+ // handle text portions for this paragraph
+ for(sal_uInt32 a(0L); a < rTextPortions.size() && fPolyStart < fPolyEnd; a++)
+ {
+ const impPathTextPortion* pCandidate = rTextPortions[a];
+ basegfx::B2DVector aFontScaling;
+ const drawinglayer::attribute::FontAttribute aCandidateFontAttribute(
+ drawinglayer::primitive2d::getFontAttributeFromVclFont(
+ aFontScaling,
+ pCandidate->getFont(),
+ pCandidate->isRTL(),
+ false));
+
+ if(pCandidate && pCandidate->getTextLength())
+ {
+ drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
+ aTextLayouter.setFont(pCandidate->getFont());
+ xub_StrLen nUsedTextLength(0);
+
+ while(nUsedTextLength < pCandidate->getTextLength() && fPolyStart < fPolyEnd)
+ {
+ xub_StrLen nNextGlyphLen(getNextGlyphLen(pCandidate, pCandidate->getTextStart() + nUsedTextLength, pCandidate->getLocale()));
+
+ // prepare portion length. Takes RTL sections into account.
+ double fPortionLength(pCandidate->getDisplayLength(nUsedTextLength, nNextGlyphLen));
+
+ if(bAutosizeScale)
+ {
+ // when autosize scaling, expand portion length
+ fPortionLength *= fAutosizeScaleFactor;
+ }
+
+ // create transformation
+ basegfx::B2DHomMatrix aNewTransformA, aNewTransformB, aNewShadowTransform;
+ basegfx::B2DPoint aStartPos(basegfx::tools::getPositionAbsolute(aPolygonCandidate, fPolyStart, fPolyLength));
+ basegfx::B2DPoint aEndPos(aStartPos);
+
+ // add font scaling
+ aNewTransformA.scale(aFontScaling.getX(), aFontScaling.getY());
+
+ // prepare scaling of text primitive
+ if(bAutosizeScale)
+ {
+ // when autosize scaling, expand text primitive scaling to it
+ aNewTransformA.scale(fAutosizeScaleFactor, fAutosizeScaleFactor);
+ }
+
+ // eventually create shadow primitives from aDecomposition and add to rDecomposition
+ const bool bShadow(XFTSHADOW_NONE != maSdrFormTextAttribute.getFormTextShadow());
+
+ if(bShadow)
+ {
+ if(XFTSHADOW_NORMAL == maSdrFormTextAttribute.getFormTextShadow())
+ {
+ aNewShadowTransform.translate(
+ maSdrFormTextAttribute.getFormTextShdwXVal(),
+ -maSdrFormTextAttribute.getFormTextShdwYVal());
+ }
+ else // XFTSHADOW_SLANT
+ {
+ double fScaleValue(maSdrFormTextAttribute.getFormTextShdwYVal() / 100.0);
+ double fShearValue(-maSdrFormTextAttribute.getFormTextShdwXVal() * F_PI1800);
+
+ aNewShadowTransform.scale(1.0, fScaleValue);
+ aNewShadowTransform.shearX(sin(fShearValue));
+ aNewShadowTransform.scale(1.0, cos(fShearValue));
+ }
+ }
+
+ switch(maSdrFormTextAttribute.getFormTextStyle())
+ {
+ case XFT_ROTATE :
+ {
+ aEndPos = basegfx::tools::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
+ const basegfx::B2DVector aDirection(aEndPos - aStartPos);
+ aNewTransformB.rotate(atan2(aDirection.getY(), aDirection.getX()));
+ aNewTransformB.translate(aStartPos.getX(), aStartPos.getY());
+
+ break;
+ }
+ case XFT_UPRIGHT :
+ {
+ aNewTransformB.translate(aStartPos.getX() - (fPortionLength / 2.0), aStartPos.getY());
+
+ break;
+ }
+ case XFT_SLANTX :
+ {
+ aEndPos = basegfx::tools::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
+ const basegfx::B2DVector aDirection(aEndPos - aStartPos);
+ const double fShearValue(atan2(aDirection.getY(), aDirection.getX()));
+ const double fSin(sin(fShearValue));
+ const double fCos(cos(fShearValue));
+
+ aNewTransformB.shearX(-fSin);
+
+ // Scale may lead to objects without height since fCos == 0.0 is possible.
+ // Renderers need to handle that, it's not a forbidden value and does not
+ // need to be avoided
+ aNewTransformB.scale(1.0, fCos);
+ aNewTransformB.translate(aStartPos.getX() - (fPortionLength / 2.0), aStartPos.getY());
+
+ break;
+ }
+ case XFT_SLANTY :
+ {
+ aEndPos = basegfx::tools::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
+ const basegfx::B2DVector aDirection(aEndPos - aStartPos);
+ const double fShearValue(atan2(aDirection.getY(), aDirection.getX()));
+ const double fCos(cos(fShearValue));
+ const double fTan(tan(fShearValue));
+
+ // shear to 'stand' on the curve
+ aNewTransformB.shearY(fTan);
+
+ // scale in X to make as tight as needed. As with XFT_SLANT_X, this may
+ // lead to primitives without width which the renderers will handle
+ aNewTransformA.scale(fCos, 1.0);
+
+ aNewTransformB.translate(aStartPos.getX(), aStartPos.getY());
+
+ break;
+ }
+ default : break; // XFT_NONE
+ }
+
+ // distance from path?
+ if(maSdrFormTextAttribute.getFormTextDistance())
+ {
+ if(aEndPos.equal(aStartPos))
+ {
+ aEndPos = basegfx::tools::getPositionAbsolute(aPolygonCandidate, fPolyStart + fPortionLength, fPolyLength);
+ }
+
+ // use back vector (aStartPos - aEndPos) here to get mirrored perpendicular as in old stuff
+ const basegfx::B2DVector aPerpendicular(
+ basegfx::getNormalizedPerpendicular(aStartPos - aEndPos) *
+ maSdrFormTextAttribute.getFormTextDistance());
+ aNewTransformB.translate(aPerpendicular.getX(), aPerpendicular.getY());
+ }
+
+ if(pCandidate->getText().Len() && nNextGlyphLen)
+ {
+ const xub_StrLen nPortionIndex(pCandidate->getPortionIndex(nUsedTextLength, nNextGlyphLen));
+ ::std::vector< double > aNewDXArray;
+
+ if(nNextGlyphLen > 1 && pCandidate->getDoubleDXArray().size())
+ {
+ // copy DXArray for portion
+ aNewDXArray.insert(
+ aNewDXArray.begin(),
+ pCandidate->getDoubleDXArray().begin() + nPortionIndex,
+ pCandidate->getDoubleDXArray().begin() + (nPortionIndex + nNextGlyphLen));
+
+ if(nPortionIndex > 0)
+ {
+ // adapt to portion start
+ double fDXOffset= *(pCandidate->getDoubleDXArray().begin() + (nPortionIndex - 1));
+ ::std::transform(
+ aNewDXArray.begin(), aNewDXArray.end(),
+ aNewDXArray.begin(), ::std::bind2nd(::std::minus<double>(), fDXOffset));
+ }
+
+ if(bAutosizeScale)
+ {
+ // when autosize scaling, adapt to DXArray, too
+ ::std::transform(
+ aNewDXArray.begin(), aNewDXArray.end(),
+ aNewDXArray.begin(), ::std::bind2nd(::std::multiplies<double>(), fAutosizeScaleFactor));
+ }
+ }
+
+ if(bShadow)
+ {
+ // shadow primitive creation
+ const Color aShadowColor(maSdrFormTextAttribute.getFormTextShdwColor());
+ const basegfx::BColor aRGBShadowColor(aShadowColor.getBColor());
+
+ drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pNew =
+ new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
+ aNewTransformB * aNewShadowTransform * aNewTransformA,
+ pCandidate->getText(),
+ nPortionIndex,
+ nNextGlyphLen,
+ aNewDXArray,
+ aCandidateFontAttribute,
+ pCandidate->getLocale(),
+ aRGBShadowColor);
+
+ mrShadowDecomposition.push_back(pNew);
+ }
+
+ {
+ // primitive creation
+ const Color aColor(pCandidate->getFont().GetColor());
+ const basegfx::BColor aRGBColor(aColor.getBColor());
+
+ drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pNew =
+ new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
+ aNewTransformB * aNewTransformA,
+ pCandidate->getText(),
+ nPortionIndex,
+ nNextGlyphLen,
+ aNewDXArray,
+ aCandidateFontAttribute,
+ pCandidate->getLocale(),
+ aRGBColor);
+
+ mrDecomposition.push_back(pNew);
+ }
+ }
+
+ // consume from portion // no += here, xub_StrLen is USHORT and the compiler will gererate a warning here
+ nUsedTextLength = nUsedTextLength + nNextGlyphLen;
+
+ // consume from polygon
+ fPolyStart += fPortionLength;
+ }
+ }
+ }
+ }
+ };
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+// primitive decomposition helpers
+
+namespace
+{
+ void impAddPolygonStrokePrimitives(
+ const basegfx::B2DPolyPolygonVector& rB2DPolyPolyVector,
+ const basegfx::B2DHomMatrix& rTransform,
+ const drawinglayer::attribute::LineAttribute& rLineAttribute,
+ const drawinglayer::attribute::StrokeAttribute& rStrokeAttribute,
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rTarget)
+ {
+ for(basegfx::B2DPolyPolygonVector::const_iterator aPolygon(rB2DPolyPolyVector.begin()); aPolygon != rB2DPolyPolyVector.end(); aPolygon++)
+ {
+ // prepare PolyPolygons
+ basegfx::B2DPolyPolygon aB2DPolyPolygon = *aPolygon;
+ aB2DPolyPolygon.transform(rTransform);
+
+ for(sal_uInt32 a(0L); a < aB2DPolyPolygon.count(); a++)
+ {
+ // create one primitive per polygon
+ drawinglayer::primitive2d::PolygonStrokePrimitive2D* pNew =
+ new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
+ aB2DPolyPolygon.getB2DPolygon(a), rLineAttribute, rStrokeAttribute);
+ rTarget.push_back(pNew);
+ }
+ }
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence impAddPathTextOutlines(
+ const std::vector< drawinglayer::primitive2d::BasePrimitive2D* >& rSource,
+ const drawinglayer::attribute::SdrFormTextOutlineAttribute& rOutlineAttribute)
+ {
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aNewPrimitives;
+
+ for(sal_uInt32 a(0L); a < rSource.size(); a++)
+ {
+ const drawinglayer::primitive2d::TextSimplePortionPrimitive2D* pTextCandidate = dynamic_cast< const drawinglayer::primitive2d::TextSimplePortionPrimitive2D* >(rSource[a]);
+
+ if(pTextCandidate)
+ {
+ basegfx::B2DPolyPolygonVector aB2DPolyPolyVector;
+ basegfx::B2DHomMatrix aPolygonTransform;
+
+ // get text outlines and their object transformation
+ pTextCandidate->getTextOutlinesAndTransformation(aB2DPolyPolyVector, aPolygonTransform);
+
+ if(aB2DPolyPolyVector.size())
+ {
+ // create stroke primitives
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aStrokePrimitives;
+ impAddPolygonStrokePrimitives(
+ aB2DPolyPolyVector,
+ aPolygonTransform,
+ rOutlineAttribute.getLineAttribute(),
+ rOutlineAttribute.getStrokeAttribute(),
+ aStrokePrimitives);
+ const sal_uInt32 nStrokeCount(aStrokePrimitives.size());
+
+ if(nStrokeCount)
+ {
+ if(rOutlineAttribute.getTransparence())
+ {
+ // create UnifiedTransparencePrimitive2D
+ drawinglayer::primitive2d::Primitive2DSequence aStrokePrimitiveSequence(nStrokeCount);
+
+ for(sal_uInt32 b(0L); b < nStrokeCount; b++)
+ {
+ aStrokePrimitiveSequence[b] = drawinglayer::primitive2d::Primitive2DReference(aStrokePrimitives[b]);
+ }
+
+ drawinglayer::primitive2d::UnifiedTransparencePrimitive2D* pNew2 =
+ new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
+ aStrokePrimitiveSequence,
+ (double)rOutlineAttribute.getTransparence() / 100.0);
+ aNewPrimitives.push_back(pNew2);
+ }
+ else
+ {
+ // add polygons to rDecomposition as polygonStrokePrimitives
+ aNewPrimitives.insert(aNewPrimitives.end(), aStrokePrimitives.begin(), aStrokePrimitives.end());
+ }
+ }
+ }
+ }
+ }
+
+ const sal_uInt32 nNewCount(aNewPrimitives.size());
+
+ if(nNewCount)
+ {
+ drawinglayer::primitive2d::Primitive2DSequence aRetval(nNewCount);
+
+ for(sal_uInt32 a(0L); a < nNewCount; a++)
+ {
+ aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(aNewPrimitives[a]);
+ }
+
+ return aRetval;
+ }
+ else
+ {
+ return drawinglayer::primitive2d::Primitive2DSequence();
+ }
+ }
+} // end of anonymous namespace
+
+//////////////////////////////////////////////////////////////////////////////
+// primitive decomposition
+
+void SdrTextObj::impDecomposePathTextPrimitive(
+ drawinglayer::primitive2d::Primitive2DSequence& rTarget,
+ const drawinglayer::primitive2d::SdrPathTextPrimitive2D& rSdrPathTextPrimitive,
+ const drawinglayer::geometry::ViewInformation2D& aViewInformation) const
+{
+ drawinglayer::primitive2d::Primitive2DSequence aRetvalA;
+ drawinglayer::primitive2d::Primitive2DSequence aRetvalB;
+
+ // prepare outliner
+ SdrOutliner& rOutliner = ImpGetDrawOutliner();
+ rOutliner.SetUpdateMode(true);
+ rOutliner.Clear();
+ rOutliner.SetPaperSize(Size(LONG_MAX,LONG_MAX));
+ rOutliner.SetText(rSdrPathTextPrimitive.getOutlinerParaObject());
+
+ // set visualizing page at Outliner; needed e.g. for PageNumberField decomposition
+ rOutliner.setVisualizedPage(GetSdrPageFromXDrawPage(aViewInformation.getVisualizedPage()));
+
+ // now break up to text portions
+ impTextBreakupHandler aConverter(rOutliner);
+ const ::std::vector< impPathTextPortion > rPathTextPortions = aConverter.decompositionPathTextPrimitive();
+
+ if(rPathTextPortions.size())
+ {
+ // get FormText and polygon values
+ const drawinglayer::attribute::SdrFormTextAttribute& rFormTextAttribute = rSdrPathTextPrimitive.getSdrFormTextAttribute();
+ const basegfx::B2DPolyPolygon& rPathPolyPolygon(rSdrPathTextPrimitive.getPathPolyPolygon());
+
+ // get loop count
+ sal_uInt32 nLoopCount(rPathPolyPolygon.count());
+
+ if(rOutliner.GetParagraphCount() < nLoopCount)
+ {
+ nLoopCount = rOutliner.GetParagraphCount();
+ }
+
+ if(nLoopCount)
+ {
+ // prepare common decomposition stuff
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aRegularDecomposition;
+ std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aShadowDecomposition;
+ impPolygonParagraphHandler aPolygonParagraphHandler(
+ rFormTextAttribute,
+ aRegularDecomposition,
+ aShadowDecomposition);
+ sal_uInt32 a;
+
+ for(a = 0L; a < nLoopCount; a++)
+ {
+ // filter text portions for this paragraph
+ ::std::vector< const impPathTextPortion* > aParagraphTextPortions;
+
+ for(sal_uInt32 b(0L); b < rPathTextPortions.size(); b++)
+ {
+ const impPathTextPortion& rCandidate = rPathTextPortions[b];
+
+ if(rCandidate.getParagraph() == a)
+ {
+ aParagraphTextPortions.push_back(&rCandidate);
+ }
+ }
+
+ // handle data pair polygon/ParagraphTextPortions
+ if(aParagraphTextPortions.size())
+ {
+ aPolygonParagraphHandler.HandlePair(rPathPolyPolygon.getB2DPolygon(a), aParagraphTextPortions);
+ }
+ }
+
+ const sal_uInt32 nShadowCount(aShadowDecomposition.size());
+ const sal_uInt32 nRegularCount(aRegularDecomposition.size());
+
+ if(nShadowCount)
+ {
+ // add shadow primitives to decomposition
+ aRetvalA.realloc(nShadowCount);
+
+ for(a = 0L; a < nShadowCount; a++)
+ {
+ aRetvalA[a] = drawinglayer::primitive2d::Primitive2DReference(aShadowDecomposition[a]);
+ }
+
+ // evtl. add shadow outlines
+ if(rFormTextAttribute.getFormTextOutline()
+ && !rFormTextAttribute.getShadowOutline().isDefault())
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence aOutlines(
+ impAddPathTextOutlines(
+ aShadowDecomposition,
+ rFormTextAttribute.getShadowOutline()));
+
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aRetvalA, aOutlines);
+ }
+ }
+
+ if(nRegularCount)
+ {
+ // add normal primitives to decomposition
+ aRetvalB.realloc(nRegularCount);
+
+ for(a = 0L; a < nRegularCount; a++)
+ {
+ aRetvalB[a] = drawinglayer::primitive2d::Primitive2DReference(aRegularDecomposition[a]);
+ }
+
+ // evtl. add outlines
+ if(rFormTextAttribute.getFormTextOutline()
+ && !rFormTextAttribute.getOutline().isDefault())
+ {
+ const drawinglayer::primitive2d::Primitive2DSequence aOutlines(
+ impAddPathTextOutlines(
+ aRegularDecomposition,
+ rFormTextAttribute.getOutline()));
+
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(aRetvalB, aOutlines);
+ }
+ }
+ }
+ }
+
+ // cleanup outliner
+ rOutliner.SetDrawPortionHdl(Link());
+ rOutliner.Clear();
+ rOutliner.setVisualizedPage(0);
+
+ // concatenate all results
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aRetvalA);
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(rTarget, aRetvalB);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotxat.cxx b/svx/source/svdraw/svdotxat.cxx
new file mode 100644
index 000000000000..12f47689bd57
--- /dev/null
+++ b/svx/source/svdraw/svdotxat.cxx
@@ -0,0 +1,464 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svl/style.hxx>
+#include <svx/svdotext.hxx>
+#include "svditext.hxx"
+#include <svx/svdmodel.hxx> // fuer GetMaxObjSize und GetStyleSheetPool
+#include <svx/svdoutl.hxx>
+#include <svx/svdorect.hxx> // fuer SetDirty bei NbcAdjustTextFrameWidthAndHeight
+#include <svx/svdocapt.hxx> // fuer SetDirty bei NbcAdjustTextFrameWidthAndHeight
+#include <svx/svdetc.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/sdtfchim.hxx>
+
+
+#include <editeng/editview.hxx>
+#include <svl/smplhint.hxx>
+#include <svl/whiter.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/fhgtitem.hxx>
+
+#include <editeng/charscaleitem.hxx>
+#include <svl/style.hxx>
+#include <svl/itemiter.hxx>
+#include <editeng/lrspitem.hxx>
+#include <svl/itempool.hxx>
+#include <editeng/numitem.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/postitem.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@@@ @@@ @@ @@ @@ @@@@@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
+//
+// Attribute, StyleSheets und AutoGrow
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrTextObj::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHgt, bool bWdt) const
+{
+ if (bTextFrame && pModel!=NULL && !rR.IsEmpty())
+ {
+ bool bFitToSize(IsFitToSize());
+ bool bWdtGrow=bWdt && IsAutoGrowWidth();
+ bool bHgtGrow=bHgt && IsAutoGrowHeight();
+ SdrTextAniKind eAniKind=GetTextAniKind();
+ SdrTextAniDirection eAniDir=GetTextAniDirection();
+ bool bScroll=eAniKind==SDRTEXTANI_SCROLL || eAniKind==SDRTEXTANI_ALTERNATE || eAniKind==SDRTEXTANI_SLIDE;
+ bool bHScroll=bScroll && (eAniDir==SDRTEXTANI_LEFT || eAniDir==SDRTEXTANI_RIGHT);
+ bool bVScroll=bScroll && (eAniDir==SDRTEXTANI_UP || eAniDir==SDRTEXTANI_DOWN);
+ if (!bFitToSize && (bWdtGrow || bHgtGrow))
+ {
+ Rectangle aR0(rR);
+ long nHgt=0,nMinHgt=0,nMaxHgt=0;
+ long nWdt=0,nMinWdt=0,nMaxWdt=0;
+ Size aSiz(rR.GetSize()); aSiz.Width()--; aSiz.Height()--;
+ Size aMaxSiz(100000,100000);
+ Size aTmpSiz(pModel->GetMaxObjSize());
+ if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width();
+ if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height();
+ if (bWdtGrow)
+ {
+ nMinWdt=GetMinTextFrameWidth();
+ nMaxWdt=GetMaxTextFrameWidth();
+ if (nMaxWdt==0 || nMaxWdt>aMaxSiz.Width()) nMaxWdt=aMaxSiz.Width();
+ if (nMinWdt<=0) nMinWdt=1;
+ aSiz.Width()=nMaxWdt;
+ }
+ if (bHgtGrow)
+ {
+ nMinHgt=GetMinTextFrameHeight();
+ nMaxHgt=GetMaxTextFrameHeight();
+ if (nMaxHgt==0 || nMaxHgt>aMaxSiz.Height()) nMaxHgt=aMaxSiz.Height();
+ if (nMinHgt<=0) nMinHgt=1;
+ aSiz.Height()=nMaxHgt;
+ }
+ long nHDist=GetTextLeftDistance()+GetTextRightDistance();
+ long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
+ aSiz.Width()-=nHDist;
+ aSiz.Height()-=nVDist;
+ if (aSiz.Width()<2) aSiz.Width()=2; // Mindestgroesse 2
+ if (aSiz.Height()<2) aSiz.Height()=2; // Mindestgroesse 2
+
+ // #101684#
+ BOOL bInEditMode = IsInEditMode();
+
+ if(!bInEditMode)
+ {
+ if (bHScroll) aSiz.Width()=0x0FFFFFFF; // Laufschrift nicht umbrechen
+ if (bVScroll) aSiz.Height()=0x0FFFFFFF;
+ }
+
+ if(pEdtOutl)
+ {
+ pEdtOutl->SetMaxAutoPaperSize(aSiz);
+ if (bWdtGrow) {
+ Size aSiz2(pEdtOutl->CalcTextSize());
+ nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz
+ if (bHgtGrow) nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz
+ } else {
+ nHgt=pEdtOutl->GetTextHeight()+1; // lieber etwas Tolleranz
+ }
+ } else {
+ Outliner& rOutliner=ImpGetDrawOutliner();
+ rOutliner.SetPaperSize(aSiz);
+ rOutliner.SetUpdateMode(TRUE);
+ // !!! hier sollte ich wohl auch noch mal die Optimierung mit
+ // bPortionInfoChecked usw einbauen
+ OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+ if ( pOutlinerParaObject != NULL )
+ {
+ rOutliner.SetText(*pOutlinerParaObject);
+ rOutliner.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
+ }
+ if (bWdtGrow)
+ {
+ Size aSiz2(rOutliner.CalcTextSize());
+ nWdt=aSiz2.Width()+1; // lieber etwas Tolleranz
+ if (bHgtGrow) nHgt=aSiz2.Height()+1; // lieber etwas Tolleranz
+ } else {
+ nHgt=rOutliner.GetTextHeight()+1; // lieber etwas Tolleranz
+ }
+ rOutliner.Clear();
+ }
+ if (nWdt<nMinWdt) nWdt=nMinWdt;
+ if (nWdt>nMaxWdt) nWdt=nMaxWdt;
+ nWdt+=nHDist;
+ if (nWdt<1) nWdt=1; // nHDist kann auch negativ sein
+ if (nHgt<nMinHgt) nHgt=nMinHgt;
+ if (nHgt>nMaxHgt) nHgt=nMaxHgt;
+ nHgt+=nVDist;
+ if (nHgt<1) nHgt=1; // nVDist kann auch negativ sein
+ long nWdtGrow=nWdt-(rR.Right()-rR.Left());
+ long nHgtGrow=nHgt-(rR.Bottom()-rR.Top());
+ if (nWdtGrow==0) bWdtGrow=FALSE;
+ if (nHgtGrow==0) bHgtGrow=FALSE;
+ if (bWdtGrow || bHgtGrow) {
+ if (bWdtGrow) {
+ SdrTextHorzAdjust eHAdj=GetTextHorizontalAdjust();
+ if (eHAdj==SDRTEXTHORZADJUST_LEFT) rR.Right()+=nWdtGrow;
+ else if (eHAdj==SDRTEXTHORZADJUST_RIGHT) rR.Left()-=nWdtGrow;
+ else {
+ long nWdtGrow2=nWdtGrow/2;
+ rR.Left()-=nWdtGrow2;
+ rR.Right()=rR.Left()+nWdt;
+ }
+ }
+ if (bHgtGrow) {
+ SdrTextVertAdjust eVAdj=GetTextVerticalAdjust();
+ if (eVAdj==SDRTEXTVERTADJUST_TOP) rR.Bottom()+=nHgtGrow;
+ else if (eVAdj==SDRTEXTVERTADJUST_BOTTOM) rR.Top()-=nHgtGrow;
+ else {
+ long nHgtGrow2=nHgtGrow/2;
+ rR.Top()-=nHgtGrow2;
+ rR.Bottom()=rR.Top()+nHgt;
+ }
+ }
+ if (aGeo.nDrehWink!=0) {
+ Point aD1(rR.TopLeft());
+ aD1-=aR0.TopLeft();
+ Point aD2(aD1);
+ RotatePoint(aD2,Point(),aGeo.nSin,aGeo.nCos);
+ aD2-=aD1;
+ rR.Move(aD2.X(),aD2.Y());
+ }
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+bool SdrTextObj::NbcAdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt)
+{
+ bool bRet=AdjustTextFrameWidthAndHeight(aRect,bHgt,bWdt);
+ if (bRet) {
+ SetRectsDirty();
+ if (HAS_BASE(SdrRectObj,this)) { // mal wieder 'nen Hack
+ ((SdrRectObj*)this)->SetXPolyDirty();
+ }
+ if (HAS_BASE(SdrCaptionObj,this)) { // mal wieder 'nen Hack
+ ((SdrCaptionObj*)this)->ImpRecalcTail();
+ }
+ }
+ return bRet;
+}
+
+bool SdrTextObj::AdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt)
+{
+ Rectangle aNeuRect(aRect);
+ bool bRet=AdjustTextFrameWidthAndHeight(aNeuRect,bHgt,bWdt);
+ if (bRet) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ aRect=aNeuRect;
+ SetRectsDirty();
+ if (HAS_BASE(SdrRectObj,this)) { // mal wieder 'nen Hack
+ ((SdrRectObj*)this)->SetXPolyDirty();
+ }
+ if (HAS_BASE(SdrCaptionObj,this)) { // mal wieder 'nen Hack
+ ((SdrCaptionObj*)this)->ImpRecalcTail();
+ }
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+ return bRet;
+}
+
+void SdrTextObj::ImpSetTextStyleSheetListeners()
+{
+ SfxStyleSheetBasePool* pStylePool=pModel!=NULL ? pModel->GetStyleSheetPool() : NULL;
+ if (pStylePool!=NULL)
+ {
+ Container aStyles(1024,64,64);
+ OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+ if (pOutlinerParaObject!=NULL)
+ {
+ // Zunaechst werden alle im ParaObject enthaltenen StyleSheets
+ // im Container aStyles gesammelt. Dazu wird die Family jeweils
+ // ans Ende des StyleSheet-Namen drangehaengt.
+ const EditTextObject& rTextObj=pOutlinerParaObject->GetTextObject();
+ XubString aStyleName;
+ SfxStyleFamily eStyleFam;
+ USHORT nParaAnz=rTextObj.GetParagraphCount();
+
+ for(UINT16 nParaNum(0); nParaNum < nParaAnz; nParaNum++)
+ {
+ rTextObj.GetStyleSheet(nParaNum, aStyleName, eStyleFam);
+
+ if(aStyleName.Len())
+ {
+ XubString aFam = UniString::CreateFromInt32((UINT16)eStyleFam);
+ aFam.Expand(5);
+
+ aStyleName += sal_Unicode('|');
+ aStyleName += aFam;
+
+ BOOL bFnd(FALSE);
+ UINT32 nNum(aStyles.Count());
+
+ while(!bFnd && nNum > 0)
+ {
+ // kein StyleSheet doppelt!
+ nNum--;
+ bFnd = (aStyleName.Equals(*(XubString*)aStyles.GetObject(nNum)));
+ }
+
+ if(!bFnd)
+ {
+ aStyles.Insert(new XubString(aStyleName), CONTAINER_APPEND);
+ }
+ }
+ }
+ }
+
+ // nun die Strings im Container durch StyleSheet* ersetzten
+ ULONG nNum=aStyles.Count();
+ while (nNum>0) {
+ nNum--;
+ XubString* pName=(XubString*)aStyles.GetObject(nNum);
+
+ // UNICODE: String aFam(pName->Cut(pName->Len()-6));
+ String aFam = pName->Copy(0, pName->Len() - 6);
+
+ aFam.Erase(0,1);
+ aFam.EraseTrailingChars();
+
+ // UNICODE: USHORT nFam=USHORT(aFam);
+ UINT16 nFam = (UINT16)aFam.ToInt32();
+
+ SfxStyleFamily eFam=(SfxStyleFamily)nFam;
+ SfxStyleSheetBase* pStyleBase=pStylePool->Find(*pName,eFam);
+ SfxStyleSheet* pStyle=PTR_CAST(SfxStyleSheet,pStyleBase);
+ delete pName;
+ if (pStyle!=NULL && pStyle!=GetStyleSheet()) {
+ aStyles.Replace(pStyle,nNum);
+ } else {
+ aStyles.Remove(nNum);
+ }
+ }
+ // jetzt alle ueberfluessigen StyleSheets entfernen
+ nNum=GetBroadcasterCount();
+ while (nNum>0) {
+ nNum--;
+ SfxBroadcaster* pBroadcast=GetBroadcasterJOE((USHORT)nNum);
+ SfxStyleSheet* pStyle=PTR_CAST(SfxStyleSheet,pBroadcast);
+ if (pStyle!=NULL && pStyle!=GetStyleSheet()) { // Sonderbehandlung fuer den StyleSheet des Objekts
+ if (aStyles.GetPos(pStyle)==CONTAINER_ENTRY_NOTFOUND) {
+ EndListening(*pStyle);
+ }
+ }
+ }
+ // und schliesslich alle in aStyles enthaltenen StyleSheets mit den vorhandenen Broadcastern mergen
+ nNum=aStyles.Count();
+ while (nNum>0) {
+ nNum--;
+ SfxStyleSheet* pStyle=(SfxStyleSheet*)aStyles.GetObject(nNum);
+ // StartListening soll selbst nachsehen, ob hier nicht evtl. schon gehorcht wird
+ StartListening(*pStyle,TRUE);
+ }
+ }
+}
+
+void SdrTextObj::NbcResizeTextAttributes(const Fraction& xFact, const Fraction& yFact)
+{
+ OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+ if (pOutlinerParaObject!=NULL && xFact.IsValid() && yFact.IsValid())
+ {
+ Fraction n100(100,1);
+ long nX=long(xFact*n100);
+ long nY=long(yFact*n100);
+ if (nX<0) nX=-nX;
+ if (nX<1) nX=1;
+ if (nX>0xFFFF) nX=0xFFFF;
+ if (nY<0) nY=-nY;
+ if (nY<1) nY=1;
+ if (nY>0xFFFF) nY=0xFFFF;
+ if (nX!=100 || nY!=100)
+ {
+ // Rahmenattribute
+ const SfxItemSet& rSet = GetObjectItemSet();
+ const SvxCharScaleWidthItem& rOldWdt=(SvxCharScaleWidthItem&)rSet.Get(EE_CHAR_FONTWIDTH);
+ const SvxFontHeightItem& rOldHgt=(SvxFontHeightItem&)rSet.Get(EE_CHAR_FONTHEIGHT);
+
+ // erstmal die alten Werte holen
+ long nRelWdt=rOldWdt.GetValue();
+ long nAbsHgt=rOldHgt.GetHeight();
+ long nRelHgt=rOldHgt.GetProp();
+
+ // Relative Breite aendern
+ nRelWdt*=nX;
+ nRelWdt/=nY;
+ if (nRelWdt<0) nRelWdt=-nRelWdt; // nicht negativ
+ if (nRelWdt<=0) nRelWdt=1; // und mind. 1%
+ if (nRelWdt>0xFFFF) nRelWdt=0xFFFF;
+
+ // Absolute Hoehe aendern
+ nAbsHgt*=nY;
+ nAbsHgt/=100;
+ if (nAbsHgt<0) nAbsHgt=-nAbsHgt; // nicht negativ
+ if (nAbsHgt<=0) nAbsHgt=1; // und mind. 1
+ if (nAbsHgt>0xFFFF) nAbsHgt=0xFFFF;
+
+ // und nun attributieren
+ SetObjectItem(SvxCharScaleWidthItem( (USHORT) nRelWdt, EE_CHAR_FONTWIDTH));
+ SetObjectItem(SvxFontHeightItem(nAbsHgt,(USHORT)nRelHgt, EE_CHAR_FONTHEIGHT));
+ // Zeichen- und Absatzattribute innerhalb des OutlinerParaObjects
+ Outliner& rOutliner=ImpGetDrawOutliner();
+ rOutliner.SetPaperSize(Size(LONG_MAX,LONG_MAX));
+ rOutliner.SetText(*pOutlinerParaObject);
+ rOutliner.DoStretchChars((USHORT)nX,(USHORT)nY);
+ OutlinerParaObject* pNewPara=rOutliner.CreateParaObject();
+ NbcSetOutlinerParaObject(pNewPara);
+ rOutliner.Clear();
+ }
+ }
+}
+
+/** #103836# iterates over the paragraphs of a given SdrObject and removes all
+ hard set character attributes with the which ids contained in the
+ given vector
+*/
+void SdrTextObj::RemoveOutlinerCharacterAttribs( const std::vector<sal_uInt16>& rCharWhichIds )
+{
+ sal_Int32 nText = getTextCount();
+
+ while( --nText >= 0 )
+ {
+ SdrText* pText = getText( nText );
+ OutlinerParaObject* pOutlinerParaObject = pText ? pText->GetOutlinerParaObject() : 0;
+
+ if(pOutlinerParaObject)
+ {
+ Outliner* pOutliner = 0;
+
+ if( pEdtOutl || (pText == getActiveText()) )
+ pOutliner = pEdtOutl;
+
+ if(!pOutliner)
+ {
+ pOutliner = &ImpGetDrawOutliner();
+ pOutliner->SetText(*pOutlinerParaObject);
+ }
+
+ ESelection aSelAll( 0, 0, 0xffff, 0xffff );
+ std::vector<sal_uInt16>::const_iterator aIter( rCharWhichIds.begin() );
+ while( aIter != rCharWhichIds.end() )
+ {
+ pOutliner->RemoveAttribs( aSelAll, false, (*aIter++) );
+ }
+
+ if(!pEdtOutl || (pText != getActiveText()) )
+ {
+ const sal_uInt32 nParaCount = pOutliner->GetParagraphCount();
+ OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount);
+ pOutliner->Clear();
+ NbcSetOutlinerParaObjectForText(pTemp, pText);
+ }
+ }
+ }
+}
+
+bool SdrTextObj::HasText() const
+{
+ if( pEdtOutl )
+ return HasEditText();
+
+ OutlinerParaObject* pOPO = GetOutlinerParaObject();
+
+ bool bHasText = false;
+ if( pOPO )
+ {
+ const EditTextObject& rETO = pOPO->GetTextObject();
+ USHORT nParaCount = rETO.GetParagraphCount();
+
+ if( nParaCount > 0 )
+ bHasText = (nParaCount > 1) || (rETO.GetText( 0 ).Len() != 0);
+ }
+
+ return bHasText;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotxdr.cxx b/svx/source/svdraw/svdotxdr.cxx
new file mode 100644
index 000000000000..76ebf0c19e99
--- /dev/null
+++ b/svx/source/svdraw/svdotxdr.cxx
@@ -0,0 +1,287 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdotext.hxx>
+#include <svx/svdhdl.hxx>
+#include <svx/svddrag.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdorect.hxx> // fuer SetXPolyDirty in MovCreate bei SolidDragging
+#include "svdglob.hxx" // Stringcache
+#include "svdstr.hrc" // Objektname
+#include <svx/svdoashp.hxx>
+#include <tools/bigint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@@@ @@@ @@ @@ @@ @@@@@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
+//
+// Dragging, Handles, Create
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_uInt32 SdrTextObj::GetHdlCount() const
+{
+ return 8L;
+}
+
+SdrHdl* SdrTextObj::GetHdl(sal_uInt32 nHdlNum) const
+{
+ SdrHdl* pH=NULL;
+ Point aPnt;
+ SdrHdlKind eKind=HDL_MOVE;
+ switch (nHdlNum) {
+ case 0: aPnt=aRect.TopLeft(); eKind=HDL_UPLFT; break; // Oben links
+ case 1: aPnt=aRect.TopCenter(); eKind=HDL_UPPER; break; // Oben
+ case 2: aPnt=aRect.TopRight(); eKind=HDL_UPRGT; break; // Oben rechts
+ case 3: aPnt=aRect.LeftCenter(); eKind=HDL_LEFT ; break; // Links
+ case 4: aPnt=aRect.RightCenter(); eKind=HDL_RIGHT; break; // Rechts
+ case 5: aPnt=aRect.BottomLeft(); eKind=HDL_LWLFT; break; // Unten links
+ case 6: aPnt=aRect.BottomCenter(); eKind=HDL_LOWER; break; // Unten
+ case 7: aPnt=aRect.BottomRight(); eKind=HDL_LWRGT; break; // Unten rechts
+ }
+ if (aGeo.nShearWink!=0) ShearPoint(aPnt,aRect.TopLeft(),aGeo.nTan);
+ if (aGeo.nDrehWink!=0) RotatePoint(aPnt,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+ if (eKind!=HDL_MOVE) {
+ pH=new SdrHdl(aPnt,eKind);
+ pH->SetObj((SdrObject*)this);
+ pH->SetDrehWink(aGeo.nDrehWink);
+ }
+ return pH;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrTextObj::hasSpecialDrag() const
+{
+ return true;
+}
+
+Rectangle SdrTextObj::ImpDragCalcRect(const SdrDragStat& rDrag) const
+{
+ Rectangle aTmpRect(aRect);
+ const SdrHdl* pHdl=rDrag.GetHdl();
+ SdrHdlKind eHdl=pHdl==NULL ? HDL_MOVE : pHdl->GetKind();
+ bool bEcke=(eHdl==HDL_UPLFT || eHdl==HDL_UPRGT || eHdl==HDL_LWLFT || eHdl==HDL_LWRGT);
+ bool bOrtho=rDrag.GetView()!=NULL && rDrag.GetView()->IsOrtho();
+ bool bBigOrtho=bEcke && bOrtho && rDrag.GetView()->IsBigOrtho();
+ Point aPos(rDrag.GetNow());
+ // Unrotate:
+ if (aGeo.nDrehWink!=0) RotatePoint(aPos,aTmpRect.TopLeft(),-aGeo.nSin,aGeo.nCos);
+ // Unshear:
+ if (aGeo.nShearWink!=0) ShearPoint(aPos,aTmpRect.TopLeft(),-aGeo.nTan);
+ //
+ bool bLft=(eHdl==HDL_UPLFT || eHdl==HDL_LEFT || eHdl==HDL_LWLFT);
+ bool bRgt=(eHdl==HDL_UPRGT || eHdl==HDL_RIGHT || eHdl==HDL_LWRGT);
+ bool bTop=(eHdl==HDL_UPRGT || eHdl==HDL_UPPER || eHdl==HDL_UPLFT);
+ bool bBtm=(eHdl==HDL_LWRGT || eHdl==HDL_LOWER || eHdl==HDL_LWLFT);
+ if (bLft) aTmpRect.Left() =aPos.X();
+ if (bRgt) aTmpRect.Right() =aPos.X();
+ if (bTop) aTmpRect.Top() =aPos.Y();
+ if (bBtm) aTmpRect.Bottom()=aPos.Y();
+ if (bOrtho) { // Ortho
+ long nWdt0=aRect.Right() -aRect.Left();
+ long nHgt0=aRect.Bottom()-aRect.Top();
+ long nXMul=aTmpRect.Right() -aTmpRect.Left();
+ long nYMul=aTmpRect.Bottom()-aTmpRect.Top();
+ long nXDiv=nWdt0;
+ long nYDiv=nHgt0;
+ bool bXNeg=(nXMul<0)!=(nXDiv<0);
+ bool bYNeg=(nYMul<0)!=(nYDiv<0);
+ nXMul=Abs(nXMul);
+ nYMul=Abs(nYMul);
+ nXDiv=Abs(nXDiv);
+ nYDiv=Abs(nYDiv);
+ Fraction aXFact(nXMul,nXDiv); // Fractions zum kuerzen
+ Fraction aYFact(nYMul,nYDiv); // und zum vergleichen
+ nXMul=aXFact.GetNumerator();
+ nYMul=aYFact.GetNumerator();
+ nXDiv=aXFact.GetDenominator();
+ nYDiv=aYFact.GetDenominator();
+ if (bEcke) { // Eckpunkthandles
+ bool bUseX=(aXFact<aYFact) != bBigOrtho;
+ if (bUseX) {
+ long nNeed=long(BigInt(nHgt0)*BigInt(nXMul)/BigInt(nXDiv));
+ if (bYNeg) nNeed=-nNeed;
+ if (bTop) aTmpRect.Top()=aTmpRect.Bottom()-nNeed;
+ if (bBtm) aTmpRect.Bottom()=aTmpRect.Top()+nNeed;
+ } else {
+ long nNeed=long(BigInt(nWdt0)*BigInt(nYMul)/BigInt(nYDiv));
+ if (bXNeg) nNeed=-nNeed;
+ if (bLft) aTmpRect.Left()=aTmpRect.Right()-nNeed;
+ if (bRgt) aTmpRect.Right()=aTmpRect.Left()+nNeed;
+ }
+ } else { // Scheitelpunkthandles
+ if ((bLft || bRgt) && nXDiv!=0) {
+ long nHgt0b=aRect.Bottom()-aRect.Top();
+ long nNeed=long(BigInt(nHgt0b)*BigInt(nXMul)/BigInt(nXDiv));
+ aTmpRect.Top()-=(nNeed-nHgt0b)/2;
+ aTmpRect.Bottom()=aTmpRect.Top()+nNeed;
+ }
+ if ((bTop || bBtm) && nYDiv!=0) {
+ long nWdt0b=aRect.Right()-aRect.Left();
+ long nNeed=long(BigInt(nWdt0b)*BigInt(nYMul)/BigInt(nYDiv));
+ aTmpRect.Left()-=(nNeed-nWdt0b)/2;
+ aTmpRect.Right()=aTmpRect.Left()+nNeed;
+ }
+ }
+ }
+ if (!ISA(SdrObjCustomShape)) // not justifying for CustomShapes to be able to detect if a shape has to be mirrored
+ ImpJustifyRect(aTmpRect);
+ return aTmpRect;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// drag
+
+bool SdrTextObj::applySpecialDrag(SdrDragStat& rDrag)
+{
+ Rectangle aNewRect(ImpDragCalcRect(rDrag));
+
+ if(aNewRect.TopLeft() != aRect.TopLeft() && (aGeo.nDrehWink || aGeo.nShearWink))
+ {
+ Point aNewPos(aNewRect.TopLeft());
+
+ if(aGeo.nShearWink)
+ ShearPoint(aNewPos,aRect.TopLeft(),aGeo.nTan);
+
+ if(aGeo.nDrehWink)
+ RotatePoint(aNewPos,aRect.TopLeft(),aGeo.nSin,aGeo.nCos);
+
+ aNewRect.SetPos(aNewPos);
+ }
+
+ if(aNewRect != aRect)
+ {
+ NbcSetLogicRect(aNewRect);
+ }
+
+ return true;
+}
+
+String SdrTextObj::getSpecialDragComment(const SdrDragStat& /*rDrag*/) const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_DragRectResize,aStr);
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Create
+
+bool SdrTextObj::BegCreate(SdrDragStat& rStat)
+{
+ rStat.SetOrtho4Possible();
+ Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
+ aRect1.Justify();
+ rStat.SetActionRect(aRect1);
+ aRect = aRect1;
+ return true;
+}
+
+bool SdrTextObj::MovCreate(SdrDragStat& rStat)
+{
+ Rectangle aRect1;
+ rStat.TakeCreateRect(aRect1);
+ ImpJustifyRect(aRect1);
+ rStat.SetActionRect(aRect1);
+ aRect=aRect1; // fuer ObjName
+ SetBoundRectDirty();
+ bSnapRectDirty=TRUE;
+ if (HAS_BASE(SdrRectObj,this)) {
+ ((SdrRectObj*)this)->SetXPolyDirty();
+ }
+ return true;
+}
+
+bool SdrTextObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ rStat.TakeCreateRect(aRect);
+ ImpJustifyRect(aRect);
+ if (bTextFrame) {
+ if (IsAutoGrowHeight()) {
+ // MinTextHeight
+ long nHgt=aRect.GetHeight()-1;
+ if (nHgt==1) nHgt=0;
+ NbcSetMinTextFrameHeight(nHgt);
+ }
+ if (IsAutoGrowWidth()) {
+ // MinTextWidth
+ long nWdt=aRect.GetWidth()-1;
+ if (nWdt==1) nWdt=0;
+ NbcSetMinTextFrameWidth(nWdt);
+ }
+ // Textrahmen neu berechnen
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ SetRectsDirty();
+ if (HAS_BASE(SdrRectObj,this)) {
+ ((SdrRectObj*)this)->SetXPolyDirty();
+ }
+ return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
+}
+
+void SdrTextObj::BrkCreate(SdrDragStat& /*rStat*/)
+{
+}
+
+bool SdrTextObj::BckCreate(SdrDragStat& /*rStat*/)
+{
+ return true;
+}
+
+basegfx::B2DPolyPolygon SdrTextObj::TakeCreatePoly(const SdrDragStat& rDrag) const
+{
+ Rectangle aRect1;
+ rDrag.TakeCreateRect(aRect1);
+ aRect1.Justify();
+
+ basegfx::B2DPolyPolygon aRetval;
+ const basegfx::B2DRange aRange(aRect1.Left(), aRect1.Top(), aRect1.Right(), aRect1.Bottom());
+ aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
+ return aRetval;
+}
+
+Pointer SdrTextObj::GetCreatePointer() const
+{
+ if (IsTextFrame()) return Pointer(POINTER_DRAW_TEXT);
+ return Pointer(POINTER_CROSS);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotxed.cxx b/svx/source/svdraw/svdotxed.cxx
new file mode 100644
index 000000000000..e679d76bcaae
--- /dev/null
+++ b/svx/source/svdraw/svdotxed.cxx
@@ -0,0 +1,357 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdotext.hxx>
+#include "svditext.hxx"
+#include <svx/svdmodel.hxx> // fuer GetMaxObjSize
+#include <svx/svdoutl.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editstat.hxx>
+#include <svl/itemset.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/sdtfchim.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@@@ @@@ @@ @@ @@ @@@@@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
+//
+// TextEdit
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrTextObj::HasTextEdit() const
+{
+ // lt. Anweisung von MB duerfen gelinkte Textobjekte nun doch
+ // geaendert werden (kein automatisches Reload)
+ return true;
+}
+
+sal_Bool SdrTextObj::BegTextEdit(SdrOutliner& rOutl)
+{
+ if (pEdtOutl!=NULL) return sal_False; // Textedit laeuft evtl. schon an einer anderen View!
+ pEdtOutl=&rOutl;
+
+ // #101684#
+ mbInEditMode = TRUE;
+
+ USHORT nOutlinerMode = OUTLINERMODE_OUTLINEOBJECT;
+ if ( !IsOutlText() )
+ nOutlinerMode = OUTLINERMODE_TEXTOBJECT;
+ rOutl.Init( nOutlinerMode );
+ rOutl.SetRefDevice( pModel->GetRefDevice() );
+
+ bool bFitToSize(IsFitToSize());
+ bool bContourFrame=IsContourTextFrame();
+ ImpSetTextEditParams();
+
+ if (!bContourFrame) {
+ ULONG nStat=rOutl.GetControlWord();
+ nStat|=EE_CNTRL_AUTOPAGESIZE;
+ if (bFitToSize || IsAutoFit())
+ nStat|=EE_CNTRL_STRETCHING;
+ else
+ nStat&=~EE_CNTRL_STRETCHING;
+ rOutl.SetControlWord(nStat);
+ }
+
+ OutlinerParaObject* pOutlinerParaObject = GetOutlinerParaObject();
+ if(pOutlinerParaObject!=NULL)
+ {
+ rOutl.SetText(*GetOutlinerParaObject());
+ rOutl.SetFixedCellHeight(((const SdrTextFixedCellHeightItem&)GetMergedItem(SDRATTR_TEXT_USEFIXEDCELLHEIGHT)).GetValue());
+ }
+
+ // ggf. Rahmenattribute am 1. (neuen) Absatz des Outliners setzen
+ if( !HasTextImpl( &rOutl ) )
+ {
+ // Outliner has no text so we must set some
+ // empty text so the outliner initialise itself
+ rOutl.SetText( String(), rOutl.GetParagraph( 0 ) );
+
+ if(GetStyleSheet())
+ rOutl.SetStyleSheet( 0, GetStyleSheet());
+
+ // Beim setzen der harten Attribute an den ersten Absatz muss
+ // der Parent pOutlAttr (=die Vorlage) temporaer entfernt
+ // werden, da sonst bei SetParaAttribs() auch alle in diesem
+ // Parent enthaltenen Items hart am Absatz attributiert werden.
+ // -> BugID 22467
+ const SfxItemSet& rSet = GetObjectItemSet();
+ SfxItemSet aFilteredSet(*rSet.GetPool(), EE_ITEMS_START, EE_ITEMS_END);
+ aFilteredSet.Put(rSet);
+ rOutl.SetParaAttribs(0, aFilteredSet);
+ }
+ if (bFitToSize)
+ {
+ Rectangle aAnchorRect;
+ Rectangle aTextRect;
+ TakeTextRect(rOutl, aTextRect, FALSE,
+ &aAnchorRect/* #97097# give TRUE here, not FALSE */);
+ Fraction aFitXKorreg(1,1);
+ ImpSetCharStretching(rOutl,aTextRect.GetSize(),aAnchorRect.GetSize(),aFitXKorreg);
+ }
+ else if (IsAutoFit())
+ {
+ ImpAutoFitText(rOutl);
+ }
+
+ if(pOutlinerParaObject)
+ {
+ // #78476# also repaint when animated text is put to edit mode
+ // to not make appear the text double
+ // #111096# should now repaint automatically.
+ // BOOL bIsAnimated(pPlusData && pPlusData->pAnimator);
+
+ if(aGeo.nDrehWink || IsFontwork() /*|| bIsAnimated*/)
+ {
+ // only repaint here, no real objectchange
+
+// ActionChanged();
+ BroadcastObjectChange();
+ }
+ }
+
+ rOutl.UpdateFields();
+ rOutl.ClearModifyFlag();
+
+ return sal_True;
+}
+
+void SdrTextObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const
+{
+ bool bFitToSize(IsFitToSize());
+ Size aPaperMin,aPaperMax;
+ Rectangle aViewInit;
+ TakeTextAnchorRect(aViewInit);
+ if (aGeo.nDrehWink!=0) {
+ Point aCenter(aViewInit.Center());
+ aCenter-=aViewInit.TopLeft();
+ Point aCenter0(aCenter);
+ RotatePoint(aCenter,Point(),aGeo.nSin,aGeo.nCos);
+ aCenter-=aCenter0;
+ aViewInit.Move(aCenter.X(),aCenter.Y());
+ }
+ Size aAnkSiz(aViewInit.GetSize());
+ aAnkSiz.Width()--; aAnkSiz.Height()--; // weil GetSize() ein draufaddiert
+ Size aMaxSiz(1000000,1000000);
+ if (pModel!=NULL) {
+ Size aTmpSiz(pModel->GetMaxObjSize());
+ if (aTmpSiz.Width()!=0) aMaxSiz.Width()=aTmpSiz.Width();
+ if (aTmpSiz.Height()!=0) aMaxSiz.Height()=aTmpSiz.Height();
+ }
+
+ // #106879#
+ // Done earlier since used in else tree below
+ SdrTextHorzAdjust eHAdj(GetTextHorizontalAdjust());
+ SdrTextVertAdjust eVAdj(GetTextVerticalAdjust());
+
+ if(IsTextFrame())
+ {
+ long nMinWdt=GetMinTextFrameWidth();
+ long nMinHgt=GetMinTextFrameHeight();
+ long nMaxWdt=GetMaxTextFrameWidth();
+ long nMaxHgt=GetMaxTextFrameHeight();
+ if (nMinWdt<1) nMinWdt=1;
+ if (nMinHgt<1) nMinHgt=1;
+ if (!bFitToSize) {
+ if (nMaxWdt==0 || nMaxWdt>aMaxSiz.Width()) nMaxWdt=aMaxSiz.Width();
+ if (nMaxHgt==0 || nMaxHgt>aMaxSiz.Height()) nMaxHgt=aMaxSiz.Height();
+ if (!IsAutoGrowWidth() ) { nMaxWdt=aAnkSiz.Width(); nMinWdt=nMaxWdt; }
+ if (!IsAutoGrowHeight()) { nMaxHgt=aAnkSiz.Height(); nMinHgt=nMaxHgt; }
+ SdrTextAniKind eAniKind=GetTextAniKind();
+ SdrTextAniDirection eAniDirection=GetTextAniDirection();
+
+ // #101684#
+ BOOL bInEditMode = IsInEditMode();
+
+ if (!bInEditMode && (eAniKind==SDRTEXTANI_SCROLL || eAniKind==SDRTEXTANI_ALTERNATE || eAniKind==SDRTEXTANI_SLIDE))
+ {
+ // Grenzenlose Papiergroesse fuer Laufschrift
+ if (eAniDirection==SDRTEXTANI_LEFT || eAniDirection==SDRTEXTANI_RIGHT) nMaxWdt=1000000;
+ if (eAniDirection==SDRTEXTANI_UP || eAniDirection==SDRTEXTANI_DOWN) nMaxHgt=1000000;
+ }
+ aPaperMax.Width()=nMaxWdt;
+ aPaperMax.Height()=nMaxHgt;
+ } else {
+ aPaperMax=aMaxSiz;
+ }
+ aPaperMin.Width()=nMinWdt;
+ aPaperMin.Height()=nMinHgt;
+ }
+ else
+ {
+ // #106879#
+ // aPaperMin needs to be set to object's size if full width is activated
+ // for hor or ver writing respectively
+ if((SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
+ || (SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting()))
+ {
+ aPaperMin = aAnkSiz;
+ }
+
+ aPaperMax=aMaxSiz;
+ }
+
+ if (pViewMin!=NULL) {
+ *pViewMin=aViewInit;
+
+ long nXFree=aAnkSiz.Width()-aPaperMin.Width();
+ if (eHAdj==SDRTEXTHORZADJUST_LEFT) pViewMin->Right()-=nXFree;
+ else if (eHAdj==SDRTEXTHORZADJUST_RIGHT) pViewMin->Left()+=nXFree;
+ else { pViewMin->Left()+=nXFree/2; pViewMin->Right()=pViewMin->Left()+aPaperMin.Width(); }
+
+ long nYFree=aAnkSiz.Height()-aPaperMin.Height();
+ if (eVAdj==SDRTEXTVERTADJUST_TOP) pViewMin->Bottom()-=nYFree;
+ else if (eVAdj==SDRTEXTVERTADJUST_BOTTOM) pViewMin->Top()+=nYFree;
+ else { pViewMin->Top()+=nYFree/2; pViewMin->Bottom()=pViewMin->Top()+aPaperMin.Height(); }
+ }
+
+ // Die PaperSize soll in den meisten Faellen von selbst wachsen
+ // #89459#
+ if(IsVerticalWriting())
+ aPaperMin.Width() = 0;
+ else
+ aPaperMin.Height() = 0; // #33102#
+
+ if(eHAdj!=SDRTEXTHORZADJUST_BLOCK || bFitToSize) {
+ aPaperMin.Width()=0;
+ }
+
+ // #103516# For complete ver adjust support, set paper min height to 0, here.
+ if(SDRTEXTVERTADJUST_BLOCK != eVAdj || bFitToSize)
+ {
+ aPaperMin.Height() = 0;
+ }
+
+ if (pPaperMin!=NULL) *pPaperMin=aPaperMin;
+ if (pPaperMax!=NULL) *pPaperMax=aPaperMax;
+ if (pViewInit!=NULL) *pViewInit=aViewInit;
+}
+
+void SdrTextObj::EndTextEdit(SdrOutliner& rOutl)
+{
+ if(rOutl.IsModified())
+ {
+ OutlinerParaObject* pNewText = NULL;
+
+ if(HasTextImpl( &rOutl ) )
+ {
+ // Damit der grauen Feldhintergrund wieder verschwindet
+ rOutl.UpdateFields();
+
+ sal_uInt16 nParaAnz = static_cast< sal_uInt16 >( rOutl.GetParagraphCount() );
+ pNewText = rOutl.CreateParaObject( 0, nParaAnz );
+ }
+
+ // need to end edit mode early since SetOutlinerParaObject already
+ // uses GetCurrentBoundRect() which needs to take the text into account
+ // to work correct
+ mbInEditMode = FALSE;
+ SetOutlinerParaObject(pNewText);
+ }
+
+ pEdtOutl = NULL;
+ rOutl.Clear();
+ UINT32 nStat = rOutl.GetControlWord();
+ nStat &= ~EE_CNTRL_AUTOPAGESIZE;
+ rOutl.SetControlWord(nStat);
+
+ // #101684#
+ mbInEditMode = FALSE;
+}
+
+USHORT SdrTextObj::GetOutlinerViewAnchorMode() const
+{
+ SdrTextHorzAdjust eH=GetTextHorizontalAdjust();
+ SdrTextVertAdjust eV=GetTextVerticalAdjust();
+ EVAnchorMode eRet=ANCHOR_TOP_LEFT;
+ if (IsContourTextFrame()) return (USHORT)eRet;
+ if (eH==SDRTEXTHORZADJUST_LEFT) {
+ if (eV==SDRTEXTVERTADJUST_TOP) {
+ eRet=ANCHOR_TOP_LEFT;
+ } else if (eV==SDRTEXTVERTADJUST_BOTTOM) {
+ eRet=ANCHOR_BOTTOM_LEFT;
+ } else {
+ eRet=ANCHOR_VCENTER_LEFT;
+ }
+ } else if (eH==SDRTEXTHORZADJUST_RIGHT) {
+ if (eV==SDRTEXTVERTADJUST_TOP) {
+ eRet=ANCHOR_TOP_RIGHT;
+ } else if (eV==SDRTEXTVERTADJUST_BOTTOM) {
+ eRet=ANCHOR_BOTTOM_RIGHT;
+ } else {
+ eRet=ANCHOR_VCENTER_RIGHT;
+ }
+ } else {
+ if (eV==SDRTEXTVERTADJUST_TOP) {
+ eRet=ANCHOR_TOP_HCENTER;
+ } else if (eV==SDRTEXTVERTADJUST_BOTTOM) {
+ eRet=ANCHOR_BOTTOM_HCENTER;
+ } else {
+ eRet=ANCHOR_VCENTER_HCENTER;
+ }
+ }
+ return (USHORT)eRet;
+}
+
+void SdrTextObj::ImpSetTextEditParams() const
+{
+ if (pEdtOutl!=NULL) {
+ bool bUpdMerk=pEdtOutl->GetUpdateMode();
+ if (bUpdMerk) pEdtOutl->SetUpdateMode(FALSE);
+ Size aPaperMin;
+ Size aPaperMax;
+ Rectangle aEditArea;
+ TakeTextEditArea(&aPaperMin,&aPaperMax,&aEditArea,NULL);
+ //SdrFitToSizeType eFit=GetFitToSize();
+ //bool bFitToSize=(eFit==SDRTEXTFIT_PROPORTIONAL || eFit==SDRTEXTFIT_ALLLINES);
+ bool bContourFrame=IsContourTextFrame();
+ //EVAnchorMode eAM=(EVAnchorMode)GetOutlinerViewAnchorMode();
+ //ULONG nViewAnz=pEdtOutl->GetViewCount();
+ pEdtOutl->SetMinAutoPaperSize(aPaperMin);
+ pEdtOutl->SetMaxAutoPaperSize(aPaperMax);
+ pEdtOutl->SetPaperSize(Size());
+ if (bContourFrame) {
+ Rectangle aAnchorRect;
+ TakeTextAnchorRect(aAnchorRect);
+ ImpSetContourPolygon(*pEdtOutl,aAnchorRect, TRUE);
+ }
+ if (bUpdMerk) pEdtOutl->SetUpdateMode(TRUE);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotxfl.cxx b/svx/source/svdraw/svdotxfl.cxx
new file mode 100644
index 000000000000..2cba5d849d8e
--- /dev/null
+++ b/svx/source/svdraw/svdotxfl.cxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <editeng/measfld.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdfield.hxx>
+
+static BOOL bInit = FALSE;
+
+// Do not remove this, it is still used in src536a!
+void SdrRegisterFieldClasses()
+{
+ if ( !bInit )
+ {
+ SvxFieldItem::GetClassManager().SV_CLASS_REGISTER(SdrMeasureField);
+ SvxFieldItem::GetClassManager().SV_CLASS_REGISTER(SvxHeaderField);
+ SvxFieldItem::GetClassManager().SV_CLASS_REGISTER(SvxFooterField);
+ SvxFieldItem::GetClassManager().SV_CLASS_REGISTER(SvxDateTimeField);
+ bInit = TRUE;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////// */
+
+bool SdrTextObj::CalcFieldValue(const SvxFieldItem& /*rField*/, USHORT /*nPara*/, USHORT /*nPos*/,
+ bool /*bEdit*/, Color*& /*rpTxtColor*/, Color*& /*rpFldColor*/, XubString& /*rRet*/) const
+{
+ return FALSE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotxln.cxx b/svx/source/svdraw/svdotxln.cxx
new file mode 100644
index 000000000000..a59d31bf99a7
--- /dev/null
+++ b/svx/source/svdraw/svdotxln.cxx
@@ -0,0 +1,352 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <ucbhelper/content.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <unotools/datetime.hxx>
+#include <svx/svdotext.hxx>
+#include "svditext.hxx"
+#include <svx/svdmodel.hxx>
+#include <editeng/editdata.hxx>
+#include <sfx2/lnkbase.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <tools/urlobj.hxx>
+#include <svl/urihelper.hxx>
+
+// #90477#
+#include <tools/tenccvt.hxx>
+
+#ifndef SVX_LIGHT
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@ @@@@@ @@@@@@ @@@@@@ @@@@@@ @@ @@ @@@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@@@ @@ @@ @@ @@@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@ @@@@@ @@ @@ @@ @@ @@@@@@ @@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@@@ @@ @@ @@ @@ @@@ @@ @@
+// @@@@ @@@@@ @@@@ @@ @@@@@@ @@ @@ @@ @@@@@ @@ @@ @@ @@ @@
+//
+// ImpSdrObjTextLink zur Verbindung von SdrTextObj und LinkManager
+//
+// Einem solchen Link merke ich mir als SdrObjUserData am Objekt. Im Gegensatz
+// zum Grafik-Link werden die ObjektDaten jedoch kopiert (fuer Paint, etc.).
+// Die Information ob das Objekt ein Link ist besteht genau darin, dass dem
+// Objekt ein entsprechender UserData-Record angehaengt ist oder nicht.
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ImpSdrObjTextLink: public ::sfx2::SvBaseLink
+{
+ SdrTextObj* pSdrObj;
+
+public:
+ ImpSdrObjTextLink( SdrTextObj* pObj1 )
+ : ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, FORMAT_FILE ),
+ pSdrObj( pObj1 )
+ {}
+ virtual ~ImpSdrObjTextLink();
+
+ virtual void Closed();
+ virtual void DataChanged( const String& rMimeType,
+ const ::com::sun::star::uno::Any & rValue );
+
+ BOOL Connect() { return 0 != SvBaseLink::GetRealObject(); }
+};
+
+ImpSdrObjTextLink::~ImpSdrObjTextLink()
+{
+}
+
+void ImpSdrObjTextLink::Closed()
+{
+ if (pSdrObj )
+ {
+ // pLink des Objekts auf NULL setzen, da die Link-Instanz ja gerade destruiert wird.
+ ImpSdrObjTextLinkUserData* pData=pSdrObj->GetLinkUserData();
+ if (pData!=NULL) pData->pLink=NULL;
+ pSdrObj->ReleaseTextLink();
+ }
+ SvBaseLink::Closed();
+}
+
+
+void ImpSdrObjTextLink::DataChanged( const String& /*rMimeType*/,
+ const ::com::sun::star::uno::Any & /*rValue */)
+{
+ bool bForceReload = false;
+ SdrModel* pModel = pSdrObj ? pSdrObj->GetModel() : 0;
+ sfx2::LinkManager* pLinkManager= pModel ? pModel->GetLinkManager() : 0;
+ if( pLinkManager )
+ {
+ ImpSdrObjTextLinkUserData* pData=pSdrObj->GetLinkUserData();
+ if( pData )
+ {
+ String aFile;
+ String aFilter;
+ pLinkManager->GetDisplayNames( this, 0,&aFile, 0, &aFilter );
+
+ if( !pData->aFileName.Equals( aFile ) ||
+ !pData->aFilterName.Equals( aFilter ))
+ {
+ pData->aFileName = aFile;
+ pData->aFilterName = aFilter;
+ pSdrObj->SetChanged();
+ bForceReload = true;
+ }
+ }
+ }
+ if (pSdrObj )
+ pSdrObj->ReloadLinkedText( bForceReload );
+}
+#endif // SVX_LIGHT
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@ @@ @@ @@ @@ @@ @@ @@ @@@@@ @@@@@@ @@@@@ @@@@@ @@@@ @@@@@@ @@@@
+// @@ @@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@@ @@@@ @@ @@ @@@@ @@@@@ @@@@@ @@ @@ @@@@@@ @@ @@@@@@
+// @@ @@ @@ @@@ @@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@@ @@ @@ @@ @@ @@ @@@@ @@@@@ @@@@@@ @@ @@ @@@@@ @@ @@ @@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(ImpSdrObjTextLinkUserData,SdrObjUserData);
+
+ImpSdrObjTextLinkUserData::ImpSdrObjTextLinkUserData(SdrTextObj* pObj1):
+ SdrObjUserData(SdrInventor,SDRUSERDATA_OBJTEXTLINK,0),
+ pObj(pObj1),
+ pLink(NULL),
+ eCharSet(RTL_TEXTENCODING_DONTKNOW)
+{
+}
+
+ImpSdrObjTextLinkUserData::~ImpSdrObjTextLinkUserData()
+{
+#ifndef SVX_LIGHT
+ delete pLink;
+#endif
+}
+
+SdrObjUserData* ImpSdrObjTextLinkUserData::Clone(SdrObject* pObj1) const
+{
+ ImpSdrObjTextLinkUserData* pData=new ImpSdrObjTextLinkUserData((SdrTextObj*)pObj1);
+ pData->aFileName =aFileName;
+ pData->aFilterName=aFilterName;
+ pData->aFileDate0 =aFileDate0;
+ pData->eCharSet =eCharSet;
+ pData->pLink=NULL;
+ return pData;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@@@ @@@ @@ @@ @@ @@@@@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrTextObj::SetTextLink(const String& rFileName, const String& rFilterName, rtl_TextEncoding eCharSet)
+{
+ if(eCharSet == RTL_TEXTENCODING_DONTKNOW)
+ eCharSet = gsl_getSystemTextEncoding();
+
+ ImpSdrObjTextLinkUserData* pData=GetLinkUserData();
+ if (pData!=NULL) {
+ ReleaseTextLink();
+ }
+ pData=new ImpSdrObjTextLinkUserData(this);
+ pData->aFileName=rFileName;
+ pData->aFilterName=rFilterName;
+ pData->eCharSet=eCharSet;
+ InsertUserData(pData);
+ ImpLinkAnmeldung();
+}
+
+void SdrTextObj::ReleaseTextLink()
+{
+ ImpLinkAbmeldung();
+ USHORT nAnz=GetUserDataCount();
+ for (USHORT nNum=nAnz; nNum>0;) {
+ nNum--;
+ SdrObjUserData* pData=GetUserData(nNum);
+ if (pData->GetInventor()==SdrInventor && pData->GetId()==SDRUSERDATA_OBJTEXTLINK) {
+ DeleteUserData(nNum);
+ }
+ }
+}
+
+bool SdrTextObj::ReloadLinkedText( bool bForceLoad)
+{
+ ImpSdrObjTextLinkUserData* pData = GetLinkUserData();
+ bool bRet = true;
+
+ if( pData )
+ {
+ ::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get();
+ DateTime aFileDT;
+ BOOL bExists = FALSE, bLoad = FALSE;
+
+ if( pBroker )
+ {
+ bExists = TRUE;
+
+ try
+ {
+ INetURLObject aURL( pData->aFileName );
+ DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+
+ ::ucbhelper::Content aCnt( aURL.GetMainURL( INetURLObject::NO_DECODE ), ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
+ ::com::sun::star::uno::Any aAny( aCnt.getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DateModified" ) ) ) );
+ ::com::sun::star::util::DateTime aDateTime;
+
+ aAny >>= aDateTime;
+ ::utl::typeConvert( aDateTime, aFileDT );
+ }
+ catch( ... )
+ {
+ bExists = FALSE;
+ }
+ }
+
+ if( bExists )
+ {
+ if( bForceLoad )
+ bLoad = TRUE;
+ else
+ bLoad = ( aFileDT > pData->aFileDate0 );
+
+ if( bLoad )
+ {
+ bRet = LoadText( pData->aFileName, pData->aFilterName, pData->eCharSet );
+ }
+
+ pData->aFileDate0 = aFileDT;
+ }
+ }
+
+ return bRet;
+}
+
+bool SdrTextObj::LoadText(const String& rFileName, const String& /*rFilterName*/, rtl_TextEncoding eCharSet)
+{
+ INetURLObject aFileURL( rFileName );
+ BOOL bRet = FALSE;
+
+ if( aFileURL.GetProtocol() == INET_PROT_NOT_VALID )
+ {
+ String aFileURLStr;
+
+ if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rFileName, aFileURLStr ) )
+ aFileURL = INetURLObject( aFileURLStr );
+ else
+ aFileURL.SetSmartURL( rFileName );
+ }
+
+ DBG_ASSERT( aFileURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
+
+ if( pIStm )
+ {
+ // #90477# pIStm->SetStreamCharSet( eCharSet );
+ pIStm->SetStreamCharSet(GetSOLoadTextEncoding(eCharSet, (sal_uInt16)pIStm->GetVersion()));
+
+ char cRTF[5];
+ cRTF[4] = 0;
+ pIStm->Read(cRTF, 5);
+
+ BOOL bRTF = cRTF[0] == '{' && cRTF[1] == '\\' && cRTF[2] == 'r' && cRTF[3] == 't' && cRTF[4] == 'f';
+
+ pIStm->Seek(0);
+
+ if( !pIStm->GetError() )
+ {
+ SetText( *pIStm, aFileURL.GetMainURL( INetURLObject::NO_DECODE ), sal::static_int_cast< USHORT >( bRTF ? EE_FORMAT_RTF : EE_FORMAT_TEXT ) );
+ bRet = TRUE;
+ }
+
+ delete pIStm;
+ }
+
+ return bRet;
+}
+
+ImpSdrObjTextLinkUserData* SdrTextObj::GetLinkUserData() const
+{
+ ImpSdrObjTextLinkUserData* pData=NULL;
+ USHORT nAnz=GetUserDataCount();
+ for (USHORT nNum=nAnz; nNum>0 && pData==NULL;) {
+ nNum--;
+ pData=(ImpSdrObjTextLinkUserData*)GetUserData(nNum);
+ if (pData->GetInventor()!=SdrInventor || pData->GetId()!=SDRUSERDATA_OBJTEXTLINK) {
+ pData=NULL;
+ }
+ }
+ return pData;
+}
+
+void SdrTextObj::ImpLinkAnmeldung()
+{
+ ImpSdrObjTextLinkUserData* pData=GetLinkUserData();
+ sfx2::LinkManager* pLinkManager=pModel!=NULL ? pModel->GetLinkManager() : NULL;
+ if (pLinkManager!=NULL && pData!=NULL && pData->pLink==NULL) { // Nicht 2x Anmelden
+ pData->pLink=new ImpSdrObjTextLink(this);
+#ifdef GCC
+ pLinkManager->InsertFileLink(*pData->pLink,OBJECT_CLIENT_FILE,pData->aFileName,
+ pData->aFilterName.Len() ?
+ &pData->aFilterName : (const String *)NULL,
+ (const String *)NULL);
+#else
+ pLinkManager->InsertFileLink(*pData->pLink,OBJECT_CLIENT_FILE,pData->aFileName,
+ pData->aFilterName.Len() ? &pData->aFilterName : NULL,NULL);
+#endif
+ pData->pLink->Connect();
+ }
+}
+
+void SdrTextObj::ImpLinkAbmeldung()
+{
+ ImpSdrObjTextLinkUserData* pData=GetLinkUserData();
+ sfx2::LinkManager* pLinkManager=pModel!=NULL ? pModel->GetLinkManager() : NULL;
+ if (pLinkManager!=NULL && pData!=NULL && pData->pLink!=NULL) { // Nicht 2x Abmelden
+ // Bei Remove wird *pLink implizit deleted
+ pLinkManager->Remove( pData->pLink );
+ pData->pLink=NULL;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
new file mode 100644
index 000000000000..2896dbf3590f
--- /dev/null
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -0,0 +1,552 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdotext.hxx>
+#include "svditext.hxx"
+#include <svx/svdtrans.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdpage.hxx> // fuer Convert
+#include <svx/svdmodel.hxx> // fuer Convert
+#include <editeng/outliner.hxx>
+#include <svx/sdr/properties/itemsettools.hxx>
+#include <svx/sdr/properties/properties.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <svl/itemset.hxx>
+#include <svditer.hxx>
+#include <drawinglayer/processor2d/textaspolygonextractor2d.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlnwtit.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@@ @@@@@ @@ @@ @@@@@@ @@@@ @@@@@ @@@@@@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@@@ @@@ @@ @@ @@ @@@@@ @@
+// @@ @@ @@@@@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@ @@@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@@@@ @@ @@ @@ @@@@ @@@@@ @@@@
+//
+// Transformationen
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrTextObj::NbcSetSnapRect(const Rectangle& rRect)
+{
+ if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0) {
+ Rectangle aSR0(GetSnapRect());
+ long nWdt0=aSR0.Right()-aSR0.Left();
+ long nHgt0=aSR0.Bottom()-aSR0.Top();
+ long nWdt1=rRect.Right()-rRect.Left();
+ long nHgt1=rRect.Bottom()-rRect.Top();
+ SdrTextObj::NbcResize(maSnapRect.TopLeft(),Fraction(nWdt1,nWdt0),Fraction(nHgt1,nHgt0));
+ SdrTextObj::NbcMove(Size(rRect.Left()-aSR0.Left(),rRect.Top()-aSR0.Top()));
+ } else {
+ long nHDist=GetTextLeftDistance()+GetTextRightDistance();
+ long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
+ long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0;
+ long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0;
+ long nTWdt1=rRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0;
+ long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
+ aRect=rRect;
+ ImpJustifyRect(aRect);
+ if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) { // #51139#
+ if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1);
+ if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1);
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ ImpCheckShear();
+ SetRectsDirty();
+ }
+}
+
+const Rectangle& SdrTextObj::GetLogicRect() const
+{
+ return aRect;
+}
+
+void SdrTextObj::NbcSetLogicRect(const Rectangle& rRect)
+{
+ long nHDist=GetTextLeftDistance()+GetTextRightDistance();
+ long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
+ long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0;
+ long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0;
+ long nTWdt1=rRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0;
+ long nTHgt1=rRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
+ aRect=rRect;
+ ImpJustifyRect(aRect);
+ if (bTextFrame) {
+ if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1);
+ if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1);
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ SetRectsDirty();
+}
+
+long SdrTextObj::GetRotateAngle() const
+{
+ return aGeo.nDrehWink;
+}
+
+long SdrTextObj::GetShearAngle(bool /*bVertical*/) const
+{
+ return aGeo.nShearWink;
+}
+
+void SdrTextObj::NbcMove(const Size& rSiz)
+{
+ MoveRect(aRect,rSiz);
+ MoveRect(aOutRect,rSiz);
+ MoveRect(maSnapRect,rSiz);
+ SetRectsDirty(sal_True);
+}
+
+void SdrTextObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ bool bNoShearMerk=aGeo.nShearWink==0;
+ bool bRota90Merk=bNoShearMerk && aGeo.nDrehWink % 9000 ==0;
+ long nHDist=GetTextLeftDistance()+GetTextRightDistance();
+ long nVDist=GetTextUpperDistance()+GetTextLowerDistance();
+ long nTWdt0=aRect.GetWidth ()-1-nHDist; if (nTWdt0<0) nTWdt0=0;
+ long nTHgt0=aRect.GetHeight()-1-nVDist; if (nTHgt0<0) nTHgt0=0;
+ bool bXMirr=(xFact.GetNumerator()<0) != (xFact.GetDenominator()<0);
+ bool bYMirr=(yFact.GetNumerator()<0) != (yFact.GetDenominator()<0);
+ if (bXMirr || bYMirr) {
+ Point aRef1(GetSnapRect().Center());
+ if (bXMirr) {
+ Point aRef2(aRef1);
+ aRef2.Y()++;
+ NbcMirrorGluePoints(aRef1,aRef2);
+ }
+ if (bYMirr) {
+ Point aRef2(aRef1);
+ aRef2.X()++;
+ NbcMirrorGluePoints(aRef1,aRef2);
+ }
+ }
+
+ if (aGeo.nDrehWink==0 && aGeo.nShearWink==0) {
+ ResizeRect(aRect,rRef,xFact,yFact);
+ if (bYMirr) {
+ aRect.Justify();
+ aRect.Move(aRect.Right()-aRect.Left(),aRect.Bottom()-aRect.Top());
+ aGeo.nDrehWink=18000;
+ aGeo.RecalcSinCos();
+ }
+ }
+ else
+ {
+ // #100663# aRect is NOT initialized for lines (polgon objects with two
+ // exceptionally handled points). Thus, after this call the text rotaion is
+ // gone. This error must be present since day one of this old drawing layer.
+ // It's astonishing that noone discovered it earlier.
+ // Polygon aPol(Rect2Poly(aRect,aGeo));
+ // Polygon aPol(Rect2Poly(GetSnapRect(), aGeo));
+
+ // #101412# go back to old method, side effects are impossible
+ // to calculate.
+ Polygon aPol(Rect2Poly(aRect,aGeo));
+
+ for(sal_uInt16 a(0); a < aPol.GetSize(); a++)
+ {
+ ResizePoint(aPol[a], rRef, xFact, yFact);
+ }
+
+ if(bXMirr != bYMirr)
+ {
+ // Polygon wenden und etwas schieben
+ Polygon aPol0(aPol);
+
+ aPol[0] = aPol0[1];
+ aPol[1] = aPol0[0];
+ aPol[2] = aPol0[3];
+ aPol[3] = aPol0[2];
+ aPol[4] = aPol0[1];
+ }
+
+ Poly2Rect(aPol, aRect, aGeo);
+ }
+
+ if (bRota90Merk) {
+ bool bRota90=aGeo.nDrehWink % 9000 ==0;
+ if (!bRota90) { // Scheinbar Rundungsfehler: Korregieren
+ long a=NormAngle360(aGeo.nDrehWink);
+ if (a<4500) a=0;
+ else if (a<13500) a=9000;
+ else if (a<22500) a=18000;
+ else if (a<31500) a=27000;
+ else a=0;
+ aGeo.nDrehWink=a;
+ aGeo.RecalcSinCos();
+ }
+ if (bNoShearMerk!=(aGeo.nShearWink==0)) { // Shear ggf. korregieren wg. Rundungsfehler
+ aGeo.nShearWink=0;
+ aGeo.RecalcTan();
+ }
+ }
+
+ ImpJustifyRect(aRect);
+ long nTWdt1=aRect.GetWidth ()-1-nHDist; if (nTWdt1<0) nTWdt1=0;
+ long nTHgt1=aRect.GetHeight()-1-nVDist; if (nTHgt1<0) nTHgt1=0;
+ if (bTextFrame && (pModel==NULL || !pModel->IsPasteResize())) { // #51139#
+ if (nTWdt0!=nTWdt1 && IsAutoGrowWidth() ) NbcSetMinTextFrameWidth(nTWdt1);
+ if (nTHgt0!=nTHgt1 && IsAutoGrowHeight()) NbcSetMinTextFrameHeight(nTHgt1);
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ ImpCheckShear();
+ SetRectsDirty();
+}
+
+void SdrTextObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ SetGlueReallyAbsolute(TRUE);
+ long dx=aRect.Right()-aRect.Left();
+ long dy=aRect.Bottom()-aRect.Top();
+ Point aP(aRect.TopLeft());
+ RotatePoint(aP,rRef,sn,cs);
+ aRect.Left()=aP.X();
+ aRect.Top()=aP.Y();
+ aRect.Right()=aRect.Left()+dx;
+ aRect.Bottom()=aRect.Top()+dy;
+ if (aGeo.nDrehWink==0) {
+ aGeo.nDrehWink=NormAngle360(nWink);
+ aGeo.nSin=sn;
+ aGeo.nCos=cs;
+ } else {
+ aGeo.nDrehWink=NormAngle360(aGeo.nDrehWink+nWink);
+ aGeo.RecalcSinCos();
+ }
+ SetRectsDirty();
+ NbcRotateGluePoints(rRef,nWink,sn,cs);
+ SetGlueReallyAbsolute(FALSE);
+}
+
+void SdrTextObj::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ SetGlueReallyAbsolute(TRUE);
+
+ // #75889# when this is a SdrPathObj aRect maybe not initialized
+ Polygon aPol(Rect2Poly(aRect.IsEmpty() ? GetSnapRect() : aRect, aGeo));
+
+ USHORT nPointCount=aPol.GetSize();
+ for (USHORT i=0; i<nPointCount; i++) {
+ ShearPoint(aPol[i],rRef,tn,bVShear);
+ }
+ Poly2Rect(aPol,aRect,aGeo);
+ ImpJustifyRect(aRect);
+ if (bTextFrame) {
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ ImpCheckShear();
+ SetRectsDirty();
+ NbcShearGluePoints(rRef,nWink,tn,bVShear);
+ SetGlueReallyAbsolute(FALSE);
+}
+
+void SdrTextObj::NbcMirror(const Point& rRef1, const Point& rRef2)
+{
+ SetGlueReallyAbsolute(TRUE);
+ bool bNoShearMerk=aGeo.nShearWink==0;
+ bool bRota90Merk = false;
+ if (bNoShearMerk &&
+ (rRef1.X()==rRef2.X() || rRef1.Y()==rRef2.Y() ||
+ Abs(rRef1.X()-rRef2.X())==Abs(rRef1.Y()-rRef2.Y()))) {
+ bRota90Merk=aGeo.nDrehWink % 9000 ==0;
+ }
+ Polygon aPol(Rect2Poly(aRect,aGeo));
+ USHORT i;
+ USHORT nPntAnz=aPol.GetSize();
+ for (i=0; i<nPntAnz; i++) {
+ MirrorPoint(aPol[i],rRef1,rRef2);
+ }
+ // Polygon wenden und etwas schieben
+ Polygon aPol0(aPol);
+ aPol[0]=aPol0[1];
+ aPol[1]=aPol0[0];
+ aPol[2]=aPol0[3];
+ aPol[3]=aPol0[2];
+ aPol[4]=aPol0[1];
+ Poly2Rect(aPol,aRect,aGeo);
+
+ if (bRota90Merk) {
+ bool bRota90=aGeo.nDrehWink % 9000 ==0;
+ if (bRota90Merk && !bRota90) { // Scheinbar Rundungsfehler: Korregieren
+ long a=NormAngle360(aGeo.nDrehWink);
+ if (a<4500) a=0;
+ else if (a<13500) a=9000;
+ else if (a<22500) a=18000;
+ else if (a<31500) a=27000;
+ else a=0;
+ aGeo.nDrehWink=a;
+ aGeo.RecalcSinCos();
+ }
+ }
+ if (bNoShearMerk!=(aGeo.nShearWink==0)) { // Shear ggf. korregieren wg. Rundungsfehler
+ aGeo.nShearWink=0;
+ aGeo.RecalcTan();
+ }
+
+ ImpJustifyRect(aRect);
+ if (bTextFrame) {
+ NbcAdjustTextFrameWidthAndHeight();
+ }
+ ImpCheckShear();
+ SetRectsDirty();
+ NbcMirrorGluePoints(rRef1,rRef2);
+ SetGlueReallyAbsolute(FALSE);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+SdrObject* SdrTextObj::ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const
+{
+ SdrObject* pRetval = 0;
+
+ if(!ImpCanConvTextToCurve())
+ {
+ // suppress HelpTexts from PresObj's
+ return 0;
+ }
+
+ // get primitives
+ const drawinglayer::primitive2d::Primitive2DSequence xSequence(GetViewContact().getViewIndependentPrimitive2DSequence());
+
+ if(xSequence.hasElements())
+ {
+ // create an extractor with neutral ViewInformation
+ const drawinglayer::geometry::ViewInformation2D aViewInformation2D(0);
+ drawinglayer::processor2d::TextAsPolygonExtractor2D aExtractor(aViewInformation2D);
+
+ // extract text as polygons
+ aExtractor.process(xSequence);
+
+ // get results
+ const drawinglayer::processor2d::TextAsPolygonDataNodeVector& rResult = aExtractor.getTarget();
+ const sal_uInt32 nResultCount(rResult.size());
+
+ if(nResultCount)
+ {
+ // prepare own target
+ SdrObjGroup* pGroup = new SdrObjGroup();
+ SdrObjList* pObjectList = pGroup->GetSubList();
+
+ // process results
+ for(sal_uInt32 a(0); a < nResultCount; a++)
+ {
+ const drawinglayer::processor2d::TextAsPolygonDataNode& rCandidate = rResult[a];
+ basegfx::B2DPolyPolygon aPolyPolygon(rCandidate.getB2DPolyPolygon());
+
+ if(aPolyPolygon.count())
+ {
+ // take care of wanted polygon type
+ if(bToPoly)
+ {
+ if(aPolyPolygon.areControlPointsUsed())
+ {
+ aPolyPolygon = basegfx::tools::adaptiveSubdivideByAngle(aPolyPolygon);
+ }
+ }
+ else
+ {
+ if(!aPolyPolygon.areControlPointsUsed())
+ {
+ aPolyPolygon = basegfx::tools::expandToCurve(aPolyPolygon);
+ }
+ }
+
+ // create ItemSet with object attributes
+ SfxItemSet aAttributeSet(GetObjectItemSet());
+ SdrPathObj* pPathObj = 0;
+
+ // always clear objectshadow; this is included in the extraction
+ aAttributeSet.Put(SdrShadowItem(false));
+
+ if(rCandidate.getIsFilled())
+ {
+ // set needed items
+ aAttributeSet.Put(XFillColorItem(String(), Color(rCandidate.getBColor())));
+ aAttributeSet.Put(XLineStyleItem(XLINE_NONE));
+ aAttributeSet.Put(XFillStyleItem(XFILL_SOLID));
+
+ // create filled SdrPathObj
+ pPathObj = new SdrPathObj(OBJ_PATHFILL, aPolyPolygon);
+ }
+ else
+ {
+ // set needed items
+ aAttributeSet.Put(XLineColorItem(String(), Color(rCandidate.getBColor())));
+ aAttributeSet.Put(XLineStyleItem(XLINE_SOLID));
+ aAttributeSet.Put(XLineWidthItem(0));
+ aAttributeSet.Put(XFillStyleItem(XFILL_NONE));
+
+ // create line SdrPathObj
+ pPathObj = new SdrPathObj(OBJ_PATHLINE, aPolyPolygon);
+ }
+
+ // copy basic information from original
+ pPathObj->ImpSetAnchorPos(GetAnchorPos());
+ pPathObj->NbcSetLayer(GetLayer());
+
+ if(GetModel())
+ {
+ pPathObj->SetModel(GetModel());
+ pPathObj->NbcSetStyleSheet(GetStyleSheet(), true);
+ }
+
+ // apply prepared ItemSet and add to target
+ pPathObj->SetMergedItemSet(aAttributeSet);
+ pObjectList->InsertObject(pPathObj);
+ }
+ }
+
+ // postprocess; if no result and/or only one object, simplify
+ if(!pObjectList->GetObjCount())
+ {
+ delete pGroup;
+ }
+ else if(1 == pObjectList->GetObjCount())
+ {
+ pRetval = pObjectList->RemoveObject(0);
+ delete pGroup;
+ }
+ else
+ {
+ pRetval = pGroup;
+ }
+ }
+ }
+
+ return pRetval;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+SdrObject* SdrTextObj::DoConvertToPolyObj(BOOL bBezier) const
+{
+ return ImpConvertContainedTextToSdrPathObjs(!bBezier);
+}
+
+bool SdrTextObj::ImpCanConvTextToCurve() const
+{
+ return !IsOutlText();
+}
+
+SdrObject* SdrTextObj::ImpConvertMakeObj(const basegfx::B2DPolyPolygon& rPolyPolygon, sal_Bool bClosed, sal_Bool bBezier, sal_Bool bNoSetAttr) const
+{
+ SdrObjKind ePathKind = bClosed ? OBJ_PATHFILL : OBJ_PATHLINE;
+ basegfx::B2DPolyPolygon aB2DPolyPolygon(rPolyPolygon);
+
+ // #i37011#
+ if(!bBezier)
+ {
+ aB2DPolyPolygon = basegfx::tools::adaptiveSubdivideByAngle(aB2DPolyPolygon);
+ ePathKind = bClosed ? OBJ_POLY : OBJ_PLIN;
+ }
+
+ SdrPathObj* pPathObj = new SdrPathObj(ePathKind, aB2DPolyPolygon);
+
+ if(bBezier)
+ {
+ // create bezier curves
+ pPathObj->SetPathPoly(basegfx::tools::expandToCurve(pPathObj->GetPathPoly()));
+ }
+
+ if(pPathObj)
+ {
+ pPathObj->ImpSetAnchorPos(aAnchor);
+ pPathObj->NbcSetLayer(SdrLayerID(GetLayer()));
+
+ if(pModel)
+ {
+ pPathObj->SetModel(pModel);
+
+ if(!bNoSetAttr)
+ {
+ sdr::properties::ItemChangeBroadcaster aC(*pPathObj);
+
+ pPathObj->ClearMergedItem();
+ pPathObj->SetMergedItemSet(GetObjectItemSet());
+ pPathObj->GetProperties().BroadcastItemChange(aC);
+ pPathObj->NbcSetStyleSheet(GetStyleSheet(), sal_True);
+ }
+ }
+ }
+
+ return pPathObj;
+}
+
+SdrObject* SdrTextObj::ImpConvertAddText(SdrObject* pObj, bool bBezier) const
+{
+ if(!ImpCanConvTextToCurve())
+ {
+ return pObj;
+ }
+
+ SdrObject* pText = ImpConvertContainedTextToSdrPathObjs(!bBezier);
+
+ if(!pText)
+ {
+ return pObj;
+ }
+
+ if(!pObj)
+ {
+ return pText;
+ }
+
+ if(pText->IsGroupObject())
+ {
+ // is already group object, add partial shape in front
+ SdrObjList* pOL=pText->GetSubList();
+ pOL->InsertObject(pObj,0);
+
+ return pText;
+ }
+ else
+ {
+ // not yet a group, create one and add partial and new shapes
+ SdrObjGroup* pGrp=new SdrObjGroup;
+ SdrObjList* pOL=pGrp->GetSubList();
+ pOL->InsertObject(pObj);
+ pOL->InsertObject(pText);
+
+ return pGrp;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx
new file mode 100644
index 000000000000..76de3eac6942
--- /dev/null
+++ b/svx/source/svdraw/svdouno.cxx
@@ -0,0 +1,668 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/sdr/contact/viewcontactofunocontrol.hxx>
+#include <svx/sdr/contact/viewobjectcontactofunocontrol.hxx>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#include <com/sun/star/util/XCloneable.hpp>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
+#include <vcl/pdfextoutdevdata.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdmodel.hxx>
+#include "svdglob.hxx" // Stringcache
+#include "svdstr.hrc" // Objektname
+#include <svx/svdetc.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdorect.hxx>
+#include "svdviter.hxx"
+#include <rtl/ref.hxx>
+#include <set>
+#include <memory>
+#include <svx/sdrpagewindow.hxx>
+#include <sdrpaintwindow.hxx>
+#include <tools/diagnose_ex.h>
+#include <svx/svdograf.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::sdr::contact;
+
+//************************************************************
+// Defines
+//************************************************************
+
+//************************************************************
+// Hilfsklasse SdrControlEventListenerImpl
+//************************************************************
+#include <com/sun/star/lang/XEventListener.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+
+// =============================================================================
+class SdrControlEventListenerImpl : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener >
+{
+protected:
+ SdrUnoObj* pObj;
+
+public:
+ SdrControlEventListenerImpl(SdrUnoObj* _pObj)
+ : pObj(_pObj)
+ {}
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ void StopListening(const uno::Reference< lang::XComponent >& xComp);
+ void StartListening(const uno::Reference< lang::XComponent >& xComp);
+};
+
+// XEventListener
+void SAL_CALL SdrControlEventListenerImpl::disposing( const ::com::sun::star::lang::EventObject& /*Source*/)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if (pObj)
+ {
+ pObj->xUnoControlModel = NULL;
+ }
+}
+
+void SdrControlEventListenerImpl::StopListening(const uno::Reference< lang::XComponent >& xComp)
+{
+ if (xComp.is())
+ xComp->removeEventListener(this);
+}
+
+void SdrControlEventListenerImpl::StartListening(const uno::Reference< lang::XComponent >& xComp)
+{
+ if (xComp.is())
+ xComp->addEventListener(this);
+}
+
+// =============================================================================
+struct SAL_DLLPRIVATE SdrUnoObjDataHolder
+{
+ mutable ::rtl::Reference< SdrControlEventListenerImpl >
+ pEventListener;
+};
+
+// =============================================================================
+namespace
+{
+ void lcl_ensureControlVisibility( SdrView* _pView, const SdrUnoObj* _pObject, bool _bVisible )
+ {
+ OSL_PRECOND( _pObject, "lcl_ensureControlVisibility: no object -> no survival!" );
+
+ SdrPageView* pPageView = _pView ? _pView->GetSdrPageView() : NULL;
+ DBG_ASSERT( pPageView, "lcl_ensureControlVisibility: no view found!" );
+ if ( !pPageView )
+ return;
+
+ ViewContact& rUnoControlContact( _pObject->GetViewContact() );
+
+ for ( sal_uInt32 i = 0; i < pPageView->PageWindowCount(); ++i )
+ {
+ const SdrPageWindow* pPageWindow = pPageView->GetPageWindow( i );
+ DBG_ASSERT( pPageWindow, "lcl_ensureControlVisibility: invalid PageViewWindow!" );
+ if ( !pPageWindow )
+ continue;
+
+ if ( !pPageWindow->HasObjectContact() )
+ continue;
+
+ ObjectContact& rPageViewContact( pPageWindow->GetObjectContact() );
+ const ViewObjectContact& rViewObjectContact( rUnoControlContact.GetViewObjectContact( rPageViewContact ) );
+ const ViewObjectContactOfUnoControl* pUnoControlContact = dynamic_cast< const ViewObjectContactOfUnoControl* >( &rViewObjectContact );
+ DBG_ASSERT( pUnoControlContact, "lcl_ensureControlVisibility: wrong ViewObjectContact type!" );
+ if ( !pUnoControlContact )
+ continue;
+
+ pUnoControlContact->ensureControlVisibility( _bVisible );
+ }
+ }
+}
+
+//************************************************************
+// SdrUnoObj
+//************************************************************
+
+TYPEINIT1(SdrUnoObj, SdrRectObj);
+
+SdrUnoObj::SdrUnoObj(const String& rModelName, BOOL _bOwnUnoControlModel)
+: m_pImpl( new SdrUnoObjDataHolder ),
+ bOwnUnoControlModel( _bOwnUnoControlModel )
+{
+ bIsUnoObj = TRUE;
+
+ m_pImpl->pEventListener = new SdrControlEventListenerImpl(this);
+
+ // nur ein owner darf eigenstaendig erzeugen
+ if (rModelName.Len())
+ CreateUnoControlModel(rModelName);
+}
+
+SdrUnoObj::SdrUnoObj(const String& rModelName,
+ const uno::Reference< lang::XMultiServiceFactory >& rxSFac,
+ BOOL _bOwnUnoControlModel)
+: m_pImpl( new SdrUnoObjDataHolder ),
+ bOwnUnoControlModel( _bOwnUnoControlModel )
+{
+ bIsUnoObj = TRUE;
+
+ m_pImpl->pEventListener = new SdrControlEventListenerImpl(this);
+
+ // nur ein owner darf eigenstaendig erzeugen
+ if (rModelName.Len())
+ CreateUnoControlModel(rModelName,rxSFac);
+}
+
+SdrUnoObj::~SdrUnoObj()
+{
+ try
+ {
+ // clean up the control model
+ uno::Reference< lang::XComponent > xComp(xUnoControlModel, uno::UNO_QUERY);
+ if (xComp.is())
+ {
+ // is the control model owned by it's environment?
+ uno::Reference< container::XChild > xContent(xUnoControlModel, uno::UNO_QUERY);
+ if (xContent.is() && !xContent->getParent().is())
+ xComp->dispose();
+ else
+ m_pImpl->pEventListener->StopListening(xComp);
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ OSL_ENSURE( sal_False, "SdrUnoObj::~SdrUnoObj: caught an exception!" );
+ }
+ delete m_pImpl;
+}
+
+void SdrUnoObj::SetModel(SdrModel* pNewModel)
+{
+ SdrRectObj::SetModel(pNewModel);
+}
+
+void SdrUnoObj::SetPage(SdrPage* pNewPage)
+{
+ SdrRectObj::SetPage(pNewPage);
+}
+
+void SdrUnoObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bRotateFreeAllowed = FALSE;
+ rInfo.bRotate90Allowed = FALSE;
+ rInfo.bMirrorFreeAllowed = FALSE;
+ rInfo.bMirror45Allowed = FALSE;
+ rInfo.bMirror90Allowed = FALSE;
+ rInfo.bTransparenceAllowed = FALSE;
+ rInfo.bGradientAllowed = FALSE;
+ rInfo.bShearAllowed = FALSE;
+ rInfo.bEdgeRadiusAllowed = FALSE;
+ rInfo.bNoOrthoDesired = FALSE;
+ rInfo.bCanConvToPath = FALSE;
+ rInfo.bCanConvToPoly = FALSE;
+ rInfo.bCanConvToPathLineToArea = FALSE;
+ rInfo.bCanConvToPolyLineToArea = FALSE;
+ rInfo.bCanConvToContour = FALSE;
+}
+
+UINT16 SdrUnoObj::GetObjIdentifier() const
+{
+ return UINT16(OBJ_UNO);
+}
+
+void SdrUnoObj::SetContextWritingMode( const sal_Int16 _nContextWritingMode )
+{
+ try
+ {
+ uno::Reference< beans::XPropertySet > xModelProperties( GetUnoControlModel(), uno::UNO_QUERY_THROW );
+ xModelProperties->setPropertyValue(
+ ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( "ContextWritingMode" ) ),
+ uno::makeAny( _nContextWritingMode )
+ );
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// ----------------------------------------------------------------------------
+namespace
+{
+ /** helper class to restore graphics at <awt::XView> object after <SdrUnoObj::Paint>
+
+ OD 08.05.2003 #109432#
+ Restoration of graphics necessary to assure that paint on a window
+
+ @author OD
+ */
+ class RestoreXViewGraphics
+ {
+ private:
+ uno::Reference< awt::XView > m_rXView;
+ uno::Reference< awt::XGraphics > m_rXGraphics;
+
+ public:
+ RestoreXViewGraphics( const uno::Reference< awt::XView >& _rXView )
+ {
+ m_rXView = _rXView;
+ m_rXGraphics = m_rXView->getGraphics();
+ }
+ ~RestoreXViewGraphics()
+ {
+ m_rXView->setGraphics( m_rXGraphics );
+ }
+ };
+}
+
+void SdrUnoObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName = ImpGetResStr(STR_ObjNameSingulUno);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+void SdrUnoObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName = ImpGetResStr(STR_ObjNamePluralUno);
+}
+
+void SdrUnoObj::operator = (const SdrObject& rObj)
+{
+ SdrRectObj::operator = (rObj);
+
+ // release the reference to the current control model
+ SetUnoControlModel(uno::Reference< awt::XControlModel >());
+
+ aUnoControlModelTypeName = ((SdrUnoObj&) rObj).aUnoControlModelTypeName;
+ aUnoControlTypeName = ((SdrUnoObj&) rObj).aUnoControlTypeName;
+
+ // copy the uno control model
+ uno::Reference< awt::XControlModel > xCtrl( ((SdrUnoObj&) rObj).GetUnoControlModel(), uno::UNO_QUERY );
+ uno::Reference< util::XCloneable > xClone( xCtrl, uno::UNO_QUERY );
+
+ if ( xClone.is() )
+ {
+ // copy the model by cloning
+ uno::Reference< awt::XControlModel > xNewModel( xClone->createClone(), uno::UNO_QUERY );
+ DBG_ASSERT( xNewModel.is(), "SdrUnoObj::operator =, no control model!");
+ xUnoControlModel = xNewModel;
+ }
+ else
+ {
+ // copy the model by streaming
+ uno::Reference< io::XPersistObject > xObj( xCtrl, uno::UNO_QUERY );
+ uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+
+ if ( xObj.is() && xFactory.is() )
+ {
+ // creating a pipe
+ uno::Reference< io::XOutputStream > xOutPipe(xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.io.Pipe")), uno::UNO_QUERY);
+ uno::Reference< io::XInputStream > xInPipe(xOutPipe, uno::UNO_QUERY);
+
+ // creating the mark streams
+ uno::Reference< io::XInputStream > xMarkIn(xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.io.MarkableInputStream")), uno::UNO_QUERY);
+ uno::Reference< io::XActiveDataSink > xMarkSink(xMarkIn, uno::UNO_QUERY);
+
+ uno::Reference< io::XOutputStream > xMarkOut(xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.io.MarkableOutputStream")), uno::UNO_QUERY);
+ uno::Reference< io::XActiveDataSource > xMarkSource(xMarkOut, uno::UNO_QUERY);
+
+ // connect mark and sink
+ uno::Reference< io::XActiveDataSink > xSink(xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.io.ObjectInputStream")), uno::UNO_QUERY);
+
+ // connect mark and source
+ uno::Reference< io::XActiveDataSource > xSource(xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.io.ObjectOutputStream")), uno::UNO_QUERY);
+
+ uno::Reference< io::XObjectOutputStream > xOutStrm(xSource, uno::UNO_QUERY);
+ uno::Reference< io::XObjectInputStream > xInStrm(xSink, uno::UNO_QUERY);
+
+ if (xMarkSink.is() && xMarkSource.is() && xSink.is() && xSource.is())
+ {
+ xMarkSink->setInputStream(xInPipe);
+ xMarkSource->setOutputStream(xOutPipe);
+ xSink->setInputStream(xMarkIn);
+ xSource->setOutputStream(xMarkOut);
+
+ // write the object to source
+ xOutStrm->writeObject(xObj);
+ xOutStrm->closeOutput();
+ // read the object
+ uno::Reference< awt::XControlModel > xModel(xInStrm->readObject(), uno::UNO_QUERY);
+ xInStrm->closeInput();
+
+ DBG_ASSERT(xModel.is(), "SdrUnoObj::operator =, keine Model erzeugt");
+
+ xUnoControlModel = xModel;
+ }
+ }
+ }
+
+ // get service name of the control from the control model
+ uno::Reference< beans::XPropertySet > xSet(xUnoControlModel, uno::UNO_QUERY);
+ if (xSet.is())
+ {
+ uno::Any aValue( xSet->getPropertyValue( rtl::OUString::createFromAscii("DefaultControl")) );
+ ::rtl::OUString aStr;
+
+ if( aValue >>= aStr )
+ aUnoControlTypeName = String(aStr);
+ }
+
+ uno::Reference< lang::XComponent > xComp(xUnoControlModel, uno::UNO_QUERY);
+ if (xComp.is())
+ m_pImpl->pEventListener->StartListening(xComp);
+}
+
+void SdrUnoObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ SdrRectObj::NbcResize(rRef,xFact,yFact);
+
+ if (aGeo.nShearWink!=0 || aGeo.nDrehWink!=0)
+ {
+ // kleine Korrekturen
+ if (aGeo.nDrehWink>=9000 && aGeo.nDrehWink<27000)
+ {
+ aRect.Move(aRect.Left()-aRect.Right(),aRect.Top()-aRect.Bottom());
+ }
+
+ aGeo.nDrehWink = 0;
+ aGeo.nShearWink = 0;
+ aGeo.nSin = 0.0;
+ aGeo.nCos = 1.0;
+ aGeo.nTan = 0.0;
+ SetRectsDirty();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+bool SdrUnoObj::hasSpecialDrag() const
+{
+ // no special drag; we have no rounding rect and
+ // do want frame handles
+ return false;
+}
+
+bool SdrUnoObj::supportsFullDrag() const
+{
+ // overloaded to have the possibility to enable/disable in debug and
+ // to ckeck some things out. Current solution is working, so default is
+ // enabled
+ static bool bDoSupportFullDrag(true);
+
+ return bDoSupportFullDrag;
+}
+
+SdrObject* SdrUnoObj::getFullDragClone() const
+{
+ SdrObject* pRetval = 0;
+ static bool bHandleSpecial(false);
+
+ if(bHandleSpecial)
+ {
+ // special handling for SdrUnoObj (FormControl). Create a SdrGrafObj
+ // for drag containing the graphical representation. This does not work too
+ // well, so the default is to simply clone
+ pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), this), GetLogicRect());
+ }
+ else
+ {
+ // call parent (simply clone)
+ pRetval = SdrRectObj::getFullDragClone();
+ }
+
+ return pRetval;
+}
+
+// -----------------------------------------------------------------------------
+void SdrUnoObj::NbcSetLayer( SdrLayerID _nLayer )
+{
+ if ( GetLayer() == _nLayer )
+ { // redundant call -> not interested in doing anything here
+ SdrRectObj::NbcSetLayer( _nLayer );
+ return;
+ }
+
+ // we need some special handling here in case we're moved from an invisible layer
+ // to a visible one, or vice versa
+ // (relative to a layer. Remember that the visibility of a layer is a view attribute
+ // - the same layer can be visible in one view, and invisible in another view, at the
+ // same time)
+ // 2003-06-03 - #110592# - fs@openoffice.org
+
+ // collect all views in which our old layer is visible
+ ::std::set< SdrView* > aPreviouslyVisible;
+
+ {
+ SdrViewIter aIter( this );
+ for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
+ aPreviouslyVisible.insert( pView );
+ }
+
+ SdrRectObj::NbcSetLayer( _nLayer );
+
+ // collect all views in which our new layer is visible
+ ::std::set< SdrView* > aNewlyVisible;
+
+ {
+ SdrViewIter aIter( this );
+ for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
+ {
+ ::std::set< SdrView* >::const_iterator aPrevPos = aPreviouslyVisible.find( pView );
+ if ( aPreviouslyVisible.end() != aPrevPos )
+ { // in pView, we were visible _before_ the layer change, and are
+ // visible _after_ the layer change, too
+ // -> we're not interested in this view at all
+ aPreviouslyVisible.erase( aPrevPos );
+ }
+ else
+ {
+ // in pView, we were visible _before_ the layer change, and are
+ // _not_ visible after the layer change
+ // => remember this view, as our visibility there changed
+ aNewlyVisible.insert( pView );
+ }
+ }
+ }
+
+ // now aPreviouslyVisible contains all views where we became invisible
+ ::std::set< SdrView* >::const_iterator aLoopViews;
+ for ( aLoopViews = aPreviouslyVisible.begin();
+ aLoopViews != aPreviouslyVisible.end();
+ ++aLoopViews
+ )
+ {
+ lcl_ensureControlVisibility( *aLoopViews, this, false );
+ }
+
+ // and aNewlyVisible all views where we became visible
+ for ( aLoopViews = aNewlyVisible.begin();
+ aLoopViews != aNewlyVisible.end();
+ ++aLoopViews
+ )
+ {
+ lcl_ensureControlVisibility( *aLoopViews, this, true );
+ }
+}
+
+void SdrUnoObj::CreateUnoControlModel(const String& rModelName)
+{
+ DBG_ASSERT(!xUnoControlModel.is(), "model already exists");
+
+ aUnoControlModelTypeName = rModelName;
+
+ uno::Reference< awt::XControlModel > xModel;
+ uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
+ if (aUnoControlModelTypeName.Len() && xFactory.is() )
+ {
+ xModel = uno::Reference< awt::XControlModel >(xFactory->createInstance(
+ aUnoControlModelTypeName), uno::UNO_QUERY);
+
+ if (xModel.is())
+ SetChanged();
+ }
+
+ SetUnoControlModel(xModel);
+}
+
+void SdrUnoObj::CreateUnoControlModel(const String& rModelName,
+ const uno::Reference< lang::XMultiServiceFactory >& rxSFac)
+{
+ DBG_ASSERT(!xUnoControlModel.is(), "model already exists");
+
+ aUnoControlModelTypeName = rModelName;
+
+ uno::Reference< awt::XControlModel > xModel;
+ if (aUnoControlModelTypeName.Len() && rxSFac.is() )
+ {
+ xModel = uno::Reference< awt::XControlModel >(rxSFac->createInstance(
+ aUnoControlModelTypeName), uno::UNO_QUERY);
+
+ if (xModel.is())
+ SetChanged();
+ }
+
+ SetUnoControlModel(xModel);
+}
+
+void SdrUnoObj::SetUnoControlModel( const uno::Reference< awt::XControlModel >& xModel)
+{
+ if (xUnoControlModel.is())
+ {
+ uno::Reference< lang::XComponent > xComp(xUnoControlModel, uno::UNO_QUERY);
+ if (xComp.is())
+ m_pImpl->pEventListener->StopListening(xComp);
+ }
+
+ xUnoControlModel = xModel;
+
+ // control model muss servicename des controls enthalten
+ if (xUnoControlModel.is())
+ {
+ uno::Reference< beans::XPropertySet > xSet(xUnoControlModel, uno::UNO_QUERY);
+ if (xSet.is())
+ {
+ uno::Any aValue( xSet->getPropertyValue(String("DefaultControl", gsl_getSystemTextEncoding())) );
+ ::rtl::OUString aStr;
+ if( aValue >>= aStr )
+ aUnoControlTypeName = String(aStr);
+ }
+
+ uno::Reference< lang::XComponent > xComp(xUnoControlModel, uno::UNO_QUERY);
+ if (xComp.is())
+ m_pImpl->pEventListener->StartListening(xComp);
+ }
+
+ // invalidate all ViewObject contacts
+ ViewContactOfUnoControl* pVC = NULL;
+ if ( impl_getViewContact( pVC ) )
+ {
+ // flushViewObjectContacts() removes all existing VOCs for the local DrawHierarchy. This
+ // is always allowed since they will be re-created on demand (and with the changed model)
+ GetViewContact().flushViewObjectContacts(true);
+ }
+}
+
+//------------------------------------------------------------------------
+uno::Reference< awt::XControl > SdrUnoObj::GetUnoControl(const SdrView& _rView, const OutputDevice& _rOut) const
+{
+ uno::Reference< awt::XControl > xControl;
+
+ SdrPageView* pPageView = _rView.GetSdrPageView();
+ OSL_ENSURE( GetPage() == pPageView->GetPage(), "SdrUnoObj::GetUnoControl: This object is not displayed in that particular view!" );
+ if ( GetPage() != pPageView->GetPage() )
+ return NULL;
+
+ SdrPageWindow* pPageWindow = pPageView ? pPageView->FindPageWindow( _rOut ) : NULL;
+ OSL_ENSURE( pPageWindow, "SdrUnoObj::GetUnoControl: did not find my SdrPageWindow!" );
+ if ( !pPageWindow )
+ return NULL;
+
+ ViewObjectContact& rViewObjectContact( GetViewContact().GetViewObjectContact( pPageWindow->GetObjectContact() ) );
+ ViewObjectContactOfUnoControl* pUnoContact = dynamic_cast< ViewObjectContactOfUnoControl* >( &rViewObjectContact );
+ OSL_ENSURE( pUnoContact, "SdrUnoObj::GetUnoControl: wrong contact type!" );
+ if ( pUnoContact )
+ xControl = pUnoContact->getControl();
+
+ return xControl;
+}
+
+//------------------------------------------------------------------------
+uno::Reference< awt::XControl > SdrUnoObj::GetTemporaryControlForWindow(
+ const Window& _rWindow, uno::Reference< awt::XControlContainer >& _inout_ControlContainer ) const
+{
+ uno::Reference< awt::XControl > xControl;
+
+ ViewContactOfUnoControl* pVC = NULL;
+ if ( impl_getViewContact( pVC ) )
+ xControl = pVC->getTemporaryControlForWindow( _rWindow, _inout_ControlContainer );
+
+ return xControl;
+}
+
+//------------------------------------------------------------------------
+bool SdrUnoObj::impl_getViewContact( ViewContactOfUnoControl*& _out_rpContact ) const
+{
+ ViewContact& rViewContact( GetViewContact() );
+ _out_rpContact = dynamic_cast< ViewContactOfUnoControl* >( &rViewContact );
+ DBG_ASSERT( _out_rpContact, "SdrUnoObj::impl_getViewContact: could not find my ViewContact!" );
+ return ( _out_rpContact != NULL );
+}
+
+//------------------------------------------------------------------------
+::sdr::contact::ViewContact* SdrUnoObj::CreateObjectSpecificViewContact()
+{
+ return new ::sdr::contact::ViewContactOfUnoControl( *this );
+}
+
+// -----------------------------------------------------------------------------
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdoutl.cxx b/svx/source/svdraw/svdoutl.cxx
new file mode 100644
index 000000000000..506f4272e2c2
--- /dev/null
+++ b/svx/source/svdraw/svdoutl.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/svdoutl.hxx>
+#include <editeng/outliner.hxx>
+#include <svx/svdotext.hxx>
+#include <editeng/editstat.hxx>
+#include <svx/svdmodel.hxx>
+#include <editeng/eeitem.hxx>
+#include <svl/itempool.hxx>
+
+DBG_NAME(SdrOutliner)
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+SdrOutliner::SdrOutliner( SfxItemPool* pItemPool, USHORT nMode )
+: Outliner( pItemPool, nMode ),
+ //mpPaintInfoRec( NULL )
+ mpVisualizedPage(0)
+{
+ DBG_CTOR(SdrOutliner,NULL);
+}
+
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+\************************************************************************/
+SdrOutliner::~SdrOutliner()
+{
+ DBG_DTOR(SdrOutliner,NULL);
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+void SdrOutliner::SetTextObj( const SdrTextObj* pObj )
+{
+ if( pObj && pObj != mpTextObj.get() )
+ {
+ SetUpdateMode(FALSE);
+ USHORT nOutlinerMode2 = OUTLINERMODE_OUTLINEOBJECT;
+ if ( !pObj->IsOutlText() )
+ nOutlinerMode2 = OUTLINERMODE_TEXTOBJECT;
+ Init( nOutlinerMode2 );
+
+ SetGlobalCharStretching(100,100);
+
+ ULONG nStat = GetControlWord();
+ nStat &= ~( EE_CNTRL_STRETCHING | EE_CNTRL_AUTOPAGESIZE );
+ SetControlWord(nStat);
+
+ Size aNullSize;
+ Size aMaxSize( 100000,100000 );
+ SetMinAutoPaperSize( aNullSize );
+ SetMaxAutoPaperSize( aMaxSize );
+ SetPaperSize( aMaxSize );
+ ClearPolygon();
+ }
+
+ mpTextObj.reset( const_cast< SdrTextObj* >(pObj) );
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+void SdrOutliner::SetTextObjNoInit( const SdrTextObj* pObj )
+{
+ mpTextObj.reset( const_cast< SdrTextObj* >(pObj) );
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+XubString SdrOutliner::CalcFieldValue(const SvxFieldItem& rField, USHORT nPara, USHORT nPos,
+ Color*& rpTxtColor, Color*& rpFldColor)
+{
+ bool bOk = false;
+ XubString aRet;
+
+ if(mpTextObj.is())
+ bOk = static_cast< SdrTextObj* >( mpTextObj.get())->CalcFieldValue(rField, nPara, nPos, FALSE, rpTxtColor, rpFldColor, aRet);
+
+ if (!bOk)
+ aRet = Outliner::CalcFieldValue(rField, nPara, nPos, rpTxtColor, rpFldColor);
+
+ return aRet;
+}
+
+const SdrTextObj* SdrOutliner::GetTextObj() const
+{
+ if( mpTextObj.is() )
+ return static_cast< SdrTextObj* >( mpTextObj.get() );
+ else
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdoutlinercache.cxx b/svx/source/svdraw/svdoutlinercache.cxx
new file mode 100644
index 000000000000..9d96e2a5ad2c
--- /dev/null
+++ b/svx/source/svdraw/svdoutlinercache.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+
+#include "svdoutlinercache.hxx"
+#include <svx/svdoutl.hxx>
+#include <svx/svdmodel.hxx>
+
+extern SdrOutliner* SdrMakeOutliner( USHORT nOutlinerMode, SdrModel* pModel );
+
+SdrOutlinerCache::SdrOutlinerCache( SdrModel* pModel )
+: mpModel( pModel ),
+ mpModeOutline( NULL ),
+ mpModeText( NULL )
+{
+}
+
+SdrOutliner* SdrOutlinerCache::createOutliner( sal_uInt16 nOutlinerMode )
+{
+ SdrOutliner* pOutliner = NULL;
+
+ if( (OUTLINERMODE_OUTLINEOBJECT == nOutlinerMode) && mpModeOutline )
+ {
+ pOutliner = mpModeOutline;
+ mpModeOutline = NULL;
+ }
+ else if( (OUTLINERMODE_TEXTOBJECT == nOutlinerMode) && mpModeText )
+ {
+ pOutliner = mpModeText;
+ mpModeText = NULL;
+ }
+ else
+ {
+ pOutliner = SdrMakeOutliner( nOutlinerMode, mpModel );
+ Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
+ pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
+ }
+
+ return pOutliner;
+}
+
+SdrOutlinerCache::~SdrOutlinerCache()
+{
+ if( mpModeOutline )
+ {
+ delete mpModeOutline;
+ mpModeOutline = NULL;
+ }
+
+ if( mpModeText )
+ {
+ delete mpModeText;
+ mpModeText = NULL;
+ }
+}
+
+void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner )
+{
+ if( pOutliner )
+ {
+ USHORT nOutlMode = pOutliner->GetOutlinerMode();
+
+ if( (OUTLINERMODE_OUTLINEOBJECT == nOutlMode) && (NULL == mpModeOutline) )
+ {
+ mpModeOutline = pOutliner;
+ pOutliner->Clear();
+ pOutliner->SetVertical( false );
+
+ // #101088# Deregister on outliner, might be reused from outliner cache
+ pOutliner->SetNotifyHdl( Link() );
+ }
+ else if( (OUTLINERMODE_TEXTOBJECT == nOutlMode) && (NULL == mpModeText) )
+ {
+ mpModeText = pOutliner;
+ pOutliner->Clear();
+ pOutliner->SetVertical( false );
+
+ // #101088# Deregister on outliner, might be reused from outliner cache
+ pOutliner->SetNotifyHdl( Link() );
+ }
+ else
+ {
+ delete pOutliner;
+ }
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx
new file mode 100644
index 000000000000..ef9e8337abe8
--- /dev/null
+++ b/svx/source/svdraw/svdovirt.cxx
@@ -0,0 +1,662 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdovirt.hxx>
+#include <svx/xpool.hxx>
+#include <svx/svdtrans.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdhdl.hxx>
+#include <svx/sdr/contact/viewcontactofvirtobj.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svddrgv.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sdr::properties::BaseProperties& SdrVirtObj::GetProperties() const
+{
+ return rRefObj.GetProperties();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// AW, OD 2004-05-03 #i27224#
+sdr::contact::ViewContact* SdrVirtObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfVirtObj(*this);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrVirtObj,SdrObject);
+
+SdrVirtObj::SdrVirtObj(SdrObject& rNewObj):
+ rRefObj(rNewObj)
+{
+ bVirtObj=TRUE; // Ja, ich bin ein virtuelles Objekt
+ rRefObj.AddReference(*this);
+ bClosedObj=rRefObj.IsClosedObj();
+}
+
+SdrVirtObj::SdrVirtObj(SdrObject& rNewObj, const Point& rAnchorPos):
+ rRefObj(rNewObj)
+{
+ aAnchor=rAnchorPos;
+ bVirtObj=TRUE; // Ja, ich bin ein virtuelles Objekt
+ rRefObj.AddReference(*this);
+ bClosedObj=rRefObj.IsClosedObj();
+}
+
+SdrVirtObj::~SdrVirtObj()
+{
+ rRefObj.DelReference(*this);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+const SdrObject& SdrVirtObj::GetReferencedObj() const
+{
+ return rRefObj;
+}
+
+SdrObject& SdrVirtObj::ReferencedObj()
+{
+ return rRefObj;
+}
+
+void __EXPORT SdrVirtObj::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/)
+{
+ bClosedObj=rRefObj.IsClosedObj();
+ SetRectsDirty(); // hier noch Optimieren.
+
+ // Only a repaint here, rRefObj may have changed and broadcasts
+ ActionChanged();
+ // BroadcastObjectChange();
+}
+
+void SdrVirtObj::NbcSetAnchorPos(const Point& rAnchorPos)
+{
+ aAnchor=rAnchorPos;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrVirtObj::SetModel(SdrModel* pNewModel)
+{
+ SdrObject::SetModel(pNewModel);
+ rRefObj.SetModel(pNewModel);
+}
+
+void SdrVirtObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rRefObj.TakeObjInfo(rInfo);
+}
+
+UINT32 SdrVirtObj::GetObjInventor() const
+{
+ return rRefObj.GetObjInventor();
+}
+
+UINT16 SdrVirtObj::GetObjIdentifier() const
+{
+ return rRefObj.GetObjIdentifier();
+}
+
+SdrObjList* SdrVirtObj::GetSubList() const
+{
+ return rRefObj.GetSubList();
+}
+
+const Rectangle& SdrVirtObj::GetCurrentBoundRect() const
+{
+ ((SdrVirtObj*)this)->aOutRect=rRefObj.GetCurrentBoundRect(); // Hier noch optimieren
+ ((SdrVirtObj*)this)->aOutRect+=aAnchor;
+ return aOutRect;
+}
+
+const Rectangle& SdrVirtObj::GetLastBoundRect() const
+{
+ ((SdrVirtObj*)this)->aOutRect=rRefObj.GetLastBoundRect(); // Hier noch optimieren
+ ((SdrVirtObj*)this)->aOutRect+=aAnchor;
+ return aOutRect;
+}
+
+void SdrVirtObj::RecalcBoundRect()
+{
+ aOutRect=rRefObj.GetCurrentBoundRect();
+ aOutRect+=aAnchor;
+}
+
+void SdrVirtObj::SetChanged()
+{
+ SdrObject::SetChanged();
+}
+
+SdrObject* SdrVirtObj::Clone() const
+{
+ SdrObject* pObj=new SdrVirtObj(((SdrVirtObj*)this)->rRefObj); // Nur eine weitere Referenz
+ return pObj;
+}
+
+void SdrVirtObj::operator=(const SdrObject& rObj)
+{ // ???anderes Objekt referenzieren???
+ SdrObject::operator=(rObj);
+ aAnchor=((SdrVirtObj&)rObj).aAnchor;
+}
+
+void SdrVirtObj::TakeObjNameSingul(XubString& rName) const
+{
+ rRefObj.TakeObjNameSingul(rName);
+ rName.Insert(sal_Unicode('['), 0);
+ rName += sal_Unicode(']');
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+void SdrVirtObj::TakeObjNamePlural(XubString& rName) const
+{
+ rRefObj.TakeObjNamePlural(rName);
+ rName.Insert(sal_Unicode('['), 0);
+ rName += sal_Unicode(']');
+}
+
+void operator +=(PolyPolygon& rPoly, const Point& rOfs)
+{
+ if (rOfs.X()!=0 || rOfs.Y()!=0) {
+ USHORT i,j;
+ for (j=0; j<rPoly.Count(); j++) {
+ Polygon aP1(rPoly.GetObject(j));
+ for (i=0; i<aP1.GetSize(); i++) {
+ aP1[i]+=rOfs;
+ }
+ rPoly.Replace(aP1,j);
+ }
+ }
+}
+
+basegfx::B2DPolyPolygon SdrVirtObj::TakeXorPoly() const
+{
+ basegfx::B2DPolyPolygon aPolyPolygon(rRefObj.TakeXorPoly());
+
+ if(aAnchor.X() || aAnchor.Y())
+ {
+ aPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(aAnchor.X(), aAnchor.Y()));
+ }
+
+ return aPolyPolygon;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_uInt32 SdrVirtObj::GetHdlCount() const
+{
+ return rRefObj.GetHdlCount();
+}
+
+SdrHdl* SdrVirtObj::GetHdl(sal_uInt32 nHdlNum) const
+{
+ SdrHdl* pHdl=rRefObj.GetHdl(nHdlNum);
+
+ // #i73248#
+ // GetHdl() at SdrObject is not guaranteed to return an object
+ if(pHdl)
+ {
+ Point aP(pHdl->GetPos()+aAnchor);
+ pHdl->SetPos(aP);
+ }
+
+ return pHdl;
+}
+
+sal_uInt32 SdrVirtObj::GetPlusHdlCount(const SdrHdl& rHdl) const
+{
+ return rRefObj.GetPlusHdlCount(rHdl);
+}
+
+SdrHdl* SdrVirtObj::GetPlusHdl(const SdrHdl& rHdl, sal_uInt32 nPlNum) const
+{
+ SdrHdl* pHdl=rRefObj.GetPlusHdl(rHdl,nPlNum);
+ pHdl->SetPos(pHdl->GetPos() + aAnchor);
+ return pHdl;
+}
+
+void SdrVirtObj::AddToHdlList(SdrHdlList& rHdlList) const
+{
+ // #i73248#
+ // SdrObject::AddToHdlList(rHdlList) is not a good thing to call
+ // since at SdrPathObj, only AddToHdlList may be used and the call
+ // will instead use the standard implementation which uses GetHdlCount()
+ // and GetHdl instead. This is not wrong, but may be much less effective
+ // and may not be prepared to GetHdl returning NULL
+
+ // get handles using AddToHdlList from ref object
+ SdrHdlList aLocalList(0);
+ rRefObj.AddToHdlList(aLocalList);
+ const sal_uInt32 nHdlCount(aLocalList.GetHdlCount());
+
+ if(nHdlCount)
+ {
+ // translate handles and add them to dest list. They are temporarily part of
+ // two lists then
+ const Point aOffset(GetOffset());
+
+ for(sal_uInt32 a(0L); a < nHdlCount; a++)
+ {
+ SdrHdl* pCandidate = aLocalList.GetHdl(a);
+ pCandidate->SetPos(pCandidate->GetPos() + aOffset);
+ rHdlList.AddHdl(pCandidate);
+ }
+
+ // remove them from source list, else they will be deleted when
+ // source list is deleted
+ while(aLocalList.GetHdlCount())
+ {
+ aLocalList.RemoveHdl(aLocalList.GetHdlCount() - 1L);
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrVirtObj::hasSpecialDrag() const
+{
+ return rRefObj.hasSpecialDrag();
+}
+
+bool SdrVirtObj::supportsFullDrag() const
+{
+ return false;
+}
+
+SdrObject* SdrVirtObj::getFullDragClone() const
+{
+ static bool bSpecialHandling(false);
+ SdrObject* pRetval = 0;
+
+ if(bSpecialHandling)
+ {
+ // special handling for VirtObj. Do not create another
+ // reference to rRefObj, this would allow to change that
+ // one on drag. Instead, create a SdrGrafObj for drag containing
+ // the graphical representation
+ pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), this), GetLogicRect());
+ }
+ else
+ {
+ SdrObject& rReferencedObject = ((SdrVirtObj*)this)->ReferencedObj();
+ pRetval = new SdrGrafObj(SdrDragView::GetObjGraphic(GetModel(), &rReferencedObject), GetLogicRect());
+ }
+
+ return pRetval;
+}
+
+bool SdrVirtObj::beginSpecialDrag(SdrDragStat& rDrag) const
+{
+ return rRefObj.beginSpecialDrag(rDrag);
+}
+
+bool SdrVirtObj::applySpecialDrag(SdrDragStat& rDrag)
+{
+ return rRefObj.applySpecialDrag(rDrag);
+}
+
+basegfx::B2DPolyPolygon SdrVirtObj::getSpecialDragPoly(const SdrDragStat& rDrag) const
+{
+ return rRefObj.getSpecialDragPoly(rDrag);
+ // Offset handlen !!!!!! fehlt noch !!!!!!!
+}
+
+String SdrVirtObj::getSpecialDragComment(const SdrDragStat& rDrag) const
+{
+ return rRefObj.getSpecialDragComment(rDrag);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrVirtObj::BegCreate(SdrDragStat& rStat)
+{
+ return rRefObj.BegCreate(rStat);
+}
+
+bool SdrVirtObj::MovCreate(SdrDragStat& rStat)
+{
+ return rRefObj.MovCreate(rStat);
+}
+
+bool SdrVirtObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ return rRefObj.EndCreate(rStat,eCmd);
+}
+
+bool SdrVirtObj::BckCreate(SdrDragStat& rStat)
+{
+ return rRefObj.BckCreate(rStat);
+}
+
+void SdrVirtObj::BrkCreate(SdrDragStat& rStat)
+{
+ rRefObj.BrkCreate(rStat);
+}
+
+basegfx::B2DPolyPolygon SdrVirtObj::TakeCreatePoly(const SdrDragStat& rDrag) const
+{
+ return rRefObj.TakeCreatePoly(rDrag);
+ // Offset handlen !!!!!! fehlt noch !!!!!!!
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrVirtObj::NbcMove(const Size& rSiz)
+{
+ MovePoint(aAnchor,rSiz);
+ SetRectsDirty();
+}
+
+void SdrVirtObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ rRefObj.NbcResize(rRef-aAnchor,xFact,yFact);
+ SetRectsDirty();
+}
+
+void SdrVirtObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ rRefObj.NbcRotate(rRef-aAnchor,nWink,sn,cs);
+ SetRectsDirty();
+}
+
+void SdrVirtObj::NbcMirror(const Point& rRef1, const Point& rRef2)
+{
+ rRefObj.NbcMirror(rRef1-aAnchor,rRef2-aAnchor);
+ SetRectsDirty();
+}
+
+void SdrVirtObj::NbcShear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ rRefObj.NbcShear(rRef-aAnchor,nWink,tn,bVShear);
+ SetRectsDirty();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrVirtObj::Move(const Size& rSiz)
+{
+ if (rSiz.Width()!=0 || rSiz.Height()!=0) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ // #110094#-14 SendRepaintBroadcast();
+ NbcMove(rSiz);
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_MOVEONLY,aBoundRect0);
+ }
+}
+
+void SdrVirtObj::Resize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ if (xFact.GetNumerator()!=xFact.GetDenominator() || yFact.GetNumerator()!=yFact.GetDenominator()) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ rRefObj.Resize(rRef-aAnchor,xFact,yFact);
+ SetRectsDirty();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+void SdrVirtObj::Rotate(const Point& rRef, long nWink, double sn, double cs)
+{
+ if (nWink!=0) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ rRefObj.Rotate(rRef-aAnchor,nWink,sn,cs);
+ SetRectsDirty();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+void SdrVirtObj::Mirror(const Point& rRef1, const Point& rRef2)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ rRefObj.Mirror(rRef1-aAnchor,rRef2-aAnchor);
+ SetRectsDirty();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+void SdrVirtObj::Shear(const Point& rRef, long nWink, double tn, bool bVShear)
+{
+ if (nWink!=0) {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ rRefObj.Shear(rRef-aAnchor,nWink,tn,bVShear);
+ SetRectsDirty();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrVirtObj::RecalcSnapRect()
+{
+ aSnapRect=rRefObj.GetSnapRect();
+ aSnapRect+=aAnchor;
+}
+
+const Rectangle& SdrVirtObj::GetSnapRect() const
+{
+ ((SdrVirtObj*)this)->aSnapRect=rRefObj.GetSnapRect();
+ ((SdrVirtObj*)this)->aSnapRect+=aAnchor;
+ return aSnapRect;
+}
+
+void SdrVirtObj::SetSnapRect(const Rectangle& rRect)
+{
+ {
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ Rectangle aR(rRect);
+ aR-=aAnchor;
+ rRefObj.SetSnapRect(aR);
+ SetRectsDirty();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+}
+
+void SdrVirtObj::NbcSetSnapRect(const Rectangle& rRect)
+{
+ Rectangle aR(rRect);
+ aR-=aAnchor;
+ SetRectsDirty();
+ rRefObj.NbcSetSnapRect(aR);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+const Rectangle& SdrVirtObj::GetLogicRect() const
+{
+ ((SdrVirtObj*)this)->aSnapRect=rRefObj.GetLogicRect(); // !!! Missbrauch von aSnapRect !!!
+ ((SdrVirtObj*)this)->aSnapRect+=aAnchor; // Wenns mal Aerger gibt, muss ein weiteres Rectangle Member her (oder Heap)
+ return aSnapRect;
+}
+
+void SdrVirtObj::SetLogicRect(const Rectangle& rRect)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ Rectangle aR(rRect);
+ aR-=aAnchor;
+ rRefObj.SetLogicRect(aR);
+ SetRectsDirty();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+void SdrVirtObj::NbcSetLogicRect(const Rectangle& rRect)
+{
+ Rectangle aR(rRect);
+ aR-=aAnchor;
+ SetRectsDirty();
+ rRefObj.NbcSetLogicRect(aR);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+long SdrVirtObj::GetRotateAngle() const
+{
+ return rRefObj.GetRotateAngle();
+}
+
+long SdrVirtObj::GetShearAngle(bool bVertical) const
+{
+ return rRefObj.GetShearAngle(bVertical);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_uInt32 SdrVirtObj::GetSnapPointCount() const
+{
+ return rRefObj.GetSnapPointCount();
+}
+
+Point SdrVirtObj::GetSnapPoint(sal_uInt32 i) const
+{
+ Point aP(rRefObj.GetSnapPoint(i));
+ aP+=aAnchor;
+ return aP;
+}
+
+sal_Bool SdrVirtObj::IsPolyObj() const
+{
+ return rRefObj.IsPolyObj();
+}
+
+sal_uInt32 SdrVirtObj::GetPointCount() const
+{
+ return rRefObj.GetPointCount();
+}
+
+Point SdrVirtObj::GetPoint(sal_uInt32 i) const
+{
+ return Point(rRefObj.GetPoint(i) + aAnchor);
+}
+
+void SdrVirtObj::NbcSetPoint(const Point& rPnt, sal_uInt32 i)
+{
+ Point aP(rPnt);
+ aP-=aAnchor;
+ rRefObj.SetPoint(aP,i);
+ SetRectsDirty();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrObjGeoData* SdrVirtObj::NewGeoData() const
+{
+ return rRefObj.NewGeoData();
+}
+
+void SdrVirtObj::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ rRefObj.SaveGeoData(rGeo);
+}
+
+void SdrVirtObj::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ rRefObj.RestGeoData(rGeo);
+ SetRectsDirty();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrObjGeoData* SdrVirtObj::GetGeoData() const
+{
+ return rRefObj.GetGeoData();
+}
+
+void SdrVirtObj::SetGeoData(const SdrObjGeoData& rGeo)
+{
+ Rectangle aBoundRect0; if (pUserCall!=NULL) aBoundRect0=GetLastBoundRect();
+ rRefObj.SetGeoData(rGeo);
+ SetRectsDirty();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrVirtObj::NbcReformatText()
+{
+ rRefObj.NbcReformatText();
+}
+
+void SdrVirtObj::ReformatText()
+{
+ rRefObj.ReformatText();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+bool SdrVirtObj::HasMacro() const
+{
+ return rRefObj.HasMacro();
+}
+
+SdrObject* SdrVirtObj::CheckMacroHit(const SdrObjMacroHitRec& rRec) const
+{
+ return rRefObj.CheckMacroHit(rRec); // Todo: Positionsversatz
+}
+
+Pointer SdrVirtObj::GetMacroPointer(const SdrObjMacroHitRec& rRec) const
+{
+ return rRefObj.GetMacroPointer(rRec); // Todo: Positionsversatz
+}
+
+void SdrVirtObj::PaintMacro(OutputDevice& rOut, const Rectangle& rDirtyRect, const SdrObjMacroHitRec& rRec) const
+{
+ rRefObj.PaintMacro(rOut,rDirtyRect,rRec); // Todo: Positionsversatz
+}
+
+bool SdrVirtObj::DoMacro(const SdrObjMacroHitRec& rRec)
+{
+ return rRefObj.DoMacro(rRec); // Todo: Positionsversatz
+}
+
+XubString SdrVirtObj::GetMacroPopupComment(const SdrObjMacroHitRec& rRec) const
+{
+ return rRefObj.GetMacroPopupComment(rRec); // Todo: Positionsversatz
+}
+
+const Point SdrVirtObj::GetOffset() const
+{
+ // #i73248# default offset of SdrVirtObj is aAnchor
+ return aAnchor;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
new file mode 100644
index 000000000000..43de1fda0230
--- /dev/null
+++ b/svx/source/svdraw/svdpage.cxx
@@ -0,0 +1,2035 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdpage.hxx>
+
+// HACK
+#include <sot/storage.hxx>
+#include <sot/clsids.hxx>
+#include <sot/storage.hxx>
+#include <svx/svdview.hxx>
+#include <string.h>
+#ifndef _STRING_H
+#define _STRING_H
+#endif
+#include <vcl/svapp.hxx>
+
+#include <tools/diagnose_ex.h>
+
+#include <svx/svdetc.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdograf.hxx> // fuer SwapInAll()
+#include <svx/svdoedge.hxx> // Zum kopieren der Konnektoren
+#include <svx/svdoole2.hxx> // Sonderbehandlung OLE beim SdrExchangeFormat
+#include "svditer.hxx"
+#include <svx/svdmodel.hxx>
+#include <svx/svdlayer.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/polysc3d.hxx>
+
+#include <svx/fmdpage.hxx>
+
+#include <sfx2/objsh.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include <svx/sdr/contact/viewcontactofsdrpage.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <algorithm>
+#include <svl/smplhint.hxx>
+
+using namespace ::com::sun::star;
+
+namespace {
+void DumpObjectList (const ::std::vector<SdrObjectWeakRef>& rContainer)
+{
+ ::std::vector<SdrObjectWeakRef>::const_iterator iObject (rContainer.begin());
+ ::std::vector<SdrObjectWeakRef>::const_iterator iEnd (rContainer.end());
+ for (int nIndex=0 ; iObject!=iEnd; ++iObject,++nIndex)
+ {
+ const SdrObject* pObject = iObject->get();
+ OSL_TRACE("%d : %x, %s", nIndex,
+ pObject,
+ ::rtl::OUStringToOString(pObject->GetName(),RTL_TEXTENCODING_UTF8).getStr());
+ }
+}
+}
+
+
+class SdrObjList::WeakSdrObjectContainerType
+ : public ::std::vector<SdrObjectWeakRef>
+{
+public:
+ WeakSdrObjectContainerType (const sal_Int32 nInitialSize)
+ : ::std::vector<SdrObjectWeakRef>(nInitialSize) {};
+};
+
+
+
+static const sal_Int32 InitialObjectContainerCapacity (64);
+DBG_NAME(SdrObjList)
+
+TYPEINIT0(SdrObjList);
+
+SdrObjList::SdrObjList(SdrModel* pNewModel, SdrPage* pNewPage, SdrObjList* pNewUpList):
+ maList(),
+ mpNavigationOrder(),
+ mbIsNavigationOrderDirty(false)
+{
+ DBG_CTOR(SdrObjList,NULL);
+ maList.reserve(InitialObjectContainerCapacity);
+ pModel=pNewModel;
+ pPage=pNewPage;
+ pUpList=pNewUpList;
+ bObjOrdNumsDirty=FALSE;
+ bRectsDirty=FALSE;
+ pOwnerObj=NULL;
+ eListKind=SDROBJLIST_UNKNOWN;
+}
+
+SdrObjList::SdrObjList(const SdrObjList& rSrcList):
+ maList(),
+ mpNavigationOrder(),
+ mbIsNavigationOrderDirty(false)
+{
+ DBG_CTOR(SdrObjList,NULL);
+ maList.reserve(InitialObjectContainerCapacity);
+ pModel=NULL;
+ pPage=NULL;
+ pUpList=NULL;
+ bObjOrdNumsDirty=FALSE;
+ bRectsDirty=FALSE;
+ pOwnerObj=NULL;
+ eListKind=SDROBJLIST_UNKNOWN;
+ *this=rSrcList;
+}
+
+SdrObjList::~SdrObjList()
+{
+ DBG_DTOR(SdrObjList,NULL);
+
+ // #111111#
+ // To avoid that the Clear() method will broadcast changes when in destruction
+ // which would call virtual methos (not allowed in destructor), the model is set
+ // to NULL here.
+ pModel = 0L;
+
+ Clear(); // Containerinhalt loeschen!
+}
+
+void SdrObjList::operator=(const SdrObjList& rSrcList)
+{
+ Clear();
+ eListKind=rSrcList.eListKind;
+ CopyObjects(rSrcList);
+}
+
+void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
+{
+ Clear();
+ bObjOrdNumsDirty=FALSE;
+ bRectsDirty =FALSE;
+ ULONG nCloneErrCnt=0;
+ ULONG nAnz=rSrcList.GetObjCount();
+ SdrInsertReason aReason(SDRREASON_COPY);
+ ULONG no;
+ for (no=0; no<nAnz; no++) {
+ SdrObject* pSO=rSrcList.GetObj(no);
+
+ // #116235#
+ //SdrObject* pDO=pSO->Clone(pPage,pModel);
+ SdrObject* pDO = pSO->Clone();
+ pDO->SetModel(pModel);
+ pDO->SetPage(pPage);
+
+ if (pDO!=NULL) {
+ NbcInsertObject(pDO,CONTAINER_APPEND,&aReason);
+ } else {
+ nCloneErrCnt++;
+ }
+ }
+ // und nun zu den Konnektoren
+ // Die neuen Objekte werden auf die der rSrcList abgebildet
+ // und so die Objektverbindungen hergestellt.
+ // Aehnliche Implementation an folgenden Stellen:
+ // void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
+ // SdrModel* SdrExchangeView::GetMarkedObjModel() const
+ // FASTBOOL SdrExchangeView::Paste(const SdrModel& rMod,...)
+ // void SdrEditView::CopyMarked()
+ if (nCloneErrCnt==0) {
+ for (no=0; no<nAnz; no++) {
+ const SdrObject* pSrcOb=rSrcList.GetObj(no);
+ SdrEdgeObj* pSrcEdge=PTR_CAST(SdrEdgeObj,pSrcOb);
+ if (pSrcEdge!=NULL) {
+ SdrObject* pSrcNode1=pSrcEdge->GetConnectedNode(TRUE);
+ SdrObject* pSrcNode2=pSrcEdge->GetConnectedNode(FALSE);
+ if (pSrcNode1!=NULL && pSrcNode1->GetObjList()!=pSrcEdge->GetObjList()) pSrcNode1=NULL; // Listenuebergreifend
+ if (pSrcNode2!=NULL && pSrcNode2->GetObjList()!=pSrcEdge->GetObjList()) pSrcNode2=NULL; // ist (noch) nicht
+ if (pSrcNode1!=NULL || pSrcNode2!=NULL) {
+ SdrObject* pEdgeObjTmp=GetObj(no);
+ SdrEdgeObj* pDstEdge=PTR_CAST(SdrEdgeObj,pEdgeObjTmp);
+ if (pDstEdge!=NULL) {
+ if (pSrcNode1!=NULL) {
+ ULONG nDstNode1=pSrcNode1->GetOrdNum();
+ SdrObject* pDstNode1=GetObj(nDstNode1);
+ if (pDstNode1!=NULL) { // Sonst grober Fehler!
+ pDstEdge->ConnectToNode(TRUE,pDstNode1);
+ } else {
+ DBG_ERROR("SdrObjList::operator=(): pDstNode1==NULL!");
+ }
+ }
+ if (pSrcNode2!=NULL) {
+ ULONG nDstNode2=pSrcNode2->GetOrdNum();
+ SdrObject* pDstNode2=GetObj(nDstNode2);
+ if (pDstNode2!=NULL) { // Node war sonst wohl nicht markiert
+ pDstEdge->ConnectToNode(FALSE,pDstNode2);
+ } else {
+ DBG_ERROR("SdrObjList::operator=(): pDstNode2==NULL!");
+ }
+ }
+ } else {
+ DBG_ERROR("SdrObjList::operator=(): pDstEdge==NULL!");
+ }
+ }
+ }
+ }
+ } else {
+#ifdef DBG_UTIL
+ ByteString aStr("SdrObjList::operator=(): Fehler beim Clonen ");
+
+ if(nCloneErrCnt == 1)
+ {
+ aStr += "eines Zeichenobjekts.";
+ }
+ else
+ {
+ aStr += "von ";
+ aStr += ByteString::CreateFromInt32( nCloneErrCnt );
+ aStr += " Zeichenobjekten.";
+ }
+
+ aStr += " Objektverbindungen werden nicht mitkopiert.";
+
+ DBG_ERROR(aStr.GetBuffer());
+#endif
+ }
+}
+
+void SdrObjList::Clear()
+{
+ sal_Bool bObjectsRemoved(sal_False);
+
+ while( ! maList.empty())
+ {
+ // remove last object from list
+ SdrObject* pObj = maList.back();
+ RemoveObjectFromContainer(maList.size()-1);
+
+ // flushViewObjectContacts() is done since SdrObject::Free is not guaranteed
+ // to delete the object and thus refresh visualisations
+ pObj->GetViewContact().flushViewObjectContacts(true);
+
+ bObjectsRemoved = sal_True;
+
+ // sent remove hint (after removal, see RemoveObject())
+ if(pModel)
+ {
+ SdrHint aHint(*pObj);
+ aHint.SetKind(HINT_OBJREMOVED);
+ aHint.SetPage(pPage);
+ pModel->Broadcast(aHint);
+ }
+
+ // delete the object itself
+ SdrObject::Free( pObj );
+ }
+
+ if(pModel && bObjectsRemoved)
+ {
+ pModel->SetChanged();
+ }
+}
+
+SdrPage* SdrObjList::GetPage() const
+{
+ return pPage;
+}
+
+void SdrObjList::SetPage(SdrPage* pNewPage)
+{
+ if (pPage!=pNewPage) {
+ pPage=pNewPage;
+ ULONG nAnz=GetObjCount();
+ for (ULONG no=0; no<nAnz; no++) {
+ SdrObject* pObj=GetObj(no);
+ pObj->SetPage(pPage);
+ }
+ }
+}
+
+SdrModel* SdrObjList::GetModel() const
+{
+ return pModel;
+}
+
+void SdrObjList::SetModel(SdrModel* pNewModel)
+{
+ if (pModel!=pNewModel) {
+ pModel=pNewModel;
+ ULONG nAnz=GetObjCount();
+ for (ULONG i=0; i<nAnz; i++) {
+ SdrObject* pObj=GetObj(i);
+ pObj->SetModel(pModel);
+ }
+ }
+}
+
+void SdrObjList::RecalcObjOrdNums()
+{
+ ULONG nAnz=GetObjCount();
+ for (ULONG no=0; no<nAnz; no++) {
+ SdrObject* pObj=GetObj(no);
+ pObj->SetOrdNum(no);
+ }
+ bObjOrdNumsDirty=FALSE;
+}
+
+void SdrObjList::RecalcRects()
+{
+ aOutRect=Rectangle();
+ aSnapRect=aOutRect;
+ ULONG nAnz=GetObjCount();
+ ULONG i;
+ for (i=0; i<nAnz; i++) {
+ SdrObject* pObj=GetObj(i);
+ if (i==0) {
+ aOutRect=pObj->GetCurrentBoundRect();
+ aSnapRect=pObj->GetSnapRect();
+ } else {
+ aOutRect.Union(pObj->GetCurrentBoundRect());
+ aSnapRect.Union(pObj->GetSnapRect());
+ }
+ }
+}
+
+void SdrObjList::SetRectsDirty()
+{
+ bRectsDirty=TRUE;
+ if (pUpList!=NULL) pUpList->SetRectsDirty();
+}
+
+void SdrObjList::impChildInserted(SdrObject& rChild) const
+{
+ sdr::contact::ViewContact* pParent = rChild.GetViewContact().GetParentContact();
+
+ if(pParent)
+ {
+ pParent->ActionChildInserted(rChild.GetViewContact());
+ }
+}
+
+void SdrObjList::NbcInsertObject(SdrObject* pObj, ULONG nPos, const SdrInsertReason* /*pReason*/)
+{
+ DBG_ASSERT(pObj!=NULL,"SdrObjList::NbcInsertObject(NULL)");
+ if (pObj!=NULL) {
+ DBG_ASSERT(!pObj->IsInserted(),"ZObjekt hat bereits Inserted-Status");
+ ULONG nAnz=GetObjCount();
+ if (nPos>nAnz) nPos=nAnz;
+ InsertObjectIntoContainer(*pObj,nPos);
+
+ if (nPos<nAnz) bObjOrdNumsDirty=TRUE;
+ pObj->SetOrdNum(nPos);
+ pObj->SetObjList(this);
+ pObj->SetPage(pPage);
+
+ // #110094# Inform the parent about change to allow invalidations at
+ // evtl. existing parent visualisations
+ impChildInserted(*pObj);
+
+ if (!bRectsDirty) {
+ aOutRect.Union(pObj->GetCurrentBoundRect());
+ aSnapRect.Union(pObj->GetSnapRect());
+ }
+ pObj->SetInserted(TRUE); // Ruft u.a. den UserCall
+ }
+}
+
+void SdrObjList::InsertObject(SdrObject* pObj, ULONG nPos, const SdrInsertReason* pReason)
+{
+ DBG_ASSERT(pObj!=NULL,"SdrObjList::InsertObject(NULL)");
+
+ if(pObj)
+ {
+ // #69055# if anchor is used, reset it before grouping
+ if(GetOwnerObj())
+ {
+ const Point& rAnchorPos = pObj->GetAnchorPos();
+ if(rAnchorPos.X() || rAnchorPos.Y())
+ pObj->NbcSetAnchorPos(Point());
+ }
+
+ // do insert to new group
+ NbcInsertObject(pObj, nPos, pReason);
+
+ // Falls das Objekt in eine Gruppe eingefuegt wird
+ // und nicht mit seinen Bruedern ueberlappt, muss es
+ // einen eigenen Redraw bekommen
+ if(pOwnerObj)
+ {
+ // only repaint here
+ pOwnerObj->ActionChanged();
+ }
+
+ if(pModel)
+ {
+ // Hier muss ein anderer Broadcast her!
+ // Repaint ab Objekt Nummer ... (Achtung: GroupObj)
+ if(pObj->GetPage())
+ {
+ SdrHint aHint(*pObj);
+
+ aHint.SetKind(HINT_OBJINSERTED);
+ pModel->Broadcast(aHint);
+ }
+
+ pModel->SetChanged();
+ }
+ }
+}
+
+SdrObject* SdrObjList::NbcRemoveObject(ULONG nObjNum)
+{
+ if (nObjNum >= maList.size())
+ {
+ OSL_ASSERT(nObjNum<maList.size());
+ return NULL;
+ }
+
+ ULONG nAnz=GetObjCount();
+ SdrObject* pObj=maList[nObjNum];
+ RemoveObjectFromContainer(nObjNum);
+
+ // flushViewObjectContacts() clears the VOC's and those invalidate
+ pObj->GetViewContact().flushViewObjectContacts(true);
+
+ DBG_ASSERT(pObj!=NULL,"Object zum Removen nicht gefunden");
+ if (pObj!=NULL) {
+ DBG_ASSERT(pObj->IsInserted(),"ZObjekt hat keinen Inserted-Status");
+ pObj->SetInserted(FALSE); // Ruft u.a. den UserCall
+ pObj->SetObjList(NULL);
+ pObj->SetPage(NULL);
+ if (!bObjOrdNumsDirty) { // Optimierung fuer den Fall, dass das letzte Obj rausgenommen wird
+ if (nObjNum!=ULONG(nAnz-1)) {
+ bObjOrdNumsDirty=TRUE;
+ }
+ }
+ SetRectsDirty();
+ }
+ return pObj;
+}
+
+SdrObject* SdrObjList::RemoveObject(ULONG nObjNum)
+{
+ if (nObjNum >= maList.size())
+ {
+ OSL_ASSERT(nObjNum<maList.size());
+ return NULL;
+ }
+
+ ULONG nAnz=GetObjCount();
+ SdrObject* pObj=maList[nObjNum];
+ RemoveObjectFromContainer(nObjNum);
+
+ DBG_ASSERT(pObj!=NULL,"Object zum Removen nicht gefunden");
+ if(pObj)
+ {
+ // flushViewObjectContacts() clears the VOC's and those invalidate
+ pObj->GetViewContact().flushViewObjectContacts(true);
+
+ DBG_ASSERT(pObj->IsInserted(),"ZObjekt hat keinen Inserted-Status");
+ if (pModel!=NULL) {
+ // Hier muss ein anderer Broadcast her!
+ if (pObj->GetPage()!=NULL) {
+ SdrHint aHint(*pObj);
+ aHint.SetKind(HINT_OBJREMOVED);
+ pModel->Broadcast(aHint);
+ }
+ pModel->SetChanged();
+ }
+ pObj->SetInserted(FALSE); // Ruft u.a. den UserCall
+ pObj->SetObjList(NULL);
+ pObj->SetPage(NULL);
+ if (!bObjOrdNumsDirty) { // Optimierung fuer den Fall, dass das letzte Obj rausgenommen wird
+ if (nObjNum!=ULONG(nAnz-1)) {
+ bObjOrdNumsDirty=TRUE;
+ }
+ }
+ SetRectsDirty();
+
+ if(pOwnerObj && !GetObjCount())
+ {
+ // empty group created; it needs to be repainted since it's
+ // visualisation changes
+ pOwnerObj->ActionChanged();
+ }
+ }
+ return pObj;
+}
+
+SdrObject* SdrObjList::NbcReplaceObject(SdrObject* pNewObj, ULONG nObjNum)
+{
+ if (nObjNum >= maList.size() || pNewObj == NULL)
+ {
+ OSL_ASSERT(nObjNum<maList.size());
+ OSL_ASSERT(pNewObj!=NULL);
+ return NULL;
+ }
+
+ SdrObject* pObj=maList[nObjNum];
+ DBG_ASSERT(pObj!=NULL,"SdrObjList::ReplaceObject: Object zum Removen nicht gefunden");
+ if (pObj!=NULL) {
+ DBG_ASSERT(pObj->IsInserted(),"SdrObjList::ReplaceObject: ZObjekt hat keinen Inserted-Status");
+ pObj->SetInserted(FALSE);
+ pObj->SetObjList(NULL);
+ pObj->SetPage(NULL);
+ ReplaceObjectInContainer(*pNewObj,nObjNum);
+
+ // flushViewObjectContacts() clears the VOC's and those invalidate
+ pObj->GetViewContact().flushViewObjectContacts(true);
+
+ pNewObj->SetOrdNum(nObjNum);
+ pNewObj->SetObjList(this);
+ pNewObj->SetPage(pPage);
+
+ // #110094# Inform the parent about change to allow invalidations at
+ // evtl. existing parent visualisations
+ impChildInserted(*pNewObj);
+
+ pNewObj->SetInserted(TRUE);
+ SetRectsDirty();
+ }
+ return pObj;
+}
+
+SdrObject* SdrObjList::ReplaceObject(SdrObject* pNewObj, ULONG nObjNum)
+{
+ if (nObjNum >= maList.size())
+ {
+ OSL_ASSERT(nObjNum<maList.size());
+ return NULL;
+ }
+ if (pNewObj == NULL)
+ {
+ OSL_ASSERT(pNewObj!=NULL);
+ return NULL;
+ }
+
+ SdrObject* pObj=maList[nObjNum];
+ DBG_ASSERT(pObj!=NULL,"SdrObjList::ReplaceObject: Object zum Removen nicht gefunden");
+ if (pObj!=NULL) {
+ DBG_ASSERT(pObj->IsInserted(),"SdrObjList::ReplaceObject: ZObjekt hat keinen Inserted-Status");
+ if (pModel!=NULL) {
+ // Hier muss ein anderer Broadcast her!
+ if (pObj->GetPage()!=NULL) {
+ SdrHint aHint(*pObj);
+ aHint.SetKind(HINT_OBJREMOVED);
+ pModel->Broadcast(aHint);
+ }
+ }
+ pObj->SetInserted(FALSE);
+ pObj->SetObjList(NULL);
+ pObj->SetPage(NULL);
+ ReplaceObjectInContainer(*pNewObj,nObjNum);
+
+ // flushViewObjectContacts() clears the VOC's and those invalidate
+ pObj->GetViewContact().flushViewObjectContacts(true);
+
+ pNewObj->SetOrdNum(nObjNum);
+ pNewObj->SetObjList(this);
+ pNewObj->SetPage(pPage);
+
+ // #110094# Inform the parent about change to allow invalidations at
+ // evtl. existing parent visualisations
+ impChildInserted(*pNewObj);
+
+ pNewObj->SetInserted(TRUE);
+ if (pModel!=NULL) {
+ // Hier muss ein anderer Broadcast her!
+ if (pNewObj->GetPage()!=NULL) {
+ SdrHint aHint(*pNewObj);
+ aHint.SetKind(HINT_OBJINSERTED);
+ pModel->Broadcast(aHint);
+ }
+ pModel->SetChanged();
+ }
+ SetRectsDirty();
+ }
+ return pObj;
+}
+
+SdrObject* SdrObjList::NbcSetObjectOrdNum(ULONG nOldObjNum, ULONG nNewObjNum)
+{
+ if (nOldObjNum >= maList.size() || nNewObjNum >= maList.size())
+ {
+ OSL_ASSERT(nOldObjNum<maList.size());
+ OSL_ASSERT(nNewObjNum<maList.size());
+ return NULL;
+ }
+
+ SdrObject* pObj=maList[nOldObjNum];
+ if (nOldObjNum==nNewObjNum) return pObj;
+ DBG_ASSERT(pObj!=NULL,"SdrObjList::NbcSetObjectOrdNum: Object nicht gefunden");
+ if (pObj!=NULL) {
+ DBG_ASSERT(pObj->IsInserted(),"SdrObjList::NbcSetObjectOrdNum: ZObjekt hat keinen Inserted-Status");
+ RemoveObjectFromContainer(nOldObjNum);
+
+ InsertObjectIntoContainer(*pObj,nNewObjNum);
+
+ // #110094# No need to delete visualisation data since same object
+ // gets inserted again. Also a single ActionChanged is enough
+ pObj->ActionChanged();
+
+ pObj->SetOrdNum(nNewObjNum);
+ bObjOrdNumsDirty=TRUE;
+ }
+ return pObj;
+}
+
+SdrObject* SdrObjList::SetObjectOrdNum(ULONG nOldObjNum, ULONG nNewObjNum)
+{
+ if (nOldObjNum >= maList.size() || nNewObjNum >= maList.size())
+ {
+ OSL_ASSERT(nOldObjNum<maList.size());
+ OSL_ASSERT(nNewObjNum<maList.size());
+ return NULL;
+ }
+
+ SdrObject* pObj=maList[nOldObjNum];
+ if (nOldObjNum==nNewObjNum) return pObj;
+ DBG_ASSERT(pObj!=NULL,"SdrObjList::SetObjectOrdNum: Object nicht gefunden");
+ if (pObj!=NULL) {
+ DBG_ASSERT(pObj->IsInserted(),"SdrObjList::SetObjectOrdNum: ZObjekt hat keinen Inserted-Status");
+ RemoveObjectFromContainer(nOldObjNum);
+ InsertObjectIntoContainer(*pObj,nNewObjNum);
+
+ // #110094#No need to delete visualisation data since same object
+ // gets inserted again. Also a single ActionChanged is enough
+ pObj->ActionChanged();
+
+ pObj->SetOrdNum(nNewObjNum);
+ bObjOrdNumsDirty=TRUE;
+ if (pModel!=NULL)
+ {
+ // Hier muss ein anderer Broadcast her!
+ if (pObj->GetPage()!=NULL) pModel->Broadcast(SdrHint(*pObj));
+ pModel->SetChanged();
+ }
+ }
+ return pObj;
+}
+
+const Rectangle& SdrObjList::GetAllObjSnapRect() const
+{
+ if (bRectsDirty) {
+ ((SdrObjList*)this)->RecalcRects();
+ ((SdrObjList*)this)->bRectsDirty=FALSE;
+ }
+ return aSnapRect;
+}
+
+const Rectangle& SdrObjList::GetAllObjBoundRect() const
+{
+ // #i106183# for deep group hierarchies like in chart2, the invalidates
+ // through the hierarchy are not correct; use a 2nd hint for the needed
+ // recalculation. Future versions will have no bool flag at all, but
+ // just aOutRect in empty state to representate an invalid state, thus
+ // it's a step in the right direction.
+ if (bRectsDirty || aOutRect.IsEmpty())
+ {
+ ((SdrObjList*)this)->RecalcRects();
+ ((SdrObjList*)this)->bRectsDirty=FALSE;
+ }
+ return aOutRect;
+}
+
+void SdrObjList::NbcReformatAllTextObjects()
+{
+ ULONG nAnz=GetObjCount();
+ ULONG nNum=0;
+
+ Printer* pPrinter = NULL;
+
+ if (pModel)
+ {
+ if (pModel->GetRefDevice() && pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
+ {
+ // Kein RefDevice oder RefDevice kein Printer
+ pPrinter = (Printer*) pModel->GetRefDevice();
+ }
+ }
+
+ while (nNum<nAnz)
+ {
+ SdrObject* pObj = GetObj(nNum);
+ if (pPrinter &&
+ pObj->GetObjInventor() == SdrInventor &&
+ pObj->GetObjIdentifier() == OBJ_OLE2 &&
+ !( (SdrOle2Obj*) pObj )->IsEmpty() )
+ {
+ //const SvInPlaceObjectRef& xObjRef = ((SdrOle2Obj*) pObj)->GetObjRef();
+ //TODO/LATER: PrinterChangeNotification needed
+ //if( xObjRef.Is() && ( xObjRef->GetMiscStatus() & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE ) )
+ // xObjRef->OnDocumentPrinterChanged(pPrinter);
+ }
+
+ pObj->NbcReformatText();
+ nAnz=GetObjCount(); // ReformatText may delete an object
+ nNum++;
+ }
+
+}
+
+void SdrObjList::ReformatAllTextObjects()
+{
+ NbcReformatAllTextObjects();
+}
+
+/** steps over all available objects and reformats all
+ edge objects that are connected to other objects so that
+ they may reposition itselfs.
+ #103122#
+*/
+void SdrObjList::ReformatAllEdgeObjects()
+{
+ const sal_uInt32 nCount=GetObjCount();
+ sal_uInt32 nObj;
+
+ for( nObj = 0; nObj < nCount; nObj++ )
+ {
+ SdrObject* pObj = GetObj(nObj);
+ if( pObj->ISA(SdrEdgeObj) )
+ static_cast<SdrEdgeObj*>(pObj)->Reformat();
+ }
+}
+
+void SdrObjList::BurnInStyleSheetAttributes()
+{
+ for(sal_uInt32 a(0L); a < GetObjCount(); a++)
+ {
+ GetObj(a)->BurnInStyleSheetAttributes();
+ }
+}
+
+ULONG SdrObjList::GetObjCount() const
+{
+ return maList.size();
+}
+
+
+
+
+SdrObject* SdrObjList::GetObj(ULONG nNum) const
+{
+ if (nNum >= maList.size())
+ {
+ OSL_ASSERT(nNum<maList.size());
+ return NULL;
+ }
+ else
+ return maList[nNum];
+}
+
+
+
+
+bool SdrObjList::IsReadOnly() const
+{
+ bool bRet = false;
+ if (pPage!=NULL && pPage!=this) bRet=pPage->IsReadOnly();
+ return bRet;
+}
+
+ULONG SdrObjList::CountAllObjects() const
+{
+ ULONG nCnt=GetObjCount();
+ ULONG nAnz=nCnt;
+ for (USHORT nNum=0; nNum<nAnz; nNum++) {
+ SdrObjList* pSubOL=GetObj(nNum)->GetSubList();
+ if (pSubOL!=NULL) {
+ nCnt+=pSubOL->CountAllObjects();
+ }
+ }
+ return nCnt;
+}
+
+void SdrObjList::ForceSwapInObjects() const
+{
+ ULONG nObjAnz=GetObjCount();
+ for (ULONG nObjNum=nObjAnz; nObjNum>0;) {
+ SdrObject* pObj=GetObj(--nObjNum);
+ SdrGrafObj* pGrafObj=PTR_CAST(SdrGrafObj,pObj);
+ if (pGrafObj!=NULL) {
+ pGrafObj->ForceSwapIn();
+ }
+ SdrObjList* pOL=pObj->GetSubList();
+ if (pOL!=NULL) {
+ pOL->ForceSwapInObjects();
+ }
+ }
+}
+
+void SdrObjList::ForceSwapOutObjects() const
+{
+ ULONG nObjAnz=GetObjCount();
+ for (ULONG nObjNum=nObjAnz; nObjNum>0;) {
+ SdrObject* pObj=GetObj(--nObjNum);
+ SdrGrafObj* pGrafObj=PTR_CAST(SdrGrafObj,pObj);
+ if (pGrafObj!=NULL) {
+ pGrafObj->ForceSwapOut();
+ }
+ SdrObjList* pOL=pObj->GetSubList();
+ if (pOL!=NULL) {
+ pOL->ForceSwapOutObjects();
+ }
+ }
+}
+
+void SdrObjList::FlattenGroups()
+{
+ sal_Int32 nObj = GetObjCount();
+ sal_Int32 i;
+ for( i=nObj-1; i>=0; --i)
+ UnGroupObj(i);
+}
+
+void SdrObjList::UnGroupObj( ULONG nObjNum )
+{
+ // if the given object is no group, this method is a noop
+ SdrObject* pUngroupObj = GetObj( nObjNum );
+ if( pUngroupObj )
+ {
+ SdrObjList* pSrcLst = pUngroupObj->GetSubList();
+ //sal_Int32 nCount( 0 );
+ if( pUngroupObj->ISA( SdrObjGroup ) && pSrcLst )
+ {
+ SdrObjGroup* pUngroupGroup = static_cast< SdrObjGroup* > (pUngroupObj);
+
+ // ungroup recursively (has to be head recursion,
+ // otherwise our indices will get trashed when doing it in
+ // the loop)
+ pSrcLst->FlattenGroups();
+
+ // the position at which we insert the members of rUngroupGroup
+ sal_Int32 nInsertPos( pUngroupGroup->GetOrdNum() );
+
+ SdrObject* pObj;
+ sal_Int32 i, nAnz = pSrcLst->GetObjCount();
+ for( i=0; i<nAnz; ++i )
+ {
+ pObj = pSrcLst->RemoveObject(0);
+ SdrInsertReason aReason(SDRREASON_VIEWCALL, pUngroupGroup);
+ InsertObject(pObj, nInsertPos, &aReason);
+ ++nInsertPos;
+ }
+
+ RemoveObject(nInsertPos);
+ }
+ }
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR("SdrObjList::UnGroupObj: object index invalid");
+#endif
+}
+
+
+
+
+bool SdrObjList::HasObjectNavigationOrder (void) const
+{
+ return mpNavigationOrder.get() != NULL;
+}
+
+
+
+
+void SdrObjList::SetObjectNavigationPosition (
+ SdrObject& rObject,
+ const sal_uInt32 nNewPosition)
+{
+ // When the navigation order container has not yet been created then
+ // create one now. It is initialized with the z-order taken from
+ // maList.
+ if (mpNavigationOrder.get() == NULL)
+ {
+ mpNavigationOrder.reset(new WeakSdrObjectContainerType(maList.size()));
+ ::std::copy(
+ maList.begin(),
+ maList.end(),
+ mpNavigationOrder->begin());
+ }
+ OSL_ASSERT(mpNavigationOrder.get()!=NULL);
+ OSL_ASSERT( mpNavigationOrder->size() == maList.size());
+
+ SdrObjectWeakRef aReference (&rObject);
+
+ // Look up the object whose navigation position is to be changed.
+ WeakSdrObjectContainerType::iterator iObject (::std::find(
+ mpNavigationOrder->begin(),
+ mpNavigationOrder->end(),
+ aReference));
+ if (iObject == mpNavigationOrder->end())
+ {
+ // The given object is not a member of the navigation order.
+ return;
+ }
+
+ // Move the object to its new position.
+ const sal_uInt32 nOldPosition = ::std::distance(mpNavigationOrder->begin(), iObject);
+ if (nOldPosition != nNewPosition)
+ {
+ mpNavigationOrder->erase(iObject);
+ sal_uInt32 nInsertPosition (nNewPosition);
+ // Adapt insertion position for the just erased object.
+ if (nNewPosition >= nOldPosition)
+ nInsertPosition -= 1;
+ if (nInsertPosition >= mpNavigationOrder->size())
+ mpNavigationOrder->push_back(aReference);
+ else
+ mpNavigationOrder->insert(mpNavigationOrder->begin()+nInsertPosition, aReference);
+
+ mbIsNavigationOrderDirty = true;
+
+ // The navigation order is written out to file so mark the model as modified.
+ if (pModel != NULL)
+ pModel->SetChanged();
+ }
+}
+
+
+
+
+SdrObject* SdrObjList::GetObjectForNavigationPosition (const sal_uInt32 nNavigationPosition) const
+{
+ if (HasObjectNavigationOrder())
+ {
+ // There is a user defined navigation order. Make sure the object
+ // index is correct and look up the object in mpNavigationOrder.
+ if (nNavigationPosition >= mpNavigationOrder->size())
+ {
+ OSL_ASSERT(nNavigationPosition < mpNavigationOrder->size());
+ }
+ else
+ return (*mpNavigationOrder)[nNavigationPosition].get();
+ }
+ else
+ {
+ // There is no user defined navigation order. Use the z-order
+ // instead.
+ if (nNavigationPosition >= maList.size())
+ {
+ OSL_ASSERT(nNavigationPosition < maList.size());
+ }
+ else
+ return maList[nNavigationPosition];
+ }
+ return NULL;
+}
+
+
+
+
+void SdrObjList::ClearObjectNavigationOrder (void)
+{
+ mpNavigationOrder.reset();
+ mbIsNavigationOrderDirty = true;
+}
+
+
+
+
+bool SdrObjList::RecalcNavigationPositions (void)
+{
+ bool bUpToDate (false);
+
+ if (mbIsNavigationOrderDirty)
+ {
+ if (mpNavigationOrder.get() != NULL)
+ {
+ mbIsNavigationOrderDirty = false;
+
+ WeakSdrObjectContainerType::iterator iObject;
+ WeakSdrObjectContainerType::const_iterator iEnd (mpNavigationOrder->end());
+ sal_uInt32 nIndex (0);
+ for (iObject=mpNavigationOrder->begin(); iObject!=iEnd; ++iObject,++nIndex)
+ (*iObject)->SetNavigationPosition(nIndex);
+
+ bUpToDate = true;
+ }
+ }
+
+ return mpNavigationOrder.get() != NULL;
+}
+
+
+
+
+void SdrObjList::SetNavigationOrder (const uno::Reference<container::XIndexAccess>& rxOrder)
+{
+ if (rxOrder.is())
+ {
+ const sal_Int32 nCount = rxOrder->getCount();
+ if ((sal_uInt32)nCount != maList.size())
+ return;
+
+ if (mpNavigationOrder.get() == NULL)
+ mpNavigationOrder.reset(new WeakSdrObjectContainerType(nCount));
+
+ for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
+ {
+ uno::Reference<uno::XInterface> xShape (rxOrder->getByIndex(nIndex), uno::UNO_QUERY);
+ SdrObject* pObject = SdrObject::getSdrObjectFromXShape(xShape);
+ if (pObject == NULL)
+ break;
+ (*mpNavigationOrder)[nIndex] = pObject;
+ }
+
+ mbIsNavigationOrderDirty = true;
+ }
+ else
+ ClearObjectNavigationOrder();
+}
+
+
+
+
+void SdrObjList::InsertObjectIntoContainer (
+ SdrObject& rObject,
+ const sal_uInt32 nInsertPosition)
+{
+ OSL_ASSERT(nInsertPosition<=maList.size());
+
+ // Update the navigation positions.
+ if (HasObjectNavigationOrder())
+ {
+ // The new object does not have a user defined position so append it
+ // to the list.
+ rObject.SetNavigationPosition(mpNavigationOrder->size());
+ mpNavigationOrder->push_back(&rObject);
+ }
+
+ // Insert object into object list. Because the insert() method requires
+ // a valid iterator as insertion position, we have to use push_back() to
+ // insert at the end of the list.
+ if (nInsertPosition >= maList.size())
+ maList.push_back(&rObject);
+ else
+ maList.insert(maList.begin()+nInsertPosition, &rObject);
+ bObjOrdNumsDirty=TRUE;
+}
+
+
+
+
+void SdrObjList::ReplaceObjectInContainer (
+ SdrObject& rNewObject,
+ const sal_uInt32 nObjectPosition)
+{
+ if (nObjectPosition >= maList.size())
+ {
+ OSL_ASSERT(nObjectPosition<maList.size());
+ return;
+ }
+
+ // Update the navigation positions.
+ if (HasObjectNavigationOrder())
+ {
+ // A user defined position of the object that is to be replaced is
+ // not transferred to the new object so erase the former and append
+ // the later object from/to the navigation order.
+ OSL_ASSERT(nObjectPosition < maList.size());
+ SdrObjectWeakRef aReference (maList[nObjectPosition]);
+ WeakSdrObjectContainerType::iterator iObject (::std::find(
+ mpNavigationOrder->begin(),
+ mpNavigationOrder->end(),
+ aReference));
+ if (iObject != mpNavigationOrder->end())
+ mpNavigationOrder->erase(iObject);
+
+ mpNavigationOrder->push_back(&rNewObject);
+
+ mbIsNavigationOrderDirty = true;
+ }
+
+ maList[nObjectPosition] = &rNewObject;
+ bObjOrdNumsDirty=TRUE;
+}
+
+
+
+
+void SdrObjList::RemoveObjectFromContainer (
+ const sal_uInt32 nObjectPosition)
+{
+ if (nObjectPosition >= maList.size())
+ {
+ OSL_ASSERT(nObjectPosition<maList.size());
+ return;
+ }
+
+ // Update the navigation positions.
+ if (HasObjectNavigationOrder())
+ {
+ SdrObjectWeakRef aReference (maList[nObjectPosition]);
+ WeakSdrObjectContainerType::iterator iObject (::std::find(
+ mpNavigationOrder->begin(),
+ mpNavigationOrder->end(),
+ aReference));
+ if (iObject != mpNavigationOrder->end())
+ mpNavigationOrder->erase(iObject);
+ mbIsNavigationOrderDirty = true;
+ }
+
+ maList.erase(maList.begin()+nObjectPosition);
+ bObjOrdNumsDirty=TRUE;
+}
+
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrPageGridFrameList::Clear()
+{
+ USHORT nAnz=GetCount();
+ for (USHORT i=0; i<nAnz; i++) {
+ delete GetObject(i);
+ }
+ aList.Clear();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// #111111# PageUser section
+
+void SdrPage::AddPageUser(sdr::PageUser& rNewUser)
+{
+ maPageUsers.push_back(&rNewUser);
+}
+
+void SdrPage::RemovePageUser(sdr::PageUser& rOldUser)
+{
+ const ::sdr::PageUserVector::iterator aFindResult = ::std::find(maPageUsers.begin(), maPageUsers.end(), &rOldUser);
+ if(aFindResult != maPageUsers.end())
+ {
+ maPageUsers.erase(aFindResult);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// #110094# DrawContact section
+
+sdr::contact::ViewContact* SdrPage::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfSdrPage(*this);
+}
+
+sdr::contact::ViewContact& SdrPage::GetViewContact() const
+{
+ if(!mpViewContact)
+ {
+ const_cast< SdrPage* >(this)->mpViewContact =
+ const_cast< SdrPage* >(this)->CreateObjectSpecificViewContact();
+ }
+
+ return *mpViewContact;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrPageProperties::ImpRemoveStyleSheet()
+{
+ if(mpStyleSheet)
+ {
+ EndListening(*mpStyleSheet);
+ mpProperties->SetParent(0);
+ mpStyleSheet = 0;
+ }
+}
+
+void SdrPageProperties::ImpAddStyleSheet(SfxStyleSheet& rNewStyleSheet)
+{
+ if(mpStyleSheet != &rNewStyleSheet)
+ {
+ ImpRemoveStyleSheet();
+ mpStyleSheet = &rNewStyleSheet;
+ StartListening(rNewStyleSheet);
+ mpProperties->SetParent(&rNewStyleSheet.GetItemSet());
+ }
+}
+
+void ImpPageChange(SdrPage& rSdrPage)
+{
+ rSdrPage.ActionChanged();
+
+ if(rSdrPage.GetModel())
+ {
+ rSdrPage.GetModel()->SetChanged(true);
+ SdrHint aHint(HINT_PAGEORDERCHG);
+ aHint.SetPage(&rSdrPage);
+ rSdrPage.GetModel()->Broadcast(aHint);
+ }
+}
+
+SdrPageProperties::SdrPageProperties(SdrPage& rSdrPage)
+: SfxListener(),
+ mpSdrPage(&rSdrPage),
+ mpStyleSheet(0),
+ mpProperties(new SfxItemSet(mpSdrPage->GetModel()->GetItemPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST))
+{
+ if(!rSdrPage.IsMasterPage())
+ {
+ mpProperties->Put(XFillStyleItem(XFILL_NONE));
+ }
+}
+
+SdrPageProperties::~SdrPageProperties()
+{
+ ImpRemoveStyleSheet();
+ delete mpProperties;
+}
+
+void SdrPageProperties::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
+{
+ const SfxSimpleHint* pSimpleHint = dynamic_cast< const SfxSimpleHint* >(&rHint);
+
+ if(pSimpleHint)
+ {
+ switch(pSimpleHint->GetId())
+ {
+ case SFX_HINT_DATACHANGED :
+ {
+ // notify change, broadcast
+ ImpPageChange(*mpSdrPage);
+ break;
+ }
+ case SFX_HINT_DYING :
+ {
+ // Style needs to be forgotten
+ ImpRemoveStyleSheet();
+ break;
+ }
+ }
+ }
+}
+
+const SfxItemSet& SdrPageProperties::GetItemSet() const
+{
+ return *mpProperties;
+}
+
+void SdrPageProperties::PutItemSet(const SfxItemSet& rSet)
+{
+ OSL_ENSURE(!mpSdrPage->IsMasterPage(), "Item set at MasterPage Attributes (!)");
+ mpProperties->Put(rSet);
+ ImpPageChange(*mpSdrPage);
+}
+
+void SdrPageProperties::PutItem(const SfxPoolItem& rItem)
+{
+ OSL_ENSURE(!mpSdrPage->IsMasterPage(), "Item set at MasterPage Attributes (!)");
+ mpProperties->Put(rItem);
+ ImpPageChange(*mpSdrPage);
+}
+
+void SdrPageProperties::ClearItem(const sal_uInt16 nWhich)
+{
+ mpProperties->ClearItem(nWhich);
+ ImpPageChange(*mpSdrPage);
+}
+
+void SdrPageProperties::SetStyleSheet(SfxStyleSheet* pStyleSheet)
+{
+ if(pStyleSheet)
+ {
+ ImpAddStyleSheet(*pStyleSheet);
+ }
+ else
+ {
+ ImpRemoveStyleSheet();
+ }
+
+ ImpPageChange(*mpSdrPage);
+}
+
+SfxStyleSheet* SdrPageProperties::GetStyleSheet() const
+{
+ return mpStyleSheet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrPage,SdrObjList);
+DBG_NAME(SdrPage)
+SdrPage::SdrPage(SdrModel& rNewModel, bool bMasterPage)
+: SdrObjList(&rNewModel, this),
+ mpViewContact(0L),
+ nWdt(10L),
+ nHgt(10L),
+ nBordLft(0L),
+ nBordUpp(0L),
+ nBordRgt(0L),
+ nBordLwr(0L),
+ pLayerAdmin(new SdrLayerAdmin(&rNewModel.GetLayerAdmin())),
+ mpSdrPageProperties(0),
+ mpMasterPageDescriptor(0L),
+ nPageNum(0L),
+ mbMaster(bMasterPage),
+ mbInserted(false),
+ mbObjectsNotPersistent(false),
+ mbSwappingLocked(false),
+ mbPageBorderOnlyLeftRight(false)
+{
+ DBG_CTOR(SdrPage,NULL);
+ aPrefVisiLayers.SetAll();
+ eListKind = (bMasterPage) ? SDROBJLIST_MASTERPAGE : SDROBJLIST_DRAWPAGE;
+
+ mpSdrPageProperties = new SdrPageProperties(*this);
+}
+
+SdrPage::SdrPage(const SdrPage& rSrcPage)
+: SdrObjList(rSrcPage.pModel, this),
+ tools::WeakBase< SdrPage >(),
+ mpViewContact(0L),
+ nWdt(rSrcPage.nWdt),
+ nHgt(rSrcPage.nHgt),
+ nBordLft(rSrcPage.nBordLft),
+ nBordUpp(rSrcPage.nBordUpp),
+ nBordRgt(rSrcPage.nBordRgt),
+ nBordLwr(rSrcPage.nBordLwr),
+ pLayerAdmin(new SdrLayerAdmin(rSrcPage.pModel->GetLayerAdmin())),
+ mpSdrPageProperties(0),
+ mpMasterPageDescriptor(0L),
+ nPageNum(rSrcPage.nPageNum),
+ mbMaster(rSrcPage.mbMaster),
+ mbInserted(false),
+ mbObjectsNotPersistent(rSrcPage.mbObjectsNotPersistent),
+ mbSwappingLocked(rSrcPage.mbSwappingLocked),
+ mbPageBorderOnlyLeftRight(rSrcPage.mbPageBorderOnlyLeftRight)
+{
+ DBG_CTOR(SdrPage,NULL);
+ aPrefVisiLayers.SetAll();
+ eListKind = (mbMaster) ? SDROBJLIST_MASTERPAGE : SDROBJLIST_DRAWPAGE;
+
+ // copy things from source
+ // Warning: this leads to slicing (see issue 93186) and has to be
+ // removed as soon as possible.
+ *this = rSrcPage;
+ OSL_ENSURE(mpSdrPageProperties,
+ "SdrPage::SdrPage: operator= did not create needed SdrPageProperties (!)");
+
+ // be careful and correct eListKind, a member of SdrObjList which
+ // will be changed by the SdrOIbjList::operator= before...
+ eListKind = (mbMaster) ? SDROBJLIST_MASTERPAGE : SDROBJLIST_DRAWPAGE;
+
+ // The previous assignment to *this may have resulted in a call to
+ // createUnoPage at a partially initialized (sliced) SdrPage object.
+ // Due to the vtable being not yet fully set-up at this stage,
+ // createUnoPage() may have been called at the wrong class.
+ // To force a call to the right createUnoPage() at a later time when the
+ // new object is full constructed mxUnoPage is disposed now.
+ uno::Reference<lang::XComponent> xComponent (mxUnoPage, uno::UNO_QUERY);
+ if (xComponent.is())
+ {
+ mxUnoPage = NULL;
+ xComponent->dispose();
+ }
+}
+
+SdrPage::~SdrPage()
+{
+ if( mxUnoPage.is() ) try
+ {
+ uno::Reference< lang::XComponent > xPageComponent( mxUnoPage, uno::UNO_QUERY_THROW );
+ mxUnoPage.clear();
+ xPageComponent->dispose();
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // #111111#
+ // tell all the registered PageUsers that the page is in destruction
+ // This causes some (all?) PageUsers to remove themselves from the list
+ // of page users. Therefore we have to use a copy of the list for the
+ // iteration.
+ ::sdr::PageUserVector aListCopy (maPageUsers.begin(), maPageUsers.end());
+ for(::sdr::PageUserVector::iterator aIterator = aListCopy.begin(); aIterator != aListCopy.end(); aIterator++)
+ {
+ sdr::PageUser* pPageUser = *aIterator;
+ DBG_ASSERT(pPageUser, "SdrPage::~SdrPage: corrupt PageUser list (!)");
+ pPageUser->PageInDestruction(*this);
+ }
+
+ // #111111#
+ // Clear the vector. This means that user do not need to call RemovePageUser()
+ // when they get called from PageInDestruction().
+ maPageUsers.clear();
+
+ delete pLayerAdmin;
+
+ TRG_ClearMasterPage();
+
+ // #110094#
+ if(mpViewContact)
+ {
+ delete mpViewContact;
+ mpViewContact = 0L;
+ }
+
+ {
+ delete mpSdrPageProperties;
+ mpSdrPageProperties = 0;
+ }
+
+ DBG_DTOR(SdrPage,NULL);
+}
+
+void SdrPage::operator=(const SdrPage& rSrcPage)
+{
+ if(mpViewContact)
+ {
+ delete mpViewContact;
+ mpViewContact = 0L;
+ }
+
+ // Joe also sets some parameters for the class this one
+ // is derived from. SdrObjList does the same bad handling of
+ // copy constructor and operator=, so i better let it stand here.
+ pPage = this;
+
+ // copy all the local parameters to make this instance
+ // a valid copy od source page before copying and inserting
+ // the contained objects
+ mbMaster = rSrcPage.mbMaster;
+ mbSwappingLocked = rSrcPage.mbSwappingLocked;
+ mbPageBorderOnlyLeftRight = rSrcPage.mbPageBorderOnlyLeftRight;
+ aPrefVisiLayers = rSrcPage.aPrefVisiLayers;
+ nWdt = rSrcPage.nWdt;
+ nHgt = rSrcPage.nHgt;
+ nBordLft = rSrcPage.nBordLft;
+ nBordUpp = rSrcPage.nBordUpp;
+ nBordRgt = rSrcPage.nBordRgt;
+ nBordLwr = rSrcPage.nBordLwr;
+ nPageNum = rSrcPage.nPageNum;
+
+ if(rSrcPage.TRG_HasMasterPage())
+ {
+ TRG_SetMasterPage(rSrcPage.TRG_GetMasterPage());
+ TRG_SetMasterPageVisibleLayers(rSrcPage.TRG_GetMasterPageVisibleLayers());
+ }
+ else
+ {
+ TRG_ClearMasterPage();
+ }
+ //aMasters = rSrcPage.aMasters;
+
+ mbObjectsNotPersistent = rSrcPage.mbObjectsNotPersistent;
+
+ {
+ // #i111122# delete SdrPageProperties when model is different
+ if(mpSdrPageProperties && GetModel() != rSrcPage.GetModel())
+ {
+ delete mpSdrPageProperties;
+ mpSdrPageProperties = 0;
+ }
+
+ if(!mpSdrPageProperties)
+ {
+ mpSdrPageProperties = new SdrPageProperties(*this);
+ }
+ else
+ {
+ mpSdrPageProperties->ClearItem(0);
+ }
+
+ if(!IsMasterPage())
+ {
+ mpSdrPageProperties->PutItemSet(rSrcPage.getSdrPageProperties().GetItemSet());
+ }
+
+ mpSdrPageProperties->SetStyleSheet(rSrcPage.getSdrPageProperties().GetStyleSheet());
+ }
+
+ // Now copy the contained obejcts (by cloning them)
+ SdrObjList::operator=(rSrcPage);
+}
+
+SdrPage* SdrPage::Clone() const
+{
+ return Clone(NULL);
+}
+
+SdrPage* SdrPage::Clone(SdrModel* pNewModel) const
+{
+ if (pNewModel==NULL) pNewModel=pModel;
+ SdrPage* pPage2=new SdrPage(*pNewModel);
+ *pPage2=*this;
+ return pPage2;
+}
+
+void SdrPage::SetSize(const Size& aSiz)
+{
+ bool bChanged(false);
+
+ if(aSiz.Width() != nWdt)
+ {
+ nWdt = aSiz.Width();
+ bChanged = true;
+ }
+
+ if(aSiz.Height() != nHgt)
+ {
+ nHgt = aSiz.Height();
+ bChanged = true;
+ }
+
+ if(bChanged)
+ {
+ SetChanged();
+ }
+}
+
+Size SdrPage::GetSize() const
+{
+ return Size(nWdt,nHgt);
+}
+
+INT32 SdrPage::GetWdt() const
+{
+ return nWdt;
+}
+
+void SdrPage::SetOrientation(Orientation eOri)
+{
+ // Quadratisch ist und bleibt immer Portrait
+ Size aSiz(GetSize());
+ if (aSiz.Width()!=aSiz.Height()) {
+ if ((eOri==ORIENTATION_PORTRAIT) == (aSiz.Width()>aSiz.Height())) {
+ SetSize(Size(aSiz.Height(),aSiz.Width()));
+ }
+ }
+}
+
+Orientation SdrPage::GetOrientation() const
+{
+ // Quadratisch ist Portrait
+ Orientation eRet=ORIENTATION_PORTRAIT;
+ Size aSiz(GetSize());
+ if (aSiz.Width()>aSiz.Height()) eRet=ORIENTATION_LANDSCAPE;
+ return eRet;
+}
+
+INT32 SdrPage::GetHgt() const
+{
+ return nHgt;
+}
+
+void SdrPage::SetBorder(INT32 nLft, INT32 nUpp, INT32 nRgt, INT32 nLwr)
+{
+ bool bChanged(false);
+
+ if(nBordLft != nLft)
+ {
+ nBordLft = nLft;
+ bChanged = true;
+ }
+
+ if(nBordUpp != nUpp)
+ {
+ nBordUpp = nUpp;
+ bChanged = true;
+ }
+
+ if(nBordRgt != nRgt)
+ {
+ nBordRgt = nRgt;
+ bChanged = true;
+ }
+
+ if(nBordLwr != nLwr)
+ {
+ nBordLwr = nLwr;
+ bChanged = true;
+ }
+
+ if(bChanged)
+ {
+ SetChanged();
+ }
+}
+
+void SdrPage::SetLftBorder(INT32 nBorder)
+{
+ if(nBordLft != nBorder)
+ {
+ nBordLft = nBorder;
+ SetChanged();
+ }
+}
+
+void SdrPage::SetUppBorder(INT32 nBorder)
+{
+ if(nBordUpp != nBorder)
+ {
+ nBordUpp = nBorder;
+ SetChanged();
+ }
+}
+
+void SdrPage::SetRgtBorder(INT32 nBorder)
+{
+ if(nBordRgt != nBorder)
+ {
+ nBordRgt=nBorder;
+ SetChanged();
+ }
+}
+
+void SdrPage::SetLwrBorder(INT32 nBorder)
+{
+ if(nBordLwr != nBorder)
+ {
+ nBordLwr=nBorder;
+ SetChanged();
+ }
+}
+
+INT32 SdrPage::GetLftBorder() const
+{
+ return nBordLft;
+}
+
+INT32 SdrPage::GetUppBorder() const
+{
+ return nBordUpp;
+}
+
+INT32 SdrPage::GetRgtBorder() const
+{
+ return nBordRgt;
+}
+
+INT32 SdrPage::GetLwrBorder() const
+{
+ return nBordLwr;
+}
+
+void SdrPage::SetModel(SdrModel* pNewModel)
+{
+ SdrModel* pOldModel=pModel;
+ SdrObjList::SetModel(pNewModel);
+ if (pNewModel!=pOldModel)
+ {
+ if (pNewModel!=NULL) {
+ pLayerAdmin->SetParent(&pNewModel->GetLayerAdmin());
+ } else {
+ pLayerAdmin->SetParent(NULL);
+ }
+ pLayerAdmin->SetModel(pNewModel);
+
+ // create new SdrPageProperties with new model (due to SfxItemSet there)
+ // and copy ItemSet and StyleSheet
+ SdrPageProperties *pNew = new SdrPageProperties(*this);
+
+ if(!IsMasterPage())
+ {
+ pNew->PutItemSet(getSdrPageProperties().GetItemSet());
+ }
+
+ pNew->SetStyleSheet(getSdrPageProperties().GetStyleSheet());
+
+ delete mpSdrPageProperties;
+ mpSdrPageProperties = pNew;
+ }
+
+ // update listeners at possible api wrapper object
+ if( pOldModel != pNewModel )
+ {
+ if( mxUnoPage.is() )
+ {
+ SvxDrawPage* pPage2 = SvxDrawPage::getImplementation( mxUnoPage );
+ if( pPage2 )
+ pPage2->ChangeModel( pNewModel );
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// #i68775# React on PageNum changes (from Model in most cases)
+void SdrPage::SetPageNum(sal_uInt16 nNew)
+{
+ if(nNew != nPageNum)
+ {
+ // change
+ nPageNum = nNew;
+
+ // notify visualisations, also notifies e.g. buffered MasterPages
+ ActionChanged();
+ }
+}
+
+USHORT SdrPage::GetPageNum() const
+{
+ if (!mbInserted)
+ return 0;
+
+ if (mbMaster) {
+ if (pModel && pModel->IsMPgNumsDirty())
+ ((SdrModel*)pModel)->RecalcPageNums(TRUE);
+ } else {
+ if (pModel && pModel->IsPagNumsDirty())
+ ((SdrModel*)pModel)->RecalcPageNums(FALSE);
+ }
+ return nPageNum;
+}
+
+void SdrPage::SetChanged()
+{
+ // #110094#-11
+ // For test purposes, use the new ViewContact for change
+ // notification now.
+ ActionChanged();
+
+ if( pModel )
+ {
+ pModel->SetChanged();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// MasterPage interface
+
+void SdrPage::TRG_SetMasterPage(SdrPage& rNew)
+{
+ if(mpMasterPageDescriptor && &(mpMasterPageDescriptor->GetUsedPage()) == &rNew)
+ return;
+
+ if(mpMasterPageDescriptor)
+ TRG_ClearMasterPage();
+
+ mpMasterPageDescriptor = new ::sdr::MasterPageDescriptor(*this, rNew);
+ GetViewContact().ActionChanged();
+}
+
+void SdrPage::TRG_ClearMasterPage()
+{
+ if(mpMasterPageDescriptor)
+ {
+ SetChanged();
+
+ // the flushViewObjectContacts() will do needed invalidates by deleting the involved VOCs
+ mpMasterPageDescriptor->GetUsedPage().GetViewContact().flushViewObjectContacts(true);
+
+ delete mpMasterPageDescriptor;
+ mpMasterPageDescriptor = 0L;
+ }
+}
+
+SdrPage& SdrPage::TRG_GetMasterPage() const
+{
+ DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_GetMasterPage(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
+ return mpMasterPageDescriptor->GetUsedPage();
+}
+
+const SetOfByte& SdrPage::TRG_GetMasterPageVisibleLayers() const
+{
+ DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_GetMasterPageVisibleLayers(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
+ return mpMasterPageDescriptor->GetVisibleLayers();
+}
+
+void SdrPage::TRG_SetMasterPageVisibleLayers(const SetOfByte& rNew)
+{
+ DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_SetMasterPageVisibleLayers(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
+ mpMasterPageDescriptor->SetVisibleLayers(rNew);
+}
+
+sdr::contact::ViewContact& SdrPage::TRG_GetMasterPageDescriptorViewContact() const
+{
+ DBG_ASSERT(mpMasterPageDescriptor != 0L, "TRG_GetMasterPageDescriptorViewContact(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
+ return mpMasterPageDescriptor->GetViewContact();
+}
+
+// #115423# used from SdrModel::RemoveMasterPage
+void SdrPage::TRG_ImpMasterPageRemoved(const SdrPage& rRemovedPage)
+{
+ if(TRG_HasMasterPage())
+ {
+ if(&TRG_GetMasterPage() == &rRemovedPage)
+ {
+ TRG_ClearMasterPage();
+ }
+ }
+}
+
+const SdrPageGridFrameList* SdrPage::GetGridFrameList(const SdrPageView* /*pPV*/, const Rectangle* /*pRect*/) const
+{
+ return NULL;
+}
+
+XubString SdrPage::GetLayoutName() const
+{
+ // Die wollte Dieter haben.
+ return String();
+}
+
+void SdrPage::SetInserted( bool bIns )
+{
+ if( mbInserted != bIns )
+ {
+ mbInserted = bIns;
+
+ SdrObjListIter aIter( *this, IM_FLAT );
+ while ( aIter.IsMore() )
+ {
+ SdrObject* pObj = aIter.Next();
+ if ( pObj->ISA(SdrOle2Obj) )
+ {
+ if( mbInserted )
+ ( (SdrOle2Obj*) pObj)->Connect();
+ else
+ ( (SdrOle2Obj*) pObj)->Disconnect();
+ }
+ }
+ }
+}
+
+
+uno::Reference< uno::XInterface > SdrPage::getUnoPage()
+{
+ // try weak reference first
+ if( !mxUnoPage.is() )
+ {
+ // create one
+ mxUnoPage = createUnoPage();
+ }
+
+ return mxUnoPage;
+}
+
+uno::Reference< uno::XInterface > SdrPage::createUnoPage()
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInt =
+ static_cast<cppu::OWeakObject*>( new SvxFmDrawPage( this ) );
+ return xInt;
+}
+
+SfxStyleSheet* SdrPage::GetTextStyleSheetForObject( SdrObject* pObj ) const
+{
+ return pObj->GetStyleSheet();
+}
+
+bool SdrPage::HasTransparentObjects( BOOL bCheckForAlphaChannel ) const
+{
+ bool bRet = false;
+
+ for( ULONG n = 0, nCount = GetObjCount(); ( n < nCount ) && !bRet; n++ )
+ if( GetObj( n )->IsTransparent( bCheckForAlphaChannel ) )
+ bRet = true;
+
+ return bRet;
+}
+
+/** returns an averaged background color of this page */
+// #i75566# GetBackgroundColor -> GetPageBackgroundColor and bScreenDisplay hint value
+Color SdrPage::GetPageBackgroundColor( SdrPageView* pView, bool bScreenDisplay ) const
+{
+ Color aColor;
+
+ if(bScreenDisplay && (!pView || pView->GetApplicationDocumentColor() == COL_AUTO))
+ {
+ svtools::ColorConfig aColorConfig;
+ aColor = aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor;
+ }
+ else
+ {
+ aColor = pView->GetApplicationDocumentColor();
+ }
+
+ const SfxItemSet* pBackgroundFill = &getSdrPageProperties().GetItemSet();
+
+ if(!IsMasterPage() && TRG_HasMasterPage())
+ {
+ if(XFILL_NONE == ((const XFillStyleItem&)pBackgroundFill->Get(XATTR_FILLSTYLE)).GetValue())
+ {
+ pBackgroundFill = &TRG_GetMasterPage().getSdrPageProperties().GetItemSet();
+ }
+ }
+
+ GetDraftFillColor(*pBackgroundFill, aColor);
+
+ return aColor;
+}
+
+/** *deprecated, use GetBackgroundColor with SdrPageView */
+Color SdrPage::GetPageBackgroundColor() const
+// #i75566# GetBackgroundColor -> GetPageBackgroundColor
+{
+ return GetPageBackgroundColor( NULL, true );
+}
+
+/** this method returns true if the object from the ViewObjectContact should
+ be visible on this page while rendering.
+ bEdit selects if visibility test is for an editing view or a final render,
+ like printing.
+*/
+bool SdrPage::checkVisibility(
+ const sdr::contact::ViewObjectContact& /*rOriginal*/,
+ const sdr::contact::DisplayInfo& /*rDisplayInfo*/,
+ bool /*bEdit*/)
+{
+ // this will be handled in the application if needed
+ return true;
+}
+
+// #110094# DrawContact support: Methods for handling Page changes
+void SdrPage::ActionChanged() const
+{
+ // Do necessary ViewContact actions
+ GetViewContact().ActionChanged();
+
+ // #i48535# also handle MasterPage change
+ if(TRG_HasMasterPage())
+ {
+ TRG_GetMasterPageDescriptorViewContact().ActionChanged();
+ }
+}
+
+// NYI: Dummy implementations for declarations in svdpage.hxx
+Bitmap SdrPage::GetBitmap(const SetOfByte& /*rVisibleLayers*/, bool /*bTrimBorders*/) const
+{
+ DBG_ASSERT(0, "SdrPage::GetBitmap(): not yet implemented.");
+ return Bitmap();
+}
+GDIMetaFile SdrPage::GetMetaFile(const SetOfByte& /*rVisibleLayers*/, bool /*bTrimBorders*/)
+{
+ DBG_ASSERT(0, "SdrPage::GetMetaFile(): not yet implemented.");
+ return GDIMetaFile();
+}
+
+bool SdrPage::isHandoutMasterPage() const
+{
+ return mbMaster && GetModel() && GetModel()->GetMasterPageCount()
+ && GetModel()->GetMasterPage(0) == this;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// sdr::Comment interface
+
+const sdr::Comment& SdrPage::GetCommentByIndex(sal_uInt32 nIndex)
+{
+ DBG_ASSERT(nIndex < maComments.size(), "SdrPage::GetCommentByIndex: Access out of range (!)");
+ return maComments[nIndex];
+}
+
+void SdrPage::AddComment(const sdr::Comment& rNew)
+{
+ maComments.push_back(rNew);
+ ::std::sort(maComments.begin(), maComments.end());
+}
+
+void SdrPage::ReplaceCommentByIndex(sal_uInt32 nIndex, const sdr::Comment& rNew)
+{
+ DBG_ASSERT(nIndex < maComments.size(), "SdrPage::GetCommentByIndex: Access out of range (!)");
+
+ if(maComments[nIndex] != rNew)
+ {
+ maComments[nIndex] = rNew;
+ ::std::sort(maComments.begin(), maComments.end());
+ }
+}
+
+const SdrPageProperties* SdrPage::getCorrectSdrPageProperties() const
+{
+ if(mpMasterPageDescriptor)
+ {
+ return mpMasterPageDescriptor->getCorrectSdrPageProperties();
+ }
+ else
+ {
+ return &getSdrPageProperties();
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// use new redirector instead of pPaintProc
+
+StandardCheckVisisbilityRedirector::StandardCheckVisisbilityRedirector()
+: ViewObjectContactRedirector()
+{
+}
+
+StandardCheckVisisbilityRedirector::~StandardCheckVisisbilityRedirector()
+{
+}
+
+drawinglayer::primitive2d::Primitive2DSequence StandardCheckVisisbilityRedirector::createRedirectedPrimitive2DSequence(
+ const sdr::contact::ViewObjectContact& rOriginal,
+ const sdr::contact::DisplayInfo& rDisplayInfo)
+{
+ SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
+
+ if(pObject)
+ {
+ if(pObject->GetPage())
+ {
+ if(pObject->GetPage()->checkVisibility(rOriginal, rDisplayInfo, false))
+ {
+ return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
+ }
+ }
+
+ return drawinglayer::primitive2d::Primitive2DSequence();
+ }
+ else
+ {
+ // not an object, maybe a page
+ return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
new file mode 100644
index 000000000000..762d05a6e770
--- /dev/null
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -0,0 +1,1125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/svdpagv.hxx>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <comphelper/processfactory.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/xpoly.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdview.hxx>
+
+#include <svx/svdedxv.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdpagv.hxx>
+#include <editeng/outliner.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdview.hxx>
+#include "svditer.hxx"
+#include <svx/svdogrp.hxx>
+#include <svx/svdtypes.hxx>
+
+#include <svx/svdotext.hxx> // fuer PaintOutlinerView
+#include <svx/svdoole2.hxx>
+
+// #110094#
+#include <svx/sdr/contact/objectcontactofpageview.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/sdr/contact/viewobjectcontactredirector.hxx>
+#include <svx/fmview.hxx>
+
+// for search on vector
+#include <algorithm>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+#include <svx/sdrpagewindow.hxx>
+#include <sdrpaintwindow.hxx>
+
+TYPEINIT1(SdrPageView, SfxListener);
+DBG_NAME(SdrPageView);
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// interface to SdrPageWindow
+
+SdrPageWindow* SdrPageView::FindPageWindow(SdrPaintWindow& rPaintWindow) const
+{
+ for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); a++)
+ {
+ if(&((*a)->GetPaintWindow()) == &rPaintWindow)
+ {
+ return *a;
+ }
+ }
+
+ return 0L;
+}
+
+const SdrPageWindow* SdrPageView::FindPatchedPageWindow( const OutputDevice& _rOutDev ) const
+{
+ for ( SdrPageWindowVector::const_iterator loop = maPageWindows.begin();
+ loop != maPageWindows.end();
+ ++loop
+ )
+ {
+ const SdrPageWindow& rPageWindow( *(*loop) );
+ const SdrPaintWindow& rPaintWindow( rPageWindow.GetOriginalPaintWindow() ? *rPageWindow.GetOriginalPaintWindow() : rPageWindow.GetPaintWindow() );
+ if ( &rPaintWindow.GetOutputDevice() == &_rOutDev )
+ {
+ return &rPageWindow;
+ }
+ }
+
+ return NULL;
+}
+
+SdrPageWindow* SdrPageView::FindPageWindow(const OutputDevice& rOutDev) const
+{
+ for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); a++)
+ {
+ if(&((*a)->GetPaintWindow().GetOutputDevice()) == &rOutDev)
+ {
+ return *a;
+ }
+ }
+
+ return 0L;
+}
+
+SdrPageWindow* SdrPageView::GetPageWindow(sal_uInt32 nIndex) const
+{
+ // #126416#
+ if(nIndex < maPageWindows.size())
+ {
+ return maPageWindows[nIndex];
+ }
+
+ return 0L;
+}
+
+void SdrPageView::ClearPageWindows()
+{
+ // #126416#
+ for(SdrPageWindowVector::const_iterator a = maPageWindows.begin(); a != maPageWindows.end(); a++)
+ {
+ delete *a;
+ }
+
+ maPageWindows.clear();
+}
+
+void SdrPageView::AppendPageWindow(SdrPageWindow& rNew)
+{
+ maPageWindows.push_back(&rNew);
+}
+
+SdrPageWindow* SdrPageView::RemovePageWindow(sal_uInt32 nPos)
+{
+ if(nPos < maPageWindows.size())
+ {
+ SdrPageWindowVector::iterator aAccess = maPageWindows.begin() + nPos;
+ // #114376# remember return value
+ SdrPageWindow* pErasedSdrPageWindow = *aAccess;
+ maPageWindows.erase(aAccess);
+ return pErasedSdrPageWindow;
+ }
+
+ return 0L;
+}
+
+SdrPageWindow* SdrPageView::RemovePageWindow(SdrPageWindow& rOld)
+{
+ const SdrPageWindowVector::iterator aFindResult = ::std::find(maPageWindows.begin(), maPageWindows.end(), &rOld);
+
+ if(aFindResult != maPageWindows.end())
+ {
+ // #114376# remember return value
+ SdrPageWindow* pSdrPageWindow = *aFindResult;
+ maPageWindows.erase(aFindResult);
+ return pSdrPageWindow;
+ }
+
+ return 0L;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+SdrPageView::SdrPageView(SdrPage* pPage1, SdrView& rNewView)
+: mrView(rNewView),
+ // #103911# col_auto color lets the view takes the default SvxColorConfig entry
+ maDocumentColor( COL_AUTO ),
+ maBackgroundColor(COL_AUTO ), // #i48367# also react on autocolor
+ mpPreparedPageWindow(0) // #i72752#
+{
+ DBG_CTOR(SdrPageView,NULL);
+ mpPage = pPage1;
+
+ if(mpPage)
+ {
+ aPgOrg.X()=mpPage->GetLftBorder();
+ aPgOrg.Y()=mpPage->GetUppBorder();
+ }
+ mbHasMarked = sal_False;
+ aLayerVisi.SetAll();
+ aLayerPrn.SetAll();
+
+ mbVisible = sal_False;
+ pAktList = NULL;
+ pAktGroup = NULL;
+ SetAktGroupAndList(NULL, mpPage);
+
+ StartListening(*rNewView.GetModel());
+
+ for(sal_uInt32 a(0L); a < rNewView.PaintWindowCount(); a++)
+ {
+ AddPaintWindowToPageView(*rNewView.GetPaintWindow(a));
+ }
+}
+
+SdrPageView::~SdrPageView()
+{
+ DBG_DTOR(SdrPageView,NULL);
+
+ // cleanup window vector
+ ClearPageWindows();
+}
+
+SdrPageWindow& SdrPageView::CreateNewPageWindowEntry(SdrPaintWindow& rPaintWindow)
+{
+ // MIB 3.7.08: Das WinRec muss sofort in die Liste eingetragen werden,
+ // weil sich das InsertControlContainer darauf verlaesst
+ //SdrPageViewWinRec* pRec = new SdrPageViewWinRec( *this, pOut );
+ //pWinList->Insert(pRec);
+ SdrPageWindow& rWindow = *(new SdrPageWindow(*this, rPaintWindow));
+ AppendPageWindow(rWindow);
+
+ return rWindow;
+}
+
+void SdrPageView::AddPaintWindowToPageView(SdrPaintWindow& rPaintWindow)
+{
+ if(!FindPageWindow(rPaintWindow))
+ {
+ CreateNewPageWindowEntry(rPaintWindow);
+ }
+}
+
+void SdrPageView::RemovePaintWindowFromPageView(SdrPaintWindow& rPaintWindow)
+{
+ SdrPageWindow* pCandidate = FindPageWindow(rPaintWindow);
+
+ if(pCandidate)
+ {
+ pCandidate = RemovePageWindow(*pCandidate);
+
+ if(pCandidate)
+ {
+ delete pCandidate;
+ }
+ }
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > SdrPageView::GetControlContainer( const OutputDevice& _rDevice ) const
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > xReturn;
+ const SdrPageWindow* pCandidate = FindPatchedPageWindow( _rDevice );
+
+ if ( pCandidate )
+ xReturn = pCandidate->GetControlContainer( true );
+
+ return xReturn;
+}
+
+void __EXPORT SdrPageView::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/)
+{
+ // not really interested in
+}
+
+void SdrPageView::ModelHasChanged()
+{
+ if (GetAktGroup()!=NULL) CheckAktGroup();
+}
+
+sal_Bool SdrPageView::IsReadOnly() const
+{
+ return (0L == GetPage() || GetView().GetModel()->IsReadOnly() || GetPage()->IsReadOnly() || GetObjList()->IsReadOnly());
+}
+
+void SdrPageView::Show()
+{
+ if(!IsVisible())
+ {
+ mbVisible = sal_True;
+ InvalidateAllWin();
+
+ for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
+ {
+ AddPaintWindowToPageView(*GetView().GetPaintWindow(a));
+ }
+ }
+}
+
+void SdrPageView::Hide()
+{
+ if(IsVisible())
+ {
+ InvalidateAllWin();
+ mbVisible = sal_False;
+ ClearPageWindows();
+ }
+}
+
+Rectangle SdrPageView::GetPageRect() const
+{
+ if (GetPage()==NULL) return Rectangle();
+ return Rectangle(Point(),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
+}
+
+void SdrPageView::InvalidateAllWin()
+{
+ if(IsVisible() && GetPage())
+ {
+ Rectangle aRect(Point(0,0),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
+ aRect.Union(GetPage()->GetAllObjBoundRect());
+ GetView().InvalidateAllWin(aRect);
+ }
+}
+
+void SdrPageView::InvalidateAllWin(const Rectangle& rRect, sal_Bool bPlus1Pix)
+{
+ if(IsVisible())
+ {
+ GetView().InvalidateAllWin(rRect, bPlus1Pix);
+ }
+}
+
+void SdrPageView::PaintOutlinerView(OutputDevice* pOut, const Rectangle& rRect) const
+{
+ if (GetView().pTextEditOutliner==NULL) return;
+ //const SdrObject* pTextObjTmp=GetView().GetTextEditObject();
+ //const SdrTextObj* pText=PTR_CAST(SdrTextObj,pTextObjTmp);
+ //bool bTextFrame=pText!=NULL && pText->IsTextFrame();
+ ULONG nViewAnz=GetView().pTextEditOutliner->GetViewCount();
+ for (ULONG i=0; i<nViewAnz; i++) {
+ OutlinerView* pOLV=GetView().pTextEditOutliner->GetView(i);
+ if (pOLV->GetWindow()==pOut) {
+ GetView().ImpPaintOutlinerView(*pOLV, rRect);
+ return;
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrPageView::PrePaint()
+{
+ const sal_uInt32 nCount(PageWindowCount());
+
+ for(sal_uInt32 a(0); a < nCount; a++)
+ {
+ SdrPageWindow* pCandidate = GetPageWindow(a);
+
+ if(pCandidate)
+ {
+ pCandidate->PrePaint();
+ }
+ }
+}
+
+void SdrPageView::CompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector) const
+{
+ if(GetPage())
+ {
+ SdrPageWindow* pPageWindow = FindPageWindow(rPaintWindow);
+ sal_Bool bIsTempTarget(sal_False);
+
+ if(!pPageWindow)
+ {
+ // create temp PageWindow
+ pPageWindow = new SdrPageWindow(*((SdrPageView*)this), rPaintWindow);
+ bIsTempTarget = sal_True;
+ }
+
+ // do the redraw
+ pPageWindow->PrepareRedraw(rReg);
+ pPageWindow->RedrawAll(pRedirector);
+
+ // get rid of temp PageWindow
+ if(bIsTempTarget)
+ {
+ delete pPageWindow;
+ pPageWindow = 0L;
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #i74769# use SdrPaintWindow directly
+
+void SdrPageView::setPreparedPageWindow(SdrPageWindow* pKnownTarget)
+{
+ // #i72752# remember prepared SdrPageWindow
+ mpPreparedPageWindow = pKnownTarget;
+}
+
+void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::contact::ViewObjectContactRedirector* pRedirector) const
+{
+ if(GetPage())
+ {
+ if(pGivenTarget)
+ {
+ const SdrPageWindow* pKnownTarget = FindPageWindow(*pGivenTarget);
+
+ if(pKnownTarget)
+ {
+ // paint known target
+ pKnownTarget->RedrawLayer(&nID, pRedirector);
+ }
+ else
+ {
+ // #i72752# DrawLayer() uses a OutputDevice different from BeginDrawLayer. This happens
+ // e.g. when SW paints a single text line in text edit mode. Try to use it
+ SdrPageWindow* pPreparedTarget = mpPreparedPageWindow;
+
+ if(pPreparedTarget)
+ {
+ // if we have a prepared target, do not use a new SdrPageWindow since this
+ // works but is expensive. Just use a temporary PaintWindow
+ SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
+
+ // Copy existing paint region to use the same as prepared in BeginDrawLayer
+ SdrPaintWindow& rExistingPaintWindow = pPreparedTarget->GetPaintWindow();
+ const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
+ aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
+
+ // patch the ExistingPageWindow
+ pPreparedTarget->patchPaintWindow(aTemporaryPaintWindow);
+
+ // redraw the layer
+ pPreparedTarget->RedrawLayer(&nID, pRedirector);
+
+ // restore the ExistingPageWindow
+ pPreparedTarget->unpatchPaintWindow();
+ }
+ else
+ {
+ OSL_ENSURE(false, "SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
+
+ // None of the known OutputDevices is the target of this paint, use
+ // a temporary SdrPageWindow for this Redraw.
+ SdrPaintWindow aTemporaryPaintWindow(mrView, *pGivenTarget);
+ SdrPageWindow aTemporaryPageWindow(*((SdrPageView*)this), aTemporaryPaintWindow);
+
+ // #i72752#
+ // Copy existing paint region if other PageWindows exist, this was created by
+ // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW
+ // paints into an unknown device other than the view was created for (e.g. VirtualDevice)
+ if(PageWindowCount())
+ {
+ SdrPageWindow* pExistingPageWindow = GetPageWindow(0L);
+ SdrPaintWindow& rExistingPaintWindow = pExistingPageWindow->GetPaintWindow();
+ const Region& rExistingRegion = rExistingPaintWindow.GetRedrawRegion();
+ aTemporaryPaintWindow.SetRedrawRegion(rExistingRegion);
+ }
+
+ aTemporaryPageWindow.RedrawLayer(&nID, pRedirector);
+ }
+ }
+ }
+ else
+ {
+ // paint in all known windows
+ for(sal_uInt32 a(0L); a < PageWindowCount(); a++)
+ {
+ SdrPageWindow* pTarget = GetPageWindow(a);
+ pTarget->RedrawLayer(&nID, pRedirector);
+ }
+ }
+ }
+}
+
+void SdrPageView::SetDesignMode( bool _bDesignMode ) const
+{
+ for ( sal_uInt32 i = 0L; i < PageWindowCount(); ++i )
+ {
+ const SdrPageWindow& rPageViewWindow = *GetPageWindow(i);
+ rPageViewWindow.SetDesignMode( _bDesignMode );
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef OS2
+#define RGBCOLOR(r,g,b) ((ULONG)(((BYTE)(b) | ((USHORT)(g)<<8)) | (((ULONG)(BYTE)(r))<<16)))
+#endif
+
+void SdrPageView::DrawPageViewGrid(OutputDevice& rOut, const Rectangle& rRect, Color aColor)
+{
+ if (GetPage()==NULL)
+ return;
+
+ long nx1=GetView().aGridBig.Width();
+ long nx2=GetView().aGridFin.Width();
+ long ny1=GetView().aGridBig.Height();
+ long ny2=GetView().aGridFin.Height();
+
+ if (nx1==0) nx1=nx2;
+ if (nx2==0) nx2=nx1;
+ if (ny1==0) ny1=ny2;
+ if (ny2==0) ny2=ny1;
+ if (nx1==0) { nx1=ny1; nx2=ny2; }
+ if (ny1==0) { ny1=nx1; ny2=nx2; }
+ if (nx1<0) nx1=-nx1;
+ if (nx2<0) nx2=-nx2;
+ if (ny1<0) ny1=-ny1;
+ if (ny2<0) ny2=-ny2;
+
+ if (nx1!=0)
+ {
+ // no more global output size, use window size instead to decide grid sizes
+ long nScreenWdt = rOut.GetOutputSizePixel().Width();
+ // old: long nScreenWdt=System::GetDesktopRectPixel().GetWidth();
+
+ // Grid bei kleinen Zoomstufen etwas erweitern
+ //Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
+ long nMinDotPix=2;
+ long nMinLinPix=4;
+
+ if (nScreenWdt>=1600)
+ {
+ nMinDotPix=4;
+ nMinLinPix=8;
+ }
+ else if (nScreenWdt>=1024)
+ {
+ nMinDotPix=3;
+ nMinLinPix=6;
+ }
+ else
+ { // z.B. 640x480
+ nMinDotPix=2;
+ nMinLinPix=4;
+ }
+ Size aMinDotDist(rOut.PixelToLogic(Size(nMinDotPix,nMinDotPix)));
+ //Size a3PixSiz(rOut.PixelToLogic(Size(2,2)));
+ Size aMinLinDist(rOut.PixelToLogic(Size(nMinLinPix,nMinLinPix)));
+ bool bHoriSolid=nx2<aMinDotDist.Width();
+ bool bVertSolid=ny2<aMinDotDist.Height();
+ // Linienabstand vergroessern (mind. 4 Pixel)
+ // Vergroesserung: *2 *5 *10 *20 *50 *100 ...
+ int nTgl=0;
+ long nVal0=nx1;
+ while (nx1<aMinLinDist.Width())
+ {
+ long a=nx1;
+
+ if (nTgl==0) nx1*=2;
+ if (nTgl==1) nx1=nVal0*5; // => nx1*=2.5
+ if (nTgl==2) nx1*=2;
+
+ nVal0=a;
+ nTgl++; if (nTgl>=3) nTgl=0;
+ }
+ nTgl=0;
+ nVal0=ny1;
+ while (ny1<aMinLinDist.Height())
+ {
+ long a=ny1;
+
+ if (nTgl==0) ny1*=2;
+ if (nTgl==1) ny1=nVal0*5; // => ny1*=2.5
+ if (nTgl==2) ny1*=2;
+
+ nVal0=a;
+ nTgl++;
+
+ if (nTgl>=3) nTgl=0;
+ }
+ // Keine Zwischenpunkte, wenn...
+ //if (nx2<a2PixSiz.Width()) nx2=nx1;
+ //if (ny2<a2PixSiz.Height()) ny2=ny1;
+
+ bool bHoriFine=nx2<nx1;
+ bool bVertFine=ny2<ny1;
+ bool bHoriLines=bHoriSolid || bHoriFine || !bVertFine;
+ bool bVertLines=bVertSolid || bVertFine;
+
+ Color aColorMerk( rOut.GetLineColor() );
+ rOut.SetLineColor( aColor );
+
+ bool bMap0=rOut.IsMapModeEnabled();
+#ifdef WIN // SetPixel-Profiling fuer Windows
+ COLORREF aWinColRef=PALETTERGB(aColor.GetRed()>>8,aColor.GetGreen()>>8,aColor.GetBlue()>>8);
+ HDC aWinhDC=Sysdepen::GethDC(rOut);
+#endif
+
+ long nWrX=0;//aWriterPageOffset.X();
+ long nWrY=0;//aWriterPageOffset.Y();
+ Point aOrg(aPgOrg);
+ long x1=GetPage()->GetLftBorder()+1+nWrX;
+ long x2=GetPage()->GetWdt()-GetPage()->GetRgtBorder()-1+nWrY;
+ long y1=GetPage()->GetUppBorder()+1+nWrX;
+ long y2=GetPage()->GetHgt()-GetPage()->GetLwrBorder()-1+nWrY;
+ const SdrPageGridFrameList* pFrames=GetPage()->GetGridFrameList(this,NULL);
+ //USHORT nBufSiz=1024; // 4k Buffer = max. 512 Punkte
+ // #90353# long* pBuf = NULL;
+ USHORT nGridPaintAnz=1;
+ if (pFrames!=NULL) nGridPaintAnz=pFrames->GetCount();
+ for (USHORT nGridPaintNum=0; nGridPaintNum<nGridPaintAnz; nGridPaintNum++) {
+ if (pFrames!=NULL) {
+ const SdrPageGridFrame& rGF=(*pFrames)[nGridPaintNum];
+ nWrX=rGF.GetPaperRect().Left();
+ nWrY=rGF.GetPaperRect().Top();
+ x1=rGF.GetUserArea().Left();
+ x2=rGF.GetUserArea().Right();
+ y1=rGF.GetUserArea().Top();
+ y2=rGF.GetUserArea().Bottom();
+ aOrg=rGF.GetUserArea().TopLeft();
+ aOrg-=rGF.GetPaperRect().TopLeft();
+ }
+ if (!rRect.IsEmpty()) {
+ Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
+ long nX1Pix=a1PixSiz.Width(); // 1 Pixel Toleranz drauf
+ long nY1Pix=a1PixSiz.Height();
+ if (x1<rRect.Left() -nX1Pix) x1=rRect.Left() -nX1Pix;
+ if (x2>rRect.Right() +nX1Pix) x2=rRect.Right() +nX1Pix;
+ if (y1<rRect.Top() -nY1Pix) y1=rRect.Top() -nY1Pix;
+ if (y2>rRect.Bottom()+nY1Pix) y2=rRect.Bottom()+nY1Pix;
+ }
+ Point aPnt;
+
+ long xBigOrg=aOrg.X()+nWrX;
+ while (xBigOrg>=x1) xBigOrg-=nx1;
+ while (xBigOrg<x1) xBigOrg+=nx1;
+ long xFinOrg=xBigOrg;
+ while (xFinOrg>=x1) xFinOrg-=nx2;
+ while (xFinOrg<x1) xFinOrg+=nx2;
+
+ long yBigOrg=aOrg.Y()+nWrY;
+ while (yBigOrg>=y1) yBigOrg-=ny1;
+ while (yBigOrg<y1) yBigOrg+=ny1;
+ long yFinOrg=yBigOrg;
+ while (yFinOrg>=y1) yFinOrg-=ny2;
+ while (yFinOrg<y1) yFinOrg+=ny2;
+
+ if( x1 <= x2 && y1 <= y2 )
+ {
+ if( bHoriLines )
+ {
+ ULONG nGridFlags = ( bHoriSolid ? GRID_HORZLINES : GRID_DOTS );
+ UINT16 nSteps = sal_uInt16(nx1 / nx2);
+ UINT32 nRestPerStepMul1000 = nSteps ? ( ((nx1 * 1000L)/ nSteps) - (nx2 * 1000L) ) : 0;
+ UINT32 nStepOffset = 0;
+ UINT16 nPointOffset = 0;
+
+ for(UINT16 a=0;a<nSteps;a++)
+ {
+ // Zeichnen
+ rOut.DrawGrid(
+ Rectangle( xFinOrg + (a * nx2) + nPointOffset, yBigOrg, x2, y2 ),
+ Size( nx1, ny1 ), nGridFlags );
+
+ // Schritt machen
+ nStepOffset += nRestPerStepMul1000;
+ while(nStepOffset >= 1000)
+ {
+ nStepOffset -= 1000;
+ nPointOffset++;
+ }
+ }
+ }
+
+ if( bVertLines )
+ {
+ ULONG nGridFlags = ( bVertSolid ? GRID_VERTLINES : GRID_DOTS );
+ UINT16 nSteps = sal_uInt16(ny1 / ny2);
+ UINT32 nRestPerStepMul1000 = nSteps ? ( ((ny1 * 1000L)/ nSteps) - (ny2 * 1000L) ) : 0;
+ UINT32 nStepOffset = 0;
+ UINT16 nPointOffset = 0;
+
+ for(UINT16 a=0;a<nSteps;a++)
+ {
+ // Zeichnen
+ rOut.DrawGrid(
+ Rectangle( xBigOrg, yFinOrg + (a * ny2) + nPointOffset, x2, y2 ),
+ Size( nx1, ny1 ), nGridFlags );
+
+ // Schritt machen
+ nStepOffset += nRestPerStepMul1000;
+ while(nStepOffset >= 1000)
+ {
+ nStepOffset -= 1000;
+ nPointOffset++;
+ }
+ }
+
+ // rOut.DrawGrid( Rectangle( xo + xBigOrg, yo + yFinOrg, x2, y2 ), Size( nx1, ny2 ), nGridFlags );
+ }
+ }
+ }
+
+ rOut.EnableMapMode(bMap0);
+ rOut.SetLineColor(aColorMerk);
+ }
+}
+
+void SdrPageView::AdjHdl()
+{
+ GetView().AdjustMarkHdl();
+}
+
+void SdrPageView::SetLayer(const XubString& rName, SetOfByte& rBS, sal_Bool bJa)
+{
+ if(!GetPage())
+ return;
+
+ SdrLayerID nID = GetPage()->GetLayerAdmin().GetLayerID(rName, sal_True);
+
+ if(SDRLAYER_NOTFOUND != nID)
+ rBS.Set(nID, bJa);
+}
+
+sal_Bool SdrPageView::IsLayer(const XubString& rName, const SetOfByte& rBS) const
+{
+ if(!GetPage())
+ return sal_False;
+
+ sal_Bool bRet(sal_False);
+
+ if(rName.Len())
+ {
+ SdrLayerID nId = GetPage()->GetLayerAdmin().GetLayerID(rName, sal_True);
+
+ if(SDRLAYER_NOTFOUND != nId)
+ {
+ bRet = rBS.IsSet(nId);
+ }
+ }
+
+ return bRet;
+}
+
+void SdrPageView::SetAllLayers(SetOfByte& rB, sal_Bool bJa)
+{
+ if(bJa)
+ {
+ rB.SetAll();
+ rB.Clear(SDRLAYER_NOTFOUND);
+ }
+ else
+ {
+ rB.ClearAll();
+ }
+}
+
+sal_Bool SdrPageView::IsObjMarkable(SdrObject* pObj) const
+{
+ if(pObj)
+ {
+ // Vom Markieren ausgeschlossen?
+ if(pObj->IsMarkProtect())
+ {
+ return sal_False;
+ }
+
+ // only visible are markable
+ if( !pObj->IsVisible() )
+ {
+ return sal_False;
+ }
+
+ // #112440#
+ if(pObj->ISA(SdrObjGroup))
+ {
+ // If object is a Group object, visibility depends evtl. on
+ // multiple layers. If one object is markable, Group is markable.
+ SdrObjList* pObjList = ((SdrObjGroup*)pObj)->GetSubList();
+
+ if(pObjList && pObjList->GetObjCount())
+ {
+ sal_Bool bGroupIsMarkable(sal_False);
+
+ for(sal_uInt32 a(0L); !bGroupIsMarkable && a < pObjList->GetObjCount(); a++)
+ {
+ SdrObject* pCandidate = pObjList->GetObj(a);
+
+ // call recursively
+ if(IsObjMarkable(pCandidate))
+ {
+ bGroupIsMarkable = sal_True;
+ }
+ }
+
+ return bGroupIsMarkable;
+ }
+ else
+ {
+ // #i43302#
+ // Allow empty groups to be selected to be able to delete them
+ return sal_True;
+ }
+ }
+ else
+ {
+ // Der Layer muss sichtbar und darf nicht gesperrt sein
+ SdrLayerID nL = pObj->GetLayer();
+ return (aLayerVisi.IsSet(BYTE(nL)) && !aLayerLock.IsSet(BYTE(nL)));
+ }
+ }
+
+ return sal_False;
+}
+
+void SdrPageView::SetPageOrigin(const Point& rOrg)
+{
+ if (rOrg!=aPgOrg) {
+ aPgOrg=rOrg;
+ if (GetView().IsGridVisible()) {
+ InvalidateAllWin();
+ }
+ }
+}
+
+void SdrPageView::ImpInvalidateHelpLineArea(USHORT nNum) const
+{
+ if (GetView().IsHlplVisible() && nNum<aHelpLines.GetCount()) {
+ const SdrHelpLine& rHL=aHelpLines[nNum];
+
+ for(sal_uInt32 a(0L); a < GetView().PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = GetView().GetPaintWindow(a);
+
+ if(pCandidate->OutputToWindow())
+ {
+ OutputDevice& rOutDev = pCandidate->GetOutputDevice();
+ Rectangle aR(rHL.GetBoundRect(rOutDev));
+ Size aSiz(rOutDev.PixelToLogic(Size(1,1)));
+ aR.Left() -= aSiz.Width();
+ aR.Right() += aSiz.Width();
+ aR.Top() -= aSiz.Height();
+ aR.Bottom() += aSiz.Height();
+ ((SdrView&)GetView()).InvalidateOneWin((Window&)rOutDev, aR);
+ }
+ }
+ }
+}
+
+void SdrPageView::SetHelpLines(const SdrHelpLineList& rHLL)
+{
+ aHelpLines=rHLL;
+ InvalidateAllWin();
+}
+
+void SdrPageView::SetHelpLine(USHORT nNum, const SdrHelpLine& rNewHelpLine)
+{
+ if (nNum<aHelpLines.GetCount() && aHelpLines[nNum]!=rNewHelpLine) {
+ bool bNeedRedraw = true;
+ if (aHelpLines[nNum].GetKind()==rNewHelpLine.GetKind()) {
+ switch (rNewHelpLine.GetKind()) {
+ case SDRHELPLINE_VERTICAL : if (aHelpLines[nNum].GetPos().X()==rNewHelpLine.GetPos().X()) bNeedRedraw = false; break;
+ case SDRHELPLINE_HORIZONTAL: if (aHelpLines[nNum].GetPos().Y()==rNewHelpLine.GetPos().Y()) bNeedRedraw = false; break;
+ default: break;
+ } // switch
+ }
+ if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
+ aHelpLines[nNum]=rNewHelpLine;
+ if (bNeedRedraw) ImpInvalidateHelpLineArea(nNum);
+ }
+}
+
+void SdrPageView::DeleteHelpLine(USHORT nNum)
+{
+ if (nNum<aHelpLines.GetCount()) {
+ ImpInvalidateHelpLineArea(nNum);
+ aHelpLines.Delete(nNum);
+ }
+}
+
+void SdrPageView::InsertHelpLine(const SdrHelpLine& rHL, USHORT nNum)
+{
+ if (nNum>aHelpLines.GetCount()) nNum=aHelpLines.GetCount();
+ aHelpLines.Insert(rHL,nNum);
+ if (GetView().IsHlplVisible()) {
+ if (GetView().IsHlplFront()) {
+ // Hier optimieren ...
+ ImpInvalidateHelpLineArea(nNum);
+ } else {
+ ImpInvalidateHelpLineArea(nNum);
+ }
+ }
+}
+
+// Betretene Gruppe und Liste setzen
+void SdrPageView::SetAktGroupAndList(SdrObject* pNewGroup, SdrObjList* pNewList)
+{
+ if(pAktGroup != pNewGroup)
+ {
+ pAktGroup = pNewGroup;
+ }
+ if(pAktList != pNewList)
+ {
+ pAktList = pNewList;
+ }
+}
+
+sal_Bool SdrPageView::EnterGroup(SdrObject* pObj)
+{
+ sal_Bool bRet(sal_False);
+
+ if(pObj && pObj->IsGroupObject())
+ {
+ sal_Bool bGlueInvalidate(GetView().ImpIsGlueVisible());
+
+ if(bGlueInvalidate)
+ {
+ GetView().GlueInvalidate();
+ }
+
+ // deselect all
+ GetView().UnmarkAll();
+
+ // set current group and list
+ SdrObjList* pNewObjList = pObj->GetSubList();
+ SetAktGroupAndList(pObj, pNewObjList);
+
+ // select contained object if only one object is contained,
+ // else select nothing and let the user decide what to do next
+ if(pNewObjList && pNewObjList->GetObjCount() == 1)
+ {
+ SdrObject* pFirstObject = pNewObjList->GetObj(0L);
+
+ if(GetView().GetSdrPageView())
+ {
+ GetView().MarkObj(pFirstObject, GetView().GetSdrPageView());
+ }
+ }
+
+ // build new handles
+ GetView().AdjustMarkHdl();
+
+ // invalidate only when view wants to visualize group entering
+ if(GetView().DoVisualizeEnteredGroup())
+ {
+ InvalidateAllWin();
+ }
+
+ if (bGlueInvalidate)
+ {
+ GetView().GlueInvalidate();
+ }
+
+ bRet = sal_True;
+ }
+
+ return bRet;
+}
+
+void SdrPageView::LeaveOneGroup()
+{
+ if(GetAktGroup())
+ {
+ BOOL bGlueInvalidate = (GetView().ImpIsGlueVisible());
+
+ if(bGlueInvalidate)
+ GetView().GlueInvalidate();
+
+ SdrObject* pLastGroup = GetAktGroup();
+ SdrObject* pParentGroup = GetAktGroup()->GetUpGroup();
+ SdrObjList* pParentList = GetPage();
+
+ if(pParentGroup)
+ pParentList = pParentGroup->GetSubList();
+
+ // Alles deselektieren
+ GetView().UnmarkAll();
+
+ // Zuweisungen, pAktGroup und pAktList muessen gesetzt sein
+ SetAktGroupAndList(pParentGroup, pParentList);
+
+ // gerade verlassene Gruppe selektieren
+ if(pLastGroup)
+ if(GetView().GetSdrPageView())
+ GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
+
+ GetView().AdjustMarkHdl();
+
+ // invalidate only when view wants to visualize group entering
+ if(GetView().DoVisualizeEnteredGroup())
+ InvalidateAllWin();
+
+ if(bGlueInvalidate)
+ GetView().GlueInvalidate();
+ }
+}
+
+void SdrPageView::LeaveAllGroup()
+{
+ if(GetAktGroup())
+ {
+ BOOL bGlueInvalidate = (GetView().ImpIsGlueVisible());
+
+ if(bGlueInvalidate)
+ GetView().GlueInvalidate();
+
+ SdrObject* pLastGroup = GetAktGroup();
+
+ // Alles deselektieren
+ GetView().UnmarkAll();
+
+ // Zuweisungen, pAktGroup und pAktList muessen gesetzt sein
+ SetAktGroupAndList(NULL, GetPage());
+
+ // Oberste letzte Gruppe finden und selektieren
+ if(pLastGroup)
+ {
+ while(pLastGroup->GetUpGroup())
+ pLastGroup = pLastGroup->GetUpGroup();
+
+ if(GetView().GetSdrPageView())
+ GetView().MarkObj(pLastGroup, GetView().GetSdrPageView());
+ }
+
+ GetView().AdjustMarkHdl();
+
+ // invalidate only when view wants to visualize group entering
+ if(GetView().DoVisualizeEnteredGroup())
+ InvalidateAllWin();
+
+ if(bGlueInvalidate)
+ GetView().GlueInvalidate();
+ }
+}
+
+USHORT SdrPageView::GetEnteredLevel() const
+{
+ USHORT nAnz=0;
+ SdrObject* pGrp=GetAktGroup();
+ while (pGrp!=NULL) {
+ nAnz++;
+ pGrp=pGrp->GetUpGroup();
+ }
+ return nAnz;
+}
+
+XubString SdrPageView::GetActualGroupName() const
+{
+ if(GetAktGroup())
+ {
+ XubString aStr(GetAktGroup()->GetName());
+
+ if(!aStr.Len())
+ aStr += sal_Unicode('?');
+
+ return aStr;
+ }
+ else
+ return String();
+}
+
+XubString SdrPageView::GetActualPathName(sal_Unicode cSep) const
+{
+ XubString aStr;
+ BOOL bNamFnd(FALSE);
+ SdrObject* pGrp = GetAktGroup();
+
+ while(pGrp)
+ {
+ XubString aStr1(pGrp->GetName());
+
+ if(!aStr1.Len())
+ aStr1 += sal_Unicode('?');
+ else
+ bNamFnd = TRUE;
+
+ aStr += aStr1;
+ pGrp = pGrp->GetUpGroup();
+
+ if(pGrp)
+ aStr += cSep;
+ }
+
+ if(!bNamFnd && GetAktGroup())
+ {
+ aStr = String();
+ aStr += sal_Unicode('(');
+ aStr += String::CreateFromInt32( GetEnteredLevel() );
+ aStr += sal_Unicode(')');
+ }
+
+ return aStr;
+}
+
+void SdrPageView::CheckAktGroup()
+{
+ SdrObject* pGrp=GetAktGroup();
+ while (pGrp!=NULL &&
+ (!pGrp->IsInserted() || pGrp->GetObjList()==NULL ||
+ pGrp->GetPage()==NULL || pGrp->GetModel()==NULL)) { // irgendwas daneben?
+ pGrp=pGrp->GetUpGroup();
+ }
+ if (pGrp!=GetAktGroup()) {
+ if (pGrp!=NULL) EnterGroup(pGrp);
+ else LeaveAllGroup();
+ }
+}
+
+// #103834# Set background color for svx at SdrPageViews
+void SdrPageView::SetApplicationBackgroundColor(Color aBackgroundColor)
+{
+ maBackgroundColor = aBackgroundColor;
+}
+
+// #109585#
+Color SdrPageView::GetApplicationBackgroundColor() const
+{
+ return maBackgroundColor;
+}
+
+// #103911# Set document color for svx at SdrPageViews
+void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor)
+{
+ maDocumentColor = aDocumentColor;
+}
+
+Color SdrPageView::GetApplicationDocumentColor() const
+{
+ return maDocumentColor;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx
new file mode 100644
index 000000000000..734b123583d0
--- /dev/null
+++ b/svx/source/svdraw/svdpntv.cxx
@@ -0,0 +1,1543 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/awt/XWindow.hpp>
+#include <svx/svdpntv.hxx>
+#include <vcl/msgbox.hxx>
+#include <sdrpaintwindow.hxx>
+#include <svtools/grfmgr.hxx>
+#include <svx/svdmodel.hxx>
+
+#ifdef DBG_UTIL
+#include <svdibrow.hxx>
+#endif
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include <svl/smplhint.hxx>
+
+#include <svx/svdpntv.hxx>
+#include <editeng/editdata.hxx>
+#include <svx/svdmrkv.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdglue.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdattrx.hxx>
+#include "svdibrow.hxx"
+#include "svditer.hxx"
+#include <svx/svdouno.hxx>
+#include <svx/sdr/overlay/overlayobjectlist.hxx>
+#include <svx/sdr/overlay/overlayrollingrectangle.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <svx/svdglue.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdview.hxx>
+#include <svx/sxlayitm.hxx>
+#include <svl/itemiter.hxx>
+#include <editeng/eeitem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/style.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <svx/svdouno.hxx>
+#include <vcl/svapp.hxx>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+
+// #i38135#
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <svx/sdr/animation/objectanimator.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #114409#-3 Migrate Encirclement
+class ImplEncirclementOverlay
+{
+ // The OverlayObjects
+ ::sdr::overlay::OverlayObjectList maObjects;
+
+ // The remembered second position in logical coodinates
+ basegfx::B2DPoint maSecondPosition;
+
+public:
+ ImplEncirclementOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos);
+ ~ImplEncirclementOverlay();
+
+ void SetSecondPosition(const basegfx::B2DPoint& rNewPosition);
+};
+
+ImplEncirclementOverlay::ImplEncirclementOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos)
+: maSecondPosition(rStartPos)
+{
+ for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
+ ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
+
+ if(pTargetOverlay)
+ {
+ ::sdr::overlay::OverlayRollingRectangleStriped* aNew = new ::sdr::overlay::OverlayRollingRectangleStriped(
+ rStartPos, rStartPos, false);
+ pTargetOverlay->add(*aNew);
+ maObjects.append(*aNew);
+ }
+ }
+}
+
+ImplEncirclementOverlay::~ImplEncirclementOverlay()
+{
+ // The OverlayObjects are cleared using the destructor of OverlayObjectList.
+ // That destructor calls clear() at the list which removes all objects from the
+ // OverlayManager and deletes them.
+}
+
+void ImplEncirclementOverlay::SetSecondPosition(const basegfx::B2DPoint& rNewPosition)
+{
+ if(rNewPosition != maSecondPosition)
+ {
+ // apply to OverlayObjects
+ for(sal_uInt32 a(0L); a < maObjects.count(); a++)
+ {
+ ::sdr::overlay::OverlayRollingRectangleStriped& rCandidate = (::sdr::overlay::OverlayRollingRectangleStriped&)maObjects.getOverlayObject(a);
+ rCandidate.setSecondPosition(rNewPosition);
+ }
+
+ // remember new position
+ maSecondPosition = rNewPosition;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// interface to SdrPaintWindow
+
+SdrPaintWindow* SdrPaintView::FindPaintWindow(const OutputDevice& rOut) const
+{
+ for(SdrPaintWindowVector::const_iterator a = maPaintWindows.begin(); a != maPaintWindows.end(); a++)
+ {
+ if(&((*a)->GetOutputDevice()) == &rOut)
+ {
+ return *a;
+ }
+ }
+
+ return 0L;
+}
+
+SdrPaintWindow* SdrPaintView::GetPaintWindow(sal_uInt32 nIndex) const
+{
+ if(nIndex < maPaintWindows.size())
+ {
+ return maPaintWindows[nIndex];
+ }
+
+ return 0L;
+}
+
+void SdrPaintView::AppendPaintWindow(SdrPaintWindow& rNew)
+{
+ maPaintWindows.push_back(&rNew);
+}
+
+SdrPaintWindow* SdrPaintView::RemovePaintWindow(SdrPaintWindow& rOld)
+{
+ SdrPaintWindow* pRetval = 0L;
+ const SdrPaintWindowVector::iterator aFindResult = ::std::find(maPaintWindows.begin(), maPaintWindows.end(), &rOld);
+
+ if(aFindResult != maPaintWindows.end())
+ {
+ // remember return value, aFindResult is no longer valid after deletion
+ pRetval = *aFindResult;
+ maPaintWindows.erase(aFindResult);
+ }
+
+ return pRetval;
+}
+
+OutputDevice* SdrPaintView::GetFirstOutputDevice() const
+{
+ if(PaintWindowCount())
+ {
+ return &(GetPaintWindow(0)->GetOutputDevice());
+ }
+
+ return 0L;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1( SvxViewHint, SfxHint );
+
+SvxViewHint::SvxViewHint (HintType eHintType)
+ : meHintType(eHintType)
+{
+}
+
+SvxViewHint::HintType SvxViewHint::GetHintType (void) const
+{
+ return meHintType;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT2(SdrPaintView,SfxListener,SfxRepeatTarget);
+
+DBG_NAME(SdrPaintView);
+
+void SdrPaintView::ImpClearVars()
+{
+#ifdef DBG_UTIL
+ pItemBrowser=NULL;
+#endif
+ bPageVisible=TRUE;
+ bPageBorderVisible=TRUE;
+ bBordVisible=TRUE;
+ bGridVisible=TRUE;
+ bGridFront =FALSE;
+ bHlplVisible=TRUE;
+ bHlplFront =TRUE;
+ bGlueVisible=FALSE;
+ bGlueVisible2=FALSE;
+ bGlueVisible3=FALSE;
+ bGlueVisible4=FALSE;
+ bSwapAsynchron=FALSE;
+ bPrintPreview=FALSE;
+ mbPreviewRenderer=FALSE;
+
+ eAnimationMode = SDR_ANIMATION_ANIMATE;
+ bAnimationPause = FALSE;
+
+ nHitTolPix=2;
+ nMinMovPix=3;
+ nHitTolLog=0;
+ nMinMovLog=0;
+ pActualOutDev=NULL;
+ pDragWin=NULL;
+ bRestoreColors=TRUE;
+ pDefaultStyleSheet=NULL;
+ bSomeObjChgdFlag=FALSE;
+ nGraphicManagerDrawMode = GRFMGR_DRAW_STANDARD;
+ aComeBackTimer.SetTimeout(1);
+ aComeBackTimer.SetTimeoutHdl(LINK(this,SdrPaintView,ImpComeBackHdl));
+ String aNam; // System::GetUserName() just return an empty string
+
+ if (pMod)
+ SetDefaultStyleSheet(pMod->GetDefaultStyleSheet(), TRUE);
+
+ aNam.ToUpperAscii();
+
+ maGridColor = Color( COL_BLACK );
+ BrkEncirclement();
+}
+
+SdrPaintView::SdrPaintView(SdrModel* pModel1, OutputDevice* pOut)
+: mpEncirclementOverlay(0L),
+ mpPageView(0L),
+ aDefaultAttr(pModel1->GetItemPool()),
+ mbBufferedOutputAllowed(false),
+ mbBufferedOverlayAllowed(false),
+ mbPagePaintingAllowed(true),
+ mbHideOle(false),
+ mbHideChart(false),
+ mbHideDraw(false),
+ mbHideFormControl(false)
+{
+ DBG_CTOR(SdrPaintView,NULL);
+ pMod=pModel1;
+ ImpClearVars();
+
+ if(pOut)
+ {
+ AddWindowToPaintView(pOut);
+ }
+
+ // Flag zur Visualisierung von Gruppen
+ bVisualizeEnteredGroup = TRUE;
+
+ maColorConfig.AddListener(this);
+ onChangeColorConfig();
+}
+
+SdrPaintView::~SdrPaintView()
+{
+ DBG_DTOR(SdrPaintView,NULL);
+ if (pDefaultStyleSheet)
+ EndListening(*pDefaultStyleSheet);
+
+ maColorConfig.RemoveListener(this);
+ ClearPageView();
+
+#ifdef DBG_UTIL
+ if(pItemBrowser)
+ {
+ delete pItemBrowser;
+ }
+#endif
+
+ // delete existing SdrPaintWindows
+ while(maPaintWindows.size())
+ {
+ delete maPaintWindows.back();
+ maPaintWindows.pop_back();
+ }
+
+ // #114409#-3 Migrate HelpLine
+ BrkEncirclement();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void __EXPORT SdrPaintView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+{
+ //If the stylesheet has been destroyed
+ if (&rBC == pDefaultStyleSheet)
+ {
+ if (rHint.ISA(SfxSimpleHint) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING)
+ pDefaultStyleSheet = NULL;
+ return;
+ }
+
+ BOOL bObjChg=!bSomeObjChgdFlag; // TRUE= auswerten fuer ComeBack-Timer
+ if (bObjChg) {
+ SdrHint* pSdrHint=PTR_CAST(SdrHint,&rHint);
+ if (pSdrHint!=NULL) {
+ SdrHintKind eKind=pSdrHint->GetKind();
+ if (eKind==HINT_OBJCHG || eKind==HINT_OBJINSERTED || eKind==HINT_OBJREMOVED) {
+ if (bObjChg) {
+ bSomeObjChgdFlag=TRUE;
+ aComeBackTimer.Start();
+ }
+ }
+ if (eKind==HINT_PAGEORDERCHG) {
+ const SdrPage* pPg=pSdrHint->GetPage();
+
+ if(pPg && !pPg->IsInserted())
+ {
+ if(mpPageView && mpPageView->GetPage() == pPg)
+ {
+ HideSdrPage();
+ }
+ }
+ }
+ }
+ }
+}
+
+void SdrPaintView::ConfigurationChanged( ::utl::ConfigurationBroadcaster* , sal_uInt32 )
+{
+ onChangeColorConfig();
+ InvalidateAllWin();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+IMPL_LINK_INLINE_START(SdrPaintView,ImpComeBackHdl,Timer*,EMPTYARG)
+{
+ if (bSomeObjChgdFlag) {
+ bSomeObjChgdFlag=FALSE;
+ ModelHasChanged();
+ }
+ return 0;
+}
+IMPL_LINK_INLINE_END(SdrPaintView,ImpComeBackHdl,Timer*,pTimer)
+
+void SdrPaintView::FlushComeBackTimer() const
+{
+ if (bSomeObjChgdFlag) {
+ // casting auf nonconst
+ ((SdrPaintView*)this)->ImpComeBackHdl(&((SdrPaintView*)this)->aComeBackTimer);
+ ((SdrPaintView*)this)->aComeBackTimer.Stop();
+ }
+}
+
+void SdrPaintView::ModelHasChanged()
+{
+ // Auch alle PageViews benachrichtigen
+ if(mpPageView && !mpPageView->GetPage()->IsInserted())
+ {
+ HideSdrPage();
+ }
+
+ // test mpPageView here again, HideSdrPage() may have invalidated it.
+ if(mpPageView)
+ {
+ mpPageView->ModelHasChanged();
+ }
+
+#ifdef DBG_UTIL
+ if(pItemBrowser)
+ {
+ pItemBrowser->SetDirty();
+ }
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrPaintView::IsAction() const
+{
+ return IsEncirclement();
+}
+
+void SdrPaintView::MovAction(const Point& rPnt)
+{
+ if (IsEncirclement())
+ {
+ MovEncirclement(rPnt);
+ }
+}
+
+void SdrPaintView::EndAction()
+{
+ if(IsEncirclement())
+ {
+ EndEncirclement();
+ }
+}
+
+void SdrPaintView::BckAction()
+{
+ BrkEncirclement();
+}
+
+void SdrPaintView::BrkAction()
+{
+ BrkEncirclement();
+}
+
+void SdrPaintView::TakeActionRect(Rectangle& rRect) const
+{
+ if(IsEncirclement())
+ {
+ rRect = Rectangle(aDragStat.GetStart(),aDragStat.GetNow());
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// info about TextEdit. Default is sal_False.
+bool SdrPaintView::IsTextEdit() const
+{
+ return false;
+}
+
+// info about TextEditPageView. Default is 0L.
+SdrPageView* SdrPaintView::GetTextEditPageView() const
+{
+ return 0L;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+USHORT SdrPaintView::ImpGetMinMovLogic(short nMinMov, const OutputDevice* pOut) const
+{
+ if (nMinMov>=0) return USHORT(nMinMov);
+ if (pOut==NULL)
+ {
+ pOut = GetFirstOutputDevice();
+ }
+ if (pOut!=NULL) {
+ return short(-pOut->PixelToLogic(Size(nMinMov,0)).Width());
+ } else {
+ return 0;
+ }
+}
+
+USHORT SdrPaintView::ImpGetHitTolLogic(short nHitTol, const OutputDevice* pOut) const
+{
+ if (nHitTol>=0) return USHORT(nHitTol);
+ if (pOut==NULL)
+ {
+ pOut = GetFirstOutputDevice();
+ }
+ if (pOut!=NULL) {
+ return short(-pOut->PixelToLogic(Size(nHitTol,0)).Width());
+ } else {
+ return 0;
+ }
+}
+
+void SdrPaintView::TheresNewMapMode()
+{
+ if (pActualOutDev!=NULL) {
+ nHitTolLog=(USHORT)((OutputDevice*)pActualOutDev)->PixelToLogic(Size(nHitTolPix,0)).Width();
+ nMinMovLog=(USHORT)((OutputDevice*)pActualOutDev)->PixelToLogic(Size(nMinMovPix,0)).Width();
+ }
+}
+
+void SdrPaintView::SetActualWin(const OutputDevice* pWin)
+{
+ pActualOutDev=pWin;
+ TheresNewMapMode();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrPaintView::BegEncirclement(const Point& rPnt)
+{
+ BrkAction();
+
+ DBG_ASSERT(0L == mpEncirclementOverlay, "SdrSnapView::BegSetPageOrg: There exists a ImplPageOriginOverlay (!)");
+ basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
+ mpEncirclementOverlay = new ImplEncirclementOverlay(*this, aStartPos);
+
+ aDragStat.Reset(rPnt);
+ aDragStat.SetMinMove(ImpGetMinMovLogic(-2,0L));
+ aDragStat.NextPoint();
+}
+
+void SdrPaintView::MovEncirclement(const Point& rPnt)
+{
+ if(IsEncirclement() && aDragStat.CheckMinMoved(rPnt))
+ {
+ aDragStat.NextMove(rPnt);
+
+ DBG_ASSERT(mpEncirclementOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
+ basegfx::B2DPoint aNewPos(rPnt.X(), rPnt.Y());
+ mpEncirclementOverlay->SetSecondPosition(aNewPos);
+ }
+}
+
+Rectangle SdrPaintView::EndEncirclement(sal_Bool bNoJustify)
+{
+ Rectangle aRetval;
+
+ if(IsEncirclement())
+ {
+ if(aDragStat.IsMinMoved())
+ {
+ aRetval = Rectangle(aDragStat.GetStart(), aDragStat.GetNow());
+
+ if(!bNoJustify)
+ {
+ aRetval.Justify();
+ }
+ }
+
+ // cleanup
+ BrkEncirclement();
+ }
+
+ return aRetval;
+}
+
+void SdrPaintView::BrkEncirclement()
+{
+ if(IsEncirclement())
+ {
+ DBG_ASSERT(mpEncirclementOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
+ delete mpEncirclementOverlay;
+ mpEncirclementOverlay = 0L;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrPaintView::ClearPageView()
+{
+ BrkAction();
+
+ if(mpPageView)
+ {
+ InvalidateAllWin();
+ delete mpPageView;
+ mpPageView = 0L;
+ }
+}
+
+SdrPageView* SdrPaintView::ShowSdrPage(SdrPage* pPage)
+{
+ if(pPage && (!mpPageView || mpPageView->GetPage() != pPage))
+ {
+ if(mpPageView)
+ {
+ InvalidateAllWin();
+ delete mpPageView;
+ }
+
+ mpPageView = new SdrPageView(pPage, *((SdrView*)this));
+ mpPageView->Show();
+ }
+
+ return mpPageView;
+}
+
+void SdrPaintView::HideSdrPage()
+{
+ if(mpPageView)
+ {
+ mpPageView->Hide();
+ delete mpPageView;
+ mpPageView = 0L;
+ }
+}
+
+void SdrPaintView::AddWindowToPaintView(OutputDevice* pNewWin)
+{
+ DBG_ASSERT(pNewWin, "SdrPaintView::AddWindowToPaintView: No OutputDevice(!)");
+ SdrPaintWindow* pNewPaintWindow = new SdrPaintWindow(*this, *pNewWin);
+ AppendPaintWindow(*pNewPaintWindow);
+
+ if(mpPageView)
+ {
+ mpPageView->AddPaintWindowToPageView(*pNewPaintWindow);
+ }
+
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL)
+ pItemBrowser->ForceParent();
+#endif
+}
+
+void SdrPaintView::DeleteWindowFromPaintView(OutputDevice* pOldWin)
+{
+ DBG_ASSERT(pOldWin, "SdrPaintView::DeleteWindowFromPaintView: No OutputDevice(!)");
+ SdrPaintWindow* pCandidate = FindPaintWindow(*pOldWin);
+
+ if(pCandidate)
+ {
+ if(mpPageView)
+ {
+ mpPageView->RemovePaintWindowFromPageView(*pCandidate);
+ }
+
+ RemovePaintWindow(*pCandidate);
+ delete pCandidate;
+ }
+
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL)
+ pItemBrowser->ForceParent();
+#endif
+}
+
+void SdrPaintView::SetLayerVisible(const XubString& rName, BOOL bShow)
+{
+ if(mpPageView)
+ {
+ mpPageView->SetLayerVisible(rName,bShow);
+ }
+
+ InvalidateAllWin();
+}
+
+bool SdrPaintView::IsLayerVisible(const XubString& rName) const
+{
+ if(mpPageView)
+ {
+ return mpPageView->IsLayerVisible(rName);
+ }
+
+ return false;
+}
+
+void SdrPaintView::SetAllLayersVisible(BOOL bShow)
+{
+ if(mpPageView)
+ {
+ mpPageView->SetAllLayersVisible(bShow);
+ }
+
+ InvalidateAllWin();
+}
+
+void SdrPaintView::SetLayerLocked(const XubString& rName, BOOL bLock)
+{
+ if(mpPageView)
+ {
+ mpPageView->SetLayerLocked(rName,bLock);
+ }
+}
+
+bool SdrPaintView::IsLayerLocked(const XubString& rName) const
+{
+ if(mpPageView)
+ {
+ return mpPageView->IsLayerLocked(rName);
+ }
+
+ return false;
+}
+
+void SdrPaintView::SetAllLayersLocked(BOOL bLock)
+{
+ if(mpPageView)
+ {
+ mpPageView->SetAllLayersLocked(bLock);
+ }
+}
+
+void SdrPaintView::SetLayerPrintable(const XubString& rName, BOOL bPrn)
+{
+ if(mpPageView)
+ {
+ mpPageView->SetLayerPrintable(rName,bPrn);
+ }
+}
+
+bool SdrPaintView::IsLayerPrintable(const XubString& rName) const
+{
+ if(mpPageView)
+ {
+ return mpPageView->IsLayerPrintable(rName);
+ }
+
+ return false;
+}
+
+void SdrPaintView::SetAllLayersPrintable(BOOL bPrn)
+{
+ if(mpPageView)
+ {
+ mpPageView->SetAllLayersPrintable(bPrn);
+ }
+}
+
+void SdrPaintView::PrePaint()
+{
+ if(mpPageView)
+ {
+ mpPageView->PrePaint();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #define SVX_REPAINT_TIMER_TEST
+
+void SdrPaintView::CompleteRedraw(OutputDevice* pOut, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector)
+{
+#ifdef SVX_REPAINT_TIMER_TEST
+#define REMEMBERED_TIMES_COUNT (10)
+ static bool bDoTimerTest(false);
+ static bool bTimesInited(false);
+ static sal_uInt32 nRepeatCount(10L);
+ static double fLastTimes[REMEMBERED_TIMES_COUNT];
+ const sal_uInt32 nStartTime(Time::GetSystemTicks());
+ sal_uInt32 count(1L);
+ sal_uInt32 a;
+
+ if(bDoTimerTest)
+ {
+ count = nRepeatCount;
+ }
+
+ for(a = 0L; a < count; a++)
+ {
+#endif // SVX_REPAINT_TIMER_TEST
+
+ // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region
+ // rReg may be made more granular (fine) with using it. Normally, rReg
+ // does come from Window::Paint() anyways and thus is based on a single
+ // rectangle which was derived from exactly that repaint region
+ Region aOptimizedRepaintRegion(rReg);
+
+ if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType())
+ {
+ Window* pWindow = (Window*)pOut;
+
+ if(pWindow->IsInPaint())
+ {
+ if(!pWindow->GetPaintRegion().IsEmpty())
+ {
+ aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion());
+
+#ifdef DBG_UTIL
+ // #i74769# test-paint repaint region
+ static bool bDoPaintForVisualControl(false);
+ if(bDoPaintForVisualControl)
+ {
+ RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
+ Rectangle aRegionRectangle;
+
+ while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
+ {
+ pWindow->SetLineColor(COL_LIGHTGREEN);
+ pWindow->SetFillColor();
+ pWindow->DrawRect(aRegionRectangle);
+ }
+
+ aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
+ }
+#endif
+ }
+ }
+ }
+
+ SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut);
+ OSL_ENSURE(pPaintWindow, "SdrPaintView::CompleteRedraw: No OutDev (!)");
+
+ DoCompleteRedraw(*pPaintWindow, aOptimizedRepaintRegion, pRedirector);
+ EndCompleteRedraw(*pPaintWindow, true);
+
+#ifdef SVX_REPAINT_TIMER_TEST
+ }
+
+ if(bDoTimerTest)
+ {
+ const sal_uInt32 nStopTime(Time::GetSystemTicks());
+ const sal_uInt32 nNeededTime(nStopTime - nStartTime);
+ const double fTimePerPaint((double)nNeededTime / (double)nRepeatCount);
+
+ if(!bTimesInited)
+ {
+ for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++)
+ {
+ fLastTimes[a] = fTimePerPaint;
+ }
+
+ bTimesInited = true;
+ }
+ else
+ {
+ for(a = 1L; a < REMEMBERED_TIMES_COUNT; a++)
+ {
+ fLastTimes[a - 1L] = fLastTimes[a];
+ }
+
+ fLastTimes[REMEMBERED_TIMES_COUNT - 1L] = fTimePerPaint;
+ }
+
+ double fAddedTimes(0.0);
+
+ for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++)
+ {
+ fAddedTimes += fLastTimes[a];
+ }
+
+ const double fAverageTimePerPaint(fAddedTimes / (double)REMEMBERED_TIMES_COUNT);
+
+ fprintf(stderr, "-----------(start result)----------\n");
+ fprintf(stderr, "StartTime : %u, StopTime: %u, NeededTime: %u, TimePerPaint: %f\n", nStartTime, nStopTime, nNeededTime, fTimePerPaint);
+ fprintf(stderr, "Remembered times: ");
+
+ for(a = 0L; a < REMEMBERED_TIMES_COUNT; a++)
+ {
+ fprintf(stderr, "%d: %f ", a, fLastTimes[a]);
+ }
+
+ fprintf(stderr, "\n");
+ fprintf(stderr, "AverageTimePerPaint: %f\n", fAverageTimePerPaint);
+ fprintf(stderr, "-----------(stop result)----------\n");
+ }
+#endif // SVX_REPAINT_TIMER_TEST
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #i72889#
+
+SdrPaintWindow* SdrPaintView::BeginCompleteRedraw(OutputDevice* pOut)
+{
+ OSL_ENSURE(pOut, "SdrPaintView::BeginCompleteRedraw: No OutDev (!)");
+ SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut);
+
+ if(pPaintWindow)
+ {
+ // draw preprocessing, only for known devices
+ // prepare PreRendering
+ pPaintWindow->PreparePreRenderDevice();
+ }
+ else
+ {
+ // None of the known OutputDevices is the target of this paint, use
+ // a temporary SdrPaintWindow for this Redraw.
+ pPaintWindow = new SdrPaintWindow(*this, *pOut);
+ pPaintWindow->setTemporaryTarget(true);
+ }
+
+ return pPaintWindow;
+}
+
+void SdrPaintView::DoCompleteRedraw(SdrPaintWindow& rPaintWindow, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector)
+{
+ // redraw all PageViews with the target. This may expand the RedrawRegion
+ // at the PaintWindow, plus taking care of FormLayer expansion
+ if(mpPageView)
+ {
+ mpPageView->CompleteRedraw(rPaintWindow, rReg, pRedirector);
+ }
+}
+
+void SdrPaintView::EndCompleteRedraw(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer)
+{
+ if(rPaintWindow.getTemporaryTarget())
+ {
+ // get rid of temp target again
+ delete (&rPaintWindow);
+ }
+ else
+ {
+ // draw postprocessing, only for known devices
+ // it is necessary to always paint FormLayer
+ if(bPaintFormLayer)
+ {
+ ImpFormLayerDrawing(rPaintWindow);
+ }
+
+ // look for active TextEdit. As long as this cannot be painted to a VDev,
+ // it cannot get part of buffering. In that case, output evtl. prerender
+ // early and paint text edit to window.
+ const bool bTextEditActive(IsTextEdit() && GetTextEditPageView());
+
+ if(bTextEditActive)
+ {
+ // output PreRendering and destroy it so that it is not used for FormLayer
+ // or overlay
+ rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion());
+
+ // draw old text edit stuff before overlay to have it as part of the background
+ // ATM. This will be changed to have the text editing on the overlay, bit it
+ // is not an easy thing to do, see BegTextEdit and the OutlinerView stuff used...
+ if(bTextEditActive)
+ {
+ ImpTextEditDrawing(rPaintWindow);
+ }
+
+ // draw Overlay directly to window. This will save the contents of the window
+ // in the RedrawRegion to the overlay background buffer, too.
+ // This may lead to problems when reading from the screen is slow from the
+ // graphics driver/graphiccard combination.
+ rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion(), false);
+ }
+ else
+ {
+ // draw Overlay, also to PreRender device if exists
+ rPaintWindow.DrawOverlay(rPaintWindow.GetRedrawRegion(), true);
+
+ // output PreRendering
+ rPaintWindow.OutputPreRenderDevice(rPaintWindow.GetRedrawRegion());
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrPaintWindow* SdrPaintView::BeginDrawLayers(OutputDevice* pOut, const Region& rReg, bool bDisableIntersect)
+{
+ // #i74769# use BeginCompleteRedraw() as common base
+ SdrPaintWindow* pPaintWindow = BeginCompleteRedraw(pOut);
+ OSL_ENSURE(pPaintWindow, "SdrPaintView::BeginDrawLayers: No SdrPaintWindow (!)");
+
+ if(mpPageView)
+ {
+ SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(*pPaintWindow);
+
+ if(pKnownTarget)
+ {
+ // #i74769# check if pOut is a win and has a ClipRegion. If Yes, the Region
+ // rReg may be made more granular (fine) with using it. Normally, rReg
+ // does come from Window::Paint() anyways and thus is based on a single
+ // rectangle which was derived from exactly that repaint region
+ Region aOptimizedRepaintRegion(rReg);
+
+ // #i76114# Intersecting the region with the Window's paint region is disabled
+ // for print preview in Calc, because the intersection can be empty (if the paint
+ // region is outside of the table area of the page), and then no clip region
+ // would be set.
+ if(pOut && OUTDEV_WINDOW == pOut->GetOutDevType() && !bDisableIntersect)
+ {
+ Window* pWindow = (Window*)pOut;
+
+ if(pWindow->IsInPaint())
+ {
+ if(!pWindow->GetPaintRegion().IsEmpty())
+ {
+ aOptimizedRepaintRegion.Intersect(pWindow->GetPaintRegion());
+
+#ifdef DBG_UTIL
+ // #i74769# test-paint repaint region
+ static bool bDoPaintForVisualControl(false);
+ if(bDoPaintForVisualControl)
+ {
+ RegionHandle aRegionHandle(aOptimizedRepaintRegion.BeginEnumRects());
+ Rectangle aRegionRectangle;
+
+ while(aOptimizedRepaintRegion.GetEnumRects(aRegionHandle, aRegionRectangle))
+ {
+ pWindow->SetLineColor(COL_LIGHTGREEN);
+ pWindow->SetFillColor();
+ pWindow->DrawRect(aRegionRectangle);
+ }
+
+ aOptimizedRepaintRegion.EndEnumRects(aRegionHandle);
+ }
+#endif
+ }
+ }
+ }
+
+ // prepare redraw
+ pKnownTarget->PrepareRedraw(aOptimizedRepaintRegion);
+
+ // remember prepared SdrPageWindow
+ mpPageView->setPreparedPageWindow(pKnownTarget);
+ }
+ }
+
+ return pPaintWindow;
+}
+
+void SdrPaintView::EndDrawLayers(SdrPaintWindow& rPaintWindow, bool bPaintFormLayer)
+{
+ // #i74769# use EndCompleteRedraw() as common base
+ EndCompleteRedraw(rPaintWindow, bPaintFormLayer);
+
+ if(mpPageView)
+ {
+ // forget prepared SdrPageWindow
+ mpPageView->setPreparedPageWindow(0);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrPaintView::ImpTextEditDrawing(SdrPaintWindow& rPaintWindow) const
+{
+ // draw old text edit stuff
+ if(IsTextEdit())
+ {
+ SdrPageView* pPageView = GetTextEditPageView();
+
+ if(pPageView)
+ {
+ // paint TextEdit directly to the destination OutDev
+ const Region& rRedrawRegion = rPaintWindow.GetRedrawRegion();
+ const Rectangle aCheckRect(rRedrawRegion.GetBoundRect());
+ pPageView->PaintOutlinerView(&rPaintWindow.GetOutputDevice(), aCheckRect);
+ }
+ }
+}
+
+void SdrPaintView::ImpFormLayerDrawing(SdrPaintWindow& rPaintWindow) const
+{
+ if(mpPageView)
+ {
+ SdrPageWindow* pKnownTarget = mpPageView->FindPageWindow(rPaintWindow);
+
+ if(pKnownTarget)
+ {
+ const SdrModel& rModel = *(GetModel());
+ const SdrLayerAdmin& rLayerAdmin = rModel.GetLayerAdmin();
+ const SdrLayerID nControlLayerId = rLayerAdmin.GetLayerID(rLayerAdmin.GetControlLayerName(), sal_False);
+
+ // BUFFERED use GetTargetOutputDevice() now, it may be targeted to VDevs, too
+ // need to set PreparedPageWindow to make DrawLayer use the correct ObjectContact
+ mpPageView->setPreparedPageWindow(pKnownTarget);
+ mpPageView->DrawLayer(nControlLayerId, &rPaintWindow.GetTargetOutputDevice());
+ mpPageView->setPreparedPageWindow(0);
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrPaintView::KeyInput(const KeyEvent& /*rKEvt*/, Window* /*pWin*/)
+{
+ return FALSE;
+}
+
+void SdrPaintView::GlueInvalidate() const
+{
+ const sal_uInt32 nWindowCount(PaintWindowCount());
+
+ for(sal_uInt32 nWinNum(0L); nWinNum < nWindowCount; nWinNum++)
+ {
+ SdrPaintWindow* pPaintWindow = GetPaintWindow(nWinNum);
+
+ if(pPaintWindow->OutputToWindow())
+ {
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+
+ if(mpPageView)
+ {
+ const SdrObjList* pOL=mpPageView->GetObjList();
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
+ const SdrObject* pObj=pOL->GetObj(nObjNum);
+ const SdrGluePointList* pGPL=pObj->GetGluePointList();
+ if (pGPL!=NULL && pGPL->GetCount()!=0) {
+ pGPL->Invalidate((Window&)rOutDev, pObj);
+ }
+ }
+ }
+ }
+ }
+}
+
+void SdrPaintView::InvalidateAllWin()
+{
+ const sal_uInt32 nWindowCount(PaintWindowCount());
+
+ for(sal_uInt32 a(0L); a < nWindowCount; a++)
+ {
+ SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
+
+ if(pPaintWindow->OutputToWindow())
+ {
+ InvalidateOneWin((Window&)pPaintWindow->GetOutputDevice());
+ }
+ }
+}
+
+void SdrPaintView::InvalidateAllWin(const Rectangle& rRect, BOOL bPlus1Pix)
+{
+ const sal_uInt32 nWindowCount(PaintWindowCount());
+
+ for(sal_uInt32 a(0L); a < nWindowCount; a++)
+ {
+ SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
+
+ if(pPaintWindow->OutputToWindow())
+ {
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+ Rectangle aRect(rRect);
+
+ if(bPlus1Pix)
+ {
+ Size aPixSiz(1,1);
+ Size aSiz(rOutDev.PixelToLogic(aPixSiz));
+ aRect.Left ()-=aSiz.Width();
+ aRect.Top ()-=aSiz.Height();
+ aRect.Right ()+=aSiz.Width();
+ aRect.Bottom()+=aSiz.Height();
+ }
+
+ Point aOrg(rOutDev.GetMapMode().GetOrigin());
+ aOrg.X()=-aOrg.X(); aOrg.Y()=-aOrg.Y();
+ Rectangle aOutRect(aOrg, rOutDev.GetOutputSize());
+
+ if (aRect.IsOver(aOutRect))
+ {
+ InvalidateOneWin((Window&)rOutDev, aRect);
+ }
+ }
+ }
+}
+
+void SdrPaintView::InvalidateOneWin(Window& rWin)
+{
+ // #111096#
+ // do not erase background, that causes flicker (!)
+ rWin.Invalidate(INVALIDATE_NOERASE);
+}
+
+void SdrPaintView::InvalidateOneWin(Window& rWin, const Rectangle& rRect)
+{
+ // #111096#
+ // do not erase background, that causes flicker (!)
+ rWin.Invalidate(rRect, INVALIDATE_NOERASE);
+}
+
+void SdrPaintView::LeaveOneGroup()
+{
+ if(mpPageView)
+ {
+ mpPageView->LeaveOneGroup();
+ }
+}
+
+void SdrPaintView::LeaveAllGroup()
+{
+ if(mpPageView)
+ {
+ mpPageView->LeaveAllGroup();
+ }
+}
+
+bool SdrPaintView::IsGroupEntered() const
+{
+ if(mpPageView)
+ {
+ return (mpPageView->GetEnteredLevel() != 0);
+ }
+
+ return false;
+}
+
+void SdrPaintView::SetNotPersistDefaultAttr(const SfxItemSet& rAttr, BOOL /*bReplaceAll*/)
+{
+ // bReplaceAll hat hier keinerlei Wirkung
+ BOOL bMeasure=ISA(SdrView) && ((SdrView*)this)->IsMeasureTool();
+ const SfxPoolItem *pPoolItem=NULL;
+ if (rAttr.GetItemState(SDRATTR_LAYERID,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ SdrLayerID nLayerId=((const SdrLayerIdItem*)pPoolItem)->GetValue();
+ const SdrLayer* pLayer=pMod->GetLayerAdmin().GetLayerPerID(nLayerId);
+ if (pLayer!=NULL) {
+ if (bMeasure) aMeasureLayer=pLayer->GetName();
+ else aAktLayer=pLayer->GetName();
+ }
+ }
+ if (rAttr.GetItemState(SDRATTR_LAYERNAME,TRUE,&pPoolItem)==SFX_ITEM_SET) {
+ if (bMeasure) aMeasureLayer=((const SdrLayerNameItem*)pPoolItem)->GetValue();
+ else aAktLayer=((const SdrLayerNameItem*)pPoolItem)->GetValue();
+ }
+}
+
+void SdrPaintView::MergeNotPersistDefaultAttr(SfxItemSet& rAttr, BOOL /*bOnlyHardAttr*/) const
+{
+ // bOnlyHardAttr hat hier keinerlei Wirkung
+ BOOL bMeasure=ISA(SdrView) && ((SdrView*)this)->IsMeasureTool();
+ const XubString& aNam=bMeasure?aMeasureLayer:aAktLayer;
+ rAttr.Put(SdrLayerNameItem(aNam));
+ SdrLayerID nLayer=pMod->GetLayerAdmin().GetLayerID(aNam,TRUE);
+ if (nLayer!=SDRLAYER_NOTFOUND) {
+ rAttr.Put(SdrLayerIdItem(nLayer));
+ }
+}
+
+void SdrPaintView::SetDefaultAttr(const SfxItemSet& rAttr, BOOL bReplaceAll)
+{
+#ifdef DBG_UTIL
+ {
+ BOOL bHasEEFeatureItems=FALSE;
+ SfxItemIter aIter(rAttr);
+ const SfxPoolItem* pItem=aIter.FirstItem();
+ while (!bHasEEFeatureItems && pItem!=NULL) {
+ if (!IsInvalidItem(pItem)) {
+ USHORT nW=pItem->Which();
+ if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) bHasEEFeatureItems=TRUE;
+ }
+ pItem=aIter.NextItem();
+ }
+
+ if(bHasEEFeatureItems)
+ {
+ String aMessage;
+ aMessage.AppendAscii("SdrPaintView::SetDefaultAttr(): Das setzen von EE_FEATURE-Items an der SdrView macht keinen Sinn! Es fuehrt nur zu Overhead und nicht mehr lesbaren Dokumenten.");
+ InfoBox(NULL, aMessage).Execute();
+ }
+ }
+#endif
+ if (bReplaceAll) aDefaultAttr.Set(rAttr);
+ else aDefaultAttr.Put(rAttr,FALSE); // FALSE= InvalidItems nicht als Default, sondern als "Loecher" betrachten
+ SetNotPersistDefaultAttr(rAttr,bReplaceAll);
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+}
+
+void SdrPaintView::SetDefaultStyleSheet(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr)
+{
+ if (pDefaultStyleSheet)
+ EndListening(*pDefaultStyleSheet);
+ pDefaultStyleSheet=pStyleSheet;
+ if (pDefaultStyleSheet)
+ StartListening(*pDefaultStyleSheet);
+
+ if (pStyleSheet!=NULL && !bDontRemoveHardAttr) {
+ SfxWhichIter aIter(pStyleSheet->GetItemSet());
+ USHORT nWhich=aIter.FirstWhich();
+ while (nWhich!=0) {
+ if (pStyleSheet->GetItemSet().GetItemState(nWhich,TRUE)==SFX_ITEM_SET) {
+ aDefaultAttr.ClearItem(nWhich);
+ }
+ nWhich=aIter.NextWhich();
+ }
+ }
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+}
+
+/* new interface src537 */
+BOOL SdrPaintView::GetAttributes(SfxItemSet& rTargetSet, BOOL bOnlyHardAttr) const
+{
+ if(bOnlyHardAttr || !pDefaultStyleSheet)
+ {
+ rTargetSet.Put(aDefaultAttr, FALSE);
+ }
+ else
+ {
+ // sonst DefStyleSheet dazumergen
+ rTargetSet.Put(pDefaultStyleSheet->GetItemSet(), FALSE);
+ rTargetSet.Put(aDefaultAttr, FALSE);
+ }
+ MergeNotPersistDefaultAttr(rTargetSet, bOnlyHardAttr);
+ return TRUE;
+}
+
+BOOL SdrPaintView::SetAttributes(const SfxItemSet& rSet, BOOL bReplaceAll)
+{
+ SetDefaultAttr(rSet,bReplaceAll);
+ return TRUE;
+}
+
+SfxStyleSheet* SdrPaintView::GetStyleSheet() const // SfxStyleSheet* SdrPaintView::GetStyleSheet(BOOL& rOk) const
+{
+ //rOk=TRUE;
+ return GetDefaultStyleSheet();
+}
+
+BOOL SdrPaintView::SetStyleSheet(SfxStyleSheet* pStyleSheet, BOOL bDontRemoveHardAttr)
+{
+ SetDefaultStyleSheet(pStyleSheet,bDontRemoveHardAttr);
+ return TRUE;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+#ifdef DBG_UTIL
+void SdrPaintView::ShowItemBrowser(BOOL bShow)
+{
+ if (bShow) {
+ if (pItemBrowser==NULL) {
+ pItemBrowser=new SdrItemBrowser(*(SdrView*)this);
+ pItemBrowser->SetFloatingMode(TRUE);
+ }
+ pItemBrowser->Show();
+ pItemBrowser->GrabFocus();
+ } else {
+ if (pItemBrowser!=NULL) {
+ pItemBrowser->Hide();
+ delete pItemBrowser;
+ pItemBrowser=NULL;
+ }
+ }
+}
+#endif
+
+void SdrPaintView::MakeVisible(const Rectangle& rRect, Window& rWin)
+{
+ MapMode aMap(rWin.GetMapMode());
+ Size aActualSize(rWin.GetOutputSize());
+
+ if( aActualSize.Height() > 0 && aActualSize.Width() > 0 )
+ {
+ Size aNewSize(rRect.GetSize());
+ BOOL bNewScale=FALSE;
+ BOOL bNeedMoreX=aNewSize.Width()>aActualSize.Width();
+ BOOL bNeedMoreY=aNewSize.Height()>aActualSize.Height();
+ if (bNeedMoreX || bNeedMoreY)
+ {
+ bNewScale=TRUE;
+ // Neuen MapMode (Size+Org) setzen und dabei alles invalidieren
+ Fraction aXFact(aNewSize.Width(),aActualSize.Width());
+ Fraction aYFact(aNewSize.Height(),aActualSize.Height());
+ if (aYFact>aXFact) aXFact=aYFact;
+ aXFact*=aMap.GetScaleX();
+ aXFact.ReduceInaccurate(10); // Um Ueberlaeufe und BigInt-Mapping zu vermeiden
+ aMap.SetScaleX(aXFact);
+ aMap.SetScaleY(aYFact);
+ rWin.SetMapMode(aMap);
+ aActualSize=rWin.GetOutputSize();
+ }
+ Point aOrg(aMap.GetOrigin());
+ long dx=0,dy=0;
+ long l=-aOrg.X();
+ long r=-aOrg.X()+aActualSize.Width()-1;
+ long o=-aOrg.Y();
+ long u=-aOrg.Y()+aActualSize.Height()-1;
+ if (l>rRect.Left()) dx=rRect.Left()-l;
+ else if (r<rRect.Right()) dx=rRect.Right()-r;
+ if (o>rRect.Top()) dy=rRect.Top()-o;
+ else if (u<rRect.Bottom()) dy=rRect.Bottom()-u;
+ aMap.SetOrigin(Point(aOrg.X()-dx,aOrg.Y()-dy));
+ if (!bNewScale) {
+ if (dx!=0 || dy!=0) {
+ rWin.Scroll(-dx,-dy);
+ rWin.SetMapMode(aMap);
+ rWin.Update();
+ }
+ } else {
+ rWin.SetMapMode(aMap);
+ InvalidateOneWin(rWin);
+ }
+ }
+}
+
+void SdrPaintView::DoConnect(SdrOle2Obj* /*pOleObj*/)
+{
+}
+
+void SdrPaintView::SetAnimationEnabled( BOOL bEnable )
+{
+ SetAnimationMode( bEnable ? SDR_ANIMATION_ANIMATE : SDR_ANIMATION_DISABLE );
+}
+
+void SdrPaintView::SetAnimationPause( bool bSet )
+{
+ if((bool)bAnimationPause != bSet)
+ {
+ bAnimationPause = bSet;
+
+ if(mpPageView)
+ {
+ for(sal_uInt32 b(0L); b < mpPageView->PageWindowCount(); b++)
+ {
+ const SdrPageWindow& rPageWindow = *(mpPageView->GetPageWindow(b));
+ sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact();
+ sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator();
+
+ if(rAnimator.IsPaused() != bSet)
+ {
+ rAnimator.SetPaused(bSet);
+ }
+ }
+ }
+ }
+}
+
+void SdrPaintView::SetAnimationMode( const SdrAnimationMode eMode )
+{
+ eAnimationMode = eMode;
+}
+
+void SdrPaintView::VisAreaChanged(const OutputDevice* pOut)
+{
+ if(mpPageView)
+ {
+ if (pOut)
+ {
+ SdrPageWindow* pWindow = mpPageView->FindPageWindow(*((OutputDevice*)pOut));
+
+ if(pWindow)
+ {
+ VisAreaChanged(*pWindow);
+ }
+ }
+ else
+ {
+ for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++)
+ {
+ VisAreaChanged(*mpPageView->GetPageWindow(a));
+ }
+ }
+ }
+}
+
+void SdrPaintView::VisAreaChanged(const SdrPageWindow& /*rWindow*/)
+{
+ // notify SfxListener
+ Broadcast(SvxViewHint(SvxViewHint::SVX_HINT_VIEWCHANGED));
+}
+
+const svtools::ColorConfig& SdrPaintView::getColorConfig() const
+{
+ return maColorConfig;
+}
+
+void SdrPaintView::onChangeColorConfig()
+{
+ SetGridColor( Color( maColorConfig.GetColorValue( svtools::DRAWGRID ).nColor ) );
+}
+
+void SdrPaintView::SetGridColor( Color aColor )
+{
+ maGridColor = aColor;
+}
+
+Color SdrPaintView::GetGridColor() const
+{
+ return maGridColor;
+}
+
+// #103834# Set background color for svx at SdrPageViews
+void SdrPaintView::SetApplicationBackgroundColor(Color aBackgroundColor)
+{
+ if(mpPageView)
+ {
+ mpPageView->SetApplicationBackgroundColor(aBackgroundColor);
+ }
+}
+
+// #103911# Set document color for svx at SdrPageViews
+void SdrPaintView::SetApplicationDocumentColor(Color aDocumentColor)
+{
+ if(mpPageView)
+ {
+ mpPageView->SetApplicationDocumentColor(aDocumentColor);
+ }
+}
+
+// #114898#
+bool SdrPaintView::IsBufferedOutputAllowed() const
+{
+ return (mbBufferedOutputAllowed && maDrawinglayerOpt.IsPaintBuffer());
+}
+
+// #114898#
+void SdrPaintView::SetBufferedOutputAllowed(bool bNew)
+{
+ if(bNew != (bool)mbBufferedOutputAllowed)
+ {
+ mbBufferedOutputAllowed = bNew;
+ }
+}
+
+bool SdrPaintView::IsBufferedOverlayAllowed() const
+{
+ return (mbBufferedOverlayAllowed && maDrawinglayerOpt.IsOverlayBuffer());
+}
+
+void SdrPaintView::SetBufferedOverlayAllowed(bool bNew)
+{
+ if(bNew != (bool)mbBufferedOverlayAllowed)
+ {
+ mbBufferedOverlayAllowed = bNew;
+ }
+}
+
+sal_Bool SdrPaintView::IsPagePaintingAllowed() const
+{
+ return mbPagePaintingAllowed;
+}
+
+void SdrPaintView::SetPagePaintingAllowed(bool bNew)
+{
+ if(bNew != (bool)mbPagePaintingAllowed)
+ {
+ mbPagePaintingAllowed = bNew;
+ }
+}
+
+// #i38135# Sets the timer for Object animations and restarts.
+void SdrPaintView::SetAnimationTimer(sal_uInt32 nTime)
+{
+ if(mpPageView)
+ {
+ // first, reset all timers at all windows to 0L
+ for(sal_uInt32 a(0L); a < mpPageView->PageWindowCount(); a++)
+ {
+ const SdrPageWindow& rPageWindow = *mpPageView->GetPageWindow(a);
+ sdr::contact::ObjectContact& rObjectContact = rPageWindow.GetObjectContact();
+ sdr::animation::primitiveAnimator& rAnimator = rObjectContact.getPrimitiveAnimator();
+ rAnimator.SetTime(nTime);
+ }
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdpoev.cxx b/svx/source/svdraw/svdpoev.cxx
new file mode 100644
index 000000000000..c0cfe91e52f0
--- /dev/null
+++ b/svx/source/svdraw/svdpoev.cxx
@@ -0,0 +1,748 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdpoev.hxx>
+#include <math.h>
+#include <svx/svdpagv.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdundo.hxx>
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+#include <svx/svdtrans.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <vcl/salbtype.hxx> // FRound
+
+#include <svx/polypolygoneditor.hxx>
+
+using namespace sdr;
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrPolyEditView::ImpResetPolyPossibilityFlags()
+{
+ eMarkedPointsSmooth=SDRPATHSMOOTH_DONTCARE;
+ eMarkedSegmentsKind=SDRPATHSEGMENT_DONTCARE;
+ bSetMarkedPointsSmoothPossible=FALSE;
+ bSetMarkedSegmentsKindPossible=FALSE;
+}
+
+void SdrPolyEditView::ImpClearVars()
+{
+ ImpResetPolyPossibilityFlags();
+}
+
+SdrPolyEditView::SdrPolyEditView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrEditView(pModel1,pOut)
+{
+ ImpClearVars();
+}
+
+SdrPolyEditView::~SdrPolyEditView()
+{
+}
+
+void SdrPolyEditView::ImpCheckPolyPossibilities()
+{
+ ImpResetPolyPossibilityFlags();
+ const ULONG nMarkAnz(GetMarkedObjectCount());
+
+ if(nMarkAnz && !ImpIsFrameHandles())
+ {
+ bool b1stSmooth(true);
+ bool b1stSegm(true);
+ bool bCurve(false);
+ bool bSmoothFuz(false);
+ bool bSegmFuz(false);
+ basegfx::B2VectorContinuity eSmooth = basegfx::CONTINUITY_NONE;
+
+ for(ULONG nMarkNum(0L); nMarkNum < nMarkAnz; nMarkNum++)
+ {
+ SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
+ CheckPolyPossibilitiesHelper( pM, b1stSmooth, b1stSegm, bCurve, bSmoothFuz, bSegmFuz, eSmooth );
+ }
+ }
+}
+
+void SdrPolyEditView::CheckPolyPossibilitiesHelper( SdrMark* pM, bool& b1stSmooth, bool& b1stSegm, bool& bCurve, bool& bSmoothFuz, bool& bSegmFuz, basegfx::B2VectorContinuity& eSmooth )
+{
+ SdrObject* pObj = pM->GetMarkedSdrObj();
+ SdrUShortCont* pPts = pM->GetMarkedPoints();
+ SdrPathObj* pPath = PTR_CAST(SdrPathObj,pObj);
+
+ if(pPath && pPts)
+ {
+ const sal_uInt32 nMarkedPntAnz(pPts->GetCount());
+
+ if(nMarkedPntAnz)
+ {
+ bool bClosed(pPath->IsClosed());
+ bSetMarkedPointsSmoothPossible = true;
+
+ if(bClosed)
+ {
+ bSetMarkedSegmentsKindPossible = true;
+ }
+
+ for(sal_uInt32 nMarkedPntNum(0L); nMarkedPntNum < nMarkedPntAnz; nMarkedPntNum++)
+ {
+ sal_uInt32 nNum(pPts->GetObject(nMarkedPntNum));
+ sal_uInt32 nPolyNum, nPntNum;
+
+ if(PolyPolygonEditor::GetRelativePolyPoint(pPath->GetPathPoly(), nNum, nPolyNum, nPntNum))
+ {
+ const basegfx::B2DPolygon aLocalPolygon(pPath->GetPathPoly().getB2DPolygon(nPolyNum));
+ bool bCanSegment(bClosed || nPntNum < aLocalPolygon.count() - 1L);
+
+ if(!bSetMarkedSegmentsKindPossible && bCanSegment)
+ {
+ bSetMarkedSegmentsKindPossible = true;
+ }
+
+ if(!bSmoothFuz)
+ {
+ if (b1stSmooth)
+ {
+ b1stSmooth = false;
+ eSmooth = basegfx::tools::getContinuityInPoint(aLocalPolygon, nPntNum);
+ }
+ else
+ {
+ bSmoothFuz = (eSmooth != basegfx::tools::getContinuityInPoint(aLocalPolygon, nPntNum));
+ }
+ }
+
+ if(!bSegmFuz)
+ {
+ if(bCanSegment)
+ {
+ bool bCrv(aLocalPolygon.isNextControlPointUsed(nPntNum));
+
+ if(b1stSegm)
+ {
+ b1stSegm = false;
+ bCurve = bCrv;
+ }
+ else
+ {
+ bSegmFuz = (bCrv != bCurve);
+ }
+ }
+ }
+ }
+ }
+
+ if(!b1stSmooth && !bSmoothFuz)
+ {
+ if(basegfx::CONTINUITY_NONE == eSmooth)
+ {
+ eMarkedPointsSmooth = SDRPATHSMOOTH_ANGULAR;
+ }
+
+ if(basegfx::CONTINUITY_C1 == eSmooth)
+ {
+ eMarkedPointsSmooth = SDRPATHSMOOTH_ASYMMETRIC;
+ }
+
+ if(basegfx::CONTINUITY_C2 == eSmooth)
+ {
+ eMarkedPointsSmooth = SDRPATHSMOOTH_SYMMETRIC;
+ }
+ }
+
+ if(!b1stSegm && !bSegmFuz)
+ {
+ eMarkedSegmentsKind = (bCurve) ? SDRPATHSEGMENT_CURVE : SDRPATHSEGMENT_LINE;
+ }
+ }
+ }
+}
+
+void SdrPolyEditView::SetMarkedPointsSmooth(SdrPathSmoothKind eKind)
+{
+ basegfx::B2VectorContinuity eFlags;
+
+ if(SDRPATHSMOOTH_ANGULAR == eKind)
+ {
+ eFlags = basegfx::CONTINUITY_NONE;
+ }
+ else if(SDRPATHSMOOTH_ASYMMETRIC == eKind)
+ {
+ eFlags = basegfx::CONTINUITY_C1;
+ }
+ else if(SDRPATHSMOOTH_SYMMETRIC == eKind)
+ {
+ eFlags = basegfx::CONTINUITY_C2;
+ }
+ else
+ {
+ return;
+ }
+
+ if(HasMarkedPoints())
+ {
+ SortMarkedObjects();
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_EditSetPointsSmooth), GetDescriptionOfMarkedPoints());
+ ULONG nMarkAnz(GetMarkedObjectCount());
+
+ for(ULONG nMarkNum(nMarkAnz); nMarkNum > 0L;)
+ {
+ nMarkNum--;
+ SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
+ SdrUShortCont* pPts = pM->GetMarkedPoints();
+ SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() );
+
+ if(pPts && pPath)
+ {
+ PolyPolygonEditor aEditor( pPath->GetPathPoly(), pPath->IsClosed() );
+ if(aEditor.SetPointsSmooth( eFlags, pPts->getContainer() ) )
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath));
+ pPath->SetPathPoly(aEditor.GetPolyPolygon());
+ }
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+ }
+}
+
+void SdrPolyEditView::SetMarkedSegmentsKind(SdrPathSegmentKind eKind)
+{
+ if(HasMarkedPoints())
+ {
+ SortMarkedObjects();
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_EditSetSegmentsKind), GetDescriptionOfMarkedPoints());
+ ULONG nMarkAnz(GetMarkedObjectCount());
+
+ for(ULONG nMarkNum(nMarkAnz); nMarkNum > 0L;)
+ {
+ nMarkNum--;
+ SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
+ SdrUShortCont* pPts = pM->GetMarkedPoints();
+ SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() );
+
+ if(pPts && pPath)
+ {
+ PolyPolygonEditor aEditor( pPath->GetPathPoly(), pPath->IsClosed() );
+ if(aEditor.SetSegmentsKind( eKind, pPts->getContainer()) )
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath));
+ pPath->SetPathPoly(aEditor.GetPolyPolygon());
+ }
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+ }
+}
+
+BOOL SdrPolyEditView::IsSetMarkedPointsSmoothPossible() const
+{
+ ForcePossibilities();
+ return bSetMarkedPointsSmoothPossible;
+}
+
+SdrPathSmoothKind SdrPolyEditView::GetMarkedPointsSmooth() const
+{
+ ForcePossibilities();
+ return eMarkedPointsSmooth;
+}
+
+BOOL SdrPolyEditView::IsSetMarkedSegmentsKindPossible() const
+{
+ ForcePossibilities();
+ return bSetMarkedSegmentsKindPossible;
+}
+
+SdrPathSegmentKind SdrPolyEditView::GetMarkedSegmentsKind() const
+{
+ ForcePossibilities();
+ return eMarkedSegmentsKind;
+}
+
+BOOL SdrPolyEditView::IsDeleteMarkedPointsPossible() const
+{
+ return HasMarkedPoints();
+}
+
+void SdrPolyEditView::DeleteMarkedPoints()
+{
+ if (HasMarkedPoints())
+ {
+ BrkAction();
+ SortMarkedObjects();
+ ULONG nMarkAnz=GetMarkedObjectCount();
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ {
+ // Description
+ BegUndo(ImpGetResStr(STR_EditDelete),GetDescriptionOfMarkedPoints(),SDRREPFUNC_OBJ_DELETE);
+ }
+
+ for (ULONG nMarkNum=nMarkAnz; nMarkNum>0;)
+ {
+ nMarkNum--;
+ SdrMark* pM=GetSdrMarkByIndex(nMarkNum);
+ SdrUShortCont* pPts=pM->GetMarkedPoints();
+ SdrPathObj* pPath = dynamic_cast< SdrPathObj* >( pM->GetMarkedSdrObj() );
+
+ if( pPath && pPts )
+ {
+ PolyPolygonEditor aEditor( pPath ->GetPathPoly(), pPath->IsClosed() );
+ if( aEditor.DeletePoints( pPts->getContainer() ) )
+ {
+ if( aEditor.GetPolyPolygon().count() )
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPath ));
+ pPath->SetPathPoly( aEditor.GetPolyPolygon() );
+ }
+ else
+ {
+ if( bUndo )
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoDeleteObject(*pPath ) );
+ pM->GetPageView()->GetObjList()->RemoveObject(pPath->GetOrdNum());
+ if( !bUndo )
+ {
+ SdrObject* pObj = pPath;
+ SdrObject::Free(pObj);
+ }
+ }
+ }
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+ UnmarkAllPoints();
+ MarkListHasChanged();
+ }
+}
+
+void SdrPolyEditView::RipUpAtMarkedPoints()
+{
+ if(HasMarkedPoints())
+ {
+ SortMarkedObjects();
+ sal_uInt32 nMarkAnz(GetMarkedObjectCount());
+
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_EditRipUp), GetDescriptionOfMarkedPoints());
+
+ for(sal_uInt32 nMarkNum(nMarkAnz); nMarkNum > 0L;)
+ {
+ nMarkNum--;
+ SdrMark* pM = GetSdrMarkByIndex(nMarkNum);
+ SdrUShortCont* pPts = pM->GetMarkedPoints();
+ SdrPathObj* pObj = PTR_CAST(SdrPathObj, pM->GetMarkedSdrObj());
+
+ if(pPts && pObj)
+ {
+ pPts->ForceSort();
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
+ sal_Bool bKorregFlag(sal_False);
+ sal_Bool bInsAny(sal_False);
+ sal_uInt32 nMarkPtsAnz(pPts->GetCount());
+ sal_uInt32 nMax(pObj->GetHdlCount());
+
+ for(sal_uInt32 i(nMarkPtsAnz); i > 0L;)
+ {
+ i--;
+ sal_uInt32 nNewPt0Idx(0L);
+ SdrObject* pNeuObj = pObj->RipPoint(pPts->GetObject(i), nNewPt0Idx);
+
+ if(pNeuObj)
+ {
+ bInsAny = sal_True;
+ SdrInsertReason aReason(SDRREASON_VIEWCALL, pObj);
+ pM->GetPageView()->GetObjList()->InsertObject(pNeuObj, pObj->GetOrdNum() + 1, &aReason);
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj));
+ MarkObj(pNeuObj, pM->GetPageView(), FALSE, TRUE);
+ }
+
+ if(nNewPt0Idx)
+ {
+ // Korrektur notwendig?
+ DBG_ASSERT(bKorregFlag==FALSE,"Mehrfache Indexkorrektur bei SdrPolyEditView::RipUp()");
+ if(!bKorregFlag)
+ {
+ bKorregFlag = sal_True;
+
+ for(sal_uInt32 nBla(0L); nBla < nMarkPtsAnz; nBla++)
+ {
+ sal_uInt32 nPntNum(pPts->GetObject(nBla));
+ nPntNum += nNewPt0Idx;
+
+ if(nPntNum >= nMax)
+ {
+ nPntNum -= nMax;
+ }
+
+ pPts->Replace((sal_uInt16)nPntNum, nBla);
+ }
+
+ i = nMarkPtsAnz; // ... und nochmal von vorn
+ }
+ }
+ }
+ }
+ }
+
+ UnmarkAllPoints();
+ if( bUndo )
+ EndUndo();
+ MarkListHasChanged();
+ }
+}
+
+bool SdrPolyEditView::IsRipUpAtMarkedPointsPossible() const
+{
+ bool bRetval(false);
+ const sal_uInt32 nMarkCount(GetMarkedObjectCount());
+
+ for(sal_uInt32 a(0); a < nMarkCount; a++)
+ {
+ const SdrMark* pMark = GetSdrMarkByIndex(a);
+ const SdrPathObj* pMarkedPathObject = dynamic_cast< const SdrPathObj* >(pMark->GetMarkedSdrObj());
+
+ if(pMarkedPathObject)
+ {
+ const SdrUShortCont* pSelectedPoints = pMark->GetMarkedPoints();
+
+ if(pSelectedPoints && pSelectedPoints->GetCount())
+ {
+ const basegfx::B2DPolyPolygon& rPathPolyPolygon = pMarkedPathObject->GetPathPoly();
+
+ if(1 == rPathPolyPolygon.count())
+ {
+ // #i76617# Do not yet use basegfx::B2DPolygon since curve definitions
+ // are different and methods need to be changed thoroughly with interaction rework
+ const Polygon aPathPolygon(rPathPolyPolygon.getB2DPolygon(0));
+ const sal_uInt16 nPointCount(aPathPolygon.GetSize());
+
+ if(nPointCount >= 3)
+ {
+ bRetval = pMarkedPathObject->IsClosedObj(); // #i76617# aPathPolygon.isClosed();
+
+ for(sal_uInt32 b(0); !bRetval && b < pSelectedPoints->GetCount(); b++)
+ {
+ const sal_uInt16 nMarkedPointNum(pSelectedPoints->GetObject(b));
+
+ bRetval = (nMarkedPointNum > 0 && nMarkedPointNum < nPointCount - 1);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return bRetval;
+}
+
+bool SdrPolyEditView::IsOpenCloseMarkedObjectsPossible() const
+{
+ bool bRetval(false);
+ const sal_uInt32 nMarkCount(GetMarkedObjectCount());
+
+ for(sal_uInt32 a(0); a < nMarkCount; a++)
+ {
+ const SdrMark* pMark = GetSdrMarkByIndex(a);
+ const SdrPathObj* pMarkedPathObject = dynamic_cast< const SdrPathObj* >(pMark->GetMarkedSdrObj());
+
+ if(pMarkedPathObject)
+ {
+ // #i76617# Do not yet use basegfx::B2DPolygon since curve definitions
+ // are different and methods need to be changed thoroughly with interaction rework
+ const PolyPolygon aPathPolyPolygon(pMarkedPathObject->GetPathPoly());
+ const sal_uInt16 nPolygonCount(aPathPolyPolygon.Count());
+
+ for(sal_uInt16 b(0); !bRetval && b < nPolygonCount; b++)
+ {
+ const Polygon& rPathPolygon = aPathPolyPolygon[b];
+ const sal_uInt16 nPointCount(rPathPolygon.GetSize());
+
+ bRetval = (nPointCount >= 3);
+ }
+ }
+ }
+
+ return bRetval;
+}
+
+SdrObjClosedKind SdrPolyEditView::GetMarkedObjectsClosedState() const
+{
+ bool bOpen(false);
+ bool bClosed(false);
+ const sal_uInt32 nMarkCount(GetMarkedObjectCount());
+
+ for(sal_uInt32 a(0); !(bOpen && bClosed) && a < nMarkCount; a++)
+ {
+ const SdrMark* pMark = GetSdrMarkByIndex(a);
+ const SdrPathObj* pMarkedPathObject = dynamic_cast< const SdrPathObj* >(pMark->GetMarkedSdrObj());
+
+ if(pMarkedPathObject)
+ {
+ if(pMarkedPathObject->IsClosedObj())
+ {
+ bClosed = true;
+ }
+ else
+ {
+ bOpen = true;
+ }
+ }
+ }
+
+ if(bOpen && bClosed)
+ {
+ return SDROBJCLOSED_DONTCARE;
+ }
+ else if(bOpen)
+ {
+ return SDROBJCLOSED_OPEN;
+ }
+ else
+ {
+ return SDROBJCLOSED_CLOSED;
+ }
+}
+
+void SdrPolyEditView::ShutMarkedObjects()
+{
+ CloseMarkedObjects();
+}
+
+void SdrPolyEditView::CloseMarkedObjects(BOOL bToggle, BOOL bOpen) // , long nOpenDistance)
+{
+ if (AreObjectsMarked())
+ {
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_EditShut),GetDescriptionOfMarkedPoints());
+
+ bool bChg=false;
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pO=pM->GetMarkedSdrObj();
+ BOOL bClosed=pO->IsClosedObj();
+ if (pO->IsPolyObj() && (bClosed==bOpen) || bToggle)
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pO));
+
+ SdrPathObj* pPathObj = dynamic_cast< SdrPathObj* >( pO );
+ if(pPathObj)
+ pPathObj->ToggleClosed();
+ bChg=true;
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+
+ if (bChg)
+ {
+ UnmarkAllPoints();
+ MarkListHasChanged();
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrPolyEditView::ImpCopyMarkedPoints()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrPolyEditView::ImpTransformMarkedPoints(PPolyTrFunc pTrFunc, const void* p1, const void* p2, const void* p3, const void* p4, const void* p5)
+{
+ const bool bUndo = IsUndoEnabled();
+
+ ULONG nMarkAnz=GetMarkedObjectCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++)
+ {
+ SdrMark* pM=GetSdrMarkByIndex(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ const SdrUShortCont* pPts=pM->GetMarkedPoints();
+ ULONG nPtAnz=pPts==NULL ? 0 : pPts->GetCount();
+ SdrPathObj* pPath=PTR_CAST(SdrPathObj,pObj);
+ if (nPtAnz!=0 && pPath!=NULL)
+ {
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj));
+
+ basegfx::B2DPolyPolygon aXPP(pPath->GetPathPoly());
+
+ for(sal_uInt32 nPtNum(0L); nPtNum < nPtAnz; nPtNum++)
+ {
+ sal_uInt32 nPt(pPts->GetObject(nPtNum));
+ sal_uInt32 nPolyNum, nPointNum;
+
+ if(PolyPolygonEditor::GetRelativePolyPoint(aXPP, nPt, nPolyNum, nPointNum))
+ {
+ //#i83671# used nLocalPointNum (which was the polygon point count)
+ // instead of the point index (nPointNum). This of course leaded
+ // to a wrong point access to the B2DPolygon.
+ basegfx::B2DPolygon aNewXP(aXPP.getB2DPolygon(nPolyNum));
+ Point aPos, aC1, aC2;
+ bool bC1(false);
+ bool bC2(false);
+
+ const basegfx::B2DPoint aB2DPos(aNewXP.getB2DPoint(nPointNum));
+ aPos = Point(FRound(aB2DPos.getX()), FRound(aB2DPos.getY()));
+
+ if(aNewXP.isPrevControlPointUsed(nPointNum))
+ {
+ const basegfx::B2DPoint aB2DC1(aNewXP.getPrevControlPoint(nPointNum));
+ aC1 = Point(FRound(aB2DC1.getX()), FRound(aB2DC1.getY()));
+ bC1 = true;
+ }
+
+ if(aNewXP.isNextControlPointUsed(nPointNum))
+ {
+ const basegfx::B2DPoint aB2DC2(aNewXP.getNextControlPoint(nPointNum));
+ aC2 = Point(FRound(aB2DC2.getX()), FRound(aB2DC2.getY()));
+ bC2 = true;
+ }
+
+ (*pTrFunc)(aPos,&aC1,&aC2,p1,p2,p3,p4,p5);
+ aNewXP.setB2DPoint(nPointNum, basegfx::B2DPoint(aPos.X(), aPos.Y()));
+
+ if (bC1)
+ {
+ aNewXP.setPrevControlPoint(nPointNum, basegfx::B2DPoint(aC1.X(), aC1.Y()));
+ }
+
+ if (bC2)
+ {
+ aNewXP.setNextControlPoint(nPointNum, basegfx::B2DPoint(aC2.X(), aC2.Y()));
+ }
+
+ aXPP.setB2DPolygon(nPolyNum, aNewXP);
+ }
+ }
+
+ pPath->SetPathPoly(aXPP);
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ImpMove(Point& rPt, Point* pC1, Point* pC2, const void* p1, const void* /*p2*/, const void* /*p3*/, const void* /*p4*/, const void* /*p5*/)
+{
+ MovePoint(rPt,*(const Size*)p1);
+ if (pC1!=NULL) MovePoint(*pC1,*(const Size*)p1);
+ if (pC2!=NULL) MovePoint(*pC2,*(const Size*)p1);
+}
+
+void SdrPolyEditView::MoveMarkedPoints(const Size& rSiz, bool bCopy)
+{
+ bCopy=FALSE; // noch nicht implementiert
+ ForceUndirtyMrkPnt();
+ XubString aStr(ImpGetResStr(STR_EditMove));
+ if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr,GetDescriptionOfMarkedPoints(),SDRREPFUNC_OBJ_MOVE);
+ if (bCopy) ImpCopyMarkedPoints();
+ ImpTransformMarkedPoints(ImpMove,&rSiz);
+ EndUndo();
+ AdjustMarkHdl();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ImpResize(Point& rPt, Point* pC1, Point* pC2, const void* p1, const void* p2, const void* p3, const void* /*p4*/, const void* /*p5*/)
+{
+ ResizePoint(rPt,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3);
+ if (pC1!=NULL) ResizePoint(*pC1,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3);
+ if (pC2!=NULL) ResizePoint(*pC2,*(const Point*)p1,*(const Fraction*)p2,*(const Fraction*)p3);
+}
+
+void SdrPolyEditView::ResizeMarkedPoints(const Point& rRef, const Fraction& xFact, const Fraction& yFact, bool bCopy)
+{
+ bCopy=FALSE; // noch nicht implementiert
+ ForceUndirtyMrkPnt();
+ XubString aStr(ImpGetResStr(STR_EditResize));
+ if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr,GetDescriptionOfMarkedPoints(),SDRREPFUNC_OBJ_RESIZE);
+ if (bCopy) ImpCopyMarkedPoints();
+ ImpTransformMarkedPoints(ImpResize,&rRef,&xFact,&yFact);
+ EndUndo();
+ AdjustMarkHdl();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+static void ImpRotate(Point& rPt, Point* pC1, Point* pC2, const void* p1, const void* /*p2*/, const void* p3, const void* p4, const void* /*p5*/)
+{
+ RotatePoint(rPt,*(const Point*)p1,*(const double*)p3,*(const double*)p4);
+ if (pC1!=NULL) RotatePoint(*pC1,*(const Point*)p1,*(const double*)p3,*(const double*)p4);
+ if (pC2!=NULL) RotatePoint(*pC2,*(const Point*)p1,*(const double*)p3,*(const double*)p4);
+}
+
+void SdrPolyEditView::RotateMarkedPoints(const Point& rRef, long nWink, bool bCopy)
+{
+ bCopy=FALSE; // noch nicht implementiert
+ ForceUndirtyMrkPnt();
+ XubString aStr(ImpGetResStr(STR_EditResize));
+ if (bCopy) aStr+=ImpGetResStr(STR_EditWithCopy);
+ BegUndo(aStr,GetDescriptionOfMarkedPoints(),SDRREPFUNC_OBJ_ROTATE);
+ if (bCopy) ImpCopyMarkedPoints();
+ double nSin=sin(nWink*nPi180);
+ double nCos=cos(nWink*nPi180);
+ ImpTransformMarkedPoints(ImpRotate,&rRef,&nWink,&nSin,&nCos);
+ EndUndo();
+ AdjustMarkHdl();
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx
new file mode 100644
index 000000000000..c4d699d2c556
--- /dev/null
+++ b/svx/source/svdraw/svdsnpv.cxx
@@ -0,0 +1,733 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdsnpv.hxx>
+#include <math.h>
+
+#include <svx/svdetc.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdpage.hxx>
+#include "svditer.hxx"
+#include <svx/sdr/overlay/overlayobjectlist.hxx>
+#include <svx/sdr/overlay/overlaycrosshair.hxx>
+#include <svx/sdr/overlay/overlayhelpline.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <sdrpaintwindow.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #114409#-1 Migrate PageOrigin
+class ImplPageOriginOverlay
+{
+ // The OverlayObjects
+ ::sdr::overlay::OverlayObjectList maObjects;
+
+ // The current position in logical coodinates
+ basegfx::B2DPoint maPosition;
+
+public:
+ ImplPageOriginOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos);
+ ~ImplPageOriginOverlay();
+
+ void SetPosition(const basegfx::B2DPoint& rNewPosition);
+};
+
+ImplPageOriginOverlay::ImplPageOriginOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos)
+: maPosition(rStartPos)
+{
+ for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
+ ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
+
+ if(pTargetOverlay)
+ {
+ ::sdr::overlay::OverlayCrosshairStriped* aNew = new ::sdr::overlay::OverlayCrosshairStriped(
+ maPosition);
+ pTargetOverlay->add(*aNew);
+ maObjects.append(*aNew);
+ }
+ }
+}
+
+ImplPageOriginOverlay::~ImplPageOriginOverlay()
+{
+ // The OverlayObjects are cleared using the destructor of OverlayObjectList.
+ // That destructor calls clear() at the list which removes all objects from the
+ // OverlayManager and deletes them.
+}
+
+void ImplPageOriginOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition)
+{
+ if(rNewPosition != maPosition)
+ {
+ // apply to OverlayObjects
+ for(sal_uInt32 a(0); a < maObjects.count(); a++)
+ {
+ sdr::overlay::OverlayCrosshairStriped* pCandidate =
+ static_cast< sdr::overlay::OverlayCrosshairStriped* >(&maObjects.getOverlayObject(a));
+
+ if(pCandidate)
+ {
+ pCandidate->setBasePosition(rNewPosition);
+ }
+ }
+
+ // remember new position
+ maPosition = rNewPosition;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #114409#-2 Migrate HelpLine
+class ImplHelpLineOverlay
+{
+ // The OverlayObjects
+ ::sdr::overlay::OverlayObjectList maObjects;
+
+ // The current position in logical coodinates
+ basegfx::B2DPoint maPosition;
+
+ // HelpLine specific stuff
+ SdrPageView* mpPageView;
+ sal_uInt16 mnHelpLineNumber;
+ SdrHelpLineKind meHelpLineKind;
+
+public:
+ ImplHelpLineOverlay(const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos,
+ SdrPageView* pPageView, sal_uInt16 nHelpLineNumber, SdrHelpLineKind eKind);
+ ~ImplHelpLineOverlay();
+
+ void SetPosition(const basegfx::B2DPoint& rNewPosition);
+
+ // access to HelpLine specific stuff
+ SdrPageView* GetPageView() const { return mpPageView; }
+ sal_uInt16 GetHelpLineNumber() const { return mnHelpLineNumber; }
+ SdrHelpLineKind GetHelpLineKind() const { return meHelpLineKind; }
+};
+
+ImplHelpLineOverlay::ImplHelpLineOverlay(
+ const SdrPaintView& rView, const basegfx::B2DPoint& rStartPos,
+ SdrPageView* pPageView, sal_uInt16 nHelpLineNumber, SdrHelpLineKind eKind)
+: maPosition(rStartPos),
+ mpPageView(pPageView),
+ mnHelpLineNumber(nHelpLineNumber),
+ meHelpLineKind(eKind)
+{
+ for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
+ ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
+
+ if(pTargetOverlay)
+ {
+ ::sdr::overlay::OverlayHelplineStriped* aNew = new ::sdr::overlay::OverlayHelplineStriped(
+ maPosition, meHelpLineKind);
+ pTargetOverlay->add(*aNew);
+ maObjects.append(*aNew);
+ }
+ }
+}
+
+ImplHelpLineOverlay::~ImplHelpLineOverlay()
+{
+ // The OverlayObjects are cleared using the destructor of OverlayObjectList.
+ // That destructor calls clear() at the list which removes all objects from the
+ // OverlayManager and deletes them.
+}
+
+void ImplHelpLineOverlay::SetPosition(const basegfx::B2DPoint& rNewPosition)
+{
+ if(rNewPosition != maPosition)
+ {
+ // apply to OverlayObjects
+ // apply to OverlayObjects
+ for(sal_uInt32 a(0); a < maObjects.count(); a++)
+ {
+ sdr::overlay::OverlayHelplineStriped* pCandidate =
+ static_cast< sdr::overlay::OverlayHelplineStriped* >(&maObjects.getOverlayObject(a));
+
+ if(pCandidate)
+ {
+ pCandidate->setBasePosition(rNewPosition);
+ }
+ }
+
+ // remember new position
+ maPosition = rNewPosition;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@ @@ @@ @@@@ @@@@@ @@ @@ @@ @@@@@ @@ @@
+// @@ @@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @ @@
+// @@@@ @@@@@@ @@@@@@ @@@@@ @@@@@ @@ @@@@ @@@@@@@
+// @@ @@ @@@ @@ @@ @@ @@@ @@ @@ @@@@@@@
+// @@ @@ @@ @@ @@ @@ @@ @@@ @@ @@ @@@ @@@
+// @@@@ @@ @@ @@ @@ @@ @ @@ @@@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrSnapView::ClearVars()
+{
+ nMagnSizPix=4;
+ bSnapEnab=TRUE;
+ bGridSnap=TRUE;
+ bSnapTo1Pix=TRUE;
+ bBordSnap=TRUE;
+ bHlplSnap=TRUE;
+ bOFrmSnap=TRUE;
+ bOPntSnap=FALSE;
+ bOConSnap=TRUE;
+ bMoveMFrmSnap=TRUE;
+ bMoveOFrmSnap=TRUE;
+ bMoveOPntSnap=TRUE;
+ bMoveOConSnap=TRUE;
+ bMoveSnapOnlyTopLeft=FALSE;
+ bOrtho=FALSE;
+ bBigOrtho=TRUE;
+ nSnapAngle=1500;
+ bAngleSnapEnab=FALSE;
+ bMoveOnlyDragging=FALSE;
+ bSlantButShear=FALSE;
+ bCrookNoContortion=FALSE;
+ eCrookMode=SDRCROOK_ROTATE;
+ bHlplFixed=FALSE;
+ bEliminatePolyPoints=FALSE;
+ nEliminatePolyPointLimitAngle=0;
+
+ // #114409#-1 Migrate PageOrigin
+ BrkSetPageOrg();
+
+ // #114409#-2 Migrate HelpLine
+ BrkDragHelpLine();
+}
+
+SdrSnapView::SdrSnapView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrPaintView(pModel1,pOut),
+ // #114409#-1 Migrate PageOrigin
+ mpPageOriginOverlay(0L),
+ // #114409#-2 Migrate HelpLine
+ mpHelpLineOverlay(0L)
+{
+ ClearVars();
+}
+
+// #114409#-1 Migrate PageOrigin
+SdrSnapView::~SdrSnapView()
+{
+ // #114409#-1 Migrate PageOrigin
+ BrkSetPageOrg();
+
+ // #114409#-2 Migrate HelpLine
+ BrkDragHelpLine();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrSnapView::IsAction() const
+{
+ return IsSetPageOrg() || IsDragHelpLine() || SdrPaintView::IsAction();
+}
+
+void SdrSnapView::MovAction(const Point& rPnt)
+{
+ SdrPaintView::MovAction(rPnt);
+ if (IsSetPageOrg()) {
+ MovSetPageOrg(rPnt);
+ }
+ if (IsDragHelpLine()) {
+ MovDragHelpLine(rPnt);
+ }
+}
+
+void SdrSnapView::EndAction()
+{
+ if (IsSetPageOrg()) {
+ EndSetPageOrg();
+ }
+ if (IsDragHelpLine()) {
+ EndDragHelpLine();
+ }
+ SdrPaintView::EndAction();
+}
+
+void SdrSnapView::BckAction()
+{
+ BrkSetPageOrg();
+ BrkDragHelpLine();
+ SdrPaintView::BckAction();
+}
+
+void SdrSnapView::BrkAction()
+{
+ BrkSetPageOrg();
+ BrkDragHelpLine();
+ SdrPaintView::BrkAction();
+}
+
+void SdrSnapView::TakeActionRect(Rectangle& rRect) const
+{
+ if (IsSetPageOrg() || IsDragHelpLine()) {
+ rRect=Rectangle(aDragStat.GetNow(),aDragStat.GetNow());
+ } else {
+ SdrPaintView::TakeActionRect(rRect);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Point SdrSnapView::GetSnapPos(const Point& rPnt, const SdrPageView* pPV) const
+{
+ Point aPt(rPnt);
+ SnapPos(aPt,pPV);
+ return aPt;
+}
+
+#define NOT_SNAPPED 0x7FFFFFFF
+USHORT SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const
+{
+ if (!bSnapEnab) return SDRSNAP_NOTSNAPPED;
+ BOOL bPVOfs=FALSE;
+ long x=rPnt.X();
+ long y=rPnt.Y();
+ if (pPV==NULL) {
+ bPVOfs=TRUE;
+ pPV=GetSdrPageView();
+ if (pPV==NULL) return SDRSNAP_NOTSNAPPED;
+ }
+
+ long dx=NOT_SNAPPED;
+ long dy=NOT_SNAPPED;
+ long dx1,dy1;
+ long mx=aMagnSiz.Width();
+ long my=aMagnSiz.Height();
+ if (bHlplVisible && bHlplSnap && !IsDragHelpLine())
+ {
+ const SdrHelpLineList& rHLL=pPV->GetHelpLines();
+ USHORT nAnz=rHLL.GetCount();
+ for (USHORT i=nAnz; i>0;) {
+ i--;
+ const SdrHelpLine& rHL=rHLL[i];
+ const Point& rPos=rHL.GetPos();
+ switch (rHL.GetKind()) {
+ case SDRHELPLINE_VERTICAL: {
+ long a=x-rPos.X();
+ if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; }
+ } break;
+ case SDRHELPLINE_HORIZONTAL: {
+ long b=y-rPos.Y();
+ if (Abs(b)<=my) { dy1=-b; if (Abs(dy1)<Abs(dy)) dy=dy1; }
+ } break;
+ case SDRHELPLINE_POINT: {
+ long a=x-rPos.X();
+ long b=y-rPos.Y();
+ if (Abs(a)<=mx && Abs(b)<=my) {
+ dx1=-a; dy1=-b;
+ if (Abs(dx1)<Abs(dx) && Abs(dy1)<Abs(dy)) { dx=dx1; dy=dy1; }
+ }
+ } break;
+ } // switch
+ }
+ }
+ if (bBordVisible && bBordSnap) {
+ SdrPage* pPage=pPV->GetPage();
+ long xs=pPage->GetWdt();
+ long ys=pPage->GetHgt();
+ long lft=pPage->GetLftBorder();
+ long rgt=pPage->GetRgtBorder();
+ long upp=pPage->GetUppBorder();
+ long lwr=pPage->GetLwrBorder();
+ long a;
+ a=x- lft ; if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // linker Rand
+ a=x-(xs-rgt); if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // rechter Rand
+ a=x ; if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // linke Papierkante
+ a=x- xs ; if (Abs(a)<=mx) { dx1=-a; if (Abs(dx1)<Abs(dx)) dx=dx1; } // rechte Papierkante
+ a=y- upp ; if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // linker Rand
+ a=y-(ys-lwr); if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // rechter Rand
+ a=y ; if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // linke Papierkante
+ a=y- ys ; if (Abs(a)<=my) { dy1=-a; if (Abs(dy1)<Abs(dy)) dy=dy1; } // rechte Papierkante
+ }
+ if (bOFrmSnap || bOPntSnap /*|| (bConnVisible && bOConSnap)*/) {
+ ULONG nMaxPointSnapCount=200;
+ ULONG nMaxFrameSnapCount=200;
+
+ // #97981# go back to IM_DEEPNOGROUPS runthrough for snap to object comparisons
+ SdrObjListIter aIter(*pPV->GetPage(),/*IM_FLAT*/IM_DEEPNOGROUPS,TRUE);
+
+ while (aIter.IsMore() && (nMaxPointSnapCount>0 || nMaxFrameSnapCount>0)) {
+ SdrObject* pO=aIter.Next();
+ Rectangle aRect(pO->GetCurrentBoundRect());
+ aRect.Left ()-=mx;
+ aRect.Right ()+=mx;
+ aRect.Top ()-=my;
+ aRect.Bottom()+=my;
+ if (aRect.IsInside(rPnt)) {
+ if (bOPntSnap && nMaxPointSnapCount>0)
+ {
+ sal_uInt32 nAnz(pO->GetSnapPointCount());
+ for (sal_uInt32 i(0L); i < nAnz && nMaxPointSnapCount > 0L; i++)
+ {
+ Point aP(pO->GetSnapPoint(i));
+ dx1=x-aP.X();
+ dy1=y-aP.Y();
+ if (Abs(dx1)<=mx && Abs(dy1)<=my && Abs(dx1)<Abs(dx) && Abs(dy1)<Abs(dy)) {
+ dx=-dx1;
+ dy=-dy1;
+ }
+ nMaxPointSnapCount--;
+ }
+ }
+ if (bOFrmSnap && nMaxFrameSnapCount>0) {
+ Rectangle aLog(pO->GetSnapRect());
+ Rectangle aR1(aLog);
+ aR1.Left ()-=mx;
+ aR1.Right ()+=mx;
+ aR1.Top ()-=my;
+ aR1.Bottom()+=my;
+ if (aR1.IsInside(rPnt)) {
+ if (Abs(x-aLog.Left ())<=mx) { dx1=-(x-aLog.Left ()); if (Abs(dx1)<Abs(dx)) dx=dx1; }
+ if (Abs(x-aLog.Right ())<=mx) { dx1=-(x-aLog.Right ()); if (Abs(dx1)<Abs(dx)) dx=dx1; }
+ if (Abs(y-aLog.Top ())<=my) { dy1=-(y-aLog.Top ()); if (Abs(dy1)<Abs(dy)) dy=dy1; }
+ if (Abs(y-aLog.Bottom())<=my) { dy1=-(y-aLog.Bottom()); if (Abs(dy1)<Abs(dy)) dy=dy1; }
+ }
+ nMaxFrameSnapCount--;
+ }
+ }
+ }
+ }
+ if(bGridSnap)
+ {
+ double fSnapWidth = aSnapWdtX;
+ if(dx == NOT_SNAPPED && fSnapWidth != 0.0)
+ {
+ double fx = (double)x;
+
+ // round statt trunc
+ if(fx - (double)pPV->GetPageOrigin().X() >= 0.0)
+ fx += fSnapWidth / 2.0;
+ else
+ fx -= fSnapWidth / 2.0;
+
+ x = (long)((fx - (double)pPV->GetPageOrigin().X()) / fSnapWidth);
+ x = (long)((double)x * fSnapWidth + (double)pPV->GetPageOrigin().X());
+ dx = 0;
+ }
+ fSnapWidth = aSnapWdtY;
+ if(dy == NOT_SNAPPED && fSnapWidth)
+ {
+ double fy = (double)y;
+
+ // round statt trunc
+ if(fy - (double)pPV->GetPageOrigin().Y() >= 0.0)
+ fy += fSnapWidth / 2.0;
+ else
+ fy -= fSnapWidth / 2.0;
+
+ y = (long)((fy - (double)pPV->GetPageOrigin().Y()) / fSnapWidth);
+ y = (long)((double)y * fSnapWidth + (double)pPV->GetPageOrigin().Y());
+ dy = 0;
+ }
+ }
+ BOOL bRet=SDRSNAP_NOTSNAPPED;
+ if (dx==NOT_SNAPPED) dx=0; else bRet|=SDRSNAP_XSNAPPED;
+ if (dy==NOT_SNAPPED) dy=0; else bRet|=SDRSNAP_YSNAPPED;
+ rPnt.X()=x+dx;
+ rPnt.Y()=y+dy;
+ return bRet;
+}
+
+void SdrSnapView::CheckSnap(const Point& rPt, const SdrPageView* pPV, long& nBestXSnap, long& nBestYSnap, bool& bXSnapped, bool& bYSnapped) const
+{
+ Point aPt(rPt);
+ USHORT nRet=SnapPos(aPt,pPV);
+ aPt-=rPt;
+ if ((nRet & SDRSNAP_XSNAPPED) !=0) {
+ if (bXSnapped) {
+ if (Abs(aPt.X())<Abs(nBestXSnap)) {
+ nBestXSnap=aPt.X();
+ }
+ } else {
+ nBestXSnap=aPt.X();
+ bXSnapped=TRUE;
+ }
+ }
+ if ((nRet & SDRSNAP_YSNAPPED) !=0) {
+ if (bYSnapped) {
+ if (Abs(aPt.Y())<Abs(nBestYSnap)) {
+ nBestYSnap=aPt.Y();
+ }
+ } else {
+ nBestYSnap=aPt.Y();
+ bYSnapped=TRUE;
+ }
+ }
+}
+
+USHORT SdrSnapView::SnapRect(const Rectangle& rRect, const SdrPageView* pPV, long& rDX, long& rDY) const
+{
+ long nBestXSnap=0;
+ long nBestYSnap=0;
+ bool bXSnapped=FALSE;
+ bool bYSnapped=FALSE;
+ CheckSnap(rRect.TopLeft() ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
+ if (!bMoveSnapOnlyTopLeft) {
+ CheckSnap(rRect.TopRight() ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
+ CheckSnap(rRect.BottomLeft() ,pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
+ CheckSnap(rRect.BottomRight(),pPV,nBestXSnap,nBestYSnap,bXSnapped,bYSnapped);
+ }
+ rDX=nBestXSnap;
+ rDY=nBestYSnap;
+ USHORT nRet=0;
+ if (bXSnapped) nRet+=SDRSNAP_XSNAPPED;
+ if (bYSnapped) nRet+=SDRSNAP_YSNAPPED;
+ return nRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_Bool SdrSnapView::BegSetPageOrg(const Point& rPnt)
+{
+ BrkAction();
+
+ DBG_ASSERT(0L == mpPageOriginOverlay, "SdrSnapView::BegSetPageOrg: There exists a ImplPageOriginOverlay (!)");
+ basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
+ mpPageOriginOverlay = new ImplPageOriginOverlay(*this, aStartPos);
+ aDragStat.Reset(GetSnapPos(rPnt,NULL));
+
+ return sal_True;
+}
+
+void SdrSnapView::MovSetPageOrg(const Point& rPnt)
+{
+ if(IsSetPageOrg())
+ {
+ aDragStat.NextMove(GetSnapPos(rPnt,NULL));
+ DBG_ASSERT(mpPageOriginOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
+ basegfx::B2DPoint aNewPos(aDragStat.GetNow().X(), aDragStat.GetNow().Y());
+ mpPageOriginOverlay->SetPosition(aNewPos);
+ }
+}
+
+sal_Bool SdrSnapView::EndSetPageOrg()
+{
+ sal_Bool bRet(sal_False);
+
+ if(IsSetPageOrg())
+ {
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ Point aPnt(aDragStat.GetNow());
+ pPV->SetPageOrigin(aPnt);
+ bRet = sal_True;
+ }
+
+ // cleanup
+ BrkSetPageOrg();
+ }
+
+ return bRet;
+}
+
+void SdrSnapView::BrkSetPageOrg()
+{
+ if(IsSetPageOrg())
+ {
+ DBG_ASSERT(mpPageOriginOverlay, "SdrSnapView::MovSetPageOrg: no ImplPageOriginOverlay (!)");
+ delete mpPageOriginOverlay;
+ mpPageOriginOverlay = 0L;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_Bool SdrSnapView::PickHelpLine(const Point& rPnt, short nTol, const OutputDevice& rOut, USHORT& rnHelpLineNum, SdrPageView*& rpPV) const
+{
+ rpPV=NULL;
+ nTol=ImpGetHitTolLogic(nTol,&rOut);
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ Point aPnt(rPnt);
+ USHORT nIndex=pPV->GetHelpLines().HitTest(aPnt,USHORT(nTol),rOut);
+ if (nIndex!=SDRHELPLINE_NOTFOUND) {
+ rpPV=pPV;
+ rnHelpLineNum=nIndex;
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+// start HelpLine drag for new HelpLine
+sal_Bool SdrSnapView::BegDragHelpLine(USHORT nHelpLineNum, SdrPageView* pPV)
+{
+ sal_Bool bRet(sal_False);
+
+ if(!bHlplFixed)
+ {
+ BrkAction();
+
+ if(pPV && nHelpLineNum < pPV->GetHelpLines().GetCount())
+ {
+ const SdrHelpLineList& rHelpLines = pPV->GetHelpLines();
+ const SdrHelpLine& rHelpLine = rHelpLines[nHelpLineNum];
+ Point aHelpLinePos = rHelpLine.GetPos(); // + pPV->GetOffset();
+ basegfx::B2DPoint aStartPos(aHelpLinePos.X(), aHelpLinePos.Y());
+
+ DBG_ASSERT(0L == mpHelpLineOverlay, "SdrSnapView::BegDragHelpLine: There exists a ImplHelpLineOverlay (!)");
+ mpHelpLineOverlay = new ImplHelpLineOverlay(*this, aStartPos, pPV, nHelpLineNum, rHelpLine.GetKind());
+
+ aDragStat.Reset(GetSnapPos(aHelpLinePos, pPV));
+ aDragStat.SetMinMove(ImpGetMinMovLogic(-3, 0L));
+
+ bRet = sal_True;
+ }
+ }
+
+ return bRet;
+}
+
+// start HelpLine drag with existing HelpLine
+sal_Bool SdrSnapView::BegDragHelpLine(const Point& rPnt, SdrHelpLineKind eNewKind)
+{
+ sal_Bool bRet(sal_False);
+
+ BrkAction();
+
+ if(GetSdrPageView())
+ {
+ DBG_ASSERT(0L == mpHelpLineOverlay, "SdrSnapView::BegDragHelpLine: There exists a ImplHelpLineOverlay (!)");
+ basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
+ mpHelpLineOverlay = new ImplHelpLineOverlay(*this, aStartPos, 0L, 0, eNewKind);
+ aDragStat.Reset(GetSnapPos(rPnt, 0L));
+ bRet = sal_True;
+ }
+
+ return bRet;
+}
+
+Pointer SdrSnapView::GetDraggedHelpLinePointer() const
+{
+ if(IsDragHelpLine())
+ {
+ switch(mpHelpLineOverlay->GetHelpLineKind())
+ {
+ case SDRHELPLINE_VERTICAL : return Pointer(POINTER_ESIZE);
+ case SDRHELPLINE_HORIZONTAL: return Pointer(POINTER_SSIZE);
+ default : return Pointer(POINTER_MOVE);
+ }
+ }
+
+ return Pointer(POINTER_MOVE);
+}
+
+void SdrSnapView::MovDragHelpLine(const Point& rPnt)
+{
+ if(IsDragHelpLine() && aDragStat.CheckMinMoved(rPnt))
+ {
+ Point aPnt(GetSnapPos(rPnt, 0L));
+
+ if(aPnt != aDragStat.GetNow())
+ {
+ aDragStat.NextMove(aPnt);
+ DBG_ASSERT(mpHelpLineOverlay, "SdrSnapView::MovDragHelpLine: no ImplHelpLineOverlay (!)");
+ basegfx::B2DPoint aNewPos(aDragStat.GetNow().X(), aDragStat.GetNow().Y());
+ mpHelpLineOverlay->SetPosition(aNewPos);
+ }
+ }
+}
+
+sal_Bool SdrSnapView::EndDragHelpLine()
+{
+ sal_Bool bRet(sal_False);
+
+ if(IsDragHelpLine())
+ {
+ if(aDragStat.IsMinMoved())
+ {
+ SdrPageView* pPageView = mpHelpLineOverlay->GetPageView();
+
+ if(pPageView)
+ {
+ // moved existing one
+ Point aPnt(aDragStat.GetNow());
+ const SdrHelpLineList& rHelpLines = pPageView->GetHelpLines();
+ SdrHelpLine aChangedHelpLine = rHelpLines[mpHelpLineOverlay->GetHelpLineNumber()];
+ aChangedHelpLine.SetPos(aPnt);
+ pPageView->SetHelpLine(mpHelpLineOverlay->GetHelpLineNumber(), aChangedHelpLine);
+
+ bRet = sal_True;
+ }
+ else
+ {
+ // create new one
+ pPageView = GetSdrPageView();
+
+ if(pPageView)
+ {
+ Point aPnt(aDragStat.GetNow());
+ SdrHelpLine aNewHelpLine(mpHelpLineOverlay->GetHelpLineKind(), aPnt);
+ pPageView->InsertHelpLine(aNewHelpLine);
+
+ bRet = sal_True;
+ }
+ }
+ }
+
+ // cleanup
+ BrkDragHelpLine();
+ }
+
+ return bRet;
+}
+
+void SdrSnapView::BrkDragHelpLine()
+{
+ if(IsDragHelpLine())
+ {
+ DBG_ASSERT(mpHelpLineOverlay, "SdrSnapView::EndDragHelpLine: no ImplHelpLineOverlay (!)");
+ delete mpHelpLineOverlay;
+ mpHelpLineOverlay = 0L;
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdstr.src b/svx/source/svdraw/svdstr.src
new file mode 100644
index 000000000000..625098330570
--- /dev/null
+++ b/svx/source/svdraw/svdstr.src
@@ -0,0 +1,2935 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+/* StarView resource file */
+
+#include "svdstr.hrc"
+ // Ab hier gecachte Strings
+String STR_ObjNameSingulNONE
+{
+ Text [ en-US ] = "draw object" ;
+};
+String STR_ObjNamePluralNONE
+{
+ Text [ en-US ] = "draw objects" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulGRUP
+{
+ Text [ en-US ] = "group object" ;
+};
+String STR_ObjNamePluralGRUP
+{
+ Text [ en-US ] = "group objects" ;
+};
+String STR_ObjNameSingulGRUPEMPTY
+{
+ Text [ en-US ] = "blank group object" ;
+};
+String STR_ObjNamePluralGRUPEMPTY
+{
+ Text [ en-US ] = "Blank group objects" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulLINE
+{
+ Text [ en-US ] = "Line" ;
+};
+String STR_ObjNameSingulLINE_Hori
+{
+ Text [ en-US ] = "horizontal line" ;
+};
+String STR_ObjNameSingulLINE_Vert
+{
+ Text [ en-US ] = "Vertical line" ;
+};
+String STR_ObjNameSingulLINE_Diag
+{
+ Text [ en-US ] = "diagonal line" ;
+};
+String STR_ObjNamePluralLINE
+{
+ Text [ en-US ] = "Lines" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulRECT
+{
+ Text [ en-US ] = "Rectangle" ;
+};
+String STR_ObjNamePluralRECT
+{
+ Text [ en-US ] = "Rectangles" ;
+};
+String STR_ObjNameSingulQUAD
+{
+ Text [ en-US ] = "Square" ;
+};
+String STR_ObjNamePluralQUAD
+{
+ Text [ en-US ] = "Squares" ;
+};
+String STR_ObjNameSingulPARAL
+{
+ Text [ en-US ] = "Parallelogram" ;
+};
+String STR_ObjNamePluralPARAL
+{
+ Text [ en-US ] = "Parallelograms" ;
+};
+String STR_ObjNameSingulRAUTE
+{
+ Text [ en-US ] = "Rhombus" ;
+};
+String STR_ObjNamePluralRAUTE
+{
+ Text [ en-US ] = "Rhombuses" ;
+};
+String STR_ObjNameSingulRECTRND
+{
+ Text [ en-US ] = "Rounded rectangle" ;
+};
+String STR_ObjNamePluralRECTRND
+{
+ Text [ en-US ] = "Rounded Rectangles" ;
+};
+String STR_ObjNameSingulQUADRND
+{
+ Text [ en-US ] = "rounded square" ;
+};
+String STR_ObjNamePluralQUADRND
+{
+ Text [ en-US ] = "Rounded Squares" ;
+};
+String STR_ObjNameSingulPARALRND
+{
+ Text [ en-US ] = "Rounded Parallelogram" ;
+};
+String STR_ObjNamePluralPARALRND
+{
+ Text [ en-US ] = "Rounded parallelograms" ;
+};
+String STR_ObjNameSingulRAUTERND
+{
+ Text [ en-US ] = "rounded rhombus" ;
+};
+String STR_ObjNamePluralRAUTERND
+{
+ Text [ en-US ] = "Rounded rhombuses" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulCIRC
+{
+ Text [ en-US ] = "Circle" ;
+};
+String STR_ObjNamePluralCIRC
+{
+ Text [ en-US ] = "Circles" ;
+};
+String STR_ObjNameSingulSECT
+{
+ Text [ en-US ] = "Circle sector" ;
+};
+String STR_ObjNamePluralSECT
+{
+ Text [ en-US ] = "Circle sectors" ;
+};
+String STR_ObjNameSingulCARC
+{
+ Text [ en-US ] = "Arc" ;
+};
+String STR_ObjNamePluralCARC
+{
+ Text [ en-US ] = "Arcs" ;
+};
+String STR_ObjNameSingulCCUT
+{
+ Text [ en-US ] = "Circle segment" ;
+};
+String STR_ObjNamePluralCCUT
+{
+ Text [ en-US ] = "Circle segments" ;
+};
+String STR_ObjNameSingulCIRCE
+{
+ Text [ en-US ] = "Ellipse" ;
+};
+String STR_ObjNamePluralCIRCE
+{
+ Text [ en-US ] = "Ellipses" ;
+};
+String STR_ObjNameSingulSECTE
+{
+ Text [ en-US ] = "Ellipse Pie" ;
+};
+String STR_ObjNamePluralSECTE
+{
+ Text [ en-US ] = "Ellipse Pies" ;
+};
+String STR_ObjNameSingulCARCE
+{
+ Text [ en-US ] = "Elliptical arc" ;
+};
+String STR_ObjNamePluralCARCE
+{
+ Text [ en-US ] = "Elliptical arcs" ;
+};
+String STR_ObjNameSingulCCUTE
+{
+ Text [ en-US ] = "Ellipse Segment" ;
+};
+String STR_ObjNamePluralCCUTE
+{
+ Text [ en-US ] = "Ellipse Segments" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulPOLY
+{
+ Text [ en-US ] = "Polygon" ;
+};
+String STR_ObjNameSingulPOLY_PntAnz
+{
+ Text [ en-US ] = "Polygon %2 corners" ;
+};
+String STR_ObjNamePluralPOLY
+{
+ Text [ en-US ] = "Polygons" ;
+};
+String STR_ObjNameSingulPLIN
+{
+ Text [ en-US ] = "Polyline" ;
+};
+String STR_ObjNameSingulPLIN_PntAnz
+{
+ Text [ en-US ] = "Polyline with %2 corners" ;
+};
+String STR_ObjNamePluralPLIN
+{
+ Text [ en-US ] = "Polylines" ;
+};
+String STR_ObjNameSingulPATHLINE
+{
+ Text [ en-US ] = "Bézier curve" ;
+};
+String STR_ObjNamePluralPATHLINE
+{
+ Text [ en-US ] = "Bézier curves" ;
+};
+String STR_ObjNameSingulPATHFILL
+{
+ Text [ en-US ] = "Bézier curve" ;
+};
+String STR_ObjNamePluralPATHFILL
+{
+ Text [ en-US ] = "Bézier curves" ;
+};
+String STR_ObjNameSingulFREELINE
+{
+ Text [ en-US ] = "Freeform Line" ;
+};
+String STR_ObjNamePluralFREELINE
+{
+ Text [ en-US ] = "Freeform Lines" ;
+};
+String STR_ObjNameSingulFREEFILL
+{
+ Text [ en-US ] = "Freeform Line" ;
+};
+String STR_ObjNamePluralFREEFILL
+{
+ Text [ en-US ] = "Freeform Lines" ;
+};
+String STR_ObjNameSingulCOMBLINE
+{
+ Text [ en-US ] = "Curve" ;
+};
+String STR_ObjNamePluralCOMBLINE
+{
+ Text [ en-US ] = "Curve objects" ;
+};
+String STR_ObjNameSingulCOMBFILL
+{
+ Text [ en-US ] = "Curve" ;
+};
+String STR_ObjNamePluralCOMBFILL
+{
+ Text [ en-US ] = "Curve objects" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulNATSPLN
+{
+ Text [ en-US ] = "Natural Spline" ;
+};
+String STR_ObjNamePluralNATSPLN
+{
+ Text [ en-US ] = "Natural Splines" ;
+};
+String STR_ObjNameSingulPERSPLN
+{
+ Text [ en-US ] = "Periodic Spline" ;
+};
+String STR_ObjNamePluralPERSPLN
+{
+ Text [ en-US ] = "Periodic Splines" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulTEXT
+{
+ Text [ en-US ] = "Text Frame" ;
+};
+String STR_ObjNamePluralTEXT
+{
+ Text [ en-US ] = "Text Frame" ;
+};
+String STR_ObjNameSingulTEXTLNK
+{
+ Text [ en-US ] = "Linked text frame" ;
+};
+String STR_ObjNamePluralTEXTLNK
+{
+ Text [ en-US ] = "Linked text frames" ;
+};
+ //String STR_ObjNameSingulXTXT {
+ // Text="Textfortsetzungsrahmen";
+ // Text[ENGLISH]="drawobject";
+ // Text[norwegian]="Tegneobjekt";
+ // Text[italian]="Disegna oggetto";
+ // Text[portuguese_brazilian]="Desenhar objeto";
+ // Text[portuguese]="Desenhar objecto";
+ // Text[finnish]="Piirto-objekti";
+ // Text[danish]="Tegneobjekt";
+ // Text[french]="Drawobject";
+ // Text[swedish]="Ritobjekt";
+ // Text[dutch]="Tekenobject";
+ // Text[spanish]="Objeto de dibujo";
+ // Text[english_us]="drawobject";
+ //};
+ //String STR_ObjNamePluralXTXT {
+ // Text="Textfortsetzungsrahmen";
+ // Text[ENGLISH]="drawobjects";
+ // Text[norwegian]="Tegneobjektr";
+ // Text[italian]="Disegna oggetti";
+ // Text[portuguese_brazilian]="Desenhar objetos";
+ // Text[portuguese]="Desenhar objectos";
+ // Text[finnish]="Piirto-objektit";
+ // Text[danish]="Tegneobjekter";
+ // Text[french]="Drawobjects";
+ // Text[swedish]="Ritobjekt";
+ // Text[dutch]="Tekenobjecten";
+ // Text[spanish]="Objetos de dibujo";
+ // Text[english_us]="drawobjects";
+ //};
+String STR_ObjNameSingulFITTEXT
+{
+ Text [ en-US ] = "Fit-to-size text object" ;
+};
+String STR_ObjNamePluralFITTEXT
+{
+ Text [ en-US ] = "Fit-to-size text objects" ;
+};
+String STR_ObjNameSingulFITALLTEXT
+{
+ Text [ en-US ] = "Fit-to-size text object" ;
+};
+String STR_ObjNamePluralFITALLTEXT
+{
+ Text [ en-US ] = "Fit-to-size text objects" ;
+};
+String STR_ObjNameSingulTITLETEXT
+{
+ Text [ en-US ] = "Title text" ;
+};
+String STR_ObjNamePluralTITLETEXT
+{
+ Text [ en-US ] = "Title texts" ;
+};
+String STR_ObjNameSingulOUTLINETEXT
+{
+ Text [ en-US ] = "Outline Text" ;
+};
+String STR_ObjNamePluralOUTLINETEXT
+{
+ Text [ en-US ] = "Outline Texts" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulGRAF
+{
+ Text [ en-US ] = "graphic" ;
+};
+String STR_ObjNamePluralGRAF
+{
+ Text [ en-US ] = "graphics" ;
+};
+String STR_ObjNameSingulGRAFLNK
+{
+ Text [ en-US ] = "Linked graphic" ;
+};
+String STR_ObjNamePluralGRAFLNK
+{
+ Text [ en-US ] = "Linked graphics" ;
+};
+String STR_ObjNameSingulGRAFNONE
+{
+ Text [ en-US ] = "Blank graphic object" ;
+};
+String STR_ObjNamePluralGRAFNONE
+{
+ Text [ en-US ] = "Blank graphic objects" ;
+};
+String STR_ObjNameSingulGRAFNONELNK
+{
+ Text [ en-US ] = "Blank linked graphic" ;
+};
+String STR_ObjNamePluralGRAFNONELNK
+{
+ Text [ en-US ] = "Blank linked graphics" ;
+};
+String STR_ObjNameSingulGRAFMTF
+{
+ Text [ en-US ] = "Metafile" ;
+};
+String STR_ObjNamePluralGRAFMTF
+{
+ Text [ en-US ] = "Metafiles" ;
+};
+String STR_ObjNameSingulGRAFMTFLNK
+{
+ Text [ en-US ] = "Linked Metafile" ;
+};
+String STR_ObjNamePluralGRAFMTFLNK
+{
+ Text [ en-US ] = "Linked Metafiles" ;
+};
+String STR_ObjNameSingulGRAFBMP
+{
+ Text [ en-US ] = "Bitmap" ;
+};
+String STR_ObjNameSingulGRAFBMPTRANS
+{
+ Text [ en-US ] = "Bitmap with transparency" ;
+};
+String STR_ObjNameSingulGRAFBMPLNK
+{
+ Text [ en-US ] = "Linked Bitmap" ;
+};
+String STR_ObjNameSingulGRAFBMPTRANSLNK
+{
+ Text [ en-US ] = "Linked bitmap with transparency" ;
+};
+String STR_ObjNamePluralGRAFBMP
+{
+ Text [ en-US ] = "Bitmaps" ;
+};
+String STR_ObjNamePluralGRAFBMPTRANS
+{
+ Text [ en-US ] = "Bitmaps with transparency" ;
+};
+String STR_ObjNamePluralGRAFBMPLNK
+{
+ Text [ en-US ] = "Linked bitmaps" ;
+};
+String STR_ObjNamePluralGRAFBMPTRANSLNK
+{
+ Text [ en-US ] = "Linked bitmaps with transparency" ;
+};
+String STR_ObjNameSingulCUSTOMSHAPE
+{
+ Text [ en-US ] = "Shape";
+};
+String STR_ObjNamePluralCUSTOMSHAPE
+{
+ Text [ en-US ] = "Shapes";
+};
+String STR_ObjNameSingulGRAFMAC
+{
+ Text [ en-US ] = "Mac graphic" ;
+};
+String STR_ObjNamePluralGRAFMAC
+{
+ Text [ en-US ] = "Mac graphics" ;
+};
+String STR_ObjNameSingulGRAFMACLNK
+{
+ Text [ en-US ] = "Linked Mac graphic" ;
+};
+String STR_ObjNamePluralGRAFMACLNK
+{
+ Text [ en-US ] = "Linked Mac graphics" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulOLE2
+{
+ Text [ en-US ] = "embedded object (OLE)" ;
+};
+String STR_ObjNamePluralOLE2
+{
+ Text [ en-US ] = "Embedded objects (OLE)" ;
+};
+String STR_ObjNameSingulUno
+{
+ Text [ en-US ] = "Control";
+};
+String STR_ObjNamePluralUno
+{
+ Text [ en-US ] = "Controls";
+};
+String STR_ObjNameSingulOLE2LNK
+{
+ Text [ en-US ] = "linked embedded object (OLE)" ;
+};
+String STR_ObjNamePluralOLE2LNK
+{
+ Text [ en-US ] = "Linked embedded objects (OLE)" ;
+};
+String STR_ObjOLE2NamePrefix
+{
+ Text [ en-US ] = "Object" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulFrame
+{
+ Text [ en-US ] = "Frame" ;
+};
+String STR_ObjNamePluralFrame
+{
+ Text [ en-US ] = "Frames" ;
+};
+String STR_ObjFrameNamePrefix
+{
+ Text [ en-US ] = "Frame" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulEDGE
+{
+ Text [ en-US ] = "Object Connectors" ;
+};
+String STR_ObjNamePluralEDGE
+{
+ Text [ en-US ] = "Object Connectors" ;
+};
+String STR_ObjNameSingulCAPTION
+{
+ Text [ en-US ] = "Callout" ;
+};
+String STR_ObjNamePluralCAPTION
+{
+ Text [ en-US ] = "Callouts" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ObjNameSingulPAGE
+{
+ Text [ en-US ] = "Preview object" ;
+};
+String STR_ObjNamePluralPAGE
+{
+ Text [ en-US ] = "Preview objects" ;
+};
+String STR_ObjNameSingulMEASURE
+{
+ Text [ en-US ] = "Dimension line" ;
+};
+String STR_ObjNamePluralMEASURE
+{
+ Text [ en-US ] = "Dimensioning objects" ;
+};
+String STR_ObjNamePlural
+{
+ Text [ en-US ] = "draw objects" ;
+};
+String STR_ObjNameNoObj
+{
+ Text [ en-US ] = "No draw object" ;
+};
+String STR_ObjNameAnd
+{
+ Text [ en-US ] = "and" ;
+};
+String STR_ObjNameSingulPlural
+{
+ Text [ en-US ] = "draw object(s)" ;
+};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// Neu ab 537: Namen fuer 3D-Objekte
+String STR_ObjNameSingulCube3d
+{
+ Text [ en-US ] = "3D cube";
+};
+
+String STR_ObjNamePluralCube3d
+{
+ Text [ en-US ] = "3D cubes";
+};
+
+String STR_ObjNameSingulExtrude3d
+{
+ Text [ en-US ] = "Extrusion object";
+};
+
+String STR_ObjNamePluralExtrude3d
+{
+ Text [ en-US ] = "Extrusion objects";
+};
+
+String STR_ObjNameSingulLabel3d
+{
+ Text [ en-US ] = "3D text";
+};
+
+String STR_ObjNamePluralLabel3d
+{
+ Text [ en-US ] = "3D texts";
+};
+
+String STR_ObjNameSingulLathe3d
+{
+ Text [ en-US ] = "rotation object";
+};
+
+String STR_ObjNamePluralLathe3d
+{
+ Text [ en-US ] = "rotation objects";
+};
+
+String STR_ObjNameSingulObj3d
+{
+ Text [ en-US ] = "3D object";
+};
+
+String STR_ObjNamePluralObj3d
+{
+ Text [ en-US ] = "3D objects";
+};
+
+String STR_ObjNamePluralPoly3d
+{
+ Text [ en-US ] = "3D polygons";
+};
+
+String STR_ObjNameSingulScene3d
+{
+ Text [ en-US ] = "3D scene";
+};
+
+String STR_ObjNamePluralScene3d
+{
+ Text [ en-US ] = "3D scenes";
+};
+
+String STR_ObjNameSingulSphere3d
+{
+ Text [ en-US ] = "sphere";
+};
+
+String STR_ObjNamePluralSphere3d
+{
+ Text [ en-US ] = "spheres";
+};
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+
+String STR_EditWithCopy
+{
+ Text [ en-US ] = "with copy" ;
+};
+String STR_EditPosSize
+{
+ Text [ en-US ] = "Set position and size for %1" ;
+};
+String STR_EditDelete
+{
+ Text [ en-US ] = "Delete %1" ;
+};
+String STR_EditMovToTop
+{
+ Text [ en-US ] = "Move %1 forward" ;
+};
+String STR_EditMovToBtm
+{
+ Text [ en-US ] = "Move %1 further back" ;
+};
+String STR_EditPutToTop
+{
+ Text [ en-US ] = "Move %1 to front" ;
+};
+String STR_EditPutToBtm
+{
+ Text [ en-US ] = "Move %1 to back" ;
+};
+String STR_EditRevOrder
+{
+ Text [ en-US ] = "Reverse order of %1" ;
+};
+String STR_EditMove
+{
+ Text [ en-US ] = "Move %1" ;
+};
+String STR_EditResize
+{
+ Text [ en-US ] = "Resize %1" ;
+};
+String STR_EditRotate
+{
+ Text [ en-US ] = "Rotate %1" ;
+};
+String STR_EditMirrorHori
+{
+ Text [ en-US ] = "Flip %1 horizontal" ;
+};
+String STR_EditMirrorVert
+{
+ Text [ en-US ] = "Flip %1 vertical" ;
+};
+String STR_EditMirrorDiag
+{
+ Text [ en-US ] = "Flip %1 diagonal" ;
+};
+String STR_EditMirrorFree
+{
+ Text [ en-US ] = "Flip %1 freehand" ;
+};
+String STR_EditShear
+{
+ Text [ en-US ] = "Distort %1 (slant)" ;
+};
+String STR_EditCrook
+{
+ Text [ en-US ] = "Arrange %1 in circle" ;
+};
+String STR_EditCrookContortion
+{
+ Text [ en-US ] = "Curve %1 in circle" ;
+};
+String STR_EditDistort
+{
+ Text [ en-US ] = "Distort %1" ;
+};
+String STR_EditRipUp
+{
+ Text [ en-US ] = "Undo %1" ;
+};
+String STR_EditSetPointsSmooth
+{
+ Text [ en-US ] = "Modify bézier properties of %1" ;
+};
+String STR_EditSetSegmentsKind
+{
+ Text [ en-US ] = "Modify bézier properties of %1" ;
+};
+String STR_EditShut
+{
+ Text [ en-US ] = "Close %1" ;
+};
+String STR_EditSetGlueEscDir
+{
+ Text [ en-US ] = "Set exit direction for %1" ;
+};
+String STR_EditSetGluePercent
+{
+ Text [ en-US ] = "Set relative attribute at %1" ;
+};
+String STR_EditSetGlueAlign
+{
+ Text [ en-US ] = "Set reference point for %1" ;
+};
+String STR_EditGroup
+{
+ Text [ en-US ] = "Group %1" ;
+};
+String STR_EditUngroup
+{
+ Text [ en-US ] = "Ungroup %1" ;
+};
+String STR_EditSetAttributes
+{
+ Text [ en-US ] = "Apply attributes to %1" ;
+};
+String STR_EditSetStylesheet
+{
+ Text [ en-US ] = "Apply Styles to %1" ;
+};
+String STR_EditDelStylesheet
+{
+ Text [ en-US ] = "Remove Style from %1" ;
+};
+String STR_EditConvToPoly
+{
+ Text [ en-US ] = "Convert %1 to polygon" ;
+};
+String STR_EditConvToPolys
+{
+ Text [ en-US ] = "Convert %1 to polygons" ;
+};
+String STR_EditConvToCurve
+{
+ Text [ en-US ] = "Convert %1 to curve" ;
+};
+String STR_EditConvToCurves
+{
+ Text [ en-US ] = "Convert %1 to curves" ;
+};
+String STR_EditConvToContour
+{
+ Text [ en-US ] = "Convert %1 to contour";
+};
+String STR_EditConvToContours
+{
+ Text [ en-US ] = "Convert %1 to contours";
+};
+String STR_EditAlign
+{
+ Text [ en-US ] = "Align %1" ;
+};
+String STR_EditAlignVTop
+{
+ Text [ en-US ] = "Align %1 to top" ;
+};
+String STR_EditAlignVBottom
+{
+ Text [ en-US ] = "Align %1 to bottom" ;
+};
+String STR_EditAlignVCenter
+{
+ Text [ en-US ] = "Horizontally center %1" ;
+};
+String STR_EditAlignHLeft
+{
+ Text [ en-US ] = "Align %1 to left" ;
+};
+String STR_EditAlignHRight
+{
+ Text [ en-US ] = "Align %1 to right" ;
+};
+String STR_EditAlignHCenter
+{
+ Text [ en-US ] = "Vertically center %1" ;
+};
+String STR_EditAlignCenter
+{
+ Text [ en-US ] = "Center %1" ;
+};
+String STR_EditTransform
+{
+ Text [ en-US ] = "Transform %1" ;
+};
+String STR_EditCombine_PolyPoly
+{
+ Text [ en-US ] = "Combine %1" ;
+};
+String STR_EditMergeMergePoly
+{
+ Text [ en-US ] = "Merge %1";
+};
+String STR_EditMergeSubstractPoly
+{
+ Text [ en-US ] = "Subtract %1";
+};
+String STR_EditMergeIntersectPoly
+{
+ Text [ en-US ] = "Intersect %1";
+};
+String STR_DistributeMarkedObjects
+{
+ Text [ en-US ] = "Distribute selected objects";
+};
+String STR_EditCombine_OnePoly
+{
+ Text [ en-US ] = "Combine %1" ;
+};
+String STR_EditDismantle_Polys
+{
+ Text [ en-US ] = "Split %1" ;
+};
+String STR_EditDismantle_Lines
+{
+ Text [ en-US ] = "Split %1" ;
+};
+String STR_EditImportMtf
+{
+ Text [ en-US ] = "Split %1" ;
+};
+String STR_EditImportSGV
+{
+ Text = "StarDraw Dos Zeichnung importieren" ;
+};
+String STR_EditImportHPGL
+{
+ Text = "HPGL importieren" ;
+};
+String STR_EditImportDXF
+{
+ Text = "DXF importieren" ;
+};
+String STR_ExchangePaste
+{
+ Text [ en-US ] = "Insert object(s)" ;
+};
+String STR_ExchangeClpCut
+{
+ Text [ en-US ] = "Cut %1" ;
+};
+String STR_ExchangeClpPaste
+{
+ Text [ en-US ] = "Paste Clipboard" ;
+};
+String STR_ExchangeDD
+{
+ Text [ en-US ] = "Drag and Drop %1" ;
+};
+String STR_ExchangeDDPaste
+{
+ Text [ en-US ] = "Insert Drag and Drop" ;
+};
+String STR_DragInsertPoint
+{
+ Text [ en-US ] = "Insert point to %1" ;
+};
+String STR_DragInsertGluePoint
+{
+ Text [ en-US ] = "Insert glue point to %1" ;
+};
+String STR_DragMethMovHdl
+{
+ Text [ en-US ] = "Move reference-point" ;
+};
+String STR_DragMethObjOwn
+{
+ Text [ en-US ] = "Geometrically change %1" ;
+};
+String STR_DragMethMove
+{
+ Text [ en-US ] = "Move %1" ;
+};
+String STR_DragMethResize
+{
+ Text [ en-US ] = "Resize %1" ;
+};
+String STR_DragMethRotate
+{
+ Text [ en-US ] = "Rotate %1" ;
+};
+String STR_DragMethMirrorHori
+{
+ Text [ en-US ] = "Flip %1 horizontal" ;
+};
+String STR_DragMethMirrorVert
+{
+ Text [ en-US ] = "Flip %1 vertical" ;
+};
+String STR_DragMethMirrorDiag
+{
+ Text [ en-US ] = "Flip %1 diagonal" ;
+};
+String STR_DragMethMirrorFree
+{
+ Text [ en-US ] = "Flip %1 freehand" ;
+};
+String STR_DragMethGradient
+{
+ Text [ en-US ] = "Interactive gradient for %1";
+};
+String STR_DragMethTransparence
+{
+ Text [ en-US ] = "Interactive transparency for %1";
+};
+String STR_DragMethShear
+{
+ Text [ en-US ] = "Distort %1 (slant)" ;
+};
+String STR_DragMethCrook
+{
+ Text [ en-US ] = "Arrange %1 in circle" ;
+};
+String STR_DragMethCrookContortion
+{
+ Text [ en-US ] = "Curve %1 in circle" ;
+};
+String STR_DragMethDistort
+{
+ Text [ en-US ] = "Distort %1" ;
+};
+String STR_DragMethCrop
+{
+ Text [ en-US ] = "Crop %O" ;
+};
+
+String STR_DragRectEckRad
+{
+ Text [ en-US ] = "Alter radius by %1" ;
+};
+String STR_DragPathObj
+{
+ Text [ en-US ] = "Change %1" ;
+};
+String STR_DragRectResize
+{
+ Text [ en-US ] = "Resize %1" ;
+};
+String STR_DragCaptFram
+{
+ Text [ en-US ] = "Move %1" ;
+};
+String STR_DragCaptTail
+{
+ Text [ en-US ] = "Move end point of %1" ;
+};
+String STR_DragCircAngle
+{
+ Text [ en-US ] = "Adjust angle by %1" ;
+};
+String STR_DragEdgeTail
+{
+ Text [ en-US ] = "Change %1" ;
+};
+String STR_ViewTextEdit
+{
+ Text [ en-US ] = "TextEdit: Paragraph %1, Row %2, Column %3" ;
+};
+String STR_ViewMarked
+{
+ Text [ en-US ] = "%1 selected" ;
+};
+String STR_ViewMarkedPoint
+{
+ Text [ en-US ] = "Point from %1" ;
+};
+String STR_ViewMarkedPoints
+{
+ Text [ en-US ] = "%2 points from %1" ;
+};
+String STR_ViewMarkedGluePoint
+{
+ Text [ en-US ] = "Glue point from %1" ;
+};
+String STR_ViewMarkedGluePoints
+{
+ Text [ en-US ] = "%2 glue points from %1" ;
+};
+String STR_ViewMarkObjs
+{
+ Text [ en-US ] = "Mark objects" ;
+};
+String STR_ViewMarkMoreObjs
+{
+ Text [ en-US ] = "Mark additional objects" ;
+};
+String STR_ViewMarkPoints
+{
+ Text [ en-US ] = "Mark points" ;
+};
+String STR_ViewMarkMorePoints
+{
+ Text [ en-US ] = "Mark additional points" ;
+};
+String STR_ViewMarkGluePoints
+{
+ Text [ en-US ] = "Mark glue points" ;
+};
+String STR_ViewMarkMoreGluePoints
+{
+ Text [ en-US ] = "Mark additional glue points" ;
+};
+String STR_ViewCreateObj
+{
+ Text [ en-US ] = "Create %1" ;
+};
+String STR_UndoInsertObj
+{
+ Text [ en-US ] = "Insert %1" ;
+};
+String STR_UndoCopyObj
+{
+ Text [ en-US ] = "Copy %1" ;
+};
+String STR_UndoObjOrdNum
+{
+ Text [ en-US ] = "Change object order of %1" ;
+};
+String STR_UndoObjSetText
+{
+ Text [ en-US ] = "Edit text of %1" ;
+};
+String STR_UndoNewPage
+{
+ Text [ en-US ] = "Insert page" ;
+};
+String STR_UndoDelPage
+{
+ Text [ en-US ] = "Delete page" ;
+};
+String STR_UndoCopPage
+{
+ Text [ en-US ] = "Copy page" ;
+};
+String STR_UndoMovPage
+{
+ Text [ en-US ] = "Change order of pages" ;
+};
+String STR_UndoNewPageMasterDscr
+{
+ Text [ en-US ] = "Assign background page" ;
+};
+String STR_UndoDelPageMasterDscr
+{
+ Text [ en-US ] = "Clear background page assignment" ;
+};
+String STR_UndoMovPageMasterDscr
+{
+ Text [ en-US ] = "Move background page assignment" ;
+};
+String STR_UndoChgPageMasterDscr
+{
+ Text [ en-US ] = "Change background page assignment" ;
+};
+String STR_UndoMergeModel
+{
+ Text [ en-US ] = "Insert document" ;
+};
+String STR_UndoNewLayer
+{
+ Text [ en-US ] = "Insert Layer" ;
+};
+String STR_UndoDelLayer
+{
+ Text [ en-US ] = "Delete layer" ;
+};
+String STR_UndoMovLayer
+{
+ Text [ en-US ] = "Change order of layers" ;
+};
+// --> OD 2009-07-09 #i73249#
+String STR_UndoObjName
+{
+ Text [ en-US ] = "Change object name of %1 to" ;
+};
+String STR_UndoObjTitle
+{
+ Text [ en-US ] = "Change object title of %1" ;
+};
+String STR_UndoObjDescription
+{
+ Text [ en-US ] = "Change object description of %1" ;
+};
+// <--
+String STR_StandardLayerName
+{
+ Text [ en-US ] = "Standard" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ItemValON
+{
+ Text [ en-US ] = "on" ;
+};
+String STR_ItemValOFF
+{
+ Text [ en-US ] = "off" ;
+};
+String STR_ItemValYES
+{
+ Text [ en-US ] = "yes" ;
+};
+String STR_ItemValNO
+{
+ Text [ en-US ] = "No" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ItemValCAPTIONTYPE1
+{
+ Text [ en-US ] = "Type 1" ;
+};
+String STR_ItemValCAPTIONTYPE2
+{
+ Text [ en-US ] = "Type 2" ;
+};
+String STR_ItemValCAPTIONTYPE3
+{
+ Text [ en-US ] = "Type 3" ;
+};
+String STR_ItemValCAPTIONTYPE4
+{
+ Text [ en-US ] = "Type 4" ;
+};
+String STR_ItemValCAPTIONESCHORI
+{
+ Text [ en-US ] = "Horizontal" ;
+};
+String STR_ItemValCAPTIONESCVERT
+{
+ Text [ en-US ] = "Vertical" ;
+};
+String STR_ItemValCAPTIONESCBESTFIT
+{
+ Text [ en-US ] = "Automatic" ;
+};
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ItemValFITTOSIZENONE
+{
+ Text [ en-US ] = "Off" ;
+};
+String STR_ItemValFITTOSIZEPROP
+{
+ Text [ en-US ] = "Proportional" ;
+};
+String STR_ItemValFITTOSIZEALLLINES
+{
+ Text [ en-US ] = "Fit to size (all rows separately) " ;
+};
+String STR_ItemValFITTOSIZERESIZEAT
+{
+ Text [ en-US ] = "Use hard attributes" ;
+};
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ItemValTEXTVADJTOP
+{
+ Text [ en-US ] = "Top" ;
+};
+String STR_ItemValTEXTVADJCENTER
+{
+ Text [ en-US ] = "Center" ;
+};
+String STR_ItemValTEXTVADJBOTTOM
+{
+ Text [ en-US ] = "Bottom" ;
+};
+String STR_ItemValTEXTVADJBLOCK
+{
+ Text [ en-US ] = "Use entire height" ;
+};
+String STR_ItemValTEXTVADJSTRETCH
+{
+ Text [ en-US ] = "Stretched" ;
+};
+String STR_ItemValTEXTHADJLEFT
+{
+ Text [ en-US ] = "Left" ;
+};
+String STR_ItemValTEXTHADJCENTER
+{
+ Text [ en-US ] = "Center" ;
+};
+String STR_ItemValTEXTHADJRIGHT
+{
+ Text [ en-US ] = "Right" ;
+};
+String STR_ItemValTEXTHADJBLOCK
+{
+ Text [ en-US ] = "Use entire width" ;
+};
+String STR_ItemValTEXTHADJSTRETCH
+{
+ Text [ en-US ] = "Stretched" ;
+};
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ItemValTEXTANI_NONE
+{
+ Text [ en-US ] = "off" ;
+};
+String STR_ItemValTEXTANI_BLINK
+{
+ Text [ en-US ] = "flash" ;
+};
+String STR_ItemValTEXTANI_SCROLL
+{
+ Text [ en-US ] = "Scroll Through" ;
+};
+String STR_ItemValTEXTANI_ALTERNATE
+{
+ Text [ en-US ] = "alternating" ;
+};
+String STR_ItemValTEXTANI_SLIDE
+{
+ Text [ en-US ] = "Scroll In" ;
+};
+String STR_ItemValTEXTANI_LEFT
+{
+ Text [ en-US ] = "left" ;
+};
+String STR_ItemValTEXTANI_UP
+{
+ Text [ en-US ] = "up" ;
+};
+String STR_ItemValTEXTANI_RIGHT
+{
+ Text [ en-US ] = "right" ;
+};
+String STR_ItemValTEXTANI_DOWN
+{
+ Text [ en-US ] = "down" ;
+};
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ItemValEDGE_ORTHOLINES
+{
+ Text [ en-US ] = "Standard Connector" ;
+};
+String STR_ItemValEDGE_THREELINES
+{
+ Text [ en-US ] = "Line Connector" ;
+};
+String STR_ItemValEDGE_ONELINE
+{
+ Text [ en-US ] = "Straight Connector" ;
+};
+String STR_ItemValEDGE_BEZIER
+{
+ Text [ en-US ] = "Curved Connector" ;
+};
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ItemValMEASURE_STD
+{
+ Text [ en-US ] = "Standard" ;
+};
+String STR_ItemValMEASURE_RADIUS
+{
+ Text [ en-US ] = "Radius" ;
+};
+String STR_ItemValMEASURE_TEXTHAUTO
+{
+ Text [ en-US ] = "automatic" ;
+};
+String STR_ItemValMEASURE_TEXTLEFTOUTSIDE
+{
+ Text [ en-US ] = "left outside" ;
+};
+String STR_ItemValMEASURE_TEXTINSIDE
+{
+ Text [ en-US ] = "inside (centered)" ;
+};
+String STR_ItemValMEASURE_TEXTRIGHTOUTSID
+{
+ Text [ en-US ] = "right outside" ;
+};
+String STR_ItemValMEASURE_TEXTVAUTO
+{
+ Text [ en-US ] = "automatic" ;
+};
+String STR_ItemValMEASURE_ABOVE
+{
+ Text [ en-US ] = "on the line" ;
+};
+String STR_ItemValMEASURETEXT_BREAKEDLINE
+{
+ Text [ en-US ] = "broken line" ;
+};
+String STR_ItemValMEASURE_BELOW
+{
+ Text [ en-US ] = "below the line" ;
+};
+String STR_ItemValMEASURETEXT_VERTICALCEN
+{
+ Text [ en-US ] = "centered" ;
+};
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ItemValCIRC_FULL
+{
+ Text [ en-US ] = "full circle" ;
+};
+String STR_ItemValCIRC_SECT
+{
+ Text [ en-US ] = "Circle Pie" ;
+};
+String STR_ItemValCIRC_CUT
+{
+ Text [ en-US ] = "Circle segment" ;
+};
+String STR_ItemValCIRC_ARC
+{
+ Text [ en-US ] = "Arc" ;
+};
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+String STR_ItemNam_SHADOW
+{
+ Text [ en-US ] = "Shadow" ;
+};
+String STR_ItemNam_SHADOWCOLOR
+{
+ Text [ en-US ] = "Shadow color" ;
+};
+String STR_ItemNam_SHADOWXDIST
+{
+ Text [ en-US ] = "Horizontal shadow outline" ;
+};
+String STR_ItemNam_SHADOWYDIST
+{
+ Text [ en-US ] = "Vertical shadow outline" ;
+};
+String STR_ItemNam_SHADOWTRANSPARENCE
+{
+ Text [ en-US ] = "Shadow transparency" ;
+};
+String STR_ItemNam_SHADOW3D
+{
+ Text [ en-US ] = "3D shadow" ;
+};
+String STR_ItemNam_SHADOWPERSP
+{
+ Text [ en-US ] = "Perspective shadow" ;
+};
+String STR_ItemNam_CAPTIONTYPE
+{
+ Text [ en-US ] = "Callout type" ;
+};
+String STR_ItemNam_CAPTIONFIXEDANGLE
+{
+ Text [ en-US ] = "Given angle" ;
+};
+String STR_ItemNam_CAPTIONANGLE
+{
+ Text [ en-US ] = "Angle" ;
+};
+String STR_ItemNam_CAPTIONGAP
+{
+ Text [ en-US ] = "Gap" ;
+};
+String STR_ItemNam_CAPTIONESCDIR
+{
+ Text [ en-US ] = "Exit direction" ;
+};
+String STR_ItemNam_CAPTIONESCISREL
+{
+ Text [ en-US ] = "Relative exit position" ;
+};
+String STR_ItemNam_CAPTIONESCREL
+{
+ Text [ en-US ] = "Exit Position" ;
+};
+String STR_ItemNam_CAPTIONESCABS
+{
+ Text [ en-US ] = "Exit Position" ;
+};
+String STR_ItemNam_CAPTIONLINELEN
+{
+ Text [ en-US ] = "Line length" ;
+};
+String STR_ItemNam_CAPTIONFITLINELEN
+{
+ Text [ en-US ] = "Auto line length" ;
+};
+String STR_ItemNam_ECKENRADIUS
+{
+ Text [ en-US ] = "Corner radius" ;
+};
+String STR_ItemNam_TEXT_LEFTDIST
+{
+ Text [ en-US ] = "Left border spacing" ;
+};
+String STR_ItemNam_TEXT_RIGHTDIST
+{
+ Text [ en-US ] = "Right border spacing" ;
+};
+String STR_ItemNam_TEXT_UPPERDIST
+{
+ Text [ en-US ] = "Upper border spacing" ;
+};
+String STR_ItemNam_TEXT_LOWERDIST
+{
+ Text [ en-US ] = "Lower border spacing" ;
+};
+String STR_ItemNam_TEXT_AUTOGROWHEIGHT
+{
+ Text [ en-US ] = "AutoFit frame height" ;
+};
+String STR_ItemNam_TEXT_MINFRAMEHEIGHT
+{
+ Text [ en-US ] = "Min. frame height" ;
+};
+String STR_ItemNam_TEXT_MAXFRAMEHEIGHT
+{
+ Text [ en-US ] = "Max. frame height" ;
+};
+String STR_ItemNam_TEXT_AUTOGROWWIDTH
+{
+ Text [ en-US ] = "AutoFit frame width" ;
+};
+String STR_ItemNam_TEXT_MINFRAMEWIDTH
+{
+ Text [ en-US ] = "Min. frame width" ;
+};
+String STR_ItemNam_TEXT_MAXFRAMEWIDTH
+{
+ Text [ en-US ] = "Max. frame width" ;
+};
+String STR_ItemNam_TEXT_VERTADJUST
+{
+ Text [ en-US ] = "Vertical text anchor" ;
+};
+String STR_ItemNam_TEXT_HORZADJUST
+{
+ Text [ en-US ] = "Horizontal text anchor" ;
+};
+String STR_ItemNam_TEXT_FITTOSIZE
+{
+ Text [ en-US ] = "Fit text to frame" ;
+};
+
+String STR_ItemNam_GRAFRED
+{
+ Text [ en-US ] = "Red";
+};
+String STR_ItemNam_GRAFGREEN
+{
+ Text [ en-US ] = "Green";
+};
+String STR_ItemNam_GRAFBLUE
+{
+ Text [ en-US ] = "Blue";
+};
+String STR_ItemNam_GRAFLUMINANCE
+{
+ Text [ en-US ] = "Brightness";
+};
+String STR_ItemNam_GRAFCONTRAST
+{
+ Text [ en-US ] = "Contrast";
+};
+String STR_ItemNam_GRAFGAMMA
+{
+ Text [ en-US ] = "Gamma";
+};
+String STR_ItemNam_GRAFTRANSPARENCE
+{
+ Text [ en-US ] = "Transparency";
+};
+String STR_ItemNam_GRAFINVERT
+{
+ Text [ en-US ] = "Invert";
+};
+String STR_ItemNam_GRAFMODE
+{
+ Text [ en-US ] = "Graphics mode";
+};
+String STR_ItemNam_GRAFRESERVE2 { Text = "" ; };
+String STR_ItemNam_GRAFRESERVE3 { Text = "" ; };
+String STR_ItemNam_GRAFRESERVE4 { Text = "" ; };
+String STR_ItemNam_GRAFRESERVE5 { Text = "" ; };
+String STR_ItemNam_GRAFRESERVE6 { Text = "" ; };
+
+String STR_ItemNam_RESERVE19 { Text = "" ; };
+String STR_ItemNamSET_MISC
+{
+ Text [ en-US ] = "Various attributes" ;
+};
+String STR_ItemNam_OBJMOVEPROTECT
+{
+ Text [ en-US ] = "Position protected" ;
+};
+String STR_ItemNam_OBJSIZEPROTECT
+{
+ Text [ en-US ] = "Size Protection" ;
+};
+String STR_ItemNam_OBJPRINTABLE
+{
+ Text [ en-US ] = "Don't print" ;
+};
+String STR_ItemNam_LAYERID
+{
+ Text [ en-US ] = "Layer Indicator" ;
+};
+String STR_ItemNam_LAYERNAME
+{
+ Text [ en-US ] = "Le~vel" ;
+};
+String STR_ItemNam_OBJECTNAME
+{
+ Text [ en-US ] = "Object name" ;
+};
+String STR_ItemNam_STARTANGLE
+{
+ Text [ en-US ] = "Start angle" ;
+};
+String STR_ItemNam_ENDANGLE
+{
+ Text [ en-US ] = "Final angle" ;
+};
+String STR_ItemNam_POSITIONX
+{
+ Text [ en-US ] = "X Position" ;
+};
+String STR_ItemNam_POSITIONY
+{
+ Text [ en-US ] = "Y Position" ;
+};
+String STR_ItemNam_SIZEWIDTH
+{
+ Text [ en-US ] = "Width" ;
+};
+String STR_ItemNam_SIZEHEIGHT
+{
+ Text [ en-US ] = "Height" ;
+};
+String STR_ItemNam_ROTATEANGLE
+{
+ Text [ en-US ] = "Rotation angle" ;
+};
+String STR_ItemNam_SHEARANGLE
+{
+ Text [ en-US ] = "Shear angle" ;
+};
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////////////////////////////////////////////////////
+ // Ende der gecachten Strings
+
+ // und hier noch Bitmaps
+Bitmap BMAP_GrafikEi { File = "grafikei.bmp" ; };
+Bitmap BMAP_GrafikDe { File = "grafikde.bmp" ; };
+
+// Strings fuer den Vorlagen-Dialog
+String SIP_UNKNOWN_ATTR
+{
+ Text [ en-US ] = "Unknown attribute";
+};
+
+// Strings fuer den Vorlagen-Dialog
+String SIP_XA_LINESTYLE
+{
+ Text [ en-US ] = "Line style";
+};
+
+String SIP_XA_LINEDASH
+{
+ Text [ en-US ] = "Line pattern";
+};
+
+String SIP_XA_LINEWIDTH
+{
+ Text [ en-US ] = "Line width";
+};
+
+String SIP_XA_LINECOLOR
+{
+ Text [ en-US ] = "Line color";
+};
+
+String SIP_XA_LINESTART
+{
+ Text [ en-US ] = "Line head";
+};
+
+String SIP_XA_LINEEND
+{
+ Text [ en-US ] = "Line end";
+};
+
+String SIP_XA_LINESTARTWIDTH
+{
+ Text [ en-US ] = "Line head width";
+};
+
+String SIP_XA_LINEENDWIDTH
+{
+ Text [ en-US ] = "Line end width";
+};
+
+String SIP_XA_LINESTARTCENTER
+{
+ Text [ en-US ] = "Center arrowhead";
+};
+
+String SIP_XA_LINEENDCENTER
+{
+ Text [ en-US ] = "Center arrowend";
+};
+
+String SIP_XA_LINETRANSPARENCE
+{
+ Text [ en-US ] = "Line transparency";
+};
+
+String SIP_XA_LINEJOINT
+{
+ Text [ en-US ] = "Line joint";
+};
+
+String SIP_XA_LINERESERVED2
+{
+ Text [ en-US ] = "Line reserved for 2";
+};
+
+String SIP_XA_LINERESERVED3
+{
+ Text [ en-US ] = "Line reserved for 3";
+};
+
+String SIP_XA_LINERESERVED4
+{
+ Text [ en-US ] = "Line reserved for 4";
+};
+
+String SIP_XA_LINERESERVED5
+{
+ Text [ en-US ] = "Line reserved for 5";
+};
+
+String SIP_XA_LINERESERVED_LAST
+{
+ Text [ en-US ] = "Line reserved for 6";
+};
+
+String SIP_XATTRSET_LINE
+{
+ Text [ en-US ] = "Line attributes";
+};
+
+String SIP_XA_FILLSTYLE
+{
+ Text [ en-US ] = "Fill style";
+};
+
+String SIP_XA_FILLCOLOR
+{
+ Text [ en-US ] = "Fillcolor";
+};
+
+String SIP_XA_FILLGRADIENT
+{
+ Text [ en-US ] = "Gradient";
+};
+
+String SIP_XA_FILLHATCH
+{
+ Text [ en-US ] = "Hatching";
+};
+
+String SIP_XA_FILLBITMAP
+{
+ Text [ en-US ] = "Fillbitmap";
+};
+
+String SIP_XA_FILLTRANSPARENCE
+{
+ Text [ en-US ] = "Transparency";
+};
+
+String SIP_XA_GRADIENTSTEPCOUNT
+{
+ Text [ en-US ] = "Number of gradient steps";
+};
+
+String SIP_XA_FILLBMP_TILE
+{
+ Text [ en-US ] = "Tile fill";
+};
+
+String SIP_XA_FILLBMP_POS
+{
+ Text [ en-US ] = "Fillbitmap position";
+};
+
+String SIP_XA_FILLBMP_SIZEX
+{
+ Text [ en-US ] = "Fillbitmap width";
+};
+
+String SIP_XA_FILLBMP_SIZEY
+{
+ Text [ en-US ] = "Height of fillbitmap";
+};
+
+String SIP_XA_FILLFLOATTRANSPARENCE
+{
+ Text [ en-US ] = "Transparent gradient";
+};
+
+String SIP_XA_SECONDARYFILLCOLOR
+{
+ Text [ en-US ] = "Fill reserved for 2";
+};
+
+String SIP_XA_FILLBMP_SIZELOG
+{
+ Text [ en-US ] = "Tile size not in %";
+};
+
+String SIP_XA_FILLBMP_TILEOFFSETX
+{
+ Text [ en-US ] = "Tile offset X in %";
+};
+
+String SIP_XA_FILLBMP_TILEOFFSETY
+{
+ Text [ en-US ] = "Tile offset Y in %";
+};
+
+String SIP_XA_FILLBMP_STRETCH
+{
+ Text [ en-US ] = "Bitmap scaling";
+};
+
+String SIP_XA_FILLRESERVED3
+{
+ Text [ en-US ] = "Bitmap reserved for 3";
+};
+
+String SIP_XA_FILLRESERVED4
+{
+ Text [ en-US ] = "Bitmap reserved for 4";
+};
+
+String SIP_XA_FILLRESERVED5
+{
+ Text [ en-US ] = "Bitmap reserved for 5";
+};
+
+String SIP_XA_FILLRESERVED6
+{
+ Text [ en-US ] = "Bitmap reserved for 6";
+};
+
+String SIP_XA_FILLRESERVED7
+{
+ Text [ en-US ] = "Bitmap reserved for 7";
+};
+
+String SIP_XA_FILLRESERVED8
+{
+ Text [ en-US ] = "Bitmap reserved for 8";
+};
+
+String SIP_XA_FILLBMP_POSOFFSETX
+{
+ Text [ en-US ] = "Tile position X in %";
+};
+
+String SIP_XA_FILLBMP_POSOFFSETY
+{
+ Text [ en-US ] = "Tile position Y in %";
+};
+
+String SIP_XA_FILLBACKGROUND
+{
+ Text [ en-US ] = "Background fill";
+};
+
+String SIP_XA_FILLRESERVED10
+{
+ Text [ en-US ] = "Fill reserved for 10";
+};
+
+String SIP_XA_FILLRESERVED11
+{
+ Text [ en-US ] = "Fill reserved for 11";
+};
+
+String SIP_XA_FILLRESERVED_LAST
+{
+ Text [ en-US ] = "Fill reserved for 12";
+};
+
+String SIP_XATTRSET_FILL
+{
+ Text [ en-US ] = "Area attributes";
+};
+
+String SIP_XA_FORMTXTSTYLE
+{
+ Text [ en-US ] = "Fontwork style";
+};
+
+String SIP_XA_FORMTXTADJUST
+{
+ Text [ en-US ] = "Fontwork alignment";
+};
+
+String SIP_XA_FORMTXTDISTANCE
+{
+ Text [ en-US ] = "Fontwork spacing";
+};
+
+String SIP_XA_FORMTXTSTART
+{
+ Text [ en-US ] = "Fontwork font begin";
+};
+
+String SIP_XA_FORMTXTMIRROR
+{
+ Text [ en-US ] = "Fontwork mirror";
+};
+
+String SIP_XA_FORMTXTOUTLINE
+{
+ Text [ en-US ] = "Fontwork outline";
+};
+
+String SIP_XA_FORMTXTSHADOW
+{
+ Text [ en-US ] = "Fontwork shadow";
+};
+
+String SIP_XA_FORMTXTSHDWCOLOR
+{
+ Text [ en-US ] = "Fontwork shadow color";
+};
+
+String SIP_XA_FORMTXTSHDWXVAL
+{
+ Text [ en-US ] = "Fontwork shadow offset X";
+};
+
+String SIP_XA_FORMTXTSHDWYVAL
+{
+ Text [ en-US ] = "Fontwork shadow offset Y";
+};
+
+String SIP_XA_FORMTXTSTDFORM
+{
+ Text [ en-US ] = "Fontwork default form";
+};
+
+String SIP_XA_FORMTXTHIDEFORM
+{
+ Text [ en-US ] = "Hide fontwork outline";
+};
+
+String SIP_XA_FORMTXTSHDWTRANSP
+{
+ Text [ en-US ] = "Fontwork shadow transparency";
+};
+
+String SIP_XA_FTRESERVED2
+{
+ Text [ en-US ] = "Fontwork reserved for 2";
+};
+
+String SIP_XA_FTRESERVED3
+{
+ Text [ en-US ] = "Fontwork reserved for 3";
+};
+
+String SIP_XA_FTRESERVED4
+{
+ Text [ en-US ] = "Fontwork reserved for 4";
+};
+
+String SIP_XA_FTRESERVED5
+{
+ Text [ en-US ] = "Fontwork reserved for 5";
+};
+
+String SIP_XA_FTRESERVED_LAST
+{
+ Text [ en-US ] = "Fontwork reserved for 6";
+};
+
+String SIP_SA_SHADOW
+{
+ Text [ en-US ] = "Shadow";
+};
+
+String SIP_SA_SHADOWCOLOR
+{
+ Text [ en-US ] = "Shadow color";
+};
+
+String SIP_SA_SHADOWXDIST
+{
+ Text [ en-US ] = "Shadow spacing X";
+};
+
+String SIP_SA_SHADOWYDIST
+{
+ Text [ en-US ] = "Shadow spacing Y";
+};
+
+String SIP_SA_SHADOWTRANSPARENCE
+{
+ Text [ en-US ] = "Shadow transparency";
+};
+
+String SIP_SA_SHADOW3D
+{
+ Text [ en-US ] = "3D shadow";
+};
+
+String SIP_SA_SHADOWPERSP
+{
+ Text [ en-US ] = "Perspective shadow";
+};
+
+String SIP_SA_CAPTIONTYPE
+{
+ Text [ en-US ] = "Type of legend";
+};
+
+String SIP_SA_CAPTIONFIXEDANGLE
+{
+ Text [ en-US ] = "Fixed legend angle";
+};
+
+String SIP_SA_CAPTIONANGLE
+{
+ Text [ en-US ] = "Legend angle";
+};
+
+String SIP_SA_CAPTIONGAP
+{
+ Text [ en-US ] = "Legend lines spacing";
+};
+
+String SIP_SA_CAPTIONESCDIR
+{
+ Text [ en-US ] = "Legend exit alignment";
+};
+
+String SIP_SA_CAPTIONESCISREL
+{
+ Text [ en-US ] = "Relative exit legend";
+};
+
+String SIP_SA_CAPTIONESCREL
+{
+ Text [ en-US ] = "Relative exit legend";
+};
+
+String SIP_SA_CAPTIONESCABS
+{
+ Text [ en-US ] = "Absolute exit of legend";
+};
+
+String SIP_SA_CAPTIONLINELEN
+{
+ Text [ en-US ] = "Legend line length";
+};
+
+String SIP_SA_CAPTIONFITLINELEN
+{
+ Text [ en-US ] = "AutoLength of legend lines";
+};
+
+String SIP_SA_ECKENRADIUS
+{
+ Text [ en-US ] = "Corner radius";
+};
+
+String SIP_SA_TEXT_MINFRAMEHEIGHT
+{
+ Text [ en-US ] = "Minimal frame height";
+};
+
+String SIP_SA_TEXT_AUTOGROWHEIGHT
+{
+ Text [ en-US ] = "AutoFit height";
+};
+
+String SIP_SA_TEXT_FITTOSIZE
+{
+ Text [ en-US ] = "Fit text to frame";
+};
+
+String SIP_SA_TEXT_LEFTDIST
+{
+ Text [ en-US ] = "Left text frame spacing";
+};
+
+String SIP_SA_TEXT_RIGHTDIST
+{
+ Text [ en-US ] = "Right text frame spacing";
+};
+
+String SIP_SA_TEXT_UPPERDIST
+{
+ Text [ en-US ] = "Upper text frame spacing";
+};
+
+String SIP_SA_TEXT_LOWERDIST
+{
+ Text [ en-US ] = "Lower text frame spacing";
+};
+
+String SIP_SA_TEXT_VERTADJUST
+{
+ Text [ en-US ] = "Vertical text anchor";
+};
+
+String SIP_SA_TEXT_MAXFRAMEHEIGHT
+{
+ Text [ en-US ] = "Maximal frame height";
+};
+
+String SIP_SA_TEXT_MINFRAMEWIDTH
+{
+ Text [ en-US ] = "Minimal frame width";
+};
+
+String SIP_SA_TEXT_MAXFRAMEWIDTH
+{
+ Text [ en-US ] = "Maximal frame width";
+};
+
+String SIP_SA_TEXT_AUTOGROWWIDTH
+{
+ Text [ en-US ] = "AutoFit width";
+};
+
+String SIP_SA_TEXT_HORZADJUST
+{
+ Text [ en-US ] = "Horizontal text anchor";
+};
+
+String SIP_SA_TEXT_ANIKIND
+{
+ Text [ en-US ] = "Ticker";
+};
+
+String SIP_SA_TEXT_ANIDIRECTION
+{
+ Text [ en-US ] = "Ticker direction";
+};
+
+String SIP_SA_TEXT_ANISTARTINSIDE
+{
+ Text [ en-US ] = "Ticker start inside";
+};
+
+String SIP_SA_TEXT_ANISTOPINSIDE
+{
+ Text [ en-US ] = "Ticker stop inside";
+};
+
+String SIP_SA_TEXT_ANICOUNT
+{
+ Text [ en-US ] = "Number of ticker runs";
+};
+
+String SIP_SA_TEXT_ANIDELAY
+{
+ Text [ en-US ] = "Speed of ticker";
+};
+
+String SIP_SA_TEXT_ANIAMOUNT
+{
+ Text [ en-US ] = "Ticker step size";
+};
+
+String SIP_SA_TEXT_CONTOURFRAME
+{
+ Text [ en-US ] = "Outline text flow";
+};
+
+String SIP_SA_CUSTOMSHAPE_ADJUSTMENT
+{
+ Text[ en-US ] = "Shape Adjustment";
+};
+
+String SIP_SA_XMLATTRIBUTES
+{
+ Text [ en-US ] = "User-defined attributes";
+};
+
+String SIP_SA_TEXT_USEFIXEDCELLHEIGHT
+{
+ Text [ en-US ] = "Use font-independent line spacing";
+};
+
+String SIP_SA_WORDWRAP
+{
+ Text[ en-US ] = "Word wrap text in shape";
+};
+
+String SIP_SA_AUTOGROWSIZE
+{
+ Text[ en-US ] = "Auto grow shape to fit text";
+};
+
+String SIP_SA_RESERVE18
+{
+ Text [ en-US ] = "SvDraw reserved for 18";
+};
+
+String SIP_SA_RESERVE19
+{
+ Text [ en-US ] = "SvDraw reserved for 19";
+};
+
+String SIP_SA_EDGEKIND
+{
+ Text [ en-US ] = "Type of connector";
+};
+
+String SIP_SA_EDGENODE1HORZDIST
+{
+ Text [ en-US ] = "Horz. spacing object 1";
+};
+
+String SIP_SA_EDGENODE1VERTDIST
+{
+ Text [ en-US ] = "Vert. spacing object 1";
+};
+
+String SIP_SA_EDGENODE2HORZDIST
+{
+ Text [ en-US ] = "Horz. spacing object 2";
+};
+
+String SIP_SA_EDGENODE2VERTDIST
+{
+ Text [ en-US ] = "Vert. spacing object 2";
+};
+
+String SIP_SA_EDGENODE1GLUEDIST
+{
+ Text [ en-US ] = "Glue spacing object 1";
+};
+
+String SIP_SA_EDGENODE2GLUEDIST
+{
+ Text [ en-US ] = "Glue spacing object 2";
+};
+
+String SIP_SA_EDGELINEDELTAANZ
+{
+ Text [ en-US ] = "Number of movable lines";
+};
+
+String SIP_SA_EDGELINE1DELTA
+{
+ Text [ en-US ] = "Offset line 1";
+};
+
+String SIP_SA_EDGELINE2DELTA
+{
+ Text [ en-US ] = "Offset line 2";
+};
+
+String SIP_SA_EDGELINE3DELTA
+{
+ Text [ en-US ] = "Offset line 3";
+};
+
+String SIP_SA_MEASUREKIND
+{
+ Text [ en-US ] = "Type of dimensioning";
+};
+
+String SIP_SA_MEASURETEXTHPOS
+{
+ Text [ en-US ] = "Dimension value - horizontal position";
+};
+
+String SIP_SA_MEASURETEXTVPOS
+{
+ Text [ en-US ] = "Dimension value - vertical position";
+};
+
+String SIP_SA_MEASURELINEDIST
+{
+ Text [ en-US ] = "Dimension line space";
+};
+
+String SIP_SA_MEASUREHELPLINEOVERHANG
+{
+ Text [ en-US ] = "Dimension help line overhang";
+};
+
+String SIP_SA_MEASUREHELPLINEDIST
+{
+ Text [ en-US ] = "Dimension help line spacing";
+};
+
+String SIP_SA_MEASUREHELPLINE1LEN
+{
+ Text [ en-US ] = "Backlog of dimension help line 1";
+};
+
+String SIP_SA_MEASUREHELPLINE2LEN
+{
+ Text [ en-US ] = "Backlog of dimension help line 2";
+};
+
+String SIP_SA_MEASUREBELOWREFEDGE
+{
+ Text [ en-US ] = "Lower edge dimensioning";
+};
+
+String SIP_SA_MEASURETEXTROTA90
+{
+ Text [ en-US ] = "Dimension value across dimension line";
+};
+
+String SIP_SA_MEASURETEXTUPSIDEDOWN
+{
+ Text [ en-US ] = "Rotate dimension value by 180 degree";
+};
+
+String SIP_SA_MEASUREOVERHANG
+{
+ Text [ en-US ] = "Dimension line overhang";
+};
+
+String SIP_SA_MEASUREUNIT
+{
+ Text [ en-US ] = "Measure unit";
+};
+
+String SIP_SA_MEASURESCALE
+{
+ Text [ en-US ] = "Additional scale factor";
+};
+
+String SIP_SA_MEASURESHOWUNIT
+{
+ Text [ en-US ] = "Measure unit display";
+};
+
+String SIP_SA_MEASUREFORMATSTRING
+{
+ Text [ en-US ] = "Dimension value format";
+};
+
+String SIP_SA_MEASURETEXTAUTOANGLE
+{
+ Text [ en-US ] = "AutoPositioning of the dimension value";
+};
+
+String SIP_SA_MEASURETEXTAUTOANGLEVIEW
+{
+ Text [ en-US ] = "Angle for the automatic positioning of the dimension value";
+};
+
+String SIP_SA_MEASURETEXTISFIXEDANGLE
+{
+ Text [ en-US ] = "Determination of the dimension value angle";
+};
+
+String SIP_SA_MEASURETEXTFIXEDANGLE
+{
+ Text [ en-US ] = "Angle of the dimension value";
+};
+
+String SIP_SA_MEASUREDECIMALPLACES
+{
+ Text [ en-US ] = "Decimal places";
+};
+
+String SIP_SA_MEASURERESERVE05
+{
+ Text [ en-US ] = "Dimensioning reserved 5";
+};
+
+String SIP_SA_MEASURERESERVE06
+{
+ Text [ en-US ] = "Dimensioning reserved for 6";
+};
+
+String SIP_SA_MEASURERESERVE07
+{
+ Text [ en-US ] = "Dimensioning reserved for 7";
+};
+
+String SIP_SA_CIRCKIND
+{
+ Text [ en-US ] = "Type of circle";
+};
+
+String SIP_SA_CIRCSTARTANGLE
+{
+ Text [ en-US ] = "Start angle";
+};
+
+String SIP_SA_CIRCENDANGLE
+{
+ Text [ en-US ] = "End angle";
+};
+
+String SIP_SA_CIRCRESERVE0
+{
+ Text [ en-US ] = "Circle reserved for 0";
+};
+
+String SIP_SA_CIRCRESERVE1
+{
+ Text [ en-US ] = "Circle reserved for 1";
+};
+
+String SIP_SA_CIRCRESERVE2
+{
+ Text [ en-US ] = "Circle reserved for 2";
+};
+
+String SIP_SA_CIRCRESERVE3
+{
+ Text [ en-US ] = "Circle reserved for 3";
+};
+
+String SIP_SA_OBJMOVEPROTECT
+{
+ Text [ en-US ] = "Protected object position";
+};
+
+String SIP_SA_OBJSIZEPROTECT
+{
+ Text [ en-US ] = "Protected object size";
+};
+
+String SIP_SA_OBJPRINTABLE
+{
+ Text [ en-US ] = "Object, printable";
+};
+
+String SIP_SA_OBJVISIBLE
+{
+ Text [ en-US ] = "Object, visible";
+};
+
+String SIP_SA_LAYERID
+{
+ Text [ en-US ] = "Level ID";
+};
+
+String SIP_SA_LAYERNAME
+{
+ Text [ en-US ] = "Layer";
+};
+
+String SIP_SA_OBJECTNAME
+{
+ Text [ en-US ] = "Object name";
+};
+
+String SIP_SA_ALLPOSITIONX
+{
+ Text [ en-US ] = "Position X, complete";
+};
+
+String SIP_SA_ALLPOSITIONY
+{
+ Text [ en-US ] = "Position Y, complete";
+};
+
+String SIP_SA_ALLSIZEWIDTH
+{
+ Text [ en-US ] = "Total Width";
+};
+
+String SIP_SA_ALLSIZEHEIGHT
+{
+ Text [ en-US ] = "Height, complete";
+};
+
+String SIP_SA_ONEPOSITIONX
+{
+ Text [ en-US ] = "Single position X";
+};
+
+String SIP_SA_ONEPOSITIONY
+{
+ Text [ en-US ] = "Single position Y";
+};
+
+String SIP_SA_ONESIZEWIDTH
+{
+ Text [ en-US ] = "Single width";
+};
+
+String SIP_SA_ONESIZEHEIGHT
+{
+ Text [ en-US ] = "Single height";
+};
+
+String SIP_SA_LOGICSIZEWIDTH
+{
+ Text [ en-US ] = "Logical width";
+};
+
+String SIP_SA_LOGICSIZEHEIGHT
+{
+ Text [ en-US ] = "Logical height";
+};
+
+String SIP_SA_ROTATEANGLE
+{
+ Text [ en-US ] = "Single rotation angle";
+};
+
+String SIP_SA_SHEARANGLE
+{
+ Text [ en-US ] = "Single shear angle";
+};
+
+String SIP_SA_MOVEX
+{
+ Text [ en-US ] = "Move horizontally";
+};
+
+String SIP_SA_MOVEY
+{
+ Text [ en-US ] = "Move vertically";
+};
+
+String SIP_SA_RESIZEXONE
+{
+ Text [ en-US ] = "Resize X, single";
+};
+
+String SIP_SA_RESIZEYONE
+{
+ Text [ en-US ] = "Resize Y, single";
+};
+
+String SIP_SA_ROTATEONE
+{
+ Text [ en-US ] = "Single rotation";
+};
+
+String SIP_SA_HORZSHEARONE
+{
+ Text [ en-US ] = "Single horizontal shear";
+};
+
+String SIP_SA_VERTSHEARONE
+{
+ Text [ en-US ] = "Single vertical shear";
+};
+
+String SIP_SA_RESIZEXALL
+{
+ Text [ en-US ] = "Resize X, complete";
+};
+
+String SIP_SA_RESIZEYALL
+{
+ Text [ en-US ] = "Resize Y, complete";
+};
+
+String SIP_SA_ROTATEALL
+{
+ Text [ en-US ] = "Rotate all";
+};
+
+String SIP_SA_HORZSHEARALL
+{
+ Text [ en-US ] = "Shear horizontal, complete";
+};
+
+String SIP_SA_VERTSHEARALL
+{
+ Text [ en-US ] = "Shear vertical, complete";
+};
+
+String SIP_SA_TRANSFORMREF1X
+{
+ Text [ en-US ] = "Reference point 1 X";
+};
+
+String SIP_SA_TRANSFORMREF1Y
+{
+ Text [ en-US ] = "Reference point 1 Y";
+};
+
+String SIP_SA_TRANSFORMREF2X
+{
+ Text [ en-US ] = "Reference point 2 X";
+};
+
+String SIP_SA_TRANSFORMREF2Y
+{
+ Text [ en-US ] = "Reference point 2 Y";
+};
+
+String SIP_EE_PARA_HYPHENATE
+{
+ Text [ en-US ] = "Hyphenation";
+};
+
+String SIP_EE_PARA_BULLETSTATE
+{
+ Text [ en-US ] = "Display bullets";
+};
+
+String SIP_EE_PARA_OUTLLRSPACE
+{
+ Text [ en-US ] = "Numbering indents";
+};
+
+String SIP_EE_PARA_OUTLLEVEL
+{
+ Text [ en-US ] = "Numbering level";
+};
+
+String SIP_EE_PARA_BULLET
+{
+ Text [ en-US ] = "Bullets and Numberings";
+};
+
+String SIP_EE_PARA_LRSPACE
+{
+ Text [ en-US ] = "Indents";
+};
+
+String SIP_EE_PARA_ULSPACE
+{
+ Text [ en-US ] = "Paragraph spacing";
+};
+
+String SIP_EE_PARA_SBL
+{
+ Text [ en-US ] = "Line spacing";
+};
+
+String SIP_EE_PARA_JUST
+{
+ Text [ en-US ] = "Paragraph alignment";
+};
+
+String SIP_EE_PARA_TABS
+{
+ Text [ en-US ] = "Tabulators";
+};
+
+String SIP_EE_CHAR_COLOR
+{
+ Text [ en-US ] = "Font color";
+};
+
+String SIP_EE_CHAR_FONTINFO
+{
+ Text [ en-US ] = "Character set";
+};
+
+String SIP_EE_CHAR_FONTHEIGHT
+{
+ Text [ en-US ] = "Font size";
+};
+
+String SIP_EE_CHAR_FONTWIDTH
+{
+ Text [ en-US ] = "Font width";
+};
+
+String SIP_EE_CHAR_WEIGHT
+{
+ Text [ en-US ] = "Bold (thickness)";
+};
+
+String SIP_EE_CHAR_UNDERLINE
+{
+ Text [ en-US ] = "Underline";
+};
+
+String SIP_EE_CHAR_OVERLINE
+{
+ Text [ en-US ] = "Overline";
+};
+
+String SIP_EE_CHAR_STRIKEOUT
+{
+ Text [ en-US ] = "Strikethrough";
+};
+
+String SIP_EE_CHAR_ITALIC
+{
+ Text [ en-US ] = "Italic";
+};
+
+String SIP_EE_CHAR_OUTLINE
+{
+ Text [ en-US ] = "Outline";
+};
+
+String SIP_EE_CHAR_SHADOW
+{
+ Text [ en-US ] = "Font shadow";
+};
+
+String SIP_EE_CHAR_ESCAPEMENT
+{
+ Text [ en-US ] = "Superscript/subscript";
+};
+
+String SIP_EE_CHAR_PAIRKERNING
+{
+ Text [ en-US ] = "Kerning";
+};
+
+String SIP_EE_CHAR_KERNING
+{
+ Text [ en-US ] = "Manual kerning";
+};
+
+String SIP_EE_CHAR_WLM
+{
+ Text [ en-US ] = "No underline for spaces";
+};
+
+String SIP_EE_FEATURE_TAB
+{
+ Text [ en-US ] = "Tabulator";
+};
+
+String SIP_EE_FEATURE_LINEBR
+{
+ Text [ en-US ] = "Optional line break";
+};
+
+String SIP_EE_FEATURE_NOTCONV
+{
+ Text [ en-US ] = "Non-convertible character";
+};
+
+String SIP_EE_FEATURE_FIELD
+{
+ Text [ en-US ] = "Fields";
+};
+
+String SIP_SA_GRAFRED
+{
+ Text [ en-US ] = "Red";
+};
+String SIP_SA_GRAFGREEN
+{
+ Text [ en-US ] = "Green";
+};
+String SIP_SA_GRAFBLUE
+{
+ Text [ en-US ] = "Blue";
+};
+String SIP_SA_GRAFLUMINANCE
+{
+ Text [ en-US ] = "Brightness";
+};
+String SIP_SA_GRAFCONTRAST
+{
+ Text [ en-US ] = "Contrast";
+};
+String SIP_SA_GRAFGAMMA
+{
+ Text [ en-US ] = "Gamma";
+};
+String SIP_SA_GRAFTRANSPARENCE
+{
+ Text [ en-US ] = "Transparency";
+};
+String SIP_SA_GRAFINVERT
+{
+ Text [ en-US ] = "Invert";
+};
+String SIP_SA_GRAFMODE
+{
+ Text [ en-US ] = "Graphics mode";
+};
+String SIP_SA_GRAFCROP
+{
+ Text [ en-US ] = "Crop";
+
+};
+String SIP_SA_GRAFRESERVE3 { Text = "" ; };
+String SIP_SA_GRAFRESERVE4 { Text = "" ; };
+String SIP_SA_GRAFRESERVE5 { Text = "" ; };
+String SIP_SA_GRAFRESERVE6 { Text = "" ; };
+
+Bitmap SIP_SA_MARKERS
+{
+ File = "markers.bmp";
+};
+
+Bitmap SIP_SA_FINE_MARKERS
+{
+ File = "markers2.bmp";
+};
+
+// #100499#
+Bitmap BMP_SVXOLEOBJ
+{
+ File = "oleobj.bmp" ;
+};
+
+// #101928#
+Bitmap SIP_SA_ACCESSIBILITY_MARKERS
+{
+ File = "markersACC.bmp";
+};
+
+String STR_ObjNameSingulMEDIA
+{
+ Text [ en-US ] = "Media object" ;
+};
+String STR_ObjNamePluralMEDIA
+{
+ Text [ en-US ] = "Media objects" ;
+};
+
+// drawing layer table strings
+
+String STR_TABLE_ATTR
+{
+ Text [ en-US ] = "Apply table attributes" ;
+};
+String STR_TABLE_AUTOFMT
+{
+ Text [ en-US ] = "AutoFormat table" ;
+};
+String STR_TABLE_INSCOL
+{
+ Text [ en-US ] = "Insert column" ;
+};
+String STR_TABLE_INSROW
+{
+ Text [ en-US ] = "Insert row" ;
+};
+String STR_UNDO_COL_DELETE
+{
+ Text [ en-US ] = "Delete column" ;
+};
+String STR_UNDO_ROW_DELETE
+{
+ Text [ en-US ] = "Delete row" ;
+};
+String STR_TABLE_SPLIT
+{
+ Text [ en-US ] = "Split cells" ;
+};
+String STR_TABLE_MERGE
+{
+ Text [ en-US ] = "Merge cells" ;
+};
+String STR_TABLE_NUMFORMAT
+{
+ Text [ en-US ] = "Format cell" ;
+};
+
+String STR_TABLE_DISTRIBUTE_ROWS
+{
+ Text [ en-US ] = "Distribute rows" ;
+};
+
+String STR_TABLE_DISTRIBUTE_COLUMNS
+{
+ Text [ en-US ] = "Distribute columns" ;
+};
+
+String STR_TABLE_STYLE
+{
+ Text [ en-US ] = "Table style" ;
+};
+
+String STR_TABLE_STYLE_SETTINGS
+{
+ Text [ en-US ] = "Table style settings" ;
+};
+
+String STR_ObjNameSingulTable
+{
+ Text [ en-US ] = "Table";
+};
+String STR_ObjNamePluralTable
+{
+ Text [ en-US ] = "Tables";
+};
+
+Bitmap SIP_SA_CROP_MARKERS
+{
+ File = "cropmarkers.bmp";
+};
+
+Bitmap SIP_SA_CROP_FINE_MARKERS
+{
+ File = "cropmarkers2.bmp";
+};
+
+Bitmap SIP_SA_ACCESSIBILITY_CROP_MARKERS
+{
+ File = "cropmarkersACC.bmp";
+};
+
+// ******************************************************************* EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/svdraw/svdtext.cxx b/svx/source/svdraw/svdtext.cxx
new file mode 100644
index 000000000000..1e270a8239ca
--- /dev/null
+++ b/svx/source/svdraw/svdtext.cxx
@@ -0,0 +1,227 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define ITEMID_FONTHEIGHT EE_CHAR_FONTHEIGHT
+
+#include "svx/svdotext.hxx"
+#include "svx/svdetc.hxx"
+#include "editeng/outlobj.hxx"
+#include "svx/svdoutl.hxx"
+#include "svx/svdmodel.hxx"
+#include "editeng/fhgtitem.hxx"
+#include <editeng/eeitem.hxx>
+#include <svl/itemset.hxx>
+
+SdrText::SdrText( SdrTextObj& rObject, OutlinerParaObject* pOutlinerParaObject /* = 0 */ )
+: mpOutlinerParaObject( pOutlinerParaObject )
+, mrObject( rObject )
+, mpModel( rObject.GetModel() )
+, mbPortionInfoChecked( false )
+{
+ OSL_ENSURE(&mrObject, "SdrText created without SdrTextObj (!)");
+}
+
+SdrText::~SdrText()
+{
+ clearWeak();
+ delete mpOutlinerParaObject;
+}
+
+void SdrText::CheckPortionInfo( SdrOutliner& rOutliner )
+{
+ if(!mbPortionInfoChecked)
+ {
+ // #i102062# no action when the Outliner is the HitTestOutliner,
+ // this will remove WrongList info at the OPO
+ if(mpModel && &rOutliner == &mpModel->GetHitTestOutliner())
+ return;
+
+ // Optimierung: ggf. BigTextObject erzeugen
+ mbPortionInfoChecked=true;
+ if(mpOutlinerParaObject!=NULL && rOutliner.ShouldCreateBigTextObject())
+ {
+ // #i102062# MemoryLeak closed
+ delete mpOutlinerParaObject;
+ mpOutlinerParaObject = rOutliner.CreateParaObject();
+ }
+ }
+}
+
+void SdrText::ReformatText()
+{
+ mbPortionInfoChecked=FALSE;
+ mpOutlinerParaObject->ClearPortionInfo();
+}
+
+const SfxItemSet& SdrText::GetItemSet() const
+{
+ return const_cast< SdrText* >(this)->GetObjectItemSet();
+}
+
+void SdrText::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
+{
+ if( mpOutlinerParaObject != pTextObject )
+ {
+ if( mpModel )
+ {
+ // Update HitTestOutliner
+ const SdrTextObj* pTestObj = mpModel->GetHitTestOutliner().GetTextObj();
+ if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject )
+ mpModel->GetHitTestOutliner().SetTextObj( 0 );
+ }
+
+ if( mpOutlinerParaObject )
+ delete mpOutlinerParaObject;
+
+ mpOutlinerParaObject = pTextObject;
+
+ mbPortionInfoChecked = false;
+ }
+}
+
+OutlinerParaObject* SdrText::GetOutlinerParaObject() const
+{
+ return mpOutlinerParaObject;
+}
+
+/** returns the current OutlinerParaObject and removes it from this instance */
+OutlinerParaObject* SdrText::RemoveOutlinerParaObject()
+{
+ if( mpModel )
+ {
+ // Update HitTestOutliner
+ const SdrTextObj* pTestObj = mpModel->GetHitTestOutliner().GetTextObj();
+ if( pTestObj && pTestObj->GetOutlinerParaObject() == mpOutlinerParaObject )
+ mpModel->GetHitTestOutliner().SetTextObj( 0 );
+ }
+
+ OutlinerParaObject* pOPO = mpOutlinerParaObject;
+
+ mpOutlinerParaObject = 0;
+ mbPortionInfoChecked = false;
+
+ return pOPO;
+}
+
+void SdrText::SetModel( SdrModel* pNewModel )
+{
+ if( pNewModel == mpModel )
+ return;
+
+ SdrModel* pOldModel = mpModel;
+ mpModel = pNewModel;
+
+ if( mpOutlinerParaObject && pOldModel!=NULL && pNewModel!=NULL)
+ {
+ bool bHgtSet = GetObjectItemSet().GetItemState(EE_CHAR_FONTHEIGHT, TRUE) == SFX_ITEM_SET;
+
+ MapUnit aOldUnit(pOldModel->GetScaleUnit());
+ MapUnit aNewUnit(pNewModel->GetScaleUnit());
+ bool bScaleUnitChanged=aNewUnit!=aOldUnit;
+ // und nun dem OutlinerParaObject einen neuen Pool verpassen
+ // !!! Hier muss noch DefTab und RefDevice der beiden Models
+ // !!! verglichen werden und dann ggf. AutoGrow zuschlagen !!!
+ // !!! fehlende Implementation !!!
+ ULONG nOldFontHgt=pOldModel->GetDefaultFontHeight();
+ ULONG nNewFontHgt=pNewModel->GetDefaultFontHeight();
+ BOOL bDefHgtChanged=nNewFontHgt!=nOldFontHgt;
+ BOOL bSetHgtItem=bDefHgtChanged && !bHgtSet;
+ if (bSetHgtItem)
+ { // #32665#
+ // zunaechst das HeightItem festklopfen, damit
+ // 1. Es eben bestehen bleibt und
+ // 2. DoStretchChars vom richtigen Wert ausgeht
+ SetObjectItem(SvxFontHeightItem(nOldFontHgt, 100, EE_CHAR_FONTHEIGHT));
+ }
+ // erst jetzt den Outliner holen, etc. damit obiges SetAttr auch wirkt
+ SdrOutliner& rOutliner = mrObject.ImpGetDrawOutliner();
+ rOutliner.SetText(*mpOutlinerParaObject);
+ delete mpOutlinerParaObject;
+ mpOutlinerParaObject=0;
+ if (bScaleUnitChanged)
+ {
+ Fraction aMetricFactor=GetMapFactor(aOldUnit,aNewUnit).X();
+
+ // Funktioniert nicht richtig:
+ // Geht am Outliner leider nur in %
+ // double nPercFloat=double(aMetricFactor)*100+0.5;
+ // USHORT nPerc=(USHORT)nPercFloat;
+ // rOutliner.DoStretchChars(100,nPerc);
+
+ if (bSetHgtItem)
+ {
+ // Und nun noch das Rahmenattribut korregieren
+ nOldFontHgt=BigMulDiv(nOldFontHgt,aMetricFactor.GetNumerator(),aMetricFactor.GetDenominator());
+ SetObjectItem(SvxFontHeightItem(nOldFontHgt, 100, EE_CHAR_FONTHEIGHT));
+ }
+ }
+ SetOutlinerParaObject(rOutliner.CreateParaObject()); // #34494#
+ mpOutlinerParaObject->ClearPortionInfo();
+ mbPortionInfoChecked=FALSE;
+ rOutliner.Clear();
+ }
+}
+
+void SdrText::ForceOutlinerParaObject( USHORT nOutlMode )
+{
+ if( mpModel && !mpOutlinerParaObject )
+ {
+ Outliner* pOutliner = SdrMakeOutliner( nOutlMode, mpModel );
+ if( pOutliner )
+ {
+ Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
+ pOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
+
+ pOutliner->SetStyleSheet( 0, GetStyleSheet());
+ OutlinerParaObject* pOutlinerParaObject = pOutliner->CreateParaObject();
+ SetOutlinerParaObject( pOutlinerParaObject );
+
+ delete pOutliner;
+ }
+ }
+}
+
+const SfxItemSet& SdrText::GetObjectItemSet()
+{
+ return mrObject.GetObjectItemSet();
+}
+
+void SdrText::SetObjectItem(const SfxPoolItem& rItem)
+{
+ mrObject.SetObjectItem( rItem );
+}
+
+SfxStyleSheet* SdrText::GetStyleSheet() const
+{
+ return mrObject.GetStyleSheet();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx
new file mode 100644
index 000000000000..0b9905dc81c7
--- /dev/null
+++ b/svx/source/svdraw/svdtrans.cxx
@@ -0,0 +1,1276 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdtrans.hxx>
+#include <math.h>
+#include <svx/xpoly.hxx>
+
+#include <vcl/virdev.hxx>
+#include <tools/bigint.hxx>
+#include <tools/debug.hxx>
+#include <unotools/syslocale.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void MoveXPoly(XPolygon& rPoly, const Size& S)
+{
+ rPoly.Move(S.Width(),S.Height());
+}
+
+void MoveXPoly(XPolyPolygon& rPoly, const Size& S)
+{
+ rPoly.Move(S.Width(),S.Height());
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ResizeRect(Rectangle& rRect, const Point& rRef, const Fraction& rxFact, const Fraction& ryFact, bool bNoJustify)
+{
+ Fraction xFact(rxFact);
+ Fraction yFact(ryFact);
+ //long nHgt=rRect.Bottom()-rRect.Top();
+
+ {
+ if (xFact.GetDenominator()==0) {
+ long nWdt=rRect.Right()-rRect.Left();
+ if (xFact.GetNumerator()>=0) { // DivZero abfangen
+ xFact=Fraction(xFact.GetNumerator(),1);
+ if (nWdt==0) rRect.Right()++;
+ } else {
+ xFact=Fraction(xFact.GetNumerator(),-1);
+ if (nWdt==0) rRect.Left()--;
+ }
+ }
+ rRect.Left() =rRef.X()+Round(((double)(rRect.Left() -rRef.X())*xFact.GetNumerator())/xFact.GetDenominator());
+ rRect.Right() =rRef.X()+Round(((double)(rRect.Right() -rRef.X())*xFact.GetNumerator())/xFact.GetDenominator());
+ }
+ {
+ if (yFact.GetDenominator()==0) {
+ long nHgt=rRect.Bottom()-rRect.Top();
+ if (yFact.GetNumerator()>=0) { // DivZero abfangen
+ yFact=Fraction(yFact.GetNumerator(),1);
+ if (nHgt==0) rRect.Bottom()++;
+ } else {
+ yFact=Fraction(yFact.GetNumerator(),-1);
+ if (nHgt==0) rRect.Top()--;
+ }
+
+ yFact=Fraction(yFact.GetNumerator(),1); // DivZero abfangen
+ }
+ rRect.Top() =rRef.Y()+Round(((double)(rRect.Top() -rRef.Y())*yFact.GetNumerator())/yFact.GetDenominator());
+ rRect.Bottom()=rRef.Y()+Round(((double)(rRect.Bottom()-rRef.Y())*yFact.GetNumerator())/yFact.GetDenominator());
+ }
+ if (!bNoJustify) rRect.Justify();
+}
+
+
+void ResizePoly(Polygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ USHORT nAnz=rPoly.GetSize();
+ for (USHORT i=0; i<nAnz; i++) {
+ ResizePoint(rPoly[i],rRef,xFact,yFact);
+ }
+}
+
+void ResizeXPoly(XPolygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ USHORT nAnz=rPoly.GetPointCount();
+ for (USHORT i=0; i<nAnz; i++) {
+ ResizePoint(rPoly[i],rRef,xFact,yFact);
+ }
+}
+
+void ResizePoly(PolyPolygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ USHORT nAnz=rPoly.Count();
+ for (USHORT i=0; i<nAnz; i++) {
+ ResizePoly(rPoly[i],rRef,xFact,yFact);
+ }
+}
+
+void ResizeXPoly(XPolyPolygon& rPoly, const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ USHORT nAnz=rPoly.Count();
+ for (USHORT i=0; i<nAnz; i++) {
+ ResizeXPoly(rPoly[i],rRef,xFact,yFact);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void RotatePoly(Polygon& rPoly, const Point& rRef, double sn, double cs)
+{
+ USHORT nAnz=rPoly.GetSize();
+ for (USHORT i=0; i<nAnz; i++) {
+ RotatePoint(rPoly[i],rRef,sn,cs);
+ }
+}
+
+void RotateXPoly(XPolygon& rPoly, const Point& rRef, double sn, double cs)
+{
+ USHORT nAnz=rPoly.GetPointCount();
+ for (USHORT i=0; i<nAnz; i++) {
+ RotatePoint(rPoly[i],rRef,sn,cs);
+ }
+}
+
+void RotatePoly(PolyPolygon& rPoly, const Point& rRef, double sn, double cs)
+{
+ USHORT nAnz=rPoly.Count();
+ for (USHORT i=0; i<nAnz; i++) {
+ RotatePoly(rPoly[i],rRef,sn,cs);
+ }
+}
+
+void RotateXPoly(XPolyPolygon& rPoly, const Point& rRef, double sn, double cs)
+{
+ USHORT nAnz=rPoly.Count();
+ for (USHORT i=0; i<nAnz; i++) {
+ RotateXPoly(rPoly[i],rRef,sn,cs);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void MirrorRect(Rectangle& rRect, const Point& /*rRef1*/, const Point& /*rRef2*/, bool bNoJustify)
+{
+ // !!! fehlende Implementation !!!
+ if (!bNoJustify) rRect.Justify();
+}
+
+void MirrorPoint(Point& rPnt, const Point& rRef1, const Point& rRef2)
+{
+ long mx=rRef2.X()-rRef1.X();
+ long my=rRef2.Y()-rRef1.Y();
+ if (mx==0) { // Achse senkrecht
+ long dx=rRef1.X()-rPnt.X();
+ rPnt.X()+=2*dx;
+ } else if (my==0) { // Achse waagerecht
+ long dy=rRef1.Y()-rPnt.Y();
+ rPnt.Y()+=2*dy;
+ } else if (mx==my) { // Achse diagonal '\'
+ long dx1=rPnt.X()-rRef1.X();
+ long dy1=rPnt.Y()-rRef1.Y();
+ rPnt.X()=rRef1.X()+dy1;
+ rPnt.Y()=rRef1.Y()+dx1;
+ } else if (mx==-my) { // Achse diagonal '/'
+ long dx1=rPnt.X()-rRef1.X();
+ long dy1=rPnt.Y()-rRef1.Y();
+ rPnt.X()=rRef1.X()-dy1;
+ rPnt.Y()=rRef1.Y()-dx1;
+ } else { // beliebige Achse
+ // mal optimieren !!!
+ // Lot auf der Spiegelachse faellen oder so
+ long nRefWink=GetAngle(rRef2-rRef1);
+ rPnt-=rRef1;
+ long nPntWink=GetAngle(rPnt);
+ long nWink=2*(nRefWink-nPntWink);
+ double a=nWink*nPi180;
+ double nSin=sin(a);
+ double nCos=cos(a);
+ RotatePoint(rPnt,Point(),nSin,nCos);
+ rPnt+=rRef1;
+ }
+}
+
+void MirrorPoly(Polygon& rPoly, const Point& rRef1, const Point& rRef2)
+{
+ USHORT nAnz=rPoly.GetSize();
+ for (USHORT i=0; i<nAnz; i++) {
+ MirrorPoint(rPoly[i],rRef1,rRef2);
+ }
+}
+
+void MirrorXPoly(XPolygon& rPoly, const Point& rRef1, const Point& rRef2)
+{
+ USHORT nAnz=rPoly.GetPointCount();
+ for (USHORT i=0; i<nAnz; i++) {
+ MirrorPoint(rPoly[i],rRef1,rRef2);
+ }
+}
+
+void MirrorPoly(PolyPolygon& rPoly, const Point& rRef1, const Point& rRef2)
+{
+ USHORT nAnz=rPoly.Count();
+ for (USHORT i=0; i<nAnz; i++) {
+ MirrorPoly(rPoly[i],rRef1,rRef2);
+ }
+}
+
+void MirrorXPoly(XPolyPolygon& rPoly, const Point& rRef1, const Point& rRef2)
+{
+ USHORT nAnz=rPoly.Count();
+ for (USHORT i=0; i<nAnz; i++) {
+ MirrorXPoly(rPoly[i],rRef1,rRef2);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void ShearPoly(Polygon& rPoly, const Point& rRef, double tn, bool bVShear)
+{
+ USHORT nAnz=rPoly.GetSize();
+ for (USHORT i=0; i<nAnz; i++) {
+ ShearPoint(rPoly[i],rRef,tn,bVShear);
+ }
+}
+
+void ShearXPoly(XPolygon& rPoly, const Point& rRef, double tn, bool bVShear)
+{
+ USHORT nAnz=rPoly.GetPointCount();
+ for (USHORT i=0; i<nAnz; i++) {
+ ShearPoint(rPoly[i],rRef,tn,bVShear);
+ }
+}
+
+void ShearPoly(PolyPolygon& rPoly, const Point& rRef, double tn, bool bVShear)
+{
+ USHORT nAnz=rPoly.Count();
+ for (USHORT i=0; i<nAnz; i++) {
+ ShearPoly(rPoly[i],rRef,tn,bVShear);
+ }
+}
+
+void ShearXPoly(XPolyPolygon& rPoly, const Point& rRef, double tn, bool bVShear)
+{
+ USHORT nAnz=rPoly.Count();
+ for (USHORT i=0; i<nAnz; i++) {
+ ShearXPoly(rPoly[i],rRef,tn,bVShear);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@ @@@@@ @@@@ @@@@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@@@@ @@ @@ @@ @@ @@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@ @@ @@ @@@@ @@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+double CrookRotateXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCenter,
+ const Point& rRad, double& rSin, double& rCos, bool bVert)
+{
+ bool bC1=pC1!=NULL;
+ bool bC2=pC2!=NULL;
+ long x0=rPnt.X();
+ long y0=rPnt.Y();
+ long cx=rCenter.X();
+ long cy=rCenter.Y();
+ double nWink=GetCrookAngle(rPnt,rCenter,rRad,bVert);
+ double sn=sin(nWink);
+ double cs=cos(nWink);
+ RotatePoint(rPnt,rCenter,sn,cs);
+ if (bC1) {
+ if (bVert) {
+ // Richtung Zentrum verschieben, als Ausgangsposition fuer Rotate
+ pC1->Y()-=y0;
+ // Resize, entsprechend der Entfernung vom Zentrum
+ pC1->Y()=Round(((double)pC1->Y()) /rRad.X()*(cx-pC1->X()));
+ pC1->Y()+=cy;
+ } else {
+ // Richtung Zentrum verschieben, als Ausgangsposition fuer Rotate
+ pC1->X()-=x0;
+ // Resize, entsprechend der Entfernung vom Zentrum
+ long nPntRad=cy-pC1->Y();
+ double nFact=(double)nPntRad/(double)rRad.Y();
+ pC1->X()=Round((double)pC1->X()*nFact);
+ pC1->X()+=cx;
+ }
+ RotatePoint(*pC1,rCenter,sn,cs);
+ }
+ if (bC2) {
+ if (bVert) {
+ // Richtung Zentrum verschieben, als Ausgangsposition fuer Rotate
+ pC2->Y()-=y0;
+ // Resize, entsprechend der Entfernung vom Zentrum
+ pC2->Y()=Round(((double)pC2->Y()) /rRad.X()*(rCenter.X()-pC2->X()));
+ pC2->Y()+=cy;
+ } else {
+ // Richtung Zentrum verschieben, als Ausgangsposition fuer Rotate
+ pC2->X()-=x0;
+ // Resize, entsprechend der Entfernung vom Zentrum
+ long nPntRad=rCenter.Y()-pC2->Y();
+ double nFact=(double)nPntRad/(double)rRad.Y();
+ pC2->X()=Round((double)pC2->X()*nFact);
+ pC2->X()+=cx;
+ }
+ RotatePoint(*pC2,rCenter,sn,cs);
+ }
+ rSin=sn;
+ rCos=cs;
+ return nWink;
+}
+
+double CrookSlantXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCenter,
+ const Point& rRad, double& rSin, double& rCos, bool bVert)
+{
+ bool bC1=pC1!=NULL;
+ bool bC2=pC2!=NULL;
+ long x0=rPnt.X();
+ long y0=rPnt.Y();
+ long dx1=0,dy1=0;
+ long dxC1=0,dyC1=0;
+ long dxC2=0,dyC2=0;
+ if (bVert) {
+ long nStart=rCenter.X()-rRad.X();
+ dx1=rPnt.X()-nStart;
+ rPnt.X()=nStart;
+ if (bC1) {
+ dxC1=pC1->X()-nStart;
+ pC1->X()=nStart;
+ }
+ if (bC2) {
+ dxC2=pC2->X()-nStart;
+ pC2->X()=nStart;
+ }
+ } else {
+ long nStart=rCenter.Y()-rRad.Y();
+ dy1=rPnt.Y()-nStart;
+ rPnt.Y()=nStart;
+ if (bC1) {
+ dyC1=pC1->Y()-nStart;
+ pC1->Y()=nStart;
+ }
+ if (bC2) {
+ dyC2=pC2->Y()-nStart;
+ pC2->Y()=nStart;
+ }
+ }
+ double nWink=GetCrookAngle(rPnt,rCenter,rRad,bVert);
+ double sn=sin(nWink);
+ double cs=cos(nWink);
+ RotatePoint(rPnt,rCenter,sn,cs);
+ if (bC1) { if (bVert) pC1->Y()-=y0-rCenter.Y(); else pC1->X()-=x0-rCenter.X(); RotatePoint(*pC1,rCenter,sn,cs); }
+ if (bC2) { if (bVert) pC2->Y()-=y0-rCenter.Y(); else pC2->X()-=x0-rCenter.X(); RotatePoint(*pC2,rCenter,sn,cs); }
+ if (bVert) {
+ rPnt.X()+=dx1;
+ if (bC1) pC1->X()+=dxC1;
+ if (bC2) pC2->X()+=dxC2;
+ } else {
+ rPnt.Y()+=dy1;
+ if (bC1) pC1->Y()+=dyC1;
+ if (bC2) pC2->Y()+=dyC2;
+ }
+ rSin=sn;
+ rCos=cs;
+ return nWink;
+}
+
+double CrookStretchXPoint(Point& rPnt, Point* pC1, Point* pC2, const Point& rCenter,
+ const Point& rRad, double& rSin, double& rCos, bool bVert,
+ const Rectangle rRefRect)
+{
+ //bool bC1=pC1!=NULL;
+ //bool bC2=pC2!=NULL;
+ //long x0=rPnt.X();
+ long y0=rPnt.Y();
+ CrookSlantXPoint(rPnt,pC1,pC2,rCenter,rRad,rSin,rCos,bVert);
+ if (bVert) {
+ } else {
+ //long nBase=rCenter.Y()-rRad.Y();
+ long nTop=rRefRect.Top();
+ long nBtm=rRefRect.Bottom();
+ long nHgt=nBtm-nTop;
+ long dy=rPnt.Y()-y0;
+ //bool bOben=rRad.Y()<0;
+ double a=((double)(y0-nTop))/nHgt;
+ a*=dy;
+ rPnt.Y()=y0+Round(a);
+ } return 0.0;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void CrookRotatePoly(XPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert)
+{
+ double nSin,nCos;
+ USHORT nPointAnz=rPoly.GetPointCount();
+ USHORT i=0;
+ while (i<nPointAnz) {
+ Point* pPnt=&rPoly[i];
+ Point* pC1=NULL;
+ Point* pC2=NULL;
+ if (i+1<nPointAnz && rPoly.IsControl(i)) { // Kontrollpunkt links
+ pC1=pPnt;
+ i++;
+ pPnt=&rPoly[i];
+ }
+ i++;
+ if (i<nPointAnz && rPoly.IsControl(i)) { // Kontrollpunkt rechts
+ pC2=&rPoly[i];
+ i++;
+ }
+ CrookRotateXPoint(*pPnt,pC1,pC2,rCenter,rRad,nSin,nCos,bVert);
+ }
+}
+
+void CrookSlantPoly(XPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert)
+{
+ double nSin,nCos;
+ USHORT nPointAnz=rPoly.GetPointCount();
+ USHORT i=0;
+ while (i<nPointAnz) {
+ Point* pPnt=&rPoly[i];
+ Point* pC1=NULL;
+ Point* pC2=NULL;
+ if (i+1<nPointAnz && rPoly.IsControl(i)) { // Kontrollpunkt links
+ pC1=pPnt;
+ i++;
+ pPnt=&rPoly[i];
+ }
+ i++;
+ if (i<nPointAnz && rPoly.IsControl(i)) { // Kontrollpunkt rechts
+ pC2=&rPoly[i];
+ i++;
+ }
+ CrookSlantXPoint(*pPnt,pC1,pC2,rCenter,rRad,nSin,nCos,bVert);
+ }
+}
+
+void CrookStretchPoly(XPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert, const Rectangle rRefRect)
+{
+ double nSin,nCos;
+ USHORT nPointAnz=rPoly.GetPointCount();
+ USHORT i=0;
+ while (i<nPointAnz) {
+ Point* pPnt=&rPoly[i];
+ Point* pC1=NULL;
+ Point* pC2=NULL;
+ if (i+1<nPointAnz && rPoly.IsControl(i)) { // Kontrollpunkt links
+ pC1=pPnt;
+ i++;
+ pPnt=&rPoly[i];
+ }
+ i++;
+ if (i<nPointAnz && rPoly.IsControl(i)) { // Kontrollpunkt rechts
+ pC2=&rPoly[i];
+ i++;
+ }
+ CrookStretchXPoint(*pPnt,pC1,pC2,rCenter,rRad,nSin,nCos,bVert,rRefRect);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void CrookRotatePoly(XPolyPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert)
+{
+ USHORT nPolyAnz=rPoly.Count();
+ for (USHORT nPolyNum=0; nPolyNum<nPolyAnz; nPolyNum++) {
+ CrookRotatePoly(rPoly[nPolyNum],rCenter,rRad,bVert);
+ }
+}
+
+void CrookSlantPoly(XPolyPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert)
+{
+ USHORT nPolyAnz=rPoly.Count();
+ for (USHORT nPolyNum=0; nPolyNum<nPolyAnz; nPolyNum++) {
+ CrookSlantPoly(rPoly[nPolyNum],rCenter,rRad,bVert);
+ }
+}
+
+void CrookStretchPoly(XPolyPolygon& rPoly, const Point& rCenter, const Point& rRad, bool bVert, const Rectangle rRefRect)
+{
+ USHORT nPolyAnz=rPoly.Count();
+ for (USHORT nPolyNum=0; nPolyNum<nPolyAnz; nPolyNum++) {
+ CrookStretchPoly(rPoly[nPolyNum],rCenter,rRad,bVert,rRefRect);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+long GetAngle(const Point& rPnt)
+{
+ long a=0;
+ if (rPnt.Y()==0) {
+ if (rPnt.X()<0) a=-18000;
+ } else if (rPnt.X()==0) {
+ if (rPnt.Y()>0) a=-9000;
+ else a=9000;
+ } else {
+ a=Round((atan2((double)-rPnt.Y(),(double)rPnt.X())/nPi180));
+ }
+ return a;
+}
+
+long NormAngle180(long a)
+{
+ while (a<18000) a+=36000;
+ while (a>=18000) a-=36000;
+ return a;
+}
+
+long NormAngle360(long a)
+{
+ while (a<0) a+=36000;
+ while (a>=36000) a-=36000;
+ return a;
+}
+
+USHORT GetAngleSector(long nWink)
+{
+ while (nWink<0) nWink+=36000;
+ while (nWink>=36000) nWink-=36000;
+ if (nWink< 9000) return 0;
+ if (nWink<18000) return 1;
+ if (nWink<27000) return 2;
+ return 3;
+}
+
+long GetLen(const Point& rPnt)
+{
+ long x=Abs(rPnt.X());
+ long y=Abs(rPnt.Y());
+ if (x+y<0x8000) { // weil 7FFF * 7FFF * 2 = 7FFE0002
+ x*=x;
+ y*=y;
+ x+=y;
+ x=Round(sqrt((double)x));
+ return x;
+ } else {
+ double nx=x;
+ double ny=y;
+ nx*=nx;
+ ny*=ny;
+ nx+=ny;
+ nx=sqrt(nx);
+ if (nx>0x7FFFFFFF) {
+ return 0x7FFFFFFF; // Ueberlauf, mehr is nich!
+ } else {
+ return Round(nx);
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void GeoStat::RecalcSinCos()
+{
+ if (nDrehWink==0) {
+ nSin=0.0;
+ nCos=1.0;
+ } else {
+ double a=nDrehWink*nPi180;
+ nSin=sin(a);
+ nCos=cos(a);
+ }
+}
+
+void GeoStat::RecalcTan()
+{
+ if (nShearWink==0) {
+ nTan=0.0;
+ } else {
+ double a=nShearWink*nPi180;
+ nTan=tan(a);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Polygon Rect2Poly(const Rectangle& rRect, const GeoStat& rGeo)
+{
+ Polygon aPol(5);
+ aPol[0]=rRect.TopLeft();
+ aPol[1]=rRect.TopRight();
+ aPol[2]=rRect.BottomRight();
+ aPol[3]=rRect.BottomLeft();
+ aPol[4]=rRect.TopLeft();
+ if (rGeo.nShearWink!=0) ShearPoly(aPol,rRect.TopLeft(),rGeo.nTan);
+ if (rGeo.nDrehWink!=0) RotatePoly(aPol,rRect.TopLeft(),rGeo.nSin,rGeo.nCos);
+ return aPol;
+}
+
+void Poly2Rect(const Polygon& rPol, Rectangle& rRect, GeoStat& rGeo)
+{
+ rGeo.nDrehWink=GetAngle(rPol[1]-rPol[0]);
+ rGeo.nDrehWink=NormAngle360(rGeo.nDrehWink);
+ // Drehung ist damit im Kasten
+ rGeo.RecalcSinCos();
+
+ Point aPt1(rPol[1]-rPol[0]);
+ if (rGeo.nDrehWink!=0) RotatePoint(aPt1,Point(0,0),-rGeo.nSin,rGeo.nCos); // -Sin fuer Rueckdrehung
+ long nWdt=aPt1.X();
+
+ Point aPt0(rPol[0]);
+ Point aPt3(rPol[3]-rPol[0]);
+ if (rGeo.nDrehWink!=0) RotatePoint(aPt3,Point(0,0),-rGeo.nSin,rGeo.nCos); // -Sin fuer Rueckdrehung
+ long nHgt=aPt3.Y();
+
+ if(aPt3.X())
+ {
+ // #i74358# the axes are not orthogonal, so for getting the correct height,
+ // calculate the length of aPt3
+
+ // #i74358# this change was wrong, in the field of the old geometry stuff
+ // it is not an error. The new height always is the same as before; shear
+ // does not change object height at all. This is different from the interactions,
+ // but obviously wanted in the old versions.
+ //
+ // nHgt = static_cast< long >(sqrt(static_cast< double >(aPt3.X() * aPt3.X() + aPt3.Y() * aPt3.Y())));
+ }
+
+ long nShW=GetAngle(aPt3);
+ nShW-=27000; // ShearWink wird zur Senkrechten gemessen
+ nShW=-nShW; // Negieren, denn '+' ist Rechtskursivierung
+
+ bool bMirr=aPt3.Y()<0;
+ if (bMirr) { // "Punktetausch" bei Spiegelung
+ nHgt=-nHgt;
+ nShW+=18000;
+ aPt0=rPol[3];
+ }
+ nShW=NormAngle180(nShW);
+ if (nShW<-9000 || nShW>9000) {
+ nShW=NormAngle180(nShW+18000);
+ }
+ if (nShW<-SDRMAXSHEAR) nShW=-SDRMAXSHEAR; // ShearWinkel begrenzen auf +/- 89.00 deg
+ if (nShW>SDRMAXSHEAR) nShW=SDRMAXSHEAR;
+ rGeo.nShearWink=nShW;
+ rGeo.RecalcTan();
+ Point aRU(aPt0);
+ aRU.X()+=nWdt;
+ aRU.Y()+=nHgt;
+ rRect=Rectangle(aPt0,aRU);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void OrthoDistance8(const Point& rPt0, Point& rPt, bool bBigOrtho)
+{
+ long dx=rPt.X()-rPt0.X();
+ long dy=rPt.Y()-rPt0.Y();
+ long dxa=Abs(dx);
+ long dya=Abs(dy);
+ if (dx==0 || dy==0 || dxa==dya) return;
+ if (dxa>=dya*2) { rPt.Y()=rPt0.Y(); return; }
+ if (dya>=dxa*2) { rPt.X()=rPt0.X(); return; }
+ if ((dxa<dya) != bBigOrtho) {
+ rPt.Y()=rPt0.Y()+(dxa* (dy>=0 ? 1 : -1) );
+ } else {
+ rPt.X()=rPt0.X()+(dya* (dx>=0 ? 1 : -1) );
+ }
+}
+
+void OrthoDistance4(const Point& rPt0, Point& rPt, bool bBigOrtho)
+{
+ long dx=rPt.X()-rPt0.X();
+ long dy=rPt.Y()-rPt0.Y();
+ long dxa=Abs(dx);
+ long dya=Abs(dy);
+ if ((dxa<dya) != bBigOrtho) {
+ rPt.Y()=rPt0.Y()+(dxa* (dy>=0 ? 1 : -1) );
+ } else {
+ rPt.X()=rPt0.X()+(dya* (dx>=0 ? 1 : -1) );
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+long BigMulDiv(long nVal, long nMul, long nDiv)
+{
+ BigInt aVal(nVal);
+ aVal*=nMul;
+ if (aVal.IsNeg()!=(nDiv<0)) {
+ aVal-=nDiv/2; // fuer korrektes Runden
+ } else {
+ aVal+=nDiv/2; // fuer korrektes Runden
+ }
+ if(nDiv)
+ {
+ aVal/=nDiv;
+ return long(aVal);
+ }
+ return 0x7fffffff;
+}
+
+void Kuerzen(Fraction& rF, unsigned nDigits)
+{
+ INT32 nMul=rF.GetNumerator();
+ INT32 nDiv=rF.GetDenominator();
+ bool bNeg = false;
+ if (nMul<0) { nMul=-nMul; bNeg=!bNeg; }
+ if (nDiv<0) { nDiv=-nDiv; bNeg=!bNeg; }
+ if (nMul==0 || nDiv==0) return;
+ UINT32 a;
+ a=UINT32(nMul); unsigned nMulZ=0; // Fuehrende Nullen zaehlen
+ while (a<0x00800000) { nMulZ+=8; a<<=8; }
+ while (a<0x80000000) { nMulZ++; a<<=1; }
+ a=UINT32(nDiv); unsigned nDivZ=0; // Fuehrende Nullen zaehlen
+ while (a<0x00800000) { nDivZ+=8; a<<=8; }
+ while (a<0x80000000) { nDivZ++; a<<=1; }
+ // Anzahl der verwendeten Digits bestimmen
+ int nMulDigits=32-nMulZ;
+ int nDivDigits=32-nDivZ;
+ // Nun bestimmen, wieviele Stellen hinten weg koennen
+ int nMulWeg=nMulDigits-nDigits; if (nMulWeg<0) nMulWeg=0;
+ int nDivWeg=nDivDigits-nDigits; if (nDivWeg<0) nDivWeg=0;
+ int nWeg=Min(nMulWeg,nDivWeg);
+ nMul>>=nWeg;
+ nDiv>>=nWeg;
+ if (nMul==0 || nDiv==0) {
+ DBG_WARNING("Oups, beim kuerzen einer Fraction hat sich Joe verrechnet.");
+ return;
+ }
+ if (bNeg) nMul=-nMul;
+ rF=Fraction(nMul,nDiv);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Wieviele eU-Einheiten passen in einen mm bzw. Inch?
+// Oder wie gross ist ein eU in mm bzw. Inch, und davon der Kehrwert
+
+FrPair GetInchOrMM(MapUnit eU)
+{
+ switch (eU) {
+ case MAP_1000TH_INCH: return FrPair(1000,1);
+ case MAP_100TH_INCH : return FrPair( 100,1);
+ case MAP_10TH_INCH : return FrPair( 10,1);
+ case MAP_INCH : return FrPair( 1,1);
+ case MAP_POINT : return FrPair( 72,1);
+ case MAP_TWIP : return FrPair(1440,1);
+ case MAP_100TH_MM : return FrPair( 100,1);
+ case MAP_10TH_MM : return FrPair( 10,1);
+ case MAP_MM : return FrPair( 1,1);
+ case MAP_CM : return FrPair( 1,10);
+ case MAP_PIXEL : {
+ VirtualDevice aVD;
+ aVD.SetMapMode(MapMode(MAP_100TH_MM));
+ Point aP(aVD.PixelToLogic(Point(64,64))); // 64 Pixel fuer bessere Genauigkeit
+ return FrPair(6400,aP.X(),6400,aP.Y());
+ }
+ case MAP_APPFONT: case MAP_SYSFONT: {
+ VirtualDevice aVD;
+ aVD.SetMapMode(MapMode(eU));
+ Point aP(aVD.LogicToPixel(Point(32,32))); // 32 Einheiten fuer bessere Genauigkeit
+ aVD.SetMapMode(MapMode(MAP_100TH_MM));
+ aP=aVD.PixelToLogic(aP);
+ return FrPair(3200,aP.X(),3200,aP.Y());
+ }
+ default: break;
+ }
+ return Fraction(1,1);
+}
+
+FrPair GetInchOrMM(FieldUnit eU)
+{
+ switch (eU) {
+ case FUNIT_INCH : return FrPair( 1,1);
+ case FUNIT_POINT : return FrPair( 72,1);
+ case FUNIT_TWIP : return FrPair(1440,1);
+ case FUNIT_100TH_MM : return FrPair( 100,1);
+ case FUNIT_MM : return FrPair( 1,1);
+ case FUNIT_CM : return FrPair( 1,10);
+ case FUNIT_M : return FrPair( 1,1000);
+ case FUNIT_KM : return FrPair( 1,1000000);
+ case FUNIT_PICA : return FrPair( 6,1);
+ case FUNIT_FOOT : return FrPair( 1,12);
+ case FUNIT_MILE : return FrPair( 1,63360);
+ default: break;
+ }
+ return Fraction(1,1);
+}
+
+// Den Faktor berechnen, der anzuwenden ist um n Einheiten von eS nach
+// eD umzurechnen. Z.B. GetMapFactor(UNIT_MM,UNIT_100TH_MM) => 100.
+
+FrPair GetMapFactor(MapUnit eS, MapUnit eD)
+{
+ if (eS==eD) return FrPair(1,1,1,1);
+ FrPair aS(GetInchOrMM(eS));
+ FrPair aD(GetInchOrMM(eD));
+ bool bSInch=IsInch(eS);
+ bool bDInch=IsInch(eD);
+ FrPair aRet(aD.X()/aS.X(),aD.Y()/aS.Y());
+ if (bSInch && !bDInch) { aRet.X()*=Fraction(127,5); aRet.Y()*=Fraction(127,5); }
+ if (!bSInch && bDInch) { aRet.X()*=Fraction(5,127); aRet.Y()*=Fraction(5,127); }
+ return aRet;
+};
+
+FrPair GetMapFactor(MapUnit eS, FieldUnit eD)
+{
+ FrPair aS(GetInchOrMM(eS));
+ FrPair aD(GetInchOrMM(eD));
+ bool bSInch=IsInch(eS);
+ bool bDInch=IsInch(eD);
+ FrPair aRet(aD.X()/aS.X(),aD.Y()/aS.Y());
+ if (bSInch && !bDInch) { aRet.X()*=Fraction(127,5); aRet.Y()*=Fraction(127,5); }
+ if (!bSInch && bDInch) { aRet.X()*=Fraction(5,127); aRet.Y()*=Fraction(5,127); }
+ return aRet;
+};
+
+FrPair GetMapFactor(FieldUnit eS, MapUnit eD)
+{
+ FrPair aS(GetInchOrMM(eS));
+ FrPair aD(GetInchOrMM(eD));
+ bool bSInch=IsInch(eS);
+ bool bDInch=IsInch(eD);
+ FrPair aRet(aD.X()/aS.X(),aD.Y()/aS.Y());
+ if (bSInch && !bDInch) { aRet.X()*=Fraction(127,5); aRet.Y()*=Fraction(127,5); }
+ if (!bSInch && bDInch) { aRet.X()*=Fraction(5,127); aRet.Y()*=Fraction(5,127); }
+ return aRet;
+};
+
+FrPair GetMapFactor(FieldUnit eS, FieldUnit eD)
+{
+ if (eS==eD) return FrPair(1,1,1,1);
+ FrPair aS(GetInchOrMM(eS));
+ FrPair aD(GetInchOrMM(eD));
+ bool bSInch=IsInch(eS);
+ bool bDInch=IsInch(eD);
+ FrPair aRet(aD.X()/aS.X(),aD.Y()/aS.Y());
+ if (bSInch && !bDInch) { aRet.X()*=Fraction(127,5); aRet.Y()*=Fraction(127,5); }
+ if (!bSInch && bDInch) { aRet.X()*=Fraction(5,127); aRet.Y()*=Fraction(5,127); }
+ return aRet;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ // 1 mile = 8 furlong = 63.360" = 1.609.344,0mm
+ // 1 furlong = 10 chains = 7.920" = 201.168,0mm
+ // 1 chain = 4 poles = 792" = 20.116,8mm
+ // 1 pole = 5 1/2 yd = 198" = 5.029,2mm
+ // 1 yd = 3 ft = 36" = 914,4mm
+ // 1 ft = 12 " = 1" = 304,8mm
+
+void GetMeterOrInch(MapUnit eMU, short& rnKomma, long& rnMul, long& rnDiv, bool& rbMetr, bool& rbInch)
+{
+ rnMul=1; rnDiv=1;
+ short nKomma=0;
+ bool bMetr = false, bInch = false;
+ switch (eMU) {
+ // Metrisch
+ case MAP_100TH_MM : bMetr = true; nKomma=5; break;
+ case MAP_10TH_MM : bMetr = true; nKomma=4; break;
+ case MAP_MM : bMetr = true; nKomma=3; break;
+ case MAP_CM : bMetr = true; nKomma=2; break;
+ // Inch
+ case MAP_1000TH_INCH: bInch = true; nKomma=3; break;
+ case MAP_100TH_INCH : bInch = true; nKomma=2; break;
+ case MAP_10TH_INCH : bInch = true; nKomma=1; break;
+ case MAP_INCH : bInch = true; nKomma=0; break;
+ case MAP_POINT : bInch = true; rnDiv=72; break; // 1Pt = 1/72"
+ case MAP_TWIP : bInch = true; rnDiv=144; nKomma=1; break; // 1Twip = 1/1440"
+ // Sonstiges
+ case MAP_PIXEL : break;
+ case MAP_SYSFONT : break;
+ case MAP_APPFONT : break;
+ case MAP_RELATIVE : break;
+ default: break;
+ } // switch
+ rnKomma=nKomma;
+ rbMetr=bMetr;
+ rbInch=bInch;
+}
+
+void GetMeterOrInch(FieldUnit eFU, short& rnKomma, long& rnMul, long& rnDiv, bool& rbMetr, bool& rbInch)
+{
+ rnMul=1; rnDiv=1;
+ short nKomma=0;
+ bool bMetr = false, bInch = false;
+ switch (eFU) {
+ case FUNIT_NONE : break;
+ // Metrisch
+ case FUNIT_100TH_MM : bMetr = true; nKomma=5; break;
+ case FUNIT_MM : bMetr = true; nKomma=3; break;
+ case FUNIT_CM : bMetr = true; nKomma=2; break;
+ case FUNIT_M : bMetr = true; nKomma=0; break;
+ case FUNIT_KM : bMetr = true; nKomma=-3; break;
+ // Inch
+ case FUNIT_TWIP : bInch = true; rnDiv=144; nKomma=1; break; // 1Twip = 1/1440"
+ case FUNIT_POINT : bInch = true; rnDiv=72; break; // 1Pt = 1/72"
+ case FUNIT_PICA : bInch = true; rnDiv=6; break; // 1Pica = 1/6" ?
+ case FUNIT_INCH : bInch = true; break; // 1" = 1"
+ case FUNIT_FOOT : bInch = true; rnMul=12; break; // 1Ft = 12"
+ case FUNIT_MILE : bInch = true; rnMul=6336; nKomma=-1; break; // 1mile = 63360"
+ // sonstiges
+ case FUNIT_CUSTOM : break;
+ case FUNIT_PERCENT : nKomma=2; break;
+ // TODO: Add code to handle the following (added to remove warning)
+ case FUNIT_CHAR : break;
+ case FUNIT_LINE : break;
+ } // switch
+ rnKomma=nKomma;
+ rbMetr=bMetr;
+ rbInch=bInch;
+}
+
+void SdrFormatter::Undirty()
+{
+ if (aScale.GetNumerator()==0 || aScale.GetDenominator()==0) aScale=Fraction(1,1);
+ bool bSrcMetr,bSrcInch,bDstMetr,bDstInch;
+ long nMul1,nDiv1,nMul2,nDiv2;
+ short nKomma1,nKomma2;
+ // Zunaechst normalisieren auf m bzw. "
+ if (!bSrcFU) {
+ GetMeterOrInch(eSrcMU,nKomma1,nMul1,nDiv1,bSrcMetr,bSrcInch);
+ } else {
+ GetMeterOrInch(eSrcFU,nKomma1,nMul1,nDiv1,bSrcMetr,bSrcInch);
+ }
+ if (!bDstFU) {
+ GetMeterOrInch(eDstMU,nKomma2,nMul2,nDiv2,bDstMetr,bDstInch);
+ } else {
+ GetMeterOrInch(eDstFU,nKomma2,nMul2,nDiv2,bDstMetr,bDstInch);
+ }
+ nMul1*=nDiv2;
+ nDiv1*=nMul2;
+ nKomma1=nKomma1-nKomma2;
+
+ if (bSrcInch && bDstMetr) {
+ nKomma1+=4;
+ nMul1*=254;
+ }
+ if (bSrcMetr && bDstInch) {
+ nKomma1-=4;
+ nDiv1*=254;
+ }
+
+ // Temporaere Fraction zum Kuerzen
+ Fraction aTempFract(nMul1,nDiv1);
+ nMul1=aTempFract.GetNumerator();
+ nDiv1=aTempFract.GetDenominator();
+
+ nMul_=nMul1;
+ nDiv_=nDiv1;
+ nKomma_=nKomma1;
+ bDirty=FALSE;
+}
+
+
+void SdrFormatter::TakeStr(long nVal, XubString& rStr) const
+{
+ sal_Unicode aNullCode('0');
+
+ if(!nVal)
+ {
+ rStr = UniString();
+ rStr += aNullCode;
+ return;
+ }
+
+ // Hier fallen trotzdem evtl. Nachkommastellen weg, wg. MulDiv statt Real
+ BOOL bNeg(nVal < 0);
+ SvtSysLocale aSysLoc;
+ const LocaleDataWrapper& rLoc = aSysLoc.GetLocaleData();
+
+ ForceUndirty();
+
+ sal_Int16 nK(nKomma_);
+ XubString aStr;
+
+ if(bNeg)
+ nVal = -nVal;
+
+ while(nK <= -3)
+ {
+ nVal *= 1000;
+ nK += 3;
+ }
+
+ while(nK <= -1)
+ {
+ nVal *= 10;
+ nK++;
+ }
+
+ if(nMul_ != nDiv_)
+ nVal = BigMulDiv(nVal, nMul_, nDiv_);
+
+ aStr = UniString::CreateFromInt32(nVal);
+
+ if(nK > 0 && aStr.Len() <= nK )
+ {
+ // Komma erforderlich
+ sal_Int16 nAnz(nK - aStr.Len());
+
+ if(nAnz >= 0 && rLoc.isNumLeadingZero())
+ nAnz++;
+
+ for(xub_StrLen i=0; i<nAnz; i++)
+ aStr.Insert(aNullCode, 0);
+
+ // zuviele Nachkommastellen abhacken
+ xub_StrLen nNumDigits(rLoc.getNumDigits());
+ xub_StrLen nWeg(nK - nNumDigits);
+
+ if(nWeg > 0)
+ {
+ // hier muesste eigentlich noch gerundet werden!
+ aStr.Erase(aStr.Len() - nWeg);
+ nK = nNumDigits;
+ }
+ }
+
+ // Vorkommastellen fuer spaeter merken
+ xub_StrLen nVorKomma(aStr.Len() - nK);
+
+ if(nK > 0)
+ {
+ // KommaChar einfuegen
+ // erstmal trailing Zeros abhacken
+ while(nK > 0 && aStr.GetChar(aStr.Len() - 1) == aNullCode)
+ {
+ aStr.Erase(aStr.Len() - 1);
+ nK--;
+ }
+
+ if(nK > 0)
+ {
+ // na, noch Nachkommastellen da?
+ sal_Unicode cDec(rLoc.getNumDecimalSep().GetChar(0));
+ aStr.Insert(cDec, nVorKomma);
+ }
+ }
+
+ // ggf. Trennpunkte bei jedem Tausender einfuegen
+ if( nVorKomma > 3 )
+ {
+ String aThoSep( rLoc.getNumThousandSep() );
+ if ( aThoSep.Len() > 0 )
+ {
+ sal_Unicode cTho( aThoSep.GetChar(0) );
+ sal_Int32 i(nVorKomma - 3);
+
+ while(i > 0)
+ {
+ rStr.Insert(cTho, (xub_StrLen)i);
+ i -= 3;
+ }
+ }
+ }
+
+ if(!aStr.Len())
+ aStr += aNullCode;
+
+ if(bNeg && (aStr.Len() > 1 || aStr.GetChar(0) != aNullCode))
+ {
+ rStr.Insert(sal_Unicode('-'), 0);
+ }
+
+ rStr = aStr;
+}
+
+void SdrFormatter::TakeUnitStr(MapUnit eUnit, XubString& rStr)
+{
+ switch(eUnit)
+ {
+ // Metrisch
+ case MAP_100TH_MM :
+ {
+ sal_Char aText[] = "/100mm";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case MAP_10TH_MM :
+ {
+ sal_Char aText[] = "/10mm";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case MAP_MM :
+ {
+ sal_Char aText[] = "mm";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case MAP_CM :
+ {
+ sal_Char aText[] = "cm";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+
+ // Inch
+ case MAP_1000TH_INCH:
+ {
+ sal_Char aText[] = "/1000\"";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case MAP_100TH_INCH :
+ {
+ sal_Char aText[] = "/100\"";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case MAP_10TH_INCH :
+ {
+ sal_Char aText[] = "/10\"";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case MAP_INCH :
+ {
+ rStr = UniString();
+ rStr += sal_Unicode('"');
+ break;
+ }
+ case MAP_POINT :
+ {
+ sal_Char aText[] = "pt";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case MAP_TWIP :
+ {
+ sal_Char aText[] = "twip";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+
+ // Sonstiges
+ case MAP_PIXEL :
+ {
+ sal_Char aText[] = "pixel";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case MAP_SYSFONT :
+ {
+ sal_Char aText[] = "sysfont";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case MAP_APPFONT :
+ {
+ sal_Char aText[] = "appfont";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case MAP_RELATIVE :
+ {
+ rStr = UniString();
+ rStr += sal_Unicode('%');
+ break;
+ }
+ default: break;
+ }
+}
+
+void SdrFormatter::TakeUnitStr(FieldUnit eUnit, XubString& rStr)
+{
+ switch(eUnit)
+ {
+ default :
+ case FUNIT_NONE :
+ case FUNIT_CUSTOM :
+ {
+ rStr = UniString();
+ break;
+ }
+
+ // Metrisch
+ case FUNIT_100TH_MM:
+ {
+ sal_Char aText[] = "/100mm";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_MM :
+ {
+ sal_Char aText[] = "mm";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_CM :
+ {
+ sal_Char aText[] = "cm";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_M :
+ {
+ rStr = UniString();
+ rStr += sal_Unicode('m');
+ break;
+ }
+ case FUNIT_KM :
+ {
+ sal_Char aText[] = "km";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+
+ // Inch
+ case FUNIT_TWIP :
+ {
+ sal_Char aText[] = "twip";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_POINT :
+ {
+ sal_Char aText[] = "pt";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_PICA :
+ {
+ sal_Char aText[] = "pica";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_INCH :
+ {
+ rStr = UniString();
+ rStr += sal_Unicode('"');
+ break;
+ }
+ case FUNIT_FOOT :
+ {
+ sal_Char aText[] = "ft";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+ case FUNIT_MILE :
+ {
+ sal_Char aText[] = "mile(s)";
+ rStr = UniString(aText, sizeof(aText-1));
+ break;
+ }
+
+ // sonstiges
+ case FUNIT_PERCENT:
+ {
+ rStr = UniString();
+ rStr += sal_Unicode('%');
+ break;
+ }
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx
new file mode 100644
index 000000000000..77dd44d6d399
--- /dev/null
+++ b/svx/source/svdraw/svdundo.cxx
@@ -0,0 +1,1874 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/svdundo.hxx>
+#include "svditext.hxx"
+#include <svx/svdotext.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdlayer.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdview.hxx>
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+#include <svx/scene3d.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/sdr/properties/itemsettools.hxx>
+#include <svx/sdr/properties/properties.hxx>
+#include <svx/svdocapt.hxx>
+#include <svl/whiter.hxx>
+#include <svx/e3dsceneupdater.hxx>
+
+#include "svdviter.hxx"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// iterates over all views and unmarks this SdrObject if it is marked
+static void ImplUnmarkObject( SdrObject* pObj )
+{
+ SdrViewIter aIter( pObj );
+ for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
+ {
+ pView->MarkObj( pObj, pView->GetSdrPageView(), TRUE );
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrUndoAction,SfxUndoAction);
+
+BOOL SdrUndoAction::CanRepeat(SfxRepeatTarget& rView) const
+{
+ SdrView* pV=PTR_CAST(SdrView,&rView);
+ if (pV!=NULL) return CanSdrRepeat(*pV);
+ return FALSE;
+}
+
+void SdrUndoAction::Repeat(SfxRepeatTarget& rView)
+{
+ SdrView* pV=PTR_CAST(SdrView,&rView);
+ if (pV!=NULL) SdrRepeat(*pV);
+ DBG_ASSERT(pV!=NULL,"Repeat: Uebergebenes SfxRepeatTarget ist keine SdrView");
+}
+
+XubString SdrUndoAction::GetRepeatComment(SfxRepeatTarget& rView) const
+{
+ SdrView* pV=PTR_CAST(SdrView,&rView);
+ if (pV!=NULL) return GetSdrRepeatComment(*pV);
+ return String();
+}
+
+bool SdrUndoAction::CanSdrRepeat(SdrView& /*rView*/) const
+{
+ return FALSE;
+}
+
+void SdrUndoAction::SdrRepeat(SdrView& /*rView*/)
+{
+}
+
+XubString SdrUndoAction::GetSdrRepeatComment(SdrView& /*rView*/) const
+{
+ return String();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoGroup::SdrUndoGroup(SdrModel& rNewMod)
+: SdrUndoAction(rNewMod),
+ aBuf(1024,32,32),
+ eFunction(SDRREPFUNC_OBJ_NONE) /*#72642#*/
+{}
+
+SdrUndoGroup::SdrUndoGroup(SdrModel& rNewMod,const String& rStr)
+: SdrUndoAction(rNewMod),
+ aBuf(1024,32,32),
+ aComment(rStr),
+ eFunction(SDRREPFUNC_OBJ_NONE)
+{}
+
+SdrUndoGroup::~SdrUndoGroup()
+{
+ Clear();
+}
+
+void SdrUndoGroup::Clear()
+{
+ for (ULONG nu=0; nu<GetActionCount(); nu++) {
+ SdrUndoAction* pAct=GetAction(nu);
+ delete pAct;
+ }
+ aBuf.Clear();
+}
+
+void SdrUndoGroup::AddAction(SdrUndoAction* pAct)
+{
+ aBuf.Insert(pAct,CONTAINER_APPEND);
+}
+
+void SdrUndoGroup::push_front( SdrUndoAction* pAct )
+{
+ aBuf.Insert(pAct, (ULONG)0 );
+}
+
+void SdrUndoGroup::Undo()
+{
+ for (ULONG nu=GetActionCount(); nu>0;) {
+ nu--;
+ SdrUndoAction* pAct=GetAction(nu);
+ pAct->Undo();
+ }
+}
+
+void SdrUndoGroup::Redo()
+{
+ for (ULONG nu=0; nu<GetActionCount(); nu++) {
+ SdrUndoAction* pAct=GetAction(nu);
+ pAct->Redo();
+ }
+}
+
+XubString SdrUndoGroup::GetComment() const
+{
+ XubString aRet(aComment);
+ sal_Char aSearchText[] = "%1";
+ String aSearchString(aSearchText, sizeof(aSearchText-1));
+
+ aRet.SearchAndReplace(aSearchString, aObjDescription);
+
+ return aRet;
+}
+
+bool SdrUndoGroup::CanSdrRepeat(SdrView& rView) const
+{
+ switch (eFunction) {
+ case SDRREPFUNC_OBJ_NONE : return FALSE;
+ case SDRREPFUNC_OBJ_DELETE : return rView.AreObjectsMarked();
+ case SDRREPFUNC_OBJ_COMBINE_POLYPOLY: return rView.IsCombinePossible(FALSE);
+ case SDRREPFUNC_OBJ_COMBINE_ONEPOLY : return rView.IsCombinePossible(TRUE);
+ case SDRREPFUNC_OBJ_DISMANTLE_POLYS : return rView.IsDismantlePossible(FALSE);
+ case SDRREPFUNC_OBJ_DISMANTLE_LINES : return rView.IsDismantlePossible(TRUE);
+ case SDRREPFUNC_OBJ_CONVERTTOPOLY : return rView.IsConvertToPolyObjPossible(FALSE);
+ case SDRREPFUNC_OBJ_CONVERTTOPATH : return rView.IsConvertToPathObjPossible(FALSE);
+ case SDRREPFUNC_OBJ_GROUP : return rView.IsGroupPossible();
+ case SDRREPFUNC_OBJ_UNGROUP : return rView.IsUnGroupPossible();
+ case SDRREPFUNC_OBJ_PUTTOTOP : return rView.IsToTopPossible();
+ case SDRREPFUNC_OBJ_PUTTOBTM : return rView.IsToBtmPossible();
+ case SDRREPFUNC_OBJ_MOVTOTOP : return rView.IsToTopPossible();
+ case SDRREPFUNC_OBJ_MOVTOBTM : return rView.IsToBtmPossible();
+ case SDRREPFUNC_OBJ_REVORDER : return rView.IsReverseOrderPossible();
+ case SDRREPFUNC_OBJ_IMPORTMTF : return rView.IsImportMtfPossible();
+ default: break;
+ } // switch
+ return FALSE;
+}
+
+void SdrUndoGroup::SdrRepeat(SdrView& rView)
+{
+ switch (eFunction) {
+ case SDRREPFUNC_OBJ_NONE : break;
+ case SDRREPFUNC_OBJ_DELETE : rView.DeleteMarked(); break;
+ case SDRREPFUNC_OBJ_COMBINE_POLYPOLY: rView.CombineMarkedObjects(sal_False); break;
+ case SDRREPFUNC_OBJ_COMBINE_ONEPOLY : rView.CombineMarkedObjects(sal_True); break;
+ case SDRREPFUNC_OBJ_DISMANTLE_POLYS : rView.DismantleMarkedObjects(FALSE); break;
+ case SDRREPFUNC_OBJ_DISMANTLE_LINES : rView.DismantleMarkedObjects(TRUE); break;
+ case SDRREPFUNC_OBJ_CONVERTTOPOLY : rView.ConvertMarkedToPolyObj(FALSE); break;
+ case SDRREPFUNC_OBJ_CONVERTTOPATH : rView.ConvertMarkedToPathObj(FALSE); break;
+ case SDRREPFUNC_OBJ_GROUP : rView.GroupMarked(); break;
+ case SDRREPFUNC_OBJ_UNGROUP : rView.UnGroupMarked(); break;
+ case SDRREPFUNC_OBJ_PUTTOTOP : rView.PutMarkedToTop(); break;
+ case SDRREPFUNC_OBJ_PUTTOBTM : rView.PutMarkedToBtm(); break;
+ case SDRREPFUNC_OBJ_MOVTOTOP : rView.MovMarkedToTop(); break;
+ case SDRREPFUNC_OBJ_MOVTOBTM : rView.MovMarkedToBtm(); break;
+ case SDRREPFUNC_OBJ_REVORDER : rView.ReverseOrderOfMarked(); break;
+ case SDRREPFUNC_OBJ_IMPORTMTF : rView.DoImportMarkedMtf(); break;
+ default: break;
+ } // switch
+}
+
+XubString SdrUndoGroup::GetSdrRepeatComment(SdrView& /*rView*/) const
+{
+ XubString aRet(aComment);
+ sal_Char aSearchText[] = "%1";
+ String aSearchString(aSearchText, sizeof(aSearchText-1));
+
+ aRet.SearchAndReplace(aSearchString, ImpGetResStr(STR_ObjNameSingulPlural));
+
+ return aRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@ @@@@@ @@@@@@ @@@@@ @@@@ @@@@@@ @@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@@@@ @@ @@@@ @@ @@ @@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@ @@@@@ @@@@ @@@@@ @@@@ @@ @@@@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoObj::SdrUndoObj(SdrObject& rNewObj):
+ SdrUndoAction(*rNewObj.GetModel()),
+ pObj(&rNewObj)
+{
+}
+
+void SdrUndoObj::GetDescriptionStringForObject( const SdrObject& _rForObject, USHORT nStrCacheID, String& rStr, bool bRepeat )
+{
+ rStr = ImpGetResStr(nStrCacheID);
+ sal_Char aSearchText[] = "%1";
+ String aSearchString(aSearchText, sizeof(aSearchText-1));
+
+ xub_StrLen nPos = rStr.Search(aSearchString);
+
+ if(nPos != STRING_NOTFOUND)
+ {
+ rStr.Erase(nPos, 2);
+
+ if(bRepeat)
+ {
+ rStr.Insert(ImpGetResStr(STR_ObjNameSingulPlural), nPos);
+ }
+ else
+ {
+ XubString aStr;
+
+ _rForObject.TakeObjNameSingul(aStr);
+ rStr.Insert(aStr, nPos);
+ }
+ }
+}
+
+void SdrUndoObj::ImpTakeDescriptionStr(USHORT nStrCacheID, XubString& rStr, bool bRepeat) const
+{
+ if ( pObj )
+ GetDescriptionStringForObject( *pObj, nStrCacheID, rStr, bRepeat );
+}
+
+// #94278# common call method for evtl. page change when UNDO/REDO
+// is triggered
+void SdrUndoObj::ImpShowPageOfThisObject()
+{
+ if(pObj && pObj->IsInserted() && pObj->GetPage() && pObj->GetModel())
+ {
+ SdrHint aHint(HINT_SWITCHTOPAGE);
+
+ aHint.SetObject(pObj);
+ aHint.SetPage(pObj->GetPage());
+
+ pObj->GetModel()->Broadcast(aHint);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSaveText)
+: SdrUndoObj(rNewObj),
+ pUndoSet(NULL),
+ pRedoSet(NULL),
+ pRepeatSet(NULL),
+ pUndoStyleSheet(NULL),
+ pRedoStyleSheet(NULL),
+ pRepeatStyleSheet(NULL),
+ bHaveToTakeRedoSet(TRUE),
+ pTextUndo(NULL),
+
+ // #i8508#
+ pTextRedo(NULL),
+
+ pUndoGroup(NULL)
+{
+ bStyleSheet = bStyleSheet1;
+
+ SdrObjList* pOL = rNewObj.GetSubList();
+ BOOL bIsGroup(pOL!=NULL && pOL->GetObjCount());
+ BOOL bIs3DScene(bIsGroup && pObj->ISA(E3dScene));
+
+ if(bIsGroup)
+ {
+ // Aha, Gruppenobjekt
+ pUndoGroup = new SdrUndoGroup(*pObj->GetModel());
+ sal_uInt32 nObjAnz(pOL->GetObjCount());
+
+ for(sal_uInt32 nObjNum(0); nObjNum < nObjAnz; nObjNum++)
+ {
+ pUndoGroup->AddAction(
+ new SdrUndoAttrObj(*pOL->GetObj(nObjNum), bStyleSheet1));
+ }
+ }
+
+ if(!bIsGroup || bIs3DScene)
+ {
+ if(pUndoSet)
+ {
+ delete pUndoSet;
+ }
+
+ pUndoSet = new SfxItemSet(pObj->GetMergedItemSet());
+
+ if(bStyleSheet)
+ pUndoStyleSheet = pObj->GetStyleSheet();
+
+ if(bSaveText)
+ {
+ pTextUndo = pObj->GetOutlinerParaObject();
+ if(pTextUndo)
+ pTextUndo = new OutlinerParaObject(*pTextUndo);
+ }
+ }
+}
+
+SdrUndoAttrObj::~SdrUndoAttrObj()
+{
+ if(pUndoSet)
+ delete pUndoSet;
+ if(pRedoSet)
+ delete pRedoSet;
+ if(pRepeatSet)
+ delete pRepeatSet;
+ if(pUndoGroup)
+ delete pUndoGroup;
+ if(pTextUndo)
+ delete pTextUndo;
+
+ // #i8508#
+ if(pTextRedo)
+ delete pTextRedo;
+}
+
+void SdrUndoAttrObj::SetRepeatAttr(const SfxItemSet& rSet)
+{
+ if(pRepeatSet)
+ delete pRepeatSet;
+
+ pRepeatSet = new SfxItemSet(rSet);
+}
+
+void SdrUndoAttrObj::Undo()
+{
+ E3DModifySceneSnapRectUpdater aUpdater(pObj);
+ BOOL bIs3DScene(pObj && pObj->ISA(E3dScene));
+
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+
+ if(!pUndoGroup || bIs3DScene)
+ {
+ if(bHaveToTakeRedoSet)
+ {
+ bHaveToTakeRedoSet = FALSE;
+
+ if(pRedoSet)
+ {
+ delete pRedoSet;
+ }
+
+ pRedoSet = new SfxItemSet(pObj->GetMergedItemSet());
+
+ if(bStyleSheet)
+ pRedoStyleSheet=pObj->GetStyleSheet();
+
+ if(pTextUndo)
+ {
+ // #i8508#
+ pTextRedo = pObj->GetOutlinerParaObject();
+
+ if(pTextRedo)
+ pTextRedo = new OutlinerParaObject(*pTextRedo);
+ }
+ }
+
+ if(bStyleSheet)
+ {
+ pRedoStyleSheet = pObj->GetStyleSheet();
+ pObj->SetStyleSheet(pUndoStyleSheet, TRUE);
+ }
+
+ sdr::properties::ItemChangeBroadcaster aItemChange(*pObj);
+
+ // #105122# Since ClearItem sets back everything to normal
+ // it also sets fit-to-size text to non-fit-to-size text and
+ // switches on autogrowheight (the default). That may lead to
+ // loosing the geometry size info for the object when it is
+ // re-layouted from AdjustTextFrameWidthAndHeight(). This makes
+ // rescuing the size of the object necessary.
+ const Rectangle aSnapRect = pObj->GetSnapRect();
+
+ if(pUndoSet)
+ {
+ // #109587#
+ if(pObj->ISA(SdrCaptionObj))
+ {
+ // do a more smooth item deletion here, else the text
+ // rect will be reformatted, especially when information regarding
+ // vertical text is changed. When clearing only set items it's
+ // slower, but safer regarding such information (it's not changed
+ // usually)
+ SfxWhichIter aIter(*pUndoSet);
+ sal_uInt16 nWhich(aIter.FirstWhich());
+
+ while(nWhich)
+ {
+ if(SFX_ITEM_SET != pUndoSet->GetItemState(nWhich, sal_False))
+ {
+ pObj->ClearMergedItem(nWhich);
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+ else
+ {
+ pObj->ClearMergedItem();
+ }
+
+ pObj->SetMergedItemSet(*pUndoSet);
+ }
+
+ // #105122# Restore prev size here when it was changed.
+ if(aSnapRect != pObj->GetSnapRect())
+ {
+ pObj->NbcSetSnapRect(aSnapRect);
+ }
+
+ pObj->GetProperties().BroadcastItemChange(aItemChange);
+
+ if(pTextUndo)
+ {
+ pObj->SetOutlinerParaObject(new OutlinerParaObject(*pTextUndo));
+ }
+ }
+
+ if(pUndoGroup)
+ {
+ pUndoGroup->Undo();
+ }
+}
+
+void SdrUndoAttrObj::Redo()
+{
+ E3DModifySceneSnapRectUpdater aUpdater(pObj);
+ BOOL bIs3DScene(pObj && pObj->ISA(E3dScene));
+
+ if(!pUndoGroup || bIs3DScene)
+ {
+ if(bStyleSheet)
+ {
+ pUndoStyleSheet = pObj->GetStyleSheet();
+ pObj->SetStyleSheet(pRedoStyleSheet, TRUE);
+ }
+
+ sdr::properties::ItemChangeBroadcaster aItemChange(*pObj);
+
+ // #105122#
+ const Rectangle aSnapRect = pObj->GetSnapRect();
+
+ if(pRedoSet)
+ {
+ // #109587#
+ if(pObj->ISA(SdrCaptionObj))
+ {
+ // do a more smooth item deletion here, else the text
+ // rect will be reformatted, especially when information regarding
+ // vertical text is changed. When clearing only set items it's
+ // slower, but safer regarding such information (it's not changed
+ // usually)
+ SfxWhichIter aIter(*pRedoSet);
+ sal_uInt16 nWhich(aIter.FirstWhich());
+
+ while(nWhich)
+ {
+ if(SFX_ITEM_SET != pRedoSet->GetItemState(nWhich, sal_False))
+ {
+ pObj->ClearMergedItem(nWhich);
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+ else
+ {
+ pObj->ClearMergedItem();
+ }
+
+ pObj->SetMergedItemSet(*pRedoSet);
+ }
+
+ // #105122# Restore prev size here when it was changed.
+ if(aSnapRect != pObj->GetSnapRect())
+ {
+ pObj->NbcSetSnapRect(aSnapRect);
+ }
+
+ pObj->GetProperties().BroadcastItemChange(aItemChange);
+
+ // #i8508#
+ if(pTextRedo)
+ {
+ pObj->SetOutlinerParaObject(new OutlinerParaObject(*pTextRedo));
+ }
+ }
+
+ if(pUndoGroup)
+ {
+ pUndoGroup->Redo();
+ }
+
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+}
+
+XubString SdrUndoAttrObj::GetComment() const
+{
+ XubString aStr;
+
+ if(bStyleSheet)
+ {
+ ImpTakeDescriptionStr(STR_EditSetStylesheet, aStr);
+ }
+ else
+ {
+ ImpTakeDescriptionStr(STR_EditSetAttributes, aStr);
+ }
+
+ return aStr;
+}
+
+void SdrUndoAttrObj::SdrRepeat(SdrView& rView)
+{
+ if(pRepeatSet)
+ {
+ rView.SetAttrToMarked(*pRepeatSet, FALSE);
+ }
+}
+
+bool SdrUndoAttrObj::CanSdrRepeat(SdrView& rView) const
+{
+ return (pRepeatSet!=0L && rView.AreObjectsMarked());
+}
+
+XubString SdrUndoAttrObj::GetSdrRepeatComment(SdrView& /*rView*/) const
+{
+ XubString aStr;
+
+ if(bStyleSheet)
+ {
+ ImpTakeDescriptionStr(STR_EditSetStylesheet, aStr, TRUE);
+ }
+ else
+ {
+ ImpTakeDescriptionStr(STR_EditSetAttributes, aStr, TRUE);
+ }
+
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrUndoMoveObj::Undo()
+{
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+
+ pObj->Move(Size(-aDistance.Width(),-aDistance.Height()));
+}
+
+void SdrUndoMoveObj::Redo()
+{
+ pObj->Move(Size(aDistance.Width(),aDistance.Height()));
+
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+}
+
+XubString SdrUndoMoveObj::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditMove,aStr);
+ return aStr;
+}
+
+void SdrUndoMoveObj::SdrRepeat(SdrView& rView)
+{
+ rView.MoveMarkedObj(aDistance);
+}
+
+bool SdrUndoMoveObj::CanSdrRepeat(SdrView& rView) const
+{
+ return rView.AreObjectsMarked();
+}
+
+XubString SdrUndoMoveObj::GetSdrRepeatComment(SdrView& /*rView*/) const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditMove,aStr,TRUE);
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoGeoObj::SdrUndoGeoObj(SdrObject& rNewObj):
+ SdrUndoObj(rNewObj),
+ pUndoGeo(NULL),
+ pRedoGeo(NULL),
+ pUndoGroup(NULL)
+{
+ SdrObjList* pOL=rNewObj.GetSubList();
+ if (pOL!=NULL && pOL->GetObjCount() && !rNewObj.ISA(E3dScene))
+ {
+ // Aha, Gruppenobjekt
+ // AW: Aber keine 3D-Szene, dann nur fuer die Szene selbst den Undo anlegen
+ pUndoGroup=new SdrUndoGroup(*pObj->GetModel());
+ ULONG nObjAnz=pOL->GetObjCount();
+ for (ULONG nObjNum=0; nObjNum<nObjAnz; nObjNum++) {
+ pUndoGroup->AddAction(new SdrUndoGeoObj(*pOL->GetObj(nObjNum)));
+ }
+ } else {
+ pUndoGeo=pObj->GetGeoData();
+ }
+}
+
+SdrUndoGeoObj::~SdrUndoGeoObj()
+{
+ if (pUndoGeo!=NULL) delete pUndoGeo;
+ if (pRedoGeo!=NULL) delete pRedoGeo;
+ if (pUndoGroup!=NULL) delete pUndoGroup;
+}
+
+void SdrUndoGeoObj::Undo()
+{
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+
+ if(pUndoGroup)
+ {
+ pUndoGroup->Undo();
+
+ // #97172#
+ // only repaint, no objectchange
+ pObj->ActionChanged();
+ }
+ else
+ {
+ if (pRedoGeo!=NULL) delete pRedoGeo;
+ pRedoGeo=pObj->GetGeoData();
+ pObj->SetGeoData(*pUndoGeo);
+ }
+}
+
+void SdrUndoGeoObj::Redo()
+{
+ if(pUndoGroup)
+ {
+ pUndoGroup->Redo();
+
+ // #97172#
+ // only repaint, no objectchange
+ pObj->ActionChanged();
+ }
+ else
+ {
+ if (pUndoGeo!=NULL) delete pUndoGeo;
+ pUndoGeo=pObj->GetGeoData();
+ pObj->SetGeoData(*pRedoGeo);
+ }
+
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+}
+
+XubString SdrUndoGeoObj::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_DragMethObjOwn,aStr);
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoObjList::SdrUndoObjList(SdrObject& rNewObj, bool bOrdNumDirect)
+: SdrUndoObj(rNewObj),
+ bOwner(FALSE),
+ pView(NULL),
+ pPageView(NULL)
+{
+ pObjList=pObj->GetObjList();
+ if (bOrdNumDirect) {
+ nOrdNum=pObj->GetOrdNumDirect();
+ } else {
+ nOrdNum=pObj->GetOrdNum();
+ }
+}
+
+SdrUndoObjList::~SdrUndoObjList()
+{
+ if (pObj!=NULL && IsOwner())
+ {
+ // Attribute muessen wieder in den regulaeren Pool
+ SetOwner(FALSE);
+
+ // nun loeschen
+ SdrObject::Free( pObj );
+ }
+}
+
+void SdrUndoObjList::SetOwner(bool bNew)
+{
+ bOwner = bNew;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrUndoRemoveObj::Undo()
+{
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+
+ DBG_ASSERT(!pObj->IsInserted(),"UndoRemoveObj: pObj ist bereits Inserted");
+ if (!pObj->IsInserted())
+ {
+ // #i11426#
+ // For UNDOs in Calc/Writer it is necessary to adapt the anchor
+ // pos of the target object.
+ Point aOwnerAnchorPos(0, 0);
+
+ if(pObjList
+ && pObjList->GetOwnerObj()
+ && pObjList->GetOwnerObj()->ISA(SdrObjGroup))
+ {
+ aOwnerAnchorPos = pObjList->GetOwnerObj()->GetAnchorPos();
+ }
+
+ E3DModifySceneSnapRectUpdater aUpdater(pObjList->GetOwnerObj());
+ SdrInsertReason aReason(SDRREASON_UNDO);
+ pObjList->InsertObject(pObj,nOrdNum,&aReason);
+
+ // #i11426#
+ if(aOwnerAnchorPos.X() || aOwnerAnchorPos.Y())
+ {
+ pObj->NbcSetAnchorPos(aOwnerAnchorPos);
+ }
+ }
+}
+
+void SdrUndoRemoveObj::Redo()
+{
+ DBG_ASSERT(pObj->IsInserted(),"RedoRemoveObj: pObj ist nicht Inserted");
+ if (pObj->IsInserted())
+ {
+ ImplUnmarkObject( pObj );
+ E3DModifySceneSnapRectUpdater aUpdater(pObj);
+ pObjList->RemoveObject(nOrdNum);
+ }
+
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrUndoInsertObj::Undo()
+{
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+
+ DBG_ASSERT(pObj->IsInserted(),"UndoInsertObj: pObj ist nicht Inserted");
+ if (pObj->IsInserted())
+ {
+ ImplUnmarkObject( pObj );
+
+#ifdef DBG_UTIL
+ SdrObject* pChkObj=
+#endif
+ pObjList->RemoveObject(nOrdNum);
+ DBG_ASSERT(pChkObj==pObj,"UndoInsertObj: RemoveObjNum!=pObj");
+ }
+}
+
+void SdrUndoInsertObj::Redo()
+{
+ DBG_ASSERT(!pObj->IsInserted(),"RedoInsertObj: pObj ist bereits Inserted");
+ if (!pObj->IsInserted())
+ {
+ // --> OD 2005-05-10 #i45952# - restore anchor position of an object,
+ // which becomes a member of a group, because its cleared in method
+ // <InsertObject(..)>. Needed for correct ReDo in Writer.
+ Point aAnchorPos( 0, 0 );
+ if ( pObjList &&
+ pObjList->GetOwnerObj() &&
+ pObjList->GetOwnerObj()->ISA(SdrObjGroup) )
+ {
+ aAnchorPos = pObj->GetAnchorPos();
+ }
+ // <--
+
+ SdrInsertReason aReason(SDRREASON_UNDO);
+ pObjList->InsertObject(pObj,nOrdNum,&aReason);
+
+ // --> OD 2005-05-10 #i45952#
+ if ( aAnchorPos.X() || aAnchorPos.Y() )
+ {
+ pObj->NbcSetAnchorPos( aAnchorPos );
+ }
+ // <--
+ }
+
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrUndoDelObj::Undo()
+{
+ SdrUndoRemoveObj::Undo();
+ DBG_ASSERT(IsOwner(),"UndoDeleteObj: pObj gehoert nicht der UndoAction");
+ SetOwner(FALSE);
+}
+
+void SdrUndoDelObj::Redo()
+{
+ SdrUndoRemoveObj::Redo();
+ DBG_ASSERT(!IsOwner(),"RedoDeleteObj: pObj gehoert bereits der UndoAction");
+ SetOwner(TRUE);
+}
+
+XubString SdrUndoDelObj::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditDelete,aStr);
+ return aStr;
+}
+
+void SdrUndoDelObj::SdrRepeat(SdrView& rView)
+{
+ rView.DeleteMarked();
+}
+
+bool SdrUndoDelObj::CanSdrRepeat(SdrView& rView) const
+{
+ return rView.AreObjectsMarked();
+}
+
+XubString SdrUndoDelObj::GetSdrRepeatComment(SdrView& /*rView*/) const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_EditDelete,aStr,TRUE);
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrUndoNewObj::Undo()
+{
+ SdrUndoInsertObj::Undo();
+ DBG_ASSERT(!IsOwner(),"RedoNewObj: pObj gehoert bereits der UndoAction");
+ SetOwner(TRUE);
+}
+
+void SdrUndoNewObj::Redo()
+{
+ SdrUndoInsertObj::Redo();
+ DBG_ASSERT(IsOwner(),"RedoNewObj: pObj gehoert nicht der UndoAction");
+ SetOwner(FALSE);
+}
+
+String SdrUndoNewObj::GetComment( const SdrObject& _rForObject )
+{
+ String sComment;
+ GetDescriptionStringForObject( _rForObject, STR_UndoInsertObj, sComment );
+ return sComment;
+}
+
+XubString SdrUndoNewObj::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoInsertObj,aStr);
+ return aStr;
+}
+
+SdrUndoReplaceObj::SdrUndoReplaceObj(SdrObject& rOldObj1, SdrObject& rNewObj1, bool bOrdNumDirect)
+: SdrUndoObj(rOldObj1),
+ bOldOwner(FALSE),
+ bNewOwner(FALSE),
+ pNewObj(&rNewObj1)
+{
+ SetOldOwner(TRUE);
+
+ pObjList=pObj->GetObjList();
+ if (bOrdNumDirect) {
+ nOrdNum=pObj->GetOrdNumDirect();
+ } else {
+ nOrdNum=pObj->GetOrdNum();
+ }
+}
+
+SdrUndoReplaceObj::~SdrUndoReplaceObj()
+{
+ if (pObj!=NULL && IsOldOwner())
+ {
+ // Attribute muessen wieder in den regulaeren Pool
+ SetOldOwner(FALSE);
+
+ // nun loeschen
+ SdrObject::Free( pObj );
+ }
+ if (pNewObj!=NULL && IsNewOwner())
+ {
+ // Attribute muessen wieder in den regulaeren Pool
+ SetNewOwner(FALSE);
+
+ // nun loeschen
+ SdrObject::Free( pNewObj );
+ }
+}
+
+void SdrUndoReplaceObj::Undo()
+{
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+
+ if (IsOldOwner() && !IsNewOwner())
+ {
+ DBG_ASSERT(!pObj->IsInserted(),"SdrUndoReplaceObj::Undo(): Altes Objekt ist bereits inserted!");
+ DBG_ASSERT(pNewObj->IsInserted(),"SdrUndoReplaceObj::Undo(): Neues Objekt ist nicht inserted!");
+ SetOldOwner(FALSE);
+ SetNewOwner(TRUE);
+
+ ImplUnmarkObject( pNewObj );
+ pObjList->ReplaceObject(pObj,nOrdNum);
+ }
+ else
+ {
+ DBG_ERROR("SdrUndoReplaceObj::Undo(): IsMine-Flags stehen verkehrt. Doppelter Undo-Aufruf?");
+ }
+}
+
+void SdrUndoReplaceObj::Redo()
+{
+ if (!IsOldOwner() && IsNewOwner())
+ {
+ DBG_ASSERT(!pNewObj->IsInserted(),"SdrUndoReplaceObj::Redo(): Neues Objekt ist bereits inserted!");
+ DBG_ASSERT(pObj->IsInserted(),"SdrUndoReplaceObj::Redo(): Altes Objekt ist nicht inserted!");
+ SetOldOwner(TRUE);
+ SetNewOwner(FALSE);
+
+ ImplUnmarkObject( pObj );
+ pObjList->ReplaceObject(pNewObj,nOrdNum);
+
+ }
+ else
+ {
+ DBG_ERROR("SdrUndoReplaceObj::Redo(): IsMine-Flags stehen verkehrt. Doppelter Redo-Aufruf?");
+ }
+
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+}
+
+void SdrUndoReplaceObj::SetNewOwner(bool bNew)
+{
+ bNewOwner = bNew;
+}
+
+void SdrUndoReplaceObj::SetOldOwner(bool bNew)
+{
+ bOldOwner = bNew;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+XubString SdrUndoCopyObj::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoCopyObj,aStr);
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// #i11702#
+
+SdrUndoObjectLayerChange::SdrUndoObjectLayerChange(SdrObject& rObj, SdrLayerID aOldLayer, SdrLayerID aNewLayer)
+: SdrUndoObj(rObj),
+ maOldLayer(aOldLayer),
+ maNewLayer(aNewLayer)
+{
+}
+
+void SdrUndoObjectLayerChange::Undo()
+{
+ ImpShowPageOfThisObject();
+ pObj->SetLayer(maOldLayer);
+}
+
+void SdrUndoObjectLayerChange::Redo()
+{
+ pObj->SetLayer(maNewLayer);
+ ImpShowPageOfThisObject();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoObjOrdNum::SdrUndoObjOrdNum(SdrObject& rNewObj, UINT32 nOldOrdNum1, UINT32 nNewOrdNum1):
+ SdrUndoObj(rNewObj),
+ nOldOrdNum(nOldOrdNum1),
+ nNewOrdNum(nNewOrdNum1)
+{
+}
+
+void SdrUndoObjOrdNum::Undo()
+{
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+
+ SdrObjList* pOL=pObj->GetObjList();
+ if (pOL==NULL) {
+ DBG_ERROR("UndoObjOrdNum: pObj hat keine ObjList");
+ return;
+ }
+ pOL->SetObjectOrdNum(nNewOrdNum,nOldOrdNum);
+}
+
+void SdrUndoObjOrdNum::Redo()
+{
+ SdrObjList* pOL=pObj->GetObjList();
+ if (pOL==NULL) {
+ DBG_ERROR("RedoObjOrdNum: pObj hat keine ObjList");
+ return;
+ }
+ pOL->SetObjectOrdNum(nOldOrdNum,nNewOrdNum);
+
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+}
+
+XubString SdrUndoObjOrdNum::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoObjOrdNum,aStr);
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoObjSetText::SdrUndoObjSetText(SdrObject& rNewObj, sal_Int32 nText)
+: SdrUndoObj(rNewObj)
+, pOldText(NULL)
+, pNewText(NULL)
+, bNewTextAvailable(FALSE)
+, bEmptyPresObj(FALSE)
+, mnText(nText)
+{
+ SdrText* pText = static_cast< SdrTextObj*>( &rNewObj )->getText(mnText);
+ if( pText && pText->GetOutlinerParaObject() )
+ pOldText = new OutlinerParaObject(*pText->GetOutlinerParaObject());
+
+ bEmptyPresObj = rNewObj.IsEmptyPresObj();
+}
+
+SdrUndoObjSetText::~SdrUndoObjSetText()
+{
+ if ( pOldText )
+ delete pOldText;
+ if ( pNewText )
+ delete pNewText;
+}
+
+void SdrUndoObjSetText::AfterSetText()
+{
+ if (!bNewTextAvailable)
+ {
+ SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText);
+ if( pText && pText->GetOutlinerParaObject() )
+ pNewText = new OutlinerParaObject(*pText->GetOutlinerParaObject());
+ bNewTextAvailable=TRUE;
+ }
+}
+
+void SdrUndoObjSetText::Undo()
+{
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+
+ // alten Text sichern fuer Redo
+ if (!bNewTextAvailable)
+ AfterSetText();
+
+ // Text fuer Undo kopieren, denn SetOutlinerParaObject() ist Eigentumsuebereignung
+ OutlinerParaObject* pText1 = pOldText;
+ if(pText1)
+ pText1 = new OutlinerParaObject(*pText1);
+
+ SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText);
+ if( pText )
+ pText->SetOutlinerParaObject(pText1);
+
+ pObj->SetEmptyPresObj( bEmptyPresObj );
+ pObj->ActionChanged();
+}
+
+void SdrUndoObjSetText::Redo()
+{
+ // Text fuer Undo kopieren, denn SetOutlinerParaObject() ist Eigentumsuebereignung
+ OutlinerParaObject* pText1 = pNewText;
+
+ if(pText1)
+ pText1 = new OutlinerParaObject(*pText1);
+
+ SdrText* pText = static_cast< SdrTextObj*>( pObj )->getText(mnText);
+ if( pText )
+ static_cast< SdrTextObj* >( pObj )->NbcSetOutlinerParaObjectForText( pText1, pText );
+
+ pObj->ActionChanged();
+
+ // #94278# Trigger PageChangeCall
+ ImpShowPageOfThisObject();
+}
+
+XubString SdrUndoObjSetText::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoObjSetText,aStr);
+ return aStr;
+}
+
+XubString SdrUndoObjSetText::GetSdrRepeatComment(SdrView& /*rView*/) const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoObjSetText,aStr);
+ return aStr;
+}
+
+void SdrUndoObjSetText::SdrRepeat(SdrView& rView)
+{
+ if (bNewTextAvailable && rView.AreObjectsMarked())
+ {
+ const SdrMarkList& rML=rView.GetMarkedObjectList();
+
+ const bool bUndo = rView.IsUndoEnabled();
+ if( bUndo )
+ {
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoObjSetText,aStr);
+ rView.BegUndo(aStr);
+ }
+
+ ULONG nAnz=rML.GetMarkCount();
+ for (ULONG nm=0; nm<nAnz; nm++)
+ {
+ SdrObject* pObj2=rML.GetMark(nm)->GetMarkedSdrObj();
+ SdrTextObj* pTextObj=PTR_CAST(SdrTextObj,pObj2);
+ if (pTextObj!=NULL)
+ {
+ if( bUndo )
+ rView.AddUndo(new SdrUndoObjSetText(*pTextObj,0));
+
+ OutlinerParaObject* pText1=pNewText;
+ if (pText1!=NULL)
+ pText1 = new OutlinerParaObject(*pText1);
+ pTextObj->SetOutlinerParaObject(pText1);
+ }
+ }
+
+ if( bUndo )
+ rView.EndUndo();
+ }
+}
+
+bool SdrUndoObjSetText::CanSdrRepeat(SdrView& rView) const
+{
+ bool bOk = false;
+ if (bNewTextAvailable && rView.AreObjectsMarked()) {
+ bOk=TRUE;
+ }
+ return bOk;
+}
+
+// --> OD 2009-07-09 #i73249#
+SdrUndoObjStrAttr::SdrUndoObjStrAttr( SdrObject& rNewObj,
+ const ObjStrAttrType eObjStrAttr,
+ const String& sOldStr,
+ const String& sNewStr)
+ : SdrUndoObj( rNewObj ),
+ meObjStrAttr( eObjStrAttr ),
+ msOldStr( sOldStr ),
+ msNewStr( sNewStr )
+{
+}
+
+void SdrUndoObjStrAttr::Undo()
+{
+ ImpShowPageOfThisObject();
+
+ switch ( meObjStrAttr )
+ {
+ case OBJ_NAME:
+ {
+ pObj->SetName( msOldStr );
+ }
+ break;
+ case OBJ_TITLE:
+ {
+ pObj->SetTitle( msOldStr );
+ }
+ break;
+ case OBJ_DESCRIPTION:
+ {
+ pObj->SetDescription( msOldStr );
+ }
+ break;
+ }
+}
+
+void SdrUndoObjStrAttr::Redo()
+{
+ switch ( meObjStrAttr )
+ {
+ case OBJ_NAME:
+ {
+ pObj->SetName( msNewStr );
+ }
+ break;
+ case OBJ_TITLE:
+ {
+ pObj->SetTitle( msNewStr );
+ }
+ break;
+ case OBJ_DESCRIPTION:
+ {
+ pObj->SetDescription( msNewStr );
+ }
+ break;
+ }
+
+ ImpShowPageOfThisObject();
+}
+
+String SdrUndoObjStrAttr::GetComment() const
+{
+ String aStr;
+ switch ( meObjStrAttr )
+ {
+ case OBJ_NAME:
+ {
+ ImpTakeDescriptionStr( STR_UndoObjName, aStr );
+ aStr += sal_Unicode(' ');
+ aStr += sal_Unicode('\'');
+ aStr += msNewStr;
+ aStr += sal_Unicode('\'');
+ }
+ break;
+ case OBJ_TITLE:
+ {
+ ImpTakeDescriptionStr( STR_UndoObjTitle, aStr );
+ }
+ break;
+ case OBJ_DESCRIPTION:
+ {
+ ImpTakeDescriptionStr( STR_UndoObjDescription, aStr );
+ }
+ break;
+ }
+
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@ @@@@ @@ @@ @@@@@ @@@@@
+// @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@@@@@ @@@@ @@@@ @@@@@
+// @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@
+// @@@@@ @@ @@ @@ @@@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoLayer::SdrUndoLayer(USHORT nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel):
+ SdrUndoAction(rNewModel),
+ pLayer(rNewLayerAdmin.GetLayer(nLayerNum)),
+ pLayerAdmin(&rNewLayerAdmin),
+ nNum(nLayerNum),
+ bItsMine(FALSE)
+{
+}
+
+SdrUndoLayer::~SdrUndoLayer()
+{
+ if (bItsMine) {
+ delete pLayer;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrUndoNewLayer::Undo()
+{
+ DBG_ASSERT(!bItsMine,"SdrUndoNewLayer::Undo(): Layer gehoert bereits der UndoAction");
+ bItsMine=TRUE;
+#ifdef DBG_UTIL
+ SdrLayer* pCmpLayer=
+#endif
+ pLayerAdmin->RemoveLayer(nNum);
+ DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoNewLayer::Undo(): Removter Layer ist != pLayer");
+}
+
+void SdrUndoNewLayer::Redo()
+{
+ DBG_ASSERT(bItsMine,"SdrUndoNewLayer::Undo(): Layer gehoert nicht der UndoAction");
+ bItsMine=FALSE;
+ pLayerAdmin->InsertLayer(pLayer,nNum);
+}
+
+XubString SdrUndoNewLayer::GetComment() const
+{
+ return ImpGetResStr(STR_UndoNewLayer);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrUndoDelLayer::Undo()
+{
+ DBG_ASSERT(bItsMine,"SdrUndoDelLayer::Undo(): Layer gehoert nicht der UndoAction");
+ bItsMine=FALSE;
+ pLayerAdmin->InsertLayer(pLayer,nNum);
+}
+
+void SdrUndoDelLayer::Redo()
+{
+ DBG_ASSERT(!bItsMine,"SdrUndoDelLayer::Undo(): Layer gehoert bereits der UndoAction");
+ bItsMine=TRUE;
+#ifdef DBG_UTIL
+ SdrLayer* pCmpLayer=
+#endif
+ pLayerAdmin->RemoveLayer(nNum);
+ DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoDelLayer::Redo(): Removter Layer ist != pLayer");
+}
+
+XubString SdrUndoDelLayer::GetComment() const
+{
+ return ImpGetResStr(STR_UndoDelLayer);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrUndoMoveLayer::Undo()
+{
+#ifdef DBG_UTIL
+ SdrLayer* pCmpLayer=
+#endif
+ pLayerAdmin->RemoveLayer(nNeuPos);
+ DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoMoveLayer::Undo(): Removter Layer ist != pLayer");
+ pLayerAdmin->InsertLayer(pLayer,nNum);
+}
+
+void SdrUndoMoveLayer::Redo()
+{
+#ifdef DBG_UTIL
+ SdrLayer* pCmpLayer=
+#endif
+ pLayerAdmin->RemoveLayer(nNum);
+ DBG_ASSERT(pCmpLayer==pLayer,"SdrUndoMoveLayer::Redo(): Removter Layer ist != pLayer");
+ pLayerAdmin->InsertLayer(pLayer,nNeuPos);
+}
+
+XubString SdrUndoMoveLayer::GetComment() const
+{
+ return ImpGetResStr(STR_UndoMovLayer);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@@@@ @@@@ @@@@ @@@@@ @@@@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@
+// @@@@@ @@@@@@ @@ @@@ @@@@ @@@@
+// @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@@@@ @@@@@ @@@@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoPage::SdrUndoPage(SdrPage& rNewPg)
+: SdrUndoAction(*rNewPg.GetModel()),
+ mrPage(rNewPg)
+{
+}
+
+void SdrUndoPage::ImpInsertPage(USHORT nNum)
+{
+ DBG_ASSERT(!mrPage.IsInserted(),"SdrUndoPage::ImpInsertPage(): mrPage ist bereits Inserted");
+ if (!mrPage.IsInserted()) {
+ if (mrPage.IsMasterPage()) {
+ rMod.InsertMasterPage(&mrPage,nNum);
+ } else {
+ rMod.InsertPage(&mrPage,nNum);
+ }
+ }
+}
+
+void SdrUndoPage::ImpRemovePage(USHORT nNum)
+{
+ DBG_ASSERT(mrPage.IsInserted(),"SdrUndoPage::ImpRemovePage(): mrPage ist nicht Inserted");
+ if (mrPage.IsInserted()) {
+ SdrPage* pChkPg=NULL;
+ if (mrPage.IsMasterPage()) {
+ pChkPg=rMod.RemoveMasterPage(nNum);
+ } else {
+ pChkPg=rMod.RemovePage(nNum);
+ }
+ DBG_ASSERT(pChkPg==&mrPage,"SdrUndoPage::ImpRemovePage(): RemovePage!=&mrPage");
+ }
+}
+
+void SdrUndoPage::ImpMovePage(USHORT nOldNum, USHORT nNewNum)
+{
+ DBG_ASSERT(mrPage.IsInserted(),"SdrUndoPage::ImpMovePage(): mrPage ist nicht Inserted");
+ if (mrPage.IsInserted()) {
+ if (mrPage.IsMasterPage()) {
+ rMod.MoveMasterPage(nOldNum,nNewNum);
+ } else {
+ rMod.MovePage(nOldNum,nNewNum);
+ }
+ }
+}
+
+void SdrUndoPage::ImpTakeDescriptionStr(USHORT nStrCacheID, XubString& rStr, USHORT /*n*/, bool /*bRepeat*/) const
+{
+ rStr=ImpGetResStr(nStrCacheID);
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoPageList::SdrUndoPageList(SdrPage& rNewPg):
+ SdrUndoPage(rNewPg),
+ bItsMine(FALSE)
+{
+ nPageNum=rNewPg.GetPageNum();
+}
+
+SdrUndoPageList::~SdrUndoPageList()
+{
+ if(bItsMine)
+ {
+ delete (&mrPage);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoDelPage::SdrUndoDelPage(SdrPage& rNewPg):
+ SdrUndoPageList(rNewPg),
+ pUndoGroup(NULL)
+{
+ bItsMine = TRUE;
+
+ // Und nun ggf. die MasterPage-Beziehungen merken
+ if(mrPage.IsMasterPage())
+ {
+ sal_uInt16 nPageAnz(rMod.GetPageCount());
+
+ for(sal_uInt16 nPageNum2(0); nPageNum2 < nPageAnz; nPageNum2++)
+ {
+ SdrPage* pDrawPage = rMod.GetPage(nPageNum2);
+
+ if(pDrawPage->TRG_HasMasterPage())
+ {
+ SdrPage& rMasterPage = pDrawPage->TRG_GetMasterPage();
+
+ if(&mrPage == &rMasterPage)
+ {
+ if(!pUndoGroup)
+ {
+ pUndoGroup = new SdrUndoGroup(rMod);
+ }
+
+ pUndoGroup->AddAction(rMod.GetSdrUndoFactory().CreateUndoPageRemoveMasterPage(*pDrawPage));
+ }
+ }
+ }
+ }
+}
+
+SdrUndoDelPage::~SdrUndoDelPage()
+{
+ if (pUndoGroup!=NULL) {
+ delete pUndoGroup;
+ }
+}
+
+void SdrUndoDelPage::Undo()
+{
+ ImpInsertPage(nPageNum);
+ if (pUndoGroup!=NULL) { // MasterPage-Beziehungen wiederherstellen
+ pUndoGroup->Undo();
+ }
+ DBG_ASSERT(bItsMine,"UndoDeletePage: mrPage gehoert nicht der UndoAction");
+ bItsMine=FALSE;
+}
+
+void SdrUndoDelPage::Redo()
+{
+ ImpRemovePage(nPageNum);
+ // Die MasterPage-Beziehungen werden ggf. von selbst geloesst
+ DBG_ASSERT(!bItsMine,"RedoDeletePage: mrPage gehoert bereits der UndoAction");
+ bItsMine=TRUE;
+}
+
+XubString SdrUndoDelPage::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoDelPage,aStr,0,FALSE);
+ return aStr;
+}
+
+XubString SdrUndoDelPage::GetSdrRepeatComment(SdrView& /*rView*/) const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoDelPage,aStr,0,FALSE);
+ return aStr;
+}
+
+void SdrUndoDelPage::SdrRepeat(SdrView& /*rView*/)
+{
+}
+
+bool SdrUndoDelPage::CanSdrRepeat(SdrView& /*rView*/) const
+{
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrUndoNewPage::Undo()
+{
+ ImpRemovePage(nPageNum);
+ DBG_ASSERT(!bItsMine,"UndoNewPage: mrPage gehoert bereits der UndoAction");
+ bItsMine=TRUE;
+}
+
+void SdrUndoNewPage::Redo()
+{
+ ImpInsertPage(nPageNum);
+ DBG_ASSERT(bItsMine,"RedoNewPage: mrPage gehoert nicht der UndoAction");
+ bItsMine=FALSE;
+}
+
+XubString SdrUndoNewPage::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoNewPage,aStr,0,FALSE);
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+XubString SdrUndoCopyPage::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoCopPage,aStr,0,FALSE);
+ return aStr;
+}
+
+XubString SdrUndoCopyPage::GetSdrRepeatComment(SdrView& /*rView*/) const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoCopPage,aStr,0,FALSE);
+ return aStr;
+}
+
+void SdrUndoCopyPage::SdrRepeat(SdrView& /*rView*/)
+{
+
+}
+
+bool SdrUndoCopyPage::CanSdrRepeat(SdrView& /*rView*/) const
+{
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrUndoSetPageNum::Undo()
+{
+ ImpMovePage(nNewPageNum,nOldPageNum);
+}
+
+void SdrUndoSetPageNum::Redo()
+{
+ ImpMovePage(nOldPageNum,nNewPageNum);
+}
+
+XubString SdrUndoSetPageNum::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoMovPage,aStr,0,FALSE);
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@ @@ @@@@ @@@@ @@@@@@ @@@@@ @@@@@ @@@@@ @@@@ @@@@ @@@@@ @@@@
+// @@@ @@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@@@@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@@@@@@ @@@@@@ @@@@ @@ @@@@ @@@@@ @@@@@ @@@@@@ @@ @@@ @@@@ @@@@
+// @@ @ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@@@ @@ @@@@@ @@ @@ @@ @@ @@ @@@@@ @@@@@ @@@@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoPageMasterPage::SdrUndoPageMasterPage(SdrPage& rChangedPage)
+: SdrUndoPage(rChangedPage),
+ mbOldHadMasterPage(mrPage.TRG_HasMasterPage())
+{
+ // get current state from page
+ if(mbOldHadMasterPage)
+ {
+ maOldSet = mrPage.TRG_GetMasterPageVisibleLayers();
+ maOldMasterPageNumber = mrPage.TRG_GetMasterPage().GetPageNum();
+ }
+}
+
+SdrUndoPageMasterPage::~SdrUndoPageMasterPage()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoPageRemoveMasterPage::SdrUndoPageRemoveMasterPage(SdrPage& rChangedPage)
+: SdrUndoPageMasterPage(rChangedPage)
+{
+}
+
+void SdrUndoPageRemoveMasterPage::Undo()
+{
+ if(mbOldHadMasterPage)
+ {
+ mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber));
+ mrPage.TRG_SetMasterPageVisibleLayers(maOldSet);
+ }
+}
+
+void SdrUndoPageRemoveMasterPage::Redo()
+{
+ mrPage.TRG_ClearMasterPage();
+}
+
+XubString SdrUndoPageRemoveMasterPage::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoDelPageMasterDscr,aStr,0,FALSE);
+ return aStr;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrUndoPageChangeMasterPage::SdrUndoPageChangeMasterPage(SdrPage& rChangedPage)
+: SdrUndoPageMasterPage(rChangedPage),
+ mbNewHadMasterPage(sal_False)
+{
+}
+
+void SdrUndoPageChangeMasterPage::Undo()
+{
+ // remember values from new page
+ if(mrPage.TRG_HasMasterPage())
+ {
+ mbNewHadMasterPage = sal_True;
+ maNewSet = mrPage.TRG_GetMasterPageVisibleLayers();
+ maNewMasterPageNumber = mrPage.TRG_GetMasterPage().GetPageNum();
+ }
+
+ // restore old values
+ if(mbOldHadMasterPage)
+ {
+ mrPage.TRG_ClearMasterPage();
+ mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maOldMasterPageNumber));
+ mrPage.TRG_SetMasterPageVisibleLayers(maOldSet);
+ }
+}
+
+void SdrUndoPageChangeMasterPage::Redo()
+{
+ // restore new values
+ if(mbNewHadMasterPage)
+ {
+ mrPage.TRG_ClearMasterPage();
+ mrPage.TRG_SetMasterPage(*mrPage.GetModel()->GetMasterPage(maNewMasterPageNumber));
+ mrPage.TRG_SetMasterPageVisibleLayers(maNewSet);
+ }
+}
+
+XubString SdrUndoPageChangeMasterPage::GetComment() const
+{
+ XubString aStr;
+ ImpTakeDescriptionStr(STR_UndoChgPageMasterDscr,aStr,0,FALSE);
+ return aStr;
+}
+
+///////////////////////////////////////////////////////////////////////
+SdrUndoFactory::~SdrUndoFactory(){}
+// shapes
+SdrUndoAction* SdrUndoFactory::CreateUndoMoveObject( SdrObject& rObject )
+{
+ return new SdrUndoMoveObj( rObject );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoMoveObject( SdrObject& rObject, const Size& rDist )
+{
+ return new SdrUndoMoveObj( rObject, rDist );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoGeoObject( SdrObject& rObject )
+{
+ return new SdrUndoGeoObj( rObject );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoAttrObject( SdrObject& rObject, bool bStyleSheet1, bool bSaveText )
+{
+ return new SdrUndoAttrObj( rObject, bStyleSheet1 ? TRUE : FALSE, bSaveText ? TRUE : FALSE );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoRemoveObject( SdrObject& rObject, bool bOrdNumDirect )
+{
+ return new SdrUndoRemoveObj( rObject, bOrdNumDirect ? TRUE : FALSE );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoInsertObject( SdrObject& rObject, bool bOrdNumDirect )
+{
+ return new SdrUndoInsertObj( rObject, bOrdNumDirect ? TRUE : FALSE );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoDeleteObject( SdrObject& rObject, bool bOrdNumDirect )
+{
+ return new SdrUndoDelObj( rObject, bOrdNumDirect ? TRUE : FALSE );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoNewObject( SdrObject& rObject, bool bOrdNumDirect )
+{
+ return new SdrUndoNewObj( rObject, bOrdNumDirect ? TRUE : FALSE );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoCopyObject( SdrObject& rObject, bool bOrdNumDirect )
+{
+ return new SdrUndoCopyObj( rObject, bOrdNumDirect ? TRUE : FALSE );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoObjectOrdNum( SdrObject& rObject, sal_uInt32 nOldOrdNum1, sal_uInt32 nNewOrdNum1)
+{
+ return new SdrUndoObjOrdNum( rObject, nOldOrdNum1, nNewOrdNum1 );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoReplaceObject( SdrObject& rOldObject, SdrObject& rNewObject, bool bOrdNumDirect )
+{
+ return new SdrUndoReplaceObj( rOldObject, rNewObject, bOrdNumDirect ? TRUE : FALSE );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoObjectLayerChange( SdrObject& rObject, SdrLayerID aOldLayer, SdrLayerID aNewLayer )
+{
+ return new SdrUndoObjectLayerChange( rObject, aOldLayer, aNewLayer );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoObjectSetText( SdrObject& rNewObj, sal_Int32 nText )
+{
+ return new SdrUndoObjSetText( rNewObj, nText );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoObjectStrAttr( SdrObject& rObject,
+ SdrUndoObjStrAttr::ObjStrAttrType eObjStrAttrType,
+ String sOldStr,
+ String sNewStr )
+{
+ return new SdrUndoObjStrAttr( rObject, eObjStrAttrType, sOldStr, sNewStr );
+}
+
+
+// layer
+SdrUndoAction* SdrUndoFactory::CreateUndoNewLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
+{
+ return new SdrUndoNewLayer( nLayerNum, rNewLayerAdmin, rNewModel );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoDeleteLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel)
+{
+ return new SdrUndoDelLayer( nLayerNum, rNewLayerAdmin, rNewModel );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoMoveLayer(sal_uInt16 nLayerNum, SdrLayerAdmin& rNewLayerAdmin, SdrModel& rNewModel, sal_uInt16 nNeuPos1)
+{
+ return new SdrUndoMoveLayer( nLayerNum, rNewLayerAdmin, rNewModel, nNeuPos1 );
+}
+
+// page
+SdrUndoAction* SdrUndoFactory::CreateUndoDeletePage(SdrPage& rPage)
+{
+ return new SdrUndoDelPage( rPage );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoNewPage(SdrPage& rPage)
+{
+ return new SdrUndoNewPage( rPage );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoCopyPage(SdrPage& rPage)
+{
+ return new SdrUndoCopyPage( rPage );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoSetPageNum(SdrPage& rNewPg, sal_uInt16 nOldPageNum1, sal_uInt16 nNewPageNum1)
+{
+ return new SdrUndoSetPageNum( rNewPg, nOldPageNum1, nNewPageNum1 );
+}
+ // master page
+SdrUndoAction* SdrUndoFactory::CreateUndoPageRemoveMasterPage(SdrPage& rChangedPage)
+{
+ return new SdrUndoPageRemoveMasterPage( rChangedPage );
+}
+
+SdrUndoAction* SdrUndoFactory::CreateUndoPageChangeMasterPage(SdrPage& rChangedPage)
+{
+ return new SdrUndoPageChangeMasterPage(rChangedPage);
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdview.cxx b/svx/source/svdraw/svdview.cxx
new file mode 100644
index 000000000000..718f75610b9a
--- /dev/null
+++ b/svx/source/svdraw/svdview.cxx
@@ -0,0 +1,1608 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <editeng/eeitem.hxx>
+
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+#include <svx/svdpagv.hxx>
+#include <svx/svdmrkv.hxx>
+#include <svx/svdedxv.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdopath.hxx> // fuer GetContext
+#include <svx/svdograf.hxx> // fuer GetContext
+#include <svx/svdomedia.hxx> // fuer GetContext
+#include <svx/svdetc.hxx> // Fuer SdrEngineDefaults
+
+#ifdef DBG_UTIL
+#include <svdibrow.hxx>
+#endif
+
+#include "svx/svdoutl.hxx"
+#include "svx/svdview.hxx"
+#include "editeng/editview.hxx" // fuer GetField
+#include "editeng/flditem.hxx" // fuer URLField
+#include "svx/obj3d.hxx"
+#include "svx/svddrgmt.hxx"
+#include "svx/svdoutl.hxx"
+#include "svx/svdotable.hxx"
+#include <tools/tenccvt.hxx>
+#include <svx/sdr/overlay/overlaypolypolygon.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <sdrpaintwindow.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <svx/sdrhittesthelper.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrViewEvent::SdrViewEvent()
+: pHdl(NULL),
+ pObj(NULL),
+ pRootObj(NULL),
+ pPV(NULL),
+ pURLField(NULL),
+ eHit(SDRHIT_NONE),
+ eEvent(SDREVENT_NONE),
+ eHdlKind(HDL_MOVE),
+ eEndCreateCmd(SDRCREATE_NEXTPOINT),
+ nMouseClicks(0),
+ nMouseMode(0),
+ nMouseCode(0),
+ nHlplIdx(0),
+ nGlueId(0),
+ bMouseDown(FALSE),
+ bMouseUp(FALSE),
+ bDoubleHdlSize(FALSE),
+ bIsAction(FALSE),
+ bIsTextEdit(FALSE),
+ bTextEditHit(FALSE),
+ bAddMark(FALSE),
+ bUnmark(FALSE),
+ bPrevNextMark(FALSE),
+ bMarkPrev(FALSE),
+ bInsPointNewObj(FALSE),
+ bDragWithCopy(FALSE),
+ bCaptureMouse(FALSE),
+ bReleaseMouse(FALSE)
+{
+}
+
+SdrViewEvent::~SdrViewEvent()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// helper class for all D&D overlays
+
+void SdrDropMarkerOverlay::ImplCreateOverlays(const SdrView& rView, const basegfx::B2DPolyPolygon& rPolyPolygon)
+{
+ for(sal_uInt32 a(0L); a < rView.PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
+ ::sdr::overlay::OverlayManager* pTargetOverlay = pCandidate->GetOverlayManager();
+
+ if(pTargetOverlay)
+ {
+ ::sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(
+ rPolyPolygon);
+ pTargetOverlay->add(*pNew);
+ maObjects.append(*pNew);
+ }
+ }
+}
+
+SdrDropMarkerOverlay::SdrDropMarkerOverlay(const SdrView& rView, const SdrObject& rObject)
+{
+ ImplCreateOverlays(rView, rObject.TakeXorPoly());
+}
+
+SdrDropMarkerOverlay::SdrDropMarkerOverlay(const SdrView& rView, const Rectangle& rRectangle)
+{
+ basegfx::B2DPolygon aB2DPolygon;
+ aB2DPolygon.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top()));
+ aB2DPolygon.append(basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top()));
+ aB2DPolygon.append(basegfx::B2DPoint(rRectangle.Right(), rRectangle.Bottom()));
+ aB2DPolygon.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
+ aB2DPolygon.setClosed(true);
+
+ basegfx::B2DPolyPolygon aB2DPolyPolygon;
+ aB2DPolyPolygon.append(aB2DPolygon);
+
+ ImplCreateOverlays(rView, aB2DPolyPolygon);
+}
+
+SdrDropMarkerOverlay::SdrDropMarkerOverlay(const SdrView& rView, const Point& rStart, const Point& rEnd)
+{
+ basegfx::B2DPolygon aB2DPolygon;
+ aB2DPolygon.append(basegfx::B2DPoint(rStart.X(), rStart.Y()));
+ aB2DPolygon.append(basegfx::B2DPoint(rEnd.X(), rEnd.Y()));
+ aB2DPolygon.setClosed(true);
+
+ basegfx::B2DPolyPolygon aB2DPolyPolygon;
+ aB2DPolyPolygon.append(aB2DPolygon);
+
+ ImplCreateOverlays(rView, aB2DPolyPolygon);
+}
+
+SdrDropMarkerOverlay::~SdrDropMarkerOverlay()
+{
+ // The OverlayObjects are cleared using the destructor of OverlayObjectList.
+ // That destructor calls clear() at the list which removes all objects from the
+ // OverlayManager and deletes them.
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// @@ @@ @@ @@@@@ @@ @@
+// @@ @@ @@ @@ @@ @@
+// @@ @@ @@ @@ @@ @ @@
+// @@@@@ @@ @@@@ @@@@@@@
+// @@@ @@ @@ @@@@@@@
+// @@@ @@ @@ @@@ @@@
+// @ @@ @@@@@ @@ @@
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+TYPEINIT1(SdrView,SdrCreateView);
+
+SdrView::SdrView(SdrModel* pModel1, OutputDevice* pOut)
+: SdrCreateView(pModel1,pOut),
+ bNoExtendedMouseDispatcher(FALSE),
+ bNoExtendedKeyDispatcher(FALSE),
+ bNoExtendedCommandDispatcher(FALSE),
+ mbMasterPagePaintCaching(sal_False)
+{
+ bTextEditOnObjectsWithoutTextIfTextTool=FALSE;
+
+ maAccessibilityOptions.AddListener(this);
+
+ onAccessibilityOptionsChanged();
+}
+
+SdrView::~SdrView()
+{
+ maAccessibilityOptions.RemoveListener(this);
+}
+
+BOOL SdrView::KeyInput(const KeyEvent& rKEvt, Window* pWin)
+{
+ SetActualWin(pWin);
+ BOOL bRet=SdrCreateView::KeyInput(rKEvt,pWin);
+ if (!bRet && !IsExtendedKeyInputDispatcherEnabled()) {
+ bRet=TRUE;
+ switch (rKEvt.GetKeyCode().GetFullFunction()) {
+ case KEYFUNC_CUT : Cut(); break;
+ case KEYFUNC_COPY : Yank(); break;
+ case KEYFUNC_PASTE : Paste(pWin); break;
+ case KEYFUNC_DELETE: DeleteMarked(); break;
+ case KEYFUNC_UNDO: pMod->Undo(); break;
+ case KEYFUNC_REDO: pMod->Redo(); break;
+ case KEYFUNC_REPEAT: pMod->Repeat(*this); break;
+ default: {
+ switch (rKEvt.GetKeyCode().GetFullCode()) {
+ case KEY_ESCAPE: {
+ if (IsTextEdit()) SdrEndTextEdit();
+ if (IsAction()) BrkAction();
+ if (pWin!=NULL) pWin->ReleaseMouse();
+ } break;
+ case KEY_DELETE: DeleteMarked(); break;
+ case KEY_CUT: case KEY_DELETE+KEY_SHIFT: Cut(); break;
+ case KEY_COPY: case KEY_INSERT+KEY_MOD1: Yank(); break;
+ case KEY_PASTE: case KEY_INSERT+KEY_SHIFT: Paste(pWin); break;
+ case KEY_UNDO: case KEY_BACKSPACE+KEY_MOD2: pMod->Undo(); break;
+ case KEY_BACKSPACE+KEY_MOD2+KEY_SHIFT: pMod->Redo(); break;
+ case KEY_REPEAT: case KEY_BACKSPACE+KEY_MOD2+KEY_MOD1: pMod->Repeat(*this); break;
+ case KEY_MOD1+KEY_A: MarkAll(); break;
+ default: bRet=FALSE;
+ } // switch
+ }
+ } // switch
+ if (bRet && pWin!=NULL) {
+ pWin->SetPointer(GetPreferedPointer(
+ pWin->PixelToLogic(pWin->ScreenToOutputPixel( pWin->GetPointerPosPixel() ) ),
+ pWin,
+ rKEvt.GetKeyCode().GetModifier()));
+ }
+ }
+ return bRet;
+}
+
+BOOL SdrView::MouseButtonDown(const MouseEvent& rMEvt, Window* pWin)
+{
+ SetActualWin(pWin);
+ if (rMEvt.IsLeft()) aDragStat.SetMouseDown(TRUE);
+ BOOL bRet=SdrCreateView::MouseButtonDown(rMEvt,pWin);
+ if (!bRet && !IsExtendedMouseEventDispatcherEnabled()) {
+ SdrViewEvent aVEvt;
+ PickAnything(rMEvt,SDRMOUSEBUTTONDOWN,aVEvt);
+ bRet=DoMouseEvent(aVEvt);
+ }
+ return bRet;
+}
+
+BOOL SdrView::MouseButtonUp(const MouseEvent& rMEvt, Window* pWin)
+{
+ SetActualWin(pWin);
+ if (rMEvt.IsLeft()) aDragStat.SetMouseDown(FALSE);
+ BOOL bAction=IsAction();
+ BOOL bRet=!bAction && SdrCreateView::MouseButtonUp(rMEvt,pWin);
+ if (!bRet && !IsExtendedMouseEventDispatcherEnabled()) {
+ SdrViewEvent aVEvt;
+ PickAnything(rMEvt,SDRMOUSEBUTTONUP,aVEvt);
+ bRet=DoMouseEvent(aVEvt);
+ }
+ return bRet;
+}
+
+BOOL SdrView::MouseMove(const MouseEvent& rMEvt, Window* pWin)
+{
+ SetActualWin(pWin);
+ aDragStat.SetMouseDown(rMEvt.IsLeft());
+ BOOL bRet=SdrCreateView::MouseMove(rMEvt,pWin);
+ if (!IsExtendedMouseEventDispatcherEnabled() && !IsTextEditInSelectionMode()) {
+ SdrViewEvent aVEvt;
+ PickAnything(rMEvt,SDRMOUSEMOVE,aVEvt);
+ if (DoMouseEvent(aVEvt)) bRet=TRUE;
+ }
+
+ // #87792# Removed code which did let the mouse snap on object
+ // points
+
+ return bRet;
+}
+
+BOOL SdrView::Command(const CommandEvent& rCEvt, Window* pWin)
+{
+ SetActualWin(pWin);
+ BOOL bRet=SdrCreateView::Command(rCEvt,pWin);
+ return bRet;
+}
+
+/* new interface src537 */
+BOOL SdrView::GetAttributes(SfxItemSet& rTargetSet, BOOL bOnlyHardAttr) const
+{
+ return SdrCreateView::GetAttributes(rTargetSet, bOnlyHardAttr);
+}
+
+SfxStyleSheet* SdrView::GetStyleSheet() const
+{
+ //BOOL bOk=FALSE;
+ return SdrCreateView::GetStyleSheet(); //bOk);
+}
+
+SdrHitKind SdrView::PickAnything(const MouseEvent& rMEvt, USHORT nEventKind, SdrViewEvent& rVEvt) const
+{
+ rVEvt.bMouseDown=nEventKind==SDRMOUSEBUTTONDOWN;
+ rVEvt.bMouseUp=nEventKind==SDRMOUSEBUTTONUP;
+ rVEvt.nMouseClicks=rMEvt.GetClicks();
+ rVEvt.nMouseMode=rMEvt.GetMode();
+ rVEvt.nMouseCode=rMEvt.GetButtons() | rMEvt.GetModifier();
+ const OutputDevice* pOut=pActualOutDev;
+ if (pOut==NULL)
+ {
+ pOut = GetFirstOutputDevice();
+ //pOut=GetWin(0);
+ }
+ Point aPnt(rMEvt.GetPosPixel());
+ if (pOut!=NULL) aPnt=pOut->PixelToLogic(aPnt);
+ rVEvt.aLogicPos=aPnt;
+ return PickAnything(aPnt,rVEvt);
+}
+
+// Mit der Maus draggen (Move)
+// Beispiel beim erzeugen eines Rechtecks. MouseDown muss ohne
+// ModKey erfolgen, weil sonst i.d.R. Markieren forciert wird (s.u.)
+// Drueckt man dann beim MouseMove gleichzeitig Shift, Ctrl, und Alt,
+// so erzeugt man ein zentrisches Quadrat ohne Fang.
+// Die Doppelbelegung von Ortho und Shift stellt i.d.R. kein Problem dar,
+// da sich beides meisst gegenseitig ausschliesst. Einzig Shear (das beim
+// Verzerren, nicht dass beim Drehen) beruecksichtigt beides gleichzeitig.
+// Dass muss der Anwender erstmal noch umschiffen (z.B. mit einer Hilfslinie).
+#define MODKEY_NoSnap bCtrl /* Fang temporaer aus */
+#define MODKEY_Ortho bShift /* na eben ortho */
+#define MODKEY_Center bAlt /* Zentrisch erzeugen/resizen */
+#define MODKEY_AngleSnap bShift
+#define MODKEY_CopyDrag bCtrl /* Draggen mit kopieren */
+
+// irgendwo hinklicken (MouseDown)
+#define MODKEY_PolyPoly bAlt /* Neues Poly bei InsPt und bei Create */
+#define MODKEY_MultiMark bShift /* MarkObj ohne vorher UnmarkAll */
+#define MODKEY_Unmark bAlt /* Unmark durch Rahmenaufziehen */
+#define MODKEY_ForceMark bCtrl /* Rahmenaufziehen erzwingen, auch wenn Obj an MausPos */
+#define MODKEY_DeepMark bAlt /* MarkNextObj */
+#define MODKEY_DeepBackw bShift /* MarkNextObj rueckwaerts */
+
+SdrHitKind SdrView::PickAnything(const Point& rLogicPos, SdrViewEvent& rVEvt) const
+{
+ const OutputDevice* pOut=pActualOutDev;
+ if (pOut==NULL)
+ {
+ pOut = GetFirstOutputDevice();
+ //pOut=GetWin(0);
+ }
+
+ // #i73628# Use a non-changeable copy of he logic pos
+ const Point aLocalLogicPosition(rLogicPos);
+
+ BOOL bEditMode=IsEditMode();
+ BOOL bPointMode=bEditMode && HasMarkablePoints();
+ BOOL bGluePointMode=IsGluePointEditMode();
+ BOOL bInsPolyPt=bPointMode && IsInsObjPointMode() && IsInsObjPointPossible();
+ BOOL bInsGluePt=bGluePointMode && IsInsGluePointMode() && IsInsGluePointPossible();
+ BOOL bIsTextEdit=IsTextEdit();
+ BOOL bTextEditHit=IsTextEditHit(aLocalLogicPosition,0/*nHitTolLog*/);
+ BOOL bTextEditSel=IsTextEditInSelectionMode();
+ BOOL bShift=(rVEvt.nMouseCode & KEY_SHIFT) !=0;
+ BOOL bCtrl=(rVEvt.nMouseCode & KEY_MOD1) !=0;
+ BOOL bAlt=(rVEvt.nMouseCode & KEY_MOD2) !=0;
+ SdrHitKind eHit=SDRHIT_NONE;
+ SdrHdl* pHdl=pOut!=NULL && !bTextEditSel ? PickHandle(aLocalLogicPosition) : NULL;
+ SdrPageView* pPV=NULL;
+ SdrObject* pObj=NULL;
+ SdrObject* pHitObj=NULL;
+ USHORT nHitPassNum=0;
+ USHORT nHlplIdx=0;
+ USHORT nGlueId=0;
+ BOOL bUnmarkedObjHit=FALSE;
+ if (bTextEditHit || bTextEditSel)
+ {
+ eHit=SDRHIT_TEXTEDIT;
+ bTextEditHit=TRUE;
+ }
+ else if (pHdl!=NULL)
+ {
+ eHit=SDRHIT_HANDLE; // Handle getroffen hat hoechste Prioritaet
+ }
+ else if (bEditMode && IsHlplVisible() && IsHlplFront() && pOut!=NULL && PickHelpLine(aLocalLogicPosition,nHitTolLog,*pOut,nHlplIdx,pPV))
+ {
+ eHit=SDRHIT_HELPLINE; // Hilfslinie im Vordergrund getroffen zum verschieben
+ }
+ else if (bGluePointMode && PickGluePoint(aLocalLogicPosition,pObj,nGlueId,pPV))
+ {
+ eHit=SDRHIT_GLUEPOINT; // nichtmarkierter Klebepunkt getroffen
+ }
+ else if (PickObj(aLocalLogicPosition,nHitTolLog,pHitObj,pPV,SDRSEARCH_DEEP|SDRSEARCH_MARKED,&pObj,NULL,&nHitPassNum))
+ {
+ eHit=SDRHIT_MARKEDOBJECT;
+ ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( pObj );
+ if( pTableObj )
+ {
+ sal_Int32 nX = 0, nY = 0;
+ switch( pTableObj->CheckTableHit( aLocalLogicPosition, nX, nY, 0 ) )
+ {
+ case sdr::table::SDRTABLEHIT_CELL:
+ eHit = SDRHIT_CELL;
+ break;
+ case sdr::table::SDRTABLEHIT_CELLTEXTAREA:
+ eHit = SDRHIT_TEXTEDITOBJ;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ else if (PickObj(aLocalLogicPosition,nHitTolLog,pHitObj,pPV,SDRSEARCH_DEEP|/*SDRSEARCH_TESTMARKABLE|*/SDRSEARCH_ALSOONMASTER|SDRSEARCH_WHOLEPAGE,&pObj,NULL,&nHitPassNum))
+ {
+ // MasterPages und WholePage fuer Macro und URL
+ eHit=SDRHIT_UNMARKEDOBJECT;
+ ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( pObj );
+ if( pTableObj )
+ {
+ sal_Int32 nX = 0, nY = 0;
+ switch( pTableObj->CheckTableHit( aLocalLogicPosition, nX, nY, 0 ) )
+ {
+ case sdr::table::SDRTABLEHIT_CELL:
+ eHit = SDRHIT_CELL;
+ break;
+ case sdr::table::SDRTABLEHIT_CELLTEXTAREA:
+ eHit = SDRHIT_TEXTEDITOBJ;
+ break;
+ default:
+ break;
+ }
+ }
+ bUnmarkedObjHit=TRUE;
+ }
+ else if (bEditMode && IsHlplVisible() && !IsHlplFront() && pOut!=NULL && PickHelpLine(aLocalLogicPosition,nHitTolLog,*pOut,nHlplIdx,pPV))
+ {
+ eHit=SDRHIT_HELPLINE; // Hilfslinie im Vordergrund getroffen zum verschieben
+ }
+ if (IsMacroMode() && eHit==SDRHIT_UNMARKEDOBJECT)
+ {
+ bool bRoot=pObj->HasMacro();
+ BOOL bDeep=pObj!=pHitObj && pHitObj->HasMacro();
+ BOOL bMid=FALSE; // Gruppierte Gruppe mit Macro getroffen?
+ SdrObject* pMidObj=NULL;
+ if (pObj!=pHitObj)
+ {
+ SdrObject* pObjTmp=NULL;
+ pObjTmp=pHitObj->GetUpGroup();
+ if (pObjTmp==pObj) pObjTmp=NULL;
+ while (pObjTmp!=NULL)
+ {
+ if (pObjTmp->HasMacro())
+ {
+ bMid=TRUE;
+ pMidObj=pObjTmp;
+ }
+ pObjTmp=pObjTmp->GetUpGroup();
+ if (pObjTmp==pObj) pObjTmp=NULL;
+ }
+ }
+
+ if (bDeep || bMid || bRoot)
+ {
+ SdrObjMacroHitRec aHitRec;
+ aHitRec.aPos=aLocalLogicPosition;
+ aHitRec.aDownPos=aLocalLogicPosition;
+ aHitRec.nTol=nHitTolLog;
+ aHitRec.pVisiLayer=&pPV->GetVisibleLayers();
+ aHitRec.pPageView=pPV;
+ if (bDeep) bDeep=pHitObj->IsMacroHit(aHitRec);
+ if (bMid ) bMid =pMidObj->IsMacroHit(aHitRec);
+ if (bRoot) bRoot=pObj->IsMacroHit(aHitRec);
+ if (bRoot || bMid || bDeep)
+ {
+ // Prio: 1.Root, 2.Mid, 3.Deep
+ rVEvt.pRootObj=pObj;
+ if (!bRoot) pObj=pMidObj;
+ if (!bRoot && !bMid) pObj=pHitObj;
+ eHit=SDRHIT_MACRO;
+ }
+ }
+ }
+ // auf URL-Field checken
+ if (IsMacroMode() && eHit==SDRHIT_UNMARKEDOBJECT)
+ {
+ SdrTextObj* pTextObj=PTR_CAST(SdrTextObj,pHitObj);
+ if (pTextObj!=NULL && pTextObj->HasText())
+ {
+ bool bTEHit(pPV &&
+ SdrObjectPrimitiveHit(*pTextObj, aLocalLogicPosition, 0, *pPV, &pPV->GetVisibleLayers(), true));
+
+ if (bTEHit)
+ {
+ Rectangle aTextRect;
+ Rectangle aAnchor;
+ SdrOutliner* pOutliner = &pTextObj->ImpGetDrawOutliner();
+ if( pTextObj->GetModel() )
+ pOutliner = &pTextObj->GetModel()->GetHitTestOutliner();
+
+ pTextObj->TakeTextRect( *pOutliner, aTextRect, FALSE, &aAnchor, FALSE );
+
+ // #i73628# Use a text-relative position for hit test in hit test outliner
+ Point aTemporaryTextRelativePosition(aLocalLogicPosition - aTextRect.TopLeft());
+
+ // FitToSize berueksichtigen
+ BOOL bFitToSize(pTextObj->IsFitToSize());
+ if (bFitToSize) {
+ Fraction aX(aTextRect.GetWidth()-1,aAnchor.GetWidth()-1);
+ Fraction aY(aTextRect.GetHeight()-1,aAnchor.GetHeight()-1);
+ ResizePoint(aTemporaryTextRelativePosition,Point(),aX,aY);
+ }
+ // Drehung berueksichtigen
+ const GeoStat& rGeo=pTextObj->GetGeoStat();
+ if (rGeo.nDrehWink!=0) RotatePoint(aTemporaryTextRelativePosition,Point(),-rGeo.nSin,rGeo.nCos); // -sin fuer Unrotate
+ // Laufschrift berueksichtigen fehlt noch ...
+ if(pActualOutDev && pActualOutDev->GetOutDevType() == OUTDEV_WINDOW)
+ {
+ OutlinerView aOLV(pOutliner, (Window*)pActualOutDev);
+ const EditView& aEV=aOLV.GetEditView();
+ const SvxFieldItem* pItem=aEV.GetField(aTemporaryTextRelativePosition);
+ if (pItem!=NULL) {
+ const SvxFieldData* pFld=pItem->GetField();
+ const SvxURLField* pURL=PTR_CAST(SvxURLField,pFld);
+ if (pURL!=NULL) {
+ eHit=SDRHIT_URLFIELD;
+ rVEvt.pURLField=pURL;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (nHitPassNum==SDRSEARCHPASS_DIRECT &&
+ (eHit==SDRHIT_MARKEDOBJECT || eHit==SDRHIT_UNMARKEDOBJECT) &&
+ (IsTextTool() || (IsEditMode() && IsQuickTextEditMode())) && pHitObj->HasTextEdit())
+ {
+ // Ringsum die TextEditArea ein Rand zum Selektieren ohne Textedit
+ Rectangle aBoundRect(pHitObj->GetCurrentBoundRect());
+
+ // #105130# Force to SnapRect when Fontwork
+ if(pHitObj->ISA(SdrTextObj) && ((SdrTextObj*)pHitObj)->IsFontwork())
+ {
+ aBoundRect = pHitObj->GetSnapRect();
+ }
+
+ // #105130# Old test for hit on BoundRect is completely wrong
+ // and never worked, doing it new here.
+ sal_Int32 nTolerance(nHitTolLog);
+ sal_Bool bBoundRectHit(sal_False);
+
+ if(pOut)
+ {
+ nTolerance = pOut->PixelToLogic(Size(2, 0)).Width();
+ }
+
+ if( (aLocalLogicPosition.X() >= aBoundRect.Left() - nTolerance && aLocalLogicPosition.X() <= aBoundRect.Left() + nTolerance)
+ || (aLocalLogicPosition.X() >= aBoundRect.Right() - nTolerance && aLocalLogicPosition.X() <= aBoundRect.Right() + nTolerance)
+ || (aLocalLogicPosition.Y() >= aBoundRect.Top() - nTolerance && aLocalLogicPosition.Y() <= aBoundRect.Top() + nTolerance)
+ || (aLocalLogicPosition.Y() >= aBoundRect.Bottom() - nTolerance && aLocalLogicPosition.Y() <= aBoundRect.Bottom() + nTolerance))
+ {
+ bBoundRectHit = sal_True;
+ }
+
+ if(!bBoundRectHit)
+ {
+ bool bTEHit(pPV &&
+ SdrObjectPrimitiveHit(*pHitObj, aLocalLogicPosition, 0, *pPV, &pPV->GetVisibleLayers(), true));
+
+ // TextEdit an Objekten im gesperrten Layer
+ if (pPV->GetLockedLayers().IsSet(pHitObj->GetLayer()))
+ {
+ bTEHit=FALSE;
+ }
+
+ if (bTEHit)
+ {
+ rVEvt.pRootObj=pObj;
+ pObj=pHitObj;
+ eHit=SDRHIT_TEXTEDITOBJ;
+ }
+ }
+ }
+ if (nHitPassNum!=SDRSEARCHPASS_DIRECT && eHit==SDRHIT_UNMARKEDOBJECT) {
+ eHit=SDRHIT_NONE;
+ pObj=NULL;
+ pPV=NULL;
+ }
+ BOOL bMouseLeft=(rVEvt.nMouseCode&MOUSE_LEFT)!=0;
+ BOOL bMouseRight=(rVEvt.nMouseCode&MOUSE_RIGHT)!=0;
+ BOOL bMouseDown=rVEvt.bMouseDown;
+ BOOL bMouseUp=rVEvt.bMouseUp;
+ SdrEventKind eEvent=SDREVENT_NONE;
+ BOOL bIsAction=IsAction();
+
+ if (bIsAction)
+ {
+ if (bMouseDown)
+ {
+ if (bMouseRight) eEvent=SDREVENT_BCKACTION;
+ }
+ else if (bMouseUp)
+ {
+ if (bMouseLeft)
+ {
+ eEvent=SDREVENT_ENDACTION;
+ if (IsDragObj())
+ {
+ eEvent=SDREVENT_ENDDRAG;
+ rVEvt.bDragWithCopy=MODKEY_CopyDrag;
+ }
+ else if (IsCreateObj() || IsInsObjPoint())
+ {
+ eEvent=IsCreateObj() ? SDREVENT_ENDCREATE : SDREVENT_ENDINSOBJPOINT;
+ rVEvt.eEndCreateCmd=SDRCREATE_NEXTPOINT;
+ if (MODKEY_PolyPoly) rVEvt.eEndCreateCmd=SDRCREATE_NEXTOBJECT;
+ if (rVEvt.nMouseClicks>1) rVEvt.eEndCreateCmd=SDRCREATE_FORCEEND;
+ }
+ else if (IsMarking())
+ {
+ eEvent=SDREVENT_ENDMARK;
+ if (!aDragStat.IsMinMoved())
+ {
+ eEvent=SDREVENT_BRKMARK;
+ rVEvt.bAddMark=MODKEY_MultiMark;
+ }
+ }
+ }
+ }
+ else
+ {
+ eEvent=SDREVENT_MOVACTION;
+ }
+ }
+ else if (eHit==SDRHIT_TEXTEDIT)
+ {
+ eEvent=SDREVENT_TEXTEDIT;
+ }
+ else if (bMouseDown && bMouseLeft)
+ {
+ if (rVEvt.nMouseClicks==2 && rVEvt.nMouseCode==MOUSE_LEFT && pObj!=NULL && pHitObj!=NULL && pHitObj->HasTextEdit() && eHit==SDRHIT_MARKEDOBJECT)
+ {
+ rVEvt.pRootObj=pObj;
+ pObj=pHitObj;
+ eEvent=SDREVENT_BEGTEXTEDIT;
+ }
+ else if (MODKEY_ForceMark && eHit!=SDRHIT_URLFIELD)
+ {
+ eEvent=SDREVENT_BEGMARK; // AddMark,Unmark */
+ }
+ else if (eHit==SDRHIT_HELPLINE)
+ {
+ eEvent=SDREVENT_BEGDRAGHELPLINE; // nix weiter
+ }
+ else if (eHit==SDRHIT_GLUEPOINT)
+ {
+ eEvent=SDREVENT_MARKGLUEPOINT; // AddMark+Drag
+ rVEvt.bAddMark=MODKEY_MultiMark || MODKEY_DeepMark; // falls bei Deep nicht getroffen
+ }
+ else if (eHit==SDRHIT_HANDLE)
+ {
+ eEvent=SDREVENT_BEGDRAGOBJ; // Mark+Drag,AddMark+Drag,DeepMark+Drag,Unmark
+ BOOL bGlue=pHdl->GetKind()==HDL_GLUE;
+ BOOL bPoly=!bGlue && IsPointMarkable(*pHdl);
+ BOOL bMarked=bGlue || (bPoly && pHdl->IsSelected());
+ if (bGlue || bPoly)
+ {
+ eEvent=bGlue ? SDREVENT_MARKGLUEPOINT : SDREVENT_MARKPOINT;
+ if (MODKEY_DeepMark)
+ {
+ rVEvt.bAddMark=TRUE;
+ rVEvt.bPrevNextMark=TRUE;
+ rVEvt.bMarkPrev=MODKEY_DeepBackw;
+ }
+ else if (MODKEY_MultiMark)
+ {
+ rVEvt.bAddMark=TRUE;
+ rVEvt.bUnmark=bMarked; // Toggle
+ if (bGlue)
+ {
+ pObj=pHdl->GetObj();
+ nGlueId=(sal_uInt16)pHdl->GetObjHdlNum();
+ }
+ }
+ else if (bMarked)
+ {
+ eEvent=SDREVENT_BEGDRAGOBJ; // MarkState nicht aendern, nur Drag
+ }
+ }
+ }
+ else if (bInsPolyPt && (MODKEY_PolyPoly || (!MODKEY_MultiMark && !MODKEY_DeepMark)))
+ {
+ eEvent=SDREVENT_BEGINSOBJPOINT;
+ rVEvt.bInsPointNewObj=MODKEY_PolyPoly;
+ }
+ else if (bInsGluePt && !MODKEY_MultiMark && !MODKEY_DeepMark)
+ {
+ eEvent=SDREVENT_BEGINSGLUEPOINT;
+ }
+ else if (eHit==SDRHIT_TEXTEDITOBJ)
+ {
+ eEvent=SDREVENT_BEGTEXTEDIT; // AddMark+Drag,DeepMark+Drag,Unmark
+ if (MODKEY_MultiMark || MODKEY_DeepMark)
+ { // falls bei Deep nicht getroffen
+ eEvent=SDREVENT_MARKOBJ;
+ }
+ }
+ else if (eHit==SDRHIT_MACRO)
+ {
+ eEvent=SDREVENT_BEGMACROOBJ; // AddMark+Drag
+ if (MODKEY_MultiMark || MODKEY_DeepMark)
+ { // falls bei Deep nicht getroffen
+ eEvent=SDREVENT_MARKOBJ;
+ }
+ }
+ else if (eHit==SDRHIT_URLFIELD)
+ {
+ eEvent=SDREVENT_EXECUTEURL; // AddMark+Drag
+ if (MODKEY_MultiMark || MODKEY_DeepMark)
+ { // falls bei Deep nicht getroffen
+ eEvent=SDREVENT_MARKOBJ;
+ }
+ }
+ else if (eHit==SDRHIT_MARKEDOBJECT)
+ {
+ eEvent=SDREVENT_BEGDRAGOBJ; // DeepMark+Drag,Unmark
+
+ if (MODKEY_MultiMark || MODKEY_DeepMark)
+ { // falls bei Deep nicht getroffen
+ eEvent=SDREVENT_MARKOBJ;
+ }
+ }
+ else if (IsCreateMode())
+ {
+ eEvent=SDREVENT_BEGCREATEOBJ; // Nix weiter
+ }
+ else if (eHit==SDRHIT_UNMARKEDOBJECT)
+ {
+ eEvent=SDREVENT_MARKOBJ; // AddMark+Drag
+ }
+ else
+ {
+ eEvent=SDREVENT_BEGMARK;
+ }
+
+ if (eEvent==SDREVENT_MARKOBJ)
+ {
+ rVEvt.bAddMark=MODKEY_MultiMark || MODKEY_DeepMark; // falls bei Deep nicht getroffen
+ rVEvt.bPrevNextMark=MODKEY_DeepMark;
+ rVEvt.bMarkPrev=MODKEY_DeepMark && MODKEY_DeepBackw;
+ }
+ if (eEvent==SDREVENT_BEGMARK)
+ {
+ rVEvt.bAddMark=MODKEY_MultiMark;
+ rVEvt.bUnmark=MODKEY_Unmark;
+ }
+ }
+ rVEvt.bIsAction=bIsAction;
+ rVEvt.bIsTextEdit=bIsTextEdit;
+ rVEvt.bTextEditHit=bTextEditHit;
+ rVEvt.aLogicPos=aLocalLogicPosition;
+ rVEvt.pHdl=pHdl;
+ rVEvt.pObj=pObj;
+ if(rVEvt.pRootObj==NULL)
+ rVEvt.pRootObj=pObj;
+ rVEvt.pPV=pPV;
+ rVEvt.nHlplIdx=nHlplIdx;
+ rVEvt.nGlueId=nGlueId;
+ rVEvt.eHit=eHit;
+ rVEvt.eEvent=eEvent;
+ rVEvt.bCaptureMouse=bMouseLeft && bMouseDown && eEvent!=SDREVENT_NONE;
+ rVEvt.bReleaseMouse=bMouseLeft && bMouseUp;
+#ifdef DGB_UTIL
+ if (rVEvt.pRootObj!=NULL) {
+ if (rVEvt.pRootObj->GetObjList()!=rVEvt.pPV->GetObjList()) {
+ DBG_ERROR("SdrView::PickAnything(): pRootObj->GetObjList()!=pPV->GetObjList() !");
+ }
+ }
+#endif
+ return eHit;
+}
+
+BOOL SdrView::DoMouseEvent(const SdrViewEvent& rVEvt)
+{
+ BOOL bRet=FALSE;
+ SdrHitKind eHit=rVEvt.eHit;
+ Point aLogicPos(rVEvt.aLogicPos);
+
+ BOOL bShift=(rVEvt.nMouseCode & KEY_SHIFT) !=0;
+ BOOL bCtrl=(rVEvt.nMouseCode & KEY_MOD1) !=0;
+ BOOL bAlt=(rVEvt.nMouseCode & KEY_MOD2) !=0;
+ BOOL bMouseLeft=(rVEvt.nMouseCode&MOUSE_LEFT)!=0;
+ //BOOL bMouseRight=(rVEvt.nMouseCode&MOUSE_RIGHT)!=0;
+ BOOL bMouseDown=rVEvt.bMouseDown;
+ BOOL bMouseUp=rVEvt.bMouseUp;
+ if (bMouseDown) {
+ if (bMouseLeft) aDragStat.SetMouseDown(TRUE);
+ } else if (bMouseUp) {
+ if (bMouseLeft) aDragStat.SetMouseDown(FALSE);
+ } else { // ansonsten MoueMove
+ aDragStat.SetMouseDown(bMouseLeft);
+ }
+
+#ifdef MODKEY_NoSnap
+ SetSnapEnabled(!MODKEY_NoSnap);
+#endif
+#ifdef MODKEY_Ortho
+ SetOrtho(MODKEY_Ortho!=IsOrthoDesired());
+#endif
+#ifdef MODKEY_BigOrtho
+ SetBigOrtho(MODKEY_BigOrtho);
+#endif
+#ifdef MODKEY_AngleSnap
+ SetAngleSnapEnabled(MODKEY_AngleSnap);
+#endif
+#ifdef MODKEY_CopyDrag
+ SetDragWithCopy(MODKEY_CopyDrag);
+#endif
+#ifdef MODKEY_Center
+ SetCreate1stPointAsCenter(MODKEY_Center);
+ SetResizeAtCenter(MODKEY_Center);
+ SetCrookAtCenter(MODKEY_Center);
+#endif
+ if (bMouseLeft && bMouseDown && rVEvt.bIsTextEdit && (eHit==SDRHIT_UNMARKEDOBJECT || eHit==SDRHIT_NONE)) {
+ SdrEndTextEdit(); // Danebengeklickt, Ende mit Edit
+ // pHdl ist dann ungueltig. Sollte aber egal sein, wein pHdl==NULL
+ // sein muesste (wg. eHit).
+ }
+ switch (rVEvt.eEvent) {
+ case SDREVENT_NONE: bRet=FALSE; break;
+ case SDREVENT_TEXTEDIT: bRet=FALSE; break; // Events an die OutlinerView werden hier nicht beruecksichtigt
+ case SDREVENT_MOVACTION: MovAction(aLogicPos); bRet=TRUE; break;
+ case SDREVENT_ENDACTION: EndAction(); bRet=TRUE; break;
+ case SDREVENT_BCKACTION: BckAction(); bRet=TRUE; break;
+ case SDREVENT_BRKACTION: BrkAction(); bRet=TRUE; break;
+ case SDREVENT_ENDMARK : EndAction(); bRet=TRUE; break;
+ case SDREVENT_BRKMARK : {
+ BrkAction();
+ if (!MarkObj(aLogicPos,nHitTolLog,rVEvt.bAddMark)) {
+ // Kein Obj getroffen. Dann werden zuerst
+ // - Markierte Klebepunkte deselektiert
+ // - dann ggf. selektierte Polygonpunkte
+ // - und ansonsten Objekte
+ if (!rVEvt.bAddMark) UnmarkAll();
+ }
+ bRet=TRUE;
+ } break;
+ case SDREVENT_ENDCREATE: { // ggf. MarkObj
+ SdrCreateCmd eCmd=SDRCREATE_NEXTPOINT;
+ if (MODKEY_PolyPoly) eCmd=SDRCREATE_NEXTOBJECT;
+ if (rVEvt.nMouseClicks>1) eCmd=SDRCREATE_FORCEEND;
+ if (!EndCreateObj(eCmd)) { // Event fuer Create nicht ausgewerten? -> Markieren
+ if (eHit==SDRHIT_UNMARKEDOBJECT || eHit==SDRHIT_TEXTEDIT) {
+ MarkObj(rVEvt.pRootObj,rVEvt.pPV);
+ if (eHit==SDRHIT_TEXTEDIT)
+ {
+ BOOL bRet2(pActualOutDev && OUTDEV_WINDOW == pActualOutDev->GetOutDevType() &&
+ SdrBeginTextEdit(rVEvt.pObj, rVEvt.pPV, (Window*)pActualOutDev, sal_False, (SdrOutliner*)0L));
+
+ if(bRet2)
+ {
+ MouseEvent aMEvt(pActualOutDev->LogicToPixel(aLogicPos),
+ 1,rVEvt.nMouseMode,rVEvt.nMouseCode,rVEvt.nMouseCode);
+
+ OutlinerView* pOLV=GetTextEditOutlinerView();
+ if (pOLV!=NULL) {
+ pOLV->MouseButtonDown(aMEvt); // Event an den Outliner, aber ohne Doppelklick
+ pOLV->MouseButtonUp(aMEvt); // Event an den Outliner, aber ohne Doppelklick
+ }
+ }
+ }
+ bRet=TRUE; // Obj markiert und ggf. TextEdit gestartet
+ } else bRet=FALSE; // Create abgebrochen, sonst nix weiter.
+ } else bRet=TRUE; // EndCreate mit TRUE returniert
+ } break;
+ case SDREVENT_ENDDRAG: {
+ bRet=EndDragObj(IsDragWithCopy());
+ ForceMarkedObjToAnotherPage(); // Undo+Klammerung fehlt noch !!!
+ } break;
+ case SDREVENT_MARKOBJ: { // + ggf. BegDrag
+ if (!rVEvt.bAddMark) UnmarkAllObj();
+ BOOL bUnmark=rVEvt.bUnmark;
+ if (rVEvt.bPrevNextMark) {
+ bRet=MarkNextObj(aLogicPos,nHitTolLog,rVEvt.bMarkPrev);
+ } else {
+ SortMarkedObjects();
+ ULONG nAnz0=GetMarkedObjectCount();
+ bRet=MarkObj(aLogicPos,nHitTolLog,rVEvt.bAddMark);
+ SortMarkedObjects();
+ ULONG nAnz1=GetMarkedObjectCount();
+ bUnmark=nAnz1<nAnz0;
+ }
+ if (!bUnmark) {
+ BegDragObj(aLogicPos,NULL,(SdrHdl*)NULL,nMinMovLog);
+ bRet=TRUE;
+ }
+ } break;
+ case SDREVENT_MARKPOINT: { // + ggf. BegDrag
+ if (!rVEvt.bAddMark) UnmarkAllPoints();
+ if (rVEvt.bPrevNextMark) {
+ bRet=MarkNextPoint(aLogicPos,rVEvt.bMarkPrev);
+ } else {
+ bRet=MarkPoint(*rVEvt.pHdl,rVEvt.bUnmark);
+ }
+ if (!rVEvt.bUnmark && !rVEvt.bPrevNextMark) {
+ BegDragObj(aLogicPos,NULL,rVEvt.pHdl,nMinMovLog);
+ bRet=TRUE;
+ }
+ } break;
+ case SDREVENT_MARKGLUEPOINT: { // + ggf. BegDrag
+ if (!rVEvt.bAddMark) UnmarkAllGluePoints();
+ if (rVEvt.bPrevNextMark) {
+ bRet=MarkNextGluePoint(aLogicPos,rVEvt.bMarkPrev);
+ } else {
+ bRet=MarkGluePoint(rVEvt.pObj,rVEvt.nGlueId,rVEvt.pPV,rVEvt.bUnmark);
+ }
+ if (!rVEvt.bUnmark && !rVEvt.bPrevNextMark) {
+ SdrHdl* pHdl=GetGluePointHdl(rVEvt.pObj,rVEvt.nGlueId);
+ BegDragObj(aLogicPos,NULL,pHdl,nMinMovLog);
+ bRet=TRUE;
+ }
+ } break;
+ case SDREVENT_BEGMARK: bRet=BegMark(aLogicPos,rVEvt.bAddMark,rVEvt.bUnmark); break;
+ case SDREVENT_BEGINSOBJPOINT: bRet = BegInsObjPoint(aLogicPos, MODKEY_PolyPoly); break;
+ case SDREVENT_ENDINSOBJPOINT: {
+ SdrCreateCmd eCmd=SDRCREATE_NEXTPOINT;
+ if (MODKEY_PolyPoly) eCmd=SDRCREATE_NEXTOBJECT;
+ if (rVEvt.nMouseClicks>1) eCmd=SDRCREATE_FORCEEND;
+ EndInsObjPoint(eCmd);
+ bRet=TRUE;
+ } break;
+ case SDREVENT_BEGINSGLUEPOINT: bRet=BegInsGluePoint(aLogicPos); break;
+ case SDREVENT_BEGDRAGHELPLINE: bRet=BegDragHelpLine(rVEvt.nHlplIdx,rVEvt.pPV); break;
+ case SDREVENT_BEGDRAGOBJ: bRet=BegDragObj(aLogicPos,NULL,rVEvt.pHdl,nMinMovLog); break;
+ case SDREVENT_BEGCREATEOBJ: {
+ if (nAktInvent==SdrInventor && nAktIdent==OBJ_CAPTION) {
+ long nHgt=SdrEngineDefaults::GetFontHeight();
+ bRet=BegCreateCaptionObj(aLogicPos,Size(5*nHgt,2*nHgt));
+ } else bRet=BegCreateObj(aLogicPos);
+ } break;
+ case SDREVENT_BEGMACROOBJ: bRet=BegMacroObj(aLogicPos,nHitTolLog,rVEvt.pObj,rVEvt.pPV,(Window*)pActualOutDev); break;
+ case SDREVENT_BEGTEXTEDIT: {
+ if (!IsObjMarked(rVEvt.pObj)) {
+ UnmarkAllObj();
+ MarkObj(rVEvt.pRootObj,rVEvt.pPV);
+ }
+
+ bRet = pActualOutDev && OUTDEV_WINDOW == pActualOutDev->GetOutDevType()&&
+ SdrBeginTextEdit(rVEvt.pObj, rVEvt.pPV, (Window*)pActualOutDev, sal_False, (SdrOutliner*)0L);
+
+ if(bRet)
+ {
+ MouseEvent aMEvt(pActualOutDev->LogicToPixel(aLogicPos),
+ 1,rVEvt.nMouseMode,rVEvt.nMouseCode,rVEvt.nMouseCode);
+ OutlinerView* pOLV=GetTextEditOutlinerView();
+ if (pOLV!=NULL) pOLV->MouseButtonDown(aMEvt); // Event an den Outliner, aber ohne Doppelklick
+ }
+ } break;
+ default: break;
+ } // switch
+ if (bRet && pActualOutDev!=NULL && pActualOutDev->GetOutDevType()==OUTDEV_WINDOW) {
+ Window* pWin=(Window*)pActualOutDev;
+ // Maus links gedrueckt?
+ BOOL bLeftDown=(rVEvt.nMouseCode&MOUSE_LEFT)!=0 && rVEvt.bMouseDown;
+ // Maus links losgelassen?
+ BOOL bLeftUp=(rVEvt.nMouseCode&MOUSE_LEFT)!=0 && rVEvt.bMouseUp;
+ // Maus links gedrueckt oder gehalten?
+ BOOL bLeftDown1=(rVEvt.nMouseCode&MOUSE_LEFT)!=0 && !rVEvt.bMouseUp;
+ pWin->SetPointer(GetPreferedPointer(rVEvt.aLogicPos,pWin,
+ rVEvt.nMouseCode & (KEY_SHIFT|KEY_MOD1|KEY_MOD2),bLeftDown1));
+ BOOL bAction=IsAction();
+ if (bLeftDown && bAction) pWin->CaptureMouse();
+ else if (bLeftUp || (rVEvt.bIsAction && !bAction)) pWin->ReleaseMouse();
+ }
+ return bRet;
+}
+#include <editeng/outlobj.hxx>
+
+Pointer SdrView::GetPreferedPointer(const Point& rMousePos, const OutputDevice* pOut, USHORT nModifier, BOOL bLeftDown) const
+{
+ // Actions
+ if (IsCreateObj())
+ {
+ return pAktCreate->GetCreatePointer();
+ }
+ if (mpCurrentSdrDragMethod)
+ {
+ if ((IsDraggingPoints() || IsDraggingGluePoints()) && IsMouseHideWhileDraggingPoints())
+ return Pointer(POINTER_NULL);
+
+ OSL_TRACE("SdrView::GetPreferedPointer(%lx) %lx\n", this, mpCurrentSdrDragMethod);
+
+ return mpCurrentSdrDragMethod->GetSdrDragPointer();
+ }
+ if (IsMarkObj() || IsMarkPoints() || IsMarkGluePoints() || IsEncirclement() || IsSetPageOrg()) return Pointer(POINTER_ARROW);
+ if (IsDragHelpLine()) return GetDraggedHelpLinePointer();
+ if (IsMacroObj()) {
+ SdrObjMacroHitRec aHitRec;
+ aHitRec.aPos=pOut->LogicToPixel(rMousePos);
+ aHitRec.aDownPos=aMacroDownPos;
+ aHitRec.nTol=nMacroTol;
+ aHitRec.pVisiLayer=&pMacroPV->GetVisibleLayers();
+ aHitRec.pPageView=pMacroPV;
+ aHitRec.pOut=pMacroWin;
+ aHitRec.bDown=bMacroDown;
+ return pMacroObj->GetMacroPointer(aHitRec);
+ }
+ //USHORT nTol=nHitTolLog;
+ // TextEdit, ObjEdit, Macro
+ if (IsTextEdit() && (IsTextEditInSelectionMode() || IsTextEditHit(rMousePos,0/*nTol*/)))
+ {
+ if(!pOut || IsTextEditInSelectionMode())
+ {
+ if(pTextEditOutliner->IsVertical())
+ return Pointer(POINTER_TEXT_VERTICAL);
+ else
+ return Pointer(POINTER_TEXT);
+ }
+ // hier muss besser der Outliner was liefern:
+ Point aPos(pOut->LogicToPixel(rMousePos));
+ Pointer aPointer(pTextEditOutlinerView->GetPointer(aPos));
+ if (aPointer==POINTER_ARROW)
+ {
+ if(pTextEditOutliner->IsVertical())
+ aPointer = POINTER_TEXT_VERTICAL;
+ else
+ aPointer = POINTER_TEXT;
+ }
+ return aPointer;
+ }
+
+ SdrViewEvent aVEvt;
+ aVEvt.nMouseCode=(nModifier&(KEY_SHIFT|KEY_MOD1|KEY_MOD2))|MOUSE_LEFT; // um zu sehen, was bei MouseLeftDown passieren wuerde
+ aVEvt.bMouseDown=!bLeftDown; // Was waere wenn ...
+ aVEvt.bMouseUp=bLeftDown; // Was waere wenn ...
+ if (pOut!=NULL)
+ ((SdrView*)this)->SetActualWin(pOut);
+ SdrHitKind eHit=PickAnything(rMousePos,aVEvt);
+ SdrEventKind eEvent=aVEvt.eEvent;
+ switch (eEvent)
+ {
+ case SDREVENT_BEGCREATEOBJ:
+ return aAktCreatePointer;
+ case SDREVENT_MARKOBJ:
+ case SDREVENT_BEGMARK:
+ return Pointer(POINTER_ARROW);
+ case SDREVENT_MARKPOINT:
+ case SDREVENT_MARKGLUEPOINT:
+ return Pointer(POINTER_MOVEPOINT);
+ case SDREVENT_BEGINSOBJPOINT:
+ case SDREVENT_BEGINSGLUEPOINT:
+ return Pointer(POINTER_CROSS);
+ case SDREVENT_EXECUTEURL:
+ return Pointer(POINTER_REFHAND);
+ case SDREVENT_BEGMACROOBJ:
+ {
+ SdrObjMacroHitRec aHitRec;
+ aHitRec.aPos=aVEvt.aLogicPos;
+ aHitRec.aDownPos=aHitRec.aPos;
+ aHitRec.nTol=nHitTolLog;
+ aHitRec.pVisiLayer=&aVEvt.pPV->GetVisibleLayers();
+ aHitRec.pPageView=aVEvt.pPV;
+ aHitRec.pOut=(OutputDevice*)pOut;
+ return aVEvt.pObj->GetMacroPointer(aHitRec);
+ }
+ default: break;
+ } // switch
+
+ switch(eHit)
+ {
+ case SDRHIT_CELL:
+ return Pointer(POINTER_ARROW);
+ case SDRHIT_HELPLINE :
+ return aVEvt.pPV->GetHelpLines()[aVEvt.nHlplIdx].GetPointer();
+ case SDRHIT_GLUEPOINT:
+ return Pointer(POINTER_MOVEPOINT);
+ case SDRHIT_TEXTEDIT :
+ case SDRHIT_TEXTEDITOBJ:
+ {
+ SdrTextObj* pText = dynamic_cast< SdrTextObj* >( aVEvt.pObj );
+ if(pText && pText->HasText())
+ {
+ OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject();
+ if(pParaObj && pParaObj->IsVertical())
+ return Pointer(POINTER_TEXT_VERTICAL);
+ }
+ return Pointer(POINTER_TEXT);
+ }
+ default: break;
+ }
+
+ BOOL bMarkHit=eHit==SDRHIT_MARKEDOBJECT;
+ SdrHdl* pHdl=aVEvt.pHdl;
+ // Nun die Pointer fuer Dragging checken
+ if (pHdl!=NULL || bMarkHit) {
+ SdrHdlKind eHdl= pHdl!=NULL ? pHdl->GetKind() : HDL_MOVE;
+ BOOL bCorner=pHdl!=NULL && pHdl->IsCornerHdl();
+ BOOL bVertex=pHdl!=NULL && pHdl->IsVertexHdl();
+ BOOL bMov=eHdl==HDL_MOVE;
+ if (bMov && (eDragMode==SDRDRAG_MOVE || eDragMode==SDRDRAG_RESIZE || bMarkedHitMovesAlways)) {
+ if (!IsMoveAllowed()) return Pointer(POINTER_ARROW); // weil Doppelklick oder Drag&Drop moeglich
+ return Pointer(POINTER_MOVE);
+ }
+ switch (eDragMode) {
+ case SDRDRAG_ROTATE: {
+ if ((bCorner || bMov) && !IsRotateAllowed(TRUE))
+ return Pointer(POINTER_NOTALLOWED);
+
+ // Sind 3D-Objekte selektiert?
+ BOOL b3DObjSelected = FALSE;
+#ifndef SVX_LIGHT
+ for (UINT32 a=0; !b3DObjSelected && a<GetMarkedObjectCount(); a++) {
+ SdrObject* pObj = GetMarkedObjectByIndex(a);
+ if(pObj && pObj->ISA(E3dObject))
+ b3DObjSelected = TRUE;
+ }
+#endif
+ // Falls es um ein 3D-Objekt geht, muss trotz !IsShearAllowed
+ // weitergemacht werden, da es sich um eine Rotation statt um
+ // einen Shear handelt
+ if (bVertex && !IsShearAllowed() && !b3DObjSelected)
+ return Pointer(POINTER_NOTALLOWED);
+ if (bMov)
+ return Pointer(POINTER_ROTATE);
+ } break;
+ case SDRDRAG_SHEAR: case SDRDRAG_DISTORT: {
+ if (bCorner) {
+ if (!IsDistortAllowed(TRUE) && !IsDistortAllowed(FALSE)) return Pointer(POINTER_NOTALLOWED);
+ else return Pointer(POINTER_REFHAND);
+ }
+ if (bVertex && !IsShearAllowed()) return Pointer(POINTER_NOTALLOWED);
+ if (bMov) {
+ if (!IsMoveAllowed()) return Pointer(POINTER_ARROW); // weil Doppelklick oder Drag&Drop moeglich
+ return Pointer(POINTER_MOVE);
+ }
+ } break;
+ case SDRDRAG_MIRROR: {
+ if (bCorner || bVertex || bMov) {
+ SdrHdl* pH1=aHdl.GetHdl(HDL_REF1);
+ SdrHdl* pH2=aHdl.GetHdl(HDL_REF2);
+ BOOL b90=FALSE;
+ BOOL b45=FALSE;
+ Point aDif;
+ if (pH1!=NULL && pH2!=NULL) {
+ aDif=pH2->GetPos()-pH1->GetPos();
+ b90=(aDif.X()==0) || aDif.Y()==0;
+ b45=b90 || (Abs(aDif.X())==Abs(aDif.Y()));
+ }
+ BOOL bNo=FALSE;
+ if (!IsMirrorAllowed(TRUE,TRUE)) bNo=TRUE; // Spiegeln ueberhaupt nicht erlaubt
+ if (!IsMirrorAllowed(FALSE,FALSE) && !b45) bNo=TRUE; // freies Spiegeln nicht erlaubt
+ if (!IsMirrorAllowed(TRUE,FALSE) && !b90) bNo=TRUE; // Spiegeln hor/ver erlaubt
+ if (bNo) return Pointer(POINTER_NOTALLOWED);
+ if (b90) {
+ return Pointer(POINTER_MIRROR);
+ }
+ return Pointer(POINTER_MIRROR);
+ }
+ } break;
+
+ case SDRDRAG_TRANSPARENCE:
+ {
+ if(!IsTransparenceAllowed())
+ return Pointer(POINTER_NOTALLOWED);
+
+ return Pointer(POINTER_REFHAND);
+ }
+
+ case SDRDRAG_GRADIENT:
+ {
+ if(!IsGradientAllowed())
+ return Pointer(POINTER_NOTALLOWED);
+
+ return Pointer(POINTER_REFHAND);
+ }
+
+ case SDRDRAG_CROOK: {
+ if (bCorner || bVertex || bMov) {
+ if (!IsCrookAllowed(TRUE) && !IsCrookAllowed(FALSE)) return Pointer(POINTER_NOTALLOWED);
+ return Pointer(POINTER_CROOK);
+ }
+ }
+
+ case SDRDRAG_CROP:
+ {
+ return Pointer(POINTER_CROP);
+ }
+
+ default: {
+ if ((bCorner || bVertex) && !IsResizeAllowed(TRUE)) return Pointer(POINTER_NOTALLOWED);
+ }
+ }
+ if (pHdl!=NULL) return pHdl->GetPointer();
+ if (bMov) {
+ if (!IsMoveAllowed()) return Pointer(POINTER_ARROW); // weil Doppelklick oder Drag&Drop moeglich
+ return Pointer(POINTER_MOVE);
+ }
+ }
+ if (eEditMode==SDREDITMODE_CREATE) return aAktCreatePointer;
+ return Pointer(POINTER_ARROW);
+}
+
+XubString SdrView::GetStatusText()
+{
+ XubString aStr;
+ XubString aName;
+
+ aStr.AppendAscii("nix");
+
+ if (pAktCreate!=NULL)
+ {
+ aStr=pAktCreate->getSpecialDragComment(aDragStat);
+
+ if(!aStr.Len())
+ {
+ pAktCreate->TakeObjNameSingul(aName);
+ aStr = ImpGetResStr(STR_ViewCreateObj);
+ }
+ }
+ else if (mpCurrentSdrDragMethod)
+ {
+ if (bInsPolyPoint || IsInsertGluePoint())
+ {
+ aStr=aInsPointUndoStr;
+ }
+ else
+ {
+ if (aDragStat.IsMinMoved())
+ {
+ OSL_TRACE("SdrView::GetStatusText(%lx) %lx\n", this, mpCurrentSdrDragMethod);
+ mpCurrentSdrDragMethod->TakeSdrDragComment(aStr);
+ }
+ }
+ }
+ else if(IsMarkObj())
+ {
+ if(AreObjectsMarked())
+ {
+ aStr = ImpGetResStr(STR_ViewMarkMoreObjs);
+ }
+ else
+ {
+ aStr = ImpGetResStr(STR_ViewMarkObjs);
+ }
+ }
+ else if(IsMarkPoints())
+ {
+ if(HasMarkedPoints())
+ {
+ aStr = ImpGetResStr(STR_ViewMarkMorePoints);
+ }
+ else
+ {
+ aStr = ImpGetResStr(STR_ViewMarkPoints);
+ }
+ } else if (IsMarkGluePoints())
+ {
+ if(HasMarkedGluePoints())
+ {
+ aStr = ImpGetResStr(STR_ViewMarkMoreGluePoints);
+ }
+ else
+ {
+ aStr = ImpGetResStr(STR_ViewMarkGluePoints);
+ }
+ }
+ else if (IsTextEdit() && pTextEditOutlinerView!=NULL) {
+ aStr=ImpGetResStr(STR_ViewTextEdit); // "TextEdit - Zeile y Spalte x";
+ ESelection aSel(pTextEditOutlinerView->GetSelection());
+ long nPar=aSel.nEndPara,nLin=0,nCol=aSel.nEndPos;
+ if (aSel.nEndPara>0) {
+ for (USHORT nParaNum=0; nParaNum<aSel.nEndPara; nParaNum++) {
+ nLin+=pTextEditOutliner->GetLineCount(nParaNum);
+ }
+ }
+ // Noch 'ne kleine Unschoenheit:
+ // Am Ende einer Zeile eines mehrzeiligen Absatzes wird die Position
+ // der naechsten Zeile des selben Absatzes angezeigt, so es eine solche
+ // gibt.
+ USHORT nParaLine=0;
+ ULONG nParaLineAnz=pTextEditOutliner->GetLineCount(aSel.nEndPara);
+ BOOL bBrk=FALSE;
+ while (!bBrk) {
+ USHORT nLen=pTextEditOutliner->GetLineLen(aSel.nEndPara,nParaLine);
+ BOOL bLastLine=(nParaLine==nParaLineAnz-1);
+ if (nCol>nLen || (!bLastLine && nCol==nLen)) {
+ nCol-=nLen;
+ nLin++;
+ nParaLine++;
+ } else bBrk=TRUE;
+ if (nLen==0) bBrk=TRUE; // Sicherheitshalber
+ }
+
+ aStr.SearchAndReplaceAscii("%1", UniString::CreateFromInt32(nPar + 1));
+ aStr.SearchAndReplaceAscii("%2", UniString::CreateFromInt32(nLin + 1));
+ aStr.SearchAndReplaceAscii("%3", UniString::CreateFromInt32(nCol + 1));
+
+#ifdef DBG_UTIL
+ aStr += UniString( RTL_CONSTASCII_USTRINGPARAM( ", Level " ) );
+ aStr += UniString::CreateFromInt32( pTextEditOutliner->GetDepth( aSel.nEndPara ) );
+#endif
+ }
+
+ if(aStr.EqualsAscii("nix"))
+ {
+ if (AreObjectsMarked()) {
+ ImpTakeDescriptionStr(STR_ViewMarked,aStr);
+ if (IsGluePointEditMode()) {
+ if (HasMarkedGluePoints()) {
+ ImpTakeDescriptionStr(STR_ViewMarked,aStr,0,IMPSDR_GLUEPOINTSDESCRIPTION);
+ }
+ } else {
+ if (HasMarkedPoints()) {
+ ImpTakeDescriptionStr(STR_ViewMarked,aStr,0,IMPSDR_POINTSDESCRIPTION);
+ }
+ }
+ } else {
+ aStr.Erase();
+ }
+ }
+ else if(aName.Len())
+ {
+ aStr.SearchAndReplaceAscii("%1", aName);
+ }
+
+ if(aStr.Len())
+ {
+ // ersten Buchstaben gross schreiben
+ String aTmpStr(aStr.Copy(0, 1));
+ aTmpStr.ToUpperAscii();
+ aStr.Replace(0, 1, aTmpStr);
+ }
+ return aStr;
+}
+
+SdrViewContext SdrView::GetContext() const
+{
+ if( IsGluePointEditMode() )
+ return SDRCONTEXT_GLUEPOINTEDIT;
+
+ const ULONG nMarkAnz = GetMarkedObjectCount();
+
+ if( HasMarkablePoints() && !IsFrameHandles() )
+ {
+ BOOL bPath=TRUE;
+ for( ULONG nMarkNum = 0; nMarkNum < nMarkAnz && bPath; nMarkNum++ )
+ if (!GetMarkedObjectByIndex(nMarkNum)->ISA(SdrPathObj))
+ bPath=FALSE;
+
+ if( bPath )
+ return SDRCONTEXT_POINTEDIT;
+ }
+
+ if( GetMarkedObjectCount() )
+ {
+ BOOL bGraf = TRUE, bMedia = TRUE, bTable = TRUE;
+
+ for( ULONG nMarkNum = 0; nMarkNum < nMarkAnz && ( bGraf || bMedia ); nMarkNum++ )
+ {
+ const SdrObject* pMarkObj = GetMarkedObjectByIndex( nMarkNum );
+ DBG_ASSERT( pMarkObj, "SdrView::GetContext(), null pointer in mark list!" );
+
+ if( !pMarkObj )
+ continue;
+
+ if( !pMarkObj->ISA( SdrGrafObj ) )
+ bGraf = FALSE;
+
+ if( !pMarkObj->ISA( SdrMediaObj ) )
+ bMedia = FALSE;
+
+ if( !pMarkObj->ISA( ::sdr::table::SdrTableObj ) )
+ bTable = FALSE;
+ }
+
+ if( bGraf )
+ return SDRCONTEXT_GRAPHIC;
+ else if( bMedia )
+ return SDRCONTEXT_MEDIA;
+ else if( bTable )
+ return SDRCONTEXT_TABLE;
+ }
+
+ return SDRCONTEXT_STANDARD;
+}
+
+void SdrView::MarkAll()
+{
+ if (IsTextEdit()) {
+ GetTextEditOutlinerView()->SetSelection(ESelection(0,0,0xFFFF,0xFFFF));
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ } else if (IsGluePointEditMode()) MarkAllGluePoints();
+ else if (HasMarkablePoints()) MarkAllPoints();
+ else MarkAllObj();
+}
+
+void SdrView::UnmarkAll()
+{
+ if (IsTextEdit()) {
+ ESelection eSel=GetTextEditOutlinerView()->GetSelection();
+ eSel.nStartPara=eSel.nEndPara;
+ eSel.nStartPos=eSel.nEndPos;
+ GetTextEditOutlinerView()->SetSelection(eSel);
+#ifdef DBG_UTIL
+ if (pItemBrowser!=NULL) pItemBrowser->SetDirty();
+#endif
+ } else if (HasMarkedGluePoints()) UnmarkAllGluePoints();
+ else if (HasMarkedPoints()) UnmarkAllPoints(); // ! Marked statt Markable !
+ else UnmarkAllObj();
+}
+
+BOOL SdrView::IsAllMarked() const
+{
+ if (IsTextEdit()) {
+ return ImpIsTextEditAllSelected();
+ }
+ if (IsGluePointEditMode()) {
+ ULONG nAnz=GetMarkableGluePointCount();
+ return nAnz!=0 && nAnz==GetMarkedGluePointCount();
+ }
+ if (HasMarkedPoints()) {
+ ULONG nAnz=GetMarkablePointCount();
+ return nAnz!=0 && nAnz==GetMarkedPointCount();
+ }
+ ULONG nAnz=GetMarkableObjCount();
+ return nAnz!=0 && nAnz == GetMarkedObjectCount();
+}
+
+BOOL SdrView::IsMarkPossible() const
+{
+ if(IsTextEdit())
+ {
+ return SdrTextObj::HasTextImpl( pTextEditOutliner );
+ }
+
+ if(IsGluePointEditMode())
+ {
+ return HasMarkableGluePoints();
+ }
+
+ if(HasMarkedPoints())
+ {
+ return HasMarkablePoints();
+ }
+
+ return HasMarkableObj();
+}
+
+BOOL SdrView::IsAllMarkPrevNextPossible() const
+{
+ if (IsTextEdit()) {
+ return FALSE;
+ }
+ if (IsGluePointEditMode()) {
+ return HasMarkableGluePoints();
+ }
+ if (HasMarkedPoints()) {
+ return HasMarkablePoints();
+ }
+ return HasMarkableObj();
+}
+
+BOOL SdrView::MarkNext(BOOL bPrev)
+{
+ if (IsTextEdit()) {
+ return FALSE;
+ }
+ if (IsGluePointEditMode() && HasMarkedGluePoints()) {
+ return MarkNextGluePoint(bPrev);
+ }
+ if (HasMarkedPoints()) {
+ return MarkNextPoint(bPrev);
+ }
+ return MarkNextObj(bPrev);
+}
+
+BOOL SdrView::MarkNext(const Point& rPnt, BOOL bPrev)
+{
+ if (IsTextEdit()) {
+ return FALSE;
+ }
+ if (IsGluePointEditMode() && HasMarkedGluePoints()) {
+ //return MarkNextGluePoint(rPnt,bPrev); fehlende Implementation !!!
+ }
+ if (HasMarkedPoints()) {
+ //return MarkNextPoint(rPnt,bPrev); fehlende Implementation !!!
+ }
+ return MarkNextObj(rPnt,-2,bPrev);
+}
+
+const Rectangle& SdrView::GetMarkedRect() const
+{
+ if (IsGluePointEditMode() && HasMarkedGluePoints()) {
+ return GetMarkedGluePointsRect();
+ }
+ if (HasMarkedPoints()) {
+ return GetMarkedPointsRect();
+ }
+ return GetMarkedObjRect();
+}
+
+void SdrView::SetMarkedRect(const Rectangle& rRect)
+{
+ if (IsGluePointEditMode() && HasMarkedGluePoints()) {
+ //SetMarkedGluePointsRect(rRect); fehlende Implementation !!!
+ } else if (HasMarkedPoints()) {
+ //SetMarkedPointsRect(rRect); fehlende Implementation !!!
+ } else SetMarkedObjRect(rRect);
+}
+
+void SdrView::DeleteMarked()
+{
+ if (IsTextEdit())
+ {
+ SdrObjEditView::KeyInput(KeyEvent(0,KeyCode(KEYFUNC_DELETE)),pTextEditWin);
+ }
+ else
+ {
+ if( mxSelectionController.is() && mxSelectionController->DeleteMarked() )
+ {
+ // action already performed by current selection controller, do nothing
+ }
+ else if (IsGluePointEditMode() && HasMarkedGluePoints())
+ {
+ DeleteMarkedGluePoints();
+ }
+ else if (GetContext()==SDRCONTEXT_POINTEDIT && HasMarkedPoints())
+ {
+ DeleteMarkedPoints();
+ }
+ else
+ {
+ DeleteMarkedObj();
+ }
+ }
+}
+
+BOOL SdrView::BegMark(const Point& rPnt, BOOL bAddMark, BOOL bUnmark)
+{
+ if (bUnmark) bAddMark=TRUE;
+ if (IsGluePointEditMode()) {
+ if (!bAddMark) UnmarkAllGluePoints();
+ return BegMarkGluePoints(rPnt,bUnmark);
+ } else if (HasMarkablePoints()) {
+ if (!bAddMark) UnmarkAllPoints();
+ return BegMarkPoints(rPnt,bUnmark);
+ } else {
+ if (!bAddMark) UnmarkAllObj();
+ return BegMarkObj(rPnt,bUnmark);
+ }
+}
+
+BOOL SdrView::IsDeleteMarkedPossible() const
+{
+ if (IsReadOnly()) return FALSE;
+ if (IsTextEdit()) return TRUE;
+ if (IsGluePointEditMode() && HasMarkedGluePoints()) return TRUE;
+ if (HasMarkedPoints()) return TRUE;
+ return IsDeleteMarkedObjPossible();
+}
+
+void SdrView::ConfigurationChanged( ::utl::ConfigurationBroadcaster*p, sal_uInt32 nHint)
+{
+ onAccessibilityOptionsChanged();
+ SdrCreateView::ConfigurationChanged(p, nHint);
+}
+
+SvtAccessibilityOptions& SdrView::getAccessibilityOptions()
+{
+ return maAccessibilityOptions;
+}
+
+/** method is called whenever the global SvtAccessibilityOptions is changed */
+void SdrView::onAccessibilityOptionsChanged()
+{
+}
+
+void SdrView::SetMasterPagePaintCaching(sal_Bool bOn)
+{
+ if(mbMasterPagePaintCaching != bOn)
+ {
+ mbMasterPagePaintCaching = bOn;
+
+ // reset at all SdrPageWindow's
+ SdrPageView* pPageView = GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b(0L); b < pPageView->PageWindowCount(); b++)
+ {
+ SdrPageWindow* pPageWindow = pPageView->GetPageWindow(b);
+ DBG_ASSERT(pPageWindow, "SdrView::SetMasterPagePaintCaching: Corrupt SdrPageWindow list (!)");
+
+ // force deletion of ObjectContact, so at re-display all VOCs
+ // will be re-created with updated flag setting
+ pPageWindow->ResetObjectContact();
+ }
+
+ // force redraw of this view
+ pPageView->InvalidateAllWin();
+ }
+ }
+}
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdviter.cxx b/svx/source/svdraw/svdviter.cxx
new file mode 100644
index 000000000000..e23fbeb78da0
--- /dev/null
+++ b/svx/source/svdraw/svdviter.cxx
@@ -0,0 +1,353 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svdviter.hxx"
+#include <svx/svdobj.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdsob.hxx>
+#include <svl/brdcst.hxx>
+#include <sdrpaintwindow.hxx>
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void SdrViewIter::ImpInitVars()
+{
+ mnListenerNum = 0L;
+ mnPageViewNum = 0L;
+ mnOutDevNum = 0L;
+ mpAktView = 0L;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrViewIter::SdrViewIter(const SdrModel* pModel)
+{
+ mpModel = pModel;
+ mpPage = 0L;
+ mpObject = 0L;
+ ImpInitVars();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrViewIter::SdrViewIter(const SdrPage* pPage, sal_Bool bNoMasterPage)
+{
+ mpPage = pPage;
+ mpModel = (pPage) ? pPage->GetModel() : 0L;
+ mpObject = 0L;
+ mbNoMasterPage = bNoMasterPage;
+ ImpInitVars();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrViewIter::SdrViewIter(const SdrObject* pObject, sal_Bool bNoMasterPage)
+{
+ mpObject = pObject;
+ mpModel = (pObject) ? pObject->GetModel() : 0L;
+ mpPage = (pObject) ? pObject->GetPage() : 0L;
+ mbNoMasterPage = bNoMasterPage;
+
+ if(!mpModel || !mpPage)
+ {
+ mpModel = 0L;
+ mpPage = 0L;
+ }
+
+ ImpInitVars();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+sal_Bool SdrViewIter::ImpCheckPageView(SdrPageView* pPV) const
+{
+ if(mpPage)
+ {
+ sal_Bool bMaster(mpPage->IsMasterPage());
+ SdrPage* pPg = pPV->GetPage();
+
+ if(pPg == mpPage)
+ {
+ if(mpObject)
+ {
+ // Objekt gewuenscht? Na dann erstmal sehen, ob
+ // das Obj in dieser PageView auch sichtbar ist.
+ SetOfByte aObjLay;
+ mpObject->getMergedHierarchyLayerSet(aObjLay);
+ aObjLay &= pPV->GetVisibleLayers();
+ return !aObjLay.IsEmpty();
+ }
+ else
+ {
+ return sal_True;
+ }
+ }
+ else
+ {
+ if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
+ {
+ if(pPg->TRG_HasMasterPage())
+ {
+ SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
+
+ if(&rMasterPage == mpPage)
+ {
+ // Aha, die gewuenschte Page ist also MasterPage in dieser PageView
+ if(mpObject)
+ {
+ // Objekt gewuenscht? Na dann erstmal sehen, ob
+ // das Obj in dieser PageView auch sichtbar ist.
+ SetOfByte aObjLay;
+ mpObject->getMergedHierarchyLayerSet(aObjLay);
+ aObjLay &= pPV->GetVisibleLayers();
+ aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
+
+ if(!aObjLay.IsEmpty())
+ {
+ return TRUE;
+ } // ansonsten die naechste MasterPage der Page ansehen...
+ }
+ else
+ {
+ return sal_True;
+ }
+ }
+ }
+ }
+
+ // MasterPage nicht erlaubt oder keine passende gefunden
+ return sal_False;
+ }
+ }
+ else
+ {
+ return sal_True;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrView* SdrViewIter::ImpFindView()
+{
+ if(mpModel)
+ {
+ sal_uInt32 nLsAnz(mpModel->GetListenerCount());
+
+ while(mnListenerNum < nLsAnz)
+ {
+ SfxListener* pLs = mpModel->GetListener((sal_uInt16)mnListenerNum);
+ mpAktView = PTR_CAST(SdrView, pLs);
+
+ if(mpAktView)
+ {
+ if(mpPage)
+ {
+ SdrPageView* pPV = mpAktView->GetSdrPageView();
+
+ if(pPV)
+ {
+ if(ImpCheckPageView(pPV))
+ {
+ return mpAktView;
+ }
+ }
+ }
+ else
+ {
+ return mpAktView;
+ }
+ }
+
+ mnListenerNum++;
+ }
+ }
+
+ mpAktView = 0L;
+ return mpAktView;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrPageView* SdrViewIter::ImpFindPageView()
+{
+ if(mpModel)
+ {
+ while(mpAktView)
+ {
+ SdrPageView* pPV = mpAktView->GetSdrPageView();
+
+ if(pPV)
+ {
+ if(mpPage)
+ {
+ if(ImpCheckPageView(pPV))
+ {
+ return pPV;
+ }
+ }
+ else
+ {
+ return pPV;
+ }
+
+ mnPageViewNum++;
+ }
+
+ mnListenerNum++;
+ ImpFindView();
+ }
+ }
+
+ return 0L;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+OutputDevice* SdrViewIter::ImpFindOutDev()
+{
+ while(mpAktView)
+ {
+ const sal_uInt32 nOutDevAnz(mpAktView->PaintWindowCount());
+
+ if(mnOutDevNum < nOutDevAnz)
+ {
+ SdrPaintWindow* pPaintWindow = mpAktView->GetPaintWindow(mnOutDevNum);
+ return &pPaintWindow->GetOutputDevice();
+ }
+
+ mnListenerNum++;
+ ImpFindView();
+ }
+
+ return 0L;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Window* SdrViewIter::ImpFindWindow()
+{
+ while(mpAktView)
+ {
+ const sal_uInt32 nOutDevAnz(mpAktView->PaintWindowCount());
+
+ while(mnOutDevNum < nOutDevAnz)
+ {
+ SdrPaintWindow* pPaintWindow = mpAktView->GetPaintWindow(mnOutDevNum);
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+
+ if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
+ {
+ return (Window*)(&rOutDev);
+ }
+
+ mnOutDevNum++;
+ }
+
+ mnListenerNum++;
+ ImpFindView();
+ }
+
+ return 0L;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrView* SdrViewIter::FirstView()
+{
+ ImpInitVars();
+ return ImpFindView();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrView* SdrViewIter::NextView()
+{
+ mnListenerNum++;
+ return ImpFindView();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrPageView* SdrViewIter::FirstPageView()
+{
+ ImpInitVars();
+ ImpFindView();
+ return ImpFindPageView();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrPageView* SdrViewIter::NextPageView()
+{
+ mnPageViewNum++;
+ return ImpFindPageView();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+OutputDevice* SdrViewIter::FirstOutDev()
+{
+ ImpInitVars();
+ ImpFindView();
+ return ImpFindOutDev();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+OutputDevice* SdrViewIter::NextOutDev()
+{
+ mnOutDevNum++;
+ return ImpFindOutDev();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Window* SdrViewIter::FirstWindow()
+{
+ ImpInitVars();
+ ImpFindView();
+ return ImpFindWindow();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Window* SdrViewIter::NextWindow()
+{
+ mnOutDevNum++;
+ return ImpFindWindow();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
new file mode 100644
index 000000000000..eac330f67d59
--- /dev/null
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -0,0 +1,897 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <vector>
+#include <editeng/editeng.hxx>
+#include "xexch.hxx"
+#include <svx/xflclit.hxx>
+#include <svx/svdxcgv.hxx>
+#include <svx/svdoutl.hxx>
+#include "svditext.hxx"
+#include <svx/svdetc.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx> // fuer kein OLE im SdrClipboardFormat
+#include <svx/svdorect.hxx>
+#include <svx/svdoedge.hxx> // fuer Konnektoren uebers Clipboard
+#include <svx/svdopage.hxx> // fuer Konnektoren uebers Clipboard
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdtrans.hxx> // Fuer GetMapFactor zum umskalieren bei PasteModel
+#include "svdstr.hrc" // Namen aus der Resource
+#include "svdglob.hxx" // StringCache
+#include "xoutbmp.hxx"
+#include <vcl/metaact.hxx>
+#include <svl/poolitem.hxx>
+#include <svl/itempool.hxx>
+#include <tools/bigint.hxx>
+#include <sot/formats.hxx>
+
+// #i13033#
+#include <clonelist.hxx>
+#include <vcl/virdev.hxx>
+
+// b4967543
+#include <svl/style.hxx>
+
+// #i72535#
+#include "fmobj.hxx"
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+SdrExchangeView::SdrExchangeView(SdrModel* pModel1, OutputDevice* pOut):
+ SdrObjEditView(pModel1,pOut)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Point SdrExchangeView::GetViewCenter(const OutputDevice* pOut) const
+{
+ Point aCenter;
+ if (pOut==NULL)
+ {
+ pOut = GetFirstOutputDevice();
+ }
+ if (pOut!=NULL) {
+ Point aOfs=pOut->GetMapMode().GetOrigin();
+ Size aOutSiz=pOut->GetOutputSize();
+ aOutSiz.Width()/=2;
+ aOutSiz.Height()/=2;
+ aCenter.X()=aOutSiz.Width() -aOfs.X();
+ aCenter.Y()=aOutSiz.Height()-aOfs.Y();
+ }
+ return aCenter;
+}
+
+Point SdrExchangeView::GetPastePos(SdrObjList* pLst, OutputDevice* pOut)
+{
+ Point aP(GetViewCenter(pOut));
+ SdrPage* pPg=NULL;
+ if (pLst!=NULL) pPg=pLst->GetPage();
+ if (pPg!=NULL) {
+ Size aSiz(pPg->GetSize());
+ aP.X()=aSiz.Width()/2;
+ aP.Y()=aSiz.Height()/2;
+ }
+ return aP;
+}
+
+BOOL SdrExchangeView::ImpLimitToWorkArea(Point& rPt) const
+{
+ BOOL bRet(FALSE);
+
+ if(!aMaxWorkArea.IsEmpty())
+ {
+ if(rPt.X()<aMaxWorkArea.Left())
+ {
+ rPt.X() = aMaxWorkArea.Left();
+ bRet = TRUE;
+ }
+
+ if(rPt.X()>aMaxWorkArea.Right())
+ {
+ rPt.X() = aMaxWorkArea.Right();
+ bRet = TRUE;
+ }
+
+ if(rPt.Y()<aMaxWorkArea.Top())
+ {
+ rPt.Y() = aMaxWorkArea.Top();
+ bRet = TRUE;
+ }
+
+ if(rPt.Y()>aMaxWorkArea.Bottom())
+ {
+ rPt.Y() = aMaxWorkArea.Bottom();
+ bRet = TRUE;
+ }
+ }
+ return bRet;
+}
+
+void SdrExchangeView::ImpGetPasteObjList(Point& /*rPos*/, SdrObjList*& rpLst)
+{
+ if (rpLst==NULL)
+ {
+ SdrPageView* pPV = GetSdrPageView();
+
+ if (pPV!=NULL) {
+ rpLst=pPV->GetObjList();
+ }
+ }
+}
+
+BOOL SdrExchangeView::ImpGetPasteLayer(const SdrObjList* pObjList, SdrLayerID& rLayer) const
+{
+ BOOL bRet=FALSE;
+ rLayer=0;
+ if (pObjList!=NULL) {
+ const SdrPage* pPg=pObjList->GetPage();
+ if (pPg!=NULL) {
+ rLayer=pPg->GetLayerAdmin().GetLayerID(aAktLayer,TRUE);
+ if (rLayer==SDRLAYER_NOTFOUND) rLayer=0;
+ SdrPageView* pPV = GetSdrPageView();
+ if (pPV!=NULL) {
+ bRet=!pPV->GetLockedLayers().IsSet(rLayer) && pPV->GetVisibleLayers().IsSet(rLayer);
+ }
+ }
+ }
+ return bRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+BOOL SdrExchangeView::Paste(const GDIMetaFile& rMtf, const Point& rPos, SdrObjList* pLst, UINT32 nOptions)
+{
+ Point aPos(rPos);
+ ImpGetPasteObjList(aPos,pLst);
+ ImpLimitToWorkArea( aPos );
+ if (pLst==NULL) return FALSE;
+ SdrLayerID nLayer;
+ if (!ImpGetPasteLayer(pLst,nLayer)) return FALSE;
+ BOOL bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
+ if (bUnmark) UnmarkAllObj();
+ SdrGrafObj* pObj=new SdrGrafObj(Graphic(rMtf));
+ pObj->SetLayer(nLayer);
+ ImpPasteObject(pObj,*pLst,aPos,rMtf.GetPrefSize(),rMtf.GetPrefMapMode(),nOptions);
+ return TRUE;
+}
+
+BOOL SdrExchangeView::Paste(const Bitmap& rBmp, const Point& rPos, SdrObjList* pLst, UINT32 nOptions)
+{
+ Point aPos(rPos);
+ ImpGetPasteObjList(aPos,pLst);
+ ImpLimitToWorkArea( aPos );
+ if (pLst==NULL) return FALSE;
+ SdrLayerID nLayer;
+ if (!ImpGetPasteLayer(pLst,nLayer)) return FALSE;
+ BOOL bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
+ if (bUnmark) UnmarkAllObj();
+ SdrGrafObj* pObj=new SdrGrafObj(Graphic(rBmp));
+ pObj->SetLayer(nLayer);
+ ImpPasteObject(pObj,*pLst,aPos,rBmp.GetSizePixel(),MapMode(MAP_PIXEL),nOptions);
+ return TRUE;
+}
+
+BOOL SdrExchangeView::Paste(const XubString& rStr, const Point& rPos, SdrObjList* pLst, UINT32 nOptions)
+{
+ if(!rStr.Len())
+ return FALSE;
+
+ Point aPos(rPos);
+ ImpGetPasteObjList(aPos,pLst);
+ ImpLimitToWorkArea( aPos );
+ if (pLst==NULL) return FALSE;
+ SdrLayerID nLayer;
+ if (!ImpGetPasteLayer(pLst,nLayer)) return FALSE;
+ BOOL bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
+ if (bUnmark) UnmarkAllObj();
+ Rectangle aTextRect(0,0,500,500);
+ SdrPage* pPage=pLst->GetPage();
+ if (pPage!=NULL) {
+ aTextRect.SetSize(pPage->GetSize());
+ }
+ SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect);
+ pObj->SetModel(pMod);
+ pObj->SetLayer(nLayer);
+ pObj->NbcSetText(rStr); // #32424# SetText vor SetAttr, weil SetAttr sonst unwirksam!
+ if (pDefaultStyleSheet!=NULL) pObj->NbcSetStyleSheet(pDefaultStyleSheet, sal_False);
+
+ pObj->SetMergedItemSet(aDefaultAttr);
+
+ SfxItemSet aTempAttr(pMod->GetItemPool()); // Keine Fuellung oder Linie
+ aTempAttr.Put(XLineStyleItem(XLINE_NONE));
+ aTempAttr.Put(XFillStyleItem(XFILL_NONE));
+
+ pObj->SetMergedItemSet(aTempAttr);
+
+ pObj->FitFrameToTextSize();
+ Size aSiz(pObj->GetLogicRect().GetSize());
+ MapUnit eMap=pMod->GetScaleUnit();
+ Fraction aMap=pMod->GetScaleFraction();
+ ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
+ return TRUE;
+}
+
+BOOL SdrExchangeView::Paste(SvStream& rInput, const String& rBaseURL, USHORT eFormat, const Point& rPos, SdrObjList* pLst, UINT32 nOptions)
+{
+ Point aPos(rPos);
+ ImpGetPasteObjList(aPos,pLst);
+ ImpLimitToWorkArea( aPos );
+ if (pLst==NULL) return FALSE;
+ SdrLayerID nLayer;
+ if (!ImpGetPasteLayer(pLst,nLayer)) return FALSE;
+ BOOL bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
+ if (bUnmark) UnmarkAllObj();
+ Rectangle aTextRect(0,0,500,500);
+ SdrPage* pPage=pLst->GetPage();
+ if (pPage!=NULL) {
+ aTextRect.SetSize(pPage->GetSize());
+ }
+ SdrRectObj* pObj=new SdrRectObj(OBJ_TEXT,aTextRect);
+ pObj->SetModel(pMod);
+ pObj->SetLayer(nLayer);
+ if (pDefaultStyleSheet!=NULL) pObj->NbcSetStyleSheet(pDefaultStyleSheet, sal_False);
+
+ pObj->SetMergedItemSet(aDefaultAttr);
+
+ SfxItemSet aTempAttr(pMod->GetItemPool()); // Keine Fuellung oder Linie
+ aTempAttr.Put(XLineStyleItem(XLINE_NONE));
+ aTempAttr.Put(XFillStyleItem(XFILL_NONE));
+
+ pObj->SetMergedItemSet(aTempAttr);
+
+ pObj->NbcSetText(rInput,rBaseURL,eFormat);
+ pObj->FitFrameToTextSize();
+ Size aSiz(pObj->GetLogicRect().GetSize());
+ MapUnit eMap=pMod->GetScaleUnit();
+ Fraction aMap=pMod->GetScaleFraction();
+ ImpPasteObject(pObj,*pLst,aPos,aSiz,MapMode(eMap,Point(0,0),aMap,aMap),nOptions);
+
+ // b4967543
+ if(pObj && pObj->GetModel() && pObj->GetOutlinerParaObject())
+ {
+ SdrOutliner& rOutliner = pObj->GetModel()->GetHitTestOutliner();
+ rOutliner.SetText(*pObj->GetOutlinerParaObject());
+
+ if(1L == rOutliner.GetParagraphCount())
+ {
+ SfxStyleSheet* pCandidate = rOutliner.GetStyleSheet(0L);
+
+ if(pCandidate)
+ {
+ if(pObj->GetModel()->GetStyleSheetPool() == &pCandidate->GetPool())
+ {
+ pObj->NbcSetStyleSheet(pCandidate, sal_True);
+ }
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+BOOL SdrExchangeView::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, UINT32 nOptions)
+{
+ const SdrModel* pSrcMod=&rMod;
+ if (pSrcMod==pMod)
+ return FALSE; // na so geht's ja nun nicht
+
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ BegUndo(ImpGetResStr(STR_ExchangePaste));
+
+ if( mxSelectionController.is() && mxSelectionController->PasteObjModel( rMod ) )
+ {
+ if( bUndo )
+ EndUndo();
+ return TRUE;
+ }
+
+ Point aPos(rPos);
+ ImpGetPasteObjList(aPos,pLst);
+ SdrPageView* pMarkPV=NULL;
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ if ( pPV->GetObjList() == pLst )
+ pMarkPV=pPV;
+ }
+
+ ImpLimitToWorkArea( aPos );
+ if (pLst==NULL)
+ return FALSE;
+
+ BOOL bUnmark=(nOptions&(SDRINSERT_DONTMARK|SDRINSERT_ADDMARK))==0 && !IsTextEdit();
+ if (bUnmark)
+ UnmarkAllObj();
+
+ // evtl. umskalieren bei unterschiedlicher MapUnit am Model
+ // Dafuer erstmal die Faktoren berechnen
+ MapUnit eSrcUnit=pSrcMod->GetScaleUnit();
+ MapUnit eDstUnit=pMod->GetScaleUnit();
+ BOOL bResize=eSrcUnit!=eDstUnit;
+ Fraction xResize,yResize;
+ Point aPt0;
+ if (bResize)
+ {
+ FrPair aResize(GetMapFactor(eSrcUnit,eDstUnit));
+ xResize=aResize.X();
+ yResize=aResize.Y();
+ }
+ SdrObjList* pDstLst=pLst;
+ USHORT nPg,nPgAnz=pSrcMod->GetPageCount();
+ for (nPg=0; nPg<nPgAnz; nPg++)
+ {
+ const SdrPage* pSrcPg=pSrcMod->GetPage(nPg);
+
+ // #104148# Use SnapRect, not BoundRect here
+ Rectangle aR=pSrcPg->GetAllObjSnapRect();
+
+ if (bResize)
+ ResizeRect(aR,aPt0,xResize,yResize);
+ Point aDist(aPos-aR.Center());
+ Size aSiz(aDist.X(),aDist.Y());
+ //ULONG nDstObjAnz0=pDstLst->GetObjCount();
+ ULONG nCloneErrCnt=0;
+ ULONG nOb,nObAnz=pSrcPg->GetObjCount();
+ BOOL bMark=pMarkPV!=NULL && !IsTextEdit() && (nOptions&SDRINSERT_DONTMARK)==0;
+
+ // #i13033#
+ // New mechanism to re-create the connections of cloned connectors
+ CloneList aCloneList;
+
+ for (nOb=0; nOb<nObAnz; nOb++)
+ {
+ const SdrObject* pSrcOb=pSrcPg->GetObj(nOb);
+
+ // #116235#
+ SdrObject* pNeuObj = pSrcOb->Clone();
+
+ if (pNeuObj!=NULL)
+ {
+ if(bResize)
+ {
+ pNeuObj->GetModel()->SetPasteResize(TRUE); // #51139#
+ pNeuObj->NbcResize(aPt0,xResize,yResize);
+ pNeuObj->GetModel()->SetPasteResize(FALSE); // #51139#
+ }
+
+ // #i39861#
+ pNeuObj->SetModel(pDstLst->GetModel());
+ pNeuObj->SetPage(pDstLst->GetPage());
+
+ pNeuObj->NbcMove(aSiz);
+
+ const SdrPage* pPg = pDstLst->GetPage();
+
+ if(pPg)
+ {
+ // #i72535#
+ const SdrLayerAdmin& rAd = pPg->GetLayerAdmin();
+ SdrLayerID nLayer(0);
+
+ if(pNeuObj->ISA(FmFormObj))
+ {
+ // for FormControls, force to form layer
+ nLayer = rAd.GetLayerID(rAd.GetControlLayerName(), true);
+ }
+ else
+ {
+ nLayer = rAd.GetLayerID(aAktLayer, TRUE);
+ }
+
+ if(SDRLAYER_NOTFOUND == nLayer)
+ {
+ nLayer = 0;
+ }
+
+ pNeuObj->SetLayer(nLayer);
+ }
+
+ SdrInsertReason aReason(SDRREASON_VIEWCALL);
+ pDstLst->InsertObject(pNeuObj,CONTAINER_APPEND,&aReason);
+
+ if( bUndo )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pNeuObj));
+
+ if (bMark) {
+ // Markhandles noch nicht sofort setzen!
+ // Das erledigt das ModelHasChanged der MarkView.
+ MarkObj(pNeuObj,pMarkPV,FALSE,TRUE);
+ }
+
+ // #i13033#
+ aCloneList.AddPair(pSrcOb, pNeuObj);
+ }
+ else
+ {
+ nCloneErrCnt++;
+ }
+ }
+
+ // #i13033#
+ // New mechanism to re-create the connections of cloned connectors
+ aCloneList.CopyConnections();
+
+ if(0L != nCloneErrCnt)
+ {
+#ifdef DBG_UTIL
+ ByteString aStr("SdrExchangeView::Paste(): Fehler beim Clonen ");
+
+ if(nCloneErrCnt == 1)
+ {
+ aStr += "eines Zeichenobjekts.";
+ }
+ else
+ {
+ aStr += "von ";
+ aStr += ByteString::CreateFromInt32( nCloneErrCnt );
+ aStr += " Zeichenobjekten.";
+ }
+
+ aStr += " Objektverbindungen werden nicht mitkopiert.";
+
+ DBG_ERROR(aStr.GetBuffer());
+#endif
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+
+ return TRUE;
+}
+
+BOOL SdrExchangeView::IsExchangeFormatSupported(ULONG nFormat) const
+{
+ return( FORMAT_PRIVATE == nFormat ||
+ FORMAT_GDIMETAFILE == nFormat ||
+ FORMAT_BITMAP == nFormat ||
+ FORMAT_RTF == nFormat ||
+ FORMAT_STRING == nFormat ||
+ SOT_FORMATSTR_ID_DRAWING == nFormat ||
+ SOT_FORMATSTR_ID_EDITENGINE == nFormat );
+}
+
+void SdrExchangeView::ImpPasteObject(SdrObject* pObj, SdrObjList& rLst, const Point& rCenter, const Size& rSiz, const MapMode& rMap, UINT32 nOptions)
+{
+ BigInt nSizX(rSiz.Width());
+ BigInt nSizY(rSiz.Height());
+ MapUnit eSrcMU=rMap.GetMapUnit();
+ MapUnit eDstMU=pMod->GetScaleUnit();
+ FrPair aMapFact(GetMapFactor(eSrcMU,eDstMU));
+ Fraction aDstFr(pMod->GetScaleFraction());
+ nSizX*=aMapFact.X().GetNumerator();
+ nSizX*=rMap.GetScaleX().GetNumerator();
+ nSizX*=aDstFr.GetDenominator();
+ nSizX/=aMapFact.X().GetDenominator();
+ nSizX/=rMap.GetScaleX().GetDenominator();
+ nSizX/=aDstFr.GetNumerator();
+ nSizY*=aMapFact.Y().GetNumerator();
+ nSizY*=rMap.GetScaleY().GetNumerator();
+ nSizX*=aDstFr.GetDenominator();
+ nSizY/=aMapFact.Y().GetDenominator();
+ nSizY/=rMap.GetScaleY().GetDenominator();
+ nSizY/=aDstFr.GetNumerator();
+ long xs=nSizX;
+ long ys=nSizY;
+ Point aPos(rCenter.X()-xs/2,rCenter.Y()-ys/2);
+ Rectangle aR(aPos.X(),aPos.Y(),aPos.X()+xs,aPos.Y()+ys);
+ pObj->SetLogicRect(aR);
+ SdrInsertReason aReason(SDRREASON_VIEWCALL);
+ rLst.InsertObject(pObj,CONTAINER_APPEND,&aReason);
+
+ if( IsUndoEnabled() )
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
+
+ SdrPageView* pMarkPV=NULL;
+ SdrPageView* pPV = GetSdrPageView();
+
+ if(pPV)
+ {
+ if (pPV->GetObjList()==&rLst)
+ pMarkPV=pPV;
+ }
+
+ BOOL bMark=pMarkPV!=NULL && !IsTextEdit() && (nOptions&SDRINSERT_DONTMARK)==0;
+ if (bMark)
+ { // Obj in der ersten gefundenen PageView markieren
+ MarkObj(pObj,pMarkPV);
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+
+Bitmap SdrExchangeView::GetMarkedObjBitmap( BOOL bNoVDevIfOneBmpMarked ) const
+{
+ Bitmap aBmp;
+
+ if( AreObjectsMarked() )
+ {
+ if( bNoVDevIfOneBmpMarked )
+ {
+ SdrObject* pGrafObjTmp = GetMarkedObjectByIndex( 0 );
+ SdrGrafObj* pGrafObj = ( GetMarkedObjectCount() == 1 ) ? PTR_CAST( SdrGrafObj, pGrafObjTmp ) : NULL;
+
+ if( pGrafObj && ( pGrafObj->GetGraphicType() == GRAPHIC_BITMAP ) )
+ aBmp = pGrafObj->GetTransformedGraphic().GetBitmap();
+ }
+
+ if( !aBmp )
+ {
+ const Graphic aGraphic( GetMarkedObjMetaFile( bNoVDevIfOneBmpMarked ) );
+
+ // #i102089# support user's settings of AA and LineSnap when the MetaFile gets
+ // rasterconverted to a bitmap
+ const SvtOptionsDrawinglayer aDrawinglayerOpt;
+ const GraphicConversionParameters aParameters(
+ Size(),
+ false,
+ aDrawinglayerOpt.IsAntiAliasing(),
+ aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete());
+
+ aBmp = aGraphic.GetBitmap(aParameters);
+ }
+ }
+
+ return aBmp;
+}
+
+// -----------------------------------------------------------------------------
+
+GDIMetaFile SdrExchangeView::GetMarkedObjMetaFile( BOOL bNoVDevIfOneMtfMarked ) const
+{
+ GDIMetaFile aMtf;
+
+ if( AreObjectsMarked() )
+ {
+ Rectangle aBound( GetMarkedObjBoundRect() );
+ Size aBoundSize( aBound.GetWidth(), aBound.GetHeight() );
+ MapMode aMap( pMod->GetScaleUnit(), Point(), pMod->GetScaleFraction(), pMod->GetScaleFraction() );
+
+ if( bNoVDevIfOneMtfMarked )
+ {
+ SdrObject* pGrafObjTmp = GetMarkedObjectByIndex( 0 );
+ SdrGrafObj* pGrafObj = ( GetMarkedObjectCount() ==1 ) ? PTR_CAST( SdrGrafObj, pGrafObjTmp ) : NULL;
+
+ if( pGrafObj )
+ {
+ Graphic aGraphic( pGrafObj->GetTransformedGraphic() );
+
+ if( aGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+ const Point aPos;
+
+ aMtf.AddAction( new MetaBmpExScaleAction( aPos, aBoundSize, aGraphic.GetBitmapEx() ) );
+ aMtf.SetPrefMapMode( aMap );
+ aMtf.SetPrefSize( aBoundSize );
+ }
+ else
+ aMtf = aGraphic.GetGDIMetaFile();
+ }
+ }
+
+ if( !aMtf.GetActionCount() )
+ {
+ VirtualDevice aOut;
+ Size aDummySize( 2, 2 );
+
+ aOut.SetOutputSizePixel( aDummySize );
+ aOut.EnableOutput( FALSE );
+ aOut.SetMapMode( aMap );
+
+ aMtf.Clear();
+ aMtf.Record( &aOut );
+
+ // Replace offset given formally to DrawMarkedObj and used at XOutDev with relative
+ // MapMode (which was also used in XOutDev in that case). Goal is to paint the object
+ // as if TopLeft point is (0,0)
+ const Fraction aNeutralFraction(1, 1);
+ const MapMode aRelativeMapMode(MAP_RELATIVE, Point(-aBound.Left(), -aBound.Top()), aNeutralFraction, aNeutralFraction);
+ aOut.SetMapMode(aRelativeMapMode);
+
+ DrawMarkedObj(aOut);
+
+ aMtf.Stop();
+ aMtf.WindStart();
+ aMtf.SetPrefMapMode( aMap );
+
+ // removed PrefSize extension. It is principially wrong to set a reduced size at
+ // the created MetaFile. The mentioned errors occurr at output time since the integer
+ // MapModes from VCL lead to errors. It is now corrected in the VCLRenderer for
+ // primitives (and may later be done in breaking up a MetaFile to primitives)
+ aMtf.SetPrefSize(aBoundSize);
+ }
+ }
+
+ return aMtf;
+}
+
+// -----------------------------------------------------------------------------
+
+Graphic SdrExchangeView::GetAllMarkedGraphic() const
+{
+ Graphic aRet;
+
+ if( AreObjectsMarked() )
+ {
+ if( ( 1 == GetMarkedObjectCount() ) && GetSdrMarkByIndex( 0 ) )
+ aRet = SdrExchangeView::GetObjGraphic( pMod, GetMarkedObjectByIndex( 0 ) );
+ else
+ aRet = GetMarkedObjMetaFile( FALSE );
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+Graphic SdrExchangeView::GetObjGraphic( const SdrModel* pModel, const SdrObject* pObj )
+{
+ Graphic aRet;
+
+ if( pModel && pObj )
+ {
+ // try to get a graphic from the object first
+ const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(pObj);
+ const SdrOle2Obj* pSdrOle2Obj = dynamic_cast< const SdrOle2Obj* >(pObj);
+
+ if(pSdrGrafObj)
+ {
+ // #110981# Make behaviour coherent with metafile
+ // recording below (which of course also takes
+ // view-transformed objects)
+ aRet = pSdrGrafObj->GetTransformedGraphic();
+ }
+ else if(pSdrOle2Obj)
+ {
+ if ( pSdrOle2Obj->GetGraphic() )
+ aRet = *pSdrOle2Obj->GetGraphic();
+ }
+
+ // if graphic could not be retrieved => go the hard way and create a MetaFile
+ if( ( GRAPHIC_NONE == aRet.GetType() ) || ( GRAPHIC_DEFAULT == aRet.GetType() ) )
+ {
+ VirtualDevice aOut;
+ GDIMetaFile aMtf;
+ const Rectangle aBoundRect( pObj->GetCurrentBoundRect() );
+ const MapMode aMap( pModel->GetScaleUnit(),
+ Point(),
+ pModel->GetScaleFraction(),
+ pModel->GetScaleFraction() );
+
+ aOut.EnableOutput( FALSE );
+ aOut.SetMapMode( aMap );
+ aMtf.Record( &aOut );
+ pObj->SingleObjectPainter( aOut ); // #110094#-17
+ aMtf.Stop();
+ aMtf.WindStart();
+
+ // #i99268# replace the original offset from using XOutDev's SetOffset
+ // NOT (as tried with #i92760#) with another MapMode which gets recorded
+ // by the Metafile itself (what always leads to problems), but by hardly
+ // moving the result
+ aMtf.Move(-aBoundRect.Left(), -aBoundRect.Top());
+
+ aMtf.SetPrefMapMode( aMap );
+ aMtf.SetPrefSize( aBoundRect.GetSize() );
+
+ if( aMtf.GetActionCount() )
+ aRet = aMtf;
+ }
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrExchangeView::DrawMarkedObj(OutputDevice& rOut) const
+{
+ SortMarkedObjects();
+
+ ::std::vector< ::std::vector< SdrMark* > > aObjVectors( 2 );
+ ::std::vector< SdrMark* >& rObjVector1 = aObjVectors[ 0 ];
+ ::std::vector< SdrMark* >& rObjVector2 = aObjVectors[ 1 ];
+ const SdrLayerAdmin& rLayerAdmin = pMod->GetLayerAdmin();
+ const sal_uInt32 nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName(), FALSE );
+ sal_uInt32 n, nCount;
+
+ for( n = 0, nCount = GetMarkedObjectCount(); n < nCount; n++ )
+ {
+ SdrMark* pMark = GetSdrMarkByIndex( n );
+
+ // paint objects on control layer on top of all otherobjects
+ if( nControlLayerId == pMark->GetMarkedSdrObj()->GetLayer() )
+ rObjVector2.push_back( pMark );
+ else
+ rObjVector1.push_back( pMark );
+ }
+
+ for( n = 0, nCount = aObjVectors.size(); n < nCount; n++ )
+ {
+ ::std::vector< SdrMark* >& rObjVector = aObjVectors[ n ];
+
+ for( sal_uInt32 i = 0; i < rObjVector.size(); i++ )
+ {
+ SdrMark* pMark = rObjVector[ i ];
+ pMark->GetMarkedSdrObj()->SingleObjectPainter( rOut ); // #110094#-17
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+SdrModel* SdrExchangeView::GetMarkedObjModel() const
+{
+ // Wenn das sortieren der MarkList mal stoeren sollte,
+ // werde ich sie mir wohl kopieren muessen.
+ SortMarkedObjects();
+ SdrModel* pNeuMod=pMod->AllocModel();
+ SdrPage* pNeuPag=pNeuMod->AllocPage(FALSE);
+ pNeuMod->InsertPage(pNeuPag);
+
+ if( !mxSelectionController.is() || !mxSelectionController->GetMarkedObjModel( pNeuPag ) )
+ {
+ ::std::vector< ::std::vector< SdrMark* > > aObjVectors( 2 );
+ ::std::vector< SdrMark* >& rObjVector1 = aObjVectors[ 0 ];
+ ::std::vector< SdrMark* >& rObjVector2 = aObjVectors[ 1 ];
+ const SdrLayerAdmin& rLayerAdmin = pMod->GetLayerAdmin();
+ const sal_uInt32 nControlLayerId = rLayerAdmin.GetLayerID( rLayerAdmin.GetControlLayerName(), FALSE );
+ sal_uInt32 n, nCount, nCloneErrCnt = 0;
+
+ for( n = 0, nCount = GetMarkedObjectCount(); n < nCount; n++ )
+ {
+ SdrMark* pMark = GetSdrMarkByIndex( n );
+
+ // paint objects on control layer on top of all otherobjects
+ if( nControlLayerId == pMark->GetMarkedSdrObj()->GetLayer() )
+ rObjVector2.push_back( pMark );
+ else
+ rObjVector1.push_back( pMark );
+ }
+
+ // #i13033#
+ // New mechanism to re-create the connections of cloned connectors
+ CloneList aCloneList;
+
+ for( n = 0, nCount = aObjVectors.size(); n < nCount; n++ )
+ {
+ ::std::vector< SdrMark* >& rObjVector = aObjVectors[ n ];
+
+ for( sal_uInt32 i = 0; i < rObjVector.size(); i++ )
+ {
+ const SdrMark* pMark = rObjVector[ i ];
+ const SdrObject* pObj = pMark->GetMarkedSdrObj();
+ SdrObject* pNeuObj;
+
+ if( pObj->ISA( SdrPageObj ) )
+ {
+ // convert SdrPageObj's to a graphic representation, because
+ // virtual connection to referenced page gets lost in new model
+ pNeuObj = new SdrGrafObj( GetObjGraphic( pMod, pObj ), pObj->GetLogicRect() );
+ pNeuObj->SetPage( pNeuPag );
+ pNeuObj->SetModel( pNeuMod );
+ }
+ else
+ {
+ // #116235#
+ // pNeuObj = pObj->Clone( pNeuPag, pNeuMod );
+ pNeuObj = pObj->Clone();
+ pNeuObj->SetPage( pNeuPag );
+ pNeuObj->SetModel( pNeuMod );
+ }
+
+ if( pNeuObj )
+ {
+ SdrInsertReason aReason(SDRREASON_VIEWCALL);
+ pNeuPag->InsertObject(pNeuObj,CONTAINER_APPEND,&aReason);
+
+ // #i13033#
+ aCloneList.AddPair(pObj, pNeuObj);
+ }
+ else
+ nCloneErrCnt++;
+ }
+ }
+
+ // #i13033#
+ // New mechanism to re-create the connections of cloned connectors
+ aCloneList.CopyConnections();
+
+ if(0L != nCloneErrCnt)
+ {
+#ifdef DBG_UTIL
+ ByteString aStr("SdrExchangeView::GetMarkedObjModel(): Fehler beim Clonen ");
+
+ if(nCloneErrCnt == 1)
+ {
+ aStr += "eines Zeichenobjekts.";
+ }
+ else
+ {
+ aStr += "von ";
+ aStr += ByteString::CreateFromInt32( nCloneErrCnt );
+ aStr += " Zeichenobjekten.";
+ }
+
+ aStr += " Objektverbindungen werden nicht mitkopiert.";
+
+ DBG_ERROR(aStr.GetBuffer());
+#endif
+ }
+ }
+ return pNeuMod;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL SdrExchangeView::Cut( ULONG /*nFormat */)
+{
+ DBG_ERROR( "SdrExchangeView::Cut: Not supported anymore" );
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrExchangeView::CutMarked( ULONG /*nFormat */)
+{
+ DBG_ERROR( "SdrExchangeView::CutMarked: Not supported anymore" );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL SdrExchangeView::Yank(ULONG /*nFormat*/)
+{
+ DBG_ERROR( "SdrExchangeView::Yank: Not supported anymore" );
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrExchangeView::YankMarked(ULONG /*nFormat*/)
+{
+ DBG_ERROR( "YankMarked: Not supported anymore" );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL SdrExchangeView::Paste(Window* /*pWin*/, ULONG /*nFormat*/)
+{
+ DBG_ERROR( "SdrExchangeView::Paste: Not supported anymore" );
+ return FALSE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/accessiblecell.cxx b/svx/source/table/accessiblecell.cxx
new file mode 100644
index 000000000000..9c8b0edb85d5
--- /dev/null
+++ b/svx/source/table/accessiblecell.cxx
@@ -0,0 +1,587 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <accessiblecell.hxx>
+
+#include "DescriptionGenerator.hxx"
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+
+#include <vcl/svapp.hxx>
+
+#include <unotools/accessiblestatesethelper.hxx>
+
+#include <editeng/outlobj.hxx>
+#include <svx/unoshtxt.hxx>
+#include <svx/svdotext.hxx>
+
+using ::rtl::OUString;
+using namespace ::sdr::table;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+
+namespace accessibility {
+
+// --------------------------------------------------------------------
+// AccessibleCell
+// --------------------------------------------------------------------
+
+AccessibleCell::AccessibleCell( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent, const sdr::table::CellRef& rCell, sal_Int32 nIndex, const AccessibleShapeTreeInfo& rShapeTreeInfo )
+: AccessibleCellBase( rxParent, AccessibleRole::TABLE_CELL )
+, maShapeTreeInfo( rShapeTreeInfo )
+, mnIndexInParent( nIndex )
+, mpText( NULL )
+, mxCell( rCell )
+{
+}
+
+// --------------------------------------------------------------------
+
+AccessibleCell::~AccessibleCell (void)
+{
+ DBG_ASSERT( mpText == 0, "svx::AccessibleCell::~AccessibleCell(), not disposed!?" );
+}
+
+// --------------------------------------------------------------------
+
+void AccessibleCell::Init (void)
+{
+ SdrView* pView = maShapeTreeInfo.GetSdrView();
+ const Window* pWindow = maShapeTreeInfo.GetWindow ();
+ if( (pView != NULL) && (pWindow != NULL) && mxCell.is())
+ {
+ OutlinerParaObject* pOutlinerParaObject = mxCell->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
+
+ bool bOwnParaObject = pOutlinerParaObject != 0;
+
+ if( !pOutlinerParaObject )
+ pOutlinerParaObject = mxCell->GetOutlinerParaObject();
+
+ // create AccessibleTextHelper to handle this shape's text
+ if( pOutlinerParaObject )
+ {
+ // non-empty text -> use full-fledged edit source right away
+ ::std::auto_ptr<SvxEditSource> pEditSource( new SvxTextEditSource( mxCell->GetObject(), mxCell.get(), *pView, *pWindow) );
+ mpText = new AccessibleTextHelper( pEditSource );
+ mpText->SetEventSource(this);
+ }
+
+ if( bOwnParaObject)
+ delete pOutlinerParaObject;
+ }
+}
+
+// --------------------------------------------------------------------
+
+sal_Bool AccessibleCell::SetState (sal_Int16 aState)
+{
+ sal_Bool bStateHasChanged = sal_False;
+
+ if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
+ {
+ // Offer FOCUSED state to edit engine and detect whether the state
+ // changes.
+ sal_Bool bIsFocused = mpText->HaveFocus ();
+ mpText->SetFocus (sal_True);
+ bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
+ }
+ else
+ bStateHasChanged = AccessibleContextBase::SetState (aState);
+
+ return bStateHasChanged;
+}
+
+// --------------------------------------------------------------------
+
+sal_Bool AccessibleCell::ResetState (sal_Int16 aState)
+{
+ sal_Bool bStateHasChanged = sal_False;
+
+ if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
+ {
+ // Try to remove FOCUSED state from the edit engine and detect
+ // whether the state changes.
+ sal_Bool bIsFocused = mpText->HaveFocus ();
+ mpText->SetFocus (sal_False);
+ bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
+ }
+ else
+ bStateHasChanged = AccessibleContextBase::ResetState (aState);
+
+ return bStateHasChanged;
+}
+
+// --------------------------------------------------------------------
+
+sal_Bool AccessibleCell::GetState (sal_Int16 aState)
+{
+ if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
+ {
+ // Just delegate the call to the edit engine. The state is not
+ // merged into the state set.
+ return mpText->HaveFocus();
+ }
+ else
+ return AccessibleContextBase::GetState (aState);
+}
+
+//-----------------------------------------------------------------------------
+
+bool AccessibleCell::operator== (const AccessibleCell& rAccessibleCell)
+{
+ return this == &rAccessibleCell;
+}
+
+//-----------------------------------------------------------------------------
+// XInterface
+//-----------------------------------------------------------------------------
+
+Any SAL_CALL AccessibleCell::queryInterface( const Type& aType ) throw (RuntimeException)
+{
+ return AccessibleCellBase::queryInterface( aType );
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL AccessibleCell::acquire( ) throw ()
+{
+ AccessibleCellBase::acquire();
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL AccessibleCell::release( ) throw ()
+{
+ AccessibleCellBase::release();
+}
+
+// --------------------------------------------------------------------
+// XAccessibleContext
+// --------------------------------------------------------------------
+
+/** The children of this cell come from the paragraphs of text.
+*/
+sal_Int32 SAL_CALL AccessibleCell::getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ThrowIfDisposed ();
+ return mpText != NULL ? mpText->GetChildCount () : 0;
+}
+
+// --------------------------------------------------------------------
+
+/** Forward the request to the shape. Return the requested shape or throw
+ an exception for a wrong index.
+*/
+Reference<XAccessible> SAL_CALL AccessibleCell::getAccessibleChild (sal_Int32 nIndex) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ThrowIfDisposed ();
+
+ // todo: does GetChild throw IndexOutOfBoundsException?
+ return mpText->GetChild (nIndex);
+}
+
+// --------------------------------------------------------------------
+
+/** Return a copy of the state set.
+ Possible states are:
+ ENABLED
+ SHOWING
+ VISIBLE
+*/
+Reference<XAccessibleStateSet> SAL_CALL AccessibleCell::getAccessibleStateSet (void) throw (RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard (maMutex);
+ Reference<XAccessibleStateSet> xStateSet;
+
+ if (rBHelper.bDisposed || mpText == NULL)
+ {
+ // Return a minimal state set that only contains the DEFUNC state.
+ xStateSet = AccessibleContextBase::getAccessibleStateSet ();
+ }
+ else
+ {
+ ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
+
+ if(pStateSet)
+ {
+ // Merge current FOCUSED state from edit engine.
+ if (mpText != NULL)
+ {
+ if (mpText->HaveFocus())
+ pStateSet->AddState (AccessibleStateType::FOCUSED);
+ else
+ pStateSet->RemoveState (AccessibleStateType::FOCUSED);
+ }
+
+ // Create a copy of the state set that may be modified by the
+ // caller without affecting the current state set.
+ xStateSet = Reference<XAccessibleStateSet>(new ::utl::AccessibleStateSetHelper (*pStateSet));
+ }
+ }
+
+ return xStateSet;
+}
+
+// --------------------------------------------------------------------
+// XAccessibleComponent
+// --------------------------------------------------------------------
+
+sal_Bool SAL_CALL AccessibleCell::containsPoint( const ::com::sun::star::awt::Point& aPoint) throw (::com::sun::star::uno::RuntimeException)
+{
+ return AccessibleComponentBase::containsPoint( aPoint );
+}
+
+/** The implementation below is at the moment straightforward. It iterates
+ over all children (and thereby instances all children which have not
+ been already instatiated) until a child covering the specifed point is
+ found.
+ This leaves room for improvement. For instance, first iterate only over
+ the already instantiated children and only if no match is found
+ instantiate the remaining ones.
+*/
+Reference<XAccessible > SAL_CALL AccessibleCell::getAccessibleAtPoint ( const ::com::sun::star::awt::Point& aPoint) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard (maMutex);
+
+ sal_Int32 nChildCount = getAccessibleChildCount ();
+ for (sal_Int32 i=0; i<nChildCount; ++i)
+ {
+ Reference<XAccessible> xChild (getAccessibleChild (i));
+ if (xChild.is())
+ {
+ Reference<XAccessibleComponent> xChildComponent (xChild->getAccessibleContext(), uno::UNO_QUERY);
+ if (xChildComponent.is())
+ {
+ awt::Rectangle aBBox (xChildComponent->getBounds());
+ if ( (aPoint.X >= aBBox.X)
+ && (aPoint.Y >= aBBox.Y)
+ && (aPoint.X < aBBox.X+aBBox.Width)
+ && (aPoint.Y < aBBox.Y+aBBox.Height) )
+ return xChild;
+ }
+ }
+ }
+
+ // Have not found a child under the given point. Returning empty
+ // reference to indicate this.
+ return uno::Reference<XAccessible>();
+}
+
+// --------------------------------------------------------------------
+
+::com::sun::star::awt::Rectangle SAL_CALL AccessibleCell::getBounds(void) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard (maMutex);
+
+ ThrowIfDisposed ();
+ ::com::sun::star::awt::Rectangle aBoundingBox;
+ if( mxCell.is() )
+ {
+ // Get the cell's bounding box in internal coordinates (in 100th of mm)
+ const ::Rectangle aCellRect( mxCell->getCellRect() );
+
+ // Transform coordinates from internal to pixel.
+ if (maShapeTreeInfo.GetViewForwarder() == NULL)
+ throw uno::RuntimeException (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleCell has no valid view forwarder")),static_cast<uno::XWeak*>(this));
+
+ ::Size aPixelSize( maShapeTreeInfo.GetViewForwarder()->LogicToPixel(::Size(aCellRect.GetWidth(), aCellRect.GetHeight())) );
+ ::Point aPixelPosition( maShapeTreeInfo.GetViewForwarder()->LogicToPixel( aCellRect.TopLeft() ));
+
+ // Clip the shape's bounding box with the bounding box of its parent.
+ Reference<XAccessibleComponent> xParentComponent ( getAccessibleParent(), uno::UNO_QUERY);
+ if (xParentComponent.is())
+ {
+ // Make the coordinates relative to the parent.
+ awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
+ int x = aPixelPosition.getX() - aParentLocation.X;
+ int y = aPixelPosition.getY() - aParentLocation.Y;
+
+ // Clip with parent (with coordinates relative to itself).
+ ::Rectangle aBBox ( x, y, x + aPixelSize.getWidth(), y + aPixelSize.getHeight());
+ awt::Size aParentSize (xParentComponent->getSize());
+ ::Rectangle aParentBBox (0,0, aParentSize.Width, aParentSize.Height);
+ aBBox = aBBox.GetIntersection (aParentBBox);
+ aBoundingBox = awt::Rectangle ( aBBox.getX(), aBBox.getY(), aBBox.getWidth(), aBBox.getHeight());
+ }
+ else
+ {
+ OSL_TRACE ("parent does not support component");
+ aBoundingBox = awt::Rectangle (aPixelPosition.getX(), aPixelPosition.getY(),aPixelSize.getWidth(), aPixelSize.getHeight());
+ }
+ }
+
+ return aBoundingBox;
+}
+
+// --------------------------------------------------------------------
+
+::com::sun::star::awt::Point SAL_CALL AccessibleCell::getLocation(void) throw (RuntimeException)
+{
+ ThrowIfDisposed ();
+ ::com::sun::star::awt::Rectangle aBoundingBox(getBounds());
+ return ::com::sun::star::awt::Point(aBoundingBox.X, aBoundingBox.Y);
+}
+
+// --------------------------------------------------------------------
+
+::com::sun::star::awt::Point SAL_CALL AccessibleCell::getLocationOnScreen(void) throw(RuntimeException)
+{
+ ThrowIfDisposed ();
+
+ // Get relative position...
+ ::com::sun::star::awt::Point aLocation(getLocation ());
+
+ // ... and add absolute position of the parent.
+ Reference<XAccessibleComponent> xParentComponent( getAccessibleParent(), uno::UNO_QUERY);
+ if(xParentComponent.is())
+ {
+ ::com::sun::star::awt::Point aParentLocation(xParentComponent->getLocationOnScreen());
+ aLocation.X += aParentLocation.X;
+ aLocation.Y += aParentLocation.Y;
+ }
+ else
+ {
+ OSL_TRACE ("getLocation: parent does not support XAccessibleComponent");
+ }
+
+ return aLocation;
+}
+
+// --------------------------------------------------------------------
+
+awt::Size SAL_CALL AccessibleCell::getSize (void) throw (RuntimeException)
+{
+ ThrowIfDisposed ();
+ awt::Rectangle aBoundingBox (getBounds());
+ return awt::Size (aBoundingBox.Width, aBoundingBox.Height);
+}
+
+// --------------------------------------------------------------------
+
+void SAL_CALL AccessibleCell::addFocusListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener) throw (::com::sun::star::uno::RuntimeException)
+{
+ AccessibleComponentBase::addFocusListener( xListener );
+}
+
+// --------------------------------------------------------------------
+
+void SAL_CALL AccessibleCell::removeFocusListener (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
+{
+ AccessibleComponentBase::removeFocusListener( xListener );
+}
+
+// --------------------------------------------------------------------
+
+void SAL_CALL AccessibleCell::grabFocus (void) throw (::com::sun::star::uno::RuntimeException)
+{
+ AccessibleComponentBase::grabFocus();
+}
+
+// --------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleCell::getForeground(void) throw (RuntimeException)
+{
+ ThrowIfDisposed ();
+ sal_Int32 nColor (0x0ffffffL);
+
+ // todo
+ return nColor;
+}
+
+// --------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleCell::getBackground (void) throw (RuntimeException)
+{
+ ThrowIfDisposed ();
+ sal_Int32 nColor (0L);
+
+ // todo
+ return nColor;
+}
+
+// --------------------------------------------------------------------
+// XAccessibleExtendedComponent
+// --------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL AccessibleCell::getFont (void) throw (::com::sun::star::uno::RuntimeException)
+{
+//todo
+ return AccessibleComponentBase::getFont();
+}
+
+// --------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL AccessibleCell::getTitledBorderText (void) throw (::com::sun::star::uno::RuntimeException)
+{
+ return AccessibleComponentBase::getTitledBorderText();
+}
+
+// --------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL AccessibleCell::getToolTipText (void) throw (::com::sun::star::uno::RuntimeException)
+{
+ return AccessibleComponentBase::getToolTipText();
+}
+
+// --------------------------------------------------------------------
+// XAccessibleEventBroadcaster
+// --------------------------------------------------------------------
+
+void SAL_CALL AccessibleCell::addEventListener( const Reference<XAccessibleEventListener >& rxListener) throw (RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard (maMutex);
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ {
+ Reference<XInterface> xSource( static_cast<XComponent *>(this) );
+ lang::EventObject aEventObj(xSource);
+ rxListener->disposing(aEventObj);
+ }
+ else
+ {
+ AccessibleContextBase::addEventListener (rxListener);
+ if (mpText != NULL)
+ mpText->AddEventListener (rxListener);
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SAL_CALL AccessibleCell::removeEventListener( const Reference<XAccessibleEventListener >& rxListener) throw (RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ AccessibleContextBase::removeEventListener(rxListener);
+ if (mpText != NULL)
+ mpText->RemoveEventListener (rxListener);
+}
+
+// --------------------------------------------------------------------
+// XServiceInfo
+// --------------------------------------------------------------------
+
+OUString SAL_CALL AccessibleCell::getImplementationName(void) throw (RuntimeException)
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleCell"));
+}
+
+// --------------------------------------------------------------------
+
+Sequence<OUString> SAL_CALL AccessibleCell::getSupportedServiceNames(void) throw (RuntimeException)
+{
+ ThrowIfDisposed ();
+
+ // Get list of supported service names from base class...
+ uno::Sequence<OUString> aServiceNames = AccessibleContextBase::getSupportedServiceNames();
+ sal_Int32 nCount (aServiceNames.getLength());
+
+ // ...and add additional names.
+ aServiceNames.realloc (nCount + 1);
+ static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.AccessibleCell"));
+ aServiceNames[nCount] = sAdditionalServiceName;
+
+ return aServiceNames;
+}
+
+// --------------------------------------------------------------------
+// IAccessibleViewForwarderListener
+// --------------------------------------------------------------------
+
+void AccessibleCell::ViewForwarderChanged (ChangeType /*aChangeType*/, const IAccessibleViewForwarder* /*pViewForwarder*/)
+{
+ // Inform all listeners that the graphical representation (i.e. size
+ // and/or position) of the shape has changed.
+ CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any());
+
+ // update our children that our screen position might have changed
+ if( mpText )
+ mpText->UpdateChildren();
+}
+
+// --------------------------------------------------------------------
+// protected
+// --------------------------------------------------------------------
+
+void AccessibleCell::disposing (void)
+{
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard (maMutex);
+
+ // Make sure to send an event that this object looses the focus in the
+ // case that it has the focus.
+ ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
+ if (pStateSet != NULL)
+ pStateSet->RemoveState(AccessibleStateType::FOCUSED);
+
+ if (mpText != NULL)
+ {
+ mpText->Dispose();
+ delete mpText;
+ mpText = NULL;
+ }
+
+ // Cleanup. Remove references to objects to allow them to be
+ // destroyed.
+ mxCell.clear();
+ maShapeTreeInfo = AccessibleShapeTreeInfo();
+
+ // Call base classes.
+ AccessibleContextBase::dispose ();
+}
+
+sal_Int32 SAL_CALL AccessibleCell::getAccessibleIndexInParent (void) throw (RuntimeException)
+{
+ ThrowIfDisposed ();
+ return mnIndexInParent;
+}
+
+::rtl::OUString SAL_CALL AccessibleCell::getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException)
+{
+ ThrowIfDisposed ();
+ SolarMutexGuard aSolarGuard;
+
+ if( mxCell.is() )
+ return mxCell->getName();
+
+ return AccessibleCellBase::getAccessibleName();
+}
+
+} // end of namespace accessibility
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/accessiblecell.hxx b/svx/source/table/accessiblecell.hxx
new file mode 100644
index 000000000000..7d2fd221c1ea
--- /dev/null
+++ b/svx/source/table/accessiblecell.hxx
@@ -0,0 +1,152 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_ACCESSIBILITY_ACCESSIBLE_CELL_HXX
+#define _SVX_ACCESSIBILITY_ACCESSIBLE_CELL_HXX
+
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+
+#include <rtl/ref.hxx>
+
+#include <editeng/AccessibleContextBase.hxx>
+#include <editeng/AccessibleComponentBase.hxx>
+#include <svx/IAccessibleViewForwarderListener.hxx>
+#include <svx/AccessibleTextHelper.hxx>
+#include <svx/AccessibleShapeTreeInfo.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+
+#include "cell.hxx"
+
+#include <boost/noncopyable.hpp>
+
+class SdrObject;
+
+
+namespace accessibility
+{
+
+class AccessibleShapeInfo;
+class AccessibleShapeTreeInfo;
+class IAccessibleParent;
+
+typedef ::cppu::ImplInheritanceHelper1< AccessibleContextBase, ::com::sun::star::accessibility::XAccessibleExtendedComponent > AccessibleCellBase;
+
+class AccessibleCell : boost::noncopyable, public AccessibleCellBase, public AccessibleComponentBase, public IAccessibleViewForwarderListener
+{
+public:
+ AccessibleCell( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent, const sdr::table::CellRef& rCell, sal_Int32 nIndex, const AccessibleShapeTreeInfo& rShapeTreeInfo);
+ virtual ~AccessibleCell (void);
+
+ virtual void Init (void);
+
+ virtual bool operator== (const AccessibleCell& rAccessibleCell);
+
+ virtual sal_Bool SetState (sal_Int16 aState);
+ virtual sal_Bool ResetState (sal_Int16 aState);
+ sal_Bool GetState (sal_Int16 aState);
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire( ) throw ();
+ virtual void SAL_CALL release( ) throw ();
+
+ // XAccessibleContext
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL getAccessibleChild(sal_Int32 nIndex) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL getAccessibleStateSet(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleComponent
+ virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const ::com::sun::star::awt::Point& aPoint) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocation(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addFocusListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeFocusListener (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getForeground(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getBackground(void) throw(::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleExtendedComponent
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTitledBorderText (void) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getToolTipText (void) throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleEventBroadcaster
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName (void) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames (void) throw(::com::sun::star::uno::RuntimeException);
+
+ // IAccessibleViewForwarderListener
+ virtual void ViewForwarderChanged (ChangeType aChangeType, const IAccessibleViewForwarder* pViewForwarder);
+
+ using cppu::WeakComponentImplHelperBase::addEventListener;
+ using cppu::WeakComponentImplHelperBase::removeEventListener;
+
+ // Misc
+
+ /** set the index _nIndex at the accessible cell param _nIndex The new index in parent.
+ */
+ inline void setIndexInParent(sal_Int32 _nIndex) { mnIndexInParent = _nIndex; }
+
+protected:
+ /// Bundle of information passed to all shapes in a document tree.
+ AccessibleShapeTreeInfo maShapeTreeInfo;
+
+ /// the index in parent.
+ sal_Int32 mnIndexInParent;
+
+ /// The accessible text engine. May be NULL if it can not be created.
+ AccessibleTextHelper* mpText;
+
+ sdr::table::CellRef mxCell;
+
+ /// This method is called from the component helper base class while disposing.
+ virtual void SAL_CALL disposing (void);
+
+private:
+ explicit AccessibleCell(void); // not implemented
+ explicit AccessibleCell(const AccessibleCell&); // not implemented
+ AccessibleCell& operator=(const AccessibleCell&); // not implemented
+};
+
+} // end of namespace accessibility
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/accessibletableshape.cxx b/svx/source/table/accessibletableshape.cxx
new file mode 100644
index 000000000000..d563e0ca5549
--- /dev/null
+++ b/svx/source/table/accessibletableshape.cxx
@@ -0,0 +1,726 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/table/XMergeableCell.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+
+#include <comphelper/accessiblewrapper.hxx>
+#include <osl/mutex.hxx>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+
+#include <svx/AccessibleTableShape.hxx>
+#include "tablecontroller.hxx"
+#include "accessiblecell.hxx"
+
+#include <algorithm>
+
+#include <cppuhelper/implbase1.hxx>
+
+using ::rtl::OUString;
+
+using namespace ::accessibility;
+using namespace ::sdr::table;
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::container;
+
+#define C2U(x) OUString(RTL_CONSTASCII_USTRINGPARAM(x))
+
+namespace accessibility
+{
+
+struct hash
+{
+ std::size_t operator()( const Reference< XCell >& xCell ) const
+ {
+ return std::size_t( xCell.get() );
+ }
+};
+
+typedef std::hash_map< Reference< XCell >, rtl::Reference< AccessibleCell >, hash > AccessibleCellMap;
+
+//-----------------------------------------------------------------------------
+// AccessibleTableShapeImpl
+//-----------------------------------------------------------------------------
+
+class AccessibleTableShapeImpl : public cppu::WeakImplHelper1< XModifyListener >
+{
+public:
+ AccessibleTableShapeImpl( AccessibleShapeTreeInfo& rShapeTreeInfo );
+
+ void init( const Reference< XAccessible>& xAccessible, const Reference< XTable >& xTable );
+ void dispose();
+
+ Reference< XAccessible > getAccessibleChild( sal_Int32 i ) throw(IndexOutOfBoundsException);
+ void getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow ) throw (IndexOutOfBoundsException );
+
+ // XModifyListener
+ virtual void SAL_CALL modified( const EventObject& aEvent ) throw (RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+
+ AccessibleShapeTreeInfo& mrShapeTreeInfo;
+ Reference< XTable > mxTable;
+ AccessibleCellMap maChildMap;
+ Reference< XAccessible> mxAccessible;
+};
+
+//-----------------------------------------------------------------------------
+
+AccessibleTableShapeImpl::AccessibleTableShapeImpl( AccessibleShapeTreeInfo& rShapeTreeInfo )
+: mrShapeTreeInfo( rShapeTreeInfo )
+{
+}
+
+//-----------------------------------------------------------------------------
+
+void AccessibleTableShapeImpl::init( const Reference< XAccessible>& xAccessible, const Reference< XTable >& xTable )
+{
+ mxAccessible = xAccessible;
+ mxTable = xTable;
+
+ if( mxTable.is() )
+ {
+ Reference< XModifyListener > xListener( this );
+ mxTable->addModifyListener( xListener );
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void AccessibleTableShapeImpl::dispose()
+{
+ if( mxTable.is() )
+ {
+ Reference< XModifyListener > xListener( this );
+ mxTable->removeModifyListener( xListener );
+ mxTable.clear();
+ }
+ mxAccessible.clear();
+}
+
+//-----------------------------------------------------------------------------
+
+Reference< XAccessible > AccessibleTableShapeImpl::getAccessibleChild( sal_Int32 nChildIndex ) throw(IndexOutOfBoundsException)
+{
+ sal_Int32 nColumn = 0, nRow = 0;
+ getColumnAndRow( nChildIndex, nColumn, nRow );
+
+ Reference< XCell > xCell( mxTable->getCellByPosition( nColumn, nRow ) );
+ AccessibleCellMap::iterator iter( maChildMap.find( xCell ) );
+
+ if( iter != maChildMap.end() )
+ {
+ Reference< XAccessible > xChild( (*iter).second.get() );
+ return xChild;
+ }
+ else
+ {
+ CellRef xCellRef( dynamic_cast< Cell* >( xCell.get() ) );
+
+ rtl::Reference< AccessibleCell > xAccessibleCell( new AccessibleCell( mxAccessible, xCellRef, nChildIndex, mrShapeTreeInfo ) );
+
+ maChildMap[xCell] = xAccessibleCell;
+
+ xAccessibleCell->Init();
+
+ Reference< XAccessible > xChild( xAccessibleCell.get() );
+ return xChild;
+ }
+}
+
+//-----------------------------------------------------------------------------
+
+void AccessibleTableShapeImpl::getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow ) throw (IndexOutOfBoundsException )
+{
+ rnRow = 0;
+ rnColumn = nChildIndex;
+
+ if( mxTable.is() )
+ {
+ const sal_Int32 nColumnCount = mxTable->getColumnCount();
+ while( rnColumn >= nColumnCount )
+ {
+ rnRow++;
+ rnColumn -= nColumnCount;
+ }
+
+ if( rnRow < mxTable->getRowCount() )
+ return;
+ }
+
+ throw IndexOutOfBoundsException();
+}
+
+// XModifyListener
+void SAL_CALL AccessibleTableShapeImpl::modified( const EventObject& /*aEvent*/ ) throw (RuntimeException)
+{
+ if( mxTable.is() ) try
+ {
+ // structural changes may have happened to the table, validate all accessible cell instances
+ AccessibleCellMap aTempChildMap;
+ aTempChildMap.swap( maChildMap );
+
+ // first move all still existing cells to maChildMap again and update their index
+
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+
+ sal_Int32 nChildIndex = 0;
+
+ for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol )
+ {
+ Reference< XCell > xCell( mxTable->getCellByPosition( nCol, nRow ) );
+ AccessibleCellMap::iterator iter( aTempChildMap.find( xCell ) );
+
+ if( iter != aTempChildMap.end() )
+ {
+ rtl::Reference< AccessibleCell > xAccessibleCell( (*iter).second );
+ xAccessibleCell->setIndexInParent( nChildIndex );
+ xAccessibleCell->CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any());
+
+ // move still existing cell from temporary child map to our child map
+ maChildMap[xCell] = xAccessibleCell;
+ aTempChildMap.erase( iter );
+ }
+
+ ++nChildIndex;
+ }
+ }
+
+ // all accessible cell instances still left in aTempChildMap must be disposed
+ // as they are no longer part of the table
+
+ for( AccessibleCellMap::iterator iter( aTempChildMap.begin() ); iter != aTempChildMap.end(); iter++ )
+ {
+ (*iter).second->dispose();
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("svx::AccessibleTableShape::modified(), exception caught!");
+ }
+}
+
+// XEventListener
+void SAL_CALL AccessibleTableShapeImpl::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
+{
+}
+
+//-----------------------------------------------------------------------------
+// AccessibleTableShape
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+
+AccessibleTableShape::AccessibleTableShape( const AccessibleShapeInfo& rShapeInfo, const AccessibleShapeTreeInfo& rShapeTreeInfo)
+: AccessibleTableShape_Base(rShapeInfo, rShapeTreeInfo)
+, mxImpl( new AccessibleTableShapeImpl( maShapeTreeInfo ) )
+{
+}
+
+//-----------------------------------------------------------------------------
+
+AccessibleTableShape::~AccessibleTableShape (void)
+{
+}
+
+//-----------------------------------------------------------------------------
+
+void AccessibleTableShape::Init()
+{
+ try
+ {
+
+ Reference< XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
+ Reference< XTable > xTable( xSet->getPropertyValue(C2U("Model")), UNO_QUERY_THROW );
+
+ mxImpl->init( this, xTable );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("AccessibleTableShape::init(), exception caught?");
+ }
+
+ AccessibleTableShape_Base::Init();
+}
+
+//-----------------------------------------------------------------------------
+
+SvxTableController* AccessibleTableShape::getTableController()
+{
+ SdrView* pView = maShapeTreeInfo.GetSdrView ();
+ if( pView )
+ return dynamic_cast< SvxTableController* >( pView->getSelectionController().get() );
+ else
+ return 0;
+}
+
+//-----------------------------------------------------------------------------
+// XInterface
+//-----------------------------------------------------------------------------
+
+Any SAL_CALL AccessibleTableShape::queryInterface( const Type& aType ) throw (RuntimeException)
+{
+ return AccessibleTableShape_Base::queryInterface( aType );
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL AccessibleTableShape::acquire( ) throw ()
+{
+ AccessibleTableShape_Base::acquire();
+}
+
+//-----------------------------------------------------------------------------
+
+void SAL_CALL AccessibleTableShape::release( ) throw ()
+{
+ AccessibleTableShape_Base::release();
+}
+
+//-----------------------------------------------------------------------------
+// XAccessible
+//-----------------------------------------------------------------------------
+
+Reference< XAccessibleContext > SAL_CALL AccessibleTableShape::getAccessibleContext(void) throw (RuntimeException)
+{
+ return AccessibleShape::getAccessibleContext ();
+}
+
+//-----------------------------------------------------------------------------
+OUString SAL_CALL AccessibleTableShape::getImplementationName(void) throw (RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.accessibility.AccessibleTableShape" ) );
+}
+
+//-----------------------------------------------------------------------------
+
+OUString AccessibleTableShape::CreateAccessibleBaseName(void) throw (RuntimeException)
+{
+ return OUString (RTL_CONSTASCII_USTRINGPARAM("TableShape"));;
+}
+
+//--------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleChildCount( ) throw(RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ return mxImpl->mxTable.is() ? mxImpl->mxTable->getRowCount() * mxImpl->mxTable->getColumnCount() : 0;
+}
+
+//--------------------------------------------------------------------
+Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleChild( sal_Int32 i ) throw(IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ ThrowIfDisposed();
+
+ return mxImpl->getAccessibleChild( i );
+}
+
+//--------------------------------------------------------------------
+Reference< XAccessibleRelationSet > SAL_CALL AccessibleTableShape::getAccessibleRelationSet( ) throw (RuntimeException)
+{
+ return AccessibleShape::getAccessibleRelationSet( );
+}
+
+//--------------------------------------------------------------------
+
+sal_Int16 SAL_CALL AccessibleTableShape::getAccessibleRole (void) throw (RuntimeException)
+{
+ return AccessibleRole::TABLE;
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL AccessibleTableShape::disposing (void)
+{
+ mxImpl->dispose();
+
+ // let the base do it's stuff
+ AccessibleShape::disposing();
+}
+
+//--------------------------------------------------------------------
+// XAccessibleTable
+//--------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleRowCount() throw (RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ return mxImpl->mxTable.is() ? mxImpl->mxTable->getRowCount() : 0;
+}
+
+//--------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleColumnCount( ) throw (RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ return mxImpl->mxTable.is() ? mxImpl->mxTable->getColumnCount() : 0;
+}
+
+//--------------------------------------------------------------------
+
+OUString SAL_CALL AccessibleTableShape::getAccessibleRowDescription( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ checkCellPosition( 0, nRow );
+ return OUString();
+}
+
+//--------------------------------------------------------------------
+
+OUString SAL_CALL AccessibleTableShape::getAccessibleColumnDescription( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ checkCellPosition( nColumn, 0 );
+ return OUString();
+}
+
+//--------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ checkCellPosition( nColumn, nRow );
+ if( mxImpl->mxTable.is() )
+ {
+ Reference< XMergeableCell > xCell( mxImpl->mxTable->getCellByPosition( nColumn, nRow ), UNO_QUERY );
+ if( xCell.is() )
+ return xCell->getRowSpan();
+ }
+ return 1;
+}
+
+//--------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ checkCellPosition( nColumn, nRow );
+ if( mxImpl->mxTable.is() )
+ {
+ Reference< XMergeableCell > xCell( mxImpl->mxTable->getCellByPosition( nColumn, nRow ), UNO_QUERY );
+ if( xCell.is() )
+ return xCell->getColumnSpan();
+ }
+ return 1;
+}
+
+//--------------------------------------------------------------------
+
+Reference< XAccessibleTable > SAL_CALL AccessibleTableShape::getAccessibleRowHeaders( ) throw (RuntimeException)
+{
+ Reference< XAccessibleTable > xRet( this ); // todo
+ return xRet;
+}
+
+//--------------------------------------------------------------------
+
+Reference< XAccessibleTable > SAL_CALL AccessibleTableShape::getAccessibleColumnHeaders( ) throw (RuntimeException)
+{
+ Reference< XAccessibleTable > xRet( this ); // todo
+ return xRet;
+}
+
+//--------------------------------------------------------------------
+
+Sequence< sal_Int32 > SAL_CALL AccessibleTableShape::getSelectedAccessibleRows( ) throw (RuntimeException)
+{
+ Sequence< sal_Int32 > aRet;
+ return aRet;
+}
+
+//--------------------------------------------------------------------
+
+Sequence< sal_Int32 > SAL_CALL AccessibleTableShape::getSelectedAccessibleColumns( ) throw (RuntimeException)
+{
+ Sequence< sal_Int32 > aRet;
+ return aRet;
+}
+
+//--------------------------------------------------------------------
+
+sal_Bool SAL_CALL AccessibleTableShape::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ checkCellPosition( 0, nRow );
+ return sal_False;
+}
+
+//--------------------------------------------------------------------
+
+sal_Bool SAL_CALL AccessibleTableShape::isAccessibleColumnSelected( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ checkCellPosition( nColumn, 0 );
+ return sal_False;
+}
+
+//--------------------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ checkCellPosition( nColumn, nRow );
+
+ sal_Int32 nChildIndex = 0;
+ if( mxImpl->mxTable.is() )
+ nChildIndex = mxImpl->mxTable->getColumnCount() * nRow + nColumn;
+
+ return getAccessibleChild( nChildIndex );
+}
+
+//--------------------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleCaption( ) throw (RuntimeException)
+{
+ Reference< XAccessible > xRet;
+ return xRet;
+}
+
+//--------------------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleSummary( ) throw (RuntimeException)
+{
+ Reference< XAccessible > xRet;
+ return xRet;
+}
+
+//--------------------------------------------------------------------
+
+sal_Bool SAL_CALL AccessibleTableShape::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ checkCellPosition( nColumn, nRow );
+
+ SvxTableController* pController = getTableController();
+ if( pController && pController->hasSelectedCells() )
+ {
+ CellPos aFirstPos, aLastPos;
+ pController->getSelectedCells( aFirstPos, aLastPos );
+ if( (aFirstPos.mnRow <= nRow) && (aFirstPos.mnCol <= nColumn) && (nRow <= aLastPos.mnRow) && (nColumn <= aLastPos.mnCol) )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+//--------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ checkCellPosition( nColumn, nRow );
+ return mxImpl->mxTable.is() ? (nRow * mxImpl->mxTable->getColumnCount() + nColumn) : 0;
+}
+
+//--------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleRow( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ sal_Int32 nColumn = 0, nRow = 0;
+ mxImpl->getColumnAndRow( nChildIndex, nColumn, nRow );
+ return nRow;
+}
+
+//--------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleColumn( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ sal_Int32 nColumn = 0, nRow = 0;
+ mxImpl->getColumnAndRow( nChildIndex, nColumn, nRow );
+ return nChildIndex;
+}
+
+//--------------------------------------------------------------------
+// XAccessibleSelection
+//--------------------------------------------------------------------
+
+void SAL_CALL AccessibleTableShape::selectAccessibleChild( sal_Int32 nChildIndex ) throw ( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aSolarGuard;
+ CellPos aPos;
+ mxImpl->getColumnAndRow( nChildIndex, aPos.mnCol, aPos.mnRow );
+
+ // todo, select table shape?!?
+ SvxTableController* pController = getTableController();
+ if( pController )
+ {
+ CellPos aFirstPos( aPos ), aLastPos( aPos );
+ if( pController->hasSelectedCells() )
+ {
+ pController->getSelectedCells( aFirstPos, aLastPos );
+
+ aFirstPos.mnRow = std::min( aFirstPos.mnRow, aPos.mnRow );
+ aFirstPos.mnCol = std::min( aFirstPos.mnCol, aPos.mnCol );
+ aLastPos.mnRow = std::max( aLastPos.mnRow, aPos.mnRow );
+ aLastPos.mnCol = std::max( aLastPos.mnCol, aPos.mnCol );
+ }
+ pController->setSelectedCells( aFirstPos, aLastPos );
+ }
+}
+
+//--------------------------------------------------------------------
+
+sal_Bool SAL_CALL AccessibleTableShape::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw ( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aSolarGuard;
+ CellPos aPos;
+ mxImpl->getColumnAndRow( nChildIndex, aPos.mnCol, aPos.mnRow );
+
+ return isAccessibleSelected(aPos.mnCol, aPos.mnRow);
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL AccessibleTableShape::clearAccessibleSelection() throw ( RuntimeException )
+{
+ SolarMutexGuard aSolarGuard;
+
+ SvxTableController* pController = getTableController();
+ if( pController )
+ pController->clearSelection();
+}
+//--------------------------------------------------------------------
+
+void SAL_CALL AccessibleTableShape::selectAllAccessibleChildren() throw ( RuntimeException )
+{
+ SolarMutexGuard aSolarGuard;
+
+ // todo: force selection of shape?
+ SvxTableController* pController = getTableController();
+ if( pController )
+ pController->selectAll();
+}
+
+//--------------------------------------------------------------------
+
+sal_Int32 SAL_CALL AccessibleTableShape::getSelectedAccessibleChildCount() throw ( RuntimeException )
+{
+ SolarMutexGuard aSolarGuard;
+
+ SvxTableController* pController = getTableController();
+ if( pController && pController->hasSelectedCells() )
+ {
+ CellPos aFirstPos, aLastPos;
+ pController->getSelectedCells( aFirstPos, aLastPos );
+
+ const sal_Int32 nSelectedColumns = std::max( (sal_Int32)0, aLastPos.mnCol - aFirstPos.mnCol ) + 1;
+ const sal_Int32 nSelectedRows = std::max( (sal_Int32)0, aLastPos.mnRow - aFirstPos.mnRow ) + 1;
+ return nSelectedRows * nSelectedColumns;
+ }
+
+ return 0;
+}
+
+//--------------------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL AccessibleTableShape::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw ( IndexOutOfBoundsException, RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+
+ SvxTableController* pController = getTableController();
+ if( pController && pController->hasSelectedCells() )
+ {
+ CellPos aFirstPos, aLastPos;
+ pController->getSelectedCells( aFirstPos, aLastPos );
+
+ const sal_Int32 nSelectedColumns = std::max( (sal_Int32)0, aLastPos.mnCol - aFirstPos.mnCol ) + 1;
+ const sal_Int32 nSelectedRows = std::max( (sal_Int32)0, aLastPos.mnRow - aFirstPos.mnRow ) + 1;
+
+ if( nSelectedChildIndex < (nSelectedRows * nSelectedColumns) )
+ {
+ while( nSelectedChildIndex >= nSelectedColumns )
+ {
+ aFirstPos.mnRow++;
+ nSelectedChildIndex -= nSelectedColumns;
+ }
+ return getAccessibleCellAt( nSelectedColumns, aFirstPos.mnRow );
+ }
+ }
+
+ throw IndexOutOfBoundsException();
+}
+
+//--------------------------------------------------------------------
+
+void SAL_CALL AccessibleTableShape::deselectAccessibleChild( sal_Int32 nChildIndex ) throw ( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aSolarGuard;
+ CellPos aPos;
+ mxImpl->getColumnAndRow( nChildIndex, aPos.mnCol, aPos.mnRow );
+
+ // todo, select table shape?!?
+ SvxTableController* pController = getTableController();
+ if( pController && pController->hasSelectedCells() )
+ {
+ CellPos aFirstPos, aLastPos;
+ pController->getSelectedCells( aFirstPos, aLastPos );
+
+ // create a selection where aPos is not part of anymore
+ aFirstPos.mnRow = std::min( aFirstPos.mnRow, aPos.mnRow+1 );
+ aFirstPos.mnCol = std::min( aFirstPos.mnCol, aPos.mnCol+1 );
+ aLastPos.mnRow = std::max( aLastPos.mnRow, aPos.mnRow-1 );
+ aLastPos.mnCol = std::max( aLastPos.mnCol, aPos.mnCol-1 );
+
+ // new selection may be invalid (child to deselect is not at a border of the selection but in between)
+ if( (aFirstPos.mnRow > aLastPos.mnRow) || (aFirstPos.mnCol > aLastPos.mnCol) )
+ pController->clearSelection(); // if selection is invalid, clear all
+ else
+ pController->setSelectedCells( aFirstPos, aLastPos );
+ }
+}
+
+//--------------------------------------------------------------------
+
+void AccessibleTableShape::checkCellPosition( sal_Int32 nCol, sal_Int32 nRow ) throw ( IndexOutOfBoundsException )
+{
+ if( (nCol >= 0) && (nRow >= 0) && mxImpl->mxTable.is() && (nCol < mxImpl->mxTable->getColumnCount()) && (nRow < mxImpl->mxTable->getRowCount()) )
+ return;
+
+ throw IndexOutOfBoundsException();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx
new file mode 100644
index 000000000000..0030b622d33d
--- /dev/null
+++ b/svx/source/table/cell.cxx
@@ -0,0 +1,1811 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/drawing/BitmapMode.hpp>
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/text/WritingMode.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
+
+#include <cppuhelper/typeprovider.hxx>
+#include <svl/style.hxx>
+#include <svl/itemset.hxx>
+
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#include "svx/sdr/properties/textproperties.hxx"
+#include "editeng/outlobj.hxx"
+#include "editeng/writingmodeitem.hxx"
+#include "svx/svdotable.hxx"
+#include "svx/svdoutl.hxx"
+#include "svx/unoshtxt.hxx"
+#include "svx/svdmodel.hxx"
+
+#include "tableundo.hxx"
+#include "cell.hxx"
+#include "svx/svdotable.hxx"
+#include "svx/svdoutl.hxx"
+#include "svx/unoshtxt.hxx"
+#include "svx/unoshprp.hxx"
+#include "svx/unoshape.hxx"
+#include "editeng/editobj.hxx"
+#include "editeng/boxitem.hxx"
+#include "svx/xflbstit.hxx"
+#include "svx/xflbmtit.hxx"
+#include <svx/svdpool.hxx>
+
+// -----------------------------------------------------------------------------
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::container;
+
+// -----------------------------------------------------------------------------
+
+static const SvxItemPropertySet* ImplGetSvxCellPropertySet()
+{
+ // Propertymap fuer einen Outliner Text
+ static const SfxItemPropertyMapEntry aSvxCellPropertyMap[] =
+ {
+ FILL_PROPERTIES
+// { MAP_CHAR_LEN("HasLevels"), OWN_ATTR_HASLEVELS, &::getBooleanCppuType(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("Style"), OWN_ATTR_STYLE, &::com::sun::star::style::XStyle::static_type(), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
+ { MAP_CHAR_LEN(UNO_NAME_TEXT_WRITINGMODE), SDRATTR_TEXTDIRECTION, &::getCppuType( (::com::sun::star::text::WritingMode*) 0 ), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_TEXT_HORZADJUST), SDRATTR_TEXT_HORZADJUST, &::getCppuType((const ::com::sun::star::drawing::TextHorizontalAdjust*)0), 0, 0}, \
+ { MAP_CHAR_LEN(UNO_NAME_TEXT_LEFTDIST), SDRATTR_TEXT_LEFTDIST, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, \
+ { MAP_CHAR_LEN(UNO_NAME_TEXT_LOWERDIST), SDRATTR_TEXT_LOWERDIST, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, \
+ { MAP_CHAR_LEN(UNO_NAME_TEXT_RIGHTDIST), SDRATTR_TEXT_RIGHTDIST, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, \
+ { MAP_CHAR_LEN(UNO_NAME_TEXT_UPPERDIST), SDRATTR_TEXT_UPPERDIST, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM}, \
+ { MAP_CHAR_LEN(UNO_NAME_TEXT_VERTADJUST), SDRATTR_TEXT_VERTADJUST, &::getCppuType((const ::com::sun::star::drawing::TextVerticalAdjust*)0), 0, 0},\
+ { MAP_CHAR_LEN(UNO_NAME_TEXT_WORDWRAP), SDRATTR_TEXT_WORDWRAP, &::getBooleanCppuType(), 0, 0}, \
+
+ { MAP_CHAR_LEN("TableBorder"), OWN_ATTR_TABLEBORDER, &::getCppuType((const TableBorder*)0), 0, 0 }, \
+ { MAP_CHAR_LEN("TopBorder"), SDRATTR_TABLE_BORDER, &::getCppuType((const BorderLine*)0), 0, TOP_BORDER }, \
+ { MAP_CHAR_LEN("BottomBorder"), SDRATTR_TABLE_BORDER, &::getCppuType((const BorderLine*)0), 0, BOTTOM_BORDER }, \
+ { MAP_CHAR_LEN("LeftBorder"), SDRATTR_TABLE_BORDER, &::getCppuType((const BorderLine*)0), 0, LEFT_BORDER }, \
+ { MAP_CHAR_LEN("RightBorder"), SDRATTR_TABLE_BORDER, &::getCppuType((const BorderLine*)0), 0, RIGHT_BORDER }, \
+
+ SVX_UNOEDIT_OUTLINER_PROPERTIES,
+ SVX_UNOEDIT_CHAR_PROPERTIES,
+ SVX_UNOEDIT_PARA_PROPERTIES,
+ {0,0,0,0,0,0}
+ };
+
+ static SvxItemPropertySet aSvxCellPropertySet( aSvxCellPropertyMap, SdrObject::GetGlobalDrawObjectItemPool() );
+ return &aSvxCellPropertySet;
+}
+
+namespace sdr
+{
+ namespace properties
+ {
+ class CellProperties : public TextProperties
+ {
+ protected:
+ // create a new itemset
+ SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& rPool);
+
+ public:
+ // basic constructor
+ CellProperties(SdrObject& rObj, sdr::table::Cell* pCell );
+
+ // constructor for copying, but using new object
+ CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell);
+
+ // destructor
+ ~CellProperties();
+
+ // Clone() operator, normally just calls the local copy constructor
+ BaseProperties& Clone(SdrObject& rObj) const;
+
+ void ForceDefaultAttributes();
+
+ void ItemSetChanged(const SfxItemSet& rSet);
+
+ void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem);
+
+ void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr);
+
+ sdr::table::CellRef mxCell;
+ };
+
+ // create a new itemset
+ SfxItemSet& CellProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+ {
+ return *(new SfxItemSet(rPool,
+
+ // range from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // range for SdrTableObj
+ SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
+
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+
+ // end
+ 0, 0));
+ }
+
+ CellProperties::CellProperties(SdrObject& rObj, sdr::table::Cell* pCell)
+ : TextProperties(rObj)
+ , mxCell(pCell)
+ {
+ }
+
+ CellProperties::CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell)
+ : TextProperties(rProps, rObj)
+ , mxCell( pCell )
+ {
+ }
+
+ CellProperties::~CellProperties()
+ {
+ }
+
+ BaseProperties& CellProperties::Clone(SdrObject& rObj) const
+ {
+ DBG_ERROR("CellProperties::Clone(), does not work yet!");
+ return *(new CellProperties(*this, rObj,0));
+ }
+
+ void CellProperties::ForceDefaultAttributes()
+ {
+ }
+
+ void CellProperties::ItemSetChanged(const SfxItemSet& rSet )
+ {
+ SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
+
+ if( mxCell.is() )
+ {
+ OutlinerParaObject* pParaObj = mxCell->GetEditOutlinerParaObject();
+
+ bool bOwnParaObj = pParaObj != 0;
+
+ if( pParaObj == 0 )
+ pParaObj = mxCell->GetOutlinerParaObject();
+
+ if(pParaObj)
+ {
+ // handle outliner attributes
+ Outliner* pOutliner = 0;
+
+ if(mxCell->IsTextEditActive())
+ {
+ pOutliner = rObj.GetTextEditOutliner();
+ }
+ else
+ {
+ pOutliner = &rObj.ImpGetDrawOutliner();
+ pOutliner->SetText(*pParaObj);
+ }
+
+ sal_uInt32 nParaCount(pOutliner->GetParagraphCount());
+
+ for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++)
+ {
+ SfxItemSet aSet(pOutliner->GetParaAttribs(nPara));
+ aSet.Put(rSet);
+ pOutliner->SetParaAttribs(nPara, aSet);
+ }
+
+ if(!mxCell->IsTextEditActive())
+ {
+ if(nParaCount)
+ {
+ // force ItemSet
+ GetObjectItemSet();
+
+ SfxItemSet aNewSet(pOutliner->GetParaAttribs(0L));
+ mpItemSet->Put(aNewSet);
+ }
+
+ OutlinerParaObject* pTemp = pOutliner->CreateParaObject(0, (sal_uInt16)nParaCount);
+ pOutliner->Clear();
+
+ mxCell->SetOutlinerParaObject(pTemp);
+ }
+
+ if( bOwnParaObj )
+ delete pParaObj;
+ }
+ }
+
+ // call parent
+ AttributeProperties::ItemSetChanged(rSet);
+
+ if( mxCell.is() )
+ mxCell->notifyModified();
+ }
+
+ void CellProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
+ {
+ if(pNewItem && (SDRATTR_TEXTDIRECTION == nWhich))
+ {
+ sal_Bool bVertical(com::sun::star::text::WritingMode_TB_RL == ((SvxWritingModeItem*)pNewItem)->GetValue());
+
+ sdr::table::SdrTableObj& rObj = (sdr::table::SdrTableObj&)GetSdrObject();
+ if( rObj.IsVerticalWriting() != bVertical )
+ rObj.SetVerticalWriting(bVertical);
+ }
+
+ // call parent
+ AttributeProperties::ItemChange( nWhich, pNewItem );
+ }
+
+ void CellProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
+ {
+ TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr );
+ }
+ } // end of namespace properties
+} // end of namespace sdr
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+// Cell
+// -----------------------------------------------------------------------------
+
+rtl::Reference< Cell > Cell::create( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject )
+{
+ rtl::Reference< Cell > xCell( new Cell( rTableObj, pOutlinerParaObject ) );
+ if( xCell->mxTable.is() )
+ {
+ Reference< XEventListener > xListener( xCell.get() );
+ xCell->mxTable->addEventListener( xListener );
+ }
+ return xCell;
+}
+
+// -----------------------------------------------------------------------------
+
+Cell::Cell( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject ) throw()
+: SdrText( rTableObj, pOutlinerParaObject )
+, SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
+, mpPropSet( ImplGetSvxCellPropertySet() )
+, mpProperties( new sdr::properties::CellProperties( rTableObj, this ) )
+, mnCellContentType( CellContentType_EMPTY )
+, mfValue( 0.0 )
+, mnError( 0 )
+, mbMerged( sal_False )
+, mnRowSpan( 1 )
+, mnColSpan( 1 )
+, mxTable( rTableObj.getTable() )
+{
+ if( rTableObj.GetModel() )
+ SetModel( rTableObj.GetModel() );
+}
+
+// -----------------------------------------------------------------------------
+
+Cell::~Cell() throw()
+{
+ dispose();
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::dispose()
+{
+ if( mxTable.is() )
+ {
+ try
+ {
+ Reference< XEventListener > xThis( this );
+ mxTable->removeEventListener( xThis );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("Cell::dispose(), exception caught!");
+ }
+ mxTable.clear();
+ }
+
+ if( mpProperties )
+ {
+ delete mpProperties;
+ mpProperties = 0;
+ }
+ SetOutlinerParaObject( 0 );
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::SetModel(SdrModel* pNewModel)
+{
+ SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( GetEditSource() );
+ if( (GetModel() != pNewModel) || ( pNewModel && !pTextEditSource) )
+ {
+ if( mpProperties )
+ {
+ SfxItemPool* pItemPool = mpProperties->GetObjectItemSet().GetPool();
+
+ // test for correct pool in ItemSet; move to new pool if necessary
+ if( pNewModel && pItemPool && pItemPool != &pNewModel->GetItemPool())
+ mpProperties->MoveToItemPool(pItemPool, &pNewModel->GetItemPool(), pNewModel);
+ }
+
+ if( pTextEditSource )
+ {
+ pTextEditSource->ChangeModel( pNewModel );
+ }
+ else
+ {
+ SetEditSource( new SvxTextEditSource( &GetObject(), this, static_cast< XWeak * >( this ) ) );
+ }
+
+ SetStyleSheet( 0, sal_True );
+ SdrText::SetModel( pNewModel );
+ ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan )
+{
+ if( (mnColSpan != nColumnSpan) || (mnRowSpan != nRowSpan) || (mbMerged != sal_False) )
+ {
+ mnColSpan = nColumnSpan;
+ mnRowSpan = nRowSpan;
+ mbMerged = sal_False;
+ notifyModified();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::mergeContent( const CellRef& xSourceCell )
+{
+ SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
+
+ if( xSourceCell->hasText() )
+ {
+ SdrOutliner& rOutliner=rTableObj.ImpGetDrawOutliner();
+ rOutliner.SetUpdateMode(TRUE);
+
+ if( hasText() )
+ {
+ rOutliner.SetText(*GetOutlinerParaObject());
+ rOutliner.AddText(*xSourceCell->GetOutlinerParaObject());
+ }
+ else
+ {
+ rOutliner.SetText(*xSourceCell->GetOutlinerParaObject());
+ }
+
+ SetOutlinerParaObject( rOutliner.CreateParaObject() );
+ rOutliner.Clear();
+ xSourceCell->SetOutlinerParaObject(rOutliner.CreateParaObject());
+ rOutliner.Clear();
+ SetStyleSheet( GetStyleSheet(), sal_True );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::cloneFrom( const CellRef& xCell )
+{
+ if( xCell.is() )
+ {
+ replaceContentAndFormating( xCell );
+
+ mnCellContentType = xCell->mnCellContentType;
+
+ msFormula = xCell->msFormula;
+ mfValue = xCell->mfValue;
+ mnError = xCell->mnError;
+
+ mbMerged = xCell->mbMerged;
+ mnRowSpan = xCell->mnRowSpan;
+ mnColSpan = xCell->mnColSpan;
+
+ }
+ notifyModified();
+}
+
+void Cell::replaceContentAndFormating( const CellRef& xSourceCell )
+{
+ if( xSourceCell.is() && mpProperties )
+ {
+ mpProperties->SetMergedItemSet( xSourceCell->GetObjectItemSet() );
+ SetOutlinerParaObject( new OutlinerParaObject(*xSourceCell->GetOutlinerParaObject()) );
+
+ SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
+ SdrTableObj& rSourceTableObj = dynamic_cast< SdrTableObj& >( xSourceCell->GetObject() );
+
+ if(rSourceTableObj.GetModel() != rTableObj.GetModel())
+ {
+ SetStyleSheet( 0, sal_True );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::setMerged()
+{
+ if( !mbMerged )
+ {
+ mbMerged = sal_True;
+ notifyModified();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::notifyModified()
+{
+ if( mxTable.is() )
+ mxTable->setModified( sal_True );
+}
+
+// -----------------------------------------------------------------------------
+// SdrTextShape proxy
+// -----------------------------------------------------------------------------
+
+bool Cell::IsTextEditActive()
+{
+ bool isActive = false;
+ SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
+ if(rTableObj.getActiveCell().get() == this )
+ {
+ OutlinerParaObject* pParaObj = rTableObj.GetEditOutlinerParaObject();
+ if( pParaObj != 0 )
+ {
+ isActive = true;
+ delete pParaObj;
+ }
+ }
+ return isActive;
+}
+
+// -----------------------------------------------------------------------------
+
+bool Cell::hasText() const
+{
+ OutlinerParaObject* pParaObj = GetOutlinerParaObject();
+ if( pParaObj )
+ {
+ const EditTextObject& rTextObj = pParaObj->GetTextObject();
+ if( rTextObj.GetParagraphCount() >= 1 )
+ {
+ if( rTextObj.GetParagraphCount() == 1 )
+ {
+ if( rTextObj.GetText(0).Len() == 0 )
+ return false;
+ }
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+
+OutlinerParaObject* Cell::GetEditOutlinerParaObject() const
+{
+ SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
+ if( rTableObj.getActiveCell().get() == this )
+ return rTableObj.GetEditOutlinerParaObject();
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::SetStyleSheet( SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr )
+{
+ // only allow cell styles for cells
+ if( pStyleSheet && pStyleSheet->GetFamily() != SFX_STYLE_FAMILY_FRAME )
+ return;
+
+ if( mpProperties && (mpProperties->GetStyleSheet() != pStyleSheet) )
+ {
+ mpProperties->SetStyleSheet( pStyleSheet, bDontRemoveHardAttr );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+const SfxItemSet& Cell::GetObjectItemSet()
+{
+ if( mpProperties )
+ {
+ return mpProperties->GetObjectItemSet();
+ }
+ else
+ {
+ DBG_ERROR("Cell::GetObjectItemSet(), called without properties!");
+ return GetObject().GetObjectItemSet();
+ }
+}
+
+void Cell::SetObjectItem(const SfxPoolItem& rItem)
+{
+ if( mpProperties )
+ {
+ mpProperties->SetObjectItem( rItem );
+ notifyModified();
+ }
+}
+
+void Cell::SetMergedItem(const SfxPoolItem& rItem)
+{
+ SetObjectItem(rItem);
+}
+
+SfxStyleSheet* Cell::GetStyleSheet() const
+{
+ if( mpProperties )
+ return mpProperties->GetStyleSheet();
+ else
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+SfxStyleSheetPool* Cell::GetStyleSheetPool() const
+{
+ if( mpProperties && mpProperties->GetStyleSheet() )
+ return dynamic_cast< SfxStyleSheetPool* >( &mpProperties->GetStyleSheet()->GetPool() );
+ else
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+const Rectangle& Cell::GetCurrentBoundRect() const
+{
+ return maCellRect;
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::TakeTextAnchorRect(Rectangle& rAnchorRect) const
+{
+ rAnchorRect.nLeft = maCellRect.nLeft + GetTextLeftDistance();
+ rAnchorRect.nRight = maCellRect.nRight - GetTextRightDistance();
+ rAnchorRect.nTop = maCellRect.nTop + GetTextUpperDistance();
+ rAnchorRect.nBottom = maCellRect.nBottom - GetTextLowerDistance();
+}
+
+// -----------------------------------------------------------------------------
+
+const SfxItemSet& Cell::GetItemSet() const
+{
+ return mpProperties->GetObjectItemSet();
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems)
+{
+ if( mpProperties )
+ {
+ mpProperties->SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
+ notifyModified();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 Cell::getMinimumWidth()
+{
+ return GetTextLeftDistance() + GetTextRightDistance() + 100;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 Cell::getMinimumHeight()
+{
+ if( !mpProperties )
+ return 0;
+
+ SdrTableObj& rTableObj = dynamic_cast< SdrTableObj& >( GetObject() );
+ sal_Int32 nMinimumHeight = 0;
+
+ Rectangle aTextRect;
+ TakeTextAnchorRect( aTextRect );
+ Size aSize( aTextRect.GetSize() );
+ aSize.Height()=0x0FFFFFFF;
+
+ SdrOutliner* pEditOutliner = rTableObj.GetCellTextEditOutliner( *this );
+ if(pEditOutliner)
+ {
+ pEditOutliner->SetMaxAutoPaperSize(aSize);
+ nMinimumHeight = pEditOutliner->GetTextHeight()+1;
+ }
+ else /*if ( hasText() )*/
+ {
+ Outliner& rOutliner=rTableObj.ImpGetDrawOutliner();
+ rOutliner.SetPaperSize(aSize);
+ rOutliner.SetUpdateMode(TRUE);
+ ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
+
+ if( GetOutlinerParaObject() )
+ {
+ rOutliner.SetText(*GetOutlinerParaObject());
+ }
+ nMinimumHeight=rOutliner.GetTextHeight()+1;
+ rOutliner.Clear();
+ }
+
+ nMinimumHeight += GetTextUpperDistance() + GetTextLowerDistance();
+ return nMinimumHeight;
+}
+
+// -----------------------------------------------------------------------------
+
+long Cell::GetTextLeftDistance() const
+{
+ return ((SdrTextLeftDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LEFTDIST))).GetValue();
+}
+
+// -----------------------------------------------------------------------------
+
+long Cell::GetTextRightDistance() const
+{
+ return ((SdrTextRightDistItem&)(GetItemSet().Get(SDRATTR_TEXT_RIGHTDIST))).GetValue();
+}
+
+// -----------------------------------------------------------------------------
+
+long Cell::GetTextUpperDistance() const
+{
+ return ((SdrTextUpperDistItem&)(GetItemSet().Get(SDRATTR_TEXT_UPPERDIST))).GetValue();
+}
+
+// -----------------------------------------------------------------------------
+
+long Cell::GetTextLowerDistance() const
+{
+ return ((SdrTextLowerDistItem&)(GetItemSet().Get(SDRATTR_TEXT_LOWERDIST))).GetValue();
+}
+
+// -----------------------------------------------------------------------------
+
+SdrTextVertAdjust Cell::GetTextVerticalAdjust() const
+{
+ return ((SdrTextVertAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
+}
+
+// -----------------------------------------------------------------------------
+
+SdrTextHorzAdjust Cell::GetTextHorizontalAdjust() const
+{
+ return ((SdrTextHorzAdjustItem&)(GetItemSet().Get(SDRATTR_TEXT_HORZADJUST))).GetValue();
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject )
+{
+ SdrText::SetOutlinerParaObject( pTextObject );
+ maSelection.nStartPara = 0xffff;
+
+ if( pTextObject == 0 )
+ ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT );
+}
+
+// -----------------------------------------------------------------------------
+
+void Cell::AddUndo()
+{
+ SdrObject& rObj = GetObject();
+ if( rObj.IsInserted() && GetModel() && GetModel()->IsUndoEnabled() )
+ {
+ CellRef xCell( this );
+ GetModel()->AddUndo( new CellUndo( &rObj, xCell ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sdr::properties::TextProperties* Cell::CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell )
+{
+ if( pProperties )
+ return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties*>(pProperties), rNewObj, &rNewCell );
+ else
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+sdr::properties::TextProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell )
+{
+ return CloneProperties(mpProperties,rNewObj,rNewCell);
+}
+
+// -----------------------------------------------------------------------------
+// XInterface
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL Cell::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if( rType == XMergeableCell::static_type() )
+ return Any( Reference< XMergeableCell >( this ) );
+
+ if( rType == XCell::static_type() )
+ return Any( Reference< XCell >( this ) );
+
+ if( rType == XLayoutConstrains::static_type() )
+ return Any( Reference< XLayoutConstrains >( this ) );
+
+ if( rType == XEventListener::static_type() )
+ return Any( Reference< XEventListener >( this ) );
+
+ Any aRet( SvxUnoTextBase::queryAggregation( rType ) );
+ if( aRet.hasValue() )
+ return aRet;
+
+ return ::cppu::OWeakObject::queryInterface( rType );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::acquire() throw ()
+{
+ ::cppu::OWeakObject::acquire();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::release() throw ()
+{
+ ::cppu::OWeakObject::release();
+}
+
+// -----------------------------------------------------------------------------
+// XTypeProvider
+// -----------------------------------------------------------------------------
+
+Sequence< Type > SAL_CALL Cell::getTypes( ) throw (RuntimeException)
+{
+ Sequence< Type > aTypes( SvxUnoTextBase::getTypes() );
+
+ sal_Int32 nLen = aTypes.getLength();
+ aTypes.realloc(nLen + 2);
+ aTypes[nLen++] = XMergeableCell::static_type();
+ aTypes[nLen++] = XLayoutConstrains::static_type();
+
+ return aTypes;
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL Cell::getImplementationId( ) throw (RuntimeException)
+{
+ static ::cppu::OImplementationId* pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// -----------------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------------
+
+OUString SAL_CALL Cell::getImplementationName( ) throw (RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.table.Cell" ) );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Cell::supportsService( const OUString& ServiceName ) throw (RuntimeException)
+{
+ if( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.table.cell" ) ) == 0 )
+ return sal_True;
+
+ if( ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.cell" ) ) == 0 )
+ return sal_True;
+
+ return SvxUnoTextBase::supportsService( ServiceName );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL Cell::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ Sequence< OUString > aSeq( SvxUnoTextBase::getSupportedServiceNames() );
+ sal_Int32 nIndex = aSeq.getLength();
+ aSeq.realloc( nIndex + 2 );
+ aSeq[nIndex++] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.cell" ) );
+ aSeq[nIndex++] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.cell" ) );
+ return aSeq;
+}
+
+// -----------------------------------------------------------------------------
+// XLayoutConstrains
+// -----------------------------------------------------------------------------
+
+::com::sun::star::awt::Size SAL_CALL Cell::getMinimumSize( ) throw (RuntimeException)
+{
+ return ::com::sun::star::awt::Size( getMinimumWidth(), getMinimumHeight() );
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::awt::Size SAL_CALL Cell::getPreferredSize( ) throw (RuntimeException)
+{
+ return getMinimumSize();
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::awt::Size SAL_CALL Cell::calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw (RuntimeException)
+{
+ return aNewSize;
+}
+
+// -----------------------------------------------------------------------------
+// XMergeableCell
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL Cell::getRowSpan() throw (RuntimeException)
+{
+ return mnRowSpan;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL Cell::getColumnSpan() throw (RuntimeException)
+{
+ return mnColSpan;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL Cell::isMerged() throw (RuntimeException)
+{
+ return mbMerged;
+}
+
+// -----------------------------------------------------------------------------
+// XCell
+// -----------------------------------------------------------------------------
+
+OUString SAL_CALL Cell::getFormula( ) throw (RuntimeException)
+{
+ return msFormula;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::setFormula( const OUString& aFormula ) throw (RuntimeException)
+{
+ if( msFormula != aFormula )
+ {
+ msFormula = aFormula;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+double SAL_CALL Cell::getValue( ) throw (RuntimeException)
+{
+ return mfValue;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::setValue( double nValue ) throw (RuntimeException)
+{
+ if( mfValue == nValue )
+ {
+ mfValue = nValue;
+ mnCellContentType = CellContentType_VALUE;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+CellContentType SAL_CALL Cell::getType() throw (RuntimeException)
+{
+ return mnCellContentType;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL Cell::getError( ) throw (RuntimeException)
+{
+ return mnError;
+}
+
+// -----------------------------------------------------------------------------
+// XPropertySet
+// -----------------------------------------------------------------------------
+
+Any Cell::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap )
+{
+ Any aAny( SvxItemPropertySet_getPropertyValue( *mpPropSet, pMap, aSet ) );
+
+ if( *pMap->pType != aAny.getValueType() )
+ {
+ // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
+ if( ( *pMap->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) )
+ {
+ sal_Int32 nValue = 0;
+ aAny >>= nValue;
+ aAny <<= (sal_Int16)nValue;
+ }
+ else
+ {
+ DBG_ERROR("GetAnyForItem() Returnvalue has wrong Type!" );
+ }
+ }
+
+ return aAny;
+}
+
+Reference< XPropertySetInfo > SAL_CALL Cell::getPropertySetInfo() throw(RuntimeException)
+{
+ return mpPropSet->getPropertySetInfo();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::setPropertyValue( const OUString& rPropertyName, const Any& rValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( (mpProperties == 0) || (GetModel() == 0) )
+ throw DisposedException();
+
+ const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
+ if( pMap )
+ {
+ if( (pMap->nFlags & PropertyAttribute::READONLY ) != 0 )
+ throw PropertyVetoException();
+
+ switch( pMap->nWID )
+ {
+ case OWN_ATTR_STYLE:
+ {
+ Reference< XStyle > xStyle;
+ if( !( rValue >>= xStyle ) )
+ throw IllegalArgumentException();
+
+ SfxUnoStyleSheet* pStyle = SfxUnoStyleSheet::getUnoStyleSheet(xStyle);
+ SetStyleSheet( pStyle, sal_True );
+ return;
+ }
+ case OWN_ATTR_TABLEBORDER:
+ {
+ if(rValue.getValueType() != ::getCppuType((const TableBorder*)0) )
+ break;
+
+ const TableBorder* pBorder = (const TableBorder* )rValue.getValue();
+ if( pBorder == NULL )
+ break;
+
+ SvxBoxItem aBox( SDRATTR_TABLE_BORDER );
+ SvxBoxInfoItem aBoxInfo( SDRATTR_TABLE_BORDER_INNER );
+ SvxBorderLine aLine;
+
+ sal_Bool bSet = SvxBoxItem::LineToSvxLine(pBorder->TopLine, aLine, false);
+ aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_TOP);
+ aBoxInfo.SetValid(VALID_TOP, pBorder->IsTopLineValid);
+
+ bSet = SvxBoxItem::LineToSvxLine(pBorder->BottomLine, aLine, false);
+ aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_BOTTOM);
+ aBoxInfo.SetValid(VALID_BOTTOM, pBorder->IsBottomLineValid);
+
+ bSet = SvxBoxItem::LineToSvxLine(pBorder->LeftLine, aLine, false);
+ aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_LEFT);
+ aBoxInfo.SetValid(VALID_LEFT, pBorder->IsLeftLineValid);
+
+ bSet = SvxBoxItem::LineToSvxLine(pBorder->RightLine, aLine, false);
+ aBox.SetLine(bSet ? &aLine : 0, BOX_LINE_RIGHT);
+ aBoxInfo.SetValid(VALID_RIGHT, pBorder->IsRightLineValid);
+
+ bSet = SvxBoxItem::LineToSvxLine(pBorder->HorizontalLine, aLine, false);
+ aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_HORI);
+ aBoxInfo.SetValid(VALID_HORI, pBorder->IsHorizontalLineValid);
+
+ bSet = SvxBoxItem::LineToSvxLine(pBorder->VerticalLine, aLine, false);
+ aBoxInfo.SetLine(bSet ? &aLine : 0, BOXINFO_LINE_VERT);
+ aBoxInfo.SetValid(VALID_VERT, pBorder->IsVerticalLineValid);
+
+ aBox.SetDistance(pBorder->Distance, false);
+ aBoxInfo.SetValid(VALID_DISTANCE, pBorder->IsDistanceValid);
+
+ mpProperties->SetObjectItem(aBox);
+ mpProperties->SetObjectItem(aBoxInfo);
+ return;
+ }
+ case OWN_ATTR_FILLBMP_MODE:
+ {
+ BitmapMode eMode;
+ if(!(rValue >>= eMode) )
+ {
+ sal_Int32 nMode = 0;
+ if(!(rValue >>= nMode))
+ throw IllegalArgumentException();
+
+ eMode = (BitmapMode)nMode;
+ }
+
+ mpProperties->SetObjectItem( XFillBmpStretchItem( eMode == BitmapMode_STRETCH ) );
+ mpProperties->SetObjectItem( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) );
+ return;
+ }
+ default:
+ {
+ SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
+ aSet.Put(mpProperties->GetItem(pMap->nWID));
+
+ bool bSpecial = false;
+
+ switch( pMap->nWID )
+ {
+ case XATTR_FILLBITMAP:
+ case XATTR_FILLGRADIENT:
+ case XATTR_FILLHATCH:
+ case XATTR_FILLFLOATTRANSPARENCE:
+ case XATTR_LINEEND:
+ case XATTR_LINESTART:
+ case XATTR_LINEDASH:
+ {
+ if( pMap->nMemberId == MID_NAME )
+ {
+ OUString aApiName;
+ if( rValue >>= aApiName )
+ {
+ if( SvxShape::SetFillAttribute( pMap->nWID, aApiName, aSet, GetModel() ) )
+ bSpecial = true;
+ }
+ }
+ }
+ break;
+ }
+
+ if( !bSpecial )
+ {
+
+ if( !SvxUnoTextRangeBase::SetPropertyValueHelper( aSet, pMap, rValue, aSet ))
+ {
+ if( aSet.GetItemState( pMap->nWID ) != SFX_ITEM_SET )
+ {
+ // Default aus ItemPool holen
+ if(GetModel()->GetItemPool().IsWhich(pMap->nWID))
+ aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
+ }
+
+ if( aSet.GetItemState( pMap->nWID ) == SFX_ITEM_SET )
+ {
+ SvxItemPropertySet_setPropertyValue( *mpPropSet, pMap, rValue, aSet );
+ }
+ }
+ }
+
+ GetModel()->SetChanged();
+ mpProperties->SetMergedItemSetAndBroadcast( aSet );
+ return;
+ }
+ }
+ }
+ throw UnknownPropertyException();
+}
+
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL Cell::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( (mpProperties == 0) || (GetModel() == 0) )
+ throw DisposedException();
+
+ const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
+ if( pMap )
+ {
+ switch( pMap->nWID )
+ {
+/*
+ case OWN_ATTR_HASLEVELS:
+ {
+ return Any( hasLevels() );
+ }
+*/
+ case OWN_ATTR_STYLE:
+ {
+ return Any( Reference< XStyle >( dynamic_cast< SfxUnoStyleSheet* >( GetStyleSheet() ) ) );
+ }
+ case OWN_ATTR_TABLEBORDER:
+ {
+ const SvxBoxInfoItem& rBoxInfoItem = static_cast<const SvxBoxInfoItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER_INNER));
+ const SvxBoxItem& rBox = static_cast<const SvxBoxItem&>(mpProperties->GetItem(SDRATTR_TABLE_BORDER));
+
+ TableBorder aTableBorder;
+ aTableBorder.TopLine = SvxBoxItem::SvxLineToLine(rBox.GetTop(), false);
+ aTableBorder.IsTopLineValid = rBoxInfoItem.IsValid(VALID_TOP);
+ aTableBorder.BottomLine = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), false);
+ aTableBorder.IsBottomLineValid = rBoxInfoItem.IsValid(VALID_BOTTOM);
+ aTableBorder.LeftLine = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), false);
+ aTableBorder.IsLeftLineValid = rBoxInfoItem.IsValid(VALID_LEFT);
+ aTableBorder.RightLine = SvxBoxItem::SvxLineToLine(rBox.GetRight(), false);
+ aTableBorder.IsRightLineValid = rBoxInfoItem.IsValid(VALID_RIGHT );
+ aTableBorder.HorizontalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), false);
+ aTableBorder.IsHorizontalLineValid = rBoxInfoItem.IsValid(VALID_HORI);
+ aTableBorder.VerticalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), false);
+ aTableBorder.IsVerticalLineValid = rBoxInfoItem.IsValid(VALID_VERT);
+ aTableBorder.Distance = rBox.GetDistance();
+ aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(VALID_DISTANCE);
+
+ return Any( aTableBorder );
+ }
+ case OWN_ATTR_FILLBMP_MODE:
+ {
+ const XFillBmpStretchItem& rStretchItem = static_cast<const XFillBmpStretchItem&>(mpProperties->GetItem(XATTR_FILLBMP_STRETCH));
+ const XFillBmpTileItem& rTileItem = static_cast<const XFillBmpTileItem&>(mpProperties->GetItem(XATTR_FILLBMP_TILE));
+ if( rTileItem.GetValue() )
+ {
+ return Any( BitmapMode_REPEAT );
+ }
+ else if( rStretchItem.GetValue() )
+ {
+ return Any( BitmapMode_STRETCH );
+ }
+ else
+ {
+ return Any( BitmapMode_NO_REPEAT );
+ }
+ }
+ default:
+ {
+ SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
+ aSet.Put(mpProperties->GetItem(pMap->nWID));
+
+ Any aAny;
+ if(!SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny ))
+ {
+ if(!aSet.Count())
+ {
+ // Default aus ItemPool holen
+ if(GetModel()->GetItemPool().IsWhich(pMap->nWID))
+ aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
+ }
+
+ if( aSet.Count() )
+ aAny = GetAnyForItem( aSet, pMap );
+ }
+
+ return aAny;
+ }
+ }
+ }
+ throw UnknownPropertyException();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::addPropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*xListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::removePropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::addVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::removeVetoableChangeListener( const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+// XMultiPropertySet
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ ::SolarMutexGuard aSolarGuard;
+
+ if( (mpProperties == 0) || (GetModel() == 0) )
+ throw DisposedException();
+
+ const sal_Int32 nCount = aPropertyNames.getLength();
+
+ const OUString* pNames = aPropertyNames.getConstArray();
+ const Any* pValues = aValues.getConstArray();
+
+ for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
+ {
+ try
+ {
+ setPropertyValue( *pNames, *pValues );
+ }
+ catch( UnknownPropertyException& )
+ {
+ DBG_ERROR("svx::Cell::setPropertyValues(), unknown property!" );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("svx::Cell::setPropertyValues(), Exception caught!" );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< Any > SAL_CALL Cell::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException)
+{
+ ::SolarMutexGuard aSolarGuard;
+
+ if( (mpProperties == 0) || (GetModel() == 0) )
+ throw DisposedException();
+
+ const sal_Int32 nCount = aPropertyNames.getLength();
+ const OUString* pNames = aPropertyNames.getConstArray();
+
+ Sequence< Any > aRet( nCount );
+ Any* pValue = aRet.getArray();
+
+ for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
+ {
+ try
+ {
+ *pValue = getPropertyValue( *pNames );
+ }
+ catch( UnknownPropertyException& )
+ {
+ DBG_ERROR("svx::Cell::setPropertyValues(), unknown property!" );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "svx::Cell::getPropertyValues(), Exception caught!" );
+ }
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::addPropertiesChangeListener( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::firePropertiesChangeEvent( const Sequence< OUString >& /*aPropertyNames*/, const Reference< XPropertiesChangeListener >& /*xListener*/ ) throw (RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+// XPropertyState
+// -----------------------------------------------------------------------------
+
+PropertyState SAL_CALL Cell::getPropertyState( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( (mpProperties == 0) || (GetModel() == 0) )
+ throw DisposedException();
+
+ const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
+
+ if( pMap )
+ {
+ PropertyState eState;
+ switch( pMap->nWID )
+ {
+ case OWN_ATTR_FILLBMP_MODE:
+ {
+ const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
+
+ const bool bStretch = rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET;
+ const bool bTile = rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET;
+ if( bStretch || bTile )
+ {
+ eState = PropertyState_DIRECT_VALUE;
+ }
+ else
+ {
+ eState = PropertyState_DEFAULT_VALUE;
+ }
+ }
+/*
+ case OWN_ATTR_HASLEVELS:
+ {
+ return PropertyState_DIRECT_VALUE;
+ }
+*/
+ case OWN_ATTR_STYLE:
+ {
+ return PropertyState_DIRECT_VALUE;
+ }
+ case OWN_ATTR_TABLEBORDER:
+ {
+ const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
+ if( (rSet.GetItemState( SDRATTR_TABLE_BORDER_INNER, sal_False ) == SFX_ITEM_DEFAULT) && (rSet.GetItemState( SDRATTR_TABLE_BORDER, sal_False ) == SFX_ITEM_DEFAULT) )
+ return PropertyState_DEFAULT_VALUE;
+
+ return PropertyState_DIRECT_VALUE;
+ }
+ default:
+ {
+ const SfxItemSet& rSet = mpProperties->GetMergedItemSet();
+
+ switch( rSet.GetItemState( pMap->nWID, sal_False ) )
+ {
+ case SFX_ITEM_READONLY:
+ case SFX_ITEM_SET:
+ eState = PropertyState_DIRECT_VALUE;
+ break;
+ case SFX_ITEM_DEFAULT:
+ eState = PropertyState_DEFAULT_VALUE;
+ break;
+ // case SFX_ITEM_UNKNOWN:
+ // case SFX_ITEM_DONTCARE:
+ // case SFX_ITEM_DISABLED:
+ default:
+ eState = PropertyState_AMBIGUOUS_VALUE;
+ break;
+ }
+
+ // if a item is set, this doesn't mean we want it :)
+ if( ( PropertyState_DIRECT_VALUE == eState ) )
+ {
+ switch( pMap->nWID )
+ {
+ // the following items are disabled by changing the
+ // fill style or the line style. so there is no need
+ // to export items without names which should be empty
+ case XATTR_FILLBITMAP:
+ case XATTR_FILLGRADIENT:
+ case XATTR_FILLHATCH:
+ case XATTR_LINEDASH:
+ {
+ NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((USHORT)pMap->nWID);
+ if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) )
+ eState = PropertyState_DEFAULT_VALUE;
+ }
+ break;
+
+ // #i36115#
+ // If e.g. the LineStart is on NONE and thus the string has length 0, it still
+ // may be a hard attribute covering the set LineStart of the parent (Style).
+ // #i37644#
+ // same is for fill float transparency
+ case XATTR_LINEEND:
+ case XATTR_LINESTART:
+ case XATTR_FILLFLOATTRANSPARENCE:
+ {
+ NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((USHORT)pMap->nWID);
+ if( ( pItem == NULL ) )
+ eState = PropertyState_DEFAULT_VALUE;
+ }
+ break;
+ }
+ }
+ }
+ }
+ return eState;
+ }
+ throw UnknownPropertyException();
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< PropertyState > SAL_CALL Cell::getPropertyStates( const Sequence< OUString >& aPropertyName ) throw(UnknownPropertyException, RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( (mpProperties == 0) || (GetModel() == 0) )
+ throw DisposedException();
+
+ const sal_Int32 nCount = aPropertyName.getLength();
+
+ Sequence< PropertyState > aRet( nCount );
+
+ const OUString* pNames = aPropertyName.getConstArray();
+ PropertyState* pState = aRet.getArray();
+
+ for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pState++ )
+ {
+ try
+ {
+ *pState = getPropertyState( *pNames );
+ }
+ catch( Exception& )
+ {
+ *pState = PropertyState_AMBIGUOUS_VALUE;
+ }
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::setPropertyToDefault( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( (mpProperties == 0) || (GetModel() == 0) )
+ throw DisposedException();
+
+ const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
+ if( pMap )
+ {
+ switch( pMap->nWID )
+ {
+ case OWN_ATTR_FILLBMP_MODE:
+ {
+ mpProperties->ClearObjectItem( XATTR_FILLBMP_STRETCH );
+ mpProperties->ClearObjectItem( XATTR_FILLBMP_TILE );
+ break;
+ }
+// case OWN_ATTR_HASLEVELS:
+ case OWN_ATTR_STYLE:
+ break;
+
+ case OWN_ATTR_TABLEBORDER:
+ {
+ mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER_INNER );
+ mpProperties->ClearObjectItem( SDRATTR_TABLE_BORDER );
+ break;
+ }
+
+ default:
+ {
+ mpProperties->ClearObjectItem( pMap->nWID );
+ }
+ }
+
+ GetModel()->SetChanged();
+ return;
+ }
+ throw UnknownPropertyException();
+}
+
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL Cell::getPropertyDefault( const OUString& aPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( (mpProperties == 0) || (GetModel() == 0) )
+ throw DisposedException();
+
+ const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
+ if( pMap )
+ {
+ switch( pMap->nWID )
+ {
+ case OWN_ATTR_FILLBMP_MODE:
+ return Any( BitmapMode_NO_REPEAT );
+
+/*
+ case OWN_ATTR_HASLEVELS:
+ return Any( sal_False );
+*/
+ case OWN_ATTR_STYLE:
+ {
+ Reference< XStyle > xStyle;
+ return Any( xStyle );
+ }
+
+ case OWN_ATTR_TABLEBORDER:
+ {
+ TableBorder aBorder;
+ return Any( aBorder );
+ }
+
+ default:
+ {
+ if( GetModel()->GetItemPool().IsWhich(pMap->nWID) )
+ {
+ SfxItemSet aSet( GetModel()->GetItemPool(), pMap->nWID, pMap->nWID);
+ aSet.Put(GetModel()->GetItemPool().GetDefaultItem(pMap->nWID));
+ return GetAnyForItem( aSet, pMap );
+ }
+ }
+ }
+ }
+ throw UnknownPropertyException();
+}
+
+// -----------------------------------------------------------------------------
+// XMultiPropertyStates
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::setAllPropertiesToDefault( ) throw (RuntimeException)
+{
+ if( mpProperties )
+ delete mpProperties;
+ mpProperties = new sdr::properties::CellProperties( static_cast< SdrTableObj& >( GetObject() ), this );
+
+ SdrOutliner& rOutliner = GetObject().ImpGetDrawOutliner();
+
+ OutlinerParaObject* pParaObj = GetOutlinerParaObject();
+ if( pParaObj )
+ {
+ rOutliner.SetText(*pParaObj);
+ sal_uInt32 nParaCount(rOutliner.GetParagraphCount());
+
+ if(nParaCount)
+ {
+ ESelection aSelection( 0, 0, EE_PARA_ALL, EE_PARA_ALL);
+ rOutliner.RemoveAttribs(aSelection, sal_True, 0);
+
+ OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount);
+ rOutliner.Clear();
+
+ SetOutlinerParaObject(pTemp);
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::setPropertiesToDefault( const Sequence< OUString >& aPropertyNames ) throw (UnknownPropertyException, RuntimeException)
+{
+ sal_Int32 nCount = aPropertyNames.getLength();
+ const OUString* pName = aPropertyNames.getConstArray();
+
+ while(nCount--)
+ setPropertyToDefault( *pName++ );
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< Any > SAL_CALL Cell::getPropertyDefaults( const Sequence< OUString >& aPropertyNames ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ sal_Int32 nCount = aPropertyNames.getLength();
+ Sequence< Any > aDefaults( nCount );
+ Any* pDefaults = aDefaults.getArray();
+ const OUString* pName = aPropertyNames.getConstArray();
+
+ while(nCount--)
+ *pDefaults++ = getPropertyDefault( *pName++ );
+
+ return aDefaults;
+}
+
+// -----------------------------------------------------------------------------
+// XFastPropertySet
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ (void)aValue;
+ (void)nHandle;
+ throw UnknownPropertyException();
+}
+
+// -----------------------------------------------------------------------------
+// TODO: Refactor this method!
+Any SAL_CALL Cell::getFastPropertyValue( sal_Int32 nHandle ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ (void)nHandle;
+ throw UnknownPropertyException();
+}
+
+// -----------------------------------------------------------------------------
+// XText
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::insertTextContent( const Reference< XTextRange >& xRange, const Reference< XTextContent >& xContent, sal_Bool bAbsorb ) throw (IllegalArgumentException, RuntimeException)
+{
+ SvxUnoTextBase::insertTextContent( xRange, xContent, bAbsorb );
+ notifyModified();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::removeTextContent( const Reference< XTextContent >& xContent ) throw (NoSuchElementException, RuntimeException)
+{
+ SvxUnoTextBase::removeTextContent( xContent );
+ notifyModified();
+}
+
+// -----------------------------------------------------------------------------
+// XSimpleText
+// -----------------------------------------------------------------------------
+
+Reference< XTextCursor > SAL_CALL Cell::createTextCursor( ) throw (RuntimeException)
+{
+ return SvxUnoTextBase::createTextCursor();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XTextCursor > SAL_CALL Cell::createTextCursorByRange( const Reference< XTextRange >& aTextPosition ) throw (RuntimeException)
+{
+ return SvxUnoTextBase::createTextCursorByRange( aTextPosition );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::insertString( const Reference< XTextRange >& xRange, const OUString& aString, sal_Bool bAbsorb ) throw (RuntimeException)
+{
+ SvxUnoTextBase::insertString( xRange, aString, bAbsorb );
+ notifyModified();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::insertControlCharacter( const Reference< XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb ) throw (IllegalArgumentException, RuntimeException)
+{
+ SvxUnoTextBase::insertControlCharacter( xRange, nControlCharacter, bAbsorb );
+ notifyModified();
+}
+
+// -----------------------------------------------------------------------------
+// XTextRange
+// -----------------------------------------------------------------------------
+
+Reference< XText > SAL_CALL Cell::getText( ) throw (RuntimeException)
+{
+ return SvxUnoTextBase::getText();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XTextRange > SAL_CALL Cell::getStart( ) throw (RuntimeException)
+{
+ return SvxUnoTextBase::getStart();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XTextRange > SAL_CALL Cell::getEnd( ) throw (RuntimeException)
+{
+ return SvxUnoTextBase::getEnd();
+}
+
+// -----------------------------------------------------------------------------
+
+OUString SAL_CALL Cell::getString( ) throw (RuntimeException)
+{
+ maSelection.nStartPara = 0xffff;
+ return SvxUnoTextBase::getString();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL Cell::setString( const OUString& aString ) throw (RuntimeException)
+{
+ SvxUnoTextBase::setString( aString );
+ notifyModified();
+}
+
+// XEventListener
+void SAL_CALL Cell::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
+{
+ mxTable.clear();
+ dispose();
+}
+
+static OUString getCellName( sal_Int32 nCol, sal_Int32 nRow )
+{
+ rtl::OUStringBuffer aBuf;
+
+ if (nCol < 26*26)
+ {
+ if (nCol < 26)
+ aBuf.append( static_cast<sal_Unicode>( 'A' +
+ static_cast<sal_uInt16>(nCol)));
+ else
+ {
+ aBuf.append( static_cast<sal_Unicode>( 'A' +
+ (static_cast<sal_uInt16>(nCol) / 26) - 1));
+ aBuf.append( static_cast<sal_Unicode>( 'A' +
+ (static_cast<sal_uInt16>(nCol) % 26)));
+ }
+ }
+ else
+ {
+ String aStr;
+ while (nCol >= 26)
+ {
+ sal_Int32 nC = nCol % 26;
+ aStr += static_cast<sal_Unicode>( 'A' +
+ static_cast<sal_uInt16>(nC));
+ nCol = nCol - nC;
+ nCol = nCol / 26 - 1;
+ }
+ aStr += static_cast<sal_Unicode>( 'A' +
+ static_cast<sal_uInt16>(nCol));
+ aStr.Reverse();
+ aBuf.append( aStr);
+ }
+ aBuf.append( OUString::valueOf(nRow+1) );
+ return aBuf.makeStringAndClear();
+}
+
+OUString Cell::getName()
+{
+ // todo: optimize!
+ OUString sName;
+ if( mxTable.is() ) try
+ {
+ Reference< XCell > xThis( static_cast< XCell* >( this ) );
+
+ sal_Int32 nRowCount = mxTable->getRowCount();
+ sal_Int32 nColCount = mxTable->getColumnCount();
+ for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
+ {
+ for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
+ {
+ Reference< XCell > xCell( mxTable->getCellByPosition( nCol, nRow ) );
+ if( xCell == xThis )
+ {
+ return getCellName( nCol, nRow );
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ }
+
+ return sName;
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/cell.hxx b/svx/source/table/cell.hxx
new file mode 100644
index 000000000000..32ba7b388f65
--- /dev/null
+++ b/svx/source/table/cell.hxx
@@ -0,0 +1,247 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_CELL_HXX_
+#define _SVX_CELL_HXX_
+
+#include <com/sun/star/table/XMergeableCell.hpp>
+#include <com/sun/star/awt/XLayoutConstrains.hpp>
+#include <com/sun/star/beans/XMultiPropertyStates.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+
+#include <rtl/ref.hxx>
+#include <svl/style.hxx>
+#include "svx/sdtaitm.hxx"
+#include "tablemodel.hxx"
+#include "editeng/unotext.hxx"
+#include "svx/svdtext.hxx"
+
+// -----------------------------------------------------------------------------
+
+class SfxItemSet;
+class OutlinerParaObject;
+class SdrObject;
+
+namespace sdr { namespace properties {
+ class TextProperties;
+} }
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+
+class SVX_DLLPUBLIC Cell : public SdrText,
+ public SvxUnoTextBase,
+ public ::com::sun::star::table::XMergeableCell,
+ public ::com::sun::star::awt::XLayoutConstrains,
+ public ::com::sun::star::lang::XEventListener,
+ public ::cppu::OWeakObject
+{
+ friend class CellUndo;
+
+public:
+ SVX_DLLPRIVATE static rtl::Reference< Cell > create( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject );
+
+ // private
+ SVX_DLLPRIVATE void dispose();
+
+ // SdrTextShape proxy
+ bool IsTextEditActive();
+ SVX_DLLPRIVATE bool hasText() const;
+
+ SVX_DLLPRIVATE void cloneFrom( const CellRef& rCell );
+
+ SVX_DLLPRIVATE void setCellRect( ::Rectangle& rCellRect ) { maCellRect = rCellRect; }
+ SVX_DLLPRIVATE const ::Rectangle& getCellRect() const { return maCellRect; }
+ SVX_DLLPRIVATE ::Rectangle& getCellRect() { return maCellRect; }
+
+ OutlinerParaObject* GetEditOutlinerParaObject() const;
+ SVX_DLLPRIVATE void SetStyleSheet( SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr );
+ SVX_DLLPRIVATE virtual SfxStyleSheet* GetStyleSheet() const;
+ SfxStyleSheetPool* GetStyleSheetPool() const;
+ SVX_DLLPRIVATE virtual const Rectangle& GetCurrentBoundRect() const;
+ SVX_DLLPRIVATE virtual void TakeTextAnchorRect(Rectangle& rAnchorRect) const;
+
+ SVX_DLLPRIVATE virtual const SfxItemSet& GetItemSet() const;
+ SVX_DLLPRIVATE void SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems);
+ void SetMergedItem(const SfxPoolItem& rItem);
+
+ SVX_DLLPRIVATE sal_Int32 getMinimumWidth();
+ SVX_DLLPRIVATE sal_Int32 getMinimumHeight();
+
+ SVX_DLLPRIVATE long GetTextLeftDistance() const;
+ SVX_DLLPRIVATE long GetTextRightDistance() const;
+ SVX_DLLPRIVATE long GetTextUpperDistance() const;
+ SVX_DLLPRIVATE long GetTextLowerDistance() const;
+
+ SVX_DLLPRIVATE SdrTextVertAdjust GetTextVerticalAdjust() const;
+ SdrTextHorzAdjust GetTextHorizontalAdjust() const;
+
+ SVX_DLLPRIVATE virtual void SetModel(SdrModel* pNewModel);
+
+ SVX_DLLPRIVATE void merge( sal_Int32 nColumnSpan, sal_Int32 nRowSpan );
+ SVX_DLLPRIVATE void mergeContent( const CellRef& xSourceCell );
+ SVX_DLLPRIVATE void replaceContentAndFormating( const CellRef& xSourceCell );
+
+ SVX_DLLPRIVATE void setMerged();
+
+ // XInterface
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& Type ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL acquire() throw ();
+ SVX_DLLPRIVATE virtual void SAL_CALL release() throw ();
+
+ // XTypeProvider
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ SVX_DLLPRIVATE virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XLayoutConstrains
+ SVX_DLLPRIVATE virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize( ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::awt::Size SAL_CALL getPreferredSize( ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::awt::Size SAL_CALL calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XMergeableCell
+ SVX_DLLPRIVATE virtual ::sal_Int32 SAL_CALL getRowSpan() throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::sal_Int32 SAL_CALL getColumnSpan() throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::sal_Bool SAL_CALL isMerged() throw (::com::sun::star::uno::RuntimeException);
+
+ // XCell
+ SVX_DLLPRIVATE virtual ::rtl::OUString SAL_CALL getFormula() throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL setFormula( const ::rtl::OUString& aFormula ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual double SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL setValue( double nValue ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::table::CellContentType SAL_CALL getType() throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual sal_Int32 SAL_CALL getError() throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::beans::XPropertySet
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XMultiPropertySet
+ SVX_DLLPRIVATE virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::beans::XPropertyState
+ SVX_DLLPRIVATE virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XMultiPropertyStates
+ SVX_DLLPRIVATE virtual void SAL_CALL setAllPropertiesToDefault( ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XFastPropertySet
+ SVX_DLLPRIVATE virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XText
+ SVX_DLLPRIVATE virtual void SAL_CALL insertTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >& xContent, ::sal_Bool bAbsorb ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL removeTextContent( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent >& xContent ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
+
+ // XSimpleText
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursor( ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > SAL_CALL createTextCursorByRange( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& aTextPosition ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL insertString( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, const ::rtl::OUString& aString, ::sal_Bool bAbsorb ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL insertControlCharacter( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >& xRange, ::sal_Int16 nControlCharacter, ::sal_Bool bAbsorb ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ // XTextRange
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText( ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart( ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd( ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual ::rtl::OUString SAL_CALL getString( ) throw (::com::sun::star::uno::RuntimeException);
+ SVX_DLLPRIVATE virtual void SAL_CALL setString( const ::rtl::OUString& aString ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ SVX_DLLPRIVATE virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ SVX_DLLPRIVATE virtual void SetOutlinerParaObject( OutlinerParaObject* pTextObject );
+
+ SVX_DLLPRIVATE void AddUndo();
+
+ using SvxUnoTextRangeBase::setPropertyValue;
+ using SvxUnoTextRangeBase::getPropertyValue;
+
+ SVX_DLLPRIVATE sdr::properties::TextProperties* CloneProperties( SdrObject& rNewObj, Cell& rNewCell );
+
+ SVX_DLLPRIVATE static sdr::properties::TextProperties* CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell );
+
+ SVX_DLLPRIVATE void notifyModified();
+
+ ::rtl::OUString getName();
+
+protected:
+ SVX_DLLPRIVATE virtual const SfxItemSet& GetObjectItemSet();
+ SVX_DLLPRIVATE virtual void SetObjectItem(const SfxPoolItem& rItem);
+
+ SVX_DLLPRIVATE ::com::sun::star::uno::Any GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap );
+
+private:
+ SVX_DLLPRIVATE Cell( SdrTableObj& rTableObj, OutlinerParaObject* pOutlinerParaObject ) throw();
+ SVX_DLLPRIVATE virtual ~Cell() throw();
+
+ const SvxItemPropertySet* mpPropSet;
+
+ sdr::properties::TextProperties* mpProperties;
+
+ ::com::sun::star::table::CellContentType mnCellContentType;
+
+ ::rtl::OUString msFormula;
+ double mfValue;
+ ::sal_Int32 mnError;
+ ::sal_Bool mbMerged;
+ ::sal_Int32 mnRowSpan;
+ ::sal_Int32 mnColSpan;
+
+ Rectangle maCellRect;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::table::XTable > mxTable;
+};
+
+// -----------------------------------------------------------------------------
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/cellcursor.cxx b/svx/source/table/cellcursor.cxx
new file mode 100644
index 000000000000..4eca7365de34
--- /dev/null
+++ b/svx/source/table/cellcursor.cxx
@@ -0,0 +1,593 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svx/svdotable.hxx"
+#include "cellcursor.hxx"
+#include "tablelayouter.hxx"
+#include "cell.hxx"
+#include "svx/svdmodel.hxx"
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+
+// -----------------------------------------------------------------------------
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::table;
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+// CellCursor
+// -----------------------------------------------------------------------------
+
+CellCursor::CellCursor( const TableModelRef & xTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
+: CellCursorBase( xTable, nLeft, nTop, nRight, nBottom )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+CellCursor::~CellCursor()
+{
+}
+
+// -----------------------------------------------------------------------------
+// XCellCursor
+// -----------------------------------------------------------------------------
+
+Reference< XCell > SAL_CALL CellCursor::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return CellRange::getCellByPosition( nColumn, nRow );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellRange > SAL_CALL CellCursor::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return CellRange::getCellRangeByPosition( nLeft, nTop, nRight, nBottom );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellRange > SAL_CALL CellCursor::getCellRangeByName( const OUString& aRange ) throw (RuntimeException)
+{
+ return CellRange::getCellRangeByName( aRange );
+}
+
+// -----------------------------------------------------------------------------
+// XCellCursor
+// -----------------------------------------------------------------------------
+
+void SAL_CALL CellCursor::gotoStart( ) throw (RuntimeException)
+{
+ mnRight = mnLeft;
+ mnBottom = mnTop;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL CellCursor::gotoEnd( ) throw (RuntimeException)
+{
+ mnLeft = mnRight;
+ mnTop = mnBottom;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL CellCursor::gotoNext( ) throw (RuntimeException)
+{
+ if( mxTable.is() )
+ {
+ mnRight++;
+ if( mnRight >= mxTable->getColumnCount() )
+ {
+ // if we past the last column, try skip to the row line
+ mnTop++;
+ if( mnTop >= mxTable->getRowCount() )
+ {
+ // if we past the last row, do not move cursor at all
+ mnTop--;
+ mnRight--;
+ }
+ else
+ {
+ // restart at the first column on the next row
+ mnRight = 0;
+ }
+ }
+ }
+
+ mnLeft = mnRight;
+ mnTop = mnBottom;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL CellCursor::gotoPrevious( ) throw (RuntimeException)
+{
+ if( mxTable.is() )
+ {
+ if( mnLeft > 0 )
+ {
+ --mnLeft;
+ }
+ else if( mnTop > 0 )
+ {
+ --mnTop;
+ mnLeft = mxTable->getColumnCount() - 1;
+ }
+ }
+
+ mnRight = mnLeft;
+ mnBottom = mnTop;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL CellCursor::gotoOffset( ::sal_Int32 nColumnOffset, ::sal_Int32 nRowOffset ) throw (RuntimeException)
+{
+ if( mxTable.is() )
+ {
+ const sal_Int32 nLeft = mnLeft + nColumnOffset;
+ if( (nLeft >= 0) && (nLeft < mxTable->getColumnCount() ) )
+ mnRight = mnLeft = nLeft;
+
+ const sal_Int32 nTop = mnTop + nRowOffset;
+ if( (nTop >= 0) && (nTop < mxTable->getRowCount()) )
+ mnTop = mnBottom = nTop;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XMergeableCellCursor
+// -----------------------------------------------------------------------------
+
+/** returns true and the merged cell positions if a merge is valid or false if a merge is
+ not valid for that range */
+bool CellCursor::GetMergedSelection( CellPos& rStart, CellPos& rEnd )
+{
+ rStart.mnCol = mnLeft; rStart.mnRow = mnTop;
+ rEnd.mnCol = mnRight; rEnd.mnRow = mnBottom;
+
+ // single cell merge is never valid
+ if( mxTable.is() && ((mnLeft != mnRight) || (mnTop != mnBottom)) ) try
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( mnLeft, mnTop ).get() ) );
+
+ // check if first cell is merged
+ if( xCell.is() && xCell->isMerged() )
+ findMergeOrigin( mxTable, mnLeft, mnTop, rStart.mnCol, rStart.mnRow );
+
+ // check if last cell is merged
+ xCell.set( dynamic_cast< Cell* >( mxTable->getCellByPosition( mnRight, mnBottom ).get() ) );
+ if( xCell.is() )
+ {
+ if( xCell->isMerged() )
+ {
+ findMergeOrigin( mxTable, mnRight, mnBottom, rEnd.mnCol, rEnd.mnRow );
+ // merge not possible if selection is only one cell and all its merges
+ if( rEnd == rStart )
+ return false;
+ xCell.set( dynamic_cast< Cell* >( mxTable->getCellByPosition( rEnd.mnCol, rEnd.mnRow ).get() ) );
+ }
+ }
+ if( xCell.is() )
+ {
+ rEnd.mnCol += xCell->getColumnSpan()-1;
+ rEnd.mnRow += xCell->getRowSpan()-1;
+ }
+
+ // now check if everything is inside the given bounds
+ sal_Int32 nRow, nCol;
+ for( nRow = rStart.mnRow; nRow <= rEnd.mnRow; nRow++ )
+ {
+ for( nCol = rStart.mnCol; nCol <= rEnd.mnCol; nCol++ )
+ {
+ xCell.set( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( !xCell.is() )
+ continue;
+
+ if( xCell->isMerged() )
+ {
+ sal_Int32 nOriginCol, nOriginRow;
+ if( findMergeOrigin( mxTable, nCol, nRow, nOriginCol, nOriginRow ) )
+ {
+ if( (nOriginCol < rStart.mnCol) || (nOriginRow < rStart.mnRow) )
+ return false;
+
+ xCell.set( dynamic_cast< Cell* >( mxTable->getCellByPosition( nOriginCol, nOriginRow ).get() ) );
+ if( xCell.is() )
+ {
+ nOriginCol += xCell->getColumnSpan()-1;
+ nOriginRow += xCell->getRowSpan()-1;
+
+ if( (nOriginCol > rEnd.mnCol) || (nOriginRow > rEnd.mnRow) )
+ return false;
+ }
+ }
+ }
+ else if( ((nCol + xCell->getColumnSpan() - 1) > rEnd.mnCol) || ((nRow + xCell->getRowSpan() - 1 ) > rEnd.mnRow) )
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("sdr::table::SvmxTableController::GetMergedSelection(), exception caught!");
+ }
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL CellCursor::merge( ) throw (NoSupportException, RuntimeException)
+{
+ CellPos aStart, aEnd;
+ if( !GetMergedSelection( aStart, aEnd ) )
+ throw NoSupportException();
+
+ if( !mxTable.is() || (mxTable->getSdrTableObj() == 0) )
+ throw DisposedException();
+
+ SdrModel* pModel = mxTable->getSdrTableObj()->GetModel();
+ const bool bUndo = pModel && mxTable->getSdrTableObj()->IsInserted() && pModel->IsUndoEnabled();
+
+ if( bUndo )
+ pModel->BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
+
+ try
+ {
+ mxTable->merge( aStart.mnCol, aStart.mnRow, aEnd.mnCol - aStart.mnCol + 1, aEnd.mnRow - aStart.mnRow + 1 );
+ mxTable->optimize();
+ mxTable->setModified(sal_True);
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("sdr::table::CellCursor::merge(), exception caught!");
+ }
+
+ if( bUndo )
+ pModel->EndUndo();
+
+ if( pModel )
+ pModel->SetChanged();
+}
+
+// -----------------------------------------------------------------------------
+
+void CellCursor::split_column( sal_Int32 nCol, sal_Int32 nColumns, std::vector< sal_Int32 >& rLeftOvers )
+{
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+
+ sal_Int32 nNewCols = 0, nRow;
+
+ // first check how many columns we need to add
+ for( nRow = mnTop; nRow <= mnBottom; ++nRow )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() && !xCell->isMerged() )
+ nNewCols = std::max( nNewCols, nColumns - xCell->getColumnSpan() + 1 - rLeftOvers[nRow] );
+ }
+
+ if( nNewCols > 0 )
+ {
+ const OUString sWidth( RTL_CONSTASCII_USTRINGPARAM("Width") );
+ Reference< XTableColumns > xCols( mxTable->getColumns(), UNO_QUERY_THROW );
+ Reference< XPropertySet > xRefColumn( xCols->getByIndex( nCol ), UNO_QUERY_THROW );
+ sal_Int32 nWidth = 0;
+ xRefColumn->getPropertyValue( sWidth ) >>= nWidth;
+ const sal_Int32 nNewWidth = nWidth / (nNewCols + 1);
+
+ // reference column gets new width + rounding errors
+ xRefColumn->setPropertyValue( sWidth, Any( nWidth - (nNewWidth * nNewCols) ) );
+
+ xCols->insertByIndex( nCol + 1, nNewCols );
+ mnRight += nNewCols;
+
+ // distribute new width
+ for( sal_Int32 nNewCol = nCol + nNewCols; nNewCol > nCol; --nNewCol )
+ {
+ Reference< XPropertySet > xNewCol( xCols->getByIndex( nNewCol ), UNO_QUERY_THROW );
+ xNewCol->setPropertyValue( sWidth, Any( nNewWidth ) );
+ }
+ }
+
+ for( nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( !xCell.is() || xCell->isMerged() )
+ {
+ if( nNewCols > 0 )
+ {
+ // merged cells are ignored, but newly added columns will be added to leftovers
+ xCell.set( dynamic_cast< Cell* >(mxTable->getCellByPosition( nCol+1, nRow ).get() ) );
+ if( !xCell.is() || !xCell->isMerged() )
+ rLeftOvers[nRow] += nNewCols;
+ }
+ }
+ else
+ {
+ sal_Int32 nRowSpan = xCell->getRowSpan() - 1;
+ sal_Int32 nColSpan = xCell->getColumnSpan() - 1;
+
+ if( (nRow >= mnTop) && (nRow <= mnBottom) )
+ {
+ sal_Int32 nCellsAvailable = 1 + nColSpan + rLeftOvers[nRow];
+ if( nColSpan == 0 )
+ nCellsAvailable += nNewCols;
+
+ DBG_ASSERT( nCellsAvailable > nColumns, "sdr::table::CellCursor::split_column(), somethings wrong" );
+
+ sal_Int32 nSplitSpan = (nCellsAvailable / (nColumns + 1)) - 1;
+
+ sal_Int32 nSplitCol = nCol;
+ sal_Int32 nSplits = nColumns + 1;
+ while( nSplits-- )
+ {
+ // last split eats rounding cells
+ if( nSplits == 0 )
+ nSplitSpan = nCellsAvailable - ((nSplitSpan+1) * nColumns) - 1;
+
+ mxTable->merge( nSplitCol, nRow, nSplitSpan + 1, nRowSpan + 1);
+ if( nSplits > 0 )
+ nSplitCol += nSplitSpan + 1;
+ }
+
+ do
+ {
+ rLeftOvers[nRow++] = 0;
+ }
+ while( nRowSpan-- );
+ --nRow;
+ }
+ else
+ {
+ // cope with outside cells, merge if needed
+ if( nColSpan < (rLeftOvers[nRow] + nNewCols) )
+ mxTable->merge( nCol, nRow, (rLeftOvers[nRow] + nNewCols) + 1, nRowSpan + 1 );
+
+ do
+ {
+ rLeftOvers[nRow++] = 0; // consumed
+ }
+ while( nRowSpan-- );
+ --nRow;
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void CellCursor::split_horizontal( sal_Int32 nColumns )
+{
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+
+ std::vector< sal_Int32 > aLeftOvers( nRowCount );
+
+ for( sal_Int32 nCol = mnRight; nCol >= mnLeft; --nCol )
+ split_column( nCol, nColumns, aLeftOvers );
+}
+
+// -----------------------------------------------------------------------------
+
+void CellCursor::split_row( sal_Int32 nRow, sal_Int32 nRows, std::vector< sal_Int32 >& rLeftOvers )
+{
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+
+ sal_Int32 nNewRows = 0, nCol;
+
+ // first check how many columns we need to add
+ for( nCol = mnLeft; nCol <= mnRight; ++nCol )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() && !xCell->isMerged() )
+ nNewRows = std::max( nNewRows, nRows - xCell->getRowSpan() + 1 - rLeftOvers[nCol] );
+ }
+
+ if( nNewRows > 0 )
+ {
+ const OUString sHeight( RTL_CONSTASCII_USTRINGPARAM("Height") );
+ Reference< XTableRows > xRows( mxTable->getRows(), UNO_QUERY_THROW );
+ Reference< XPropertySet > xRefRow( xRows->getByIndex( nRow ), UNO_QUERY_THROW );
+ sal_Int32 nHeight = 0;
+ xRefRow->getPropertyValue( sHeight ) >>= nHeight;
+ const sal_Int32 nNewHeight = nHeight / (nNewRows + 1);
+
+ // reference row gets new height + rounding errors
+ xRefRow->setPropertyValue( sHeight, Any( nHeight - (nNewHeight * nNewRows) ) );
+
+ xRows->insertByIndex( nRow + 1, nNewRows );
+ mnBottom += nNewRows;
+
+ // distribute new width
+ for( sal_Int32 nNewRow = nRow + nNewRows; nNewRow > nRow; --nNewRow )
+ {
+ Reference< XPropertySet > xNewRow( xRows->getByIndex( nNewRow ), UNO_QUERY_THROW );
+ xNewRow->setPropertyValue( sHeight, Any( nNewHeight ) );
+ }
+ }
+
+ for( nCol = 0; nCol < nColCount; ++nCol )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( !xCell.is() || xCell->isMerged() )
+ {
+ if( nNewRows )
+ {
+ // merged cells are ignored, but newly added columns will be added to leftovers
+ xCell.set( dynamic_cast< Cell* >(mxTable->getCellByPosition( nCol, nRow+1 ).get() ) );
+ if( !xCell.is() || !xCell->isMerged() )
+ rLeftOvers[nCol] += nNewRows;
+ }
+ }
+ else
+ {
+ sal_Int32 nRowSpan = xCell->getRowSpan() - 1;
+ sal_Int32 nColSpan = xCell->getColumnSpan() - 1;
+
+ if( (nCol >= mnLeft) && (nCol <= mnRight) )
+ {
+ sal_Int32 nCellsAvailable = 1 + nRowSpan + rLeftOvers[nCol];
+ if( nRowSpan == 0 )
+ nCellsAvailable += nNewRows;
+
+ DBG_ASSERT( nCellsAvailable > nRows, "sdr::table::CellCursor::split_row(), somethings wrong" );
+
+ sal_Int32 nSplitSpan = (nCellsAvailable / (nRows + 1)) - 1;
+
+ sal_Int32 nSplitRow = nRow;
+ sal_Int32 nSplits = nRows + 1;
+ while( nSplits-- )
+ {
+ // last split eats rounding cells
+ if( nSplits == 0 )
+ nSplitSpan = nCellsAvailable - ((nSplitSpan+1) * nRows) - 1;
+
+ mxTable->merge( nCol, nSplitRow, nColSpan + 1, nSplitSpan + 1 );
+ if( nSplits > 0 )
+ nSplitRow += nSplitSpan + 1;
+ }
+
+ do
+ {
+ rLeftOvers[nCol++] = 0;
+ }
+ while( nColSpan-- );
+ --nCol;
+ }
+ else
+ {
+ // cope with outside cells, merge if needed
+ if( nRowSpan < (rLeftOvers[nCol] + nNewRows) )
+ mxTable->merge( nCol, nRow, nColSpan + 1, (rLeftOvers[nCol] + nNewRows) + 1 );
+
+ do
+ {
+ rLeftOvers[nCol++] = 0; // consumed
+ }
+ while( nColSpan-- );
+ --nCol;
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void CellCursor::split_vertical( sal_Int32 nRows )
+{
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+
+ std::vector< sal_Int32 > aLeftOvers( nColCount );
+
+ for( sal_Int32 nRow = mnBottom; nRow >= mnTop; --nRow )
+ split_row( nRow, nRows, aLeftOvers );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL CellCursor::split( sal_Int32 nColumns, sal_Int32 nRows ) throw (NoSupportException, IllegalArgumentException, RuntimeException)
+{
+ if( (nColumns < 0) || (nRows < 0) )
+ throw IllegalArgumentException();
+
+ if( !mxTable.is() || (mxTable->getSdrTableObj() == 0) )
+ throw DisposedException();
+
+ SdrModel* pModel = mxTable->getSdrTableObj()->GetModel();
+ const bool bUndo = pModel && mxTable->getSdrTableObj()->IsInserted() && pModel->IsUndoEnabled();
+ if( bUndo )
+ pModel->BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
+
+ try
+ {
+ if( nColumns > 0 )
+ split_horizontal( nColumns );
+
+ if( nRows > 0 )
+ split_vertical( nRows );
+
+ if( nColumns > 0 ||nRows > 0 )
+ mxTable->setModified(sal_True);
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("sdr::table::CellCursor::split(), exception caught!");
+ throw NoSupportException();
+ }
+
+ if( bUndo )
+ pModel->EndUndo();
+
+ if( pModel )
+ pModel->SetChanged();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CellCursor::isMergeable( ) throw (RuntimeException)
+{
+ CellPos aStart, aEnd;
+ return GetMergedSelection( aStart, aEnd ) ? sal_True : sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL CellCursor::isUnmergeable( ) throw (RuntimeException)
+{
+ // this is true if there is at least one merged cell in the current range
+ for( sal_Int32 nRow = mnTop; nRow <= mnBottom; nRow++ )
+ {
+ for( sal_Int32 nCol = mnLeft; nCol <= mnRight; nCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() && ( (xCell->getRowSpan() > 1) || (xCell->getColumnSpan() > 1) ) )
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/cellcursor.hxx b/svx/source/table/cellcursor.hxx
new file mode 100644
index 000000000000..8876abe7ea8a
--- /dev/null
+++ b/svx/source/table/cellcursor.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_CELLCURSOR_HXX_
+#define _SVX_CELLCURSOR_HXX_
+
+#include <com/sun/star/table/XMergeableCellRange.hpp>
+#include <com/sun/star/table/XCellCursor.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include "cellrange.hxx"
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+struct CellPos;
+
+// -----------------------------------------------------------------------------
+// CellCursor
+// -----------------------------------------------------------------------------
+
+typedef ::cppu::ImplInheritanceHelper2< CellRange, ::com::sun::star::table::XCellCursor, ::com::sun::star::table::XMergeableCellRange > CellCursorBase;
+
+class CellCursor : public CellCursorBase
+{
+public:
+ CellCursor( const TableModelRef& xTableModel, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom );
+ virtual ~CellCursor();
+
+ // XCellRange
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > SAL_CALL getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByName( const ::rtl::OUString& aRange ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XCellCursor
+ virtual void SAL_CALL gotoStart( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL gotoEnd( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL gotoNext( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL gotoPrevious( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL gotoOffset( ::sal_Int32 nColumnOffset, ::sal_Int32 nRowOffset ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XMergeableCellRange
+ virtual void SAL_CALL merge( ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL split( ::sal_Int32 Columns, ::sal_Int32 Rows ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isMergeable( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isUnmergeable( ) throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ bool GetMergedSelection( CellPos& rStart, CellPos& rEnd );
+
+ void split_column( sal_Int32 nCol, sal_Int32 nColumns, std::vector< sal_Int32 >& rLeftOvers );
+ void split_horizontal( sal_Int32 nColumns );
+ void split_row( sal_Int32 nRow, sal_Int32 nRows, std::vector< sal_Int32 >& rLeftOvers );
+ void split_vertical( sal_Int32 nRows );
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/celleditsource.cxx b/svx/source/table/celleditsource.cxx
new file mode 100644
index 000000000000..3ee05610b9e2
--- /dev/null
+++ b/svx/source/table/celleditsource.cxx
@@ -0,0 +1,1058 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
+
+#include <rtl/ref.hxx>
+#include <osl/mutex.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <comphelper/processfactory.hxx>
+#include <svl/lstner.hxx>
+#include <svl/hint.hxx>
+#include <svl/style.hxx>
+
+#include "celleditsource.hxx"
+#include "cell.hxx"
+#include "svx/svdmodel.hxx"
+#include "svx/svdoutl.hxx"
+#include "svx/svdobj.hxx"
+#include "editeng/unoedhlp.hxx"
+#include "svx/svdview.hxx"
+#include "svx/svdetc.hxx"
+#include "editeng/outliner.hxx"
+#include "editeng/unoforou.hxx"
+#include "editeng/unoviwou.hxx"
+#include "editeng/outlobj.hxx"
+#include "svx/svdotext.hxx"
+#include "svx/svdpage.hxx"
+#include "editeng/editeng.hxx"
+#include "editeng/unotext.hxx"
+#include "sdrpaintwindow.hxx"
+
+//------------------------------------------------------------------------
+
+using ::rtl::OUString;
+using namespace ::osl;
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::linguistic2;
+using namespace ::com::sun::star::lang;
+
+//------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+//------------------------------------------------------------------------
+// CellEditSourceImpl
+//------------------------------------------------------------------------
+
+/** @descr
+ <p>This class essentially provides the text and view forwarders. If
+ no SdrView is given, this class handles the UNO objects, which are
+ currently not concerned with view issues. In this case,
+ GetViewForwarder() always returns NULL and the underlying
+ EditEngine of the SvxTextForwarder is a background one (i.e. not
+ the official DrawOutliner, but one created exclusively for this
+ object, with no relation to a view).
+ </p>
+
+ <p>If a SdrView is given at construction time, the caller is
+ responsible for destroying this object when the view becomes
+ invalid (the views cannot notify). If GetViewForwarder(sal_True)
+ is called, the underlying shape is put into edit mode, the view
+ forwarder returned encapsulates the OutlinerView and the next call
+ to GetTextForwarder() yields a forwarder encapsulating the actual
+ DrawOutliner. Thus, changes on that Outliner are immediately
+ reflected on the screen. If the object leaves edit mode, the old
+ behaviour is restored.</p>
+ */
+class CellEditSourceImpl : public SfxListener, public SfxBroadcaster
+{
+private:
+ oslInterlockedCount maRefCount;
+
+ SdrView* mpView;
+ const Window* mpWindow;
+ SdrModel* mpModel;
+ SdrOutliner* mpOutliner;
+ SvxOutlinerForwarder* mpTextForwarder;
+ SvxDrawOutlinerViewForwarder* mpViewForwarder;
+ Reference< ::com::sun::star::linguistic2::XLinguServiceManager > mxLinguServiceManager;
+ Point maTextOffset;
+ bool mbDataValid;
+ bool mbDisposed;
+ bool mbIsLocked;
+ bool mbNeedsUpdate;
+ bool mbOldUndoMode;
+ bool mbForwarderIsEditMode; // have to reflect that, since ENDEDIT can happen more often
+ bool mbShapeIsEditMode; // #104157# only true, if HINT_BEGEDIT was received
+ bool mbNotificationsDisabled; // prevent EditEngine/Outliner notifications (e.g. when setting up forwarder)
+
+ CellRef mxCell;
+ SvxUnoTextRangeBaseList maTextRanges;
+
+ SvxTextForwarder* GetBackgroundTextForwarder();
+ SvxTextForwarder* GetEditModeTextForwarder();
+ SvxDrawOutlinerViewForwarder* CreateViewForwarder();
+
+ void SetupOutliner();
+ void UpdateOutliner();
+
+ bool HasView() const { return mpView != 0; }
+ bool IsEditMode() const { return mxCell->IsTextEditActive(); };
+ void dispose();
+
+public:
+ CellEditSourceImpl( const CellRef& xCell );
+ CellEditSourceImpl( const CellRef& xCell, SdrView& rView, const Window& rWindow );
+ ~CellEditSourceImpl();
+
+ void SAL_CALL acquire();
+ void SAL_CALL release();
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ SvxEditSource* Clone() const;
+ SvxTextForwarder* GetTextForwarder();
+ SvxEditViewForwarder* GetEditViewForwarder( sal_Bool );
+ void UpdateData();
+
+ void addRange( SvxUnoTextRangeBase* pNewRange );
+ void removeRange( SvxUnoTextRangeBase* pOldRange );
+ const SvxUnoTextRangeBaseList& getRanges() const;
+
+ void lock();
+ void unlock();
+
+ BOOL IsValid() const;
+
+ Rectangle GetVisArea();
+ Point LogicToPixel( const Point&, const MapMode& rMapMode );
+ Point PixelToLogic( const Point&, const MapMode& rMapMode );
+
+ DECL_LINK( NotifyHdl, EENotify* );
+
+ void ChangeModel( SdrModel* pNewModel );
+};
+
+//------------------------------------------------------------------------
+
+CellEditSourceImpl::CellEditSourceImpl( const CellRef& xCell )
+ : maRefCount ( 0 ),
+ mpView ( NULL ),
+ mpWindow ( NULL ),
+ mpModel ( NULL ),
+ mpOutliner ( NULL ),
+ mpTextForwarder ( NULL ),
+ mpViewForwarder ( NULL ),
+ mbDataValid ( false ),
+ mbDisposed ( false ),
+ mbIsLocked ( false ),
+ mbNeedsUpdate ( false ),
+ mbOldUndoMode ( false ),
+ mbForwarderIsEditMode ( false ),
+ mbShapeIsEditMode ( false ),
+ mbNotificationsDisabled ( false ),
+ mxCell( xCell )
+{
+}
+
+//------------------------------------------------------------------------
+
+CellEditSourceImpl::CellEditSourceImpl( const CellRef& xCell, SdrView& rView, const Window& rWindow )
+ : maRefCount ( 0 ),
+ mpView ( &rView ),
+ mpWindow ( &rWindow ),
+ mpModel ( NULL ),
+ mpOutliner ( NULL ),
+ mpTextForwarder ( NULL ),
+ mpViewForwarder ( NULL ),
+ mbDataValid ( false ),
+ mbDisposed ( false ),
+ mbIsLocked ( false ),
+ mbNeedsUpdate ( false ),
+ mbOldUndoMode ( false ),
+ mbForwarderIsEditMode ( false ),
+ mbShapeIsEditMode ( true ),
+ mbNotificationsDisabled ( false ),
+ mxCell( xCell )
+{
+ if( mpView )
+ StartListening( *mpView );
+
+ // #104157# Init edit mode state from shape info (IsTextEditActive())
+ mbShapeIsEditMode = IsEditMode();
+}
+
+//------------------------------------------------------------------------
+
+CellEditSourceImpl::~CellEditSourceImpl()
+{
+ DBG_ASSERT( mbIsLocked == sal_False, "CellEditSourceImpl::~CellEditSourceImpl(), was not unlocked before dispose!" );
+ dispose();
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSourceImpl::addRange( SvxUnoTextRangeBase* pNewRange )
+{
+ if( pNewRange )
+ if( std::find( maTextRanges.begin(), maTextRanges.end(), pNewRange ) == maTextRanges.end() )
+ maTextRanges.push_back( pNewRange );
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSourceImpl::removeRange( SvxUnoTextRangeBase* pOldRange )
+{
+ if( pOldRange )
+ maTextRanges.remove( pOldRange );
+}
+
+//------------------------------------------------------------------------
+
+const SvxUnoTextRangeBaseList& CellEditSourceImpl::getRanges() const
+{
+ return maTextRanges;
+}
+
+//------------------------------------------------------------------------
+
+void SAL_CALL CellEditSourceImpl::acquire()
+{
+ osl_incrementInterlockedCount( &maRefCount );
+}
+
+//------------------------------------------------------------------------
+
+void SAL_CALL CellEditSourceImpl::release()
+{
+ if( ! osl_decrementInterlockedCount( &maRefCount ) )
+ delete this;
+}
+
+void CellEditSourceImpl::ChangeModel( SdrModel* pNewModel )
+{
+ if( mpModel != pNewModel )
+ {
+ if( mpOutliner )
+ {
+ if( mpModel )
+ mpModel->disposeOutliner( mpOutliner );
+ else
+ delete mpOutliner;
+ mpOutliner = 0;
+ }
+
+ if( mpView )
+ {
+ EndListening( *mpView );
+ mpView = 0;
+ }
+
+ mpWindow = 0;
+ mxLinguServiceManager.clear();
+
+ mpModel = pNewModel;
+
+ if( mpTextForwarder )
+ {
+ delete mpTextForwarder;
+ mpTextForwarder = 0;
+ }
+
+ if( mpViewForwarder )
+ {
+ delete mpViewForwarder;
+ mpViewForwarder = 0;
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSourceImpl::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+ const SvxViewHint* pViewHint = PTR_CAST( SvxViewHint, &rHint );
+
+ if( pViewHint )
+ {
+ switch( pViewHint->GetHintType() )
+ {
+ case SvxViewHint::SVX_HINT_VIEWCHANGED:
+ Broadcast( *pViewHint );
+ break;
+ }
+ }
+ else if( pSdrHint )
+ {
+ switch( pSdrHint->GetKind() )
+ {
+ case HINT_OBJCHG:
+ {
+ mbDataValid = FALSE; // Text muss neu geholt werden
+
+ if( HasView() )
+ {
+ // #104157# Update maTextOffset, object has changed
+ // #105196#, #105203#: Cannot call that // here,
+ // since TakeTextRect() (called from there) //
+ // changes outliner content.
+ // UpdateOutliner();
+
+ // #101029# Broadcast object changes, as they might change visible attributes
+ SvxViewHint aHint(SvxViewHint::SVX_HINT_VIEWCHANGED);
+ Broadcast( aHint );
+ }
+ break;
+ }
+
+ case HINT_BEGEDIT:
+/* todo
+ if( mpObject == pSdrHint->GetObject() )
+ {
+ // invalidate old forwarder
+ if( !mbForwarderIsEditMode )
+ {
+ delete mpTextForwarder;
+ mpTextForwarder = NULL;
+ }
+
+ // register as listener - need to broadcast state change messages
+ if( mpView && mpView->GetTextEditOutliner() )
+ mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, CellEditSourceImpl, NotifyHdl) );
+
+ // #104157# Only now we're really in edit mode
+ mbShapeIsEditMode = TRUE;
+
+ Broadcast( *pSdrHint );
+ }
+*/
+ break;
+
+ case HINT_ENDEDIT:
+/* todo
+ if( mpObject == pSdrHint->GetObject() )
+ {
+ Broadcast( *pSdrHint );
+
+ // #104157# We're no longer in edit mode
+ mbShapeIsEditMode = FALSE;
+
+ // remove as listener - outliner might outlive ourselves
+ if( mpView && mpView->GetTextEditOutliner() )
+ mpView->GetTextEditOutliner()->SetNotifyHdl( Link() );
+
+ // destroy view forwarder, OutlinerView no longer
+ // valid (no need for UpdateData(), it's been
+ // synched on SdrEndTextEdit)
+ delete mpViewForwarder;
+ mpViewForwarder = NULL;
+
+ // #100424# Invalidate text forwarder, we might
+ // not be called again before entering edit mode a
+ // second time! Then, the old outliner might be
+ // invalid.
+ if( mbForwarderIsEditMode )
+ {
+ mbForwarderIsEditMode = sal_False;
+ delete mpTextForwarder;
+ mpTextForwarder = NULL;
+ }
+ }
+*/
+ break;
+
+ case HINT_MODELCLEARED:
+ dispose();
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+/* unregister at all objects and set all references to 0 */
+void CellEditSourceImpl::dispose()
+{
+ if( mpTextForwarder )
+ {
+ delete mpTextForwarder;
+ mpTextForwarder = 0;
+ }
+
+ if( mpViewForwarder )
+ {
+ delete mpViewForwarder;
+ mpViewForwarder = 0;
+ }
+
+ if( mpOutliner )
+ {
+ if( mpModel )
+ {
+ mpModel->disposeOutliner( mpOutliner );
+ }
+ else
+ {
+ delete mpOutliner;
+ }
+ mpOutliner = 0;
+ }
+
+ if( mpView )
+ {
+ EndListening( *mpView );
+ mpView = 0;
+ }
+
+ mpModel = 0;
+ mpWindow = 0;
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSourceImpl::SetupOutliner()
+{
+ // #101029#
+ // only for UAA edit source: setup outliner equivalently as in
+ // SdrTextObj::Paint(), such that formatting equals screen
+ // layout
+/* todo
+ if( mpObject && mpOutliner )
+ {
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
+ Rectangle aPaintRect;
+ if( pTextObj )
+ {
+ Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() );
+ pTextObj->SetupOutlinerFormatting( *mpOutliner, aPaintRect );
+
+ // #101029# calc text offset from shape anchor
+ maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft();
+ }
+ }
+*/
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSourceImpl::UpdateOutliner()
+{
+ // #104157#
+ // only for UAA edit source: update outliner equivalently as in
+ // SdrTextObj::Paint(), such that formatting equals screen
+ // layout
+/* todo
+ if( mpObject && mpOutliner )
+ {
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
+ Rectangle aPaintRect;
+ if( pTextObj )
+ {
+ Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() );
+ pTextObj->UpdateOutlinerFormatting( *mpOutliner, aPaintRect );
+
+ // #101029# calc text offset from shape anchor
+ maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft();
+ }
+ }
+*/
+}
+
+//------------------------------------------------------------------------
+
+
+SvxTextForwarder* CellEditSourceImpl::GetBackgroundTextForwarder()
+{
+ sal_Bool bCreated = sal_False;
+
+ // #99840#: prevent EE/Outliner notifications during setup
+ mbNotificationsDisabled = true;
+
+ if (!mpTextForwarder)
+ {
+ if( mpOutliner == NULL )
+ {
+ mpOutliner = mpModel->createOutliner( OUTLINERMODE_TEXTOBJECT );
+
+ // #109151# Do the setup after outliner creation, would be useless otherwise
+ if( HasView() )
+ {
+ // #101029#, #104157# Setup outliner _before_ filling it
+ SetupOutliner();
+ }
+
+// todo? mpOutliner->SetTextObjNoInit( pTextObj );
+
+ if( mbIsLocked )
+ {
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_False );
+ mbOldUndoMode = ((EditEngine*)&(mpOutliner->GetEditEngine()))->IsUndoEnabled();
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( sal_False );
+ }
+
+ if ( !mxLinguServiceManager.is() )
+ {
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ mxLinguServiceManager = Reference< XLinguServiceManager >(
+ xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.linguistic2.LinguServiceManager" ))), UNO_QUERY );
+ }
+
+ if ( mxLinguServiceManager.is() )
+ {
+ Reference< XHyphenator > xHyphenator( mxLinguServiceManager->getHyphenator(), UNO_QUERY );
+ if( xHyphenator.is() )
+ mpOutliner->SetHyphenator( xHyphenator );
+ }
+ }
+
+ mpTextForwarder = new SvxOutlinerForwarder( *mpOutliner );
+
+ // delay listener subscription and UAA initialization until Outliner is fully setup
+ bCreated = true;
+ mbForwarderIsEditMode = false;
+ }
+
+ if( !mbDataValid )
+ {
+ mpTextForwarder->flushCache();
+
+ OutlinerParaObject* pOutlinerParaObject = NULL;
+ bool bTextEditActive = false;
+
+ pOutlinerParaObject = mxCell->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
+
+ if( pOutlinerParaObject )
+ bTextEditActive = true; // text edit active
+ else
+ pOutlinerParaObject = mxCell->GetOutlinerParaObject();
+
+ if( pOutlinerParaObject )
+ {
+ mpOutliner->SetText( *pOutlinerParaObject );
+ }
+ else
+ {
+ bool bVertical = false; // todo?
+
+ // set objects style sheet on empty outliner
+ SfxStyleSheetPool* pPool = mxCell->GetStyleSheetPool();
+ if( pPool )
+ mpOutliner->SetStyleSheetPool( pPool );
+
+ SfxStyleSheet* pStyleSheet = mxCell->GetStyleSheet();
+ if( pStyleSheet )
+ mpOutliner->SetStyleSheet( 0, pStyleSheet );
+
+ if( bVertical )
+ mpOutliner->SetVertical( sal_True );
+ }
+
+ // evtually we have to set the border attributes
+ if (mpOutliner->GetParagraphCount()==1)
+ {
+ // if we only have one paragraph we check if it is empty
+ XubString aStr( mpOutliner->GetText( mpOutliner->GetParagraph( 0 ) ) );
+
+ if(!aStr.Len())
+ {
+ // its empty, so we have to force the outliner to initialise itself
+ mpOutliner->SetText( String(), mpOutliner->GetParagraph( 0 ) );
+
+ if(mxCell->GetStyleSheet())
+ mpOutliner->SetStyleSheet( 0, mxCell->GetStyleSheet());
+ }
+ }
+
+ if( bTextEditActive )
+ delete pOutlinerParaObject;
+
+ mbDataValid = true;
+ }
+
+ if( bCreated && mpOutliner && HasView() )
+ {
+ // register as listener - need to broadcast state change messages
+ // registration delayed until outliner is completely set up
+ mpOutliner->SetNotifyHdl( LINK(this, CellEditSourceImpl, NotifyHdl) );
+ }
+
+ // #99840#: prevent EE/Outliner notifications during setup
+ mbNotificationsDisabled = false;
+
+ return mpTextForwarder;
+}
+
+//------------------------------------------------------------------------
+
+SvxTextForwarder* CellEditSourceImpl::GetEditModeTextForwarder()
+{
+ if( !mpTextForwarder && HasView() )
+ {
+ SdrOutliner* pEditOutliner = mpView->GetTextEditOutliner();
+
+ if( pEditOutliner )
+ {
+ mpTextForwarder = new SvxOutlinerForwarder( *pEditOutliner );
+ mbForwarderIsEditMode = true;
+ }
+ }
+
+ return mpTextForwarder;
+}
+
+//------------------------------------------------------------------------
+
+SvxTextForwarder* CellEditSourceImpl::GetTextForwarder()
+{
+ if( mbDisposed )
+ return NULL;
+
+ if( mpModel == NULL )
+ return NULL;
+
+ // distinguish the cases
+ // a) connected to view, maybe edit mode is active, can work directly on the EditOutliner
+ // b) background Outliner, reflect changes into ParaOutlinerObject (this is exactly the old UNO code)
+ if( HasView() )
+ {
+ if( IsEditMode() != mbForwarderIsEditMode )
+ {
+ // forwarder mismatch - create new
+ delete mpTextForwarder;
+ mpTextForwarder = NULL;
+ }
+
+ if( IsEditMode() )
+ return GetEditModeTextForwarder();
+ else
+ return GetBackgroundTextForwarder();
+ }
+ else
+ return GetBackgroundTextForwarder();
+}
+
+//------------------------------------------------------------------------
+
+SvxDrawOutlinerViewForwarder* CellEditSourceImpl::CreateViewForwarder()
+{
+ if( mpView->GetTextEditOutlinerView() )
+ {
+ // register as listener - need to broadcast state change messages
+ mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, CellEditSourceImpl, NotifyHdl) );
+
+ Rectangle aBoundRect( mxCell->GetCurrentBoundRect() );
+ OutlinerView& rOutlView = *mpView->GetTextEditOutlinerView();
+
+ return new SvxDrawOutlinerViewForwarder( rOutlView, aBoundRect.TopLeft() );
+ }
+
+ return NULL;
+}
+
+SvxEditViewForwarder* CellEditSourceImpl::GetEditViewForwarder( sal_Bool bCreate )
+{
+ if( mbDisposed )
+ return NULL;
+
+ if( mpModel == NULL )
+ return NULL;
+
+ // shall we delete?
+ if( mpViewForwarder )
+ {
+ if( !IsEditMode() )
+ {
+ // destroy all forwarders (no need for UpdateData(),
+ // it's been synched on SdrEndTextEdit)
+ delete mpViewForwarder;
+ mpViewForwarder = NULL;
+ }
+ }
+ // which to create? Directly in edit mode, create new, or none?
+ else if( mpView )
+ {
+ if( IsEditMode() )
+ {
+ // create new view forwarder
+ mpViewForwarder = CreateViewForwarder();
+ }
+ else if( bCreate )
+ {
+ // dispose old text forwarder
+ UpdateData();
+
+ delete mpTextForwarder;
+ mpTextForwarder = NULL;
+
+ // enter edit mode
+ mpView->SdrEndTextEdit();
+
+/* todo
+ if(mpView->SdrBeginTextEdit(mpObject, 0L, 0L, sal_False, (SdrOutliner*)0L, 0L, sal_False, sal_False))
+ {
+ if( mxCell->IsTextEditActive() )
+ {
+ // create new view forwarder
+ mpViewForwarder = CreateViewForwarder();
+ }
+ else
+ {
+ // failure. Somehow, SdrBeginTextEdit did not set
+ // our SdrTextObj into edit mode
+ mpView->SdrEndTextEdit();
+ }
+ }
+*/
+ }
+ }
+
+ return mpViewForwarder;
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSourceImpl::UpdateData()
+{
+ // if we have a view and in edit mode, we're working with the
+ // DrawOutliner. Thus, all changes made on the text forwarder are
+ // reflected on the view and committed to the model on
+ // SdrEndTextEdit(). Thus, no need for explicit updates here.
+ if( !HasView() || !IsEditMode() )
+ {
+ if( mbIsLocked )
+ {
+ mbNeedsUpdate = true;
+ }
+ else
+ {
+ if( mpOutliner && !mbDisposed )
+ {
+ if( mpOutliner->GetParagraphCount() != 1 || mpOutliner->GetEditEngine().GetTextLen( 0 ) )
+ {
+ mxCell->SetOutlinerParaObject( mpOutliner->CreateParaObject() );
+ }
+ else
+ {
+ mxCell->SetOutlinerParaObject( NULL );
+ }
+ }
+ }
+ }
+}
+
+void CellEditSourceImpl::lock()
+{
+ mbIsLocked = true;
+ if( mpOutliner )
+ {
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_False );
+ mbOldUndoMode = ((EditEngine*)&(mpOutliner->GetEditEngine()))->IsUndoEnabled();
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( sal_False );
+ }
+}
+
+void CellEditSourceImpl::unlock()
+{
+ mbIsLocked = false;
+
+ if( mbNeedsUpdate )
+ {
+ UpdateData();
+ mbNeedsUpdate = false;
+ }
+
+ if( mpOutliner )
+ {
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_True );
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( mbOldUndoMode );
+ }
+}
+
+BOOL CellEditSourceImpl::IsValid() const
+{
+ return mpView && mpWindow ? TRUE : FALSE;
+}
+
+Rectangle CellEditSourceImpl::GetVisArea()
+{
+ if( IsValid() )
+ {
+ SdrPaintWindow* pPaintWindow = mpView->FindPaintWindow(*mpWindow);
+ Rectangle aVisArea;
+
+ if(pPaintWindow)
+ {
+ aVisArea = pPaintWindow->GetVisibleArea();
+ }
+
+ // offset vis area by edit engine left-top position
+ Rectangle aAnchorRect;
+ mxCell->TakeTextAnchorRect( aAnchorRect );
+ aVisArea.Move( -aAnchorRect.Left(), -aAnchorRect.Top() );
+
+ MapMode aMapMode(mpWindow->GetMapMode());
+ aMapMode.SetOrigin(Point());
+ return mpWindow->LogicToPixel( aVisArea, aMapMode );
+ }
+
+ return Rectangle();
+}
+
+Point CellEditSourceImpl::LogicToPixel( const Point& rPoint, const MapMode& rMapMode )
+{
+ // #101029#: The responsibilities of ViewForwarder happen to be
+ // somewhat mixed in this case. On the one hand, we need the
+ // different interface queries on the SvxEditSource interface,
+ // since we need both VisAreas. On the other hand, if an
+ // EditViewForwarder exists, maTextOffset does not remain static,
+ // but may change with every key press.
+ if( IsEditMode() )
+ {
+ SvxEditViewForwarder* pForwarder = GetEditViewForwarder(sal_False);
+
+ if( pForwarder )
+ return pForwarder->LogicToPixel( rPoint, rMapMode );
+ }
+ else if( IsValid() && mpModel )
+ {
+ // #101029#
+ Point aPoint1( rPoint );
+ aPoint1.X() += maTextOffset.X();
+ aPoint1.Y() += maTextOffset.Y();
+
+ Point aPoint2( OutputDevice::LogicToLogic( aPoint1, rMapMode,
+ MapMode(mpModel->GetScaleUnit()) ) );
+ MapMode aMapMode(mpWindow->GetMapMode());
+ aMapMode.SetOrigin(Point());
+ return mpWindow->LogicToPixel( aPoint2, aMapMode );
+ }
+
+ return Point();
+}
+
+Point CellEditSourceImpl::PixelToLogic( const Point& rPoint, const MapMode& rMapMode )
+{
+ // #101029#: The responsibilities of ViewForwarder happen to be
+ // somewhat mixed in this case. On the one hand, we need the
+ // different interface queries on the SvxEditSource interface,
+ // since we need both VisAreas. On the other hand, if an
+ // EditViewForwarder exists, maTextOffset does not remain static,
+ // but may change with every key press.
+ if( IsEditMode() )
+ {
+ SvxEditViewForwarder* pForwarder = GetEditViewForwarder(sal_False);
+
+ if( pForwarder )
+ return pForwarder->PixelToLogic( rPoint, rMapMode );
+ }
+ else if( IsValid() && mpModel )
+ {
+ MapMode aMapMode(mpWindow->GetMapMode());
+ aMapMode.SetOrigin(Point());
+ Point aPoint1( mpWindow->PixelToLogic( rPoint, aMapMode ) );
+ Point aPoint2( OutputDevice::LogicToLogic( aPoint1,
+ MapMode(mpModel->GetScaleUnit()),
+ rMapMode ) );
+ // #101029#
+ aPoint2.X() -= maTextOffset.X();
+ aPoint2.Y() -= maTextOffset.Y();
+
+ return aPoint2;
+ }
+
+ return Point();
+}
+
+IMPL_LINK(CellEditSourceImpl, NotifyHdl, EENotify*, aNotify)
+{
+ if( aNotify && !mbNotificationsDisabled )
+ {
+ ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( aNotify) );
+
+ if( aHint.get() )
+ Broadcast( *aHint.get() );
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+// --------------------------------------------------------------------
+// CellEditSource
+// --------------------------------------------------------------------
+
+CellEditSource::CellEditSource( const CellRef& xCell )
+{
+ mpImpl = new CellEditSourceImpl( xCell );
+ mpImpl->acquire();
+}
+
+// --------------------------------------------------------------------
+CellEditSource::CellEditSource( const CellRef& xCell, SdrView& rView, const Window& rWindow )
+{
+ mpImpl = new CellEditSourceImpl( xCell, rView, rWindow );
+ mpImpl->acquire();
+}
+
+// --------------------------------------------------------------------
+
+CellEditSource::CellEditSource( CellEditSourceImpl* pImpl )
+{
+ mpImpl = pImpl;
+ mpImpl->acquire();
+}
+
+//------------------------------------------------------------------------
+CellEditSource::~CellEditSource()
+{
+ ::SolarMutexGuard aGuard;
+ mpImpl->release();
+}
+
+//------------------------------------------------------------------------
+SvxEditSource* CellEditSource::Clone() const
+{
+ return new CellEditSource( mpImpl );
+}
+
+//------------------------------------------------------------------------
+SvxTextForwarder* CellEditSource::GetTextForwarder()
+{
+ return mpImpl->GetTextForwarder();
+}
+
+//------------------------------------------------------------------------
+SvxEditViewForwarder* CellEditSource::GetEditViewForwarder( sal_Bool bCreate )
+{
+ return mpImpl->GetEditViewForwarder( bCreate );
+}
+
+//------------------------------------------------------------------------
+
+SvxViewForwarder* CellEditSource::GetViewForwarder()
+{
+ return this;
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSource::UpdateData()
+{
+ mpImpl->UpdateData();
+}
+
+//------------------------------------------------------------------------
+
+SfxBroadcaster& CellEditSource::GetBroadcaster() const
+{
+ return *mpImpl;
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSource::lock()
+{
+ mpImpl->lock();
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSource::unlock()
+{
+ mpImpl->unlock();
+}
+
+//------------------------------------------------------------------------
+
+BOOL CellEditSource::IsValid() const
+{
+ return mpImpl->IsValid();
+}
+
+//------------------------------------------------------------------------
+
+Rectangle CellEditSource::GetVisArea() const
+{
+ return mpImpl->GetVisArea();
+}
+
+//------------------------------------------------------------------------
+
+Point CellEditSource::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ return mpImpl->LogicToPixel( rPoint, rMapMode );
+}
+
+//------------------------------------------------------------------------
+
+Point CellEditSource::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ return mpImpl->PixelToLogic( rPoint, rMapMode );
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSource::addRange( SvxUnoTextRangeBase* pNewRange )
+{
+ mpImpl->addRange( pNewRange );
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSource::removeRange( SvxUnoTextRangeBase* pOldRange )
+{
+ mpImpl->removeRange( pOldRange );
+}
+
+//------------------------------------------------------------------------
+
+const SvxUnoTextRangeBaseList& CellEditSource::getRanges() const
+{
+ return mpImpl->getRanges();
+}
+
+//------------------------------------------------------------------------
+
+void CellEditSource::ChangeModel( SdrModel* pNewModel )
+{
+ mpImpl->ChangeModel( pNewModel );
+}
+
+//------------------------------------------------------------------------
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/celleditsource.hxx b/svx/source/table/celleditsource.hxx
new file mode 100644
index 000000000000..cc9249a5b1f0
--- /dev/null
+++ b/svx/source/table/celleditsource.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 SVX_TABLE_CELLEDITSOURCE_HXX
+#define SVX_TABLE_CELLEDITSOURCE_HXX
+
+#include "cell.hxx"
+#include "celltypes.hxx"
+#include "editeng/unoedsrc.hxx"
+
+class SvxTextForwarder;
+class SdrObject;
+class SdrModel;
+class SdrView;
+class Window;
+
+namespace sdr { namespace table {
+
+class CellEditSourceImpl;
+
+class CellEditSource : public SvxEditSource, public SvxViewForwarder
+{
+public:
+ CellEditSource( const CellRef& xCell );
+
+ /** Since the views don't broadcast their dying, make sure that
+ this object gets destroyed if the view becomes invalid
+
+ The window is necessary, since our views can display on multiple windows
+ */
+ CellEditSource( const CellRef& xCell, SdrView& rView, const Window& rViewWindow );
+ virtual ~CellEditSource();
+
+ virtual SvxEditSource* Clone() const;
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxViewForwarder* GetViewForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate = sal_False );
+ virtual void UpdateData();
+
+ virtual void addRange( SvxUnoTextRangeBase* pNewRange );
+ virtual void removeRange( SvxUnoTextRangeBase* pOldRange );
+ virtual const SvxUnoTextRangeBaseList& getRanges() const;
+
+ virtual SfxBroadcaster& GetBroadcaster() const;
+
+ void lock();
+ void unlock();
+
+ // the SvxViewForwarder interface
+ virtual BOOL IsValid() const;
+ virtual Rectangle GetVisArea() const;
+ virtual Point LogicToPixel( const Point&, const MapMode& ) const;
+ virtual Point PixelToLogic( const Point&, const MapMode& ) const;
+
+ void ChangeModel( SdrModel* pNewModel );
+
+private:
+ CellEditSource( CellEditSourceImpl* pImpl );
+
+ CellEditSourceImpl* mpImpl;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/cellrange.cxx b/svx/source/table/cellrange.cxx
new file mode 100644
index 000000000000..4adb71dd7146
--- /dev/null
+++ b/svx/source/table/cellrange.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "cellrange.hxx"
+
+// -----------------------------------------------------------------------------
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::table;
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+// CellRange
+// -----------------------------------------------------------------------------
+
+CellRange::CellRange( const TableModelRef & xTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
+: mxTable( xTable )
+, mnLeft(nLeft)
+, mnTop(nTop)
+, mnRight(nRight)
+, mnBottom(nBottom)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+CellRange::~CellRange()
+{
+}
+
+// -----------------------------------------------------------------------------
+// ICellRange
+// -----------------------------------------------------------------------------
+
+sal_Int32 CellRange::getLeft()
+{
+ return mnLeft;
+}
+
+sal_Int32 CellRange::getTop()
+{
+ return mnTop;
+}
+
+sal_Int32 CellRange::getRight()
+{
+ return mnRight;
+}
+
+sal_Int32 CellRange::getBottom()
+{
+ return mnBottom;
+}
+
+Reference< XTable > CellRange::getTable()
+{
+ return mxTable.get();
+}
+
+// -----------------------------------------------------------------------------
+// XCellRange
+// -----------------------------------------------------------------------------
+
+Reference< XCell > SAL_CALL CellRange::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return mxTable->getCellByPosition( mnLeft + nColumn, mnTop + nRow );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellRange > SAL_CALL CellRange::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ if( (nLeft >= 0 ) && (nTop >= 0) && (nRight >= nLeft) && (nBottom >= nTop) )
+ {
+ nLeft += mnLeft;
+ nTop += mnTop;
+ nRight += mnLeft;
+ nBottom += mnTop;
+
+ const sal_Int32 nMaxColumns = (mnRight == -1) ? mxTable->getColumnCount() : mnLeft;
+ const sal_Int32 nMaxRows = (mnBottom == -1) ? mxTable->getRowCount() : mnBottom;
+ if( (nLeft < nMaxColumns) && (nRight < nMaxColumns) && (nTop < nMaxRows) && (nBottom < nMaxRows) )
+ {
+ return mxTable->getCellRangeByPosition( nLeft, nTop, nRight, nBottom );
+ }
+ }
+ throw IndexOutOfBoundsException();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellRange > SAL_CALL CellRange::getCellRangeByName( const OUString& /*aRange*/ ) throw (RuntimeException)
+{
+ return Reference< XCellRange >();
+}
+
+// -----------------------------------------------------------------------------
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/cellrange.hxx b/svx/source/table/cellrange.hxx
new file mode 100644
index 000000000000..49725fa1c18d
--- /dev/null
+++ b/svx/source/table/cellrange.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_CELLRANGE_HXX_
+#define _SVX_CELLRANGE_HXX_
+
+#include <com/sun/star/table/XCellRange.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+#include "tablemodel.hxx"
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+// CellRange
+// -----------------------------------------------------------------------------
+
+class CellRange : public ::cppu::WeakAggImplHelper1< ::com::sun::star::table::XCellRange >, public ICellRange
+{
+public:
+ CellRange( const TableModelRef & xTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom );
+ virtual ~CellRange();
+
+ // ICellRange
+ virtual sal_Int32 getLeft();
+ virtual sal_Int32 getTop();
+ virtual sal_Int32 getRight();
+ virtual sal_Int32 getBottom();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XTable > getTable();
+
+ // XCellRange
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > SAL_CALL getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByName( const ::rtl::OUString& aRange ) throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ TableModelRef mxTable;
+ sal_Int32 mnLeft;
+ sal_Int32 mnTop;
+ sal_Int32 mnRight;
+ sal_Int32 mnBottom;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/celltypes.hxx b/svx/source/table/celltypes.hxx
new file mode 100644
index 000000000000..9f28ebbb67e0
--- /dev/null
+++ b/svx/source/table/celltypes.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_CELLTYPES_HXX_
+#define _SVX_CELLTYPES_HXX_
+
+#include <rtl/ref.hxx>
+#include <vector>
+
+namespace sdr { namespace table {
+
+class Cell;
+class TableModel;
+class TableRow;
+class TableColumn;
+class TableRows;
+class TableColumns;
+typedef rtl::Reference< Cell > CellRef;
+typedef rtl::Reference< TableModel > TableModelRef;
+typedef rtl::Reference< TableRow > TableRowRef;
+typedef rtl::Reference< TableColumn > TableColumnRef;
+typedef rtl::Reference< TableRows > TableRowsRef;
+typedef rtl::Reference< TableColumns > TableColumnsRef;
+typedef std::vector< CellRef > CellVector;
+typedef std::vector< TableRowRef > RowVector;
+typedef std::vector< TableColumnRef > ColumnVector;
+
+class TableDesignUser
+{
+public:
+ virtual bool isInUse() = 0;
+};
+
+template< typename T >
+class RangeIterator
+{
+public:
+ /** creates an iterator from rStart (including) to rEnd (excluding) if
+ bForeward is true or from nEnd (excluding to nStart (including).
+ rStart must be <= rEnd.
+ */
+ RangeIterator( const T& rStart, const T& rEnd, bool bForeward = true )
+ {
+ if( bForeward )
+ {
+ maIter = rStart;
+ maEnd = rEnd;
+ }
+ else
+ {
+ maIter = rEnd-1;
+ maEnd = rStart-1;
+ }
+ }
+
+ /* returns true if the next call to next() will return true also. */
+ bool hasNext() const
+ {
+ return maIter != maEnd;
+ }
+
+ /* iterates in the configured direction and returns true if rValue
+ now contains a valid positon in the range of this iterator */
+ bool next( T& rValue )
+ {
+ if( maIter == maEnd )
+ return false;
+
+ rValue = maIter;
+ if( maIter < maEnd )
+ maIter++;
+ else
+ maIter--;
+ return true;
+ }
+
+private:
+ T maEnd;
+ T maIter;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/makefile.mk b/svx/source/table/makefile.mk
new file mode 100644
index 000000000000..1eaaef12aa02
--- /dev/null
+++ b/svx/source/table/makefile.mk
@@ -0,0 +1,80 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=svxpch
+PROJECTPCHSOURCE=$(PRJ)$/util$/svxpch
+
+PRJNAME=svx
+TARGET=table
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE;
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+LIB1TARGET= $(SLB)$/$(TARGET)-core.lib
+LIB1OBJFILES= \
+ $(SLO)$/propertyset.obj\
+ $(SLO)$/cell.obj\
+ $(SLO)$/cellrange.obj\
+ $(SLO)$/cellcursor.obj\
+ $(SLO)$/tablerow.obj\
+ $(SLO)$/tablerows.obj\
+ $(SLO)$/tablecolumn.obj\
+ $(SLO)$/tablecolumns.obj\
+ $(SLO)$/tablemodel.obj\
+ $(SLO)$/svdotable.obj\
+ $(SLO)$/viewcontactoftableobj.obj\
+ $(SLO)$/tablelayouter.obj\
+ $(SLO)$/tablehandles.obj\
+ $(SLO)$/tablecontroller.obj\
+ $(SLO)$/tableundo.obj
+
+LIB2TARGET= $(SLB)$/$(TARGET).lib
+LIB2OBJFILES= \
+ $(SLO)$/celleditsource.obj \
+ $(SLO)$/tabledesign.obj \
+ $(SLO)$/accessibletableshape.obj \
+ $(SLO)$/accessiblecell.obj \
+ $(SLO)$/tablertfexporter.obj \
+ $(SLO)$/tablertfimporter.obj
+
+SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES)
+
+SRS1NAME=table
+SRC1FILES= table.src
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/table/propertyset.cxx b/svx/source/table/propertyset.cxx
new file mode 100644
index 000000000000..c3f643b05e46
--- /dev/null
+++ b/svx/source/table/propertyset.cxx
@@ -0,0 +1,262 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "propertyset.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+
+namespace comphelper {
+
+// -----------------------------------------------------------------------------
+// FastPropertySetInfo
+// -----------------------------------------------------------------------------
+
+FastPropertySetInfo::FastPropertySetInfo()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+FastPropertySetInfo::FastPropertySetInfo( const PropertyVector& rProps )
+{
+ addProperties( rProps );
+}
+
+// -----------------------------------------------------------------------------
+
+FastPropertySetInfo::~FastPropertySetInfo()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void FastPropertySetInfo::addProperty( const Property& rProperty )
+{
+ maProperties.push_back( rProperty );
+ maMap[ rProperty.Name ] = maProperties.size() - 1;
+}
+
+// -----------------------------------------------------------------------------
+
+void FastPropertySetInfo::addProperties( const PropertyVector& rProps )
+{
+ sal_uInt32 nIndex = maProperties.size();
+ sal_uInt32 nCount = rProps.size();
+ maProperties.resize( nIndex + nCount );
+ PropertyVector::const_iterator aIter( rProps.begin() );
+ while( nCount-- )
+ {
+ const Property& rProperty = (*aIter++);
+ maProperties[nIndex] = rProperty;
+ maMap[ rProperty.Name ] = nIndex++;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+const Property& FastPropertySetInfo::getProperty( const OUString& aName ) throw (UnknownPropertyException )
+{
+ PropertyMap::iterator aIter( maMap.find( aName ) );
+ if( aIter == maMap.end() )
+ throw UnknownPropertyException();
+ return maProperties[(*aIter).second];
+}
+
+// -----------------------------------------------------------------------------
+
+const Property* FastPropertySetInfo::hasProperty( const OUString& aName )
+{
+ PropertyMap::iterator aIter( maMap.find( aName ) );
+ if( aIter == maMap.end() )
+ return 0;
+ else
+ return &maProperties[(*aIter).second];
+}
+
+// -----------------------------------------------------------------------------
+// XPropertySetInfo
+// -----------------------------------------------------------------------------
+
+Sequence< Property > SAL_CALL FastPropertySetInfo::getProperties() throw (RuntimeException)
+{
+ return Sequence< Property >( &maProperties[0], maProperties.size() );
+}
+
+// -----------------------------------------------------------------------------
+
+Property SAL_CALL FastPropertySetInfo::getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException)
+{
+ return getProperty( aName );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL FastPropertySetInfo::hasPropertyByName( const OUString& aName ) throw (RuntimeException)
+{
+ return hasProperty( aName ) != 0 ? sal_True : sal_False;;
+}
+
+// -----------------------------------------------------------------------------
+// FastPropertySet
+// -----------------------------------------------------------------------------
+
+FastPropertySet::FastPropertySet( const rtl::Reference< FastPropertySetInfo >& xInfo )
+: mxInfo( xInfo )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+FastPropertySet::~FastPropertySet()
+{
+}
+
+// -----------------------------------------------------------------------------
+// XPropertySet
+// -----------------------------------------------------------------------------
+
+Reference< XPropertySetInfo > SAL_CALL FastPropertySet::getPropertySetInfo( ) throw (RuntimeException)
+{
+ return Reference< XPropertySetInfo >( mxInfo.get() );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL FastPropertySet::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ setFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle, aValue );
+}
+
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL FastPropertySet::getPropertyValue( const OUString& aPropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ return getFastPropertyValue( mxInfo->getProperty( aPropertyName ).Handle );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL FastPropertySet::addPropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL FastPropertySet::removePropertyChangeListener( const OUString&, const Reference< XPropertyChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL FastPropertySet::addVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL FastPropertySet::removeVetoableChangeListener( const OUString&, const Reference< XVetoableChangeListener >& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+// XMultiPropertySet
+// -----------------------------------------------------------------------------
+
+void SAL_CALL FastPropertySet::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) throw (PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ const OUString* pPropertyNames = aPropertyNames.getConstArray();
+ const Any* pValues = aValues.getConstArray();
+ sal_Int32 nCount = aPropertyNames.getLength();
+ if( nCount != aValues.getLength() )
+ throw IllegalArgumentException();
+
+ while( nCount-- )
+ {
+ const Property* pProperty = mxInfo->hasProperty( *pPropertyNames++ );
+ if( pProperty ) try
+ {
+ setFastPropertyValue( pProperty->Handle, *pValues );
+ }
+ catch( UnknownPropertyException& )
+ {
+ }
+ pValues++;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+Sequence< Any > SAL_CALL FastPropertySet::getPropertyValues( const Sequence< OUString >& aPropertyNames ) throw (RuntimeException)
+{
+ sal_Int32 nCount = aPropertyNames.getLength();
+ Sequence< Any > aValues( nCount );
+
+ const OUString* pPropertyNames = aPropertyNames.getConstArray();
+ Any* pValues = aValues.getArray();
+ while( nCount-- )
+ {
+ const Property* pProperty = mxInfo->hasProperty( *pPropertyNames++ );
+ if( pProperty ) try
+ {
+ *pValues = getFastPropertyValue( pProperty->Handle );
+ }
+ catch( UnknownPropertyException& )
+ {
+ }
+ pValues++;
+ }
+ return aValues;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL FastPropertySet::addPropertiesChangeListener( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& ) throw (RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL FastPropertySet::removePropertiesChangeListener( const Reference< XPropertiesChangeListener >& ) throw (RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL FastPropertySet::firePropertiesChangeEvent( const Sequence< OUString >&, const Reference< XPropertiesChangeListener >& ) throw (RuntimeException)
+{
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/propertyset.hxx b/svx/source/table/propertyset.hxx
new file mode 100644
index 000000000000..ae07d035ae7e
--- /dev/null
+++ b/svx/source/table/propertyset.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _COMPHELPER_PROPERTYSET_HXX_
+#define _COMPHELPER_PROPERTYSET_HXX_
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <rtl/ref.hxx>
+#include <functional>
+#include <hash_map>
+#include <vector>
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase3.hxx>
+
+namespace comphelper {
+
+// -----------------------------------------------------------------------------
+
+typedef std::vector< ::com::sun::star::beans::Property > PropertyVector;
+typedef std::hash_map< ::rtl::OUString, ::sal_uInt32, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > PropertyMap;
+
+// -----------------------------------------------------------------------------
+
+class FastPropertySetInfo : public ::cppu::WeakAggImplHelper1< ::com::sun::star::beans::XPropertySetInfo >
+{
+public:
+ FastPropertySetInfo();
+ FastPropertySetInfo( const PropertyVector& rProps );
+ virtual ~FastPropertySetInfo();
+
+ void addProperty( const ::com::sun::star::beans::Property& rProperty );
+ void addProperties( const PropertyVector& rProps );
+
+ const ::com::sun::star::beans::Property& getProperty( const ::rtl::OUString& aName ) throw (::com::sun::star::beans::UnknownPropertyException );
+ const ::com::sun::star::beans::Property* hasProperty( const ::rtl::OUString& aName );
+
+ // XPropertySetInfo
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName( const ::rtl::OUString& aName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& Name ) throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ PropertyVector maProperties;
+ PropertyMap maMap;
+};
+
+// -----------------------------------------------------------------------------
+
+class FastPropertySet : public ::cppu::WeakAggImplHelper3< ::com::sun::star::beans::XPropertySet, ::com::sun::star::beans::XMultiPropertySet, ::com::sun::star::beans::XFastPropertySet >
+{
+public:
+ FastPropertySet( const rtl::Reference< FastPropertySetInfo >& xInfo );
+ virtual ~FastPropertySet();
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XMultiPropertySet
+// virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XFastPropertySet
+ virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) = 0;
+ virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) = 0;
+
+private:
+ rtl::Reference< FastPropertySetInfo > mxInfo;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
new file mode 100644
index 000000000000..d04e35d146a6
--- /dev/null
+++ b/svx/source/table/svdotable.cxx
@@ -0,0 +1,2823 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define ITEMID_BOX SDRATTR_TABLE_BORDER
+#define ITEMID_BOXINFO SDRATTR_TABLE_BORDER_INNER
+
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+#include <vcl/canvastools.hxx>
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <svl/style.hxx>
+#include "editeng/editstat.hxx"
+#include "editeng/outlobj.hxx"
+#include "svx/svdview.hxx"
+#include "svx/sdr/properties/textproperties.hxx"
+#include "svx/svdotable.hxx"
+#include "svx/svdhdl.hxx"
+#include "viewcontactoftableobj.hxx"
+#include "svx/svdoutl.hxx"
+#include "svx/svddrag.hxx"
+#include "svx/svdpagv.hxx"
+#include "tablemodel.hxx"
+#include "cell.hxx"
+#include "svx/xflclit.hxx"
+#include "tablelayouter.hxx"
+#include "svx/svdetc.hxx"
+#include "tablehandles.hxx"
+#include "editeng/boxitem.hxx"
+#include "svx/framelink.hxx"
+#include "svx/sdr/table/tabledesign.hxx"
+#include "svx/svdundo.hxx"
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+#include "editeng/writingmodeitem.hxx"
+#include "editeng/frmdiritem.hxx"
+#include "svx/xflhtit.hxx"
+#include "svx/xflftrit.hxx"
+#include "svx/xfltrit.hxx"
+
+// -----------------------------------------------------------------------------
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::XInterface;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::container::XIndexAccess;
+using ::com::sun::star::style::XStyle;
+using ::com::sun::star::table::XTableRows;
+using ::com::sun::star::table::XTableColumns;
+using ::com::sun::star::table::XTable;
+using ::com::sun::star::beans::XPropertySet;
+using ::com::sun::star::util::XModifyBroadcaster;
+using sdr::properties::TextProperties;
+using sdr::properties::BaseProperties;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::style;
+
+namespace sdr { namespace table {
+
+class TableProperties : public TextProperties
+{
+protected:
+ // create a new itemset
+ SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& rPool);
+
+public:
+ // basic constructor
+ TableProperties(SdrObject& rObj );
+
+ // constructor for copying, but using new object
+ TableProperties(const TableProperties& rProps, SdrObject& rObj );
+
+ // destructor
+ ~TableProperties();
+
+ // Clone() operator, normally just calls the local copy constructor
+ BaseProperties& Clone(SdrObject& rObj) const;
+
+ virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem);
+};
+
+TableProperties::TableProperties(SdrObject& rObj)
+: TextProperties(rObj)
+{
+}
+
+TableProperties::TableProperties(const TableProperties& rProps, SdrObject& rObj)
+: TextProperties(rProps, rObj)
+{
+}
+
+TableProperties::~TableProperties()
+{
+}
+
+BaseProperties& TableProperties::Clone(SdrObject& rObj) const
+{
+ return *(new TableProperties(*this, rObj));
+}
+
+void TableProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
+{
+ if( nWhich == SDRATTR_TEXTDIRECTION )
+ AttributeProperties::ItemChange( nWhich, pNewItem );
+ else
+ TextProperties::ItemChange( nWhich, pNewItem );
+}
+
+// create a new itemset
+SfxItemSet& TableProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
+{
+ return *(new SfxItemSet(rPool,
+
+ // range from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+
+ // range for SdrTableObj
+ SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
+
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+
+ // end
+ 0, 0));
+}
+
+class TableObjectGeoData : public SdrTextObjGeoData
+{
+public:
+ Rectangle maLogicRect;
+};
+
+//------------------------------------------------------------------------
+// TableStyleSettings
+//------------------------------------------------------------------------
+
+TableStyleSettings::TableStyleSettings()
+: mbUseFirstRow(true)
+, mbUseLastRow(false)
+, mbUseFirstColumn(false)
+, mbUseLastColumn(false)
+, mbUseRowBanding(true)
+, mbUseColumnBanding(false)
+{
+}
+
+TableStyleSettings::TableStyleSettings( const TableStyleSettings& rStyle )
+{
+ (*this) = rStyle;
+}
+
+TableStyleSettings& TableStyleSettings::operator=(const TableStyleSettings& rStyle)
+{
+ mbUseFirstRow = rStyle.mbUseFirstRow;
+ mbUseLastRow = rStyle.mbUseLastRow;
+ mbUseFirstColumn = rStyle.mbUseFirstColumn;
+ mbUseLastColumn = rStyle.mbUseLastColumn;
+ mbUseRowBanding = rStyle.mbUseRowBanding;
+ mbUseColumnBanding = rStyle.mbUseColumnBanding;
+ return *this;
+}
+
+bool TableStyleSettings::operator==( const TableStyleSettings& rStyle ) const
+{
+ return
+ (mbUseFirstRow == rStyle.mbUseFirstRow) &&
+ (mbUseLastRow == rStyle.mbUseLastRow) &&
+ (mbUseFirstColumn == rStyle.mbUseFirstColumn) &&
+ (mbUseLastColumn == rStyle.mbUseLastColumn) &&
+ (mbUseRowBanding == rStyle.mbUseRowBanding) &&
+ (mbUseColumnBanding == rStyle.mbUseColumnBanding);
+}
+
+// -----------------------------------------------------------------------------
+
+class SdrTableObjImpl : public TableDesignUser, public ::cppu::WeakImplHelper1< ::com::sun::star::util::XModifyListener >
+{
+public:
+ CellRef mxActiveCell;
+ TableModelRef mxTable;
+ SdrTableObj* mpTableObj;
+ TableLayouter* mpLayouter;
+ CellPos maEditPos;
+ TableStyleSettings maTableStyle;
+ Reference< XIndexAccess > mxTableStyle;
+ bool mbModifyPending;
+// sal_Int32 mnSavedEditRowHeight;
+
+ void SetModel(SdrModel* pOldModel, SdrModel* pNewModel);
+
+ CellRef getCell( const CellPos& rPos ) const;
+ void LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHeight );
+
+ bool ApplyCellStyles();
+ void UpdateCells( Rectangle& rArea );
+
+ SdrTableObjImpl();
+ virtual ~SdrTableObjImpl();
+
+ void init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 nRows );
+ void dispose();
+
+ sal_Int32 getColumnCount() const;
+ sal_Int32 getRowCount() const;
+
+ void DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset );
+
+ const SfxPoolItem* GetCellItem( const CellPos& rPos, sal_uInt16 nWhich ) const;
+// void GetBorderLines( const CellPos& rPos, const SvxBorderLine** ppLeft, const SvxBorderLine** ppTop, const SvxBorderLine** ppRight, const SvxBorderLine** ppBottom ) const;
+
+ void operator=( const SdrTableObjImpl& rSource );
+
+ // XModifyListener
+ virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ void update();
+
+ void connectTableStyle();
+ void disconnectTableStyle();
+ virtual bool isInUse();
+
+ bool UpdateWritingMode();
+};
+
+// -----------------------------------------------------------------------------
+
+SdrTableObjImpl::SdrTableObjImpl()
+: mpTableObj( 0 )
+, mpLayouter( 0 )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SdrTableObjImpl::~SdrTableObjImpl()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrTableObjImpl::init( SdrTableObj* pTable, sal_Int32 nColumns, sal_Int32 nRows )
+{
+ mpTableObj = pTable;
+ mxTable = new TableModel( pTable );
+ mxTable->init( nColumns, nRows );
+ mpLayouter = new TableLayouter( mxTable );
+ Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
+ mxTable->addModifyListener( xListener );
+ UpdateWritingMode();
+ LayoutTable( mpTableObj->aRect, true, true );
+ mpTableObj->maLogicRect = mpTableObj->aRect;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrTableObjImpl::operator=( const SdrTableObjImpl& rSource )
+{
+ if( mpLayouter )
+ {
+ delete mpLayouter;
+ mpLayouter = 0;
+ }
+
+ if( mxTable.is() )
+ {
+ Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
+ mxTable->removeModifyListener( xListener );
+ mxTable->dispose();
+ mxTable.clear();
+ }
+
+ maTableStyle = rSource.maTableStyle;
+
+ mxTable = new TableModel( mpTableObj, rSource.mxTable );
+ mpLayouter = new TableLayouter( mxTable );
+ Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
+ mxTable->addModifyListener( xListener );
+ mxTableStyle = rSource.mxTableStyle;
+ UpdateWritingMode();
+ ApplyCellStyles();
+ mpTableObj->aRect = mpTableObj->maLogicRect;
+ LayoutTable( mpTableObj->aRect, false, false );
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrTableObjImpl::SetModel(SdrModel* /*pOldModel*/, SdrModel* pNewModel)
+{
+ // try to find new table style
+
+ Reference< XIndexAccess > xNewTableStyle;
+ if( mxTableStyle.is() ) try
+ {
+ const OUString sStyleName( Reference< XNamed >( mxTableStyle, UNO_QUERY_THROW )->getName() );
+
+ Reference< XStyleFamiliesSupplier > xSFS( pNewModel->getUnoModel(), UNO_QUERY_THROW );
+ Reference< XNameAccess > xFamilyNameAccess( xSFS->getStyleFamilies(), UNO_QUERY_THROW );
+ const rtl::OUString sFamilyName( RTL_CONSTASCII_USTRINGPARAM( "table" ) );
+ Reference< XNameAccess > xTableFamilyAccess( xFamilyNameAccess->getByName( sFamilyName ), UNO_QUERY_THROW );
+
+ if( xTableFamilyAccess->hasByName( sStyleName ) )
+ {
+ // found table style with the same name
+ xTableFamilyAccess->getByName( sStyleName ) >>= xNewTableStyle;
+ }
+ else
+ {
+ // copy or?
+ Reference< XIndexAccess > xIndexAccess( xTableFamilyAccess, UNO_QUERY_THROW );
+ xIndexAccess->getByIndex( 0 ) >>= xNewTableStyle;
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("svx::SdrTableObjImpl::SetModel(), exception caught!");
+ }
+
+ mxTableStyle = xNewTableStyle;
+
+ update();
+}
+
+// -----------------------------------------------------------------------------
+
+bool SdrTableObjImpl::ApplyCellStyles()
+{
+ if( !mxTable.is() || !mxTable.is() || !mxTableStyle.is() )
+ return false;
+
+ bool bChanges = false;
+
+ const sal_Int32 nColCount = getColumnCount();
+ const sal_Int32 nRowCount = getRowCount();
+
+ const TableStyleSettings& rStyle = maTableStyle;
+
+ CellPos aPos;
+ for( aPos.mnRow = 0; aPos.mnRow < nRowCount; ++aPos.mnRow )
+ {
+ const bool bFirstRow = (aPos.mnRow == 0) && rStyle.mbUseFirstRow;
+ const bool bLastRow = (aPos.mnRow == nRowCount-1) && rStyle.mbUseLastRow;
+
+ for( aPos.mnCol = 0; aPos.mnCol < nColCount; ++aPos.mnCol )
+ {
+ Reference< XStyle > xStyle;
+
+ // first and last row win first, if used and available
+ if( bFirstRow )
+ {
+ mxTableStyle->getByIndex(first_row_style) >>= xStyle;
+ }
+ else if( bLastRow )
+ {
+ mxTableStyle->getByIndex(last_row_style) >>= xStyle;
+ }
+
+ if( !xStyle.is() )
+ {
+ // next come first and last column, if used and available
+ if( rStyle.mbUseFirstColumn && (aPos.mnCol == 0) )
+ {
+ mxTableStyle->getByIndex(first_column_style) >>= xStyle;
+ }
+ else if( rStyle.mbUseLastColumn && (aPos.mnCol == nColCount-1) )
+ {
+ mxTableStyle->getByIndex(last_column_style) >>= xStyle;
+ }
+ }
+
+ if( !xStyle.is() && rStyle.mbUseRowBanding )
+ {
+ if( (aPos.mnRow & 1) == 0 )
+ {
+ mxTableStyle->getByIndex(even_rows_style) >>= xStyle;
+ }
+ else
+ {
+ mxTableStyle->getByIndex(odd_rows_style) >>= xStyle;
+ }
+ }
+
+ if( !xStyle.is() && rStyle.mbUseColumnBanding )
+ {
+ if( (aPos.mnCol & 1) == 0 )
+ {
+ mxTableStyle->getByIndex(even_columns_style) >>= xStyle;
+ }
+ else
+ {
+ mxTableStyle->getByIndex(odd_columns_style) >>= xStyle;
+ }
+ }
+
+ if( !xStyle.is() )
+ {
+ // use default cell style if non found yet
+ mxTableStyle->getByIndex(body_style) >>= xStyle;
+ }
+
+
+ if( xStyle.is() )
+ {
+ SfxUnoStyleSheet* pStyle = SfxUnoStyleSheet::getUnoStyleSheet(xStyle);
+
+ if( pStyle )
+ {
+ CellRef xCell( getCell( aPos ) );
+ if( xCell.is() && ( xCell->GetStyleSheet() != pStyle ) )
+ {
+ bChanges = true;
+ xCell->SetStyleSheet( pStyle, sal_True );
+ }
+ }
+ }
+ }
+ }
+
+ return bChanges;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrTableObjImpl::dispose()
+{
+ if( mxTable.is() )
+ mxTable->dispose();
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrTableObjImpl::DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset )
+{
+ if( (nEdge > 0) && mxTable.is()) try
+ {
+ const OUString sSize( RTL_CONSTASCII_USTRINGPARAM( "Size" ) );
+ nEdge--;
+ if( mbHorizontal )
+ {
+ if( (nEdge >= 0) && (nEdge < getRowCount()) )
+ {
+ sal_Int32 nHeigth = mpLayouter->getRowHeight( nEdge );
+ nHeigth += nOffset;
+ Reference< XIndexAccess > xRows( mxTable->getRows(), UNO_QUERY_THROW );
+ Reference< XPropertySet > xRowSet( xRows->getByIndex( nEdge ), UNO_QUERY_THROW );
+ xRowSet->setPropertyValue( sSize, Any( nHeigth ) );
+ }
+ }
+ else
+ {
+ if( (nEdge >= 0) && (nEdge < getColumnCount()) )
+ {
+ sal_Int32 nWidth = mpLayouter->getColumnWidth( nEdge );
+ nWidth += nOffset;
+
+ Reference< XIndexAccess > xCols( mxTable->getColumns(), UNO_QUERY_THROW );
+ Reference< XPropertySet > xColSet( xCols->getByIndex( nEdge ), UNO_QUERY_THROW );
+ xColSet->setPropertyValue( sSize, Any( nWidth ) );
+
+ if( nEdge > 0 && nEdge < mxTable->getColumnCount() )
+ {
+ const bool bRTL = mpLayouter->GetWritingMode() == WritingMode_RL_TB;
+
+ if( bRTL )
+ nEdge--;
+ else
+ nEdge++;
+
+ if( (bRTL && (nEdge >= 0)) || (!bRTL && (nEdge < mxTable->getColumnCount())) )
+ {
+ nWidth = mpLayouter->getColumnWidth( nEdge );
+ nWidth = std::max( (sal_Int32)(nWidth - nOffset), (sal_Int32)0 );
+
+ xColSet = Reference< XPropertySet >( xCols->getByIndex( nEdge ), UNO_QUERY_THROW );
+ xColSet->setPropertyValue( sSize, Any( nWidth ) );
+ }
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "svx::SdrTableObjImpl::DragEdge(), exception caught!" );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XModifyListener
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SdrTableObjImpl::modified( const ::com::sun::star::lang::EventObject& /*aEvent*/ ) throw (::com::sun::star::uno::RuntimeException)
+{
+ update();
+}
+
+void SdrTableObjImpl::update()
+{
+ // source can be the table model itself or the assigned table template
+ TableModelNotifyGuard aGuard( mxTable.get() );
+ if( mpTableObj )
+ {
+ if( (maEditPos.mnRow >= getRowCount()) || (maEditPos.mnCol >= getColumnCount()) || (getCell( maEditPos ) != mxActiveCell) )
+ {
+ if(maEditPos.mnRow >= getRowCount())
+ maEditPos.mnRow = getRowCount()-1;
+
+ if(maEditPos.mnCol >= getColumnCount())
+ maEditPos.mnCol = getColumnCount()-1;
+
+ mpTableObj->setActiveCell( maEditPos );
+ }
+
+ ApplyCellStyles();
+
+ mpTableObj->aRect = mpTableObj->maLogicRect;
+ LayoutTable( mpTableObj->aRect, false, false );
+
+ mpTableObj->SetRectsDirty();
+ mpTableObj->ActionChanged();
+ mpTableObj->BroadcastObjectChange();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrTableObjImpl::connectTableStyle()
+{
+ if( mxTableStyle.is() )
+ {
+ Reference< XModifyBroadcaster > xBroadcaster( mxTableStyle, UNO_QUERY );
+ if( xBroadcaster.is() )
+ {
+ Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
+ xBroadcaster->addModifyListener( xListener );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrTableObjImpl::disconnectTableStyle()
+{
+ if( mxTableStyle.is() )
+ {
+ Reference< XModifyBroadcaster > xBroadcaster( mxTableStyle, UNO_QUERY );
+ if( xBroadcaster.is() )
+ {
+ Reference< XModifyListener > xListener( static_cast< ::com::sun::star::util::XModifyListener* >(this) );
+ xBroadcaster->removeModifyListener( xListener );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+bool SdrTableObjImpl::isInUse()
+{
+ return mpTableObj && mpTableObj->IsInserted();
+}
+
+// -----------------------------------------------------------------------------
+// XEventListener
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SdrTableObjImpl::disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw (::com::sun::star::uno::RuntimeException)
+{
+ mxActiveCell.clear();
+ mxTable.clear();
+ if( mpLayouter )
+ {
+ delete mpLayouter;
+ mpLayouter = 0;
+ }
+ mpTableObj = 0;
+}
+
+// -----------------------------------------------------------------------------
+
+CellRef SdrTableObjImpl::getCell( const CellPos& rPos ) const
+{
+ CellRef xCell;
+ if( mxTable.is() ) try
+ {
+ xCell.set( dynamic_cast< Cell* >( mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "svx::SdrTableObjImpl::getCell(), exception caught!" );
+ }
+ return xCell;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SdrTableObjImpl::getColumnCount() const
+{
+ return mxTable.is() ? mxTable->getColumnCount() : 0;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SdrTableObjImpl::getRowCount() const
+{
+ return mxTable.is() ? mxTable->getRowCount() : 0;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrTableObjImpl::LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHeight )
+{
+ if( mpLayouter && mpTableObj->GetModel() )
+ {
+ TableModelNotifyGuard aGuard( mxTable.get() );
+ mpLayouter->LayoutTable( rArea, bFitWidth, bFitHeight );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+bool SdrTableObjImpl::UpdateWritingMode()
+{
+ if( mpTableObj && mpLayouter )
+ {
+ WritingMode eWritingMode = (WritingMode)static_cast< const SvxWritingModeItem& >( mpTableObj->GetObjectItem( SDRATTR_TEXTDIRECTION ) ).GetValue();
+
+ if( eWritingMode != WritingMode_TB_RL )
+ {
+ if( static_cast< const SvxFrameDirectionItem& >( mpTableObj->GetObjectItem( EE_PARA_WRITINGDIR ) ).GetValue() == FRMDIR_HORI_LEFT_TOP )
+ eWritingMode = WritingMode_LR_TB;
+ else
+ eWritingMode = WritingMode_RL_TB;
+ }
+
+ if( eWritingMode != mpLayouter->GetWritingMode() )
+ {
+ mpLayouter->SetWritingMode( eWritingMode );
+ return true;
+ }
+ }
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+
+void SdrTableObjImpl::UpdateCells( Rectangle& rArea )
+{
+ if( mpLayouter && mxTable.is() )
+ {
+ TableModelNotifyGuard aGuard( mxTable.get() );
+ mpLayouter->updateCells( rArea );
+ mxTable->setModified(sal_True);
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+const SfxPoolItem* SdrTableObjImpl::GetCellItem( const CellPos& rPos, sal_uInt16 nWhich ) const
+{
+ CellRef xCell( getCell( rPos ) );
+ if( xCell.is() )
+ return xCell->GetItemSet().GetItem( nWhich );
+ else
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+// BaseProperties section
+// -----------------------------------------------------------------------------
+
+sdr::properties::BaseProperties* SdrTableObj::CreateObjectSpecificProperties()
+{
+ return new TableProperties(*this);
+}
+
+// -----------------------------------------------------------------------------
+// DrawContact section
+// -----------------------------------------------------------------------------
+
+sdr::contact::ViewContact* SdrTableObj::CreateObjectSpecificViewContact()
+{
+ return new sdr::contact::ViewContactOfTableObj(*this);
+}
+
+// --------------------------------------------------------------------
+
+TYPEINIT1(SdrTableObj,SdrTextObj);
+
+// --------------------------------------------------------------------
+
+SdrTableObj::SdrTableObj(SdrModel* _pModel)
+{
+ pModel = _pModel;
+ init( 1, 1 );
+}
+
+// --------------------------------------------------------------------
+
+SdrTableObj::SdrTableObj(SdrModel* _pModel, const ::Rectangle& rNewRect, sal_Int32 nColumns, sal_Int32 nRows)
+: SdrTextObj( rNewRect )
+, maLogicRect( rNewRect )
+{
+ pModel = _pModel;
+
+ if( nColumns <= 0 )
+ nColumns = 1;
+
+ if( nRows <= 0 )
+ nRows = 1;
+
+ init( nColumns, nRows );
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::init( sal_Int32 nColumns, sal_Int32 nRows )
+{
+ bClosedObj = TRUE;
+
+ mpImpl = new SdrTableObjImpl;
+ mpImpl->acquire();
+ mpImpl->init( this, nColumns, nRows );
+}
+
+// --------------------------------------------------------------------
+
+SdrTableObj::~SdrTableObj()
+{
+ mpImpl->dispose();
+ mpImpl->release();
+}
+
+// --------------------------------------------------------------------
+// table stuff
+// --------------------------------------------------------------------
+
+Reference< XTable > SdrTableObj::getTable() const
+{
+ return Reference< XTable >( mpImpl->mxTable.get() );
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::isValid( const CellPos& rPos ) const
+{
+ return (rPos.mnCol >= 0) && (rPos.mnCol < mpImpl->getColumnCount()) && (rPos.mnRow >= 0) && (rPos.mnRow < mpImpl->getRowCount());
+}
+
+// --------------------------------------------------------------------
+
+CellPos SdrTableObj::getFirstCell() const
+{
+ return CellPos( 0,0 );
+}
+
+// --------------------------------------------------------------------
+
+CellPos SdrTableObj::getLastCell() const
+{
+ CellPos aPos;
+ if( mpImpl->mxTable.is() )
+ {
+ aPos.mnCol = mpImpl->getColumnCount()-1;
+ aPos.mnRow = mpImpl->getRowCount()-1;
+ }
+ return aPos;
+}
+
+// --------------------------------------------------------------------
+
+CellPos SdrTableObj::getLeftCell( const CellPos& rPos, bool bEdgeTravel ) const
+{
+ switch( GetWritingMode() )
+ {
+ default:
+ case WritingMode_LR_TB:
+ return getPreviousCell( rPos, bEdgeTravel );
+ case WritingMode_RL_TB:
+ return getNextCell( rPos, bEdgeTravel );
+ case WritingMode_TB_RL:
+ return getPreviousRow( rPos, bEdgeTravel );
+ }
+}
+
+// --------------------------------------------------------------------
+
+CellPos SdrTableObj::getRightCell( const CellPos& rPos, bool bEdgeTravel ) const
+{
+ switch( GetWritingMode() )
+ {
+ default:
+ case WritingMode_LR_TB:
+ return getNextCell( rPos, bEdgeTravel );
+ case WritingMode_RL_TB:
+ return getPreviousCell( rPos, bEdgeTravel );
+ case WritingMode_TB_RL:
+ return getNextRow( rPos, bEdgeTravel );
+ }
+}
+
+// --------------------------------------------------------------------
+
+CellPos SdrTableObj::getUpCell( const CellPos& rPos, bool bEdgeTravel ) const
+{
+ switch( GetWritingMode() )
+ {
+ default:
+ case WritingMode_LR_TB:
+ case WritingMode_RL_TB:
+ return getPreviousRow( rPos, bEdgeTravel );
+ case WritingMode_TB_RL:
+ return getPreviousCell( rPos, bEdgeTravel );
+ }
+}
+
+// --------------------------------------------------------------------
+
+CellPos SdrTableObj::getDownCell( const CellPos& rPos, bool bEdgeTravel ) const
+{
+ switch( GetWritingMode() )
+ {
+ default:
+ case WritingMode_LR_TB:
+ case WritingMode_RL_TB:
+ return getNextRow( rPos, bEdgeTravel );
+ case WritingMode_TB_RL:
+ return getNextCell( rPos, bEdgeTravel );
+ }
+}
+
+// --------------------------------------------------------------------
+
+CellPos SdrTableObj::getPreviousCell( const CellPos& rPos, bool bEdgeTravel ) const
+{
+ CellPos aPos( rPos );
+ if( mpImpl )
+ {
+ CellRef xCell( mpImpl->getCell( aPos ) );
+ if( xCell.is() && xCell->isMerged() )
+ {
+ sal_Int32 nTemp = 0;
+ findMergeOrigin( mpImpl->mxTable.get(), aPos.mnCol, aPos.mnRow, aPos.mnCol, nTemp );
+ }
+
+ if( aPos.mnCol > 0 )
+ {
+ --aPos.mnCol;
+ }
+
+ else if( bEdgeTravel && (aPos.mnRow > 0) )
+ {
+ aPos.mnCol = mpImpl->mxTable->getColumnCount()-1;
+ --aPos.mnRow;
+ }
+ }
+ return aPos;
+}
+
+// --------------------------------------------------------------------
+
+CellPos SdrTableObj::getNextCell( const CellPos& rPos, bool bEdgeTravel ) const
+{
+ CellPos aPos( rPos );
+ if( mpImpl )
+ {
+ CellRef xCell( mpImpl->getCell( aPos ) );
+ if( xCell.is() )
+ {
+ if( xCell->isMerged() )
+ {
+ findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, aPos.mnCol, aPos.mnRow );
+
+ xCell = mpImpl->getCell(aPos);
+
+ if( xCell.is() )
+ {
+ aPos.mnCol += xCell->getColumnSpan();
+ aPos.mnRow = rPos.mnRow;
+ }
+ }
+ else
+ {
+ aPos.mnCol += xCell->getColumnSpan();
+ }
+
+ if( aPos.mnCol < mpImpl->mxTable->getColumnCount() )
+ return aPos;
+
+ if( bEdgeTravel && ((aPos.mnRow + 1) < mpImpl->getRowCount()) )
+ {
+ aPos.mnCol = 0;
+ aPos.mnRow += 1;
+ return aPos;
+ }
+ }
+ }
+
+ // last cell reached, no traveling possible
+ return rPos;
+}
+
+// --------------------------------------------------------------------
+
+CellPos SdrTableObj::getPreviousRow( const CellPos& rPos, bool bEdgeTravel ) const
+{
+ CellPos aPos( rPos );
+ if( mpImpl )
+ {
+ CellRef xCell( mpImpl->getCell( aPos ) );
+ if( xCell.is() )
+ {
+ if( xCell->isMerged() )
+ {
+ sal_Int32 nTemp = 0;
+ findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, nTemp, aPos.mnRow );
+ }
+ }
+
+ if( aPos.mnRow > 0 )
+ {
+ --aPos.mnRow;
+ }
+ else if( bEdgeTravel && (aPos.mnCol > 0) )
+ {
+ aPos.mnRow = mpImpl->mxTable->getRowCount()-1;
+ --aPos.mnCol;
+ }
+ }
+ return aPos;
+}
+
+// --------------------------------------------------------------------
+
+CellPos SdrTableObj::getNextRow( const CellPos& rPos, bool bEdgeTravel ) const
+{
+ CellPos aPos( rPos );
+
+ if( mpImpl )
+ {
+ CellRef xCell( mpImpl->getCell( rPos ) );
+ if( xCell.is() )
+ {
+ if( xCell->isMerged() )
+ {
+ findMergeOrigin( mpImpl->mxTable, aPos.mnCol, aPos.mnRow, aPos.mnCol, aPos.mnRow );
+ xCell = mpImpl->getCell(aPos);
+ aPos.mnCol = rPos.mnCol;
+ }
+
+ if( xCell.is() )
+ aPos.mnRow += xCell->getRowSpan();
+
+ if( aPos.mnRow < mpImpl->mxTable->getRowCount() )
+ return aPos;
+
+ if( bEdgeTravel && (aPos.mnCol + 1) < mpImpl->mxTable->getColumnCount() )
+ {
+ aPos.mnRow = 0;
+ aPos.mnCol += 1;
+
+ while( aPos.mnCol < mpImpl->mxTable->getColumnCount() )
+ {
+ xCell = mpImpl->getCell( aPos );
+ if( xCell.is() && !xCell->isMerged() )
+ return aPos;
+ aPos.mnCol += 1;
+ }
+ }
+ }
+ }
+
+ // last position reached, no more traveling possible
+ return rPos;
+}
+
+// --------------------------------------------------------------------
+
+const TableStyleSettings& SdrTableObj::getTableStyleSettings() const
+{
+ if( mpImpl )
+ {
+ return mpImpl->maTableStyle;
+ }
+ else
+ {
+ static TableStyleSettings aTmp;
+ return aTmp;
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::setTableStyleSettings( const TableStyleSettings& rStyle )
+{
+ if( mpImpl )
+ {
+ mpImpl->maTableStyle = rStyle;
+ mpImpl->update();
+ }
+}
+
+// --------------------------------------------------------------------
+
+TableHitKind SdrTableObj::CheckTableHit( const Point& rPos, sal_Int32& rnX, sal_Int32& rnY, int nTol ) const
+{
+ if( !mpImpl || !mpImpl->mxTable.is() )
+ return SDRTABLEHIT_NONE;
+
+ rnX = 0;
+ rnY = 0;
+
+ const sal_Int32 nColCount = mpImpl->getColumnCount();
+ const sal_Int32 nRowCount = mpImpl->getRowCount();
+
+ sal_Int32 nX = rPos.X() + nTol - aRect.nLeft;
+ sal_Int32 nY = rPos.Y() + nTol - aRect.nTop;
+
+ if( (nX < 0) || (nX > (aRect.GetWidth() + nTol)) || (nY < 0) || (nY > (aRect.GetHeight() + nTol) ) )
+ return SDRTABLEHIT_NONE;
+
+ // get vertical edge number and check for a hit
+ const bool bRTL = GetWritingMode() == WritingMode_RL_TB;
+ bool bVrtHit = false;
+ if( nX >= 0 )
+ {
+ if( !bRTL )
+ {
+ while( rnX <= nColCount )
+ {
+ if( nX <= (2*nTol) )
+ {
+ bVrtHit = true;
+ break;
+ }
+
+ if( rnX == nColCount )
+ break;
+
+ nX -= mpImpl->mpLayouter->getColumnWidth( rnX );
+ if( nX < 0 )
+ break;
+ rnX++;
+ }
+ }
+ else
+ {
+ rnX = nColCount;
+ while( rnX >= 0 )
+ {
+ if( nX <= (2*nTol) )
+ {
+ bVrtHit = true;
+ break;
+ }
+
+ if( rnX == 0 )
+ break;
+
+ rnX--;
+ nX -= mpImpl->mpLayouter->getColumnWidth( rnX );
+ if( nX < 0 )
+ break;
+ }
+ }
+ }
+
+ // rnX is now the edge number left to the pointer, if it was hit bHrzHit is also true
+
+ // get vertical edge number and check for a hit
+ bool bHrzHit = false;
+ if( nY >= 0 )
+ {
+ while( rnY <= nRowCount )
+ {
+ if( nY <= (2*nTol) )
+ {
+ bHrzHit = true;
+ break;
+ }
+
+ if( rnY == nRowCount )
+ break;
+
+ nY -= mpImpl->mpLayouter->getRowHeight(rnY);
+ if( nY < 0 )
+ break;
+ rnY++;
+ }
+ }
+
+ // rnY is now the edge number above the pointer, if it was hit bVrtHit is also true
+
+ if( bVrtHit && mpImpl->mpLayouter->isEdgeVisible( rnX, rnY, false ) )
+ return SDRTABLEHIT_VERTICAL_BORDER;
+
+ if( bHrzHit && mpImpl->mpLayouter->isEdgeVisible( rnX, rnY, true ) )
+ return SDRTABLEHIT_HORIZONTAL_BORDER;
+
+ CellRef xCell( mpImpl->getCell( CellPos( rnX, rnY ) ) );
+ if( xCell.is() && xCell->isMerged() )
+ findMergeOrigin( mpImpl->mxTable.get(), rnX, rnY, rnX, rnY );
+
+ if( xCell.is() )
+ {
+ nX += mpImpl->mpLayouter->getColumnWidth( rnX );
+ if( nX < xCell->GetTextLeftDistance() )
+ return SDRTABLEHIT_CELL;
+ }
+
+ return SDRTABLEHIT_CELLTEXTAREA;
+}
+
+const SfxItemSet& SdrTableObj::GetActiveCellItemSet() const
+{
+ return getActiveCell()->GetItemSet();
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::InsertRows( sal_Int32 nIndex, sal_Int32 nCount /*= 1*/ )
+{
+ if( mpImpl->mxTable.is() ) try
+ {
+ Reference< XTableRows > xRows( mpImpl->mxTable->getRows(), UNO_QUERY_THROW );
+ xRows->insertByIndex( nIndex, nCount );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SdrTableObj::InsertRows(), exception caught!");
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::InsertColumns( sal_Int32 nIndex, sal_Int32 nCount /*= 1*/ )
+{
+ if( mpImpl->mxTable.is() ) try
+ {
+ Reference< XTableColumns > xColumns( mpImpl->mxTable->getColumns(), UNO_QUERY_THROW );
+ xColumns->insertByIndex( nIndex, nCount );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SdrTableObj::InsertColumns(), exception caught!");
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::DeleteRows( sal_Int32 nIndex, sal_Int32 nCount /*= 1*/ )
+{
+ if( mpImpl->mxTable.is() ) try
+ {
+ Reference< XTableRows > xRows( mpImpl->mxTable->getRows(), UNO_QUERY_THROW );
+ xRows->removeByIndex( nIndex, nCount );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SdrTableObj::DeleteRows(), exception caught!");
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::DeleteColumns( sal_Int32 nIndex, sal_Int32 nCount /*= 1*/ )
+{
+ if( mpImpl->mxTable.is() ) try
+ {
+ Reference< XTableColumns > xColumns( mpImpl->mxTable->getColumns(), UNO_QUERY_THROW );
+ xColumns->removeByIndex( nIndex, nCount );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SdrTableObj::DeleteColumns(), exception caught!");
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::setTableStyle( const Reference< XIndexAccess >& xTableStyle )
+{
+ if( mpImpl && (mpImpl->mxTableStyle != xTableStyle) )
+ {
+ mpImpl->disconnectTableStyle();
+ mpImpl->mxTableStyle = xTableStyle;
+ mpImpl->connectTableStyle();
+ mpImpl->update();
+ }
+}
+
+// --------------------------------------------------------------------
+
+const Reference< XIndexAccess >& SdrTableObj::getTableStyle() const
+{
+ if( mpImpl )
+ {
+ return mpImpl->mxTableStyle;
+ }
+ else
+ {
+ static Reference< XIndexAccess > aTmp;
+ return aTmp;
+ }
+}
+
+// --------------------------------------------------------------------
+// text stuff
+// --------------------------------------------------------------------
+
+/** returns the currently active text. */
+SdrText* SdrTableObj::getActiveText() const
+{
+ return dynamic_cast< SdrText* >( getActiveCell().get() );
+}
+
+// --------------------------------------------------------------------
+
+/** returns the nth available text. */
+SdrText* SdrTableObj::getText( sal_Int32 nIndex ) const
+{
+ if( mpImpl->mxTable.is() )
+ {
+ const sal_Int32 nColCount = mpImpl->getColumnCount();
+ if( nColCount )
+ {
+ CellPos aPos( nIndex % nColCount, nIndex / nColCount );
+
+ CellRef xCell( mpImpl->getCell( aPos ) );
+ return dynamic_cast< SdrText* >( xCell.get() );
+ }
+ }
+ return 0;
+}
+
+// --------------------------------------------------------------------
+
+/** returns the number of texts available for this object. */
+sal_Int32 SdrTableObj::getTextCount() const
+{
+ if( mpImpl->mxTable.is() )
+ {
+ const sal_Int32 nColCount = mpImpl->getColumnCount();
+ const sal_Int32 nRowCount = mpImpl->getRowCount();
+
+ return nColCount * nRowCount;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+// --------------------------------------------------------------------
+
+/** changes the current active text */
+void SdrTableObj::setActiveText( sal_Int32 nIndex )
+{
+ if( mpImpl && mpImpl->mxTable.is() )
+ {
+ const sal_Int32 nColCount = mpImpl->mxTable->getColumnCount();
+ if( nColCount )
+ {
+ CellPos aPos( nIndex % nColCount, nIndex / nColCount );
+ if( isValid( aPos ) )
+ setActiveCell( aPos );
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+/** returns the index of the text that contains the given point or -1 */
+sal_Int32 SdrTableObj::CheckTextHit(const Point& rPnt) const
+{
+ if( mpImpl && mpImpl->mxTable.is() )
+ {
+ CellPos aPos;
+ if( CheckTableHit( rPnt, aPos.mnCol, aPos.mnRow, 0 ) == SDRTABLEHIT_CELLTEXTAREA )
+ return aPos.mnRow * mpImpl->mxTable->getColumnCount() + aPos.mnCol;
+ }
+
+ return 0;
+}
+
+// --------------------------------------------------------------------
+
+SdrOutliner* SdrTableObj::GetCellTextEditOutliner( const Cell& rCell ) const
+{
+ if( mpImpl && (mpImpl->getCell( mpImpl->maEditPos ).get() == &rCell) )
+ return pEdtOutl;
+ else
+ return 0;
+}
+
+
+// --------------------------------------------------------------------
+
+const TableLayouter& SdrTableObj::getTableLayouter() const
+{
+ OSL_ENSURE(mpImpl && mpImpl->mpLayouter, "getTableLayouter() error: no mpImpl or mpLayouter (!)");
+ return *(mpImpl->mpLayouter);
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::FitFrameToTextSize()
+{
+ // todo
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::IsAutoGrowHeight() const
+{
+ return true;
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::IsAutoGrowWidth() const
+{
+ return true;
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::HasText() const
+{
+ return true;
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::IsTextEditActive( const CellPos& rPos )
+{
+ return pEdtOutl && mpImpl && (rPos == mpImpl->maEditPos);
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::onEditOutlinerStatusEvent( EditStatus* pEditStatus )
+{
+ if( (pEditStatus->GetStatusWord() & EE_STAT_TEXTHEIGHTCHANGED) && mpImpl && mpImpl->mpLayouter )
+ {
+ Rectangle aRect0( aRect );
+ aRect = maLogicRect;
+// mpImpl->mpLayouter->setRowHeight( mpImpl->maEditPos.mnRow, mpImpl->mnSavedEditRowHeight );
+ mpImpl->LayoutTable( aRect, false, false );
+ SetRectsDirty();
+ ActionChanged();
+ BroadcastObjectChange();
+ if( aRect0 != aRect )
+ SendUserCall(SDRUSERCALL_RESIZE,aRect0);
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
+{
+ rInfo.bResizeFreeAllowed=TRUE;
+ rInfo.bResizePropAllowed=TRUE;
+ rInfo.bRotateFreeAllowed=FALSE;
+ rInfo.bRotate90Allowed =FALSE;
+ rInfo.bMirrorFreeAllowed=FALSE;
+ rInfo.bMirror45Allowed =FALSE;
+ rInfo.bMirror90Allowed =FALSE;
+
+ // allow transparence
+ rInfo.bTransparenceAllowed = TRUE;
+
+ // gradient depends on fillstyle
+ XFillStyle eFillStyle = ((XFillStyleItem&)(GetObjectItem(XATTR_FILLSTYLE))).GetValue();
+ rInfo.bGradientAllowed = (eFillStyle == XFILL_GRADIENT);
+ rInfo.bShearAllowed =FALSE;
+ rInfo.bEdgeRadiusAllowed=FALSE;
+ rInfo.bCanConvToPath =FALSE;
+ rInfo.bCanConvToPoly =FALSE;
+ rInfo.bCanConvToPathLineToArea=FALSE;
+ rInfo.bCanConvToPolyLineToArea=FALSE;
+ rInfo.bCanConvToContour = FALSE;
+}
+
+// --------------------------------------------------------------------
+
+UINT16 SdrTableObj::GetObjIdentifier() const
+{
+ return static_cast<UINT16>(OBJ_TABLE);
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::SetPage(SdrPage* pNewPage)
+{
+ SdrTextObj::SetPage(pNewPage);
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::SetModel(SdrModel* pNewModel)
+{
+ SdrModel* pOldModel = GetModel();
+ if( pNewModel != pOldModel )
+ {
+ SdrTextObj::SetModel(pNewModel);
+
+ if( mpImpl )
+ {
+ mpImpl->SetModel( pOldModel, pNewModel );
+
+ if( !maLogicRect.IsEmpty() )
+ {
+ aRect = maLogicRect;
+ mpImpl->LayoutTable( aRect, false, false );
+ }
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::TakeTextRect( SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText, Rectangle* pAnchorRect, BOOL bLineWidth ) const
+{
+ if( mpImpl )
+ TakeTextRect( mpImpl->maEditPos, rOutliner, rTextRect, bNoEditText, pAnchorRect, bLineWidth );
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, Rectangle& rTextRect, bool bNoEditText, Rectangle* pAnchorRect, BOOL /*bLineWidth*/ ) const
+{
+ if( !mpImpl )
+ return;
+
+ CellRef xCell( mpImpl->getCell( rPos ) );
+ if( !xCell.is() )
+ return;
+
+ Rectangle aAnkRect;
+ TakeTextAnchorRect( rPos, aAnkRect );
+
+ SdrTextVertAdjust eVAdj=xCell->GetTextVerticalAdjust();
+// SdrTextHorzAdjust eHAdj=xCell->GetTextHorizontalAdjust();
+
+ ULONG nStat0=rOutliner.GetControlWord();
+ Size aNullSize;
+ nStat0 |= EE_CNTRL_AUTOPAGESIZE;
+ rOutliner.SetControlWord(nStat0);
+ rOutliner.SetMinAutoPaperSize(aNullSize);
+ rOutliner.SetMaxAutoPaperSize(aAnkRect.GetSize());
+ rOutliner.SetPaperSize(aAnkRect.GetSize());
+
+ // #103516# New try with _BLOCK for hor and ver after completely
+ // supporting full width for vertical text.
+// if( SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting())
+// {
+ rOutliner.SetMinAutoPaperSize(Size(aAnkRect.GetWidth(), 0));
+// }
+// else if(SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting())
+// {
+// rOutliner.SetMinAutoPaperSize(Size(0, aAnkRect.GetHeight()));
+// }
+
+ // ---
+
+ // set text at outliner, maybe from edit outliner
+ OutlinerParaObject* pPara= xCell->GetOutlinerParaObject();
+ if (pEdtOutl && !bNoEditText && mpImpl->mxActiveCell == xCell )
+ pPara=pEdtOutl->CreateParaObject();
+
+ if (pPara)
+ {
+ const bool bHitTest = pModel && (&pModel->GetHitTestOutliner() == &rOutliner);
+
+ const SdrTextObj* pTestObj = rOutliner.GetTextObj();
+ if( !pTestObj || !bHitTest || (pTestObj != this) || (pTestObj->GetOutlinerParaObject() != xCell->GetOutlinerParaObject()) )
+ {
+ if( bHitTest ) // #i33696# take back fix #i27510#
+ rOutliner.SetTextObj( this );
+
+ rOutliner.SetUpdateMode(TRUE);
+ rOutliner.SetText(*pPara);
+ }
+ }
+ else
+ {
+ rOutliner.SetTextObj( NULL );
+ }
+
+ if (pEdtOutl && !bNoEditText && pPara && mpImpl->mxActiveCell == xCell )
+ delete pPara;
+
+ rOutliner.SetUpdateMode(TRUE);
+ rOutliner.SetControlWord(nStat0);
+
+ Point aTextPos(aAnkRect.TopLeft());
+ Size aTextSiz(rOutliner.GetPaperSize());
+/*
+ if (eHAdj==SDRTEXTHORZADJUST_CENTER || eHAdj==SDRTEXTHORZADJUST_RIGHT)
+ {
+ long nFreeWdt=aAnkRect.GetWidth()-aTextSiz.Width();
+ if (eHAdj==SDRTEXTHORZADJUST_CENTER)
+ aTextPos.X()+=nFreeWdt/2;
+ if (eHAdj==SDRTEXTHORZADJUST_RIGHT)
+ aTextPos.X()+=nFreeWdt;
+ }
+*/
+ if (eVAdj==SDRTEXTVERTADJUST_CENTER || eVAdj==SDRTEXTVERTADJUST_BOTTOM)
+ {
+ long nFreeHgt=aAnkRect.GetHeight()-aTextSiz.Height();
+ if (eVAdj==SDRTEXTVERTADJUST_CENTER)
+ aTextPos.Y()+=nFreeHgt/2;
+ if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
+ aTextPos.Y()+=nFreeHgt;
+ }
+
+ if (pAnchorRect)
+ *pAnchorRect=aAnkRect;
+
+ rTextRect=Rectangle(aTextPos,aTextSiz);
+}
+
+// --------------------------------------------------------------------
+
+const CellRef& SdrTableObj::getActiveCell() const
+{
+ if( mpImpl )
+ {
+ if( !mpImpl->mxActiveCell.is() )
+ {
+ CellPos aPos;
+ const_cast< SdrTableObj* >(this)->setActiveCell( aPos );
+ }
+ return mpImpl->mxActiveCell;
+ }
+ else
+ {
+ static CellRef xCell;
+ return xCell;
+ }
+}
+
+// --------------------------------------------------------------------
+
+sal_Int32 SdrTableObj::getRowCount() const
+{
+ return mpImpl ? mpImpl->getRowCount() : 0;
+}
+
+// --------------------------------------------------------------------
+
+sal_Int32 SdrTableObj::getColumnCount() const
+{
+ return mpImpl ? mpImpl->getColumnCount() : 0;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::setActiveCell( const CellPos& rPos )
+{
+ if( mpImpl && mpImpl->mxTable.is() ) try
+ {
+ mpImpl->mxActiveCell.set( dynamic_cast< Cell* >( mpImpl->mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) );
+ if( mpImpl->mxActiveCell.is() && mpImpl->mxActiveCell->isMerged() )
+ {
+ CellPos aOrigin;
+ findMergeOrigin( mpImpl->mxTable.get(), rPos.mnCol, rPos.mnRow, aOrigin.mnCol, aOrigin.mnRow );
+ mpImpl->mxActiveCell.set( dynamic_cast< Cell* >( mpImpl->mxTable->getCellByPosition( aOrigin.mnCol, aOrigin.mnRow ).get() ) );
+ mpImpl->maEditPos = aOrigin;
+ }
+ else
+ {
+ mpImpl->maEditPos = rPos;
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SdrTableObj::setActiveCell(), exception caught!");
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::getActiveCellPos( CellPos& rPos ) const
+{
+ rPos = mpImpl->maEditPos;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::getCellBounds( const CellPos& rPos, ::Rectangle& rCellRect )
+{
+ if( mpImpl )
+ {
+ CellRef xCell( mpImpl->getCell( rPos ) );
+ if( xCell.is() )
+ rCellRect = xCell->getCellRect();
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::TakeTextAnchorRect(Rectangle& rAnchorRect) const
+{
+ if( mpImpl )
+ TakeTextAnchorRect( mpImpl->maEditPos, rAnchorRect );
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::TakeTextAnchorRect( const CellPos& rPos, Rectangle& rAnchorRect ) const
+{
+ Rectangle aAnkRect(aRect);
+
+ if( mpImpl )
+ {
+ CellRef xCell( mpImpl->getCell( rPos ) );
+ if( xCell.is() )
+ xCell->TakeTextAnchorRect( aAnkRect );
+ }
+
+ ImpJustifyRect(aAnkRect);
+ rAnchorRect=aAnkRect;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::TakeTextEditArea(Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin) const
+{
+ if( mpImpl )
+ TakeTextEditArea( mpImpl->maEditPos, pPaperMin, pPaperMax, pViewInit, pViewMin );
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::TakeTextEditArea( const CellPos& rPos, Size* pPaperMin, Size* pPaperMax, Rectangle* pViewInit, Rectangle* pViewMin ) const
+{
+ Size aPaperMin,aPaperMax;
+ Rectangle aViewInit;
+ TakeTextAnchorRect( rPos, aViewInit );
+
+ Size aAnkSiz(aViewInit.GetSize());
+ aAnkSiz.Width()--; aAnkSiz.Height()--; // weil GetSize() ein draufaddiert
+
+ Size aMaxSiz(aAnkSiz.Width(),1000000);
+ if (pModel!=NULL)
+ {
+ Size aTmpSiz(pModel->GetMaxObjSize());
+ if (aTmpSiz.Height()!=0)
+ aMaxSiz.Height()=aTmpSiz.Height();
+ }
+
+ CellRef xCell( mpImpl->getCell( rPos ) );
+ SdrTextVertAdjust eVAdj = xCell.is() ? xCell->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_TOP;
+// SdrTextHorzAdjust eHAdj = xCell.is() ? xCell->GetTextHorizontalAdjust() : SDRTEXTHORZADJUST_LEFT;
+
+ aPaperMax=aMaxSiz;
+
+// if((SDRTEXTHORZADJUST_BLOCK == eHAdj && !IsVerticalWriting()) || (SDRTEXTVERTADJUST_BLOCK == eVAdj && IsVerticalWriting()))
+ aPaperMin.Width() = aAnkSiz.Width();
+
+ if (pViewMin!=NULL)
+ {
+ *pViewMin=aViewInit;
+/*
+ long nXFree=aAnkSiz.Width()-aPaperMin.Width();
+
+ if (eHAdj==SDRTEXTHORZADJUST_LEFT)
+ {
+ pViewMin->Right()-=nXFree;
+ }
+ else if (eHAdj==SDRTEXTHORZADJUST_RIGHT)
+ {
+ pViewMin->Left()+=nXFree;
+ }
+ else
+ {
+ pViewMin->Left()+=nXFree/2;
+ pViewMin->Right()=pViewMin->Left()+aPaperMin.Width();
+ }
+*/
+ long nYFree=aAnkSiz.Height()-aPaperMin.Height();
+
+ if (eVAdj==SDRTEXTVERTADJUST_TOP)
+ {
+ pViewMin->Bottom()-=nYFree;
+ }
+ else if (eVAdj==SDRTEXTVERTADJUST_BOTTOM)
+ {
+ pViewMin->Top()+=nYFree;
+ }
+ else
+ {
+ pViewMin->Top()+=nYFree/2;
+ pViewMin->Bottom()=pViewMin->Top()+aPaperMin.Height();
+ }
+ }
+
+
+ if(IsVerticalWriting())
+ aPaperMin.Width() = 0;
+ else
+ aPaperMin.Height() = 0;
+
+ if (pPaperMin!=NULL) *pPaperMin=aPaperMin;
+ if (pPaperMax!=NULL) *pPaperMax=aPaperMax;
+ if (pViewInit!=NULL) *pViewInit=aViewInit;
+}
+
+// --------------------------------------------------------------------
+
+USHORT SdrTableObj::GetOutlinerViewAnchorMode() const
+{
+ EVAnchorMode eRet=ANCHOR_TOP_LEFT;
+ CellRef xCell( getActiveCell() );
+ if( xCell.is() )
+ {
+ SdrTextVertAdjust eV=xCell->GetTextVerticalAdjust();
+// SdrTextHorzAdjust eH=xCell->GetTextHorizontalAdjust();
+
+// if (eH==SDRTEXTHORZADJUST_LEFT)
+ {
+ if (eV==SDRTEXTVERTADJUST_TOP)
+ {
+ eRet=ANCHOR_TOP_LEFT;
+ }
+ else if (eV==SDRTEXTVERTADJUST_BOTTOM)
+ {
+ eRet=ANCHOR_BOTTOM_LEFT;
+ }
+ else
+ {
+ eRet=ANCHOR_VCENTER_LEFT;
+ }
+ }
+/*
+ else if (eH==SDRTEXTHORZADJUST_RIGHT)
+ {
+ if (eV==SDRTEXTVERTADJUST_TOP)
+ {
+ eRet=ANCHOR_TOP_RIGHT;
+ }
+ else if (eV==SDRTEXTVERTADJUST_BOTTOM)
+ {
+ eRet=ANCHOR_BOTTOM_RIGHT;
+ }
+ else
+ {
+ eRet=ANCHOR_VCENTER_RIGHT;
+ }
+ }
+ else
+ {
+ if (eV==SDRTEXTVERTADJUST_TOP)
+ {
+ eRet=ANCHOR_TOP_HCENTER;
+ }
+ else if (eV==SDRTEXTVERTADJUST_BOTTOM)
+ {
+ eRet=ANCHOR_BOTTOM_HCENTER;
+ }
+ else
+ {
+ eRet=ANCHOR_VCENTER_HCENTER;
+ }
+ }
+*/
+ }
+ return (USHORT)eRet;
+}
+
+// --------------------------------------------------------------------
+
+OutlinerParaObject* SdrTableObj::GetEditOutlinerParaObject() const
+{
+ return SdrTextObj::GetEditOutlinerParaObject();
+}
+
+// --------------------------------------------------------------------
+
+SdrOutliner* SdrTableObj::GetCellTextEditOutliner( const CellPos& rPos ) const
+{
+ if( pEdtOutl && mpImpl && (mpImpl->maEditPos == rPos) )
+ return pEdtOutl;
+ else
+ return 0;
+}
+
+// --------------------------------------------------------------------
+
+struct ImplTableShadowPaintInfo
+{
+ Color maShadowColor;
+ sal_uInt32 mnXDistance;
+ sal_uInt32 mnYDistance;
+ sal_uInt16 mnShadowTransparence;
+
+ ImplTableShadowPaintInfo( const SfxItemSet& rSet )
+ {
+ const SdrShadowColorItem& rShadColItem = ((const SdrShadowColorItem&)(rSet.Get(SDRATTR_SHADOWCOLOR)));
+ maShadowColor = rShadColItem.GetColorValue();
+ mnShadowTransparence = ((const SdrShadowTransparenceItem&)(rSet.Get(SDRATTR_SHADOWTRANSPARENCE))).GetValue();
+
+ mnXDistance = ((SdrShadowXDistItem&)(rSet.Get(SDRATTR_SHADOWXDIST))).GetValue();
+ mnYDistance = ((SdrShadowYDistItem&)(rSet.Get(SDRATTR_SHADOWYDIST))).GetValue();
+ }
+};
+
+// --------------------------------------------------------------------
+
+void lcl_VertLineEnds( OutputDevice& rDev, const Point& rTop, const Point& rBottom,
+ const Color& rColor, long nXOffs, long nWidth,
+ const svx::frame::Style& rTopLine, const svx::frame::Style& rBottomLine )
+{
+ rDev.SetLineColor(rColor); // PEN_NULL ???
+ rDev.SetFillColor(rColor);
+
+ // Position oben/unten muss unabhaengig von der Liniendicke sein,
+ // damit der Winkel stimmt (oder X-Position auch anpassen)
+ long nTopPos = rTop.Y();
+ long nBotPos = rBottom.Y();
+
+ long nTopLeft = rTop.X() + nXOffs;
+ long nTopRight = nTopLeft + nWidth - 1;
+
+ long nBotLeft = rBottom.X() + nXOffs;
+ long nBotRight = nBotLeft + nWidth - 1;
+
+ // oben abschliessen
+
+ if ( rTopLine.Prim() )
+ {
+ long nLineW = rTopLine.GetWidth();
+ if (nLineW >= 2)
+ {
+ Point aTriangle[3];
+ aTriangle[0] = Point( nTopLeft, nTopPos ); // wie aPoints[0]
+ aTriangle[1] = Point( nTopRight, nTopPos ); // wie aPoints[1]
+ aTriangle[2] = Point( rTop.X(), nTopPos - (nLineW - 1) / 2 );
+ Polygon aTriPoly( 3, aTriangle );
+ rDev.DrawPolygon( aTriPoly );
+ }
+ }
+
+ // unten abschliessen
+
+ if ( rBottomLine.Prim() )
+ {
+ long nLineW = rBottomLine.GetWidth();
+ if (nLineW >= 2)
+ {
+ Point aTriangle[3];
+ aTriangle[0] = Point( nBotLeft, nBotPos ); // wie aPoints[3]
+ aTriangle[1] = Point( nBotRight, nBotPos ); // wie aPoints[2]
+ aTriangle[2] = Point( rBottom.X(), nBotPos - (nLineW - 1) / 2 + nLineW - 1 );
+ Polygon aTriPoly( 3, aTriangle );
+ rDev.DrawPolygon( aTriPoly );
+ }
+ }
+}
+
+void lcl_VertLine( OutputDevice& rDev, const Point& rTop, const Point& rBottom,
+ const svx::frame::Style& rLine,
+ const svx::frame::Style& rTopLine, const svx::frame::Style& rBottomLine,
+ const Color* pForceColor )
+{
+ if( rLine.Prim() )
+ {
+ svx::frame::DrawVerFrameBorderSlanted( rDev, rTop, rBottom, rLine, pForceColor );
+
+ svx::frame::Style aScaled( rLine );
+ aScaled.ScaleSelf( 1.0 / cos( svx::frame::GetVerDiagAngle( rTop, rBottom ) ) );
+ if( pForceColor )
+ aScaled.SetColor( *pForceColor );
+
+ long nXOffs = (aScaled.GetWidth() - 1) / -2L;
+
+ lcl_VertLineEnds( rDev, rTop, rBottom, aScaled.GetColor(),
+ nXOffs, aScaled.Prim(), rTopLine, rBottomLine );
+
+ if( aScaled.Secn() )
+ lcl_VertLineEnds( rDev, rTop, rBottom, aScaled.GetColor(),
+ nXOffs + aScaled.Prim() + aScaled.Dist(), aScaled.Secn(), rTopLine, rBottomLine );
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::TakeObjNameSingul(XubString& rName) const
+{
+ rName = ImpGetResStr(STR_ObjNameSingulTable);
+
+ String aName( GetName() );
+ if(aName.Len())
+ {
+ rName += sal_Unicode(' ');
+ rName += sal_Unicode('\'');
+ rName += aName;
+ rName += sal_Unicode('\'');
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::TakeObjNamePlural(XubString& rName) const
+{
+ rName = ImpGetResStr(STR_ObjNamePluralTable);
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::operator=(const SdrObject& rObj)
+{
+ // call parent
+ SdrObject::operator=(rObj);
+
+ const SdrTableObj* pTableObj = dynamic_cast< const SdrTableObj* >( &rObj );
+ if (pTableObj!=NULL)
+ {
+ TableModelNotifyGuard aGuard( mpImpl ? mpImpl->mxTable.get() : 0 );
+
+ maLogicRect = pTableObj->maLogicRect;
+ aRect = pTableObj->aRect;
+ aGeo = pTableObj->aGeo;
+ eTextKind = pTableObj->eTextKind;
+ bTextFrame = pTableObj->bTextFrame;
+ aTextSize = pTableObj->aTextSize;
+ bTextSizeDirty = pTableObj->bTextSizeDirty;
+ bNoShear = pTableObj->bNoShear;
+ bNoRotate = pTableObj->bNoRotate;
+ bNoMirror = pTableObj->bNoMirror;
+ bDisableAutoWidthOnDragging = pTableObj->bDisableAutoWidthOnDragging;
+
+ if( pTableObj->mpImpl )
+ *mpImpl = *pTableObj->mpImpl;
+ }
+}
+
+// --------------------------------------------------------------------
+
+basegfx::B2DPolyPolygon SdrTableObj::TakeXorPoly() const
+{
+ return SdrTextObj::TakeXorPoly();
+}
+
+// --------------------------------------------------------------------
+
+basegfx::B2DPolyPolygon SdrTableObj::TakeContour() const
+{
+ return SdrTextObj::TakeContour();
+}
+
+// --------------------------------------------------------------------
+
+const Rectangle& SdrTableObj::GetSnapRect() const
+{
+ return aRect;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::NbcSetSnapRect(const Rectangle& rRect)
+{
+ NbcSetLogicRect( rRect );
+}
+
+// --------------------------------------------------------------------
+
+const Rectangle& SdrTableObj::GetLogicRect() const
+{
+ return maLogicRect;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::RecalcSnapRect()
+{
+}
+
+// --------------------------------------------------------------------
+
+sal_uInt32 SdrTableObj::GetSnapPointCount() const
+{
+ return SdrTextObj::GetSnapPointCount();
+}
+
+// --------------------------------------------------------------------
+
+
+Point SdrTableObj::GetSnapPoint(sal_uInt32 i) const
+{
+ return SdrTextObj::GetSnapPoint(i);
+}
+
+// --------------------------------------------------------------------
+
+sal_Bool SdrTableObj::BegTextEdit(SdrOutliner& rOutl)
+{
+ if( pEdtOutl != NULL )
+ return sal_False;
+
+ pEdtOutl=&rOutl;
+
+// ForceOutlinerParaObject();
+
+ mbInEditMode = TRUE;
+
+ rOutl.Init( OUTLINERMODE_TEXTOBJECT );
+ rOutl.SetRefDevice( pModel->GetRefDevice() );
+
+// --
+ bool bUpdMerk=rOutl.GetUpdateMode();
+ if (bUpdMerk) rOutl.SetUpdateMode(FALSE);
+ Size aPaperMin;
+ Size aPaperMax;
+ Rectangle aEditArea;
+ TakeTextEditArea(&aPaperMin,&aPaperMax,&aEditArea,NULL);
+
+ rOutl.SetMinAutoPaperSize(aPaperMin);
+ rOutl.SetMaxAutoPaperSize(aPaperMax);
+ rOutl.SetPaperSize(aPaperMax);
+
+ if (bUpdMerk) rOutl.SetUpdateMode(TRUE);
+//---
+
+ ULONG nStat=rOutl.GetControlWord();
+// nStat &= ~EE_CNTRL_AUTOPAGESIZE;
+ nStat |= EE_CNTRL_AUTOPAGESIZE;
+ nStat &=~EE_CNTRL_STRETCHING;
+ rOutl.SetControlWord(nStat);
+
+ OutlinerParaObject* pPara = GetOutlinerParaObject();
+ if(pPara)
+ rOutl.SetText(*pPara);
+
+ rOutl.UpdateFields();
+ rOutl.ClearModifyFlag();
+
+// mpImpl->mnSavedEditRowHeight = mpImpl->mpLayouter->getRowHeight( mpImpl->maEditPos.mnRow );
+
+ return sal_True;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::EndTextEdit(SdrOutliner& rOutl)
+{
+ if(rOutl.IsModified())
+ {
+ if( GetModel() && GetModel()->IsUndoEnabled() )
+ GetModel()->AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*this) );
+
+ OutlinerParaObject* pNewText = 0;
+ Paragraph* p1stPara = rOutl.GetParagraph( 0 );
+ UINT32 nParaAnz = rOutl.GetParagraphCount();
+
+ if(p1stPara)
+ {
+ if(nParaAnz == 1)
+ {
+ // if its only one paragraph, check if it is empty
+ XubString aStr(rOutl.GetText(p1stPara));
+
+ if(!aStr.Len())
+ {
+ // gotcha!
+ nParaAnz = 0;
+ }
+ }
+
+ // to remove the grey field background
+ rOutl.UpdateFields();
+
+ if(nParaAnz != 0)
+ {
+ // create new text object
+ pNewText = rOutl.CreateParaObject( 0, (sal_uInt16)nParaAnz );
+ }
+ }
+ SetOutlinerParaObject(pNewText);
+ }
+
+ pEdtOutl = 0;
+ rOutl.Clear();
+ UINT32 nStat = rOutl.GetControlWord();
+ nStat &= ~EE_CNTRL_AUTOPAGESIZE;
+ rOutl.SetControlWord(nStat);
+
+ mbInEditMode = FALSE;
+}
+
+// --------------------------------------------------------------------
+
+OutlinerParaObject* SdrTableObj::GetOutlinerParaObject() const
+{
+ CellRef xCell( getActiveCell() );
+ if( xCell.is() )
+ return xCell->GetOutlinerParaObject();
+ else
+ return 0;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::NbcSetOutlinerParaObject( OutlinerParaObject* pTextObject)
+{
+ CellRef xCell( getActiveCell() );
+ if( xCell.is() )
+ {
+ if( pModel )
+ {
+ // Update HitTestOutliner
+ const SdrTextObj* pTestObj = pModel->GetHitTestOutliner().GetTextObj();
+ if( pTestObj && pTestObj->GetOutlinerParaObject() == xCell->GetOutlinerParaObject() )
+ pModel->GetHitTestOutliner().SetTextObj( NULL );
+ }
+
+ xCell->SetOutlinerParaObject( pTextObject );
+
+ SetTextSizeDirty();
+ NbcAdjustTextFrameWidthAndHeight();
+// ImpSetTextStyleSheetListeners();
+// ImpCheckMasterCachable();
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::NbcSetLogicRect(const Rectangle& rRect)
+{
+ maLogicRect=rRect;
+ ImpJustifyRect(maLogicRect);
+ const bool bWidth = maLogicRect.getWidth() != aRect.getWidth();
+ const bool bHeight = maLogicRect.getHeight() != aRect.getHeight();
+ aRect=maLogicRect;
+ NbcAdjustTextFrameWidthAndHeight( !bHeight, !bWidth );
+ SetRectsDirty();
+}
+
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::AdjustToMaxRect( const Rectangle& rMaxRect, bool /* bShrinkOnly = false */ )
+{
+ Rectangle aAdjustRect( rMaxRect );
+ aAdjustRect.setHeight( GetLogicRect().getHeight() );
+ SetLogicRect( aAdjustRect );
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::NbcMove(const Size& rSiz)
+{
+ MoveRect(maLogicRect,rSiz);
+ SdrTextObj::NbcMove( rSiz );
+ if( mpImpl )
+ mpImpl->UpdateCells( aRect );
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
+{
+ Rectangle aOldRect( maLogicRect );
+ ResizeRect(maLogicRect,rRef,xFact,yFact);
+
+ aRect = maLogicRect;
+ NbcAdjustTextFrameWidthAndHeight( maLogicRect.GetHeight() == aOldRect.GetHeight(), maLogicRect.GetWidth() == aOldRect.GetWidth() );
+ SetRectsDirty();
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::AdjustTextFrameWidthAndHeight(bool bHgt, bool bWdt)
+{
+ Rectangle aNeuRect(maLogicRect);
+ bool bRet=AdjustTextFrameWidthAndHeight(aNeuRect,bHgt,bWdt);
+ if (bRet)
+ {
+ Rectangle aBoundRect0;
+ if (pUserCall!=NULL)
+ aBoundRect0=GetLastBoundRect();
+ aRect=aNeuRect;
+ SetRectsDirty();
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+ }
+ return bRet;
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::AdjustTextFrameWidthAndHeight(Rectangle& rR, bool bHeight, bool bWidth) const
+{
+ if((pModel == NULL) || rR.IsEmpty() || !mpImpl || !mpImpl->mxTable.is() )
+ return FALSE;
+
+ Rectangle aRectangle( rR );
+ mpImpl->LayoutTable( aRectangle, !bWidth, !bHeight );
+
+ if( aRectangle != rR )
+ {
+ rR = aRectangle;
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::NbcReformatText()
+{
+ NbcAdjustTextFrameWidthAndHeight();
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::ReformatText()
+{
+ Rectangle aBoundRect0;
+ if (pUserCall!=NULL)
+ aBoundRect0=GetLastBoundRect();
+ NbcReformatText();
+ SetChanged();
+ BroadcastObjectChange();
+ SendUserCall(SDRUSERCALL_RESIZE,aBoundRect0);
+}
+
+// --------------------------------------------------------------------
+
+sal_Bool SdrTableObj::IsVerticalWriting() const
+{
+ const SvxWritingModeItem* pModeItem = dynamic_cast< const SvxWritingModeItem* >( &GetObjectItem( SDRATTR_TEXTDIRECTION ) );
+ return pModeItem && pModeItem->GetValue() == com::sun::star::text::WritingMode_TB_RL;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::SetVerticalWriting(sal_Bool bVertical )
+{
+ if( bVertical != IsVerticalWriting() )
+ {
+ SvxWritingModeItem aModeItem( com::sun::star::text::WritingMode_LR_TB, SDRATTR_TEXTDIRECTION );
+ SetObjectItem( aModeItem );
+ }
+}
+
+// --------------------------------------------------------------------
+
+WritingMode SdrTableObj::GetWritingMode() const
+{
+ WritingMode eMode = WritingMode_LR_TB;
+ if( mpImpl && mpImpl->mpLayouter )
+ eMode = mpImpl->mpLayouter->GetWritingMode();
+ return eMode;
+}
+
+// --------------------------------------------------------------------
+
+// gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon
+// with the base geometry and returns TRUE. Otherwise it returns FALSE.
+sal_Bool SdrTableObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B2DPolyPolygon& rPolyPolygon ) const
+{
+ return SdrTextObj::TRGetBaseGeometry( rMatrix, rPolyPolygon );
+}
+
+// --------------------------------------------------------------------
+
+// sets the base geometry of the object using infos contained in the homogen 3x3 matrix.
+// If it's an SdrPathObj it will use the provided geometry information. The Polygon has
+// to use (0,0) as upper left and will be scaled to the given size in the matrix.
+void SdrTableObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const basegfx::B2DPolyPolygon& rPolyPolygon )
+{
+ SdrTextObj::TRSetBaseGeometry( rMatrix, rPolyPolygon );
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::IsRealyEdited() const
+{
+ return pEdtOutl && pEdtOutl->IsModified();
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::IsFontwork() const
+{
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+sal_uInt32 SdrTableObj::GetHdlCount() const
+{
+ sal_uInt32 nCount = SdrTextObj::GetHdlCount();
+ const sal_Int32 nRowCount = mpImpl->getRowCount();
+ const sal_Int32 nColCount = mpImpl->getColumnCount();
+
+ if( nRowCount && nColCount )
+ nCount += nRowCount + nColCount + 2 + 1;
+
+ return nCount;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::AddToHdlList(SdrHdlList& rHdlList) const
+{
+ const sal_Int32 nRowCount = mpImpl->getRowCount();
+ const sal_Int32 nColCount = mpImpl->getColumnCount();
+
+ // first add row handles
+ std::vector< TableEdgeHdl* > aRowEdges( nRowCount + 1 );
+
+ for( sal_Int32 nRow = 0; nRow <= nRowCount; nRow++ )
+ {
+ sal_Int32 nEdgeMin, nEdgeMax;
+ const sal_Int32 nEdge = mpImpl->mpLayouter->getHorizontalEdge( nRow, &nEdgeMin, &nEdgeMax );
+ nEdgeMin -= nEdge;
+ nEdgeMax -= nEdge;
+
+ Point aPoint( aRect.TopLeft() );
+ aPoint.Y() += nEdge;
+
+ TableEdgeHdl* pHdl= new TableEdgeHdl(aPoint,true,nEdgeMin,nEdgeMax,nColCount+1);
+ pHdl->SetPointNum( nRow );
+ rHdlList.AddHdl( pHdl );
+ aRowEdges[nRow] = pHdl;
+ }
+
+ // second add column handles
+ std::vector< TableEdgeHdl* > aColEdges( nColCount + 1 );
+
+ for( sal_Int32 nCol = 0; nCol <= nColCount; nCol++ )
+ {
+ sal_Int32 nEdgeMin, nEdgeMax;
+ const sal_Int32 nEdge = mpImpl->mpLayouter->getVerticalEdge( nCol, &nEdgeMin, &nEdgeMax );
+ nEdgeMin -= nEdge;
+ nEdgeMax -= nEdge;
+
+ Point aPoint( aRect.TopLeft() );
+ aPoint.X() += nEdge;
+
+ TableEdgeHdl* pHdl = new TableEdgeHdl(aPoint,false,nEdgeMin,nEdgeMax, nRowCount+1);
+ pHdl->SetPointNum( nCol );
+ rHdlList.AddHdl( pHdl );
+ aColEdges[nCol] = pHdl;
+ }
+
+ // now add visible edges to row and column handles
+ if( mpImpl && mpImpl->mpLayouter )
+ {
+ TableLayouter& rLayouter = *mpImpl->mpLayouter;
+
+ sal_Int32 nY = 0;
+
+ for( sal_Int32 nRow = 0; nRow <= nRowCount; ++nRow )
+ {
+ const sal_Int32 nRowHeight = (nRow == nRowCount) ? 0 : rLayouter.getRowHeight(nRow);
+ sal_Int32 nX = 0;
+
+ for( sal_Int32 nCol = 0; nCol <= nColCount; ++nCol )
+ {
+ const sal_Int32 nColWidth = (nCol == nColCount) ? 0 : rLayouter.getColumnWidth(nCol);
+
+ if( nRowHeight > 0 )
+ {
+ if( rLayouter.isEdgeVisible( nCol, nRow, false ) )
+ aColEdges[nCol]->SetEdge( nRow, nY, nY + nRowHeight, (rLayouter.getBorderLine( nCol, nRow, false ) == 0) ? Visible : Invisible);
+ }
+
+ if( nColWidth > 0 )
+ {
+ if( rLayouter.isEdgeVisible( nCol, nRow, true ) )
+ aRowEdges[nRow]->SetEdge( nCol, nX, nX + nColWidth, (rLayouter.getBorderLine( nCol, nRow, true ) == 0) ? Visible : Invisible);
+ }
+
+ nX += nColWidth;
+ }
+
+ nY += nRowHeight;
+ }
+ }
+
+ // add remaining handles
+ SdrHdl* pH=0;
+ rHdlList.AddHdl( pH = new TableBorderHdl( aRect ) ); pH->SetMoveOutside( true );
+ rHdlList.AddHdl( pH = new SdrHdl(aRect.TopLeft(),HDL_UPLFT) ); pH->SetMoveOutside( true );
+ rHdlList.AddHdl( pH = new SdrHdl(aRect.TopCenter(),HDL_UPPER) ); pH->SetMoveOutside( true );
+ rHdlList.AddHdl( pH = new SdrHdl(aRect.TopRight(),HDL_UPRGT) ); pH->SetMoveOutside( true );
+ rHdlList.AddHdl( pH = new SdrHdl(aRect.LeftCenter(),HDL_LEFT) ); pH->SetMoveOutside( true );
+ rHdlList.AddHdl( pH = new SdrHdl(aRect.RightCenter(),HDL_RIGHT) ); pH->SetMoveOutside( true );
+ rHdlList.AddHdl( pH = new SdrHdl(aRect.BottomLeft(),HDL_LWLFT) ); pH->SetMoveOutside( true );
+ rHdlList.AddHdl( pH = new SdrHdl(aRect.BottomCenter(),HDL_LOWER) ); pH->SetMoveOutside( true );
+ rHdlList.AddHdl( pH = new SdrHdl(aRect.BottomRight(),HDL_LWRGT) ); pH->SetMoveOutside( true );
+
+ ULONG nHdlCount = rHdlList.GetHdlCount();
+ for( ULONG nHdl = 0; nHdl < nHdlCount; nHdl++ )
+ rHdlList.GetHdl(nHdl)->SetObj((SdrObject*)this);
+}
+
+// --------------------------------------------------------------------
+
+SdrHdl* SdrTableObj::GetHdl(sal_uInt32 nHdlNum) const
+{
+ // #i73248#
+ // Warn the user that this is ineffective and show alternatives. Should not be used at all.
+ OSL_ENSURE(false, "SdrTableObj::GetHdl(): ineffective, use AddToHdlList instead (!)");
+
+ // to have an alternative, get single handle using the ineffective way
+ SdrHdl* pRetval = 0;
+ SdrHdlList aLocalList(0);
+ AddToHdlList(aLocalList);
+ const sal_uInt32 nHdlCount(aLocalList.GetHdlCount());
+
+ if(nHdlCount && nHdlNum < nHdlCount)
+ {
+ // remove and remember. The other created handles will be deleted again with the
+ // destruction of the local list
+ pRetval = aLocalList.RemoveHdl(nHdlNum);
+ }
+
+ return pRetval;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Draging
+
+bool SdrTableObj::hasSpecialDrag() const
+{
+ return true;
+}
+
+bool SdrTableObj::beginSpecialDrag(SdrDragStat& rDrag) const
+{
+ const SdrHdl* pHdl = rDrag.GetHdl();
+ const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind());
+
+ switch( eHdl )
+ {
+ case HDL_UPLFT:
+ case HDL_UPPER:
+ case HDL_UPRGT:
+ case HDL_LEFT:
+ case HDL_RIGHT:
+ case HDL_LWLFT:
+ case HDL_LOWER:
+ case HDL_LWRGT:
+ case HDL_MOVE:
+ {
+ break;
+ }
+
+ case HDL_USER:
+ {
+ rDrag.SetEndDragChangesAttributes(false);
+ rDrag.SetNoSnap(true);
+ break;
+ }
+
+ default:
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool SdrTableObj::applySpecialDrag(SdrDragStat& rDrag)
+{
+ bool bRet(true);
+ const SdrHdl* pHdl = rDrag.GetHdl();
+ const SdrHdlKind eHdl((pHdl == NULL) ? HDL_MOVE : pHdl->GetKind());
+
+ switch( eHdl )
+ {
+ case HDL_UPLFT:
+ case HDL_UPPER:
+ case HDL_UPRGT:
+ case HDL_LEFT:
+ case HDL_RIGHT:
+ case HDL_LWLFT:
+ case HDL_LOWER:
+ case HDL_LWRGT:
+ {
+ const Rectangle aNewRectangle(ImpDragCalcRect(rDrag));
+
+ if(aNewRectangle != aRect)
+ {
+ NbcSetLogicRect(aNewRectangle);
+ }
+
+ break;
+ }
+
+ case HDL_MOVE:
+ {
+ NbcMove( Size( rDrag.GetDX(), rDrag.GetDY() ) );
+ break;
+ }
+
+ case HDL_USER:
+ {
+ rDrag.SetEndDragChangesAttributes(false);
+ rDrag.SetNoSnap(true);
+ const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl );
+
+ if( pEdgeHdl )
+ {
+ if( GetModel() && IsInserted() )
+ {
+ rDrag.SetEndDragChangesAttributes(true);
+ }
+
+ mpImpl->DragEdge( pEdgeHdl->IsHorizontalEdge(), pEdgeHdl->GetPointNum(), pEdgeHdl->GetValidDragOffset( rDrag ) );
+ }
+ break;
+ }
+
+ default:
+ {
+ bRet = false;
+ }
+ }
+
+ return bRet;
+}
+
+String SdrTableObj::getSpecialDragComment(const SdrDragStat& rDrag) const
+{
+ return SdrTextObj::getSpecialDragComment( rDrag );
+}
+
+basegfx::B2DPolyPolygon SdrTableObj::getSpecialDragPoly(const SdrDragStat& rDrag) const
+{
+ basegfx::B2DPolyPolygon aRetval;
+ const SdrHdl* pHdl = rDrag.GetHdl();
+
+ if( pHdl && (HDL_USER == pHdl->GetKind()) )
+ {
+ const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl );
+
+ if( pEdgeHdl )
+ {
+ aRetval = pEdgeHdl->getSpecialDragPoly( rDrag );
+ }
+ }
+
+ return aRetval;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Create
+// --------------------------------------------------------------------
+
+bool SdrTableObj::BegCreate(SdrDragStat& rStat)
+{
+ rStat.SetOrtho4Possible();
+ Rectangle aRect1(rStat.GetStart(), rStat.GetNow());
+ aRect1.Justify();
+ rStat.SetActionRect(aRect1);
+ aRect = aRect1;
+ return true;
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::MovCreate(SdrDragStat& rStat)
+{
+ Rectangle aRect1;
+ rStat.TakeCreateRect(aRect1);
+ ImpJustifyRect(aRect1);
+ rStat.SetActionRect(aRect1);
+ aRect=aRect1; // fuer ObjName
+ SetBoundRectDirty();
+ bSnapRectDirty=TRUE;
+ return true;
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+ rStat.TakeCreateRect(aRect);
+ ImpJustifyRect(aRect);
+ return (eCmd==SDRCREATE_FORCEEND || rStat.GetPointAnz()>=2);
+}
+
+void SdrTableObj::BrkCreate(SdrDragStat& /*rStat*/)
+{
+}
+
+// --------------------------------------------------------------------
+
+bool SdrTableObj::BckCreate(SdrDragStat& /*rStat*/)
+{
+ return true;
+}
+
+// --------------------------------------------------------------------
+
+basegfx::B2DPolyPolygon SdrTableObj::TakeCreatePoly(const SdrDragStat& rDrag) const
+{
+ Rectangle aRect1;
+ rDrag.TakeCreateRect(aRect1);
+ aRect1.Justify();
+
+ basegfx::B2DPolyPolygon aRetval;
+ const basegfx::B2DRange aRange(aRect1.Left(), aRect1.Top(), aRect1.Right(), aRect1.Bottom());
+ aRetval.append(basegfx::tools::createPolygonFromRect(aRange));
+ return aRetval;
+}
+
+// --------------------------------------------------------------------
+
+Pointer SdrTableObj::GetCreatePointer() const
+{
+ return Pointer(POINTER_CROSS);
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::createCell( CellRef& xNewCell )
+{
+ xNewCell = Cell::create( *this, 0 );
+}
+
+// --------------------------------------------------------------------
+
+SdrObjGeoData *SdrTableObj::NewGeoData() const
+{
+ return new TableObjectGeoData;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::SaveGeoData(SdrObjGeoData& rGeo) const
+{
+ DBG_ASSERT( dynamic_cast< TableObjectGeoData* >( &rGeo ), "svx::SdrTableObj::SaveGeoData(), illegal geo data!" );
+ SdrTextObj::SaveGeoData (rGeo);
+
+ ((TableObjectGeoData &) rGeo).maLogicRect = maLogicRect;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::RestGeoData(const SdrObjGeoData& rGeo)
+{
+ DBG_ASSERT( dynamic_cast< const TableObjectGeoData* >( &rGeo ), "svx::SdrTableObj::SaveGeoData(), illegal geo data!" );
+
+ maLogicRect = ((TableObjectGeoData &) rGeo).maLogicRect;
+
+ SdrTextObj::RestGeoData (rGeo);
+
+ if( mpImpl )
+ mpImpl->LayoutTable( aRect, false, false );
+ ActionChanged();
+}
+
+// --------------------------------------------------------------------
+
+SdrTableObj* SdrTableObj::CloneRange( const CellPos& rStart, const CellPos& rEnd )
+{
+ const sal_Int32 nColumns = rEnd.mnCol - rStart.mnCol + 1;
+ const sal_Int32 nRows = rEnd.mnRow - rStart.mnRow + 1;
+
+ SdrTableObj* pNewTableObj = new SdrTableObj( GetModel(), GetCurrentBoundRect(), nColumns, nRows);
+ pNewTableObj->setTableStyleSettings( getTableStyleSettings() );
+ pNewTableObj->setTableStyle( getTableStyle() );
+
+ Reference< XTable > xTable( getTable() );
+ Reference< XTable > xNewTable( pNewTableObj->getTable() );
+
+ if( !xTable.is() || !xNewTable.is() )
+ {
+ delete pNewTableObj;
+ return 0;
+ }
+
+ // copy cells
+ for( sal_Int32 nRow = 0; nRow < nRows; ++nRow )
+ {
+ for( sal_Int32 nCol = 0; nCol < nColumns; ++nCol ) try
+ {
+ CellRef xTargetCell( dynamic_cast< Cell* >( xNewTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xTargetCell.is() )
+ xTargetCell->cloneFrom( dynamic_cast< Cell* >( xTable->getCellByPosition( rStart.mnCol + nCol, rStart.mnRow + nRow ).get() ) );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "svx::SvxTableController::GetMarkedObjModel(), exception caught!" );
+ }
+ }
+
+ // copy row heights
+ Reference< XTableRows > xNewRows( xNewTable->getRows(), UNO_QUERY_THROW );
+ const OUString sHeight( RTL_CONSTASCII_USTRINGPARAM( "Height" ) );
+ for( sal_Int32 nRow = 0; nRow < nRows; ++nRow )
+ {
+ Reference< XPropertySet > xNewSet( xNewRows->getByIndex( nRow ), UNO_QUERY_THROW );
+ xNewSet->setPropertyValue( sHeight, Any( mpImpl->mpLayouter->getRowHeight( rStart.mnRow + nRow ) ) );
+ }
+
+ // copy column widths
+ Reference< XTableColumns > xNewColumns( xNewTable->getColumns(), UNO_QUERY_THROW );
+ const OUString sWidth( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
+ for( sal_Int32 nCol = 0; nCol < nColumns; ++nCol )
+ {
+ Reference< XPropertySet > xNewSet( xNewColumns->getByIndex( nCol ), UNO_QUERY_THROW );
+ xNewSet->setPropertyValue( sWidth, Any( mpImpl->mpLayouter->getColumnWidth( rStart.mnCol + nCol ) ) );
+ }
+
+ pNewTableObj->NbcReformatText();
+ pNewTableObj->SetLogicRect( pNewTableObj->GetCurrentBoundRect() );
+
+ return pNewTableObj;
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn )
+{
+ if( mpImpl && mpImpl->mpLayouter )
+ {
+ TableModelNotifyGuard aGuard( mpImpl->mxTable.get() );
+ mpImpl->mpLayouter->DistributeColumns( aRect, nFirstColumn, nLastColumn );
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow )
+{
+ if( mpImpl && mpImpl->mpLayouter )
+ {
+ TableModelNotifyGuard aGuard( mpImpl->mxTable.get() );
+ mpImpl->mpLayouter->DistributeRows( aRect, nFirstRow, nLastRow );
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::SetChanged()
+{
+ if( mpImpl )
+ {
+ if( mpImpl->UpdateWritingMode() )
+ mpImpl->LayoutTable( aRect, false, false );
+ }
+
+ ::SdrTextObj::SetChanged();
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::uno_lock()
+{
+ if( mpImpl && mpImpl->mxTable.is() )
+ mpImpl->mxTable->lockBroadcasts();
+}
+
+// --------------------------------------------------------------------
+
+void SdrTableObj::uno_unlock()
+{
+ if( mpImpl && mpImpl->mxTable.is() )
+ mpImpl->mxTable->unlockBroadcasts();
+}
+
+// --------------------------------------------------------------------
+
+
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/table.src b/svx/source/table/table.src
new file mode 100644
index 000000000000..4a696f9e0ce9
--- /dev/null
+++ b/svx/source/table/table.src
@@ -0,0 +1,34 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "svx/dialogs.hrc"
+
+String RID_SVXSTR_STYLEFAMILY_TABLEDESIGN
+{
+ Text [ en-US ] = "Table Design Styles";
+};
+
diff --git a/svx/source/table/tablecolumn.cxx b/svx/source/table/tablecolumn.cxx
new file mode 100644
index 000000000000..c083f1aad92b
--- /dev/null
+++ b/svx/source/table/tablecolumn.cxx
@@ -0,0 +1,308 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/lang/DisposedException.hpp>
+
+#include "tablecolumn.hxx"
+#include "tableundo.hxx"
+#include "svx/svdmodel.hxx"
+#include "svx/svdotable.hxx"
+
+// -----------------------------------------------------------------------------
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::beans;
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+const sal_Int32 Property_Width = 0;
+const sal_Int32 Property_OptimalWidth = 1;
+const sal_Int32 Property_IsVisible = 2;
+const sal_Int32 Property_IsStartOfNewPage = 3;
+
+// -----------------------------------------------------------------------------
+// TableRow
+// -----------------------------------------------------------------------------
+
+TableColumn::TableColumn( const TableModelRef& xTableModel, sal_Int32 nColumn )
+: TableColumnBase( getStaticPropertySetInfo() )
+, mxTableModel( xTableModel )
+, mnColumn( nColumn )
+, mnWidth( 0 )
+, mbOptimalWidth( sal_True )
+, mbIsVisible( sal_True )
+, mbIsStartOfNewPage( sal_False )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+TableColumn::~TableColumn()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void TableColumn::dispose()
+{
+ mxTableModel.clear();
+}
+
+// -----------------------------------------------------------------------------
+
+void TableColumn::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException)
+{
+ if( !mxTableModel.is() )
+ throw DisposedException();
+}
+
+// -----------------------------------------------------------------------------
+
+TableColumn& TableColumn::operator=( const TableColumn& r )
+{
+ mnWidth = r.mnWidth;
+ mbOptimalWidth = r.mbOptimalWidth;
+ mbIsVisible = r.mbIsVisible;
+ mbIsStartOfNewPage = r.mbIsStartOfNewPage;
+
+ return *this;
+}
+
+// -----------------------------------------------------------------------------
+// XCellRange
+// -----------------------------------------------------------------------------
+
+Reference< XCell > SAL_CALL TableColumn::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ throwIfDisposed();
+ if( nColumn != 0 )
+ throw IndexOutOfBoundsException();
+
+ return mxTableModel->getCellByPosition( mnColumn, nRow );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellRange > SAL_CALL TableColumn::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ throwIfDisposed();
+ if( (nTop >= 0 ) && (nLeft == 0) && (nBottom >= nTop) && (nRight == 0) )
+ {
+ return mxTableModel->getCellRangeByPosition( mnColumn, nTop, mnColumn, nBottom );
+ }
+ throw IndexOutOfBoundsException();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellRange > SAL_CALL TableColumn::getCellRangeByName( const OUString& /*aRange*/ ) throw (RuntimeException)
+{
+ return Reference< XCellRange >();
+}
+
+// -----------------------------------------------------------------------------
+// XNamed
+// -----------------------------------------------------------------------------
+
+OUString SAL_CALL TableColumn::getName() throw (RuntimeException)
+{
+ return maName;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableColumn::setName( const OUString& aName ) throw (RuntimeException)
+{
+ maName = aName;
+}
+
+// -----------------------------------------------------------------------------
+// XFastPropertySet
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException)
+{
+ bool bOk = false;
+ bool bChange = false;
+
+ SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
+
+ TableColumnUndo* pUndo = 0;
+ if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled() )
+ {
+ TableColumnRef xThis( this );
+ pUndo = new TableColumnUndo( xThis );
+ }
+
+ switch( nHandle )
+ {
+ case Property_Width:
+ {
+ sal_Int32 nWidth = mnWidth;
+ bOk = aValue >>= nWidth;
+ if( bOk && (nWidth != mnWidth) )
+ {
+ mnWidth = nWidth;
+ mbOptimalWidth = mnWidth == 0;
+ bChange = true;
+ }
+ break;
+ }
+ case Property_OptimalWidth:
+ {
+ sal_Bool bOptimalWidth = mbOptimalWidth;
+ bOk = aValue >>= bOptimalWidth;
+ if( bOk && (mbOptimalWidth != bOptimalWidth) )
+ {
+ mbOptimalWidth = bOptimalWidth;
+ if( bOptimalWidth )
+ mnWidth = 0;
+ bChange = true;
+ }
+ break;
+ }
+ case Property_IsVisible:
+ {
+ sal_Bool bIsVisible = mbIsVisible;
+ bOk = aValue >>= bIsVisible;
+ if( bOk && (mbIsVisible != bIsVisible) )
+ {
+ mbIsVisible = bIsVisible;
+ bChange = true;
+ }
+ break;
+ }
+
+ case Property_IsStartOfNewPage:
+ {
+ sal_Bool bIsStartOfNewPage = mbIsStartOfNewPage;
+ bOk = aValue >>= bIsStartOfNewPage;
+ if( bOk && (mbIsStartOfNewPage != bIsStartOfNewPage) )
+ {
+ mbIsStartOfNewPage = bIsStartOfNewPage;
+ bChange = true;
+ }
+ break;
+ }
+ default:
+ throw UnknownPropertyException();
+ }
+ if( !bOk )
+ throw IllegalArgumentException();
+
+ if( bChange )
+ {
+ if( pUndo )
+ {
+ pModel->AddUndo( pUndo );
+ pUndo = 0;
+ }
+ mxTableModel->setModified(sal_True);
+ }
+
+ if( pUndo )
+ delete pUndo;
+}
+
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL TableColumn::getFastPropertyValue( sal_Int32 nHandle ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ switch( nHandle )
+ {
+ case Property_Width: return Any( mnWidth );
+ case Property_OptimalWidth: return Any( mbOptimalWidth );
+ case Property_IsVisible: return Any( mbIsVisible );
+ case Property_IsStartOfNewPage: return Any( mbIsStartOfNewPage );
+ default: throw UnknownPropertyException();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+rtl::Reference< ::comphelper::FastPropertySetInfo > TableColumn::getStaticPropertySetInfo()
+{
+ static rtl::Reference< ::comphelper::FastPropertySetInfo > xInfo;
+ if( !xInfo.is() )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !xInfo.is() )
+ {
+ comphelper::PropertyVector aProperties(6);
+
+ aProperties[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" ) );
+ aProperties[0].Handle = Property_Width;
+ aProperties[0].Type = ::getCppuType((const sal_Int32*)0);
+ aProperties[0].Attributes = 0;
+
+ aProperties[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "OptimalWidth" ) );
+ aProperties[1].Handle = Property_OptimalWidth;
+ aProperties[1].Type = ::getBooleanCppuType();
+ aProperties[1].Attributes = 0;
+
+ aProperties[2].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) );
+ aProperties[2].Handle = Property_IsVisible;
+ aProperties[2].Type = ::getBooleanCppuType();
+ aProperties[2].Attributes = 0;
+
+ aProperties[3].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" ) );
+ aProperties[3].Handle = Property_IsStartOfNewPage;
+ aProperties[3].Type = ::getBooleanCppuType();
+ aProperties[3].Attributes = 0;
+
+ aProperties[4].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) );
+ aProperties[4].Handle = Property_Width;
+ aProperties[4].Type = ::getCppuType((const sal_Int32*)0);
+ aProperties[4].Attributes = 0;
+
+ aProperties[5].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "OptimalSize" ) );
+ aProperties[5].Handle = Property_OptimalWidth;
+ aProperties[5].Type = ::getBooleanCppuType();
+ aProperties[5].Attributes = 0;
+
+ xInfo.set( new ::comphelper::FastPropertySetInfo(aProperties) );
+ }
+ }
+
+ return xInfo;
+}
+
+// -----------------------------------------------------------------------------
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablecolumn.hxx b/svx/source/table/tablecolumn.hxx
new file mode 100644
index 000000000000..37e041101b29
--- /dev/null
+++ b/svx/source/table/tablecolumn.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TABLECOLUMN_HXX_
+#define _SVX_TABLECOLUMN_HXX_
+
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+#include "propertyset.hxx"
+#include "tablemodel.hxx"
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+// TableColumn
+// -----------------------------------------------------------------------------
+
+typedef ::cppu::ImplInheritanceHelper2< ::comphelper::FastPropertySet, ::com::sun::star::table::XCellRange, ::com::sun::star::container::XNamed > TableColumnBase;
+
+class TableColumn : public TableColumnBase
+{
+ friend class TableColumnUndo;
+ friend class TableModel;
+public:
+ TableColumn( const TableModelRef& xTableModel, sal_Int32 nColumn );
+ virtual ~TableColumn();
+
+ void dispose();
+ void throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException);
+
+ TableColumn& operator=( const TableColumn& );
+
+ // XCellRange
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > SAL_CALL getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByName( const ::rtl::OUString& aRange ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XFastPropertySet
+ virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+private:
+ static rtl::Reference< ::comphelper::FastPropertySetInfo > getStaticPropertySetInfo();
+
+ TableModelRef mxTableModel;
+ sal_Int32 mnColumn;
+ sal_Int32 mnWidth;
+ sal_Bool mbOptimalWidth;
+ sal_Bool mbIsVisible;
+ sal_Bool mbIsStartOfNewPage;
+ ::rtl::OUString maName;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablecolumns.cxx b/svx/source/table/tablecolumns.cxx
new file mode 100644
index 000000000000..f05492061efe
--- /dev/null
+++ b/svx/source/table/tablecolumns.cxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/lang/DisposedException.hpp>
+
+#include "tablecolumns.hxx"
+#include "tablecolumn.hxx"
+
+// -----------------------------------------------------------------------------
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::table;
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+// TableColumns
+// -----------------------------------------------------------------------------
+
+TableColumns::TableColumns( const TableModelRef& xTableModel )
+: mxTableModel( xTableModel )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+TableColumns::~TableColumns()
+{
+ dispose();
+}
+
+// -----------------------------------------------------------------------------
+
+void TableColumns::dispose()
+{
+ mxTableModel.clear();
+}
+
+// -----------------------------------------------------------------------------
+
+void TableColumns::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException)
+{
+ if( !mxTableModel.is() )
+ throw DisposedException();
+}
+
+// -----------------------------------------------------------------------------
+// XTableRows
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableColumns::insertByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (RuntimeException)
+{
+ throwIfDisposed();
+ mxTableModel->insertColumns( nIndex, nCount );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableColumns::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (RuntimeException)
+{
+ throwIfDisposed();
+ mxTableModel->removeColumns( nIndex, nCount );
+}
+
+// -----------------------------------------------------------------------------
+// XIndexAccess
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL TableColumns::getCount() throw (RuntimeException)
+{
+ throwIfDisposed();
+ return mxTableModel->getColumnCount();
+}
+
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL TableColumns::getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ throwIfDisposed();
+
+ if( ( Index < 0 ) || ( Index >= mxTableModel->getColumnCount() ) )
+ throw IndexOutOfBoundsException();
+
+ return Any( Reference< XCellRange >( mxTableModel->getColumn( Index ).get() ) );
+}
+
+// -----------------------------------------------------------------------------
+// XElementAccess
+// -----------------------------------------------------------------------------
+
+Type SAL_CALL TableColumns::getElementType() throw (RuntimeException)
+{
+ throwIfDisposed();
+
+ return XCellRange::static_type();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL TableColumns::hasElements() throw (RuntimeException)
+{
+ throwIfDisposed();
+
+ return mxTableModel->getColumnCount() != 0;
+}
+
+// -----------------------------------------------------------------------------
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablecolumns.hxx b/svx/source/table/tablecolumns.hxx
new file mode 100644
index 000000000000..6fd9f21f7294
--- /dev/null
+++ b/svx/source/table/tablecolumns.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TABLECOLUMNS_HXX_
+#define _SVX_TABLECOLUMNS_HXX_
+
+#include <com/sun/star/table/XTableColumns.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+#include "tablemodel.hxx"
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+// TableColumns
+// -----------------------------------------------------------------------------
+
+class TableColumns : public ::cppu::WeakAggImplHelper1< ::com::sun::star::table::XTableColumns >
+{
+public:
+ TableColumns( const TableModelRef& xTableModel );
+ virtual ~TableColumns();
+
+ void dispose();
+ void throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException);
+
+ // XTableColumns
+ virtual void SAL_CALL insertByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // Methods
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasElements() throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ TableModelRef mxTableModel;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
new file mode 100644
index 000000000000..a6cdedec479e
--- /dev/null
+++ b/svx/source/table/tablecontroller.cxx
@@ -0,0 +1,2621 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "tablecontroller.hxx"
+
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/table/XMergeableCellRange.hpp>
+#include <com/sun/star/table/XMergeableCell.hpp>
+
+#include <sal/config.h>
+
+#include <vcl/svapp.hxx>
+#include <svl/whiter.hxx>
+
+#include <sfx2/request.hxx>
+
+#include <editeng/scripttypeitem.hxx>
+#include <svx/svdotable.hxx>
+#include <svx/sdr/overlay/overlayobjectcell.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <svx/svxids.hrc>
+#include <editeng/outlobj.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdetc.hxx>
+#include <editeng/editobj.hxx>
+#include "editeng/editstat.hxx"
+#include "editeng/unolingu.hxx"
+#include "svx/sdrpagewindow.hxx"
+#include <svx/selectioncontroller.hxx>
+#include <svx/svdmodel.hxx>
+#include "sdrpaintwindow.hxx"
+#include <svx/svxdlg.hxx>
+#include <editeng/boxitem.hxx>
+#include "cell.hxx"
+#include <editeng/borderline.hxx>
+#include <editeng/colritem.hxx>
+#include "editeng/bolnitem.hxx"
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+#include "svx/svdpage.hxx"
+#include "tableundo.hxx"
+#include "tablelayouter.hxx"
+
+using ::rtl::OUString;
+using namespace ::sdr::table;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::style;
+
+namespace sdr { namespace table {
+
+// --------------------------------------------------------------------
+// class SvxTableControllerModifyListener
+// --------------------------------------------------------------------
+
+class SvxTableControllerModifyListener : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XModifyListener >
+{
+public:
+ SvxTableControllerModifyListener( SvxTableController* pController )
+ : mpController( pController ) {}
+
+ // XModifyListener
+ virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ SvxTableController* mpController;
+};
+
+// --------------------------------------------------------------------
+// XModifyListener
+// --------------------------------------------------------------------
+
+void SAL_CALL SvxTableControllerModifyListener::modified( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if( mpController )
+ mpController->onTableModified();
+}
+
+// --------------------------------------------------------------------
+// XEventListener
+// --------------------------------------------------------------------
+
+void SAL_CALL SvxTableControllerModifyListener::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
+{
+ mpController = 0;
+}
+
+// --------------------------------------------------------------------
+// class SvxTableController
+// --------------------------------------------------------------------
+
+rtl::Reference< sdr::SelectionController > CreateTableController( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController )
+{
+ return SvxTableController::create( pView, pObj, xRefController );
+}
+
+// --------------------------------------------------------------------
+
+rtl::Reference< sdr::SelectionController > SvxTableController::create( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController )
+{
+ if( xRefController.is() )
+ {
+ SvxTableController* pController = dynamic_cast< SvxTableController* >( xRefController.get() );
+ if( pController && (pController->mxTableObj.get() == pObj) && (pController->mpView == pView) )
+ return xRefController;
+ }
+ return new SvxTableController( pView, pObj );
+}
+
+// --------------------------------------------------------------------
+
+SvxTableController::SvxTableController( SdrObjEditView* pView, const SdrObject* pObj )
+: mbCellSelectionMode(false)
+, mbLeftButtonDown(false)
+, mpSelectionOverlay(0)
+, mpView( dynamic_cast< SdrView* >( pView ) )
+, mxTableObj( dynamic_cast< SdrTableObj* >( const_cast< SdrObject* >( pObj ) ) )
+, mpModel( 0 )
+, mnUpdateEvent( 0 )
+{
+ if( pObj )
+ mpModel = pObj->GetModel();
+
+ if( mxTableObj.is() )
+ {
+ static_cast< const SdrTableObj* >( pObj )->getActiveCellPos( maCursorFirstPos );
+ maCursorLastPos = maCursorFirstPos;
+
+ Reference< XTable > xTable( static_cast< const SdrTableObj* >( pObj )->getTable() );
+ if( xTable.is() )
+ {
+ mxModifyListener = new SvxTableControllerModifyListener( this );
+ xTable->addModifyListener( mxModifyListener );
+
+ mxTable.set( dynamic_cast< TableModel* >( xTable.get() ) );
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+SvxTableController::~SvxTableController()
+{
+ if( mnUpdateEvent )
+ {
+ Application::RemoveUserEvent( mnUpdateEvent );
+ }
+
+ if( mxModifyListener.is() && mxTableObj.get() )
+ {
+ Reference< XTable > xTable( static_cast< SdrTableObj* >( mxTableObj.get() )->getTable() );
+ if( xTable.is() )
+ {
+ xTable->removeModifyListener( mxModifyListener );
+ mxModifyListener.clear();
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+const sal_uInt16 ACTION_NONE = 0;
+const sal_uInt16 ACTION_GOTO_FIRST_CELL = 1;
+const sal_uInt16 ACTION_GOTO_FIRST_COLUMN = 2;
+const sal_uInt16 ACTION_GOTO_FIRST_ROW = 3;
+const sal_uInt16 ACTION_GOTO_LEFT_CELL = 4;
+const sal_uInt16 ACTION_GOTO_UP_CELL = 5;
+const sal_uInt16 ACTION_GOTO_RIGHT_CELL = 6;
+const sal_uInt16 ACTION_GOTO_DOWN_CELL = 7;
+const sal_uInt16 ACTION_GOTO_LAST_CELL = 8;
+const sal_uInt16 ACTION_GOTO_LAST_COLUMN = 9;
+const sal_uInt16 ACTION_GOTO_LAST_ROW = 10;
+const sal_uInt16 ACTION_EDIT_CELL = 11;
+const sal_uInt16 ACTION_STOP_TEXT_EDIT = 12;
+const sal_uInt16 ACTION_REMOVE_SELECTION = 13;
+const sal_uInt16 ACTION_START_SELECTION = 14;
+const sal_uInt16 ACTION_HANDLED_BY_VIEW = 15;
+const sal_uInt16 ACTION_TAB = 18;
+
+bool SvxTableController::onKeyInput(const KeyEvent& rKEvt, Window* pWindow )
+{
+ if( !checkTableObject() )
+ return false;
+
+ // check if we are read only
+ if( mpModel && mpModel->IsReadOnly())
+ {
+ switch( rKEvt.GetKeyCode().GetCode() )
+ {
+ case awt::Key::DOWN:
+ case awt::Key::UP:
+ case awt::Key::LEFT:
+ case awt::Key::RIGHT:
+ case awt::Key::TAB:
+ case awt::Key::HOME:
+ case awt::Key::END:
+ case awt::Key::NUM2:
+ case awt::Key::NUM4:
+ case awt::Key::NUM6:
+ case awt::Key::NUM8:
+ case awt::Key::ESCAPE:
+ case awt::Key::F2:
+ break;
+ default:
+ // tell the view we eat the event, no further processing needed
+ return true;
+ }
+ }
+
+ sal_uInt16 nAction = getKeyboardAction( rKEvt, pWindow );
+
+ return executeAction( nAction, ( rKEvt.GetKeyCode().IsShift() ) ? sal_True : sal_False, pWindow );
+}
+
+// --------------------------------------------------------------------
+// ::com::sun::star::awt::XMouseClickHandler:
+// --------------------------------------------------------------------
+
+bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, Window* pWindow )
+{
+ if( !pWindow || !checkTableObject() )
+ return false;
+
+ SdrViewEvent aVEvt;
+ if( !rMEvt.IsRight() && mpView->PickAnything(rMEvt,SDRMOUSEBUTTONDOWN, aVEvt) == SDRHIT_HANDLE )
+ return false;
+
+ TableHitKind eHit = static_cast< SdrTableObj* >(mxTableObj.get())->CheckTableHit( pWindow->PixelToLogic(rMEvt.GetPosPixel()), maMouseDownPos.mnCol, maMouseDownPos.mnRow, 0 );
+
+ mbLeftButtonDown = (rMEvt.GetClicks() == 1) && rMEvt.IsLeft();
+
+ if( eHit == SDRTABLEHIT_CELL )
+ {
+ StartSelection( maMouseDownPos );
+ return true;
+ }
+
+ if( rMEvt.IsRight() && eHit != SDRTABLEHIT_NONE )
+ return true; // right click will become context menu
+
+ // for cell selektion with the mouse remember our first hit
+ if( mbLeftButtonDown )
+ {
+ RemoveSelection();
+
+ Point aPnt(rMEvt.GetPosPixel());
+ if (pWindow!=NULL)
+ aPnt=pWindow->PixelToLogic(aPnt);
+
+ SdrHdl* pHdl = mpView->PickHandle(aPnt);
+
+ if( pHdl )
+ {
+ mbLeftButtonDown = false;
+ }
+ else
+ {
+ ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+
+ if( !pWindow || !pTableObj || eHit == SDRTABLEHIT_NONE)
+ {
+ mbLeftButtonDown = false;
+ }
+ }
+ }
+
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+bool SvxTableController::onMouseButtonUp(const MouseEvent& rMEvt, Window* /*pWin*/)
+{
+ if( !checkTableObject() )
+ return false;
+
+ mbLeftButtonDown = false;
+
+ if( rMEvt.GetClicks() == 2 )
+ return true;
+
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+bool SvxTableController::onMouseMove(const MouseEvent& rMEvt, Window* pWindow )
+{
+ if( !checkTableObject() )
+ return false;
+
+ if( rMEvt.IsLeft() )
+ {
+ int i = 0;
+ i++;
+ }
+
+ SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() );
+ CellPos aPos;
+ if( mbLeftButtonDown && pTableObj && pTableObj->CheckTableHit( pWindow->PixelToLogic(rMEvt.GetPosPixel()), aPos.mnCol, aPos.mnRow, 0 ) != SDRTABLEHIT_NONE )
+ {
+ if(aPos != maMouseDownPos)
+ {
+ if( mbCellSelectionMode )
+ {
+ setSelectedCells( maMouseDownPos, aPos );
+ return true;
+ }
+ else
+ {
+ StartSelection( maMouseDownPos );
+ }
+ }
+ else if( mbCellSelectionMode )
+ {
+ UpdateSelection( aPos );
+ return true;
+ }
+ }
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::onSelectionHasChanged()
+{
+ bool bSelected = false;
+
+ SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() );
+ if( pTableObj && pTableObj->IsTextEditActive() )
+ {
+ pTableObj->getActiveCellPos( maCursorFirstPos );
+ maCursorLastPos = maCursorFirstPos;
+ mbCellSelectionMode = false;
+ }
+ else
+ {
+ const SdrMarkList& rMarkList= mpView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 )
+ bSelected = mxTableObj.get() == rMarkList.GetMark(0)->GetMarkedSdrObj();
+ }
+
+ if( bSelected )
+ {
+ updateSelectionOverlay();
+ }
+ else
+ {
+ destroySelectionOverlay();
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::GetState( SfxItemSet& rSet )
+{
+ if( !mxTable.is() || !mxTableObj.is() || !mxTableObj->GetModel() )
+ return;
+
+ SfxItemSet* pSet = 0;
+
+ bool bVertDone = false;
+
+ // Iterate over all requested items in the set.
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_TABLE_VERT_BOTTOM:
+ case SID_TABLE_VERT_CENTER:
+ case SID_TABLE_VERT_NONE:
+ {
+ if( !mxTable.is() || !mxTableObj->GetModel() )
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else if(!bVertDone)
+ {
+ if( !pSet )
+ {
+ pSet = new SfxItemSet( mxTableObj->GetModel()->GetItemPool() );
+ MergeAttrFromSelectedCells(*pSet, FALSE);
+ }
+
+ SdrTextVertAdjust eAdj = SDRTEXTVERTADJUST_BLOCK;
+
+ if( pSet->GetItemState( SDRATTR_TEXT_VERTADJUST ) != SFX_ITEM_DONTCARE )
+ eAdj = ((SdrTextVertAdjustItem&)(pSet->Get(SDRATTR_TEXT_VERTADJUST))).GetValue();
+
+ rSet.Put(SfxBoolItem(SID_TABLE_VERT_BOTTOM, eAdj == SDRTEXTVERTADJUST_BOTTOM));
+ rSet.Put(SfxBoolItem(SID_TABLE_VERT_CENTER, eAdj == SDRTEXTVERTADJUST_CENTER));
+ rSet.Put(SfxBoolItem(SID_TABLE_VERT_NONE, eAdj == SDRTEXTVERTADJUST_TOP));
+ bVertDone = true;
+ }
+ break;
+ }
+ case SID_TABLE_DELETE_ROW:
+ if( !mxTable.is() || !hasSelectedCells() || (mxTable->getRowCount() <= 1) )
+ rSet.DisableItem(SID_TABLE_DELETE_ROW);
+ break;
+ case SID_TABLE_DELETE_COL:
+ if( !mxTable.is() || !hasSelectedCells() || (mxTable->getColumnCount() <= 1) )
+ rSet.DisableItem(SID_TABLE_DELETE_COL);
+ break;
+ case SID_TABLE_MERGE_CELLS:
+ if( !mxTable.is() || !hasSelectedCells() )
+ rSet.DisableItem(SID_TABLE_MERGE_CELLS);
+ break;
+ case SID_TABLE_SPLIT_CELLS:
+ if( !hasSelectedCells() || !mxTable.is() )
+ rSet.DisableItem(SID_TABLE_SPLIT_CELLS);
+ break;
+
+ case SID_OPTIMIZE_TABLE:
+ case SID_TABLE_DISTRIBUTE_COLUMNS:
+ case SID_TABLE_DISTRIBUTE_ROWS:
+ {
+ bool bDistributeColumns = false;
+ bool bDistributeRows = false;
+ if( mxTable.is() )
+ {
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ bDistributeColumns = aStart.mnCol != aEnd.mnCol;
+ bDistributeRows = aStart.mnRow != aEnd.mnRow;
+ }
+ if( !bDistributeColumns && !bDistributeRows )
+ rSet.DisableItem(SID_OPTIMIZE_TABLE);
+ if( !bDistributeColumns )
+ rSet.DisableItem(SID_TABLE_DISTRIBUTE_COLUMNS);
+ if( !bDistributeRows )
+ rSet.DisableItem(SID_TABLE_DISTRIBUTE_ROWS);
+ break;
+ }
+
+ case SID_AUTOFORMAT:
+ case SID_TABLE_SORT_DIALOG:
+ case SID_TABLE_AUTOSUM:
+// if( !mxTable.is() )
+// rSet.DisableItem( nWhich );
+ break;
+ default:
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+ if( pSet )
+ delete pSet;
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs )
+{
+ ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ if( !pTableObj )
+ return;
+
+ if( mxTable.is() ) try
+ {
+ //
+ bool bInsertAfter = true;
+ sal_uInt16 nCount = 0;
+ if( pArgs )
+ {
+ const SfxPoolItem* pItem = 0;
+ pArgs->GetItemState(nSId, FALSE, &pItem);
+ if (pItem)
+ {
+ nCount = ((const SfxInt16Item* )pItem)->GetValue();
+ if(SFX_ITEM_SET == pArgs->GetItemState(SID_TABLE_PARAM_INSERT_AFTER, TRUE, &pItem))
+ bInsertAfter = ((const SfxBoolItem* )pItem)->GetValue();
+ }
+ }
+
+ CellPos aStart, aEnd;
+ if( hasSelectedCells() )
+ {
+ getSelectedCells( aStart, aEnd );
+ }
+ else
+ {
+ if( bInsertAfter )
+ {
+ aStart.mnCol = mxTable->getColumnCount() - 1;
+ aStart.mnRow = mxTable->getRowCount() - 1;
+ aEnd = aStart;
+ }
+ }
+
+ if( pTableObj->IsTextEditActive() )
+ mpView->SdrEndTextEdit(sal_True);
+
+ RemoveSelection();
+
+ const OUString sSize( RTL_CONSTASCII_USTRINGPARAM( "Size" ) );
+
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+
+ switch( nSId )
+ {
+ case SID_TABLE_INSERT_COL:
+ {
+ TableModelNotifyGuard aGuard( mxTable.get() );
+
+ if( bUndo )
+ {
+ mpModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
+ mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
+ }
+
+ Reference< XTableColumns > xCols( mxTable->getColumns() );
+ const sal_Int32 nNewColumns = (nCount == 0) ? (aEnd.mnCol - aStart.mnCol + 1) : nCount;
+ const sal_Int32 nNewStartColumn = aEnd.mnCol + (bInsertAfter ? 1 : 0);
+ xCols->insertByIndex( nNewStartColumn, nNewColumns );
+
+ for( sal_Int32 nOffset = 0; nOffset < nNewColumns; nOffset++ )
+ {
+ Reference< XPropertySet >( xCols->getByIndex( aEnd.mnCol + nOffset + 1 ), UNO_QUERY_THROW )->
+ setPropertyValue( sSize,
+ Reference< XPropertySet >( xCols->getByIndex( aStart.mnCol + nOffset ), UNO_QUERY_THROW )->
+ getPropertyValue( sSize ) );
+ }
+
+ if( bUndo )
+ mpModel->EndUndo();
+
+ aStart.mnCol = nNewStartColumn;
+ aStart.mnRow = 0;
+ aEnd.mnCol = aStart.mnCol + nNewColumns - 1;
+ aEnd.mnRow = mxTable->getRowCount() - 1;
+ break;
+ }
+
+ case SID_TABLE_INSERT_ROW:
+ {
+ TableModelNotifyGuard aGuard( mxTable.get() );
+
+ if( bUndo )
+ {
+ mpModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW ) );
+ mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
+ }
+
+ Reference< XTableRows > xRows( mxTable->getRows() );
+ const sal_Int32 nNewRows = (nCount == 0) ? (aEnd.mnRow - aStart.mnRow + 1) : nCount;
+ const sal_Int32 nNewRowStart = aEnd.mnRow + (bInsertAfter ? 1 : 0);
+ xRows->insertByIndex( nNewRowStart, nNewRows );
+
+ for( sal_Int32 nOffset = 0; nOffset < nNewRows; nOffset++ )
+ {
+ Reference< XPropertySet >( xRows->getByIndex( aEnd.mnRow + nOffset + 1 ), UNO_QUERY_THROW )->
+ setPropertyValue( sSize,
+ Reference< XPropertySet >( xRows->getByIndex( aStart.mnRow + nOffset ), UNO_QUERY_THROW )->
+ getPropertyValue( sSize ) );
+ }
+
+ if( bUndo )
+ mpModel->EndUndo();
+
+ aStart.mnCol = 0;
+ aStart.mnRow = nNewRowStart;
+ aEnd.mnCol = mxTable->getColumnCount() - 1;
+ aEnd.mnRow = aStart.mnRow + nNewRows - 1;
+ break;
+ }
+ }
+
+ StartSelection( aStart );
+ UpdateSelection( aEnd );
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("svx::SvxTableController::onInsert(), exception caught!");
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::onDelete( sal_uInt16 nSId )
+{
+ ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ if( !pTableObj )
+ return;
+
+ if( mxTable.is() && hasSelectedCells() )
+ {
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ if( pTableObj->IsTextEditActive() )
+ mpView->SdrEndTextEdit(sal_True);
+
+ RemoveSelection();
+
+ bool bDeleteTable = false;
+ switch( nSId )
+ {
+ case SID_TABLE_DELETE_COL:
+ {
+ const sal_Int32 nRemovedColumns = aEnd.mnCol - aStart.mnCol + 1;
+ if( nRemovedColumns == mxTable->getColumnCount() )
+ {
+ bDeleteTable = true;
+ }
+ else
+ {
+ Reference< XTableColumns > xCols( mxTable->getColumns() );
+ xCols->removeByIndex( aStart.mnCol, nRemovedColumns );
+ }
+ break;
+ }
+
+ case SID_TABLE_DELETE_ROW:
+ {
+ const sal_Int32 nRemovedRows = aEnd.mnRow - aStart.mnRow + 1;
+ if( nRemovedRows == mxTable->getRowCount() )
+ {
+ bDeleteTable = true;
+ }
+ else
+ {
+ Reference< XTableRows > xRows( mxTable->getRows() );
+ xRows->removeByIndex( aStart.mnRow, nRemovedRows );
+ }
+ break;
+ }
+ }
+
+ if( bDeleteTable )
+ mpView->DeleteMarkedObj();
+ else
+ UpdateTableShape();
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::onSelect( sal_uInt16 nSId )
+{
+ if( mxTable.is() )
+ {
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+ if( nRowCount && nColCount )
+ {
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ switch( nSId )
+ {
+ case SID_TABLE_SELECT_ALL:
+ aEnd.mnCol = 0; aEnd.mnRow = 0;
+ aStart.mnCol = nColCount - 1; aStart.mnRow = nRowCount - 1;
+ break;
+ case SID_TABLE_SELECT_COL:
+ aEnd.mnRow = nRowCount - 1;
+ aStart.mnRow = 0;
+ break;
+ case SID_TABLE_SELECT_ROW:
+ aEnd.mnCol = nColCount - 1;
+ aStart.mnCol = 0;
+ break;
+ }
+
+ StartSelection( aEnd );
+ gotoCell( aStart, true, 0 );
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+void SvxTableController::onFormatTable( SfxRequest& rReq )
+{
+ ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ if( !pTableObj )
+ return;
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if( !pArgs && pTableObj->GetModel() )
+ {
+ SfxItemSet aNewAttr( pTableObj->GetModel()->GetItemPool() );
+ MergeAttrFromSelectedCells(aNewAttr, FALSE);
+
+ // merge drawing layer text distance items into SvxBoxItem used by the dialog
+ SvxBoxItem aBoxItem( static_cast< const SvxBoxItem& >( aNewAttr.Get( SDRATTR_TABLE_BORDER ) ) );
+ aBoxItem.SetDistance( sal::static_int_cast< USHORT >( ((SdrTextLeftDistItem&)(aNewAttr.Get(SDRATTR_TEXT_LEFTDIST))).GetValue()), BOX_LINE_LEFT );
+ aBoxItem.SetDistance( sal::static_int_cast< USHORT >( ((SdrTextRightDistItem&)(aNewAttr.Get(SDRATTR_TEXT_RIGHTDIST))).GetValue()), BOX_LINE_RIGHT );
+ aBoxItem.SetDistance( sal::static_int_cast< USHORT >( ((SdrTextUpperDistItem&)(aNewAttr.Get(SDRATTR_TEXT_UPPERDIST))).GetValue()), BOX_LINE_TOP );
+ aBoxItem.SetDistance( sal::static_int_cast< USHORT >( ((SdrTextLowerDistItem&)(aNewAttr.Get(SDRATTR_TEXT_LOWERDIST))).GetValue()), BOX_LINE_BOTTOM );
+ aNewAttr.Put( aBoxItem );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ std::auto_ptr< SfxAbstractTabDialog > pDlg( pFact ? pFact->CreateSvxFormatCellsDialog( NULL, &aNewAttr, pTableObj->GetModel(), pTableObj) : 0 );
+ if( pDlg.get() && pDlg->Execute() )
+ {
+ SfxItemSet aNewSet( *(pDlg->GetOutputItemSet ()) );
+
+ SvxBoxItem aNewBoxItem( static_cast< const SvxBoxItem& >( aNewSet.Get( SDRATTR_TABLE_BORDER ) ) );
+
+ if( aNewBoxItem.GetDistance( BOX_LINE_LEFT ) != aBoxItem.GetDistance( BOX_LINE_LEFT ) )
+ aNewSet.Put(SdrTextLeftDistItem( aNewBoxItem.GetDistance( BOX_LINE_LEFT ) ) );
+
+ if( aNewBoxItem.GetDistance( BOX_LINE_RIGHT ) != aBoxItem.GetDistance( BOX_LINE_RIGHT ) )
+ aNewSet.Put(SdrTextRightDistItem( aNewBoxItem.GetDistance( BOX_LINE_RIGHT ) ) );
+
+ if( aNewBoxItem.GetDistance( BOX_LINE_TOP ) != aBoxItem.GetDistance( BOX_LINE_TOP ) )
+ aNewSet.Put(SdrTextUpperDistItem( aNewBoxItem.GetDistance( BOX_LINE_TOP ) ) );
+
+ if( aNewBoxItem.GetDistance( BOX_LINE_BOTTOM ) != aBoxItem.GetDistance( BOX_LINE_BOTTOM ) )
+ aNewSet.Put(SdrTextLowerDistItem( aNewBoxItem.GetDistance( BOX_LINE_BOTTOM ) ) );
+
+ SetAttrToSelectedCells(aNewSet, FALSE);
+ }
+ UpdateTableShape();
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::Execute( SfxRequest& rReq )
+{
+ const sal_uInt16 nSId = rReq.GetSlot();
+ switch( nSId )
+ {
+ case SID_TABLE_INSERT_ROW:
+ case SID_TABLE_INSERT_COL:
+ onInsert( nSId, rReq.GetArgs() );
+ break;
+ case SID_TABLE_DELETE_ROW:
+ case SID_TABLE_DELETE_COL:
+ onDelete( nSId );
+ break;
+ case SID_TABLE_SELECT_ALL:
+ case SID_TABLE_SELECT_COL:
+ case SID_TABLE_SELECT_ROW:
+ onSelect( nSId );
+ break;
+ case SID_FORMAT_TABLE_DLG:
+ onFormatTable( rReq );
+ break;
+
+ case SID_FRAME_LINESTYLE:
+ case SID_FRAME_LINECOLOR:
+ case SID_ATTR_BORDER:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if( pArgs )
+ ApplyBorderAttr( *pArgs );
+ }
+ break;
+
+ case SID_ATTR_FILL_STYLE:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if( pArgs )
+ SetAttributes( *pArgs, false );
+ }
+ break;
+
+ case SID_TABLE_MERGE_CELLS:
+ MergeMarkedCells();
+ break;
+
+ case SID_TABLE_SPLIT_CELLS:
+ SplitMarkedCells();
+ break;
+
+ case SID_TABLE_DISTRIBUTE_COLUMNS:
+ DistributeColumns();
+ break;
+
+ case SID_TABLE_DISTRIBUTE_ROWS:
+ DistributeRows();
+ break;
+
+ case SID_TABLE_VERT_BOTTOM:
+ case SID_TABLE_VERT_CENTER:
+ case SID_TABLE_VERT_NONE:
+ SetVertical( nSId );
+ break;
+
+ case SID_AUTOFORMAT:
+ case SID_TABLE_SORT_DIALOG:
+ case SID_TABLE_AUTOSUM:
+ default:
+ break;
+
+ case SID_TABLE_STYLE:
+ SetTableStyle( rReq.GetArgs() );
+ break;
+
+ case SID_TABLE_STYLE_SETTINGS:
+ SetTableStyleSettings( rReq.GetArgs() );
+ break;
+ }
+}
+
+void SvxTableController::SetTableStyle( const SfxItemSet* pArgs )
+{
+ SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ SdrModel* pModel = pTableObj ? pTableObj->GetModel() : 0;
+
+ if( !pTableObj || !pModel || !pArgs || (SFX_ITEM_SET != pArgs->GetItemState(SID_TABLE_STYLE, FALSE)) )
+ return;
+
+ const SfxStringItem* pArg = dynamic_cast< const SfxStringItem* >( &pArgs->Get( SID_TABLE_STYLE ) );
+ if( pArg && mxTable.is() ) try
+ {
+ Reference< XStyleFamiliesSupplier > xSFS( pModel->getUnoModel(), UNO_QUERY_THROW );
+ Reference< XNameAccess > xFamilyNameAccess( xSFS->getStyleFamilies(), UNO_QUERY_THROW );
+ const OUString sFamilyName( RTL_CONSTASCII_USTRINGPARAM( "table" ) );
+ Reference< XNameAccess > xTableFamilyAccess( xFamilyNameAccess->getByName( sFamilyName ), UNO_QUERY_THROW );
+
+ if( xTableFamilyAccess->hasByName( pArg->GetValue() ) )
+ {
+ // found table style with the same name
+ Reference< XIndexAccess > xNewTableStyle( xTableFamilyAccess->getByName( pArg->GetValue() ), UNO_QUERY_THROW );
+
+ const bool bUndo = pModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE) );
+ pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ }
+
+ pTableObj->setTableStyle( xNewTableStyle );
+
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+ for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
+ {
+ for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ ) try
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() )
+ {
+ SfxItemSet aSet( xCell->GetItemSet() );
+ bool bChanges = false;
+ const SfxItemSet& rStyleAttribs = xCell->GetStyleSheet()->GetItemSet();
+
+ for ( USHORT nWhich = SDRATTR_START; nWhich <= SDRATTR_TABLE_LAST; nWhich++ )
+ {
+ if( (rStyleAttribs.GetItemState( nWhich ) == SFX_ITEM_ON) && (aSet.GetItemState( nWhich ) == SFX_ITEM_ON) )
+ {
+ aSet.ClearItem( nWhich );
+ bChanges = true;
+ }
+ }
+
+ if( bChanges )
+ {
+ if( bUndo )
+ xCell->AddUndo();
+
+ xCell->SetMergedItemSetAndBroadcast( aSet, sal_True );
+ }
+ }
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR( "svx::SvxTableController::SetTableStyle(), exception caught!" );
+ }
+ }
+
+ if( bUndo )
+ pModel->EndUndo();
+ }
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR( "svx::SvxTableController::SetTableStyle(), exception caught!" );
+ }
+}
+
+void SvxTableController::SetTableStyleSettings( const SfxItemSet* pArgs )
+{
+ SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ SdrModel* pModel = pTableObj ? pTableObj->GetModel() : 0;
+
+ if( !pTableObj || !pModel )
+ return;
+
+ TableStyleSettings aSettings( pTableObj->getTableStyleSettings() );
+
+ const SfxPoolItem *pPoolItem=NULL;
+
+ if( (SFX_ITEM_SET == pArgs->GetItemState(ID_VAL_USEFIRSTROWSTYLE, FALSE,&pPoolItem)) )
+ aSettings.mbUseFirstRow = static_cast< const SfxBoolItem* >(pPoolItem)->GetValue();
+
+ if( (SFX_ITEM_SET == pArgs->GetItemState(ID_VAL_USELASTROWSTYLE, FALSE,&pPoolItem)) )
+ aSettings.mbUseLastRow = static_cast< const SfxBoolItem* >(pPoolItem)->GetValue();
+
+ if( (SFX_ITEM_SET == pArgs->GetItemState(ID_VAL_USEBANDINGROWSTYLE, FALSE,&pPoolItem)) )
+ aSettings.mbUseRowBanding = static_cast< const SfxBoolItem* >(pPoolItem)->GetValue();
+
+ if( (SFX_ITEM_SET == pArgs->GetItemState(ID_VAL_USEFIRSTCOLUMNSTYLE, FALSE,&pPoolItem)) )
+ aSettings.mbUseFirstColumn = static_cast< const SfxBoolItem* >(pPoolItem)->GetValue();
+
+ if( (SFX_ITEM_SET == pArgs->GetItemState(ID_VAL_USELASTCOLUMNSTYLE, FALSE,&pPoolItem)) )
+ aSettings.mbUseLastColumn = static_cast< const SfxBoolItem* >(pPoolItem)->GetValue();
+
+ if( (SFX_ITEM_SET == pArgs->GetItemState(ID_VAL_USEBANDINGCOLUMNSTYLE, FALSE,&pPoolItem)) )
+ aSettings.mbUseColumnBanding = static_cast< const SfxBoolItem* >(pPoolItem)->GetValue();
+
+ if( aSettings == pTableObj->getTableStyleSettings() )
+ return;
+
+ const bool bUndo = pModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ pModel->BegUndo( ImpGetResStr(STR_TABLE_STYLE_SETTINGS) );
+ pModel->AddUndo( new TableStyleUndo( *pTableObj ) );
+ }
+
+ pTableObj->setTableStyleSettings( aSettings );
+
+ if( bUndo )
+ pModel->EndUndo();
+}
+
+void SvxTableController::SetVertical( sal_uInt16 nSId )
+{
+ SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ if( mxTable.is() && pTableObj )
+ {
+ TableModelNotifyGuard aGuard( mxTable.get() );
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ SdrTextVertAdjust eAdj = SDRTEXTVERTADJUST_TOP;
+
+ switch( nSId )
+ {
+ case SID_TABLE_VERT_BOTTOM:
+ eAdj = SDRTEXTVERTADJUST_BOTTOM;
+ break;
+ case SID_TABLE_VERT_CENTER:
+ eAdj = SDRTEXTVERTADJUST_CENTER;
+ break;
+ //case SID_TABLE_VERT_NONE:
+ default:
+ break;
+ }
+
+ SdrTextVertAdjustItem aItem( eAdj );
+
+ for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ {
+ for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() )
+ xCell->SetMergedItem(aItem);
+ }
+ }
+
+ UpdateTableShape();
+ }
+}
+
+void SvxTableController::MergeMarkedCells()
+{
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ if( pTableObj )
+ {
+ if( pTableObj->IsTextEditActive() )
+ mpView->SdrEndTextEdit(sal_True);
+
+ TableModelNotifyGuard aGuard( mxTable.get() );
+ MergeRange( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow );
+ }
+}
+
+void SvxTableController::SplitMarkedCells()
+{
+ if( mxTable.is() )
+ {
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ std::auto_ptr< SvxAbstractSplittTableDialog > xDlg( pFact ? pFact->CreateSvxSplittTableDialog( NULL, false, 99, 99 ) : 0 );
+ if( xDlg.get() && xDlg->Execute() )
+ {
+ const sal_Int32 nCount = xDlg->GetCount() - 1;
+ if( nCount < 1 )
+ return;
+
+ getSelectedCells( aStart, aEnd );
+
+ Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) ), UNO_QUERY_THROW );
+
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+
+
+ SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() );
+ if( pTableObj )
+ {
+ if( pTableObj->IsTextEditActive() )
+ mpView->SdrEndTextEdit(sal_True);
+
+ TableModelNotifyGuard aGuard( mxTable.get() );
+
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
+ {
+ mpModel->BegUndo( ImpGetResStr(STR_TABLE_SPLIT) );
+ mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
+ }
+
+ if( xDlg->IsHorizontal() )
+ {
+ xRange->split( 0, nCount );
+ }
+ else
+ {
+ xRange->split( nCount, 0 );
+ }
+
+ if( bUndo )
+ mpModel->EndUndo();
+ }
+ aEnd.mnRow += mxTable->getRowCount() - nRowCount;
+ aEnd.mnCol += mxTable->getColumnCount() - nColCount;
+
+ setSelectedCells( aStart, aEnd );
+ }
+ }
+}
+
+void SvxTableController::DistributeColumns()
+{
+ SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() );
+ if( pTableObj )
+ {
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
+ {
+ mpModel->BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_COLUMNS) );
+ mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
+ }
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ pTableObj->DistributeColumns( aStart.mnCol, aEnd.mnCol );
+
+ if( bUndo )
+ mpModel->EndUndo();
+ }
+}
+
+void SvxTableController::DistributeRows()
+{
+ SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() );
+ if( pTableObj )
+ {
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
+ {
+ mpModel->BegUndo( ImpGetResStr(STR_TABLE_DISTRIBUTE_ROWS) );
+ mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*pTableObj) );
+ }
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ pTableObj->DistributeRows( aStart.mnRow, aEnd.mnRow );
+
+ if( bUndo )
+ mpModel->EndUndo();
+ }
+}
+
+bool SvxTableController::DeleteMarked()
+{
+ if( mbCellSelectionMode )
+ {
+ if( mxTable.is() )
+ {
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ {
+ for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() )
+ xCell->SetOutlinerParaObject( 0 );
+ }
+ }
+
+ UpdateTableShape();
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool SvxTableController::GetStyleSheet( SfxStyleSheet*& rpStyleSheet ) const
+{
+ if( hasSelectedCells() )
+ {
+ rpStyleSheet = 0;
+
+ if( mxTable.is() )
+ {
+ SfxStyleSheet* pRet=0;
+ bool b1st=true;
+
+ CellPos aStart, aEnd;
+ const_cast<SvxTableController&>(*this).getSelectedCells( aStart, aEnd );
+
+ for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ {
+ for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() )
+ {
+ SfxStyleSheet* pSS=xCell->GetStyleSheet();
+ if(b1st)
+ {
+ pRet=pSS;
+ }
+ else if(pRet != pSS)
+ {
+ return true;
+ }
+ b1st=false;
+ }
+ }
+ }
+ rpStyleSheet = pRet;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool SvxTableController::SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr )
+{
+ if( hasSelectedCells() && (!pStyleSheet || pStyleSheet->GetFamily() == SFX_STYLE_FAMILY_FRAME) )
+ {
+ if( mxTable.is() )
+ {
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ {
+ for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() )
+ xCell->SetStyleSheet(pStyleSheet,bDontRemoveHardAttr);
+ }
+ }
+
+ UpdateTableShape();
+ return true;
+ }
+ }
+ return false;
+}
+
+// --------------------------------------------------------------------
+// internals
+// --------------------------------------------------------------------
+
+bool SvxTableController::checkTableObject()
+{
+ return mxTableObj.is();
+}
+
+// --------------------------------------------------------------------
+
+sal_uInt16 SvxTableController::getKeyboardAction( const KeyEvent& rKEvt, Window* /*pWindow*/ )
+{
+ const bool bMod1 = rKEvt.GetKeyCode().IsMod1(); // ctrl
+ const bool bMod2 = rKEvt.GetKeyCode().IsMod2() != 0; // Alt
+
+ const bool bTextEdit = mpView->IsTextEdit();
+
+ sal_uInt16 nAction = ACTION_HANDLED_BY_VIEW;
+
+ ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ if( !pTableObj )
+ return nAction;
+
+ // handle special keys
+ const sal_Int16 nCode = rKEvt.GetKeyCode().GetCode();
+ switch( nCode )
+ {
+ case awt::Key::ESCAPE: // handle escape
+ {
+ if( bTextEdit )
+ {
+ // escape during text edit ends text edit
+ nAction = ACTION_STOP_TEXT_EDIT;
+ }
+ if( mbCellSelectionMode )
+ {
+ // escape with selected cells removes selection
+ nAction = ACTION_REMOVE_SELECTION;
+ }
+ break;
+ }
+ case awt::Key::RETURN: // handle return
+ {
+ if( !bMod1 && !bMod2 && !bTextEdit )
+ {
+ // when not already editing, return starts text edit
+ setSelectionStart( pTableObj->getFirstCell() );
+ nAction = ACTION_EDIT_CELL;
+ }
+ break;
+ }
+ case awt::Key::F2: // f2 toggles text edit
+ {
+ if( bMod1 || bMod2 ) // f2 with modifiers is handled by the view
+ {
+ }
+ else if( bTextEdit )
+ {
+ // f2 during text edit stops text edit
+ nAction = ACTION_STOP_TEXT_EDIT;
+ }
+ else if( mbCellSelectionMode )
+ {
+ // f2 with selected cells removes selection
+ nAction = ACTION_REMOVE_SELECTION;
+ }
+ else
+ {
+ // f2 with no selection and no text edit starts text edit
+ setSelectionStart( pTableObj->getFirstCell() );
+ nAction = ACTION_EDIT_CELL;
+ }
+ break;
+ }
+ case awt::Key::HOME:
+ case awt::Key::NUM7:
+ {
+ if( (bMod1 || bMod2) && (bTextEdit || mbCellSelectionMode) )
+ {
+ if( bMod1 && !bMod2 )
+ {
+ // strg + home jumps to first cell
+ nAction = ACTION_GOTO_FIRST_CELL;
+ }
+ else if( !bMod1 && bMod2 )
+ {
+ // alt + home jumps to first column
+ nAction = ACTION_GOTO_FIRST_COLUMN;
+ }
+ }
+ break;
+ }
+ case awt::Key::END:
+ case awt::Key::NUM1:
+ {
+ if( (bMod1 || bMod2) && (bTextEdit || mbCellSelectionMode) )
+ {
+ if( bMod1 && !bMod2 )
+ {
+ // strg + end jumps to last cell
+ nAction = ACTION_GOTO_LAST_CELL;
+ }
+ else if( !bMod1 && bMod2 )
+ {
+ // alt + home jumps to last column
+ nAction = ACTION_GOTO_LAST_COLUMN;
+ }
+ }
+ break;
+ }
+
+ case awt::Key::TAB:
+ {
+ if( bTextEdit || mbCellSelectionMode )
+ nAction = ACTION_TAB;
+ break;
+ }
+
+ case awt::Key::UP:
+ case awt::Key::NUM8:
+ case awt::Key::DOWN:
+ case awt::Key::NUM2:
+ case awt::Key::LEFT:
+ case awt::Key::NUM4:
+ case awt::Key::RIGHT:
+ case awt::Key::NUM6:
+ {
+ bool bTextMove = false;
+
+ if( !bMod1 && bMod2 )
+ {
+ if( (nCode == awt::Key::UP) || (nCode == awt::Key::NUM8) )
+ {
+ nAction = ACTION_GOTO_LEFT_CELL;
+ }
+ else if( (nCode == awt::Key::DOWN) || (nCode == awt::Key::NUM2) )
+ {
+ nAction = ACTION_GOTO_RIGHT_CELL;
+ }
+ break;
+ }
+
+ if( !bTextMove )
+ {
+ OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+ if( pOLV )
+ {
+ RemoveSelection();
+ // during text edit, check if we navigate out of the cell
+ ESelection aOldSelection = pOLV->GetSelection();
+ pOLV->PostKeyEvent(rKEvt);
+ bTextMove = pOLV && ( aOldSelection.IsEqual(pOLV->GetSelection()) );
+ if( !bTextMove )
+ {
+ nAction = ACTION_NONE;
+ }
+ }
+ }
+
+ if( mbCellSelectionMode || bTextMove )
+ {
+ // no text edit, navigate in cells if selection active
+ switch( nCode )
+ {
+ case awt::Key::LEFT:
+ case awt::Key::NUM4:
+ nAction = ACTION_GOTO_LEFT_CELL;
+ break;
+ case awt::Key::RIGHT:
+ case awt::Key::NUM6:
+ nAction = ACTION_GOTO_RIGHT_CELL;
+ break;
+ case awt::Key::DOWN:
+ case awt::Key::NUM2:
+ nAction = ACTION_GOTO_DOWN_CELL;
+ break;
+ case awt::Key::UP:
+ case awt::Key::NUM8:
+ nAction = ACTION_GOTO_UP_CELL;
+ break;
+ }
+ }
+ break;
+ }
+ case awt::Key::PAGEUP:
+ if( bMod2 )
+ nAction = ACTION_GOTO_FIRST_ROW;
+ break;
+
+ case awt::Key::PAGEDOWN:
+ if( bMod2 )
+ nAction = ACTION_GOTO_LAST_ROW;
+ break;
+ }
+ return nAction;
+}
+
+bool SvxTableController::executeAction( sal_uInt16 nAction, bool bSelect, Window* pWindow )
+{
+ ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ if( !pTableObj )
+ return false;
+
+ switch( nAction )
+ {
+ case ACTION_GOTO_FIRST_CELL:
+ {
+ gotoCell( pTableObj->getFirstCell(), bSelect, pWindow, nAction );
+ break;
+ }
+
+ case ACTION_GOTO_LEFT_CELL:
+ {
+ gotoCell( pTableObj->getLeftCell( getSelectionEnd(), !bSelect ), bSelect, pWindow, nAction );
+ break;
+ }
+
+ case ACTION_GOTO_RIGHT_CELL:
+ {
+ gotoCell( pTableObj->getRightCell( getSelectionEnd(), !bSelect ), bSelect, pWindow, nAction);
+ break;
+ }
+
+ case ACTION_GOTO_LAST_CELL:
+ {
+ gotoCell( pTableObj->getLastCell(), bSelect, pWindow, nAction );
+ break;
+ }
+
+ case ACTION_GOTO_FIRST_COLUMN:
+ {
+ CellPos aPos( pTableObj->getFirstCell().mnCol, getSelectionEnd().mnRow );
+ gotoCell( aPos, bSelect, pWindow, nAction );
+ break;
+ }
+
+ case ACTION_GOTO_LAST_COLUMN:
+ {
+ CellPos aPos( pTableObj->getLastCell().mnCol, getSelectionEnd().mnRow );
+ gotoCell( aPos, bSelect, pWindow, nAction );
+ break;
+ }
+
+ case ACTION_GOTO_FIRST_ROW:
+ {
+ CellPos aPos( getSelectionEnd().mnCol, pTableObj->getFirstCell().mnRow );
+ gotoCell( aPos, bSelect, pWindow, nAction );
+ break;
+ }
+
+ case ACTION_GOTO_UP_CELL:
+ {
+ gotoCell( pTableObj->getUpCell(getSelectionEnd(), !bSelect), bSelect, pWindow, nAction );
+ break;
+ }
+
+ case ACTION_GOTO_DOWN_CELL:
+ {
+ gotoCell( pTableObj->getDownCell(getSelectionEnd(), !bSelect), bSelect, pWindow, nAction );
+ break;
+ }
+
+ case ACTION_GOTO_LAST_ROW:
+ {
+ CellPos aPos( getSelectionEnd().mnCol, pTableObj->getLastCell().mnRow );
+ gotoCell( aPos, bSelect, pWindow, nAction );
+ break;
+ }
+
+ case ACTION_EDIT_CELL:
+ EditCell( getSelectionStart(), pWindow, 0, nAction );
+ break;
+
+ case ACTION_STOP_TEXT_EDIT:
+ StopTextEdit();
+ break;
+
+ case ACTION_REMOVE_SELECTION:
+ RemoveSelection();
+ break;
+
+ case ACTION_START_SELECTION:
+ StartSelection( getSelectionStart() );
+ break;
+
+ case ACTION_TAB:
+ {
+ if( bSelect )
+ gotoCell( pTableObj->getPreviousCell( getSelectionEnd(), true ), false, pWindow, nAction );
+ else
+ {
+ CellPos aSelectionEnd( getSelectionEnd() );
+ CellPos aNextCell( pTableObj->getNextCell( aSelectionEnd, true ) );
+ if( aSelectionEnd == aNextCell )
+ {
+ onInsert( SID_TABLE_INSERT_ROW, 0 );
+ aNextCell = pTableObj->getNextCell( aSelectionEnd, true );
+ }
+ gotoCell( aNextCell, false, pWindow, nAction );
+ }
+ break;
+ }
+ }
+
+ return nAction != ACTION_HANDLED_BY_VIEW;
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::gotoCell( const CellPos& rPos, bool bSelect, Window* pWindow, sal_uInt16 nAction )
+{
+ if( mxTableObj.is() && static_cast<SdrTableObj*>(mxTableObj.get())->IsTextEditActive() )
+ mpView->SdrEndTextEdit(sal_True);
+
+ if( bSelect )
+ {
+ maCursorLastPos = rPos;
+ if( mxTableObj.is() )
+ static_cast< SdrTableObj* >( mxTableObj.get() )->setActiveCell( rPos );
+
+ if( !mbCellSelectionMode )
+ {
+ setSelectedCells( maCursorFirstPos, rPos );
+ }
+ else
+ {
+ UpdateSelection( rPos );
+ }
+ }
+ else
+ {
+ RemoveSelection();
+ EditCell( rPos, pWindow, 0, nAction );
+ }
+}
+
+// --------------------------------------------------------------------
+
+const CellPos& SvxTableController::getSelectionStart()
+{
+ checkCell( maCursorFirstPos );
+ return maCursorFirstPos;
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::setSelectionStart( const CellPos& rPos )
+{
+ maCursorFirstPos = rPos;
+}
+
+// --------------------------------------------------------------------
+
+const CellPos& SvxTableController::getSelectionEnd()
+{
+ checkCell( maCursorLastPos );
+ return maCursorLastPos;
+}
+
+// --------------------------------------------------------------------
+
+Reference< XCellCursor > SvxTableController::getSelectionCursor()
+{
+ Reference< XCellCursor > xCursor;
+
+ if( mxTable.is() )
+ {
+ if( hasSelectedCells() )
+ {
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+ xCursor = mxTable->createCursorByRange( mxTable->getCellRangeByPosition( aStart.mnCol, aStart.mnRow, aEnd.mnCol, aEnd.mnRow ) );
+ }
+ else
+ {
+ xCursor = mxTable->createCursor();
+ }
+ }
+
+ return xCursor;
+}
+
+void SvxTableController::MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow )
+{
+ if( mxTable.is() ) try
+ {
+ Reference< XMergeableCellRange > xRange( mxTable->createCursorByRange( mxTable->getCellRangeByPosition( nFirstCol, nFirstRow,nLastCol, nLastRow ) ), UNO_QUERY_THROW );
+ if( xRange->isMergeable() )
+ {
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+ if( bUndo )
+ {
+ mpModel->BegUndo( ImpGetResStr(STR_TABLE_MERGE) );
+ mpModel->AddUndo( mpModel->GetSdrUndoFactory().CreateUndoGeoObject(*mxTableObj.get()) );
+ }
+
+ xRange->merge();
+
+ if( bUndo )
+ mpModel->EndUndo();
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ASSERT( false, "sdr::table::SvxTableController::MergeRange(), exception caught!" );
+ }
+}
+
+
+
+// --------------------------------------------------------------------
+
+void SvxTableController::checkCell( CellPos& rPos )
+{
+ if( mxTable.is() ) try
+ {
+ if( rPos.mnCol >= mxTable->getColumnCount() )
+ rPos.mnCol = mxTable->getColumnCount()-1;
+
+ if( rPos.mnRow >= mxTable->getRowCount() )
+ rPos.mnRow = mxTable->getRowCount()-1;
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("sdr::table::SvxTableController::checkCell(), exception caught!" );
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::findMergeOrigin( CellPos& rPos )
+{
+ if( mxTable.is() ) try
+ {
+ Reference< XMergeableCell > xCell( mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ), UNO_QUERY_THROW );
+ if( xCell.is() && xCell->isMerged() )
+ {
+ ::findMergeOrigin( mxTable, rPos.mnCol, rPos.mnRow, rPos.mnCol, rPos.mnRow );
+ }
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("sdr::table::SvxTableController::findMergeOrigin(), exception caught!" );
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::EditCell( const CellPos& rPos, ::Window* pWindow, const awt::MouseEvent* pMouseEvent /*= 0*/, sal_uInt16 nAction /*= ACTION_NONE */ )
+{
+ SdrPageView* pPV = mpView->GetSdrPageView();
+
+ ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ if( pTableObj && pTableObj->GetPage() == pPV->GetPage() )
+ {
+ bool bEmptyOutliner = false;
+
+ if(!pTableObj->GetOutlinerParaObject() && mpView->GetTextEditOutliner())
+ {
+ ::Outliner* pOutl = mpView->GetTextEditOutliner();
+ ULONG nParaAnz = pOutl->GetParagraphCount();
+ Paragraph* p1stPara = pOutl->GetParagraph( 0 );
+
+ if(nParaAnz==1 && p1stPara)
+ {
+ // Bei nur einem Pararaph
+ if (pOutl->GetText(p1stPara).Len() == 0)
+ {
+ bEmptyOutliner = true;
+ }
+ }
+ }
+
+ CellPos aPos( rPos );
+ findMergeOrigin( aPos );
+
+ if( pTableObj != mpView->GetTextEditObject() || bEmptyOutliner || !pTableObj->IsTextEditActive( aPos ) )
+ {
+ if( pTableObj->IsTextEditActive() )
+ mpView->SdrEndTextEdit(sal_True);
+
+ pTableObj->setActiveCell( aPos );
+
+ // create new outliner, owner will be the SdrObjEditView
+ SdrOutliner* pOutl = SdrMakeOutliner( OUTLINERMODE_OUTLINEOBJECT, mpModel );
+ if( pTableObj->IsVerticalWriting() )
+ pOutl->SetVertical( TRUE );
+
+ if(mpView->SdrBeginTextEdit(pTableObj, pPV, pWindow, sal_True, pOutl))
+ {
+ maCursorLastPos = maCursorFirstPos = rPos;
+
+ OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+
+ bool bNoSel = true;
+
+ if( pMouseEvent )
+ {
+ ::MouseEvent aMEvt( *pMouseEvent );
+
+ SdrViewEvent aVEvt;
+ SdrHitKind eHit = mpView->PickAnything(aMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
+
+ if (eHit == SDRHIT_TEXTEDIT)
+ {
+ // Text getroffen
+ pOLV->MouseButtonDown(aMEvt);
+ pOLV->MouseMove(aMEvt);
+ pOLV->MouseButtonUp(aMEvt);
+// pOLV->MouseButtonDown(aMEvt);
+ bNoSel = false;
+ }
+ else
+ {
+ nAction = ACTION_GOTO_LEFT_CELL;
+ }
+ }
+
+ if( bNoSel )
+ {
+ // Move cursor to end of text
+ ESelection aNewSelection;
+
+ const WritingMode eMode = pTableObj->GetWritingMode();
+ if( ((nAction == ACTION_GOTO_LEFT_CELL) || (nAction == ACTION_GOTO_RIGHT_CELL)) && (eMode != WritingMode_TB_RL) )
+ {
+ const bool bLast = ((nAction == ACTION_GOTO_LEFT_CELL) && (eMode == WritingMode_LR_TB)) ||
+ ((nAction == ACTION_GOTO_RIGHT_CELL) && (eMode == WritingMode_RL_TB));
+
+ if( bLast )
+ aNewSelection = ESelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
+ }
+ pOLV->SetSelection(aNewSelection);
+ }
+ }
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+bool SvxTableController::StopTextEdit()
+{
+ if(mpView->IsTextEdit())
+ {
+ mpView->SdrEndTextEdit();
+ mpView->SetCurrentObj(OBJ_TABLE);
+ mpView->SetEditMode(SDREDITMODE_EDIT);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::DeleteTable()
+{
+ //
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::getSelectedCells( CellPos& rFirst, CellPos& rLast )
+{
+ if( mbCellSelectionMode )
+ {
+ checkCell( maCursorFirstPos );
+ checkCell( maCursorLastPos );
+
+ rFirst.mnCol = std::min( maCursorFirstPos.mnCol, maCursorLastPos.mnCol );
+ rFirst.mnRow = std::min( maCursorFirstPos.mnRow, maCursorLastPos.mnRow );
+ rLast.mnCol = std::max( maCursorFirstPos.mnCol, maCursorLastPos.mnCol );
+ rLast.mnRow = std::max( maCursorFirstPos.mnRow, maCursorLastPos.mnRow );
+
+ bool bExt = false;
+ if( mxTable.is() ) do
+ {
+ bExt = false;
+ for( sal_Int32 nRow = rFirst.mnRow; nRow <= rLast.mnRow && !bExt; nRow++ )
+ {
+ for( sal_Int32 nCol = rFirst.mnCol; nCol <= rLast.mnCol && !bExt; nCol++ )
+ {
+ Reference< XMergeableCell > xCell( mxTable->getCellByPosition( nCol, nRow ), UNO_QUERY );
+ if( !xCell.is() )
+ continue;
+
+ if( xCell->isMerged() )
+ {
+ CellPos aPos( nCol, nRow );
+ findMergeOrigin( aPos );
+ if( (aPos.mnCol < rFirst.mnCol) || (aPos.mnRow < rFirst.mnRow) )
+ {
+ rFirst.mnCol = std::min( rFirst.mnCol, aPos.mnCol );
+ rFirst.mnRow = std::min( rFirst.mnRow, aPos.mnRow );
+ bExt = true;
+ }
+ }
+ else
+ {
+ if( ((nCol + xCell->getColumnSpan() - 1) > rLast.mnCol) || (nRow + xCell->getRowSpan() - 1 ) > rLast.mnRow )
+ {
+ rLast.mnCol = std::max( rLast.mnCol, nCol + xCell->getColumnSpan() - 1 );
+ rLast.mnRow = std::max( rLast.mnRow, nRow + xCell->getRowSpan() - 1 );
+ bExt = true;
+ }
+ }
+ }
+ }
+ }
+ while(bExt);
+ }
+ else if( mpView && mpView->IsTextEdit() )
+ {
+ rFirst = getSelectionStart();
+ findMergeOrigin( rFirst );
+ rLast = rFirst;
+
+ if( mxTable.is() )
+ {
+ Reference< XMergeableCell > xCell( mxTable->getCellByPosition( rLast.mnCol, rLast.mnRow ), UNO_QUERY );
+ if( xCell.is() )
+ {
+ rLast.mnCol += xCell->getColumnSpan() - 1;
+ rLast.mnRow += xCell->getRowSpan() - 1;
+ }
+ }
+ }
+ else
+ {
+ rFirst.mnCol = 0;
+ rFirst.mnRow = 0;
+ if( mxTable.is() )
+ {
+ rLast.mnRow = mxTable->getRowCount()-1;
+ rLast.mnCol = mxTable->getColumnCount()-1;
+ }
+ else
+ {
+ rLast.mnRow = 0;
+ rLast.mnCol = 0;
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::StartSelection( const CellPos& rPos )
+{
+ StopTextEdit();
+ mbCellSelectionMode = true;
+ maCursorLastPos = maCursorFirstPos = rPos;
+ mpView->MarkListHasChanged();
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::setSelectedCells( const CellPos& rStart, const CellPos& rEnd )
+{
+ StopTextEdit();
+ mbCellSelectionMode = true;
+ maCursorFirstPos = rStart;
+ UpdateSelection( rEnd );
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::UpdateSelection( const CellPos& rPos )
+{
+ maCursorLastPos = rPos;
+ mpView->MarkListHasChanged();
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::clearSelection()
+{
+ RemoveSelection();
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::selectAll()
+{
+ if( mxTable.is() )
+ {
+ CellPos aPos1, aPos2( mxTable->getColumnCount()-1, mxTable->getRowCount()-1 );
+ if( (aPos2.mnCol >= 0) && (aPos2.mnRow >= 0) )
+ {
+ setSelectedCells( aPos1, aPos2 );
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::RemoveSelection()
+{
+ if( mbCellSelectionMode )
+ {
+ mbCellSelectionMode = false;
+ mpView->MarkListHasChanged();
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::onTableModified()
+{
+ if( mnUpdateEvent == 0 )
+ mnUpdateEvent = Application::PostUserEvent( LINK( this, SvxTableController, UpdateHdl ) );
+}
+// --------------------------------------------------------------------
+
+void SvxTableController::updateSelectionOverlay()
+{
+ destroySelectionOverlay();
+ if( mbCellSelectionMode )
+ {
+ ::sdr::table::SdrTableObj* pTableObj = dynamic_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+ if( pTableObj )
+ {
+ sdr::overlay::OverlayObjectCell::RangeVector aRanges;
+
+ Rectangle aRect;
+ CellPos aStart,aEnd;
+ getSelectedCells( aStart, aEnd );
+ pTableObj->getCellBounds( aStart, aRect );
+
+ basegfx::B2DRange a2DRange( basegfx::B2DPoint(aRect.Left(), aRect.Top()) );
+ a2DRange.expand( basegfx::B2DPoint(aRect.Right(), aRect.Bottom()) );
+
+ findMergeOrigin( aEnd );
+ pTableObj->getCellBounds( aEnd, aRect );
+ a2DRange.expand( basegfx::B2DPoint(aRect.Left(), aRect.Top()) );
+ a2DRange.expand( basegfx::B2DPoint(aRect.Right(), aRect.Bottom()) );
+ aRanges.push_back( a2DRange );
+
+ ::Color aHighlight( COL_BLUE );
+ OutputDevice* pOutDev = mpView->GetFirstOutputDevice();
+ if( pOutDev )
+ aHighlight = pOutDev->GetSettings().GetStyleSettings().GetHighlightColor();
+
+ const sal_uInt32 nCount = mpView->PaintWindowCount();
+ for( sal_uInt32 nIndex = 0; nIndex < nCount; nIndex++ )
+ {
+ SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(nIndex);
+ if( pPaintWindow )
+ {
+ ::sdr::overlay::OverlayManager* pOverlayManager = pPaintWindow->GetOverlayManager();
+ if( pOverlayManager )
+ {
+ // sdr::overlay::CellOverlayType eType = sdr::overlay::CELL_OVERLAY_INVERT;
+ sdr::overlay::CellOverlayType eType = sdr::overlay::CELL_OVERLAY_TRANSPARENT;
+
+ sdr::overlay::OverlayObjectCell* pOverlay = new sdr::overlay::OverlayObjectCell( eType, aHighlight, aRanges );
+
+ pOverlayManager->add(*pOverlay);
+ mpSelectionOverlay = new ::sdr::overlay::OverlayObjectList;
+ mpSelectionOverlay->append(*pOverlay);
+ }
+ }
+ }
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::destroySelectionOverlay()
+{
+ if( mpSelectionOverlay )
+ {
+ delete mpSelectionOverlay;
+ mpSelectionOverlay = 0;
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const
+{
+ if( mxTable.is() )
+ {
+ CellPos aStart, aEnd;
+ const_cast<SvxTableController&>(*this).getSelectedCells( aStart, aEnd );
+
+ for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ {
+ for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() && !xCell->isMerged() )
+ {
+ const SfxItemSet& rSet = xCell->GetItemSet();
+ SfxWhichIter aIter(rSet);
+ sal_uInt16 nWhich(aIter.FirstWhich());
+ while(nWhich)
+ {
+ if(!bOnlyHardAttr)
+ {
+ if(SFX_ITEM_DONTCARE == rSet.GetItemState(nWhich, FALSE))
+ rAttr.InvalidateItem(nWhich);
+ else
+ rAttr.MergeValue(rSet.Get(nWhich), TRUE);
+ }
+ else if(SFX_ITEM_SET == rSet.GetItemState(nWhich, FALSE))
+ {
+ const SfxPoolItem& rItem = rSet.Get(nWhich);
+ rAttr.MergeValue(rItem, TRUE);
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+ }
+ }
+ }
+
+ if( mpView->IsTextEdit() )
+ {
+ }
+}
+
+// --------------------------------------------------------------------
+
+const sal_uInt16 CELL_BEFORE = 0x0001;
+const sal_uInt16 CELL_LEFT = 0x0002;
+const sal_uInt16 CELL_RIGHT = 0x0004;
+const sal_uInt16 CELL_AFTER = 0x0008;
+
+const sal_uInt16 CELL_UPPER = 0x0010;
+const sal_uInt16 CELL_TOP = 0x0020;
+const sal_uInt16 CELL_BOTTOM = 0x0040;
+const sal_uInt16 CELL_LOWER = 0x0080;
+
+// --------------------------------------------------------------------
+
+static void ImplSetLinePreserveColor( SvxBoxItem& rNewFrame, const SvxBorderLine* pNew, USHORT nLine )
+{
+ if( pNew )
+ {
+ const SvxBorderLine* pOld = rNewFrame.GetLine(nLine);
+ if( pOld )
+ {
+ SvxBorderLine aNewLine( *pNew );
+ aNewLine.SetColor( pOld->GetColor() );
+ rNewFrame.SetLine( &aNewLine, nLine );
+ return;
+ }
+ }
+ rNewFrame.SetLine( pNew, nLine );
+}
+
+// --------------------------------------------------------------------
+
+static void ImplApplyBoxItem( sal_uInt16 nCellFlags, const SvxBoxItem* pBoxItem, const SvxBoxInfoItem* pBoxInfoItem, SvxBoxItem& rNewFrame )
+{
+ if( (nCellFlags & (CELL_BEFORE|CELL_AFTER|CELL_UPPER|CELL_LOWER)) != 0 )
+ {
+ // current cell is outside the selection
+
+ if( (nCellFlags & ( CELL_BEFORE|CELL_AFTER)) == 0 ) // check if its not nw or ne corner
+ {
+ if( nCellFlags & CELL_UPPER )
+ {
+ if( pBoxInfoItem->IsValid(VALID_TOP) )
+ rNewFrame.SetLine(0, BOX_LINE_BOTTOM );
+ }
+ else if( nCellFlags & CELL_LOWER )
+ {
+ if( pBoxInfoItem->IsValid(VALID_BOTTOM) )
+ rNewFrame.SetLine( 0, BOX_LINE_TOP );
+ }
+ }
+ else if( (nCellFlags & ( CELL_UPPER|CELL_LOWER)) == 0 ) // check if its not sw or se corner
+ {
+ if( nCellFlags & CELL_BEFORE )
+ {
+ if( pBoxInfoItem->IsValid(VALID_LEFT) )
+ rNewFrame.SetLine( 0, BOX_LINE_RIGHT );
+ }
+ else if( nCellFlags & CELL_AFTER )
+ {
+ if( pBoxInfoItem->IsValid(VALID_RIGHT) )
+ rNewFrame.SetLine( 0, BOX_LINE_LEFT );
+ }
+ }
+ }
+ else
+ {
+ // current cell is inside the selection
+
+ if( (nCellFlags & CELL_LEFT) ? pBoxInfoItem->IsValid(VALID_LEFT) : pBoxInfoItem->IsValid(VALID_VERT) )
+ rNewFrame.SetLine( (nCellFlags & CELL_LEFT) ? pBoxItem->GetLeft() : pBoxInfoItem->GetVert(), BOX_LINE_LEFT );
+
+ if( (nCellFlags & CELL_RIGHT) ? pBoxInfoItem->IsValid(VALID_RIGHT) : pBoxInfoItem->IsValid(VALID_VERT) )
+ rNewFrame.SetLine( (nCellFlags & CELL_RIGHT) ? pBoxItem->GetRight() : pBoxInfoItem->GetVert(), BOX_LINE_RIGHT );
+
+ if( (nCellFlags & CELL_TOP) ? pBoxInfoItem->IsValid(VALID_TOP) : pBoxInfoItem->IsValid(VALID_HORI) )
+ rNewFrame.SetLine( (nCellFlags & CELL_TOP) ? pBoxItem->GetTop() : pBoxInfoItem->GetHori(), BOX_LINE_TOP );
+
+ if( (nCellFlags & CELL_BOTTOM) ? pBoxInfoItem->IsValid(VALID_BOTTOM) : pBoxInfoItem->IsValid(VALID_HORI) )
+ rNewFrame.SetLine( (nCellFlags & CELL_BOTTOM) ? pBoxItem->GetBottom() : pBoxInfoItem->GetHori(), BOX_LINE_BOTTOM );
+
+ // apply distance to borders
+ if( pBoxInfoItem->IsValid( VALID_DISTANCE ) )
+ for( USHORT nLine = 0; nLine < 4; ++nLine )
+ rNewFrame.SetDistance( pBoxItem->GetDistance( nLine ), nLine );
+ }
+}
+
+// --------------------------------------------------------------------
+
+static void ImplSetLineColor( SvxBoxItem& rNewFrame, USHORT nLine, const Color& rColor )
+{
+ const SvxBorderLine* pSourceLine = rNewFrame.GetLine( nLine );
+ if( pSourceLine )
+ {
+ SvxBorderLine aLine( *pSourceLine );
+ aLine.SetColor( rColor );
+ rNewFrame.SetLine( &aLine, nLine );
+ }
+}
+
+// --------------------------------------------------------------------
+
+static void ImplApplyLineColorItem( sal_uInt16 nCellFlags, const SvxColorItem* pLineColorItem, SvxBoxItem& rNewFrame )
+{
+ const Color aColor( pLineColorItem->GetValue() );
+
+ if( (nCellFlags & (CELL_LOWER|CELL_BEFORE|CELL_AFTER)) == 0 )
+ ImplSetLineColor( rNewFrame, BOX_LINE_BOTTOM, aColor );
+
+ if( (nCellFlags & (CELL_UPPER|CELL_BEFORE|CELL_AFTER)) == 0 )
+ ImplSetLineColor( rNewFrame, BOX_LINE_TOP, aColor );
+
+ if( (nCellFlags & (CELL_UPPER|CELL_LOWER|CELL_AFTER)) == 0 )
+ ImplSetLineColor( rNewFrame, BOX_LINE_RIGHT, aColor );
+
+ if( (nCellFlags & (CELL_UPPER|CELL_LOWER|CELL_BEFORE)) == 0 )
+ ImplSetLineColor( rNewFrame, BOX_LINE_LEFT, aColor );
+}
+
+// --------------------------------------------------------------------
+
+static void ImplApplyBorderLineItem( sal_uInt16 nCellFlags, const SvxBorderLine* pBorderLineItem, SvxBoxItem& rNewFrame )
+{
+ if( (nCellFlags & ( CELL_BEFORE|CELL_AFTER|CELL_UPPER|CELL_LOWER)) != 0 )
+ {
+ if( (nCellFlags & ( CELL_BEFORE|CELL_AFTER)) == 0 ) // check if its not nw or ne corner
+ {
+ if( nCellFlags & CELL_UPPER )
+ {
+ if( rNewFrame.GetBottom() )
+ ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, BOX_LINE_BOTTOM );
+ }
+ else if( nCellFlags & CELL_LOWER )
+ {
+ if( rNewFrame.GetTop() )
+ ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, BOX_LINE_TOP );
+ }
+ }
+ else if( (nCellFlags & ( CELL_UPPER|CELL_LOWER)) == 0 ) // check if its not sw or se corner
+ {
+ if( nCellFlags & CELL_BEFORE )
+ {
+ if( rNewFrame.GetRight() )
+ ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, BOX_LINE_RIGHT );
+ }
+ else if( nCellFlags & CELL_AFTER )
+ {
+ if( rNewFrame.GetLeft() )
+ ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, BOX_LINE_LEFT );
+ }
+ }
+ }
+ else
+ {
+ if( rNewFrame.GetBottom() )
+ ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, BOX_LINE_BOTTOM );
+ if( rNewFrame.GetTop() )
+ ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, BOX_LINE_TOP );
+ if( rNewFrame.GetRight() )
+ ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, BOX_LINE_RIGHT );
+ if( rNewFrame.GetLeft() )
+ ImplSetLinePreserveColor( rNewFrame, pBorderLineItem, BOX_LINE_LEFT );
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::ApplyBorderAttr( const SfxItemSet& rAttr )
+{
+ if( mxTable.is() )
+ {
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+ if( nRowCount && nColCount )
+ {
+ const SvxBoxItem* pBoxItem = 0;
+ if(SFX_ITEM_SET == rAttr.GetItemState(SDRATTR_TABLE_BORDER, FALSE) )
+ pBoxItem = dynamic_cast< const SvxBoxItem* >( &rAttr.Get( SDRATTR_TABLE_BORDER ) );
+
+ const SvxBoxInfoItem* pBoxInfoItem = 0;
+ if(SFX_ITEM_SET == rAttr.GetItemState(SDRATTR_TABLE_BORDER_INNER, FALSE) )
+ pBoxInfoItem = dynamic_cast< const SvxBoxInfoItem* >( &rAttr.Get( SDRATTR_TABLE_BORDER_INNER ) );
+
+ const SvxColorItem* pLineColorItem = 0;
+ if(SFX_ITEM_SET == rAttr.GetItemState(SID_FRAME_LINECOLOR, FALSE) )
+ pLineColorItem = dynamic_cast< const SvxColorItem* >( &rAttr.Get( SID_FRAME_LINECOLOR ) );
+
+ const SvxBorderLine* pBorderLineItem = 0;
+ if(SFX_ITEM_SET == rAttr.GetItemState(SID_FRAME_LINESTYLE, FALSE) )
+ pBorderLineItem = ((const SvxLineItem&)rAttr.Get( SID_FRAME_LINESTYLE )).GetLine();
+
+ if( pBoxInfoItem && !pBoxItem )
+ {
+ const static SvxBoxItem gaEmptyBoxItem( SDRATTR_TABLE_BORDER );
+ pBoxItem = &gaEmptyBoxItem;
+ }
+ else if( pBoxItem && !pBoxInfoItem )
+ {
+ const static SvxBoxInfoItem gaEmptyBoxInfoItem( SDRATTR_TABLE_BORDER_INNER );
+ pBoxInfoItem = &gaEmptyBoxInfoItem;
+ }
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ const sal_Int32 nLastRow = std::min( aEnd.mnRow + 2, nRowCount );
+ const sal_Int32 nLastCol = std::min( aEnd.mnCol + 2, nColCount );
+
+ for( sal_Int32 nRow = std::max( aStart.mnRow - 1, (sal_Int32)0 ); nRow < nLastRow; nRow++ )
+ {
+ sal_uInt16 nRowFlags = 0;
+ nRowFlags |= (nRow == aStart.mnRow) ? CELL_TOP : 0;
+ nRowFlags |= (nRow == aEnd.mnRow) ? CELL_BOTTOM : 0;
+ nRowFlags |= (nRow < aStart.mnRow) ? CELL_UPPER : 0;
+ nRowFlags |= (nRow > aEnd.mnRow) ? CELL_LOWER : 0;
+
+ for( sal_Int32 nCol = std::max( aStart.mnCol - 1, (sal_Int32)0 ); nCol < nLastCol; nCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( !xCell.is() )
+ continue;
+
+ const SfxItemSet& rSet = xCell->GetItemSet();
+ const SvxBoxItem* pOldOuter = (const SvxBoxItem*) &rSet.Get( SDRATTR_TABLE_BORDER );
+
+ SvxBoxItem aNewFrame( *pOldOuter );
+
+ sal_uInt16 nCellFlags = nRowFlags;
+ nCellFlags |= (nCol == aStart.mnCol) ? CELL_LEFT : 0;
+ nCellFlags |= (nCol == aEnd.mnCol) ? CELL_RIGHT : 0;
+ nCellFlags |= (nCol < aStart.mnCol) ? CELL_BEFORE : 0;
+ nCellFlags |= (nCol > aEnd.mnCol) ? CELL_AFTER : 0;
+
+ if( pBoxItem && pBoxInfoItem )
+ ImplApplyBoxItem( nCellFlags, pBoxItem, pBoxInfoItem, aNewFrame );
+
+ if( pLineColorItem )
+ ImplApplyLineColorItem( nCellFlags, pLineColorItem, aNewFrame );
+
+ if( pBorderLineItem )
+ ImplApplyBorderLineItem( nCellFlags, pBorderLineItem, aNewFrame );
+
+ if (aNewFrame != *pOldOuter)
+ {
+ SfxItemSet aAttr(*rSet.GetPool(), rSet.GetRanges());
+ aAttr.Put(aNewFrame);
+ xCell->SetMergedItemSetAndBroadcast( aAttr, false );
+ }
+ }
+ }
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+void SvxTableController::UpdateTableShape()
+{
+ SdrObject* pTableObj = mxTableObj.get();
+ if( pTableObj )
+ {
+ pTableObj->ActionChanged();
+ pTableObj->BroadcastObjectChange();
+ }
+ updateSelectionOverlay();
+}
+
+
+// --------------------------------------------------------------------
+
+void SvxTableController::SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll)
+{
+ if( mxTable.is() )
+ {
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+
+ if( bUndo )
+ mpModel->BegUndo( ImpGetResStr(STR_TABLE_NUMFORMAT) );
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ SfxItemSet aAttr(*rAttr.GetPool(), rAttr.GetRanges());
+ aAttr.Put(rAttr, TRUE);
+
+ const bool bFrame = (rAttr.GetItemState( SDRATTR_TABLE_BORDER ) == SFX_ITEM_SET) || (rAttr.GetItemState( SDRATTR_TABLE_BORDER_INNER ) == SFX_ITEM_SET);
+
+ if( bFrame )
+ {
+ aAttr.ClearItem( SDRATTR_TABLE_BORDER );
+ aAttr.ClearItem( SDRATTR_TABLE_BORDER_INNER );
+ }
+
+ for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ {
+ for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() )
+ {
+ if( bUndo )
+ xCell->AddUndo();
+ xCell->SetMergedItemSetAndBroadcast(aAttr, bReplaceAll);
+ }
+ }
+ }
+
+ if( bFrame )
+ {
+ ApplyBorderAttr( rAttr );
+ }
+
+ UpdateTableShape();
+
+ if( bUndo )
+ mpModel->EndUndo();
+
+ }
+}
+
+// --------------------------------------------------------------------
+
+bool SvxTableController::GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const
+{
+ if( mxTableObj.is() && hasSelectedCells() )
+ {
+ MergeAttrFromSelectedCells( rTargetSet, bOnlyHardAttr );
+
+ if( mpView->IsTextEdit() )
+ {
+ if( mxTableObj->GetOutlinerParaObject() )
+ rTargetSet.Put( SvxScriptTypeItem( mxTableObj->GetOutlinerParaObject()->GetTextObject().GetScriptType() ) );
+
+ OutlinerView* pTextEditOutlinerView = mpView->GetTextEditOutlinerView();
+ if(pTextEditOutlinerView)
+ {
+ // FALSE= InvalidItems nicht al Default, sondern als "Loecher" betrachten
+ rTargetSet.Put(pTextEditOutlinerView->GetAttribs(), FALSE);
+ rTargetSet.Put( SvxScriptTypeItem( pTextEditOutlinerView->GetSelectedScriptType() ), FALSE );
+ }
+ }
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+// --------------------------------------------------------------------
+
+bool SvxTableController::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
+{
+ if( mbCellSelectionMode || mpView->IsTextEdit() )
+ {
+ SetAttrToSelectedCells( rSet, bReplaceAll );
+ return true;
+ }
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+bool SvxTableController::GetMarkedObjModel( SdrPage* pNewPage )
+{
+ if( mxTableObj.is() && mbCellSelectionMode && pNewPage ) try
+ {
+ ::sdr::table::SdrTableObj& rTableObj = *static_cast< ::sdr::table::SdrTableObj* >( mxTableObj.get() );
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ SdrTableObj* pNewTableObj = rTableObj.CloneRange( aStart, aEnd );
+
+ pNewTableObj->SetPage( pNewPage );
+ pNewTableObj->SetModel( pNewPage->GetModel() );
+
+ SdrInsertReason aReason(SDRREASON_VIEWCALL);
+ pNewPage->InsertObject(pNewTableObj,CONTAINER_APPEND,&aReason);
+
+ return true;
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "svx::SvxTableController::GetMarkedObjModel(), exception caught!" );
+ }
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+bool SvxTableController::PasteObjModel( const SdrModel& rModel )
+{
+ if( mxTableObj.is() && mpView && (rModel.GetPageCount() >= 1) )
+ {
+ const SdrPage* pPastePage = rModel.GetPage(0);
+ if( pPastePage && pPastePage->GetObjCount() == 1 )
+ {
+ SdrTableObj* pPasteTableObj = dynamic_cast< SdrTableObj* >( pPastePage->GetObj(0) );
+ if( pPasteTableObj )
+ {
+ return PasteObject( pPasteTableObj );
+ }
+ }
+ }
+
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+bool SvxTableController::PasteObject( SdrTableObj* pPasteTableObj )
+{
+ if( !pPasteTableObj )
+ return false;
+
+ Reference< XTable > xPasteTable( pPasteTableObj->getTable() );
+ if( !xPasteTable.is() )
+ return false;
+
+ if( !mxTable.is() )
+ return false;
+
+ sal_Int32 nPasteColumns = xPasteTable->getColumnCount();
+ sal_Int32 nPasteRows = xPasteTable->getRowCount();
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ if( mpView->IsTextEdit() )
+ mpView->SdrEndTextEdit(sal_True);
+
+ sal_Int32 nColumns = mxTable->getColumnCount();
+ sal_Int32 nRows = mxTable->getRowCount();
+
+ const sal_Int32 nMissing = nPasteRows - ( nRows - aStart.mnRow );
+ if( nMissing > 0 )
+ {
+ Reference< XTableRows > xRows( mxTable->getRows() );
+ xRows->insertByIndex( nRows, nMissing );
+ nRows = mxTable->getRowCount();
+ }
+
+ nPasteRows = std::min( nPasteRows, nRows - aStart.mnRow );
+ nPasteColumns = std::min( nPasteColumns, nColumns - aStart.mnCol );
+
+ // copy cell contents
+ for( sal_Int32 nRow = 0; nRow < nPasteRows; ++nRow )
+ {
+ for( sal_Int32 nCol = 0; nCol < nPasteColumns; ++nCol )
+ {
+ CellRef xTargetCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( aStart.mnCol + nCol, aStart.mnRow + nRow ).get() ) );
+ if( xTargetCell.is() && !xTargetCell->isMerged() )
+ {
+ xTargetCell->AddUndo();
+ xTargetCell->cloneFrom( dynamic_cast< Cell* >( xPasteTable->getCellByPosition( nCol, nRow ).get() ) );
+ nCol += xTargetCell->getColumnSpan() - 1;
+ }
+ }
+ }
+
+ UpdateTableShape();
+
+ return true;
+}
+
+bool SvxTableController::TakeFormatPaintBrush( boost::shared_ptr< SfxItemSet >& /*rFormatSet*/ )
+{
+ // SdrView::TakeFormatPaintBrush() is enough
+ return false;
+}
+
+bool SvxTableController::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats )
+{
+ if( mbCellSelectionMode )
+ {
+ SdrTextObj* pTableObj = dynamic_cast<SdrTextObj*>( mxTableObj.get() );
+ if( !pTableObj )
+ return false;
+
+ const bool bUndo = mpModel && mpModel->IsUndoEnabled();
+
+ if( bUndo )
+ mpModel->BegUndo( ImpGetResStr(STR_TABLE_NUMFORMAT) );
+
+ CellPos aStart, aEnd;
+ getSelectedCells( aStart, aEnd );
+
+ SfxItemSet aAttr(*rFormatSet.GetPool(), rFormatSet.GetRanges());
+ aAttr.Put(rFormatSet, TRUE);
+
+ const bool bFrame = (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER ) == SFX_ITEM_SET) || (rFormatSet.GetItemState( SDRATTR_TABLE_BORDER_INNER ) == SFX_ITEM_SET);
+
+ if( bFrame )
+ {
+ aAttr.ClearItem( SDRATTR_TABLE_BORDER );
+ aAttr.ClearItem( SDRATTR_TABLE_BORDER_INNER );
+ }
+
+ const USHORT* pRanges = rFormatSet.GetRanges();
+ bool bTextOnly = true;
+
+ while( *pRanges )
+ {
+ if( (*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START) )
+ {
+ bTextOnly = true;
+ break;
+ }
+ pRanges += 2;
+ }
+
+ const bool bReplaceAll = false;
+ for( sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++ )
+ {
+ for( sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() )
+ {
+ if( bUndo )
+ xCell->AddUndo();
+ if( !bTextOnly )
+ xCell->SetMergedItemSetAndBroadcast(aAttr, bReplaceAll);
+
+ SdrText* pText = static_cast< SdrText* >( xCell.get() );
+ mpView->ApplyFormatPaintBrushToText( rFormatSet, *pTableObj, pText, bNoCharacterFormats, bNoParagraphFormats );
+ }
+ }
+ }
+
+ if( bFrame )
+ {
+ ApplyBorderAttr( rFormatSet );
+ }
+
+ UpdateTableShape();
+
+ if( bUndo )
+ mpModel->EndUndo();
+
+ return true;
+
+ }
+ return false;
+}
+
+
+// --------------------------------------------------------------------
+
+IMPL_LINK( SvxTableController, UpdateHdl, void *, EMPTYARG )
+{
+ mnUpdateEvent = 0;
+
+ if( mbCellSelectionMode )
+ {
+ CellPos aStart( maCursorFirstPos );
+ CellPos aEnd( maCursorLastPos );
+ checkCell(aStart);
+ checkCell(aEnd);
+ if( aStart != maCursorFirstPos || aEnd != maCursorLastPos )
+ {
+ setSelectedCells( aStart, aEnd );
+ }
+ }
+ updateSelectionOverlay();
+
+ return 0;
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablecontroller.hxx b/svx/source/table/tablecontroller.hxx
new file mode 100644
index 000000000000..b0e199e89994
--- /dev/null
+++ b/svx/source/table/tablecontroller.hxx
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TABLECONTROLLER_HXX_
+#define _SVX_TABLECONTROLLER_HXX_
+
+#include <com/sun/star/util/XModifyListener.hpp>
+#include <com/sun/star/table/XTable.hpp>
+#include <rtl/ref.hxx>
+
+#include <svx/sdr/overlay/overlayobjectlist.hxx>
+#include <svx/selectioncontroller.hxx>
+#include <svx/svdotable.hxx>
+#include <svx/svdview.hxx>
+#include <tablemodel.hxx>
+
+class SdrObjEditView;
+class SdrObject;
+class SfxItemSet;
+
+namespace sdr { namespace table {
+
+const sal_Int16 SELTYPE_NONE = 0;
+const sal_Int16 SELTYPE_MOUSE = 1;
+const sal_Int16 SELTYPE_KEYS = 2;
+
+class SVX_DLLPUBLIC SvxTableController: public sdr::SelectionController
+{
+public:
+ SVX_DLLPRIVATE SvxTableController( SdrObjEditView* pView, const SdrObject* pObj );
+ SVX_DLLPRIVATE virtual ~SvxTableController();
+
+ // from sdr::SelectionController
+ SVX_DLLPRIVATE virtual bool onKeyInput(const KeyEvent& rKEvt, Window* pWin);
+ SVX_DLLPRIVATE virtual bool onMouseButtonDown(const MouseEvent& rMEvt, Window* pWin);
+ SVX_DLLPRIVATE virtual bool onMouseButtonUp(const MouseEvent& rMEvt, Window* pWin);
+ SVX_DLLPRIVATE virtual bool onMouseMove(const MouseEvent& rMEvt, Window* pWin);
+
+ SVX_DLLPRIVATE virtual bool DeleteMarked();
+
+ SVX_DLLPRIVATE virtual void onSelectionHasChanged();
+
+ SVX_DLLPRIVATE virtual void GetState( SfxItemSet& rSet );
+ SVX_DLLPRIVATE virtual void Execute( SfxRequest& rReq );
+
+ SVX_DLLPRIVATE virtual bool GetStyleSheet( SfxStyleSheet* &rpStyleSheet ) const;
+ SVX_DLLPRIVATE virtual bool SetStyleSheet( SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr );
+
+ SVX_DLLPRIVATE virtual bool TakeFormatPaintBrush( boost::shared_ptr< SfxItemSet >& rFormatSet );
+ SVX_DLLPRIVATE virtual bool ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats );
+
+ // slots
+ SVX_DLLPRIVATE void onInsert( sal_uInt16 nSId, const SfxItemSet* pArgs = 0 );
+ SVX_DLLPRIVATE void onDelete( sal_uInt16 nSId );
+ SVX_DLLPRIVATE void onSelect( sal_uInt16 nSId );
+ SVX_DLLPRIVATE void onFormatTable( SfxRequest& rReq );
+ SVX_DLLPRIVATE void MergeMarkedCells();
+ SVX_DLLPRIVATE void SplitMarkedCells();
+ SVX_DLLPRIVATE void DistributeColumns();
+ SVX_DLLPRIVATE void DistributeRows();
+ SVX_DLLPRIVATE void SetVertical( sal_uInt16 nSId );
+
+ SVX_DLLPRIVATE static rtl::Reference< sdr::SelectionController > create( SdrObjEditView* pView, const SdrObject* pObj, const rtl::Reference< sdr::SelectionController >& xRefController );
+
+ SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const;
+ SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll);
+
+ SVX_DLLPRIVATE virtual bool GetAttributes(SfxItemSet& rTargetSet, bool bOnlyHardAttr) const;
+ SVX_DLLPRIVATE virtual bool SetAttributes(const SfxItemSet& rSet, bool bReplaceAll);
+
+ SVX_DLLPRIVATE virtual bool GetMarkedObjModel( SdrPage* pNewPage );
+ SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel );
+
+ SVX_DLLPRIVATE bool hasSelectedCells() const { return mbCellSelectionMode || mpView->IsTextEdit(); }
+
+ void getSelectedCells( CellPos& rFirstPos, CellPos& rLastPos );
+ void setSelectedCells( const CellPos& rFirstPos, const CellPos& rLastPos );
+ void clearSelection();
+ void selectAll();
+
+ SVX_DLLPRIVATE void onTableModified();
+
+private:
+ SvxTableController(SvxTableController &); // not defined
+ void operator =(SvxTableController &); // not defined
+
+ // internals
+ SVX_DLLPRIVATE void ApplyBorderAttr( const SfxItemSet& rAttr );
+ SVX_DLLPRIVATE void UpdateTableShape();
+
+ SVX_DLLPRIVATE void SetTableStyle( const SfxItemSet* pArgs );
+ SVX_DLLPRIVATE void SetTableStyleSettings( const SfxItemSet* pArgs );
+
+ SVX_DLLPRIVATE bool PasteObject( SdrTableObj* pPasteTableObj );
+
+ SVX_DLLPRIVATE bool checkTableObject();
+ SVX_DLLPRIVATE bool updateTableObject();
+ SVX_DLLPRIVATE const CellPos& getSelectionStart();
+ SVX_DLLPRIVATE void setSelectionStart( const CellPos& rPos );
+ SVX_DLLPRIVATE const CellPos& getSelectionEnd();
+ SVX_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellCursor > getSelectionCursor();
+ SVX_DLLPRIVATE void checkCell( CellPos& rPos );
+
+ SVX_DLLPRIVATE void MergeRange( sal_Int32 nFirstCol, sal_Int32 nFirstRow, sal_Int32 nLastCol, sal_Int32 nLastRow );
+
+ SVX_DLLPRIVATE void EditCell( const CellPos& rPos, ::Window* pWindow, const ::com::sun::star::awt::MouseEvent* pMouseEvent = 0, sal_uInt16 nAction = 0 );
+ SVX_DLLPRIVATE bool StopTextEdit();
+
+ SVX_DLLPRIVATE void DeleteTable();
+
+ SVX_DLLPRIVATE sal_uInt16 getKeyboardAction( const KeyEvent& rKEvt, Window* pWindow );
+ SVX_DLLPRIVATE bool executeAction( sal_uInt16 nAction, bool bSelect, Window* pWindow );
+ SVX_DLLPRIVATE void gotoCell( const CellPos& rCell, bool bSelect, Window* pWindow, sal_uInt16 nAction = 0 );
+
+ SVX_DLLPRIVATE void StartSelection( const CellPos& rPos );
+ SVX_DLLPRIVATE void UpdateSelection( const CellPos& rPos );
+ SVX_DLLPRIVATE void RemoveSelection();
+ SVX_DLLPRIVATE void updateSelectionOverlay();
+ SVX_DLLPRIVATE void destroySelectionOverlay();
+
+ SVX_DLLPRIVATE void findMergeOrigin( CellPos& rPos );
+
+ DECL_LINK( UpdateHdl, void * );
+
+ TableModelRef mxTable;
+
+ CellPos maCursorFirstPos;
+ CellPos maCursorLastPos;
+ bool mbCellSelectionMode;
+ CellPos maMouseDownPos;
+ bool mbLeftButtonDown;
+ ::sdr::overlay::OverlayObjectList* mpSelectionOverlay;
+
+ SdrView* mpView;
+ SdrObjectWeakRef mxTableObj;
+ SdrModel* mpModel;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener > mxModifyListener;
+
+ ULONG mnUpdateEvent;
+};
+
+} }
+
+#endif // _SVX_TABLECONTROLLER_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tabledesign.cxx b/svx/source/table/tabledesign.cxx
new file mode 100644
index 000000000000..32627b812ad3
--- /dev/null
+++ b/svx/source/table/tabledesign.cxx
@@ -0,0 +1,810 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <com/sun/star/util/XModifyListener.hpp>
+#include <comphelper/serviceinfohelper.hxx>
+
+#include <osl/mutex.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/compbase6.hxx>
+#include <cppuhelper/implbase7.hxx>
+#include <cppuhelper/interfacecontainer.h>
+
+#include "svx/unoprov.hxx"
+#include "svx/sdr/table/tabledesign.hxx"
+#include "svx/dialmgr.hxx"
+#include "svx/dialogs.hrc"
+
+#include "celltypes.hxx"
+
+#include <vector>
+#include <map>
+
+#include <boost/bind.hpp>
+
+// -----------------------------------------------------------------------------
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::style;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::container;
+
+using ::rtl::OUString;
+using ::osl::MutexGuard;
+using ::osl::ClearableMutexGuard;
+using ::cppu::OInterfaceContainerHelper;
+
+namespace sdr { namespace table {
+
+typedef std::map< OUString, sal_Int32 > CellStyleNameMap;
+
+typedef ::cppu::WeakComponentImplHelper6< XStyle, XNameReplace, XServiceInfo, XIndexAccess, XModifyBroadcaster, XModifyListener > TableDesignStyleBase;
+
+class TableDesignStyle : private ::cppu::BaseMutex, public TableDesignStyleBase
+{
+public:
+ TableDesignStyle();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ // XStyle
+ virtual ::sal_Bool SAL_CALL isUserDefined() throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL isInUse() throw (RuntimeException);
+ virtual OUString SAL_CALL getParentStyle() throw (RuntimeException);
+ virtual void SAL_CALL setParentStyle( const OUString& aParentStyle ) throw (NoSuchElementException, RuntimeException);
+
+ // XNamed
+ virtual OUString SAL_CALL getName() throw (RuntimeException);
+ virtual void SAL_CALL setName( const OUString& aName ) throw (RuntimeException);
+
+ // XNameAccess
+ virtual Any SAL_CALL getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getElementNames() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(RuntimeException);
+
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw(RuntimeException);
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw(RuntimeException) ;
+ virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException);
+
+ // XModifyBroadcaster
+ virtual void SAL_CALL addModifyListener( const Reference< XModifyListener >& aListener ) throw (RuntimeException);
+ virtual void SAL_CALL removeModifyListener( const Reference< XModifyListener >& aListener ) throw (RuntimeException);
+
+ // XModifyListener
+ virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ void notifyModifyListener();
+
+ // this function is called upon disposing the component
+ virtual void SAL_CALL disposing();
+
+ static const CellStyleNameMap& getCellStyleNameMap();
+
+ OUString msName;
+ Reference< XStyle > maCellStyles[style_count];
+};
+
+typedef std::vector< Reference< XStyle > > TableDesignStyleVector;
+
+class TableDesignFamily : public ::cppu::WeakImplHelper7< XNameContainer, XNamed, XIndexAccess, XSingleServiceFactory, XServiceInfo, XComponent, XPropertySet >
+{
+public:
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ // XNamed
+ virtual OUString SAL_CALL getName( ) throw (RuntimeException);
+ virtual void SAL_CALL setName( const OUString& aName ) throw (RuntimeException);
+
+ // XNameAccess
+ virtual Any SAL_CALL getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getElementNames() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(RuntimeException);
+
+ // XElementAccess
+ virtual Type SAL_CALL getElementType() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw(RuntimeException);
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw(RuntimeException) ;
+ virtual Any SAL_CALL getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException);
+
+ // XNameContainer
+ virtual void SAL_CALL insertByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException);
+ virtual void SAL_CALL removeByName( const OUString& Name ) throw(NoSuchElementException, WrappedTargetException, RuntimeException);
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const OUString& aName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException);
+
+ // XSingleServiceFactory
+ virtual Reference< XInterface > SAL_CALL createInstance( ) throw(Exception, RuntimeException);
+ virtual Reference< XInterface > SAL_CALL createInstanceWithArguments( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL dispose( ) throw (RuntimeException);
+ virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException);
+ virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException);
+
+ // XPropertySet
+ virtual Reference<XPropertySetInfo> SAL_CALL getPropertySetInfo() throw (RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException);
+ virtual Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const Reference<XPropertyChangeListener>& xListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const Reference<XPropertyChangeListener>& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener(const OUString& PropertyName, const Reference<XVetoableChangeListener>& aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener(const OUString& PropertyName,const Reference<XVetoableChangeListener>&aListener ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException);
+
+ TableDesignStyleVector maDesigns;
+};
+
+//------------------------------------------------------------------------
+// TableDesignStyle
+//------------------------------------------------------------------------
+
+TableDesignStyle::TableDesignStyle()
+: TableDesignStyleBase(m_aMutex)
+{
+}
+
+const CellStyleNameMap& TableDesignStyle::getCellStyleNameMap()
+{
+ static CellStyleNameMap aMap;
+ if( aMap.empty() )
+ {
+ CellStyleNameMap aNewMap;
+ aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "first-row" ) ) ] = first_row_style;
+ aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "last-row" ) ) ] = last_row_style;
+ aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "first-column" ) ) ] = first_column_style;
+ aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "last-column" ) ) ] = last_column_style;
+ aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "body" ) ) ] = body_style;
+ aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "even-rows" ) ) ] = even_rows_style;
+ aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "odd-rows" ) ) ] = odd_rows_style;
+ aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "even-columns" ) ) ] = even_columns_style;
+ aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "odd-columns" ) ) ] = odd_columns_style;
+ aNewMap[ OUString( RTL_CONSTASCII_USTRINGPARAM( "background" ) ) ] = background_style;
+ aMap.swap( aNewMap );
+ }
+
+ return aMap;
+}
+
+// ----------------------------------------------------------
+// XServiceInfo
+// ----------------------------------------------------------
+
+OUString SAL_CALL TableDesignStyle::getImplementationName() throw(RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("TableDesignStyle") );
+}
+
+// ----------------------------------------------------------
+
+sal_Bool SAL_CALL TableDesignStyle::supportsService( const OUString& ServiceName ) throw(RuntimeException)
+{
+ return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
+}
+
+// ----------------------------------------------------------
+
+Sequence< OUString > SAL_CALL TableDesignStyle::getSupportedServiceNames() throw(RuntimeException)
+{
+ OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.Style") );
+ Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+// ----------------------------------------------------------
+// XStyle
+// ----------------------------------------------------------
+
+sal_Bool SAL_CALL TableDesignStyle::isUserDefined() throw (RuntimeException)
+{
+ return sal_False;
+}
+
+// ----------------------------------------------------------
+
+sal_Bool SAL_CALL TableDesignStyle::isInUse() throw (RuntimeException)
+{
+ ClearableMutexGuard aGuard( rBHelper.rMutex );
+ OInterfaceContainerHelper * pContainer = rBHelper.getContainer( XModifyListener::static_type() );
+ if( pContainer )
+ {
+ Sequence< Reference< XInterface > > aListener( pContainer->getElements() );
+ aGuard.clear();
+
+ sal_Int32 nIndex = aListener.getLength();
+ while( --nIndex >= 0 )
+ {
+ TableDesignUser* pUser = dynamic_cast< TableDesignUser* >( aListener[nIndex].get() );
+ if( pUser && pUser->isInUse() )
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+// ----------------------------------------------------------
+
+OUString SAL_CALL TableDesignStyle::getParentStyle() throw (RuntimeException)
+{
+ return OUString();
+}
+
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignStyle::setParentStyle( const OUString& ) throw (NoSuchElementException, RuntimeException)
+{
+}
+
+// ----------------------------------------------------------
+// XNamed
+// ----------------------------------------------------------
+
+OUString SAL_CALL TableDesignStyle::getName() throw (RuntimeException)
+{
+ return msName;
+}
+
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignStyle::setName( const OUString& rName ) throw (RuntimeException)
+{
+ msName = rName;
+}
+
+// ----------------------------------------------------------
+// XNameAccess
+// ----------------------------------------------------------
+
+Any SAL_CALL TableDesignStyle::getByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const CellStyleNameMap& rMap = getCellStyleNameMap();
+
+ CellStyleNameMap::const_iterator iter = rMap.find( rName );
+ if( iter == rMap.end() )
+ throw NoSuchElementException();
+
+ return Any( maCellStyles[(*iter).second] );
+}
+
+// ----------------------------------------------------------
+
+Sequence< OUString > SAL_CALL TableDesignStyle::getElementNames() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const CellStyleNameMap& rMap = getCellStyleNameMap();
+ Sequence< OUString > aRet( rMap.size() );
+ OUString* pName = aRet.getArray();
+
+ CellStyleNameMap::const_iterator iter = rMap.begin();
+ while( iter != rMap.end() )
+ *pName++ = (*iter++).first;
+
+ return aRet;
+}
+
+// ----------------------------------------------------------
+
+sal_Bool SAL_CALL TableDesignStyle::hasByName( const OUString& rName ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const CellStyleNameMap& rMap = getCellStyleNameMap();
+
+ CellStyleNameMap::const_iterator iter = rMap.find( rName );
+ return ( iter != rMap.end() ) ? sal_True : sal_False;
+}
+
+// ----------------------------------------------------------
+// XElementAccess
+// ----------------------------------------------------------
+
+Type SAL_CALL TableDesignStyle::getElementType() throw(RuntimeException)
+{
+ return XStyle::static_type();
+}
+
+// ----------------------------------------------------------
+
+sal_Bool SAL_CALL TableDesignStyle::hasElements() throw(RuntimeException)
+{
+ return sal_True;
+}
+
+// ----------------------------------------------------------
+// XIndexAccess
+// ----------------------------------------------------------
+
+sal_Int32 SAL_CALL TableDesignStyle::getCount() throw(RuntimeException)
+{
+ return style_count;
+}
+
+// ----------------------------------------------------------
+
+Any SAL_CALL TableDesignStyle::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( (Index < 0) || (Index >= style_count) )
+ throw IndexOutOfBoundsException();
+
+ return Any( maCellStyles[Index] );
+}
+
+// ----------------------------------------------------------
+// XNameReplace
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignStyle::replaceByName( const OUString& rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const CellStyleNameMap& rMap = getCellStyleNameMap();
+ CellStyleNameMap::const_iterator iter = rMap.find( rName );
+ if( iter == rMap.end() )
+ throw NoSuchElementException();
+
+
+ Reference< XStyle > xNewStyle;
+ if( !(aElement >>= xNewStyle) )
+ throw IllegalArgumentException();
+
+ const sal_Int32 nIndex = (*iter).second;
+
+ Reference< XStyle > xOldStyle( maCellStyles[nIndex] );
+
+ if( xNewStyle != xOldStyle )
+ {
+ Reference< XModifyListener > xListener( this );
+
+ // end listening to old style, if possible
+ Reference< XModifyBroadcaster > xOldBroadcaster( xOldStyle, UNO_QUERY );
+ if( xOldBroadcaster.is() )
+ xOldBroadcaster->removeModifyListener( xListener );
+
+ // start listening to new style, if possible
+ Reference< XModifyBroadcaster > xNewBroadcaster( xNewStyle, UNO_QUERY );
+ if( xNewBroadcaster.is() )
+ xNewBroadcaster->addModifyListener( xListener );
+
+ maCellStyles[nIndex] = xNewStyle;
+ }
+}
+
+// ----------------------------------------------------------
+// XComponent
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignStyle::disposing()
+{
+ for( sal_Int32 nIndex = 0; nIndex < style_count; nIndex++ )
+ maCellStyles[nIndex].clear();
+}
+
+//------------------------------------------------------------------------
+// XModifyBroadcaster
+//------------------------------------------------------------------------
+
+void SAL_CALL TableDesignStyle::addModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException)
+{
+ ClearableMutexGuard aGuard( rBHelper.rMutex );
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ {
+ aGuard.clear();
+ EventObject aEvt( static_cast< OWeakObject * >( this ) );
+ xListener->disposing( aEvt );
+ }
+ else
+ {
+ rBHelper.addListener( XModifyListener::static_type(), xListener );
+ }
+}
+
+//------------------------------------------------------------------------
+
+void SAL_CALL TableDesignStyle::removeModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException)
+{
+ rBHelper.removeListener( XModifyListener::static_type(), xListener );
+}
+
+//------------------------------------------------------------------------
+
+void TableDesignStyle::notifyModifyListener()
+{
+ MutexGuard aGuard( rBHelper.rMutex );
+
+ OInterfaceContainerHelper * pContainer = rBHelper.getContainer( XModifyListener::static_type() );
+ if( pContainer )
+ {
+ EventObject aEvt( static_cast< OWeakObject * >( this ) );
+ pContainer->forEach<XModifyListener>( boost::bind( &XModifyListener::modified, _1, boost::cref( aEvt ) ) );
+ }
+}
+
+//------------------------------------------------------------------------
+// XModifyListener
+//------------------------------------------------------------------------
+
+// if we get a modify hint from a style, notify all registered XModifyListener
+void SAL_CALL TableDesignStyle::modified( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
+{
+ notifyModifyListener();
+}
+
+//------------------------------------------------------------------------
+
+void SAL_CALL TableDesignStyle::disposing( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+//------------------------------------------------------------------------
+// TableStyle
+//------------------------------------------------------------------------
+
+// ----------------------------------------------------------
+// XServiceInfo
+// ----------------------------------------------------------
+
+OUString SAL_CALL TableDesignFamily::getImplementationName() throw(RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("TableDesignFamily") );
+}
+
+// ----------------------------------------------------------
+
+sal_Bool SAL_CALL TableDesignFamily::supportsService( const OUString& ServiceName ) throw(RuntimeException)
+{
+ return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
+}
+
+// ----------------------------------------------------------
+
+Sequence< OUString > SAL_CALL TableDesignFamily::getSupportedServiceNames() throw(RuntimeException)
+{
+ OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.StyleFamily") );
+ Sequence< OUString > aSeq( &aServiceName, 1 );
+ return aSeq;
+}
+
+// ----------------------------------------------------------
+// XNamed
+// ----------------------------------------------------------
+
+OUString SAL_CALL TableDesignFamily::getName() throw (RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "table" ) );
+}
+
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignFamily::setName( const OUString& ) throw (RuntimeException)
+{
+}
+
+// ----------------------------------------------------------
+// XNameAccess
+// ----------------------------------------------------------
+
+Any SAL_CALL TableDesignFamily::getByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
+ {
+ if( (*iter)->getName() == rName )
+ return Any( (*iter) );
+ }
+
+ throw NoSuchElementException();
+}
+
+// ----------------------------------------------------------
+
+Sequence< OUString > SAL_CALL TableDesignFamily::getElementNames() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ Sequence< OUString > aRet( maDesigns.size() );
+ OUString* pNames = aRet.getArray();
+
+ for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
+ *pNames++ = (*iter)->getName();
+
+ return aRet;
+}
+
+// ----------------------------------------------------------
+
+sal_Bool SAL_CALL TableDesignFamily::hasByName( const OUString& aName ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
+ if( (*iter)->getName() == aName )
+ return sal_True;
+
+ return sal_False;
+}
+
+// ----------------------------------------------------------
+// XElementAccess
+// ----------------------------------------------------------
+
+Type SAL_CALL TableDesignFamily::getElementType() throw(RuntimeException)
+{
+ return XStyle::static_type();
+}
+
+// ----------------------------------------------------------
+
+sal_Bool SAL_CALL TableDesignFamily::hasElements() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return maDesigns.empty() ? sal_False : sal_True;
+}
+
+// ----------------------------------------------------------
+// XIndexAccess
+// ----------------------------------------------------------
+
+sal_Int32 SAL_CALL TableDesignFamily::getCount() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return sal::static_int_cast< sal_Int32 >( maDesigns.size() );
+}
+
+// ----------------------------------------------------------
+
+Any SAL_CALL TableDesignFamily::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( (Index >= 0) && (Index < sal::static_int_cast< sal_Int32 >( maDesigns.size() ) ) )
+ return Any( maDesigns[Index] );
+
+ throw IndexOutOfBoundsException();
+}
+
+// ----------------------------------------------------------
+// XNameContainer
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignFamily::insertByName( const OUString& rName, const Any& rElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ Reference< XStyle > xStyle( rElement, UNO_QUERY );
+ if( !xStyle.is() )
+ throw IllegalArgumentException();
+
+ xStyle->setName( rName );
+ for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
+ if( (*iter)->getName() == rName )
+ throw ElementExistException();
+
+ maDesigns.push_back( xStyle );
+}
+
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignFamily::removeByName( const OUString& rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
+ {
+ if( (*iter)->getName() == rName )
+ {
+ maDesigns.erase( iter );
+ return;
+ }
+ }
+
+
+ throw NoSuchElementException();
+}
+
+// ----------------------------------------------------------
+// XNameReplace
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignFamily::replaceByName( const OUString& rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ Reference< XStyle > xStyle( aElement, UNO_QUERY );
+ if( !xStyle.is() )
+ throw IllegalArgumentException();
+
+ for( TableDesignStyleVector::iterator iter( maDesigns.begin() ); iter != maDesigns.end(); iter++ )
+ {
+ if( (*iter)->getName() == rName )
+ {
+ (*iter) = xStyle;
+ xStyle->setName( rName );
+ return;
+ }
+ }
+
+ throw NoSuchElementException();
+}
+
+// ----------------------------------------------------------
+// XSingleServiceFactory
+// ----------------------------------------------------------
+
+Reference< XInterface > SAL_CALL TableDesignFamily::createInstance() throw(Exception, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return Reference< XInterface >( static_cast< XStyle* >( new TableDesignStyle ) );
+}
+
+// ----------------------------------------------------------
+
+Reference< XInterface > SAL_CALL TableDesignFamily::createInstanceWithArguments( const Sequence< Any >& ) throw(Exception, RuntimeException)
+{
+ return createInstance();
+}
+
+// ----------------------------------------------------------
+// XComponent
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignFamily::dispose( ) throw (RuntimeException)
+{
+ TableDesignStyleVector aDesigns;
+ aDesigns.swap( maDesigns );
+
+ for( TableDesignStyleVector::iterator iter( aDesigns.begin() ); iter != aDesigns.end(); iter++ )
+ {
+ Reference< XComponent > xComp( (*iter), UNO_QUERY );
+ if( xComp.is() )
+ xComp->dispose();
+ }
+}
+
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignFamily::addEventListener( const Reference< XEventListener >& ) throw (RuntimeException)
+{
+}
+
+// ----------------------------------------------------------
+
+void SAL_CALL TableDesignFamily::removeEventListener( const Reference< XEventListener >& ) throw (RuntimeException)
+{
+}
+
+// ----------------------------------------------------------
+// XPropertySet
+// ----------------------------------------------------------
+
+Reference<XPropertySetInfo> TableDesignFamily::getPropertySetInfo() throw (RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+ return Reference<XPropertySetInfo>();
+}
+
+// ----------------------------------------------------------
+
+void TableDesignFamily::setPropertyValue( const OUString& , const Any& ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+}
+
+// ----------------------------------------------------------
+
+Any TableDesignFamily::getPropertyValue( const OUString& PropertyName ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ if (PropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DisplayName") ))
+ {
+ OUString sDisplayName( SVX_RESSTR( RID_SVXSTR_STYLEFAMILY_TABLEDESIGN ) );
+ return Any( sDisplayName );
+ }
+ else
+ {
+ throw UnknownPropertyException( OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property: ") ) + PropertyName, static_cast<OWeakObject *>(this) );
+ }
+}
+
+// ----------------------------------------------------------
+
+void TableDesignFamily::addPropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+}
+
+// ----------------------------------------------------------
+
+void TableDesignFamily::removePropertyChangeListener( const OUString& , const Reference<XPropertyChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+}
+
+// ----------------------------------------------------------
+
+void TableDesignFamily::addVetoableChangeListener( const OUString& , const Reference<XVetoableChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+}
+
+// ----------------------------------------------------------
+
+void TableDesignFamily::removeVetoableChangeListener( const OUString& , const Reference<XVetoableChangeListener>& ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+}
+
+// --------------------------------------------------------------------
+
+
+SVX_DLLPUBLIC Reference< XNameAccess > CreateTableDesignFamily()
+{
+ return new TableDesignFamily();
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablehandles.cxx b/svx/source/table/tablehandles.cxx
new file mode 100644
index 000000000000..a1501aa78cd0
--- /dev/null
+++ b/svx/source/table/tablehandles.cxx
@@ -0,0 +1,317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "tablehandles.hxx"
+
+#include <vcl/svapp.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/canvastools.hxx>
+#include <vcl/hatch.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/range/b2drectangle.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <svx/sdr/overlay/overlayobject.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <svx/sdrpagewindow.hxx>
+#include <sdrpaintwindow.hxx>
+#include <svx/svdmrkv.hxx>
+#include <svx/svdpagv.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <svx/sdr/overlay/overlayhatchrect.hxx>
+#include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
+
+namespace sdr { namespace table {
+
+// --------------------------------------------------------------------
+
+class OverlayTableEdge : public sdr::overlay::OverlayObject
+{
+protected:
+ basegfx::B2DPolyPolygon maPolyPolygon;
+ bool mbVisible;
+
+ // geometry creation for OverlayObject
+ virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
+
+public:
+ OverlayTableEdge( const basegfx::B2DPolyPolygon& rPolyPolygon, bool bVisible );
+ virtual ~OverlayTableEdge();
+};
+
+// --------------------------------------------------------------------
+
+TableEdgeHdl::TableEdgeHdl( const Point& rPnt, bool bHorizontal, sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nEdges )
+: SdrHdl( rPnt, HDL_USER )
+, mbHorizontal( bHorizontal )
+, mnMin( nMin )
+, mnMax( nMax )
+, maEdges(nEdges)
+{
+}
+
+void TableEdgeHdl::SetEdge( sal_Int32 nEdge, sal_Int32 nStart, sal_Int32 nEnd, TableEdgeState eState )
+{
+ if( (nEdge >= 0) && (nEdge <= sal::static_int_cast<sal_Int32>(maEdges.size())) )
+ {
+ maEdges[nEdge].mnStart = nStart;
+ maEdges[nEdge].mnEnd = nEnd;
+ maEdges[nEdge].meState = eState;
+ }
+ else
+ {
+ OSL_ENSURE( false, "sdr::table::TableEdgeHdl::SetEdge(), invalid edge!" );
+ }
+}
+
+Pointer TableEdgeHdl::GetPointer() const
+{
+ if( mbHorizontal )
+ return POINTER_VSPLIT;
+ else
+ return POINTER_HSPLIT;
+}
+
+sal_Int32 TableEdgeHdl::GetValidDragOffset( const SdrDragStat& rDrag ) const
+{
+ return std::min( std::max( static_cast<sal_Int32>(mbHorizontal ? rDrag.GetDY() : rDrag.GetDX()), mnMin ), mnMax );
+}
+
+basegfx::B2DPolyPolygon TableEdgeHdl::getSpecialDragPoly(const SdrDragStat& rDrag) const
+{
+ basegfx::B2DPolyPolygon aVisible;
+ basegfx::B2DPolyPolygon aInvisible;
+
+ // create and return visible and non-visible parts for drag
+ getPolyPolygon(aVisible, aInvisible, &rDrag);
+ aVisible.append(aInvisible);
+
+ return aVisible;
+}
+
+void TableEdgeHdl::getPolyPolygon(basegfx::B2DPolyPolygon& rVisible, basegfx::B2DPolyPolygon& rInvisible, const SdrDragStat* pDrag) const
+{
+ // changed method to create visible and invisible partial polygons in one run in
+ // separate PolyPolygons; both kinds are used
+ basegfx::B2DPoint aOffset(aPos.X(), aPos.Y());
+ rVisible.clear();
+ rInvisible.clear();
+
+ if( pDrag )
+ {
+ int n = mbHorizontal ? 1 : 0;
+ aOffset[n] = aOffset[n] + GetValidDragOffset( *pDrag );
+ }
+
+ basegfx::B2DPoint aStart(aOffset), aEnd(aOffset);
+ int nPos = mbHorizontal ? 0 : 1;
+ TableEdgeVector::const_iterator aIter( maEdges.begin() );
+
+ while( aIter != maEdges.end() )
+ {
+ TableEdge aEdge(*aIter++);
+
+ aStart[nPos] = aOffset[nPos] + aEdge.mnStart;
+ aEnd[nPos] = aOffset[nPos] + aEdge.mnEnd;
+
+ basegfx::B2DPolygon aPolygon;
+ aPolygon.append( aStart );
+ aPolygon.append( aEnd );
+
+ if(aEdge.meState == Visible)
+ {
+ rVisible.append(aPolygon);
+ }
+ else
+ {
+ rInvisible.append(aPolygon);
+ }
+ }
+}
+
+void TableEdgeHdl::CreateB2dIAObject()
+{
+ GetRidOfIAObject();
+
+ if(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden())
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ basegfx::B2DPolyPolygon aVisible;
+ basegfx::B2DPolyPolygon aInvisible;
+
+ // get visible and invisible parts
+ getPolyPolygon(aVisible, aInvisible, 0);
+
+ if(aVisible.count() || aInvisible.count())
+ {
+ for(sal_uInt32 nWindow = 0; nWindow < pPageView->PageWindowCount(); nWindow++)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(nWindow);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager())
+ {
+ if(aVisible.count())
+ {
+ // create overlay object for visible parts
+ sdr::overlay::OverlayObject* pOverlayObject = new OverlayTableEdge(aVisible, true);
+ rPageWindow.GetOverlayManager()->add(*pOverlayObject);
+ maOverlayGroup.append(*pOverlayObject);
+ }
+
+ if(aInvisible.count())
+ {
+ // also create overlay object vor invisible parts to allow
+ // a standard HitTest using the primitives from that overlay object
+ // (see OverlayTableEdge implementation)
+ sdr::overlay::OverlayObject* pOverlayObject = new OverlayTableEdge(aInvisible, false);
+ rPageWindow.GetOverlayManager()->add(*pOverlayObject);
+ maOverlayGroup.append(*pOverlayObject);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+OverlayTableEdge::OverlayTableEdge( const basegfx::B2DPolyPolygon& rPolyPolygon, bool bVisible )
+: OverlayObject(Color(COL_GRAY))
+, maPolyPolygon( rPolyPolygon )
+, mbVisible(bVisible)
+{
+}
+
+OverlayTableEdge::~OverlayTableEdge()
+{
+}
+
+drawinglayer::primitive2d::Primitive2DSequence OverlayTableEdge::createOverlayObjectPrimitive2DSequence()
+{
+ drawinglayer::primitive2d::Primitive2DSequence aRetval;
+
+ if(maPolyPolygon.count())
+ {
+ // Discussed with CL. Currently i will leave the transparence out since this
+ // a little bit expensive. We may check the look with drag polygons later
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::PolyPolygonHairlinePrimitive2D(
+ maPolyPolygon,
+ getBaseColor().getBColor()));
+
+ if(mbVisible)
+ {
+ // visible, just return as sequence
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+ }
+ else
+ {
+ // embed in HiddenGeometryPrimitive2D to support HitTest of this invisible
+ // overlay object
+ const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aReference, 1);
+ const drawinglayer::primitive2d::Primitive2DReference aNewReference(
+ new drawinglayer::primitive2d::HiddenGeometryPrimitive2D(aSequence));
+ aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aNewReference, 1);
+ }
+ }
+
+ return aRetval;
+}
+
+// ====================================================================
+
+TableBorderHdl::TableBorderHdl( const Rectangle& rRect )
+: SdrHdl( rRect.TopLeft(), HDL_MOVE )
+, maRectangle( rRect )
+{
+
+}
+
+Pointer TableBorderHdl::GetPointer() const
+{
+ return POINTER_MOVE;
+}
+
+// create marker for this kind
+void TableBorderHdl::CreateB2dIAObject()
+{
+ GetRidOfIAObject();
+
+ if(pHdlList && pHdlList->GetView() && !pHdlList->GetView()->areMarkHandlesHidden())
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 nWindow = 0; nWindow < pPageView->PageWindowCount(); nWindow++)
+ {
+ // const SdrPageViewWinRec& rPageViewWinRec = rPageViewWinList[b];
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(nWindow);
+
+ if(rPageWindow.GetPaintWindow().OutputToWindow())
+ {
+ if(rPageWindow.GetOverlayManager())
+ {
+ const basegfx::B2DRange aRange(vcl::unotools::b2DRectangleFromRectangle(maRectangle));
+ sdr::overlay::OverlayObject* pOverlayObject = new sdr::overlay::OverlayHatchRect(
+ aRange.getMinimum(),
+ aRange.getMaximum(),
+ Color(0x80, 0x80, 0x80),
+ 6.0,
+ 0.0,
+ 45 * F_PI180,
+ 0.0);
+
+ rPageWindow.GetOverlayManager()->add(*pOverlayObject);
+ maOverlayGroup.append(*pOverlayObject);
+ }
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+} // end of namespace table
+} // end of namespace sdr
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablehandles.hxx b/svx/source/table/tablehandles.hxx
new file mode 100644
index 000000000000..b243e1d82aee
--- /dev/null
+++ b/svx/source/table/tablehandles.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TABLEHANDLES_HXX
+#define _SVX_TABLEHANDLES_HXX
+
+#include <svx/sdr/overlay/overlayobject.hxx>
+
+#include <svx/svdhdl.hxx>
+
+// --------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+enum TableEdgeState { Empty, Invisible, Visible };
+
+struct TableEdge
+{
+ sal_Int32 mnStart;
+ sal_Int32 mnEnd;
+ TableEdgeState meState;
+
+ TableEdge() : mnStart(0), mnEnd(0), meState(Empty) {}
+};
+
+typedef std::vector< TableEdge > TableEdgeVector;
+
+class TableEdgeHdl : public SdrHdl
+{
+public:
+ TableEdgeHdl( const Point& rPnt, bool bHorizontal, sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nEdges );
+
+ sal_Int32 GetValidDragOffset( const SdrDragStat& rDrag ) const;
+
+ virtual Pointer GetPointer() const;
+
+ void SetEdge( sal_Int32 nEdge, sal_Int32 nStart, sal_Int32 nEnd, TableEdgeState nState );
+
+ bool IsHorizontalEdge() const { return mbHorizontal; }
+
+ basegfx::B2DPolyPolygon getSpecialDragPoly(const SdrDragStat& rDrag) const;
+ void getPolyPolygon(basegfx::B2DPolyPolygon& rVisible, basegfx::B2DPolyPolygon& rInvisible, const SdrDragStat* pDrag) const;
+
+protected:
+ // create marker for this kind
+ virtual void CreateB2dIAObject();
+
+private:
+ bool mbHorizontal;
+ sal_Int32 mnMin, mnMax;
+ TableEdgeVector maEdges;
+};
+
+class TableBorderHdl : public SdrHdl
+{
+public:
+ TableBorderHdl( const Rectangle& rRect );
+
+ virtual Pointer GetPointer() const;
+
+protected:
+ // create marker for this kind
+ virtual void CreateB2dIAObject();
+
+private:
+ Rectangle maRectangle;
+};
+
+} // end of namespace table
+} // end of namespace sdr
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
new file mode 100644
index 000000000000..693f8c880987
--- /dev/null
+++ b/svx/source/table/tablelayouter.cxx
@@ -0,0 +1,1303 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/table/XMergeableCell.hpp>
+#include <com/sun/star/awt/XLayoutConstrains.hpp>
+#include <boost/bind.hpp>
+
+#include "cell.hxx"
+#include "cellrange.hxx"
+#include "tablemodel.hxx"
+#include "tablerow.hxx"
+#include "tablerows.hxx"
+#include "tablecolumn.hxx"
+#include "tablecolumns.hxx"
+#include "tablelayouter.hxx"
+#include "svx/svdotable.hxx"
+#include "editeng/borderline.hxx"
+#include "editeng/boxitem.hxx"
+#include "svx/svdmodel.hxx"
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+
+using ::rtl::OUString;
+using ::com::sun::star::awt::XLayoutConstrains;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::text;
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+
+static SvxBorderLine gEmptyBorder;
+
+// -----------------------------------------------------------------------------
+
+TableLayouter::TableLayouter( const TableModelRef& xTableModel )
+: mxTable( xTableModel )
+, meWritingMode( WritingMode_LR_TB )
+, msSize( RTL_CONSTASCII_USTRINGPARAM( "Size" ) )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+TableLayouter::~TableLayouter()
+{
+ ClearBorderLayout();
+}
+
+// -----------------------------------------------------------------------------
+
+basegfx::B2ITuple TableLayouter::getCellSize( const CellPos& rPos ) const
+{
+ sal_Int32 width = 0;
+ sal_Int32 height = 0;
+
+ try
+ {
+ CellRef xCell( getCell( rPos ) );
+ if( xCell.is() && !xCell->isMerged() )
+ {
+ CellPos aPos( rPos );
+
+ sal_Int32 nRowCount = getRowCount();
+ sal_Int32 nRowSpan = std::max( xCell->getRowSpan(), (sal_Int32)1 );
+ while( nRowSpan && (aPos.mnRow < nRowCount) )
+ {
+ if( ((sal_Int32)maRows.size()) <= aPos.mnRow )
+ break;
+
+ height += maRows[aPos.mnRow++].mnSize;
+ nRowSpan--;
+ }
+
+ sal_Int32 nColCount = getColumnCount();
+ sal_Int32 nColSpan = std::max( xCell->getColumnSpan(), (sal_Int32)1 );
+ while( nColSpan && (aPos.mnCol < nColCount ) )
+ {
+ if( ((sal_Int32)maColumns.size()) <= aPos.mnCol )
+ break;
+
+ width += maColumns[aPos.mnCol++].mnSize;
+ nColSpan--;
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "TableLayouter::getCellSize(), exception caught!" );
+ }
+
+ return basegfx::B2ITuple( width, height );
+}
+
+// -----------------------------------------------------------------------------
+
+bool TableLayouter::getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rArea ) const
+{
+ try
+ {
+ CellRef xCell( getCell( rPos ) );
+ if( xCell.is() && !xCell->isMerged() && isValid(rPos) )
+ {
+ const basegfx::B2ITuple aCellSize( getCellSize( rPos ) );
+
+ if( (rPos.mnCol < ((sal_Int32)maColumns.size()) && (rPos.mnRow < ((sal_Int32)maRows.size()) ) ) )
+ {
+ const sal_Int32 x = maColumns[rPos.mnCol].mnPos;
+ const sal_Int32 y = maRows[rPos.mnRow].mnPos;
+
+ rArea = basegfx::B2IRectangle( x, y, x + aCellSize.getX(), y + aCellSize.getY() );
+ return true;
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "TableLayouter::getCellSize(), exception caught!" );
+ }
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableLayouter::getRowHeight( sal_Int32 nRow )
+{
+ if( isValidRow(nRow) )
+ return maRows[nRow].mnSize;
+ else
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::setRowHeight( sal_Int32 nRow, sal_Int32 nHeight )
+{
+ if( isValidRow(nRow) )
+ {
+ maRows[nRow].mnSize = nHeight;
+ }
+ else
+ {
+ DBG_ERROR( "TableLayouter::setRowHeight(), row out of range!" );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableLayouter::getColumnWidth( sal_Int32 nColumn )
+{
+ if( isValidColumn(nColumn) )
+ return maColumns[nColumn].mnSize;
+ else
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::setColumnWidth( sal_Int32 nColumn, sal_Int32 nWidth )
+{
+ if( isValidColumn(nColumn) )
+ maColumns[nColumn].mnSize = nWidth;
+ else
+ DBG_ERROR( "TableLayouter::setColumnWidth(), column out of range!" );
+}
+
+// -----------------------------------------------------------------------------
+
+bool TableLayouter::isEdgeVisible( sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal ) const
+{
+ const BorderLineMap& rMap = bHorizontal ? maHorizontalBorders : maVerticalBorders;
+
+ if( (nEdgeX >= 0) && (nEdgeX < sal::static_int_cast<sal_Int32>(rMap.size())) &&
+ (nEdgeY >= 0) && (nEdgeY < sal::static_int_cast<sal_Int32>(rMap[nEdgeX].size())) )
+ {
+ return rMap[nEdgeX][nEdgeY] != 0;
+ }
+ else
+ {
+ OSL_ENSURE( false, "sdr::table::TableLayouter::getBorderLine(), invalid edge!" );
+ }
+
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+
+/** returns the requested borderline in rpBorderLine or a null pointer if there is no border at this edge */
+SvxBorderLine* TableLayouter::getBorderLine( sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal )const
+{
+ SvxBorderLine* pLine = 0;
+
+ const BorderLineMap& rMap = bHorizontal ? maHorizontalBorders : maVerticalBorders;
+
+ if( (nEdgeX >= 0) && (nEdgeX < sal::static_int_cast<sal_Int32>(rMap.size())) &&
+ (nEdgeY >= 0) && (nEdgeY < sal::static_int_cast<sal_Int32>(rMap[nEdgeX].size())) )
+ {
+ pLine = rMap[nEdgeX][nEdgeY];
+ if( pLine == &gEmptyBorder )
+ pLine = 0;
+ }
+ else
+ {
+ OSL_ENSURE( false, "sdr::table::TableLayouter::getBorderLine(), invalid edge!" );
+ }
+
+ return pLine;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableLayouter::getHorizontalEdge( int nEdgeY, sal_Int32* pnMin /*= 0*/, sal_Int32* pnMax /*= 0*/ )
+{
+ sal_Int32 nRet = 0;
+ if( (nEdgeY >= 0) && (nEdgeY <= getRowCount() ) )
+ nRet = maRows[std::min((sal_Int32)nEdgeY,getRowCount()-1)].mnPos;
+
+ if( nEdgeY == getRowCount() )
+ nRet += maRows[nEdgeY - 1].mnSize;
+
+ if( pnMin )
+ {
+ if( (nEdgeY > 0) && (nEdgeY <= getRowCount() ) )
+ {
+ *pnMin = maRows[nEdgeY-1].mnPos + 600; // todo
+ }
+ else
+ {
+ *pnMin = nRet;
+ }
+ }
+
+ if( pnMax )
+ {
+ *pnMax = 0x0fffffff;
+ }
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableLayouter::getVerticalEdge( int nEdgeX, sal_Int32* pnMin /*= 0*/, sal_Int32* pnMax /*= 0*/ )
+{
+ sal_Int32 nRet = 0;
+
+ const sal_Int32 nColCount = getColumnCount();
+ if( (nEdgeX >= 0) && (nEdgeX <= nColCount ) )
+ nRet = maColumns[std::min((sal_Int32)nEdgeX,nColCount-1)].mnPos;
+
+ const bool bRTL = meWritingMode == WritingMode_RL_TB;
+ if( bRTL )
+ {
+ if( (nEdgeX >= 0) && (nEdgeX < nColCount) )
+ nRet += maColumns[nEdgeX].mnSize;
+ }
+ else
+ {
+ if( nEdgeX == getColumnCount() )
+ nRet += maColumns[nEdgeX - 1].mnSize;
+ }
+
+ if( pnMin )
+ {
+ *pnMin = nRet;
+ if( bRTL )
+ {
+ if( nEdgeX < nColCount )
+ *pnMin = nRet - maColumns[nEdgeX].mnSize + getMinimumColumnWidth(nEdgeX);
+ }
+ else
+ {
+ if( (nEdgeX > 0) && (nEdgeX <= nColCount ) )
+ *pnMin = maColumns[nEdgeX-1].mnPos + getMinimumColumnWidth( nEdgeX-1 );
+ }
+ }
+
+ if( pnMax )
+ {
+ *pnMax = 0x0fffffff; // todo
+ if( bRTL )
+ {
+ if( nEdgeX > 0 )
+ *pnMax = nRet + maColumns[nEdgeX-1].mnSize - getMinimumColumnWidth( nEdgeX-1 );
+ }
+ else
+ {
+ if( (nEdgeX >= 0) && (nEdgeX < nColCount ) )
+ *pnMax = maColumns[nEdgeX].mnPos + maColumns[nEdgeX].mnSize - getMinimumColumnWidth( nEdgeX );
+ }
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+static bool checkMergeOrigin( const TableModelRef& xTable, sal_Int32 nMergedX, sal_Int32 nMergedY, sal_Int32 nCellX, sal_Int32 nCellY, bool& bRunning )
+{
+ Reference< XMergeableCell > xCell( xTable->getCellByPosition( nCellX, nCellY ), UNO_QUERY );
+ if( xCell.is() && !xCell->isMerged() )
+ {
+ const sal_Int32 nRight = xCell->getColumnSpan() + nCellX;
+ const sal_Int32 nBottom = xCell->getRowSpan() + nCellY;
+ if( (nMergedX < nRight) && (nMergedY < nBottom) )
+ return true;
+
+ bRunning = false;
+ }
+ return false;
+}
+
+/** returns true if the cell(nMergedX,nMergedY) is merged with other cells.
+ the returned cell( rOriginX, rOriginY ) is the origin( top left cell ) of the merge.
+*/
+bool findMergeOrigin( const TableModelRef& xTable, sal_Int32 nMergedX, sal_Int32 nMergedY, sal_Int32& rOriginX, sal_Int32& rOriginY )
+{
+ rOriginX = nMergedX;
+ rOriginY = nMergedY;
+
+ if( xTable.is() ) try
+ {
+ // check if this cell already the origin or not merged at all
+ Reference< XMergeableCell > xCell( xTable->getCellByPosition( nMergedX, nMergedY ), UNO_QUERY_THROW );
+ if( !xCell.is() || !xCell->isMerged() )
+ return true;
+
+ bool bCheckVert = true;
+ bool bCheckHorz = true;
+
+ sal_Int32 nMinCol = 0;
+ sal_Int32 nMinRow = 0;
+
+ sal_Int32 nStep = 1, i;
+
+ sal_Int32 nRow, nCol;
+ do
+ {
+ if( bCheckVert )
+ {
+ nRow = nMergedY - nStep;
+ if( nRow >= nMinRow )
+ {
+ nCol = nMergedX;
+ for( i = 0; (i <= nStep) && (nCol >= nMinCol); i++, nCol-- )
+ {
+ if( checkMergeOrigin( xTable, nMergedX, nMergedY, nCol, nRow, bCheckVert ) )
+ {
+ rOriginX = nCol; rOriginY = nRow;
+ return true;
+ }
+
+ if( !bCheckVert )
+ {
+ if( nCol == nMergedX )
+ {
+ nMinRow = nRow+1;
+ }
+ else
+ {
+ bCheckVert = true;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ bCheckVert = false;
+ }
+ }
+
+ if( bCheckHorz )
+ {
+ nCol = nMergedX - nStep;
+ if( nCol >= nMinCol )
+ {
+ nRow = nMergedY;
+ for( i = 0; (i < nStep) && (nRow >= nMinRow); i++, nRow-- )
+ {
+ if( checkMergeOrigin( xTable, nMergedX, nMergedY, nCol, nRow, bCheckHorz ) )
+ {
+ rOriginX = nCol; rOriginY = nRow;
+ return true;
+ }
+
+ if( !bCheckHorz )
+ {
+ if( nRow == nMergedY )
+ {
+ nMinCol = nCol+1;
+ }
+ else
+ {
+ bCheckHorz = true;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ bCheckHorz = false;
+ }
+ }
+ nStep++;
+ }
+ while( bCheckVert || bCheckHorz );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("sdr::table::TableLayouter::findMergeOrigin(), exception caught!");
+ }
+ return false;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableLayouter::getMinimumColumnWidth( sal_Int32 nColumn )
+{
+ if( isValidColumn( nColumn ) )
+ {
+ return maColumns[nColumn].mnMinSize;
+ }
+ else
+ {
+ DBG_ERROR( "TableLayouter::getMinimumColumnWidth(), column out of range!" );
+ return 0;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableLayouter::distribute( LayoutVector& rLayouts, sal_Int32 nDistribute )
+{
+ // break loops after 100 runs to avoid freezing office due to developer error
+ sal_Int32 nSafe = 100;
+
+ const sal_Size nCount = rLayouts.size();
+ sal_Size nIndex;
+
+ bool bConstrainsBroken = false;
+
+ do
+ {
+ // first enforce minimum size constrains on all entities
+ for( nIndex = 0; nIndex < nCount; ++nIndex )
+ {
+ Layout& rLayout = rLayouts[nIndex];
+ if( rLayout.mnSize < rLayout.mnMinSize )
+ {
+ nDistribute -= rLayout.mnMinSize - rLayout.mnSize;
+ rLayout.mnSize = rLayout.mnMinSize;
+ }
+ }
+
+ // calculate current width
+ // if nDistribute is < 0 (shrinking), entities that are already
+ // at minimum width are not counted
+ sal_Int32 nCurrentWidth = 0;
+ for( nIndex = 0; nIndex < nCount; ++nIndex )
+ {
+ Layout& rLayout = rLayouts[nIndex];
+ if( (nDistribute > 0) || (rLayout.mnSize > rLayout.mnMinSize) )
+ nCurrentWidth += rLayout.mnSize;
+ }
+
+ bConstrainsBroken = false;
+
+ // now distribute over entities
+ if( (nCurrentWidth != 0) && (nDistribute != 0) )
+ {
+ sal_Int32 nDistributed = nDistribute;
+ for( nIndex = 0; nIndex < nCount; ++nIndex )
+ {
+ Layout& rLayout = rLayouts[nIndex];
+ if( (nDistribute > 0) || (rLayout.mnSize > rLayout.mnMinSize) )
+ {
+ sal_Int32 n;
+ if( nIndex == (nCount-1) )
+ n = nDistributed; // for last entitie, use up rest
+ else
+ n = (nDistribute * rLayout.mnSize) / nCurrentWidth; //
+
+ nDistributed -= n;
+ rLayout.mnSize += n;
+
+ if( rLayout.mnSize < rLayout.mnMinSize )
+ bConstrainsBroken = true;
+ }
+ }
+ }
+ } while( bConstrainsBroken && --nSafe );
+
+ sal_Int32 nSize = 0;
+ for( nIndex = 0; nIndex < nCount; ++nIndex )
+ nSize += rLayouts[nIndex].mnSize;
+
+ return nSize;
+}
+
+// -----------------------------------------------------------------------------
+
+typedef std::vector< CellRef > MergeableCellVector;
+typedef std::vector< MergeableCellVector > MergeVector;
+typedef std::vector< sal_Int32 > Int32Vector;
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::LayoutTableWidth( Rectangle& rArea, bool bFit )
+{
+ const sal_Int32 nColCount = getColumnCount();
+ const sal_Int32 nRowCount = getRowCount();
+ if( nColCount == 0 )
+ return;
+
+ MergeVector aMergedCells( nColCount );
+ Int32Vector aOptimalColumns;
+
+ const OUString sOptimalSize( RTL_CONSTASCII_USTRINGPARAM("OptimalSize") );
+
+ if( sal::static_int_cast< sal_Int32 >( maColumns.size() ) != nColCount )
+ maColumns.resize( nColCount );
+
+ Reference< XTableColumns > xCols( mxTable->getColumns(), UNO_QUERY_THROW );
+
+ // first calculate current width and initial minimum width per column,
+ // merged cells will be counted later
+ sal_Int32 nCurrentWidth = 0;
+ sal_Int32 nCol = 0, nRow = 0;
+ for( nCol = 0; nCol < nColCount; nCol++ )
+ {
+ sal_Int32 nMinWidth = 0;
+
+ bool bIsEmpty = true; // check if all cells in this column are merged
+
+ for( nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ CellRef xCell( getCell( CellPos( nCol, nRow ) ) );
+ if( xCell.is() && !xCell->isMerged() )
+ {
+ bIsEmpty = false;
+
+ sal_Int32 nColSpan = xCell->getColumnSpan();
+ if( nColSpan > 1 )
+ {
+ // merged cells will be evaluated later
+ aMergedCells[nCol+nColSpan-1].push_back( xCell );
+ }
+ else
+ {
+ nMinWidth = std::max( nMinWidth, xCell->getMinimumSize().Width );
+ }
+ }
+ }
+
+ maColumns[nCol].mnMinSize = nMinWidth;
+
+ if( bIsEmpty )
+ {
+ maColumns[nCol].mnSize = 0;
+ }
+ else
+ {
+ sal_Int32 nColWidth = 0;
+ Reference< XPropertySet > xColSet( xCols->getByIndex( nCol ), UNO_QUERY_THROW );
+ sal_Bool bOptimal = sal_False;
+ xColSet->getPropertyValue( sOptimalSize ) >>= bOptimal;
+ if( bOptimal )
+ {
+ aOptimalColumns.push_back(nCol);
+ }
+ else
+ {
+ xColSet->getPropertyValue( msSize ) >>= nColWidth;
+ }
+
+ maColumns[nCol].mnSize = nColWidth;
+
+ if( maColumns[nCol].mnSize < nMinWidth )
+ maColumns[nCol].mnSize = nMinWidth;
+
+ nCurrentWidth += maColumns[nCol].mnSize;
+ }
+ }
+
+ // if we have optimal sized rows, distribute what is given (left)
+ if( !bFit && !aOptimalColumns.empty() && (nCurrentWidth < rArea.getWidth()) )
+ {
+ sal_Int32 nLeft = rArea.getWidth() - nCurrentWidth;
+ sal_Int32 nDistribute = nLeft / aOptimalColumns.size();
+
+ Int32Vector::iterator iter( aOptimalColumns.begin() );
+ while( iter != aOptimalColumns.end() )
+ {
+ sal_Int32 nOptCol = (*iter++);
+ if( iter == aOptimalColumns.end() )
+ nDistribute = nLeft;
+
+ maColumns[nOptCol].mnSize += nDistribute;
+ nLeft -= nDistribute;
+ }
+
+ DBG_ASSERT( nLeft == 0, "svx::TableLayouter::LayoutTableWidtht(), layouting failed!" );
+ }
+
+ // now check if merged cells fit
+ for( nCol = 1; nCol < nColCount; ++nCol )
+ {
+ bool bChanges = false;
+ MergeableCellVector::iterator iter( aMergedCells[nCol].begin() );
+
+ const sal_Int32 nOldSize = maColumns[nCol].mnSize;
+
+ while( iter != aMergedCells[nCol].end() )
+ {
+ CellRef xCell( (*iter++) );
+ sal_Int32 nMinWidth = xCell->getMinimumSize().Width;
+
+ for( sal_Int32 nMCol = nCol - xCell->getColumnSpan() + 1; (nMCol > 0) && (nMCol < nCol); ++nMCol )
+ nMinWidth -= maColumns[nMCol].mnSize;
+
+ if( nMinWidth > maColumns[nCol].mnMinSize )
+ maColumns[nCol].mnMinSize = nMinWidth;
+
+ if( nMinWidth > maColumns[nCol].mnSize )
+ {
+ maColumns[nCol].mnSize = nMinWidth;
+ bChanges = true;
+ }
+ }
+
+ if( bChanges )
+ nCurrentWidth += maColumns[nCol].mnSize - nOldSize;
+ }
+
+ // now scale if wanted and needed
+ if( bFit && (nCurrentWidth != rArea.getWidth()) )
+ distribute( maColumns, rArea.getWidth() - nCurrentWidth );
+
+ // last step, update left edges
+ sal_Int32 nNewWidth = 0;
+
+ const bool bRTL = meWritingMode == WritingMode_RL_TB;
+ RangeIterator<sal_Int32> coliter( 0, nColCount, !bRTL );
+ while( coliter.next(nCol ) )
+ {
+ maColumns[nCol].mnPos = nNewWidth;
+ nNewWidth += maColumns[nCol].mnSize;
+ if( bFit )
+ {
+ Reference< XPropertySet > xColSet( xCols->getByIndex(nCol), UNO_QUERY_THROW );
+ xColSet->setPropertyValue( msSize, Any( maColumns[nCol].mnSize ) );
+ }
+ }
+
+ rArea.SetSize( Size( nNewWidth, rArea.GetHeight() ) );
+ updateCells( rArea );
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::LayoutTableHeight( Rectangle& rArea, bool bFit )
+{
+ const sal_Int32 nColCount = getColumnCount();
+ const sal_Int32 nRowCount = getRowCount();
+ if( nRowCount == 0 )
+ return;
+
+ Reference< XTableRows > xRows( mxTable->getRows() );
+
+ MergeVector aMergedCells( nRowCount );
+ Int32Vector aOptimalRows;
+
+ const OUString sOptimalSize( RTL_CONSTASCII_USTRINGPARAM("OptimalSize") );
+
+ // first calculate current height and initial minimum size per column,
+ // merged cells will be counted later
+ sal_Int32 nCurrentHeight = 0;
+ sal_Int32 nCol, nRow;
+ for( nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ sal_Int32 nMinHeight = 0;
+
+ bool bIsEmpty = true; // check if all cells in this row are merged
+
+ for( nCol = 0; nCol < nColCount; ++nCol )
+ {
+ CellRef xCell( getCell( CellPos( nCol, nRow ) ) );
+ if( xCell.is() && !xCell->isMerged() )
+ {
+ bIsEmpty = false;
+
+ sal_Int32 nRowSpan = xCell->getRowSpan();
+ if( nRowSpan > 1 )
+ {
+ // merged cells will be evaluated later
+ aMergedCells[nRow+nRowSpan-1].push_back( xCell );
+ }
+ else
+ {
+ nMinHeight = std::max( nMinHeight, xCell->getMinimumSize().Height );
+ }
+ }
+ }
+
+ maRows[nRow].mnMinSize = nMinHeight;
+
+ if( bIsEmpty )
+ {
+ maRows[nRow].mnSize = 0;
+ }
+ else
+ {
+ sal_Int32 nRowHeight = 0;
+ Reference< XPropertySet > xRowSet( xRows->getByIndex(nRow), UNO_QUERY_THROW );
+
+ sal_Bool bOptimal = sal_False;
+ xRowSet->getPropertyValue( sOptimalSize ) >>= bOptimal;
+ if( bOptimal )
+ {
+ aOptimalRows.push_back( nRow );
+ }
+ else
+ {
+ xRowSet->getPropertyValue( msSize ) >>= nRowHeight;
+ }
+
+ maRows[nRow].mnSize = nRowHeight;
+
+ if( maRows[nRow].mnSize < nMinHeight )
+ maRows[nRow].mnSize = nMinHeight;
+
+ nCurrentHeight += maRows[nRow].mnSize;
+ }
+ }
+
+ // if we have optimal sized rows, distribute what is given (left)
+ if( !bFit && !aOptimalRows.empty() && (nCurrentHeight < rArea.getHeight()) )
+ {
+ sal_Int32 nLeft = rArea.getHeight() - nCurrentHeight;
+ sal_Int32 nDistribute = nLeft / aOptimalRows.size();
+
+ Int32Vector::iterator iter( aOptimalRows.begin() );
+ while( iter != aOptimalRows.end() )
+ {
+ sal_Int32 nOptRow = (*iter++);
+ if( iter == aOptimalRows.end() )
+ nDistribute = nLeft;
+
+ maRows[nOptRow].mnSize += nDistribute;
+ nLeft -= nDistribute;
+
+ }
+
+ DBG_ASSERT( nLeft == 0, "svx::TableLayouter::LayoutTableHeight(), layouting failed!" );
+ }
+
+ // now check if merged cells fit
+ for( nRow = 1; nRow < nRowCount; ++nRow )
+ {
+ bool bChanges = false;
+ sal_Int32 nOldSize = maRows[nRow].mnSize;
+
+ MergeableCellVector::iterator iter( aMergedCells[nRow].begin() );
+ while( iter != aMergedCells[nRow].end() )
+ {
+ CellRef xCell( (*iter++) );
+ sal_Int32 nMinHeight = xCell->getMinimumSize().Height;
+
+ for( sal_Int32 nMRow = nRow - xCell->getRowSpan() + 1; (nMRow > 0) && (nMRow < nRow); ++nMRow )
+ nMinHeight -= maRows[nMRow].mnSize;
+
+ if( nMinHeight > maRows[nRow].mnMinSize )
+ maRows[nRow].mnMinSize = nMinHeight;
+
+ if( nMinHeight > maRows[nRow].mnSize )
+ {
+ maRows[nRow].mnSize = nMinHeight;
+ bChanges = true;
+ }
+ }
+ if( bChanges )
+ nCurrentHeight += maRows[nRow].mnSize - nOldSize;
+ }
+
+ // now scale if wanted and needed
+ if( bFit && nCurrentHeight != rArea.getHeight() )
+ distribute( maRows, rArea.getHeight() - nCurrentHeight );
+
+ // last step, update left edges
+ sal_Int32 nNewHeight = 0;
+ for( nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ maRows[nRow].mnPos = nNewHeight;
+ nNewHeight += maRows[nRow].mnSize;
+
+ if( bFit )
+ {
+ Reference< XPropertySet > xRowSet( xRows->getByIndex(nRow), UNO_QUERY_THROW );
+ xRowSet->setPropertyValue( msSize, Any( maRows[nRow].mnSize ) );
+ }
+ }
+
+ rArea.SetSize( Size( rArea.GetWidth(), nNewHeight ) );
+ updateCells( rArea );
+}
+
+// -----------------------------------------------------------------------------
+
+/** try to fit the table into the given rectangle.
+ If the rectangle is to small, it will be grown to fit the table. */
+void TableLayouter::LayoutTable( Rectangle& rRectangle, bool bFitWidth, bool bFitHeight )
+{
+ if( !mxTable.is() )
+ return;
+
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+
+ if( (nRowCount != getRowCount()) || (nColCount != getColumnCount()) )
+ {
+ if( static_cast< sal_Int32 >( maRows.size() ) != nRowCount )
+ maRows.resize( nRowCount );
+
+ Reference< XTableRows > xRows( mxTable->getRows() );
+ for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
+ maRows[nRow].clear();
+
+ if( static_cast< sal_Int32 >( maColumns.size() ) != nColCount )
+ maColumns.resize( nColCount );
+
+ for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
+ maColumns[nCol].clear();
+ }
+
+ LayoutTableWidth( rRectangle, bFitWidth );
+ LayoutTableHeight( rRectangle, bFitHeight );
+ UpdateBorderLayout();
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::updateCells( Rectangle& rRectangle )
+{
+ const sal_Int32 nColCount = getColumnCount();
+ const sal_Int32 nRowCount = getRowCount();
+
+ CellPos aPos;
+ for( aPos.mnRow = 0; aPos.mnRow < nRowCount; aPos.mnRow++ )
+ {
+ for( aPos.mnCol = 0; aPos.mnCol < nColCount; aPos.mnCol++ )
+ {
+ CellRef xCell( getCell( aPos ) );
+ if( xCell.is() )
+ {
+ basegfx::B2IRectangle aCellArea;
+ getCellArea( aPos, aCellArea );
+
+ Rectangle aCellRect;
+ aCellRect.nLeft = aCellArea.getMinX();
+ aCellRect.nRight = aCellArea.getMaxX();
+ aCellRect.nTop = aCellArea.getMinY();
+ aCellRect.nBottom = aCellArea.getMaxY();
+ aCellRect.Move( rRectangle.nLeft, rRectangle.nTop );
+ xCell->setCellRect( aCellRect );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+CellRef TableLayouter::getCell( const CellPos& rPos ) const
+{
+ CellRef xCell;
+ if( mxTable.is() ) try
+ {
+ xCell.set( dynamic_cast< Cell* >( mxTable->getCellByPosition( rPos.mnCol, rPos.mnRow ).get() ) );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR( "sdr::table::TableLayouter::getCell(), exception caught!" );
+ }
+ return xCell;
+}
+
+// -----------------------------------------------------------------------------
+
+bool TableLayouter::HasPriority( const SvxBorderLine* pThis, const SvxBorderLine* pOther )
+{
+ if (!pThis || ((pThis == &gEmptyBorder) && (pOther != 0)))
+ return false;
+ if (!pOther || (pOther == &gEmptyBorder))
+ return true;
+
+ USHORT nThisSize = pThis->GetOutWidth() + pThis->GetDistance() + pThis->GetInWidth();
+ USHORT nOtherSize = pOther->GetOutWidth() + pOther->GetDistance() + pOther->GetInWidth();
+
+ if (nThisSize > nOtherSize)
+ return true;
+
+ else if (nThisSize < nOtherSize)
+ {
+ return false;
+ }
+ else
+ {
+ if ( pOther->GetInWidth() && !pThis->GetInWidth() )
+ {
+ return true;
+ }
+ else if ( pThis->GetInWidth() && !pOther->GetInWidth() )
+ {
+ return false;
+ }
+ else
+ {
+ return true; //! ???
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::SetBorder( sal_Int32 nCol, sal_Int32 nRow, bool bHorizontal, const SvxBorderLine* pLine )
+{
+ if( pLine == 0 )
+ pLine = &gEmptyBorder;
+
+ SvxBorderLine *pOld = bHorizontal ? maHorizontalBorders[nCol][nRow] : maVerticalBorders[nCol][nRow];
+
+ if( HasPriority( pLine, pOld ) )
+ {
+ if( (pOld != 0) && (pOld != &gEmptyBorder) )
+ delete pOld;
+
+ SvxBorderLine* pNew = ( pLine != &gEmptyBorder ) ? new SvxBorderLine(*pLine) : &gEmptyBorder;
+
+ if( bHorizontal )
+ maHorizontalBorders[nCol][nRow] = pNew;
+ else
+ maVerticalBorders[nCol][nRow] = pNew;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::ClearBorderLayout()
+{
+ ClearBorderLayout(maHorizontalBorders);
+ ClearBorderLayout(maVerticalBorders);
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::ClearBorderLayout(BorderLineMap& rMap)
+{
+ const sal_Int32 nColCount = rMap.size();
+
+ for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
+ {
+ const sal_Int32 nRowCount = rMap[nCol].size();
+ for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
+ {
+ SvxBorderLine* pLine = rMap[nCol][nRow];
+ if( pLine )
+ {
+ if( pLine != &gEmptyBorder )
+ delete pLine;
+
+ rMap[nCol][nRow] = 0;
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::ResizeBorderLayout()
+{
+ ClearBorderLayout();
+ ResizeBorderLayout(maHorizontalBorders);
+ ResizeBorderLayout(maVerticalBorders);
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::ResizeBorderLayout( BorderLineMap& rMap )
+{
+ const sal_Int32 nColCount = getColumnCount() + 1;
+ const sal_Int32 nRowCount = getRowCount() + 1;
+
+ if( sal::static_int_cast<sal_Int32>(rMap.size()) != nColCount )
+ rMap.resize( nColCount );
+
+ for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
+ {
+ if( sal::static_int_cast<sal_Int32>(rMap[nCol].size()) != nRowCount )
+ rMap[nCol].resize( nRowCount );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::UpdateBorderLayout()
+{
+ // make sure old border layout is cleared and border maps have correct size
+ ResizeBorderLayout();
+
+ const sal_Int32 nColCount = getColumnCount();
+ const sal_Int32 nRowCount = getRowCount();
+
+ CellPos aPos;
+ for( aPos.mnRow = 0; aPos.mnRow < nRowCount; aPos.mnRow++ )
+ {
+ for( aPos.mnCol = 0; aPos.mnCol < nColCount; aPos.mnCol++ )
+ {
+ CellRef xCell( getCell( aPos ) );
+ if( !xCell.is() || xCell->isMerged() )
+ continue;
+
+ const SvxBoxItem* pThisAttr = (const SvxBoxItem*)xCell->GetItemSet().GetItem( SDRATTR_TABLE_BORDER );
+ OSL_ENSURE(pThisAttr,"sdr::table::TableLayouter::UpdateBorderLayout(), no border attribute?");
+
+ if( !pThisAttr )
+ continue;
+
+ const sal_Int32 nLastRow = xCell->getRowSpan() + aPos.mnRow;
+ const sal_Int32 nLastCol = xCell->getColumnSpan() + aPos.mnCol;
+
+ for( sal_Int32 nRow = aPos.mnRow; nRow < nLastRow; nRow++ )
+ {
+ SetBorder( aPos.mnCol, nRow, false, pThisAttr->GetLeft() );
+ SetBorder( nLastCol, nRow, false, pThisAttr->GetRight() );
+ }
+
+ for( sal_Int32 nCol = aPos.mnCol; nCol < nLastCol; nCol++ )
+ {
+ SetBorder( nCol, aPos.mnRow, true, pThisAttr->GetTop() );
+ SetBorder( nCol, nLastRow, true, pThisAttr->GetBottom() );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+/*
+void TableLayouter::SetLayoutToModel()
+{
+ const sal_Int32 nRowCount = getRowCount();
+ const sal_Int32 nColCount = getColumnCount();
+
+ try
+ {
+ sal_Int32 nOldSize = 0;
+
+ Reference< XIndexAccess > xRows( mxTable->getRows(), UNO_QUERY_THROW );
+ for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ )
+ {
+ Reference< XPropertySet > xRowSet( xRows->getByIndex( nRow ), UNO_QUERY_THROW );
+ xRowSet->getPropertyValue( msSize ) >>= nOldSize;
+ if( maRows[nRow].mnSize != nOldSize )
+ xRowSet->setPropertyValue( msSize, Any( maRows[nRow].mnSize ) );
+ }
+
+ for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
+ {
+ Reference< XPropertySet > xColSet( getColumnByIndex( nCol ), UNO_QUERY_THROW );
+ xColSet->getPropertyValue( msSize ) >>= nOldSize;
+ if( maColumns[nCol].mnSize != nOldSize )
+ xColSet->setPropertyValue( msSize, Any( maColumns[nCol].mnSize ) );
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("sdr::table::TableLayouter::SetLayoutToModel(), exception caught!");
+ }
+}
+*/
+// -----------------------------------------------------------------------------
+
+void TableLayouter::DistributeColumns( ::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol )
+{
+ if( mxTable.is() ) try
+ {
+ const sal_Int32 nColCount = getColumnCount();
+
+ if( (nFirstCol < 0) || (nFirstCol>= nLastCol) || (nLastCol >= nColCount) )
+ return;
+
+ sal_Int32 nAllWidth = 0;
+ for( sal_Int32 nCol = nFirstCol; nCol <= nLastCol; ++nCol )
+ nAllWidth += getColumnWidth(nCol);
+
+ sal_Int32 nWidth = nAllWidth / (nLastCol-nFirstCol+1);
+
+ Reference< XTableColumns > xCols( mxTable->getColumns(), UNO_QUERY_THROW );
+
+ for( sal_Int32 nCol = nFirstCol; nCol <= nLastCol; ++nCol )
+ {
+ if( nCol == nLastCol )
+ nWidth = nAllWidth; // last column get round errors
+
+ Reference< XPropertySet > xColSet( xCols->getByIndex( nCol ), UNO_QUERY_THROW );
+ xColSet->setPropertyValue( msSize, Any( nWidth ) );
+
+ nAllWidth -= nWidth;
+ }
+
+ LayoutTable( rArea, true, false );
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("sdr::table::TableLayouter::DistributeColumns(), exception caught!");
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow )
+{
+ if( mxTable.is() ) try
+ {
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+
+ if( (nFirstRow < 0) || (nFirstRow>= nLastRow) || (nLastRow >= nRowCount) )
+ return;
+
+ sal_Int32 nAllHeight = 0;
+ sal_Int32 nMinHeight = 0;
+
+ for( sal_Int32 nRow = nFirstRow; nRow <= nLastRow; ++nRow )
+ {
+ nMinHeight = std::max( maRows[nRow].mnMinSize, nMinHeight );
+ nAllHeight += maRows[nRow].mnSize;
+ }
+
+ const sal_Int32 nRows = (nLastRow-nFirstRow+1);
+ sal_Int32 nHeight = nAllHeight / nRows;
+
+ if( nHeight < nMinHeight )
+ {
+ sal_Int32 nNeededHeight = nRows * nMinHeight;
+ rArea.nBottom += nNeededHeight - nAllHeight;
+ nHeight = nMinHeight;
+ nAllHeight = nRows * nMinHeight;
+ }
+
+ Reference< XTableRows > xRows( mxTable->getRows(), UNO_QUERY_THROW );
+ for( sal_Int32 nRow = nFirstRow; nRow <= nLastRow; ++nRow )
+ {
+ if( nRow == nLastRow )
+ nHeight = nAllHeight; // last row get round errors
+
+ Reference< XPropertySet > xRowSet( xRows->getByIndex( nRow ), UNO_QUERY_THROW );
+ xRowSet->setPropertyValue( msSize, Any( nHeight ) );
+
+ nAllHeight -= nHeight;
+ }
+
+ LayoutTable( rArea, false, true );
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("sdr::table::TableLayouter::DistributeRows(), exception caught!");
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableLayouter::SetWritingMode( com::sun::star::text::WritingMode eWritingMode )
+{
+ meWritingMode = eWritingMode;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableLayouter::getColumnStart( sal_Int32 nColumn ) const
+{
+ if( isValidColumn(nColumn) )
+ return maColumns[nColumn].mnPos;
+ else
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableLayouter::getRowStart( sal_Int32 nRow ) const
+{
+ if( isValidRow(nRow) )
+ return maRows[nRow].mnPos;
+ else
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+/*
+sal_Int32 TableLayouter::detectInsertedOrRemovedRows()
+{
+ sal_Int32 nHeightChange = 0;
+
+ try
+ {
+ Reference< XIndexAccess > xRows( mxTable->getRows(), UNO_QUERY_THROW );
+ std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >::iterator oldIter( mxRows.begin() );
+ sal_Int32 nCount = xRows->getCount();
+ for( sal_Int32 nRow = 0; nRow < nCount; nRow++ )
+ {
+ Reference< XInterface > xRow( xRows->getByIndex(nRow), UNO_QUERY );
+
+ std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >::iterator searchIter = mxRows.end();
+ if( oldIter != mxRows.end() )
+ searchIter = std::find( oldIter,mxRows.end(), xRow );
+
+ if( searchIter == mxRows.end() )
+ {
+ // new row
+ Reference< XPropertySet > xSet( xRow, UNO_QUERY_THROW );
+ sal_Int32 nSize = 0;
+ xSet->getPropertyValue( msSize ) >>= nSize;
+ nHeightChange += nSize;
+ }
+ else if( searchIter == oldIter )
+ {
+ // no change
+ oldIter++;
+ }
+ else
+ {
+ // rows removed
+ do
+ {
+ Reference< XPropertySet > xSet( (*oldIter), UNO_QUERY_THROW );
+ sal_Int32 nSize = 0;
+ xSet->getPropertyValue( msSize ) >>= nSize;
+ nHeightChange -= nSize;
+ }
+ while( oldIter++ != searchIter );
+ }
+ }
+
+ while( oldIter != mxRows.end() )
+ {
+ // rows removed
+ Reference< XPropertySet > xSet( (*oldIter++), UNO_QUERY_THROW );
+ sal_Int32 nSize = 0;
+ xSet->getPropertyValue( msSize ) >>= nSize;
+ nHeightChange -= nSize;
+ }
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("svx::TableLayouter::detectInsertedOrRemovedRows(), exception caught!");
+ }
+
+ return nHeightChange;
+}
+*/
+
+// -----------------------------------------------------------------------------
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablelayouter.hxx b/svx/source/table/tablelayouter.hxx
new file mode 100644
index 000000000000..6bb9d1b735b4
--- /dev/null
+++ b/svx/source/table/tablelayouter.hxx
@@ -0,0 +1,181 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TABLE_TABLELAYOUTER_HXX_
+#define _SVX_TABLE_TABLELAYOUTER_HXX_
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/text/WritingMode.hpp>
+#include <com/sun/star/table/XTable.hpp>
+#include <basegfx/range/b2irectangle.hxx>
+#include <basegfx/tuple/b2ituple.hxx>
+#include <tools/gen.hxx>
+#include <boost/shared_ptr.hpp>
+#include <vector>
+#include <map>
+
+#include "svx/svdotable.hxx"
+
+// -----------------------------------------------------------------------------
+
+class SvxBorderLine;
+
+namespace sdr { namespace table {
+
+/** returns true if the cell(nMergedCol,nMergedRow) is merged with other cells.
+ the returned cell( rOriginCol, rOriginRow ) is the origin( top left cell ) of the merge.
+*/
+bool findMergeOrigin( const TableModelRef& xTable, sal_Int32 nMergedCol, sal_Int32 nMergedRow, sal_Int32& rOriginCol, sal_Int32& rOriginRow );
+
+typedef std::vector< SvxBorderLine* > BorderLineVector;
+typedef std::vector< BorderLineVector > BorderLineMap;
+
+// -----------------------------------------------------------------------------
+// TableModel
+// -----------------------------------------------------------------------------
+
+class TableLayouter
+{
+public:
+ TableLayouter( const TableModelRef& xTableModel );
+ virtual ~TableLayouter();
+
+ /** this checks if new rows are inserted or old rows where removed.
+ This can be used to grow or shrink the table shape in this case.
+ @returns
+ the height difference
+ sal_Int32 detectInsertedOrRemovedRows();
+ */
+
+ /** try to fit the table into the given rectangle.
+ If the rectangle is to small, it will be grown to fit the table.
+
+ if bFitWidth or bFitHeight is set, the layouter tries to scale
+ the rows and/or columns to the given area. The result my be bigger
+ to fullfill constrains.
+
+ if bFitWidth or bFitHeight is set, the model is changed.
+ */
+ void LayoutTable( ::Rectangle& rRectangle, bool bFitWidth, bool bFitHeight );
+
+ /** after a call to LayoutTable, this method can be used to set the new
+ column and row sizes back to the model. */
+// void SetLayoutToModel();
+
+ void UpdateBorderLayout();
+
+ basegfx::B2ITuple getCellSize( const CellPos& rPos ) const;
+ bool getCellArea( const CellRef& xCell, basegfx::B2IRectangle& rArea ) const;
+ bool getCellArea( const CellPos& rPos, basegfx::B2IRectangle& rArea ) const;
+
+ ::sal_Int32 getRowCount() const { return static_cast< ::sal_Int32 >( maRows.size() ); }
+ ::sal_Int32 getColumnCount() const { return static_cast< ::sal_Int32 >( maColumns.size() ); }
+
+ sal_Int32 getRowHeight( sal_Int32 nRow );
+
+ // sets the layout height of the given row hard, LayoutTable must be called directly after calling this method! */
+ void setRowHeight( sal_Int32 nRow, sal_Int32 nHeight );
+
+ sal_Int32 getColumnWidth( sal_Int32 nColumn );
+
+ // sets the layout width of the given column hard, LayoutTable must be called directly after calling this method! */
+ void setColumnWidth( sal_Int32 nColumn, sal_Int32 nWidth );
+
+ sal_Int32 getMinimumColumnWidth( sal_Int32 nColumn );
+
+ sal_Int32 getColumnStart( sal_Int32 nColumn ) const;
+ sal_Int32 getRowStart( sal_Int32 nRow ) const;
+
+ /** checks if the given edge is visible.
+ Edges between merged cells are not visible.
+ */
+ bool isEdgeVisible( sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal ) const;
+
+ /** returns the requested borderline in rpBorderLine or a null pointer if there is no border at this edge */
+ SvxBorderLine* getBorderLine( sal_Int32 nEdgeX, sal_Int32 nEdgeY, bool bHorizontal )const;
+
+ void updateCells( ::Rectangle& rRectangle );
+
+ sal_Int32 getHorizontalEdge( int nEdgeY, sal_Int32* pnMin = 0, sal_Int32* pnMax = 0 );
+ sal_Int32 getVerticalEdge( int nEdgeX , sal_Int32* pnMin = 0, sal_Int32* pnMax = 0);
+
+ void DistributeColumns( ::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol );
+ void DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow );
+
+ com::sun::star::text::WritingMode GetWritingMode() const { return meWritingMode; }
+ void SetWritingMode( com::sun::star::text::WritingMode eWritingMode );
+
+private:
+ CellRef getCell( const CellPos& rPos ) const;
+
+ void LayoutTableWidth( ::Rectangle& rArea, bool bFit );
+ void LayoutTableHeight( ::Rectangle& rArea, bool bFit );
+
+ inline bool isValidColumn( sal_Int32 nColumn ) const { return (nColumn >= 0) && (nColumn < static_cast<sal_Int32>( maColumns.size())); }
+ inline bool isValidRow( sal_Int32 nRow ) const { return (nRow >= 0) && (nRow < static_cast<sal_Int32>( maRows.size())); }
+ inline bool isValid( const CellPos& rPos ) const { return isValidColumn( rPos.mnCol ) && isValidRow( rPos.mnRow ); }
+
+ void ClearBorderLayout();
+ void ClearBorderLayout(BorderLineMap& rMap);
+ void ResizeBorderLayout();
+ void ResizeBorderLayout( BorderLineMap& rMap );
+
+ void SetBorder( sal_Int32 nCol, sal_Int32 nRow, bool bHorizontal, const SvxBorderLine* pLine );
+
+ static bool HasPriority( const SvxBorderLine* pThis, const SvxBorderLine* pOther );
+
+ struct Layout
+ {
+ sal_Int32 mnPos;
+ sal_Int32 mnSize;
+ sal_Int32 mnMinSize;
+
+ Layout() : mnPos( 0 ), mnSize( 0 ), mnMinSize( 0 ) {}
+ void clear() { mnPos = 0; mnSize = 0; mnMinSize = 0; }
+ };
+ typedef std::vector< Layout > LayoutVector;
+
+ sal_Int32 distribute( LayoutVector& rLayouts, sal_Int32 nDistribute );
+
+ TableModelRef mxTable;
+ LayoutVector maRows;
+ LayoutVector maColumns;
+
+ BorderLineMap maHorizontalBorders;
+ BorderLineMap maVerticalBorders;
+
+ com::sun::star::text::WritingMode meWritingMode;
+
+ const rtl::OUString msSize;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx
new file mode 100644
index 000000000000..baa1c0269bf1
--- /dev/null
+++ b/svx/source/table/tablemodel.cxx
@@ -0,0 +1,1260 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/table/XMergeableCell.hpp>
+
+#include <algorithm>
+#include <boost/bind.hpp>
+
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+
+#include "cell.hxx"
+#include "cellcursor.hxx"
+#include "tablemodel.hxx"
+#include "tablerow.hxx"
+#include "tablerows.hxx"
+#include "tablecolumn.hxx"
+#include "tablecolumns.hxx"
+#include "tableundo.hxx"
+#include "svx/svdotable.hxx"
+#include "svx/svdmodel.hxx"
+#include "svdstr.hrc"
+#include "svdglob.hxx"
+
+//#define PLEASE_DEBUG_THE_TABLES 1
+
+using ::rtl::OUString;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+
+// removes the given range from a vector
+template< class Vec, class Iter > void remove_range( Vec& rVector, sal_Int32 nIndex, sal_Int32 nCount )
+{
+ const sal_Int32 nSize = static_cast<sal_Int32>(rVector.size());
+ if( nCount && (nIndex >= 0) && (nIndex < nSize) )
+ {
+ if( (nIndex + nCount) >= nSize )
+ {
+ // remove at end
+ rVector.resize( nIndex );
+ }
+ else
+ {
+ Iter aBegin( rVector.begin() );
+ while( nIndex-- )
+ aBegin++;
+ if( nCount == 1 )
+ {
+ rVector.erase( aBegin );
+ }
+ else
+ {
+ Iter aEnd( aBegin );
+
+ while( nCount-- )
+ aEnd++;
+ rVector.erase( aBegin, aEnd );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+/** inserts a range into a vector */
+template< class Vec, class Iter, class Entry > sal_Int32 insert_range( Vec& rVector, sal_Int32 nIndex, sal_Int32 nCount )
+{
+ if( nCount )
+ {
+ if( nIndex >= static_cast< sal_Int32 >( rVector.size() ) )
+ {
+ // append at end
+ nIndex = static_cast< sal_Int32 >( rVector.size() ); // cap to end
+ rVector.resize( nIndex + nCount );
+ }
+ else
+ {
+ // insert
+ sal_Int32 nFind = nIndex;
+ Iter aIter( rVector.begin() );
+ while( nFind-- )
+ aIter++;
+
+ Entry aEmpty;
+ rVector.insert( aIter, nCount, aEmpty );
+ }
+ }
+ return nIndex;
+}
+
+// -----------------------------------------------------------------------------
+
+TableModel::TableModel( SdrTableObj* pTableObj )
+: TableModelBase( m_aMutex )
+, mpTableObj( pTableObj )
+, mbModified( sal_False )
+, mbNotifyPending( false )
+, mnNotifyLock( 0 )
+{
+}
+
+TableModel::TableModel( SdrTableObj* pTableObj, const TableModelRef& xSourceTable )
+: TableModelBase( m_aMutex )
+, mpTableObj( pTableObj )
+, mbModified( sal_False )
+, mbNotifyPending( false )
+, mnNotifyLock( 0 )
+{
+ if( xSourceTable.is() )
+ {
+ const sal_Int32 nColCount = xSourceTable->getColumnCountImpl();
+ const sal_Int32 nRowCount = xSourceTable->getRowCountImpl();
+
+ init( nColCount, nRowCount );
+
+ sal_Int32 nRows = nRowCount;
+ while( nRows-- )
+ (*maRows[nRows]) = (*xSourceTable->maRows[nRows]);
+
+ sal_Int32 nColumns = nColCount;
+ while( nColumns-- )
+ (*maColumns[nColumns]) = (*xSourceTable->maColumns[nColumns]);
+
+ // copy cells
+ for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol )
+ {
+ for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ CellRef xTargetCell( getCell( nCol, nRow ) );
+ if( xTargetCell.is() )
+ xTargetCell->cloneFrom( xSourceTable->getCell( nCol, nRow ) );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+TableModel::~TableModel()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::init( sal_Int32 nColumns, sal_Int32 nRows )
+{
+ if( nRows < 20 )
+ maRows.reserve( 20 );
+
+ if( nColumns < 20 )
+ maColumns.reserve( 20 );
+
+ if( nRows && nColumns )
+ {
+ maColumns.resize( nColumns );
+ maRows.resize( nRows );
+
+ while( nRows-- )
+ maRows[nRows].set( new TableRow( this, nRows, nColumns ) );
+
+ while( nColumns-- )
+ maColumns[nColumns].set( new TableColumn( this, nColumns ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+// ICellRange
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableModel::getLeft()
+{
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableModel::getTop()
+{
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableModel::getRight()
+{
+ return getColumnCount();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableModel::getBottom()
+{
+ return getRowCount();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XTable > TableModel::getTable()
+{
+ return this;
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::UndoInsertRows( sal_Int32 nIndex, sal_Int32 nCount )
+{
+ TableModelNotifyGuard aGuard( this );
+
+ // remove the rows
+ remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount );
+ updateRows();
+ setModified(sal_True);
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::UndoRemoveRows( sal_Int32 nIndex, RowVector& aRows )
+{
+ TableModelNotifyGuard aGuard( this );
+
+ const sal_Int32 nCount = sal::static_int_cast< sal_Int32 >( aRows.size() );
+
+ nIndex = insert_range<RowVector,RowVector::iterator,TableRowRef>( maRows, nIndex, nCount );
+
+ for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset )
+ maRows[nIndex+nOffset] = aRows[nOffset];
+
+ updateRows();
+ setModified(sal_True);
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::UndoInsertColumns( sal_Int32 nIndex, sal_Int32 nCount )
+{
+ TableModelNotifyGuard aGuard( this );
+
+ // now remove the columns
+ remove_range<ColumnVector,ColumnVector::iterator>( maColumns, nIndex, nCount );
+ sal_Int32 nRows = getRowCountImpl();
+ while( nRows-- )
+ maRows[nRows]->removeColumns( nIndex, nCount );
+
+ updateColumns();
+ setModified(sal_True);
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::UndoRemoveColumns( sal_Int32 nIndex, ColumnVector& aCols, CellVector& aCells )
+{
+ TableModelNotifyGuard aGuard( this );
+
+ const sal_Int32 nCount = sal::static_int_cast< sal_Int32 >( aCols.size() );
+
+ // assert if there are not enough cells saved
+ DBG_ASSERT( (aCols.size() * maRows.size()) == aCells.size(), "sdr::table::TableModel::UndoRemoveColumns(), invalid undo data!" );
+
+ nIndex = insert_range<ColumnVector,ColumnVector::iterator,TableColumnRef>( maColumns, nIndex, nCount );
+ for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset )
+ maColumns[nIndex+nOffset] = aCols[nOffset];
+
+ CellVector::iterator aIter( aCells.begin() );
+
+ sal_Int32 nRows = getRowCountImpl();
+ for( sal_Int32 nRow = 0; nRow < nRows; ++nRow )
+ maRows[nRow]->insertColumns( nIndex, nCount, &aIter );
+
+ updateColumns();
+ setModified(sal_True);
+}
+
+// -----------------------------------------------------------------------------
+// XTable
+// -----------------------------------------------------------------------------
+
+Reference< XCellCursor > SAL_CALL TableModel::createCursor() throw (RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ return createCursorByRange( Reference< XCellRange >( this ) );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellCursor > SAL_CALL TableModel::createCursorByRange( const Reference< XCellRange >& Range ) throw (IllegalArgumentException, RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ ICellRange* pRange = dynamic_cast< ICellRange* >( Range.get() );
+ if( (pRange == 0) || (pRange->getTable().get() != this) )
+ throw IllegalArgumentException();
+
+ TableModelRef xModel( this );
+ return new CellCursor( xModel, pRange->getLeft(), pRange->getTop(), pRange->getRight(), pRange->getBottom() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL TableModel::getRowCount() throw (RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ return getRowCountImpl();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL TableModel::getColumnCount() throw (RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ return getColumnCountImpl();
+}
+
+// -----------------------------------------------------------------------------
+// XComponent
+// -----------------------------------------------------------------------------
+
+void TableModel::dispose() throw (RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ TableModelBase::dispose();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
+{
+ TableModelBase::addEventListener( xListener );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
+{
+ TableModelBase::removeEventListener( xListener );
+}
+
+// -----------------------------------------------------------------------------
+// XModifiable
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL TableModel::isModified( ) throw (RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ return mbModified;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::setModified( sal_Bool bModified ) throw (PropertyVetoException, RuntimeException)
+{
+ {
+ ::SolarMutexGuard aGuard;
+ mbModified = bModified;
+ }
+ if( bModified )
+ notifyModification();
+}
+
+// -----------------------------------------------------------------------------
+// XModifyBroadcaster
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::addModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException)
+{
+ rBHelper.addListener( XModifyListener::static_type() , xListener );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::removeModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException)
+{
+ rBHelper.removeListener( XModifyListener::static_type() , xListener );
+}
+
+// -----------------------------------------------------------------------------
+// XColumnRowRange
+// -----------------------------------------------------------------------------
+
+Reference< XTableColumns > SAL_CALL TableModel::getColumns() throw (RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( !mxTableColumns.is() )
+ mxTableColumns.set( new TableColumns( this ) );
+ return mxTableColumns.get();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XTableRows > SAL_CALL TableModel::getRows() throw (RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( !mxTableRows.is() )
+ mxTableRows.set( new TableRows( this ) );
+ return mxTableRows.get();
+}
+
+// -----------------------------------------------------------------------------
+// XCellRange
+// -----------------------------------------------------------------------------
+
+Reference< XCell > SAL_CALL TableModel::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw ( IndexOutOfBoundsException, RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ CellRef xCell( getCell( nColumn, nRow ) );
+ if( xCell.is() )
+ return xCell.get();
+
+ throw IndexOutOfBoundsException();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellRange > SAL_CALL TableModel::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( (nLeft >= 0) && (nTop >= 0) && (nRight >= nLeft) && (nBottom >= nTop) && (nRight < getColumnCountImpl()) && (nBottom < getRowCountImpl() ) )
+ {
+ TableModelRef xModel( this );
+ return new CellRange( xModel, nLeft, nTop, nRight, nBottom );
+ }
+
+ throw IndexOutOfBoundsException();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellRange > SAL_CALL TableModel::getCellRangeByName( const OUString& /*aRange*/ ) throw (RuntimeException)
+{
+ return Reference< XCellRange >();
+}
+
+// -----------------------------------------------------------------------------
+// XPropertySet
+// -----------------------------------------------------------------------------
+
+Reference< XPropertySetInfo > SAL_CALL TableModel::getPropertySetInfo( ) throw (RuntimeException)
+{
+ Reference< XPropertySetInfo > xInfo;
+ return xInfo;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::setPropertyValue( const ::rtl::OUString& /*aPropertyName*/, const Any& /*aValue*/ ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL TableModel::getPropertyValue( const OUString& /*PropertyName*/ ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ return Any();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::addPropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*xListener*/ ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::removePropertyChangeListener( const OUString& /*aPropertyName*/, const Reference< XPropertyChangeListener >& /*xListener*/ ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::addVetoableChangeListener( const OUString& /*aPropertyName*/, const Reference< XVetoableChangeListener >& /*xListener*/ ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::removeVetoableChangeListener( const OUString& /*aPropertyName*/, const Reference< XVetoableChangeListener >& /*xListener*/ ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+// XFastPropertySet
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableModel::setFastPropertyValue( ::sal_Int32 /*nHandle*/, const Any& /*aValue*/ ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL TableModel::getFastPropertyValue( ::sal_Int32 /*nHandle*/ ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ Any aAny;
+ return aAny;
+}
+
+// -----------------------------------------------------------------------------
+// internals
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableModel::getRowCountImpl() const
+{
+ return static_cast< sal_Int32 >( maRows.size() );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 TableModel::getColumnCountImpl() const
+{
+ return static_cast< sal_Int32 >( maColumns.size() );
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::disposing()
+{
+ if( !maRows.empty() )
+ {
+ RowVector::iterator aIter( maRows.begin() );
+ while( aIter != maRows.end() )
+ (*aIter++)->dispose();
+ RowVector().swap(maRows);
+ }
+
+ if( !maColumns.empty() )
+ {
+ ColumnVector::iterator aIter( maColumns.begin() );
+ while( aIter != maColumns.end() )
+ (*aIter++)->dispose();
+ ColumnVector().swap(maColumns);
+ }
+
+ if( mxTableColumns.is() )
+ {
+ mxTableColumns->dispose();
+ mxTableColumns.clear();
+ }
+
+ if( mxTableRows.is() )
+ {
+ mxTableRows->dispose();
+ mxTableRows.clear();
+ }
+
+ mpTableObj = 0;
+}
+
+// -----------------------------------------------------------------------------
+// XBroadcaster
+// -----------------------------------------------------------------------------
+
+void TableModel::lockBroadcasts() throw (RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ ++mnNotifyLock;
+}
+// -----------------------------------------------------------------------------
+
+void TableModel::unlockBroadcasts() throw (RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ --mnNotifyLock;
+ if( mnNotifyLock <= 0 )
+ {
+ mnNotifyLock = 0;
+ if( mbNotifyPending )
+ notifyModification();
+ }
+}
+
+// -----------------------------------------------------------------------------
+#ifdef PLEASE_DEBUG_THE_TABLES
+#include <stdio.h>
+#endif
+
+void TableModel::notifyModification()
+{
+ ::osl::MutexGuard guard( m_aMutex );
+ if( (mnNotifyLock == 0) && mpTableObj && mpTableObj->GetModel() )
+ {
+ mbNotifyPending = false;
+
+ ::cppu::OInterfaceContainerHelper * pModifyListeners = rBHelper.getContainer( XModifyListener::static_type() );
+ if( pModifyListeners )
+ {
+ EventObject aSource;
+ aSource.Source = static_cast< ::cppu::OWeakObject* >(this);
+ pModifyListeners->notifyEach( &XModifyListener::modified, aSource);
+ }
+ }
+ else
+ {
+ mbNotifyPending = true;
+ }
+
+#ifdef PLEASE_DEBUG_THE_TABLES
+ FILE* file = fopen( "c:\\table.xml","w" );
+
+ const sal_Int32 nColCount = getColumnCountImpl();
+ const sal_Int32 nRowCount = getRowCountImpl();
+
+ fprintf( file, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\r" );
+ fprintf( file, "<table columns=\"%ld\" rows=\"%ld\" updated=\"%s\">\n\r", nColCount, nRowCount, mbNotifyPending ? "false" : "true");
+
+ for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol )
+ {
+ fprintf( file, "<column this=\"%lx\"/>\n\r", maColumns[nCol].get() );
+ }
+
+ // first check merged cells before and inside the removed rows
+ for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ fprintf( file, "<row this=\"%lx\">\n\r", maRows[nRow].get() );
+ for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol )
+ {
+ CellRef xCell( getCell( nCol, nRow ) );
+ fprintf( file, "<cell this=\"%lx\"", xCell.get() );
+
+ sal_Int32 nRowSpan = xCell->getRowSpan();
+ sal_Int32 nColSpan = xCell->getColumnSpan();
+ sal_Bool bMerged = xCell->isMerged();
+
+ if( nColSpan != 1 )
+ fprintf( file, " column-span=\"%ld\"", nColSpan );
+ if( nRowSpan != 1 )
+ fprintf( file, " row-span=\"%ld\"", nRowSpan );
+
+ if( bMerged )
+ fprintf( file, " merged=\"true\"" );
+
+ fprintf( file, "/>" );
+ }
+ fprintf( file, "\n\r</row>\n\r" );
+ }
+
+ fprintf( file, "</table>\n\r" );
+ fclose( file );
+#endif
+}
+
+// -----------------------------------------------------------------------------
+
+CellRef TableModel::getCell( sal_Int32 nCol, sal_Int32 nRow ) const
+{
+ if( ((nRow >= 0) && (nRow < getRowCountImpl())) && (nCol >= 0) && (nCol < getColumnCountImpl()) )
+ {
+ return maRows[nRow]->maCells[nCol];
+ }
+ else
+ {
+ CellRef xRet;
+ return xRet;
+ }
+}
+
+// -----------------------------------------------------------------------------
+/*
+bool TableModel::getCellPos( const CellRef& xCell, ::sal_Int32& rnCol, ::sal_Int32& rnRow ) const
+{
+ const sal_Int32 nRowCount = getRowCount();
+ const sal_Int32 nColCount = getColumnCount();
+ for( rnRow = 0; rnRow < nRowCount; rnRow++ )
+ {
+ for( rnCol = 0; rnCol < nColCount; rnCol++ )
+ {
+ if( maRows[rnRow]->maCells[rnCol] == xCell )
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+*/
+
+// -----------------------------------------------------------------------------
+
+CellRef TableModel::createCell()
+{
+ CellRef xCell;
+ if( mpTableObj )
+ mpTableObj->createCell( xCell );
+ return xCell;
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::insertColumns( sal_Int32 nIndex, sal_Int32 nCount )
+{
+ if( nCount && mpTableObj )
+ {
+ try
+ {
+ SdrModel* pModel = mpTableObj->GetModel();
+
+ TableModelNotifyGuard aGuard( this );
+ nIndex = insert_range<ColumnVector,ColumnVector::iterator,TableColumnRef>( maColumns, nIndex, nCount );
+
+ sal_Int32 nRows = getRowCountImpl();
+ while( nRows-- )
+ maRows[nRows]->insertColumns( nIndex, nCount );
+
+ ColumnVector aNewColumns(nCount);
+ for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset )
+ {
+ TableColumnRef xNewCol( new TableColumn( this, nIndex+nOffset ) );
+ maColumns[nIndex+nOffset] = xNewCol;
+ aNewColumns[nOffset] = xNewCol;
+ }
+
+ const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ if( bUndo )
+ {
+ pModel->BegUndo( ImpGetResStr(STR_TABLE_INSCOL) );
+ pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+
+ TableModelRef xThis( this );
+
+ nRows = getRowCountImpl();
+ CellVector aNewCells( nCount * nRows );
+ CellVector::iterator aCellIter( aNewCells.begin() );
+
+ nRows = getRowCountImpl();
+ for( sal_Int32 nRow = 0; nRow < nRows; ++nRow )
+ {
+ for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset )
+ (*aCellIter++) = getCell( nIndex + nOffset, nRow );
+ }
+
+ pModel->AddUndo( new InsertColUndo( xThis, nIndex, aNewColumns, aNewCells ) );
+ }
+
+ const sal_Int32 nRowCount = getRowCountImpl();
+ // check if cells merge over new columns
+ for( sal_Int32 nCol = 0; nCol < nIndex; ++nCol )
+ {
+ for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ CellRef xCell( getCell( nCol, nRow ) );
+ sal_Int32 nColSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getColumnSpan() : 1;
+ if( (nColSpan != 1) && ((nColSpan + nCol ) > nIndex) )
+ {
+ // cell merges over newly created columns, so add the new columns to the merged cell
+ const sal_Int32 nRowSpan = xCell->getRowSpan();
+ nColSpan += nCount;
+ merge( nCol, nRow, nColSpan, nRowSpan );
+ }
+ }
+ }
+
+ if( bUndo )
+ pModel->EndUndo();
+
+ if( pModel )
+ pModel->SetChanged();
+
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("sdr::table::TableModel::insertColumns(), exception caught!");
+ }
+ updateColumns();
+ setModified(sal_True);
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
+{
+ sal_Int32 nColCount = getColumnCountImpl();
+
+ if( mpTableObj && nCount && (nIndex >= 0) && (nIndex < nColCount) )
+ {
+ try
+ {
+ TableModelNotifyGuard aGuard( this );
+
+ // clip removed columns to columns actually avalaible
+ if( (nIndex + nCount) > nColCount )
+ nCount = nColCount - nIndex;
+
+ sal_Int32 nRows = getRowCountImpl();
+
+ SdrModel* pModel = mpTableObj->GetModel();
+
+ const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ if( bUndo )
+ {
+ pModel->BegUndo( ImpGetResStr(STR_UNDO_COL_DELETE) );
+ pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+
+ TableModelRef xThis( this );
+ ColumnVector aRemovedCols( nCount );
+ sal_Int32 nOffset;
+ for( nOffset = 0; nOffset < nCount; ++nOffset )
+ {
+ aRemovedCols[nOffset] = maColumns[nIndex+nOffset];
+ }
+
+ CellVector aRemovedCells( nCount * nRows );
+ CellVector::iterator aCellIter( aRemovedCells.begin() );
+ for( sal_Int32 nRow = 0; nRow < nRows; ++nRow )
+ {
+ for( nOffset = 0; nOffset < nCount; ++nOffset )
+ (*aCellIter++) = getCell( nIndex + nOffset, nRow );
+ }
+
+ pModel->AddUndo( new RemoveColUndo( xThis, nIndex, aRemovedCols, aRemovedCells ) );
+ }
+
+ // only rows before and inside the removed rows are considered
+ nColCount = nIndex + nCount + 1;
+
+ const sal_Int32 nRowCount = getRowCountImpl();
+
+ // first check merged cells before and inside the removed rows
+ for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol )
+ {
+ for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ CellRef xCell( getCell( nCol, nRow ) );
+ sal_Int32 nColSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getColumnSpan() : 1;
+ if( nColSpan <= 1 )
+ continue;
+
+ if( nCol >= nIndex )
+ {
+ // current cell is inside the removed columns
+ if( (nCol + nColSpan) > ( nIndex + nCount ) )
+ {
+ // current cells merges with columns after the removed columns
+ const sal_Int32 nRemove = nCount - nCol + nIndex;
+
+ CellRef xTargetCell( getCell( nIndex + nCount, nRow ) );
+ if( xTargetCell.is() )
+ {
+ if( bUndo )
+ xTargetCell->AddUndo();
+ xTargetCell->merge( nColSpan - nRemove, xCell->getRowSpan() );
+ xTargetCell->replaceContentAndFormating( xCell );
+ }
+ }
+ }
+ else if( nColSpan > (nIndex - nCol) )
+ {
+ // current cells spans inside the removed columns, so adjust
+ const sal_Int32 nRemove = ::std::min( nCount, nCol + nColSpan - nIndex );
+ if( bUndo )
+ xCell->AddUndo();
+ xCell->merge( nColSpan - nRemove, xCell->getRowSpan() );
+ }
+ }
+ }
+
+ // now remove the columns
+ remove_range<ColumnVector,ColumnVector::iterator>( maColumns, nIndex, nCount );
+ while( nRows-- )
+ maRows[nRows]->removeColumns( nIndex, nCount );
+
+ if( bUndo )
+ pModel->EndUndo();
+
+ if( pModel )
+ pModel->SetChanged();
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("sdr::table::TableModel::removeColumns(), exception caught!");
+ }
+
+ updateColumns();
+ setModified(sal_True);
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::insertRows( sal_Int32 nIndex, sal_Int32 nCount )
+{
+ if( nCount && mpTableObj )
+ {
+ SdrModel* pModel = mpTableObj->GetModel();
+ const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+ try
+ {
+ TableModelNotifyGuard aGuard( this );
+
+ nIndex = insert_range<RowVector,RowVector::iterator,TableRowRef>( maRows, nIndex, nCount );
+
+ RowVector aNewRows(nCount);
+ const sal_Int32 nColCount = getColumnCountImpl();
+ for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset )
+ {
+ TableRowRef xNewRow( new TableRow( this, nIndex+nOffset, nColCount ) );
+ maRows[nIndex+nOffset] = xNewRow;
+ aNewRows[nOffset] = xNewRow;
+ }
+
+ if( bUndo )
+ {
+ pModel->BegUndo( ImpGetResStr(STR_TABLE_INSROW) );
+ pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+ TableModelRef xThis( this );
+ pModel->AddUndo( new InsertRowUndo( xThis, nIndex, aNewRows ) );
+ }
+
+ // check if cells merge over new columns
+ for( sal_Int32 nRow = 0; nRow < nIndex; ++nRow )
+ {
+ for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol )
+ {
+ CellRef xCell( getCell( nCol, nRow ) );
+ sal_Int32 nRowSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getRowSpan() : 1;
+ if( (nRowSpan > 1) && ((nRowSpan + nRow) > nIndex) )
+ {
+ // cell merges over newly created columns, so add the new columns to the merged cell
+ const sal_Int32 nColSpan = xCell->getColumnSpan();
+ nRowSpan += nCount;
+ merge( nCol, nRow, nColSpan, nRowSpan );
+ }
+ }
+ }
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("sdr::table::TableModel::insertRows(), exception caught!");
+ }
+ if( bUndo )
+ pModel->EndUndo();
+
+ if( pModel )
+ pModel->SetChanged();
+
+ updateRows();
+ setModified(sal_True);
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::removeRows( sal_Int32 nIndex, sal_Int32 nCount )
+{
+ sal_Int32 nRowCount = getRowCountImpl();
+
+ if( mpTableObj && nCount && (nIndex >= 0) && (nIndex < nRowCount) )
+ {
+ SdrModel* pModel = mpTableObj->GetModel();
+ const bool bUndo = pModel && mpTableObj->IsInserted()&& pModel->IsUndoEnabled();
+
+ try
+ {
+ TableModelNotifyGuard aGuard( this );
+
+ // clip removed rows to rows actually avalaible
+ if( (nIndex + nCount) > nRowCount )
+ nCount = nRowCount - nIndex;
+
+ if( bUndo )
+ {
+ pModel->BegUndo( ImpGetResStr(STR_UNDO_ROW_DELETE) );
+ pModel->AddUndo( pModel->GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) );
+
+ TableModelRef xThis( this );
+
+ RowVector aRemovedRows( nCount );
+ for( sal_Int32 nOffset = 0; nOffset < nCount; ++nOffset )
+ aRemovedRows[nOffset] = maRows[nIndex+nOffset];
+
+ pModel->AddUndo( new RemoveRowUndo( xThis, nIndex, aRemovedRows ) );
+ }
+
+ // only rows before and inside the removed rows are considered
+ nRowCount = nIndex + nCount + 1;
+
+ const sal_Int32 nColCount = getColumnCountImpl();
+
+ // first check merged cells before and inside the removed rows
+ for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol )
+ {
+ CellRef xCell( getCell( nCol, nRow ) );
+ sal_Int32 nRowSpan = (xCell.is() && !xCell->isMerged()) ? xCell->getRowSpan() : 1;
+ if( nRowSpan <= 1 )
+ continue;
+
+ if( nRow >= nIndex )
+ {
+ // current cell is inside the removed rows
+ if( (nRow + nRowSpan) > (nIndex + nCount) )
+ {
+ // current cells merges with rows after the removed rows
+ const sal_Int32 nRemove = nCount - nRow + nIndex;
+
+ CellRef xTargetCell( getCell( nCol, nIndex + nCount ) );
+ if( xTargetCell.is() )
+ {
+ if( bUndo )
+ xTargetCell->AddUndo();
+ xTargetCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove );
+ xTargetCell->replaceContentAndFormating( xCell );
+ }
+ }
+ }
+ else if( nRowSpan > (nIndex - nRow) )
+ {
+ // current cells spans inside the removed rows, so adjust
+ const sal_Int32 nRemove = ::std::min( nCount, nRow + nRowSpan - nIndex );
+ if( bUndo )
+ xCell->AddUndo();
+ xCell->merge( xCell->getColumnSpan(), nRowSpan - nRemove );
+ }
+ }
+ }
+
+ // now remove the rows
+ remove_range<RowVector,RowVector::iterator>( maRows, nIndex, nCount );
+
+ if( bUndo )
+ pModel->EndUndo();
+
+ if( pModel )
+ pModel->SetChanged();
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("sdr::table::TableModel::removeRows(), exception caught!");
+ }
+
+ updateRows();
+ setModified(sal_True);
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+TableRowRef TableModel::getRow( sal_Int32 nRow ) const throw (IndexOutOfBoundsException)
+{
+ if( (nRow >= 0) && (nRow < getRowCountImpl()) )
+ return maRows[nRow];
+
+ throw IndexOutOfBoundsException();
+}
+
+// -----------------------------------------------------------------------------
+
+TableColumnRef TableModel::getColumn( sal_Int32 nColumn ) const throw (IndexOutOfBoundsException)
+{
+ if( (nColumn >= 0) && (nColumn < getColumnCountImpl()) )
+ return maColumns[nColumn];
+
+ throw IndexOutOfBoundsException();
+}
+
+// -----------------------------------------------------------------------------
+
+/** deletes rows and columns that are completly merged. Must be called between BegUndo/EndUndo! */
+void TableModel::optimize()
+{
+ TableModelNotifyGuard aGuard( this );
+
+ bool bWasModified = false;
+
+ if( !maRows.empty() && !maColumns.empty() )
+ {
+ sal_Int32 nCol = getColumnCountImpl() - 1;
+ while( nCol > 0 )
+ {
+ bool bEmpty = true;
+ for( sal_Int32 nRow = 0; (nRow < getRowCountImpl()) && bEmpty; nRow++ )
+ {
+ Reference< XMergeableCell > xCell( getCellByPosition( nCol, nRow ), UNO_QUERY );
+ if( xCell.is() && !xCell->isMerged() )
+ bEmpty = false;
+ }
+
+ if( bEmpty )
+ {
+ if( nCol > 0 ) try
+ {
+ const OUString sWidth( RTL_CONSTASCII_USTRINGPARAM("Width") );
+ sal_Int32 nWidth1 = 0, nWidth2 = 0;
+ Reference< XPropertySet > xSet1( static_cast< XCellRange* >( maColumns[nCol].get() ), UNO_QUERY_THROW );
+ Reference< XPropertySet > xSet2( static_cast< XCellRange* >( maColumns[nCol-1].get() ), UNO_QUERY_THROW );
+ xSet1->getPropertyValue( sWidth ) >>= nWidth1;
+ xSet2->getPropertyValue( sWidth ) >>= nWidth2;
+ nWidth1 += nWidth2;
+ xSet2->setPropertyValue( sWidth, Any( nWidth1 ) );
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("svx::TableModel::optimize(), exception caught!");
+ }
+
+ removeColumns( nCol, 1 );
+ bWasModified = true;
+ }
+
+ nCol--;
+ }
+
+ sal_Int32 nRow = getRowCountImpl() - 1;
+ while( nRow > 0 )
+ {
+ bool bEmpty = true;
+ for( nCol = 0; (nCol < getColumnCountImpl()) && bEmpty; nCol++ )
+ {
+ Reference< XMergeableCell > xCell( getCellByPosition( nCol, nRow ), UNO_QUERY );
+ if( xCell.is() && !xCell->isMerged() )
+ bEmpty = false;
+ }
+
+ if( bEmpty )
+ {
+ if( nRow > 0 ) try
+ {
+ const OUString sHeight( RTL_CONSTASCII_USTRINGPARAM("Height") );
+ sal_Int32 nHeight1 = 0, nHeight2 = 0;
+ Reference< XPropertySet > xSet1( static_cast< XCellRange* >( maRows[nRow].get() ), UNO_QUERY_THROW );
+ Reference< XPropertySet > xSet2( static_cast< XCellRange* >( maRows[nRow-1].get() ), UNO_QUERY_THROW );
+ xSet1->getPropertyValue( sHeight ) >>= nHeight1;
+ xSet2->getPropertyValue( sHeight ) >>= nHeight2;
+ nHeight1 += nHeight2;
+ xSet2->setPropertyValue( sHeight, Any( nHeight1 ) );
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("svx::TableModel::optimize(), exception caught!");
+ }
+
+ removeRows( nRow, 1 );
+ bWasModified = true;
+ }
+
+ nRow--;
+ }
+ }
+ if( bWasModified )
+ setModified(sal_True);
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::merge( sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan )
+{
+ SdrModel* pModel = mpTableObj->GetModel();
+
+ const bool bUndo = pModel && mpTableObj->IsInserted() && pModel->IsUndoEnabled();
+
+ const sal_Int32 nLastRow = nRow + nRowSpan;
+ const sal_Int32 nLastCol = nCol + nColSpan;
+
+ if( (nLastRow > getRowCount()) || (nLastCol > getRowCount() ) )
+ {
+ DBG_ERROR("TableModel::merge(), merge beyound the table!");
+ }
+
+ // merge first cell
+ CellRef xOriginCell( dynamic_cast< Cell* >( getCellByPosition( nCol, nRow ).get() ) );
+ if( xOriginCell.is() )
+ {
+ if( bUndo )
+ xOriginCell->AddUndo();
+ xOriginCell->merge( nColSpan, nRowSpan );
+ }
+
+ sal_Int32 nTempCol = nCol + 1;
+
+ // merge remaining cells
+ for( ; nRow < nLastRow; nRow++ )
+ {
+ for( ; nTempCol < nLastCol; nTempCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( getCellByPosition( nTempCol, nRow ).get() ) );
+ if( xCell.is() && !xCell->isMerged() )
+ {
+ if( bUndo )
+ xCell->AddUndo();
+ xCell->setMerged();
+ xOriginCell->mergeContent( xCell );
+ }
+ }
+ nTempCol = nCol;
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+
+void TableModel::updateRows()
+{
+ sal_Int32 nRow = 0;
+ RowVector::iterator iter = maRows.begin();
+ while( iter != maRows.end() )
+ {
+ (*iter++)->mnRow = nRow++;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableModel::updateColumns()
+{
+ sal_Int32 nColumn = 0;
+ ColumnVector::iterator iter = maColumns.begin();
+ while( iter != maColumns.end() )
+ {
+ (*iter++)->mnColumn = nColumn++;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablemodel.hxx b/svx/source/table/tablemodel.hxx
new file mode 100644
index 000000000000..518bf1caba48
--- /dev/null
+++ b/svx/source/table/tablemodel.hxx
@@ -0,0 +1,228 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TABLE_TABLEMODEL_HXX_
+#define _SVX_TABLE_TABLEMODEL_HXX_
+
+#include <com/sun/star/util/XBroadcaster.hpp>
+#include <com/sun/star/table/XTable.hpp>
+#include <basegfx/range/b2irectangle.hxx>
+#include <basegfx/tuple/b2ituple.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/listenernotification.hxx>
+#include <tools/gen.hxx>
+#include "celltypes.hxx"
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+class SdrTableObj;
+
+// -----------------------------------------------------------------------------
+// ICellRange
+// -----------------------------------------------------------------------------
+
+/** base class for each object implementing an XCellRange */
+class ICellRange
+{
+public:
+ virtual sal_Int32 getLeft() = 0;
+ virtual sal_Int32 getTop() = 0;
+ virtual sal_Int32 getRight() = 0;
+ virtual sal_Int32 getBottom() = 0;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XTable > getTable() = 0;
+};
+
+// -----------------------------------------------------------------------------
+// TableModel
+// -----------------------------------------------------------------------------
+
+typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::table::XTable, ::com::sun::star::util::XBroadcaster > TableModelBase;
+
+class TableModel : public TableModelBase,
+ public ::comphelper::OBaseMutex,
+ public ICellRange
+{
+ friend class InsertRowUndo;
+ friend class RemoveRowUndo;
+ friend class InsertColUndo;
+ friend class RemoveColUndo;
+ friend class TableColumnUndo;
+ friend class TableRowUndo;
+ friend class TableColumn;
+ friend class TableRow;
+ friend class TableRows;
+ friend class TableColumns;
+ friend class TableModelNotifyGuard;
+
+public:
+ TableModel( SdrTableObj* pTableObj );
+ TableModel( SdrTableObj* pTableObj, const TableModelRef& xSourceTable );
+ virtual ~TableModel();
+
+ void init( sal_Int32 nColumns, sal_Int32 nRows );
+
+ SdrTableObj* getSdrTableObj() const { return mpTableObj; }
+
+ /** deletes rows and columns that are completly merged. Must be called between BegUndo/EndUndo! */
+ void optimize();
+
+ /// merges the cell at the given position with the given span
+ void merge( sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan );
+
+ // ICellRange
+ virtual sal_Int32 getLeft();
+ virtual sal_Int32 getTop();
+ virtual sal_Int32 getRight();
+ virtual sal_Int32 getBottom();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XTable > getTable();
+
+ // XTable
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellCursor > SAL_CALL createCursor( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellCursor > SAL_CALL createCursorByRange( const ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >& Range ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getRowCount() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XModifiable
+ virtual ::sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setModified( ::sal_Bool bModified ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException);
+
+ // XModifyBroadcaster
+ virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XColumnRowRange
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XTableColumns > SAL_CALL getColumns() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XTableRows > SAL_CALL getRows() throw (::com::sun::star::uno::RuntimeException);
+
+ // XCellRange
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > SAL_CALL getCellByPosition( ::sal_Int32 nColumn, ::sal_Int32 nRow ) throw ( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByPosition( ::sal_Int32 nLeft, ::sal_Int32 nTop, ::sal_Int32 nRight, ::sal_Int32 nBottom ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByName( const ::rtl::OUString& aRange ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XFastPropertySet
+ virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XBroadcaster
+ virtual void SAL_CALL lockBroadcasts() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL unlockBroadcasts() throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ void notifyModification();
+
+ void insertColumns( sal_Int32 nIndex, sal_Int32 nCount );
+ void removeColumns( sal_Int32 nIndex, sal_Int32 nCount );
+ void insertRows( sal_Int32 nIndex, sal_Int32 nCount );
+ void removeRows( sal_Int32 nIndex, sal_Int32 nCount );
+
+ sal_Int32 getRowCountImpl() const;
+ sal_Int32 getColumnCountImpl() const;
+
+ CellRef createCell();
+ CellRef getCell( ::sal_Int32 nCol, ::sal_Int32 nRow ) const;
+
+ void UndoInsertRows( sal_Int32 nIndex, sal_Int32 nCount );
+ void UndoRemoveRows( sal_Int32 nIndex, RowVector& aNewRows );
+
+ void UndoInsertColumns( sal_Int32 nIndex, sal_Int32 nCount );
+ void UndoRemoveColumns( sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells );
+
+private:
+ /** this function is called upon disposing the component
+ */
+ virtual void SAL_CALL disposing();
+
+ TableRowRef getRow( sal_Int32 nRow ) const throw (::com::sun::star::lang::IndexOutOfBoundsException);
+ TableColumnRef getColumn( sal_Int32 nColumn ) const throw (::com::sun::star::lang::IndexOutOfBoundsException);
+
+ void updateRows();
+ void updateColumns();
+
+ RowVector maRows;
+ ColumnVector maColumns;
+
+ TableColumnsRef mxTableColumns;
+ TableRowsRef mxTableRows;
+
+ SdrTableObj* mpTableObj;
+
+ sal_Bool mbModified;
+ bool mbNotifyPending;
+
+ sal_Int32 mnNotifyLock;
+};
+
+class TableModelNotifyGuard
+{
+public:
+ TableModelNotifyGuard( TableModel* pModel )
+ : mxBroadcaster( static_cast< ::com::sun::star::util::XBroadcaster* >( pModel ) )
+ {
+ if( mxBroadcaster.is() )
+ mxBroadcaster->lockBroadcasts();
+ }
+
+ TableModelNotifyGuard( ::com::sun::star::uno::XInterface* pInterface )
+ : mxBroadcaster( pInterface, ::com::sun::star::uno::UNO_QUERY )
+ {
+ if( mxBroadcaster.is() )
+ mxBroadcaster->lockBroadcasts();
+ }
+
+ ~TableModelNotifyGuard()
+ {
+ if( mxBroadcaster.is() )
+ mxBroadcaster->unlockBroadcasts();
+ }
+
+private:
+ com::sun::star::uno::Reference< ::com::sun::star::util::XBroadcaster > mxBroadcaster;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx
new file mode 100644
index 000000000000..1a945cbf26f5
--- /dev/null
+++ b/svx/source/table/tablerow.cxx
@@ -0,0 +1,384 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/lang/DisposedException.hpp>
+
+#include "cell.hxx"
+#include "tablerow.hxx"
+#include "tableundo.hxx"
+#include "svx/svdmodel.hxx"
+#include "svx/svdotable.hxx"
+
+// -----------------------------------------------------------------------------
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::beans;
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+const sal_Int32 Property_Height = 0;
+const sal_Int32 Property_OptimalHeight = 1;
+const sal_Int32 Property_IsVisible = 2;
+const sal_Int32 Property_IsStartOfNewPage = 3;
+
+// -----------------------------------------------------------------------------
+// TableRow
+// -----------------------------------------------------------------------------
+
+TableRow::TableRow( const TableModelRef& xTableModel, sal_Int32 nRow, sal_Int32 nColumns )
+: TableRowBase( getStaticPropertySetInfo() )
+, mxTableModel( xTableModel )
+, mnRow( nRow )
+, mnHeight( 0 )
+, mbOptimalHeight( sal_True )
+, mbIsVisible( sal_True )
+, mbIsStartOfNewPage( sal_False )
+{
+ if( nColumns < 20 )
+ maCells.reserve( 20 );
+
+ if( nColumns )
+ {
+ maCells.resize( nColumns );
+ while( nColumns-- )
+ maCells[ nColumns ] = mxTableModel->createCell();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+TableRow::~TableRow()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void TableRow::dispose()
+{
+ mxTableModel.clear();
+ if( !maCells.empty() )
+ {
+ CellVector::iterator aIter( maCells.begin() );
+ while( aIter != maCells.end() )
+ (*aIter++)->dispose();
+ CellVector().swap(maCells);
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableRow::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException)
+{
+ if( !mxTableModel.is() )
+ throw DisposedException();
+}
+
+// -----------------------------------------------------------------------------
+
+TableRow& TableRow::operator=( const TableRow& r )
+{
+ mnHeight = r.mnHeight;
+ mbOptimalHeight = r.mbOptimalHeight;
+ mbIsVisible = r.mbIsVisible;
+ mbIsStartOfNewPage = r.mbIsStartOfNewPage;
+ maName = r.maName;
+
+ return *this;
+}
+
+// -----------------------------------------------------------------------------
+
+void TableRow::insertColumns( sal_Int32 nIndex, sal_Int32 nCount, CellVector::iterator* pIter /* = 0 */ )
+{
+ throwIfDisposed();
+ if( nCount )
+ {
+ if( nIndex >= static_cast< sal_Int32 >( maCells.size() ) )
+ nIndex = static_cast< sal_Int32 >( maCells.size() );
+ if ( pIter )
+ maCells.insert( maCells.begin() + nIndex, *pIter, (*pIter) + nCount );
+ else
+ {
+ maCells.reserve( maCells.size() + nCount );
+ for ( sal_Int32 i = 0; i < nCount; i++ )
+ maCells.insert( maCells.begin() + nIndex + i, mxTableModel->createCell() );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void TableRow::removeColumns( sal_Int32 nIndex, sal_Int32 nCount )
+{
+ throwIfDisposed();
+ if( (nCount >= 0) && ( nIndex >= 0) )
+ {
+ if( (nIndex + nCount) < static_cast< sal_Int32 >( maCells.size() ) )
+ {
+ CellVector::iterator aBegin( maCells.begin() );
+ while( nIndex-- && (aBegin != maCells.end()) )
+ aBegin++;
+
+ if( nCount > 1 )
+ {
+ CellVector::iterator aEnd( aBegin );
+ while( nCount-- && (aEnd != maCells.end()) )
+ aEnd++;
+ maCells.erase( aBegin, aEnd );
+ }
+ else
+ {
+ maCells.erase( aBegin );
+ }
+ }
+ else
+ {
+ maCells.resize( nIndex );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+// XCellRange
+// -----------------------------------------------------------------------------
+
+Reference< XCell > SAL_CALL TableRow::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ throwIfDisposed();
+ if( nRow != 0 )
+ throw IndexOutOfBoundsException();
+
+ return mxTableModel->getCellByPosition( nColumn, mnRow );
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellRange > SAL_CALL TableRow::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ throwIfDisposed();
+ if( (nLeft >= 0 ) && (nTop == 0) && (nRight >= nLeft) && (nBottom == 0) )
+ {
+ return mxTableModel->getCellRangeByPosition( nLeft, mnRow, nRight, mnRow );
+ }
+ throw IndexOutOfBoundsException();
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XCellRange > SAL_CALL TableRow::getCellRangeByName( const OUString& /*aRange*/ ) throw (RuntimeException)
+{
+ throwIfDisposed();
+ return Reference< XCellRange >();
+}
+
+// -----------------------------------------------------------------------------
+// XNamed
+// -----------------------------------------------------------------------------
+
+OUString SAL_CALL TableRow::getName() throw (RuntimeException)
+{
+ return maName;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableRow::setName( const OUString& aName ) throw (RuntimeException)
+{
+ maName = aName;
+}
+
+// -----------------------------------------------------------------------------
+// XFastPropertySet
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aValue ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, RuntimeException)
+{
+ bool bOk = false;
+ bool bChange = false;
+
+ TableRowUndo* pUndo = 0;
+
+ SdrModel* pModel = mxTableModel->getSdrTableObj()->GetModel();
+
+ const bool bUndo = mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && pModel && pModel->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ TableRowRef xThis( this );
+ pUndo = new TableRowUndo( xThis );
+ }
+
+ switch( nHandle )
+ {
+ case Property_Height:
+ {
+ sal_Int32 nHeight = mnHeight;
+ bOk = aValue >>= nHeight;
+ if( bOk && (mnHeight != nHeight) )
+ {
+ mnHeight = nHeight;
+ mbOptimalHeight = mnHeight == 0;
+ bChange = true;
+ }
+ break;
+ }
+
+ case Property_OptimalHeight:
+ {
+ sal_Bool bOptimalHeight = mbOptimalHeight;
+ bOk = aValue >>= bOptimalHeight;
+ if( bOk && (mbOptimalHeight != bOptimalHeight) )
+ {
+ mbOptimalHeight = bOptimalHeight;
+ if( bOptimalHeight )
+ mnHeight = 0;
+ bChange = true;
+ }
+ break;
+ }
+ case Property_IsVisible:
+ {
+ sal_Bool bIsVisible = mbIsVisible;
+ bOk = aValue >>= bIsVisible;
+ if( bOk && (mbIsVisible != bIsVisible) )
+ {
+ mbIsVisible = bIsVisible;
+ bChange = true;
+ }
+ break;
+ }
+
+ case Property_IsStartOfNewPage:
+ {
+ sal_Bool bIsStartOfNewPage = mbIsStartOfNewPage;
+ bOk = aValue >>= bIsStartOfNewPage;
+ if( bOk && (mbIsStartOfNewPage != bIsStartOfNewPage) )
+ {
+ mbIsStartOfNewPage = bIsStartOfNewPage;
+ bChange = true;
+ }
+ break;
+ }
+ default:
+ throw UnknownPropertyException();
+ }
+ if( !bOk )
+ throw IllegalArgumentException();
+
+ if( bChange )
+ {
+ if( pUndo )
+ {
+ pModel->AddUndo( pUndo );
+ pUndo = 0;
+ }
+ mxTableModel->setModified(sal_True);
+ }
+
+ if( pUndo )
+ delete pUndo;
+}
+
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL TableRow::getFastPropertyValue( sal_Int32 nHandle ) throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ switch( nHandle )
+ {
+ case Property_Height: return Any( mnHeight );
+ case Property_OptimalHeight: return Any( mbOptimalHeight );
+ case Property_IsVisible: return Any( mbIsVisible );
+ case Property_IsStartOfNewPage: return Any( mbIsStartOfNewPage );
+ default: throw UnknownPropertyException();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+rtl::Reference< ::comphelper::FastPropertySetInfo > TableRow::getStaticPropertySetInfo()
+{
+ static rtl::Reference< ::comphelper::FastPropertySetInfo > xInfo;
+ if( !xInfo.is() )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !xInfo.is() )
+ {
+ comphelper::PropertyVector aProperties(6);
+
+ aProperties[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Height" ) );
+ aProperties[0].Handle = Property_Height;
+ aProperties[0].Type = ::getCppuType((const sal_Int32*)0);
+ aProperties[0].Attributes = 0;
+
+ aProperties[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "OptimalHeight" ) );
+ aProperties[1].Handle = Property_OptimalHeight;
+ aProperties[1].Type = ::getBooleanCppuType();
+ aProperties[1].Attributes = 0;
+
+ aProperties[2].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) );
+ aProperties[2].Handle = Property_IsVisible;
+ aProperties[2].Type = ::getBooleanCppuType();
+ aProperties[2].Attributes = 0;
+
+ aProperties[3].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" ) );
+ aProperties[3].Handle = Property_IsStartOfNewPage;
+ aProperties[3].Type = ::getBooleanCppuType();
+ aProperties[3].Attributes = 0;
+
+ aProperties[4].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Size" ) );
+ aProperties[4].Handle = Property_Height;
+ aProperties[4].Type = ::getCppuType((const sal_Int32*)0);
+ aProperties[4].Attributes = 0;
+
+ aProperties[5].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "OptimalSize" ) );
+ aProperties[5].Handle = Property_OptimalHeight;
+ aProperties[5].Type = ::getBooleanCppuType();
+ aProperties[5].Attributes = 0;
+
+ xInfo.set( new ::comphelper::FastPropertySetInfo(aProperties) );
+ }
+ }
+
+ return xInfo;
+}
+
+// -----------------------------------------------------------------------------
+
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablerow.hxx b/svx/source/table/tablerow.hxx
new file mode 100644
index 000000000000..9d7e5061010c
--- /dev/null
+++ b/svx/source/table/tablerow.hxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TABLEROW_HXX_
+#define _SVX_TABLEROW_HXX_
+
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+#include "propertyset.hxx"
+#include "tablemodel.hxx"
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+// TableRow
+// -----------------------------------------------------------------------------
+
+typedef ::cppu::ImplInheritanceHelper2< ::comphelper::FastPropertySet, ::com::sun::star::table::XCellRange, ::com::sun::star::container::XNamed > TableRowBase;
+
+class TableRow : public TableRowBase
+{
+ friend class TableModel;
+ friend class TableRowUndo;
+public:
+ TableRow( const TableModelRef& xTableModel, sal_Int32 nRow, sal_Int32 nColumns );
+ virtual ~TableRow();
+
+ void dispose();
+ void throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException);
+
+ TableRow& operator=( const TableRow& );
+
+ void insertColumns( sal_Int32 nIndex, sal_Int32 nCount, CellVector::iterator* pIter = 0 );
+ void removeColumns( sal_Int32 nIndex, sal_Int32 nCount );
+
+ // XCellRange
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > SAL_CALL getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange > SAL_CALL getCellRangeByName( const ::rtl::OUString& aRange ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XNamed
+ virtual ::rtl::OUString SAL_CALL getName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XFastPropertySet
+ virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+private:
+ static rtl::Reference< ::comphelper::FastPropertySetInfo > getStaticPropertySetInfo();
+
+ TableModelRef mxTableModel;
+ CellVector maCells;
+ sal_Int32 mnRow;
+ sal_Int32 mnHeight;
+ sal_Bool mbOptimalHeight;
+ sal_Bool mbIsVisible;
+ sal_Bool mbIsStartOfNewPage;
+ ::rtl::OUString maName;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablerows.cxx b/svx/source/table/tablerows.cxx
new file mode 100644
index 000000000000..ed04a5d81cad
--- /dev/null
+++ b/svx/source/table/tablerows.cxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/lang/DisposedException.hpp>
+
+#include "cell.hxx"
+#include "tablerow.hxx"
+#include "tablerows.hxx"
+
+// -----------------------------------------------------------------------------
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::table;
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+// TableRows
+// -----------------------------------------------------------------------------
+
+TableRows::TableRows( const TableModelRef& xTableModel )
+: mxTableModel( xTableModel )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+TableRows::~TableRows()
+{
+ dispose();
+}
+
+// -----------------------------------------------------------------------------
+
+void TableRows::dispose()
+{
+ mxTableModel.clear();
+}
+
+// -----------------------------------------------------------------------------
+
+void TableRows::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException)
+{
+ if( !mxTableModel.is() )
+ throw DisposedException();
+}
+
+// -----------------------------------------------------------------------------
+// XTableRows
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableRows::insertByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (RuntimeException)
+{
+ throwIfDisposed();
+ mxTableModel->insertRows( nIndex, nCount );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL TableRows::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (RuntimeException)
+{
+ throwIfDisposed();
+ mxTableModel->removeRows( nIndex, nCount );
+}
+
+// -----------------------------------------------------------------------------
+// XIndexAccess
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL TableRows::getCount() throw (RuntimeException)
+{
+ throwIfDisposed();
+ return mxTableModel->getRowCount();
+}
+
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL TableRows::getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ throwIfDisposed();
+ return Any( Reference< XCellRange >( static_cast< XCellRange* >( mxTableModel->getRow( Index ).get() ) ) );
+}
+
+// -----------------------------------------------------------------------------
+// XElementAccess
+// -----------------------------------------------------------------------------
+
+Type SAL_CALL TableRows::getElementType() throw (RuntimeException)
+{
+ throwIfDisposed();
+ return XCellRange::static_type();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL TableRows::hasElements() throw (RuntimeException)
+{
+ throwIfDisposed();
+ return mxTableModel->getRowCount() != 0;
+}
+
+// -----------------------------------------------------------------------------
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablerows.hxx b/svx/source/table/tablerows.hxx
new file mode 100644
index 000000000000..e8e82281a245
--- /dev/null
+++ b/svx/source/table/tablerows.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TABLEROWS_HXX_
+#define _SVX_TABLEROWS_HXX_
+
+#include <com/sun/star/table/XTableRows.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+#include "tablemodel.hxx"
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+// -----------------------------------------------------------------------------
+// TableRows
+// -----------------------------------------------------------------------------
+
+class TableRows : public ::cppu::WeakAggImplHelper1< ::com::sun::star::table::XTableRows >
+{
+public:
+ TableRows( const TableModelRef& xTableModel );
+ virtual ~TableRows();
+
+ void dispose();
+ void throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException);
+
+ // XTableRows
+ virtual void SAL_CALL insertByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // Methods
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasElements() throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ TableModelRef mxTableModel;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablertfexporter.cxx b/svx/source/table/tablertfexporter.cxx
new file mode 100644
index 000000000000..e01946bcd576
--- /dev/null
+++ b/svx/source/table/tablertfexporter.cxx
@@ -0,0 +1,285 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <vector>
+
+#include <com/sun/star/table/XTable.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <tools/stream.hxx>
+#include <svtools/rtfkeywd.hxx>
+#include <svtools/rtfout.hxx>
+
+#include <editeng/eeitem.hxx>
+#include <svx/sdtaitm.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/udlnitem.hxx>
+
+#include "cell.hxx"
+#include "celltypes.hxx"
+#include "svx/svdotable.hxx"
+#include "svx/svdoutl.hxx"
+#include "editeng/editeng.hxx"
+#include "editeng/outlobj.hxx"
+
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+
+namespace sdr { namespace table {
+
+class SdrTableRtfExporter
+{
+public:
+ SdrTableRtfExporter( SvStream& rStrmP, SdrTableObj& rObj );
+ ULONG Write();
+ void WriteRow( const Reference< XPropertySet >& xRowSet, sal_Int32 nRow, const std::vector< sal_Int32 >& aColumnStart );
+ void WriteCell( sal_Int32 nCol, sal_Int32 nRow );
+
+private:
+ SvStream& mrStrm;
+ SdrTableObj& mrObj;
+ Reference< XTable > mxTable;
+ const OUString msSize;
+};
+
+void SdrTableObj::ExportAsRTF( SvStream& rStrm, SdrTableObj& rObj )
+{
+ SdrTableRtfExporter aEx( rStrm, rObj );
+ aEx.Write();
+}
+
+SdrTableRtfExporter::SdrTableRtfExporter( SvStream& rStrm, SdrTableObj& rObj )
+: mrStrm( rStrm )
+, mrObj( rObj )
+, mxTable( rObj.getTable() )
+, msSize( RTL_CONSTASCII_USTRINGPARAM("Size") )
+{
+}
+
+long HundMMToTwips( long nIn )
+{
+ long nRet = OutputDevice::LogicToLogic( nIn, MAP_100TH_MM, MAP_TWIP );
+ return nRet;
+}
+
+ULONG SdrTableRtfExporter::Write()
+{
+ mrStrm << '{' << OOO_STRING_SVTOOLS_RTF_RTF;
+ mrStrm << OOO_STRING_SVTOOLS_RTF_ANSI << RTFOutFuncs::sNewLine;
+
+ Reference< XTableColumns > xColumns( mxTable->getColumns() );
+ const sal_Int32 nColCount = xColumns->getCount();
+
+ std::vector< sal_Int32 > aColumnStart;
+ aColumnStart.reserve( nColCount );
+
+ // determine right offset of cells
+ sal_Int32 nPos = 0;
+ for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ ) try
+ {
+ Reference< XPropertySet > xSet( xColumns->getByIndex(nCol), UNO_QUERY_THROW );
+ sal_Int32 nWidth = 0;
+ xSet->getPropertyValue( msSize ) >>= nWidth;
+ nPos += HundMMToTwips( nWidth );
+ aColumnStart.push_back( nPos );
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("SdrTableRtfExporter::Write(), exception caught!");
+ }
+
+ // export rows
+ Reference< XTableRows > xRows( mxTable->getRows() );
+ const sal_Int32 nRowCount = xRows->getCount();
+
+ for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ ) try
+ {
+ Reference< XPropertySet > xRowSet( xRows->getByIndex(nRow), UNO_QUERY_THROW );
+ WriteRow( xRowSet, nRow, aColumnStart );
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("SdrTableRtfExporter::Write(), exception caught!");
+ }
+
+ mrStrm << '}' << RTFOutFuncs::sNewLine;
+ return mrStrm.GetError();
+}
+
+void SdrTableRtfExporter::WriteRow( const Reference< XPropertySet >& xRowSet, sal_Int32 nRow, const std::vector< sal_Int32 >& aColumnStart )
+{
+ sal_Int32 nRowHeight = 0;
+ xRowSet->getPropertyValue( msSize ) >>= nRowHeight;
+
+ mrStrm << OOO_STRING_SVTOOLS_RTF_TROWD << OOO_STRING_SVTOOLS_RTF_TRGAPH << "30" << OOO_STRING_SVTOOLS_RTF_TRLEFT << "-30";
+ mrStrm << OOO_STRING_SVTOOLS_RTF_TRRH << ByteString::CreateFromInt32( nRowHeight ).GetBuffer();
+
+ const sal_Int32 nColCount = mxTable->getColumnCount();
+ for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
+ {
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+
+ if( !xCell.is() )
+ continue;
+
+/*
+ const sal_Bool bIsMerged = xCell->isMerged();
+ const sal_Int32 nRowSpan = xCell->getRowSpan();
+ const sal_Int32 nColSpan = xCell->getColumnSpan();
+
+ const sal_Char* pChar;
+
+ if( !bIsMerged && ((nRowSpan > 1) || (nColSpan > 1)) )
+ mrStrm << OOO_STRING_SVTOOLS_RTF_CLMGF; // The first cell in a range of table cells to be merged.
+
+ SdrTextVertAdjust eVAdj = xCell->GetTextVerticalAdjust();
+ switch( eVAdj )
+ {
+ case SVX_VER_JUSTIFY_TOP: pChar = OOO_STRING_SVTOOLS_RTF_CLVERTALT; break;
+ case SVX_VER_JUSTIFY_CENTER: pChar = OOO_STRING_SVTOOLS_RTF_CLVERTALC; break;
+ case SVX_VER_JUSTIFY_BOTTOM: pChar = OOO_STRING_SVTOOLS_RTF_CLVERTALB; break;
+ case SVX_VER_JUSTIFY_STANDARD: pChar = OOO_STRING_SVTOOLS_RTF_CLVERTALB; break; //! Bottom
+ default: pChar = NULL; break;
+ }
+ if ( pChar )
+ mrStrm << pChar;
+*/
+ mrStrm << OOO_STRING_SVTOOLS_RTF_CELLX << ByteString::CreateFromInt32( aColumnStart[nCol] ).GetBuffer();
+ if ( (nCol & 0x0F) == 0x0F )
+ mrStrm << RTFOutFuncs::sNewLine; // Zeilen nicht zu lang werden lassen
+ }
+ mrStrm << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_PLAIN << OOO_STRING_SVTOOLS_RTF_INTBL << RTFOutFuncs::sNewLine;
+
+ ULONG nStrmPos = mrStrm.Tell();
+ for( sal_Int32 nCol = 0; nCol < nColCount; nCol++ )
+ {
+ WriteCell( nCol, nRow );
+ if ( mrStrm.Tell() - nStrmPos > 255 )
+ {
+ mrStrm << RTFOutFuncs::sNewLine;
+ nStrmPos = mrStrm.Tell();
+ }
+ }
+ mrStrm << OOO_STRING_SVTOOLS_RTF_ROW << RTFOutFuncs::sNewLine;
+}
+
+
+void SdrTableRtfExporter::WriteCell( sal_Int32 nCol, sal_Int32 nRow )
+{
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+
+ if( !xCell.is() || xCell->isMerged() )
+ {
+ mrStrm << OOO_STRING_SVTOOLS_RTF_CELL;
+ return ;
+ }
+
+ String aContent;
+
+ OutlinerParaObject* pParaObj = xCell->GetEditOutlinerParaObject();
+ bool bOwnParaObj = pParaObj != 0;
+
+ if( pParaObj == 0 )
+ pParaObj = xCell->GetOutlinerParaObject();
+
+ if(pParaObj)
+ {
+ // handle outliner attributes
+ SdrOutliner& rOutliner = mrObj.ImpGetDrawOutliner();
+ rOutliner.SetText(*pParaObj);
+
+ aContent = rOutliner.GetEditEngine().GetText( LINEEND_LF );
+
+ rOutliner.Clear();
+
+ if( bOwnParaObj )
+ delete pParaObj;
+ }
+
+ bool bResetPar, bResetAttr;
+ bResetPar = bResetAttr = FALSE;
+
+ SdrTextHorzAdjust eHAdj = xCell->GetTextHorizontalAdjust();
+
+ const SfxItemSet& rCellSet = xCell->GetItemSet();
+
+ const SvxWeightItem& rWeightItem = (const SvxWeightItem&) rCellSet.Get( EE_CHAR_WEIGHT );
+ const SvxPostureItem& rPostureItem = (const SvxPostureItem&) rCellSet.Get( EE_CHAR_ITALIC );
+ const SvxUnderlineItem& rUnderlineItem = (const SvxUnderlineItem&) rCellSet.Get( EE_CHAR_UNDERLINE );
+
+ const sal_Char* pChar;
+
+ switch( eHAdj )
+ {
+ case SDRTEXTHORZADJUST_CENTER: pChar = OOO_STRING_SVTOOLS_RTF_QC; break;
+ case SDRTEXTHORZADJUST_BLOCK: pChar = OOO_STRING_SVTOOLS_RTF_QJ; break;
+ case SDRTEXTHORZADJUST_RIGHT: pChar = OOO_STRING_SVTOOLS_RTF_QR; break;
+ case SDRTEXTHORZADJUST_LEFT:
+ default: pChar = OOO_STRING_SVTOOLS_RTF_QL; break;
+ }
+ mrStrm << pChar;
+
+ if ( rWeightItem.GetWeight() >= WEIGHT_BOLD )
+ { // bold
+ bResetAttr = true;
+ mrStrm << OOO_STRING_SVTOOLS_RTF_B;
+ }
+ if ( rPostureItem.GetPosture() != ITALIC_NONE )
+ { // italic
+ bResetAttr = true;
+ mrStrm << OOO_STRING_SVTOOLS_RTF_I;
+ }
+ if ( rUnderlineItem.GetLineStyle() != UNDERLINE_NONE )
+ { // underline
+ bResetAttr = true;
+ mrStrm << OOO_STRING_SVTOOLS_RTF_UL;
+ }
+
+ mrStrm << ' ';
+ RTFOutFuncs::Out_String( mrStrm, aContent );
+ mrStrm << OOO_STRING_SVTOOLS_RTF_CELL;
+
+ if ( bResetPar )
+ mrStrm << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL;
+ if ( bResetAttr )
+ mrStrm << OOO_STRING_SVTOOLS_RTF_PLAIN;
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablertfimporter.cxx b/svx/source/table/tablertfimporter.cxx
new file mode 100644
index 000000000000..5c217129c905
--- /dev/null
+++ b/svx/source/table/tablertfimporter.cxx
@@ -0,0 +1,449 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+
+#include <com/sun/star/table/XTable.hpp>
+
+#include <tools/stream.hxx>
+#include <svtools/rtftoken.h>
+
+#include <editeng/eeitem.hxx>
+#include <svx/svdetc.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/outlobj.hxx>
+
+#include "cell.hxx"
+#include "celltypes.hxx"
+#include "svx/svdotable.hxx"
+#include "svx/svdoutl.hxx"
+#include "editeng/editeng.hxx"
+#include "editeng/editdata.hxx"
+#include "svx/svdmodel.hxx"
+#include "editeng/svxrtf.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+
+namespace sdr { namespace table {
+
+struct RTFCellDefault
+{
+ SfxItemSet maItemSet;
+ sal_Int32 mnCol;
+ USHORT mnTwips; // right border of the cell
+ sal_Int32 mnColSpan; // MergeCell if >1, merged cells if 0
+
+ RTFCellDefault( SfxItemPool* pPool ) : maItemSet( *pPool ), mnCol(0), mnTwips(0 ), mnColSpan(1) {}
+};
+
+typedef std::vector< boost::shared_ptr< RTFCellDefault > > RTFCellDefaultVector;
+
+struct RTFCellInfo
+{
+ SfxItemSet maItemSet;
+ sal_Int32 mnStartPara;
+ sal_Int32 mnParaCount;
+ sal_Int32 mnColSpan;
+
+ RTFCellInfo( SfxItemPool& rPool ) : maItemSet( rPool ), mnStartPara(0), mnParaCount(0), mnColSpan(0) {}
+};
+
+typedef boost::shared_ptr< RTFCellInfo > RTFCellInfoPtr;
+typedef std::vector< RTFCellInfoPtr > RTFColumnVector;
+
+typedef boost::shared_ptr< RTFColumnVector > RTFColumnVectorPtr;
+
+typedef std::vector< RTFColumnVectorPtr > RTFRowVector;
+
+class SdrTableRTFParser
+{
+public:
+ SdrTableRTFParser( SdrTableObj& rTableObj );
+ ~SdrTableRTFParser();
+
+ void Read( SvStream& rStream );
+
+ void ProcToken( ImportInfo* pInfo );
+
+ void NextRow();
+ void NextColumn();
+ void NewCellRow();
+
+ void InsertCell( ImportInfo* pInfo );
+
+ void FillTable();
+
+ DECL_LINK( RTFImportHdl, ImportInfo* );
+
+private:
+ SdrTableObj& mrTableObj;
+ SdrOutliner* mpOutliner;
+ SfxItemPool& mrItemPool;
+
+ RTFCellDefaultVector maDefaultList;
+ RTFCellDefaultVector::iterator maDefaultIterator;
+
+ int mnLastToken;
+ sal_Int32 mnLastWidth;
+ bool mbNewDef;
+
+ USHORT mnStartPara;
+
+ sal_Int32 mnColCnt;
+ sal_Int32 mnRowCnt;
+ sal_Int32 mnColMax;
+
+ std::vector< sal_Int32 > maColumnEdges;
+
+ RTFRowVector maRows;
+
+ RTFCellDefault* mpInsDefault;
+ RTFCellDefault* mpActDefault;
+ RTFCellDefault* mpDefMerge;
+
+ Reference< XTable > mxTable;
+};
+
+SdrTableRTFParser::SdrTableRTFParser( SdrTableObj& rTableObj )
+: mrTableObj( rTableObj )
+, mpOutliner( SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, rTableObj.GetModel() ) )
+, mrItemPool( rTableObj.GetModel()->GetItemPool() )
+, mnLastToken( 0 )
+, mnLastWidth( 0 )
+, mbNewDef( false )
+, mnStartPara( 0 )
+, mnColCnt( 0 )
+, mnRowCnt( 0 )
+, mnColMax( 0 )
+, mpActDefault( 0 )
+, mpDefMerge( 0 )
+, mxTable( rTableObj.getTable() )
+{
+ mpOutliner->SetUpdateMode(TRUE);
+ mpOutliner->SetStyleSheet( 0, mrTableObj.GetStyleSheet() );
+ mpInsDefault = new RTFCellDefault( &mrItemPool );
+}
+
+SdrTableRTFParser::~SdrTableRTFParser()
+{
+ delete mpOutliner;
+ delete mpInsDefault;
+}
+
+void SdrTableRTFParser::Read( SvStream& rStream )
+{
+ EditEngine& rEdit = const_cast< EditEngine& >( mpOutliner->GetEditEngine() );
+
+ Link aOldLink( rEdit.GetImportHdl() );
+ rEdit.SetImportHdl( LINK( this, SdrTableRTFParser, RTFImportHdl ) );
+ mpOutliner->Read( rStream, String(), EE_FORMAT_RTF );
+ rEdit.SetImportHdl( aOldLink );
+
+ FillTable();
+}
+
+IMPL_LINK( SdrTableRTFParser, RTFImportHdl, ImportInfo*, pInfo )
+{
+ switch ( pInfo->eState )
+ {
+ case RTFIMP_NEXTTOKEN:
+ ProcToken( pInfo );
+ break;
+ case RTFIMP_UNKNOWNATTR:
+ ProcToken( pInfo );
+ break;
+ case RTFIMP_START:
+ {
+ SvxRTFParser* pParser = (SvxRTFParser*) pInfo->pParser;
+ pParser->SetAttrPool( &mrItemPool );
+ RTFPardAttrMapIds& rMap = pParser->GetPardMap();
+ rMap.nBox = SDRATTR_TABLE_BORDER;
+ }
+ break;
+ case RTFIMP_END:
+ if ( pInfo->aSelection.nEndPos )
+ {
+ mpActDefault = NULL;
+ pInfo->nToken = RTF_PAR;
+ pInfo->aSelection.nEndPara++;
+ ProcToken( pInfo );
+ }
+ break;
+ case RTFIMP_SETATTR:
+ break;
+ case RTFIMP_INSERTTEXT:
+ break;
+ case RTFIMP_INSERTPARA:
+ break;
+ default:
+ DBG_ERRORFILE("unknown ImportInfo.eState");
+ }
+ return 0;
+}
+
+void SdrTableRTFParser::NextRow()
+{
+ ++mnRowCnt;
+}
+
+void SdrTableRTFParser::InsertCell( ImportInfo* pInfo )
+{
+ sal_Int32 nCol = mpActDefault->mnCol;
+
+ RTFCellInfoPtr xCellInfo( new RTFCellInfo(mrItemPool) );
+
+ xCellInfo->mnStartPara = mnStartPara;
+ xCellInfo->mnParaCount = pInfo->aSelection.nEndPara - 1 - mnStartPara;
+
+ if( !maRows.empty() )
+ {
+ RTFColumnVectorPtr xColumn( maRows.back() );
+
+ if( xColumn->size() <= (size_t)nCol )
+ xColumn->resize( nCol+1 );
+
+ (*xColumn)[nCol] = xCellInfo;
+ }
+
+ mnStartPara = pInfo->aSelection.nEndPara - 1;
+}
+
+void SdrTableRTFParser::FillTable()
+{
+ try
+ {
+ sal_Int32 nColCount = mxTable->getColumnCount();
+ Reference< XTableColumns > xCols( mxTable->getColumns(), UNO_QUERY_THROW );
+
+ if( nColCount < mnColMax )
+ {
+ xCols->insertByIndex( nColCount, mnColMax - nColCount );
+ nColCount = mxTable->getColumnCount();
+ }
+
+ const OUString sWidth( RTL_CONSTASCII_USTRINGPARAM("Width") );
+ sal_Int32 nCol, nLastEdge = 0;
+ for( nCol = 0; nCol < nColCount; nCol++ )
+ {
+ Reference< XPropertySet > xSet( xCols->getByIndex( nCol ), UNO_QUERY_THROW );
+ sal_Int32 nWidth = maColumnEdges[nCol] - nLastEdge;
+
+ xSet->setPropertyValue( sWidth, Any( nWidth ) );
+ nLastEdge += nWidth;
+ }
+
+ const sal_Int32 nRowCount = mxTable->getRowCount();
+ if( nRowCount < mnRowCnt )
+ {
+ Reference< XTableRows > xRows( mxTable->getRows(), UNO_QUERY_THROW );
+ xRows->insertByIndex( nRowCount, mnRowCnt - nRowCount );
+ }
+
+ for( sal_Int32 nRow = 0; nRow < (sal_Int32)maRows.size(); nRow++ )
+ {
+ RTFColumnVectorPtr xColumn( maRows[nRow] );
+ for( nCol = 0; nCol < (sal_Int32)xColumn->size(); nCol++ )
+ {
+ RTFCellInfoPtr xCellInfo( (*xColumn)[nCol] );
+
+ CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) );
+ if( xCell.is() && xCellInfo.get() )
+ {
+ const SfxPoolItem *pPoolItem = 0;
+ if( xCellInfo->maItemSet.GetItemState(SDRATTR_TABLE_BORDER,FALSE,&pPoolItem)==SFX_ITEM_SET)
+ xCell->SetMergedItem( *pPoolItem );
+
+ String sDebug = mpOutliner->GetText( mpOutliner->GetParagraph( xCellInfo->mnStartPara ), xCellInfo->mnParaCount );
+
+ OutlinerParaObject* pTextObject = mpOutliner->CreateParaObject( (USHORT)xCellInfo->mnStartPara, (USHORT)xCellInfo->mnParaCount );
+ if( pTextObject )
+ {
+ SdrOutliner& rOutliner=mrTableObj.ImpGetDrawOutliner();
+ rOutliner.SetUpdateMode(TRUE);
+ rOutliner.SetText( *pTextObject );
+ mrTableObj.NbcSetOutlinerParaObjectForText( rOutliner.CreateParaObject(), xCell.get() );
+ delete pTextObject;
+ }
+ }
+ }
+ }
+
+ Rectangle aRect( mrTableObj.GetSnapRect() );
+ aRect.nRight = aRect.nLeft + nLastEdge;
+ mrTableObj.NbcSetSnapRect( aRect );
+
+ }
+ catch( Exception& e )
+ {
+ (void)e;
+ DBG_ERROR("sdr::table::SdrTableRTFParser::InsertCell(), exception caught!" );
+ }
+}
+
+void SdrTableRTFParser::NewCellRow()
+{
+ if( mbNewDef )
+ {
+ mbNewDef = FALSE;
+
+ maRows.push_back( RTFColumnVectorPtr( new RTFColumnVector() ) );
+ }
+ mpDefMerge = NULL;
+ maDefaultIterator = maDefaultList.begin();
+
+ NextColumn();
+
+ DBG_ASSERT( mpActDefault, "NewCellRow: pActDefault==0" );
+}
+
+void SdrTableRTFParser::NextColumn()
+{
+ if( maDefaultIterator != maDefaultList.end() )
+ mpActDefault = (*maDefaultIterator++).get();
+ else
+ mpActDefault = 0;
+}
+
+long TwipsToHundMM( long nIn )
+{
+ long nRet = OutputDevice::LogicToLogic( nIn, MAP_TWIP, MAP_100TH_MM );
+ return nRet;
+}
+
+void SdrTableRTFParser::ProcToken( ImportInfo* pInfo )
+{
+ switch ( pInfo->nToken )
+ {
+ case RTF_TROWD: // denotes table row defauls, before RTF_CELLX
+ {
+ mnColCnt = 0;
+ maDefaultList.clear();
+ mpDefMerge = NULL;
+ mnLastToken = pInfo->nToken;
+ }
+ break;
+ case RTF_CLMGF: // The first cell of cells to be merged
+ {
+ mpDefMerge = mpInsDefault;
+ mnLastToken = pInfo->nToken;
+ }
+ break;
+ case RTF_CLMRG: // A cell to be merged with the preceding cell
+ {
+ if ( !mpDefMerge )
+ mpDefMerge = maDefaultList.back().get();
+ DBG_ASSERT( mpDefMerge, "RTF_CLMRG: pDefMerge==0" );
+ if( mpDefMerge )
+ mpDefMerge->mnColSpan++;
+ mpInsDefault->mnColSpan = 0;
+ mnLastToken = pInfo->nToken;
+ }
+ break;
+ case RTF_CELLX: // closes cell default
+ {
+ mbNewDef = TRUE;
+ mpInsDefault->mnCol = mnColCnt;
+ maDefaultList.push_back( boost::shared_ptr< RTFCellDefault >( mpInsDefault ) );
+
+ if( (sal_Int32)maColumnEdges.size() <= mnColCnt )
+ maColumnEdges.resize( mnColCnt + 1 );
+
+ const sal_Int32 nSize = TwipsToHundMM( pInfo->nTokenValue );
+ maColumnEdges[mnColCnt] = std::max( maColumnEdges[mnColCnt], nSize );
+
+ mpInsDefault = new RTFCellDefault( &mrItemPool );
+ if ( ++mnColCnt > mnColMax )
+ mnColMax = mnColCnt;
+ mnLastToken = pInfo->nToken;
+ }
+ break;
+ case RTF_INTBL: // before the first RTF_CELL
+ {
+ if ( mnLastToken != RTF_INTBL && mnLastToken != RTF_CELL && mnLastToken != RTF_PAR )
+ {
+ NewCellRow();
+ mnLastToken = pInfo->nToken;
+ }
+ }
+ break;
+ case RTF_CELL: // denotes the end of a cell.
+ {
+ DBG_ASSERT( mpActDefault, "RTF_CELL: pActDefault==0" );
+ if ( mbNewDef || !mpActDefault )
+ NewCellRow();
+ if ( !mpActDefault )
+ mpActDefault = mpInsDefault;
+ if ( mpActDefault->mnColSpan > 0 )
+ {
+ InsertCell(pInfo);
+ }
+ NextColumn();
+ mnLastToken = pInfo->nToken;
+ }
+ break;
+ case RTF_ROW: // means the end of a row
+ {
+ NextRow();
+ mnLastToken = pInfo->nToken;
+ }
+ break;
+ case RTF_PAR: // Paragraph
+ mnLastToken = pInfo->nToken;
+ break;
+ default:
+ { // do not set nLastToken
+ switch ( pInfo->nToken & ~(0xff | RTF_TABLEDEF) )
+ {
+ case RTF_SHADINGDEF:
+// ((SvxRTFParser*)pInfo->pParser)->ReadBackgroundAttr(pInfo->nToken, mpInsDefault->maItemSet, TRUE );
+ break;
+ case RTF_BRDRDEF:
+ ((SvxRTFParser*)pInfo->pParser)->ReadBorderAttr(pInfo->nToken, mpInsDefault->maItemSet, TRUE );
+ break;
+ }
+ }
+ }
+}
+
+void SdrTableObj::ImportAsRTF( SvStream& rStream, SdrTableObj& rObj )
+{
+ SdrTableRTFParser aParser( rObj );
+ aParser.Read( rStream );
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx
new file mode 100644
index 000000000000..67b36aaf0b42
--- /dev/null
+++ b/svx/source/table/tableundo.cxx
@@ -0,0 +1,562 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "svx/sdr/properties/textproperties.hxx"
+#include "editeng/outlobj.hxx"
+
+#include "cell.hxx"
+#include "tableundo.hxx"
+#include "svx/svdotable.hxx"
+#include "tablerow.hxx"
+#include "tablecolumn.hxx"
+
+
+// -----------------------------------------------------------------------------
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::table;
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+CellUndo::CellUndo( const SdrObjectWeakRef& xObjRef, const CellRef& xCell )
+: SdrUndoAction( *xCell->GetModel() )
+, mxObjRef( xObjRef )
+, mxCell( xCell )
+, mbUndo( true )
+{
+ if( mxCell.is() && mxObjRef.is() )
+ {
+ getDataFromCell( maUndoData );
+ mxObjRef->AddObjectUser( *this );
+ }
+}
+
+CellUndo::~CellUndo()
+{
+ if( mxObjRef.is() )
+ mxObjRef->RemoveObjectUser( *this );
+ dispose();
+}
+
+void CellUndo::dispose()
+{
+ mxCell.clear();
+ delete maUndoData.mpProperties;
+ maUndoData.mpProperties = 0;
+ delete maRedoData.mpProperties;
+ maRedoData.mpProperties = 0;
+ delete maUndoData.mpOutlinerParaObject;
+ maUndoData.mpOutlinerParaObject = 0;
+ delete maRedoData.mpOutlinerParaObject;
+ maRedoData.mpOutlinerParaObject = 0;
+}
+
+void CellUndo::ObjectInDestruction(const SdrObject& )
+{
+ dispose();
+}
+
+void CellUndo::Undo()
+{
+ if( mxCell.is() && mbUndo )
+ {
+ if( maRedoData.mpProperties == 0 )
+ getDataFromCell( maRedoData );
+
+ setDataToCell( maUndoData );
+ mbUndo = false;
+ }
+}
+
+void CellUndo::Redo()
+{
+ if( mxCell.is() && !mbUndo )
+ {
+ setDataToCell( maRedoData );
+ mbUndo = true;
+ }
+}
+
+BOOL CellUndo::Merge( SfxUndoAction *pNextAction )
+{
+ CellUndo* pNext = dynamic_cast< CellUndo* >( pNextAction );
+ if( pNext && pNext->mxCell.get() == mxCell.get() )
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+void CellUndo::setDataToCell( const Data& rData )
+{
+ delete mxCell->mpProperties;
+ if( rData.mpProperties )
+ mxCell->mpProperties = Cell::CloneProperties( rData.mpProperties, *mxObjRef.get(), *mxCell.get() );
+ else
+ mxCell->mpProperties = 0;
+
+ if( rData.mpOutlinerParaObject )
+ mxCell->SetOutlinerParaObject( new OutlinerParaObject(*rData.mpOutlinerParaObject) );
+ else
+ mxCell->RemoveOutlinerParaObject();
+
+ mxCell->msFormula = rData.msFormula;
+ mxCell->mfValue = rData.mfValue;
+ mxCell->mnError = rData.mnError;
+ mxCell->mbMerged = rData.mbMerged;
+ mxCell->mnRowSpan = rData.mnRowSpan;
+ mxCell->mnColSpan = rData.mnColSpan;
+
+ if( mxObjRef.is() )
+ mxObjRef->ActionChanged();
+}
+
+void CellUndo::getDataFromCell( Data& rData )
+{
+ if( mxObjRef.is() && mxCell.is() )
+ {
+ if( mxCell->mpProperties )
+ rData.mpProperties = mxCell->CloneProperties( *mxObjRef.get(), *mxCell.get());
+
+ if( mxCell->GetOutlinerParaObject() )
+ rData.mpOutlinerParaObject = new OutlinerParaObject(*mxCell->GetOutlinerParaObject());
+ else
+ rData.mpOutlinerParaObject = 0;
+
+ rData.mnCellContentType = mxCell->mnCellContentType;
+
+ rData.msFormula = mxCell->msFormula;
+ rData.mfValue = mxCell->mfValue;
+ rData.mnError = mxCell->mnError;
+ rData.mbMerged = mxCell->mbMerged;
+ rData.mnRowSpan = mxCell->mnRowSpan;
+ rData.mnColSpan = mxCell->mnColSpan;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// class InsertRowUndo : public SdrUndoAction
+// -----------------------------------------------------------------------------
+
+static void Dispose( RowVector& rRows )
+{
+ RowVector::iterator aIter( rRows.begin() );
+ while( aIter != rRows.end() )
+ (*aIter++)->dispose();
+}
+
+// -----------------------------------------------------------------------------
+
+InsertRowUndo::InsertRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aNewRows )
+: SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
+, mxTable( xTable )
+, mnIndex( nIndex )
+, mbUndo( true )
+{
+ maRows.swap( aNewRows );
+}
+
+// -----------------------------------------------------------------------------
+
+InsertRowUndo::~InsertRowUndo()
+{
+ if( !mbUndo )
+ Dispose( maRows );
+}
+
+// -----------------------------------------------------------------------------
+
+void InsertRowUndo::Undo()
+{
+ if( mxTable.is() )
+ {
+ mxTable->UndoInsertRows( mnIndex, sal::static_int_cast< sal_Int32 >( maRows.size() ) );
+ mbUndo = false;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void InsertRowUndo::Redo()
+{
+ if( mxTable.is() )
+ {
+ mxTable->UndoRemoveRows( mnIndex, maRows );
+ mbUndo = true;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// class RemoveRowUndo : public SdrUndoAction
+// -----------------------------------------------------------------------------
+
+RemoveRowUndo::RemoveRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aRemovedRows )
+: SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
+, mxTable( xTable )
+, mnIndex( nIndex )
+, mbUndo( true )
+{
+ maRows.swap( aRemovedRows );
+}
+
+// -----------------------------------------------------------------------------
+
+RemoveRowUndo::~RemoveRowUndo()
+{
+ if( mbUndo )
+ Dispose( maRows );
+}
+
+// -----------------------------------------------------------------------------
+
+void RemoveRowUndo::Undo()
+{
+ if( mxTable.is() )
+ {
+ mxTable->UndoRemoveRows( mnIndex, maRows );
+ mbUndo = false;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void RemoveRowUndo::Redo()
+{
+ if( mxTable.is() )
+ {
+ mxTable->UndoInsertRows( mnIndex, sal::static_int_cast< sal_Int32 >( maRows.size() ) );
+ mbUndo = true;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// class InsertColUndo : public SdrUndoAction
+// -----------------------------------------------------------------------------
+
+static void Dispose( ColumnVector& rCols )
+{
+ ColumnVector::iterator aIter( rCols.begin() );
+ while( aIter != rCols.end() )
+ (*aIter++)->dispose();
+}
+
+// -----------------------------------------------------------------------------
+
+static void Dispose( CellVector& rCells )
+{
+ CellVector::iterator aIter( rCells.begin() );
+ while( aIter != rCells.end() )
+ (*aIter++)->dispose();
+}
+
+// -----------------------------------------------------------------------------
+
+InsertColUndo::InsertColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells )
+: SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
+, mxTable( xTable )
+, mnIndex( nIndex )
+, mbUndo( true )
+{
+ maColumns.swap( aNewCols );
+ maCells.swap( aCells );
+}
+
+// -----------------------------------------------------------------------------
+
+InsertColUndo::~InsertColUndo()
+{
+ if( !mbUndo )
+ {
+ Dispose( maColumns );
+ Dispose( maCells );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void InsertColUndo::Undo()
+{
+ if( mxTable.is() )
+ {
+ mxTable->UndoInsertColumns( mnIndex, sal::static_int_cast< sal_Int32 >( maColumns.size() ) );
+ mbUndo = false;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void InsertColUndo::Redo()
+{
+ if( mxTable.is() )
+ {
+ mxTable->UndoRemoveColumns( mnIndex, maColumns, maCells );
+ mbUndo = true;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// class RemoveColUndo : public SdrUndoAction
+// -----------------------------------------------------------------------------
+
+RemoveColUndo::RemoveColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells )
+: SdrUndoAction( *xTable->getSdrTableObj()->GetModel() )
+, mxTable( xTable )
+, mnIndex( nIndex )
+, mbUndo( true )
+{
+ maColumns.swap( aNewCols );
+ maCells.swap( aCells );
+}
+
+// -----------------------------------------------------------------------------
+
+RemoveColUndo::~RemoveColUndo()
+{
+ if( mbUndo )
+ {
+ Dispose( maColumns );
+ Dispose( maCells );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void RemoveColUndo::Undo()
+{
+ if( mxTable.is() )
+ {
+ mxTable->UndoRemoveColumns( mnIndex, maColumns, maCells );
+ mbUndo = false;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void RemoveColUndo::Redo()
+{
+ if( mxTable.is() )
+ {
+ mxTable->UndoInsertColumns( mnIndex, sal::static_int_cast< sal_Int32 >( maColumns.size() ) );
+ mbUndo = true;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// class TableColumnUndo : public SdrUndoAction
+// -----------------------------------------------------------------------------
+
+TableColumnUndo::TableColumnUndo( const TableColumnRef& xCol )
+: SdrUndoAction( *xCol->mxTableModel->getSdrTableObj()->GetModel() )
+, mxCol( xCol )
+, mbHasRedoData( false )
+{
+ getData( maUndoData );
+}
+
+// -----------------------------------------------------------------------------
+
+TableColumnUndo::~TableColumnUndo()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void TableColumnUndo::Undo()
+{
+ if( !mbHasRedoData )
+ {
+ getData( maRedoData );
+ mbHasRedoData = true;
+ }
+ setData( maUndoData );
+}
+
+// -----------------------------------------------------------------------------
+
+void TableColumnUndo::Redo()
+{
+ setData( maRedoData );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL TableColumnUndo::Merge( SfxUndoAction *pNextAction )
+{
+ TableColumnUndo* pNext = dynamic_cast< TableColumnUndo* >( pNextAction );
+ return pNext && pNext->mxCol == mxCol;
+}
+
+// -----------------------------------------------------------------------------
+
+void TableColumnUndo::setData( const Data& rData )
+{
+ mxCol->mnColumn = rData.mnColumn;
+ mxCol->mnWidth = rData.mnWidth;
+ mxCol->mbOptimalWidth = rData.mbOptimalWidth;
+ mxCol->mbIsVisible = rData.mbIsVisible;
+ mxCol->mbIsStartOfNewPage = rData.mbIsStartOfNewPage;
+ mxCol->maName = rData.maName;
+}
+
+// -----------------------------------------------------------------------------
+
+void TableColumnUndo::getData( Data& rData )
+{
+ rData.mnColumn = mxCol->mnColumn;
+ rData.mnWidth = mxCol->mnWidth;
+ rData.mbOptimalWidth = mxCol->mbOptimalWidth;
+ rData.mbIsVisible = mxCol->mbIsVisible;
+ rData.mbIsStartOfNewPage = mxCol->mbIsStartOfNewPage;
+ rData.maName = mxCol->maName;
+}
+
+// -----------------------------------------------------------------------------
+// class TableRowUndo : public SdrUndoAction
+// -----------------------------------------------------------------------------
+
+TableRowUndo::TableRowUndo( const TableRowRef& xRow )
+: SdrUndoAction( *xRow->mxTableModel->getSdrTableObj()->GetModel() )
+, mxRow( xRow )
+, mbHasRedoData( false )
+{
+ getData( maUndoData );
+}
+
+// -----------------------------------------------------------------------------
+
+TableRowUndo::~TableRowUndo()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void TableRowUndo::Undo()
+{
+ if( !mbHasRedoData )
+ {
+ getData( maRedoData );
+ mbHasRedoData = true;
+ }
+ setData( maUndoData );
+}
+
+// -----------------------------------------------------------------------------
+
+void TableRowUndo::Redo()
+{
+ setData( maRedoData );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL TableRowUndo::Merge( SfxUndoAction *pNextAction )
+{
+ TableRowUndo* pNext = dynamic_cast< TableRowUndo* >( pNextAction );
+ return pNext && pNext->mxRow == mxRow;
+}
+
+// -----------------------------------------------------------------------------
+
+void TableRowUndo::setData( const Data& rData )
+{
+ mxRow->mnRow = rData.mnRow;
+ mxRow->mnHeight = rData.mnHeight;
+ mxRow->mbOptimalHeight = rData.mbOptimalHeight;
+ mxRow->mbIsVisible = rData.mbIsVisible;
+ mxRow->mbIsStartOfNewPage = rData.mbIsStartOfNewPage;
+ mxRow->maName = rData.maName;
+ }
+
+// -----------------------------------------------------------------------------
+
+void TableRowUndo::getData( Data& rData )
+{
+ rData.mnRow = mxRow->mnRow;
+ rData.mnHeight = mxRow->mnHeight;
+ rData.mbOptimalHeight = mxRow->mbOptimalHeight;
+ rData.mbIsVisible = mxRow->mbIsVisible;
+ rData.mbIsStartOfNewPage = mxRow->mbIsStartOfNewPage;
+ rData.maName = mxRow->maName;
+}
+
+// -----------------------------------------------------------------------------
+
+TableStyleUndo::TableStyleUndo( const SdrTableObj& rTableObj )
+: SdrUndoAction( *rTableObj.GetModel() )
+, mxObjRef( const_cast< sdr::table::SdrTableObj*>( &rTableObj ) )
+{
+ getData( maUndoData );
+}
+
+void TableStyleUndo::Undo()
+{
+ if( !mbHasRedoData )
+ {
+ getData( maRedoData );
+ mbHasRedoData = true;
+ }
+ setData( maUndoData );
+}
+
+void TableStyleUndo::Redo()
+{
+ setData( maRedoData );
+}
+
+void TableStyleUndo::setData( const Data& rData )
+{
+ SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxObjRef.get() );
+ if( pTableObj )
+ {
+ pTableObj->setTableStyle( rData.mxTableStyle );
+ pTableObj->setTableStyleSettings( rData.maSettings );
+ }
+}
+
+void TableStyleUndo::getData( Data& rData )
+{
+ SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxObjRef.get() );
+ if( pTableObj )
+ {
+ rData.maSettings = pTableObj->getTableStyleSettings();
+ rData.mxTableStyle = pTableObj->getTableStyle();
+ }
+}
+
+} }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tableundo.hxx b/svx/source/table/tableundo.hxx
new file mode 100644
index 000000000000..f5d4c8e52dd0
--- /dev/null
+++ b/svx/source/table/tableundo.hxx
@@ -0,0 +1,262 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_TABLEUNDO_HXX_
+#define _SVX_TABLEUNDO_HXX_
+
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/table/CellContentType.hpp>
+
+#include "svx/svdotable.hxx"
+#include "svx/svdobj.hxx"
+#include "svx/svdundo.hxx"
+
+#include "celltypes.hxx"
+
+namespace sdr { namespace properties {
+ class TextProperties;
+} }
+
+class OutlinerParaObject;
+
+// -----------------------------------------------------------------------------
+
+namespace sdr { namespace table {
+
+class CellUndo : public SdrUndoAction, public sdr::ObjectUser
+{
+public:
+ CellUndo( const SdrObjectWeakRef& xObjRef, const CellRef& xCell );
+ virtual ~CellUndo();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual BOOL Merge( SfxUndoAction *pNextAction );
+
+ void dispose();
+ virtual void ObjectInDestruction(const SdrObject& rObject);
+
+private:
+ struct Data
+ {
+ sdr::properties::TextProperties* mpProperties;
+ OutlinerParaObject* mpOutlinerParaObject;
+
+ ::com::sun::star::table::CellContentType mnCellContentType;
+
+ ::rtl::OUString msFormula;
+ double mfValue;
+ ::sal_Int32 mnError;
+ ::sal_Bool mbMerged;
+ ::sal_Int32 mnRowSpan;
+ ::sal_Int32 mnColSpan;
+
+ Data() : mpProperties(0), mpOutlinerParaObject(0) {};
+ };
+
+ void setDataToCell( const Data& rData );
+ void getDataFromCell( Data& rData );
+
+ SdrObjectWeakRef mxObjRef;
+ CellRef mxCell;
+ Data maUndoData;
+ Data maRedoData;
+ bool mbUndo;
+};
+
+// -----------------------------------------------------------------------------
+
+class InsertRowUndo : public SdrUndoAction
+{
+public:
+ InsertRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aNewRows );
+ virtual ~InsertRowUndo();
+
+ virtual void Undo();
+ virtual void Redo();
+
+private:
+ TableModelRef mxTable;
+ sal_Int32 mnIndex;
+ RowVector maRows;
+ bool mbUndo;
+};
+
+// -----------------------------------------------------------------------------
+
+class RemoveRowUndo : public SdrUndoAction
+{
+public:
+ RemoveRowUndo( const TableModelRef& xTable, sal_Int32 nIndex, RowVector& aRemovedRows );
+ virtual ~RemoveRowUndo();
+
+ virtual void Undo();
+ virtual void Redo();
+
+private:
+ TableModelRef mxTable;
+ sal_Int32 mnIndex;
+ RowVector maRows;
+ bool mbUndo;
+};
+
+// -----------------------------------------------------------------------------
+
+class InsertColUndo : public SdrUndoAction
+{
+public:
+ InsertColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells );
+ virtual ~InsertColUndo();
+
+ virtual void Undo();
+ virtual void Redo();
+
+private:
+ TableModelRef mxTable;
+ sal_Int32 mnIndex;
+ ColumnVector maColumns;
+ CellVector maCells;
+ bool mbUndo;
+};
+
+// -----------------------------------------------------------------------------
+
+class RemoveColUndo : public SdrUndoAction
+{
+public:
+ RemoveColUndo( const TableModelRef& xTable, sal_Int32 nIndex, ColumnVector& aNewCols, CellVector& aCells );
+ virtual ~RemoveColUndo();
+
+ virtual void Undo();
+ virtual void Redo();
+
+private:
+ TableModelRef mxTable;
+ sal_Int32 mnIndex;
+ ColumnVector maColumns;
+ CellVector maCells;
+ bool mbUndo;
+};
+
+// -----------------------------------------------------------------------------
+
+class TableColumnUndo : public SdrUndoAction
+{
+public:
+ TableColumnUndo( const TableColumnRef& xCol );
+ virtual ~TableColumnUndo();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual BOOL Merge( SfxUndoAction *pNextAction );
+
+private:
+ struct Data
+ {
+ sal_Int32 mnColumn;
+ sal_Int32 mnWidth;
+ sal_Bool mbOptimalWidth;
+ sal_Bool mbIsVisible;
+ sal_Bool mbIsStartOfNewPage;
+ ::rtl::OUString maName;
+ };
+
+ void setData( const Data& rData );
+ void getData( Data& rData );
+
+ TableColumnRef mxCol;
+ Data maUndoData;
+ Data maRedoData;
+ bool mbHasRedoData;
+};
+
+// -----------------------------------------------------------------------------
+
+class TableRowUndo : public SdrUndoAction
+{
+public:
+ TableRowUndo( const TableRowRef& xRow );
+ virtual ~TableRowUndo();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual BOOL Merge( SfxUndoAction *pNextAction );
+
+private:
+ struct Data
+ {
+ CellVector maCells;
+ sal_Int32 mnRow;
+ sal_Int32 mnHeight;
+ sal_Bool mbOptimalHeight;
+ sal_Bool mbIsVisible;
+ sal_Bool mbIsStartOfNewPage;
+ ::rtl::OUString maName;
+ };
+
+ void setData( const Data& rData );
+ void getData( Data& rData );
+
+ TableRowRef mxRow;
+ Data maUndoData;
+ Data maRedoData;
+ bool mbHasRedoData;
+};
+
+// -----------------------------------------------------------------------------
+
+class TableStyleUndo : public SdrUndoAction
+{
+public:
+ TableStyleUndo( const SdrTableObj& rTableObj );
+
+ virtual void Undo();
+ virtual void Redo();
+
+private:
+ SdrObjectWeakRef mxObjRef;
+
+ struct Data
+ {
+ TableStyleSettings maSettings;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > mxTableStyle;
+ };
+
+ void setData( const Data& rData );
+ void getData( Data& rData );
+
+ Data maUndoData;
+ Data maRedoData;
+ bool mbHasRedoData;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/viewcontactoftableobj.cxx b/svx/source/table/viewcontactoftableobj.cxx
new file mode 100644
index 000000000000..b2e24ed4e8c9
--- /dev/null
+++ b/svx/source/table/viewcontactoftableobj.cxx
@@ -0,0 +1,743 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "viewcontactoftableobj.hxx"
+#include <svx/svdotable.hxx>
+#include <com/sun/star/table/XTable.hpp>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/primitive2d/sdrdecompositiontools.hxx>
+#include <svx/sdr/primitive2d/sdrattributecreator.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <svx/sdr/attribute/sdrtextattribute.hxx>
+#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
+#include <editeng/borderline.hxx>
+#include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
+#include <svx/sdr/attribute/sdrfilltextattribute.hxx>
+#include <drawinglayer/attribute/sdrlineattribute.hxx>
+#include <drawinglayer/attribute/sdrshadowattribute.hxx>
+#include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+#include "cell.hxx"
+#include "tablelayouter.hxx"
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ class SdrCellPrimitive2D : public BufferedDecompositionPrimitive2D
+ {
+ private:
+ basegfx::B2DHomMatrix maTransform;
+ attribute::SdrFillTextAttribute maSdrFTAttribute;
+
+ protected:
+ // local decomposition.
+ virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
+
+ public:
+ SdrCellPrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const attribute::SdrFillTextAttribute& rSdrFTAttribute)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maSdrFTAttribute(rSdrFTAttribute)
+ {
+ }
+
+ // data access
+ const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
+ const attribute::SdrFillTextAttribute& getSdrFTAttribute() const { return maSdrFTAttribute; }
+
+ // compare operator
+ virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
+
+ // provide unique ID
+ DeclPrimitrive2DIDBlock()
+ };
+
+ Primitive2DSequence SdrCellPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ // prepare unit polygon
+ Primitive2DSequence aRetval;
+ const basegfx::B2DPolyPolygon aUnitPolyPolygon(basegfx::tools::createUnitPolygon());
+
+ // add fill
+ if(!getSdrFTAttribute().getFill().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createPolyPolygonFillPrimitive(
+ aUnitPolyPolygon,
+ getTransform(),
+ getSdrFTAttribute().getFill(),
+ getSdrFTAttribute().getFillFloatTransGradient()));
+ }
+ else
+ {
+ // if no fill create one for HitTest and BoundRect fallback
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createHiddenGeometryPrimitives2D(
+ true,
+ aUnitPolyPolygon,
+ getTransform()));
+ }
+
+ // add text
+ if(!getSdrFTAttribute().getText().isDefault())
+ {
+ appendPrimitive2DReferenceToPrimitive2DSequence(aRetval,
+ createTextPrimitive(
+ aUnitPolyPolygon,
+ getTransform(),
+ getSdrFTAttribute().getText(),
+ attribute::SdrLineAttribute(),
+ true,
+ false,
+ false));
+ }
+
+ return aRetval;
+ }
+
+ bool SdrCellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrCellPrimitive2D& rCompare = (SdrCellPrimitive2D&)rPrimitive;
+
+ return (getTransform() == rCompare.getTransform()
+ && getSdrFTAttribute() == rCompare.getSdrFTAttribute());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrCellPrimitive2D, PRIMITIVE2D_ID_SDRCELLPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ class SdrBorderlinePrimitive2D : public BufferedDecompositionPrimitive2D
+ {
+ private:
+ basegfx::B2DHomMatrix maTransform;
+ SvxBorderLine maLeftLine;
+ SvxBorderLine maBottomLine;
+ SvxBorderLine maRightLine;
+ SvxBorderLine maTopLine;
+
+ // bitfield
+ unsigned mbLeftIsOutside : 1;
+ unsigned mbBottomIsOutside : 1;
+ unsigned mbRightIsOutside : 1;
+ unsigned mbTopIsOutside : 1;
+ unsigned mbInTwips : 1;
+
+ protected:
+ // local decomposition.
+ virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
+
+ public:
+ SdrBorderlinePrimitive2D(
+ const basegfx::B2DHomMatrix& rTransform,
+ const SvxBorderLine& rLeftLine,
+ const SvxBorderLine& rBottomLine,
+ const SvxBorderLine& rRightLine,
+ const SvxBorderLine& rTopLine,
+ bool bLeftIsOutside,
+ bool bBottomIsOutside,
+ bool bRightIsOutside,
+ bool bTopIsOutside,
+ bool bInTwips)
+ : BufferedDecompositionPrimitive2D(),
+ maTransform(rTransform),
+ maLeftLine(rLeftLine),
+ maBottomLine(rBottomLine),
+ maRightLine(rRightLine),
+ maTopLine(rTopLine),
+ mbLeftIsOutside(bLeftIsOutside),
+ mbBottomIsOutside(bBottomIsOutside),
+ mbRightIsOutside(bRightIsOutside),
+ mbTopIsOutside(bTopIsOutside),
+ mbInTwips(bInTwips)
+ {
+ }
+
+
+ // data access
+ const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
+ const SvxBorderLine& getLeftLine() const { return maLeftLine; }
+ const SvxBorderLine& getBottomLine() const { return maBottomLine; }
+ const SvxBorderLine& getRightLine() const { return maRightLine; }
+ const SvxBorderLine& getTopLine() const { return maTopLine; }
+ bool getLeftIsOutside() const { return mbLeftIsOutside; }
+ bool getBottomIsOutside() const { return mbBottomIsOutside; }
+ bool getRightIsOutside() const { return mbRightIsOutside; }
+ bool getTopIsOutside() const { return mbTopIsOutside; }
+ bool getInTwips() const { return mbInTwips; }
+
+ // compare operator
+ virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
+
+ // provide unique ID
+ DeclPrimitrive2DIDBlock()
+ };
+
+ sal_uInt16 getBorderLineOutWidth(const SvxBorderLine& rLineA)
+ {
+ return (1 == rLineA.GetOutWidth() ? 0 : rLineA.GetOutWidth());
+ }
+
+ sal_uInt16 getBorderLineDistance(const SvxBorderLine& rLineA)
+ {
+ return (1 == rLineA.GetDistance() ? 0 : rLineA.GetDistance());
+ }
+
+ sal_uInt16 getBorderLineInWidth(const SvxBorderLine& rLineA)
+ {
+ return (1 == rLineA.GetInWidth() ? 0 : rLineA.GetInWidth());
+ }
+
+ sal_uInt16 getBorderLineWidth(const SvxBorderLine& rLineA)
+ {
+ return getBorderLineOutWidth(rLineA) + getBorderLineDistance(rLineA) + getBorderLineInWidth(rLineA);
+ }
+
+ double getInnerExtend(const SvxBorderLine& rLineA, bool bSideToUse)
+ {
+ if(!rLineA.isEmpty())
+ {
+ if(rLineA.isDouble())
+ {
+ // reduce to inner edge of associated matching line
+ return -((getBorderLineWidth(rLineA) / 2.0) - (bSideToUse ? getBorderLineOutWidth(rLineA) : getBorderLineInWidth(rLineA)));
+ }
+ else
+ {
+ // extend to overlap with single line
+ return getBorderLineWidth(rLineA) / 2.0;
+ }
+ }
+
+ return 0.0;
+ }
+
+ double getOuterExtend(const SvxBorderLine& rLineA)
+ {
+ if(!rLineA.isEmpty())
+ {
+ // extend to overlap with single line
+ return getBorderLineWidth(rLineA) / 2.0;
+ }
+
+ return 0.0;
+ }
+
+ double getChangedValue(sal_uInt16 nValue, bool bChangeToMM)
+ {
+ if(1 == nValue)
+ return 1.0;
+
+ if(bChangeToMM)
+ return nValue * (127.0 / 72.0);
+
+ return (double)nValue;
+ }
+
+ Primitive2DSequence SdrBorderlinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const
+ {
+ Primitive2DSequence xRetval(4);
+ sal_uInt32 nInsert(0);
+ const double fTwipsToMM(getInTwips() ? (127.0 / 72.0) : 1.0);
+
+ if(!getLeftLine().isEmpty())
+ {
+ // create left line from top to bottom
+ const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 0.0));
+ const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(0.0, 1.0));
+
+ if(!aStart.equal(aEnd))
+ {
+ const double fExtendIS(getInnerExtend(getTopLine(), false));
+ const double fExtendIE(getInnerExtend(getBottomLine(), true));
+ double fExtendOS(0.0);
+ double fExtendOE(0.0);
+
+ if(getLeftIsOutside())
+ {
+ if(getTopIsOutside())
+ {
+ fExtendOS = getOuterExtend(getTopLine());
+ }
+
+ if(getBottomIsOutside())
+ {
+ fExtendOE = getOuterExtend(getBottomLine());
+ }
+ }
+
+ xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
+ aStart,
+ aEnd,
+ getChangedValue(getLeftLine().GetOutWidth(), getInTwips()),
+ getChangedValue(getLeftLine().GetDistance(), getInTwips()),
+ getChangedValue(getLeftLine().GetInWidth(), getInTwips()),
+ fExtendIS * fTwipsToMM,
+ fExtendIE * fTwipsToMM,
+ fExtendOS * fTwipsToMM,
+ fExtendOE * fTwipsToMM,
+ true,
+ getLeftIsOutside(),
+ getLeftLine().GetColor().getBColor(),
+ getLeftLine().GetStyle()));
+ }
+ }
+
+ if(!getBottomLine().isEmpty())
+ {
+ // create bottom line from left to right
+ const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 1.0));
+ const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 1.0));
+
+ if(!aStart.equal(aEnd))
+ {
+ const double fExtendIS(getInnerExtend(getLeftLine(), true));
+ const double fExtendIE(getInnerExtend(getRightLine(), false));
+ double fExtendOS(0.0);
+ double fExtendOE(0.0);
+
+ if(getBottomIsOutside())
+ {
+ if(getLeftIsOutside())
+ {
+ fExtendOS = getOuterExtend(getLeftLine());
+ }
+
+ if(getRightIsOutside())
+ {
+ fExtendOE = getOuterExtend(getRightLine());
+ }
+ }
+
+ xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
+ aStart,
+ aEnd,
+ getChangedValue(getBottomLine().GetOutWidth(), getInTwips()),
+ getChangedValue(getBottomLine().GetDistance(), getInTwips()),
+ getChangedValue(getBottomLine().GetInWidth(), getInTwips()),
+ fExtendIS * fTwipsToMM,
+ fExtendIE * fTwipsToMM,
+ fExtendOS * fTwipsToMM,
+ fExtendOE * fTwipsToMM,
+ true,
+ getBottomIsOutside(),
+ getBottomLine().GetColor().getBColor(),
+ getBottomLine().GetStyle()));
+ }
+ }
+
+ if(!getRightLine().isEmpty())
+ {
+ // create right line from top to bottom
+ const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(1.0, 0.0));
+ const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 1.0));
+
+ if(!aStart.equal(aEnd))
+ {
+ const double fExtendIS(getInnerExtend(getTopLine(), false));
+ const double fExtendIE(getInnerExtend(getBottomLine(), true));
+ double fExtendOS(0.0);
+ double fExtendOE(0.0);
+
+ if(getRightIsOutside())
+ {
+ if(getTopIsOutside())
+ {
+ fExtendOS = getOuterExtend(getTopLine());
+ }
+
+ if(getBottomIsOutside())
+ {
+ fExtendOE = getOuterExtend(getBottomLine());
+ }
+ }
+
+ xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
+ aStart,
+ aEnd,
+ getChangedValue(getRightLine().GetOutWidth(), getInTwips()),
+ getChangedValue(getRightLine().GetDistance(), getInTwips()),
+ getChangedValue(getRightLine().GetInWidth(), getInTwips()),
+ fExtendOS * fTwipsToMM,
+ fExtendOE * fTwipsToMM,
+ fExtendIS * fTwipsToMM,
+ fExtendIE * fTwipsToMM,
+ getRightIsOutside(),
+ true,
+ getRightLine().GetColor().getBColor(),
+ getRightLine().GetStyle()));
+ }
+ }
+
+ if(!getTopLine().isEmpty())
+ {
+ // create top line from left to right
+ const basegfx::B2DPoint aStart(getTransform() * basegfx::B2DPoint(0.0, 0.0));
+ const basegfx::B2DPoint aEnd(getTransform() * basegfx::B2DPoint(1.0, 0.0));
+
+ if(!aStart.equal(aEnd))
+ {
+ const double fExtendIS(getInnerExtend(getLeftLine(), true));
+ const double fExtendIE(getInnerExtend(getRightLine(), false));
+ double fExtendOS(0.0);
+ double fExtendOE(0.0);
+
+ if(getTopIsOutside())
+ {
+ if(getLeftIsOutside())
+ {
+ fExtendOS = getOuterExtend(getLeftLine());
+ }
+
+ if(getRightIsOutside())
+ {
+ fExtendOE = getOuterExtend(getRightLine());
+ }
+ }
+
+ xRetval[nInsert++] = Primitive2DReference(new BorderLinePrimitive2D(
+ aStart,
+ aEnd,
+ getChangedValue(getTopLine().GetOutWidth(), getInTwips()),
+ getChangedValue(getTopLine().GetDistance(), getInTwips()),
+ getChangedValue(getTopLine().GetInWidth(), getInTwips()),
+ fExtendOS * fTwipsToMM,
+ fExtendOE * fTwipsToMM,
+ fExtendIS * fTwipsToMM,
+ fExtendIE * fTwipsToMM,
+ getTopIsOutside(),
+ true,
+ getTopLine().GetColor().getBColor(),
+ getTopLine().GetStyle()));
+ }
+ }
+
+ xRetval.realloc(nInsert);
+ return xRetval;
+ }
+
+ bool SdrBorderlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
+ {
+ const SdrBorderlinePrimitive2D& rCompare = (SdrBorderlinePrimitive2D&)rPrimitive;
+
+ return (getTransform() == rCompare.getTransform()
+ && getLeftLine() == rCompare.getLeftLine()
+ && getBottomLine() == rCompare.getBottomLine()
+ && getRightLine() == rCompare.getRightLine()
+ && getTopLine() == rCompare.getTopLine()
+ && getLeftIsOutside() == rCompare.getLeftIsOutside()
+ && getBottomIsOutside() == rCompare.getBottomIsOutside()
+ && getRightIsOutside() == rCompare.getRightIsOutside()
+ && getTopIsOutside() == rCompare.getTopIsOutside()
+ && getInTwips() == rCompare.getInTwips());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(SdrBorderlinePrimitive2D, PRIMITIVE2D_ID_SDRBORDERLINEPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace contact
+ {
+ void impGetLine(SvxBorderLine& aLine, const sdr::table::TableLayouter& rLayouter, sal_Int32 nX, sal_Int32 nY, bool bHorizontal, sal_Int32 nColCount, sal_Int32 nRowCount, bool bIsRTL)
+ {
+ if(nX >= 0 && nX <= nColCount && nY >= 0 && nY <= nRowCount)
+ {
+ const SvxBorderLine* pLine = rLayouter.getBorderLine(nX, nY, bHorizontal);
+
+ if(pLine)
+ {
+ // copy line content
+ aLine = *pLine;
+
+ // check for mirroring. This shall always be done when it is
+ // not a top- or rightmost line
+ bool bMirror(aLine.isDouble());
+
+ if(bMirror)
+ {
+ if(bHorizontal)
+ {
+ // mirror all bottom lines
+ bMirror = (0 != nY);
+ }
+ else
+ {
+ // mirror all left lines
+ bMirror = (bIsRTL ? 0 != nX : nX != nColCount);
+ }
+ }
+
+ if(bMirror)
+ {
+ aLine.SetOutWidth(pLine->GetInWidth());
+ aLine.SetInWidth(pLine->GetOutWidth());
+ }
+
+ return;
+ }
+ }
+
+ // no success, copy empty line
+ const SvxBorderLine aEmptyLine;
+ aLine = aEmptyLine;
+ }
+
+ drawinglayer::primitive2d::Primitive2DSequence ViewContactOfTableObj::createViewIndependentPrimitive2DSequence() const
+ {
+ const sdr::table::SdrTableObj& rTableObj = GetTableObj();
+ const uno::Reference< com::sun::star::table::XTable > xTable = rTableObj.getTable();
+
+ if(xTable.is())
+ {
+ // create primitive representation for table
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+ const sal_Int32 nRowCount(xTable->getRowCount());
+ const sal_Int32 nColCount(xTable->getColumnCount());
+ const sal_Int32 nAllCount(nRowCount * nColCount);
+
+ if(nAllCount)
+ {
+ const sdr::table::TableLayouter& rTableLayouter = rTableObj.getTableLayouter();
+ const bool bIsRTL(com::sun::star::text::WritingMode_RL_TB == rTableObj.GetWritingMode());
+ sdr::table::CellPos aCellPos;
+ sdr::table::CellRef xCurrentCell;
+ basegfx::B2IRectangle aCellArea;
+
+ // create range using the model data directly. This is in SdrTextObj::aRect which i will access using
+ // GetGeoRect() to not trigger any calculations. It's the unrotated geometry.
+ const Rectangle& rObjectRectangle(rTableObj.GetGeoRect());
+ const basegfx::B2DRange aObjectRange(rObjectRectangle.Left(), rObjectRectangle.Top(), rObjectRectangle.Right(), rObjectRectangle.Bottom());
+
+ // for each cell we need potentially a cell primitive and a border primitive
+ // (e.g. single cell). Prepare sequences and input counters
+ drawinglayer::primitive2d::Primitive2DSequence xCellSequence(nAllCount);
+ drawinglayer::primitive2d::Primitive2DSequence xBorderSequence(nAllCount);
+ sal_uInt32 nCellInsert(0);
+ sal_uInt32 nBorderInsert(0);
+
+ // variables for border lines
+ SvxBorderLine aLeftLine;
+ SvxBorderLine aBottomLine;
+ SvxBorderLine aRightLine;
+ SvxBorderLine aTopLine;
+
+ // create single primitives per cell
+ for(aCellPos.mnRow = 0; aCellPos.mnRow < nRowCount; aCellPos.mnRow++)
+ {
+ for(aCellPos.mnCol = 0; aCellPos.mnCol < nColCount; aCellPos.mnCol++)
+ {
+ xCurrentCell.set(dynamic_cast< sdr::table::Cell* >(xTable->getCellByPosition(aCellPos.mnCol, aCellPos.mnRow).get()));
+
+ if(xCurrentCell.is() && !xCurrentCell->isMerged())
+ {
+ if(rTableLayouter.getCellArea(aCellPos, aCellArea))
+ {
+ // create cell transformation matrix
+ basegfx::B2DHomMatrix aCellMatrix;
+ aCellMatrix.set(0, 0, (double)aCellArea.getWidth());
+ aCellMatrix.set(1, 1, (double)aCellArea.getHeight());
+ aCellMatrix.set(0, 2, (double)aCellArea.getMinX() + aObjectRange.getMinX());
+ aCellMatrix.set(1, 2, (double)aCellArea.getMinY() + aObjectRange.getMinY());
+
+ // handle cell fillings and text
+ const SfxItemSet& rCellItemSet = xCurrentCell->GetItemSet();
+ const sal_uInt32 nTextIndex(nColCount * aCellPos.mnRow + aCellPos.mnCol);
+ const SdrText* pSdrText = rTableObj.getText(nTextIndex);
+ drawinglayer::attribute::SdrFillTextAttribute aAttribute;
+
+ if(pSdrText)
+ {
+ // #i101508# take cell's local text frame distances into account
+ const sal_Int32 nLeft(xCurrentCell->GetTextLeftDistance());
+ const sal_Int32 nRight(xCurrentCell->GetTextRightDistance());
+ const sal_Int32 nUpper(xCurrentCell->GetTextUpperDistance());
+ const sal_Int32 nLower(xCurrentCell->GetTextLowerDistance());
+
+ aAttribute = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
+ rCellItemSet,
+ pSdrText,
+ &nLeft,
+ &nUpper,
+ &nRight,
+ &nLower);
+ }
+ else
+ {
+ aAttribute = drawinglayer::primitive2d::createNewSdrFillTextAttribute(
+ rCellItemSet,
+ pSdrText);
+ }
+
+ // always create cell primitives for BoundRect and HitTest
+ {
+ const drawinglayer::primitive2d::Primitive2DReference xCellReference(
+ new drawinglayer::primitive2d::SdrCellPrimitive2D(
+ aCellMatrix, aAttribute));
+ xCellSequence[nCellInsert++] = xCellReference;
+ }
+
+ // handle cell borders
+ const sal_Int32 nX(bIsRTL ? nColCount - aCellPos.mnCol : aCellPos.mnCol);
+ const sal_Int32 nY(aCellPos.mnRow);
+
+ // get access values for X,Y at the cell's end
+ const sal_Int32 nXSpan(xCurrentCell->getColumnSpan());
+ const sal_Int32 nYSpan(xCurrentCell->getRowSpan());
+ const sal_Int32 nXRight(bIsRTL ? nX - nXSpan : nX + nXSpan);
+ const sal_Int32 nYBottom(nY + nYSpan);
+
+ // get basic lines
+ impGetLine(aLeftLine, rTableLayouter, nX, nY, false, nColCount, nRowCount, bIsRTL);
+ impGetLine(aBottomLine, rTableLayouter, nX, nYBottom, true, nColCount, nRowCount, bIsRTL);
+ impGetLine(aRightLine, rTableLayouter, nXRight, nY, false, nColCount, nRowCount, bIsRTL);
+ impGetLine(aTopLine, rTableLayouter, nX, nY, true, nColCount, nRowCount, bIsRTL);
+
+ // create the primtive containing all data for one cell with borders
+ xBorderSequence[nBorderInsert++] = drawinglayer::primitive2d::Primitive2DReference(
+ new drawinglayer::primitive2d::SdrBorderlinePrimitive2D(
+ aCellMatrix,
+ aLeftLine,
+ aBottomLine,
+ aRightLine,
+ aTopLine,
+ bIsRTL ? nX == nColCount : 0 == nX,
+ nRowCount == nYBottom,
+ bIsRTL ? 0 == nXRight : nXRight == nColCount,
+ 0 == nY,
+ true));
+ }
+ }
+ }
+ }
+
+ // no empty references; reallocate sequences by used count
+ xCellSequence.realloc(nCellInsert);
+ xBorderSequence.realloc(nBorderInsert);
+
+ // append to target. We want fillings and text first
+ xRetval = xCellSequence;
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, xBorderSequence);
+ }
+
+ if(xRetval.hasElements())
+ {
+ // check and create evtl. shadow for created content
+ const SfxItemSet& rObjectItemSet = rTableObj.GetMergedItemSet();
+ const drawinglayer::attribute::SdrShadowAttribute aNewShadowAttribute(
+ drawinglayer::primitive2d::createNewSdrShadowAttribute(rObjectItemSet));
+
+ if(!aNewShadowAttribute.isDefault())
+ {
+ xRetval = drawinglayer::primitive2d::createEmbeddedShadowPrimitive(xRetval, aNewShadowAttribute);
+ }
+ }
+
+ return xRetval;
+ }
+ else
+ {
+ // take unrotated snap rect (direct model data) for position and size
+ const Rectangle& rRectangle = rTableObj.GetGeoRect();
+ const basegfx::B2DRange aObjectRange(
+ rRectangle.Left(), rRectangle.Top(),
+ rRectangle.Right(), rRectangle.Bottom());
+
+ // create object matrix
+ const GeoStat& rGeoStat(rTableObj.GetGeoStat());
+ const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0);
+ const double fRotate(rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0);
+ const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aObjectRange.getWidth(), aObjectRange.getHeight(), fShearX, fRotate,
+ aObjectRange.getMinX(), aObjectRange.getMinY()));
+
+ // credate an invisible outline for the cases where no visible content exists
+ const drawinglayer::primitive2d::Primitive2DReference xReference(
+ drawinglayer::primitive2d::createHiddenGeometryPrimitives2D(
+ false,
+ aObjectMatrix));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
+ }
+ }
+
+ ViewContactOfTableObj::ViewContactOfTableObj(::sdr::table::SdrTableObj& rTableObj)
+ : ViewContactOfSdrObj(rTableObj)
+ {
+ }
+
+ ViewContactOfTableObj::~ViewContactOfTableObj()
+ {
+ }
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/viewcontactoftableobj.hxx b/svx/source/table/viewcontactoftableobj.hxx
new file mode 100644
index 000000000000..3a7b5e4c8368
--- /dev/null
+++ b/svx/source/table/viewcontactoftableobj.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SDR_CONTACT_VIEWCONTACTOFTABLEOBJ_HXX
+#define _SDR_CONTACT_VIEWCONTACTOFTABLEOBJ_HXX
+
+#include <svx/sdr/contact/viewcontactofsdrobj.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// predeclarations
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace sdr
+{
+ namespace table
+ {
+ class SdrTableObj;
+ }
+
+ namespace contact
+ {
+ class ViewContactOfTableObj : public ViewContactOfSdrObj
+ {
+ protected:
+ // internal access to SdrTextObj
+ ::sdr::table::SdrTableObj& GetTableObj() const
+ {
+ return (::sdr::table::SdrTableObj&)GetSdrObject();
+ }
+
+ // This method is responsible for creating the graphical visualisation data derived ONLY from
+ // the model data
+ virtual drawinglayer::primitive2d::Primitive2DSequence createViewIndependentPrimitive2DSequence() const;
+
+ public:
+ // basic constructor, used from SdrObject.
+ ViewContactOfTableObj(::sdr::table::SdrTableObj& rTextObj);
+ virtual ~ViewContactOfTableObj();
+ };
+ } // end of namespace contact
+} // end of namespace sdr
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/colorwindow.hxx b/svx/source/tbxctrls/colorwindow.hxx
new file mode 100644
index 000000000000..763f2bfb8f20
--- /dev/null
+++ b/svx/source/tbxctrls/colorwindow.hxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+//========================================================================
+// class SvxColorWindow_Impl --------------------------------------------------
+//========================================================================
+#ifndef __SVX_COLORWINDOW_HXX_
+#define __SVX_COLORWINDOW_HXX_
+
+#include <sfx2/tbxctrl.hxx>
+#include <svl/lstner.hxx>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/frame/XFrame.hpp>
+
+//========================================================================
+// class SvxColorWindow_Impl --------------------------------------------------
+//========================================================================
+
+class SvxColorWindow_Impl : public SfxPopupWindow
+{
+ using FloatingWindow::StateChanged;
+
+private:
+ const USHORT theSlotId;
+ ValueSet aColorSet;
+ rtl::OUString maCommand;
+
+#if _SOLAR__PRIVATE
+ DECL_LINK( SelectHdl, void * );
+#endif
+
+protected:
+ virtual void Resize();
+ virtual BOOL Close();
+
+public:
+ SvxColorWindow_Impl( const rtl::OUString& rCommand,
+ USHORT nSlotId,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
+ const String& rWndTitle,
+ Window* pParentWindow );
+ ~SvxColorWindow_Impl();
+ void StartSelection();
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState );
+
+ virtual SfxPopupWindow* Clone() const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/colrctrl.cxx b/svx/source/tbxctrls/colrctrl.cxx
new file mode 100644
index 000000000000..f07784520dd9
--- /dev/null
+++ b/svx/source/tbxctrls/colrctrl.cxx
@@ -0,0 +1,664 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/dialogs.hrc>
+
+
+#include <tools/list.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/image.hxx>
+
+#include <svx/colrctrl.hxx>
+
+#include <svx/svdview.hxx>
+#include "drawitem.hxx"
+#include <editeng/colritem.hxx>
+#include "xattr.hxx"
+#include <svx/xtable.hxx>
+#include <svx/dialmgr.hxx>
+#include "xexch.hxx"
+#include <vcl/svapp.hxx>
+
+SFX_IMPL_DOCKINGWINDOW( SvxColorChildWindow, SID_COLOR_CONTROL )
+
+// ------------------------
+// - SvxColorValueSetData -
+// ------------------------
+
+class SvxColorValueSetData : public TransferableHelper
+{
+private:
+
+ XFillExchangeData maData;
+
+protected:
+
+ virtual void AddSupportedFormats();
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+
+public:
+
+ SvxColorValueSetData( const XFillAttrSetItem& rSetItem ) :
+ maData( rSetItem ) {}
+};
+
+// -----------------------------------------------------------------------------
+
+void SvxColorValueSetData::AddSupportedFormats()
+{
+ AddFormat( SOT_FORMATSTR_ID_XFA );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SvxColorValueSetData::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+{
+ sal_Bool bRet = sal_False;
+
+ if( SotExchange::GetFormat( rFlavor ) == SOT_FORMATSTR_ID_XFA )
+ {
+ SetObject( &maData, 0, rFlavor );
+ bRet = sal_True;
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SvxColorValueSetData::WriteObject( SotStorageStreamRef& rxOStm, void*, sal_uInt32 , const ::com::sun::star::datatransfer::DataFlavor& )
+{
+ *rxOStm << maData;
+ return( rxOStm->GetError() == ERRCODE_NONE );
+}
+
+/*************************************************************************
+|*
+|* SvxColorValueSet: Ctor
+|*
+\************************************************************************/
+
+SvxColorValueSet::SvxColorValueSet( Window* _pParent, WinBits nWinStyle ) :
+ ValueSet( _pParent, nWinStyle ),
+ DragSourceHelper( this ),
+ bLeft (TRUE)
+{
+}
+
+/*************************************************************************
+|*
+|* SvxColorValueSet: Ctor
+|*
+\************************************************************************/
+
+SvxColorValueSet::SvxColorValueSet( Window* _pParent, const ResId& rResId ) :
+ ValueSet( _pParent, rResId ),
+ DragSourceHelper( this ),
+ bLeft (TRUE)
+{
+}
+
+/*************************************************************************
+|*
+|* SvxColorValueSet: MouseButtonDown
+|*
+\************************************************************************/
+
+void SvxColorValueSet::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ // Fuer Mac noch anders handlen !
+ if( rMEvt.IsLeft() )
+ {
+ bLeft = TRUE;
+ ValueSet::MouseButtonDown( rMEvt );
+ }
+ else
+ {
+ bLeft = FALSE;
+ MouseEvent aMEvt( rMEvt.GetPosPixel(),
+ rMEvt.GetClicks(),
+ rMEvt.GetMode(),
+ MOUSE_LEFT,
+ rMEvt.GetModifier() );
+ ValueSet::MouseButtonDown( aMEvt );
+ }
+
+ aDragPosPixel = GetPointerPosPixel();
+}
+
+/*************************************************************************
+|*
+|* SvxColorValueSet: MouseButtonUp
+|*
+\************************************************************************/
+
+void SvxColorValueSet::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ // Fuer Mac noch anders handlen !
+ if( rMEvt.IsLeft() )
+ {
+ bLeft = TRUE;
+ ValueSet::MouseButtonUp( rMEvt );
+ }
+ else
+ {
+ bLeft = FALSE;
+ MouseEvent aMEvt( rMEvt.GetPosPixel(),
+ rMEvt.GetClicks(),
+ rMEvt.GetMode(),
+ MOUSE_LEFT,
+ rMEvt.GetModifier() );
+ ValueSet::MouseButtonUp( aMEvt );
+ }
+ SetNoSelection();
+}
+
+/*************************************************************************
+|*
+|* Command-Event
+|*
+\************************************************************************/
+
+void SvxColorValueSet::Command(const CommandEvent& rCEvt)
+{
+ // Basisklasse
+ ValueSet::Command(rCEvt);
+}
+
+/*************************************************************************
+|*
+|* StartDrag
+|*
+\************************************************************************/
+
+void SvxColorValueSet::StartDrag( sal_Int8 , const Point& )
+{
+ Application::PostUserEvent(STATIC_LINK(this, SvxColorValueSet, ExecDragHdl));
+}
+
+/*************************************************************************
+|*
+|* Drag&Drop asynchron ausfuehren
+|*
+\************************************************************************/
+
+void SvxColorValueSet::DoDrag()
+{
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ USHORT nItemId = GetItemId( aDragPosPixel );
+
+ if( pDocSh && nItemId )
+ {
+ XFillAttrSetItem aXFillSetItem( &pDocSh->GetPool() );
+ SfxItemSet& rSet = aXFillSetItem.GetItemSet();
+
+ rSet.Put( XFillColorItem( GetItemText( nItemId ), GetItemColor( nItemId ) ) );
+ rSet.Put(XFillStyleItem( ( 1 == nItemId ) ? XFILL_NONE : XFILL_SOLID ) );
+
+ EndSelection();
+ ( new SvxColorValueSetData( aXFillSetItem ) )->StartDrag( this, DND_ACTION_COPY );
+ ReleaseMouse();
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+IMPL_STATIC_LINK(SvxColorValueSet, ExecDragHdl, void*, EMPTYARG)
+{
+ // Als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch die
+ // Farbleiste geloescht werden darf
+ pThis->DoDrag();
+ return(0);
+}
+
+/*************************************************************************
+|*
+|* Ableitung vom SfxChildWindow als "Behaelter" fuer Animator
+|*
+\************************************************************************/
+
+SvxColorChildWindow::SvxColorChildWindow( Window* _pParent,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( _pParent, nId )
+{
+ SvxColorDockingWindow* pWin = new SvxColorDockingWindow( pBindings, this,
+ _pParent, SVX_RES( RID_SVXCTRL_COLOR ) );
+ pWindow = pWin;
+
+ eChildAlignment = SFX_ALIGN_BOTTOM;
+
+ pWin->Initialize( pInfo );
+}
+
+
+
+/*************************************************************************
+|*
+|* Ctor: SvxColorDockingWindow
+|*
+\************************************************************************/
+
+SvxColorDockingWindow::SvxColorDockingWindow
+(
+ SfxBindings* _pBindings,
+ SfxChildWindow* pCW,
+ Window* _pParent,
+ const ResId& rResId
+) :
+
+ SfxDockingWindow( _pBindings, pCW, _pParent, rResId ),
+
+ pColorTable ( NULL ),
+ aColorSet ( this, ResId( 1, *rResId.GetResMgr() ) ),
+ nLeftSlot ( SID_ATTR_FILL_COLOR ),
+ nRightSlot ( SID_ATTR_LINE_COLOR ),
+ nCols ( 20 ),
+ nLines ( 1 ),
+ aColorSize ( 14, 14 )
+
+{
+ FreeResource();
+
+ aColorSet.SetStyle( aColorSet.GetStyle() | WB_ITEMBORDER );
+ aColorSet.SetSelectHdl( LINK( this, SvxColorDockingWindow, SelectHdl ) );
+
+ // Get the model from the view shell. Using SfxObjectShell::Current()
+ // is unreliable when called at the wrong times.
+ SfxObjectShell* pDocSh = NULL;
+ if (_pBindings != NULL)
+ {
+ SfxDispatcher* pDispatcher = _pBindings->GetDispatcher();
+ if (pDispatcher != NULL)
+ {
+ SfxViewFrame* pFrame = pDispatcher->GetFrame();
+ if (pFrame != NULL)
+ {
+ SfxViewShell* pViewShell = pFrame->GetViewShell();
+ if (pViewShell != NULL)
+ pDocSh = pViewShell->GetObjectShell();
+ }
+ }
+ }
+
+ if ( pDocSh )
+ {
+ const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
+ if( pItem )
+ {
+ pColorTable = ( (SvxColorTableItem*) pItem )->GetColorTable();
+ FillValueSet();
+ }
+ }
+ aItemSize = aColorSet.CalcItemSizePixel( aColorSize );
+ aItemSize.Width() = aItemSize.Width() + aColorSize.Width();
+ aItemSize.Width() /= 2;
+ aItemSize.Height() = aItemSize.Height() + aColorSize.Height();
+ aItemSize.Height() /= 2;
+
+ SetSize();
+ aColorSet.Show();
+ StartListening( *_pBindings, TRUE );
+}
+
+
+/*************************************************************************
+|*
+|* Dtor: SvxColorDockingWindow
+|*
+\************************************************************************/
+
+SvxColorDockingWindow::~SvxColorDockingWindow()
+{
+ EndListening( GetBindings() );
+}
+
+/*************************************************************************
+|*
+|* Notify
+|*
+\************************************************************************/
+
+void SvxColorDockingWindow::Notify( SfxBroadcaster& , const SfxHint& rHint )
+{
+ const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint);
+ if ( pPoolItemHint
+ && ( pPoolItemHint->GetObject()->ISA( SvxColorTableItem ) ) )
+ {
+ // Die Liste der Farben hat sich geaendert
+ pColorTable = ( (SvxColorTableItem*) pPoolItemHint->GetObject() )->GetColorTable();
+ FillValueSet();
+ }
+}
+
+/*************************************************************************
+|*
+|* FillValueSet
+|*
+\************************************************************************/
+
+void SvxColorDockingWindow::FillValueSet()
+{
+ if( pColorTable )
+ {
+ aColorSet.Clear();
+
+ // Erster Eintrag: unsichtbar
+ long nPtX = aColorSize.Width() - 1;
+ long nPtY = aColorSize.Height() - 1;
+ VirtualDevice aVD;
+ aVD.SetOutputSizePixel( aColorSize );
+ aVD.SetLineColor( Color( COL_BLACK ) );
+ aVD.SetBackground( Wallpaper( Color( COL_WHITE ) ) );
+ aVD.DrawLine( Point(), Point( nPtX, nPtY ) );
+ aVD.DrawLine( Point( 0, nPtY ), Point( nPtX, 0 ) );
+
+ Bitmap aBmp( aVD.GetBitmap( Point(), aColorSize ) );
+
+ aColorSet.InsertItem( (USHORT)1, Image(aBmp), SVX_RESSTR( RID_SVXSTR_INVISIBLE ) );
+
+ XColorEntry* pEntry;
+ nCount = pColorTable->Count();
+
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pColorTable->GetColor( i );
+ aColorSet.InsertItem( (USHORT)i+2,
+ pEntry->GetColor(), pEntry->GetName() );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* SetSize
+|*
+\************************************************************************/
+
+void SvxColorDockingWindow::SetSize()
+{
+ // Groesse fuer ValueSet berechnen
+ Size aSize = GetOutputSizePixel();
+ aSize.Width() -= 4;
+ aSize.Height() -= 4;
+
+ // Zeilen und Spalten berechnen
+ nCols = (USHORT) ( aSize.Width() / aItemSize.Width() );
+ nLines = (USHORT) ( (float) aSize.Height() / (float) aItemSize.Height() /*+ 0.35*/ );
+ if( nLines == 0 )
+ nLines++;
+
+ // Scrollbar setzen/entfernen
+ WinBits nBits = aColorSet.GetStyle();
+ if ( nLines * nCols >= nCount )
+ nBits &= ~WB_VSCROLL;
+ else
+ nBits |= WB_VSCROLL;
+ aColorSet.SetStyle( nBits );
+
+ // ScrollBar ?
+ long nScrollWidth = aColorSet.GetScrollWidth();
+ if( nScrollWidth > 0 )
+ {
+ // Spalten mit ScrollBar berechnen
+ nCols = (USHORT) ( ( aSize.Width() - nScrollWidth ) / aItemSize.Width() );
+ }
+ aColorSet.SetColCount( nCols );
+
+ if( IsFloatingMode() )
+ aColorSet.SetLineCount( nLines );
+ else
+ {
+ aColorSet.SetLineCount( 0 ); // sonst wird LineHeight ignoriert
+ aColorSet.SetItemHeight( aItemSize.Height() );
+ }
+
+ aColorSet.SetPosSizePixel( Point( 2, 2 ), aSize );
+}
+
+/*************************************************************************
+|*
+|* SvxColorDockingWindow: Close
+|*
+\************************************************************************/
+
+BOOL SvxColorDockingWindow::Close()
+{
+ SfxBoolItem aItem( SID_COLOR_CONTROL, FALSE );
+ GetBindings().GetDispatcher()->Execute(
+ SID_COLOR_CONTROL, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+ SfxDockingWindow::Close();
+ return( TRUE );
+}
+
+/*************************************************************************
+|*
+|* SelectHdl
+|*
+\************************************************************************/
+
+IMPL_LINK( SvxColorDockingWindow, SelectHdl, void *, EMPTYARG )
+{
+ SfxDispatcher* pDispatcher = GetBindings().GetDispatcher();
+ USHORT nPos = aColorSet.GetSelectItemId();
+ Color aColor( aColorSet.GetItemColor( nPos ) );
+ String aStr( aColorSet.GetItemText( nPos ) );
+
+ if (aColorSet.IsLeftButton())
+ {
+ if ( nLeftSlot == SID_ATTR_FILL_COLOR )
+ {
+ if ( nPos == 1 ) // unsichtbar
+ {
+ XFillStyleItem aXFillStyleItem( XFILL_NONE );
+ pDispatcher->Execute( nLeftSlot, SFX_CALLMODE_RECORD, &aXFillStyleItem, 0L );
+ }
+ else
+ {
+ BOOL bDone = FALSE;
+
+ // Wenn wir eine DrawView haben und uns im TextEdit-Modus befinden,
+ // wird nicht die Flaechen-, sondern die Textfarbe zugewiesen
+ SfxViewShell* pViewSh = SfxViewShell::Current();
+ if ( pViewSh )
+ {
+ SdrView* pView = pViewSh->GetDrawView();
+ if ( pView && pView->IsTextEdit() )
+ {
+ SvxColorItem aTextColorItem( aColor, SID_ATTR_CHAR_COLOR );
+ pDispatcher->Execute(
+ SID_ATTR_CHAR_COLOR, SFX_CALLMODE_RECORD, &aTextColorItem, 0L );
+ bDone = TRUE;
+ }
+ }
+ if ( !bDone )
+ {
+ XFillStyleItem aXFillStyleItem( XFILL_SOLID );
+ XFillColorItem aXFillColorItem( aStr, aColor );
+ pDispatcher->Execute(
+ nLeftSlot, SFX_CALLMODE_RECORD, &aXFillColorItem, &aXFillStyleItem, 0L );
+ }
+ }
+ }
+ else if ( nPos != 1 ) // unsichtbar
+ {
+ SvxColorItem aLeftColorItem( aColor, nLeftSlot );
+ pDispatcher->Execute( nLeftSlot, SFX_CALLMODE_RECORD, &aLeftColorItem, 0L );
+ }
+ }
+ else
+ {
+ if ( nRightSlot == SID_ATTR_LINE_COLOR )
+ {
+ if( nPos == 1 ) // unsichtbar
+ {
+ XLineStyleItem aXLineStyleItem( XLINE_NONE );
+ pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineStyleItem, 0L );
+ }
+ else
+ {
+ // Sollte der LineStyle unsichtbar sein, so wird er auf SOLID gesetzt
+ SfxViewShell* pViewSh = SfxViewShell::Current();
+ if ( pViewSh )
+ {
+ SdrView* pView = pViewSh->GetDrawView();
+ if ( pView )
+ {
+ SfxItemSet aAttrSet( pView->GetModel()->GetItemPool() );
+ pView->GetAttributes( aAttrSet );
+ if ( aAttrSet.GetItemState( XATTR_LINESTYLE ) != SFX_ITEM_DONTCARE )
+ {
+ XLineStyle eXLS = (XLineStyle)
+ ( (const XLineStyleItem&)aAttrSet.Get( XATTR_LINESTYLE ) ).GetValue();
+ if ( eXLS == XLINE_NONE )
+ {
+ XLineStyleItem aXLineStyleItem( XLINE_SOLID );
+ pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineStyleItem, 0L );
+ }
+ }
+ }
+ }
+
+ XLineColorItem aXLineColorItem( aStr, aColor );
+ pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aXLineColorItem, 0L );
+ }
+ }
+ else if ( nPos != 1 ) // unsichtbar
+ {
+ SvxColorItem aRightColorItem( aColor, nRightSlot );
+ pDispatcher->Execute( nRightSlot, SFX_CALLMODE_RECORD, &aRightColorItem, 0L );
+ }
+ }
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Resizing
+|*
+\************************************************************************/
+
+
+void SvxColorDockingWindow::Resizing( Size& rNewSize )
+{
+ rNewSize.Width() -= 4;
+ rNewSize.Height() -= 4;
+
+ // Spalten und Reihen ermitteln
+ nCols = (USHORT) ( (float) rNewSize.Width() / (float) aItemSize.Width() + 0.5 );
+ nLines = (USHORT) ( (float) rNewSize.Height() / (float) aItemSize.Height() + 0.5 );
+ if( nLines == 0 )
+ nLines = 1;
+
+ // Scrollbar setzen/entfernen
+ WinBits nBits = aColorSet.GetStyle();
+ if ( nLines * nCols >= nCount )
+ nBits &= ~WB_VSCROLL;
+ else
+ nBits |= WB_VSCROLL;
+ aColorSet.SetStyle( nBits );
+
+ // ScrollBar ?
+ long nScrollWidth = aColorSet.GetScrollWidth();
+ if( nScrollWidth > 0 )
+ {
+ // Spalten mit ScrollBar berechnen
+ nCols = (USHORT) ( ( ( (float) rNewSize.Width() - (float) nScrollWidth ) )
+ / (float) aItemSize.Width() + 0.5 );
+ }
+ if( nCols <= 1 )
+ nCols = 2;
+
+ // Max. Reihen anhand der gegebenen Spalten berechnen
+ long nMaxLines = nCount / nCols;
+ if( nCount % nCols )
+ nMaxLines++;
+
+ nLines = sal::static_int_cast< USHORT >(
+ std::min< long >( nLines, nMaxLines ) );
+
+ // Groesse des Windows setzen
+ rNewSize.Width() = nCols * aItemSize.Width() + nScrollWidth + 4;
+ rNewSize.Height() = nLines * aItemSize.Height() + 4;
+}
+
+/*************************************************************************
+|*
+|* Resize
+|*
+\************************************************************************/
+
+void SvxColorDockingWindow::Resize()
+{
+ if ( !IsFloatingMode() || !GetFloatingWindow()->IsRollUp() )
+ SetSize();
+ SfxDockingWindow::Resize();
+}
+
+
+
+void SvxColorDockingWindow::GetFocus (void)
+{
+ SfxDockingWindow::GetFocus();
+ // Grab the focus to the color value set so that it can be controlled
+ // with the keyboard.
+ aColorSet.GrabFocus();
+}
+
+long SvxColorDockingWindow::Notify( NotifyEvent& rNEvt )
+{
+ long nRet = 0;
+ if( ( rNEvt.GetType() == EVENT_KEYINPUT ) )
+ {
+ KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
+ USHORT nKeyCode = aKeyEvt.GetKeyCode().GetCode();
+ switch( nKeyCode )
+ {
+ case KEY_ESCAPE:
+ GrabFocusToDocument();
+ nRet = 1;
+ break;
+ }
+ }
+
+ return nRet ? nRet : SfxDockingWindow::Notify( rNEvt );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/colrctrl.src b/svx/source/tbxctrls/colrctrl.src
new file mode 100644
index 000000000000..151261ee159f
--- /dev/null
+++ b/svx/source/tbxctrls/colrctrl.src
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+#include "helpid.hrc"
+ // pragma ----------------------------------------------------------------
+
+ // RID_SVXCTRL_COLOR -----------------------------------------------------
+DockingWindow RID_SVXCTRL_COLOR
+{
+ HelpID = HID_CTRL_COLOR ;
+ Border = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Sizeable = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ Dockable = TRUE ;
+ EnableResizing = TRUE ;
+ Size = MAP_APPFONT ( 150 , 22 ) ;
+ Text [ en-US ] = "Colors" ;
+ Control 1
+ {
+ HelpId = HID_COLOR_CTL_COLORS ;
+ Pos = MAP_APPFONT ( 2 , 2 ) ;
+ Size = MAP_APPFONT ( 146 , 18 ) ;
+ Border = FALSE ;
+ };
+};
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx b/svx/source/tbxctrls/extrusioncontrols.cxx
new file mode 100644
index 000000000000..72958e2cc0e3
--- /dev/null
+++ b/svx/source/tbxctrls/extrusioncontrols.cxx
@@ -0,0 +1,1051 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/awt/MenuItemStyle.hpp>
+#include <com/sun/star/awt/XPopupMenuExtended.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+
+#include <osl/mutex.hxx>
+
+#include <vcl/toolbox.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <svl/eitem.hxx>
+#include <vcl/settings.hxx>
+#include <svl/intitem.hxx>
+#include <editeng/colritem.hxx>
+#include <tools/urlobj.hxx>
+
+#include <svx/dialogs.hrc>
+#include <svx/svdtrans.hxx>
+#include <svx/sdasitm.hxx>
+#include <svx/dialmgr.hxx>
+#include "svx/extrusioncolorcontrol.hxx"
+
+#include "helpid.hrc"
+#include "extrusioncontrols.hxx"
+#include "extrusioncontrols.hrc"
+#include "colorwindow.hxx"
+#include "extrusiondepthdialog.hxx"
+
+////////////
+
+using ::rtl::OUString;
+using ::svtools::ToolbarMenu;
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::graphic;
+
+namespace svx
+{
+
+/*************************************************************************
+|*
+|* ExtrusionDirectionWindow
+|*
+\************************************************************************/
+
+static sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
+
+ExtrusionDirectionWindow::ExtrusionDirectionWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow )
+: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_DIRECTION ))
+, mrController( rController )
+, maImgPerspective( SVX_RES( IMG_PERSPECTIVE ) )
+, maImgPerspectiveH( SVX_RES( IMG_PERSPECTIVE_H ) )
+, maImgParallel( SVX_RES( IMG_PARALLEL ) )
+, maImgParallelH( SVX_RES( IMG_PARALLEL_H ) )
+, msExtrusionDirection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirection" ) )
+, msExtrusionProjection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionProjection" ) )
+{
+ SetHelpId( HID_MENU_EXTRUSION_DIRECTION );
+
+ USHORT i;
+ for( i = DIRECTION_NW; i <= DIRECTION_SE; i++ )
+ {
+ maImgDirection[i] = Image( SVX_RES( IMG_DIRECTION + i ) );
+ maImgDirectionH[i] = Image( SVX_RES( IMG_DIRECTION_H + i ) );
+ }
+
+ SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectHdl ) );
+ mpDirectionSet = createEmptyValueSetControl();
+ mpDirectionSet->SetHelpId( HID_VALUESET_EXTRUSION_DIRECTION );
+
+ mpDirectionSet->SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectHdl ) );
+ mpDirectionSet->SetColCount( 3 );
+ mpDirectionSet->EnableFullItemMode( FALSE );
+
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ for( i = DIRECTION_NW; i <= DIRECTION_SE; i++ )
+ {
+ String aText( SVX_RES( STR_DIRECTION + i ) );
+ mpDirectionSet->InsertItem( i+1, bHighContrast ? maImgDirectionH[ i ] : maImgDirection[ i ], aText );
+ }
+
+ mpDirectionSet->SetOutputSizePixel( Size( 72, 72 ) );
+
+ appendEntry( 2, mpDirectionSet );
+ appendSeparator();
+ appendEntry( 0, String( SVX_RES( STR_PERSPECTIVE ) ), bHighContrast ? maImgPerspectiveH : maImgPerspective );
+ appendEntry( 1, String( SVX_RES( STR_PARALLEL ) ), bHighContrast ? maImgParallelH : maImgParallel );
+
+ SetOutputSizePixel( getMenuSize() );
+
+ FreeResource();
+
+ AddStatusListener( msExtrusionDirection );
+ AddStatusListener( msExtrusionProjection );
+}
+
+void ExtrusionDirectionWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ ToolbarMenu::DataChanged( rDCEvt );
+
+ if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ {
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ for( USHORT i = DIRECTION_NW; i <= DIRECTION_SE; i++ )
+ {
+ mpDirectionSet->SetItemImage( i+1, bHighContrast ? maImgDirectionH[ i ] : maImgDirection[ i ] );
+ }
+
+ setEntryImage( 0, bHighContrast ? maImgPerspectiveH : maImgPerspective );
+ setEntryImage( 1, bHighContrast ? maImgParallelH : maImgParallel );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled )
+{
+ if( mpDirectionSet )
+ {
+ USHORT nItemId;
+ for( nItemId = DIRECTION_NW; nItemId <= DIRECTION_SE; nItemId++ )
+ {
+ if( gSkewList[nItemId] == nSkew )
+ break;
+ }
+
+ if( nItemId <= DIRECTION_SE )
+ {
+ mpDirectionSet->SelectItem( nItemId+1 );
+ }
+ else
+ {
+ mpDirectionSet->SetNoSelection();
+ }
+ }
+ enableEntry( 2, bEnabled );
+}
+
+// -----------------------------------------------------------------------
+
+void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bEnabled )
+{
+ checkEntry( 0, (nProjection == 0) && bEnabled );
+ checkEntry( 1, (nProjection == 1 ) && bEnabled );
+ enableEntry( 0, bEnabled );
+ enableEntry( 1, bEnabled );
+}
+
+// -----------------------------------------------------------------------
+
+void SAL_CALL ExtrusionDirectionWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
+{
+ if( Event.FeatureURL.Main.equals( msExtrusionDirection ) )
+ {
+ if( !Event.IsEnabled )
+ {
+ implSetDirection( -1, false );
+ }
+ else
+ {
+ sal_Int32 nValue = 0;
+ if( Event.State >>= nValue )
+ implSetDirection( nValue, true );
+ }
+ }
+ else if( Event.FeatureURL.Main.equals( msExtrusionProjection ) )
+ {
+ if( !Event.IsEnabled )
+ {
+ implSetProjection( -1, false );
+ }
+ else
+ {
+ sal_Int32 nValue = 0;
+ if( Event.State >>= nValue )
+ implSetProjection( nValue, true );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ExtrusionDirectionWindow, SelectHdl, void *, pControl )
+{
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ if( pControl == mpDirectionSet )
+ {
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = msExtrusionDirection.copy(5);
+ aArgs[0].Value <<= (sal_Int32)gSkewList[mpDirectionSet->GetSelectItemId()-1];
+
+ mrController.dispatchCommand( msExtrusionDirection, aArgs );
+ }
+ else
+ {
+ int nProjection = getSelectedEntryId();
+ if( (nProjection >= 0) && (nProjection < 2 ) )
+ {
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = msExtrusionProjection.copy(5);
+ aArgs[0].Value <<= (sal_Int32)nProjection;
+
+ mrController.dispatchCommand( msExtrusionProjection, aArgs );
+ implSetProjection( nProjection, true );
+ }
+ }
+
+ return 0;
+}
+
+// =======================================================================
+// ExtrusionDirectionControl
+// =======================================================================
+
+ExtrusionDirectionControl::ExtrusionDirectionControl( const Reference< lang::XMultiServiceFactory >& rServiceManager )
+: svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirectionFloater" ) ) )
+{
+}
+
+// -----------------------------------------------------------------------
+
+::Window* ExtrusionDirectionControl::createPopupWindow( ::Window* pParent )
+{
+ return new ExtrusionDirectionWindow( *this, m_xFrame, pParent );
+}
+
+// -----------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------
+
+OUString SAL_CALL ExtrusionDirectionControl_getImplementationName()
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionDirectionController" ));
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ExtrusionDirectionControl_getSupportedServiceNames() throw( RuntimeException )
+{
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
+ return aSNS;
+}
+
+// --------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL SAL_CALL ExtrusionDirectionControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
+{
+ return *new ExtrusionDirectionControl( rSMgr );
+}
+
+// --------------------------------------------------------------------
+
+OUString SAL_CALL ExtrusionDirectionControl::getImplementationName( ) throw (RuntimeException)
+{
+ return ExtrusionDirectionControl_getImplementationName();
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ExtrusionDirectionControl::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ return ExtrusionDirectionControl_getSupportedServiceNames();
+}
+
+// ####################################################################
+
+ExtrusionDepthDialog::ExtrusionDepthDialog( Window* pParent, double fDepth, FieldUnit eDefaultUnit )
+: ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_EXTRUSION_DEPTH ) ),
+ maFLDepth( this, SVX_RES( FL_DEPTH ) ),
+ maMtrDepth( this, SVX_RES( MTR_DEPTH ) ),
+ maOKButton( this, SVX_RES( BTN_OK ) ),
+ maCancelButton( this, SVX_RES( BTN_CANCEL ) ),
+ maHelpButton( this, SVX_RES( BTN_HELP ) )
+{
+ bool bMetric = IsMetric( eDefaultUnit );
+ maMtrDepth.SetUnit( bMetric ? FUNIT_CM : FUNIT_INCH );
+ maMtrDepth.SetValue( (int) fDepth * 100, FUNIT_100TH_MM );
+
+ FreeResource();
+}
+
+ExtrusionDepthDialog::~ExtrusionDepthDialog()
+{
+}
+
+double ExtrusionDepthDialog::getDepth() const
+{
+// bool bMetric = IsMetric( meDefaultUnit );
+ return (double)( maMtrDepth.GetValue( FUNIT_100TH_MM ) ) / 100.0;
+}
+
+// ####################################################################
+
+double aDepthListInch[] = { 0, 1270,2540,5080,10160 };
+double aDepthListMM[] = { 0, 1000, 2500, 5000, 10000 };
+
+ExtrusionDepthWindow::ExtrusionDepthWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow )
+: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_DEPTH ))
+, mrController( rController )
+, maImgDepth0( SVX_RES( IMG_DEPTH_0 ) )
+, maImgDepth1( SVX_RES( IMG_DEPTH_1 ) )
+, maImgDepth2( SVX_RES( IMG_DEPTH_2 ) )
+, maImgDepth3( SVX_RES( IMG_DEPTH_3 ) )
+, maImgDepth4( SVX_RES( IMG_DEPTH_4 ) )
+, maImgDepthInfinity( SVX_RES( IMG_DEPTH_INFINITY ) )
+, maImgDepth0h( SVX_RES( IMG_DEPTH_0_H ) )
+, maImgDepth1h( SVX_RES( IMG_DEPTH_1_H ) )
+, maImgDepth2h( SVX_RES( IMG_DEPTH_2_H ) )
+, maImgDepth3h( SVX_RES( IMG_DEPTH_3_H ) )
+, maImgDepth4h( SVX_RES( IMG_DEPTH_4_H ) )
+, maImgDepthInfinityh( SVX_RES( IMG_DEPTH_INFINITY_H ) )
+, mfDepth( -1.0 )
+, msExtrusionDepth( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepth" ) )
+, msMetricUnit( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" ) )
+{
+ SetHelpId( HID_MENU_EXTRUSION_DEPTH );
+
+ SetSelectHdl( LINK( this, ExtrusionDepthWindow, SelectHdl ) );
+
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ String aEmpty;
+ appendEntry( 0, aEmpty, bHighContrast ? maImgDepth0h : maImgDepth0 );
+ appendEntry( 1, aEmpty, bHighContrast ? maImgDepth1h : maImgDepth1 );
+ appendEntry( 2, aEmpty, bHighContrast ? maImgDepth2h : maImgDepth2 );
+ appendEntry( 3, aEmpty, bHighContrast ? maImgDepth3h : maImgDepth3 );
+ appendEntry( 4, aEmpty, bHighContrast ? maImgDepth4h : maImgDepth4 );
+ appendEntry( 5, String( SVX_RES( STR_INFINITY ) ), bHighContrast ? maImgDepthInfinityh : maImgDepthInfinity );
+ appendEntry( 6, String( SVX_RES( STR_CUSTOM ) ) );
+
+ SetOutputSizePixel( getMenuSize() );
+
+ FreeResource();
+
+ AddStatusListener( msExtrusionDepth );
+ AddStatusListener( msMetricUnit );
+}
+
+// -----------------------------------------------------------------------
+
+void ExtrusionDepthWindow::implSetDepth( double fDepth )
+{
+ mfDepth = fDepth;
+ int i;
+ for( i = 0; i < 7; i++ )
+ {
+ if( i == 5 )
+ {
+ checkEntry( i, fDepth >= 338666 );
+ }
+ else if( i != 6 )
+ {
+ checkEntry( i, (fDepth == (IsMetric( meUnit ) ? aDepthListMM[i] : aDepthListInch[i]) ) );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ExtrusionDepthWindow::implFillStrings( FieldUnit eUnit )
+{
+ meUnit = eUnit;
+ USHORT nResource = IsMetric( eUnit ) ? RID_SVXSTR_DEPTH_0 : RID_SVXSTR_DEPTH_0_INCH;
+
+ for( int i = 0; i < 5; i++ )
+ {
+ String aStr( SVX_RES( nResource + i ) );
+ setEntryText( i, aStr );
+ };
+}
+
+// -----------------------------------------------------------------------
+
+void SAL_CALL ExtrusionDepthWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
+{
+ if( Event.FeatureURL.Main.equals( msExtrusionDepth ) )
+ {
+ if( !Event.IsEnabled )
+ {
+ implSetDepth( 0 );
+ }
+ else
+ {
+ double fValue = 0.0;
+ if( Event.State >>= fValue )
+ implSetDepth( fValue );
+ }
+ }
+ else if( Event.FeatureURL.Main.equals( msMetricUnit ) )
+ {
+ if( Event.IsEnabled )
+ {
+ sal_Int32 nValue = 0;
+ if( Event.State >>= nValue )
+ {
+ implFillStrings( static_cast<FieldUnit>(nValue) );
+ if( mfDepth >= 0.0 )
+ implSetDepth( mfDepth );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ExtrusionDepthWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ ToolbarMenu::DataChanged( rDCEvt );
+
+ if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ {
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ setEntryImage( 0, bHighContrast ? maImgDepth0h : maImgDepth0 );
+ setEntryImage( 1, bHighContrast ? maImgDepth1h : maImgDepth1 );
+ setEntryImage( 2, bHighContrast ? maImgDepth2h : maImgDepth2 );
+ setEntryImage( 3, bHighContrast ? maImgDepth3h : maImgDepth3 );
+ setEntryImage( 4, bHighContrast ? maImgDepth4h : maImgDepth4 );
+ setEntryImage( 5, bHighContrast ? maImgDepthInfinityh : maImgDepthInfinity );
+ }
+}
+
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ExtrusionDepthWindow, SelectHdl, void *, EMPTYARG )
+{
+ int nSelected = getSelectedEntryId();
+ if( nSelected != -1 )
+ {
+ if( nSelected == 6 )
+ {
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ const rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepthDialog" ));
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 2 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Depth" ));
+ aArgs[0].Value <<= mfDepth;
+ aArgs[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ));
+ aArgs[1].Value <<= static_cast<sal_Int32>( meUnit );
+
+ mrController.dispatchCommand( aCommand, aArgs );
+ }
+ else
+ {
+ double fDepth;
+
+ if( nSelected == 5 )
+ {
+ fDepth = 338666.6;
+ }
+ else
+ {
+ fDepth = IsMetric( meUnit ) ? aDepthListMM[nSelected] : aDepthListInch[nSelected];
+ }
+
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = msExtrusionDepth.copy(5);
+ aArgs[0].Value <<= fDepth;
+
+ mrController.dispatchCommand( msExtrusionDepth, aArgs );
+ implSetDepth( fDepth );
+
+ if ( IsInPopupMode() )
+ EndPopupMode();
+ }
+ }
+ return 0;
+}
+
+// =======================================================================
+// ExtrusionDirectionControl
+// =======================================================================
+
+ExtrusionDepthController::ExtrusionDepthController( const Reference< lang::XMultiServiceFactory >& rServiceManager )
+: svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDepthFloater" ) ) )
+{
+}
+
+// -----------------------------------------------------------------------
+
+::Window* ExtrusionDepthController::createPopupWindow( ::Window* pParent )
+{
+ return new ExtrusionDepthWindow( *this, m_xFrame, pParent );
+}
+
+
+// -----------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------
+
+OUString SAL_CALL ExtrusionDepthController_getImplementationName()
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionDepthController" ));
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ExtrusionDepthController_getSupportedServiceNames() throw( RuntimeException )
+{
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.PopupMenuController" ));
+ return aSNS;
+}
+
+// --------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL SAL_CALL ExtrusionDepthController_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
+{
+ return *new ExtrusionDepthController( rSMgr );
+}
+
+// --------------------------------------------------------------------
+
+OUString SAL_CALL ExtrusionDepthController::getImplementationName( ) throw (RuntimeException)
+{
+ return ExtrusionDepthController_getImplementationName();
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ExtrusionDepthController::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ return ExtrusionDepthController_getSupportedServiceNames();
+}
+
+
+// ####################################################################
+
+// -------------------------------------------------------------------------
+
+ExtrusionLightingWindow::ExtrusionLightingWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow )
+: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_LIGHTING ))
+, mrController( rController )
+, maImgBright( SVX_RES( IMG_LIGHTING_BRIGHT ) )
+, maImgNormal( SVX_RES( IMG_LIGHTING_NORMAL ) )
+, maImgDim( SVX_RES( IMG_LIGHTING_DIM ) )
+, maImgBrighth( SVX_RES( IMG_LIGHTING_BRIGHT_H ) )
+, maImgNormalh( SVX_RES( IMG_LIGHTING_NORMAL_H ) )
+, maImgDimh( SVX_RES( IMG_LIGHTING_DIM_H ) )
+, mnLevel( 0 )
+, mbLevelEnabled( false )
+, mnDirection( FROM_FRONT )
+, mbDirectionEnabled( false )
+, msExtrusionLightingDirection( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingDirection" ))
+, msExtrusionLightingIntensity( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionLightingIntensity" ))
+{
+ USHORT i;
+ for( i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; i++ )
+ {
+ if( i != FROM_FRONT )
+ {
+ maImgLightingOff[i] = Image( SVX_RES( IMG_LIGHT_OFF + i ) );
+ maImgLightingOn[i] = Image( SVX_RES( IMG_LIGHT_ON + i ) );
+ maImgLightingOffh[i] = Image( SVX_RES( IMG_LIGHT_OFF_H + i ) );
+ maImgLightingOnh[i] = Image( SVX_RES( IMG_LIGHT_ON_H + i ) );
+ }
+ maImgLightingPreview[i] = Image( SVX_RES( IMG_LIGHT_PREVIEW + i ) );
+ maImgLightingPreviewh[i] = Image( SVX_RES( IMG_LIGHT_PREVIEW_H + i ) );
+ }
+
+ SetHelpId( HID_MENU_EXTRUSION_LIGHTING );
+ SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectHdl ) );
+
+ mpLightingSet = createEmptyValueSetControl();
+ mpLightingSet->SetHelpId( HID_VALUESET_EXTRUSION_LIGHTING );
+
+ mpLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectHdl ) );
+ mpLightingSet->SetColCount( 3 );
+ mpLightingSet->EnableFullItemMode( FALSE );
+
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ for( i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; i++ )
+ {
+ if( i != FROM_FRONT )
+ {
+ mpLightingSet->InsertItem( i+1, bHighContrast ? maImgLightingOffh[i] : maImgLightingOff[i] );
+ }
+ else
+ {
+ mpLightingSet->InsertItem( 5, bHighContrast ? maImgLightingPreviewh[FROM_FRONT] : maImgLightingPreview[FROM_FRONT] );
+ }
+ }
+ mpLightingSet->SetOutputSizePixel( Size( 72, 72 ) );
+
+ appendEntry( 3, mpLightingSet );
+ appendSeparator();
+ appendEntry( 0, String( SVX_RES( STR_BRIGHT ) ), bHighContrast ? maImgBrighth : maImgBright );
+ appendEntry( 1, String( SVX_RES( STR_NORMAL ) ), bHighContrast ? maImgNormalh : maImgNormal );
+ appendEntry( 2, String( SVX_RES( STR_DIM ) ), bHighContrast ? maImgDimh : maImgDim );
+
+ SetOutputSizePixel( getMenuSize() );
+
+ FreeResource();
+
+ AddStatusListener( msExtrusionLightingDirection );
+ AddStatusListener( msExtrusionLightingIntensity );
+}
+
+// -----------------------------------------------------------------------
+
+void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled )
+{
+ mnLevel = nLevel;
+ mbLevelEnabled = bEnabled;
+ int i = 0;
+ for( i = 0; i < 3; i++ )
+ {
+ checkEntry( i, (i == nLevel) && bEnabled );
+ enableEntry( i, bEnabled );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled )
+{
+ mnDirection = nDirection;
+ mbDirectionEnabled = bEnabled;
+
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ if( !bEnabled )
+ nDirection = FROM_FRONT;
+
+ USHORT nItemId;
+ for( nItemId = FROM_TOP_LEFT; nItemId <= FROM_BOTTOM_RIGHT; nItemId++ )
+ {
+ if( nItemId == FROM_FRONT )
+ {
+ mpLightingSet->SetItemImage( nItemId + 1, bHighContrast ? maImgLightingPreviewh[ nDirection ] : maImgLightingPreview[ nDirection ] );
+ }
+ else
+ {
+ if( bHighContrast )
+ {
+ mpLightingSet->SetItemImage( nItemId + 1, (USHORT)nDirection == nItemId ? maImgLightingOnh[nItemId] : maImgLightingOffh[nItemId] );
+ }
+ else
+ {
+ mpLightingSet->SetItemImage( nItemId + 1, (USHORT)nDirection == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId] );
+ }
+ }
+ }
+
+ enableEntry( 3, bEnabled );
+}
+
+// -----------------------------------------------------------------------
+
+void SAL_CALL ExtrusionLightingWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
+{
+ if( Event.FeatureURL.Main.equals( msExtrusionLightingIntensity ) )
+ {
+ if( !Event.IsEnabled )
+ {
+ implSetIntensity( 0, false );
+ }
+ else
+ {
+ sal_Int32 nValue = 0;
+ if( Event.State >>= nValue )
+ implSetIntensity( nValue, true );
+ }
+ }
+ else if( Event.FeatureURL.Main.equals( msExtrusionLightingDirection ) )
+ {
+ if( !Event.IsEnabled )
+ {
+ implSetDirection( 0, false );
+ }
+ else
+ {
+ sal_Int32 nValue = 0;
+ if( Event.State >>= nValue )
+ implSetDirection( nValue, true );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ExtrusionLightingWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ ToolbarMenu::DataChanged( rDCEvt );
+
+ if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ {
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ implSetDirection( mnDirection, mbDirectionEnabled );
+ setEntryImage( 0, bHighContrast ? maImgBrighth : maImgBright );
+ setEntryImage( 1, bHighContrast ? maImgNormalh : maImgNormal );
+ setEntryImage( 2, bHighContrast ? maImgDimh : maImgDim );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ExtrusionLightingWindow, SelectHdl, void *, pControl )
+{
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ if( pControl == this )
+ {
+ int nLevel = getSelectedEntryId();
+ if( nLevel >= 0 )
+ {
+ if( nLevel != 3 )
+ {
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = msExtrusionLightingIntensity.copy(5);
+ aArgs[0].Value <<= (sal_Int32)nLevel;
+
+ mrController.dispatchCommand( msExtrusionLightingIntensity, aArgs );
+
+ implSetIntensity( nLevel, true );
+ }
+ }
+ }
+ else
+ {
+ sal_Int32 nDirection = mpLightingSet->GetSelectItemId();
+
+ if( (nDirection > 0) && (nDirection < 10) )
+ {
+ nDirection--;
+
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = msExtrusionLightingDirection.copy(5);
+ aArgs[0].Value <<= (sal_Int32)nDirection;
+
+ mrController.dispatchCommand( msExtrusionLightingDirection, aArgs );
+
+ implSetDirection( nDirection, true );
+ }
+
+ }
+
+ return 0;
+}
+
+// ========================================================================
+
+ExtrusionLightingControl::ExtrusionLightingControl( const Reference< lang::XMultiServiceFactory >& rServiceManager )
+: svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionDirectionFloater" ) ) )
+{
+}
+
+// -----------------------------------------------------------------------
+
+::Window* ExtrusionLightingControl::createPopupWindow( ::Window* pParent )
+{
+ return new ExtrusionLightingWindow( *this, m_xFrame, pParent );
+}
+
+// -----------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------
+
+OUString SAL_CALL ExtrusionLightingControl_getImplementationName()
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionLightingController" ));
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ExtrusionLightingControl_getSupportedServiceNames() throw( RuntimeException )
+{
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
+ return aSNS;
+}
+
+// --------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL SAL_CALL ExtrusionLightingControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
+{
+ return *new ExtrusionLightingControl( rSMgr );
+}
+
+// --------------------------------------------------------------------
+
+OUString SAL_CALL ExtrusionLightingControl::getImplementationName( ) throw (RuntimeException)
+{
+ return ExtrusionLightingControl_getImplementationName();
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ExtrusionLightingControl::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ return ExtrusionLightingControl_getSupportedServiceNames();
+}
+
+// ####################################################################
+
+ExtrusionSurfaceWindow::ExtrusionSurfaceWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow )
+: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_EXTRUSION_SURFACE ))
+, mrController( rController )
+, maImgSurface1( SVX_RES( IMG_WIRE_FRAME ) )
+, maImgSurface2( SVX_RES( IMG_MATTE ) )
+, maImgSurface3( SVX_RES( IMG_PLASTIC ) )
+, maImgSurface4( SVX_RES( IMG_METAL ) )
+, maImgSurface1h( SVX_RES( IMG_WIRE_FRAME_H ) )
+, maImgSurface2h( SVX_RES( IMG_MATTE_H ) )
+, maImgSurface3h( SVX_RES( IMG_PLASTIC_H ) )
+, maImgSurface4h( SVX_RES( IMG_METAL_H ) )
+, msExtrusionSurface( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurface" ))
+{
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ SetHelpId( HID_MENU_EXTRUSION_SURFACE );
+ SetSelectHdl( LINK( this, ExtrusionSurfaceWindow, SelectHdl ) );
+
+ appendEntry( 0, String( SVX_RES( STR_WIREFRAME ) ), bHighContrast ? maImgSurface1h : maImgSurface1 );
+ appendEntry( 1, String( SVX_RES( STR_MATTE ) ), bHighContrast ? maImgSurface2h : maImgSurface2 );
+ appendEntry( 2, String( SVX_RES( STR_PLASTIC ) ), bHighContrast ? maImgSurface3h : maImgSurface3 );
+ appendEntry( 3, String( SVX_RES( STR_METAL ) ), bHighContrast ? maImgSurface4h : maImgSurface4 );
+
+ SetOutputSizePixel( getMenuSize() );
+
+ FreeResource();
+
+ AddStatusListener( msExtrusionSurface );
+}
+
+// -----------------------------------------------------------------------
+
+void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled )
+{
+// if( mpMenu )
+ {
+ int i;
+ for( i = 0; i < 4; i++ )
+ {
+ checkEntry( i, (i == nSurface) && bEnabled );
+ enableEntry( i, bEnabled );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SAL_CALL ExtrusionSurfaceWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
+{
+ if( Event.FeatureURL.Main.equals( msExtrusionSurface ) )
+ {
+ if( !Event.IsEnabled )
+ {
+ implSetSurface( 0, false );
+ }
+ else
+ {
+ sal_Int32 nValue = 0;
+ if( Event.State >>= nValue )
+ implSetSurface( nValue, true );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ExtrusionSurfaceWindow, SelectHdl, void *, EMPTYARG )
+{
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ sal_Int32 nSurface = getSelectedEntryId();
+ if( nSurface >= 0 )
+ {
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = msExtrusionSurface.copy(5);
+ aArgs[0].Value <<= (sal_Int32)nSurface;
+
+ mrController.dispatchCommand( msExtrusionSurface, aArgs );
+
+ implSetSurface( nSurface, true );
+ }
+
+ return 0;
+}
+
+// ========================================================================
+
+ExtrusionSurfaceControl::ExtrusionSurfaceControl( const Reference< lang::XMultiServiceFactory >& rServiceManager )
+: svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ExtrusionSurfaceFloater" ) ) )
+{
+}
+
+// -----------------------------------------------------------------------
+
+::Window* ExtrusionSurfaceControl::createPopupWindow( ::Window* pParent )
+{
+ return new ExtrusionSurfaceWindow( *this, m_xFrame, pParent );
+}
+
+// -----------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------
+
+OUString SAL_CALL ExtrusionSurfaceControl_getImplementationName()
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.ExtrusionSurfaceController" ));
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ExtrusionSurfaceControl_getSupportedServiceNames() throw( RuntimeException )
+{
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
+ return aSNS;
+}
+
+// --------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL SAL_CALL ExtrusionSurfaceControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
+{
+ return *new ExtrusionSurfaceControl( rSMgr );
+}
+
+// --------------------------------------------------------------------
+
+OUString SAL_CALL ExtrusionSurfaceControl::getImplementationName( ) throw (RuntimeException)
+{
+ return ExtrusionSurfaceControl_getImplementationName();
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL ExtrusionSurfaceControl::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ return ExtrusionSurfaceControl_getSupportedServiceNames();
+}
+
+//========================================================================
+
+SFX_IMPL_TOOLBOX_CONTROL( ExtrusionColorControl, SvxColorItem );
+
+ExtrusionColorControl::ExtrusionColorControl(
+ USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+: SfxToolBoxControl ( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+ mpBtnUpdater = new ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW );
+}
+
+// -----------------------------------------------------------------------
+
+ExtrusionColorControl::~ExtrusionColorControl()
+{
+ delete mpBtnUpdater;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType ExtrusionColorControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* ExtrusionColorControl::CreatePopupWindow()
+{
+ SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Extrusion3DColor" )),
+ SID_EXTRUSION_3D_COLOR,
+ m_xFrame,
+ SVX_RESSTR( RID_SVXSTR_EXTRUSION_COLOR ),
+ &GetToolBox() );
+ pColorWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
+ pColorWin->StartSelection();
+ SetPopupWindow( pColorWin );
+ return pColorWin;
+}
+
+// -----------------------------------------------------------------------
+
+void ExtrusionColorControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+
+ if( nSID == SID_EXTRUSION_3D_COLOR )
+ {
+ const SvxColorItem* pItem = 0;
+
+ if( SFX_ITEM_DONTCARE != eState )
+ pItem = PTR_CAST( SvxColorItem, pState );
+
+ if ( pItem )
+ mpBtnUpdater->Update( pItem->GetValue());
+ }
+
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+ rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/extrusioncontrols.hrc b/svx/source/tbxctrls/extrusioncontrols.hrc
new file mode 100644
index 000000000000..c406d5c683a7
--- /dev/null
+++ b/svx/source/tbxctrls/extrusioncontrols.hrc
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <svx/dialogs.hrc>
+
+// enum to index light images
+#define FROM_TOP_LEFT 0
+#define FROM_TOP 1
+#define FROM_TOP_RIGHT 2
+#define FROM_LEFT 3
+#define FROM_FRONT 4
+#define FROM_RIGHT 5
+#define FROM_BOTTOM_LEFT 6
+#define FROM_BOTTOM 7
+#define FROM_BOTTOM_RIGHT 8
+
+#define DIRECTION_NW 0
+#define DIRECTION_N 1
+#define DIRECTION_NE 2
+#define DIRECTION_W 3
+#define DIRECTION_NONE 4
+#define DIRECTION_E 5
+#define DIRECTION_SW 6
+#define DIRECTION_S 7
+#define DIRECTION_SE 8
+
+#define STR_PERSPECTIVE 1
+#define STR_PARALLEL 2
+#define STR_CUSTOM 3
+#define STR_INFINITY 4
+
+#define STR_BRIGHT 15
+#define STR_NORMAL 16
+#define STR_DIM 17
+
+#define STR_WIREFRAME 18
+#define STR_MATTE 19
+#define STR_PLASTIC 20
+#define STR_METAL 21
+
+#define STR_DIRECTION 30 // needs 10 resource ids
+
+#define IMG_DIRECTION 1 // needs 10 resource ids
+#define IMG_DIRECTION_H 10 // needs 10 resource ids
+
+#define IMG_DEPTH_0 19
+#define IMG_DEPTH_1 20
+#define IMG_DEPTH_2 21
+#define IMG_DEPTH_3 22
+#define IMG_DEPTH_4 23
+#define IMG_DEPTH_INFINITY 24
+
+#define IMG_DEPTH_0_H 25
+#define IMG_DEPTH_1_H 26
+#define IMG_DEPTH_2_H 27
+#define IMG_DEPTH_3_H 28
+#define IMG_DEPTH_4_H 29
+#define IMG_DEPTH_INFINITY_H 30
+
+#define IMG_PERSPECTIVE 31
+#define IMG_PERSPECTIVE_H 32
+#define IMG_PARALLEL 33
+#define IMG_PARALLEL_H 34
+
+#define IMG_WIRE_FRAME 35
+#define IMG_MATTE 36
+#define IMG_PLASTIC 37
+#define IMG_METAL 38
+
+#define IMG_WIRE_FRAME_H 39
+#define IMG_MATTE_H 40
+#define IMG_PLASTIC_H 41
+#define IMG_METAL_H 42
+
+#define IMG_LIGHT_OFF 50 // needs 10 resource ids
+#define IMG_LIGHT_ON 60 // needs 10 resource ids
+#define IMG_LIGHT_PREVIEW 70 // needs 10 resource ids
+
+#define IMG_LIGHT_OFF_H 80 // needs 10 resource ids
+#define IMG_LIGHT_ON_H 90 // needs 10 resource ids
+#define IMG_LIGHT_PREVIEW_H 100 // needs 10 resource ids
+
+#define IMG_LIGHTING_BRIGHT 110
+#define IMG_LIGHTING_NORMAL 111
+#define IMG_LIGHTING_DIM 112
+
+#define IMG_LIGHTING_BRIGHT_H 113
+#define IMG_LIGHTING_NORMAL_H 114
+#define IMG_LIGHTING_DIM_H 115
+
+#define FL_DEPTH 1
+#define MTR_DEPTH 2
+#define BTN_OK 3
+#define BTN_CANCEL 4
+#define BTN_HELP 5
+
+//
diff --git a/svx/source/tbxctrls/extrusioncontrols.hxx b/svx/source/tbxctrls/extrusioncontrols.hxx
new file mode 100644
index 000000000000..3fcf2bd693e5
--- /dev/null
+++ b/svx/source/tbxctrls/extrusioncontrols.hxx
@@ -0,0 +1,262 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_EXTRUSION_CONTROLS_HXX
+#define _SVX_EXTRUSION_CONTROLS_HXX
+
+#include "svx/svxdllapi.h"
+
+#include <svtools/valueset.hxx>
+#include <svtools/svtreebx.hxx>
+#include <vcl/button.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+
+#include <svtools/toolbarmenu.hxx>
+#include <svtools/popupwindowcontroller.hxx>
+#include <svtools/popupmenucontrollerbase.hxx>
+
+class SfxBindings;
+class SfxStatusForwarder;
+
+//========================================================================
+
+namespace svx
+{
+class ToolboxButtonColorUpdater;
+
+class ExtrusionDirectionWindow : public svtools::ToolbarMenu
+{
+public:
+ ExtrusionDirectionWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow );
+
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+private:
+ svt::ToolboxController& mrController;
+ ValueSet* mpDirectionSet;
+
+ Image maImgDirection[9];
+ Image maImgDirectionH[9];
+
+ Image maImgPerspective;
+ Image maImgPerspectiveH;
+ Image maImgParallel;
+ Image maImgParallelH;
+
+ const rtl::OUString msExtrusionDirection;
+ const rtl::OUString msExtrusionProjection;
+
+ DECL_LINK( SelectHdl, void * );
+ void FillValueSet();
+
+ void implSetDirection( sal_Int32 nSkew, bool bEnabled = true );
+ void implSetProjection( sal_Int32 nProjection, bool bEnabled = true );
+
+};
+
+//========================================================================
+
+class ExtrusionDirectionControl : public svt::PopupWindowController
+{
+public:
+ ExtrusionDirectionControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
+
+ virtual ::Window* createPopupWindow( ::Window* pParent );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ using svt::PopupWindowController::createPopupWindow;
+};
+
+//========================================================================
+
+class ExtrusionDepthWindow : public svtools::ToolbarMenu
+{
+private:
+ svt::ToolboxController& mrController;
+
+ Image maImgDepth0;
+ Image maImgDepth1;
+ Image maImgDepth2;
+ Image maImgDepth3;
+ Image maImgDepth4;
+ Image maImgDepthInfinity;
+
+ Image maImgDepth0h;
+ Image maImgDepth1h;
+ Image maImgDepth2h;
+ Image maImgDepth3h;
+ Image maImgDepth4h;
+ Image maImgDepthInfinityh;
+
+ FieldUnit meUnit;
+ double mfDepth;
+
+ const rtl::OUString msExtrusionDepth;
+ const rtl::OUString msMetricUnit;
+
+ DECL_LINK( SelectHdl, void * );
+
+ void implFillStrings( FieldUnit eUnit );
+ void implSetDepth( double fDepth );
+
+public:
+ ExtrusionDepthWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow );
+
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+};
+
+//========================================================================
+
+class ExtrusionDepthController : public svt::PopupWindowController
+{
+public:
+ ExtrusionDepthController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
+
+ virtual ::Window* createPopupWindow( ::Window* pParent );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ using svt::PopupWindowController::createPopupWindow;
+};
+
+//========================================================================
+
+class ExtrusionLightingWindow : public svtools::ToolbarMenu
+{
+private:
+ svt::ToolboxController& mrController;
+ ValueSet* mpLightingSet;
+
+ Image maImgLightingOff[9];
+ Image maImgLightingOn[9];
+ Image maImgLightingPreview[9];
+
+ Image maImgLightingOffh[9];
+ Image maImgLightingOnh[9];
+ Image maImgLightingPreviewh[9];
+
+ Image maImgBright;
+ Image maImgNormal;
+ Image maImgDim;
+ Image maImgBrighth;
+ Image maImgNormalh;
+ Image maImgDimh;
+
+ int mnLevel;
+ bool mbLevelEnabled;
+ int mnDirection;
+ bool mbDirectionEnabled;
+
+ const rtl::OUString msExtrusionLightingDirection;
+ const rtl::OUString msExtrusionLightingIntensity;
+
+ void implSetIntensity( int nLevel, bool bEnabled );
+ void implSetDirection( int nDirection, bool bEnabled );
+
+ DECL_LINK( SelectHdl, void * );
+public:
+ ExtrusionLightingWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow );
+
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+};
+
+//========================================================================
+
+class ExtrusionLightingControl : public svt::PopupWindowController
+{
+public:
+ ExtrusionLightingControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
+
+ virtual ::Window* createPopupWindow( ::Window* pParent );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ using svt::PopupWindowController::createPopupWindow;
+};
+
+//========================================================================
+
+class ExtrusionSurfaceWindow : public svtools::ToolbarMenu
+{
+private:
+ svt::ToolboxController& mrController;
+
+ Image maImgSurface1;
+ Image maImgSurface2;
+ Image maImgSurface3;
+ Image maImgSurface4;
+ Image maImgSurface1h;
+ Image maImgSurface2h;
+ Image maImgSurface3h;
+ Image maImgSurface4h;
+
+ const rtl::OUString msExtrusionSurface;
+
+ DECL_LINK( SelectHdl, void * );
+
+ void implSetSurface( int nSurface, bool bEnabled );
+
+public:
+ ExtrusionSurfaceWindow( svt::ToolboxController& rController, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, Window* pParentWindow );
+
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
+};
+
+//========================================================================
+
+class ExtrusionSurfaceControl : public svt::PopupWindowController
+{
+public:
+ ExtrusionSurfaceControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
+
+ virtual ::Window* createPopupWindow( ::Window* pParent );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ using svt::PopupWindowController::createPopupWindow;
+};
+
+//========================================================================
+
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/extrusioncontrols.src b/svx/source/tbxctrls/extrusioncontrols.src
new file mode 100644
index 000000000000..826234889050
--- /dev/null
+++ b/svx/source/tbxctrls/extrusioncontrols.src
@@ -0,0 +1,796 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+#include "extrusioncontrols.hrc"
+
+#define MASKCOLOR MaskColor = Color { Red=0xFFFF; Green=0x0000; Blue=0xFFFF; };
+
+DockingWindow RID_SVXFLOAT_EXTRUSION_DIRECTION
+{
+ Border = FALSE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Sizeable = FALSE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+
+ Text [ en-US ] = "Extrusion Direction" ;
+
+ Image IMG_DIRECTION + DIRECTION_NW
+ {
+ ImageBitmap = Bitmap { File = "directionnorthwest_22.bmp" ; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION_H + DIRECTION_NW
+ {
+ ImageBitmap = Bitmap { File = "directionnorthwest_22_h.bmp" ; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION + DIRECTION_N
+ {
+ ImageBitmap = Bitmap { File = "directionnorth_22.bmp" ; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION_H + DIRECTION_N
+ {
+ ImageBitmap = Bitmap { File = "directionnorth_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION + DIRECTION_NE
+ {
+ ImageBitmap = Bitmap { File = "directionnortheast_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION_H + DIRECTION_NE
+ {
+ ImageBitmap = Bitmap { File = "directionnortheast_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION + DIRECTION_W
+ {
+ ImageBitmap = Bitmap { File = "directionwest_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION_H + DIRECTION_W
+ {
+ ImageBitmap = Bitmap { File = "directionwest_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION + DIRECTION_NONE
+ {
+ ImageBitmap = Bitmap { File = "directionstraight_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION_H + DIRECTION_NONE
+ {
+ ImageBitmap = Bitmap { File = "directionstraight_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION + DIRECTION_E
+ {
+ ImageBitmap = Bitmap { File = "directioneast_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION_H + DIRECTION_E
+ {
+ ImageBitmap = Bitmap { File = "directioneast_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION + DIRECTION_SW
+ {
+ ImageBitmap = Bitmap { File = "directionsouthwest_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION_H + DIRECTION_SW
+ {
+ ImageBitmap = Bitmap { File = "directionsouthwest_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION + DIRECTION_S
+ {
+ ImageBitmap = Bitmap { File = "directionsouth_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION_H + DIRECTION_S
+ {
+ ImageBitmap = Bitmap { File = "directionsouth_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION + DIRECTION_SE
+ {
+ ImageBitmap = Bitmap { File = "directionsoutheast_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DIRECTION_H + DIRECTION_SE
+ {
+ ImageBitmap = Bitmap { File = "directionsoutheast_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_PERSPECTIVE
+ {
+ ImageBitmap = Bitmap { File = "perspective_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_PERSPECTIVE_H
+ {
+ ImageBitmap = Bitmap { File = "perspective_16_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_PARALLEL
+ {
+ ImageBitmap = Bitmap { File = "parallel_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_PARALLEL_H
+ {
+ ImageBitmap = Bitmap { File = "parallel_16_h.bmp"; };
+ MASKCOLOR
+ };
+
+ String STR_PERSPECTIVE
+ {
+ Text [ en-US ] = "~Perspective" ;
+ };
+
+ String STR_PARALLEL
+ {
+ Text [ en-US ] = "P~arallel" ;
+ };
+ String STR_DIRECTION + DIRECTION_NW
+ {
+ Text [ en-US ] = "Extrusion North-West";
+ };
+ String STR_DIRECTION + DIRECTION_N
+ {
+ Text [ en-US ] = "Extrusion North";
+ };
+ String STR_DIRECTION + DIRECTION_NE
+ {
+ Text [ en-US ] = "Extrusion North-East";
+ };
+ String STR_DIRECTION + DIRECTION_W
+ {
+ Text [ en-US ] = "Extrusion West";
+ };
+ String STR_DIRECTION + DIRECTION_NONE
+ {
+ Text [ en-US ] = "Extrusion Backwards";
+ };
+ String STR_DIRECTION + DIRECTION_E
+ {
+ Text [ en-US ] = "Extrusion East";
+ };
+ String STR_DIRECTION + DIRECTION_SW
+ {
+ Text [ en-US ] = "Extrusion South-West";
+ };
+ String STR_DIRECTION + DIRECTION_S
+ {
+ Text [ en-US ] = "Extrusion South";
+ };
+ String STR_DIRECTION + DIRECTION_SE
+ {
+ Text [ en-US ] = "Extrusion South-East";
+ };
+};
+
+DockingWindow RID_SVXFLOAT_EXTRUSION_DEPTH
+{
+ Border = FALSE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Sizeable = FALSE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+
+ Text [ en-US ] = "Extrusion Depth" ;
+
+ String STR_CUSTOM
+ {
+ Text [ en-US ] = "~Custom...";
+ };
+
+ String STR_INFINITY
+ {
+ Text [ en-US ] = "~Infinity";
+ };
+
+ Image IMG_DEPTH_0
+ {
+ ImageBitmap = Bitmap { File = "extrusion0inch_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DEPTH_0_H
+ {
+ ImageBitmap = Bitmap { File = "extrusion0inch_16_h.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_DEPTH_1
+ {
+ ImageBitmap = Bitmap { File = "extrusion05inch_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DEPTH_1_H
+ {
+ ImageBitmap = Bitmap { File = "extrusion05inch_16_h.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_DEPTH_2
+ {
+ ImageBitmap = Bitmap { File = "extrusion1inch_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DEPTH_2_H
+ {
+ ImageBitmap = Bitmap { File = "extrusion1inch_16_h.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_DEPTH_3
+ {
+ ImageBitmap = Bitmap { File = "extrusion2inch_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DEPTH_3_H
+ {
+ ImageBitmap = Bitmap { File = "extrusion2inch_16_h.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_DEPTH_4
+ {
+ ImageBitmap = Bitmap { File = "extrusion4inch_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DEPTH_4_H
+ {
+ ImageBitmap = Bitmap { File = "extrusion4inch_16_h.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_DEPTH_INFINITY
+ {
+ ImageBitmap = Bitmap { File = "extrusioninfinity_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_DEPTH_INFINITY_H
+ {
+ ImageBitmap = Bitmap { File = "extrusioninfinity_16_h.bmp"; };
+ MASKCOLOR
+ };
+};
+
+
+DockingWindow RID_SVXFLOAT_EXTRUSION_LIGHTING
+{
+ Border = FALSE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Sizeable = FALSE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+
+ Text [ en-US ] = "Extrusion Lighting" ;
+
+ Image IMG_LIGHT_OFF + FROM_TOP_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightofffromtopleft_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF + FROM_TOP
+ {
+ ImageBitmap = Bitmap { File = "lightofffromtop_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF + FROM_TOP_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightofffromtopright_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF + FROM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightofffromleft_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF + FROM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightofffromright_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF + FROM_BOTTOM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightofffrombottomleft_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF + FROM_BOTTOM
+ {
+ ImageBitmap = Bitmap { File = "lightofffrombottom_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF + FROM_BOTTOM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightofffrombottomright_22.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_LIGHT_OFF_H + FROM_TOP_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightofffromtopleft_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF_H + FROM_TOP
+ {
+ ImageBitmap = Bitmap { File = "lightofffromtop_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF_H + FROM_TOP_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightofffromtopright_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF_H + FROM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightofffromleft_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF_H + FROM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightofffromright_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF_H + FROM_BOTTOM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightofffrombottomleft_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF_H + FROM_BOTTOM
+ {
+ ImageBitmap = Bitmap { File = "lightofffrombottom_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_OFF_H + FROM_BOTTOM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightofffrombottomright_22_h.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_LIGHT_ON + FROM_TOP_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightonfromtopleft_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON + FROM_TOP
+ {
+ ImageBitmap = Bitmap { File = "lightonfromtop_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON + FROM_TOP_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightonfromtopright_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON + FROM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightonfromleft_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON + FROM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightonfromright_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON + FROM_BOTTOM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightonfrombottomleft_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON + FROM_BOTTOM
+ {
+ ImageBitmap = Bitmap { File = "lightonfrombottom_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON + FROM_BOTTOM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightonfrombottomright_22.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_LIGHT_ON_H + FROM_TOP_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightonfromtopleft_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON_H + FROM_TOP
+ {
+ ImageBitmap = Bitmap { File = "lightonfromtop_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON_H + FROM_TOP_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightonfromtopright_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON_H + FROM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightonfromleft_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON_H + FROM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightonfromright_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON_H + FROM_BOTTOM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightonfrombottomleft_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON_H + FROM_BOTTOM
+ {
+ ImageBitmap = Bitmap { File = "lightonfrombottom_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_ON_H + FROM_BOTTOM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightonfrombottomright_22_h.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_LIGHT_PREVIEW + FROM_TOP_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightfromtopleft_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW + FROM_TOP
+ {
+ ImageBitmap = Bitmap { File = "lightfromtop_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW + FROM_TOP_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightfromtopright_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW + FROM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightfromleft_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW + FROM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightfromright_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW + FROM_FRONT
+ {
+ ImageBitmap = Bitmap { File = "lightfromfront_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW + FROM_BOTTOM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightfrombottomleft_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW + FROM_BOTTOM
+ {
+ ImageBitmap = Bitmap { File = "lightfrombottom_22.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW + FROM_BOTTOM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightfrombottomright_22.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_LIGHT_PREVIEW_H + FROM_TOP_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightfromtopleft_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW_H + FROM_TOP
+ {
+ ImageBitmap = Bitmap { File = "lightfromtop_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW_H + FROM_TOP_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightfromtopright_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW_H + FROM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightfromleft_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW_H + FROM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightfromright_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW_H + FROM_FRONT
+ {
+ ImageBitmap = Bitmap { File = "lightfromfront_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW_H + FROM_BOTTOM_LEFT
+ {
+ ImageBitmap = Bitmap { File = "lightfrombottomleft_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW_H + FROM_BOTTOM
+ {
+ ImageBitmap = Bitmap { File = "lightfrombottom_22_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHT_PREVIEW_H + FROM_BOTTOM_RIGHT
+ {
+ ImageBitmap = Bitmap { File = "lightfrombottomright_22_h.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_LIGHTING_BRIGHT
+ {
+ ImageBitmap = Bitmap { File = "brightlit_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHTING_NORMAL
+ {
+ ImageBitmap = Bitmap { File = "normallit_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHTING_DIM
+ {
+ ImageBitmap = Bitmap { File = "dimlit_16.bmp"; };
+ MASKCOLOR
+ };
+
+ Image IMG_LIGHTING_BRIGHT_H
+ {
+ ImageBitmap = Bitmap { File = "brightlit_16_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHTING_NORMAL_H
+ {
+ ImageBitmap = Bitmap { File = "normallit_16_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_LIGHTING_DIM_H
+ {
+ ImageBitmap = Bitmap { File = "dimlit_16_h.bmp"; };
+ MASKCOLOR
+ };
+
+ String STR_BRIGHT
+ {
+ Text [ en-US ] = "~Bright";
+ };
+
+ String STR_NORMAL
+ {
+ Text [ en-US ] = "~Normal";
+ };
+
+ String STR_DIM
+ {
+ Text [ en-US ] = "~Dim";
+ };
+};
+
+DockingWindow RID_SVXFLOAT_EXTRUSION_SURFACE
+{
+ Border = FALSE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Sizeable = FALSE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+
+ Text [ en-US ] = "Extrusion Surface" ;
+
+ String STR_WIREFRAME
+ {
+ Text [ en-US ] = "~Wire Frame";
+ };
+
+ String STR_MATTE
+ {
+ Text [ en-US ] = "~Matt";
+ };
+
+ String STR_PLASTIC
+ {
+ Text [ en-US ] = "~Plastic";
+ };
+
+ String STR_METAL
+ {
+ Text [ en-US ] = "Me~tal";
+ };
+
+ Image IMG_WIRE_FRAME
+ {
+ ImageBitmap = Bitmap { File = "wireframe_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_WIRE_FRAME_H
+ {
+ ImageBitmap = Bitmap { File = "wireframe_16_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_MATTE
+ {
+ ImageBitmap = Bitmap { File = "matte_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_MATTE_H
+ {
+ ImageBitmap = Bitmap { File = "matte_16_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_PLASTIC
+ {
+ ImageBitmap = Bitmap { File = "plastic_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_PLASTIC_H
+ {
+ ImageBitmap = Bitmap { File = "plastic_16_h.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_METAL
+ {
+ ImageBitmap = Bitmap { File = "metal_16.bmp"; };
+ MASKCOLOR
+ };
+ Image IMG_METAL_H
+ {
+ ImageBitmap = Bitmap { File = "metal_16_h.bmp"; };
+ MASKCOLOR
+ };
+
+};
+
+#define WIDTH 140
+#define HEIGHT (4 * 3 + 3 * 14)
+
+ModalDialog RID_SVX_MDLG_EXTRUSION_DEPTH
+{
+ OutputSize = TRUE;
+ SVLook = TRUE ;
+ Moveable = TRUE;
+ Closeable = TRUE;
+
+ Size = MAP_APPFONT( WIDTH, HEIGHT );
+
+ Text [ en-US ] = "Extrusion Depth" ;
+
+ FixedText FL_DEPTH
+ {
+ Pos = MAP_APPFONT ( 3 , 3 ) ;
+ Size = MAP_APPFONT ( WIDTH - 50 - 12 , 8 ) ;
+ Text [ en-US ] = "~Value" ;
+ };
+ MetricField MTR_DEPTH
+ {
+ //HelpId = HID_SD_CTL_FAVORITES ;
+ Border = FALSE ;
+ Pos = MAP_APPFONT ( 3 , 14 ) ;
+ Size = MAP_APPFONT ( WIDTH - 50 - 12, 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Minimum = 0 ;
+ Maximum = 338666 ;
+ StrictFormat = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_MM ;
+ SpinSize = 10 ;
+ };
+ OkButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( WIDTH - 50 - 3 , 1 * 3 + 0 * 14 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ DefButton = TRUE ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( WIDTH - 50 - 3 , 2 * 3 + 1 * 14 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( WIDTH - 50 - 3 , 3 * 3 + 2 * 14 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ TabStop = TRUE ;
+ };
+};
+
+String RID_SVXSTR_EXTRUSION_COLOR
+{
+ Text [ en-US ] = "Extrusion Color";
+};
+
+String RID_SVXSTR_DEPTH_0
+{
+ Text [ en-US ] = "~0 cm";
+};
+
+String RID_SVXSTR_DEPTH_1
+{
+ Text [ en-US ] = "~1 cm";
+};
+
+String RID_SVXSTR_DEPTH_2
+{
+ Text [ en-US ] = "~2.5 cm";
+};
+
+String RID_SVXSTR_DEPTH_3
+{
+ Text [ en-US ] = "~5 cm";
+};
+
+String RID_SVXSTR_DEPTH_4
+{
+ Text [ en-US ] = "10 ~cm";
+};
+
+String RID_SVXSTR_DEPTH_0_INCH
+{
+ Text [ en-US ] = "0 inch";
+};
+
+String RID_SVXSTR_DEPTH_1_INCH
+{
+ Text [ en-US ] = "0.~5 inch";
+};
+
+String RID_SVXSTR_DEPTH_2_INCH
+{
+ Text [ en-US ] = "~1 inch";
+};
+
+String RID_SVXSTR_DEPTH_3_INCH
+{
+ Text [ en-US ] = "~2 inch";
+};
+
+String RID_SVXSTR_DEPTH_4_INCH
+{
+ Text [ en-US ] = "~4 inch";
+};
+
+
diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx
new file mode 100644
index 000000000000..45e2ff25e5a1
--- /dev/null
+++ b/svx/source/tbxctrls/fillctrl.cxx
@@ -0,0 +1,848 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewsh.hxx>
+#include <rtl/ustring.hxx>
+
+#include <svx/dialogs.hrc>
+
+#define DELAY_TIMEOUT 300
+
+#define TMP_STR_BEGIN '['
+#define TMP_STR_END ']'
+
+#include "drawitem.hxx"
+#include "xattr.hxx"
+#include <svx/xtable.hxx>
+#include <svx/fillctrl.hxx>
+#include <svx/itemwin.hxx>
+#include <svx/dialmgr.hxx>
+#include "helpid.hrc"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxFillToolBoxControl, XFillStyleItem );
+
+/*************************************************************************
+|*
+|* SvxFillToolBoxControl
+|*
+\************************************************************************/
+
+SvxFillToolBoxControl::SvxFillToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+
+ pStyleItem ( NULL ),
+ pColorItem ( NULL ),
+ pGradientItem ( NULL ),
+ pHatchItem ( NULL ),
+ pBitmapItem ( NULL ),
+ pFillControl ( NULL ),
+ pFillTypeLB ( NULL ),
+ pFillAttrLB ( NULL ),
+ bUpdate ( FALSE ),
+ bIgnoreStatusUpdate( FALSE ),
+ eLastXFS ( XFILL_NONE )
+{
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )));
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )));
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )));
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillBitmap" )));
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GradientListState" )));
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HatchListState" )));
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BitmapListState" )));
+}
+
+//========================================================================
+
+SvxFillToolBoxControl::~SvxFillToolBoxControl()
+{
+ delete pStyleItem;
+ delete pColorItem;
+ delete pGradientItem;
+ delete pHatchItem;
+ delete pBitmapItem;
+}
+
+//========================================================================
+
+void SvxFillToolBoxControl::StateChanged(
+
+ USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ bool bEnableControls = false;
+
+ if ( bIgnoreStatusUpdate )
+ return;
+
+ if( eState == SFX_ITEM_DISABLED )
+ {
+ if( nSID == SID_ATTR_FILL_STYLE )
+ {
+ pFillTypeLB->Disable();
+ pFillTypeLB->SetNoSelection();
+ }
+ pFillAttrLB->Disable();
+ pFillAttrLB->SetNoSelection();
+ }
+ else
+ {
+ if ( SFX_ITEM_AVAILABLE == eState )
+ {
+ if( nSID == SID_ATTR_FILL_STYLE )
+ {
+ delete pStyleItem;
+ pStyleItem = (XFillStyleItem*) pState->Clone();
+ pFillTypeLB->Enable();
+
+ eLastXFS = pFillTypeLB->GetSelectEntryPos();
+ bUpdate = TRUE;
+
+ XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
+ pFillTypeLB->SelectEntryPos(
+ sal::static_int_cast< USHORT >( eXFS ) );
+ pFillAttrLB->Enable();
+ }
+ else if( pStyleItem )
+ {
+ XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
+
+ if( nSID == SID_ATTR_FILL_COLOR )
+ {
+ delete pColorItem;
+ pColorItem = (XFillColorItem*) pState->Clone();
+
+ if( eXFS == XFILL_SOLID )
+ bEnableControls = true;
+ }
+ else if( nSID == SID_ATTR_FILL_GRADIENT )
+ {
+ delete pGradientItem;
+ pGradientItem = (XFillGradientItem*) pState->Clone();
+
+ if( eXFS == XFILL_GRADIENT )
+ bEnableControls = true;
+ }
+ else if( nSID == SID_ATTR_FILL_HATCH )
+ {
+ delete pHatchItem;
+ pHatchItem = (XFillHatchItem*) pState->Clone();
+
+ if( eXFS == XFILL_HATCH )
+ bEnableControls = true;
+ }
+ else if( nSID == SID_ATTR_FILL_BITMAP )
+ {
+ delete pBitmapItem;
+ pBitmapItem = (XFillBitmapItem*) pState->Clone();
+
+ if( eXFS == XFILL_BITMAP )
+ bEnableControls = true;
+ }
+ }
+ if( bEnableControls )
+ {
+ //pFillTypeLB->Enable();
+ pFillAttrLB->Enable();
+
+ bUpdate = TRUE;
+ }
+
+ Update( pState );
+ }
+ else
+ {
+ // leerer oder uneindeutiger Status
+ if( nSID == SID_ATTR_FILL_STYLE )
+ {
+ pFillTypeLB->SetNoSelection();
+ pFillAttrLB->Disable();
+ pFillAttrLB->SetNoSelection();
+ bUpdate = FALSE;
+ }
+ else
+ {
+ XFillStyle eXFS = XFILL_NONE;
+ if( pStyleItem )
+ eXFS = (XFillStyle)pStyleItem->GetValue();
+ if( !pStyleItem ||
+ ( nSID == SID_ATTR_FILL_COLOR && eXFS == XFILL_SOLID ) ||
+ ( nSID == SID_ATTR_FILL_GRADIENT && eXFS == XFILL_GRADIENT ) ||
+ ( nSID == SID_ATTR_FILL_HATCH && eXFS == XFILL_HATCH ) ||
+ ( nSID == SID_ATTR_FILL_BITMAP && eXFS == XFILL_BITMAP ) )
+ {
+ pFillAttrLB->SetNoSelection();
+ //bUpdate = FALSE;
+ }
+ }
+ }
+ }
+}
+
+//========================================================================
+
+void SvxFillToolBoxControl::IgnoreStatusUpdate( sal_Bool bSet )
+{
+ bIgnoreStatusUpdate = bSet;
+}
+
+//========================================================================
+
+void SvxFillToolBoxControl::Update( const SfxPoolItem* pState )
+{
+ if ( pStyleItem && pState && bUpdate )
+ {
+ bUpdate = FALSE;
+
+ XFillStyle eXFS = (XFillStyle)pStyleItem->GetValue();
+
+ // Pruefen, ob Fuellstil schon vorher aktiv war
+ //if( eTmpXFS != eXFS )
+ if( (XFillStyle) eLastXFS != eXFS )
+ pFillControl->SelectFillTypeHdl( NULL );
+ //eLastXFS = eXFS;
+
+ switch( eXFS )
+ {
+ case XFILL_NONE:
+ break;
+
+ case XFILL_SOLID:
+ {
+ if ( pColorItem )
+ {
+ String aString( pColorItem->GetName() );
+ ::Color aColor = pColorItem->GetColorValue();
+
+ pFillAttrLB->SelectEntry( aString );
+
+ if ( pFillAttrLB->GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND ||
+ pFillAttrLB->GetSelectEntryColor() != aColor )
+ pFillAttrLB->SelectEntry( aColor );
+
+ // NEU
+ // Pruefen, ob Eintrag nicht in der Liste ist
+ if( pFillAttrLB->GetSelectEntryPos() ==
+ LISTBOX_ENTRY_NOTFOUND ||
+ pFillAttrLB->GetSelectEntryColor() != aColor )
+ {
+ USHORT nCount = pFillAttrLB->GetEntryCount();
+ String aTmpStr;
+ if( nCount > 0 )
+ {
+ //Letzter Eintrag wird auf temporaere Farbe geprueft
+ aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
+ if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
+ aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
+ {
+ pFillAttrLB->RemoveEntry( nCount - 1 );
+ }
+ }
+ aTmpStr = TMP_STR_BEGIN;
+ aTmpStr += aString;
+ aTmpStr += TMP_STR_END;
+
+ //pFillAttrLB->SetUpdateMode( FALSE );
+ USHORT nPos = pFillAttrLB->InsertEntry( aColor, aTmpStr );
+ //pFillAttrLB->SetUpdateMode( TRUE );
+ pFillAttrLB->SelectEntryPos( nPos );
+ }
+ // NEU
+ }
+ else
+ pFillAttrLB->SetNoSelection();
+ }
+ break;
+
+ case XFILL_GRADIENT:
+ {
+ if ( pGradientItem )
+ {
+ String aString( pGradientItem->GetName() );
+ pFillAttrLB->SelectEntry( aString );
+ // NEU
+ // Pruefen, ob Eintrag nicht in der Liste ist
+ if( pFillAttrLB->GetSelectEntry() != aString )
+ {
+ USHORT nCount = pFillAttrLB->GetEntryCount();
+ String aTmpStr;
+ if( nCount > 0 )
+ {
+ //Letzter Eintrag wird auf temporaeren Eintrag geprueft
+ aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
+ if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
+ aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
+ {
+ pFillAttrLB->RemoveEntry( nCount - 1 );
+ }
+ }
+ aTmpStr = TMP_STR_BEGIN;
+ aTmpStr += aString;
+ aTmpStr += TMP_STR_END;
+
+ XGradientEntry* pEntry = new XGradientEntry( pGradientItem->GetGradientValue(), aTmpStr );
+ String aEmptyString = String();
+ XGradientList aGradientList( aEmptyString );
+ aGradientList.Insert( pEntry );
+ aGradientList.SetDirty( FALSE );
+ Bitmap* pBmp = aGradientList.CreateBitmapForUI( 0 );
+
+ if( pBmp )
+ {
+ ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp );
+ pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
+ delete pBmp;
+ }
+
+ aGradientList.Remove( 0 );
+ delete pEntry;
+ }
+ // NEU
+ }
+ else
+ pFillAttrLB->SetNoSelection();
+ }
+ break;
+
+ case XFILL_HATCH:
+ {
+ if ( pHatchItem )
+ {
+ String aString( pHatchItem->GetName() );
+ pFillAttrLB->SelectEntry( aString );
+ // NEU
+ // Pruefen, ob Eintrag nicht in der Liste ist
+ if( pFillAttrLB->GetSelectEntry() != aString )
+ {
+ USHORT nCount = pFillAttrLB->GetEntryCount();
+ String aTmpStr;
+ if( nCount > 0 )
+ {
+ //Letzter Eintrag wird auf temporaeren Eintrag geprueft
+ aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
+ if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
+ aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
+ {
+ pFillAttrLB->RemoveEntry( nCount - 1 );
+ }
+ }
+ aTmpStr = TMP_STR_BEGIN;
+ aTmpStr += aString;
+ aTmpStr += TMP_STR_END;
+
+ XHatchEntry* pEntry = new XHatchEntry( pHatchItem->GetHatchValue(), aTmpStr );
+ String aEmptyString = String();
+ XHatchList aHatchList( aEmptyString );
+ aHatchList.Insert( pEntry );
+ aHatchList.SetDirty( FALSE );
+ Bitmap* pBmp = aHatchList.CreateBitmapForUI( 0 );
+
+ if( pBmp )
+ {
+ ( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp );
+ pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
+ delete pBmp;
+ }
+
+ aHatchList.Remove( 0 );
+ delete pEntry;
+ }
+ // NEU
+ }
+ else
+ pFillAttrLB->SetNoSelection();
+ }
+ break;
+
+ case XFILL_BITMAP:
+ {
+ if ( pBitmapItem )
+ // &&
+ // SfxObjectShell::Current() &&
+ // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) )
+ {
+ String aString( pBitmapItem->GetName() );
+ // Bitmap aBitmap( pBitmapItem->GetValue() );
+
+ // SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
+ // SfxObjectShell::Current()->GetItem( SID_BITMAP_LIST ) ) );
+ pFillAttrLB->SelectEntry( aString );
+ // NEU
+ // Pruefen, ob Eintrag nicht in der Liste ist
+ if( pFillAttrLB->GetSelectEntry() != aString )
+ {
+ USHORT nCount = pFillAttrLB->GetEntryCount();
+ String aTmpStr;
+ if( nCount > 0 )
+ {
+ //Letzter Eintrag wird auf temporaeren Eintrag geprueft
+ aTmpStr = pFillAttrLB->GetEntry( nCount - 1 );
+ if( aTmpStr.GetChar(0) == TMP_STR_BEGIN &&
+ aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
+ {
+ pFillAttrLB->RemoveEntry( nCount - 1 );
+ }
+ }
+ aTmpStr = TMP_STR_BEGIN;
+ aTmpStr += aString;
+ aTmpStr += TMP_STR_END;
+
+ XBitmapEntry* pEntry = new XBitmapEntry( pBitmapItem->GetBitmapValue(), aTmpStr );
+ XBitmapList aBitmapList( String::CreateFromAscii("TmpList") );
+ aBitmapList.Insert( pEntry );
+ aBitmapList.SetDirty( FALSE );
+ //Bitmap* pBmp = aBitmapList.GetBitmap( 0 );
+ //( (ListBox*)pFillAttrLB )->InsertEntry( pEntry->GetName(), *pBmp );
+ pFillAttrLB->Fill( &aBitmapList );
+ pFillAttrLB->SelectEntryPos( pFillAttrLB->GetEntryCount() - 1 );
+ aBitmapList.Remove( 0 );
+ delete pEntry;
+ }
+ // NEU
+ }
+ else
+ pFillAttrLB->SetNoSelection();
+ }
+ break;
+
+ default:
+ DBG_ERROR( "Nicht unterstuetzter Flaechentyp" );
+ break;
+ }
+ }
+
+ if( pState && pStyleItem )
+ {
+ XFillStyle eXFS = (XFillStyle) pStyleItem->GetValue();
+
+ // Die Listen haben sich geaendert ?
+ if( pState->ISA( SvxColorTableItem ) &&
+ eXFS == XFILL_SOLID )
+ {
+ ::Color aTmpColor( pFillAttrLB->GetSelectEntryColor() );
+ pFillAttrLB->Clear();
+ pFillAttrLB->Fill( ( (SvxColorTableItem*)pState )->GetColorTable() );
+ pFillAttrLB->SelectEntry( aTmpColor );
+ }
+ if( pState->ISA( SvxGradientListItem ) &&
+ eXFS == XFILL_GRADIENT )
+ {
+ String aString( pFillAttrLB->GetSelectEntry() );
+ pFillAttrLB->Clear();
+ pFillAttrLB->Fill( ( (SvxGradientListItem*)pState )->GetGradientList() );
+ pFillAttrLB->SelectEntry( aString );
+ }
+ if( pState->ISA( SvxHatchListItem ) &&
+ eXFS == XFILL_HATCH )
+ {
+ String aString( pFillAttrLB->GetSelectEntry() );
+ pFillAttrLB->Clear();
+ pFillAttrLB->Fill( ( (SvxHatchListItem*)pState )->GetHatchList() );
+ pFillAttrLB->SelectEntry( aString );
+ }
+ if( pState->ISA( SvxBitmapListItem ) &&
+ eXFS == XFILL_BITMAP )
+ {
+ String aString( pFillAttrLB->GetSelectEntry() );
+ pFillAttrLB->Clear();
+ pFillAttrLB->Fill( ( (SvxBitmapListItem*)pState )->GetBitmapList() );
+ pFillAttrLB->SelectEntry( aString );
+ }
+ }
+}
+
+//========================================================================
+
+Window* SvxFillToolBoxControl::CreateItemWindow( Window *pParent )
+{
+ if ( GetSlotId() == SID_ATTR_FILL_STYLE )
+ {
+ pFillControl = new FillControl( pParent );
+ // Damit dem FillControl das SvxFillToolBoxControl bekannt ist
+ // (und um kompatibel zu bleiben)
+ pFillControl->SetData( this );
+
+ pFillAttrLB = (SvxFillAttrBox*)pFillControl->pLbFillAttr;
+ pFillTypeLB = (SvxFillTypeBox*)pFillControl->pLbFillType;
+
+ pFillAttrLB->SetUniqueId( HID_FILL_ATTR_LISTBOX );
+ pFillTypeLB->SetUniqueId( HID_FILL_TYPE_LISTBOX );
+
+ return pFillControl;
+ }
+ return NULL;
+}
+
+/*************************************************************************
+|*
+|* FillControl
+|*
+\************************************************************************/
+
+FillControl::FillControl( Window* pParent, WinBits nStyle ) :
+ Window( pParent, nStyle | WB_DIALOGCONTROL ),
+ pLbFillType(new SvxFillTypeBox( this )),
+ aLogicalFillSize(40,80),
+ aLogicalAttrSize(50,80)
+{
+ pLbFillAttr = new SvxFillAttrBox( this );
+ Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
+ Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
+ pLbFillType->SetSizePixel(aTypeSize);
+ pLbFillAttr->SetSizePixel(aAttrSize);
+ //to get the base height
+ aTypeSize = pLbFillType->GetSizePixel();
+ aAttrSize = pLbFillAttr->GetSizePixel();
+ Point aAttrPnt = pLbFillAttr->GetPosPixel();
+ SetSizePixel(
+ Size( aAttrPnt.X() + aAttrSize.Width(),
+ Max( aAttrSize.Height(), aTypeSize.Height() ) ) );
+
+ pLbFillType->SetSelectHdl( LINK( this, FillControl, SelectFillTypeHdl ) );
+ pLbFillAttr->SetSelectHdl( LINK( this, FillControl, SelectFillAttrHdl ) );
+
+ aDelayTimer.SetTimeout( DELAY_TIMEOUT );
+ aDelayTimer.SetTimeoutHdl( LINK( this, FillControl, DelayHdl ) );
+ aDelayTimer.Start();
+}
+
+//------------------------------------------------------------------------
+
+FillControl::~FillControl()
+{
+ delete pLbFillType;
+ delete pLbFillAttr;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( FillControl, DelayHdl, Timer *, EMPTYARG )
+{
+ SelectFillTypeHdl( NULL );
+ ( (SvxFillToolBoxControl*)GetData() )->updateStatus( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )));
+// ( (SvxFillToolBoxControl*)GetData() )->GetBindings().Invalidate( SID_ATTR_FILL_STYLE );
+ return 0;
+}
+IMPL_LINK_INLINE_END( FillControl, DelayHdl, Timer *, pTimer )
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( FillControl, SelectFillTypeHdl, ListBox *, pBox )
+{
+ XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
+
+ // Spaeter sollte eine Optimierung derart erfolgen, dass die
+ // Listen, bzw. Tables nur dann geloescht und wieder aufgebaut
+ // werden, wenn sich die Listen, bzw. Tables tatsaechlich geaendert
+ // haben (in den LBs natuerlich).
+
+ if ( ( pBox && !pBox->IsTravelSelect() ) || !pBox )
+ {
+ // Damit wir in folgendem Fall einen Status anzeigen koennen:
+ // Ein Typ wurde ausgewaehlt aber kein Attribut.
+ // Die Selektion hat genau die gleichen Attribute wie die vorherige.
+// SvxFillToolBoxControl* pControlerItem = (SvxFillToolBoxControl*)GetData();
+// if( pControlerItem )
+// pControlerItem->ClearCache();
+
+ pLbFillAttr->Clear();
+ SfxObjectShell* pSh = SfxObjectShell::Current();
+
+ switch( eXFS )
+ {
+ case XFILL_NONE:
+ {
+ pLbFillType->Selected();
+ SelectFillAttrHdl( pBox );
+ pLbFillAttr->Disable();
+ }
+ break;
+
+ case XFILL_SOLID:
+ {
+ if ( pSh && pSh->GetItem( SID_COLOR_TABLE ) )
+ {
+ SvxColorTableItem aItem( *(const SvxColorTableItem*)(
+ pSh->GetItem( SID_COLOR_TABLE ) ) );
+ pLbFillAttr->Enable();
+ pLbFillAttr->Fill( aItem.GetColorTable() );
+ }
+ else
+ pLbFillAttr->Disable();
+ }
+ break;
+
+ case XFILL_GRADIENT:
+ {
+ if ( pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
+ {
+ SvxGradientListItem aItem( *(const SvxGradientListItem*)(
+ pSh->GetItem( SID_GRADIENT_LIST ) ) );
+ pLbFillAttr->Enable();
+ pLbFillAttr->Fill( aItem.GetGradientList() );
+ }
+ else
+ pLbFillAttr->Disable();
+ }
+ break;
+
+ case XFILL_HATCH:
+ {
+ if ( pSh && pSh->GetItem( SID_HATCH_LIST ) )
+ {
+ SvxHatchListItem aItem( *(const SvxHatchListItem*)(
+ pSh->GetItem( SID_HATCH_LIST ) ) );
+ pLbFillAttr->Enable();
+ pLbFillAttr->Fill( aItem.GetHatchList() );
+ }
+ else
+ pLbFillAttr->Disable();
+ }
+ break;
+
+ case XFILL_BITMAP:
+ {
+ if ( pSh && pSh->GetItem( SID_BITMAP_LIST ) )
+ {
+ SvxBitmapListItem aItem( *(const SvxBitmapListItem*)(
+ pSh->GetItem( SID_BITMAP_LIST ) ) );
+ pLbFillAttr->Enable();
+ pLbFillAttr->Fill( aItem.GetBitmapList() );
+ }
+ else
+ pLbFillAttr->Disable();
+ }
+ break;
+ }
+
+ if( eXFS != XFILL_NONE ) // Wurde schon erledigt
+ {
+ if ( pBox )
+ pLbFillType->Selected();
+
+ // release focus
+ if ( pBox && pLbFillType->IsRelease() )
+ {
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ if( pViewShell && pViewShell->GetWindow() )
+ pViewShell->GetWindow()->GrabFocus();
+ }
+ }
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( FillControl, SelectFillAttrHdl, ListBox *, pBox )
+{
+ XFillStyle eXFS = (XFillStyle)pLbFillType->GetSelectEntryPos();
+ XFillStyleItem aXFillStyleItem( eXFS );
+ BOOL bAction = pBox && !pLbFillAttr->IsTravelSelect();
+
+ SfxObjectShell* pSh = SfxObjectShell::Current();
+ if ( bAction )
+ {
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+
+ // First set the style
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" ));
+ aXFillStyleItem.QueryValue( a );
+ aArgs[0].Value = a;
+ ( (SvxFillToolBoxControl*)GetData() )->IgnoreStatusUpdate( TRUE );
+ ((SvxFillToolBoxControl*)GetData())->Dispatch(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillStyle" )), aArgs );
+ ( (SvxFillToolBoxControl*)GetData() )->IgnoreStatusUpdate( FALSE );
+
+ switch( eXFS )
+ {
+ case XFILL_NONE:
+ {
+ }
+ break;
+
+ case XFILL_SOLID:
+ {
+ // NEU
+ //Eintrag wird auf temporaere Farbe geprueft
+ String aTmpStr = pLbFillAttr->GetSelectEntry();
+ if( aTmpStr.GetChar(0) == TMP_STR_BEGIN && aTmpStr.GetChar(aTmpStr.Len()-1) == TMP_STR_END )
+ {
+ aTmpStr.Erase( aTmpStr.Len()-1, 1 );
+ aTmpStr.Erase( 0, 1 );
+ }
+
+ XFillColorItem aXFillColorItem( aTmpStr, pLbFillAttr->GetSelectEntryColor() );
+
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillColor" ));
+ aXFillColorItem.QueryValue( a );
+ aArgs[0].Value = a;
+ ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillColor" )),
+ aArgs );
+ }
+ break;
+ case XFILL_GRADIENT:
+ {
+ USHORT nPos = pLbFillAttr->GetSelectEntryPos();
+
+ if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_GRADIENT_LIST ) )
+ {
+ SvxGradientListItem aItem(
+ *(const SvxGradientListItem*)( pSh->GetItem( SID_GRADIENT_LIST ) ) );
+
+ if ( nPos < aItem.GetGradientList()->Count() ) // kein temp. Eintrag ?
+ {
+ XGradient aGradient = aItem.GetGradientList()->GetGradient( nPos )->GetGradient();
+ XFillGradientItem aXFillGradientItem( pLbFillAttr->GetSelectEntry(), aGradient );
+
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ));
+ aXFillGradientItem.QueryValue( a );
+ aArgs[0].Value = a;
+ ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillGradient" )),
+ aArgs );
+ }
+ }
+ }
+ break;
+
+ case XFILL_HATCH:
+ {
+ USHORT nPos = pLbFillAttr->GetSelectEntryPos();
+
+ if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_HATCH_LIST ) )
+ {
+ SvxHatchListItem aItem( *(const SvxHatchListItem*)( pSh->GetItem( SID_HATCH_LIST ) ) );
+
+ if ( nPos < aItem.GetHatchList()->Count() ) // kein temp. Eintrag ?
+ {
+ XHatch aHatch = aItem.GetHatchList()->GetHatch( nPos )->GetHatch();
+ XFillHatchItem aXFillHatchItem( pLbFillAttr->GetSelectEntry(), aHatch );
+
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" ));
+ aXFillHatchItem.QueryValue( a );
+ aArgs[0].Value = a;
+ ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillHatch" )),
+ aArgs );
+ }
+ }
+ }
+ break;
+
+ case XFILL_BITMAP:
+ {
+ USHORT nPos = pLbFillAttr->GetSelectEntryPos();
+
+ if ( nPos != LISTBOX_ENTRY_NOTFOUND && pSh && pSh->GetItem( SID_BITMAP_LIST ) )
+ {
+ SvxBitmapListItem aItem(
+ *(const SvxBitmapListItem*)( pSh->GetItem( SID_BITMAP_LIST ) ) );
+
+ if ( nPos < aItem.GetBitmapList()->Count() ) // kein temp. Eintrag ?
+ {
+ XOBitmap aXOBitmap = aItem.GetBitmapList()->GetBitmap( nPos )->GetXBitmap();
+ XFillBitmapItem aXFillBitmapItem( pLbFillAttr->GetSelectEntry(), aXOBitmap );
+
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmap" ));
+ aXFillBitmapItem.QueryValue( a );
+ aArgs[0].Value = a;
+ ((SvxFillToolBoxControl*)GetData())->Dispatch( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillBitmap" )),
+ aArgs );
+ }
+ }
+ }
+ break;
+ }
+
+ // release focus
+ if ( pLbFillAttr->IsRelease() && pBox )
+ {
+ SfxViewShell* pViewShell = SfxViewShell::Current();
+ if( pViewShell && pViewShell->GetWindow() )
+ {
+ pViewShell->GetWindow()->GrabFocus();
+ }
+ }
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+void FillControl::Resize()
+{
+ // Breite der beiden ListBoxen nicht 1/2 : 1/2, sondern 2/5 : 3/5
+ long nW = GetOutputSizePixel().Width() / 5;
+ long nH = 180;
+ long nSep = 0; // war vorher 4
+
+ pLbFillType->SetSizePixel( Size( nW * 2 - nSep, nH ) );
+ pLbFillAttr->SetPosSizePixel( Point( nW * 2 + nSep, 0 ), Size( nW * 3 - nSep, nH ) );
+}
+/* -----------------------------08.03.2002 15:04------------------------------
+
+ ---------------------------------------------------------------------------*/
+
+void FillControl::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ Size aTypeSize(LogicToPixel(aLogicalFillSize, MAP_APPFONT));
+ Size aAttrSize(LogicToPixel(aLogicalAttrSize, MAP_APPFONT));
+ pLbFillType->SetSizePixel(aTypeSize);
+ pLbFillAttr->SetSizePixel(aAttrSize);
+ //to get the base height
+ aTypeSize = pLbFillType->GetSizePixel();
+ aAttrSize = pLbFillAttr->GetSizePixel();
+ Point aAttrPnt = pLbFillAttr->GetPosPixel();
+
+ SetSizePixel(
+ Size( aAttrPnt.X() + aAttrSize.Width(),
+ Max( aAttrSize.Height(), aTypeSize.Height() ) ) );
+ }
+ Window::DataChanged( rDCEvt );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
new file mode 100644
index 000000000000..199626d6dcde
--- /dev/null
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -0,0 +1,821 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/text/WritingMode.hpp>
+
+#include <vcl/toolbox.hxx>
+
+#include <svl/itempool.hxx>
+
+#include <svtools/toolbarmenu.hxx>
+#include <svtools/popupwindowcontroller.hxx>
+#include <svtools/popupmenucontrollerbase.hxx>
+
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <editeng/eeitem.hxx>
+#include <editeng/frmdiritem.hxx>
+
+#include <svx/fmmodel.hxx>
+#include <svx/svxids.hrc>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/svdpage.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdoutl.hxx>
+
+#include "gallery.hxx"
+#include <dlgutil.hxx>
+
+#include "fontworkgallery.hxx"
+#include "fontworkgallery.hrc"
+
+#include <algorithm>
+
+#include "helpid.hrc"
+
+using ::rtl::OUString;
+using ::svtools::ToolbarMenu;
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+
+namespace svx
+{
+
+const int nColCount = 4;
+const int nLineCount = 4;
+
+/*************************************************************************
+|* Svx3DWin - FloatingWindow
+\************************************************************************/
+FontWorkGalleryDialog::FontWorkGalleryDialog( SdrView* pSdrView, Window* pParent, sal_uInt16 /*nSID*/ ) :
+ ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_FONTWORK_GALLERY ) ),
+ maCtlFavorites ( this, SVX_RES( CTL_FAVORITES ) ),
+ maFLFavorites ( this, SVX_RES( FL_FAVORITES ) ),
+ maOKButton ( this, SVX_RES( BTN_OK ) ),
+ maCancelButton ( this, SVX_RES( BTN_CANCEL ) ),
+ maHelpButton ( this, SVX_RES( BTN_HELP ) ),
+ mnThemeId ( 0xffff ),
+ mpSdrView ( pSdrView ),
+ mpModel ( (FmFormModel*)pSdrView->GetModel() ),
+ maStrClickToAddText ( SVX_RES( STR_CLICK_TO_ADD_TEXT ) ),
+ mppSdrObject ( NULL ),
+ mpDestModel ( NULL )
+{
+ FreeResource();
+
+ maCtlFavorites.SetDoubleClickHdl( LINK( this, FontWorkGalleryDialog, DoubleClickFavoriteHdl ) );
+ maOKButton.SetClickHdl( LINK( this, FontWorkGalleryDialog, ClickOKHdl ) );
+
+ maCtlFavorites.SetColCount( nColCount );
+ maCtlFavorites.SetLineCount( nLineCount );
+ maCtlFavorites.SetExtraSpacing( 3 );
+
+ initfavorites( GALLERY_THEME_FONTWORK, maFavoritesHorizontal );
+ fillFavorites( GALLERY_THEME_FONTWORK, maFavoritesHorizontal );
+}
+
+static void delete_bitmap( Bitmap* p ) { delete p; }
+
+// -----------------------------------------------------------------------
+FontWorkGalleryDialog::~FontWorkGalleryDialog()
+{
+ std::for_each( maFavoritesHorizontal.begin(), maFavoritesHorizontal.end(), delete_bitmap );
+}
+
+// -----------------------------------------------------------------------
+
+void FontWorkGalleryDialog::initfavorites(sal_uInt16 nThemeId, std::vector< Bitmap * >& rFavorites)
+{
+ // Ueber die Gallery werden die Favoriten eingelesen
+ ULONG nFavCount = GalleryExplorer::GetSdrObjCount( nThemeId );
+
+ // Gallery thema locken
+ GalleryExplorer::BeginLocking(nThemeId);
+
+ sal_uInt32 nModelPos;
+ FmFormModel *pModel = NULL;
+ for( nModelPos = 0; nModelPos < nFavCount; nModelPos++ )
+ {
+ Bitmap* pThumb = new Bitmap;
+
+ if( GalleryExplorer::GetSdrObj( nThemeId, nModelPos, pModel, pThumb ) )
+ {
+/*
+ VirtualDevice aVDev;
+ Size aRenderSize( aThumbSize.Width() * 4, aThumbSize.Height() * 4 );
+ aVDev.SetOutputSizePixel( aRenderSize );
+
+ if( GalleryExplorer::DrawCentered( &aVDev, *pModel ) )
+ {
+ aThumb = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
+
+ Size aMS( 4, 4 );
+ BmpFilterParam aParam( aMS );
+ aThumb.Filter( BMP_FILTER_MOSAIC, &aParam );
+ aThumb.Scale( aThumbSize );
+ }
+*/
+ }
+
+ rFavorites.push_back( pThumb );
+ }
+
+ // Gallery thema freigeben
+ GalleryExplorer::EndLocking(nThemeId);
+}
+
+void FontWorkGalleryDialog::fillFavorites( sal_uInt16 nThemeId, std::vector< Bitmap * >& rFavorites )
+{
+ mnThemeId = nThemeId;
+
+ Size aThumbSize( maCtlFavorites.GetSizePixel() );
+ aThumbSize.Width() /= nColCount;
+ aThumbSize.Height() /= nLineCount;
+ aThumbSize.Width() -= 12;
+ aThumbSize.Height() -= 12;
+
+ std::vector< Bitmap * >::size_type nFavCount = rFavorites.size();
+
+ // ValueSet Favoriten
+ if( nFavCount > (nColCount * nLineCount) )
+ {
+ WinBits nWinBits = maCtlFavorites.GetStyle();
+ nWinBits |= WB_VSCROLL;
+ maCtlFavorites.SetStyle( nWinBits );
+ }
+
+ maCtlFavorites.Clear();
+
+ sal_uInt32 nFavorite;
+ for( nFavorite = 1; nFavorite <= nFavCount; nFavorite++ )
+ {
+ String aStr(SVX_RES(RID_SVXFLOAT3D_FAVORITE));
+ aStr += sal_Unicode(' ');
+ aStr += String::CreateFromInt32((sal_Int32)nFavorite);
+ Image aThumbImage( *rFavorites[nFavorite-1] );
+ maCtlFavorites.InsertItem( (sal_uInt16)nFavorite, aThumbImage, aStr );
+ }
+}
+
+void FontWorkGalleryDialog::changeText( SdrTextObj* pObj )
+{
+ if( pObj )
+ {
+ SdrOutliner& rOutl = mpModel->GetDrawOutliner(pObj);
+
+ USHORT nOutlMode = rOutl.GetMode();
+ Size aPaperSize = rOutl.GetPaperSize();
+ BOOL bUpdateMode = rOutl.GetUpdateMode();
+ rOutl.SetUpdateMode(FALSE);
+ rOutl.SetParaAttribs( 0, rOutl.GetEmptyItemSet() );
+
+ // #95114# Always set the object's StyleSheet at the Outliner to
+ // use the current objects StyleSheet. Thus it's the same as in
+ // SetText(...).
+ // #95114# Moved this implementation from where SetObjText(...) was called
+ // to inside this method to work even when outliner is fetched here.
+ rOutl.SetStyleSheet(0, pObj->GetStyleSheet());
+
+ rOutl.SetPaperSize( pObj->GetLogicRect().GetSize() );
+
+ rOutl.SetText( maStrClickToAddText, rOutl.GetParagraph( 0 ) );
+ pObj->SetOutlinerParaObject( rOutl.CreateParaObject() );
+
+ rOutl.Init( nOutlMode );
+ rOutl.SetParaAttribs( 0, rOutl.GetEmptyItemSet() );
+ rOutl.SetUpdateMode( bUpdateMode );
+ rOutl.SetPaperSize( aPaperSize );
+
+ rOutl.Clear();
+ }
+}
+
+void FontWorkGalleryDialog::SetSdrObjectRef( SdrObject** ppSdrObject, SdrModel* pModel )
+{
+ mppSdrObject = ppSdrObject;
+ mpDestModel = pModel;
+}
+
+void FontWorkGalleryDialog::insertSelectedFontwork()
+{
+ USHORT nItemId = maCtlFavorites.GetSelectItemId();
+
+ if( nItemId > 0 )
+ {
+ FmFormModel* pModel = new FmFormModel();
+ pModel->GetItemPool().FreezeIdRanges();
+
+ if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel ) )
+ {
+ SdrPage* pPage = pModel->GetPage(0);
+ if( pPage && pPage->GetObjCount() )
+ {
+ SdrObject* pNewObject = pPage->GetObj(0)->Clone();
+
+ // center shape on current view
+ OutputDevice* pOutDev = mpSdrView->GetFirstOutputDevice();
+ if( pOutDev )
+ {
+ Rectangle aObjRect( pNewObject->GetLogicRect() );
+ Rectangle aVisArea = pOutDev->PixelToLogic(Rectangle(Point(0,0), pOutDev->GetOutputSizePixel()));
+/*
+ sal_Int32 nObjHeight = aObjRect.GetHeight();
+ VirtualDevice aVirDev( 1 ); // calculating the optimal textwidth
+ Font aFont;
+ aFont.SetHeight( nObjHeight );
+ aVirDev.SetMapMode( MAP_100TH_MM );
+ aVirDev.SetFont( aFont );
+ aObjRect.SetSize( Size( aVirDev.GetTextWidth( maStrClickToAddText ), nObjHeight ) );
+*/
+ Point aPagePos = aVisArea.Center();
+ aPagePos.X() -= aObjRect.GetWidth() / 2;
+ aPagePos.Y() -= aObjRect.GetHeight() / 2;
+ Rectangle aNewObjectRectangle(aPagePos, aObjRect.GetSize());
+ SdrPageView* pPV = mpSdrView->GetSdrPageView();
+
+ pNewObject->SetLogicRect(aNewObjectRectangle);
+ if ( mppSdrObject )
+ {
+ *mppSdrObject = pNewObject;
+ (*mppSdrObject)->SetModel( mpDestModel );
+ }
+ else if( pPV )
+ {
+ mpSdrView->InsertObjectAtView( pNewObject, *pPV );
+ // changeText( PTR_CAST( SdrTextObj, pNewObject ) );
+ }
+ }
+ }
+ }
+
+ delete pModel;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( FontWorkGalleryDialog, ClickOKHdl, void*, EMPTYARG )
+{
+ insertSelectedFontwork();
+ EndDialog( true );
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( FontWorkGalleryDialog, DoubleClickFavoriteHdl, void*, EMPTYARG )
+{
+ insertSelectedFontwork();
+ EndDialog( true );
+ return( 0L );
+}
+
+//------------------------------------------------------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( FontWorkShapeTypeControl, SfxStringItem );
+FontWorkShapeTypeControl::FontWorkShapeTypeControl( USHORT nSlotId, USHORT nId, ToolBox &rTbx )
+: SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+FontWorkShapeTypeControl::~FontWorkShapeTypeControl()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType FontWorkShapeTypeControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK; //( aLastAction.getLength() == 0 ? SFX_POPUPWINDOW_ONCLICK : SFX_POPUPWINDOW_ONTIMEOUT );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* FontWorkShapeTypeControl::CreatePopupWindow()
+{
+ rtl::OUString aSubTbxResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/fontworkshapetype" ) );
+ createAndPositionSubToolBar( aSubTbxResName );
+ return NULL;
+}
+
+// -----------------------------------------------------------------------
+
+void FontWorkShapeTypeControl::Select( BOOL )
+{
+
+}
+
+// ========================================================================
+// FontWorkAlignmentWindow
+// ========================================================================
+
+class FontWorkAlignmentWindow : public ToolbarMenu
+{
+public:
+ FontWorkAlignmentWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow );
+
+ virtual void SAL_CALL statusChanged( const frame::FeatureStateEvent& Event ) throw ( RuntimeException );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+private:
+ svt::ToolboxController& mrController;
+
+ Image maImgAlgin1;
+ Image maImgAlgin2;
+ Image maImgAlgin3;
+ Image maImgAlgin4;
+ Image maImgAlgin5;
+ Image maImgAlgin1h;
+ Image maImgAlgin2h;
+ Image maImgAlgin3h;
+ Image maImgAlgin4h;
+ Image maImgAlgin5h;
+
+ const rtl::OUString msFontworkAlignment;
+
+ DECL_LINK( SelectHdl, void * );
+
+ void implSetAlignment( int nAlignmentMode, bool bEnabled );
+};
+
+FontWorkAlignmentWindow::FontWorkAlignmentWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow )
+: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_FONTWORK_ALIGNMENT ))
+, mrController( rController )
+, maImgAlgin1( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16 ) )
+, maImgAlgin2( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16 ) )
+, maImgAlgin3( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16 ) )
+, maImgAlgin4( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16 ) )
+, maImgAlgin5( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16 ) )
+, maImgAlgin1h( SVX_RES( IMG_FONTWORK_ALIGN_LEFT_16_H ) )
+, maImgAlgin2h( SVX_RES( IMG_FONTWORK_ALIGN_CENTER_16_H ) )
+, maImgAlgin3h( SVX_RES( IMG_FONTWORK_ALIGN_RIGHT_16_H ) )
+, maImgAlgin4h( SVX_RES( IMG_FONTWORK_ALIGN_WORD_16_H ) )
+, maImgAlgin5h( SVX_RES( IMG_FONTWORK_ALIGN_STRETCH_16_H ) )
+, msFontworkAlignment( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ) )
+{
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ SetHelpId( HID_POPUP_FONTWORK_ALIGN );
+ SetSelectHdl( LINK( this, FontWorkAlignmentWindow, SelectHdl ) );
+
+ appendEntry( 0, String( SVX_RES( STR_ALIGN_LEFT ) ), bHighContrast ? maImgAlgin1h : maImgAlgin1 );
+ appendEntry( 1, String( SVX_RES( STR_ALIGN_CENTER ) ), bHighContrast ? maImgAlgin2h : maImgAlgin2 );
+ appendEntry( 2, String( SVX_RES( STR_ALIGN_RIGHT ) ), bHighContrast ? maImgAlgin3h : maImgAlgin3 );
+ appendEntry( 3, String( SVX_RES( STR_ALIGN_WORD ) ), bHighContrast ? maImgAlgin4h : maImgAlgin4 );
+ appendEntry( 4, String( SVX_RES( STR_ALIGN_STRETCH ) ), bHighContrast ? maImgAlgin5h : maImgAlgin5 );
+
+ SetOutputSizePixel( getMenuSize() );
+
+ FreeResource();
+
+ AddStatusListener( msFontworkAlignment );
+}
+
+// -----------------------------------------------------------------------
+
+void FontWorkAlignmentWindow::implSetAlignment( int nSurface, bool bEnabled )
+{
+ int i;
+ for( i = 0; i < 5; i++ )
+ {
+ checkEntry( i, (i == nSurface) && bEnabled );
+ enableEntry( i, bEnabled );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SAL_CALL FontWorkAlignmentWindow::statusChanged( const frame::FeatureStateEvent& Event ) throw ( RuntimeException )
+{
+ if( Event.FeatureURL.Main.equals( msFontworkAlignment ) )
+ {
+ if( !Event.IsEnabled )
+ {
+ implSetAlignment( 0, false );
+ }
+ else
+ {
+ sal_Int32 nValue = 0;
+ if( Event.State >>= nValue )
+ implSetAlignment( nValue, true );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void FontWorkAlignmentWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ ToolbarMenu::DataChanged( rDCEvt );
+
+ if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ {
+ bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ appendEntry( 0, String( SVX_RES( STR_ALIGN_LEFT ) ), bHighContrast ? maImgAlgin1h : maImgAlgin1 );
+ appendEntry( 1, String( SVX_RES( STR_ALIGN_CENTER ) ), bHighContrast ? maImgAlgin2h : maImgAlgin2 );
+ appendEntry( 2, String( SVX_RES( STR_ALIGN_RIGHT ) ), bHighContrast ? maImgAlgin3h : maImgAlgin3 );
+ appendEntry( 3, String( SVX_RES( STR_ALIGN_WORD ) ), bHighContrast ? maImgAlgin4h : maImgAlgin4 );
+ appendEntry( 4, String( SVX_RES( STR_ALIGN_STRETCH ) ), bHighContrast ? maImgAlgin5h : maImgAlgin5 );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( FontWorkAlignmentWindow, SelectHdl, void *, EMPTYARG )
+{
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ sal_Int32 nAlignment = getSelectedEntryId();
+ if( nAlignment >= 0 )
+ {
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = msFontworkAlignment.copy(5);
+ aArgs[0].Value <<= (sal_Int32)nAlignment;
+
+ mrController.dispatchCommand( msFontworkAlignment, aArgs );
+
+ implSetAlignment( nAlignment, true );
+ }
+
+ return 0;
+}
+
+// ========================================================================
+// FontWorkAlignmentControl
+// ========================================================================
+
+class FontWorkAlignmentControl : public svt::PopupWindowController
+{
+public:
+ FontWorkAlignmentControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
+
+ virtual ::Window* createPopupWindow( ::Window* pParent );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ using svt::PopupWindowController::createPopupWindow;
+};
+
+
+// -----------------------------------------------------------------------
+
+FontWorkAlignmentControl::FontWorkAlignmentControl( const Reference< lang::XMultiServiceFactory >& rServiceManager )
+: svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkAlignment" ) ) )
+{
+}
+
+// -----------------------------------------------------------------------
+
+::Window* FontWorkAlignmentControl::createPopupWindow( ::Window* pParent )
+{
+ return new FontWorkAlignmentWindow( *this, m_xFrame, pParent );
+}
+
+// -----------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------
+
+OUString SAL_CALL FontWorkAlignmentControl_getImplementationName()
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FontWorkAlignmentController" ));
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL FontWorkAlignmentControl_getSupportedServiceNames() throw( RuntimeException )
+{
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
+ return aSNS;
+}
+
+// --------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL SAL_CALL FontWorkAlignmentControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
+{
+ return *new FontWorkAlignmentControl( rSMgr );
+}
+
+// --------------------------------------------------------------------
+
+OUString SAL_CALL FontWorkAlignmentControl::getImplementationName( ) throw (RuntimeException)
+{
+ return FontWorkAlignmentControl_getImplementationName();
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL FontWorkAlignmentControl::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ return FontWorkAlignmentControl_getSupportedServiceNames();
+}
+
+
+// ####################################################################
+
+class FontWorkCharacterSpacingWindow : public ToolbarMenu
+{
+public:
+ FontWorkCharacterSpacingWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow );
+
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
+private:
+ svt::ToolboxController& mrController;
+
+ const rtl::OUString msFontworkCharacterSpacing;
+ const rtl::OUString msFontworkKernCharacterPairs;
+
+ DECL_LINK( SelectHdl, void * );
+
+ void implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled );
+ void implSetKernCharacterPairs( sal_Bool bKernOnOff, bool bEnabled );
+
+};
+
+// -----------------------------------------------------------------------
+
+FontWorkCharacterSpacingWindow::FontWorkCharacterSpacingWindow( svt::ToolboxController& rController, const Reference< XFrame >& rFrame, Window* pParentWindow )
+: ToolbarMenu( rFrame, pParentWindow, SVX_RES( RID_SVXFLOAT_FONTWORK_CHARSPACING ))
+, mrController( rController )
+, msFontworkCharacterSpacing( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacing" ) )
+, msFontworkKernCharacterPairs( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkKernCharacterPairs" ) )
+{
+ SetHelpId( HID_POPUP_FONTWORK_CHARSPACE );
+ SetSelectHdl( LINK( this, FontWorkCharacterSpacingWindow, SelectHdl ) );
+
+ appendEntry( 0, String( SVX_RES( STR_CHARS_SPACING_VERY_TIGHT ) ), MIB_RADIOCHECK );
+ appendEntry( 1, String( SVX_RES( STR_CHARS_SPACING_TIGHT ) ), MIB_RADIOCHECK );
+ appendEntry( 2, String( SVX_RES( STR_CHARS_SPACING_NORMAL ) ), MIB_RADIOCHECK );
+ appendEntry( 3, String( SVX_RES( STR_CHARS_SPACING_LOOSE ) ), MIB_RADIOCHECK );
+ appendEntry( 4, String( SVX_RES( STR_CHARS_SPACING_VERY_LOOSE ) ), MIB_RADIOCHECK );
+ appendEntry( 5, String( SVX_RES( STR_CHARS_SPACING_CUSTOM ) ), MIB_RADIOCHECK );
+ appendSeparator();
+ appendEntry( 6, String( SVX_RES( STR_CHARS_SPACING_KERN_PAIRS ) ), MIB_CHECKABLE );
+
+ SetOutputSizePixel( getMenuSize() );
+
+ FreeResource();
+
+ AddStatusListener( msFontworkCharacterSpacing );
+ AddStatusListener( msFontworkKernCharacterPairs );
+}
+
+// -----------------------------------------------------------------------
+
+void FontWorkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled )
+{
+ sal_Int32 i;
+ for ( i = 0; i < 6; i++ )
+ {
+ checkEntry( i, sal_False );
+ enableEntry( i, bEnabled );
+ }
+ if ( nCharacterSpacing != -1 )
+ {
+ sal_Int32 nEntry;
+ switch( nCharacterSpacing )
+ {
+ case 80 : nEntry = 0; break;
+ case 90 : nEntry = 1; break;
+ case 100 : nEntry = 2; break;
+ case 120 : nEntry = 3; break;
+ case 150 : nEntry = 4; break;
+ default : nEntry = 5; break;
+ }
+ checkEntry( nEntry, bEnabled );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void FontWorkCharacterSpacingWindow::implSetKernCharacterPairs( sal_Bool, bool bEnabled )
+{
+ enableEntry( 6, bEnabled );
+ checkEntry( 6, bEnabled );
+}
+
+// -----------------------------------------------------------------------
+
+void SAL_CALL FontWorkCharacterSpacingWindow::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException )
+{
+ if( Event.FeatureURL.Main.equals( msFontworkCharacterSpacing ) )
+ {
+ if( !Event.IsEnabled )
+ {
+ implSetCharacterSpacing( 0, false );
+ }
+ else
+ {
+ sal_Int32 nValue = 0;
+ if( Event.State >>= nValue )
+ implSetCharacterSpacing( nValue, true );
+ }
+ }
+ else if( Event.FeatureURL.Main.equals( msFontworkKernCharacterPairs ) )
+ {
+ if( !Event.IsEnabled )
+ {
+ implSetKernCharacterPairs( 0, false );
+ }
+ else
+ {
+ sal_Bool bValue = sal_False;
+ if( Event.State >>= bValue )
+ implSetKernCharacterPairs( bValue, true );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( FontWorkCharacterSpacingWindow, SelectHdl, void *, EMPTYARG )
+{
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ sal_Int32 nSelection = getSelectedEntryId();
+ sal_Int32 nCharacterSpacing;
+ switch( nSelection )
+ {
+ case 0 : nCharacterSpacing = 80; break;
+ case 1 : nCharacterSpacing = 90; break;
+ case 2 : nCharacterSpacing = 100; break;
+ case 3 : nCharacterSpacing = 120; break;
+ case 4 : nCharacterSpacing = 150; break;
+ default : nCharacterSpacing = 100; break;
+ }
+ if ( nSelection == 5 ) // custom spacing
+ {
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = msFontworkCharacterSpacing.copy(5);
+ aArgs[0].Value <<= (sal_Int32)nCharacterSpacing;
+
+ mrController.dispatchCommand( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacingDialog" )), aArgs );
+ }
+ else if ( nSelection == 6 ) // KernCharacterPairs
+ {
+ rtl::OUString aCommand( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkKernCharacterPairs" ));
+
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = msFontworkKernCharacterPairs.copy(5);
+ aArgs[0].Value <<= (sal_Bool) sal_True;
+
+ mrController.dispatchCommand( msFontworkKernCharacterPairs, aArgs );
+
+ implSetKernCharacterPairs( sal_True, true );
+ }
+ else if( nSelection >= 0 )
+ {
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = msFontworkCharacterSpacing.copy(5);
+ aArgs[0].Value <<=( sal_Int32)nCharacterSpacing;
+
+ mrController.dispatchCommand( msFontworkCharacterSpacing, aArgs );
+
+ implSetCharacterSpacing( nCharacterSpacing, true );
+ }
+
+ return 0;
+}
+
+// ========================================================================
+// FontWorkCharacterSpacingControl
+// ========================================================================
+
+class FontWorkCharacterSpacingControl : public svt::PopupWindowController
+{
+public:
+ FontWorkCharacterSpacingControl( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
+
+ virtual ::Window* createPopupWindow( ::Window* pParent );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ using svt::PopupWindowController::createPopupWindow;
+};
+
+
+FontWorkCharacterSpacingControl::FontWorkCharacterSpacingControl( const Reference< lang::XMultiServiceFactory >& rServiceManager )
+: svt::PopupWindowController( rServiceManager, Reference< frame::XFrame >(), OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontworkCharacterSpacingFloater" ) ) )
+{
+}
+
+// -----------------------------------------------------------------------
+
+::Window* FontWorkCharacterSpacingControl::createPopupWindow( ::Window* pParent )
+{
+ return new FontWorkCharacterSpacingWindow( *this, m_xFrame, pParent );
+}
+
+// -----------------------------------------------------------------------
+// XServiceInfo
+// -----------------------------------------------------------------------
+
+OUString SAL_CALL FontWorkCharacterSpacingControl_getImplementationName()
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FontWorkCharacterSpacingController" ));
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL FontWorkCharacterSpacingControl_getSupportedServiceNames() throw( RuntimeException )
+{
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
+ return aSNS;
+}
+
+// --------------------------------------------------------------------
+
+Reference< XInterface > SAL_CALL SAL_CALL FontWorkCharacterSpacingControl_createInstance( const Reference< XMultiServiceFactory >& rSMgr ) throw( RuntimeException )
+{
+ return *new FontWorkCharacterSpacingControl( rSMgr );
+}
+
+// --------------------------------------------------------------------
+
+OUString SAL_CALL FontWorkCharacterSpacingControl::getImplementationName( ) throw (RuntimeException)
+{
+ return FontWorkCharacterSpacingControl_getImplementationName();
+}
+
+// --------------------------------------------------------------------
+
+Sequence< OUString > SAL_CALL FontWorkCharacterSpacingControl::getSupportedServiceNames( ) throw (RuntimeException)
+{
+ return FontWorkCharacterSpacingControl_getSupportedServiceNames();
+}
+
+// ========================================================================
+// FontworkCharacterSpacingDialog
+// ========================================================================
+
+FontworkCharacterSpacingDialog::FontworkCharacterSpacingDialog( Window* pParent, sal_Int32 nScale )
+: ModalDialog( pParent, SVX_RES( RID_SVX_MDLG_FONTWORK_CHARSPACING ) ),
+ maFLScale( this, SVX_RES( FT_VALUE ) ),
+ maMtrScale( this, SVX_RES( MF_VALUE ) ),
+ maOKButton( this, SVX_RES( BTN_OK ) ),
+ maCancelButton( this, SVX_RES( BTN_CANCEL ) ),
+ maHelpButton( this, SVX_RES( BTN_HELP ) )
+{
+ maMtrScale.SetValue( nScale );
+ FreeResource();
+}
+
+FontworkCharacterSpacingDialog::~FontworkCharacterSpacingDialog()
+{
+}
+
+sal_Int32 FontworkCharacterSpacingDialog::getScale() const
+{
+ return (sal_Int32)maMtrScale.GetValue();
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/fontworkgallery.src b/svx/source/tbxctrls/fontworkgallery.src
new file mode 100644
index 000000000000..f4d5e421bcc3
--- /dev/null
+++ b/svx/source/tbxctrls/fontworkgallery.src
@@ -0,0 +1,323 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "helpid.hrc"
+#include <svx/dialogs.hrc>
+#include "fontworkgallery.hrc"
+#include "svtools/controldims.hrc"
+
+#define WIDTH 256
+#define HEIGHT 256
+
+#define MASKCOLOR MaskColor = Color { Red=0xFFFF; Green=0x0000; Blue=0xFFFF; };
+
+ModalDialog RID_SVX_MDLG_FONTWORK_GALLERY
+{
+ OutputSize = TRUE;
+ SVLook = TRUE ;
+ Moveable = TRUE;
+ Closeable = TRUE;
+
+ Size = MAP_APPFONT( WIDTH, HEIGHT );
+
+ Text [ en-US ] = "Fontwork Gallery" ;
+
+ FixedLine FL_FAVORITES
+ {
+ Pos = MAP_APPFONT ( 3 , 3 ) ;
+ Size = MAP_APPFONT ( WIDTH - 6 , 8 ) ;
+ Text [ en-US ] = "Select a Fontwork style:" ;
+ };
+ Control CTL_FAVORITES
+ {
+ HelpId = HID_CTL_FONTWORK_FAVORITES ;
+ Border = FALSE ;
+ Pos = MAP_APPFONT ( 3 , 14 ) ;
+ Size = MAP_APPFONT ( WIDTH - 6,
+ HEIGHT - RSC_CD_PUSHBUTTON_HEIGHT -
+ 6 - RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ OkButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( WIDTH - 3 * RSC_CD_PUSHBUTTON_WIDTH - 9 ,
+ HEIGHT - 3 - RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH,
+ RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( WIDTH - 2 * RSC_CD_PUSHBUTTON_WIDTH - 6 ,
+ HEIGHT - 3 - RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH,
+ RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( WIDTH - 1 * RSC_CD_PUSHBUTTON_WIDTH - 3 ,
+ HEIGHT - 3 - RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ Size = MAP_APPFONT ( RSC_CD_PUSHBUTTON_WIDTH,
+ RSC_CD_PUSHBUTTON_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+ String STR_CLICK_TO_ADD_TEXT
+ {
+ Text [ en-US ] = "Click to edit text" ;
+ };
+};
+
+DockingWindow RID_SVXFLOAT_FONTWORK_ALIGNMENT
+{
+ Border = FALSE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Sizeable = FALSE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+
+ Text [ en-US ] = "Fontwork Alignment" ;
+
+ String STR_ALIGN_LEFT
+ {
+ Text [ en-US ] = "~Left Align";
+ };
+ String STR_ALIGN_CENTER
+ {
+ Text [ en-US ] = "~Center";
+ };
+ String STR_ALIGN_RIGHT
+ {
+ Text [ en-US ] = "~Right Align";
+ };
+ String STR_ALIGN_WORD
+ {
+ Text [ en-US ] = "~Word Justify";
+ };
+ String STR_ALIGN_STRETCH
+ {
+ Text [ en-US ] = "S~tretch Justify";
+ };
+
+ Image IMG_FONTWORK_ALIGN_LEFT_16
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignleft_16.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_LEFT_16_H
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignleft_16_h.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_LEFT_26
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignleft_26.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_LEFT_26_H
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignleft_26_h.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_CENTER_16
+ {
+ ImageBitmap = Bitmap { File = "fontworkaligncentered_16.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_CENTER_16_H
+ {
+ ImageBitmap = Bitmap { File = "fontworkaligncentered_16_h.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_CENTER_26
+ {
+ ImageBitmap = Bitmap { File = "fontworkaligncentered_26.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_CENTER_26_H
+ {
+ ImageBitmap = Bitmap { File = "fontworkaligncentered_26_h.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_RIGHT_16
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignright_16.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_RIGHT_16_H
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignright_16_h.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_RIGHT_26
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignright_26.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_RIGHT_26_H
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignright_26_h.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_WORD_16
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignjustified_16.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_WORD_16_H
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignjustified_16_h.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_WORD_26
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignjustified_26.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_WORD_26_H
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignjustified_26_h.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_STRETCH_16
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignstretch_16.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_STRETCH_16_H
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignstretch_16_h.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_STRETCH_26
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignstretch_26.png"; };
+ MASKCOLOR
+ };
+ Image IMG_FONTWORK_ALIGN_STRETCH_26_H
+ {
+ ImageBitmap = Bitmap { File = "fontworkalignstretch_26_h.png"; };
+ MASKCOLOR
+ };
+};
+
+DockingWindow RID_SVXFLOAT_FONTWORK_CHARSPACING
+{
+ Border = FALSE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Sizeable = FALSE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+
+ Text [ en-US ] = "Fontwork Character Spacing" ;
+
+ String STR_CHARS_SPACING_VERY_TIGHT
+ {
+ Text [ en-US ] = "~Very Tight";
+ };
+ String STR_CHARS_SPACING_TIGHT
+ {
+ Text [ en-US ] = "~Tight";
+ };
+ String STR_CHARS_SPACING_NORMAL
+ {
+ Text [ en-US ] = "~Normal";
+ };
+ String STR_CHARS_SPACING_LOOSE
+ {
+ Text [ en-US ] = "~Loose";
+ };
+ String STR_CHARS_SPACING_VERY_LOOSE
+ {
+ Text [ en-US ] = "Very ~Loose";
+ };
+ String STR_CHARS_SPACING_CUSTOM
+ {
+ Text [ en-US ] = "~Custom...";
+ };
+ String STR_CHARS_SPACING_KERN_PAIRS
+ {
+ Text [ en-US ] = "~Kern Character Pairs";
+ };
+};
+
+ModalDialog RID_SVX_MDLG_FONTWORK_CHARSPACING
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 139 , 64 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ Text [ en-US ] = "Fontwork Character Spacing" ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 83 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 83 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 83 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_VALUE
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 76 , 8 ) ;
+ Text[ en-US ] = "~Value";
+ };
+ MetricField MF_VALUE
+ {
+ Border = FALSE ;
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 32 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ Maximum = 500 ;
+ StrictFormat = TRUE ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = "%" ;
+ Last = 100 ;
+ SpinSize = 5 ;
+ };
+};
+
diff --git a/svx/source/tbxctrls/formatpaintbrushctrl.cxx b/svx/source/tbxctrls/formatpaintbrushctrl.cxx
new file mode 100644
index 000000000000..a06289269db8
--- /dev/null
+++ b/svx/source/tbxctrls/formatpaintbrushctrl.cxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "formatpaintbrushctrl.hxx"
+
+// header for class SfxBoolItem
+#include <svl/eitem.hxx>
+
+// header for define SFX_APP
+#include <sfx2/app.hxx>
+
+// header for class ToolBox
+#include <vcl/toolbox.hxx>
+
+//.............................................................................
+namespace svx
+{
+//.............................................................................
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+
+SFX_IMPL_TOOLBOX_CONTROL( FormatPaintBrushToolBoxControl, SfxBoolItem );
+
+FormatPaintBrushToolBoxControl::FormatPaintBrushToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ : SfxToolBoxControl( nSlotId, nId, rTbx )
+ , m_bPersistentCopy(false)
+ , m_aDoubleClickTimer()
+{
+ ULONG nDblClkTime = rTbx.GetSettings().GetMouseSettings().GetDoubleClickTime();
+
+ m_aDoubleClickTimer.SetTimeoutHdl( LINK(this, FormatPaintBrushToolBoxControl, WaitDoubleClickHdl) );
+ m_aDoubleClickTimer.SetTimeout(nDblClkTime);
+}
+
+// -----------------------------------------------------------------------
+
+FormatPaintBrushToolBoxControl::~FormatPaintBrushToolBoxControl()
+{
+ m_aDoubleClickTimer.Stop();
+}
+
+// -----------------------------------------------------------------------
+void FormatPaintBrushToolBoxControl::impl_executePaintBrush()
+{
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PersistentCopy" ));
+ aArgs[0].Value = makeAny( static_cast<sal_Bool>(m_bPersistentCopy) );
+ Dispatch( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatPaintbrush" ))
+ , aArgs );
+}
+
+// -----------------------------------------------------------------------
+void FormatPaintBrushToolBoxControl::DoubleClick()
+{
+ m_aDoubleClickTimer.Stop();
+
+ m_bPersistentCopy = true;
+ this->impl_executePaintBrush();
+}
+
+// -----------------------------------------------------------------------
+void FormatPaintBrushToolBoxControl::Click()
+{
+ m_bPersistentCopy = false;
+ m_aDoubleClickTimer.Start();
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK(FormatPaintBrushToolBoxControl, WaitDoubleClickHdl, void*, EMPTYARG )
+{
+ //there was no second click during waiting
+ this->impl_executePaintBrush();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+void FormatPaintBrushToolBoxControl::Select( BOOL )
+{
+}
+
+// -----------------------------------------------------------------------
+void FormatPaintBrushToolBoxControl::StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ if( ( eState & SFX_ITEM_SET ) == 0 )
+ m_bPersistentCopy = false;
+ SfxToolBoxControl::StateChanged( nSID, eState, pState );
+}
+
+//.............................................................................
+} //namespace svx
+//.............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx
new file mode 100644
index 000000000000..e0c0d88801e3
--- /dev/null
+++ b/svx/source/tbxctrls/grafctrl.cxx
@@ -0,0 +1,1290 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+
+#include <vcl/toolbox.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/whiter.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <tools/urlobj.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <svx/svxids.hrc>
+#include "grafctrl.hrc"
+#include <svx/dialogs.hrc>
+#include <editeng/brshitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svx/sdgcpitm.hxx>
+
+#include <svx/itemwin.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdtrans.hxx>
+#include "grafctrl.hxx"
+#include "tbxcolor.hxx"
+
+// namespaces
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+
+#include <svx/svxdlg.hxx>
+// -----------
+// - Defines -
+// -----------
+
+#define SYMBOL_TO_FIELD_OFFSET 4
+#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
+#define TOOLBOX_NAME ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "colorbar" ) )
+
+// ----------------
+// - TbxImageItem -
+// ----------------
+
+TYPEINIT1_AUTOFACTORY( TbxImageItem, SfxUInt16Item );
+
+//---------------------------------------------------------
+
+TbxImageItem::TbxImageItem( USHORT _nWhich, UINT16 nImage ) :
+ SfxUInt16Item( _nWhich, nImage )
+{
+}
+
+//---------------------------------------------------------
+
+SfxPoolItem* TbxImageItem::Clone( SfxItemPool* ) const
+{
+ return new TbxImageItem( *this );
+}
+
+//---------------------------------------------------------
+
+int TbxImageItem::operator==( const SfxPoolItem& rItem ) const
+{
+ return( ( (TbxImageItem&) rItem ).GetValue() == GetValue() );
+}
+
+// -----------------------
+// - ImplGrafMetricField -
+// -----------------------
+
+class ImplGrafMetricField : public MetricField
+{
+ using Window::Update;
+
+private:
+ Timer maTimer;
+ OUString maCommand;
+ Reference< XFrame > mxFrame;
+
+ DECL_LINK( ImplModifyHdl, Timer* );
+
+protected:
+
+ virtual void Modify();
+
+public:
+
+ ImplGrafMetricField( Window* pParent, const rtl::OUString& aCmd, const Reference< XFrame >& rFrame );
+ ~ImplGrafMetricField();
+
+ void Update( const SfxPoolItem* pItem );
+ const OUString& GetCommand() const { return maCommand; }
+};
+
+// -----------------------------------------------------------------------------
+
+ImplGrafMetricField::ImplGrafMetricField( Window* pParent, const rtl::OUString& rCmd, const Reference< XFrame >& rFrame ) :
+ MetricField( pParent, WB_BORDER | WB_SPIN | WB_REPEAT | WB_3DLOOK ),
+ maCommand( rCmd ),
+ mxFrame( rFrame )
+{
+ Size aSize( GetTextWidth( String::CreateFromAscii("-100 %") ), GetTextHeight() );
+
+ aSize.Width() += 20, aSize.Height() += 6;
+ SetSizePixel( aSize );
+
+ if ( maCommand.equalsAscii( ".uno:GrafGamma" ))
+ {
+ SetDecimalDigits( 2 );
+
+ SetMin( 10 );
+ SetFirst( 10 );
+ SetMax( 1000 );
+ SetLast( 1000 );
+ SetSpinSize( 10 );
+ }
+ else
+ {
+ const long nMinVal = ( maCommand.equalsAscii( ".uno:GrafTransparence" )) ? 0 : -100;
+
+ SetUnit( FUNIT_CUSTOM );
+ SetCustomUnitText( String::CreateFromAscii(" %") );
+ SetDecimalDigits( 0 );
+
+ SetMin( nMinVal );
+ SetFirst( nMinVal );
+ SetMax( 100 );
+ SetLast( 100 );
+ SetSpinSize( 1 );
+ }
+
+ maTimer.SetTimeout( 100 );
+ maTimer.SetTimeoutHdl( LINK( this, ImplGrafMetricField, ImplModifyHdl ) );
+}
+
+// -----------------------------------------------------------------------------
+
+ImplGrafMetricField::~ImplGrafMetricField()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void ImplGrafMetricField::Modify()
+{
+ maTimer.Start();
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( ImplGrafMetricField, ImplModifyHdl, Timer*, EMPTYARG )
+{
+ const sal_Int64 nVal = GetValue();
+
+ // Convert value to an any to be usable with dispatch API
+ Any a;
+ if ( maCommand.equalsAscii( ".uno:GrafRed" ) ||
+ maCommand.equalsAscii( ".uno:GrafGreen" ) ||
+ maCommand.equalsAscii( ".uno:GrafBlue" ) ||
+ maCommand.equalsAscii( ".uno:GrafLuminance" ) ||
+ maCommand.equalsAscii( ".uno:GrafContrast" ))
+ a = makeAny( sal_Int16( nVal ));
+ else if ( maCommand.equalsAscii( ".uno:GrafGamma" ) ||
+ maCommand.equalsAscii( ".uno:GrafTransparence" ))
+ a = makeAny( sal_Int32( nVal ));
+
+ if ( a.hasValue() )
+ {
+ INetURLObject aObj( maCommand );
+
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = aObj.GetURLPath();
+ aArgs[0].Value = a;
+
+ SfxToolBoxControl::Dispatch(
+ Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
+ maCommand,
+ aArgs );
+ }
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+void ImplGrafMetricField::Update( const SfxPoolItem* pItem )
+{
+ if( pItem )
+ {
+ long nValue;
+
+ if ( maCommand.equalsAscii( ".uno:GrafTransparence" ))
+ nValue = ( (SfxUInt16Item*) pItem )->GetValue();
+ else if ( maCommand.equalsAscii( ".uno:GrafGamma" ))
+ nValue = ( (SfxUInt32Item*) pItem )->GetValue();
+ else
+ nValue = ( (SfxInt16Item*) pItem )->GetValue();
+
+ SetValue( nValue );
+ }
+ else
+ SetText( String() );
+}
+
+// --------------------
+// - ImplGrafControl -
+// --------------------
+
+struct CommandToRID
+{
+ const char* pCommand;
+ USHORT nResId;
+ USHORT nHCResId;
+};
+
+static USHORT ImplGetRID( const OUString& aCommand, bool bHighContrast )
+{
+ static const CommandToRID aImplCommandToResMap[] =
+ {
+ { ".uno:GrafRed", RID_SVXIMG_GRAF_RED, RID_SVXIMG_GRAF_RED_H },
+ { ".uno:GrafGreen", RID_SVXIMG_GRAF_GREEN, RID_SVXIMG_GRAF_GREEN_H },
+ { ".uno:GrafBlue", RID_SVXIMG_GRAF_BLUE, RID_SVXIMG_GRAF_BLUE_H },
+ { ".uno:GrafLuminance", RID_SVXIMG_GRAF_LUMINANCE, RID_SVXIMG_GRAF_LUMINANCE_H },
+ { ".uno:GrafContrast", RID_SVXIMG_GRAF_CONTRAST, RID_SVXIMG_GRAF_CONTRAST_H },
+ { ".uno:GrafGamma", RID_SVXIMG_GRAF_GAMMA, RID_SVXIMG_GRAF_GAMMA_H },
+ { ".uno:GrafTransparence", RID_SVXIMG_GRAF_TRANSPARENCE, RID_SVXIMG_GRAF_TRANSPARENCE_H },
+ { 0, 0, 0 }
+ };
+
+ USHORT nRID = 0;
+
+ sal_Int32 i( 0 );
+ while ( aImplCommandToResMap[ i ].pCommand )
+ {
+ if ( aCommand.equalsAscii( aImplCommandToResMap[ i ].pCommand ))
+ {
+ if ( bHighContrast )
+ nRID = aImplCommandToResMap[ i ].nHCResId;
+ else
+ nRID = aImplCommandToResMap[ i ].nResId;
+ break;
+ }
+ ++i;
+ }
+
+ return nRID;
+}
+
+// -----------------------------------------------------------------------------
+
+class ImplGrafControl : public Control
+{
+ using Window::Update;
+private:
+ FixedImage maImage;
+ ImplGrafMetricField maField;
+
+protected:
+
+ virtual void GetFocus();
+
+public:
+
+ ImplGrafControl( Window* pParent, USHORT nSlotId, const rtl::OUString& rCmd, const Reference< XFrame >& rFrame );
+ ~ImplGrafControl();
+
+ void Update( const SfxPoolItem* pItem ) { maField.Update( pItem ); }
+ void SetText( const String& rStr ) { maField.SetText( rStr ); }
+};
+
+// -----------------------------------------------------------------------------
+
+ImplGrafControl::ImplGrafControl( Window* pParent, USHORT nSlotId, const rtl::OUString& rCmd, const Reference< XFrame >& rFrame ) :
+ Control( pParent, WB_TABSTOP ),
+ maImage ( this ),
+ maField ( this, rCmd, rFrame )
+{
+ ResId aResId( ImplGetRID( rCmd, false ), DIALOG_MGR() ) ;
+ Image aImage( aResId );
+
+ ResId aResIdHC( ImplGetRID( rCmd, true ), DIALOG_MGR() ) ;
+ Image aImageHC( aResIdHC );
+
+ Size aImgSize( aImage.GetSizePixel() );
+ Size aFldSize( maField.GetSizePixel() );
+ long nFldY, nImgY;
+
+ maImage.SetImage( aImage );
+ maImage.SetModeImage( aImageHC, BMP_COLOR_HIGHCONTRAST );
+ maImage.SetSizePixel( aImgSize );
+ // we want to see the backbround of the toolbox, not of the FixedImage or Control
+ maImage.SetBackground( Wallpaper( COL_TRANSPARENT ) );
+ SetBackground( Wallpaper( COL_TRANSPARENT ) );
+
+ if( aImgSize.Height() > aFldSize.Height() )
+ nImgY = 0, nFldY = ( aImgSize.Height() - aFldSize.Height() ) >> 1;
+ else
+ nFldY = 0, nImgY = ( aFldSize.Height() - aImgSize.Height() ) >> 1;
+
+ long nOffset = SYMBOL_TO_FIELD_OFFSET / 2;
+ maImage.SetPosPixel( Point( nOffset, nImgY ) );
+ maField.SetPosPixel( Point( aImgSize.Width() + SYMBOL_TO_FIELD_OFFSET, nFldY ) );
+ SetSizePixel( Size( aImgSize.Width() + aFldSize.Width() + SYMBOL_TO_FIELD_OFFSET + nOffset,
+ Max( aImgSize.Height(), aFldSize.Height() ) ) );
+
+ SetBackground( Wallpaper() ); // transparent background
+
+ maImage.Show();
+
+ maField.SetHelpId( nSlotId );
+ maField.SetSmartHelpId( SmartId( rCmd ));
+ maField.Show();
+}
+
+// -----------------------------------------------------------------------------
+
+ImplGrafControl::~ImplGrafControl()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void ImplGrafControl::GetFocus()
+{
+ maField.GrabFocus();
+}
+
+// -----------------------
+// - ImplGrafModeControl -
+// -----------------------
+
+class ImplGrafModeControl : public ListBox
+{
+ using Window::Update;
+private:
+ USHORT mnCurPos;
+ Reference< XFrame > mxFrame;
+
+ virtual void Select();
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual long Notify( NotifyEvent& rNEvt );
+ void ImplReleaseFocus();
+
+public:
+
+ ImplGrafModeControl( Window* pParent, const Reference< XFrame >& rFrame );
+ ~ImplGrafModeControl();
+
+ void Update( const SfxPoolItem* pItem );
+};
+
+// -----------------------------------------------------------------------------
+
+ImplGrafModeControl::ImplGrafModeControl( Window* pParent, const Reference< XFrame >& rFrame ) :
+ ListBox( pParent, WB_BORDER | WB_DROPDOWN | WB_AUTOHSCROLL ),
+ mnCurPos( 0 ),
+ mxFrame( rFrame )
+{
+ SetSizePixel( Size( 100, 260 ) );
+
+ InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_STANDARD ) );
+ InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_GREYS ) );
+ InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_MONO ) );
+ InsertEntry( SVX_RESSTR( RID_SVXSTR_GRAFMODE_WATERMARK ) );
+
+ Show();
+}
+
+// -----------------------------------------------------------------------
+
+ImplGrafModeControl::~ImplGrafModeControl()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void ImplGrafModeControl::Select()
+{
+ if ( !IsTravelSelect() )
+ {
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GrafMode" ));
+ aArgs[0].Value = makeAny( sal_Int16( GetSelectEntryPos() ));
+
+ /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
+ This instance may be deleted in the meantime (i.e. when a dialog is opened
+ while in Dispatch()), accessing members will crash in this case. */
+ ImplReleaseFocus();
+
+ SfxToolBoxControl::Dispatch(
+ Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GrafMode" )),
+ aArgs );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+long ImplGrafModeControl::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nType = rNEvt.GetType();
+
+ if( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
+ mnCurPos = GetSelectEntryPos();
+
+ return ListBox::PreNotify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+long ImplGrafModeControl::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = ListBox::Notify( rNEvt );
+
+ if( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+
+ switch( pKEvt->GetKeyCode().GetCode() )
+ {
+ case KEY_RETURN:
+ {
+ Select();
+ nHandled = 1;
+ }
+ break;
+
+ case KEY_ESCAPE:
+ {
+ SelectEntryPos( mnCurPos );
+ ImplReleaseFocus();
+ nHandled = 1;
+ }
+ break;
+ }
+ }
+
+ return nHandled;
+}
+
+// -----------------------------------------------------------------------
+
+void ImplGrafModeControl::ImplReleaseFocus()
+{
+ if( SfxViewShell::Current() )
+ {
+ Window* pShellWnd = SfxViewShell::Current()->GetWindow();
+
+ if( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ImplGrafModeControl::Update( const SfxPoolItem* pItem )
+{
+ if( pItem )
+ SelectEntryPos( ((SfxUInt16Item*)pItem)->GetValue() );
+ else
+ SetNoSelection();
+}
+
+// -----------------------
+// - ImplGrafFilterPopup -
+// -----------------------
+/*
+CD!!!
+class ImplGrafFilterPopup : public SfxPopupWindow
+{
+private:
+
+ SvxGrafFilterToolBoxControl* mpParent;
+ Reference< XConfigurableUIElement > m_xToolBar;
+// SfxToolBoxManager maTbxMgr;
+ ResId maResIdWin;
+ ResId maResIdTbx;
+ WindowAlign meTbxAlign;
+ Link maSelectHdl;
+
+ DECL_LINK( TbxSelectHdl, void* );
+
+public:
+ ImplGrafFilterPopup( USHORT nId, SvxGrafFilterToolBoxControl* pParent,
+ WindowAlign eAlign,
+ const ResId& rResIdWin, const ResId& rResIdTbx,
+ SfxBindings& rBindings );
+ ~ImplGrafFilterPopup();
+
+ virtual SfxPopupWindow* Clone() const;
+ virtual void PopupModeEnd();
+
+ void StartSelection() { maTbxMgr.GetToolBox().StartSelection(); }
+ void Update();
+};
+
+// -----------------------------------------------------------------------------
+
+ImplGrafFilterPopup::ImplGrafFilterPopup( USHORT nId, SvxGrafFilterToolBoxControl* pParent,
+ WindowAlign eAlign,
+ const ResId& rResIdWin, const ResId& rResIdTbx ) :
+ SfxPopupWindow ( nId, rResIdWin ),
+ mpParent ( pParent ),
+ maTbxMgr ( this, GetBindings(), rResIdTbx ),
+ maResIdWin ( rResIdWin ),
+ maResIdTbx ( rResIdTbx ),
+ meTbxAlign ( eAlign )
+{
+ maTbxMgr.UseDefault();
+
+ maSelectHdl = maTbxMgr.GetToolBox().GetSelectHdl();
+ maTbxMgr.GetToolBox().SetSelectHdl( LINK( this, ImplGrafFilterPopup, TbxSelectHdl ) );
+
+ FreeResource();
+
+ const Size aSize( maTbxMgr.CalcWindowSizePixel() );
+ maTbxMgr.SetPosSizePixel( Point(), aSize );
+ SetOutputSizePixel( aSize );
+}
+
+// -----------------------------------------------------------------------------
+
+ImplGrafFilterPopup::~ImplGrafFilterPopup()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SfxPopupWindow* ImplGrafFilterPopup::Clone() const
+{
+ return( new ImplGrafFilterPopup( GetId(), mpParent, meTbxAlign,
+ maResIdWin, maResIdTbx,
+ (SfxBindings&) GetBindings() ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void ImplGrafFilterPopup::Update()
+{
+ ToolBox* pBox = &maTbxMgr.GetToolBox();
+ maTbxMgr.Activate( pBox );
+ maTbxMgr.Deactivate( pBox );
+}
+
+// -----------------------------------------------------------------------------
+
+void ImplGrafFilterPopup::PopupModeEnd()
+{
+ maTbxMgr.GetToolBox().EndSelection();
+ SfxPopupWindow::PopupModeEnd();
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( ImplGrafFilterPopup, TbxSelectHdl, void*, EMPTYARG )
+{
+ const USHORT nSlotId = maTbxMgr.GetToolBox().GetCurItemId();
+
+ if( IsInPopupMode() )
+ EndPopupMode();
+
+ GetBindings().GetDispatcher()->Execute( nSlotId, SFX_CALLMODE_ASYNCHRON );
+
+ return 0;
+}
+*/
+// -------------------------------
+// - SvxGrafFilterToolBoxControl -
+// -------------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxGrafFilterToolBoxControl, TbxImageItem );
+
+// -----------------------------------------------------------------------------
+
+SvxGrafFilterToolBoxControl::SvxGrafFilterToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+}
+
+// -----------------------------------------------------------------------------
+
+SvxGrafFilterToolBoxControl::~SvxGrafFilterToolBoxControl()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SvxGrafFilterToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* )
+{
+ GetToolBox().EnableItem( GetId(), ( eState != SFX_ITEM_DISABLED ) );
+}
+
+// -----------------------------------------------------------------------------
+
+SfxPopupWindowType SvxGrafFilterToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+// -----------------------------------------------------------------------------
+
+SfxPopupWindow* SvxGrafFilterToolBoxControl::CreatePopupWindow()
+{
+ rtl::OUString aSubTbxResName(
+ RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/graffilterbar" ) );
+ createAndPositionSubToolBar( aSubTbxResName );
+
+ return NULL;
+}
+
+// -------------------------
+// - SvxGrafToolBoxControl -
+// -------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxGrafToolBoxControl, SfxVoidItem );
+
+// -----------------------------------------------------------------------------
+
+SvxGrafToolBoxControl::SvxGrafToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+}
+
+// -----------------------------------------------------------------------------
+
+SvxGrafToolBoxControl::~SvxGrafToolBoxControl()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SvxGrafToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ ImplGrafControl* pCtrl = (ImplGrafControl*) GetToolBox().GetItemWindow( GetId() );
+ DBG_ASSERT( pCtrl, "Control not found" );
+
+ if( eState == SFX_ITEM_DISABLED )
+ {
+ pCtrl->Disable();
+ pCtrl->SetText( String() );
+ }
+ else
+ {
+ pCtrl->Enable();
+
+ if( eState == SFX_ITEM_AVAILABLE )
+ pCtrl->Update( pState );
+ else
+ pCtrl->Update( NULL );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+Window* SvxGrafToolBoxControl::CreateItemWindow( Window *pParent )
+{
+ return( new ImplGrafControl( pParent, GetSlotId(), m_aCommandURL, m_xFrame ) );
+}
+
+// ----------------------------
+// - SvxGrafRedToolBoxControl -
+// ----------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxGrafRedToolBoxControl, SfxInt16Item );
+
+// -----------------------------------------------------------------------------
+
+SvxGrafRedToolBoxControl::SvxGrafRedToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SvxGrafToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+// ------------------------------
+// - SvxGrafGreenToolBoxControl -
+// ------------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxGrafGreenToolBoxControl, SfxInt16Item );
+
+// -----------------------------------------------------------------------------
+
+SvxGrafGreenToolBoxControl::SvxGrafGreenToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SvxGrafToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+// -----------------------------
+// - SvxGrafBlueToolBoxControl -
+// -----------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxGrafBlueToolBoxControl, SfxInt16Item );
+
+// -----------------------------------------------------------------------------
+
+SvxGrafBlueToolBoxControl::SvxGrafBlueToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SvxGrafToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+// ----------------------------------
+// - SvxGrafLuminanceToolBoxControl -
+// ----------------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxGrafLuminanceToolBoxControl, SfxInt16Item );
+
+// -----------------------------------------------------------------------------
+
+SvxGrafLuminanceToolBoxControl::SvxGrafLuminanceToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SvxGrafToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+// ----------------------------------
+// - SvxGrafContrastToolBoxControl -
+// ----------------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxGrafContrastToolBoxControl, SfxInt16Item );
+
+// -----------------------------------------------------------------------------
+
+SvxGrafContrastToolBoxControl::SvxGrafContrastToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SvxGrafToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+// ------------------------------
+// - SvxGrafGammaToolBoxControl -
+// ------------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxGrafGammaToolBoxControl, SfxUInt32Item );
+
+// -----------------------------------------------------------------------------
+
+SvxGrafGammaToolBoxControl::SvxGrafGammaToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SvxGrafToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+// -------------------------------------
+// - SvxGrafTransparenceToolBoxControl -
+// -------------------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxGrafTransparenceToolBoxControl, SfxUInt16Item );
+
+// -----------------------------------------------------------------------------
+
+SvxGrafTransparenceToolBoxControl::SvxGrafTransparenceToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SvxGrafToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+// -----------------------------
+// - SvxGrafModeToolBoxControl -
+// -----------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxGrafModeToolBoxControl, SfxUInt16Item );
+
+// -----------------------------------------------------------------------------
+
+SvxGrafModeToolBoxControl::SvxGrafModeToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SvxGrafModeToolBoxControl::~SvxGrafModeToolBoxControl()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SvxGrafModeToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ ImplGrafModeControl* pCtrl = (ImplGrafModeControl*) GetToolBox().GetItemWindow( GetId() );
+ DBG_ASSERT( pCtrl, "Control not found" );
+
+ if( eState == SFX_ITEM_DISABLED )
+ {
+ pCtrl->Disable();
+ pCtrl->SetText( String() );
+ }
+ else
+ {
+ pCtrl->Enable();
+
+ if( eState == SFX_ITEM_AVAILABLE )
+ pCtrl->Update( pState );
+ else
+ pCtrl->Update( NULL );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+Window* SvxGrafModeToolBoxControl::CreateItemWindow( Window *pParent )
+{
+ return( new ImplGrafModeControl( pParent, m_xFrame ) );
+}
+
+// ---------------------
+// - SvxGrafAttrHelper -
+// ---------------------
+
+void SvxGrafAttrHelper::ExecuteGrafAttr( SfxRequest& rReq, SdrView& rView )
+{
+ SfxItemPool& rPool = rView.GetModel()->GetItemPool();
+ SfxItemSet aSet( rPool, SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST );
+
+ const bool bUndo = rView.IsUndoEnabled();
+
+ String aUndoStr;
+
+ if( bUndo )
+ {
+ aUndoStr = rView.GetDescriptionOfMarkedObjects();
+ aUndoStr.Append( sal_Unicode(' ') );
+ }
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ USHORT nSlot = rReq.GetSlot();
+
+ if( !pArgs || SFX_ITEM_SET != pArgs->GetItemState( nSlot, FALSE, &pItem ))
+ pItem = 0;
+
+ switch( nSlot )
+ {
+ case SID_ATTR_GRAF_RED:
+ {
+ if( pItem )
+ {
+ aSet.Put( SdrGrafRedItem( ((SfxInt16Item*)pItem)->GetValue() ));
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFRED ) ) );
+ }
+ }
+ break;
+
+ case SID_ATTR_GRAF_GREEN:
+ {
+ if( pItem )
+ {
+ aSet.Put( SdrGrafGreenItem( ((SfxInt16Item*)pItem)->GetValue() ));
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFGREEN ) ) );
+ }
+ }
+ break;
+
+ case SID_ATTR_GRAF_BLUE:
+ {
+ if( pItem )
+ {
+ aSet.Put( SdrGrafBlueItem( ((SfxInt16Item*)pItem)->GetValue() ));
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFBLUE ) ) );
+ }
+ }
+ break;
+
+ case SID_ATTR_GRAF_LUMINANCE:
+ {
+ if( pItem )
+ {
+ aSet.Put( SdrGrafLuminanceItem( ((SfxInt16Item*)pItem)->GetValue() ));
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFLUMINANCE ) ) );
+ }
+ }
+ break;
+
+ case SID_ATTR_GRAF_CONTRAST:
+ {
+ if( pItem )
+ {
+ aSet.Put( SdrGrafContrastItem( ((SfxInt16Item*)pItem)->GetValue() ));
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFCONTRAST ) ) );
+ }
+ }
+ break;
+
+ case SID_ATTR_GRAF_GAMMA:
+ {
+ if( pItem )
+ {
+ aSet.Put( SdrGrafGamma100Item( ((SfxUInt32Item*)pItem)->GetValue() ));
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFGAMMA ) ) );
+ }
+ }
+ break;
+
+ case SID_ATTR_GRAF_TRANSPARENCE:
+ {
+ if( pItem )
+ {
+ aSet.Put( SdrGrafTransparenceItem( ((SfxUInt16Item*)pItem)->GetValue() ));
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFTRANSPARENCY ) ) );
+ }
+ }
+ break;
+
+ case SID_ATTR_GRAF_MODE:
+ {
+ if( pItem )
+ {
+ aSet.Put( SdrGrafModeItem( (GraphicDrawMode) ((SfxUInt16Item*)pItem)->GetValue() ));
+ if( bUndo )
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFMODE ) ) );
+ }
+ }
+ break;
+
+ case( SID_ATTR_GRAF_CROP ):
+ {
+ const SdrMarkList& rMarkList = rView.GetMarkedObjectList();
+
+ if( 0 < rMarkList.GetMarkCount() )
+ {
+ SdrGrafObj* pObj = (SdrGrafObj*) rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) &&
+ ( pObj->GetGraphicType() != GRAPHIC_NONE ) &&
+ ( pObj->GetGraphicType() != GRAPHIC_DEFAULT ) )
+ {
+ SfxItemSet aGrfAttr( rPool, SDRATTR_GRAFCROP, SDRATTR_GRAFCROP, 0 );
+ const SfxMapUnit eOldMetric = rPool.GetMetric( 0 );
+ const MapMode aMap100( MAP_100TH_MM );
+ const MapMode aMapTwip( MAP_TWIP );
+
+ aGrfAttr.Put(pObj->GetMergedItemSet());
+ rPool.SetDefaultMetric( SFX_MAPUNIT_TWIP );
+
+ SfxItemSet aCropDlgAttr( rPool,
+ SDRATTR_GRAFCROP, SDRATTR_GRAFCROP,
+ SID_ATTR_GRAF_GRAPHIC, SID_ATTR_GRAF_GRAPHIC,
+ SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
+ SID_ATTR_GRAF_FRMSIZE, SID_ATTR_GRAF_FRMSIZE,
+ SID_ATTR_GRAF_CROP, SID_ATTR_GRAF_CROP, 0 );
+
+ aCropDlgAttr.Put( SvxBrushItem( pObj->GetGraphic(), GPOS_MM, SID_ATTR_GRAF_GRAPHIC ) );
+ aCropDlgAttr.Put( SvxSizeItem( SID_ATTR_PAGE_SIZE,
+ Size( OutputDevice::LogicToLogic(
+ Size( 200000, 200000 ), aMap100, aMapTwip ) ) ) );
+ aCropDlgAttr.Put( SvxSizeItem( SID_ATTR_GRAF_FRMSIZE, OutputDevice::LogicToLogic(
+ pObj->GetLogicRect().GetSize(), aMap100, aMapTwip ) ) );
+
+ const SdrGrafCropItem& rCrop = (const SdrGrafCropItem&) aGrfAttr.Get( SDRATTR_GRAFCROP );
+ Size aLTSize( OutputDevice::LogicToLogic(
+ Size( rCrop.GetLeft(), rCrop.GetTop() ), aMap100, aMapTwip ) );
+ Size aRBSize( OutputDevice::LogicToLogic(
+ Size( rCrop.GetRight(), rCrop.GetBottom() ), aMap100, aMapTwip ) );
+
+ aCropDlgAttr.Put( SdrGrafCropItem( aLTSize.Width(), aLTSize.Height(),
+ aRBSize.Width(), aRBSize.Height() ) );
+
+ SfxSingleTabDialog aCropDialog( SfxViewShell::Current() ? SfxViewShell::Current()->GetWindow() : NULL,
+ aCropDlgAttr, 950 );
+ const String aCropStr = SVX_RESSTR( RID_SVXSTR_GRAFCROP );
+
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet error!");
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_GRFCROP );
+ DBG_ASSERT(fnCreatePage, "Dialogdiet error!");
+ SfxTabPage* pTabPage = (*fnCreatePage)( &aCropDialog, aCropDlgAttr );
+
+ pTabPage->SetText( aCropStr );
+ aCropDialog.SetTabPage( pTabPage );
+
+ if( aCropDialog.Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutAttr = aCropDialog.GetOutputItemSet();
+
+ if( pOutAttr )
+ {
+ aUndoStr.Append( String( SVX_RESSTR( RID_SVXSTR_UNDO_GRAFCROP ) ) );
+
+ // set crop attributes
+ if( SFX_ITEM_SET <= pOutAttr->GetItemState( SDRATTR_GRAFCROP ) )
+ {
+ const SdrGrafCropItem& rNewCrop = (const SdrGrafCropItem&) pOutAttr->Get( SDRATTR_GRAFCROP );
+
+ aLTSize = OutputDevice::LogicToLogic( Size( rNewCrop.GetLeft(), rNewCrop.GetTop() ), aMapTwip, aMap100 );
+ aRBSize = OutputDevice::LogicToLogic( Size( rNewCrop.GetRight(), rNewCrop.GetBottom() ), aMapTwip, aMap100 );
+ aSet.Put( SdrGrafCropItem( aLTSize.Width(), aLTSize.Height(), aRBSize.Width(), aRBSize.Height() ) );
+ }
+
+ // set new logic rect
+ if( SFX_ITEM_SET <= pOutAttr->GetItemState( SID_ATTR_GRAF_FRMSIZE ) )
+ {
+ Point aNewOrigin( pObj->GetLogicRect().TopLeft() );
+ const Size& rGrfSize = ( (const SvxSizeItem&) pOutAttr->Get( SID_ATTR_GRAF_FRMSIZE ) ).GetSize();
+ Size aNewGrfSize( OutputDevice::LogicToLogic( rGrfSize, aMapTwip, aMap100 ) );
+ Size aOldGrfSize( pObj->GetLogicRect().GetSize() );
+
+ Rectangle aNewRect( aNewOrigin, aNewGrfSize );
+ Point aOffset( (aNewGrfSize.Width() - aOldGrfSize.Width()) >> 1,
+ (aNewGrfSize.Height() - aOldGrfSize.Height()) >> 1 );
+
+ // #106181# rotate snap rect before setting it
+ const GeoStat& aGeo = pObj->GetGeoStat();
+
+ if (aGeo.nDrehWink!=0 || aGeo.nShearWink!=0)
+ {
+ Polygon aPol(aNewRect);
+
+ // also transform origin offset
+ if (aGeo.nShearWink!=0)
+ {
+ ShearPoly(aPol,
+ aNewRect.TopLeft(),
+ aGeo.nTan);
+ ShearPoint(aOffset, Point(0,0), aGeo.nTan);
+ }
+ if (aGeo.nDrehWink!=0)
+ {
+ RotatePoly(aPol,
+ aNewRect.TopLeft(),
+ aGeo.nSin,aGeo.nCos);
+ RotatePoint(aOffset, Point(0,0), aGeo.nSin,aGeo.nCos);
+ }
+
+ // apply offset
+ aPol.Move( -aOffset.X(), -aOffset.Y() );
+ aNewRect=aPol.GetBoundRect();
+ }
+ else
+ {
+ aNewRect.Move( -aOffset.X(), -aOffset.Y() );
+ }
+
+ if( !aSet.Count() )
+ rView.SetMarkedObjRect( aNewRect );
+ else
+ {
+ if( bUndo )
+ {
+ rView.BegUndo( aUndoStr );
+ rView.AddUndo( rView.GetModel()->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
+ }
+ pObj->SetSnapRect( aNewRect );
+ rView.SetAttributes( aSet );
+
+ if( bUndo )
+ rView.EndUndo();
+ aSet.ClearItem();
+ }
+ }
+ }
+ }
+
+ rPool.SetDefaultMetric( eOldMetric );
+ }
+ }
+ }
+ break;
+
+ case SID_COLOR_SETTINGS:
+ {
+ svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
+ aToolboxAccess.toggleToolbox();
+ rReq.Done();
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ if( aSet.Count() )
+ {
+ if( bUndo )
+ rView.BegUndo( aUndoStr );
+
+ rView.SetAttributes( aSet );
+
+ if( bUndo )
+ rView.EndUndo();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView& rView )
+{
+ SfxItemPool& rPool = rView.GetModel()->GetItemPool();
+ SfxItemSet aAttrSet( rPool );
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+
+ rView.GetAttributes( aAttrSet );
+
+ while( nWhich )
+ {
+ USHORT nSlotId = SfxItemPool::IsWhich( nWhich ) ? rPool.GetSlotId( nWhich ) : nWhich;
+
+ switch( nSlotId )
+ {
+ case( SID_ATTR_GRAF_MODE ):
+ {
+ if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFMODE ) )
+ {
+ rSet.Put( SfxUInt16Item( nSlotId,
+ sal::static_int_cast< UINT16 >( ITEMVALUE( aAttrSet, SDRATTR_GRAFMODE, SdrGrafModeItem ) ) ) );
+ }
+ }
+ break;
+
+ case( SID_ATTR_GRAF_RED ):
+ {
+ if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFRED ) )
+ {
+ rSet.Put( SfxInt16Item( nSlotId,
+ ITEMVALUE( aAttrSet, SDRATTR_GRAFRED, SdrGrafRedItem ) ) );
+ }
+ }
+ break;
+
+ case( SID_ATTR_GRAF_GREEN ):
+ {
+ if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGREEN ) )
+ {
+ rSet.Put( SfxInt16Item( nSlotId,
+ ITEMVALUE( aAttrSet, SDRATTR_GRAFGREEN, SdrGrafGreenItem ) ) );
+ }
+ }
+ break;
+
+ case( SID_ATTR_GRAF_BLUE ):
+ {
+ if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFBLUE ) )
+ {
+ rSet.Put( SfxInt16Item( nSlotId,
+ ITEMVALUE( aAttrSet, SDRATTR_GRAFBLUE, SdrGrafBlueItem ) ) );
+ }
+ }
+ break;
+
+ case( SID_ATTR_GRAF_LUMINANCE ):
+ {
+ if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFLUMINANCE ) )
+ {
+ rSet.Put( SfxInt16Item( nSlotId,
+ ITEMVALUE( aAttrSet, SDRATTR_GRAFLUMINANCE, SdrGrafLuminanceItem ) ) );
+ }
+ }
+ break;
+
+ case( SID_ATTR_GRAF_CONTRAST ):
+ {
+ if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFCONTRAST ) )
+ {
+ rSet.Put( SfxInt16Item( nSlotId,
+ ITEMVALUE( aAttrSet, SDRATTR_GRAFCONTRAST, SdrGrafContrastItem ) ) );
+ }
+ }
+ break;
+
+ case( SID_ATTR_GRAF_GAMMA ):
+ {
+ if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFGAMMA ) )
+ {
+ rSet.Put( SfxUInt32Item( nSlotId,
+ ITEMVALUE( aAttrSet, SDRATTR_GRAFGAMMA, SdrGrafGamma100Item ) ) );
+ }
+ }
+ break;
+
+ case( SID_ATTR_GRAF_TRANSPARENCE ):
+ {
+ if( SFX_ITEM_AVAILABLE <= aAttrSet.GetItemState( SDRATTR_GRAFTRANSPARENCE ) )
+ {
+ const SdrMarkList& rMarkList = rView.GetMarkedObjectList();
+ BOOL bEnable = TRUE;
+
+ for( USHORT i = 0, nCount = (USHORT) rMarkList.GetMarkCount();
+ ( i < nCount ) && bEnable; i++ )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( !pObj || !pObj->ISA( SdrGrafObj ) ||
+ ( (SdrGrafObj*) pObj )->HasGDIMetaFile() ||
+ ( (SdrGrafObj*) pObj )->IsAnimated() )
+ {
+ bEnable = FALSE;
+ }
+ }
+
+ if( bEnable )
+ rSet.Put( SfxUInt16Item( nSlotId,
+ ITEMVALUE( aAttrSet, SDRATTR_GRAFTRANSPARENCE, SdrGrafTransparenceItem ) ) );
+ else
+ rSet.DisableItem( SID_ATTR_GRAF_TRANSPARENCE );
+ }
+ }
+ break;
+
+ case( SID_ATTR_GRAF_CROP ):
+ {
+ const SdrMarkList& rMarkList = rView.GetMarkedObjectList();
+ BOOL bDisable = TRUE;
+
+ if( 1 == rMarkList.GetMarkCount() )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) )
+ {
+ SdrGrafObj* pGrafObj = (SdrGrafObj*) pObj;
+
+ if( ( pGrafObj->GetGraphicType() != GRAPHIC_NONE ) &&
+ ( pGrafObj->GetGraphicType() != GRAPHIC_DEFAULT ) )
+ {
+ bDisable = FALSE;
+ }
+ }
+ }
+
+ if( bDisable )
+ rSet.DisableItem( nSlotId );
+ }
+ break;
+
+ case SID_COLOR_SETTINGS :
+ {
+ svx::ToolboxAccess aToolboxAccess( TOOLBOX_NAME );
+ rSet.Put( SfxBoolItem( nWhich, aToolboxAccess.isToolboxVisible() ) );
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/grafctrl.hrc b/svx/source/tbxctrls/grafctrl.hrc
new file mode 100644
index 000000000000..10eafae0a6b8
--- /dev/null
+++ b/svx/source/tbxctrls/grafctrl.hrc
@@ -0,0 +1,28 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#define TBX_GRFFILTER 1
diff --git a/svx/source/tbxctrls/grafctrl.src b/svx/source/tbxctrls/grafctrl.src
new file mode 100644
index 000000000000..a0d437ff9c34
--- /dev/null
+++ b/svx/source/tbxctrls/grafctrl.src
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "grafctrl.hrc"
+#include <svx/dialogs.hrc>
+#include "helpid.hrc"
+#include <svx/svxids.hrc>
+
+FloatingWindow RID_SVXTBX_GRFFILTER
+{
+ HelpId = HID_GRFFILTER;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Text [ en-US ] = "Filters" ;
+ ToolBox TBX_GRFFILTER
+ {
+ SVLook = TRUE ;
+ MenuStrings = TRUE ;
+ Align = BOXALIGN_TOP;
+ LineCount = 3;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_INVERT ;
+ HelpID = HID_GRFFILTER_INVERT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_SMOOTH ;
+ HelpID = HID_GRFFILTER_SMOOTH ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_SHARPEN ;
+ HelpID = HID_GRFFILTER_SHARPEN ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_REMOVENOISE ;
+ HelpID = HID_GRFFILTER_REMOVENOISE ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_BREAK ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_SOLARIZE ;
+ HelpId = HID_GRFFILTER_SOLARIZE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_SEPIA ;
+ HelpId = HID_GRFFILTER_SEPIA ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_POSTER ;
+ HelpId = HID_GRFFILTER_POSTER ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_POPART ;
+ HelpId = HID_GRFFILTER_POPART ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_BREAK ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_SOBEL ;
+ HelpId = HID_GRFFILTER_SOBEL ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_EMBOSS ;
+ HelpId = HID_GRFFILTER_EMBOSS ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER_MOSAIC ;
+ HelpId = HID_GRFFILTER_MOSAIC ;
+ };
+ };
+ };
+};
+
+// -----------
+// - Strings -
+// -----------
+
+String RID_SVXSTR_UNDO_GRAFMODE
+{
+ Text [ en-US ] = "Graphics Mode";
+};
+String RID_SVXSTR_UNDO_GRAFRED
+{
+ Text [ en-US ] = "Red";
+};
+String RID_SVXSTR_UNDO_GRAFGREEN
+{
+ Text [ en-US ] = "Green";
+};
+String RID_SVXSTR_UNDO_GRAFBLUE
+{
+ Text [ en-US ] = "Blue";
+};
+String RID_SVXSTR_UNDO_GRAFLUMINANCE
+{
+ Text [ en-US ] = "Brightness";
+};
+String RID_SVXSTR_UNDO_GRAFCONTRAST
+{
+ Text [ en-US ] = "Contrast";
+};
+String RID_SVXSTR_UNDO_GRAFGAMMA
+{
+ Text [ en-US ] = "Gamma";
+};
+String RID_SVXSTR_UNDO_GRAFTRANSPARENCY
+{
+ Text [ en-US ] = "Transparency";
+};
+String RID_SVXSTR_GRAFCROP
+{
+ Text [ en-US ] = "Crop";
+};
+
+// ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/tbxctrls/itemwin.cxx b/svx/source/tbxctrls/itemwin.cxx
new file mode 100644
index 000000000000..4a1bbd49f189
--- /dev/null
+++ b/svx/source/tbxctrls/itemwin.cxx
@@ -0,0 +1,828 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <tools/shl.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/module.hxx>
+#include <tools/urlobj.hxx>
+
+#define _SVX_ITEMWIN_CXX
+
+#include <vcl/svapp.hxx>
+
+#include <svx/dialogs.hrc>
+
+#define DELAY_TIMEOUT 100
+
+#include <svx/xlnclit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xtable.hxx>
+#include "drawitem.hxx"
+#include <svx/dialmgr.hxx>
+#include "dlgutil.hxx"
+#include <svx/itemwin.hxx>
+#include "linectrl.hxx"
+#include <svtools/colorcfg.hxx>
+
+#include "linectrl.hrc"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+
+#define LOGICAL_EDIT_HEIGHT 12
+//========================================================================
+// SvxLineBox
+//========================================================================
+
+SvxLineBox::SvxLineBox( Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) :
+ LineLB( pParent, nBits ),
+ meBmpMode ( GetSettings().GetStyleSettings().GetHighContrastMode() ? BMP_COLOR_HIGHCONTRAST : BMP_COLOR_NORMAL ),
+ nCurPos ( 0 ),
+ aLogicalSize(40,140),
+ bRelease ( TRUE ),
+ mpSh ( NULL ),
+ mxFrame ( rFrame )
+{
+ SetSizePixel( LogicToPixel( aLogicalSize, MAP_APPFONT ));
+ Show();
+
+ aDelayTimer.SetTimeout( DELAY_TIMEOUT );
+ aDelayTimer.SetTimeoutHdl( LINK( this, SvxLineBox, DelayHdl_Impl ) );
+ aDelayTimer.Start();
+}
+
+// -----------------------------------------------------------------------
+
+SvxLineBox::~SvxLineBox()
+{
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxLineBox, DelayHdl_Impl, Timer *, EMPTYARG )
+{
+ if ( GetEntryCount() == 0 )
+ {
+ mpSh = SfxObjectShell::Current();
+ FillControl();
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineBox::Select()
+{
+ // Call the parent's Select() member to trigger accessibility events.
+ LineLB::Select();
+
+ if ( !IsTravelSelect() )
+ {
+ XLineStyle eXLS;
+ USHORT nPos = GetSelectEntryPos();
+// SfxDispatcher* pDisp = rBindings.GetDispatcher();
+ //DBG_ASSERT( pDisp, "invalid Dispatcher" );
+
+ switch ( nPos )
+ {
+ case 0:
+ eXLS = XLINE_NONE;
+ break;
+
+ case 1:
+ eXLS = XLINE_SOLID;
+ break;
+
+ default:
+ {
+ eXLS = XLINE_DASH;
+
+ if ( nPos != LISTBOX_ENTRY_NOTFOUND &&
+ SfxObjectShell::Current() &&
+ SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) )
+ {
+ // LineDashItem wird nur geschickt, wenn es auch einen Dash besitzt.
+ // Notify k"ummert sich darum!
+ SvxDashListItem aItem( *(const SvxDashListItem*)(
+ SfxObjectShell::Current()->GetItem( SID_DASH_LIST ) ) );
+ XLineDashItem aLineDashItem( GetSelectEntry(),
+ aItem.GetDashList()->GetDash( nPos - 2 )->GetDash() );
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineDash" ));
+ aLineDashItem.QueryValue ( a );
+ aArgs[0].Value = a;
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" )),
+ aArgs );
+// pDisp->Execute( SID_ATTR_LINE_DASH, SFX_CALLMODE_RECORD, &aLineDashItem, 0L );
+ }
+ }
+ break;
+ }
+
+ XLineStyleItem aLineStyleItem( eXLS );
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XLineStyle" ));
+ aLineStyleItem.QueryValue ( a );
+ aArgs[0].Value = a;
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:XLineStyle" )),
+ aArgs );
+// pDisp->Execute( SID_ATTR_LINE_STYLE, SFX_CALLMODE_RECORD, &aLineStyleItem, 0L );
+
+ nCurPos = GetSelectEntryPos();
+ ReleaseFocus_Impl();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+long SvxLineBox::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nType = rNEvt.GetType();
+
+ switch(nType)
+ {
+ case EVENT_MOUSEBUTTONDOWN:
+ case EVENT_GETFOCUS:
+ nCurPos = GetSelectEntryPos();
+ break;
+ case EVENT_LOSEFOCUS:
+ SelectEntryPos(nCurPos);
+ break;
+ case EVENT_KEYINPUT:
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ if( pKEvt->GetKeyCode().GetCode() == KEY_TAB)
+ {
+ bRelease = FALSE;
+ Select();
+ }
+ }
+ break;
+ }
+ return LineLB::PreNotify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+long SvxLineBox::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = LineLB::Notify( rNEvt );
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+
+ switch ( pKEvt->GetKeyCode().GetCode() )
+ {
+ case KEY_RETURN:
+ Select();
+ nHandled = 1;
+ break;
+
+ case KEY_ESCAPE:
+ SelectEntryPos( nCurPos );
+ ReleaseFocus_Impl();
+ nHandled = 1;
+ break;
+ }
+ }
+ return nHandled;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineBox::ReleaseFocus_Impl()
+{
+ if(!bRelease)
+ {
+ bRelease = TRUE;
+ return;
+ }
+
+ if( SfxViewShell::Current() )
+ {
+ Window* pShellWnd = SfxViewShell::Current()->GetWindow();
+
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+}
+/* -----------------------------08.03.2002 15:39------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxLineBox::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
+ Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
+ SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
+ }
+
+ LineLB::DataChanged( rDCEvt );
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ BmpColorMode eMode = GetSettings().GetStyleSettings().GetHighContrastMode() ? BMP_COLOR_HIGHCONTRAST : BMP_COLOR_NORMAL;
+ if( eMode != meBmpMode )
+ {
+ meBmpMode = eMode;
+ FillControl();
+ }
+ }
+}
+
+void SvxLineBox::FillControl()
+{
+ FillStyles();
+ if ( !mpSh )
+ mpSh = SfxObjectShell::Current();
+
+ if( mpSh )
+ {
+ const SvxDashListItem* pItem = (const SvxDashListItem*)( mpSh->GetItem( SID_DASH_LIST ) );
+ if ( pItem )
+ Fill( pItem->GetDashList() );
+ }
+
+
+// rBindings.Invalidate( SID_ATTR_LINE_DASH );
+}
+//========================================================================
+// SvxColorBox
+//========================================================================
+
+SvxColorBox::SvxColorBox(
+ Window* pParent,
+ const ::rtl::OUString& rCommand,
+ const Reference< XFrame >& rFrame,
+ WinBits nBits ) :
+ ColorLB( pParent, nBits ),
+ nCurPos ( 0 ),
+ aLogicalSize(45,80),
+ bRelease ( TRUE ),
+ maCommand ( rCommand ),
+ mxFrame ( rFrame )
+{
+ SetSizePixel( LogicToPixel( aLogicalSize , MAP_APPFONT));
+ Show();
+
+ SfxObjectShell* pSh = SfxObjectShell::Current();
+
+ if ( pSh )
+ {
+ const SvxColorTableItem* pItem =
+ (const SvxColorTableItem*)( pSh->GetItem( SID_COLOR_TABLE ) );
+ if(pItem)
+ Fill( pItem->GetColorTable() );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxColorBox, DelayHdl_Impl, Timer *, EMPTYARG )
+{
+ SfxObjectShell* pSh = SfxObjectShell::Current();
+
+ if ( pSh )
+ {
+ const SvxColorTableItem* pItem = (const SvxColorTableItem*)( pSh->GetItem( SID_COLOR_TABLE ) );
+ if ( pItem )
+ Fill( pItem->GetColorTable() );
+// rBindings.Invalidate( nId );
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SvxColorBox::~SvxColorBox()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxColorBox::Update( const XLineColorItem* pItem )
+{
+ if ( pItem )
+ SelectEntry( pItem->GetColorValue() );
+ else
+ SetNoSelection();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxColorBox::Select()
+{
+ // OJ: base class call needed here because otherwise no event is send for accessibility
+ ColorLB::Select();
+ if ( !IsTravelSelect() )
+ {
+ XLineColorItem aLineColorItem( GetSelectEntry(), GetSelectEntryColor() );
+
+ INetURLObject aObj( maCommand );
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = aObj.GetURLPath();
+ aLineColorItem.QueryValue( a );
+ aArgs[0].Value = a;
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
+ maCommand,
+ aArgs );
+// rBindings.GetDispatcher()->Execute( nId, SFX_CALLMODE_RECORD, &aLineColorItem, 0L );
+
+ nCurPos = GetSelectEntryPos();
+ ReleaseFocus_Impl();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+long SvxColorBox::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nType = rNEvt.GetType();
+
+ switch(nType)
+ {
+ case EVENT_MOUSEBUTTONDOWN:
+ case EVENT_GETFOCUS:
+ nCurPos = GetSelectEntryPos();
+ break;
+ case EVENT_LOSEFOCUS:
+ SelectEntryPos(nCurPos);
+ break;
+ case EVENT_KEYINPUT:
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+
+ if( pKEvt->GetKeyCode().GetCode() == KEY_TAB)
+ {
+ bRelease = FALSE;
+ Select();
+ }
+ }
+ }
+
+ return ColorLB::PreNotify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+long SvxColorBox::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = ColorLB::Notify( rNEvt );
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+
+ switch ( pKEvt->GetKeyCode().GetCode() )
+ {
+ case KEY_RETURN:
+ Select();
+ nHandled = 1;
+ break;
+
+ case KEY_ESCAPE:
+ SelectEntryPos( nCurPos );
+ ReleaseFocus_Impl();
+ nHandled = 1;
+ break;
+ }
+ }
+ return nHandled;
+}
+/* -----------------------------08.03.2002 15:35------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxColorBox::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
+ Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
+ SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
+ }
+
+ ColorLB::DataChanged( rDCEvt );
+}
+// -----------------------------------------------------------------------
+
+void SvxColorBox::ReleaseFocus_Impl()
+{
+ if(!bRelease)
+ {
+ bRelease = TRUE;
+ return;
+ }
+
+ if( SfxViewShell::Current() )
+ {
+ Window* pShellWnd = SfxViewShell::Current()->GetWindow();
+
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+}
+
+//========================================================================
+// SvxMetricField
+//========================================================================
+
+SvxMetricField::SvxMetricField(
+ Window* pParent, const Reference< XFrame >& rFrame, WinBits nBits ) :
+ MetricField( pParent, nBits ),
+ aCurTxt( String() ),
+ mxFrame( rFrame )
+{
+ Size aSize = Size(GetTextWidth( String::CreateFromAscii("99,99mm") ),GetTextHeight());
+ aSize.Width() += 20;
+ aSize.Height() += 6;
+ SetSizePixel( aSize );
+ aLogicalSize = PixelToLogic(aSize, MAP_APPFONT);
+ SetUnit( FUNIT_MM );
+ SetDecimalDigits( 2 );
+ SetMax( 5000 );
+ SetMin( 0 );
+ SetLast( 5000 );
+ SetFirst( 0 );
+
+ eDlgUnit = SfxModule::GetCurrentFieldUnit();
+ SetFieldUnit( *this, eDlgUnit, FALSE );
+ Show();
+}
+
+// -----------------------------------------------------------------------
+
+SvxMetricField::~SvxMetricField()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxMetricField::Update( const XLineWidthItem* pItem )
+{
+ if ( pItem )
+ {
+ if ( pItem->GetValue() != GetCoreValue( *this, ePoolUnit ) )
+ SetMetricValue( *this, pItem->GetValue(), ePoolUnit );
+ }
+ else
+ SetText( String() );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxMetricField::Modify()
+{
+ MetricField::Modify();
+ long nTmp = GetCoreValue( *this, ePoolUnit );
+ XLineWidthItem aLineWidthItem( nTmp );
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineWidth" ));
+ aLineWidthItem.QueryValue( a );
+ aArgs[0].Value = a;
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineWidth" )),
+ aArgs );
+// rBindings.GetDispatcher()->Execute( SID_ATTR_LINE_WIDTH, SFX_CALLMODE_RECORD, &aLineWidthItem, 0L );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxMetricField::ReleaseFocus_Impl()
+{
+ if( SfxViewShell::Current() )
+ {
+ Window* pShellWnd = SfxViewShell::Current()->GetWindow();
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxMetricField::Down()
+{
+ sal_Int64 nValue = GetValue();
+ nValue -= GetSpinSize();
+
+ // Um unter OS/2 einen Sprung auf Max zu verhindern
+ if ( nValue >= GetMin() )
+ MetricField::Down();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxMetricField::Up()
+{
+ MetricField::Up();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxMetricField::SetCoreUnit( SfxMapUnit eUnit )
+{
+ ePoolUnit = eUnit;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxMetricField::RefreshDlgUnit()
+{
+ FieldUnit eTmpUnit = SfxModule::GetCurrentFieldUnit();
+ if ( eDlgUnit != eTmpUnit )
+ {
+ eDlgUnit = eTmpUnit;
+ SetFieldUnit( *this, eDlgUnit, FALSE );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+long SvxMetricField::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nType = rNEvt.GetType();
+
+ if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
+ aCurTxt = GetText();
+
+ return MetricField::PreNotify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+long SvxMetricField::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = MetricField::Notify( rNEvt );
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ const KeyCode& rKey = pKEvt->GetKeyCode();
+ SfxViewShell* pSh = SfxViewShell::Current();
+
+ if ( rKey.GetModifier() && rKey.GetGroup() != KEYGROUP_CURSOR && pSh )
+ pSh->KeyInput( *pKEvt );
+ else
+ {
+ bool bHandled = false;
+
+ switch ( rKey.GetCode() )
+ {
+ case KEY_RETURN:
+ Reformat();
+ bHandled = true;
+ break;
+
+ case KEY_ESCAPE:
+ SetText( aCurTxt );
+ bHandled = true;
+ break;
+ }
+
+ if ( bHandled )
+ {
+ nHandled = 1;
+ Modify();
+ ReleaseFocus_Impl();
+ }
+ }
+ }
+ return nHandled;
+}
+/* -----------------------------08.03.2002 15:32------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxMetricField::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
+ }
+
+ MetricField::DataChanged( rDCEvt );
+}
+
+//========================================================================
+// SvxFillTypeBox
+//========================================================================
+
+SvxFillTypeBox::SvxFillTypeBox( Window* pParent, WinBits nBits ) :
+ FillTypeLB( pParent, nBits | WB_TABSTOP ),
+ nCurPos ( 0 ),
+ bSelect ( FALSE ),
+ bRelease(TRUE)
+{
+ SetSizePixel( LogicToPixel( Size(40, 40 ),MAP_APPFONT ));
+ Fill();
+ SelectEntryPos( XFILL_SOLID );
+ Show();
+}
+
+// -----------------------------------------------------------------------
+
+SvxFillTypeBox::~SvxFillTypeBox()
+{
+}
+
+// -----------------------------------------------------------------------
+
+long SvxFillTypeBox::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nType = rNEvt.GetType();
+
+ if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
+ nCurPos = GetSelectEntryPos();
+ else if ( EVENT_LOSEFOCUS == nType
+ && Application::GetFocusWindow()
+ && !IsWindowOrChild( Application::GetFocusWindow(), TRUE ) )
+ {
+ if ( !bSelect )
+ SelectEntryPos( nCurPos );
+ else
+ bSelect = FALSE;
+ }
+
+ return FillTypeLB::PreNotify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+long SvxFillTypeBox::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = FillTypeLB::Notify( rNEvt );
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ switch ( pKEvt->GetKeyCode().GetCode() )
+ {
+ case KEY_RETURN:
+ nHandled = 1;
+ ( (Link&)GetSelectHdl() ).Call( this );
+ break;
+ case KEY_TAB:
+ bRelease = FALSE;
+ ( (Link&)GetSelectHdl() ).Call( this );
+ bRelease = TRUE;
+ break;
+
+ case KEY_ESCAPE:
+ SelectEntryPos( nCurPos );
+ ReleaseFocus_Impl();
+ nHandled = 1;
+ break;
+ }
+ }
+ return nHandled;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFillTypeBox::ReleaseFocus_Impl()
+{
+ if( SfxViewShell::Current() )
+ {
+ Window* pShellWnd = SfxViewShell::Current()->GetWindow();
+
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+}
+
+//========================================================================
+// SvxFillAttrBox
+//========================================================================
+
+SvxFillAttrBox::SvxFillAttrBox( Window* pParent, WinBits nBits ) :
+
+ FillAttrLB( pParent, nBits | WB_TABSTOP ),
+
+ nCurPos( 0 ),
+ bRelease( TRUE )
+
+{
+ SetPosPixel( Point( 90, 0 ) );
+ SetSizePixel( LogicToPixel( Size(50, 80 ), MAP_APPFONT ));
+ Show();
+}
+
+// -----------------------------------------------------------------------
+
+SvxFillAttrBox::~SvxFillAttrBox()
+{
+}
+
+// -----------------------------------------------------------------------
+
+long SvxFillAttrBox::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nType = rNEvt.GetType();
+
+ if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
+ nCurPos = GetSelectEntryPos();
+
+ return FillAttrLB::PreNotify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+long SvxFillAttrBox::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = FillAttrLB::Notify( rNEvt );
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+
+ switch ( pKEvt->GetKeyCode().GetCode() )
+ {
+ case KEY_RETURN:
+ ( (Link&)GetSelectHdl() ).Call( this );
+ nHandled = 1;
+ break;
+ case KEY_TAB:
+ bRelease = FALSE;
+ GetSelectHdl().Call( this );
+ bRelease = TRUE;
+ break;
+ case KEY_ESCAPE:
+ SelectEntryPos( nCurPos );
+ ReleaseFocus_Impl();
+ nHandled = 1;
+ break;
+ }
+ }
+ return nHandled;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFillAttrBox::Select()
+{
+ FillAttrLB::Select();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFillAttrBox::ReleaseFocus_Impl()
+{
+ if( SfxViewShell::Current() )
+ {
+ Window* pShellWnd = SfxViewShell::Current()->GetWindow();
+
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/layctrl.cxx b/svx/source/tbxctrls/layctrl.cxx
new file mode 100644
index 000000000000..0620f1f59a68
--- /dev/null
+++ b/svx/source/tbxctrls/layctrl.cxx
@@ -0,0 +1,850 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+#include <vcl/toolbox.hxx>
+#include <vcl/button.hxx>
+#include <svl/intitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/app.hxx>
+
+#include <svx/dialogs.hrc>
+#include "layctrl.hxx"
+#include <svx/dialmgr.hxx>
+#include <comphelper/processfactory.hxx>
+#include <svtools/colorcfg.hxx>
+
+// namespaces
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::frame;
+
+SFX_IMPL_TOOLBOX_CONTROL(SvxTableToolBoxControl,SfxUInt16Item);
+SFX_IMPL_TOOLBOX_CONTROL(SvxColumnsToolBoxControl,SfxUInt16Item);
+
+// class TableWindow -----------------------------------------------------
+
+const long TABLE_CELL_WIDTH = 15;
+const long TABLE_CELL_HEIGHT = 15;
+
+const long TABLE_CELLS_HORIZ = 10;
+const long TABLE_CELLS_VERT = 15;
+
+const long TABLE_POS_X = 2;
+const long TABLE_POS_Y = 2;
+
+const long TABLE_WIDTH = TABLE_POS_X + TABLE_CELLS_HORIZ*TABLE_CELL_WIDTH;
+const long TABLE_HEIGHT = TABLE_POS_Y + TABLE_CELLS_VERT*TABLE_CELL_HEIGHT;
+
+class TableWindow : public SfxPopupWindow
+{
+private:
+ PushButton aTableButton;
+ ::Color aLineColor;
+ ::Color aFillColor;
+ ::Color aHighlightFillColor;
+ ::Color aBackgroundColor;
+ long nCol;
+ long nLine;
+ BOOL bInitialKeyInput;
+ BOOL m_bMod1;
+ ToolBox& rTbx;
+ Reference< XFrame > mxFrame;
+ rtl::OUString maCommand;
+
+ DECL_LINK( SelectHdl, void * );
+
+public:
+ TableWindow( USHORT nSlotId,
+ const rtl::OUString& rCmd,
+ const String& rText,
+ ToolBox& rParentTbx,
+ const Reference< XFrame >& rFrame );
+ ~TableWindow();
+
+ void KeyInput( const KeyEvent& rKEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void Paint( const Rectangle& );
+ virtual void PopupModeEnd();
+ virtual SfxPopupWindow* Clone() const;
+
+private:
+ void Update( long nNewCol, long nNewLine );
+ void TableDialog( const Sequence< PropertyValue >& rArgs );
+ void CloseAndShowTableDialog();
+};
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( TableWindow, SelectHdl, void *, EMPTYARG )
+{
+ CloseAndShowTableDialog();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+TableWindow::TableWindow( USHORT nSlotId, const rtl::OUString& rCmd, const String& rText, ToolBox& rParentTbx, const Reference< XFrame >& rFrame ) :
+ SfxPopupWindow( nSlotId, rFrame, WinBits( WB_STDPOPUP ) ),
+ aTableButton( this ),
+ nCol( 0 ),
+ nLine( 0 ),
+ bInitialKeyInput(TRUE),
+ m_bMod1(FALSE),
+ rTbx(rParentTbx),
+ mxFrame( rFrame ),
+ maCommand( rCmd )
+{
+ const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
+ svtools::ColorConfig aColorConfig;
+
+ aLineColor = rStyles.GetShadowColor();
+ aFillColor = rStyles.GetWindowColor();
+ aHighlightFillColor = rStyles.GetHighlightColor();
+ aBackgroundColor = GetSettings().GetStyleSettings().GetFaceColor();
+
+ SetBackground( aBackgroundColor );
+ Font aFont = GetFont();
+ aFont.SetColor( ::Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor ) );
+ aFont.SetFillColor( aBackgroundColor );
+ aFont.SetTransparent( FALSE );
+ SetFont( aFont );
+
+ SetText( rText );
+
+ aTableButton.SetPosSizePixel( Point( TABLE_POS_X + TABLE_CELL_WIDTH, TABLE_HEIGHT + 5 ),
+ Size( TABLE_WIDTH - TABLE_POS_X - 2*TABLE_CELL_WIDTH, 24 ) );
+ aTableButton.SetText( String( SVX_RESSTR( RID_SVXSTR_MORE ) ) );
+ aTableButton.SetClickHdl( LINK( this, TableWindow, SelectHdl ) );
+ aTableButton.Show();
+
+ SetOutputSizePixel( Size( TABLE_WIDTH + 3, TABLE_HEIGHT + 33 ) );
+}
+
+// -----------------------------------------------------------------------
+
+TableWindow::~TableWindow()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* TableWindow::Clone() const
+{
+ return new TableWindow( GetId(), maCommand, GetText(), rTbx, mxFrame );
+}
+
+// -----------------------------------------------------------------------
+
+void TableWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ SfxPopupWindow::MouseMove( rMEvt );
+ Point aPos = rMEvt.GetPosPixel();
+ Point aMousePos( aPos );
+
+ long nNewCol = ( aMousePos.X() - TABLE_POS_X + TABLE_CELL_WIDTH ) / TABLE_CELL_WIDTH;
+ long nNewLine = ( aMousePos.Y() - TABLE_POS_Y + TABLE_CELL_HEIGHT ) / TABLE_CELL_HEIGHT;
+
+ Update( nNewCol, nNewLine );
+}
+
+// -----------------------------------------------------------------------
+
+void TableWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ bool bHandled = false;
+ USHORT nModifier = rKEvt.GetKeyCode().GetModifier();
+ USHORT nKey = rKEvt.GetKeyCode().GetCode();
+ if ( !nModifier )
+ {
+ bHandled = true;
+ long nNewCol = nCol;
+ long nNewLine = nLine;
+ switch(nKey)
+ {
+ case KEY_UP:
+ if ( nNewLine > 1 )
+ nNewLine--;
+ else
+ EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
+ break;
+ case KEY_DOWN:
+ if ( nNewLine < TABLE_CELLS_VERT )
+ nNewLine++;
+ else
+ CloseAndShowTableDialog();
+ break;
+ case KEY_LEFT:
+ if ( nNewCol > 1 )
+ nNewCol--;
+ else
+ EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
+ break;
+ case KEY_RIGHT:
+ if ( nNewCol < TABLE_CELLS_HORIZ )
+ nNewCol++;
+ else
+ CloseAndShowTableDialog();
+ break;
+ case KEY_ESCAPE:
+ EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
+ break;
+ case KEY_RETURN:
+ EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
+ break;
+ case KEY_TAB:
+ CloseAndShowTableDialog();
+ break;
+ default:
+ bHandled = false;
+ }
+ if ( bHandled )
+ {
+ //make sure that a table can initially be created
+ if(bInitialKeyInput)
+ {
+ bInitialKeyInput = FALSE;
+ if(!nNewLine)
+ nNewLine = 1;
+ if(!nNewCol)
+ nNewCol = 1;
+ }
+ Update( nNewCol, nNewLine );
+ }
+ }
+ else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
+ {
+ m_bMod1 = TRUE;
+ EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
+ }
+
+ if(!bHandled)
+ SfxPopupWindow::KeyInput(rKEvt);
+}
+
+// -----------------------------------------------------------------------
+
+void TableWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ SfxPopupWindow::MouseButtonUp( rMEvt );
+ EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
+}
+
+// -----------------------------------------------------------------------
+
+void TableWindow::Paint( const Rectangle& )
+{
+ const long nSelectionWidth = TABLE_POS_X + nCol*TABLE_CELL_WIDTH;
+ const long nSelectionHeight = TABLE_POS_Y + nLine*TABLE_CELL_HEIGHT;
+
+ // the non-selected parts of the table
+ SetLineColor( aLineColor );
+ SetFillColor( aFillColor );
+ DrawRect( Rectangle( nSelectionWidth, TABLE_POS_Y, TABLE_WIDTH, nSelectionHeight ) );
+ DrawRect( Rectangle( TABLE_POS_X, nSelectionHeight, nSelectionWidth, TABLE_HEIGHT ) );
+ DrawRect( Rectangle( nSelectionWidth, nSelectionHeight, TABLE_WIDTH, TABLE_HEIGHT ) );
+
+ // the selection
+ if ( nCol > 0 && nLine > 0 )
+ {
+ SetFillColor( aHighlightFillColor );
+ DrawRect( Rectangle( TABLE_POS_X, TABLE_POS_Y,
+ nSelectionWidth, nSelectionHeight ) );
+ }
+
+ // lines inside of the table
+ SetLineColor( aLineColor );
+ for ( long i = 1; i < TABLE_CELLS_VERT; ++i )
+ DrawLine( Point( TABLE_POS_X, TABLE_POS_Y + i*TABLE_CELL_HEIGHT ),
+ Point( TABLE_WIDTH, TABLE_POS_Y + i*TABLE_CELL_HEIGHT ) );
+
+ for ( long i = 1; i < TABLE_CELLS_HORIZ; ++i )
+ DrawLine( Point( TABLE_POS_X + i*TABLE_CELL_WIDTH, TABLE_POS_Y ),
+ Point( TABLE_POS_X + i*TABLE_CELL_WIDTH, TABLE_HEIGHT ) );
+
+ // the text near the mouse cursor telling the table dimensions
+ if ( nCol && nLine )
+ {
+ String aText;
+ aText += String::CreateFromInt32( nCol );
+ aText.AppendAscii( " x " );
+ aText += String::CreateFromInt32( nLine );
+ if(GetId() == FN_SHOW_MULTIPLE_PAGES)
+ {
+ aText += ' ';
+ aText += String(SVX_RESSTR(RID_SVXSTR_PAGES));
+ }
+
+ Size aSize = GetOutputSizePixel();
+ Size aTextSize( GetTextWidth( aText ), GetTextHeight() );
+
+ long nTextX = nSelectionWidth + TABLE_CELL_WIDTH;
+ long nTextY = nSelectionHeight + TABLE_CELL_HEIGHT;
+ const long nTipBorder = 2;
+
+ if ( aTextSize.Width() + TABLE_POS_X + TABLE_CELL_WIDTH + 2*nTipBorder < nSelectionWidth )
+ nTextX = nSelectionWidth - TABLE_CELL_WIDTH - aTextSize.Width();
+
+ if ( aTextSize.Height() + TABLE_POS_Y + TABLE_CELL_HEIGHT + 2*nTipBorder < nSelectionHeight )
+ nTextY = nSelectionHeight - TABLE_CELL_HEIGHT - aTextSize.Height();
+
+ SetLineColor( aLineColor );
+ SetFillColor( aBackgroundColor );
+ DrawRect( Rectangle ( nTextX - 2*nTipBorder, nTextY - 2*nTipBorder,
+ nTextX + aTextSize.Width() + nTipBorder, nTextY + aTextSize.Height() + nTipBorder ) );
+
+ // #i95350# force RTL output
+ if ( IsRTLEnabled() )
+ aText.Insert( 0x202D, 0 );
+
+ DrawText( Point( nTextX, nTextY ), aText );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void TableWindow::PopupModeEnd()
+{
+ if ( !IsPopupModeCanceled() && nCol && nLine )
+ {
+ Sequence< PropertyValue > aArgs( 2 );
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Columns" ));
+ aArgs[0].Value = makeAny( sal_Int16( nCol ));
+ aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Rows" ));
+ aArgs[1].Value = makeAny( sal_Int16( nLine ));
+
+ TableDialog( aArgs );
+ }
+
+ SfxPopupWindow::PopupModeEnd();
+}
+
+// -----------------------------------------------------------------------
+
+void TableWindow::Update( long nNewCol, long nNewLine )
+{
+ if ( nNewCol < 0 || nNewCol > TABLE_CELLS_HORIZ )
+ nNewCol = 0;
+
+ if ( nNewLine < 0 || nNewLine > TABLE_CELLS_VERT )
+ nNewLine = 0;
+
+ if ( nNewCol != nCol || nNewLine != nLine )
+ {
+ nCol = nNewCol;
+ nLine = nNewLine;
+ Invalidate( Rectangle( TABLE_POS_X, TABLE_POS_Y, TABLE_WIDTH, TABLE_HEIGHT ) );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void TableWindow::TableDialog( const Sequence< PropertyValue >& rArgs )
+{
+ Window* pParent = rTbx.GetParent();
+ USHORT nId = GetId();
+ pParent->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE, reinterpret_cast<void*>(nId));
+
+ Reference< XDispatchProvider > xDispatchProvider( mxFrame, UNO_QUERY );
+ if ( xDispatchProvider.is() )
+ {
+ com::sun::star::util::URL aTargetURL;
+ Reference < XURLTransformer > xTrans( ::comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )),
+ UNO_QUERY );
+ aTargetURL.Complete = maCommand;
+ xTrans->parseStrict( aTargetURL );
+
+ Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch( aTargetURL, rtl::OUString(), 0 );
+ if ( xDispatch.is() )
+ xDispatch->dispatch( aTargetURL, rArgs );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void TableWindow::CloseAndShowTableDialog()
+{
+ // close the toolbar tool
+ EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL );
+
+ // and open the table dialog instead
+ TableDialog( Sequence< PropertyValue >() );
+}
+
+// class ColumnsWindow ---------------------------------------------------
+
+class ColumnsWindow : public SfxPopupWindow
+{
+private:
+ ::Color aLineColor;
+ ::Color aHighlightLineColor;
+ ::Color aFillColor;
+ ::Color aHighlightFillColor;
+ ::Color aFaceColor;
+ long nCol;
+ long nWidth;
+ long nMX;
+ long nTextHeight;
+ BOOL bInitialKeyInput;
+ BOOL m_bMod1;
+ ToolBox& rTbx;
+ Reference< XFrame > mxFrame;
+ ::rtl::OUString maCommand;
+
+ void UpdateSize_Impl( long nNewCol );
+public:
+ ColumnsWindow( USHORT nId, const ::rtl::OUString& rCmd, const String& rText, ToolBox& rParentTbx, const Reference< XFrame >& rFrame );
+
+ void KeyInput( const KeyEvent& rKEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void Paint( const Rectangle& );
+ virtual void PopupModeEnd();
+ virtual SfxPopupWindow* Clone() const;
+
+ USHORT GetColCount() const { return (USHORT)nCol; }
+};
+
+// -----------------------------------------------------------------------
+
+ColumnsWindow::ColumnsWindow( USHORT nId, const ::rtl::OUString& rCmd, const String& rText, ToolBox& rParentTbx, const Reference< XFrame >& rFrame ) :
+ SfxPopupWindow( nId, rFrame, WB_STDPOPUP ),
+ bInitialKeyInput(TRUE),
+ m_bMod1(FALSE),
+ rTbx(rParentTbx),
+ mxFrame(rFrame),
+ maCommand( rCmd )
+{
+ const StyleSettings& rStyles = Application::GetSettings().GetStyleSettings();
+ svtools::ColorConfig aColorConfig;
+ aLineColor = ::Color( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
+ aHighlightLineColor = rStyles.GetHighlightTextColor();
+ aFillColor = rStyles.GetWindowColor();
+ aHighlightFillColor = rStyles.GetHighlightColor();
+ aFaceColor = rStyles.GetFaceColor();
+
+ nTextHeight = GetTextHeight()+1;
+ SetBackground();
+ Font aFont( GetFont() );
+ aFont.SetColor( aLineColor );
+ aFont.SetFillColor( aFaceColor );
+ aFont.SetTransparent( FALSE );
+ SetFont( aFont );
+
+ nCol = 0;
+ nWidth = 4;
+
+ SetText( rText );
+
+ Size aLogicSize = LogicToPixel( Size( 95, 155 ), MapMode( MAP_10TH_MM ) );
+ nMX = aLogicSize.Width();
+ SetOutputSizePixel( Size( nMX*nWidth-1, aLogicSize.Height()+nTextHeight ) );
+ StartCascading();
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* ColumnsWindow::Clone() const
+{
+ return new ColumnsWindow( GetId(), maCommand, GetText(), rTbx, mxFrame );
+}
+
+// -----------------------------------------------------------------------
+
+void ColumnsWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ SfxPopupWindow::MouseMove( rMEvt );
+ Point aPos = rMEvt.GetPosPixel();
+ Point aMousePos = aPos;
+ Point aWinPos = GetPosPixel();
+
+ if ( rMEvt.IsEnterWindow() )
+ CaptureMouse();
+ else if ( aMousePos.X() < 0 || aMousePos.Y() < 0 )
+ {
+ nCol = 0;
+ ReleaseMouse();
+ Invalidate();
+ return;
+ }
+
+ long nNewCol = 0;
+ if ( aPos.X() > 0 )
+ nNewCol = aPos.X() / nMX + 1;
+ if ( aPos.Y() < 0 )
+ nNewCol = 0;
+ if ( nNewCol > 20 )
+ nNewCol = 20;
+ UpdateSize_Impl( nNewCol );
+}
+/* -----------------------------21.05.2002 16:16------------------------------
+
+ ---------------------------------------------------------------------------*/
+void ColumnsWindow::UpdateSize_Impl( long nNewCol )
+{
+ Size aWinSize = GetOutputSizePixel();
+ long nMinCol = 0;
+ long nMaxCol = 0;
+ Point aWinPos;// = GetPosPixel();
+
+ if ( nWidth <= nNewCol )
+ {
+ Point aMaxPos = OutputToScreenPixel( GetDesktopRectPixel().BottomRight() );
+
+ if ( nWidth <= nNewCol )
+ {
+ nWidth = nNewCol;
+ nWidth++;
+ }
+
+ while ( nWidth > 0 &&
+ (short)(aWinPos.X()+(nMX*nWidth-1)) >= aMaxPos.X()-3 )
+ nWidth--;
+
+ if ( nNewCol > nWidth )
+ nNewCol = nWidth;
+
+ Invalidate( Rectangle( 0, aWinSize.Height()-nTextHeight+2,
+ aWinSize.Width(), aWinSize.Height() ) );
+ SetOutputSizePixel( Size( nMX*nWidth-1, aWinSize.Height() ) );
+ }
+
+
+ if ( nNewCol != nCol )
+ {
+ Invalidate( Rectangle( 0, aWinSize.Height()-nTextHeight+2,
+ aWinSize.Width(), aWinSize.Height() ) );
+
+ if ( nNewCol < nCol )
+ {
+ nMinCol = nNewCol;
+ nMaxCol = nCol;
+ }
+ else
+ {
+ nMinCol = nCol;
+ nMaxCol = nNewCol;
+ }
+
+ Invalidate( Rectangle( nMinCol*nMX-1, 0,
+ nMaxCol*nMX+1, aWinSize.Height()-nTextHeight+2 ) );
+ nCol = nNewCol;
+ }
+ Update();
+}
+// -----------------------------------------------------------------------
+
+void ColumnsWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ SfxPopupWindow::MouseButtonDown( rMEvt );
+ CaptureMouse();
+}
+/* -----------------------------21.05.2002 16:11------------------------------
+
+ ---------------------------------------------------------------------------*/
+void ColumnsWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ BOOL bHandled = FALSE;
+ USHORT nModifier = rKEvt.GetKeyCode().GetModifier();
+ USHORT nKey = rKEvt.GetKeyCode().GetCode();
+ if(!nModifier)
+ {
+ if( KEY_LEFT == nKey || KEY_RIGHT == nKey ||
+ KEY_RETURN == nKey ||KEY_ESCAPE == nKey ||
+ KEY_UP == nKey)
+ {
+ bHandled = TRUE;
+ long nNewCol = nCol;
+ switch(nKey)
+ {
+ case KEY_LEFT :
+ if(nNewCol)
+ nNewCol--;
+ break;
+ case KEY_RIGHT :
+ nNewCol++;
+ break;
+ case KEY_RETURN :
+ if(IsMouseCaptured())
+ ReleaseMouse();
+ EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL );
+ break;
+ case KEY_ESCAPE :
+ case KEY_UP :
+ EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL);
+ break;
+ }
+ //make sure that a table can initially be created
+ if(bInitialKeyInput)
+ {
+ bInitialKeyInput = FALSE;
+ if(!nNewCol)
+ nNewCol = 1;
+ }
+ UpdateSize_Impl( nNewCol );
+ }
+ }
+ else if(KEY_MOD1 == nModifier && KEY_RETURN == nKey)
+ {
+ m_bMod1 = TRUE;
+ if(IsMouseCaptured())
+ ReleaseMouse();
+ EndPopupMode(FLOATWIN_POPUPMODEEND_CLOSEALL );
+ }
+ if(!bHandled)
+ SfxPopupWindow::KeyInput(rKEvt);
+}
+
+// -----------------------------------------------------------------------
+
+void ColumnsWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ SfxPopupWindow::MouseButtonUp( rMEvt );
+ ReleaseMouse();
+
+ if ( IsInPopupMode() )
+ EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL );
+}
+
+// -----------------------------------------------------------------------
+
+void ColumnsWindow::Paint( const Rectangle& )
+{
+ long i;
+ long j;
+ long nLineWidth;
+ Size aSize = GetOutputSizePixel();
+
+ for ( i = 0; i < nWidth; i++ )
+ {
+ if ( i < nCol )
+ {
+ SetLineColor( aHighlightLineColor );
+ SetFillColor( aHighlightFillColor );
+ }
+ else
+ {
+ SetLineColor( aLineColor );
+ SetFillColor( aFillColor );
+ }
+
+ DrawRect( Rectangle( i*nMX-1, -1,
+ i*nMX+nMX, aSize.Height()-nTextHeight+1 ) );
+
+ j = 4;
+ while ( j < aSize.Height()-nTextHeight-4 )
+ {
+ if ( !(j % 16) )
+ nLineWidth = 10;
+ else
+ nLineWidth = 4;
+ DrawLine( Point( i*nMX+4, j ), Point( i*nMX+nMX-nLineWidth-4, j ) );
+ j += 4;
+ }
+ }
+
+ SetLineColor();
+ SetFillColor( aFaceColor );
+ String aText;
+ if ( nCol )
+ aText = String( String::CreateFromInt32(nCol) );
+ else
+ aText = Button::GetStandardText( BUTTON_CANCEL ).EraseAllChars( '~' );
+
+ Size aTextSize(GetTextWidth( aText ), GetTextHeight());
+ DrawText( Point( ( aSize.Width() - aTextSize.Width() ) / 2, aSize.Height() - nTextHeight + 2 ), aText );
+
+ DrawRect( Rectangle( 0, aSize.Height()-nTextHeight+2, (aSize.Width()-aTextSize.Width())/2-1, aSize.Height() ) );
+ DrawRect( Rectangle( (aSize.Width()-aTextSize.Width())/2+aTextSize.Width(), aSize.Height()-nTextHeight+2, aSize.Width(), aSize.Height() ) );
+
+ SetLineColor( aLineColor );
+ SetFillColor();
+ DrawRect( Rectangle( 0, 0, aSize.Width() - 1, aSize.Height() - nTextHeight + 1 ) );
+}
+
+// -----------------------------------------------------------------------
+
+void ColumnsWindow::PopupModeEnd()
+{
+ if ( !IsPopupModeCanceled() && nCol )
+ {
+ USHORT nId = GetId();
+ Window* pParent = rTbx.GetParent();
+ pParent->UserEvent(SVX_EVENT_COLUM_WINDOW_EXECUTE, reinterpret_cast<void*>(nId));
+
+ Sequence< PropertyValue > aArgs( 2 );
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Columns" ));
+ aArgs[0].Value = makeAny( sal_Int16( nCol ));
+ aArgs[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Modifier" ));
+ aArgs[1].Value = makeAny( sal_Int16( m_bMod1 ? KEY_MOD1 : 0 ));
+
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
+ maCommand,
+ aArgs );
+ }
+ else if ( IsPopupModeCanceled() )
+ ReleaseMouse();
+ SfxPopupWindow::PopupModeEnd();
+}
+
+// class SvxTableToolBoxControl ------------------------------------------
+
+SvxTableToolBoxControl::SvxTableToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ bEnabled( TRUE )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+SvxTableToolBoxControl::~SvxTableToolBoxControl()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType SvxTableToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxTableToolBoxControl::CreatePopupWindow()
+{
+ if ( bEnabled )
+ {
+ ToolBox& rTbx = GetToolBox();
+ TableWindow* pWin = new TableWindow( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), rTbx, m_xFrame );
+ pWin->StartPopupMode( &rTbx, FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_NOKEYCLOSE );
+ SetPopupWindow( pWin );
+ return pWin;
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxTableToolBoxControl::CreatePopupWindowCascading()
+{
+ if ( bEnabled )
+ return new TableWindow( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame );
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxTableToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState )
+{
+ if ( pState && pState->ISA(SfxUInt16Item) )
+ {
+ INT16 nValue = static_cast< const SfxUInt16Item* >( pState )->GetValue();
+ bEnabled = ( nValue != 0 );
+ }
+ else
+ bEnabled = SFX_ITEM_DISABLED != eState;
+
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+ rTbx.SetItemState( nId,
+ ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
+}
+
+// class SvxColumnsToolBoxControl ------------------------------------------
+
+SvxColumnsToolBoxControl::SvxColumnsToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+SvxColumnsToolBoxControl::~SvxColumnsToolBoxControl()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType SvxColumnsToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONTIMEOUTANDMOVE;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxColumnsToolBoxControl::CreatePopupWindow()
+{
+ ColumnsWindow* pWin = 0;
+ if(bEnabled)
+ {
+ pWin = new ColumnsWindow( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame );
+ pWin->StartPopupMode( &GetToolBox(),
+ FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_NOKEYCLOSE );
+ SetPopupWindow( pWin );
+ }
+ return pWin;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxColumnsToolBoxControl::CreatePopupWindowCascading()
+{
+ ColumnsWindow* pWin = 0;
+ if(bEnabled)
+ {
+ pWin = new ColumnsWindow( GetSlotId(), m_aCommandURL, GetToolBox().GetItemText( GetId() ), GetToolBox(), m_xFrame );
+ }
+ return pWin;
+}
+/* -----------------18.11.99 16:38-------------------
+
+ --------------------------------------------------*/
+void SvxColumnsToolBoxControl::StateChanged( USHORT nSID,
+ SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ bEnabled = SFX_ITEM_DISABLED != eState;
+ SfxToolBoxControl::StateChanged(nSID, eState, pState );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/lboxctrl.cxx b/svx/source/tbxctrls/lboxctrl.cxx
new file mode 100644
index 000000000000..d8c8fe4e4375
--- /dev/null
+++ b/svx/source/tbxctrls/lboxctrl.cxx
@@ -0,0 +1,349 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#ifdef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#include <vcl/lstbox.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/event.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/tbxctrl.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewsh.hxx>
+#include <tools/gen.hxx>
+#include <svl/intitem.hxx>
+#include <svl/eitem.hxx>
+#include <svtools/stdctrl.hxx>
+#include <svl/slstitm.hxx>
+#include <svl/stritem.hxx>
+#include <svx/dialmgr.hxx>
+#include <lboxctrl.hxx>
+#include <vcl/mnemonic.hxx>
+#include <tools/urlobj.hxx>
+
+#include <svx/svxids.hrc>
+#include <svx/dialogs.hrc>
+
+#include "lboxctrl.hrc"
+
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::frame;
+
+class SvxPopupWindowListBox;
+
+/////////////////////////////////////////////////////////////////
+
+class SvxPopupWindowListBox : public SfxPopupWindow
+{
+ using FloatingWindow::StateChanged;
+
+ ListBox * pListBox;
+ ToolBox & rToolBox;
+ BOOL bUserSel;
+ USHORT nTbxId;
+ rtl::OUString maCommandURL;
+ // disallow copy-constructor and assignment-operator
+
+ SvxPopupWindowListBox(const int& );
+ SvxPopupWindowListBox & operator = (const int& );
+
+// SvxPopupWindowListBox( USHORT nSlotId, ToolBox& rTbx, USHORT nTbxItemId );
+
+public:
+ SvxPopupWindowListBox( USHORT nSlotId, const rtl::OUString& rCommandURL, USHORT nTbxId, ToolBox& rTbx );
+ virtual ~SvxPopupWindowListBox();
+
+ // SfxPopupWindow
+ virtual SfxPopupWindow * Clone() const;
+ virtual void PopupModeEnd();
+ virtual void StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+
+ void StartSelection();
+ inline ListBox & GetListBox() { return *pListBox; }
+
+ BOOL IsUserSelected() const { return bUserSel; }
+ void SetUserSelected( BOOL bVal ) { bUserSel = bVal; }
+ /*virtual*/Window* GetPreferredKeyInputWindow();
+};
+
+/////////////////////////////////////////////////////////////////
+
+SvxPopupWindowListBox::SvxPopupWindowListBox( USHORT nSlotId, const rtl::OUString& rCommandURL, USHORT nId, ToolBox& rTbx ) :
+ SfxPopupWindow( nSlotId, Reference< XFrame >(), SVX_RES( RID_SVXTBX_UNDO_REDO_CTRL ) ),
+ rToolBox ( rTbx ),
+ bUserSel ( FALSE ),
+ nTbxId ( nId ),
+ maCommandURL( rCommandURL )
+{
+ DBG_ASSERT( nSlotId == GetId(), "id mismatch" );
+ pListBox = new ListBox( this, SVX_RES( LB_SVXTBX_UNDO_REDO_CTRL ) );
+ FreeResource();
+ pListBox->EnableMultiSelection( TRUE, TRUE );
+ SetBackground( GetSettings().GetStyleSettings().GetDialogColor() );
+ AddStatusListener( rCommandURL );
+}
+
+
+SvxPopupWindowListBox::~SvxPopupWindowListBox()
+{
+ delete pListBox;
+}
+
+
+SfxPopupWindow* SvxPopupWindowListBox::Clone() const
+{
+ return new SvxPopupWindowListBox( GetId(), maCommandURL, nTbxId, rToolBox );
+}
+
+
+void SvxPopupWindowListBox::PopupModeEnd()
+{
+ rToolBox.EndSelection();
+ SfxPopupWindow::PopupModeEnd();
+ //FloatingWindow::PopupModeEnd();
+
+ if( SfxViewShell::Current() )
+ {
+ Window* pShellWnd = SfxViewShell::Current()->GetWindow();
+ if (pShellWnd)
+ pShellWnd->GrabFocus();
+ }
+}
+
+
+void SvxPopupWindowListBox::StateChanged(
+ USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ rToolBox.EnableItem( nTbxId, ( SfxToolBoxControl::GetItemState( pState ) != SFX_ITEM_DISABLED) );
+ SfxPopupWindow::StateChanged( nSID, eState, pState );
+}
+
+
+void SvxPopupWindowListBox::StartSelection()
+{
+ rToolBox.StartSelection();
+}
+
+Window* SvxPopupWindowListBox::GetPreferredKeyInputWindow()
+{
+ // allows forwarding key events in the correct window
+ // without setting the focus
+ return pListBox->GetPreferredKeyInputWindow();
+}
+
+/////////////////////////////////////////////////////////////////
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxListBoxControl, SfxStringItem );
+
+
+SvxListBoxControl::SvxListBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ :SfxToolBoxControl( nSlotId, nId, rTbx ),
+ pPopupWin ( 0 )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+}
+
+
+SvxListBoxControl::~SvxListBoxControl()
+{
+}
+
+
+SfxPopupWindow* SvxListBoxControl::CreatePopupWindow()
+{
+ DBG_ERROR( "not implemented" );
+ return 0;
+}
+
+
+SfxPopupWindowType SvxListBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONTIMEOUT;
+}
+
+
+void SvxListBoxControl::StateChanged(
+ USHORT, SfxItemState, const SfxPoolItem* pState )
+{
+ GetToolBox().EnableItem( GetId(),
+ SFX_ITEM_DISABLED != GetItemState(pState) );
+}
+
+
+IMPL_LINK( SvxListBoxControl, PopupModeEndHdl, void *, EMPTYARG )
+{
+ if( pPopupWin && 0 == pPopupWin->GetPopupModeFlags() &&
+ pPopupWin->IsUserSelected() )
+ {
+ USHORT nCount = pPopupWin->GetListBox().GetSelectEntryCount();
+
+ INetURLObject aObj( m_aCommandURL );
+
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = aObj.GetURLPath();
+ aArgs[0].Value = makeAny( sal_Int16( nCount ));
+ SfxToolBoxControl::Dispatch( m_aCommandURL, aArgs );
+ }
+ return 0;
+}
+
+
+void SvxListBoxControl::Impl_SetInfo( USHORT nCount )
+{
+ DBG_ASSERT( pPopupWin, "NULL pointer, PopupWindow missing" );
+
+// ListBox &rListBox = pPopupWin->GetListBox();
+
+ USHORT nId;
+ if (nCount == 1)
+ nId = SID_UNDO == GetSlotId() ? RID_SVXSTR_NUM_UNDO_ACTION : RID_SVXSTR_NUM_REDO_ACTION;
+ else
+ nId = SID_UNDO == GetSlotId() ? RID_SVXSTR_NUM_UNDO_ACTIONS : RID_SVXSTR_NUM_REDO_ACTIONS;
+
+ aActionStr = String(SVX_RES(nId));
+
+ String aText( aActionStr );
+ aText.SearchAndReplaceAllAscii( "$(ARG1)", String::CreateFromInt32( nCount ) );
+ pPopupWin->SetText( aText );
+}
+
+
+IMPL_LINK( SvxListBoxControl, SelectHdl, void *, EMPTYARG )
+{
+ if (pPopupWin)
+ {
+ //pPopupWin->SetUserSelected( FALSE );
+
+ ListBox &rListBox = pPopupWin->GetListBox();
+ if (rListBox.IsTravelSelect())
+ Impl_SetInfo( rListBox.GetSelectEntryCount() );
+ else
+ {
+ pPopupWin->SetUserSelected( TRUE );
+ pPopupWin->EndPopupMode( 0 );
+ }
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxUndoRedoControl, SfxStringItem );
+
+SvxUndoRedoControl::SvxUndoRedoControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ : SvxListBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+ aDefaultText = MnemonicGenerator::EraseAllMnemonicChars( rTbx.GetItemText( nId ) );
+}
+
+SvxUndoRedoControl::~SvxUndoRedoControl()
+{
+}
+
+void SvxUndoRedoControl::StateChanged(
+ USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ if ( nSID == SID_UNDO || nSID == SID_REDO )
+ {
+ if ( eState == SFX_ITEM_DISABLED )
+ {
+ ToolBox& rBox = GetToolBox();
+ rBox.SetQuickHelpText( GetId(), aDefaultText );
+ }
+ else if ( pState && pState->ISA( SfxStringItem ) )
+ {
+ SfxStringItem& rItem = *(SfxStringItem *)pState;
+ ToolBox& rBox = GetToolBox();
+ String aQuickHelpText = MnemonicGenerator::EraseAllMnemonicChars( rItem.GetValue() );
+ rBox.SetQuickHelpText( GetId(), aQuickHelpText );
+ }
+ SvxListBoxControl::StateChanged( nSID, eState, pState );
+ }
+ else
+ {
+ aUndoRedoList.clear();
+
+ if ( pState && pState->ISA( SfxStringListItem ) )
+ {
+ SfxStringListItem &rItem = *(SfxStringListItem *)pState;
+ const List* pLst = rItem.GetList();
+ DBG_ASSERT( pLst, "no undo actions available" );
+ if ( pLst )
+ {
+ for( long nI = 0, nEnd = pLst->Count(); nI < nEnd; ++nI )
+ aUndoRedoList.push_back( rtl::OUString( *(String *)pLst->GetObject( nI )));
+ }
+ }
+ }
+}
+
+SfxPopupWindow* SvxUndoRedoControl::CreatePopupWindow()
+{
+ DBG_ASSERT(( SID_UNDO == GetSlotId() || SID_REDO == GetSlotId() ), "mismatching ids" );
+
+ if ( m_aCommandURL.equalsAscii( ".uno:Undo" ))
+ updateStatus( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GetUndoStrings" )));
+ else
+ updateStatus( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GetRedoStrings" )));
+
+ ToolBox& rBox = GetToolBox();
+
+ pPopupWin = new SvxPopupWindowListBox( GetSlotId(), m_aCommandURL, GetId(), rBox );
+ pPopupWin->SetPopupModeEndHdl( LINK( this, SvxUndoRedoControl,
+ PopupModeEndHdl ) );
+ ListBox &rListBox = pPopupWin->GetListBox();
+ rListBox.SetSelectHdl( LINK( this, SvxUndoRedoControl, SelectHdl ) );
+
+ for( sal_uInt32 n = 0; n < aUndoRedoList.size(); n++ )
+ rListBox.InsertEntry( String( aUndoRedoList[n] ));
+
+ rListBox.SelectEntryPos( 0 );
+ aActionStr = String( SVX_RES( SID_UNDO == GetSlotId() ?
+ RID_SVXSTR_NUM_UNDO_ACTIONS : RID_SVXSTR_NUM_REDO_ACTIONS ) );
+ Impl_SetInfo( rListBox.GetSelectEntryCount() );
+
+ // move focus in floating window without
+ // closing it (GrabFocus() would close it!)
+ pPopupWin->StartPopupMode( &rBox, FLOATWIN_POPUPMODE_GRABFOCUS );
+ //pPopupWin->GetListBox().GrabFocus();
+
+ return pPopupWin;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/lboxctrl.hrc b/svx/source/tbxctrls/lboxctrl.hrc
new file mode 100644
index 000000000000..6f744ae1c25a
--- /dev/null
+++ b/svx/source/tbxctrls/lboxctrl.hrc
@@ -0,0 +1,30 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#define LB_SVXTBX_UNDO_REDO_CTRL 11
+#define FT_NUM_OPERATIONS 12
+
diff --git a/svx/source/tbxctrls/lboxctrl.src b/svx/source/tbxctrls/lboxctrl.src
new file mode 100644
index 000000000000..149627ef1622
--- /dev/null
+++ b/svx/source/tbxctrls/lboxctrl.src
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+#include <helpid.hrc>
+#include "lboxctrl.hrc"
+
+FloatingWindow RID_SVXTBX_UNDO_REDO_CTRL
+{
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 102 , 87 ) ;
+ HelpID = HID_SVXTBX_UNDO_REDO_CTRL ;
+ StdPopup = TRUE;
+ Hide = TRUE ;
+ OutputSize = TRUE ;
+
+ ListBox LB_SVXTBX_UNDO_REDO_CTRL
+ {
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 100 , 85 ) ;
+ Border = TRUE ;
+ DropDown = FALSE ;
+ OutputSize = TRUE ;
+ };
+};
+
+String RID_SVXSTR_NUM_UNDO_ACTIONS
+{
+ Text[ en-US ] = "Actions to undo: $(ARG1)";
+};
+
+String RID_SVXSTR_NUM_UNDO_ACTION
+{
+ Text[ en-US ] = "Actions to undo: $(ARG1)" ;
+};
+
+String RID_SVXSTR_NUM_REDO_ACTIONS
+{
+ Text[ en-US ] = "Actions to redo: $(ARG1)";
+};
+
+String RID_SVXSTR_NUM_REDO_ACTION
+{
+ Text[ en-US ] = "Actions to redo: $(ARG1)";
+};
diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx
new file mode 100644
index 000000000000..976c41efa28c
--- /dev/null
+++ b/svx/source/tbxctrls/linectrl.cxx
@@ -0,0 +1,785 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+
+#include <vcl/toolbox.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+
+#include <svx/dialogs.hrc>
+#include "helpid.hrc"
+
+#include "drawitem.hxx"
+#include "xattr.hxx"
+#include <svx/xtable.hxx>
+#include "linectrl.hxx"
+#include <svx/itemwin.hxx>
+#include <svx/dialmgr.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+
+// Fuer Linienenden-Controller
+#define MAX_LINES 12
+
+// STATIC DATA -----------------------------------------------------------
+
+#define RESIZE_VALUE_POPUP(value_set) \
+{ \
+ Size aSize = GetOutputSizePixel(); \
+ aSize.Width() -= 4; \
+ aSize.Height() -= 4; \
+ (value_set).SetPosSizePixel( Point(2,2), aSize ); \
+}
+
+#define CALCSIZE_VALUE_POPUP(value_set,item_size) \
+{ \
+ Size aSize = (value_set).CalcWindowSizePixel( (item_size) ); \
+ aSize.Width() += 4; \
+ aSize.Height() += 4; \
+ SetOutputSizePixel( aSize ); \
+}
+
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxLineStyleToolBoxControl, XLineStyleItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxLineWidthToolBoxControl, XLineWidthItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxLineColorToolBoxControl, XLineColorItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxLineEndToolBoxControl, SfxBoolItem );
+
+/*************************************************************************
+|*
+|* SvxLineStyleToolBoxControl
+|*
+\************************************************************************/
+
+SvxLineStyleToolBoxControl::SvxLineStyleToolBoxControl( USHORT nSlotId,
+ USHORT nId,
+ ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ pStyleItem ( NULL ),
+ pDashItem ( NULL ),
+ bUpdate ( FALSE )
+{
+ addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineDash" )));
+ addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DashListState" )));
+}
+
+//========================================================================
+
+SvxLineStyleToolBoxControl::~SvxLineStyleToolBoxControl()
+{
+ delete pStyleItem;
+ delete pDashItem;
+}
+
+//========================================================================
+
+void SvxLineStyleToolBoxControl::StateChanged (
+
+ USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() );
+ DBG_ASSERT( pBox, "Window not found!" );
+
+ if( eState == SFX_ITEM_DISABLED )
+ {
+ pBox->Disable();
+ pBox->SetNoSelection();
+ }
+ else
+ {
+ pBox->Enable();
+
+ if ( eState == SFX_ITEM_AVAILABLE )
+ {
+ if( nSID == SID_ATTR_LINE_STYLE )
+ {
+ delete pStyleItem;
+ pStyleItem = (XLineStyleItem*)pState->Clone();
+ }
+ else if( nSID == SID_ATTR_LINE_DASH )
+ {
+ delete pDashItem;
+ pDashItem = (XLineDashItem*)pState->Clone();
+ }
+
+ bUpdate = TRUE;
+ Update( pState );
+ }
+ else if ( nSID != SID_DASH_LIST )
+ {
+ // kein oder uneindeutiger Status
+ pBox->SetNoSelection();
+ }
+ }
+}
+
+//========================================================================
+
+void SvxLineStyleToolBoxControl::Update( const SfxPoolItem* pState )
+{
+ if ( pState && bUpdate )
+ {
+ bUpdate = FALSE;
+
+ SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() );
+ DBG_ASSERT( pBox, "Window not found!" );
+
+ // Da der Timer unerwartet zuschlagen kann, kann es vorkommen, dass
+ // die LB noch nicht gefuellt ist. Ein ClearCache() am Control im
+ // DelayHdl() blieb ohne Erfolg.
+ if( pBox->GetEntryCount() == 0 )
+ pBox->FillControl();
+
+ XLineStyle eXLS;
+
+ if ( pStyleItem )
+ eXLS = ( XLineStyle )pStyleItem->GetValue();
+ else
+ eXLS = XLINE_NONE;
+
+ switch( eXLS )
+ {
+ case XLINE_NONE:
+ pBox->SelectEntryPos( 0 );
+ break;
+
+ case XLINE_SOLID:
+ pBox->SelectEntryPos( 1 );
+ break;
+
+ case XLINE_DASH:
+ {
+ if( pDashItem )
+ {
+ String aString( pDashItem->GetName() );
+ pBox->SelectEntry( aString );
+ }
+ else
+ pBox->SetNoSelection();
+ }
+ break;
+
+ default:
+ DBG_ERROR( "Nicht unterstuetzter Linientyp" );
+ break;
+ }
+ }
+
+ if ( pState && ( pState->ISA( SvxDashListItem ) ) )
+ {
+ // Die Liste der Linienstile hat sich geaendert
+ SvxLineBox* pBox = (SvxLineBox*)GetToolBox().GetItemWindow( GetId() );
+ DBG_ASSERT( pBox, "Window not found!" );
+
+ String aString( pBox->GetSelectEntry() );
+ pBox->Clear();
+ pBox->InsertEntry( SVX_RESSTR(RID_SVXSTR_INVISIBLE) );
+ pBox->InsertEntry( SVX_RESSTR(RID_SVXSTR_SOLID) );
+ pBox->Fill( ((SvxDashListItem*)pState )->GetDashList() );
+ pBox->SelectEntry( aString );
+ }
+}
+
+//========================================================================
+
+Window* SvxLineStyleToolBoxControl::CreateItemWindow( Window *pParent )
+{
+ return new SvxLineBox( pParent, m_xFrame );
+}
+
+/*************************************************************************
+|*
+|* SvxLineWidthToolBoxControl
+|*
+\************************************************************************/
+
+SvxLineWidthToolBoxControl::SvxLineWidthToolBoxControl(
+ USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:MetricUnit" )));
+}
+
+//========================================================================
+
+SvxLineWidthToolBoxControl::~SvxLineWidthToolBoxControl()
+{
+}
+
+//========================================================================
+
+void SvxLineWidthToolBoxControl::StateChanged(
+ USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ SvxMetricField* pFld = (SvxMetricField*)
+ GetToolBox().GetItemWindow( GetId() );
+ DBG_ASSERT( pFld, "Window not found" );
+
+ if ( nSID == SID_ATTR_METRIC )
+ {
+ pFld->RefreshDlgUnit();
+ }
+ else
+ {
+ if ( eState == SFX_ITEM_DISABLED )
+ {
+ pFld->Disable();
+ pFld->SetText( String() );
+ }
+ else
+ {
+ pFld->Enable();
+
+ if ( eState == SFX_ITEM_AVAILABLE )
+ {
+ DBG_ASSERT( pState->ISA(XLineWidthItem), "falscher ItemType" );
+
+ // Core-Unit an MetricField uebergeben
+ // Darf nicht in CreateItemWin() geschehen!
+ SfxMapUnit eUnit = SFX_MAPUNIT_100TH_MM; // CD!!! GetCoreMetric();
+ pFld->SetCoreUnit( eUnit );
+
+ pFld->Update( (const XLineWidthItem*)pState );
+ }
+ else
+ pFld->Update( NULL );
+ }
+ }
+}
+
+//========================================================================
+
+Window* SvxLineWidthToolBoxControl::CreateItemWindow( Window *pParent )
+{
+ return( new SvxMetricField( pParent, m_xFrame ) );
+}
+
+/*************************************************************************
+|*
+|* SvxLineColorToolBoxControl
+|*
+\************************************************************************/
+
+SvxLineColorToolBoxControl::SvxLineColorToolBoxControl(
+ USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
+}
+
+//========================================================================
+
+SvxLineColorToolBoxControl::~SvxLineColorToolBoxControl()
+{
+}
+
+//========================================================================
+
+void SvxLineColorToolBoxControl::StateChanged(
+
+ USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() );
+ DBG_ASSERT( pBox, "Window not found" );
+
+ if ( nSID != SID_COLOR_TABLE )
+ {
+ if ( eState == SFX_ITEM_DISABLED )
+ {
+ pBox->Disable();
+ pBox->SetNoSelection();
+ }
+ else
+ {
+ pBox->Enable();
+
+ if ( eState == SFX_ITEM_AVAILABLE )
+ {
+ DBG_ASSERT( pState->ISA(XLineColorItem), "falscher ItemTyoe" );
+ pBox->Update( (const XLineColorItem*) pState );
+ }
+ else
+ pBox->Update( NULL );
+ }
+ }
+ else
+ Update( pState );
+}
+
+//========================================================================
+
+void SvxLineColorToolBoxControl::Update( const SfxPoolItem* pState )
+{
+ if ( pState && ( pState->ISA( SvxColorTableItem ) ) )
+ {
+ SvxColorBox* pBox = (SvxColorBox*)GetToolBox().GetItemWindow( GetId() );
+
+ DBG_ASSERT( pBox, "Window not found" );
+
+ // Die Liste der Farben (ColorTable) hat sich geaendert:
+ ::Color aTmpColor( pBox->GetSelectEntryColor() );
+ pBox->Clear();
+ pBox->Fill( ( (SvxColorTableItem*)pState )->GetColorTable() );
+ pBox->SelectEntry( aTmpColor );
+ }
+}
+
+//========================================================================
+
+Window* SvxLineColorToolBoxControl::CreateItemWindow( Window *pParent )
+{
+ return new SvxColorBox( pParent, m_aCommandURL, m_xFrame );
+}
+
+/*************************************************************************
+|*
+|* SvxLineEndWindow
+|*
+\************************************************************************/
+
+SvxLineEndWindow::SvxLineEndWindow(
+ USHORT nSlotId,
+ const Reference< XFrame >& rFrame,
+ const String& rWndTitle ) :
+ SfxPopupWindow( nSlotId,
+ rFrame,
+ WinBits( WB_STDPOPUP ) ),
+ pLineEndList ( NULL ),
+ aLineEndSet ( this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
+ nCols ( 2 ),
+ nLines ( 12 ),
+ nLineEndWidth ( 400 ),
+ bPopupMode ( TRUE ),
+ mbInResize ( false ),
+ mxFrame ( rFrame )
+{
+ SetText( rWndTitle );
+ implInit();
+}
+
+SvxLineEndWindow::SvxLineEndWindow(
+ USHORT nSlotId,
+ const Reference< XFrame >& rFrame,
+ Window* pParentWindow,
+ const String& rWndTitle ) :
+ SfxPopupWindow( nSlotId,
+ rFrame,
+ pParentWindow,
+ WinBits( WB_STDPOPUP ) ),
+ pLineEndList ( NULL ),
+ aLineEndSet ( this, WinBits( WB_ITEMBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
+ nCols ( 2 ),
+ nLines ( 12 ),
+ nLineEndWidth ( 400 ),
+ bPopupMode ( TRUE ),
+ mbInResize ( false ),
+ mxFrame ( rFrame )
+{
+ SetText( rWndTitle );
+ implInit();
+}
+
+void SvxLineEndWindow::implInit()
+{
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ const SfxPoolItem* pItem = NULL;
+
+ SetHelpId( HID_POPUP_LINEEND );
+ aLineEndSet.SetHelpId( HID_POPUP_LINEEND_CTRL );
+
+ if ( pDocSh )
+ {
+ pItem = pDocSh->GetItem( SID_LINEEND_LIST );
+ if( pItem )
+ pLineEndList = ( (SvxLineEndListItem*) pItem )->GetLineEndList();
+
+ pItem = pDocSh->GetItem( SID_ATTR_LINEEND_WIDTH_DEFAULT );
+ if( pItem )
+ nLineEndWidth = ( (SfxUInt16Item*) pItem )->GetValue();
+ }
+ DBG_ASSERT( pLineEndList, "LineEndList wurde nicht gefunden" );
+
+ aLineEndSet.SetSelectHdl( LINK( this, SvxLineEndWindow, SelectHdl ) );
+ aLineEndSet.SetColCount( nCols );
+
+ // ValueSet mit Eintraegen der LineEndList fuellen
+ FillValueSet();
+
+ AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineEndListState" )));
+
+ //ChangeHelpId( HID_POPUP_LINEENDSTYLE );
+ aLineEndSet.Show();
+}
+
+SfxPopupWindow* SvxLineEndWindow::Clone() const
+{
+ return new SvxLineEndWindow( GetId(), mxFrame, GetText() );
+}
+
+// -----------------------------------------------------------------------
+
+SvxLineEndWindow::~SvxLineEndWindow()
+{
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxLineEndWindow, SelectHdl, void *, EMPTYARG )
+{
+ XLineEndItem* pLineEndItem = NULL;
+ XLineStartItem* pLineStartItem = NULL;
+ USHORT nId = aLineEndSet.GetSelectItemId();
+
+ if( nId == 1 )
+ {
+ pLineStartItem = new XLineStartItem();
+ }
+ else if( nId == 2 )
+ {
+ pLineEndItem = new XLineEndItem();
+ }
+ else if( nId % 2 ) // LinienAnfang
+ {
+ XLineEndEntry* pEntry = pLineEndList->GetLineEnd( ( nId - 1 ) / 2 - 1 );
+ pLineStartItem = new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() );
+ }
+ else // LinienEnde
+ {
+ XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nId / 2 - 2 );
+ pLineEndItem = new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() );
+ }
+
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ Sequence< PropertyValue > aArgs( 1 );
+ Any a;
+
+ if ( pLineStartItem )
+ {
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStart" ));
+ pLineStartItem->QueryValue( a );
+ aArgs[0].Value = a;
+ }
+ else
+ {
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineEnd" ));
+ pLineEndItem->QueryValue( a );
+ aArgs[0].Value = a;
+ }
+
+ /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
+ This instance may be deleted in the meantime (i.e. when a dialog is opened
+ while in Dispatch()), accessing members will crash in this case. */
+ aLineEndSet.SetNoSelection();
+
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( mxFrame->getController(), UNO_QUERY ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineEndStyle" )),
+ aArgs );
+
+ delete pLineEndItem;
+ delete pLineStartItem;
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineEndWindow::FillValueSet()
+{
+ if( pLineEndList )
+ {
+ XLineEndEntry* pEntry = NULL;
+ Bitmap* pBmp = NULL;
+ VirtualDevice aVD;
+
+ long nCount = pLineEndList->Count();
+
+ // Erster Eintrag: kein LinienEnde
+ // Temporaer wird ein Eintrag hinzugefuegt, um die UI-Bitmap zu erhalten
+ basegfx::B2DPolyPolygon aNothing;
+ pLineEndList->Insert( new XLineEndEntry( aNothing, SVX_RESSTR( RID_SVXSTR_NONE ) ) );
+ pEntry = pLineEndList->GetLineEnd( nCount );
+ pBmp = pLineEndList->GetBitmap( nCount );
+ DBG_ASSERT( pBmp, "UI-Bitmap wurde nicht erzeugt" );
+
+ aBmpSize = pBmp->GetSizePixel();
+ aVD.SetOutputSizePixel( aBmpSize, FALSE );
+ aBmpSize.Width() = aBmpSize.Width() / 2;
+ Point aPt0( 0, 0 );
+ Point aPt1( aBmpSize.Width(), 0 );
+
+ aVD.DrawBitmap( Point(), *pBmp );
+ aLineEndSet.InsertItem( 1, aVD.GetBitmap( aPt0, aBmpSize ), pEntry->GetName() );
+ aLineEndSet.InsertItem( 2, aVD.GetBitmap( aPt1, aBmpSize ), pEntry->GetName() );
+
+ delete pLineEndList->Remove( nCount );
+
+ for( long i = 0; i < nCount; i++ )
+ {
+ pEntry = pLineEndList->GetLineEnd( i );
+ DBG_ASSERT( pEntry, "Konnte auf LineEndEntry nicht zugreifen" );
+ pBmp = pLineEndList->GetBitmap( i );
+ DBG_ASSERT( pBmp, "UI-Bitmap wurde nicht erzeugt" );
+
+ aVD.DrawBitmap( aPt0, *pBmp );
+ aLineEndSet.InsertItem( (USHORT)((i+1L)*2L+1L), aVD.GetBitmap( aPt0, aBmpSize ), pEntry->GetName() );
+ aLineEndSet.InsertItem( (USHORT)((i+2L)*2L), aVD.GetBitmap( aPt1, aBmpSize ), pEntry->GetName() );
+ }
+ nLines = Min( (USHORT)(nCount + 1), (USHORT) MAX_LINES );
+ aLineEndSet.SetLineCount( nLines );
+
+ SetSize();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineEndWindow::Resize()
+{
+ // since we change the size inside this call, check if we
+ // are called recursive
+ if( !mbInResize )
+ {
+ mbInResize = true;
+ if ( !IsRollUp() )
+ {
+ aLineEndSet.SetColCount( nCols );
+ aLineEndSet.SetLineCount( nLines );
+
+ SetSize();
+
+ Size aSize = GetOutputSizePixel();
+ aSize.Width() -= 4;
+ aSize.Height() -= 4;
+ aLineEndSet.SetPosSizePixel( Point( 2, 2 ), aSize );
+ }
+ //SfxPopupWindow::Resize();
+ mbInResize = false;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT SvxLineEndWindow::Resizing( Size& rNewSize )
+{
+ Size aBitmapSize = aBmpSize; // -> Member
+ aBitmapSize.Width() += 6; //
+ aBitmapSize.Height() += 6; //
+
+ Size aItemSize = aLineEndSet.CalcItemSizePixel( aBitmapSize ); // -> Member
+ //Size aOldSize = GetOutputSizePixel(); // fuer Breite
+
+ USHORT nItemCount = aLineEndSet.GetItemCount(); // -> Member
+
+ // Spalten ermitteln
+ long nItemW = aItemSize.Width();
+ long nW = rNewSize.Width();
+ nCols = (USHORT) Max( ( (ULONG)(( nW + nItemW ) / ( nItemW * 2 ) )),
+ (ULONG) 1L );
+ nCols *= 2;
+
+ // Reihen ermitteln
+ long nItemH = aItemSize.Height();
+ long nH = rNewSize.Height();
+ nLines = (USHORT) Max( ( ( nH + nItemH / 2 ) / nItemH ), 1L );
+
+ USHORT nMaxCols = nItemCount / nLines;
+ if( nItemCount % nLines )
+ nMaxCols++;
+ if( nCols > nMaxCols )
+ nCols = nMaxCols;
+ nW = nItemW * nCols;
+
+ // Keine ungerade Anzahl von Spalten
+ if( nCols % 2 )
+ nCols--;
+ nCols = Max( nCols, (USHORT) 2 );
+
+ USHORT nMaxLines = nItemCount / nCols;
+ if( nItemCount % nCols )
+ nMaxLines++;
+ if( nLines > nMaxLines )
+ nLines = nMaxLines;
+ nH = nItemH * nLines;
+
+ rNewSize.Width() = nW;
+ rNewSize.Height() = nH;
+}
+// -----------------------------------------------------------------------
+
+void SvxLineEndWindow::StartSelection()
+{
+ aLineEndSet.StartSelection();
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SvxLineEndWindow::Close()
+{
+ return SfxPopupWindow::Close();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineEndWindow::StateChanged(
+ USHORT nSID, SfxItemState, const SfxPoolItem* pState )
+{
+ if ( nSID == SID_LINEEND_LIST )
+ {
+ // Die Liste der LinienEnden (LineEndList) hat sich geaendert:
+ if ( pState && pState->ISA( SvxLineEndListItem ))
+ {
+ pLineEndList = ((SvxLineEndListItem*)pState)->GetLineEndList();
+ DBG_ASSERT( pLineEndList, "LineEndList nicht gefunden" );
+
+ aLineEndSet.Clear();
+ FillValueSet();
+
+ Size aSize = GetOutputSizePixel();
+ Resizing( aSize );
+ Resize();
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineEndWindow::PopupModeEnd()
+{
+ if ( IsVisible() )
+ {
+ bPopupMode = FALSE;
+ SetSize();
+ }
+ SfxPopupWindow::PopupModeEnd();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineEndWindow::SetSize()
+{
+ //if( !bPopupMode )
+ if( !IsInPopupMode() )
+ {
+ USHORT nItemCount = aLineEndSet.GetItemCount(); // -> Member
+ USHORT nMaxLines = nItemCount / nCols; // -> Member ?
+ if( nItemCount % nCols )
+ nMaxLines++;
+
+ WinBits nBits = aLineEndSet.GetStyle();
+ if ( nLines == nMaxLines )
+ nBits &= ~WB_VSCROLL;
+ else
+ nBits |= WB_VSCROLL;
+ aLineEndSet.SetStyle( nBits );
+ }
+
+ Size aSize( aBmpSize );
+ aSize.Width() += 6;
+ aSize.Height() += 6;
+ aSize = aLineEndSet.CalcWindowSizePixel( aSize );
+ aSize.Width() += 4;
+ aSize.Height() += 4;
+ SetOutputSizePixel( aSize );
+ aSize.Height() = aBmpSize.Height();
+ aSize.Height() += 14;
+ //SetMinOutputSizePixel( aSize );
+}
+
+void SvxLineEndWindow::GetFocus (void)
+{
+ SfxPopupWindow::GetFocus();
+ // Grab the focus to the line ends value set so that it can be controlled
+ // with the keyboard.
+ aLineEndSet.GrabFocus();
+}
+
+/*************************************************************************
+|*
+|* SvxLineEndToolBoxControl
+|*
+\************************************************************************/
+
+SvxLineEndToolBoxControl::SvxLineEndToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox &rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+SvxLineEndToolBoxControl::~SvxLineEndToolBoxControl()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType SvxLineEndToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxLineEndToolBoxControl::CreatePopupWindow()
+{
+ SvxLineEndWindow* pLineEndWin =
+ new SvxLineEndWindow( GetId(), m_xFrame, &GetToolBox(), SVX_RESSTR( RID_SVXSTR_LINEEND ) );
+ pLineEndWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS );
+ pLineEndWin->StartSelection();
+ SetPopupWindow( pLineEndWin );
+ return pLineEndWin;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineEndToolBoxControl::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* )
+{
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+ rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/linectrl.src b/svx/source/tbxctrls/linectrl.src
new file mode 100644
index 000000000000..6ed613bb20fe
--- /dev/null
+++ b/svx/source/tbxctrls/linectrl.src
@@ -0,0 +1,34 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "linectrl.hrc"
+
+Bitmap RID_SVXCTRL_LINECTRL
+{
+ File = "soliline.bmp" ;
+};
+
diff --git a/svx/source/tbxctrls/makefile.mk b/svx/source/tbxctrls/makefile.mk
new file mode 100644
index 000000000000..a9ea745f3cc0
--- /dev/null
+++ b/svx/source/tbxctrls/makefile.mk
@@ -0,0 +1,84 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+TARGET=tbxctrls
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+LIB1TARGET= $(SLB)$/$(TARGET)-core.lib
+LIB1OBJFILES= \
+ $(SLO)$/fontworkgallery.obj\
+ $(SLO)$/extrusioncontrols.obj \
+ $(SLO)$/tbcontrl.obj \
+ $(SLO)$/tbxcolorupdate.obj
+
+LIB2TARGET= $(SLB)$/$(TARGET).lib
+LIB2OBJFILES= \
+ $(SLO)$/formatpaintbrushctrl.obj\
+ $(SLO)$/colrctrl.obj \
+ $(SLO)$/fillctrl.obj \
+ $(SLO)$/grafctrl.obj \
+ $(SLO)$/itemwin.obj \
+ $(SLO)$/layctrl.obj \
+ $(SLO)$/lboxctrl.obj \
+ $(SLO)$/linectrl.obj \
+ $(SLO)$/tbxalign.obj \
+ $(SLO)$/tbxdrctl.obj \
+ $(SLO)$/verttexttbxctrl.obj \
+ $(SLO)$/subtoolboxcontrol.obj \
+ $(SLO)$/tbxcolor.obj \
+ $(SLO)$/tbunocontroller.obj \
+ $(SLO)$/tbunosearchcontrollers.obj
+
+SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES)
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ fontworkgallery.src \
+ extrusioncontrols.src \
+ colrctrl.src \
+ lboxctrl.src \
+ linectrl.src \
+ tbcontrl.src \
+ tbunosearchcontrollers.src \
+ tbxdraw.src \
+ grafctrl.src
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/tbxctrls/subtoolboxcontrol.cxx b/svx/source/tbxctrls/subtoolboxcontrol.cxx
new file mode 100644
index 000000000000..96d98ebc6738
--- /dev/null
+++ b/svx/source/tbxctrls/subtoolboxcontrol.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svl/intitem.hxx>
+
+#include <vcl/toolbox.hxx>
+#include <sfx2/app.hxx>
+#include <svx/subtoolboxcontrol.hxx>
+#include <svx/svxids.hrc>
+
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxSubToolBoxControl, SfxUInt16Item );
+
+/**********************************************************************
+
+**********************************************************************/
+
+SvxSubToolBoxControl::SvxSubToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+: SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+}
+
+/**********************************************************************
+
+**********************************************************************/
+
+SvxSubToolBoxControl::~SvxSubToolBoxControl()
+{
+}
+
+/**********************************************************************
+
+**********************************************************************/
+
+SfxPopupWindow* SvxSubToolBoxControl::CreatePopupWindow()
+{
+ const sal_Char* pResource = 0;
+ switch( GetSlotId() )
+ {
+ case SID_OPTIMIZE_TABLE:
+ pResource = "private:resource/toolbar/optimizetablebar";
+ break;
+ }
+
+ if( pResource )
+ createAndPositionSubToolBar( rtl::OUString::createFromAscii( pResource ) );
+ return NULL;
+}
+
+/**********************************************************************
+
+**********************************************************************/
+
+SfxPopupWindowType SvxSubToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
new file mode 100644
index 000000000000..6f47b96b52c1
--- /dev/null
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -0,0 +1,2887 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+#include <tools/shl.hxx>
+#include <svl/poolitem.hxx>
+#include <svl/eitem.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/bmpacc.hxx>
+#include <svtools/valueset.hxx>
+#include <svtools/ctrlbox.hxx>
+#include <svl/style.hxx>
+#include <svtools/ctrltool.hxx>
+#include <svtools/borderhelper.hxx>
+#include <svl/stritem.hxx>
+#include <unotools/pathoptions.hxx>
+#include <sfx2/tplpitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/docfac.hxx>
+#include <sfx2/templdlg.hxx>
+#include <svl/isethint.hxx>
+#include <sfx2/querystatus.hxx>
+#include <sfx2/sfxstatuslistener.hxx>
+#include <tools/urlobj.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <unotools/fontoptions.hxx>
+#include <vcl/mnemonic.hxx>
+
+#include <vcl/svapp.hxx>
+#include <svl/smplhint.hxx>
+
+#define _SVX_TBCONTRL_CXX
+#include <svtools/colorcfg.hxx>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/status/ItemStatus.hpp>
+#include <com/sun/star/frame/status/FontHeight.hpp>
+
+#include <svx/dialogs.hrc>
+#include <svx/svxitems.hrc>
+#include "helpid.hrc"
+#include "htmlmode.hxx"
+#include <svx/xtable.hxx>
+#include "editeng/fontitem.hxx"
+#include <editeng/fhgtitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/colritem.hxx>
+#include "editeng/flstitem.hxx"
+#include "editeng/bolnitem.hxx"
+#include "drawitem.hxx"
+#include <svx/tbcontrl.hxx>
+#include "dlgutil.hxx"
+#include <svx/dialmgr.hxx>
+#include "colorwindow.hxx"
+#include <memory>
+
+#include <svx/framelink.hxx>
+#include <svx/tbxcolorupdate.hxx>
+#include <editeng/eerdll.hxx>
+#include <editeng/editrids.hrc>
+
+// ------------------------------------------------------------------------
+
+#define MAX_MRU_FONTNAME_ENTRIES 5
+#define LOGICAL_EDIT_HEIGHT 12
+
+// STATIC DATA -----------------------------------------------------------
+
+#ifndef DELETEZ
+#define DELETEZ(p) (delete (p), (p)=NULL)
+#endif
+// don't make more than 15 entries visible at once
+#define MAX_STYLES_ENTRIES static_cast< USHORT >( 15 )
+
+void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet );
+void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize );
+BOOL lcl_FontChangedHint( const SfxHint &rHint );
+
+// namespaces
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+
+SFX_IMPL_TOOLBOX_CONTROL( SvxStyleToolBoxControl, SfxTemplateItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxFontNameToolBoxControl, SvxFontItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorToolBoxControl, SvxColorItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxFontColorExtToolBoxControl, SvxColorItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxColorToolBoxControl, SvxColorItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxFrameToolBoxControl, SvxBoxItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineStyleToolBoxControl, SvxLineItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxFrameLineColorToolBoxControl, SvxColorItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxReloadControllerItem, SfxBoolItem );
+SFX_IMPL_TOOLBOX_CONTROL( SvxSimpleUndoRedoController, SfxStringItem );
+
+//========================================================================
+// class SvxStyleBox_Impl -----------------------------------------------------
+//========================================================================
+
+
+class SvxStyleBox_Impl : public ComboBox
+{
+ using Window::IsVisible;
+public:
+ SvxStyleBox_Impl( Window* pParent, USHORT nSlot, const OUString& rCommand, SfxStyleFamily eFamily, const Reference< XDispatchProvider >& rDispatchProvider,
+ const Reference< XFrame >& _xFrame,const String& rClearFormatKey, const String& rMoreKey, BOOL bInSpecialMode );
+ ~SvxStyleBox_Impl();
+
+ void SetFamily( SfxStyleFamily eNewFamily );
+ inline BOOL IsVisible() { return bVisible; }
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual long Notify( NotifyEvent& rNEvt );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ virtual void StateChanged( StateChangedType nStateChange );
+
+ inline void SetVisibilityListener( const Link& aVisListener ) { aVisibilityListener = aVisListener; }
+ inline void RemoveVisibilityListener() { aVisibilityListener = Link(); }
+
+ void SetDefaultStyle( const ::rtl::OUString& rDefault ) { sDefaultStyle = rDefault; }
+ DECL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control* );
+
+protected:
+ virtual void Select();
+
+private:
+ USHORT nSlotId;
+ SfxStyleFamily eStyleFamily;
+ USHORT nCurSel;
+ BOOL bRelease;
+ Size aLogicalSize;
+ Link aVisibilityListener;
+ BOOL bVisible;
+ Reference< XDispatchProvider > m_xDispatchProvider;
+ Reference< XFrame > m_xFrame;
+ OUString m_aCommand;
+ String aClearFormatKey;
+ String aMoreKey;
+ String sDefaultStyle;
+ BOOL bInSpecialMode;
+
+ void ReleaseFocus();
+};
+
+//========================================================================
+// class SvxFontNameBox --------------------------------------------------
+//========================================================================
+
+class SvxFontNameBox_Impl : public FontNameBox
+{
+ using Window::Update;
+private:
+ const FontList* pFontList;
+ ::std::auto_ptr<FontList> m_aOwnFontList;
+ Font aCurFont;
+ Size aLogicalSize;
+ String aCurText;
+ USHORT nFtCount;
+ BOOL bRelease;
+ Reference< XDispatchProvider > m_xDispatchProvider;
+ Reference< XFrame > m_xFrame;
+
+ void ReleaseFocus_Impl();
+ void EnableControls_Impl();
+
+protected:
+ virtual void Select();
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+public:
+ SvxFontNameBox_Impl( Window* pParent, const Reference< XDispatchProvider >& rDispatchProvider,const Reference< XFrame >& _xFrame
+ , WinBits nStyle = WB_SORT
+ );
+
+ void FillList();
+ void Update( const SvxFontItem* pFontItem );
+ USHORT GetListCount() { return nFtCount; }
+ void Clear() { FontNameBox::Clear(); nFtCount = 0; }
+ void Fill( const FontList* pList )
+ { FontNameBox::Fill( pList );
+ nFtCount = pList->GetFontNameCount(); }
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual long Notify( NotifyEvent& rNEvt );
+ virtual Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+ inline void SetOwnFontList(::std::auto_ptr<FontList> _aOwnFontList) { m_aOwnFontList = _aOwnFontList; }
+};
+
+//========================================================================
+// class SvxFrameWindow_Impl --------------------------------------------------
+//========================================================================
+
+// fuer den SelectHdl werden die Modifier gebraucht, also
+// muss man sie im MouseButtonUp besorgen
+
+class SvxFrmValueSet_Impl : public ValueSet
+{
+ USHORT nModifier;
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+public:
+ SvxFrmValueSet_Impl(Window* pParent, WinBits nWinStyle)
+ : ValueSet(pParent, nWinStyle), nModifier(0) {}
+ USHORT GetModifier() const {return nModifier;}
+
+};
+
+void SvxFrmValueSet_Impl::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ nModifier = rMEvt.GetModifier();
+ ValueSet::MouseButtonUp(rMEvt);
+}
+
+class SvxFrameWindow_Impl : public SfxPopupWindow
+{
+ using FloatingWindow::StateChanged;
+
+private:
+ SvxFrmValueSet_Impl aFrameSet;
+ ImageList aImgList;
+ sal_Bool bParagraphMode;
+
+#if _SOLAR__PRIVATE
+ DECL_LINK( SelectHdl, void * );
+#endif
+
+protected:
+ virtual void Resize();
+ virtual BOOL Close();
+ virtual Window* GetPreferredKeyInputWindow();
+ virtual void GetFocus();
+
+public:
+ SvxFrameWindow_Impl( USHORT nId, const Reference< XFrame >& rFrame, Window* pParentWindow );
+ ~SvxFrameWindow_Impl();
+ void StartSelection();
+
+ virtual void StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState );
+ virtual SfxPopupWindow* Clone() const;
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ inline BOOL IsHighContrast( void ) const;
+};
+
+inline BOOL SvxFrameWindow_Impl::IsHighContrast( void ) const
+{
+ return GetSettings().GetStyleSettings().GetHighContrastMode();
+}
+
+//========================================================================
+// class SvxLineWindow_Impl ---------------------------------------------------
+//========================================================================
+class SvxLineWindow_Impl : public SfxPopupWindow
+{
+private:
+ ValueSet aLineSet;
+ bool m_bIsWriter;
+
+#if _SOLAR__PRIVATE
+ void MakeLineBitmap( USHORT nNo, Bitmap& rBmp, const Size& rSize, String& rStr,
+ const ::Color& rLine, const ::Color& rBack );
+ DECL_LINK( SelectHdl, void * );
+#endif
+
+protected:
+ virtual void Resize();
+ virtual BOOL Close();
+ virtual Window* GetPreferredKeyInputWindow();
+ virtual void GetFocus();
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ void CreateBitmaps( void );
+public:
+ SvxLineWindow_Impl( USHORT nId, const Reference< XFrame >& rFrame, Window* pParentWindow );
+
+ void StartSelection();
+ virtual SfxPopupWindow* Clone() const;
+};
+
+//########################################################################
+// Hilfsklassen:
+//========================================================================
+// class SfxStyleControllerItem ------------------------------------------
+//========================================================================
+class SvxStyleToolBoxControl;
+
+class SfxStyleControllerItem_Impl : public SfxStatusListener
+{
+ public:
+ SfxStyleControllerItem_Impl( const Reference< XDispatchProvider >& rDispatchProvider,
+ USHORT nSlotId,
+ const rtl::OUString& rCommand,
+ SvxStyleToolBoxControl& rTbxCtl );
+
+ protected:
+ virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState );
+
+ private:
+ SvxStyleToolBoxControl& rControl;
+};
+
+//========================================================================
+// class SvxStyleBox_Impl -----------------------------------------------------
+//========================================================================
+
+SvxStyleBox_Impl::SvxStyleBox_Impl(
+ Window* pParent,
+ USHORT nSlot,
+ const rtl::OUString& rCommand,
+ SfxStyleFamily eFamily,
+ const Reference< XDispatchProvider >& rDispatchProvider,
+ const Reference< XFrame >& _xFrame,
+ const String& rClearFormatKey,
+ const String& rMoreKey,
+ BOOL bInSpec) :
+
+ ComboBox( pParent, SVX_RES( RID_SVXTBX_STYLE ) ),
+
+ nSlotId ( nSlot ),
+ eStyleFamily( eFamily ),
+ bRelease ( TRUE ),
+ bVisible(FALSE),
+ m_xDispatchProvider( rDispatchProvider ),
+ m_xFrame(_xFrame),
+ m_aCommand ( rCommand ),
+ aClearFormatKey ( rClearFormatKey ),
+ aMoreKey ( rMoreKey ),
+ bInSpecialMode ( bInSpec )
+{
+ aLogicalSize = PixelToLogic( GetSizePixel(), MAP_APPFONT );
+ EnableAutocomplete( TRUE );
+}
+
+SvxStyleBox_Impl::~SvxStyleBox_Impl()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxStyleBox_Impl::ReleaseFocus()
+{
+ if ( !bRelease )
+ {
+ bRelease = TRUE;
+ return;
+ }
+ if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
+ m_xFrame->getContainerWindow()->setFocus();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxStyleBox_Impl::Select()
+{
+ // Tell base class about selection so that AT get informed about it.
+ ComboBox::Select();
+
+ if ( !IsTravelSelect() )
+ {
+ String aSelEntry( GetText() );
+ bool bDoIt = true, bClear = false;
+ if( bInSpecialMode )
+ {
+ if( aSelEntry == aClearFormatKey && GetSelectEntryPos() == 0 )
+ {
+ aSelEntry = sDefaultStyle;
+ bClear = true;
+ //not only apply default style but also call 'ClearFormatting'
+ Sequence< PropertyValue > aEmptyVals;
+ SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:ResetAttributes"),
+ aEmptyVals);
+ }
+ else if( aSelEntry == aMoreKey && GetSelectEntryPos() == ( GetEntryCount() - 1 ) )
+ {
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ DBG_ASSERT( pViewFrm, "SvxStyleBox_Impl::Select(): no viewframe" );
+ pViewFrm->ShowChildWindow( SID_STYLE_DESIGNER );
+ SfxChildWindow* pChildWin = pViewFrm->GetChildWindow( SID_STYLE_DESIGNER );
+ if ( pChildWin && pChildWin->GetWindow() )
+ {
+ static_cast< SfxTemplateDialogWrapper* >( pChildWin )->SetParagraphFamily();
+ static_cast< SfxDockingWindow* >( pChildWin->GetWindow() )->AutoShow( sal_True );
+ Application::PostUserEvent(
+ STATIC_LINK( 0, SvxStyleBox_Impl, FocusHdl_Impl ), pChildWin->GetWindow() );
+ }
+ bDoIt = false;
+ }
+ }
+
+ // #i36723# after ReleaseFocus() the new entry is included into the List
+ sal_Bool bCreateNew = GetSelectEntryPos() == LISTBOX_ENTRY_NOTFOUND;
+
+ /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
+ This instance may be deleted in the meantime (i.e. when a dialog is opened
+ while in Dispatch()), accessing members will crash in this case. */
+ ReleaseFocus();
+
+ if( bDoIt )
+ {
+ if ( bClear )
+ SetText( aSelEntry );
+ SaveValue();
+
+ Sequence< PropertyValue > aArgs( 2 );
+ aArgs[0].Value = makeAny( OUString( aSelEntry ) );
+ aArgs[1].Name = OUString::createFromAscii( "Family" );
+ aArgs[1].Value = makeAny( sal_Int16( eStyleFamily ));
+ if( bCreateNew )
+ {
+ aArgs[0].Name = OUString::createFromAscii( "Param" );
+ SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:StyleNewByExample"), aArgs);
+ }
+ else
+ {
+ aArgs[0].Name = OUString::createFromAscii( "Template" );
+ SfxToolBoxControl::Dispatch( m_xDispatchProvider, m_aCommand, aArgs );
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------
+
+void SvxStyleBox_Impl::SetFamily( SfxStyleFamily eNewFamily )
+{
+ eStyleFamily = eNewFamily;
+}
+
+// -----------------------------------------------------------------------
+
+long SvxStyleBox_Impl::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nType = rNEvt.GetType();
+
+ if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
+ nCurSel = GetSelectEntryPos();
+ else if ( EVENT_LOSEFOCUS == nType )
+ {
+ // don't handle before our Select() is called
+ if ( !HasFocus() && !HasChildPathFocus() )
+ SetText( GetSavedValue() );
+ }
+ return ComboBox::PreNotify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+long SvxStyleBox_Impl::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = 0;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ USHORT nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+
+ switch ( nCode )
+ {
+ case KEY_RETURN:
+ case KEY_TAB:
+ {
+ if ( KEY_TAB == nCode )
+ bRelease = FALSE;
+ else
+ nHandled = 1;
+ Select();
+ break;
+ }
+
+ case KEY_ESCAPE:
+ SelectEntryPos( nCurSel );
+ ReleaseFocus();
+ nHandled = 1;
+ break;
+ }
+ }
+ return nHandled ? nHandled : ComboBox::Notify( rNEvt );
+}
+/* -----------------------------08.03.2002 13:03------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxStyleBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
+ Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
+ SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
+ }
+
+ ComboBox::DataChanged( rDCEvt );
+}
+
+void SvxStyleBox_Impl::StateChanged( StateChangedType nStateChange )
+{
+ ComboBox::StateChanged( nStateChange );
+
+ if ( nStateChange == STATE_CHANGE_VISIBLE )
+ {
+ bVisible = IsReallyVisible();
+ if ( aVisibilityListener.IsSet() )
+ aVisibilityListener.Call( this );
+ }
+ else if ( nStateChange == STATE_CHANGE_INITSHOW )
+ {
+ bVisible = TRUE;
+ if ( aVisibilityListener.IsSet() )
+ aVisibilityListener.Call( this );
+ }
+}
+
+//--------------------------------------------------------------------
+
+IMPL_STATIC_LINK( SvxStyleBox_Impl, FocusHdl_Impl, Control*, _pCtrl )
+{
+ (void)pThis;
+ if ( _pCtrl )
+ _pCtrl->GrabFocus();
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL GetDocFontList_Impl( const FontList** ppFontList, SvxFontNameBox_Impl* pBox )
+{
+ BOOL bChanged = FALSE;
+ const SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ SvxFontListItem* pFontListItem = NULL;
+
+ if ( pDocSh )
+ pFontListItem =
+ (SvxFontListItem*)pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
+ else
+ {
+ ::std::auto_ptr<FontList> aFontList(new FontList( pBox ));
+ *ppFontList = aFontList.get();
+ pBox->SetOwnFontList(aFontList);
+ bChanged = TRUE;
+ }
+
+ if ( pFontListItem )
+ {
+ const FontList* pNewFontList = pFontListItem->GetFontList();
+ DBG_ASSERT( pNewFontList, "Doc-FontList not available!" );
+
+ // keine alte Liste, aber neue Liste
+ if ( !*ppFontList && pNewFontList )
+ {
+ // => "ubernehmen
+ *ppFontList = pNewFontList;
+ bChanged = TRUE;
+ }
+ else
+ {
+ // Vergleich der Fontlisten ist nicht vollkommen
+ // wird die Fontliste am Doc geaendert, kann man hier
+ // nur ueber die Listbox Aenderungen feststellen, weil
+ // ppFontList dabei schon upgedatet wurde
+ bChanged =
+ ( ( *ppFontList != pNewFontList ) ||
+ pBox->GetListCount() != pNewFontList->GetFontNameCount() );
+ HACK(vergleich ist unvollstaendig)
+
+ if ( bChanged )
+ *ppFontList = pNewFontList;
+ }
+
+ if ( pBox )
+ pBox->Enable();
+ }
+ else if ( pBox && ( pDocSh || ( !pDocSh && !ppFontList )))
+ {
+ // Disable box only when we have a SfxObjectShell and didn't get a font list OR
+ // we don't have a SfxObjectShell and no current font list.
+ // It's possible that we currently have no SfxObjectShell, but a current font list.
+ // See #i58471: When a user set the focus into the font name combo box and opens
+ // the help window with F1. After closing the help window, we disable the font name
+ // combo box. The SfxObjectShell::Current() method returns in that case zero. But the
+ // font list hasn't changed and therefore the combo box shouldn't be disabled!
+ pBox->Disable();
+ }
+
+ // in die FontBox ggf. auch die neue Liste f"ullen
+ if ( pBox && bChanged )
+ {
+ if ( *ppFontList )
+ pBox->Fill( *ppFontList );
+ else
+ pBox->Clear();
+ }
+ return bChanged;
+}
+
+//========================================================================
+// class SvxFontNameBox_Impl --------------------------------------------------
+//========================================================================
+
+SvxFontNameBox_Impl::SvxFontNameBox_Impl( Window* pParent, const Reference< XDispatchProvider >& rDispatchProvider,const Reference< XFrame >& _xFrame, WinBits nStyle ) :
+
+ FontNameBox ( pParent, nStyle | WinBits( WB_DROPDOWN | WB_AUTOHSCROLL ) ),
+ pFontList ( NULL ),
+ aLogicalSize ( 75,160 ),
+ nFtCount ( 0 ),
+ bRelease ( TRUE ),
+ m_xDispatchProvider( rDispatchProvider ),
+ m_xFrame (_xFrame)
+{
+ SetSizePixel(LogicToPixel( aLogicalSize, MAP_APPFONT ));
+ EnableControls_Impl();
+}
+// -----------------------------------------------------------------------
+
+void SvxFontNameBox_Impl::FillList()
+{
+ // alte Selektion merken, und am Ende wieder setzen
+ Selection aOldSel = GetSelection();
+ // hat sich Doc-Fontlist geaendert?
+ GetDocFontList_Impl( &pFontList, this );
+ aCurText = GetText();
+ SetSelection( aOldSel );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontNameBox_Impl::Update( const SvxFontItem* pFontItem )
+{
+ if ( pFontItem )
+ {
+ aCurFont.SetName ( pFontItem->GetFamilyName() );
+ aCurFont.SetFamily ( pFontItem->GetFamily() );
+ aCurFont.SetStyleName ( pFontItem->GetStyleName() );
+ aCurFont.SetPitch ( pFontItem->GetPitch() );
+ aCurFont.SetCharSet ( pFontItem->GetCharSet() );
+ }
+ String aCurName = aCurFont.GetName();
+ if ( GetText() != aCurName )
+ SetText( aCurName );
+}
+
+// -----------------------------------------------------------------------
+
+long SvxFontNameBox_Impl::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nType = rNEvt.GetType();
+
+ if ( EVENT_MOUSEBUTTONDOWN == nType || EVENT_GETFOCUS == nType )
+ {
+ EnableControls_Impl();
+ FillList();
+ }
+ return FontNameBox::PreNotify( rNEvt );
+}
+
+// -----------------------------------------------------------------------
+
+long SvxFontNameBox_Impl::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = 0;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ USHORT nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+
+ switch ( nCode )
+ {
+ case KEY_RETURN:
+ case KEY_TAB:
+ {
+ if ( KEY_TAB == nCode )
+ bRelease = FALSE;
+ else
+ nHandled = 1;
+ Select();
+ break;
+ }
+
+ case KEY_ESCAPE:
+ SetText( aCurText );
+ ReleaseFocus_Impl();
+ break;
+ }
+ }
+ else if ( EVENT_LOSEFOCUS == rNEvt.GetType() )
+ {
+ Window* pFocusWin = Application::GetFocusWindow();
+ if ( !HasFocus() && GetSubEdit() != pFocusWin )
+ SetText( GetSavedValue() );
+ }
+
+ return nHandled ? nHandled : FontNameBox::Notify( rNEvt );
+}
+
+// ---------------------------------------------------------------------------
+void SvxFontNameBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ SetSizePixel(LogicToPixel(aLogicalSize, MAP_APPFONT));
+ Size aDropSize( aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT);
+ SetDropDownSizePixel(LogicToPixel(aDropSize, MAP_APPFONT));
+ }
+
+ FontNameBox::DataChanged( rDCEvt );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontNameBox_Impl::ReleaseFocus_Impl()
+{
+ if ( !bRelease )
+ {
+ bRelease = TRUE;
+ return;
+ }
+ if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
+ m_xFrame->getContainerWindow()->setFocus();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontNameBox_Impl::EnableControls_Impl()
+{
+ SvtFontOptions aFontOpt;
+ BOOL bEnable = aFontOpt.IsFontHistoryEnabled();
+ USHORT nEntries = bEnable ? MAX_MRU_FONTNAME_ENTRIES : 0;
+ if ( GetMaxMRUCount() != nEntries )
+ {
+ // refill in the next GetFocus-Handler
+ pFontList = NULL;
+ Clear();
+ SetMaxMRUCount( nEntries );
+ }
+
+ bEnable = aFontOpt.IsFontWYSIWYGEnabled();
+ EnableWYSIWYG( bEnable );
+ EnableSymbols( bEnable );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontNameBox_Impl::Select()
+{
+ FontNameBox::Select();
+
+ if ( !IsTravelSelect() )
+ {
+ if ( pFontList )
+ {
+ FontInfo aInfo( pFontList->Get( GetText(),
+ aCurFont.GetWeight(),
+ aCurFont.GetItalic() ) );
+ aCurFont = aInfo;
+
+ SvxFontItem aFontItem( aInfo.GetFamily(),
+ aInfo.GetName(),
+ aInfo.GetStyleName(),
+ aInfo.GetPitch(),
+ aInfo.GetCharSet(),
+ SID_ATTR_CHAR_FONT );
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharFontName" ));
+ aFontItem.QueryValue( a );
+ aArgs[0].Value = a;
+
+ // #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
+ // This instance may be deleted in the meantime (i.e. when a dialog is opened
+ // while in Dispatch()), accessing members will crash in this case.
+ ReleaseFocus_Impl();
+
+ SfxToolBoxControl::Dispatch( m_xDispatchProvider,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName" )),
+ aArgs );
+ }
+ else
+ ReleaseFocus_Impl();
+ }
+}
+
+//========================================================================
+// class SvxColorWindow_Impl --------------------------------------------------
+//========================================================================
+#ifndef WB_NO_DIRECTSELECT
+#define WB_NO_DIRECTSELECT ((WinBits)0x04000000)
+#endif
+
+#define PALETTE_X 10
+#define PALETTE_Y 11
+#define PALETTE_SIZE (PALETTE_X * PALETTE_Y)
+
+SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
+ USHORT nSlotId,
+ const Reference< XFrame >& rFrame,
+ const String& rWndTitle,
+ Window* pParentWindow ) :
+
+ SfxPopupWindow( nSlotId, rFrame, pParentWindow, WinBits( WB_STDPOPUP ) ),
+
+ theSlotId( nSlotId ),
+ aColorSet( this, WinBits( WB_ITEMBORDER | WB_NAMEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT) ),
+ maCommand( rCommand )
+
+{
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ const SfxPoolItem* pItem = NULL;
+ XColorTable* pColorTable = NULL;
+ BOOL bKillTable = FALSE;
+ const Size aSize12( 13, 13 );
+
+ if ( pDocSh )
+ if ( 0 != ( pItem = pDocSh->GetItem( SID_COLOR_TABLE ) ) )
+ pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
+
+ if ( !pColorTable )
+ {
+ pColorTable = new XColorTable( SvtPathOptions().GetPalettePath() );
+ bKillTable = TRUE;
+ }
+
+ if ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId )
+ {
+ aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
+ aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_TRANSPARENT ) );
+ }
+ else if ( SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId )
+ {
+ SfxPoolItem* pDummy;
+
+ Reference< XDispatchProvider > aDisp( GetFrame()->getController(), UNO_QUERY );
+ SfxQueryStatus aQueryStatus( aDisp,
+ SID_ATTR_AUTO_COLOR_INVALID,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoColorInvalid" )));
+ SfxItemState eState = aQueryStatus.QueryState( pDummy );
+ if( (SFX_ITEM_DEFAULT > eState) || ( SID_EXTRUSION_3D_COLOR == theSlotId ) )
+ {
+ aColorSet.SetStyle( aColorSet.GetStyle() | WB_NONEFIELD );
+ aColorSet.SetText( SVX_RESSTR( RID_SVXSTR_AUTOMATIC ) );
+ }
+ }
+
+ if ( pColorTable )
+ {
+ short i = 0;
+ long nCount = pColorTable->Count();
+ XColorEntry* pEntry = NULL;
+ ::Color aColWhite( COL_WHITE );
+ String aStrWhite( EditResId(RID_SVXITEMS_COLOR_WHITE) );
+
+ if ( nCount > PALETTE_SIZE )
+ // Show scrollbar if more than PALLETTE_SIZE colors are available
+ aColorSet.SetStyle( aColorSet.GetStyle() | WB_VSCROLL );
+
+ for ( i = 0; i < nCount; i++ )
+ {
+ pEntry = pColorTable->GetColor(i);
+ aColorSet.InsertItem( i+1, pEntry->GetColor(), pEntry->GetName() );
+ }
+
+ while ( i < PALETTE_SIZE )
+ {
+ // fill empty elements if less then PALLETTE_SIZE colors are available
+ aColorSet.InsertItem( i+1, aColWhite, aStrWhite );
+ i++;
+ }
+ }
+
+ aColorSet.SetSelectHdl( LINK( this, SvxColorWindow_Impl, SelectHdl ) );
+ aColorSet.SetColCount( PALETTE_X );
+ aColorSet.SetLineCount( PALETTE_Y );
+
+ lcl_CalcSizeValueSet( *this, aColorSet, aSize12 );
+
+ SetHelpId( HID_POPUP_COLOR );
+ aColorSet.SetHelpId( HID_POPUP_COLOR_CTRL );
+
+ SetText( rWndTitle );
+ aColorSet.Show();
+
+ AddStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColorTableState" )));
+ if ( bKillTable )
+ delete pColorTable;
+}
+
+SvxColorWindow_Impl::~SvxColorWindow_Impl()
+{
+}
+
+void SvxColorWindow_Impl::KeyInput( const KeyEvent& rKEvt )
+{
+ aColorSet.KeyInput(rKEvt);
+}
+
+SfxPopupWindow* SvxColorWindow_Impl::Clone() const
+{
+ return new SvxColorWindow_Impl( maCommand, theSlotId, GetFrame(), GetText(), GetParent() );
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxColorWindow_Impl, SelectHdl, void *, EMPTYARG )
+{
+ USHORT nItemId = aColorSet.GetSelectItemId();
+ SvxColorItem aColorItem( aColorSet.GetItemColor( nItemId ), theSlotId );
+
+ /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() calls.
+ This instance may be deleted in the meantime (i.e. when a dialog is opened
+ while in Dispatch()), accessing members will crash in this case. */
+ aColorSet.SetNoSelection();
+
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ if ( !nItemId && ( SID_ATTR_CHAR_COLOR_BACKGROUND == theSlotId || SID_BACKGROUND_COLOR == theSlotId ) )
+ {
+ Sequence< PropertyValue > aArgs;
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
+ maCommand,
+ aArgs );
+ }
+ else if ( !nItemId && (SID_ATTR_CHAR_COLOR == theSlotId || SID_ATTR_CHAR_COLOR2 == theSlotId || SID_EXTRUSION_3D_COLOR == theSlotId) )
+ {
+ SvxColorItem _aColorItem( COL_AUTO, theSlotId );
+ INetURLObject aObj( maCommand );
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = aObj.GetURLPath();
+ _aColorItem.QueryValue( a );
+ aArgs[0].Value = a;
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
+ maCommand,
+ aArgs );
+ }
+ else
+ {
+ INetURLObject aObj( maCommand );
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = aObj.GetURLPath();
+ aColorItem.QueryValue( a );
+ aArgs[0].Value = a;
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
+ maCommand,
+ aArgs );
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxColorWindow_Impl::Resize()
+{
+ lcl_ResizeValueSet( *this, aColorSet);
+}
+
+// -----------------------------------------------------------------------
+
+void SvxColorWindow_Impl::StartSelection()
+{
+ aColorSet.StartSelection();
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SvxColorWindow_Impl::Close()
+{
+ return SfxPopupWindow::Close();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxColorWindow_Impl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+{
+ if (( SFX_ITEM_DISABLED != eState ) && pState )
+ {
+ if (( nSID == SID_COLOR_TABLE ) && ( pState->ISA( SvxColorTableItem )))
+ {
+ XColorTable* pColorTable = pState ? ((SvxColorTableItem *)pState)->GetColorTable() : NULL;
+
+ if ( pColorTable )
+ {
+ // Die Liste der Farben (ColorTable) hat sich ge"andert:
+ short i = 0;
+ long nCount = pColorTable->Count();
+ XColorEntry* pEntry = NULL;
+ ::Color aColWhite( COL_WHITE );
+ String aStrWhite( SVX_RES( RID_SVXITEMS_COLOR_WHITE ) );
+
+ // ScrollBar an oder aus
+ WinBits nBits = aColorSet.GetStyle();
+ if ( nCount > PALETTE_SIZE )
+ nBits &= ~WB_VSCROLL;
+ else
+ nBits |= WB_VSCROLL;
+ aColorSet.SetStyle( nBits );
+
+ for ( i = 0; i < nCount; ++i )
+ {
+ pEntry = pColorTable->GetColor(i);
+ aColorSet.SetItemColor( i + 1, pEntry->GetColor() );
+ aColorSet.SetItemText ( i + 1, pEntry->GetName() );
+ }
+
+ while ( i < PALETTE_SIZE )
+ {
+ aColorSet.SetItemColor( i + 1, aColWhite );
+ aColorSet.SetItemText ( i + 1, aStrWhite );
+ i++;
+ }
+ }
+ }
+ }
+}
+
+//========================================================================
+// class SvxFrameWindow_Impl --------------------------------------------------
+//========================================================================
+
+SvxFrameWindow_Impl::SvxFrameWindow_Impl( USHORT nId, const Reference< XFrame >& rFrame, Window* pParentWindow ) :
+
+ SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP ) ),
+ aFrameSet ( this, WinBits( WB_ITEMBORDER | WB_DOUBLEBORDER | WB_3DLOOK | WB_NO_DIRECTSELECT ) ),
+ bParagraphMode(sal_False)
+
+{
+ BindListener();
+ String sCommand(String::CreateFromAscii( ".uno:BorderReducedMode" ));
+ AddStatusListener( sCommand );
+ aImgList = ImageList( SVX_RES( IsHighContrast()? RID_SVXIL_FRAME_HC : RID_SVXIL_FRAME ) );
+
+ /*
+ * 1 2 3 4
+ * -------------------------------------
+ * NONE LEFT RIGHT LEFTRIGHT
+ * TOP BOTTOM TOPBOTTOM OUTER
+ * -------------------------------------
+ * HOR HORINNER VERINNER ALL <- kann ueber bParagraphMode
+ * abgeschaltet werden
+ */
+
+ USHORT i = 0;
+
+ for ( i=1; i<9; i++ )
+ aFrameSet.InsertItem( i, aImgList.GetImage(i) );
+
+ //bParagraphMode should have been set in StateChanged
+ if ( !bParagraphMode )
+ for ( i = 9; i < 13; i++ )
+ aFrameSet.InsertItem( i, aImgList.GetImage(i) );
+
+ aFrameSet.SetColCount( 4 );
+ aFrameSet.SetSelectHdl( LINK( this, SvxFrameWindow_Impl, SelectHdl ) );
+
+ lcl_CalcSizeValueSet( *this, aFrameSet,Size( 20, 20 ));
+
+ SetHelpId( HID_POPUP_FRAME );
+ SetText( SVX_RESSTR(RID_SVXSTR_FRAME) );
+ aFrameSet.Show();
+}
+/*-- 22.09.2004 12:27:50---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+SvxFrameWindow_Impl::~SvxFrameWindow_Impl()
+{
+ UnbindListener();
+}
+
+SfxPopupWindow* SvxFrameWindow_Impl::Clone() const
+{
+ //! HACK: wie bekomme ich den Paragraph-Mode ??
+ return new SvxFrameWindow_Impl( GetId(), GetFrame(), GetParent() );
+}
+
+Window* SvxFrameWindow_Impl::GetPreferredKeyInputWindow()
+{
+ return &aFrameSet;
+}
+
+void SvxFrameWindow_Impl::GetFocus()
+{
+ aFrameSet.GrabFocus();
+}
+
+void SvxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ SfxPopupWindow::DataChanged( rDCEvt );
+
+ if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ {
+ aImgList = ImageList( SVX_RES( IsHighContrast()? RID_SVXIL_FRAME_HC : RID_SVXIL_FRAME ) );
+
+ USHORT nNumOfItems = aFrameSet.GetItemCount();
+
+ for( USHORT i = 1 ; i <= nNumOfItems ; ++i )
+ aFrameSet.SetItemImage( i, aImgList.GetImage( i ) );
+ }
+}
+// -----------------------------------------------------------------------
+
+#define FRM_VALID_LEFT 0x01
+#define FRM_VALID_RIGHT 0x02
+#define FRM_VALID_TOP 0x04
+#define FRM_VALID_BOTTOM 0x08
+#define FRM_VALID_HINNER 0x10
+#define FRM_VALID_VINNER 0x20
+#define FRM_VALID_OUTER 0x0f
+#define FRM_VALID_ALL 0xff
+
+//
+// Per default bleiben ungesetzte Linien unveraendert
+// Mit Shift werden ungesetzte Linien zurueckgsetzt
+//
+IMPL_LINK( SvxFrameWindow_Impl, SelectHdl, void *, EMPTYARG )
+{
+ ::Color aColBlack( COL_BLACK );
+ SvxBoxItem aBorderOuter( SID_ATTR_BORDER_OUTER );
+ SvxBoxInfoItem aBorderInner( SID_ATTR_BORDER_INNER );
+ SvxBorderLine theDefLine;
+ SvxBorderLine *pLeft = 0,
+ *pRight = 0,
+ *pTop = 0,
+ *pBottom = 0;
+ USHORT nSel = aFrameSet.GetSelectItemId();
+ USHORT nModifier = aFrameSet.GetModifier();
+ BYTE nValidFlags = 0;
+
+ theDefLine.SetOutWidth( DEF_LINE_WIDTH_0 );
+ switch ( nSel )
+ {
+ case 1: nValidFlags |= FRM_VALID_ALL;
+ break; // NONE
+ case 2: pLeft = &theDefLine;
+ nValidFlags |= FRM_VALID_LEFT;
+ break; // LEFT
+ case 3: pRight = &theDefLine;
+ nValidFlags |= FRM_VALID_RIGHT;
+ break; // RIGHT
+ case 4: pLeft = pRight = &theDefLine;
+ nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT;
+ break; // LEFTRIGHT
+ case 5: pTop = &theDefLine;
+ nValidFlags |= FRM_VALID_TOP;
+ break; // TOP
+ case 6: pBottom = &theDefLine;
+ nValidFlags |= FRM_VALID_BOTTOM;
+ break; // BOTTOM
+ case 7: pTop = pBottom = &theDefLine;
+ nValidFlags |= FRM_VALID_BOTTOM|FRM_VALID_TOP;
+ break; // TOPBOTTOM
+ case 8: pLeft = pRight = pTop = pBottom = &theDefLine;
+ nValidFlags |= FRM_VALID_OUTER;
+ break; // OUTER
+
+ // Tabelle innen:
+ case 9: // HOR
+ pTop = pBottom = &theDefLine;
+ aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
+ aBorderInner.SetLine( NULL, BOXINFO_LINE_VERT );
+ nValidFlags |= FRM_VALID_HINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
+ break;
+
+ case 10: // HORINNER
+ pLeft = pRight = pTop = pBottom = &theDefLine;
+ aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
+ aBorderInner.SetLine( NULL, BOXINFO_LINE_VERT );
+ nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT|FRM_VALID_HINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
+ break;
+
+ case 11: // VERINNER
+ pLeft = pRight = pTop = pBottom = &theDefLine;
+ aBorderInner.SetLine( NULL, BOXINFO_LINE_HORI );
+ aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_VERT );
+ nValidFlags |= FRM_VALID_RIGHT|FRM_VALID_LEFT|FRM_VALID_VINNER|FRM_VALID_TOP|FRM_VALID_BOTTOM;
+ break;
+
+ case 12: // ALL
+ pLeft = pRight = pTop = pBottom = &theDefLine;
+ aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_HORI );
+ aBorderInner.SetLine( &theDefLine, BOXINFO_LINE_VERT );
+ nValidFlags |= FRM_VALID_ALL;
+ break;
+
+ default:
+ break;
+ }
+ aBorderOuter.SetLine( pLeft, BOX_LINE_LEFT );
+ aBorderOuter.SetLine( pRight, BOX_LINE_RIGHT );
+ aBorderOuter.SetLine( pTop, BOX_LINE_TOP );
+ aBorderOuter.SetLine( pBottom, BOX_LINE_BOTTOM );
+
+ if(nModifier == KEY_SHIFT)
+ nValidFlags |= FRM_VALID_ALL;
+ aBorderInner.SetValid( VALID_TOP, 0 != (nValidFlags&FRM_VALID_TOP ));
+ aBorderInner.SetValid( VALID_BOTTOM, 0 != (nValidFlags&FRM_VALID_BOTTOM ));
+ aBorderInner.SetValid( VALID_LEFT, 0 != (nValidFlags&FRM_VALID_LEFT));
+ aBorderInner.SetValid( VALID_RIGHT, 0 != (nValidFlags&FRM_VALID_RIGHT ));
+ aBorderInner.SetValid( VALID_HORI, 0 != (nValidFlags&FRM_VALID_HINNER ));
+ aBorderInner.SetValid( VALID_VERT, 0 != (nValidFlags&FRM_VALID_VINNER));
+ aBorderInner.SetValid( VALID_DISTANCE, TRUE );
+ aBorderInner.SetValid( VALID_DISABLE, FALSE );
+
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 2 );
+ aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "OuterBorder" ));
+ aBorderOuter.QueryValue( a );
+ aArgs[0].Value = a;
+ aArgs[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "InnerBorder" ));
+ aBorderInner.QueryValue( a );
+ aArgs[1].Value = a;
+
+ /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
+ This instance may be deleted in the meantime (i.e. when a dialog is opened
+ while in Dispatch()), accessing members will crash in this case. */
+ aFrameSet.SetNoSelection();
+
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SetBorderStyle" )),
+ aArgs );
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFrameWindow_Impl::Resize()
+{
+ lcl_ResizeValueSet( *this, aFrameSet);
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFrameWindow_Impl::StateChanged(
+
+ USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ if ( pState && nSID == SID_BORDER_REDUCED_MODE)
+ {
+ const SfxBoolItem* pItem = PTR_CAST( SfxBoolItem, pState );
+
+ if ( pItem )
+ {
+ bParagraphMode = (BOOL)pItem->GetValue();
+ //initial calls mustn't insert or remove elements
+ if(aFrameSet.GetItemCount())
+ {
+ BOOL bTableMode = ( aFrameSet.GetItemCount() == 12 );
+ BOOL bResize = FALSE;
+
+ if ( bTableMode && bParagraphMode )
+ {
+ for ( USHORT i = 9; i < 13; i++ )
+ aFrameSet.RemoveItem(i);
+ bResize = TRUE;
+ }
+ else if ( !bTableMode && !bParagraphMode )
+ {
+ for ( USHORT i = 9; i < 13; i++ )
+ aFrameSet.InsertItem( i, aImgList.GetImage(i) );
+ bResize = TRUE;
+ }
+
+ if ( bResize )
+ {
+ lcl_CalcSizeValueSet( *this, aFrameSet,Size( 20, 20 ));
+ }
+ }
+ }
+ }
+ SfxPopupWindow::StateChanged( nSID, eState, pState );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFrameWindow_Impl::StartSelection()
+{
+ aFrameSet.StartSelection();
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SvxFrameWindow_Impl::Close()
+{
+ return SfxPopupWindow::Close();
+}
+
+//========================================================================
+// class SvxLineWindow_Impl --------------------------------------------------
+//========================================================================
+
+SvxLineWindow_Impl::SvxLineWindow_Impl( USHORT nId, const Reference< XFrame >& rFrame, Window* pParentWindow ) :
+
+ SfxPopupWindow( nId, rFrame, pParentWindow, WinBits( WB_STDPOPUP ) ),
+
+ aLineSet( this, WinBits( WB_3DLOOK | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_NAMEFIELD | WB_NONEFIELD | WB_NO_DIRECTSELECT ) )
+{
+ try
+ {
+ Reference< lang::XServiceInfo > xServices( rFrame->getController()->getModel(), UNO_QUERY_THROW );
+ m_bIsWriter = xServices->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument")));
+ }
+ catch(const uno::Exception& )
+ {
+ }
+ Size aBmpSize( 55, 12 );
+ CreateBitmaps();
+
+ aLineSet.SetColCount( 2 );
+ aLineSet.SetSelectHdl( LINK( this, SvxLineWindow_Impl, SelectHdl ) );
+ aLineSet.SetText( SVX_RESSTR(STR_NONE) );
+
+ lcl_CalcSizeValueSet( *this, aLineSet, aBmpSize );
+
+ SetHelpId( HID_POPUP_LINE );
+ SetText( SVX_RESSTR(RID_SVXSTR_FRAME_STYLE) );
+ aLineSet.Show();
+}
+
+SfxPopupWindow* SvxLineWindow_Impl::Clone() const
+{
+ return new SvxLineWindow_Impl( GetId(), GetFrame(), GetParent() );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineWindow_Impl::MakeLineBitmap( USHORT nNo, Bitmap& rBmp, const Size& rSize, String& rStr,
+ const ::Color& rLineCol, const ::Color& rBackCol )
+{
+ VirtualDevice aVirDev( *this );
+ Rectangle aRect( Point(2,0), Size(rSize.Width()-4,0) );
+
+ // grau einfaerben und Bitmap sichern:
+ aVirDev.SetOutputSizePixel( rSize );
+ aVirDev.SetLineColor();
+ aVirDev.SetFillColor( rBackCol );
+ aVirDev.DrawRect( Rectangle( Point(0,0), rSize ) );
+ aVirDev.SetFillColor( rLineCol );
+
+ sal_uInt16 nLineWidth = 0;
+ switch ( nNo )
+ {
+ case 1: // DEF_LINE_WIDTH_0
+ aRect.Top() = 6;
+ aRect.Bottom() = 6;
+ aVirDev.DrawRect( aRect );
+ break;
+
+ case 2: // DEF_LINE_WIDTH_1
+ aRect.Top() = 5;
+ aRect.Bottom() = 6;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) DEF_LINE_WIDTH_1/20;
+ break;
+
+ case 3: // DEF_LINE_WIDTH_2
+ aRect.Top() = 5;
+ aRect.Bottom() = 7;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) DEF_LINE_WIDTH_2/20;
+ break;
+
+ case 4: // DEF_LINE_WIDTH_3
+ aRect.Top() = 4;
+ aRect.Bottom() = 7;
+ aVirDev.DrawRect( aRect );
+ aVirDev.DrawRect( Rectangle( Point(2,4), Point(37,7) ) );
+ nLineWidth = (USHORT) DEF_LINE_WIDTH_3/20;
+ break;
+
+ case 5: // DEF_LINE_WIDTH_4
+ aRect.Top() = 4;
+ aRect.Bottom() = 8;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) DEF_LINE_WIDTH_4/20;
+ break;
+
+ case 6: // DEF_DOUBLE_LINE0
+ aRect.Top() = 5;
+ aRect.Bottom() = 5;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 7;
+ aRect.Bottom() = 7;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE0_OUT+DEF_DOUBLE_LINE0_IN+DEF_DOUBLE_LINE0_DIST)/20;
+ break;
+
+ case 7: // DEF_DOUBLE_LINE7
+ aRect.Top() = 4;
+ aRect.Bottom() = 4;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 7;
+ aRect.Bottom() = 7;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE7_OUT+DEF_DOUBLE_LINE7_IN+DEF_DOUBLE_LINE7_DIST)/20;
+ break;
+
+ case 8: // DEF_DOUBLE_LINE1
+ aRect.Top() = 4;
+ aRect.Bottom() = 5;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 7;
+ aRect.Bottom() = 8;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE1_OUT+DEF_DOUBLE_LINE1_IN+DEF_DOUBLE_LINE1_DIST)/20;
+ break;
+
+ case 9: // DEF_DOUBLE_LINE2
+ aRect.Top() = 3;
+ aRect.Bottom() = 5;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 8;
+ aRect.Bottom() = 10;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE2_OUT+DEF_DOUBLE_LINE2_IN+DEF_DOUBLE_LINE2_DIST)/20;
+ break;
+
+ case 10: // DEF_DOUBLE_LINE8
+ aRect.Top() = 3;
+ aRect.Bottom() = 4;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 7;
+ aRect.Bottom() = 7;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE8_OUT+DEF_DOUBLE_LINE8_IN+DEF_DOUBLE_LINE8_DIST)/20;
+ break;
+
+ case 11: // DEF_DOUBLE_LINE9
+ aRect.Top() = 3;
+ aRect.Bottom() = 5;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 8;
+ aRect.Bottom() = 8;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE9_OUT+DEF_DOUBLE_LINE9_IN+DEF_DOUBLE_LINE9_DIST)/20;
+ break;
+
+ case 12: // DEF_DOUBLE_LINE10
+ aRect.Top() = 2;
+ aRect.Bottom() = 5;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 8;
+ aRect.Bottom() = 8;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE10_OUT+DEF_DOUBLE_LINE10_IN+DEF_DOUBLE_LINE10_DIST)/20;
+ break;
+
+ case 13: // DEF_DOUBLE_LINE3
+ aRect.Top() = 4;
+ aRect.Bottom() = 5;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 7;
+ aRect.Bottom() = 7;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE3_OUT+DEF_DOUBLE_LINE3_IN+DEF_DOUBLE_LINE3_DIST)/20;
+ break;
+
+ case 14: // DEF_DOUBLE_LINE4
+ aRect.Top() = 4;
+ aRect.Bottom() = 4;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 6;
+ aRect.Bottom() = 7;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE4_OUT+DEF_DOUBLE_LINE4_IN+DEF_DOUBLE_LINE4_DIST)/20;
+ break;
+
+ case 15: // DEF_DOUBLE_LINE5
+ aRect.Top() = 3;
+ aRect.Bottom() = 5;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 8;
+ aRect.Bottom() = 9;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE5_OUT+DEF_DOUBLE_LINE5_IN+DEF_DOUBLE_LINE5_DIST)/20;
+ break;
+
+ case 16: // DEF_DOUBLE_LINE6
+ aRect.Top() = 3;
+ aRect.Bottom() = 4;
+ aVirDev.DrawRect( aRect );
+ aRect.Top() = 7;
+ aRect.Bottom() = 9;
+ aVirDev.DrawRect( aRect );
+ nLineWidth = (USHORT) (DEF_DOUBLE_LINE6_OUT+DEF_DOUBLE_LINE6_IN+DEF_DOUBLE_LINE6_DIST)/20;
+ break;
+ case 17: // Dotted line
+ aRect.Top() = 6;
+ aRect.Bottom() = 6;
+ aVirDev.SetLineColor( rLineCol );
+ aVirDev.SetFillColor();
+ svtools::DrawLine( aVirDev, aRect.LeftCenter(), aRect.RightCenter(), 1, DOTTED );
+ break;
+
+ case 18: // Dashed line
+ aRect.Top() = 6;
+ aRect.Bottom() = 6;
+ aVirDev.SetLineColor( rLineCol );
+ aVirDev.SetFillColor();
+ svtools::DrawLine( aVirDev, aRect.LeftCenter(), aRect.RightCenter(), 1, DASHED );
+ break;
+
+ default:
+ break;
+ }
+ if ( nLineWidth )
+ {
+ rStr = String::CreateFromInt32( nLineWidth );
+ rStr.AppendAscii(" pt");
+ }
+ rBmp = aVirDev.GetBitmap( Point(0,0), rSize );
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxLineWindow_Impl, SelectHdl, void *, EMPTYARG )
+{
+ SvxLineItem aLineItem( SID_FRAME_LINESTYLE );
+ USHORT n1 = 0,
+ n2 = 0,
+ n3 = 0;
+ SvxBorderStyle nStyle = SOLID;
+ BOOL bSetLine = TRUE;
+
+ switch ( aLineSet.GetSelectItemId() )
+ {
+ case 1: n1 = DEF_LINE_WIDTH_0; break;
+ case 2: n1 = DEF_LINE_WIDTH_1; break;
+ case 3: n1 = DEF_LINE_WIDTH_2; break;
+ case 4: n1 = DEF_LINE_WIDTH_3; break;
+ case 5: n1 = DEF_LINE_WIDTH_4; break;
+
+ case 6: n1 = DEF_DOUBLE_LINE0_OUT;
+ n2 = DEF_DOUBLE_LINE0_IN;
+ n3 = DEF_DOUBLE_LINE0_DIST; break;
+ case 7: n1 = DEF_DOUBLE_LINE7_OUT;
+ n2 = DEF_DOUBLE_LINE7_IN;
+ n3 = DEF_DOUBLE_LINE7_DIST; break;
+ case 8: n1 = DEF_DOUBLE_LINE1_OUT;
+ n2 = DEF_DOUBLE_LINE1_IN;
+ n3 = DEF_DOUBLE_LINE1_DIST; break;
+ case 9: n1 = DEF_DOUBLE_LINE2_OUT;
+ n2 = DEF_DOUBLE_LINE2_IN;
+ n3 = DEF_DOUBLE_LINE2_DIST; break;
+ case 10: n1 = DEF_DOUBLE_LINE8_OUT;
+ n2 = DEF_DOUBLE_LINE8_IN;
+ n3 = DEF_DOUBLE_LINE8_DIST; break;
+ case 11: n1 = DEF_DOUBLE_LINE9_OUT;
+ n2 = DEF_DOUBLE_LINE9_IN;
+ n3 = DEF_DOUBLE_LINE9_DIST; break;
+ case 12: n1 = DEF_DOUBLE_LINE10_OUT;
+ n2 = DEF_DOUBLE_LINE10_IN;
+ n3 = DEF_DOUBLE_LINE10_DIST; break;
+ case 13: n1 = DEF_DOUBLE_LINE3_OUT;
+ n2 = DEF_DOUBLE_LINE3_IN;
+ n3 = DEF_DOUBLE_LINE3_DIST; break;
+ case 14: n1 = DEF_DOUBLE_LINE4_OUT;
+ n2 = DEF_DOUBLE_LINE4_IN;
+ n3 = DEF_DOUBLE_LINE4_DIST; break;
+ case 15: n1 = DEF_DOUBLE_LINE5_OUT;
+ n2 = DEF_DOUBLE_LINE5_IN;
+ n3 = DEF_DOUBLE_LINE5_DIST; break;
+ case 16: n1 = DEF_DOUBLE_LINE6_OUT;
+ n2 = DEF_DOUBLE_LINE6_IN;
+ n3 = DEF_DOUBLE_LINE6_DIST; break;
+ case 17:
+ n1 = DEF_LINE_WIDTH_5;
+ nStyle = DOTTED;
+ break;
+ case 18:
+ n1 = DEF_LINE_WIDTH_5;
+ nStyle = DASHED;
+ break;
+ case 0:
+ default:
+ bSetLine = FALSE;
+ break;
+ }
+ if ( bSetLine )
+ {
+ SvxBorderLine aTmp( NULL, n1, n2, n3, nStyle );
+ aLineItem.SetLine( &aTmp );
+ }
+ else
+ aLineItem.SetLine( 0 );
+
+ if ( IsInPopupMode() )
+ EndPopupMode();
+
+ Any a;
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "LineStyle" ));
+ aLineItem.QueryValue( a, m_bIsWriter ? CONVERT_TWIPS : 0 );
+ aArgs[0].Value = a;
+
+ /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
+ This instance may be deleted in the meantime (i.e. when a dialog is opened
+ while in Dispatch()), accessing members will crash in this case. */
+ aLineSet.SetNoSelection();
+
+ SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LineStyle" )),
+ aArgs );
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineWindow_Impl::Resize()
+{
+ lcl_ResizeValueSet( *this, aLineSet);
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineWindow_Impl::StartSelection()
+{
+ aLineSet.StartSelection();
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SvxLineWindow_Impl::Close()
+{
+ return SfxPopupWindow::Close();
+}
+
+// -----------------------------------------------------------------------
+
+Window* SvxLineWindow_Impl::GetPreferredKeyInputWindow()
+{
+ return &aLineSet;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxLineWindow_Impl::GetFocus()
+{
+ aLineSet.GrabFocus();
+}
+
+void SvxLineWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ SfxPopupWindow::DataChanged( rDCEvt );
+
+ if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
+ {
+ CreateBitmaps();
+ Invalidate();
+ }
+}
+
+void SvxLineWindow_Impl::CreateBitmaps( void )
+{
+ Size aBmpSize( 55, 12 );
+ Bitmap aBmp;
+ String aStr;
+
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ svtools::ColorConfig aColorConfig;
+ ::Color aLineCol( aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor );
+ ::Color aBackCol( rStyleSettings.GetWindowColor() );
+ aLineSet.Clear();
+
+ for( USHORT i = 1 ; i < 19 ; ++i )
+ {
+ MakeLineBitmap( i, aBmp, aBmpSize, aStr, aLineCol, aBackCol );
+ aLineSet.InsertItem( i, aBmp, aStr );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+//########################################################################
+// Hilfsklassen
+
+//========================================================================
+// class SfxStyleControllerItem_Impl ------------------------------------------
+//========================================================================
+
+SfxStyleControllerItem_Impl::SfxStyleControllerItem_Impl(
+ const Reference< XDispatchProvider >& rDispatchProvider,
+ USHORT nSlotId, // Family-ID
+ const rtl::OUString& rCommand, // .uno: command bound to this item
+ SvxStyleToolBoxControl& rTbxCtl ) // Controller-Instanz, dem dieses Item zugeordnet ist.
+ : SfxStatusListener( rDispatchProvider, nSlotId, rCommand ),
+ rControl( rTbxCtl )
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SfxStyleControllerItem_Impl::StateChanged(
+ USHORT, SfxItemState eState, const SfxPoolItem* pState )
+{
+ switch ( GetId() )
+ {
+ case SID_STYLE_FAMILY1:
+ case SID_STYLE_FAMILY2:
+ case SID_STYLE_FAMILY3:
+ case SID_STYLE_FAMILY4:
+ case SID_STYLE_FAMILY5:
+ {
+ const USHORT nIdx = GetId() - SID_STYLE_FAMILY_START;
+
+ if ( SFX_ITEM_AVAILABLE == eState )
+ {
+ const SfxTemplateItem* pStateItem =
+ PTR_CAST( SfxTemplateItem, pState );
+ DBG_ASSERT( pStateItem != NULL, "SfxTemplateItem expected" );
+ rControl.SetFamilyState( nIdx, pStateItem );
+ }
+ else
+ rControl.SetFamilyState( nIdx, NULL );
+ break;
+ }
+ }
+}
+
+//########################################################################
+
+//========================================================================
+// class SvxStyleToolBoxControl ------------------------------------------
+//========================================================================
+
+struct SvxStyleToolBoxControl::Impl
+{
+ String aClearForm;
+ String aMore;
+ ::std::vector< ::rtl::OUString > aDefaultStyles;
+ BOOL bListening;
+ BOOL bSpecModeWriter;
+ BOOL bSpecModeCalc;
+
+ inline Impl( void )
+ :aClearForm ( SVX_RESSTR( RID_SVXSTR_CLEARFORM ) )
+ ,aMore ( SVX_RESSTR( RID_SVXSTR_MORE ) )
+ ,bListening ( FALSE )
+ ,bSpecModeWriter ( FALSE )
+ ,bSpecModeCalc ( FALSE )
+ {
+
+
+ }
+ void InitializeStyles(Reference < frame::XModel > xModel)
+ {
+ //now convert the default style names to the localized names
+ try
+ {
+ Reference< style::XStyleFamiliesSupplier > xStylesSupplier( xModel, UNO_QUERY_THROW );
+ Reference< lang::XServiceInfo > xServices( xModel, UNO_QUERY_THROW );
+ bSpecModeWriter = xServices->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextDocument")));
+ if(bSpecModeWriter)
+ {
+ Reference<container::XNameAccess> xParaStyles;
+ xStylesSupplier->getStyleFamilies()->getByName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles"))) >>=
+ xParaStyles;
+ static const sal_Char* aWriterStyles[] =
+ {
+ "Standard",
+ "Heading 1",
+ "Heading 2",
+ "Heading 3",
+ "Text body"
+ };
+ for( sal_uInt32 nStyle = 0; nStyle < sizeof( aWriterStyles ) / sizeof( sal_Char*); ++nStyle )
+ {
+ try
+ {
+ Reference< beans::XPropertySet > xStyle;
+ xParaStyles->getByName( rtl::OUString::createFromAscii( aWriterStyles[nStyle] )) >>= xStyle;
+ ::rtl::OUString sName;
+ xStyle->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName"))) >>= sName;
+ if( sName.getLength() )
+ aDefaultStyles.push_back(sName);
+ }
+ catch( const uno::Exception& )
+ {}
+ }
+
+ }
+ else if( 0 != (
+ bSpecModeCalc = xServices->supportsService(::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument")))))
+ {
+ static const sal_Char* aCalcStyles[] =
+ {
+ "Default",
+ "Heading 1",
+ "Heading 2",
+ "Result",
+ "Result2"
+ };
+ Reference<container::XNameAccess> xCellStyles;
+ xStylesSupplier->getStyleFamilies()->getByName(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellStyles"))) >>=
+ xCellStyles;
+ for( sal_uInt32 nStyle = 0; nStyle < sizeof( aCalcStyles ) / sizeof( sal_Char*); ++nStyle )
+ {
+ try
+ {
+ Reference< beans::XPropertySet > xStyle;
+ xCellStyles->getByName( rtl::OUString::createFromAscii( aCalcStyles[nStyle] )) >>= xStyle;
+ ::rtl::OUString sName;
+ xStyle->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName")))>>= sName;
+ if( sName.getLength() )
+ aDefaultStyles.push_back(sName);
+ }
+ catch( const uno::Exception& )
+ {}
+ }
+ }
+ }
+ catch(const uno::Exception& )
+ {
+ DBG_ERROR("error while initializing style names");
+ }
+ }
+};
+
+
+// mapping table from bound items. BE CAREFUL this table must be in the
+// same order as the uno commands bound to the slots SID_STYLE_FAMILY1..n
+// MAX_FAMILIES must also be correctly set!
+static const char* StyleSlotToStyleCommand[MAX_FAMILIES] =
+{
+ ".uno:CharStyle",
+ ".uno:ParaStyle",
+ ".uno:FrameStyle",
+ ".uno:PageStyle",
+ ".uno:TemplateFamily5"
+};
+
+SvxStyleToolBoxControl::SvxStyleToolBoxControl(
+ USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ : SfxToolBoxControl ( nSlotId, nId, rTbx ),
+ pStyleSheetPool ( NULL ),
+ nActFamily ( 0xffff ),
+ bListening ( FALSE ),
+ pImpl ( new Impl )
+{
+ for ( USHORT i=0; i<MAX_FAMILIES; i++ )
+ {
+ pBoundItems[i] = 0;
+ m_xBoundItems[i] = Reference< XComponent >();
+ pFamilyState[i] = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------
+SvxStyleToolBoxControl::~SvxStyleToolBoxControl()
+{
+}
+
+// -----------------------------------------------------------------------
+void SAL_CALL SvxStyleToolBoxControl::initialize( const Sequence< Any >& aArguments )
+throw ( Exception, RuntimeException)
+{
+ SfxToolBoxControl::initialize( aArguments );
+
+ // After initialize we should have a valid frame member where we can retrieve our
+ // dispatch provider.
+ if ( m_xFrame.is() )
+ {
+ pImpl->InitializeStyles(m_xFrame->getController()->getModel());
+ Reference< XDispatchProvider > xDispatchProvider( m_xFrame->getController(), UNO_QUERY );
+ for ( USHORT i=0; i<MAX_FAMILIES; i++ )
+ {
+ pBoundItems[i] = new SfxStyleControllerItem_Impl( xDispatchProvider,
+ SID_STYLE_FAMILY_START + i,
+ OUString::createFromAscii( StyleSlotToStyleCommand[i] ),
+ *this );
+ m_xBoundItems[i] = Reference< XComponent >( static_cast< OWeakObject* >( pBoundItems[i] ), UNO_QUERY );
+ pFamilyState[i] = NULL;
+ }
+ }
+}
+
+// XComponent
+void SAL_CALL SvxStyleToolBoxControl::dispose()
+throw (::com::sun::star::uno::RuntimeException)
+{
+ SfxToolBoxControl::dispose();
+
+ for( USHORT i=0; i<MAX_FAMILIES; i++ )
+ {
+ if ( m_xBoundItems[i].is() )
+ {
+ try
+ {
+ m_xBoundItems[i]->dispose();
+ }
+ catch ( Exception& )
+ {
+ }
+
+ m_xBoundItems[i].clear();
+ pBoundItems[i] = 0;
+ }
+ DELETEZ( pFamilyState[i] );
+ }
+ pStyleSheetPool = NULL;
+ DELETEZ( pImpl );
+}
+
+// -----------------------------------------------------------------------
+void SAL_CALL SvxStyleToolBoxControl::update() throw (RuntimeException)
+{
+ // Do nothing, we will start binding our listener when we are visible.
+ // See link SvxStyleToolBoxControl::VisibilityNotification.
+ SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
+ if ( pBox->IsVisible() )
+ {
+ for ( int i=0; i<MAX_FAMILIES; i++ )
+ pBoundItems [i]->ReBind();
+
+ bindListener();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SfxStyleFamily SvxStyleToolBoxControl::GetActFamily()
+{
+ switch ( nActFamily-1 + SID_STYLE_FAMILY_START )
+ {
+ case SID_STYLE_FAMILY1: return SFX_STYLE_FAMILY_CHAR;
+ case SID_STYLE_FAMILY2: return SFX_STYLE_FAMILY_PARA;
+ case SID_STYLE_FAMILY3: return SFX_STYLE_FAMILY_FRAME;
+ case SID_STYLE_FAMILY4: return SFX_STYLE_FAMILY_PAGE;
+ case SID_STYLE_FAMILY5: return SFX_STYLE_FAMILY_PSEUDO;
+ default:
+ DBG_ERROR( "unknown style family" );
+ break;
+ }
+ return SFX_STYLE_FAMILY_PARA;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxStyleToolBoxControl::FillStyleBox()
+{
+ SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
+
+ DBG_ASSERT( pStyleSheetPool, "StyleSheetPool not found!" );
+ DBG_ASSERT( pBox, "Control not found!" );
+
+ if ( pStyleSheetPool && pBox && nActFamily!=0xffff )
+ {
+ const SfxStyleFamily eFamily = GetActFamily();
+ USHORT nCount = pStyleSheetPool->Count();
+ USHORT i = 0;
+ SfxStyleSheetBase* pStyle = NULL;
+ BOOL bDoFill = FALSE;
+
+ pStyleSheetPool->SetSearchMask( eFamily, SFXSTYLEBIT_USED );
+
+ //------------------------------
+ // Ueberpruefen, ob Fill noetig:
+ //------------------------------
+
+ pStyle = pStyleSheetPool->First();
+ //!!! TODO: This condition isn't right any longer, because we always show some default entries
+ //!!! so the list doesn't show the count
+ if ( nCount != pBox->GetEntryCount() )
+ {
+ bDoFill = TRUE;
+ }
+ else
+ {
+ while ( pStyle && !bDoFill )
+ {
+ bDoFill = ( pBox->GetEntry(i) != pStyle->GetName() );
+ pStyle = pStyleSheetPool->Next();
+ i++;
+ }
+ }
+
+ if ( bDoFill )
+ {
+ pBox->SetUpdateMode( FALSE );
+ pBox->Clear();
+
+ {
+ USHORT _i;
+ sal_uInt32 nCnt = pImpl->aDefaultStyles.size();
+ bool bInsert;
+
+ pStyle = pStyleSheetPool->First();
+
+ if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc )
+ {
+ while ( pStyle )
+ {
+ // sort out default styles
+ bInsert = true;
+ ::rtl::OUString aName( pStyle->GetName() );
+ for( _i = 0 ; _i < nCnt ; ++_i )
+ {
+ if( pImpl->aDefaultStyles[_i] == aName )
+ {
+ bInsert = false;
+ break;
+ }
+ }
+
+ if( bInsert )
+ pBox->InsertEntry( aName );
+ pStyle = pStyleSheetPool->Next();
+ }
+ }
+ else
+ {
+ while ( pStyle )
+ {
+ pBox->InsertEntry( pStyle->GetName() );
+ pStyle = pStyleSheetPool->Next();
+ }
+ }
+ }
+
+ if( pImpl->bSpecModeWriter || pImpl->bSpecModeCalc )
+ {
+ // insert default styles
+ USHORT _i;
+ sal_uInt32 nCnt = pImpl->aDefaultStyles.size();
+ USHORT nPos = 1;
+ for( _i = 0 ; _i < nCnt ; ++_i )
+ {
+ pBox->InsertEntry( pImpl->aDefaultStyles[_i], nPos );
+ ++nPos;
+ }
+
+ // disable sort to preserve special order
+ WinBits nWinBits = pBox->GetStyle();
+ nWinBits &= ~WB_SORT;
+ pBox->SetStyle( nWinBits );
+
+ pBox->InsertEntry( pImpl->aClearForm, 0 );
+ pBox->SetSeparatorPos( 0 );
+
+ pBox->InsertEntry( pImpl->aMore );
+
+ // enable sort again
+ nWinBits |= WB_SORT;
+ pBox->SetStyle( nWinBits );
+ }
+
+ pBox->SetUpdateMode( TRUE );
+ pBox->SetFamily( eFamily );
+
+ USHORT nLines = Min( pBox->GetEntryCount(), MAX_STYLES_ENTRIES );
+ pBox->SetDropDownLineCount( nLines );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxStyleToolBoxControl::SelectStyle( const String& rStyleName )
+{
+ SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)GetToolBox().GetItemWindow( GetId() );
+ DBG_ASSERT( pBox, "Control not found!" );
+
+ if ( pBox )
+ {
+// String aStrSel( pBox->GetSelectEntry() );
+ String aStrSel( pBox->GetText() );
+
+ if ( rStyleName.Len() > 0 )
+ {
+ if ( rStyleName != aStrSel )
+// pBox->SelectEntry( rStyleName );
+ pBox->SetText( rStyleName );
+ }
+ else
+ pBox->SetNoSelection();
+ pBox->SaveValue();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxStyleToolBoxControl::Update()
+{
+ SfxStyleSheetBasePool* pPool = NULL;
+ SfxObjectShell* pDocShell = SfxObjectShell::Current();
+
+ if ( pDocShell )
+ pPool = pDocShell->GetStyleSheetPool();
+
+ USHORT i;
+ for ( i=0; i<MAX_FAMILIES; i++ )
+ if( pFamilyState[i] )
+ break;
+
+ if ( i==MAX_FAMILIES || !pPool )
+ {
+ pStyleSheetPool = pPool;
+ return;
+ }
+
+ //--------------------------------------------------------------------
+ const SfxTemplateItem* pItem = NULL;
+
+ if ( nActFamily == 0xffff || 0 == (pItem = pFamilyState[nActFamily-1]) )
+ // aktueller Bereich nicht innerhalb der erlaubten Bereiche
+ // oder Default
+ {
+ pStyleSheetPool = pPool;
+ nActFamily = 2;
+
+ pItem = pFamilyState[nActFamily-1];
+ if ( !pItem )
+ {
+ nActFamily++;
+ pItem = pFamilyState[nActFamily-1];
+ }
+
+ if ( !pItem )
+ {
+ DBG_WARNING( "Unknown Family" ); // can happen
+ }
+ }
+ else if ( pPool != pStyleSheetPool )
+ pStyleSheetPool = pPool;
+
+ FillStyleBox(); // entscheidet selbst, ob gefuellt werden muss
+
+ if ( pItem )
+ SelectStyle( pItem->GetStyleName() );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxStyleToolBoxControl::SetFamilyState( USHORT nIdx,
+ const SfxTemplateItem* pItem )
+{
+ DELETEZ( pFamilyState[nIdx] );
+
+ if ( pItem )
+ pFamilyState[nIdx] = new SfxTemplateItem( *pItem );
+
+ Update();
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( SvxStyleToolBoxControl, VisibilityNotification, void*, EMPTYARG )
+{
+
+ USHORT i;
+
+ // Call ReBind() && UnBind() according to visibility
+ SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)( GetToolBox().GetItemWindow( GetId() ));
+ if ( pBox->IsVisible() && !isBound() )
+ {
+ for ( i=0; i<MAX_FAMILIES; i++ )
+ pBoundItems [i]->ReBind();
+
+ bindListener();
+ }
+ else if ( !pBox->IsVisible() && isBound() )
+ {
+ for ( i=0; i<MAX_FAMILIES; i++ )
+ pBoundItems[i]->UnBind();
+ unbindListener();
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxStyleToolBoxControl::StateChanged(
+
+ USHORT , SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+ SvxStyleBox_Impl* pBox = (SvxStyleBox_Impl*)(rTbx.GetItemWindow( nId ));
+ TriState eTri = STATE_NOCHECK;
+
+ DBG_ASSERT( pBox, "Control not found!" );
+
+ if ( SFX_ITEM_DISABLED == eState )
+ pBox->Disable();
+ else
+ pBox->Enable();
+
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+
+ switch ( eState )
+ {
+ case SFX_ITEM_AVAILABLE:
+ eTri = ((const SfxBoolItem*)pState)->GetValue()
+ ? STATE_CHECK
+ : STATE_NOCHECK;
+ break;
+
+ case SFX_ITEM_DONTCARE:
+ eTri = STATE_DONTKNOW;
+ break;
+ }
+
+ rTbx.SetItemState( nId, eTri );
+
+ if ( SFX_ITEM_DISABLED != eState )
+ Update();
+}
+
+// -----------------------------------------------------------------------
+
+Window* SvxStyleToolBoxControl::CreateItemWindow( Window *pParent )
+{
+ SvxStyleBox_Impl* pBox = new SvxStyleBox_Impl( pParent,
+ SID_STYLE_APPLY,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StyleApply" )),
+ SFX_STYLE_FAMILY_PARA,
+ Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
+ m_xFrame,
+ pImpl->aClearForm,
+ pImpl->aMore,
+ pImpl->bSpecModeWriter || pImpl->bSpecModeCalc );
+ if( pImpl->aDefaultStyles.size())
+ pBox->SetDefaultStyle( pImpl->aDefaultStyles[0] );
+ // Set visibility listener to bind/unbind controller
+ pBox->SetVisibilityListener( LINK( this, SvxStyleToolBoxControl, VisibilityNotification ));
+
+ return pBox;
+}
+
+//========================================================================
+// class SvxFontNameToolBoxControl ---------------------------------------
+//========================================================================
+
+SvxFontNameToolBoxControl::SvxFontNameToolBoxControl(
+ USHORT nSlotId,
+ USHORT nId,
+ ToolBox& rTbx )
+
+ : SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontNameToolBoxControl::StateChanged(
+
+ USHORT , SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+ SvxFontNameBox_Impl* pBox = (SvxFontNameBox_Impl*)(rTbx.GetItemWindow( nId ));
+
+ DBG_ASSERT( pBox, "Control not found!" );
+
+ if ( SFX_ITEM_DISABLED == eState )
+ {
+ pBox->Disable();
+ pBox->Update( (const SvxFontItem*)NULL );
+ }
+ else
+ {
+ pBox->Enable();
+
+ if ( SFX_ITEM_AVAILABLE == eState )
+ {
+ const SvxFontItem* pFontItem = dynamic_cast< const SvxFontItem* >( pState );
+
+ DBG_ASSERT( pFontItem, "svx::SvxFontNameToolBoxControl::StateChanged(), wrong item type!" );
+ if( pFontItem )
+ pBox->Update( pFontItem );
+ }
+ else
+ pBox->SetText( String() );
+ pBox->SaveValue();
+ }
+
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+}
+
+// -----------------------------------------------------------------------
+
+Window* SvxFontNameToolBoxControl::CreateItemWindow( Window *pParent )
+{
+ SvxFontNameBox_Impl* pBox = new SvxFontNameBox_Impl( pParent,
+ Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY ),
+ m_xFrame,0);
+ return pBox;
+}
+
+//========================================================================
+// class SvxFontColorToolBoxControl --------------------------------------
+//========================================================================
+
+SvxFontColorToolBoxControl::SvxFontColorToolBoxControl(
+ USHORT nSlotId,
+ USHORT nId,
+ ToolBox& rTbx )
+
+ : SfxToolBoxControl( nSlotId, nId, rTbx ),
+ pBtnUpdater( new ::svx::ToolboxButtonColorUpdater(
+ nSlotId, nId, &GetToolBox(), TBX_UPDATER_MODE_CHAR_COLOR_NEW ))
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+}
+
+// -----------------------------------------------------------------------
+
+SvxFontColorToolBoxControl::~SvxFontColorToolBoxControl()
+{
+ delete pBtnUpdater;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType SvxFontColorToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxFontColorToolBoxControl::CreatePopupWindow()
+{
+ SvxColorWindow_Impl* pColorWin =
+ new SvxColorWindow_Impl(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Color" )),
+ SID_ATTR_CHAR_COLOR,
+ m_xFrame,
+ SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
+ &GetToolBox() );
+
+ pColorWin->StartPopupMode( &GetToolBox(),
+ FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
+ pColorWin->StartSelection();
+ SetPopupWindow( pColorWin );
+ return pColorWin;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontColorToolBoxControl::StateChanged(
+
+ USHORT , SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+ const SvxColorItem* pItem = 0;
+
+ if ( SFX_ITEM_DONTCARE != eState )
+ pItem = PTR_CAST( SvxColorItem, pState );
+
+ if ( pItem )
+ pBtnUpdater->Update( pItem->GetValue());
+
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+ rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
+}
+
+//========================================================================
+// class SvxColorToolBoxControl --------------------------------
+//========================================================================
+
+SvxColorToolBoxControl::SvxColorToolBoxControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ if ( nSlotId == SID_BACKGROUND_COLOR )
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+ else
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+ pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() );
+}
+
+// -----------------------------------------------------------------------
+
+SvxColorToolBoxControl::~SvxColorToolBoxControl()
+{
+ delete pBtnUpdater;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType SvxColorToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxColorToolBoxControl::CreatePopupWindow()
+{
+ USHORT nResId = GetSlotId() == SID_BACKGROUND_COLOR ?
+ RID_SVXSTR_BACKGROUND : RID_SVXSTR_COLOR;
+ SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:BackgroundColor" )),
+ SID_BACKGROUND_COLOR,
+ m_xFrame,
+ SVX_RESSTR(nResId),
+ &GetToolBox() );
+
+ pColorWin->StartPopupMode( &GetToolBox(),
+ FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
+ pColorWin->StartSelection();
+ SetPopupWindow( pColorWin );
+ return pColorWin;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxColorToolBoxControl::StateChanged(
+
+ USHORT , SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ const SvxColorItem* pItem = 0;
+ if ( SFX_ITEM_DONTCARE != eState )
+ pItem = PTR_CAST( SvxColorItem, pState );
+
+ if ( pItem )
+ pBtnUpdater->Update( pItem->GetValue() );
+
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+ rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
+}
+
+//========================================================================
+// class SvxFontColorExtToolBoxControl --------------------------------------
+//========================================================================
+
+SvxFontColorExtToolBoxControl::SvxFontColorExtToolBoxControl(
+ USHORT nSlotId,
+ USHORT nId,
+ ToolBox& rTbx ) :
+
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ pBtnUpdater(0)
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+ // The following commands are available at the writer module.
+ if ( SID_ATTR_CHAR_COLOR2 == nSlotId )
+ addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" )));
+ else
+ addStatusListener( OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" )));
+
+ USHORT nMode = SID_ATTR_CHAR_COLOR2 == nSlotId
+ ? TBX_UPDATER_MODE_CHAR_COLOR_NEW : TBX_UPDATER_MODE_CHAR_COLOR_NEW;
+ pBtnUpdater = new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox(), nMode );
+}
+
+// -----------------------------------------------------------------------
+
+SvxFontColorExtToolBoxControl::~SvxFontColorExtToolBoxControl()
+{
+ delete pBtnUpdater;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType SvxFontColorExtToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONTIMEOUT;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxFontColorExtToolBoxControl::CreatePopupWindow()
+{
+ SvxColorWindow_Impl* pColorWin =
+ new SvxColorWindow_Impl(
+ m_aCommandURL,
+ GetSlotId(),
+ m_xFrame,
+ SVX_RESSTR( RID_SVXITEMS_EXTRAS_CHARCOLOR ),
+ &GetToolBox() );
+
+ if ( GetSlotId() == SID_ATTR_CHAR_COLOR_BACKGROUND )
+ pColorWin->SetText( SVX_RESSTR( RID_SVXSTR_EXTRAS_CHARBACKGROUND ) );
+
+ pColorWin->StartPopupMode( &GetToolBox(),
+ FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
+ pColorWin->StartSelection();
+ SetPopupWindow( pColorWin );
+ return pColorWin;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontColorExtToolBoxControl::StateChanged(
+
+ USHORT nSID, SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+ const SvxColorItem* pItem = 0;
+
+ if ( nSID == SID_ATTR_CHAR_COLOR_EXT ||
+ nSID == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT )
+ {
+ if ( SFX_ITEM_DONTCARE != eState )
+ {
+ const SfxBoolItem* pBool = PTR_CAST( SfxBoolItem, pState );
+ rTbx.CheckItem( nId, pBool && pBool->GetValue());
+ }
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+ }
+ else
+ {
+ if ( SFX_ITEM_DONTCARE != eState )
+ pItem = PTR_CAST( SvxColorItem, pState );
+
+ if ( pItem )
+ pBtnUpdater->Update( pItem->GetValue() );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontColorExtToolBoxControl::Select( BOOL )
+{
+ OUString aCommand;
+ OUString aParamName;
+ if ( SID_ATTR_CHAR_COLOR2 == GetSlotId() )
+ {
+ aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharColorExt" ));
+ aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColorExt" ));
+ }
+ else
+ {
+ aCommand = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharBackgroundExt" ));
+ aParamName = OUString( RTL_CONSTASCII_USTRINGPARAM( "CharBackgroundExt" ));
+ }
+
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[0].Name = aParamName;
+ aArgs[0].Value = makeAny( GetToolBox().IsItemChecked( GetId() ));
+ Dispatch( aCommand, aArgs );
+}
+
+//========================================================================
+// class SvxFrameToolBoxControl ------------------------------------------
+//========================================================================
+
+SvxFrameToolBoxControl::SvxFrameToolBoxControl(
+ USHORT nSlotId,
+ USHORT nId,
+ ToolBox& rTbx )
+
+ : SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType SvxFrameToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxFrameToolBoxControl::CreatePopupWindow()
+{
+ SvxFrameWindow_Impl* pFrameWin = new SvxFrameWindow_Impl(
+ GetSlotId(), m_xFrame, &GetToolBox() );
+
+ pFrameWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS | FLOATWIN_POPUPMODE_ALLOWTEAROFF );
+ pFrameWin->StartSelection();
+ SetPopupWindow( pFrameWin );
+
+ return pFrameWin;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFrameToolBoxControl::StateChanged(
+
+ USHORT, SfxItemState eState, const SfxPoolItem* )
+
+{
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+ rTbx.SetItemState( nId, (SFX_ITEM_DONTCARE == eState)
+ ? STATE_DONTKNOW
+ : STATE_NOCHECK );
+}
+
+//========================================================================
+// class SvxFrameLineStyleToolBoxControl ---------------------------------
+//========================================================================
+
+SvxFrameLineStyleToolBoxControl::SvxFrameLineStyleToolBoxControl(
+ USHORT nSlotId,
+ USHORT nId,
+ ToolBox& rTbx )
+
+ : SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType SvxFrameLineStyleToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxFrameLineStyleToolBoxControl::CreatePopupWindow()
+{
+ SvxLineWindow_Impl* pLineWin = new SvxLineWindow_Impl( GetSlotId(), m_xFrame, &GetToolBox() );
+ pLineWin->StartPopupMode( &GetToolBox(), FLOATWIN_POPUPMODE_GRABFOCUS );
+ pLineWin->StartSelection();
+ SetPopupWindow( pLineWin );
+
+ return pLineWin;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFrameLineStyleToolBoxControl::StateChanged(
+
+ USHORT , SfxItemState eState, const SfxPoolItem* )
+{
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+ rTbx.SetItemState( nId, (SFX_ITEM_DONTCARE == eState)
+ ? STATE_DONTKNOW
+ : STATE_NOCHECK );
+}
+
+//========================================================================
+// class SvxFrameLineColorToolBoxControl ---------------------------------
+//========================================================================
+
+SvxFrameLineColorToolBoxControl::SvxFrameLineColorToolBoxControl(
+ USHORT nSlotId,
+ USHORT nId,
+ ToolBox& rTbx ) :
+
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ pBtnUpdater(new ::svx::ToolboxButtonColorUpdater( nSlotId, nId, &GetToolBox() ))
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWNONLY | rTbx.GetItemBits( nId ) );
+}
+
+// -----------------------------------------------------------------------
+
+SvxFrameLineColorToolBoxControl::~SvxFrameLineColorToolBoxControl()
+{
+
+ delete pBtnUpdater;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType SvxFrameLineColorToolBoxControl::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindow* SvxFrameLineColorToolBoxControl::CreatePopupWindow()
+{
+ SvxColorWindow_Impl* pColorWin = new SvxColorWindow_Impl(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FrameLineColor" )),
+ SID_FRAME_LINECOLOR,
+ m_xFrame,
+ SVX_RESSTR(RID_SVXSTR_FRAME_COLOR),
+ &GetToolBox() );
+
+ pColorWin->StartPopupMode( &GetToolBox(),
+ FLOATWIN_POPUPMODE_GRABFOCUS|FLOATWIN_POPUPMODE_ALLOWTEAROFF );
+ pColorWin->StartSelection();
+ SetPopupWindow( pColorWin );
+ return pColorWin;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFrameLineColorToolBoxControl::StateChanged(
+
+ USHORT , SfxItemState eState, const SfxPoolItem* pState )
+
+{
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+ rTbx.EnableItem( nId, SFX_ITEM_DISABLED != eState );
+ rTbx.SetItemState( nId, ( SFX_ITEM_DONTCARE == eState ) ? STATE_DONTKNOW : STATE_NOCHECK );
+
+ const SvxColorItem* pItem = 0;
+ if ( SFX_ITEM_DONTCARE != eState )
+ {
+ pItem = PTR_CAST( SvxColorItem, pState );
+ if ( pItem )
+ pBtnUpdater->Update( pItem->GetValue());
+ }
+}
+
+// class SvxReloadControllerItem_Impl ------------------------------------
+
+class SvxReloadControllerItem_Impl
+{
+public:
+ Image* pNormalImage;
+ Image* pSpecialImage;
+
+ SvxReloadControllerItem_Impl() :
+ pNormalImage( new Image( SVX_RES( RID_SVX_RELOAD_NORMAL ) ) ), pSpecialImage( 0 ) {}
+ ~SvxReloadControllerItem_Impl() { delete pNormalImage; delete pSpecialImage; }
+
+ Image& GetNormalImage() { return *pNormalImage; }
+ Image& GetSpecialImage()
+ {
+ if ( !pSpecialImage )
+ pSpecialImage = new Image( SVX_RES( RID_SVX_RELOAD_SPECIAL ) );
+ return *pSpecialImage;
+ }
+};
+
+// -----------------------------------------------------------------------
+
+SvxReloadControllerItem::SvxReloadControllerItem( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+: SfxToolBoxControl( nSlotId, nId, rTbx )
+, pImpl( new SvxReloadControllerItem_Impl )
+{
+ rTbx.SetItemImage( nId, pImpl->GetNormalImage() );
+}
+
+// -----------------------------------------------------------------------
+
+SvxReloadControllerItem::~SvxReloadControllerItem()
+{
+ delete pImpl;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxReloadControllerItem::StateChanged(
+ USHORT , SfxItemState eState, const SfxPoolItem* pState )
+{
+ SfxBoolItem* pItem = PTR_CAST( SfxBoolItem, pState );
+ ToolBox& rBox = GetToolBox();
+ if( pItem )
+ {
+ rBox.SetItemImage( GetId(),
+ pItem->GetValue() ? pImpl->GetSpecialImage() :
+ pImpl->GetNormalImage() );
+ }
+ rBox.EnableItem( GetId(), eState != SFX_ITEM_DISABLED );
+}
+
+//========================================================================
+// class SvxSimpleUndoRedoController -------------------------------------
+//========================================================================
+
+SvxSimpleUndoRedoController::SvxSimpleUndoRedoController( USHORT nSlotId, USHORT nId, ToolBox& rTbx )
+ :SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ aDefaultText = rTbx.GetItemText( nId );
+}
+
+// -----------------------------------------------------------------------
+
+SvxSimpleUndoRedoController::~SvxSimpleUndoRedoController()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void SvxSimpleUndoRedoController::StateChanged( USHORT, SfxItemState eState, const SfxPoolItem* pState )
+{
+ SfxStringItem* pItem = PTR_CAST( SfxStringItem, pState );
+ ToolBox& rBox = GetToolBox();
+ if ( pItem && eState != SFX_ITEM_DISABLED )
+ {
+ ::rtl::OUString aNewText( MnemonicGenerator::EraseAllMnemonicChars( pItem->GetValue() ) );
+ rBox.SetQuickHelpText( GetId(), aNewText );
+ }
+ if ( eState == SFX_ITEM_DISABLED )
+ rBox.SetQuickHelpText( GetId(), aDefaultText );
+ rBox.EnableItem( GetId(), eState != SFX_ITEM_DISABLED );
+}
+
+//========================================================================
+
+void lcl_ResizeValueSet( Window &rWin, ValueSet &rValueSet )
+{
+ Size aSize = rWin.GetOutputSizePixel();
+ aSize.Width() -= 4;
+ aSize.Height() -= 4;
+ rValueSet.SetPosSizePixel( Point(2,2), aSize );
+}
+
+// -----------------------------------------------------------------------
+
+void lcl_CalcSizeValueSet( Window &rWin, ValueSet &rValueSet, const Size &aItemSize )
+{
+ Size aSize = rValueSet.CalcWindowSizePixel( aItemSize );
+ aSize.Width() += 4;
+ aSize.Height() += 4;
+ rWin.SetOutputSizePixel( aSize );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL lcl_FontChangedHint( const SfxHint &rHint )
+{
+ SfxPoolItemHint *pItemHint = PTR_CAST(SfxPoolItemHint, &rHint);
+ if ( pItemHint )
+ {
+ SfxPoolItem *pItem = pItemHint->GetObject();
+ return ( pItem->Which() == SID_ATTR_CHAR_FONTLIST );
+ }
+ else
+ {
+ SfxSimpleHint* pSimpleHint = PTR_CAST(SfxSimpleHint, &rHint);
+ return pSimpleHint && ( SFX_HINT_DATACHANGED ==
+ ( pSimpleHint->GetId() & SFX_HINT_DATACHANGED ) );
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::accessibility::XAccessible > SvxFontNameBox_Impl::CreateAccessible()
+{
+ FillList();
+ return FontNameBox::CreateAccessible();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/tbcontrl.src b/svx/source/tbxctrls/tbcontrl.src
new file mode 100644
index 000000000000..67cff9ac4558
--- /dev/null
+++ b/svx/source/tbxctrls/tbcontrl.src
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include <svx/dialogs.hrc>
+#include <helpid.hrc>
+ // pragma ----------------------------------------------------------------
+
+/*
+ * Bitmaps f"ur SvxFrameWindow
+ */
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+
+Image RID_SVX_RELOAD_NORMAL
+{
+ ImageBitmap = Bitmap { File = "reload.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVX_RELOAD_SPECIAL
+{
+ ImageBitmap = Bitmap { File = "reloads.bmp" ; };
+ MASKCOLOR
+};
+ImageList RID_SVXIL_FRAME
+{
+ Prefix = "fr";
+ IdList = { 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 ; 11 ; 12 ; };
+ IdCount = { 12 ; };
+ MASKCOLOR
+};
+ImageList RID_SVXIL_FRAME_HC
+{
+ Prefix = "frh";
+ IdList = { 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ; 8 ; 9 ; 10 ; 11 ; 12 ; };
+ IdCount = { 12 ; };
+ MASKCOLOR
+};
+String RID_SVXSTR_TRANSPARENT
+{
+ Text [ en-US ] = "No Fill" ;
+};
+String RID_SVXSTR_FILLPATTERN
+{
+ Text [ en-US ] = "Pattern" ;
+};
+String RID_SVXSTR_FRAME
+{
+ Text [ en-US ] = "Borders" ;
+};
+String RID_SVXSTR_FRAME_STYLE
+{
+ Text [ en-US ] = "Border Style" ;
+};
+String RID_SVXSTR_FRAME_COLOR
+{
+ Text [ en-US ] = "Border Color" ;
+};
+ComboBox RID_SVXTBX_STYLE
+{
+ HelpId = HID_STYLE_LISTBOX ;
+ Size = MAP_APPFONT ( 67 , 86 ) ;
+ DropDown = TRUE ;
+ Sort = TRUE ;
+ AutoHScroll = TRUE ;
+ DDExtraWidth = TRUE ;
+ Border = TRUE ;
+ Hide = TRUE ;
+};
+String RID_SVXSTR_EXTRAS_CHARBACKGROUND
+{
+ Text [ en-US ] = "Highlighting" ;
+};
+String RID_SVXSTR_BACKGROUND
+{
+ Text [ en-US ] = "Background";
+};
+String RID_SVXSTR_AUTOMATIC
+{
+ Text [ en-US ] = "Automatic";
+};
+String RID_SVXSTR_PAGES
+{
+ Text [ en-US ] = "Pages";
+};
+Image RID_SVXIMG_GRAF_RED
+{
+ ImageBitmap = Bitmap { File = "sc10865.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_GREEN
+{
+ ImageBitmap = Bitmap { File = "sc10866.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_BLUE
+{
+ ImageBitmap = Bitmap { File = "sc10867.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_LUMINANCE
+{
+ ImageBitmap = Bitmap { File = "sc10863.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_CONTRAST
+{
+ ImageBitmap = Bitmap { File = "sc10864.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_GAMMA
+{
+ ImageBitmap = Bitmap { File = "sc10868.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_TRANSPARENCE
+{
+ ImageBitmap = Bitmap { File = "sc10869.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_RED_H
+{
+ ImageBitmap = Bitmap { File = "sch10865.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_GREEN_H
+{
+ ImageBitmap = Bitmap { File = "sch10866.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_BLUE_H
+{
+ ImageBitmap = Bitmap { File = "sch10867.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_LUMINANCE_H
+{
+ ImageBitmap = Bitmap { File = "sch10863.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_CONTRAST_H
+{
+ ImageBitmap = Bitmap { File = "sch10864.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_GAMMA_H
+{
+ ImageBitmap = Bitmap { File = "sch10868.bmp" ; };
+ MASKCOLOR
+};
+Image RID_SVXIMG_GRAF_TRANSPARENCE_H
+{
+ ImageBitmap = Bitmap { File = "sch10869.bmp" ; };
+ MASKCOLOR
+};
+String RID_SVXSTR_CLEARFORM
+{
+ Text [ en-US ] = "Clear formatting";
+};
+String RID_SVXSTR_MORE
+{
+ Text [ en-US ] = "More...";
+};
+
+// ********************************************************************** EOF
+
diff --git a/svx/source/tbxctrls/tbunocontroller.cxx b/svx/source/tbxctrls/tbunocontroller.cxx
new file mode 100644
index 000000000000..7b08c78030d9
--- /dev/null
+++ b/svx/source/tbxctrls/tbunocontroller.cxx
@@ -0,0 +1,432 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "tbunocontroller.hxx"
+
+#include <com/sun/star/frame/status/FontHeight.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <svtools/ctrltool.hxx>
+#include <svtools/ctrlbox.hxx>
+#include <osl/mutex.hxx>
+
+#include <memory>
+
+#define LOGICAL_EDIT_HEIGHT 12
+
+using namespace ::com::sun::star;
+
+namespace svx
+{
+
+class FontHeightToolBoxControl;
+class SvxFontSizeBox_Impl : public FontSizeBox
+{
+public:
+ SvxFontSizeBox_Impl( Window* pParent,
+ const uno::Reference< frame::XDispatchProvider >& rDispatchProvider,
+ const uno::Reference< frame::XFrame >& _xFrame,
+ FontHeightToolBoxControl& rCtrl );
+
+ void statusChanged_Impl( long nHeight, bool bErase = false );
+ void UpdateFont( const ::com::sun::star::awt::FontDescriptor& rCurrentFont );
+
+ virtual long Notify( NotifyEvent& rNEvt );
+
+protected:
+ virtual void Select();
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+private:
+ FontHeightToolBoxControl* m_pCtrl;
+ String m_aCurText;
+ Size m_aLogicalSize;
+ BOOL m_bRelease;
+ uno::Reference< frame::XDispatchProvider > m_xDispatchProvider;
+ uno::Reference< frame::XFrame > m_xFrame;
+ uno::Reference< awt::XWindow > m_xOldFocusWindow;
+
+ void ReleaseFocus_Impl();
+};
+
+//========================================================================
+// class SvxFontSizeBox_Impl --------------------------------------------------
+//========================================================================
+
+SvxFontSizeBox_Impl::SvxFontSizeBox_Impl(
+ Window* _pParent,
+ const uno::Reference< frame::XDispatchProvider >& _rDispatchProvider,
+ const uno::Reference< frame::XFrame >& _xFrame,
+ FontHeightToolBoxControl& _rCtrl ) :
+
+ FontSizeBox( _pParent, WinBits( WB_DROPDOWN ) ),
+
+ m_pCtrl ( &_rCtrl ),
+ m_aLogicalSize ( 30,100 ),
+ m_bRelease ( TRUE ),
+ m_xDispatchProvider ( _rDispatchProvider ),
+ m_xFrame ( _xFrame )
+{
+ SetSizePixel( LogicToPixel( m_aLogicalSize, MAP_APPFONT ));
+ SetValue( 0 );
+ SetText( String() );
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontSizeBox_Impl::ReleaseFocus_Impl()
+{
+ if ( !m_bRelease )
+ {
+ m_bRelease = TRUE;
+ return;
+ }
+
+ if ( m_xFrame.is() && m_xFrame->getContainerWindow().is() )
+ m_xFrame->getContainerWindow()->setFocus();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontSizeBox_Impl::Select()
+{
+ FontSizeBox::Select();
+
+ if ( !IsTravelSelect() )
+ {
+ sal_Int64 nSelVal = GetValue();
+ float fSelVal = float( nSelVal ) / 10;
+
+ uno::Sequence< beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight.Height" ));
+ aArgs[0].Value = uno::makeAny( fSelVal );
+
+ /* #i33380# DR 2004-09-03 Moved the following line above the Dispatch() call.
+ This instance may be deleted in the meantime (i.e. when a dialog is opened
+ while in Dispatch()), accessing members will crash in this case. */
+ ReleaseFocus_Impl();
+
+ m_pCtrl->dispatchCommand( aArgs );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontSizeBox_Impl::statusChanged_Impl( long nPoint, bool bErase )
+{
+ if ( !bErase )
+ {
+ // Metric Umrechnen
+ long nVal = nPoint;
+
+ // ge"andert => neuen Wert setzen
+ if ( GetValue() != nVal )
+ SetValue( nVal );
+ }
+ else
+ {
+ // Wert in der Anzeige l"oschen
+ SetValue( -1L );
+ SetText( String() );
+ }
+ SaveValue();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxFontSizeBox_Impl::UpdateFont( const ::com::sun::star::awt::FontDescriptor& rCurrentFont )
+{
+ // Sizes-Liste auff"ullen
+ sal_Int64 nOldVal = GetValue(); // alten Wert merken
+ const FontList* _pFontList = NULL;
+ ::std::auto_ptr<FontList> aHold( new FontList( this ));
+ _pFontList = aHold.get();
+
+ if ( rCurrentFont.Name.getLength() > 0 )
+ {
+ FontInfo _aFontInfo;
+ _aFontInfo.SetName( rCurrentFont.Name );
+ _aFontInfo.SetStyleName( rCurrentFont.StyleName );
+ _aFontInfo.SetHeight( rCurrentFont.Height );
+ Fill( &_aFontInfo, _pFontList );
+ }
+ else
+ {
+ Fill( NULL, _pFontList );
+ }
+ SetValue( nOldVal ); // alten Wert wiederherstellen
+ m_aCurText = GetText(); // zum R"ucksetzen bei ESC merken
+}
+
+// -----------------------------------------------------------------------
+
+long SvxFontSizeBox_Impl::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = 0;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ USHORT nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+
+ switch ( nCode )
+ {
+ case KEY_RETURN:
+ case KEY_TAB:
+ {
+ if ( KEY_TAB == nCode )
+ m_bRelease = FALSE;
+ else
+ nHandled = 1;
+ Select();
+ break;
+ }
+
+ case KEY_ESCAPE:
+ SetText( m_aCurText );
+ ReleaseFocus_Impl();
+ nHandled = 1;
+ break;
+ }
+ }
+ else if( EVENT_LOSEFOCUS == rNEvt.GetType() )
+ {
+ Window* pFocusWin = Application::GetFocusWindow();
+ if(!HasFocus() && GetSubEdit() != pFocusWin)
+ SetText(GetSavedValue());
+ }
+
+ return nHandled ? nHandled : FontSizeBox::Notify( rNEvt );
+}
+
+// ---------------------------------------------------------------------------
+
+void SvxFontSizeBox_Impl::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ SetSizePixel( LogicToPixel( m_aLogicalSize, MAP_APPFONT ));
+ Size aDropSize( m_aLogicalSize.Width(), LOGICAL_EDIT_HEIGHT );
+ SetDropDownSizePixel( LogicToPixel( aDropSize, MAP_APPFONT ));
+ }
+
+ FontSizeBox::DataChanged( rDCEvt );
+}
+
+//========================================================================
+// class FontHeightToolBoxControl
+//========================================================================
+
+FontHeightToolBoxControl::FontHeightToolBoxControl(
+ const uno::Reference< lang::XMultiServiceFactory >& rServiceManager ) :
+ svt::ToolboxController( rServiceManager,
+ uno::Reference< frame::XFrame >(),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontHeight" )) ),
+ m_pBox( NULL )
+{
+ addStatusListener( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName" )));
+}
+
+FontHeightToolBoxControl::~FontHeightToolBoxControl()
+{
+}
+
+// XInterface
+::com::sun::star::uno::Any SAL_CALL FontHeightToolBoxControl::queryInterface( const ::com::sun::star::uno::Type& aType )
+throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Any a = ToolboxController::queryInterface( aType );
+ if ( a.hasValue() )
+ return a;
+
+ return ::cppu::queryInterface( aType, static_cast< lang::XServiceInfo* >( this ));
+}
+
+void SAL_CALL FontHeightToolBoxControl::acquire() throw ()
+{
+ ToolboxController::acquire();
+}
+
+void SAL_CALL FontHeightToolBoxControl::release() throw ()
+{
+ ToolboxController::release();
+}
+
+// XServiceInfo
+sal_Bool SAL_CALL FontHeightToolBoxControl::supportsService( const ::rtl::OUString& ServiceName )
+throw(uno::RuntimeException)
+{
+ const uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
+ const ::rtl::OUString * pArray = aSNL.getConstArray();
+
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return true;
+
+ return false;
+}
+
+::rtl::OUString SAL_CALL FontHeightToolBoxControl::getImplementationName()
+throw( uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL FontHeightToolBoxControl::getSupportedServiceNames( )
+throw( uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+uno::Sequence< ::rtl::OUString > FontHeightToolBoxControl::getSupportedServiceNames_Static()
+throw()
+{
+ uno::Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
+ return aSNS;
+}
+
+// XComponent
+void SAL_CALL FontHeightToolBoxControl::dispose()
+throw (uno::RuntimeException)
+{
+ svt::ToolboxController::dispose();
+
+ SolarMutexGuard aSolarMutexGuard;
+ delete m_pBox;
+ m_pBox = 0;
+}
+
+// XStatusListener
+void SAL_CALL FontHeightToolBoxControl::statusChanged(
+ const frame::FeatureStateEvent& rEvent )
+throw ( uno::RuntimeException )
+{
+ if ( m_pBox )
+ {
+ SolarMutexGuard aSolarMutexGuard;
+ if ( rEvent.FeatureURL.Path.equalsAscii( "FontHeight" ))
+ {
+ if ( rEvent.IsEnabled )
+ {
+ m_pBox->Enable();
+ frame::status::FontHeight aFontHeight;
+ if ( rEvent.State >>= aFontHeight )
+ m_pBox->statusChanged_Impl( long( 10. * aFontHeight.Height ), false );
+ else
+ m_pBox->statusChanged_Impl( long( -1 ), true );
+ }
+ else
+ m_pBox->Disable();
+ }
+ else if ( rEvent.FeatureURL.Path.equalsAscii( "CharFontName" ))
+ {
+ if ( rEvent.State >>= m_aCurrentFont )
+ m_pBox->UpdateFont( m_aCurrentFont );
+ }
+ }
+}
+
+// XToolbarController
+void SAL_CALL FontHeightToolBoxControl::execute( sal_Int16 /*KeyModifier*/ )
+throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+void SAL_CALL FontHeightToolBoxControl::click()
+throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+void SAL_CALL FontHeightToolBoxControl::doubleClick()
+throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+uno::Reference< awt::XWindow > SAL_CALL FontHeightToolBoxControl::createPopupWindow()
+throw (::com::sun::star::uno::RuntimeException)
+{
+ return uno::Reference< awt::XWindow >();
+}
+
+uno::Reference< awt::XWindow > SAL_CALL FontHeightToolBoxControl::createItemWindow(
+ const uno::Reference< awt::XWindow >& Parent )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Reference< awt::XWindow > xItemWindow;
+ uno::Reference< awt::XWindow > xParent( Parent );
+
+ Window* pParent = VCLUnoHelper::GetWindow( xParent );
+ if ( pParent )
+ {
+ SolarMutexGuard aSolarMutexGuard;
+ m_pBox = new SvxFontSizeBox_Impl(
+ pParent,
+ uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ),
+ m_xFrame,
+ *this );
+ xItemWindow = VCLUnoHelper::GetInterface( m_pBox );
+ }
+
+ return xItemWindow;
+}
+
+void FontHeightToolBoxControl::dispatchCommand(
+ const uno::Sequence< beans::PropertyValue >& rArgs )
+{
+ uno::Reference< frame::XDispatchProvider > xDispatchProvider( m_xFrame, uno::UNO_QUERY );
+ if ( xDispatchProvider.is() )
+ {
+ util::URL aURL;
+ uno::Reference< frame::XDispatch > xDispatch;
+ uno::Reference< util::XURLTransformer > xURLTransformer = getURLTransformer();
+
+ aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontHeight" ));
+ xURLTransformer->parseStrict( aURL );
+ xDispatch = xDispatchProvider->queryDispatch( aURL, ::rtl::OUString(), 0 );
+ if ( xDispatch.is() )
+ xDispatch->dispatch( aURL, rArgs );
+ }
+}
+
+uno::Reference< uno::XInterface > SAL_CALL FontHeightToolBoxControl_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory >& rSMgr )
+{
+ return *new FontHeightToolBoxControl( rSMgr );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.cxx b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
new file mode 100644
index 000000000000..145a2ef3fdd9
--- /dev/null
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.cxx
@@ -0,0 +1,876 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "tbunosearchcontrollers.hxx"
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/ui/XUIElement.hpp>
+#include <com/sun/star/util/URL.hpp>
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+
+namespace svx
+{
+
+static const ::rtl::OUString SEARCHITEM_SEARCHSTRING = ::rtl::OUString::createFromAscii("SearchItem.SearchString");
+static const ::rtl::OUString SEARCHITEM_SEARCHBACKWARD = ::rtl::OUString::createFromAscii("SearchItem.Backward");
+
+static const ::rtl::OUString COMMAND_EXECUTESEARCH = ::rtl::OUString::createFromAscii(".uno:ExecuteSearch");
+static const ::rtl::OUString COMMAND_FINDTEXT = ::rtl::OUString::createFromAscii(".uno:FindText") ;
+static const ::rtl::OUString COMMAND_DOWNSEARCH = ::rtl::OUString::createFromAscii(".uno:DownSearch");
+static const ::rtl::OUString COMMAND_UPSEARCH = ::rtl::OUString::createFromAscii(".uno:UpSearch") ;
+static const ::rtl::OUString COMMAND_APPENDSEARCHHISTORY = ::rtl::OUString::createFromAscii("AppendSearchHistory");
+
+static const ::rtl::OUString SERVICENAME_URLTRANSFORMER = ::rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer");
+static const sal_Int32 REMEMBER_SIZE = 10;
+
+void impl_executeSearch( const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr, const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Sequence< css::beans::PropertyValue >& lArgs )
+{
+ css::uno::Reference< css::util::XURLTransformer > xURLTransformer( rSMgr->createInstance(SERVICENAME_URLTRANSFORMER), css::uno::UNO_QUERY );
+ if ( xURLTransformer.is() )
+ {
+ css::util::URL aURL;
+ aURL.Complete = COMMAND_EXECUTESEARCH;
+ xURLTransformer->parseStrict(aURL);
+
+ css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider(xFrame, css::uno::UNO_QUERY);
+ if ( xDispatchProvider.is() )
+ {
+ css::uno::Reference< css::frame::XDispatch > xDispatch = xDispatchProvider->queryDispatch( aURL, ::rtl::OUString(), 0 );
+ if ( xDispatch.is() && aURL.Complete.getLength() > 0 )
+ xDispatch->dispatch( aURL, lArgs );
+ }
+ }
+}
+
+FindTextFieldControl::FindTextFieldControl( Window* pParent, WinBits nStyle,
+ css::uno::Reference< css::frame::XFrame >& xFrame,
+ css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager) :
+ ComboBox( pParent, nStyle ),
+ m_xFrame(xFrame),
+ m_xServiceManager(xServiceManager),
+ m_bToClearTextField(sal_True)
+{
+ InitControls_Impl();
+}
+
+FindTextFieldControl::~FindTextFieldControl()
+{
+}
+
+void FindTextFieldControl::InitControls_Impl()
+{
+ SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) );
+ SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor());
+
+ EnableAutocomplete(TRUE, TRUE);
+}
+
+void FindTextFieldControl::Remember_Impl(const String& rStr)
+{
+ USHORT nCount = GetEntryCount();
+
+ for (USHORT i=0; i<nCount; ++i)
+ {
+ if ( rStr == GetEntry(i))
+ return;
+ }
+
+ if (nCount == REMEMBER_SIZE)
+ RemoveEntry(REMEMBER_SIZE-1);
+
+ InsertEntry(rStr, 0);
+}
+
+void FindTextFieldControl::Modify()
+{
+ ComboBox::Modify();
+
+ SetControlForeground( GetSettings().GetStyleSettings().GetWindowTextColor() );
+}
+
+long FindTextFieldControl::PreNotify( NotifyEvent& rNEvt )
+{
+ long nRet= ComboBox::PreNotify( rNEvt );
+
+ switch ( rNEvt.GetType() )
+ {
+ case EVENT_KEYINPUT:
+ {
+ const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
+ sal_Bool bCtrl = pKeyEvent->GetKeyCode().IsMod1();
+ sal_Bool bAlt = pKeyEvent->GetKeyCode().IsMod2();
+ sal_Bool bShift = pKeyEvent->GetKeyCode().IsShift();
+ sal_uInt16 nCode = pKeyEvent->GetKeyCode().GetCode();
+
+ if ( (bCtrl && bAlt && KEY_F == nCode) || KEY_ESCAPE == nCode )
+ {
+ nRet = 1;
+ GrabFocusToDocument();
+ }
+
+ if ( KEY_RETURN == nCode )
+ {
+ Remember_Impl(GetText());
+
+ ::rtl::OUString sFindText = GetText();
+ css::uno::Sequence< css::beans::PropertyValue > lArgs(2);
+
+ lArgs[0].Name = SEARCHITEM_SEARCHSTRING;
+ lArgs[0].Value <<= sFindText;
+
+ lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD;
+ if (bShift)
+ lArgs[1].Value <<= sal_True;
+ else
+ lArgs[1].Value <<= sal_False;
+
+ impl_executeSearch(m_xServiceManager, m_xFrame, lArgs);
+ nRet = 1;
+ }
+ break;
+ }
+
+ case EVENT_GETFOCUS:
+ if ( m_bToClearTextField )
+ {
+ SetText( String() );
+ m_bToClearTextField = sal_False;
+ }
+ SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
+ break;
+
+ case EVENT_LOSEFOCUS:
+ if ( GetText().Len() == 0 )
+ {
+ SetText( SVX_RESSTR( RID_SVXSTR_FINDBAR_FIND ) );
+ SetControlForeground(GetSettings().GetStyleSettings().GetDisableColor());
+ m_bToClearTextField = sal_True;
+ }
+ break;
+ }
+
+ return nRet;
+}
+
+
+//-----------------------------------------------------------------------------------------------------------
+// SearchToolbarControllersManager
+
+SearchToolbarControllersManager* SearchToolbarControllersManager::m_pInstance = 0;
+
+SearchToolbarControllersManager::SearchToolbarControllersManager()
+{
+}
+
+SearchToolbarControllersManager::~SearchToolbarControllersManager()
+{
+}
+
+SearchToolbarControllersManager* SearchToolbarControllersManager::createControllersManager()
+{
+ if (!m_pInstance)
+ m_pInstance = new SearchToolbarControllersManager();
+
+ return m_pInstance;
+}
+
+void SearchToolbarControllersManager::registryController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& xStatusListener, const ::rtl::OUString& sCommandURL )
+{
+ SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
+ if (pIt == aSearchToolbarControllersMap.end())
+ {
+ SearchToolbarControllersVec lControllers(1);
+ lControllers[0].Name = sCommandURL;
+ lControllers[0].Value <<= xStatusListener;
+ aSearchToolbarControllersMap.insert(SearchToolbarControllersMap::value_type(xFrame, lControllers));
+ }
+ else
+ {
+ sal_Int32 nSize = pIt->second.size();
+ for (sal_Int32 i=0; i<nSize; ++i)
+ {
+ if (pIt->second[i].Name.equals(sCommandURL))
+ return;
+ }
+
+ pIt->second.resize(nSize+1);
+ pIt->second[nSize].Name = sCommandURL;
+ pIt->second[nSize].Value <<= xStatusListener;
+ }
+}
+
+void SearchToolbarControllersManager::freeController( const css::uno::Reference< css::frame::XFrame >& xFrame, const css::uno::Reference< css::frame::XStatusListener >& /*xStatusListener*/, const ::rtl::OUString& sCommandURL )
+{
+ SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
+ if (pIt != aSearchToolbarControllersMap.end())
+ {
+ for (SearchToolbarControllersVec::iterator pItCtrl=pIt->second.begin(); pItCtrl!=pIt->second.end(); ++pItCtrl)
+ {
+ if (pItCtrl->Name.equals(sCommandURL))
+ {
+ pIt->second.erase(pItCtrl);
+ break;
+ }
+ }
+
+ if (pIt->second.empty())
+ aSearchToolbarControllersMap.erase(pIt);
+ }
+}
+
+css::uno::Reference< css::frame::XStatusListener > SearchToolbarControllersManager::findController( const css::uno::Reference< css::frame::XFrame >& xFrame, const ::rtl::OUString& sCommandURL )
+{
+ css::uno::Reference< css::frame::XStatusListener > xStatusListener;
+
+ SearchToolbarControllersMap::iterator pIt = aSearchToolbarControllersMap.find(xFrame);
+ if (pIt != aSearchToolbarControllersMap.end())
+ {
+ for (SearchToolbarControllersVec::iterator pItCtrl =pIt->second.begin(); pItCtrl != pIt->second.end(); ++pItCtrl)
+ {
+ if (pItCtrl->Name.equals(sCommandURL))
+ {
+ pItCtrl->Value >>= xStatusListener;
+ break;
+ }
+ }
+ }
+
+ return xStatusListener;
+}
+
+//-----------------------------------------------------------------------------------------------------------
+// FindTextToolbarController
+
+FindTextToolbarController::FindTextToolbarController( const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager )
+ :svt::ToolboxController( rServiceManager,
+ css::uno::Reference< css::frame::XFrame >(),
+ COMMAND_FINDTEXT )
+{
+}
+
+FindTextToolbarController::~FindTextToolbarController()
+{
+}
+
+// XInterface
+css::uno::Any SAL_CALL FindTextToolbarController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException )
+{
+ css::uno::Any a = ToolboxController::queryInterface( aType );
+ if ( a.hasValue() )
+ return a;
+
+ return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
+}
+
+void SAL_CALL FindTextToolbarController::acquire() throw ()
+{
+ ToolboxController::acquire();
+}
+
+void SAL_CALL FindTextToolbarController::release() throw ()
+{
+ ToolboxController::release();
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL FindTextToolbarController::getImplementationName() throw( css::uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+sal_Bool SAL_CALL FindTextToolbarController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException )
+{
+ const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
+ const ::rtl::OUString * pArray = aSNL.getConstArray();
+
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return true;
+
+ return false;
+}
+
+css::uno::Sequence< ::rtl::OUString > SAL_CALL FindTextToolbarController::getSupportedServiceNames() throw( css::uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+css::uno::Sequence< ::rtl::OUString > FindTextToolbarController::getSupportedServiceNames_Static() throw()
+{
+ css::uno::Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ) );
+ return aSNS;
+}
+
+// XComponent
+void SAL_CALL FindTextToolbarController::dispose() throw ( css::uno::RuntimeException )
+{
+ SolarMutexGuard aSolarMutexGuard;
+
+ SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
+
+ svt::ToolboxController::dispose();
+ delete m_pFindTextFieldControl;
+ m_pFindTextFieldControl = 0;
+}
+
+// XInitialization
+void SAL_CALL FindTextToolbarController::initialize( const css::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException)
+{
+ svt::ToolboxController::initialize(aArguments);
+
+ Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
+ ToolBox* pToolBox = (ToolBox*)pWindow;
+ if ( pToolBox )
+ {
+ USHORT nItemCount = pToolBox->GetItemCount();
+ for ( USHORT i=0; i<nItemCount; ++i )
+ {
+ ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i);
+ if ( sItemCommand.equals( COMMAND_DOWNSEARCH ) )
+ m_nDownSearchId = i;
+ else if (sItemCommand.equals( COMMAND_UPSEARCH ))
+ m_nUpSearchId = i;
+ }
+ }
+
+ SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
+}
+
+// XToolbarController
+void SAL_CALL FindTextToolbarController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException )
+{
+}
+
+css::uno::Reference< css::awt::XWindow > SAL_CALL FindTextToolbarController::createItemWindow( const css::uno::Reference< css::awt::XWindow >& Parent ) throw ( css::uno::RuntimeException )
+{
+ css::uno::Reference< css::awt::XWindow > xItemWindow;
+
+ css::uno::Reference< css::awt::XWindow > xParent( Parent );
+ Window* pParent = VCLUnoHelper::GetWindow( xParent );
+ if ( pParent )
+ {
+ ToolBox* pToolbar = ( ToolBox* )pParent;
+ m_pFindTextFieldControl = new FindTextFieldControl( pToolbar, WinBits( WB_DROPDOWN | WB_VSCROLL), m_xFrame, m_xServiceManager );
+
+ Size aSize(100, m_pFindTextFieldControl->GetTextHeight() + 200);
+ m_pFindTextFieldControl->SetSizePixel( aSize );
+ m_pFindTextFieldControl->SetModifyHdl(LINK(this, FindTextToolbarController, EditModifyHdl));
+ }
+ xItemWindow = VCLUnoHelper::GetInterface( m_pFindTextFieldControl );
+
+ return xItemWindow;
+}
+
+// XStatusListener
+void SAL_CALL FindTextToolbarController::statusChanged( const css::frame::FeatureStateEvent& rEvent ) throw ( css::uno::RuntimeException )
+{
+ SolarMutexGuard aSolarMutexGuard;
+ if ( m_bDisposed )
+ return;
+
+ ::rtl::OUString aFeatureURL = rEvent.FeatureURL.Complete;
+ if (aFeatureURL.equalsAscii("AppendSearchHistory"))
+ {
+ m_pFindTextFieldControl->Remember_Impl(m_pFindTextFieldControl->GetText());
+ }
+}
+
+IMPL_LINK( FindTextToolbarController, EditModifyHdl, void *, EMPTYARG )
+{
+ // enable or disable item DownSearch/UpSearch of findbar
+ Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
+ ToolBox* pToolBox = (ToolBox*)pWindow;
+ if ( pToolBox && m_pFindTextFieldControl )
+ {
+ if (m_pFindTextFieldControl->GetText().Len()>0)
+ {
+ if ( !pToolBox->IsItemEnabled(m_nDownSearchId) )
+ pToolBox->EnableItem(m_nDownSearchId, sal_True);
+ if ( !pToolBox->IsItemEnabled(m_nUpSearchId) )
+ pToolBox->EnableItem(m_nUpSearchId, sal_True);
+ }
+ else
+ {
+ if ( pToolBox->IsItemEnabled(m_nDownSearchId) )
+ pToolBox->EnableItem(m_nDownSearchId, sal_False);
+ if ( pToolBox->IsItemEnabled(m_nUpSearchId) )
+ pToolBox->EnableItem(m_nUpSearchId, sal_False);
+ }
+ }
+
+ return 0;
+}
+
+//-----------------------------------------------------------------------------------------------------------
+// class DownSearchToolboxController
+
+DownSearchToolboxController::DownSearchToolboxController(const css::uno::Reference< css::lang::XMultiServiceFactory >& rServiceManager )
+ : svt::ToolboxController( rServiceManager,
+ css::uno::Reference< css::frame::XFrame >(),
+ COMMAND_DOWNSEARCH )
+{
+}
+
+DownSearchToolboxController::~DownSearchToolboxController()
+{
+}
+
+// XInterface
+css::uno::Any SAL_CALL DownSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException )
+{
+ css::uno::Any a = ToolboxController::queryInterface( aType );
+ if ( a.hasValue() )
+ return a;
+
+ return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
+}
+
+void SAL_CALL DownSearchToolboxController::acquire() throw ()
+{
+ ToolboxController::acquire();
+}
+
+void SAL_CALL DownSearchToolboxController::release() throw ()
+{
+ ToolboxController::release();
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL DownSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+sal_Bool SAL_CALL DownSearchToolboxController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException )
+{
+ const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
+ const ::rtl::OUString * pArray = aSNL.getConstArray();
+
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return true;
+
+ return false;
+}
+
+css::uno::Sequence< ::rtl::OUString > SAL_CALL DownSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+css::uno::Sequence< ::rtl::OUString > DownSearchToolboxController::getSupportedServiceNames_Static() throw()
+{
+ css::uno::Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ));
+ return aSNS;
+}
+
+// XComponent
+void SAL_CALL DownSearchToolboxController::dispose() throw ( css::uno::RuntimeException )
+{
+ SolarMutexGuard aSolarMutexGuard;
+
+ SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
+
+ svt::ToolboxController::dispose();
+}
+
+// XInitialization
+void SAL_CALL DownSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException )
+{
+ svt::ToolboxController::initialize( aArguments );
+ SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
+}
+
+// XToolbarController
+void SAL_CALL DownSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException)
+{
+ if ( m_bDisposed )
+ throw css::lang::DisposedException();
+
+ ::rtl::OUString sFindText;
+ Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
+ ToolBox* pToolBox = (ToolBox*)pWindow;
+ if ( pToolBox )
+ {
+ USHORT nItemCount = pToolBox->GetItemCount();
+ for ( USHORT i=0; i<nItemCount; ++i )
+ {
+ ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i);
+ if ( sItemCommand.equals( COMMAND_FINDTEXT ) )
+ {
+ Window* pItemWin = pToolBox->GetItemWindow(i);
+ if (pItemWin)
+ sFindText = pItemWin->GetText();
+ break;
+ }
+ }
+ }
+
+ css::uno::Sequence< css::beans::PropertyValue > lArgs(2);
+ lArgs[0].Name = SEARCHITEM_SEARCHSTRING;
+ lArgs[0].Value <<= sFindText;
+ lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD;
+ lArgs[1].Value <<= sal_False;
+
+ impl_executeSearch(m_xServiceManager, m_xFrame, lArgs);
+
+ css::frame::FeatureStateEvent aEvent;
+ aEvent.FeatureURL.Complete = COMMAND_APPENDSEARCHHISTORY;
+ css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT);
+ if (xStatusListener.is())
+ xStatusListener->statusChanged( aEvent );
+}
+
+// XStatusListener
+void SAL_CALL DownSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException )
+{
+ SolarMutexGuard aSolarMutexGuard;
+ if ( m_bDisposed )
+ return;
+}
+
+//-----------------------------------------------------------------------------------------------------------
+// class UpSearchToolboxController
+
+UpSearchToolboxController::UpSearchToolboxController( const css::uno::Reference< css::lang::XMultiServiceFactory > & rServiceManager )
+ :svt::ToolboxController( rServiceManager,
+ css::uno::Reference< css::frame::XFrame >(),
+ COMMAND_UPSEARCH )
+{
+}
+
+UpSearchToolboxController::~UpSearchToolboxController()
+{
+}
+
+// XInterface
+css::uno::Any SAL_CALL UpSearchToolboxController::queryInterface( const css::uno::Type& aType ) throw ( css::uno::RuntimeException )
+{
+ css::uno::Any a = ToolboxController::queryInterface( aType );
+ if ( a.hasValue() )
+ return a;
+
+ return ::cppu::queryInterface( aType, static_cast< css::lang::XServiceInfo* >( this ) );
+}
+
+void SAL_CALL UpSearchToolboxController::acquire() throw ()
+{
+ ToolboxController::acquire();
+}
+
+void SAL_CALL UpSearchToolboxController::release() throw ()
+{
+ ToolboxController::release();
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL UpSearchToolboxController::getImplementationName() throw( css::uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+sal_Bool SAL_CALL UpSearchToolboxController::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException )
+{
+ const css::uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
+ const ::rtl::OUString * pArray = aSNL.getConstArray();
+
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return true;
+
+ return false;
+}
+
+css::uno::Sequence< ::rtl::OUString > SAL_CALL UpSearchToolboxController::getSupportedServiceNames() throw( css::uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+css::uno::Sequence< ::rtl::OUString > UpSearchToolboxController::getSupportedServiceNames_Static() throw()
+{
+ css::uno::Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ) );
+ return aSNS;
+}
+
+// XComponent
+void SAL_CALL UpSearchToolboxController::dispose() throw ( css::uno::RuntimeException )
+{
+ SolarMutexGuard aSolarMutexGuard;
+
+ SearchToolbarControllersManager::createControllersManager()->freeController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
+
+ svt::ToolboxController::dispose();
+}
+
+// XInitialization
+void SAL_CALL UpSearchToolboxController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException )
+{
+ svt::ToolboxController::initialize( aArguments );
+ SearchToolbarControllersManager::createControllersManager()->registryController(m_xFrame, css::uno::Reference< css::frame::XStatusListener >(static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY), m_aCommandURL);
+}
+
+// XToolbarController
+void SAL_CALL UpSearchToolboxController::execute( sal_Int16 /*KeyModifier*/ ) throw ( css::uno::RuntimeException )
+{
+ if ( m_bDisposed )
+ throw css::lang::DisposedException();
+
+ ::rtl::OUString sFindText;
+ Window* pWindow = VCLUnoHelper::GetWindow( getParent() );
+ ToolBox* pToolBox = (ToolBox*)pWindow;
+ if ( pToolBox )
+ {
+ USHORT nItemCount = pToolBox->GetItemCount();
+ for ( USHORT i=0; i<nItemCount; ++i )
+ {
+ ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i);
+ if ( sItemCommand.equals( COMMAND_FINDTEXT ) )
+ {
+ Window* pItemWin = pToolBox->GetItemWindow(i);
+ if (pItemWin)
+ sFindText = pItemWin->GetText();
+ break;
+ }
+ }
+ }
+
+ css::uno::Sequence< css::beans::PropertyValue > lArgs(2);
+ lArgs[0].Name = SEARCHITEM_SEARCHSTRING;
+ lArgs[0].Value <<= sFindText;
+ lArgs[1].Name = SEARCHITEM_SEARCHBACKWARD;
+ lArgs[1].Value <<= sal_True;
+
+ impl_executeSearch(m_xServiceManager, m_xFrame, lArgs);
+
+ css::frame::FeatureStateEvent aEvent;
+ aEvent.FeatureURL.Complete = COMMAND_APPENDSEARCHHISTORY;
+ css::uno::Reference< css::frame::XStatusListener > xStatusListener = SearchToolbarControllersManager::createControllersManager()->findController(m_xFrame, COMMAND_FINDTEXT);
+ if (xStatusListener.is())
+ xStatusListener->statusChanged( aEvent );
+}
+
+// XStatusListener
+void SAL_CALL UpSearchToolboxController::statusChanged( const css::frame::FeatureStateEvent& /*rEvent*/ ) throw ( css::uno::RuntimeException )
+{
+ SolarMutexGuard aSolarMutexGuard;
+ if ( m_bDisposed )
+ return;
+}
+
+//-----------------------------------------------------------------------------------------------------------
+// class FindbarDispatcher
+
+FindbarDispatcher::FindbarDispatcher(const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory)
+ : m_xFactory( xFactory )
+{
+}
+
+FindbarDispatcher::~FindbarDispatcher()
+{
+ m_xFactory = NULL;
+ m_xFrame = NULL;
+}
+
+// XInterface
+css::uno::Any SAL_CALL FindbarDispatcher::queryInterface( const css::uno::Type& aType ) throw( css::uno::RuntimeException )
+{
+ css::uno::Any aReturn( ::cppu::queryInterface( aType,
+ static_cast< css::lang::XServiceInfo* >(this),
+ static_cast< css::lang::XInitialization* >(this),
+ static_cast< css::frame::XDispatchProvider* >(this),
+ static_cast< css::frame::XDispatch* >(this)) );
+
+ if ( aReturn.hasValue() )
+ return aReturn;
+
+ return OWeakObject::queryInterface( aType );
+}
+
+void SAL_CALL FindbarDispatcher::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+void SAL_CALL FindbarDispatcher::release() throw()
+{
+ OWeakObject::release();
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL FindbarDispatcher::getImplementationName() throw( css::uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+sal_Bool SAL_CALL FindbarDispatcher::supportsService( const ::rtl::OUString& ServiceName ) throw( css::uno::RuntimeException )
+{
+ return (
+ ServiceName.equalsAscii("com.sun.star.comp.svx.FindbarDispatcher") ||
+ ServiceName.equalsAscii("com.sun.star.frame.ProtocolHandler")
+ );
+}
+
+css::uno::Sequence< ::rtl::OUString > SAL_CALL FindbarDispatcher::getSupportedServiceNames() throw( css::uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+css::uno::Sequence< ::rtl::OUString > FindbarDispatcher::getSupportedServiceNames_Static() throw()
+{
+ css::uno::Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svx.FindbarDispatcher" ));
+ aSNS.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ProtocolHandler" ));
+ return aSNS;
+}
+
+// XInitialization
+void SAL_CALL FindbarDispatcher::initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw ( css::uno::Exception, css::uno::RuntimeException )
+{
+ if ( aArguments.getLength() )
+ aArguments[0] >>= m_xFrame;
+}
+
+// XDispatchProvider
+css::uno::Reference< css::frame::XDispatch > SAL_CALL FindbarDispatcher::queryDispatch( const css::util::URL& aURL, const ::rtl::OUString& /*sTargetFrameName*/, sal_Int32 /*nSearchFlags*/ ) throw( css::uno::RuntimeException )
+{
+ css::uno::Reference< css::frame::XDispatch > xDispatch;
+
+ if ( aURL.Protocol.equalsAscii("vnd.sun.star.findbar:") )
+ xDispatch = this;
+
+ return xDispatch;
+}
+
+css::uno::Sequence < css::uno::Reference< css::frame::XDispatch > > SAL_CALL FindbarDispatcher::queryDispatches( const css::uno::Sequence < css::frame::DispatchDescriptor >& seqDescripts ) throw( css::uno::RuntimeException )
+{
+ sal_Int32 nCount = seqDescripts.getLength();
+ css::uno::Sequence < css::uno::Reference < XDispatch > > lDispatcher( nCount );
+
+ for( sal_Int32 i=0; i<nCount; ++i )
+ lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL, seqDescripts[i].FrameName, seqDescripts[i].SearchFlags );
+
+ return lDispatcher;
+}
+
+// XDispatch
+void SAL_CALL FindbarDispatcher::dispatch( const css::util::URL& aURL, const css::uno::Sequence < css::beans::PropertyValue >& /*lArgs*/ ) throw( css::uno::RuntimeException )
+{
+ //vnd.sun.star.findbar:FocusToFindbar - set cursor to the FindTextFieldControl of the findbar
+ if ( aURL.Path.equalsAscii("FocusToFindbar") )
+ {
+ css::uno::Reference< css::beans::XPropertySet > xPropSet(m_xFrame, css::uno::UNO_QUERY);
+ if(!xPropSet.is())
+ return;
+
+ css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
+ css::uno::Any aValue = xPropSet->getPropertyValue( ::rtl::OUString::createFromAscii("LayoutManager") );
+ aValue >>= xLayoutManager;
+ if (!xLayoutManager.is())
+ return;
+
+ const ::rtl::OUString sResourceURL = ::rtl::OUString::createFromAscii("private:resource/toolbar/findbar");
+ css::uno::Reference< css::ui::XUIElement > xUIElement = xLayoutManager->getElement(sResourceURL);
+ if (!xUIElement.is())
+ return;
+
+ css::uno::Reference< css::awt::XWindow > xWindow(xUIElement->getRealInterface(), css::uno::UNO_QUERY);
+ Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
+ ToolBox* pToolBox = (ToolBox*)pWindow;
+ if ( pToolBox )
+ {
+ USHORT nItemCount = pToolBox->GetItemCount();
+ for ( USHORT i=0; i<nItemCount; ++i )
+ {
+ ::rtl::OUString sItemCommand = pToolBox->GetItemCommand(i);
+ if ( sItemCommand.equalsAscii(".uno:FindText") )
+ {
+ Window* pItemWin = pToolBox->GetItemWindow( i );
+ if ( pItemWin )
+ {
+ pItemWin->GrabFocus();
+ return;
+ }
+ }
+ }
+ }
+
+ }
+}
+
+void SAL_CALL FindbarDispatcher::addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& /*xControl*/, const css::util::URL& /*aURL*/ ) throw ( css::uno::RuntimeException )
+{
+}
+
+void SAL_CALL FindbarDispatcher::removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& /*xControl*/, const css::util::URL& /*aURL*/ ) throw ( css::uno::RuntimeException )
+{
+}
+
+//-----------------------------------------------------------------------------------------------------------
+// create Instance
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL FindTextToolbarController_createInstance(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr )
+{
+ return *new FindTextToolbarController( rSMgr );
+}
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL DownSearchToolboxController_createInstance(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr )
+{
+ return *new DownSearchToolboxController( rSMgr );
+}
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL UpSearchToolboxController_createInstance(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr )
+{
+ return *new UpSearchToolboxController( rSMgr );
+}
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL FindbarDispatcher_createInstance(
+ const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr )
+{
+ return *new FindbarDispatcher( rSMgr );
+}
+
+//-----------------------------------------------------------------------------------------------------------
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/tbunosearchcontrollers.src b/svx/source/tbxctrls/tbunosearchcontrollers.src
new file mode 100644
index 000000000000..ff1565e2d289
--- /dev/null
+++ b/svx/source/tbxctrls/tbunosearchcontrollers.src
@@ -0,0 +1,33 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+
+String RID_SVXSTR_FINDBAR_FIND
+{
+ Text [ en-US ] = "Find" ;
+};
diff --git a/svx/source/tbxctrls/tbxalign.cxx b/svx/source/tbxctrls/tbxalign.cxx
new file mode 100644
index 000000000000..f35550d21b54
--- /dev/null
+++ b/svx/source/tbxctrls/tbxalign.cxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svl/aeitem.hxx>
+
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+
+#include "tbxalign.hxx"
+#include "tbxdraw.hxx"
+#include "tbxdraw.hrc"
+#include <tools/shl.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+
+#include <sfx2/app.hxx>
+#include <vcl/toolbox.hxx>
+
+SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlAlign, SfxAllEnumItem);
+
+/*************************************************************************
+|*
+|* Klasse fuer SwToolbox
+|*
+\************************************************************************/
+
+SvxTbxCtlAlign::SvxTbxCtlAlign( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx )
+ , m_aSubTbName( RTL_CONSTASCII_USTRINGPARAM( "alignmentbar" ))
+ , m_aSubTbResName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/alignmentbar" ))
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+
+ m_aCommand = m_aCommandURL;
+}
+
+/*************************************************************************
+|*
+|* Wenn man ein PopupWindow erzeugen will
+|*
+\************************************************************************/
+
+SfxPopupWindowType SvxTbxCtlAlign::GetPopupWindowType() const
+{
+ return(SFX_POPUPWINDOW_ONCLICK);
+}
+
+/*************************************************************************
+|*
+|* Hier wird das Fenster erzeugt
+|* Lage der Toolbox mit GetToolBox() abfragbar
+|* rItemRect sind die Screen-Koordinaten
+|*
+\************************************************************************/
+
+SfxPopupWindow* SvxTbxCtlAlign::CreatePopupWindow()
+{
+ SolarMutexGuard aGuard;
+ if ( GetSlotId() == SID_OBJECT_ALIGN )
+ createAndPositionSubToolBar( m_aSubTbResName );
+ return NULL;
+}
+
+//========================================================================
+// XSubToolbarController
+//========================================================================
+
+::sal_Bool SAL_CALL SvxTbxCtlAlign::opensSubToolbar() throw (::com::sun::star::uno::RuntimeException)
+{
+ // We control a sub-toolbar therefor, we have to return true.
+ return sal_True;
+}
+
+::rtl::OUString SAL_CALL SvxTbxCtlAlign::getSubToolbarName() throw (::com::sun::star::uno::RuntimeException)
+{
+ // Provide the controlled sub-toolbar name, so we are notified whenever
+ // this toolbar executes a function.
+ SolarMutexGuard aGuard;
+ return m_aSubTbName;
+}
+
+void SAL_CALL SvxTbxCtlAlign::functionSelected( const ::rtl::OUString& aCommand ) throw (::com::sun::star::uno::RuntimeException)
+{
+ // Our sub-toolbar wants to executes a function. We have to change
+ // the image of our toolbar button to reflect the new function.
+ SolarMutexGuard aGuard;
+ if ( !m_bDisposed )
+ {
+ if ( aCommand.getLength() > 0 )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
+ Image aImage = GetImage( xFrame, aCommand, hasBigImages(), isHighContrast() );
+ if ( !!aImage )
+ GetToolBox().SetItemImage( GetId(), aImage );
+ }
+ }
+}
+
+void SAL_CALL SvxTbxCtlAlign::updateImage() throw (::com::sun::star::uno::RuntimeException)
+{
+ // We should update the button image of our parent (toolbar). Use the stored
+ // command to set the correct current image.
+ SolarMutexGuard aGuard;
+ if ( m_aCommand.getLength() > 0 )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( getFrameInterface());
+ Image aImage = GetImage( xFrame, m_aCommand, hasBigImages(), isHighContrast() );
+ if ( !!aImage )
+ GetToolBox().SetItemImage( GetId(), aImage );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/tbxcolor.cxx b/svx/source/tbxctrls/tbxcolor.cxx
new file mode 100644
index 000000000000..24008a9384ad
--- /dev/null
+++ b/svx/source/tbxctrls/tbxcolor.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "tbxcolor.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::frame;
+
+ #define DECLARE_ASCII(s) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(s) )
+ #define TOOLBAR_RESNAME DECLARE_ASCII("private:resource/toolbar/")
+ #define PROPNAME_LAYOUTMANAGER DECLARE_ASCII("LayoutManager")
+
+ //====================================================================
+ //= ToolboxAccess
+ //====================================================================
+ ToolboxAccess::ToolboxAccess( const ::rtl::OUString& rToolboxName ) :
+
+ m_bDocking ( false ),
+ m_sToolboxResName ( TOOLBAR_RESNAME )
+
+ {
+ m_sToolboxResName += rToolboxName;
+
+ // the layout manager
+ if ( SfxViewFrame::Current() )
+ {
+ try
+ {
+ Reference< XFrame > xFrame = SfxViewFrame::Current()->GetFrame().GetFrameInterface();
+ Reference< XPropertySet > xFrameProps( xFrame, UNO_QUERY );
+ if ( xFrameProps.is() )
+ xFrameProps->getPropertyValue( PROPNAME_LAYOUTMANAGER ) >>= m_xLayouter;
+ }
+ catch ( Exception& )
+ {
+ DBG_ERRORFILE( "ToolboxAccess::Ctor(): exception" );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ToolboxAccess::toggleToolbox() const
+ {
+ try
+ {
+ Reference< XLayoutManager > xManager( m_xLayouter );
+ OSL_ENSURE( xManager. is(), "ToolboxAccess::toggleToolbox: couldn't obtain the layout manager!" );
+ if ( xManager. is() )
+ {
+ if ( xManager->isElementVisible( m_sToolboxResName ) )
+ {
+ xManager->hideElement( m_sToolboxResName );
+ xManager->destroyElement( m_sToolboxResName );
+ }
+ else
+ {
+ xManager->createElement( m_sToolboxResName );
+ xManager->showElement( m_sToolboxResName );
+ ::com::sun::star::awt::Point aPos;
+
+ if ( m_bDocking )
+ xManager->dockWindow( m_sToolboxResName,
+ ::com::sun::star::ui::DockingArea_DOCKINGAREA_BOTTOM, aPos );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ToolboxAccess::toggleToolbox: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ToolboxAccess::isToolboxVisible() const
+ {
+ return ( m_xLayouter.is() && m_xLayouter->isElementVisible( m_sToolboxResName ) );
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx
new file mode 100644
index 000000000000..80d1b46ed658
--- /dev/null
+++ b/svx/source/tbxctrls/tbxcolorupdate.cxx
@@ -0,0 +1,211 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/tbxcolorupdate.hxx>
+#include <svx/svxids.hrc>
+
+#include <vcl/toolbox.hxx>
+#include <vcl/bmpacc.hxx>
+#include <tools/debug.hxx>
+
+#define IMAGE_COL_TRANSPARENT COL_LIGHTMAGENTA
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ //====================================================================
+ //= ToolboxButtonColorUpdater
+ //====================================================================
+
+ ToolboxButtonColorUpdater::ToolboxButtonColorUpdater(
+ USHORT nId,
+ USHORT nTbxBtnId,
+ ToolBox* ptrTbx,
+ USHORT nMode ) :
+ mnDrawMode ( nMode ),
+ mnBtnId ( nTbxBtnId ),
+ mnSlotId ( nId ),
+ mpTbx ( ptrTbx ),
+ maCurColor ( COL_TRANSPARENT )
+ {
+ if (mnSlotId == SID_BACKGROUND_COLOR)
+ mnDrawMode = TBX_UPDATER_MODE_CHAR_COLOR_NEW;
+ DBG_ASSERT( ptrTbx, "ToolBox not found :-(" );
+ mbWasHiContrastMode = ptrTbx ? ( ptrTbx->GetSettings().GetStyleSettings().GetHighContrastMode() ) : FALSE;
+ Update(mnSlotId == SID_ATTR_CHAR_COLOR2 ? COL_BLACK : COL_GRAY);
+ }
+
+ // -----------------------------------------------------------------------
+
+ ToolboxButtonColorUpdater::~ToolboxButtonColorUpdater()
+ {
+ }
+
+ // -----------------------------------------------------------------------
+
+ void ToolboxButtonColorUpdater::Update( const Color& rColor )
+ {
+ Image aImage( mpTbx->GetItemImage( mnBtnId ) );
+ const bool bSizeChanged = ( maBmpSize != aImage.GetSizePixel() );
+ const bool bDisplayModeChanged = ( mbWasHiContrastMode != mpTbx->GetSettings().GetStyleSettings().GetHighContrastMode() );
+ Color aColor( rColor );
+
+ // !!! #109290# Workaround for SetFillColor with COL_AUTO
+ if( aColor.GetColor() == COL_AUTO )
+ aColor = Color( COL_TRANSPARENT );
+
+ if( ( maCurColor != aColor ) || bSizeChanged || bDisplayModeChanged )
+ {
+ BitmapEx aBmpEx( aImage.GetBitmapEx() );
+ Bitmap aBmp( aBmpEx.GetBitmap() );
+ BitmapWriteAccess* pBmpAcc = aBmp.AcquireWriteAccess();
+
+ maBmpSize = aBmp.GetSizePixel();
+
+ if( pBmpAcc )
+ {
+ Bitmap aMsk;
+ BitmapWriteAccess* pMskAcc;
+ const Point aNullPnt;
+
+ if( aBmpEx.IsAlpha() )
+ pMskAcc = ( aMsk = aBmpEx.GetAlpha().GetBitmap() ).AcquireWriteAccess();
+ else if( aBmpEx.IsTransparent() )
+ pMskAcc = ( aMsk = aBmpEx.GetMask() ).AcquireWriteAccess();
+ else
+ pMskAcc = NULL;
+
+ mbWasHiContrastMode = mpTbx->GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ if( mnDrawMode == TBX_UPDATER_MODE_CHAR_COLOR_NEW && ( COL_TRANSPARENT != aColor.GetColor() ) )
+ pBmpAcc->SetLineColor( aColor );
+ else if( mpTbx->GetBackground().GetColor().IsDark() )
+ pBmpAcc->SetLineColor( Color( COL_WHITE ) );
+ else
+ pBmpAcc->SetLineColor( Color( COL_BLACK ) );
+
+ pBmpAcc->SetFillColor( maCurColor = aColor );
+
+ if( TBX_UPDATER_MODE_CHAR_COLOR_NEW == mnDrawMode || TBX_UPDATER_MODE_NONE == mnDrawMode )
+ {
+ if( TBX_UPDATER_MODE_CHAR_COLOR_NEW == mnDrawMode )
+ {
+ if( maBmpSize.Width() <= 16 )
+ maUpdRect = Rectangle( Point( 0,12 ), Size( maBmpSize.Width(), 4 ) );
+ else
+ maUpdRect = Rectangle( Point( 1, maBmpSize.Height() - 7 ), Size( maBmpSize.Width() - 2 ,6 ) );
+ }
+ else
+ {
+ if( maBmpSize.Width() <= 16 )
+ maUpdRect = Rectangle( Point( 7, 7 ), Size( 8, 8 ) );
+ else
+ maUpdRect = Rectangle( Point( maBmpSize.Width() - 12, maBmpSize.Height() - 12 ), Size( 11, 11 ) );
+ }
+
+ pBmpAcc->DrawRect( maUpdRect );
+
+ if( pMskAcc )
+ {
+ if( COL_TRANSPARENT == aColor.GetColor() )
+ {
+ pMskAcc->SetLineColor( COL_BLACK );
+ pMskAcc->SetFillColor( COL_WHITE );
+ }
+ else
+ pMskAcc->SetFillColor( COL_BLACK );
+
+ pMskAcc->DrawRect( maUpdRect );
+ }
+ }
+ else
+ {
+ DBG_ERROR( "ToolboxButtonColorUpdater::Update: TBX_UPDATER_MODE_CHAR_COLOR / TBX_UPDATER_MODE_CHAR_BACKGROUND" );
+ // !!! DrawChar( aVirDev, aColor );
+ }
+
+ aBmp.ReleaseAccess( pBmpAcc );
+
+ if( pMskAcc )
+ aMsk.ReleaseAccess( pMskAcc );
+
+ if( aBmpEx.IsAlpha() )
+ aBmpEx = BitmapEx( aBmp, AlphaMask( aMsk ) );
+ else if( aBmpEx.IsTransparent() )
+ aBmpEx = BitmapEx( aBmp, aMsk );
+ else
+ aBmpEx = aBmp;
+
+ mpTbx->SetItemImage( mnBtnId, Image( aBmpEx ) );
+ }
+ }
+ }
+
+ // -----------------------------------------------------------------------
+
+ void ToolboxButtonColorUpdater::DrawChar( VirtualDevice& rVirDev, const Color& rCol )
+ {
+ Font aOldFont = rVirDev.GetFont();
+ Font aFont = aOldFont;
+ Size aSz = aFont.GetSize();
+ aSz.Height() = maBmpSize.Height();
+ aFont.SetSize( aSz );
+ aFont.SetWeight( WEIGHT_BOLD );
+
+ if ( mnDrawMode == TBX_UPDATER_MODE_CHAR_COLOR )
+ {
+ aFont.SetColor( rCol );
+ aFont.SetFillColor( Color( IMAGE_COL_TRANSPARENT ) );
+ }
+ else
+ {
+ rVirDev.SetLineColor();
+ rVirDev.SetFillColor( rCol );
+ Rectangle aRect( Point(0,0), maBmpSize );
+ rVirDev.DrawRect( aRect );
+ aFont.SetFillColor( rCol );
+ }
+ rVirDev.SetFont( aFont );
+ Size aTxtSize(rVirDev.GetTextWidth( 'A' ), rVirDev.GetTextHeight());
+ Point aPos( ( maBmpSize.Width() - aTxtSize.Width() ) / 2,
+ ( maBmpSize.Height() - aTxtSize.Height() ) / 2 );
+
+ rVirDev.DrawText( aPos, 'A' );
+ rVirDev.SetFont( aOldFont );
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/tbxdraw.hrc b/svx/source/tbxctrls/tbxdraw.hrc
new file mode 100644
index 000000000000..3dd9eafd913c
--- /dev/null
+++ b/svx/source/tbxctrls/tbxdraw.hrc
@@ -0,0 +1,31 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+#include <svx/dialogs.hrc>
+#include <svx/svxids.hrc>
+
+#define TBX_DRAW 1
+#define TBX_ALIGNMENT SID_OBJECT_ALIGN_LEFT
diff --git a/svx/source/tbxctrls/tbxdraw.src b/svx/source/tbxctrls/tbxdraw.src
new file mode 100644
index 000000000000..e4c7c1d29632
--- /dev/null
+++ b/svx/source/tbxctrls/tbxdraw.src
@@ -0,0 +1,265 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include "tbxdraw.hrc"
+#include <svx/dialogs.hrc>
+#include "helpid.hrc"
+#include <svx/svxids.hrc>
+ // pragma ----------------------------------------------------------------
+
+ // -----------------------------------------------------------------------
+#define IMAGE_STDBTN_COLOR Color { Red = 0xC000; Green = 0xC000; Blue = 0xC000; }
+FloatingWindow RID_SVXTBX_DRAW
+{
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ HelpID = HID_DRAWTOOL_TBX ;
+ ToolBox TBX_DRAW
+ {
+ HelpId = HID_SVXTBX_DRAW ;
+ SVLook = TRUE ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_SELECT ;
+ HelpID = SID_OBJECT_SELECT ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Selection" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_LINE ;
+ HelpID = SID_DRAW_LINE ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Line" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_RECT ;
+ HelpID = SID_DRAW_RECT ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Rectangle" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_ELLIPSE ;
+ HelpID = SID_DRAW_ELLIPSE ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Ellipse" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_POLYGON_NOFILL ;
+ HelpID = SID_DRAW_POLYGON_NOFILL ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Polygon" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_BEZIER_NOFILL ;
+ HelpID = SID_DRAW_BEZIER_NOFILL ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Curve";
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_FREELINE_NOFILL ;
+ HelpID = SID_DRAW_FREELINE_NOFILL ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Freeform Line";
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_ARC ;
+ HelpID = SID_DRAW_ARC ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Arc" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_PIE ;
+ HelpID = SID_DRAW_PIE ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Ellipse Pie" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_CIRCLECUT ;
+ HelpID = SID_DRAW_CIRCLECUT ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Circle Segment" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_TEXT ;
+ HelpID = SID_DRAW_TEXT ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Text" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_TEXT_VERTICAL ;
+ HelpID = SID_DRAW_TEXT_VERTICAL ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Vertical Text";
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_TEXT_MARQUEE ;
+ HelpID = SID_DRAW_TEXT_MARQUEE ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Text Animation" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_CAPTION ;
+ HelpID = SID_DRAW_CAPTION ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Callouts" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_DRAW_CAPTION_VERTICAL ;
+ HelpID = SID_DRAW_CAPTION_VERTICAL ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Vertical Callout";
+ };
+ };
+ };
+ Text [ en-US ] = "Draw Functions" ;
+};
+FloatingWindow RID_SVXTBX_ALIGNMENT
+{
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE ;
+ HelpID = HID_ALIGN_TBX ;
+ SVLook = TRUE ;
+ Text [ en-US ] = "Alignment" ;
+ ToolBox TBX_ALIGNMENT
+ {
+ HelpId = HID_SVXTBX_ALIGNMENT ;
+ SVLook = TRUE ;
+ HelpID = SID_OBJECT_ALIGN ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_ALIGN_LEFT ;
+ HelpID = SID_OBJECT_ALIGN_LEFT ;
+ Text [ en-US ] = "Left" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_ALIGN_CENTER ;
+ HelpID = SID_OBJECT_ALIGN_CENTER ;
+ Text [ en-US ] = "Center" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_ALIGN_RIGHT ;
+ HelpID = SID_OBJECT_ALIGN_RIGHT ;
+ Text [ en-US ] = "Right" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_ALIGN_UP ;
+ HelpID = SID_OBJECT_ALIGN_UP ;
+ Text [ en-US ] = "Top" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_ALIGN_MIDDLE ;
+ HelpID = SID_OBJECT_ALIGN_MIDDLE ;
+ Text [ en-US ] = "Centered" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_ALIGN_DOWN ;
+ HelpID = SID_OBJECT_ALIGN_DOWN ;
+ Text [ en-US ] = "Bottom" ;
+ };
+ };
+ };
+};
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svx/source/tbxctrls/tbxdrctl.cxx b/svx/source/tbxctrls/tbxdrctl.cxx
new file mode 100644
index 000000000000..87533e56b967
--- /dev/null
+++ b/svx/source/tbxctrls/tbxdrctl.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+
+#include <tools/ref.hxx>
+#include <tools/shl.hxx>
+#include <svl/aeitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/toolbox.hxx>
+
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+
+#include "tbxctl.hxx"
+#include "tbxdraw.hxx"
+#include "tbxcolor.hxx"
+#include "tbxdraw.hrc"
+#include <com/sun/star/frame/XLayoutManager.hpp>
+
+SFX_IMPL_TOOLBOX_CONTROL(SvxTbxCtlDraw, SfxAllEnumItem);
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+
+// -----------------------------------------------------------------------
+
+SvxTbxCtlDraw::SvxTbxCtlDraw( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+
+ m_sToolboxName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/drawbar" ) )
+
+{
+ rTbx.SetItemBits( nId, TIB_CHECKABLE | rTbx.GetItemBits( nId ) );
+ rTbx.Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void SvxTbxCtlDraw::StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ GetToolBox().EnableItem( GetId(), ( eState != SFX_ITEM_DISABLED ) );
+ SfxToolBoxControl::StateChanged( nSID, eState, pState );
+
+ Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
+ if ( xLayoutMgr.is() )
+ GetToolBox().CheckItem(
+ GetId(), xLayoutMgr->isElementVisible( m_sToolboxName ) != sal_False );
+}
+
+// -----------------------------------------------------------------------
+
+SfxPopupWindowType SvxTbxCtlDraw::GetPopupWindowType() const
+{
+ return SFX_POPUPWINDOW_ONCLICK;
+}
+
+// -----------------------------------------------------------------------
+
+void SvxTbxCtlDraw::toggleToolbox()
+{
+ Reference< XLayoutManager > xLayoutMgr = getLayoutManager();
+ if ( xLayoutMgr.is() )
+ {
+ BOOL bCheck = FALSE;
+ if ( xLayoutMgr->isElementVisible( m_sToolboxName ) )
+ {
+ xLayoutMgr->hideElement( m_sToolboxName );
+ xLayoutMgr->destroyElement( m_sToolboxName );
+ }
+ else
+ {
+ bCheck = TRUE;
+ xLayoutMgr->createElement( m_sToolboxName );
+ xLayoutMgr->showElement( m_sToolboxName );
+ }
+
+ GetToolBox().CheckItem( GetId(), bCheck );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvxTbxCtlDraw::Select( BOOL )
+{
+ toggleToolbox();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/tbxctrls/verttexttbxctrl.cxx b/svx/source/tbxctrls/verttexttbxctrl.cxx
new file mode 100644
index 000000000000..88a03f53e651
--- /dev/null
+++ b/svx/source/tbxctrls/verttexttbxctrl.cxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include <verttexttbxctrl.hxx>
+#include <svl/languageoptions.hxx>
+#include <sfx2/app.hxx>
+#include <svl/eitem.hxx>
+#include <vcl/toolbox.hxx>
+#include <rtl/ustring.hxx>
+
+SFX_IMPL_TOOLBOX_CONTROL(SvxCTLTextTbxCtrl, SfxBoolItem);
+SFX_IMPL_TOOLBOX_CONTROL(SvxVertTextTbxCtrl, SfxBoolItem);
+
+// -----------------------------27.04.01 15:50--------------------------------
+
+SvxCTLTextTbxCtrl::SvxCTLTextTbxCtrl(USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx )
+{
+ SetVert(FALSE);
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CTLFontState" )));
+}
+
+SvxVertTextTbxCtrl::SvxVertTextTbxCtrl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SvxVertCTLTextTbxCtrl( nSlotId, nId, rTbx )
+{
+ SetVert(TRUE);
+ addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:VerticalTextState" )));
+}
+
+/* ---------------------------------------------------------------------------*/
+SvxVertCTLTextTbxCtrl::SvxVertCTLTextTbxCtrl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ bCheckVertical(sal_True)
+{
+}
+
+/* -----------------------------27.04.01 15:53--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SvxVertCTLTextTbxCtrl::~SvxVertCTLTextTbxCtrl( )
+{
+}
+/* -----------------------------27.04.01 15:50--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SvxVertCTLTextTbxCtrl::StateChanged(
+ USHORT nSID,
+ SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ SvtLanguageOptions aLangOptions;
+ BOOL bCalc = sal_False;
+ BOOL bVisible = GetToolBox().IsItemVisible(GetId());
+ sal_Bool bEnabled = sal_False;
+ if ( nSID == SID_VERTICALTEXT_STATE )
+ bEnabled = aLangOptions.IsVerticalTextEnabled();
+ else if ( nSID == SID_CTLFONT_STATE )
+ bEnabled = aLangOptions.IsCTLFontEnabled();
+ else
+ {
+ SfxToolBoxControl::StateChanged(nSID, eState, pState);
+ return;
+ }
+
+ if(bEnabled)
+ {
+ if(!bVisible)
+ {
+ GetToolBox().ShowItem( GetId(), TRUE );
+ bCalc = sal_True;
+ }
+ }
+ else if(bVisible)
+ {
+ GetToolBox().HideItem( GetId() );
+ bCalc = sal_True;
+ }
+ if(bCalc)
+ {
+ ToolBox& rTbx = GetToolBox();
+ Window* pParent = rTbx.GetParent();
+ WindowType nWinType = pParent->GetType();
+ if(WINDOW_FLOATINGWINDOW == nWinType)
+ {
+ Size aSize(rTbx.CalcWindowSizePixel());
+ rTbx.SetPosSizePixel( Point(), aSize );
+ pParent->SetOutputSizePixel( aSize );
+ }
+ }
+}
+/* -----------------------------27.04.01 15:50--------------------------------
+
+ ---------------------------------------------------------------------------*/
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/toolbars/extrusionbar.cxx b/svx/source/toolbars/extrusionbar.cxx
new file mode 100644
index 000000000000..63e52191a08e
--- /dev/null
+++ b/svx/source/toolbars/extrusionbar.cxx
@@ -0,0 +1,1373 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
+#include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
+#include <com/sun/star/drawing/ShadeMode.hpp>
+#include <com/sun/star/drawing/Position3D.hpp>
+#include <com/sun/star/drawing/Direction3D.hpp>
+#include <com/sun/star/drawing/ProjectionMode.hpp>
+#include <svx/svdundo.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/bindings.hxx>
+#include <svx/xsflclit.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/svdoashp.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/svdview.hxx>
+#include <editeng/colritem.hxx>
+#include "chrtitem.hxx"
+
+#include <svx/extrusionbar.hxx>
+#include "extrusiondepthdialog.hxx"
+
+
+using namespace ::svx;
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::uno;
+
+/*************************************************************************
+|*
+|* Standardinterface deklarieren (Die Slotmap darf nicht leer sein, also
+|* tragen wir etwas ein, was hier (hoffentlich) nie vorkommt).
+|*
+\************************************************************************/
+
+#define ShellClass ExtrusionBar
+
+SFX_SLOTMAP(ExtrusionBar)
+{
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+};
+
+SFX_IMPL_INTERFACE(ExtrusionBar, SfxShell, SVX_RES(RID_SVX_EXTRUSION_BAR))
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT, SVX_RES(RID_SVX_EXTRUSION_BAR) );
+}
+
+TYPEINIT1( ExtrusionBar, SfxShell );
+
+
+/*************************************************************************
+|*
+|* Standard-Konstruktor
+|*
+\************************************************************************/
+
+ExtrusionBar::ExtrusionBar(SfxViewShell* pViewShell )
+: SfxShell(pViewShell)
+{
+ DBG_ASSERT( pViewShell, "svx::ExtrusionBar::ExtrusionBar(), I need a viewshell!" );
+ if( pViewShell )
+ SetPool(&pViewShell->GetPool());
+
+ SetHelpId( SVX_INTERFACE_EXTRUSION_BAR );
+ SetName( String( SVX_RES( RID_SVX_EXTRUSION_BAR )));
+}
+
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+ExtrusionBar::~ExtrusionBar()
+{
+ SetRepeatTarget(NULL);
+}
+
+void getLightingDirectionDefaults( const Direction3D **pLighting1Defaults, const Direction3D **pLighting2Defaults )
+{
+
+ static const Direction3D aLighting1Defaults[9] =
+ {
+ Direction3D( -50000, -50000, 10000 ),
+ Direction3D( 0, -50000, 10000 ),
+ Direction3D( 50000, -50000, 10000 ),
+ Direction3D( -50000, 0, 10000 ),
+ Direction3D( 0, 0, 10000 ),
+ Direction3D( 50000, 0, 10000 ),
+ Direction3D( -50000, 50000, 10000 ),
+ Direction3D( 0, 50000, 10000 ),
+ Direction3D( 50000, 50000, 10000 )
+ };
+
+ static const Direction3D aLighting2Defaults[9] =
+ {
+ Direction3D( 50000,0, 10000 ),
+ Direction3D( 0, 50000, 10000 ),
+ Direction3D( -50000, 0, 10000 ),
+ Direction3D( 50000, 0, 10000 ),
+ Direction3D( 0, 0, 10000 ),
+ Direction3D( -50000, 0, 10000 ),
+ Direction3D( 50000, 0, 10000 ),
+ Direction3D( 0, -50000, 10000 ),
+ Direction3D( -50000, 0, 10000 )
+ };
+
+ *pLighting1Defaults = (const Direction3D *)aLighting1Defaults;
+ *pLighting2Defaults = (const Direction3D *)aLighting2Defaults;
+};
+
+static void impl_execute( SdrView*, SfxRequest& rReq, SdrCustomShapeGeometryItem& rGeometryItem, SdrObject* pObj )
+{
+ static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
+ static const rtl::OUString sProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
+ static const rtl::OUString sRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "RotateAngle" ) );
+ static const rtl::OUString sViewPoint( RTL_CONSTASCII_USTRINGPARAM ( "ViewPoint" ) );
+ static const rtl::OUString sOrigin( RTL_CONSTASCII_USTRINGPARAM ( "Origin" ) );
+ static const rtl::OUString sSkew( RTL_CONSTASCII_USTRINGPARAM ( "Skew" ) );
+ static const rtl::OUString sDepth( RTL_CONSTASCII_USTRINGPARAM ( "Depth" ) );
+
+ sal_uInt16 nSID = rReq.GetSlot();
+ switch( nSID )
+ {
+ case SID_EXTRUSION_TOOGLE:
+ {
+ com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
+
+ if( pAny )
+ {
+ sal_Bool bOn;
+ (*pAny) >>= bOn;
+ bOn = !bOn;
+ (*pAny) <<= bOn;
+ }
+ else
+ {
+ com::sun::star::beans::PropertyValue aPropValue;
+ aPropValue.Name = sExtrusion;
+ aPropValue.Value <<= sal_True;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+ }
+ }
+ break;
+
+ case SID_EXTRUSION_TILT_DOWN:
+ case SID_EXTRUSION_TILT_UP:
+ case SID_EXTRUSION_TILT_LEFT:
+ case SID_EXTRUSION_TILT_RIGHT:
+ {
+ sal_Bool bHorizontal = ( nSID == SID_EXTRUSION_TILT_DOWN ) || ( nSID == SID_EXTRUSION_TILT_UP );
+ sal_Int32 nDiff = ( nSID == SID_EXTRUSION_TILT_LEFT ) || ( nSID == SID_EXTRUSION_TILT_UP ) ? 5 : -5;
+ EnhancedCustomShapeParameterPair aRotateAnglePropPair;
+ double fX = 0.0;
+ double fY = 0.0;
+ aRotateAnglePropPair.First.Value <<= fX;
+ aRotateAnglePropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
+ aRotateAnglePropPair.Second.Value <<= fY;
+ aRotateAnglePropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
+ com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sExtrusion, sRotateAngle );
+ if( pAny && ( *pAny >>= aRotateAnglePropPair ) )
+ {
+ aRotateAnglePropPair.First.Value >>= fX;
+ aRotateAnglePropPair.Second.Value >>= fY;
+ }
+ if ( bHorizontal )
+ fX += nDiff;
+ else
+ fY += nDiff;
+ aRotateAnglePropPair.First.Value <<= fX;
+ aRotateAnglePropPair.Second.Value <<= fY;
+ com::sun::star::beans::PropertyValue aPropValue;
+ aPropValue.Name = sRotateAngle;
+ aPropValue.Value <<= aRotateAnglePropPair;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+ }
+ break;
+
+ case SID_EXTRUSION_DIRECTION:
+ {
+ if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_DIRECTION ) == SFX_ITEM_SET )
+ {
+ sal_Int32 nSkew = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_EXTRUSION_DIRECTION))->GetValue();
+
+ Position3D aViewPoint( 3472, -3472, 25000 );
+ double fOriginX = 0.50;
+ double fOriginY = -0.50;
+ double fSkewAngle = nSkew;
+ double fSkew = 50.0;
+
+ switch( nSkew )
+ {
+ case 135:
+ aViewPoint.PositionY = 3472;
+ fOriginY = 0.50;
+ break;
+ case 90:
+ aViewPoint.PositionX = 0;
+ aViewPoint.PositionY = 3472;
+ fOriginX = 0;
+ fOriginY = -0.50;
+ break;
+ case 45:
+ aViewPoint.PositionX = -3472;
+ aViewPoint.PositionY = 3472;
+ fOriginX = -0.50;
+ fOriginY = 0.50;
+ break;
+ case 180:
+ aViewPoint.PositionY = 0;
+ fOriginY = 0;
+ break;
+ case 0:
+ aViewPoint.PositionX = 0;
+ aViewPoint.PositionY = 0;
+ fOriginX = 0;
+ fOriginY = 0;
+ fSkew = 0.0;
+ break;
+ case -360:
+ aViewPoint.PositionX = -3472;
+ aViewPoint.PositionY = 0;
+ fOriginX = -0.50;
+ fOriginY = 0;
+ break;
+ case -90:
+ aViewPoint.PositionX = 0;
+ fOriginX = 0;
+ break;
+ case -45:
+ aViewPoint.PositionX = -3472;
+ fOriginX = -0.50;
+ break;
+ }
+
+ com::sun::star::beans::PropertyValue aPropValue;
+
+ aPropValue.Name = sViewPoint;
+ aPropValue.Value <<= aViewPoint;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+
+ EnhancedCustomShapeParameterPair aOriginPropPair;
+ aOriginPropPair.First.Value <<= fOriginX;
+ aOriginPropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
+ aOriginPropPair.Second.Value <<= fOriginY;
+ aOriginPropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
+ aPropValue.Name = sOrigin;
+ aPropValue.Value <<= aOriginPropPair;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ EnhancedCustomShapeParameterPair aSkewPropPair;
+ aSkewPropPair.First.Value <<= fSkew;
+ aSkewPropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
+ aSkewPropPair.Second.Value <<= fSkewAngle;
+ aSkewPropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
+ aPropValue.Name = sSkew;
+ aPropValue.Value <<= aSkewPropPair;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+ }
+ }
+ break;
+ case SID_EXTRUSION_PROJECTION:
+ {
+ if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_PROJECTION ) == SFX_ITEM_SET )
+ {
+ sal_Int32 nProjection = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_EXTRUSION_PROJECTION))->GetValue();
+ ProjectionMode eProjectionMode = nProjection == 1 ? ProjectionMode_PARALLEL : ProjectionMode_PERSPECTIVE;
+ com::sun::star::beans::PropertyValue aPropValue;
+ aPropValue.Name = sProjectionMode;
+ aPropValue.Value <<= eProjectionMode;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+ }
+ }
+ break;
+ case SID_EXTRUSION_DEPTH:
+ {
+ if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_DEPTH ) == SFX_ITEM_SET)
+ {
+ double fDepth = ((const SvxDoubleItem*)rReq.GetArgs()->GetItem(SID_EXTRUSION_DEPTH))->GetValue();
+ double fFraction = 0.0;
+ EnhancedCustomShapeParameterPair aDepthPropPair;
+ aDepthPropPair.First.Value <<= fDepth;
+ aDepthPropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
+ aDepthPropPair.Second.Value <<= fFraction;
+ aDepthPropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
+
+ com::sun::star::beans::PropertyValue aPropValue;
+ aPropValue.Name = sDepth;
+ aPropValue.Value <<= aDepthPropPair;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+ }
+ }
+ break;
+ case SID_EXTRUSION_3D_COLOR:
+ {
+ static const rtl::OUString sExtrusionColor( RTL_CONSTASCII_USTRINGPARAM ( "Color" ) );
+
+ if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_3D_COLOR ) == SFX_ITEM_SET)
+ {
+ Color aColor( ((const SvxColorItem&)rReq.GetArgs()->Get(SID_EXTRUSION_3D_COLOR)).GetValue() );
+
+ const bool bAuto = aColor == COL_AUTO;
+
+ com::sun::star::beans::PropertyValue aPropValue;
+ aPropValue.Name = sExtrusionColor;
+ aPropValue.Value <<= bAuto ? sal_False : sal_True;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ if( bAuto )
+ {
+ pObj->ClearMergedItem( XATTR_SECONDARYFILLCOLOR );
+ }
+ else
+ {
+ pObj->SetMergedItem( XSecondaryFillColorItem( String(), aColor ) );
+ }
+ pObj->BroadcastObjectChange();
+ }
+ }
+ break;
+ case SID_EXTRUSION_SURFACE:
+ {
+ static const rtl::OUString sShadeMode( RTL_CONSTASCII_USTRINGPARAM ( "ShadeMode" ) );
+ static const rtl::OUString sSpecularity( RTL_CONSTASCII_USTRINGPARAM ( "Specularity" ) );
+ static const rtl::OUString sDiffusion( RTL_CONSTASCII_USTRINGPARAM ( "Diffusion" ) );
+ static const rtl::OUString sMetal( RTL_CONSTASCII_USTRINGPARAM ( "Metal" ) );
+
+ if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_SURFACE ) == SFX_ITEM_SET)
+ {
+ sal_Int32 nSurface = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_EXTRUSION_SURFACE))->GetValue();
+
+ ShadeMode eShadeMode( ShadeMode_FLAT );
+ sal_Bool bMetal = sal_False;
+ double fSpecularity = 0;
+ double fDiffusion = 0;
+
+ switch( nSurface )
+ {
+ case 0: // wireframe
+ eShadeMode = ShadeMode_DRAFT;
+ break;
+ case 1: // matte
+ break;
+ case 2: // plastic
+ fSpecularity = 122.0;
+ break;
+ case 3: // metal
+ bMetal = true;
+ fSpecularity = 122.0;
+ fDiffusion = 122.0;
+ break;
+ }
+
+ com::sun::star::beans::PropertyValue aPropValue;
+ aPropValue.Name = sShadeMode;
+ aPropValue.Value <<= eShadeMode;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ aPropValue.Name = sMetal;
+ aPropValue.Value <<= bMetal;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ aPropValue.Name = sSpecularity;
+ aPropValue.Value <<= fSpecularity;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ aPropValue.Name = sDiffusion;
+ aPropValue.Value <<= fDiffusion;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+ }
+ }
+ break;
+ case SID_EXTRUSION_LIGHTING_INTENSITY:
+ {
+ static const rtl::OUString sBrightness( RTL_CONSTASCII_USTRINGPARAM ( "Brightness" ) );
+ static const rtl::OUString sLightFace( RTL_CONSTASCII_USTRINGPARAM ( "LightFace" ) );
+ static const rtl::OUString sFirstLightHarsh( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightHarsh" ) );
+ static const rtl::OUString sSecondLightHarsh( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightHarsh" ) );
+ static const rtl::OUString sFirstLightLevel( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightLevel" ) );
+ static const rtl::OUString sSecondLightLevel( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightLevel" ) );
+
+ if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_LIGHTING_INTENSITY ) == SFX_ITEM_SET)
+ {
+ sal_Int32 nLevel = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_EXTRUSION_LIGHTING_INTENSITY))->GetValue();
+
+ double fBrightness;
+ sal_Bool bHarsh2;
+ double fLevel1;
+ double fLevel2;
+
+ switch( nLevel )
+ {
+ case 0: // bright
+ fBrightness = 34.0;
+ bHarsh2 = sal_False;
+ fLevel1 = 66.0;
+ fLevel2 = 66.0;
+ break;
+ case 1: // normal
+ fBrightness = 15.0;
+ bHarsh2 = sal_False;
+ fLevel1 = 67.0;
+ fLevel2 = 37.0;
+ break;
+ case 2: // dim
+ fBrightness = 6.0;
+ bHarsh2 = sal_True;
+ fLevel1 = 79.0;
+ fLevel2 = 21.0;
+ break;
+ }
+
+ com::sun::star::beans::PropertyValue aPropValue;
+ aPropValue.Name = sBrightness;
+ aPropValue.Value <<= fBrightness;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ aPropValue.Name = sLightFace;
+ aPropValue.Value <<= sal_True;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ aPropValue.Name = sFirstLightHarsh;
+ aPropValue.Value <<= sal_True;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ aPropValue.Name = sSecondLightHarsh;
+ aPropValue.Value <<= bHarsh2;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ aPropValue.Name = sFirstLightLevel;
+ aPropValue.Value <<= fLevel1;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ aPropValue.Name = sSecondLightLevel;
+ aPropValue.Value <<= fLevel2;
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+ }
+ }
+ break;
+ case SID_EXTRUSION_LIGHTING_DIRECTION:
+ {
+ if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_LIGHTING_DIRECTION ) == SFX_ITEM_SET)
+ {
+ sal_Int32 nDirection = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_EXTRUSION_LIGHTING_DIRECTION))->GetValue();
+
+ if((nDirection >= 0) && (nDirection < 9))
+ {
+ const rtl::OUString sFirstLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightDirection" ) );
+ const rtl::OUString sSecondLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightDirection" ) );
+
+ const Direction3D * pLighting1Defaults;
+ const Direction3D * pLighting2Defaults;
+
+ getLightingDirectionDefaults( &pLighting1Defaults, &pLighting2Defaults );
+
+ com::sun::star::beans::PropertyValue aPropValue;
+ aPropValue.Name = sFirstLightDirection;
+ aPropValue.Value <<= pLighting1Defaults[nDirection];
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+
+ aPropValue.Name = sSecondLightDirection;
+ aPropValue.Value <<= pLighting2Defaults[nDirection];
+ rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
+ }
+ }
+ }
+ break;
+
+ }
+}
+
+void ExtrusionBar::execute( SdrView* pSdrView, SfxRequest& rReq, SfxBindings& rBindings )
+{
+ sal_uInt16 nSID = rReq.GetSlot();
+ sal_uInt16 nStrResId = 0;
+
+ const bool bUndo = pSdrView && pSdrView->IsUndoEnabled();
+
+ switch( nSID )
+ {
+ case SID_EXTRUSION_TOOGLE:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ON_OFF;
+ } // PASSTROUGH
+ case SID_EXTRUSION_TILT_DOWN:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_DOWN;
+ } // PASSTROUGH
+ case SID_EXTRUSION_TILT_UP:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_UP;
+ } // PASSTROUGH
+ case SID_EXTRUSION_TILT_LEFT:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_LEFT;
+ } // PASSTROUGH
+ case SID_EXTRUSION_TILT_RIGHT:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_RIGHT;
+ } // PASSTROUGH
+ case SID_EXTRUSION_DIRECTION:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ORIENTATION;
+ } // PASSTROUGH
+ case SID_EXTRUSION_PROJECTION:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_PROJECTION;
+ } // PASSTROUGH
+ case SID_EXTRUSION_DEPTH:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_DEPTH;
+ } // PASSTROUGH
+ case SID_EXTRUSION_3D_COLOR:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_COLOR;
+ } // PASSTROUGH
+ case SID_EXTRUSION_SURFACE:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_SURFACE;
+ } // PASSTROUGH
+ case SID_EXTRUSION_LIGHTING_INTENSITY:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_BRIGHTNESS;
+ } // PASSTROUGH
+ case SID_EXTRUSION_LIGHTING_DIRECTION:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_LIGHTING;
+
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ for(i=0; i<nCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ if( bUndo )
+ {
+ String aStr( SVX_RES( nStrResId ) );
+ pSdrView->BegUndo( aStr );
+ pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
+ }
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ impl_execute( pSdrView, rReq, aGeometryItem, pObj );
+ pObj->SetMergedItem( aGeometryItem );
+ pObj->BroadcastObjectChange();
+ if( bUndo )
+ pSdrView->EndUndo();
+
+ // simulate a context change:
+ // force SelectionHasChanged() being called
+ // so that extrusion bar will be visible/hidden
+ pSdrView->MarkListHasChanged();
+ }
+ }
+ }
+ break;
+
+ case SID_EXTRUSION_DEPTH_DIALOG:
+ if( rReq.GetArgs() &&
+ (rReq.GetArgs()->GetItemState( SID_EXTRUSION_DEPTH ) == SFX_ITEM_SET) &&
+ (rReq.GetArgs()->GetItemState( SID_ATTR_METRIC ) == SFX_ITEM_SET))
+ {
+ double fDepth = ((const SvxDoubleItem*)rReq.GetArgs()->GetItem(SID_EXTRUSION_DEPTH))->GetValue();
+ FieldUnit eUnit = (FieldUnit)((const SfxUInt16Item*)rReq.GetArgs()->GetItem(SID_ATTR_METRIC))->GetValue();
+
+ ExtrusionDepthDialog aDlg( 0L, fDepth, eUnit );
+ USHORT nRet = aDlg.Execute();
+ if( nRet != 0 )
+ {
+ fDepth = aDlg.getDepth();
+
+ SvxDoubleItem aItem( fDepth, SID_EXTRUSION_DEPTH );
+ SfxPoolItem* aItems[] = { &aItem, 0 };
+ rBindings.Execute( SID_EXTRUSION_DEPTH, (const SfxPoolItem**)aItems );
+ }
+ }
+ break;
+ }
+
+ if( nSID == SID_EXTRUSION_TOOGLE )
+ {
+ static USHORT SidArray[] = {
+ SID_EXTRUSION_TILT_DOWN,
+ SID_EXTRUSION_TILT_UP,
+ SID_EXTRUSION_TILT_LEFT,
+ SID_EXTRUSION_TILT_RIGHT,
+ SID_EXTRUSION_DEPTH_FLOATER,
+ SID_EXTRUSION_DIRECTION_FLOATER,
+ SID_EXTRUSION_LIGHTING_FLOATER,
+ SID_EXTRUSION_SURFACE_FLOATER,
+ SID_EXTRUSION_3D_COLOR,
+ SID_EXTRUSION_DEPTH,
+ SID_EXTRUSION_DIRECTION,
+ SID_EXTRUSION_PROJECTION,
+ SID_EXTRUSION_LIGHTING_DIRECTION,
+ SID_EXTRUSION_LIGHTING_INTENSITY,
+ SID_EXTRUSION_SURFACE,
+ 0 };
+
+ rBindings.Invalidate( SidArray );
+ }
+}
+
+void getExtrusionDirectionState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
+ static const rtl::OUString sViewPoint( RTL_CONSTASCII_USTRINGPARAM ( "ViewPoint" ) );
+ static const rtl::OUString sOrigin( RTL_CONSTASCII_USTRINGPARAM ( "Origin" ) );
+ static const rtl::OUString sSkew( RTL_CONSTASCII_USTRINGPARAM ( "Skew" ) );
+ static const rtl::OUString sProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
+
+ com::sun::star::uno::Any* pAny;
+
+ double fFinalSkewAngle = -1;
+ bool bHasCustomShape = false;
+
+ for(i=0;i<nCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+
+ // see if this is an extruded customshape
+ if( !bHasCustomShape )
+ {
+ Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
+ if( pAny_ )
+ *pAny_ >>= bHasCustomShape;
+
+ if( !bHasCustomShape )
+ continue;
+ }
+
+ sal_Bool bParallel = sal_True;
+ Position3D aViewPoint( 3472, -3472, 25000 );
+ double fOriginX = 0.50;
+ double fOriginY = -0.50;
+ double fSkewAngle = -135;
+ double fSkew = 50.0;
+
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sProjectionMode );
+ sal_Int16 nProjectionMode = sal_Int16();
+ if( pAny && ( *pAny >>= nProjectionMode ) )
+ bParallel = nProjectionMode == ProjectionMode_PARALLEL;
+
+ if( bParallel )
+ {
+ EnhancedCustomShapeParameterPair aSkewPropPair;
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sSkew );
+ if( pAny && ( *pAny >>= aSkewPropPair ) )
+ {
+ aSkewPropPair.First.Value >>= fSkew;
+ aSkewPropPair.Second.Value >>= fSkewAngle;
+ }
+ if ( fSkew == 0.0 )
+ fSkewAngle = 0.0;
+ else if ( fSkewAngle == 0.0 )
+ fSkewAngle = -360.0;
+ }
+ else
+ {
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sViewPoint );
+ if( pAny )
+ *pAny >>= aViewPoint;
+
+ EnhancedCustomShapeParameterPair aOriginPropPair;
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sOrigin );
+ if( pAny && ( *pAny >>= aOriginPropPair ) )
+ {
+ aOriginPropPair.First.Value >>= fOriginX;
+ aOriginPropPair.Second.Value >>= fOriginY;
+ }
+ fSkewAngle = -1;
+ const double e = 0.0001;
+ if( aViewPoint.PositionX > e )
+ {
+ if( aViewPoint.PositionY > e )
+ {
+ if( (fOriginX > e ) && ( fOriginY > e ) )
+ fSkewAngle = 135.0;
+ }
+ else if( aViewPoint.PositionY < -e )
+ {
+ if( ( fOriginX > e ) && ( fOriginY < -e ) )
+ fSkewAngle = -135.0;
+ }
+ else
+ {
+ if( ( fOriginX > e ) && ( fOriginY > -e ) && ( fOriginY < e ) )
+ fSkewAngle = 180.0;
+ }
+ }
+ else if( aViewPoint.PositionX < -e )
+ {
+ if( aViewPoint.PositionY < -e )
+ {
+ if( ( fOriginX < -e ) && ( fOriginY < -e ) )
+ fSkewAngle = -45.0;
+ }
+ else if( aViewPoint.PositionY > e )
+ {
+ if( ( fOriginX < -e ) && ( fOriginY > e ) )
+ fSkewAngle = 45.0;
+ }
+ else
+ {
+ if( ( fOriginX < e ) && ( fOriginY > -e ) && ( fOriginY < e ) )
+ fSkewAngle = -360.0;
+ }
+ }
+ else
+ {
+ if( aViewPoint.PositionY < -e )
+ {
+ if( ( fOriginX > -e ) && ( fOriginX < e ) && ( fOriginY < -e ) )
+ fSkewAngle = -90.0;
+ }
+ else if( aViewPoint.PositionY > e )
+ {
+ if( ( fOriginX > -e ) && ( fOriginX < e ) && ( fOriginY > e ) )
+ fSkewAngle = 90.0;
+ }
+ else
+ {
+ if( ( fOriginX > -e ) && ( fOriginX < e ) && ( fOriginY > -e ) && ( fOriginY < e ) )
+ fSkewAngle = 0.0;
+ }
+ }
+ }
+
+ if( fFinalSkewAngle == -1.0 )
+ {
+ fFinalSkewAngle = fSkewAngle;
+ }
+ else if( fSkewAngle != fFinalSkewAngle )
+ {
+ fFinalSkewAngle = -1.0;
+ }
+
+ if( fFinalSkewAngle == -1.0 )
+ break;
+ }
+ }
+
+ if( bHasCustomShape )
+ rSet.Put( SfxInt32Item( SID_EXTRUSION_DIRECTION, (sal_Int32)fFinalSkewAngle ) );
+ else
+ rSet.DisableItem( SID_EXTRUSION_DIRECTION );
+}
+
+void getExtrusionProjectionState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
+ static const rtl::OUString sProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
+
+ com::sun::star::uno::Any* pAny;
+
+ sal_Int32 nFinalProjection = -1;
+ bool bHasCustomShape = false;
+
+ for(i=0;i<nCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ // see if this is an extruded customshape
+ if( !bHasCustomShape )
+ {
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
+ if( pAny_ )
+ *pAny_ >>= bHasCustomShape;
+
+ if( !bHasCustomShape )
+ continue;
+ }
+
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+
+ sal_Bool bParallel = sal_True;
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sProjectionMode );
+ ProjectionMode eProjectionMode;
+ if( pAny && ( *pAny >>= eProjectionMode ) )
+ bParallel = eProjectionMode == ProjectionMode_PARALLEL;
+
+ if( nFinalProjection == -1 )
+ {
+ nFinalProjection = bParallel;
+ }
+ else if( nFinalProjection != bParallel )
+ {
+ nFinalProjection = -1;
+ break;
+ }
+ }
+ }
+
+ if( bHasCustomShape )
+ rSet.Put( SfxInt32Item( SID_EXTRUSION_PROJECTION, nFinalProjection ) );
+ else
+ rSet.DisableItem( SID_EXTRUSION_PROJECTION );
+}
+
+void getExtrusionSurfaceState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
+ static const rtl::OUString sShadeMode( RTL_CONSTASCII_USTRINGPARAM ( "ShadeMode" ) );
+ static const rtl::OUString sSpecularity( RTL_CONSTASCII_USTRINGPARAM ( "Specularity" ) );
+ static const rtl::OUString sDiffusion( RTL_CONSTASCII_USTRINGPARAM ( "Diffusion" ) );
+ static const rtl::OUString sMetal( RTL_CONSTASCII_USTRINGPARAM ( "Metal" ) );
+
+ com::sun::star::uno::Any* pAny;
+
+ sal_Int32 nFinalSurface = -1;
+ bool bHasCustomShape = false;
+
+ for(i=0;i<nCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+
+ // see if this is an extruded customshape
+ if( !bHasCustomShape )
+ {
+ Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
+ if( pAny_ )
+ *pAny_ >>= bHasCustomShape;
+
+ if( !bHasCustomShape )
+ continue;
+ }
+
+ sal_Int32 nSurface = 0; // wire frame
+
+ ShadeMode eShadeMode( ShadeMode_FLAT );
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sShadeMode );
+ if( pAny )
+ *pAny >>= eShadeMode;
+
+ if( eShadeMode == ShadeMode_FLAT )
+ {
+ sal_Bool bMetal = sal_False;
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sMetal );
+ if( pAny )
+ *pAny >>= bMetal;
+
+ if( bMetal )
+ {
+ nSurface = 3; // metal
+ }
+ else
+ {
+ double fSpecularity = 0;
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sSpecularity );
+ if( pAny )
+ *pAny >>= fSpecularity;
+
+ const double e = 0.0001;
+ if( (fSpecularity > -e) && (fSpecularity < e) )
+ {
+ nSurface = 1; // matte
+ }
+ else
+ {
+ nSurface = 2; // plastic
+ }
+ }
+ }
+
+ if( nFinalSurface == -1 )
+ {
+ nFinalSurface = nSurface;
+ }
+ else if( nFinalSurface != nSurface )
+ {
+ nFinalSurface = -1;
+ break;
+ }
+ }
+ }
+
+ if( bHasCustomShape )
+ rSet.Put( SfxInt32Item( SID_EXTRUSION_SURFACE, nFinalSurface ) );
+ else
+ rSet.DisableItem( SID_EXTRUSION_SURFACE );
+}
+
+void getExtrusionDepthState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
+ static const rtl::OUString sDepth( RTL_CONSTASCII_USTRINGPARAM ( "Depth" ) );
+
+ com::sun::star::uno::Any* pAny;
+
+ double fFinalDepth = -1;
+ bool bHasCustomShape = false;
+
+ for(i=0;i<nCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+
+ // see if this is an extruded customshape
+ if( !bHasCustomShape )
+ {
+ Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
+ if( pAny_ )
+ *pAny_ >>= bHasCustomShape;
+
+ if( !bHasCustomShape )
+ continue;
+ }
+
+ double fDepth = 1270.0;
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sDepth );
+ if( pAny )
+ {
+ EnhancedCustomShapeParameterPair aDepthPropPair;
+ if ( *pAny >>= aDepthPropPair )
+ aDepthPropPair.First.Value >>= fDepth;
+ }
+
+ if( fFinalDepth == -1 )
+ {
+ fFinalDepth = fDepth;
+ }
+ else if( fFinalDepth != fDepth )
+ {
+ fFinalDepth = -1;
+ break;
+ }
+ }
+ }
+
+ if( pSdrView->GetModel() )
+ {
+ FieldUnit eUnit = pSdrView->GetModel()->GetUIUnit();
+ rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, (USHORT)eUnit ) );
+ }
+
+ if( bHasCustomShape )
+ rSet.Put( SvxDoubleItem( fFinalDepth, SID_EXTRUSION_DEPTH ) );
+ else
+ rSet.DisableItem( SID_EXTRUSION_DEPTH );
+}
+
+static bool compare_direction( const Direction3D& d1, const Direction3D& d2 )
+{
+ if( ((d1.DirectionX < 0) && (d2.DirectionX < 0)) || ((d1.DirectionX == 0) && (d2.DirectionX == 0)) || ((d1.DirectionX > 0) && (d2.DirectionX > 0)) )
+ {
+ if( ((d1.DirectionY < 0) && (d2.DirectionY < 0)) || ((d1.DirectionY == 0) && (d2.DirectionY == 0)) || ((d1.DirectionY > 0) && (d2.DirectionY > 0)) )
+ {
+ if( ((d1.DirectionZ < 0) && (d2.DirectionZ < 0)) || ((d1.DirectionZ == 0) && (d2.DirectionZ == 0)) || ((d1.DirectionZ > 0) && (d2.DirectionZ > 0)) )
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+void getExtrusionLightingDirectionState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
+ static const rtl::OUString sFirstLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightDirection" ) );
+ static const rtl::OUString sSecondLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightDirection" ) );
+
+ const Direction3D * pLighting1Defaults;
+ const Direction3D * pLighting2Defaults;
+
+ getLightingDirectionDefaults( &pLighting1Defaults, &pLighting2Defaults );
+
+ com::sun::star::uno::Any* pAny;
+
+ int nFinalDirection = -1;
+ bool bHasCustomShape = false;
+
+ for(i=0;i<nCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+
+ // see if this is an extruded customshape
+ if( !bHasCustomShape )
+ {
+ Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
+ if( pAny_ )
+ *pAny_ >>= bHasCustomShape;
+
+ if( !bHasCustomShape )
+ continue;
+ }
+
+ Direction3D aFirstLightDirection( 50000, 0, 10000 );
+ Direction3D aSecondLightDirection( -50000, 0, 10000 );
+
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sFirstLightDirection );
+ if( pAny )
+ *pAny >>= aFirstLightDirection;
+
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sSecondLightDirection );
+ if( pAny )
+ *pAny >>= aSecondLightDirection;
+
+ int nDirection = -1;
+
+ int j;
+ for( j = 0; j < 9; j++ )
+ {
+ if( compare_direction( aFirstLightDirection, pLighting1Defaults[j] ) &&
+ compare_direction( aSecondLightDirection, pLighting2Defaults[j] ))
+ {
+ nDirection = j;
+ break;
+ }
+ }
+
+ if( nFinalDirection == -1 )
+ {
+ nFinalDirection = nDirection;
+ }
+ else if( nDirection != nFinalDirection )
+ {
+ nFinalDirection = -1;
+ }
+
+ if( nFinalDirection == -1 )
+ break;
+ }
+ }
+
+ if( bHasCustomShape )
+ rSet.Put( SfxInt32Item( SID_EXTRUSION_LIGHTING_DIRECTION, (sal_Int32)nFinalDirection ) );
+ else
+ rSet.DisableItem( SID_EXTRUSION_LIGHTING_DIRECTION );
+}
+
+void getExtrusionLightingIntensityState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
+ static const rtl::OUString sBrightness( RTL_CONSTASCII_USTRINGPARAM ( "Brightness" ) );
+
+ com::sun::star::uno::Any* pAny;
+
+ int nFinalLevel = -1;
+ bool bHasCustomShape = false;
+
+ for(i=0;i<nCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+
+ // see if this is an extruded customshape
+ if( !bHasCustomShape )
+ {
+ Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
+ if( pAny_ )
+ *pAny_ >>= bHasCustomShape;
+
+ if( !bHasCustomShape )
+ continue;
+ }
+
+ double fBrightness = 22178.0 / 655.36;
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sBrightness );
+ if( pAny )
+ *pAny >>= fBrightness;
+
+ int nLevel;
+ if( fBrightness >= 30.0 )
+ {
+ nLevel = 0; // Bright
+ }
+ else if( fBrightness >= 10.0 )
+ {
+ nLevel = 1; // Noraml;
+ }
+ else
+ {
+ nLevel = 2; // Dim
+ }
+
+ if( nFinalLevel == -1 )
+ {
+ nFinalLevel = nLevel;
+ }
+ else if( nFinalLevel != nLevel )
+ {
+ nFinalLevel = -1;
+ break;
+ }
+ }
+ }
+
+ if( bHasCustomShape )
+ rSet.Put( SfxInt32Item( SID_EXTRUSION_LIGHTING_INTENSITY, nFinalLevel ) );
+ else
+ rSet.DisableItem( SID_EXTRUSION_LIGHTING_INTENSITY );
+}
+
+void getExtrusionColorState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
+ static const rtl::OUString sExtrusionColor( RTL_CONSTASCII_USTRINGPARAM ( "Color" ) );
+
+ com::sun::star::uno::Any* pAny;
+
+ bool bInit = false;
+ bool bAmbigius = false;
+ Color aFinalColor;
+ bool bHasCustomShape = false;
+
+ for(i=0;i<nCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+
+ // see if this is an extruded customshape
+ if( !bHasCustomShape )
+ {
+ Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
+ if( pAny_ )
+ *pAny_ >>= bHasCustomShape;
+
+ if( !bHasCustomShape )
+ continue;
+ }
+
+ Color aColor;
+
+ bool bUseColor = false;
+ pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusionColor );
+ if( pAny )
+ *pAny >>= bUseColor;
+
+ if( bUseColor )
+ {
+ const XSecondaryFillColorItem& rItem = *(XSecondaryFillColorItem*)&(pObj->GetMergedItem( XATTR_SECONDARYFILLCOLOR ));
+ aColor = rItem.GetColorValue();
+ }
+ else
+ {
+ aColor = COL_AUTO;
+ }
+
+ if( !bInit )
+ {
+ aFinalColor = aColor;
+ bInit = true;
+ }
+ else if( aFinalColor != aColor )
+ {
+ bAmbigius = true;
+ break;
+ }
+ }
+ }
+
+ if( bAmbigius )
+ aFinalColor = COL_AUTO;
+
+ if( bHasCustomShape )
+ rSet.Put( SvxColorItem( aFinalColor, SID_EXTRUSION_3D_COLOR ) );
+ else
+ rSet.DisableItem( SID_EXTRUSION_3D_COLOR );
+}
+
+namespace svx {
+bool checkForSelectedCustomShapes( SdrView* pSdrView, bool bOnlyExtruded )
+{
+ static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
+
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+ bool bFound = false;
+
+ for(i=0;(i<nCount) && !bFound ; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ if( bOnlyExtruded )
+ {
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ Any* pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
+ if( pAny )
+ *pAny >>= bFound;
+ }
+ else
+ {
+ bFound = true;
+ }
+ }
+ }
+
+ return bFound;
+}
+}
+
+void ExtrusionBar::getState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ if (rSet.GetItemState(SID_EXTRUSION_DIRECTION) != SFX_ITEM_UNKNOWN)
+ {
+ getExtrusionDirectionState( pSdrView, rSet );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_PROJECTION) != SFX_ITEM_UNKNOWN)
+ {
+ getExtrusionProjectionState( pSdrView, rSet );
+ }
+ const bool bOnlyExtrudedCustomShapes =
+ checkForSelectedCustomShapes( pSdrView, true );
+ if (rSet.GetItemState(SID_EXTRUSION_TILT_DOWN) != SFX_ITEM_UNKNOWN)
+ {
+ if (! bOnlyExtrudedCustomShapes)
+ rSet.DisableItem( SID_EXTRUSION_TILT_DOWN );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_TILT_DOWN) != SFX_ITEM_UNKNOWN)
+ {
+ if (! bOnlyExtrudedCustomShapes)
+ rSet.DisableItem( SID_EXTRUSION_TILT_DOWN );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_TILT_UP) != SFX_ITEM_UNKNOWN)
+ {
+ if (! bOnlyExtrudedCustomShapes)
+ rSet.DisableItem( SID_EXTRUSION_TILT_UP );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_TILT_LEFT) != SFX_ITEM_UNKNOWN)
+ {
+ if (! bOnlyExtrudedCustomShapes)
+ rSet.DisableItem( SID_EXTRUSION_TILT_LEFT );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_TILT_RIGHT) != SFX_ITEM_UNKNOWN)
+ {
+ if (! bOnlyExtrudedCustomShapes)
+ rSet.DisableItem( SID_EXTRUSION_TILT_RIGHT );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_3D_COLOR) != SFX_ITEM_UNKNOWN)
+ {
+ if (! bOnlyExtrudedCustomShapes)
+ rSet.DisableItem( SID_EXTRUSION_3D_COLOR );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_DEPTH_FLOATER) != SFX_ITEM_UNKNOWN)
+ {
+ if (! bOnlyExtrudedCustomShapes)
+ rSet.DisableItem( SID_EXTRUSION_DEPTH_FLOATER );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_DIRECTION_FLOATER) != SFX_ITEM_UNKNOWN)
+ {
+ if (! bOnlyExtrudedCustomShapes)
+ rSet.DisableItem( SID_EXTRUSION_DIRECTION_FLOATER );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_LIGHTING_FLOATER) != SFX_ITEM_UNKNOWN)
+ {
+ if (! bOnlyExtrudedCustomShapes)
+ rSet.DisableItem( SID_EXTRUSION_LIGHTING_FLOATER );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_SURFACE_FLOATER) != SFX_ITEM_UNKNOWN)
+ {
+ if(! bOnlyExtrudedCustomShapes)
+ rSet.DisableItem( SID_EXTRUSION_SURFACE_FLOATER );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_TOOGLE) != SFX_ITEM_UNKNOWN)
+ {
+ if( !checkForSelectedCustomShapes( pSdrView, false ) )
+ rSet.DisableItem( SID_EXTRUSION_TOOGLE );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_DEPTH) != SFX_ITEM_UNKNOWN)
+ {
+ getExtrusionDepthState( pSdrView, rSet );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_SURFACE) != SFX_ITEM_UNKNOWN)
+ {
+ getExtrusionSurfaceState( pSdrView, rSet );
+ }
+ if (rSet.GetItemState(SID_EXTRUSION_LIGHTING_INTENSITY) != SFX_ITEM_UNKNOWN)
+ {
+ getExtrusionLightingIntensityState( pSdrView, rSet );
+ }
+
+ if (rSet.GetItemState(SID_EXTRUSION_LIGHTING_DIRECTION) != SFX_ITEM_UNKNOWN)
+ {
+ getExtrusionLightingDirectionState( pSdrView, rSet );
+ }
+
+ if (rSet.GetItemState(SID_EXTRUSION_3D_COLOR) != SFX_ITEM_UNKNOWN)
+ {
+ getExtrusionColorState( pSdrView, rSet );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/toolbars/extrusionbar.src b/svx/source/toolbars/extrusionbar.src
new file mode 100644
index 000000000000..3e6c6ad7e5cb
--- /dev/null
+++ b/svx/source/toolbars/extrusionbar.src
@@ -0,0 +1,115 @@
+#include <svx/svxids.hrc>
+#include <svx/dialogs.hrc>
+
+ToolBox RID_SVX_EXTRUSION_BAR
+{
+ HelpId = RID_SVX_EXTRUSION_BAR ;
+ Align = BOXALIGN_BOTTOM ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_EXTRUSION_TOOGLE ;
+ HelpID = SID_EXTRUSION_TOOGLE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_EXTRUSION_TILT_DOWN ;
+ HelpID = SID_EXTRUSION_TILT_DOWN ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_EXTRUSION_TILT_UP ;
+ HelpID = SID_EXTRUSION_TILT_UP ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_EXTRUSION_TILT_LEFT ;
+ HelpID = SID_EXTRUSION_TILT_LEFT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_EXTRUSION_TILT_RIGHT ;
+ HelpID = SID_EXTRUSION_TILT_RIGHT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_EXTRUSION_DEPTH_FLOATER ;
+ HelpID = SID_EXTRUSION_DEPTH_FLOATER ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_EXTRUSION_DIRECTION_FLOATER ;
+ HelpID = SID_EXTRUSION_DIRECTION_FLOATER ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_EXTRUSION_LIGHTING_FLOATER ;
+ HelpID = SID_EXTRUSION_LIGHTING_FLOATER ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_EXTRUSION_SURFACE_FLOATER ;
+ HelpID = SID_EXTRUSION_SURFACE_FLOATER ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_EXTRUSION_3D_COLOR ;
+ HelpID = SID_EXTRUSION_3D_COLOR ;
+ };
+ };
+};
+
+String RID_SVX_EXTRUSION_BAR
+{
+ Text [ en-US ] = "Extrusion";
+};
+
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_ON_OFF
+{
+ Text [ en-US ] = "Apply Extrusion On/Off";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_DOWN
+{
+ Text [ en-US ] = "Tilt Down";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_UP
+{
+ Text [ en-US ] = "Tilt Up";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_LEFT
+{
+ Text [ en-US ] = "Tilt Left";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_RIGHT
+{
+ Text [ en-US ] = "Tilt Right";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_DEPTH
+{
+ Text [ en-US ] = "Change Extrusion Depth";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_ORIENTATION
+{
+ Text [ en-US ] = "Change Orientation";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_PROJECTION
+{
+ Text [ en-US ] = "Change Projection Type";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_LIGHTING
+{
+ Text [ en-US ] = "Change Lighting";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_BRIGHTNESS
+{
+ Text [ en-US ] = "Change Brightness";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_SURFACE
+{
+ Text [ en-US ] = "Change Extrusion Surface";
+};
+String RID_SVXSTR_UNDO_APPLY_EXTRUSION_COLOR
+{
+ Text [ en-US ] = "Change Extrusion Color";
+};
diff --git a/svx/source/toolbars/fontworkbar.cxx b/svx/source/toolbars/fontworkbar.cxx
new file mode 100644
index 000000000000..719e8ebf5df6
--- /dev/null
+++ b/svx/source/toolbars/fontworkbar.cxx
@@ -0,0 +1,642 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/svdundo.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/viewsh.hxx>
+#include "unoapi.hxx"
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
+#include <svx/dialmgr.hxx>
+#include <svx/svdoashp.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/svdview.hxx>
+#include <svx/sdasitm.hxx>
+#include <svx/svdoashp.hxx>
+#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
+#include <sfx2/bindings.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/charscaleitem.hxx>
+#include <editeng/kernitem.hxx>
+#include <sdrpaintwindow.hxx>
+
+#include <svx/svxids.hrc>
+#include <svx/fontworkbar.hxx>
+#include "fontworkgallery.hxx"
+
+using ::rtl::OUString;
+
+using namespace ::svx;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+
+void SetAlignmentState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ sal_Int32 nAlignment = -1;
+ for( i = 0; i < nCount; i++ )
+ {
+ SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ sal_Int32 nOldAlignment = nAlignment;
+ SdrTextHorzAdjustItem& rTextHorzAdjustItem = (SdrTextHorzAdjustItem&)pObj->GetMergedItem( SDRATTR_TEXT_HORZADJUST );
+ SdrTextFitToSizeTypeItem& rTextFitToSizeTypeItem = (SdrTextFitToSizeTypeItem&)pObj->GetMergedItem( SDRATTR_TEXT_FITTOSIZE );
+ switch ( rTextHorzAdjustItem.GetValue() )
+ {
+ case SDRTEXTHORZADJUST_LEFT : nAlignment = 0; break;
+ case SDRTEXTHORZADJUST_CENTER : nAlignment = 1; break;
+ case SDRTEXTHORZADJUST_RIGHT : nAlignment = 2; break;
+ case SDRTEXTHORZADJUST_BLOCK :
+ {
+ if ( rTextFitToSizeTypeItem.GetValue() == SDRTEXTFIT_NONE )
+ nAlignment = 3;
+ else if ( rTextFitToSizeTypeItem.GetValue() == SDRTEXTFIT_ALLLINES )
+ nAlignment = 4;
+ }
+ }
+ if ( ( nOldAlignment != -1 ) && ( nOldAlignment != nAlignment ) )
+ {
+ nAlignment = -1;
+ break;
+ }
+ }
+ }
+ rSet.Put( SfxInt32Item( SID_FONTWORK_ALIGNMENT, nAlignment ) );
+}
+
+void SetCharacterSpacingState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ sal_Int32 nCharacterSpacing = -1;
+ for( i = 0; i < nCount; i++ )
+ {
+ SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ sal_Int32 nOldCharacterSpacing = nCharacterSpacing;
+ SvxCharScaleWidthItem& rCharScaleWidthItem = (SvxCharScaleWidthItem&)pObj->GetMergedItem( EE_CHAR_FONTWIDTH );
+ nCharacterSpacing = rCharScaleWidthItem.GetValue();
+ if ( ( nOldCharacterSpacing != -1 ) && ( nOldCharacterSpacing != nCharacterSpacing ) )
+ {
+ nCharacterSpacing = -1;
+ break;
+ }
+ }
+ }
+ rSet.Put( SfxInt32Item( SID_FONTWORK_CHARACTER_SPACING, nCharacterSpacing ) );
+}
+
+
+void SetKernCharacterPairsState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ sal_Bool bChecked = sal_False;
+ for( i = 0; i < nCount; i++ )
+ {
+ SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ SvxKerningItem& rKerningItem = (SvxKerningItem&)pObj->GetMergedItem( EE_CHAR_KERNING );
+ if ( rKerningItem.GetValue() )
+ bChecked = sal_True;
+ }
+ }
+ rSet.Put( SfxBoolItem( SID_FONTWORK_KERN_CHARACTER_PAIRS, bChecked ) );
+}
+
+void SetFontWorkShapeTypeState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+
+ rtl::OUString aFontWorkShapeType;
+
+ for( i = 0; i < nCount; i++ )
+ {
+ SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
+ if( pObj->ISA( SdrObjCustomShape ) )
+ {
+ const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ Any* pAny = aGeometryItem.GetPropertyValueByName( sType );
+ if( pAny )
+ {
+ rtl::OUString aType;
+ if ( *pAny >>= aType )
+ {
+ if ( aFontWorkShapeType.getLength() )
+ {
+ if ( !aFontWorkShapeType.equals( aType ) ) // different FontWorkShapeTypes selected ?
+ {
+ aFontWorkShapeType = rtl::OUString();
+ break;
+ }
+ }
+ aFontWorkShapeType = aType;
+ }
+ }
+ }
+ }
+ rSet.Put( SfxStringItem( SID_FONTWORK_SHAPE_TYPE, aFontWorkShapeType ) );
+}
+
+/*************************************************************************
+|*
+|* Standardinterface deklarieren (Die Slotmap darf nicht leer sein, also
+|* tragen wir etwas ein, was hier (hoffentlich) nie vorkommt).
+|*
+\************************************************************************/
+
+#define ShellClass FontworkBar
+
+SFX_SLOTMAP(FontworkBar)
+{
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+};
+
+SFX_IMPL_INTERFACE(FontworkBar, SfxShell, SVX_RES(RID_SVX_FONTWORK_BAR))
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT, SVX_RES(RID_SVX_FONTWORK_BAR) );
+}
+
+TYPEINIT1( FontworkBar, SfxShell );
+
+
+/*************************************************************************
+|*
+|* Standard-Konstruktor
+|*
+\************************************************************************/
+
+FontworkBar::FontworkBar(SfxViewShell* pViewShell )
+: SfxShell(pViewShell)
+{
+ DBG_ASSERT( pViewShell, "svx::FontworkBar::FontworkBar(), I need a viewshell!" );
+ if( pViewShell )
+ SetPool(&pViewShell->GetPool());
+
+ SetHelpId( SVX_INTERFACE_FONTWORK_BAR );
+ SetName( String( SVX_RES( RID_SVX_FONTWORK_BAR) ));
+}
+
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FontworkBar::~FontworkBar()
+{
+ SetRepeatTarget(NULL);
+}
+
+static Window* ImpGetViewWin(SdrView* pView)
+{
+ if( pView )
+ {
+ const sal_uInt32 nAnz(pView->PaintWindowCount());
+ for(sal_uInt32 nNum(0L); nNum < nAnz; nNum++)
+ {
+ OutputDevice* pOut = &(pView->GetPaintWindow(nNum)->GetOutputDevice());
+
+ if(OUTDEV_WINDOW == pOut->GetOutDevType())
+ {
+ return (Window*)pOut;
+ }
+ }
+ }
+
+ return 0L;
+}
+
+namespace svx {
+bool checkForSelectedFontWork( SdrView* pSdrView, sal_uInt32& nCheckStatus )
+{
+ if ( nCheckStatus & 2 )
+ return ( nCheckStatus & 1 ) != 0;
+
+ static const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
+
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+ sal_Bool bFound = sal_False;
+ for(i=0;(i<nCount) && !bFound ; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ Any* pAny = aGeometryItem.GetPropertyValueByName( sTextPath, sTextPath );
+ if( pAny )
+ *pAny >>= bFound;
+ }
+ }
+ if ( bFound )
+ nCheckStatus |= 1;
+ nCheckStatus |= 2;
+ return bFound;
+}
+}
+
+static void impl_execute( SdrView*, SfxRequest& rReq, SdrCustomShapeGeometryItem& rGeometryItem, SdrObject* pObj )
+{
+ static const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
+ static const rtl::OUString sSameLetterHeights( RTL_CONSTASCII_USTRINGPARAM ( "SameLetterHeights" ) );
+
+ sal_uInt16 nSID = rReq.GetSlot();
+ switch( nSID )
+ {
+ case SID_FONTWORK_SAME_LETTER_HEIGHTS:
+ {
+ com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sSameLetterHeights );
+ if( pAny )
+ {
+ sal_Bool bOn;
+ (*pAny) >>= bOn;
+ bOn = !bOn;
+ (*pAny) <<= bOn;
+ }
+ }
+ break;
+
+ case SID_FONTWORK_ALIGNMENT:
+ {
+ if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_FONTWORK_ALIGNMENT ) == SFX_ITEM_SET )
+ {
+ sal_Int32 nValue = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_FONTWORK_ALIGNMENT))->GetValue();
+ if ( ( nValue >= 0 ) && ( nValue < 5 ) )
+ {
+ SdrFitToSizeType eFTS = SDRTEXTFIT_NONE;
+ SdrTextHorzAdjust eHorzAdjust;
+ switch ( nValue )
+ {
+ case 4 : eFTS = SDRTEXTFIT_ALLLINES; // passthrough
+ case 3 : eHorzAdjust = SDRTEXTHORZADJUST_BLOCK; break;
+ default:
+ case 0 : eHorzAdjust = SDRTEXTHORZADJUST_LEFT; break;
+ case 1 : eHorzAdjust = SDRTEXTHORZADJUST_CENTER; break;
+ case 2 : eHorzAdjust = SDRTEXTHORZADJUST_RIGHT; break;
+ }
+ pObj->SetMergedItem( SdrTextHorzAdjustItem( eHorzAdjust ) );
+ pObj->SetMergedItem( SdrTextFitToSizeTypeItem( eFTS ) );
+ pObj->BroadcastObjectChange();
+ }
+ }
+ }
+ break;
+
+ case SID_FONTWORK_CHARACTER_SPACING:
+ {
+ if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_CHARACTER_SPACING ) == SFX_ITEM_SET ) )
+ {
+ sal_Int32 nCharSpacing = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_FONTWORK_CHARACTER_SPACING))->GetValue();
+ pObj->SetMergedItem( SvxCharScaleWidthItem( (sal_uInt16)nCharSpacing, EE_CHAR_FONTWIDTH ) );
+ pObj->BroadcastObjectChange();
+ }
+ }
+ break;
+
+ case SID_FONTWORK_KERN_CHARACTER_PAIRS:
+ {
+ if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_KERN_CHARACTER_PAIRS ) == SFX_ITEM_SET ) )
+ {
+ // sal_Bool bKernCharacterPairs = ((const SfxBoolItem*)rReq.GetArgs()->GetItem(SID_FONTWORK_KERN_CHARACTER_PAIRS))->GetValue();
+//TODO: pObj->SetMergedItem( SvxCharScaleWidthItem( (sal_uInt16)nCharSpacing, EE_CHAR_FONTWIDTH ) );
+ pObj->BroadcastObjectChange();
+ }
+ }
+ break;
+ }
+}
+
+#include "gallery.hxx"
+#include <svx/fmmodel.hxx>
+#include <svx/fmpage.hxx>
+#include <svl/itempool.hxx>
+
+void GetGeometryForCustomShape( SdrCustomShapeGeometryItem& rGeometryItem, const rtl::OUString rCustomShape )
+{
+ const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
+
+ com::sun::star::beans::PropertyValue aPropVal;
+ aPropVal.Name = sType;
+ aPropVal.Value <<= rCustomShape;
+ rGeometryItem.SetPropertyValue( aPropVal );
+
+ const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
+ const rtl::OUString sCoordinateOrigin( RTL_CONSTASCII_USTRINGPARAM ( "CoordinateOrigin" ) );
+ const rtl::OUString sCoordinateSize( RTL_CONSTASCII_USTRINGPARAM ( "CoordinateSize" ) );
+ const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM ( "Equations" ) );
+ const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM ( "Handles" ) );
+ const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
+ rGeometryItem.ClearPropertyValue( sAdjustmentValues );
+ rGeometryItem.ClearPropertyValue( sCoordinateOrigin );
+ rGeometryItem.ClearPropertyValue( sCoordinateSize );
+ rGeometryItem.ClearPropertyValue( sEquations );
+ rGeometryItem.ClearPropertyValue( sHandles );
+ rGeometryItem.ClearPropertyValue( sPath );
+
+ /* SJ: CustomShapes that are available in the gallery are having the highest
+ priority, so we will take a look there before taking the internal default */
+
+ if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
+ {
+ std::vector< rtl::OUString > aObjList;
+ if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
+ {
+ sal_uInt16 i;
+ for ( i = 0; i < aObjList.size(); i++ )
+ {
+ if ( aObjList[ i ].equalsIgnoreAsciiCase( rCustomShape ) )
+ {
+ FmFormModel aFormModel;
+ SfxItemPool& rPool = aFormModel.GetItemPool();
+ rPool.FreezeIdRanges();
+ if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
+ {
+ const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 );
+ if( pSourceObj )
+ {
+ PropertyValue aPropVal_;
+ SdrCustomShapeGeometryItem& rSourceGeometry = (SdrCustomShapeGeometryItem&)pSourceObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
+ com::sun::star::uno::Any* pAny = rSourceGeometry.GetPropertyValueByName( sType );
+ if ( pAny )
+ {
+ aPropVal_.Name = sType;
+ aPropVal_.Value = *pAny;
+ rGeometryItem.SetPropertyValue( aPropVal_ );
+ }
+ pAny = rSourceGeometry.GetPropertyValueByName( sAdjustmentValues );
+ if ( pAny )
+ {
+ aPropVal_.Name = sAdjustmentValues;
+ aPropVal_.Value = *pAny;
+ rGeometryItem.SetPropertyValue( aPropVal_ );
+ }
+ pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateOrigin );
+ if ( pAny )
+ {
+ aPropVal_.Name = sCoordinateOrigin;
+ aPropVal_.Value = *pAny;
+ rGeometryItem.SetPropertyValue( aPropVal_ );
+ }
+ pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateSize );
+ if ( pAny )
+ {
+ aPropVal_.Name = sCoordinateSize;
+ aPropVal_.Value = *pAny;
+ rGeometryItem.SetPropertyValue( aPropVal_ );
+ }
+ pAny = rSourceGeometry.GetPropertyValueByName( sEquations );
+ if ( pAny )
+ {
+ aPropVal_.Name = sEquations;
+ aPropVal_.Value = *pAny;
+ rGeometryItem.SetPropertyValue( aPropVal_ );
+ }
+ pAny = rSourceGeometry.GetPropertyValueByName( sHandles );
+ if ( pAny )
+ {
+ aPropVal_.Name = sHandles;
+ aPropVal_.Value = *pAny;
+ rGeometryItem.SetPropertyValue( aPropVal_ );
+ }
+ pAny = rSourceGeometry.GetPropertyValueByName( sPath );
+ if ( pAny )
+ {
+ aPropVal_.Name = sPath;
+ aPropVal_.Value = *pAny;
+ rGeometryItem.SetPropertyValue( aPropVal_ );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+void FontworkBar::execute( SdrView* pSdrView, SfxRequest& rReq, SfxBindings& rBindings )
+{
+ sal_uInt16 nStrResId = 0;
+
+ sal_uInt16 nSID = rReq.GetSlot();
+ switch( nSID )
+ {
+ case SID_FONTWORK_GALLERY_FLOATER:
+ {
+ FontWorkGalleryDialog aDlg( pSdrView, ImpGetViewWin(pSdrView), nSID );
+ aDlg.Execute();
+ }
+ break;
+
+ case SID_FONTWORK_SHAPE_TYPE:
+ {
+ rtl::OUString aCustomShape;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
+ aCustomShape = rItm.GetValue();
+ }
+ if ( aCustomShape.getLength() )
+ {
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ sal_uInt32 nCount = rMarkList.GetMarkCount(), i;
+ for( i = 0; i < nCount; i++ )
+ {
+ SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ const bool bUndo = pSdrView->IsUndoEnabled();
+
+ if( bUndo )
+ {
+ String aStr( SVX_RES( RID_SVXSTR_UNDO_APPLY_FONTWORK_SHAPE ) );
+ pSdrView->BegUndo( aStr );
+ pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
+ }
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ GetGeometryForCustomShape( aGeometryItem, aCustomShape );
+ pObj->SetMergedItem( aGeometryItem );
+
+ Reference< drawing::XShape > aXShape = GetXShapeForSdrObject( (SdrObjCustomShape*)pObj );
+ if ( aXShape.is() )
+ {
+ Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( aXShape, UNO_QUERY );
+ if( xDefaulter.is() )
+ xDefaulter->createCustomShapeDefaults( aCustomShape );
+ }
+
+ pObj->BroadcastObjectChange();
+ if( bUndo )
+ pSdrView->EndUndo();
+ pSdrView->AdjustMarkHdl(); //HMH sal_True );
+ rBindings.Invalidate( SID_FONTWORK_SHAPE_TYPE );
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_FONTWORK_CHARACTER_SPACING_DIALOG :
+ {
+ if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_CHARACTER_SPACING ) == SFX_ITEM_SET ) )
+ {
+ sal_Int32 nCharSpacing = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_FONTWORK_CHARACTER_SPACING))->GetValue();
+ FontworkCharacterSpacingDialog aDlg( 0L, nCharSpacing );
+ USHORT nRet = aDlg.Execute();
+ if( nRet != 0 )
+ {
+ SfxInt32Item aItem( SID_FONTWORK_CHARACTER_SPACING, aDlg.getScale() );
+ SfxPoolItem* aItems[] = { &aItem, 0 };
+ rBindings.Execute( SID_FONTWORK_CHARACTER_SPACING, (const SfxPoolItem**)aItems );
+ }
+ }
+ }
+ break;
+
+ case SID_FONTWORK_SHAPE:
+ case SID_FONTWORK_ALIGNMENT:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_ALIGNMENT;
+ } // PASSTROUGH
+ case SID_FONTWORK_CHARACTER_SPACING:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_CHARACTER_SPACING;
+ } // PASSTROUGH
+ case SID_FONTWORK_KERN_CHARACTER_PAIRS:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_CHARACTER_SPACING;
+ } // PASSTROUGH
+ case SID_FONTWORK_SAME_LETTER_HEIGHTS:
+ {
+ if ( !nStrResId )
+ nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_SAME_LETTER_HEIGHT;
+
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount(), i;
+ for( i = 0; i < nCount; i++ )
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if( pObj->ISA(SdrObjCustomShape) )
+ {
+ const bool bUndo = pSdrView->IsUndoEnabled();
+ if( bUndo )
+ {
+ String aStr( SVX_RES( nStrResId ) );
+ pSdrView->BegUndo( aStr );
+ pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
+ }
+ SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
+ impl_execute( pSdrView, rReq, aGeometryItem, pObj );
+ pObj->SetMergedItem( aGeometryItem );
+ pObj->BroadcastObjectChange();
+ if( bUndo )
+ pSdrView->EndUndo();
+ }
+ }
+ }
+ break;
+ };
+}
+
+void FontworkBar::getState( SdrView* pSdrView, SfxItemSet& rSet )
+{
+ sal_uInt32 nCheckStatus = 0;
+
+ /*
+ if ( rSet.GetItemState( SID_FONTWORK_SHAPE ) != SFX_ITEM_UNKNOWN )
+ {
+ sal_Bool bBreak = sal_True;
+ }
+ */
+ if ( rSet.GetItemState( SID_FONTWORK_ALIGNMENT_FLOATER ) != SFX_ITEM_UNKNOWN )
+ {
+ if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
+ rSet.DisableItem( SID_FONTWORK_ALIGNMENT_FLOATER );
+ }
+ if ( rSet.GetItemState( SID_FONTWORK_ALIGNMENT ) != SFX_ITEM_UNKNOWN )
+ {
+ if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
+ rSet.DisableItem( SID_FONTWORK_ALIGNMENT );
+ else
+ SetAlignmentState( pSdrView, rSet );
+ }
+ if ( rSet.GetItemState( SID_FONTWORK_CHARACTER_SPACING_FLOATER ) != SFX_ITEM_UNKNOWN )
+ {
+ if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
+ rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING_FLOATER );
+ }
+ if ( rSet.GetItemState( SID_FONTWORK_CHARACTER_SPACING ) != SFX_ITEM_UNKNOWN )
+ {
+ if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
+ rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING );
+ else
+ SetCharacterSpacingState( pSdrView, rSet );
+ }
+ if ( rSet.GetItemState( SID_FONTWORK_KERN_CHARACTER_PAIRS ) != SFX_ITEM_UNKNOWN )
+ {
+ if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
+ rSet.DisableItem( SID_FONTWORK_KERN_CHARACTER_PAIRS );
+ else
+ SetKernCharacterPairsState( pSdrView, rSet );
+ }
+ if ( rSet.GetItemState( SID_FONTWORK_SAME_LETTER_HEIGHTS ) != SFX_ITEM_UNKNOWN )
+ {
+ if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
+ rSet.DisableItem( SID_FONTWORK_SAME_LETTER_HEIGHTS );
+ }
+ if ( rSet.GetItemState( SID_FONTWORK_SHAPE_TYPE ) != SFX_ITEM_UNKNOWN )
+ {
+ if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
+ rSet.DisableItem( SID_FONTWORK_SHAPE_TYPE );
+ else
+ SetFontWorkShapeTypeState( pSdrView, rSet );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/toolbars/fontworkbar.src b/svx/source/toolbars/fontworkbar.src
new file mode 100644
index 000000000000..ed9b152fe46a
--- /dev/null
+++ b/svx/source/toolbars/fontworkbar.src
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+
+ToolBox RID_SVX_FONTWORK_BAR
+{
+ HelpId = RID_SVX_FONTWORK_BAR ;
+ Align = BOXALIGN_BOTTOM ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_FONTWORK_GALLERY_FLOATER ;
+ HelpID = SID_FONTWORK_GALLERY_FLOATER ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_FONTWORK_SHAPE_TYPE ;
+ HelpID = SID_FONTWORK_SHAPE_TYPE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_FONTWORK_SAME_LETTER_HEIGHTS ;
+ HelpID = SID_FONTWORK_SAME_LETTER_HEIGHTS ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_FONTWORK_ALIGNMENT_FLOATER ;
+ HelpID = SID_FONTWORK_ALIGNMENT_FLOATER ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_FONTWORK_CHARACTER_SPACING_FLOATER ;
+ HelpID = SID_FONTWORK_CHARACTER_SPACING_FLOATER ;
+ };
+ };
+};
+
+String RID_SVX_FONTWORK_BAR
+{
+ Text [ en-US ] = "Fontwork";
+};
+
+String RID_SVXSTR_UNDO_APPLY_FONTWORK_SHAPE
+{
+ Text [ en-US ] = "Apply Fontwork Shape";
+};
+
+String RID_SVXSTR_UNDO_APPLY_FONTWORK_SAME_LETTER_HEIGHT
+{
+ Text [ en-US ] = "Apply Fontwork Same Letter Heights";
+};
+
+String RID_SVXSTR_UNDO_APPLY_FONTWORK_ALIGNMENT
+{
+ Text [ en-US ] = "Apply Fontwork Alignment";
+};
+
+String RID_SVXSTR_UNDO_APPLY_FONTWORK_CHARACTER_SPACING
+{
+ Text [ en-US ] = "Apply Fontwork Character Spacing";
+};
diff --git a/svx/source/toolbars/makefile.mk b/svx/source/toolbars/makefile.mk
new file mode 100644
index 000000000000..40c7f2ccb73e
--- /dev/null
+++ b/svx/source/toolbars/makefile.mk
@@ -0,0 +1,56 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=svxpch
+PROJECTPCHSOURCE=$(PRJ)$/util$/svxpch
+
+PRJNAME=svx
+TARGET=toolbars
+ENABLE_EXCEPTIONS=TRUE;
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=toolbars
+SRC1FILES = \
+ extrusionbar.src \
+ fontworkbar.src
+
+SLOFILES= \
+ $(SLO)$/extrusionbar.obj \
+ $(SLO)$/fontworkbar.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/unodialogs/inc/buttongroup.hrc b/svx/source/unodialogs/inc/buttongroup.hrc
new file mode 100644
index 000000000000..8385627295d3
--- /dev/null
+++ b/svx/source/unodialogs/inc/buttongroup.hrc
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * 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 _UNODIALOGS_BUTTONGROUP_HRC
+#define _UNODIALOGS_BUTTONGROUP_HRC
+
+#include "resids.hrc"
+
+#define PB_OK 1
+#define PB_CANCEL 1
+#define PB_HELP 1
+
+#define BUTTONGROUP_BUTTONWIDTH 40
+
+#define BUTTONS_OK_CANCEL_HELP( xRightPos, yTopPos, xOffset, yOffset ) \
+OKButton PB_OK \
+{ \
+ Pos = MAP_APPFONT ( xRightPos-BUTTONGROUP_BUTTONWIDTH-xOffset-xOffset , yTopPos ) ; \
+ Size = MAP_APPFONT ( BUTTONGROUP_BUTTONWIDTH , 14 ) ; \
+ TabStop = TRUE ; \
+ DefButton = TRUE ; \
+}; \
+CancelButton PB_CANCEL \
+{ \
+ Pos = MAP_APPFONT ( xRightPos-BUTTONGROUP_BUTTONWIDTH-xOffset , yTopPos+yOffset ) ; \
+ Size = MAP_APPFONT ( BUTTONGROUP_BUTTONWIDTH , 14 ) ; \
+ TabStop = TRUE ; \
+}; \
+HelpButton PB_HELP \
+{ \
+ Pos = MAP_APPFONT ( xRightPos-BUTTONGROUP_BUTTONWIDTH , yTopPos+yOffset+yOffset ) ; \
+ Size = MAP_APPFONT ( BUTTONGROUP_BUTTONWIDTH , 14 ) ; \
+ TabStop = TRUE ; \
+};
+
+#define BUTTONS_OK_CANCEL_HELP_STACKED( xRightPos ) \
+BUTTONS_OK_CANCEL_HELP( xRightPos, 6, 0, 17 )
+
+#define BUTTONS_OK_CANCEL_HELP_ABREAST( xRightPos, yTopPos ) \
+BUTTONS_OK_CANCEL_HELP( xRightPos, yTopPos, (BUTTONGROUP_BUTTONWIDTH+3), 0 )
+
+#endif
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx
new file mode 100644
index 000000000000..04505821d329
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.cxx
@@ -0,0 +1,894 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "chinese_dictionarydialog.hxx"
+#include "chinese_dictionarydialog.hrc"
+#include "resid.hxx"
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/i18n/TextConversionOption.hpp>
+#include <com/sun/star/linguistic2/ConversionDictionaryType.hpp>
+#include <com/sun/star/linguistic2/ConversionPropertyType.hpp>
+#include <com/sun/star/linguistic2/XConversionDictionaryList.hpp>
+#include <com/sun/star/linguistic2/XConversionPropertyType.hpp>
+#include <com/sun/star/util/XFlushable.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+// header for class HeaderBar
+#include <svtools/headbar.hxx>
+// header for define RET_OK
+#include <vcl/msgbox.hxx>
+// header for class SvtLinguConfigItem
+#include <unotools/lingucfg.hxx>
+#include <unotools/linguprops.hxx>
+// header for class IntlWrapper
+#include <unotools/intlwrapper.hxx>
+#include <comphelper/processfactory.hxx>
+// header for class Application
+#include <vcl/svapp.hxx>
+#include "helpid.hrc"
+
+//disable compiler warning C4355: 'this' : used in base member initializer list
+#ifdef _MSC_VER
+# pragma warning (disable : 4355)
+#endif
+
+//.............................................................................
+namespace textconversiondlgs
+{
+//.............................................................................
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+#define HEADER_BAR_BITS ( HIB_LEFT | HIB_VCENTER | HIB_CLICKABLE | HIB_FIXED | HIB_FIXEDPOS )
+
+DictionaryList::DictionaryList( Window* pParent, const ResId& rResId)
+ : SvHeaderTabListBox( pParent, rResId )
+ , m_xDictionary(0)
+ , m_pHeaderBar(0)
+ , m_pPropertyTypeNameListBox(0)
+ , m_aToBeDeleted()
+ , m_nSortColumnIndex(0)
+{
+}
+
+DictionaryList::DictionaryList( Window* pParent )
+ : SvHeaderTabListBox( pParent, 0 )
+ , m_xDictionary(0)
+ , m_pHeaderBar(0)
+ , m_pPropertyTypeNameListBox(0)
+ , m_aToBeDeleted()
+ , m_nSortColumnIndex(0)
+{
+}
+
+String DictionaryList::getPropertyTypeName( sal_Int16 nConversionPropertyType ) const
+{
+ if(!m_pPropertyTypeNameListBox || !m_pPropertyTypeNameListBox->GetEntryCount())
+ return String();
+
+ USHORT nPos = static_cast<USHORT>( nConversionPropertyType )-1;
+ if(nPos<m_pPropertyTypeNameListBox->GetEntryCount())
+ return m_pPropertyTypeNameListBox->GetEntry(nPos);
+ return m_pPropertyTypeNameListBox->GetEntry(0);
+}
+
+String DictionaryList::makeTabString( const DictionaryEntry& rEntry ) const
+{
+ String aStr( rEntry.m_aTerm );
+ aStr += '\t';
+ aStr += String( rEntry.m_aMapping );
+ aStr += '\t';
+ aStr += getPropertyTypeName( rEntry.m_nConversionPropertyType );
+ return aStr;
+}
+
+void DictionaryList::initDictionaryControl( const Reference< linguistic2::XConversionDictionary>& xDictionary
+ , ListBox* pPropertyTypeNameListBox )
+{
+ SetWindowBits( WB_VSCROLL );
+ SetSelectionMode( SINGLE_SELECTION );
+ SetBorderStyle( WINDOW_BORDER_MONO );
+ SetHighlightRange();
+
+ if(m_xDictionary.is())
+ return;
+
+ m_xDictionary = xDictionary;
+ m_pPropertyTypeNameListBox = pPropertyTypeNameListBox;
+}
+
+void DictionaryList::save()
+{
+ if( !m_xDictionary.is() )
+ return;
+
+ Reference< linguistic2::XConversionPropertyType > xPropertyType( m_xDictionary, uno::UNO_QUERY );
+
+ sal_Int32 nN;
+ DictionaryEntry* pE;
+
+ for( nN = m_aToBeDeleted.size(); nN--; )
+ {
+ pE = m_aToBeDeleted[nN];
+ m_xDictionary->removeEntry( pE->m_aTerm, pE->m_aMapping );
+ }
+ for( nN = GetRowCount(); nN--; )
+ {
+ pE = getEntryOnPos( nN );
+ if(pE->m_bNewEntry)
+ {
+ try
+ {
+ m_xDictionary->addEntry( pE->m_aTerm, pE->m_aMapping );
+ xPropertyType->setPropertyType( pE->m_aTerm, pE->m_aMapping, pE->m_nConversionPropertyType );
+ }
+ catch( uno::Exception& )
+ {
+
+ }
+ }
+ }
+ Reference< util::XFlushable > xFlush( m_xDictionary, uno::UNO_QUERY );
+ if( xFlush.is() )
+ xFlush->flush();
+}
+
+void DictionaryList::deleteAll()
+{
+ sal_Int32 nN;
+ for( nN = GetRowCount(); nN--; )
+ deleteEntryOnPos( nN );
+ for( nN = m_aToBeDeleted.size(); nN--; )
+ {
+ DictionaryEntry* pE = m_aToBeDeleted[nN];
+ delete pE;
+ }
+ m_aToBeDeleted.clear();
+}
+
+void DictionaryList::refillFromDictionary( sal_Int32 nTextConversionOptions )
+{
+ deleteAll();
+
+ if(!m_xDictionary.is())
+ return;
+
+ Sequence< rtl::OUString > aLeftList( m_xDictionary->getConversionEntries( linguistic2::ConversionDirection_FROM_LEFT ) );
+ sal_Int32 nCount = aLeftList.getLength();
+
+ Reference< linguistic2::XConversionPropertyType > xPropertyType( m_xDictionary, uno::UNO_QUERY );
+
+ rtl::OUString aLeft, aRight;
+ sal_Int16 nConversionPropertyType;
+
+ for(sal_Int32 nN=0; nN<nCount; nN++)
+ {
+ aLeft = aLeftList[nN];
+ Sequence< rtl::OUString > aRightList( m_xDictionary->getConversions(
+ aLeft, 0, aLeft.getLength()
+ , linguistic2::ConversionDirection_FROM_LEFT, nTextConversionOptions ) );
+
+ if(aRightList.getLength()!=1)
+ {
+ OSL_ASSERT("The Chinese Translation Dictionary should have exactly one Mapping for each term.");
+ continue;
+ }
+
+ aRight = aRightList[0];
+ nConversionPropertyType = linguistic2::ConversionPropertyType::OTHER;
+ if(xPropertyType.is())
+ nConversionPropertyType = xPropertyType->getPropertyType(aLeft, aRight);
+
+ DictionaryEntry* pEntry = new DictionaryEntry( aLeft, aRight, nConversionPropertyType );
+ SvLBoxEntry* pLBEntry = InsertEntry( makeTabString( *pEntry ) );
+ pLBEntry->SetUserData( pEntry );
+ }
+
+ if( GetEntryCount() > 0 )
+ SelectRow( 0 );
+}
+
+DictionaryEntry* DictionaryList::getFirstSelectedEntry() const
+{
+ DictionaryEntry* pRet=0;
+ for( sal_Int32 nN=GetRowCount(); nN--; )
+ {
+ if( IsRowSelected( nN ) )
+ {
+ pRet = getEntryOnPos( nN );
+ break;
+ }
+ }
+ return pRet;
+}
+
+DictionaryEntry* DictionaryList::getEntryOnPos( sal_Int32 nPos ) const
+{
+ DictionaryEntry* pEntry=0;
+ SvLBoxEntry* pLBEntry = GetEntryOnPos( nPos );
+ if(pLBEntry)
+ pEntry = (DictionaryEntry*)pLBEntry->GetUserData();
+ return pEntry;
+}
+
+DictionaryEntry* DictionaryList::getTermEntry( const rtl::OUString& rTerm ) const
+{
+ DictionaryEntry* pE = 0;
+ for( sal_Int32 nN=GetRowCount(); nN--; )
+ {
+ pE = getEntryOnPos( nN );
+ if( pE && rTerm.equals( pE->m_aTerm ) )
+ return pE;
+ }
+ return 0;
+}
+
+bool DictionaryList::hasTerm( const rtl::OUString& rTerm ) const
+{
+ return getTermEntry(rTerm) !=0 ;
+}
+
+void DictionaryList::addEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping
+ , sal_Int16 nConversionPropertyType, ULONG nPos )
+{
+ if( hasTerm( rTerm ) )
+ return;
+
+ DictionaryEntry* pEntry = new DictionaryEntry( rTerm, rMapping, nConversionPropertyType, sal_True );
+ SvLBoxEntry* pLBEntry = InsertEntryToColumn( makeTabString( *pEntry ), nPos );
+ pLBEntry->SetUserData( pEntry );
+ SelectRow( GetEntryPos( pLBEntry ) );
+}
+
+void DictionaryList::deleteEntryOnPos( sal_Int32 nPos )
+{
+ SvLBoxEntry* pLBEntry = GetEntryOnPos( nPos );
+ DictionaryEntry* pEntry = getEntryOnPos( nPos );
+ if( pLBEntry )
+ RemoveParentKeepChilds( pLBEntry );
+ if( pEntry )
+ {
+ if( pEntry->m_bNewEntry )
+ delete pEntry;
+ else
+ m_aToBeDeleted.push_back( pEntry );
+ }
+}
+
+ULONG DictionaryList::deleteEntries( const rtl::OUString& rTerm )
+{
+ ULONG nPos = LIST_APPEND;
+ for( sal_Int32 nN=GetRowCount(); nN--; )
+ {
+ DictionaryEntry* pCurEntry = getEntryOnPos( nN );
+ if( rTerm.equals( pCurEntry->m_aTerm ) )
+ {
+ nPos = nN;
+ SvLBoxEntry* pCurLBEntry = GetEntryOnPos( nN );
+ RemoveParentKeepChilds( pCurLBEntry );
+ if( pCurEntry->m_bNewEntry )
+ delete pCurEntry;
+ else
+ m_aToBeDeleted.push_back( pCurEntry );
+ }
+ }
+ return nPos;
+}
+
+DictionaryList::~DictionaryList()
+{
+}
+
+void DictionaryList::activate( HeaderBar* pHeaderBar )
+{
+ if(!m_pHeaderBar)
+ {
+ m_pHeaderBar = pHeaderBar;
+
+ Point aPos = GetPosPixel();
+ Size aSize = GetSizePixel();
+ Size aHeadSize = pHeaderBar->GetSizePixel();
+
+ aPos.Y() += aHeadSize.Height();
+ SetPosSizePixel( aPos, Size( aSize.Width(), aSize.Height() - aHeadSize.Height() ) );
+ InitHeaderBar( pHeaderBar );
+ }
+ Show();
+}
+
+HeaderBar* DictionaryList::createHeaderBar( const String& rColumn1, const String& rColumn2, const String& rColumn3
+ , long nWidth1, long nWidth2, long nWidth3 )
+{
+ HeaderBar* pHeaderBar = new HeaderBar( Control::GetParent(), WB_BUTTONSTYLE | WB_BOTTOMBORDER );
+ pHeaderBar->SetPosSizePixel( GetPosPixel(), pHeaderBar->CalcWindowSizePixel() );
+
+ HeaderBarItemBits nBits = HEADER_BAR_BITS;
+ pHeaderBar->InsertItem( 1, rColumn1, nWidth1, nBits | HIB_UPARROW );
+ pHeaderBar->InsertItem( 2, rColumn2, nWidth2, nBits );
+ pHeaderBar->InsertItem( 3, rColumn3, nWidth3, nBits );
+
+ pHeaderBar->Show();
+ return pHeaderBar;
+}
+
+void DictionaryList::Resize()
+{
+ SvHeaderTabListBox::Resize();
+ Size aBoxSize = GetOutputSizePixel();
+
+ if ( !aBoxSize.Width() )
+ return;
+
+ Size aBarSize = m_pHeaderBar->GetSizePixel();
+ aBarSize.Width() = GetSizePixel().Width();
+ m_pHeaderBar->SetSizePixel( aBarSize );
+}
+
+void DictionaryList::sortByColumn( USHORT nSortColumnIndex, bool bSortAtoZ )
+{
+ m_nSortColumnIndex=nSortColumnIndex;
+ if( nSortColumnIndex<3 )
+ {
+ if(bSortAtoZ)
+ GetModel()->SetSortMode(SortAscending);
+ else
+ GetModel()->SetSortMode(SortDescending);
+
+ GetModel()->SetCompareHdl( LINK( this, DictionaryList, CompareHdl));
+ GetModel()->Resort();
+ }
+ else
+ GetModel()->SetSortMode(SortNone);
+}
+
+USHORT DictionaryList::getSortColumn() const
+{
+ return m_nSortColumnIndex;
+}
+
+IMPL_LINK( DictionaryList, CompareHdl, SvSortData*, pData )
+{
+ SvLBoxEntry* pLeft = (SvLBoxEntry*)(pData->pLeft );
+ SvLBoxEntry* pRight = (SvLBoxEntry*)(pData->pRight );
+ return (long) ColumnCompare(pLeft,pRight);
+}
+
+StringCompare DictionaryList::ColumnCompare( SvLBoxEntry* pLeft, SvLBoxEntry* pRight )
+{
+ StringCompare eCompare=COMPARE_EQUAL;
+
+ SvLBoxItem* pLeftItem = getItemAtColumn( pLeft, m_nSortColumnIndex );
+ SvLBoxItem* pRightItem = getItemAtColumn( pRight, m_nSortColumnIndex );
+
+ if(pLeftItem != NULL && pRightItem != NULL)
+ {
+ USHORT nLeftKind=pLeftItem->IsA();
+ USHORT nRightKind=pRightItem->IsA();
+
+ if(nRightKind == SV_ITEM_ID_LBOXSTRING &&
+ nLeftKind == SV_ITEM_ID_LBOXSTRING )
+ {
+ IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
+ const CollatorWrapper* pCollator = aIntlWrapper.getCaseCollator();
+
+ eCompare=(StringCompare)pCollator->compareString( ((SvLBoxString*)pLeftItem)->GetText(),
+ ((SvLBoxString*)pRightItem)->GetText());
+
+ if(eCompare==COMPARE_EQUAL)
+ eCompare=COMPARE_LESS;
+ }
+ }
+ return eCompare;
+}
+
+SvLBoxItem* DictionaryList::getItemAtColumn( SvLBoxEntry* pEntry, USHORT nColumn ) const
+{
+ SvLBoxItem* pItem = NULL;
+ if( pEntry )
+ {
+ USHORT nCount = pEntry->ItemCount();
+ nColumn++;
+ if( nTreeFlags & TREEFLAG_CHKBTN )
+ nColumn++;
+ if( nColumn < nCount )
+ pItem = pEntry->GetItem( nColumn );
+ }
+ return pItem;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
+DictionaryEntry::DictionaryEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping
+ , sal_Int16 nConversionPropertyType
+ , sal_Bool bNewEntry )
+ : m_aTerm( rTerm )
+ , m_aMapping( rMapping )
+ , m_nConversionPropertyType( nConversionPropertyType )
+ , m_bNewEntry( bNewEntry )
+{
+ if( m_nConversionPropertyType == 0 )
+ m_nConversionPropertyType = 1;
+}
+
+DictionaryEntry::~DictionaryEntry()
+{
+}
+
+bool DictionaryEntry::operator==( const DictionaryEntry& rE ) const
+{
+ return m_aTerm == rE.m_aTerm
+ && m_aMapping == rE.m_aMapping
+ && m_nConversionPropertyType == rE.m_nConversionPropertyType;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
+ChineseDictionaryDialog::ChineseDictionaryDialog( Window* pParent )
+ : ModalDialog( pParent, TextConversionDlgs_ResId( DLG_CHINESEDICTIONARY ) )
+ , m_nTextConversionOptions( i18n::TextConversionOption::NONE )
+ , m_aRB_To_Simplified( this, TextConversionDlgs_ResId( RB_TO_SIMPLIFIED ) )
+ , m_aRB_To_Traditional( this, TextConversionDlgs_ResId( RB_TO_TRADITIONAL ) )
+ , m_aCB_Reverse( this, TextConversionDlgs_ResId( CB_REVERSE ) )
+ , m_aFT_Term( this, TextConversionDlgs_ResId( FT_TERM ) )
+ , m_aED_Term( this, TextConversionDlgs_ResId( ED_TERM ) )
+ , m_aFT_Mapping( this, TextConversionDlgs_ResId( FT_MAPPING ) )
+ , m_aED_Mapping( this, TextConversionDlgs_ResId( ED_MAPPING ) )
+ , m_aFT_Property( this, TextConversionDlgs_ResId( FT_PROPERTY ) )
+ , m_aLB_Property( this, TextConversionDlgs_ResId( LB_PROPERTY ) )
+ , m_pHeaderBar( 0 )
+ , m_aCT_DictionaryToSimplified( this, TextConversionDlgs_ResId( CT_MAPPINGLIST ) )
+ , m_aCT_DictionaryToTraditional( this )
+ , m_aPB_Add( this, TextConversionDlgs_ResId( PB_ADD ) )
+ , m_aPB_Modify( this, TextConversionDlgs_ResId( PB_MODIFY ) )
+ , m_aPB_Delete( this, TextConversionDlgs_ResId( PB_DELETE ) )
+ , m_aFL_Bottomline( this, TextConversionDlgs_ResId( FL_BOTTOMLINE ) )
+ , m_aBP_OK( this, TextConversionDlgs_ResId( PB_OK ) )
+ , m_aBP_Cancel( this, TextConversionDlgs_ResId( PB_CANCEL ) )
+ , m_aBP_Help( this, TextConversionDlgs_ResId( PB_HELP ) )
+ , m_xContext( 0 )
+ , m_xFactory( 0 )
+{
+ FreeResource();
+
+ m_aRB_To_Simplified.SetHelpId( HID_SVX_CHINESE_DICTIONARY_RB_CONVERSION_TO_SIMPLIFIED );
+ m_aRB_To_Traditional.SetHelpId( HID_SVX_CHINESE_DICTIONARY_RB_CONVERSION_TO_TRADITIONAL );
+
+ m_aCB_Reverse.SetHelpId( HID_SVX_CHINESE_DICTIONARY_CB_REVERSE );
+
+ m_aCT_DictionaryToSimplified.SetHelpId( HID_SVX_CHINESE_DICTIONARY_LB_TO_SIMPLIFIED );
+ m_aCT_DictionaryToTraditional.SetHelpId( HID_SVX_CHINESE_DICTIONARY_LB_TO_TRADITIONAL );
+
+ SvtLinguConfig aLngCfg;
+ sal_Bool bValue = sal_Bool();
+ Any aAny( aLngCfg.GetProperty( rtl::OUString::createFromAscii( UPN_IS_REVERSE_MAPPING ) ) );
+ if( aAny >>= bValue )
+ m_aCB_Reverse.Check( bValue );
+
+ m_aLB_Property.SetDropDownLineCount( m_aLB_Property.GetEntryCount() );
+ m_aLB_Property.SelectEntryPos(0);
+
+ Reference< linguistic2::XConversionDictionary > xDictionary_To_Simplified(0);
+ Reference< linguistic2::XConversionDictionary > xDictionary_To_Traditional(0);
+ //get dictionaries
+ {
+ if(!m_xContext.is())
+ m_xContext = Reference< XComponentContext >( ::cppu::defaultBootstrap_InitialComponentContext() );
+ if(m_xContext.is())
+ m_xFactory = Reference< lang::XMultiComponentFactory >( m_xContext->getServiceManager() );
+ if(m_xFactory.is())
+ {
+ Reference< linguistic2::XConversionDictionaryList > xDictionaryList(
+ m_xFactory->createInstanceWithContext(
+ rtl::OUString::createFromAscii("com.sun.star.linguistic2.ConversionDictionaryList")
+ , m_xContext), uno::UNO_QUERY);
+ if( xDictionaryList.is() )
+ {
+ Reference< container::XNameContainer > xContainer( xDictionaryList->getDictionaryContainer() );
+ if(xContainer.is())
+ {
+ try
+ {
+ rtl::OUString aNameTo_Simplified( rtl::OUString::createFromAscii("ChineseT2S") );
+ rtl::OUString aNameTo_Traditional( rtl::OUString::createFromAscii("ChineseS2T") );
+ lang::Locale aLocale;
+ aLocale.Language = rtl::OUString::createFromAscii("zh");
+
+ if( xContainer->hasByName( aNameTo_Simplified ) )
+ xDictionary_To_Simplified = Reference< linguistic2::XConversionDictionary >(
+ xContainer->getByName( aNameTo_Simplified ), UNO_QUERY );
+ else
+ {
+ aLocale.Country = rtl::OUString::createFromAscii("TW");
+ xDictionary_To_Simplified = Reference< linguistic2::XConversionDictionary >(
+ xDictionaryList->addNewDictionary( aNameTo_Simplified
+ , aLocale, linguistic2::ConversionDictionaryType::SCHINESE_TCHINESE
+ ), UNO_QUERY );
+ }
+ if (xDictionary_To_Simplified.is())
+ xDictionary_To_Simplified->setActive( sal_True );
+
+
+ if( xContainer->hasByName( aNameTo_Traditional ) )
+ xDictionary_To_Traditional = Reference< linguistic2::XConversionDictionary >(
+ xContainer->getByName( aNameTo_Traditional ), UNO_QUERY );
+ else
+ {
+ aLocale.Country = rtl::OUString::createFromAscii("CN");
+ xDictionary_To_Traditional = Reference< linguistic2::XConversionDictionary >(
+ xDictionaryList->addNewDictionary( aNameTo_Traditional
+ , aLocale, linguistic2::ConversionDictionaryType::SCHINESE_TCHINESE
+ ), UNO_QUERY );
+ }
+ if (xDictionary_To_Traditional.is())
+ xDictionary_To_Traditional->setActive( sal_True );
+
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ }
+ }
+ }
+
+ //init HeaderBar and set tabs
+ {
+ String aColumn1( OutputDevice::GetNonMnemonicString( m_aFT_Term.GetText() ) );
+ String aColumn2( OutputDevice::GetNonMnemonicString( m_aFT_Mapping.GetText() ) );
+ String aColumn3( OutputDevice::GetNonMnemonicString( m_aFT_Property.GetText() ) );
+
+ long nWidth1 = m_aED_Mapping.GetPosPixel().X() - m_aED_Term.GetPosPixel().X();
+ long nWidth2 = m_aLB_Property.GetPosPixel().X() - m_aED_Mapping.GetPosPixel().X();
+ long nWidth3 = m_aLB_Property.GetSizePixel().Width();
+
+ m_pHeaderBar = m_aCT_DictionaryToSimplified.createHeaderBar( aColumn1, aColumn2, aColumn3, nWidth1, nWidth2, nWidth3 );
+ if(m_pHeaderBar)
+ m_pHeaderBar->SetHelpId( HID_SVX_CHINESE_DICTIONARY_LB_HEADER );
+
+ long pTabs[] = { 3, 0, nWidth1, nWidth1 + nWidth2 };
+ m_aCT_DictionaryToSimplified.SetTabs( &pTabs[0], MAP_PIXEL );
+ m_aCT_DictionaryToTraditional.SetTabs( &pTabs[0], MAP_PIXEL );
+ }
+
+ //init dictionary controls
+ m_aCT_DictionaryToTraditional.SetPosPixel( m_aCT_DictionaryToSimplified.GetPosPixel() );
+ m_aCT_DictionaryToTraditional.SetSizePixel( m_aCT_DictionaryToSimplified.GetSizePixel() );
+
+ m_aCT_DictionaryToSimplified.initDictionaryControl( xDictionary_To_Simplified, &m_aLB_Property );
+ m_aCT_DictionaryToTraditional.initDictionaryControl( xDictionary_To_Traditional, &m_aLB_Property );
+
+ //
+ updateAfterDirectionChange();
+
+ //set hdl
+ if(m_pHeaderBar)
+ m_pHeaderBar->SetSelectHdl( LINK( this, ChineseDictionaryDialog, HeaderBarClick ) );
+
+ m_aED_Term.SetModifyHdl( LINK( this, ChineseDictionaryDialog, EditFieldsHdl ) );
+ m_aED_Mapping.SetModifyHdl( LINK( this, ChineseDictionaryDialog, EditFieldsHdl ) );
+ m_aLB_Property.SetSelectHdl( LINK( this, ChineseDictionaryDialog, EditFieldsHdl ) );
+
+ m_aRB_To_Simplified.SetClickHdl( LINK( this, ChineseDictionaryDialog, DirectionHdl ) );
+ m_aRB_To_Traditional.SetClickHdl( LINK( this, ChineseDictionaryDialog, DirectionHdl ) );
+
+ m_aCT_DictionaryToSimplified.SetSelectHdl( LINK( this, ChineseDictionaryDialog, MappingSelectHdl ));
+ m_aCT_DictionaryToTraditional.SetSelectHdl( LINK( this, ChineseDictionaryDialog, MappingSelectHdl ));
+
+ m_aPB_Add.SetClickHdl( LINK( this, ChineseDictionaryDialog, AddHdl ) );
+ m_aPB_Modify.SetClickHdl( LINK( this, ChineseDictionaryDialog, ModifyHdl ) );
+ m_aPB_Delete.SetClickHdl( LINK( this, ChineseDictionaryDialog, DeleteHdl ) );
+}
+
+ChineseDictionaryDialog::~ChineseDictionaryDialog()
+{
+ m_xContext=0;
+ m_xFactory=0;
+ delete m_pHeaderBar;
+}
+
+void ChineseDictionaryDialog::setDirectionAndTextConversionOptions( bool bDirectionToSimplified, sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ )
+{
+ if( bDirectionToSimplified == bool(m_aRB_To_Simplified.IsChecked())
+ && nTextConversionOptions == m_nTextConversionOptions )
+ return;
+
+ m_nTextConversionOptions = nTextConversionOptions;
+
+ if( bDirectionToSimplified )
+ m_aRB_To_Simplified.Check();
+ else
+ m_aRB_To_Traditional.Check();
+ updateAfterDirectionChange();
+}
+
+IMPL_LINK( ChineseDictionaryDialog, DirectionHdl, void*, EMPTYARG )
+{
+ updateAfterDirectionChange();
+ return 0;
+}
+
+void ChineseDictionaryDialog::updateAfterDirectionChange()
+{
+ Reference< linguistic2::XConversionDictionary > xDictionary(0);
+
+ if( m_aRB_To_Simplified.IsChecked() )
+ {
+ m_aCT_DictionaryToSimplified.activate( m_pHeaderBar );
+ m_aCT_DictionaryToTraditional.Hide();
+ xDictionary = m_aCT_DictionaryToSimplified.m_xDictionary;
+ }
+ else
+ {
+ m_aCT_DictionaryToTraditional.activate( m_pHeaderBar );
+ m_aCT_DictionaryToSimplified.Hide();
+ xDictionary = m_aCT_DictionaryToTraditional.m_xDictionary;
+ }
+
+ updateButtons();
+}
+
+IMPL_LINK( ChineseDictionaryDialog, EditFieldsHdl, Control*, EMPTYARG )
+{
+ updateButtons();
+ return 0;
+}
+IMPL_LINK( ChineseDictionaryDialog, MappingSelectHdl, void*, EMPTYARG )
+{
+ DictionaryEntry* pE = getActiveDictionary().getFirstSelectedEntry();
+ if(pE)
+ {
+ m_aED_Term.SetText( pE->m_aTerm );
+ m_aED_Mapping.SetText( pE->m_aMapping );
+ sal_Int16 nPos = pE->m_nConversionPropertyType-1;
+ if( nPos<0 || nPos>=m_aLB_Property.GetEntryCount() )
+ nPos=0;
+ if( m_aLB_Property.GetEntryCount() )
+ m_aLB_Property.SelectEntryPos(nPos);
+ }
+
+ updateButtons();
+ return 0;
+}
+
+bool ChineseDictionaryDialog::isEditFieldsHaveContent() const
+{
+ return m_aED_Term.GetText().Len() && m_aED_Mapping.GetText().Len();
+}
+
+bool ChineseDictionaryDialog::isEditFieldsContentEqualsSelectedListContent() const
+{
+ DictionaryEntry* pE = getActiveDictionary().getFirstSelectedEntry();
+ if( pE )
+ {
+ if( pE->m_aTerm != rtl::OUString( m_aED_Term.GetText() ) )
+ return false;
+ if( pE->m_aMapping != rtl::OUString( m_aED_Mapping.GetText() ) )
+ return false;
+ if( pE->m_nConversionPropertyType != m_aLB_Property.GetSelectEntryPos()+1 )
+ return false;
+ return true;
+ }
+ return false;
+}
+
+const DictionaryList& ChineseDictionaryDialog::getActiveDictionary() const
+{
+ if( m_aRB_To_Traditional.IsChecked() )
+ return m_aCT_DictionaryToTraditional;
+ return m_aCT_DictionaryToSimplified;
+}
+
+DictionaryList& ChineseDictionaryDialog::getActiveDictionary()
+{
+ if( m_aRB_To_Traditional.IsChecked() )
+ return m_aCT_DictionaryToTraditional;
+ return m_aCT_DictionaryToSimplified;
+}
+
+const DictionaryList& ChineseDictionaryDialog::getReverseDictionary() const
+{
+ if( m_aRB_To_Traditional.IsChecked() )
+ return m_aCT_DictionaryToSimplified;
+ return m_aCT_DictionaryToTraditional;
+}
+
+DictionaryList& ChineseDictionaryDialog::getReverseDictionary()
+{
+ if( m_aRB_To_Traditional.IsChecked() )
+ return m_aCT_DictionaryToSimplified;
+ return m_aCT_DictionaryToTraditional;
+}
+
+void ChineseDictionaryDialog::updateButtons()
+{
+ bool bAdd = isEditFieldsHaveContent() && !getActiveDictionary().hasTerm( m_aED_Term.GetText() );
+ m_aPB_Add.Enable( bAdd );
+
+ m_aPB_Delete.Enable( !bAdd && getActiveDictionary().GetSelectedRowCount()>0 );
+
+// DictionaryEntry* pFirstSelectedEntry = getActiveDictionary().getFirstSelectedEntry();
+
+ bool bModify = false;
+ {
+ DictionaryEntry* pFirstSelectedEntry = getActiveDictionary().getFirstSelectedEntry();
+ bModify = !bAdd && getActiveDictionary().GetSelectedRowCount()==1
+ && pFirstSelectedEntry && pFirstSelectedEntry->m_aTerm.equals( m_aED_Term.GetText() );
+ if( bModify && isEditFieldsContentEqualsSelectedListContent() )
+ bModify = false;
+ }
+ m_aPB_Modify.Enable( bModify );
+}
+
+IMPL_LINK( ChineseDictionaryDialog, AddHdl, void*, EMPTYARG )
+{
+ if( !isEditFieldsHaveContent() )
+ return 0;
+
+ sal_Int16 nConversionPropertyType = m_aLB_Property.GetSelectEntryPos()+1;
+
+ getActiveDictionary().addEntry( m_aED_Term.GetText(), m_aED_Mapping.GetText(), nConversionPropertyType );
+
+ if( m_aCB_Reverse.IsChecked() )
+ {
+ getReverseDictionary().deleteEntries( m_aED_Mapping.GetText() );
+ getReverseDictionary().addEntry( m_aED_Mapping.GetText(), m_aED_Term.GetText(), nConversionPropertyType );
+ }
+
+ updateButtons();
+ return 0;
+}
+IMPL_LINK( ChineseDictionaryDialog, ModifyHdl, void*, EMPTYARG )
+{
+ rtl::OUString aTerm( m_aED_Term.GetText() );
+ rtl::OUString aMapping( m_aED_Mapping.GetText() );
+ sal_Int16 nConversionPropertyType = m_aLB_Property.GetSelectEntryPos()+1;
+
+ DictionaryList& rActive = getActiveDictionary();
+ DictionaryList& rReverse = getReverseDictionary();
+
+ DictionaryEntry* pE = rActive.getFirstSelectedEntry();
+ if( pE->m_aTerm != aTerm )
+ return 0;
+
+ if( pE )
+ {
+ if( pE->m_aMapping != aMapping || pE->m_nConversionPropertyType != nConversionPropertyType )
+ {
+ if( m_aCB_Reverse.IsChecked() )
+ {
+ ULONG nPos = rReverse.deleteEntries( pE->m_aMapping );
+ nPos = rReverse.deleteEntries( aMapping );
+ rReverse.addEntry( aMapping, aTerm, nConversionPropertyType, nPos );
+ }
+
+ ULONG nPos = rActive.deleteEntries( aTerm );
+ rActive.addEntry( aTerm, aMapping, nConversionPropertyType, nPos );
+ }
+ }
+
+ updateButtons();
+ return 0;
+}
+
+IMPL_LINK( ChineseDictionaryDialog, DeleteHdl, void*, EMPTYARG )
+{
+ DictionaryList& rActive = getActiveDictionary();
+ DictionaryList& rReverse = getReverseDictionary();
+
+ if( rActive.GetSelectedRowCount()>0)
+ {
+ DictionaryEntry* pEntry;
+
+ rtl::OUString aMapping;
+ for( sal_Int32 nN=rActive.GetRowCount(); nN--; )
+ {
+ if( rActive.IsRowSelected( nN ) )
+ {
+ pEntry = rActive.getEntryOnPos( nN );
+ if(pEntry)
+ {
+ aMapping = pEntry->m_aMapping;
+ rActive.deleteEntryOnPos( nN );
+ if( m_aCB_Reverse.IsChecked() )
+ rReverse.deleteEntries( aMapping );
+ }
+ break;
+ }
+ }
+ }
+
+ updateButtons();
+ return 0;
+}
+
+short ChineseDictionaryDialog::Execute()
+{
+ sal_Int32 nTextConversionOptions = m_nTextConversionOptions;
+ if(m_nTextConversionOptions | i18n::TextConversionOption::USE_CHARACTER_VARIANTS )
+ nTextConversionOptions = nTextConversionOptions^i18n::TextConversionOption::USE_CHARACTER_VARIANTS ;
+
+ m_aCT_DictionaryToSimplified.refillFromDictionary( nTextConversionOptions );
+ m_aCT_DictionaryToTraditional.refillFromDictionary( m_nTextConversionOptions );
+
+ short nRet = ModalDialog::Execute();
+
+ if( nRet == RET_OK )
+ {
+ //save settings to configuration
+ SvtLinguConfig aLngCfg;
+ Any aAny;
+ aAny <<= sal_Bool( !!m_aCB_Reverse.IsChecked() );
+ aLngCfg.SetProperty( rtl::OUString::createFromAscii( UPN_IS_REVERSE_MAPPING ), aAny );
+
+ m_aCT_DictionaryToSimplified.save();
+ m_aCT_DictionaryToTraditional.save();
+ }
+
+ m_aCT_DictionaryToSimplified.deleteAll();
+ m_aCT_DictionaryToTraditional.deleteAll();
+
+ return nRet;
+}
+
+IMPL_LINK( ChineseDictionaryDialog, HeaderBarClick, void*, EMPTYARG )
+{
+ if(m_pHeaderBar)
+ {
+ USHORT nId = m_pHeaderBar->GetCurItemId();
+ HeaderBarItemBits nBits = m_pHeaderBar->GetItemBits(nId);
+ if( nBits & HIB_CLICKABLE )
+ {
+ //set new arrow positions in headerbar
+ m_pHeaderBar->SetItemBits( getActiveDictionary().getSortColumn()+1, HEADER_BAR_BITS );
+ if( nBits & HIB_UPARROW )
+ m_pHeaderBar->SetItemBits( nId, HEADER_BAR_BITS | HIB_DOWNARROW );
+ else
+ m_pHeaderBar->SetItemBits( nId, HEADER_BAR_BITS | HIB_UPARROW );
+
+ //sort lists
+ nBits = m_pHeaderBar->GetItemBits(nId);
+ bool bSortAtoZ = nBits & HIB_UPARROW;
+ getActiveDictionary().sortByColumn(nId-1,bSortAtoZ);
+ getReverseDictionary().sortByColumn(nId-1,bSortAtoZ);
+ }
+ }
+ return 0;
+}
+
+//.............................................................................
+} //end namespace
+//.............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hrc b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hrc
new file mode 100644
index 000000000000..6ba634335f66
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hrc
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * 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 _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HRC
+#define _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HRC
+
+#include "resids.hrc"
+#include "buttongroup.hrc"
+#include "chinese_direction_ids.hrc"
+
+#define ED_TERM 1
+#define ED_MAPPING 2
+
+#define LB_PROPERTY 1
+
+#define CB_REVERSE 1
+
+#define FT_TERM 1
+#define FT_MAPPING 2
+#define FT_PROPERTY 3
+
+#define CT_MAPPINGLIST 1
+
+#define PB_ADD 1
+#define PB_MODIFY 2
+#define PB_DELETE 3
+
+#define FL_BOTTOMLINE 1
+
+#endif
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hxx b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hxx
new file mode 100644
index 000000000000..3f97c1df8a1c
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.hxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HXX
+#define _TEXTCONVERSIONDLGS_CHINESE_DICTIONARYDLG_HXX
+
+#include <vcl/dialog.hxx>
+// header for class FixedLine
+#include <vcl/fixed.hxx>
+// header for class RadioButton
+#include <vcl/button.hxx>
+// header for class Edit
+#include <vcl/edit.hxx>
+// header for class ListBox
+#include <vcl/lstbox.hxx>
+// header for class SvHeaderTabListBox
+#include <svtools/svtabbx.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/linguistic2/XConversionDictionary.hpp>
+
+#include <vector>
+
+//.............................................................................
+namespace textconversiondlgs
+{
+//.............................................................................
+
+//-----------------------------------------------------------------------------
+/**
+*/
+
+struct DictionaryEntry
+{
+ DictionaryEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping
+ , sal_Int16 nConversionPropertyType //linguistic2::ConversionPropertyType
+ , sal_Bool bNewEntry = sal_False );
+
+ virtual ~DictionaryEntry();
+
+ bool operator==( const DictionaryEntry& rE ) const;
+
+ rtl::OUString m_aTerm;
+ rtl::OUString m_aMapping;
+ sal_Int16 m_nConversionPropertyType; //linguistic2::ConversionPropertyType
+
+ sal_Bool m_bNewEntry;
+};
+
+class DictionaryList : public SvHeaderTabListBox
+{
+public:
+ DictionaryList( Window* pParent, const ResId& );
+ DictionaryList( Window* pParent );
+ virtual ~DictionaryList();
+
+ HeaderBar* createHeaderBar( const String& rColumn1, const String& rColumn2, const String& rColumn3
+ , long nWidth1, long nWidth2, long nWidth3 );
+
+ void initDictionaryControl( const ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XConversionDictionary>& xDictionary
+ , ListBox* pPropertyTypeNameListBox );
+ void activate( HeaderBar* pHeaderBar );
+ void deleteAll();
+ void refillFromDictionary( sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
+ void save();
+
+ DictionaryEntry* getTermEntry( const rtl::OUString& rTerm ) const;
+ bool hasTerm( const rtl::OUString& rTerm ) const;
+
+ void addEntry( const rtl::OUString& rTerm, const rtl::OUString& rMapping
+ , sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/, ULONG nPos = LIST_APPEND );
+ ULONG deleteEntries( const rtl::OUString& rTerm ); //return lowest position of deleted entries or LIST_APPEND if no entry was deleted
+ void deleteEntryOnPos( sal_Int32 nPos );
+ DictionaryEntry* getEntryOnPos( sal_Int32 nPos ) const;
+ DictionaryEntry* getFirstSelectedEntry() const;
+
+ void sortByColumn( USHORT nSortColumnIndex, bool bSortAtoZ );
+ USHORT getSortColumn() const;
+
+ virtual void Resize();
+
+private:
+ String getPropertyTypeName( sal_Int16 nConversionPropertyType /*linguistic2::ConversionPropertyType*/ ) const;
+ String makeTabString( const DictionaryEntry& rEntry ) const;
+
+ DECL_LINK( CompareHdl, SvSortData* );
+ StringCompare ColumnCompare( SvLBoxEntry* pLeft, SvLBoxEntry* pRight );
+ SvLBoxItem* getItemAtColumn( SvLBoxEntry* pEntry, USHORT nColumn ) const;
+
+public:
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::linguistic2::XConversionDictionary> m_xDictionary;
+
+private:
+ HeaderBar* m_pHeaderBar;
+ ListBox* m_pPropertyTypeNameListBox;
+
+ std::vector< DictionaryEntry* > m_aToBeDeleted;
+
+ USHORT m_nSortColumnIndex;
+};
+
+class ChineseDictionaryDialog : public ModalDialog
+{
+public:
+ ChineseDictionaryDialog( Window* pParent );
+ virtual ~ChineseDictionaryDialog();
+
+ //this method should be called once before calling execute
+ void setDirectionAndTextConversionOptions( bool bDirectionToSimplified, sal_Int32 nTextConversionOptions /*i18n::TextConversionOption*/ );
+
+ virtual short Execute();
+
+private:
+ DECL_LINK( DirectionHdl, void* );
+ DECL_LINK( EditFieldsHdl, Control* );
+ DECL_LINK( MappingSelectHdl, void* );
+ DECL_LINK( AddHdl, void* );
+ DECL_LINK( ModifyHdl, void* );
+ DECL_LINK( DeleteHdl, void* );
+ DECL_LINK( HeaderBarClick, void* );
+
+ void updateAfterDirectionChange();
+ void updateButtons();
+
+ bool isEditFieldsHaveContent() const;
+ bool isEditFieldsContentEqualsSelectedListContent() const;
+
+ DictionaryList& getActiveDictionary();
+ DictionaryList& getReverseDictionary();
+
+ const DictionaryList& getActiveDictionary() const;
+ const DictionaryList& getReverseDictionary() const;
+
+private:
+ sal_Int32 m_nTextConversionOptions; //i18n::TextConversionOption
+
+ RadioButton m_aRB_To_Simplified;
+ RadioButton m_aRB_To_Traditional;
+
+ CheckBox m_aCB_Reverse;
+
+ FixedText m_aFT_Term;
+ Edit m_aED_Term;
+
+ FixedText m_aFT_Mapping;
+ Edit m_aED_Mapping;
+
+ FixedText m_aFT_Property;
+ ListBox m_aLB_Property;
+
+ HeaderBar* m_pHeaderBar;
+ DictionaryList m_aCT_DictionaryToSimplified;
+ DictionaryList m_aCT_DictionaryToTraditional;
+
+ PushButton m_aPB_Add;
+ PushButton m_aPB_Modify;
+ PushButton m_aPB_Delete;
+
+ FixedLine m_aFL_Bottomline;
+
+ OKButton m_aBP_OK;
+ CancelButton m_aBP_Cancel;
+ HelpButton m_aBP_Help;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XMultiComponentFactory> m_xFactory;
+};
+
+//.............................................................................
+} //end namespace
+//.............................................................................
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.src b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.src
new file mode 100644
index 000000000000..2a0c9b2f28b7
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_dictionarydialog.src
@@ -0,0 +1,184 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "chinese_dictionarydialog.hrc"
+#include "chinese_direction.hrc"
+
+#ifndef _SVT_CONTROLDIMS_HRC_
+#include <svtools/controldims.hrc>
+#endif
+
+//-----------------------------------------------------------------------------
+//defines for positions and sizes:
+
+#define FULL_WIDTH (245)
+#define FULL_HEIGHT (165)
+
+#define ROW_1 (RSC_SP_DLG_INNERBORDER_TOP)
+#define ROW_2 (ROW_1+RSC_CD_RADIOBUTTON_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define ROW_3 (ROW_2+RSC_CD_RADIOBUTTON_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define ROW_4 (ROW_3+RSC_CD_CHECKBOX_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define ROW_5 (ROW_4+RSC_CD_FIXEDTEXT_HEIGHT+RSC_SP_CTRL_DESC_Y)
+#define ROW_6 (ROW_5+RSC_CD_TEXTBOX_HEIGHT+RSC_SP_CTRL_DESC_Y)
+
+#define ROW_5a (ROW_5+RSC_CD_PUSHBUTTON_HEIGHT+RSC_SP_CTRL_DESC_Y)
+#define ROW_5b (ROW_5a+RSC_CD_PUSHBUTTON_HEIGHT+RSC_SP_CTRL_DESC_Y)
+
+#define ROW_8 (FULL_HEIGHT-RSC_SP_DLG_INNERBORDER_BOTTOM-RSC_CD_PUSHBUTTON_HEIGHT)
+#define ROW_7 (ROW_8-RSC_CD_FIXEDLINE_HEIGHT-2)
+
+#define LIST_HEIGHT (ROW_7-RSC_SP_CTRL_Y-ROW_6)
+
+#define COL_WIDTH 60
+#define BUTTONCOL_WIDTH 40
+#define COL_1 (RSC_SP_DLG_INNERBORDER_LEFT+RSC_SP_FLGR_SPACE_X)
+#define COL_2 (COL_1+COL_WIDTH+1)
+#define COL_3 (COL_2+COL_WIDTH+1)
+#define COL_4 (FULL_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT-BUTTONCOL_WIDTH)
+
+#define REST_COL_WIDTH (COL_4-COL_3-RSC_SP_CTRL_GROUP_X)
+
+//-----------------------------------------------------------------------------
+
+ModalDialog DLG_CHINESEDICTIONARY
+{
+ //HelpId = ;
+ Size = MAP_APPFONT( FULL_WIDTH, FULL_HEIGHT );
+ OutputSize = TRUE;
+ Closeable = TRUE ;
+ Moveable = TRUE ;
+ SVLook = TRUE;
+
+ Text [ en-US ] = "Edit Dictionary";
+
+ DIRECTION_RADIOBUTTONS( COL_1, ROW_1, FULL_WIDTH - COL_1 - RSC_SP_DLG_INNERBORDER_RIGHT )
+
+ CheckBox CB_REVERSE
+ {
+ Pos = MAP_APPFONT ( COL_1, ROW_3 ) ;
+ Size = MAP_APPFONT ( FULL_WIDTH - COL_1 - RSC_SP_DLG_INNERBORDER_RIGHT , RSC_CD_CHECKBOX_HEIGHT ) ;
+
+ Text [ en-US ] = "Reverse mapping";
+ };
+
+ FixedText FT_TERM
+ {
+ Pos = MAP_APPFONT ( COL_1 , ROW_4 ) ;
+ Size = MAP_APPFONT ( COL_WIDTH, RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Term";
+ };
+ Edit ED_TERM
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( COL_1 , ROW_5 ) ;
+ Size = MAP_APPFONT ( COL_WIDTH , RSC_CD_TEXTBOX_HEIGHT ) ;
+ };
+
+
+ FixedText FT_MAPPING
+ {
+ Pos = MAP_APPFONT ( COL_2 , ROW_4 ) ;
+ Size = MAP_APPFONT ( COL_WIDTH, RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Mapping";
+ };
+ Edit ED_MAPPING
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( COL_2 , ROW_5 ) ;
+ Size = MAP_APPFONT ( COL_WIDTH , RSC_CD_TEXTBOX_HEIGHT ) ;
+ };
+
+ FixedText FT_PROPERTY
+ {
+ Pos = MAP_APPFONT ( COL_3 , ROW_4 ) ;
+ Size = MAP_APPFONT ( REST_COL_WIDTH, RSC_CD_FIXEDTEXT_HEIGHT ) ;
+ Text [ en-US ] = "Property";
+ };
+ ListBox LB_PROPERTY
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( COL_3 , ROW_5 ) ;
+ Size = MAP_APPFONT ( REST_COL_WIDTH , RSC_CD_TEXTBOX_HEIGHT ) ;
+ DropDown = TRUE ;
+
+ stringlist [ en-US ] =
+ {
+ < "Other" ; Default ; > ;
+ < "Foreign" ; > ;
+ < "First name" ; > ;
+ < "Last name" ; > ;
+ < "Title" ; > ;
+ < "Status" ; > ;
+ < "Place name" ; > ;
+ < "Business" ; > ;
+ < "Adjective" ; > ;
+ < "Idiom" ; > ;
+ < "Abbreviation" ; > ;
+ < "Numerical" ; > ;
+ < "Noun" ; > ;
+ < "Verb" ; > ;
+ < "Brand name" ; > ;
+ };
+ };
+
+ Control CT_MAPPINGLIST
+ {
+ Pos = MAP_APPFONT ( COL_1, ROW_6 ) ;
+ Size = MAP_APPFONT ( COL_4 - COL_1 - RSC_SP_CTRL_GROUP_X, LIST_HEIGHT ) ;
+ TabStop = TRUE ;
+ };
+
+ PushButton PB_ADD
+ {
+ Pos = MAP_APPFONT( COL_4, ROW_5 );
+ Size = MAP_APPFONT( BUTTONCOL_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT );
+
+ Text [ en-US ] = "~Add";
+ };
+ PushButton PB_MODIFY
+ {
+ Pos = MAP_APPFONT( COL_4, ROW_5a );
+ Size = MAP_APPFONT( BUTTONCOL_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT );
+
+ Text [ en-US ] = "~Modify";
+ };
+ PushButton PB_DELETE
+ {
+ Pos = MAP_APPFONT( COL_4, ROW_5b );
+ Size = MAP_APPFONT( BUTTONCOL_WIDTH , RSC_CD_PUSHBUTTON_HEIGHT );
+
+ Text [ en-US ] = "~Delete";
+ };
+
+ FixedLine FL_BOTTOMLINE
+ {
+ Pos = MAP_APPFONT ( 0 , ROW_7 ) ;
+ Size = MAP_APPFONT ( FULL_WIDTH, RSC_CD_FIXEDLINE_HEIGHT ) ;
+ };
+
+ BUTTONS_OK_CANCEL_HELP_ABREAST( FULL_WIDTH - RSC_SP_DLG_INNERBORDER_RIGHT, ROW_8 )
+};
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_direction_ids.hrc b/svx/source/unodialogs/textconversiondlgs/chinese_direction_ids.hrc
new file mode 100644
index 000000000000..161add1e73a6
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_direction_ids.hrc
@@ -0,0 +1,34 @@
+/*************************************************************************
+ *
+ * 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 _TEXTCONVERSIONDLGS_CHINESE_DIRECTION_IDS_HXX
+#define _TEXTCONVERSIONDLGS_CHINESE_DIRECTION_IDS_HXX
+
+#define RB_TO_SIMPLIFIED 1
+#define RB_TO_TRADITIONAL 2
+
+#endif
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_direction_tmpl.hrc b/svx/source/unodialogs/textconversiondlgs/chinese_direction_tmpl.hrc
new file mode 100644
index 000000000000..956f6232a437
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_direction_tmpl.hrc
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * 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 _TEXTCONVERSIONDLGS_CHINESE_DIRECTION_HRC
+#define _TEXTCONVERSIONDLGS_CHINESE_DIRECTION_HRC
+
+#include "chinese_direction_ids.hrc"
+
+#ifndef _SVT_CONTROLDIMS_HRC_
+#include <svtools/controldims.hrc>
+#endif
+
+#define DIRECTION_RADIOBUTTONS( D_XPOS, D_YPOS, D_FULLWIDTH ) \
+RadioButton RB_TO_SIMPLIFIED \
+{ \
+ Pos = MAP_APPFONT( D_XPOS, D_YPOS ); \
+ Size = MAP_APPFONT ( D_FULLWIDTH, RSC_CD_RADIOBUTTON_HEIGHT ) ; \
+ Text [ en-US ] = "~Traditional Chinese to simplified Chinese"; \
+}; \
+RadioButton RB_TO_TRADITIONAL \
+{ \
+ Pos = MAP_APPFONT( D_XPOS, D_YPOS + RSC_CD_RADIOBUTTON_HEIGHT+RSC_SP_CTRL_GROUP_Y ); \
+ Size = MAP_APPFONT ( D_FULLWIDTH, RSC_CD_RADIOBUTTON_HEIGHT ) ; \
+ Text [ en-US ] = "~Simplified Chinese to traditional Chinese"; \
+};
+
+#endif
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx
new file mode 100644
index 000000000000..ce24a3af250f
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.cxx
@@ -0,0 +1,288 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "chinese_translation_unodialog.hxx"
+#include "chinese_translationdialog.hxx"
+#include <osl/mutex.hxx>
+#include <osl/mutex.hxx>
+// header for class Application
+#include <vcl/svapp.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+// header for define RET_CANCEL
+#include <vcl/msgbox.hxx>
+
+// header for class OImplementationId
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+
+//.............................................................................
+namespace textconversiondlgs
+{
+//.............................................................................
+using namespace ::com::sun::star;
+
+#define SERVICE_IMPLEMENTATION_NAME ::rtl::OUString::createFromAscii("com.sun.star.comp.linguistic2.ChineseTranslationDialog")
+#define SERVICE_NAME ::rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
+
+#define C2U(cChar) rtl::OUString::createFromAscii(cChar)
+
+ChineseTranslation_UnoDialog::ChineseTranslation_UnoDialog( const uno::Reference< uno::XComponentContext >& xContext )
+ : m_xCC( xContext )
+ , m_xParentWindow( 0 )
+ , m_pDialog( 0 )
+ , m_bDisposed(sal_False)
+ , m_bInDispose(sal_False)
+ , m_aContainerMutex()
+ , m_aDisposeEventListeners(m_aContainerMutex)
+{
+}
+
+ChineseTranslation_UnoDialog::~ChineseTranslation_UnoDialog()
+{
+ SolarMutexGuard aSolarGuard;
+ impl_DeleteDialog();
+}
+
+void ChineseTranslation_UnoDialog::impl_DeleteDialog()
+{
+ if( m_pDialog )
+ {
+ if(m_pDialog->IsInExecute())
+ m_pDialog->EndDialog(RET_CANCEL);
+ delete m_pDialog;
+ m_pDialog = 0;
+ }
+}
+//-------------------------------------------------------------------------
+// lang::XServiceInfo
+
+::rtl::OUString SAL_CALL ChineseTranslation_UnoDialog::getImplementationName() throw( uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+::rtl::OUString ChineseTranslation_UnoDialog::getImplementationName_Static()
+{
+ return SERVICE_IMPLEMENTATION_NAME;
+}
+
+sal_Bool SAL_CALL ChineseTranslation_UnoDialog::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
+{
+ uno::Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames();
+ const ::rtl::OUString* pArray = aSNL.getArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ {
+ if( pArray[ i ] == ServiceName )
+ return sal_True;
+ }
+ return sal_False;
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL ChineseTranslation_UnoDialog::getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+uno::Sequence< rtl::OUString > ChineseTranslation_UnoDialog::getSupportedServiceNames_Static()
+{
+ uno::Sequence< rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[ 0 ] = SERVICE_NAME;
+ return aSNS;
+}
+
+//-------------------------------------------------------------------------
+// ui::dialogs::XExecutableDialog
+
+void SAL_CALL ChineseTranslation_UnoDialog::setTitle( const ::rtl::OUString& ) throw(uno::RuntimeException)
+{
+ //not implemented - fell free to do so, if you do need this
+}
+
+//-------------------------------------------------------------------------
+void SAL_CALL ChineseTranslation_UnoDialog::initialize( const uno::Sequence< uno::Any >& aArguments ) throw(uno::Exception, uno::RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ if( m_bDisposed || m_bInDispose )
+ return;
+
+ const uno::Any* pArguments = aArguments.getConstArray();
+ for(sal_Int32 i=0; i<aArguments.getLength(); ++i, ++pArguments)
+ {
+ beans::PropertyValue aProperty;
+ if(*pArguments >>= aProperty)
+ {
+ if( aProperty.Name.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ParentWindow" ) ) == 0 )
+ {
+ aProperty.Value >>= m_xParentWindow;
+ }
+ }
+ }
+}
+
+//-------------------------------------------------------------------------
+sal_Int16 SAL_CALL ChineseTranslation_UnoDialog::execute() throw(uno::RuntimeException)
+{
+ sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
+ {
+ SolarMutexGuard aSolarGuard;
+ if( m_bDisposed || m_bInDispose )
+ return nRet;
+
+ if( !m_pDialog )
+ {
+ Window* pParent = NULL;
+ if( m_xParentWindow.is() )
+ {
+ VCLXWindow* pImplementation = VCLXWindow::GetImplementation(m_xParentWindow);
+ if (pImplementation)
+ pParent = pImplementation->GetWindow();
+ }
+ uno::Reference< XComponent > xComp( this );
+ m_pDialog = new ChineseTranslationDialog( pParent );
+ }
+ if( !m_pDialog )
+ return nRet;
+ nRet = m_pDialog->Execute();
+ if(nRet==RET_OK)
+ nRet=ui::dialogs::ExecutableDialogResults::OK;
+ }
+ return nRet;
+}
+
+//-------------------------------------------------------------------------
+// lang::XComponent
+
+void SAL_CALL ChineseTranslation_UnoDialog::dispose() throw (uno::RuntimeException)
+{
+ lang::EventObject aEvt;
+ {
+ SolarMutexGuard aSolarGuard;
+ if( m_bDisposed || m_bInDispose )
+ return;
+ m_bInDispose = true;
+
+ impl_DeleteDialog();
+ m_xParentWindow = 0;
+ m_bDisposed = true;
+
+ aEvt.Source = static_cast< XComponent * >( this );
+ }
+ if( m_aDisposeEventListeners.getLength() )
+ m_aDisposeEventListeners.disposeAndClear( aEvt );
+}
+
+void SAL_CALL ChineseTranslation_UnoDialog::addEventListener( const uno::Reference< lang::XEventListener > & xListener ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ if( m_bDisposed || m_bInDispose )
+ return;
+ m_aDisposeEventListeners.addInterface( xListener );
+}
+
+void SAL_CALL ChineseTranslation_UnoDialog::removeEventListener( const uno::Reference< lang::XEventListener > & xListener ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+ if( m_bDisposed || m_bInDispose )
+ return;
+ m_aDisposeEventListeners.removeInterface( xListener );
+}
+
+//-------------------------------------------------------------------------
+// XPropertySet
+
+uno::Reference< beans::XPropertySetInfo > SAL_CALL ChineseTranslation_UnoDialog::getPropertySetInfo( ) throw (uno::RuntimeException)
+{
+ return 0;
+}
+void SAL_CALL ChineseTranslation_UnoDialog::setPropertyValue( const ::rtl::OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ //only read only properties
+ throw beans::PropertyVetoException();
+}
+uno::Any SAL_CALL ChineseTranslation_UnoDialog::getPropertyValue( const ::rtl::OUString& rPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ uno::Any aRet;
+
+ sal_Bool bDirectionToSimplified = sal_True;
+ sal_Bool bUseCharacterVariants = sal_False;
+ sal_Bool bTranslateCommonTerms = sal_False;
+
+ {
+ SolarMutexGuard aSolarGuard;
+ if( m_bDisposed || m_bInDispose || !m_pDialog )
+ return aRet;
+ m_pDialog->getSettings( bDirectionToSimplified, bUseCharacterVariants, bTranslateCommonTerms );
+ }
+
+ if( rPropertyName.equals( C2U("IsDirectionToSimplified") ) )
+ {
+ aRet <<= bDirectionToSimplified;
+ }
+ else if( rPropertyName.equals( C2U("IsUseCharacterVariants") ) )
+ {
+ aRet <<= bUseCharacterVariants;
+ }
+ else if( rPropertyName.equals( C2U("IsTranslateCommonTerms") ) )
+ {
+ aRet <<= bTranslateCommonTerms;
+ }
+ else
+ {
+ throw beans::UnknownPropertyException();
+ }
+ return aRet;
+
+}
+void SAL_CALL ChineseTranslation_UnoDialog::addPropertyChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ //only not bound properties -> ignore listener
+}
+void SAL_CALL ChineseTranslation_UnoDialog::removePropertyChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ //only not bound properties -> ignore listener
+}
+void SAL_CALL ChineseTranslation_UnoDialog::addVetoableChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ //only not bound properties -> ignore listener
+}
+void SAL_CALL ChineseTranslation_UnoDialog::removeVetoableChangeListener( const ::rtl::OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ //only not bound properties -> ignore listener
+}
+
+//.............................................................................
+} //end namespace
+//.............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.hxx b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.hxx
new file mode 100644
index 000000000000..9a2924c8efb0
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_translation_unodialog.hxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _TEXTCONVERSIONDLGS_CHINESE_TRANSLATION_UNODIALOG_HXX
+#define _TEXTCONVERSIONDLGS_CHINESE_TRANSLATION_UNODIALOG_HXX
+
+#include <cppuhelper/component.hxx>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/implbase5.hxx>
+
+//.............................................................................
+namespace textconversiondlgs
+{
+//.............................................................................
+
+//-------------------------------------------------------------------------
+/** This class provides the chinese translation dialog as an uno component.
+
+It can be created via lang::XMultiComponentFactory::createInstanceWithContext
+with servicename "com.sun.star.linguistic2.ChineseTranslationDialog"
+or implemenation name "com.sun.star.comp.linguistic2.ChineseTranslationDialog"
+
+It can be initialized via the XInitialization interface with the following single parameter:
+PropertyValue-Parameter: Name="ParentWindow" Type="awt::XWindow".
+
+It can be executed via the ui::dialogs::XExecutableDialog interface.
+
+Made settings can be retrieved via beans::XPropertySet interface.
+Following properties are available (read only and not bound):
+1) Name="IsDirectionToSimplified" Type="sal_Bool"
+2) Name="IsUseCharacterVariants" Type="sal_Bool"
+3) Name="IsTranslateCommonTerms" Type="sal_Bool"
+
+The dialog gets this information from the registry on execute and writes it back to the registry if ended with OK.
+*/
+
+class ChineseTranslationDialog;
+
+class ChineseTranslation_UnoDialog : public ::cppu::WeakImplHelper5 <
+ ::com::sun::star::ui::dialogs::XExecutableDialog
+ , ::com::sun::star::lang::XInitialization
+ , ::com::sun::star::beans::XPropertySet
+ , ::com::sun::star::lang::XComponent
+ , ::com::sun::star::lang::XServiceInfo
+ >
+ // ,public ::com::sun::star::uno::XWeak // implemented by WeakImplHelper(optional interface)
+ // ,public ::com::sun::star::uno::XInterface // implemented by WeakImplHelper(optional interface)
+ // ,public ::com::sun::star::lang::XTypeProvider // implemented by WeakImplHelper
+{
+public:
+ ChineseTranslation_UnoDialog( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext >& xContext );
+ virtual ~ChineseTranslation_UnoDialog();
+
+ // lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ static ::rtl::OUString getImplementationName_Static();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static();
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ create( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext) throw(::com::sun::star::uno::Exception)
+ {
+ return (::cppu::OWeakObject *)new ChineseTranslation_UnoDialog( xContext );
+ }
+
+ // lang::XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // ui::dialogs::XExecutableDialog
+ virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL execute( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // beans::XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // lang::XComponent
+ virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ //no default constructor
+ ChineseTranslation_UnoDialog();
+
+ void impl_DeleteDialog();
+
+private:
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XComponentContext> m_xCC;
+ com::sun::star::uno::Reference<
+ com::sun::star::awt::XWindow > m_xParentWindow;
+
+ ChineseTranslationDialog* m_pDialog;
+
+ sal_Bool m_bDisposed; ///Dispose call ready.
+ sal_Bool m_bInDispose;///In dispose call
+ osl::Mutex m_aContainerMutex;
+ cppu::OInterfaceContainerHelper m_aDisposeEventListeners;
+};
+
+//.............................................................................
+} //end namespace
+//.............................................................................
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.cxx b/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.cxx
new file mode 100644
index 000000000000..bda83bf52e3a
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.cxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "chinese_translationdialog.hxx"
+#include "chinese_translationdialog.hrc"
+#include "resid.hxx"
+#include "chinese_dictionarydialog.hxx"
+#include <com/sun/star/i18n/TextConversionOption.hpp>
+// header for define RET_OK
+#include <vcl/msgbox.hxx>
+// header for class SvtLinguConfigItem
+#include <unotools/lingucfg.hxx>
+#include <unotools/linguprops.hxx>
+#include "helpid.hrc"
+
+//disable compiler warning C4355: 'this' : used in base member initializer list
+#ifdef _MSC_VER
+# pragma warning (disable : 4355)
+#endif
+
+//.............................................................................
+namespace textconversiondlgs
+{
+//.............................................................................
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+ChineseTranslationDialog::ChineseTranslationDialog( Window* pParent )
+ : ModalDialog( pParent, TextConversionDlgs_ResId( DLG_CHINESETRANSLATION ) )
+ , m_aFL_Direction( this, TextConversionDlgs_ResId( FL_DIRECTION ) )
+ , m_aRB_To_Simplified( this, TextConversionDlgs_ResId( RB_TO_SIMPLIFIED ) )
+ , m_aRB_To_Traditional( this, TextConversionDlgs_ResId( RB_TO_TRADITIONAL ) )
+ , m_aCB_Use_Variants( this, TextConversionDlgs_ResId( CB_USE_VARIANTS ) )
+ , m_aFL_Commonterms( this, TextConversionDlgs_ResId( FL_COMMONTERMS ) )
+ , m_aCB_Translate_Commonterms( this, TextConversionDlgs_ResId( CB_TRANSLATE_COMMONTERMS ) )
+ , m_aPB_Editterms( this, TextConversionDlgs_ResId( PB_EDITTERMS ) )
+ , m_aFL_Bottomline( this, TextConversionDlgs_ResId( FL_BOTTOMLINE ) )
+ , m_aBP_OK( this, TextConversionDlgs_ResId( PB_OK ) )
+ , m_aBP_Cancel( this, TextConversionDlgs_ResId( PB_CANCEL ) )
+ , m_aBP_Help( this, TextConversionDlgs_ResId( PB_HELP ) )
+ , m_pDictionaryDialog(0)
+{
+ FreeResource();
+
+ m_aRB_To_Simplified.SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_SIMPLIFIED );
+ m_aRB_To_Traditional.SetHelpId( HID_SVX_CHINESE_TRANSLATION_RB_CONVERSION_TO_TRADITIONAL );
+ m_aCB_Use_Variants.SetHelpId( HID_SVX_CHINESE_TRANSLATION_CB_USE_VARIANTS );
+
+ SvtLinguConfig aLngCfg;
+ sal_Bool bValue = sal_Bool();
+ Any aAny( aLngCfg.GetProperty( rtl::OUString::createFromAscii( UPN_IS_DIRECTION_TO_SIMPLIFIED ) ) );
+ aAny >>= bValue;
+ if( bValue )
+ m_aRB_To_Simplified.Check();
+ else
+ m_aRB_To_Traditional.Check();
+
+ aAny = aLngCfg.GetProperty( rtl::OUString::createFromAscii( UPN_IS_USE_CHARACTER_VARIANTS ) );
+ if( aAny >>= bValue )
+ m_aCB_Use_Variants.Check( bValue );
+
+ // #117820# (search for other occurences!)
+ // disable and hide that checkbox until it is decided if it is needed or not.
+ // If it is to be removed later the respective code needs to be removed as
+ // well, otherwise we just have to remove the next lines again.
+ m_aCB_Use_Variants.Check( sal_False );
+ m_aCB_Use_Variants.Enable( sal_False );
+ m_aCB_Use_Variants.Show( sal_False );
+
+ aAny = aLngCfg.GetProperty( rtl::OUString::createFromAscii( UPN_IS_TRANSLATE_COMMON_TERMS ) );
+ if( aAny >>= bValue )
+ m_aCB_Translate_Commonterms.Check( bValue );
+
+ m_aPB_Editterms.SetClickHdl( LINK( this, ChineseTranslationDialog, DictionaryHdl ) );
+ m_aRB_To_Simplified.SetClickHdl( LINK( this, ChineseTranslationDialog, DirectionHdl ) );
+ m_aRB_To_Traditional.SetClickHdl( LINK( this, ChineseTranslationDialog, DirectionHdl ) );
+ m_aCB_Translate_Commonterms.SetClickHdl( LINK( this, ChineseTranslationDialog, CommonTermsHdl ) );
+ m_aBP_OK.SetClickHdl( LINK( this, ChineseTranslationDialog, OkHdl ) );
+
+ impl_UpdateVariantsCheckBox();
+}
+
+ChineseTranslationDialog::~ChineseTranslationDialog()
+{
+ if(m_pDictionaryDialog)
+ {
+ if(m_pDictionaryDialog->IsInExecute())
+ m_pDictionaryDialog->EndDialog();
+ delete m_pDictionaryDialog;
+ }
+}
+
+void ChineseTranslationDialog::getSettings( sal_Bool& rbDirectionToSimplified
+ , sal_Bool& rbUseCharacterVariants
+ , sal_Bool& rbTranslateCommonTerms ) const
+{
+ rbDirectionToSimplified = m_aRB_To_Simplified.IsChecked();
+ rbUseCharacterVariants = m_aCB_Use_Variants.IsChecked();
+ rbTranslateCommonTerms = m_aCB_Translate_Commonterms.IsChecked();
+}
+
+void ChineseTranslationDialog::impl_UpdateVariantsCheckBox()
+{
+// #117820# (search for other occurences!)
+// m_aCB_Use_Variants.Enable( m_aRB_To_Traditional.IsChecked() );
+}
+
+IMPL_LINK( ChineseTranslationDialog, DirectionHdl, void*, EMPTYARG )
+{
+ impl_UpdateVariantsCheckBox();
+ return 0;
+}
+
+IMPL_LINK( ChineseTranslationDialog, CommonTermsHdl, void*, EMPTYARG )
+{
+// #117820# (search for other occurences!)
+// if( m_aCB_Translate_Commonterms.IsChecked() && m_aRB_To_Traditional.IsChecked() )
+// m_aCB_Use_Variants.Check( true );
+ return 0;
+}
+
+IMPL_LINK( ChineseTranslationDialog, OkHdl, void*, EMPTYARG )
+{
+ //save settings to configuration
+ SvtLinguConfig aLngCfg;
+ Any aAny;
+ aAny <<= sal_Bool( !!m_aRB_To_Simplified.IsChecked() );
+ aLngCfg.SetProperty( rtl::OUString::createFromAscii( UPN_IS_DIRECTION_TO_SIMPLIFIED ), aAny );
+ aAny <<= sal_Bool( !!m_aCB_Use_Variants.IsChecked() );
+ aLngCfg.SetProperty( rtl::OUString::createFromAscii( UPN_IS_USE_CHARACTER_VARIANTS ), aAny );
+ aAny <<= sal_Bool( !!m_aCB_Translate_Commonterms.IsChecked() );
+ aLngCfg.SetProperty( rtl::OUString::createFromAscii( UPN_IS_TRANSLATE_COMMON_TERMS ), aAny );
+
+ EndDialog( RET_OK );
+ return 0;
+}
+
+IMPL_LINK( ChineseTranslationDialog, DictionaryHdl, void*, EMPTYARG )
+{
+ if( !m_pDictionaryDialog )
+ {
+ m_pDictionaryDialog = new ChineseDictionaryDialog(this);
+ }
+ if( m_pDictionaryDialog )
+ {
+ if( m_pDictionaryDialog->IsInExecute() )
+ {
+ if( !m_pDictionaryDialog->IsReallyVisible() )
+ {
+ m_pDictionaryDialog->ToTop();
+ m_pDictionaryDialog->GrabFocusToFirstControl();
+ }
+ }
+ else
+ {
+ sal_Int32 nTextConversionOptions = i18n::TextConversionOption::NONE;
+ if( !m_aCB_Translate_Commonterms.IsChecked() )
+ nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+ if( m_aCB_Use_Variants.IsChecked() )
+ nTextConversionOptions = nTextConversionOptions | i18n::TextConversionOption::USE_CHARACTER_VARIANTS;
+
+ m_pDictionaryDialog->setDirectionAndTextConversionOptions( m_aRB_To_Simplified.IsChecked(), nTextConversionOptions );
+ m_pDictionaryDialog->Execute();
+ }
+ }
+ return 0;
+}
+
+//.............................................................................
+} //end namespace
+//.............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.hrc b/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.hrc
new file mode 100644
index 000000000000..bc3540501680
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.hrc
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * 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 _TEXTCONVERSIONDLGS_CHINESE_TRANSLATIONDLG_HRC
+#define _TEXTCONVERSIONDLGS_CHINESE_TRANSLATIONDLG_HRC
+
+#include "resids.hrc"
+#include "buttongroup.hrc"
+#include "chinese_direction_ids.hrc"
+
+#define PB_EDITTERMS 1
+
+#define CB_USE_VARIANTS 1
+#define CB_TRANSLATE_COMMONTERMS 2
+#define CB_REVERSE 3
+
+#define FL_DIRECTION 1
+#define FL_COMMONTERMS 2
+#define FL_BOTTOMLINE 3
+
+#endif
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.hxx b/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.hxx
new file mode 100644
index 000000000000..2805217c7745
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _TEXTCONVERSIONDLGS_CHINESE_TRANSLATIONDLG_HXX
+#define _TEXTCONVERSIONDLGS_CHINESE_TRANSLATIONDLG_HXX
+
+#include <vcl/dialog.hxx>
+// header for class FixedLine
+#include <vcl/fixed.hxx>
+// header for class RadioButton
+#include <vcl/button.hxx>
+
+//.............................................................................
+namespace textconversiondlgs
+{
+//.............................................................................
+
+//-----------------------------------------------------------------------------
+/**
+*/
+class ChineseDictionaryDialog;
+
+class ChineseTranslationDialog : public ModalDialog
+{
+public:
+ ChineseTranslationDialog( Window* pParent );
+ virtual ~ChineseTranslationDialog();
+
+ void getSettings( sal_Bool& rbDirectionToSimplified
+ , sal_Bool& rbUseCharacterVariants
+ , sal_Bool& rbTranslateCommonTerms ) const;
+
+private:
+ DECL_LINK( DictionaryHdl, void* );
+ DECL_LINK( DirectionHdl, void* );
+ DECL_LINK( CommonTermsHdl, void* );
+ DECL_LINK( OkHdl, void* );
+ void impl_UpdateVariantsCheckBox();
+
+private:
+ FixedLine m_aFL_Direction;
+
+ RadioButton m_aRB_To_Simplified;
+ RadioButton m_aRB_To_Traditional;
+ CheckBox m_aCB_Use_Variants;
+
+ FixedLine m_aFL_Commonterms;
+
+ CheckBox m_aCB_Translate_Commonterms;
+ PushButton m_aPB_Editterms;
+
+ FixedLine m_aFL_Bottomline;
+
+ OKButton m_aBP_OK;
+ CancelButton m_aBP_Cancel;
+ HelpButton m_aBP_Help;
+
+ ChineseDictionaryDialog* m_pDictionaryDialog;
+};
+
+//.............................................................................
+} //end namespace
+//.............................................................................
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.src b/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.src
new file mode 100644
index 000000000000..52dfd00909f7
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.src
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "chinese_translationdialog.hrc"
+#include "chinese_direction.hrc"
+
+#ifndef _SVT_CONTROLDIMS_HRC_
+#include <svtools/controldims.hrc>
+#endif
+
+//-----------------------------------------------------------------------------
+//defines for positions and sizes:
+
+#define FULL_WIDTH (220)
+#define FULL_HEIGHT (120)
+#define EDITBUTTON_WIDTH (75)
+
+#define COL_1 (RSC_SP_DLG_INNERBORDER_LEFT)
+#define COL_2 (COL_1+RSC_SP_FLGR_SPACE_X)
+#define COL_3 (COL_2+RSC_SP_CHK_TEXTINDENT)
+#define COL_4 (FULL_WIDTH-RSC_SP_DLG_INNERBORDER_RIGHT-EDITBUTTON_WIDTH)
+
+#define ROW_1 (RSC_SP_DLG_INNERBORDER_TOP)
+#define ROW_2 (ROW_1+RSC_CD_FIXEDLINE_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define ROW_3 (ROW_2+RSC_CD_RADIOBUTTON_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+#define ROW_4 (ROW_3+RSC_CD_RADIOBUTTON_HEIGHT+RSC_SP_CTRL_DESC_Y)
+#define ROW_5 (ROW_4+RSC_CD_CHECKBOX_HEIGHT+RSC_SP_CTRL_Y)
+#define ROW_6 (ROW_5+RSC_CD_FIXEDLINE_HEIGHT+RSC_SP_CTRL_GROUP_Y)
+
+#define ROW_8 (FULL_HEIGHT-RSC_SP_DLG_INNERBORDER_BOTTOM-RSC_CD_PUSHBUTTON_HEIGHT)
+#define ROW_7 (ROW_8-RSC_CD_FIXEDLINE_HEIGHT-2)
+
+//-----------------------------------------------------------------------------
+
+ModalDialog DLG_CHINESETRANSLATION
+{
+ //HelpId = ;
+ Size = MAP_APPFONT( FULL_WIDTH, FULL_HEIGHT );
+ OutputSize = TRUE;
+ Closeable = TRUE ;
+ Moveable = TRUE ;
+ SVLook = TRUE;
+
+ Text [ en-US ] = "Chinese Conversion";
+
+ FixedLine FL_DIRECTION
+ {
+ Pos = MAP_APPFONT ( COL_1 , ROW_1 ) ;
+ Size = MAP_APPFONT ( FULL_WIDTH - COL_1 - RSC_SP_DLG_INNERBORDER_RIGHT, RSC_CD_FIXEDLINE_HEIGHT ) ;
+ Text [ en-US ] = "Conversion direction";
+ };
+
+ DIRECTION_RADIOBUTTONS( COL_2, ROW_2, (FULL_WIDTH - COL_2 - RSC_SP_DLG_INNERBORDER_RIGHT) )
+
+ CheckBox CB_USE_VARIANTS
+ {
+ Pos = MAP_APPFONT( COL_3, ROW_4 );
+ Size = MAP_APPFONT ( FULL_WIDTH - COL_3 - RSC_SP_DLG_INNERBORDER_RIGHT, RSC_CD_CHECKBOX_HEIGHT ) ;
+
+ Text [ en-US ] = "~Use Taiwan, Hong Kong SAR, and Macao SAR character variants";
+ };
+
+ FixedLine FL_COMMONTERMS
+ {
+ Pos = MAP_APPFONT ( COL_1 , ROW_5 ) ;
+ Size = MAP_APPFONT ( FULL_WIDTH - COL_1 - RSC_SP_DLG_INNERBORDER_RIGHT, RSC_CD_FIXEDLINE_HEIGHT ) ;
+ Text [ en-US ] = "Common terms";
+ };
+
+ CheckBox CB_TRANSLATE_COMMONTERMS
+ {
+ Pos = MAP_APPFONT( COL_2, ROW_6 );
+ Size = MAP_APPFONT ( COL_4 - COL_2, RSC_CD_CHECKBOX_HEIGHT ) ;
+
+ Text [ en-US ] = "Translate ~common terms";
+ };
+
+ PushButton PB_EDITTERMS
+ {
+ Pos = MAP_APPFONT( COL_4, ROW_6-(RSC_CD_PUSHBUTTON_HEIGHT-RSC_CD_CHECKBOX_HEIGHT)/2 );
+ Size = MAP_APPFONT( EDITBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT );
+
+ Text [ en-US ] = "~Edit Terms...";
+ };
+
+ FixedLine FL_BOTTOMLINE
+ {
+ Pos = MAP_APPFONT ( 0 , ROW_7 ) ;
+ Size = MAP_APPFONT ( FULL_WIDTH, RSC_CD_FIXEDLINE_HEIGHT ) ;
+ };
+
+ BUTTONS_OK_CANCEL_HELP_ABREAST( FULL_WIDTH - RSC_SP_DLG_INNERBORDER_RIGHT, ROW_8 )
+};
diff --git a/svx/source/unodialogs/textconversiondlgs/makefile.mk b/svx/source/unodialogs/textconversiondlgs/makefile.mk
new file mode 100644
index 000000000000..b5013ca9d165
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/makefile.mk
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=svx
+TARGET=textconversiondlgs
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE=TRUE
+
+LOCALIZE_ME=chinese_direction_tmpl.hrc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/services.obj\
+ $(SLO)$/resid.obj\
+ $(SLO)$/chinese_dictionarydialog.obj\
+ $(SLO)$/chinese_translationdialog.obj\
+ $(SLO)$/chinese_translation_unodialog.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES= \
+ chinese_translationdialog.src\
+ chinese_dictionarydialog.src
+
+RESLIB1NAME=$(TARGET)
+RESLIB1SRSFILES= $(SRS)$/$(TARGET).srs
+
+.IF "$(GUI)" == "OS2"
+SHL1TARGET= txcnvdlg
+.ELSE
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+.ENDIF
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(CPPUHELPERLIB) \
+ $(UNOTOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(TOOLSLIB) \
+ $(TKLIB) \
+ $(SVTOOLLIB) \
+ $(SVLLIB) \
+ $(VCLLIB)
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1IMPLIB= i$(TARGET)
+SHL1DEPN= $(SHL1LIBS)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+
+# --- Targets ------------------------------------------------------
+.INCLUDE : target.mk
+
+$(SRS)$/$(TARGET).srs: $(INCCOM)$/chinese_direction.hrc
+$(SLO)$/chinese_dictionarydialog.obj: $(INCCOM)$/chinese_direction.hrc
+$(SLO)$/chinese_translationdialog.obj: $(INCCOM)$/chinese_direction.hrc
+
diff --git a/svx/source/unodialogs/textconversiondlgs/resid.cxx b/svx/source/unodialogs/textconversiondlgs/resid.cxx
new file mode 100644
index 000000000000..bb0a62be9e2b
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/resid.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "resid.hxx"
+#include <tools/resmgr.hxx>
+
+//.............................................................................
+namespace textconversiondlgs
+{
+//.............................................................................
+
+static ResMgr* getTextConversionResMgr()
+{
+ static ResMgr* pMgr = NULL;
+ if( ! pMgr )
+ pMgr = ResMgr::CreateResMgr( "textconversiondlgs" );
+ return pMgr;
+}
+TextConversionDlgs_ResId::TextConversionDlgs_ResId(USHORT nId)
+ : ResId( nId, *getTextConversionResMgr() )
+{
+}
+
+//.............................................................................
+} //end namespace
+//.............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodialogs/textconversiondlgs/resid.hxx b/svx/source/unodialogs/textconversiondlgs/resid.hxx
new file mode 100644
index 000000000000..f920fd3a9023
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/resid.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _TEXTCONVERSIONDLGS_RESID_HXX
+#define _TEXTCONVERSIONDLGS_RESID_HXX
+
+#include <tools/resid.hxx>
+
+//.............................................................................
+namespace textconversiondlgs
+{
+//.............................................................................
+
+//-----------------------------------------------------------------------------
+/**
+*/
+
+class TextConversionDlgs_ResId : public ResId
+{
+ public:
+ TextConversionDlgs_ResId(USHORT nId);
+};
+
+//.............................................................................
+} //end namespace
+//.............................................................................
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodialogs/textconversiondlgs/resids.hrc b/svx/source/unodialogs/textconversiondlgs/resids.hrc
new file mode 100644
index 000000000000..8581baed1de4
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/resids.hrc
@@ -0,0 +1,33 @@
+/*************************************************************************
+ *
+ * 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 _TEXTCONVERSIONDLGS_RESID_HRC
+#define _TEXTCONVERSIONDLGS_RESID_HRC
+
+#define DLG_CHINESETRANSLATION 300
+#define DLG_CHINESEDICTIONARY 301
+
+#endif
diff --git a/svx/source/unodialogs/textconversiondlgs/services.cxx b/svx/source/unodialogs/textconversiondlgs/services.cxx
new file mode 100644
index 000000000000..1035c41d1a85
--- /dev/null
+++ b/svx/source/unodialogs/textconversiondlgs/services.cxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include "chinese_translation_unodialog.hxx"
+#include <cppuhelper/implementationentry.hxx>
+
+static struct ::cppu::ImplementationEntry g_entries_unodialogs_chinesetranslation[] =
+{
+ {
+ ::textconversiondlgs::ChineseTranslation_UnoDialog::create
+ , ::textconversiondlgs::ChineseTranslation_UnoDialog::getImplementationName_Static
+ , ::textconversiondlgs::ChineseTranslation_UnoDialog::getSupportedServiceNames_Static
+ , ::cppu::createSingleComponentFactory
+ , 0
+ , 0
+ }
+ ,{ 0, 0, 0, 0, 0, 0 }
+};
+
+// component exports
+extern "C"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ return ::cppu::component_writeInfoHelper(
+ pServiceManager, pRegistryKey, g_entries_unodialogs_chinesetranslation );
+}
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ return ::cppu::component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey , g_entries_unodialogs_chinesetranslation );
+}
+}
+//=========================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
new file mode 100644
index 000000000000..946aaa1a7557
--- /dev/null
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -0,0 +1,1285 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <vector>
+#include <osl/mutex.hxx>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/document/XMimeTypeInfo.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/graphic/XGraphicRenderer.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/task/XInteractionContinuation.hpp>
+
+#include <framework/interaction.hxx>
+#include <com/sun/star/drawing/GraphicFilterRequest.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <cppuhelper/implbase4.hxx>
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+#include <vcl/metaact.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/virdev.hxx>
+#include <svtools/FilterConfigItem.hxx>
+#include <svl/outstrm.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/sdr/contact/viewcontactofsdrobj.hxx>
+#include <editeng/numitem.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdograf.hxx>
+#include "xoutbmp.hxx"
+#include "svtools/filter.hxx"
+#include "unoapi.hxx"
+#include <svx/svdpage.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/fmview.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/unopage.hxx>
+#include <svx/pageitem.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/svdoutl.hxx>
+#include <editeng/flditem.hxx>
+
+#include "boost/scoped_ptr.hpp"
+
+#define MAX_EXT_PIX 2048
+
+using namespace ::comphelper;
+using namespace ::osl;
+using ::rtl::OUString;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::task;
+#include <svx/sdr/contact/viewobjectcontactredirector.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+
+// #i102251#
+#include <editeng/editstat.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace svx
+{
+ struct ExportSettings
+ {
+ OUString maFilterName;
+ OUString maMediaType;
+ URL maURL;
+ com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > mxOutputStream;
+ com::sun::star::uno::Reference< com::sun::star::graphic::XGraphicRenderer > mxGraphicRenderer;
+ com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator > mxStatusIndicator;
+ com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > mxInteractionHandler;
+
+ sal_Int32 mnWidth;
+ sal_Int32 mnHeight;
+ sal_Bool mbExportOnlyBackground;
+ sal_Bool mbVerboseComments;
+ sal_Bool mbScrollText;
+ sal_Bool mbUseHighContrast;
+ sal_Bool mbTranslucent;
+
+ Sequence< PropertyValue > maFilterData;
+
+ Fraction maScaleX;
+ Fraction maScaleY;
+
+ ExportSettings( SdrModel* pDoc );
+ };
+
+ ExportSettings::ExportSettings( SdrModel* pDoc )
+ : mnWidth( 0 )
+ , mnHeight( 0 )
+ , mbExportOnlyBackground( false )
+ , mbVerboseComments( false )
+ , mbScrollText( false )
+ , mbUseHighContrast( false )
+ , mbTranslucent( sal_False )
+ , maScaleX( 1, 1 )
+ , maScaleY( 1, 1 )
+ {
+ if( pDoc )
+ {
+ maScaleX = pDoc->GetScaleFraction();
+ maScaleY = pDoc->GetScaleFraction();
+ }
+ }
+
+ /** implements a component to export shapes or pages to external graphic formats.
+
+ @implements com.sun.star.drawing.GraphicExportFilter
+ */
+ class GraphicExporter : public WeakImplHelper4< XFilter, XExporter, XServiceInfo, XMimeTypeInfo >
+ {
+ public:
+ GraphicExporter();
+ virtual ~GraphicExporter();
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor ) throw(RuntimeException);
+ virtual void SAL_CALL cancel( ) throw(RuntimeException);
+
+ // XExporter
+ virtual void SAL_CALL setSourceDocument( const Reference< XComponent >& xDoc ) throw(IllegalArgumentException, RuntimeException);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
+
+ // XMimeTypeInfo
+ virtual sal_Bool SAL_CALL supportsMimeType( const ::rtl::OUString& MimeTypeName ) throw (RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedMimeTypeNames( ) throw (RuntimeException);
+
+ VirtualDevice* CreatePageVDev( SdrPage* pPage, ULONG nWidthPixel, ULONG nHeightPixel ) const;
+
+ DECL_LINK( CalcFieldValueHdl, EditFieldInfo* );
+
+ void ParseSettings( const Sequence< PropertyValue >& aDescriptor, ExportSettings& rSettings );
+ bool GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, sal_Bool bVectorType );
+
+ private:
+ Reference< XShape > mxShape;
+ Reference< XDrawPage > mxPage;
+ Reference< XShapes > mxShapes;
+
+ SvxDrawPage* mpUnoPage;
+
+ Link maOldCalcFieldValueHdl;
+ sal_Int32 mnPageNumber;
+ SdrPage* mpCurrentPage;
+ SdrModel* mpDoc;
+ };
+
+ SVX_DLLPUBLIC Reference< XInterface > SAL_CALL GraphicExporter_createInstance(const Reference< XMultiServiceFactory > & )
+ throw( Exception )
+ {
+ return (XWeak*)new GraphicExporter();
+ }
+
+ SVX_DLLPUBLIC Sequence< OUString > SAL_CALL GraphicExporter_getSupportedServiceNames()
+ throw()
+ {
+ Sequence< OUString > aSupportedServiceNames( 1 );
+ aSupportedServiceNames[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicExportFilter" ) );
+ return aSupportedServiceNames;
+ }
+
+ SVX_DLLPUBLIC OUString SAL_CALL GraphicExporter_getImplementationName()
+ throw()
+ {
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Draw.GraphicExporter" ) );
+ }
+
+ /** creates a bitmap that is optionaly transparent from a metafile
+ */
+ BitmapEx GetBitmapFromMetaFile( const GDIMetaFile& rMtf, BOOL bTransparent, const Size* pSize )
+ {
+ Graphic aGraphic( rMtf );
+ BitmapEx aBmpEx;
+
+ // #i102089# support user's settings of AA and LineSnap when the MetaFile gets
+ // rasterconverted to a bitmap
+ const SvtOptionsDrawinglayer aDrawinglayerOpt;
+ const GraphicConversionParameters aParameters(
+ pSize ? *pSize : Size(0, 0),
+ true, // allow unlimited size
+ aDrawinglayerOpt.IsAntiAliasing(),
+ aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete());
+
+ if( bTransparent )
+ {
+ Graphic aMaskGraphic(rMtf.GetMonochromeMtf(COL_BLACK));
+ Bitmap aMaskBmp(aMaskGraphic.GetBitmap(aParameters));
+
+ aMaskBmp.Convert(BMP_CONVERSION_1BIT_THRESHOLD);
+ aBmpEx = BitmapEx(aGraphic.GetBitmap(aParameters), aMaskBmp);
+ }
+ else
+ {
+ aBmpEx = BitmapEx(aGraphic.GetBitmap(aParameters));
+ }
+
+ aBmpEx.SetPrefMapMode( rMtf.GetPrefMapMode() );
+ aBmpEx.SetPrefSize( rMtf.GetPrefSize() );
+
+ return aBmpEx;
+ }
+
+ Size* CalcSize( sal_Int32 nWidth, sal_Int32 nHeight, const Size& aBoundSize, Size& aOutSize )
+ {
+ if( (nWidth == 0) && (nHeight == 0) )
+ return NULL;
+
+ if( (nWidth == 0) && (nHeight != 0) && (aBoundSize.Height() != 0) )
+ {
+ nWidth = ( nHeight * aBoundSize.Width() ) / aBoundSize.Height();
+ }
+ else if( (nWidth != 0) && (nHeight == 0) && (aBoundSize.Width() != 0) )
+ {
+ nHeight = ( nWidth * aBoundSize.Height() ) / aBoundSize.Width();
+ }
+
+ aOutSize.Width() = nWidth;
+ aOutSize.Height() = nHeight;
+
+ return &aOutSize;
+ }
+}
+
+class ImplExportCheckVisisbilityRedirector : public ::sdr::contact::ViewObjectContactRedirector
+{
+public:
+ ImplExportCheckVisisbilityRedirector( SdrPage* pCurrentPage );
+ virtual ~ImplExportCheckVisisbilityRedirector();
+
+ virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
+ const sdr::contact::ViewObjectContact& rOriginal,
+ const sdr::contact::DisplayInfo& rDisplayInfo);
+
+private:
+ SdrPage* mpCurrentPage;
+};
+
+ImplExportCheckVisisbilityRedirector::ImplExportCheckVisisbilityRedirector( SdrPage* pCurrentPage )
+: ViewObjectContactRedirector(), mpCurrentPage( pCurrentPage )
+{
+}
+
+ImplExportCheckVisisbilityRedirector::~ImplExportCheckVisisbilityRedirector()
+{
+}
+
+drawinglayer::primitive2d::Primitive2DSequence ImplExportCheckVisisbilityRedirector::createRedirectedPrimitive2DSequence(
+ const sdr::contact::ViewObjectContact& rOriginal,
+ const sdr::contact::DisplayInfo& rDisplayInfo)
+{
+ SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
+
+ if(pObject)
+ {
+ SdrPage* pPage = mpCurrentPage;
+ if( pPage == 0 )
+ pPage = pObject->GetPage();
+
+ if( (pPage == 0) || pPage->checkVisibility(rOriginal, rDisplayInfo, false) )
+ {
+ return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
+ }
+
+ return drawinglayer::primitive2d::Primitive2DSequence();
+ }
+ else
+ {
+ // not an object, maybe a page
+ return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
+ }
+}
+
+using namespace ::svx;
+
+GraphicExporter::GraphicExporter()
+: mpUnoPage( NULL ), mnPageNumber(-1), mpCurrentPage(0), mpDoc( NULL )
+{
+}
+
+GraphicExporter::~GraphicExporter()
+{
+}
+
+IMPL_LINK(GraphicExporter, CalcFieldValueHdl, EditFieldInfo*, pInfo)
+{
+ if( pInfo )
+ {
+ if( mpCurrentPage )
+ {
+ pInfo->SetSdrPage( mpCurrentPage );
+ }
+ else if( mnPageNumber != -1 )
+ {
+ const SvxFieldData* pField = pInfo->GetField().GetField();
+ if( pField && pField->ISA( SvxPageField ) )
+ {
+ String aPageNumValue;
+ BOOL bUpper = FALSE;
+
+ switch(mpDoc->GetPageNumType())
+ {
+ case SVX_CHARS_UPPER_LETTER:
+ aPageNumValue += (sal_Unicode)(char)((mnPageNumber - 1) % 26 + 'A');
+ break;
+ case SVX_CHARS_LOWER_LETTER:
+ aPageNumValue += (sal_Unicode)(char)((mnPageNumber - 1) % 26 + 'a');
+ break;
+ case SVX_ROMAN_UPPER:
+ bUpper = TRUE;
+ case SVX_ROMAN_LOWER:
+ aPageNumValue += SvxNumberFormat::CreateRomanString(mnPageNumber, bUpper);
+ break;
+ case SVX_NUMBER_NONE:
+ aPageNumValue.Erase();
+ aPageNumValue += sal_Unicode(' ');
+ break;
+ default:
+ aPageNumValue += String::CreateFromInt32( (sal_Int32)mnPageNumber );
+ }
+
+ pInfo->SetRepresentation( aPageNumValue );
+
+ return(0);
+ }
+ }
+ }
+
+ long nRet = maOldCalcFieldValueHdl.Call( pInfo );
+
+ if( pInfo && mpCurrentPage )
+ pInfo->SetSdrPage( 0 );
+
+ return nRet;
+}
+
+/** creates an virtual device for the given page
+
+ @return the returned VirtualDevice is owned by the caller
+*/
+VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, ULONG nWidthPixel, ULONG nHeightPixel ) const
+{
+ VirtualDevice* pVDev = new VirtualDevice();
+ MapMode aMM( MAP_100TH_MM );
+
+ Point aPoint( 0, 0 );
+ Size aPageSize(pPage->GetSize());
+
+ // use scaling?
+ if( nWidthPixel )
+ {
+ const Fraction aFrac( (long) nWidthPixel, pVDev->LogicToPixel( aPageSize, aMM ).Width() );
+
+ aMM.SetScaleX( aFrac );
+
+ if( nHeightPixel == 0 )
+ aMM.SetScaleY( aFrac );
+ }
+
+ if( nHeightPixel )
+ {
+ const Fraction aFrac( (long) nHeightPixel, pVDev->LogicToPixel( aPageSize, aMM ).Height() );
+
+ if( nWidthPixel == 0 )
+ aMM.SetScaleX( aFrac );
+
+ aMM.SetScaleY( aFrac );
+ }
+
+ pVDev->SetMapMode( aMM );
+#ifdef DBG_UTIL
+ BOOL bAbort = !
+#endif
+ pVDev->SetOutputSize(aPageSize);
+ DBG_ASSERT(!bAbort, "virt. Device nicht korrekt erzeugt");
+
+ SdrView* pView = new SdrView(mpDoc, pVDev);
+ pView->SetPageVisible( FALSE );
+ pView->SetBordVisible( FALSE );
+ pView->SetGridVisible( FALSE );
+ pView->SetHlplVisible( FALSE );
+ pView->SetGlueVisible( FALSE );
+ pView->ShowSdrPage(pPage);
+ Region aRegion (Rectangle( aPoint, aPageSize ) );
+
+ ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
+
+ pView->CompleteRedraw(pVDev, aRegion, &aRedirector);
+
+ delete pView;
+ return pVDev;
+}
+
+void GraphicExporter::ParseSettings( const Sequence< PropertyValue >& aDescriptor, ExportSettings& rSettings )
+{
+ sal_Int32 nArgs = aDescriptor.getLength();
+ const PropertyValue* pValues = aDescriptor.getConstArray();
+ while( nArgs-- )
+ {
+ if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FilterName" ) ) )
+ {
+ pValues->Value >>= rSettings.maFilterName;
+ }
+ else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) )
+ {
+ pValues->Value >>= rSettings.maMediaType;
+ }
+ else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "URL" ) ) )
+ {
+ if( !( pValues->Value >>= rSettings.maURL ) )
+ {
+ pValues->Value >>= rSettings.maURL.Complete;
+ }
+ }
+ else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "OutputStream" ) ) )
+ {
+ pValues->Value >>= rSettings.mxOutputStream;
+ }
+ else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "GraphicRenderer" ) ) )
+ {
+ pValues->Value >>= rSettings.mxGraphicRenderer;
+ }
+ else if ( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StatusIndicator" ) ) )
+ {
+ pValues->Value >>= rSettings.mxStatusIndicator;
+ }
+ else if ( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "InteractionHandler" ) ) )
+ {
+ pValues->Value >>= rSettings.mxInteractionHandler;
+ }
+ else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Width" ) ) ) // for compatibility reasons, deprecated
+ {
+ pValues->Value >>= rSettings.mnWidth;
+ }
+ else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Height" ) ) ) // for compatibility reasons, deprecated
+ {
+ pValues->Value >>= rSettings.mnHeight;
+ }
+ else if( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ExportOnlyBackground" ) ) ) // for compatibility reasons, deprecated
+ {
+ pValues->Value >>= rSettings.mbExportOnlyBackground;
+ }
+ else if ( pValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FilterData" ) ) )
+ {
+ pValues->Value >>= rSettings.maFilterData;
+
+ sal_Int32 nFilterArgs = rSettings.maFilterData.getLength();
+ PropertyValue* pDataValues = rSettings.maFilterData.getArray();
+ while( nFilterArgs-- )
+ {
+ if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Translucent" ) ) )
+ {
+ if ( !( pDataValues->Value >>= rSettings.mbTranslucent ) ) // SJ: TODO: The GIF Transparency is stored as int32 in
+ { // configuration files, this has to be changed to boolean
+ sal_Int32 nTranslucent = 0;
+ if ( pDataValues->Value >>= nTranslucent )
+ rSettings.mbTranslucent = nTranslucent != 0;
+ }
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "PixelWidth" ) ) )
+ {
+ pDataValues->Value >>= rSettings.mnWidth;
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "PixelHeight" ) ) )
+ {
+ pDataValues->Value >>= rSettings.mnHeight;
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Width" ) ) ) // for compatibility reasons, deprecated
+ {
+ pDataValues->Value >>= rSettings.mnWidth;
+ pDataValues->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PixelWidth" ) );
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Height" ) ) ) // for compatibility reasons, deprecated
+ {
+ pDataValues->Value >>= rSettings.mnHeight;
+ pDataValues->Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PixelHeight" ) );
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ExportOnlyBackground" ) ) )
+ {
+ pDataValues->Value >>= rSettings.mbExportOnlyBackground;
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "HighContrast" ) ) )
+ {
+ pDataValues->Value >>= rSettings.mbUseHighContrast;
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "PageNumber" ) ) )
+ {
+ pDataValues->Value >>= mnPageNumber;
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VerboseComments" ) ) )
+ {
+ // #110496# Read flag for verbose metafile comments
+ pDataValues->Value >>= rSettings.mbVerboseComments;
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ScrollText" ) ) )
+ {
+ // #110496# Read flag solitary scroll text metafile
+ pDataValues->Value >>= rSettings.mbScrollText;
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CurrentPage" ) ) )
+ {
+ Reference< XDrawPage > xPage;
+ pDataValues->Value >>= xPage;
+ if( xPage.is() )
+ {
+ SvxDrawPage* pUnoPage = SvxDrawPage::getImplementation( xPage );
+ if( pUnoPage && pUnoPage->GetSdrPage() )
+ mpCurrentPage = pUnoPage->GetSdrPage();
+ }
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ScaleXNumerator" ) ) )
+ {
+ sal_Int32 nVal = 1;
+ if( pDataValues->Value >>= nVal )
+ rSettings.maScaleX = Fraction( nVal, rSettings.maScaleX.GetDenominator() );
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ScaleXDenominator" ) ) )
+ {
+ sal_Int32 nVal = 1;
+ if( pDataValues->Value >>= nVal )
+ rSettings.maScaleX = Fraction( rSettings.maScaleX.GetNumerator(), nVal );
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ScaleYNumerator" ) ) )
+ {
+ sal_Int32 nVal = 1;
+ if( pDataValues->Value >>= nVal )
+ rSettings.maScaleY = Fraction( nVal, rSettings.maScaleY.GetDenominator() );
+ }
+ else if( pDataValues->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ScaleYDenominator" ) ) )
+ {
+ sal_Int32 nVal = 1;
+ if( pDataValues->Value >>= nVal )
+ rSettings.maScaleY = Fraction( rSettings.maScaleY.GetNumerator(), nVal );
+ }
+
+ pDataValues++;
+ }
+ }
+
+ pValues++;
+ }
+
+ // putting the StatusIndicator that we got from the MediaDescriptor into our local FilterData copy
+ if ( rSettings.mxStatusIndicator.is() )
+ {
+ rtl::OUString sStatusIndicator( RTL_CONSTASCII_USTRINGPARAM( "StatusIndicator" ) );
+ int i = rSettings.maFilterData.getLength();
+ rSettings.maFilterData.realloc( i + 1 );
+ rSettings.maFilterData[ i ].Name = sStatusIndicator;
+ rSettings.maFilterData[ i ].Value <<= rSettings.mxStatusIndicator;
+ }
+}
+
+bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic, sal_Bool bVectorType )
+{
+ if( !mpDoc || !mpUnoPage )
+ return false;
+
+ SdrPage* pPage = mpUnoPage->GetSdrPage();
+ if( !pPage )
+ return false;
+
+ VirtualDevice aVDev;
+ const MapMode aMap( mpDoc->GetScaleUnit(), Point(), rSettings.maScaleX, rSettings.maScaleY );
+
+ SdrOutliner& rOutl=mpDoc->GetDrawOutliner(NULL);
+ maOldCalcFieldValueHdl = rOutl.GetCalcFieldValueHdl();
+ rOutl.SetCalcFieldValueHdl( LINK(this, GraphicExporter, CalcFieldValueHdl) );
+ rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor() );
+
+ // #i102251#
+ const sal_uInt32 nOldCntrl(rOutl.GetControlWord());
+ sal_uInt32 nCntrl = nOldCntrl & ~EE_CNTRL_ONLINESPELLING;
+ rOutl.SetControlWord(nCntrl);
+
+ SdrObject* pTempBackgroundShape = 0;
+ std::vector< SdrObject* > aShapes;
+ bool bRet = true;
+
+ // export complete page?
+ if ( !mxShape.is() )
+ {
+ if( rSettings.mbExportOnlyBackground )
+ {
+ const SdrPageProperties* pCorrectProperties = pPage->getCorrectSdrPageProperties();
+
+ if(pCorrectProperties)
+ {
+ pTempBackgroundShape = new SdrRectObj(Rectangle(Point(0,0), pPage->GetSize()));
+ pTempBackgroundShape->SetMergedItemSet(pCorrectProperties->GetItemSet());
+ pTempBackgroundShape->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pTempBackgroundShape->NbcSetStyleSheet(pCorrectProperties->GetStyleSheet(), true);
+ aShapes.push_back(pTempBackgroundShape);
+ }
+ }
+ else
+ {
+ const Size aSize( pPage->GetSize() );
+
+ // generate a bitmap to convert it to a pixel format.
+ // For gif pictures there can also be a vector format used (bTranslucent)
+ if ( !bVectorType && !rSettings.mbTranslucent )
+ {
+ long nWidthPix = 0;
+ long nHeightPix = 0;
+ if ( rSettings.mnWidth > 0 && rSettings.mnHeight > 0 )
+ {
+ nWidthPix = rSettings.mnWidth;
+ nHeightPix = rSettings.mnHeight;
+ }
+ else
+ {
+ const Size aSizePix( Application::GetDefaultDevice()->LogicToPixel( aSize, aMap ) );
+ if (aSizePix.Width() > MAX_EXT_PIX || aSizePix.Height() > MAX_EXT_PIX)
+ {
+ if (aSizePix.Width() > MAX_EXT_PIX)
+ nWidthPix = MAX_EXT_PIX;
+ else
+ nWidthPix = aSizePix.Width();
+ if (aSizePix.Height() > MAX_EXT_PIX)
+ nHeightPix = MAX_EXT_PIX;
+ else
+ nHeightPix = aSizePix.Height();
+
+ double fWidthDif = aSizePix.Width() / nWidthPix;
+ double fHeightDif = aSizePix.Height() / nHeightPix;
+
+ if (fWidthDif > fHeightDif)
+ nHeightPix = static_cast<long>(aSizePix.Height() / fWidthDif);
+ else
+ nWidthPix = static_cast<long>(aSizePix.Width() / fHeightDif);
+ }
+ else
+ {
+ nWidthPix = aSizePix.Width();
+ nHeightPix = aSizePix.Height();
+ }
+ }
+
+ boost::scoped_ptr< SdrView > pLocalView;
+ if( PTR_CAST( FmFormModel, mpDoc ) )
+ {
+ pLocalView.reset( new FmFormView( PTR_CAST( FmFormModel, mpDoc ), &aVDev ) );
+ }
+ else
+ {
+ pLocalView.reset( new SdrView( mpDoc, &aVDev ) );
+ }
+
+
+ VirtualDevice* pVDev = CreatePageVDev( pPage, nWidthPix, nHeightPix );
+
+ if( pVDev )
+ {
+ aGraphic = pVDev->GetBitmap( Point(), pVDev->GetOutputSize() );
+ aGraphic.SetPrefMapMode( aMap );
+ aGraphic.SetPrefSize( aSize );
+ delete pVDev;
+ }
+ }
+ // create a metafile to export a vector format
+ else
+ {
+ GDIMetaFile aMtf;
+
+ aVDev.SetMapMode( aMap );
+ if( rSettings.mbUseHighContrast )
+ aVDev.SetDrawMode( aVDev.GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+ aVDev.EnableOutput( FALSE );
+ aMtf.Record( &aVDev );
+ Size aNewSize;
+
+ // create a view
+ SdrView* pView;
+
+ if( PTR_CAST( FmFormModel, mpDoc ) )
+ {
+ pView = new FmFormView( PTR_CAST( FmFormModel, mpDoc ), &aVDev );
+ }
+ else
+ {
+ pView = new SdrView( mpDoc, &aVDev );
+ }
+
+ pView->SetBordVisible( FALSE );
+ pView->SetPageVisible( FALSE );
+ pView->ShowSdrPage( pPage );
+
+ if ( pView && pPage )
+ {
+ pView->SetBordVisible( FALSE );
+ pView->SetPageVisible( FALSE );
+ pView->ShowSdrPage( pPage );
+
+ const Point aNewOrg( pPage->GetLftBorder(), pPage->GetUppBorder() );
+ aNewSize = Size( aSize.Width() - pPage->GetLftBorder() - pPage->GetRgtBorder(),
+ aSize.Height() - pPage->GetUppBorder() - pPage->GetLwrBorder() );
+ const Rectangle aClipRect( aNewOrg, aNewSize );
+ MapMode aVMap( aMap );
+
+ aVDev.Push();
+ aVMap.SetOrigin( Point( -aNewOrg.X(), -aNewOrg.Y() ) );
+ aVDev.SetRelativeMapMode( aVMap );
+ aVDev.IntersectClipRegion( aClipRect );
+
+ // Use new StandardCheckVisisbilityRedirector
+ ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
+
+ pView->CompleteRedraw(&aVDev, Region(Rectangle(Point(), aNewSize)), &aRedirector);
+
+ aVDev.Pop();
+
+ aMtf.Stop();
+ aMtf.WindStart();
+ aMtf.SetPrefMapMode( aMap );
+ aMtf.SetPrefSize( aNewSize );
+
+ // AW: Here the current version was filtering out the META_CLIPREGION_ACTIONs
+ // from the metafile. I asked some other developers why this was done, but no
+ // one knew a direct reason. Since it's in for long time, it may be an old
+ // piece of code. MetaFiles save and load ClipRegions with polygons with preserving
+ // the polygons, so a resolution-indepent roundtrip is supported. Removed this
+ // code since it destroys some MetaFiles where ClipRegions are used. Anyways,
+ // just filtering them out is a hack, at least the encapsulated content would need
+ // to be clipped geometrically.
+ aGraphic = Graphic(aMtf);
+ }
+
+ if ( pView )
+ {
+ pView->HideSdrPage();
+ delete pView;
+ }
+
+ if( rSettings.mbTranslucent )
+ {
+ Size aOutSize;
+ aGraphic = GetBitmapFromMetaFile( aGraphic.GetGDIMetaFile(), TRUE, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aNewSize, aOutSize ) );
+ }
+ }
+ }
+ }
+
+ // export only single shape or shape collection
+ else
+ {
+ // build list of SdrObject
+ if( mxShapes.is() )
+ {
+ Reference< XShape > xShape;
+ const sal_Int32 nCount = mxShapes->getCount();
+
+ for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
+ {
+ mxShapes->getByIndex( nIndex ) >>= xShape;
+ SdrObject* pObj = GetSdrObjectFromXShape( xShape );
+ if( pObj )
+ aShapes.push_back( pObj );
+ }
+ }
+ else
+ {
+ // only one shape
+ SdrObject* pObj = GetSdrObjectFromXShape( mxShape );
+ if( pObj )
+ aShapes.push_back( pObj );
+ }
+
+ if( 0 == aShapes.size() )
+ bRet = false;
+ }
+
+ if( bRet && aShapes.size() )
+ {
+ // special treatment for only one SdrGrafObj that has text
+ sal_Bool bSingleGraphic = sal_False;
+
+ if( 1 == aShapes.size() )
+ {
+ if( !bVectorType )
+ {
+ SdrObject* pObj = aShapes.front();
+ if( pObj && pObj->ISA( SdrGrafObj ) && !( (SdrGrafObj*) pObj )->HasText() )
+ {
+ aGraphic = ( (SdrGrafObj*) pObj )->GetTransformedGraphic();
+ if ( aGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+ Size aSizePixel( aGraphic.GetSizePixel() );
+ if( rSettings.mnWidth && rSettings.mnHeight &&
+ ( ( rSettings.mnWidth != aSizePixel.Width() ) ||
+ ( rSettings.mnHeight != aSizePixel.Height() ) ) )
+ {
+ BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
+ aBmpEx.Scale( Size( rSettings.mnWidth, rSettings.mnHeight ) );
+ aGraphic = aBmpEx;
+ }
+ }
+ bSingleGraphic = sal_True;
+ }
+ }
+ else if( rSettings.mbScrollText )
+ {
+ SdrObject* pObj = aShapes.front();
+ if( pObj && pObj->ISA( SdrTextObj )
+ && ( (SdrTextObj*) pObj )->HasText() )
+ {
+ Rectangle aScrollRectangle;
+ Rectangle aPaintRectangle;
+
+ const boost::scoped_ptr< GDIMetaFile > pMtf(
+ ( (SdrTextObj*) pObj )->GetTextScrollMetaFileAndRectangle(
+ aScrollRectangle, aPaintRectangle ) );
+
+ // take the larger one of the two rectangles (that
+ // should be the bound rect of the retrieved
+ // metafile)
+ Rectangle aTextRect;
+
+ if( aScrollRectangle.IsInside( aPaintRectangle ) )
+ aTextRect = aScrollRectangle;
+ else
+ aTextRect = aPaintRectangle;
+
+ // setup pref size and mapmode
+ pMtf->SetPrefSize( aTextRect.GetSize() );
+
+ // set actual origin (mtf is at actual shape
+ // output position)
+ MapMode aLocalMapMode( aMap );
+ aLocalMapMode.SetOrigin(
+ Point( -aPaintRectangle.Left(),
+ -aPaintRectangle.Top() ) );
+ pMtf->SetPrefMapMode( aLocalMapMode );
+
+ pMtf->AddAction( new MetaCommentAction(
+ "XTEXT_SCROLLRECT", 0,
+ reinterpret_cast<BYTE const*>(&aScrollRectangle),
+ sizeof( Rectangle ) ) );
+ pMtf->AddAction( new MetaCommentAction(
+ "XTEXT_PAINTRECT", 0,
+ reinterpret_cast<BYTE const*>(&aPaintRectangle),
+ sizeof( Rectangle ) ) );
+
+ aGraphic = Graphic( *pMtf );
+
+ bSingleGraphic = sal_True;
+ }
+ }
+ }
+
+ if( !bSingleGraphic )
+ {
+ // create a metafile for all shapes
+ VirtualDevice aOut;
+
+ // calculate bound rect for all shapes
+ Rectangle aBound;
+
+ {
+ std::vector< SdrObject* >::iterator aIter = aShapes.begin();
+ const std::vector< SdrObject* >::iterator aEnd = aShapes.end();
+
+ while( aIter != aEnd )
+ {
+ SdrObject* pObj = (*aIter++);
+ Rectangle aR1(pObj->GetCurrentBoundRect());
+ if (aBound.IsEmpty())
+ aBound=aR1;
+ else
+ aBound.Union(aR1);
+ }
+ }
+
+ aOut.EnableOutput( FALSE );
+ aOut.SetMapMode( aMap );
+ if( rSettings.mbUseHighContrast )
+ aOut.SetDrawMode( aVDev.GetDrawMode() | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+
+ GDIMetaFile aMtf;
+ aMtf.Clear();
+ aMtf.Record( &aOut );
+
+ MapMode aOutMap( aMap );
+ aOutMap.SetOrigin( Point( -aBound.TopLeft().X(), -aBound.TopLeft().Y() ) );
+ aOut.SetRelativeMapMode( aOutMap );
+
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ if(mpCurrentPage)
+ {
+ if(mpCurrentPage->TRG_HasMasterPage() && pPage->IsMasterPage())
+ {
+ // MasterPage is processed as another page's SubContent
+ aDisplayInfo.SetProcessLayers(mpCurrentPage->TRG_GetMasterPageVisibleLayers());
+ aDisplayInfo.SetSubContentActive(true);
+ }
+ }
+
+ if(aShapes.size())
+ {
+ // more effective way to paint a vector of SdrObjects. Hand over the processed page
+ // to have it in the
+ sdr::contact::ObjectContactOfObjListPainter aMultiObjectPainter(aOut, aShapes, mpCurrentPage);
+ ImplExportCheckVisisbilityRedirector aCheckVisibilityRedirector(mpCurrentPage);
+ aMultiObjectPainter.SetViewObjectContactRedirector(&aCheckVisibilityRedirector);
+
+ aMultiObjectPainter.ProcessDisplay(aDisplayInfo);
+ }
+
+ aMtf.Stop();
+ aMtf.WindStart();
+
+ const Size aExtSize( aOut.PixelToLogic( Size( 0, 0 ) ) );
+ Size aBoundSize( aBound.GetWidth() + ( aExtSize.Width() ),
+ aBound.GetHeight() + ( aExtSize.Height() ) );
+
+ aMtf.SetPrefMapMode( aMap );
+ aMtf.SetPrefSize( aBoundSize );
+
+ if( !bVectorType )
+ {
+ Size aOutSize;
+ aGraphic = GetBitmapFromMetaFile( aMtf, rSettings.mbTranslucent, CalcSize( rSettings.mnWidth, rSettings.mnHeight, aBoundSize, aOutSize ) );
+ }
+ else
+ {
+ aGraphic = aMtf;
+ }
+ }
+ }
+
+ if(pTempBackgroundShape)
+ {
+ SdrObject::Free(pTempBackgroundShape);
+ }
+
+ rOutl.SetCalcFieldValueHdl( maOldCalcFieldValueHdl );
+
+ // #i102251#
+ rOutl.SetControlWord(nOldCntrl);
+
+ return bRet;
+
+}
+
+// XFilter
+sal_Bool SAL_CALL GraphicExporter::filter( const Sequence< PropertyValue >& aDescriptor )
+ throw(RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( NULL == mpUnoPage )
+ return sal_False;
+
+ GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter();
+
+ if( NULL == pFilter || NULL == mpUnoPage->GetSdrPage() || NULL == mpDoc )
+ return sal_False;
+
+ // get the arguments from the descriptor
+ ExportSettings aSettings( mpDoc );
+ ParseSettings( aDescriptor, aSettings );
+
+ const sal_uInt16 nFilter = aSettings.maMediaType.getLength()
+ ? pFilter->GetExportFormatNumberForMediaType( aSettings.maMediaType )
+ : pFilter->GetExportFormatNumberForShortName( aSettings.maFilterName );
+ sal_Bool bVectorType = !pFilter->IsExportPixelFormat( nFilter );
+
+ // create the output stuff
+ Graphic aGraphic;
+
+ USHORT nStatus = GetGraphic( aSettings, aGraphic, bVectorType ) ? GRFILTER_OK : GRFILTER_FILTERERROR;
+
+ if( nStatus == GRFILTER_OK )
+ {
+ // export graphic only if it has a size
+ const Size aGraphSize( aGraphic.GetPrefSize() );
+ if ( ( aGraphSize.Width() == 0 ) || ( aGraphSize.Height() == 0 ) )
+ {
+ nStatus = GRFILTER_FILTERERROR;
+ }
+ else
+ {
+ // now we have a graphic, so export it
+ if( aSettings.mxGraphicRenderer.is() )
+ {
+ // render graphic directly into given renderer
+ aSettings.mxGraphicRenderer->render( aGraphic.GetXGraphic() );
+ }
+ else if( aSettings.mxOutputStream.is() )
+ {
+ // TODO: Either utilize optional XSeekable functionality for the
+ // SvOutputStream, or adapt the graphic filter to not seek anymore.
+ SvMemoryStream aStream( 1024, 1024 );
+
+ nStatus = pFilter->ExportGraphic( aGraphic, String(), aStream, nFilter, &aSettings.maFilterData );
+
+ // copy temp stream to XOutputStream
+ SvOutputStream aOutputStream( aSettings.mxOutputStream );
+ aStream.Seek(0);
+ aOutputStream << aStream;
+ }
+ else
+ {
+ INetURLObject aURLObject( aSettings.maURL.Complete );
+ DBG_ASSERT( aURLObject.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
+
+ nStatus = XOutBitmap::ExportGraphic( aGraphic, aURLObject, *pFilter, nFilter, &aSettings.maFilterData );
+ }
+ }
+ }
+
+ if ( aSettings.mxInteractionHandler.is() && ( nStatus != GRFILTER_OK ) )
+ {
+ Any aInteraction;
+ Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > lContinuations(1);
+ ::framework::ContinuationApprove* pApprove = new ::framework::ContinuationApprove();
+ lContinuations[0] = Reference< XInteractionContinuation >(static_cast< XInteractionContinuation* >(pApprove), UNO_QUERY);
+
+ GraphicFilterRequest aErrorCode;
+ aErrorCode.ErrCode = nStatus;
+ aInteraction <<= aErrorCode;
+ framework::InteractionRequest* pRequest = new framework::InteractionRequest( aInteraction, lContinuations );
+ Reference< XInteractionRequest >xRequest( static_cast< XInteractionRequest* >(pRequest), UNO_QUERY );
+ aSettings.mxInteractionHandler->handle( xRequest );
+ }
+ return nStatus == GRFILTER_OK;
+}
+
+void SAL_CALL GraphicExporter::cancel()
+ throw(RuntimeException)
+{
+}
+
+// XExporter
+
+/** the source 'document' could be a XDrawPage, a XShape or a generic XShapes */
+void SAL_CALL GraphicExporter::setSourceDocument( const Reference< lang::XComponent >& xComponent )
+ throw(IllegalArgumentException, RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ mxShapes = NULL;
+ mpUnoPage = NULL;
+
+ try
+ {
+ // any break inside this one loop while will throw a IllegalArgumentException
+ do
+ {
+ mxPage = Reference< XDrawPage >::query( xComponent );
+ mxShapes = Reference< XShapes >::query( xComponent );
+ mxShape = Reference< XShape >::query( xComponent );
+
+ // Step 1: try a generic XShapes
+ if( !mxPage.is() && !mxShape.is() && mxShapes.is() )
+ {
+ // we do not support empty shape collections
+ if( 0 == mxShapes->getCount() )
+ break;
+
+ // get first shape to detect corresponding page and model
+ mxShapes->getByIndex(0) >>= mxShape;
+ }
+ else
+ {
+ mxShapes = NULL;
+ }
+
+ // Step 2: try a shape
+ if( mxShape.is() )
+ {
+ if( NULL == GetSdrObjectFromXShape( mxShape ) )
+ break;
+
+ // get page for this shape
+ Reference< XChild > xChild( mxShape, UNO_QUERY );
+ if( !xChild.is() )
+ break;
+
+ Reference< XInterface > xInt;
+ do
+ {
+ xInt = xChild->getParent();
+ mxPage = Reference< XDrawPage >::query( xInt );
+ if( !mxPage.is() )
+ xChild = Reference< XChild >::query( xInt );
+ }
+ while( !mxPage.is() && xChild.is() );
+
+ if( !mxPage.is() )
+ break;
+ }
+
+ // Step 3: check the page
+ if( !mxPage.is() )
+ break;
+
+ mpUnoPage = SvxDrawPage::getImplementation( mxPage );
+
+ if( NULL == mpUnoPage || NULL == mpUnoPage->GetSdrPage() )
+ break;
+
+ mpDoc = mpUnoPage->GetSdrPage()->GetModel();
+
+ // Step 4: If we got a generic XShapes test all contained shapes
+ // if they belong to the same XDrawPage
+
+ if( mxShapes.is() )
+ {
+ SdrPage* pPage = mpUnoPage->GetSdrPage();
+ SdrObject* pObj;
+ Reference< XShape > xShape;
+
+ sal_Bool bOk = sal_True;
+
+ const sal_Int32 nCount = mxShapes->getCount();
+
+ // test all but the first shape if they have the same page than
+ // the first shape
+ for( sal_Int32 nIndex = 1; bOk && ( nIndex < nCount ); nIndex++ )
+ {
+ mxShapes->getByIndex( nIndex ) >>= xShape;
+ pObj = GetSdrObjectFromXShape( xShape );
+ bOk = pObj && pObj->GetPage() == pPage;
+ }
+
+ if( !bOk )
+ break;
+ }
+
+ // no errors so far
+ return;
+ }
+ while( 0 );
+ }
+ catch( Exception& )
+ {
+ }
+
+ throw IllegalArgumentException();
+}
+
+// XServiceInfo
+OUString SAL_CALL GraphicExporter::getImplementationName( )
+ throw(RuntimeException)
+{
+ return GraphicExporter_getImplementationName();
+}
+
+sal_Bool SAL_CALL GraphicExporter::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ Sequence< OUString > aSeq( GraphicExporter_getSupportedServiceNames() );
+ sal_Int32 nArgs = aSeq.getLength();
+ const OUString* pService = aSeq.getConstArray();
+ while( nArgs-- )
+ if( *pService++ == ServiceName )
+ return sal_True;
+
+ return sal_False;
+}
+
+Sequence< OUString > SAL_CALL GraphicExporter::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ return GraphicExporter_getSupportedServiceNames();
+}
+
+// XMimeTypeInfo
+sal_Bool SAL_CALL GraphicExporter::supportsMimeType( const OUString& MimeTypeName ) throw (RuntimeException)
+{
+ const String aMimeTypeName( MimeTypeName );
+
+ GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter();
+ sal_uInt16 nCount = pFilter->GetExportFormatCount();
+ sal_uInt16 nFilter;
+ for( nFilter = 0; nFilter < nCount; nFilter++ )
+ {
+ if( aMimeTypeName.Equals( pFilter->GetExportFormatMediaType( nFilter ) ) )
+ {
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+Sequence< OUString > SAL_CALL GraphicExporter::getSupportedMimeTypeNames( ) throw (RuntimeException)
+{
+ GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter();
+ sal_uInt16 nCount = pFilter->GetExportFormatCount();
+ sal_uInt16 nFilter;
+ sal_uInt16 nFound = 0;
+
+ Sequence< OUString > aSeq( nCount );
+ OUString* pStr = aSeq.getArray();
+
+ for( nFilter = 0; nFilter < nCount; nFilter++ )
+ {
+ OUString aMimeType( pFilter->GetExportFormatMediaType( nFilter ) );
+ if( aMimeType.getLength() )
+ {
+ *pStr++ = aMimeType;
+ nFound++;
+ }
+ }
+
+ if( nFound < nCount )
+ aSeq.realloc( nFound );
+
+ return aSeq;
+}
+
+Graphic SvxGetGraphicForShape( SdrObject& rShape, bool bVector )
+{
+ Graphic aGraphic;
+ try
+ {
+ rtl::Reference< GraphicExporter > xExporter( new GraphicExporter() );
+ Reference< XComponent > xComp( rShape.getUnoShape(), UNO_QUERY_THROW );
+ xExporter->setSourceDocument( xComp );
+ ExportSettings aSettings( rShape.GetModel() );
+ xExporter->GetGraphic( aSettings, aGraphic, bVector );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SvxGetGraphicForShape(), exception caught!");
+ }
+ return aGraphic;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/UnoGraphicExporter.hxx b/svx/source/unodraw/UnoGraphicExporter.hxx
new file mode 100644
index 000000000000..775e6acaa368
--- /dev/null
+++ b/svx/source/unodraw/UnoGraphicExporter.hxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_UNOGRAPHICEXPORTER_HXX_
+#define _SVX_UNOGRAPHICEXPORTER_HXX_
+
+#include <com/sun/star/uno/XInterface.hpp>
+
+namespace svx
+{
+ SVX_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GraphicExporter_createInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr) throw( ::com::sun::star::uno::Exception );
+ SVX_DLLPUBLIC ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GraphicExporter_getSupportedServiceNames() throw();
+ SVX_DLLPUBLIC ::rtl::OUString SAL_CALL GraphicExporter_getImplementationName() throw();
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/UnoNameItemTable.cxx b/svx/source/unodraw/UnoNameItemTable.cxx
new file mode 100644
index 000000000000..f053554873f5
--- /dev/null
+++ b/svx/source/unodraw/UnoNameItemTable.cxx
@@ -0,0 +1,343 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <set>
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
+#include <svl/style.hxx>
+#include <comphelper/stl_types.hxx>
+
+#include <svx/svdmodel.hxx>
+#include "UnoNameItemTable.hxx"
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#include "unoapi.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+using namespace ::cppu;
+
+SvxUnoNameItemTable::SvxUnoNameItemTable( SdrModel* pModel, USHORT nWhich, BYTE nMemberId ) throw()
+: mpModel( pModel ),
+ mpModelPool( pModel ? &pModel->GetItemPool() : NULL ),
+ mnWhich( nWhich ), mnMemberId( nMemberId )
+{
+ if( pModel )
+ StartListening( *pModel );
+}
+
+SvxUnoNameItemTable::~SvxUnoNameItemTable() throw()
+{
+ if( mpModel )
+ EndListening( *mpModel );
+ dispose();
+}
+
+bool SvxUnoNameItemTable::isValid( const NameOrIndex* pItem ) const
+{
+ return pItem && (pItem->GetName().Len() != 0);
+}
+
+void SvxUnoNameItemTable::dispose()
+{
+ ItemPoolVector::iterator aIter = maItemSetVector.begin();
+ const ItemPoolVector::iterator aEnd = maItemSetVector.end();
+
+ while( aIter != aEnd )
+ {
+ delete (*aIter++);
+ }
+
+ maItemSetVector.clear();
+}
+
+void SvxUnoNameItemTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
+{
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+
+ if( pSdrHint && HINT_MODELCLEARED == pSdrHint->GetKind() )
+ dispose();
+}
+
+sal_Bool SAL_CALL SvxUnoNameItemTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
+{
+ uno::Sequence< OUString > aSNL( getSupportedServiceNames() );
+ const OUString * pArray = aSNL.getConstArray();
+
+ for( INT32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return TRUE;
+
+ return FALSE;
+}
+
+void SAL_CALL SvxUnoNameItemTable::ImplInsertByName( const OUString& aName, const uno::Any& aElement )
+{
+ SfxItemSet* mpInSet = new SfxItemSet( *mpModelPool, mnWhich, mnWhich );
+ maItemSetVector.push_back( mpInSet );
+
+ NameOrIndex* pNewItem = createItem();
+ pNewItem->SetName( String( aName ) );
+ pNewItem->PutValue( aElement, mnMemberId );
+ mpInSet->Put( *pNewItem, mnWhich );
+ delete pNewItem;
+}
+
+// XNameContainer
+void SAL_CALL SvxUnoNameItemTable::insertByName( const OUString& aApiName, const uno::Any& aElement )
+ throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if( hasByName( aApiName ) )
+ throw container::ElementExistException();
+
+ String aName;
+ SvxUnogetInternalNameForItem( mnWhich, aApiName, aName );
+
+ ImplInsertByName( aName, aElement );
+}
+
+
+
+void SAL_CALL SvxUnoNameItemTable::removeByName( const OUString& aApiName )
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // a little quickfix for 2.0 to let applications clear api
+ // created items that are not used
+ if( aApiName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("~clear~") ) )
+ {
+ dispose();
+ return;
+ }
+
+ String Name;
+ SvxUnogetInternalNameForItem( mnWhich, aApiName, Name );
+
+ ItemPoolVector::iterator aIter = maItemSetVector.begin();
+ const ItemPoolVector::iterator aEnd = maItemSetVector.end();
+
+ NameOrIndex *pItem;
+ const String aSearchName( Name );
+
+ while( aIter != aEnd )
+ {
+ pItem = (NameOrIndex *)&((*aIter)->Get( mnWhich ) );
+ if( pItem->GetName() == aSearchName )
+ {
+ delete (*aIter);
+ maItemSetVector.erase( aIter );
+ return;
+ }
+ aIter++;
+ }
+
+ if( !hasByName( Name ) )
+ throw container::NoSuchElementException();
+}
+
+// XNameReplace
+void SAL_CALL SvxUnoNameItemTable::replaceByName( const OUString& aApiName, const uno::Any& aElement )
+ throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ String aName;
+ SvxUnogetInternalNameForItem( mnWhich, aApiName, aName );
+
+ ItemPoolVector::iterator aIter = maItemSetVector.begin();
+ const ItemPoolVector::iterator aEnd = maItemSetVector.end();
+
+ NameOrIndex *pItem;
+ const String aSearchName( aName );
+
+ while( aIter != aEnd )
+ {
+ pItem = (NameOrIndex *)&((*aIter)->Get( mnWhich ) );
+ if( pItem->GetName() == aSearchName )
+ {
+ NameOrIndex* pNewItem = createItem();
+ pNewItem->SetName( aSearchName );
+ if( !pNewItem->PutValue( aElement, mnMemberId ) || !isValid( pNewItem ) )
+ throw lang::IllegalArgumentException();
+
+ (*aIter)->Put( *pNewItem );
+ return;
+ }
+ aIter++;
+ }
+
+ // if it is not in our own sets, modify the pool!
+ sal_Bool bFound = sal_False;
+
+ USHORT nSurrogate;
+ USHORT nCount = mpModelPool ? mpModelPool->GetItemCount( mnWhich ) : 0;
+ for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, nSurrogate);
+ if( pItem && pItem->GetName() == aSearchName )
+ {
+ pItem->PutValue( aElement, mnMemberId );
+ bFound = sal_True;
+ break;
+ }
+ }
+
+ if( bFound )
+ ImplInsertByName( aName, aElement );
+ else
+ throw container::NoSuchElementException();
+
+ if( !hasByName( aName ) )
+ throw container::NoSuchElementException();
+}
+
+// XNameAccess
+uno::Any SAL_CALL SvxUnoNameItemTable::getByName( const OUString& aApiName )
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aName;
+ SvxUnogetInternalNameForItem( mnWhich, aApiName, aName );
+
+ uno::Any aAny;
+
+ if( mpModelPool && aName.Len() != 0 )
+ {
+ const String aSearchName( aName );
+ NameOrIndex *pItem;
+ sal_Int32 nSurrogate;
+
+ sal_Int32 nSurrogateCount = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( mnWhich ) : 0;
+ for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, (USHORT)nSurrogate );
+
+ if( isValid( pItem ) && (pItem->GetName() == aSearchName) )
+ {
+ pItem->QueryValue( aAny, mnMemberId );
+ return aAny;
+ }
+ }
+ }
+
+ throw container::NoSuchElementException();
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoNameItemTable::getElementNames( )
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ std::set< OUString, comphelper::UStringLess > aNameSet;
+
+ NameOrIndex *pItem;
+ OUString aApiName;
+
+ const sal_Int32 nSurrogateCount = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( mnWhich ) : 0;
+ sal_Int32 nSurrogate;
+ for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, (USHORT)nSurrogate );
+
+ if( !isValid( pItem ) )
+ continue;
+
+ SvxUnogetApiNameForItem( mnWhich, pItem->GetName(), aApiName );
+ aNameSet.insert( aApiName );
+ }
+
+ uno::Sequence< OUString > aSeq( aNameSet.size() );
+ OUString* pNames = aSeq.getArray();
+
+ std::set< OUString, comphelper::UStringLess >::iterator aIter( aNameSet.begin() );
+ const std::set< OUString, comphelper::UStringLess >::iterator aEnd( aNameSet.end() );
+
+ while( aIter != aEnd )
+ {
+ *pNames++ = *aIter++;
+ }
+
+ return aSeq;
+}
+
+sal_Bool SAL_CALL SvxUnoNameItemTable::hasByName( const OUString& aApiName )
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ String aName;
+ SvxUnogetInternalNameForItem( mnWhich, aApiName, aName );
+
+ if( aName.Len() == 0 )
+ return sal_False;
+
+ const String aSearchName( aName );
+ USHORT nSurrogate;
+
+ const NameOrIndex *pItem;
+
+ USHORT nCount = mpModelPool ? mpModelPool->GetItemCount( mnWhich ) : 0;
+ for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, nSurrogate );
+ if( isValid( pItem ) && (pItem->GetName() == aSearchName) )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+sal_Bool SAL_CALL SvxUnoNameItemTable::hasElements( )
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ const NameOrIndex *pItem;
+
+ sal_Int32 nSurrogate;
+ const sal_Int32 nSurrogateCount = mpModelPool ? (sal_Int32)mpModelPool->GetItemCount( mnWhich ) : 0;
+ for( nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( mnWhich, (USHORT)nSurrogate );
+
+ if( isValid( pItem ) )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/UnoNameItemTable.hxx b/svx/source/unodraw/UnoNameItemTable.hxx
new file mode 100644
index 000000000000..fe919c2a9791
--- /dev/null
+++ b/svx/source/unodraw/UnoNameItemTable.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_UNONAMEITEMTABLE_HXX_
+#define _SVX_UNONAMEITEMTABLE_HXX_
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+
+#include <cppuhelper/implbase2.hxx>
+
+#include <vector>
+#include <svl/lstner.hxx>
+#include <svx/xit.hxx>
+
+#include <svx/xdef.hxx>
+
+class SdrModel;
+class SfxItemPool;
+class SfxItemSet;
+
+typedef std::vector< SfxItemSet* > ItemPoolVector;
+class SvxUnoNameItemTable : public cppu::WeakImplHelper2< com::sun::star::container::XNameContainer, com::sun::star::lang::XServiceInfo >,
+ public SfxListener
+{
+private:
+ SdrModel* mpModel;
+ SfxItemPool* mpModelPool;
+ USHORT mnWhich;
+ BYTE mnMemberId;
+
+ ItemPoolVector maItemSetVector;
+
+ void SAL_CALL ImplInsertByName( const rtl::OUString& aName, const com::sun::star::uno::Any& aElement );
+
+public:
+ SvxUnoNameItemTable( SdrModel* pModel, USHORT nWhich, BYTE nMemberId ) throw();
+ virtual ~SvxUnoNameItemTable() throw();
+
+ virtual NameOrIndex* createItem() const throw() = 0;
+ virtual bool isValid( const NameOrIndex* pItem ) const;
+
+ void dispose();
+
+ // SfxListener
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw ();
+
+ // XServiceInfo
+ virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) throw( com::sun::star::uno::RuntimeException);
+
+ // XNameContainer
+ virtual void SAL_CALL insertByName( const rtl::OUString& aName, const com::sun::star::uno::Any& aElement ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::ElementExistException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeByName( const rtl::OUString& Name ) throw( com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException);
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const rtl::OUString& aName, const com::sun::star::uno::Any& aElement ) throw( com::sun::star::lang::IllegalArgumentException, com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException);
+
+ // XNameAccess
+ virtual com::sun::star::uno::Any SAL_CALL getByName( const rtl::OUString& aName ) throw( com::sun::star::container::NoSuchElementException, com::sun::star::lang::WrappedTargetException, com::sun::star::uno::RuntimeException);
+ virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getElementNames( ) throw( com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw( com::sun::star::uno::RuntimeException);
+
+ // XElementAccess
+ virtual sal_Bool SAL_CALL hasElements( ) throw( com::sun::star::uno::RuntimeException);
+};
+
+#endif // _SVX_UNONAMEITEMTABLE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/UnoNamespaceMap.cxx b/svx/source/unodraw/UnoNamespaceMap.cxx
new file mode 100644
index 000000000000..ff1291077702
--- /dev/null
+++ b/svx/source/unodraw/UnoNamespaceMap.cxx
@@ -0,0 +1,315 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <set>
+
+#include "UnoNamespaceMap.hxx"
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <cppuhelper/implbase2.hxx>
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+#include <comphelper/stl_types.hxx>
+#include <svl/itempool.hxx>
+#include "unoapi.hxx"
+#include "editeng/xmlcnitm.hxx"
+
+
+using namespace ::comphelper;
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+
+namespace svx
+{
+ /** implements a component to export namespaces of all SvXMLAttrContainerItem inside
+ one or two pools with a variable count of which ids.
+ */
+ class NamespaceMap : public WeakImplHelper2< XNameAccess, XServiceInfo >
+ {
+ private:
+ sal_uInt16* mpWhichIds;
+ SfxItemPool* mpPool;
+
+ public:
+ NamespaceMap( sal_uInt16* pWhichIds, SfxItemPool* pPool );
+ virtual ~NamespaceMap();
+
+ // XNameAccess
+ virtual Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (RuntimeException);
+
+ // XElementAccess
+ virtual Type SAL_CALL getElementType( ) throw (RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( ) throw (RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException);
+ };
+
+ Reference< XInterface > SAL_CALL NamespaceMap_createInstance( sal_uInt16* pWhichIds, SfxItemPool* pPool1, SfxItemPool* )
+ {
+ return (XWeak*)new NamespaceMap( pWhichIds, pPool1 );
+ }
+
+ Reference< XInterface > SAL_CALL NamespaceMap_createInstance( sal_uInt16* pWhichIds, SfxItemPool* pPool )
+ {
+ return (XWeak*)new NamespaceMap( pWhichIds, pPool );
+ }
+
+ Sequence< ::rtl::OUString > SAL_CALL NamespaceMap_getSupportedServiceNames()
+ throw()
+ {
+ Sequence< ::rtl::OUString > aSupportedServiceNames( 1 );
+ aSupportedServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.NamespaceMap" ) );
+ return aSupportedServiceNames;
+ }
+
+ ::rtl::OUString SAL_CALL NamespaceMap_getImplementationName()
+ throw()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Svx.NamespaceMap" ) );
+ }
+
+
+
+ class NamespaceIteratorImpl
+ {
+ private:
+ SfxItemPool* mpPool;
+
+ sal_uInt16* mpWhichId;
+
+ sal_uInt16 mnItemCount;
+ sal_uInt16 mnItem;
+
+ const SvXMLAttrContainerItem* mpCurrentAttr;
+ sal_uInt16 mnCurrentAttr;
+
+ public:
+
+ NamespaceIteratorImpl( sal_uInt16* pWhichIds, SfxItemPool* pPool );
+
+ sal_Bool next( ::rtl::OUString& rPrefix, ::rtl::OUString& rURL );
+ };
+}
+
+using namespace ::svx;
+
+// -------------
+
+NamespaceIteratorImpl::NamespaceIteratorImpl( sal_uInt16* pWhichIds, SfxItemPool* pPool )
+{
+ mpPool = pPool;
+ mpCurrentAttr = NULL;
+ mnCurrentAttr = 0;
+
+ mpWhichId = pWhichIds;
+
+ mnItem = 0;
+ mnItemCount = (mpWhichId && (0 != *mpWhichId) && mpPool) ? mpPool->GetItemCount( *mpWhichId ) : 0;
+}
+
+sal_Bool NamespaceIteratorImpl::next( ::rtl::OUString& rPrefix, ::rtl::OUString& rURL )
+{
+ // we still need to process the current attribute
+ if( mpCurrentAttr && (mnCurrentAttr != USHRT_MAX) )
+ {
+ rPrefix = mpCurrentAttr->GetPrefix( mnCurrentAttr );
+ rURL = mpCurrentAttr->GetNamespace( mnCurrentAttr );
+
+ mnCurrentAttr = mpCurrentAttr->GetNextNamespaceIndex( mnCurrentAttr );
+ return sal_True;
+ }
+
+ // we need the next namespace item
+ mpCurrentAttr = NULL;
+
+ const SfxPoolItem* pItem = 0;
+ // look for the next available item in the current pool
+ while( (mnItem < mnItemCount) && ( NULL == (pItem = mpPool->GetItem( *mpWhichId, mnItem ) ) ) )
+ mnItem++;
+
+ // are we finished with the current whichid?
+ if( mnItem == mnItemCount )
+ {
+ mpWhichId++;
+
+ // are we finished with the current pool?
+ if( 0 != *mpWhichId )
+ {
+ mnItem = 0;
+ mnItemCount = (mpWhichId && (0 != *mpWhichId) && mpPool) ? mpPool->GetItemCount( *mpWhichId ) : 0;
+ return next( rPrefix, rURL );
+ }
+
+ pItem = NULL;
+ }
+
+ if( pItem )
+ {
+ mnItem++;
+
+ // get that item and see if there namespaces inside
+ const SvXMLAttrContainerItem *pUnknown = (const SvXMLAttrContainerItem *)pItem;
+ if( (pUnknown->GetAttrCount() > 0) )
+ {
+ mpCurrentAttr = pUnknown;
+ mnCurrentAttr = pUnknown->GetFirstNamespaceIndex();
+ }
+ return next( rPrefix, rURL );
+ }
+
+ return false;
+}
+
+// -------------
+
+NamespaceMap::NamespaceMap( sal_uInt16* pWhichIds, SfxItemPool* pPool )
+: mpWhichIds( pWhichIds ), mpPool( pPool )
+{
+}
+
+NamespaceMap::~NamespaceMap()
+{
+}
+
+// XNameAccess
+Any SAL_CALL NamespaceMap::getByName( const ::rtl::OUString& aName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ NamespaceIteratorImpl aIter( mpWhichIds, mpPool );
+
+ ::rtl::OUString aPrefix;
+ ::rtl::OUString aURL;
+
+ sal_Bool bFound;
+
+ do
+ {
+ bFound = aIter.next( aPrefix, aURL );
+ }
+ while( bFound && (aPrefix != aName ) );
+
+ if( !bFound )
+ throw NoSuchElementException();
+
+ return makeAny( aURL );
+}
+
+Sequence< ::rtl::OUString > SAL_CALL NamespaceMap::getElementNames() throw (RuntimeException)
+{
+ NamespaceIteratorImpl aIter( mpWhichIds, mpPool );
+
+ ::rtl::OUString aPrefix;
+ ::rtl::OUString aURL;
+
+ std::set< ::rtl::OUString, comphelper::UStringLess > aPrefixSet;
+
+ while( aIter.next( aPrefix, aURL ) )
+ aPrefixSet.insert( aPrefix );
+
+ Sequence< ::rtl::OUString > aSeq( aPrefixSet.size() );
+ ::rtl::OUString* pPrefixes = aSeq.getArray();
+
+ std::set< ::rtl::OUString, comphelper::UStringLess >::iterator aPrefixIter( aPrefixSet.begin() );
+ const std::set< ::rtl::OUString, comphelper::UStringLess >::iterator aEnd( aPrefixSet.end() );
+
+ while( aPrefixIter != aEnd )
+ {
+ *pPrefixes++ = *aPrefixIter++;
+ }
+
+ return aSeq;
+}
+
+sal_Bool SAL_CALL NamespaceMap::hasByName( const ::rtl::OUString& aName ) throw (RuntimeException)
+{
+ NamespaceIteratorImpl aIter( mpWhichIds, mpPool );
+
+ ::rtl::OUString aPrefix;
+ ::rtl::OUString aURL;
+
+ sal_Bool bFound;
+
+ do
+ {
+ bFound = aIter.next( aPrefix, aURL );
+ }
+ while( bFound && (aPrefix != aName ) );
+
+ return bFound;
+}
+
+// XElementAccess
+Type SAL_CALL NamespaceMap::getElementType() throw (RuntimeException)
+{
+ return ::getCppuType( (const ::rtl::OUString*) 0 );
+}
+
+sal_Bool SAL_CALL NamespaceMap::hasElements() throw (RuntimeException)
+{
+ NamespaceIteratorImpl aIter( mpWhichIds, mpPool );
+
+ ::rtl::OUString aPrefix;
+ ::rtl::OUString aURL;
+
+ return aIter.next( aPrefix, aURL );
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL NamespaceMap::getImplementationName( )
+ throw(RuntimeException)
+{
+ return NamespaceMap_getImplementationName();
+}
+
+sal_Bool SAL_CALL NamespaceMap::supportsService( const ::rtl::OUString& )
+ throw(RuntimeException)
+{
+ return sal_True;
+}
+
+Sequence< ::rtl::OUString > SAL_CALL NamespaceMap::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ return NamespaceMap_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx
new file mode 100644
index 000000000000..e2f63cce8bf8
--- /dev/null
+++ b/svx/source/unodraw/XPropertyTable.cxx
@@ -0,0 +1,745 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "XPropertyTable.hxx"
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/drawing/Hatch.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#include <cppuhelper/implbase2.hxx>
+#include "unopolyhelper.hxx"
+#include <svx/xdef.hxx>
+
+#include "unoapi.hxx"
+#include <editeng/unoprnms.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+using namespace com::sun::star;
+using namespace ::cppu;
+using namespace ::rtl;
+
+class SvxUnoXPropertyTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >
+{
+private:
+ XPropertyTable* mpTable;
+ XPropertyList* mpList;
+ sal_Int16 mnWhich;
+
+ long getCount() const { return mpList ? mpList->Count() : (mpTable?mpTable->Count():0); }
+ XPropertyEntry* get( long index ) const;
+public:
+ SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw();
+ SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyTable* pTable ) throw();
+
+ virtual ~SvxUnoXPropertyTable() throw();
+
+ virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw() = 0;
+ virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw() = 0;
+
+ // XServiceInfo
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException);
+
+ // XNameContainer
+ virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XNameAccess
+ virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException);
+
+ // XElementAccess
+ virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException);
+};
+
+SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyTable* pTable ) throw()
+: mpTable( pTable ), mpList( NULL ), mnWhich( nWhich )
+{
+}
+
+SvxUnoXPropertyTable::SvxUnoXPropertyTable( sal_Int16 nWhich, XPropertyList* pList ) throw()
+: mpTable( NULL ), mpList( pList ), mnWhich( nWhich )
+{
+}
+
+SvxUnoXPropertyTable::~SvxUnoXPropertyTable() throw()
+{
+}
+
+XPropertyEntry* SvxUnoXPropertyTable::get( long index ) const
+{
+ if( mpTable )
+ return mpTable->Get( index, 0 );
+ else if( mpList )
+ return mpList->Get( index, 0 );
+ else
+ return NULL;
+}
+
+// XServiceInfo
+sal_Bool SAL_CALL SvxUnoXPropertyTable::supportsService( const OUString& ServiceName )
+ throw( uno::RuntimeException)
+{
+ const uno::Sequence< OUString > aServices( getSupportedServiceNames() );
+ const OUString* pServices = aServices.getConstArray();
+ const sal_Int32 nCount = aServices.getLength();
+ sal_Int32 i;
+ for( i = 0; i < nCount; i++ )
+ {
+ if( *pServices++ == ServiceName )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+// XNameContainer
+void SAL_CALL SvxUnoXPropertyTable::insertByName( const OUString& aName, const uno::Any& aElement )
+ throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( NULL == mpList && NULL == mpTable )
+ throw lang::IllegalArgumentException();
+
+ if( hasByName( aName ) )
+ throw container::ElementExistException();
+
+ String aInternalName;
+ SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
+
+ XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement );
+ if( NULL == pNewEntry )
+ throw lang::IllegalArgumentException();
+
+ if( mpList )
+ mpList->Insert( pNewEntry );
+ else
+ mpTable->Insert( mpTable->Count(), pNewEntry );
+}
+
+void SAL_CALL SvxUnoXPropertyTable::removeByName( const OUString& Name )
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aInternalName;
+ SvxUnogetInternalNameForItem( mnWhich, Name, aInternalName );
+
+ const long nCount = getCount();
+ long i;
+ XPropertyEntry* pEntry;
+ for( i = 0; i < nCount; i++ )
+ {
+ pEntry = get( i );
+ if( pEntry && pEntry->GetName() == aInternalName )
+ {
+ if( mpList )
+ delete mpList->Remove( i, 0 );
+ else
+ delete mpTable->Remove( i, 0 );
+ return;
+ }
+ }
+
+ throw container::NoSuchElementException();
+}
+
+// XNameReplace
+void SAL_CALL SvxUnoXPropertyTable::replaceByName( const OUString& aName, const uno::Any& aElement )
+ throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aInternalName;
+ SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
+
+ const long nCount = getCount();
+ long i;
+ XPropertyEntry* pEntry;
+ for( i = 0; i < nCount; i++ )
+ {
+ pEntry = get( i );
+ if( pEntry && pEntry->GetName() == aInternalName )
+ {
+ XPropertyEntry* pNewEntry = getEntry( aInternalName, aElement );
+ if( NULL == pNewEntry )
+ throw lang::IllegalArgumentException();
+
+ if( mpList )
+ delete mpList->Replace( pNewEntry, i );
+ else
+ delete mpTable->Replace( i, pNewEntry );
+ return;
+ }
+ }
+
+ throw container::NoSuchElementException();
+}
+
+// XNameAccess
+uno::Any SAL_CALL SvxUnoXPropertyTable::getByName( const OUString& aName )
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aInternalName;
+ SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
+
+ const long nCount = getCount();
+ long i;
+ XPropertyEntry* pEntry;
+ for( i = 0; i < nCount; i++ )
+ {
+ pEntry = get( i );
+
+ if( pEntry && pEntry->GetName() == aInternalName )
+ return getAny( pEntry );
+ }
+
+ throw container::NoSuchElementException();
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoXPropertyTable::getElementNames()
+ throw( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const long nCount = getCount();
+ uno::Sequence< OUString > aNames( nCount );
+ OUString* pNames = aNames.getArray();
+ long i;
+ XPropertyEntry* pEntry;
+ for( i = 0; i < nCount; i++ )
+ {
+ pEntry = get( i );
+
+ if( pEntry )
+ {
+ SvxUnogetApiNameForItem( mnWhich, pEntry->GetName(), *pNames );
+ pNames++;
+ }
+ }
+
+ return aNames;
+}
+
+sal_Bool SAL_CALL SvxUnoXPropertyTable::hasByName( const OUString& aName )
+ throw( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aInternalName;
+ SvxUnogetInternalNameForItem( mnWhich, aName, aInternalName );
+
+ const long nCount = mpList?mpList->Count():0;
+ long i;
+ XPropertyEntry* pEntry;
+ for( i = 0; i < nCount; i++ )
+ {
+ pEntry = get( i );
+ if( pEntry && pEntry->GetName() == aInternalName )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+// XElementAccess
+sal_Bool SAL_CALL SvxUnoXPropertyTable::hasElements( )
+ throw( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return getCount() != 0;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+class SvxUnoXColorTable : public SvxUnoXPropertyTable
+{
+public:
+ SvxUnoXColorTable( XPropertyTable* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINECOLOR, pTable ) {};
+
+ // SvxUnoXPropertyTable
+ virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
+ virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+};
+
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoXColorTable_createInstance( XPropertyTable* pTable ) throw()
+{
+ return (OWeakObject*) new SvxUnoXColorTable( pTable );
+}
+
+// SvxUnoXPropertyTable
+uno::Any SvxUnoXColorTable::getAny( const XPropertyEntry* pEntry ) const throw()
+{
+ uno::Any aAny;
+ aAny <<= (sal_Int32)((XColorEntry*)pEntry)->GetColor().GetColor();
+ return aAny;
+}
+
+XPropertyEntry* SvxUnoXColorTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
+{
+ sal_Int32 nColor = 0;
+ if( !(rAny >>= nColor) )
+ return NULL;
+
+ const Color aColor( (ColorData)nColor );
+ const String aName( rName );
+ return new XColorEntry( aColor, aName );
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoXColorTable::getElementType()
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const sal_Int32*)0);
+}
+
+// XServiceInfo
+OUString SAL_CALL SvxUnoXColorTable::getImplementationName( ) throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXColorTable" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoXColorTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.ColorTable" ) );
+ uno::Sequence< OUString > aServices( &aServiceName, 1 );
+ return aServices;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+class SvxUnoXLineEndTable : public SvxUnoXPropertyTable
+{
+public:
+ SvxUnoXLineEndTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEEND, pTable ) {};
+
+ // SvxUnoXPropertyTable
+ virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
+ virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+};
+
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoXLineEndTable_createInstance( XPropertyList* pTable ) throw()
+{
+ return (OWeakObject*)new SvxUnoXLineEndTable( pTable );
+}
+
+// SvxUnoXPropertyTable
+uno::Any SvxUnoXLineEndTable::getAny( const XPropertyEntry* pEntry ) const throw()
+{
+
+ uno::Any aAny;
+ drawing::PolyPolygonBezierCoords aBezier;
+ SvxConvertB2DPolyPolygonToPolyPolygonBezier( ((XLineEndEntry*)pEntry)->GetLineEnd(), aBezier );
+ aAny <<= aBezier;
+ return aAny;
+}
+
+XPropertyEntry* SvxUnoXLineEndTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
+{
+
+ if( !rAny.getValue() || rAny.getValueType() != ::getCppuType((const drawing::PolyPolygonBezierCoords*)0) )
+ return NULL;
+
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ drawing::PolyPolygonBezierCoords* pCoords = (drawing::PolyPolygonBezierCoords*)rAny.getValue();
+ if( pCoords->Coordinates.getLength() > 0 )
+ aPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon( pCoords );
+
+ // #86265# make sure polygon is closed
+ aPolyPolygon.setClosed(true);
+
+ const String aName( rName );
+ return new XLineEndEntry( aPolyPolygon, aName );
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoXLineEndTable::getElementType()
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const drawing::PolyPolygonBezierCoords*)0);
+}
+
+// XServiceInfo
+OUString SAL_CALL SvxUnoXLineEndTable::getImplementationName( ) throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXLineEndTable" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoXLineEndTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.LineEndTable" ) );
+ uno::Sequence< OUString > aServices( &aServiceName, 1 );
+ return aServices;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+class SvxUnoXDashTable : public SvxUnoXPropertyTable
+{
+public:
+ SvxUnoXDashTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_LINEDASH, pTable ) {};
+
+ // SvxUnoXPropertyTable
+ virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
+ virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+};
+
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoXDashTable_createInstance( XPropertyList* pTable ) throw()
+{
+ return (OWeakObject*)new SvxUnoXDashTable( pTable );
+}
+
+// SvxUnoXPropertyTable
+uno::Any SvxUnoXDashTable::getAny( const XPropertyEntry* pEntry ) const throw()
+{
+ const XDash& rXD = ((XDashEntry*)pEntry)->GetDash();
+
+ drawing::LineDash aLineDash;
+
+ aLineDash.Style = (::com::sun::star::drawing::DashStyle)((UINT16)rXD.GetDashStyle());
+ aLineDash.Dots = rXD.GetDots();
+ aLineDash.DotLen = rXD.GetDotLen();
+ aLineDash.Dashes = rXD.GetDashes();
+ aLineDash.DashLen = rXD.GetDashLen();
+ aLineDash.Distance = rXD.GetDistance();
+
+ uno::Any aAny;
+ aAny <<= aLineDash;
+ return aAny;
+}
+
+XPropertyEntry* SvxUnoXDashTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
+{
+ drawing::LineDash aLineDash;
+ if(!(rAny >>= aLineDash))
+ return NULL;
+
+ XDash aXDash;
+
+ aXDash.SetDashStyle((XDashStyle)((UINT16)(aLineDash.Style)));
+ aXDash.SetDots(aLineDash.Dots);
+ aXDash.SetDotLen(aLineDash.DotLen);
+ aXDash.SetDashes(aLineDash.Dashes);
+ aXDash.SetDashLen(aLineDash.DashLen);
+ aXDash.SetDistance(aLineDash.Distance);
+
+ const String aName( rName );
+ return new XDashEntry( aXDash, aName );
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoXDashTable::getElementType()
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const drawing::LineDash*)0);
+}
+
+// XServiceInfo
+OUString SAL_CALL SvxUnoXDashTable::getImplementationName( ) throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXDashTable" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoXDashTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.DashTable" ) );
+ uno::Sequence< OUString > aServices( &aServiceName, 1 );
+ return aServices;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+class SvxUnoXHatchTable : public SvxUnoXPropertyTable
+{
+public:
+ SvxUnoXHatchTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLHATCH, pTable ) {};
+
+ // SvxUnoXPropertyTable
+ virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
+ virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+};
+
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoXHatchTable_createInstance( XPropertyList* pTable ) throw()
+{
+ return (OWeakObject*)new SvxUnoXHatchTable( pTable );
+}
+
+// SvxUnoXPropertyTable
+uno::Any SvxUnoXHatchTable::getAny( const XPropertyEntry* pEntry ) const throw()
+{
+ const XHatch& aHatch = ((XHatchEntry*)pEntry)->GetHatch();
+
+ drawing::Hatch aUnoHatch;
+
+ aUnoHatch.Style = (drawing::HatchStyle)aHatch.GetHatchStyle();
+ aUnoHatch.Color = aHatch.GetColor().GetColor();
+ aUnoHatch.Distance = aHatch.GetDistance();
+ aUnoHatch.Angle = aHatch.GetAngle();
+
+ uno::Any aAny;
+ aAny <<= aUnoHatch;
+ return aAny;
+}
+
+XPropertyEntry* SvxUnoXHatchTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
+{
+ drawing::Hatch aUnoHatch;
+ if(!(rAny >>= aUnoHatch))
+ return NULL;
+
+ XHatch aXHatch;
+ aXHatch.SetHatchStyle( (XHatchStyle)aUnoHatch.Style );
+ aXHatch.SetColor( aUnoHatch.Color );
+ aXHatch.SetDistance( aUnoHatch.Distance );
+ aXHatch.SetAngle( aUnoHatch.Angle );
+
+ const String aName( rName );
+ return new XHatchEntry( aXHatch, aName );
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoXHatchTable::getElementType()
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const drawing::Hatch*)0);
+}
+
+// XServiceInfo
+OUString SAL_CALL SvxUnoXHatchTable::getImplementationName( ) throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXHatchTable" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoXHatchTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.HatchTable" ) );
+ uno::Sequence< OUString > aServices( &aServiceName, 1 );
+ return aServices;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+class SvxUnoXGradientTable : public SvxUnoXPropertyTable
+{
+public:
+ SvxUnoXGradientTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLGRADIENT, pTable ) {};
+
+ // SvxUnoXPropertyTable
+ virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
+ virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+};
+
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoXGradientTable_createInstance( XPropertyList* pTable ) throw()
+{
+ return (OWeakObject*)new SvxUnoXGradientTable( pTable );
+}
+
+// SvxUnoXPropertyTable
+uno::Any SvxUnoXGradientTable::getAny( const XPropertyEntry* pEntry ) const throw()
+{
+ const XGradient& aXGradient = ((XGradientEntry*)pEntry)->GetGradient();
+ awt::Gradient aGradient;
+
+ aGradient.Style = (awt::GradientStyle) aXGradient.GetGradientStyle();
+ aGradient.StartColor = (INT32)aXGradient.GetStartColor().GetColor();
+ aGradient.EndColor = (INT32)aXGradient.GetEndColor().GetColor();
+ aGradient.Angle = (short)aXGradient.GetAngle();
+ aGradient.Border = aXGradient.GetBorder();
+ aGradient.XOffset = aXGradient.GetXOffset();
+ aGradient.YOffset = aXGradient.GetYOffset();
+ aGradient.StartIntensity = aXGradient.GetStartIntens();
+ aGradient.EndIntensity = aXGradient.GetEndIntens();
+ aGradient.StepCount = aXGradient.GetSteps();
+
+ uno::Any aAny;
+ aAny <<= aGradient;
+ return aAny;
+}
+
+XPropertyEntry* SvxUnoXGradientTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
+{
+ awt::Gradient aGradient;
+ if(!(rAny >>= aGradient))
+ return NULL;
+
+ XGradient aXGradient;
+
+ aXGradient.SetGradientStyle( (XGradientStyle) aGradient.Style );
+ aXGradient.SetStartColor( aGradient.StartColor );
+ aXGradient.SetEndColor( aGradient.EndColor );
+ aXGradient.SetAngle( aGradient.Angle );
+ aXGradient.SetBorder( aGradient.Border );
+ aXGradient.SetXOffset( aGradient.XOffset );
+ aXGradient.SetYOffset( aGradient.YOffset );
+ aXGradient.SetStartIntens( aGradient.StartIntensity );
+ aXGradient.SetEndIntens( aGradient.EndIntensity );
+ aXGradient.SetSteps( aGradient.StepCount );
+
+ const String aName( rName );
+ return new XGradientEntry( aXGradient, aName );
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoXGradientTable::getElementType()
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const awt::Gradient*)0);
+}
+
+// XServiceInfo
+OUString SAL_CALL SvxUnoXGradientTable::getImplementationName( ) throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXGradientTable" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoXGradientTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GradientTable" ) );
+ uno::Sequence< OUString > aServices( &aServiceName, 1 );
+ return aServices;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+class SvxUnoXBitmapTable : public SvxUnoXPropertyTable
+{
+public:
+ SvxUnoXBitmapTable( XPropertyList* pTable ) throw() : SvxUnoXPropertyTable( XATTR_FILLBITMAP, pTable ) {};
+
+ // SvxUnoXPropertyTable
+ virtual uno::Any getAny( const XPropertyEntry* pEntry ) const throw();
+ virtual XPropertyEntry* getEntry( const OUString& rName, const uno::Any& rAny ) const throw();
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw( uno::RuntimeException );
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+};
+
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoXBitmapTable_createInstance( XPropertyList* pTable ) throw()
+{
+ return (OWeakObject*)new SvxUnoXBitmapTable( pTable );
+}
+
+// SvxUnoXPropertyTable
+uno::Any SvxUnoXBitmapTable::getAny( const XPropertyEntry* pEntry ) const throw()
+{
+ OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
+ aURL += OUString::createFromAscii( ((XBitmapEntry*)pEntry)->GetXBitmap().GetGraphicObject().GetUniqueID().GetBuffer() );
+
+ uno::Any aAny;
+ aAny <<= aURL;
+ return aAny;
+}
+
+XPropertyEntry* SvxUnoXBitmapTable::getEntry( const OUString& rName, const uno::Any& rAny ) const throw()
+{
+ OUString aURL;
+ if(!(rAny >>= aURL))
+ return NULL;
+
+ GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) );
+ XOBitmap aBMP( aGrafObj );
+
+ const String aName( rName );
+ return new XBitmapEntry( aBMP, aName );
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoXBitmapTable::getElementType()
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const OUString*)0);
+}
+
+// XServiceInfo
+OUString SAL_CALL SvxUnoXBitmapTable::getImplementationName( ) throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoXBitmapTable" ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoXBitmapTable::getSupportedServiceNames( ) throw( uno::RuntimeException)
+{
+ const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.BitmapTable" ) );
+ uno::Sequence< OUString > aServices( &aServiceName, 1 );
+ return aServices;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/gluepts.cxx b/svx/source/unodraw/gluepts.cxx
new file mode 100644
index 000000000000..79675e851175
--- /dev/null
+++ b/svx/source/unodraw/gluepts.cxx
@@ -0,0 +1,549 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/container/XIdentifierContainer.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/drawing/GluePoint2.hpp>
+
+#include <cppuhelper/implbase2.hxx>
+
+#include <svx/svdmodel.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdglue.hxx>
+#include <svx/svdpage.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+using namespace ::cppu;
+
+const USHORT NON_USER_DEFINED_GLUE_POINTS = 4;
+
+class SvxUnoGluePointAccess : public WeakImplHelper2< container::XIndexContainer, container::XIdentifierContainer >
+{
+private:
+ SdrObjectWeakRef mpObject;
+
+public:
+ SvxUnoGluePointAccess( SdrObject* pObject ) throw();
+ virtual ~SvxUnoGluePointAccess() throw();
+
+ // XIdentifierContainer
+ virtual sal_Int32 SAL_CALL insert( const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual void SAL_CALL removeByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XIdentifierReplace
+ virtual void SAL_CALL replaceByIdentifer( sal_Int32 Identifier, const uno::Any& aElement ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XIdentifierReplace
+ virtual uno::Any SAL_CALL getByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual uno::Sequence< sal_Int32 > SAL_CALL getIdentifiers( ) throw (uno::RuntimeException);
+
+ /* deprecated */
+ // XIndexContainer
+ virtual void SAL_CALL insertByIndex( sal_Int32 Index, const uno::Any& Element ) throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual void SAL_CALL removeByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
+
+ /* deprecated */
+ // XIndexReplace
+ virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const uno::Any& Element ) throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
+
+ /* deprecated */
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw(uno::RuntimeException);
+ virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException);
+};
+
+static void convert( const SdrGluePoint& rSdrGlue, drawing::GluePoint2& rUnoGlue ) throw()
+{
+ rUnoGlue.Position.X = rSdrGlue.GetPos().X();
+ rUnoGlue.Position.Y = rSdrGlue.GetPos().Y();
+ rUnoGlue.IsRelative = rSdrGlue.IsPercent();
+
+ switch( rSdrGlue.GetAlign() )
+ {
+ case SDRVERTALIGN_TOP|SDRHORZALIGN_LEFT:
+ rUnoGlue.PositionAlignment = drawing::Alignment_TOP_LEFT;
+ break;
+ case SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP:
+ rUnoGlue.PositionAlignment = drawing::Alignment_TOP;
+ break;
+ case SDRVERTALIGN_TOP|SDRHORZALIGN_RIGHT:
+ rUnoGlue.PositionAlignment = drawing::Alignment_TOP_RIGHT;
+ break;
+ case SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER:
+ rUnoGlue.PositionAlignment = drawing::Alignment_CENTER;
+ break;
+ case SDRHORZALIGN_RIGHT|SDRVERTALIGN_CENTER:
+ rUnoGlue.PositionAlignment = drawing::Alignment_RIGHT;
+ break;
+ case SDRHORZALIGN_LEFT|SDRVERTALIGN_BOTTOM:
+ rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM_LEFT;
+ break;
+ case SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM:
+ rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM;
+ break;
+ case SDRHORZALIGN_RIGHT|SDRVERTALIGN_BOTTOM:
+ rUnoGlue.PositionAlignment = drawing::Alignment_BOTTOM_RIGHT;
+ break;
+// case SDRHORZALIGN_LEFT:
+ default:
+ rUnoGlue.PositionAlignment = drawing::Alignment_LEFT;
+ break;
+ }
+
+ switch( rSdrGlue.GetEscDir() )
+ {
+ case SDRESC_LEFT:
+ rUnoGlue.Escape = drawing::EscapeDirection_LEFT;
+ break;
+ case SDRESC_RIGHT:
+ rUnoGlue.Escape = drawing::EscapeDirection_RIGHT;
+ break;
+ case SDRESC_TOP:
+ rUnoGlue.Escape = drawing::EscapeDirection_UP;
+ break;
+ case SDRESC_BOTTOM:
+ rUnoGlue.Escape = drawing::EscapeDirection_DOWN;
+ break;
+ case SDRESC_HORZ:
+ rUnoGlue.Escape = drawing::EscapeDirection_HORIZONTAL;
+ break;
+ case SDRESC_VERT:
+ rUnoGlue.Escape = drawing::EscapeDirection_VERTICAL;
+ break;
+// case SDRESC_SMART:
+ default:
+ rUnoGlue.Escape = drawing::EscapeDirection_SMART;
+ break;
+ }
+}
+
+static void convert( const drawing::GluePoint2& rUnoGlue, SdrGluePoint& rSdrGlue ) throw()
+{
+ rSdrGlue.SetPos( Point( rUnoGlue.Position.X, rUnoGlue.Position.Y ) );
+ rSdrGlue.SetPercent( rUnoGlue.IsRelative );
+
+ switch( rUnoGlue.PositionAlignment )
+ {
+ case drawing::Alignment_TOP_LEFT:
+ rSdrGlue.SetAlign( SDRVERTALIGN_TOP|SDRHORZALIGN_LEFT );
+ break;
+ case drawing::Alignment_TOP:
+ rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_TOP );
+ break;
+ case drawing::Alignment_TOP_RIGHT:
+ rSdrGlue.SetAlign( SDRVERTALIGN_TOP|SDRHORZALIGN_RIGHT );
+ break;
+ case drawing::Alignment_CENTER:
+ rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_CENTER );
+ break;
+ case drawing::Alignment_RIGHT:
+ rSdrGlue.SetAlign( SDRHORZALIGN_RIGHT|SDRVERTALIGN_CENTER );
+ break;
+ case drawing::Alignment_BOTTOM_LEFT:
+ rSdrGlue.SetAlign( SDRHORZALIGN_LEFT|SDRVERTALIGN_BOTTOM );
+ break;
+ case drawing::Alignment_BOTTOM:
+ rSdrGlue.SetAlign( SDRHORZALIGN_CENTER|SDRVERTALIGN_BOTTOM );
+ break;
+ case drawing::Alignment_BOTTOM_RIGHT:
+ rSdrGlue.SetAlign( SDRHORZALIGN_RIGHT|SDRVERTALIGN_BOTTOM );
+ break;
+// case SDRHORZALIGN_LEFT:
+ default:
+ rSdrGlue.SetAlign( SDRHORZALIGN_LEFT );
+ break;
+ }
+ switch( rUnoGlue.Escape )
+ {
+ case drawing::EscapeDirection_LEFT:
+ rSdrGlue.SetEscDir(SDRESC_LEFT);
+ break;
+ case drawing::EscapeDirection_RIGHT:
+ rSdrGlue.SetEscDir(SDRESC_RIGHT);
+ break;
+ case drawing::EscapeDirection_UP:
+ rSdrGlue.SetEscDir(SDRESC_TOP);
+ break;
+ case drawing::EscapeDirection_DOWN:
+ rSdrGlue.SetEscDir(SDRESC_BOTTOM);
+ break;
+ case drawing::EscapeDirection_HORIZONTAL:
+ rSdrGlue.SetEscDir(SDRESC_HORZ);
+ break;
+ case drawing::EscapeDirection_VERTICAL:
+ rSdrGlue.SetEscDir(SDRESC_VERT);
+ break;
+// case drawing::EscapeDirection_SMART:
+ default:
+ rSdrGlue.SetEscDir(SDRESC_SMART);
+ break;
+ }
+}
+
+SvxUnoGluePointAccess::SvxUnoGluePointAccess( SdrObject* pObject ) throw()
+: mpObject( pObject )
+{
+}
+
+SvxUnoGluePointAccess::~SvxUnoGluePointAccess() throw()
+{
+}
+
+// XIdentifierContainer
+sal_Int32 SAL_CALL SvxUnoGluePointAccess::insert( const uno::Any& aElement ) throw (lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( mpObject.is() )
+ {
+ SdrGluePointList* pList = mpObject->ForceGluePointList();
+ if( pList )
+ {
+ // second, insert the new glue point
+ drawing::GluePoint2 aUnoGlue;
+
+ if( aElement >>= aUnoGlue )
+ {
+ SdrGluePoint aSdrGlue;
+ convert( aUnoGlue, aSdrGlue );
+ USHORT nId = pList->Insert( aSdrGlue );
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+ // mpObject->BroadcastObjectChange();
+
+ return (sal_Int32)((*pList)[nId].GetId() + NON_USER_DEFINED_GLUE_POINTS) - 1;
+ }
+
+ throw lang::IllegalArgumentException();
+ }
+ }
+
+ return -1;
+}
+
+void SAL_CALL SvxUnoGluePointAccess::removeByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( mpObject.is() && ( Identifier >= NON_USER_DEFINED_GLUE_POINTS ))
+ {
+ const USHORT nId = (USHORT)(Identifier - NON_USER_DEFINED_GLUE_POINTS) + 1;
+
+ SdrGluePointList* pList = const_cast<SdrGluePointList*>(mpObject->GetGluePointList());
+ const USHORT nCount = pList ? pList->GetCount() : 0;
+ USHORT i;
+
+ for( i = 0; i < nCount; i++ )
+ {
+ if( (*pList)[i].GetId() == nId )
+ {
+ pList->Delete( i );
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+ // mpObject->BroadcastObjectChange();
+
+ return;
+ }
+ }
+ }
+
+ throw container::NoSuchElementException();
+}
+
+// XIdentifierReplace
+void SAL_CALL SvxUnoGluePointAccess::replaceByIdentifer( sal_Int32 Identifier, const uno::Any& aElement ) throw (lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( mpObject.is() && mpObject->IsNode() )
+ {
+ struct drawing::GluePoint2 aGluePoint;
+ if( (Identifier < NON_USER_DEFINED_GLUE_POINTS) || !(aElement >>= aGluePoint))
+ throw lang::IllegalArgumentException();
+
+ const USHORT nId = (USHORT)( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1;
+
+ SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() );
+ const USHORT nCount = pList ? pList->GetCount() : 0;
+ USHORT i;
+ for( i = 0; i < nCount; i++ )
+ {
+ if( (*pList)[i].GetId() == nId )
+ {
+ // change the glue point
+ SdrGluePoint& rTempPoint = (*pList)[i];
+ convert( aGluePoint, rTempPoint );
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+ // mpObject->BroadcastObjectChange();
+
+ return;
+ }
+ }
+
+ throw container::NoSuchElementException();
+ }
+}
+
+// XIdentifierAccess
+uno::Any SAL_CALL SvxUnoGluePointAccess::getByIdentifier( sal_Int32 Identifier ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( mpObject.is() && mpObject->IsNode() )
+ {
+ struct drawing::GluePoint2 aGluePoint;
+
+ if( Identifier < NON_USER_DEFINED_GLUE_POINTS ) // default glue point?
+ {
+ SdrGluePoint aTempPoint = mpObject->GetVertexGluePoint( (USHORT)Identifier );
+ aGluePoint.IsUserDefined = sal_False;
+ convert( aTempPoint, aGluePoint );
+ return uno::makeAny( aGluePoint );
+ }
+ else
+ {
+ const USHORT nId = (USHORT)( Identifier - NON_USER_DEFINED_GLUE_POINTS ) + 1;
+
+ const SdrGluePointList* pList = mpObject->GetGluePointList();
+ const USHORT nCount = pList ? pList->GetCount() : 0;
+ for( USHORT i = 0; i < nCount; i++ )
+ {
+ const SdrGluePoint& rTempPoint = (*pList)[i];
+ if( rTempPoint.GetId() == nId )
+ {
+ // #i38892#
+ if(rTempPoint.IsUserDefined())
+ {
+ aGluePoint.IsUserDefined = sal_True;
+ }
+
+ convert( rTempPoint, aGluePoint );
+ return uno::makeAny( aGluePoint );
+ }
+ }
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException();
+}
+
+uno::Sequence< sal_Int32 > SAL_CALL SvxUnoGluePointAccess::getIdentifiers() throw (uno::RuntimeException)
+{
+ if( mpObject.is() )
+ {
+ const SdrGluePointList* pList = mpObject->GetGluePointList();
+ const USHORT nCount = pList ? pList->GetCount() : 0;
+
+ USHORT i;
+
+ uno::Sequence< sal_Int32 > aIdSequence( nCount + NON_USER_DEFINED_GLUE_POINTS );
+ sal_Int32 *pIdentifier = aIdSequence.getArray();
+
+ for( i = 0; i < NON_USER_DEFINED_GLUE_POINTS; i++ )
+ *pIdentifier++ = (sal_Int32)i;
+
+ for( i = 0; i < nCount; i++ )
+ *pIdentifier++ = (sal_Int32) ( (*pList)[i].GetId() + NON_USER_DEFINED_GLUE_POINTS ) - 1;
+
+ return aIdSequence;
+ }
+ else
+ {
+ uno::Sequence< sal_Int32 > aEmpty;
+ return aEmpty;
+ }
+}
+
+/* deprecated */
+
+// XIndexContainer
+void SAL_CALL SvxUnoGluePointAccess::insertByIndex( sal_Int32, const uno::Any& Element )
+ throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( mpObject.is() )
+ {
+ SdrGluePointList* pList = mpObject->ForceGluePointList();
+ if( pList )
+ {
+ SdrGluePoint aSdrGlue;
+ drawing::GluePoint2 aUnoGlue;
+
+ if( Element >>= aUnoGlue )
+ {
+ convert( aUnoGlue, aSdrGlue );
+ pList->Insert( aSdrGlue );
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+ // mpObject->BroadcastObjectChange();
+
+ return;
+ }
+
+ throw lang::IllegalArgumentException();
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException();
+}
+
+void SAL_CALL SvxUnoGluePointAccess::removeByIndex( sal_Int32 Index )
+ throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( mpObject.is() )
+ {
+ SdrGluePointList* pList = mpObject->ForceGluePointList();
+ if( pList )
+ {
+ Index -= 4;
+ if( Index >= 0 && Index < pList->GetCount() )
+ {
+ pList->Delete( (USHORT)Index );
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+ // mpObject->BroadcastObjectChange();
+
+ return;
+ }
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException();
+}
+
+// XIndexReplace
+void SAL_CALL SvxUnoGluePointAccess::replaceByIndex( sal_Int32 Index, const uno::Any& Element )
+ throw(lang::IllegalArgumentException, lang::IndexOutOfBoundsException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ drawing::GluePoint2 aUnoGlue;
+ if(!(Element >>= aUnoGlue))
+ throw lang::IllegalArgumentException();
+
+ Index -= 4;
+ if( mpObject.is() && Index >= 0 )
+ {
+ SdrGluePointList* pList = const_cast< SdrGluePointList* >( mpObject->GetGluePointList() );
+ if( pList && Index < pList->GetCount() )
+ {
+ SdrGluePoint& rGlue = (*pList)[(USHORT)Index];
+ convert( aUnoGlue, rGlue );
+
+ // only repaint, no objectchange
+ mpObject->ActionChanged();
+ // mpObject->BroadcastObjectChange();
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException();
+}
+
+// XIndexAccess
+sal_Int32 SAL_CALL SvxUnoGluePointAccess::getCount()
+ throw(uno::RuntimeException)
+{
+ sal_Int32 nCount = 0;
+ if( mpObject.is() )
+ {
+ // each node has a default of 4 glue points
+ // and any number of user defined glue points
+ if( mpObject->IsNode() )
+ {
+ nCount += 4;
+
+ const SdrGluePointList* pList = mpObject->GetGluePointList();
+ if( pList )
+ nCount += pList->GetCount();
+ }
+ }
+
+ return nCount;
+}
+
+uno::Any SAL_CALL SvxUnoGluePointAccess::getByIndex( sal_Int32 Index )
+ throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( Index >= 0 && mpObject.is() && mpObject->IsNode() )
+ {
+ struct drawing::GluePoint2 aGluePoint;
+
+ if( Index < 4 ) // default glue point?
+ {
+ SdrGluePoint aTempPoint = mpObject->GetVertexGluePoint( (USHORT)Index );
+ aGluePoint.IsUserDefined = sal_False;
+ convert( aTempPoint, aGluePoint );
+ uno::Any aAny;
+ aAny <<= aGluePoint;
+ return aAny;
+ }
+ else
+ {
+ Index -= 4;
+ const SdrGluePointList* pList = mpObject->GetGluePointList();
+ if( pList && Index < pList->GetCount() )
+ {
+ const SdrGluePoint& rTempPoint = (*pList)[(USHORT)Index];
+ aGluePoint.IsUserDefined = sal_True;
+ convert( rTempPoint, aGluePoint );
+ uno::Any aAny;
+ aAny <<= aGluePoint;
+ return aAny;
+ }
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException();
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoGluePointAccess::getElementType()
+ throw( uno::RuntimeException)
+{
+ return ::getCppuType((const struct drawing::GluePoint2*)0);
+}
+
+sal_Bool SAL_CALL SvxUnoGluePointAccess::hasElements()
+ throw( uno::RuntimeException)
+{
+ return mpObject.is() && mpObject->IsNode();
+}
+
+/**
+ * Create a SvxUnoGluePointAccess
+ */
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoGluePointAccess_createInstance( SdrObject* pObject )
+{
+ return *new SvxUnoGluePointAccess(pObject);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/makefile.mk b/svx/source/unodraw/makefile.mk
new file mode 100644
index 000000000000..6815f28f4c79
--- /dev/null
+++ b/svx/source/unodraw/makefile.mk
@@ -0,0 +1,83 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+TARGET=unodraw
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+LIB1TARGET= $(SLB)$/$(TARGET)-core.lib
+LIB1OBJFILES= \
+ $(SLO)$/UnoGraphicExporter.obj \
+ $(SLO)$/XPropertyTable.obj \
+ $(SLO)$/UnoNameItemTable.obj \
+ $(SLO)$/unoshape.obj \
+ $(SLO)$/unoshap2.obj \
+ $(SLO)$/unoshap3.obj \
+ $(SLO)$/unoshap4.obj \
+ $(SLO)$/unopage.obj \
+ $(SLO)$/unoshtxt.obj \
+ $(SLO)$/unoprov.obj \
+ $(SLO)$/unomod.obj \
+ $(SLO)$/unomlstr.obj \
+ $(SLO)$/unogtabl.obj \
+ $(SLO)$/unohtabl.obj \
+ $(SLO)$/unobtabl.obj \
+ $(SLO)$/unottabl.obj \
+ $(SLO)$/unomtabl.obj \
+ $(SLO)$/unodtabl.obj \
+ $(SLO)$/gluepts.obj \
+ $(SLO)$/tableshape.obj \
+ $(SLO)$/shapepropertynotifier.obj
+
+LIB2TARGET= $(SLB)$/$(TARGET).lib
+LIB2OBJFILES= \
+ $(SLO)$/UnoNamespaceMap.obj \
+ $(SLO)$/unopool.obj \
+ $(SLO)$/unoctabl.obj \
+ $(SLO)$/unoshcol.obj \
+ $(SLO)$/recoveryui.obj
+
+SLOFILES = $(LIB1OBJFILES) $(LIB2OBJFILES)
+
+SRS1NAME=unodraw
+SRC1FILES = \
+ unodraw.src
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svx/source/unodraw/recoveryui.cxx b/svx/source/unodraw/recoveryui.cxx
new file mode 100644
index 000000000000..a08415ca2e48
--- /dev/null
+++ b/svx/source/unodraw/recoveryui.cxx
@@ -0,0 +1,402 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+//===============================================
+// includes
+#include "recoveryui.hxx"
+#include "docrecovery.hxx"
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <osl/file.hxx>
+#include <rtl/bootstrap.hxx>
+#include <comphelper/configurationhelper.hxx>
+
+#include <vcl/svapp.hxx>
+
+//===============================================
+// const
+
+#define IMPLEMENTATIONNAME_RECOVERYUI ::rtl::OUString::createFromAscii("com.sun.star.comp.svx.RecoveryUI")
+#define SERVICENAME_RECOVERYUI ::rtl::OUString::createFromAscii("com.sun.star.dialog.RecoveryUI")
+
+//===============================================
+// namespace
+
+namespace svx
+{
+
+namespace css = ::com::sun::star;
+namespace svxdr = ::svx::DocRecovery;
+
+using namespace ::rtl;
+using namespace ::osl;
+
+//===============================================
+RecoveryUI::RecoveryUI(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
+ : m_xSMGR (xSMGR )
+ , m_pParentWindow(0 )
+ , m_eJob (RecoveryUI::E_JOB_UNKNOWN)
+{
+}
+
+//===============================================
+RecoveryUI::~RecoveryUI()
+{
+}
+
+//===============================================
+::rtl::OUString SAL_CALL RecoveryUI::getImplementationName()
+ throw(css::uno::RuntimeException)
+{
+ return RecoveryUI::st_getImplementationName();
+}
+
+//===============================================
+sal_Bool SAL_CALL RecoveryUI::supportsService(const ::rtl::OUString& sServiceName)
+ throw(css::uno::RuntimeException)
+{
+ const css::uno::Sequence< ::rtl::OUString > lServices = RecoveryUI::st_getSupportedServiceNames();
+ sal_Int32 c = lServices.getLength();
+ sal_Int32 i = 0;
+ for (i=0; i<c; ++i)
+ {
+ const ::rtl::OUString& sSupportedService = lServices[i];
+ if (sSupportedService.equals(sServiceName))
+ return sal_True;
+ }
+ return sal_False;
+}
+
+//===============================================
+css::uno::Sequence< ::rtl::OUString > SAL_CALL RecoveryUI::getSupportedServiceNames()
+ throw(css::uno::RuntimeException)
+{
+ return RecoveryUI::st_getSupportedServiceNames();
+}
+
+//===============================================
+css::uno::Any SAL_CALL RecoveryUI::dispatchWithReturnValue(const css::util::URL& aURL,
+ const css::uno::Sequence< css::beans::PropertyValue >& )
+ throw(css::uno::RuntimeException)
+{
+ // Internaly we use VCL ... every call into vcl based code must
+ // be guarded by locking the global solar mutex.
+ ::SolarMutexGuard aSolarLock;
+
+ css::uno::Any aRet;
+ RecoveryUI::EJob eJob = impl_classifyJob(aURL);
+ // TODO think about outside arguments
+
+ switch(eJob)
+ {
+ case RecoveryUI::E_DO_EMERGENCY_SAVE :
+ {
+ sal_Bool bRet = impl_doEmergencySave();
+ aRet <<= bRet;
+ break;
+ }
+
+ case RecoveryUI::E_DO_RECOVERY :
+ impl_doRecovery();
+ break;
+
+ case RecoveryUI::E_DO_CRASHREPORT :
+ impl_doCrashReport();
+ break;
+
+ default :
+ break;
+ }
+
+ return aRet;
+}
+
+//===============================================
+void SAL_CALL RecoveryUI::dispatch(const css::util::URL& aURL ,
+ const css::uno::Sequence< css::beans::PropertyValue >& lArguments)
+ throw(css::uno::RuntimeException)
+{
+ // recycle this method :-)
+ dispatchWithReturnValue(aURL, lArguments);
+}
+
+//===============================================
+void SAL_CALL RecoveryUI::addStatusListener(const css::uno::Reference< css::frame::XStatusListener >&, const css::util::URL& ) throw(css::uno::RuntimeException)
+{
+ // TODO
+ OSL_ENSURE(sal_False, "RecoveryUI::addStatusListener()\nNot implemented yet!");
+}
+
+//===============================================
+void SAL_CALL RecoveryUI::removeStatusListener(const css::uno::Reference< css::frame::XStatusListener >&, const css::util::URL& )
+ throw(css::uno::RuntimeException)
+{
+ // TODO
+ OSL_ENSURE(sal_False, "RecoveryUI::removeStatusListener()\nNot implemented yet!");
+}
+
+//===============================================
+::rtl::OUString RecoveryUI::st_getImplementationName()
+{
+ static ::rtl::OUString IMPLEMENTATIONNAME = IMPLEMENTATIONNAME_RECOVERYUI;
+ return IMPLEMENTATIONNAME;
+}
+
+//===============================================
+css::uno::Sequence< ::rtl::OUString > RecoveryUI::st_getSupportedServiceNames()
+{
+ css::uno::Sequence< ::rtl::OUString > lServiceNames(1); lServiceNames.getArray() [0] = SERVICENAME_RECOVERYUI;
+ return lServiceNames;
+}
+
+//===============================================
+css::uno::Reference< css::uno::XInterface > SAL_CALL RecoveryUI::st_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
+{
+ RecoveryUI* pNew = new RecoveryUI(xSMGR);
+ return css::uno::Reference< css::uno::XInterface >(static_cast< css::lang::XServiceInfo* >(pNew));
+}
+
+//===============================================
+
+static OUString GetCrashConfigDir()
+{
+
+#if defined(WNT) || defined(OS2)
+ OUString ustrValue = OUString::createFromAscii("${$BRAND_BASE_DIR/program/bootstrap.ini:UserInstallation}");
+#elif defined(MACOSX)
+ OUString ustrValue = OUString::createFromAscii("~");
+#else
+ OUString ustrValue = OUString::createFromAscii("$SYSUSERCONFIG");
+#endif
+ Bootstrap::expandMacros( ustrValue );
+
+#if defined(WNT) || defined(OS2)
+ ustrValue += OUString::createFromAscii("/user/crashdata");
+#endif
+ return ustrValue;
+}
+
+//===============================================
+
+#if defined(WNT) || defined(OS2)
+#define LCKFILE "crashdat.lck"
+#else
+#define LCKFILE ".crash_report_unsent"
+#endif
+
+
+static OUString GetUnsentURL()
+{
+ OUString aURL = GetCrashConfigDir();
+
+ aURL += OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
+ aURL += OUString( RTL_CONSTASCII_USTRINGPARAM( LCKFILE ) );
+
+ return aURL;
+}
+
+//===============================================
+
+static bool new_crash_pending()
+{
+ OUString aUnsentURL = GetUnsentURL();
+ File aFile( aUnsentURL );
+
+ if ( FileBase::E_None == aFile.open( OpenFlag_Read ) )
+ {
+ aFile.close();
+ return true;
+ }
+
+ return false;
+}
+//===============================================
+
+static bool delete_pending_crash()
+{
+ OUString aUnsentURL = GetUnsentURL();
+ return ( FileBase::E_None == File::remove( aUnsentURL ) );
+}
+
+RecoveryUI::EJob RecoveryUI::impl_classifyJob(const css::util::URL& aURL)
+{
+ m_eJob = RecoveryUI::E_JOB_UNKNOWN;
+ if (aURL.Protocol.equals(RECOVERY_CMDPART_PROTOCOL))
+ {
+ if (aURL.Path.equals(RECOVERY_CMDPART_DO_EMERGENCY_SAVE))
+ m_eJob = RecoveryUI::E_DO_EMERGENCY_SAVE;
+ else
+ if (aURL.Path.equals(RECOVERY_CMDPART_DO_RECOVERY))
+ m_eJob = RecoveryUI::E_DO_RECOVERY;
+ else
+ if (aURL.Path.equals(RECOVERY_CMDPART_DO_CRASHREPORT))
+ m_eJob = RecoveryUI::E_DO_CRASHREPORT;
+ }
+
+ return m_eJob;
+}
+
+//===============================================
+sal_Bool RecoveryUI::impl_doEmergencySave()
+{
+ // create core service, which implements the real "emergency save" algorithm.
+ svxdr::RecoveryCore* pCore = new svxdr::RecoveryCore(m_xSMGR, sal_True);
+ css::uno::Reference< css::frame::XStatusListener > xCore(pCore);
+
+ // create all needed dialogs for this operation
+ // and bind it to the used core service
+ svxdr::TabDialog4Recovery* pWizard = new svxdr::TabDialog4Recovery(m_pParentWindow);
+ svxdr::IExtendedTabPage* pPage1 = new svxdr::SaveDialog (pWizard, pCore );
+ pWizard->addTabPage(pPage1);
+
+ // start the wizard
+ short nRet = pWizard->Execute();
+
+ delete pPage1 ;
+ delete pWizard;
+
+ return (nRet==DLG_RET_OK_AUTOLUNCH);
+}
+
+//===============================================
+void RecoveryUI::impl_doRecovery()
+{
+ sal_Bool bRecoveryOnly( sal_False );
+
+ ::rtl::OUString CFG_PACKAGE_RECOVERY( RTL_CONSTASCII_USTRINGPARAM ( "org.openoffice.Office.Recovery/" ));
+ ::rtl::OUString CFG_PATH_CRASHREPORTER( RTL_CONSTASCII_USTRINGPARAM( "CrashReporter" ));
+ ::rtl::OUString CFG_ENTRY_ENABLED( RTL_CONSTASCII_USTRINGPARAM ( "Enabled" ));
+
+ sal_Bool bCrashRepEnabled( sal_True );
+ css::uno::Any aVal = ::comphelper::ConfigurationHelper::readDirectKey(
+ m_xSMGR,
+ CFG_PACKAGE_RECOVERY,
+ CFG_PATH_CRASHREPORTER,
+ CFG_ENTRY_ENABLED,
+ ::comphelper::ConfigurationHelper::E_READONLY);
+ aVal >>= bCrashRepEnabled;
+ bRecoveryOnly = !bCrashRepEnabled;
+
+ // create core service, which implements the real "emergency save" algorithm.
+ svxdr::RecoveryCore* pCore = new svxdr::RecoveryCore(m_xSMGR, sal_False);
+ css::uno::Reference< css::frame::XStatusListener > xCore(pCore);
+
+ // create all needed dialogs for this operation
+ // and bind it to the used core service
+ svxdr::TabDialog4Recovery* pWizard = new svxdr::TabDialog4Recovery (m_pParentWindow);
+ svxdr::IExtendedTabPage* pPage1 = new svxdr::RecoveryDialog (pWizard, pCore );
+ svxdr::IExtendedTabPage* pPage2 = 0;
+ svxdr::IExtendedTabPage* pPage3 = 0;
+
+ pWizard->addTabPage(pPage1);
+ if ( !bRecoveryOnly && new_crash_pending() )
+ {
+ pPage2 = new svxdr::ErrorRepWelcomeDialog(pWizard );
+ pPage3 = new svxdr::ErrorRepSendDialog (pWizard );
+ pWizard->addTabPage(pPage2);
+ pWizard->addTabPage(pPage3);
+ }
+
+ // start the wizard
+ pWizard->Execute();
+
+ impl_showAllRecoveredDocs();
+
+ delete pPage3 ;
+ delete pPage2 ;
+ delete pPage1 ;
+ delete pWizard;
+
+ delete_pending_crash();
+}
+
+//===============================================
+
+void RecoveryUI::impl_doCrashReport()
+{
+ if ( new_crash_pending() )
+ {
+ svxdr::TabDialog4Recovery* pWizard = new svxdr::TabDialog4Recovery (m_pParentWindow );
+ svxdr::IExtendedTabPage* pPage1 = new svxdr::ErrorRepWelcomeDialog(pWizard, sal_False);
+ svxdr::IExtendedTabPage* pPage2 = new svxdr::ErrorRepSendDialog (pWizard );
+ pWizard->addTabPage(pPage1);
+ pWizard->addTabPage(pPage2);
+
+ // start the wizard
+ pWizard->Execute();
+
+ delete pPage2 ;
+ delete pPage1 ;
+ delete pWizard;
+
+ delete_pending_crash();
+ }
+}
+
+//===============================================
+void RecoveryUI::impl_showAllRecoveredDocs()
+{
+ css::uno::Reference< css::frame::XFramesSupplier > xDesktop(
+ m_xSMGR->createInstance(SERVICENAME_DESKTOP),
+ css::uno::UNO_QUERY_THROW);
+
+ css::uno::Reference< css::container::XIndexAccess > xTaskContainer(
+ xDesktop->getFrames(),
+ css::uno::UNO_QUERY_THROW);
+
+ sal_Int32 c = xTaskContainer->getCount();
+ sal_Int32 i = 0;
+ for (i=0; i<c; ++i)
+ {
+ try
+ {
+ css::uno::Reference< css::frame::XFrame > xTask;
+ xTaskContainer->getByIndex(i) >>= xTask;
+ if (!xTask.is())
+ continue;
+
+ css::uno::Reference< css::awt::XWindow > xWindow = xTask->getContainerWindow();
+ if (!xWindow.is())
+ continue;
+
+ xWindow->setVisible(sal_True);
+ }
+ catch(const css::uno::RuntimeException& exRun)
+ { throw exRun; }
+ catch(const css::uno::Exception&)
+ { continue; }
+ }
+}
+
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/shapeimpl.hxx b/svx/source/unodraw/shapeimpl.hxx
new file mode 100644
index 000000000000..f1b460c4272a
--- /dev/null
+++ b/svx/source/unodraw/shapeimpl.hxx
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_SHAPEIMPL_HXX
+#define _SVX_SHAPEIMPL_HXX
+
+#include <svx/unoshape.hxx>
+
+class SvGlobalName;
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+class SvxShapeCaption : public SvxShapeText
+{
+public:
+ SvxShapeCaption( SdrObject* pObj ) throw();
+ virtual ~SvxShapeCaption() throw();
+};
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+class SvxPluginShape : public SvxOle2Shape
+{
+protected:
+ // overide these for special property handling in subcasses. Return true if property is handled
+ virtual bool setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual bool getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+public:
+ SvxPluginShape( SdrObject* pObj ) throw();
+ virtual ~SvxPluginShape() throw();
+
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL );
+};
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+class SvxAppletShape : public SvxOle2Shape
+{
+protected:
+ // overide these for special property handling in subcasses. Return true if property is handled
+ virtual bool setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual bool getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+public:
+ SvxAppletShape( SdrObject* pObj ) throw();
+ virtual ~SvxAppletShape() throw();
+
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL );
+};
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+class SvxFrameShape : public SvxOle2Shape
+{
+protected:
+ // overide these for special property handling in subcasses. Return true if property is handled
+ virtual bool setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual bool getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+public:
+ SvxFrameShape( SdrObject* pObj ) throw();
+ virtual ~SvxFrameShape() throw();
+
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ virtual void Create( SdrObject* pNewOpj, SvxDrawPage* pNewPage = NULL ) throw ();
+};
+
+
+// ====================================================================
+
+class SvxTableShape : public SvxShape
+{
+protected:
+ // overide these for special property handling in subcasses. Return true if property is handled
+ virtual bool setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual bool getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ virtual void lock();
+ virtual void unlock();
+
+public:
+
+ SvxTableShape( SdrObject* pObj ) throw();
+ virtual ~SvxTableShape() throw();
+};
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/shapepropertynotifier.cxx b/svx/source/unodraw/shapepropertynotifier.cxx
new file mode 100644
index 000000000000..4e249ead3470
--- /dev/null
+++ b/svx/source/unodraw/shapepropertynotifier.cxx
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * 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_svx.hxx"
+
+#include "svx/shapepropertynotifier.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/stl_types.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/weak.hxx>
+#include <tools/diagnose_ex.h>
+
+#include <hash_map>
+
+namespace
+{
+
+ struct ShapePropertyHash
+ {
+ size_t operator()( ::svx::ShapeProperty __x ) const
+ {
+ return size_t( __x );
+ }
+ };
+}
+
+//........................................................................
+namespace svx
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::beans::XPropertyChangeListener;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::beans::XPropertySet;
+ /** === end UNO using === **/
+
+ typedef ::std::hash_map< ShapeProperty, PPropertyValueProvider, ShapePropertyHash > PropertyProviders;
+
+ typedef ::cppu::OMultiTypeInterfaceContainerHelperVar < ::rtl::OUString
+ , ::comphelper::UStringHash
+ , ::comphelper::UStringEqual
+ > PropertyChangeListenerContainer;
+
+ //====================================================================
+ //= IPropertyValueProvider
+ //====================================================================
+ IPropertyValueProvider::~IPropertyValueProvider()
+ {
+ }
+
+ //====================================================================
+ //= PropertyChangeNotifier_Data
+ //====================================================================
+ struct PropertyChangeNotifier_Data
+ {
+ ::cppu::OWeakObject& m_rContext;
+ PropertyProviders m_aProviders;
+ PropertyChangeListenerContainer m_aPropertyChangeListeners;
+
+ PropertyChangeNotifier_Data( ::cppu::OWeakObject& _rContext, ::osl::Mutex& _rMutex )
+ :m_rContext( _rContext )
+ ,m_aPropertyChangeListeners( _rMutex )
+ {
+ }
+ };
+ //====================================================================
+ //= PropertyValueProvider
+ //====================================================================
+ //--------------------------------------------------------------------
+ ::rtl::OUString PropertyValueProvider::getPropertyName() const
+ {
+ return m_sPropertyName;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyValueProvider::getCurrentValue( Any& _out_rValue ) const
+ {
+ Reference< XPropertySet > xContextProps( const_cast< PropertyValueProvider* >( this )->m_rContext, UNO_QUERY_THROW );
+ _out_rValue = xContextProps->getPropertyValue( getPropertyName() );
+ }
+
+ //====================================================================
+ //= PropertyChangeNotifier
+ //====================================================================
+ //--------------------------------------------------------------------
+ PropertyChangeNotifier::PropertyChangeNotifier( ::cppu::OWeakObject& _rOwner, ::osl::Mutex& _rMutex )
+ :m_pData( new PropertyChangeNotifier_Data( _rOwner, _rMutex ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ PropertyChangeNotifier::~PropertyChangeNotifier()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyChangeNotifier::registerProvider( const ShapeProperty _eProperty, const PPropertyValueProvider _pProvider )
+ {
+ ENSURE_OR_THROW( _eProperty != eInvalidShapeProperty, "Illegal ShapeProperty value!" );
+ ENSURE_OR_THROW( !!_pProvider, "NULL factory not allowed." );
+
+ OSL_ENSURE( m_pData->m_aProviders.find( _eProperty ) == m_pData->m_aProviders.end(),
+ "PropertyChangeNotifier::registerProvider: factory for this ID already present!" );
+
+ m_pData->m_aProviders[ _eProperty ] = _pProvider;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyChangeNotifier::notifyPropertyChange( const ShapeProperty _eProperty ) const
+ {
+ ENSURE_OR_THROW( _eProperty != eInvalidShapeProperty, "Illegal ShapeProperty value!" );
+
+ PropertyProviders::const_iterator provPos = m_pData->m_aProviders.find( _eProperty );
+ OSL_ENSURE( provPos != m_pData->m_aProviders.end(), "PropertyChangeNotifier::notifyPropertyChange: no factory!" );
+ if ( provPos == m_pData->m_aProviders.end() )
+ return;
+
+ ::rtl::OUString sPropertyName( provPos->second->getPropertyName() );
+
+ ::cppu::OInterfaceContainerHelper* pPropListeners = m_pData->m_aPropertyChangeListeners.getContainer( sPropertyName );
+ ::cppu::OInterfaceContainerHelper* pAllListeners = m_pData->m_aPropertyChangeListeners.getContainer( ::rtl::OUString() );
+ if ( !pPropListeners && !pAllListeners )
+ return;
+
+ try
+ {
+ PropertyChangeEvent aEvent;
+ aEvent.Source = m_pData->m_rContext;
+ // Handle/OldValue not supported
+ aEvent.PropertyName = provPos->second->getPropertyName();
+ provPos->second->getCurrentValue( aEvent.NewValue );
+
+ if ( pPropListeners )
+ pPropListeners->notifyEach( &XPropertyChangeListener::propertyChange, aEvent );
+ if ( pAllListeners )
+ pAllListeners->notifyEach( &XPropertyChangeListener::propertyChange, aEvent );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyChangeNotifier::addPropertyChangeListener( const ::rtl::OUString& _rPropertyName, const Reference< XPropertyChangeListener >& _rxListener )
+ {
+ m_pData->m_aPropertyChangeListeners.addInterface( _rPropertyName, _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyChangeNotifier::removePropertyChangeListener( const ::rtl::OUString& _rPropertyName, const Reference< XPropertyChangeListener >& _rxListener )
+ {
+ m_pData->m_aPropertyChangeListeners.removeInterface( _rPropertyName, _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyChangeNotifier::disposing()
+ {
+ EventObject aEvent;
+ aEvent.Source = m_pData->m_rContext;
+ m_pData->m_aPropertyChangeListeners.disposeAndClear( aEvent );
+ }
+
+//........................................................................
+} // namespace svx
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/tableshape.cxx b/svx/source/unodraw/tableshape.cxx
new file mode 100644
index 000000000000..1f9c93c13a0c
--- /dev/null
+++ b/svx/source/unodraw/tableshape.cxx
@@ -0,0 +1,196 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "shapeimpl.hxx"
+#include "svx/unoshprp.hxx"
+#include "svx/svdotable.hxx"
+#include <svx/svdpool.hxx>
+
+///////////////////////////////////////////////////////////////////////
+
+using ::rtl::OUString;
+
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::sdr::table;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+
+SvxTableShape::SvxTableShape( SdrObject* pObj ) throw()
+: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_TABLE), aSvxMapProvider.GetPropertySet(SVXMAP_TABLE, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+ SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.TableShape" ) ) );
+}
+
+//----------------------------------------------------------------------
+SvxTableShape::~SvxTableShape() throw()
+{
+}
+
+//----------------------------------------------------------------------
+
+bool SvxTableShape::setPropertyValueImpl(
+ const ::rtl::OUString& rName,
+ const SfxItemPropertySimpleEntry* pProperty,
+ const ::com::sun::star::uno::Any& rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_TABLETEMPLATE:
+ {
+ Reference< XIndexAccess > xTemplate;
+
+ if( !(rValue >>= xTemplate) )
+ throw IllegalArgumentException();
+
+ if( mpObj.is() )
+ static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyle(xTemplate);
+
+ return true;
+ }
+ case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
+ case OWN_ATTR_TABLETEMPLATE_LASTROW:
+ case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
+ case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
+ case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
+ case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
+ {
+ if( mpObj.is() )
+ {
+ TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
+
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue >>= aSettings.mbUseFirstRow; break;
+ case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue >>= aSettings.mbUseLastRow; break;
+ case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue >>= aSettings.mbUseFirstColumn; break;
+ case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue >>= aSettings.mbUseLastColumn; break;
+ case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue >>= aSettings.mbUseRowBanding; break;
+ case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue >>= aSettings.mbUseColumnBanding; break;
+ }
+
+ static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyleSettings(aSettings);
+ }
+
+ return true;
+ }
+ default:
+ {
+ return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+ }
+}
+
+extern Graphic SvxGetGraphicForShape( SdrObject& rShape, bool bVector );
+
+bool SvxTableShape::getPropertyValueImpl(
+ const ::rtl::OUString& rName,
+ const SfxItemPropertySimpleEntry* pProperty,
+ ::com::sun::star::uno::Any& rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_OLEMODEL:
+ {
+ if( mpObj.is() )
+ {
+ rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTable();
+ }
+ return true;
+ }
+ case OWN_ATTR_TABLETEMPLATE:
+ {
+ if( mpObj.is() )
+ {
+ rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyle();
+ }
+ return true;
+ }
+ case OWN_ATTR_BITMAP:
+ {
+ if( mpObj.is() )
+ {
+ Graphic aGraphic( SvxGetGraphicForShape( *mpObj.get(), true ) );
+ rValue <<= aGraphic.GetXGraphic();
+ }
+ return true;
+ }
+ case OWN_ATTR_TABLETEMPLATE_FIRSTROW:
+ case OWN_ATTR_TABLETEMPLATE_LASTROW:
+ case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN:
+ case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN:
+ case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
+ case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
+ {
+ if( mpObj.is() )
+ {
+ TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
+
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_TABLETEMPLATE_FIRSTROW: rValue <<= aSettings.mbUseFirstRow; break;
+ case OWN_ATTR_TABLETEMPLATE_LASTROW: rValue <<= aSettings.mbUseLastRow; break;
+ case OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN: rValue <<= aSettings.mbUseFirstColumn; break;
+ case OWN_ATTR_TABLETEMPLATE_LASTCOLUMN: rValue <<= aSettings.mbUseLastColumn; break;
+ case OWN_ATTR_TABLETEMPLATE_BANDINGROWS: rValue <<= aSettings.mbUseRowBanding; break;
+ case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS: rValue <<= aSettings.mbUseColumnBanding; break;
+ }
+ }
+
+ return true;
+ }
+ default:
+ {
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+ }
+}
+
+void SvxTableShape::lock()
+{
+ SvxShape::lock();
+ if( mpObj.is() )
+ static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_lock();
+}
+
+void SvxTableShape::unlock()
+{
+ if( mpObj.is() )
+ static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_unlock();
+ SvxShape::unlock();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unobtabl.cxx b/svx/source/unodraw/unobtabl.cxx
new file mode 100644
index 000000000000..d5512ebe6121
--- /dev/null
+++ b/svx/source/unodraw/unobtabl.cxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svl/itempool.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <svl/itemset.hxx>
+#include <svx/xit.hxx>
+#include "UnoNameItemTable.hxx"
+
+#include <svx/xbtmpit.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/xflhtit.hxx>
+#include "unoapi.hxx"
+#include <svx/unomid.hxx>
+#include <editeng/unoprnms.hxx>
+#include "unofill.hxx"
+#include <editeng/memberids.hrc>
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+using namespace ::cppu;
+
+class SvxUnoBitmapTable : public SvxUnoNameItemTable
+{
+public:
+ SvxUnoBitmapTable( SdrModel* pModel ) throw();
+ virtual ~SvxUnoBitmapTable() throw();
+
+ virtual NameOrIndex* createItem() const throw();
+ virtual bool isValid( const NameOrIndex* pItem ) const;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException);
+};
+
+SvxUnoBitmapTable::SvxUnoBitmapTable( SdrModel* pModel ) throw()
+: SvxUnoNameItemTable( pModel, XATTR_FILLBITMAP, MID_GRAFURL )
+{
+}
+
+SvxUnoBitmapTable::~SvxUnoBitmapTable() throw()
+{
+}
+
+bool SvxUnoBitmapTable::isValid( const NameOrIndex* pItem ) const
+{
+ if( SvxUnoNameItemTable::isValid( pItem ) )
+ {
+ const XFillBitmapItem* pBitmapItem = dynamic_cast< const XFillBitmapItem* >( pItem );
+ if( pBitmapItem )
+ {
+ const GraphicObject& rGraphic = pBitmapItem->GetBitmapValue().GetGraphicObject();
+ return rGraphic.GetSizeBytes() > 0;
+ }
+ }
+
+ return false;
+}
+
+OUString SAL_CALL SvxUnoBitmapTable::getImplementationName() throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoBitmapTable") );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoBitmapTable::getSupportedServiceNames( )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable" ));
+ return aSNS;
+}
+
+NameOrIndex* SvxUnoBitmapTable::createItem() const throw()
+{
+ return new XFillBitmapItem();
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoBitmapTable::getElementType( )
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType( (const ::rtl::OUString*)0 );
+}
+
+/**
+ * Create a bitmaptable
+ */
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoBitmapTable_createInstance( SdrModel* pModel )
+{
+ return *new SvxUnoBitmapTable(pModel);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoctabl.cxx b/svx/source/unodraw/unoctabl.cxx
new file mode 100644
index 000000000000..e9ac80209519
--- /dev/null
+++ b/svx/source/unodraw/unoctabl.cxx
@@ -0,0 +1,450 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <unotools/pathoptions.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+#include "../customshapes/EnhancedCustomShapeEngine.hxx"
+
+#include <svx/xtable.hxx>
+#include "unoshcol.hxx"
+#include "recoveryui.hxx"
+#include "xmlgrhlp.hxx"
+#include "tbunocontroller.hxx"
+#include "tbunosearchcontrollers.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+using namespace ::cppu;
+
+class SvxUnoColorTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >
+{
+private:
+ XColorTable* pTable;
+
+public:
+ SvxUnoColorTable() throw();
+ virtual ~SvxUnoColorTable() throw();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException);
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+
+ static OUString getImplementationName_Static() throw()
+ {
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxUnoColorTable"));
+ }
+
+ static uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw();
+
+ // XNameContainer
+ virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XNameAccess
+ virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+ virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException);
+};
+
+SvxUnoColorTable::SvxUnoColorTable() throw()
+{
+ pTable = new XColorTable( SvtPathOptions().GetPalettePath() );
+}
+
+SvxUnoColorTable::~SvxUnoColorTable() throw()
+{
+ delete pTable;
+}
+
+sal_Bool SAL_CALL SvxUnoColorTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
+{
+ uno::Sequence< OUString > aSNL( getSupportedServiceNames() );
+ const OUString * pArray = aSNL.getConstArray();
+
+ for( INT32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return TRUE;
+
+ return FALSE;
+}
+
+OUString SAL_CALL SvxUnoColorTable::getImplementationName() throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoColorTable") );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoColorTable::getSupportedServiceNames( )
+ throw( uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+uno::Sequence< OUString > SvxUnoColorTable::getSupportedServiceNames_Static(void) throw()
+{
+ uno::Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ColorTable" ));
+ return aSNS;
+}
+
+// XNameContainer
+void SAL_CALL SvxUnoColorTable::insertByName( const OUString& aName, const uno::Any& aElement )
+ throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ if( hasByName( aName ) )
+ throw container::ElementExistException();
+
+ INT32 nColor = 0;
+ if( !(aElement >>= nColor) )
+ throw lang::IllegalArgumentException();
+
+ if( pTable )
+ {
+ XColorEntry* pEntry = new XColorEntry( Color( (ColorData)nColor ), aName );
+ pTable->Insert( pTable->Count(), pEntry );
+ }
+}
+
+void SAL_CALL SvxUnoColorTable::removeByName( const OUString& Name )
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( Name ) : -1;
+ if( nIndex == -1 )
+ throw container::NoSuchElementException();
+
+ pTable->Remove( nIndex );
+}
+
+// XNameReplace
+void SAL_CALL SvxUnoColorTable::replaceByName( const OUString& aName, const uno::Any& aElement )
+ throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ INT32 nColor = 0;
+ if( !(aElement >>= nColor) )
+ throw lang::IllegalArgumentException();
+
+ long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( aName ) : -1;
+ if( nIndex == -1 )
+ throw container::NoSuchElementException();
+
+ XColorEntry* pEntry = new XColorEntry( Color( (ColorData)nColor ), aName );
+ delete pTable->Replace( nIndex, pEntry );
+}
+
+// XNameAccess
+uno::Any SAL_CALL SvxUnoColorTable::getByName( const OUString& aName )
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( aName ) : -1;
+ if( nIndex == -1 )
+ throw container::NoSuchElementException();
+
+ XColorEntry* pEntry = ((XColorTable*)pTable)->GetColor( nIndex );
+ return uno::Any( (sal_Int32) pEntry->GetColor().GetRGBColor() );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoColorTable::getElementNames( )
+ throw( uno::RuntimeException )
+{
+ const long nCount = pTable ? pTable->Count() : 0;
+
+ uno::Sequence< OUString > aSeq( nCount );
+ OUString* pStrings = aSeq.getArray();
+
+ for( long nIndex = 0; nIndex < nCount; nIndex++ )
+ {
+ XColorEntry* pEntry = pTable->GetColor( (long)nIndex );
+ pStrings[nIndex] = pEntry->GetName();
+ }
+
+ return aSeq;
+}
+
+sal_Bool SAL_CALL SvxUnoColorTable::hasByName( const OUString& aName )
+ throw( uno::RuntimeException )
+{
+ long nIndex = pTable ? ((XPropertyTable*)pTable)->Get( aName ) : -1;
+ return nIndex != -1;
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoColorTable::getElementType( )
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const sal_Int32*)0);
+}
+
+sal_Bool SAL_CALL SvxUnoColorTable::hasElements( )
+ throw( uno::RuntimeException )
+{
+ return pTable && pTable->Count() != 0;
+}
+
+/**
+ * Create a colortable
+ */
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoColorTable_createInstance(const uno::Reference< lang::XMultiServiceFactory > & ) throw(uno::Exception)
+{
+ return *new SvxUnoColorTable();
+}
+uno::Reference< uno::XInterface > SAL_CALL create_EnhancedCustomShapeEngine( const uno::Reference< lang::XMultiServiceFactory >& rxFact ) throw(uno::Exception)
+{
+ return *new EnhancedCustomShapeEngine( rxFact );
+}
+
+//
+// export this service
+//
+
+#include "UnoGraphicExporter.hxx"
+#include "unogalthemeprovider.hxx"
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include "sal/types.h"
+#include "osl/diagnose.h"
+#include "cppuhelper/factory.hxx"
+#include "uno/lbnames.h"
+#include <svx/sdr/primitive2d/primitiveFactory2d.hxx>
+
+/*
+namespace svx
+{
+extern OUString SAL_CALL ExtrusionDepthController_getImplementationName();
+extern uno::Reference< uno::XInterface > SAL_CALL ExtrusionDepthController_createInstance(const uno::Reference< lang::XMultiServiceFactory > &) throw( uno::RuntimeException );
+extern uno::Sequence< OUString > SAL_CALL ExtrusionDepthController_getSupportedServiceNames() throw( uno::RuntimeException );
+}
+*/
+
+extern "C"
+{
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment (
+ const sal_Char ** ppEnvTypeName, uno_Environment ** )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+static void writeInfo (
+ registry::XRegistryKey * pRegistryKey,
+ const OUString& rImplementationName,
+ const uno::Sequence< OUString >& rServices)
+{
+ uno::Reference< registry::XRegistryKey > xNewKey(
+ pRegistryKey->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + rImplementationName + OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) ) );
+
+ for( sal_Int32 i = 0; i < rServices.getLength(); i++ )
+ xNewKey->createKey( rServices.getConstArray()[i]);
+}
+
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo (
+ void * , void * pRegistryKey)
+{
+ if( pRegistryKey )
+ {
+ try
+ {
+ registry::XRegistryKey *pKey = reinterpret_cast< registry::XRegistryKey * >( pRegistryKey );
+
+ writeInfo( pKey, SvxShapeCollection::getImplementationName_Static(), SvxShapeCollection::getSupportedServiceNames_Static() );
+ writeInfo( pKey, SvxUnoColorTable::getImplementationName_Static(), SvxUnoColorTable::getSupportedServiceNames_Static() );
+ writeInfo( pKey, EnhancedCustomShapeEngine_getImplementationName(), EnhancedCustomShapeEngine_getSupportedServiceNames() );
+ writeInfo( pKey, svx::RecoveryUI::st_getImplementationName(), svx::RecoveryUI::st_getSupportedServiceNames() );
+ writeInfo( pKey, svx::GraphicExporter_getImplementationName(), svx::GraphicExporter_getSupportedServiceNames() );
+ writeInfo( pKey, svx::FontHeightToolBoxControl::getImplementationName_Static(), svx::FontHeightToolBoxControl::getSupportedServiceNames_Static() );
+
+ writeInfo( pKey, svx::FindTextToolbarController::getImplementationName_Static(), svx::FindTextToolbarController::getSupportedServiceNames_Static() );
+ writeInfo( pKey, svx::DownSearchToolboxController::getImplementationName_Static(), svx::DownSearchToolboxController::getSupportedServiceNames_Static() );
+ writeInfo( pKey, svx::UpSearchToolboxController::getImplementationName_Static(), svx::UpSearchToolboxController::getSupportedServiceNames_Static() );
+ writeInfo( pKey, svx::FindbarDispatcher::getImplementationName_Static(), svx::FindbarDispatcher::getSupportedServiceNames_Static() );
+
+ writeInfo( pKey, ::unogallery::GalleryThemeProvider_getImplementationName(),::unogallery::GalleryThemeProvider_getSupportedServiceNames() );
+
+ // XPrimitiveFactory2D
+ writeInfo( pKey,
+ drawinglayer::primitive2d::PrimitiveFactory2D::getImplementationName_Static(),
+ drawinglayer::primitive2d::PrimitiveFactory2D::getSupportedServiceNames_Static() );
+
+ writeInfo( pKey, ::svx::SvXMLGraphicImportHelper_getImplementationName(),::svx::SvXMLGraphicImportHelper_getSupportedServiceNames() );
+ writeInfo( pKey, ::svx::SvXMLGraphicExportHelper_getImplementationName(),::svx::SvXMLGraphicExportHelper_getSupportedServiceNames() );
+// writeInfo( pKey, ::svx::ExtrusionDepthController_getImplementationName(),::svx::ExtrusionDepthController_getSupportedServiceNames() );
+ }
+ catch (registry::InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+
+ return sal_True;
+}
+
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory (
+ const sal_Char * pImplName, void * pServiceManager, void * )
+{
+ void * pRet = 0;
+ if( pServiceManager )
+ {
+ uno::Reference< lang::XSingleServiceFactory > xFactory;
+
+ if( rtl_str_compare( pImplName, "com.sun.star.drawing.SvxUnoColorTable" ) == 0 )
+ {
+ xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ SvxUnoColorTable::getImplementationName_Static(),
+ SvxUnoColorTable_createInstance,
+ SvxUnoColorTable::getSupportedServiceNames_Static() );
+ }
+ else if ( rtl_str_compare( pImplName, "com.sun.star.drawing.EnhancedCustomShapeEngine" ) == 0 )
+ {
+ xFactory = createSingleFactory( reinterpret_cast< NMSP_LANG::XMultiServiceFactory* >( pServiceManager ),
+ EnhancedCustomShapeEngine_getImplementationName(),
+ create_EnhancedCustomShapeEngine,
+ EnhancedCustomShapeEngine_getSupportedServiceNames() );
+ }
+ else if( rtl_str_compare( pImplName, "com.sun.star.drawing.SvxShapeCollection" ) == 0 )
+ {
+ xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ SvxShapeCollection::getImplementationName_Static(),
+ SvxShapeCollection_createInstance,
+ SvxShapeCollection::getSupportedServiceNames_Static() );
+ }
+ else if( svx::RecoveryUI::st_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ svx::RecoveryUI::st_getImplementationName(),
+ svx::RecoveryUI::st_createInstance,
+ svx::RecoveryUI::st_getSupportedServiceNames() );
+ }
+ else if( svx::GraphicExporter_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ svx::GraphicExporter_getImplementationName(),
+ svx::GraphicExporter_createInstance,
+ svx::GraphicExporter_getSupportedServiceNames() );
+ }
+ else if ( svx::FontHeightToolBoxControl::getImplementationName_Static().equalsAscii( pImplName ) )
+ {
+ xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ svx::FontHeightToolBoxControl::getImplementationName_Static(),
+ svx::FontHeightToolBoxControl_createInstance,
+ svx::FontHeightToolBoxControl::getSupportedServiceNames_Static() );
+ }
+ else if ( svx::FindTextToolbarController::getImplementationName_Static().equalsAscii( pImplName ) )
+ {
+ xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ svx::FindTextToolbarController::getImplementationName_Static(),
+ svx::FindTextToolbarController_createInstance,
+ svx::FindTextToolbarController::getSupportedServiceNames_Static() );
+ }
+ else if ( svx::DownSearchToolboxController::getImplementationName_Static().equalsAscii( pImplName ) )
+ {
+ xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ svx::DownSearchToolboxController::getImplementationName_Static(),
+ svx::DownSearchToolboxController_createInstance,
+ svx::DownSearchToolboxController::getSupportedServiceNames_Static() );
+ }
+ else if ( svx::UpSearchToolboxController::getImplementationName_Static().equalsAscii( pImplName ) )
+ {
+ xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ svx::UpSearchToolboxController::getImplementationName_Static(),
+ svx::UpSearchToolboxController_createInstance,
+ svx::UpSearchToolboxController::getSupportedServiceNames_Static() );
+ }
+ else if ( svx::FindbarDispatcher::getImplementationName_Static().equalsAscii( pImplName ) )
+ {
+ xFactory = createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ svx::FindbarDispatcher::getImplementationName_Static(),
+ svx::FindbarDispatcher_createInstance,
+ svx::FindbarDispatcher::getSupportedServiceNames_Static() );
+ }
+ else if( ::unogallery::GalleryThemeProvider_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ ::unogallery::GalleryThemeProvider_getImplementationName(),
+ ::unogallery::GalleryThemeProvider_createInstance,
+ ::unogallery::GalleryThemeProvider_getSupportedServiceNames() );
+ }
+ else if( drawinglayer::primitive2d::PrimitiveFactory2D::getImplementationName_Static().equalsAscii( pImplName ) )
+ {
+ // XPrimitiveFactory2D
+ xFactory = ::cppu::createSingleFactory( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ drawinglayer::primitive2d::PrimitiveFactory2D::getImplementationName_Static(),
+ drawinglayer::primitive2d::XPrimitiveFactory2DProvider_createInstance,
+ drawinglayer::primitive2d::PrimitiveFactory2D::getSupportedServiceNames_Static() );
+ }
+ else if( ::svx::SvXMLGraphicImportHelper_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ ::svx::SvXMLGraphicImportHelper_getImplementationName(),
+ ::svx::SvXMLGraphicImportHelper_createInstance,
+ ::svx::SvXMLGraphicImportHelper_getSupportedServiceNames() );
+ }
+ else if( ::svx::SvXMLGraphicExportHelper_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ ::svx::SvXMLGraphicExportHelper_getImplementationName(),
+ ::svx::SvXMLGraphicExportHelper_createInstance,
+ ::svx::SvXMLGraphicExportHelper_getSupportedServiceNames() );
+ }
+/*
+ else if( ::svx::ExtrusionDepthController_getImplementationName().equalsAscii( pImplName ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),
+ ::svx::ExtrusionDepthController_getImplementationName(),
+ ::svx::ExtrusionDepthController_createInstance,
+ ::svx::ExtrusionDepthController_getSupportedServiceNames() );
+ }
+*/
+ if( xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unodraw.src b/svx/source/unodraw/unodraw.src
new file mode 100644
index 000000000000..f905e651cf79
--- /dev/null
+++ b/svx/source/unodraw/unodraw.src
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include <svx/dialogs.hrc>
+
+Bitmap RID_UNODRAW_OBJECTS
+{
+ File = "objects.bmp" ;
+};
+Bitmap RID_UNODRAW_OLE2
+{
+ File = "ole.bmp" ;
+};
+Bitmap RID_UNODRAW_GRAPHICS
+{
+ File = "graphic.bmp" ;
+};
+
diff --git a/svx/source/unodraw/unodtabl.cxx b/svx/source/unodraw/unodtabl.cxx
new file mode 100644
index 000000000000..8fe41f38366d
--- /dev/null
+++ b/svx/source/unodraw/unodtabl.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/drawing/LineDash.hpp>
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
+
+#include <vector>
+#include "UnoNameItemTable.hxx"
+#include <svx/xlndsit.hxx>
+#include <svx/unomid.hxx>
+
+#include <svx/xdash.hxx>
+#include <svx/svdmodel.hxx>
+#include "unofill.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+using namespace ::cppu;
+
+class SvxUnoDashTable : public SvxUnoNameItemTable
+{
+public:
+ SvxUnoDashTable( SdrModel* pModel ) throw();
+ virtual ~SvxUnoDashTable() throw();
+
+ virtual NameOrIndex* createItem() const throw();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException);
+};
+
+SvxUnoDashTable::SvxUnoDashTable( SdrModel* pModel ) throw()
+: SvxUnoNameItemTable( pModel, XATTR_LINEDASH, MID_LINEDASH )
+{
+}
+
+SvxUnoDashTable::~SvxUnoDashTable() throw()
+{
+}
+
+OUString SAL_CALL SvxUnoDashTable::getImplementationName() throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDashTable") );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoDashTable::getSupportedServiceNames( )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable" ));
+ return aSNS;
+}
+
+NameOrIndex* SvxUnoDashTable::createItem() const throw()
+{
+ XLineDashItem* pNewItem = new XLineDashItem();
+ pNewItem->SetWhich( XATTR_LINEDASH ); // set which id for pooling
+ return pNewItem;
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoDashTable::getElementType( )
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const struct drawing::LineDash*)0);
+}
+
+/**
+ * Create a gradienttable
+ */
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoDashTable_createInstance( SdrModel* pModel )
+{
+ return *new SvxUnoDashTable(pModel);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unogtabl.cxx b/svx/source/unodraw/unogtabl.cxx
new file mode 100644
index 000000000000..243b6bc445d2
--- /dev/null
+++ b/svx/source/unodraw/unogtabl.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/awt/Gradient.hpp>
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
+#include "UnoNameItemTable.hxx"
+
+#include <svx/xgrad.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/xdef.hxx>
+#include <svx/xflgrit.hxx>
+#include "unofill.hxx"
+#include <svx/unomid.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+using namespace ::cppu;
+
+class SvxUnoGradientTable : public SvxUnoNameItemTable
+{
+public:
+ SvxUnoGradientTable( SdrModel* pModel ) throw();
+ virtual ~SvxUnoGradientTable() throw();
+
+ virtual NameOrIndex* createItem() const throw();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException);
+};
+
+SvxUnoGradientTable::SvxUnoGradientTable( SdrModel* pModel ) throw()
+ : SvxUnoNameItemTable( pModel, XATTR_FILLGRADIENT, MID_FILLGRADIENT )
+{
+}
+
+SvxUnoGradientTable::~SvxUnoGradientTable() throw()
+{
+}
+
+OUString SAL_CALL SvxUnoGradientTable::getImplementationName() throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoGradientTable") );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoGradientTable::getSupportedServiceNames( )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable" ));
+ return aSNS;
+}
+
+
+// XNameContainer
+NameOrIndex* SvxUnoGradientTable::createItem() const throw()
+{
+ return new XFillGradientItem();
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoGradientTable::getElementType( )
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const struct awt::Gradient*)0);
+}
+
+/**
+ * Create a gradienttable
+ */
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoGradientTable_createInstance( SdrModel* pModel )
+{
+ return *new SvxUnoGradientTable(pModel);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unohtabl.cxx b/svx/source/unodraw/unohtabl.cxx
new file mode 100644
index 000000000000..17a03e652e2e
--- /dev/null
+++ b/svx/source/unodraw/unohtabl.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/drawing/Hatch.hpp>
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
+#include "UnoNameItemTable.hxx"
+
+#include <svx/xhatch.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/xdef.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/unomid.hxx>
+#include "unofill.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+using namespace ::cppu;
+
+class SvxUnoHatchTable : public SvxUnoNameItemTable
+{
+public:
+ SvxUnoHatchTable( SdrModel* pModel ) throw();
+ virtual ~SvxUnoHatchTable() throw();
+
+ virtual NameOrIndex* createItem() const throw();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException);
+};
+
+SvxUnoHatchTable::SvxUnoHatchTable( SdrModel* pModel ) throw()
+: SvxUnoNameItemTable( pModel, XATTR_FILLHATCH, MID_FILLHATCH )
+{
+}
+
+SvxUnoHatchTable::~SvxUnoHatchTable() throw()
+{
+}
+
+OUString SAL_CALL SvxUnoHatchTable::getImplementationName() throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoHatchTable") );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoHatchTable::getSupportedServiceNames( )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable" ));
+ return aSNS;
+}
+
+NameOrIndex* SvxUnoHatchTable::createItem() const throw()
+{
+ return new XFillHatchItem();
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoHatchTable::getElementType( )
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const struct drawing::Hatch*)0);
+}
+
+/**
+ * Create a hatchtable
+ */
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoHatchTable_createInstance( SdrModel* pModel )
+{
+ return *new SvxUnoHatchTable(pModel);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unomlstr.cxx b/svx/source/unodraw/unomlstr.cxx
new file mode 100644
index 000000000000..925d447e96dc
--- /dev/null
+++ b/svx/source/unodraw/unomlstr.cxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <svx/svdobj.hxx>
+// header for class OGuard
+#include <osl/mutex.hxx>
+// header for class Application
+#include <vcl/svapp.hxx>
+
+#include "unomlstr.hxx"
+
+using namespace ::com::sun::star;
+
+SvxUnoShapeModifyListener::SvxUnoShapeModifyListener( SdrObject* pObj ) throw()
+{
+ mpObj = pObj;
+}
+
+SvxUnoShapeModifyListener::~SvxUnoShapeModifyListener() throw()
+{
+}
+
+// ::com::sun::star::util::XModifyListener
+void SAL_CALL SvxUnoShapeModifyListener::modified(const lang::EventObject& ) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if( mpObj )
+ {
+ mpObj->SetChanged();
+ mpObj->BroadcastObjectChange();
+ }
+}
+
+// ::com::sun::star::lang::XEventListener
+void SvxUnoShapeModifyListener::disposing(const lang::EventObject& ) throw( uno::RuntimeException )
+{
+ invalidate();
+}
+
+// internal
+void SvxUnoShapeModifyListener::invalidate() throw()
+{
+ mpObj = NULL;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unomod.cxx b/svx/source/unodraw/unomod.cxx
new file mode 100644
index 000000000000..339ba79e4168
--- /dev/null
+++ b/svx/source/unodraw/unomod.cxx
@@ -0,0 +1,757 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define _SVX_USE_UNOGLOBALS_
+#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
+#include <com/sun/star/lang/NoSupportException.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/list.hxx>
+#include <svl/itemprop.hxx>
+#include <svtools/unoevent.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/serviceinfohelper.hxx>
+
+#include <cppuhelper/implbase2.hxx>
+#include <unofill.hxx>
+#include <editeng/unonrule.hxx>
+#include <svtools/unoimap.hxx>
+#include <svx/fmdpage.hxx>
+#include <svx/fmmodel.hxx>
+#include <svx/fmpage.hxx>
+#include <sfx2/sfx.hrc>
+#include <unoapi.hxx>
+
+#include <svx/svdmodel.hxx>
+#include "globl3d.hxx"
+#include <svx/svdtypes.hxx>
+#include <svx/unoprov.hxx>
+#include <svx/unopage.hxx>
+#include <editeng/unofield.hxx>
+#include <svx/unomod.hxx>
+#include <svx/unomodel.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/unoshape.hxx>
+
+//-////////////////////////////////////////////////////////////////////
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star;
+
+//-////////////////////////////////////////////////////////////////////
+
+#define QUERYINT( xint ) \
+ if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
+ aAny <<= uno::Reference< xint >(this)
+
+#define ITYPE( xint ) \
+ ::getCppuType((const uno::Reference< xint >*)0)
+
+//-////////////////////////////////////////////////////////////////////
+
+#ifndef SVX_LIGHT
+
+class SvxUnoDrawPagesAccess : public ::cppu::WeakImplHelper2< ::com::sun::star::drawing::XDrawPages, ::com::sun::star::lang::XServiceInfo >
+{
+private:
+ SvxUnoDrawingModel& mrModel;
+
+public:
+ SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel ) throw();
+ virtual ~SvxUnoDrawPagesAccess() throw();
+
+ // XDrawPages
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+};
+#endif
+//-////////////////////////////////////////////////////////////////////
+
+#ifndef SVX_LIGHT
+const SvEventDescription* ImplGetSupportedMacroItems()
+{
+ static const SvEventDescription aMacroDescriptionsImpl[] =
+ {
+ { SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
+ { SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
+ { 0, NULL }
+ };
+
+ return aMacroDescriptionsImpl;
+}
+#endif
+
+//-////////////////////////////////////////////////////////////////////
+
+/** fills the given EventObject from the given SdrHint.
+ @returns
+ true if the SdrHint could be translated to an EventObject<br>
+ false if not
+*/
+sal_Bool SvxUnoDrawMSFactory::createEvent( const SdrModel* pDoc, const SdrHint* pSdrHint, ::com::sun::star::document::EventObject& aEvent )
+{
+ const SdrObject* pObj = NULL;
+ const SdrPage* pPage = NULL;
+
+ switch( pSdrHint->GetKind() )
+ {
+// case HINT_LAYERCHG: // Layerdefinition geaendert
+// case HINT_LAYERORDERCHG: // Layerreihenfolge geaendert (Insert/Remove/ChangePos)
+// case HINT_LAYERSETCHG: // Layerset geaendert
+// case HINT_LAYERSETORDERCHG: // Layersetreihenfolge geaendert (Insert/Remove/ChangePos)
+
+// #115423#
+// case HINT_PAGECHG: // Page geaendert
+// aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageModified" ) );
+// pPage = pSdrHint->GetPage();
+// break;
+ case HINT_PAGEORDERCHG: // Reihenfolge der Seiten (Zeichenseiten oder Masterpages) geaendert (Insert/Remove/ChangePos)
+ aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageOrderModified" ) );
+ pPage = pSdrHint->GetPage();
+ break;
+ case HINT_OBJCHG: // Objekt geaendert
+ aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeModified" ) );
+ pObj = pSdrHint->GetObject();
+ break;
+ case HINT_OBJINSERTED: // Neues Zeichenobjekt eingefuegt
+ aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeInserted" ) );
+ pObj = pSdrHint->GetObject();
+ break;
+ case HINT_OBJREMOVED: // Zeichenobjekt aus Liste entfernt
+ aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeRemoved" ) );
+ pObj = pSdrHint->GetObject();
+ break;
+// HINT_DEFAULTTABCHG, // Default Tabulatorweite geaendert
+// HINT_DEFFONTHGTCHG, // Default FontHeight geaendert
+// HINT_SWITCHTOPAGE, // #94278# UNDO/REDO at an object evtl. on another page
+// HINT_OBJLISTCLEAR // Is called before an SdrObjList will be cleared
+ default:
+ return sal_False;
+ }
+
+ if( pObj )
+ aEvent.Source = const_cast<SdrObject*>(pObj)->getUnoShape();
+ else if( pPage )
+ aEvent.Source = const_cast<SdrPage*>(pPage)->getUnoPage();
+ else
+ aEvent.Source = (const_cast<SdrModel*>(pDoc))->getUnoModel();
+
+ return sal_True;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstance( const OUString& rServiceSpecifier )
+ throw( uno::Exception, uno::RuntimeException )
+{
+ const OUString aDrawingPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.") );
+
+ if( rServiceSpecifier.compareTo( aDrawingPrefix, aDrawingPrefix.getLength() ) == 0 )
+ {
+ sal_uInt32 nType = UHashMap::getId( rServiceSpecifier );
+ if( nType != UHASHMAP_NOTFOUND )
+ {
+ UINT16 nT = (UINT16)(nType & ~E3D_INVENTOR_FLAG);
+ UINT32 nI = (nType & E3D_INVENTOR_FLAG)?E3dInventor:SdrInventor;
+
+ return uno::Reference< uno::XInterface >( (drawing::XShape*) SvxDrawPage::CreateShapeByTypeAndInventor( nT, nI ) );
+ }
+ }
+
+ uno::Reference< uno::XInterface > xRet( createTextField( rServiceSpecifier ) );
+ if( !xRet.is() )
+ throw lang::ServiceNotRegisteredException();
+
+ return xRet;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createTextField( const ::rtl::OUString& ServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+{
+ return SvxUnoTextCreateTextField( ServiceSpecifier );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstanceWithArguments( const OUString&, const uno::Sequence< ::com::sun::star::uno::Any >& )
+ throw( uno::Exception, uno::RuntimeException )
+{
+ throw lang::NoSupportException();
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoDrawMSFactory::getAvailableServiceNames()
+ throw( uno::RuntimeException )
+{
+ return UHashMap::getServiceNames();
+}
+
+uno::Sequence< OUString > SvxUnoDrawMSFactory::concatServiceNames( uno::Sequence< OUString >& rServices1, uno::Sequence< OUString >& rServices2 ) throw()
+{
+ const sal_Int32 nLen1 = rServices1.getLength();
+ const sal_Int32 nLen2 = rServices2.getLength();
+
+ uno::Sequence< OUString > aSeq( nLen1+nLen2 );
+ OUString* pStrings = aSeq.getArray();
+
+ sal_Int32 nIdx;
+ OUString* pStringDst = pStrings;
+ const OUString* pStringSrc = rServices1.getArray();
+
+ for( nIdx = 0; nIdx < nLen1; nIdx++ )
+ *pStringDst++ = *pStringSrc++;
+
+ pStringSrc = rServices2.getArray();
+
+ for( nIdx = 0; nIdx < nLen2; nIdx++ )
+ *pStringDst++ = *pStringSrc++;
+
+ return aSeq;
+}
+
+
+#ifndef SVX_LIGHT
+
+///
+SvxUnoDrawingModel::SvxUnoDrawingModel( SdrModel* pDoc ) throw()
+: mpDoc( pDoc )
+{
+}
+
+SvxUnoDrawingModel::~SvxUnoDrawingModel() throw()
+{
+}
+
+uno::Any SAL_CALL SvxUnoDrawingModel::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
+{
+ uno::Any aAny;
+
+ QUERYINT(lang::XServiceInfo);
+ else QUERYINT(lang::XMultiServiceFactory);
+ else QUERYINT(drawing::XDrawPagesSupplier);
+ else QUERYINT(com::sun::star::ucb::XAnyCompareFactory);
+ else
+ return SfxBaseModel::queryInterface( rType );
+
+ return aAny;
+}
+
+void SAL_CALL SvxUnoDrawingModel::acquire() throw ( )
+{
+ SfxBaseModel::acquire();
+}
+
+void SAL_CALL SvxUnoDrawingModel::release() throw ( )
+{
+ SfxBaseModel::release();
+}
+
+// XTypeProvider
+uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawingModel::getTypes( ) throw(uno::RuntimeException)
+{
+ if( maTypeSequence.getLength() == 0 )
+ {
+ const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() );
+ const sal_Int32 nBaseTypes = aBaseTypes.getLength();
+ const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
+
+ const sal_Int32 nOwnTypes = 4; // !DANGER! Keep this updated!
+
+ maTypeSequence.realloc( nBaseTypes + nOwnTypes );
+ uno::Type* pTypes = maTypeSequence.getArray();
+
+ *pTypes++ = ITYPE(lang::XServiceInfo);
+ *pTypes++ = ITYPE(lang::XMultiServiceFactory);
+ *pTypes++ = ITYPE(drawing::XDrawPagesSupplier);
+ *pTypes++ = ITYPE(com::sun::star::ucb::XAnyCompareFactory);
+
+ for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
+ *pTypes++ = *pBaseTypes++;
+ }
+
+ return maTypeSequence;
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL SvxUnoDrawingModel::getImplementationId( ) throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+void SAL_CALL SvxUnoDrawingModel::lockControllers( )
+ throw(uno::RuntimeException)
+{
+ if( mpDoc )
+ mpDoc->setLock( sal_True );
+}
+
+void SAL_CALL SvxUnoDrawingModel::unlockControllers( )
+ throw(uno::RuntimeException)
+{
+ if( mpDoc && mpDoc->isLocked() )
+ {
+ mpDoc->setLock( sal_False );
+ }
+}
+
+sal_Bool SAL_CALL SvxUnoDrawingModel::hasControllersLocked( )
+ throw(uno::RuntimeException)
+{
+ return mpDoc && mpDoc->isLocked();
+}
+
+// XDrawPagesSupplier
+uno::Reference< drawing::XDrawPages > SAL_CALL SvxUnoDrawingModel::getDrawPages()
+ throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ uno::Reference< drawing::XDrawPages > xDrawPages( mxDrawPagesAccess );
+
+ if( !xDrawPages.is() )
+ mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SvxUnoDrawPagesAccess(*this);
+
+ return xDrawPages;
+}
+
+// XMultiServiceFactory ( SvxFmMSFactory )
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawingModel::createInstance( const OUString& aServiceSpecifier )
+ throw(uno::Exception, uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) )
+ {
+ if( !mxDashTable.is() )
+ mxDashTable = SvxUnoDashTable_createInstance( mpDoc );
+ return mxDashTable;
+ }
+ if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) )
+ {
+ if( !mxGradientTable.is() )
+ mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc );
+ return mxGradientTable;
+ }
+ if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) )
+ {
+ if( !mxHatchTable.is() )
+ mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc );
+ return mxHatchTable;
+ }
+ if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) )
+ {
+ if( !mxBitmapTable.is() )
+ mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc );
+ return mxBitmapTable;
+ }
+ if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) )
+ {
+ if( !mxTransGradientTable.is() )
+ mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc );
+ return mxTransGradientTable;
+ }
+ if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
+ {
+ if( !mxMarkerTable.is() )
+ mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc );
+ return mxMarkerTable;
+ }
+ if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.NumberingRules" ) ) )
+ {
+ return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY );
+ }
+
+ if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapRectangleObject") ) )
+ {
+ return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() );
+ }
+
+ if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapCircleObject") ) )
+ {
+ return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() );
+ }
+
+ if( aServiceSpecifier.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.image.ImageMapPolygonObject") ) )
+ {
+ return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() );
+ }
+
+ if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextField.DateTime") ) )
+ {
+ return (::cppu::OWeakObject * )new SvxUnoTextField( ID_EXT_DATEFIELD );
+ }
+
+ uno::Reference< uno::XInterface > xRet;
+
+ const String aType( aServiceSpecifier );
+ if( aType.EqualsAscii( "com.sun.star.presentation.", 0, 26 ) )
+ {
+ SvxShape* pShape = NULL;
+
+ sal_uInt16 nType = OBJ_TEXT;
+ // create a shape wrapper
+ if( aType.EqualsAscii( "TitleTextShape", 26, 14 ) )
+ {
+ nType = OBJ_TEXT;
+ }
+ else if( aType.EqualsAscii( "OutlinerShape", 26, 13 ) )
+ {
+ nType = OBJ_TEXT;
+ }
+ else if( aType.EqualsAscii( "SubtitleShape", 26, 13 ) )
+ {
+ nType = OBJ_TEXT;
+ }
+ else if( aType.EqualsAscii( "GraphicObjectShape", 26, 18 ) )
+ {
+ nType = OBJ_GRAF;
+ }
+ else if( aType.EqualsAscii( "PageShape", 26, 9 ) )
+ {
+ nType = OBJ_PAGE;
+ }
+ else if( aType.EqualsAscii( "OLE2Shape", 26, 9 ) )
+ {
+ nType = OBJ_OLE2;
+ }
+ else if( aType.EqualsAscii( "ChartShape", 26, 10 ) )
+ {
+ nType = OBJ_OLE2;
+ }
+ else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
+ {
+ nType = OBJ_OLE2;
+ }
+ else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) )
+ {
+ nType = OBJ_OLE2;
+ }
+ else if( aType.EqualsAscii( "NotesShape", 26, 10 ) )
+ {
+ nType = OBJ_TEXT;
+ }
+ else if( aType.EqualsAscii( "HandoutShape", 26, 12 ) )
+ {
+ nType = OBJ_PAGE;
+ }
+ else if( aType.EqualsAscii( "FooterShape", 26, 12 ) )
+ {
+ nType = OBJ_TEXT;
+ }
+ else if( aType.EqualsAscii( "HeaderShape", 26, 12 ) )
+ {
+ nType = OBJ_TEXT;
+ }
+ else if( aType.EqualsAscii( "SlideNumberShape", 26, 17 ) )
+ {
+ nType = OBJ_TEXT;
+ }
+ else if( aType.EqualsAscii( "DateTimeShape", 26, 17 ) )
+ {
+ nType = OBJ_TEXT;
+ }
+ else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
+ {
+ nType = OBJ_TABLE;
+ }
+ else
+ {
+ throw lang::ServiceNotRegisteredException();
+ }
+
+ // create the API wrapper
+ pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor );
+
+ // set shape type
+ if( pShape )
+ pShape->SetShapeType(aServiceSpecifier);
+
+ xRet = (uno::XWeak*)pShape;
+ }
+ else
+ {
+ xRet = SvxFmMSFactory::createInstance( aServiceSpecifier );
+ }
+
+ return xRet;
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getAvailableServiceNames()
+ throw(uno::RuntimeException)
+{
+ const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() );
+
+ uno::Sequence< OUString > aSNS( 21 );
+
+ sal_uInt16 i = 0;
+
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.NumberingRules"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapRectangleObject"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapCircleObject"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapPolygonObject"));
+
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SubtitleShape"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.GraphicObjectShape"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.ChartShape"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OLE2Shape"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TableShape"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OrgChartShape"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesShape"));
+ aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutShape"));
+
+ DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" );
+
+ return comphelper::concatSequences( aSNS_ORG, aSNS );
+}
+
+// lang::XServiceInfo
+OUString SAL_CALL SvxUnoDrawingModel::getImplementationName()
+ throw(uno::RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDrawingModel"));
+}
+
+sal_Bool SAL_CALL SvxUnoDrawingModel::supportsService( const OUString& ServiceName )
+ throw(uno::RuntimeException)
+{
+ return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getSupportedServiceNames() throw(uno::RuntimeException)
+{
+ OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument"));
+ uno::Sequence< OUString > aSeq( &aSN, 1 );
+ return aSeq;
+}
+
+// XAnyCompareFactory
+uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SvxUnoDrawingModel::createAnyCompareByName( const OUString& )
+ throw(uno::RuntimeException)
+{
+ return SvxCreateNumRuleCompare();
+}
+
+//=============================================================================
+// class SvxUnoDrawPagesAccess
+//=============================================================================
+
+SvxUnoDrawPagesAccess::SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel ) throw()
+: mrModel(rMyModel)
+{
+}
+
+SvxUnoDrawPagesAccess::~SvxUnoDrawPagesAccess() throw()
+{
+}
+
+// XIndexAccess
+sal_Int32 SAL_CALL SvxUnoDrawPagesAccess::getCount()
+ throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ sal_Int32 nCount = 0;
+
+ if( mrModel.mpDoc )
+ nCount = mrModel.mpDoc->GetPageCount();
+
+ return( nCount );
+}
+
+uno::Any SAL_CALL SvxUnoDrawPagesAccess::getByIndex( sal_Int32 Index )
+ throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ uno::Any aAny;
+
+ if( mrModel.mpDoc )
+ {
+ if( (Index < 0) || (Index >= mrModel.mpDoc->GetPageCount() ) )
+ throw lang::IndexOutOfBoundsException();
+
+ SdrPage* pPage = mrModel.mpDoc->GetPage( (sal_uInt16)Index );
+ if( pPage )
+ {
+ uno::Reference< uno::XInterface > xPage( pPage->mxUnoPage );
+
+ if( !xPage.is() )
+ {
+ if( PTR_CAST( FmFormModel, mrModel.mpDoc ) )
+ xPage = (drawing::XDrawPage*)new SvxFmDrawPage( pPage );
+ else
+ xPage = (drawing::XDrawPage*)new SvxDrawPage( pPage );
+
+ pPage->mxUnoPage = xPage;
+ }
+
+ aAny <<= xPage;
+ }
+ }
+ return aAny;
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoDrawPagesAccess::getElementType()
+ throw(uno::RuntimeException)
+{
+ return ITYPE( drawing::XDrawPage );
+}
+
+sal_Bool SAL_CALL SvxUnoDrawPagesAccess::hasElements()
+ throw(uno::RuntimeException)
+{
+ return getCount() > 0;
+}
+
+// XDrawPages
+
+/******************************************************************************
+* Erzeugt eine neue Seite mit Model an der angegebennen Position und gibt die *
+* dazugehoerige SdDrawPage zurueck. *
+******************************************************************************/
+uno::Reference< drawing::XDrawPage > SAL_CALL SvxUnoDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex )
+ throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ uno::Reference< drawing::XDrawPage > xDrawPage;
+
+ if( mrModel.mpDoc )
+ {
+ SdrPage* pPage;
+
+ if( PTR_CAST( FmFormModel, mrModel.mpDoc ) )
+ pPage = new FmFormPage(*(FmFormModel*)mrModel.mpDoc, NULL);
+ else
+ pPage = new SdrPage(*mrModel.mpDoc);
+
+ mrModel.mpDoc->InsertPage( pPage, (sal_uInt16)nIndex );
+ xDrawPage = uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() );
+ }
+
+ return xDrawPage;
+}
+
+void SAL_CALL SvxUnoDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
+ throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ sal_uInt16 nPageCount = mrModel.mpDoc->GetPageCount();
+ if( nPageCount > 1 )
+ {
+ // pPage von xPage besorgen und dann die Id (nPos )ermitteln
+ SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage );
+ if( pSvxPage )
+ {
+ SdrPage* pPage = pSvxPage->GetSdrPage();
+ if(pPage)
+ {
+ sal_uInt16 nPage = pPage->GetPageNum();
+ mrModel.mpDoc->DeletePage( nPage );
+ }
+ }
+ }
+}
+
+// XServiceInfo
+sal_Char pSvxUnoDrawPagesAccessService[sizeof("com.sun.star.drawing.DrawPages")] = "com.sun.star.drawing.DrawPages";
+
+OUString SAL_CALL SvxUnoDrawPagesAccess::getImplementationName( ) throw(uno::RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoDrawPagesAccess" ) );
+}
+
+sal_Bool SAL_CALL SvxUnoDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( pSvxUnoDrawPagesAccessService ) );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoDrawPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException)
+{
+ OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoDrawPagesAccessService ) );
+ uno::Sequence< OUString > aSeq( &aService, 1 );
+ return aSeq;
+}
+#include <editeng/unonrule.hxx>
+com::sun::star::uno::Reference< com::sun::star::container::XIndexReplace > SvxCreateNumRule( SdrModel* pModel ) throw()
+{
+ SvxNumRule* pDefaultRule = NULL;
+ if( pModel )
+ {
+ SvxNumBulletItem* pItem = (SvxNumBulletItem*) pModel->GetItemPool().GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET);
+ if( pItem )
+ {
+ pDefaultRule = pItem->GetNumRule();
+ }
+ }
+
+ if( pDefaultRule )
+ {
+ return SvxCreateNumRule( pDefaultRule );
+ }
+ else
+ {
+ SvxNumRule aTempRule( 0, 10, false );
+ return SvxCreateNumRule( &aTempRule );
+ }
+}
+
+///////////////////////////////////////////////////////////////////////
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unomtabl.cxx b/svx/source/unodraw/unomtabl.cxx
new file mode 100644
index 000000000000..4f161ece7889
--- /dev/null
+++ b/svx/source/unodraw/unomtabl.cxx
@@ -0,0 +1,483 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <set>
+#include <comphelper/stl_types.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/drawing/PointSequence.hpp>
+#include <svl/style.hxx>
+
+#include <cppuhelper/implbase2.hxx>
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
+#include <svl/lstner.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/xdef.hxx>
+#include <svx/xflhtit.hxx>
+
+#include <vector>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+
+#include "unofill.hxx"
+
+#include "unoapi.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+using namespace ::cppu;
+
+typedef std::vector< SfxItemSet* > ItemPoolVector;
+
+class SvxUnoMarkerTable : public WeakImplHelper2< container::XNameContainer, lang::XServiceInfo >,
+ public SfxListener
+{
+private:
+ SdrModel* mpModel;
+ SfxItemPool* mpModelPool;
+
+ ItemPoolVector maItemSetVector;
+
+public:
+ SvxUnoMarkerTable( SdrModel* pModel ) throw();
+ virtual ~SvxUnoMarkerTable() throw();
+
+ void dispose();
+
+ // SfxListener
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw ();
+
+ void SAL_CALL ImplInsertByName( const OUString& aName, const uno::Any& aElement );
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw( uno::RuntimeException);
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+
+ // XNameContainer
+ virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual void SAL_CALL removeByName( const OUString& Name ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XNameAccess
+ virtual uno::Any SAL_CALL getByName( const OUString& aName ) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) throw( uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw( uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( ) throw( uno::RuntimeException);
+};
+
+SvxUnoMarkerTable::SvxUnoMarkerTable( SdrModel* pModel ) throw()
+: mpModel( pModel ),
+ mpModelPool( pModel ? &pModel->GetItemPool() : (SfxItemPool*)NULL )
+{
+ if( pModel )
+ StartListening( *pModel );
+}
+
+SvxUnoMarkerTable::~SvxUnoMarkerTable() throw()
+{
+ if( mpModel )
+ EndListening( *mpModel );
+ dispose();
+}
+
+void SvxUnoMarkerTable::dispose()
+{
+ ItemPoolVector::iterator aIter = maItemSetVector.begin();
+ const ItemPoolVector::iterator aEnd = maItemSetVector.end();
+
+ while( aIter != aEnd )
+ {
+ delete (*aIter++);
+ }
+
+ maItemSetVector.clear();
+}
+
+// SfxListener
+void SvxUnoMarkerTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
+{
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+
+ if( pSdrHint && HINT_MODELCLEARED == pSdrHint->GetKind() )
+ dispose();
+}
+
+sal_Bool SAL_CALL SvxUnoMarkerTable::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
+{
+ uno::Sequence< OUString > aSNL( getSupportedServiceNames() );
+ const OUString * pArray = aSNL.getConstArray();
+
+ for( INT32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return TRUE;
+
+ return FALSE;
+}
+
+OUString SAL_CALL SvxUnoMarkerTable::getImplementationName() throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoMarkerTable") );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getSupportedServiceNames( )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable" ));
+ return aSNS;
+}
+
+void SAL_CALL SvxUnoMarkerTable::ImplInsertByName( const OUString& aName, const uno::Any& aElement )
+{
+ SfxItemSet* mpInSet = new SfxItemSet( *mpModelPool, XATTR_LINESTART, XATTR_LINEEND );
+ maItemSetVector.push_back( mpInSet );
+
+ XLineEndItem aEndMarker;
+ aEndMarker.SetName( String( aName ) );
+ aEndMarker.PutValue( aElement );
+
+ mpInSet->Put( aEndMarker, XATTR_LINEEND );
+
+ XLineStartItem aStartMarker;
+ aStartMarker.SetName( String( aName ) );
+ aStartMarker.PutValue( aElement );
+
+ mpInSet->Put( aStartMarker, XATTR_LINESTART );
+}
+
+// XNameContainer
+void SAL_CALL SvxUnoMarkerTable::insertByName( const OUString& aApiName, const uno::Any& aElement )
+ throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if( hasByName( aApiName ) )
+ throw container::ElementExistException();
+
+ String aName;
+ SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName );
+
+ ImplInsertByName( aName, aElement );
+}
+
+void SAL_CALL SvxUnoMarkerTable::removeByName( const OUString& aApiName )
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // a little quickfix for 2.0 to let applications clear api
+ // created items that are not used
+ if( aApiName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("~clear~") ) )
+ {
+ dispose();
+ return;
+ }
+
+ String Name;
+ SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, Name );
+
+ ItemPoolVector::iterator aIter = maItemSetVector.begin();
+ const ItemPoolVector::iterator aEnd = maItemSetVector.end();
+
+ NameOrIndex *pItem;
+ const String aSearchName( Name );
+
+ while( aIter != aEnd )
+ {
+ pItem = (NameOrIndex *)&((*aIter)->Get( XATTR_LINEEND ) );
+ if( pItem->GetName() == aSearchName )
+ {
+ delete (*aIter);
+ maItemSetVector.erase( aIter );
+ return;
+ }
+ aIter++;
+ }
+
+ if( !hasByName( Name ) )
+ throw container::NoSuchElementException();
+}
+
+// XNameReplace
+void SAL_CALL SvxUnoMarkerTable::replaceByName( const OUString& aApiName, const uno::Any& aElement )
+ throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ String aName;
+ SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName );
+
+ ItemPoolVector::iterator aIter = maItemSetVector.begin();
+ const ItemPoolVector::iterator aEnd = maItemSetVector.end();
+
+ NameOrIndex *pItem;
+ const String aSearchName( aName );
+
+ while( aIter != aEnd )
+ {
+ pItem = (NameOrIndex *)&((*aIter)->Get( XATTR_LINEEND ) );
+ if( pItem->GetName() == aSearchName )
+ {
+ XLineEndItem aEndMarker;
+ aEndMarker.SetName( aSearchName );
+ if( !aEndMarker.PutValue( aElement ) )
+ throw lang::IllegalArgumentException();
+
+ (*aIter)->Put( aEndMarker, XATTR_LINEEND );
+
+ XLineStartItem aStartMarker;
+ aStartMarker.SetName( aSearchName );
+ aStartMarker.PutValue( aElement );
+
+ (*aIter)->Put( aStartMarker, XATTR_LINESTART );
+ return;
+ }
+ aIter++;
+ }
+
+ // if it is not in our own sets, modify the pool!
+ sal_Bool bFound = sal_False;
+
+ USHORT nSurrogate;
+ const USHORT nStartCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINESTART ) : 0;
+ for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINESTART, nSurrogate);
+ if( pItem && pItem->GetName() == aSearchName )
+ {
+ pItem->PutValue( aElement );
+ bFound = sal_True;
+ break;
+ }
+ }
+
+ const USHORT nEndCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINEEND ) : 0;
+ for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINEEND, nSurrogate);
+ if( pItem && pItem->GetName() == aSearchName )
+ {
+ pItem->PutValue( aElement );
+ bFound = sal_True;
+ break;
+ }
+ }
+
+ if( bFound )
+ ImplInsertByName( aName, aElement );
+ else
+ throw container::NoSuchElementException();
+}
+
+static sal_Bool getByNameFromPool( const String& rSearchName, SfxItemPool* pPool, USHORT nWhich, uno::Any& rAny )
+{
+ NameOrIndex *pItem;
+ const sal_Int32 nSurrogateCount = pPool ? (sal_Int32)pPool->GetItemCount( nWhich ) : 0;
+ for( sal_Int32 nSurrogate = 0; nSurrogate < nSurrogateCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)pPool->GetItem( nWhich, (USHORT)nSurrogate );
+
+ if( pItem && pItem->GetName() == rSearchName )
+ {
+ pItem->QueryValue( rAny, 0 );
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+// XNameAccess
+uno::Any SAL_CALL SvxUnoMarkerTable::getByName( const OUString& aApiName )
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ String aName;
+ SvxUnogetInternalNameForItem( XATTR_LINEEND, aApiName, aName );
+
+ uno::Any aAny;
+
+ if( mpModelPool && aName.Len() != 0 )
+ {
+ do
+ {
+ const String aSearchName( aName );
+ if( getByNameFromPool( aSearchName, mpModelPool, XATTR_LINESTART, aAny ) )
+ break;
+
+ if( getByNameFromPool( aSearchName, mpModelPool, XATTR_LINEEND, aAny ) )
+ break;
+
+ throw container::NoSuchElementException();
+ }
+ while(0);
+ }
+
+ return aAny;
+}
+
+static void createNamesForPool( SfxItemPool* pPool, USHORT nWhich, std::set< OUString, comphelper::UStringLess >& rNameSet )
+{
+ const sal_Int32 nSuroCount = pPool->GetItemCount( nWhich );
+ sal_Int32 nSurrogate;
+
+ NameOrIndex *pItem;
+ OUString aName;
+
+ for( nSurrogate = 0; nSurrogate < nSuroCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)pPool->GetItem( nWhich, (USHORT)nSurrogate );
+
+ if( pItem == NULL || pItem->GetName().Len() == 0 )
+ continue;
+
+ SvxUnogetApiNameForItem( XATTR_LINEEND, pItem->GetName(), aName );
+ rNameSet.insert( aName );
+ }
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoMarkerTable::getElementNames()
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ std::set< OUString, comphelper::UStringLess > aNameSet;
+
+ // search model pool for line starts
+ createNamesForPool( mpModelPool, XATTR_LINESTART, aNameSet );
+
+ // search model pool for line ends
+ createNamesForPool( mpModelPool, XATTR_LINEEND, aNameSet );
+
+ uno::Sequence< OUString > aSeq( aNameSet.size() );
+ OUString* pNames = aSeq.getArray();
+
+ std::set< OUString, comphelper::UStringLess >::iterator aIter( aNameSet.begin() );
+ const std::set< OUString, comphelper::UStringLess >::iterator aEnd( aNameSet.end() );
+
+ while( aIter != aEnd )
+ {
+ *pNames++ = *aIter++;
+ }
+
+ return aSeq;
+}
+
+sal_Bool SAL_CALL SvxUnoMarkerTable::hasByName( const OUString& aName )
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if( aName.getLength() == 0 )
+ return sal_False;
+
+ String aSearchName;
+
+ NameOrIndex *pItem;
+
+ SvxUnogetInternalNameForItem( XATTR_LINESTART, aName, aSearchName );
+ USHORT nStartCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINESTART ) : 0;
+ USHORT nSurrogate;
+ for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINESTART, nSurrogate);
+ if( pItem && pItem->GetName() == aSearchName )
+ return sal_True;
+ }
+
+ SvxUnogetInternalNameForItem( XATTR_LINEEND, aName, aSearchName );
+ USHORT nEndCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINEEND ) : 0;
+ for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINEEND, nSurrogate);
+ if( pItem && pItem->GetName() == aSearchName )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoMarkerTable::getElementType( )
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const drawing::PointSequence*)0);
+}
+
+sal_Bool SAL_CALL SvxUnoMarkerTable::hasElements( )
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ NameOrIndex *pItem;
+
+ const USHORT nStartCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINESTART ) : 0;
+ USHORT nSurrogate;
+ for( nSurrogate = 0; nSurrogate < nStartCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINESTART, nSurrogate);
+ if( pItem && pItem->GetName().Len() != 0 )
+ return sal_True;
+ }
+
+ const USHORT nEndCount = mpModelPool ? mpModelPool->GetItemCount( XATTR_LINEEND ) : 0;
+ for( nSurrogate = 0; nSurrogate < nEndCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)mpModelPool->GetItem( XATTR_LINEEND, nSurrogate);
+ if( pItem && pItem->GetName().Len() != 0 )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+/**
+ * Create a hatchtable
+ */
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoMarkerTable_createInstance( SdrModel* pModel )
+{
+ return *new SvxUnoMarkerTable(pModel);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx
new file mode 100644
index 000000000000..2aba85ef508d
--- /dev/null
+++ b/svx/source/unodraw/unopage.cxx
@@ -0,0 +1,1009 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define _SVX_USE_UNOGLOBALS_
+#include <com/sun/star/document/EventObject.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <osl/mutex.hxx>
+#include <osl/mutex.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sot/clsids.hxx>
+#include <comphelper/serviceinfohelper.hxx>
+
+#include <rtl/uuid.h>
+#include <rtl/memory.h>
+#include <sfx2/objsh.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/unopage.hxx>
+#include "shapeimpl.hxx"
+#include "globl3d.hxx"
+#include <svx/polysc3d.hxx>
+#include <svx/unoprov.hxx>
+#include <svx/svdopath.hxx>
+#include "unoapi.hxx"
+#include <svx/svdomeas.hxx>
+#include <svx/extrud3d.hxx>
+#include <svx/lathe3d.hxx>
+#include <vcl/svapp.hxx>
+
+using ::rtl::OUString;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::drawing;
+
+#define INTERFACE_TYPE( xint ) \
+ ::getCppuType((const Reference< xint >*)0)
+
+#define QUERYINT( xint ) \
+ if( rType == ::getCppuType((const Reference< xint >*)0) ) \
+ aAny <<= Reference< xint >(this)
+
+DECLARE_LIST( SvxDrawPageList, SvxDrawPage * )
+
+
+/**********************************************************************
+* class SvxDrawPage *
+**********************************************************************/
+
+UNO3_GETIMPLEMENTATION_IMPL( SvxDrawPage );
+DBG_NAME(SvxDrawPage)
+SvxDrawPage::SvxDrawPage( SdrPage* pInPage ) throw()
+: mrBHelper( getMutex() )
+, mpPage( pInPage )
+, mpModel( 0 )
+{
+ DBG_CTOR(SvxDrawPage,NULL);
+ // Am Broadcaster anmelden
+ if( mpPage )
+ mpModel = mpPage->GetModel();
+ if( mpModel )
+ StartListening( *mpModel );
+
+
+ // Erzeugen der (hidden) ::com::sun::star::sdbcx::View
+ mpView = new SdrView( mpModel );
+ if( mpView )
+ mpView->SetDesignMode(sal_True);
+}
+
+//----------------------------------------------------------------------
+// Ctor fuer SvxDrawPage_NewInstance()
+//----------------------------------------------------------------------
+SvxDrawPage::SvxDrawPage() throw()
+: mrBHelper( getMutex() )
+, mpPage( NULL )
+, mpModel( NULL )
+, mpView( NULL )
+{
+ DBG_CTOR(SvxDrawPage,NULL);
+}
+
+//----------------------------------------------------------------------
+SvxDrawPage::~SvxDrawPage() throw()
+{
+ DBG_ASSERT( mrBHelper.bDisposed, "SvxDrawPage must be disposed!" );
+ if( !mrBHelper.bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+ DBG_DTOR(SvxDrawPage,NULL);
+}
+
+//----------------------------------------------------------------------
+
+// XInterface
+void SvxDrawPage::release() throw()
+{
+/*
+ uno::Reference< uno::XInterface > x( xDelegator );
+ if (! x.is())
+ {
+ if (osl_decrementInterlockedCount( &m_refCount ) == 0)
+ {
+ if (! mrBHelper.bDisposed)
+ {
+ uno::Reference< uno::XInterface > xHoldAlive( (uno::XWeak*)this );
+ // First dispose
+ try
+ {
+ dispose();
+ }
+ catch(::com::sun::star::uno::Exception&)
+ {
+ // release should not throw exceptions
+ }
+
+ // only the alive ref holds the object
+ OSL_ASSERT( m_refCount == 1 );
+ // destroy the object if xHoldAlive decrement the refcount to 0
+ return;
+ }
+ }
+ // restore the reference count
+ osl_incrementInterlockedCount( &m_refCount );
+ }
+*/
+ OWeakAggObject::release();
+}
+
+//----------------------------------------------------------------------
+
+SvxDrawPage* SvxDrawPage::GetPageForSdrPage( SdrPage* mpPage ) throw()
+{
+ return getImplementation( mpPage->getUnoPage() );
+}
+
+// XComponent
+void SvxDrawPage::disposing() throw()
+{
+ if( mpModel )
+ {
+ EndListening( *mpModel );
+ mpModel = NULL;
+ }
+
+ if( mpView )
+ {
+ delete mpView;
+ mpView = NULL;
+ }
+ mpPage = 0;
+}
+
+//----------------------------------------------------------------------
+// XComponent
+//----------------------------------------------------------------------
+
+void SvxDrawPage::dispose()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aSolarGuard;
+
+ // An frequently programming error is to release the last
+ // reference to this object in the disposing message.
+ // Make it rubust, hold a self Reference.
+ uno::Reference< lang::XComponent > xSelf( this );
+
+ // Guard dispose against multible threading
+ // Remark: It is an error to call dispose more than once
+ sal_Bool bDoDispose = sal_False;
+ {
+ osl::MutexGuard aGuard( mrBHelper.rMutex );
+ if( !mrBHelper.bDisposed && !mrBHelper.bInDispose )
+ {
+ // only one call go into this section
+ mrBHelper.bInDispose = sal_True;
+ bDoDispose = sal_True;
+ }
+ }
+
+ // Do not hold the mutex because we are broadcasting
+ if( bDoDispose )
+ {
+ // Create an event with this as sender
+ try
+ {
+ uno::Reference< uno::XInterface > xSource( uno::Reference< uno::XInterface >::query( (lang::XComponent *)this ) );
+ ::com::sun::star::document::EventObject aEvt;
+ aEvt.Source = xSource;
+ // inform all listeners to release this object
+ // The listener container are automaticly cleared
+ mrBHelper.aLC.disposeAndClear( aEvt );
+ // notify subclasses to do their dispose
+ disposing();
+ }
+ catch(::com::sun::star::uno::Exception& e)
+ {
+ // catch exception and throw again but signal that
+ // the object was disposed. Dispose should be called
+ // only once.
+ mrBHelper.bDisposed = sal_True;
+ mrBHelper.bInDispose = sal_False;
+ throw e;
+ }
+
+ // the values bDispose and bInDisposing must set in this order.
+ // No multithread call overcome the "!rBHelper.bDisposed && !rBHelper.bInDispose" guard.
+ mrBHelper.bDisposed = sal_True;
+ mrBHelper.bInDispose = sal_False;
+ }
+
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxDrawPage::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( mpModel == 0 )
+ throw lang::DisposedException();
+
+ mrBHelper.addListener( ::getCppuType( &aListener ) , aListener );
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxDrawPage::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( mpModel == 0 )
+ throw lang::DisposedException();
+
+ mrBHelper.removeListener( ::getCppuType( &aListener ) , aListener );
+}
+
+//----------------------------------------------------------------------
+// SfxListener
+//----------------------------------------------------------------------
+
+void SvxDrawPage::Notify( SfxBroadcaster&, const SfxHint& /*rHint*/ )
+{
+/*
+ if( mpModel )
+ {
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+ if( pSdrHint )
+ {
+ switch( pSdrHint->GetKind() )
+ {
+ case HINT_MODELCLEARED:
+ dispose();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+*/
+}
+
+//----------------------------------------------------------------------
+// ::com::sun::star::drawing::XShapes
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape )
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if( (mpModel == 0) || (mpPage == 0) )
+ throw lang::DisposedException();
+
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+
+ if( NULL == pShape )
+ return;
+
+ SdrObject *pObj = pShape->GetSdrObject();
+
+ if(!pObj)
+ {
+ pObj = CreateSdrObject( xShape );
+ }
+ else if ( !pObj->IsInserted() )
+ {
+ pObj->SetModel(mpModel);
+ mpPage->InsertObject( pObj );
+ }
+
+ if(pObj == NULL)
+ return;
+
+ pShape->Create( pObj, this );
+
+ if( mpModel )
+ mpModel->SetChanged();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxDrawPage::remove( const Reference< drawing::XShape >& xShape )
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if( (mpModel == 0) || (mpPage == 0) )
+ throw lang::DisposedException();
+
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+
+ if(pShape)
+ {
+ SdrObject* pObj = pShape->GetSdrObject();
+ if(pObj)
+ {
+ // SdrObject aus der Page loeschen
+ sal_uInt32 nCount = mpPage->GetObjCount();
+ for( sal_uInt32 nNum = 0; nNum < nCount; nNum++ )
+ {
+ if(mpPage->GetObj(nNum) == pObj)
+ {
+ OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj );
+ SdrObject::Free( pObj );
+ break;
+ }
+ }
+ }
+ }
+
+ if( mpModel )
+ mpModel->SetChanged();
+}
+
+//----------------------------------------------------------------------
+// ::com::sun::star::container::XIndexAccess
+//----------------------------------------------------------------------
+
+sal_Int32 SAL_CALL SvxDrawPage::getCount()
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if( (mpModel == 0) || (mpPage == 0) )
+ throw lang::DisposedException();
+
+ return( (sal_Int32) mpPage->GetObjCount() );
+}
+
+//----------------------------------------------------------------------
+uno::Any SAL_CALL SvxDrawPage::getByIndex( sal_Int32 Index )
+ throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( (mpModel == 0) || (mpPage == 0) )
+ throw lang::DisposedException();
+
+ if ( Index < 0 || Index >= (sal_Int32)mpPage->GetObjCount() )
+ throw lang::IndexOutOfBoundsException();
+
+ SdrObject* pObj = mpPage->GetObj( Index );
+ if( pObj == NULL )
+ throw uno::RuntimeException();
+
+
+ return makeAny(Reference< drawing::XShape >( pObj->getUnoShape(), uno::UNO_QUERY ));
+}
+
+
+//----------------------------------------------------------------------
+// ::com::sun::star::container::XElementAccess
+//----------------------------------------------------------------------
+
+uno::Type SAL_CALL SvxDrawPage::getElementType()
+ throw( uno::RuntimeException )
+{
+ return INTERFACE_TYPE( drawing::XShape );
+}
+
+//----------------------------------------------------------------------
+sal_Bool SAL_CALL SvxDrawPage::hasElements()
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if( (mpModel == 0) || (mpPage == 0) )
+ throw lang::DisposedException();
+
+ return mpPage && mpPage->GetObjCount()>0;
+}
+
+namespace
+{
+ void lcl_markSdrObjectOfShape( const Reference< drawing::XShape >& _rxShape, SdrView& _rView, SdrPageView& _rPageView )
+ {
+ SvxShape* pShape = SvxShape::getImplementation( _rxShape );
+ if ( !pShape )
+ return;
+
+ SdrObject* pObj = pShape->GetSdrObject();
+ if ( !pObj )
+ return;
+
+ _rView.MarkObj( pObj, &_rPageView );
+ }
+}
+
+//----------------------------------------------------------------------
+// ACHTUNG: _SelectObjectsInView selektiert die ::com::sun::star::drawing::Shapes nur in der angegebennen
+// SdrPageView. Dies muß nicht die sichtbare SdrPageView sein.
+//----------------------------------------------------------------------
+void SvxDrawPage::_SelectObjectsInView( const Reference< drawing::XShapes > & aShapes, SdrPageView* pPageView ) throw ()
+{
+ DBG_ASSERT(pPageView,"SdrPageView ist NULL! [CL]");
+ DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
+
+ if(pPageView!=NULL && mpView!=NULL)
+ {
+ mpView->UnmarkAllObj( pPageView );
+
+ long nCount = aShapes->getCount();
+ for( long i = 0; i < nCount; i++ )
+ {
+ uno::Any aAny( aShapes->getByIndex(i) );
+ Reference< drawing::XShape > xShape;
+ if( aAny >>= xShape )
+ lcl_markSdrObjectOfShape( xShape, *mpView, *pPageView );
+ }
+ }
+}
+
+//----------------------------------------------------------------------
+// ACHTUNG: _SelectObjectInView selektiert das Shape *nur* in der angegebennen
+// SdrPageView. Dies muß nicht die sichtbare SdrPageView sein.
+//----------------------------------------------------------------------
+void SvxDrawPage::_SelectObjectInView( const Reference< drawing::XShape > & xShape, SdrPageView* pPageView ) throw()
+{
+ DBG_ASSERT(pPageView,"SdrPageView ist NULL! [CL]");
+ DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
+
+ if(pPageView!=NULL && mpView != NULL)
+ {
+ mpView->UnmarkAllObj( pPageView );
+ lcl_markSdrObjectOfShape( xShape, *mpView, *pPageView );
+ }
+}
+
+//----------------------------------------------------------------------
+Reference< drawing::XShapeGroup > SAL_CALL SvxDrawPage::group( const Reference< drawing::XShapes >& xShapes )
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if( (mpModel == 0) || (mpPage == 0) )
+ throw lang::DisposedException();
+
+ DBG_ASSERT(mpPage,"SdrPage ist NULL! [CL]");
+ DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
+
+ Reference< ::com::sun::star::drawing::XShapeGroup > xShapeGroup;
+ if(mpPage==NULL||mpView==NULL||!xShapes.is())
+ return xShapeGroup;
+
+ SdrPageView* pPageView = mpView->ShowSdrPage( mpPage );
+
+ _SelectObjectsInView( xShapes, pPageView );
+
+ mpView->GroupMarked();
+
+ mpView->AdjustMarkHdl();
+ const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if( pObj )
+ xShapeGroup = Reference< drawing::XShapeGroup >::query( pObj->getUnoShape() );
+ }
+
+ mpView->HideSdrPage();
+
+ if( mpModel )
+ mpModel->SetChanged();
+
+ return xShapeGroup;
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxDrawPage::ungroup( const Reference< drawing::XShapeGroup >& aGroup )
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if( (mpModel == 0) || (mpPage == 0) )
+ throw lang::DisposedException();
+
+ DBG_ASSERT(mpPage,"SdrPage ist NULL! [CL]");
+ DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
+
+ if(mpPage==NULL||mpView==NULL||!aGroup.is())
+ return;
+
+ SdrPageView* pPageView = mpView->ShowSdrPage( mpPage );
+
+ Reference< drawing::XShape > xShape( aGroup, UNO_QUERY );
+ _SelectObjectInView( xShape, pPageView );
+ mpView->UnGroupMarked();
+
+ mpView->HideSdrPage();
+
+ if( mpModel )
+ mpModel->SetChanged();
+}
+
+//----------------------------------------------------------------------
+SdrObject *SvxDrawPage::_CreateSdrObject( const Reference< drawing::XShape > & xShape ) throw()
+{
+ sal_uInt16 nType;
+ sal_uInt32 nInventor;
+
+ GetTypeAndInventor( nType, nInventor, xShape->getShapeType() );
+ SdrObject* pNewObj = 0;
+
+ if( nType != 0 )
+ {
+ awt::Size aSize = xShape->getSize();
+ aSize.Width += 1;
+ aSize.Height += 1;
+ awt::Point aPos = xShape->getPosition();
+ Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) );
+
+ // special cases
+ if( nInventor == SdrInventor )
+ {
+ switch( nType )
+ {
+ case OBJ_MEASURE:
+ {
+ pNewObj = new SdrMeasureObj( aRect.TopLeft(), aRect.BottomRight() );
+ break;
+ }
+ case OBJ_LINE:
+ {
+ basegfx::B2DPolygon aPoly;
+ aPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top()));
+ aPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
+ pNewObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
+ break;
+ }
+ }
+ }
+
+ if( pNewObj == NULL )
+ pNewObj = SdrObjFactory::MakeNewObject( nInventor, nType, mpPage );
+
+ if(pNewObj)
+ {
+ pNewObj->SetSnapRect(aRect);
+
+ if( pNewObj->ISA(E3dPolyScene))
+ {
+ // Szene initialisieren
+ E3dScene* pScene = (E3dScene*)pNewObj;
+
+ double fW = (double)aSize.Width;
+ double fH = (double)aSize.Height;
+
+ Camera3D aCam(pScene->GetCamera());
+ aCam.SetAutoAdjustProjection(sal_False);
+ aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
+ basegfx::B3DPoint aLookAt;
+ basegfx::B3DPoint aCamPos(0.0, 0.0, 10000.0);
+ aCam.SetPosAndLookAt(aCamPos, aLookAt);
+ aCam.SetFocalLength(100.0);
+ aCam.SetDefaults(aCamPos, aLookAt, 10000.0);
+ pScene->SetCamera(aCam);
+
+ pScene->SetRectsDirty();
+ }
+ else if(pNewObj->ISA(E3dExtrudeObj))
+ {
+ E3dExtrudeObj* pObj = (E3dExtrudeObj*)pNewObj;
+ basegfx::B2DPolygon aNewPolygon;
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
+ aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
+ aNewPolygon.setClosed(true);
+ pObj->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon));
+
+ // #107245# pObj->SetExtrudeCharacterMode(TRUE);
+ pObj->SetMergedItem(Svx3DCharacterModeItem(sal_True));
+ }
+ else if(pNewObj->ISA(E3dLatheObj))
+ {
+ E3dLatheObj* pObj = (E3dLatheObj*)pNewObj;
+ basegfx::B2DPolygon aNewPolygon;
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
+ aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
+ aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
+ aNewPolygon.setClosed(true);
+ pObj->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon));
+
+ // #107245# pObj->SetLatheCharacterMode(TRUE);
+ pObj->SetMergedItem(Svx3DCharacterModeItem(sal_True));
+ }
+ }
+ }
+
+ return pNewObj;
+}
+
+//----------------------------------------------------------------------
+void SvxDrawPage::GetTypeAndInventor( sal_uInt16& rType, sal_uInt32& rInventor, const OUString& aName ) const throw()
+{
+ sal_uInt32 nTempType = UHashMap::getId( aName );
+
+ if( nTempType == UHASHMAP_NOTFOUND )
+ {
+ if( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape")) ||
+ aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.TableShape")) )
+ {
+ rInventor = SdrInventor;
+ rType = OBJ_TABLE;
+ }
+ else if( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.MediaShape" )) )
+ {
+ rInventor = SdrInventor;
+ rType = OBJ_MEDIA;
+ }
+ }
+ else if(nTempType & E3D_INVENTOR_FLAG)
+ {
+ rInventor = E3dInventor;
+ rType = (sal_uInt16)(nTempType & ~E3D_INVENTOR_FLAG);
+ }
+ else
+ {
+ rInventor = SdrInventor;
+ rType = (sal_uInt16)nTempType;
+
+ switch( rType )
+ {
+ case OBJ_FRAME:
+ case OBJ_OLE2_PLUGIN:
+ case OBJ_OLE2_APPLET:
+ rType = OBJ_OLE2;
+ break;
+ }
+ }
+}
+
+//----------------------------------------------------------------------
+SvxShape* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor, SdrObject *pObj, SvxDrawPage *mpPage ) throw()
+{
+ SvxShape* pRet = NULL;
+ switch( nInventor )
+ {
+ case E3dInventor:
+ {
+ switch( nType )
+ {
+ case E3D_SCENE_ID :
+ case E3D_POLYSCENE_ID :
+ pRet = new Svx3DSceneObject( pObj, mpPage );
+ break;
+ case E3D_CUBEOBJ_ID :
+ pRet = new Svx3DCubeObject( pObj );
+ break;
+ case E3D_SPHEREOBJ_ID :
+ pRet = new Svx3DSphereObject( pObj );
+ break;
+ case E3D_LATHEOBJ_ID :
+ pRet = new Svx3DLatheObject( pObj );
+ break;
+ case E3D_EXTRUDEOBJ_ID :
+ pRet = new Svx3DExtrudeObject( pObj );
+ break;
+ case E3D_POLYGONOBJ_ID :
+ pRet = new Svx3DPolygonObject( pObj );
+ break;
+ default: // unbekanntes 3D-Objekt auf der Page
+ pRet = new SvxShape( pObj );
+ break;
+ }
+ break;
+ }
+ case SdrInventor:
+ {
+ switch( nType )
+ {
+// case OBJ_NONE:
+// break;
+ case OBJ_GRUP:
+ pRet = new SvxShapeGroup( pObj, mpPage );
+ break;
+ case OBJ_LINE:
+ pRet = new SvxShapePolyPolygon( pObj , PolygonKind_LINE );
+ break;
+ case OBJ_RECT:
+ pRet = new SvxShapeRect( pObj );
+ break;
+ case OBJ_CIRC:
+ case OBJ_SECT:
+ case OBJ_CARC:
+ case OBJ_CCUT:
+ pRet = new SvxShapeCircle( pObj );
+ break;
+ case OBJ_POLY:
+ pRet = new SvxShapePolyPolygon( pObj , PolygonKind_POLY );
+ break;
+ case OBJ_PLIN:
+ pRet = new SvxShapePolyPolygon( pObj , PolygonKind_PLIN );
+ break;
+ case OBJ_SPLNLINE:
+ case OBJ_PATHLINE:
+ pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_PATHLINE );
+ break;
+ case OBJ_SPLNFILL:
+ case OBJ_PATHFILL:
+ pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_PATHFILL );
+ break;
+ case OBJ_FREELINE:
+ pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_FREELINE );
+ break;
+ case OBJ_FREEFILL:
+ pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_FREEFILL );
+ break;
+ case OBJ_CAPTION:
+ pRet = new SvxShapeCaption( pObj );
+ break;
+ case OBJ_TITLETEXT:
+ case OBJ_OUTLINETEXT:
+ case OBJ_TEXT:
+ pRet = new SvxShapeText( pObj );
+ break;
+ case OBJ_GRAF:
+ pRet = new SvxGraphicObject( pObj );
+ break;
+ case OBJ_FRAME:
+ pRet = new SvxFrameShape( pObj );
+ break;
+ case OBJ_OLE2_APPLET:
+ pRet = new SvxAppletShape( pObj );
+ break;
+ case OBJ_OLE2_PLUGIN:
+ pRet = new SvxPluginShape( pObj );
+ break;
+ case OBJ_OLE2:
+ {
+ if( pObj && !pObj->IsEmptyPresObj() && mpPage )
+ {
+ SdrPage* pSdrPage = mpPage->GetSdrPage();
+ if( pSdrPage )
+ {
+ SdrModel* pSdrModel = pSdrPage->GetModel();
+ if( pSdrModel )
+ {
+ ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist();
+ if( pPersist )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
+ GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
+
+ // TODO CL->KA: Why is this not working anymore?
+ if( xObject.is() )
+ {
+ SvGlobalName aClassId( xObject->getClassID() );
+
+ const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
+ const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
+ const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
+
+ if( aPluginClassId == aClassId )
+ {
+ pRet = new SvxPluginShape( pObj );
+ nType = OBJ_OLE2_PLUGIN;
+ }
+ else if( aAppletClassId == aClassId )
+ {
+ pRet = new SvxAppletShape( pObj );
+ nType = OBJ_OLE2_APPLET;
+ }
+ else if( aIFrameClassId == aClassId )
+ {
+ pRet = new SvxFrameShape( pObj );
+ nType = OBJ_FRAME;
+ }
+ }
+ }
+ }
+ }
+ }
+ if( pRet == NULL )
+ {
+ pRet = new SvxOle2Shape( pObj, aSvxMapProvider.GetMap(SVXMAP_OLE2), aSvxMapProvider.GetPropertySet(SVXMAP_OLE2, SdrObject::GetGlobalDrawObjectItemPool()) );
+ }
+ }
+ break;
+ case OBJ_EDGE:
+ pRet = new SvxShapeConnector( pObj );
+ break;
+ case OBJ_PATHPOLY:
+ pRet = new SvxShapePolyPolygon( pObj , PolygonKind_PATHPOLY );
+ break;
+ case OBJ_PATHPLIN:
+ pRet = new SvxShapePolyPolygon( pObj , PolygonKind_PATHPLIN );
+ break;
+ case OBJ_PAGE:
+ pRet = new SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_PAGE), aSvxMapProvider.GetPropertySet(SVXMAP_PAGE, SdrObject::GetGlobalDrawObjectItemPool()) );
+ break;
+ case OBJ_MEASURE:
+ pRet = new SvxShapeDimensioning( pObj );
+ break;
+// case OBJ_DUMMY:
+// break;
+ case OBJ_UNO:
+ pRet = new SvxShapeControl( pObj );
+ break;
+ case OBJ_CUSTOMSHAPE:
+ pRet = new SvxCustomShape( pObj );
+ break;
+ case OBJ_MEDIA:
+ pRet = new SvxMediaShape( pObj );
+ break;
+ case OBJ_TABLE:
+ pRet = new SvxTableShape( pObj );
+ break;
+ default: // unbekanntes 2D-Objekt auf der Page
+ DBG_ERROR("Nicht implementierter Starone-Shape erzeugt! [CL]");
+ pRet = new SvxShapeText( pObj );
+ break;
+ }
+ break;
+ }
+ default: // Unbekannter Inventor
+ {
+ DBG_ERROR("AW: Unknown Inventor in SvxDrawPage::_CreateShape()");
+ break;
+ }
+ }
+
+ if(pRet)
+ {
+ sal_uInt32 nObjId = nType;
+
+ if( nInventor == E3dInventor )
+ nObjId |= E3D_INVENTOR_FLAG;
+
+ switch(nObjId)
+ {
+ case OBJ_CCUT: // Kreisabschnitt
+ case OBJ_CARC: // Kreisbogen
+ case OBJ_SECT: // Kreissektor
+ nObjId = OBJ_CIRC;
+ break;
+
+ case E3D_SCENE_ID | E3D_INVENTOR_FLAG:
+ nObjId = E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG;
+ break;
+
+ case OBJ_TITLETEXT:
+ case OBJ_OUTLINETEXT:
+ nObjId = OBJ_TEXT;
+ break;
+ }
+
+ pRet->setShapeKind(nObjId);
+ }
+
+ return pRet;
+}
+
+//----------------------------------------------------------------------
+Reference< drawing::XShape > SvxDrawPage::_CreateShape( SdrObject *pObj ) const throw()
+{
+ Reference< drawing::XShape > xShape( CreateShapeByTypeAndInventor(pObj->GetObjIdentifier(),
+ pObj->GetObjInventor(),
+ pObj,
+ (SvxDrawPage*)this));
+ return xShape;
+}
+
+//----------------------------------------------------------------------
+SdrObject *SvxDrawPage::CreateSdrObject( const Reference< drawing::XShape > & xShape ) throw()
+{
+ SdrObject* pObj = _CreateSdrObject( xShape );
+ if( pObj && !pObj->IsInserted() )
+ mpPage->InsertObject( pObj );
+
+ return pObj;
+}
+
+//----------------------------------------------------------------------
+// ::com::sun::star::lang::XServiceInfo
+//----------------------------------------------------------------------
+OUString SAL_CALL SvxDrawPage::getImplementationName() throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxDrawPage"));
+}
+
+sal_Bool SAL_CALL SvxDrawPage::supportsService( const OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxDrawPage::getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aSeq( 1 );
+ aSeq.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ShapeCollection" ));
+ return aSeq;
+}
+
+SvxShape* CreateSvxShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor ) throw()
+{
+ return SvxDrawPage::CreateShapeByTypeAndInventor( nType, nInventor );
+}
+
+void SvxDrawPage::ChangeModel( SdrModel* pNewModel )
+{
+ if( pNewModel != mpModel )
+ {
+ if( mpModel )
+ EndListening( *mpModel );
+
+ if( pNewModel )
+ StartListening( *pNewModel );
+
+ mpModel = pNewModel;
+
+ if( mpView )
+ {
+ delete mpView;
+ mpView = new SdrView( mpModel );
+ if( mpView )
+ mpView->SetDesignMode(sal_True);
+ }
+ }
+}
+
+/** returns a StarOffice API wrapper for the given SdrPage */
+uno::Reference< drawing::XDrawPage > GetXDrawPageForSdrPage( SdrPage* pPage ) throw ()
+{
+ if(pPage)
+ {
+ uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
+
+ return xDrawPage;
+ }
+
+ return uno::Reference< drawing::XDrawPage >();
+}
+
+/** returns the SdrObject from the given StarOffice API wrapper */
+SdrPage* GetSdrPageFromXDrawPage( uno::Reference< drawing::XDrawPage > xDrawPage ) throw()
+{
+ if(xDrawPage.is())
+ {
+ SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xDrawPage );
+
+ if(pDrawPage)
+ {
+ return pDrawPage->GetSdrPage();
+ }
+ }
+
+ return NULL;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unopool.cxx b/svx/source/unodraw/unopool.cxx
new file mode 100644
index 000000000000..bcfc40c055c2
--- /dev/null
+++ b/svx/source/unodraw/unopool.cxx
@@ -0,0 +1,431 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+
+#include <comphelper/propertysetinfo.hxx>
+#include <rtl/uuid.h>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include "unopool.hxx"
+#include <svx/svdmodel.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/unoprov.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/unoshprp.hxx>
+#include <svx/xflbstit.hxx>
+#include <svx/xflbmtit.hxx>
+#include <svx/unopage.hxx>
+#include <svx/svdetc.hxx>
+#include <editeng/editeng.hxx>
+
+#include "unoapi.hxx"
+#include <memory>
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+using namespace ::cppu;
+
+SvxUnoDrawPool::SvxUnoDrawPool( SdrModel* pModel, sal_Int32 nServiceId ) throw()
+: PropertySetHelper( SvxPropertySetInfoPool::getOrCreate( nServiceId ) ), mpModel( pModel )
+{
+ init();
+}
+
+/* deprecated */
+SvxUnoDrawPool::SvxUnoDrawPool( SdrModel* pModel ) throw()
+: PropertySetHelper( SvxPropertySetInfoPool::getOrCreate( SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS ) ), mpModel( pModel )
+{
+ init();
+}
+
+SvxUnoDrawPool::~SvxUnoDrawPool() throw()
+{
+ SfxItemPool::Free(mpDefaultsPool);
+}
+
+void SvxUnoDrawPool::init()
+{
+ mpDefaultsPool = new SdrItemPool();
+ SfxItemPool* pOutlPool=EditEngine::CreatePool();
+ mpDefaultsPool->SetSecondaryPool(pOutlPool);
+
+ SdrModel::SetTextDefaults( mpDefaultsPool, SdrEngineDefaults::GetFontHeight() );
+ mpDefaultsPool->SetDefaultMetric((SfxMapUnit)SdrEngineDefaults::GetMapUnit());
+ mpDefaultsPool->FreezeIdRanges();
+}
+
+SfxItemPool* SvxUnoDrawPool::getModelPool( sal_Bool bReadOnly ) throw()
+{
+ if( mpModel )
+ {
+ return &mpModel->GetItemPool();
+ }
+ else
+ {
+ if( bReadOnly )
+ return mpDefaultsPool;
+ else
+ return NULL;
+ }
+}
+
+void SvxUnoDrawPool::getAny( SfxItemPool* pPool, const comphelper::PropertyMapEntry* pEntry, uno::Any& rValue )
+ throw(beans::UnknownPropertyException)
+{
+ switch( pEntry->mnHandle )
+ {
+ case OWN_ATTR_FILLBMP_MODE:
+ {
+ XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)&pPool->GetDefaultItem(XATTR_FILLBMP_STRETCH);
+ XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)&pPool->GetDefaultItem(XATTR_FILLBMP_TILE);
+ if( pTileItem && pTileItem->GetValue() )
+ {
+ rValue <<= drawing::BitmapMode_REPEAT;
+ }
+ else if( pStretchItem && pStretchItem->GetValue() )
+ {
+ rValue <<= drawing::BitmapMode_STRETCH;
+ }
+ else
+ {
+ rValue <<= drawing::BitmapMode_NO_REPEAT;
+ }
+ break;
+ }
+ default:
+ {
+ const SfxMapUnit eMapUnit = pPool ? pPool->GetMetric((USHORT)pEntry->mnHandle) : SFX_MAPUNIT_100TH_MM;
+
+ BYTE nMemberId = pEntry->mnMemberId & (~SFX_METRIC_ITEM);
+ if( eMapUnit == SFX_MAPUNIT_100TH_MM )
+ nMemberId &= (~CONVERT_TWIPS);
+
+ // DVO, OD 10.10.2003 #i18732#
+ // Assure, that ID is a Which-ID (it could be a Slot-ID.)
+ // Thus, convert handle to Which-ID.
+ pPool->GetDefaultItem( pPool->GetWhich( (USHORT)pEntry->mnHandle ) ).QueryValue( rValue, nMemberId );
+ }
+ }
+
+
+ // check for needed metric translation
+ const SfxMapUnit eMapUnit = pPool->GetMetric((USHORT)pEntry->mnHandle);
+ if(pEntry->mnMemberId & SFX_METRIC_ITEM && eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ SvxUnoConvertToMM( eMapUnit, rValue );
+ }
+ // convert int32 to correct enum type if needed
+ else if ( pEntry->mpType->getTypeClass() == uno::TypeClass_ENUM && rValue.getValueType() == ::getCppuType((const sal_Int32*)0) )
+ {
+ sal_Int32 nEnum;
+ rValue >>= nEnum;
+
+ rValue.setValue( &nEnum, *pEntry->mpType );
+ }
+}
+
+void SvxUnoDrawPool::putAny( SfxItemPool* pPool, const comphelper::PropertyMapEntry* pEntry, const uno::Any& rValue )
+ throw(beans::UnknownPropertyException, lang::IllegalArgumentException)
+{
+ uno::Any aValue( rValue );
+
+ const SfxMapUnit eMapUnit = pPool->GetMetric((USHORT)pEntry->mnHandle);
+ if(pEntry->mnMemberId & SFX_METRIC_ITEM && eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ SvxUnoConvertFromMM( eMapUnit, aValue );
+ }
+
+ // DVO, OD 10.10.2003 #i18732#
+ // Assure, that ID is a Which-ID (it could be a Slot-ID.)
+ // Thus, convert handle to Which-ID.
+ const sal_uInt16 nWhich = pPool->GetWhich( (sal_uInt16)pEntry->mnHandle );
+ switch( nWhich )
+ {
+ case OWN_ATTR_FILLBMP_MODE:
+ do
+ {
+ drawing::BitmapMode eMode;
+ if(!(aValue >>= eMode) )
+ {
+ sal_Int32 nMode = 0;
+ if(!(aValue >>= nMode))
+ throw lang::IllegalArgumentException();
+
+ eMode = (drawing::BitmapMode)nMode;
+ }
+
+ pPool->SetPoolDefaultItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) );
+ pPool->SetPoolDefaultItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) );
+ return;
+ }
+ while(0);
+
+ default:
+ {
+ ::std::auto_ptr<SfxPoolItem> pNewItem( pPool->GetDefaultItem( nWhich ).Clone() );
+ BYTE nMemberId = pEntry->mnMemberId & (~SFX_METRIC_ITEM);
+ if( !pPool || (pPool->GetMetric(nWhich) == SFX_MAPUNIT_100TH_MM) )
+ nMemberId &= (~CONVERT_TWIPS);
+
+ if( !pNewItem->PutValue( aValue, nMemberId ) )
+ throw lang::IllegalArgumentException();
+
+ pPool->SetPoolDefaultItem( *pNewItem );
+ }
+ }
+}
+
+void SvxUnoDrawPool::_setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const uno::Any* pValues )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ SolarMutexGuard aGuard;
+
+ SfxItemPool* pPool = getModelPool( sal_False );
+
+ DBG_ASSERT( pPool, "I need a SfxItemPool!" );
+ if( NULL == pPool )
+ throw beans::UnknownPropertyException();
+
+ while( *ppEntries )
+ putAny( pPool, *ppEntries++, *pValues++ );
+}
+
+void SvxUnoDrawPool::_getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, uno::Any* pValue )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException )
+{
+ SolarMutexGuard aGuard;
+
+ SfxItemPool* pPool = getModelPool( sal_True );
+
+ DBG_ASSERT( pPool, "I need a SfxItemPool!" );
+ if( NULL == pPool )
+ throw beans::UnknownPropertyException();
+
+ while( *ppEntries )
+ getAny( pPool, *ppEntries++, *pValue++ );
+}
+
+void SvxUnoDrawPool::_getPropertyStates( const comphelper::PropertyMapEntry** ppEntries, beans::PropertyState* pStates )
+ throw(beans::UnknownPropertyException )
+{
+ SolarMutexGuard aGuard;
+
+ SfxItemPool* pPool = getModelPool( sal_True );
+
+ if( pPool && pPool != mpDefaultsPool )
+ {
+ while( *ppEntries )
+ {
+ // OD 13.10.2003 #i18732#
+ // Assure, that ID is a Which-ID (it could be a Slot-ID.)
+ // Thus, convert handle to Which-ID.
+ const sal_uInt16 nWhich = pPool->GetWhich( ((sal_uInt16)(*ppEntries)->mnHandle) );
+
+ switch( nWhich )
+ {
+ case OWN_ATTR_FILLBMP_MODE:
+ {
+ // use method <IsStaticDefaultItem(..)> instead of using
+ // probably incompatible item pool <mpDefaultPool>.
+ if ( IsStaticDefaultItem( &(pPool->GetDefaultItem( XATTR_FILLBMP_STRETCH )) ) ||
+ IsStaticDefaultItem( &(pPool->GetDefaultItem( XATTR_FILLBMP_TILE )) ) )
+ {
+ *pStates = beans::PropertyState_DEFAULT_VALUE;
+ }
+ else
+ {
+ *pStates = beans::PropertyState_DIRECT_VALUE;
+ }
+ }
+ break;
+ default:
+ // OD 13.10.2003 #i18732# - correction:
+ // use method <IsStaticDefaultItem(..)> instead of using probably
+ // incompatible item pool <mpDefaultPool>.
+ const SfxPoolItem& r1 = pPool->GetDefaultItem( nWhich );
+ //const SfxPoolItem& r2 = mpDefaultPool->GetDefaultItem( nWhich );
+
+ if ( IsStaticDefaultItem( &r1 ) )
+ {
+ *pStates = beans::PropertyState_DEFAULT_VALUE;
+ }
+ else
+ {
+ *pStates = beans::PropertyState_DIRECT_VALUE;
+ }
+ }
+
+ pStates++;
+ ppEntries++;
+ }
+ }
+ else
+ {
+ // as long as we have no model, all properties are default
+ while( *ppEntries++ )
+ *pStates++ = beans::PropertyState_DEFAULT_VALUE;
+ return;
+ }
+}
+
+void SvxUnoDrawPool::_setPropertyToDefault( const comphelper::PropertyMapEntry* pEntry )
+ throw(beans::UnknownPropertyException )
+{
+ SolarMutexGuard aGuard;
+
+ SfxItemPool* pPool = getModelPool( sal_True );
+
+ // OD 10.10.2003 #i18732#
+ // Assure, that ID is a Which-ID (it could be a Slot-ID.)
+ // Thus, convert handle to Which-ID.
+ const sal_uInt16 nWhich = pPool->GetWhich( (USHORT)pEntry->mnHandle );
+ if ( pPool && pPool != mpDefaultsPool )
+ {
+ // OD 13.10.2003 #i18732# - use method <ResetPoolDefaultItem(..)>
+ // instead of using probably incompatible item pool <mpDefaultsPool>.
+ pPool->ResetPoolDefaultItem( nWhich );
+ }
+}
+
+uno::Any SvxUnoDrawPool::_getPropertyDefault( const comphelper::PropertyMapEntry* pEntry )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException )
+{
+ SolarMutexGuard aGuard;
+
+ // OD 13.10.2003 #i18732# - use method <GetPoolDefaultItem(..)> instead of
+ // using probably incompatible item pool <mpDefaultsPool>
+ uno::Any aAny;
+ SfxItemPool* pPool = getModelPool( sal_True );
+ const sal_uInt16 nWhich = pPool->GetWhich( (USHORT)pEntry->mnHandle );
+ const SfxPoolItem *pItem = pPool->GetPoolDefaultItem ( nWhich );
+ pItem->QueryValue( aAny, pEntry->mnMemberId );
+
+ return aAny;
+}
+
+// XInterface
+
+uno::Any SAL_CALL SvxUnoDrawPool::queryInterface( const uno::Type & rType )
+ throw( uno::RuntimeException )
+{
+ return OWeakAggObject::queryInterface( rType );
+}
+
+uno::Any SAL_CALL SvxUnoDrawPool::queryAggregation( const uno::Type & rType )
+ throw(uno::RuntimeException)
+{
+ uno::Any aAny;
+
+ if( rType == ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0) )
+ aAny <<= uno::Reference< lang::XServiceInfo >(this);
+ else if( rType == ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0) )
+ aAny <<= uno::Reference< lang::XTypeProvider >(this);
+ else if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) )
+ aAny <<= uno::Reference< beans::XPropertySet >(this);
+ else if( rType == ::getCppuType((const uno::Reference< beans::XPropertyState >*)0) )
+ aAny <<= uno::Reference< beans::XPropertyState >(this);
+ else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0) )
+ aAny <<= uno::Reference< beans::XMultiPropertySet >(this);
+ else
+ aAny <<= OWeakAggObject::queryAggregation( rType );
+
+ return aAny;
+}
+
+void SAL_CALL SvxUnoDrawPool::acquire() throw ( )
+{
+ OWeakAggObject::acquire();
+}
+
+void SAL_CALL SvxUnoDrawPool::release() throw ( )
+{
+ OWeakAggObject::release();
+}
+
+uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawPool::getTypes()
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< uno::Type > aTypes( 6 );
+ uno::Type* pTypes = aTypes.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< uno::XAggregation>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet>*)0);
+
+ return aTypes;
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL SvxUnoDrawPool::getImplementationId()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// XServiceInfo
+
+sal_Bool SAL_CALL SvxUnoDrawPool::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
+{
+ uno::Sequence< OUString > aSNL( getSupportedServiceNames() );
+ const OUString * pArray = aSNL.getConstArray();
+
+ for( INT32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return TRUE;
+
+ return FALSE;
+}
+
+OUString SAL_CALL SvxUnoDrawPool::getImplementationName() throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDrawPool") );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoDrawPool::getSupportedServiceNames( )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Defaults" ));
+ return aSNS;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
new file mode 100644
index 000000000000..911dff21a4f9
--- /dev/null
+++ b/svx/source/unodraw/unoprov.cxx
@@ -0,0 +1,1457 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sal/macros.h>
+
+#define _SVX_USE_UNOGLOBALS_
+
+#include <com/sun/star/table/XTable.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+#include <com/sun/star/media/ZoomLevel.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <hash_map>
+#include <vcl/fldunit.hxx>
+#include <tools/shl.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <comphelper/propertysetinfo.hxx>
+#include <svx/dialmgr.hxx>
+#include "unoapi.hxx"
+#include <editeng/unotext.hxx>
+#include <svx/unoshprp.hxx>
+#include <editeng/editeng.hxx>
+#include "globl3d.hxx"
+#include <svx/dialogs.hrc>
+#include <svx/svdpool.hxx>
+#include <svx/svdobj.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans::PropertyAttribute;
+using ::com::sun::star::drawing::TextVerticalAdjust;
+
+SfxItemPropertyMapEntry* ImplGetSvxShapePropertyMap()
+{
+ static SfxItemPropertyMapEntry aShapePropertyMap_Impl[] =
+ {
+ EDGERADIUS_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ TEXT_PROPERTIES
+ // #FontWork#
+ FONTWORK_PROPERTIES
+ CUSTOMSHAPE_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aShapePropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxTextShapePropertyMap()
+{
+ static SfxItemPropertyMapEntry aTextShapePropertyMap_Impl[] =
+ {
+ EDGERADIUS_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES_NO_SHEAR
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ TEXT_PROPERTIES
+ // #FontWork#
+ FONTWORK_PROPERTIES
+ CUSTOMSHAPE_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aTextShapePropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxConnectorPropertyMap()
+{
+ static SfxItemPropertyMapEntry aConnectorPropertyMap_Impl[] =
+ {
+ SPECIAL_CONNECTOR_PROPERTIES
+ EDGERADIUS_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ TEXT_PROPERTIES
+ // #FontWork#
+ FONTWORK_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aConnectorPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxDimensioningPropertyMap()
+{
+ static SfxItemPropertyMapEntry aDimensioningPropertyMap_Impl[] =
+ {
+ SPECIAL_DIMENSIONING_PROPERTIES
+ EDGERADIUS_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ TEXT_PROPERTIES
+ // #FontWork#
+ FONTWORK_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aDimensioningPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxCirclePropertyMap()
+{
+ static SfxItemPropertyMapEntry aCirclePropertyMap_Impl[] =
+ {
+ SPECIAL_CIRCLE_PROPERTIES
+ EDGERADIUS_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ TEXT_PROPERTIES
+ // #FontWork#
+ FONTWORK_PROPERTIES
+ CUSTOMSHAPE_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aCirclePropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxPolyPolygonPropertyMap()
+{
+ static SfxItemPropertyMapEntry aPolyPolygonPropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN("Geometry"), OWN_ATTR_BASE_GEOMETRY, SEQTYPE(::getCppuType((const ::com::sun::star::drawing::PointSequenceSequence*)0)), 0, 0 },
+ SPECIAL_POLYGON_PROPERTIES
+ SPECIAL_POLYPOLYGON_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ TEXT_PROPERTIES
+ // #FontWork#
+ FONTWORK_PROPERTIES
+ CUSTOMSHAPE_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aPolyPolygonPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxPolyPolygonBezierPropertyMap()
+{
+ static SfxItemPropertyMapEntry aPolyPolygonBezierPropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN("Geometry"), OWN_ATTR_BASE_GEOMETRY, &::getCppuType((const ::com::sun::star::drawing::PolyPolygonBezierCoords*)0), 0, 0 },
+ SPECIAL_POLYGON_PROPERTIES
+ SPECIAL_POLYPOLYGONBEZIER_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ TEXT_PROPERTIES
+ // #FontWork#
+ FONTWORK_PROPERTIES
+ CUSTOMSHAPE_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aPolyPolygonBezierPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxGraphicObjectPropertyMap()
+{
+ static SfxItemPropertyMapEntry aGraphicObjectPropertyMap_Impl[] =
+ {
+ SPECIAL_GRAPHOBJ_PROPERTIES
+
+ // #i25616#
+ FILL_PROPERTIES
+
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES_NO_SHEAR
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ TEXT_PROPERTIES
+ // #FontWork#
+ FONTWORK_PROPERTIES
+ { MAP_CHAR_LEN("IsMirrored"), OWN_ATTR_MIRRORED , &::getCppuBooleanType(), 0, 0},
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("GraphicStream"), OWN_ATTR_GRAPHIC_STREAM, &::com::sun::star::io::XInputStream::static_type(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aGraphicObjectPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvx3DSceneObjectPropertyMap()
+{
+ static SfxItemPropertyMapEntry a3DSceneObjectPropertyMap_Impl[] =
+ {
+ SPECIAL_3DSCENEOBJECT_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ {0,0,0,0,0,0}
+
+ };
+
+ return a3DSceneObjectPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvx3DCubeObjectPropertyMap()
+{
+ static SfxItemPropertyMapEntry a3DCubeObjectPropertyMap_Impl[] =
+ {
+ SPECIAL_3DCUBEOBJECT_PROPERTIES
+ MISC_3D_OBJ_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return a3DCubeObjectPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvx3DSphereObjectPropertyMap()
+{
+ static SfxItemPropertyMapEntry a3DSphereObjectPropertyMap_Impl[] =
+ {
+ SPECIAL_3DSPHEREOBJECT_PROPERTIES
+ MISC_3D_OBJ_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+ return a3DSphereObjectPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvx3DLatheObjectPropertyMap()
+{
+ static SfxItemPropertyMapEntry a3DLatheObjectPropertyMap_Impl[] =
+ {
+ SPECIAL_3DLATHEOBJECT_PROPERTIES
+
+ // #107245# New 3D properties which are possible for lathe and extrude 3d objects
+ SPECIAL_3DLATHEANDEXTRUDEOBJ_PROPERTIES
+
+ SPECIAL_3DBACKSCALE_PROPERTIES
+ MISC_3D_OBJ_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return a3DLatheObjectPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvx3DExtrudeObjectPropertyMap()
+{
+ static SfxItemPropertyMapEntry a3DExtrudeObjectPropertyMap_Impl[] =
+ {
+ SPECIAL_3DEXTRUDEOBJECT_PROPERTIES
+
+ // #107245# New 3D properties which are possible for lathe and extrude 3d objects
+ SPECIAL_3DLATHEANDEXTRUDEOBJ_PROPERTIES
+
+ SPECIAL_3DBACKSCALE_PROPERTIES
+ MISC_3D_OBJ_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return a3DExtrudeObjectPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvx3DPolygonObjectPropertyMap()
+{
+ static SfxItemPropertyMapEntry a3DPolygonObjectPropertyMap_Impl[] =
+ {
+ SPECIAL_3DPOLYGONOBJECT_PROPERTIES
+ MISC_3D_OBJ_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return a3DPolygonObjectPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxAllPropertyMap()
+{
+ static SfxItemPropertyMapEntry aAllPropertyMap_Impl[] =
+ {
+ SHADOW_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ FILL_PROPERTIES
+ EDGERADIUS_PROPERTIES
+ TEXT_PROPERTIES
+ // #FontWork#
+ FONTWORK_PROPERTIES
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SPECIAL_CONNECTOR_PROPERTIES
+ SPECIAL_DIMENSIONING_PROPERTIES
+ SPECIAL_CIRCLE_PROPERTIES
+ SPECIAL_POLYGON_PROPERTIES
+ SPECIAL_POLYPOLYGON_PROPERTIES
+ SPECIAL_POLYPOLYGONBEZIER_PROPERTIES
+ SPECIAL_GRAPHOBJ_PROPERTIES
+ SPECIAL_3DSCENEOBJECT_PROPERTIES
+ MISC_3D_OBJ_PROPERTIES
+ SPECIAL_3DCUBEOBJECT_PROPERTIES
+ SPECIAL_3DSPHEREOBJECT_PROPERTIES
+ SPECIAL_3DLATHEOBJECT_PROPERTIES
+ SPECIAL_3DEXTRUDEOBJECT_PROPERTIES
+
+ // #107245# New 3D properties which are possible for lathe and extrude 3d objects
+ SPECIAL_3DLATHEANDEXTRUDEOBJ_PROPERTIES
+
+ SPECIAL_3DBACKSCALE_PROPERTIES
+ SPECIAL_3DPOLYGONOBJECT_PROPERTIES
+ CUSTOMSHAPE_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aAllPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxGroupPropertyMap()
+{
+ static SfxItemPropertyMapEntry aGroupPropertyMap_Impl[] =
+ {
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ {0,0,0,0,0,0}
+
+ };
+
+ return aGroupPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxOle2PropertyMap()
+{
+ static SfxItemPropertyMapEntry aOle2PropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, \
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_OLE2_METAFILE), OWN_ATTR_METAFILE , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("ThumbnailGraphicURL"), OWN_ATTR_THUMBNAIL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN("Model"), OWN_ATTR_OLEMODEL , &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("EmbeddedObject"), OWN_ATTR_OLE_EMBEDDED_OBJECT , &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("EmbeddedObjectNoNewClient"),OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("OriginalSize"), OWN_ATTR_OLESIZE , &::getCppuType(( const ::com::sun::star::awt::Size*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("CLSID"), OWN_ATTR_CLSID , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN("IsInternal"), OWN_ATTR_INTERNAL_OLE , &::getBooleanCppuType() , ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("VisibleArea"), OWN_ATTR_OLE_VISAREA , &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), 0, 0},
+ { MAP_CHAR_LEN("Aspect"), OWN_ATTR_OLE_ASPECT , &::getCppuType((const sal_Int64*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_OLE2_PERSISTNAME), OWN_ATTR_PERSISTNAME , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN("LinkURL"), OWN_ATTR_OLE_LINKURL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_GRAPHOBJ_GRAPHIC), OWN_ATTR_VALUE_GRAPHIC , &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic>*)0), 0, 0},
+ // #i68101#
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aOle2PropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxPluginPropertyMap()
+{
+ static SfxItemPropertyMapEntry aPluginPropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN("PluginMimeType"), OWN_ATTR_PLUGIN_MIMETYPE , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN("PluginURL"), OWN_ATTR_PLUGIN_URL , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN("PluginCommands"), OWN_ATTR_PLUGIN_COMMANDS , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >*)0)), 0, 0},
+ { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, \
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_OLE2_METAFILE), OWN_ATTR_METAFILE , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("ThumbnailGraphicURL"), OWN_ATTR_THUMBNAIL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_OLE2_PERSISTNAME), OWN_ATTR_PERSISTNAME , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN("LinkURL"), OWN_ATTR_OLE_LINKURL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("VisibleArea"), OWN_ATTR_OLE_VISAREA , &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), 0, 0},
+ // #i68101#
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aPluginPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxFramePropertyMap()
+{
+ //TODO/LATER: new properties for ScrollingMode and DefaultBorder
+ static SfxItemPropertyMapEntry aFramePropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN("FrameURL"), OWN_ATTR_FRAME_URL , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN("FrameName"), OWN_ATTR_FRAME_NAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN("FrameIsAutoScroll"), OWN_ATTR_FRAME_ISAUTOSCROLL , &::getBooleanCppuType() , ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
+ { MAP_CHAR_LEN("FrameIsBorder"), OWN_ATTR_FRAME_ISBORDER , &::getBooleanCppuType() , 0, 0},
+ { MAP_CHAR_LEN("FrameMarginWidth"), OWN_ATTR_FRAME_MARGIN_WIDTH , &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN("FrameMarginHeight"), OWN_ATTR_FRAME_MARGIN_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, \
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_OLE2_METAFILE), OWN_ATTR_METAFILE , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("ThumbnailGraphicURL"), OWN_ATTR_THUMBNAIL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_OLE2_PERSISTNAME), OWN_ATTR_PERSISTNAME , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN("LinkURL"), OWN_ATTR_OLE_LINKURL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("VisibleArea"), OWN_ATTR_OLE_VISAREA , &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), 0, 0},
+ // #i68101#
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aFramePropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxAppletPropertyMap()
+{
+ static SfxItemPropertyMapEntry aAppletPropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN("AppletCodeBase"), OWN_ATTR_APPLET_CODEBASE , &::getCppuType(( const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN("AppletName"), OWN_ATTR_APPLET_NAME , &::getCppuType(( const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN("AppletCode"), OWN_ATTR_APPLET_CODE , &::getCppuType(( const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN("AppletCommands"), OWN_ATTR_APPLET_COMMANDS , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >*)0)), 0, 0},
+ { MAP_CHAR_LEN("AppletDocBase"), OWN_ATTR_APPLET_DOCBASE , &::getCppuType(( const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN("AppletIsScript"), OWN_ATTR_APPLET_ISSCRIPT , &::getBooleanCppuType(), 0, 0 },
+ { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, \
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_OLE2_METAFILE), OWN_ATTR_METAFILE , SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("ThumbnailGraphicURL"), OWN_ATTR_THUMBNAIL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_OLE2_PERSISTNAME), OWN_ATTR_PERSISTNAME , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN("LinkURL"), OWN_ATTR_OLE_LINKURL , &::getCppuType(( const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("VisibleArea"), OWN_ATTR_OLE_VISAREA , &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), 0, 0},
+ // #i68101#
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aAppletPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxControlShapePropertyMap()
+{
+ static SfxItemPropertyMapEntry aControlPropertyMap_Impl[] =
+ {
+ // the following properties are mapped to the XControl Model of this shape
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTNAME), 0, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTSTYLENAME), 0, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTFAMILY), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTCHARSET), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_HEIGHT), 0, &::getCppuType((const float*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTPITCH), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_POSTURE), 0, &::getCppuType((const ::com::sun::star::awt::FontSlant*)0),0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_WEIGHT), 0, &::getCppuType((const float*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_UNDERLINE), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_STRIKEOUT), 0, &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_COLOR), 0, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ { MAP_CHAR_LEN("CharRelief"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN("CharUnderlineColor"), 0, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ { MAP_CHAR_LEN("CharKerning"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN("CharWordMode"), 0, &::getBooleanCppuType(), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_PARA_ADJUST), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN("TextVerticalAdjust"), 0, &::getCppuType((const TextVerticalAdjust*)0), MAYBEVOID, 0 },
+ { MAP_CHAR_LEN("ControlBackground"), 0, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ { MAP_CHAR_LEN("ControlBorder"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN("ControlBorderColor"), 0, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ { MAP_CHAR_LEN("ControlSymbolColor"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN("ImageScaleMode"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN("ControlTextEmphasis"), 0, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ { MAP_CHAR_LEN("ControlWritingMode"), 0, &::cppu::UnoType< sal_Int16 >::get(), 0, 0},
+ // the following properties are handled by SvxShape
+ { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ // #i68101#
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ // #i112587#
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_PRINTABLE), SDRATTR_OBJPRINTABLE , &::getBooleanCppuType(), 0, 0}, \
+ { MAP_CHAR_LEN("Visible"), SDRATTR_OBJVISIBLE , &::getBooleanCppuType(), 0, 0}, \
+ {0,0,0,0,0,0}
+
+ };
+
+ return aControlPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxPageShapePropertyMap()
+{
+ static SfxItemPropertyMapEntry aPageShapePropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN("PageNumber"), OWN_ATTR_PAGE_NUMBER , &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION , &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 }, \
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER , &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID , &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME),SDRATTR_LAYERNAME , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP , &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME , &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ // #i68101#
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aPageShapePropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxCaptionPropertyMap()
+{
+ static SfxItemPropertyMapEntry aCaptionPropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN("CaptionPoint"), OWN_ATTR_CAPTION_POINT, &::getCppuType((const com::sun::star::awt::Point*)0), 0, 0 },
+ { MAP_CHAR_LEN("CaptionType"), SDRATTR_CAPTIONTYPE, &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN("CaptionIsFixedAngle"), SDRATTR_CAPTIONFIXEDANGLE, &::getBooleanCppuType(), 0, 0},
+ { MAP_CHAR_LEN("CaptionAngle"), SDRATTR_CAPTIONANGLE, &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN("CaptionGap"), SDRATTR_CAPTIONGAP, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM},
+ { MAP_CHAR_LEN("CaptionEscapeDirection"), SDRATTR_CAPTIONESCDIR, &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN("CaptionIsEscapeRelative"), SDRATTR_CAPTIONESCISREL, &::getBooleanCppuType(), 0, 0},
+ { MAP_CHAR_LEN("CaptionEscapeRelative"), SDRATTR_CAPTIONESCREL, &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN("CaptionEscapeAbsolute"), SDRATTR_CAPTIONESCABS, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM},
+ { MAP_CHAR_LEN("CaptionLineLength"), SDRATTR_CAPTIONLINELEN, &::getCppuType((const sal_Int32*)0), 0, SFX_METRIC_ITEM},
+ { MAP_CHAR_LEN("CaptionIsFitLineLength"), SDRATTR_CAPTIONFITLINELEN, &::getBooleanCppuType(), 0, 0},
+ EDGERADIUS_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ TEXT_PROPERTIES
+ // #FontWork#
+ FONTWORK_PROPERTIES
+ { MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aCaptionPropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxCustomShapePropertyMap()
+{
+ static SfxItemPropertyMapEntry aCustomShapePropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN("CustomShapeEngine"), SDRATTR_CUSTOMSHAPE_ENGINE, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN("CustomShapeData"), SDRATTR_CUSTOMSHAPE_DATA, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ { MAP_CHAR_LEN("CustomShapeGeometry"), SDRATTR_CUSTOMSHAPE_GEOMETRY, SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >*)0)), 0, 0 },
+ { MAP_CHAR_LEN("CustomShapeGraphicURL"), SDRATTR_CUSTOMSHAPE_REPLACEMENT_URL, &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ CUSTOMSHAPE_PROPERTIES
+ FILL_PROPERTIES
+ LINE_PROPERTIES
+ LINE_PROPERTIES_START_END
+ SHAPE_DESCRIPTOR_PROPERTIES
+ MISC_OBJ_PROPERTIES
+ LINKTARGET_PROPERTIES
+ SHADOW_PROPERTIES
+ TEXT_PROPERTIES
+ {MAP_CHAR_LEN("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+ return aCustomShapePropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxMediaShapePropertyMap()
+{
+ static SfxItemPropertyMapEntry aMediaShapePropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER, &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID, &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME), SDRATTR_LAYERNAME, &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP, &::getCppuType(( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME, &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION, &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 },
+ { MAP_CHAR_LEN("MediaURL"), OWN_ATTR_MEDIA_URL, &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN("PreferredSize"), OWN_ATTR_MEDIA_PREFERREDSIZE, &::getCppuType((const ::com::sun::star::awt::Size*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("Loop"), OWN_ATTR_MEDIA_LOOP, &::getCppuType((const sal_Bool*)0), 0, 0},
+ { MAP_CHAR_LEN("Mute"), OWN_ATTR_MEDIA_MUTE, &::getCppuType((const sal_Bool*)0), 0, 0},
+ { MAP_CHAR_LEN("VolumeDB"), OWN_ATTR_MEDIA_VOLUMEDB, &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN("Zoom"), OWN_ATTR_MEDIA_ZOOM, &::getCppuType((const ::com::sun::star::media::ZoomLevel*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ // #i68101#
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aMediaShapePropertyMap_Impl;
+}
+
+SfxItemPropertyMapEntry* ImplGetSvxTableShapePropertyMap()
+{
+ static SfxItemPropertyMapEntry aTableShapePropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_ZORDER), OWN_ATTR_ZORDER, &::getCppuType((const sal_Int32*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERID), SDRATTR_LAYERID, &::getCppuType((const sal_Int16*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_LAYERNAME), SDRATTR_LAYERNAME, &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), OWN_ATTR_LDBITMAP, &::com::sun::star::awt::XBitmap::static_type(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), OWN_ATTR_LDNAME, &::getCppuType(( const ::rtl::OUString*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("Transformation"), OWN_ATTR_TRANSFORMATION, &::getCppuType((const struct com::sun::star::drawing::HomogenMatrix3*)0), 0, 0 },
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_MOVEPROTECT), SDRATTR_OBJMOVEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_BOUNDRECT), OWN_ATTR_BOUNDRECT, &::getCppuType((const ::com::sun::star::awt::Rectangle*)0), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , &::getCppuType((const ::rtl::OUString*)0), 0, 0},
+ { MAP_CHAR_LEN("Model"), OWN_ATTR_OLEMODEL , &::com::sun::star::table::XTable::static_type(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+ { MAP_CHAR_LEN("TableTemplate"), OWN_ATTR_TABLETEMPLATE , &::com::sun::star::container::XIndexAccess::static_type(), 0, 0},
+ { MAP_CHAR_LEN("UseFirstRowStyle"), OWN_ATTR_TABLETEMPLATE_FIRSTROW, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN("UseLastRowStyle"), OWN_ATTR_TABLETEMPLATE_LASTROW, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN("UseFirstColumnStyle"), OWN_ATTR_TABLETEMPLATE_FIRSTCOLUMN, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN("UseLastColumnStyle"), OWN_ATTR_TABLETEMPLATE_LASTCOLUMN, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN("UseBandingRowStyle"), OWN_ATTR_TABLETEMPLATE_BANDINGROWS, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN("UseBandingColumnStyle"), OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS, &::getBooleanCppuType(),0, 0},
+ { MAP_CHAR_LEN("ReplacementGraphic"), OWN_ATTR_BITMAP, &::com::sun::star::graphic::XGraphic::static_type(), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},
+
+ {0,0,0,0,0,0}
+ };
+
+ return aTableShapePropertyMap_Impl;
+}
+
+comphelper::PropertyMapEntry* ImplGetSvxDrawingDefaultsPropertyMap()
+{
+ static comphelper::PropertyMapEntry aSvxDrawingDefaultsPropertyMap_Impl[] =
+ {
+ SHADOW_PROPERTIES
+ LINE_PROPERTIES_DEFAULTS
+ FILL_PROPERTIES_BMP
+ FILL_PROPERTIES_DEFAULTS
+ EDGERADIUS_PROPERTIES
+ TEXT_PROPERTIES_DEFAULTS
+ CONNECTOR_PROPERTIES
+ SPECIAL_DIMENSIONING_PROPERTIES_DEFAULTS
+ MISC_3D_OBJ_PROPERTIES
+ SPECIAL_3DBACKSCALE_PROPERTIES
+ {0,0,0,0,0,0}
+
+ };
+
+ return aSvxDrawingDefaultsPropertyMap_Impl;
+}
+
+comphelper::PropertyMapEntry* ImplGetAdditionalWriterDrawingDefaultsPropertyMap()
+{
+ static comphelper::PropertyMapEntry aSvxAdditionalDefaultsPropertyMap_Impl[] =
+ {
+ { MAP_CHAR_LEN("IsFollowingTextFlow"), SID_SW_FOLLOW_TEXT_FLOW, &::getBooleanCppuType(), 0, 0},
+ {0,0,0,0,0,0}
+
+ };
+
+ return aSvxAdditionalDefaultsPropertyMap_Impl;
+}
+
+/***********************************************************************
+* class UHashMap *
+***********************************************************************/
+
+typedef ::std::hash_map< rtl::OUString, sal_uInt32, rtl::OUStringHash > UHashMapImpl;
+
+namespace {
+ static const UHashMapImpl &GetUHashImpl()
+ {
+ static UHashMapImpl aImpl(63);
+ static bool bInited = false;
+ if (!bInited) {
+ struct { const char *name; sal_Int32 length; sal_uInt32 id; } aInit[] = {
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.RectangleShape"), OBJ_RECT },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.EllipseShape"), OBJ_CIRC },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ControlShape"), OBJ_UNO },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ConnectorShape"), OBJ_EDGE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MeasureShape"), OBJ_MEASURE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.LineShape"), OBJ_LINE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonShape"), OBJ_POLY },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLineShape"), OBJ_PLIN },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenBezierShape"), OBJ_PATHLINE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedBezierShape"), OBJ_PATHFILL },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OpenFreeHandShape"), OBJ_FREELINE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.ClosedFreeHandShape"), OBJ_FREEFILL },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyPolygonPathShape"), OBJ_PATHPOLY },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PolyLinePathShape"), OBJ_PATHPLIN },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GraphicObjectShape"), OBJ_GRAF },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GroupShape"), OBJ_GRUP },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TextShape"), OBJ_TEXT },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.OLE2Shape"), OBJ_OLE2 },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PageShape"), OBJ_PAGE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.CaptionShape"), OBJ_CAPTION },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.FrameShape"), OBJ_FRAME },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.PluginShape"), OBJ_OLE2_PLUGIN },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.AppletShape"), OBJ_OLE2_APPLET },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.CustomShape"), OBJ_CUSTOMSHAPE },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MediaShape"), OBJ_MEDIA },
+
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSceneObject"), E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DCubeObject"), E3D_CUBEOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DSphereObject"), E3D_SPHEREOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DLatheObject"), E3D_LATHEOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DExtrudeObject"), E3D_EXTRUDEOBJ_ID | E3D_INVENTOR_FLAG },
+ { RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Shape3DPolygonObject"), E3D_POLYGONOBJ_ID | E3D_INVENTOR_FLAG },
+ };
+ for (sal_uInt32 i = 0; i < SAL_N_ELEMENTS(aInit); i++)
+ aImpl[rtl::OUString( aInit[i].name, aInit[i].length, RTL_TEXTENCODING_ASCII_US ) ] = aInit[i].id;
+ bInited = true;
+ }
+ return aImpl;
+ }
+}
+
+//----------------------------------------------------------------------
+rtl::OUString UHashMap::getNameFromId(sal_uInt32 nId)
+{
+ const UHashMapImpl &rMap = GetUHashImpl();
+
+ for (UHashMapImpl::const_iterator it = rMap.begin(); it != rMap.end(); it++)
+ {
+ if (it->second == nId)
+ return it->first;
+ }
+ DBG_ERROR("[CL] unknown SdrObjekt identifier");
+ return rtl::OUString();
+}
+
+uno::Sequence< OUString > UHashMap::getServiceNames()
+{
+ const UHashMapImpl &rMap = GetUHashImpl();
+
+ int i = 0;
+ uno::Sequence< OUString > aSeq( rMap.size() );
+ OUString* pStrings = aSeq.getArray();
+
+ for (UHashMapImpl::const_iterator it = rMap.begin(); it != rMap.end(); it++)
+ pStrings[i++] = it->first;
+
+ return aSeq;
+}
+
+UINT32 UHashMap::getId( const OUString& rCompareString )
+{
+ const UHashMapImpl &rMap = GetUHashImpl();
+ UHashMapImpl::const_iterator it = rMap.find( rCompareString );
+ if( it == rMap.end() )
+ return UHASHMAP_NOTFOUND;
+ else
+ return it->second;
+}
+
+/***********************************************************************
+* class SvxUnoPropertyMapProvider *
+***********************************************************************/
+
+SvxUnoPropertyMapProvider aSvxMapProvider;
+
+EXTERN_C
+#if defined( PM2 ) && (!defined( CSET ) && !defined ( MTW ) && !defined( WTC ))
+int _stdcall
+#else
+#ifdef WNT
+int _cdecl
+#else
+int
+#endif
+#endif
+Svx_CompareMap(const void* pSmaller, const void* pBigger )
+{
+ int nDiff = strcmp( ((const SfxItemPropertyMapEntry*)pSmaller)->pName,
+ ((const SfxItemPropertyMapEntry*)pBigger)->pName );
+ return nDiff;
+}
+
+// ---------------------------------------------------------------------
+
+SvxUnoPropertyMapProvider::SvxUnoPropertyMapProvider()
+{
+ for(UINT16 i=0;i<SVXMAP_END; i++)
+ {
+ aSetArr[i] = 0;
+ aMapArr[i] = 0;
+ }
+}
+
+SvxUnoPropertyMapProvider::~SvxUnoPropertyMapProvider()
+{
+ for(UINT16 i=0;i<SVXMAP_END; i++)
+ delete aSetArr[i];
+}
+
+// ---------------------------------------------------------------------
+
+/*void SvxUnoPropertyMapProvider::Sort(USHORT nId)
+{
+ SfxItemPropertyMapEntry* pTemp = aMapArr[nId];
+ UINT16 i = 0;
+ while(pTemp[i].pName) { i++; }
+ qsort(aMapArr[nId], i, sizeof(SfxItemPropertyMapEntry), Svx_CompareMap);
+}*/
+
+// ---------------------------------------------------------------------
+
+const SfxItemPropertyMapEntry* SvxUnoPropertyMapProvider::GetMap(UINT16 nPropertyId)
+{
+ DBG_ASSERT(nPropertyId < SVXMAP_END, "Id ?" );
+ if(!aMapArr[nPropertyId]) {
+ switch(nPropertyId) {
+ case SVXMAP_SHAPE: aMapArr[SVXMAP_SHAPE]=ImplGetSvxShapePropertyMap(); break;
+ case SVXMAP_CONNECTOR: aMapArr[SVXMAP_CONNECTOR]=ImplGetSvxConnectorPropertyMap(); break;
+ case SVXMAP_DIMENSIONING: aMapArr[SVXMAP_DIMENSIONING]=ImplGetSvxDimensioningPropertyMap(); break;
+ case SVXMAP_CIRCLE: aMapArr[SVXMAP_CIRCLE]=ImplGetSvxCirclePropertyMap(); break;
+ case SVXMAP_POLYPOLYGON: aMapArr[SVXMAP_POLYPOLYGON]=ImplGetSvxPolyPolygonPropertyMap(); break;
+ case SVXMAP_POLYPOLYGONBEZIER: aMapArr[SVXMAP_POLYPOLYGONBEZIER]=ImplGetSvxPolyPolygonBezierPropertyMap(); break;
+ case SVXMAP_GRAPHICOBJECT: aMapArr[SVXMAP_GRAPHICOBJECT]=ImplGetSvxGraphicObjectPropertyMap(); break;
+ case SVXMAP_3DSCENEOBJECT: aMapArr[SVXMAP_3DSCENEOBJECT]=ImplGetSvx3DSceneObjectPropertyMap(); break;
+ case SVXMAP_3DCUBEOBJEKT: aMapArr[SVXMAP_3DCUBEOBJEKT]=ImplGetSvx3DCubeObjectPropertyMap(); break;
+ case SVXMAP_3DSPHEREOBJECT: aMapArr[SVXMAP_3DSPHEREOBJECT]=ImplGetSvx3DSphereObjectPropertyMap(); break;
+ case SVXMAP_3DLATHEOBJECT: aMapArr[SVXMAP_3DLATHEOBJECT]=ImplGetSvx3DLatheObjectPropertyMap(); break;
+ case SVXMAP_3DEXTRUDEOBJECT: aMapArr[SVXMAP_3DEXTRUDEOBJECT]=ImplGetSvx3DExtrudeObjectPropertyMap(); break;
+ case SVXMAP_3DPOLYGONOBJECT: aMapArr[SVXMAP_3DPOLYGONOBJECT]=ImplGetSvx3DPolygonObjectPropertyMap(); break;
+ case SVXMAP_ALL: aMapArr[SVXMAP_ALL]=ImplGetSvxAllPropertyMap(); break;
+ case SVXMAP_GROUP: aMapArr[SVXMAP_GROUP]=ImplGetSvxGroupPropertyMap(); break;
+ case SVXMAP_CAPTION: aMapArr[SVXMAP_CAPTION]=ImplGetSvxCaptionPropertyMap(); break;
+ case SVXMAP_OLE2: aMapArr[SVXMAP_OLE2]=ImplGetSvxOle2PropertyMap(); break;
+ case SVXMAP_PLUGIN: aMapArr[SVXMAP_PLUGIN]=ImplGetSvxPluginPropertyMap(); break;
+ case SVXMAP_FRAME: aMapArr[SVXMAP_FRAME]=ImplGetSvxFramePropertyMap(); break;
+ case SVXMAP_APPLET: aMapArr[SVXMAP_APPLET]=ImplGetSvxAppletPropertyMap(); break;
+ case SVXMAP_CONTROL: aMapArr[SVXMAP_CONTROL]=ImplGetSvxControlShapePropertyMap(); break;
+ case SVXMAP_TEXT: aMapArr[SVXMAP_TEXT]=ImplGetSvxTextShapePropertyMap(); break;
+ case SVXMAP_CUSTOMSHAPE: aMapArr[SVXMAP_CUSTOMSHAPE]=ImplGetSvxCustomShapePropertyMap(); break;
+ case SVXMAP_MEDIA: aMapArr[SVXMAP_MEDIA]=ImplGetSvxMediaShapePropertyMap(); break;
+ case SVXMAP_TABLE: aMapArr[SVXMAP_TABLE]=ImplGetSvxTableShapePropertyMap(); break;
+ case SVXMAP_PAGE: aMapArr[SVXMAP_PAGE] = ImplGetSvxPageShapePropertyMap(); break;
+
+ default:
+ DBG_ERROR( "Unknown property map for SvxUnoPropertyMapProvider!" );
+ }
+// Sort(nPropertyId);
+ }
+ return aMapArr[nPropertyId];
+}
+const SvxItemPropertySet* SvxUnoPropertyMapProvider::GetPropertySet(UINT16 nPropertyId, SfxItemPool& rPool)
+{
+ if( !aSetArr[nPropertyId] )
+ aSetArr[nPropertyId] = new SvxItemPropertySet( GetMap( nPropertyId ), rPool );
+ return aSetArr[nPropertyId];
+}
+
+// #####################################################################
+
+/** maps the API constant MeasureUnit to a vcl MapUnit enum.
+ Returns false if conversion is not supported.
+
+ @cl: for warnings01 I found out that this method never worked so I thin
+ it is not used at all
+sal_Bool SvxMeasureUnitToMapUnit( const short eApi, int& eVcl ) throw()
+{
+ switch( eVcl )
+ {
+ case util::MeasureUnit::MM_100TH: eVcl = MAP_100TH_MM; break;
+ case util::MeasureUnit::MM_10TH: eVcl = MAP_10TH_MM; break;
+ case util::MeasureUnit::MM: eVcl = MAP_MM; break;
+ case util::MeasureUnit::CM: eVcl = MAP_CM; break;
+ case util::MeasureUnit::INCH_1000TH: eVcl = MAP_1000TH_INCH; break;
+ case util::MeasureUnit::INCH_100TH: eVcl = MAP_100TH_INCH; break;
+ case util::MeasureUnit::INCH_10TH: eVcl = MAP_10TH_INCH; break;
+ case util::MeasureUnit::INCH: eVcl = MAP_INCH; break;
+ case util::MeasureUnit::POINT: eVcl = MAP_POINT; break;
+ case util::MeasureUnit::TWIP: eVcl = MAP_TWIP; break;
+ case util::MeasureUnit::PERCENT: eVcl = MAP_RELATIVE; break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+*/
+
+/** maps the vcl MapUnit enum to a API constant MeasureUnit.
+ Returns false if conversion is not supported.
+*/
+sal_Bool SvxMapUnitToMeasureUnit( const short eVcl, short& eApi ) throw()
+{
+ switch( eVcl )
+ {
+ case MAP_100TH_MM: eApi = util::MeasureUnit::MM_100TH; break;
+ case MAP_10TH_MM: eApi = util::MeasureUnit::MM_10TH; break;
+ case MAP_MM: eApi = util::MeasureUnit::MM; break;
+ case MAP_CM: eApi = util::MeasureUnit::CM; break;
+ case MAP_1000TH_INCH: eApi = util::MeasureUnit::INCH_1000TH; break;
+ case MAP_100TH_INCH: eApi = util::MeasureUnit::INCH_100TH; break;
+ case MAP_10TH_INCH: eApi = util::MeasureUnit::INCH_10TH; break;
+ case MAP_INCH: eApi = util::MeasureUnit::INCH; break;
+ case MAP_POINT: eApi = util::MeasureUnit::POINT; break;
+ case MAP_TWIP: eApi = util::MeasureUnit::TWIP; break;
+ case MAP_RELATIVE: eApi = util::MeasureUnit::PERCENT; break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+/** maps the API constant MeasureUnit to a vcl MapUnit enum.
+ Returns false if conversion is not supported.
+*/
+
+sal_Bool SvxMeasureUnitToFieldUnit( const short eApi, short& eVcl ) throw()
+{
+ switch( eApi )
+ {
+ case util::MeasureUnit::MM: eVcl = FUNIT_MM; break;
+ case util::MeasureUnit::CM: eVcl = FUNIT_CM; break;
+ case util::MeasureUnit::M: eVcl = FUNIT_M; break;
+ case util::MeasureUnit::KM: eVcl = FUNIT_KM; break;
+ case util::MeasureUnit::TWIP: eVcl = FUNIT_TWIP; break;
+ case util::MeasureUnit::POINT: eVcl = FUNIT_POINT; break;
+ case util::MeasureUnit::PICA: eVcl = FUNIT_PICA; break;
+ case util::MeasureUnit::INCH: eVcl = FUNIT_INCH; break;
+ case util::MeasureUnit::FOOT: eVcl = FUNIT_FOOT; break;
+ case util::MeasureUnit::MILE: eVcl = FUNIT_MILE; break;
+ case util::MeasureUnit::PERCENT: eVcl = FUNIT_PERCENT; break;
+ case util::MeasureUnit::MM_100TH: eVcl = FUNIT_100TH_MM; break;
+ default:
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+/** maps the vcl MapUnit enum to a API constant MeasureUnit.
+ Returns false if conversion is not supported.
+*/
+sal_Bool SvxFieldUnitToMeasureUnit( const short eVcl, short& eApi ) throw()
+{
+ switch( eVcl )
+ {
+ case FUNIT_MM: eApi = util::MeasureUnit::MM; break;
+ case FUNIT_CM: eApi = util::MeasureUnit::CM; break;
+ case FUNIT_M: eApi = util::MeasureUnit::M; break;
+ case FUNIT_KM: eApi = util::MeasureUnit::KM; break;
+ case FUNIT_TWIP: eApi = util::MeasureUnit::TWIP; break;
+ case FUNIT_POINT: eApi = util::MeasureUnit::POINT; break;
+ case FUNIT_PICA: eApi = util::MeasureUnit::PICA; break;
+ case FUNIT_INCH: eApi = util::MeasureUnit::INCH; break;
+ case FUNIT_FOOT: eApi = util::MeasureUnit::FOOT; break;
+ case FUNIT_MILE: eApi = util::MeasureUnit::MILE; break;
+ case FUNIT_PERCENT: eApi = util::MeasureUnit::PERCENT; break;
+ case FUNIT_100TH_MM: eApi = util::MeasureUnit::MM_100TH; break;
+ default:
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+bool SvxUnoGetResourceRanges( const short nWhich, int& nApiResIds, int& nIntResIds, int& nCount ) throw()
+{
+ switch( nWhich )
+ {
+ case XATTR_FILLBITMAP:
+ nApiResIds = RID_SVXSTR_BMP_DEF_START;
+ nIntResIds = RID_SVXSTR_BMP_START;
+ nCount = RID_SVXSTR_BMP_DEF_END - RID_SVXSTR_BMP_DEF_START + 1;
+ break;
+
+ case XATTR_LINEDASH:
+ nApiResIds = RID_SVXSTR_DASH_DEF_START;
+ nIntResIds = RID_SVXSTR_DASH_START;
+ nCount = RID_SVXSTR_DASH_DEF_END - RID_SVXSTR_DASH_DEF_START + 1;
+ break;
+
+ case XATTR_LINESTART:
+ case XATTR_LINEEND:
+ nApiResIds = RID_SVXSTR_LEND_DEF_START;
+ nIntResIds = RID_SVXSTR_LEND_START;
+ nCount = RID_SVXSTR_LEND_DEF_END - RID_SVXSTR_LEND_DEF_START + 1;
+ break;
+
+ case XATTR_FILLGRADIENT:
+ nApiResIds = RID_SVXSTR_GRDT_DEF_START;
+ nIntResIds = RID_SVXSTR_GRDT_START;
+ nCount = RID_SVXSTR_GRDT_DEF_END - RID_SVXSTR_GRDT_DEF_START + 1;
+ break;
+
+ case XATTR_FILLHATCH:
+ nApiResIds = RID_SVXSTR_HATCH_DEF_START;
+ nIntResIds = RID_SVXSTR_HATCH_START;
+ nCount = RID_SVXSTR_HATCH_DEF_END - RID_SVXSTR_HATCH_DEF_START + 1;
+ break;
+
+ case XATTR_FILLFLOATTRANSPARENCE:
+ nApiResIds = RID_SVXSTR_TRASNGR_DEF_START;
+ nIntResIds = RID_SVXSTR_TRASNGR_START;
+ nCount = RID_SVXSTR_TRASNGR_DEF_END - RID_SVXSTR_TRASNGR_DEF_START + 1;
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*sal_Int16 SvxUnoGetWhichIdForNamedProperty( const ::rtl::OUString & rPropName )
+{
+ sal_Int16 nWhich = 0;
+
+ const SfxItemPropertyMapEntry* pMap = aSvxMapProvider.GetMap( SVXMAP_SHAPE );
+ if( pMap )
+ {
+ const SfxItemPropertyMapEntry* pFound = SfxItemPropertyMapEntry::getByName( pMap, rPropName );
+ if( pFound )
+ nWhich = pFound->nWID;
+ }
+
+ return nWhich;
+} */
+
+bool SvxUnoConvertResourceString( int nSourceResIds, int nDestResIds, int nCount, String& rString ) throw()
+{
+ // first, calculate the search string length without an optional number behind the name
+ xub_StrLen nLength = rString.Len();
+ while( nLength > 0 )
+ {
+ const sal_Unicode nChar = rString.GetChar( nLength - 1 );
+ if( (nChar < '0') || (nChar > '9') )
+ break;
+
+ nLength--;
+ }
+
+ // if we cut off a number, also cut of some spaces
+ if( nLength != rString.Len() )
+ {
+ while( nLength > 0 )
+ {
+ const sal_Unicode nChar = rString.GetChar( nLength - 1 );
+ if( nChar != ' ' )
+ break;
+
+ nLength--;
+ }
+ }
+
+ const String aShortString( rString.Copy( 0, nLength ) );
+
+ int i;
+ for( i = 0; i < nCount; i++ )
+ {
+ USHORT nResId = (USHORT)(nSourceResIds + i);
+ const ResId aRes( SVX_RES(nResId));
+ const String aCompare( aRes );
+ if( aShortString == aCompare )
+ {
+ USHORT nNewResId = (USHORT)(nDestResIds + i);
+ ResId aNewRes( SVX_RES( nNewResId ));
+ rString.Replace( 0, aShortString.Len(), String( aNewRes ) );
+ return TRUE;
+ }
+ else if( rString == aCompare )
+ {
+ USHORT nNewResId = (USHORT)(nDestResIds + i);
+ ResId aNewRes( SVX_RES( nNewResId ));
+ rString = String( aNewRes );
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static USHORT __READONLY_DATA SvxUnoColorNameDefResId[] =
+{
+ RID_SVXSTR_BLUEGREY_DEF,
+ RID_SVXSTR_BLACK_DEF,
+ RID_SVXSTR_BLUE_DEF,
+ RID_SVXSTR_GREEN_DEF,
+ RID_SVXSTR_CYAN_DEF,
+ RID_SVXSTR_RED_DEF,
+ RID_SVXSTR_MAGENTA_DEF,
+ RID_SVXSTR_BROWN_DEF,
+ RID_SVXSTR_GREY_DEF,
+ RID_SVXSTR_LIGHTGREY_DEF,
+ RID_SVXSTR_LIGHTBLUE_DEF,
+ RID_SVXSTR_LIGHTGREEN_DEF,
+ RID_SVXSTR_LIGHTCYAN_DEF,
+ RID_SVXSTR_LIGHTRED_DEF,
+ RID_SVXSTR_LIGHTMAGENTA_DEF,
+ RID_SVXSTR_YELLOW_DEF,
+ RID_SVXSTR_WHITE_DEF,
+ RID_SVXSTR_ORANGE_DEF,
+ RID_SVXSTR_VIOLET_DEF,
+ RID_SVXSTR_BORDEAUX_DEF,
+ RID_SVXSTR_PALE_YELLOW_DEF,
+ RID_SVXSTR_PALE_GREEN_DEF,
+ RID_SVXSTR_DKVIOLET_DEF,
+ RID_SVXSTR_SALMON_DEF,
+ RID_SVXSTR_SEABLUE_DEF,
+ RID_SVXSTR_COLOR_SUN_DEF,
+ RID_SVXSTR_COLOR_CHART_DEF
+};
+
+static USHORT __READONLY_DATA SvxUnoColorNameResId[] =
+{
+ RID_SVXSTR_BLUEGREY,
+ RID_SVXSTR_BLACK,
+ RID_SVXSTR_BLUE,
+ RID_SVXSTR_GREEN,
+ RID_SVXSTR_CYAN,
+ RID_SVXSTR_RED,
+ RID_SVXSTR_MAGENTA,
+ RID_SVXSTR_BROWN,
+ RID_SVXSTR_GREY,
+ RID_SVXSTR_LIGHTGREY,
+ RID_SVXSTR_LIGHTBLUE,
+ RID_SVXSTR_LIGHTGREEN,
+ RID_SVXSTR_LIGHTCYAN,
+ RID_SVXSTR_LIGHTRED,
+ RID_SVXSTR_LIGHTMAGENTA,
+ RID_SVXSTR_YELLOW,
+ RID_SVXSTR_WHITE,
+ RID_SVXSTR_ORANGE,
+ RID_SVXSTR_VIOLET,
+ RID_SVXSTR_BORDEAUX,
+ RID_SVXSTR_PALE_YELLOW,
+ RID_SVXSTR_PALE_GREEN,
+ RID_SVXSTR_DKVIOLET,
+ RID_SVXSTR_SALMON,
+ RID_SVXSTR_SEABLUE,
+ RID_SVXSTR_COLOR_SUN,
+ RID_SVXSTR_COLOR_CHART
+};
+
+bool SvxUnoConvertResourceString( USHORT* pSourceResIds, USHORT* pDestResIds, int nCount, String& rString ) throw()
+{
+ //We replace e.g. "Gray 10%" with the translation of Gray, but we shouldn't
+ //replace "Red Hat 1" with the translation of Red :-)
+ rtl::OUString sStr(rString);
+ const sal_Unicode *pStr = sStr.getStr();
+ sal_Int32 nLength = sStr.getLength();
+ while( nLength > 0 )
+ {
+ const sal_Unicode nChar = pStr[nLength-1];
+ if (nChar != '%' && (nChar < '0' || nChar > '9'))
+ break;
+ nLength--;
+ }
+ sStr = rtl::OUString(pStr, nLength).trim();
+
+ for(int i = 0; i < nCount; ++i )
+ {
+ String aStrDefName = SVX_RESSTR( pSourceResIds[i] );
+ if( sStr.equals( aStrDefName ) )
+ {
+ String aReplace = SVX_RESSTR( pDestResIds[i] );
+ rString.Replace( 0, aStrDefName.Len(), aReplace );
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/** if the given name is a predefined name for the current language it is replaced by
+ the corresponding api name.
+*/
+void SvxUnogetApiNameForItem( const sal_Int16 nWhich, const String& rInternalName, rtl::OUString& rApiName ) throw()
+{
+#ifndef SVX_LIGHT
+ String aNew = rInternalName;
+
+ if( nWhich == XATTR_LINECOLOR )
+ {
+ if( SvxUnoConvertResourceString( (USHORT*)SvxUnoColorNameResId, (USHORT*)SvxUnoColorNameDefResId, sizeof( SvxUnoColorNameResId ) / sizeof( USHORT ), aNew ) )
+ {
+ rApiName = aNew;
+ return;
+ }
+ }
+ else
+ {
+ int nApiResIds;
+ int nIntResIds;
+ int nCount;
+
+ if( SvxUnoGetResourceRanges( nWhich, nApiResIds, nIntResIds, nCount ) )
+ {
+ if(SvxUnoConvertResourceString( nIntResIds, nApiResIds, nCount, aNew ) )
+ {
+ rApiName = aNew;
+ return;
+ }
+ }
+ }
+#endif
+
+ // just use previous name, if nothing else was found.
+ rApiName = rInternalName;
+}
+
+/** if the given name is a predefined api name it is replaced by the predefined name
+ for the current language.
+*/
+void SvxUnogetInternalNameForItem( const sal_Int16 nWhich, const rtl::OUString& rApiName, String& rInternalName ) throw()
+{
+#ifndef SVX_LIGHT
+ String aNew = rApiName;
+
+ if( nWhich == XATTR_LINECOLOR )
+ {
+ if( SvxUnoConvertResourceString( (USHORT*)SvxUnoColorNameDefResId, (USHORT*)SvxUnoColorNameResId, sizeof( SvxUnoColorNameResId ) / sizeof( USHORT ), aNew ) )
+ {
+ rInternalName = aNew;
+ return;
+ }
+ }
+ else
+ {
+ int nApiResIds;
+ int nIntResIds;
+ int nCount;
+
+ if( SvxUnoGetResourceRanges( nWhich, nApiResIds, nIntResIds, nCount ) )
+ {
+ if(SvxUnoConvertResourceString( nApiResIds, nIntResIds, nCount, aNew ) )
+ {
+ rInternalName = aNew;
+ return;
+ }
+ }
+ }
+#endif // !SVX_LIGHT
+
+ // just use previous name, if nothing else was found.
+ rInternalName = rApiName;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+comphelper::PropertySetInfo* SvxPropertySetInfoPool::getOrCreate( sal_Int32 nServiceId ) throw()
+{
+ SolarMutexGuard aGuard;
+
+ if( nServiceId > SVXUNO_SERVICEID_LASTID )
+ {
+ DBG_ERROR( "unknown service id!" );
+ return NULL;
+ }
+
+ if( mpInfos[ nServiceId ] == NULL )
+ {
+ mpInfos[nServiceId] = new comphelper::PropertySetInfo();
+ mpInfos[nServiceId]->acquire();
+
+ switch( nServiceId )
+ {
+ case SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS:
+ mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS]->add( ImplGetSvxDrawingDefaultsPropertyMap() );
+ break;
+ case SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER:
+ mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->add( ImplGetSvxDrawingDefaultsPropertyMap() );
+ mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->remove( OUString( RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_EDIT_PARA_IS_HANGING_PUNCTUATION ) ) );
+ // OD 13.10.2003 #i18732# - add property map for writer item 'IsFollowingTextFlow'
+ mpInfos[SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER]->add( ImplGetAdditionalWriterDrawingDefaultsPropertyMap() );
+ break;
+
+ default:
+ DBG_ERROR( "unknown service id!" );
+ }
+ }
+
+ return mpInfos[ nServiceId ];
+}
+
+comphelper::PropertySetInfo* SvxPropertySetInfoPool::mpInfos[SVXUNO_SERVICEID_LASTID+1] = { NULL };
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
new file mode 100644
index 000000000000..c5e4b01af85f
--- /dev/null
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -0,0 +1,2147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define _SVX_USE_UNOGLOBALS_
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+#include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/drawing/PointSequenceSequence.hpp>
+#include <com/sun/star/drawing/PointSequence.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <tools/urlobj.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <svtools/fltcall.hxx>
+#include <svtools/filter.hxx>
+
+#include <boost/scoped_ptr.hpp>
+#include <svx/svdpool.hxx>
+#include <rtl/uuid.h>
+#include <rtl/memory.h>
+#include <tools/urlobj.hxx>
+
+#include <editeng/unoprnms.hxx>
+#include <svx/unoshape.hxx>
+#include <svx/unopage.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdouno.hxx>
+#include "shapeimpl.hxx"
+#include "svx/unoshprp.hxx"
+#include <svx/svdoashp.hxx>
+#include "unopolyhelper.hxx"
+
+// #i29181#
+#include "svdviter.hxx"
+#include <svx/svdview.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+using ::rtl::OUString;
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+
+#define INTERFACE_TYPE( xint ) \
+ ::getCppuType((const Reference< xint >*)0)
+
+#define QUERYINT( xint ) \
+ if( rType == ::getCppuType((const Reference< xint >*)0) ) \
+ aAny <<= Reference< xint >(this)
+
+class GDIMetaFile;
+class SvStream;
+sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
+ FilterConfigItem* pFilterConfigItem = NULL, sal_Bool bPlaceable = sal_True );
+
+/***********************************************************************
+* class SvxShapeGroup *
+***********************************************************************/
+
+SvxShapeGroup::SvxShapeGroup( SdrObject* pObj, SvxDrawPage* pDrawPage ) throw() :
+ SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_GROUP), aSvxMapProvider.GetPropertySet(SVXMAP_GROUP, SdrObject::GetGlobalDrawObjectItemPool()) ),
+ mxPage( pDrawPage )
+{
+}
+
+//----------------------------------------------------------------------
+SvxShapeGroup::~SvxShapeGroup() throw()
+{
+}
+
+//----------------------------------------------------------------------
+void SvxShapeGroup::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
+{
+ SvxShape::Create( pNewObj, pNewPage );
+ mxPage = pNewPage;
+}
+
+//----------------------------------------------------------------------
+uno::Any SAL_CALL SvxShapeGroup::queryInterface( const uno::Type & rType )
+ throw(uno::RuntimeException)
+{
+ return SvxShape::queryInterface( rType );
+}
+
+uno::Any SAL_CALL SvxShapeGroup::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
+{
+ uno::Any aAny;
+
+ QUERYINT( drawing::XShapeGroup );
+ else QUERYINT( drawing::XShapes );
+ else QUERYINT( container::XIndexAccess );
+ else QUERYINT( container::XElementAccess );
+ else
+ return SvxShape::queryAggregation( rType );
+
+ return aAny;
+}
+
+void SAL_CALL SvxShapeGroup::acquire() throw ( )
+{
+ SvxShape::acquire();
+}
+
+void SAL_CALL SvxShapeGroup::release() throw ( )
+{
+ SvxShape::release();
+}
+
+uno::Sequence< uno::Type > SAL_CALL SvxShapeGroup::getTypes()
+ throw (uno::RuntimeException)
+{
+ return SvxShape::getTypes();
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL SvxShapeGroup::getImplementationId()
+ throw (uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// ::com::sun::star::drawing::XShape
+
+//----------------------------------------------------------------------
+OUString SAL_CALL SvxShapeGroup::getShapeType()
+ throw( uno::RuntimeException )
+{
+ return SvxShape::getShapeType();
+}
+
+//------------------------------------------------------------------1----
+awt::Point SAL_CALL SvxShapeGroup::getPosition() throw(uno::RuntimeException)
+{
+ return SvxShape::getPosition();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeGroup::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
+{
+ SvxShape::setPosition(Position);
+}
+
+//----------------------------------------------------------------------
+
+awt::Size SAL_CALL SvxShapeGroup::getSize() throw(uno::RuntimeException)
+{
+ return SvxShape::getSize();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeGroup::setSize( const awt::Size& rSize )
+ throw(beans::PropertyVetoException, uno::RuntimeException)
+{
+ SvxShape::setSize( rSize );
+}
+
+// drawing::XShapeGroup
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeGroup::enterGroup( ) throw(uno::RuntimeException)
+{
+ // Todo
+// pDrView->EnterMarkedGroup();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeGroup::leaveGroup( ) throw(uno::RuntimeException)
+{
+ // Todo
+// pDrView->LeaveOneGroup();
+}
+
+//----------------------------------------------------------------------
+
+// XShapes
+void SAL_CALL SvxShapeGroup::add( const uno::Reference< drawing::XShape >& xShape )
+ throw( uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+
+ if( mpObj.is()&& mxPage.is() && pShape )
+ {
+ SdrObject* pSdrShape = pShape->GetSdrObject();
+ if( pSdrShape == NULL )
+ pSdrShape = mxPage->_CreateSdrObject( xShape );
+
+ if( pSdrShape->IsInserted() )
+ pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
+
+ mpObj->GetSubList()->InsertObject( pSdrShape );
+ pSdrShape->SetModel(mpObj->GetModel());
+
+ // #85922# It makes no sense to set the layer asked
+ // from the group object since these is an iteration
+ // over the contained objects. In consequence, this
+ // statement erases all layer information from the draw
+ // objects. Layers need to be set at draw objects directly
+ // and have nothing to do with grouping at all.
+ // pSdrShape->SetLayer(pObject->GetLayer());
+
+ // Establish connection between new SdrObject and its wrapper before
+ // inserting the new shape into the group. There a new wrapper
+ // would be created when this connection would not already exist.
+ pShape->Create( pSdrShape, mxPage.get() );
+
+ if( mpModel )
+ mpModel->SetChanged();
+ }
+ else
+ {
+ DBG_ERROR("could not add XShape to group shape!");
+ }
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xShape )
+ throw( uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ SdrObject* pSdrShape = NULL;
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+
+ if( pShape )
+ pSdrShape = pShape->GetSdrObject();
+
+ if( !mpObj.is() || pSdrShape == NULL || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get() )
+ throw uno::RuntimeException();
+
+ SdrObjList& rList = *pSdrShape->GetObjList();
+
+ const sal_uInt32 nObjCount = rList.GetObjCount();
+ sal_uInt32 nObjNum = 0;
+ while( nObjNum < nObjCount )
+ {
+ if(rList.GetObj( nObjNum ) == pSdrShape )
+ break;
+ nObjNum++;
+ }
+
+ if( nObjNum < nObjCount )
+ {
+ // #i29181#
+ // If the SdrObject which is about to be deleted is in any selection,
+ // deselect it first.
+ SdrViewIter aIter( pSdrShape );
+
+ for ( SdrView* pView = aIter.FirstView(); pView; pView = aIter.NextView() )
+ {
+ if(CONTAINER_ENTRY_NOTFOUND != pView->TryToFindMarkedObject(pSdrShape))
+ {
+ pView->MarkObj(pSdrShape, pView->GetSdrPageView(), sal_True, sal_False);
+ }
+ }
+
+ SdrObject* pObject = rList.NbcRemoveObject( nObjNum );
+ SdrObject::Free( pObject );
+ }
+ else
+ {
+ DBG_ASSERT( 0, "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
+ }
+
+ if( mpModel )
+ mpModel->SetChanged();
+}
+
+// XIndexAccess
+
+//----------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShapeGroup::getCount() throw( uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ sal_Int32 nRetval = 0;
+
+ if(mpObj.is() && mpObj->GetSubList())
+ nRetval = mpObj->GetSubList()->GetObjCount();
+ else
+ throw uno::RuntimeException();
+
+ return nRetval;
+}
+
+//----------------------------------------------------------------------
+uno::Any SAL_CALL SvxShapeGroup::getByIndex( sal_Int32 Index )
+ throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( !mpObj.is() || mpObj->GetSubList() == NULL )
+ throw uno::RuntimeException();
+
+ if( mpObj->GetSubList()->GetObjCount() <= (sal_uInt32)Index )
+ throw lang::IndexOutOfBoundsException();
+
+ SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index );
+
+ if(pDestObj == NULL)
+ throw lang::IndexOutOfBoundsException();
+
+ Reference< drawing::XShape > xShape( pDestObj->getUnoShape(), uno::UNO_QUERY );
+ return uno::makeAny( xShape );
+}
+
+// ::com::sun::star::container::XElementAccess
+
+//----------------------------------------------------------------------
+uno::Type SAL_CALL SvxShapeGroup::getElementType() throw( uno::RuntimeException )
+{
+ return ::getCppuType(( const Reference< drawing::XShape >*)0);
+}
+
+//----------------------------------------------------------------------
+sal_Bool SAL_CALL SvxShapeGroup::hasElements() throw( uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
+}
+
+//----------------------------------------------------------------------
+// ::com::sun::star::lang::XServiceInfo
+
+uno::Sequence< OUString > SAL_CALL SvxShapeGroup::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ return SvxShape::getSupportedServiceNames();
+}
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+SvxShapeConnector::SvxShapeConnector( SdrObject* pObj ) throw() :
+ SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CONNECTOR), aSvxMapProvider.GetPropertySet(SVXMAP_CONNECTOR, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+//----------------------------------------------------------------------
+SvxShapeConnector::~SvxShapeConnector() throw()
+{
+}
+
+//----------------------------------------------------------------------
+
+uno::Any SAL_CALL SvxShapeConnector::queryInterface( const uno::Type & rType )
+ throw(uno::RuntimeException)
+{
+ return SvxShapeText::queryInterface( rType );
+}
+
+uno::Any SAL_CALL SvxShapeConnector::queryAggregation( const uno::Type & rType )
+ throw(uno::RuntimeException)
+{
+ uno::Any aAny;
+
+ QUERYINT( drawing::XConnectorShape );
+ else
+ return SvxShapeText::queryAggregation( rType );
+
+ return aAny;
+}
+
+void SAL_CALL SvxShapeConnector::acquire() throw ( )
+{
+ SvxShapeText::acquire();
+}
+
+void SAL_CALL SvxShapeConnector::release() throw ( )
+{
+ SvxShapeText::release();
+}
+// XTypeProvider
+
+uno::Sequence< uno::Type > SAL_CALL SvxShapeConnector::getTypes()
+ throw (uno::RuntimeException)
+{
+ return SvxShape::getTypes();
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL SvxShapeConnector::getImplementationId()
+ throw (uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// ::com::sun::star::drawing::XShape
+
+//----------------------------------------------------------------------
+OUString SAL_CALL SvxShapeConnector::getShapeType()
+ throw( uno::RuntimeException )
+{
+ return SvxShapeText::getShapeType();
+}
+
+//------------------------------------------------------------------1----
+awt::Point SAL_CALL SvxShapeConnector::getPosition() throw(uno::RuntimeException)
+{
+ return SvxShapeText::getPosition();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeConnector::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
+{
+ SvxShapeText::setPosition(Position);
+}
+
+//----------------------------------------------------------------------
+
+awt::Size SAL_CALL SvxShapeConnector::getSize() throw(uno::RuntimeException)
+{
+ return SvxShapeText::getSize();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeConnector::setSize( const awt::Size& rSize )
+ throw(beans::PropertyVetoException, uno::RuntimeException)
+{
+ SvxShapeText::setSize( rSize );
+}
+
+//----------------------------------------------------------------------
+
+// XConnectorShape
+
+void SAL_CALL SvxShapeConnector::connectStart( const uno::Reference< drawing::XConnectableShape >& xShape, drawing::ConnectionType ) throw( uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
+ SvxShape* pShape = SvxShape::getImplementation( xRef );
+
+ if( pShape )
+ mpObj->ConnectToNode( sal_True, pShape->mpObj.get() );
+
+ if( mpModel )
+ mpModel->SetChanged();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeConnector::connectEnd( const uno::Reference< drawing::XConnectableShape >& xShape, drawing::ConnectionType )
+ throw( uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
+ SvxShape* pShape = SvxShape::getImplementation( xRef );
+
+ if( mpObj.is() && pShape )
+ mpObj->ConnectToNode( sal_False, pShape->mpObj.get() );
+
+ if( mpModel )
+ mpModel->SetChanged();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeConnector::disconnectBegin( const uno::Reference< drawing::XConnectableShape >& )
+ throw( uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if(mpObj.is())
+ mpObj->DisconnectFromNode( sal_True );
+
+ if( mpModel )
+ mpModel->SetChanged();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeConnector::disconnectEnd( const uno::Reference< drawing::XConnectableShape >& )
+ throw( uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if(mpObj.is())
+ mpObj->DisconnectFromNode( sal_False );
+
+ if( mpModel )
+ mpModel->SetChanged();
+}
+
+//----------------------------------------------------------------------
+// ::com::sun::star::lang::XServiceInfo
+//----------------------------------------------------------------------
+uno::Sequence< OUString > SAL_CALL SvxShapeConnector::getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ return SvxShapeText::getSupportedServiceNames();
+}
+
+/***********************************************************************
+* class SvxShapeControl *
+***********************************************************************/
+DBG_NAME(SvxShapeControl)
+
+SvxShapeControl::SvxShapeControl( SdrObject* pObj ) throw() :
+ SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CONTROL), aSvxMapProvider.GetPropertySet(SVXMAP_CONTROL, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+ DBG_CTOR(SvxShapeControl,NULL);
+ setShapeKind( OBJ_UNO );
+}
+
+//----------------------------------------------------------------------
+SvxShapeControl::~SvxShapeControl() throw()
+{
+ DBG_DTOR(SvxShapeControl,NULL);
+}
+
+//----------------------------------------------------------------------
+uno::Any SAL_CALL SvxShapeControl::queryInterface( const uno::Type & rType )
+ throw(uno::RuntimeException)
+{
+ return SvxShapeText::queryInterface( rType );
+}
+
+uno::Any SAL_CALL SvxShapeControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
+{
+ uno::Any aAny;
+
+ QUERYINT( drawing::XControlShape );
+ else
+ return SvxShapeText::queryAggregation( rType );
+
+ return aAny;
+}
+
+void SAL_CALL SvxShapeControl::acquire() throw ( )
+{
+ SvxShapeText::acquire();
+}
+
+void SAL_CALL SvxShapeControl::release() throw ( )
+{
+ SvxShapeText::release();
+}
+// XTypeProvider
+
+uno::Sequence< uno::Type > SAL_CALL SvxShapeControl::getTypes()
+ throw (uno::RuntimeException)
+{
+ return SvxShape::getTypes();
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL SvxShapeControl::getImplementationId()
+ throw (uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// ::com::sun::star::drawing::XShape
+
+//----------------------------------------------------------------------
+OUString SAL_CALL SvxShapeControl::getShapeType()
+ throw( uno::RuntimeException )
+{
+ return SvxShapeText::getShapeType();
+}
+
+//------------------------------------------------------------------1----
+awt::Point SAL_CALL SvxShapeControl::getPosition() throw(uno::RuntimeException)
+{
+ return SvxShapeText::getPosition();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeControl::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
+{
+ SvxShapeText::setPosition(Position);
+}
+
+//----------------------------------------------------------------------
+
+awt::Size SAL_CALL SvxShapeControl::getSize() throw(uno::RuntimeException)
+{
+ return SvxShapeText::getSize();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeControl::setSize( const awt::Size& rSize )
+ throw(beans::PropertyVetoException, uno::RuntimeException)
+{
+ SvxShapeText::setSize( rSize );
+}
+
+//----------------------------------------------------------------------
+// XControlShape
+
+Reference< awt::XControlModel > SAL_CALL SvxShapeControl::getControl()
+ throw( uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ Reference< awt::XControlModel > xModel;
+
+ SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
+ if( pUnoObj )
+ xModel = pUnoObj->GetUnoControlModel();
+
+ return xModel;
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeControl::setControl( const Reference< awt::XControlModel >& xControl )
+ throw( uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
+ if( pUnoObj )
+ pUnoObj->SetUnoControlModel( xControl );
+
+ if( mpModel )
+ mpModel->SetChanged();
+}
+
+// XServiceInfo
+uno::Sequence< OUString > SAL_CALL SvxShapeControl::getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ return SvxShapeText::getSupportedServiceNames();
+}
+
+static struct
+{
+ const sal_Char* mpAPIName;
+ sal_uInt16 mnAPINameLen;
+
+ const sal_Char* mpFormName;
+ sal_uInt16 mnFormNameLen;
+}
+SvxShapeControlPropertyMapping[] =
+{
+ // Warning: The first entry must be FontSlant because the any needs to be converted
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_POSTURE), MAP_CHAR_LEN("FontSlant") }, // const sal_Int16 => ::com::sun::star::awt::FontSlant
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTNAME), MAP_CHAR_LEN("FontName") },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTSTYLENAME), MAP_CHAR_LEN("FontStyleName") },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTFAMILY), MAP_CHAR_LEN("FontFamily") },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTCHARSET), MAP_CHAR_LEN("FontCharset") },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_HEIGHT), MAP_CHAR_LEN("FontHeight") },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_FONTPITCH), MAP_CHAR_LEN("FontPitch" ) },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_WEIGHT), MAP_CHAR_LEN("FontWeight" ) },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_UNDERLINE), MAP_CHAR_LEN("FontUnderline") },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_STRIKEOUT), MAP_CHAR_LEN("FontStrikeout") },
+ { MAP_CHAR_LEN("CharKerning"), MAP_CHAR_LEN("FontKerning") },
+ { MAP_CHAR_LEN("CharWordMode"), MAP_CHAR_LEN("FontWordLineMode" ) },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_CHAR_COLOR), MAP_CHAR_LEN("TextColor") },
+ { MAP_CHAR_LEN("CharRelief"), MAP_CHAR_LEN("FontRelief") },
+ { MAP_CHAR_LEN("CharUnderlineColor"), MAP_CHAR_LEN("TextLineColor") },
+ { MAP_CHAR_LEN(UNO_NAME_EDIT_PARA_ADJUST), MAP_CHAR_LEN("Align") },
+ { MAP_CHAR_LEN("TextVerticalAdjust"), MAP_CHAR_LEN("VerticalAlign") },
+ { MAP_CHAR_LEN("ControlBackground"), MAP_CHAR_LEN("BackgroundColor") },
+ { MAP_CHAR_LEN("ControlSymbolColor"), MAP_CHAR_LEN("SymbolColor") },
+ { MAP_CHAR_LEN("ControlBorder"), MAP_CHAR_LEN("Border") },
+ { MAP_CHAR_LEN("ControlBorderColor"), MAP_CHAR_LEN("BorderColor") },
+ { MAP_CHAR_LEN("ControlTextEmphasis"), MAP_CHAR_LEN("FontEmphasisMark") },
+ { MAP_CHAR_LEN("ImageScaleMode"), MAP_CHAR_LEN("ScaleMode") },
+ { MAP_CHAR_LEN("ControlWritingMode"), MAP_CHAR_LEN("WritingMode") },
+ { NULL,0, NULL, 0 }
+};
+
+namespace
+{
+ static bool lcl_convertPropertyName( const OUString& rApiName, OUString& rInternalName )
+ {
+ sal_uInt16 i = 0;
+ while( SvxShapeControlPropertyMapping[i].mpAPIName )
+ {
+ if( rApiName.reverseCompareToAsciiL( SvxShapeControlPropertyMapping[i].mpAPIName, SvxShapeControlPropertyMapping[i].mnAPINameLen ) == 0 )
+ {
+ rInternalName = OUString( SvxShapeControlPropertyMapping[i].mpFormName, SvxShapeControlPropertyMapping[i].mnFormNameLen, RTL_TEXTENCODING_ASCII_US );
+ }
+ ++i;
+ }
+ return rInternalName.getLength() > 0;
+ }
+
+ struct EnumConversionMap
+ {
+ sal_Int16 nAPIValue;
+ sal_Int16 nFormValue;
+ };
+
+ EnumConversionMap aMapAdjustToAlign[] =
+ {
+ // note that order matters:
+ // lcl_convertTextAlignmentToParaAdjustment and lcl_convertParaAdjustmentToTextAlignment search this map from the _beginning_
+ // and use the first matching entry
+ {style::ParagraphAdjust_LEFT, (sal_Int16)awt::TextAlign::LEFT},
+ {style::ParagraphAdjust_CENTER, (sal_Int16)awt::TextAlign::CENTER},
+ {style::ParagraphAdjust_RIGHT, (sal_Int16)awt::TextAlign::RIGHT},
+ {style::ParagraphAdjust_BLOCK, (sal_Int16)awt::TextAlign::RIGHT},
+ {style::ParagraphAdjust_STRETCH, (sal_Int16)awt::TextAlign::LEFT},
+ {-1,-1}
+ };
+
+ static void lcl_mapFormToAPIValue( Any& _rValue, const EnumConversionMap* _pMap )
+ {
+ sal_Int16 nValue = sal_Int16();
+ OSL_VERIFY( _rValue >>= nValue );
+
+ const EnumConversionMap* pEntry = _pMap;
+ while ( pEntry && ( pEntry->nFormValue != -1 ) )
+ {
+ if ( nValue == pEntry->nFormValue )
+ {
+ _rValue <<= pEntry->nAPIValue;
+ return;
+ }
+ ++pEntry;
+ }
+ }
+
+ static void lcl_mapAPIToFormValue( Any& _rValue, const EnumConversionMap* _pMap )
+ {
+ sal_Int32 nValue = 0;
+ OSL_VERIFY( _rValue >>= nValue );
+
+ const EnumConversionMap* pEntry = _pMap;
+ while ( pEntry && ( pEntry->nAPIValue != -1 ) )
+ {
+ if ( nValue == pEntry->nAPIValue )
+ {
+ _rValue <<= pEntry->nFormValue;
+ return;
+ }
+ ++pEntry;
+ }
+ }
+
+ static void lcl_convertTextAlignmentToParaAdjustment( Any& rValue )
+ {
+ lcl_mapFormToAPIValue( rValue, aMapAdjustToAlign );
+ }
+
+ static void lcl_convertParaAdjustmentToTextAlignment( Any& rValue )
+ {
+ lcl_mapAPIToFormValue( rValue, aMapAdjustToAlign );
+ }
+
+ void convertVerticalAdjustToVerticalAlign( Any& _rValue ) SAL_THROW( ( lang::IllegalArgumentException ) )
+ {
+ if ( !_rValue.hasValue() )
+ return;
+
+ drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
+ style::VerticalAlignment eAlign = style::VerticalAlignment_TOP;
+ if ( !( _rValue >>= eAdjust ) )
+ throw lang::IllegalArgumentException();
+ switch ( eAdjust )
+ {
+ case drawing::TextVerticalAdjust_TOP: eAlign = style::VerticalAlignment_TOP; break;
+ case drawing::TextVerticalAdjust_BOTTOM: eAlign = style::VerticalAlignment_BOTTOM; break;
+ default: eAlign = style::VerticalAlignment_MIDDLE; break;
+ }
+ _rValue <<= eAlign;
+ }
+
+ void convertVerticalAlignToVerticalAdjust( Any& _rValue )
+ {
+ if ( !_rValue.hasValue() )
+ return;
+ style::VerticalAlignment eAlign = style::VerticalAlignment_TOP;
+ drawing::TextVerticalAdjust eAdjust = drawing::TextVerticalAdjust_TOP;
+ OSL_VERIFY( _rValue >>= eAlign );
+ switch ( eAlign )
+ {
+ case style::VerticalAlignment_TOP: eAdjust = drawing::TextVerticalAdjust_TOP; break;
+ case style::VerticalAlignment_BOTTOM: eAdjust = drawing::TextVerticalAdjust_BOTTOM; break;
+ default: eAdjust = drawing::TextVerticalAdjust_CENTER; break;
+ }
+ _rValue <<= eAdjust;
+ }
+}
+
+void SAL_CALL SvxShapeControl::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
+{
+ OUString aFormsName;
+ if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
+ {
+ uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
+ if( xControl.is() )
+ {
+ uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
+ if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
+ {
+ uno::Any aConvertedValue( aValue );
+ if ( aFormsName.equalsAscii( "FontSlant" ) )
+ {
+ awt::FontSlant nSlant;
+ if( !(aValue >>= nSlant ) )
+ throw lang::IllegalArgumentException();
+ aConvertedValue <<= (sal_Int16)nSlant;
+ }
+ else if ( aFormsName.equalsAscii( "Align" ) )
+ {
+ lcl_convertParaAdjustmentToTextAlignment( aConvertedValue );
+ }
+ else if ( aFormsName.equalsAscii( "VerticalAlign" ) )
+ {
+ convertVerticalAdjustToVerticalAlign( aConvertedValue );
+ }
+
+ xControl->setPropertyValue( aFormsName, aConvertedValue );
+ }
+ }
+ }
+ else
+ {
+ SvxShape::setPropertyValue( aPropertyName, aValue );
+ }
+}
+
+uno::Any SAL_CALL SvxShapeControl::getPropertyValue( const OUString& aPropertyName )
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OUString aFormsName;
+ if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
+ {
+ uno::Reference< beans::XPropertySet > xControl( getControl(), uno::UNO_QUERY );
+
+ uno::Any aValue;
+ if( xControl.is() )
+ {
+ uno::Reference< beans::XPropertySetInfo > xInfo( xControl->getPropertySetInfo() );
+ if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
+ {
+ aValue = xControl->getPropertyValue( aFormsName );
+ if ( aFormsName.equalsAscii( "FontSlant" ) )
+ {
+ awt::FontSlant eSlant = awt::FontSlant_NONE;
+ sal_Int16 nSlant = sal_Int16();
+ if ( aValue >>= nSlant )
+ {
+ eSlant = (awt::FontSlant)nSlant;
+ }
+ else
+ {
+ OSL_VERIFY( aValue >>= eSlant );
+ }
+ aValue <<= eSlant;
+ }
+ else if ( aFormsName.equalsAscii( "Align" ) )
+ {
+ lcl_convertTextAlignmentToParaAdjustment( aValue );
+ }
+ else if ( aFormsName.equalsAscii( "VerticalAlign" ) )
+ {
+ convertVerticalAlignToVerticalAdjust( aValue );
+ }
+ }
+ }
+
+ return aValue;
+ }
+ else
+ {
+ return SvxShape::getPropertyValue( aPropertyName );
+ }
+
+}
+
+// XPropertyState
+beans::PropertyState SAL_CALL SvxShapeControl::getPropertyState( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException )
+{
+ OUString aFormsName;
+ if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
+ {
+ uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
+
+ if( xControl.is() && xPropSet.is() )
+ {
+ uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
+ if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
+ {
+ return xControl->getPropertyState( aFormsName );
+ }
+ }
+
+ return beans::PropertyState_DEFAULT_VALUE;
+ }
+ else
+ {
+ return SvxShape::getPropertyState( PropertyName );
+ }
+}
+
+void SAL_CALL SvxShapeControl::setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw( beans::UnknownPropertyException, uno::RuntimeException )
+{
+ OUString aFormsName;
+ if ( lcl_convertPropertyName( PropertyName, aFormsName ) )
+ {
+ uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xPropSet( getControl(), uno::UNO_QUERY );
+
+ if( xControl.is() && xPropSet.is() )
+ {
+ uno::Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() );
+ if( xInfo.is() && xInfo->hasPropertyByName( aFormsName ) )
+ {
+ xControl->setPropertyToDefault( aFormsName );
+ }
+ }
+ }
+ else
+ {
+ SvxShape::setPropertyToDefault( PropertyName );
+ }
+}
+
+uno::Any SAL_CALL SvxShapeControl::getPropertyDefault( const ::rtl::OUString& aPropertyName )
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ OUString aFormsName;
+ if ( lcl_convertPropertyName( aPropertyName, aFormsName ) )
+ {
+ uno::Reference< beans::XPropertyState > xControl( getControl(), uno::UNO_QUERY );
+
+ if( xControl.is() )
+ {
+ Any aDefault( xControl->getPropertyDefault( aFormsName ) );
+ if ( aFormsName.equalsAscii( "FontSlant" ) )
+ {
+ sal_Int16 nSlant( 0 );
+ aDefault >>= nSlant;
+ aDefault <<= (awt::FontSlant)nSlant;
+ }
+ else if ( aFormsName.equalsAscii( "Align" ) )
+ {
+ lcl_convertTextAlignmentToParaAdjustment( aDefault );
+ }
+ else if ( aFormsName.equalsAscii( "VerticalAlign" ) )
+ {
+ convertVerticalAlignToVerticalAdjust( aDefault );
+ }
+ return aDefault;
+ }
+
+ throw beans::UnknownPropertyException();
+ }
+ else
+ {
+ return SvxShape::getPropertyDefault( aPropertyName );
+ }
+}
+
+
+/***********************************************************************
+* class SvxShapeDimensioning *
+***********************************************************************/
+
+//----------------------------------------------------------------------
+SvxShapeDimensioning::SvxShapeDimensioning( SdrObject* pObj ) throw()
+: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_DIMENSIONING), aSvxMapProvider.GetPropertySet(SVXMAP_DIMENSIONING, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+//----------------------------------------------------------------------
+SvxShapeDimensioning::~SvxShapeDimensioning() throw()
+{
+}
+
+// ::com::sun::star::lang::XServiceInfo
+uno::Sequence< OUString > SAL_CALL SvxShapeDimensioning::getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ return SvxShapeText::getSupportedServiceNames();
+}
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+//----------------------------------------------------------------------
+SvxShapeCircle::SvxShapeCircle( SdrObject* pObj ) throw()
+: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CIRCLE), aSvxMapProvider.GetPropertySet(SVXMAP_CIRCLE, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+//----------------------------------------------------------------------
+SvxShapeCircle::~SvxShapeCircle() throw()
+{
+}
+
+// ::com::sun::star::lang::XServiceInfo
+// XServiceInfo
+uno::Sequence< OUString > SAL_CALL SvxShapeCircle::getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ return SvxShapeText::getSupportedServiceNames();
+}
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+#include <svx/svdopath.hxx>
+
+//----------------------------------------------------------------------
+SvxShapePolyPolygon::SvxShapePolyPolygon( SdrObject* pObj , drawing::PolygonKind eNew )
+ throw( com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
+: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_POLYPOLYGON), aSvxMapProvider.GetPropertySet(SVXMAP_POLYPOLYGON, SdrObject::GetGlobalDrawObjectItemPool()) )
+, mePolygonKind( eNew )
+{
+}
+
+//----------------------------------------------------------------------
+SvxShapePolyPolygon::~SvxShapePolyPolygon() throw()
+{
+}
+
+basegfx::B2DPolyPolygon SAL_CALL ImplSvxPointSequenceSequenceToB2DPolyPolygon( const drawing::PointSequenceSequence* pOuterSequence) throw()
+{
+ basegfx::B2DPolyPolygon aRetval;
+
+ // Zeiger auf innere sequences holen
+ const drawing::PointSequence* pInnerSequence = pOuterSequence->getConstArray();
+ const drawing::PointSequence* pInnerSeqEnd = pInnerSequence + pOuterSequence->getLength();
+
+ for(;pInnerSequence != pInnerSeqEnd; ++pInnerSequence)
+ {
+ // Neues Polygon vorbereiten
+ basegfx::B2DPolygon aNewPolygon;
+
+ // Zeiger auf Arrays holen
+ const awt::Point* pArray = pInnerSequence->getConstArray();
+ const awt::Point* pArrayEnd = pArray + pInnerSequence->getLength();
+
+ for(;pArray != pArrayEnd;++pArray)
+ {
+ aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
+ }
+
+ // check for closed state flag
+ basegfx::tools::checkClosed(aNewPolygon);
+
+ // Neues Teilpolygon einfuegen
+ aRetval.append(aNewPolygon);
+ }
+
+ return aRetval;
+}
+
+//----------------------------------------------------------------------
+
+bool SvxShapePolyPolygon::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_VALUE_POLYPOLYGON:
+ {
+ if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ) )
+ {
+ basegfx::B2DPolyPolygon aNewPolyPolygon(ImplSvxPointSequenceSequenceToB2DPolyPolygon( (drawing::PointSequenceSequence*)rValue.getValue()));
+ SetPolygon(aNewPolyPolygon);
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_BASE_GEOMETRY:
+ {
+ if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0)))
+ {
+ if( mpObj.is() )
+ {
+ basegfx::B2DPolyPolygon aNewPolyPolygon;
+ basegfx::B2DHomMatrix aNewHomogenMatrix;
+
+ mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ aNewPolyPolygon = ImplSvxPointSequenceSequenceToB2DPolyPolygon((drawing::PointSequenceSequence*)rValue.getValue());
+ mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ }
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_VALUE_POLYGON:
+ {
+ if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PointSequenceSequence*)0) ))
+ {
+ drawing::PointSequence* pSequence = (drawing::PointSequence*)rValue.getValue();
+
+ // Neues Polygon vorbereiten
+ basegfx::B2DPolygon aNewPolygon;
+
+ // Zeiger auf Arrays holen
+ // Zeiger auf Arrays holen
+ const awt::Point* pArray = pSequence->getConstArray();
+ const awt::Point* pArrayEnd = pArray + pSequence->getLength();
+
+ for(;pArray != pArrayEnd;++pArray)
+ {
+ aNewPolygon.append(basegfx::B2DPoint(pArray->X, pArray->Y));
+ }
+
+ // check for closed state flag
+ basegfx::tools::checkClosed(aNewPolygon);
+
+ // Polygon setzen
+ SetPolygon(basegfx::B2DPolyPolygon(aNewPolygon));
+ return true;
+ }
+ break;
+ }
+ default:
+ return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ throw lang::IllegalArgumentException();
+}
+
+void SAL_CALL B2DPolyPolygonToSvxPointSequenceSequence( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PointSequenceSequence& rRetval )
+{
+ if( (sal_uInt32)rRetval.getLength() != rPolyPoly.count() )
+ rRetval.realloc( rPolyPoly.count() );
+
+ // Zeiger auf aeussere Arrays holen
+ drawing::PointSequence* pOuterSequence = rRetval.getArray();
+
+ for(sal_uInt32 a(0L); a < rPolyPoly.count(); a++)
+ {
+ // Einzelpolygon holen
+ const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(a));
+
+ // #i75974# take closed stae into account, the API polygon still uses the old closed definition
+ // with last/first point are identical (cannot hold information about open polygons with identical
+ // first and last point, though)
+ const sal_uInt32 nPointCount(aPoly.count());
+ const bool bIsClosed(aPoly.isClosed());
+
+ // Platz in Arrays schaffen
+ pOuterSequence->realloc(bIsClosed ? nPointCount + 1 : nPointCount);
+
+ // Pointer auf arrays holen
+ awt::Point* pInnerSequence = pOuterSequence->getArray();
+
+ for(sal_uInt32 b(0L); b < nPointCount; b++)
+ {
+ const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
+ *pInnerSequence = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
+ pInnerSequence++;
+ }
+
+ // #i75974# copy first point
+ if(bIsClosed)
+ {
+ *pInnerSequence = *pOuterSequence->getArray();
+ }
+
+ pOuterSequence++;
+ }
+}
+
+//----------------------------------------------------------------------
+
+bool SvxShapePolyPolygon::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_VALUE_POLYPOLYGON:
+ {
+ // PolyPolygon in eine struct PolyPolygon packen
+ const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
+ drawing::PointSequenceSequence aRetval( rPolyPoly.count() );
+
+ B2DPolyPolygonToSvxPointSequenceSequence( rPolyPoly, aRetval );
+
+ rValue <<= aRetval;
+ break;
+ }
+ case OWN_ATTR_BASE_GEOMETRY:
+ {
+ // pack a PolyPolygon in struct PolyPolygon
+ basegfx::B2DPolyPolygon aNewPolyPolygon;
+ basegfx::B2DHomMatrix aNewHomogenMatrix;
+
+ if(mpObj.is())
+ mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+
+ drawing::PointSequenceSequence aRetval(aNewPolyPolygon.count());
+ B2DPolyPolygonToSvxPointSequenceSequence(aNewPolyPolygon, aRetval);
+ rValue <<= aRetval;
+ break;
+ }
+ case OWN_ATTR_VALUE_POLYGON:
+ {
+ // PolyPolygon in eine struct PolyPolygon packen
+ const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
+
+ sal_Int32 nCount = 0;
+ if( rPolyPoly.count() > 0 )
+ nCount = rPolyPoly.getB2DPolygon(0L).count();
+
+ drawing::PointSequence aRetval( nCount );
+
+ if( nCount > 0 )
+ {
+ // Einzelpolygon holen
+ const basegfx::B2DPolygon aPoly(rPolyPoly.getB2DPolygon(0L));
+
+ // Pointer auf arrays holen
+ awt::Point* pSequence = aRetval.getArray();
+
+ for(sal_Int32 b=0;b<nCount;b++)
+ {
+ const basegfx::B2DPoint aPoint(aPoly.getB2DPoint(b));
+ *pSequence++ = awt::Point( basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY()) );
+ }
+ }
+
+ rValue <<= aRetval;
+ break;
+ }
+ case OWN_ATTR_VALUE_POLYGONKIND:
+ {
+ rValue <<= GetPolygonKind();
+ break;
+ }
+ default:
+ return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------
+drawing::PolygonKind SvxShapePolyPolygon::GetPolygonKind() const throw()
+{
+ return mePolygonKind;
+}
+
+//----------------------------------------------------------------------
+void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw()
+{
+ ::SolarMutexGuard aGuard;
+
+ if(mpObj.is())
+ ((SdrPathObj*)mpObj.get())->SetPathPoly(rNew);
+}
+
+//----------------------------------------------------------------------
+basegfx::B2DPolyPolygon SvxShapePolyPolygon::GetPolygon() const throw()
+{
+ ::SolarMutexGuard aGuard;
+
+ if(mpObj.is())
+ {
+ return ((SdrPathObj*)mpObj.get())->GetPathPoly();
+ }
+ else
+ {
+ return basegfx::B2DPolyPolygon();
+ }
+}
+
+// ::com::sun::star::lang::XServiceInfo
+uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygon::getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ return SvxShapeText::getSupportedServiceNames();
+}
+
+/***********************************************************************
+* class SvxShapePolyPolygonBezier *
+***********************************************************************/
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/drawing/FlagSequence.hpp>
+//----------------------------------------------------------------------
+SvxShapePolyPolygonBezier::SvxShapePolyPolygonBezier( SdrObject* pObj , drawing::PolygonKind eNew ) throw()
+: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_POLYPOLYGONBEZIER), aSvxMapProvider.GetPropertySet(SVXMAP_POLYPOLYGONBEZIER, SdrObject::GetGlobalDrawObjectItemPool()) )
+, mePolygonKind( eNew )
+{
+}
+
+//----------------------------------------------------------------------
+SvxShapePolyPolygonBezier::~SvxShapePolyPolygonBezier() throw()
+{
+}
+
+basegfx::B2DPolyPolygon SvxConvertPolyPolygonBezierToB2DPolyPolygon(const drawing::PolyPolygonBezierCoords* pSourcePolyPolygon)
+ throw( IllegalArgumentException )
+{
+ const sal_Int32 nOuterSequenceCount(pSourcePolyPolygon->Coordinates.getLength());
+ basegfx::B2DPolyPolygon aNewPolyPolygon;
+
+ if(pSourcePolyPolygon->Flags.getLength() != nOuterSequenceCount)
+ {
+ throw IllegalArgumentException();
+ }
+
+ // get pointers to inner sequence
+ const drawing::PointSequence* pInnerSequence = pSourcePolyPolygon->Coordinates.getConstArray();
+ const drawing::FlagSequence* pInnerSequenceFlags = pSourcePolyPolygon->Flags.getConstArray();
+
+ for(sal_Int32 a(0); a < nOuterSequenceCount; a++)
+ {
+ const sal_Int32 nInnerSequenceCount(pInnerSequence->getLength());
+
+ if(pInnerSequenceFlags->getLength() != nInnerSequenceCount)
+ {
+ throw IllegalArgumentException();
+ }
+
+ // prepare new polygon
+ basegfx::B2DPolygon aNewPolygon;
+ const awt::Point* pArray = pInnerSequence->getConstArray();
+ const drawing::PolygonFlags* pArrayFlags = pInnerSequenceFlags->getConstArray();
+
+ // get first point and flag
+ basegfx::B2DPoint aNewCoordinatePair(pArray->X, pArray->Y); pArray++;
+ XPolyFlags ePolyFlag((XPolyFlags)((sal_uInt16)*pArrayFlags)); pArrayFlags++;
+ basegfx::B2DPoint aControlA;
+ basegfx::B2DPoint aControlB;
+
+ // first point is not allowed to be a control point
+ if(XPOLY_CONTROL == ePolyFlag)
+ {
+ throw IllegalArgumentException();
+ }
+
+ // add first point as start point
+ aNewPolygon.append(aNewCoordinatePair);
+
+ for(sal_Int32 b(1); b < nInnerSequenceCount;)
+ {
+ // prepare loop
+ bool bControlA(false);
+ bool bControlB(false);
+
+ // get next point and flag
+ aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y);
+ ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags));
+ pArray++; pArrayFlags++; b++;
+
+ if(b < nInnerSequenceCount && XPOLY_CONTROL == ePolyFlag)
+ {
+ aControlA = aNewCoordinatePair;
+ bControlA = true;
+
+ // get next point and flag
+ aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y);
+ ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags));
+ pArray++; pArrayFlags++; b++;
+ }
+
+ if(b < nInnerSequenceCount && XPOLY_CONTROL == ePolyFlag)
+ {
+ aControlB = aNewCoordinatePair;
+ bControlB = true;
+
+ // get next point and flag
+ aNewCoordinatePair = basegfx::B2DPoint(pArray->X, pArray->Y);
+ ePolyFlag = XPolyFlags((XPolyFlags)((sal_uInt16)*pArrayFlags));
+ pArray++; pArrayFlags++; b++;
+ }
+
+ // two or no control points are consumed, another one would be an error.
+ // It's also an error if only one control point was read
+ if(XPOLY_CONTROL == ePolyFlag || bControlA != bControlB)
+ {
+ throw IllegalArgumentException();
+ }
+
+ // the previous writes used the B2DPolyPoygon -> PolyPolygon converter
+ // which did not create minimal PolyPolygons, but created all control points
+ // as null vectors (identical points). Because of the former P(CA)(CB)-norm of
+ // B2DPolygon and it's unused sign of being the zero-vector and CA and CB being
+ // relative to P, an empty edge was exported as P == CA == CB. Luckily, the new
+ // export format can be read without errors by the old OOo-versions, so we need only
+ // to correct here at read and do not need to export a wrong but compatible version
+ // for the future.
+ if(bControlA
+ && aControlA.equal(aControlB)
+ && aControlA.equal(aNewPolygon.getB2DPoint(aNewPolygon.count() - 1)))
+ {
+ bControlA = bControlB = false;
+ }
+
+ if(bControlA)
+ {
+ // add bezier edge
+ aNewPolygon.appendBezierSegment(aControlA, aControlB, aNewCoordinatePair);
+ }
+ else
+ {
+ // add edge
+ aNewPolygon.append(aNewCoordinatePair);
+ }
+ }
+
+ // next sequence
+ pInnerSequence++;
+ pInnerSequenceFlags++;
+
+ // #i72807# API import uses old line start/end-equal definition for closed,
+ // so we need to correct this to closed state here
+ basegfx::tools::checkClosed(aNewPolygon);
+
+ // add new subpolygon
+ aNewPolyPolygon.append(aNewPolygon);
+ }
+
+ return aNewPolyPolygon;
+}
+
+//----------------------------------------------------------------------
+
+bool SvxShapePolyPolygonBezier::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
+ {
+ if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0) ) )
+ {
+ basegfx::B2DPolyPolygon aNewPolyPolygon(SvxConvertPolyPolygonBezierToB2DPolyPolygon( (drawing::PolyPolygonBezierCoords*)rValue.getValue()));
+ SetPolygon(aNewPolyPolygon);
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_BASE_GEOMETRY:
+ {
+ if( rValue.getValue() && (rValue.getValueType() == ::getCppuType(( const drawing::PolyPolygonBezierCoords*)0)) )
+ {
+ if( mpObj.is() )
+ {
+ basegfx::B2DPolyPolygon aNewPolyPolygon;
+ basegfx::B2DHomMatrix aNewHomogenMatrix;
+
+ mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ aNewPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon((drawing::PolyPolygonBezierCoords*)rValue.getValue());
+ mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ }
+ return true;
+ }
+ break;
+ }
+ default:
+ return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ throw IllegalArgumentException();
+}
+
+void SvxConvertB2DPolyPolygonToPolyPolygonBezier( const basegfx::B2DPolyPolygon& rPolyPoly, drawing::PolyPolygonBezierCoords& rRetval )
+{
+ // use PolyPolygon converter as base. Since PolyPolygonBezierCoords uses
+ // integer coordinates, this is no precision loss at all.
+ const PolyPolygon aPolyPoly(rPolyPoly);
+
+ // Polygone innerhalb vrobereiten
+ rRetval.Coordinates.realloc((sal_Int32)aPolyPoly.Count());
+ rRetval.Flags.realloc((sal_Int32)aPolyPoly.Count());
+
+ // Zeiger auf aeussere Arrays holen
+ drawing::PointSequence* pOuterSequence = rRetval.Coordinates.getArray();
+ drawing::FlagSequence* pOuterFlags = rRetval.Flags.getArray();
+
+ for(sal_uInt16 a=0;a<aPolyPoly.Count();a++)
+ {
+ // Einzelpolygon holen
+ const Polygon& rPoly = aPolyPoly[a];
+
+ // Platz in Arrays schaffen
+ pOuterSequence->realloc((sal_Int32)rPoly.GetSize());
+ pOuterFlags->realloc((sal_Int32)rPoly.GetSize());
+
+ // Pointer auf arrays holen
+ awt::Point* pInnerSequence = pOuterSequence->getArray();
+ drawing::PolygonFlags* pInnerFlags = pOuterFlags->getArray();
+
+ for(sal_uInt16 b=0;b<rPoly.GetSize();b++)
+ {
+ *pInnerSequence++ = awt::Point( rPoly[b].X(), rPoly[b].Y() );
+ *pInnerFlags++ = (drawing::PolygonFlags)((sal_uInt16)rPoly.GetFlags(b));
+ }
+
+ pOuterSequence++;
+ pOuterFlags++;
+ }
+}
+
+//----------------------------------------------------------------------
+
+bool SvxShapePolyPolygonBezier::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_VALUE_POLYPOLYGONBEZIER:
+ {
+ // PolyPolygon in eine struct PolyPolygon packen
+ const basegfx::B2DPolyPolygon& rPolyPoly = GetPolygon();
+ drawing::PolyPolygonBezierCoords aRetval;
+ SvxConvertB2DPolyPolygonToPolyPolygonBezier(rPolyPoly, aRetval );
+
+ rValue <<= aRetval;
+ break;
+ }
+ case OWN_ATTR_BASE_GEOMETRY:
+ {
+ // PolyPolygon in eine struct PolyPolygon packen
+ basegfx::B2DPolyPolygon aNewPolyPolygon;
+ basegfx::B2DHomMatrix aNewHomogenMatrix;
+ mpObj.get()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ drawing::PolyPolygonBezierCoords aRetval;
+ SvxConvertB2DPolyPolygonToPolyPolygonBezier(aNewPolyPolygon, aRetval);
+
+ rValue <<= aRetval;
+ break;
+ }
+ case OWN_ATTR_VALUE_POLYGONKIND:
+ {
+ rValue <<= mePolygonKind;
+ break;
+ }
+ default:
+ return SvxShapeText::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------
+drawing::PolygonKind SvxShapePolyPolygonBezier::GetPolygonKind() const throw()
+{
+ return mePolygonKind;
+}
+
+//----------------------------------------------------------------------
+void SvxShapePolyPolygonBezier::SetPolygon(const basegfx::B2DPolyPolygon& rNew) throw()
+{
+ ::SolarMutexGuard aGuard;
+
+ if(mpObj.is())
+ static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
+}
+
+//----------------------------------------------------------------------
+basegfx::B2DPolyPolygon SvxShapePolyPolygonBezier::GetPolygon() const throw()
+{
+ ::SolarMutexGuard aGuard;
+
+ if(mpObj.is())
+ {
+ return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
+ }
+ else
+ {
+ return basegfx::B2DPolyPolygon();
+ }
+}
+
+
+// ::com::sun::star::lang::XServiceInfo
+uno::Sequence< OUString > SAL_CALL SvxShapePolyPolygonBezier::getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ return SvxShapeText::getSupportedServiceNames();
+}
+
+/***********************************************************************
+* class SvxGraphicObject *
+***********************************************************************/
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <vcl/cvtgrf.hxx>
+#include <svx/svdograf.hxx>
+#ifndef SVX_LIGHT
+#include <sfx2/docfile.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/fcontnr.hxx>
+#endif
+
+#include "toolkit/unohlp.hxx"
+
+//----------------------------------------------------------------------
+SvxGraphicObject::SvxGraphicObject( SdrObject* pObj ) throw()
+: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_GRAPHICOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_GRAPHICOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+//----------------------------------------------------------------------
+SvxGraphicObject::~SvxGraphicObject() throw()
+{
+}
+
+//----------------------------------------------------------------------
+
+bool SvxGraphicObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ bool bOk = false;
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_VALUE_FILLBITMAP:
+ {
+ if( rValue.getValue() )
+ {
+ if( rValue.getValueType() == ::getCppuType(( const uno::Sequence< sal_Int8 >*)0) )
+ {
+ uno::Sequence<sal_Int8>* pSeq( (uno::Sequence<sal_Int8>*)rValue.getValue() );
+ SvMemoryStream aMemStm;
+ Graphic aGraphic;
+
+ aMemStm.SetBuffer( (char*)pSeq->getConstArray(), pSeq->getLength(), sal_False, pSeq->getLength() );
+
+ if( GraphicConverter::Import( aMemStm, aGraphic ) == ERRCODE_NONE )
+ {
+ static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
+ bOk = true;
+ }
+ }
+ }
+ else if( (rValue.getValueType() == awt::XBitmap::static_type()) || (rValue.getValueType() == graphic::XGraphic::static_type()))
+ {
+ Reference< graphic::XGraphic> xGraphic( rValue, UNO_QUERY );
+ if( xGraphic.is() )
+ {
+ ((SdrGrafObj*)mpObj.get())->SetGraphic(Graphic(xGraphic));
+ bOk = true;
+ }
+ else
+ {
+ // Bitmap in das Objekt packen
+ Reference< awt::XBitmap > xBmp( rValue, UNO_QUERY );
+ if( xBmp.is() )
+ {
+ // Bitmap einsetzen
+ Graphic aGraphic(VCLUnoHelper::GetBitmap( xBmp ));
+ ((SdrGrafObj*)mpObj.get())->SetGraphic(aGraphic);
+ bOk = true;
+ }
+ }
+ }
+ break;
+ }
+ case OWN_ATTR_GRAFURL:
+ {
+ OUString aURL;
+ if( rValue >>= aURL )
+ {
+ if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 )
+ {
+ // graphic manager url
+ aURL = aURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
+ String aTmpStr(aURL);
+ ByteString aUniqueID( aTmpStr, RTL_TEXTENCODING_UTF8 );
+ GraphicObject aGrafObj( aUniqueID );
+
+ // #101808# since loading a graphic can cause a reschedule of the office
+ // it is possible that our shape is removed while where in this
+ // method.
+ if( mpObj.is() )
+ {
+ static_cast<SdrGrafObj*>(mpObj.get())->ReleaseGraphicLink();
+ static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicObject( aGrafObj );
+ }
+ }
+ else if( aURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 )
+ {
+ // normal link
+ String aFilterName;
+ const SfxFilter* pSfxFilter = NULL;
+ SfxMedium aSfxMedium( aURL, STREAM_READ | STREAM_SHARE_DENYNONE, FALSE );
+
+ SFX_APP()->GetFilterMatcher().GuessFilter( aSfxMedium, &pSfxFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE );
+
+ if( !pSfxFilter )
+ {
+ INetURLObject aURLObj( aURL );
+
+ if( aURLObj.GetProtocol() == INET_PROT_NOT_VALID )
+ {
+ String aValidURL;
+
+ if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aURL, aValidURL ) )
+ aURLObj = INetURLObject( aValidURL );
+ }
+
+ if( aURLObj.GetProtocol() != INET_PROT_NOT_VALID )
+ {
+ GraphicFilter* pGrfFilter = GraphicFilter::GetGraphicFilter();
+ aFilterName = pGrfFilter->GetImportFormatName( pGrfFilter->GetImportFormatNumberForShortName( aURLObj.getExtension() ) );
+ }
+ }
+ else
+ aFilterName = pSfxFilter->GetFilterName();
+
+ // #101808# since loading a graphic can cause a reschedule of the office
+ // it is possible that our shape is removed while where in this
+ // method.
+ if( mpObj.is() )
+ static_cast<SdrGrafObj*>(mpObj.get())->SetGraphicLink( aURL, aFilterName );
+
+ }
+ bOk = true;
+ }
+ break;
+ }
+
+ case OWN_ATTR_GRAFSTREAMURL:
+ {
+ OUString aStreamURL;
+
+ if( rValue >>= aStreamURL )
+ {
+ if( aStreamURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPKGPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) ) != 0 )
+ aStreamURL = OUString();
+
+ if( mpObj.is() )
+ {
+ static_cast<SdrGrafObj*>(mpObj.get())->SetGrafStreamURL( aStreamURL );
+ static_cast<SdrGrafObj*>(mpObj.get())->ForceSwapOut();
+ }
+ bOk = true;
+ }
+ break;
+ }
+
+ case OWN_ATTR_VALUE_GRAPHIC:
+ {
+ Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
+ if( xGraphic.is() )
+ {
+ static_cast< SdrGrafObj*>( mpObj.get() )->SetGraphic( xGraphic );
+ bOk = true;
+ }
+ break;
+ }
+ default:
+ return SvxShapeText::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ if( !bOk )
+ throw lang::IllegalArgumentException();
+
+ if( mpModel )
+ mpModel->SetChanged();
+
+ return true;
+}
+
+//----------------------------------------------------------------------
+
+bool SvxGraphicObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_VALUE_FILLBITMAP:
+ {
+ const Graphic& rGraphic = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic();
+
+ if(rGraphic.GetType() != GRAPHIC_GDIMETAFILE)
+ {
+ // Objekt in eine Bitmap packen
+ Reference< ::com::sun::star::awt::XBitmap > xBitmap( VCLUnoHelper::CreateBitmap(static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphic().GetBitmapEx()) );
+ rValue <<= xBitmap;
+ }
+ else
+ {
+ SvMemoryStream aDestStrm( 65535, 65535 );
+
+ ConvertGDIMetaFileToWMF( rGraphic.GetGDIMetaFile(), aDestStrm, NULL, sal_False );
+ const uno::Sequence<sal_Int8> aSeq(
+ static_cast< const sal_Int8* >(aDestStrm.GetData()),
+ aDestStrm.GetEndOfData());
+ rValue <<= aSeq;
+ }
+ break;
+ }
+
+ case OWN_ATTR_GRAFURL:
+ {
+ if( static_cast< SdrGrafObj*>( mpObj.get() )->IsLinkedGraphic() )
+ {
+ rValue <<= OUString( static_cast< SdrGrafObj*>( mpObj.get() )->GetFileName() );
+ }
+ else
+ {
+ const GraphicObject& rGrafObj = static_cast< SdrGrafObj*>( mpObj.get() )->GetGraphicObject(true);
+ OUString aURL( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
+ aURL += OUString::createFromAscii( rGrafObj.GetUniqueID().GetBuffer() );
+ rValue <<= aURL;
+ }
+ break;
+ }
+
+ case OWN_ATTR_GRAFSTREAMURL:
+ {
+ const OUString aStreamURL( ( (SdrGrafObj*) mpObj.get() )->GetGrafStreamURL() );
+ if( aStreamURL.getLength() )
+ rValue <<= aStreamURL;
+ break;
+ }
+
+ case OWN_ATTR_VALUE_GRAPHIC:
+ {
+ Reference< graphic::XGraphic > xGraphic( static_cast< SdrGrafObj* >( mpObj.get() )->GetGraphic().GetXGraphic() );
+ rValue <<= xGraphic;
+ break;
+ }
+
+ case OWN_ATTR_GRAPHIC_STREAM:
+ {
+ rValue <<= static_cast< SdrGrafObj* >( mpObj.get() )->getInputStream();
+ break;
+ }
+ default:
+ return SvxShapeText::getPropertyValueImpl(rName, pProperty,rValue);
+ }
+
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxShapeCaption::SvxShapeCaption( SdrObject* pObj ) throw()
+: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_CAPTION), aSvxMapProvider.GetPropertySet(SVXMAP_CAPTION, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+SvxShapeCaption::~SvxShapeCaption() throw()
+{
+}
+
+/***********************************************************************
+* class SvxCustomShape *
+***********************************************************************/
+
+SvxCustomShape::SvxCustomShape( SdrObject* pObj ) throw() :
+ SvxShapeText( pObj, aSvxMapProvider.GetMap( SVXMAP_CUSTOMSHAPE ), aSvxMapProvider.GetPropertySet(SVXMAP_CUSTOMSHAPE, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+//----------------------------------------------------------------------
+SvxCustomShape::~SvxCustomShape() throw()
+{
+}
+
+//----------------------------------------------------------------------
+
+void SvxCustomShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
+{
+ SvxShapeText::Create( pNewObj, pNewPage );
+}
+
+//----------------------------------------------------------------------
+
+uno::Any SAL_CALL SvxCustomShape::queryInterface( const uno::Type & rType )
+ throw(uno::RuntimeException)
+{
+ return SvxShapeText::queryInterface( rType );
+}
+
+uno::Any SAL_CALL SvxCustomShape::queryAggregation( const uno::Type & rType )
+ throw(uno::RuntimeException)
+{
+ ::com::sun::star::uno::Any aReturn = SvxShapeText::queryAggregation( rType );
+ if ( !aReturn.hasValue() )
+ aReturn = ::cppu::queryInterface(rType, static_cast<drawing::XEnhancedCustomShapeDefaulter*>(this) );
+ return aReturn;
+}
+
+void SAL_CALL SvxCustomShape::acquire() throw ( )
+{
+ SvxShapeText::acquire();
+}
+
+void SAL_CALL SvxCustomShape::release() throw ( )
+{
+ SvxShapeText::release();
+}
+
+//----------------------------------------------------------------------
+
+uno::Sequence< uno::Type > SAL_CALL SvxCustomShape::getTypes()
+ throw (uno::RuntimeException)
+{
+ return SvxShapeText::getTypes();
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL SvxCustomShape::getImplementationId()
+ throw (uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// ::com::sun::star::drawing::XShape
+
+//----------------------------------------------------------------------
+OUString SAL_CALL SvxCustomShape::getShapeType()
+ throw( uno::RuntimeException )
+{
+ return SvxShape::getShapeType();
+}
+
+//------------------------------------------------------------------1----
+awt::Point SAL_CALL SvxCustomShape::getPosition() throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ if ( mpModel && mpObj.is() )
+ {
+ SdrAShapeObjGeoData aCustomShapeGeoData;
+ ((SdrObjCustomShape*)mpObj.get())->SaveGeoData( aCustomShapeGeoData );
+
+ sal_Bool bMirroredX = sal_False;
+ sal_Bool bMirroredY = sal_False;
+
+ if ( mpObj.is() )
+ {
+ bMirroredX = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredX() );
+ bMirroredY = ( ((SdrObjCustomShape*)mpObj.get())->IsMirroredY() );
+ }
+ // get aRect, this is the unrotated snaprect
+ Rectangle aRect(((SdrObjCustomShape*)mpObj.get())->GetLogicRect());
+ Rectangle aRectangle( aRect );
+
+ if ( bMirroredX || bMirroredY )
+ { // we have to retrieve the unmirrored rect
+
+ GeoStat aNewGeo( aCustomShapeGeoData.aGeo );
+ if ( bMirroredX )
+ {
+ Polygon aPol( Rect2Poly( aRect, aNewGeo ) );
+ Rectangle aBoundRect( aPol.GetBoundRect() );
+
+ Point aRef1( ( aBoundRect.Left() + aBoundRect.Right() ) >> 1, aBoundRect.Top() );
+ Point aRef2( aRef1.X(), aRef1.Y() + 1000 );
+ USHORT i;
+ USHORT nPntAnz=aPol.GetSize();
+ for (i=0; i<nPntAnz; i++)
+ {
+ MirrorPoint(aPol[i],aRef1,aRef2);
+ }
+ // Polygon wenden und etwas schieben
+ Polygon aPol0(aPol);
+ aPol[0]=aPol0[1];
+ aPol[1]=aPol0[0];
+ aPol[2]=aPol0[3];
+ aPol[3]=aPol0[2];
+ aPol[4]=aPol0[1];
+ Poly2Rect(aPol,aRectangle,aNewGeo);
+ }
+ if ( bMirroredY )
+ {
+ Polygon aPol( Rect2Poly( aRectangle, aNewGeo ) );
+ Rectangle aBoundRect( aPol.GetBoundRect() );
+
+ Point aRef1( aBoundRect.Left(), ( aBoundRect.Top() + aBoundRect.Bottom() ) >> 1 );
+ Point aRef2( aRef1.X() + 1000, aRef1.Y() );
+ USHORT i;
+ USHORT nPntAnz=aPol.GetSize();
+ for (i=0; i<nPntAnz; i++)
+ {
+ MirrorPoint(aPol[i],aRef1,aRef2);
+ }
+ // Polygon wenden und etwas schieben
+ Polygon aPol0(aPol);
+ aPol[0]=aPol0[1];
+ aPol[1]=aPol0[0];
+ aPol[2]=aPol0[3];
+ aPol[3]=aPol0[2];
+ aPol[4]=aPol0[1];
+ Poly2Rect( aPol, aRectangle, aNewGeo );
+ }
+ }
+ Point aPt( aRectangle.TopLeft() );
+
+ if( mpModel->IsWriter() )
+ aPt -= mpObj->GetAnchorPos();
+
+ ForceMetricTo100th_mm(aPt);
+ return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() );
+ }
+ else
+ return SvxShape::getPosition();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxCustomShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
+{
+ SvxShapeText::setPosition(Position);
+}
+
+//----------------------------------------------------------------------
+
+awt::Size SAL_CALL SvxCustomShape::getSize() throw(uno::RuntimeException)
+{
+ return SvxShapeText::getSize();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxCustomShape::setSize( const awt::Size& rSize )
+ throw(beans::PropertyVetoException, uno::RuntimeException)
+{
+ SvxShapeText::setSize( rSize );
+}
+
+//----------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, com::sun::star::beans::PropertyVetoException, com::sun::star::lang::IllegalArgumentException)
+{
+ ::SolarMutexGuard aGuard;
+ SdrObject* pObject = mpObj.get();
+
+ sal_Bool bCustomShapeGeometry = pObject && aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CustomShapeGeometry" ) );
+
+ sal_Bool bMirroredX = sal_False;
+ sal_Bool bMirroredY = sal_False;
+
+ if ( bCustomShapeGeometry )
+ {
+ bMirroredX = ( ((SdrObjCustomShape*)pObject)->IsMirroredX() );
+ bMirroredY = ( ((SdrObjCustomShape*)pObject)->IsMirroredY() );
+ }
+
+ SvxShape::setPropertyValue( aPropertyName, aValue );
+
+ if ( bCustomShapeGeometry )
+ {
+ ((SdrObjCustomShape*)pObject)->MergeDefaultAttributes(0);
+ Rectangle aRect( pObject->GetSnapRect() );
+
+ // #i38892#
+ bool bNeedsMirrorX = ((SdrObjCustomShape*)pObject)->IsMirroredX() != bMirroredX;
+ bool bNeedsMirrorY = ((SdrObjCustomShape*)pObject)->IsMirroredY() != bMirroredY;
+
+ boost::scoped_ptr< SdrGluePointList > pListCopy;
+ if( bNeedsMirrorX || bNeedsMirrorY )
+ {
+ const SdrGluePointList* pList = pObject->GetGluePointList();
+ if( pList )
+ pListCopy.reset( new SdrGluePointList(*pList) );
+ }
+
+ if ( bNeedsMirrorX )
+ {
+ Point aTop( ( aRect.Left() + aRect.Right() ) >> 1, aRect.Top() );
+ Point aBottom( aTop.X(), aTop.Y() + 1000 );
+ pObject->NbcMirror( aTop, aBottom );
+ // NbcMirroring is flipping the current mirror state,
+ // so we have to set the correct state again
+ ((SdrObjCustomShape*)pObject)->SetMirroredX( bMirroredX ? sal_False : sal_True );
+ }
+ if ( bNeedsMirrorY )
+ {
+ Point aLeft( aRect.Left(), ( aRect.Top() + aRect.Bottom() ) >> 1 );
+ Point aRight( aLeft.X() + 1000, aLeft.Y() );
+ pObject->NbcMirror( aLeft, aRight );
+ // NbcMirroring is flipping the current mirror state,
+ // so we have to set the correct state again
+ ((SdrObjCustomShape*)pObject)->SetMirroredY( bMirroredY ? sal_False : sal_True );
+ }
+
+ if( pListCopy )
+ {
+ SdrGluePointList* pNewList = const_cast< SdrGluePointList* >( pObject->GetGluePointList() );
+ if(pNewList)
+ *pNewList = *pListCopy;
+ }
+ }
+}
+
+bool SvxCustomShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case SDRATTR_ROTATEANGLE:
+ {
+ double fAngle = static_cast<SdrObjCustomShape*>(mpObj.get())->GetObjectRotation();
+ fAngle *= 100;
+ rValue <<= (sal_Int32)fAngle;
+ return true;
+ }
+ default:
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+}
+//----------------------------------------------------------------------
+
+void SvxCustomShape::createCustomShapeDefaults( const rtl::OUString& rValueType ) throw (::com::sun::star::uno::RuntimeException)
+{
+ ((SdrObjCustomShape*)mpObj.get())->MergeDefaultAttributes( &rValueType );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx
new file mode 100644
index 000000000000..a9be7f6cc6b5
--- /dev/null
+++ b/svx/source/unodraw/unoshap3.cxx
@@ -0,0 +1,1212 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define _SVX_USE_UNOGLOBALS_
+#include <com/sun/star/drawing/HomogenMatrix.hpp>
+#include <com/sun/star/drawing/Position3D.hpp>
+#include <com/sun/star/drawing/Direction3D.hpp>
+#include <com/sun/star/drawing/DoubleSequence.hpp>
+#include <com/sun/star/drawing/CameraGeometry.hpp>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <comphelper/serviceinfohelper.hxx>
+
+#include <rtl/uuid.h>
+#include <rtl/memory.h>
+#include <svx/svdpool.hxx>
+#include <svx/unoshape.hxx>
+#include <svx/unopage.hxx>
+#include <editeng/unoprnms.hxx>
+#include <svx/polysc3d.hxx>
+#include "globl3d.hxx"
+#include <svx/cube3d.hxx>
+#include <svx/sphere3d.hxx>
+#include <svx/lathe3d.hxx>
+#include <svx/extrud3d.hxx>
+#include <svx/polygn3d.hxx>
+#include "svx/unoshprp.hxx"
+#include "svx/svdmodel.hxx"
+#include <basegfx/polygon/b3dpolygon.hxx>
+#include <basegfx/polygon/b3dpolygontools.hxx>
+#include <com/sun/star/drawing/PolyPolygonShape3D.hpp>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+
+using ::rtl::OUString;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+
+#define INTERFACE_TYPE( xint ) \
+ ::getCppuType((const Reference< xint >*)0)
+
+#define QUERYINT( xint ) \
+ if( rType == ::getCppuType((const Reference< xint >*)0) ) \
+ aAny <<= Reference< xint >(this)
+
+/***********************************************************************
+* class Svx3DSceneObject *
+***********************************************************************/
+
+//----------------------------------------------------------------------
+Svx3DSceneObject::Svx3DSceneObject( SdrObject* pObj, SvxDrawPage* pDrawPage ) throw()
+: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DSCENEOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DSCENEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) )
+, mxPage( pDrawPage )
+{
+}
+
+//----------------------------------------------------------------------
+Svx3DSceneObject::~Svx3DSceneObject() throw()
+{
+}
+
+//----------------------------------------------------------------------
+void Svx3DSceneObject::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
+{
+ SvxShape::Create( pNewObj, pNewPage );
+ mxPage = pNewPage;
+}
+
+//----------------------------------------------------------------------
+uno::Any SAL_CALL Svx3DSceneObject::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
+{
+ uno::Any aAny;
+
+ QUERYINT( drawing::XShapes );
+ else QUERYINT( container::XIndexAccess );
+ else QUERYINT( container::XElementAccess );
+ else
+ return SvxShape::queryAggregation( rType );
+
+ return aAny;
+}
+
+uno::Any SAL_CALL Svx3DSceneObject::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException )
+{
+ return SvxShape::queryInterface( rType );
+}
+
+void SAL_CALL Svx3DSceneObject::acquire() throw ( )
+{
+ SvxShape::acquire();
+}
+
+void SAL_CALL Svx3DSceneObject::release() throw ( )
+{
+ SvxShape::release();
+}
+
+// XTypeProvider
+
+uno::Sequence< uno::Type > SAL_CALL Svx3DSceneObject::getTypes()
+ throw (uno::RuntimeException)
+{
+
+ return SvxShape::getTypes();
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL Svx3DSceneObject::getImplementationId()
+ throw (uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape )
+ throw( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+
+ if(!mpObj.is() || !mxPage.is() || pShape == NULL || NULL != pShape->GetSdrObject() )
+ throw uno::RuntimeException();
+
+ SdrObject* pSdrShape = mxPage->_CreateSdrObject( xShape );
+ if( pSdrShape->ISA(E3dObject) )
+ {
+ mpObj->GetSubList()->NbcInsertObject( pSdrShape );
+
+ if(pShape)
+ pShape->Create( pSdrShape, mxPage.get() );
+ }
+ else
+ {
+ SdrObject::Free( pSdrShape );
+ throw uno::RuntimeException();
+ }
+
+ if( mpModel )
+ mpModel->SetChanged();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL Svx3DSceneObject::remove( const Reference< drawing::XShape >& xShape )
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+
+ if(!mpObj.is() || pShape == NULL)
+ throw uno::RuntimeException();
+
+ SdrObject* pSdrShape = pShape->GetSdrObject();
+ if(pSdrShape == NULL || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get())
+ {
+ throw uno::RuntimeException();
+ }
+ else
+ {
+ SdrObjList& rList = *pSdrShape->GetObjList();
+
+ const sal_uInt32 nObjCount = rList.GetObjCount();
+ sal_uInt32 nObjNum = 0;
+ while( nObjNum < nObjCount )
+ {
+ if(rList.GetObj( nObjNum ) == pSdrShape )
+ break;
+ nObjNum++;
+ }
+
+ if( nObjNum < nObjCount )
+ {
+ SdrObject* pObject = rList.NbcRemoveObject( nObjNum );
+ SdrObject::Free( pObject );
+ }
+ else
+ {
+ DBG_ASSERT( 0, "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
+ }
+ }
+}
+
+//----------------------------------------------------------------------
+sal_Int32 SAL_CALL Svx3DSceneObject::getCount()
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ sal_Int32 nRetval = 0;
+
+ if(mpObj.is() && mpObj->ISA(E3dPolyScene) && mpObj->GetSubList())
+ nRetval = mpObj->GetSubList()->GetObjCount();
+ return nRetval;
+}
+
+//----------------------------------------------------------------------
+
+uno::Any SAL_CALL Svx3DSceneObject::getByIndex( sal_Int32 Index )
+ throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( !mpObj.is() || mpObj->GetSubList() == NULL )
+ throw uno::RuntimeException();
+
+ if( mpObj->GetSubList()->GetObjCount() <= (sal_uInt32)Index )
+ throw lang::IndexOutOfBoundsException();
+
+ SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index );
+ if(pDestObj == NULL)
+ throw lang::IndexOutOfBoundsException();
+
+ Reference< drawing::XShape > xShape( pDestObj->getUnoShape(), uno::UNO_QUERY );
+ uno::Any aAny;
+ aAny <<= xShape;
+ return aAny;
+}
+
+//----------------------------------------------------------------------
+// ::com::sun::star::container::XElementAccess
+
+uno::Type SAL_CALL Svx3DSceneObject::getElementType()
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType(( const Reference< drawing::XShape>*)0);
+}
+
+//----------------------------------------------------------------------
+sal_Bool SAL_CALL Svx3DSceneObject::hasElements()
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
+}
+
+//----------------------------------------------------------------------
+
+static bool ConvertHomogenMatrixToObject( E3dObject* pObject, const Any& rValue )
+{
+ drawing::HomogenMatrix m;
+ if( rValue >>= m )
+ {
+ basegfx::B3DHomMatrix aMat;
+ aMat.set(0, 0, m.Line1.Column1);
+ aMat.set(0, 1, m.Line1.Column2);
+ aMat.set(0, 2, m.Line1.Column3);
+ aMat.set(0, 3, m.Line1.Column4);
+ aMat.set(1, 0, m.Line2.Column1);
+ aMat.set(1, 1, m.Line2.Column2);
+ aMat.set(1, 2, m.Line2.Column3);
+ aMat.set(1, 3, m.Line2.Column4);
+ aMat.set(2, 0, m.Line3.Column1);
+ aMat.set(2, 1, m.Line3.Column2);
+ aMat.set(2, 2, m.Line3.Column3);
+ aMat.set(2, 3, m.Line3.Column4);
+ aMat.set(3, 0, m.Line4.Column1);
+ aMat.set(3, 1, m.Line4.Column2);
+ aMat.set(3, 2, m.Line4.Column3);
+ aMat.set(3, 3, m.Line4.Column4);
+ pObject->SetTransform(aMat);
+ return true;
+ }
+ return false;
+}
+
+static void ConvertObjectToHomogenMatric( E3dObject* pObject, Any& rValue )
+{
+ drawing::HomogenMatrix aHomMat;
+ const basegfx::B3DHomMatrix& rMat = pObject->GetTransform();
+ aHomMat.Line1.Column1 = rMat.get(0, 0);
+ aHomMat.Line1.Column2 = rMat.get(0, 1);
+ aHomMat.Line1.Column3 = rMat.get(0, 2);
+ aHomMat.Line1.Column4 = rMat.get(0, 3);
+ aHomMat.Line2.Column1 = rMat.get(1, 0);
+ aHomMat.Line2.Column2 = rMat.get(1, 1);
+ aHomMat.Line2.Column3 = rMat.get(1, 2);
+ aHomMat.Line2.Column4 = rMat.get(1, 3);
+ aHomMat.Line3.Column1 = rMat.get(2, 0);
+ aHomMat.Line3.Column2 = rMat.get(2, 1);
+ aHomMat.Line3.Column3 = rMat.get(2, 2);
+ aHomMat.Line3.Column4 = rMat.get(2, 3);
+ aHomMat.Line4.Column1 = rMat.get(3, 0);
+ aHomMat.Line4.Column2 = rMat.get(3, 1);
+ aHomMat.Line4.Column3 = rMat.get(3, 2);
+ aHomMat.Line4.Column4 = rMat.get(3, 3);
+ rValue <<= aHomMat;
+}
+
+//----------------------------------------------------------------------
+#include <svditer.hxx>
+
+struct ImpRememberTransAndRect
+{
+ basegfx::B3DHomMatrix maMat;
+ Rectangle maRect;
+};
+
+bool Svx3DSceneObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Transformationsmatrix in das Objekt packen
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ return true;
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY:
+ {
+ // set CameraGeometry at scene
+ E3dScene* pScene = static_cast< E3dScene* >( mpObj.get() );
+ drawing::CameraGeometry aCamGeo;
+
+ if(rValue >>= aCamGeo)
+ {
+ basegfx::B3DPoint aVRP(aCamGeo.vrp.PositionX, aCamGeo.vrp.PositionY, aCamGeo.vrp.PositionZ);
+ basegfx::B3DVector aVPN(aCamGeo.vpn.DirectionX, aCamGeo.vpn.DirectionY, aCamGeo.vpn.DirectionZ);
+ basegfx::B3DVector aVUP(aCamGeo.vup.DirectionX, aCamGeo.vup.DirectionY, aCamGeo.vup.DirectionZ);
+
+ // rescue scene transformation
+ ImpRememberTransAndRect aSceneTAR;
+ aSceneTAR.maMat = pScene->GetTransform();
+ aSceneTAR.maRect = pScene->GetSnapRect();
+
+ // rescue object transformations
+ SdrObjListIter aIter(*pScene->GetSubList(), IM_DEEPWITHGROUPS);
+ List aObjTrans;
+ while(aIter.IsMore())
+ {
+ E3dObject* p3DObj = (E3dObject*)aIter.Next();
+ basegfx::B3DHomMatrix* pNew = new basegfx::B3DHomMatrix;
+ *pNew = p3DObj->GetTransform();
+ aObjTrans.Insert(pNew, LIST_APPEND);
+ }
+
+ // reset object transformations
+ aIter.Reset();
+ while(aIter.IsMore())
+ {
+ E3dObject* p3DObj = (E3dObject*)aIter.Next();
+ p3DObj->NbcSetTransform(basegfx::B3DHomMatrix());
+ }
+
+ // reset scene transformation and make a complete recalc
+ pScene->NbcSetTransform(basegfx::B3DHomMatrix());
+
+ // fill old camera from new parameters
+ Camera3D aCam(pScene->GetCamera());
+ const basegfx::B3DRange& rVolume = pScene->GetBoundVolume();
+ double fW = rVolume.getWidth();
+ double fH = rVolume.getHeight();
+
+ const SfxItemSet& rSceneSet = pScene->GetMergedItemSet();
+ double fCamPosZ =
+ (double)((const SfxUInt32Item&)rSceneSet.Get(SDRATTR_3DSCENE_DISTANCE)).GetValue();
+ double fCamFocal =
+ (double)((const SfxUInt32Item&)rSceneSet.Get(SDRATTR_3DSCENE_FOCAL_LENGTH)).GetValue();
+
+ aCam.SetAutoAdjustProjection(FALSE);
+ aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
+ basegfx::B3DPoint aLookAt;
+ basegfx::B3DPoint aCamPos(0.0, 0.0, fCamPosZ);
+ aCam.SetPosAndLookAt(aCamPos, aLookAt);
+ aCam.SetFocalLength(fCamFocal / 100.0);
+ aCam.SetDefaults(basegfx::B3DPoint(0.0, 0.0, fCamPosZ), aLookAt, fCamFocal / 100.0);
+ aCam.SetDeviceWindow(Rectangle(0, 0, (long)fW, (long)fH));
+
+ // set at scene
+ pScene->SetCamera(aCam);
+
+ // #91047# use imported VRP, VPN and VUP (if used)
+ sal_Bool bVRPUsed(!aVRP.equal(basegfx::B3DPoint(0.0, 0.0, 1.0)));
+ sal_Bool bVPNUsed(!aVPN.equal(basegfx::B3DVector(0.0, 0.0, 1.0)));
+ sal_Bool bVUPUsed(!aVUP.equal(basegfx::B3DVector(0.0, 1.0, 0.0)));
+
+ if(bVRPUsed || bVPNUsed || bVUPUsed)
+ {
+ pScene->GetCameraSet().SetViewportValues(aVRP, aVPN, aVUP);
+ }
+
+ // set object transformations again at objects
+ aIter.Reset();
+ sal_uInt32 nIndex(0L);
+ while(aIter.IsMore())
+ {
+ E3dObject* p3DObj = (E3dObject*)aIter.Next();
+ basegfx::B3DHomMatrix* pMat = (basegfx::B3DHomMatrix*)aObjTrans.GetObject(nIndex++);
+ p3DObj->NbcSetTransform(*pMat);
+ delete pMat;
+ }
+
+ // set scene transformation again at scene
+ pScene->NbcSetTransform(aSceneTAR.maMat);
+ pScene->NbcSetSnapRect(aSceneTAR.maRect);
+
+ return true;
+ }
+ break;
+ }
+ default:
+ return SvxShape::setPropertyValueImpl(rName, pProperty, rValue);
+ }
+
+ throw IllegalArgumentException();
+}
+
+//----------------------------------------------------------------------
+
+bool Svx3DSceneObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Objekt in eine homogene 4x4 Matrix packen
+ ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY:
+ {
+ // get CameraGeometry from scene
+ E3dScene* pScene = static_cast< E3dScene* >( mpObj.get() );
+ drawing::CameraGeometry aCamGeo;
+
+ // fill Vectors from scene camera
+ B3dCamera& aCameraSet = pScene->GetCameraSet();
+ basegfx::B3DPoint aVRP(aCameraSet.GetVRP());
+ basegfx::B3DVector aVPN(aCameraSet.GetVPN());
+ basegfx::B3DVector aVUP(aCameraSet.GetVUV());
+
+ // transfer to structure
+ aCamGeo.vrp.PositionX = aVRP.getX();
+ aCamGeo.vrp.PositionY = aVRP.getY();
+ aCamGeo.vrp.PositionZ = aVRP.getZ();
+ aCamGeo.vpn.DirectionX = aVPN.getX();
+ aCamGeo.vpn.DirectionY = aVPN.getY();
+ aCamGeo.vpn.DirectionZ = aVPN.getZ();
+ aCamGeo.vup.DirectionX = aVUP.getX();
+ aCamGeo.vup.DirectionY = aVUP.getY();
+ aCamGeo.vup.DirectionZ = aVUP.getZ();
+
+ rValue <<= aCamGeo;
+ break;
+ }
+ default:
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ return true;
+}
+
+// ::com::sun::star::lang::XServiceInfo
+uno::Sequence< OUString > SAL_CALL Svx3DSceneObject::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() );
+ comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.Shape3DScene" );
+ return aSeq;
+}
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+//----------------------------------------------------------------------
+Svx3DCubeObject::Svx3DCubeObject( SdrObject* pObj ) throw()
+: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DCUBEOBJEKT), aSvxMapProvider.GetPropertySet(SVXMAP_3DCUBEOBJEKT, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+//----------------------------------------------------------------------
+Svx3DCubeObject::~Svx3DCubeObject() throw()
+{
+}
+
+//----------------------------------------------------------------------
+bool Svx3DCubeObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Transformationsmatrix in das Objekt packen
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ return true;
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_POSITION:
+ {
+ // Position in das Objekt packen
+ drawing::Position3D aUnoPos;
+ if( rValue >>= aUnoPos )
+ {
+ basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ);
+ static_cast< E3dCubeObj* >( mpObj.get() )->SetCubePos(aPos);
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_SIZE:
+ {
+ // Groesse in das Objekt packen
+ drawing::Direction3D aDirection;
+ if( rValue >>= aDirection )
+ {
+ basegfx::B3DVector aSize(aDirection.DirectionX, aDirection.DirectionY, aDirection.DirectionZ);
+ static_cast< E3dCubeObj* >( mpObj.get() )->SetCubeSize(aSize);
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_POS_IS_CENTER:
+ {
+ sal_Bool bNew = sal_False;
+ // sal_Bool bPosIsCenter in das Objekt packen
+ if( rValue >>= bNew )
+ {
+ static_cast< E3dCubeObj* >( mpObj.get() )->SetPosIsCenter(bNew);
+ return true;
+ }
+ break;
+ }
+ default:
+ return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ throw IllegalArgumentException();
+}
+
+//----------------------------------------------------------------------
+
+bool Svx3DCubeObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Transformation in eine homogene Matrix packen
+ ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_POSITION:
+ {
+ // Position packen
+ const basegfx::B3DPoint& rPos = ((E3dCubeObj*)mpObj.get())->GetCubePos();
+ drawing::Position3D aPos;
+
+ aPos.PositionX = rPos.getX();
+ aPos.PositionY = rPos.getY();
+ aPos.PositionZ = rPos.getZ();
+
+ rValue <<= aPos;
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_SIZE:
+ {
+ // Groesse packen
+ const basegfx::B3DVector& rSize = static_cast<E3dCubeObj*>(mpObj.get())->GetCubeSize();
+ drawing::Direction3D aDir;
+
+ aDir.DirectionX = rSize.getX();
+ aDir.DirectionY = rSize.getY();
+ aDir.DirectionZ = rSize.getZ();
+
+ rValue <<= aDir;
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_POS_IS_CENTER:
+ {
+ rValue <<= static_cast<E3dCubeObj*>(mpObj.get())->GetPosIsCenter();
+ break;
+ }
+ default:
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ return true;
+}
+
+// ::com::sun::star::lang::XServiceInfo
+uno::Sequence< OUString > SAL_CALL Svx3DCubeObject::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() );
+ comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D",
+ "com.sun.star.drawing.Shape3DCube");
+ return aSeq;
+}
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+//----------------------------------------------------------------------
+Svx3DSphereObject::Svx3DSphereObject( SdrObject* pObj ) throw()
+: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DSPHEREOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DSPHEREOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+//----------------------------------------------------------------------
+Svx3DSphereObject::~Svx3DSphereObject() throw()
+{
+}
+
+//----------------------------------------------------------------------
+
+bool Svx3DSphereObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Transformationsmatrix in das Objekt packen
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ return true;
+ break;
+ }
+
+ case OWN_ATTR_3D_VALUE_POSITION:
+ {
+ // Position in das Objekt packen
+ drawing::Position3D aUnoPos;
+ if( rValue >>= aUnoPos )
+ {
+ basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ);
+ static_cast<E3dSphereObj*>(mpObj.get())->SetCenter(aPos);
+ return true;
+ }
+ break;
+ }
+
+ case OWN_ATTR_3D_VALUE_SIZE:
+ {
+ // Groesse in das Objekt packen
+ drawing::Direction3D aDir;
+ if( rValue >>= aDir )
+ {
+ basegfx::B3DVector aPos(aDir.DirectionX, aDir.DirectionY, aDir.DirectionZ);
+ static_cast<E3dSphereObj*>(mpObj.get())->SetSize(aPos);
+ return true;
+ }
+ break;
+ }
+ default:
+ return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ throw IllegalArgumentException();
+}
+
+//----------------------------------------------------------------------
+
+bool Svx3DSphereObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Transformation in eine homogene Matrix packen
+ ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_POSITION:
+ {
+ // Position packen
+ const basegfx::B3DPoint& rPos = ((E3dSphereObj*)mpObj.get())->Center();
+ drawing::Position3D aPos;
+
+ aPos.PositionX = rPos.getX();
+ aPos.PositionY = rPos.getY();
+ aPos.PositionZ = rPos.getZ();
+
+ rValue <<= aPos;
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_SIZE:
+ {
+ // Groesse packen
+ const basegfx::B3DVector& rSize = ((E3dSphereObj*)mpObj.get())->Size();
+ drawing::Direction3D aDir;
+
+ aDir.DirectionX = rSize.getX();
+ aDir.DirectionY = rSize.getY();
+ aDir.DirectionZ = rSize.getZ();
+
+ rValue <<= aDir;
+ break;
+ }
+ default:
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ return true;
+}
+
+// ::com::sun::star::lang::XServiceInfo
+uno::Sequence< OUString > SAL_CALL Svx3DSphereObject::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() );
+ comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D",
+ "com.sun.star.drawing.Shape3DSphere");
+ return aSeq;
+}
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+//----------------------------------------------------------------------
+Svx3DLatheObject::Svx3DLatheObject( SdrObject* pObj ) throw()
+: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DLATHEOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DLATHEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+//----------------------------------------------------------------------
+Svx3DLatheObject::~Svx3DLatheObject() throw()
+{
+}
+
+bool PolyPolygonShape3D_to_B3dPolyPolygon(
+ const Any& rValue,
+ basegfx::B3DPolyPolygon& rResultPolygon,
+ bool bCorrectPolygon)
+{
+ drawing::PolyPolygonShape3D aSourcePolyPolygon;
+ if( !(rValue >>= aSourcePolyPolygon) )
+ return false;
+
+ sal_Int32 nOuterSequenceCount = aSourcePolyPolygon.SequenceX.getLength();
+ if(nOuterSequenceCount != aSourcePolyPolygon.SequenceY.getLength() || nOuterSequenceCount != aSourcePolyPolygon.SequenceZ.getLength())
+ return false;
+
+ drawing::DoubleSequence* pInnerSequenceX = aSourcePolyPolygon.SequenceX.getArray();
+ drawing::DoubleSequence* pInnerSequenceY = aSourcePolyPolygon.SequenceY.getArray();
+ drawing::DoubleSequence* pInnerSequenceZ = aSourcePolyPolygon.SequenceZ.getArray();
+ for(sal_Int32 a(0L);a<nOuterSequenceCount;a++)
+ {
+ sal_Int32 nInnerSequenceCount = pInnerSequenceX->getLength();
+ if(nInnerSequenceCount != pInnerSequenceY->getLength() || nInnerSequenceCount != pInnerSequenceZ->getLength())
+ {
+ return false;
+ }
+ basegfx::B3DPolygon aNewPolygon;
+ double* pArrayX = pInnerSequenceX->getArray();
+ double* pArrayY = pInnerSequenceY->getArray();
+ double* pArrayZ = pInnerSequenceZ->getArray();
+ for(sal_Int32 b(0L);b<nInnerSequenceCount;b++)
+ {
+ aNewPolygon.append(basegfx::B3DPoint(*pArrayX++,*pArrayY++,*pArrayZ++));
+ }
+ pInnerSequenceX++;
+ pInnerSequenceY++;
+ pInnerSequenceZ++;
+
+ // #i101520# correction is needed for imported polygons of old format,
+ // see callers
+ if(bCorrectPolygon)
+ {
+ basegfx::tools::checkClosed(aNewPolygon);
+ }
+
+ rResultPolygon.append(aNewPolygon);
+ }
+ return true;
+}
+
+static void B3dPolyPolygon_to_PolyPolygonShape3D( const basegfx::B3DPolyPolygon& rSourcePolyPolygon, Any& rValue )
+{
+ drawing::PolyPolygonShape3D aRetval;
+ aRetval.SequenceX.realloc(rSourcePolyPolygon.count());
+ aRetval.SequenceY.realloc(rSourcePolyPolygon.count());
+ aRetval.SequenceZ.realloc(rSourcePolyPolygon.count());
+ drawing::DoubleSequence* pOuterSequenceX = aRetval.SequenceX.getArray();
+ drawing::DoubleSequence* pOuterSequenceY = aRetval.SequenceY.getArray();
+ drawing::DoubleSequence* pOuterSequenceZ = aRetval.SequenceZ.getArray();
+ for(sal_uInt32 a(0L);a<rSourcePolyPolygon.count();a++)
+ {
+ const basegfx::B3DPolygon aPoly(rSourcePolyPolygon.getB3DPolygon(a));
+ sal_Int32 nPointCount(aPoly.count());
+ if(aPoly.isClosed()) nPointCount++;
+ pOuterSequenceX->realloc(nPointCount);
+ pOuterSequenceY->realloc(nPointCount);
+ pOuterSequenceZ->realloc(nPointCount);
+ double* pInnerSequenceX = pOuterSequenceX->getArray();
+ double* pInnerSequenceY = pOuterSequenceY->getArray();
+ double* pInnerSequenceZ = pOuterSequenceZ->getArray();
+ for(sal_uInt32 b(0L);b<aPoly.count();b++)
+ {
+ const basegfx::B3DPoint aPoint(aPoly.getB3DPoint(b));
+ *pInnerSequenceX++ = aPoint.getX();
+ *pInnerSequenceY++ = aPoint.getY();
+ *pInnerSequenceZ++ = aPoint.getZ();
+ }
+ if(aPoly.isClosed())
+ {
+ const basegfx::B3DPoint aPoint(aPoly.getB3DPoint(0L));
+ *pInnerSequenceX++ = aPoint.getX();
+ *pInnerSequenceY++ = aPoint.getY();
+ *pInnerSequenceZ++ = aPoint.getZ();
+ }
+ pOuterSequenceX++;
+ pOuterSequenceY++;
+ pOuterSequenceZ++;
+ }
+ rValue <<= aRetval;
+}
+
+//----------------------------------------------------------------------
+
+bool Svx3DLatheObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Transformationsmatrix in das Objekt packen
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ return true;
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
+ {
+ // Polygondefinition in das Objekt packen
+ basegfx::B3DPolyPolygon aNewB3DPolyPolygon;
+
+ // #i101520# Probably imported
+ if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, true ) )
+ {
+ // #105127# SetPolyPoly3D sets the Svx3DVerticalSegmentsItem to the number
+ // of points of the polygon. Thus, value gets lost. To avoid this, rescue
+ // item here and re-set after setting the polygon.
+ const sal_uInt32 nPrevVerticalSegs(static_cast<E3dLatheObj*>(mpObj.get())->GetVerticalSegments());
+
+ // Polygon setzen
+ const basegfx::B3DHomMatrix aIdentity;
+ const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity));
+ static_cast<E3dLatheObj*>(mpObj.get())->SetPolyPoly2D(aB2DPolyPolygon);
+ const sal_uInt32 nPostVerticalSegs(static_cast<E3dLatheObj*>(mpObj.get())->GetVerticalSegments());
+
+ if(nPrevVerticalSegs != nPostVerticalSegs)
+ {
+ // restore the vertical segment count
+ static_cast<E3dLatheObj*>(mpObj.get())->SetMergedItem(Svx3DVerticalSegmentsItem(nPrevVerticalSegs));
+ }
+ return true;
+ }
+ break;
+ }
+ default:
+ return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ throw IllegalArgumentException();
+}
+
+//----------------------------------------------------------------------
+bool Svx3DLatheObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Transformation in eine homogene Matrix packen
+ drawing::HomogenMatrix aHomMat;
+ basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(mpObj.get())->GetTransform();
+
+ // pack evtl. transformed matrix to output
+ aHomMat.Line1.Column1 = aMat.get(0, 0);
+ aHomMat.Line1.Column2 = aMat.get(0, 1);
+ aHomMat.Line1.Column3 = aMat.get(0, 2);
+ aHomMat.Line1.Column4 = aMat.get(0, 3);
+ aHomMat.Line2.Column1 = aMat.get(1, 0);
+ aHomMat.Line2.Column2 = aMat.get(1, 1);
+ aHomMat.Line2.Column3 = aMat.get(1, 2);
+ aHomMat.Line2.Column4 = aMat.get(1, 3);
+ aHomMat.Line3.Column1 = aMat.get(2, 0);
+ aHomMat.Line3.Column2 = aMat.get(2, 1);
+ aHomMat.Line3.Column3 = aMat.get(2, 2);
+ aHomMat.Line3.Column4 = aMat.get(2, 3);
+ aHomMat.Line4.Column1 = aMat.get(3, 0);
+ aHomMat.Line4.Column2 = aMat.get(3, 1);
+ aHomMat.Line4.Column3 = aMat.get(3, 2);
+ aHomMat.Line4.Column4 = aMat.get(3, 3);
+
+ rValue <<= aHomMat;
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
+ {
+ const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dLatheObj*>(mpObj.get())->GetPolyPoly2D();
+ const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly));
+
+ B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue);
+ break;
+ }
+ default:
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ return true;
+}
+
+// ::com::sun::star::lang::XServiceInfo
+uno::Sequence< OUString > SAL_CALL Svx3DLatheObject::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() );
+ comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D",
+ "com.sun.star.drawing.Shape3DLathe");
+ return aSeq;
+}
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+Svx3DExtrudeObject::Svx3DExtrudeObject( SdrObject* pObj ) throw()
+: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DEXTRUDEOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DEXTRUDEOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+//----------------------------------------------------------------------
+Svx3DExtrudeObject::~Svx3DExtrudeObject() throw()
+{
+}
+
+//----------------------------------------------------------------------
+
+bool Svx3DExtrudeObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Transformationsmatrix in das Objekt packen
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ return true;
+ break;
+ }
+
+ case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
+ {
+ // Polygondefinition in das Objekt packen
+ basegfx::B3DPolyPolygon aNewB3DPolyPolygon;
+
+ // #i101520# Probably imported
+ if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, true ) )
+ {
+ // Polygon setzen
+ const basegfx::B3DHomMatrix aIdentity;
+ const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity));
+ static_cast<E3dExtrudeObj*>(mpObj.get())->SetExtrudePolygon(aB2DPolyPolygon);
+ return true;
+ }
+ break;
+ }
+ default:
+ return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ throw IllegalArgumentException();
+}
+
+//----------------------------------------------------------------------
+
+bool Svx3DExtrudeObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Transformation in eine homogene Matrix packen
+ drawing::HomogenMatrix aHomMat;
+ basegfx::B3DHomMatrix aMat = ((E3dObject*)mpObj.get())->GetTransform();
+
+ // pack evtl. transformed matrix to output
+ aHomMat.Line1.Column1 = aMat.get(0, 0);
+ aHomMat.Line1.Column2 = aMat.get(0, 1);
+ aHomMat.Line1.Column3 = aMat.get(0, 2);
+ aHomMat.Line1.Column4 = aMat.get(0, 3);
+ aHomMat.Line2.Column1 = aMat.get(1, 0);
+ aHomMat.Line2.Column2 = aMat.get(1, 1);
+ aHomMat.Line2.Column3 = aMat.get(1, 2);
+ aHomMat.Line2.Column4 = aMat.get(1, 3);
+ aHomMat.Line3.Column1 = aMat.get(2, 0);
+ aHomMat.Line3.Column2 = aMat.get(2, 1);
+ aHomMat.Line3.Column3 = aMat.get(2, 2);
+ aHomMat.Line3.Column4 = aMat.get(2, 3);
+ aHomMat.Line4.Column1 = aMat.get(3, 0);
+ aHomMat.Line4.Column2 = aMat.get(3, 1);
+ aHomMat.Line4.Column3 = aMat.get(3, 2);
+ aHomMat.Line4.Column4 = aMat.get(3, 3);
+
+ rValue <<= aHomMat;
+ break;
+ }
+
+ case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
+ {
+ // Polygondefinition packen
+ const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dExtrudeObj*>(mpObj.get())->GetExtrudePolygon();
+ const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly));
+
+ B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue);
+ break;
+ }
+ default:
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ return true;
+}
+
+// ::com::sun::star::lang::XServiceInfo
+uno::Sequence< OUString > SAL_CALL Svx3DExtrudeObject::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() );
+ comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D",
+ "com.sun.star.drawing.Shape3DExtrude");
+ return aSeq;
+}
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+//----------------------------------------------------------------------
+Svx3DPolygonObject::Svx3DPolygonObject( SdrObject* pObj ) throw()
+: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_3DPOLYGONOBJECT), aSvxMapProvider.GetPropertySet(SVXMAP_3DPOLYGONOBJECT, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+//----------------------------------------------------------------------
+Svx3DPolygonObject::~Svx3DPolygonObject() throw()
+{
+}
+
+//----------------------------------------------------------------------
+bool Svx3DPolygonObject::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ // Transformationsmatrix in das Objekt packen
+ if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+ return true;
+ break;
+ }
+
+ case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
+ {
+ // Polygondefinition in das Objekt packen
+ basegfx::B3DPolyPolygon aNewB3DPolyPolygon;
+
+ // #i101520# Direct API data (e.g. from chart)
+ if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) )
+ {
+ // Polygon setzen
+ static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyPolygon3D(aNewB3DPolyPolygon);
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_NORMALSPOLYGON3D:
+ {
+ // Normalendefinition in das Objekt packen
+ basegfx::B3DPolyPolygon aNewB3DPolyPolygon;
+
+ // #i101520# Direct API data (e.g. from chart)
+ if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) )
+ {
+ // Polygon setzen
+ static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyNormals3D(aNewB3DPolyPolygon);
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_TEXTUREPOLYGON3D:
+ {
+ // Texturdefinition in das Objekt packen
+ basegfx::B3DPolyPolygon aNewB3DPolyPolygon;
+
+ // #i101520# Direct API data (e.g. from chart)
+ if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) )
+ {
+ // Polygon setzen
+ const basegfx::B3DHomMatrix aIdentity;
+ const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity));
+ static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyTexture2D(aB2DPolyPolygon);
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_3D_VALUE_LINEONLY:
+ {
+ sal_Bool bNew = sal_False;
+ if( rValue >>= bNew )
+ {
+ static_cast<E3dPolygonObj*>(mpObj.get())->SetLineOnly(bNew);
+ return true;
+ }
+ break;
+ }
+ default:
+ return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ throw IllegalArgumentException();
+}
+
+//----------------------------------------------------------------------
+bool Svx3DPolygonObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
+ {
+ ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+ break;
+ }
+
+ case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
+ {
+ B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyPolygon3D(),rValue);
+ break;
+ }
+
+ case OWN_ATTR_3D_VALUE_NORMALSPOLYGON3D:
+ {
+ B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyNormals3D(),rValue);
+ break;
+ }
+
+ case OWN_ATTR_3D_VALUE_TEXTUREPOLYGON3D:
+ {
+ // Texturdefinition packen
+ const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyTexture2D();
+ const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly));
+
+ B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon,rValue);
+ break;
+ }
+
+ case OWN_ATTR_3D_VALUE_LINEONLY:
+ {
+ rValue <<= (sal_Bool)static_cast<E3dPolygonObj*>(mpObj.get())->GetLineOnly();
+ break;
+ }
+
+ default:
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ return true;
+}
+
+// ::com::sun::star::lang::XServiceInfo
+uno::Sequence< OUString > SAL_CALL Svx3DPolygonObject::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ Sequence< OUString > aSeq( SvxShape::getSupportedServiceNames() );
+ comphelper::ServiceInfoHelper::addToSequence( aSeq, 2, "com.sun.star.drawing.Shape3D",
+ "com.sun.star.drawing.Shape3DPolygon");
+ return aSeq;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
new file mode 100644
index 000000000000..f4bfea185fb4
--- /dev/null
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -0,0 +1,996 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/embed/XLinkageSupport.hpp>
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+
+#define _SVX_USE_UNOGLOBALS_
+
+#include <vcl/virdev.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/svdpool.hxx>
+#ifndef SVX_LIGHT
+#include <sot/clsids.hxx>
+#include <sfx2/frmdescr.hxx>
+#endif
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/docfile.hxx>
+
+#include <sot/storage.hxx>
+#include <sot/exchange.hxx>
+#include <svtools/FilterConfigItem.hxx>
+
+#include <svx/svdmodel.hxx>
+#include "shapeimpl.hxx"
+
+#include <svx/unoshprp.hxx>
+
+#include "unoapi.hxx"
+#include "svx/svdpagv.hxx"
+#include "svx/svdview.hxx"
+#include "svdglob.hxx"
+#include "svdstr.hrc"
+
+///////////////////////////////////////////////////////////////////////
+
+extern sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream, FilterConfigItem* pFilterConfigItem = NULL, sal_Bool bPlaceable = sal_True );
+
+///////////////////////////////////////////////////////////////////////
+
+using namespace ::osl;
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::beans;
+
+///////////////////////////////////////////////////////////////////////
+SvxOle2Shape::SvxOle2Shape( SdrObject* pObject ) throw()
+: SvxShape( pObject, aSvxMapProvider.GetMap(SVXMAP_OLE2), aSvxMapProvider.GetPropertySet(SVXMAP_OLE2, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+}
+
+SvxOle2Shape::SvxOle2Shape( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw ()
+: SvxShape( pObject, pPropertyMap, pPropertySet )
+{
+}
+
+SvxOle2Shape::~SvxOle2Shape() throw()
+{
+}
+
+::com::sun::star::uno::Any SAL_CALL SvxOle2Shape::queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return SvxShape::queryAggregation( rType );
+}
+
+//XPropertySet
+bool SvxOle2Shape::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+/*
+ case OWN_ATTR_CLSID:
+ {
+ OUString aCLSID;
+ if( rValue >>= aCLSID )
+ {
+ // init an ole object with a global name
+ SdrOle2Obj* pOle2 = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ if( pOle2 )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj = pOle2->GetObjRef();
+ if ( !xObj.is() )
+ {
+ SvGlobalName aClassName;
+ if( aClassName.MakeId( aCLSID ) )
+ {
+ SfxObjectShell* pPersist = mpModel->GetPersist();
+ ::rtl::OUString aPersistName;
+ Any aAny( getPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ) ) );
+ aAny >>= aPersistName;
+
+ //TODO/LATER: how to cope with creation failure?!
+ xObj = pPersist->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aPersistName );
+ if( xObj.is() )
+ {
+ aAny <<= aPersistName;
+ setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), aAny );
+ pOle2->SetObjRef( xObj );
+
+ Rectangle aRect = pOle2->GetLogicRect();
+ awt::Size aSz;
+ Size aSize( pOle2->GetLogicRect().GetSize() );
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( pOle2->GetAspect(), aSz );
+ }
+ }
+ }
+ }
+ return true;
+ }
+ break;
+ }
+*/
+ case OWN_ATTR_OLE_VISAREA:
+ {
+ // TODO/LATER: seems to make no sence for iconified object
+
+ awt::Rectangle aVisArea;
+ if( (rValue >>= aVisArea) && mpObj->ISA(SdrOle2Obj))
+ {
+ Size aTmp( aVisArea.X + aVisArea.Width, aVisArea.Y + aVisArea.Height );
+ uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)mpObj.get())->GetObjRef();
+ if( xObj.is() )
+ {
+ try
+ {
+ MapUnit aMapUnit( MAP_100TH_MM ); // the API handles with MAP_100TH_MM map mode
+ MapUnit aObjUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( embed::Aspects::MSOLE_CONTENT ) );
+ aTmp = OutputDevice::LogicToLogic( aTmp, aMapUnit, aObjUnit );
+ xObj->setVisualAreaSize( embed::Aspects::MSOLE_CONTENT, awt::Size( aTmp.Width(), aTmp.Height() ) );
+ }
+ catch( uno::Exception& )
+ {
+ OSL_ENSURE( sal_False, "Couldn't set the visual area for the object!\n" );
+ }
+ }
+
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_OLE_ASPECT:
+ {
+ sal_Int64 nAspect = 0;
+ if( rValue >>= nAspect )
+ {
+ static_cast<SdrOle2Obj*>(mpObj.get())->SetAspect( nAspect );
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_CLSID:
+ {
+ OUString aCLSID;
+ if( rValue >>= aCLSID )
+ {
+ // init a ole object with a global name
+ SvGlobalName aClassName;
+ if( aClassName.MakeId( aCLSID ) )
+ {
+ if( createObject( aClassName ) )
+ return true;
+ }
+ }
+ break;
+ }
+ case OWN_ATTR_THUMBNAIL:
+ {
+ OUString aURL;
+ if( rValue >>= aURL )
+ {
+ GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) );
+ static_cast<SdrOle2Obj*>(mpObj.get())->SetGraphic( &aGrafObj.GetGraphic() );
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_VALUE_GRAPHIC:
+ {
+ uno::Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
+ if( xGraphic.is() )
+ {
+ SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ if( pOle )
+ {
+ GraphicObject aGrafObj( xGraphic );
+ const Graphic aGraphic( aGrafObj.GetGraphic() );
+ pOle->SetGraphicToObj( aGraphic, rtl::OUString() );
+ }
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_PERSISTNAME:
+ {
+ OUString aPersistName;
+ if( rValue >>= aPersistName )
+ {
+ static_cast<SdrOle2Obj*>(mpObj.get())->SetPersistName( aPersistName );
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_OLE_LINKURL:
+ {
+ OUString aLinkURL;
+ if( rValue >>= aLinkURL )
+ {
+ createLink( aLinkURL );
+ return true;
+ }
+ break;
+ }
+ default:
+ return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ throw IllegalArgumentException();
+}
+
+bool SvxOle2Shape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_CLSID:
+ {
+ OUString aCLSID;
+ SvGlobalName aClassName = GetClassName_Impl(aCLSID);
+ rValue <<= aCLSID;
+ break;
+ }
+
+ case OWN_ATTR_INTERNAL_OLE:
+ {
+ rtl::OUString sCLSID;
+ rValue <<= SotExchange::IsInternal( GetClassName_Impl(sCLSID) );
+ break;
+ }
+
+ case OWN_ATTR_METAFILE:
+ {
+ SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get());
+ if( pObj )
+ {
+ Graphic* pGraphic = pObj->GetGraphic();
+ if( pGraphic )
+ {
+ BOOL bIsWMF = FALSE;
+ if ( pGraphic->IsLink() )
+ {
+ GfxLink aLnk = pGraphic->GetLink();
+ if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF )
+ {
+ bIsWMF = TRUE;
+ uno::Sequence<sal_Int8> aSeq((sal_Int8*)aLnk.GetData(), (sal_Int32) aLnk.GetDataSize());
+ rValue <<= aSeq;
+ }
+ }
+ if ( !bIsWMF )
+ {
+ GDIMetaFile aMtf;
+ if ( pGraphic->GetType() != GRAPHIC_BITMAP )
+ aMtf = pObj->GetGraphic()->GetGDIMetaFile();
+ else
+ {
+ VirtualDevice aVirDev;
+ aMtf.Record( &aVirDev );
+ pGraphic->Draw( &aVirDev, Point(), pGraphic->GetPrefSize() );
+ aMtf.Stop();
+ aMtf.SetPrefSize( pGraphic->GetPrefSize() );
+ aMtf.SetPrefMapMode( pGraphic->GetPrefMapMode() );
+ }
+ SvMemoryStream aDestStrm( 65535, 65535 );
+ ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False );
+ const uno::Sequence<sal_Int8> aSeq(
+ static_cast< const sal_Int8* >(aDestStrm.GetData()),
+ aDestStrm.GetEndOfData());
+ rValue <<= aSeq;
+ }
+ }
+ }
+ else
+ {
+ rValue = GetBitmap( sal_True );
+ }
+ break;
+ }
+
+ case OWN_ATTR_OLE_VISAREA:
+ {
+ awt::Rectangle aVisArea;
+ if( mpObj->ISA(SdrOle2Obj))
+ {
+ MapMode aMapMode( MAP_100TH_MM ); // the API uses this map mode
+ Size aTmp = ((SdrOle2Obj*)mpObj.get())->GetOrigObjSize( &aMapMode ); // get the size in the requested map mode
+ aVisArea = awt::Rectangle( 0, 0, aTmp.Width(), aTmp.Height() );
+ }
+
+ rValue <<= aVisArea;
+ break;
+ }
+
+ case OWN_ATTR_OLESIZE:
+ {
+ Size aTmp( static_cast<SdrOle2Obj*>(mpObj.get())->GetOrigObjSize() );
+ rValue <<= awt::Size( aTmp.Width(), aTmp.Height() );
+ break;
+ }
+
+ case OWN_ATTR_OLE_ASPECT:
+ {
+ rValue <<= static_cast<SdrOle2Obj*>(mpObj.get())->GetAspect();
+ break;
+ }
+
+ case OWN_ATTR_OLEMODEL:
+ case OWN_ATTR_OLE_EMBEDDED_OBJECT:
+ case OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT:
+ {
+ SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>( mpObj.get() );
+ if( pObj )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
+ if ( xObj.is()
+ && ( pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT || pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT || svt::EmbeddedObjectRef::TryRunningState( xObj ) ) )
+ {
+ // Discussed with CL fue to the before GetPaintingPageView
+ // usage. Removed it, former fallback is used now
+ if ( pProperty->nWID == OWN_ATTR_OLEMODEL || pProperty->nWID == OWN_ATTR_OLE_EMBEDDED_OBJECT )
+ {
+#ifdef DBG_UTIL
+ const sal_Bool bSuccess(pObj->AddOwnLightClient());
+ OSL_ENSURE( bSuccess, "An object without client is provided!" );
+#else
+ pObj->AddOwnLightClient();
+#endif
+ }
+
+ if ( pProperty->nWID == OWN_ATTR_OLEMODEL )
+ rValue <<= pObj->GetObjRef()->getComponent();
+ else
+ rValue <<= xObj;
+ }
+ }
+ break;
+ }
+
+ case OWN_ATTR_VALUE_GRAPHIC:
+ {
+ uno::Reference< graphic::XGraphic > xGraphic;
+ Graphic* pGraphic = static_cast<SdrOle2Obj*>( mpObj.get() )->GetGraphic();
+ if( pGraphic )
+ xGraphic = pGraphic->GetXGraphic();
+ rValue <<= xGraphic;
+ break;
+ }
+
+ case OWN_ATTR_THUMBNAIL:
+ {
+ OUString aURL;
+ SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ if( pOle )
+ {
+ Graphic* pGraphic = pOle->GetGraphic();
+
+ // if there isn't already a preview graphic set, check if we need to generate
+ // one if model says so
+ if( pGraphic == NULL && !pOle->IsEmptyPresObj() && mpModel->IsSaveOLEPreview() )
+ pGraphic = pOle->GetGraphic();
+
+ if( pGraphic )
+ {
+ GraphicObject aObj( *pGraphic );
+ aURL = OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
+ aURL += OUString::createFromAscii( aObj.GetUniqueID().GetBuffer() );
+ }
+ }
+ rValue <<= aURL;
+ break;
+ }
+ case OWN_ATTR_PERSISTNAME:
+ {
+ OUString aPersistName;
+ SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+
+ if( pOle )
+ {
+ aPersistName = pOle->GetPersistName();
+ if( aPersistName.getLength() )
+ {
+ ::comphelper::IEmbeddedHelper *pPersist = mpObj->GetModel()->GetPersist();
+ if( (NULL == pPersist) || !pPersist->getEmbeddedObjectContainer().HasEmbeddedObject( pOle->GetPersistName() ) )
+ aPersistName = OUString();
+ }
+ }
+
+ rValue <<= aPersistName;
+ break;
+ }
+ case OWN_ATTR_OLE_LINKURL:
+ {
+ OUString aLinkURL;
+ SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+
+ if( pOle )
+ {
+ uno::Reference< embed::XLinkageSupport > xLink( pOle->GetObjRef(), uno::UNO_QUERY );
+ if ( xLink.is() && xLink->isLink() )
+ aLinkURL = xLink->getLinkURL();
+ }
+
+ rValue <<= aLinkURL;
+ break;
+ }
+ default:
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ return true;
+}
+
+sal_Bool SvxOle2Shape::createObject( const SvGlobalName &aClassName )
+{
+ DBG_TESTSOLARMUTEX();
+
+ SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ if ( !pOle2Obj || !pOle2Obj->IsEmpty() )
+ return sal_False;
+
+ // create storage and inplace object
+ ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist();
+ ::rtl::OUString aPersistName;
+ OUString aTmpStr;
+ if( getPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ) ) >>= aTmpStr )
+ aPersistName = aTmpStr;
+
+ //TODO/LATER: how to cope with creation failure?!
+ uno::Reference < embed::XEmbeddedObject > xObj( pPersist->getEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aPersistName ) );
+ if( xObj.is() )
+ {
+ Rectangle aRect = pOle2Obj->GetLogicRect();
+ if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 )
+ {
+ // TODO/LATER: is it possible that this method is used to create an iconified object?
+ // default size
+ try
+ {
+ awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() );
+ aRect.SetSize( Size( aSz.Width, aSz.Height ) );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {}
+ pOle2Obj->SetLogicRect( aRect );
+ }
+ else
+ {
+ awt::Size aSz;
+ Size aSize = pOle2Obj->GetLogicRect().GetSize();
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( pOle2Obj->GetAspect(), aSz );
+ }
+
+ // connect the object after the visual area is set
+ setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), Any( aTmpStr = aPersistName ) );
+
+ // the object is inserted during setting of PersistName property usually
+ if( pOle2Obj->IsEmpty() )
+ pOle2Obj->SetObjRef( xObj );
+ }
+
+ return xObj.is();
+}
+
+sal_Bool SvxOle2Shape::createLink( const ::rtl::OUString& aLinkURL )
+{
+ DBG_TESTSOLARMUTEX();
+
+ SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ if ( !pOle2Obj || !pOle2Obj->IsEmpty() )
+ return sal_False;
+
+ ::rtl::OUString aPersistName;
+
+ ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist();
+
+ uno::Sequence< beans::PropertyValue > aMediaDescr( 1 );
+ aMediaDescr[0].Name = ::rtl::OUString::createFromAscii( "URL" );
+ aMediaDescr[0].Value <<= aLinkURL;
+
+ uno::Reference< task::XInteractionHandler > xInteraction = pPersist->getInteractionHandler();
+ if ( xInteraction.is() )
+ {
+ aMediaDescr.realloc( 2 );
+ aMediaDescr[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) );
+ aMediaDescr[1].Value <<= xInteraction;
+ }
+
+ //TODO/LATER: how to cope with creation failure?!
+ uno::Reference< embed::XEmbeddedObject > xObj =
+ pPersist->getEmbeddedObjectContainer().InsertEmbeddedLink( aMediaDescr , aPersistName );
+
+ if( xObj.is() )
+ {
+ Rectangle aRect = pOle2Obj->GetLogicRect();
+ if ( aRect.GetWidth() == 100 && aRect.GetHeight() == 100 )
+ {
+ // default size
+ try
+ {
+ awt::Size aSz = xObj->getVisualAreaSize( pOle2Obj->GetAspect() );
+ aRect.SetSize( Size( aSz.Width, aSz.Height ) );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {}
+ pOle2Obj->SetLogicRect( aRect );
+ }
+ else
+ {
+ awt::Size aSz;
+ Size aSize = pOle2Obj->GetLogicRect().GetSize();
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( pOle2Obj->GetAspect(), aSz );
+ }
+
+ // connect the object after the visual area is set
+ setPropertyValue( OUString::createFromAscii( UNO_NAME_OLE2_PERSISTNAME ), uno::makeAny( aPersistName ) );
+
+ // the object is inserted during setting of PersistName property usually
+ if ( pOle2Obj->IsEmpty() )
+ pOle2Obj->SetObjRef( xObj );
+ }
+
+ return xObj.is();
+}
+
+void SvxOle2Shape::resetModifiedState()
+{
+ ::comphelper::IEmbeddedHelper* pPersist = mpModel ? mpModel->GetPersist() : 0;
+ if( pPersist && !pPersist->isEnableSetModified() )
+ {
+ SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+ if( pOle && !pOle->IsEmpty() )
+ {
+ uno::Reference < util::XModifiable > xMod( pOle->GetObjRef(), uno::UNO_QUERY );
+ if( xMod.is() )
+ // TODO/MBA: what's this?!
+ xMod->setModified( sal_False );
+ }
+ }
+}
+
+const SvGlobalName SvxOle2Shape::GetClassName_Impl(rtl::OUString& rHexCLSID)
+{
+ DBG_TESTSOLARMUTEX();
+ SvGlobalName aClassName;
+ SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+
+ if( pOle2Obj )
+ {
+ rHexCLSID = rtl::OUString();
+
+ if( pOle2Obj->IsEmpty() )
+ {
+ ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist();
+ if( pPersist )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj =
+ pPersist->getEmbeddedObjectContainer().GetEmbeddedObject( pOle2Obj->GetPersistName() );
+ if ( xObj.is() )
+ {
+ aClassName = SvGlobalName( xObj->getClassID() );
+ rHexCLSID = aClassName.GetHexName();
+ }
+ }
+ }
+
+ if (!rHexCLSID.getLength())
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj( pOle2Obj->GetObjRef() );
+ if ( xObj.is() )
+ {
+ aClassName = SvGlobalName( xObj->getClassID() );
+ rHexCLSID = aClassName.GetHexName();
+ }
+ }
+ }
+
+ return aClassName;
+}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxAppletShape::SvxAppletShape( SdrObject* pObject ) throw()
+: SvxOle2Shape( pObject, aSvxMapProvider.GetMap(SVXMAP_APPLET), aSvxMapProvider.GetPropertySet(SVXMAP_APPLET, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+ SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AppletShape" ) ) );
+}
+
+SvxAppletShape::~SvxAppletShape() throw()
+{
+}
+
+void SvxAppletShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
+{
+ SvxShape::Create( pNewObj, pNewPage );
+ const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
+ createObject(aAppletClassId);
+ SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AppletShape" ) ) );
+}
+
+void SAL_CALL SvxAppletShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ SvxShape::setPropertyValue( aPropertyName, rValue );
+ resetModifiedState();
+}
+
+void SAL_CALL SvxAppletShape::setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ SvxShape::setPropertyValues( aPropertyNames, rValues );
+ resetModifiedState();
+}
+
+bool SvxAppletShape::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) )
+ {
+ if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ {
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ if( xSet.is() )
+ {
+ // allow exceptions to pass through
+ xSet->setPropertyValue( rName, rValue );
+ }
+ }
+ return true;
+ }
+ else
+ {
+ return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+}
+
+bool SvxAppletShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) )
+ {
+ if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ {
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ if( xSet.is() )
+ {
+ rValue = xSet->getPropertyValue( rName );
+ }
+ }
+ return true;
+ }
+ else
+ {
+ return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxPluginShape::SvxPluginShape( SdrObject* pObject ) throw()
+: SvxOle2Shape( pObject, aSvxMapProvider.GetMap(SVXMAP_PLUGIN), aSvxMapProvider.GetPropertySet(SVXMAP_PLUGIN, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+ SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.PluginShape" ) ) );
+}
+
+SvxPluginShape::~SvxPluginShape() throw()
+{
+}
+
+void SvxPluginShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
+{
+ SvxShape::Create( pNewObj, pNewPage );
+ const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
+ createObject(aPluginClassId);
+ SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.PluginShape" ) ) );
+}
+
+void SAL_CALL SvxPluginShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ SvxShape::setPropertyValue( aPropertyName, rValue );
+ resetModifiedState();
+}
+
+void SAL_CALL SvxPluginShape::setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ SvxOle2Shape::setPropertyValues( aPropertyNames, rValues );
+ resetModifiedState();
+}
+
+bool SvxPluginShape::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) )
+ {
+ if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ {
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ if( xSet.is() )
+ {
+ // allow exceptions to pass through
+ xSet->setPropertyValue( rName, rValue );
+ }
+ }
+ return true;
+ }
+ else
+ {
+ return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+}
+
+bool SvxPluginShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) )
+ {
+ if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ {
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ if( xSet.is() )
+ {
+ rValue <<= xSet->getPropertyValue( rName );
+ }
+ }
+ return true;
+ }
+ else
+ {
+ return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxFrameShape::SvxFrameShape( SdrObject* pObject ) throw()
+: SvxOle2Shape( pObject, aSvxMapProvider.GetMap(SVXMAP_FRAME), aSvxMapProvider.GetPropertySet(SVXMAP_FRAME, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+ SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.FrameShape" ) ) );
+}
+
+SvxFrameShape::~SvxFrameShape() throw()
+{
+}
+
+void SvxFrameShape::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage ) throw ()
+{
+ SvxShape::Create( pNewObj, pNewPage );
+ const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
+ createObject(aIFrameClassId);
+ SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.FrameShape" ) ) );
+}
+
+void SAL_CALL SvxFrameShape::setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ SvxShape::setPropertyValue( aPropertyName, rValue );
+ resetModifiedState();
+}
+
+void SAL_CALL SvxFrameShape::setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ SvxOle2Shape::setPropertyValues( aPropertyNames, rValues );
+ resetModifiedState();
+}
+
+bool SvxFrameShape::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) )
+ {
+ if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ {
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ if( xSet.is() )
+ {
+ // allow exceptions to pass through
+ xSet->setPropertyValue( rName, rValue );
+ }
+ }
+ return true;
+ }
+ else
+ {
+ return SvxOle2Shape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+}
+
+bool SvxFrameShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) )
+ {
+ if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+ {
+ uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ if( xSet.is() )
+ {
+ rValue <<= xSet->getPropertyValue( rName );
+ }
+ }
+ return true;
+ }
+ else
+ {
+ return SvxOle2Shape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+}
+
+/***********************************************************************
+* *
+***********************************************************************/
+
+SvxMediaShape::SvxMediaShape( SdrObject* pObj ) throw()
+: SvxShape( pObj, aSvxMapProvider.GetMap(SVXMAP_MEDIA), aSvxMapProvider.GetPropertySet(SVXMAP_MEDIA, SdrObject::GetGlobalDrawObjectItemPool()) )
+{
+ SetShapeType( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.MediaShape" ) ) );
+}
+
+//----------------------------------------------------------------------
+SvxMediaShape::~SvxMediaShape() throw()
+{
+}
+
+//----------------------------------------------------------------------
+
+bool SvxMediaShape::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if( (pProperty->nWID >= OWN_ATTR_MEDIA_URL) && (pProperty->nWID <= OWN_ATTR_MEDIA_ZOOM) )
+ {
+ SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() );
+ ::avmedia::MediaItem aItem;
+ bool bOk = false;
+
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_MEDIA_URL:
+ {
+ OUString aURL;
+ if( rValue >>= aURL )
+ {
+ bOk = true;
+ aItem.setURL( aURL );
+ }
+ }
+ break;
+
+ case( OWN_ATTR_MEDIA_LOOP ):
+ {
+ sal_Bool bLoop = sal_Bool();
+
+ if( rValue >>= bLoop )
+ {
+ bOk = true;
+ aItem.setLoop( bLoop );
+ }
+ }
+ break;
+
+ case( OWN_ATTR_MEDIA_MUTE ):
+ {
+ sal_Bool bMute = sal_Bool();
+
+ if( rValue >>= bMute )
+ {
+ bOk = true;
+ aItem.setMute( bMute );
+ }
+ }
+ break;
+
+ case( OWN_ATTR_MEDIA_VOLUMEDB ):
+ {
+ sal_Int16 nVolumeDB = sal_Int16();
+
+ if( rValue >>= nVolumeDB )
+ {
+ bOk = true;
+ aItem.setVolumeDB( nVolumeDB );
+ }
+ }
+ break;
+
+ case( OWN_ATTR_MEDIA_ZOOM ):
+ {
+ ::com::sun::star::media::ZoomLevel eLevel;
+
+ if( rValue >>= eLevel )
+ {
+ bOk = true;
+ aItem.setZoom( eLevel );
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR("SvxMediaShape::setPropertyValueImpl(), unknown argument!");
+ }
+
+ if( bOk )
+ {
+ pMedia->setMediaProperties( aItem );
+ return true;
+ }
+ }
+ else
+ {
+ return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
+ }
+
+ throw IllegalArgumentException();
+}
+
+//----------------------------------------------------------------------
+
+bool SvxMediaShape::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if( ( pProperty->nWID >= OWN_ATTR_MEDIA_URL ) && ( pProperty->nWID <= OWN_ATTR_MEDIA_ZOOM ) )
+ {
+ SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() );
+ const ::avmedia::MediaItem aItem( pMedia->getMediaProperties() );
+
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_MEDIA_URL:
+ rValue <<= aItem.getURL();
+ break;
+
+ case( OWN_ATTR_MEDIA_LOOP ):
+ rValue <<= (sal_Bool) aItem.isLoop();
+ break;
+
+ case( OWN_ATTR_MEDIA_MUTE ):
+ rValue <<= (sal_Bool) aItem.isMute();
+ break;
+
+ case( OWN_ATTR_MEDIA_VOLUMEDB ):
+ rValue <<= (sal_Int16) aItem.getVolumeDB();
+ break;
+
+ case( OWN_ATTR_MEDIA_ZOOM ):
+ rValue <<= aItem.getZoom();
+ break;
+
+ default:
+ DBG_ERROR("SvxMediaShape::getPropertyValueImpl(), unknown property!");
+ }
+ return true;
+ }
+ else
+ {
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
new file mode 100644
index 000000000000..7b2477c8cb09
--- /dev/null
+++ b/svx/source/unodraw/unoshape.cxx
@@ -0,0 +1,4649 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#define _SVX_USE_UNOGLOBALS_
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/drawing/CircleKind.hpp>
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <vcl/svapp.hxx>
+#include <svl/itemprop.hxx>
+#include <svtools/fltcall.hxx>
+#include <osl/mutex.hxx>
+#include <editeng/unotext.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdoole2.hxx>
+#include <osl/mutex.hxx>
+#include <comphelper/extract.hxx>
+#include "svx/shapepropertynotifier.hxx"
+#include <comphelper/serviceinfohelper.hxx>
+#include <toolkit/unohlp.hxx>
+#include <comphelper/serviceinfohelper.hxx>
+#include <rtl/uuid.h>
+#include <rtl/memory.h>
+#include <vcl/gfxlink.hxx>
+#include <vcl/virdev.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewsh.hxx>
+#include "svx/svdopage.hxx"
+#include "svx/xflbstit.hxx"
+#include "svx/xflbmtit.hxx"
+#include "svx/xlnstit.hxx"
+#include "svx/xlnedit.hxx"
+#include "svx/svdogrp.hxx"
+#include "svx/scene3d.hxx"
+#include "svx/svdmodel.hxx"
+#include "globl3d.hxx"
+#include "svx/fmglob.hxx"
+#include "svx/unopage.hxx"
+#include "svx/view3d.hxx"
+#include "svx/unoshape.hxx"
+#include "svx/svxids.hrc"
+#include "svx/unoshtxt.hxx"
+#include "svx/svdpage.hxx"
+#include "svx/unoshprp.hxx"
+#include "svx/sxciaitm.hxx" // todo: remove
+#include "svx/svdograf.hxx"
+#include "unoapi.hxx"
+#include "svx/svdomeas.hxx"
+#include "svx/svdpagv.hxx"
+#include "svx/svdpool.hxx"
+#include <tools/shl.hxx> //
+#include "svx/dialmgr.hxx" // not nice, we need our own resources some day
+#include "svx/dialogs.hrc" //
+#include "svx/svdocapt.hxx"
+#include <svx/obj3d.hxx>
+#include <tools/diagnose_ex.h>
+#include "svx/xflftrit.hxx"
+#include "svx/xtable.hxx"
+#include "svx/xbtmpit.hxx"
+#include "svx/xflgrit.hxx"
+#include "svx/xflhtit.hxx"
+#include "svx/xlnedit.hxx"
+#include "svx/xlnstit.hxx"
+#include "svx/xlndsit.hxx"
+#include "svdglob.hxx"
+#include "svdstr.hrc"
+#include "unomaster.hxx"
+#include <editeng/outlobj.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+#include <vector>
+
+// #i68523#
+#include "svx/lathe3d.hxx"
+#include "svx/extrud3d.hxx"
+#include "unopolyhelper.hxx"
+
+#include <comphelper/scopeguard.hxx>
+#include <boost/bind.hpp>
+
+using ::rtl::OUString;
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using ::svx::PropertyValueProvider;
+using ::svx::IPropertyValueProvider;
+
+#define QUERYINT( xint ) \
+ if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
+ aAny <<= uno::Reference< xint >(this)
+
+class GDIMetaFile;
+class SvStream;
+sal_Bool ConvertGDIMetaFileToWMF( const GDIMetaFile & rMTF, SvStream & rTargetStream,
+ FilterConfigItem* pFilterConfigItem = NULL, sal_Bool bPlaceable = sal_True );
+
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoGluePointAccess_createInstance( SdrObject* pObject );
+
+/***********************************************************************
+* class SvxShapeImpl *
+***********************************************************************/
+
+struct SvxShapeImpl
+{
+ SvxShape& mrAntiImpl;
+ SfxItemSet* mpItemSet;
+ sal_uInt32 mnObjId;
+ SvxShapeMaster* mpMaster;
+ bool mbHasSdrObjectOwnership;
+ bool mbDisposing;
+
+ /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when
+ * a SvxShape::Create() call is executed. It is then set to the created
+ * SdrObject so a multiple call to SvxShape::Create() with same SdrObject
+ * is prohibited.
+ */
+ SdrObject* mpCreatedObj;
+
+ // for xComponent
+ ::cppu::OInterfaceContainerHelper maDisposeListeners;
+ ::svx::PropertyChangeNotifier maPropertyNotifier;
+
+ SvxShapeImpl( SvxShape& _rAntiImpl, ::osl::Mutex& _rMutex )
+ :mrAntiImpl( _rAntiImpl )
+ ,mpItemSet( NULL )
+ ,mnObjId( 0 )
+ ,mpMaster( NULL )
+ ,mbHasSdrObjectOwnership( false )
+ ,mbDisposing( false )
+ ,mpCreatedObj( NULL )
+ ,maDisposeListeners( _rMutex )
+ ,maPropertyNotifier( _rAntiImpl, _rMutex )
+ {
+ }
+};
+
+/**********************************************************************/
+class ShapePositionProvider : public PropertyValueProvider
+{
+public:
+ ShapePositionProvider( const SvxShapeImpl& _shapeImpl )
+ :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Position" )
+ {
+ }
+
+protected:
+ virtual void getCurrentValue( Any& _out_rCurrentValue ) const
+ {
+ _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getPosition();
+ }
+};
+
+//----------------------------------------------------------------------
+class ShapeSizeProvider : public PropertyValueProvider
+{
+public:
+ ShapeSizeProvider( const SvxShapeImpl& _shapeImpl )
+ :PropertyValueProvider( _shapeImpl.mrAntiImpl, "Size" )
+ {
+ }
+
+protected:
+ virtual void getCurrentValue( Any& _out_rCurrentValue ) const
+ {
+ _out_rCurrentValue <<= static_cast< SvxShape& >( getContext() ).getSize();
+ }
+};
+
+/***********************************************************************
+* class SvxShape *
+***********************************************************************/
+
+DBG_NAME(SvxShape)
+
+SvxShape::SvxShape( SdrObject* pObject ) throw()
+: maSize(100,100)
+, mpImpl( new SvxShapeImpl( *this, maMutex ) )
+, mbIsMultiPropertyCall(false)
+, mpPropSet(aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
+, maPropMapEntries(aSvxMapProvider.GetMap(SVXMAP_SHAPE))
+, mpObj(pObject)
+, mpModel(NULL)
+, mnLockCount(0)
+{
+ DBG_CTOR(SvxShape,NULL);
+ impl_construct();
+}
+
+//----------------------------------------------------------------------
+SvxShape::SvxShape( SdrObject* pObject, const SfxItemPropertyMapEntry* pEntries, const SvxItemPropertySet* pPropertySet ) throw()
+: maSize(100,100)
+, mpImpl( new SvxShapeImpl( *this, maMutex ) )
+, mbIsMultiPropertyCall(false)
+, mpPropSet(pPropertySet)
+, maPropMapEntries(pEntries)
+, mpObj(pObject)
+, mpModel(NULL)
+, mnLockCount(0)
+{
+ DBG_CTOR(SvxShape,NULL);
+ impl_construct();
+}
+
+//----------------------------------------------------------------------
+SvxShape::SvxShape() throw()
+: maSize(100,100)
+, mpImpl( new SvxShapeImpl( *this, maMutex ) )
+, mbIsMultiPropertyCall(false)
+, mpPropSet(aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
+, maPropMapEntries(aSvxMapProvider.GetMap(SVXMAP_SHAPE))
+, mpObj(NULL)
+, mpModel(NULL)
+, mnLockCount(0)
+{
+ DBG_CTOR(SvxShape,NULL);
+ impl_construct();
+}
+
+//----------------------------------------------------------------------
+SvxShape::~SvxShape() throw()
+{
+ ::SolarMutexGuard aGuard;
+
+ DBG_ASSERT( mnLockCount == 0, "Locked shape was disposed!" );
+
+ if ( mpModel )
+ EndListening( *mpModel );
+
+ if ( mpImpl->mpMaster )
+ mpImpl->mpMaster->dispose();
+
+ if ( mpObj.is() )
+ mpObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() );
+
+ if( HasSdrObjectOwnership() && mpObj.is() )
+ {
+ mpImpl->mbHasSdrObjectOwnership = false;
+ SdrObject* pObject = mpObj.get();
+ SdrObject::Free( pObject );
+ }
+
+ delete mpImpl, mpImpl = NULL;
+
+ DBG_DTOR(SvxShape,NULL);
+}
+
+//----------------------------------------------------------------------
+
+void SvxShape::TakeSdrObjectOwnership()
+{
+ mpImpl->mbHasSdrObjectOwnership = true;
+}
+
+//----------------------------------------------------------------------
+
+bool SvxShape::HasSdrObjectOwnership() const
+{
+ if ( !mpImpl->mbHasSdrObjectOwnership )
+ return false;
+
+ OSL_ENSURE( mpObj.is(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" );
+ return mpObj.is();
+}
+
+//----------------------------------------------------------------------
+
+void SvxShape::setShapeKind( sal_uInt32 nKind )
+{
+ mpImpl->mnObjId = nKind;
+}
+
+//----------------------------------------------------------------------
+
+sal_uInt32 SvxShape::getShapeKind() const
+{
+ return mpImpl->mnObjId;
+}
+
+//----------------------------------------------------------------------
+
+void SvxShape::setMaster( SvxShapeMaster* pMaster )
+{
+ mpImpl->mpMaster = pMaster;
+}
+
+SvxShapeMaster* SvxShape::getMaster()
+{
+ return mpImpl->mpMaster;
+}
+
+const SvxShapeMaster* SvxShape::getMaster() const
+{
+ return mpImpl->mpMaster;
+}
+
+//----------------------------------------------------------------------
+
+uno::Any SAL_CALL SvxShape::queryAggregation( const uno::Type& rType ) throw (uno::RuntimeException)
+{
+ if( mpImpl->mpMaster )
+ {
+ uno::Any aAny;
+ if( mpImpl->mpMaster->queryAggregation( rType, aAny ) )
+ return aAny;
+ }
+
+ return SvxShape_UnoImplHelper::queryAggregation(rType);
+}
+
+//----------------------------------------------------------------------
+const ::com::sun::star::uno::Sequence< sal_Int8 > & SvxShape::getUnoTunnelId() throw()
+{
+ static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0;
+ if( !pSeq )
+ {
+ ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+//----------------------------------------------------------------------
+SvxShape* SvxShape::getImplementation( const uno::Reference< uno::XInterface >& xInt )
+{
+ uno::Reference< lang::XUnoTunnel > xUT( xInt, ::com::sun::star::uno::UNO_QUERY );
+ if( xUT.is() )
+ return reinterpret_cast<SvxShape*>(sal::static_int_cast<sal_uIntPtr>(xUT->getSomething( SvxShape::getUnoTunnelId())));
+ else
+ return NULL;
+}
+
+//----------------------------------------------------------------------
+sal_Int64 SAL_CALL SvxShape::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException) \
+{
+ if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_uIntPtr>(this));
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+//----------------------------------------------------------------------
+SvxShape* SvxShape::GetShapeForSdrObj( SdrObject* pObj ) throw()
+{
+ return getImplementation( pObj->getUnoShape() );
+}
+
+//----------------------------------------------------------------------
+::svx::PropertyChangeNotifier& SvxShape::getShapePropertyChangeNotifier()
+{
+ return mpImpl->maPropertyNotifier;
+}
+
+//----------------------------------------------------------------------
+void SvxShape::impl_construct()
+{
+ mpImpl->maPropertyNotifier.registerProvider( ::svx::eShapePosition,
+ ::svx::PPropertyValueProvider( new ShapePositionProvider( *mpImpl ) ) );
+ mpImpl->maPropertyNotifier.registerProvider( ::svx::eShapeSize,
+ ::svx::PPropertyValueProvider( new ShapeSizeProvider( *mpImpl ) ) );
+
+ if ( mpObj.is() )
+ impl_initFromSdrObject();
+}
+
+//----------------------------------------------------------------------
+void SvxShape::impl_initFromSdrObject()
+{
+ DBG_TESTSOLARMUTEX();
+ OSL_PRECOND( mpObj.is(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" );
+ if ( !mpObj.is() )
+ return;
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ mpObj->setUnoShape( *this, SdrObject::GrantXShapeAccess() );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+
+ mpModel = mpObj->GetModel();
+
+ // #i40944#
+ // Do not simply return when no model but do the type corrections
+ // following below.
+ if(mpModel)
+ {
+ StartListening( *mpModel );
+ }
+
+ const sal_uInt32 nInventor = mpObj->GetObjInventor();
+
+ // is it one of ours (svx) ?
+ if( nInventor == SdrInventor || nInventor == E3dInventor || nInventor == FmFormInventor )
+ {
+ if(nInventor == FmFormInventor)
+ {
+ mpImpl->mnObjId = OBJ_UNO;
+ }
+ else
+ {
+ mpImpl->mnObjId = mpObj->GetObjIdentifier();
+ if( nInventor == E3dInventor )
+ mpImpl->mnObjId |= E3D_INVENTOR_FLAG;
+ }
+
+ switch(mpImpl->mnObjId)
+ {
+ case OBJ_CCUT: // Kreisabschnitt
+ case OBJ_CARC: // Kreisbogen
+ case OBJ_SECT: // Kreissektor
+ mpImpl->mnObjId = OBJ_CIRC;
+ break;
+
+ case E3D_SCENE_ID | E3D_INVENTOR_FLAG:
+ mpImpl->mnObjId = E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG;
+ break;
+ }
+ }
+}
+
+//----------------------------------------------------------------------
+void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
+{
+ DBG_TESTSOLARMUTEX();
+
+ OSL_PRECOND( pNewObj, "SvxShape::Create: invalid new object!" );
+ if ( !pNewObj )
+ return;
+
+ OSL_ENSURE( ( mpImpl->mpCreatedObj == NULL ) || ( mpImpl->mpCreatedObj == pNewObj ),
+ "SvxShape::Create: the same shape used for two different objects?! Strange ..." );
+
+ // --> CL, OD 2005-07-19 #i52126# - correct condition
+ if ( mpImpl->mpCreatedObj != pNewObj )
+ // <--
+ {
+ DBG_ASSERT( pNewObj->GetModel(), "no model for SdrObject?" );
+ // --> CL, OD 2005-07-19 #i52126#
+ mpImpl->mpCreatedObj = pNewObj;
+ // <--
+
+ if( mpObj.is() && mpObj->GetModel() )
+ {
+ EndListening( *mpObj->GetModel() );
+ }
+
+ mpObj.reset( pNewObj );
+
+ OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" );
+ // this was previously set in impl_initFromSdrObject, but I think it was superfluous
+ // (it definitely was in the other context where it was called, but I strongly suppose
+ // it was also superfluous when called from here)
+ impl_initFromSdrObject();
+
+ ObtainSettingsFromPropertySet( *mpPropSet );
+
+ // save user call
+ SdrObjUserCall* pUser = mpObj->GetUserCall();
+ mpObj->SetUserCall(NULL);
+
+ setPosition( maPosition );
+ setSize( maSize );
+
+ // restore user call after we set the initial size
+ mpObj->SetUserCall( pUser );
+
+ // if this shape was already named, use this name
+ if( maShapeName.getLength() )
+ {
+ mpObj->SetName( maShapeName );
+ maShapeName = OUString();
+ }
+ }
+}
+
+//----------------------------------------------------------------------
+
+void SvxShape::ChangeModel( SdrModel* pNewModel )
+{
+ DBG_TESTSOLARMUTEX();
+ if( mpObj.is() && mpObj->GetModel() )
+ {
+ if( mpObj->GetModel() != pNewModel )
+ {
+ EndListening( *mpObj->GetModel() );
+ }
+ }
+
+ // --> CL, OD 2005-07-19 #i52126# - always listen to new model
+ if( pNewModel )
+ {
+ StartListening( *pNewModel );
+ }
+ // <--
+
+ // HACK #i53696# ChangeModel should be virtual, but it isn't. can't change that for 2.0.1
+ SvxShapeText* pShapeText = dynamic_cast< SvxShapeText* >( this );
+ if( pShapeText )
+ {
+ SvxTextEditSource* pTextEditSource = dynamic_cast< SvxTextEditSource* >( pShapeText->GetEditSource() );
+ if( pTextEditSource )
+ pTextEditSource->ChangeModel( pNewModel );
+ }
+
+ mpModel = pNewModel;
+
+ if( mpImpl->mpMaster )
+ mpImpl->mpMaster->modelChanged( pNewModel );
+}
+
+//----------------------------------------------------------------------
+
+void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw()
+{
+ DBG_TESTSOLARMUTEX();
+ if(mpModel)
+ {
+ SfxMapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ rPoint.A() = MM_TO_TWIPS(rPoint.A());
+ rPoint.B() = MM_TO_TWIPS(rPoint.B());
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("AW: Missing unit translation to PoolMetric!");
+ }
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------
+// --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051
+void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw()
+{
+ DBG_TESTSOLARMUTEX();
+ if(mpModel)
+ {
+ SfxMapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ basegfx::B2DHomMatrix aTransform;
+ const double fMMToTWIPS(72.0 / 127.0);
+
+ aTransform.scale(fMMToTWIPS, fMMToTWIPS);
+ rPolyPolygon.transform(aTransform);
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("Missing unit translation to PoolMetric!");
+ }
+ }
+ }
+ }
+}
+// <--
+
+//----------------------------------------------------------------------
+void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw()
+{
+ DBG_TESTSOLARMUTEX();
+ SfxMapUnit eMapUnit = SFX_MAPUNIT_100TH_MM;
+ if(mpModel)
+ {
+ eMapUnit = mpModel->GetItemPool().GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ rPoint.A() = TWIPS_TO_MM(rPoint.A());
+ rPoint.B() = TWIPS_TO_MM(rPoint.B());
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("AW: Missing unit translation to 100th mm!");
+ }
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------
+// --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051
+void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) const throw()
+{
+ DBG_TESTSOLARMUTEX();
+ SfxMapUnit eMapUnit = SFX_MAPUNIT_100TH_MM;
+ if(mpModel)
+ {
+ eMapUnit = mpModel->GetItemPool().GetMetric(0);
+ if(eMapUnit != SFX_MAPUNIT_100TH_MM)
+ {
+ switch(eMapUnit)
+ {
+ case SFX_MAPUNIT_TWIP :
+ {
+ basegfx::B2DHomMatrix aTransform;
+ const double fTWIPSToMM(127.0 / 72.0);
+ aTransform.scale(fTWIPSToMM, fTWIPSToMM);
+ rPolyPolygon.transform(aTransform);
+ break;
+ }
+ default:
+ {
+ DBG_ERROR("Missing unit translation to 100th mm!");
+ }
+ }
+ }
+ }
+}
+// <--
+//----------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------
+void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet,
+ SfxItemSet& rSet, uno::Reference< beans::XPropertySet > xSet, const SfxItemPropertyMap* pMap )
+{
+ if(rPropSet.AreThereOwnUsrAnys())
+ {
+ const SfxItemPropertyMap* pSrc = rPropSet.getPropertyMap();
+ PropertyEntryVector_t aSrcPropVector = pSrc->getPropertyEntries();
+ PropertyEntryVector_t::const_iterator aSrcIt = aSrcPropVector.begin();
+ while(aSrcIt != aSrcPropVector.end())
+ {
+ if(aSrcIt->nWID)
+ {
+ uno::Any* pUsrAny = rPropSet.GetUsrAnyForID(aSrcIt->nWID);
+ if(pUsrAny)
+ {
+ // Aequivalenten Eintrag in pDst suchen
+ const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( aSrcIt->sName );
+ if(pEntry)
+ {
+ // entry found
+ if(pEntry->nWID >= OWN_ATTR_VALUE_START && pEntry->nWID <= OWN_ATTR_VALUE_END)
+ {
+ // Special ID im PropertySet, kann nur direkt am
+ // Objekt gesetzt werden+
+ xSet->setPropertyValue( aSrcIt->sName, *pUsrAny);
+ }
+ else
+ {
+ if(rSet.GetPool()->IsWhich(pEntry->nWID))
+ rSet.Put(rSet.GetPool()->GetDefaultItem(pEntry->nWID));
+ // setzen
+ SvxItemPropertySet_setPropertyValue(rPropSet, pEntry, *pUsrAny, rSet);
+ }
+ }
+ }
+ }
+
+ // next entry
+ ++aSrcIt;
+ }
+ const_cast< SvxItemPropertySet& >(rPropSet).ClearAllUsrAny();
+ }
+}
+
+
+void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet)
+{
+ DBG_TESTSOLARMUTEX();
+ if(mpObj.is() && rPropSet.AreThereOwnUsrAnys() && mpModel)
+ {
+ SfxItemSet aSet( mpModel->GetItemPool(), SDRATTR_START, SDRATTR_END, 0);
+ Reference< beans::XPropertySet > xShape( (OWeakObject*)this, UNO_QUERY );
+ SvxItemPropertySet_ObtainSettingsFromPropertySet(rPropSet, aSet, xShape, mpPropSet->getPropertyMap() );
+
+ mpObj->SetMergedItemSetAndBroadcast(aSet);
+
+ mpObj->ApplyNotPersistAttr( aSet );
+ }
+}
+
+//----------------------------------------------------------------------
+
+uno::Any SvxShape::GetBitmap( sal_Bool bMetaFile /* = sal_False */ ) const throw()
+{
+ DBG_TESTSOLARMUTEX();
+ uno::Any aAny;
+
+ if( !mpObj.is() || mpModel == NULL || !mpObj->IsInserted() || NULL == mpObj->GetPage() )
+ return aAny;
+
+ VirtualDevice aVDev;
+ aVDev.SetMapMode(MapMode(MAP_100TH_MM));
+
+ SdrModel* pModel = mpObj->GetModel();
+ SdrPage* pPage = mpObj->GetPage();
+
+ E3dView* pView = new E3dView( pModel, &aVDev );
+ pView->hideMarkHandles();
+ SdrPageView* pPageView = pView->ShowSdrPage(pPage);
+
+ SdrObject *pTempObj = mpObj.get();
+ pView->MarkObj(pTempObj,pPageView);
+
+ Rectangle aRect(pTempObj->GetCurrentBoundRect());
+ aRect.Justify();
+ Size aSize(aRect.GetSize());
+
+ GDIMetaFile aMtf( pView->GetAllMarkedMetaFile() );
+ if( bMetaFile )
+ {
+ SvMemoryStream aDestStrm( 65535, 65535 );
+ ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False );
+ const uno::Sequence<sal_Int8> aSeq(
+ static_cast< const sal_Int8* >(aDestStrm.GetData()),
+ aDestStrm.GetEndOfData());
+ aAny.setValue( &aSeq, ::getCppuType((const uno::Sequence< sal_Int8 >*)0) );
+ }
+ else
+ {
+ Graphic aGraph(aMtf);
+ aGraph.SetPrefSize(aSize);
+ aGraph.SetPrefMapMode(MAP_100TH_MM);
+
+ Reference< awt::XBitmap > xBmp( aGraph.GetXGraphic(), UNO_QUERY );
+ aAny <<= xBmp;
+ }
+
+ pView->UnmarkAll();
+ delete pView;
+
+ return aAny;
+}
+
+//----------------------------------------------------------------------
+
+uno::Sequence< uno::Type > SAL_CALL SvxShape::getTypes()
+ throw (uno::RuntimeException)
+{
+ if( mpImpl->mpMaster )
+ {
+ return mpImpl->mpMaster->getTypes();
+ }
+ else
+ {
+ return _getTypes();
+ }
+}
+
+//----------------------------------------------------------------------
+
+uno::Sequence< uno::Type > SAL_CALL SvxShape::_getTypes()
+ throw(uno::RuntimeException)
+{
+ switch( mpImpl->mnObjId )
+ {
+ // shapes without text
+ case OBJ_OLE2:
+ case OBJ_PAGE:
+ case OBJ_FRAME:
+ case OBJ_OLE2_PLUGIN:
+ case OBJ_OLE2_APPLET:
+ case E3D_CUBEOBJ_ID|E3D_INVENTOR_FLAG:
+ case E3D_SPHEREOBJ_ID|E3D_INVENTOR_FLAG:
+ case E3D_LATHEOBJ_ID|E3D_INVENTOR_FLAG:
+ case E3D_EXTRUDEOBJ_ID|E3D_INVENTOR_FLAG:
+ case E3D_POLYGONOBJ_ID|E3D_INVENTOR_FLAG:
+ case OBJ_MEDIA:
+ {
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
+
+ if( aTypeSequence.getLength() == 0 )
+ {
+ // Ready for multithreading; get global mutex for first call of this method only! see before
+ MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
+
+ // Control these pointer again ... it can be, that another instance will be faster then these!
+ if( aTypeSequence.getLength() == 0 )
+ {
+ aTypeSequence.realloc( 12 );
+ uno::Type* pTypes = aTypeSequence.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
+// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
+ *pTypes++ = beans::XMultiPropertyStates::static_type();
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
+ }
+ }
+ return aTypeSequence;
+ }
+ // group shape
+ case OBJ_GRUP:
+ {
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
+
+ if( aTypeSequence.getLength() == 0 )
+ {
+ // Ready for multithreading; get global mutex for first call of this method only! see before
+ MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
+
+ // Control these pointer again ... it can be, that another instance will be faster then these!
+ if( aTypeSequence.getLength() == 0 )
+ {
+ aTypeSequence.realloc( 14 );
+ uno::Type* pTypes = aTypeSequence.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
+// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
+ *pTypes++ = beans::XMultiPropertyStates::static_type();
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapes>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapeGroup>*)0);
+ }
+ }
+ return aTypeSequence;
+ }
+ // connector shape
+ case OBJ_EDGE:
+ {
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
+
+ if( aTypeSequence.getLength() == 0 )
+ {
+ // Ready for multithreading; get global mutex for first call of this method only! see before
+ MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
+
+ // Control these pointer again ... it can be, that another instance will be faster then these!
+ if( aTypeSequence.getLength() == 0 )
+ {
+ aTypeSequence.realloc( 17 );
+ uno::Type* pTypes = aTypeSequence.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
+// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
+ *pTypes++ = beans::XMultiPropertyStates::static_type();
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XConnectorShape>*)0);
+ // from SvxUnoTextBase::getTypes()
+ *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0);
+ *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0);
+ *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
+ *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0);
+ }
+ }
+ return aTypeSequence;
+ }
+ // control shape
+ case OBJ_UNO:
+ {
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
+
+ if( aTypeSequence.getLength() == 0 )
+ {
+ // Ready for multithreading; get global mutex for first call of this method only! see before
+ MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
+
+ // Control these pointer again ... it can be, that another instance will be faster then these!
+ if( aTypeSequence.getLength() == 0 )
+ {
+ aTypeSequence.realloc( 13 );
+ uno::Type* pTypes = aTypeSequence.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
+// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
+ *pTypes++ = beans::XMultiPropertyStates::static_type();
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XControlShape>*)0);
+ }
+ }
+ return aTypeSequence;
+ }
+ // 3d scene shape
+ case E3D_POLYSCENE_ID|E3D_INVENTOR_FLAG:
+ {
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
+
+ if( aTypeSequence.getLength() == 0 )
+ {
+ // Ready for multithreading; get global mutex for first call of this method only! see before
+ MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
+
+ // Control these pointer again ... it can be, that another instance will be faster then these!
+ if( aTypeSequence.getLength() == 0 )
+ {
+ aTypeSequence.realloc( 13 );
+ uno::Type* pTypes = aTypeSequence.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
+// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
+ *pTypes++ = beans::XMultiPropertyStates::static_type();
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShapes>*)0);
+ }
+ }
+ return aTypeSequence;
+ }
+ case OBJ_CUSTOMSHAPE:
+ {
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
+
+ if( aTypeSequence.getLength() == 0 )
+ {
+ // Ready for multithreading; get global mutex for first call of this method only! see before
+ MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
+
+ // Control these pointer again ... it can be, that another instance will be faster then these!
+ if( aTypeSequence.getLength() == 0 )
+ {
+ aTypeSequence.realloc( 16 );
+ uno::Type* pTypes = aTypeSequence.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
+// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
+ *pTypes++ = beans::XMultiPropertyStates::static_type();
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
+ // from SvxUnoTextBase::getTypes()
+ *pTypes++ = ::getCppuType(( const uno::Reference< text::XText >*)0);
+ *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
+ *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0);
+ *pTypes++ = ::getCppuType(( const uno::Reference< drawing::XEnhancedCustomShapeDefaulter >*)0);
+ }
+ }
+ return aTypeSequence;
+ }
+ // shapes with text
+ case OBJ_RECT:
+ case OBJ_CIRC:
+ case OBJ_MEASURE:
+ case OBJ_LINE:
+ case OBJ_POLY:
+ case OBJ_PLIN:
+ case OBJ_PATHLINE:
+ case OBJ_PATHFILL:
+ case OBJ_FREELINE:
+ case OBJ_FREEFILL:
+ case OBJ_PATHPOLY:
+ case OBJ_PATHPLIN:
+ case OBJ_GRAF:
+ case OBJ_TEXT:
+ case OBJ_CAPTION:
+ case OBJ_TABLE:
+ default:
+ {
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > aTypeSequence;
+
+ if( aTypeSequence.getLength() == 0 )
+ {
+ // Ready for multithreading; get global mutex for first call of this method only! see before
+ MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
+
+ // Control these pointer again ... it can be, that another instance will be faster then these!
+ if( aTypeSequence.getLength() == 0 )
+ {
+ aTypeSequence.realloc( 16 );
+ uno::Type* pTypes = aTypeSequence.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XShape >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XComponent >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0);
+// *pTypes++ = ::getCppuType((const uno::Reference< beans::XTolerantMultiPropertySet >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState >*)0);
+ *pTypes++ = beans::XMultiPropertyStates::static_type();
+ *pTypes++ = ::getCppuType((const uno::Reference< drawing::XGluePointsSupplier >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XChild >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XUnoTunnel >*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XNamed >*)0);
+ // from SvxUnoTextBase::getTypes()
+ *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0);
+ *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0);
+ *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
+ *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0);
+ }
+ }
+ return aTypeSequence;
+ }
+ }
+}
+
+//----------------------------------------------------------------------
+
+uno::Sequence< sal_Int8 > SAL_CALL SvxShape::getImplementationId()
+ throw (uno::RuntimeException)
+{
+ static ::cppu::OImplementationId* pID = NULL ;
+
+ if ( pID == NULL )
+ {
+ // Ready for multithreading; get global mutex for first call of this method only! see before
+ MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
+
+ // Control these pointer again ... it can be, that another instance will be faster then these!
+ if ( pID == NULL )
+ {
+ // Create a new static ID ...
+ static ::cppu::OImplementationId aID( sal_False ) ;
+ // ... and set his address to static pointer!
+ pID = &aID ;
+ }
+ }
+
+ return pID->getImplementationId() ;
+}
+
+//----------------------------------------------------------------------
+
+Reference< uno::XInterface > SvxShape_NewInstance()
+{
+ return uno::Reference< uno::XInterface >(static_cast< OWeakObject* >( new SvxShape() ) );
+}
+
+//----------------------------------------------------------------------
+
+void SvxShape::onUserCall(SdrUserCallType /*_eUserCall*/, const Rectangle& /*_rNewBoundRect*/ )
+{
+ // obsolete, not called anymore
+}
+
+//----------------------------------------------------------------------
+// SfxListener
+//----------------------------------------------------------------------
+
+void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
+{
+ DBG_TESTSOLARMUTEX();
+ if( !mpObj.is() )
+ return;
+
+ // #i55919# HINT_OBJCHG is only interesting if it's for this object
+
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+ if (!pSdrHint || ( /* (pSdrHint->GetKind() != HINT_OBJREMOVED) && */
+ (pSdrHint->GetKind() != HINT_MODELCLEARED) &&
+ // #110094#-9 (pSdrHint->GetKind() != HINT_OBJLISTCLEAR) &&
+ ((pSdrHint->GetKind() != HINT_OBJCHG || pSdrHint->GetObject() != mpObj.get() ))))
+ return;
+
+ uno::Reference< uno::XInterface > xSelf( mpObj->getWeakUnoShape() );
+ if( !xSelf.is() )
+ {
+ mpObj.reset( NULL );
+ return;
+ }
+
+ sal_Bool bClearMe = sal_False;
+
+ switch( pSdrHint->GetKind() )
+ {
+ case HINT_OBJCHG:
+ {
+ updateShapeKind();
+ break;
+ }
+ case HINT_MODELCLEARED:
+ {
+ bClearMe = sal_True;
+ mpModel = NULL;
+ break;
+ }
+ default:
+ break;
+ };
+
+ if( bClearMe )
+ {
+ if( !HasSdrObjectOwnership() )
+ mpObj.reset( NULL );
+ if ( !mpImpl->mbDisposing )
+ dispose();
+ }
+}
+
+// XShape
+
+//----------------------------------------------------------------------
+// The "*LogicRectHack" functions also existed in sch, and those
+// duplicate symbols cause Bad Things To Happen (TM) #i9462#.
+// Prefixing with 'svx' and marking static to make sure name collisions
+// do not occur.
+
+static sal_Bool svx_needLogicRectHack( SdrObject* pObj )
+{
+ if( pObj->GetObjInventor() == SdrInventor)
+ {
+ switch(pObj->GetObjIdentifier())
+ {
+ case OBJ_GRUP:
+ case OBJ_LINE:
+ case OBJ_POLY:
+ case OBJ_PLIN:
+ case OBJ_PATHLINE:
+ case OBJ_PATHFILL:
+ case OBJ_FREELINE:
+ case OBJ_FREEFILL:
+ case OBJ_SPLNLINE:
+ case OBJ_SPLNFILL:
+ case OBJ_EDGE:
+ case OBJ_PATHPOLY:
+ case OBJ_PATHPLIN:
+ case OBJ_MEASURE:
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+//----------------------------------------------------------------------
+
+static Rectangle svx_getLogicRectHack( SdrObject* pObj )
+{
+ if(svx_needLogicRectHack(pObj))
+ {
+ return pObj->GetSnapRect();
+ }
+ else
+ {
+ return pObj->GetLogicRect();
+ }
+}
+
+//----------------------------------------------------------------------
+
+static void svx_setLogicRectHack( SdrObject* pObj, const Rectangle& rRect )
+{
+ if(svx_needLogicRectHack(pObj))
+ {
+ pObj->SetSnapRect( rRect );
+ }
+ else
+ {
+ pObj->SetLogicRect( rRect );
+ }
+}
+
+//----------------------------------------------------------------------
+
+awt::Point SAL_CALL SvxShape::getPosition() throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( mpObj.is() && mpModel)
+ {
+ Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
+ Point aPt( aRect.Left(), aRect.Top() );
+
+ // Position is relativ to anchor, so recalc to absolut position
+ if( mpModel->IsWriter() )
+ aPt -= mpObj->GetAnchorPos();
+
+ ForceMetricTo100th_mm(aPt);
+ return ::com::sun::star::awt::Point( aPt.X(), aPt.Y() );
+ }
+ else
+ {
+ return maPosition;
+ }
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShape::setPosition( const awt::Point& Position ) throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( mpObj.is() && mpModel )
+ {
+ // do NOT move 3D objects, this would change the homogen
+ // transformation matrix
+ if(!mpObj->ISA(E3dCompoundObject))
+ {
+ Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
+ Point aLocalPos( Position.X, Position.Y );
+ ForceMetricToItemPoolMetric(aLocalPos);
+
+ // Position ist absolut, relativ zum Anker stellen
+ if( mpModel->IsWriter() )
+ aLocalPos += mpObj->GetAnchorPos();
+
+ long nDX = aLocalPos.X() - aRect.Left();
+ long nDY = aLocalPos.Y() - aRect.Top();
+
+ mpObj->Move( Size( nDX, nDY ) );
+ mpModel->SetChanged();
+ }
+ }
+
+ maPosition = Position;
+}
+
+//----------------------------------------------------------------------
+awt::Size SAL_CALL SvxShape::getSize() throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( mpObj.is() && mpModel)
+ {
+ Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
+ Size aObjSize( aRect.getWidth(), aRect.getHeight() );
+ ForceMetricTo100th_mm(aObjSize);
+ return ::com::sun::star::awt::Size( aObjSize.getWidth(), aObjSize.getHeight() );
+ }
+ else
+ return maSize;
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShape::setSize( const awt::Size& rSize )
+ throw(beans::PropertyVetoException, uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( mpObj.is() && mpModel)
+ {
+ Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
+ Size aLocalSize( rSize.Width, rSize.Height );
+ ForceMetricToItemPoolMetric(aLocalSize);
+
+ if(mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_MEASURE )
+ {
+ Fraction aWdt(aLocalSize.Width(),aRect.Right()-aRect.Left());
+ Fraction aHgt(aLocalSize.Height(),aRect.Bottom()-aRect.Top());
+ Point aPt = mpObj->GetSnapRect().TopLeft();
+ mpObj->Resize(aPt,aWdt,aHgt);
+ }
+ else
+ {
+ //aRect.SetSize(aLocalSize); // this call substract 1 // http://www.openoffice.org/issues/show_bug.cgi?id=83193
+ if ( !aLocalSize.Width() )
+ {
+ aRect.Right() = RECT_EMPTY;
+ }
+ else
+ aRect.setWidth(aLocalSize.Width());
+ if ( !aLocalSize.Height() )
+ {
+ aRect.Bottom() = RECT_EMPTY;
+ }
+ else
+ aRect.setHeight(aLocalSize.Height());
+
+ svx_setLogicRectHack( mpObj.get(), aRect );
+ }
+
+ mpModel->SetChanged();
+ }
+ maSize = rSize;
+}
+
+//----------------------------------------------------------------------
+
+// XNamed
+OUString SAL_CALL SvxShape::getName( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ if( mpObj.is() )
+ {
+ return mpObj->GetName();
+ }
+ else
+ {
+ return maShapeName;
+ }
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::setName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ if( mpObj.is() )
+ {
+ mpObj->SetName( aName );
+ }
+ else
+ {
+ maShapeName = aName;
+ }
+}
+
+// XShapeDescriptor
+
+//----------------------------------------------------------------------
+OUString SAL_CALL SvxShape::getShapeType() throw(uno::RuntimeException)
+{
+ if( !maShapeType.getLength() )
+ return UHashMap::getNameFromId( mpImpl->mnObjId );
+ else
+ return maShapeType;
+}
+
+// XComponent
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShape::dispose() throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( mpImpl->mbDisposing )
+ return; // caught a recursion
+
+ mpImpl->mbDisposing = true;
+
+ lang::EventObject aEvt;
+ aEvt.Source = *(OWeakAggObject*) this;
+ mpImpl->maDisposeListeners.disposeAndClear(aEvt);
+ mpImpl->maPropertyNotifier.disposing();
+
+ if ( mpObj.is() )
+ {
+ bool bFreeSdrObject = false;
+
+ if ( mpObj->IsInserted() && mpObj->GetPage() )
+ {
+ OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" );
+ // normally, we are allowed to free the SdrObject only if we have its ownership.
+ // Why isn't this checked here?
+
+ SdrPage* pPage = mpObj->GetPage();
+ // SdrObject aus der Page loeschen
+ sal_uInt32 nCount = pPage->GetObjCount();
+ for ( sal_uInt32 nNum = 0; nNum < nCount; ++nNum )
+ {
+ if ( pPage->GetObj( nNum ) == mpObj.get() )
+ {
+ OSL_VERIFY( pPage->RemoveObject( nNum ) == mpObj.get() );
+ bFreeSdrObject = true;
+ break;
+ }
+ }
+ }
+
+ mpObj->setUnoShape( NULL, SdrObject::GrantXShapeAccess() );
+
+ if ( bFreeSdrObject )
+ {
+ // in case we have the ownership of the SdrObject, a Free
+ // would do nothing. So ensure the ownership is reset.
+ mpImpl->mbHasSdrObjectOwnership = false;
+ SdrObject* pObject = mpObj.get();
+ SdrObject::Free( pObject );
+ }
+ }
+
+ if( mpModel )
+ {
+ EndListening( *mpModel );
+ mpModel = NULL;
+ }
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::addEventListener( const Reference< lang::XEventListener >& xListener )
+ throw(uno::RuntimeException)
+{
+ mpImpl->maDisposeListeners.addInterface(xListener);
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::removeEventListener( const Reference< lang::XEventListener >& aListener ) throw(uno::RuntimeException)
+{
+ mpImpl->maDisposeListeners.removeInterface(aListener);
+}
+
+// XPropertySet
+
+//----------------------------------------------------------------------
+
+Reference< beans::XPropertySetInfo > SAL_CALL
+ SvxShape::getPropertySetInfo() throw(uno::RuntimeException)
+{
+ if( mpImpl->mpMaster )
+ {
+ return mpImpl->mpMaster->getPropertySetInfo();
+ }
+ else
+ {
+ return _getPropertySetInfo();
+ }
+}
+
+Reference< beans::XPropertySetInfo > SAL_CALL
+ SvxShape::_getPropertySetInfo() throw(uno::RuntimeException)
+{
+ return mpPropSet->getPropertySetInfo();
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::addPropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ mpImpl->maPropertyNotifier.addPropertyChangeListener( _propertyName, _listener );
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::removePropertyChangeListener( const OUString& _propertyName, const Reference< beans::XPropertyChangeListener >& _listener ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ mpImpl->maPropertyNotifier.removePropertyChangeListener( _propertyName, _listener );
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( false, "SvxShape::addVetoableChangeListener: don't have any vetoable properties, so why ...?" );
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( false, "SvxShape::removeVetoableChangeListener: don't have any vetoable properties, so why ...?" );
+}
+
+//----------------------------------------------------------------------
+
+sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName )
+{
+ SfxItemSet aSet( mpModel->GetItemPool(), (USHORT)nWID, (USHORT)nWID );
+
+ if( SetFillAttribute( nWID, rName, aSet, mpModel ) )
+ {
+ //mpObj->SetItemSetAndBroadcast(aSet);
+ mpObj->SetMergedItemSetAndBroadcast(aSet);
+
+ return sal_True;
+ }
+ else
+ {
+ return sal_False;
+ }
+}
+
+//----------------------------------------------------------------------
+
+sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const ::rtl::OUString& rName, SfxItemSet& rSet, SdrModel* pModel )
+{
+ // check if an item with the given name and which id is inside the models
+ // pool or the stylesheet pool, if found its puttet in the itemse
+ if( !SetFillAttribute( nWID, rName, rSet ) )
+ {
+ // we did not find such item in one of the pools, so we check
+ // the property lists that are loaded for the model for items
+ // that support such.
+ String aStrName;
+ SvxUnogetInternalNameForItem( (sal_Int16)nWID, rName, aStrName );
+
+ switch( nWID )
+ {
+ case XATTR_FILLBITMAP:
+ {
+ XBitmapList* pBitmapList = pModel->GetBitmapList();
+
+ if( !pBitmapList )
+ return sal_False;
+
+ long nPos = ((XPropertyList*)pBitmapList)->Get(aStrName);
+ if( nPos == -1 )
+ return sal_False;
+
+ XBitmapEntry* pEntry = pBitmapList->GetBitmap( nPos );
+ XFillBitmapItem aBmpItem;
+ aBmpItem.SetWhich( XATTR_FILLBITMAP );
+ aBmpItem.SetName( rName );
+ aBmpItem.SetBitmapValue( pEntry->GetXBitmap() );
+ rSet.Put( aBmpItem );
+ break;
+ }
+ case XATTR_FILLGRADIENT:
+ {
+ XGradientList* pGradientList = pModel->GetGradientList();
+
+ if( !pGradientList )
+ return sal_False;
+
+ long nPos = ((XPropertyList*)pGradientList)->Get(aStrName);
+ if( nPos == -1 )
+ return sal_False;
+
+ XGradientEntry* pEntry = pGradientList->GetGradient( nPos );
+ XFillGradientItem aGrdItem;
+ aGrdItem.SetWhich( XATTR_FILLGRADIENT );
+ aGrdItem.SetName( rName );
+ aGrdItem.SetGradientValue( pEntry->GetGradient() );
+ rSet.Put( aGrdItem );
+ break;
+ }
+ case XATTR_FILLHATCH:
+ {
+ XHatchList* pHatchList = pModel->GetHatchList();
+
+ if( !pHatchList )
+ return sal_False;
+
+ long nPos = ((XPropertyList*)pHatchList)->Get(aStrName);
+ if( nPos == -1 )
+ return sal_False;
+
+ XHatchEntry* pEntry = pHatchList->GetHatch( nPos );
+ XFillHatchItem aHatchItem;
+ aHatchItem.SetWhich( XATTR_FILLHATCH );
+ aHatchItem.SetName( rName );
+ aHatchItem.SetHatchValue( pEntry->GetHatch() );
+ rSet.Put( aHatchItem );
+ break;
+ }
+ case XATTR_LINEEND:
+ case XATTR_LINESTART:
+ {
+ XLineEndList* pLineEndList = pModel->GetLineEndList();
+
+ if( !pLineEndList )
+ return sal_False;
+
+ long nPos = ((XPropertyList*)pLineEndList)->Get(aStrName);
+ if( nPos == -1 )
+ return sal_False;
+
+ XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
+ if( XATTR_LINEEND == nWID )
+ {
+ XLineEndItem aLEItem;
+ aLEItem.SetWhich( XATTR_LINEEND );
+ aLEItem.SetName( rName );
+ aLEItem.SetLineEndValue( pEntry->GetLineEnd() );
+ rSet.Put( aLEItem );
+ }
+ else
+ {
+ XLineStartItem aLSItem;
+ aLSItem.SetWhich( XATTR_LINESTART );
+ aLSItem.SetName( rName );
+ aLSItem.SetLineStartValue( pEntry->GetLineEnd() );
+ rSet.Put( aLSItem );
+ }
+
+ break;
+ }
+ case XATTR_LINEDASH:
+ {
+ XDashList* pDashList = pModel->GetDashList();
+
+ if( !pDashList )
+ return sal_False;
+
+ long nPos = ((XPropertyList*)pDashList)->Get(aStrName);
+ if( nPos == -1 )
+ return sal_False;
+
+ XDashEntry* pEntry = pDashList->GetDash( nPos );
+ XLineDashItem aDashItem;
+ aDashItem.SetWhich( XATTR_LINEDASH );
+ aDashItem.SetName( rName );
+ aDashItem.SetDashValue( pEntry->GetDash() );
+ rSet.Put( aDashItem );
+ break;
+ }
+ default:
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+}
+
+//----------------------------------------------------------------------
+
+sal_Bool SAL_CALL SvxShape::SetFillAttribute( sal_Int32 nWID, const OUString& rName, SfxItemSet& rSet )
+{
+ String aName;
+ SvxUnogetInternalNameForItem( (sal_Int16)nWID, rName, aName );
+
+ if( aName.Len() == 0 )
+ {
+ switch( nWID )
+ {
+ case XATTR_LINEEND:
+ case XATTR_LINESTART:
+ {
+ const String aEmpty;
+ const basegfx::B2DPolyPolygon aEmptyPoly;
+ if( nWID == XATTR_LINEEND )
+ rSet.Put( XLineEndItem( aEmpty, aEmptyPoly ) );
+ else
+ rSet.Put( XLineStartItem( aEmpty, aEmptyPoly ) );
+
+ return sal_True;
+ }
+ case XATTR_FILLFLOATTRANSPARENCE:
+ {
+ // #85953# Set a disabled XFillFloatTransparenceItem
+ rSet.Put(XFillFloatTransparenceItem());
+
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+ }
+
+ const SfxItemPool* pPool = rSet.GetPool();
+
+ const String aSearchName( aName );
+ const USHORT nCount = pPool->GetItemCount((USHORT)nWID);
+ const NameOrIndex *pItem;
+
+ for( USHORT nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)pPool->GetItem((USHORT)nWID, nSurrogate);
+ if( pItem && ( pItem->GetName() == aSearchName ) )
+ {
+ rSet.Put( *pItem );
+ return sal_True;
+ }
+ }
+
+ return sal_False;
+}
+
+//----------------------------------------------------------------------
+
+// static
+/* os: unused function
+ uno::Any SAL_CALL SvxShape::GetFillAttributeByName(
+ const ::rtl::OUString& rPropertyName, const ::rtl::OUString& rName, SdrModel* pModel )
+{
+ uno::Any aResult;
+ DBG_ASSERT( pModel, "Invalid Model in GetFillAttributeByName()" );
+ if( ! pModel )
+ return aResult;
+
+ sal_Int16 nWhich = SvxUnoGetWhichIdForNamedProperty( rPropertyName );
+
+ // search pool for item
+ const SfxItemPool& rPool = pModel->GetItemPool();
+
+ const String aSearchName( rName );
+ const USHORT nCount = rPool.GetItemCount((USHORT)nWhich);
+ const NameOrIndex *pItem = 0;
+ bool bFound = false;
+
+ for( USHORT nSurrogate = 0; ! bFound && nSurrogate < nCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)rPool.GetItem((USHORT)nWhich, nSurrogate);
+ if( pItem && ( pItem->GetName() == aSearchName ) )
+ {
+ bFound = true;
+ }
+ }
+
+ // check the property lists that are loaded for the model for items that
+ // support such.
+ String aStrName;
+ SvxUnogetInternalNameForItem( nWhich, rName, aStrName );
+
+ switch( nWhich )
+ {
+ case XATTR_FILLBITMAP:
+ {
+ XFillBitmapItem aBmpItem;
+ if( ! bFound )
+ {
+ XBitmapList* pBitmapList = pModel->GetBitmapList();
+
+ if( !pBitmapList )
+ break;
+
+ long nPos = ((XPropertyList*)pBitmapList)->Get(aStrName);
+ if( nPos == -1 )
+ break;
+
+ XBitmapEntry* pEntry = pBitmapList->GetBitmap( nPos );
+ aBmpItem.SetWhich( XATTR_FILLBITMAP );
+ aBmpItem.SetName( rName );
+ aBmpItem.SetBitmapValue( pEntry->GetXBitmap() );
+ pItem = & aBmpItem;
+ }
+ DBG_ASSERT( pItem, "Invalid Item" );
+ if( pItem )
+ pItem->QueryValue( aResult ); // default: XBitmap. MID_GRAFURL instead?
+ }
+ break;
+
+ case XATTR_FILLGRADIENT:
+ {
+ XFillGradientItem aGrdItem;
+ if( ! bFound )
+ {
+ XGradientList* pGradientList = pModel->GetGradientList();
+
+ if( !pGradientList )
+ break;
+
+ long nPos = ((XPropertyList*)pGradientList)->Get(aStrName);
+ if( nPos == -1 )
+ break;
+
+ XGradientEntry* pEntry = pGradientList->GetGradient( nPos );
+ aGrdItem.SetWhich( XATTR_FILLGRADIENT );
+ aGrdItem.SetName( rName );
+ aGrdItem.SetGradientValue( pEntry->GetGradient() );
+ pItem = & aGrdItem;
+ }
+ DBG_ASSERT( pItem, "Invalid Item" );
+ if( pItem )
+ pItem->QueryValue( aResult, MID_FILLGRADIENT );
+ }
+ break;
+
+ case XATTR_FILLHATCH:
+ {
+ XFillHatchItem aHatchItem;
+ if( ! bFound )
+ {
+ XHatchList* pHatchList = pModel->GetHatchList();
+
+ if( !pHatchList )
+ break;
+
+ long nPos = ((XPropertyList*)pHatchList)->Get(aStrName);
+ if( nPos == -1 )
+ break;
+
+ XHatchEntry* pEntry = pHatchList->GetHatch( nPos );
+ aHatchItem.SetWhich( XATTR_FILLHATCH );
+ aHatchItem.SetName( rName );
+ aHatchItem.SetHatchValue( pEntry->GetHatch() );
+ pItem = & aHatchItem;
+ }
+ DBG_ASSERT( pItem, "Invalid Item" );
+ if( pItem )
+ pItem->QueryValue( aResult, MID_FILLHATCH );
+ }
+ break;
+
+ case XATTR_LINEEND:
+ case XATTR_LINESTART:
+ {
+ if( ! bFound )
+ {
+ XLineEndList* pLineEndList = pModel->GetLineEndList();
+
+ if( !pLineEndList )
+ break;
+
+ long nPos = ((XPropertyList*)pLineEndList)->Get(aStrName);
+ if( nPos == -1 )
+ break;
+
+ XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nPos );
+ if( nWhich == XATTR_LINEEND )
+ {
+ XLineEndItem aLEItem;
+ aLEItem.SetWhich( XATTR_LINEEND );
+ aLEItem.SetName( rName );
+ aLEItem.SetLineEndValue( pEntry->GetLineEnd() );
+ aLEItem.QueryValue( aResult );
+ }
+ else
+ {
+ XLineStartItem aLSItem;
+ aLSItem.SetWhich( XATTR_LINESTART );
+ aLSItem.SetName( rName );
+ aLSItem.SetLineStartValue( pEntry->GetLineEnd() );
+ aLSItem.QueryValue( aResult );
+ }
+ }
+ else
+ {
+ DBG_ASSERT( pItem, "Invalid Item" );
+ if( pItem )
+ pItem->QueryValue( aResult );
+ }
+ }
+ break;
+
+ case XATTR_LINEDASH:
+ {
+ XLineDashItem aDashItem;
+ if( ! bFound )
+ {
+ XDashList* pDashList = pModel->GetDashList();
+
+ if( !pDashList )
+ break;
+
+ long nPos = ((XPropertyList*)pDashList)->Get(aStrName);
+ if( nPos == -1 )
+ break;
+
+ XDashEntry* pEntry = pDashList->GetDash( nPos );
+ aDashItem.SetWhich( XATTR_LINEDASH );
+ aDashItem.SetName( rName );
+ aDashItem.SetDashValue( pEntry->GetDash() );
+ pItem = & aDashItem;
+ }
+ DBG_ASSERT( pItem, "Invalid Item" );
+ if( pItem )
+ pItem->QueryValue( aResult, MID_LINEDASH );
+ }
+ break;
+ }
+
+ return aResult;
+} */
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( mpImpl->mpMaster )
+ {
+ mpImpl->mpMaster->setPropertyValue( rPropertyName, rVal );
+ }
+ else
+ {
+ _setPropertyValue( rPropertyName, rVal );
+ }
+}
+
+void SAL_CALL SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any& rVal )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
+
+ if( mpObj.is() && mpModel )
+ {
+ if( pMap == NULL )
+ throw beans::UnknownPropertyException();
+
+ if( (pMap->nFlags & beans::PropertyAttribute::READONLY ) != 0 )
+ throw beans::PropertyVetoException();
+
+ mpModel->SetChanged();
+
+ if(!setPropertyValueImpl( rPropertyName, pMap, rVal ) )
+ {
+ DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST, "Not persist item not handled!" );
+ DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" );
+
+ sal_Bool bIsNotPersist = pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST && pMap->nWID != SDRATTR_TEXTDIRECTION;
+
+ if( pMap->nWID == SDRATTR_ECKENRADIUS )
+ {
+ sal_Int32 nCornerRadius = 0;
+ if( !(rVal >>= nCornerRadius) || (nCornerRadius < 0) || (nCornerRadius > 5000000))
+ throw IllegalArgumentException();
+ }
+
+ SfxItemSet* pSet;
+ if( mbIsMultiPropertyCall && !bIsNotPersist )
+ {
+ if( mpImpl->mpItemSet == NULL )
+ {
+ pSet = mpImpl->mpItemSet = mpObj->GetMergedItemSet().Clone();
+ }
+ else
+ {
+ pSet = mpImpl->mpItemSet;
+ }
+ }
+ else
+ {
+ pSet = new SfxItemSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID);
+ }
+
+ if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET )
+ pSet->Put(mpObj->GetMergedItem(pMap->nWID));
+
+ if( !SvxUnoTextRangeBase::SetPropertyValueHelper( *pSet, pMap, rVal, *pSet ))
+ {
+ if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET )
+ {
+ if(bIsNotPersist)
+ {
+ // Not-Persistant Attribute, hole diese extra
+ mpObj->TakeNotPersistAttr(*pSet, sal_False);
+ }
+ }
+
+ if( pSet->GetItemState( pMap->nWID ) != SFX_ITEM_SET )
+ {
+ // Default aus ItemPool holen
+ if(mpModel->GetItemPool().IsWhich(pMap->nWID))
+ pSet->Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
+ }
+
+ if( pSet->GetItemState( pMap->nWID ) == SFX_ITEM_SET )
+ {
+ SvxItemPropertySet_setPropertyValue( *mpPropSet, pMap, rVal, *pSet );
+ }
+ }
+
+ if(bIsNotPersist)
+ {
+ // Not-Persist Attribute extra setzen
+ mpObj->ApplyNotPersistAttr( *pSet );
+ delete pSet;
+ }
+ else
+ {
+ // if we have a XMultiProperty call then the item set
+ // will be set in setPropertyValues later
+ if( !mbIsMultiPropertyCall )
+ {
+ mpObj->SetMergedItemSetAndBroadcast( *pSet );
+
+ delete pSet;
+ }
+ }
+ return;
+ }
+ }
+ else
+ {
+ // since we have no actual sdr object right now
+ // remember all properties in a list. These
+ // properties will be set when the sdr object is
+ // created
+
+ if(pMap && pMap->nWID)
+// Fixme: We should throw a UnknownPropertyException here.
+// But since this class is aggregated from classes
+// that support additional properties that we don't
+// know here we silently store *all* properties, even
+// if they may be not supported after creation
+ mpPropSet->setPropertyValue( pMap, rVal );
+ }
+}
+
+//----------------------------------------------------------------------
+
+uno::Any SAL_CALL SvxShape::getPropertyValue( const OUString& PropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if ( mpImpl->mpMaster )
+ return mpImpl->mpMaster->getPropertyValue( PropertyName );
+ else
+ return _getPropertyValue( PropertyName );
+}
+
+//----------------------------------------------------------------------
+
+uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
+
+ uno::Any aAny;
+ if( mpObj.is() && mpModel )
+ {
+ if(pMap == NULL )
+ throw beans::UnknownPropertyException();
+
+ if( !getPropertyValueImpl( PropertyName, pMap, aAny ) )
+ {
+ DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || (pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST), "Not persist item not handled!" );
+ DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" );
+
+ SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID);
+ aSet.Put(mpObj->GetMergedItem(pMap->nWID));
+
+ if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pMap, aAny ))
+ return aAny;
+
+ if(!aSet.Count())
+ {
+ if(pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST)
+ {
+ // Not-Persistant Attribute, hole diese extra
+ mpObj->TakeNotPersistAttr(aSet, sal_False);
+ }
+ }
+
+ if(!aSet.Count())
+ {
+ // Default aus ItemPool holen
+ if(mpModel->GetItemPool().IsWhich(pMap->nWID))
+ aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
+ }
+
+ if(aSet.Count())
+ aAny = GetAnyForItem( aSet, pMap );
+ }
+ }
+ else
+ {
+
+// Fixme: we should return default values for OWN_ATTR !
+
+ if(pMap && pMap->nWID)
+// FixMe: see setPropertyValue
+ aAny = mpPropSet->getPropertyValue( pMap );
+
+ }
+ return aAny;
+}
+
+//----------------------------------------------------------------------
+
+// XMultiPropertySet
+void SAL_CALL SvxShape::setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aSolarGuard;
+
+ const sal_Int32 nCount = aPropertyNames.getLength();
+ const OUString* pNames = aPropertyNames.getConstArray();
+
+ const uno::Any* pValues = aValues.getConstArray();
+
+ // make sure mbIsMultiPropertyCall and mpImpl->mpItemSet are
+ // reseted even when an execption is thrown
+ const ::comphelper::ScopeGuard aGuard( boost::bind( &SvxShape::endSetPropertyValues, this ) );
+
+ mbIsMultiPropertyCall = sal_True;
+
+ if( mpImpl->mpMaster )
+ {
+ for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
+ {
+ try
+ {
+ setPropertyValue( *pNames, *pValues );
+ }
+ catch( beans::UnknownPropertyException& e )
+ {
+ (void)e;
+ }
+ catch( uno::Exception& ex )
+ {
+ (void)ex;
+ }
+ }
+ }
+ else
+ {
+ uno::Reference< beans::XPropertySet > xSet;
+ queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ) >>= xSet;
+
+ for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pNames++, pValues++ )
+ {
+ try
+ {
+ xSet->setPropertyValue( *pNames, *pValues );
+ }
+ catch( beans::UnknownPropertyException& e )
+ {
+ (void)e;
+ }
+ catch( uno::Exception& ex )
+ {
+ (void)ex;
+ }
+ }
+ }
+
+ if( mpImpl->mpItemSet && mpObj.is() )
+ mpObj->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet );
+}
+
+//----------------------------------------------------------------------
+
+void SvxShape::endSetPropertyValues()
+{
+ mbIsMultiPropertyCall = sal_False;
+ if( mpImpl->mpItemSet )
+ {
+ delete mpImpl->mpItemSet;
+ mpImpl->mpItemSet = 0;
+ }
+}
+
+//----------------------------------------------------------------------
+
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL SvxShape::getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException)
+{
+ const sal_Int32 nCount = aPropertyNames.getLength();
+ const OUString* pNames = aPropertyNames.getConstArray();
+
+ uno::Sequence< uno::Any > aRet( nCount );
+ uno::Any* pValue = aRet.getArray();;
+
+ if( mpImpl->mpMaster )
+ {
+ for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
+ {
+ try
+ {
+ *pValue = getPropertyValue( *pNames );
+ }
+ catch( uno::Exception& )
+ {
+ DBG_ERROR( "SvxShape::getPropertyValues, unknown property asked" );
+ }
+ }
+ }
+ else
+ {
+ uno::Reference< beans::XPropertySet > xSet;
+ queryInterface( ::getCppuType( (const uno::Reference< beans::XPropertySet >*) 0) ) >>= xSet;
+
+ for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++, pValue++, pNames++ )
+ {
+ try
+ {
+ *pValue = xSet->getPropertyValue( *pNames );
+ }
+ catch( uno::Exception& )
+ {
+ DBG_ERROR( "SvxShape::getPropertyValues, unknown property asked" );
+ }
+ }
+ }
+
+ return aRet;
+}
+
+void SAL_CALL SvxShape::addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+void SAL_CALL SvxShape::removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+void SAL_CALL SvxShape::firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& ) throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+//----------------------------------------------------------------------
+
+uno::Any SvxShape::GetAnyForItem( SfxItemSet& aSet, const SfxItemPropertySimpleEntry* pMap ) const
+{
+ DBG_TESTSOLARMUTEX();
+ uno::Any aAny;
+
+ switch(pMap->nWID)
+ {
+ case SDRATTR_CIRCSTARTANGLE:
+ {
+ const SfxPoolItem* pPoolItem=NULL;
+ if(aSet.GetItemState(SDRATTR_CIRCSTARTANGLE,sal_False,&pPoolItem)==SFX_ITEM_SET)
+ {
+ sal_Int32 nAngle = ((SdrCircStartAngleItem*)pPoolItem)->GetValue();
+ aAny <<= nAngle;
+ }
+ break;
+ }
+
+ case SDRATTR_CIRCENDANGLE:
+ {
+ const SfxPoolItem* pPoolItem=NULL;
+ if (aSet.GetItemState(SDRATTR_CIRCENDANGLE,sal_False,&pPoolItem)==SFX_ITEM_SET)
+ {
+ sal_Int32 nAngle = ((SdrCircEndAngleItem*)pPoolItem)->GetValue();
+ aAny <<= nAngle;
+ }
+ break;
+ }
+
+ case SDRATTR_CIRCKIND:
+ {
+ if( mpObj->GetObjInventor() == SdrInventor)
+ {
+ drawing::CircleKind eKind;
+ switch(mpObj->GetObjIdentifier())
+ {
+ case OBJ_CIRC: // Kreis, Ellipse
+ eKind = drawing::CircleKind_FULL;
+ break;
+ case OBJ_CCUT: // Kreisabschnitt
+ eKind = drawing::CircleKind_CUT;
+ break;
+ case OBJ_CARC: // Kreisbogen
+ eKind = drawing::CircleKind_ARC;
+ break;
+ case OBJ_SECT: // Kreissektor
+ eKind = drawing::CircleKind_SECTION;
+ break;
+ }
+ aAny <<= eKind;
+ }
+ break;
+ }
+ default:
+ {
+ // Hole Wert aus ItemSet
+ aAny = SvxItemPropertySet_getPropertyValue( *mpPropSet, pMap, aSet );
+
+ if( *pMap->pType != aAny.getValueType() )
+ {
+ // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
+ if( ( *pMap->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) )
+ {
+ sal_Int32 nValue = 0;
+ aAny >>= nValue;
+ aAny <<= (sal_Int16)nValue;
+ }
+ else
+ {
+ DBG_ERROR("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" );
+ }
+ }
+
+ }
+ }
+
+ return aAny;
+}
+
+//----------------------------------------------------------------------
+
+// XPropertyState
+beans::PropertyState SAL_CALL SvxShape::getPropertyState( const OUString& PropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ if( mpImpl->mpMaster )
+ {
+ return mpImpl->mpMaster->getPropertyState( PropertyName );
+ }
+ else
+ {
+ return _getPropertyState( PropertyName );
+ }
+}
+
+beans::PropertyState SAL_CALL SvxShape::_getPropertyState( const OUString& PropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
+
+ if( !mpObj.is() || pMap == NULL )
+ throw beans::UnknownPropertyException();
+
+ beans::PropertyState eState;
+ if( !getPropertyStateImpl( pMap, eState ) )
+ {
+ const SfxItemSet& rSet = mpObj->GetMergedItemSet();
+
+ switch( rSet.GetItemState( pMap->nWID, sal_False ) )
+ {
+ case SFX_ITEM_READONLY:
+ case SFX_ITEM_SET:
+ eState = beans::PropertyState_DIRECT_VALUE;
+ break;
+ case SFX_ITEM_DEFAULT:
+ eState = beans::PropertyState_DEFAULT_VALUE;
+ break;
+// case SFX_ITEM_UNKNOWN:
+// case SFX_ITEM_DONTCARE:
+// case SFX_ITEM_DISABLED:
+ default:
+ eState = beans::PropertyState_AMBIGUOUS_VALUE;
+ break;
+ }
+
+ // if a item is set, this doesn't mean we want it :)
+ if( ( beans::PropertyState_DIRECT_VALUE == eState ) )
+ {
+ switch( pMap->nWID )
+ {
+ // the following items are disabled by changing the
+ // fill style or the line style. so there is no need
+ // to export items without names which should be empty
+ case XATTR_FILLBITMAP:
+ case XATTR_FILLGRADIENT:
+ case XATTR_FILLHATCH:
+ case XATTR_LINEDASH:
+ {
+ NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((USHORT)pMap->nWID);
+ if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) )
+ eState = beans::PropertyState_DEFAULT_VALUE;
+ }
+ break;
+
+ // #i36115#
+ // If e.g. the LineStart is on NONE and thus the string has length 0, it still
+ // may be a hard attribute covering the set LineStart of the parent (Style).
+ // #i37644#
+ // same is for fill float transparency
+ case XATTR_LINEEND:
+ case XATTR_LINESTART:
+ case XATTR_FILLFLOATTRANSPARENCE:
+ {
+ NameOrIndex* pItem = (NameOrIndex*)rSet.GetItem((USHORT)pMap->nWID);
+ if( ( pItem == NULL ) )
+ eState = beans::PropertyState_DEFAULT_VALUE;
+ }
+ break;
+ }
+ }
+ }
+ return eState;
+}
+
+//----------------------------------------------------------------------
+
+bool SvxShape::setPropertyValueImpl( const ::rtl::OUString&, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+ case OWN_ATTR_CAPTION_POINT:
+ {
+ awt::Point aPnt;
+ if( rValue >>= aPnt )
+ {
+ Point aVclPoint( aPnt.X, aPnt.Y );
+
+ // #90763# position is relative to top left, make it absolute
+ basegfx::B2DPolyPolygon aNewPolyPolygon;
+ basegfx::B2DHomMatrix aNewHomogenMatrix;
+ mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+
+ aVclPoint.X() += basegfx::fround(aNewHomogenMatrix.get(0, 2));
+ aVclPoint.Y() += basegfx::fround(aNewHomogenMatrix.get(1, 2));
+
+ // #88657# metric of pool maybe twips (writer)
+ ForceMetricToItemPoolMetric(aVclPoint);
+
+ // #88491# position relative to anchor
+ if( mpModel->IsWriter() )
+ {
+ aVclPoint += mpObj->GetAnchorPos();
+ }
+
+ ((SdrCaptionObj*)mpObj.get())->SetTailPos(aVclPoint);
+
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_TRANSFORMATION:
+ {
+ drawing::HomogenMatrix3 aMatrix;
+ if(rValue >>= aMatrix)
+ {
+ basegfx::B2DPolyPolygon aNewPolyPolygon;
+ basegfx::B2DHomMatrix aNewHomogenMatrix;
+
+ mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+
+ aNewHomogenMatrix.set(0, 0, aMatrix.Line1.Column1);
+ aNewHomogenMatrix.set(0, 1, aMatrix.Line1.Column2);
+ aNewHomogenMatrix.set(0, 2, aMatrix.Line1.Column3);
+ aNewHomogenMatrix.set(1, 0, aMatrix.Line2.Column1);
+ aNewHomogenMatrix.set(1, 1, aMatrix.Line2.Column2);
+ aNewHomogenMatrix.set(1, 2, aMatrix.Line2.Column3);
+ aNewHomogenMatrix.set(2, 0, aMatrix.Line3.Column1);
+ aNewHomogenMatrix.set(2, 1, aMatrix.Line3.Column2);
+ aNewHomogenMatrix.set(2, 2, aMatrix.Line3.Column3);
+
+ mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ return true;
+ }
+ break;
+ }
+
+ case OWN_ATTR_ZORDER:
+ {
+ sal_Int32 nNewOrdNum = 0;
+ if(rValue >>= nNewOrdNum)
+ {
+ SdrObjList* pObjList = mpObj->GetObjList();
+ if( pObjList )
+ {
+#ifdef DBG_UTIL
+ SdrObject* pCheck =
+#endif
+ pObjList->SetObjectOrdNum( mpObj->GetOrdNum(), (ULONG)nNewOrdNum );
+ DBG_ASSERT( pCheck == mpObj.get(), "GetOrdNum() failed!" );
+ }
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_FRAMERECT:
+ {
+ awt::Rectangle aUnoRect;
+ if(rValue >>= aUnoRect)
+ {
+ Point aTopLeft( aUnoRect.X, aUnoRect.Y );
+ Size aObjSize( aUnoRect.Width, aUnoRect.Height );
+ ForceMetricToItemPoolMetric(aTopLeft);
+ ForceMetricToItemPoolMetric(aObjSize);
+ Rectangle aRect;
+ aRect.SetPos(aTopLeft);
+ aRect.SetSize(aObjSize);
+ mpObj->SetSnapRect(aRect);
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_MIRRORED:
+ {
+ sal_Bool bMirror = sal_Bool();
+ if(rValue >>= bMirror )
+ {
+ SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( mpObj.get() );
+ if( pObj )
+ pObj->SetMirrored(bMirror);
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_EDGE_START_OBJ:
+ case OWN_ATTR_EDGE_END_OBJ:
+ case OWN_ATTR_GLUEID_HEAD:
+ case OWN_ATTR_GLUEID_TAIL:
+ case OWN_ATTR_EDGE_START_POS:
+ case OWN_ATTR_EDGE_END_POS:
+ case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
+ {
+ SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(mpObj.get());
+ if(pEdgeObj)
+ {
+ switch(pProperty->nWID)
+ {
+ case OWN_ATTR_EDGE_START_OBJ:
+ case OWN_ATTR_EDGE_END_OBJ:
+ {
+ Reference< drawing::XShape > xShape;
+ if( rValue >>= xShape )
+ {
+ SdrObject* pNode = GetSdrObjectFromXShape( xShape );
+ if( pNode )
+ {
+ pEdgeObj->ConnectToNode( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, pNode );
+ pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_EDGE_START_OBJ, -1 );
+ return true;
+ }
+ }
+ break;
+ }
+
+ case OWN_ATTR_EDGE_START_POS:
+ case OWN_ATTR_EDGE_END_POS:
+ {
+ awt::Point aUnoPoint;
+ if( rValue >>= aUnoPoint )
+ {
+ Point aPoint( aUnoPoint.X, aUnoPoint.Y );
+
+ // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051
+ // perform metric change before applying anchor position,
+ // because the anchor position is in pool metric.
+ ForceMetricToItemPoolMetric( aPoint );
+ // <--
+ if( mpModel->IsWriter() )
+ aPoint += mpObj->GetAnchorPos();
+
+ pEdgeObj->SetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS, aPoint );
+ return true;
+ }
+ break;
+ }
+
+ case OWN_ATTR_GLUEID_HEAD:
+ case OWN_ATTR_GLUEID_TAIL:
+ {
+ sal_Int32 nId = 0;
+ if( rValue >>= nId )
+ {
+ pEdgeObj->setGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD, nId );
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
+ {
+ drawing::PolyPolygonBezierCoords aPolyPoly;
+ if ( rValue >>= aPolyPoly )
+ {
+ basegfx::B2DPolyPolygon aNewPolyPolygon( SvxConvertPolyPolygonBezierToB2DPolyPolygon( &aPolyPoly ) );
+ // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051
+ ForceMetricToItemPoolMetric( aNewPolyPolygon );
+ // <--
+ if( mpModel->IsWriter() )
+ {
+ Point aPoint( mpObj->GetAnchorPos() );
+ aNewPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(aPoint.X(), aPoint.Y()));
+ }
+ pEdgeObj->SetEdgeTrackPath( aNewPolyPolygon );
+ return true;
+ }
+ }
+ }
+ }
+ break;
+ }
+ case OWN_ATTR_MEASURE_START_POS:
+ case OWN_ATTR_MEASURE_END_POS:
+ {
+ SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(mpObj.get());
+ awt::Point aUnoPoint;
+ if(pMeasureObj && ( rValue >>= aUnoPoint ) )
+ {
+ Point aPoint( aUnoPoint.X, aUnoPoint.Y );
+
+ // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue i59051
+ ForceMetricToItemPoolMetric( aPoint );
+ // <--
+ if( mpModel->IsWriter() )
+ aPoint += mpObj->GetAnchorPos();
+
+ pMeasureObj->NbcSetPoint( aPoint, pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0L : 1L );
+ pMeasureObj->SetChanged();
+ pMeasureObj->BroadcastObjectChange();
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_FILLBMP_MODE:
+ {
+ drawing::BitmapMode eMode;
+ if(!(rValue >>= eMode) )
+ {
+ sal_Int32 nMode = 0;
+ if(!(rValue >>= nMode))
+ break;
+
+ eMode = (drawing::BitmapMode)nMode;
+ }
+ mpObj->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) );
+ mpObj->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) );
+ return true;
+ }
+
+ case SDRATTR_LAYERID:
+ {
+ sal_Int16 nLayerId = sal_Int16();
+ if( rValue >>= nLayerId )
+ {
+ SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID((unsigned char)nLayerId);
+ if( pLayer )
+ {
+ mpObj->SetLayer((unsigned char)nLayerId);
+ return true;
+ }
+ }
+ break;
+ }
+
+ case SDRATTR_LAYERNAME:
+ {
+ OUString aLayerName;
+ if( rValue >>= aLayerName )
+ {
+ const SdrLayer* pLayer=mpModel->GetLayerAdmin().GetLayer(aLayerName, TRUE);
+ if( pLayer != NULL )
+ {
+ mpObj->SetLayer( pLayer->GetID() );
+ return true;
+ }
+ }
+ break;
+ }
+ case SDRATTR_ROTATEANGLE:
+ {
+ sal_Int32 nAngle = 0;
+ if( rValue >>= nAngle )
+ {
+ Point aRef1(mpObj->GetSnapRect().Center());
+ nAngle -= mpObj->GetRotateAngle();
+ if (nAngle!=0)
+ {
+ double nSin=sin(nAngle*nPi180);
+ double nCos=cos(nAngle*nPi180);
+ mpObj->Rotate(aRef1,nAngle,nSin,nCos);
+ }
+ return true;
+ }
+
+ break;
+ }
+
+ case SDRATTR_SHEARANGLE:
+ {
+ sal_Int32 nShear = 0;
+ if( rValue >>= nShear )
+ {
+ nShear -= mpObj->GetShearAngle();
+ if(nShear != 0 )
+ {
+ Point aRef1(mpObj->GetSnapRect().Center());
+ double nTan=tan(nShear*nPi180);
+ mpObj->Shear(aRef1,nShear,nTan,FALSE);
+ return true;
+ }
+ }
+
+ break;
+ }
+
+ case SDRATTR_OBJMOVEPROTECT:
+ {
+ sal_Bool bMoveProtect = sal_Bool();
+ if( rValue >>= bMoveProtect )
+ {
+ mpObj->SetMoveProtect(bMoveProtect);
+ return true;
+ }
+ break;
+ }
+ case SDRATTR_OBJECTNAME:
+ {
+ OUString aName;
+ if( rValue >>= aName )
+ {
+ mpObj->SetName( aName );
+ return true;
+ }
+ break;
+ }
+
+ // #i68101#
+ case OWN_ATTR_MISC_OBJ_TITLE:
+ {
+ OUString aTitle;
+ if( rValue >>= aTitle )
+ {
+ mpObj->SetTitle( aTitle );
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_MISC_OBJ_DESCRIPTION:
+ {
+ OUString aDescription;
+ if( rValue >>= aDescription )
+ {
+ mpObj->SetDescription( aDescription );
+ return true;
+ }
+ break;
+ }
+
+ case SDRATTR_OBJPRINTABLE:
+ {
+ sal_Bool bPrintable = sal_Bool();
+ if( rValue >>= bPrintable )
+ {
+ mpObj->SetPrintable(bPrintable);
+ return true;
+ }
+ break;
+ }
+ case SDRATTR_OBJVISIBLE:
+ {
+ sal_Bool bVisible = sal_Bool();
+ if( rValue >>= bVisible )
+ {
+ mpObj->SetVisible(bVisible);
+ return true;
+ }
+ break;
+ }
+ case SDRATTR_OBJSIZEPROTECT:
+ {
+ sal_Bool bResizeProtect = sal_Bool();
+ if( rValue >>= bResizeProtect )
+ {
+ mpObj->SetResizeProtect(bResizeProtect);
+ return true;
+ }
+ break;
+ }
+ case OWN_ATTR_PAGE_NUMBER:
+ {
+ sal_Int32 nPageNum = 0;
+ if( (rValue >>= nPageNum) && ( nPageNum >= 0 ) && ( nPageNum <= 0xffff ) )
+ {
+ SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(mpObj.get());
+ if( pPageObj )
+ {
+ SdrModel* pModel = pPageObj->GetModel();
+ SdrPage* pNewPage = 0L;
+ const sal_uInt16 nDestinationPageNum((sal_uInt16)((nPageNum << 1L) - 1L));
+
+ if(pModel)
+ {
+ if(nDestinationPageNum < pModel->GetPageCount())
+ {
+ pNewPage = pModel->GetPage(nDestinationPageNum);
+ }
+ }
+
+ pPageObj->SetReferencedPage(pNewPage);
+ }
+
+ return true;
+ }
+ break;
+ }
+ case XATTR_FILLBITMAP:
+ case XATTR_FILLGRADIENT:
+ case XATTR_FILLHATCH:
+ case XATTR_FILLFLOATTRANSPARENCE:
+ case XATTR_LINEEND:
+ case XATTR_LINESTART:
+ case XATTR_LINEDASH:
+ {
+ if( pProperty->nMemberId == MID_NAME )
+ {
+ OUString aApiName;
+ if( rValue >>= aApiName )
+ {
+ if( SetFillAttribute( pProperty->nWID, aApiName ) )
+ return true;
+ }
+ break;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ default:
+ {
+ return false;
+ }
+ }
+ throw lang::IllegalArgumentException();
+}
+
+//----------------------------------------------------------------------
+
+bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ switch( pProperty->nWID )
+ {
+/*
+ case OWN_ATTR_HASLEVELS:
+ {
+ rValue <<= SvxTextEditSource::hasLevels( mpObj.get() );
+ break;
+ }
+*/
+ case OWN_ATTR_CAPTION_POINT:
+ {
+ Point aVclPoint = ((SdrCaptionObj*)mpObj.get())->GetTailPos();
+
+ // #88491# make pos relative to anchor
+ if( mpModel->IsWriter() )
+ {
+ aVclPoint -= mpObj->GetAnchorPos();
+ }
+
+ // #88657# metric of pool maybe twips (writer)
+ ForceMetricTo100th_mm(aVclPoint);
+
+ // #90763# pos is absolute, make it relative to top left
+ basegfx::B2DPolyPolygon aNewPolyPolygon;
+ basegfx::B2DHomMatrix aNewHomogenMatrix;
+ mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+
+ aVclPoint.X() -= basegfx::fround(aNewHomogenMatrix.get(0, 2));
+ aVclPoint.Y() -= basegfx::fround(aNewHomogenMatrix.get(1, 2));
+
+ awt::Point aPnt( aVclPoint.X(), aVclPoint.Y() );
+ rValue <<= aPnt;
+ break;
+ }
+
+ case OWN_ATTR_TRANSFORMATION:
+ {
+ basegfx::B2DPolyPolygon aNewPolyPolygon;
+ basegfx::B2DHomMatrix aNewHomogenMatrix;
+ mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+ drawing::HomogenMatrix3 aMatrix;
+
+ aMatrix.Line1.Column1 = aNewHomogenMatrix.get(0, 0);
+ aMatrix.Line1.Column2 = aNewHomogenMatrix.get(0, 1);
+ aMatrix.Line1.Column3 = aNewHomogenMatrix.get(0, 2);
+ aMatrix.Line2.Column1 = aNewHomogenMatrix.get(1, 0);
+ aMatrix.Line2.Column2 = aNewHomogenMatrix.get(1, 1);
+ aMatrix.Line2.Column3 = aNewHomogenMatrix.get(1, 2);
+ aMatrix.Line3.Column1 = aNewHomogenMatrix.get(2, 0);
+ aMatrix.Line3.Column2 = aNewHomogenMatrix.get(2, 1);
+ aMatrix.Line3.Column3 = aNewHomogenMatrix.get(2, 2);
+
+ rValue <<= aMatrix;
+
+ break;
+ }
+
+ case OWN_ATTR_ZORDER:
+ {
+ rValue <<= (sal_Int32)mpObj->GetOrdNum();
+ break;
+ }
+
+ case OWN_ATTR_BITMAP:
+ {
+ rValue = GetBitmap();
+ if(!rValue.hasValue())
+ throw uno::RuntimeException();
+
+ break;
+ }
+
+ case OWN_ATTR_ISFONTWORK:
+ {
+ rValue <<= (sal_Bool)(mpObj->ISA(SdrTextObj) && ((SdrTextObj*)mpObj.get())->IsFontwork());
+ break;
+ }
+
+ case OWN_ATTR_FRAMERECT:
+ {
+ Rectangle aRect( mpObj->GetSnapRect() );
+ Point aTopLeft( aRect.TopLeft() );
+ Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
+ ForceMetricTo100th_mm(aTopLeft);
+ ForceMetricTo100th_mm(aObjSize);
+ ::com::sun::star::awt::Rectangle aUnoRect(
+ aTopLeft.X(), aTopLeft.Y(),
+ aObjSize.getWidth(), aObjSize.getHeight() );
+ rValue <<= aUnoRect;
+ break;
+ }
+
+ case OWN_ATTR_BOUNDRECT:
+ {
+ Rectangle aRect( mpObj->GetCurrentBoundRect() );
+ Point aTopLeft( aRect.TopLeft() );
+ Size aObjSize( aRect.GetWidth(), aRect.GetHeight() );
+ ForceMetricTo100th_mm(aTopLeft);
+ ForceMetricTo100th_mm(aObjSize);
+ ::com::sun::star::awt::Rectangle aUnoRect(
+ aTopLeft.X(), aTopLeft.Y(),
+ aObjSize.getWidth(), aObjSize.getHeight() );
+ rValue <<= aUnoRect;
+ break;
+ }
+
+ case OWN_ATTR_LDNAME:
+ {
+ OUString aName( mpObj->GetName() );
+ rValue <<= aName;
+ break;
+ }
+
+ case OWN_ATTR_LDBITMAP:
+ {
+ sal_uInt16 nId;
+ if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_OLE2 )
+ {
+ nId = RID_UNODRAW_OLE2;
+ }
+ else if( mpObj->GetObjInventor() == SdrInventor && mpObj->GetObjIdentifier() == OBJ_GRAF )
+ {
+ nId = RID_UNODRAW_GRAPHICS;
+ }
+ else
+ {
+ nId = RID_UNODRAW_OBJECTS;
+ }
+
+ BitmapEx aBmp( SVX_RES(nId) );
+ Reference< awt::XBitmap > xBmp( VCLUnoHelper::CreateBitmap( aBmp ) );
+
+ rValue <<= xBmp;
+ break;
+ }
+
+ case OWN_ATTR_MIRRORED:
+ {
+ sal_Bool bMirror = sal_False;
+ if( mpObj.is() && mpObj->ISA(SdrGrafObj) )
+ bMirror = ((SdrGrafObj*)mpObj.get())->IsMirrored();
+
+ rValue <<= bMirror;
+ }
+
+ case OWN_ATTR_EDGE_START_OBJ:
+ case OWN_ATTR_EDGE_START_POS:
+ case OWN_ATTR_EDGE_END_POS:
+ case OWN_ATTR_EDGE_END_OBJ:
+ case OWN_ATTR_GLUEID_HEAD:
+ case OWN_ATTR_GLUEID_TAIL:
+ case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
+ {
+ SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(mpObj.get());
+ if(pEdgeObj)
+ {
+ switch(pProperty->nWID)
+ {
+ case OWN_ATTR_EDGE_START_OBJ:
+ case OWN_ATTR_EDGE_END_OBJ:
+ {
+ SdrObject* pNode = pEdgeObj->GetConnectedNode(pProperty->nWID == OWN_ATTR_EDGE_START_OBJ);
+ if(pNode)
+ {
+ Reference< drawing::XShape > xShape( GetXShapeForSdrObject( pNode ) );
+ if(xShape.is())
+ rValue <<= xShape;
+
+ }
+ break;
+ }
+
+ case OWN_ATTR_EDGE_START_POS:
+ case OWN_ATTR_EDGE_END_POS:
+ {
+ Point aPoint( pEdgeObj->GetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS ) );
+ if( mpModel->IsWriter() )
+ aPoint -= mpObj->GetAnchorPos();
+
+ ForceMetricTo100th_mm( aPoint );
+ awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
+
+ rValue <<= aUnoPoint;
+ break;
+ }
+ case OWN_ATTR_GLUEID_HEAD:
+ case OWN_ATTR_GLUEID_TAIL:
+ {
+ rValue <<= pEdgeObj->getGluePointIndex( pProperty->nWID == OWN_ATTR_GLUEID_HEAD );
+ break;
+ }
+ case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
+ {
+ basegfx::B2DPolyPolygon aPolyPoly( pEdgeObj->GetEdgeTrackPath() );
+ if( mpModel->IsWriter() )
+ {
+ Point aPoint( mpObj->GetAnchorPos() );
+ aPolyPoly.transform(basegfx::tools::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y()));
+ }
+ // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue 59051
+ ForceMetricTo100th_mm( aPolyPoly );
+ // <--
+ drawing::PolyPolygonBezierCoords aRetval;
+ SvxConvertB2DPolyPolygonToPolyPolygonBezier( aPolyPoly, aRetval);
+ rValue <<= aRetval;
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ case OWN_ATTR_MEASURE_START_POS:
+ case OWN_ATTR_MEASURE_END_POS:
+ {
+ SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(mpObj.get());
+ if(pMeasureObj)
+ {
+ Point aPoint( pMeasureObj->GetPoint( pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 ) );
+ if( mpModel->IsWriter() )
+ aPoint -= mpObj->GetAnchorPos();
+
+ // --> OD 2010-02-19 #i108851# - reintroduction of fix for issue 59051
+ ForceMetricTo100th_mm( aPoint );
+ // <--
+ awt::Point aUnoPoint( aPoint.X(), aPoint.Y() );
+
+ rValue <<= aUnoPoint;
+ break;
+ }
+ break;
+ }
+
+ case OWN_ATTR_FILLBMP_MODE:
+ {
+ const SfxItemSet& rObjItemSet = mpObj->GetMergedItemSet();
+
+ XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)&rObjItemSet.Get(XATTR_FILLBMP_STRETCH);
+ XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)&rObjItemSet.Get(XATTR_FILLBMP_TILE);
+
+ if( pTileItem && pTileItem->GetValue() )
+ {
+ rValue <<= drawing::BitmapMode_REPEAT;
+ }
+ else if( pStretchItem && pStretchItem->GetValue() )
+ {
+ rValue <<= drawing::BitmapMode_STRETCH;
+ }
+ else
+ {
+ rValue <<= drawing::BitmapMode_NO_REPEAT;
+ }
+ break;
+ }
+ case SDRATTR_LAYERID:
+ rValue <<= (sal_Int16)mpObj->GetLayer();
+ break;
+
+ case SDRATTR_LAYERNAME:
+ {
+ SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID(mpObj->GetLayer());
+ if( pLayer )
+ {
+ OUString aName( pLayer->GetName() );
+ rValue <<= aName;
+ }
+ break;
+ }
+
+ case SDRATTR_ROTATEANGLE:
+ rValue <<= mpObj->GetRotateAngle();
+ break;
+
+ case SDRATTR_SHEARANGLE:
+ rValue <<= mpObj->GetShearAngle();
+ break;
+
+ case SDRATTR_OBJMOVEPROTECT:
+ rValue = uno::makeAny( (sal_Bool) mpObj->IsMoveProtect() );
+ break;
+
+ case SDRATTR_OBJECTNAME:
+ {
+ OUString aName( mpObj->GetName() );
+ rValue <<= aName;
+ break;
+ }
+
+ // #i68101#
+ case OWN_ATTR_MISC_OBJ_TITLE:
+ {
+ OUString aTitle( mpObj->GetTitle() );
+ rValue <<= aTitle;
+ break;
+ }
+
+ case OWN_ATTR_MISC_OBJ_DESCRIPTION:
+ {
+ OUString aDescription( mpObj->GetDescription() );
+ rValue <<= aDescription;
+ break;
+ }
+
+ case SDRATTR_OBJPRINTABLE:
+ rValue <<= static_cast<sal_Bool>( mpObj->IsPrintable() );
+ break;
+
+ case SDRATTR_OBJVISIBLE:
+ rValue <<= static_cast<sal_Bool>( mpObj->IsVisible() );
+ break;
+
+ case SDRATTR_OBJSIZEPROTECT:
+ rValue <<= static_cast<sal_Bool>( mpObj->IsResizeProtect() );
+ break;
+
+ case OWN_ATTR_PAGE_NUMBER:
+ {
+ SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(mpObj.get());
+ if(pPageObj)
+ {
+ SdrPage* pPage = pPageObj->GetReferencedPage();
+ sal_Int32 nPageNumber = (pPage) ? pPage->GetPageNum() : 0L;
+ nPageNumber++;
+ nPageNumber >>= 1;
+ rValue <<= nPageNumber;
+ }
+ break;
+ }
+
+ case OWN_ATTR_UINAME_SINGULAR:
+ {
+ String aTmp;
+ mpObj->TakeObjNameSingul( aTmp );
+ rValue <<= OUString( aTmp );
+ break;
+ }
+
+ case OWN_ATTR_UINAME_PLURAL:
+ {
+ String aTmp;
+ mpObj->TakeObjNamePlural( aTmp );
+ rValue <<= OUString( aTmp );
+ break;
+ }
+ case OWN_ATTR_METAFILE:
+ {
+ SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get());
+ if( pObj )
+ {
+ Graphic* pGraphic = pObj->GetGraphic();
+ if( pGraphic )
+ {
+ BOOL bIsWMF = FALSE;
+ if ( pGraphic->IsLink() )
+ {
+ GfxLink aLnk = pGraphic->GetLink();
+ if ( aLnk.GetType() == GFX_LINK_TYPE_NATIVE_WMF )
+ {
+ bIsWMF = TRUE;
+ uno::Sequence<sal_Int8> aSeq((sal_Int8*)aLnk.GetData(), (sal_Int32) aLnk.GetDataSize());
+ rValue <<= aSeq;
+ }
+ }
+ if ( !bIsWMF )
+ {
+ GDIMetaFile aMtf;
+ if ( pGraphic->GetType() != GRAPHIC_BITMAP )
+ aMtf = pObj->GetGraphic()->GetGDIMetaFile();
+ else
+ {
+ VirtualDevice aVirDev;
+ aMtf.Record( &aVirDev );
+ pGraphic->Draw( &aVirDev, Point(), pGraphic->GetPrefSize() );
+ aMtf.Stop();
+ aMtf.SetPrefSize( pGraphic->GetPrefSize() );
+ aMtf.SetPrefMapMode( pGraphic->GetPrefMapMode() );
+ }
+ SvMemoryStream aDestStrm( 65535, 65535 );
+ ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False );
+ const uno::Sequence<sal_Int8> aSeq(
+ static_cast< const sal_Int8* >(aDestStrm.GetData()),
+ aDestStrm.GetEndOfData());
+ rValue <<= aSeq;
+ }
+ }
+ }
+ else
+ {
+ rValue = GetBitmap( sal_True );
+ }
+ break;
+ }
+
+
+ default:
+ return false;
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------
+
+bool SvxShape::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
+{
+ if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
+ {
+ const SfxItemSet& rSet = mpObj->GetMergedItemSet();
+
+ if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET ||
+ rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET )
+ {
+ rState = beans::PropertyState_DIRECT_VALUE;
+ }
+ else
+ {
+ rState = beans::PropertyState_AMBIGUOUS_VALUE;
+ }
+ }
+ else if((( pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
+ ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST )) && ( pProperty->nWID != SDRATTR_TEXTDIRECTION ) )
+ {
+ rState = beans::PropertyState_DIRECT_VALUE;
+ }
+ else
+ {
+ return false;
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------
+
+bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
+{
+ if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE )
+ {
+ mpObj->ClearMergedItem( XATTR_FILLBMP_STRETCH );
+ mpObj->ClearMergedItem( XATTR_FILLBMP_TILE );
+ return true;
+ }
+ else if((pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) ||
+ ( pProperty->nWID >= SDRATTR_NOTPERSIST_FIRST && pProperty->nWID <= SDRATTR_NOTPERSIST_LAST ))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+//----------------------------------------------------------------------
+
+uno::Sequence< beans::PropertyState > SAL_CALL SvxShape::getPropertyStates( const uno::Sequence< OUString >& aPropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ const sal_Int32 nCount = aPropertyName.getLength();
+ const OUString* pNames = aPropertyName.getConstArray();
+
+ uno::Sequence< beans::PropertyState > aRet( nCount );
+ beans::PropertyState* pState = aRet.getArray();
+
+ if( mpImpl->mpMaster )
+ {
+ for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
+ pState[nIdx] = getPropertyState( pNames[nIdx] );
+
+ }
+ else
+ {
+ for( sal_Int32 nIdx = 0; nIdx < nCount; nIdx++ )
+ pState[nIdx] = getPropertyState( pNames[nIdx] );
+ }
+
+ return aRet;
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::setPropertyToDefault( const OUString& PropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ if( mpImpl->mpMaster )
+ {
+ mpImpl->mpMaster->setPropertyToDefault( PropertyName );
+ }
+ else
+ {
+ _setPropertyToDefault( PropertyName );
+ }
+}
+
+void SAL_CALL SvxShape::_setPropertyToDefault( const OUString& PropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ const SfxItemPropertySimpleEntry* pProperty = mpPropSet->getPropertyMapEntry(PropertyName);
+
+ if( !mpObj.is() || mpModel == NULL || pProperty == NULL )
+ throw beans::UnknownPropertyException();
+
+ if( !setPropertyToDefaultImpl( pProperty ) )
+ {
+ mpObj->ClearMergedItem( pProperty->nWID );
+ }
+
+ mpModel->SetChanged();
+}
+
+//----------------------------------------------------------------------
+
+uno::Any SAL_CALL SvxShape::getPropertyDefault( const OUString& aPropertyName )
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( mpImpl->mpMaster )
+ {
+ return mpImpl->mpMaster->getPropertyDefault( aPropertyName );
+ }
+ else
+ {
+ return _getPropertyDefault( aPropertyName );
+ }
+}
+
+uno::Any SAL_CALL SvxShape::_getPropertyDefault( const OUString& aPropertyName )
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName);
+
+ if( !mpObj.is() || pMap == NULL || mpModel == NULL )
+ throw beans::UnknownPropertyException();
+
+ if(( pMap->nWID >= OWN_ATTR_VALUE_START && pMap->nWID <= OWN_ATTR_VALUE_END ) ||
+ ( pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST ))
+ {
+ return getPropertyValue( aPropertyName );
+ }
+
+ // Default aus ItemPool holen
+ if(!mpModel->GetItemPool().IsWhich(pMap->nWID))
+ throw beans::UnknownPropertyException();
+
+ SfxItemSet aSet( mpModel->GetItemPool(), pMap->nWID, pMap->nWID);
+ aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
+
+ return GetAnyForItem( aSet, pMap );
+}
+
+// XMultiPropertyStates
+void SvxShape::setAllPropertiesToDefault() throw (uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( !mpObj.is() )
+ throw lang::DisposedException();
+ mpObj->ClearMergedItem(); // nWhich == 0 => all
+
+ if(mpObj->ISA(SdrGrafObj))
+ {
+ // defaults for graphic objects have changed:
+ mpObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) );
+ mpObj->SetMergedItem( XLineStyleItem( XLINE_NONE ) );
+ }
+
+ // #i68523# special handling for Svx3DCharacterModeItem, this is not saved
+ // but needs to be TRUE in svx, pool default (false) in sch. Since sch
+ // does not load lathe or extrude objects, it is possible to set the items
+ // here.
+ // For other solution possibilities, see task description.
+ if(mpObj->ISA(E3dLatheObj) || mpObj->ISA(E3dExtrudeObj))
+ {
+ mpObj->SetMergedItem(Svx3DCharacterModeItem(true));
+ }
+
+ mpModel->SetChanged();
+}
+
+void SvxShape::setPropertiesToDefault(
+ const uno::Sequence<OUString>& aPropertyNames )
+ throw (beans::UnknownPropertyException, uno::RuntimeException)
+{
+ for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos )
+ setPropertyToDefault( aPropertyNames[pos] );
+}
+
+uno::Sequence<uno::Any> SvxShape::getPropertyDefaults(
+ const uno::Sequence<OUString>& aPropertyNames )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ ::std::vector<uno::Any> ret;
+ for ( sal_Int32 pos = 0; pos < aPropertyNames.getLength(); ++pos )
+ ret.push_back( getPropertyDefault( aPropertyNames[pos] ) );
+ return uno::Sequence<uno::Any>( &ret[0], ret.size() );
+}
+
+//----------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// XServiceInfo
+//----------------------------------------------------------------------
+OUString SAL_CALL SvxShape::getImplementationName()
+ throw(uno::RuntimeException)
+{
+ static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("SvxShape") );
+ return aServiceName;
+}
+
+#define STAR_NAMESPACE "com.sun.star."
+
+const char* sUNO_service_style_ParagraphProperties = STAR_NAMESPACE "style.ParagraphProperties";
+const char* sUNO_service_style_ParagraphPropertiesComplex = STAR_NAMESPACE "style.ParagraphPropertiesComplex";
+const char* sUNO_service_style_ParagraphPropertiesAsian = STAR_NAMESPACE "style.ParagraphPropertiesAsian";
+const char* sUNO_service_style_CharacterProperties = STAR_NAMESPACE "style.CharacterProperties";
+const char* sUNO_service_style_CharacterPropertiesComplex = STAR_NAMESPACE "style.CharacterPropertiesComplex";
+const char* sUNO_service_style_CharacterPropertiesAsian = STAR_NAMESPACE "style.CharacterPropertiesAsian";
+
+const char* sUNO_service_drawing_FillProperties = STAR_NAMESPACE "drawing.FillProperties";
+const char* sUNO_service_drawing_TextProperties = STAR_NAMESPACE "drawing.TextProperties";
+const char* sUNO_service_drawing_LineProperties = STAR_NAMESPACE "drawing.LineProperties";
+const char* sUNO_service_drawing_ConnectorProperties = STAR_NAMESPACE "drawing.ConnectorProperties";
+const char* sUNO_service_drawing_MeasureProperties = STAR_NAMESPACE "drawing.MeasureProperties";
+const char* sUNO_service_drawing_ShadowProperties = STAR_NAMESPACE "drawing.ShadowProperties";
+
+const char* sUNO_service_drawing_RotationDescriptor = STAR_NAMESPACE "drawing.RotationDescriptor";
+
+const char* sUNO_service_drawing_Text = STAR_NAMESPACE "drawing.Text";
+const char* sUNO_service_drawing_GroupShape = STAR_NAMESPACE "drawing.GroupShape";
+
+const char* sUNO_service_drawing_CustomShapeProperties = STAR_NAMESPACE "drawing.CustomShapeProperties";
+const char* sUNO_service_drawing_CustomShape = STAR_NAMESPACE "drawing.CustomShape";
+
+const char* sUNO_service_drawing_PolyPolygonDescriptor = STAR_NAMESPACE "drawing.PolyPolygonDescriptor";
+const char* sUNO_service_drawing_PolyPolygonBezierDescriptor= STAR_NAMESPACE "drawing.PolyPolygonBezierDescriptor";
+
+const char* sUNO_service_drawing_LineShape = STAR_NAMESPACE "drawing.LineShape";
+const char* sUNO_service_drawing_Shape = STAR_NAMESPACE "drawing.Shape";
+const char* sUNO_service_drawing_RectangleShape = STAR_NAMESPACE "drawing.RectangleShape";
+const char* sUNO_service_drawing_EllipseShape = STAR_NAMESPACE "drawing.EllipseShape";
+const char* sUNO_service_drawing_PolyPolygonShape = STAR_NAMESPACE "drawing.PolyPolygonShape";
+const char* sUNO_service_drawing_PolyLineShape = STAR_NAMESPACE "drawing.PolyLineShape";
+const char* sUNO_service_drawing_OpenBezierShape = STAR_NAMESPACE "drawing.OpenBezierShape";
+const char* sUNO_service_drawing_ClosedBezierShape = STAR_NAMESPACE "drawing.ClosedBezierShape";
+const char* sUNO_service_drawing_TextShape = STAR_NAMESPACE "drawing.TextShape";
+const char* sUNO_service_drawing_GraphicObjectShape = STAR_NAMESPACE "drawing.GraphicObjectShape";
+const char* sUNO_service_drawing_OLE2Shape = STAR_NAMESPACE "drawing.OLE2Shape";
+const char* sUNO_service_drawing_PageShape = STAR_NAMESPACE "drawing.PageShape";
+const char* sUNO_service_drawing_CaptionShape = STAR_NAMESPACE "drawing.CaptionShape";
+const char* sUNO_service_drawing_MeasureShape = STAR_NAMESPACE "drawing.MeasureShape";
+const char* sUNO_service_drawing_FrameShape = STAR_NAMESPACE "drawing.FrameShape";
+const char* sUNO_service_drawing_ControlShape = STAR_NAMESPACE "drawing.ControlShape";
+const char* sUNO_service_drawing_ConnectorShape = STAR_NAMESPACE "drawing.ConnectorShape";
+const char* sUNO_service_drawing_MediaShape = STAR_NAMESPACE "drawing.MediaShape";
+
+
+uno::Sequence< OUString > SAL_CALL SvxShape::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ if( mpImpl->mpMaster )
+ {
+ return mpImpl->mpMaster->getSupportedServiceNames();
+ }
+ else
+ {
+ return _getSupportedServiceNames();
+ }
+}
+
+uno::Sequence< OUString > SAL_CALL SvxShape::_getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( mpObj.is() && mpObj->GetObjInventor() == SdrInventor)
+ {
+ const UINT16 nIdent = mpObj->GetObjIdentifier();
+
+ switch(nIdent)
+ {
+ case OBJ_GRUP:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_GroupServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_GroupServices, 2,
+ sUNO_service_drawing_GroupShape,
+ sUNO_service_drawing_Shape );
+
+ pSeq = &SvxShape_GroupServices;
+ }
+ }
+
+ return *pSeq;
+ }
+ case OBJ_CUSTOMSHAPE:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_CustomShapeServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_CustomShapeServices, 13,
+ sUNO_service_drawing_CustomShape,
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_CustomShapeProperties,
+ sUNO_service_drawing_FillProperties,
+ sUNO_service_drawing_LineProperties,
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+ pSeq = &SvxShape_CustomShapeServices;
+ }
+ }
+ return *pSeq;
+ }
+ case OBJ_LINE:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_LineServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_LineServices,14,
+ sUNO_service_drawing_LineShape,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_LineProperties,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_PolyPolygonDescriptor,
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+
+ pSeq = &SvxShape_LineServices;
+ }
+ }
+ return *pSeq;
+ }
+
+ case OBJ_RECT:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_RectServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_RectServices,14,
+ sUNO_service_drawing_RectangleShape,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_FillProperties,
+ sUNO_service_drawing_LineProperties,
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+ pSeq = &SvxShape_RectServices;
+ }
+
+ }
+ return *pSeq;
+ }
+
+ case OBJ_CIRC:
+ case OBJ_SECT:
+ case OBJ_CARC:
+ case OBJ_CCUT:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_CircServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_CircServices,14,
+ sUNO_service_drawing_EllipseShape,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_FillProperties,
+ sUNO_service_drawing_LineProperties,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+
+ pSeq = &SvxShape_CircServices;
+ }
+ }
+
+ return *pSeq;
+ }
+
+ case OBJ_PATHPLIN:
+ case OBJ_PLIN:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_PathServices;
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_PathServices,14,
+ sUNO_service_drawing_PolyLineShape,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_LineProperties,
+
+ sUNO_service_drawing_PolyPolygonDescriptor,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+ pSeq = &SvxShape_PathServices;
+ }
+ }
+ return *pSeq;
+ }
+
+ case OBJ_PATHPOLY:
+ case OBJ_POLY:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_PolyServices;
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_PolyServices,15,
+ sUNO_service_drawing_PolyPolygonShape,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_LineProperties,
+ sUNO_service_drawing_FillProperties,
+
+ sUNO_service_drawing_PolyPolygonDescriptor,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+
+ pSeq = &SvxShape_PolyServices;
+ }
+ }
+ return *pSeq;
+ }
+
+ case OBJ_FREELINE:
+ case OBJ_PATHLINE:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_FreeLineServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeLineServices,15,
+ sUNO_service_drawing_OpenBezierShape,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_LineProperties,
+ sUNO_service_drawing_FillProperties,
+
+ sUNO_service_drawing_PolyPolygonBezierDescriptor,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+
+ pSeq = &SvxShape_FreeLineServices;
+ }
+ }
+
+ return *pSeq;
+ }
+
+ case OBJ_FREEFILL:
+ case OBJ_PATHFILL:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_FreeFillServices;
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_FreeFillServices,15,
+ sUNO_service_drawing_ClosedBezierShape,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_LineProperties,
+ sUNO_service_drawing_FillProperties,
+
+ sUNO_service_drawing_PolyPolygonBezierDescriptor,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+
+ pSeq = &SvxShape_FreeFillServices;
+ }
+ }
+ return *pSeq;
+ }
+
+ case OBJ_OUTLINETEXT:
+ case OBJ_TITLETEXT:
+ case OBJ_TEXT:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_TextServices;
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_TextServices,14,
+ sUNO_service_drawing_TextShape,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_FillProperties,
+ sUNO_service_drawing_LineProperties,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+
+ pSeq = &SvxShape_TextServices;
+ }
+ }
+ return *pSeq;
+ }
+
+ case OBJ_GRAF:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_GrafServices;
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_GrafServices, 12,
+ sUNO_service_drawing_GraphicObjectShape,
+
+ sUNO_service_drawing_Shape,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+
+ pSeq = &SvxShape_GrafServices;
+ }
+ }
+ return *pSeq;
+ }
+
+ case OBJ_OLE2:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_Ole2Services;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_Ole2Services, 2,
+ sUNO_service_drawing_OLE2Shape,
+ sUNO_service_drawing_Shape);
+
+ pSeq = &SvxShape_Ole2Services;
+ }
+ }
+ return *pSeq;
+ }
+
+ case OBJ_CAPTION:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_CaptionServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_CaptionServices,14,
+ sUNO_service_drawing_CaptionShape,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_FillProperties,
+ sUNO_service_drawing_LineProperties,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+
+ pSeq = &SvxShape_CaptionServices;
+ }
+ }
+
+ return *pSeq;
+ }
+
+ case OBJ_PAGE:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_PageServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_PageServices, 2,
+ sUNO_service_drawing_PageShape,
+ sUNO_service_drawing_Shape );
+
+ pSeq = &SvxShape_PageServices;
+ }
+ }
+
+ return *pSeq;
+ }
+
+ case OBJ_MEASURE:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_MeasureServices;
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_MeasureServices,15,
+ sUNO_service_drawing_MeasureShape,
+
+ sUNO_service_drawing_MeasureProperties,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_LineProperties,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_PolyPolygonDescriptor,
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+
+ pSeq = &SvxShape_MeasureServices;
+ }
+ }
+
+ return *pSeq;
+ }
+
+ case OBJ_FRAME:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_FrameServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_FrameServices, 2,
+ sUNO_service_drawing_FrameShape,
+ sUNO_service_drawing_Shape );
+
+ pSeq = &SvxShape_FrameServices;
+ }
+ }
+
+ return *pSeq;
+ }
+
+ case OBJ_UNO:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard _aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_UnoServices;
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2,
+ sUNO_service_drawing_ControlShape,
+ sUNO_service_drawing_Shape );
+
+ pSeq = &SvxShape_UnoServices;
+ }
+ }
+ return *pSeq;
+ }
+
+ case OBJ_EDGE:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_EdgeServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_EdgeServices,15,
+ sUNO_service_drawing_ConnectorShape,
+ sUNO_service_drawing_ConnectorProperties,
+
+ sUNO_service_drawing_Shape,
+ sUNO_service_drawing_LineProperties,
+
+ sUNO_service_drawing_Text,
+ sUNO_service_drawing_TextProperties,
+ sUNO_service_style_ParagraphProperties,
+ sUNO_service_style_ParagraphPropertiesComplex,
+ sUNO_service_style_ParagraphPropertiesAsian,
+ sUNO_service_style_CharacterProperties,
+ sUNO_service_style_CharacterPropertiesComplex,
+ sUNO_service_style_CharacterPropertiesAsian,
+
+ sUNO_service_drawing_PolyPolygonDescriptor,
+ sUNO_service_drawing_ShadowProperties,
+ sUNO_service_drawing_RotationDescriptor);
+
+ pSeq = &SvxShape_EdgeServices;
+ }
+ }
+ return *pSeq;
+ }
+ case OBJ_MEDIA:
+ {
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_MediaServices;
+
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_MediaServices, 2,
+ sUNO_service_drawing_MediaShape,
+ sUNO_service_drawing_Shape);
+
+ pSeq = &SvxShape_MediaServices;
+ }
+ }
+ return *pSeq;
+ }
+ }
+ }
+ else if( mpObj.is() && mpObj->GetObjInventor() == FmFormInventor)
+ {
+#if OSL_DEBUG_LEVEL > 0
+ const UINT16 nIdent = mpObj->GetObjIdentifier();
+ OSL_ENSURE( nIdent == OBJ_UNO, "SvxShape::_getSupportedServiceNames: FmFormInventor, but no UNO object?" );
+#endif
+ static uno::Sequence< OUString > *pSeq = 0;
+ if( 0 == pSeq )
+ {
+// ::SolarMutexGuard aGuard;
+// if( 0 == pSeq )
+ {
+ static uno::Sequence< OUString > SvxShape_UnoServices;
+ comphelper::ServiceInfoHelper::addToSequence( SvxShape_UnoServices, 2,
+ sUNO_service_drawing_ControlShape,
+ sUNO_service_drawing_Shape );
+
+ pSeq = &SvxShape_UnoServices;
+ }
+ }
+ return *pSeq;
+ }
+ OSL_ENSURE( false, "SvxShape::_getSupportedServiceNames: could not determine object type!" );
+ uno::Sequence< OUString > aSeq;
+ return aSeq;
+}
+
+//----------------------------------------------------------------------
+sal_Bool SAL_CALL SvxShape::supportsService( const OUString& ServiceName ) throw ( uno::RuntimeException )
+{
+ Sequence< OUString > SupportedServices( getSupportedServiceNames() );
+ const ::rtl::OUString * pArray = SupportedServices.getConstArray();
+ const sal_Int32 nCount = SupportedServices.getLength();
+ sal_Int32 i;
+ for( i = 0; i < nCount; i++ )
+ if( *pArray++ == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+//----------------------------------------------------------------------
+
+// XGluePointsSupplier
+uno::Reference< container::XIndexContainer > SAL_CALL SvxShape::getGluePoints()
+ throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ uno::Reference< container::XIndexContainer > xGluePoints( mxGluePoints );
+
+ if( mpObj.is() && !xGluePoints.is() )
+ {
+ uno::Reference< container::XIndexContainer > xNew( SvxUnoGluePointAccess_createInstance( mpObj.get() ), uno::UNO_QUERY );
+ mxGluePoints = xGluePoints = xNew;
+ }
+
+ return xGluePoints;
+}
+
+//----------------------------------------------------------------------
+
+// XChild
+uno::Reference< uno::XInterface > SAL_CALL SvxShape::getParent( )
+ throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( mpObj.is() && mpObj->GetObjList() )
+ {
+ SdrObjList* pObjList = mpObj->GetObjList();
+
+ switch( pObjList->GetListKind() )
+ {
+ case SDROBJLIST_GROUPOBJ:
+ if( pObjList->GetOwnerObj()->ISA( SdrObjGroup ) )
+ return PTR_CAST( SdrObjGroup, pObjList->GetOwnerObj())->getUnoShape();
+ else if( pObjList->GetOwnerObj()->ISA( E3dScene ) )
+ return PTR_CAST( E3dScene, pObjList->GetOwnerObj())->getUnoShape();
+ break;
+ case SDROBJLIST_DRAWPAGE:
+ case SDROBJLIST_MASTERPAGE:
+ return PTR_CAST( SdrPage, pObjList )->getUnoPage();
+ default:
+ DBG_ERROR( "SvxShape::getParent( ): unexpected SdrObjListKind" );
+ break;
+ }
+ }
+
+ uno::Reference< uno::XInterface > xParent;
+ return xParent;
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& )
+ throw(lang::NoSupportException, uno::RuntimeException)
+{
+ throw lang::NoSupportException();
+}
+
+//----------------------------------------------------------------------
+
+/** called from the XActionLockable interface methods on initial locking */
+void SvxShape::lock()
+{
+}
+
+//----------------------------------------------------------------------
+
+/** called from the XActionLockable interface methods on final unlock */
+void SvxShape::unlock()
+{
+}
+
+//----------------------------------------------------------------------
+
+// XActionLockable
+sal_Bool SAL_CALL SvxShape::isActionLocked( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ return mnLockCount != 0;
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::addActionLock( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ DBG_ASSERT( mnLockCount < 0xffff, "lock overflow in SvxShape!" );
+ mnLockCount++;
+
+ if( mnLockCount == 1 )
+ lock();
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::removeActionLock( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ DBG_ASSERT( mnLockCount > 0, "lock underflow in SvxShape!" );
+ mnLockCount--;
+
+ if( mnLockCount == 0 )
+ unlock();
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShape::setActionLocks( sal_Int16 nLock ) throw (::com::sun::star::uno::RuntimeException )
+{
+ ::SolarMutexGuard aGuard;
+
+ if( (mnLockCount == 0) && (nLock != 0) )
+ unlock();
+
+ if( (mnLockCount != 0) && (nLock == 0) )
+ lock();
+
+ mnLockCount = (sal_uInt16)nLock;
+}
+
+//----------------------------------------------------------------------
+
+sal_Int16 SAL_CALL SvxShape::resetActionLocks( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+
+ if( mnLockCount != 0 )
+ unlock();
+
+ sal_Int16 nOldLocks = (sal_Int16)mnLockCount;
+ mnLockCount = 0;
+
+ return nOldLocks;
+}
+
+//----------------------------------------------------------------------
+
+/** since polygon shapes can change theire kind during editing, we have
+ to recheck it here.
+ Circle shapes also change theire kind, but theire all treated equal
+ so no update is necessary.
+*/
+void SvxShape::updateShapeKind()
+{
+ switch( mpImpl->mnObjId )
+ {
+ case OBJ_LINE:
+ case OBJ_POLY:
+ case OBJ_PLIN:
+ case OBJ_PATHLINE:
+ case OBJ_PATHFILL:
+ case OBJ_FREELINE:
+ case OBJ_FREEFILL:
+ case OBJ_PATHPOLY:
+ case OBJ_PATHPLIN:
+ {
+ const sal_uInt32 nId = mpObj->GetObjIdentifier();
+
+ if( nId != mpImpl->mnObjId )
+ {
+ mpImpl->mnObjId = nId;
+
+ }
+ break;
+ }
+ };
+}
+
+/***********************************************************************
+* class SvxShapeText *
+***********************************************************************/
+SvxShapeText::SvxShapeText() throw ()
+: SvxShape(NULL, aSvxMapProvider.GetMap(SVXMAP_TEXT), aSvxMapProvider.GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
+{
+}
+
+//----------------------------------------------------------------------
+SvxShapeText::SvxShapeText( SdrObject* pObject ) throw ()
+: SvxShape( pObject, aSvxMapProvider.GetMap(SVXMAP_TEXT), aSvxMapProvider.GetPropertySet(SVXMAP_TEXT, SdrObject::GetGlobalDrawObjectItemPool()) ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
+{
+ if( pObject && pObject->GetModel() )
+ SetEditSource( new SvxTextEditSource( pObject, 0, static_cast< uno::XWeak * >( this ) ) );
+}
+
+//----------------------------------------------------------------------
+SvxShapeText::SvxShapeText( SdrObject* pObject, const SfxItemPropertyMapEntry* pPropertyMap, const SvxItemPropertySet* pPropertySet ) throw ()
+: SvxShape( pObject, pPropertyMap, pPropertySet ), SvxUnoTextBase( ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() )
+{
+ if( pObject && pObject->GetModel() )
+ SetEditSource( new SvxTextEditSource( pObject, 0, static_cast< uno::XWeak * >( this ) ) );
+}
+
+//----------------------------------------------------------------------
+SvxShapeText::~SvxShapeText() throw ()
+{
+ // check if only this instance is registered at the ranges
+ DBG_ASSERT( (NULL == GetEditSource()) || (GetEditSource()->getRanges().size()==1),
+ "svx::SvxShapeText::~SvxShapeText(), text shape with living text ranges destroyed!");
+}
+
+void SvxShapeText::Create( SdrObject* pNewObj, SvxDrawPage* pNewPage )
+{
+ if( pNewObj && (NULL == GetEditSource()))
+ SetEditSource( new SvxTextEditSource( pNewObj, 0, static_cast< uno::XWeak* >(this) ) );
+
+ SvxShape::Create( pNewObj, pNewPage );
+}
+
+// XInterface
+//----------------------------------------------------------------------
+uno::Any SAL_CALL SvxShapeText::queryInterface( const uno::Type & rType )
+ throw( uno::RuntimeException )
+{
+ return SvxShape::queryInterface( rType );
+}
+
+//----------------------------------------------------------------------
+
+uno::Any SAL_CALL SvxShapeText::queryAggregation( const uno::Type & rType )
+ throw( uno::RuntimeException )
+{
+ uno::Any aAny( SvxShape::queryAggregation( rType ) );
+ if( aAny.hasValue() )
+ return aAny;
+
+ return SvxUnoTextBase::queryAggregation( rType );
+}
+
+//----------------------------------------------------------------------
+
+void SAL_CALL SvxShapeText::acquire() throw()
+{
+ SvxShape::acquire();
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeText::release() throw()
+{
+ SvxShape::release();
+}
+
+// XServiceInfo
+//----------------------------------------------------------------------
+OUString SAL_CALL SvxShapeText::getImplementationName() throw( uno::RuntimeException )
+{
+ static OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM("SvxShapeText") );
+ return aServiceName;
+}
+
+//----------------------------------------------------------------------
+uno::Sequence< OUString > SAL_CALL SvxShapeText::getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ return SvxShape::getSupportedServiceNames();
+}
+
+//----------------------------------------------------------------------
+sal_Bool SAL_CALL SvxShapeText::supportsService( const OUString& ServiceName ) throw ( uno::RuntimeException )
+{
+ return SvxShape::supportsService(ServiceName);
+}
+
+ // XTypeProvider
+//----------------------------------------------------------------------
+uno::Sequence< uno::Type > SAL_CALL SvxShapeText::getTypes()
+ throw( uno::RuntimeException )
+{
+ return SvxShape::getTypes();
+}
+
+sal_Int64 SAL_CALL SvxShapeText::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException) \
+{
+ const sal_Int64 nReturn = SvxShape::getSomething( rId );
+ if( nReturn )
+ return nReturn;
+
+ return SvxUnoTextBase::getSomething( rId );
+}
+
+//----------------------------------------------------------------------
+uno::Sequence< sal_Int8 > SAL_CALL SvxShapeText::getImplementationId()
+ throw( uno::RuntimeException )
+{
+ static ::cppu::OImplementationId* pID = NULL ;
+
+ if ( pID == NULL )
+ {
+ // Ready for multithreading; get global mutex for first call of this method only! see before
+ MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
+
+ // Control these pointer again ... it can be, that another instance will be faster then these!
+ if ( pID == NULL )
+ {
+ // Create a new static ID ...
+ static ::cppu::OImplementationId aID( sal_False ) ;
+ // ... and set his address to static pointer!
+ pID = &aID ;
+ }
+ }
+
+ return pID->getImplementationId() ;
+}
+
+//----------------------------------------------------------------------
+
+/** called from the XActionLockable interface methods on initial locking */
+void SvxShapeText::lock()
+{
+ SvxTextEditSource* pEditSource = (SvxTextEditSource*)GetEditSource();
+ if( pEditSource )
+ pEditSource->lock();
+}
+
+//----------------------------------------------------------------------
+
+/** called from the XActionLockable interface methods on final unlock */
+void SvxShapeText::unlock()
+{
+ SvxTextEditSource* pEditSource = (SvxTextEditSource*)GetEditSource();
+ if( pEditSource )
+ pEditSource->unlock();
+}
+
+// ::com::sun::star::text::XTextRange
+uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getStart() throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
+ if( pForwarder )
+ ::GetSelection( maSelection, pForwarder );
+ return SvxUnoTextBase::getStart();
+
+}
+
+uno::Reference< text::XTextRange > SAL_CALL SvxShapeText::getEnd() throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
+ if( pForwarder )
+ ::GetSelection( maSelection, pForwarder );
+ return SvxUnoTextBase::getEnd();
+}
+
+OUString SAL_CALL SvxShapeText::getString() throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
+ if( pForwarder )
+ ::GetSelection( maSelection, pForwarder );
+ return SvxUnoTextBase::getString();
+}
+
+
+void SAL_CALL SvxShapeText::setString( const OUString& aString ) throw(uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : NULL;
+ if( pForwarder )
+ ::GetSelection( maSelection, pForwarder );
+ SvxUnoTextBase::setString( aString );
+}
+
+// overide these for special property handling in subcasses. Return true if property is handled
+bool SvxShapeText::setPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, const ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ // HACK-fix #99090#
+ // since SdrTextObj::SetVerticalWriting exchanges
+ // SDRATTR_TEXT_AUTOGROWWIDTH and SDRATTR_TEXT_AUTOGROWHEIGHT,
+ // we have to set the textdirection here
+
+ if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
+ {
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() );
+ if( pTextObj )
+ {
+ com::sun::star::text::WritingMode eMode;
+ if( rValue >>= eMode )
+ {
+ pTextObj->SetVerticalWriting( eMode == com::sun::star::text::WritingMode_TB_RL );
+ }
+ }
+ return true;
+ }
+ return SvxShape::setPropertyValueImpl( rName, pProperty, rValue );
+}
+
+bool SvxShapeText::getPropertyValueImpl( const ::rtl::OUString& rName, const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::uno::Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+{
+ if( pProperty->nWID == SDRATTR_TEXTDIRECTION )
+ {
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() );
+ if( pTextObj && pTextObj->IsVerticalWriting() )
+ rValue <<= com::sun::star::text::WritingMode_TB_RL;
+ else
+ rValue <<= com::sun::star::text::WritingMode_LR_TB;
+ return true;
+ }
+
+ return SvxShape::getPropertyValueImpl( rName, pProperty, rValue );
+}
+
+bool SvxShapeText::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty, ::com::sun::star::beans::PropertyState& rState ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
+{
+ return SvxShape::getPropertyStateImpl( pProperty, rState );
+}
+
+bool SvxShapeText::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProperty ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException)
+{
+ return SvxShape::setPropertyToDefaultImpl( pProperty );
+}
+
+/***********************************************************************
+* class SvxShapeRect *
+***********************************************************************/
+DBG_NAME(SvxShapeRect)
+SvxShapeRect::SvxShapeRect( SdrObject* pObj ) throw()
+: SvxShapeText( pObj, aSvxMapProvider.GetMap(SVXMAP_SHAPE), aSvxMapProvider.GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
+{
+ DBG_CTOR(SvxShapeRect,NULL);
+}
+
+SvxShapeRect::~SvxShapeRect() throw()
+{
+ DBG_DTOR(SvxShapeRect,NULL);
+}
+
+uno::Any SAL_CALL SvxShapeRect::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
+{
+ return SvxShapeText::queryInterface( rType );
+}
+
+uno::Any SAL_CALL SvxShapeRect::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
+{
+ return SvxShapeText::queryAggregation( rType );
+}
+
+void SAL_CALL SvxShapeRect::acquire() throw()
+{
+ OWeakAggObject::acquire();
+}
+
+void SAL_CALL SvxShapeRect::release() throw()
+{
+ OWeakAggObject::release();
+}
+//----------------------------------------------------------------------
+// XServiceInfo
+//----------------------------------------------------------------------
+uno::Sequence< OUString > SvxShapeRect::getSupportedServiceNames(void) throw( uno::RuntimeException )
+{
+ return SvxShape::getSupportedServiceNames();
+}
+
+/** returns a StarOffice API wrapper for the given SdrObject */
+uno::Reference< drawing::XShape > GetXShapeForSdrObject( SdrObject* pObj ) throw ()
+{
+ uno::Reference< drawing::XShape > xShape( pObj->getUnoShape(), uno::UNO_QUERY );
+ return xShape;
+}
+
+/** returns the SdrObject from the given StarOffice API wrapper */
+SdrObject* GetSdrObjectFromXShape( uno::Reference< drawing::XShape > xShape ) throw()
+{
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+ return pShape ? pShape->GetSdrObject() : 0;
+}
+
+//----------------------------------------------------------------------
+
+SdrObject* SdrObject::getSdrObjectFromXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xInt )
+{
+ SvxShape* pSvxShape = SvxShape::getImplementation( xInt );
+ return pSvxShape ? pSvxShape->GetSdrObject() : 0;
+}
+
+uno::Any SvxItemPropertySet_getPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const SfxItemSet& rSet )
+{
+ if(!pMap || !pMap->nWID)
+ return uno::Any();
+
+ // Check is for items that store either metric values if thei are positiv or percentage if thei are negativ.
+ bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY );
+ return rPropSet.getPropertyValue( pMap, rSet, (pMap->nWID != SDRATTR_XMLATTRIBUTES), bDontConvertNegativeValues );
+}
+
+void SvxItemPropertySet_setPropertyValue( const SvxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry* pMap, const uno::Any& rVal, SfxItemSet& rSet )
+{
+ if(!pMap || !pMap->nWID)
+ return;
+
+ bool bDontConvertNegativeValues = ( pMap->nWID == XATTR_FILLBMP_SIZEX || pMap->nWID == XATTR_FILLBMP_SIZEY );
+ rPropSet.setPropertyValue( pMap, rVal, rSet, bDontConvertNegativeValues );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoshcol.cxx b/svx/source/unodraw/unoshcol.cxx
new file mode 100644
index 000000000000..14e32c0a098d
--- /dev/null
+++ b/svx/source/unodraw/unoshcol.cxx
@@ -0,0 +1,261 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/document/EventObject.hpp>
+
+#include "unoshcol.hxx"
+#include <svx/unoprov.hxx>
+#include <comphelper/serviceinfohelper.hxx>
+
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::drawing;
+
+/***********************************************************************
+* *
+***********************************************************************/
+SvxShapeCollection::SvxShapeCollection() throw()
+: maShapeContainer( maMutex ), mrBHelper( maMutex )
+{
+}
+
+//----------------------------------------------------------------------
+SvxShapeCollection::~SvxShapeCollection() throw()
+{
+}
+
+
+//----------------------------------------------------------------------
+Reference< uno::XInterface > SvxShapeCollection_NewInstance() throw()
+{
+ Reference< drawing::XShapes > xShapes( new SvxShapeCollection() );
+ Reference< uno::XInterface > xRef( xShapes, UNO_QUERY );
+ return xRef;
+}
+
+// XInterface
+void SvxShapeCollection::release() throw()
+{
+ uno::Reference< uno::XInterface > x( xDelegator );
+ if (! x.is())
+ {
+ if (osl_decrementInterlockedCount( &m_refCount ) == 0)
+ {
+ if (! mrBHelper.bDisposed)
+ {
+ uno::Reference< uno::XInterface > xHoldAlive( (uno::XWeak*)this );
+ // First dispose
+ try
+ {
+ dispose();
+ }
+ catch(::com::sun::star::uno::Exception&)
+ {
+ // release should not throw exceptions
+ }
+
+ // only the alive ref holds the object
+ OSL_ASSERT( m_refCount == 1 );
+ // destroy the object if xHoldAlive decrement the refcount to 0
+ return;
+ }
+ }
+ // restore the reference count
+ osl_incrementInterlockedCount( &m_refCount );
+ }
+ OWeakAggObject::release();
+}
+
+// XComponent
+void SvxShapeCollection::disposing() throw()
+{
+ maShapeContainer.clear();
+}
+
+// XComponent
+void SvxShapeCollection::dispose()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ // An frequently programming error is to release the last
+ // reference to this object in the disposing message.
+ // Make it rubust, hold a self Reference.
+ uno::Reference< lang::XComponent > xSelf( this );
+
+ // Guard dispose against multible threading
+ // Remark: It is an error to call dispose more than once
+ sal_Bool bDoDispose = sal_False;
+ {
+ osl::MutexGuard aGuard( mrBHelper.rMutex );
+ if( !mrBHelper.bDisposed && !mrBHelper.bInDispose )
+ {
+ // only one call go into this section
+ mrBHelper.bInDispose = sal_True;
+ bDoDispose = sal_True;
+ }
+ }
+
+ // Do not hold the mutex because we are broadcasting
+ if( bDoDispose )
+ {
+ // Create an event with this as sender
+ try
+ {
+ uno::Reference< uno::XInterface > xSource( uno::Reference< uno::XInterface >::query( (lang::XComponent *)this ) );
+ document::EventObject aEvt;
+ aEvt.Source = xSource;
+ // inform all listeners to release this object
+ // The listener container are automaticly cleared
+ mrBHelper.aLC.disposeAndClear( aEvt );
+ // notify subclasses to do their dispose
+ disposing();
+ }
+ catch(::com::sun::star::uno::Exception& e)
+ {
+ // catch exception and throw again but signal that
+ // the object was disposed. Dispose should be called
+ // only once.
+ mrBHelper.bDisposed = sal_True;
+ mrBHelper.bInDispose = sal_False;
+ throw e;
+ }
+
+ // the values bDispose and bInDisposing must set in this order.
+ // No multithread call overcome the "!rBHelper.bDisposed && !rBHelper.bInDispose" guard.
+ mrBHelper.bDisposed = sal_True;
+ mrBHelper.bInDispose = sal_False;
+ }
+ else
+ {
+ // in a multithreaded environment, it can't be avoided, that dispose is called twice.
+ // However this condition is traced, because it MAY indicate an error.
+ OSL_TRACE( "OComponentHelper::dispose() - dispose called twice" );
+ }
+}
+
+// XComponent
+void SAL_CALL SvxShapeCollection::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException)
+{
+ mrBHelper.addListener( ::getCppuType( &aListener ) , aListener );
+}
+
+// XComponent
+void SAL_CALL SvxShapeCollection::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException)
+{
+ mrBHelper.removeListener( ::getCppuType( &aListener ) , aListener );
+}
+
+// XShapes
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeCollection::add( const Reference< drawing::XShape >& xShape ) throw( uno::RuntimeException )
+{
+ maShapeContainer.addInterface( xShape );
+}
+
+//----------------------------------------------------------------------
+void SAL_CALL SvxShapeCollection::remove( const uno::Reference< drawing::XShape >& xShape ) throw( uno::RuntimeException )
+{
+ maShapeContainer.removeInterface( xShape );
+}
+
+//----------------------------------------------------------------------
+sal_Int32 SAL_CALL SvxShapeCollection::getCount() throw( uno::RuntimeException )
+{
+ return maShapeContainer.getLength();
+}
+
+//----------------------------------------------------------------------
+uno::Any SAL_CALL SvxShapeCollection::getByIndex( sal_Int32 Index )
+ throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ if( Index < 0 || Index >= getCount() )
+ throw lang::IndexOutOfBoundsException();
+
+ uno::Sequence< Reference< uno::XInterface> > xElements( maShapeContainer.getElements() );
+
+
+ return uno::makeAny( Reference< XShape>(static_cast< drawing::XShape* >( xElements.getArray()[Index].get())) );
+}
+
+// XElementAccess
+
+//----------------------------------------------------------------------
+uno::Type SAL_CALL SvxShapeCollection::getElementType() throw( uno::RuntimeException )
+{
+ return ::getCppuType(( const Reference< drawing::XShape >*)0);
+}
+
+//----------------------------------------------------------------------
+sal_Bool SAL_CALL SvxShapeCollection::hasElements() throw( uno::RuntimeException )
+{
+ return getCount() != 0;
+}
+
+//----------------------------------------------------------------------
+// XServiceInfo
+//----------------------------------------------------------------------
+::rtl::OUString SAL_CALL SvxShapeCollection::getImplementationName()
+ throw( uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+::rtl::OUString SvxShapeCollection::getImplementationName_Static()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.SvxShapeCollection") );
+}
+
+sal_Bool SAL_CALL SvxShapeCollection::supportsService( const ::rtl::OUString& ServiceName )
+ throw( uno::RuntimeException )
+{
+ return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL SvxShapeCollection::getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+uno::Sequence< ::rtl::OUString > SvxShapeCollection::getSupportedServiceNames_Static()
+{
+ uno::Sequence< ::rtl::OUString > aSeq(2);
+ aSeq.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.Shapes") );
+ aSeq.getArray()[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ShapeCollection") );
+ return aSeq;
+}
+
+Reference< XInterface > SAL_CALL SvxShapeCollection_createInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& )
+{
+ return *( new SvxShapeCollection() );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx
new file mode 100644
index 000000000000..ae97b5b6b45a
--- /dev/null
+++ b/svx/source/unodraw/unoshtxt.cxx
@@ -0,0 +1,1151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/uno/XInterface.hpp>
+#include <vcl/svapp.hxx>
+
+#include <svx/unoshtxt.hxx>
+#include <editeng/unoedhlp.hxx>
+#include <svl/lstner.hxx>
+#include <rtl/ref.hxx>
+#include <osl/mutex.hxx>
+#include <svl/hint.hxx>
+#include <svl/style.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdetc.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/unoforou.hxx>
+#include <editeng/unoviwou.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdpage.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editobj.hxx>
+
+#include <editeng/unotext.hxx>
+#include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
+#include <comphelper/processfactory.hxx>
+#include <osl/mutex.hxx>
+#include <sdrpaintwindow.hxx>
+
+using namespace ::osl;
+using namespace ::rtl;
+
+using ::com::sun::star::uno::XInterface;
+
+namespace css = ::com::sun::star;
+
+
+//------------------------------------------------------------------------
+// SvxTextEditSourceImpl
+//------------------------------------------------------------------------
+
+/** @descr
+ <p>This class essentially provides the text and view forwarders. If
+ no SdrView is given, this class handles the UNO objects, which are
+ currently not concerned with view issues. In this case,
+ GetViewForwarder() always returns NULL and the underlying
+ EditEngine of the SvxTextForwarder is a background one (i.e. not
+ the official DrawOutliner, but one created exclusively for this
+ object, with no relation to a view).
+ </p>
+
+ <p>If a SdrView is given at construction time, the caller is
+ responsible for destroying this object when the view becomes
+ invalid (the views cannot notify). If GetViewForwarder(sal_True)
+ is called, the underlying shape is put into edit mode, the view
+ forwarder returned encapsulates the OutlinerView and the next call
+ to GetTextForwarder() yields a forwarder encapsulating the actual
+ DrawOutliner. Thus, changes on that Outliner are immediately
+ reflected on the screen. If the object leaves edit mode, the old
+ behaviour is restored.</p>
+ */
+class SvxTextEditSourceImpl : public SfxListener, public SfxBroadcaster, public sdr::ObjectUser
+{
+private:
+ oslInterlockedCount maRefCount;
+
+ SdrObject* mpObject;
+ SdrText* mpText;
+ SdrView* mpView;
+ const Window* mpWindow;
+ SdrModel* mpModel;
+ SdrOutliner* mpOutliner;
+ SvxOutlinerForwarder* mpTextForwarder;
+ SvxDrawOutlinerViewForwarder* mpViewForwarder; // if non-NULL, use GetViewModeTextForwarder text forwarder
+ css::uno::Reference< css::linguistic2::XLinguServiceManager > m_xLinguServiceManager;
+ Point maTextOffset;
+ BOOL mbDataValid;
+ BOOL mbDestroyed;
+ BOOL mbIsLocked;
+ BOOL mbNeedsUpdate;
+ BOOL mbOldUndoMode;
+ BOOL mbForwarderIsEditMode; // have to reflect that, since ENDEDIT can happen more often
+ BOOL mbShapeIsEditMode; // #104157# only true, if HINT_BEGEDIT was received
+ BOOL mbNotificationsDisabled; // prevent EditEngine/Outliner notifications (e.g. when setting up forwarder)
+
+ XInterface* mpOwner;
+ SvxUnoTextRangeBaseList maTextRanges;
+
+ SvxTextForwarder* GetBackgroundTextForwarder();
+ SvxTextForwarder* GetEditModeTextForwarder();
+ SvxDrawOutlinerViewForwarder* CreateViewForwarder();
+
+ void SetupOutliner();
+ void UpdateOutliner();
+
+ sal_Bool HasView() const { return mpView ? sal_True : sal_False; }
+ sal_Bool IsEditMode() const
+ {
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
+ return mbShapeIsEditMode && pTextObj && pTextObj->IsTextEditActive() ? sal_True : sal_False;
+ }
+
+ void dispose();
+
+public:
+ SvxTextEditSourceImpl( SdrObject* pObject, SdrText* pText, XInterface* pOwner );
+ SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText, SdrView& rView, const Window& rWindow );
+ ~SvxTextEditSourceImpl();
+
+ void SAL_CALL acquire();
+ void SAL_CALL release();
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ SvxEditSource* Clone() const;
+ SvxTextForwarder* GetTextForwarder();
+ SvxEditViewForwarder* GetEditViewForwarder( sal_Bool );
+ void UpdateData();
+
+ void addRange( SvxUnoTextRangeBase* pNewRange );
+ void removeRange( SvxUnoTextRangeBase* pOldRange );
+ const SvxUnoTextRangeBaseList& getRanges() const;
+
+ SdrObject* GetSdrObject() const { return mpObject; }
+
+ void lock();
+ void unlock();
+
+ BOOL IsValid() const;
+
+ Rectangle GetVisArea();
+ Point LogicToPixel( const Point&, const MapMode& rMapMode );
+ Point PixelToLogic( const Point&, const MapMode& rMapMode );
+
+ DECL_LINK( NotifyHdl, EENotify* );
+
+ virtual void ObjectInDestruction(const SdrObject& rObject);
+
+ void ChangeModel( SdrModel* pNewModel );
+};
+
+//------------------------------------------------------------------------
+
+SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject* pObject, SdrText* pText, XInterface* pOwner )
+ : maRefCount ( 0 ),
+ mpObject ( pObject ),
+ mpText ( pText ),
+ mpView ( NULL ),
+ mpWindow ( NULL ),
+ mpModel ( pObject ? pObject->GetModel() : NULL ),
+ mpOutliner ( NULL ),
+ mpTextForwarder ( NULL ),
+ mpViewForwarder ( NULL ),
+ mbDataValid ( FALSE ),
+ mbDestroyed ( FALSE ),
+ mbIsLocked ( FALSE ),
+ mbNeedsUpdate ( FALSE ),
+ mbOldUndoMode ( FALSE ),
+ mbForwarderIsEditMode ( FALSE ),
+ mbShapeIsEditMode ( FALSE ),
+ mbNotificationsDisabled ( FALSE ),
+ mpOwner( pOwner )
+{
+ DBG_ASSERT( mpObject, "invalid pObject!" );
+
+ if( !mpText )
+ {
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject );
+ if( pTextObj )
+ mpText = pTextObj->getText( 0 );
+ }
+
+ if( mpModel )
+ StartListening( *mpModel );
+
+ if( mpObject )
+ mpObject->AddObjectUser( *this );
+}
+
+//------------------------------------------------------------------------
+
+SvxTextEditSourceImpl::SvxTextEditSourceImpl( SdrObject& rObject, SdrText* pText, SdrView& rView, const Window& rWindow )
+ : maRefCount ( 0 ),
+ mpObject ( &rObject ),
+ mpText ( pText ),
+ mpView ( &rView ),
+ mpWindow ( &rWindow ),
+ mpModel ( rObject.GetModel() ),
+ mpOutliner ( NULL ),
+ mpTextForwarder ( NULL ),
+ mpViewForwarder ( NULL ),
+ mbDataValid ( FALSE ),
+ mbDestroyed ( FALSE ),
+ mbIsLocked ( FALSE ),
+ mbNeedsUpdate ( FALSE ),
+ mbOldUndoMode ( FALSE ),
+ mbForwarderIsEditMode ( FALSE ),
+ mbShapeIsEditMode ( TRUE ),
+ mbNotificationsDisabled ( FALSE ),
+ mpOwner(0)
+{
+ if( !mpText )
+ {
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject );
+ if( pTextObj )
+ mpText = pTextObj->getText( 0 );
+ }
+
+ if( mpModel )
+ StartListening( *mpModel );
+ if( mpView )
+ StartListening( *mpView );
+ if( mpObject )
+ mpObject->AddObjectUser( *this );
+
+ // #104157# Init edit mode state from shape info (IsTextEditActive())
+ mbShapeIsEditMode = IsEditMode();
+}
+
+//------------------------------------------------------------------------
+
+SvxTextEditSourceImpl::~SvxTextEditSourceImpl()
+{
+ DBG_ASSERT( mbIsLocked == sal_False, "text edit source was not unlocked before dispose!" );
+ if( mpObject )
+ mpObject->RemoveObjectUser( *this );
+
+ dispose();
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEditSourceImpl::addRange( SvxUnoTextRangeBase* pNewRange )
+{
+ if( pNewRange )
+ if( std::find( maTextRanges.begin(), maTextRanges.end(), pNewRange ) == maTextRanges.end() )
+ maTextRanges.push_back( pNewRange );
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEditSourceImpl::removeRange( SvxUnoTextRangeBase* pOldRange )
+{
+ if( pOldRange )
+ maTextRanges.remove( pOldRange );
+}
+
+//------------------------------------------------------------------------
+
+const SvxUnoTextRangeBaseList& SvxTextEditSourceImpl::getRanges() const
+{
+ return maTextRanges;
+}
+
+//------------------------------------------------------------------------
+
+void SAL_CALL SvxTextEditSourceImpl::acquire()
+{
+ osl_incrementInterlockedCount( &maRefCount );
+}
+
+//------------------------------------------------------------------------
+
+void SAL_CALL SvxTextEditSourceImpl::release()
+{
+ if( ! osl_decrementInterlockedCount( &maRefCount ) )
+ delete this;
+}
+
+void SvxTextEditSourceImpl::ChangeModel( SdrModel* pNewModel )
+{
+ if( mpModel != pNewModel )
+ {
+ if( mpModel )
+ EndListening( *mpModel );
+
+ if( mpOutliner )
+ {
+ if( mpModel )
+ mpModel->disposeOutliner( mpOutliner );
+ else
+ delete mpOutliner;
+ mpOutliner = 0;
+ }
+
+ if( mpView )
+ {
+ EndListening( *mpView );
+ mpView = 0;
+ }
+
+ mpWindow = 0;
+ m_xLinguServiceManager.clear();
+ mpOwner = 0;
+
+ mpModel = pNewModel;
+
+ if( mpTextForwarder )
+ {
+ delete mpTextForwarder;
+ mpTextForwarder = 0;
+ }
+
+ if( mpViewForwarder )
+ {
+ delete mpViewForwarder;
+ mpViewForwarder = 0;
+ }
+
+ if( mpModel )
+ StartListening( *mpModel );
+ }
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEditSourceImpl::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // #i105988 keep reference to this object
+ rtl::Reference< SvxTextEditSourceImpl > xThis( this );
+
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+ const SvxViewHint* pViewHint = PTR_CAST( SvxViewHint, &rHint );
+
+ if( pViewHint )
+ {
+ switch( pViewHint->GetHintType() )
+ {
+ case SvxViewHint::SVX_HINT_VIEWCHANGED:
+ Broadcast( *pViewHint );
+ break;
+ }
+ }
+ else if( pSdrHint )
+ {
+ switch( pSdrHint->GetKind() )
+ {
+ case HINT_OBJCHG:
+ {
+ mbDataValid = FALSE; // Text muss neu geholt werden
+
+ if( HasView() )
+ {
+ // #104157# Update maTextOffset, object has changed
+ // #105196#, #105203#: Cannot call that // here,
+ // since TakeTextRect() (called from there) //
+ // changes outliner content.
+ // UpdateOutliner();
+
+ // #101029# Broadcast object changes, as they might change visible attributes
+ SvxViewHint aHint(SvxViewHint::SVX_HINT_VIEWCHANGED);
+ Broadcast( aHint );
+ }
+ break;
+ }
+
+ case HINT_BEGEDIT:
+ if( mpObject == pSdrHint->GetObject() )
+ {
+ // invalidate old forwarder
+ if( !mbForwarderIsEditMode )
+ {
+ delete mpTextForwarder;
+ mpTextForwarder = NULL;
+ }
+
+ // register as listener - need to broadcast state change messages
+ if( mpView && mpView->GetTextEditOutliner() )
+ mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) );
+
+ // #104157# Only now we're really in edit mode
+ mbShapeIsEditMode = TRUE;
+
+ Broadcast( *pSdrHint );
+ }
+ break;
+
+ case HINT_ENDEDIT:
+ if( mpObject == pSdrHint->GetObject() )
+ {
+ Broadcast( *pSdrHint );
+
+ // #104157# We're no longer in edit mode
+ mbShapeIsEditMode = FALSE;
+
+ // remove as listener - outliner might outlive ourselves
+ if( mpView && mpView->GetTextEditOutliner() )
+ mpView->GetTextEditOutliner()->SetNotifyHdl( Link() );
+
+ // destroy view forwarder, OutlinerView no longer
+ // valid (no need for UpdateData(), it's been
+ // synched on SdrEndTextEdit)
+ delete mpViewForwarder;
+ mpViewForwarder = NULL;
+
+ // #100424# Invalidate text forwarder, we might
+ // not be called again before entering edit mode a
+ // second time! Then, the old outliner might be
+ // invalid.
+ if( mbForwarderIsEditMode )
+ {
+ mbForwarderIsEditMode = sal_False;
+ delete mpTextForwarder;
+ mpTextForwarder = NULL;
+ }
+ }
+ break;
+
+ case HINT_MODELCLEARED:
+ dispose();
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+/* this is a callback from the attached SdrObject when it is actually deleted */
+void SvxTextEditSourceImpl::ObjectInDestruction(const SdrObject&)
+{
+ mpObject = 0;
+ dispose();
+ Broadcast( SfxSimpleHint( SFX_HINT_DYING ) );
+}
+
+/* unregister at all objects and set all references to 0 */
+void SvxTextEditSourceImpl::dispose()
+{
+ if( mpTextForwarder )
+ {
+ delete mpTextForwarder;
+ mpTextForwarder = 0;
+ }
+
+ if( mpViewForwarder )
+ {
+ delete mpViewForwarder;
+ mpViewForwarder = 0;
+ }
+
+ if( mpOutliner )
+ {
+ if( mpModel )
+ {
+ mpModel->disposeOutliner( mpOutliner );
+ }
+ else
+ {
+ delete mpOutliner;
+ }
+ mpOutliner = 0;
+ }
+
+ if( mpModel )
+ {
+ EndListening( *mpModel );
+ mpModel = 0;
+ }
+
+ if( mpView )
+ {
+ EndListening( *mpView );
+ mpView = 0;
+ }
+
+ if( mpObject )
+ {
+ mpObject->RemoveObjectUser( *this );
+ mpObject = 0;
+ }
+ mpWindow = 0;
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEditSourceImpl::SetupOutliner()
+{
+ // #101029#
+ // only for UAA edit source: setup outliner equivalently as in
+ // SdrTextObj::Paint(), such that formatting equals screen
+ // layout
+ if( mpObject && mpOutliner )
+ {
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
+ Rectangle aPaintRect;
+ if( pTextObj )
+ {
+ Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() );
+ pTextObj->SetupOutlinerFormatting( *mpOutliner, aPaintRect );
+
+ // #101029# calc text offset from shape anchor
+ maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft();
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEditSourceImpl::UpdateOutliner()
+{
+ // #104157#
+ // only for UAA edit source: update outliner equivalently as in
+ // SdrTextObj::Paint(), such that formatting equals screen
+ // layout
+ if( mpObject && mpOutliner )
+ {
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
+ Rectangle aPaintRect;
+ if( pTextObj )
+ {
+ Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() );
+ pTextObj->UpdateOutlinerFormatting( *mpOutliner, aPaintRect );
+
+ // #101029# calc text offset from shape anchor
+ maTextOffset = aPaintRect.TopLeft() - aBoundRect.TopLeft();
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+
+
+SvxTextForwarder* SvxTextEditSourceImpl::GetBackgroundTextForwarder()
+{
+ sal_Bool bCreated = sal_False;
+
+ // #99840#: prevent EE/Outliner notifications during setup
+ mbNotificationsDisabled = sal_True;
+
+ if (!mpTextForwarder)
+ {
+ if( mpOutliner == NULL )
+ {
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
+ USHORT nOutlMode = OUTLINERMODE_TEXTOBJECT;
+ if( pTextObj && pTextObj->IsTextFrame() && pTextObj->GetTextKind() == OBJ_OUTLINETEXT )
+ nOutlMode = OUTLINERMODE_OUTLINEOBJECT;
+
+ mpOutliner = mpModel->createOutliner( nOutlMode );
+
+ // #109151# Do the setup after outliner creation, would be useless otherwise
+ if( HasView() )
+ {
+ // #101029#, #104157# Setup outliner _before_ filling it
+ SetupOutliner();
+ }
+
+ mpOutliner->SetTextObjNoInit( pTextObj );
+/*
+ mpOutliner = SdrMakeOutliner( nOutlMode, pModel );
+ Outliner& aDrawOutliner = pModel->GetDrawOutliner();
+ mpOutliner->SetCalcFieldValueHdl( aDrawOutliner.GetCalcFieldValueHdl() );
+*/
+ if( mbIsLocked )
+ {
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_False );
+ mbOldUndoMode = ((EditEngine*)&(mpOutliner->GetEditEngine()))->IsUndoEnabled();
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( sal_False );
+ }
+
+// -
+ if ( !m_xLinguServiceManager.is() )
+ {
+ css::uno::Reference< css::lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ m_xLinguServiceManager = css::uno::Reference< css::linguistic2::XLinguServiceManager >(
+ xMgr->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.linguistic2.LinguServiceManager" ))), css::uno::UNO_QUERY );
+ }
+
+ if ( m_xLinguServiceManager.is() )
+ {
+ css::uno::Reference< css::linguistic2::XHyphenator > xHyphenator( m_xLinguServiceManager->getHyphenator(), css::uno::UNO_QUERY );
+ if( xHyphenator.is() )
+ mpOutliner->SetHyphenator( xHyphenator );
+ }
+// -
+ }
+
+
+ mpTextForwarder = new SvxOutlinerForwarder( *mpOutliner, (mpObject->GetObjInventor() == SdrInventor) && (mpObject->GetObjIdentifier() == OBJ_OUTLINETEXT) );
+ // delay listener subscription and UAA initialization until Outliner is fully setup
+ bCreated = sal_True;
+
+ mbForwarderIsEditMode = sal_False;
+ }
+
+ if( mpObject && mpText && !mbDataValid && mpObject->IsInserted() && mpObject->GetPage() )
+ {
+ mpTextForwarder->flushCache();
+
+ OutlinerParaObject* pOutlinerParaObject = NULL;
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
+ if( pTextObj && pTextObj->getActiveText() == mpText )
+ pOutlinerParaObject = pTextObj->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
+ bool bOwnParaObj(false);
+
+ if( pOutlinerParaObject )
+ bOwnParaObj = true; // text edit active
+ else
+ pOutlinerParaObject = mpText->GetOutlinerParaObject();
+
+ if( pOutlinerParaObject && ( bOwnParaObj || !mpObject->IsEmptyPresObj() || mpObject->GetPage()->IsMasterPage() ) )
+ {
+ mpOutliner->SetText( *pOutlinerParaObject );
+
+ // #91254# put text to object and set EmptyPresObj to FALSE
+ if( mpText && bOwnParaObj && pOutlinerParaObject && mpObject->IsEmptyPresObj() && pTextObj->IsRealyEdited() )
+ {
+ mpObject->SetEmptyPresObj( FALSE );
+ static_cast< SdrTextObj* >( mpObject)->NbcSetOutlinerParaObjectForText( pOutlinerParaObject, mpText );
+
+ // #i103982# Here, due to mpObject->NbcSetOutlinerParaObjectForText, we LOSE ownership of the
+ // OPO, so do NOT delete it when leaving this method (!)
+ bOwnParaObj = false;
+ }
+ }
+ else
+ {
+ sal_Bool bVertical = pOutlinerParaObject ? pOutlinerParaObject->IsVertical() : sal_False;
+
+ // set objects style sheet on empty outliner
+ SfxStyleSheetPool* pPool = (SfxStyleSheetPool*)mpObject->GetModel()->GetStyleSheetPool();
+ if( pPool )
+ mpOutliner->SetStyleSheetPool( pPool );
+
+ SfxStyleSheet* pStyleSheet = mpObject->GetPage()->GetTextStyleSheetForObject( mpObject );
+ if( pStyleSheet )
+ mpOutliner->SetStyleSheet( 0, pStyleSheet );
+
+ if( bVertical )
+ mpOutliner->SetVertical( sal_True );
+ }
+
+ // evtually we have to set the border attributes
+ if (mpOutliner->GetParagraphCount()==1)
+ {
+ // if we only have one paragraph we check if it is empty
+ XubString aStr( mpOutliner->GetText( mpOutliner->GetParagraph( 0 ) ) );
+
+ if(!aStr.Len())
+ {
+ // its empty, so we have to force the outliner to initialise itself
+ mpOutliner->SetText( String(), mpOutliner->GetParagraph( 0 ) );
+
+ if(mpObject->GetStyleSheet())
+ mpOutliner->SetStyleSheet( 0, mpObject->GetStyleSheet());
+ }
+ }
+
+ mbDataValid = TRUE;
+
+ if( bOwnParaObj )
+ delete pOutlinerParaObject;
+ }
+
+ if( bCreated && mpOutliner && HasView() )
+ {
+ // register as listener - need to broadcast state change messages
+ // registration delayed until outliner is completely set up
+ mpOutliner->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) );
+ }
+
+ // #99840#: prevent EE/Outliner notifications during setup
+ mbNotificationsDisabled = sal_False;
+
+ return mpTextForwarder;
+}
+
+//------------------------------------------------------------------------
+
+SvxTextForwarder* SvxTextEditSourceImpl::GetEditModeTextForwarder()
+{
+ if( !mpTextForwarder && HasView() )
+ {
+ SdrOutliner* pEditOutliner = mpView->GetTextEditOutliner();
+
+ if( pEditOutliner )
+ {
+ mpTextForwarder = new SvxOutlinerForwarder( *pEditOutliner, (mpObject->GetObjInventor() == SdrInventor) && (mpObject->GetObjIdentifier() == OBJ_OUTLINETEXT) );
+ mbForwarderIsEditMode = sal_True;
+ }
+ }
+
+ return mpTextForwarder;
+}
+
+//------------------------------------------------------------------------
+
+SvxTextForwarder* SvxTextEditSourceImpl::GetTextForwarder()
+{
+ if( mbDestroyed || mpObject == NULL )
+ return NULL;
+
+ if( mpModel == NULL )
+ mpModel = mpObject->GetModel();
+
+ if( mpModel == NULL )
+ return NULL;
+
+ // distinguish the cases
+ // a) connected to view, maybe edit mode is active, can work directly on the EditOutliner
+ // b) background Outliner, reflect changes into ParaOutlinerObject (this is exactly the old UNO code)
+ if( HasView() )
+ {
+ if( IsEditMode() != mbForwarderIsEditMode )
+ {
+ // forwarder mismatch - create new
+ delete mpTextForwarder;
+ mpTextForwarder = NULL;
+ }
+
+ if( IsEditMode() )
+ return GetEditModeTextForwarder();
+ else
+ return GetBackgroundTextForwarder();
+ }
+ else
+ return GetBackgroundTextForwarder();
+}
+
+//------------------------------------------------------------------------
+
+SvxDrawOutlinerViewForwarder* SvxTextEditSourceImpl::CreateViewForwarder()
+{
+ if( mpView->GetTextEditOutlinerView() && mpObject )
+ {
+ // register as listener - need to broadcast state change messages
+ mpView->GetTextEditOutliner()->SetNotifyHdl( LINK(this, SvxTextEditSourceImpl, NotifyHdl) );
+
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
+ if( pTextObj )
+ {
+ Rectangle aBoundRect( pTextObj->GetCurrentBoundRect() );
+ OutlinerView& rOutlView = *mpView->GetTextEditOutlinerView();
+
+ return new SvxDrawOutlinerViewForwarder( rOutlView, aBoundRect.TopLeft() );
+ }
+ }
+
+ return NULL;
+}
+
+SvxEditViewForwarder* SvxTextEditSourceImpl::GetEditViewForwarder( sal_Bool bCreate )
+{
+ if( mbDestroyed || mpObject == NULL )
+ return NULL;
+
+ if( mpModel == NULL )
+ mpModel = mpObject->GetModel();
+
+ if( mpModel == NULL )
+ return NULL;
+
+ // shall we delete?
+ if( mpViewForwarder )
+ {
+ if( !IsEditMode() )
+ {
+ // destroy all forwarders (no need for UpdateData(),
+ // it's been synched on SdrEndTextEdit)
+ delete mpViewForwarder;
+ mpViewForwarder = NULL;
+ }
+ }
+ // which to create? Directly in edit mode, create new, or none?
+ else if( mpView )
+ {
+ if( IsEditMode() )
+ {
+ // create new view forwarder
+ mpViewForwarder = CreateViewForwarder();
+ }
+ else if( bCreate )
+ {
+ // dispose old text forwarder
+ UpdateData();
+
+ delete mpTextForwarder;
+ mpTextForwarder = NULL;
+
+ // enter edit mode
+ mpView->SdrEndTextEdit();
+
+ if(mpView->SdrBeginTextEdit(mpObject, 0L, 0L, sal_False, (SdrOutliner*)0L, 0L, sal_False, sal_False))
+ {
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
+ if( pTextObj->IsTextEditActive() )
+ {
+ // create new view forwarder
+ mpViewForwarder = CreateViewForwarder();
+ }
+ else
+ {
+ // failure. Somehow, SdrBeginTextEdit did not set
+ // our SdrTextObj into edit mode
+ mpView->SdrEndTextEdit();
+ }
+ }
+ }
+ }
+
+ return mpViewForwarder;
+}
+
+//------------------------------------------------------------------------
+
+void SvxTextEditSourceImpl::UpdateData()
+{
+ // if we have a view and in edit mode, we're working with the
+ // DrawOutliner. Thus, all changes made on the text forwarder are
+ // reflected on the view and committed to the model on
+ // SdrEndTextEdit(). Thus, no need for explicit updates here.
+ if( !HasView() || !IsEditMode() )
+ {
+ if( mbIsLocked )
+ {
+ mbNeedsUpdate = sal_True;
+ }
+ else
+ {
+ if( mpOutliner && mpObject && mpText && !mbDestroyed )
+ {
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObject );
+ if( pTextObj )
+ {
+ if( mpOutliner->GetParagraphCount() != 1 || mpOutliner->GetEditEngine().GetTextLen( 0 ) )
+ {
+ if( mpOutliner->GetParagraphCount() > 1 )
+ {
+ if( pTextObj && pTextObj->IsTextFrame() && pTextObj->GetTextKind() == OBJ_TITLETEXT )
+ {
+ while( mpOutliner->GetParagraphCount() > 1 )
+ {
+ ESelection aSel( 0,mpOutliner->GetEditEngine().GetTextLen( 0 ), 1,0 );
+ mpOutliner->QuickInsertLineBreak( aSel );
+ }
+ }
+ }
+
+ pTextObj->NbcSetOutlinerParaObjectForText( mpOutliner->CreateParaObject(), mpText );
+ }
+ else
+ {
+ pTextObj->NbcSetOutlinerParaObjectForText( NULL,mpText );
+ }
+ }
+
+ if( mpObject->IsEmptyPresObj() )
+ mpObject->SetEmptyPresObj(sal_False);
+ }
+ }
+ }
+}
+
+void SvxTextEditSourceImpl::lock()
+{
+ mbIsLocked = sal_True;
+ if( mpOutliner )
+ {
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_False );
+ mbOldUndoMode = ((EditEngine*)&(mpOutliner->GetEditEngine()))->IsUndoEnabled();
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( sal_False );
+ }
+}
+
+void SvxTextEditSourceImpl::unlock()
+{
+ mbIsLocked = sal_False;
+
+ if( mbNeedsUpdate )
+ {
+ UpdateData();
+ mbNeedsUpdate = sal_False;
+ }
+
+ if( mpOutliner )
+ {
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->SetUpdateMode( sal_True );
+ ((EditEngine*)&(mpOutliner->GetEditEngine()))->EnableUndo( mbOldUndoMode );
+ }
+}
+
+BOOL SvxTextEditSourceImpl::IsValid() const
+{
+ return mpView && mpWindow ? TRUE : FALSE;
+}
+
+Rectangle SvxTextEditSourceImpl::GetVisArea()
+{
+ if( IsValid() )
+ {
+ SdrPaintWindow* pPaintWindow = mpView->FindPaintWindow(*mpWindow);
+ Rectangle aVisArea;
+
+ if(pPaintWindow)
+ {
+ aVisArea = pPaintWindow->GetVisibleArea();
+ }
+
+ // offset vis area by edit engine left-top position
+ SdrTextObj* pTextObj = PTR_CAST( SdrTextObj, mpObject );
+ if( pTextObj )
+ {
+ Rectangle aAnchorRect;
+ pTextObj->TakeTextAnchorRect( aAnchorRect );
+ aVisArea.Move( -aAnchorRect.Left(), -aAnchorRect.Top() );
+
+ MapMode aMapMode(mpWindow->GetMapMode());
+ aMapMode.SetOrigin(Point());
+ return mpWindow->LogicToPixel( aVisArea, aMapMode );
+ }
+ }
+
+ return Rectangle();
+}
+
+Point SvxTextEditSourceImpl::LogicToPixel( const Point& rPoint, const MapMode& rMapMode )
+{
+ // #101029#: The responsibilities of ViewForwarder happen to be
+ // somewhat mixed in this case. On the one hand, we need the
+ // different interface queries on the SvxEditSource interface,
+ // since we need both VisAreas. On the other hand, if an
+ // EditViewForwarder exists, maTextOffset does not remain static,
+ // but may change with every key press.
+ if( IsEditMode() )
+ {
+ SvxEditViewForwarder* pForwarder = GetEditViewForwarder(sal_False);
+
+ if( pForwarder )
+ return pForwarder->LogicToPixel( rPoint, rMapMode );
+ }
+ else if( IsValid() && mpModel )
+ {
+ // #101029#
+ Point aPoint1( rPoint );
+ aPoint1.X() += maTextOffset.X();
+ aPoint1.Y() += maTextOffset.Y();
+
+ Point aPoint2( OutputDevice::LogicToLogic( aPoint1, rMapMode,
+ MapMode(mpModel->GetScaleUnit()) ) );
+ MapMode aMapMode(mpWindow->GetMapMode());
+ aMapMode.SetOrigin(Point());
+ return mpWindow->LogicToPixel( aPoint2, aMapMode );
+ }
+
+ return Point();
+}
+
+Point SvxTextEditSourceImpl::PixelToLogic( const Point& rPoint, const MapMode& rMapMode )
+{
+ // #101029#: The responsibilities of ViewForwarder happen to be
+ // somewhat mixed in this case. On the one hand, we need the
+ // different interface queries on the SvxEditSource interface,
+ // since we need both VisAreas. On the other hand, if an
+ // EditViewForwarder exists, maTextOffset does not remain static,
+ // but may change with every key press.
+ if( IsEditMode() )
+ {
+ SvxEditViewForwarder* pForwarder = GetEditViewForwarder(sal_False);
+
+ if( pForwarder )
+ return pForwarder->PixelToLogic( rPoint, rMapMode );
+ }
+ else if( IsValid() && mpModel )
+ {
+ MapMode aMapMode(mpWindow->GetMapMode());
+ aMapMode.SetOrigin(Point());
+ Point aPoint1( mpWindow->PixelToLogic( rPoint, aMapMode ) );
+ Point aPoint2( OutputDevice::LogicToLogic( aPoint1,
+ MapMode(mpModel->GetScaleUnit()),
+ rMapMode ) );
+ // #101029#
+ aPoint2.X() -= maTextOffset.X();
+ aPoint2.Y() -= maTextOffset.Y();
+
+ return aPoint2;
+ }
+
+ return Point();
+}
+
+IMPL_LINK(SvxTextEditSourceImpl, NotifyHdl, EENotify*, aNotify)
+{
+ if( aNotify && !mbNotificationsDisabled )
+ {
+ ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( aNotify) );
+
+ if( aHint.get() )
+ Broadcast( *aHint.get() );
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+// --------------------------------------------------------------------
+// SvxTextEditSource
+// --------------------------------------------------------------------
+
+SvxTextEditSource::SvxTextEditSource( SdrObject* pObject, SdrText* pText, XInterface* pOwner )
+{
+ mpImpl = new SvxTextEditSourceImpl( pObject, pText, pOwner );
+ mpImpl->acquire();
+}
+
+// --------------------------------------------------------------------
+SvxTextEditSource::SvxTextEditSource( SdrObject& rObj, SdrText* pText, SdrView& rView, const Window& rWindow )
+{
+ mpImpl = new SvxTextEditSourceImpl( rObj, pText, rView, rWindow );
+ mpImpl->acquire();
+}
+
+// --------------------------------------------------------------------
+
+SvxTextEditSource::SvxTextEditSource( SvxTextEditSourceImpl* pImpl )
+{
+ mpImpl = pImpl;
+ mpImpl->acquire();
+}
+
+//------------------------------------------------------------------------
+SvxTextEditSource::~SvxTextEditSource()
+{
+ ::SolarMutexGuard aGuard;
+
+ mpImpl->release();
+}
+
+//------------------------------------------------------------------------
+SvxEditSource* SvxTextEditSource::Clone() const
+{
+ return new SvxTextEditSource( mpImpl );
+}
+
+//------------------------------------------------------------------------
+SvxTextForwarder* SvxTextEditSource::GetTextForwarder()
+{
+ return mpImpl->GetTextForwarder();
+}
+
+//------------------------------------------------------------------------
+SvxEditViewForwarder* SvxTextEditSource::GetEditViewForwarder( sal_Bool bCreate )
+{
+ return mpImpl->GetEditViewForwarder( bCreate );
+}
+
+//------------------------------------------------------------------------
+SvxViewForwarder* SvxTextEditSource::GetViewForwarder()
+{
+ return this;
+}
+
+//------------------------------------------------------------------------
+void SvxTextEditSource::UpdateData()
+{
+ mpImpl->UpdateData();
+}
+
+SfxBroadcaster& SvxTextEditSource::GetBroadcaster() const
+{
+ return *mpImpl;
+}
+
+SdrObject* SvxTextEditSource::GetSdrObject() const
+{
+ return mpImpl->GetSdrObject();
+}
+
+void SvxTextEditSource::lock()
+{
+ mpImpl->lock();
+}
+
+void SvxTextEditSource::unlock()
+{
+ mpImpl->unlock();
+}
+
+BOOL SvxTextEditSource::IsValid() const
+{
+ return mpImpl->IsValid();
+}
+
+Rectangle SvxTextEditSource::GetVisArea() const
+{
+ return mpImpl->GetVisArea();
+}
+
+Point SvxTextEditSource::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ return mpImpl->LogicToPixel( rPoint, rMapMode );
+}
+
+Point SvxTextEditSource::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ return mpImpl->PixelToLogic( rPoint, rMapMode );
+}
+
+void SvxTextEditSource::addRange( SvxUnoTextRangeBase* pNewRange )
+{
+ mpImpl->addRange( pNewRange );
+}
+
+void SvxTextEditSource::removeRange( SvxUnoTextRangeBase* pOldRange )
+{
+ mpImpl->removeRange( pOldRange );
+}
+
+const SvxUnoTextRangeBaseList& SvxTextEditSource::getRanges() const
+{
+ return mpImpl->getRanges();
+}
+
+void SvxTextEditSource::ChangeModel( SdrModel* pNewModel )
+{
+ mpImpl->ChangeModel( pNewModel );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unottabl.cxx b/svx/source/unodraw/unottabl.cxx
new file mode 100644
index 000000000000..e20263cf92aa
--- /dev/null
+++ b/svx/source/unodraw/unottabl.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/awt/Gradient.hpp>
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
+#include <svx/xgrad.hxx>
+#include <svx/xflftrit.hxx>
+
+#include <svx/svdmodel.hxx>
+#include <svx/xflhtit.hxx>
+#include "unofill.hxx"
+#include <svx/unomid.hxx>
+#include "UnoNameItemTable.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+using namespace ::cppu;
+
+class SvxUnoTransGradientTable : public SvxUnoNameItemTable
+{
+public:
+ SvxUnoTransGradientTable( SdrModel* pModel ) throw();
+ virtual ~SvxUnoTransGradientTable() throw();
+
+ virtual NameOrIndex* createItem() const throw();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName( ) throw( uno::RuntimeException );
+ virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw( uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw( uno::RuntimeException);
+};
+
+SvxUnoTransGradientTable::SvxUnoTransGradientTable( SdrModel* pModel ) throw()
+: SvxUnoNameItemTable( pModel, XATTR_FILLFLOATTRANSPARENCE, MID_FILLGRADIENT )
+{
+}
+
+SvxUnoTransGradientTable::~SvxUnoTransGradientTable() throw()
+{
+}
+
+OUString SAL_CALL SvxUnoTransGradientTable::getImplementationName() throw( uno::RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoTransGradientTable") );
+}
+
+uno::Sequence< OUString > SAL_CALL SvxUnoTransGradientTable::getSupportedServiceNames( )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable" ));
+ return aSNS;
+}
+
+NameOrIndex* SvxUnoTransGradientTable::createItem() const throw()
+{
+ XFillFloatTransparenceItem* pNewItem = new XFillFloatTransparenceItem();
+ pNewItem->SetEnabled( TRUE );
+ return pNewItem;
+}
+
+// XElementAccess
+uno::Type SAL_CALL SvxUnoTransGradientTable::getElementType( )
+ throw( uno::RuntimeException )
+{
+ return ::getCppuType((const struct awt::Gradient*)0);
+}
+
+/**
+ * Create a hatchtable
+ */
+uno::Reference< uno::XInterface > SAL_CALL SvxUnoTransGradientTable_createInstance( SdrModel* pModel )
+{
+ return *new SvxUnoTransGradientTable(pModel);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unogallery/makefile.mk b/svx/source/unogallery/makefile.mk
new file mode 100755
index 000000000000..113bd70db0ee
--- /dev/null
+++ b/svx/source/unogallery/makefile.mk
@@ -0,0 +1,48 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+TARGET=unogallery
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/unogalthemeprovider.obj \
+ $(SLO)$/unogaltheme.obj \
+ $(SLO)$/unogalitem.obj
+
+# --- Target -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/svx/source/unogallery/unogalitem.cxx b/svx/source/unogallery/unogalitem.cxx
new file mode 100644
index 000000000000..015c3c1cf4c8
--- /dev/null
+++ b/svx/source/unogallery/unogalitem.cxx
@@ -0,0 +1,484 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "unogalitem.hxx"
+#include "unogaltheme.hxx"
+#include "galtheme.hxx"
+#include "svx/galmisc.hxx"
+#include <svx/fmmodel.hxx>
+#include <rtl/uuid.h>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/graph.hxx>
+#include <svl/itemprop.hxx>
+#include <svl/itempool.hxx>
+#include "galobj.hxx"
+
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/gallery/GalleryItemType.hpp>
+
+#define UNOGALLERY_GALLERYITEMTYPE 1
+#define UNOGALLERY_URL 2
+#define UNOGALLERY_TITLE 3
+#define UNOGALLERY_THUMBNAIL 4
+#define UNOGALLERY_GRAPHIC 5
+#define UNOGALLERY_DRAWING 6
+
+using namespace ::com::sun::star;
+
+namespace unogallery {
+
+// -----------------
+// - GalleryItem -
+// -----------------
+
+GalleryItem::GalleryItem( ::unogallery::GalleryTheme& rTheme, const GalleryObject& rObject ) :
+ ::comphelper::PropertySetHelper( createPropertySetInfo() ),
+ mpTheme( &rTheme ),
+ mpGalleryObject( &rObject )
+{
+ mpTheme->implRegisterGalleryItem( *this );
+}
+
+// ------------------------------------------------------------------------------
+
+GalleryItem::~GalleryItem()
+ throw()
+{
+ if( mpTheme )
+ mpTheme->implDeregisterGalleryItem( *this );
+}
+
+// ------------------------------------------------------------------------------
+
+bool GalleryItem::isValid() const
+{
+ return( mpTheme != NULL );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Any SAL_CALL GalleryItem::queryAggregation( const uno::Type & rType )
+ throw( uno::RuntimeException )
+{
+ uno::Any aAny;
+
+ if( rType == ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0) )
+ aAny <<= uno::Reference< lang::XServiceInfo >(this);
+ else if( rType == ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0) )
+ aAny <<= uno::Reference< lang::XTypeProvider >(this);
+ else if( rType == ::getCppuType((const uno::Reference< gallery::XGalleryItem >*)0) )
+ aAny <<= uno::Reference< gallery::XGalleryItem >(this);
+ else if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) )
+ aAny <<= uno::Reference< beans::XPropertySet >(this);
+ else if( rType == ::getCppuType((const uno::Reference< beans::XPropertyState >*)0) )
+ aAny <<= uno::Reference< beans::XPropertyState >(this);
+ else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0) )
+ aAny <<= uno::Reference< beans::XMultiPropertySet >(this);
+ else
+ aAny <<= OWeakAggObject::queryAggregation( rType );
+
+ return aAny;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Any SAL_CALL GalleryItem::queryInterface( const uno::Type & rType )
+ throw( uno::RuntimeException )
+{
+ return OWeakAggObject::queryInterface( rType );
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL GalleryItem::acquire()
+ throw()
+{
+ OWeakAggObject::acquire();
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL GalleryItem::release()
+ throw()
+{
+ OWeakAggObject::release();
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString GalleryItem::getImplementationName_Static()
+ throw()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.gallery.GalleryItem" ) );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > GalleryItem::getSupportedServiceNames_Static()
+ throw()
+{
+ uno::Sequence< ::rtl::OUString > aSeq( 1 );
+
+ aSeq.getArray()[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.gallery.GalleryItem" ) );
+
+ return aSeq;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL GalleryItem::getImplementationName()
+ throw( uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL GalleryItem::supportsService( const ::rtl::OUString& ServiceName )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
+ const ::rtl::OUString* pArray = aSNL.getConstArray();
+
+ for( int i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return true;
+
+ return false;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL GalleryItem::getSupportedServiceNames()
+ throw( uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< uno::Type > SAL_CALL GalleryItem::getTypes()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< uno::Type > aTypes( 6 );
+ uno::Type* pTypes = aTypes.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< gallery::XGalleryItem>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet>*)0);
+
+ return aTypes;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< sal_Int8 > SAL_CALL GalleryItem::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ static uno::Sequence< sal_Int8 > aId;
+
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( reinterpret_cast< sal_uInt8* >( aId.getArray() ), 0, sal_True );
+ }
+
+ return aId;
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL GalleryItem::getType()
+ throw (uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ sal_Int8 nRet = gallery::GalleryItemType::EMPTY;
+
+ if( isValid() )
+ {
+ switch( implGetObject()->eObjKind )
+ {
+ case( SGA_OBJ_SOUND ):
+ case( SGA_OBJ_VIDEO ):
+ nRet = gallery::GalleryItemType::MEDIA;
+ break;
+
+ case( SGA_OBJ_SVDRAW ):
+ nRet = gallery::GalleryItemType::DRAWING;
+ break;
+
+ default:
+ nRet = gallery::GalleryItemType::GRAPHIC;
+ break;
+ }
+ }
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::comphelper::PropertySetInfo* GalleryItem::createPropertySetInfo()
+{
+ SolarMutexGuard aGuard;
+ ::comphelper::PropertySetInfo* pRet = new ::comphelper::PropertySetInfo();
+
+ static ::comphelper::PropertyMapEntry aEntries[] =
+ {
+ { MAP_CHAR_LEN( "GalleryItemType" ), UNOGALLERY_GALLERYITEMTYPE, &::getCppuType( (const sal_Int8*)(0)),
+ beans::PropertyAttribute::READONLY, 0 },
+
+ { MAP_CHAR_LEN( "URL" ), UNOGALLERY_URL, &::getCppuType( (const ::rtl::OUString*)(0)),
+ beans::PropertyAttribute::READONLY, 0 },
+
+ { MAP_CHAR_LEN( "Title" ), UNOGALLERY_TITLE, &::getCppuType( (const ::rtl::OUString*)(0)),
+ 0, 0 },
+
+ { MAP_CHAR_LEN( "Thumbnail" ), UNOGALLERY_THUMBNAIL, &::getCppuType( (const uno::Reference< graphic::XGraphic >*)(0)),
+ beans::PropertyAttribute::READONLY, 0 },
+
+ { MAP_CHAR_LEN( "Graphic" ), UNOGALLERY_GRAPHIC, &::getCppuType( (const uno::Reference< graphic::XGraphic >*)(0)),
+ beans::PropertyAttribute::READONLY, 0 },
+
+ { MAP_CHAR_LEN( "Drawing" ), UNOGALLERY_DRAWING, &::getCppuType( (const uno::Reference< lang::XComponent >*)(0) ),
+ beans::PropertyAttribute::READONLY, 0 },
+
+ { 0,0,0,0,0,0}
+ };
+
+ pRet->acquire();
+ pRet->add( aEntries );
+
+ return pRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void GalleryItem::_setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const uno::Any* pValues )
+ throw( beans::UnknownPropertyException,
+ beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException )
+{
+ const SolarMutexGuard aGuard;
+
+ while( *ppEntries )
+ {
+ if( UNOGALLERY_TITLE == (*ppEntries)->mnHandle )
+ {
+ ::rtl::OUString aNewTitle;
+
+ if( *pValues >>= aNewTitle )
+ {
+ ::GalleryTheme* pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
+
+ if( pGalTheme )
+ {
+ SgaObject* pObj = pGalTheme->ImplReadSgaObject( const_cast< GalleryObject* >( implGetObject() ) );
+
+ if( pObj )
+ {
+ if( ::rtl::OUString( pObj->GetTitle() ) != aNewTitle )
+ {
+ pObj->SetTitle( aNewTitle );
+ pGalTheme->InsertObject( *pObj );
+ }
+
+ delete pObj;
+ }
+ }
+ }
+ else
+ {
+ throw lang::IllegalArgumentException();
+ }
+ }
+
+ ++ppEntries;
+ ++pValues;
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void GalleryItem::_getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, uno::Any* pValue )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException )
+{
+ const SolarMutexGuard aGuard;
+
+ while( *ppEntries )
+ {
+ switch( (*ppEntries)->mnHandle )
+ {
+ case( UNOGALLERY_GALLERYITEMTYPE ):
+ {
+ *pValue <<= sal_Int8( getType() );
+ }
+ break;
+
+ case( UNOGALLERY_URL ):
+ {
+ ::GalleryTheme* pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
+
+ if( pGalTheme )
+ *pValue <<= ::rtl::OUString( implGetObject()->aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+ }
+ break;
+
+ case( UNOGALLERY_TITLE ):
+ {
+ ::GalleryTheme* pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
+
+ if( pGalTheme )
+ {
+ SgaObject* pObj = pGalTheme->AcquireObject( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ) );
+
+ if( pObj )
+ {
+ *pValue <<= ::rtl::OUString( pObj->GetTitle() );
+ pGalTheme->ReleaseObject( pObj );
+ }
+ }
+ }
+ break;
+
+ case( UNOGALLERY_THUMBNAIL ):
+ {
+ ::GalleryTheme* pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
+
+ if( pGalTheme )
+ {
+ SgaObject* pObj = pGalTheme->AcquireObject( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ) );
+
+ if( pObj )
+ {
+ Graphic aThumbnail;
+
+ if( pObj->IsThumbBitmap() )
+ aThumbnail = pObj->GetThumbBmp();
+ else
+ aThumbnail = pObj->GetThumbMtf();
+
+ *pValue <<= aThumbnail.GetXGraphic();
+ pGalTheme->ReleaseObject( pObj );
+ }
+ }
+ }
+ break;
+
+ case( UNOGALLERY_GRAPHIC ):
+ {
+ ::GalleryTheme* pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
+ Graphic aGraphic;
+
+ if( pGalTheme && pGalTheme->GetGraphic( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ), aGraphic ) )
+ *pValue <<= aGraphic.GetXGraphic();
+ }
+ break;
+
+ case( UNOGALLERY_DRAWING ):
+ {
+ if( gallery::GalleryItemType::DRAWING == getType() )
+ {
+ ::GalleryTheme* pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
+ FmFormModel* pModel = new FmFormModel;
+
+ pModel->GetItemPool().FreezeIdRanges();
+
+ if( pGalTheme && pGalTheme->GetModel( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ), *pModel ) )
+ {
+ uno::Reference< lang::XComponent > xDrawing( new GalleryDrawingModel( pModel ) );
+
+ pModel->setUnoModel( uno::Reference< uno::XInterface >::query( xDrawing ) );
+ *pValue <<= xDrawing;
+ }
+ else
+ delete pModel;
+ }
+ }
+ break;
+ }
+
+ ++ppEntries;
+ ++pValue;
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+const ::GalleryObject* GalleryItem::implGetObject() const
+{
+ return mpGalleryObject;
+}
+
+// ------------------------------------------------------------------------------
+
+void GalleryItem::implSetInvalid()
+{
+ if( mpTheme )
+ {
+ mpTheme = NULL;
+ mpGalleryObject = NULL;
+ }
+}
+
+// -----------------------
+// - GalleryDrawingModel -
+// -----------------------
+
+GalleryDrawingModel::GalleryDrawingModel( SdrModel* pDoc )
+ throw() :
+ SvxUnoDrawingModel( pDoc )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+GalleryDrawingModel::~GalleryDrawingModel()
+ throw()
+{
+ delete GetDoc();
+}
+
+// -----------------------------------------------------------------------------
+
+UNO3_GETIMPLEMENTATION_IMPL( GalleryDrawingModel );
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unogallery/unogalitem.hxx b/svx/source/unogallery/unogalitem.hxx
new file mode 100644
index 000000000000..71e6b6ea94cb
--- /dev/null
+++ b/svx/source/unogallery/unogalitem.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_UNOGALITEM_HXX
+#define _SVX_UNOGALITEM_HXX
+
+#include <svx/unomodel.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/gallery/XGalleryItem.hpp>
+#include <comphelper/propertysethelper.hxx>
+#include <comphelper/propertysetinfo.hxx>
+
+class GalleryTheme;
+struct GalleryObject;
+namespace unogallery { class GalleryTheme; }
+
+namespace unogallery {
+
+// ---------------
+// - GalleryItem -
+// ---------------
+
+class GalleryItem : public ::cppu::OWeakAggObject,
+ public ::com::sun::star::lang::XServiceInfo,
+ public ::com::sun::star::lang::XTypeProvider,
+ public ::com::sun::star::gallery::XGalleryItem,
+ public ::comphelper::PropertySetHelper
+{
+ friend class ::unogallery::GalleryTheme;
+
+public:
+
+ GalleryItem( ::unogallery::GalleryTheme& rTheme, const GalleryObject& rObject );
+ ~GalleryItem() throw();
+
+ bool isValid() const;
+
+ static ::rtl::OUString getImplementationName_Static() throw();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
+
+protected:
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XGalleryItem
+ virtual ::sal_Int8 SAL_CALL getType( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // PropertySetHelper
+ virtual void _setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const ::com::sun::star::uno::Any* pValues ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, ::com::sun::star::uno::Any* pValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
+
+protected:
+
+ ::comphelper::PropertySetInfo* createPropertySetInfo();
+
+private:
+
+ ::unogallery::GalleryTheme* mpTheme;
+ const ::GalleryObject* mpGalleryObject;
+
+ const ::GalleryObject* implGetObject() const;
+ void implSetInvalid();
+
+ // not available
+ GalleryItem();
+ GalleryItem( const GalleryItem& );
+ GalleryItem& operator=( const GalleryItem& );
+};
+
+// -----------------------
+// - GalleryDrawingModel -
+// -----------------------
+
+class GalleryDrawingModel : public SvxUnoDrawingModel
+{
+public:
+
+ GalleryDrawingModel( SdrModel* pDoc ) throw();
+ virtual ~GalleryDrawingModel() throw();
+
+ UNO3_GETIMPLEMENTATION_DECL( GalleryDrawingModel )
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unogallery/unogaltheme.cxx b/svx/source/unogallery/unogaltheme.cxx
new file mode 100644
index 000000000000..9e5a1e8bc24b
--- /dev/null
+++ b/svx/source/unogallery/unogaltheme.cxx
@@ -0,0 +1,469 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <algorithm>
+
+#include "unogaltheme.hxx"
+#include "unogalitem.hxx"
+#include "galtheme.hxx"
+#include "svx/gallery1.hxx"
+#include "svx/galmisc.hxx"
+#include <svx/fmmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/unopage.hxx>
+#include <svl/itempool.hxx>
+#include <rtl/uuid.h>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <unotools/pathoptions.hxx>
+
+using namespace ::com::sun::star;
+
+namespace unogallery {
+
+// -----------------
+// - GalleryTheme -
+// -----------------
+
+GalleryTheme::GalleryTheme( const ::rtl::OUString& rThemeName )
+{
+ mpGallery = ::Gallery::GetGalleryInstance();
+ mpTheme = ( mpGallery ? mpGallery->AcquireTheme( rThemeName, *this ) : NULL );
+
+ if( mpGallery )
+ StartListening( *mpGallery );
+}
+
+// ------------------------------------------------------------------------------
+
+GalleryTheme::~GalleryTheme()
+{
+ const SolarMutexGuard aGuard;
+
+ DBG_ASSERT( !mpTheme || mpGallery, "Theme is living without Gallery" );
+
+ implReleaseItems( NULL );
+
+ if( mpGallery )
+ {
+ EndListening( *mpGallery );
+
+ if( mpTheme )
+ mpGallery->ReleaseTheme( mpTheme, *this );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString GalleryTheme::getImplementationName_Static()
+ throw()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.gallery.GalleryTheme" ) );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > GalleryTheme::getSupportedServiceNames_Static()
+ throw()
+{
+ uno::Sequence< ::rtl::OUString > aSeq( 1 );
+
+ aSeq.getArray()[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.gallery.GalleryTheme" ) );
+
+ return aSeq;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL GalleryTheme::getImplementationName()
+ throw( uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL GalleryTheme::supportsService( const ::rtl::OUString& ServiceName )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
+ const ::rtl::OUString* pArray = aSNL.getConstArray();
+
+ for( int i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return true;
+
+ return false;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL GalleryTheme::getSupportedServiceNames()
+ throw( uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< uno::Type > SAL_CALL GalleryTheme::getTypes()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< uno::Type > aTypes( 5 );
+ uno::Type* pTypes = aTypes.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XElementAccess>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XIndexAccess>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< gallery::XGalleryTheme>*)0);
+
+ return aTypes;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< sal_Int8 > SAL_CALL GalleryTheme::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ static uno::Sequence< sal_Int8 > aId;
+
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( reinterpret_cast< sal_uInt8* >( aId.getArray() ), 0, sal_True );
+ }
+
+ return aId;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Type SAL_CALL GalleryTheme::getElementType()
+ throw (uno::RuntimeException)
+{
+ return ::getCppuType( (const uno::Reference< gallery::XGalleryItem >*) 0);
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL GalleryTheme::hasElements()
+ throw (uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ return( ( mpTheme != NULL ) && ( mpTheme->GetObjectCount() > 0 ) );
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL GalleryTheme::getCount()
+ throw (uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ return( mpTheme ? mpTheme->GetObjectCount() : 0 );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Any SAL_CALL GalleryTheme::getByIndex( ::sal_Int32 nIndex )
+ throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ uno::Any aRet;
+
+ if( mpTheme )
+ {
+ if( ( nIndex < 0 ) || ( nIndex >= getCount() ) )
+ {
+ throw lang::IndexOutOfBoundsException();
+ }
+ else
+ {
+ const GalleryObject* pObj = mpTheme->ImplGetGalleryObject( nIndex );
+
+ if( pObj )
+ aRet = uno::makeAny( uno::Reference< gallery::XGalleryItem >( new GalleryItem( *this, *pObj ) ) );
+ }
+ }
+
+ return aRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL GalleryTheme::getName( )
+ throw (uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ ::rtl::OUString aRet;
+
+ if( mpTheme )
+ aRet = mpTheme->GetName();
+
+ return aRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL GalleryTheme::update( )
+ throw (uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ if( mpTheme )
+ {
+ const Link aDummyLink;
+ mpTheme->Actualize( aDummyLink );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+::sal_Int32 SAL_CALL GalleryTheme::insertURLByIndex(
+ const ::rtl::OUString& rURL, ::sal_Int32 nIndex )
+ throw (lang::WrappedTargetException, uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ sal_Int32 nRet = -1;
+
+ if( mpTheme )
+ {
+ try
+ {
+ const INetURLObject aURL( rURL );
+
+ nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
+
+ if( ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) && mpTheme->InsertURL( aURL, nIndex ) )
+ {
+ const GalleryObject* pObj = mpTheme->ImplGetGalleryObject( aURL );
+
+ if( pObj )
+ nRet = mpTheme->ImplGetGalleryObjectPos( pObj );
+ }
+ }
+ catch( ... )
+ {
+ }
+ }
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::sal_Int32 SAL_CALL GalleryTheme::insertGraphicByIndex(
+ const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nIndex )
+ throw (lang::WrappedTargetException, uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ sal_Int32 nRet = -1;
+
+ if( mpTheme )
+ {
+ try
+ {
+ const Graphic aGraphic( rxGraphic );
+
+ nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
+
+ if( mpTheme->InsertGraphic( aGraphic, nIndex ) )
+ nRet = nIndex;
+ }
+ catch( ... )
+ {
+ }
+ }
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------------
+
+::sal_Int32 SAL_CALL GalleryTheme::insertDrawingByIndex(
+ const uno::Reference< lang::XComponent >& Drawing, sal_Int32 nIndex )
+ throw (lang::WrappedTargetException, uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ sal_Int32 nRet = -1;
+
+ if( mpTheme )
+ {
+ GalleryDrawingModel* pModel = GalleryDrawingModel::getImplementation( Drawing );
+
+ if( pModel && pModel->GetDoc() && pModel->GetDoc()->ISA( FmFormModel ) )
+ {
+ //Here we're inserting something that's already a gallery theme drawing
+
+ nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );
+
+ if( mpTheme->InsertModel( *static_cast< FmFormModel* >( pModel->GetDoc() ), nIndex ) )
+ nRet = nIndex;
+ }
+ else if (!pModel)
+ {
+ //#i80184# Try to do the right thing and make a Gallery drawing out of an ordinary
+ //Drawing if possible.
+ try
+ {
+ uno::Reference< drawing::XDrawPagesSupplier > xDrawPagesSupplier( Drawing, uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPage > xPage( xDrawPages->getByIndex( 0 ), uno::UNO_QUERY_THROW );
+ SvxDrawPage* pUnoPage = xPage.is() ? SvxDrawPage::getImplementation( xPage ) : NULL;
+ SdrModel* pOrigModel = pUnoPage ? pUnoPage->GetSdrPage()->GetModel() : NULL;
+ SdrPage* pOrigPage = pUnoPage ? pUnoPage->GetSdrPage() : NULL;
+
+ if (pOrigPage && pOrigModel)
+ {
+ FmFormModel* pTmpModel = new FmFormModel(&pOrigModel->GetItemPool());
+ SdrPage* pNewPage = pOrigPage->Clone();
+ pTmpModel->InsertPage(pNewPage, 0);
+
+ uno::Reference< lang::XComponent > xDrawing( new GalleryDrawingModel( pTmpModel ) );
+ pTmpModel->setUnoModel( uno::Reference< uno::XInterface >::query( xDrawing ) );
+
+ nRet = insertDrawingByIndex( xDrawing, nIndex );
+ return nRet;
+ }
+ }
+ catch (...)
+ {
+ }
+ }
+ }
+
+ return nRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL GalleryTheme::removeByIndex( sal_Int32 nIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ if( mpTheme )
+ {
+ if( ( nIndex < 0 ) || ( nIndex >= getCount() ) )
+ throw lang::IndexOutOfBoundsException();
+ else
+ mpTheme->RemoveObject( nIndex );
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void GalleryTheme::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ const SolarMutexGuard aGuard;
+ const GalleryHint& rGalleryHint = static_cast< const GalleryHint& >( rHint );
+
+ switch( rGalleryHint.GetType() )
+ {
+ case( GALLERY_HINT_CLOSE_THEME ):
+ {
+ DBG_ASSERT( !mpTheme || mpGallery, "Theme is living without Gallery" );
+
+ implReleaseItems( NULL );
+
+ if( mpGallery && mpTheme )
+ {
+ mpGallery->ReleaseTheme( mpTheme, *this );
+ mpTheme = NULL;
+ }
+ }
+ break;
+
+ case( GALLERY_HINT_CLOSE_OBJECT ):
+ {
+ GalleryObject* pObj = reinterpret_cast< GalleryObject* >( rGalleryHint.GetData1() );
+
+ if( pObj )
+ implReleaseItems( pObj );
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+void GalleryTheme::implReleaseItems( GalleryObject* pObj )
+{
+ const SolarMutexGuard aGuard;
+
+ for( GalleryItemList::iterator aIter = maItemList.begin(); aIter != maItemList.end(); )
+ {
+ if( !pObj || ( (*aIter)->implGetObject() == pObj ) )
+ {
+ (*aIter)->implSetInvalid();
+ aIter = maItemList.erase( aIter );
+ }
+ else
+ ++aIter;
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+::GalleryTheme* GalleryTheme::implGetTheme() const
+{
+ return mpTheme;
+}
+
+// ------------------------------------------------------------------------------
+
+void GalleryTheme::implRegisterGalleryItem( ::unogallery::GalleryItem& rItem )
+{
+ const SolarMutexGuard aGuard;
+
+// DBG_ASSERT( maItemList.find( &rItem ) == maItemList.end(), "Item already registered" );
+ maItemList.push_back( &rItem );
+}
+
+// ------------------------------------------------------------------------------
+
+void GalleryTheme::implDeregisterGalleryItem( ::unogallery::GalleryItem& rItem )
+{
+ const SolarMutexGuard aGuard;
+
+// DBG_ASSERT( maItemList.find( &rItem ) != maItemList.end(), "Item is not registered" );
+ maItemList.remove( &rItem );
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unogallery/unogaltheme.hxx b/svx/source/unogallery/unogaltheme.hxx
new file mode 100644
index 000000000000..8c9f1de670da
--- /dev/null
+++ b/svx/source/unogallery/unogaltheme.hxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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 _SVX_UNOGALTHEME_HXX
+#define _SVX_UNOGALTHEME_HXX
+
+#include <list>
+
+#include <cppuhelper/implbase1.hxx>
+#include <svl/lstner.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/gallery/XGalleryTheme.hpp>
+
+class Gallery;
+class GalleryTheme;
+struct GalleryObject;
+namespace unogallery { class GalleryItem; }
+
+namespace unogallery {
+
+// ----------------
+// - GalleryTheme -
+// ----------------
+
+class GalleryTheme : public ::cppu::WeakImplHelper1< ::com::sun::star::gallery::XGalleryTheme >,
+ public SfxListener
+{
+ friend class ::unogallery::GalleryItem;
+
+public:
+
+ GalleryTheme( const ::rtl::OUString& rThemeName );
+ ~GalleryTheme();
+
+ static ::rtl::OUString getImplementationName_Static() throw();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
+
+protected:
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService( const rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasElements() throw (::com::sun::star::uno::RuntimeException);
+
+ // XIndexAccess
+ virtual ::sal_Int32 SAL_CALL getCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // XGalleryThemes
+ virtual ::rtl::OUString SAL_CALL getName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL update( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL insertURLByIndex( const ::rtl::OUString& URL, ::sal_Int32 Index ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL insertGraphicByIndex( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& Graphic, ::sal_Int32 Index ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL insertDrawingByIndex( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& Drawing, ::sal_Int32 Index ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+
+ // SfxListener
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+private:
+
+ typedef ::std::list< ::unogallery::GalleryItem* > GalleryItemList;
+
+ GalleryItemList maItemList;
+ ::Gallery* mpGallery;
+ ::GalleryTheme* mpTheme;
+
+ ::GalleryTheme* implGetTheme() const;
+
+ void implReleaseItems( GalleryObject* pObj );
+
+ void implRegisterGalleryItem( ::unogallery::GalleryItem& rItem );
+ void implDeregisterGalleryItem( ::unogallery::GalleryItem& rItem );
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unogallery/unogalthemeprovider.cxx b/svx/source/unogallery/unogalthemeprovider.cxx
new file mode 100644
index 000000000000..258dd53faefb
--- /dev/null
+++ b/svx/source/unogallery/unogalthemeprovider.cxx
@@ -0,0 +1,317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include "unogalthemeprovider.hxx"
+#include "unogaltheme.hxx"
+#include "svx/gallery1.hxx"
+#include <rtl/uuid.h>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <unotools/pathoptions.hxx>
+#include <com/sun/star/gallery/XGalleryTheme.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+using namespace ::com::sun::star;
+
+namespace unogallery {
+
+// --------------------
+// - Helper functions -
+// --------------------
+
+uno::Reference< uno::XInterface > SAL_CALL GalleryThemeProvider_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & )
+ throw( uno::Exception )
+{
+ return *( new GalleryThemeProvider() );
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL GalleryThemeProvider_getSupportedServiceNames()
+ throw()
+{
+ return GalleryThemeProvider::getSupportedServiceNames_Static();
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL GalleryThemeProvider_getImplementationName()
+ throw()
+{
+ return GalleryThemeProvider::getImplementationName_Static();
+}
+
+// -----------------
+// - GalleryThemeProvider -
+// -----------------
+
+GalleryThemeProvider::GalleryThemeProvider() :
+ mbHiddenThemes( sal_False )
+{
+ mpGallery = ::Gallery::GetGalleryInstance();
+}
+
+// ------------------------------------------------------------------------------
+
+GalleryThemeProvider::~GalleryThemeProvider()
+{
+}
+
+// ------------------------------------------------------------------------------
+
+SVX_DLLPUBLIC ::rtl::OUString GalleryThemeProvider::getImplementationName_Static()
+ throw()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.gallery.GalleryThemeProvider" ) );
+}
+
+// ------------------------------------------------------------------------------
+
+SVX_DLLPUBLIC uno::Sequence< ::rtl::OUString > GalleryThemeProvider::getSupportedServiceNames_Static()
+ throw()
+{
+ uno::Sequence< ::rtl::OUString > aSeq( 1 );
+
+ aSeq.getArray()[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.gallery.GalleryThemeProvider" ) );
+
+ return aSeq;
+}
+
+// ------------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL GalleryThemeProvider::getImplementationName()
+ throw( uno::RuntimeException )
+{
+ return getImplementationName_Static();
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL GalleryThemeProvider::supportsService( const ::rtl::OUString& ServiceName )
+ throw( uno::RuntimeException )
+{
+ uno::Sequence< ::rtl::OUString > aSNL( getSupportedServiceNames() );
+ const ::rtl::OUString* pArray = aSNL.getConstArray();
+
+ for( int i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return true;
+
+ return false;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL GalleryThemeProvider::getSupportedServiceNames()
+ throw( uno::RuntimeException )
+{
+ return getSupportedServiceNames_Static();
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< uno::Type > SAL_CALL GalleryThemeProvider::getTypes()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< uno::Type > aTypes( 6 );
+ uno::Type* pTypes = aTypes.getArray();
+
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< lang::XInitialization>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XElementAccess>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< container::XNameAccess>*)0);
+ *pTypes++ = ::getCppuType((const uno::Reference< gallery::XGalleryThemeProvider>*)0);
+
+ return aTypes;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< sal_Int8 > SAL_CALL GalleryThemeProvider::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ static uno::Sequence< sal_Int8 > aId;
+
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( reinterpret_cast< sal_uInt8* >( aId.getArray() ), 0, sal_True );
+ }
+
+ return aId;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL GalleryThemeProvider::initialize( const uno::Sequence< uno::Any >& rArguments )
+ throw ( uno::Exception, uno::RuntimeException )
+{
+ uno::Sequence< beans::PropertyValue > aParams;
+ sal_Int32 i;
+
+ for( i = 0; i < rArguments.getLength(); ++i )
+ {
+ if( rArguments[ i ] >>= aParams )
+ break;
+ }
+
+ for( i = 0; i < aParams.getLength(); ++i )
+ {
+ const beans::PropertyValue& rProp = aParams[ i ];
+
+ if( rProp.Name.equalsAscii( "ProvideHiddenThemes" ) )
+ rProp.Value >>= mbHiddenThemes;
+ }
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Type SAL_CALL GalleryThemeProvider::getElementType()
+ throw (uno::RuntimeException)
+{
+ return ::getCppuType( (const uno::Reference< gallery::XGalleryTheme >*) 0);
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL GalleryThemeProvider::hasElements()
+ throw (uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ return( ( mpGallery != NULL ) && ( mpGallery->GetThemeCount() > 0 ) );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Any SAL_CALL GalleryThemeProvider::getByName( const ::rtl::OUString& rName )
+ throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ uno::Any aRet;
+
+ if( !mpGallery || !mpGallery->HasTheme( rName ) )
+ {
+ throw container::NoSuchElementException();
+ }
+ else
+ {
+ aRet = uno::makeAny( uno::Reference< gallery::XGalleryTheme >( new ::unogallery::GalleryTheme( rName ) ) );
+ }
+
+ return aRet;
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL GalleryThemeProvider::getElementNames()
+ throw (uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ sal_uInt32 i = 0, nCount = ( mpGallery ? mpGallery->GetThemeCount() : 0 ), nRealCount = 0;
+ uno::Sequence< ::rtl::OUString > aSeq( nCount );
+
+ for( ; i < nCount; ++i )
+ {
+ const GalleryThemeEntry* pEntry = mpGallery->GetThemeInfo( i );
+
+ if( mbHiddenThemes || !pEntry->IsHidden() )
+ aSeq[ nRealCount++ ] = pEntry->GetThemeName();
+ }
+
+ aSeq.realloc( nRealCount );
+
+ return aSeq;
+}
+
+// ------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL GalleryThemeProvider::hasByName( const ::rtl::OUString& rName )
+ throw (uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ sal_Bool bRet = sal_False;
+
+ if( mpGallery && mpGallery->HasTheme( rName ) )
+ bRet = ( mbHiddenThemes || !mpGallery->GetThemeInfo( rName )->IsHidden() );
+
+ return( bRet );
+}
+
+// ------------------------------------------------------------------------------
+
+uno::Reference< gallery::XGalleryTheme > SAL_CALL GalleryThemeProvider::insertNewByName( const ::rtl::OUString& rThemeName )
+ throw (container::ElementExistException, uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+ uno::Reference< gallery::XGalleryTheme > xRet;
+
+ if( mpGallery )
+ {
+ if( mpGallery->HasTheme( rThemeName ) )
+ {
+ throw container::ElementExistException();
+ }
+ else if( mpGallery->CreateTheme( rThemeName ) )
+ {
+ xRet = new ::unogallery::GalleryTheme( rThemeName );
+ }
+ }
+
+ return xRet;
+}
+
+// ------------------------------------------------------------------------------
+
+void SAL_CALL GalleryThemeProvider::removeByName( const ::rtl::OUString& rName )
+ throw (container::NoSuchElementException, uno::RuntimeException)
+{
+ const SolarMutexGuard aGuard;
+
+ if( !mpGallery ||
+ !mpGallery->HasTheme( rName ) ||
+ ( !mbHiddenThemes && mpGallery->GetThemeInfo( rName )->IsHidden() ) )
+ {
+ throw container::NoSuchElementException();
+ }
+ else
+ {
+ mpGallery->RemoveTheme( rName );
+ }
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xml/makefile.mk b/svx/source/xml/makefile.mk
new file mode 100644
index 000000000000..02e6f3ae1f23
--- /dev/null
+++ b/svx/source/xml/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=svx
+TARGET=xml
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+SLOFILES = \
+ $(SLO)$/xmlexport.obj \
+ $(SLO)$/xmlxtimp.obj \
+ $(SLO)$/xmlxtexp.obj \
+ $(SLO)$/xmlgrhlp.obj \
+ $(SLO)$/xmleohlp.obj
+
+# --- Targets --------------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/svx/source/xml/xmleohlp.cxx b/svx/source/xml/xmleohlp.cxx
new file mode 100644
index 000000000000..182f2317d856
--- /dev/null
+++ b/svx/source/xml/xmleohlp.cxx
@@ -0,0 +1,817 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <stdio.h>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XEmbedObjectCreator.hpp>
+#include <com/sun/star/embed/XEmbedObjectFactory.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <com/sun/star/embed/EntryInitModes.hpp>
+#include <com/sun/star/embed/EmbedStates.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <tools/debug.hxx>
+#include <unotools/streamwrap.hxx>
+#include <unotools/tempfile.hxx>
+
+#include <svtools/embedhlp.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <comphelper/embeddedobjectcontainer.hxx>
+
+#include <sot/clsids.hxx>
+#include <map>
+#include "xmleohlp.hxx"
+
+// -----------
+// - Defines -
+// -----------
+
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::utl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+
+#define XML_CONTAINERSTORAGE_NAME_60 "Pictures"
+#define XML_CONTAINERSTORAGE_NAME "ObjectReplacements"
+#define XML_EMBEDDEDOBJECT_URL_BASE "vnd.sun.star.EmbeddedObject:"
+#define XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE "vnd.sun.star.GraphicObject:"
+
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+
+class OutputStorageWrapper_Impl : public ::cppu::WeakImplHelper1<XOutputStream>
+{
+ ::osl::Mutex maMutex;
+ Reference < XOutputStream > xOut;
+ TempFile aTempFile;
+ sal_Bool bStreamClosed : 1;
+ SvStream* pStream;
+
+public:
+ OutputStorageWrapper_Impl();
+ virtual ~OutputStorageWrapper_Impl();
+
+// stario::XOutputStream
+ virtual void SAL_CALL writeBytes(const Sequence< sal_Int8 >& aData) throw(NotConnectedException, BufferSizeExceededException, RuntimeException);
+ virtual void SAL_CALL flush() throw(NotConnectedException, BufferSizeExceededException, RuntimeException);
+ virtual void SAL_CALL closeOutput() throw(NotConnectedException, BufferSizeExceededException, RuntimeException);
+
+ SvStream* GetStream();
+};
+
+OutputStorageWrapper_Impl::OutputStorageWrapper_Impl()
+ : bStreamClosed( sal_False )
+ , pStream(0)
+{
+ aTempFile.EnableKillingFile();
+ pStream = aTempFile.GetStream( STREAM_READWRITE );
+ xOut = new OOutputStreamWrapper( *pStream );
+}
+
+OutputStorageWrapper_Impl::~OutputStorageWrapper_Impl()
+{
+}
+
+SvStream *OutputStorageWrapper_Impl::GetStream()
+{
+ if( bStreamClosed )
+ return pStream;
+ return NULL;
+}
+
+void SAL_CALL OutputStorageWrapper_Impl::writeBytes(
+ const Sequence< sal_Int8 >& aData)
+ throw(NotConnectedException, BufferSizeExceededException, RuntimeException)
+{
+ MutexGuard aGuard( maMutex );
+ xOut->writeBytes( aData );
+}
+
+void SAL_CALL OutputStorageWrapper_Impl::flush()
+ throw(NotConnectedException, BufferSizeExceededException, RuntimeException)
+{
+ MutexGuard aGuard( maMutex );
+ xOut->flush();
+}
+
+void SAL_CALL OutputStorageWrapper_Impl::closeOutput()
+ throw(NotConnectedException, BufferSizeExceededException, RuntimeException)
+{
+ MutexGuard aGuard( maMutex );
+ xOut->closeOutput();
+ bStreamClosed = sal_True;
+}
+
+// -----------------------------------------------------------------------------
+
+struct OUStringLess
+{
+ bool operator() ( const ::rtl::OUString& r1, const ::rtl::OUString& r2 ) const
+ {
+ return (r1 < r2) != sal_False;
+ }
+};
+
+// -----------------------------------------------------------------------------
+
+// -----------------------------
+// - SvXMLEmbeddedObjectHelper -
+// -----------------------------
+DBG_NAME(SvXMLEmbeddedObjectHelper)
+SvXMLEmbeddedObjectHelper::SvXMLEmbeddedObjectHelper() :
+ WeakComponentImplHelper2< XEmbeddedObjectResolver, XNameAccess >( maMutex ),
+ maReplacementGraphicsContainerStorageName( RTL_CONSTASCII_USTRINGPARAM(XML_CONTAINERSTORAGE_NAME) ),
+ maReplacementGraphicsContainerStorageName60( RTL_CONSTASCII_USTRINGPARAM(XML_CONTAINERSTORAGE_NAME_60) ),
+ mpDocPersist( 0 ),
+ meCreateMode( EMBEDDEDOBJECTHELPER_MODE_READ ),
+ mpStreamMap( 0 )
+{
+ DBG_CTOR(SvXMLEmbeddedObjectHelper,NULL);
+}
+
+SvXMLEmbeddedObjectHelper::SvXMLEmbeddedObjectHelper( ::comphelper::IEmbeddedHelper& rDocPersist, SvXMLEmbeddedObjectHelperMode eCreateMode ) :
+ WeakComponentImplHelper2< XEmbeddedObjectResolver, XNameAccess >( maMutex ),
+ maReplacementGraphicsContainerStorageName( RTL_CONSTASCII_USTRINGPARAM(XML_CONTAINERSTORAGE_NAME) ),
+ maReplacementGraphicsContainerStorageName60( RTL_CONSTASCII_USTRINGPARAM(XML_CONTAINERSTORAGE_NAME_60) ),
+ mpDocPersist( 0 ),
+ meCreateMode( EMBEDDEDOBJECTHELPER_MODE_READ ),
+ mpStreamMap( 0 )
+{
+ DBG_CTOR(SvXMLEmbeddedObjectHelper,NULL);
+ Init( 0, rDocPersist, eCreateMode );
+}
+
+
+// -----------------------------------------------------------------------------
+
+SvXMLEmbeddedObjectHelper::~SvXMLEmbeddedObjectHelper()
+{
+ DBG_DTOR(SvXMLEmbeddedObjectHelper,NULL);
+ if( mpStreamMap )
+ {
+ SvXMLEmbeddedObjectHelper_Impl::iterator aIter = mpStreamMap->begin();
+ SvXMLEmbeddedObjectHelper_Impl::iterator aEnd = mpStreamMap->end();
+ for( ; aIter != aEnd; aIter++ )
+ {
+ if( aIter->second )
+ {
+ aIter->second->release();
+ aIter->second = 0;
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SvXMLEmbeddedObjectHelper::disposing()
+{
+ Flush();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SvXMLEmbeddedObjectHelper::ImplGetStorageNames(
+ const ::rtl::OUString& rURLStr,
+ ::rtl::OUString& rContainerStorageName,
+ ::rtl::OUString& rObjectStorageName,
+ sal_Bool bInternalToExternal,
+ sal_Bool *pGraphicRepl,
+ sal_Bool *pOasisFormat ) const
+{
+ // internal URL: vnd.sun.star.EmbeddedObject:<object-name>
+ // or: vnd.sun.star.EmbeddedObject:<path>/<object-name>
+ // internal replacement images:
+ // vnd.sun.star.EmbeddedObjectGraphic:<object-name>
+ // or: vnd.sun.star.EmbeddedObjectGraphic:<path>/<object-name>
+ // external URL: ./<path>/<object-name>
+ // or: <path>/<object-name>
+ // or: <object-name>
+ // currently, path may only consist of a single directory name
+ // it is also possible to have additional arguments at the end of URL: <main URL>[?<name>=<value>[,<name>=<value>]*]
+
+ if( pGraphicRepl )
+ *pGraphicRepl = sal_False;
+
+ if( pOasisFormat )
+ *pOasisFormat = sal_True; // the default value
+
+ if( !rURLStr.getLength() )
+ return sal_False;
+
+ // get rid of arguments
+ sal_Int32 nPos = rURLStr.indexOf( '?' );
+ ::rtl::OUString aURLNoPar;
+ if ( nPos == -1 )
+ aURLNoPar = rURLStr;
+ else
+ {
+ aURLNoPar = rURLStr.copy( 0, nPos );
+
+ // check the arguments
+ nPos++;
+ while( nPos >= 0 && nPos < rURLStr.getLength() )
+ {
+ ::rtl::OUString aToken = rURLStr.getToken( 0, ',', nPos );
+ if ( aToken.equalsIgnoreAsciiCase( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "oasis=false" ) ) ) )
+ {
+ if ( pOasisFormat )
+ *pOasisFormat = sal_False;
+ break;
+ }
+ else
+ {
+ DBG_ASSERT( sal_False, "invalid arguments was found in URL!" );
+ }
+ }
+ }
+
+ if( bInternalToExternal )
+ {
+ nPos = aURLNoPar.indexOf( ':' );
+ if( -1 == nPos )
+ return sal_False;
+ sal_Bool bObjUrl =
+ 0 == aURLNoPar.compareToAscii( XML_EMBEDDEDOBJECT_URL_BASE,
+ sizeof( XML_EMBEDDEDOBJECT_URL_BASE ) -1 );
+ sal_Bool bGrUrl = !bObjUrl &&
+ 0 == aURLNoPar.compareToAscii( XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE,
+ sizeof( XML_EMBEDDEDOBJECTGRAPHIC_URL_BASE ) -1 );
+ if( !(bObjUrl || bGrUrl) )
+ return sal_False;
+
+ sal_Int32 nPathStart = nPos + 1;
+ nPos = aURLNoPar.lastIndexOf( '/' );
+ if( -1 == nPos )
+ {
+ rContainerStorageName = ::rtl::OUString();
+ rObjectStorageName = aURLNoPar.copy( nPathStart );
+ }
+ else if( nPos > nPathStart )
+ {
+ rContainerStorageName = aURLNoPar.copy( nPathStart, nPos-nPathStart);
+ rObjectStorageName = aURLNoPar.copy( nPos+1 );
+ }
+ else
+ return sal_False;
+
+ if( bGrUrl )
+ {
+ sal_Bool bOASIS = mxRootStorage.is() &&
+ ( SotStorage::GetVersion( mxRootStorage ) > SOFFICE_FILEFORMAT_60 );
+ rContainerStorageName = bOASIS
+ ? maReplacementGraphicsContainerStorageName
+ : maReplacementGraphicsContainerStorageName60;
+
+ if( pGraphicRepl )
+ *pGraphicRepl = sal_True;
+ }
+
+
+ }
+ else
+ {
+ DBG_ASSERT( '#' != aURLNoPar[0], "invalid object URL" );
+
+ sal_Int32 _nPos = aURLNoPar.lastIndexOf( '/' );
+ if( -1 == _nPos )
+ {
+ rContainerStorageName = ::rtl::OUString();
+ rObjectStorageName = aURLNoPar;
+ }
+ else
+ {
+ //eliminate 'superfluous' slashes at start and end
+ //#i103076# load objects with all allowed xlink:href syntaxes
+ {
+ //eliminate './' at start
+ sal_Int32 nStart = 0;
+ sal_Int32 nCount = aURLNoPar.getLength();
+ if( 0 == aURLNoPar.compareToAscii( "./", 2 ) )
+ {
+ nStart = 2;
+ nCount -= 2;
+ }
+
+ //eliminate '/' at end
+ sal_Int32 nEnd = aURLNoPar.lastIndexOf( '/' );
+ if( nEnd == aURLNoPar.getLength()-1 && nEnd != (nStart-1) )
+ nCount--;
+
+ aURLNoPar = aURLNoPar.copy( nStart, nCount );
+ }
+
+ _nPos = aURLNoPar.lastIndexOf( '/' );
+ if( _nPos >= 0 )
+ rContainerStorageName = aURLNoPar.copy( 0, _nPos );
+ rObjectStorageName = aURLNoPar.copy( _nPos+1 );
+ }
+ }
+
+ if( -1 != rContainerStorageName.indexOf( '/' ) )
+ {
+ DBG_ERROR( "SvXMLEmbeddedObjectHelper: invalid path name" );
+ return sal_False;
+ }
+
+ return sal_True;
+}
+
+
+// -----------------------------------------------------------------------------
+
+uno::Reference < embed::XStorage > SvXMLEmbeddedObjectHelper::ImplGetContainerStorage(
+ const ::rtl::OUString& rStorageName )
+{
+ DBG_ASSERT( -1 == rStorageName.indexOf( '/' ) &&
+ -1 == rStorageName.indexOf( '\\' ),
+ "nested embedded storages aren't supported" );
+ if( !mxContainerStorage.is() ||
+ ( rStorageName != maCurContainerStorageName ) )
+ {
+ if( mxContainerStorage.is() &&
+ maCurContainerStorageName.getLength() > 0 &&
+ EMBEDDEDOBJECTHELPER_MODE_WRITE == meCreateMode )
+ {
+ uno::Reference < embed::XTransactedObject > xTrans( mxContainerStorage, uno::UNO_QUERY );
+ if ( xTrans.is() )
+ xTrans->commit();
+ }
+
+ if( rStorageName.getLength() > 0 && mxRootStorage.is() )
+ {
+ sal_Int32 nMode = EMBEDDEDOBJECTHELPER_MODE_WRITE == meCreateMode
+ ? ::embed::ElementModes::READWRITE
+ : ::embed::ElementModes::READ;
+ mxContainerStorage = mxRootStorage->openStorageElement( rStorageName,
+ nMode );
+ }
+ else
+ {
+ mxContainerStorage = mxRootStorage;
+ }
+ maCurContainerStorageName = rStorageName;
+ }
+
+ return mxContainerStorage;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SvXMLEmbeddedObjectHelper::ImplReadObject(
+ const ::rtl::OUString& rContainerStorageName,
+ ::rtl::OUString& rObjName,
+ const SvGlobalName *pClassId,
+ SvStream* pTemp )
+{
+ (void)pClassId;
+
+ uno::Reference < embed::XStorage > xDocStor( mpDocPersist->getStorage() );
+ uno::Reference < embed::XStorage > xCntnrStor( ImplGetContainerStorage( rContainerStorageName ) );
+
+ if( !xCntnrStor.is() && !pTemp )
+ return sal_False;
+
+ String aSrcObjName( rObjName );
+ comphelper::EmbeddedObjectContainer& rContainer = mpDocPersist->getEmbeddedObjectContainer();
+
+ // Is the object name unique?
+ // if the object is already instantiated by GetEmbeddedObject
+ // that means that the duplication is being loaded
+ sal_Bool bDuplicate = rContainer.HasInstantiatedEmbeddedObject( rObjName );
+ DBG_ASSERT( !bDuplicate, "An object in the document is referenced twice!" );
+
+ if( xDocStor != xCntnrStor || pTemp || bDuplicate )
+ {
+ // TODO/LATER: make this alltogether a method in the EmbeddedObjectContainer
+
+ // create a unique name for the duplicate object
+ if( bDuplicate )
+ rObjName = rContainer.CreateUniqueObjectName();
+
+ if( pTemp )
+ {
+ try
+ {
+ pTemp->Seek( 0 );
+ uno::Reference < io::XStream > xStm = xDocStor->openStreamElement( rObjName,
+ embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
+ SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( xStm );
+ *pTemp >> *pStream;
+ delete pStream;
+
+ // TODO/LATER: what to do when other types of objects are based on substream persistence?
+ // This is an ole object
+ uno::Reference< beans::XPropertySet > xProps( xStm, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ),
+ uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.sun.star.oleobject" ) ) ) );
+
+ xStm->getOutputStream()->closeOutput();
+ }
+ catch ( uno::Exception& )
+ {
+ return sal_False;
+ }
+ }
+ else
+ {
+ try
+ {
+ xCntnrStor->copyElementTo( aSrcObjName, xDocStor, rObjName );
+ }
+ catch ( uno::Exception& )
+ {
+ return sal_False;
+ }
+ }
+ }
+
+ // make object known to the container
+ // TODO/LATER: could be done a little bit more efficient!
+ ::rtl::OUString aName( rObjName );
+
+ // TODO/LATER: The provided pClassId is ignored for now.
+ // The stream contains OLE storage internally and this storage already has a class id specifying the
+ // server that was used to create the object. pClassId could be used to specify the server that should
+ // be used for the next opening, but this information seems to be out of the file format responsibility
+ // area.
+ rContainer.GetEmbeddedObject( aName );
+
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SvXMLEmbeddedObjectHelper::ImplInsertEmbeddedObjectURL(
+ const ::rtl::OUString& rURLStr )
+{
+ ::rtl::OUString sRetURL;
+
+ ::rtl::OUString aContainerStorageName, aObjectStorageName;
+ if( !ImplGetStorageNames( rURLStr, aContainerStorageName,
+ aObjectStorageName,
+ EMBEDDEDOBJECTHELPER_MODE_WRITE == meCreateMode ) )
+ return sRetURL;
+
+ if( EMBEDDEDOBJECTHELPER_MODE_READ == meCreateMode )
+ {
+ OutputStorageWrapper_Impl *pOut = 0;
+ SvXMLEmbeddedObjectHelper_Impl::iterator aIter;
+
+ if( mpStreamMap )
+ {
+ aIter = mpStreamMap->find( rURLStr );
+ if( aIter != mpStreamMap->end() && aIter->second )
+ pOut = aIter->second;
+ }
+
+ SvGlobalName aClassId, *pClassId = 0;
+ sal_Int32 nPos = aObjectStorageName.lastIndexOf( '!' );
+ if( -1 != nPos && aClassId.MakeId( aObjectStorageName.copy( nPos+1 ) ) )
+ {
+ aObjectStorageName = aObjectStorageName.copy( 0, nPos );
+ pClassId = &aClassId;
+ }
+
+ ImplReadObject( aContainerStorageName, aObjectStorageName, pClassId, pOut ? pOut->GetStream() : 0 );
+ sRetURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(XML_EMBEDDEDOBJECT_URL_BASE) );
+ sRetURL += aObjectStorageName;
+
+ if( pOut )
+ {
+ mpStreamMap->erase( aIter );
+ pOut->release();
+ }
+ }
+ else
+ {
+ // Objects are written using ::comphelper::IEmbeddedHelper::SaveAs
+ sRetURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("./") );
+ if( aContainerStorageName.getLength() )
+ {
+ sRetURL += aContainerStorageName;
+ sRetURL += ::rtl::OUString( '/' );
+ }
+ sRetURL += aObjectStorageName;
+ }
+
+ return sRetURL;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< io::XInputStream > SvXMLEmbeddedObjectHelper::ImplGetReplacementImage(
+ const uno::Reference< embed::XEmbeddedObject >& xObj )
+{
+ uno::Reference< io::XInputStream > xStream;
+
+ if( xObj.is() )
+ {
+ try
+ {
+ sal_Bool bSwitchBackToLoaded = sal_False;
+ sal_Int32 nCurState = xObj->getCurrentState();
+ if ( nCurState == embed::EmbedStates::LOADED || nCurState == embed::EmbedStates::RUNNING )
+ {
+ // means that the object is not active
+ // copy replacement image from old to new container
+ ::rtl::OUString aMediaType;
+ xStream = mpDocPersist->getEmbeddedObjectContainer().GetGraphicStream( xObj, &aMediaType );
+ }
+
+ if ( !xStream.is() )
+ {
+ // the image must be regenerated
+ // TODO/LATER: another aspect could be used
+ if ( nCurState == embed::EmbedStates::LOADED )
+ bSwitchBackToLoaded = sal_True;
+
+ ::rtl::OUString aMediaType;
+ xStream = svt::EmbeddedObjectRef::GetGraphicReplacementStream(
+ embed::Aspects::MSOLE_CONTENT,
+ xObj,
+ &aMediaType );
+ }
+
+ if ( bSwitchBackToLoaded )
+ // switch back to loaded state; that way we have a minimum cache confusion
+ xObj->changeState( embed::EmbedStates::LOADED );
+ }
+ catch( uno::Exception& )
+ {}
+ }
+
+ return xStream;
+}
+
+// -----------------------------------------------------------------------------
+
+void SvXMLEmbeddedObjectHelper::Init(
+ const uno::Reference < embed::XStorage >& rRootStorage,
+ ::comphelper::IEmbeddedHelper& rPersist,
+ SvXMLEmbeddedObjectHelperMode eCreateMode )
+{
+ mxRootStorage = rRootStorage;
+ mpDocPersist = &rPersist;
+ meCreateMode = eCreateMode;
+}
+
+// -----------------------------------------------------------------------------
+
+SvXMLEmbeddedObjectHelper* SvXMLEmbeddedObjectHelper::Create(
+ const uno::Reference < embed::XStorage >& rRootStorage,
+ ::comphelper::IEmbeddedHelper& rDocPersist,
+ SvXMLEmbeddedObjectHelperMode eCreateMode,
+ sal_Bool bDirect )
+{
+ (void)bDirect;
+
+ SvXMLEmbeddedObjectHelper* pThis = new SvXMLEmbeddedObjectHelper;
+
+ pThis->acquire();
+ pThis->Init( rRootStorage, rDocPersist, eCreateMode );
+
+ return pThis;
+}
+
+SvXMLEmbeddedObjectHelper* SvXMLEmbeddedObjectHelper::Create(
+ ::comphelper::IEmbeddedHelper& rDocPersist,
+ SvXMLEmbeddedObjectHelperMode eCreateMode )
+{
+ SvXMLEmbeddedObjectHelper* pThis = new SvXMLEmbeddedObjectHelper;
+
+ pThis->acquire();
+ pThis->Init( 0, rDocPersist, eCreateMode );
+
+ return pThis;
+}
+
+// -----------------------------------------------------------------------------
+
+void SvXMLEmbeddedObjectHelper::Destroy(
+ SvXMLEmbeddedObjectHelper* pSvXMLEmbeddedObjectHelper )
+{
+ if( pSvXMLEmbeddedObjectHelper )
+ {
+ pSvXMLEmbeddedObjectHelper->dispose();
+ pSvXMLEmbeddedObjectHelper->release();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SvXMLEmbeddedObjectHelper::Flush()
+{
+ if( mxTempStorage.is() )
+ {
+ Reference < XComponent > xComp( mxTempStorage, UNO_QUERY );
+ xComp->dispose();
+ }
+}
+
+// XGraphicObjectResolver: alien objects!
+::rtl::OUString SAL_CALL SvXMLEmbeddedObjectHelper::resolveEmbeddedObjectURL( const ::rtl::OUString& aURL )
+ throw(RuntimeException)
+{
+ MutexGuard aGuard( maMutex );
+
+ return ImplInsertEmbeddedObjectURL( aURL );
+}
+
+// XNameAccess: alien objects!
+Any SAL_CALL SvXMLEmbeddedObjectHelper::getByName(
+ const ::rtl::OUString& rURLStr )
+ throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ MutexGuard aGuard( maMutex );
+ Any aRet;
+ if( EMBEDDEDOBJECTHELPER_MODE_READ == meCreateMode )
+ {
+ Reference < XOutputStream > xStrm;
+ if( mpStreamMap )
+ {
+ SvXMLEmbeddedObjectHelper_Impl::iterator aIter =
+ mpStreamMap->find( rURLStr );
+ if( aIter != mpStreamMap->end() && aIter->second )
+ xStrm = aIter->second;
+ }
+ if( !xStrm.is() )
+ {
+ OutputStorageWrapper_Impl *pOut = new OutputStorageWrapper_Impl;
+ pOut->acquire();
+ if( !mpStreamMap )
+ mpStreamMap = new SvXMLEmbeddedObjectHelper_Impl;
+ (*mpStreamMap)[rURLStr] = pOut;
+ xStrm = pOut;
+ }
+
+ aRet <<= xStrm;
+ }
+ else
+ {
+ sal_Bool bGraphicRepl = sal_False;
+ sal_Bool bOasisFormat = sal_True;
+ Reference < XInputStream > xStrm;
+ ::rtl::OUString aContainerStorageName, aObjectStorageName;
+ if( ImplGetStorageNames( rURLStr, aContainerStorageName,
+ aObjectStorageName,
+ sal_True,
+ &bGraphicRepl,
+ &bOasisFormat ) )
+ {
+ try
+ {
+ comphelper::EmbeddedObjectContainer& rContainer =
+ mpDocPersist->getEmbeddedObjectContainer();
+
+ Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( aObjectStorageName );
+ DBG_ASSERT( xObj.is(), "Didn't get object" );
+
+ if( xObj.is() )
+ {
+ if( bGraphicRepl )
+ {
+ xStrm = ImplGetReplacementImage( xObj );
+ }
+ else
+ {
+ Reference < embed::XEmbedPersist > xPersist( xObj, UNO_QUERY );
+ if( xPersist.is() )
+ {
+ if( !mxTempStorage.is() )
+ mxTempStorage =
+ comphelper::OStorageHelper::GetTemporaryStorage();
+ Sequence < beans::PropertyValue > aDummy( 0 ), aEmbDescr( 1 );
+ aEmbDescr[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StoreVisualReplacement" ) );
+ aEmbDescr[0].Value <<= (sal_Bool)(!bOasisFormat);
+ if ( !bOasisFormat )
+ {
+ ::rtl::OUString aMimeType;
+ uno::Reference< io::XInputStream > xGrInStream = ImplGetReplacementImage( xObj );
+ if ( xGrInStream.is() )
+ {
+ aEmbDescr.realloc( 2 );
+ aEmbDescr[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "VisualReplacement" ) );
+ aEmbDescr[1].Value <<= xGrInStream;
+ }
+ }
+
+ xPersist->storeToEntry( mxTempStorage, aObjectStorageName,
+ aDummy, aEmbDescr );
+ Reference < io::XStream > xStream =
+ mxTempStorage->openStreamElement(
+ aObjectStorageName,
+ embed::ElementModes::READ);
+ if( xStream.is() )
+ xStrm = xStream->getInputStream();
+ }
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+
+ aRet <<= xStrm;
+ }
+
+ return aRet;
+}
+
+Sequence< ::rtl::OUString > SAL_CALL SvXMLEmbeddedObjectHelper::getElementNames()
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( maMutex );
+ return Sequence< ::rtl::OUString >(0);
+}
+
+sal_Bool SAL_CALL SvXMLEmbeddedObjectHelper::hasByName( const ::rtl::OUString& rURLStr )
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( maMutex );
+ if( EMBEDDEDOBJECTHELPER_MODE_READ == meCreateMode )
+ {
+ return sal_True;
+ }
+ else
+ {
+ ::rtl::OUString aContainerStorageName, aObjectStorageName;
+ if( !ImplGetStorageNames( rURLStr, aContainerStorageName,
+ aObjectStorageName,
+ sal_True ) )
+ return sal_False;
+
+ comphelper::EmbeddedObjectContainer& rContainer = mpDocPersist->getEmbeddedObjectContainer();
+ return aObjectStorageName.getLength() > 0 &&
+ rContainer.HasEmbeddedObject( aObjectStorageName );
+ }
+}
+
+// XNameAccess
+Type SAL_CALL SvXMLEmbeddedObjectHelper::getElementType()
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( maMutex );
+ if( EMBEDDEDOBJECTHELPER_MODE_READ == meCreateMode )
+ return ::getCppuType((const Reference<XOutputStream>*)0);
+ else
+ return ::getCppuType((const Reference<XInputStream>*)0);
+}
+
+sal_Bool SAL_CALL SvXMLEmbeddedObjectHelper::hasElements()
+ throw (RuntimeException)
+{
+ MutexGuard aGuard( maMutex );
+ if( EMBEDDEDOBJECTHELPER_MODE_READ == meCreateMode )
+ {
+ return sal_True;
+ }
+ else
+ {
+ comphelper::EmbeddedObjectContainer& rContainer = mpDocPersist->getEmbeddedObjectContainer();
+ return rContainer.HasEmbeddedObjects();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xml/xmlexport.cxx b/svx/source/xml/xmlexport.cxx
new file mode 100644
index 000000000000..467cc97c5c36
--- /dev/null
+++ b/svx/source/xml/xmlexport.cxx
@@ -0,0 +1,286 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/xml/sax/SAXParseException.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <comphelper/processfactory.hxx>
+#include <unotools/streamwrap.hxx>
+#include <sot/storage.hxx>
+#include <svx/svdmodel.hxx>
+#include <xmleohlp.hxx>
+#include <xmlgrhlp.hxx>
+
+#include <svx/unomodel.hxx>
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+sal_Bool SvxDrawingLayerExport( SdrModel* pModel, const uno::Reference<io::XOutputStream>& xOut, const Reference< lang::XComponent >& xComponent )
+{
+ return SvxDrawingLayerExport( pModel, xOut, xComponent, "com.sun.star.comp.DrawingLayer.XMLExporter" );
+}
+
+sal_Bool SvxDrawingLayerExport( SdrModel* pModel, const uno::Reference<io::XOutputStream>& xOut, const Reference< lang::XComponent >& xComponent, const char* pExportService )
+{
+ sal_Bool bDocRet = xOut.is();
+
+ Reference< document::XGraphicObjectResolver > xGraphicResolver;
+ SvXMLGraphicHelper *pGraphicHelper = 0;
+
+ Reference< document::XEmbeddedObjectResolver > xObjectResolver;
+ SvXMLEmbeddedObjectHelper *pObjectHelper = 0;
+
+ Reference< lang::XComponent > xSourceDoc( xComponent );
+ try
+ {
+ if( !xSourceDoc.is() )
+ {
+ xSourceDoc = new SvxUnoDrawingModel( pModel );
+ pModel->setUnoModel( Reference< XInterface >::query( xSourceDoc ) );
+ }
+
+ uno::Reference< lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
+ if( !xServiceFactory.is() )
+ {
+ DBG_ERROR( "got no service manager" );
+ bDocRet = sal_False;
+ }
+
+ if( bDocRet )
+ {
+ uno::Reference< uno::XInterface > xWriter( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ) ) ) );
+ if( !xWriter.is() )
+ {
+ DBG_ERROR( "com.sun.star.xml.sax.Writer service missing" );
+ bDocRet = sal_False;
+ }
+
+ ::comphelper::IEmbeddedHelper *pPersist = pModel->GetPersist();
+ if( pPersist )
+ {
+ pObjectHelper = SvXMLEmbeddedObjectHelper::Create( *pPersist, EMBEDDEDOBJECTHELPER_MODE_WRITE );
+ xObjectResolver = pObjectHelper;
+ }
+
+ pGraphicHelper = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_WRITE );
+ xGraphicResolver = pGraphicHelper;
+
+ if( bDocRet )
+ {
+ uno::Reference<xml::sax::XDocumentHandler> xHandler( xWriter, uno::UNO_QUERY );
+
+ // doc export
+ uno::Reference< io::XActiveDataSource > xDocSrc( xWriter, uno::UNO_QUERY );
+ xDocSrc->setOutputStream( xOut );
+
+ uno::Sequence< uno::Any > aArgs( xObjectResolver.is() ? 3 : 2 );
+ aArgs[0] <<= xHandler;
+ aArgs[1] <<= xGraphicResolver;
+ if( xObjectResolver.is() )
+ aArgs[2] <<= xObjectResolver;
+
+ uno::Reference< document::XFilter > xFilter( xServiceFactory->createInstanceWithArguments( OUString::createFromAscii( pExportService ), aArgs ), uno::UNO_QUERY );
+ if( !xFilter.is() )
+ {
+ DBG_ERROR( "com.sun.star.comp.Draw.XMLExporter service missing" );
+ bDocRet = sal_False;
+ }
+
+ if( bDocRet )
+ {
+ uno::Reference< document::XExporter > xExporter( xFilter, uno::UNO_QUERY );
+ if( xExporter.is() )
+ {
+ xExporter->setSourceDocument( xSourceDoc );
+
+ uno::Sequence< beans::PropertyValue > aDescriptor( 0 );
+ bDocRet = xFilter->filter( aDescriptor );
+ }
+ }
+ }
+ }
+ }
+ catch(uno::Exception e)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ bDocRet = sal_False;
+ }
+
+ if( pGraphicHelper )
+ SvXMLGraphicHelper::Destroy( pGraphicHelper );
+ xGraphicResolver = 0;
+
+ if( pObjectHelper )
+ SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
+ xObjectResolver = 0;
+
+ return bDocRet;
+}
+
+sal_Bool SvxDrawingLayerExport( SdrModel* pModel, const uno::Reference<io::XOutputStream>& xOut )
+{
+ Reference< lang::XComponent > xComponent;
+ return SvxDrawingLayerExport( pModel, xOut, xComponent );
+}
+
+//-////////////////////////////////////////////////////////////////////
+
+sal_Bool SvxDrawingLayerImport( SdrModel* pModel, const uno::Reference<io::XInputStream>& xInputStream, const Reference< lang::XComponent >& xComponent )
+{
+ return SvxDrawingLayerImport( pModel, xInputStream, xComponent, "com.sun.star.comp.Draw.XMLOasisImporter" );
+}
+
+sal_Bool SvxDrawingLayerImport( SdrModel* pModel, const uno::Reference<io::XInputStream>& xInputStream, const Reference< lang::XComponent >& xComponent, const char* pImportService )
+{
+ sal_uInt32 nRet = 0;
+
+ Reference< document::XGraphicObjectResolver > xGraphicResolver;
+ SvXMLGraphicHelper *pGraphicHelper = 0;
+
+ Reference< document::XEmbeddedObjectResolver > xObjectResolver;
+ SvXMLEmbeddedObjectHelper *pObjectHelper = 0;
+
+ Reference< lang::XComponent > xTargetDocument( xComponent );
+ if( !xTargetDocument.is() )
+ {
+ xTargetDocument = new SvxUnoDrawingModel( pModel );
+ pModel->setUnoModel( Reference< XInterface >::query( xTargetDocument ) );
+ }
+
+ Reference< frame::XModel > xTargetModel( xTargetDocument, UNO_QUERY );
+
+ try
+ {
+ // Get service factory
+ Reference< lang::XMultiServiceFactory > xServiceFactory = comphelper::getProcessServiceFactory();
+ DBG_ASSERT( xServiceFactory.is(), "XMLReader::Read: got no service manager" );
+
+ if( !xServiceFactory.is() )
+ nRet = 1;
+
+ if( 0 == nRet )
+ {
+ if ( xTargetModel.is() )
+ xTargetModel->lockControllers();
+
+ // -------------------------------------
+
+ pGraphicHelper = SvXMLGraphicHelper::Create( GRAPHICHELPER_MODE_READ );
+ xGraphicResolver = pGraphicHelper;
+
+ ::comphelper::IEmbeddedHelper *pPersist = pModel->GetPersist();
+ if( pPersist )
+ {
+ pObjectHelper = SvXMLEmbeddedObjectHelper::Create(
+ *pPersist,
+ EMBEDDEDOBJECTHELPER_MODE_READ );
+ xObjectResolver = pObjectHelper;
+ }
+ }
+
+ // -------------------------------------
+
+ if( 0 == nRet )
+ {
+
+ // parse
+ // prepare ParserInputSrouce
+ xml::sax::InputSource aParserInput;
+ aParserInput.aInputStream = xInputStream;
+
+ // get parser
+ Reference< xml::sax::XParser > xParser( xServiceFactory->createInstance( OUString::createFromAscii("com.sun.star.xml.sax.Parser") ), UNO_QUERY );
+ DBG_ASSERT( xParser.is(), "Can't create parser" );
+
+ // prepare filter arguments
+ Sequence<Any> aFilterArgs( 2 );
+ Any *pArgs = aFilterArgs.getArray();
+ *pArgs++ <<= xGraphicResolver;
+ *pArgs++ <<= xObjectResolver;
+
+ // get filter
+ Reference< xml::sax::XDocumentHandler > xFilter( xServiceFactory->createInstanceWithArguments( OUString::createFromAscii( pImportService ), aFilterArgs), UNO_QUERY );
+ DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
+
+ nRet = 1;
+ if( xParser.is() && xFilter.is() )
+ {
+ // connect parser and filter
+ xParser->setDocumentHandler( xFilter );
+
+ // connect model and filter
+ uno::Reference < document::XImporter > xImporter( xFilter, UNO_QUERY );
+ xImporter->setTargetDocument( xTargetDocument );
+
+ // finally, parser the stream
+ xParser->parseStream( aParserInput );
+
+ nRet = 0;
+ }
+ }
+ }
+ catch( uno::Exception& r )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if( pGraphicHelper )
+ SvXMLGraphicHelper::Destroy( pGraphicHelper );
+ xGraphicResolver = 0;
+
+ if( pObjectHelper )
+ SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
+ xObjectResolver = 0;
+
+ if ( xTargetModel.is() )
+ xTargetModel->unlockControllers();
+
+ return nRet == 0;
+}
+
+sal_Bool SvxDrawingLayerImport( SdrModel* pModel, const uno::Reference<io::XInputStream>& xInputStream )
+{
+ Reference< lang::XComponent > xComponent;
+ return SvxDrawingLayerImport( pModel, xInputStream, xComponent );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
new file mode 100644
index 000000000000..32bfaae8bbd6
--- /dev/null
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -0,0 +1,1155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <sal/macros.h>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <cppuhelper/compbase4.hxx>
+
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/streamwrap.hxx>
+#include <unotools/tempfile.hxx>
+#include <tools/debug.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <vcl/gfxlink.hxx>
+#include <vcl/metaact.hxx>
+#include <tools/zcodec.hxx>
+
+#include "svtools/filter.hxx"
+#include "xmlgrhlp.hxx"
+
+#include <algorithm>
+
+// -----------
+// - Defines -
+// -----------
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::io;
+
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+#define XML_GRAPHICSTORAGE_NAME "Pictures"
+#define XML_PACKAGE_URL_BASE "vnd.sun.star.Package:"
+#define XML_GRAPHICOBJECT_URL_BASE "vnd.sun.star.GraphicObject:"
+
+// ---------------------------
+// - SvXMLGraphicInputStream -
+// ---------------------------
+
+const MetaCommentAction* ImplCheckForEPS( GDIMetaFile& rMtf )
+{
+ static ByteString aComment( (const sal_Char*)"EPSReplacementGraphic" );
+ const MetaCommentAction* pComment = NULL;
+
+ if ( ( rMtf.GetActionCount() >= 2 )
+ && ( rMtf.FirstAction()->GetType() == META_EPS_ACTION )
+ && ( ((const MetaAction*)rMtf.GetAction( 1 ))->GetType() == META_COMMENT_ACTION )
+ && ( ((const MetaCommentAction*)rMtf.GetAction( 1 ))->GetComment() == aComment ) )
+ pComment = (const MetaCommentAction*)rMtf.GetAction( 1 );
+
+ return pComment;
+}
+
+class SvXMLGraphicInputStream : public::cppu::WeakImplHelper1< XInputStream >
+{
+private:
+
+ virtual sal_Int32 SAL_CALL readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead) throw(NotConnectedException, BufferSizeExceededException, RuntimeException);
+ virtual sal_Int32 SAL_CALL readSomeBytes(Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead) throw(NotConnectedException, BufferSizeExceededException, RuntimeException);
+ virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) throw(NotConnectedException, BufferSizeExceededException, RuntimeException);
+ virtual sal_Int32 SAL_CALL available() throw(NotConnectedException, RuntimeException);
+ virtual void SAL_CALL closeInput() throw(NotConnectedException, RuntimeException);
+
+private:
+
+ ::utl::TempFile maTmp;
+ Reference< XInputStream > mxStmWrapper;
+
+ // not available
+ SvXMLGraphicInputStream();
+ SvXMLGraphicInputStream( const SvXMLGraphicInputStream& );
+ SvXMLGraphicInputStream& operator==( SvXMLGraphicInputStream& );
+
+public:
+
+ SvXMLGraphicInputStream( const ::rtl::OUString& rGraphicId );
+ virtual ~SvXMLGraphicInputStream();
+
+ sal_Bool Exists() const { return mxStmWrapper.is(); }
+};
+
+// -----------------------------------------------------------------------------
+
+SvXMLGraphicInputStream::SvXMLGraphicInputStream( const ::rtl::OUString& rGraphicId )
+{
+ String aGraphicId( rGraphicId );
+ GraphicObject aGrfObject( ByteString( aGraphicId, RTL_TEXTENCODING_ASCII_US ) );
+
+ maTmp.EnableKillingFile();
+
+ if( aGrfObject.GetType() != GRAPHIC_NONE )
+ {
+ SvStream* pStm = ::utl::UcbStreamHelper::CreateStream( maTmp.GetURL(), STREAM_WRITE | STREAM_TRUNC );
+
+ if( pStm )
+ {
+ Graphic aGraphic( (Graphic&) aGrfObject.GetGraphic() );
+ const GfxLink aGfxLink( aGraphic.GetLink() );
+ sal_Bool bRet = sal_False;
+
+ if( aGfxLink.GetDataSize() && aGfxLink.GetData() )
+ {
+ pStm->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() );
+ bRet = ( pStm->GetError() == 0 );
+ }
+ else
+ {
+ if( aGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+ GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter();
+ String aFormat;
+
+ if( aGraphic.IsAnimated() )
+ aFormat = String( RTL_CONSTASCII_USTRINGPARAM( "gif" ) );
+ else
+ aFormat = String( RTL_CONSTASCII_USTRINGPARAM( "png" ) );
+
+ bRet = ( pFilter->ExportGraphic( aGraphic, String(), *pStm, pFilter->GetExportFormatNumberForShortName( aFormat ) ) == 0 );
+ }
+ else if( aGraphic.GetType() == GRAPHIC_GDIMETAFILE )
+ {
+ pStm->SetVersion( SOFFICE_FILEFORMAT_8 );
+ pStm->SetCompressMode( COMPRESSMODE_ZBITMAP );
+ ( (GDIMetaFile&) aGraphic.GetGDIMetaFile() ).Write( *pStm );
+ bRet = ( pStm->GetError() == 0 );
+ }
+ }
+
+ if( bRet )
+ {
+ pStm->Seek( 0 );
+ mxStmWrapper = new ::utl::OInputStreamWrapper( pStm, sal_True );
+ }
+ else
+ delete pStm;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+SvXMLGraphicInputStream::~SvXMLGraphicInputStream()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL SvXMLGraphicInputStream::readBytes( Sequence< sal_Int8 >& rData, sal_Int32 nBytesToRead )
+ throw( NotConnectedException, BufferSizeExceededException, RuntimeException )
+{
+ if( !mxStmWrapper.is() )
+ throw NotConnectedException();
+
+ return mxStmWrapper->readBytes( rData, nBytesToRead );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL SvXMLGraphicInputStream::readSomeBytes( Sequence< sal_Int8 >& rData, sal_Int32 nMaxBytesToRead )
+ throw( NotConnectedException, BufferSizeExceededException, RuntimeException )
+{
+ if( !mxStmWrapper.is() )
+ throw NotConnectedException() ;
+
+ return mxStmWrapper->readSomeBytes( rData, nMaxBytesToRead );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SvXMLGraphicInputStream::skipBytes( sal_Int32 nBytesToSkip )
+ throw( NotConnectedException, BufferSizeExceededException, RuntimeException )
+{
+ if( !mxStmWrapper.is() )
+ throw NotConnectedException() ;
+
+ mxStmWrapper->skipBytes( nBytesToSkip );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL SvXMLGraphicInputStream::available() throw( NotConnectedException, RuntimeException )
+{
+ if( !mxStmWrapper.is() )
+ throw NotConnectedException() ;
+
+ return mxStmWrapper->available();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SvXMLGraphicInputStream::closeInput() throw( NotConnectedException, RuntimeException )
+{
+ if( !mxStmWrapper.is() )
+ throw NotConnectedException() ;
+
+ mxStmWrapper->closeInput();
+}
+
+// ----------------------------
+// - SvXMLGraphicOutputStream -
+// ----------------------------
+
+class SvXMLGraphicOutputStream : public::cppu::WeakImplHelper1< XOutputStream >
+{
+private:
+
+ // XOutputStream
+ virtual void SAL_CALL writeBytes( const Sequence< sal_Int8 >& rData ) throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException );
+ virtual void SAL_CALL flush() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException );
+ virtual void SAL_CALL closeOutput() throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException );
+
+private:
+
+ ::utl::TempFile* mpTmp;
+ SvStream* mpOStm;
+ Reference< XOutputStream > mxStmWrapper;
+ GraphicObject maGrfObj;
+ sal_Bool mbClosed;
+
+ // not available
+ SvXMLGraphicOutputStream( const SvXMLGraphicOutputStream& );
+ SvXMLGraphicOutputStream& operator==( SvXMLGraphicOutputStream& );
+
+public:
+
+ SvXMLGraphicOutputStream();
+ virtual ~SvXMLGraphicOutputStream();
+
+ sal_Bool Exists() const { return mxStmWrapper.is(); }
+ const GraphicObject& GetGraphicObject();
+};
+
+// -----------------------------------------------------------------------------
+
+SvXMLGraphicOutputStream::SvXMLGraphicOutputStream() :
+ mpTmp( new ::utl::TempFile ),
+ mbClosed( sal_False )
+{
+ mpTmp->EnableKillingFile();
+
+ mpOStm = ::utl::UcbStreamHelper::CreateStream( mpTmp->GetURL(), STREAM_WRITE | STREAM_TRUNC );
+
+ if( mpOStm )
+ mxStmWrapper = new ::utl::OOutputStreamWrapper( *mpOStm );
+}
+
+// -----------------------------------------------------------------------------
+
+SvXMLGraphicOutputStream::~SvXMLGraphicOutputStream()
+{
+ delete mpTmp;
+ delete mpOStm;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SvXMLGraphicOutputStream::writeBytes( const Sequence< sal_Int8 >& rData )
+ throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
+{
+ if( !mxStmWrapper.is() )
+ throw NotConnectedException() ;
+
+ mxStmWrapper->writeBytes( rData );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SvXMLGraphicOutputStream::flush()
+ throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
+{
+ if( !mxStmWrapper.is() )
+ throw NotConnectedException() ;
+
+ mxStmWrapper->flush();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SvXMLGraphicOutputStream::closeOutput()
+ throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException )
+{
+ if( !mxStmWrapper.is() )
+ throw NotConnectedException() ;
+
+ mxStmWrapper->closeOutput();
+ mxStmWrapper = Reference< XOutputStream >();
+
+ mbClosed = sal_True;
+}
+
+// ------------------------------------------------------------------------------
+
+const GraphicObject& SvXMLGraphicOutputStream::GetGraphicObject()
+{
+ if( mbClosed && ( maGrfObj.GetType() == GRAPHIC_NONE ) && mpOStm )
+ {
+ Graphic aGraphic;
+
+ mpOStm->Seek( 0 );
+ USHORT nFormat = GRFILTER_FORMAT_DONTKNOW;
+ USHORT pDeterminedFormat = GRFILTER_FORMAT_DONTKNOW;
+ GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, String(), *mpOStm ,nFormat,&pDeterminedFormat );
+
+ if (pDeterminedFormat == GRFILTER_FORMAT_DONTKNOW)
+ {
+ //Read the first two byte to check whether it is a gzipped stream, is so it may be in wmz or emz format
+ //unzip them and try again
+
+ BYTE sFirstBytes[ 2 ];
+
+ mpOStm->Seek( STREAM_SEEK_TO_END );
+ ULONG nStreamLen = mpOStm->Tell();
+ mpOStm->Seek( 0 );
+
+ if ( !nStreamLen )
+ {
+ SvLockBytes* pLockBytes = mpOStm->GetLockBytes();
+ if ( pLockBytes )
+ pLockBytes->SetSynchronMode( TRUE );
+
+ mpOStm->Seek( STREAM_SEEK_TO_END );
+ nStreamLen = mpOStm->Tell();
+ mpOStm->Seek( 0 );
+ }
+ if( nStreamLen >= 2 )
+ {
+ //read two byte
+ mpOStm->Read( sFirstBytes, 2 );
+
+ if( sFirstBytes[0] == 0x1f && sFirstBytes[1] == 0x8b )
+ {
+ SvMemoryStream* pDest = new SvMemoryStream;
+ ZCodec aZCodec( 0x8000, 0x8000 );
+ aZCodec.BeginCompression(ZCODEC_GZ_LIB);
+ mpOStm->Seek( 0 );
+ aZCodec.Decompress( *mpOStm, *pDest );
+
+ if (aZCodec.EndCompression() && pDest )
+ {
+ pDest->Seek( STREAM_SEEK_TO_END );
+ ULONG nStreamLen_ = pDest->Tell();
+ if (nStreamLen_)
+ {
+ pDest->Seek(0L);
+ GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, String(), *pDest ,nFormat,&pDeterminedFormat );
+ }
+ }
+ delete pDest;
+ }
+ }
+ }
+
+ maGrfObj = aGraphic;
+ if( maGrfObj.GetType() != GRAPHIC_NONE )
+ {
+ delete mpOStm, mpOStm = NULL;
+ delete mpTmp, mpTmp = NULL;
+ }
+ }
+
+ return maGrfObj;
+}
+
+// ----------------------
+// - SvXMLGraphicHelper -
+// ----------------------
+
+SvXMLGraphicHelper::SvXMLGraphicHelper( SvXMLGraphicHelperMode eCreateMode ) :
+ ::cppu::WeakComponentImplHelper2< ::com::sun::star::document::XGraphicObjectResolver,
+ ::com::sun::star::document::XBinaryStreamResolver >( maMutex )
+{
+ Init( NULL, eCreateMode, sal_False );
+}
+
+SvXMLGraphicHelper::SvXMLGraphicHelper() :
+ ::cppu::WeakComponentImplHelper2< ::com::sun::star::document::XGraphicObjectResolver,
+ ::com::sun::star::document::XBinaryStreamResolver >( maMutex )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SvXMLGraphicHelper::~SvXMLGraphicHelper()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SvXMLGraphicHelper::disposing()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SvXMLGraphicHelper::ImplGetStreamNames( const ::rtl::OUString& rURLStr,
+ ::rtl::OUString& rPictureStorageName,
+ ::rtl::OUString& rPictureStreamName )
+{
+ String aURLStr( rURLStr );
+ sal_Bool bRet = sal_False;
+
+ if( aURLStr.Len() )
+ {
+ aURLStr = aURLStr.GetToken( aURLStr.GetTokenCount( ':' ) - 1, ':' );
+ const sal_uInt32 nTokenCount = aURLStr.GetTokenCount( '/' );
+
+ if( 1 == nTokenCount )
+ {
+ rPictureStorageName = String( RTL_CONSTASCII_USTRINGPARAM( XML_GRAPHICSTORAGE_NAME ) );
+ rPictureStreamName = aURLStr;
+ bRet = sal_True;
+ }
+ else if( 2 == nTokenCount )
+ {
+ rPictureStorageName = aURLStr.GetToken( 0, '/' );
+
+ DBG_ASSERT( rPictureStorageName.getLength() &&
+ rPictureStorageName.getStr()[ 0 ] != '#',
+ "invalid relative URL" );
+
+ rPictureStreamName = aURLStr.GetToken( 1, '/' );
+ bRet = sal_True;
+ }
+ else
+ {
+ DBG_ERROR( "SvXMLGraphicHelper::ImplInsertGraphicURL: invalid scheme" );
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference < embed::XStorage > SvXMLGraphicHelper::ImplGetGraphicStorage( const ::rtl::OUString& rStorageName )
+{
+ uno::Reference < embed::XStorage > xRetStorage;
+ if( mxRootStorage.is() )
+ {
+ try
+ {
+ xRetStorage = mxRootStorage->openStorageElement(
+ maCurStorageName = rStorageName,
+ ( GRAPHICHELPER_MODE_WRITE == meCreateMode )
+ ? embed::ElementModes::READWRITE
+ : embed::ElementModes::READ );
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ //#i43196# try again to open the storage element - this time readonly
+ if(!xRetStorage.is())
+ {
+ try
+ {
+ xRetStorage = mxRootStorage->openStorageElement( maCurStorageName = rStorageName, embed::ElementModes::READ );
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+ }
+
+ return xRetStorage;
+}
+
+// -----------------------------------------------------------------------------
+
+SvxGraphicHelperStream_Impl SvXMLGraphicHelper::ImplGetGraphicStream( const ::rtl::OUString& rPictureStorageName,
+ const ::rtl::OUString& rPictureStreamName,
+ BOOL bTruncate )
+{
+ SvxGraphicHelperStream_Impl aRet;
+ aRet.xStorage = ImplGetGraphicStorage( rPictureStorageName );
+
+ if( aRet.xStorage.is() )
+ {
+ sal_Int32 nMode = embed::ElementModes::READ;
+ if ( GRAPHICHELPER_MODE_WRITE == meCreateMode )
+ {
+ nMode = embed::ElementModes::READWRITE;
+ if ( bTruncate )
+ nMode |= embed::ElementModes::TRUNCATE;
+ }
+
+ aRet.xStream = aRet.xStorage->openStreamElement( rPictureStreamName, nMode );
+ if( aRet.xStream.is() && ( GRAPHICHELPER_MODE_WRITE == meCreateMode ) )
+ {
+//REMOVE ::rtl::OUString aPropName( RTL_CONSTASCII_USTRINGPARAM("Encrypted") );
+ ::rtl::OUString aPropName( RTL_CONSTASCII_USTRINGPARAM("UseCommonStoragePasswordEncryption") );
+ uno::Reference < beans::XPropertySet > xProps( aRet.xStream, uno::UNO_QUERY );
+ xProps->setPropertyValue( aPropName, uno::makeAny( sal_True) );
+ }
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+String SvXMLGraphicHelper::ImplGetGraphicMimeType( const String& rFileName ) const
+{
+ struct XMLGraphicMimeTypeMapper
+ {
+ const char* pExt;
+ const char* pMimeType;
+ };
+
+ static XMLGraphicMimeTypeMapper aMapper[] =
+ {
+ { "gif", "image/gif" },
+ { "png", "image/png" },
+ { "jpg", "image/jpeg" },
+ { "tif", "image/tiff" }
+ };
+
+ String aMimeType;
+
+ if( ( rFileName.Len() >= 4 ) && ( rFileName.GetChar( rFileName.Len() - 4 ) == '.' ) )
+ {
+ const ByteString aExt( rFileName.Copy( rFileName.Len() - 3 ), RTL_TEXTENCODING_ASCII_US );
+
+ for( long i = 0, nCount = SAL_N_ELEMENTS( aMapper ); ( i < nCount ) && !aMimeType.Len(); i++ )
+ if( aExt == aMapper[ i ].pExt )
+ aMimeType = String( aMapper[ i ].pMimeType, RTL_TEXTENCODING_ASCII_US );
+ }
+
+ return aMimeType;
+}
+
+// -----------------------------------------------------------------------------
+
+Graphic SvXMLGraphicHelper::ImplReadGraphic( const ::rtl::OUString& rPictureStorageName,
+ const ::rtl::OUString& rPictureStreamName )
+{
+ Graphic aGraphic;
+ SvxGraphicHelperStream_Impl aStream( ImplGetGraphicStream( rPictureStorageName, rPictureStreamName, FALSE ) );
+ if( aStream.xStream.is() )
+ {
+ SvStream* pStream = utl::UcbStreamHelper::CreateStream( aStream.xStream );
+ GraphicFilter::GetGraphicFilter()->ImportGraphic( aGraphic, String(), *pStream );
+ delete pStream;
+ }
+
+ return aGraphic;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SvXMLGraphicHelper::ImplWriteGraphic( const ::rtl::OUString& rPictureStorageName,
+ const ::rtl::OUString& rPictureStreamName,
+ const ::rtl::OUString& rGraphicId )
+{
+ String aGraphicId( rGraphicId );
+ GraphicObject aGrfObject( ByteString( aGraphicId, RTL_TEXTENCODING_ASCII_US ) );
+ sal_Bool bRet = sal_False;
+
+ if( aGrfObject.GetType() != GRAPHIC_NONE )
+ {
+ SvxGraphicHelperStream_Impl aStream( ImplGetGraphicStream( rPictureStorageName, rPictureStreamName, FALSE ) );
+ if( aStream.xStream.is() )
+ {
+ Graphic aGraphic( (Graphic&) aGrfObject.GetGraphic() );
+ const GfxLink aGfxLink( aGraphic.GetLink() );
+ const ::rtl::OUString aMimeType( ImplGetGraphicMimeType( rPictureStreamName ) );
+ uno::Any aAny;
+ uno::Reference < beans::XPropertySet > xProps( aStream.xStream, uno::UNO_QUERY );
+
+ // set stream properties (MediaType/Compression)
+ if( aMimeType.getLength() )
+ {
+ aAny <<= aMimeType;
+ xProps->setPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "MediaType" ) ), aAny );
+ }
+
+ const sal_Bool bCompressed = ( ( 0 == aMimeType.getLength() ) || ( aMimeType == ::rtl::OUString::createFromAscii( "image/tiff" ) ) );
+ aAny <<= bCompressed;
+ xProps->setPropertyValue( String( RTL_CONSTASCII_USTRINGPARAM( "Compressed" ) ), aAny );
+
+ SvStream* pStream = utl::UcbStreamHelper::CreateStream( aStream.xStream );
+ if( aGfxLink.GetDataSize() && aGfxLink.GetData() )
+ pStream->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() );
+ else
+ {
+ if( aGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+ GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter();
+ String aFormat;
+
+ if( aGraphic.IsAnimated() )
+ aFormat = String( RTL_CONSTASCII_USTRINGPARAM( "gif" ) );
+ else
+ aFormat = String( RTL_CONSTASCII_USTRINGPARAM( "png" ) );
+
+ bRet = ( pFilter->ExportGraphic( aGraphic, String(), *pStream,
+ pFilter->GetExportFormatNumberForShortName( aFormat ) ) == 0 );
+ }
+ else if( aGraphic.GetType() == GRAPHIC_GDIMETAFILE )
+ {
+ pStream->SetVersion( SOFFICE_FILEFORMAT_8 );
+ pStream->SetCompressMode( COMPRESSMODE_ZBITMAP );
+
+ // SJ: first check if this metafile is just a eps file, then we will store the eps instead of svm
+ GDIMetaFile& rMtf( (GDIMetaFile&)aGraphic.GetGDIMetaFile() );
+ const MetaCommentAction* pComment = ImplCheckForEPS( rMtf );
+ if ( pComment )
+ {
+ sal_uInt32 nSize = pComment->GetDataSize();
+ const BYTE* pData = pComment->GetData();
+ if ( nSize && pData )
+ pStream->Write( pData, nSize );
+
+ const MetaEPSAction* pAct = ( (const MetaEPSAction*)rMtf.FirstAction() );
+ const GfxLink& rLink = pAct->GetLink();
+
+ pStream->Write( rLink.GetData(), rLink.GetDataSize() );
+ }
+ else
+ rMtf.Write( *pStream );
+
+ bRet = ( pStream->GetError() == 0 );
+ }
+ }
+ uno::Reference < embed::XTransactedObject > xStorage(
+ aStream.xStorage, uno::UNO_QUERY);
+ delete pStream;
+ aStream.xStream->getOutputStream()->closeOutput();
+ if( xStorage.is() )
+ xStorage->commit();
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SvXMLGraphicHelper::ImplInsertGraphicURL( const ::rtl::OUString& rURLStr, sal_uInt32 nInsertPos, rtl::OUString& rRequestedFileName )
+{
+ rtl::OUString aURLString( rURLStr );
+ ::rtl::OUString aPictureStorageName, aPictureStreamName;
+ if( ( maURLSet.find( aURLString ) != maURLSet.end() ) )
+ {
+ URLPairVector::iterator aIter( maGrfURLs.begin() ), aEnd( maGrfURLs.end() );
+ while( aIter != aEnd )
+ {
+ if( aURLString == (*aIter).first )
+ {
+ maGrfURLs[ nInsertPos ].second = (*aIter).second;
+ aIter = aEnd;
+ }
+ else
+ aIter++;
+ }
+ }
+ else if( ImplGetStreamNames( aURLString, aPictureStorageName, aPictureStreamName ) )
+ {
+ URLPair& rURLPair = maGrfURLs[ nInsertPos ];
+
+ if( GRAPHICHELPER_MODE_READ == meCreateMode )
+ {
+ const GraphicObject aObj( ImplReadGraphic( aPictureStorageName, aPictureStreamName ) );
+
+ if( aObj.GetType() != GRAPHIC_NONE )
+ {
+ const static ::rtl::OUString aBaseURL( RTL_CONSTASCII_USTRINGPARAM( XML_GRAPHICOBJECT_URL_BASE ) );
+
+ maGrfObjs.push_back( aObj );
+ rURLPair.second = aBaseURL;
+ rURLPair.second += String( aObj.GetUniqueID().GetBuffer(), RTL_TEXTENCODING_ASCII_US );
+ }
+ else
+ rURLPair.second = String();
+ }
+ else
+ {
+ const String aGraphicObjectId( aPictureStreamName );
+ const GraphicObject aGrfObject( ByteString( aGraphicObjectId, RTL_TEXTENCODING_ASCII_US ) );
+
+ if( aGrfObject.GetType() != GRAPHIC_NONE )
+ {
+ String aStreamName( aGraphicObjectId );
+ Graphic aGraphic( (Graphic&) aGrfObject.GetGraphic() );
+ const GfxLink aGfxLink( aGraphic.GetLink() );
+ String aExtension;
+
+ if( aGfxLink.GetDataSize() )
+ {
+ switch( aGfxLink.GetType() )
+ {
+ case( GFX_LINK_TYPE_EPS_BUFFER ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".eps" ) ); break;
+ case( GFX_LINK_TYPE_NATIVE_GIF ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".gif" ) ); break;
+ case( GFX_LINK_TYPE_NATIVE_JPG ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".jpg" ) ); break;
+ case( GFX_LINK_TYPE_NATIVE_PNG ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".png" ) ); break;
+ case( GFX_LINK_TYPE_NATIVE_TIF ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".tif" ) ); break;
+ case( GFX_LINK_TYPE_NATIVE_WMF ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".wmf" ) ); break;
+ case( GFX_LINK_TYPE_NATIVE_MET ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".met" ) ); break;
+ case( GFX_LINK_TYPE_NATIVE_PCT ): aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".pct" ) ); break;
+
+ default:
+ aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".grf" ) );
+ break;
+ }
+ }
+ else
+ {
+ if( aGrfObject.GetType() == GRAPHIC_BITMAP )
+ {
+ if( aGrfObject.IsAnimated() )
+ aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".gif" ) );
+ else
+ aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".png" ) );
+ }
+ else if( aGrfObject.GetType() == GRAPHIC_GDIMETAFILE )
+ {
+ // SJ: first check if this metafile is just a eps file, then we will store the eps instead of svm
+ GDIMetaFile& rMtf( (GDIMetaFile&)aGraphic.GetGDIMetaFile() );
+ if ( ImplCheckForEPS( rMtf ) )
+ aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".eps" ) );
+ else
+ aExtension = String( RTL_CONSTASCII_USTRINGPARAM( ".svm" ) );
+ }
+ }
+
+ rtl::OUString aURLEntry;
+ const String sPictures( RTL_CONSTASCII_USTRINGPARAM( "Pictures/" ) );
+
+ if ( rRequestedFileName.getLength() )
+ {
+ aURLEntry = sPictures;
+ aURLEntry += rRequestedFileName;
+ aURLEntry += aExtension;
+
+ URLPairVector::iterator aIter( maGrfURLs.begin() ), aEnd( maGrfURLs.end() );
+ while( aIter != aEnd )
+ {
+ if( aURLEntry == (*aIter).second )
+ break;
+ aIter++;
+ }
+ if ( aIter == aEnd )
+ aStreamName = rRequestedFileName;
+ }
+
+ aStreamName += aExtension;
+
+ if( mbDirect && aStreamName.Len() )
+ ImplWriteGraphic( aPictureStorageName, aStreamName, aGraphicObjectId );
+
+ rURLPair.second = sPictures;
+ rURLPair.second += aStreamName;
+ }
+ }
+
+ maURLSet.insert( aURLString );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SvXMLGraphicHelper::Init( const uno::Reference < embed::XStorage >& rXMLStorage,
+ SvXMLGraphicHelperMode eCreateMode,
+ BOOL bDirect )
+{
+ mxRootStorage = rXMLStorage;
+ meCreateMode = eCreateMode;
+ mbDirect = ( ( GRAPHICHELPER_MODE_READ == meCreateMode ) ? bDirect : sal_True );
+}
+
+// -----------------------------------------------------------------------------
+
+SvXMLGraphicHelper* SvXMLGraphicHelper::Create( const uno::Reference < embed::XStorage >& rXMLStorage,
+ SvXMLGraphicHelperMode eCreateMode,
+ BOOL bDirect )
+{
+ SvXMLGraphicHelper* pThis = new SvXMLGraphicHelper;
+
+ pThis->acquire();
+ pThis->Init( rXMLStorage, eCreateMode, bDirect );
+
+ return pThis;
+}
+
+// -----------------------------------------------------------------------------
+
+SvXMLGraphicHelper* SvXMLGraphicHelper::Create( SvXMLGraphicHelperMode eCreateMode )
+{
+ SvXMLGraphicHelper* pThis = new SvXMLGraphicHelper;
+
+ pThis->acquire();
+ pThis->Init( NULL, eCreateMode, sal_False );
+
+ return pThis;
+}
+
+// -----------------------------------------------------------------------------
+
+void SvXMLGraphicHelper::Destroy( SvXMLGraphicHelper* pSvXMLGraphicHelper )
+{
+ if( pSvXMLGraphicHelper )
+ {
+ pSvXMLGraphicHelper->dispose();
+ pSvXMLGraphicHelper->release();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+// XGraphicObjectResolver
+::rtl::OUString SAL_CALL SvXMLGraphicHelper::resolveGraphicObjectURL( const ::rtl::OUString& rURL )
+ throw(uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ const sal_Int32 nIndex = maGrfURLs.size();
+
+ rtl::OUString aURL( rURL );
+ rtl::OUString aUserData;
+ rtl::OUString aRequestedFileName;
+
+ sal_Int32 nUser = rURL.indexOf( '?', 0 );
+ if ( nUser >= 0 )
+ {
+ aURL = rtl::OUString( rURL.copy( 0, nUser ) );
+ nUser++;
+ aUserData = rURL.copy( nUser, rURL.getLength() - nUser );
+ }
+ if ( aUserData.getLength() )
+ {
+ sal_Int32 nIndex2 = 0;
+ do
+ {
+ rtl::OUString aToken = aUserData.getToken( 0, ';', nIndex2 );
+ sal_Int32 n = aToken.indexOf( '=' );
+ if ( ( n > 0 ) && ( ( n + 1 ) < aToken.getLength() ) )
+ {
+ rtl::OUString aParam( aToken.copy( 0, n ) );
+ rtl::OUString aValue( aToken.copy( n + 1, aToken.getLength() - ( n + 1 ) ) );
+
+ const rtl::OUString sRequestedName( RTL_CONSTASCII_USTRINGPARAM("requestedName") );
+ if ( aParam.match( sRequestedName ) )
+ aRequestedFileName = aValue;
+ }
+ }
+ while ( nIndex2 >= 0 );
+ }
+
+ maGrfURLs.push_back( ::std::make_pair( aURL, ::rtl::OUString() ) );
+ ImplInsertGraphicURL( aURL, nIndex, aRequestedFileName );
+
+ return maGrfURLs[ nIndex ].second;
+}
+
+// -----------------------------------------------------------------------------
+
+// XBinaryStreamResolver
+Reference< XInputStream > SAL_CALL SvXMLGraphicHelper::getInputStream( const ::rtl::OUString& rURL )
+ throw( RuntimeException )
+{
+ Reference< XInputStream > xRet;
+ ::rtl::OUString aPictureStorageName, aGraphicId;
+
+
+ if( ( GRAPHICHELPER_MODE_WRITE == meCreateMode ) &&
+ ImplGetStreamNames( rURL, aPictureStorageName, aGraphicId ) )
+ {
+ SvXMLGraphicInputStream* pInputStream = new SvXMLGraphicInputStream( aGraphicId );
+
+ if( pInputStream->Exists() )
+ xRet = pInputStream;
+ else
+ delete pInputStream;
+ }
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+Reference< XOutputStream > SAL_CALL SvXMLGraphicHelper::createOutputStream()
+ throw( RuntimeException )
+{
+ Reference< XOutputStream > xRet;
+
+ if( GRAPHICHELPER_MODE_READ == meCreateMode )
+ {
+ SvXMLGraphicOutputStream* pOutputStream = new SvXMLGraphicOutputStream;
+
+ if( pOutputStream->Exists() )
+ maGrfStms.push_back( xRet = pOutputStream );
+ else
+ delete pOutputStream;
+ }
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL SvXMLGraphicHelper::resolveOutputStream( const Reference< XOutputStream >& rxBinaryStream )
+ throw( RuntimeException )
+{
+ ::rtl::OUString aRet;
+
+ if( ( GRAPHICHELPER_MODE_READ == meCreateMode ) && rxBinaryStream.is() )
+ {
+ if( ::std::find( maGrfStms.begin(), maGrfStms.end(), rxBinaryStream ) != maGrfStms.end() )
+ {
+ SvXMLGraphicOutputStream* pOStm = static_cast< SvXMLGraphicOutputStream* >( rxBinaryStream.get() );
+
+ if( pOStm )
+ {
+ const GraphicObject& rGrfObj = pOStm->GetGraphicObject();
+ const ::rtl::OUString aId( ::rtl::OUString::createFromAscii( rGrfObj.GetUniqueID().GetBuffer() ) );
+
+ if( aId.getLength() )
+ {
+ aRet = ::rtl::OUString::createFromAscii( XML_GRAPHICOBJECT_URL_BASE );
+ aRet += aId;
+ }
+ }
+ }
+ }
+
+ return aRet;
+}
+
+
+// --------------------------------------------------------------------------------
+
+// for instantiation via service manager
+namespace svx
+{
+
+namespace impl
+{
+typedef ::cppu::WeakComponentImplHelper4<
+ lang::XInitialization,
+ document::XGraphicObjectResolver,
+ document::XBinaryStreamResolver,
+ lang::XServiceInfo >
+ SvXMLGraphicImportExportHelper_Base;
+class MutexContainer
+{
+public:
+ virtual ~MutexContainer();
+
+protected:
+ mutable ::osl::Mutex m_aMutex;
+};
+MutexContainer::~MutexContainer()
+{}
+} // namespace impl
+
+class SvXMLGraphicImportExportHelper :
+ public impl::MutexContainer,
+ public impl::SvXMLGraphicImportExportHelper_Base
+{
+public:
+ SvXMLGraphicImportExportHelper( SvXMLGraphicHelperMode eMode );
+
+protected:
+ // is called from WeakComponentImplHelper when XComponent::dispose() was
+ // called from outside
+ virtual void SAL_CALL disposing();
+
+ // ____ XInitialization ____
+ // one argument is allowed, which is the XStorage
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments )
+ throw (Exception,
+ RuntimeException);
+
+ // ____ XGraphicObjectResolver ____
+ virtual ::rtl::OUString SAL_CALL resolveGraphicObjectURL( const ::rtl::OUString& aURL )
+ throw (RuntimeException);
+
+ // ____ XBinaryStreamResolver ____
+ virtual Reference< io::XInputStream > SAL_CALL getInputStream( const ::rtl::OUString& aURL )
+ throw (RuntimeException);
+ virtual Reference< io::XOutputStream > SAL_CALL createOutputStream()
+ throw (RuntimeException);
+ virtual ::rtl::OUString SAL_CALL resolveOutputStream( const Reference< io::XOutputStream >& aBinaryStream )
+ throw (RuntimeException);
+
+ // ____ XServiceInfo ____
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (RuntimeException);
+
+private:
+ SvXMLGraphicHelperMode m_eGraphicHelperMode;
+ Reference< XGraphicObjectResolver > m_xGraphicObjectResolver;
+ Reference< XBinaryStreamResolver > m_xBinaryStreamResolver;
+};
+
+SvXMLGraphicImportExportHelper::SvXMLGraphicImportExportHelper( SvXMLGraphicHelperMode eMode ) :
+ impl::SvXMLGraphicImportExportHelper_Base( m_aMutex ),
+ m_eGraphicHelperMode( eMode )
+{}
+
+void SAL_CALL SvXMLGraphicImportExportHelper::disposing()
+{
+ Reference< XComponent > xComp( m_xGraphicObjectResolver, UNO_QUERY );
+ OSL_ASSERT( xComp.is());
+ if( xComp.is())
+ xComp->dispose();
+ // m_xBinaryStreamResolver is a reference to the same object => don't call
+ // dispose() again
+}
+
+// ____ XInitialization ____
+void SAL_CALL SvXMLGraphicImportExportHelper::initialize(
+ const Sequence< Any >& aArguments )
+ throw (Exception, RuntimeException)
+{
+ Reference< embed::XStorage > xStorage;
+ if( aArguments.getLength() > 0 )
+ aArguments[0] >>= xStorage;
+
+ SvXMLGraphicHelper * pHelper( SvXMLGraphicHelper::Create( xStorage, m_eGraphicHelperMode ));
+ m_xGraphicObjectResolver.set( pHelper );
+ m_xBinaryStreamResolver.set( pHelper );
+ // SvXMLGraphicHelper::Create calls acquire. Since we have two references
+ // now it is safe (and necessary) to undo this acquire
+ pHelper->release();
+}
+
+// ____ XGraphicObjectResolver ____
+::rtl::OUString SAL_CALL SvXMLGraphicImportExportHelper::resolveGraphicObjectURL( const ::rtl::OUString& aURL )
+ throw (uno::RuntimeException)
+{
+ return m_xGraphicObjectResolver->resolveGraphicObjectURL( aURL );
+}
+
+
+// ____ XBinaryStreamResolver ____
+Reference< io::XInputStream > SAL_CALL SvXMLGraphicImportExportHelper::getInputStream( const ::rtl::OUString& aURL )
+ throw (uno::RuntimeException)
+{
+ return m_xBinaryStreamResolver->getInputStream( aURL );
+}
+Reference< io::XOutputStream > SAL_CALL SvXMLGraphicImportExportHelper::createOutputStream()
+ throw (uno::RuntimeException)
+{
+ return m_xBinaryStreamResolver->createOutputStream();
+}
+::rtl::OUString SAL_CALL SvXMLGraphicImportExportHelper::resolveOutputStream( const Reference< io::XOutputStream >& aBinaryStream )
+ throw (uno::RuntimeException)
+{
+ return m_xBinaryStreamResolver->resolveOutputStream( aBinaryStream );
+}
+
+// ____ XServiceInfo ____
+::rtl::OUString SAL_CALL SvXMLGraphicImportExportHelper::getImplementationName()
+ throw (uno::RuntimeException)
+{
+ if( m_eGraphicHelperMode == GRAPHICHELPER_MODE_READ )
+ return SvXMLGraphicImportHelper_getImplementationName();
+ return SvXMLGraphicExportHelper_getImplementationName();
+}
+::sal_Bool SAL_CALL SvXMLGraphicImportExportHelper::supportsService( const ::rtl::OUString& ServiceName )
+ throw (uno::RuntimeException)
+{
+ Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames());
+ const ::rtl::OUString * pBegin = aServiceNames.getConstArray();
+ const ::rtl::OUString * pEnd = pBegin + aServiceNames.getLength();
+ return (::std::find( pBegin, pEnd, ServiceName ) != pEnd);
+}
+Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicImportExportHelper::getSupportedServiceNames()
+ throw (uno::RuntimeException)
+{
+ if( m_eGraphicHelperMode == GRAPHICHELPER_MODE_READ )
+ return SvXMLGraphicImportHelper_getSupportedServiceNames();
+ return SvXMLGraphicExportHelper_getSupportedServiceNames();
+}
+
+// import
+Reference< XInterface > SAL_CALL SvXMLGraphicImportHelper_createInstance(const Reference< XMultiServiceFactory > & /* rSMgr */ )
+ throw( Exception )
+{
+ return static_cast< XWeak* >( new SvXMLGraphicImportExportHelper( GRAPHICHELPER_MODE_READ ));
+}
+::rtl::OUString SAL_CALL SvXMLGraphicImportHelper_getImplementationName()
+ throw()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Svx.GraphicImportHelper" ));
+}
+Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicImportHelper_getSupportedServiceNames()
+ throw()
+{
+ // XGraphicObjectResolver and XBinaryStreamResolver are not part of any service
+ Sequence< ::rtl::OUString > aSupportedServiceNames( 2 );
+ aSupportedServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.GraphicObjectResolver" ) );
+ aSupportedServiceNames[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.BinaryStreamResolver" ) );
+ return aSupportedServiceNames;
+}
+
+// export
+Reference< XInterface > SAL_CALL SvXMLGraphicExportHelper_createInstance(const Reference< XMultiServiceFactory > & /* rSMgr */ )
+ throw( Exception )
+{
+ return static_cast< XWeak* >( new SvXMLGraphicImportExportHelper( GRAPHICHELPER_MODE_WRITE ));
+}
+::rtl::OUString SAL_CALL SvXMLGraphicExportHelper_getImplementationName()
+ throw()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Svx.GraphicExportHelper" ));
+}
+Sequence< ::rtl::OUString > SAL_CALL SvXMLGraphicExportHelper_getSupportedServiceNames()
+ throw()
+{
+ // XGraphicObjectResolver and XBinaryStreamResolver are not part of any service
+ Sequence< ::rtl::OUString > aSupportedServiceNames( 2 );
+ aSupportedServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.GraphicObjectResolver" ) );
+ aSupportedServiceNames[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.BinaryStreamResolver" ) );
+ return aSupportedServiceNames;
+}
+
+} // namespace svx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xml/xmlxtexp.cxx b/svx/source/xml/xmlxtexp.cxx
new file mode 100644
index 000000000000..6ac4cc03fb21
--- /dev/null
+++ b/svx/source/xml/xmlxtexp.cxx
@@ -0,0 +1,495 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/drawing/Hatch.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <sfx2/docfile.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <xmloff/xmluconv.hxx>
+#include "xmloff/xmlnmspe.hxx"
+#include "xmloff/nmspmap.hxx"
+
+#include "xmloff/xmltoken.hxx"
+#include "xmloff/xmlmetae.hxx"
+#include "xmloff/DashStyle.hxx"
+#include "xmloff/GradientStyle.hxx"
+#include "xmloff/HatchStyle.hxx"
+#include "xmloff/ImageStyle.hxx"
+#include "xmloff/MarkerStyle.hxx"
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <comphelper/processfactory.hxx>
+#include <unotools/streamwrap.hxx>
+#include "xmlgrhlp.hxx"
+
+#include "xmlxtexp.hxx"
+
+#include <comphelper/storagehelper.hxx>
+
+using namespace com::sun::star;
+using namespace com::sun::star::container;
+using namespace com::sun::star::document;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::awt;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::xml::sax;
+using namespace ::xmloff::token;
+using namespace ::rtl;
+using namespace cppu;
+
+using com::sun::star::embed::XTransactedObject;
+
+class SvxXMLTableEntryExporter
+{
+public:
+ SvxXMLTableEntryExporter( SvXMLExport& rExport ) : mrExport( rExport ) {}
+ virtual ~SvxXMLTableEntryExporter();
+
+ virtual void exportEntry( const OUString& rStrName, const Any& rValue ) = 0;
+
+protected:
+ SvXMLExport& mrExport;
+};
+
+class SvxXMLColorEntryExporter : public SvxXMLTableEntryExporter
+{
+public:
+ SvxXMLColorEntryExporter( SvXMLExport& rExport );
+ virtual ~SvxXMLColorEntryExporter();
+
+ virtual void exportEntry( const OUString& rStrName, const Any& rValue );
+};
+
+class SvxXMLLineEndEntryExporter : public SvxXMLTableEntryExporter
+{
+public:
+ SvxXMLLineEndEntryExporter( SvXMLExport& rExport );
+ SvxXMLLineEndEntryExporter();
+ virtual ~SvxXMLLineEndEntryExporter();
+
+ virtual void exportEntry( const OUString& rStrName, const Any& rValue );
+private:
+ XMLMarkerStyleExport maMarkerStyle;
+};
+
+class SvxXMLDashEntryExporter : public SvxXMLTableEntryExporter
+{
+public:
+ SvxXMLDashEntryExporter( SvXMLExport& rExport );
+ virtual ~SvxXMLDashEntryExporter();
+
+ virtual void exportEntry( const OUString& rStrName, const Any& rValue );
+
+private:
+ XMLDashStyleExport maDashStyle;
+};
+
+class SvxXMLHatchEntryExporter : public SvxXMLTableEntryExporter
+{
+public:
+ SvxXMLHatchEntryExporter( SvXMLExport& rExport );
+ virtual ~SvxXMLHatchEntryExporter();
+
+ virtual void exportEntry( const OUString& rStrName, const Any& rValue );
+private:
+ XMLHatchStyleExport maHatchStyle;
+};
+
+class SvxXMLGradientEntryExporter : public SvxXMLTableEntryExporter
+{
+public:
+ SvxXMLGradientEntryExporter( SvXMLExport& rExport );
+ virtual ~SvxXMLGradientEntryExporter();
+
+ virtual void exportEntry( const OUString& rStrName, const Any& rValue );
+private:
+ XMLGradientStyleExport maGradientStyle;
+};
+
+class SvxXMLBitmapEntryExporter : public SvxXMLTableEntryExporter
+{
+public:
+ SvxXMLBitmapEntryExporter( SvXMLExport& rExport );
+ virtual ~SvxXMLBitmapEntryExporter();
+
+ virtual void exportEntry( const OUString& rStrName, const Any& rValue );
+
+private:
+ XMLImageStyle maImageStyle;
+};
+
+///////////////////////////////////////////////////////////////////////
+
+// #110680#
+SvxXMLXTableExportComponent::SvxXMLXTableExportComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ const OUString& rFileName,
+ const uno::Reference<xml::sax::XDocumentHandler> & rHandler,
+ const uno::Reference<container::XNameContainer >& xTable,
+ uno::Reference<document::XGraphicObjectResolver >& xGrfResolver )
+: SvXMLExport( xServiceFactory, rFileName, rHandler, NULL, MAP_100TH_MM),
+ mxTable( xTable )
+{
+
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_OOO), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_OFFICE), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE );
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_DRAW), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW );
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_XLINK), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
+ _GetNamespaceMap().Add( GetXMLToken(XML_NP_SVG), GetXMLToken(XML_N_SVG), XML_NAMESPACE_SVG );
+ SetGraphicResolver( xGrfResolver );
+ setExportFlags( 0 );
+}
+
+SvxXMLXTableExportComponent::~SvxXMLXTableExportComponent()
+{
+}
+
+sal_Bool SvxXMLXTableExportComponent::save( const OUString& rURL, const uno::Reference<container::XNameContainer >& xTable ) throw()
+{
+ uno::Reference < embed::XStorage > xStorage;
+ SfxMedium* pMedium = NULL;
+ sal_Bool bRet = sal_False;
+
+ uno::Reference< XGraphicObjectResolver > xGrfResolver;
+ SvXMLGraphicHelper* pGraphicHelper = 0;
+
+ try
+ {
+ do
+ {
+ uno::Reference < io::XOutputStream > xOut;
+ uno::Reference < io::XStream > xStream;
+
+ sal_Bool bNeedStorage = xTable->getElementType() == ::getCppuType((const OUString*)0);
+
+ uno::Reference< lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
+ if( !xServiceFactory.is() )
+ {
+ DBG_ERROR( "got no service manager" );
+ return FALSE;
+ }
+
+ uno::Reference< uno::XInterface > xWriter( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ) ) ) );
+ if( !xWriter.is() )
+ {
+ DBG_ERROR( "com.sun.star.xml.sax.Writer service missing" );
+ return FALSE;
+ }
+
+ uno::Reference<xml::sax::XDocumentHandler> xHandler( xWriter, uno::UNO_QUERY );
+
+ if( bNeedStorage )
+ {
+ xStorage =
+ ::comphelper::OStorageHelper::GetStorageFromURL( rURL, embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE );
+
+ if( !xStorage.is() )
+ {
+ DBG_ERROR( "no storage!" );
+ break;
+ }
+
+ OUString sMetaName( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) );
+ xStream = xStorage->openStreamElement( sMetaName, embed::ElementModes::WRITE );
+ pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_WRITE );
+ xGrfResolver = pGraphicHelper;
+ xOut = xStream->getOutputStream();
+ }
+ else
+ {
+ pMedium = new SfxMedium( rURL, STREAM_WRITE | STREAM_TRUNC, TRUE );
+ pMedium->IsRemote();
+
+ SvStream* pStream = pMedium->GetOutStream();
+ if( NULL == pStream )
+ {
+ DBG_ERROR( "no output stream!" );
+ break;
+ }
+
+ xOut = new utl::OOutputStreamWrapper( *pStream );
+ }
+
+ uno::Reference<io::XActiveDataSource> xMetaSrc( xWriter, uno::UNO_QUERY );
+ xMetaSrc->setOutputStream( xOut );
+
+ const OUString aName;
+
+ // #110680#
+ // SvxXMLXTableExportComponent aExporter( aName, xHandler, xTable, xGrfResolver );
+ SvxXMLXTableExportComponent aExporter( xServiceFactory, aName, xHandler, xTable, xGrfResolver );
+
+ bRet = aExporter.exportTable();
+
+ }
+ while( 0 );
+
+ if( pGraphicHelper )
+ SvXMLGraphicHelper::Destroy( pGraphicHelper );
+
+ if( xStorage.is() )
+ {
+ uno::Reference< XTransactedObject > xTrans( xStorage, UNO_QUERY );
+ if( xTrans.is() )
+ xTrans->commit();
+
+ uno::Reference< XComponent > xComp( xStorage, UNO_QUERY );
+ if( xComp.is() )
+ xStorage->dispose();
+ }
+ }
+ catch( uno::Exception& )
+ {
+ bRet = sal_False;
+ }
+
+ if( pMedium )
+ {
+ pMedium->Commit();
+ delete pMedium;
+ }
+
+ return bRet;
+}
+
+sal_Bool SvxXMLXTableExportComponent::exportTable() throw()
+{
+ sal_Bool bRet = sal_False;
+
+ try
+ {
+ GetDocHandler()->startDocument();
+
+ // export namespaces
+ sal_uInt16 nPos = GetNamespaceMap().GetFirstKey();
+ while( USHRT_MAX != nPos )
+ {
+ GetAttrList().AddAttribute( GetNamespaceMap().GetAttrNameByKey( nPos ), GetNamespaceMap().GetNameByKey( nPos ) );
+ nPos = GetNamespaceMap().GetNextKey( nPos );
+ }
+
+ do
+ {
+ if( !mxTable.is() )
+ break;
+
+ char const* pEleName;
+ Type aExportType = mxTable->getElementType();
+ SvxXMLTableEntryExporter* pExporter = NULL;
+
+ if( aExportType == ::getCppuType((const sal_Int32*)0) )
+ {
+ pExporter = new SvxXMLColorEntryExporter(*this);
+ pEleName = "color-table";
+ }
+ else if( aExportType == ::getCppuType((const drawing::PolyPolygonBezierCoords*)0) )
+ {
+ pExporter = new SvxXMLLineEndEntryExporter(*this);
+ pEleName = "marker-table";
+ }
+ else if( aExportType == ::getCppuType((const drawing::LineDash*)0) )
+ {
+ pExporter = new SvxXMLDashEntryExporter(*this);
+ pEleName = "dash-table";
+ }
+ else if( aExportType == ::getCppuType((const drawing::Hatch*)0) )
+ {
+ pExporter = new SvxXMLHatchEntryExporter(*this);
+ pEleName = "hatch-table";
+ }
+ else if( aExportType == ::getCppuType((const awt::Gradient*)0))
+ {
+ pExporter = new SvxXMLGradientEntryExporter(*this);
+ pEleName = "gradient-table";
+ }
+ else if( aExportType == ::getCppuType((const OUString*)0))
+ {
+ pExporter = new SvxXMLBitmapEntryExporter(*this);
+ pEleName = "bitmap-table";
+ }
+ else
+ {
+ DBG_ERROR( "unknown type for export");
+ break;
+ }
+
+ SvXMLElementExport aElem( *this, XML_NAMESPACE_OOO, pEleName, sal_True, sal_True );
+
+ Sequence< OUString > aNames = mxTable->getElementNames();
+ const sal_Int32 nCount = aNames.getLength();
+ const OUString* pNames = aNames.getConstArray();
+ Any aAny;
+
+ sal_Int32 nIndex;
+ for( nIndex = 0; nIndex < nCount; nIndex++, pNames++ )
+ {
+ aAny = mxTable->getByName( *pNames );
+ pExporter->exportEntry( *pNames, aAny );
+ }
+
+ bRet = sal_True;
+ }
+ while(0);
+
+ GetDocHandler()->endDocument();
+ }
+ catch( Exception e )
+ {
+ bRet = sal_False;
+ }
+
+ return bRet;
+}
+
+// methods without content:
+void SvxXMLXTableExportComponent::_ExportAutoStyles() {}
+void SvxXMLXTableExportComponent::_ExportMasterStyles() {}
+void SvxXMLXTableExportComponent::_ExportContent() {}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxXMLTableEntryExporter::~SvxXMLTableEntryExporter()
+{
+}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxXMLColorEntryExporter::SvxXMLColorEntryExporter( SvXMLExport& rExport )
+: SvxXMLTableEntryExporter( rExport )
+{
+}
+
+SvxXMLColorEntryExporter::~SvxXMLColorEntryExporter()
+{
+}
+
+void SvxXMLColorEntryExporter::exportEntry( const OUString& rStrName, const Any& rValue )
+{
+ mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, rStrName );
+
+ sal_Int32 nColor = 0;
+ rValue >>= nColor;
+
+ OUStringBuffer aOut;
+ mrExport.GetMM100UnitConverter().convertColor( aOut, nColor );
+ mrExport.AddAttribute( XML_NAMESPACE_DRAW, XML_COLOR, aOut.makeStringAndClear() );
+
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DRAW, XML_COLOR, sal_True, sal_True );
+}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxXMLLineEndEntryExporter::SvxXMLLineEndEntryExporter( SvXMLExport& rExport )
+: SvxXMLTableEntryExporter( rExport ), maMarkerStyle( rExport )
+{
+}
+
+SvxXMLLineEndEntryExporter::~SvxXMLLineEndEntryExporter()
+{
+}
+
+void SvxXMLLineEndEntryExporter::exportEntry( const OUString& rStrName, const Any& rValue )
+{
+ maMarkerStyle.exportXML( rStrName, rValue );
+}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxXMLDashEntryExporter::SvxXMLDashEntryExporter( SvXMLExport& rExport )
+: SvxXMLTableEntryExporter( rExport ), maDashStyle( rExport )
+{
+}
+
+SvxXMLDashEntryExporter::~SvxXMLDashEntryExporter()
+{
+}
+
+void SvxXMLDashEntryExporter::exportEntry( const OUString& rStrName, const Any& rValue )
+{
+ maDashStyle.exportXML( rStrName, rValue );
+}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxXMLHatchEntryExporter::SvxXMLHatchEntryExporter( SvXMLExport& rExport )
+: SvxXMLTableEntryExporter( rExport ), maHatchStyle( rExport )
+{
+}
+
+SvxXMLHatchEntryExporter::~SvxXMLHatchEntryExporter()
+{
+}
+
+void SvxXMLHatchEntryExporter::exportEntry( const OUString& rStrName, const Any& rValue )
+{
+ maHatchStyle.exportXML( rStrName, rValue );
+}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxXMLGradientEntryExporter::SvxXMLGradientEntryExporter( SvXMLExport& rExport )
+: SvxXMLTableEntryExporter( rExport ), maGradientStyle( rExport )
+{
+}
+
+SvxXMLGradientEntryExporter::~SvxXMLGradientEntryExporter()
+{
+}
+
+void SvxXMLGradientEntryExporter::exportEntry( const OUString& rStrName, const Any& rValue )
+{
+ maGradientStyle.exportXML( rStrName, rValue );
+}
+
+///////////////////////////////////////////////////////////////////////
+
+SvxXMLBitmapEntryExporter::SvxXMLBitmapEntryExporter( SvXMLExport& rExport )
+: SvxXMLTableEntryExporter( rExport )
+{
+}
+
+SvxXMLBitmapEntryExporter::~SvxXMLBitmapEntryExporter()
+{
+}
+
+void SvxXMLBitmapEntryExporter::exportEntry( const OUString& rStrName, const Any& rValue )
+{
+ maImageStyle.exportXML( rStrName, rValue, mrExport );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xml/xmlxtimp.cxx b/svx/source/xml/xmlxtimp.cxx
new file mode 100644
index 000000000000..8e48b015df55
--- /dev/null
+++ b/svx/source/xml/xmlxtimp.cxx
@@ -0,0 +1,488 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/document/XGraphicObjectResolver.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/io/XActiveDataControl.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/drawing/Hatch.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XSeekable.hdl>
+#include <comphelper/processfactory.hxx>
+#include <unotools/streamwrap.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <sfx2/docfile.hxx>
+#include <xmloff/xmluconv.hxx>
+#include "xmloff/xmlnmspe.hxx"
+#include "xmloff/nmspmap.hxx"
+
+#include "xmloff/xmltoken.hxx"
+#include "xmloff/xmlmetae.hxx"
+#include "xmloff/DashStyle.hxx"
+#include "xmloff/GradientStyle.hxx"
+#include "xmloff/HatchStyle.hxx"
+#include "xmloff/ImageStyle.hxx"
+#include "xmloff/MarkerStyle.hxx"
+#include <xmloff/xmlictxt.hxx>
+#include "xmlgrhlp.hxx"
+#include "xmloff/attrlist.hxx"
+
+#include "xmlxtimp.hxx"
+
+using namespace com::sun::star;
+using namespace com::sun::star::container;
+using namespace com::sun::star::document;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::awt;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::xml::sax;
+using namespace ::rtl;
+using namespace ::xmloff::token;
+using namespace cppu;
+
+sal_Char __READONLY_DATA sXML_np__office[] = "__office";
+sal_Char __READONLY_DATA sXML_np__office_ooo[] = "___office";
+sal_Char __READONLY_DATA sXML_np__draw[] = "__draw";
+sal_Char __READONLY_DATA sXML_np__draw_ooo[] = "___draw";
+sal_Char __READONLY_DATA sXML_np__ooo[] = "__ooo";
+sal_Char __READONLY_DATA sXML_np__xlink[] = "__xlink";
+
+///////////////////////////////////////////////////////////////////////
+
+enum SvxXMLTableImportContextEnum { stice_unknown, stice_color, stice_marker, stice_dash, stice_hatch, stice_gradient, stice_bitmap };
+
+///////////////////////////////////////////////////////////////////////
+
+class SvxXMLTableImportContext : public SvXMLImportContext
+{
+public:
+ SvxXMLTableImportContext( SvXMLImport& rImport, USHORT nPrfx, const OUString& rLName, const uno::Reference< XAttributeList >& xAttrList, SvxXMLTableImportContextEnum eContext, const uno::Reference< XNameContainer >& xTable,
+ sal_Bool bOOoFormat );
+ virtual ~SvxXMLTableImportContext();
+
+ virtual SvXMLImportContext *CreateChildContext( USHORT nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList );
+
+ SvxXMLXTableImport& getImport() const { return *(SvxXMLXTableImport*)&GetImport(); }
+
+protected:
+ void importColor( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
+ void importMarker( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
+ void importDash( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
+ void importHatch( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
+ void importGradient( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
+ void importBitmap( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName );
+
+private:
+ uno::Reference< XNameContainer > mxTable;
+ SvxXMLTableImportContextEnum meContext;
+ sal_Bool mbOOoFormat;
+};
+
+///////////////////////////////////////////////////////////////////////
+
+SvxXMLTableImportContext::SvxXMLTableImportContext( SvXMLImport& rImport, USHORT nPrfx, const OUString& rLName, const uno::Reference< XAttributeList >&, SvxXMLTableImportContextEnum eContext, const uno::Reference< XNameContainer >& xTable, sal_Bool bOOoFormat )
+: SvXMLImportContext( rImport, nPrfx, rLName ), mxTable( xTable ), meContext( eContext ),
+ mbOOoFormat( bOOoFormat )
+{
+}
+
+SvxXMLTableImportContext::~SvxXMLTableImportContext()
+{
+}
+
+SvXMLImportContext *SvxXMLTableImportContext::CreateChildContext( USHORT nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& rAttrList )
+{
+ if( XML_NAMESPACE_DRAW == nPrefix )
+ {
+ uno::Reference< XAttributeList > xAttrList( rAttrList );
+ if( mbOOoFormat &&
+ (stice_dash == meContext || stice_hatch == meContext ||
+ stice_bitmap == meContext) )
+ {
+ SvXMLAttributeList *pAttrList = new SvXMLAttributeList( rAttrList );
+ xAttrList = pAttrList;
+ sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rAttrName = xAttrList->getNameByIndex( i );
+ OUString aLocalName;
+ sal_uInt16 nPrefix_ =
+ GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
+ &aLocalName );
+ if( XML_NAMESPACE_XLINK == nPrefix_ &&
+ stice_bitmap == meContext &&
+ IsXMLToken( aLocalName, XML_HREF ) )
+ {
+ const OUString rValue = xAttrList->getValueByIndex( i );
+ if( rValue.getLength() && '#' == rValue[0] )
+ pAttrList->SetValueByIndex( i, rValue.copy( 1 ) );
+ }
+ else if( XML_NAMESPACE_DRAW == nPrefix_ &&
+ ( ( stice_dash == meContext &&
+ (IsXMLToken( aLocalName, XML_DOTS1_LENGTH ) ||
+ IsXMLToken( aLocalName, XML_DOTS2_LENGTH ) ||
+ IsXMLToken( aLocalName, XML_DISTANCE )) ) ||
+ ( stice_hatch == meContext &&
+ IsXMLToken( aLocalName, XML_HATCH_DISTANCE ) ) ) )
+ {
+ const OUString rValue = xAttrList->getValueByIndex( i );
+ sal_Int32 nPos = rValue.getLength();
+ while( nPos && rValue[nPos-1] <= ' ' )
+ --nPos;
+ if( nPos > 2 &&
+ ('c'==rValue[nPos-2] || 'C'==rValue[nPos-2]) &&
+ ('h'==rValue[nPos-1] || 'H'==rValue[nPos-1]) )
+ {
+ pAttrList->SetValueByIndex( i, rValue.copy( 0, nPos-2 ) );
+ }
+ }
+ }
+ }
+ try
+ {
+ Any aAny;
+ OUString aName;
+
+ switch( meContext )
+ {
+ case stice_color:
+ importColor( nPrefix, rLocalName, xAttrList, aAny, aName );
+ break;
+ case stice_marker:
+ importMarker( nPrefix, rLocalName, xAttrList, aAny, aName );
+ break;
+ case stice_dash:
+ importDash( nPrefix, rLocalName, xAttrList, aAny, aName );
+ break;
+ case stice_hatch:
+ importHatch( nPrefix, rLocalName, xAttrList, aAny, aName );
+ break;
+ case stice_gradient:
+ importGradient( nPrefix, rLocalName, xAttrList, aAny, aName );
+ break;
+ case stice_bitmap:
+ importBitmap( nPrefix, rLocalName, xAttrList, aAny, aName );
+ break;
+ case stice_unknown:
+ break;
+ }
+
+ if( aName.getLength() && aAny.hasValue() )
+ {
+ if( mxTable->hasByName( aName ) )
+ {
+ mxTable->replaceByName( aName, aAny );
+ }
+ else
+ {
+ mxTable->insertByName( aName, aAny );
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+
+ return new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
+}
+
+void SvxXMLTableImportContext::importColor( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
+{
+ (void)nPrfx;
+ (void)rLocalName;
+
+ const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
+ for( sal_Int16 i=0; i < nAttrCount; i++ )
+ {
+ const OUString& rFullAttrName = xAttrList->getNameByIndex( i );
+ OUString aLocalName;
+ sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rFullAttrName, &aLocalName );
+
+
+ if( XML_NAMESPACE_DRAW == nPrefix )
+ {
+ if( aLocalName == GetXMLToken(XML_NAME) )
+ {
+ rName = xAttrList->getValueByIndex( i );
+ }
+ else if( aLocalName == GetXMLToken(XML_COLOR) )
+ {
+ Color aColor;
+ SvXMLUnitConverter::convertColor(aColor, xAttrList->getValueByIndex( i ));
+ rAny <<= (sal_Int32)aColor.GetColor();
+ }
+ }
+ }
+}
+
+void SvxXMLTableImportContext::importMarker( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
+{
+ (void)nPrfx;
+ (void)rLocalName;
+
+ try
+ {
+ XMLMarkerStyleImport aMarkerStyle( GetImport() );
+ aMarkerStyle.importXML( xAttrList, rAny, rName );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SvxXMLTableImportContext::importMarker(), exception caught!");
+ }
+}
+
+void SvxXMLTableImportContext::importDash( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
+{
+ (void)nPrfx;
+ (void)rLocalName;
+
+ try
+ {
+ XMLDashStyleImport aDashStyle( GetImport() );
+ aDashStyle.importXML( xAttrList, rAny, rName );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SvxXMLTableImportContext::importDash(), exception caught!");
+ }
+}
+
+void SvxXMLTableImportContext::importHatch( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
+{
+ (void)nPrfx;
+ (void)rLocalName;
+
+ try
+ {
+ XMLHatchStyleImport aHatchStyle( GetImport() );
+ aHatchStyle.importXML( xAttrList, rAny, rName );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SvxXMLTableImportContext::importHatch(), exception caught!");
+ }
+}
+
+void SvxXMLTableImportContext::importGradient( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
+{
+ (void)nPrfx;
+ (void)rLocalName;
+
+ try
+ {
+ XMLGradientStyleImport aGradientStyle( GetImport() );
+ aGradientStyle.importXML( xAttrList, rAny, rName );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SvxXMLTableImportContext::importGradient(), exception caught!");
+ }
+}
+
+void SvxXMLTableImportContext::importBitmap( USHORT nPrfx, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList, Any& rAny, OUString& rName )
+{
+ (void)nPrfx;
+ (void)rLocalName;
+
+ try
+ {
+ XMLImageStyle aImageStyle;
+ aImageStyle.importXML( xAttrList, rAny, rName, GetImport() );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SvxXMLTableImportContext::importBitmap(), exception caught!");
+ }
+}
+
+///////////////////////////////////////////////////////////////////////
+
+// #110680#
+SvxXMLXTableImport::SvxXMLXTableImport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ const uno::Reference< XNameContainer > & rTable,
+ uno::Reference< XGraphicObjectResolver >& xGrfResolver )
+: SvXMLImport(xServiceFactory, 0),
+ mrTable( rTable )
+{
+ SetGraphicResolver( xGrfResolver );
+
+ GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__ooo ) ), GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
+ GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office ) ), GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE );
+ GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw ) ), GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW );
+ GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__xlink ) ), GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
+
+ // OOo namespaces for reading OOo 1.1 files
+ GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__office_ooo ) ),
+ GetXMLToken(XML_N_OFFICE_OOO),
+ XML_NAMESPACE_OFFICE );
+ GetNamespaceMap().Add( OUString( RTL_CONSTASCII_USTRINGPARAM ( sXML_np__draw_ooo ) ),
+ GetXMLToken(XML_N_DRAW_OOO),
+ XML_NAMESPACE_DRAW );
+}
+
+SvxXMLXTableImport::~SvxXMLXTableImport() throw ()
+{
+}
+
+sal_Bool SvxXMLXTableImport::load( const OUString& rUrl, const uno::Reference< XNameContainer >& xTable ) throw()
+{
+ sal_Bool bRet = sal_True;
+
+ uno::Reference< XGraphicObjectResolver > xGrfResolver;
+ SvXMLGraphicHelper* pGraphicHelper = 0;
+
+ try
+ {
+ do
+ {
+ SfxMedium aMedium( rUrl, STREAM_READ | STREAM_NOCREATE, TRUE );
+
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
+ if( !xServiceFactory.is() )
+ {
+ DBG_ERROR( "SvxXMLXTableImport::load: got no service manager" );
+ break;
+ }
+
+ uno::Reference< xml::sax::XParser > xParser( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Parser" ) ) ), uno::UNO_QUERY_THROW );
+ uno::Reference < io::XStream > xIStm;
+ uno::Reference< io::XActiveDataSource > xSource;
+
+ xml::sax::InputSource aParserInput;
+ aParserInput.sSystemId = aMedium.GetName();
+
+ if( aMedium.IsStorage() )
+ {
+ uno::Reference < embed::XStorage > xStorage( aMedium.GetStorage( sal_False ), uno::UNO_QUERY_THROW );
+
+ const String aContentStmName( RTL_CONSTASCII_USTRINGPARAM( "Content.xml" ) );
+ xIStm.set( xStorage->openStreamElement( aContentStmName, embed::ElementModes::READ ), uno::UNO_QUERY_THROW );
+ if( !xIStm.is() )
+ {
+ DBG_ERROR( "could not open Content stream" );
+ break;
+ }
+
+ aParserInput.aInputStream = xIStm->getInputStream();
+ pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_READ );
+ xGrfResolver = pGraphicHelper;
+ }
+ else
+ {
+ aParserInput.aInputStream = aMedium.GetInputStream();
+ uno::Reference< io::XSeekable > xSeek( aParserInput.aInputStream, uno::UNO_QUERY_THROW );
+ xSeek->seek( 0 );
+ }
+
+ if( xSource.is() )
+ {
+ uno::Reference< io::XActiveDataControl > xSourceControl( xSource, UNO_QUERY_THROW );
+ xSourceControl->start();
+ }
+
+ // #110680#
+ // uno::Reference< XDocumentHandler > xHandler( new SvxXMLXTableImport( xTable, xGrfResolver ) );
+ uno::Reference< XDocumentHandler > xHandler( new SvxXMLXTableImport( xServiceFactory, xTable, xGrfResolver ) );
+
+ xParser->setDocumentHandler( xHandler );
+ xParser->parseStream( aParserInput );
+ }
+ while(0);
+
+ if( pGraphicHelper )
+ SvXMLGraphicHelper::Destroy( pGraphicHelper );
+ }
+ catch( uno::Exception& )
+ {
+// CL: I disabled this assertion since its an error, but it happens
+// each time you load a document with property tables that are not
+// on the current machine. Maybe a better fix would be to place
+// a file exists check before importing...
+// DBG_ERROR("svx::SvxXMLXTableImport::load(), exception caught!");
+ bRet = sal_False;
+ }
+
+ return bRet;
+}
+
+SvXMLImportContext *SvxXMLXTableImport::CreateContext( sal_uInt16 nPrefix, const OUString& rLocalName, const uno::Reference< XAttributeList >& xAttrList )
+{
+ if( XML_NAMESPACE_OOO == nPrefix ||
+ XML_NAMESPACE_OFFICE == nPrefix )
+ {
+ sal_Bool bOOoFormat = (XML_NAMESPACE_OFFICE == nPrefix);
+ Type aType = mrTable->getElementType();
+
+ if( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "color-table" ) ) )
+ {
+ if( aType == ::getCppuType((const sal_Int32*)0) )
+ return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_color, mrTable, bOOoFormat );
+ }
+ else if( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "marker-table" ) ) )
+ {
+ if( aType == ::getCppuType((const drawing::PolyPolygonBezierCoords*)0) )
+ return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_marker, mrTable, bOOoFormat );
+ }
+ else if( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "dash-table" ) ) )
+ {
+ if( aType == ::getCppuType((const drawing::LineDash*)0) )
+ return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_dash, mrTable, bOOoFormat );
+ }
+ else if( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "hatch-table" ) ) )
+ {
+ if( aType == ::getCppuType((const drawing::Hatch*)0) )
+ return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_hatch, mrTable, bOOoFormat );
+ }
+ else if( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "gradient-table" ) ) )
+ {
+ if( aType == ::getCppuType((const awt::Gradient*)0))
+ return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_gradient, mrTable, bOOoFormat );
+ }
+ else if( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "bitmap-table" ) ) )
+ {
+ if( aType == ::getCppuType((const OUString*)0))
+ return new SvxXMLTableImportContext( *this, nPrefix, rLocalName, xAttrList, stice_bitmap, mrTable, bOOoFormat );
+ }
+ }
+
+ return new SvXMLImportContext( *this, nPrefix, rLocalName );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
new file mode 100644
index 000000000000..a371addc95af
--- /dev/null
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -0,0 +1,771 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <sot/factory.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <vcl/bmpacc.hxx>
+#include <tools/poly.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/wrkwin.hxx>
+#include <svl/solar.hrc>
+#include <sfx2/docfile.hxx>
+#include <sfx2/app.hxx>
+#include "xoutbmp.hxx"
+#include <svtools/FilterConfigItem.hxx>
+#include <svtools/filter.hxx>
+
+// -----------
+// - Defines -
+// -----------
+
+#define FORMAT_BMP String(RTL_CONSTASCII_USTRINGPARAM("bmp"))
+#define FORMAT_GIF String(RTL_CONSTASCII_USTRINGPARAM("gif"))
+#define FORMAT_JPG String(RTL_CONSTASCII_USTRINGPARAM("jpg"))
+#define FORMAT_PNG String(RTL_CONSTASCII_USTRINGPARAM("png"))
+
+// --------------
+// - XOutBitmap -
+// --------------
+
+GraphicFilter* XOutBitmap::pGrfFilter = NULL;
+
+// -----------------------------------------------------------------------------
+
+BitmapEx XOutBitmap::CreateQuickDrawBitmapEx( const Graphic& rGraphic, const OutputDevice& rCompDev,
+ const MapMode& rMapMode, const Size& rLogSize,
+ const Point& rPoint, const Size& rSize )
+{
+ BitmapEx aRetBmp;
+
+ if( rGraphic.IsAlpha() )
+ aRetBmp = rGraphic.GetBitmapEx();
+ else
+ {
+ VirtualDevice aVDev( rCompDev );
+ MapMode aMap( rMapMode );
+
+ aMap.SetOrigin( Point() );
+ aVDev.SetMapMode( aMap );
+
+ Point aPoint( aVDev.LogicToPixel( rPoint ) );
+ Size aOldSize( aVDev.LogicToPixel( rSize ) );
+ Size aAbsSize( aOldSize );
+ Size aQSizePix( aVDev.LogicToPixel( rLogSize ) );
+
+ aVDev.SetMapMode( MapMode() );
+
+ if( aOldSize.Width() < 0 )
+ aAbsSize.Width() = -aAbsSize.Width();
+
+ if( aOldSize.Height() < 0 )
+ aAbsSize.Height() = -aAbsSize.Height();
+
+ if( aVDev.SetOutputSizePixel( aAbsSize ) )
+ {
+ Point aNewOrg( -aPoint.X(), -aPoint.Y() );
+ const Point aNullPoint;
+
+ // horizontale Spiegelung ggf. beruecksichtigen
+ if( aOldSize.Width() < 0 )
+ {
+ aNewOrg.X() -= aOldSize.Width();
+
+ // und jetzt noch einen abziehen
+ aNewOrg.X()--;
+ }
+
+ // vertikale Spiegelung ggf. beruecksichtigen
+ if( rSize.Height() < 0 )
+ {
+ aNewOrg.Y() -= aOldSize.Height();
+
+ // und jetzt noch einen abziehen
+ aNewOrg.Y()--;
+ }
+
+ if( rGraphic.GetType() != GRAPHIC_BITMAP )
+ {
+ rGraphic.Draw( &aVDev, aNewOrg, aQSizePix );
+
+ const Bitmap aBmp( aVDev.GetBitmap( aNullPoint, aAbsSize ) );
+ Bitmap aMask;
+
+ Graphic( rGraphic.GetGDIMetaFile().GetMonochromeMtf( COL_BLACK ) ).Draw( &aVDev, aNewOrg, aQSizePix );
+ aMask = aVDev.GetBitmap( aNullPoint, aAbsSize );
+ aRetBmp = BitmapEx( aBmp, aMask );
+ }
+ else
+ {
+ Bitmap aBmp( rGraphic.GetBitmap() );
+
+// UNX has got problems with 1x1 bitmaps which are transparent (KA 02.11.1998)
+#ifdef UNX
+ const Size aBmpSize( aBmp.GetSizePixel() );
+ BOOL bFullTrans = FALSE;
+
+ if( aBmpSize.Width() == 1 && aBmpSize.Height() == 1 && rGraphic.IsTransparent() )
+ {
+ Bitmap aTrans( rGraphic.GetBitmapEx().GetMask() );
+ BitmapReadAccess* pMAcc = aBmp.AcquireReadAccess();
+
+ if( pMAcc )
+ {
+ if( pMAcc->GetColor( 0, 0 ) == BitmapColor( Color( COL_WHITE ) ) )
+ bFullTrans = TRUE;
+
+ aTrans.ReleaseAccess( pMAcc );
+ }
+ }
+
+ if( !bFullTrans )
+#endif // UNX
+
+ {
+ DitherBitmap( aBmp );
+ aVDev.DrawBitmap( aNewOrg, aQSizePix, aBmp );
+ aBmp = aVDev.GetBitmap( aNullPoint, aAbsSize );
+
+ if( !rGraphic.IsTransparent() )
+ aRetBmp = BitmapEx( aBmp );
+ else
+ {
+ Bitmap aTrans( rGraphic.GetBitmapEx().GetMask() );
+
+ if( !aTrans )
+ aRetBmp = BitmapEx( aBmp, rGraphic.GetBitmapEx().GetTransparentColor() );
+ else
+ {
+ aVDev.DrawBitmap( aNewOrg, aQSizePix, aTrans );
+ aRetBmp = BitmapEx( aBmp, aVDev.GetBitmap( Point(), aAbsSize ) );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return aRetBmp;
+}
+
+// ------------------------------------------------------------------------
+
+void XOutBitmap::DrawQuickDrawBitmapEx( OutputDevice* pOutDev, const Point& rPt,
+ const Size& rSize, const BitmapEx& rBmpEx )
+{
+ const Size aBmpSizePix( rBmpEx.GetSizePixel() );
+ const Size aSizePix( pOutDev->LogicToPixel( rSize ) );
+
+ if ( ( aSizePix.Width() - aBmpSizePix.Width() ) || ( aSizePix.Height() - aBmpSizePix.Height() ) )
+ rBmpEx.Draw( pOutDev, rPt, rSize );
+ else
+ rBmpEx.Draw( pOutDev, rPt );
+}
+
+// ------------------------------------------------------------------------
+
+void XOutBitmap::DrawTiledBitmapEx( OutputDevice* pOutDev,
+ const Point& rStartPt, const Size& rGrfSize,
+ const Rectangle& rTileRect, const BitmapEx& rBmpEx )
+{
+ Rectangle aClipRect( pOutDev->LogicToPixel( pOutDev->GetClipRegion().GetBoundRect() ) );
+ Rectangle aPixRect( pOutDev->LogicToPixel( rTileRect ) );
+ const Size aPixSize( pOutDev->LogicToPixel( rGrfSize ) );
+ const Point aPixPoint( pOutDev->LogicToPixel( rStartPt ) );
+ Point aOrg;
+ const long nWidth = aPixSize.Width();
+ const long nHeight = aPixSize.Height();
+ long nXPos = aPixPoint.X() + ( ( aPixRect.Left() - aPixPoint.X() ) / nWidth ) * nWidth;
+ long nYPos = aPixPoint.Y() + ( ( aPixRect.Top() - aPixPoint.Y() ) / nHeight ) * nHeight;
+ const long nBottom = aPixRect.Bottom();
+ const long nRight = aPixRect.Right();
+ const long nLeft = nXPos;
+ const BOOL bNoSize = ( aPixSize == rBmpEx.GetSizePixel() );
+
+ pOutDev->Push();
+ pOutDev->SetMapMode( MapMode() );
+
+ // ggf. neue ClipRegion berechnen und setzen
+ if ( pOutDev->IsClipRegion() )
+ aPixRect.Intersection( aClipRect );
+
+ pOutDev->SetClipRegion( aPixRect );
+
+ while( nYPos <= nBottom )
+ {
+ while( nXPos <= nRight )
+ {
+ if ( bNoSize )
+ rBmpEx.Draw( pOutDev, Point( nXPos, nYPos ) );
+ else
+ rBmpEx.Draw( pOutDev, Point( nXPos, nYPos ), aPixSize );
+
+ nXPos += nWidth;
+ }
+
+ nXPos = nLeft;
+ nYPos += nHeight;
+ }
+
+ pOutDev->Pop();
+}
+
+// ------------------------------------------------------------------------
+
+Animation XOutBitmap::MirrorAnimation( const Animation& rAnimation, BOOL bHMirr, BOOL bVMirr )
+{
+ Animation aNewAnim( rAnimation );
+
+ if( bHMirr || bVMirr )
+ {
+ const Size& rGlobalSize = aNewAnim.GetDisplaySizePixel();
+ ULONG nMirrorFlags = 0L;
+
+ if( bHMirr )
+ nMirrorFlags |= BMP_MIRROR_HORZ;
+
+ if( bVMirr )
+ nMirrorFlags |= BMP_MIRROR_VERT;
+
+ for( USHORT i = 0, nCount = aNewAnim.Count(); i < nCount; i++ )
+ {
+ AnimationBitmap aAnimBmp( aNewAnim.Get( i ) );
+
+ // BitmapEx spiegeln
+ aAnimBmp.aBmpEx.Mirror( nMirrorFlags );
+
+ // Die Positionen innerhalb der Gesamtbitmap
+ // muessen natuerlich auch angepasst werden
+ if( bHMirr )
+ aAnimBmp.aPosPix.X() = rGlobalSize.Width() - aAnimBmp.aPosPix.X() -
+ aAnimBmp.aSizePix.Width();
+
+ if( bVMirr )
+ aAnimBmp.aPosPix.Y() = rGlobalSize.Height() - aAnimBmp.aPosPix.Y() -
+ aAnimBmp.aSizePix.Height();
+
+ aNewAnim.Replace( aAnimBmp, i );
+ }
+ }
+
+ return aNewAnim;
+}
+
+// ------------------------------------------------------------------------
+
+Graphic XOutBitmap::MirrorGraphic( const Graphic& rGraphic, const ULONG nMirrorFlags )
+{
+ Graphic aRetGraphic;
+
+ if( nMirrorFlags )
+ {
+ if( rGraphic.IsAnimated() )
+ {
+ aRetGraphic = MirrorAnimation( rGraphic.GetAnimation(),
+ ( nMirrorFlags & BMP_MIRROR_HORZ ) == BMP_MIRROR_HORZ,
+ ( nMirrorFlags & BMP_MIRROR_VERT ) == BMP_MIRROR_VERT );
+ }
+ else
+ {
+ if( rGraphic.IsTransparent() )
+ {
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+
+ aBmpEx.Mirror( nMirrorFlags );
+ aRetGraphic = aBmpEx;
+ }
+ else
+ {
+ Bitmap aBmp( rGraphic.GetBitmap() );
+
+ aBmp.Mirror( nMirrorFlags );
+ aRetGraphic = aBmp;
+ }
+ }
+ }
+ else
+ aRetGraphic = rGraphic;
+
+ return aRetGraphic;
+}
+
+// ------------------------------------------------------------------------
+
+USHORT XOutBitmap::WriteGraphic( const Graphic& rGraphic, String& rFileName,
+ const String& rFilterName, const ULONG nFlags,
+ const Size* pMtfSize_100TH_MM )
+{
+ if( rGraphic.GetType() != GRAPHIC_NONE )
+ {
+ INetURLObject aURL( rFileName );
+ Graphic aGraphic;
+ String aExt;
+ GraphicFilter* pFilter = GraphicFilter::GetGraphicFilter();
+ USHORT nErr = GRFILTER_FILTERERROR, nFilter = GRFILTER_FORMAT_NOTFOUND;
+ BOOL bTransparent = rGraphic.IsTransparent(), bAnimated = rGraphic.IsAnimated();
+
+ DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "XOutBitmap::WriteGraphic(...): invalid URL" );
+
+ // calculate correct file name
+ if( !( nFlags & XOUTBMP_DONT_EXPAND_FILENAME ) )
+ {
+ String aName( aURL.getBase() );
+ aName += '_';
+ aName += String(aURL.getExtension());
+ aName += '_';
+ String aStr( String::CreateFromInt32( rGraphic.GetChecksum(), 16 ) );
+ if ( aStr.GetChar(0) == '-' )
+ aStr.SetChar(0,'m');
+ aName += aStr;
+ aURL.setBase( aName );
+ }
+
+ if( ( nFlags & XOUTBMP_USE_NATIVE_IF_POSSIBLE ) &&
+ !( nFlags & XOUTBMP_MIRROR_HORZ ) &&
+ !( nFlags & XOUTBMP_MIRROR_VERT ) &&
+ ( rGraphic.GetType() != GRAPHIC_GDIMETAFILE ) && rGraphic.IsLink() )
+ {
+ // try to write native link
+ const GfxLink aGfxLink( ( (Graphic&) rGraphic ).GetLink() );
+
+ switch( aGfxLink.GetType() )
+ {
+ case( GFX_LINK_TYPE_NATIVE_GIF ): aExt = FORMAT_GIF; break;
+ case( GFX_LINK_TYPE_NATIVE_JPG ): aExt = FORMAT_JPG; break;
+ case( GFX_LINK_TYPE_NATIVE_PNG ): aExt = FORMAT_PNG; break;
+
+ default:
+ break;
+ }
+
+ if( aExt.Len() )
+ {
+ aURL.setExtension( aExt );
+ rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE );
+
+ SfxMedium aMedium( aURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_SHARE_DENYNONE | STREAM_TRUNC, TRUE );
+ SvStream* pOStm = aMedium.GetOutStream();
+
+ if( pOStm && aGfxLink.GetDataSize() && aGfxLink.GetData() )
+ {
+ pOStm->Write( aGfxLink.GetData(), aGfxLink.GetDataSize() );
+ aMedium.Commit();
+
+ if( !aMedium.GetError() )
+ nErr = GRFILTER_OK;
+ }
+ }
+ }
+
+ if( GRFILTER_OK != nErr )
+ {
+ String aFilter( rFilterName );
+ BOOL bWriteTransGrf = ( aFilter.EqualsIgnoreCaseAscii( "transgrf" ) ) ||
+ ( aFilter.EqualsIgnoreCaseAscii( "gif" ) ) ||
+ ( nFlags & XOUTBMP_USE_GIF_IF_POSSIBLE ) ||
+ ( ( nFlags & XOUTBMP_USE_GIF_IF_SENSIBLE ) && ( bAnimated || bTransparent ) );
+
+ // get filter and extension
+ if( bWriteTransGrf )
+ aFilter = FORMAT_GIF;
+
+ nFilter = pFilter->GetExportFormatNumberForShortName( aFilter );
+
+ if( GRFILTER_FORMAT_NOTFOUND == nFilter )
+ {
+ nFilter = pFilter->GetExportFormatNumberForShortName( FORMAT_JPG );
+
+ if( GRFILTER_FORMAT_NOTFOUND == nFilter )
+ nFilter = pFilter->GetExportFormatNumberForShortName( FORMAT_BMP );
+ }
+
+ if( GRFILTER_FORMAT_NOTFOUND != nFilter )
+ {
+ aExt = pFilter->GetExportFormatShortName( nFilter ).ToLowerAscii();
+
+ if( bWriteTransGrf )
+ {
+ if( bAnimated )
+ aGraphic = rGraphic;
+ else
+ {
+ if( pMtfSize_100TH_MM && ( rGraphic.GetType() != GRAPHIC_BITMAP ) )
+ {
+ VirtualDevice aVDev;
+ const Size aSize( aVDev.LogicToPixel( *pMtfSize_100TH_MM, MAP_100TH_MM ) );
+
+ if( aVDev.SetOutputSizePixel( aSize ) )
+ {
+ const Wallpaper aWallpaper( aVDev.GetBackground() );
+ const Point aPt;
+
+ aVDev.SetBackground( Wallpaper( Color( COL_BLACK ) ) );
+ aVDev.Erase();
+ rGraphic.Draw( &aVDev, aPt, aSize );
+
+ const Bitmap aBitmap( aVDev.GetBitmap( aPt, aSize ) );
+
+ aVDev.SetBackground( aWallpaper );
+ aVDev.Erase();
+ rGraphic.Draw( &aVDev, aPt, aSize );
+
+ aVDev.SetRasterOp( ROP_XOR );
+ aVDev.DrawBitmap( aPt, aSize, aBitmap );
+ aGraphic = BitmapEx( aBitmap, aVDev.GetBitmap( aPt, aSize ) );
+ }
+ else
+ aGraphic = rGraphic.GetBitmapEx();
+ }
+ else
+ aGraphic = rGraphic.GetBitmapEx();
+ }
+ }
+ else
+ {
+ if( pMtfSize_100TH_MM && ( rGraphic.GetType() != GRAPHIC_BITMAP ) )
+ {
+ VirtualDevice aVDev;
+ const Size aSize( aVDev.LogicToPixel( *pMtfSize_100TH_MM, MAP_100TH_MM ) );
+
+ if( aVDev.SetOutputSizePixel( aSize ) )
+ {
+ rGraphic.Draw( &aVDev, Point(), aSize );
+ aGraphic = aVDev.GetBitmap( Point(), aSize );
+ }
+ else
+ aGraphic = rGraphic.GetBitmap();
+ }
+ else
+ aGraphic = rGraphic.GetBitmap();
+ }
+
+ // mirror?
+ if( ( nFlags & XOUTBMP_MIRROR_HORZ ) || ( nFlags & XOUTBMP_MIRROR_VERT ) )
+ aGraphic = MirrorGraphic( aGraphic, nFlags );
+
+ if( ( GRFILTER_FORMAT_NOTFOUND != nFilter ) && ( aGraphic.GetType() != GRAPHIC_NONE ) )
+ {
+ aURL.setExtension( aExt );
+ rFileName = aURL.GetMainURL( INetURLObject::NO_DECODE );
+ nErr = ExportGraphic( aGraphic, aURL, *pFilter, nFilter, NULL );
+ }
+ }
+ }
+
+ return nErr;
+ }
+ else
+ {
+ return GRFILTER_OK;
+ }
+}
+
+// ------------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+USHORT XOutBitmap::ExportGraphic( const Graphic& rGraphic, const INetURLObject& rURL,
+ GraphicFilter& rFilter, const USHORT nFormat,
+ const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData )
+{
+ DBG_ASSERT( rURL.GetProtocol() != INET_PROT_NOT_VALID, "XOutBitmap::ExportGraphic(...): invalid URL" );
+
+ SfxMedium aMedium( rURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE | STREAM_SHARE_DENYNONE | STREAM_TRUNC, TRUE );
+ SvStream* pOStm = aMedium.GetOutStream();
+ USHORT nRet = GRFILTER_IOERROR;
+
+ if( pOStm )
+ {
+ pGrfFilter = &rFilter;
+
+ nRet = rFilter.ExportGraphic( rGraphic, rURL.GetMainURL( INetURLObject::NO_DECODE ), *pOStm, nFormat, pFilterData );
+
+ pGrfFilter = NULL;
+ aMedium.Commit();
+
+ if( aMedium.GetError() && ( GRFILTER_OK == nRet ) )
+ nRet = GRFILTER_IOERROR;
+ }
+
+ return nRet;
+}
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+// ------------------------------------------------------------------------
+
+Bitmap XOutBitmap::DetectEdges( const Bitmap& rBmp, const BYTE cThreshold )
+{
+ const Size aSize( rBmp.GetSizePixel() );
+ Bitmap aRetBmp;
+ BOOL bRet = FALSE;
+
+ if( ( aSize.Width() > 2L ) && ( aSize.Height() > 2L ) )
+ {
+ Bitmap aWorkBmp( rBmp );
+
+ if( aWorkBmp.Convert( BMP_CONVERSION_8BIT_GREYS ) )
+ {
+ Bitmap aDstBmp( aSize, 1 );
+ BitmapReadAccess* pReadAcc = aWorkBmp.AcquireReadAccess();
+ BitmapWriteAccess* pWriteAcc = aDstBmp.AcquireWriteAccess();
+
+ if( pReadAcc && pWriteAcc )
+ {
+ const long nWidth = aSize.Width();
+ const long nWidth2 = nWidth - 2L;
+ const long nHeight = aSize.Height();
+ const long nHeight2 = nHeight - 2L;
+ const long lThres2 = (long) cThreshold * cThreshold;
+ const BitmapColor aWhite = (BYTE) pWriteAcc->GetBestMatchingColor( Color( COL_WHITE ) );
+ const BitmapColor aBlack = (BYTE) pWriteAcc->GetBestMatchingColor( Color( COL_BLACK ) );
+ long nSum1;
+ long nSum2;
+ long lGray;
+
+ // Rand mit Weiss init.
+ pWriteAcc->SetLineColor( Color( COL_WHITE) );
+ pWriteAcc->DrawLine( Point(), Point( nWidth - 1L, 0L ) );
+ pWriteAcc->DrawLine( Point( nWidth - 1L, 0L ), Point( nWidth - 1L, nHeight - 1L ) );
+ pWriteAcc->DrawLine( Point( nWidth - 1L, nHeight - 1L ), Point( 0L, nHeight - 1L ) );
+ pWriteAcc->DrawLine( Point( 0, nHeight - 1L ), Point() );
+
+ for( long nY = 0L, nY1 = 1L, nY2 = 2; nY < nHeight2; nY++, nY1++, nY2++ )
+ {
+ for( long nX = 0L, nXDst = 1L, nXTmp; nX < nWidth2; nX++, nXDst++ )
+ {
+ nXTmp = nX;
+
+ nSum1 = -( nSum2 = lGray = (BYTE) pReadAcc->GetPixel( nY, nXTmp++ ) );
+ nSum2 += ( (long) (BYTE) pReadAcc->GetPixel( nY, nXTmp++ ) ) << 1;
+ nSum1 += ( lGray = pReadAcc->GetPixel( nY, nXTmp ) );
+ nSum2 += lGray;
+
+ nSum1 += ( (long) (BYTE) pReadAcc->GetPixel( nY1, nXTmp ) ) << 1;
+ nSum1 -= ( (long) (BYTE) pReadAcc->GetPixel( nY1, nXTmp -= 2 ) ) << 1;
+
+ nSum1 += ( lGray = -(long) (BYTE) pReadAcc->GetPixel( nY2, nXTmp++ ) );
+ nSum2 += lGray;
+ nSum2 -= ( (long) (BYTE) pReadAcc->GetPixel( nY2, nXTmp++ ) ) << 1;
+ nSum1 += ( lGray = (long) (BYTE) pReadAcc->GetPixel( nY2, nXTmp ) );
+ nSum2 -= lGray;
+
+ if( ( nSum1 * nSum1 + nSum2 * nSum2 ) < lThres2 )
+ pWriteAcc->SetPixel( nY1, nXDst, aWhite );
+ else
+ pWriteAcc->SetPixel( nY1, nXDst, aBlack );
+ }
+ }
+
+ bRet = TRUE;
+ }
+
+ aWorkBmp.ReleaseAccess( pReadAcc );
+ aDstBmp.ReleaseAccess( pWriteAcc );
+
+ if( bRet )
+ aRetBmp = aDstBmp;
+ }
+ }
+
+ if( !aRetBmp )
+ aRetBmp = rBmp;
+ else
+ {
+ aRetBmp.SetPrefMapMode( rBmp.GetPrefMapMode() );
+ aRetBmp.SetPrefSize( rBmp.GetPrefSize() );
+ }
+
+ return aRetBmp;
+};
+
+// ------------------------------------------------------------------------
+
+Polygon XOutBitmap::GetCountour( const Bitmap& rBmp, const ULONG nFlags,
+ const BYTE cEdgeDetectThreshold, const Rectangle* pWorkRectPixel )
+{
+ Bitmap aWorkBmp;
+ Polygon aRetPoly;
+ Point aTmpPoint;
+ Rectangle aWorkRect( aTmpPoint, rBmp.GetSizePixel() );
+
+ if( pWorkRectPixel )
+ aWorkRect.Intersection( *pWorkRectPixel );
+
+ aWorkRect.Justify();
+
+ if( ( aWorkRect.GetWidth() > 4 ) && ( aWorkRect.GetHeight() > 4 ) )
+ {
+ // falls Flag gesetzt, muessen wir Kanten detektieren
+ if( nFlags & XOUTBMP_CONTOUR_EDGEDETECT )
+ aWorkBmp = DetectEdges( rBmp, cEdgeDetectThreshold );
+ else
+ aWorkBmp = rBmp;
+
+ BitmapReadAccess* pAcc = aWorkBmp.AcquireReadAccess();
+
+ if( pAcc )
+ {
+ const Size& rPrefSize = aWorkBmp.GetPrefSize();
+ const long nWidth = pAcc->Width();
+ const long nHeight = pAcc->Height();
+ const double fFactorX = (double) rPrefSize.Width() / nWidth;
+ const double fFactorY = (double) rPrefSize.Height() / nHeight;
+ const long nStartX1 = aWorkRect.Left() + 1L;
+ const long nEndX1 = aWorkRect.Right();
+ const long nStartX2 = nEndX1 - 1L;
+// const long nEndX2 = nStartX1 - 1L;
+ const long nStartY1 = aWorkRect.Top() + 1L;
+ const long nEndY1 = aWorkRect.Bottom();
+ const long nStartY2 = nEndY1 - 1L;
+// const long nEndY2 = nStartY1 - 1L;
+ Point* pPoints1 = NULL;
+ Point* pPoints2 = NULL;
+ long nX, nY;
+ USHORT nPolyPos = 0;
+ const BitmapColor aBlack = pAcc->GetBestMatchingColor( Color( COL_BLACK ) );
+
+ if( nFlags & XOUTBMP_CONTOUR_VERT )
+ {
+ pPoints1 = new Point[ nWidth ];
+ pPoints2 = new Point[ nWidth ];
+
+ for( nX = nStartX1; nX < nEndX1; nX++ )
+ {
+ nY = nStartY1;
+
+ // zunaechst Zeile von Links nach Rechts durchlaufen
+ while( nY < nEndY1 )
+ {
+ if( aBlack == pAcc->GetPixel( nY, nX ) )
+ {
+ pPoints1[ nPolyPos ] = Point( nX, nY );
+ nY = nStartY2;
+
+ // diese Schleife wird immer gebreaked da hier ja min. ein Pixel ist
+ while( TRUE )
+ {
+ if( aBlack == pAcc->GetPixel( nY, nX ) )
+ {
+ pPoints2[ nPolyPos ] = Point( nX, nY );
+ break;
+ }
+
+ nY--;
+ }
+
+ nPolyPos++;
+ break;
+ }
+
+ nY++;
+ }
+ }
+ }
+ else
+ {
+ pPoints1 = new Point[ nHeight ];
+ pPoints2 = new Point[ nHeight ];
+
+ for ( nY = nStartY1; nY < nEndY1; nY++ )
+ {
+ nX = nStartX1;
+
+ // zunaechst Zeile von Links nach Rechts durchlaufen
+ while( nX < nEndX1 )
+ {
+ if( aBlack == pAcc->GetPixel( nY, nX ) )
+ {
+ pPoints1[ nPolyPos ] = Point( nX, nY );
+ nX = nStartX2;
+
+ // diese Schleife wird immer gebreaked da hier ja min. ein Pixel ist
+ while( TRUE )
+ {
+ if( aBlack == pAcc->GetPixel( nY, nX ) )
+ {
+ pPoints2[ nPolyPos ] = Point( nX, nY );
+ break;
+ }
+
+ nX--;
+ }
+
+ nPolyPos++;
+ break;
+ }
+
+ nX++;
+ }
+ }
+ }
+
+ const USHORT nNewSize1 = nPolyPos << 1;
+
+ aRetPoly = Polygon( nPolyPos, pPoints1 );
+ aRetPoly.SetSize( nNewSize1 + 1 );
+ aRetPoly[ nNewSize1 ] = aRetPoly[ 0 ];
+
+ for( USHORT j = nPolyPos; nPolyPos < nNewSize1; )
+ aRetPoly[ nPolyPos++ ] = pPoints2[ --j ];
+
+ if( ( fFactorX != 0. ) && ( fFactorY != 0. ) )
+ aRetPoly.Scale( fFactorX, fFactorY );
+
+ delete[] pPoints1;
+ delete[] pPoints2;
+ }
+ }
+
+ return aRetPoly;
+};
+
+// ----------------
+// - DitherBitmap -
+// ----------------
+
+BOOL DitherBitmap( Bitmap& rBitmap )
+{
+ BOOL bRet = FALSE;
+
+ if( ( rBitmap.GetBitCount() >= 8 ) && ( Application::GetDefaultDevice()->GetColorCount() < 257 ) )
+ bRet = rBitmap.Dither( BMP_DITHER_FLOYD );
+ else
+ bRet = FALSE;
+
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/_xpoly.cxx b/svx/source/xoutdev/_xpoly.cxx
new file mode 100644
index 000000000000..0fb2aba264b8
--- /dev/null
+++ b/svx/source/xoutdev/_xpoly.cxx
@@ -0,0 +1,2135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <osl/endian.h>
+#include <tools/stream.hxx>
+#include <tools/debug.hxx>
+#include <tools/poly.hxx>
+
+#include <svx/xpoly.hxx>
+#include "xpolyimp.hxx"
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/numeric/ftools.hxx>
+
+#define GLOBALOVERFLOW
+
+DBG_NAME(XPolygon);
+DBG_NAME(XPolyPolygon);
+
+/*************************************************************************
+|*
+|* ImpXPolygon::ImpXPolygon()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 12.01.95 ESO
+|*
+*************************************************************************/
+
+ImpXPolygon::ImpXPolygon( USHORT nInitSize, USHORT _nResize )
+{
+ pPointAry = NULL;
+ pFlagAry = NULL;
+ bDeleteOldPoints = FALSE;
+ nSize = 0;
+ nResize = _nResize;
+ nPoints = 0;
+ nRefCount = 1;
+
+ Resize( nInitSize );
+}
+
+/*************************************************************************
+|*
+|* ImpXPolygon::ImpXPolygon()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 12.01.95 ESO
+|*
+*************************************************************************/
+
+ImpXPolygon::ImpXPolygon( const ImpXPolygon& rImpXPoly )
+{
+ ( (ImpXPolygon&) rImpXPoly ).CheckPointDelete();
+
+ pPointAry = NULL;
+ pFlagAry = NULL;
+ bDeleteOldPoints = FALSE;
+ nSize = 0;
+ ImpXPolygon::nResize = rImpXPoly.nResize;
+ nPoints = 0;
+ nRefCount = 1;
+
+ Resize( rImpXPoly.nSize );
+
+ // Kopieren
+ nPoints = rImpXPoly.nPoints;
+ memcpy( pPointAry, rImpXPoly.pPointAry, nSize*sizeof( Point ) );
+ memcpy( pFlagAry, rImpXPoly.pFlagAry, nSize );
+}
+
+/*************************************************************************
+|*
+|* ImpXPolygon::~ImpXPolygon()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 12.01.95 ESO
+|*
+*************************************************************************/
+
+ImpXPolygon::~ImpXPolygon()
+{
+ delete[] (char*) pPointAry;
+ delete[] pFlagAry;
+ if ( bDeleteOldPoints )
+ delete[] (char*) pOldPointAry;
+}
+
+/*************************************************************************
+|*
+|* ImpXPolygon::operator==()
+|*
+|* Ersterstellung Joe 26-09-95
+|* Letzte Aenderung
+|*
+*************************************************************************/
+
+
+bool ImpXPolygon::operator==(const ImpXPolygon& rImpXPoly) const
+{
+ return nPoints==rImpXPoly.nPoints &&
+ (nPoints==0 ||
+ (memcmp(pPointAry,rImpXPoly.pPointAry,nPoints*sizeof(Point))==0 &&
+ memcmp(pFlagAry,rImpXPoly.pFlagAry,nPoints)==0));
+}
+
+/*************************************************************************
+|*
+|* ImpXPolygon::Resize()
+|*
+|* !!! Polygongroesse aendern - wenn bDeletePoints FALSE, dann den
+|* Point-Array nicht loeschen, sondern in pOldPointAry sichern und
+|* das Flag bDeleteOldPoints setzen. Beim naechsten Zugriff wird
+|* das Array dann geloescht.
+|* Damit wird verhindert, dass bei XPoly[n] = XPoly[0] durch ein
+|* Resize der fuer den rechten Ausdruck verwendete Point-Array
+|* vorzeitig geloescht wird.
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 12.01.95 ESO
+|*
+*************************************************************************/
+
+void ImpXPolygon::Resize( USHORT nNewSize, BOOL bDeletePoints )
+{
+ if( nNewSize == nSize )
+ return;
+
+ BYTE* pOldFlagAry = pFlagAry;
+ USHORT nOldSize = nSize;
+
+ CheckPointDelete();
+ pOldPointAry = pPointAry;
+
+ // Neue Groesse auf vielfaches von nResize runden, sofern Objekt
+ // nicht neu angelegt wurde (nSize != 0)
+ if ( nSize != 0 && nNewSize > nSize )
+ {
+ DBG_ASSERT(nResize, "Resize-Versuch trotz nResize = 0 !");
+ nNewSize = nSize + ((nNewSize-nSize-1) / nResize + 1) * nResize;
+ }
+ // Punkt Array erzeugen
+ nSize = nNewSize;
+ pPointAry = (Point*)new char[ nSize*sizeof( Point ) ];
+ memset( pPointAry, 0, nSize*sizeof( Point ) );
+
+ // Flag Array erzeugen
+ pFlagAry = new BYTE[ nSize ];
+ memset( pFlagAry, 0, nSize );
+
+ // Eventuell umkopieren
+ if( nOldSize )
+ {
+ if( nOldSize < nSize )
+ {
+ memcpy( pPointAry, pOldPointAry, nOldSize*sizeof( Point ) );
+ memcpy( pFlagAry, pOldFlagAry, nOldSize );
+ }
+ else
+ {
+ memcpy( pPointAry, pOldPointAry, nSize*sizeof( Point ) );
+ memcpy( pFlagAry, pOldFlagAry, nSize );
+
+ // Anzahl der gueltigen Punkte anpassen
+ if( nPoints > nSize )
+ nPoints = nSize;
+ }
+ if ( bDeletePoints ) delete[] (char*) pOldPointAry;
+ else bDeleteOldPoints = TRUE;
+ delete[] pOldFlagAry;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* ImpXPolygon::InsertSpace()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 29.03.95 ESO
+|*
+*************************************************************************/
+
+void ImpXPolygon::InsertSpace( USHORT nPos, USHORT nCount )
+{
+ CheckPointDelete();
+
+ if ( nPos > nPoints )
+ nPos = nPoints;
+
+ // Wenn Polygon zu klein dann groesser machen
+ if( (nPoints + nCount) > nSize )
+ Resize( nPoints + nCount );
+
+ // Wenn nicht hinter dem letzten Punkt eingefuegt wurde,
+ // den Rest nach hinten schieben
+ if( nPos < nPoints )
+ {
+ USHORT nMove = nPoints - nPos;
+ memmove( &pPointAry[nPos+nCount], &pPointAry[nPos],
+ nMove * sizeof(Point) );
+ memmove( &pFlagAry[nPos+nCount], &pFlagAry[nPos], nMove );
+ }
+ memset( &pPointAry[nPos], 0, nCount * sizeof( Point ) );
+ memset( &pFlagAry [nPos], 0, nCount );
+
+ nPoints = nPoints + nCount;
+}
+
+
+/*************************************************************************
+|*
+|* ImpXPolygon::Remove()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 12.01.94 ESO
+|*
+*************************************************************************/
+
+void ImpXPolygon::Remove( USHORT nPos, USHORT nCount )
+{
+ CheckPointDelete();
+
+ if( (nPos + nCount) <= nPoints )
+ {
+ USHORT nMove = nPoints - nPos - nCount;
+
+ if( nMove )
+ {
+ memmove( &pPointAry[nPos], &pPointAry[nPos+nCount],
+ nMove * sizeof(Point) );
+ memmove( &pFlagAry[nPos], &pFlagAry[nPos+nCount], nMove );
+ }
+ memset( &pPointAry[nPoints - nCount], 0, nCount * sizeof( Point ) );
+ memset( &pFlagAry [nPoints - nCount], 0, nCount );
+ nPoints = nPoints - nCount;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* XPolygon::XPolygon()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 08.11.94
+|*
+*************************************************************************/
+
+XPolygon::XPolygon( USHORT nSize, USHORT nResize )
+{
+ DBG_CTOR(XPolygon,NULL);
+ pImpXPolygon = new ImpXPolygon( nSize, nResize );
+}
+
+/*************************************************************************
+|*
+|* XPolygon::XPolygon()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 08.11.94
+|*
+*************************************************************************/
+
+XPolygon::XPolygon( const XPolygon& rXPoly )
+{
+ DBG_CTOR(XPolygon,NULL);
+ pImpXPolygon = rXPoly.pImpXPolygon;
+ pImpXPolygon->nRefCount++;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::XPolygon()
+|*
+|* XPolygon aus einem Standardpolygon erstellen
+|* Ersterstellung 18.01.95 ESO
+|* Letzte Aenderung 18.01.95 ESO
+|*
+*************************************************************************/
+
+XPolygon::XPolygon( const Polygon& rPoly )
+{
+ DBG_CTOR(XPolygon,NULL);
+
+ USHORT nSize = rPoly.GetSize();
+ pImpXPolygon = new ImpXPolygon( nSize );
+ pImpXPolygon->nPoints = nSize;
+
+ for( USHORT i = 0; i < nSize; i++ )
+ {
+ pImpXPolygon->pPointAry[i] = rPoly[i];
+ pImpXPolygon->pFlagAry[i] = (BYTE) rPoly.GetFlags( i );
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolygon::XPolygon()
+|*
+|* Rechteck (auch mit abgerundeten Ecken) als Bezierpolygon erzeugen
+|* Ersterstellung 09.01.95 ESO
+|* Letzte Aenderung 09.01.95 ESO
+|*
+*************************************************************************/
+
+XPolygon::XPolygon(const Rectangle& rRect, long nRx, long nRy)
+{
+ DBG_CTOR(XPolygon,NULL);
+ pImpXPolygon = new ImpXPolygon(17);
+ long nWh = (rRect.GetWidth() - 1) / 2;
+ long nHh = (rRect.GetHeight() - 1) / 2;
+
+ if ( nRx > nWh ) nRx = nWh;
+ if ( nRy > nHh ) nRy = nHh;
+
+ // Rx negativ, damit Umlauf im Uhrzeigersinn erfolgt
+ nRx = -nRx;
+
+ // Faktor fuer Kontrollpunkte der Bezierkurven: 8/3 * (sin(45g) - 0.5)
+ long nXHdl = (long)(0.552284749 * nRx);
+ long nYHdl = (long)(0.552284749 * nRy);
+ USHORT nPos = 0;
+
+ if ( nRx && nRy )
+ {
+ Point aCenter;
+
+ for (USHORT nQuad = 0; nQuad < 4; nQuad++)
+ {
+ switch ( nQuad )
+ {
+ case 0: aCenter = rRect.TopLeft();
+ aCenter.X() -= nRx;
+ aCenter.Y() += nRy;
+ break;
+ case 1: aCenter = rRect.TopRight();
+ aCenter.X() += nRx;
+ aCenter.Y() += nRy;
+ break;
+ case 2: aCenter = rRect.BottomRight();
+ aCenter.X() += nRx;
+ aCenter.Y() -= nRy;
+ break;
+ case 3: aCenter = rRect.BottomLeft();
+ aCenter.X() -= nRx;
+ aCenter.Y() -= nRy;
+ break;
+ }
+ GenBezArc(aCenter, nRx, nRy, nXHdl, nYHdl, 0, 900, nQuad, nPos);
+ pImpXPolygon->pFlagAry[nPos ] = (BYTE) XPOLY_SMOOTH;
+ pImpXPolygon->pFlagAry[nPos+3] = (BYTE) XPOLY_SMOOTH;
+ nPos += 4;
+ }
+ }
+ else
+ {
+ pImpXPolygon->pPointAry[nPos++] = rRect.TopLeft();
+ pImpXPolygon->pPointAry[nPos++] = rRect.TopRight();
+ pImpXPolygon->pPointAry[nPos++] = rRect.BottomRight();
+ pImpXPolygon->pPointAry[nPos++] = rRect.BottomLeft();
+ }
+ pImpXPolygon->pPointAry[nPos] = pImpXPolygon->pPointAry[0];
+ pImpXPolygon->nPoints = nPos + 1;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::XPolygon()
+|*
+|* Ellipsen(bogen) als Bezierpolygon erzeugen
+|* Ersterstellung 09.01.95
+|* Letzte Aenderung 09.01.95
+|*
+*************************************************************************/
+
+XPolygon::XPolygon(const Point& rCenter, long nRx, long nRy,
+ USHORT nStartAngle, USHORT nEndAngle, BOOL bClose)
+{
+ DBG_CTOR(XPolygon,NULL);
+ pImpXPolygon = new ImpXPolygon(17);
+
+ nStartAngle %= 3600;
+ if ( nEndAngle > 3600 ) nEndAngle %= 3600;
+ BOOL bFull = (nStartAngle == 0 && nEndAngle == 3600);
+
+ // Faktor fuer Kontrollpunkte der Bezierkurven: 8/3 * (sin(45g) - 0.5)
+ long nXHdl = (long)(0.552284749 * nRx);
+ long nYHdl = (long)(0.552284749 * nRy);
+ USHORT nPos = 0;
+ BOOL bLoopEnd = FALSE;
+
+ do
+ {
+ USHORT nA1, nA2;
+ USHORT nQuad = nStartAngle / 900;
+ if ( nQuad == 4 ) nQuad = 0;
+ bLoopEnd = CheckAngles(nStartAngle, nEndAngle, nA1, nA2);
+ GenBezArc(rCenter, nRx, nRy, nXHdl, nYHdl, nA1, nA2, nQuad, nPos);
+ nPos += 3;
+ if ( !bLoopEnd )
+ pImpXPolygon->pFlagAry[nPos] = (BYTE) XPOLY_SMOOTH;
+
+ } while ( !bLoopEnd );
+
+ // Wenn kein Vollkreis, dann ggf. Enden mit Mittelpunkt verbinden
+ if ( !bFull && bClose )
+ pImpXPolygon->pPointAry[++nPos] = rCenter;
+
+ if ( bFull )
+ {
+ pImpXPolygon->pFlagAry[0 ] = (BYTE) XPOLY_SMOOTH;
+ pImpXPolygon->pFlagAry[nPos] = (BYTE) XPOLY_SMOOTH;
+ }
+ pImpXPolygon->nPoints = nPos + 1;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::~XPolygon()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 08.11.94
+|*
+*************************************************************************/
+
+XPolygon::~XPolygon()
+{
+ DBG_DTOR(XPolygon,NULL);
+ if( pImpXPolygon->nRefCount > 1 )
+ pImpXPolygon->nRefCount--;
+ else
+ delete pImpXPolygon;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::CheckReference()
+|*
+|* Referenzzaehler desImpXPoly pruefen und ggf. von diesem abkoppeln
+|* Ersterstellung 17.01.95 ESO
+|* Letzte Aenderung 17.01.95 ESO
+|*
+*************************************************************************/
+
+void XPolygon::CheckReference()
+{
+ if( pImpXPolygon->nRefCount > 1 )
+ {
+ pImpXPolygon->nRefCount--;
+ pImpXPolygon = new ImpXPolygon( *pImpXPolygon );
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolygon::SetSize()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 08.11.94
+|*
+*************************************************************************/
+
+void XPolygon::SetSize( USHORT nNewSize )
+{
+ CheckReference();
+ pImpXPolygon->Resize( nNewSize );
+}
+
+/*************************************************************************
+|*
+|* XPolygon::GetSize()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 12.01.95 ESO
+|*
+*************************************************************************/
+
+USHORT XPolygon::GetSize() const
+{
+ pImpXPolygon->CheckPointDelete();
+ return pImpXPolygon->nSize;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::SetPointCount()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 12.01.95 ESO
+|*
+*************************************************************************/
+
+void XPolygon::SetPointCount( USHORT nPoints )
+{
+ pImpXPolygon->CheckPointDelete();
+ CheckReference();
+
+ if( pImpXPolygon->nSize < nPoints )
+ pImpXPolygon->Resize( nPoints );
+
+ if ( nPoints < pImpXPolygon->nPoints )
+ {
+ USHORT nSize = pImpXPolygon->nPoints - nPoints;
+ memset( &pImpXPolygon->pPointAry[nPoints], 0, nSize * sizeof( Point ) );
+ memset( &pImpXPolygon->pFlagAry [nPoints], 0, nSize );
+ }
+ pImpXPolygon->nPoints = nPoints;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::GetPointCount()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 12.01.95 ESO
+|*
+*************************************************************************/
+
+USHORT XPolygon::GetPointCount() const
+{
+ pImpXPolygon->CheckPointDelete();
+ return pImpXPolygon->nPoints;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Insert()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 08.11.94
+|*
+*************************************************************************/
+
+void XPolygon::Insert( USHORT nPos, const Point& rPt, XPolyFlags eFlags )
+{
+ CheckReference();
+ if (nPos>pImpXPolygon->nPoints) nPos=pImpXPolygon->nPoints;
+ pImpXPolygon->InsertSpace( nPos, 1 );
+ pImpXPolygon->pPointAry[nPos] = rPt;
+ pImpXPolygon->pFlagAry[nPos] = (BYTE)eFlags;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Insert()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 08.11.94
+|*
+*************************************************************************/
+
+void XPolygon::Insert( USHORT nPos, const XPolygon& rXPoly )
+{
+ CheckReference();
+ if (nPos>pImpXPolygon->nPoints) nPos=pImpXPolygon->nPoints;
+
+ USHORT nPoints = rXPoly.GetPointCount();
+
+ pImpXPolygon->InsertSpace( nPos, nPoints );
+
+ memcpy( &(pImpXPolygon->pPointAry[nPos]),
+ rXPoly.pImpXPolygon->pPointAry,
+ nPoints*sizeof( Point ) );
+ memcpy( &(pImpXPolygon->pFlagAry[nPos]),
+ rXPoly.pImpXPolygon->pFlagAry,
+ nPoints );
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Insert()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 08.11.94
+|*
+*************************************************************************/
+
+void XPolygon::Insert( USHORT nPos, const Polygon& rPoly )
+{
+ CheckReference();
+ if (nPos>pImpXPolygon->nPoints) nPos=pImpXPolygon->nPoints;
+
+ USHORT nPoints = rPoly.GetSize();
+
+ pImpXPolygon->InsertSpace( nPos, nPoints );
+
+ USHORT i;
+ for( i=0; i < nPoints; i++ )
+ pImpXPolygon->pPointAry[i] = rPoly[i];
+
+ // Die Flags sind durch das InsertSpace bereits auf 0 gesetzt
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Remove()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 08.11.94
+|*
+*************************************************************************/
+
+void XPolygon::Remove( USHORT nPos, USHORT nCount )
+{
+ CheckReference();
+ pImpXPolygon->Remove( nPos, nCount );
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Move()
+|*
+|* Beschreibung
+|* Ersterstellung 09.11.94
+|* Letzte Aenderung 09.11.94
+|*
+*************************************************************************/
+
+void XPolygon::Move( long nHorzMove, long nVertMove )
+{
+ if ( !nHorzMove && !nVertMove )
+ return;
+
+ CheckReference();
+
+ // Punkte verschieben
+ USHORT nCount = pImpXPolygon->nPoints;
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ Point* pPt = &(pImpXPolygon->pPointAry[i]);
+ pPt->X() += nHorzMove;
+ pPt->Y() += nVertMove;
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolygon::GetBoundRect()
+|*
+|* Beschreibung
+|* Ersterstellung 09.11.94
+|* Letzte Aenderung 12.01.95 ESO
+|*
+*************************************************************************/
+
+Rectangle XPolygon::GetBoundRect() const
+{
+ pImpXPolygon->CheckPointDelete();
+ Rectangle aRetval;
+
+ if(pImpXPolygon->nPoints)
+ {
+ // #i37709#
+ // For historical reasons the control points are not part of the
+ // BoundRect. This makes it necessary to subdivide the polygon to
+ // get a relatively correct BoundRect. Numerically, this is not
+ // correct and never was.
+
+ const basegfx::B2DRange aPolygonRange(basegfx::tools::getRange(getB2DPolygon()));
+ aRetval = Rectangle(
+ FRound(aPolygonRange.getMinX()), FRound(aPolygonRange.getMinY()),
+ FRound(aPolygonRange.getMaxX()), FRound(aPolygonRange.getMaxY()));
+ }
+
+ return aRetval;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::operator[]()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 12.01.95
+|*
+*************************************************************************/
+
+const Point& XPolygon::operator[]( USHORT nPos ) const
+{
+ DBG_ASSERT(nPos < pImpXPolygon->nPoints, "Ungueltiger Index bei const-Arrayzugriff auf XPolygon");
+
+ pImpXPolygon->CheckPointDelete();
+ return pImpXPolygon->pPointAry[nPos];
+}
+
+/*************************************************************************
+|*
+|* XPolygon::operator[]()
+|*
+|* Beschreibung
+|* Ersterstellung 08.11.94
+|* Letzte Aenderung 12.01.95 ESO
+|*
+*************************************************************************/
+
+Point& XPolygon::operator[]( USHORT nPos )
+{
+ pImpXPolygon->CheckPointDelete();
+ CheckReference();
+
+ if( nPos >= pImpXPolygon->nSize )
+ {
+ DBG_ASSERT(pImpXPolygon->nResize, "Ungueltiger Index bei Arrayzugriff auf XPolygon");
+ pImpXPolygon->Resize(nPos + 1, FALSE);
+ }
+ if( nPos >= pImpXPolygon->nPoints )
+ pImpXPolygon->nPoints = nPos + 1;
+
+ return pImpXPolygon->pPointAry[nPos];
+}
+
+/*************************************************************************
+|*
+|* XPolygon::operator=()
+|*
+|* Beschreibung Zuweisungsoperator
+|* Ersterstellung ESO 22.11.94
+|* Letzte Aenderung ESO 12.01.95
+|*
+*************************************************************************/
+
+XPolygon& XPolygon::operator=( const XPolygon& rXPoly )
+{
+ pImpXPolygon->CheckPointDelete();
+
+ rXPoly.pImpXPolygon->nRefCount++;
+
+ if( pImpXPolygon->nRefCount > 1 )
+ pImpXPolygon->nRefCount--;
+ else
+ delete pImpXPolygon;
+
+ pImpXPolygon = rXPoly.pImpXPolygon;
+ return *this;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::operator==()
+|*
+|* Beschreibung Gleichheitsoperator
+|* Ersterstellung ESO 22.11.94
+|* Letzte Aenderung Joe 26.09.95
+|*
+*************************************************************************/
+
+BOOL XPolygon::operator==( const XPolygon& rXPoly ) const
+{
+ pImpXPolygon->CheckPointDelete();
+ if (rXPoly.pImpXPolygon==pImpXPolygon) return TRUE;
+ return *rXPoly.pImpXPolygon == *pImpXPolygon;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::operator!=()
+|*
+|* Beschreibung Ungleichheitsoperator
+|* Ersterstellung ESO 22.11.94
+|* Letzte Aenderung Joe 26.09.95
+|*
+*************************************************************************/
+
+BOOL XPolygon::operator!=( const XPolygon& rXPoly ) const
+{
+ pImpXPolygon->CheckPointDelete();
+ if (rXPoly.pImpXPolygon==pImpXPolygon) return FALSE;
+ return *rXPoly.pImpXPolygon != *pImpXPolygon;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::GetFlags()
+|*
+|* Flags fuer den Punkt an der Position nPos zurueckgeben
+|* Ersterstellung ESO 11.11.94
+|* Letzte Aenderung ESO 12.01.95
+|*
+*************************************************************************/
+
+XPolyFlags XPolygon::GetFlags( USHORT nPos ) const
+{
+ pImpXPolygon->CheckPointDelete();
+ return (XPolyFlags) pImpXPolygon->pFlagAry[nPos];
+}
+
+/*************************************************************************
+|*
+|* XPolygon::SetFlags()
+|*
+|* Flags fuer den Punkt an der Position nPos setzen
+|* Ersterstellung ESO 11.11.94
+|* Letzte Aenderung ESO 12.01.95
+|*
+*************************************************************************/
+
+void XPolygon::SetFlags( USHORT nPos, XPolyFlags eFlags )
+{
+ pImpXPolygon->CheckPointDelete();
+ CheckReference();
+ pImpXPolygon->pFlagAry[nPos] = (BYTE) eFlags;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::IsControl()
+|*
+|* Kurzform zur Abfrage des CONTROL-Flags
+|* Ersterstellung ESO 09.01.95
+|* Letzte Aenderung ESO 12.01.95
+|*
+*************************************************************************/
+
+BOOL XPolygon::IsControl(USHORT nPos) const
+{
+ return ( (XPolyFlags) pImpXPolygon->pFlagAry[nPos] == XPOLY_CONTROL );
+}
+
+/*************************************************************************
+|*
+|* XPolygon::IsSmooth()
+|*
+|* Kurzform zur Abfrage von SMOOTH- und SYMMTR-Flag
+|* Ersterstellung ESO 18.04.95
+|* Letzte Aenderung ESO 18.04.95
+|*
+*************************************************************************/
+
+BOOL XPolygon::IsSmooth(USHORT nPos) const
+{
+ XPolyFlags eFlag = (XPolyFlags) pImpXPolygon->pFlagAry[nPos];
+ return ( eFlag == XPOLY_SMOOTH || eFlag == XPOLY_SYMMTR );
+}
+
+/*************************************************************************
+|*
+|* XPolygon::CalcDistance()
+|*
+|* Abstand zwischen zwei Punkten berechnen
+|* Ersterstellung ESO 09.01.95
+|* Letzte Aenderung ESO 09.01.95
+|*
+*************************************************************************/
+
+double XPolygon::CalcDistance(USHORT nP1, USHORT nP2)
+{
+ const Point& rP1 = pImpXPolygon->pPointAry[nP1];
+ const Point& rP2 = pImpXPolygon->pPointAry[nP2];
+ double fDx = rP2.X() - rP1.X();
+ double fDy = rP2.Y() - rP1.Y();
+ return sqrt(fDx * fDx + fDy * fDy);
+}
+
+/*************************************************************************
+|*
+|* XPolygon::SubdivideBezier()
+|*
+|* Bezierkurve unterteilen
+|* Ersterstellung ESO 09.01.95
+|* Letzte Aenderung ESO 09.01.95
+|*
+*************************************************************************/
+
+void XPolygon::SubdivideBezier(USHORT nPos, BOOL bCalcFirst, double fT)
+{
+ Point* pPoints = pImpXPolygon->pPointAry;
+ double fT2 = fT * fT;
+ double fT3 = fT * fT2;
+ double fU = 1.0 - fT;
+ double fU2 = fU * fU;
+ double fU3 = fU * fU2;
+ USHORT nIdx = nPos;
+ short nPosInc, nIdxInc;
+
+ if ( bCalcFirst )
+ {
+ nPos += 3;
+ nPosInc = -1;
+ nIdxInc = 0;
+ }
+ else
+ {
+ nPosInc = 1;
+ nIdxInc = 1;
+ }
+ pPoints[nPos].X() = (long) (fU3 * pPoints[nIdx ].X() +
+ fT * fU2 * pPoints[nIdx+1].X() * 3 +
+ fT2 * fU * pPoints[nIdx+2].X() * 3 +
+ fT3 * pPoints[nIdx+3].X());
+ pPoints[nPos].Y() = (long) (fU3 * pPoints[nIdx ].Y() +
+ fT * fU2 * pPoints[nIdx+1].Y() * 3 +
+ fT2 * fU * pPoints[nIdx+2].Y() * 3 +
+ fT3 * pPoints[nIdx+3].Y());
+ nPos = nPos + nPosInc;
+ nIdx = nIdx + nIdxInc;
+ pPoints[nPos].X() = (long) (fU2 * pPoints[nIdx ].X() +
+ fT * fU * pPoints[nIdx+1].X() * 2 +
+ fT2 * pPoints[nIdx+2].X());
+ pPoints[nPos].Y() = (long) (fU2 * pPoints[nIdx ].Y() +
+ fT * fU * pPoints[nIdx+1].Y() * 2 +
+ fT2 * pPoints[nIdx+2].Y());
+ nPos = nPos + nPosInc;
+ nIdx = nIdx + nIdxInc;
+ pPoints[nPos].X() = (long) (fU * pPoints[nIdx ].X() +
+ fT * pPoints[nIdx+1].X());
+ pPoints[nPos].Y() = (long) (fU * pPoints[nIdx ].Y() +
+ fT * pPoints[nIdx+1].Y());
+}
+
+/************************************************************************/
+
+void XPolygon::GenBezArc(const Point& rCenter, long nRx, long nRy,
+ long nXHdl, long nYHdl, USHORT nStart, USHORT nEnd,
+ USHORT nQuad, USHORT nFirst)
+{
+ Point* pPoints = pImpXPolygon->pPointAry;
+ pPoints[nFirst ] = rCenter;
+ pPoints[nFirst+3] = rCenter;
+
+ if ( nQuad == 1 || nQuad == 2 )
+ {
+ nRx = -nRx; nXHdl = -nXHdl;
+ }
+ if ( nQuad == 0 || nQuad == 1 )
+ {
+ nRy = -nRy; nYHdl = -nYHdl;
+ }
+
+ if ( nQuad == 0 || nQuad == 2 )
+ {
+ pPoints[nFirst].X() += nRx; pPoints[nFirst+3].Y() += nRy;
+ }
+ else
+ {
+ pPoints[nFirst].Y() += nRy; pPoints[nFirst+3].X() += nRx;
+ }
+ pPoints[nFirst+1] = pPoints[nFirst];
+ pPoints[nFirst+2] = pPoints[nFirst+3];
+
+ if ( nQuad == 0 || nQuad == 2 )
+ {
+ pPoints[nFirst+1].Y() += nYHdl; pPoints[nFirst+2].X() += nXHdl;
+ }
+ else
+ {
+ pPoints[nFirst+1].X() += nXHdl; pPoints[nFirst+2].Y() += nYHdl;
+ }
+ if ( nStart > 0 )
+ SubdivideBezier(nFirst, FALSE, (double)nStart / 900);
+ if ( nEnd < 900 )
+ SubdivideBezier(nFirst, TRUE, (double)(nEnd-nStart) / (900-nStart));
+ SetFlags(nFirst+1, XPOLY_CONTROL);
+ SetFlags(nFirst+2, XPOLY_CONTROL);
+}
+
+/************************************************************************/
+
+BOOL XPolygon::CheckAngles(USHORT& nStart, USHORT nEnd, USHORT& nA1, USHORT& nA2)
+{
+ if ( nStart == 3600 ) nStart = 0;
+ if ( nEnd == 0 ) nEnd = 3600;
+ USHORT nStPrev = nStart;
+ USHORT nMax = (nStart / 900 + 1) * 900;
+ USHORT nMin = nMax - 900;
+
+ if ( nEnd >= nMax || nEnd <= nStart ) nA2 = 900;
+ else nA2 = nEnd - nMin;
+ nA1 = nStart - nMin;
+ nStart = nMax;
+
+ // TRUE zurueck, falls letztes Segment berechnet wurde
+ return (nStPrev < nEnd && nStart >= nEnd);
+}
+
+/*************************************************************************
+|*
+|* XPolygon::CalcSmoothJoin()
+|*
+|* glatten Uebergang zu einer Bezierkurve berechnen, indem der
+|* entsprechende Punkt auf die Verbindungslinie von zwei anderen
+|* Punkten projiziert wird
+|* Center = End- bzw. Anfangspunkt der Bezierkurve
+|* Drag = der bewegte Punkt, der die Verschiebung von Pnt vorgibt
+|* Pnt = der zu modifizierende Punkt
+|* Wenn Center am Anfang bzw. Ende des Polygons liegt, wird Pnt
+|* auf die entgegengesetzte Seite verlegt
+|* Ersterstellung ESO 09.01.95
+|* Letzte Aenderung ESO 18.04.95
+|*
+\************************************************************************/
+
+void XPolygon::CalcSmoothJoin(USHORT nCenter, USHORT nDrag, USHORT nPnt)
+{
+ CheckReference();
+
+// USHORT nMaxPnt = pImpXPolygon->nPoints - 1;
+
+// if ( nCenter == nMaxPnt ) nPnt = 1;
+// else if ( nCenter == 0 ) nPnt = nMaxPnt - 1;
+
+ // Wenn nPnt kein Control-Punkt, d.h. nicht verschiebbar, dann
+ // statt dessen nDrag auf der Achse nCenter-nPnt verschieben
+ if ( !IsControl(nPnt) )
+ {
+ USHORT nTmp = nDrag;
+ nDrag = nPnt;
+ nPnt = nTmp;
+ }
+ Point* pPoints = pImpXPolygon->pPointAry;
+ Point aDiff = pPoints[nDrag] - pPoints[nCenter];
+ double fDiv = CalcDistance(nCenter, nDrag);
+
+ if ( fDiv )
+ {
+ double fRatio = CalcDistance(nCenter, nPnt) / fDiv;
+ // bei SMOOTH bisherige Laenge beibehalten
+ if ( GetFlags(nCenter) == XPOLY_SMOOTH || !IsControl(nDrag) )
+ {
+ aDiff.X() = (long) (fRatio * aDiff.X());
+ aDiff.Y() = (long) (fRatio * aDiff.Y());
+ }
+ pPoints[nPnt] = pPoints[nCenter] - aDiff;
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolygon::CalcTangent()
+|*
+|* Tangente fuer den Uebergang zwischen zwei Bezierkurven berechnen
+|* Center = End- bzw. Anfangspunkt der Bezierkurven
+|* Prev = vorheriger Zugpunkt
+|* Next = naechster Zugpunkt
+|* Ersterstellung ESO 09.01.95
+|* Letzte Aenderung ESO 18.04.95
+|*
+\************************************************************************/
+
+void XPolygon::CalcTangent(USHORT nCenter, USHORT nPrev, USHORT nNext)
+{
+ CheckReference();
+
+ double fAbsLen = CalcDistance(nNext, nPrev);
+
+ if ( fAbsLen )
+ {
+ const Point& rCenter = pImpXPolygon->pPointAry[nCenter];
+ Point& rNext = pImpXPolygon->pPointAry[nNext];
+ Point& rPrev = pImpXPolygon->pPointAry[nPrev];
+ Point aDiff = rNext - rPrev;
+ double fNextLen = CalcDistance(nCenter, nNext) / fAbsLen;
+ double fPrevLen = CalcDistance(nCenter, nPrev) / fAbsLen;
+
+ // bei SYMMTR gleiche Laenge fuer beide Seiten
+ if ( GetFlags(nCenter) == XPOLY_SYMMTR )
+ {
+ fPrevLen = (fNextLen + fPrevLen) / 2;
+ fNextLen = fPrevLen;
+ }
+ rNext.X() = rCenter.X() + (long) (fNextLen * aDiff.X());
+ rNext.Y() = rCenter.Y() + (long) (fNextLen * aDiff.Y());
+ rPrev.X() = rCenter.X() - (long) (fPrevLen * aDiff.X());
+ rPrev.Y() = rCenter.Y() - (long) (fPrevLen * aDiff.Y());
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolygon::PointsToBezier()
+|*
+|* wandelt vier Polygonpunkte in eine Bezierkurve durch diese Punkte um
+|* Ersterstellung ESO 09.01.95
+|* Letzte Aenderung ESO 09.01.95
+|*
+\************************************************************************/
+
+void XPolygon::PointsToBezier(USHORT nFirst)
+{
+ double nFullLength, nPart1Length, nPart2Length;
+ double fX0, fY0, fX1, fY1, fX2, fY2, fX3, fY3;
+ double fTx1, fTx2, fTy1, fTy2;
+ double fT1, fU1, fT2, fU2, fV;
+ Point* pPoints = pImpXPolygon->pPointAry;
+
+ if ( nFirst > pImpXPolygon->nPoints - 4 || IsControl(nFirst) ||
+ IsControl(nFirst+1) || IsControl(nFirst+2) || IsControl(nFirst+3) )
+ return;
+
+ CheckReference();
+
+ fTx1 = pPoints[nFirst+1].X();
+ fTy1 = pPoints[nFirst+1].Y();
+ fTx2 = pPoints[nFirst+2].X();
+ fTy2 = pPoints[nFirst+2].Y();
+ fX0 = pPoints[nFirst ].X();
+ fY0 = pPoints[nFirst ].Y();
+ fX3 = pPoints[nFirst+3].X();
+ fY3 = pPoints[nFirst+3].Y();
+
+ nPart1Length = CalcDistance(nFirst, nFirst+1);
+ nPart2Length = nPart1Length + CalcDistance(nFirst+1, nFirst+2);
+ nFullLength = nPart2Length + CalcDistance(nFirst+2, nFirst+3);
+ if ( nFullLength < 20 )
+ return;
+
+ if ( nPart2Length == nFullLength )
+ nPart2Length -= 1;
+ if ( nPart1Length == nFullLength )
+ nPart1Length = nPart2Length - 1;
+ if ( nPart1Length <= 0 )
+ nPart1Length = 1;
+ if ( nPart2Length <= 0 || nPart2Length == nPart1Length )
+ nPart2Length = nPart1Length + 1;
+
+ fT1 = nPart1Length / nFullLength;
+ fU1 = 1.0 - fT1;
+ fT2 = nPart2Length / nFullLength;
+ fU2 = 1.0 - fT2;
+ fV = 3 * (1.0 - (fT1 * fU2) / (fT2 * fU1));
+
+ fX1 = fTx1 / (fT1 * fU1 * fU1) - fTx2 * fT1 / (fT2 * fT2 * fU1 * fU2);
+ fX1 /= fV;
+ fX1 -= fX0 * ( fU1 / fT1 + fU2 / fT2) / 3;
+ fX1 += fX3 * ( fT1 * fT2 / (fU1 * fU2)) / 3;
+
+ fY1 = fTy1 / (fT1 * fU1 * fU1) - fTy2 * fT1 / (fT2 * fT2 * fU1 * fU2);
+ fY1 /= fV;
+ fY1 -= fY0 * ( fU1 / fT1 + fU2 / fT2) / 3;
+ fY1 += fY3 * ( fT1 * fT2 / (fU1 * fU2)) / 3;
+
+ fX2 = fTx2 / (fT2 * fT2 * fU2 * 3) - fX0 * fU2 * fU2 / ( fT2 * fT2 * 3);
+ fX2 -= fX1 * fU2 / fT2;
+ fX2 -= fX3 * fT2 / (fU2 * 3);
+
+ fY2 = fTy2 / (fT2 * fT2 * fU2 * 3) - fY0 * fU2 * fU2 / ( fT2 * fT2 * 3);
+ fY2 -= fY1 * fU2 / fT2;
+ fY2 -= fY3 * fT2 / (fU2 * 3);
+
+ pPoints[nFirst+1] = Point((long) fX1, (long) fY1);
+ pPoints[nFirst+2] = Point((long) fX2, (long) fY2);
+ SetFlags(nFirst+1, XPOLY_CONTROL);
+ SetFlags(nFirst+2, XPOLY_CONTROL);
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Translate()
+|*
+|* Polygon auf den uebergebenen Punkt verschieben
+|* Ersterstellung ESO 17.01.95
+|* Letzte Aenderung ESO 17.01.95
+|*
+*************************************************************************/
+
+void XPolygon::Translate(const Point& rTrans)
+{
+ pImpXPolygon->CheckPointDelete();
+ CheckReference();
+
+ USHORT nPntCnt = pImpXPolygon->nPoints;
+
+ for (USHORT i = 0; i < nPntCnt; i++)
+ pImpXPolygon->pPointAry[i] += rTrans;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Rotate()
+|*
+|* Alle Punkte um den Punkt rCenter drehen, Sinus und Cosinus
+|* muessen uebergeben werden
+|* Ersterstellung ESO 09.01.95
+|* Letzte Aenderung ESO 17.01.95
+|*
+*************************************************************************/
+
+void XPolygon::Rotate(const Point& rCenter, double fSin, double fCos)
+{
+ pImpXPolygon->CheckPointDelete();
+ CheckReference();
+
+ long nX;
+ long nY;
+ long nNewX;
+ long nNewY;
+ long nCenterX = rCenter.X();
+ long nCenterY = rCenter.Y();
+
+ USHORT nPntCnt = pImpXPolygon->nPoints;
+
+ for (USHORT i = 0; i < nPntCnt; i++)
+ {
+ Point *pPt = &(pImpXPolygon->pPointAry[i]);
+ nX = pPt->X()-nCenterX;
+ nY = pPt->Y()-nCenterY;
+ nNewX = (long)floor(fCos * nX + fSin * nY + 0.5);
+ nNewY = -(long)floor(fSin * nX - fCos * nY + 0.5);
+ pPt->X() = nNewX + nCenterX;
+ pPt->Y() = nNewY + nCenterY;
+
+ /* und so stand das in einem anderen File auf T:
+ dass ich am 29-11-1995 gegettet habe. Joe M.
+ USHORT nPntCnt = pImpXPolygon->nPoints;
+
+ for (USHORT i = 0; i < nPntCnt; i++)
+ {
+ Point P = pImpXPolygon->pPointAry[i] - rCenter;
+ long X = P.X();
+ long Y = P.Y();
+ P.X() = (long)floor(fCos * X + fSin * Y + 0.5);
+ P.Y() = -(long)floor(fSin * X - fCos * Y + 0.5);
+ pImpXPolygon->pPointAry[i] = P + rCenter;
+ */
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Rotate()
+|*
+|* Alle Punkte um den Punkt rCenter mit dem Winkel nAngle drehen
+|* Winkel in 10tel Grad, Wertebereich 0 - 3600
+|* Ersterstellung ESO 17.01.95
+|* Letzte Aenderung ESO 17.01.95
+|*
+*************************************************************************/
+
+void XPolygon::Rotate(const Point& rCenter, USHORT nAngle)
+{
+ nAngle %= 3600;
+
+ if ( nAngle != 0 )
+ {
+ double fAngle = F_PI * nAngle / 1800;
+ double fSin = sin(fAngle);
+ double fCos = cos(fAngle);
+ Rotate(rCenter, fSin, fCos);
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Scale()
+|*
+|* XPolygon in X- und/oder Y-Richtung skalieren
+|* Ersterstellung ESO 01.02.95
+|* Letzte Aenderung ESO 01.02.95
+|*
+*************************************************************************/
+
+void XPolygon::Scale(double fSx, double fSy)
+{
+ pImpXPolygon->CheckPointDelete();
+ CheckReference();
+
+ USHORT nPntCnt = pImpXPolygon->nPoints;
+
+ for (USHORT i = 0; i < nPntCnt; i++)
+ {
+ Point& rPnt = pImpXPolygon->pPointAry[i];
+ rPnt.X() = (long)(fSx * rPnt.X());
+ rPnt.Y() = (long)(fSy * rPnt.Y());
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolygon::SlantX()
+|*
+|* XPolygon in X-Richtung um einen beliebigen Winkel kippen,
+|* bezogen auf eine Referenz-Y-Koordinate
+|* Ersterstellung ESO 01.02.95
+|* Letzte Aenderung ESO 01.02.95
+|*
+*************************************************************************/
+
+void XPolygon::SlantX(long nYRef, double fSin, double fCos)
+{
+ pImpXPolygon->CheckPointDelete();
+ CheckReference();
+
+ USHORT nPntCnt = pImpXPolygon->nPoints;
+
+ for (USHORT i = 0; i < nPntCnt; i++)
+ {
+ Point& rPnt = pImpXPolygon->pPointAry[i];
+ long nDy = rPnt.Y() - nYRef;
+ rPnt.X() += (long)(fSin * nDy);
+ rPnt.Y() = nYRef + (long)(fCos * nDy);
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolygon::SlantY()
+|*
+|* XPolygon in Y-Richtung um einen beliebigen Winkel kippen,
+|* bezogen auf eine Referenz-X-Koordinate
+|* Ersterstellung ESO 01.02.95
+|* Letzte Aenderung ESO 01.02.95
+|*
+*************************************************************************/
+
+void XPolygon::SlantY(long nXRef, double fSin, double fCos)
+{
+ pImpXPolygon->CheckPointDelete();
+ CheckReference();
+
+ USHORT nPntCnt = pImpXPolygon->nPoints;
+
+ for (USHORT i = 0; i < nPntCnt; i++)
+ {
+ Point& rPnt = pImpXPolygon->pPointAry[i];
+ long nDx = rPnt.X() - nXRef;
+ rPnt.X() = nXRef + (long)(fCos * nDx);
+ rPnt.Y() -= (long)(fSin * nDx);
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Distort()
+|*
+|* XPolygon verzerren, indem die Koordinaten relativ zu einem
+|* Referenzrechteck in ein beliebiges Viereck skaliert werden
+|* Zuordnung der Viereck-Punkte im Polygon zum Referenzrechteck:
+|* 0: links oben 0----1
+|* 1: rechts oben | |
+|* 2: rechts unten 3----2
+|* 3: links unten
+|* Ersterstellung ESO 07.07.95
+|* Letzte Aenderung ESO 07.07.95
+|*
+*************************************************************************/
+
+void XPolygon::Distort(const Rectangle& rRefRect,
+ const XPolygon& rDistortedRect)
+{
+ pImpXPolygon->CheckPointDelete();
+ CheckReference();
+
+ long Xr, Wr, X1, X2, X3, X4;
+ long Yr, Hr, Y1, Y2, Y3, Y4;
+ double fTx, fTy, fUx, fUy;
+
+ Xr = rRefRect.Left();
+ Yr = rRefRect.Top();
+ Wr = rRefRect.GetWidth();
+ Hr = rRefRect.GetHeight();
+
+ if ( Wr && Hr )
+ {
+ DBG_ASSERT(rDistortedRect.pImpXPolygon->nPoints >= 4,
+ "Distort-Rechteck zu klein");
+
+ X1 = rDistortedRect[0].X();
+ Y1 = rDistortedRect[0].Y();
+ X2 = rDistortedRect[1].X();
+ Y2 = rDistortedRect[1].Y();
+ X3 = rDistortedRect[3].X();
+ Y3 = rDistortedRect[3].Y();
+ X4 = rDistortedRect[2].X();
+ Y4 = rDistortedRect[2].Y();
+
+ USHORT nPntCnt = pImpXPolygon->nPoints;
+
+ for (USHORT i = 0; i < nPntCnt; i++)
+ {
+ Point& rPnt = pImpXPolygon->pPointAry[i];
+
+ fTx = (double)(rPnt.X() - Xr) / Wr;
+ fTy = (double)(rPnt.Y() - Yr) / Hr;
+ fUx = 1.0 - fTx;
+ fUy = 1.0 - fTy;
+
+ rPnt.X() = (long) ( fUy * (fUx * X1 + fTx * X2) +
+ fTy * (fUx * X3 + fTx * X4) );
+ rPnt.Y() = (long) ( fUx * (fUy * Y1 + fTy * Y3) +
+ fTx * (fUy * Y2 + fTy * Y4) );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Bestimme den linken, unteren Punkt des Polygons und richte das
+|* Polygon so aus, dass dieser Punkt auf dem Index 0 liegt
+|*
+\************************************************************************/
+
+void XPolygon::Rotate20()
+{
+ pImpXPolygon->CheckPointDelete();
+ CheckReference();
+
+ double fMinY = pImpXPolygon->pPointAry->Y();
+ double fMinX = pImpXPolygon->pPointAry->X();
+ long nPntCnt = pImpXPolygon->nPoints;
+ long nIndex0 = 0;
+
+ for (long nPoints = 1; nPoints < nPntCnt; ++nPoints)
+ {
+ const Point &rPnt = pImpXPolygon->pPointAry[nPoints];
+
+ if ( (rPnt.X() < fMinX) || (fMinX == rPnt.X() && fMinY >= rPnt.Y()) )
+ {
+ fMinX = rPnt.X();
+ fMinY = rPnt.Y();
+ nIndex0 = nPoints;
+ }
+ }
+
+ if (nIndex0 < nPntCnt)
+ {
+ Point *pTemp = new Point [nIndex0];
+ memcpy (pTemp, pImpXPolygon->pPointAry, nIndex0 * sizeof (Point));
+ memcpy (pImpXPolygon->pPointAry, &pImpXPolygon->pPointAry [nIndex0], (nPntCnt - nIndex0) * sizeof (Point));
+ memcpy (&pImpXPolygon->pPointAry [nIndex0], pTemp, nIndex0 * sizeof (Point));
+ delete[] pTemp;
+ }
+}
+
+basegfx::B2DPolygon XPolygon::getB2DPolygon() const
+{
+ // #i74631# use tools Polygon class for conversion to not have the code doubled
+ // here. This needs one more conversion but avoids different convertors in
+ // the long run
+ DBG_ASSERT(pImpXPolygon != 0, "XPolygon::getB2DPolygon(): XPolygon has no implementation incarnated (!)");
+ const Polygon aSource(GetPointCount(), pImpXPolygon->pPointAry, pImpXPolygon->pFlagAry);
+
+ return aSource.getB2DPolygon();
+}
+
+XPolygon::XPolygon(const basegfx::B2DPolygon& rPolygon)
+{
+ // #i74631# use tools Polygon class for conversion to not have the code doubled
+ // here. This needs one more conversion but avoids different convertors in
+ // the long run
+ DBG_CTOR(XPolygon,NULL);
+
+ const Polygon aSource(rPolygon);
+ USHORT nSize = aSource.GetSize();
+ pImpXPolygon = new ImpXPolygon( nSize );
+ pImpXPolygon->nPoints = nSize;
+
+ for( USHORT i = 0; i < nSize; i++ )
+ {
+ pImpXPolygon->pPointAry[i] = aSource[i];
+ pImpXPolygon->pFlagAry[i] = (BYTE) aSource.GetFlags( i );
+ }
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//+--------------- XPolyPolygon -----------------------------------------+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+/*************************************************************************
+|*
+|* ImpXPolyPolygon::ImpXPolyPolygon()
+|*
+|* Beschreibung Erzeugt das XPolygon-Array
+|* Ersterstellung CL 09.11.94
+|* Letzte Aenderung MM 09.11.94
+|*
+*************************************************************************/
+
+ImpXPolyPolygon::ImpXPolyPolygon( const ImpXPolyPolygon& rImpXPolyPoly ) :
+ aXPolyList( rImpXPolyPoly.aXPolyList )
+{
+ nRefCount = 1;
+
+ // Einzelne Elemente duplizieren
+ XPolygon* pXPoly = aXPolyList.First();
+ while ( pXPoly )
+ {
+ aXPolyList.Replace( new XPolygon( *(aXPolyList.GetCurObject()) ) );
+ pXPoly = aXPolyList.Next();
+ }
+}
+
+
+/*************************************************************************
+|*
+|* ImpXPolyPolygon::~ImpXPolyPolygon()
+|*
+|* Beschreibung Loescht das Polygon-Array
+|* Ersterstellung CL 09.06.93
+|* Letzte Aenderung CL 09.06.93
+|*
+*************************************************************************/
+
+ImpXPolyPolygon::~ImpXPolyPolygon()
+{
+ XPolygon* pXPoly = aXPolyList.First();
+ while( pXPoly )
+ {
+ delete pXPoly;
+ pXPoly = aXPolyList.Next();
+ }
+}
+
+/*************************************************************************
+|*
+|* ImpXPolyPolygon::operator==()
+|*
+|* Ersterstellung Joe 26-09-95
+|* Letzte Aenderung
+|*
+*************************************************************************/
+
+
+bool ImpXPolyPolygon::operator==(const ImpXPolyPolygon& rImpXPolyPoly) const
+{
+ USHORT nAnz=(USHORT)aXPolyList.Count();
+ const XPolygonList& rCmpList=rImpXPolyPoly.aXPolyList;
+ if (nAnz!=(USHORT)rCmpList.Count()) return FALSE;
+ bool bEq=true;
+ for (USHORT i=nAnz; i>0 && bEq;) {
+ i--;
+ bEq= *aXPolyList.GetObject(i) == *rCmpList.GetObject(i);
+ }
+ return bEq;
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::XPolyPolygon()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung CL 27.01.93
+|*
+*************************************************************************/
+
+XPolyPolygon::XPolyPolygon( USHORT nInitSize, USHORT nResize )
+{
+ DBG_CTOR(XPolyPolygon,NULL);
+ pImpXPolyPolygon = new ImpXPolyPolygon( nInitSize, nResize );
+}
+
+
+/*************************************************************************
+|*
+|* XPolyPolygon::XPolyPolygon()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung CL 27.01.93
+|*
+*************************************************************************/
+
+XPolyPolygon::XPolyPolygon( const XPolygon& rXPoly )
+{
+ DBG_CTOR(XPolyPolygon,NULL);
+ pImpXPolyPolygon = new ImpXPolyPolygon;
+ pImpXPolyPolygon->aXPolyList.Insert( new XPolygon( rXPoly ) );
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::XPolyPolygon()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung CL 27.01.93
+|*
+*************************************************************************/
+
+XPolyPolygon::XPolyPolygon( const XPolyPolygon& rXPolyPoly )
+{
+ DBG_CTOR(XPolyPolygon,NULL);
+ pImpXPolyPolygon = rXPolyPoly.pImpXPolyPolygon;
+ pImpXPolyPolygon->nRefCount++;
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::XPolyPolygon()
+|*
+|* XPolyPolygon aus einen Standard-PolyPolygon erzeugen
+|* Ersterstellung 18.01.95 ESO
+|* Letzte Aenderung 18.01.95 ESO
+|*
+*************************************************************************/
+
+XPolyPolygon::XPolyPolygon( const PolyPolygon& rPolyPoly )
+{
+ DBG_CTOR(XPolyPolygon,NULL);
+ pImpXPolyPolygon = new ImpXPolyPolygon;
+
+ for (USHORT i = 0; i < rPolyPoly.Count(); i++)
+ pImpXPolyPolygon->aXPolyList.Insert(
+ new XPolygon(rPolyPoly.GetObject(i)) );
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::~XPolyPolygon()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung CL 27.01.93
+|*
+*************************************************************************/
+
+XPolyPolygon::~XPolyPolygon()
+{
+ DBG_DTOR(XPolyPolygon,NULL);
+ if( pImpXPolyPolygon->nRefCount > 1 )
+ pImpXPolyPolygon->nRefCount--;
+ else
+ delete pImpXPolyPolygon;
+}
+
+/*************************************************************************
+|*
+|* XPolygon::CheckReference()
+|*
+|* Referenzzaehler desImpXPolyPoly pruefen und ggf. von diesem abkoppeln
+|* Ersterstellung 18.01.95 ESO
+|* Letzte Aenderung 18.01.95 ESO
+|*
+*************************************************************************/
+
+void XPolyPolygon::CheckReference()
+{
+ if( pImpXPolyPolygon->nRefCount > 1 )
+ {
+ pImpXPolyPolygon->nRefCount--;
+ pImpXPolyPolygon = new ImpXPolyPolygon( *pImpXPolyPolygon );
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Insert()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung CL 27.01.93
+|*
+*************************************************************************/
+
+void XPolyPolygon::Insert( const XPolygon& rXPoly, USHORT nPos )
+{
+ CheckReference();
+ XPolygon* pXPoly = new XPolygon( rXPoly );
+ pImpXPolyPolygon->aXPolyList.Insert( pXPoly, nPos );
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Insert()
+|*
+|* saemtliche XPolygone aus einem XPolyPolygon einfuegen
+|* Ersterstellung 18.01.95 ESO
+|* Letzte Aenderung 18.01.95 ESO
+|*
+*************************************************************************/
+
+void XPolyPolygon::Insert( const XPolyPolygon& rXPolyPoly, USHORT nPos )
+{
+ CheckReference();
+
+ for (USHORT i = 0; i < rXPolyPoly.Count(); i++)
+ {
+ XPolygon* pXPoly = new XPolygon(rXPolyPoly[i]);
+ pImpXPolyPolygon->aXPolyList.Insert(pXPoly, nPos);
+ if ( nPos != XPOLYPOLY_APPEND )
+ nPos++;
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Remove()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung CL 27.01.93
+|*
+*************************************************************************/
+
+XPolygon XPolyPolygon::Remove( USHORT nPos )
+{
+ CheckReference();
+ XPolygon* pTmpXPoly = pImpXPolyPolygon->aXPolyList.Remove( nPos );
+ XPolygon aXPoly( *pTmpXPoly );
+ delete pTmpXPoly;
+ return aXPoly;
+}
+
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Replace()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung CL 27.01.93
+|*
+*************************************************************************/
+
+XPolygon XPolyPolygon::Replace( const XPolygon& rXPoly, USHORT nPos )
+{
+ CheckReference();
+ XPolygon* pXPoly = new XPolygon( rXPoly );
+ XPolygon* pTmpXPoly = pImpXPolyPolygon->aXPolyList.Replace( pXPoly, nPos );
+ XPolygon aXPoly( *pTmpXPoly );
+ delete pTmpXPoly;
+ return aXPoly;
+}
+
+
+/*************************************************************************
+|*
+|* XPolyPolygon::GetObject()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung CL 27.01.93
+|*
+*************************************************************************/
+
+const XPolygon& XPolyPolygon::GetObject( USHORT nPos ) const
+{
+ return *(pImpXPolyPolygon->aXPolyList.GetObject( nPos ));
+}
+
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Clear()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung TH 17.10.94
+|*
+*************************************************************************/
+
+void XPolyPolygon::Clear()
+{
+ if ( pImpXPolyPolygon->nRefCount > 1 )
+ {
+ pImpXPolyPolygon->nRefCount--;
+ pImpXPolyPolygon = new ImpXPolyPolygon();
+ }
+ else
+ {
+ XPolygon* pXPoly = pImpXPolyPolygon->aXPolyList.First();
+ while( pXPoly )
+ {
+ delete pXPoly;
+ pXPoly = pImpXPolyPolygon->aXPolyList.Next();
+ }
+ pImpXPolyPolygon->aXPolyList.Clear();
+ }
+}
+
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Count()
+|*
+|* Beschreibung
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung CL 27.01.93
+|*
+*************************************************************************/
+
+USHORT XPolyPolygon::Count() const
+{
+ return (USHORT)(pImpXPolyPolygon->aXPolyList.Count());
+}
+
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Move()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung TH 04.10.94
+|* Letzte Aenderung TH 04.10.94
+|*
+*************************************************************************/
+
+void XPolyPolygon::Move( long nHorzMove, long nVertMove )
+{
+ // Diese Abfrage sollte man fuer die DrawEngine durchfuehren
+ if ( !nHorzMove && !nVertMove )
+ return;
+
+ // Referenzcounter beruecksichtigen
+ CheckReference();
+
+ // Punkte verschieben
+ XPolygon* pXPoly = pImpXPolyPolygon->aXPolyList.First();
+ while( pXPoly )
+ {
+ pXPoly->Move( nHorzMove, nVertMove );
+ pXPoly = pImpXPolyPolygon->aXPolyList.Next();
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::GetBoundRect()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung TH 04.10.94
+|* Letzte Aenderung TH 04.10.94
+|*
+*************************************************************************/
+
+Rectangle XPolyPolygon::GetBoundRect() const
+{
+ USHORT nXPoly = (USHORT)pImpXPolyPolygon->aXPolyList.Count();
+ Rectangle aRect;
+
+ for ( USHORT n = 0; n < nXPoly; n++ )
+ {
+ const XPolygon* pXPoly = pImpXPolyPolygon->aXPolyList.GetObject( n );
+ aRect.Union( pXPoly->GetBoundRect() );
+ }
+
+ return aRect;
+}
+
+
+/*************************************************************************
+|*
+|* XPolyPolygon::operator[]()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung TH 28.10.94
+|* Letzte Aenderung TH 28.10.94
+|*
+*************************************************************************/
+
+XPolygon& XPolyPolygon::operator[]( USHORT nPos )
+{
+ CheckReference();
+ return *(pImpXPolyPolygon->aXPolyList.GetObject( nPos ));
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::operator=()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung CL 27.01.93
+|*
+*************************************************************************/
+
+XPolyPolygon& XPolyPolygon::operator=( const XPolyPolygon& rXPolyPoly )
+{
+ rXPolyPoly.pImpXPolyPolygon->nRefCount++;
+
+ if( pImpXPolyPolygon->nRefCount > 1 )
+ pImpXPolyPolygon->nRefCount--;
+ else
+ delete pImpXPolyPolygon;
+
+ pImpXPolyPolygon = rXPolyPoly.pImpXPolyPolygon;
+ return *this;
+}
+
+
+/*************************************************************************
+|*
+|* XPolyPolygon::operator==()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung Joe 27.01.93
+|*
+*************************************************************************/
+
+BOOL XPolyPolygon::operator==( const XPolyPolygon& rXPolyPoly ) const
+{
+ if (pImpXPolyPolygon==rXPolyPoly.pImpXPolyPolygon) return TRUE;
+ return *pImpXPolyPolygon == *rXPolyPoly.pImpXPolyPolygon;
+}
+
+
+/*************************************************************************
+|*
+|* XPolyPolygon::operator!=()
+|*
+|* Beschreibung POLY.SDW
+|* Ersterstellung CL 27.01.93
+|* Letzte Aenderung Joe 27.01.93
+|*
+*************************************************************************/
+
+BOOL XPolyPolygon::operator!=( const XPolyPolygon& rXPolyPoly ) const
+{
+ if (pImpXPolyPolygon==rXPolyPoly.pImpXPolyPolygon) return FALSE;
+ return *pImpXPolyPolygon != *rXPolyPoly.pImpXPolyPolygon;
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Translate()
+|*
+|* Alle Polygone auf den uebergebenen Punkt verschieben
+|* Ersterstellung ESO 25.01.95
+|* Letzte Aenderung ESO 25.01.95
+|*
+*************************************************************************/
+
+void XPolyPolygon::Translate(const Point& rTrans)
+{
+ CheckReference();
+
+ for (USHORT i = 0; i < Count(); i++)
+ pImpXPolyPolygon->aXPolyList.GetObject(i)->Translate(rTrans);
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Rotate()
+|*
+|* Alle Polygone um den Punkt rCenter drehen, Sinus und Cosinus
+|* muessen uebergeben werden
+|* Ersterstellung ESO 25.01.95
+|* Letzte Aenderung ESO 25.01.95
+|*
+*************************************************************************/
+
+void XPolyPolygon::Rotate(const Point& rCenter, double fSin, double fCos)
+{
+ CheckReference();
+
+ for (USHORT i = 0; i < Count(); i++)
+ pImpXPolyPolygon->aXPolyList.GetObject(i)->Rotate(rCenter, fSin, fCos);
+}
+
+/*************************************************************************
+|*
+|* Bestimme den linken, unteren Punkt des Polygons und richte das
+|* Polygon so aus, dass dieser Punkt auf dem Index 0 liegt
+|*
+\************************************************************************/
+
+void XPolyPolygon::Rotate20()
+{
+ CheckReference();
+
+ for (USHORT i = 0; i < Count(); i++)
+ pImpXPolyPolygon->aXPolyList.GetObject(i)->Rotate20();
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Rotate()
+|*
+|* Alle Poylgone um den Punkt rCenter mit dem Winkel nAngle drehen
+|* Winkel in 10tel Grad, Wertebereich 0 - 3600
+|* Ersterstellung ESO 25.01.95
+|* Letzte Aenderung ESO 25.01.95
+|*
+*************************************************************************/
+
+void XPolyPolygon::Rotate(const Point& rCenter, USHORT nAngle)
+{
+ nAngle %= 3600;
+
+ if ( nAngle != 0 )
+ {
+ double fAngle = F_PI * nAngle / 1800;
+ double fSin = sin(fAngle);
+ double fCos = cos(fAngle);
+ Rotate(rCenter, fSin, fCos);
+ }
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::Scale()
+|*
+|* Alle Polygone in X- und/oder Y-Richtung skalieren
+|* Ersterstellung ESO 01.02.95
+|* Letzte Aenderung ESO 01.02.95
+|*
+*************************************************************************/
+
+void XPolyPolygon::Scale(double fSx, double fSy)
+{
+ CheckReference();
+
+ for (USHORT i = 0; i < Count(); i++)
+ pImpXPolyPolygon->aXPolyList.GetObject(i)->Scale(fSx, fSy);
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::SlantX()
+|*
+|* Alle Polygone in X-Richtung um einen beliebigen Winkel kippen,
+|* bezogen auf eine Referenz-Y-Koordinate
+|* Ersterstellung ESO 01.02.95
+|* Letzte Aenderung ESO 01.02.95
+|*
+*************************************************************************/
+
+void XPolyPolygon::SlantX(long nYRef, double fSin, double fCos)
+{
+ CheckReference();
+
+ for (USHORT i = 0; i < Count(); i++)
+ pImpXPolyPolygon->aXPolyList.GetObject(i)->SlantX(nYRef, fSin, fCos);
+}
+
+/*************************************************************************
+|*
+|* XPolyPolygon::SlantY()
+|*
+|* Alle Polygone in Y-Richtung um einen beliebigen Winkel kippen,
+|* bezogen auf eine Referenz-X-Koordinate
+|* Ersterstellung ESO 01.02.95
+|* Letzte Aenderung ESO 01.02.95
+|*
+*************************************************************************/
+
+void XPolyPolygon::SlantY(long nXRef, double fSin, double fCos)
+{
+ CheckReference();
+
+ for (USHORT i = 0; i < Count(); i++)
+ pImpXPolyPolygon->aXPolyList.GetObject(i)->SlantY(nXRef, fSin, fCos);
+}
+
+/*************************************************************************
+|*
+|* XPolygon::Distort()
+|*
+|* XPolygon verzerren, indem die Koordinaten relativ zu einem
+|* Referenzrechteck in ein beliebiges Viereck skaliert werden
+|* Zuordnung der Viereck-Punkte im Polygon zum Referenzrechteck:
+|* 0: links oben 0----1
+|* 1: rechts oben | |
+|* 2: rechts unten 3----2
+|* 3: links unten
+|* Ersterstellung ESO 07.07.95
+|* Letzte Aenderung ESO 07.07.95
+|*
+*************************************************************************/
+
+void XPolyPolygon::Distort(const Rectangle& rRefRect,
+ const XPolygon& rDistortedRect)
+{
+ CheckReference();
+
+ for (USHORT i = 0; i < Count(); i++)
+ pImpXPolyPolygon->aXPolyList.GetObject(i)->Distort(rRefRect,
+ rDistortedRect);
+}
+
+basegfx::B2DPolyPolygon XPolyPolygon::getB2DPolyPolygon() const
+{
+ basegfx::B2DPolyPolygon aRetval;
+
+ for(sal_uInt16 a(0L); a < Count(); a++)
+ {
+ const XPolygon& rPoly = (*this)[a];
+ aRetval.append(rPoly.getB2DPolygon());
+ }
+
+ return aRetval;
+}
+
+XPolyPolygon::XPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon)
+{
+ DBG_CTOR(XPolyPolygon,NULL);
+ pImpXPolyPolygon = new ImpXPolyPolygon( 16, 16 );
+
+ for(sal_uInt32 a(0L); a < rPolyPolygon.count(); a++)
+ {
+ basegfx::B2DPolygon aCandidate = rPolyPolygon.getB2DPolygon(a);
+ XPolygon aNewPoly(aCandidate);
+ Insert(aNewPoly);
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/makefile.mk b/svx/source/xoutdev/makefile.mk
new file mode 100644
index 000000000000..1ed48bc71f08
--- /dev/null
+++ b/svx/source/xoutdev/makefile.mk
@@ -0,0 +1,59 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=svx
+PROJECTPCH=xout
+PROJECTPCHSOURCE=xoutpch
+TARGET=xout
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/xattr.obj \
+ $(SLO)$/xattr2.obj \
+ $(SLO)$/xattrbmp.obj \
+ $(SLO)$/xpool.obj \
+ $(SLO)$/xtable.obj \
+ $(SLO)$/xtabcolr.obj \
+ $(SLO)$/xtablend.obj \
+ $(SLO)$/xtabdash.obj \
+ $(SLO)$/xtabhtch.obj \
+ $(SLO)$/xtabgrdt.obj \
+ $(SLO)$/xtabbtmp.obj \
+ $(SLO)$/xexch.obj \
+ $(SLO)$/_xpoly.obj \
+ $(SLO)$/_xoutbmp.obj
+
+.INCLUDE : target.mk
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
new file mode 100644
index 000000000000..f6f0c850787a
--- /dev/null
+++ b/svx/source/xoutdev/xattr.cxx
@@ -0,0 +1,5780 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include <com/sun/star/drawing/Hatch.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/drawing/DashStyle.hpp>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/drawing/PointSequence.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <svl/itempool.hxx>
+#include <editeng/memberids.hrc>
+#include <tools/stream.hxx>
+
+#include "unoapi.hxx"
+#include <svl/style.hxx>
+#include "unopolyhelper.hxx"
+
+#include <tools/bigint.hxx>
+#include <svl/itemset.hxx>
+#include <svx/dialogs.hrc>
+#include "svdstr.hrc"
+#include "xattr.hxx"
+#include <svx/xtable.hxx>
+#include <svx/dialmgr.hxx>
+#include <editeng/itemtype.hxx>
+#include <svx/xdef.hxx>
+#include <svx/unomid.hxx>
+#include <svx/svdmodel.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/vector/b2dvector.hxx>
+
+#include <stdio.h>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+
+#define GLOBALOVERFLOW
+
+#define TWIP_TO_MM100(TWIP) ((TWIP) >= 0 ? (((TWIP)*127L+36L)/72L) : (((TWIP)*127L-36L)/72L))
+#define MM100_TO_TWIP(MM100) ((MM100) >= 0 ? (((MM100)*72L+63L)/127L) : (((MM100)*72L-63L)/127L))
+
+/************************************************************************/
+
+#define VCLTOSVCOL( rCol ) (USHORT)((((USHORT)(rCol))<<8)|(rCol))
+
+/************************************************************************/
+
+XubString aNameOrIndexEmptyString;
+
+TYPEINIT1_AUTOFACTORY(NameOrIndex, SfxStringItem);
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+long ScaleMetricValue( long nVal, long nMul, long nDiv )
+{
+ BigInt aVal( nVal );
+
+ aVal *= nMul;
+
+ if ( aVal.IsNeg() != ( nDiv < 0 ) )
+ aVal-=nDiv/2; // fuer korrektes Runden
+ else
+ aVal+=nDiv/2; // fuer korrektes Runden
+
+ aVal/=nDiv;
+
+ return long( aVal );
+}
+
+/*************************************************************************
+|*
+|* NameOrIndex::NameOrIndex(USHORT nWhich, INT32 nIndex)
+|*
+|* Beschreibung
+|* Ersterstellung 14.11.94
+|* Letzte Aenderung 14.11.94
+|*
+*************************************************************************/
+
+NameOrIndex::NameOrIndex(USHORT _nWhich, INT32 nIndex) :
+ SfxStringItem(_nWhich, aNameOrIndexEmptyString),
+ nPalIndex(nIndex)
+{
+}
+
+/*************************************************************************
+|*
+|* NameOrIndex::NameOrIndex(USHORT nWhich, const String& rName)
+|*
+|* Beschreibung
+|* Ersterstellung 14.11.94
+|* Letzte Aenderung 14.11.94
+|*
+*************************************************************************/
+
+NameOrIndex::NameOrIndex(USHORT _nWhich, const XubString& rName) :
+ SfxStringItem(_nWhich, rName),
+ nPalIndex(-1)
+{
+}
+
+/*************************************************************************
+|*
+|* NameOrIndex::NameOrIndex(USHORT nWhich, SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 14.11.94
+|* Letzte Aenderung 14.11.94
+|*
+*************************************************************************/
+
+NameOrIndex::NameOrIndex(USHORT _nWhich, SvStream& rIn) :
+ SfxStringItem(_nWhich, rIn)
+{
+ rIn >> nPalIndex;
+}
+
+/*************************************************************************
+|*
+|* NameOrIndex::NameOrIndex(const NameOrIndex& rNameOrIndex)
+|*
+|* Beschreibung
+|* Ersterstellung 14.11.94
+|* Letzte Aenderung 14.11.94
+|*
+*************************************************************************/
+
+NameOrIndex::NameOrIndex(const NameOrIndex& rNameOrIndex) :
+ SfxStringItem(rNameOrIndex),
+ nPalIndex(rNameOrIndex.nPalIndex)
+{
+}
+
+/*************************************************************************
+|*
+|* int NameOrIndex::operator==(const SfxPoolItem& rItem) const
+|*
+|* Beschreibung
+|* Ersterstellung 14.11.94
+|* Letzte Aenderung 14.11.94
+|*
+*************************************************************************/
+
+int NameOrIndex::operator==(const SfxPoolItem& rItem) const
+{
+ return ( SfxStringItem::operator==(rItem) &&
+ ((const NameOrIndex&) rItem).nPalIndex == nPalIndex );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* NameOrIndex::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 14.11.94
+|* Letzte Aenderung 14.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* NameOrIndex::Clone(SfxItemPool* /*pPool*/) const
+{
+
+ return new NameOrIndex(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* NameOrIndex::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 14.11.94
+|* Letzte Aenderung 14.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* NameOrIndex::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new NameOrIndex(Which(), rIn);
+}
+
+/*************************************************************************
+|*
+|* SvStream* NameOrIndex::Store(SvStream& rIn) const
+|*
+|* Beschreibung
+|* Ersterstellung 14.11.94
+|* Letzte Aenderung 14.11.94
+|*
+*************************************************************************/
+
+SvStream& NameOrIndex::Store( SvStream& rOut, USHORT nItemVersion ) const
+{
+ SfxStringItem::Store( rOut, nItemVersion );
+ rOut << nPalIndex;
+ return rOut;
+}
+
+/** this static checks if the given NameOrIndex item has a unique name for its value.
+ The returned String is a unique name for an item with this value in both given pools.
+ Argument pPool2 can be null.
+ If returned string equals NameOrIndex->GetName(), the name was already unique.
+*/
+String NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_uInt16 nWhich, const SfxItemPool* pPool1, const SfxItemPool* /*pPool2*/, SvxCompareValueFunc pCompareValueFunc, USHORT nPrefixResId, XPropertyList* pDefaults )
+{
+ sal_Bool bForceNew = sal_False;
+
+ String aUniqueName;
+ SvxUnogetInternalNameForItem( nWhich, pCheckItem->GetName(), aUniqueName );
+
+ // 2. if we have a name check if there is already an item with the
+ // same name in the documents pool with a different line end or start
+
+ if( aUniqueName.Len() && pPool1 )
+ {
+ const sal_uInt16 nCount = pPool1->GetItemCount( nWhich );
+
+ const NameOrIndex *pItem;
+ for( sal_uInt16 nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)pPool1->GetItem( nWhich, nSurrogate );
+
+ if( pItem && ( pItem->GetName() == pCheckItem->GetName() ) )
+ {
+ // if there is already an item with the same name and the same
+ // value its ok to set it
+ if( !pCompareValueFunc( pItem, pCheckItem ) )
+ {
+ // same name but different value, we need a new name for this item
+ aUniqueName = String();
+ bForceNew = sal_True;
+ }
+ break;
+ }
+ }
+ }
+
+ // if we have no name yet, find existing item with same conent or
+ // create a unique name
+ if( aUniqueName.Len() == 0 )
+ {
+ sal_Int32 nUserIndex = 1;
+ const ResId aRes(SVX_RES(nPrefixResId));
+ String aUser( aRes );
+ aUser += sal_Unicode( ' ' );
+
+ if( pDefaults )
+ {
+ const int nCount = pDefaults->Count();
+ int nIndex;
+ for( nIndex = 0; nIndex < nCount; nIndex++ )
+ {
+ XPropertyEntry* pEntry = pDefaults->Get( nIndex, 0 );
+ if( pEntry )
+ {
+ bool bFound = false;
+
+ switch( nWhich )
+ {
+ case XATTR_FILLBITMAP:
+ bFound = (((XFillBitmapItem*)pCheckItem)->GetBitmapValue().GetGraphicObject().GetUniqueID() ==
+ ((XBitmapEntry*)pEntry)->GetXBitmap().GetGraphicObject().GetUniqueID());
+ break;
+ case XATTR_LINEDASH:
+ bFound = (((XLineDashItem*)pCheckItem)->GetDashValue() == ((XDashEntry*)pEntry) ->GetDash());
+ break;
+ case XATTR_LINESTART:
+ bFound = (((XLineStartItem*)pCheckItem)->GetLineStartValue() == ((XLineEndEntry*)pEntry)->GetLineEnd());
+ break;
+ case XATTR_LINEEND:
+ bFound = (((XLineEndItem*)pCheckItem)->GetLineEndValue() == ((XLineEndEntry*)pEntry)->GetLineEnd());
+ break;
+ case XATTR_FILLGRADIENT:
+ bFound = (((XFillGradientItem*)pCheckItem)->GetGradientValue() == ((XGradientEntry*)pEntry)->GetGradient());
+ break;
+ case XATTR_FILLHATCH:
+ bFound = (((XFillHatchItem*)pCheckItem)->GetHatchValue() == ((XHatchEntry*)pEntry)->GetHatch());
+ break;
+ }
+
+ if( bFound )
+ {
+ aUniqueName = pEntry->GetName();
+ break;
+ }
+ else
+ {
+ sal_Int32 nThisIndex = pEntry->GetName().Copy( aUser.Len() ).ToInt32();
+ if( nThisIndex >= nUserIndex )
+ nUserIndex = nThisIndex + 1;
+ }
+ }
+ }
+ }
+
+ if( (aUniqueName.Len() == 0) && pPool1 )
+ {
+ const sal_uInt16 nCount = pPool1->GetItemCount( nWhich );
+ const NameOrIndex *pItem;
+ for( sal_uInt16 nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ pItem = (NameOrIndex*)pPool1->GetItem( nWhich, nSurrogate );
+
+ if( pItem && pItem->GetName().Len() )
+ {
+ if( !bForceNew && pCompareValueFunc( pItem, pCheckItem ) )
+ return pItem->GetName();
+
+ if( pItem->GetName().CompareTo( aUser, aUser.Len() ) == 0 )
+ {
+ sal_Int32 nThisIndex = pItem->GetName().Copy( aUser.Len() ).ToInt32();
+ if( nThisIndex >= nUserIndex )
+ nUserIndex = nThisIndex + 1;
+ }
+ }
+ }
+ aUniqueName = aUser;
+ aUniqueName += String::CreateFromInt32( nUserIndex );
+ }
+ }
+
+ return aUniqueName;
+}
+
+//*************************************************************************
+
+// -------------------
+// class XColorItem
+// -------------------
+TYPEINIT1_AUTOFACTORY(XColorItem, NameOrIndex);
+
+/*************************************************************************
+|*
+|* XColorItem::XColorItem(USHORT nWhich, INT32 nIndex, const Color& rTheColor)
+|*
+\************************************************************************/
+
+XColorItem::XColorItem(USHORT _nWhich, INT32 nIndex, const Color& rTheColor) :
+ NameOrIndex(_nWhich, nIndex),
+ aColor(rTheColor)
+{
+}
+
+/*************************************************************************
+|*
+|* XColorItem::XColorItem(USHORT nWhich, const String& rName, const Color& rTheColor)
+|*
+\************************************************************************/
+
+XColorItem::XColorItem(USHORT _nWhich, const XubString& rName, const Color& rTheColor) :
+ NameOrIndex(_nWhich, rName),
+ aColor(rTheColor)
+{
+}
+
+/*************************************************************************
+|*
+|* XColorItem::XColorItem(const XColorItem& rItem)
+|*
+\************************************************************************/
+
+XColorItem::XColorItem(const XColorItem& rItem) :
+ NameOrIndex(rItem),
+ aColor(rItem.aColor)
+{
+}
+
+/*************************************************************************
+|*
+|* XColorItem::XColorItem(USHORT nWhich, SvStream& rIn)
+|*
+\************************************************************************/
+
+XColorItem::XColorItem(USHORT _nWhich, SvStream& rIn) :
+ NameOrIndex(_nWhich, rIn)
+{
+ if (!IsIndex())
+ {
+ rIn >> aColor;
+ }
+}
+
+/*************************************************************************
+|*
+|* XColorItem::Clone(SfxItemPool* pPool) const
+|*
+\************************************************************************/
+
+SfxPoolItem* XColorItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XColorItem(*this);
+}
+
+/*************************************************************************
+|*
+|* int XColorItem::operator==(const SfxPoolItem& rItem) const
+|*
+\************************************************************************/
+
+int XColorItem::operator==(const SfxPoolItem& rItem) const
+{
+ return ( NameOrIndex::operator==(rItem) &&
+ ((const XColorItem&) rItem).aColor == aColor );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XColorItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+\************************************************************************/
+
+SfxPoolItem* XColorItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XColorItem(Which(), rIn);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XColorItem::Store(SvStream& rOut) const
+|*
+\************************************************************************/
+
+SvStream& XColorItem::Store( SvStream& rOut, USHORT nItemVersion ) const
+{
+ NameOrIndex::Store( rOut, nItemVersion );
+
+ if ( !IsIndex() )
+ {
+ rOut << aColor;
+ }
+
+ return rOut;
+}
+
+/*************************************************************************
+|*
+|* const XColor& XColorItem::GetColorValue(const XColorTable* pTable) const
+|*
+\************************************************************************/
+
+const Color& XColorItem::GetColorValue(const XColorTable* pTable) const
+{
+ if (!IsIndex())
+ return aColor;
+ else
+ return pTable->GetColor(GetIndex())->GetColor();
+
+}
+
+bool XColorItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetColorValue().GetRGBColor();
+ return true;
+}
+
+bool XColorItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ rVal >>= nValue;
+ SetColorValue( nValue );
+
+ return true;
+}
+
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Linienattribute
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------
+// class XLineStyleItem
+//---------------------
+TYPEINIT1_AUTOFACTORY(XLineStyleItem, SfxEnumItem);
+
+/*************************************************************************
+|*
+|* XLineStyleItem::XLineStyleItem(XLineStyle eTheLineStyle)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+XLineStyleItem::XLineStyleItem(XLineStyle eTheLineStyle) :
+ SfxEnumItem(XATTR_LINESTYLE, sal::static_int_cast< USHORT >(eTheLineStyle))
+{
+}
+
+/*************************************************************************
+|*
+|* XLineStyleItem::XLineStyleItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineStyleItem::XLineStyleItem(SvStream& rIn) :
+ SfxEnumItem(XATTR_LINESTYLE, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineStyleItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 09.11.94
+|* Letzte Aenderung 09.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineStyleItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineStyleItem( *this );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineStyleItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineStyleItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineStyleItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineStyleItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ {
+ USHORT nId = 0;
+
+ switch( (USHORT)GetValue() )
+ {
+ case XLINE_NONE:
+ nId = RID_SVXSTR_INVISIBLE;
+ break;
+ case XLINE_SOLID:
+ nId = RID_SVXSTR_SOLID;
+ break;
+ }
+
+ if ( nId )
+ rText = SVX_RESSTR( nId );
+ return ePres;
+ }
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+bool XLineStyleItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ ::com::sun::star::drawing::LineStyle eLS = (::com::sun::star::drawing::LineStyle)GetValue();
+ rVal <<= eLS;
+ return true;
+}
+
+bool XLineStyleItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ ::com::sun::star::drawing::LineStyle eLS;
+ if(!(rVal >>= eLS ))
+ {
+ // also try an int (for Basic)
+ sal_Int32 nLS = 0;
+ if(!(rVal >>= nLS))
+ return false;
+ eLS = (::com::sun::star::drawing::LineStyle)nLS;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( eLS ) );
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+USHORT XLineStyleItem::GetValueCount() const
+{
+ return 3;
+}
+
+
+// ------------
+// class XDash
+// ------------
+/*************************************************************************
+|*
+|* XDash::XDash(XDashStyle, USHORT, ULONG, USHORT, ULONG, ULONG)
+|*
+|* Beschreibung
+|* Ersterstellung 21.11.94
+|* Letzte Aenderung 21.11.94
+|*
+*************************************************************************/
+
+XDash::XDash(XDashStyle eTheDash, USHORT nTheDots, ULONG nTheDotLen,
+ USHORT nTheDashes, ULONG nTheDashLen, ULONG nTheDistance) :
+ eDash(eTheDash),
+ nDots(nTheDots),
+ nDotLen(nTheDotLen),
+ nDashes(nTheDashes),
+ nDashLen(nTheDashLen),
+ nDistance(nTheDistance)
+{
+}
+
+/*************************************************************************
+|*
+|* int XDash::operator==(const SfxPoolItem& rItem) const
+|*
+|* Beschreibung
+|* Ersterstellung 29.11.94
+|* Letzte Aenderung 29.11.94
+|*
+*************************************************************************/
+
+bool XDash::operator==(const XDash& rDash) const
+{
+ return ( eDash == rDash.eDash &&
+ nDots == rDash.nDots &&
+ nDotLen == rDash.nDotLen &&
+ nDashes == rDash.nDashes &&
+ nDashLen == rDash.nDashLen &&
+ nDistance == rDash.nDistance );
+}
+
+// XDash is translated into an array of doubles which describe the lengths of the
+// dashes, dots and empty passages. It returns the complete length of the full DashDot
+// sequence and fills the given vetor of doubles accordingly (also resizing, so deleting it).
+static double SMALLEST_DASH_WIDTH(26.95);
+double XDash::CreateDotDashArray(::std::vector< double >& rDotDashArray, double fLineWidth) const
+{
+ double fFullDotDashLen(0.0);
+ const sal_uInt16 nNumDotDashArray = (GetDots() + GetDashes()) * 2;
+ rDotDashArray.resize( nNumDotDashArray, 0.0 );
+ sal_uInt16 a;
+ sal_uInt16 nIns(0);
+ double fDashDotDistance = (double)GetDistance();
+ double fSingleDashLen = (double)GetDashLen();
+ double fSingleDotLen = (double)GetDotLen();
+
+ if(GetDashStyle() == XDASH_RECTRELATIVE || GetDashStyle() == XDASH_ROUNDRELATIVE)
+ {
+ if(fLineWidth != 0.0)
+ {
+ double fFactor = fLineWidth / 100.0;
+
+ if(GetDashes())
+ {
+ if(GetDashLen())
+ {
+ // is a dash
+ fSingleDashLen *= fFactor;
+ }
+ else
+ {
+ // is a dot
+ fSingleDashLen = fLineWidth;
+ }
+ }
+
+ if(GetDots())
+ {
+ if(GetDotLen())
+ {
+ // is a dash
+ fSingleDotLen *= fFactor;
+ }
+ else
+ {
+ // is a dot
+ fSingleDotLen = fLineWidth;
+ }
+ }
+
+ if(GetDashes() || GetDots())
+ {
+ if(GetDistance())
+ {
+ fDashDotDistance *= fFactor;
+ }
+ else
+ {
+ fDashDotDistance = fLineWidth;
+ }
+ }
+ }
+ else
+ {
+ if(GetDashes())
+ {
+ if(GetDashLen())
+ {
+ // is a dash
+ fSingleDashLen = (SMALLEST_DASH_WIDTH * fSingleDashLen) / 100.0;
+ }
+ else
+ {
+ // is a dot
+ fSingleDashLen = SMALLEST_DASH_WIDTH;
+ }
+ }
+
+ if(GetDots())
+ {
+ if(GetDotLen())
+ {
+ // is a dash
+ fSingleDotLen = (SMALLEST_DASH_WIDTH * fSingleDotLen) / 100.0;
+ }
+ else
+ {
+ // is a dot
+ fSingleDotLen = SMALLEST_DASH_WIDTH;
+ }
+ }
+
+ if(GetDashes() || GetDots())
+ {
+ if(GetDistance())
+ {
+ // dash as distance
+ fDashDotDistance = (SMALLEST_DASH_WIDTH * fDashDotDistance) / 100.0;
+ }
+ else
+ {
+ // dot as distance
+ fDashDotDistance = SMALLEST_DASH_WIDTH;
+ }
+ }
+ }
+ }
+ else
+ {
+ // smallest dot size compare value
+ double fDotCompVal(fLineWidth != 0.0 ? fLineWidth : SMALLEST_DASH_WIDTH);
+
+ // absolute values
+ if(GetDashes())
+ {
+ if(GetDashLen())
+ {
+ // is a dash
+ if(fSingleDashLen < SMALLEST_DASH_WIDTH)
+ {
+ fSingleDashLen = SMALLEST_DASH_WIDTH;
+ }
+ }
+ else
+ {
+ // is a dot
+ if(fSingleDashLen < fDotCompVal)
+ {
+ fSingleDashLen = fDotCompVal;
+ }
+ }
+ }
+
+ if(GetDots())
+ {
+ if(GetDotLen())
+ {
+ // is a dash
+ if(fSingleDotLen < SMALLEST_DASH_WIDTH)
+ {
+ fSingleDotLen = SMALLEST_DASH_WIDTH;
+ }
+ }
+ else
+ {
+ // is a dot
+ if(fSingleDotLen < fDotCompVal)
+ {
+ fSingleDotLen = fDotCompVal;
+ }
+ }
+ }
+
+ if(GetDashes() || GetDots())
+ {
+ if(GetDistance())
+ {
+ // dash as distance
+ if(fDashDotDistance < SMALLEST_DASH_WIDTH)
+ {
+ fDashDotDistance = SMALLEST_DASH_WIDTH;
+ }
+ }
+ else
+ {
+ // dot as distance
+ if(fDashDotDistance < fDotCompVal)
+ {
+ fDashDotDistance = fDotCompVal;
+ }
+ }
+ }
+ }
+
+ for(a=0;a<GetDots();a++)
+ {
+ rDotDashArray[nIns++] = fSingleDotLen;
+ fFullDotDashLen += fSingleDotLen;
+ rDotDashArray[nIns++] = fDashDotDistance;
+ fFullDotDashLen += fDashDotDistance;
+ }
+
+ for(a=0;a<GetDashes();a++)
+ {
+ rDotDashArray[nIns++] = fSingleDashLen;
+ fFullDotDashLen += fSingleDashLen;
+ rDotDashArray[nIns++] = fDashDotDistance;
+ fFullDotDashLen += fDashDotDistance;
+ }
+
+ return fFullDotDashLen;
+}
+
+// -------------------
+// class XLineDashItem
+// -------------------
+TYPEINIT1_AUTOFACTORY(XLineDashItem, NameOrIndex);
+
+/*************************************************************************
+|*
+|* XLineDashItem::XLineDashItem(INT32 nIndex, const XDash& rTheDash)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineDashItem::XLineDashItem(INT32 nIndex, const XDash& rTheDash) :
+ NameOrIndex(XATTR_LINEDASH, nIndex),
+ aDash(rTheDash)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineDashItem::XLineDashItem(const String& rName, const XDash& rTheDash)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineDashItem::XLineDashItem(const XubString& rName, const XDash& rTheDash) :
+ NameOrIndex(XATTR_LINEDASH, rName),
+ aDash(rTheDash)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineDashItem::XLineDashItem(const XLineDashItem& rItem)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineDashItem::XLineDashItem(const XLineDashItem& rItem) :
+ NameOrIndex(rItem),
+ aDash(rItem.aDash)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineDashItem::XLineDashItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineDashItem::XLineDashItem(SvStream& rIn) :
+ NameOrIndex(XATTR_LINEDASH, rIn)
+{
+ if (!IsIndex())
+ {
+ USHORT nSTemp;
+ UINT32 nLTemp;
+ INT32 nITemp;
+
+ rIn >> nITemp; aDash.SetDashStyle((XDashStyle)nITemp);
+ rIn >> nSTemp; aDash.SetDots(nSTemp);
+ rIn >> nLTemp; aDash.SetDotLen(nLTemp);
+ rIn >> nSTemp; aDash.SetDashes(nSTemp);
+ rIn >> nLTemp; aDash.SetDashLen(nLTemp);
+ rIn >> nLTemp; aDash.SetDistance(nLTemp);
+ }
+}
+
+//*************************************************************************
+
+XLineDashItem::XLineDashItem(SfxItemPool* /*pPool*/, const XDash& rTheDash)
+: NameOrIndex( XATTR_LINEDASH, -1 ),
+ aDash(rTheDash)
+{
+}
+
+//*************************************************************************
+
+XLineDashItem::XLineDashItem(SfxItemPool* /*pPool*/)
+: NameOrIndex(XATTR_LINEDASH, -1 )
+{
+}
+
+/*************************************************************************
+|*
+|* XLineDashItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineDashItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineDashItem(*this);
+}
+
+/*************************************************************************
+|*
+|* int XLineDashItem::operator==(const SfxPoolItem& rItem) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+int XLineDashItem::operator==(const SfxPoolItem& rItem) const
+{
+ return ( NameOrIndex::operator==(rItem) &&
+ aDash == ((const XLineDashItem&) rItem).aDash );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineDashItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineDashItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineDashItem(rIn);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineDashItem::Store(SvStream& rOut) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SvStream& XLineDashItem::Store( SvStream& rOut, USHORT nItemVersion ) const
+{
+ NameOrIndex::Store( rOut, nItemVersion );
+
+ if (!IsIndex())
+ {
+ rOut << (INT32) aDash.GetDashStyle();
+ rOut << aDash.GetDots();
+ rOut << (UINT32) aDash.GetDotLen();
+ rOut << aDash.GetDashes();
+ rOut << (UINT32) aDash.GetDashLen();
+ rOut << (UINT32) aDash.GetDistance();
+ }
+
+ return rOut;
+}
+
+/*************************************************************************
+|*
+|* const XDash& XLineDashItem::GetValue(const XDashTable* pTable) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+const XDash& XLineDashItem::GetDashValue(const XDashTable* pTable) const // GetValue -> GetDashValue
+{
+ if (!IsIndex())
+ return aDash;
+ else
+ return pTable->GetDash(GetIndex())->GetDash();
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineDashItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetName();
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+//------------------------------------------------------------------------
+
+bool XLineDashItem::HasMetrics() const
+{
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+bool XLineDashItem::ScaleMetrics(long nMul, long nDiv)
+{
+ aDash.SetDotLen( ScaleMetricValue( aDash.GetDotLen(), nMul, nDiv ) );
+ aDash.SetDashLen( ScaleMetricValue( aDash.GetDashLen(), nMul, nDiv ) );
+ aDash.SetDistance( ScaleMetricValue( aDash.GetDistance(), nMul, nDiv ) );
+ return true;
+}
+
+bool XLineDashItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ switch ( nMemberId )
+ {
+ case 0:
+ {
+ uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
+
+ ::com::sun::star::drawing::LineDash aLineDash;
+
+ const XDash& rXD = GetDashValue();
+ aLineDash.Style = (::com::sun::star::drawing::DashStyle)((UINT16)rXD.GetDashStyle());
+ aLineDash.Dots = rXD.GetDots();
+ aLineDash.DotLen = rXD.GetDotLen();
+ aLineDash.Dashes = rXD.GetDashes();
+ aLineDash.DashLen = rXD.GetDashLen();
+ aLineDash.Distance = rXD.GetDistance();
+
+ rtl::OUString aApiName;
+ SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
+ aPropSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ));
+ aPropSeq[0].Value = uno::makeAny( aApiName );
+ aPropSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LineDash" ));
+ aPropSeq[1].Value = uno::makeAny( aLineDash );
+ rVal = uno::makeAny( aPropSeq );
+ break;
+ }
+
+ case MID_NAME:
+ {
+ rtl::OUString aApiName;
+ SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
+ rVal <<= aApiName;
+ break;
+ }
+
+ case MID_LINEDASH:
+ {
+ const XDash& rXD = GetDashValue();
+
+ ::com::sun::star::drawing::LineDash aLineDash;
+
+ aLineDash.Style = (::com::sun::star::drawing::DashStyle)((UINT16)rXD.GetDashStyle());
+ aLineDash.Dots = rXD.GetDots();
+ aLineDash.DotLen = rXD.GetDotLen();
+ aLineDash.Dashes = rXD.GetDashes();
+ aLineDash.DashLen = rXD.GetDashLen();
+ aLineDash.Distance = rXD.GetDistance();
+
+ rVal <<= aLineDash;
+ break;
+ }
+
+ case MID_LINEDASH_STYLE:
+ {
+ const XDash& rXD = GetDashValue();
+ rVal <<= (::com::sun::star::drawing::DashStyle)((sal_Int16)rXD.GetDashStyle());
+ break;
+ }
+
+ case MID_LINEDASH_DOTS:
+ {
+ const XDash& rXD = GetDashValue();
+ rVal <<= rXD.GetDots();
+ break;
+ }
+
+ case MID_LINEDASH_DOTLEN:
+ {
+ const XDash& rXD = GetDashValue();
+ rVal <<= rXD.GetDotLen();
+ break;
+ }
+
+ case MID_LINEDASH_DASHES:
+ {
+ const XDash& rXD = GetDashValue();
+ rVal <<= rXD.GetDashes();
+ break;
+ }
+
+ case MID_LINEDASH_DASHLEN:
+ {
+ const XDash& rXD = GetDashValue();
+ rVal <<= rXD.GetDashLen();
+ break;
+ }
+
+ case MID_LINEDASH_DISTANCE:
+ {
+ const XDash& rXD = GetDashValue();
+ rVal <<= rXD.GetDistance();
+ break;
+ }
+
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ return true;
+}
+
+bool XLineDashItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ switch ( nMemberId )
+ {
+ case 0:
+ {
+ uno::Sequence< beans::PropertyValue > aPropSeq;
+ ::com::sun::star::drawing::LineDash aLineDash;
+ rtl::OUString aName;
+ sal_Bool bLineDash( sal_False );
+
+ if ( rVal >>= aPropSeq )
+ {
+ for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ )
+ {
+ if ( aPropSeq[n].Name.equalsAsciiL( "Name", 4 ))
+ aPropSeq[n].Value >>= aName;
+ else if ( aPropSeq[n].Name.equalsAsciiL( "LineDash", 8 ))
+ {
+ if ( aPropSeq[n].Value >>= aLineDash )
+ bLineDash = true;
+ }
+ }
+
+ SetName( aName );
+ if ( bLineDash )
+ {
+ XDash aXDash;
+
+ aXDash.SetDashStyle((XDashStyle)((UINT16)(aLineDash.Style)));
+ aXDash.SetDots(aLineDash.Dots);
+ aXDash.SetDotLen(aLineDash.DotLen);
+ aXDash.SetDashes(aLineDash.Dashes);
+ aXDash.SetDashLen(aLineDash.DashLen);
+ aXDash.SetDistance(aLineDash.Distance);
+
+ if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
+ aXDash.SetDots(1);
+
+ SetDashValue( aXDash );
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ case MID_NAME:
+ {
+ rtl::OUString aName;
+ if (!(rVal >>= aName))
+ return false;
+ SetName( aName );
+ break;
+ }
+
+ case MID_LINEDASH:
+ {
+ ::com::sun::star::drawing::LineDash aLineDash;
+ if(!(rVal >>= aLineDash))
+ return false;
+
+ XDash aXDash;
+
+ aXDash.SetDashStyle((XDashStyle)((UINT16)(aLineDash.Style)));
+ aXDash.SetDots(aLineDash.Dots);
+ aXDash.SetDotLen(aLineDash.DotLen);
+ aXDash.SetDashes(aLineDash.Dashes);
+ aXDash.SetDashLen(aLineDash.DashLen);
+ aXDash.SetDistance(aLineDash.Distance);
+
+ if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
+ aXDash.SetDots(1);
+
+ SetDashValue( aXDash );
+ break;
+ }
+
+ case MID_LINEDASH_STYLE:
+ {
+ sal_Int16 nVal = sal_Int16();
+ if(!(rVal >>= nVal))
+ return false;
+
+ XDash aXDash = GetDashValue();
+ aXDash.SetDashStyle((XDashStyle)((UINT16)(nVal)));
+
+ if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
+ aXDash.SetDots(1);
+
+ SetDashValue( aXDash );
+
+ break;
+ }
+
+ case MID_LINEDASH_DOTS:
+ case MID_LINEDASH_DASHES:
+ {
+ sal_Int16 nVal = sal_Int16();
+ if(!(rVal >>= nVal))
+ return false;
+
+ XDash aXDash = GetDashValue();
+ if ( nMemberId == MID_LINEDASH_DOTS )
+ aXDash.SetDots( nVal );
+ else
+ aXDash.SetDashes( nVal );
+
+ if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
+ aXDash.SetDots(1);
+
+ SetDashValue( aXDash );
+ break;
+ }
+
+ case MID_LINEDASH_DOTLEN:
+ case MID_LINEDASH_DASHLEN:
+ case MID_LINEDASH_DISTANCE:
+ {
+ sal_Int32 nVal = 0;
+ if(!(rVal >>= nVal))
+ return false;
+
+ XDash aXDash = GetDashValue();
+ if ( nMemberId == MID_LINEDASH_DOTLEN )
+ aXDash.SetDotLen( nVal );
+ else if ( nMemberId == MID_LINEDASH_DASHLEN )
+ aXDash.SetDashLen( nVal );
+ else
+ aXDash.SetDistance( nVal );
+
+ if((0 == aXDash.GetDots()) && (0 == aXDash.GetDashes()))
+ aXDash.SetDots(1);
+
+ SetDashValue( aXDash );
+ break;
+ }
+ }
+
+ return true;
+}
+
+BOOL XLineDashItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
+{
+ return ((XLineDashItem*)p1)->GetDashValue() == ((XLineDashItem*)p2)->GetDashValue();
+}
+
+XLineDashItem* XLineDashItem::checkForUniqueItem( SdrModel* pModel ) const
+{
+ if( pModel )
+ {
+ const String aUniqueName = NameOrIndex::CheckNamedItem( this,
+ XATTR_LINEDASH,
+ &pModel->GetItemPool(),
+ pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL,
+ XLineDashItem::CompareValueFunc,
+ RID_SVXSTR_DASH11,
+ pModel->GetDashList() );
+
+ // if the given name is not valid, replace it!
+ if( aUniqueName != GetName() )
+ {
+ return new XLineDashItem( aUniqueName, aDash );
+ }
+ }
+
+ return (XLineDashItem*)this;
+}
+
+// -------------------
+// class XLineWidthItem
+// -------------------
+TYPEINIT1_AUTOFACTORY(XLineWidthItem, SfxMetricItem);
+
+/*************************************************************************
+|*
+|* XLineWidthItem::XLineWidthItem(long nWidth)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+XLineWidthItem::XLineWidthItem(long nWidth) :
+ SfxMetricItem(XATTR_LINEWIDTH, nWidth)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineWidthItem::XLineWidthItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineWidthItem::XLineWidthItem(SvStream& rIn) :
+ SfxMetricItem(XATTR_LINEWIDTH, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineWidthItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineWidthItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineWidthItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineWidthItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineWidthItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineWidthItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineWidthItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit ePresUnit,
+ XubString& rText, const IntlWrapper * pIntl
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetMetricText( (long) GetValue(),
+ eCoreUnit, ePresUnit, pIntl);
+ rText += SVX_RESSTR( GetMetricId( ePresUnit) );
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+bool XLineWidthItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+ sal_Int32 nValue = GetValue();
+ if( 0 != (nMemberId&CONVERT_TWIPS) )
+ nValue = TWIP_TO_MM100(nValue);
+
+ rVal <<= nValue;
+ return true;
+}
+
+bool XLineWidthItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+ sal_Int32 nValue = 0;
+ rVal >>= nValue;
+ if( 0 != (nMemberId&CONVERT_TWIPS) )
+ nValue = MM100_TO_TWIP(nValue);
+
+ SetValue( nValue );
+ return true;
+}
+
+// -------------------
+// class XLineColorItem
+// -------------------
+TYPEINIT1_AUTOFACTORY(XLineColorItem, XColorItem);
+
+/*************************************************************************
+|*
+|* XLineColorItem::XLineColorItem(INT32 nIndex, const Color& rTheColor)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineColorItem::XLineColorItem(INT32 nIndex, const Color& rTheColor) :
+ XColorItem(XATTR_LINECOLOR, nIndex, rTheColor)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineColorItem::XLineColorItem(const XubString& rName, const Color& rTheColor)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineColorItem::XLineColorItem(const XubString& rName, const Color& rTheColor) :
+ XColorItem(XATTR_LINECOLOR, rName, rTheColor)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineColorItem::XLineColorItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineColorItem::XLineColorItem(SvStream& rIn) :
+ XColorItem(XATTR_LINECOLOR, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineColorItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineColorItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineColorItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineColorItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineColorItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineColorItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineColorItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetName();
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+bool XLineColorItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetColorValue().GetRGBColor();
+ return true;
+}
+
+bool XLineColorItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue))
+ return false;
+
+ SetColorValue( nValue );
+ return true;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// tooling for simple spooling B2DPolygon to file and back
+
+namespace
+{
+ void streamOutB2DPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon, SvStream& rOut)
+ {
+ const sal_uInt32 nPolygonCount(rPolyPolygon.count());
+ rOut << nPolygonCount;
+
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
+ {
+ const basegfx::B2DPolygon aCandidate(rPolyPolygon.getB2DPolygon(a));
+ const sal_uInt32 nPointCount(aCandidate.count());
+ const sal_uInt8 bClosed(aCandidate.isClosed() ? 1 : 0);
+ const sal_uInt8 bControlPoints(aCandidate.areControlPointsUsed() ? 1 : 0);
+ rOut << nPointCount;
+ rOut << bClosed;
+ rOut << bControlPoints;
+
+ for(sal_uInt32 b(0L); b < nPointCount; b++)
+ {
+ const basegfx::B2DPoint aPoint(aCandidate.getB2DPoint(b));
+ rOut << aPoint.getX();
+ rOut << aPoint.getY();
+
+ if(bControlPoints)
+ {
+ const sal_uInt8 bEdgeIsCurve(aCandidate.isPrevControlPointUsed(b) || aCandidate.isNextControlPointUsed(b) ? 1 : 0);
+ rOut << bEdgeIsCurve;
+
+ if(bEdgeIsCurve)
+ {
+ const basegfx::B2DVector aControlVectorA(aCandidate.getPrevControlPoint(b));
+ rOut << aControlVectorA.getX();
+ rOut << aControlVectorA.getY();
+
+ const basegfx::B2DVector aControlVectorB(aCandidate.getNextControlPoint(b));
+ rOut << aControlVectorB.getX();
+ rOut << aControlVectorB.getY();
+ }
+ }
+ }
+ }
+ }
+
+ basegfx::B2DPolyPolygon streamInB2DPolyPolygon(SvStream& rIn)
+ {
+ basegfx::B2DPolyPolygon aRetval;
+ sal_uInt32 nPolygonCount;
+ rIn >> nPolygonCount;
+
+ for(sal_uInt32 a(0L); a < nPolygonCount; a++)
+ {
+ sal_uInt32 nPointCount;
+ sal_uInt8 bClosed;
+ sal_uInt8 bControlPoints;
+
+ rIn >> nPointCount;
+ rIn >> bClosed;
+ rIn >> bControlPoints;
+
+ basegfx::B2DPolygon aCandidate;
+ aCandidate.setClosed(0 != bClosed);
+
+ for(sal_uInt32 b(0L); b < nPointCount; b++)
+ {
+ double fX, fY;
+ rIn >> fX;
+ rIn >> fY;
+ aCandidate.append(basegfx::B2DPoint(fX, fY));
+
+ if(0 != bControlPoints)
+ {
+ sal_uInt8 bEdgeIsCurve;
+ rIn >> bEdgeIsCurve;
+
+ if(0 != bEdgeIsCurve)
+ {
+ rIn >> fX;
+ rIn >> fY;
+ aCandidate.setPrevControlPoint(b, basegfx::B2DVector(fX, fY));
+
+ rIn >> fX;
+ rIn >> fY;
+ aCandidate.setNextControlPoint(b, basegfx::B2DVector(fX, fY));
+ }
+ }
+ }
+
+ aRetval.append(aCandidate);
+ }
+
+ return aRetval;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+// -----------------------
+// class XLineStartItem
+// -----------------------
+TYPEINIT1_AUTOFACTORY(XLineStartItem, NameOrIndex);
+
+/*************************************************************************
+|*
+|* XLineStartItem::XLineStartItem(INT32 nIndex)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+XLineStartItem::XLineStartItem(INT32 nIndex)
+: NameOrIndex(XATTR_LINESTART, nIndex)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineStartItem::XLineStartItem(const XubString& rName,
+|* const basegfx::B2DPolyPolygon& rXPolygon)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+XLineStartItem::XLineStartItem(const XubString& rName, const basegfx::B2DPolyPolygon& rPolyPolygon)
+: NameOrIndex(XATTR_LINESTART, rName),
+ maPolyPolygon(rPolyPolygon)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineStartItem::XLineStartItem(const XLineStartItem& rItem)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 17.11.94
+|*
+*************************************************************************/
+
+XLineStartItem::XLineStartItem(const XLineStartItem& rItem)
+: NameOrIndex(rItem),
+ maPolyPolygon(rItem.maPolyPolygon)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineStartItem::XLineStartItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 17.11.94
+|*
+*************************************************************************/
+
+XLineStartItem::XLineStartItem(SvStream& rIn) :
+ NameOrIndex(XATTR_LINESTART, rIn)
+{
+ if (!IsIndex())
+ {
+ maPolyPolygon = streamInB2DPolyPolygon(rIn);
+ }
+}
+
+//*************************************************************************
+
+XLineStartItem::XLineStartItem(SfxItemPool* /*pPool*/, const basegfx::B2DPolyPolygon& rPolyPolygon)
+: NameOrIndex( XATTR_LINESTART, -1 ),
+ maPolyPolygon(rPolyPolygon)
+{
+}
+
+//*************************************************************************
+
+XLineStartItem::XLineStartItem(SfxItemPool* /*pPool*/)
+: NameOrIndex(XATTR_LINESTART, -1 )
+{
+}
+
+/*************************************************************************
+|*
+|* XLineStartItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineStartItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineStartItem(*this);
+}
+
+/*************************************************************************
+|*
+|* int XLineStartItem::operator==(const SfxPoolItem& rItem) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+int XLineStartItem::operator==(const SfxPoolItem& rItem) const
+{
+ return ( NameOrIndex::operator==(rItem) && ((const XLineStartItem&) rItem).maPolyPolygon == maPolyPolygon );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineStartItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineStartItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineStartItem(rIn);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineStartItem::Store(SvStream& rOut) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+SvStream& XLineStartItem::Store( SvStream& rOut, USHORT nItemVersion ) const
+{
+ NameOrIndex::Store( rOut, nItemVersion );
+
+ if (!IsIndex())
+ {
+ streamOutB2DPolyPolygon(maPolyPolygon, rOut);
+ }
+
+ return rOut;
+}
+
+/*************************************************************************
+|*
+|* const basegfx::B2DPolyPolygon& XLineStartItem::GetValue(const XLineEndTable* pTable)
+|* const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+basegfx::B2DPolyPolygon XLineStartItem::GetLineStartValue(const XLineEndTable* pTable) const
+{
+ if (!IsIndex())
+ {
+ return maPolyPolygon;
+ }
+ else
+ {
+ return pTable->GetLineEnd(GetIndex())->GetLineEnd();
+ }
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineStartItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetName();
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+bool XLineStartItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ if( nMemberId == MID_NAME )
+ {
+ rtl::OUString aApiName;
+ SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
+ rVal <<= aApiName;
+ }
+ else
+ {
+ com::sun::star::drawing::PolyPolygonBezierCoords aBezier;
+ SvxConvertB2DPolyPolygonToPolyPolygonBezier( maPolyPolygon, aBezier );
+ rVal <<= aBezier;
+ }
+
+ return true;
+}
+
+bool XLineStartItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ if( nMemberId == MID_NAME )
+ {
+ return false;
+ }
+ else
+ {
+ maPolyPolygon.clear();
+
+ if( rVal.hasValue() && rVal.getValue() )
+ {
+ if( rVal.getValueType() != ::getCppuType((const com::sun::star::drawing::PolyPolygonBezierCoords*)0) )
+ return false;
+
+ com::sun::star::drawing::PolyPolygonBezierCoords* pCoords = (com::sun::star::drawing::PolyPolygonBezierCoords*)rVal.getValue();
+ if( pCoords->Coordinates.getLength() > 0 )
+ {
+ maPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon( pCoords );
+ // #i72807# close line start/end polygons hard
+ // maPolyPolygon.setClosed(true);
+ }
+ }
+ }
+
+ return true;
+}
+
+/** this function searches in both the models pool and the styles pool for XLineStartItem
+ and XLineEndItem with the same value or name and returns an item with the value of
+ this item and a unique name for an item with this value. */
+XLineStartItem* XLineStartItem::checkForUniqueItem( SdrModel* pModel ) const
+{
+ if( pModel )
+ {
+ XLineStartItem* pTempItem = NULL;
+ const XLineStartItem* pLineStartItem = this;
+
+ String aUniqueName( GetName() );
+
+ if( !maPolyPolygon.count() )
+ {
+ // if the polygon is empty, check if the name is empty
+ if( aUniqueName.Len() == 0 )
+ return (XLineStartItem*)this;
+
+ // force empty name for empty polygons
+ return new XLineStartItem( String(), maPolyPolygon );
+ }
+
+ if( maPolyPolygon.count() > 1L )
+ {
+ // check if the polygon is closed
+ if(!maPolyPolygon.isClosed())
+ {
+ // force a closed polygon
+ basegfx::B2DPolyPolygon aNew(maPolyPolygon);
+ aNew.setClosed(true);
+ pTempItem = new XLineStartItem( aUniqueName, aNew );
+ pLineStartItem = pTempItem;
+ }
+ }
+
+ sal_Bool bForceNew = sal_False;
+
+ // 2. if we have a name check if there is already an item with the
+ // same name in the documents pool with a different line end or start
+
+ sal_uInt16 nCount, nSurrogate;
+
+ const SfxItemPool* pPool1 = &pModel->GetItemPool();
+ if( aUniqueName.Len() && pPool1 )
+ {
+ nCount = pPool1->GetItemCount( XATTR_LINESTART );
+
+ for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ const XLineStartItem* pItem = (const XLineStartItem*)pPool1->GetItem( XATTR_LINESTART, nSurrogate );
+
+ if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
+ {
+ // if there is already an item with the same name and the same
+ // value its ok to set it
+ if( pItem->GetLineStartValue() != pLineStartItem->GetLineStartValue() )
+ {
+ // same name but different value, we need a new name for this item
+ aUniqueName = String();
+ bForceNew = sal_True;
+ }
+ break;
+ }
+ }
+
+ if( !bForceNew )
+ {
+ nCount = pPool1->GetItemCount( XATTR_LINEEND );
+
+ for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ const XLineEndItem* pItem = (const XLineEndItem*)pPool1->GetItem( XATTR_LINEEND, nSurrogate );
+
+ if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
+ {
+ // if there is already an item with the same name and the same
+ // value its ok to set it
+ if( pItem->GetLineEndValue() != pLineStartItem->GetLineStartValue() )
+ {
+ // same name but different value, we need a new name for this item
+ aUniqueName = String();
+ bForceNew = sal_True;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL;
+ if( aUniqueName.Len() && pPool2)
+ {
+ nCount = pPool2->GetItemCount( XATTR_LINESTART );
+ for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ const XLineStartItem* pItem = (const XLineStartItem*)pPool2->GetItem( XATTR_LINESTART, nSurrogate );
+
+ if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
+ {
+ // if there is already an item with the same name and the same
+ // value its ok to set it
+ if( pItem->GetLineStartValue() != pLineStartItem->GetLineStartValue() )
+ {
+ // same name but different value, we need a new name for this item
+ aUniqueName = String();
+ bForceNew = sal_True;
+ }
+ break;
+ }
+ }
+
+ if( !bForceNew )
+ {
+ nCount = pPool2->GetItemCount( XATTR_LINEEND );
+ for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ const XLineEndItem* pItem = (const XLineEndItem*)pPool2->GetItem( XATTR_LINEEND, nSurrogate );
+
+ if( pItem && ( pItem->GetName() == pLineStartItem->GetName() ) )
+ {
+ // if there is already an item with the same name and the same
+ // value its ok to set it
+ if( pItem->GetLineEndValue() != pLineStartItem->GetLineStartValue() )
+ {
+ // same name but different value, we need a new name for this item
+ aUniqueName = String();
+ bForceNew = sal_True;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // if we have no name yet, find existing item with same conent or
+ // create a unique name
+ if( aUniqueName.Len() == 0 )
+ {
+ sal_Bool bFoundExisting = sal_False;
+
+ sal_Int32 nUserIndex = 1;
+ const ResId aRes(SVX_RES(RID_SVXSTR_LINEEND));
+ const String aUser( aRes );
+
+ if( pPool1 )
+ {
+ nCount = pPool1->GetItemCount( XATTR_LINESTART );
+ sal_uInt16 nSurrogate2;
+
+ for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ )
+ {
+ const XLineStartItem* pItem = (const XLineStartItem*)pPool1->GetItem( XATTR_LINESTART, nSurrogate2 );
+
+ if( pItem && pItem->GetName().Len() )
+ {
+ if( !bForceNew && pItem->GetLineStartValue() == pLineStartItem->GetLineStartValue() )
+ {
+ aUniqueName = pItem->GetName();
+ bFoundExisting = sal_True;
+ break;
+ }
+
+ if( pItem->GetName().CompareTo( aUser, aUser.Len() ) == 0 )
+ {
+ sal_Int32 nThisIndex = pItem->GetName().Copy( aUser.Len() ).ToInt32();
+ if( nThisIndex >= nUserIndex )
+ nUserIndex = nThisIndex + 1;
+ }
+ }
+ }
+
+ nCount = pPool1->GetItemCount( XATTR_LINEEND );
+ for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ )
+ {
+ const XLineEndItem* pItem = (const XLineEndItem*)pPool1->GetItem( XATTR_LINEEND, nSurrogate2 );
+
+ if( pItem && pItem->GetName().Len() )
+ {
+ if( !bForceNew && pItem->GetLineEndValue() == pLineStartItem->GetLineStartValue() )
+ {
+ aUniqueName = pItem->GetName();
+ bFoundExisting = sal_True;
+ break;
+ }
+
+ if( pItem->GetName().CompareTo( aUser, aUser.Len() ) == 0 )
+ {
+ sal_Int32 nThisIndex = pItem->GetName().Copy( aUser.Len() ).ToInt32();
+ if( nThisIndex >= nUserIndex )
+ nUserIndex = nThisIndex + 1;
+ }
+ }
+ }
+ }
+
+ if( !bFoundExisting )
+ {
+ aUniqueName = aUser;
+ aUniqueName += sal_Unicode(' ');
+ aUniqueName += String::CreateFromInt32( nUserIndex );
+ }
+ }
+
+ // if the given name is not valid, replace it!
+ if( aUniqueName != GetName() || pTempItem )
+ {
+ if( pTempItem )
+ {
+ pTempItem->SetName( aUniqueName );
+ return pTempItem;
+ }
+ else
+ {
+ return new XLineStartItem( aUniqueName, maPolyPolygon );
+ }
+ }
+ }
+
+ return (XLineStartItem*)this;
+}
+
+// ---------------------
+// class XLineEndItem
+// ---------------------
+TYPEINIT1_AUTOFACTORY(XLineEndItem, NameOrIndex);
+
+/*************************************************************************
+|*
+|* XLineEndItem::XLineEndItem(INT32 nIndex)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+XLineEndItem::XLineEndItem(INT32 nIndex)
+: NameOrIndex(XATTR_LINEEND, nIndex)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineEndItem::XLineEndItem(const XubString& rName,
+|* const basegfx::B2DPolyPolygon& rXPolygon)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+XLineEndItem::XLineEndItem(const XubString& rName, const basegfx::B2DPolyPolygon& rPolyPolygon)
+: NameOrIndex(XATTR_LINEEND, rName),
+ maPolyPolygon(rPolyPolygon)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineEndItem::XLineEndItem(const XLineEndItem& rItem)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+XLineEndItem::XLineEndItem(const XLineEndItem& rItem)
+: NameOrIndex(rItem),
+ maPolyPolygon(rItem.maPolyPolygon)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineEndItem::XLineEndItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 17.11.94
+|*
+*************************************************************************/
+
+XLineEndItem::XLineEndItem(SvStream& rIn) :
+ NameOrIndex(XATTR_LINEEND, rIn)
+{
+ if (!IsIndex())
+ {
+ maPolyPolygon = streamInB2DPolyPolygon(rIn);
+ }
+}
+
+//*************************************************************************
+
+XLineEndItem::XLineEndItem(SfxItemPool* /*pPool*/, const basegfx::B2DPolyPolygon& rPolyPolygon)
+: NameOrIndex( XATTR_LINEEND, -1 ),
+ maPolyPolygon(rPolyPolygon)
+{
+}
+
+//*************************************************************************
+
+XLineEndItem::XLineEndItem(SfxItemPool* /*pPool*/)
+: NameOrIndex(XATTR_LINEEND, -1 )
+{
+}
+
+/*************************************************************************
+|*
+|* XLineEndItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineEndItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineEndItem(*this);
+}
+
+/*************************************************************************
+|*
+|* int XLineEndItem::operator==(const SfxPoolItem& rItem) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 17.11.94
+|*
+*************************************************************************/
+
+int XLineEndItem::operator==(const SfxPoolItem& rItem) const
+{
+ return ( NameOrIndex::operator==(rItem) && ((const XLineEndItem&) rItem).maPolyPolygon == maPolyPolygon );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineEndItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineEndItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineEndItem(rIn);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineEndItem::Store(SvStream& rOut) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 17.11.94
+|*
+*************************************************************************/
+
+SvStream& XLineEndItem::Store( SvStream& rOut, USHORT nItemVersion ) const
+{
+ NameOrIndex::Store( rOut, nItemVersion );
+
+ if (!IsIndex())
+ {
+ streamOutB2DPolyPolygon(maPolyPolygon, rOut);
+ }
+
+ return rOut;
+}
+
+/*************************************************************************
+|*
+|* const basegfx::B2DPolyPolygon& XLineEndItem::GetValue(const XLineEndTable* pTable) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+basegfx::B2DPolyPolygon XLineEndItem::GetLineEndValue(const XLineEndTable* pTable) const
+{
+ if (!IsIndex())
+ {
+ return maPolyPolygon;
+ }
+ else
+ {
+ return pTable->GetLineEnd(GetIndex())->GetLineEnd();
+ }
+}
+
+
+/** this function searches in both the models pool and the styles pool for XLineStartItem
+ and XLineEndItem with the same value or name and returns an item with the value of
+ this item and a unique name for an item with this value. */
+XLineEndItem* XLineEndItem::checkForUniqueItem( SdrModel* pModel ) const
+{
+ if( pModel )
+ {
+ XLineEndItem* pTempItem = NULL;
+ const XLineEndItem* pLineEndItem = this;
+
+ String aUniqueName( GetName() );
+
+ if( !maPolyPolygon.count() )
+ {
+ // if the polygon is empty, check if the name is empty
+ if( aUniqueName.Len() == 0 )
+ return (XLineEndItem*)this;
+
+ // force empty name for empty polygons
+ return new XLineEndItem( String(), maPolyPolygon );
+ }
+
+ if( maPolyPolygon.count() > 1L )
+ {
+ // check if the polygon is closed
+ if(!maPolyPolygon.isClosed())
+ {
+ // force a closed polygon
+ basegfx::B2DPolyPolygon aNew(maPolyPolygon);
+ aNew.setClosed(true);
+ pTempItem = new XLineEndItem( aUniqueName, aNew );
+ pLineEndItem = pTempItem;
+ }
+ }
+
+ sal_Bool bForceNew = sal_False;
+
+ // 2. if we have a name check if there is already an item with the
+ // same name in the documents pool with a different line end or start
+
+ sal_uInt16 nCount, nSurrogate;
+
+ const SfxItemPool* pPool1 = &pModel->GetItemPool();
+ if( aUniqueName.Len() && pPool1 )
+ {
+ nCount = pPool1->GetItemCount( XATTR_LINESTART );
+
+ for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ const XLineStartItem* pItem = (const XLineStartItem*)pPool1->GetItem( XATTR_LINESTART, nSurrogate );
+
+ if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
+ {
+ // if there is already an item with the same name and the same
+ // value its ok to set it
+ if( pItem->GetLineStartValue() != pLineEndItem->GetLineEndValue() )
+ {
+ // same name but different value, we need a new name for this item
+ aUniqueName = String();
+ bForceNew = sal_True;
+ }
+ break;
+ }
+ }
+
+ if( !bForceNew )
+ {
+ nCount = pPool1->GetItemCount( XATTR_LINEEND );
+
+ for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ const XLineEndItem* pItem = (const XLineEndItem*)pPool1->GetItem( XATTR_LINEEND, nSurrogate );
+
+ if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
+ {
+ // if there is already an item with the same name and the same
+ // value its ok to set it
+ if( pItem->GetLineEndValue() != pLineEndItem->GetLineEndValue() )
+ {
+ // same name but different value, we need a new name for this item
+ aUniqueName = String();
+ bForceNew = sal_True;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ const SfxItemPool* pPool2 = pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL;
+ if( aUniqueName.Len() && pPool2)
+ {
+ nCount = pPool2->GetItemCount( XATTR_LINESTART );
+ for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ const XLineStartItem* pItem = (const XLineStartItem*)pPool2->GetItem( XATTR_LINESTART, nSurrogate );
+
+ if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
+ {
+ // if there is already an item with the same name and the same
+ // value its ok to set it
+ if( pItem->GetLineStartValue() != pLineEndItem->GetLineEndValue() )
+ {
+ // same name but different value, we need a new name for this item
+ aUniqueName = String();
+ bForceNew = sal_True;
+ }
+ break;
+ }
+ }
+
+ if( !bForceNew )
+ {
+ nCount = pPool2->GetItemCount( XATTR_LINEEND );
+ for( nSurrogate = 0; nSurrogate < nCount; nSurrogate++ )
+ {
+ const XLineEndItem* pItem = (const XLineEndItem*)pPool2->GetItem( XATTR_LINEEND, nSurrogate );
+
+ if( pItem && ( pItem->GetName() == pLineEndItem->GetName() ) )
+ {
+ // if there is already an item with the same name and the same
+ // value its ok to set it
+ if( pItem->GetLineEndValue() != pLineEndItem->GetLineEndValue() )
+ {
+ // same name but different value, we need a new name for this item
+ aUniqueName = String();
+ bForceNew = sal_True;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // if we have no name yet, find existing item with same conent or
+ // create a unique name
+ if( aUniqueName.Len() == 0 )
+ {
+ sal_Bool bFoundExisting = sal_False;
+
+ sal_Int32 nUserIndex = 1;
+ const ResId aRes(SVX_RES(RID_SVXSTR_LINEEND));
+ const String aUser( aRes );
+
+ if( pPool1 )
+ {
+ nCount = pPool1->GetItemCount( XATTR_LINESTART );
+ sal_uInt16 nSurrogate2;
+
+ for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ )
+ {
+ const XLineStartItem* pItem = (const XLineStartItem*)pPool1->GetItem( XATTR_LINESTART, nSurrogate2 );
+
+ if( pItem && pItem->GetName().Len() )
+ {
+ if( !bForceNew && pItem->GetLineStartValue() == pLineEndItem->GetLineEndValue() )
+ {
+ aUniqueName = pItem->GetName();
+ bFoundExisting = sal_True;
+ break;
+ }
+
+ if( pItem->GetName().CompareTo( aUser, aUser.Len() ) == 0 )
+ {
+ sal_Int32 nThisIndex = pItem->GetName().Copy( aUser.Len() ).ToInt32();
+ if( nThisIndex >= nUserIndex )
+ nUserIndex = nThisIndex + 1;
+ }
+ }
+ }
+
+ nCount = pPool1->GetItemCount( XATTR_LINEEND );
+ for( nSurrogate2 = 0; nSurrogate2 < nCount; nSurrogate2++ )
+ {
+ const XLineEndItem* pItem = (const XLineEndItem*)pPool1->GetItem( XATTR_LINEEND, nSurrogate2 );
+
+ if( pItem && pItem->GetName().Len() )
+ {
+ if( !bForceNew && pItem->GetLineEndValue() == pLineEndItem->GetLineEndValue() )
+ {
+ aUniqueName = pItem->GetName();
+ bFoundExisting = sal_True;
+ break;
+ }
+
+ if( pItem->GetName().CompareTo( aUser, aUser.Len() ) == 0 )
+ {
+ sal_Int32 nThisIndex = pItem->GetName().Copy( aUser.Len() ).ToInt32();
+ if( nThisIndex >= nUserIndex )
+ nUserIndex = nThisIndex + 1;
+ }
+ }
+ }
+ }
+
+ if( !bFoundExisting )
+ {
+ aUniqueName = aUser;
+ aUniqueName += sal_Unicode(' ');
+ aUniqueName += String::CreateFromInt32( nUserIndex );
+ }
+ }
+
+ // if the given name is not valid, replace it!
+ if( aUniqueName != GetName() || pTempItem )
+ {
+ if( pTempItem )
+ {
+ pTempItem->SetName( aUniqueName );
+ return pTempItem;
+ }
+ else
+ {
+ return new XLineEndItem( aUniqueName, maPolyPolygon );
+ }
+ }
+ }
+
+ return (XLineEndItem*)this;
+}
+
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineEndItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetName();
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+bool XLineEndItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ if( nMemberId == MID_NAME )
+ {
+ rtl::OUString aApiName;
+ SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
+ rVal <<= aApiName;
+ }
+ else
+ {
+ com::sun::star::drawing::PolyPolygonBezierCoords aBezier;
+ SvxConvertB2DPolyPolygonToPolyPolygonBezier( maPolyPolygon, aBezier );
+ rVal <<= aBezier;
+ }
+ return true;
+}
+
+bool XLineEndItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ if( nMemberId == MID_NAME )
+ {
+ return false;
+ }
+ else
+ {
+ maPolyPolygon.clear();
+
+ if( rVal.hasValue() && rVal.getValue() )
+ {
+ if( rVal.getValueType() != ::getCppuType((const com::sun::star::drawing::PolyPolygonBezierCoords*)0) )
+ return false;
+
+ com::sun::star::drawing::PolyPolygonBezierCoords* pCoords = (com::sun::star::drawing::PolyPolygonBezierCoords*)rVal.getValue();
+ if( pCoords->Coordinates.getLength() > 0 )
+ {
+ maPolyPolygon = SvxConvertPolyPolygonBezierToB2DPolyPolygon( pCoords );
+ // #i72807# close line start/end polygons hard
+ // maPolyPolygon.setClosed(true);
+ }
+ }
+ }
+
+ return true;
+}
+
+// ----------------------------
+// class XLineStartWidthItem
+// ----------------------------
+TYPEINIT1_AUTOFACTORY(XLineStartWidthItem, SfxMetricItem);
+
+/*************************************************************************
+|*
+|* XLineStartWidthItem::XLineStartWidthItem(INT32 nWidth)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+XLineStartWidthItem::XLineStartWidthItem(long nWidth) :
+ SfxMetricItem(XATTR_LINESTARTWIDTH, nWidth)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineStartWidthItem::XLineStartWidthItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineStartWidthItem::XLineStartWidthItem(SvStream& rIn) :
+ SfxMetricItem(XATTR_LINESTARTWIDTH, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineStartWidthItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineStartWidthItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineStartWidthItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineStartWidthItem::Create(SvStream& rIn, USHORT nVer)
+|* const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineStartWidthItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineStartWidthItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineStartWidthItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit ePresUnit,
+ XubString& rText, const IntlWrapper * pIntl
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetMetricText( (long) GetValue(),
+ eCoreUnit, ePresUnit, pIntl);
+ rText += SVX_RESSTR( GetMetricId( ePresUnit) );
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+bool XLineStartWidthItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+bool XLineStartWidthItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ rVal >>= nValue;
+ SetValue( nValue );
+ return true;
+}
+
+
+
+// --------------------------
+// class XLineEndWidthItem
+// --------------------------
+TYPEINIT1_AUTOFACTORY(XLineEndWidthItem, SfxMetricItem);
+
+/*************************************************************************
+|*
+|* XLineEndWidthItem::XLineEndWidthItem(long nWidth)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineEndWidthItem::XLineEndWidthItem(long nWidth) :
+ SfxMetricItem(XATTR_LINEENDWIDTH, nWidth)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineEndWidthItem::XLineEndWidthItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineEndWidthItem::XLineEndWidthItem(SvStream& rIn) :
+ SfxMetricItem(XATTR_LINEENDWIDTH, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineEndWidthItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineEndWidthItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineEndWidthItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineEndWidthItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineEndWidthItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineEndWidthItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineEndWidthItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit,
+ SfxMapUnit ePresUnit,
+ XubString& rText, const IntlWrapper *pIntl
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetMetricText( (long) GetValue(),
+ eCoreUnit, ePresUnit, pIntl);
+ rText += SVX_RESSTR( GetMetricId( ePresUnit) );
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+bool XLineEndWidthItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+bool XLineEndWidthItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ rVal >>= nValue;
+ SetValue( nValue );
+ return true;
+}
+
+
+// -----------------------------
+// class XLineStartCenterItem
+// -----------------------------
+TYPEINIT1_AUTOFACTORY(XLineStartCenterItem, SfxBoolItem);
+
+/*************************************************************************
+|*
+|* XLineStartCenterItem::XLineStartCenterItem(BOOL bStartCenter)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineStartCenterItem::XLineStartCenterItem(BOOL bStartCenter) :
+ SfxBoolItem(XATTR_LINESTARTCENTER, bStartCenter)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineStartCenterItem::XLineStartCenterItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineStartCenterItem::XLineStartCenterItem(SvStream& rIn) :
+ SfxBoolItem(XATTR_LINESTARTCENTER, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineStartCenterItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineStartCenterItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineStartCenterItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineStartCenterItem::Create(SvStream& rIn, USHORT nVer)
+|* const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineStartCenterItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineStartCenterItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineStartCenterItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = XubString( ResId( GetValue() ? RID_SVXSTR_CENTERED :
+ RID_SVXSTR_NOTCENTERED, DIALOG_MGR() ) );
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+bool XLineStartCenterItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ sal_Bool bValue = GetValue();
+ rVal.setValue( &bValue, ::getCppuBooleanType() );
+ return true;
+}
+
+bool XLineStartCenterItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ if( !rVal.hasValue() || rVal.getValueType() != ::getCppuBooleanType() )
+ return false;
+
+ SetValue( *(sal_Bool*)rVal.getValue() );
+ return true;
+}
+
+
+// ---------------------------
+// class XLineEndCenterItem
+// ---------------------------
+TYPEINIT1_AUTOFACTORY(XLineEndCenterItem, SfxBoolItem);
+
+/*************************************************************************
+|*
+|* XLineEndCenterItem::XLineEndCenterItem(BOOL bEndCenter)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineEndCenterItem::XLineEndCenterItem(BOOL bEndCenter) :
+ SfxBoolItem(XATTR_LINEENDCENTER, bEndCenter)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineEndCenterItem::XLineEndCenterItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XLineEndCenterItem::XLineEndCenterItem(SvStream& rIn) :
+ SfxBoolItem(XATTR_LINEENDCENTER, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineEndCenterItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineEndCenterItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineEndCenterItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineEndCenterItem::Create(SvStream& rIn, USHORT nVer)
+|* const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineEndCenterItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineEndCenterItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineEndCenterItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = XubString( ResId( GetValue() ? RID_SVXSTR_CENTERED :
+ RID_SVXSTR_NOTCENTERED, DIALOG_MGR() ) );
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+bool XLineEndCenterItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ sal_Bool bValue = GetValue();
+ rVal.setValue( &bValue, ::getCppuBooleanType() );
+ return true;
+}
+
+bool XLineEndCenterItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ if( !rVal.hasValue() || rVal.getValueType() != ::getCppuBooleanType() )
+ return false;
+
+ SetValue( *(sal_Bool*)rVal.getValue() );
+ return true;
+}
+
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Fuellattribute
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+// --------------------
+// class XFillStyleItem
+// --------------------
+TYPEINIT1_AUTOFACTORY(XFillStyleItem, SfxEnumItem);
+
+/*************************************************************************
+|*
+|* XFillStyleItem::XFillStyleItem(XFillStyle eFillStyle)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillStyleItem::XFillStyleItem(XFillStyle eFillStyle) :
+ SfxEnumItem(XATTR_FILLSTYLE, sal::static_int_cast< USHORT >(eFillStyle))
+{
+}
+
+/*************************************************************************
+|*
+|* XFillStyleItem::XFillStyleItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillStyleItem::XFillStyleItem(SvStream& rIn) :
+ SfxEnumItem(XATTR_FILLSTYLE, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillStyleItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 09.11.94
+|* Letzte Aenderung 09.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillStyleItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFillStyleItem( *this );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFillStyleItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillStyleItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillStyleItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XFillStyleItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ {
+ USHORT nId = 0;
+
+ switch( (USHORT)GetValue() )
+ {
+ case XFILL_NONE:
+ nId = RID_SVXSTR_INVISIBLE;
+ break;
+ case XFILL_SOLID:
+ nId = RID_SVXSTR_SOLID;
+ break;
+ case XFILL_GRADIENT:
+ nId = RID_SVXSTR_GRADIENT;
+ break;
+ case XFILL_HATCH:
+ nId = RID_SVXSTR_HATCH;
+ break;
+ case XFILL_BITMAP:
+ nId = RID_SVXSTR_BITMAP;
+ break;
+ }
+
+ if ( nId )
+ rText = SVX_RESSTR( nId );
+ return ePres;
+ }
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT XFillStyleItem::GetValueCount() const
+{
+ return 5;
+}
+
+// -----------------------------------------------------------------------
+bool XFillStyleItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ ::com::sun::star::drawing::FillStyle eFS = (::com::sun::star::drawing::FillStyle)GetValue();
+
+ rVal <<= eFS;
+
+ return true;
+}
+
+// -----------------------------------------------------------------------
+bool XFillStyleItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ ::com::sun::star::drawing::FillStyle eFS;
+ if(!(rVal >>= eFS))
+ {
+ // also try an int (for Basic)
+ sal_Int32 nFS = 0;
+ if(!(rVal >>= nFS))
+ return false;
+ eFS = (::com::sun::star::drawing::FillStyle)nFS;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( eFS ) );
+
+ return true;
+}
+
+
+// -------------------
+// class XFillColorItem
+// -------------------
+TYPEINIT1_AUTOFACTORY(XFillColorItem, XColorItem);
+
+/*************************************************************************
+|*
+|* XFillColorItem::XFillColorItem(INT32 nIndex, const Color& rTheColor)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillColorItem::XFillColorItem(INT32 nIndex, const Color& rTheColor) :
+ XColorItem(XATTR_FILLCOLOR, nIndex, rTheColor)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillColorItem::XFillColorItem(const XubString& rName, const Color& rTheColor)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillColorItem::XFillColorItem(const XubString& rName, const Color& rTheColor) :
+ XColorItem(XATTR_FILLCOLOR, rName, rTheColor)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillColorItem::XFillColorItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillColorItem::XFillColorItem(SvStream& rIn) :
+ XColorItem(XATTR_FILLCOLOR, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillColorItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillColorItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFillColorItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFillColorItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillColorItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillColorItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XFillColorItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetName();
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+bool XFillColorItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetColorValue().GetRGBColor();
+
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
+bool XFillColorItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ if(!(rVal >>= nValue ))
+ return false;
+
+ SetColorValue( nValue );
+ return true;
+}
+
+// -----------------------------
+// class XSecondaryFillColorItem
+// -----------------------------
+TYPEINIT1_AUTOFACTORY(XSecondaryFillColorItem, XColorItem);
+
+XSecondaryFillColorItem::XSecondaryFillColorItem(INT32 nIndex, const Color& rTheColor) :
+ XColorItem(XATTR_SECONDARYFILLCOLOR, nIndex, rTheColor)
+{
+}
+
+XSecondaryFillColorItem::XSecondaryFillColorItem(const XubString& rName, const Color& rTheColor) :
+ XColorItem(XATTR_SECONDARYFILLCOLOR, rName, rTheColor)
+{
+}
+
+XSecondaryFillColorItem::XSecondaryFillColorItem( SvStream& rIn ) :
+ XColorItem(XATTR_SECONDARYFILLCOLOR, rIn)
+{
+}
+
+SfxPoolItem* XSecondaryFillColorItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XSecondaryFillColorItem(*this);
+}
+
+SfxPoolItem* XSecondaryFillColorItem::Create( SvStream& rIn, USHORT nVer ) const
+{
+ if ( nVer >= 2 )
+ return new XSecondaryFillColorItem( rIn );
+ else
+ return new XSecondaryFillColorItem( String(), Color(0,184,255) );
+}
+USHORT XSecondaryFillColorItem::GetVersion( USHORT /*nFileFormatVersion*/ ) const
+{
+ return 2;
+}
+SfxItemPresentation XSecondaryFillColorItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetName();
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+// ----------------
+// class XGradient
+// ----------------
+
+/*************************************************************************
+|*
+|* XGradient::XGradient()
+|*
+*************************************************************************/
+
+XGradient::XGradient() :
+ eStyle( XGRAD_LINEAR ),
+ aStartColor( Color( COL_BLACK ) ),
+ aEndColor( Color( COL_WHITE ) ),
+ nAngle( 0 ),
+ nBorder( 0 ),
+ nOfsX( 50 ),
+ nOfsY( 50 ),
+ nIntensStart( 100 ),
+ nIntensEnd( 100 ),
+ nStepCount( 0 )
+{
+}
+
+/*************************************************************************
+|*
+|* XGradient::XGradient(XGradientStyle, const Color&, const Color&,
+|* long, USHORT, USHORT, USHORT)
+|*
+|* Beschreibung
+|* Ersterstellung 21.11.94
+|* Letzte Aenderung 21.11.94
+|*
+*************************************************************************/
+
+XGradient::XGradient(const Color& rStart, const Color& rEnd,
+ XGradientStyle eTheStyle, long nTheAngle, USHORT nXOfs,
+ USHORT nYOfs, USHORT nTheBorder,
+ USHORT nStartIntens, USHORT nEndIntens,
+ USHORT nSteps) :
+ eStyle(eTheStyle),
+ aStartColor(rStart),
+ aEndColor(rEnd),
+ nAngle(nTheAngle),
+ nBorder(nTheBorder),
+ nOfsX(nXOfs),
+ nOfsY(nYOfs),
+ nIntensStart(nStartIntens),
+ nIntensEnd(nEndIntens),
+ nStepCount(nSteps)
+{
+}
+
+/*************************************************************************
+|*
+|* int XGradient::operator==(const SfxPoolItem& rItem) const
+|*
+|* Beschreibung
+|* Ersterstellung 29.11.94
+|* Letzte Aenderung 29.11.94
+|*
+*************************************************************************/
+
+bool XGradient::operator==(const XGradient& rGradient) const
+{
+ return ( eStyle == rGradient.eStyle &&
+ aStartColor == rGradient.aStartColor &&
+ aEndColor == rGradient.aEndColor &&
+ nAngle == rGradient.nAngle &&
+ nBorder == rGradient.nBorder &&
+ nOfsX == rGradient.nOfsX &&
+ nOfsY == rGradient.nOfsY &&
+ nIntensStart == rGradient.nIntensStart &&
+ nIntensEnd == rGradient.nIntensEnd &&
+ nStepCount == rGradient.nStepCount );
+}
+
+
+// -----------------------
+// class XFillGradientItem
+// -----------------------
+TYPEINIT1_AUTOFACTORY(XFillGradientItem, NameOrIndex);
+
+/*************************************************************************
+|*
+|* XFillGradientItem::XFillGradientItem(INT32 nIndex,
+|* const XGradient& rTheGradient)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillGradientItem::XFillGradientItem(INT32 nIndex,
+ const XGradient& rTheGradient) :
+ NameOrIndex(XATTR_FILLGRADIENT, nIndex),
+ aGradient(rTheGradient)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillGradientItem::XFillGradientItem(const XubString& rName,
+|* const XGradient& rTheGradient)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillGradientItem::XFillGradientItem(const XubString& rName,
+ const XGradient& rTheGradient) :
+ NameOrIndex(XATTR_FILLGRADIENT, rName),
+ aGradient(rTheGradient)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillGradientItem::XFillGradientItem(const XFillGradientItem& rItem)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillGradientItem::XFillGradientItem(const XFillGradientItem& rItem) :
+ NameOrIndex(rItem),
+ aGradient(rItem.aGradient)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillGradientItem::XFillGradientItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillGradientItem::XFillGradientItem(SvStream& rIn, USHORT nVer) :
+ NameOrIndex(XATTR_FILLGRADIENT, rIn),
+ aGradient(COL_BLACK, COL_WHITE)
+{
+ if (!IsIndex())
+ {
+ USHORT nUSTemp;
+ USHORT nRed;
+ USHORT nGreen;
+ USHORT nBlue;
+ INT16 nITemp;
+ INT32 nLTemp;
+
+ rIn >> nITemp; aGradient.SetGradientStyle((XGradientStyle)nITemp);
+ rIn >> nRed;
+ rIn >> nGreen;
+ rIn >> nBlue;
+ Color aCol;
+ aCol = Color( (BYTE)( nRed >> 8 ), (BYTE)( nGreen >> 8 ), (BYTE)( nBlue >> 8 ) );
+ aGradient.SetStartColor( aCol );
+
+ rIn >> nRed;
+ rIn >> nGreen;
+ rIn >> nBlue;
+ aCol = Color( (BYTE)( nRed >> 8 ), (BYTE)( nGreen >> 8 ), (BYTE)( nBlue >> 8 ) );
+ aGradient.SetEndColor(aCol);
+ rIn >> nLTemp; aGradient.SetAngle(nLTemp);
+ rIn >> nUSTemp; aGradient.SetBorder(nUSTemp);
+ rIn >> nUSTemp; aGradient.SetXOffset(nUSTemp);
+ rIn >> nUSTemp; aGradient.SetYOffset(nUSTemp);
+ rIn >> nUSTemp; aGradient.SetStartIntens(nUSTemp);
+ rIn >> nUSTemp; aGradient.SetEndIntens(nUSTemp);
+
+ // bei neueren Versionen wird zusaetzlich
+ // die Schrittweite mit eingelesen
+ if (nVer >= 1)
+ {
+ rIn >> nUSTemp; aGradient.SetSteps(nUSTemp);
+ }
+ }
+}
+
+//*************************************************************************
+
+XFillGradientItem::XFillGradientItem(SfxItemPool* /*pPool*/, const XGradient& rTheGradient)
+: NameOrIndex( XATTR_FILLGRADIENT, -1 ),
+ aGradient(rTheGradient)
+{
+}
+
+//*************************************************************************
+
+XFillGradientItem::XFillGradientItem(SfxItemPool* /*pPool*/)
+: NameOrIndex(XATTR_FILLGRADIENT, -1 )
+{
+}
+
+/*************************************************************************
+|*
+|* XFillGradientItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillGradientItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFillGradientItem(*this);
+}
+
+/*************************************************************************
+|*
+|* int XFillGradientItem::operator==(const SfxPoolItem& rItem) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+int XFillGradientItem::operator==(const SfxPoolItem& rItem) const
+{
+ return ( NameOrIndex::operator==(rItem) &&
+ aGradient == ((const XFillGradientItem&) rItem).aGradient );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFillGradientItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillGradientItem::Create(SvStream& rIn, USHORT nVer) const
+{
+ return new XFillGradientItem(rIn, nVer);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFillGradientItem::Store(SvStream& rOut) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SvStream& XFillGradientItem::Store( SvStream& rOut, USHORT nItemVersion ) const
+{
+ NameOrIndex::Store( rOut, nItemVersion );
+
+ if (!IsIndex())
+ {
+ rOut << (INT16)aGradient.GetGradientStyle();
+
+ USHORT nTmp;
+
+ nTmp = VCLTOSVCOL( aGradient.GetStartColor().GetRed() ); rOut << nTmp;
+ nTmp = VCLTOSVCOL( aGradient.GetStartColor().GetGreen() ); rOut << nTmp;
+ nTmp = VCLTOSVCOL( aGradient.GetStartColor().GetBlue() ); rOut << nTmp;
+ nTmp = VCLTOSVCOL( aGradient.GetEndColor().GetRed() ); rOut << nTmp;
+ nTmp = VCLTOSVCOL( aGradient.GetEndColor().GetGreen() ); rOut << nTmp;
+ nTmp = VCLTOSVCOL( aGradient.GetEndColor().GetBlue() ); rOut << nTmp;
+
+ rOut << (INT32) aGradient.GetAngle();
+ rOut << aGradient.GetBorder();
+ rOut << aGradient.GetXOffset();
+ rOut << aGradient.GetYOffset();
+ rOut << aGradient.GetStartIntens();
+ rOut << aGradient.GetEndIntens();
+ rOut << aGradient.GetSteps();
+ }
+
+ return rOut;
+}
+
+/*************************************************************************
+|*
+|* const XGradient& XFillGradientItem::GetValue(const XGradientTable* pTable)
+|* const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+const XGradient& XFillGradientItem::GetGradientValue(const XGradientTable* pTable) const // GetValue -> GetGradientValue
+{
+ if (!IsIndex())
+ return aGradient;
+ else
+ return pTable->GetGradient(GetIndex())->GetGradient();
+}
+
+
+/*************************************************************************
+|*
+|* USHORT XFillGradientItem::GetVersion() const
+|*
+|* Beschreibung
+|* Ersterstellung 01.11.95
+|* Letzte Aenderung 01.11.95
+|*
+*************************************************************************/
+
+USHORT XFillGradientItem::GetVersion( USHORT /*nFileFormatVersion*/) const
+{
+ // !!! this version number also represents the version number of superclasses
+ // !!! (e.g. XFillFloatTransparenceItem); if you make any changes here,
+ // !!! the superclass is also affected
+ return 1;
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XFillGradientItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetName();
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+// -----------------------------------------------------------------------
+bool XFillGradientItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+ //sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+ switch ( nMemberId )
+ {
+ case 0:
+ {
+ uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
+
+ ::com::sun::star::awt::Gradient aGradient2;
+
+ const XGradient& aXGradient = GetGradientValue();
+ aGradient2.Style = (::com::sun::star::awt::GradientStyle) aXGradient.GetGradientStyle();
+ aGradient2.StartColor = (INT32)aXGradient.GetStartColor().GetColor();
+ aGradient2.EndColor = (INT32)aXGradient.GetEndColor().GetColor();
+ aGradient2.Angle = (short)aXGradient.GetAngle();
+ aGradient2.Border = aXGradient.GetBorder();
+ aGradient2.XOffset = aXGradient.GetXOffset();
+ aGradient2.YOffset = aXGradient.GetYOffset();
+ aGradient2.StartIntensity = aXGradient.GetStartIntens();
+ aGradient2.EndIntensity = aXGradient.GetEndIntens();
+ aGradient2.StepCount = aXGradient.GetSteps();
+
+ rtl::OUString aApiName;
+ SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
+ aPropSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ));
+ aPropSeq[0].Value = uno::makeAny( aApiName );
+ aPropSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillGradient" ));
+ aPropSeq[1].Value = uno::makeAny( aGradient2 );
+ rVal = uno::makeAny( aPropSeq );
+ break;
+ }
+
+ case MID_FILLGRADIENT:
+ {
+ const XGradient& aXGradient = GetGradientValue();
+ ::com::sun::star::awt::Gradient aGradient2;
+
+ aGradient2.Style = (::com::sun::star::awt::GradientStyle) aXGradient.GetGradientStyle();
+ aGradient2.StartColor = (INT32)aXGradient.GetStartColor().GetColor();
+ aGradient2.EndColor = (INT32)aXGradient.GetEndColor().GetColor();
+ aGradient2.Angle = (short)aXGradient.GetAngle();
+ aGradient2.Border = aXGradient.GetBorder();
+ aGradient2.XOffset = aXGradient.GetXOffset();
+ aGradient2.YOffset = aXGradient.GetYOffset();
+ aGradient2.StartIntensity = aXGradient.GetStartIntens();
+ aGradient2.EndIntensity = aXGradient.GetEndIntens();
+ aGradient2.StepCount = aXGradient.GetSteps();
+
+ rVal <<= aGradient2;
+ break;
+ }
+
+ case MID_NAME:
+ {
+ rtl::OUString aApiName;
+ SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
+ rVal <<= aApiName;
+ break;
+ }
+
+ case MID_GRADIENT_STYLE: rVal <<= (sal_Int16)GetGradientValue().GetGradientStyle(); break;
+ case MID_GRADIENT_STARTCOLOR: rVal <<= (sal_Int32)GetGradientValue().GetStartColor().GetColor(); break;
+ case MID_GRADIENT_ENDCOLOR: rVal <<= (sal_Int32)GetGradientValue().GetEndColor().GetColor(); break;
+ case MID_GRADIENT_ANGLE: rVal <<= (sal_Int16)GetGradientValue().GetAngle(); break;
+ case MID_GRADIENT_BORDER: rVal <<= GetGradientValue().GetBorder(); break;
+ case MID_GRADIENT_XOFFSET: rVal <<= GetGradientValue().GetXOffset(); break;
+ case MID_GRADIENT_YOFFSET: rVal <<= GetGradientValue().GetYOffset(); break;
+ case MID_GRADIENT_STARTINTENSITY: rVal <<= GetGradientValue().GetStartIntens(); break;
+ case MID_GRADIENT_ENDINTENSITY: rVal <<= GetGradientValue().GetEndIntens(); break;
+ case MID_GRADIENT_STEPCOUNT: rVal <<= GetGradientValue().GetSteps(); break;
+
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ return true;
+}
+
+// -----------------------------------------------------------------------
+bool XFillGradientItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ switch ( nMemberId )
+ {
+ case 0:
+ {
+ uno::Sequence< beans::PropertyValue > aPropSeq;
+ ::com::sun::star::awt::Gradient aGradient2;
+ rtl::OUString aName;
+ bool bGradient( false );
+
+ if ( rVal >>= aPropSeq )
+ {
+ for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ )
+ {
+ if ( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" )))
+ aPropSeq[n].Value >>= aName;
+ else if ( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FillGradient" )))
+ {
+ if ( aPropSeq[n].Value >>= aGradient2 )
+ bGradient = true;
+ }
+ }
+
+ SetName( aName );
+ if ( bGradient )
+ {
+ XGradient aXGradient;
+
+ aXGradient.SetGradientStyle( (XGradientStyle) aGradient2.Style );
+ aXGradient.SetStartColor( aGradient2.StartColor );
+ aXGradient.SetEndColor( aGradient2.EndColor );
+ aXGradient.SetAngle( aGradient2.Angle );
+ aXGradient.SetBorder( aGradient2.Border );
+ aXGradient.SetXOffset( aGradient2.XOffset );
+ aXGradient.SetYOffset( aGradient2.YOffset );
+ aXGradient.SetStartIntens( aGradient2.StartIntensity );
+ aXGradient.SetEndIntens( aGradient2.EndIntensity );
+ aXGradient.SetSteps( aGradient2.StepCount );
+
+ SetGradientValue( aXGradient );
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ case MID_NAME:
+ {
+ rtl::OUString aName;
+ if (!(rVal >>= aName ))
+ return false;
+ SetName( aName );
+ break;
+ }
+
+ case MID_FILLGRADIENT:
+ {
+ ::com::sun::star::awt::Gradient aGradient2;
+ if(!(rVal >>= aGradient2))
+ return false;
+
+ XGradient aXGradient;
+
+ aXGradient.SetGradientStyle( (XGradientStyle) aGradient2.Style );
+ aXGradient.SetStartColor( aGradient2.StartColor );
+ aXGradient.SetEndColor( aGradient2.EndColor );
+ aXGradient.SetAngle( aGradient2.Angle );
+ aXGradient.SetBorder( aGradient2.Border );
+ aXGradient.SetXOffset( aGradient2.XOffset );
+ aXGradient.SetYOffset( aGradient2.YOffset );
+ aXGradient.SetStartIntens( aGradient2.StartIntensity );
+ aXGradient.SetEndIntens( aGradient2.EndIntensity );
+ aXGradient.SetSteps( aGradient2.StepCount );
+
+ SetGradientValue( aXGradient );
+ break;
+ }
+
+ case MID_GRADIENT_STARTCOLOR:
+ case MID_GRADIENT_ENDCOLOR:
+ {
+ sal_Int32 nVal = 0;
+ if(!(rVal >>= nVal ))
+ return false;
+
+ XGradient aXGradient = GetGradientValue();
+
+ if ( nMemberId == MID_GRADIENT_STARTCOLOR )
+ aXGradient.SetStartColor( nVal );
+ else
+ aXGradient.SetEndColor( nVal );
+ SetGradientValue( aXGradient );
+ break;
+ }
+
+ case MID_GRADIENT_STYLE:
+ case MID_GRADIENT_ANGLE:
+ case MID_GRADIENT_BORDER:
+ case MID_GRADIENT_STARTINTENSITY:
+ case MID_GRADIENT_ENDINTENSITY:
+ case MID_GRADIENT_STEPCOUNT:
+ case MID_GRADIENT_XOFFSET:
+ case MID_GRADIENT_YOFFSET:
+ {
+ sal_Int16 nVal = sal_Int16();
+ if(!(rVal >>= nVal ))
+ return false;
+
+ XGradient aXGradient = GetGradientValue();
+
+ switch ( nMemberId )
+ {
+ case MID_GRADIENT_STYLE:
+ aXGradient.SetGradientStyle( (XGradientStyle)nVal ); break;
+ case MID_GRADIENT_ANGLE:
+ aXGradient.SetAngle( nVal ); break;
+ case MID_GRADIENT_BORDER:
+ aXGradient.SetBorder( nVal ); break;
+ case MID_GRADIENT_STARTINTENSITY:
+ aXGradient.SetStartIntens( nVal ); break;
+ case MID_GRADIENT_ENDINTENSITY:
+ aXGradient.SetEndIntens( nVal ); break;
+ case MID_GRADIENT_STEPCOUNT:
+ aXGradient.SetSteps( nVal ); break;
+ case MID_GRADIENT_XOFFSET:
+ aXGradient.SetXOffset( nVal ); break;
+ case MID_GRADIENT_YOFFSET:
+ aXGradient.SetYOffset( nVal ); break;
+ }
+
+ SetGradientValue( aXGradient );
+ break;
+ }
+ }
+
+ return true;
+}
+
+BOOL XFillGradientItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
+{
+ return ((XFillGradientItem*)p1)->GetGradientValue() == ((XFillGradientItem*)p2)->GetGradientValue();
+}
+
+XFillGradientItem* XFillGradientItem::checkForUniqueItem( SdrModel* pModel ) const
+{
+ if( pModel )
+ {
+ const String aUniqueName = NameOrIndex::CheckNamedItem( this,
+ XATTR_FILLGRADIENT,
+ &pModel->GetItemPool(),
+ pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL,
+ XFillGradientItem::CompareValueFunc,
+ RID_SVXSTR_GRADIENT,
+ pModel->GetGradientList() );
+
+ // if the given name is not valid, replace it!
+ if( aUniqueName != GetName() )
+ {
+ return new XFillGradientItem( aUniqueName, aGradient );
+ }
+ }
+
+ return (XFillGradientItem*)this;
+}
+
+// ----------------------------------
+// class XFillFloatTransparenceItem -
+// ----------------------------------
+
+TYPEINIT1_AUTOFACTORY( XFillFloatTransparenceItem, XFillGradientItem );
+
+// -----------------------------------------------------------------------------
+
+XFillFloatTransparenceItem::XFillFloatTransparenceItem() :
+ bEnabled( FALSE )
+{
+ SetWhich( XATTR_FILLFLOATTRANSPARENCE );
+}
+
+//------------------------------------------------------------------------
+
+XFillFloatTransparenceItem::XFillFloatTransparenceItem( INT32 nIndex, const XGradient& rGradient, BOOL bEnable ) :
+ XFillGradientItem ( nIndex, rGradient ),
+ bEnabled ( bEnable )
+{
+ SetWhich( XATTR_FILLFLOATTRANSPARENCE );
+}
+
+//------------------------------------------------------------------------
+
+XFillFloatTransparenceItem::XFillFloatTransparenceItem(const XubString& rName, const XGradient& rGradient, BOOL bEnable ) :
+ XFillGradientItem ( rName, rGradient ),
+ bEnabled ( bEnable )
+{
+ SetWhich( XATTR_FILLFLOATTRANSPARENCE );
+}
+
+//------------------------------------------------------------------------
+
+XFillFloatTransparenceItem::XFillFloatTransparenceItem( const XFillFloatTransparenceItem& rItem ) :
+ XFillGradientItem ( rItem ),
+ bEnabled ( rItem.bEnabled )
+{
+ SetWhich( XATTR_FILLFLOATTRANSPARENCE );
+}
+
+//------------------------------------------------------------------------
+
+//XFillFloatTransparenceItem::XFillFloatTransparenceItem( SvStream& rIn, USHORT nVer ) :
+// XFillGradientItem ( rIn, nVer )
+//{
+// SetWhich( XATTR_FILLFLOATTRANSPARENCE );
+// rIn >> bEnabled;
+//}
+
+//*************************************************************************
+
+XFillFloatTransparenceItem::XFillFloatTransparenceItem(SfxItemPool* /*pPool*/, const XGradient& rTheGradient, BOOL bEnable )
+: XFillGradientItem ( -1, rTheGradient ),
+ bEnabled ( bEnable )
+{
+ SetWhich( XATTR_FILLFLOATTRANSPARENCE );
+}
+
+//*************************************************************************
+
+XFillFloatTransparenceItem::XFillFloatTransparenceItem(SfxItemPool* /*pPool*/)
+{
+ SetWhich( XATTR_FILLFLOATTRANSPARENCE );
+}
+
+//------------------------------------------------------------------------
+
+int XFillFloatTransparenceItem::operator==( const SfxPoolItem& rItem ) const
+{
+ return ( NameOrIndex::operator==(rItem) ) &&
+ ( GetGradientValue() == ((const XFillGradientItem&)rItem).GetGradientValue() ) &&
+ ( bEnabled == ( (XFillFloatTransparenceItem&) rItem ).bEnabled );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* XFillFloatTransparenceItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillFloatTransparenceItem( *this );
+}
+
+//------------------------------------------------------------------------
+
+//SfxPoolItem* XFillFloatTransparenceItem::Create( SvStream& rIn, USHORT nVer ) const
+//{
+// return( ( 0 == nVer ) ? Clone( NULL ) : new XFillFloatTransparenceItem( rIn, nVer ) );
+//}
+
+//------------------------------------------------------------------------
+
+//SvStream& XFillFloatTransparenceItem::Store( SvStream& rOut, USHORT nItemVersion ) const
+//{
+// XFillGradientItem::Store( rOut, nItemVersion );
+// rOut << bEnabled;
+// return rOut;
+//}
+
+//------------------------------------------------------------------------
+
+USHORT XFillFloatTransparenceItem::GetVersion( USHORT nFileFormatVersion ) const
+{
+ // !!! if version number of this object must be increased, please !!!
+ // !!! increase version number of base class XFillGradientItem !!!
+ return XFillGradientItem::GetVersion( nFileFormatVersion );
+}
+
+//------------------------------------------------------------------------
+
+bool XFillFloatTransparenceItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+ return XFillGradientItem::QueryValue( rVal, nMemberId );
+}
+
+//------------------------------------------------------------------------
+
+bool XFillFloatTransparenceItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+ return XFillGradientItem::PutValue( rVal, nMemberId );
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XFillFloatTransparenceItem::GetPresentation( SfxItemPresentation ePres,
+ SfxMapUnit eCoreUnit, SfxMapUnit ePresUnit,
+ XubString& rText,
+ const IntlWrapper * pIntlWrapper ) const
+{
+ return XFillGradientItem::GetPresentation( ePres, eCoreUnit, ePresUnit, rText, pIntlWrapper );
+}
+
+BOOL XFillFloatTransparenceItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
+{
+ return ((XFillFloatTransparenceItem*)p1)->IsEnabled() == ((XFillFloatTransparenceItem*)p2)->IsEnabled() &&
+ ((XFillFloatTransparenceItem*)p1)->GetGradientValue() == ((XFillFloatTransparenceItem*)p2)->GetGradientValue();
+}
+
+XFillFloatTransparenceItem* XFillFloatTransparenceItem::checkForUniqueItem( SdrModel* pModel ) const
+{
+ // #85953# unique name only necessary when enabled
+ if(IsEnabled())
+ {
+ if( pModel )
+ {
+ const String aUniqueName = NameOrIndex::CheckNamedItem( this,
+ XATTR_FILLFLOATTRANSPARENCE,
+ &pModel->GetItemPool(),
+ pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL,
+ XFillFloatTransparenceItem::CompareValueFunc,
+ RID_SVXSTR_TRASNGR0,
+ NULL );
+
+ // if the given name is not valid, replace it!
+ if( aUniqueName != GetName() )
+ {
+ return new XFillFloatTransparenceItem( aUniqueName, GetGradientValue(), TRUE );
+ }
+ }
+ }
+ else
+ {
+ // #85953# if disabled, force name to empty string
+ if(GetName().Len())
+ {
+ return new XFillFloatTransparenceItem(String(), GetGradientValue(), FALSE);
+ }
+ }
+
+ return (XFillFloatTransparenceItem*)this;
+}
+
+// -------------
+// class XHatch
+// -------------
+
+/*************************************************************************
+|*
+|* XHatch::XHatch(XHatchStyle, const Color&, long, long)
+|*
+|* Beschreibung
+|* Ersterstellung 21.11.94
+|* Letzte Aenderung 21.11.94
+|*
+*************************************************************************/
+
+XHatch::XHatch(const Color& rCol, XHatchStyle eTheStyle, long nTheDistance,
+ long nTheAngle) :
+ eStyle(eTheStyle),
+ aColor(rCol),
+ nDistance(nTheDistance),
+ nAngle(nTheAngle)
+{
+}
+
+/*************************************************************************
+|*
+|* int XHatch::operator==(const SfxPoolItem& rItem) const
+|*
+|* Beschreibung
+|* Ersterstellung 29.11.94
+|* Letzte Aenderung 29.11.94
+|*
+*************************************************************************/
+
+bool XHatch::operator==(const XHatch& rHatch) const
+{
+ return ( eStyle == rHatch.eStyle &&
+ aColor == rHatch.aColor &&
+ nDistance == rHatch.nDistance &&
+ nAngle == rHatch.nAngle );
+}
+
+
+// -----------------------
+// class XFillHatchItem
+// -----------------------
+TYPEINIT1_AUTOFACTORY(XFillHatchItem, NameOrIndex);
+
+/*************************************************************************
+|*
+|* XFillHatchItem::XFillHatchItem(INT32 nIndex,
+|* const XHatch& rTheHatch)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillHatchItem::XFillHatchItem(INT32 nIndex,
+ const XHatch& rTheHatch) :
+ NameOrIndex(XATTR_FILLHATCH, nIndex),
+ aHatch(rTheHatch)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillHatchItem::XFillHatchItem(const XubString& rName,
+|* const XHatch& rTheHatch)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillHatchItem::XFillHatchItem(const XubString& rName,
+ const XHatch& rTheHatch) :
+ NameOrIndex(XATTR_FILLHATCH, rName),
+ aHatch(rTheHatch)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillHatchItem::XFillHatchItem(const XFillHatchItem& rItem)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillHatchItem::XFillHatchItem(const XFillHatchItem& rItem) :
+ NameOrIndex(rItem),
+ aHatch(rItem.aHatch)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillHatchItem::XFillHatchItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+XFillHatchItem::XFillHatchItem(SvStream& rIn) :
+ NameOrIndex(XATTR_FILLHATCH, rIn),
+ aHatch(COL_BLACK)
+{
+ if (!IsIndex())
+ {
+ USHORT nRed;
+ USHORT nGreen;
+ USHORT nBlue;
+ INT16 nITemp;
+ INT32 nLTemp;
+
+ rIn >> nITemp; aHatch.SetHatchStyle((XHatchStyle)nITemp);
+ rIn >> nRed;
+ rIn >> nGreen;
+ rIn >> nBlue;
+
+ Color aCol;
+ aCol = Color( (BYTE)( nRed >> 8 ), (BYTE)( nGreen >> 8 ), (BYTE)( nBlue >> 8 ) );
+ aHatch.SetColor(aCol);
+ rIn >> nLTemp; aHatch.SetDistance(nLTemp);
+ rIn >> nLTemp; aHatch.SetAngle(nLTemp);
+ }
+}
+
+//*************************************************************************
+
+XFillHatchItem::XFillHatchItem(SfxItemPool* /*pPool*/, const XHatch& rTheHatch)
+: NameOrIndex( XATTR_FILLHATCH, -1 ),
+ aHatch(rTheHatch)
+{
+}
+
+//*************************************************************************
+
+XFillHatchItem::XFillHatchItem(SfxItemPool* /*pPool*/)
+: NameOrIndex(XATTR_FILLHATCH, -1 )
+{
+}
+
+/*************************************************************************
+|*
+|* XFillHatchItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillHatchItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFillHatchItem(*this);
+}
+
+/*************************************************************************
+|*
+|* int XFillHatchItem::operator==(const SfxPoolItem& rItem) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+int XFillHatchItem::operator==(const SfxPoolItem& rItem) const
+{
+ return ( NameOrIndex::operator==(rItem) &&
+ aHatch == ((const XFillHatchItem&) rItem).aHatch );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFillHatchItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillHatchItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillHatchItem(rIn);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFillHatchItem::Store(SvStream& rOut) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 15.11.94
+|*
+*************************************************************************/
+
+SvStream& XFillHatchItem::Store( SvStream& rOut, USHORT nItemVersion ) const
+{
+ NameOrIndex::Store( rOut, nItemVersion );
+
+ if (!IsIndex())
+ {
+ rOut << (INT16)aHatch.GetHatchStyle();
+
+ USHORT nTmp;
+ nTmp = VCLTOSVCOL( aHatch.GetColor().GetRed() ); rOut << nTmp;
+ nTmp = VCLTOSVCOL( aHatch.GetColor().GetGreen() ); rOut << nTmp;
+ nTmp = VCLTOSVCOL( aHatch.GetColor().GetBlue() ); rOut << nTmp;
+
+ rOut << (INT32) aHatch.GetDistance();
+ rOut << (INT32) aHatch.GetAngle();
+ }
+
+ return rOut;
+}
+
+/*************************************************************************
+|*
+|* const XHatch& XFillHatchItem::GetValue(const XHatchTable* pTable) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 18.11.94
+|*
+*************************************************************************/
+
+const XHatch& XFillHatchItem::GetHatchValue(const XHatchTable* pTable) const // GetValue -> GetHatchValue
+{
+ if (!IsIndex())
+ return aHatch;
+ else
+ return pTable->GetHatch(GetIndex())->GetHatch();
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XFillHatchItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = GetName();
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+//------------------------------------------------------------------------
+
+bool XFillHatchItem::HasMetrics() const
+{
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+bool XFillHatchItem::ScaleMetrics(long nMul, long nDiv)
+{
+ aHatch.SetDistance( ScaleMetricValue( aHatch.GetDistance(), nMul, nDiv ) );
+ return true;
+}
+
+// -----------------------------------------------------------------------
+bool XFillHatchItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ switch ( nMemberId )
+ {
+ case 0:
+ {
+ uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
+
+ ::com::sun::star::drawing::Hatch aUnoHatch;
+
+ aUnoHatch.Style = (::com::sun::star::drawing::HatchStyle)aHatch.GetHatchStyle();
+ aUnoHatch.Color = aHatch.GetColor().GetColor();
+ aUnoHatch.Distance = aHatch.GetDistance();
+ aUnoHatch.Angle = aHatch.GetAngle();
+
+ rtl::OUString aApiName;
+ SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
+ aPropSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ));
+ aPropSeq[0].Value = uno::makeAny( aApiName );
+ aPropSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillHatch" ));
+ aPropSeq[1].Value = uno::makeAny( aUnoHatch );
+ rVal = uno::makeAny( aPropSeq );
+ break;
+ }
+
+ case MID_FILLHATCH:
+ {
+ ::com::sun::star::drawing::Hatch aUnoHatch;
+
+ aUnoHatch.Style = (::com::sun::star::drawing::HatchStyle)aHatch.GetHatchStyle();
+ aUnoHatch.Color = aHatch.GetColor().GetColor();
+ aUnoHatch.Distance = aHatch.GetDistance();
+ aUnoHatch.Angle = aHatch.GetAngle();
+ rVal <<= aUnoHatch;
+ break;
+ }
+
+ case MID_NAME:
+ {
+ rtl::OUString aApiName;
+ SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
+ rVal <<= aApiName;
+ break;
+ }
+
+ case MID_HATCH_STYLE:
+ rVal <<= (::com::sun::star::drawing::HatchStyle)aHatch.GetHatchStyle(); break;
+ case MID_HATCH_COLOR:
+ rVal <<= (sal_Int32)aHatch.GetColor().GetColor(); break;
+ case MID_HATCH_DISTANCE:
+ rVal <<= aHatch.GetDistance(); break;
+ case MID_HATCH_ANGLE:
+ rVal <<= aHatch.GetAngle(); break;
+
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ return true;
+}
+
+// -----------------------------------------------------------------------
+bool XFillHatchItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ switch ( nMemberId )
+ {
+ case 0:
+ {
+ uno::Sequence< beans::PropertyValue > aPropSeq;
+ ::com::sun::star::drawing::Hatch aUnoHatch;
+ rtl::OUString aName;
+ bool bHatch( false );
+
+ if ( rVal >>= aPropSeq )
+ {
+ for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ )
+ {
+ if ( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" )))
+ aPropSeq[n].Value >>= aName;
+ else if ( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FillHatch" )))
+ {
+ if ( aPropSeq[n].Value >>= aUnoHatch )
+ bHatch = true;
+ }
+ }
+
+ SetName( aName );
+ if ( bHatch )
+ {
+ aHatch.SetHatchStyle( (XHatchStyle)aUnoHatch.Style );
+ aHatch.SetColor( aUnoHatch.Color );
+ aHatch.SetDistance( aUnoHatch.Distance );
+ aHatch.SetAngle( aUnoHatch.Angle );
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ case MID_FILLHATCH:
+ {
+ ::com::sun::star::drawing::Hatch aUnoHatch;
+ if(!(rVal >>= aUnoHatch))
+ return false;
+
+ aHatch.SetHatchStyle( (XHatchStyle)aUnoHatch.Style );
+ aHatch.SetColor( aUnoHatch.Color );
+ aHatch.SetDistance( aUnoHatch.Distance );
+ aHatch.SetAngle( aUnoHatch.Angle );
+ break;
+ }
+
+ case MID_NAME:
+ {
+ rtl::OUString aName;
+ if (!(rVal >>= aName ))
+ return false;
+ SetName( aName );
+ break;
+ }
+
+ case MID_HATCH_STYLE:
+ {
+ sal_Int16 nVal = sal_Int16();
+ if (!(rVal >>= nVal ))
+ return false;
+ aHatch.SetHatchStyle( (XHatchStyle)nVal );
+ break;
+ }
+
+ case MID_HATCH_COLOR:
+ case MID_HATCH_DISTANCE:
+ case MID_HATCH_ANGLE:
+ {
+ sal_Int32 nVal = 0;
+ if (!(rVal >>= nVal ))
+ return false;
+
+ if ( nMemberId == MID_HATCH_COLOR )
+ aHatch.SetColor( nVal );
+ else if ( nMemberId == MID_HATCH_DISTANCE )
+ aHatch.SetDistance( nVal );
+ else
+ aHatch.SetAngle( nVal );
+ break;
+ }
+
+ default: DBG_ERROR("Wrong MemberId!"); return false;
+ }
+
+ return true;
+}
+
+BOOL XFillHatchItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
+{
+ return ((XFillHatchItem*)p1)->GetHatchValue() == ((XFillHatchItem*)p2)->GetHatchValue();
+}
+
+XFillHatchItem* XFillHatchItem::checkForUniqueItem( SdrModel* pModel ) const
+{
+ if( pModel )
+ {
+ const String aUniqueName = NameOrIndex::CheckNamedItem( this,
+ XATTR_FILLHATCH,
+ &pModel->GetItemPool(),
+ pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL,
+ XFillHatchItem::CompareValueFunc,
+ RID_SVXSTR_HATCH10,
+ pModel->GetHatchList() );
+
+ // if the given name is not valid, replace it!
+ if( aUniqueName != GetName() )
+ {
+ return new XFillHatchItem( aUniqueName, aHatch );
+ }
+ }
+
+ return (XFillHatchItem*)this;
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// FormText-Attribute
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//-------------------------
+// class XFormTextStyleItem
+//-------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextStyleItem, SfxEnumItem);
+
+/*************************************************************************
+|*
+|* XFormTextStyleItem::XFormTextStyleItem()
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+XFormTextStyleItem::XFormTextStyleItem(XFormTextStyle eTheStyle) :
+ SfxEnumItem(XATTR_FORMTXTSTYLE, sal::static_int_cast< USHORT >(eTheStyle))
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextStyleItem::XFormTextStyleItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+XFormTextStyleItem::XFormTextStyleItem(SvStream& rIn) :
+ SfxEnumItem(XATTR_FORMTXTSTYLE, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextStyleItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextStyleItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextStyleItem( *this );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextStyleItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextStyleItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextStyleItem(rIn);
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+USHORT XFormTextStyleItem::GetValueCount() const
+{
+ return 5;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+// #FontWork#
+bool XFormTextStyleItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+// #FontWork#
+bool XFormTextStyleItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ rVal >>= nValue;
+ SetValue(sal::static_int_cast< USHORT >(nValue));
+
+ return true;
+}
+
+//-------------------------
+// class XFormTextAdjustItem
+//-------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextAdjustItem, SfxEnumItem);
+
+/*************************************************************************
+|*
+|* XFormTextAdjustItem::XFormTextAdjustItem()
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+XFormTextAdjustItem::XFormTextAdjustItem(XFormTextAdjust eTheAdjust) :
+ SfxEnumItem(XATTR_FORMTXTADJUST, sal::static_int_cast< USHORT >(eTheAdjust))
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextAdjustItem::XFormTextAdjustItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+XFormTextAdjustItem::XFormTextAdjustItem(SvStream& rIn) :
+ SfxEnumItem(XATTR_FORMTXTADJUST, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextAdjustItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextAdjustItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextAdjustItem( *this );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextAdjustItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextAdjustItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextAdjustItem(rIn);
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+USHORT XFormTextAdjustItem::GetValueCount() const
+{
+ return 4;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+// #FontWork#
+bool XFormTextAdjustItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+// #FontWork#
+bool XFormTextAdjustItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ rVal >>= nValue;
+ SetValue(sal::static_int_cast< USHORT >(nValue));
+
+ return true;
+}
+
+//----------------------------
+// class XFormTextDistanceItem
+//----------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextDistanceItem, SfxMetricItem);
+
+/*************************************************************************
+|*
+|* XFormTextDistanceItem::XFormTextDistanceItem()
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+XFormTextDistanceItem::XFormTextDistanceItem(long nDist) :
+ SfxMetricItem(XATTR_FORMTXTDISTANCE, nDist)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextDistanceItem::XFormTextDistanceItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+XFormTextDistanceItem::XFormTextDistanceItem(SvStream& rIn) :
+ SfxMetricItem(XATTR_FORMTXTDISTANCE, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextDistanceItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextDistanceItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextDistanceItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextDistanceItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextDistanceItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextDistanceItem(rIn);
+}
+
+//-------------------------
+// class XFormTextStartItem
+//-------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextStartItem, SfxMetricItem);
+
+/*************************************************************************
+|*
+|* XFormTextStartItem::XFormTextStartItem(long nStart)
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+XFormTextStartItem::XFormTextStartItem(long nStart) :
+ SfxMetricItem(XATTR_FORMTXTSTART, nStart)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextStartItem::XFormTextStartItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+XFormTextStartItem::XFormTextStartItem(SvStream& rIn) :
+ SfxMetricItem(XATTR_FORMTXTSTART, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextStartItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextStartItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextStartItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextStartItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 02.02.95 ESO
+|* Letzte Aenderung 02.02.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextStartItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextStartItem(rIn);
+}
+
+// -------------------------
+// class XFormTextMirrorItem
+// -------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextMirrorItem, SfxBoolItem);
+
+/*************************************************************************
+|*
+|* XFormTextMirrorItem::XFormTextMirrorItem(BOOL bMirror)
+|*
+|* Ersterstellung 06.02.95 ESO
+|* Letzte Aenderung 06.02.95 ESO
+|*
+*************************************************************************/
+
+XFormTextMirrorItem::XFormTextMirrorItem(BOOL bMirror) :
+ SfxBoolItem(XATTR_FORMTXTMIRROR, bMirror)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextMirrorItem::XFormTextMirrorItem(SvStream& rIn)
+|*
+|* Ersterstellung 06.02.95 ESO
+|* Letzte Aenderung 06.02.95 ESO
+|*
+*************************************************************************/
+
+XFormTextMirrorItem::XFormTextMirrorItem(SvStream& rIn) :
+ SfxBoolItem(XATTR_FORMTXTMIRROR, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextMirrorItem::Clone(SfxItemPool* pPool) const
+|*
+|* Ersterstellung 06.02.95 ESO
+|* Letzte Aenderung 06.02.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextMirrorItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextMirrorItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextMirrorItem::Create(SvStream& rIn, USHORT nVer)
+|* const
+|*
+|* Ersterstellung 06.02.95 ESO
+|* Letzte Aenderung 06.02.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextMirrorItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextMirrorItem(rIn);
+}
+
+
+// --------------------------
+// class XFormTextOutlineItem
+// --------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextOutlineItem, SfxBoolItem);
+
+/*************************************************************************
+|*
+|* XFormTextOutlineItem::XFormTextOutlineItem()
+|*
+|* Ersterstellung 27.06.95 ESO
+|* Letzte Aenderung 27.06.95 ESO
+|*
+*************************************************************************/
+
+XFormTextOutlineItem::XFormTextOutlineItem(BOOL bOutline) :
+ SfxBoolItem(XATTR_FORMTXTOUTLINE, bOutline)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextOutlineItem::XFormTextOutlineItem(SvStream& rIn)
+|*
+|* Ersterstellung 27.06.95 ESO
+|* Letzte Aenderung 27.06.95 ESO
+|*
+*************************************************************************/
+
+XFormTextOutlineItem::XFormTextOutlineItem(SvStream& rIn) :
+ SfxBoolItem(XATTR_FORMTXTOUTLINE, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextOutlineItem::Clone(SfxItemPool* pPool) const
+|*
+|* Ersterstellung 27.06.95 ESO
+|* Letzte Aenderung 27.06.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextOutlineItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextOutlineItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextOutlineItem::Create(SvStream& rIn, USHORT nVer)
+|* const
+|*
+|* Ersterstellung 27.06.95 ESO
+|* Letzte Aenderung 27.06.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextOutlineItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextOutlineItem(rIn);
+}
+
+//--------------------------
+// class XFormTextShadowItem
+//--------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextShadowItem, SfxEnumItem);
+
+/*************************************************************************
+|*
+|* XFormTextShadowItem::XFormTextShadowItem()
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+XFormTextShadowItem::XFormTextShadowItem(XFormTextShadow eFormTextShadow) :
+ SfxEnumItem(
+ XATTR_FORMTXTSHADOW, sal::static_int_cast< USHORT >(eFormTextShadow))
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowItem::XFormTextShadowItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+XFormTextShadowItem::XFormTextShadowItem(SvStream& rIn) :
+ SfxEnumItem(XATTR_FORMTXTSHADOW, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextShadowItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextShadowItem( *this );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextShadowItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextShadowItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextShadowItem(rIn);
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+USHORT XFormTextShadowItem::GetValueCount() const
+{
+ return 3;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+// #FontWork#
+bool XFormTextShadowItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+// #FontWork#
+bool XFormTextShadowItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ rVal >>= nValue;
+ SetValue(sal::static_int_cast< USHORT >(nValue));
+
+ return true;
+}
+
+// -------------------------------
+// class XFormTextShadowColorItem
+// -------------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextShadowColorItem, XColorItem);
+
+/*************************************************************************
+|*
+|* XFormTextShadowColorItem::XFormTextShadowColorItem()
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+XFormTextShadowColorItem::XFormTextShadowColorItem(INT32 nIndex,
+ const Color& rTheColor) :
+ XColorItem(XATTR_FORMTXTSHDWCOLOR, nIndex, rTheColor)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowColorItem::XFormTextShadowColorItem(const XubString& rName, const Color& rTheColor)
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+XFormTextShadowColorItem::XFormTextShadowColorItem(const XubString& rName,
+ const Color& rTheColor) :
+ XColorItem(XATTR_FORMTXTSHDWCOLOR, rName, rTheColor)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowColorItem::XFormTextShadowColorItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+XFormTextShadowColorItem::XFormTextShadowColorItem(SvStream& rIn) :
+ XColorItem(XATTR_FORMTXTSHDWCOLOR, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowColorItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextShadowColorItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextShadowColorItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextShadowColorItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextShadowColorItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextShadowColorItem(rIn);
+}
+
+//------------------------------
+// class XFormTextShadowXValItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextShadowXValItem, SfxMetricItem);
+
+/*************************************************************************
+|*
+|* XFormTextShadowXValItem::XFormTextShadowXValItem(long)
+|*
+|* Beschreibung
+|* Ersterstellung 28.06.95 ESO
+|* Letzte Aenderung 28.06.95 ESO
+|*
+*************************************************************************/
+
+XFormTextShadowXValItem::XFormTextShadowXValItem(long nVal) :
+ SfxMetricItem(XATTR_FORMTXTSHDWXVAL, nVal)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowXValItem::XFormTextShadowXValItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 28.06.95 ESO
+|* Letzte Aenderung 28.06.95 ESO
+|*
+*************************************************************************/
+
+XFormTextShadowXValItem::XFormTextShadowXValItem(SvStream& rIn) :
+ SfxMetricItem(XATTR_FORMTXTSHDWXVAL, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowXValItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 28.06.95 ESO
+|* Letzte Aenderung 28.06.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextShadowXValItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextShadowXValItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextShadowXValItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 28.06.95 ESO
+|* Letzte Aenderung 28.06.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextShadowXValItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextShadowXValItem(rIn);
+}
+
+//------------------------------
+// class XFormTextShadowYValItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextShadowYValItem, SfxMetricItem);
+
+/*************************************************************************
+|*
+|* XFormTextShadowYValItem::XFormTextShadowYValItem(long)
+|*
+|* Beschreibung
+|* Ersterstellung 28.06.95 ESO
+|* Letzte Aenderung 28.06.95 ESO
+|*
+*************************************************************************/
+
+XFormTextShadowYValItem::XFormTextShadowYValItem(long nVal) :
+ SfxMetricItem(XATTR_FORMTXTSHDWYVAL, nVal)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowYValItem::XFormTextShadowYValItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 28.06.95 ESO
+|* Letzte Aenderung 28.06.95 ESO
+|*
+*************************************************************************/
+
+XFormTextShadowYValItem::XFormTextShadowYValItem(SvStream& rIn) :
+ SfxMetricItem(XATTR_FORMTXTSHDWYVAL, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowYValItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 28.06.95 ESO
+|* Letzte Aenderung 28.06.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextShadowYValItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextShadowYValItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextShadowYValItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 28.06.95 ESO
+|* Letzte Aenderung 28.06.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextShadowYValItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextShadowYValItem(rIn);
+}
+
+//---------------------------
+// class XFormTextStdFormItem
+//---------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextStdFormItem, SfxEnumItem);
+
+/*************************************************************************
+|*
+|* XFormTextStdFormItem::XFormTextStdFormItem()
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+XFormTextStdFormItem::XFormTextStdFormItem(XFormTextStdForm eFormTextStdForm) :
+ SfxEnumItem(
+ XATTR_FORMTXTSTDFORM, sal::static_int_cast< USHORT >(eFormTextStdForm))
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextStdFormItem::XFormTextStdFormItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+XFormTextStdFormItem::XFormTextStdFormItem(SvStream& rIn) :
+ SfxEnumItem(XATTR_FORMTXTSTDFORM, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextStdFormItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextStdFormItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextStdFormItem( *this );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextStdFormItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 27.06.95
+|* Letzte Aenderung 27.06.95
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextStdFormItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextStdFormItem(rIn);
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+USHORT XFormTextStdFormItem::GetValueCount() const
+{
+ return 3;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+// #FontWork#
+bool XFormTextStdFormItem::QueryValue( uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ rVal <<= (sal_Int32)GetValue();
+ return true;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\*************************************************************************/
+
+// #FontWork#
+bool XFormTextStdFormItem::PutValue( const uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ sal_Int32 nValue = 0;
+ rVal >>= nValue;
+ SetValue(sal::static_int_cast< USHORT >(nValue));
+
+ return true;
+}
+
+// --------------------------
+// class XFormTextHideFormItem
+// --------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextHideFormItem, SfxBoolItem);
+
+/*************************************************************************
+|*
+|* XFormTextHideFormItem::XFormTextHideFormItem()
+|*
+|* Ersterstellung 27.06.95 ESO
+|* Letzte Aenderung 27.06.95 ESO
+|*
+*************************************************************************/
+
+XFormTextHideFormItem::XFormTextHideFormItem(BOOL bHide) :
+ SfxBoolItem(XATTR_FORMTXTHIDEFORM, bHide)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextHideFormItem::XFormTextHideFormItem(SvStream& rIn)
+|*
+|* Ersterstellung 27.06.95 ESO
+|* Letzte Aenderung 27.06.95 ESO
+|*
+*************************************************************************/
+
+XFormTextHideFormItem::XFormTextHideFormItem(SvStream& rIn) :
+ SfxBoolItem(XATTR_FORMTXTHIDEFORM, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextHideFormItem::Clone(SfxItemPool* pPool) const
+|*
+|* Ersterstellung 27.06.95 ESO
+|* Letzte Aenderung 27.06.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextHideFormItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextHideFormItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextHideFormItem::Create(SvStream& rIn, USHORT nVer)
+|* const
+|*
+|* Ersterstellung 27.06.95 ESO
+|* Letzte Aenderung 27.06.95 ESO
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextHideFormItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextHideFormItem(rIn);
+}
+
+
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// SetItems
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+TYPEINIT1(XLineAttrSetItem, SfxSetItem);
+
+/*************************************************************************
+|*
+|* Konstruktoren fuer Linienattribute-SetItem
+|*
+\************************************************************************/
+
+XLineAttrSetItem::XLineAttrSetItem( SfxItemSet* pItemSet ) :
+ SfxSetItem( XATTRSET_LINE, pItemSet)
+{
+}
+
+/************************************************************************/
+
+XLineAttrSetItem::XLineAttrSetItem( SfxItemPool* pItemPool ) :
+ SfxSetItem( XATTRSET_LINE,
+ new SfxItemSet( *pItemPool, XATTR_LINE_FIRST, XATTR_LINE_LAST))
+{
+}
+
+/************************************************************************/
+
+XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr ) :
+ SfxSetItem( rLineAttr )
+{
+}
+
+/************************************************************************/
+
+XLineAttrSetItem::XLineAttrSetItem( const XLineAttrSetItem& rLineAttr,
+ SfxItemPool* pItemPool) :
+ SfxSetItem( rLineAttr, pItemPool )
+{
+}
+
+/*************************************************************************
+|*
+|* Clone-Funktion
+|*
+\************************************************************************/
+
+SfxPoolItem* XLineAttrSetItem::Clone( SfxItemPool* pPool ) const
+{
+ return new XLineAttrSetItem( *this, pPool );
+}
+
+/*************************************************************************
+|*
+|* SetItem aus Stream erzeugen
+|*
+\************************************************************************/
+
+SfxPoolItem* XLineAttrSetItem::Create( SvStream& rStream, USHORT /*nVersion*/) const
+{
+ SfxItemSet *pSet2 = new SfxItemSet( *GetItemSet().GetPool(),
+ XATTR_LINE_FIRST, XATTR_LINE_LAST);
+ pSet2->Load( rStream );
+ return new XLineAttrSetItem( pSet2 );
+}
+
+/*************************************************************************
+|*
+|* SetItem in Stream speichern
+|*
+\************************************************************************/
+
+SvStream& XLineAttrSetItem::Store( SvStream& rStream, USHORT nItemVersion ) const
+{
+ return SfxSetItem::Store( rStream, nItemVersion );
+}
+
+
+TYPEINIT1(XFillAttrSetItem, SfxSetItem);
+
+/*************************************************************************
+|*
+|* Konstruktoren fuer Fuellattribute-SetItem
+|*
+\************************************************************************/
+
+XFillAttrSetItem::XFillAttrSetItem( SfxItemSet* pItemSet ) :
+ SfxSetItem( XATTRSET_FILL, pItemSet)
+{
+}
+
+/************************************************************************/
+
+XFillAttrSetItem::XFillAttrSetItem( SfxItemPool* pItemPool ) :
+ SfxSetItem( XATTRSET_FILL,
+ new SfxItemSet( *pItemPool, XATTR_FILL_FIRST, XATTR_FILL_LAST))
+{
+}
+
+/************************************************************************/
+
+XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr ) :
+ SfxSetItem( rFillAttr )
+{
+}
+
+/************************************************************************/
+
+XFillAttrSetItem::XFillAttrSetItem( const XFillAttrSetItem& rFillAttr,
+ SfxItemPool* pItemPool ) :
+ SfxSetItem( rFillAttr, pItemPool )
+{
+}
+
+/*************************************************************************
+|*
+|* Clone-Funktion
+|*
+\************************************************************************/
+
+SfxPoolItem* XFillAttrSetItem::Clone( SfxItemPool* pPool ) const
+{
+ return new XFillAttrSetItem( *this, pPool );
+}
+
+/*************************************************************************
+|*
+|* SetItem aus Stream erzeugen
+|*
+\************************************************************************/
+
+SfxPoolItem* XFillAttrSetItem::Create( SvStream& rStream, USHORT /*nVersion*/) const
+{
+ SfxItemSet *pSet2 = new SfxItemSet( *GetItemSet().GetPool(),
+ XATTR_FILL_FIRST, XATTR_FILL_LAST);
+ pSet2->Load( rStream );
+ return new XFillAttrSetItem( pSet2 );
+}
+
+/*************************************************************************
+|*
+|* SetItem in Stream speichern
+|*
+\************************************************************************/
+
+SvStream& XFillAttrSetItem::Store( SvStream& rStream, USHORT nItemVersion ) const
+{
+ return SfxSetItem::Store( rStream, nItemVersion );
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xattr2.cxx b/svx/source/xoutdev/xattr2.cxx
new file mode 100644
index 000000000000..ffc0fbe98cbd
--- /dev/null
+++ b/svx/source/xoutdev/xattr2.cxx
@@ -0,0 +1,1714 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+
+#include <com/sun/star/drawing/LineJoint.hpp>
+#include <com/sun/star/uno/Any.hxx>
+
+#include <svx/dialogs.hrc>
+#include "xattr.hxx"
+#include <svx/xtable.hxx>
+#include <svx/dialmgr.hxx>
+#include <editeng/itemtype.hxx>
+#include <svx/xdef.hxx>
+
+#define GLOBALOVERFLOW
+
+/************************************************************************/
+
+//------------------------------
+// class XLineTransparenceItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY(XLineTransparenceItem, SfxUInt16Item);
+
+/*************************************************************************
+|*
+|* XLineTransparenceItem::XLineTransparenceItem(USHORT)
+|*
+|* Beschreibung
+|* Ersterstellung 07.11.95 KA
+|* Letzte Aenderung 07.11.95 KA
+|*
+*************************************************************************/
+
+XLineTransparenceItem::XLineTransparenceItem(USHORT nLineTransparence) :
+ SfxUInt16Item(XATTR_LINETRANSPARENCE, nLineTransparence)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineTransparenceItem::XLineTransparenceItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 07.11.95 KA
+|* Letzte Aenderung 07.11.95 KA
+|*
+*************************************************************************/
+
+XLineTransparenceItem::XLineTransparenceItem(SvStream& rIn) :
+ SfxUInt16Item(XATTR_LINETRANSPARENCE, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XLineTransparenceItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 07.11.95 KA
+|* Letzte Aenderung 07.11.95 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineTransparenceItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineTransparenceItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XLineTransparenceItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 07.11.95 KA
+|* Letzte Aenderung 07.11.95 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XLineTransparenceItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XLineTransparenceItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XLineTransparenceItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = XubString( ResId( RID_SVXSTR_TRANSPARENCE, DIALOG_MGR() ) );
+ rText.AppendAscii(": ");
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ rText += XubString( UniString::CreateFromInt32((USHORT) GetValue()) );
+ rText += sal_Unicode('%');
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+//-----------------------
+// class XLineJointItem -
+//-----------------------
+
+TYPEINIT1_AUTOFACTORY(XLineJointItem, SfxEnumItem);
+
+// -----------------------------------------------------------------------------
+
+XLineJointItem::XLineJointItem( XLineJoint eLineJoint ) :
+ SfxEnumItem(XATTR_LINEJOINT, sal::static_int_cast< USHORT >(eLineJoint))
+{
+}
+
+// -----------------------------------------------------------------------------
+
+XLineJointItem::XLineJointItem( SvStream& rIn ) :
+ SfxEnumItem( XATTR_LINEJOINT, rIn )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+USHORT XLineJointItem::GetVersion( USHORT /*nFileFormatVersion*/) const
+{
+ return 1;
+}
+
+// -----------------------------------------------------------------------------
+
+SfxPoolItem* XLineJointItem::Create( SvStream& rIn, USHORT nVer ) const
+{
+ XLineJointItem* pRet = new XLineJointItem( rIn );
+
+ if(nVer < 1)
+ pRet->SetValue(XLINEJOINT_ROUND);
+
+ return pRet;
+}
+
+// -----------------------------------------------------------------------------
+
+SfxPoolItem* XLineJointItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XLineJointItem( *this );
+}
+
+// -----------------------------------------------------------------------------
+
+SfxItemPresentation XLineJointItem::GetPresentation( SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/, XubString& rText, const IntlWrapper*) const
+{
+ rText.Erase();
+
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE: return ePres;
+
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ {
+ USHORT nId = 0;
+
+ switch( GetValue() )
+ {
+ case( XLINEJOINT_NONE ):
+ nId = RID_SVXSTR_LINEJOINT_NONE;
+ break;
+
+ case( XLINEJOINT_MIDDLE ):
+ nId = RID_SVXSTR_LINEJOINT_MIDDLE;
+ break;
+
+
+ case( XLINEJOINT_BEVEL ):
+ nId = RID_SVXSTR_LINEJOINT_BEVEL;
+ break;
+
+
+ case( XLINEJOINT_MITER ):
+ nId = RID_SVXSTR_LINEJOINT_MITER;
+ break;
+
+
+ case( XLINEJOINT_ROUND ):
+ nId = RID_SVXSTR_LINEJOINT_ROUND;
+ break;
+ }
+
+ if( nId )
+ rText = SVX_RESSTR( nId );
+
+ return ePres;
+ }
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+bool XLineJointItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/) const
+{
+ ::com::sun::star::drawing::LineJoint eJoint = ::com::sun::star::drawing::LineJoint_NONE;
+
+ switch( GetValue() )
+ {
+ case XLINEJOINT_NONE:
+ break;
+ case XLINEJOINT_MIDDLE:
+ eJoint = ::com::sun::star::drawing::LineJoint_MIDDLE;
+ break;
+ case XLINEJOINT_BEVEL:
+ eJoint = ::com::sun::star::drawing::LineJoint_BEVEL;
+ break;
+ case XLINEJOINT_MITER:
+ eJoint = ::com::sun::star::drawing::LineJoint_MITER;
+ break;
+ case XLINEJOINT_ROUND:
+ eJoint = ::com::sun::star::drawing::LineJoint_ROUND;
+ break;
+ default:
+ DBG_ERROR( "Unknown LineJoint enum value!" );
+ }
+
+ rVal <<= eJoint;
+ return true;
+}
+
+// -----------------------------------------------------------------------------
+
+bool XLineJointItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE /*nMemberId*/)
+{
+ XLineJoint eJoint = XLINEJOINT_NONE;
+ ::com::sun::star::drawing::LineJoint eUnoJoint;
+
+ if(!(rVal >>= eUnoJoint))
+ {
+ // also try an int (for Basic)
+ sal_Int32 nLJ = 0;
+ if(!(rVal >>= nLJ))
+ return false;
+ eUnoJoint = (::com::sun::star::drawing::LineJoint)nLJ;
+ }
+
+ switch( eUnoJoint )
+ {
+ case ::com::sun::star::drawing::LineJoint_MIDDLE:
+ eJoint = XLINEJOINT_MIDDLE;
+ break;
+ case ::com::sun::star::drawing::LineJoint_BEVEL:
+ eJoint = XLINEJOINT_BEVEL;
+ break;
+ case ::com::sun::star::drawing::LineJoint_MITER:
+ eJoint = XLINEJOINT_MITER;
+ break;
+ case ::com::sun::star::drawing::LineJoint_ROUND:
+ eJoint = XLINEJOINT_ROUND;
+ break;
+ default:
+ break;
+ }
+
+ SetValue( sal::static_int_cast< USHORT >( eJoint ) );
+
+ return true;
+}
+
+// -----------------------------------------------------------------------------
+
+USHORT XLineJointItem::GetValueCount() const
+{
+ // don't forget to update the api interface also
+ return 5;
+}
+
+//------------------------------
+// class XFillTransparenceItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY(XFillTransparenceItem, SfxUInt16Item);
+
+/*************************************************************************
+|*
+|* XFillTransparenceItem::XFillTransparenceItem(USHORT)
+|*
+|* Beschreibung
+|* Ersterstellung 07.11.95 KA
+|* Letzte Aenderung 07.11.95 KA
+|*
+*************************************************************************/
+
+XFillTransparenceItem::XFillTransparenceItem(USHORT nFillTransparence) :
+ SfxUInt16Item(XATTR_FILLTRANSPARENCE, nFillTransparence)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillTransparenceItem::XFillTransparenceItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 07.11.95 KA
+|* Letzte Aenderung 07.11.95 KA
+|*
+*************************************************************************/
+
+XFillTransparenceItem::XFillTransparenceItem(SvStream& rIn) :
+ SfxUInt16Item(XATTR_FILLTRANSPARENCE, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFillTransparenceItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 07.11.95 KA
+|* Letzte Aenderung 07.11.95 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillTransparenceItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFillTransparenceItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFillTransparenceItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 07.11.95 KA
+|* Letzte Aenderung 07.11.95 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillTransparenceItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillTransparenceItem(rIn);
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XFillTransparenceItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText = XubString( ResId( RID_SVXSTR_TRANSPARENCE, DIALOG_MGR() ) );
+ rText.AppendAscii(": ");
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ rText += XubString( UniString::CreateFromInt32((USHORT) GetValue() ));
+ rText += sal_Unicode('%');
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+//------------------------------
+// class XFormTextShadowTranspItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY(XFormTextShadowTranspItem, SfxUInt16Item);
+
+/*************************************************************************
+|*
+|* XFormTextShadowTranspItem::XFormTextShadowTranspItem(USHORT)
+|*
+|* Beschreibung
+|* Ersterstellung 09.11.95 KA
+|* Letzte Aenderung 09.11.95 KA
+|*
+*************************************************************************/
+
+XFormTextShadowTranspItem::XFormTextShadowTranspItem(USHORT nShdwTransparence) :
+ SfxUInt16Item(XATTR_FORMTXTSHDWTRANSP, nShdwTransparence)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowTranspItem::XFormTextShadowTranspItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 09.11.95 KA
+|* Letzte Aenderung 09.11.95 KA
+|*
+*************************************************************************/
+
+XFormTextShadowTranspItem::XFormTextShadowTranspItem(SvStream& rIn) :
+ SfxUInt16Item(XATTR_FORMTXTSHDWTRANSP, rIn)
+{
+}
+
+/*************************************************************************
+|*
+|* XFormTextShadowTranspItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 09.11.95 KA
+|* Letzte Aenderung 09.11.95 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextShadowTranspItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFormTextShadowTranspItem(*this);
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFormTextShadowTranspItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 09.11.95 KA
+|* Letzte Aenderung 09.11.95 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFormTextShadowTranspItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFormTextShadowTranspItem(rIn);
+}
+
+
+//------------------------------
+// class XFillGradientStepCountItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY(XGradientStepCountItem, SfxUInt16Item);
+
+/*************************************************************************
+|*
+|* XGradientStepCountItem::XGradientStepCountItem( USHORT )
+|*
+|* Beschreibung
+|* Ersterstellung 23.01.96 KA
+|* Letzte Aenderung 23.01.96 KA
+|*
+*************************************************************************/
+
+XGradientStepCountItem::XGradientStepCountItem( USHORT nStepCount ) :
+ SfxUInt16Item( XATTR_GRADIENTSTEPCOUNT, nStepCount )
+{
+}
+
+/*************************************************************************
+|*
+|* XGradientStepCountItem::XGradientStepCountItem( SvStream& rIn )
+|*
+|* Beschreibung
+|* Ersterstellung 23.01.96 KA
+|* Letzte Aenderung 23.01.96 KA
+|*
+*************************************************************************/
+
+XGradientStepCountItem::XGradientStepCountItem( SvStream& rIn ) :
+ SfxUInt16Item( XATTR_GRADIENTSTEPCOUNT, rIn )
+{
+}
+
+/*************************************************************************
+|*
+|* XGradientStepCountItem::Clone( SfxItemPool* pPool ) const
+|*
+|* Beschreibung
+|* Ersterstellung 23.01.96 KA
+|* Letzte Aenderung 23.01.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XGradientStepCountItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XGradientStepCountItem( *this );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XGradientStepCountItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 23.01.96 KA
+|* Letzte Aenderung 23.01.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XGradientStepCountItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XGradientStepCountItem( rIn );
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XGradientStepCountItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+// rText = XubString( ResId( RID_SVXSTR_GRADIENTSTEPCOUNT, DIALOG_MGR() ) );
+// rText += ": ";
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ rText += XubString( UniString::CreateFromInt32((USHORT) GetValue() ));
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+//------------------------------
+// class XFillBmpTileItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY( XFillBmpTileItem, SfxBoolItem );
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpTileItem::XFillBmpTileItem( BOOL bTile ) :
+ SfxBoolItem( XATTR_FILLBMP_TILE, bTile )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpTileItem::XFillBmpTileItem( SvStream& rIn ) :
+ SfxBoolItem( XATTR_FILLBMP_TILE, rIn )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpTileItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBmpTileItem( *this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpTileItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBmpTileItem( rIn );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxItemPresentation XFillBmpTileItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+//------------------------------
+// class XFillBmpTilePosItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY( XFillBmpPosItem, SfxEnumItem );
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpPosItem::XFillBmpPosItem( RECT_POINT eRP ) :
+ SfxEnumItem( XATTR_FILLBMP_POS, sal::static_int_cast< USHORT >( eRP ) )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpPosItem::XFillBmpPosItem( SvStream& rIn ) :
+ SfxEnumItem( XATTR_FILLBMP_POS, rIn )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpPosItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBmpPosItem( *this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpPosItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBmpPosItem( rIn );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxItemPresentation XFillBmpPosItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+/******************************************************************************
+|*
+|*
+|*
+\******************************************************************************/
+
+USHORT XFillBmpPosItem::GetValueCount() const
+{
+ return 9;
+}
+
+
+//------------------------------
+// class XFillBmpTileSizeXItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY( XFillBmpSizeXItem, SfxMetricItem );
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpSizeXItem::XFillBmpSizeXItem( long nSizeX ) :
+ SfxMetricItem( XATTR_FILLBMP_SIZEX, nSizeX )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpSizeXItem::XFillBmpSizeXItem( SvStream& rIn ) :
+ SfxMetricItem( XATTR_FILLBMP_SIZEX, rIn )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpSizeXItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBmpSizeXItem( *this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpSizeXItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBmpSizeXItem( rIn );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxItemPresentation XFillBmpSizeXItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Beschreibung
+|* Ersterstellung 05.11.96 KA
+|* Letzte Aenderung 05.11.96 KA
+|*
+\*************************************************************************/
+
+bool XFillBmpSizeXItem::HasMetrics() const
+{
+ return GetValue() > 0L;
+}
+
+
+//------------------------------
+// class XFillBmpTileSizeYItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY( XFillBmpSizeYItem, SfxMetricItem );
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpSizeYItem::XFillBmpSizeYItem( long nSizeY ) :
+ SfxMetricItem( XATTR_FILLBMP_SIZEY, nSizeY )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpSizeYItem::XFillBmpSizeYItem( SvStream& rIn ) :
+ SfxMetricItem( XATTR_FILLBMP_SIZEY, rIn )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpSizeYItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBmpSizeYItem( *this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpSizeYItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBmpSizeYItem( rIn );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxItemPresentation XFillBmpSizeYItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Beschreibung
+|* Ersterstellung 05.11.96 KA
+|* Letzte Aenderung 05.11.96 KA
+|*
+\*************************************************************************/
+
+bool XFillBmpSizeYItem::HasMetrics() const
+{
+ return GetValue() > 0L;
+}
+
+
+//------------------------------
+// class XFillBmpTileLogItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY( XFillBmpSizeLogItem, SfxBoolItem );
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpSizeLogItem::XFillBmpSizeLogItem( BOOL bLog ) :
+ SfxBoolItem( XATTR_FILLBMP_SIZELOG, bLog )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpSizeLogItem::XFillBmpSizeLogItem( SvStream& rIn ) :
+ SfxBoolItem( XATTR_FILLBMP_SIZELOG, rIn )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpSizeLogItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBmpSizeLogItem( *this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpSizeLogItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBmpSizeLogItem( rIn );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxItemPresentation XFillBmpSizeLogItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+//------------------------------
+// class XFillBmpTileOffXItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY( XFillBmpTileOffsetXItem, SfxUInt16Item );
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpTileOffsetXItem::XFillBmpTileOffsetXItem( USHORT nOffX ) :
+ SfxUInt16Item( XATTR_FILLBMP_TILEOFFSETX, nOffX )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpTileOffsetXItem::XFillBmpTileOffsetXItem( SvStream& rIn ) :
+ SfxUInt16Item( XATTR_FILLBMP_TILEOFFSETX, rIn )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpTileOffsetXItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBmpTileOffsetXItem( *this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpTileOffsetXItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBmpTileOffsetXItem( rIn );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxItemPresentation XFillBmpTileOffsetXItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+//------------------------------
+// class XFillBmpTileOffYItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY( XFillBmpTileOffsetYItem, SfxUInt16Item );
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpTileOffsetYItem::XFillBmpTileOffsetYItem( USHORT nOffY ) :
+ SfxUInt16Item( XATTR_FILLBMP_TILEOFFSETY, nOffY )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpTileOffsetYItem::XFillBmpTileOffsetYItem( SvStream& rIn ) :
+ SfxUInt16Item( XATTR_FILLBMP_TILEOFFSETY, rIn )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpTileOffsetYItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBmpTileOffsetYItem( *this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpTileOffsetYItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBmpTileOffsetYItem( rIn );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxItemPresentation XFillBmpTileOffsetYItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+//------------------------------
+// class XFillBmpStretchItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY( XFillBmpStretchItem, SfxBoolItem );
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpStretchItem::XFillBmpStretchItem( BOOL bStretch ) :
+ SfxBoolItem( XATTR_FILLBMP_STRETCH, bStretch )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+XFillBmpStretchItem::XFillBmpStretchItem( SvStream& rIn ) :
+ SfxBoolItem( XATTR_FILLBMP_STRETCH, rIn )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpStretchItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBmpStretchItem( *this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpStretchItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBmpStretchItem( rIn );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung 28.02.96 KA
+|* Letzte Aenderung 28.02.96 KA
+|*
+*************************************************************************/
+
+SfxItemPresentation XFillBmpStretchItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+//------------------------------
+// class XFillBmpTileOffPosXItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY( XFillBmpPosOffsetXItem, SfxUInt16Item );
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung KA 29.04.96
+|* Letzte Aenderung KA 29.04.96
+|*
+*************************************************************************/
+
+XFillBmpPosOffsetXItem::XFillBmpPosOffsetXItem( USHORT nOffPosX ) :
+ SfxUInt16Item( XATTR_FILLBMP_POSOFFSETX, nOffPosX )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung KA 29.04.96
+|* Letzte Aenderung KA 29.04.96
+|*
+*************************************************************************/
+
+XFillBmpPosOffsetXItem::XFillBmpPosOffsetXItem( SvStream& rIn ) :
+ SfxUInt16Item( XATTR_FILLBMP_POSOFFSETX, rIn )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung KA 29.04.96
+|* Letzte Aenderung KA 29.04.96
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpPosOffsetXItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBmpPosOffsetXItem( *this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung KA 29.04.96
+|* Letzte Aenderung KA 29.04.96
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpPosOffsetXItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBmpPosOffsetXItem( rIn );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung KA 29.04.96
+|* Letzte Aenderung KA 29.04.96
+|*
+*************************************************************************/
+
+SfxItemPresentation XFillBmpPosOffsetXItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+//------------------------------
+// class XFillBmpTileOffPosYItem
+//------------------------------
+TYPEINIT1_AUTOFACTORY( XFillBmpPosOffsetYItem, SfxUInt16Item );
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung KA 29.04.96
+|* Letzte Aenderung KA 29.04.96
+|*
+*************************************************************************/
+
+XFillBmpPosOffsetYItem::XFillBmpPosOffsetYItem( USHORT nOffPosY ) :
+ SfxUInt16Item( XATTR_FILLBMP_POSOFFSETY, nOffPosY )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung KA 29.04.96
+|* Letzte Aenderung KA 29.04.96
+|*
+*************************************************************************/
+
+XFillBmpPosOffsetYItem::XFillBmpPosOffsetYItem( SvStream& rIn ) :
+ SfxUInt16Item( XATTR_FILLBMP_POSOFFSETY, rIn )
+{
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung KA 29.04.96
+|* Letzte Aenderung KA 29.04.96
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpPosOffsetYItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBmpPosOffsetYItem( *this );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung KA 29.04.96
+|* Letzte Aenderung KA 29.04.96
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBmpPosOffsetYItem::Create( SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBmpPosOffsetYItem( rIn );
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+|* Beschreibung
+|* Ersterstellung KA 29.04.96
+|* Letzte Aenderung KA 29.04.96
+|*
+*************************************************************************/
+
+SfxItemPresentation XFillBmpPosOffsetYItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ rText.Erase();
+
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+//--------------------------
+// class XFillBackgroundItem
+//--------------------------
+TYPEINIT1_AUTOFACTORY(XFillBackgroundItem, SfxBoolItem);
+
+/*************************************************************************
+|*
+|* XFillBackgroundItem::XFillBackgroundItem( BOOL )
+|*
+|* Beschreibung
+|* Ersterstellung 19.11.96 KA
+|* Letzte Aenderung
+|*
+*************************************************************************/
+
+XFillBackgroundItem::XFillBackgroundItem( BOOL bFill ) :
+ SfxBoolItem( XATTR_FILLBACKGROUND, bFill )
+{
+}
+
+/*************************************************************************
+|*
+|* XFillBackgroundItem::XFillBackgroundItem( SvStream& rIn )
+|*
+|* Beschreibung
+|* Ersterstellung 23.01.96 KA
+|* Letzte Aenderung 23.01.96 KA
+|*
+*************************************************************************/
+
+XFillBackgroundItem::XFillBackgroundItem( SvStream& rIn ) :
+ SfxBoolItem( XATTR_FILLBACKGROUND, rIn )
+{
+}
+
+/*************************************************************************
+|*
+|* XFillBackgroundItem::Clone( SfxItemPool* pPool ) const
+|*
+|* Beschreibung
+|* Ersterstellung 23.01.96 KA
+|* Letzte Aenderung 23.01.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBackgroundItem::Clone( SfxItemPool* /*pPool*/) const
+{
+ return new XFillBackgroundItem( *this );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFillBackgroundItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 23.01.96 KA
+|* Letzte Aenderung 23.01.96 KA
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBackgroundItem::Create(SvStream& rIn, USHORT /*nVer*/) const
+{
+ return new XFillBackgroundItem( rIn );
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XFillBackgroundItem::GetPresentation( SfxItemPresentation ePres, SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/, XubString& rText, const IntlWrapper*) const
+{
+ rText.Erase();
+
+ switch( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ return ePres;
+
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
new file mode 100644
index 000000000000..d625a248ca33
--- /dev/null
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -0,0 +1,897 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/graphic/XGraphic.hpp>
+#include <tools/stream.hxx>
+#include <vcl/window.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/bitmapex.hxx>
+#include <toolkit/unohlp.hxx>
+#include <svl/style.hxx>
+#include <editeng/memberids.hrc>
+
+#include <svx/dialogs.hrc>
+#include "xattr.hxx"
+#include <svx/xtable.hxx>
+#include <svx/xdef.hxx>
+#include <svx/unomid.hxx>
+#include <editeng/unoprnms.hxx>
+
+#include "unoapi.hxx"
+#include <svx/svdmodel.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#define GLOBALOVERFLOW
+
+using namespace ::com::sun::star;
+
+// ---------------
+// class XOBitmap
+// ---------------
+
+/*************************************************************************
+|*
+|* XOBitmap::XOBitmap()
+|*
+|* Beschreibung
+|* Ersterstellung 27.07.95
+|* Letzte Aenderung 27.07.95
+|*
+*************************************************************************/
+
+XOBitmap::XOBitmap() :
+ eType ( XBITMAP_NONE ),
+ eStyle ( XBITMAP_STRETCH ),
+ pPixelArray ( NULL ),
+ bGraphicDirty ( FALSE )
+{
+}
+
+/*************************************************************************
+|*
+|* XOBitmap::XOBitmap( Bitmap aBitmap, XBitmapStyle eStyle = XBITMAP_TILE )
+|*
+|* Beschreibung
+|* Ersterstellung 26.07.95
+|* Letzte Aenderung 26.07.95
+|*
+*************************************************************************/
+
+XOBitmap::XOBitmap( const Bitmap& rBmp, XBitmapStyle eInStyle ) :
+ eType ( XBITMAP_IMPORT ),
+ eStyle ( eInStyle ),
+ aGraphicObject ( rBmp ),
+ pPixelArray ( NULL ),
+ bGraphicDirty ( FALSE )
+{
+}
+
+/*************************************************************************
+|*
+|* XOBitmap::XOBitmap( Bitmap aBitmap, XBitmapStyle eStyle = XBITMAP_TILE )
+|*
+|* Beschreibung
+|* Ersterstellung 26.07.95
+|* Letzte Aenderung 26.07.95
+|*
+*************************************************************************/
+
+XOBitmap::XOBitmap( const GraphicObject& rGraphicObject, XBitmapStyle eInStyle ) :
+ eType ( XBITMAP_IMPORT ),
+ eStyle ( eInStyle ),
+ aGraphicObject ( rGraphicObject ),
+ pPixelArray ( NULL ),
+ bGraphicDirty ( FALSE )
+{
+}
+
+/*************************************************************************
+|*
+|* XOBitmap::XOBitmap( USHORT* pArray, const Color& aPixelColor,
+|* const Color& aBckgrColor, const Size& rSize = Size( 8, 8 ),
+|* XBitmapStyle eStyle = XBITMAP_TILE )
+|*
+|* Beschreibung
+|* Ersterstellung 26.07.95
+|* Letzte Aenderung 26.07.95
+|*
+*************************************************************************/
+
+XOBitmap::XOBitmap( const USHORT* pArray, const Color& rPixelColor,
+ const Color& rBckgrColor, const Size& rSize,
+ XBitmapStyle eInStyle ) :
+ eStyle ( eInStyle ),
+ pPixelArray ( NULL ),
+ aArraySize ( rSize ),
+ aPixelColor ( rPixelColor ),
+ aBckgrColor ( rBckgrColor ),
+ bGraphicDirty ( TRUE )
+
+{
+ if( aArraySize.Width() == 8 && aArraySize.Height() == 8 )
+ {
+ eType = XBITMAP_8X8;
+ pPixelArray = new USHORT[ 64 ];
+
+ for( USHORT i = 0; i < 64; i++ )
+ *( pPixelArray + i ) = *( pArray + i );
+ }
+ else
+ {
+ DBG_ASSERT( 0, "Nicht unterstuetzte Bitmapgroesse" );
+ }
+}
+
+/*************************************************************************
+|*
+|* XOBitmap::XOBitmap( const XOBitmap& rXBmp )
+|*
+|* Beschreibung
+|* Ersterstellung 27.07.95
+|* Letzte Aenderung 27.07.95
+|*
+*************************************************************************/
+
+XOBitmap::XOBitmap( const XOBitmap& rXBmp ) :
+ pPixelArray ( NULL )
+{
+ eType = rXBmp.eType;
+ eStyle = rXBmp.eStyle;
+ aGraphicObject = rXBmp.aGraphicObject;
+ aArraySize = rXBmp.aArraySize;
+ aPixelColor = rXBmp.aPixelColor;
+ aBckgrColor = rXBmp.aBckgrColor;
+ bGraphicDirty = rXBmp.bGraphicDirty;
+
+ if( rXBmp.pPixelArray )
+ {
+ if( eType == XBITMAP_8X8 )
+ {
+ pPixelArray = new USHORT[ 64 ];
+
+ for( USHORT i = 0; i < 64; i++ )
+ *( pPixelArray + i ) = *( rXBmp.pPixelArray + i );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* XOBitmap::XOBitmap( Bitmap aBitmap, XBitmapStyle eStyle = XBITMAP_TILE )
+|*
+|* Beschreibung
+|* Ersterstellung 26.07.95
+|* Letzte Aenderung 26.07.95
+|*
+*************************************************************************/
+
+XOBitmap::~XOBitmap()
+{
+ if( pPixelArray )
+ delete []pPixelArray;
+}
+
+/*************************************************************************
+|*
+|* XOBitmap& XOBitmap::operator=( const XOBitmap& rXBmp )
+|*
+|* Beschreibung
+|* Ersterstellung 27.07.95
+|* Letzte Aenderung 27.07.95
+|*
+*************************************************************************/
+
+XOBitmap& XOBitmap::operator=( const XOBitmap& rXBmp )
+{
+ eType = rXBmp.eType;
+ eStyle = rXBmp.eStyle;
+ aGraphicObject = rXBmp.aGraphicObject;
+ aArraySize = rXBmp.aArraySize;
+ aPixelColor = rXBmp.aPixelColor;
+ aBckgrColor = rXBmp.aBckgrColor;
+ bGraphicDirty = rXBmp.bGraphicDirty;
+
+ if( rXBmp.pPixelArray )
+ {
+ if( eType == XBITMAP_8X8 )
+ {
+ pPixelArray = new USHORT[ 64 ];
+
+ for( USHORT i = 0; i < 64; i++ )
+ *( pPixelArray + i ) = *( rXBmp.pPixelArray + i );
+ }
+ }
+ return( *this );
+}
+
+/*************************************************************************
+|*
+|* int XOBitmap::operator==( const XOBitmap& rXOBitmap ) const
+|*
+|* Beschreibung
+|* Ersterstellung 26.07.95
+|* Letzte Aenderung 26.07.95
+|*
+*************************************************************************/
+
+int XOBitmap::operator==( const XOBitmap& rXOBitmap ) const
+{
+ if( eType != rXOBitmap.eType ||
+ eStyle != rXOBitmap.eStyle ||
+ aGraphicObject != rXOBitmap.aGraphicObject ||
+ aArraySize != rXOBitmap.aArraySize ||
+ aPixelColor != rXOBitmap.aPixelColor ||
+ aBckgrColor != rXOBitmap.aBckgrColor ||
+ bGraphicDirty != rXOBitmap.bGraphicDirty )
+ {
+ return( FALSE );
+ }
+
+ if( pPixelArray && rXOBitmap.pPixelArray )
+ {
+ USHORT nCount = (USHORT) ( aArraySize.Width() * aArraySize.Height() );
+ for( USHORT i = 0; i < nCount; i++ )
+ {
+ if( *( pPixelArray + i ) != *( rXOBitmap.pPixelArray + i ) )
+ return( FALSE );
+ }
+ }
+ return( TRUE );
+}
+
+/*************************************************************************
+|*
+|* void SetPixelArray( const USHORT* pArray )
+|*
+|* Beschreibung
+|* Ersterstellung 27.07.95
+|* Letzte Aenderung 27.07.95
+|*
+*************************************************************************/
+
+void XOBitmap::SetPixelArray( const USHORT* pArray )
+{
+ if( eType == XBITMAP_8X8 )
+ {
+ if( pPixelArray )
+ delete []pPixelArray;
+
+ pPixelArray = new USHORT[ 64 ];
+
+ for( USHORT i = 0; i < 64; i++ )
+ *( pPixelArray + i ) = *( pArray + i );
+
+ bGraphicDirty = TRUE;
+ }
+ else
+ {
+ DBG_ASSERT( 0, "Nicht unterstuetzter Bitmaptyp" );
+ }
+}
+
+/*************************************************************************
+|*
+|* Bitmap XOBitmap::GetBitmap()
+|*
+|* Beschreibung
+|* Ersterstellung 26.07.95
+|* Letzte Aenderung 26.07.95
+|*
+*************************************************************************/
+
+Bitmap XOBitmap::GetBitmap() const
+{
+ return GetGraphicObject().GetGraphic().GetBitmap();
+}
+
+/*************************************************************************
+|*
+|* Bitmap XOBitmap::GetGraphicObject()
+|*
+|* Beschreibung
+|* Ersterstellung
+|* Letzte Aenderung
+|*
+*************************************************************************/
+
+const GraphicObject& XOBitmap::GetGraphicObject() const
+{
+ if( bGraphicDirty )
+ ( (XOBitmap*) this )->Array2Bitmap();
+
+ return aGraphicObject;
+}
+
+/*************************************************************************
+|*
+|* void XOBitmap::Bitmap2Array()
+|*
+|* Beschreibung Umwandlung der Bitmap in Array, Hinter- u.
+|* Vordergrundfarbe
+|* Ersterstellung 27.07.95
+|* Letzte Aenderung 27.07.95
+|*
+*************************************************************************/
+
+void XOBitmap::Bitmap2Array()
+{
+ VirtualDevice aVD;
+ BOOL bPixelColor = FALSE;
+ const Bitmap aBitmap( GetBitmap() );
+ const USHORT nLines = 8; // von Type abhaengig
+
+ if( !pPixelArray )
+ pPixelArray = new USHORT[ nLines * nLines ];
+
+ aVD.SetOutputSizePixel( aBitmap.GetSizePixel() );
+ aVD.DrawBitmap( Point(), aBitmap );
+ aPixelColor = aBckgrColor = aVD.GetPixel( Point() );
+
+ // Aufbau des Arrays und Ermittlung der Vorder-, bzw.
+ // Hintergrundfarbe
+ for( USHORT i = 0; i < nLines; i++ )
+ {
+ for( USHORT j = 0; j < nLines; j++ )
+ {
+ if ( aVD.GetPixel( Point( j, i ) ) == aBckgrColor )
+ *( pPixelArray + j + i * nLines ) = 0;
+ else
+ {
+ *( pPixelArray + j + i * nLines ) = 1;
+ if( !bPixelColor )
+ {
+ aPixelColor = aVD.GetPixel( Point( j, i ) );
+ bPixelColor = TRUE;
+ }
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* void XOBitmap::Array2Bitmap()
+|*
+|* Beschreibung Umwandlung des Arrays, Hinter- u.
+|* Vordergrundfarbe in eine Bitmap
+|* Ersterstellung 27.07.95
+|* Letzte Aenderung 27.07.95
+|*
+*************************************************************************/
+
+void XOBitmap::Array2Bitmap()
+{
+ VirtualDevice aVD;
+ USHORT nLines = 8; // von Type abhaengig
+
+ if( !pPixelArray )
+ return;
+
+ aVD.SetOutputSizePixel( Size( nLines, nLines ) );
+
+ // Aufbau der Bitmap
+ for( USHORT i = 0; i < nLines; i++ )
+ {
+ for( USHORT j = 0; j < nLines; j++ )
+ {
+ if( *( pPixelArray + j + i * nLines ) == 0 )
+ aVD.DrawPixel( Point( j, i ), aBckgrColor );
+ else
+ aVD.DrawPixel( Point( j, i ), aPixelColor );
+ }
+ }
+
+ aGraphicObject = GraphicObject( aVD.GetBitmap( Point(), Size( nLines, nLines ) ) );
+ bGraphicDirty = FALSE;
+}
+
+// -----------------------
+// class XFillBitmapItem
+// -----------------------
+TYPEINIT1_AUTOFACTORY(XFillBitmapItem, NameOrIndex);
+
+/*************************************************************************
+|*
+|* XFillBitmapItem::XFillBitmapItem(long nIndex,
+|* const Bitmap& rTheBitmap)
+|*
+|* Beschreibung
+|* Ersterstellung 17.11.94
+|* Letzte Aenderung 17.11.94
+|*
+*************************************************************************/
+
+XFillBitmapItem::XFillBitmapItem(long nIndex,
+ const XOBitmap& rTheBitmap) :
+ NameOrIndex( XATTR_FILLBITMAP, nIndex ),
+ aXOBitmap( rTheBitmap )
+{
+}
+
+/*************************************************************************
+|*
+|* XFillBitmapItem::XFillBitmapItem(const XubString& rName,
+|* const Bitmap& rTheBitmap)
+|*
+|* Beschreibung
+|* Ersterstellung 17.11.94
+|* Letzte Aenderung 17.11.94
+|*
+*************************************************************************/
+
+XFillBitmapItem::XFillBitmapItem(const XubString& rName,
+ const XOBitmap& rTheBitmap) :
+ NameOrIndex( XATTR_FILLBITMAP, rName ),
+ aXOBitmap( rTheBitmap )
+{
+}
+
+/*************************************************************************
+|*
+|* XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem)
+|*
+|* Beschreibung
+|* Ersterstellung 17.11.94
+|* Letzte Aenderung 17.11.94
+|*
+*************************************************************************/
+
+XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem) :
+ NameOrIndex( rItem ),
+ aXOBitmap( rItem.aXOBitmap )
+{
+}
+
+/*************************************************************************
+|*
+|* XFillBitmapItem::XFillBitmapItem(SvStream& rIn)
+|*
+|* Beschreibung
+|* Ersterstellung 17.11.94
+|* Letzte Aenderung 26.07.94
+|*
+*************************************************************************/
+
+XFillBitmapItem::XFillBitmapItem( SvStream& rIn, USHORT nVer ) :
+ NameOrIndex( XATTR_FILLBITMAP, rIn )
+{
+ if( nVer == 0 )
+ {
+ if (!IsIndex())
+ {
+ // Behandlung der alten Bitmaps
+ Bitmap aBmp;
+
+ rIn >> aBmp;
+
+ aXOBitmap.SetBitmap( aBmp );
+ aXOBitmap.SetBitmapStyle( XBITMAP_TILE );
+
+ if( aBmp.GetSizePixel().Width() == 8 &&
+ aBmp.GetSizePixel().Height() == 8 )
+ {
+ aXOBitmap.SetBitmapType( XBITMAP_8X8 );
+ aXOBitmap.Bitmap2Array();
+ }
+ else
+ aXOBitmap.SetBitmapType( XBITMAP_IMPORT );
+ }
+ }
+ else if( nVer == 1 )
+ {
+ if (!IsIndex())
+ {
+ INT16 iTmp;
+ rIn >> iTmp;
+ aXOBitmap.SetBitmapStyle( (XBitmapStyle) iTmp );
+ rIn >> iTmp;
+ aXOBitmap.SetBitmapType( (XBitmapType) iTmp );
+
+ if( aXOBitmap.GetBitmapType() == XBITMAP_IMPORT )
+ {
+ Bitmap aBmp;
+ rIn >> aBmp;
+ aXOBitmap.SetBitmap( aBmp );
+ }
+ else if( aXOBitmap.GetBitmapType() == XBITMAP_8X8 )
+ {
+ USHORT* pArray = new USHORT[ 64 ];
+ Color aColor;
+
+ for( USHORT i = 0; i < 64; i++ )
+ rIn >> *( pArray + i );
+ aXOBitmap.SetPixelArray( pArray );
+
+ rIn >> aColor;
+ aXOBitmap.SetPixelColor( aColor );
+ rIn >> aColor;
+ aXOBitmap.SetBackgroundColor( aColor );
+
+ delete []pArray;
+ }
+ }
+ }
+
+ // #81908# force bitmap to exist
+ aXOBitmap.GetBitmap();
+}
+
+//*************************************************************************
+
+XFillBitmapItem::XFillBitmapItem( SfxItemPool* /*pPool*/, const XOBitmap& rTheBitmap )
+: NameOrIndex( XATTR_FILLBITMAP, -1 ),
+ aXOBitmap( rTheBitmap )
+{
+}
+
+//*************************************************************************
+
+XFillBitmapItem::XFillBitmapItem( SfxItemPool* /*pPool*/)
+: NameOrIndex(XATTR_FILLBITMAP, -1 )
+{
+}
+
+/*************************************************************************
+|*
+|* XFillBitmapItem::Clone(SfxItemPool* pPool) const
+|*
+|* Beschreibung
+|* Ersterstellung 17.11.94
+|* Letzte Aenderung 17.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBitmapItem::Clone(SfxItemPool* /*pPool*/) const
+{
+ return new XFillBitmapItem(*this);
+}
+
+/*************************************************************************
+|*
+|* int XFillBitmapItem::operator==(const SfxPoolItem& rItem) const
+|*
+|* Beschreibung
+|* Ersterstellung 17.11.94
+|* Letzte Aenderung 26.07.95
+|*
+*************************************************************************/
+
+int XFillBitmapItem::operator==(const SfxPoolItem& rItem) const
+{
+ return ( NameOrIndex::operator==(rItem) &&
+ aXOBitmap == ((const XFillBitmapItem&) rItem).aXOBitmap );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, USHORT nVer) const
+|*
+|* Beschreibung
+|* Ersterstellung 17.11.94
+|* Letzte Aenderung 17.11.94
+|*
+*************************************************************************/
+
+SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, USHORT nVer) const
+{
+ return new XFillBitmapItem( rIn, nVer );
+}
+
+/*************************************************************************
+|*
+|* SfxPoolItem* XFillBitmapItem::Store(SvStream& rOut) const
+|*
+|* Beschreibung
+|* Ersterstellung 17.11.94
+|* Letzte Aenderung 26.07.94
+|*
+*************************************************************************/
+
+SvStream& XFillBitmapItem::Store( SvStream& rOut, USHORT nItemVersion ) const
+{
+ NameOrIndex::Store( rOut, nItemVersion );
+
+ if (!IsIndex())
+ {
+ rOut << (INT16) aXOBitmap.GetBitmapStyle();
+ if( !aXOBitmap.GetBitmap() )
+ rOut << (INT16) XBITMAP_NONE;
+ else
+ {
+ rOut << (INT16) aXOBitmap.GetBitmapType();
+ if( aXOBitmap.GetBitmapType() == XBITMAP_IMPORT )
+ {
+ const USHORT nOldComprMode = rOut.GetCompressMode();
+ USHORT nNewComprMode = nOldComprMode;
+
+ if( rOut.GetVersion() >= SOFFICE_FILEFORMAT_50 )
+ nNewComprMode |= COMPRESSMODE_ZBITMAP;
+ else
+ nNewComprMode &= ~COMPRESSMODE_ZBITMAP;
+
+ rOut.SetCompressMode( nNewComprMode );
+ rOut << aXOBitmap.GetBitmap();
+ rOut.SetCompressMode( nOldComprMode );
+ }
+ else if( aXOBitmap.GetBitmapType() == XBITMAP_8X8 )
+ {
+ USHORT* pArray = aXOBitmap.GetPixelArray();
+ for( USHORT i = 0; i < 64; i++ )
+ rOut << (USHORT) *( pArray + i );
+
+ rOut << aXOBitmap.GetPixelColor();
+ rOut << aXOBitmap.GetBackgroundColor();
+ }
+ }
+ }
+
+ return rOut;
+}
+
+/*************************************************************************
+|*
+|* const Bitmap& XFillBitmapItem::GetValue(const XBitmapTable* pTable) const
+|*
+|* Beschreibung
+|* Ersterstellung 15.11.94
+|* Letzte Aenderung 26.07.94
+|*
+*************************************************************************/
+
+const XOBitmap& XFillBitmapItem::GetBitmapValue(const XBitmapTable* pTable) const // GetValue -> GetBitmapValue
+{
+ if (!IsIndex())
+ return aXOBitmap;
+ else
+ return pTable->GetBitmap(GetIndex())->GetXBitmap();
+}
+
+
+/*************************************************************************
+|*
+|* USHORT XFillBitmapItem::GetVersion() const
+|*
+|* Beschreibung
+|* Ersterstellung 26.07.95
+|* Letzte Aenderung 26.07.95
+|*
+*************************************************************************/
+
+USHORT XFillBitmapItem::GetVersion( USHORT /*nFileFormatVersion*/) const
+{
+ // 2. Version
+ return( 1 );
+}
+
+//------------------------------------------------------------------------
+
+SfxItemPresentation XFillBitmapItem::GetPresentation
+(
+ SfxItemPresentation ePres,
+ SfxMapUnit /*eCoreUnit*/,
+ SfxMapUnit /*ePresUnit*/,
+ XubString& rText, const IntlWrapper *
+) const
+{
+ switch ( ePres )
+ {
+ case SFX_ITEM_PRESENTATION_NONE:
+ rText.Erase();
+ return ePres;
+ case SFX_ITEM_PRESENTATION_NAMELESS:
+ case SFX_ITEM_PRESENTATION_COMPLETE:
+ rText += GetName();
+ return ePres;
+ default:
+ return SFX_ITEM_PRESENTATION_NONE;
+ }
+}
+
+//------------------------------------------------------------------------
+
+bool XFillBitmapItem::QueryValue( ::com::sun::star::uno::Any& rVal, BYTE nMemberId ) const
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ // needed for MID_NAME
+ ::rtl::OUString aApiName;
+ // needed for complete item (MID 0)
+ ::rtl::OUString aInternalName;
+
+ ::rtl::OUString aURL;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp;
+
+ if( nMemberId == MID_NAME )
+ {
+ SvxUnogetApiNameForItem( Which(), GetName(), aApiName );
+ }
+ else if( nMemberId == 0 )
+ {
+ aInternalName = GetName();
+ }
+
+ if( nMemberId == MID_GRAFURL ||
+ nMemberId == 0 )
+ {
+ XOBitmap aLocalXOBitmap( GetBitmapValue() );
+ aURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(UNO_NAME_GRAPHOBJ_URLPREFIX));
+ aURL += ::rtl::OUString::createFromAscii( aLocalXOBitmap.GetGraphicObject().GetUniqueID().GetBuffer() );
+ }
+ if( nMemberId == MID_BITMAP ||
+ nMemberId == 0 )
+ {
+ XOBitmap aLocalXOBitmap( GetBitmapValue() );
+ Bitmap aBmp( aLocalXOBitmap.GetBitmap() );
+ BitmapEx aBmpEx( aBmp );
+
+ xBmp.set( VCLUnoHelper::CreateBitmap( aBmpEx ) );
+ }
+
+ if( nMemberId == MID_NAME )
+ rVal <<= aApiName;
+ else if( nMemberId == MID_GRAFURL )
+ rVal <<= aURL;
+ else if( nMemberId == MID_BITMAP )
+ rVal <<= xBmp;
+ else
+ {
+ // member-id 0 => complete item (e.g. for toolbars)
+ DBG_ASSERT( nMemberId == 0, "invalid member-id" );
+ uno::Sequence< beans::PropertyValue > aPropSeq( 3 );
+
+ aPropSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ));
+ aPropSeq[0].Value = uno::makeAny( aInternalName );
+ aPropSeq[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillBitmapURL" ));
+ aPropSeq[1].Value = uno::makeAny( aURL );
+ aPropSeq[2].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Bitmap" ));
+ aPropSeq[2].Value = uno::makeAny( xBmp );
+
+ rVal <<= aPropSeq;
+ }
+
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+bool XFillBitmapItem::PutValue( const ::com::sun::star::uno::Any& rVal, BYTE nMemberId )
+{
+// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
+ nMemberId &= ~CONVERT_TWIPS;
+
+ ::rtl::OUString aName;
+ ::rtl::OUString aURL;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBmp;
+ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > xGraphic;
+
+ bool bSetName = false;
+ bool bSetURL = false;
+ bool bSetBitmap = false;
+
+ if( nMemberId == MID_NAME )
+ bSetName = (rVal >>= aName);
+ else if( nMemberId == MID_GRAFURL )
+ bSetURL = (rVal >>= aURL);
+ else if( nMemberId == MID_BITMAP )
+ {
+ bSetBitmap = (rVal >>= xBmp);
+ if ( !bSetBitmap )
+ bSetBitmap = (rVal >>= xGraphic );
+ }
+ else
+ {
+ DBG_ASSERT( nMemberId == 0, "invalid member-id" );
+ uno::Sequence< beans::PropertyValue > aPropSeq;
+ if( rVal >>= aPropSeq )
+ {
+ for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ )
+ {
+ if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Name" )))
+ bSetName = (aPropSeq[n].Value >>= aName);
+ else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FillBitmapURL" )))
+ bSetURL = (aPropSeq[n].Value >>= aURL);
+ else if( aPropSeq[n].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Bitmap" )))
+ bSetBitmap = (aPropSeq[n].Value >>= xBmp);
+ }
+ }
+ }
+
+ if( bSetName )
+ {
+ SetName( aName );
+ }
+ if( bSetURL )
+ {
+ GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) );
+ XOBitmap aBMP( aGrafObj );
+ SetBitmapValue( aBMP );
+ }
+ if( bSetBitmap )
+ {
+ Bitmap aInput;
+ if ( xBmp.is() )
+ {
+ BitmapEx aInputEx( VCLUnoHelper::GetBitmap( xBmp ) );
+ aInput = aInputEx.GetBitmap();
+ }
+ else if ( xGraphic.is() )
+ {
+ Graphic aGraphic( xGraphic );
+ aInput = aGraphic.GetBitmap();
+ }
+
+ // note: aXOBitmap is the member bitmap
+ aXOBitmap.SetBitmap( aInput );
+ aXOBitmap.SetBitmapType(XBITMAP_IMPORT);
+
+ if(aInput.GetSizePixel().Width() == 8
+ && aInput.GetSizePixel().Height() == 8
+ && aInput.GetColorCount() == 2)
+ {
+ aXOBitmap.Bitmap2Array();
+ aXOBitmap.SetBitmapType(XBITMAP_8X8);
+ aXOBitmap.SetPixelSize(aInput.GetSizePixel());
+ }
+ }
+
+ return (bSetName || bSetURL || bSetBitmap);
+}
+
+BOOL XFillBitmapItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
+{
+ return ((XFillBitmapItem*)p1)->GetBitmapValue().GetGraphicObject().GetUniqueID() ==
+ ((XFillBitmapItem*)p2)->GetBitmapValue().GetGraphicObject().GetUniqueID();
+}
+
+XFillBitmapItem* XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const
+{
+ if( pModel )
+ {
+ const String aUniqueName = NameOrIndex::CheckNamedItem( this,
+ XATTR_FILLBITMAP,
+ &pModel->GetItemPool(),
+ pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : NULL,
+ XFillBitmapItem::CompareValueFunc,
+ RID_SVXSTR_BMP21,
+ pModel->GetBitmapList() );
+
+ // if the given name is not valid, replace it!
+ if( aUniqueName != GetName() )
+ {
+ return new XFillBitmapItem( aUniqueName, aXOBitmap );
+ }
+ }
+
+ return (XFillBitmapItem*)this;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xexch.cxx b/svx/source/xoutdev/xexch.cxx
new file mode 100644
index 000000000000..5335967f3732
--- /dev/null
+++ b/svx/source/xoutdev/xexch.cxx
@@ -0,0 +1,203 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#include <sot/formats.hxx>
+#include <tools/vcompat.hxx>
+#include <svx/xflasit.hxx>
+#include <svx/xfillit0.hxx>
+#include <svl/itempool.hxx>
+#include <svl/whiter.hxx>
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
+#include <svx/xdef.hxx>
+#include "xexch.hxx"
+
+
+TYPEINIT1_AUTOFACTORY( XFillExchangeData, SvDataCopyStream );
+
+
+/*************************************************************************
+|*
+|* Default-Ctor (Fuer Assign())
+|*
+*************************************************************************/
+XFillExchangeData::XFillExchangeData() :
+ pXFillAttrSetItem( NULL ),
+ pPool( NULL )
+{
+}
+
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+*************************************************************************/
+XFillExchangeData::XFillExchangeData( const XFillAttrSetItem rXFillAttrSetItem ) :
+ pXFillAttrSetItem( (XFillAttrSetItem*) rXFillAttrSetItem.Clone( rXFillAttrSetItem.GetItemSet().GetPool() ) ),
+ pPool( rXFillAttrSetItem.GetItemSet().GetPool() )
+{
+}
+
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+*************************************************************************/
+XFillExchangeData::~XFillExchangeData()
+{
+ delete pXFillAttrSetItem;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+*************************************************************************/
+ULONG XFillExchangeData::RegisterClipboardFormatName()
+{
+ return( SOT_FORMATSTR_ID_XFA );
+}
+
+/******************************************************************************
+|*
+|* Binaer-Export (z.Z. ohne Versionsverwaltung, da nicht persistent!)
+|*
+\******************************************************************************/
+
+SvStream& operator<<( SvStream& rOStm, const XFillExchangeData& rData )
+{
+ if( rData.pXFillAttrSetItem )
+ {
+ SfxWhichIter aIter( rData.pXFillAttrSetItem->GetItemSet() );
+ USHORT nWhich = aIter.FirstWhich();
+ const SfxPoolItem* pItem;
+ sal_uInt32 nItemCount = 0;
+ sal_Size nFirstPos = rOStm.Tell();
+
+ rOStm << nItemCount;
+
+ while( nWhich )
+ {
+ if( SFX_ITEM_SET == rData.pXFillAttrSetItem->GetItemSet().GetItemState( nWhich, FALSE, &pItem ) )
+ {
+ VersionCompat aCompat( rOStm, STREAM_WRITE );
+ const USHORT nItemVersion2 = pItem->GetVersion( (USHORT) rOStm.GetVersion() );
+
+ rOStm << nWhich << nItemVersion2;
+ pItem->Store( rOStm, nItemVersion2 );
+
+ nItemCount++;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+
+ const ULONG nLastPos = rOStm.Tell();
+ rOStm.Seek( nFirstPos );
+ rOStm << nItemCount;
+ rOStm.Seek( nLastPos );
+ }
+
+ return rOStm;
+}
+
+
+/******************************************************************************
+|*
+|* Binaer-Import (z.Z. ohne Versionsverwaltung, da nicht persistent!)
+|*
+\******************************************************************************/
+
+SvStream& operator>>( SvStream& rIStm, XFillExchangeData& rData )
+{
+ DBG_ASSERT( rData.pPool, "XFillExchangeData has no pool" );
+
+ SfxItemSet* pSet = new SfxItemSet ( *rData.pPool, XATTR_FILL_FIRST, XATTR_FILL_LAST );
+ SfxPoolItem* pNewItem;
+ sal_uInt32 nItemCount = 0;
+ USHORT nWhich, nItemVersion;
+
+ rIStm >> nItemCount;
+
+ if( nItemCount > ( XATTR_FILL_LAST - XATTR_FILL_FIRST + 1 ) )
+ nItemCount = ( XATTR_FILL_LAST - XATTR_FILL_FIRST + 1 );
+
+ for( sal_uInt32 i = 0; i < nItemCount; i++ )
+ {
+ VersionCompat aCompat( rIStm, STREAM_READ );
+
+ rIStm >> nWhich >> nItemVersion;
+
+ if( nWhich )
+ {
+ pNewItem = rData.pPool->GetDefaultItem( nWhich ).Create( rIStm, nItemVersion );
+
+ if( pNewItem )
+ {
+ pSet->Put( *pNewItem );
+ delete pNewItem;
+ }
+ }
+ }
+
+ delete rData.pXFillAttrSetItem;
+ rData.pXFillAttrSetItem = new XFillAttrSetItem( pSet );
+ rData.pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool();
+
+ return rIStm;
+}
+
+/*************************************************************************
+|*
+|* XBitmap& XBitmap::operator=( const XBitmap& rXBmp )
+|*
+*************************************************************************/
+
+XFillExchangeData& XFillExchangeData::operator=( const XFillExchangeData& rData )
+{
+ delete pXFillAttrSetItem;
+
+ if( rData.pXFillAttrSetItem )
+ pXFillAttrSetItem = (XFillAttrSetItem*) rData.pXFillAttrSetItem->Clone( pPool = rData.pXFillAttrSetItem->GetItemSet().GetPool() );
+ else
+ {
+ pPool = NULL;
+ pXFillAttrSetItem = NULL;
+ }
+
+ return( *this );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xpool.cxx b/svx/source/xoutdev/xpool.cxx
new file mode 100644
index 000000000000..36abdb07cf34
--- /dev/null
+++ b/svx/source/xoutdev/xpool.cxx
@@ -0,0 +1,238 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/xtable.hxx>
+#include "xattr.hxx"
+#include <svx/xpool.hxx>
+#include <svx/svdattr.hxx>
+#include <svx/svxids.hrc>
+#include <svl/itemset.hxx>
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+XOutdevItemPool::XOutdevItemPool(
+ SfxItemPool* _pMaster,
+ sal_uInt16 nAttrStart,
+ sal_uInt16 nAttrEnd,
+ sal_Bool bLoadRefCounts)
+: SfxItemPool(String("XOutdevItemPool", gsl_getSystemTextEncoding()), nAttrStart, nAttrEnd, 0L, 0L, bLoadRefCounts)
+{
+ // prepare some defaults
+ const XubString aNullStr;
+ const Bitmap aNullBmp;
+ const basegfx::B2DPolyPolygon aNullPol;
+ const Color aNullLineCol(RGB_Color(COL_BLACK));
+ const Color aNullFillCol(RGB_Color(COL_DEFAULT_SHAPE_FILLING)); // "Blue 8"
+ const Color aNullShadowCol(RGB_Color(COL_LIGHTGRAY));
+ const XDash aNullDash;
+ const XGradient aNullGrad(aNullLineCol, RGB_Color(COL_WHITE));
+ const XHatch aNullHatch(aNullLineCol);
+
+ // get master pointer, evtl. add myself to the end of the pools
+ if(!_pMaster)
+ {
+ _pMaster = this;
+ }
+ else
+ {
+ SfxItemPool* pParent = _pMaster;
+
+ while(pParent->GetSecondaryPool())
+ {
+ pParent = pParent->GetSecondaryPool();
+ }
+
+ pParent->SetSecondaryPool(this);
+ }
+
+ // prepare PoolDefaults
+ mppLocalPoolDefaults = new SfxPoolItem*[GetLastWhich() - GetFirstWhich() + 1];
+
+ mppLocalPoolDefaults[XATTR_LINESTYLE -XATTR_START] = new XLineStyleItem;
+ mppLocalPoolDefaults[XATTR_LINEDASH -XATTR_START] = new XLineDashItem(this,aNullDash);
+ mppLocalPoolDefaults[XATTR_LINEWIDTH -XATTR_START] = new XLineWidthItem;
+ mppLocalPoolDefaults[XATTR_LINECOLOR -XATTR_START] = new XLineColorItem(aNullStr,aNullLineCol);
+ mppLocalPoolDefaults[XATTR_LINESTART -XATTR_START] = new XLineStartItem(this,aNullPol);
+ mppLocalPoolDefaults[XATTR_LINEEND -XATTR_START] = new XLineEndItem (this,aNullPol);
+ mppLocalPoolDefaults[XATTR_LINESTARTWIDTH -XATTR_START] = new XLineStartWidthItem;
+ mppLocalPoolDefaults[XATTR_LINEENDWIDTH -XATTR_START] = new XLineEndWidthItem;
+ mppLocalPoolDefaults[XATTR_LINESTARTCENTER -XATTR_START] = new XLineStartCenterItem;
+ mppLocalPoolDefaults[XATTR_LINEENDCENTER -XATTR_START] = new XLineEndCenterItem;
+ mppLocalPoolDefaults[XATTR_LINETRANSPARENCE -XATTR_START] = new XLineTransparenceItem;
+ mppLocalPoolDefaults[XATTR_LINEJOINT -XATTR_START] = new XLineJointItem;
+ mppLocalPoolDefaults[XATTR_FILLSTYLE -XATTR_START] = new XFillStyleItem;
+ mppLocalPoolDefaults[XATTR_FILLCOLOR -XATTR_START] = new XFillColorItem (aNullStr,aNullFillCol);
+ mppLocalPoolDefaults[XATTR_FILLGRADIENT -XATTR_START] = new XFillGradientItem(this,aNullGrad);
+ mppLocalPoolDefaults[XATTR_FILLHATCH -XATTR_START] = new XFillHatchItem (this,aNullHatch);
+ mppLocalPoolDefaults[XATTR_FILLBITMAP -XATTR_START] = new XFillBitmapItem (this,aNullBmp);
+ mppLocalPoolDefaults[XATTR_FILLTRANSPARENCE -XATTR_START] = new XFillTransparenceItem;
+ mppLocalPoolDefaults[XATTR_GRADIENTSTEPCOUNT -XATTR_START] = new XGradientStepCountItem;
+ mppLocalPoolDefaults[XATTR_FILLBMP_TILE -XATTR_START] = new XFillBmpTileItem;
+ mppLocalPoolDefaults[XATTR_FILLBMP_POS -XATTR_START] = new XFillBmpPosItem;
+ mppLocalPoolDefaults[XATTR_FILLBMP_SIZEX -XATTR_START] = new XFillBmpSizeXItem;
+ mppLocalPoolDefaults[XATTR_FILLBMP_SIZEY -XATTR_START] = new XFillBmpSizeYItem;
+ mppLocalPoolDefaults[XATTR_FILLBMP_SIZELOG -XATTR_START] = new XFillBmpSizeLogItem;
+ mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETX -XATTR_START] = new XFillBmpTileOffsetXItem;
+ mppLocalPoolDefaults[XATTR_FILLBMP_TILEOFFSETY -XATTR_START] = new XFillBmpTileOffsetYItem;
+ mppLocalPoolDefaults[XATTR_FILLBMP_STRETCH -XATTR_START] = new XFillBmpStretchItem;
+ mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETX -XATTR_START] = new XFillBmpPosOffsetXItem;
+ mppLocalPoolDefaults[XATTR_FILLBMP_POSOFFSETY -XATTR_START] = new XFillBmpPosOffsetYItem;
+ mppLocalPoolDefaults[XATTR_FILLFLOATTRANSPARENCE -XATTR_START] = new XFillFloatTransparenceItem( this, aNullGrad, FALSE );
+ mppLocalPoolDefaults[XATTR_SECONDARYFILLCOLOR -XATTR_START] = new XSecondaryFillColorItem(aNullStr, aNullFillCol);
+ mppLocalPoolDefaults[XATTR_FILLBACKGROUND -XATTR_START] = new XFillBackgroundItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTSTYLE -XATTR_START] = new XFormTextStyleItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTADJUST -XATTR_START] = new XFormTextAdjustItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTDISTANCE -XATTR_START] = new XFormTextDistanceItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTSTART -XATTR_START] = new XFormTextStartItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTMIRROR -XATTR_START] = new XFormTextMirrorItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTOUTLINE -XATTR_START] = new XFormTextOutlineItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTSHADOW -XATTR_START] = new XFormTextShadowItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTSHDWCOLOR -XATTR_START] = new XFormTextShadowColorItem(aNullStr,aNullShadowCol);
+ mppLocalPoolDefaults[XATTR_FORMTXTSHDWXVAL -XATTR_START] = new XFormTextShadowXValItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTSHDWYVAL -XATTR_START] = new XFormTextShadowYValItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTSTDFORM -XATTR_START] = new XFormTextStdFormItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTHIDEFORM -XATTR_START] = new XFormTextHideFormItem;
+ mppLocalPoolDefaults[XATTR_FORMTXTSHDWTRANSP -XATTR_START] = new XFormTextShadowTranspItem;
+
+ // create SetItems
+ SfxItemSet* pSet=new SfxItemSet(*_pMaster, XATTR_LINE_FIRST, XATTR_LINE_LAST);
+ mppLocalPoolDefaults[XATTRSET_LINE - XATTR_START] = new XLineAttrSetItem(pSet);
+ pSet=new SfxItemSet(*_pMaster, XATTR_FILL_FIRST, XATTR_FILL_LAST);
+ mppLocalPoolDefaults[XATTRSET_FILL - XATTR_START] = new XFillAttrSetItem(pSet);
+
+ // create ItemInfos
+ mpLocalItemInfos = new SfxItemInfo[GetLastWhich() - GetFirstWhich() + 1];
+ for(sal_uInt16 i(GetFirstWhich()); i <= GetLastWhich(); i++)
+ {
+ mpLocalItemInfos[i - XATTR_START]._nSID = 0;
+ mpLocalItemInfos[i - XATTR_START]._nFlags = SFX_ITEM_POOLABLE;
+ }
+
+ mpLocalItemInfos[XATTR_LINESTYLE -XATTR_START]._nSID = SID_ATTR_LINE_STYLE;
+ mpLocalItemInfos[XATTR_LINEDASH -XATTR_START]._nSID = SID_ATTR_LINE_DASH;
+ mpLocalItemInfos[XATTR_LINEWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_WIDTH;
+ mpLocalItemInfos[XATTR_LINECOLOR -XATTR_START]._nSID = SID_ATTR_LINE_COLOR;
+ mpLocalItemInfos[XATTR_LINESTART -XATTR_START]._nSID = SID_ATTR_LINE_START;
+ mpLocalItemInfos[XATTR_LINEEND -XATTR_START]._nSID = SID_ATTR_LINE_END;
+ mpLocalItemInfos[XATTR_LINESTARTWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_STARTWIDTH;
+ mpLocalItemInfos[XATTR_LINEENDWIDTH -XATTR_START]._nSID = SID_ATTR_LINE_ENDWIDTH;
+ mpLocalItemInfos[XATTR_LINESTARTCENTER -XATTR_START]._nSID = SID_ATTR_LINE_STARTCENTER;
+ mpLocalItemInfos[XATTR_LINEENDCENTER -XATTR_START]._nSID = SID_ATTR_LINE_ENDCENTER;
+ mpLocalItemInfos[XATTR_FILLSTYLE -XATTR_START]._nSID = SID_ATTR_FILL_STYLE;
+ mpLocalItemInfos[XATTR_FILLCOLOR -XATTR_START]._nSID = SID_ATTR_FILL_COLOR;
+ mpLocalItemInfos[XATTR_FILLGRADIENT -XATTR_START]._nSID = SID_ATTR_FILL_GRADIENT;
+ mpLocalItemInfos[XATTR_FILLHATCH -XATTR_START]._nSID = SID_ATTR_FILL_HATCH;
+ mpLocalItemInfos[XATTR_FILLBITMAP -XATTR_START]._nSID = SID_ATTR_FILL_BITMAP;
+ mpLocalItemInfos[XATTR_FORMTXTSTYLE -XATTR_START]._nSID = SID_FORMTEXT_STYLE;
+ mpLocalItemInfos[XATTR_FORMTXTADJUST -XATTR_START]._nSID = SID_FORMTEXT_ADJUST;
+ mpLocalItemInfos[XATTR_FORMTXTDISTANCE -XATTR_START]._nSID = SID_FORMTEXT_DISTANCE;
+ mpLocalItemInfos[XATTR_FORMTXTSTART -XATTR_START]._nSID = SID_FORMTEXT_START;
+ mpLocalItemInfos[XATTR_FORMTXTMIRROR -XATTR_START]._nSID = SID_FORMTEXT_MIRROR;
+ mpLocalItemInfos[XATTR_FORMTXTOUTLINE -XATTR_START]._nSID = SID_FORMTEXT_OUTLINE;
+ mpLocalItemInfos[XATTR_FORMTXTSHADOW -XATTR_START]._nSID = SID_FORMTEXT_SHADOW;
+ mpLocalItemInfos[XATTR_FORMTXTSHDWCOLOR -XATTR_START]._nSID = SID_FORMTEXT_SHDWCOLOR;
+ mpLocalItemInfos[XATTR_FORMTXTSHDWXVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWXVAL;
+ mpLocalItemInfos[XATTR_FORMTXTSHDWYVAL -XATTR_START]._nSID = SID_FORMTEXT_SHDWYVAL;
+ mpLocalItemInfos[XATTR_FORMTXTSTDFORM -XATTR_START]._nSID = SID_FORMTEXT_STDFORM;
+ mpLocalItemInfos[XATTR_FORMTXTHIDEFORM -XATTR_START]._nSID = SID_FORMTEXT_HIDEFORM;
+
+ // if it's my own creation level, set Defaults and ItemInfos
+ if(XATTR_START == GetFirstWhich() && XATTR_END == GetLastWhich())
+ {
+ SetDefaults(mppLocalPoolDefaults);
+ SetItemInfos(mpLocalItemInfos);
+ }
+}
+
+/*************************************************************************
+|*
+|* copy ctor, sorgt dafuer, dass die static defaults gecloned werden
+|* (Parameter 2 = TRUE)
+|*
+\************************************************************************/
+
+XOutdevItemPool::XOutdevItemPool(const XOutdevItemPool& rPool)
+: SfxItemPool(rPool, TRUE),
+ mppLocalPoolDefaults(0L),
+ mpLocalItemInfos(0L)
+{
+}
+
+/*************************************************************************
+|*
+|* Clone()
+|*
+\************************************************************************/
+
+SfxItemPool* XOutdevItemPool::Clone() const
+{
+ return new XOutdevItemPool(*this);
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+XOutdevItemPool::~XOutdevItemPool()
+{
+ Delete();
+
+ // remove own static defaults
+ if(mppLocalPoolDefaults)
+ {
+ SfxPoolItem** ppDefaultItem = mppLocalPoolDefaults;
+ for(sal_uInt16 i(GetLastWhich() - GetFirstWhich() + 1); i; --i, ++ppDefaultItem)
+ {
+ if ( *ppDefaultItem ) //Teile schon von abgel. Klasse abgeraeumt!
+ {
+ SetRefCount( **ppDefaultItem, 0 );
+ delete *ppDefaultItem;
+ }
+ }
+
+ delete[] mppLocalPoolDefaults;
+ }
+
+ if(mpLocalItemInfos)
+ {
+ delete[] mpLocalItemInfos;
+ }
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xtabbtmp.cxx b/svx/source/xoutdev/xtabbtmp.cxx
new file mode 100644
index 000000000000..83145d7a5288
--- /dev/null
+++ b/svx/source/xoutdev/xtabbtmp.cxx
@@ -0,0 +1,297 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#ifndef SVX_LIGHT
+
+#include <com/sun/star/container/XNameContainer.hpp>
+#include "XPropertyTable.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+
+#include "xmlxtexp.hxx"
+#include "xmlxtimp.hxx"
+
+#endif
+
+#include <tools/urlobj.hxx>
+#include <vcl/virdev.hxx>
+#include <svl/itemset.hxx>
+#include <sfx2/docfile.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <svx/xtable.hxx>
+#include <svx/xpool.hxx>
+
+#define GLOBALOVERFLOW
+
+using namespace com::sun::star;
+using namespace rtl;
+
+sal_Unicode const pszExtBitmap[] = {'s','o','b'};
+
+static char const aChckBitmap[] = { 0x04, 0x00, 'S','O','B','L'}; // very old
+static char const aChckBitmap0[] = { 0x04, 0x00, 'S','O','B','0'}; // old
+static char const aChckBitmap1[] = { 0x04, 0x00, 'S','O','B','1'}; // = 5.2
+static char const aChckXML[] = { 'P', 'K', 0x03, 0x04 }; // = 6.0
+
+// -------------------
+// class XBitmapTable
+// -------------------
+
+/*************************************************************************
+|*
+|* XBitmapTable::XBitmapTable()
+|*
+*************************************************************************/
+
+XBitmapTable::XBitmapTable( const String& rPath,
+ XOutdevItemPool* pInPool,
+ USHORT nInitSize, USHORT nReSize ) :
+ XPropertyTable( rPath, pInPool, nInitSize, nReSize)
+{
+ pBmpTable = new Table( nInitSize, nReSize );
+}
+
+/************************************************************************/
+
+XBitmapTable::~XBitmapTable()
+{
+}
+
+/************************************************************************/
+
+XBitmapEntry* XBitmapTable::Replace(long nIndex, XBitmapEntry* pEntry )
+{
+ return (XBitmapEntry*) XPropertyTable::Replace(nIndex, pEntry);
+}
+
+/************************************************************************/
+
+XBitmapEntry* XBitmapTable::Remove(long nIndex)
+{
+ return (XBitmapEntry*) XPropertyTable::Remove(nIndex, 0);
+}
+
+/************************************************************************/
+
+XBitmapEntry* XBitmapTable::GetBitmap(long nIndex) const
+{
+ return (XBitmapEntry*) XPropertyTable::Get(nIndex, 0);
+}
+
+/************************************************************************/
+
+BOOL XBitmapTable::Load()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XBitmapTable::Save()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XBitmapTable::Create()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XBitmapTable::CreateBitmapsForUI()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+Bitmap* XBitmapTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/)
+{
+ return( NULL );
+}
+
+// ------------------
+// class XBitmapList
+// ------------------
+
+/*************************************************************************
+|*
+|* XBitmapList::XBitmapList()
+|*
+*************************************************************************/
+
+XBitmapList::XBitmapList( const String& rPath,
+ XOutdevItemPool* pInPool,
+ USHORT nInitSize, USHORT nReSize ) :
+ XPropertyList( rPath, pInPool, nInitSize, nReSize)
+{
+ // pBmpList = new List( nInitSize, nReSize );
+}
+
+/************************************************************************/
+
+XBitmapList::~XBitmapList()
+{
+}
+
+/************************************************************************/
+
+XBitmapEntry* XBitmapList::Replace(XBitmapEntry* pEntry, long nIndex )
+{
+ return (XBitmapEntry*) XPropertyList::Replace(pEntry, nIndex);
+}
+
+/************************************************************************/
+
+XBitmapEntry* XBitmapList::Remove(long nIndex)
+{
+ return (XBitmapEntry*) XPropertyList::Remove(nIndex, 0);
+}
+
+/************************************************************************/
+
+XBitmapEntry* XBitmapList::GetBitmap(long nIndex) const
+{
+ return (XBitmapEntry*) XPropertyList::Get(nIndex, 0);
+}
+
+/************************************************************************/
+
+BOOL XBitmapList::Load()
+{
+ if( bListDirty )
+ {
+ bListDirty = FALSE;
+
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+ }
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XBitmapList::Save()
+{
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+}
+
+/************************************************************************/
+// Umgestellt am 27.07.95 auf XBitmap
+
+BOOL XBitmapList::Create()
+{
+ // Array der Bitmap
+ //-----------------------
+ // 00 01 02 03 04 05 06 07
+ // 08 09 10 11 12 13 14 15
+ // 16 17 18 19 20 21 22 23
+ // 24 25 26 27 28 29 30 31
+ // 32 33 34 35 36 37 38 39
+ // 40 41 42 43 44 45 46 47
+ // 48 49 50 51 52 53 54 55
+ // 56 57 58 59 60 61 62 63
+
+ String aStr( SVX_RES( RID_SVXSTR_BITMAP ) );
+ Color aColWhite( RGB_Color( COL_WHITE ) );
+ xub_StrLen nLen;
+ USHORT aArray[64];
+
+ memset( aArray, 0, sizeof( aArray ) );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert( new XBitmapEntry( XOBitmap( aArray, aColWhite, aColWhite ), aStr ) );
+
+ aArray[ 0] = 1; aArray[ 9] = 1; aArray[18] = 1; aArray[27] = 1;
+ aArray[36] = 1; aArray[45] = 1; aArray[54] = 1; aArray[63] = 1;
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_BLACK ), aColWhite ), aStr ) );
+
+ aArray[ 7] = 1; aArray[14] = 1; aArray[21] = 1; aArray[28] = 1;
+ aArray[35] = 1; aArray[42] = 1; aArray[49] = 1; aArray[56] = 1;
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_LIGHTRED ), aColWhite ), aStr ) );
+
+ aArray[24] = 1; aArray[25] = 1; aArray[26] = 1;
+ aArray[29] = 1; aArray[30] = 1; aArray[31] = 1;
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert( new XBitmapEntry( XOBitmap( aArray, RGB_Color( COL_LIGHTBLUE ), aColWhite ), aStr ) );
+
+ return( TRUE );
+}
+
+/************************************************************************/
+
+BOOL XBitmapList::CreateBitmapsForUI()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+Bitmap* XBitmapList::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/)
+{
+ return( NULL );
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xtabcolr.cxx b/svx/source/xoutdev/xtabcolr.cxx
new file mode 100644
index 000000000000..359c7434fe85
--- /dev/null
+++ b/svx/source/xoutdev/xtabcolr.cxx
@@ -0,0 +1,551 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#ifndef SVX_LIGHT
+
+#include <com/sun/star/container/XNameContainer.hpp>
+#include "XPropertyTable.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+
+#include <unotools/pathoptions.hxx>
+
+#include "xmlxtexp.hxx"
+#include "xmlxtimp.hxx"
+
+#endif
+
+#include <sfx2/docfile.hxx>
+#include <tools/urlobj.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <svx/xtable.hxx>
+#include <svx/xpool.hxx>
+
+#define GLOBALOVERFLOW
+
+using namespace com::sun::star;
+using namespace rtl;
+
+sal_Unicode const pszExtColor[] = {'s','o','c'};
+
+static char const aChckColor[] = { 0x04, 0x00, 'S','O','C','L'}; // < 5.2
+static char const aChckColor0[] = { 0x04, 0x00, 'S','O','C','0'}; // = 5.2
+static char const aChckXML[] = { '<', '?', 'x', 'm', 'l' }; // = 6.0
+
+// ------------------
+// class XColorTable
+// ------------------
+
+static XColorTable* pTable=0;
+
+/*************************************************************************
+|*
+|* XColorTable::XColorTable()
+|*
+*************************************************************************/
+
+XColorTable::XColorTable( const String& rPath,
+ XOutdevItemPool* pInPool,
+ USHORT nInitSize, USHORT nReSize ) :
+ XPropertyTable( rPath, pInPool, nInitSize, nReSize)
+{
+ // ColorTable braucht keine eigene BmpTable
+ // pBmpTable = new Table( nInitSize, nReSize );
+}
+
+/************************************************************************/
+
+XColorTable::~XColorTable()
+{
+}
+
+XColorTable* XColorTable::GetStdColorTable()
+{
+ if ( !pTable )
+ pTable = new XColorTable( SvtPathOptions().GetPalettePath() );
+ return pTable;
+}
+
+/************************************************************************/
+
+XColorEntry* XColorTable::Replace(long nIndex, XColorEntry* pEntry )
+{
+ return (XColorEntry*) XPropertyTable::Replace(nIndex, pEntry);
+}
+
+/************************************************************************/
+
+XColorEntry* XColorTable::Remove(long nIndex)
+{
+ return (XColorEntry*) XPropertyTable::Remove(nIndex, 0);
+}
+
+/************************************************************************/
+
+XColorEntry* XColorTable::GetColor(long nIndex) const
+{
+ return (XColorEntry*) XPropertyTable::Get(nIndex, 0);
+}
+
+/************************************************************************/
+
+BOOL XColorTable::Load()
+{
+ if( bTableDirty )
+ {
+ bTableDirty = FALSE;
+
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtColor, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXColorTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+ }
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XColorTable::Save()
+{
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtColor, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXColorTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+}
+
+/************************************************************************/
+
+BOOL XColorTable::Create()
+{
+ XubString aStr;
+ xub_StrLen nLen;
+ ResMgr& rRes = DIALOG_MGR();
+
+ static USHORT __READONLY_DATA aResId[] =
+ {
+ RID_SVXSTR_BLACK,
+ RID_SVXSTR_BLUE,
+ RID_SVXSTR_GREEN,
+ RID_SVXSTR_CYAN,
+ RID_SVXSTR_RED,
+ RID_SVXSTR_MAGENTA,
+ RID_SVXSTR_BROWN,
+ RID_SVXSTR_GREY,
+ RID_SVXSTR_LIGHTGREY,
+ RID_SVXSTR_LIGHTBLUE,
+ RID_SVXSTR_LIGHTGREEN,
+ RID_SVXSTR_LIGHTCYAN,
+ RID_SVXSTR_LIGHTRED,
+ RID_SVXSTR_LIGHTMAGENTA,
+ RID_SVXSTR_YELLOW,
+ RID_SVXSTR_WHITE
+ };
+
+ // MT: COL_XXX ist in VCL kein enum mehr!!!
+ // COL_WHITE ist seeeehr gross! ( => Zugriff ueber das obige Array hinweg )
+ // Mit der unteren Schleife gibt es keinen Absturtz, aber es ist
+ // alles schwarz, weil alles kleine Werte.
+ // Ausserdem ist die ganze Vorgehensweise laut MM sehr unperformant
+ // => lieber gleich Stringlisten laden.
+
+ // BM: ifndef VCL part removed (deprecated)
+
+ static ColorData __READONLY_DATA aColTab[] =
+ {
+ COL_BLACK,
+ COL_BLUE,
+ COL_GREEN,
+ COL_CYAN,
+ COL_RED,
+ COL_MAGENTA,
+ COL_BROWN,
+ COL_GRAY,
+ COL_LIGHTGRAY,
+ COL_LIGHTBLUE,
+ COL_LIGHTGREEN,
+ COL_LIGHTCYAN,
+ COL_LIGHTRED,
+ COL_LIGHTMAGENTA,
+ COL_YELLOW,
+ COL_WHITE
+ };
+
+ for( USHORT n = 0; n < 16; ++n )
+ {
+ Insert( n, new XColorEntry( Color( aColTab[n] ),
+ String( ResId( aResId[ n ], rRes )) ) );
+ }
+
+ aStr = SVX_RESSTR( RID_SVXSTR_GREY );
+ aStr.AppendAscii(" 80%");
+ nLen = aStr.Len() - 3;
+ Insert(16, new XColorEntry( Color( 51, 51, 51 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('7'));
+ Insert(17, new XColorEntry( Color( 76, 76, 76 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('6'));
+ Insert(18, new XColorEntry( Color(102,102,102 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert(19, new XColorEntry( Color(153,153,153 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(20, new XColorEntry( Color(179,179,179 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(21, new XColorEntry( Color(204,204,204 ), aStr ) );
+ // BM: new 15%
+ aStr.SetChar(nLen, sal_Unicode('1'));
+ aStr.SetChar(nLen + 1, sal_Unicode('5'));
+ Insert(22, new XColorEntry( Color(217,217,217 ), aStr ) );
+ aStr.SetChar(nLen + 1, sal_Unicode('0'));
+ Insert(23, new XColorEntry( Color(230,230,230 ), aStr ) );
+ Insert(24, new XColorEntry( Color(230,230,255 ), SVX_RESSTR( RID_SVXSTR_BLUEGREY ) ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_RED );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(25, new XColorEntry( Color(255, 51,102 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(26, new XColorEntry( Color(220, 35, 0 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(27, new XColorEntry( Color(184, 71, 0 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert(28, new XColorEntry( Color(255, 51, 51 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('5'));
+ Insert(29, new XColorEntry( Color(235, 97, 61 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('6'));
+ Insert(30, new XColorEntry( Color(184, 71, 71 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('7'));
+ Insert(31, new XColorEntry( Color(184, 0, 71 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('8'));
+ Insert(32, new XColorEntry( Color(153, 40, 76 ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_MAGENTA );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(33, new XColorEntry( Color(148, 0,107 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(34, new XColorEntry( Color(148, 71,107 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(35, new XColorEntry( Color(148, 71,148 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert(36, new XColorEntry( Color(153,102,204 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('5'));
+ Insert(37, new XColorEntry( Color(107, 71,148 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('6'));
+ Insert(38, new XColorEntry( Color(107, 35,148 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('7'));
+ Insert(39, new XColorEntry( Color(107, 0,148 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('8'));
+ Insert(40, new XColorEntry( Color( 94, 17,166 ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_BLUE );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(41, new XColorEntry( Color( 40, 0,153 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(42, new XColorEntry( Color( 71, 0,184 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(43, new XColorEntry( Color( 35, 0,220 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert(44, new XColorEntry( Color( 35, 35,220 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('5'));
+ Insert(45, new XColorEntry( Color( 0, 71,255 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('6'));
+ Insert(46, new XColorEntry( Color( 0,153,255 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('7'));
+ Insert(47, new XColorEntry( Color( 0,184,255 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('8'));
+ Insert(48, new XColorEntry( Color(153,204,255 ), aStr ) );
+ //Insert(48, new XColorEntry( Color( 46,215,255 ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_CYAN );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(49, new XColorEntry( Color( 0,220,255 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(50, new XColorEntry( Color( 0,204,204 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(51, new XColorEntry( Color( 35,184,220 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert(52, new XColorEntry( Color( 71,184,184 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('5'));
+ Insert(53, new XColorEntry( Color( 51,163,163 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('6'));
+ Insert(54, new XColorEntry( Color( 25,138,138 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('7'));
+ Insert(55, new XColorEntry( Color( 0,107,107 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('8'));
+ Insert(56, new XColorEntry( Color( 0, 74, 74 ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_GREEN );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(57, new XColorEntry( Color( 53, 94, 0 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(58, new XColorEntry( Color( 92,133, 38 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(59, new XColorEntry( Color(125,166, 71 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert(60, new XColorEntry( Color(148,189, 94 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('5'));
+ Insert(61, new XColorEntry( Color( 0,174, 0 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('6'));
+ Insert(62, new XColorEntry( Color( 51,204,102 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('7'));
+ Insert(63, new XColorEntry( Color( 61,235, 61 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('8'));
+ Insert(64, new XColorEntry( Color( 35,255, 35 ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_YELLOW );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(65, new XColorEntry( Color(230,255, 0 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(66, new XColorEntry( Color(255,255,153 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(67, new XColorEntry( Color(255,255,102 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert(68, new XColorEntry( Color(230,230, 76 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('5'));
+ Insert(69, new XColorEntry( Color(204,204, 0 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('6'));
+ Insert(70, new XColorEntry( Color(179,179, 0 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('7'));
+ Insert(71, new XColorEntry( Color(128,128, 25 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('8'));
+ Insert(72, new XColorEntry( Color(102,102, 0 ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_BROWN );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(73, new XColorEntry( Color( 76, 25, 0 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(74, new XColorEntry( Color(102, 51, 0 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(75, new XColorEntry( Color(128, 76, 25 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert(76, new XColorEntry( Color(153,102, 51 ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_ORANGE );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(77, new XColorEntry( Color(204,102, 51 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(78, new XColorEntry( Color(255,102, 51 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(79, new XColorEntry( Color(255,153,102 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert(80, new XColorEntry( Color(255,204,153 ), aStr ) );
+
+ // new chart colors
+ aStr = SVX_RESSTR( RID_SVXSTR_VIOLET );
+ Insert( 81, new XColorEntry( Color( 0x99, 0x99, 0xff ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_BORDEAUX );
+ Insert( 82, new XColorEntry( Color( 0x99, 0x33, 0x66 ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_PALE_YELLOW );
+ Insert( 83, new XColorEntry( Color( 0xff, 0xff, 0xcc ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_PALE_GREEN );
+ Insert( 84, new XColorEntry( Color( 0xcc, 0xff, 0xff ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_DKVIOLET );
+ Insert( 85, new XColorEntry( Color( 0x66, 0x00, 0x66 ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_SALMON );
+ Insert( 86, new XColorEntry( Color( 0xff, 0x80, 0x80 ), aStr ) );
+
+ aStr = SVX_RESSTR( RID_SVXSTR_SEABLUE );
+ Insert( 87, new XColorEntry( Color( 0x00, 0x66, 0xcc ), aStr ) );
+
+ // Sun colors
+ aStr = SVX_RESSTR( RID_SVXSTR_COLOR_SUN );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert( 88, new XColorEntry( Color( 0x33, 0x33, 0x66 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert( 89, new XColorEntry( Color( 0x66, 0x66, 0x99 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert( 90, new XColorEntry( Color( 0x99, 0x99, 0xcc ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert( 91, new XColorEntry( Color( 0xcc, 0xcc, 0xff ), aStr ) );
+
+ // Chart default colors
+ aStr = SVX_RESSTR( RID_SVXSTR_COLOR_CHART );
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert( 92, new XColorEntry( Color( 0x00, 0x45, 0x86 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert( 93, new XColorEntry( Color( 0xff, 0x42, 0x0e ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert( 94, new XColorEntry( Color( 0xff, 0xd3, 0x20 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert( 95, new XColorEntry( Color( 0x57, 0x9d, 0x1c ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('5'));
+ Insert( 96, new XColorEntry( Color( 0x7e, 0x00, 0x21 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('6'));
+ Insert( 97, new XColorEntry( Color( 0x83, 0xca, 0xff ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('7'));
+ Insert( 98, new XColorEntry( Color( 0x31, 0x40, 0x04 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('8'));
+ Insert( 99, new XColorEntry( Color( 0xae, 0xcf, 0x00 ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('9'));
+ Insert( 100, new XColorEntry( Color( 0x4b, 0x1f, 0x6f ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('1'));
+ aStr.AppendAscii("0");
+ nLen = aStr.Len() - 1;
+ Insert( 101, new XColorEntry( Color( 0xff, 0x95, 0x0e ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('1'));
+ Insert( 102, new XColorEntry( Color( 0xc5, 0x00, 0x0b ), aStr ) );
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert( 103, new XColorEntry( Color( 0x00, 0x84, 0xd1 ), aStr ) );
+
+ return( Count() == 104 );
+}
+
+/************************************************************************/
+
+BOOL XColorTable::CreateBitmapsForUI()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+Bitmap* XColorTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/)
+{
+ return( NULL );
+}
+
+// --------------------
+// class XColorList
+// --------------------
+
+/*************************************************************************
+|*
+|* XColorList::XColorList()
+|*
+*************************************************************************/
+
+XColorList::XColorList( const String& rPath,
+ XOutdevItemPool* pInPool,
+ USHORT nInitSize, USHORT nReSize ) :
+ XPropertyList( rPath, pInPool, nInitSize, nReSize)
+{
+ // pBmpList = new List( nInitSize, nReSize );
+}
+
+/************************************************************************/
+
+XColorList::~XColorList()
+{
+}
+
+/************************************************************************/
+
+XColorEntry* XColorList::Replace(XColorEntry* pEntry, long nIndex )
+{
+ return (XColorEntry*) XPropertyList::Replace(pEntry, nIndex);
+}
+
+/************************************************************************/
+
+XColorEntry* XColorList::Remove(long nIndex)
+{
+ return (XColorEntry*) XPropertyList::Remove(nIndex, 0);
+}
+
+/************************************************************************/
+
+XColorEntry* XColorList::GetColor(long nIndex) const
+{
+ return (XColorEntry*) XPropertyList::Get(nIndex, 0);
+}
+
+/************************************************************************/
+
+BOOL XColorList::Load()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XColorList::Save()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XColorList::Create()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XColorList::CreateBitmapsForUI()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+Bitmap* XColorList::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/)
+{
+ return( NULL );
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx
new file mode 100644
index 000000000000..db11b5b07124
--- /dev/null
+++ b/svx/source/xoutdev/xtabdash.cxx
@@ -0,0 +1,381 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#ifndef SVX_LIGHT
+
+#include <com/sun/star/container/XNameContainer.hpp>
+#include "XPropertyTable.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+
+#include "xmlxtexp.hxx"
+#include "xmlxtimp.hxx"
+
+#endif
+#include <vcl/svapp.hxx>
+
+#include <tools/urlobj.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/window.hxx>
+#include <svl/itemset.hxx>
+#include <sfx2/docfile.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <svx/xtable.hxx>
+#include <svx/xpool.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xflclit.hxx>
+
+#include <svx/svdorect.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+
+using namespace com::sun::star;
+using namespace rtl;
+
+#define GLOBALOVERFLOW
+
+sal_Unicode const pszExtDash[] = {'s','o','d'};
+char const aChckDash[] = { 0x04, 0x00, 'S','O','D','L'}; // < 5.2
+char const aChckDash0[] = { 0x04, 0x00, 'S','O','D','0'}; // = 5.2
+char const aChckXML[] = { '<', '?', 'x', 'm', 'l' }; // = 6.0
+
+// -----------------
+// class XDashTable
+// -----------------
+
+/*************************************************************************
+|*
+|* XDashTable::XDashTable()
+|*
+*************************************************************************/
+
+XDashTable::XDashTable( const String& rPath,
+ XOutdevItemPool* pInPool,
+ USHORT nInitSize, USHORT nReSize ) :
+ XPropertyTable( rPath, pInPool, nInitSize, nReSize)
+{
+ pBmpTable = new Table( nInitSize, nReSize );
+}
+
+/************************************************************************/
+
+XDashTable::~XDashTable()
+{
+}
+
+/************************************************************************/
+
+XDashEntry* XDashTable::Replace(long nIndex, XDashEntry* pEntry )
+{
+ return (XDashEntry*) XPropertyTable::Replace(nIndex, pEntry);
+}
+
+/************************************************************************/
+
+XDashEntry* XDashTable::Remove(long nIndex)
+{
+ return (XDashEntry*) XPropertyTable::Remove(nIndex, 0);
+}
+
+/************************************************************************/
+
+XDashEntry* XDashTable::GetDash(long nIndex) const
+{
+ return (XDashEntry*) XPropertyTable::Get(nIndex, 0);
+}
+
+/************************************************************************/
+
+BOOL XDashTable::Load()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XDashTable::Save()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XDashTable::Create()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XDashTable::CreateBitmapsForUI()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+Bitmap* XDashTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/)
+{
+ return( NULL );
+}
+
+// ----------------
+// class XDashList
+// ----------------
+
+class impXDashList
+{
+private:
+ VirtualDevice* mpVirtualDevice;
+ SdrModel* mpSdrModel;
+ SdrObject* mpBackgroundObject;
+ SdrObject* mpLineObject;
+
+public:
+ impXDashList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB, SdrObject* pL)
+ : mpVirtualDevice(pV),
+ mpSdrModel(pM),
+ mpBackgroundObject(pB),
+ mpLineObject(pL)
+ {}
+
+ ~impXDashList()
+ {
+ delete mpVirtualDevice;
+ SdrObject::Free(mpBackgroundObject);
+ SdrObject::Free(mpLineObject);
+ delete mpSdrModel;
+ }
+
+ VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; }
+ SdrObject* getBackgroundObject() const { return mpBackgroundObject; }
+ SdrObject* getLineObject() const { return mpLineObject; }
+};
+
+void XDashList::impCreate()
+{
+ if(!mpData)
+ {
+ const Point aZero(0, 0);
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ VirtualDevice* pVirDev = new VirtualDevice;
+ OSL_ENSURE(0 != pVirDev, "XDashList: no VirtualDevice created!" );
+ pVirDev->SetMapMode(MAP_100TH_MM);
+ const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH * 2, BITMAP_HEIGHT)));
+ pVirDev->SetOutputSize(aSize);
+ pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode()
+ ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
+ : DRAWMODE_DEFAULT);
+
+ SdrModel* pSdrModel = new SdrModel();
+ OSL_ENSURE(0 != pSdrModel, "XDashList: no SdrModel created!" );
+ pSdrModel->GetItemPool().FreezeIdRanges();
+
+ const Rectangle aBackgroundSize(aZero, aSize);
+ SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize);
+ OSL_ENSURE(0 != pBackgroundObject, "XDashList: no BackgroundObject created!" );
+ pBackgroundObject->SetModel(pSdrModel);
+ pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_SOLID));
+ pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pBackgroundObject->SetMergedItem(XFillColorItem(String(), rStyleSettings.GetFieldColor()));
+
+ const basegfx::B2DPoint aStart(0, aSize.Height() / 2);
+ const basegfx::B2DPoint aEnd(aSize.Width(), aSize.Height() / 2);
+ basegfx::B2DPolygon aPolygon;
+ aPolygon.append(aStart);
+ aPolygon.append(aEnd);
+ SdrObject* pLineObject = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygon));
+ OSL_ENSURE(0 != pLineObject, "XDashList: no LineObject created!" );
+ pLineObject->SetModel(pSdrModel);
+ pLineObject->SetMergedItem(XLineStyleItem(XLINE_DASH));
+ pLineObject->SetMergedItem(XLineColorItem(String(), rStyleSettings.GetFieldTextColor()));
+ pLineObject->SetMergedItem(XLineWidthItem(30));
+
+ mpData = new impXDashList(pVirDev, pSdrModel, pBackgroundObject, pLineObject);
+ OSL_ENSURE(0 != mpData, "XDashList: data creation went wrong!" );
+ }
+}
+
+void XDashList::impDestroy()
+{
+ if(mpData)
+ {
+ delete mpData;
+ mpData = 0;
+ }
+}
+
+XDashList::XDashList(const String& rPath, XOutdevItemPool* pInPool, sal_uInt16 nInitSize, sal_uInt16 nReSize)
+: XPropertyList(rPath, pInPool, nInitSize, nReSize),
+ mpData(0)
+{
+ pBmpList = new List(nInitSize, nReSize);
+}
+
+XDashList::~XDashList()
+{
+ impDestroy();
+}
+
+XDashEntry* XDashList::Replace(XDashEntry* pEntry, long nIndex )
+{
+ return (XDashEntry*) XPropertyList::Replace(pEntry, nIndex);
+}
+
+XDashEntry* XDashList::Remove(long nIndex)
+{
+ return (XDashEntry*) XPropertyList::Remove(nIndex, 0);
+}
+
+XDashEntry* XDashList::GetDash(long nIndex) const
+{
+ return (XDashEntry*) XPropertyList::Get(nIndex, 0);
+}
+
+BOOL XDashList::Load()
+{
+ if( bListDirty )
+ {
+ bListDirty = FALSE;
+
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtDash, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXDashTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+ }
+ return( FALSE );
+}
+
+BOOL XDashList::Save()
+{
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtDash, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXDashTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+}
+
+BOOL XDashList::Create()
+{
+ XubString aStr( SVX_RES( RID_SVXSTR_LINESTYLE ) );
+ xub_StrLen nLen;
+
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(new XDashEntry(XDash(XDASH_RECT,1, 50,1, 50, 50),aStr));
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(new XDashEntry(XDash(XDASH_RECT,1,500,1,500,500),aStr));
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(new XDashEntry(XDash(XDASH_RECT,2, 50,3,250,120),aStr));
+
+ return( TRUE );
+}
+
+BOOL XDashList::CreateBitmapsForUI()
+{
+ impCreate();
+
+ for( long i = 0; i < Count(); i++)
+ {
+ Bitmap* pBmp = CreateBitmapForUI( i, FALSE );
+ DBG_ASSERT( pBmp, "XDashList: Bitmap(UI) konnte nicht erzeugt werden!" );
+
+ if( pBmp )
+ pBmpList->Insert( pBmp, i );
+ }
+
+ impDestroy();
+
+ return( TRUE );
+}
+
+Bitmap* XDashList::CreateBitmapForUI( long nIndex, BOOL bDelete )
+{
+ impCreate();
+ VirtualDevice* pVD = mpData->getVirtualDevice();
+ SdrObject* pLine = mpData->getLineObject();
+
+ pLine->SetMergedItem(XLineStyleItem(XLINE_DASH));
+ pLine->SetMergedItem(XLineDashItem(String(), GetDash(nIndex)->GetDash()));
+
+ sdr::contact::SdrObjectVector aObjectVector;
+ aObjectVector.push_back(mpData->getBackgroundObject());
+ aObjectVector.push_back(pLine);
+ sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0);
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ aPainter.ProcessDisplay(aDisplayInfo);
+
+ const Point aZero(0, 0);
+ Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize()));
+
+ if(bDelete)
+ {
+ impDestroy();
+ }
+
+ return pBitmap;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx
new file mode 100644
index 000000000000..d58b8a9a7600
--- /dev/null
+++ b/svx/source/xoutdev/xtabgrdt.cxx
@@ -0,0 +1,375 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#ifndef SVX_LIGHT
+
+#include <com/sun/star/container/XNameContainer.hpp>
+#include "XPropertyTable.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+
+#include "xmlxtexp.hxx"
+#include "xmlxtimp.hxx"
+
+#endif
+
+#include <tools/urlobj.hxx>
+#include <vcl/virdev.hxx>
+#include <svl/itemset.hxx>
+#include <sfx2/docfile.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <svx/xtable.hxx>
+#include <svx/xpool.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflgrit.hxx>
+
+#include <svx/svdorect.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xgrscit.hxx>
+
+#define GLOBALOVERFLOW
+
+using namespace com::sun::star;
+using namespace rtl;
+
+sal_Unicode const pszExtGradient[] = {'s','o','g'};
+
+char const aChckGradient[] = { 0x04, 0x00, 'S','O','G','L'}; // < 5.2
+char const aChckGradient0[] = { 0x04, 0x00, 'S','O','G','0'}; // = 5.2
+char const aChckXML[] = { '<', '?', 'x', 'm', 'l' }; // = 6.0
+
+// ---------------------
+// class XGradientTable
+// ---------------------
+
+/*************************************************************************
+|*
+|* XGradientTable::XGradientTable()
+|*
+*************************************************************************/
+
+XGradientTable::XGradientTable( const String& rPath,
+ XOutdevItemPool* pInPool,
+ USHORT nInitSize, USHORT nReSize ) :
+ XPropertyTable( rPath, pInPool, nInitSize, nReSize)
+{
+ pBmpTable = new Table( nInitSize, nReSize );
+}
+
+/************************************************************************/
+
+XGradientTable::~XGradientTable()
+{
+}
+
+/************************************************************************/
+
+XGradientEntry* XGradientTable::Replace(long nIndex, XGradientEntry* pEntry )
+{
+ return (XGradientEntry*) XPropertyTable::Replace(nIndex, pEntry);
+}
+
+/************************************************************************/
+
+XGradientEntry* XGradientTable::Remove(long nIndex)
+{
+ return (XGradientEntry*) XPropertyTable::Remove(nIndex, 0);
+}
+
+/************************************************************************/
+
+XGradientEntry* XGradientTable::GetGradient(long nIndex) const
+{
+ return (XGradientEntry*) XPropertyTable::Get(nIndex, 0);
+}
+
+/************************************************************************/
+
+BOOL XGradientTable::Load()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XGradientTable::Save()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XGradientTable::Create()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XGradientTable::CreateBitmapsForUI()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+Bitmap* XGradientTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/)
+{
+ return( NULL );
+}
+
+// --------------------
+// class XGradientList
+// --------------------
+
+class impXGradientList
+{
+private:
+ VirtualDevice* mpVirtualDevice;
+ SdrModel* mpSdrModel;
+ SdrObject* mpBackgroundObject;
+
+public:
+ impXGradientList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB)
+ : mpVirtualDevice(pV),
+ mpSdrModel(pM),
+ mpBackgroundObject(pB)
+ {}
+
+ ~impXGradientList()
+ {
+ delete mpVirtualDevice;
+ SdrObject::Free(mpBackgroundObject);
+ delete mpSdrModel;
+ }
+
+ VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; }
+ SdrObject* getBackgroundObject() const { return mpBackgroundObject; }
+};
+
+void XGradientList::impCreate()
+{
+ if(!mpData)
+ {
+ const Point aZero(0, 0);
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ VirtualDevice* pVirDev = new VirtualDevice;
+ OSL_ENSURE(0 != pVirDev, "XGradientList: no VirtualDevice created!" );
+ pVirDev->SetMapMode(MAP_100TH_MM);
+ const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH, BITMAP_HEIGHT)));
+ pVirDev->SetOutputSize(aSize);
+ pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode()
+ ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
+ : DRAWMODE_DEFAULT);
+
+ SdrModel* pSdrModel = new SdrModel();
+ OSL_ENSURE(0 != pSdrModel, "XGradientList: no SdrModel created!" );
+ pSdrModel->GetItemPool().FreezeIdRanges();
+
+ const Size aSinglePixel(pVirDev->PixelToLogic(Size(1, 1)));
+ const Rectangle aBackgroundSize(aZero, Size(aSize.getWidth() - aSinglePixel.getWidth(), aSize.getHeight() - aSinglePixel.getHeight()));
+ SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize);
+ OSL_ENSURE(0 != pBackgroundObject, "XGradientList: no BackgroundObject created!" );
+ pBackgroundObject->SetModel(pSdrModel);
+ pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_GRADIENT));
+ pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_SOLID));
+ pBackgroundObject->SetMergedItem(XLineColorItem(String(), Color(COL_BLACK)));
+ pBackgroundObject->SetMergedItem(XGradientStepCountItem(sal_uInt16((BITMAP_WIDTH + BITMAP_HEIGHT) / 3)));
+
+ mpData = new impXGradientList(pVirDev, pSdrModel, pBackgroundObject);
+ OSL_ENSURE(0 != mpData, "XGradientList: data creation went wrong!" );
+ }
+}
+
+void XGradientList::impDestroy()
+{
+ if(mpData)
+ {
+ delete mpData;
+ mpData = 0;
+ }
+}
+
+XGradientList::XGradientList( const String& rPath, XOutdevItemPool* pInPool, sal_uInt16 nInitSize, sal_uInt16 nReSize)
+: XPropertyList(rPath, pInPool, nInitSize, nReSize),
+ mpData(0)
+{
+ pBmpList = new List(nInitSize, nReSize);
+}
+
+XGradientList::~XGradientList()
+{
+ if(mpData)
+ {
+ delete mpData;
+ mpData = 0;
+ }
+}
+
+XGradientEntry* XGradientList::Replace(XGradientEntry* pEntry, long nIndex )
+{
+ return( (XGradientEntry*) XPropertyList::Replace( pEntry, nIndex ) );
+}
+
+XGradientEntry* XGradientList::Remove(long nIndex)
+{
+ return( (XGradientEntry*) XPropertyList::Remove( nIndex, 0 ) );
+}
+
+XGradientEntry* XGradientList::GetGradient(long nIndex) const
+{
+ return( (XGradientEntry*) XPropertyList::Get( nIndex, 0 ) );
+}
+
+BOOL XGradientList::Load()
+{
+ if( bListDirty )
+ {
+ bListDirty = FALSE;
+
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtGradient, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXGradientTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+
+ }
+ return( FALSE );
+}
+
+BOOL XGradientList::Save()
+{
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtGradient, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXGradientTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+}
+
+BOOL XGradientList::Create()
+{
+ XubString aStr( SVX_RES( RID_SVXSTR_GRADIENT ) );
+ xub_StrLen nLen;
+
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(new XGradientEntry(XGradient(RGB_Color(COL_BLACK ),RGB_Color(COL_WHITE ),XGRAD_LINEAR , 0,10,10, 0,100,100),aStr));
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(new XGradientEntry(XGradient(RGB_Color(COL_BLUE ),RGB_Color(COL_RED ),XGRAD_AXIAL , 300,20,20,10,100,100),aStr));
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(new XGradientEntry(XGradient(RGB_Color(COL_RED ),RGB_Color(COL_YELLOW ),XGRAD_RADIAL , 600,30,30,20,100,100),aStr));
+ aStr.SetChar(nLen, sal_Unicode('4'));
+ Insert(new XGradientEntry(XGradient(RGB_Color(COL_YELLOW ),RGB_Color(COL_GREEN ),XGRAD_ELLIPTICAL, 900,40,40,30,100,100),aStr));
+ aStr.SetChar(nLen, sal_Unicode('5'));
+ Insert(new XGradientEntry(XGradient(RGB_Color(COL_GREEN ),RGB_Color(COL_MAGENTA),XGRAD_SQUARE , 1200,50,50,40,100,100),aStr));
+ aStr.SetChar(nLen, sal_Unicode('6'));
+ Insert(new XGradientEntry(XGradient(RGB_Color(COL_MAGENTA),RGB_Color(COL_YELLOW ),XGRAD_RECT , 1900,60,60,50,100,100),aStr));
+
+ return( TRUE );
+}
+
+BOOL XGradientList::CreateBitmapsForUI()
+{
+ impCreate();
+
+ for( long i = 0; i < Count(); i++)
+ {
+ Bitmap* pBmp = CreateBitmapForUI( i, FALSE );
+ DBG_ASSERT( pBmp, "XGradientList: Bitmap(UI) konnte nicht erzeugt werden!" );
+
+ if( pBmp )
+ pBmpList->Insert( pBmp, i );
+ }
+
+ impDestroy();
+
+ return( FALSE );
+}
+
+Bitmap* XGradientList::CreateBitmapForUI( long nIndex, BOOL bDelete )
+{
+ impCreate();
+ VirtualDevice* pVD = mpData->getVirtualDevice();
+ SdrObject* pBackgroundObject = mpData->getBackgroundObject();
+
+ const SfxItemSet& rItemSet = pBackgroundObject->GetMergedItemSet();
+ pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_GRADIENT));
+ pBackgroundObject->SetMergedItem(XFillGradientItem(rItemSet.GetPool(), GetGradient(nIndex)->GetGradient()));
+
+ sdr::contact::SdrObjectVector aObjectVector;
+ aObjectVector.push_back(pBackgroundObject);
+ sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0);
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ aPainter.ProcessDisplay(aDisplayInfo);
+
+ const Point aZero(0, 0);
+ Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize()));
+
+ if(bDelete)
+ {
+ impDestroy();
+ }
+
+ return pBitmap;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xtabhtch.cxx b/svx/source/xoutdev/xtabhtch.cxx
new file mode 100644
index 000000000000..a35389ee8fa2
--- /dev/null
+++ b/svx/source/xoutdev/xtabhtch.cxx
@@ -0,0 +1,377 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#ifndef SVX_LIGHT
+
+#include <com/sun/star/container/XNameContainer.hpp>
+#include "XPropertyTable.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+#include <vcl/svapp.hxx>
+
+#include "xmlxtexp.hxx"
+#include "xmlxtimp.hxx"
+
+#endif
+
+#include <tools/urlobj.hxx>
+#include <vcl/virdev.hxx>
+#include <svl/itemset.hxx>
+#include <sfx2/docfile.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <svx/xtable.hxx>
+#include <svx/xpool.hxx>
+#include "dlgutil.hxx"
+#include <svx/xflhtit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xfillit0.hxx>
+
+#include <svx/svdorect.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include <svx/xlnclit.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+
+sal_Unicode const pszExtHatch[] = {'s','o','h'};
+
+char const aChckHatch[] = { 0x04, 0x00, 'S','O','H','L'}; // < 5.2
+char const aChckHatch0[] = { 0x04, 0x00, 'S','O','H','0'}; // = 5.2
+char const aChckXML[] = { '<', '?', 'x', 'm', 'l' }; // = 6.0
+
+// ------------------
+// class XHatchTable
+// ------------------
+
+/*************************************************************************
+|*
+|* XHatchTable::XHatchTable()
+|*
+*************************************************************************/
+
+XHatchTable::XHatchTable( const String& rPath,
+ XOutdevItemPool* pInPool,
+ USHORT nInitSize, USHORT nReSize ) :
+ XPropertyTable( rPath, pInPool, nInitSize, nReSize)
+{
+ pBmpTable = new Table( nInitSize, nReSize );
+}
+
+/************************************************************************/
+
+XHatchTable::~XHatchTable()
+{
+}
+
+/************************************************************************/
+
+XHatchEntry* XHatchTable::Replace(long nIndex, XHatchEntry* pEntry )
+{
+ return (XHatchEntry*) XPropertyTable::Replace(nIndex, pEntry);
+}
+
+/************************************************************************/
+
+XHatchEntry* XHatchTable::Remove(long nIndex)
+{
+ return (XHatchEntry*) XPropertyTable::Remove(nIndex, 0);
+}
+
+/************************************************************************/
+
+XHatchEntry* XHatchTable::GetHatch(long nIndex) const
+{
+ return (XHatchEntry*) XPropertyTable::Get(nIndex, 0);
+}
+
+/************************************************************************/
+
+BOOL XHatchTable::Load()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XHatchTable::Save()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XHatchTable::Create()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XHatchTable::CreateBitmapsForUI()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+Bitmap* XHatchTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/)
+{
+ return( NULL );
+}
+
+// -----------------
+// class XHatchList
+// -----------------
+
+class impXHatchList
+{
+private:
+ VirtualDevice* mpVirtualDevice;
+ SdrModel* mpSdrModel;
+ SdrObject* mpBackgroundObject;
+ SdrObject* mpHatchObject;
+
+public:
+ impXHatchList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB, SdrObject* pH)
+ : mpVirtualDevice(pV),
+ mpSdrModel(pM),
+ mpBackgroundObject(pB),
+ mpHatchObject(pH)
+ {}
+
+ ~impXHatchList()
+ {
+ delete mpVirtualDevice;
+ SdrObject::Free(mpBackgroundObject);
+ SdrObject::Free(mpHatchObject);
+ delete mpSdrModel;
+ }
+
+ VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; }
+ SdrObject* getBackgroundObject() const { return mpBackgroundObject; }
+ SdrObject* getHatchObject() const { return mpHatchObject; }
+};
+
+void XHatchList::impCreate()
+{
+ if(!mpData)
+ {
+ const Point aZero(0, 0);
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ VirtualDevice* pVirDev = new VirtualDevice;
+ OSL_ENSURE(0 != pVirDev, "XDashList: no VirtualDevice created!" );
+ pVirDev->SetMapMode(MAP_100TH_MM);
+ const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH, BITMAP_HEIGHT)));
+ pVirDev->SetOutputSize(aSize);
+ pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode()
+ ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
+ : DRAWMODE_DEFAULT);
+
+ SdrModel* pSdrModel = new SdrModel();
+ OSL_ENSURE(0 != pSdrModel, "XDashList: no SdrModel created!" );
+ pSdrModel->GetItemPool().FreezeIdRanges();
+
+ const Size aSinglePixel(pVirDev->PixelToLogic(Size(1, 1)));
+ const Rectangle aBackgroundSize(aZero, Size(aSize.getWidth() - aSinglePixel.getWidth(), aSize.getHeight() - aSinglePixel.getHeight()));
+ SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize);
+ OSL_ENSURE(0 != pBackgroundObject, "XDashList: no BackgroundObject created!" );
+ pBackgroundObject->SetModel(pSdrModel);
+ pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_SOLID));
+ pBackgroundObject->SetMergedItem(XFillColorItem(String(), rStyleSettings.GetFieldColor()));
+ pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_SOLID));
+ pBackgroundObject->SetMergedItem(XLineColorItem(String(), Color(COL_BLACK)));
+
+ SdrObject* pHatchObject = new SdrRectObj(aBackgroundSize);
+ OSL_ENSURE(0 != pHatchObject, "XDashList: no HatchObject created!" );
+ pHatchObject->SetModel(pSdrModel);
+ pHatchObject->SetMergedItem(XFillStyleItem(XFILL_HATCH));
+ pHatchObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
+
+ mpData = new impXHatchList(pVirDev, pSdrModel, pBackgroundObject, pHatchObject);
+ OSL_ENSURE(0 != mpData, "XDashList: data creation went wrong!" );
+ }
+}
+
+void XHatchList::impDestroy()
+{
+ if(mpData)
+ {
+ delete mpData;
+ mpData = 0;
+ }
+}
+
+XHatchList::XHatchList(const String& rPath, XOutdevItemPool* pInPool, sal_uInt16 nInitSize, sal_uInt16 nReSize)
+: XPropertyList(rPath, pInPool, nInitSize, nReSize),
+ mpData(0)
+{
+ pBmpList = new List(nInitSize, nReSize);
+}
+
+XHatchList::~XHatchList()
+{
+ if(mpData)
+ {
+ delete mpData;
+ mpData = 0;
+ }
+}
+
+XHatchEntry* XHatchList::Replace(XHatchEntry* pEntry, long nIndex )
+{
+ return (XHatchEntry*) XPropertyList::Replace(pEntry, nIndex);
+}
+
+XHatchEntry* XHatchList::Remove(long nIndex)
+{
+ return (XHatchEntry*) XPropertyList::Remove(nIndex, 0);
+}
+
+XHatchEntry* XHatchList::GetHatch(long nIndex) const
+{
+ return (XHatchEntry*) XPropertyList::Get(nIndex, 0);
+}
+
+BOOL XHatchList::Load()
+{
+ if( bListDirty )
+ {
+ bListDirty = FALSE;
+
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtHatch, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXHatchTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+ }
+ return( FALSE );
+}
+
+BOOL XHatchList::Save()
+{
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtHatch, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXHatchTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+}
+
+BOOL XHatchList::Create()
+{
+ XubString aStr( SVX_RES( RID_SVXSTR_HATCH ) );
+ xub_StrLen nLen;
+
+ aStr.AppendAscii(" 1");
+ nLen = aStr.Len() - 1;
+ Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLACK),XHATCH_SINGLE,100, 0),aStr));
+ aStr.SetChar(nLen, sal_Unicode('2'));
+ Insert(new XHatchEntry(XHatch(RGB_Color(COL_RED ),XHATCH_DOUBLE, 80,450),aStr));
+ aStr.SetChar(nLen, sal_Unicode('3'));
+ Insert(new XHatchEntry(XHatch(RGB_Color(COL_BLUE ),XHATCH_TRIPLE,120, 0),aStr));
+
+ return( TRUE );
+}
+
+BOOL XHatchList::CreateBitmapsForUI()
+{
+ impCreate();
+
+ for( long i = 0; i < Count(); i++)
+ {
+ Bitmap* pBmp = CreateBitmapForUI( i, FALSE );
+ DBG_ASSERT( pBmp, "XHatchList: Bitmap(UI) konnte nicht erzeugt werden!" );
+
+ if( pBmp )
+ pBmpList->Insert( pBmp, i );
+ }
+
+ impDestroy();
+
+ return( TRUE );
+}
+
+Bitmap* XHatchList::CreateBitmapForUI( long nIndex, BOOL bDelete )
+{
+ impCreate();
+ VirtualDevice* pVD = mpData->getVirtualDevice();
+ SdrObject* pHatchObject = mpData->getHatchObject();
+
+ pHatchObject->SetMergedItem(XFillStyleItem(XFILL_HATCH));
+ pHatchObject->SetMergedItem(XFillHatchItem(String(), GetHatch(nIndex)->GetHatch()));
+
+ sdr::contact::SdrObjectVector aObjectVector;
+ aObjectVector.push_back(mpData->getBackgroundObject());
+ aObjectVector.push_back(pHatchObject);
+ sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0);
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ aPainter.ProcessDisplay(aDisplayInfo);
+
+ const Point aZero(0, 0);
+ Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize()));
+
+ if(bDelete)
+ {
+ impDestroy();
+ }
+
+ return pBitmap;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xtable.cxx b/svx/source/xoutdev/xtable.cxx
new file mode 100644
index 000000000000..7cd13e0bc664
--- /dev/null
+++ b/svx/source/xoutdev/xtable.cxx
@@ -0,0 +1,513 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+#include <svx/xtable.hxx>
+#include <svx/xpool.hxx>
+
+#define GLOBALOVERFLOW
+
+// Vergleichsstrings
+sal_Unicode __FAR_DATA pszStandard[] = { 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', 0 };
+
+// Konvertiert in echte RGB-Farben, damit in den Listboxen
+// endlich mal richtig selektiert werden kann.
+Color RGB_Color( ColorData nColorName )
+{
+ Color aColor( nColorName );
+ Color aRGBColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() );
+ return aRGBColor;
+}
+
+// ---------------------
+// class XPropertyTable
+// ---------------------
+
+/*************************************************************************
+|*
+|* XPropertyTable::XPropertyTable()
+|*
+*************************************************************************/
+
+XPropertyTable::XPropertyTable( const String& rPath,
+ XOutdevItemPool* pInPool,
+ USHORT nInitSize, USHORT nReSize ) :
+ aName ( pszStandard, 8 ),
+ aPath ( rPath ),
+ pXPool ( pInPool ),
+ aTable ( nInitSize, nReSize ),
+ pBmpTable ( NULL ),
+ bTableDirty ( TRUE ),
+ bBitmapsDirty ( TRUE ),
+ bOwnPool ( FALSE )
+{
+ if( !pXPool )
+ {
+ bOwnPool = TRUE;
+ pXPool = new XOutdevItemPool;
+ DBG_ASSERT( pXPool, "XOutPool konnte nicht erzeugt werden!" );
+ }
+}
+
+/*************************************************************************
+|*
+|* XPropertyTable::XPropertyTable( SvStraem& )
+|*
+*************************************************************************/
+
+XPropertyTable::XPropertyTable( SvStream& /*rIn*/) :
+ pBmpTable ( NULL )
+{
+}
+
+/*************************************************************************
+|*
+|* XPropertyTable::~XPropertyTable()
+|*
+*************************************************************************/
+
+XPropertyTable::~XPropertyTable()
+{
+ XPropertyEntry* pEntry = (XPropertyEntry*)aTable.First();
+ Bitmap* pBitmap = NULL;
+ for (ULONG nIndex = 0; nIndex < aTable.Count(); nIndex++)
+ {
+ delete pEntry;
+ pEntry = (XPropertyEntry*)aTable.Next();
+ }
+ // Hier wird die Bitmaptabelle geloescht
+ if( pBmpTable )
+ {
+ pBitmap = (Bitmap*) pBmpTable->First();
+
+ for( ULONG nIndex = 0; nIndex < pBmpTable->Count(); nIndex++ )
+ {
+ delete pBitmap;
+ pBitmap = (Bitmap*) pBmpTable->Next();
+ }
+ delete pBmpTable;
+ pBmpTable = NULL;
+ }
+ // Eigener Pool wird geloescht
+ if( bOwnPool && pXPool )
+ {
+ SfxItemPool::Free(pXPool);
+ }
+}
+
+/*************************************************************************
+|*
+|* XPropertyTable::Clear()
+|*
+*************************************************************************/
+
+void XPropertyTable::Clear()
+{
+ aTable.Clear();
+ if( pBmpTable )
+ pBmpTable->Clear();
+}
+
+/************************************************************************/
+
+long XPropertyTable::Count() const
+{
+ if( bTableDirty )
+ {
+ // ( (XPropertyTable*) this )->bTableDirty = FALSE; <- im Load()
+ if( !( (XPropertyTable*) this )->Load() )
+ ( (XPropertyTable*) this )->Create();
+ }
+ return( aTable.Count() );
+}
+
+/*************************************************************************
+|*
+|* XPropertyEntry* XPropertyTable::Get()
+|*
+*************************************************************************/
+
+XPropertyEntry* XPropertyTable::Get( long nIndex, USHORT /*nDummy*/) const
+{
+ if( bTableDirty )
+ {
+ // ( (XPropertyTable*) this )->bTableDirty = FALSE; <- im Load()
+ if( !( (XPropertyTable*) this )->Load() )
+ ( (XPropertyTable*) this )->Create();
+ }
+ return (XPropertyEntry*) aTable.GetObject( (ULONG) nIndex );
+}
+
+/*************************************************************************
+|*
+|* long XPropertyTable::Get(const String& rName)
+|*
+*************************************************************************/
+
+long XPropertyTable::Get(const XubString& rName)
+{
+ if( bTableDirty )
+ {
+ // bTableDirty = FALSE;
+ if( !Load() )
+ Create();
+ }
+ long nPos = 0;
+ XPropertyEntry* pEntry = (XPropertyEntry*)aTable.First();
+ while (pEntry && pEntry->GetName() != rName)
+ {
+ nPos++;
+ pEntry = (XPropertyEntry*)aTable.Next();
+ }
+ if (!pEntry) nPos = -1;
+ return nPos;
+}
+
+/*************************************************************************
+|*
+|* Bitmap* XPropertyTable::GetBitmap()
+|*
+*************************************************************************/
+
+Bitmap* XPropertyTable::GetBitmap( long nIndex ) const
+{
+ if( pBmpTable )
+ {
+ if( bBitmapsDirty )
+ {
+ ( (XPropertyTable*) this )->bBitmapsDirty = FALSE;
+ ( (XPropertyTable*) this )->CreateBitmapsForUI();
+ }
+
+ if( pBmpTable->Count() >= (ULONG) nIndex )
+ return (Bitmap*) pBmpTable->GetObject( (ULONG) nIndex );
+ }
+ return( NULL );
+}
+
+/*************************************************************************
+|*
+|* void XPropertyTable::Insert()
+|*
+*************************************************************************/
+
+BOOL XPropertyTable::Insert( long nIndex, XPropertyEntry* pEntry )
+{
+ BOOL bReturn = aTable.Insert( (ULONG) nIndex, pEntry );
+
+ if( pBmpTable && !bBitmapsDirty )
+ {
+ Bitmap* pBmp = CreateBitmapForUI( (ULONG) nIndex );
+ pBmpTable->Insert( (ULONG) nIndex, pBmp );
+ }
+ return bReturn;
+}
+
+/*************************************************************************
+|*
+|* void XPropertyTable::Replace()
+|*
+*************************************************************************/
+
+XPropertyEntry* XPropertyTable::Replace( long nIndex, XPropertyEntry* pEntry )
+{
+ XPropertyEntry* pOldEntry = (XPropertyEntry*) aTable.Replace( (ULONG) nIndex, pEntry );
+
+ if( pBmpTable && !bBitmapsDirty )
+ {
+ Bitmap* pBmp = CreateBitmapForUI( (ULONG) nIndex );
+ Bitmap* pOldBmp = (Bitmap*) pBmpTable->Replace( (ULONG) nIndex, pBmp );
+ if( pOldBmp )
+ delete pOldBmp;
+ }
+ return pOldEntry;
+}
+
+/*************************************************************************
+|*
+|* void XPropertyTable::Remove()
+|*
+*************************************************************************/
+
+XPropertyEntry* XPropertyTable::Remove( long nIndex, USHORT /*nDummy*/)
+{
+ if( pBmpTable && !bBitmapsDirty )
+ {
+ Bitmap* pOldBmp = (Bitmap*) pBmpTable->Remove( (ULONG) nIndex );
+ if( pOldBmp )
+ delete pOldBmp;
+ }
+ return (XPropertyEntry*) aTable.Remove((ULONG)nIndex);
+}
+
+/************************************************************************/
+
+void XPropertyTable::SetName( const String& rString )
+{
+ if(rString.Len())
+ {
+ aName = rString;
+ }
+}
+
+// --------------------
+// class XPropertyList
+// --------------------
+
+
+/*************************************************************************
+|*
+|* XPropertyList::XPropertyList()
+|*
+*************************************************************************/
+
+XPropertyList::XPropertyList( const String& rPath,
+ XOutdevItemPool* pInPool,
+ USHORT nInitSize, USHORT nReSize ) :
+ aName ( pszStandard, 8 ),
+ aPath ( rPath ),
+ pXPool ( pInPool ),
+ aList ( nInitSize, nReSize ),
+ pBmpList ( NULL ),
+ bListDirty ( TRUE ),
+ bBitmapsDirty ( TRUE ),
+ bOwnPool ( FALSE )
+{
+ if( !pXPool )
+ {
+ bOwnPool = TRUE;
+ pXPool = new XOutdevItemPool;
+ DBG_ASSERT( pXPool, "XOutPool konnte nicht erzeugt werden!" );
+ }
+}
+
+/*************************************************************************
+|*
+|* XPropertyList::XPropertyList( SvStraem& )
+|*
+*************************************************************************/
+
+XPropertyList::XPropertyList( SvStream& /*rIn*/) :
+ pBmpList ( NULL )
+{
+}
+
+/*************************************************************************
+|*
+|* XPropertyList::~XPropertyList()
+|*
+*************************************************************************/
+
+XPropertyList::~XPropertyList()
+{
+ XPropertyEntry* pEntry = (XPropertyEntry*)aList.First();
+ Bitmap* pBitmap = NULL;
+ for( ULONG nIndex = 0; nIndex < aList.Count(); nIndex++ )
+ {
+ delete pEntry;
+ pEntry = (XPropertyEntry*)aList.Next();
+ }
+
+ if( pBmpList )
+ {
+ pBitmap = (Bitmap*) pBmpList->First();
+
+ for( ULONG nIndex = 0; nIndex < pBmpList->Count(); nIndex++ )
+ {
+ delete pBitmap;
+ pBitmap = (Bitmap*) pBmpList->Next();
+ }
+ delete pBmpList;
+ pBmpList = NULL;
+ }
+
+ if( bOwnPool && pXPool )
+ {
+ SfxItemPool::Free(pXPool);
+ }
+}
+
+/*************************************************************************
+|*
+|* XPropertyList::Clear()
+|*
+*************************************************************************/
+
+void XPropertyList::Clear()
+{
+ aList.Clear();
+ if( pBmpList )
+ pBmpList->Clear();
+}
+
+/************************************************************************/
+
+long XPropertyList::Count() const
+{
+ if( bListDirty )
+ {
+ // ( (XPropertyList*) this )->bListDirty = FALSE; <- im Load()
+ if( !( (XPropertyList*) this )->Load() )
+ ( (XPropertyList*) this )->Create();
+ }
+ return( aList.Count() );
+}
+
+/*************************************************************************
+|*
+|* XPropertyEntry* XPropertyList::Get()
+|*
+*************************************************************************/
+
+XPropertyEntry* XPropertyList::Get( long nIndex, USHORT /*nDummy*/) const
+{
+ if( bListDirty )
+ {
+ // ( (XPropertyList*) this )->bListDirty = FALSE; <- im Load()
+ if( !( (XPropertyList*) this )->Load() )
+ ( (XPropertyList*) this )->Create();
+ }
+ return (XPropertyEntry*) aList.GetObject( (ULONG) nIndex );
+}
+
+/*************************************************************************
+|*
+|* XPropertyList::Get()
+|*
+*************************************************************************/
+
+long XPropertyList::Get(const XubString& rName)
+{
+ if( bListDirty )
+ {
+ //bListDirty = FALSE;
+ if( !Load() )
+ Create();
+ }
+ long nPos = 0;
+ XPropertyEntry* pEntry = (XPropertyEntry*)aList.First();
+ while (pEntry && pEntry->GetName() != rName)
+ {
+ nPos++;
+ pEntry = (XPropertyEntry*)aList.Next();
+ }
+ if (!pEntry) nPos = -1;
+ return nPos;
+}
+
+/*************************************************************************
+|*
+|* Bitmap* XPropertyList::GetBitmap()
+|*
+*************************************************************************/
+
+Bitmap* XPropertyList::GetBitmap( long nIndex ) const
+{
+ if( pBmpList )
+ {
+ if( bBitmapsDirty )
+ {
+ ( (XPropertyList*) this )->bBitmapsDirty = FALSE;
+ ( (XPropertyList*) this )->CreateBitmapsForUI();
+ }
+ if( pBmpList->Count() >= (ULONG) nIndex )
+ return (Bitmap*) pBmpList->GetObject( (ULONG) nIndex );
+ }
+ return( NULL );
+}
+
+/*************************************************************************
+|*
+|* void XPropertyList::Insert()
+|*
+*************************************************************************/
+
+void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex )
+{
+ aList.Insert( pEntry, (ULONG) nIndex );
+
+ if( pBmpList && !bBitmapsDirty )
+ {
+ Bitmap* pBmp = CreateBitmapForUI(
+ (ULONG) nIndex < aList.Count() ? nIndex : aList.Count() - 1 );
+ pBmpList->Insert( pBmp, (ULONG) nIndex );
+ }
+}
+
+/*************************************************************************
+|*
+|* void XPropertyList::Replace()
+|*
+*************************************************************************/
+
+XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex )
+{
+ XPropertyEntry* pOldEntry = (XPropertyEntry*) aList.Replace( pEntry, (ULONG) nIndex );
+
+ if( pBmpList && !bBitmapsDirty )
+ {
+ Bitmap* pBmp = CreateBitmapForUI( (ULONG) nIndex );
+ Bitmap* pOldBmp = (Bitmap*) pBmpList->Replace( pBmp, (ULONG) nIndex );
+ if( pOldBmp )
+ delete pOldBmp;
+ }
+ return pOldEntry;
+}
+
+/*************************************************************************
+|*
+|* void XPropertyList::Remove()
+|*
+*************************************************************************/
+
+XPropertyEntry* XPropertyList::Remove( long nIndex, USHORT /*nDummy*/)
+{
+ if( pBmpList && !bBitmapsDirty )
+ {
+ Bitmap* pOldBmp = (Bitmap*) pBmpList->Remove( (ULONG) nIndex );
+ if( pOldBmp )
+ delete pOldBmp;
+ }
+ return (XPropertyEntry*) aList.Remove( (ULONG) nIndex );
+}
+
+/************************************************************************/
+
+void XPropertyList::SetName( const String& rString )
+{
+ if(rString.Len())
+ {
+ aName = rString;
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/xoutdev/xtablend.cxx b/svx/source/xoutdev/xtablend.cxx
new file mode 100644
index 000000000000..cd0c8446871b
--- /dev/null
+++ b/svx/source/xoutdev/xtablend.cxx
@@ -0,0 +1,396 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * 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_svx.hxx"
+
+// include ---------------------------------------------------------------
+
+#ifndef SVX_LIGHT
+
+#include <com/sun/star/container/XNameContainer.hpp>
+#include "XPropertyTable.hxx"
+#include <unotools/ucbstreamhelper.hxx>
+
+#include "xmlxtexp.hxx"
+#include "xmlxtimp.hxx"
+
+#endif
+#include <tools/urlobj.hxx>
+#include <vcl/virdev.hxx>
+
+#include <vcl/svapp.hxx>
+#include <svl/itemset.hxx>
+#include <sfx2/docfile.hxx>
+
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+
+#include <svx/xtable.hxx>
+#include <svx/xpool.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnedit.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+
+#include <svx/svdorect.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+
+#define GLOBALOVERFLOW
+
+using namespace com::sun::star;
+using namespace rtl;
+
+sal_Unicode const pszExtLineEnd[] = {'s','o','e'};
+
+static char const aChckLEnd[] = { 0x04, 0x00, 'S','O','E','L'}; // < 5.2
+static char const aChckLEnd0[] = { 0x04, 0x00, 'S','O','E','0'}; // = 5.2
+static char const aChckXML[] = { '<', '?', 'x', 'm', 'l' }; // = 6.0
+
+// --------------------
+// class XLineEndTable
+// --------------------
+
+/*************************************************************************
+|*
+|* XLineEndTable::XLineEndTable()
+|*
+*************************************************************************/
+
+XLineEndTable::XLineEndTable( const String& rPath,
+ XOutdevItemPool* pInPool,
+ USHORT nInitSize, USHORT nReSize ) :
+ XPropertyTable( rPath, pInPool, nInitSize, nReSize)
+{
+ pBmpTable = new Table( nInitSize, nReSize );
+}
+
+/************************************************************************/
+
+XLineEndTable::~XLineEndTable()
+{
+}
+
+/************************************************************************/
+
+XLineEndEntry* XLineEndTable::Replace(long nIndex, XLineEndEntry* pEntry )
+{
+ return (XLineEndEntry*) XPropertyTable::Replace(nIndex, pEntry);
+}
+
+/************************************************************************/
+
+XLineEndEntry* XLineEndTable::Remove(long nIndex)
+{
+ return (XLineEndEntry*) XPropertyTable::Remove(nIndex, 0);
+}
+
+/************************************************************************/
+
+XLineEndEntry* XLineEndTable::GetLineEnd(long nIndex) const
+{
+ return (XLineEndEntry*) XPropertyTable::Get(nIndex, 0);
+}
+
+/************************************************************************/
+
+BOOL XLineEndTable::Load()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XLineEndTable::Save()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+BOOL XLineEndTable::Create()
+{
+ return( FALSE );
+}
+
+/************************************************************************/
+
+Bitmap* XLineEndTable::CreateBitmapForUI( long /*nIndex*/, BOOL /*bDelete*/)
+{
+ return( NULL );
+}
+
+/************************************************************************/
+
+BOOL XLineEndTable::CreateBitmapsForUI()
+{
+ return( FALSE );
+}
+
+// --------------------
+// class XLineEndList
+// --------------------
+
+class impXLineEndList
+{
+private:
+ VirtualDevice* mpVirtualDevice;
+ SdrModel* mpSdrModel;
+ SdrObject* mpBackgroundObject;
+ SdrObject* mpLineObject;
+
+public:
+ impXLineEndList(VirtualDevice* pV, SdrModel* pM, SdrObject* pB, SdrObject* pL)
+ : mpVirtualDevice(pV),
+ mpSdrModel(pM),
+ mpBackgroundObject(pB),
+ mpLineObject(pL)
+ {}
+
+ ~impXLineEndList()
+ {
+ delete mpVirtualDevice;
+ SdrObject::Free(mpBackgroundObject);
+ SdrObject::Free(mpLineObject);
+ delete mpSdrModel;
+ }
+
+ VirtualDevice* getVirtualDevice() const { return mpVirtualDevice; }
+ SdrObject* getBackgroundObject() const { return mpBackgroundObject; }
+ SdrObject* getLineObject() const { return mpLineObject; }
+};
+
+void XLineEndList::impCreate()
+{
+ if(!mpData)
+ {
+ const Point aZero(0, 0);
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ VirtualDevice* pVirDev = new VirtualDevice;
+ OSL_ENSURE(0 != pVirDev, "XLineEndList: no VirtualDevice created!" );
+ pVirDev->SetMapMode(MAP_100TH_MM);
+ const Size aSize(pVirDev->PixelToLogic(Size(BITMAP_WIDTH * 2, BITMAP_HEIGHT)));
+ pVirDev->SetOutputSize(aSize);
+ pVirDev->SetDrawMode(rStyleSettings.GetHighContrastMode()
+ ? DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT
+ : DRAWMODE_DEFAULT);
+
+ SdrModel* pSdrModel = new SdrModel();
+ OSL_ENSURE(0 != pSdrModel, "XLineEndList: no SdrModel created!" );
+ pSdrModel->GetItemPool().FreezeIdRanges();
+
+ const Rectangle aBackgroundSize(aZero, aSize);
+ SdrObject* pBackgroundObject = new SdrRectObj(aBackgroundSize);
+ OSL_ENSURE(0 != pBackgroundObject, "XLineEndList: no BackgroundObject created!" );
+ pBackgroundObject->SetModel(pSdrModel);
+ pBackgroundObject->SetMergedItem(XFillStyleItem(XFILL_SOLID));
+ pBackgroundObject->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ pBackgroundObject->SetMergedItem(XFillColorItem(String(), rStyleSettings.GetFieldColor()));
+
+ const basegfx::B2DPoint aStart(0, aSize.Height() / 2);
+ const basegfx::B2DPoint aEnd(aSize.Width(), aSize.Height() / 2);
+ basegfx::B2DPolygon aPolygon;
+ aPolygon.append(aStart);
+ aPolygon.append(aEnd);
+ SdrObject* pLineObject = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPolygon));
+ OSL_ENSURE(0 != pLineObject, "XLineEndList: no LineObject created!" );
+ pLineObject->SetModel(pSdrModel);
+ pLineObject->SetMergedItem(XLineStartWidthItem(aSize.Height()));
+ pLineObject->SetMergedItem(XLineEndWidthItem(aSize.Height()));
+ pLineObject->SetMergedItem(XLineColorItem(String(), rStyleSettings.GetFieldTextColor()));
+
+ mpData = new impXLineEndList(pVirDev, pSdrModel, pBackgroundObject, pLineObject);
+ OSL_ENSURE(0 != mpData, "XLineEndList: data creation went wrong!" );
+ }
+}
+
+void XLineEndList::impDestroy()
+{
+ if(mpData)
+ {
+ delete mpData;
+ mpData = 0;
+ }
+}
+
+XLineEndList::XLineEndList(const String& rPath, XOutdevItemPool* _pXPool, sal_uInt16 nInitSize, sal_uInt16 nReSize)
+: XPropertyList(rPath, _pXPool, nInitSize, nReSize),
+ mpData(0)
+{
+ pBmpList = new List(nInitSize, nReSize);
+}
+
+XLineEndList::~XLineEndList()
+{
+ impDestroy();
+}
+
+XLineEndEntry* XLineEndList::Replace(XLineEndEntry* pEntry, long nIndex )
+{
+ return (XLineEndEntry*) XPropertyList::Replace(pEntry, nIndex);
+}
+
+XLineEndEntry* XLineEndList::Remove(long nIndex)
+{
+ return (XLineEndEntry*) XPropertyList::Remove(nIndex, 0);
+}
+
+XLineEndEntry* XLineEndList::GetLineEnd(long nIndex) const
+{
+ return (XLineEndEntry*) XPropertyList::Get(nIndex, 0);
+}
+
+BOOL XLineEndList::Load()
+{
+ if( bListDirty )
+ {
+ bListDirty = FALSE;
+
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtLineEnd, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXLineEndTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+ }
+ return( FALSE );
+}
+
+BOOL XLineEndList::Save()
+{
+ INetURLObject aURL( aPath );
+
+ if( INET_PROT_NOT_VALID == aURL.GetProtocol() )
+ {
+ DBG_ASSERT( !aPath.Len(), "invalid URL" );
+ return FALSE;
+ }
+
+ aURL.Append( aName );
+
+ if( !aURL.getExtension().getLength() )
+ aURL.setExtension( rtl::OUString( pszExtLineEnd, 3 ) );
+
+ uno::Reference< container::XNameContainer > xTable( SvxUnoXLineEndTable_createInstance( this ), uno::UNO_QUERY );
+ return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable );
+}
+
+BOOL XLineEndList::Create()
+{
+ basegfx::B2DPolygon aTriangle;
+ aTriangle.append(basegfx::B2DPoint(10.0, 0.0));
+ aTriangle.append(basegfx::B2DPoint(0.0, 30.0));
+ aTriangle.append(basegfx::B2DPoint(20.0, 30.0));
+ aTriangle.setClosed(true);
+ Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aTriangle), SVX_RESSTR( RID_SVXSTR_ARROW ) ) );
+
+ basegfx::B2DPolygon aSquare;
+ aSquare.append(basegfx::B2DPoint(0.0, 0.0));
+ aSquare.append(basegfx::B2DPoint(10.0, 0.0));
+ aSquare.append(basegfx::B2DPoint(10.0, 10.0));
+ aSquare.append(basegfx::B2DPoint(0.0, 10.0));
+ aSquare.setClosed(true);
+ Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aSquare), SVX_RESSTR( RID_SVXSTR_SQUARE ) ) );
+
+ basegfx::B2DPolygon aCircle(basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0.0, 0.0), 100.0));
+ Insert( new XLineEndEntry( basegfx::B2DPolyPolygon(aCircle), SVX_RESSTR( RID_SVXSTR_CIRCLE ) ) );
+
+ return( TRUE );
+}
+
+BOOL XLineEndList::CreateBitmapsForUI()
+{
+ impCreate();
+
+ for( long i = 0; i < Count(); i++)
+ {
+ Bitmap* pBmp = CreateBitmapForUI( i, FALSE );
+ OSL_ENSURE(0 != pBmp, "XLineEndList: Bitmap(UI) could not be created!" );
+
+ if( pBmp )
+ pBmpList->Insert( pBmp, i );
+ }
+
+ impDestroy();
+
+ return( TRUE );
+}
+
+Bitmap* XLineEndList::CreateBitmapForUI( long nIndex, BOOL bDelete )
+{
+ impCreate();
+ VirtualDevice* pVD = mpData->getVirtualDevice();
+ SdrObject* pLine = mpData->getLineObject();
+
+ pLine->SetMergedItem(XLineStyleItem(XLINE_SOLID));
+ pLine->SetMergedItem(XLineStartItem(String(), GetLineEnd(nIndex)->GetLineEnd()));
+ pLine->SetMergedItem(XLineEndItem(String(), GetLineEnd(nIndex)->GetLineEnd()));
+
+ sdr::contact::SdrObjectVector aObjectVector;
+ aObjectVector.push_back(mpData->getBackgroundObject());
+ aObjectVector.push_back(pLine);
+ sdr::contact::ObjectContactOfObjListPainter aPainter(*pVD, aObjectVector, 0);
+ sdr::contact::DisplayInfo aDisplayInfo;
+
+ aPainter.ProcessDisplay(aDisplayInfo);
+
+ const Point aZero(0, 0);
+ Bitmap* pBitmap = new Bitmap(pVD->GetBitmap(aZero, pVD->GetOutputSize()));
+
+ if(bDelete)
+ {
+ impDestroy();
+ }
+
+ return pBitmap;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */